How it works#
This page is for readers who want the internals: how the cartridge is built, where things are in the ROM and the save, and how the program runs a game. Everything here was read from the program and checked in emulators (the last section says how). Addresses are the console's, bank and offset ($80:8001); offsets into the save are written $0000–$7FFF. Where a point was read from the code but not seen running, it says so. Each section ends with the project's note and tool that hold the full detail; they are files in the project that made this guide, not pages of the site.
Super Dante is RPG Tsukuru 2's direct ancestor, built by the same developer with the same tool chain, and much of this page reads as "RT2's, in an earlier form". The RT2 guide's How it works describes the later machine; Compared with RPG Tsukuru 2 sets the two side by side.
The cartridge#
SHVC-ARDJ, header title DANTE SFC, maker code B1. Inside:
- 1 MB of ROM (8 Mbit), LoROM, run at FastROM speed, with no coprocessor.
- 32 KB of battery SRAM, seen by the console at
$70:0000–$7FFF; the program reaches it as bank$F0, mostly through the data bank, so its offsets appear in the code as plain absolute operands. It holds one user game and three play saves. - No memory-pack slot. Through the second controller port the program talks to a Turbo File Twin, its only storage besides the cartridge.
Just under the ROM header, at $80:FF80, sits the developer's tag in ASCII, KUSOU KAGAKU DEVELOPMENT SYSTEM VER 2.21, followed by B1ARDJ, the maker and game codes. RT2 has the same tag at the same place, as VER 2.28. The opening shows © 1995 ASCII CORPORATION and © 1995 空想科学 (Kuusou Kagaku), the developer.
Notes/Super Dante.md, Notes/Dumps.md.
The program's banks#
In LoROM each bank shows 32 KB of ROM at $8000–$FFFF, so the 1 MB are the 32 banks $80–$9F, bank $80 + n being the file's bytes from n × $8000. Code is in twelve of them: $80 shared by everything, $81 and $83–$85 the game being played and the battle, $82 the boot screens and the demo, $86 the Turbo File library, $87–$8A the front end and every editor, $9F the sound module. The rest is data.
$95 was touched by none of the logged runs.The map was made with a code/data log: Mesen marks each ROM byte as it is run or read. 112 headless runs (from power-on, and random presses from 57 saved states: every menu and editor page, play in the sample and the factory saves, test play, a battle) logged 69,329 bytes of code from 912 routine entries, and the Turbo File runs in MesenCE later added the library: 74,843 code bytes in all. RT2, in a ROM twice the size, logged 90,300. Landmarks:
| Address | What |
|---|---|
$80:8001 | Reset |
$80:802B | The main loop; the mode table at $80:F000, the step dispatcher $80:8E4C |
$80:86B2 | Queue a VRAM DMA for the next NMI |
$80:8873 | The one pad reader |
$80:8A84, $80:8A9A | The random number generator; the same, mod n |
$80:8AC0 | The decompressor |
$80:9140 | Create an object |
$80:9CD6, $80:9D34 | Start a script; the script VM's run loop (tables from $80:BB1F) |
$80:FF80 | The development tag, VER 2.21 |
$81:A5E3 | The move-script runner (people's movement) |
$81:A6D2 | The event interpreter's step |
$81:CD01 | The part decoder |
$81:E7FD | The character routine |
$82:DEA2, $82:DDA2 | The proportional font's pointers; the 8 × 8 font's code → tile table |
$83:803F | The Mode 7 view |
$83:A14A | Passability |
$84:A298 | The page conditions |
$85:8040 | The 8 × 8 font |
$85:9060 | The encounter roll |
$85:F5E8 | The escape roll |
$86:FE16 | The Turbo File library's one entry |
$87:A60E | Write a play save |
$87:BB3F, $87:BCC7 | The power-on check; the format |
$87:BAEB | Write the save's sums |
$89:80D1 | A blank project's defaults |
$8C:8000 | The factory save image: the sample game FATE |
$9F:FFFA, $9F:FFFD | The sound interface; the sound start-up |
What RT2 kept. A comparison of the two ROMs finds 412 runs of 32 bytes or more in both, about 47 KB: the reset, NMI and IRQ, the core library (objects, the DMA queue, HDMA, multiply and divide, the random numbers, the decompressor), the windows and the script VM, the event interpreter's step and the move-script runner, text drawing, the Mode 7 view and its 16 KB of perspective tables, pieces of the battle, the Turbo File library and the sound chip's pitch table. Most of bank $80 sits 6 bytes lower in Super Dante than in RT2. Not shared: the save check, the editors, the encounter check, RT2's tile packer and the sound driver's code.
Notes/Super Dante/Program.md; Tools/snes_dis.py (the disassembler), Tools/mesen_cover.py, Tools/snes_common.py rt2 dante.
The main loop and its modes#
The reset ($80:8001) sets the stack and the FastROM bit and clears the mode word $B9. The main loop ($80:802B) waits for each frame and runs the routine for the current mode through the table at $80:F000, an RTL address a mode. A mode with several steps starts with JSL $80:8E4C and keeps its step in $BB, moving on by adding 4. All of this is RT2's code at RT2's addresses.
| Mode | Entry | What |
|---|---|---|
$00 | $80:803E | Power-on: the RAM cleared, but for the random seed |
$3C | $80:8061 | Cold or warm boot: a copy of the development tag in RAM tells a reset from a power-on |
$40 / $44 | $82:8000 | Cold boot: the logos ($44 on a PAL console, the same code) |
$48 / $4C | $82:8061 | Warm boot, after a reset: the sound start-up, then straight to the demo (read from the code; never run) |
$50 | $82:8E05 | The opening demo: the castle, the moon and the staff |
$54 | $87:8234 | The front end and every editor; its second step runs the save check |
$58 | $83:9175 | Setting up play: the game state built, the title card on a new game |
$5C | $84:968F | Playing a game, the user's, a test play or the sample: the field, the maps and the battle |
$60 | $83:8A32 | The ending: nine cards, then back to the demo |
$04–$38 | Unused, as in RT2; nothing sets them |
One mode for the front end and the editors. RT2 gives editing a mode of its own ($78); Super Dante runs the title menu, the game menus, the edit menu and all ten editors as objects under mode $54's last step. The table ends at $60.
Objects. Every screen is a tree of objects, as in RT2: records in RAM, each with a routine that dispatches on its state, created by $80:9140. Video work is queued: $80:86B2 adds a DMA to a list that the NMI sends to VRAM.
Warm and cold boot. At power-on mode $3C compares the 48 bytes of the development tag with a copy in RAM ($7E:3A10). A power-on finds no copy, writes one and shows the logos ($40); a reset finds it and goes straight to the opening demo ($48), skipping the logos. That is read from the code; the warm boot was never run here. L + R + START + SELECT does much the same from inside a game: a hook in the frame-wait table ($87:BEB2) sends mode $54 back to its title-menu step, past the save check.
Notes/Super Dante/Program.md, Hidden Content.md, Game.md; Tools/rt2_modes.py --rom dante.
The SRAM image#
The 32 KB are one uncompressed image at fixed offsets: a signature, a total, the three play saves, one sum, the database, the maps and one event space. The program reads the image in place; the editors copy their part into RAM, work on it there, and write it back with the sums.
$7FF8–$7FFF at every save and copied back before the power-on check. Nearly all of the save is under the one main sum, so a stray bit anywhere in it fails the check.| Offset | Bytes | What |
|---|---|---|
$0000 | 24 | The signature SHVC?? SUPER DANTE, padded with spaces (RT2's: SHVC????RPG TKOUL 2) |
$0018 | 2 | The total: a record of the four sums below |
$001A | 3 × 256 | The three play saves, each with its own sum |
$031A | 2 | The main sum, over $031C–$7FF7 |
$031C | 1 | The save counter, +1 at every editor's save |
$031D | 16 + 16 | The title; the author |
$033D | 128 × 13 | Items |
$09BD | 32 × 12 | Magic |
$0B3D | 8 | The field enemies on land and at sea: two 32-bit masks, rewritten at every save |
$0B45 | 80 × 30 | Enemies: 0–31 the field's, 32–63 the dungeons', 64–79 the events' |
$14A5 | 27 | The start: the first party, gold, the vehicles, the music slots, the start place |
$14C0 | 8 × 40 | Heroes |
$1600 | 1,024 | The field's enemy map: 16 × 16 field screens, a 32-bit mask each |
$1A00 | 1,024 | The pool screens' enemy masks, 4 bytes a screen |
$1E00 | 10 | The map header: bits 0–1 of $1E00 choose the field; the rest not identified |
$1E0A | 64 | A nibble a map: 0 unused, 9 castle, A dungeon, B town |
$1E4A | 32 | The screen pool's bitmap, a bit a screen in use |
$1E6A | 128 × 8 | The map names |
$226A | 128 × 16 | The maps' grids: 4 × 4 screens, each a pool screen + 1, 0 none |
$2A6A | 255 × 16 | The pool: 16 part numbers a screen, rows first |
$3A5A | 17,772 | The event space |
$7FC6 | 50 | Not identified (read in place of the start block in one case, test play by the look of it) |
$7FF8 | 8 | A copy of the bytes at $0000, $1000 … $7000 |
The database is fixed records, packed where they could be. Several numbers are 14-bit fields sharing a word with two bits of something else: the value is the word shifted right by 2, the low two bits belong to another field, and the editors cap the value at 9,999. An item's kind, 0–13, is split between the low bits of its power and its price; an enemy's attack word carries where it appears (land, sea) in its low bits; its defence, speed, experience and gold are four 14-bit numbers packed into 7 bytes.
| Record | Bytes | Layout |
|---|---|---|
Item (128 at $033D) | 13 | 0–1 power (bits 2–15) and the kind's low 2 bits; 2–9 name; 10–11 price (bits 2–15) and the kind's high 2 bits; 12 who can equip, bit n = hero n |
Spell (32 at $09BD) | 12 | 0–7 name; 8 MP cost; 9 the animation (1–13; 0 and $FF none); 10–11 power. The effect is the slot |
Enemy (80 at $0B45) | 30 | 0–7 name; 8 graphic (bits 0–6; bit 7 set on every defined enemy); 9 battle methods 0–7; 10–13 the spells it casts, a 32-bit mask; 14 methods 8–15; 15–18 the spells that work on it; 19–20 HP (bits 2–15); 21–22 attack (bits 2–15) and where it appears (bits 0–1: 1 land, 2 sea); 23–29 defence, speed, experience and gold, four 14-bit numbers, low bits first |
Hero (8 at $14C0) | 40 | 0–4 name; 5 graphic; 6 starting level; 7–11 the growth of strength, vitality, intelligence, agility and luck; 12–39 the level each spell is learned at, 32 × 7 bits (99 never) |
Two parts of the save are rewritten from the rest at every save: the two 32-bit masks at $0B3D of which field enemies appear on land and at sea, a cache of the enemies' own "where it appears" bits. A hero's type in the editor (えいゆう, せんし …) is not stored at all: it only fills in the growth figures from a preset.
The start block ($14A5, 27 bytes) is copied into the play state in RAM ($7E:8100) when a new game begins, and its fields land at the same relative places as the play saves keep them: the first party as four 4-bit hero numbers ended by $F, 24-bit gold, the ship's and airship's graphics as two nibbles stored + 1 (0 for none), the seven music slots (battle, ship, airship, field, town, dungeon, castle), the start map and place (map $FF is the field), and the two vehicles' places. A blank project starts heroes 0–3 on the field at 1, 1; the sample starts hero 6 alone in the throne room of map 127.
The power-on check#
Each time the console is switched on, the front end's step at $87:8270 calls $87:BB3F as the title menu first appears, and keeps the result in $06EF:
- Restore the 4 KB marks. The 8 bytes at
$7FF8–$7FFFare copied back to$0000,$1000,$2000…$7000. Every save makes that copy first, so each byte on a 4 KB boundary comes back from its last save before anything is checked. What it guards against is not settled: a trace from power-on to the title shows nothing else writing them. RT2 has no such copy. - The signature: 24 bytes,
SHVC?? SUPER DANTE, against the template at$87:BBE9. A mismatch formats. - The main sum (
$87:BCAE): the 16-bit sum of$031C–$7FF7, against the word at$031A. A mismatch formats. - Each play save (
$87:BC3D): the 16-bit sum of its bytes 2–255 against its first word. A mismatch zeroes that slot alone and sets its bit in the result. - The total (
$87:BC88): over the four words main, slot 0, slot 1 and slot 2 (a failed slot counts 0), each word w adds w + its low byte + its high byte. If it differs it is rewritten without complaint: the total is a record, not a check.
The format ($87:BCC7) writes the signature, zeroes $001A–$7FF7, writes a blank project's few defaults ($89:80D1: the start block's party and places, and $FFFF in every enemy's "spells that work on it" mask), then the sums and the total. The title then shows バックアップのデータがきえました. $06EF is 0 for a good save and for a new cartridge (a bad signature), $A0 for a bad main sum, and $80 + the slot bits for a failed play save; any nonzero value also switches on a debug box on the Turbo File pages until a game is started (below).
So the check has RT2's shape (signature, sums, slots, a total, a format) but is written separately: one sum where RT2 has nine sections, a total repaired rather than checked, a message where RT2 is silent, and the boundary copy.
Play saves#
Three of 256 bytes, at $001A, $011A and $021A. An empty slot is all zeros. A slot is written by $87:A60E (Record and the save point, after $83:831C has put the party's place into the play state) and read back by $83:86E8 on Continue; its fields are copies of the play state's.
| Offset | Bytes | What |
|---|---|---|
+$00 | 2 | The sum of bytes +$02–$FF |
+$02 | 2 | A stamp: the main sum when the slot was saved (written, never compared) |
+$04 | 1 | The save counter + $80: never 0, so the list takes a nonzero byte as "in use" |
+$05 | 1 | The kind of game: 0 the user's, 1 test play (テスト), 2 the sample (サンプル) |
+$06 | 3 | Gold |
+$09 | 2 | The party: four hero numbers in nibbles, $F ends it |
+$0B | 25 | The 200 switches, a bit each |
+$24 | 4 | The places visited, a 32-bit mask, for teleport |
+$28 | 28 | The rest of the teleport list as it stood (written, not read back) |
+$44 | 18 | Where the party is (map, x, y; map $FF the field), the two vehicles' places, what the party rides |
+$56 | 8 × 19 | The heroes, in hero order, in the party or not |
+$EE | 18 | Unused |
Each hero's 19 bytes are: the level; HP and MP now, 2 bytes each; experience, 24 bits; ten carried items, each an item number with bit 7 set if equipped ($FF none); and one byte not yet identified. The heroes' names, growth and spells come from the game data, never the slot: from the save for a user or test game, from the ROM's factory image for the sample.
A hand-edited save shows the reading is right: the factory image written out as text, one slot's gold set to 12,345, a hero's HP to 150 and the party reversed, then built back with new sums, plays in the emulator with exactly those changes.
The cartridge's damaged save#
The save on the second-hand cartridge studied here fails the check: its main sum is off by $B6, and its first power-on in a console would erase it. Three dumps after cleaning the contacts came back identical, so the damage is in the SRAM, not the reading. The stored total matches the stored sums exactly, so the game wrote the save whole and the data changed afterwards. With the layout known, the difference is six lone set bits, each in a field the save's project leaves empty, adding to $B6 exactly:
| Offset | Bit | Where | Why it is damage |
|---|---|---|---|
$0347 | $40 | Item 0's price | Every item of this project is empty; this one alone would cost 16 |
$1A5F | $20 | Screen 23's enemy mask | No screen is in use |
$2197 | $40 | Map 101's name | No map is named; $40 is ▼, which no name can hold |
$2719 | $02 | The map screens | All zero but for this bit |
$34CE | $04 | The map screens | The same |
$3BC7 | $10 | The event space | Zero past the events' end but for this bit |
Clearing the six bits gives an image that passes the check as stored, with no sum rewritten, and the game keeps it. Set bits and nothing cleared, scattered, in a save the battery otherwise held, is what decaying cells look like. What the save holds is on Behind the scenes.
Notes/Super Dante/Save.md; Tools/dante_save.py (check, dump, json and build: every field out to text and back, byte for byte; repair, factory).
Text and the fonts#
One byte a character, the same code in the save and the program's strings, and no second page: RT2's 01 xx kanji are gone, and with them all but 16 kanji. 00 ends a string, and a line of a message; name fields are padded with 5E, the space.
| Codes | Characters |
|---|---|
00 | End of a string, or of a message's line |
01, 02 | ゛ and ゜ alone (in no string) |
06, 07 | 『 』 |
08–0F | 姫 王 城 塔 戦 死 黒 法 |
10 | ▶, the cursor (8 × 8 font only) |
11–1F | 。 、 ー, the two halves of a bracket (8 × 8 only), ○ × ・, a small E (8 × 8 only), . , … ? ! / |
20–2A | P–Z |
2C–2F | 攻 撃 神 剣 |
30–3A | 0–9, : |
3B | A small raised P (8 × 8 only) |
3C–3F | 街 魔 士 聖 |
40 | ▼, more text (8 × 8 only) |
41–4F | A–O |
5E | The space |
5F–8C | あ … ん |
8D–95 | ぁ ぃ ぅ ぇ ぉ ゃ ゅ ょ っ |
96–C3 | ア … ン |
C4–CC | The small katakana |
CD–FF | The 51 voiced kana, が … ポ |
03–05, 2B, 50–5D | Unused |
From 5F on the table is RT2's byte for byte, and so are the digits and A–O. P–Z moved from RT2's 50–5A to 20–2A, the space from 40 to 5E, 『 』 to 06–07. 50–5D are unused: the 8 × 8 font keeps its window frame pieces there.
Two fonts:
- The proportional font (the messages, the editors' fields, the name keyboard): 256 word pointers at
$82:DEA2, one per code, each to a width byte and that many 16-pixel columns, RT2's record format. Every unused code points at one blank record. The kana are 11 columns wide, redrawn: no glyph is the same as RT2's. - The 8 × 8 font (the menus' small text, the battle's windows): 216 tiles of 2 bits a pixel at
$85:8040, not in code order, reached through a code → tile table at$82:DDA2. A voiced kana is drawn as its plain tile with ゛ or ゜ in the row above. Some codes exist only here: the ▶ cursor (10), the ▼ more-text arrow (40) and a small raised P (3B), so theHPandMPlabels are48 3Band4D 3B. RT2 has two 8 × 8 fonts in code order; with one font in its own order, Super Dante needs the table.
The character routine is $81:E7FD (RT2's $81:F6FA), with the text object's mode choosing the font. The program's strings are in the same code: 21 tables of long pointers hold 331 (hero types, item kinds, the 16 battle methods, the 32 magic effects, the 53 event commands in two forms, the keyboard's rows), and the screens' scripts print 985 more, 1,316 in all. The name keyboard draws its rows from one of these tables, so its three pages tie every typeable character's code to its glyph.
Notes/Super Dante/Text.md; Tools/dante_text.py (table, font, find, dump).
The event space and the bytecode#
All events live in one space of 17,772 bytes, $3A5A–$7FC5: a head of seven words, then the field's events, then every map's events in one run, each map event naming its map. RT2 has a directory and a block per map; here, finding a map's events means walking the whole run, and the sample's are in the order they were made, not by map. The head:
| Offset | The sample | What |
|---|---|---|
$3A5A | 426 | The number of events |
$3A5C | 7 | The bytes free: the event page's のこり |
$3A5E | 31 | The number of field events |
$3A60 | 426 | The number of events to the end of the maps' |
$3A62 | $05A3 | The end of the field's events, from $3A68 |
$3A64 | $4557 | The end of the maps' events |
$3A66 | $4557 | The end of all events |
The position is packed into a word. On the field (256 × 256 cells) the low two bits are x's low bits, the next two y's, then six bits of x ÷ 4 and six of y ÷ 4; on a map (64 × 64) four bits each, with the top four zero. The editor's cursor at 8, 1 on the field is $0024.
A page is its size word, a graphic byte (bit 7 set on people, clear on objects in every save: inferred to be the person / object flag, as RT2's flags byte has it), a byte with the movement type in bits 0–2 and the start condition in bits 4–6, then, on pages 2–4 only, six bytes of conditions: an item, a party mask (bit n = hero n), a switch and 24-bit gold, each $FF for "none" (gold $FFFFFF, party 0). A page 2–4 with no condition never holds. The commands follow, to the page's size, with no end marker. Pages are stored page 1 first, each header with its own commands; RT2 stores the headers highest first and the commands after them.
The commands are RPG Tsukuru 2's first 53, numbered differently. Super Dante stores the slot of each command in the editor's label tables, grouped by what it acts on; RT2 renumbered the same commands (the hero's moves first) and appended 22 more. The event editor's picker lists them in RT2's order, which shows the order the commands were designed in. Each command is an opcode byte and fixed operands; only the message, 01 nn then nn lines each ended by 00, carries text.
| Op | Command | Bytes | Operands | RT2 |
|---|---|---|---|---|
00 | End the event | 1 | 00 | |
01 | Message | 2 + text | Line count, then the lines | 01 |
02, 03 | Switch on, off | 2 | Switch | 02, 03 |
04, 05 | Item +, − | 2 | Item | 04, 05 |
06, 07 | Gold +, − | 4 | 24-bit amount | 06, 07 |
08–0B | HP +, HP −, MP +, MP − | 3 | 16-bit amount | 09–0C |
0C, 0D | Poison, paralyse | 1 | 0D, 0E | |
0E, 0F | A hero joins, leaves | 2 | Hero | 0F, 10 |
10 | Experience + | 4 | 24-bit amount | 08 |
11 | Battle | 5 | Four enemies, FF none; no music | 29 (music and four) |
12 | Warp | 4 | Map (FF the field), x, y | 2A |
13–16 | The event faces up, right, down, left | 1 | 19–1C | |
17–1A | The event steps | 1 | 1D–20 | |
1B–1E | The hero faces | 1 | 11–14 | |
1F–22 | The hero steps | 1 | 15–18 | |
23 | Inn | 3 | 16-bit price | 2B |
24 | Shop | 5 | Four items, FF none | 2C (eight) |
25 | Flash the screen | 1 | 21 | |
26–2A | Screen brighter, darker, red, blue, monochrome | 1 | 22–26 | |
2B | Colours back | 1 | 27 | |
2C | Shake the screen | 1 | 28 | |
2D | Wait | 2 | Tenths of a second | 2D |
2E | The event vanishes | 1 | 2E | |
2F, 30 | Music, sound | 2 | Song, effect | 2F, 30 |
31, 32 | Yes, no (the branches of a question) | 1 | 31, 32 | |
33 | Save point | 1 | 33 | |
34 | The ending | 1 | No music | 34 (a song) |
Questions work as RT2's: a message, then 31, the yes branch, 32, the no branch to the end of the page. The sample has six, none nested. Of the 53 commands the sample uses 45; the most used are the message (362 times), the warp (158), the sound (128), the wait (127) and switch on (122), and the hero's steps 295 times together.
The interpreter#
The step is RT2's code ($81:A6D2, RT2's $81:A393): a running event is an object with its command pointer at [$0C] and a flag byte at $0F. While bit 1 is clear the step calls the opcode's start handler (table at $83:C024); while it is set, the continue handler ($83:C0B4) once a frame; it loops within the frame until bit 0 (done) or bit 1 (waiting) is set. A run of switches, items and gold costs no frames; a message, a step or a wait holds the event. Advancing adds the command's size from the table at $83:FA4D, or for a message counts its lines' ends.
There are 72 handlers: the 53 commands and 19 of the runtime's own, $35–$47 (RT2 has 93). The handlers are not RT2's code: only the experience, inn, shake, wait and sound handlers begin with RT2's bytes, and the rest are written around Super Dante's operands. The runtime's own opcodes run its small scripts:
| Op | What | RT2 |
|---|---|---|
$39 | Fade the screen in, to full brightness | 50 |
$3D | Gather the party | |
$3E | Jump through slots that hold JML $000000: unfinished | |
$3F | Board the ship | |
$40 | Board the airship | 54 |
$41 | Stop | |
$44 | End of the page | 57 |
$45 | A 3-frame wait | 58 |
$35–$38, $3A–$3C, $42, $43, $46, $47 | Not identified |
Pseudo-events. The start of play and boarding a vehicle are 16-byte event scripts the runtime copies to $7F:F800 ($84:9FBC). The start of play is 12 mm xx yy 39 44, with map and place filled in from the start block or the save: a warp, a fade in, the end. RT2's is the same, 2A mm xx yy 50 57, in RT2's numbers. Boarding the ship is 3D 3F 41, the airship 3D 40 41.
Choosing a page. The highest of pages 2–4 whose conditions all hold is shown and run, else page 1 ($84:A298). An item condition holds when anyone in the party carries the item, equipped or not; a switch is bit n & 7 of byte $96 + (n >> 3) of the play state, the 200 flags the play save keeps.
Notes/Super Dante/Events.md, Game.md; Tools/dante_events.py (head, check, dump, table).
Maps, the part codec and Mode 7#
Maps are built in RT2's units, with one twist: the parts are packed in the ROM by a codec of their own, and the field is a picture in the ROM rather than something the user builds.
| Unit | Size | What it is |
|---|---|---|
| Tile | 8 × 8 pixels | Maps: 4 bits a pixel, mode 1. The field: 8 bits a pixel, Mode 7 |
| Chip | 16 × 16 pixels, one cell | 4 tiles |
| Part | 4 × 4 chips | 16 chip numbers, packed in the ROM by the codec |
| Screen | 4 × 4 parts | Maps only: 16 part numbers in the save's pool of 255 screens |
| Map | 4 × 4 screens: 64 × 64 cells | A grid of 16 pool screens, 0 for none (part 0 drawn there) |
| Field | 64 × 64 parts: 256 × 256 cells | One of four in the ROM; nothing of it is in the save |
A map is laid out by $84:9DB8: each of its 16 grid cells takes a pool screen's 16 part bytes ($2A6A + 16 n), or part 0 for an empty cell, into a part window at $7F:0000. The kind nibble chooses everything else: a load routine, a script, and the kind's own parts, chips, tiles and colours. The castle set animates four of its tiles.
| Kind | Load | Parts | Ground chips | Object chips | Tiles | Colours |
|---|---|---|---|---|---|---|
| Castle (9) | $84:983F | $96:B376 | $96:BBD7 | $96:C337 | $96:8000 | $96:C277 |
| Dungeon (A) | $84:98B1 | $96:F5CA | $97:8000 | $97:8460 | $96:C54F | $97:83A0 |
| Town (B) | $84:9923 | $97:B181 | $97:AA89 | $97:B8BD | $97:85E8 | $97:B7FD |
| The field | $84:9791 | $98:8000–$9B:8000 | $99:BD75 (239) | $9A:C765 (19 objects) | $99:C4ED | $9A:C6A5 |
The part codec#
A part is 16 chip numbers, but the ROM doesn't store them as 32 bytes, as RT2 does. It stores one record per part, packed, and decodes it on demand ($81:CD01):
$81:CD01. Parts are not stored one by one: a pointer leads to a run of eight records of different lengths, and each record is a small program in one of 65 forms, many of them built on a neighbouring part.- Finding the record. The set's table has one 3-byte pointer for every 8 parts. Part p's record is found from pointer p >> 3 by skipping p & 7 records, each record's length given by its first byte through a length table (
$81:CE95). - Decoding it. The first byte, always even, picks one of 128 handlers (
$81:CD95; 70 distinct routines, 65 kinds in use), which write the 16 chip numbers to[$F4]. The simplest store sixteen chip bytes or sixteen words, or one value for all sixteen cells. Others choose between two, four or eight chips per cell by one, two or three 16-bit masks. - Sharing. Many kinds start from another part, an earlier one (p − (256 − b)) or a second part decoded into the buffer's other half, and change a few cells. Neighbouring parts that differ in a corner cost a few bytes.
- A part number with bit 15 set would take 32 bytes from RAM instead; no part in the ROM does.
Rather than re-implement 70 handlers, the project's map tool runs $81:CD01 itself in a small 65816 interpreter, about 600 instructions a part; the four fields' 16,384 parts take about a minute. RT2 dropped the codec for plain 32-byte parts.
The field and Mode 7#
The field is Mode 7: one 8-bit-colour layer that the console can rotate and scale, the tilemap kept as a 128 × 128 window that follows the view. Four fields are in the ROM, each 64 × 64 parts (256 × 256 cells, 4,096 pixels), and the save's header byte $1E00 bits 0–1 chooses one (the sample uses field 2). Each field's parts have a bank to themselves ($98–$9B), and the four share one chip table (239 chips, $99:BD75), one set of 256 tiles ($99:C4ED, packed by method $04) and one set of colours. The field wraps at its edges.
Field objects (an object event with graphic 1–19) are drawn into the field itself: the event loader ($84:A42F) writes up to four chips from a 19-entry table at $9A:C765 over the ground, so a castle or a town is part of the picture. People are sprites. The same Mode 7 engine draws the title card's field behind the game's title and the airship's view, with perspective tables shared with RT2 (16 KB from $82:9D49).
Layers on maps. In mode 1, BG2 is the ground (the parts) and BG1 the objects: an object event's graphic g is chip g of the kind's object chip table, on its cell. People and the party are sprites.
Passability is per edge ($83:A14A). Each chip has an attribute byte whose low four bits close its four sides (0 right, 1 up, 2 left, 3 down), from tables at $83:A770 (ground) and $83:AB70 (objects), 256 entries per kind: field, castle, dungeon, town. A step in direction d is blocked if the cell left closes side d or the cell entered closes the side facing it. On maps the object layer's chip replaces the ground's where there is one, and a person blocks. RT2 has one attribute per cell, open or closed.
Battle backgrounds follow the place: on a map by its kind (castle hall, cave, town street), on the field by the chip under the leader (grassland, desert, sea, forest, swamp, or the rocky canyon if any neighbour is one).
Notes/Super Dante/Maps.md, Game.md; Tools/dante_maps.py (render, check, sheet, list), Tools/snes_cpu.py, Tools/snes_ppu.py.
The decompressors and the graphics#
Every packed block begins with a method byte, and one routine, RT2's ($80:8AC0), dispatches on it. Super Dante uses only the two LZ methods: RT2's tile packer, method $10, is not there, and the characters' tiles are stored raw.
| Method | Routine | What | Used for |
|---|---|---|---|
$00 | $80:8AEA | Stored | |
$04 | $80:8B36 | LZ on bytes | The fields' tiles |
$08 | $80:8BF7 | LZ on 16-bit words | Everything else packed: map tiles, enemies, battle backgrounds, spell animations, the vehicles, the editors' graphics |
$10 | RT2's tile packer | Not in Super Dante |
The LZ methods read eight tokens to a control byte: a literal, or a copy of 3–18 units from a position in a window that starts with zero units before the output.
| What | Where | How |
|---|---|---|
| 54 enemies | $8D:8000 + 2 g (headers), $8D:8294 + 4 g (colours) | Width, height, tiles and arrangement (method $08); one 16-colour palette each, no colour choice |
| 9 battle backgrounds | $94:8000 | Tiles, a 32 × 28 tilemap and 32 colours each |
| 54 characters, the vehicles | $91:8000 (tiles), $91:80F4 (frames), $90:8000 (colours) | 61 entries: 1 the air vehicle's shadow, 2–4 a dragon, an airship, a balloon, 5–6 a sailing ship, a small boat, 7–60 the characters |
| 13 spell animations | $92:8000, $92:8068 | Tiles, two sprite palettes, frames and a sequence of (frame, time) pairs; 1–32 steps |
| The fonts | $82:DEA2, $85:8040 | The proportional font; the 8 × 8 font |
| Map sets, the fields | $96–$97, $98–$9B | Above |
| The editors' graphics | $8B | Method $08 streams |
Characters and vehicles share one table: 61 entries, each a pointer to its sprite tiles and one to its frame table (a frame is a count, then per 8 × 8 piece its offsets, tile and attributes). Entries 1–6 are the vehicles and the air vehicle's shadow, packed; entries 7–60 are the 54 characters, raw, graphic g being entry g + 6. A character is 16 × 16 pixels in 8 frames, two each way, and stores only the tiles its frames use (24 to 32). Graphic 0 is turned into 54, a blank, when a game starts, so "no graphic" is invisible. RT2's characters are 16 × 24, in fixed blocks of 48 tiles, at resource g + 15.
Spells store their animation as graphic g, which plays animation g − 1; graphic 0 plays none. Each of the 13 animations has its own 32 colours, where RT2's 23 share one set.
Notes/Super Dante/Graphics.md; Tools/dante_gfx.py (enemies, battlebgs, sprites, magic, check).
The object-script VM#
Almost everything Super Dante shows is bytecode: the field's windows, the event commands' windows, the battle's flow and its messages, the front end, every editor page, the boot screens and the demo. RT2's virtual machine runs it, the same code moved 6 bytes lower in bank $80: the run loop is $80:9D34, a script is started by $80:9CD6, and the op lengths, handlers and continue handlers are tables from $80:BB1F. Bit 7 of an op turns its last operand into a variable; variables are reached through a base (absolute, the object's own record, a walk of the object tree); control flow is structured (if, else, loops, switch and case, no jump offsets).
Eight operations are swapped. The two programs have the same set of operations, but eight of them sit in opposite places: what is an op in one is a sub-op (after a 00 or 80 prefix) in the other.
| Super Dante | What | RT2 |
|---|---|---|
Ops 70–75 | Print a variable in binary or hex, 8, 16 or 24 bits | Sub-ops 10–15 |
Op 7C | Have the NMI upload the colours every frame | Sub-op 17 |
Op 7F | Wait for a pad button | Sub-op 19 |
Sub-ops 10–15 | Push and pop a byte, word or 24-bit variable on the data stack | Ops 70–75 |
Sub-op 17 | Set the palette bits over a rectangle of the window | Op 7C |
Sub-op 19 | Load through a pointer | Op 7F |
Sub-ops 1A, 1B | AND and OR the palette bits over a rectangle | Stores through a pointer |
The swap is consistent through every script: the push and pop that every script uses take 4 bytes in Super Dante and 3 in RT2, while the debug prints nothing uses take a full op. So the encoding changed between the programs and the scripts were recompiled; with the debug prints as ops, Super Dante's reads as the earlier layout. Sub-ops 1A and 1B are Super Dante's own: they AND and OR the palette bits over a rectangle of a window, and only the field's scripts use them (78 times).
Where the scripts are. Windows are found through tables of long pointers indexed by an object's +$6C: the field's 49 windows at $84:A65F, the battle's 16 scripts at $85:A705, the front end's and editors' 139 at $87:8008, and the event commands' windows, which here have a small table per command (the message, the inn, the shop, the full bag, the yes / no, the save point) where RT2 has one of 13. The editors also keep script addresses in variables and describe their lists by records of pointers, which the project's walker follows.
From these, 903 scripts and subroutines, 118,503 bytes, are reached in banks $82–$85 and $87–$8A, and no walked byte ever ran as code. RT2 has 1,634 and 202,130 bytes. Of 201 valid op bytes, 114 are used; goto, the exchanges, the 24-bit arithmetic and the plain number prints are never used, and the hex prints only by one debug box. Bank $8B, which RT2's layout suggested would hold the editors' scripts, holds packed graphics.
A message runs the same way: the message command compiles its lines into VM text ops in an 80-byte buffer (60 6E line 00 6C 6C a line) and runs them, four lines to a window, with a blinking ▼ at the end.
Notes/Super Dante/Scripts.md; Tools/dante_vm.py (dis, tree, windows, scan, check, listing).
The battle and the random numbers#
A battle has eight records of 256 bytes: the party in slots 0–3, the enemies in 4–7. A hero's record is the hero's play record ($7E:8200 + 256 × the hero) copied whole; an enemy's is built from its 30 bytes in the save, the 14-bit fields unpacked. The flow is scripts (the table at $85:A705) calling native routines for the rules, as in RT2, and the action codes, the turn order (by speed, a bubble sort that swaps only on strictly less), the enemy's choice (every method and spell it has equally likely) and the experience table are RT2's. The rules inside are not: damage is attack − defence ÷ 2 with 0 possible, confusion does nothing, an enemy that revives does so every turn, items are always used up. How battles work gives them all.
The action blocks. Each target of an action gets a block of $40 bytes from $7E:8B30, shared by all combatants and outliving a battle: the target, the amount, the kill and miss flags. A heal-all fills one block per living member but applies them to every member, stepping on for the fallen too, so the last living member reads a block nobody filled this time. That is the heal-all bug.
The random number generator#
$80:8A84: s = s × 5 + $3711, 16 bits at $00A7, returning the high byte; $80:8A9A takes a step and returns the high byte mod n. It is RT2's code. The start-up clears RAM but keeps $00A7, so the seed is whatever the RAM held at power-on. Unlike RT2, Super Dante doesn't draw numbers while it waits for a frame: runs in two emulators from the same cleared RAM and the same presses drew the same numbers in the same order, some a frame later (inferred from that).
Encounters ($85:9060) are one fixed curve, with no rate per place. A counter goes up by one each step on foot or by ship (and jumps from 16 to 24); a battle starts if a random byte is below the table at $85:90CF:
| Steps since the last battle | 1 | 2–7 | 8–12 | 13–15 | 16 on |
|---|---|---|---|---|---|
| A battle's chance a step | 0 | 1 in 256 | 2 in 256 | 4 in 256 | 32 in 256 (1 in 8) |
Table entries 16–23 hold a gentler ramp (4, 8, 8, 12 … 28) that the jump to 24 skips: a curve someone meant to smooth, and didn't. The enemies come from the place's 32-bit mask (the field screen's at $1600, ANDed with the land or sea mask; a map screen's at $1A00), shuffled by 331 random swaps; the group size is a table of sixteen each of 1, 2, 3 and 4 indexed by a random number & 63, capped by the enemies available and the screen's width (32 tiles).
Notes/Super Dante/Battle.md, Game.md; Tools/dante_battle.py (record, check, show: a battle recorded in the emulator and replayed through a model of the rules), Tools/dante_xcheck.py.
The sound driver#
Super Dante has its own SPC700 driver, the earlier generation of the line that RT2 and the SFC Kanadeeru continue: RT2's command bytes, sequence bytes, tempo formula, pitch table and record layouts are all here, but the code is another build, sharing only about 190 bytes with RT2's beyond the 768-byte pitch table. At power-on ($9F:FFFD → $9F:B6B4) the program sends the sound chip everything in one list, through the chip's boot ROM, from bank $9C:
| To | Bytes | What |
|---|---|---|
$00F2 | 15 × 2 | DSP settings: the echo at $E000, 8 KB |
$06C0 | 7 | Two entries: the cold start, the restart |
$06CC | $112E | The driver |
$DF00 | $C8 | Its DSP set-up and the vibrato presets |
$1840 | $100 | 64 instruments |
$1A00 | $84 | The sample directory, 33 entries |
$1B00 | $A464 | The 33 samples (BRR) |
$1940 | $C0 | The 24-note drum kit |
$C000 | $16 | An empty song, block 0 |
$D000 | $D3C | The 60 sound effects |
- The interface. A sound is
JSL $9F:FFFAwith its number in A, straight to the ports with no queue: the command, a parameter if any, then a counter the driver echoes. - Its own clock. Timer 0 ticks the driver 62.5 times a second; RT2's driver ticks only when the 65816 sends it a command each frame. With 24 units to a quarter note, the tempo byte is the beats per minute at 60 ticks, so songs play about 4 % faster than their figure.
- Songs. 31 songs in 19 blocks of 1–3; a block is sent to
$C000through the boot ROM when its song is wanted, and a change of song within a block costs no upload. Each song has eight tracks on the eight voices, every track with its own tempo. Six songs end; the other 25 loop. - Effects are 60 sequences in the same format at
$D000, one unit a tick. An effect takes the voices it names (most use voice 6 or 7, the victory fanfare all eight), muting the music's channel there, which keeps counting so it comes back in step. The newest effect wins. - Instruments. 64 instruments on 33 samples (41 KB), a 24-note drum kit and 9 vibrato presets, all uploaded once; no sample has a tuning of its own (RT2's do).
- Fades. Before a new area's song the game fades the old one out and the new one in; fades touch only the music.
| A | Does |
|---|---|
$00 | Stop everything |
$01–$1F | Song 1–31 (its block uploaded first if needed) |
$20–$5B | Effect 0–59: the event command's sound 1–60 |
$5C–$7F | Nothing |
$FF, $FE | Mono, stereo |
$FD, $FC | Pause, resume |
$FB, $FA | Fade the music out, in |
$F9 | The next song fades in |
$F8, $F7 | Fade speed, a level (the parameter in X) |
$F6 | One extra tick |
Notes/Super Dante/Sound.md; Tools/dante_sound.py (uploads, check, song, se, instruments, samples, rip, verify). Every song and effect is ripped as an .spc from the ROM alone (Music and sound).
The Turbo File#
Bank $86, from $86:F000 to $86:FFE7, holds the STF library that all four SFC Tsukuru titles carry, in an earlier build than RT2's. It has one entry, JSL $86:FE16 with a function number in A, and a table of 15 functions (RT2 has 17). It returns 0 for success; an error stores its code at $7F:E000 and restores the stack pointer saved at $7F:E002, a jump out of any depth. Its first $383 bytes (the wire routines, the block read, write and verify) are RT2's at the same offsets, so every block written is read back and compared here too; after that the code differs.
| Function | Entry | Used for |
|---|---|---|
| 0 | $86:FE65 | Start: the device's status |
| 1 | $86:FE81 | Mount: read the table, check FAT0 |
| 2 | $86:FE9D | Format (from the check, and from the delete page when everything is marked) |
| 3, 4 | $86:FEB9, $86:FECE | The first and the next file matching a pattern |
| 5 | $86:FEF5 | Select the first matching file |
| 6 | $86:FF16 | Free space |
| 7 | $86:FF37 | Delete |
| 8, 9 | $86:FF58, $86:FF79 | Open for reading; create |
| 10, 11 | $86:FF9A, $86:FFA9 | Close after reading; after writing |
| 12, 13 | $86:FFB8, $86:FFC7 | Read, write n bytes |
| 14 | $86:FFD6 | Status only (never seen called) |
The Twin in STF mode is 128 KB: a 4 KB table of 124 four-byte entries (each a file's size on its first block, the next block, and the block's 8-bit sum), the mark FAT0, then 124 blocks of 1 KB.
The file is the SRAM after its signature, under a 24-byte header in place of the signature:
| File offset | Bytes | What |
|---|---|---|
$0000 | 20 | SHVC ARDJ SUPER DANTE, the pattern at $88:AF15 |
$0014 | 1 | The kind: always N |
$0015 | 3 | The number, three ASCII digits |
$0018 | 32,744 | SRAM $0018–$7FFF: the total, the play saves, the sum and the whole game |
- Saving (
$88:AEC2) copies the whole SRAM to$7F:0000, writes the header over its first 24 bytes, and calls create, write$7FE8bytes from$7F:0018, and close. The file takes the first free blocks. - Numbering (
$88:AF52): the walk marks each Super Dante file's number in a 1,000-byte table at$7F:8000; the new number is the highest + 1, or the lowest free once 999 is taken. The load list is built from the same table, eight a page. - Loading (
$88:AE31) finds, opens and reads the file into$7F:0018, and only then copies it to the SRAM from$0018. A file that fails to read leaves the SRAM alone; the signature at$0000is never touched, and the power-on check doesn't run after a load. - The kinds. The letter after the name is chosen from a two-entry table,
NandC. OnlyNis ever written; on loading,Cdispatches to a bare return. A second kind of file was planned and never made. - Formatting writes
$FFover the whole table area andFAT0, leaving the blocks; deleting frees the file's table entries and leaves its blocks. RT2's format writes only the 124 entries.
Super Dante's files are the ones whose header starts with its 20-byte pattern ($88:AF15); others appear only on the delete page. Save, load and delete round-trip byte for byte, and every Twin image the game wrote can be rebuilt from its contents by the project's tool.
Notes/Super Dante/Storage.md, Notes/Turbo File.md; Tools/dante_store.py (twin, list, srm, check), Tools/snes_turbofile.py.
Hidden in the ROM#
The program carries a little it never shows, all on Behind the scenes:
- A debug box on the Turbo File pages. After every library call, the front end's Turbo File scripts call
$87:EAD7, which does nothing while$06EFis 0. After a power-on that erased the save it isn't, and the box printsFUNC:the function,ERR:its result andADR:an address, and waits for a button, until play clears$06EF. These are the only uses of the VM's hex print ops. - An older build's debug monitor in bank
$80's never-run stretch ($80:C0BC–$80:EFFF): a boot screen readingKUSOU KAGAKU DEVELOP SYSTEMVER 2.18, a crash handler that set mode$08, and an error screen dumping the script VM's state (its PC, the op, the two stacks, a step count), all in ASCII for a font the final program doesn't have. - Stale scripts of an earlier build in banks
$82and$84, linked against an older layout: an old field menu with a のりおり (board / leave) command the final game dropped. - The sound driver's credit,
ApuDrv v1.0 (C) 1994 S.Isoda, at$9F:FFC0.
There is no debug menu: one pad reader ($80:8873), and no button code but L + R + START + SELECT and test play's B.
Notes/Super Dante/Hidden Content.md.
How this was checked#
Every format on this page was written back as well as read, or drawn and compared with the emulator's own screen, so that a reading that was nearly right would show:
| What | How | Result |
|---|---|---|
| The save | Every field out to text and back, for the factory image, a blank project and the cartridge's save; a hand-edited save played | Byte for byte; the edited save plays as edited |
| The power-on check | The game's sums recomputed; saves good and bad run from power-on | Every sum as the game makes it; the damaged save erased, the repaired one kept |
| The events | Every event, page and command of both saves parsed to its size | Factory 426 events, 603 pages, 1,808 commands and 7 bytes free: the 17,772 exactly |
| The maps | Seven views drawn from the save and the ROM (the part codec run as the game's own code), against the emulator's layers | Pixel for pixel |
| The graphics | A battle screen drawn from the ROM; every sprite in the seven views | Pixel for pixel; every frame as expected |
| The battle | Recorded runs (16 in Mesen, 10 in bsnes) replayed turn by turn through a model of the rules | 517 turns and 76 escape rolls in Mesen, 276 and 47 in bsnes; none wrong |
| The sound | Every song and effect ripped from the ROM and played against the game playing it | All 91 match, every track's position on the same frame within one |
| The scripts | The VM's length tables against its operands; every reachable script walked | No mismatch in 201 ops and 41 sub-ops; 903 scripts, none ever run as code |
| The text | The keyboard's rows decoded through the table | Exactly the keyboard's three pages |
| The Turbo File | Save, load and delete in MesenCE with a Twin | Both saves out and back byte for byte; every Twin image rebuilt |
- The emulators. Mesen 2, run headless by a script (savestates, scripted presses, watches, traces, memory dumps, screenshots from the frame buffer); MesenCE, a fork of it that emulates the Turbo File Twin; and bsnes through its libretro core, run from Python.
- Why replay. A battle is recorded with every random number at its call site and every change to the combatants, then replayed through a model of the rules, which must give the same action, HP and status every turn.
- The second emulator. In bsnes, which has no execution hooks, a copy of the ROM was patched to log the same things to a ring in RAM. Started from cleared RAM with the same presses, the two emulators drew the same numbers and played the same battles.
- The game's own code where it is easier. The part codec and the maps were checked by running
$81:CD01itself in a small 65816 interpreter, and the sound rips by having a copy of the ROM play each song from the opening demo's call.
Notes/Super Dante/Analysis Plan.md; Tools/mesen.py, Tools/lr.py.
Fan-made reference material, one of the Eschaton Games Tsukuru guides. Not affiliated with the publishers of the titles it covers. Corrections and questions: contact@eschaton.games.