Restore video system screens and memcpy bug in V_CopyRect

* Restore screen numbers; BG is 4, at least in the ST module.
* Let ST module allocate BG, which is just 32 pixels high and not a full
  VRAM (huge memory gain!)
* Fix V_CopyRect() not working because memcpy is still broken (this will
  be changed later with a proper memcpy)
This commit is contained in:
Lephenixnoir 2021-07-27 14:18:06 +02:00
parent 271d9d588d
commit d7ee5a1bbb
Signed by: Lephenixnoir
GPG Key ID: 1BBA026E13FC0495
7 changed files with 42 additions and 54 deletions

View File

@ -6,11 +6,13 @@
// WAD file access method (enable exactly one)
//---
/* Use BFile dynamically (slow but entirely accurate, a good reference) */
/* Use BFile (100% accurate but slows down the game quite a bit because of
reads happening all the time; mostly a good reference for testing) */
// #define CGDOOM_WAD_BFILE
/* Search fragments in physical ROM and copy by hand (faster) */
/* Search fragments in physical ROM when loading the game, and copy by hand
from ROM to RAM during accesses (much faster) */
#define CGDOOM_WAD_MAPPING
/* Search fragments in phyiscal ROM and copy with DMA (even faster) */
/* Idem, but copy copy with DMA (even faster) */
// #define CGDOOM_WAD_MAPPING_DMA
/* Settings for file mappings: traverse the whole 32-MiB Flash */

4
README
View File

@ -8,10 +8,10 @@ Credit goes to:
TODO:
-> Reenable LTO if possible
-> HUD glitches?
-> Include a proper fast, version of memcpy
-> Try and use more memory regions in z_zone.c
-> Overclocking etc.
-> Improve file mapping speed
-> Improve file mapping speed (DMA)
CGDOOM used to be compiled with the mini-SDK. However, it's become quite
difficult to get a copy of that. Instead, this port is built with a slightly

View File

@ -309,7 +309,27 @@ void ResetData(FileMapping *pMap)
pMap->miCurrentLength = 0;
}
int CreateFileMapping(const unsigned short *pFileName,FileMapping *pMap){
void I_Error (char *error, ...);
#ifdef CGDOOM_WAD_BFILE
int FindInFlash(void **buf, int size, int readpos)
{
return 0;
}
int Flash_ReadFile(void *buf, int size, int readpos)
{
return Bfile_ReadFile_OS(cgdoom_wad_fd, buf, size, readpos);
}
#else /* CGDOOM_WAD_MAPPING, CGDOOM_WAD_MAPPING_DMA */
static FileMapping *gpWADMap = 0;
int CreateFileMapping(const unsigned short *pFileName,FileMapping *pMap)
{
int iResult = 0;
char cBuffer[FLASH_PAGE_SIZE];
int hFile = Bfile_OpenFile_OS(pFileName,0,0);
@ -322,7 +342,7 @@ int CreateFileMapping(const unsigned short *pFileName,FileMapping *pMap){
while(iLength > 0)
{
//do not optimize (= do not move these 2 variables before loop)!
// fx-cg allocates pages for file in <random> order so page from the end of the file
// fx-cg allocates pages for file in <random> order so page from the end of the file
//can have lower index than page from the beginning
const char *pTgt = pFlashFS;
int iPageIndx = 0;
@ -392,24 +412,7 @@ int CreateFileMapping(const unsigned short *pFileName,FileMapping *pMap){
lbExit:
Bfile_CloseFile_OS(hFile);
return iResult;
}
void I_Error (char *error, ...);
static FileMapping *gpWADMap = 0;
#ifdef CGDOOM_WAD_BFILE
int FindInFlash(void **buf, int size, int readpos)
{
return 0;
}
int Flash_ReadFile(void *buf, int size, int readpos)
{
return Bfile_ReadFile_OS(cgdoom_wad_fd, buf, size, readpos);
}
#else /* CGDOOM_WAD_MAPPING, CGDOOM_WAD_MAPPING_DMA */
int FindInFlash(void **buf, int size, int readpos)
{

View File

@ -558,8 +558,6 @@ void R_SetViewSize( int blocks)
setblocks = blocks;
}
void V_Clear();
//
// R_ExecuteSetViewSize
//
@ -573,7 +571,6 @@ void R_ExecuteSetViewSize (void)
int startmap;
setsizeneeded = false;
V_Clear();
if (setblocks == 11)
{

View File

@ -427,7 +427,6 @@ void ST_refreshBackground(void)
V_CopyRect(ST_X, 0, BG, ST_WIDTH, ST_HEIGHT, ST_X, ST_Y, FG);
}
}
@ -474,13 +473,13 @@ void CGSwitchClip()
}
}
void CGFreeMem()
{
static char cRAMBuff[16];
int iFree = Z_FreeMemory();
CGDAppendNum0_999("Free:",iFree,0,cRAMBuff);
plyr->message = cRAMBuff;
}
void CGFreeMem()
{
static char cRAMBuff[16];
int iFree = Z_FreeMemory();
CGDAppendNum0_999("Free:",iFree,0,cRAMBuff);
plyr->message = cRAMBuff;
}
int giRefreshMask = 1;
void CGRefreshSwitch()
@ -1104,5 +1103,5 @@ void ST_Init (void)
{
veryfirsttime = 0;
ST_loadData();
//screens[4] = (byte *) Z_Malloc(ST_WIDTH*ST_HEIGHT, PU_STATIC, 0);
screens[4] = (byte *) Z_Malloc(ST_WIDTH*ST_HEIGHT, PU_STATIC, 0);
}

View File

@ -171,7 +171,8 @@ void V_CopyRect(int srcx,int srcy,int srcscrn,int width,int height,int destx,int
dest = screens[destscrn]+SCREENWIDTH*desty+destx;
for ( ; height>0 ; height--)
{
memcpy (dest, src, width);
for(int n = 0; n < width; n++) dest[n] = src[n];
// memcpy (dest, src, width);
src += SCREENWIDTH;
dest += SCREENWIDTH;
}
@ -355,18 +356,8 @@ void V_Init (void)
for (i=0 ; i< SCREEN_COUNT; i++)
screens[i] = CGDMalloc(SCREENWIDTH*SCREENHEIGHT);*/
screens[0] = SaveVRAMBuffer;
screens[1] = SaveVRAMBuffer + SCREENWIDTH*SCREENHEIGHT;
ASSERT(SAVE_VRAM_SIZE >= 2 * SCREENWIDTH*SCREENHEIGHT);
ASSERT(SCREEN_COUNT == 2);
//Blank the screen, to indicate on real hardware that SOMETHING is going on
//Done since loading on real hardware takes so damn long
// I_PrepScreen();
}
//CGD: hack to clear screen (except lower part) when changing details
void V_Clear()
{
memset(screens[0],0,320*(200-32));
memset(screens[1],0,320*200);
}

View File

@ -41,16 +41,12 @@
#define CENTERY (SCREENHEIGHT/2)
// Screen 0 is the screen updated by I_Update screen.
// Screen 1 is an extra buffer.
// Background and foreground screen numbers
//
#define BG 1 //4
// Screen numbers
#define BG 4
#define FG 0
#define SCREEN_COUNT 2
#define SCREEN_COUNT 5
extern byte* screens[SCREEN_COUNT];
extern int dirtybox[4];