Tetris (USA)
Tetris (USA) is on a MMC1 board with 32,768 bytes of program. A crawl of 6,400 steps from power-on kept 54 paths that found new code. Played back over 181,254 frames, they executed 6,318 bytes of it, 19 percent.
What the rules named
- The poll: 2
- The wait for the frame: 4
- The jump engine: 1
- The bank switch: 7
- The picture writer: 1
- The palette writers: 3
- The sprite writers: 5
- The scroll writer: 2
- The sound driver: 1
- The random byte: 1
The 121 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, and their names in the listing say what they are: a poll, an engine, a drain.
| at | its name in the listing | entered by | times | what it is, and the evidence |
|---|---|---|---|---|
| $AC82 (bank 0) | b0_engine_AC82 | a call | 194,840 | The jump engine: tables 4, jumps through them 194,840 |
| $AB69 (bank 0) | b0_poll_AB69 | a call | 110,004 | The poll: port $4016, reads a frame 16, strobes a frame 4 The poll: port $4017, reads a frame 16, strobes a frame 4 |
| $AC6A (bank 0) | b0_sprites_AC6A | a call | 60,749 | The sprite writers: frames it ran in 54,948, writes to the sprite page 15,521,454 |
| $AB47 (bank 0) | b0_random_AB47 | a call | 60,684 | The random byte: frames it ran in 55,002, bytes $0017,$0018, rotates 2, exclusive-ors 1 |
| $8005 (bank 0) | b0_nmi | each frame (NMI) | 55,002 | The scroll writer: frames it ran in 55,002, writes in the blank 109,960 |
| $E000 (bank 1) | b1_sound_E000 | a call | 55,002 | The sound driver: frames it ran in 54,734, writes 55,002 |
| $82B1 (bank 0) | b0_dispatch_82B1 | a table | 37,643 | The scroll writer: frames it ran in 37,643, writes in the blank 75,286 |
| $9725 (bank 0) | b0_drain_9725 | a call | 36,688 | The picture writer: frames it ran in 9,172, writes 26,800, in the blank 26,800, while drawing 0 |
| $8C27 (bank 0) | b0_sprites_8C27 | a call | 18,224 | The sprite writers: frames it ran in 11,732, writes to the sprite page 199,848 |
| $ACB7 (bank 0) | b0_bank_ACB7 | a call | 9,574 | The bank switch: writes 47,870, in the blank 1,100, while drawing 46,770 |
| $ACCB (bank 0) | b0_bank_ACCB | a call | 9,574 | The bank switch: writes 47,870, in the blank 1,100, while drawing 46,770 |
| $94EE (bank 0) | b0_dispatch_94EE | a table | 9,360 | The palette writers: frames it ran in 9,360, writes 9,360 |
| $8A0A (bank 0) | b0_sprites_8A0A | a call | 9,304 | The sprite writers: frames it ran in 9,304, writes to the sprite page 150,282 |
| $8BCE (bank 0) | b0_sprites_8BCE | a call | 9,304 | The sprite writers: frames it ran in 9,304, writes to the sprite page 148,560 |
| $AA98 (bank 0) | b0_palette_AA98 | a call | 493 | The palette writers: frames it ran in 468, writes 4,393 |
| $ACA3 (bank 0) | b0_bank_ACA3 | a call | 140 | The bank switch: writes 700, in the blank 270, while drawing 430 |
| $ACDF (bank 0) | b0_bank_ACDF | a call | 54 | The bank switch: writes 270, in the blank 270, while drawing 0 |
| $FF00 (bank 1) | b1_reset | power-on | 54 | The bank switch: writes 108, in the blank 108, while drawing 0 The sprite writers: frames it ran in 9,870, writes to the sprite page 13,824 |
| $82D1 (bank 0) | b0_dispatch_82D1 | a table | 50 | The bank switch: writes 100, in the blank 0, while drawing 100 |
| $83D7 (bank 0) | b0_dispatch_83D7 | a table | 36 | The bank switch: writes 72, in the blank 0, while drawing 72 |
| $9808 (bank 0) | b0_palette_9808 | a call | 22 | The palette writers: frames it ran in 22, writes 176 |
| $AB8B (bank 0) | a call | 110,001 | ||
| $8161 (bank 0) | a call | 65,364 | ||
| $819B (bank 0) | a call | 65,170 | ||
| $815D (bank 0) | a table | 65,168 | ||
| $804B (bank 0) | a call | 55,002 | ||
| $9D51 (bank 0) | a call | 55,002 | ||
| $AB5E (bank 0) | a call | 55,002 | ||
| $AB9D (bank 0) | a call | 55,002 | ||
| $AA2F (bank 0) | a call | 54,458 | ||
| $E194 (bank 1) | a call | 50,624 | ||
| $E19C (bank 1) | a call | 50,624 | ||
| $E1AC (bank 1) | a call | 50,624 | ||
| $E1B9 (bank 1) | a call | 50,624 | ||
| $E583 (bank 1) | a call | 50,624 | ||
| $E5D0 (bank 1) | a call | 29,077 | ||
| $E766 (bank 1) | a call | 29,077 | ||
| $8174 (bank 0) | a table | 9,304 | ||
| $8186 (bank 0) | a table | 9,304 | ||
| $81B2 (bank 0) | a call | 9,304 | ||
| $8776 (bank 0) | a call | 9,304 | ||
| $87AE (bank 0) | a call | 9,304 | ||
| $8884 (bank 0) | a table | 9,304 | ||
| $9CBF (bank 0) | a table | 9,304 | ||
| $9E16 (bank 0) | a table | 9,304 | ||
| $A37F (bank 0) | a table | 9,304 | ||
| $9874 (bank 0) | a call | 9,302 | ||
| $9E27 (bank 0) | a table | 9,302 | ||
| $81CF (bank 0) | a table | 8,367 | ||
| $88AB (bank 0) | a call | 8,367 | ||
| $8914 (bank 0) | a call | 8,367 | ||
| $89AE (bank 0) | a call | 8,367 | ||
| $85DA (bank 0) | a table | 7,999 | ||
| $E735 (bank 1) | a call | 7,897 | ||
| $EA41 (bank 1) | a call | 5,058 | ||
| $E072 (bank 1) | a call | 4,509 | ||
| $E0B5 (bank 1) | a call | 4,013 | ||
| $948B (bank 0) | a call | 1,733 | ||
| $84AE (bank 0) | a call | 1,526 | ||
| $9712 (bank 0) | a call | 1,432 | ||
| $E481 (bank 1) | a table | 1,282 | ||
| $E39C (bank 1) | a table | 1,011 | ||
| $9DE8 (bank 0) | a call | 824 | ||
| $E04B (bank 1) | a call | 668 | ||
| $E3DD (bank 1) | a table | 646 | ||
| $E3B3 (bank 1) | a table | 552 | ||
| $AA45 (bank 0) | a call | 544 | ||
| $E9EB (bank 1) | a call | 509 | ||
| $EA03 (bank 1) | a call | 509 | ||
| $AB21 (bank 0) | a call | 493 | ||
| $E637 (bank 1) | a call | 446 | ||
| $E271 (bank 1) | a call | 363 | ||
| $E425 (bank 1) | a table | 360 | ||
| $E33B (bank 1) | a call | 339 | ||
| $9A6B (bank 0) | a table | 309 | ||
| $AA52 (bank 0) | a call | 270 | ||
| $AA5F (bank 0) | a call | 270 | ||
| $AA6B (bank 0) | a call | 270 | ||
| $AA78 (bank 0) | a call | 270 | ||
| $AA8A (bank 0) | a call | 270 | ||
| $E253 (bank 1) | a call | 255 | ||
| $E390 (bank 1) | a table | 217 | ||
| $AA82 (bank 0) | a call | 216 | ||
| $AC1C (bank 0) | a call | 216 | ||
| $E003 (bank 1) | a call | 198 | ||
| $977F (bank 0) | a call | 188 | ||
| $9E39 (bank 0) | a table | 178 | ||
| $988E (bank 0) | a table | 142 | ||
| $9CAF (bank 0) | a call | 135 | ||
| $9D17 (bank 0) | a call | 133 | ||
| $98EB (bank 0) | a call | 110 | ||
| $99A2 (bank 0) | a table | 110 | ||
| $E287 (bank 1) | a call | 110 | ||
| $E473 (bank 1) | a table | 110 | ||
| $9E07 (bank 0) | a call | 107 | ||
| $E247 (bank 1) | a call | 104 | ||
| $E6D7 (bank 1) | a call | 104 | ||
| $E3CA (bank 1) | a table | 93 | ||
| $9969 (bank 0) | a call | 88 | ||
| $E417 (bank 1) | a call | 86 | ||
| $E43B (bank 1) | a table | 86 | ||
| $9B03 (bank 0) | a table | 66 | ||
| $9B58 (bank 0) | a table | 66 | ||
| $A3F2 (bank 0) | a table | 66 | ||
| $E3D1 (bank 1) | a table | 66 | ||
| $E384 (bank 1) | a table | 56 | ||
| $8200 (bank 0) | a table | 54 | ||
| $824F (bank 0) | a table | 54 | ||
| $A459 (bank 0) | a call | 54 | ||
| $E006 (bank 1) | a call | 54 | ||
| $E244 (bank 1) | a call | 54 | ||
| $9907 (bank 0) | a call | 48 | ||
| $9FF2 (bank 0) | a call | 36 | ||
| $85F0 (bank 0) | a table | 22 | ||
| $86DC (bank 0) | a table | 22 | ||
| $87DC (bank 0) | a call | 22 | ||
| $E41A (bank 1) | a table | 14 | ||
| $E40E (bank 1) | a table | 10 | ||
| $E42E (bank 1) | a table | 4 | ||
| $9DF6 (bank 0) | a table | 2 | ||
| $E403 (bank 1) | a table | 2 |
Where it waits
Loops a rule named that sit inside a routine and are not themselves a place the code is entered.
| at | its name in the listing | what it is, and the evidence |
|---|---|---|
| $828D (bank 0) | b0_wait_828D | The wait for the frame: waits on the byte at $00F5, times entered 54, turns 6,257, calls on each turn 1, writes of it under the frame interrupt 1,987,495, frames in all 55,254 |
| $A45B (bank 0) | b0_wait_A45B | The wait for the frame: waits on the byte at $00C3, times entered 54, turns 13,470, calls on each turn 1, writes of it under the frame interrupt 192,960, frames in all 55,254 |
| $AA37 (bank 0) | b0_wait_AA37 | The wait for the frame: waits on the byte at $0033, times entered 54,458, turns 214,054,962, writes of it under the frame interrupt 55,002, frames in all 55,254 |
| $AA4D (bank 0) | b0_wait_AA4D | The wait for the frame: waits on the byte at $0033, times entered 544, turns 2,062,901, writes of it under the frame interrupt 55,002, frames in all 55,254 |
The tables it jumps through
A table of addresses the game picks one from. Some sit right after a call to a jump engine; others are anywhere in the cartridge, and we find them by where the address the game jumped through was loaded from. Some games jump by pushing an address and returning to it, and some keep a table as two, the low bytes of its addresses in one place and the high bytes in another; both are found the same way. 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 | reached | entries | taken | chosen by the byte at |
|---|---|---|---|---|
| $8050 (bank 0) | after a call | 4 | 3 | $00BD |
| $8166 (bank 0) | after a call | 7 | 6 | $00C0 |
| $81A0 (bank 0) | after a call | 9 | 9 | $00A7 |
| $81B7 (bank 0) | after a call | 10 | 8 | $0068 |
| $E015 (bank 1) | through a pointer | 20 | 15 |
The memory its routines share
449 bytes of memory were written by one routine and read by another, and 47 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 |
|---|---|---|---|
| $0400 | 201 | 4 | |
| $0500 | 201 | 2 | |
| $0700 | 80 | 2 | |
| $0200 | 32 | 10 | |
| $0040 | 32 | 2 | |
| $0060 | 32 | 2 | |
| $0000 | 25 | 2 | |
| $0001 | 24 | 1 | |
| $0730 | 21 | 3 | |
| $03EF | 16 | 1 | |
| $03F0 | 13 | 3 | |
| $03F1 | 13 | 1 |
The 24 busiest shared bytes
| byte | reads and writes | routines writing | routines reading |
|---|---|---|---|
| $0001 | 20,022,880 | 6 | 6 |
| $0000 | 20,021,494 | 6 | 6 |
| $00F5 | 3,633,963 | 5 | 6 |
| $0040 | 641,258 | 4 | 6 |
| $0060 | 614,130 | 3 | 3 |
| $00A7 | 307,410 | 6 | 6 |
| $00E0 | 242,904 | 6 | 6 |
| $00F7 | 210,524 | 3 | 5 |
| $00ED | 204,165 | 5 | 6 |
| $00C0 | 195,843 | 6 | 6 |
| $06F1 | 152,551 | 6 | 3 |
| $0017 | 152,200 | 2 | 5 |
| $06F5 | 152,089 | 3 | 3 |
| $06F0 | 151,980 | 2 | 3 |
| $06F2 | 151,980 | 2 | 3 |
| $06F3 | 151,980 | 2 | 3 |
| $00B1 | 122,500 | 2 | 6 |
| $00FB | 110,112 | 1 | 2 |
| $00FF | 109,104 | 6 | 6 |
| $0049 | 85,525 | 6 | 6 |
| $06FD | 80,316 | 3 | 4 |
| $00A0 | 77,429 | 5 | 3 |
| $00A1 | 77,429 | 5 | 3 |
| $00EE | 73,296 | 2 | 5 |
This page shows none of the game's bytes. The listing these figures were read from stays with the cartridge.