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 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.

atentered bytimeswhat it is, and the evidence
$E125 (bank 14)a call64,260
The jump engine: tables 9, jumps through them 64,260
$F67E (bank 14)a call27,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 call16,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 call13,754
The bank switch: writes 165,048, in the blank 165,048, while drawing 0
$EC82 (bank 14)a call13,753
The bank switch: writes 54,996, in the blank 39,967, while drawing 15,029
$FF88 (bank 14)a call13,753
The bank switch: writes 55,000, in the blank 51,956, while drawing 3,044
$8361 (bank 4)a call13,750
The sound driver: frames it ran in 12,753, writes 45,424
$ECE4 (bank 14)a call7,120
The palette writers: frames it ran in 7,120, writes 832
$ED0C (bank 14)a call6,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 call5,929
The sprite writers: frames it ran in 5,927, writes to the sprite page 379,330
$9E0B (bank 3)a call5,880
The sprite writers: frames it ran in 5,880, writes to the sprite page 47,040
$F31A (bank 14)a call5,880
The sprite writers: frames it ran in 5,880, writes to the sprite page 117,600
$9CF6 (bank 2)a call1,793
The sprite writers: frames it ran in 1,449, writes to the sprite page 20,700
$9D95 (bank 3)a call1,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 call93
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 call64
The sprite writers: frames it ran in 128, writes to the sprite page 4,096
$FFA0 (bank 14)a call57
The bank switch: writes 57, in the blank 0, while drawing 57
$9A3D (bank 0)a call31
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-on31
The bank switch: writes 62, in the blank 62, while drawing 0
$E288 (bank 14)a call29
The sprite writers: frames it ran in 3,051, writes to the sprite page 3,712
$9E3F (bank 2)a call12
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 call58,080
$820E (bank 2)a call52,740
$8214 (bank 2)a call52,740
$823D (bank 2)a call52,740
$9AB9 (bank 2)a call52,740
$820D (bank 2)a table50,554
$9A4E (bank 1)a call21,647
$9A71 (bank 1)a call21,647
$92AA (bank 0)a call21,625
$92C1 (bank 0)a call21,625
$8643 (bank 4)a call20,408
$924F (bank 0)a call19,790
$8488 (bank 0)a call16,976
$9053 (bank 0)a call15,832
$9816 (bank 6)a call14,520
$9818 (bank 6)a call14,520
$981A (bank 6)a call14,520
$981C (bank 6)a call14,520
$8000 (bank 4)a call13,750
$8078 (bank 4)a call13,644
$8138 (bank 4)a call13,644
$82A2 (bank 4)a call13,644
$82FD (bank 4)a call13,644
$EC6E (bank 14)a call13,534
$F661 (bank 14)a call13,534
$EAB1 (bank 14)a call12,089
$FAFE (bank 14)a call11,760
$8FB2 (bank 0)a call7,916
$8FB5 (bank 0)a call7,916
$8FF5 (bank 0)a call7,814
$8FF8 (bank 0)a call7,814
$8C04 (bank 6)a call7,370
$9890 (bank 6)a call6,204
$8010 (bank 2)a call5,880
$8083 (bank 0)a call5,880
$F0E9 (bank 14)a call5,880
$F17E (bank 14)a call5,880
$F228 (bank 14)a call5,880
$F47C (bank 14)a call5,880
$F494 (bank 14)a call5,880
$F4C3 (bank 14)a call5,880
$FACA (bank 14)a call5,880
$8256 (bank 2)a call5,860
$82ED (bank 2)a table5,860
$9885 (bank 6)a call5,060
$8A02 (bank 0)a call3,958
$8A41 (bank 0)a table3,958
$8B35 (bank 0)a call3,958
$8C1A (bank 0)a call3,958
$8CD9 (bank 0)a call3,958
$8D6F (bank 0)a call3,958
$8DC0 (bank 0)a call3,958
$8EA4 (bank 0)a call3,958
$8EA6 (bank 0)a call3,958
$8EFA (bank 0)a call3,958
$8FFD (bank 0)a call3,958
$9316 (bank 0)a call3,958
$967B (bank 6)a call3,894
$9878 (bank 6)a call3,894
$8D2C (bank 0)a call3,789
$97E2 (bank 6)a call3,630
$828F (bank 0)a call3,111
$958C (bank 3)a call2,852
$9B87 (bank 3)a call2,852
$9BE2 (bank 3)a call2,852
$9C2E (bank 3)a call2,852
$9D29 (bank 3)a call2,852
$9D4C (bank 3)a call2,852
$9D6B (bank 3)a call2,852
$8629 (bank 4)a call2,690
$8894 (bank 2)a call2,186
$88E8 (bank 2)a call2,186
$89B9 (bank 2)a table2,186
$82E2 (bank 0)a call2,149
$833E (bank 0)a call2,123
$895D (bank 0)a call2,031
$8634 (bank 4)a call1,911
$910C (bank 0)a call1,854
$873F (bank 4)a call1,617
$86C1 (bank 4)a call1,539
$8577 (bank 2)a call1,426
$8A57 (bank 2)a call1,426
$9471 (bank 2)a table1,426
$94FD (bank 3)a call1,426
$95AC (bank 3)a call1,426
$98D1 (bank 2)a call1,426
$997E (bank 2)a call1,426
$9B1F (bank 2)a call1,426
$9E4F (bank 2)a call1,426
$9E54 (bank 2)a call1,426
$86BA (bank 4)a call1,354
$86CE (bank 4)a call1,341
$8743 (bank 4)a call1,210
$9DC5 (bank 3)a call1,173
$823D (bank 0)a call1,135
$8000 (bank 0)a call1,080
$F6C0 (bank 14)a call1,080
$82BE (bank 0)a call990
$846A (bank 0)a call822
$8311 (bank 2)a call720
$9608 (bank 0)a call656
$EAAD (bank 14)a call618
$8412 (bank 0)a call550
$8138 (bank 2)a call420
$84AC (bank 0)a call416
$9370 (bank 6)a call408
$938A (bank 6)a call288
$ECB4 (bank 14)a call192
$EA31 (bank 14)a call140
$EAA9 (bank 14)a call139
$E9A4 (bank 14)a call134
$8898 (bank 6)a call132
$8BB3 (bank 6)a table132
$EA94 (bank 14)a call114
$8451 (bank 10)a call74
$95D4 (bank 6)a call68
$88D8 (bank 6)a call66
$8CAF (bank 6)a table66
$8314 (bank 0)a call58
$E198 (bank 14)a call57
$E1F4 (bank 14)a call46
$88B5 (bank 6)a call44
$9020 (bank 6)a table44
$95AF (bank 0)a call44
$98A8 (bank 6)a call44
$98BC (bank 6)a call44
$E15B (bank 14)a call33
$E166 (bank 14)a call33
$E17F (bank 14)a call33
$9604 (bank 0)a call31
$FE41 (bank 14)a call31
$FE57 (bank 14)a call29
$86C8 (bank 4)a call27
$FE6E (bank 14)a call27
$93A4 (bank 6)a call24
$FE16 (bank 14)a call24
$8327 (bank 10)a call23
$E1FA (bank 14)a call23
$E228 (bank 14)a call23
$F218 (bank 14)a call23
$86EE (bank 0)a call22
$88FE (bank 6)a call22
$933A (bank 6)a call22
$946D (bank 0)a call22
$94CA (bank 0)a call22
$94DC (bank 0)a table22
$950E (bank 6)a call22
$9561 (bank 0)a call22
$9567 (bank 6)a call22
$95E6 (bank 6)a call22
$9728 (bank 6)a call22
$98DC (bank 6)a call22
$F754 (bank 14)a call22
$8441 (bank 2)a call12
$845D (bank 2)a call12
$8C99 (bank 0)a call7
$81A2 (bank 0)a call4
$E9EB (bank 14)a call4
$81D6 (bank 0)a call2
$81FE (bank 0)a call2

Where it waits

Loops a rule named that sit inside a routine and are not themselves a place the code is entered.

atwhat 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.

atentriestakenchosen by the byte at
$8A2F (bank 0)11$0050
$94D0 (bank 0)11$0534
$8242 (bank 2)22$0051, $0052, $0053, $0054
$8260 (bank 2)11$00EC
$83B3 (bank 2)211$0093, $0094
$8A5C (bank 2)81$0093, $0094
$889B (bank 6)101
$88B8 (bank 6)121
$88DE (bank 6)11

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

frombytes reachedinstructionspositions it holds
$00281143 across
$0032621 down
$0047562 down
$04D6512 down
$00002562
$02002536
$02011975
$02031974
$02021973
$02041933
$02051933
$02061931

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.

slotsarraysroutinespositions acrosspositions downadded into themchoosing a jumptravelling with them
1174$0028$0032$003C, $0407, $04CB$0014, $001E, $003C, $0407, $04CB
543$0047$005B, $006F, $009F

The 24 busiest shared bytes

bytereads and writesroutines writingroutines reading
$00F5805,46536
$0001471,71066
$0000375,46766
$000A256,91566
$00EC219,03426
$00F0197,88263
$00F1197,88263
$0002197,74566
$0003192,86066
$0051136,51816
$0012132,84936
$000B123,36366
$00A8120,93016
$00E6109,81066
$00F790,99225
$000790,59466
$040088,72424
$009079,00316
$000C77,86566
$002874,18436
$00CB72,99256
$001472,22546
$002971,75016
$00E970,61533

This page shows none of the game's bytes. The listing these figures were read from stays with the cartridge.

All the games