Super Mario Bros. 2 (USA) (Rev 1)
Super Mario Bros. 2 (USA) (Rev 1) is on a MMC3 board with 131,072 bytes of program. A crawl of 400 steps from power-on kept 31 paths that found new code. Played back over 24,411 frames, they executed 9,665 bytes of it, 7 percent.
What the rules named
- The poll: 2
- The wait for the frame: 2
- The jump engine: 1
- The bank switch: 6
- The picture writer: 1
- The palette writers: 3
- The sprite writers: 7
- The scroll writer: 1
- The sound driver: 1
- Where two things are compared: 3
The 182 routines the runs entered
Every place the game's code was entered, by a call, an interrupt or a jump through a table. The ones a rule named come first, with what the rule saw.
| at | entered by | times | what it is, and the evidence |
|---|---|---|---|
| $E125 (bank 14) | a call | 64,260 | The jump engine: tables 9, jumps through them 64,260 |
| $F67E (bank 14) | a call | 27,068 | The poll: port $4016, reads a frame 16, strobes a frame 4 The poll: port $4017, reads a frame 16, strobes a frame 4 |
| $FF85 (bank 14) | a call | 16,984 | The bank switch: writes 67,936, in the blank 532, while drawing 67,404 |
| $EB94 (bank 14) | each frame (NMI) | 13,754 | The scroll writer: frames it ran in 13,787, writes in the blank 26,820 |
| $FF73 (bank 14) | a call | 13,754 | The bank switch: writes 165,048, in the blank 165,048, while drawing 0 |
| $EC82 (bank 14) | a call | 13,753 | The bank switch: writes 54,996, in the blank 39,967, while drawing 15,029 |
| $FF88 (bank 14) | a call | 13,753 | The bank switch: writes 55,000, in the blank 51,956, while drawing 3,044 |
| $8361 (bank 4) | a call | 13,750 | The sound driver: frames it ran in 12,753, writes 45,424 |
| $ECE4 (bank 14) | a call | 7,120 | The palette writers: frames it ran in 7,120, writes 832 |
| $ED0C (bank 14) | a call | 6,414 | The palette writers: frames it ran in 6,414, writes 2,348 The picture writer: frames it ran in 6,414, writes 86,779, in the blank 13,772, while drawing 73,007 |
| $ECA6 (bank 14) | a call | 5,929 | The sprite writers: frames it ran in 5,927, writes to the sprite page 379,330 |
| $9E0B (bank 3) | a call | 5,880 | The sprite writers: frames it ran in 5,880, writes to the sprite page 47,040 |
| $F31A (bank 14) | a call | 5,880 | The sprite writers: frames it ran in 5,880, writes to the sprite page 117,600 |
| $9CF6 (bank 2) | a call | 1,793 | The sprite writers: frames it ran in 1,449, writes to the sprite page 20,700 |
| $9D95 (bank 3) | a call | 1,173 | Where two things are compared: instructions 1, pairs of bytes 8, bytes in all 5, times compared 3,104, Y positions at $0032,$004A,$004B,$04D9,$04DA |
| $9D82 (bank 3) | a call | 93 | Where two things are compared: instructions 1, pairs of bytes 2, bytes in all 3, times compared 93, X positions at $0028,$002C,$002D |
| $EC90 (bank 14) | a call | 64 | The sprite writers: frames it ran in 128, writes to the sprite page 4,096 |
| $FFA0 (bank 14) | a call | 57 | The bank switch: writes 57, in the blank 0, while drawing 57 |
| $9A3D (bank 0) | a call | 31 | The palette writers: frames it ran in 706, writes 992 The sprite writers: frames it ran in 706, writes to the sprite page 9,792 |
| $FF50 (bank 14) | power-on | 31 | The bank switch: writes 62, in the blank 62, while drawing 0 |
| $E288 (bank 14) | a call | 29 | The sprite writers: frames it ran in 3,051, writes to the sprite page 3,712 |
| $9E3F (bank 2) | a call | 12 | Where two things are compared: instructions 1, pairs of bytes 2, bytes in all 3, times compared 12, X positions at $0028,$002C,$002D |
| $97D6 (bank 6) | a call | 58,080 | |
| $820E (bank 2) | a call | 52,740 | |
| $8214 (bank 2) | a call | 52,740 | |
| $823D (bank 2) | a call | 52,740 | |
| $9AB9 (bank 2) | a call | 52,740 | |
| $820D (bank 2) | a table | 50,554 | |
| $9A4E (bank 1) | a call | 21,647 | |
| $9A71 (bank 1) | a call | 21,647 | |
| $92AA (bank 0) | a call | 21,625 | |
| $92C1 (bank 0) | a call | 21,625 | |
| $8643 (bank 4) | a call | 20,408 | |
| $924F (bank 0) | a call | 19,790 | |
| $8488 (bank 0) | a call | 16,976 | |
| $9053 (bank 0) | a call | 15,832 | |
| $9816 (bank 6) | a call | 14,520 | |
| $9818 (bank 6) | a call | 14,520 | |
| $981A (bank 6) | a call | 14,520 | |
| $981C (bank 6) | a call | 14,520 | |
| $8000 (bank 4) | a call | 13,750 | |
| $8078 (bank 4) | a call | 13,644 | |
| $8138 (bank 4) | a call | 13,644 | |
| $82A2 (bank 4) | a call | 13,644 | |
| $82FD (bank 4) | a call | 13,644 | |
| $EC6E (bank 14) | a call | 13,534 | |
| $F661 (bank 14) | a call | 13,534 | |
| $EAB1 (bank 14) | a call | 12,089 | |
| $FAFE (bank 14) | a call | 11,760 | |
| $8FB2 (bank 0) | a call | 7,916 | |
| $8FB5 (bank 0) | a call | 7,916 | |
| $8FF5 (bank 0) | a call | 7,814 | |
| $8FF8 (bank 0) | a call | 7,814 | |
| $8C04 (bank 6) | a call | 7,370 | |
| $9890 (bank 6) | a call | 6,204 | |
| $8010 (bank 2) | a call | 5,880 | |
| $8083 (bank 0) | a call | 5,880 | |
| $F0E9 (bank 14) | a call | 5,880 | |
| $F17E (bank 14) | a call | 5,880 | |
| $F228 (bank 14) | a call | 5,880 | |
| $F47C (bank 14) | a call | 5,880 | |
| $F494 (bank 14) | a call | 5,880 | |
| $F4C3 (bank 14) | a call | 5,880 | |
| $FACA (bank 14) | a call | 5,880 | |
| $8256 (bank 2) | a call | 5,860 | |
| $82ED (bank 2) | a table | 5,860 | |
| $9885 (bank 6) | a call | 5,060 | |
| $8A02 (bank 0) | a call | 3,958 | |
| $8A41 (bank 0) | a table | 3,958 | |
| $8B35 (bank 0) | a call | 3,958 | |
| $8C1A (bank 0) | a call | 3,958 | |
| $8CD9 (bank 0) | a call | 3,958 | |
| $8D6F (bank 0) | a call | 3,958 | |
| $8DC0 (bank 0) | a call | 3,958 | |
| $8EA4 (bank 0) | a call | 3,958 | |
| $8EA6 (bank 0) | a call | 3,958 | |
| $8EFA (bank 0) | a call | 3,958 | |
| $8FFD (bank 0) | a call | 3,958 | |
| $9316 (bank 0) | a call | 3,958 | |
| $967B (bank 6) | a call | 3,894 | |
| $9878 (bank 6) | a call | 3,894 | |
| $8D2C (bank 0) | a call | 3,789 | |
| $97E2 (bank 6) | a call | 3,630 | |
| $828F (bank 0) | a call | 3,111 | |
| $958C (bank 3) | a call | 2,852 | |
| $9B87 (bank 3) | a call | 2,852 | |
| $9BE2 (bank 3) | a call | 2,852 | |
| $9C2E (bank 3) | a call | 2,852 | |
| $9D29 (bank 3) | a call | 2,852 | |
| $9D4C (bank 3) | a call | 2,852 | |
| $9D6B (bank 3) | a call | 2,852 | |
| $8629 (bank 4) | a call | 2,690 | |
| $8894 (bank 2) | a call | 2,186 | |
| $88E8 (bank 2) | a call | 2,186 | |
| $89B9 (bank 2) | a table | 2,186 | |
| $82E2 (bank 0) | a call | 2,149 | |
| $833E (bank 0) | a call | 2,123 | |
| $895D (bank 0) | a call | 2,031 | |
| $8634 (bank 4) | a call | 1,911 | |
| $910C (bank 0) | a call | 1,854 | |
| $873F (bank 4) | a call | 1,617 | |
| $86C1 (bank 4) | a call | 1,539 | |
| $8577 (bank 2) | a call | 1,426 | |
| $8A57 (bank 2) | a call | 1,426 | |
| $9471 (bank 2) | a table | 1,426 | |
| $94FD (bank 3) | a call | 1,426 | |
| $95AC (bank 3) | a call | 1,426 | |
| $98D1 (bank 2) | a call | 1,426 | |
| $997E (bank 2) | a call | 1,426 | |
| $9B1F (bank 2) | a call | 1,426 | |
| $9E4F (bank 2) | a call | 1,426 | |
| $9E54 (bank 2) | a call | 1,426 | |
| $86BA (bank 4) | a call | 1,354 | |
| $86CE (bank 4) | a call | 1,341 | |
| $8743 (bank 4) | a call | 1,210 | |
| $9DC5 (bank 3) | a call | 1,173 | |
| $823D (bank 0) | a call | 1,135 | |
| $8000 (bank 0) | a call | 1,080 | |
| $F6C0 (bank 14) | a call | 1,080 | |
| $82BE (bank 0) | a call | 990 | |
| $846A (bank 0) | a call | 822 | |
| $8311 (bank 2) | a call | 720 | |
| $9608 (bank 0) | a call | 656 | |
| $EAAD (bank 14) | a call | 618 | |
| $8412 (bank 0) | a call | 550 | |
| $8138 (bank 2) | a call | 420 | |
| $84AC (bank 0) | a call | 416 | |
| $9370 (bank 6) | a call | 408 | |
| $938A (bank 6) | a call | 288 | |
| $ECB4 (bank 14) | a call | 192 | |
| $EA31 (bank 14) | a call | 140 | |
| $EAA9 (bank 14) | a call | 139 | |
| $E9A4 (bank 14) | a call | 134 | |
| $8898 (bank 6) | a call | 132 | |
| $8BB3 (bank 6) | a table | 132 | |
| $EA94 (bank 14) | a call | 114 | |
| $8451 (bank 10) | a call | 74 | |
| $95D4 (bank 6) | a call | 68 | |
| $88D8 (bank 6) | a call | 66 | |
| $8CAF (bank 6) | a table | 66 | |
| $8314 (bank 0) | a call | 58 | |
| $E198 (bank 14) | a call | 57 | |
| $E1F4 (bank 14) | a call | 46 | |
| $88B5 (bank 6) | a call | 44 | |
| $9020 (bank 6) | a table | 44 | |
| $95AF (bank 0) | a call | 44 | |
| $98A8 (bank 6) | a call | 44 | |
| $98BC (bank 6) | a call | 44 | |
| $E15B (bank 14) | a call | 33 | |
| $E166 (bank 14) | a call | 33 | |
| $E17F (bank 14) | a call | 33 | |
| $9604 (bank 0) | a call | 31 | |
| $FE41 (bank 14) | a call | 31 | |
| $FE57 (bank 14) | a call | 29 | |
| $86C8 (bank 4) | a call | 27 | |
| $FE6E (bank 14) | a call | 27 | |
| $93A4 (bank 6) | a call | 24 | |
| $FE16 (bank 14) | a call | 24 | |
| $8327 (bank 10) | a call | 23 | |
| $E1FA (bank 14) | a call | 23 | |
| $E228 (bank 14) | a call | 23 | |
| $F218 (bank 14) | a call | 23 | |
| $86EE (bank 0) | a call | 22 | |
| $88FE (bank 6) | a call | 22 | |
| $933A (bank 6) | a call | 22 | |
| $946D (bank 0) | a call | 22 | |
| $94CA (bank 0) | a call | 22 | |
| $94DC (bank 0) | a table | 22 | |
| $950E (bank 6) | a call | 22 | |
| $9561 (bank 0) | a call | 22 | |
| $9567 (bank 6) | a call | 22 | |
| $95E6 (bank 6) | a call | 22 | |
| $9728 (bank 6) | a call | 22 | |
| $98DC (bank 6) | a call | 22 | |
| $F754 (bank 14) | a call | 22 | |
| $8441 (bank 2) | a call | 12 | |
| $845D (bank 2) | a call | 12 | |
| $8C99 (bank 0) | a call | 7 | |
| $81A2 (bank 0) | a call | 4 | |
| $E9EB (bank 14) | a call | 4 | |
| $81D6 (bank 0) | a call | 2 | |
| $81FE (bank 0) | a call | 2 |
Where it waits
Loops a rule named that sit inside a routine and are not themselves a place the code is entered.
| at | what it is, and the evidence |
|---|---|
| $961A (bank 0) | The wait for the frame: waits on the byte at $00EB, times entered 686, turns 2,926,371, writes of it under the frame interrupt 27,506, frames in all 13,911 |
| $EAC3 (bank 14) | The wait for the frame: waits on the byte at $00EB, times entered 12,872, turns 49,070,935, writes of it under the frame interrupt 27,506, frames in all 13,911 |
The jump engine's tables
Each table sits right after a call to the engine. An entry is counted as far as the runs saw one taken; the true table may be longer. The last column is the byte of memory whose value picked the entry, where we could follow it: the game's mode, or what one of its objects is doing.
| at | entries | taken | chosen by the byte at |
|---|---|---|---|
| $8A2F (bank 0) | 1 | 1 | $0050 |
| $94D0 (bank 0) | 1 | 1 | $0534 |
| $8242 (bank 2) | 2 | 2 | $0051, $0052, $0053, $0054 |
| $8260 (bank 2) | 1 | 1 | $00EC |
| $83B3 (bank 2) | 21 | 1 | $0093, $0094 |
| $8A5C (bank 2) | 8 | 1 | $0093, $0094 |
| $889B (bank 6) | 10 | 1 | |
| $88B8 (bank 6) | 12 | 1 | |
| $88DE (bank 6) | 1 | 1 |
The memory its routines share
1,023 bytes of memory were written by one routine and read by another, and 85 places were reached through an index, which is what a table or a set of object slots in memory looks like.
Reaches through an index: those that hold positions, then the longest
| from | bytes reached | instructions | positions it holds |
|---|---|---|---|
| $0028 | 11 | 4 | 3 across |
| $0032 | 6 | 2 | 1 down |
| $0047 | 5 | 6 | 2 down |
| $04D6 | 5 | 1 | 2 down |
| $0000 | 256 | 2 | |
| $0200 | 253 | 6 | |
| $0201 | 197 | 5 | |
| $0203 | 197 | 4 | |
| $0202 | 197 | 3 | |
| $0204 | 193 | 3 | |
| $0205 | 193 | 3 | |
| $0206 | 193 | 1 |
What travels with a position
Arrays that at least two routines step through together with an array of positions, across the same range. That is what a table of the things on the screen looks like in memory: one array for each property, one slot for each thing. We can say which arrays hold positions, which of the others get added into them, which is what a speed does, and which pick the way through a jump table, which is what a state or a kind does. What the rest hold is not named yet.
| slots | arrays | routines | positions across | positions down | added into them | choosing a jump | travelling with them |
|---|---|---|---|---|---|---|---|
| 11 | 7 | 4 | $0028 | $0032 | $003C, $0407, $04CB | $0014, $001E, $003C, $0407, $04CB | |
| 5 | 4 | 3 | $0047 | $005B, $006F, $009F |
The 24 busiest shared bytes
| byte | reads and writes | routines writing | routines reading |
|---|---|---|---|
| $00F5 | 805,465 | 3 | 6 |
| $0001 | 471,710 | 6 | 6 |
| $0000 | 375,467 | 6 | 6 |
| $000A | 256,915 | 6 | 6 |
| $00EC | 219,034 | 2 | 6 |
| $00F0 | 197,882 | 6 | 3 |
| $00F1 | 197,882 | 6 | 3 |
| $0002 | 197,745 | 6 | 6 |
| $0003 | 192,860 | 6 | 6 |
| $0051 | 136,518 | 1 | 6 |
| $0012 | 132,849 | 3 | 6 |
| $000B | 123,363 | 6 | 6 |
| $00A8 | 120,930 | 1 | 6 |
| $00E6 | 109,810 | 6 | 6 |
| $00F7 | 90,992 | 2 | 5 |
| $0007 | 90,594 | 6 | 6 |
| $0400 | 88,724 | 2 | 4 |
| $0090 | 79,003 | 1 | 6 |
| $000C | 77,865 | 6 | 6 |
| $0028 | 74,184 | 3 | 6 |
| $00CB | 72,992 | 5 | 6 |
| $0014 | 72,225 | 4 | 6 |
| $0029 | 71,750 | 1 | 6 |
| $00E9 | 70,615 | 3 | 3 |
This page shows none of the game's bytes. The listing these figures were read from stays with the cartridge.