Tetris (USA)
Tetris (USA) is on a MMC1 board with 32,768 bytes of program. A crawl of 400 steps from power-on kept 33 paths that found new code. Played back over 32,313 frames, they executed 5,371 bytes of it, 16 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 111 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 |
|---|---|---|---|
| $AB69 (bank 0) | a call | 43,322 | The poll: port $4016, reads a frame 16, strobes a frame 4 The poll: port $4017, reads a frame 16, strobes a frame 4 |
| $AC82 (bank 0) | a call | 30,073 | The jump engine: tables 4, jumps through them 30,073 |
| $AB47 (bank 0) | a call | 24,059 | The random byte: frames it ran in 21,661, bytes $0017,$0018, rotates 2, exclusive-ors 1 |
| $AC6A (bank 0) | a call | 22,895 | The sprite writers: frames it ran in 21,628, writes to the sprite page 5,842,818 |
| $8005 (bank 0) | each frame (NMI) | 21,661 | The scroll writer: frames it ran in 21,661, writes in the blank 43,298 |
| $E000 (bank 1) | a call | 21,661 | The sound driver: frames it ran in 21,500, writes 21,661 |
| $82B1 (bank 0) | a table | 18,728 | The scroll writer: frames it ran in 18,728, writes in the blank 37,456 |
| $8C27 (bank 0) | a call | 3,403 | The sprite writers: frames it ran in 1,977, writes to the sprite page 28,840 |
| $9725 (bank 0) | a call | 2,244 | The picture writer: frames it ran in 561, writes 3,000, in the blank 3,000, while drawing 0 |
| $ACB7 (bank 0) | a call | 711 | The bank switch: writes 3,555, in the blank 650, while drawing 2,905 |
| $ACCB (bank 0) | a call | 711 | The bank switch: writes 3,555, in the blank 650, while drawing 2,905 |
| $94EE (bank 0) | a table | 561 | The palette writers: frames it ran in 561, writes 561 |
| $8A0A (bank 0) | a call | 550 | The sprite writers: frames it ran in 550, writes to the sprite page 8,811 |
| $8BCE (bank 0) | a call | 550 | The sprite writers: frames it ran in 550, writes to the sprite page 8,496 |
| $AA98 (bank 0) | a call | 296 | The palette writers: frames it ran in 276, writes 2,592 |
| $ACA3 (bank 0) | a call | 84 | The bank switch: writes 420, in the blank 165, while drawing 255 |
| $ACDF (bank 0) | a call | 33 | The bank switch: writes 165, in the blank 165, while drawing 0 |
| $FF00 (bank 1) | power-on | 33 | The bank switch: writes 66, in the blank 66, while drawing 0 The sprite writers: frames it ran in 889, writes to the sprite page 8,448 |
| $82D1 (bank 0) | a table | 31 | The bank switch: writes 62, in the blank 0, while drawing 62 |
| $83D7 (bank 0) | a table | 20 | The bank switch: writes 40, in the blank 0, while drawing 40 |
| $9808 (bank 0) | a call | 12 | The palette writers: frames it ran in 12, writes 96 |
| $AB8B (bank 0) | a call | 43,321 | |
| $804B (bank 0) | a call | 21,661 | |
| $9D51 (bank 0) | a call | 21,661 | |
| $AB5E (bank 0) | a call | 21,661 | |
| $AB9D (bank 0) | a call | 21,661 | |
| $E194 (bank 1) | a call | 21,642 | |
| $E19C (bank 1) | a call | 21,642 | |
| $E1AC (bank 1) | a call | 21,642 | |
| $E1B9 (bank 1) | a call | 21,642 | |
| $E583 (bank 1) | a call | 21,642 | |
| $AA2F (bank 0) | a call | 21,338 | |
| $E5D0 (bank 1) | a call | 7,397 | |
| $E766 (bank 1) | a call | 7,397 | |
| $8161 (bank 0) | a call | 3,989 | |
| $815D (bank 0) | a table | 3,873 | |
| $819B (bank 0) | a call | 3,873 | |
| $85DA (bank 0) | a table | 2,372 | |
| $E735 (bank 1) | a call | 1,976 | |
| $EA41 (bank 1) | a call | 1,391 | |
| $E072 (bank 1) | a call | 1,379 | |
| $E0B5 (bank 1) | a call | 1,256 | |
| $E481 (bank 1) | a table | 756 | |
| $84AE (bank 0) | a call | 706 | |
| $8174 (bank 0) | a table | 550 | |
| $8186 (bank 0) | a table | 550 | |
| $81B2 (bank 0) | a call | 550 | |
| $8776 (bank 0) | a call | 550 | |
| $87AE (bank 0) | a call | 550 | |
| $8884 (bank 0) | a table | 550 | |
| $9CBF (bank 0) | a table | 550 | |
| $9E16 (bank 0) | a table | 550 | |
| $A37F (bank 0) | a table | 550 | |
| $9874 (bank 0) | a call | 549 | |
| $9E27 (bank 0) | a table | 549 | |
| $81CF (bank 0) | a table | 530 | |
| $88AB (bank 0) | a call | 530 | |
| $8914 (bank 0) | a call | 530 | |
| $89AE (bank 0) | a call | 530 | |
| $9712 (bank 0) | a call | 440 | |
| $AA45 (bank 0) | a call | 323 | |
| $AB21 (bank 0) | a call | 296 | |
| $E3B3 (bank 1) | a table | 294 | |
| $E271 (bank 1) | a call | 201 | |
| $AA52 (bank 0) | a call | 161 | |
| $AA5F (bank 0) | a call | 161 | |
| $AA6B (bank 0) | a call | 161 | |
| $AA78 (bank 0) | a call | 161 | |
| $AA8A (bank 0) | a call | 161 | |
| $E253 (bank 1) | a call | 151 | |
| $E3DD (bank 1) | a table | 150 | |
| $E04B (bank 1) | a call | 137 | |
| $AA82 (bank 0) | a call | 132 | |
| $AC1C (bank 0) | a call | 132 | |
| $E9EB (bank 1) | a call | 126 | |
| $EA03 (bank 1) | a call | 126 | |
| $E003 (bank 1) | a call | 118 | |
| $948B (bank 0) | a call | 105 | |
| $E287 (bank 1) | a call | 64 | |
| $E473 (bank 1) | a table | 64 | |
| $9E07 (bank 0) | a call | 49 | |
| $E247 (bank 1) | a call | 49 | |
| $E3CA (bank 1) | a table | 49 | |
| $E6D7 (bank 1) | a call | 49 | |
| $E39C (bank 1) | a table | 46 | |
| $8200 (bank 0) | a table | 33 | |
| $A459 (bank 0) | a call | 33 | |
| $E006 (bank 1) | a call | 33 | |
| $E244 (bank 1) | a call | 33 | |
| $824F (bank 0) | a table | 32 | |
| $98EB (bank 0) | a call | 26 | |
| $9907 (bank 0) | a call | 26 | |
| $9FF2 (bank 0) | a call | 20 | |
| $E33B (bank 1) | a call | 20 | |
| $9969 (bank 0) | a call | 14 | |
| $85F0 (bank 0) | a table | 12 | |
| $86DC (bank 0) | a table | 12 | |
| $87DC (bank 0) | a call | 12 | |
| $E3D1 (bank 1) | a table | 10 | |
| $E417 (bank 1) | a call | 10 | |
| $9A6B (bank 0) | a table | 8 | |
| $E390 (bank 1) | a table | 8 | |
| $E637 (bank 1) | a call | 6 | |
| $9CAF (bank 0) | a call | 5 | |
| $988E (bank 0) | a table | 4 | |
| $9D17 (bank 0) | a call | 4 | |
| $99A2 (bank 0) | a table | 2 | |
| $9B03 (bank 0) | a table | 2 | |
| $9B58 (bank 0) | a table | 2 | |
| $A3F2 (bank 0) | a table | 2 | |
| $E384 (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 | what it is, and the evidence |
|---|---|
| $828D (bank 0) | The wait for the frame: waits on the byte at $00F5, times entered 32, turns 2,277, calls on each turn 1, writes of it under the frame interrupt 779,777, frames in all 21,813 |
| $A45B (bank 0) | The wait for the frame: waits on the byte at $00C3, times entered 33, turns 8,136, calls on each turn 1, writes of it under the frame interrupt 70,306, frames in all 21,813 |
| $AA37 (bank 0) | The wait for the frame: waits on the byte at $0033, times entered 21,338, turns 86,515,130, writes of it under the frame interrupt 21,661, frames in all 21,813 |
| $AA4D (bank 0) | The wait for the frame: waits on the byte at $0033, times entered 323, turns 1,223,757, writes of it under the frame interrupt 21,661, frames in all 21,813 |
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 |
|---|---|---|---|
| $8050 (bank 0) | 4 | 3 | $00BD |
| $8166 (bank 0) | 6 | 5 | $00C0 |
| $81A0 (bank 0) | 9 | 9 | $00A7 |
| $81B7 (bank 0) | 9 | 7 | $0068 |
The memory its routines share
392 bytes of memory were written by one routine and read by another, and 44 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 |
|---|---|---|---|
| $0700 | 80 | 2 | |
| $0200 | 32 | 10 | |
| $0040 | 32 | 2 | |
| $0060 | 32 | 2 | |
| $0000 | 25 | 2 | |
| $0001 | 24 | 1 | |
| $03EF | 16 | 1 | |
| $03F0 | 13 | 3 | |
| $03F1 | 13 | 1 | |
| $0690 | 10 | 1 | |
| $0680 | 9 | 3 | |
| $0730 | 9 | 3 |
The 24 busiest shared bytes
| byte | reads and writes | routines writing | routines reading |
|---|---|---|---|
| $0000 | 7,465,961 | 6 | 6 |
| $0001 | 7,461,993 | 6 | 6 |
| $00F5 | 1,407,825 | 4 | 6 |
| $00E0 | 96,007 | 6 | 6 |
| $00ED | 85,013 | 5 | 6 |
| $0017 | 68,784 | 2 | 4 |
| $06F1 | 65,129 | 6 | 3 |
| $06F5 | 65,041 | 3 | 3 |
| $06F0 | 64,992 | 2 | 3 |
| $06F2 | 64,992 | 2 | 3 |
| $06F3 | 64,992 | 2 | 3 |
| $00F7 | 53,642 | 2 | 5 |
| $00FF | 52,936 | 6 | 6 |
| $00B1 | 45,438 | 2 | 4 |
| $00FB | 43,388 | 1 | 2 |
| $0040 | 37,973 | 4 | 6 |
| $0060 | 36,336 | 3 | 3 |
| $00C0 | 30,615 | 5 | 6 |
| $06FD | 29,407 | 3 | 4 |
| $00BD | 22,406 | 6 | 3 |
| $06F9 | 22,295 | 6 | 6 |
| $06F8 | 22,136 | 2 | 4 |
| $06FA | 22,010 | 2 | 3 |
| $06FB | 22,010 | 2 | 3 |
This page shows none of the game's bytes. The listing these figures were read from stays with the cartridge.