This is about the file object representing a save-file. It has size 21440B (= 0x53C0 = 1340 lines), of mostly blank space.
There are 5 files loaded in memory:
||“active” file, used in gameplay to store/reflect changes between saves|
||“BiT” file, a surrogate active file for title-screen activity|
||a copy of file 1|
||a copy of file 2|
||a copy of file 3|
It’ll also be useful to define these file variables:
|FC||FA, FB||“current” file, = FA during gameplay and FB during title-screen|
|FS||F1, F2, F3||“selected” file, = the file most recently selected on the title screen (including any started file)|
- F1, F2, F3 are intended to always reflect the actual save data, which is loaded and stored here.
- Precisely, FC is FA if
800115e0: cf.isFileInactive()(see decompilation) returns 0 and FB otherwise. FC is FB during title-screen except that when selecting/starting a file, it switches to FA briefly while an anti-commit happens. It’s always FA during gameplay.
- Precisely, FS is F(n+1), where n is the value of the byte at
cf + 0xa83c: cf.selectedFileNo, where
cf = 8095545c.
- FA, FB are members of the
cfcurrentFiles object and F1, F2, F3 of the
sfsaveFiles object; see the page on the CF class. They are contiguous within their objects (i.e. in arrays).
Most operations to do with files are managed by the CF “CurrentFiles” class, which is a singleton whose instance is labelled
cf and is located at
8095545c. Some high-level dynamics:
- Resetting blanks FA and FB, commits FB (blank), then initialises FB with some defaults like 24 1/4-hearts.
- Selecting a file sets FS appropriately, then copies FS → FA.
- Saving copies FA → FS.
- Committing copies various bits of static data (from
806xxxxx, e.g. current scene-flag array) onto FC.
- Anti-Committing copies FC → static data (as above), and takes place on the title-screen during reset, file selects and file starts.
This is the layout of a file object.
First col is the offset in hex from the start of the file.
Third col is the size in hex of that section.
A “line” is 16B (hex editor convention).
The space between a / and the next named address is believed to be empty.
A section labelled _ is believed to be empty (for padding).
☆ denotes something that may be committed from/loaded to static data.
Many bits of data come in triples corresponding to spawn types 1,2,3, which are labelled t1,t2,t3 below. Depending on the spawn type, data for one specific type is read by the game – note the same labels in cf functions. t1 and t3 respectively correspond to save/start and loading-zone/continue.
|0||times||||playtime ; savetime . format: 3,645,000,000 = 1min; floor-rounded|
|10||position||||3 triples of floats (x,y,z for each of t1,t2,t3 rsp)|
|70||co‑ords 2||[0C]||1 triple of floats(?): ???|
|II||Global Flags||||(66 lines)|
|7C0||adventure pouch items||||int|
|7E0||item check items||[E0]||int|
|8D0||file area index||||appears on file-select as area name|
|8D4||file hero name||||appears on file-select; UTF-16 big-endian, 8 chars|
|8E4||story flags||||☆ | story flag table covers 8E4–944 |
|9E4||item flags||||☆ | breakdown below|
|A64||?||||☆ | “heartbeat” – committed every frame|
|III||Scene Flags||[1A4]||(27 lines)|
|30FC||loadzone temp flags||||☆ | treated as part of scratch by anti-commits and certain commits|
|32F4||?||||☆ | 2k of nothing, still copied a lot|
|52F4||potion timers||[C]||blue, blue+, green, green+, purple, purple+. 2B ints|
|53C0||//||(end of object)|
|Item Flags||||(8 lines)|
|9E4||inventory flags||[1A]||inv flag table exactly|
|A34||counters (menu)||[1E]||treasure, bug, pouch, crystal; counters table starts at A33|
|A5B||counters (item)||||hp,$,keys,ammo; counters table goes past end|
|5318||scene flag index||||picks the row of scene flags (Bob)|
|531C||area t1||||char, e.g. “F000”|
|533C||area t2||||char, e.g. “F000”|
|535C||area t3||||char, e.g. “F000”|
|539C||sky keep puzzle||||byte; access is modulo 9|
|53A5||forced layer t1||||// (Bob)|
|53A6||forced layer t2|||
|53A7||forced layer t3|||
|53A8||entrance t1||||// reload to spawn at entrance, not coords|
|53A9||t1 entrance load flag||||forces entrance during type-1 load (start file)|
|53AD||new file||||set on new file; unset by saving|
|53B1||shield pouch slot?||||pouch slot number of currently-equipped shield|
|53B5||?||||// t1, t3|
9D0: selected menu panel (+ other stuff) 
30FD: (according to Bob) “if (*file+0x30FD)&0x0A is true in a file, then selecting that file in BiT will automatically flush the cutscene queue”. Something about auto-commits.