Skip to content
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

Open
wants to merge 3 commits into
base: rv32emu
Choose a base branch
from
Open

Conversation

tseng0201
Copy link

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

src/doomdef.h Outdated Show resolved Hide resolved
src/riscv/i_system.c Outdated Show resolved Hide resolved
src/doomdef.h Outdated Show resolved Hide resolved
Copy link

@jserv jserv left a 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.

@tseng0201 tseng0201 force-pushed the rv32emu branch 4 times, most recently from 24013b8 to b6b349d Compare January 13, 2023 12:21
@jserv
Copy link

jserv commented Jan 13, 2023

I merge all the commit to one commit, and add more information about my change in commit. Because, some mistake, one commit( Disconnect character movement from the mouse movements ) is not belong to me, should I delete it?

Use git rebase -i again.

jserv

This comment was marked as outdated.

@@ -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.
Copy link

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.

src/riscv/i_system.c Outdated Show resolved Hide resolved
src/riscv/i_system.c Outdated Show resolved Hide resolved
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants