27 November 2026: sprite frames, tables proved by their readers, and the colours
Five pull requests went in since the last post. One is a review that brings every routine back to verified. The other four are data: the scene backgrounds' maps, the sprite frame records, a second round of tables, and the palettes with the battle's action frames. As before, each is rebuilt from readable files to the exact bytes of the cartridge, and each says how sure it is of where its data ends.
All 3,736 routines verified again
The last post ended with a small debt. To state a proof about the location graphics, two routine headers had gained two sentences, and a routine whose source changes goes back for an independent review, even for a comment. Review round 203 (#132) approved both, LocLoad_Unk0960 and Ppu_SetBgLayout. The round also fixed a stale note: one header still called a caller "unmatched", although it is LocLoad_DrawMap, matched long ago. The note now names it and says where in it the call sits. So the count is back to 3,736 of 3,736 routines matched, readable and verified.
The scene backgrounds' maps
Last time the location maps became text. The eight scenes run by bank $C2's scene engine have backgrounds of their own, stored the same way in spirit but in their own layout, and #133 does those. The proof starts from the routine that sets up the scenes' display: background mode 1, with the tilemaps of the three layers at fixed places in video memory. From there:
- Metatiles: 6 packs, each holding 256 metatiles for layer 1 and 256 for layer 2, four tilemap words each, which the scene's drawing routine copies into the layer's tilemap unchanged.
- Maps: 8 packs, each a grid of 96 by 64 metatile numbers for layer 1 and another for layer 2, read row by row.
- Layer 3: 5 packs of plain tilemap words. The routine that loads them always copies 4,096 bytes, which is two 32 by 32 screens, so the tools now refuse a layer-3 file of any other size.
That is 19 packs, about 143 KB once unpacked, all packed back byte-exact. One more layer-3 pack is unpacked only by a script routine, and nothing traced reads the result, so it stays as bytes.
What a sprite frame record is
A character on the SNES is not one picture. The console draws sprites in small squares, and a character's frame is several of them placed side by side. Chrono Trigger keeps a list of these pieces for every frame of every sprite: a sprite frame record. #134 turns all of them into text.
A record has two parts. First come the tile words, two bytes each, one for every 8 by 8 tile of the frame: bits 0 to 10 say which tile of the sprite's graphics to copy, and bit 14 says to draw it mirrored. Then come the x/y pairs, two signed bytes each, one for every 16 by 16 sprite: how far left or right, and up or down, of the object's position that sprite goes. Four 8 by 8 tiles fill one 16 by 16 sprite, so a record with 16 words has 4 pairs, which makes 40 bytes. The bigger sizes are 80, 120 and 240 bytes, with more words and pairs in the same proportion.
The size of a set's records comes from two bits of its sprite record, a five-byte description of the sprite, and the field, the menu and the battle code all agree on what those bits mean. The text writes a frame as its words, like 014h for tile $014 mirrored, and a line of pairs.
The result: 4,745 frame records in 225 runs, 237,320 bytes, rebuilt exactly. The runs of six sets (2,960 bytes) stay as bytes, because no sprite record names those sets, so nothing says what size their records are.
Proved, inferred and assumed
Every table in the ROM has a start the code points at. Where it ends is often harder: the bytes just run on into the next thing. The project now labels every end it uses with how it knows it, in three grades.
- Proved: the code itself fixes the end. The reader can only reach so far, because of the size of its index, a limit it clamps to, or because the only place the index comes from never goes higher.
- Inferred: nothing in the code stops a reader going further, so the end is taken from the data around it, usually the next pointer.
- Assumed: the end would be proved, but only if something holds that has not been traced yet.
The sprite frame records are inferred. Frame number f of a set is at its start plus f times the record size, and no reader checks f. So each run is taken from one set's pointer up to the next. Every one of the 220 runs that ends at another pointer comes out a whole number of records, which is good support, but it is not proof. The zeros after the last record of each area are marked as probable padding, because a frame number could still reach them.
Proving a table's size by running its reader
Pull request #135 went through the tables that were still raw bytes, and for seven of them it found a proof that is worth spelling out.
Suppose a routine reads a table using a one-byte index. A byte has only 256 values, so the project runs the routine 256 times in its own interpreter, once for each value, with everything else about the machine left unknown. It records which bytes of the table each run reads. The rule is strict: each value must read exactly its own record and nothing else. If that holds for all 256 runs, the record size and the number of records both come straight from the code.
The unknowns do real work here. The 65816 often indexes with a 16-bit register, and if the routine never clears the top half, the address it reads from is unknown. Then the run reads nothing the tools can name, and the table is refused. So a pass also proves that the code clears or masks the high byte.
Two of the seven are only assumed. That pair, a table of effect graphics lists and its colours, is indexed by a byte the routine loads into an 8-bit register and then uses as 16 bits. That is safe only if the hidden top byte is zero at that moment, and the code just before it waits on other work, so nobody has shown it is. The tables are converted, but the label says exactly what the bound rests on.
The other tables in #135 were bounded in other ways: the sprite animation lists by the next animation's offset, which all three readers use; the menu's 56 draw lists by running them the way the menu does, up to their end byte; and four tables by a defined limit, such as the highest level the experience code allows. Of 157,019 bytes of raw tables, about 96 KB now have readable forms, 11,703 bytes turned out to be zero fill, and 48,632 bytes in 142 pieces stay as bytes, each listed in DATA_PLAN.md with the reader and why it does not prove an end.
Colours on the SNES
The last post showed the graphics in grey, because tiles hold palette numbers, not colours. #136 is where the colours come in.
An SNES colour is one 16-bit word with five bits each for red, green and blue, so each channel runs from 0 to 31. Red is in the lowest bits and blue in the highest, which is why it is often called BGR, and the top bit is unused. That gives 32,768 possible colours. The console holds the colours it can show at once in CGRAM, a small memory of 256 colours (512 bytes). Sprites take their colours from the second half and background tiles from the first; for 16-colour tiles the colours come in rows of 16, and a tile's palette number picks the row.
From ROM to screen
A palette in the ROM is just words like these. To reach the screen, the game copies it into a buffer in work RAM, and at the next vertical blank (the moment the screen is not being drawn) a DMA transfer sends the whole buffer into CGRAM.
The location palettes show the route well. When a location loads, its palette number picks one of the palette sets in ROM, each seven rows of 15 colours. The loader copies them into rows 1 to 7 of the palette buffer, colours 1 to 15 of each, and leaves colour 0 alone: on the SNES, colour 0 of each row is transparent, so there is nothing to store. A second routine copies that buffer to the one sent to CGRAM, and the upload starts from colour 0. Because the location data is the only place the palette number comes from, and its values stop at 87, exactly 88 sets are proved.
Four raw palettes became records, each with a proof of this kind (19,108 bytes), and eight scene palette packs became text, as rows of 16 colours, each written R,G,B. The colour figure's toy word would be 31,11,11. Several palettes stay as bytes: the colour cycles whose list is not proved, the palettes only the $C3 module reads, and rows whose readers' index runs past them.
The battle's action frames
The same pull request did the 128 packs of the battle's action frames. Each frame is a header with a row count, one bit mask per row saying which columns hold a 16 by 16 sprite, and then a tile and an attribute byte for each one. They are read the way the battle code reads them: up to the end of the unpacked data, where the loader puts a zero that stops the reader. 119 packs end exactly there, and the other 9 are empty.
Where the data stands
Tonight's count from the build: data in readable form is 3,123,675 bytes, 74.5% of the ROM, up from 64.6% a month ago. What is still placed as plain bytes is now 666,593 bytes, down from 1.1 MB.
What is left is easy to name, and none of it is quick:
- The last of the
$C3module's code. About 90.6% of its code bytes are matched (19,050 of 21,030); the rest are still the ROM's bytes, packed back with the module. - The music. The sequences and the instrument samples, about 311 KB, are still bytes. The sequences are the last script language.
- Tables no reader proves yet. About 49 KB of tables, and the palettes listed above, stay as bytes because their readers' indexes reach past them or come from other tables that are not proved. Some will give way as more readers are traced; some may only ever be inferred.
None of this is stored in the project: the tools write the text and images from the player's own ROM, and the build rebuilds the ROM from them.
Next
The music sequences; the rest of the $C3 module; and the tables and palettes whose readers can still be traced.