Repository navigation
Main gets a lighter main-menu slot count, stronger save tests and save tickets that match the code - #39
Merged
redcode9 merged 13 commits intoNov 16, 2026
Conversation
SAV-1.5 said two No answers at startup open the menu. From game.gba or the browser they do; from a launcher (ROM in argv) they quit, as a failed launcher load already did. Accepted on 2026-11-16: the ticket, the SAV-1 goal and docs/saves.md now say so.
Since savestate_file_exists() recovers a cut save first, the Save and Load row cost about ten sceIo calls per empty slot, some 121 each time the main menu opened. The count now stats each slot once; the Load page, the benchmark and every load still recover first.
save_io_write returns 0 on ENOSPC, but the fake returned -1, so no test fed save_store a 0 and the guard against spinning on a full Memory Stick could go unnoticed. The fake now returns 0 and asserts that nothing writes again after it, so a regression fails instead of hanging.
The repair test's fallback values matched the obvious defaults, so a sanitize that ignored them passed, and no valid state had type NONE. The fallback now differs from every default, and a NONE state must load unchanged.
SAV-1.6, SAV-1.7 and SAV-2.4 still said the format stays v5, and SAV-1.7 that its event was missing. The tree logs SAVE_LOAD, SAVESTATE_REPAIR and SAVE_WRITE in format 6, ENG-1.6's version.
EXT-1.2 said the target writes a whole generation before any read. It writes one block (3Fh) on every boot, since a generation would destroy what read_back checks, and after the first boot it runs as eeprom8k plus that write.
The main menu now counts its state slots with savestate_file_stat(), so the guard that keeps file system calls out of menu_draw_main_status() looks for that name too.
The ticket already says the format stays at v6, the version ENG-1.6 bumped to, so the fallback to that bump no longer applies.
gui.c: the main menu's slot count comment now says both when it is counted (also after an AUTO state write, from main) and why it skips recovery (this branch). tests/test_save_io.py keeps main's trace save test, which calls the module-level build_and_run, and this branch's slot count test.
redcode9
merged commit Nov 16, 2026
6afd012
into
features/state-of-the-art-development/main
8 checks passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Review-fix round for
wip/save-store. The branch was fast-forwarded to main 391f5e9 first, so this PR holds eleven commits: one PSP code change insource/src/gui.cwith its host test, two test-only changes, one line in a check script and seven docs commits.save_store.c,save_format.c,memory.candmain.cdo not change.What was wrong and what changed:
game.gbaor the browser. From a launcher (ROM in argv) the emulator quits instead (source/src/main.c:2410-2419), as a failed launcher load already did before this branch. PR Main gets the save store: safe .sav reads and writes, pre-link copies #24 listed the difference under "To know before merging" and was merged, butdocs/wip/save-store.mdstill said «da confermare nella PR», and the SAV-1 goal anddocs/saves.mdstill said two No answers go back to the game list. SAV-1.5, the SAV-1 goal,docs/saves.mdand the wip note now describe both startup cases. c184a77 rewraps thedocs/saves.mdparagraph, which had a 96-column line.tests/test_startup.pyalready checks both behaviours, so no code changed.menu()atsource/src/main.c:2419, as thegame.gbapath does, and updatetests/test_startup.py:189.menu_status_count_states()(ui-ge) counted the slots withsavestate_file_exists(), which runssave_store_recover()first (save-store). For an empty slot, recovery checks three names, and each missing name costs a stat plus a folder open and close, then removes the.tmp: about 11 calls per slot, on the first entry and on every Back from a submenu. Neither branch did this alone; the two met when main was merged into ui-ge. A new staticsavestate_file_stat()does the onesceIoGetstat.savestate_file_exists()recovers and then calls it, and the count usessavestate_file_stat()directly, so it is back to 11 stats. The Load slot backup check, the benchmark arm and every load still recover first. A comment records the trade-off: a save cut mid-write counts as empty on the main-menu row until a load recovers it.tests/test_save_io.pygainstest_main_menu_counts_slots_without_recovery, which cuts the three functions out ofgui.c, runs them against counting stubs and checks 11 stats, no recovery and the right counts. 53a4fc1 widens the guard inscripts/check-menu-layout.shthat keeps file system calls out of the per-framemenu_draw_main_status(), so asavestate_file_stat()call there now fails the check too.save_io_writereturns 0 on a full Memory Stick, buttests/fake_store_io.creturned -1, so the guard atsave_store.c:152that stops the write loop on a 0 could regress with every test still green. That regression would freeze the emulator on every save to a full Memory Stick. The fake now returns 0 when the device is full and keeps -1 for a bad handle, so negative counts stay covered. It also asserts that nothing writes again after a 0 on the same open file (atook_nothingfield, reset on eachopen_write), so the regression fails the test at once instead of hanging it. No production code changed.tests/test_save_format.cis now Flash, 32 KiB SRAM, 128 KiB Flash and 8 KiB EEPROM, and the asserts follow. A state withSAVE_TYPE_NONE, saved before the game's first backup access, must now load unchanged. The SRAM size had the same gap and is covered too. Tests only.runtime_log.hwrites version 6 andmemory.clogsSAVESTATE_REPAIR. The three tickets now say v6, and SAV-1.7 namesRUNTIME_LOG_EVENT_SAVESTATE_REPAIR. 3db2bcf drops the last sentence of SAV-1.6, about moving the event into ENG-1.6's bump if the rule were refused: that bump has happened. The historical sentence «È il primo tipo di evento nuovo dalla v5» stays.eeprom8k_wfirsttarget writes a whole generation before any read (3961356).tests/save-rom/source/main.cwrites one block (3Fh) with an 81-unit DMA on every boot, because the ROM cannot tell an empty chip without reading it and a whole generation would destroy the oneread_backchecks. Its «Cosa» now says so, notes that the text said «una generazione» until 2026-11-16, and says later boots run aseeprom8kplus that write. The EXT-1.2 status line in the wip note records the change. The ROM code is unchanged.Tickets whose status changed:
make test-romswith an ARM compiler and its PSP sessions.docs/wip/save-store.mdcites dbab178 for SAV-2.6. No wait changed and no story became startable.Tests on this host (clang with the freestanding host shim; UBSan in trap mode):
test_save_store, with zlib'scrc32.cbuilt as an object in place of-lz: passes, plain and with UBSan. Withsave_store.c:152changed fromcount <= 0tocount < 0, both builds now stop on the fake's assert. Before this PR the same mutant passed, and with a fake that returned 0 it hung.test_save_format: passes, plain and with UBSan. Five mutants ofsave_format_sanitizenow fail both builds: the type check as>=, and the type, SRAM, Flash and EEPROM fallbacks hard-coded to SRAM, 64 KiB, 64 KiB and 512.tests.test_save_io: OK (2 tests), plain and with UBSan. The new test fails when the count callssavestate_file_exists()for the numbered slots or for the auto slot, when recovery is dropped fromsavestate_file_exists(), and when the auto slot is hard-coded.scripts/check-menu-layout.sh: passes on HEAD. With agui.cmutant that callssavestate_file_stat(0)insidemenu_draw_main_status(), the new pattern fails (rc=1) and the old one passed (rc=0).scripts/check-tree.sh(messages, menu layout, runtime lifecycle, video lifecycle, performance, script syntax, forbidden names, module tests, source tree), pluscheck-menu-layout.sh,check-lifecycle.sh,check-performance.shandcheck-messages.shon their own, run from CR-stripped copies withPYTHON=python: all pass.tests.test_browser_text,test_input_shortcuts,test_startup,test_theme_boot,test_toast_drawandtest_ui_goldenunder the shim: all pass excepttest_startup.test_diagnostic_autorun_glueandtest_ui_golden.test_screens_match_golden_hashes. Both fail the same way on a clean export of 391f5e9, so they come from the shim environment, not from this PR (the autorun test fails because the shim has nostrcat).git archiveexport of the branch and got the same results.git diff --check 391f5e9..HEADis clean. No message table changed, and every changed file keeps its line endings.test_save_io.pyis already inmake test-tools, andtest_save_formatandtest_save_storeare already inHOST_TESTSand the sanitize lists.make check,make test-sanitize,make check-cbmcand both PSP builds on this PR.Not verified here:
make check,make test-sanitizewith gcc and ASan,make check-cbmcand the PSP builds: this machine has no make, gcc or PSPDev. Thegui.cchange is PSP code built with-Werror. It was read for unused statics, unused locals and declaration order, but not compiled for the PSP. CI has to confirm it.test_memory_backup,test_eepromandtest_perf_dma_probelink the changed fake but needmemory.cand the PSP SDK headers, so they did not run here. By reading they are safe: they reach the fake only throughsave_store_append, which stops after the first 0, andopen_writeresetstook_nothingbefore any retry.test_memory_backup's retry on a full device (test_failed_write_stays_pending) depends on that reset. CI has to confirm all three.dir_stateis unmeasured; it belongs in the UI-11.1 hardware session. SAV-1.5 and EXT-1.2 still need their PSP sessions.Files of other branches touched (rule 5):
source/src/gui.c:menu_status_count_states()is ui-ge's UI-11.1 code. The change splits save-store'ssavestate_file_exists()into one new static helper and changes the two call sites in the count. Nothing else in ui-ge's code changed.scripts/check-menu-layout.sh(ui-ge): one line, the grep pattern at line 82, nowsceIo|savestate_file_(exists|stat)|get_savestate_info.CHANGELOG.md(shared): only this branch's two Unreleased lines about the pre-link copy.docs/BACKLOG.md(shared): only this branch's tickets: the SAV-1 goal, SAV-1.5, SAV-1.6, SAV-1.7, SAV-2.4 and EXT-1.2.Skipped, with the reason:
test_sanitize_repairs_each_fieldeach fallback value is now the other valid constant, so mutants that hard-codeSRAM_32K,FLASH_128KorEEPROM_8Kstill pass. A second run with SRAM, 64 KiB, 64 KiB and 512 as the values in use would catch them.test_main_menu_counts_slots_without_recoverydoes not check thatsavestate_file_exists()recovers before it stats. Its recovery stub changes nothing, so a version that stats first passes. A stub that makes a cut slot appear on recovery would catch it.took_nothingreset inopen_writepassestest_save_store; onlytest_memory_backup's retry reaches it, and that runs in CI only.CHANGELOG.mdUnreleased has two «### Fixed» headings. They come from the open-BIOS, ui-ge and ui-foundation commits, not from this branch, so they are left for their owners.CHANGELOG.mdentry: the main-menu slot count and the recovery it no longer runs are both new in Unreleased, so no released build had the extra calls. The other fixes are tests and docs.The branch stays open, so
docs/wip/save-store.mdstays.