diff --git a/CGDOOM-minisdk/CGDOOM/platform.h b/CGDOOM-minisdk/CGDOOM/platform.h index 834365d..9a514af 100644 --- a/CGDOOM-minisdk/CGDOOM/platform.h +++ b/CGDOOM-minisdk/CGDOOM/platform.h @@ -53,6 +53,29 @@ enum { disable.) */ #define CGDOOM_DIRECT_R61524 +//--- +// Memory distribution +//--- + +/* When direct-display access is disabled, put the screens in secondary VRAM + and use VRAM for rendering. When it's enabled, put the screens in VRAM and + use the secondary VRAM as heap. We swap because using the VRAM as heap would + cause problems with error screens (stepping through errors would crash). */ +#ifdef CGDOOM_DIRECT_R61524 +# define CGDOOM_SCREENS_BASE ((void *)GetVRAMAddress()) +#else +# define CGDOOM_SCREENS_BASE SaveVRAMBuffer +#endif + +/* The primary/secondary VRAM covers 384*216*2 = 162 kiB: + -> Give 320*200 = 64 kB to screens[0] (main display) + -> Give 320*200 = 64 kB to screens[1] (intermissions) + -> Give 320*32 = 10 kiB to screens[4] (status bar) + -> 27 kiB are left */ +#define CGDOOM_SCREENS_0 (CGDOOM_SCREENS_BASE) +#define CGDOOM_SCREENS_1 (CGDOOM_SCREENS_BASE + 320*200) +#define CGDOOM_SCREENS_4 (CGDOOM_SCREENS_BASE + 320*200*2) + //--- #include "keyboard.hpp" diff --git a/README b/README index 06840af..ea88bbd 100644 --- a/README +++ b/README @@ -19,13 +19,12 @@ UI improvements TODO: WAD support TODO: -> Unmodified 1.9 shareware WAD works all the way through? -> Shareware WAD from Planète Casio should work 100% --> Ultimate DOOM WAD runs out of memory in E1M6, otherwise should work +-> Ultimate Doom WAD should work 100% for episode 1 Technical support TODO: -> Supply more VRAM memory to internal allocator => Merge internal heap into Z_Zone? (< 50 kB) => Rewrite video code to use long PRAM0 access? (138 kB) - => Use the XRAM/R61524 combo and use VRAM as heap? (160 kB) -> Rate-limit the game when overclocking -> Load/Save game would be very cool -> Reenable LTO if possible diff --git a/cgdoom/i_system.c b/cgdoom/i_system.c index ca888bb..3680089 100644 --- a/cgdoom/i_system.c +++ b/cgdoom/i_system.c @@ -75,6 +75,15 @@ byte* I_ZoneBase (int* size, int i) *size = &eextra - &sextra; return &sextra; } +#ifdef CGDOOM_DIRECT_R61524 + if (i == 2) + { + /* Secondary VRAM (screen buffers being in the main VRAM because we're + doing direct access so we don't need Bdisp_PutDisp_DD() */ + *size = 384 * 216 * 2; + return SaveVRAMBuffer; + } +#endif return NULL; } diff --git a/cgdoom/st_stuff.c b/cgdoom/st_stuff.c index 63a0088..baf56c9 100644 --- a/cgdoom/st_stuff.c +++ b/cgdoom/st_stuff.c @@ -1114,5 +1114,5 @@ void ST_Init (void) { veryfirsttime = 0; ST_loadData(); - screens[4] = SaveVRAMBuffer + 2 * SCREENWIDTH * SCREENHEIGHT; + screens[4] = CGDOOM_SCREENS_4; } diff --git a/cgdoom/v_video.c b/cgdoom/v_video.c index 64de3aa..951b1a0 100644 --- a/cgdoom/v_video.c +++ b/cgdoom/v_video.c @@ -352,9 +352,9 @@ void V_GetBlock( int x, int y, int scrn, int width, int height, byte* dest void V_Init (void) { /* screens[0] is the main screen */ - screens[0] = SaveVRAMBuffer; + screens[0] = CGDOOM_SCREENS_0; /* screens[1] is used for the level end sequence (intermission) */ - screens[1] = SaveVRAMBuffer + SCREENWIDTH * SCREENHEIGHT; + screens[1] = CGDOOM_SCREENS_1; /* screens[2] and screens[3] are used for wipe effects (disabled here) */ /* screens[4] is used for the status bar (allocated by st_stuff.c) */