Menu engine, menu table and screen graph (Menu/.ssb, Menu/.alr + executable)
How the menu screens run on top of the script
VM (“Menu script VM”): which script is which
menu, how screens follow each other, what the
items are, how a screen’s art is loaded and
drawn, and which built-ins a screen needs.
Addresses are for Store build 1.3.25854.2. Read
in the executable and in the user’s own
_en scripts with
ssbdump.py; M
unless marked. No script text is reproduced
here: screens are named by their file name,
strings by their role.
This section corrects three statements of the hudtext run (fixed in place above): 0x2040 is “go to menu id”, 0x1010 / 0x1011 are music play / stop, 0x20AE / 0x20AF are per-menu saved words.
Files
Menu/<name>_<lang>.ssb,lang=en/ja: 75 scripts per language. The loader 0x140245780 builds the name from the menu’s table name and the language suffix. A second folderMenuD/holds another copy of the same script set with slightly different sizes; the loader picks folder name “menu” or a second name by bit 0x2000 of the global flag word 0x140530034 (which build mode sets the bit was not traced, L).Menu/<Set>.alr: one texture set per screen family. Every one is the same layout as the battle HUD file (“Battle HUD”: chunk 0x10 = texture list + sprite table, with chunks 0x11, 0x15, 0x16), checked withalrwalk.pyon 19 files (H). Counts (textures / sprites):VsMode4 / 63,DckMenu2 / 11,StMenu3 / 4 (also carries model chunks),Option2 / 4,MNet12 / 84,Title3 / 3,Mission5 / 40,Shop5 / 6,Labo3 / 19,Town4 / 14,WusMn<Lang>8 / 201 (the shared window, frame and button set),BtMenu<Lang>3 / 180,FDLogo13 / 13,MSLogo6 / 6,SRoll6 / 6,MovMode1 / 1, and one-picture filesLdCg00–41(loading pictures),Mpt000–143,Cpt1–7<Lang>(1 / 1 each). OnlyBtMenu,WusMnandCpthave language variants; all other language differences are script strings.- A menu ALR holds no layout: sprite rectangles only. All positions are numbers in the scripts (640 × 480 design space, see “Bitmap font and text drawing”).
Menu table (0x1403fa3d0)
87 records × 24 bytes; the record index is the menu id used by every “go to menu” built-in.
| Offset | Type | Field |
|---|---|---|
| +0x00 | pointer | script base name (file name without language suffix) |
| +0x08 | s16 × 4 | saved words: 0x20AE(menu, i) reads, 0x20AF(menu, i, v) writes; they survive menu changes (used as “came back from sub-screen” markers and remembered rows) |
| +0x10 | pointer | loaded script module (0 = not loaded) |
Ids (file base names): 1 = no menu (closing),
2 menu1, 3 command, 4
option, 5 vsmode, 6
shop, 7 playdatasel, 8
mainmenu, 9 bgmtest,
10 vsmenu, 11–26
mb01–mb16, 27
skillbuy, 28
skillsell, 29 junkbuy,
30 arsenalbuy, 31
arsenalsell, 32
muoutput, 33 mapintro,
34 chapter, 35 and 42
livelogon, 36
livemain, 37
livequick, 38
livesearch, 39
livecreategame, 40
livetrade, 41
liveranking, 43
livesession, 44
livelobby, 45
laboratory, 46
livecharasel, 47
livestagesel, 48
liverulesel, 49
pausemenu, 51
livestart, 52 liveend,
53 liveerror, 54
livelobbyres, 56
ending, 57 slinkstart,
58 slinkend, 59
slinkmenu, 60
slinksearch, 61
slinkcreate, 62
slinkname, 63
labostock, 64
arsenaledit, 65
talkselect, 66
battleend, 67
livearsel, 68
liveoption, 70
vslobby, 71 townstart,
72 battlestart, 73
missionselect, 74
livedbtl, 75
livedbtlres, 76
movietest, 77 compe,
78 compe_res, 79
E3MENU, 80 title, 81
liveaware, 82
livetrade_h, 83
livetrade_c, 84
livegterr, 85
liveinvite, 86
livejoinssn (H,
read from the table; ids 50, 55, 69 are
empty).
Context object ([0x140533c58], 0x10a90 bytes)
| Offset | Field |
|---|---|
| +0x40 | 16 item records × 0x103C |
| +0x10400 | pad mask word: bit 0 = pad 1 may drive the menu, bit 1 = pad 2 |
| +0x10402 | current item (target of the “current item” built-ins) |
| +0x10408 | item being drawn |
| +0x10410 | focus item (the one that gets input; −1 none) |
| +0x10414 / +0x10418 | event code / event parameter of this tick |
| +0x1041c | four ints (0x2048 read, 0x204A write) |
| +0x10530 | texture set slots, 64 × 0x20: +0 name, +0x10 load id, +0x18 handle table |
| +0x105b0 | name save stack, 8 deep (index at +0x105f0) |
| +0x105f4 | current menu id (0x20B0 reads) |
| +0x105f6 | seven words (0x2080 write / 0x2081 read), saved with the history entry |
| +0x10608 | current menu table record |
| +0x10610 / +0x1061e | tick function name / draw function name |
| +0x1062c | pending task name |
| +0x1063c | text mode (0x205A) |
| +0x10a40 | the script thread |
Other globals: state 0x140533744 (1 loading,
2 running, 3 closed); menu arguments 0x140533c10
(0x204D(i, v) write / 0x204E(i) read; native
code passes values to a screen here, for example
the result kind to battleend);
history 0x140533b00 (16 entries × 16 bytes: menu
id + the seven words; index 0x140533c50); menu
variables (0x209A(i, v) write / 0x2099(i) read),
which survive between scenes of one screen.
Open, go to, back
- open 0x140246020(ctx, id): id 1 → state 3
(closed). Otherwise clears all items, then loads
the script if the record has no module (state 1)
or starts the function
InitMenuat once. - go to 0x140246130(ctx, id, force) = built-in
0x2040(id): pushes the current
id and the seven words on the history, then
opens
id. - back 0x1402461f0 = built-in 0x2041(): pops the history and opens that menu.
- Native openers (who opens which menu): game start → 7; battle flow → 72 at match start and, at match end, the return menu id held in 0x1404bc8a4 (set by built-in 0x41CE or by the match setup’s fifth parameter); result flow → 66 with menu argument 0 = result kind; pause → 49; online flow → 36, 51, 53, 54, 86; story flow → 34, 45, 73; a sign-out watchdog in the menu tick → 86 or 7.
Per-frame tick (0x140248230)
- Clear the event (code 0, parameter −1).
- State 1: when the script has loaded, start
InitMenuand go to state 2. - Run the focus item’s type input function (it may set the event).
- Run the screen’s tick function by name (if set).
- Start the pending task (if a name is set) as the thread’s function; run the thread with a budget of 0x2000 instructions.
- Run each of the 16 items’ type tick functions.
Drawing is separate: the screen’s draw function (by name) runs every frame and draws items with 0x206A(item) and its own sprites and text.
Scenes. 0x204C(name) sets tick = “m” + name and draw = “d” + name. The usual tick function is one line: 0x2046(prefix + name), which starts the task named prefix + name + suffix when an event came in. So a screen is a set of scenes, and each scene is: a draw function, a tick function, and one task function per event it handles.
| Event code | Suffix | Raised by |
|---|---|---|
| 2 / 3 / 4 | _OK / _YE /
_NO |
message box closed: confirm / yes / no |
| 5 / 6 | _TA / _TB |
A / B (B and Back raise 6 on lists) |
| 7 | _BL |
|
| 8 / 9 | _TX / _TY |
X / Y |
| 10 | _WH |
right shoulder |
| 11 / 12 | _TL / _TR |
|
| 13 / 14 | _ST / _BA |
Start / Back |
| 15 / 16 | _LT / _RT |
triggers |
| 17–20 | _U / _D /
_L / _R |
directions (lists raise 19 / 20) |
| 100–611 | _S<n> (n = code −
100) |
list row chosen (row index, or the row’s own value) |
(table 0x1402f6700; codes ≤ 0 start nothing.) 0x2049(code, param) raises an event from script; 0x2047() / 0x204B() read code / parameter. 0x2042(name, n) sets the pending task directly (name, or name + number); 0x2043(name) / 0x2044(name) set tick / draw alone (0 clears); 0x208D–0x2090 push / pop names on the save stack (sub-scenes such as a message box over a list); 0x2045() resets; 0x2060() destroys all items.
Items
16 retained records; a script creates them in its draw or init code and destroys them when the scene changes.
| Offset | Type | Field |
|---|---|---|
| +0x00 | s16 × 4 | x, y, width, height |
| +0x08 | s16 | type |
| +0x0A | s16 | state word (0x207E) |
| +0x10 | s16 | (0x2073) |
| +0x12 | s16 | selected row (0x2074 set; 0x20B5(item, row)) |
| +0x16 | s16 | entry count |
| +0x18 | s16 | visible rows (0x2072) |
| +0x1A | s16 | top row (0x2067) |
| +0x1C | s16 | style bits (0x207D) |
| +0x24 | pointer × n | entry text pointers; the same area read as s32 from index 0x100 on holds per-row values |
| +0x1024 | pointer | caption (0x2066) |
| +0x102C | pointer | user pointer (0x206E) |
| +0x1034 | pointer | row-draw callback: a script function called per visible row with (x, y, row, entry); the scripts set it as entry index 0x202 through 0x2069 / 0x2076 (0x140207e40 has no index bound) (menus r2) |
Generic field access: 0x206D(field) / 0x2077(item, field) read, 0x2071(field, v) / 0x2078(item, field, v) write; field < 16 = s16 at 2 · field, field ≥ 16 = s32 at +0x24 + 4 · (field − 16). Others: 0x2061(id, type) create, 0x2070(id) destroy, 0x2062 / 0x2063 set / get current item, 0x2068(text) add entry, 0x207B(row, text) set a row, 0x2069 / 0x2076(i, text), 0x206F / 0x2079(item, i) read an entry pointer, 0x2075(dst, src) copy the selected row, 0x206B / 0x206C set / get focus, 0x206A(id) draw.
Types (table 0x1402dcaf0, 24
slots; each type = {create, tick, draw, input}
functions). Use counts are over the non-story
_en scripts.
| Type | Uses | What it is | Functions |
|---|---|---|---|
| 1 | 101 | list / menu: framed window, rows, cursor | draw 0x14024a780, input 0x14024b000 |
| 2 | 84 | text box: framed window with its entries as lines; height = 24 · lines + 2 when the style is not negative | draw 0x140249bc0 |
| 3 | 77 | caption / help bar (rectangle + one text) | draw 0x140249420 |
| 5 | 394 | message box: opens the shared dialog 0x140169d60 (position, a style letter from table 0x1402f6bc0, caption), then raises event 2 / 3 / 4 with parameter = item id | input 0x140249590 |
| 6 | a second dialog kind | input 0x140249710 | |
| 8 | skill detail panel, 162×56, drawn by 0x14016f2c0 (skill id = the item’s selected row, style, x, y, 8 label entries) | draw 0x14024a0a0 | |
| 9 | the skill card (uifix 11-14 correction; was “plain coloured panel”): card routine 0x140168410 with skill id = the item’s selected row, see “Arsenal editor, skill lists and the card panel” | create 0x140249d70, draw 0x140249df0 | |
| 21 | 99 | value row (label + value, left / right changes) | 0x140249250 / 0x1402493a0 / 0x140249270 |
| 12, 14 | skill stock lists (shop / laboratory), (uifix 11-14) | 12: 0x140249e40 / draw 0x14024a050 / input 0x140249fa0; 14: 0x14024a0d0 / 0x14024a3b0 / 0x14024a100 | |
| 16, 17 | arsenal name header and the arsenal editor grid (uifix 11-14) | 16: 0x140248ea0 / 0x140249050 / 0x140248ef0; 17: 0x140248b30 / draw 0x140248e10 / input 0x140248b50 | |
| 7, 10, 13, 15, 18–23 | few | not read (L: text entry, gauges, number pickers by their use) | see the type table |
List input (type 1, 0x14024b000), for the pads allowed by the mask:
- B or Back → event 6, cue 1 (not when style bit 13 is set); X → 8; Y → 9; left → 19; right → 20; right shoulder → 10.
- A or Start (not when style bit 14 is set) → event 100 + row and cue 0. When the low style nibble is 1 the row’s own value (s32 at +0x24 + 4 · (row + 0x100), masked with 0x1ff when style bit 12 is set) is used in place of the row index, and a value with bit 16 set is a disabled row: cue 2, no event.
- Up / down move the selected row and scroll (count, visible rows, top row); cue 3 when it changed. Style bits 10–11 = 01: row 0 is a heading that cannot be selected; bit 10 set: stop at the ends; clear: wrap around (the auto-repeat never wraps).
- Cues go through 0x140276330(0, cue, cue, 0x1000, 0x1000, 0) = common bank cues 0 confirm, 1 cancel, 2 refused, 3 cursor move (this assigns the four cues the audio run left unassigned, H for the roles). Scripts play the same cues with 0x102B(cue), plus cue 37 and cue 200.
Frame drawing (M /
L): windows are drawn by
0x14016cb40(window object [0x1404c0140], x, y,
w, h, colour A, colour B, −1, 0): a vertical
two-colour fill plus border pieces from the
shared window set (WusMn), through
helpers 0x14016cf30, 0x14016cd00 and
0x14016b350. Colours read: list fill 0xff38574d
→ 0xff001e1a, list text 0xff5cac95; text box
fill 0xff32524e → 0xff123e35, text 0xff73e1cf.
The list draw can hand each row to a script
function for custom drawing (0x140245830). The
border sprite numbers and corner sizes were not
read.
Texture sets, sprites, fader, labels
- 0x2050(slot | flags, name)
(0x140246920) loads
Menu/<name>.alrinto slot 0–63 (flag 0x40 / 0x80 = load modes 1 / 2) and returns true once loaded, so scripts wait on it in a loop; 0x2051(slot) tests; 0x2054(slot) frees. Sets seen:vsmodeandvsmenu→VSMODE,mainmenu→STMENU,option→OPTION,arsenaleditandlaboratory→Labo,shop→SHOP,title→FDLogo(and the logo sets), online screens →MNET. - 0x2052(set, n, x, y) draws sprite n of a set at (x, y); set ≥ 0 = a slot, −1 = the system window set, −2 = the battle HUD set, −3 = a single button-glyph texture. 0x209F(set, n, x, y, argb) the same with a colour; 0x2053 (7 arguments) with scales.
- Text: 0x2058 text, 0x2057 formatted text, 0x205F width, 0x205B corner colours, 0x205A text mode, 0x2059 flush, 0x205D rectangle, 0x204F(sel, a, b) picks one of two strings; any string starting with “$" is a localisation key resolved by 0x1400230a0 (the PC port's string table), "$$” is a literal. 0x102D(dst, fmt, …) formats into a buffer.
- Fader (object [0x14052dd70]): mode +0x136 (0 clear, 1 fading in, 2 fading out, 3 black), alpha +0x138, step +0x140, rgb +0x13c. 0x2055(kind): low byte 0 = clear now, 1 = fade in, 2 = fade out, 3 = black now; high byte = step per tick (0 → default 0x20 = 8 ticks; 0x55 = 3 ticks); the step resets to 0x20 when a fade ends. Fade in: alpha −= step down to 0; fade out: alpha += step up to 255. 0x2056() is true while no fade runs. Draw 0x1401c6cb0: one rectangle (−1, 0, 640, 482) of colour alpha << 24 | rgb over everything. H
- 0x2098(kind, a, b) (0x140246360), menu system services: 0 set the pad mask word; 1–3 and 6 the loading / status label object (text, show, hide); 4 render-state reset; 5 label flags set a / clear b; 7 global flag word 0x140530034 set a / clear b; 8 test that word against a; 9 label text from a string; 10 / 11 clear flags 0x1102; 12 → 0x1401c6d90; 13 pause object [0x1404c0130] → 0x140167580.
Group 0 and 1 built-ins used by menus
| Id | Meaning |
|---|---|
| 0x0000–0x0004, 0x0007 | nothing (debug prints left in the scripts) |
| 0x0005(n) | random 0..n−1 |
| 0x0006(name) | name hash |
| 0x0008(name, x) / 0x0009() / 0x000A() | request another script module / loaded? / unload |
| 0x000E / 0x000F, 0x0012 / 0x0013 | byte and s16 peek / poke on a pointer |
| 0x0010 / 0x0011 | static word read / write |
| 0x1010(track) / 0x1011() | play music track / stop music |
| 0x1013(v) / 0x1014(frames, v) | music volume (0x1000 = full) / fade to a volume |
| 0x1016–0x1022, 0x1023 | sound-test lists (only bgmtest)
/ stop and reset |
| 0x1024 / 0x1025 / 0x1026 (pad) | buttons held / newly pressed / auto-repeat |
| 0x1029(a, skip) | a < 0 resets; else the first of the four
raw pads (other than skip) that
newly pressed A or Start, or −1: the “player 2
press a button” poll |
| 0x102A | string length |
| 0x102B(cue) | play a system sound cue |
| 0x102D, 0x1034, 0x1035 | format, UTF-8 copy / truncate, clear a buffer |
Music tracks by screen:
playdatasel, mainmenu
31; option 33; vsmode,
vsmenu 34; livemain
35; battleend 37 / 38;
laboratory 29; shop
60.
Data queries (group 2, 0x2095–0x2097)
| Call | Kinds |
|---|---|
| 0x2095(kind + 0x100 · player, index, sub) (0x14024c220) | 31 arsenal count; 33 skill id
sub of arsenal index;
34 arsenal name; 35 arsenal record pointer (0x64
bytes: name +4, 30 skill ids s16 from +0x14,
school word +0x50); 36 / 41 a per-arsenal byte
read / write; 38 skill name; 39, 40, 42 skill
record words (+0xE, +0x12, +0x28; records 0x90
bytes at [0x1404bdc50]) |
| 0x2096(kind, i) (0x14024c410) | (corrected by the menus run 11-12: this is the character table, not the stages) 40 count; 41 / 42 the run-time character entry’s name / display name (entries 0xA0 bytes, read from 0x1404c01e8 = table 0x1404c01e0 + 8, so +0 / +8 here are the entry’s second and third strings); 43 s32 at +0x70 here = entry +0x78 = the colour variant count (charaset +0x3A; the versus screen opens its colour pick when ≥ 2); 44 unlocked (bitset 0x1404616a4, < 56); 46 unlock |
| 0x2097(kind, i) (0x14024c500) | (corrected 11-12: the stage table, 0x28-byte entries at 0x140509ba0, count 0x14050a5d0, from stageset) 50 count; 51 / 52 / 53 full / short / internal name (+0 / +8 / +0x10 pointers); 54 stage number (+0x18); 55 variant count (+0x1C); 56 selectable flag (+0x20); 57 unlocked (bit 27 + i); 59 unlock. The split-screen stage list walks a 17-entry table of stage indices in the script and lists the rows with 56 and 57 set |
| 0x507A(player, arsenal, flags) (0x14015b9e0) | arsenal usable test; flag bits 32, 64, 128, 256, 16384 select which rule to test (too few skills, school limits …; bit meanings L) |
Split-screen versus: settings and start (H for the path)
Settings block, written by 0x201A(kind, i, v) and read by 0x201B(kind, i) (0x1401d0630 / 0x1401d06d0):
| Kind | Field | Stored at |
|---|---|---|
| 1 | character of player i | s32 0x1405b1848 + 8 · i |
| 2 | arsenal slot of player i | s16 0x1405b184c + 8 · i |
| 3 | stage | s16 0x1405b1858 |
| 4 | return menu id | s16 0x1405b185c |
| 6 | game rule (mode row) | s16 0x1405b185a |
| 8 | extra word used by the single-battle start | s16 0x1405b1860 |
0x201C(i, v) runs entry i of table 0x1403ed940 (16-byte stride). Entry 4 = split-screen battle setup 0x1401d0750: builds two player records (0x48 bytes: present, index, character …); for each player loads the chosen arsenal (the kind-35 query above) and sets it as the battle deck (0x14014f830), and takes the school factor from the arsenal’s school word (1..3 → a float of the common parameter block, else 1.0) into 0x1404bc958[i]; then calls the match setup 0x140128990 with game mode 6, the records, the return menu and the stage, sets match mode 0x1404bc5dc = the game rule, 0x1404bca04 = 4, 0x1404bc8b8 = 2. Rule 2 skips the per-player arsenal load. Entry 5 = single battle (game mode 2).
Screen order of the offline versus mode:
title(logos, then “press start”) →playdatasel(profile) →mainmenu.mainmenurows → story (71), options (4), online (51), versus (5); back → 7.vsmode(id 5): player 2 joins: 0x1029 polls the other pads for A / Start, then the second player’s profile is picked (memory-unit and profile built-ins 0x209D / 0x209E, 0x208A–0x208C). → 10; back → 8.vsmenu(id 10), one script with these scenes: top menu (start, shop → 6, arsenal laboratory → 45), rule list, stage list, character list for player 1 then 2, arsenal list for player 1 then 2 (with an arsenal contents view), an options scene and a final “lobby” confirmation scene. Menu variables: 0 rule, 1 stage, 2 / 3 characters, 4 / 5 arsenal slots, 6 “came from the confirmation scene” (a change returns there), 11 view toggle. On entry they are loaded from the settings block (0x201B). Each list writes its variable on A and goes to the next scene; B goes one scene back; back from the top → 5.- On confirm: music fades (0x1014(15, 0)), the
six settings are written (0x201A kinds 3, 6, 1,
1, 2, 2), the return menu is set to 70,
0x201C(4, 0) sets the battle
up, the screen fades, waits until 0x41CC reports
the battle loaded, fades out fast (0x2055 with
step 0x55) and closes the menu system with
0x2040(1). The battle then opens
battlestart(72). - After the battle:
battleend(66) → back; the battle flow opens the return menu 70 =vslobby, a stub that goes straight to 10, so the players land invsmenuagain with their settings kept.
Other game built-ins of these screens: 0x41CC battle loaded?; 0x41CE(id) set the return menu; 0x3173 a save byte + 1; 0x42A3(v) and 0x4359(v) set a mode word / a camera or background preset for the menu backdrop (L).
Pause menu (id 49)
Opened by the pause object (0x1401674b0
family, at 0x1401676c4) with menu arguments 0
and 2 set. One script with a scene per
situation: offline battle, online battle, town,
a “disconnect” variant, and a PC options scene.
It draws by the pad mask (0x2098 kind 0 gives
the pausing pad the menu), tests 0x4290 / 0x4291
(flag bits 2 and 4 of 0x14050d220: which rows to
show), and its rows are: resume (0x2041),
options (→ 68 liveoption, or the PC
option rows through the 0xA0xx group), help
(opens a web page through 0xA001: stub), quit
(0x40D3: sets the end reason 5 and ends the
battle), story-only rows (0x30E3). On open it
sets label flags and the global flag bit
0x100000; closing clears them. (11-12
correction) Every exit goes through one
helper: 0x40D3 (end reason 5, then 0x14012dca0),
menu argument 1 = the exit code (128 resume; 129
the second row and 132 quit, both after a
confirm), then 0x2041. The pause object sets
argument 0 = its u16 +0x12 (the scene; 0 = the
offline battle’s five rows) and argument 2 = its
+0x54 (the pausing pad). The caller reads
argument 1 after the close: the battle only ends
for a quit. vsmenu’s init goes to the online
screen (51) when flag 0x100000 is set, argument
0 ≠ 0 and its first saved value is 0, so the
flag must be clear again when the pause is
over.
Online and PC-port built-ins (to stub)
- Common prelude: every
live*/slink*script starts with the same error handling functions: service error → 84 / 53, signed out → 42 / 59, session lost → 36 / 58 / 52. They poll 0x41E7, 0x4218, 0x421A, 0x4222–0x4224, 0x4235, 0x42BA, 0x42C4, 0x42D6, 0x4318, 0x433F, 0x4342 (service and session state). A rebuild that never raises those states never enters them. - Online screen graph:
livestart(51) → 85 / 36 / 42;livemain(36) rows → 43, 38, 48, 40, 6, 45, 41, 68;slinkstart(57) →slinkmenu(59) rows → 43, 48, 6, 45, back → 58;slinkcreate(61) → 62 / 44;slinksearch(60) → 44;liverulesel(48) → 47 and from its init → 61 / 39;livelobby(44): host rows → 46 character, 67 arsenal, 47 stage; client rows → 46, 67; start → 1 (close, the battle begins);livelobbyres(54) → 44;liveend(52) /slinkend(58) → 8. - Session settings
(
liverulesel): four value rows stepped left / right by 0x4242(d0, d1, d2, d3) (0x140183010): game type 0x14050d2d8 (0..2, wraps), game rule 0x140518cf0 (0..11, wraps; some rules are skipped depending on the game type), a third two-way setting 0x14051c0e0, a toggle 0x140519ab8; read back by 0x4243–0x4246; 0x42A9(rule) tests a per-rule availability bit (0x14051c93c). The rule index is the match mode row, so heavy mode is reached by stepping the rule row to 4 on this screen (rules run: mode row 4). The split-screenvsmenurule list writes the same mode row through 0x201A kind 6. - One-on-one CPU battle
(
livedbtl, id 74; cpu run’s open item): first entry goes to the arsenal select (67) with saved word 0 = 1; on return it runs 0x4295 (0x140214770): both characters come from a random picker (0x1401907a0), the player’s deck is the save’s current arsenal, and the CPU’s deck is the record at 0x1404bc8e0, which is filled by 0x140183e80 from a list of records received from the online service (64 entries × 0x4C, state word 0x140519abc). So this battle needs service data; offline there is no source for the CPU deck (the rebuild usescom/deck, see “CPU opponents”). - Group 9 (0x9000–0x900A): the PC port’s announcement / news list on the main menu (count, item i, select, open, seen flags). Stub: count 0.
- Group 10 (0xA000–0xA018): PC settings and helpers: 0xA003(i) / 0xA004(i, v) read / write option i (0–15: display and mouse options), 0xA009(i) option limits, 0xA012–0xA018 key binding list (22 actions, 14 slots), 0xA001(key, x) open a web page, 0xA007 / 0xA008 sign-in helpers. Needed only for the PC options scene.
- 665 distinct built-in ids are used by the
non-story scripts: group 2: 111, group 4: 306,
group 5: 54 (45 of them only in
arsenaledit), group 8: 58, group 3: 48, group 1: 26, group 10: 24, group 9: 11, group 6: 8 (title), group 7: 4. Most of group 4 is online session state.
Rebuild implementation (menus) (11-12)
godot/scripts/menu/pd_menu.gd
(engine), pd_font.gd (font, rich
text), menu_flow.gd (the session
around the battle),
converter/menuexport.py (scripts,
sets, font, character table). Decoded while
building it (PC exe 1.3.25854.2):
- Start screen. The game starts at the profile screen (id 7), which drives the title through group 6: 0x6020 init (state 0, frame 0), 0x6022 tick, 0x6023 draw, 0x6024 skip the intro (state → 2 unless 2 / 4), 0x6025(confirm) (not yet idle and confirm: skip to 2, returns 0; idle: state 3 for confirm, 4 for cancel, returns 1), 0x6026 = state is −1, 0x6027 = state is neither 2 nor 4. Tick (0x140276d50): 0 → 1 (intro) → after 0x73 frames 2 (idle) ; 3 / 4 fade out over 50 frames → −1. The screen’s own tick polls the pads (0x1029: any pad’s A / Start = event 5; X = 8; 1800 idle frames = event 2, the demo). 0x8046(0) / 0x8047(0) start and poll the async load of the title logo data into overlay slot 3 (0x1402419b0 / 0x140241a90); 0x8048 releases it.
- Save slots (PC port). After the title the profile screen enumerates the save slots: 0x208A(i) starts, 0x208B(i) polls, 0x208C(kind, slot) reads (0x14024c020; slot records 0x388 bytes at 0x14059ad50, 3 slots): kind 7 name (+0x364), 8 slot state (0x14024c1d0), 10 / 13 s16 +0x34C / +0x354, 14 in use (0x1401cfa60), 15 = 50001. 0xA00A starts the storage load, 0xA002 returns its result (0x1400bd7f0; 0 while nothing is pending). 0x20AD = global flag 0x80 clear. vsmode uses the same calls for player 2’s profile.
- Main menu rows (row values → event tasks): 100 story, 110 the versus submenu (its rows: online, split-screen → vsmode, a third online row), 120 options (id 4), 130 web page, 140, 150. B goes back to the profile screen.
- vsmode waits for a second pad (0x1029 skipping pad 0); then player 2’s memory and profile pick, then id 10.
- Character grid (vsmenu). Four columns; the script maps the cursor through one of two static tables of character indices (X switches tables); A tests 0x2096 kind 44 (refused: cue 2) and opens the colour pick when kind 43 ≥ 2. Pads are read with 0x1024–0x1026, the stick bits in the high half (masks 0x00010001 … 0x00080008).
- 0x20A3(on, src, dst, constant) (0x140207b50): blend on → render state (dst << 4 | src) << 8 | 1 (0x14028e4e0), off → blending off; then state 0x4B = constant. 0x20A4(kind 0..7, …) (0x140208590): the 3D model preview dispatch (0x14016fe20 family). 0x3173 = byte 0x14059aae5 + 1. 0x1013 / 0x1014(frames, v) music volume / fade.
- Profile-screen resets with no effect on our side: 0x5087 / 0x508E (words of the record at [0x1404c0140]), 0x42DB / 0x42DA (session state), 0x508F ([0x1404bec00] + 0x5C), 0x20B3 (byte 0x140533c55), 0x2083 (an option byte of 0x14052dfb0.., 0x14024b9d0).
- battleend reads the game kind from menu argument 0 (3 = split-screen versus: its own win / loss / draw scenes) and the result from 0x41C4 (1 / 3 win, 2 / 4 / 5 loss, 6 draw). Its banner and results-list calls (group 8: 0x8008, 0x8009, 0x8014, 0x8015, 0x8028, 0x8029, 0x803C, 0x803D; plus 0x704C, 0x3104) are not decoded yet: our build runs the screen’s script and its exits but draws neither.
- Group 8 as the result screens and the countdown use it (11-12, menus): 0x8007(set, sprite, x, y, colour) one sprite centred on the point; 0x8008(on, kind) the sprite render mode (kind 1 = alpha blend, render state 0x5401; 0 = additive, 0x1101); 0x8009 sampler states only. Banner A 0x801E(slot, set, sprite, grey, step, delay): its tick (0x14022f4d0) lowers the grey by step per tick once the delay is over. Banner B 0x8028(slot, set, sprite, target, step, delay): alpha starts at 0, its tick (0x14022f630) adds step per tick after the delay, capped at the target when step > 0. Timed text D 0x803C(slot, colour 0, colour 1, ticks, delay) / 0x803D(slot, x, y, format, args…): after the delay its phase counts 0 → ticks once (0x14022f8a0); the draw (0x14022f8d0) blends the two ARGB colours per channel by phase / ticks in 1/256 steps (0x140218a80), formats the string, measures it in rich-text mode 1 and draws it centred on x in the context’s mode (the scripts set 0x205A(1) around it). The battleend prompt fades 0x00ffa516 → 0xffffa516 over 30 ticks. 0x8014 resets the banner manager (0x14022ed90), 0x8015 hides it.
- battleend, corrected: the
split-screen versus draw scene
starts only banner B (sprite 86, drawn at (320,
150)); banner A + the direct sprite at (127,
150) and banner B at (513, 150) belong to the
win / loss scenes. The three versus scenes
close the menu on the confirm
(their task fades out and calls 0x2041); only
the online and system-link scenes call the
results-list set-up (scene
RESL). So a split-screen versus battle shows no results list. - Results-list data (online / system link): 0x41D4(slot) place (4 for an empty slot, −1 when not in the battle: 0x1404bcb38 empty flags, 0x1404bc8c8 “in battle”, 0x1404bc5c0 places); 0x41D5(slot) knockouts made = the slot’s row of the 4 × 4 tally 0x1404bc970 without itself; 0x41D6(slot) times knocked out = the slot’s column; 0x42A5(slot) empty slot; 0x431C(slot) in battle; 0x42A7(slot) money (0x1404bc9c0); 0x704C the funds (0x14052decc); 0x4238 the local slot (0x140527bc4); 0x4243 team mode (0x14050d2d8); 0x407A(slot) team; 0x422F(slot) the name (0x41-byte records at 0x1404bca30).
- Countdown placement (the ready phase’s object, draw 0x14021a2c0): ticks 0 / 30 / 60 start banner A slots 3 / 2 / 1 (set −2, sprites 0x50 / 0x4F / 0x4E, grey 40, step 2) with cue 632; tick 90 starts banner A slot 0 (sprite 0x54, grey 50, step 1) and banner B slot 0 (sprite 0x54, alpha 255, step −8, delay 50) with cue 633. Drawn: after tick 90 B then A (additive) at (320, 150); before it the newest number sprite solid at (320, 166) (0x8007’s code) with its banner-A glow (point constant 0x1402f84c0).
- Options block: 0x2082(i) / 0x2083(i, v) (0x14024b700 / 0x14024b9d0): options 0..12 are the bytes 0x14052dfb0 + i, 13..21 words from 0x14052dfc0, 22..23 words at 0x14059a9d8.., a few more ranges (flags, PC settings) above. The profile screen’s new-profile routine writes option 0 = 0, 1 = 0x11, 2 = 0x11 (vibration on for both players), 3 = 0, 4 / 5 = 60, 6..11 = 0, 13..19 = −1. In the options screen’s controller scene the rows toggle option 0 (right stick x), 1 (right stick y) and 2 (vibration) with value xor 1 and set the context word 6 (0x2080(6, 1): the changed flag).
- The script and texture formats above build
on Esper-RE (github.com/Torphedo/Esper-RE,
GPL-3.0; textures go through its
.alr→ DDS path inconverter/alrdds.cxx) and the Phantom Dust Modding Wiki (phantomdust.miraheze.org/wiki/Modding).
media/
leftovers
media/dlcustom.xpr(6 293 504 bytes): an Xbox packed-resource file (magicXPR0, total size, header size 0x800, then texture resource entries). No string in the executable names it: unused by this build (M).media/ArialUni.Ttf: no reference found either. The executable imports DirectWrite and names a system UI font for the PC overlay text (0x1400b20f0); all menu and HUD text goes through the bitmap font (“Bitmap font and text drawing”). So the rebuild needs neither file (M).
Not read
- The arsenal editor screen logic
(
arsenaledit, 45 group-5 built-ins 0x5011–0x508E; the script side of native 31),livecharasel/livestagesel/livearselinternals and the character select parameter file, the shared menu class 0x140167d00. - Item types 6, 7, 10, 12, 13, 16, 17, 19, 20 and the border sprite numbers of the window frame; text entry.
- 0x2082–0x208C, 0x209B–0x20A7, 0x20A9–0x20B4 beyond their handler addresses; exact kinds of 0x2097; which skipped rules belong to which game type in 0x140183010.
- The lobby packets.
Implementation notes for the rebuild
- Interpret the user’s scripts at run time rather than re-drawing each screen by hand: the layout numbers, row texts and flow all live in the scripts, so this is the only way to be 1:1 without copying game text. Needed: the VM (32 opcodes, already specified), this section’s engine (context, tick order, scenes and event suffixes, 16 items, history, saved words, menu variables), and a built-in table that returns 0 for unknown ids.
- Built-ins needed for the offline + our-netplay flow, in order: (a) flow: 0x2040–0x204F, 0x2080 / 0x2081, 0x208D–0x2090, 0x2098 kinds 0 / 5 / 7 / 8, 0x2099 / 0x209A, 0x20AE– 0x20B0; (b) items: 0x2060–0x207E, 0x20B5, types 1, 2, 3, 5, 21 first; (c) drawing: 0x2050–0x205F, 0x209F, the fader; (d) input and sound: 0x1024–0x1026, 0x1029, 0x102B, 0x1010 / 0x1011 / 0x1013 / 0x1014, formatting 0x102A / 0x102D; (e) data: 0x2095–0x2097, 0x507A, backed by our arsenal store, stage list and character list; (f) versus: 0x201A / 0x201B / 0x201C, 0x41CC, 0x41CE.
- First target:
vsmenualone (enter at id 10 with both players present), ending in our own match start in place of 0x201C(4): rule → match mode row, stage, two characters, two arsenals. Thenbattlestart/battleend,pausemenu(offline scene),vsmode,mainmenu,title. - For netplay keep our own lobby transport but
drive it from the game’s
livelobby,livecharasel,livestagesel,liveruleselandlivearselscreens later: stub the prelude built-ins as “signed in, no error”, and map the session settings (game type, rule, including heavy = rule 4) onto our session. Until those screens are read, the split-screenvsmenuflow can serve as the netplay set-up screen for the host. - Stub: groups 9 and 10, web page calls,
memory-unit and profile calls (answer “one
profile, ready”), trade, ranking, the CPU battle
livedbtl. - Sprites: convert each
Menu/<Set>.alrwith the HUD converter (hudconv.py) at run time on the user’s machine; set numbers −1 / −2 map toWusMn<Lang>/BtMenu<Lang>. - Windows: until the border sprites are read, draw the decoded two-colour fill with a plain 1-pixel border and list that as a placeholder.