dm2-saves: reverse the Sega CD BRAM save format (add SaveVariant::SegaCd) #158
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Reverse the Sega CD BRAM save format and add a
SaveVariant::SegaCdtodm2-saves(currently: DosRetail, MacRetail, DosBetaV09).Context
A DM2 US Sega CD saved game was captured from BlastEm's Sega CD internal
backup RAM (
internal.bram, 8 KB). It holds one real save: payload runs~
0x40–0x14a0(~5 KB), with a directory-entry pair above the standardSEGA_CD_ROM/RAM_CARTRIDGE___BRAM format footer. The RAM-cart image(
cart.bram, 128 KB) was formatted but empty. These are BRAM (saved-gamedata), not emulator save states — so they carry the game's own save format,
nothing else.
Why the existing decoder can't read it
dm2-savestargetsSkSave.dat, whose three variants share one on-disklayout: mostly plaintext (42-byte header, embedded dungeon state, raw
section blocks) with only a trailing suppression bitstream compressed. Two
facts rule that layout out for the Sega CD BRAM:
SkSave.datis ~45.9 KB; the compressed bitstreamalone is ~6.3–6.9 KB. The entire Sega CD internal BRAM is 8 KB. A
plaintext-layout save cannot fit.
(
18fe 0001 … a39b … 9360), with no plaintext header —w_timer_flagdoes not read as
1at the expected offset under either endian. TheDOS/Mac format is not high-entropy up front (readable map/record tables).
So the Sega CD save is a genuinely different, tighter encoding built to fit
BRAM — not the existing layout byte-swapped. Nothing in the crate reads it
today.
Goal
docs/formats/.SaveVariant::SegaCd+ alooks_like_*predicate and parse/write path.convert.rsso Sega CD ↔DOS/Mac conversion becomes possible (the Sega CD is big-endian 68000 like
the Mac variant, so shared sub-structures — champion records, object tables
— may be recognizable once decompressed; the Mac decoder is the reference).
Method
SKUL.FTLon the Sub-CPU — the samemodule and the same BlastEm Sub-CPU tracing workflow built for the palette
work (
tooling/palette-oracle/blastem-debugger.md), so that toolingtransfers directly.
footer) to recover the save's true start block and length — the two entries
in this sample are not clean 11-char filenames at the obvious offsets, so
the directory model needs care before the blob can be cleanly extracted.
Difficulties
reversing is guess-and-check against a single save. Producing several
in-game saves at known states → more BRAM captures would give an oracle.
gitignored (kept in
scratch/), not committed as fixtures.