Legend of Zelda, The (USA) (Rev 1)

Legend of Zelda, The (USA) (Rev 1) is on a MMC1 board with 131,072 bytes of program. A crawl of 6,400 steps from power-on kept 110 paths that found new code. Played back over 289,730 frames, they executed 14,209 bytes of it, 11 percent.

What the rules named

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

atits name in the listingentered bytimeswhat it is, and the evidence
$FFAC (bank 7)b7_bank_FFACa call560,164
The bank switch: writes 2,800,806, in the blank 583,600, while drawing 2,217,206
$E5E2 (bank 7)b7_engine_E5E2a call305,104
The jump engine: tables 20, jumps through them 305,104
$A0F6 (bank 6)b6_drain_A0F6a call112,849
The palette writers: frames it ran in 112,849, writes 39,580
The picture writer: frames it ran in 112,849, writes 649,576, in the blank 498,236, while drawing 151,340
$E484 (bank 7)b7_nmieach frame (NMI)112,849
The game inside the interrupt: frames it ran in 113,961, frames in all 119,210, the spin is at $E45B
The random byte: frames it ran in 113,961, bytes $0018,$0019,$001A, rotates 3, exclusive-ors 2
The scroll writer: frames it ran in 113,961, writes in the blank 379,599
$9C67 (bank 0)b0_sound_9C67a call112,720
The sound driver: frames it ran in 112,720, writes 610,770
$E62D (bank 7)b7_poll_E62Da call110,688
The poll: port $4017, reads a frame 17, strobes a frame 6
$E640 (bank 7)b7_poll_E640a call110,688
The poll: port $4016, reads a frame 17, strobes a frame 4
$E70E (bank 7)b7_sprites_E70Ea call86,774
The sprite writers: frames it ran in 14,219, writes to the sprite page 421,468
$98F5 (bank 2)b2_sprites_98F5a call81,528
The sprite writers: frames it ran in 27,176, writes to the sprite page 1,304,448
$8094 (bank 4)b4_compare_8094a call30,679
Where two things are compared: instructions 4, pairs of bytes 10, bytes in all 11, times compared 1,335, X positions at $0070,$0071,$0072,$0073,$0074,$0525, Y positions at $0084,$0085,$0086,$0087,$0088,$0525
$9943 (bank 2)b2_sprites_9943a call27,176
The sprite writers: frames it ran in 27,176, writes to the sprite page 434,816
$F23C (bank 7)b7_sprites_F23Ca call19,874
The sprite writers: frames it ran in 19,874, writes to the sprite page 687
$986B (bank 2)b2_sprites_986Ba call18,784
The sprite writers: frames it ran in 18,784, writes to the sprite page 2,103,808
$E5F7 (bank 7)b7_sprites_E5F7a call18,067
The sprite writers: frames it ran in 18,067, writes to the sprite page 1,156,288
$88F8 (bank 4)b4_dispatch_88F8a table15,692
Where two things are compared: instructions 1, pairs of bytes 4, bytes in all 5, times compared 70, X positions at $0070,$0071,$0072,$0073,$0074
$9EF0 (bank 2)b2_dispatch_9EF0a table13,114
The sprite writers: frames it ran in 13,181, writes to the sprite page 11,688
$A1C3 (bank 2)b2_sprites_A1C3a call13,047
The sprite writers: frames it ran in 13,047, writes to the sprite page 24,735
$A1DD (bank 2)b2_sprites_A1DDa call13,047
The sprite writers: frames it ran in 13,047, writes to the sprite page 24,735
$A204 (bank 2)b2_sprites_A204a call13,047
The sprite writers: frames it ran in 13,047, writes to the sprite page 615
$A59A (bank 2)b2_dispatch_A59Aa table8,668
The sprite writers: frames it ran in 8,668, writes to the sprite page 34,084
$F9C9 (bank 7)b7_sprites_F9C9a call7,099
The sprite writers: frames it ran in 2,353, writes to the sprite page 56,792
$97D8 (bank 2)b2_sprites_97D8a call4,682
The sprite writers: frames it ran in 4,682, writes to the sprite page 18,728
$97EA (bank 2)b2_sprites_97EAa call3,130
The sprite writers: frames it ran in 913, writes to the sprite page 64,432
$8521 (bank 5)b5_split_8521a call2,136
The split: frames it ran in 2,182, scroll writes while drawing 1,496, status reads while drawing 1,307,588
$841E (bank 5)b5_sprites_841Ea call2,115
The sprite writers: frames it ran in 2,115, writes to the sprite page 83
$BF98 (bank 5)b5_bank_BF98a call2,078
The bank switch: writes 10,390, in the blank 0, while drawing 10,390
$82D7 (bank 4)b4_dispatch_82D7a table2,015
The sprite writers: frames it ran in 1,590, writes to the sprite page 7,496
$81DD (bank 5)b5_compare_81DDa call1,923
Where two things are compared: instructions 1, pairs of bytes 1, bytes in all 2, times compared 240, X positions at $0000,$0070
$BFAC (bank 2)b2_bank_BFACa call1,039
The bank switch: writes 5,195, in the blank 0, while drawing 5,195
$BFAC (bank 5)b5_bank_BFACa call1,039
The bank switch: writes 5,195, in the blank 0, while drawing 5,195
$80D4 (bank 5)b5_dispatch_80D4a table514
The sprite writers: frames it ran in 514, writes to the sprite page 4
$B726 (bank 5)b5_sprites_B726a call514
The sprite writers: frames it ran in 514, writes to the sprite page 4,112
$8CE4 (bank 5)b5_dispatch_8CE4a table494
The sprite writers: frames it ran in 494, writes to the sprite page 202
$F238 (bank 7)b7_sprites_F238a call489
The sprite writers: frames it ran in 299, writes to the sprite page 39
$8130 (bank 5)b5_sprites_8130a call445
The sprite writers: frames it ran in 445, writes to the sprite page 445
$8A04 (bank 5)b5_compare_8A04a call415
Where two things are compared: instructions 2, pairs of bytes 8, bytes in all 9, times compared 219, X positions at $0070,$0071,$0072,$0073,$0074,$0525, Y positions at $0084,$0087,$0088,$0525
$FF98 (bank 7)b7_bank_FF98a call251
The bank switch: writes 1,255, in the blank 550, while drawing 705
$8D17 (bank 5)b5_dispatch_8D17a table228
The sprite writers: frames it ran in 228, writes to the sprite page 732
$B31A (bank 4)b4_compare_B31Aa call221
Where two things are compared: instructions 2, pairs of bytes 8, bytes in all 10, times compared 442, X positions at $0070,$0071,$0072,$0073,$0074, Y positions at $0084,$0085,$0086,$0087,$0088
$8755 (bank 4)b4_dispatch_8755a table110
Where two things are compared: instructions 3, pairs of bytes 10, bytes in all 11, times compared 232, X positions at $0070,$0071,$0072,$0073,$0074,$0525, Y positions at $0084,$0085,$0086,$0087,$0088,$0525
$EB76 (bank 7)b7_dispatch_EB76a table110
The sprite writers: frames it ran in 110, writes to the sprite page 104
$FF50 (bank 7)b7_resetpower-on110
The bank switch: writes 990, in the blank 990, while drawing 0
$A18E (bank 2)b2_sprites_A18Ea call81
The sprite writers: frames it ran in 81, writes to the sprite page 1,132
$810F (bank 5)b5_dispatch_810Fa table77
The sprite writers: frames it ran in 77, writes to the sprite page 1
$83B2 (bank 5)b5_sprites_83B2a call46
The sprite writers: frames it ran in 46, writes to the sprite page 184
$A351 (bank 2)a call599,865
$FE98 (bank 7)a call234,162
$A42B (bank 2)a call222,285
$B821 (bank 5)a call198,420
$9C50 (bank 0)a call194,500
$FA93 (bank 7)a call169,766
$9F7C (bank 0)a call160,529
$A080 (bank 6)a call112,849
$9825 (bank 0)a call112,739
$98CC (bank 0)a call112,739
$99A0 (bank 0)a call112,720
$9AD3 (bank 0)a call112,720
$9B83 (bank 0)a call112,720
$F0AC (bank 7)a call108,177
$EB30 (bank 7)a call108,127
$FB74 (bank 7)a call70,970
$9020 (bank 2)a table56,456
$90CF (bank 2)a call56,148
$903B (bank 2)a table56,129
$EFD0 (bank 7)a call50,213
$F0E3 (bank 7)a call49,990
$F92A (bank 7)a call38,980
$87D3 (bank 4)a call30,679
$8BFF (bank 4)a table30,679
$98C3 (bank 2)a call27,176
$A1F7 (bank 2)a call23,376
$FA3C (bank 7)a call22,966
$EC1B (bank 7)a table20,555
$B1E6 (bank 5)a call20,548
$B7C8 (bank 5)a call19,835
$B3F4 (bank 5)a call19,694
$E78A (bank 7)a call19,541
$8D96 (bank 5)a call19,534
$8DCF (bank 5)a call19,534
$B29A (bank 5)a call19,534
$E6EA (bank 7)a call19,534
$E7FE (bank 7)a call19,534
$EDA0 (bank 7)a call19,534
$86E0 (bank 4)a call19,490
$F36F (bank 7)a call19,490
$F4A0 (bank 7)a call19,490
$F73E (bank 7)a call19,490
$F769 (bank 7)a call19,490
$8F85 (bank 5)a call19,311
$A13E (bank 1)a call19,311
$AABF (bank 5)a call19,008
$AAF1 (bank 5)a call19,008
$95AC (bank 2)a table18,806
$979D (bank 2)a call17,129
$960C (bank 2)a table16,781
$972A (bank 2)a call16,781
$EDF4 (bank 7)a call13,808
$8F5A (bank 4)a call13,724
$8EEB (bank 4)a table13,252
$A011 (bank 2)a call11,756
$A591 (bank 2)a table8,815
$9B79 (bank 2)a table8,392
$95C1 (bank 2)a table7,970
$9C09 (bank 0)a call7,594
$9F72 (bank 0)a call7,499
$EDFA (bank 7)a call7,218
$FA0C (bank 7)a call7,099
$9EE2 (bank 0)a call6,948
$8A03 (bank 4)a call6,195
$8A11 (bank 4)a call6,195
$B2CD (bank 4)a call5,974
$8A21 (bank 4)a call5,925
$FA89 (bank 7)a call5,393
$9BFF (bank 0)a call5,283
$9C27 (bank 0)a call5,078
$9C3B (bank 0)a call4,967
$EBAA (bank 7)a table4,934
$E8F8 (bank 7)a call4,612
$E625 (bank 7)a call4,254
$9EDC (bank 0)a call4,195
$9C1D (bank 0)a call3,893
$95EC (bank 2)a table3,849
$8424 (bank 5)a call2,115
$EB62 (bank 7)a table2,115
$A8DE (bank 5)a call2,078
$84A4 (bank 5)a table1,923
$8506 (bank 5)a call1,923
$EB86 (bank 7)a table1,808
$FAA0 (bank 7)a call1,487
$8371 (bank 4)a call1,445
$F08D (bank 7)a call1,445
$A307 (bank 2)a call1,379
$FAAE (bank 7)a call1,143
$B3A9 (bank 5)a call1,132
$82A8 (bank 5)a call1,122
$E9A1 (bank 7)a table1,122
$EEE4 (bank 7)a call1,122
$E96F (bank 7)a table1,078
$A924 (bank 5)a call1,070
$96DD (bank 2)a call1,041
$973A (bank 2)a call1,041
$B559 (bank 5)a call1,021
$8006 (bank 5)a call994
$9D2A (bank 2)a call955
$831F (bank 5)a table916
$E94B (bank 7)a table602
$E9D8 (bank 7)a table594
$A35D (bank 2)a call589
$E47D (bank 7)a call543
$E580 (bank 7)a call543
$B5EB (bank 5)a call514
$B5EF (bank 5)a call514
$B6A7 (bank 5)a call514
$A3E1 (bank 2)a call511
$8F0E (bank 4)a table472
$9FDE (bank 2)a call472
$8D6D (bank 5)a table463
$A4C4 (bank 2)a table462
$E46D (bank 7)a call433
$F1A0 (bank 7)a call406
$E9C3 (bank 7)a table405
$A223 (bank 1)a call397
$F149 (bank 7)a call397
$8070 (bank 5)a table361
$B282 (bank 5)a call361
$E6CE (bank 7)a call355
$804F (bank 2)a call327
$B000 (bank 4)a call325
$F855 (bank 7)a call318
$F1AF (bank 7)a table309
$A2A0 (bank 2)a table308
$E679 (bank 7)a call306
$B0E1 (bank 5)a call301
$8929 (bank 5)a call299
$9830 (bank 2)a table293
$EA3D (bank 7)a call292
$8A4D (bank 4)a call270
$B39F (bank 4)a call270
$B83A (bank 5)a call248
$A437 (bank 2)a call243
$80D7 (bank 6)a call241
$8A2F (bank 5)a table238
$8D60 (bank 5)a table235
$8D84 (bank 1)a call218
$E608 (bank 7)a call212
$EBA1 (bank 7)a call210
$AC07 (bank 5)a call205
$B05E (bank 5)a call204
$8D05 (bank 5)a table186
$877B (bank 5)a table178
$8D00 (bank 1)a call176
$8CB6 (bank 5)a table154
$905D (bank 2)a table154
$A47F (bank 2)a table154
$A4BD (bank 2)a table154
$A51E (bank 2)a table154
$AC10 (bank 5)a call154
$AC16 (bank 5)a call154
$8015 (bank 4)a table150
$8832 (bank 4)a call150
$B179 (bank 4)a call150
$FEB3 (bank 7)a call150
$FEBB (bank 7)a call150
$A5DF (bank 2)a table147
$EA51 (bank 7)a call147
$EBC0 (bank 7)a table146
$83D7 (bank 5)a call136
$A3C8 (bank 2)a call134
$A764 (bank 2)a call134
$8091 (bank 3)a call132
$80DC (bank 3)a call132
$E977 (bank 7)a table131
$94E7 (bank 2)a table128
$B68D (bank 5)a call115
$808C (bank 6)a call110
$80C6 (bank 6)a call110
$9512 (bank 2)a table110
$9545 (bank 2)a table110
$B4AC (bank 5)a call110
$B4E8 (bank 5)a call110
$E45E (bank 7)a call110
$A8C4 (bank 5)a call108
$A9F4 (bank 5)a call108
$AB30 (bank 5)a call108
$8941 (bank 5)a call102
$896E (bank 5)a call102
$90B8 (bank 5)a call102
$B0B6 (bank 5)a call102
$B366 (bank 5)a call102
$EA6B (bank 7)a table102
$EAD3 (bank 7)a call102
$EDD7 (bank 7)a call102
$833D (bank 5)a table79
$8044 (bank 3)a call66
$8047 (bank 6)a table66
$805E (bank 3)a call66
$80A4 (bank 6)a call66
$8484 (bank 5)a call66
$B000 (bank 5)a table66
$B009 (bank 5)a table66
$B010 (bank 5)a table66
$B016 (bank 5)a table66
$B01D (bank 5)a table66
$B02A (bank 5)a table66
$B036 (bank 5)a table66
$E9F7 (bank 7)a table66
$EA00 (bank 7)a call66
$EA11 (bank 7)a table66
$8070 (bank 6)a table65
$80B5 (bank 6)a call65
$8109 (bank 6)a call65
$EB96 (bank 7)a table65
$F1C3 (bank 7)a table63
$983C (bank 2)a table57
$A0F0 (bank 2)a call53
$848C (bank 5)a call51
$E85A (bank 7)a call51
$82BB (bank 5)a table44
$830E (bank 5)a table44
$83C2 (bank 5)a call44
$B07A (bank 5)a table44
$B464 (bank 5)a call44
$B522 (bank 5)a table44
$E68F (bank 7)a call44
$EADD (bank 7)a call44
$835C (bank 5)a table39
$8439 (bank 5)a table39
$8492 (bank 5)a table39
$84BA (bank 5)a table38
$84DF (bank 5)a table38
$B560 (bank 5)a call38
$82FB (bank 5)a call35
$F1D0 (bank 7)a call32
$873F (bank 4)a table28
$847E (bank 5)a table26
$8A13 (bank 5)a call19
$902E (bank 5)a call19
$9573 (bank 2)a table18
$959A (bank 2)a table18
$84E8 (bank 5)a table12
$EBA3 (bank 7)a call12
$9FC5 (bank 2)a table9
$8600 (bank 5)a table8
$8038 (bank 5)a table7
$8057 (bank 5)a table7
$805E (bank 5)a table7
$8062 (bank 5)a table7
$806C (bank 5)a table7
$819A (bank 5)a table7
$8CA6 (bank 5)a table7
$8CAB (bank 5)a table7
$8CC8 (bank 5)a table7
$8CCD (bank 5)a table7
$8CD2 (bank 5)a table7
$8CDB (bank 5)a table7
$9D42 (bank 0)a call7
$8D0B (bank 5)a table6
$8283 (bank 5)a call4
$EA2B (bank 7)a call4
$A017 (bank 2)a call2
$F1DA (bank 7)a table2
$8E0A (bank 5)a call1
$8E26 (bank 5)a call1
$8E42 (bank 5)a table1

Where it waits

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

atits name in the listingwhat it is, and the evidence
$E45B (bank 7)b7_spin_E45B
The idle spin: turns 837,334,170, turns a frame 7,024

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.

atreachedentriestakenchosen by the byte at
$900E (bank 2)after a call33$042D
$901A (bank 2)after a call33$042D
$9035 (bank 2)after a call33$0013
$90DA (bank 2)after a call22$042D
$90E4 (bank 2)after a call55$042D
$A292 (bank 2)after a call75$0013
$A596 (bank 2)after a call22$0013
$8024 (bank 5)after a call109$00E1
$82AD (bank 5)after a call65$0013
$8429 (bank 5)after a call77$0013
$8C8C (bank 5)after a call1313$0013
$8E30 (bank 5)after a call11$0656
$8043 (bank 6)after a call22$0013
$E923 (bank 7)after a call411$0012, $0016
$E9E5 (bank 7)after a call29$0013
$F1A7 (bank 7)after a call44$0395, $0396, $0398, $0397

The memory its routines share

1,373 bytes of memory were written by one routine and read by another, and 64 places were reached through an index, which is what a table or a set of object slots in memory looks like.

004080C0$0000$0100$0200$0300$0400$0500$0600$070011↓1X1Y111↓1
The console's 2,048 bytes of memory, one row for each 256. A numbered span is a column of one of the object tables drawn below, counted in the same order, as long as the table and filled as it is there. Where a table's columns overlap, its things lie one after another, each with all its properties, so the table is one outline with a mark where each property starts. A dark square is a position a rule saw compared. A tick under a row is one of the 24 busiest shared bytes. 1 of those are in memory on the cartridge and are not on this map. The second row is the page the processor keeps its stack in. Reaches through an index that belong to no table are not drawn: the loops that clear memory reach nearly every byte.

Reaches through an index: those that hold positions, then the longest

frombytes reachedinstructionspositions it holds
$000024071 across
$007011261 across
$008411265 down
$0071814 across
$02012536
$02002535
$02022533
$02032533
$05601281
$01FF1131
$03025212
$0530485

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, which pick the way through a jump table, which is what a state or a kind does, and which are only ever counted down, which is what a timer does. What the rest hold is not named yet.

012345678910$0019$0028↓+1$0070X$0084Y$0098+1$00AC+8$00C0↓+3$049E
Table 1: 8 arrays of up to 11 slots that 22 routines step through together. Each column is an array at its address and each row a slot, so one thing on the screen is one row across all of them. A number under a column is how many more bytes that array was reached across than the table is long. X and Y are positions, and the darker squares are the slots a rule saw compared. + is added into a position, which is what a speed does. → chose a jump, which is what a state or a kind does. ↓ is only ever counted down, which is what a timer does. A plain outline travels with them and is not named yet.
slotsarraysroutinespositions acrosspositions downadded into themchoosing a jumpcounted downtravelling with them
11822$0070$0084$0028, $00C0$0019, $0028, $0098, $00AC, $00C0, $049E

The 24 busiest shared bytes

bytereads and writesroutines writingroutines reading
$000033,376,88466
$000114,727,91666
$00F811,975,69846
$000210,458,69766
$00037,383,72666
$000E2,145,53366
$00042,139,12466
$000F1,916,70866
$00051,241,79166
$00841,001,84566
$0007998,72766
$0340873,83734
$000A842,25866
$00C1826,18156
$6E2C801,24923
$000B745,28466
$0070713,17066
$00FA700,77814
$0341663,34646
$0006636,85466
$000D628,58666
$0015558,21426
$00C2554,48966
$00AC550,01266

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

All the games