-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reduce DOOM memory use #8
base: rv32emu
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use git rebase -i
to squash the commits.
Read https://cbea.ms/git-commit/ and rewrite the git commit messages.
24013b8
to
b6b349d
Compare
Use |
@@ -27,6 +27,15 @@ | |||
#include <stdio.h> | |||
#include <string.h> | |||
|
|||
// Disable screens wipe effect, you will get worse game experience, | |||
// but it can save about 130KB on DOOMHEAP. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You have to provide the proof for memory reduction. Check the report later.
Reduce memory use for doom Control flag "DISABLE_WIPES" and "COMBINE_SCREENS" are define in doomdef.h. DISABLE_WIPES will cut wipe screen effect, COMBINE_SCREENS will discard screen buffer_1、buffer_2、buffer_3. V_Init() function make four screen buffers pointer to same address(address of screen buffer #0) In v_video.c. DOOMHEAP are replaced by static array and it size are controled by DOOM_HEAP_SIZE, both are in i_system.c. Screen buffers are replaced by static array and I_AllocLow will return screen buffers directly in i_system.c. If cut wipe screen effect, in f_wipe.c only wipe_StartScreen()、wipe_EndScreen()、wipe_ScreenWipe() will remain, wipe_ScreenWipe() only copy data from screen buffer_3 to screen buffer_0 directly.
provide the proof for memory reduction, detail in doomdef.h
Add static modifier on CombinedScreens and DOOMHeap in i_system.c for help compiler optimization. No other file use both array directly and they use them by pointer.
Follow by embeddedDOOM
I cut wipe function and combine screen.
cut wipe function can save 130560 bytes on heep.
combine screen, if we cut wipe function it mean we don't need screen buffer 2 and 3, and screen buffer 1 can be abandon by worse game experience, so we only use screen buffer 0 to output, this way we can save 192000 bytes.
I set DISABLE_WIPES flag for cut wipe, COMBINE_SCREENS for combine screen. both flag define in doomdef.h.
By the way saving game will using screen buffer 3 for saving some information, if you want use combine screen you should add extra space for saving game.
below is my improve in reduce DOOM memory use
original game size
text data bss dec hex filename
546200 86324 8633373 9265897 8d62e9 doom-riscv.elf
my implement(combine screen + cut wipe function)
text data bss dec hex filename
545352 86324 7811601 8443277 80d589 doom-riscv.elf