Skip to content

Main cleanup - #201

Merged
roengstrom merged 14 commits into
mainfrom
main-cleanup
Oct 30, 2026
Merged

roengstrom merged 14 commits into
mainfrom
main-cleanup

Conversation

@roengstrom

Copy link
Copy Markdown
Owner

No description provided.

@decomp-dev

decomp-dev Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Report for SLUS_008.92 (8515813 - c61a15b)

✅ 3 new matches
Unit Item Bytes Before After
src/main SaveFieldSnapshot +356 0.00% 100.00%
src/main DisableStpBit +140 0.00% 100.00%
src/main RestoreFieldSnapshot +140 0.00% 100.00%
🥀 3 broken matches
Unit Item Bytes Before After
src/main func_80011870 -356 100.00% 0.00%
src/main flushGpuOt -140 100.00% 0.00%
src/main RestoreSnapshot -140 100.00% 0.00%

It sends the GPU one command that stops setting the STP bit on drawn pixels, which battles turn on. It is only called from main.c, so it is now static.
Mode 2 is the battle-start transition, 3 the battle and 4 the battle results screen. The enum moves to gamestate.h next to g_renderMode, and the code uses its names instead of numbers.
VsyncHandler sets it every VBlank and the field clears it when a fade-in starts. Nothing reads it.
Both add one frame's share of a second every VBlank and tick their timer when a whole second has passed.
func_80011870 records where a loaded game resumes each time the menu opens, and RestoreSnapshot puts it back. This also names the facing direction and previous field it saves.
It is the field engine's global state block, not an entity.
A field's script entities live in four arrays, one per kind: lines, doors, background animations and actors.
Its two public functions move out of fe_object1.h, and the trigger dispatcher only it calls becomes static.
fe_object1.h repeated the declarations gamestate.h already has.
The field's random battle roll reads a 256-byte table at g_fieldRngIndex and adds g_fieldRngOffset. The field state snapshot saves both.
SaveFieldSnapshot runs when the menu opens and RestoreFieldSnapshot when a save is loaded. Both are only called from main.c, so they are now static.
@roengstrom
roengstrom merged commit 6cba77d into main Oct 30, 2026
1 check passed
@roengstrom
roengstrom deleted the main-cleanup branch October 30, 2026 23:16
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.

3 participants