Files

This is about the file object representing a save-file. It has size 21440B (= 0x53C0 = 1340 lines), of mostly blank space.

File Externals

There are 5 files loaded in memory:

File Address Description
FA 80955464 “active” file, used in gameplay to store/reflect changes between saves
FB 8095A824‬ “BiT” file, a surrogate active file for title-screen activity
F1 809BE200‬ a copy of file 1
F2 809C35C0‬ a copy of file 2
F3 809C8980‬ a copy of file 3

It’ll also be useful to define these file variables:

Var Values Description
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)

Notes:

Dynamics

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:

File Internals

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.

I Head [80] (8 lines)
0 times [10] playtime [8]; savetime [8]. format: 3,645,000,000 = 1min; floor-rounded
10 position [24] 3 triples of floats (x,y,z for each of t1,t2,t3 rsp)
34 /    
70 co‑ords 2 [0C] 1 triple of floats(?): ???
7C /    
II Global Flags [420] (66 lines)
7B0 ? [10]  
7C0 adventure pouch items [20] int[8]
7E0 item check items [E0] int[60]
8D0 file area index [4] appears on file-select as area name
8D4 file hero name [10] appears on file-select; UTF-16 big-endian, 8 chars
8E4 story flags [100] | story flag table covers 8E4–944 [60]
9E4 item flags [80] | breakdown below
A64 ? [10] | “heartbeat” – committed every frame
A74 ? [15C]  
BD0 /    
III Scene Flags [1A4] (27 lines)
1A60 ? [4]  
1A64 scene flags [1A0]
1C04 /    
IV ??? [40] (4 lines)
2A60 ?           [4]  
2A64 ?           [4]
2A68 ?           [38]  
2AA0 /    
V Temporary [394] (58 lines)
2F60 ? [194]  
30F4 temp flags [8]
30FC loadzone temp flags [8] | treated as part of scratch by anti-commits and certain commits
3104 scratch [1f0] |
32F4 ? [2000] | 2k of nothing, still copied a lot
VI Tail [CC] (13 lines)
52F4 potion timers [C] blue, blue+, green, green+, purple, purple+. 2B ints
5300 tail [C0] breakdown below
53C0 //   (end of object)

Breakdowns

  Item Flags [80] (8 lines)
9E4 inventory flags [1A] inv flag table exactly
9FE ? [36]  
A34 counters (menu) [1E] treasure, bug, pouch, crystal; counters table starts at A33
A52 ? [9]  
A5B counters (item) [9] hp,$,keys,ammo; counters table goes past end
  Tail [C0] (12 lines)
5300 _ [2]  
5302 total hearts [2]  
5304 ? [2] heart-related
5306 current hearts [2]  
5308 ? [2] // t1
530A ? [2] // t2
530C ? [2] // t3
530E angle t1 [2]  
5310 angle t2 [2]  
5312 angle t3 [2]  
5314 ? [2]  
5316 _ [2]  
5318 scene flag index [2] picks the row of scene flags (Bob)
531A _ [2]  
531C area t1 [20] char[32], e.g. “F000”
533C area t2 [20] char[32], e.g. “F000”
535C area t3 [20] char[32], e.g. “F000”
537C _ [20]  
539C sky keep puzzle [9] byte[9]; access is modulo 9
53A5 forced layer t1 [1] // (Bob)
53A6 forced layer t2 [1]  
53A7 forced layer t3 [1]  
53A8 entrance t1 [1] // reload to spawn at entrance, not coords
53A9 t1 entrance load flag [1] forces entrance during type-1 load (start file)
53AA entrance t2 [1]  
53AB entrance t3 [1]  
53AC _ [1]  
53AD new file [1] set on new file; unset by saving
53AE ? [1]  
53AF _ [1]  
53B0 ? [1]  
53B1 shield pouch slot? [1] pouch slot number of currently-equipped shield
53B2 ? [1]  
53B3 night t1 [1]  
53B4 night t3 [1]  
53B5 ? [1] // t1, t3
53B6 _ [6]  
53BC checksum [4]  

Misc:

9D0: selected menu panel (+ other stuff) [1]
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.