Emulate PRAM and the secondary VRAM layout

This commit is contained in:
Lephenixnoir 2021-09-30 11:44:07 +02:00
parent 1260b93ba5
commit 913ac35582
Signed by: Lephenixnoir
GPG Key ID: 1BBA026E13FC0495
5 changed files with 32 additions and 20 deletions

View File

@ -524,7 +524,7 @@ int main(void)
if (!strcmp(wads[choice].name, "doomu4.wad"))
CGD_SingleEpisodeUltimate = 4;
uintptr_t secondary_vram = ((uintptr_t)GetSecondaryVRAMAddress() | 3) + 1;
uintptr_t secondary_vram = ((uintptr_t)GetSecondaryVRAMAddress() + 3) & -4;
SaveVRAMBuffer = (void *)secondary_vram;
/* fx-CG 50 / Graph 90+E: RAM starts at 0x0c000000 in physical memory */
@ -534,6 +534,8 @@ int main(void)
if(CGD_2MBLineMemory)
CGD_2MBLineMemory = FindZeroedMemory((void *)0xac200000);
void *PRAM0_alloc_start = PRAM0_START;
/* Remember WAD file name for saves and loads */
static char wad_name[32] = { 0 };
for (int i = 0; wads[choice].name[i] != '.'; i++)
@ -564,7 +566,7 @@ int main(void)
#endif /* FLASH_INDEX */
time = RTC_GetTicks();
gWADMap.mTable = (void *)0xfe200000; /* PRAM0 */
gWADMap.mTable = PRAM0_START;
int fd = Bfile_OpenFile_OS(wads[choice].path, 0, 0);
int size = CreateFileMapping(fd, &gWADMap);
Bfile_CloseFile_OS(fd);
@ -605,13 +607,12 @@ int main(void)
GetKey(&key);
}
/* Initialize the PRAM allocator */
void *PRAM0_start = (void *)0xfe200000;
void *PRAM0_end = (void *)0xfe228000;
PRAM0_start += gWADMap.miItemCount * sizeof(FileMappingItem);
CGD_PRAM_Init(PRAM0_start, PRAM0_end);
PRAM0_alloc_start += gWADMap.miItemCount * sizeof(FileMappingItem);
}
/* Initialize the PRAM allocator */
CGD_PRAM_Init(PRAM0_alloc_start, PRAM0_END);
memset(VRAM, 0, WIDTH*HEIGHT*2);
D_DoomMain();

View File

@ -67,16 +67,6 @@ byte* I_ZoneBase (int* size, int i)
return NULL;
}
byte *I_ScreenBase(int screen)
{
if (screen == 0 || screen == 1 || screen == 2 || screen == 3)
return malloc(320 * 200);
if (screen == 4)
return malloc(320 * 32);
return NULL;
}
#else /* fx-CG build */
/* On the calculator, scrap every possible bit of RAM */
@ -114,6 +104,8 @@ byte* I_ZoneBase (int* size, int i)
return NULL;
}
#endif
byte *I_ScreenBase(int screen)
{
/* The primary/secondary VRAM covers 384*216*2 = 162 kiB:
@ -141,8 +133,6 @@ byte *I_ScreenBase(int screen)
return NULL;
}
#endif
//
// I_Init
// Initialize machine state

View File

@ -50,6 +50,15 @@
disable.) */
#define CGDOOM_DIRECT_R61524
//---
// Memory layout
//---
/* PRAM0 is an area of SPU2 memory that supports only 32-bit access. It is used
for the file mapping and some allocations; see <cgdoom-alloc.h>. */
#define PRAM0_START ((void *)0xfe200000)
#define PRAM0_END ((void *)0xfe228000)
//---
// Memory distribution
//---

View File

@ -8,6 +8,8 @@
SDL_Window *window = NULL;
SDL_Surface *VRAM_RGB888 = NULL;
char _PRAM0[160*1024];
/* Rendering system emulation. */
uint16_t _VRAM[WIDTH * HEIGHT];
@ -334,7 +336,7 @@ int Bfile_FindNext(int fd, uint16_t *found, void *fileinfo0)
return -16;
const char *name = glob->gl_pathv[*pos];
Bfile_StrToName_ncpy(found, name, strlen(name));
Bfile_StrToName_ncpy(found, name, strlen(name)+1);
(*pos)++;
Bfile_FileInfo *fileinfo = fileinfo0;

View File

@ -8,6 +8,16 @@
#include <stdint.h>
#include "keyboard.hpp"
//---
// Memory layout
//---
extern char _PRAM0[160*1024];
#define PRAM0_START ((void *)_PRAM0)
#define PRAM0_END ((void *)_PRAM0 + sizeof _PRAM0)
#define CGDOOM_SCREENS_BASE SaveVRAMBuffer
//---
// fx-CG-specific functions not defined on emulator
//---