diff --git a/src/doomdef.h b/src/doomdef.h index ebd51f0..404ce8e 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -27,6 +27,15 @@ #include #include +// Disable screens wipe effect, you will get worse game experience, +// but it can save about 130KB on DOOMHEAP. +#define DISABLE_WIPES + +// Discard screen buffers, any screen effect will direct output on your screen, +// It can save 192kb on heap. +// Remeber you can only use this when disable screens wipe. +#define COMBINE_SCREENS + // The packed attribute forces structures to be packed into the minimum // space necessary. If this is not done, the compiler may align structure // fields differently to optimise memory access, inflating the overall diff --git a/src/f_wipe.c b/src/f_wipe.c index d46607b..cf20792 100644 --- a/src/f_wipe.c +++ b/src/f_wipe.c @@ -46,7 +46,7 @@ static byte* wipe_scr_start; static byte* wipe_scr_end; static byte* wipe_scr; - +#ifndef DISABLE_WIPES void wipe_shittyColMajorXform ( short* array, @@ -233,6 +233,7 @@ wipe_exitMelt Z_Free(y); return 0; } +#endif int wipe_StartScreen @@ -246,6 +247,7 @@ wipe_StartScreen return 0; } +#ifndef DISABLE_WIPES int wipe_EndScreen ( int x, @@ -301,3 +303,18 @@ wipe_ScreenWipe return !go; } +#else +int +wipe_ScreenWipe +( int wipeno, + int x, + int y, + int width, + int height, + int ticks ) +{ + //Because we don't need wipe effct, just move screens[3] to screens[0] + memcpy( screens[0], wipe_scr_end, width*height ); + return 1; +} +#endif diff --git a/src/riscv/i_system.c b/src/riscv/i_system.c index 2ed5c50..e9084e6 100644 --- a/src/riscv/i_system.c +++ b/src/riscv/i_system.c @@ -39,6 +39,21 @@ #include "console.h" +#ifdef COMBINE_SCREENS +unsigned char CombinedScreens[SCREENWIDTH*SCREENHEIGHT]; +#else +unsigned char CombinedScreens[SCREENWIDTH*SCREENHEIGHT*4]; +#endif + +/* Original 6M - wipe function (130560 bytes) */ +#ifdef DISABLE_WIPES +#define DOOM_HEAP_SIZE 6*1024*1024 - 130560 +#else +#define DOOM_HEAP_SIZE 6*1024*1024 +#endif + +unsigned char DOOMHeap[DOOM_HEAP_SIZE]; + enum { KEY_EVENT = 0, MOUSE_MOTION_EVENT = 1, @@ -139,9 +154,9 @@ I_Init(void) byte * I_ZoneBase(int *size) { - /* Give 6M to DOOM */ - *size = 6 * 1024 * 1024; - return (byte *) malloc (*size); + /* Give DOOM_HEAP_SIZE to DOOM */ + *size = DOOM_HEAP_SIZE; + return (byte *) DOOMHeap; } @@ -313,8 +328,11 @@ I_Quit(void) byte * I_AllocLow(int length) { - /* FIXME: check if memory allocation succeeds */ - return calloc(1, length); + /* Return screen buffer */ + byte* mem; + mem = CombinedScreens; + memset (mem,0,length); + return mem; } diff --git a/src/v_video.c b/src/v_video.c index 881f4ab..301b835 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -463,9 +463,16 @@ void V_Init (void) byte* base; // stick these in low dos memory on PCs - + +#ifndef COMBINE_SCREENS base = I_AllocLow (SCREENWIDTH*SCREENHEIGHT*4); for (i=0 ; i<4 ; i++) screens[i] = base + i*SCREENWIDTH*SCREENHEIGHT; +#else + base = I_AllocLow (SCREENWIDTH*SCREENHEIGHT); + + for (i=0 ; i<4 ; i++) + screens[i] = base; +#endif }