Eschaton GamesRPG Tsukuru Advance an English guide

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 flash, and how the program runs a game. Addresses are the GBA's own: the ROM appears at 0x0800_0000, the two work RAMs at 0x0200_0000 (256 KiB) and 0x0300_0000 (32 KiB), the flash at 0x0E00_0000. Offsets inside the flash and inside a record are written $90, +$1A. Everything here was read from the program and checked in emulators (the last section says how); where a point was read from the code but not seen running, it says so (read), and where it is a reading not traced to the end, inferred. Each section ends with the project's notes and tools that hold the full detail: they are files in the project that made this guide, not pages of the site.

RPG Tsukuru Advance is a new program. It is written in C, by RPG Tsukuru GB's team, and shares no code with GB (hand-written Game Boy code) or with RT3 and RT4 (C on the PlayStation). What it keeps from GB is the design: numbered kinds of task, each a table of steps run once a frame; GB's battle rules; and GB's Turbo File driver, written again byte for byte. Compared with the titles around it sets them side by side.

The cartridge#

The ROM's header names it RPGTCOOLGBA, game code A8TJ, maker CP. Inside:

There is no development tag: no company string, no build date, no developer's name. The only version in the ROM is 「VERSION 0214A」 on the DEBUG TASK, a developers' boot screen nothing reaches (Behind the scenes). The program was compiled with GCC (libgcc's helpers are linked in), with Nintendo's MusicPlayer2000 for sound and AGBAssert for its checks; 33 source paths survive in the asserts (below).

Notes/RPG Tsukuru Advance.md, Notes/RPG Tsukuru Advance/Program.md.

The ROM map#

ROMWhat
0x0800_0000–0x080E_EDBBCode, 0.93 MiB: the ARM start-up, then the program in Thumb, then the libraries; the ARM interrupt dispatcher at 0x080E_ED00
0x080E_EDBCThe scene table: 13 scene functions
0x080E_EE90The process table: 299 kinds × 16 bytes
0x080F_0140The signature RPGTCOOL GBA; at 0x080F_0154 the empty game's header
0x080F_0154–0x0813_70FFThe program's data: each kind's state table, strings, the windows and screens, the database's defaults
0x0813_7100MusicPlayer2000's players; 0x0813_7118 the song table (307 entries)
to 0x087F_9FAFSound samples and songs; graphics from 0x081B_A2A0, 58 regions, every one with code that loads it; the font (0x0872_B184, 0x0873_A184), and the three project images: the default library at 0x0871_B2B4 (raw), Jewel Keeper at 0x0871_EE14 and the Tutorial at 0x0879_ED28 (both LZ77)
0x087F_9FB0–end$FF: 24,656 bytes of padding

The code is 0.93 MiB, and analysis found none past it: 5,557 functions in a Ghidra project made from a copy of the ROM. Two pieces run from RAM: the flash library's read loop, which it copies onto the stack, and MusicPlayer2000's mixer, copied to the fast RAM at start-up. The libraries are Nintendo's and the compiler's:

AddressLibrary
0x080E_6E1C–Nintendo's MusicPlayer2000 (m4aSongNumStart; SoundMain 0x080E_60E8, whose mixer runs from IWRAM at 0x0300_1268)
0x080E_8300–Nintendo's FLASH512_V130: ReadFlash 0x080E_8548, which copies its inner loop onto the stack and runs it there; the sector writer 0x080E_89A6
0x080E_8C40–0x080E_8FC0Nintendo's AGBPrint and AGBAssert (assert_fail 0x080E_8F9C)
0x080E_8FE4, 0x080E_8FE8libgcc's _call_via_r1, _call_via_r2: every call through a pointer
0x080E_AFC0–0x080E_B27CThe C library: memcpy 0x080E_B008, memset 0x080E_B0F0, memcmp 0x080E_B27C; newlib's rand at 0x080E_B158

Notes/RPG Tsukuru Advance/Program.md; Tools/adv_ghidra.py (the Ghidra project, built headless), Tools/adv_dis.py (a Thumb listing).

The program#

Scenes#

The main loop (0x0800_0108) runs one of 13 scene functions from the table at 0x080E_EDBC, chosen by the byte at 0x0201_0710. Each scene creates one root process, and the rest of the scene is that process's tree. The boot stores 4, the title, or 10 in the user-game mode; the top menu chooses the next by tab × 3 + item through the table at 0x0813_5A28.

SceneRoot kindWhat
00The boot and the power-on check
11The DEBUG TASK: nothing sets this scene (Behind the scenes)
22A play session
311Make the Data
4272The title
5273The top menu (with 261, its tabs)
6276Data Exchange
7277Options
8278, play mode 2Jewel Keeper's title
9278, play mode 3Make the Game: your game's title, for test play
10278, play mode 1Your game's title, in the user-game mode
11281Turbo File
12298Loading the Tutorial

Processes#

The whole program, the editors, the game player and the system's windows alike, is a tree of processes. Each process is one of 299 kinds, defined by the table at 0x080E_EE90: 16 bytes a kind, the enter function (called once, when the process is made), the leave function (when it ends), its state table (one function a state), and flags. Every frame, each live process runs the function its state byte names; a state moves on by changing that byte. A screen's code is found from its kind: its enter sets it up, its states are its loop, and the kinds it creates are its windows and pages.

A framemain loop0x0800_0108scene byte0x0201_0710: 0–12scene table0x080E_EDBC, 13root process0x0300_1220Each frame every live processruns the state its byte +5 namesfrom its kind’s state table(0x080E_EE90, 299 kinds).Scene 5: the top menu273top menu261the three tabs250cells251cellsScene 2: play (as seen at the first message)2the play session4the field (3 on the world)56 ×289event runner10 ×37map objects1712message window9 also creates 13–20:choices, shops, the inn …34field menu (B)160create mode (START)created under the field when needed61battle62–71 its parts;from the fieldor an eventServices under everyscreen: 240 the windowcontroller, 246 yes/no,250, 251 the animatedcells
The program as a tree of processes: the main loop runs one scene, each scene builds its own tree, and the numbers are the processes’ kinds. Play’s tree is as seen at the cartridge game’s first message.

proc_create(parent, kind, priority, flags, param) (0x0800_1290) takes a process from a free list, joins it to a run list and to its parent's children, and calls the kind's enter. The root is at 0x0300_1220, the run lists after it at 0x0300_1244, one list a priority at 0x0300_1258; each frame 0x0800_172C walks them. Ending a process (0x0800_13A8) calls its leave at once; a process with children stays, inactive, until the last of them ends, and is freed then.

OffsetWhat
+$0Flags: bits 0–1 active, bit 2 flipped as the frame's walk passes it, bits 3–5 from the creator's flags
+$2The kind
+$4The priority (a run list for each)
+$5The state: the index into the kind's state table
+$10The parent; +$14, +$18 the first and last child; +$1C, +$20 the previous and next sibling
+$28–The links in the run lists

The kinds sit in the ROM in the source tree's order, so a range of kinds is a part of the program:

KindsCode fromWhat
0–10, 12–230x0801_905CThe boot and the game player: 0 the boot, 1 the DEBUG TASK, 2 a play session, 3 the field on the world map, 4 on a local map, 5–10 and 17 the field's parts (10 one per thing on the map), 9 the event runner, 12 the message window, 13–20 the runner's windows (Yes/No, Choice, Password, telops, the church, the inn, the shop), 21–23 the egg palette
11, 237–239, 254–260, 262–271, 274–279, 287–2980x0805_70ECThe top level: 11 Make the Data, 238 Clear Data, 254 the first-time setup, 262 the level-up window, 263 the staff roll, 264 the end mark, 265 the Game Over, 266 "save the game's data?", 267 the save point, 276 Data Exchange, 277 Options, 278 a game's title, 279 its Continue, 287 its Options, 298 the Tutorial's load
72–2360x0806_8124The editors' pages, in the source's order: the title 72–75, the system 77–80, characters 82–86, jobs 92–95, items 98–101, skills 106–109, monsters 112–116, units 121–124, maps 130–151, create mode 160 and its placement editors 161–180, an event's contents 187, the command catalogue 188 and its parameter pages 190–220, Save 228, messages 230–234, keywords 236
240–2520x080A_77FCThe services: 240 the window controller under every screen, 242–244 the number boxes, 246 the Yes/No box, 250 and 251 the animated cells of the title and menus
61–710x080A_BCC0The battle: 61 and its parts
34–60, 2800x080C_B0ECThe field menu (34) and its pages: Items 35, Status 42, Skills 45, Equip 50, Order 56, Save 57 (58 in test play); 280 the map view
24–33, 253, 261, 272, 273, 281–2860x080D_B97C24 the name keyboard, 27–33 its lists of names; 261 the top menu's tabs, 272 the title, 273 the top menu; 281–286 the Turbo File

Four kinds are never created: 49 (an equipment menu), 189 (an event-editor page), 224 (a developer's shortcut into create mode) and 237 (a menu in Make the Data); and kind 1, the DEBUG TASK, is created only by scene 1, which nothing sets (Behind the scenes).

The pad#

One routine reads the buttons (0x0800_F348, once a frame, the only reader of the GBA's key register), into 0x0201_0730: the buttons held, those new this frame, and a repeat (12 frames, then every 6). Up with down reads as up, left with right as left. Nothing reads the buttons at power-on or compares a sequence of them: there is no soft reset and no button code (read).

The asserts#

The program links Nintendo's AGBPrint and AGBAssert: 58 checks in the code call assert_fail(file, line, expression, halt) (0x080E_8F9C), every one with halt set. On the developers' IS-AGB debugger that prints 「ASSERTION FAILED FILE=[…] LINE=[…] EXP=[…]」 and stops. On a cartridge it shows nothing: the debugger's registers at 0x09FE_xxxx are then a mirror of the ROM, so the print loop reads game data, calls into it and ends on a swi 0xFF that is no BIOS call. A failed assert hangs the game with no message: one set off on purpose in Mesen (an event record of a kind the field doesn't expect) left a black screen and the program stopped where it was.

The checks keep their source file, line and expression, which give the developers' own tree: service/sv_buram/ (the flash and the project image, a file for each kind of data: sv_udjob.c, sv_udmap.c, sv_udevt.c …), service/sv_win/, edit/ (a file for each editor page: p_editchr08.c, p_editevt201a.c …), srv_proc/ (the services), and tf/ (the Turbo File). Some of the expressions say what they guard: !chk_size (sv_buram.c, line 932: the game fits the flash), objno < 128 (at most 128 things on a map), gSysWork.trs_flag_resv_buffp (the chest marks' buffer). The full list is in the notes.

Notes/RPG Tsukuru Advance/Program.md, Hidden Content.md, Play.md; Tools/adv_mesen.py --exec 08001290 (logs every process made, with its kind).

The flash#

Sixteen sectors of 4 KiB. Sectors 0–14 hold the project image, your game, 61,440 bytes; sector 15 holds the play saves. The program reads the image whole into RAM at 0x0200_0000 at power-on, keeps it packed there, unpacks one record at a time when an editor or play needs it, and writes the image back whole.

The flash, 64 KiB: 16 sectors of 4 KiBsectors 0–14: your game (the project image), 61,440 bytes, read and written whole0123456789101112131415play saves$0000Sectors 0–14: the project image (not to scale)headersections 0–15, end to endsumzeros to $EFFF$0000$0090after the last section$EFFFsignature, version,settings, bytes free,the section tableonly what differs from the defaults,record by record32-bit sumSector 15: the three play saves (to scale)slot 1, 1,324 bytesslot 2slot 3which play wrote each slot; its partyunused ($FF), then the sum
The 64 KiB flash: sectors 0–14 hold the game, read and written whole; sector 15 holds the three play saves.

The power-on check#

The boot (kind 0, from 0x0801_9104, a step a frame):

  1. An empty game is built in RAM (0x0800_19E4): the 60 KiB buffer zero-filled, the header from the template at 0x080F_0154, every section emptied, the bytes free set to $EF6C, the sections' first records made, the sum written.
  2. The flash is identified and read over it (ReadFlash(0, 0, buffer, $F000)), at about frame 283.
  3. Each of the 15 sectors is looked at (0x0800_1958). One whose first 8 bytes read BURAM NG (the program's mark for a bad sector) fills the buffer with that mark, so the next step fails. One whose first 16 bytes are all $FF stops the check as erased: the program shows 「チュートリアルデータを ロードしています…」, unpacks the Tutorial from 0x0879_ED28, writes it, and writes sector 15's fresh record.
  4. The image is checked (0x0801_92A8): the signature (0x0800_1AE4), the sum (0x0800_1C80, which first refuses an image that would end past $EFFF) and the version (0x0800_20C8, at least 10). Any of them wrong: an empty game replaces it, 「バックアップデータの内容が壊れています。」 shows, and the empty game is written.

The writes begin at frames 297–312, long before a button could stop them. Each case was run from a copy of the flash, in both emulators, with the same result to the byte (Saving and sharing has the table). The DEBUG TASK has two keys for the same machinery: R+SELECT writes an empty game, L+SELECT erases sectors 0–14 and leaves sector 15 (run from a patched copy).

The project image#

OffsetSizeWhatThe cartridge's game
$0012The signature RPGTCOOL GBA (checked at power-on)
$0C1Bits 2–7 the format version, at least 10 (checked); bit 1 a flag the program sets and clears; bit 0 not understood$29: version 10
$0D1The editor BGM (a song)$25: song 37, データをツクル
$0E1Bits 0–1 the cursor speed, bit 2 the user-game mode, bit 3 not understood, bits 4–6 the message speed$38: message speed 3
$0F–$113Not understoodzeros
$122The bytes free: $EF6C less the sixteen sections' lengths$B615, 46,613
$14–$4752Not understoodFF FF 7F 00, then zeros
$4864The section table: an offset and a length (halfwords) for each of the 16
$888The next free id of sections 3–9 and 1109 19 1A 36 8A 13 02 0C
$90–The sections, end to end
After the last4The sum: the 32-bit sum of every byte before it$000A_8511, at $39E7

$EF6C is $F000 less the header and the sum: 61,292 bytes of data. The sum is a plain 32-bit sum of every byte from $0000 to the end of the last section, written just after it (0x0800_1BFC, which also zeroes the rest up to $F000). The settings in $0D–$0E are inside it: a header changed by hand without fixing the sum is rejected at power-on (seen).

The sections#

0The system: the element names, the church, the special screens' BGM125 bytes
1The title and the staff126 bytes
2The start; the three vehicles (records 2–4)4the start only, 13 bytes
3Characters88, 230 bytes
4Jobs10015, 205 bytes
5Monsters9921, 513 bytes
6Skills9951, 740 bytes
7Items9930, 484 bytes
8Units9918, 189 bytes
9Keywords30none
10The variables ?A–?Z, fixed 9-byte entries26none
11Maps309, 920 bytes
12Messages, a block a list99 a list10 lists, 119 messages, 5,032 bytes
13Encounters (the units placed on a map), a block a list64 a list13 lists, 130 bytes
14Stairs (inferred), 9-byte records, a block a list20 a list32 lists, 12 records, 300 bytes
15Events, a block a list224 a list97 lists, 269 events, 5,872 bytes
The project image, to scale: 61,440 bytes acrossan empty gamefree: 61,169 bytesthe cartridge’s gamefree: 46,613 bytesthe Tutorial10,85910,198free: 36,828 bytesJewel Keeper33,23617,962headerdatabase (sections 0–10)maps (11)messages (12)encounters, stairs (13, 14)events (15)The numbers are the bytes of messages and of events. Jewel Keeper fills the image to its last byte.
Where the bytes go: four project images (an empty game, the cartridge’s game, the Tutorial and Jewel Keeper), section by section and to scale.

Every section lies end to end from $90, each at the offset and length the table at $48 gives. A store (0x0800_2490) packs one record into the section in RAM; a commit (0x0800_2718) moves every later section along and puts right the table, the bytes free and the sum. Each section has a 16-byte descriptor in RAM (0x0800_2F58 returns it) with its count and its maximum, the maxima from the byte table at 0x080F_132C. An editor's refusals come from these: the count at the maximum, or the bytes free short of a default record (Limits).

The ROM's three images are laid out the same way. The default at 0x0871_B2B4, stored raw, is not a game but a library the editors copy records from: 50 jobs, 99 monsters, 98 skills, 99 items, 25 maps, no events or messages, its monsters named with size letters (Sスライム, LLオーディン). Jewel Keeper and the Tutorial, both version 63, are packed with LZ77; Jewel Keeper's sum sits at $EFFC, the last place it can.

Records#

Each record is packed by its kind's own routine, storing only what differs from the default. Byte 0 is the record's id and byte 1 its length (halfwords in the maps, messages and events); then flag bits, one for each optional field; then a few bytes always stored; then each field whose flag is set, in the routine's order. A text field is 8-bit text to its 0, and a text field left empty is not stored at all.

A packed record: skill 2, ホイミ, in section 6 of the cartridge’s game0200D1072163034005CE6B27D08009281032110012id 2length 13flagsbits 0–2always storedkind 22, MP cost 3name ホ イ ミone byte each, 0 ends+$04effect 40+$02power 50Flag bit 0 says the name follows, bit 1 the effect, bit 2 the power; bit 3 (the help display) is clear, so it keeps its default.Numbers are little-endian (32 00 is 50). The editor shows the effect as 41: lists number from 1 on screen.
A packed record: the skill ホイミ, 13 bytes, as section 6 of the cartridge’s game stores it (flash offset $484).

Sections 2, 10, 13 and 14 hold fixed records, stored whole. A map's record depends on its type: the world map's is 12 bytes; a dungeon's is an 11-byte head and a sub-record for each floor; a town's a 12-byte head and 15 bytes for each building. A reader of names has to step over the two-byte codes, not stop at the first 0: a kanji such as 06 00 has a 0 inside it.

Blocks#

Sections 12–15 are runs of blocks, one for each list: a head (a key, the block's size counting the head, and the list's next free id), then the list's records. The heads of sections 12 and 13 are 4 bytes (key 1, size 2, counter 1), those of 14 and 15 are 6 (each 2). The keys rise with gaps, an empty list keeping its block. The map records hold their lists' keys; 0x0800_3A60 checks a key's range by kind: a message list at most 30, an encounter list below 180, a stairs list at most 479, an event list at most 1,469.

Sector 15#

WhereSizeWhat
Sector 15 $000–$0023Which play wrote each slot: 1 your game published, 2 Jewel Keeper, 3 Make the Game
$00F + 4 × slot4 a slotThe party's members, for the save list
$01C + $52C × slot1,324 a slotThe three slots, to $F9F
$FA0–$FFB92Unused: $FF
$FFC4The plain byte sum of $000–$FFB
A slot +$000$300The eight characters, $60 each
+$300$20The members' states, 8 bytes each (HP, poison, paralysis …)
+$320$20CThe play state from the gold on: the gold, the map and square (+$340–+$343), the switches, the timer, the bag, the vehicles

A fresh sector 15 is zeros but byte $1B ($FF, not understood), $FF from $FA0, and the sum A3 5C 00 00; the cartridge's is exactly that, so no game was ever saved on it. A save (kind 59) reads the sector whole, packs the slot from the play state, sums it again and writes it (0x080A_BC74(proc, 1, buffer); the project's write is the same routine with 0 and the image). Continue (kind 279) reads it up to 16 times while the sum fails (0x0804_BEC0), and lists only the slots whose first byte matches the title it came from.

Notes/RPG Tsukuru Advance/Save.md, Play.md (§Saving and loading); Tools/adv_save.py (check, sections, dump, rebuild, roundtrip, settext, diff): it parses each of the four images down to its fields and builds it again, byte for byte, and an image it edited was taken by the game, which then wrote back the same 61,440 bytes.

Text#

One table of 2,560 codes, the font's own order, serves everything the program writes in a window: its own strings, your names and messages. It is not Shift-JIS. The program's strings are 16-bit (little-endian; $000A a new line, $0000 the end); your game's text is 8-bit: a byte $01–$09 starts a two-byte code (byte × 256 + the next), $0A is a new line, $00 the end, and any other byte is its own code. So kana, Latin and marks take one byte in your game, kanji two. The cartridge game's first message, 「隊長!おきてください!」, is 04 FE 05 53 21 7F 81 8D 82 3E 85 7C 21: 隊 $4FE, 長 $553, then a byte each.

CodesWhat
$000–$0FFKana, Latin letters, digits and marks: the katakana at their JIS X0201 places, the hiragana in no kana order around them
$100–$7A21,699 kanji of JIS level 1, in Shift-JIS order (亜 … 腕): the rarer 1,266 left out
$7B0–$831130 kanji more, the ones an RPG wants (鎧 兜 斧 闇 呪 祠 罠 …) and the staff's name kanji
$832–$85DMarks (「 」, arrows, ○ △ □, ♪, Ⅰ–Ⅹ, ©) and two kanji
The restBlank

Six name codes, $0B–$10, each followed by a record's number, draw a character's, job's, item's, skill's, monster's or map's current name in a message: the cartridge's game greets its hero by the name the player gave him with $0B 01. The message copier (0x0800_FFE8) takes every byte from $01 to $10, $0A aside, together with the next.

The font is 8 × 12 pixels, drawn into the window's tiles by 0x0801_02A0 from two planes: a 1-bit mask (0x0873_A184, stored inverted, four glyphs a row) and a 2-bit colour plane (0x0872_B184), whose ink is colour 2, the body, or 3, a lighter edge that softens corners. The big outlined headings (オプション, 消費MP …) are pictures, not text. The kanji were identified by likeness, each glyph against JIS level 1 drawn small, then checked against the keyboard's lists of kanji by reading; six stay doubtful (Messages and text).

Notes/RPG Tsukuru Advance/Text.md; Tools/adv_text.py (table, font, dec8, enc8, strings).

The database records#

Each kind's unpacker starts from its default struct in ROM (0x080F_01E4 the system … 0x080F_048C the unit), puts the fixed bytes in place and reads in the flagged fields. The structs, as the program holds them in RAM:

SectionStructFields (offset: field)
0 System$3C+$02 … +$2A the five element names (4 characters); +$34 the church's two prices (14 bits each, and a bit for "× LV"); +$38, +$39 the shop's and the church's BGM
1 Title$128+$01 the BGM; +$02 the title picture (0–36); +$03 the frame (bits 0–3) and "shown by an event" (bit 4); +$04 the title (24); +$36 the author (12); +$50 and +$BC the six staff roles and names (8 each)
3 Characters$88+$00 the job; +$02 LV; +$04 thirty skills and +$40 their levels; +$5E–+$66 the five starting pieces of equipment; +$68 the id; +$6A the name (6); +$78 the graphic; +$7C the resistances; +$84 the growth speed (bits 0–1), in use (bit 2, inferred)
4 Jobs$20+$00–+$05 the six growths; +$06 the id; +$08 the name; +$1A–+$1C the attack, defence and turn skills (6 bits each)
5 Monsters$44+$00 gold; +$02 EXP; +$04 the job; +$06 LV; +$08 seven skills and +$30 their conditions; +$18 extra HP (32 bits); +$1C the id; +$1D the graphic; +$1E the name; +$38 the resistances; +$40 the graphic's variant and the personality
6 Skills$1C+$00 the MP cost; +$02 the power; +$04 the effect; +$06 the name; +$18 the id; +$19 the kind (bits 0–5), technique (bit 6), all (bit 7); +$1A the statuses cured and the help display
7 Items$20+$00 the price; +$02 the power (or +$19 the statuses cured, or +$1A the skill cast: one of the three, by kind); +$04 the id; +$06 the name; +$18 the kind and all; +$1B who can equip it (a bit a character); +$1C the extra effect; +$1D the icon; +$1E the help display
8 Units$10+$00 the id; +$01–+$06 six members; +$07–+$0A four treasures; +$0B the formation and the type; +$0C the unit effect; +$0E its condition
9 Keywords$14+$00 the id; +$02 the word (8)

Notes/RPG Tsukuru Advance/Database.md; Tools/adv_db.py (dump, raw, check).

Maps#

A map is picked, never drawn: each of the three types is built from pieces in the ROM into a grid of cells, 4 bytes each (a flag byte, a byte, the block's number). A block is 16 × 16 pixels, four entries of a tile map.

A position is a word: x, y, the map, and a byte whose bits 0–5 are the building or the floor and bits 6–7 the storey (0 outdoors, 1–3 inside). A floor is given as a number with 5 for the entrance floor, the others counted from it; a dungeon is left by walking off its outer edge, and only on its entrance floor.

The field's screen is mode 0, four text backgrounds of 512 × 256:

Screen blockPriorityHolds
$193The ground (on the world map, shown on BG2)
$1B1 (2 on the world map)The layer over it: walls, roofs, trees
$1D2A third layer, with tiles of its own
$1F0The window and test play's bar

The camera keeps the hero at (112, 56) on screen. Every map of the four images was drawn by the project's tools, 652 pictures, and each of the 122 screens that showed one matched its drawing with 0 pixels different.

Notes/RPG Tsukuru Advance/Maps.md, Graphics.md; Tools/adv_maps.py, adv_ppu.py (a GBA screen from a RAM dump, matching the emulator's frame buffer exactly), adv_gfx.py.

Events#

The lists and the records#

Section 15 holds one list for each place events can stand: the world map, a town's outdoors, each storey of each building, each dungeon floor. An event's record is its id (2 bytes) and length (2), a byte whose bits 0–3 are its kind and bits 4–6 its page count, its x and y, then what its kind needs:

KindWhatAfter x and y (bytes 5, 6)
0ObjectThe pages' heads, then all their commands
1PersonThe same (a person's head adds facing, movement and speed)
2Map entrance, on the world mapWhere the party stands on leaving the map; three more cells if byte 4 bit 7 is set; then the pages (each with its destination) and commands
3ChestIts chest mark, its graphic, four 2-bit content kinds (nothing, item, gold, unit), then 4 bytes for each content
4DoorIts number (0–149), its graphic, the key item (no image has a door)
5Event eggThe egg; in byte 4, bits 4–5, a thing (0) or a person (1); its collision is fixed in the cartridge
6—Not stored: the field's own entries for the vehicles (its store routine asserts)

Pages. Page 1 has a short head (the graphic, the start type and its parameter; a person's facing, movement and speed; an entrance's destination) and no conditions. Each later page's head starts with its own length and holds its two conditions, its start type, its graphic and the offset of its commands. All the pages' commands follow the last head as one run, each page's ending with opcode 0. The page in force is, as the games are written, the last whose conditions hold; Enterbrain's published FAQ says the higher page wins; the field's choosing code was not read.

The commands#

A command is its opcode byte and fixed arguments, little-endian, the size per opcode from the table at 0x080F_1748. Bits 0–6 are the opcode, 0–110: 1–80 the catalogue's commands, 81–106 Set ?A to Set ?Z, 107–110 the second-branch labels of Yes/No, Choice, Battle (Win/Lose) and Password; 0 ends the page. Bit 7 is an option the command's page sets: a message from the common list, a sound played without waiting, and the like. A page is unpacked into 16-byte commands (0x0800_B688; packed again by 0x0800_B81C).

The interpreter is kind 9, the event runner: its state 1 (0x0802_DDD0) takes the next command and calls the routine for its opcode from the table at 0x0810_3F54; the routine is called again every frame until it says it has finished (0x0803_F960). Windows, shops, inns and battles are processes the routine creates and waits on.

Branches. A branching command whose first answer comes (はい, the first choice, the right password, a won battle) simply goes on to the next command. Otherwise it scans forward for its own label, counting the same pair's openers and labels for depth, and goes on after it; with none, it clears its own opcode and the page ends. A label reached by running ends the page, as opcode 0 does: there is no rejoining. The Yes/No scan is GB's, step for step.

Variables. Section 10's 26 fixed entries are the variables ?A–?Z. Each declares the field it stands for (an owner kind, a field, a record, an opcode), from which the program works out a field code; the values are 32-bit, in the play state. Set ?X stores its value only if the variable's field code is still the one recorded when the command was written. No image uses a variable.

Checked: every page of the four images (1,605) splits exactly by the size table; the events go to a script and back to the same bytes; and script-written events ran in the game as predicted, branches included.

Notes/RPG Tsukuru Advance/Events.md; Tools/adv_events.py (list, script, build, roundtrip).

The battle, in short#

A battle is kind 61 (39 states) with its parts as kinds 62–71, started by 0x080C_4788 from the field (a step's encounter, or test play's SELECT) or from an event's battle command. Its work (pointer at 0x0300_072C, zeroed at each start) holds ten combatants, the party's four and the unit's six places: their HP and MP, their four stats as set up and as randomised each round (±⅛), the modifiers that skills set, their statuses and commands, and copies of the monsters' and the unit's records. The rules are on How battles work.

The random numbers are the Mersenne Twister, MT19937 (0x0800_F1BC, its state at 0x0200_F760), in its 1998 reference form, seeding with Knuth's 69069 and a default seed of 4357. It is seeded once, from the frame counter (0x0300_0724), when Make the Game is chosen on the top menu: 612 at frame 890 of a cold boot. rand(lo, hi, n) (0x0800_FC94) sums n draws, so n > 1 gives a bell-shaped spread. The field's code uses the C library's rand instead.

Checked: 53 battles recorded with every draw logged were replayed by the project's model of the battle, draw for draw, 19,117 draws with every combatant's HP through every value; the first 31 were replayed again in the second emulator, each taking the same seed and ending with the same twister state.

Notes/RPG Tsukuru Advance/Battle.md; Tools/adv_battle.py (make, record, check, mt).

The sound#

Nintendo's MusicPlayer2000, linked whole, plays everything. SoundMain runs once a frame from the VBlank handler: the effects' player first runs the music's (so the music always ticks first), then the four PSG channels are updated, then the mixer, in ARM code in the fast RAM, mixes 8 DirectSound channels at 10,512 Hz (176 samples a frame) with a reverb pass. Two players: music, and effects.

Checked: the project's model of the engine, ported routine by routine, matched the game's own mixer output byte for byte over every song (277,080 calls compared); the guide's clips are its renders (Music and sound).

Notes/RPG Tsukuru Advance/Sound.md; Tools/adv_m4a.py (the engine's model), adv_sound.py.

Data Exchange (kind 276) uses the GBA's multi-player link mode at 115,200 bits a second, in 72-byte frames. The ROM also holds the version tag of Nintendo's multi-player serial library, MultiSio010918 (18 September 2001), which nothing points to. The exchange itself was not run or read further.

The Turbo File (kinds 281–286, the source's tf/, code from 0x080E_3930) speaks RPG Tsukuru GB's protocol byte for byte, over the GBA's 8-bit serial mode with the device's clock:

A file is the whole flash, 8 blocks of the device's 8 KiB, marked A8TJ and named RPG TCOOL GBA and two characters (an assert in p_tf04.c refuses one outside 0–9 and A–Z): 15 games to a side, where GB's 4-block files fit 30. No device or model of one was run (GB's Turbo File, as it ran).

Notes/Turbo File.md, Notes/RPG Tsukuru Advance.md (§Lineage).

How this was checked#

Mesen 2.1.1 ran the cartridge headless, scripted from Lua: from power-on with a pad script, it took frame-buffer shots, RAM dumps, read, write and execution traces with the program counter, the live process tree and savestates. Every run started from a copy of the cartridge's flash; the original was never written. mGBA 0.11, through a libretro frontend in Python, was the second emulator, and the findings that rested on Mesen alone were run again there:

WhatIn both emulators
The boot and the menusFrame for frame to frame 1,300: the scene byte, the random-number state and the frame counter change on the same frames
Power-on, eight flash imagesThe same 65,536 bytes left in each (the power-on check)
31 recorded battlesThe same seed, the same random-number state at the end, and no word of the battle's work with a different history
Two play tests (the caps, the inn)The same settled screens, pixel for pixel

Where the two differ is timing, not logic: a long load can take a frame more in Mesen, so a fixed-frame shot of a moving screen can differ; a value being written as a frame ends can be caught at different points; and Mesen's shots of a fast-changing screen blend two frames. Which is nearer the hardware was not tested. The screenshots of this guide come from both: the editors' from Mesen, the cartridge game's from mGBA.

Notes/RPG Tsukuru Advance/Second Emulator.md; Tools/adv_mesen.py, Tools/adv_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.