Tetris (Game Boy)/ROM map

From Data Crystal
Jump to navigation Jump to search

Chip tiny.png The following article is a ROM map for Tetris (Game Boy).

Generate next Tetromino

ROM0:2062 21 00 C2         ld   hl,C200
ROM0:2065 36 00            ld   (hl),00              ;wC200 = 0x00
ROM0:2067 2C               inc  l
ROM0:2068 36 18            ld   (hl),18              ;wC201 = 0x18
ROM0:206A 2C               inc  l
ROM0:206B 36 3F            ld   (hl),3F              ;wC202 = 0x3F
ROM0:206D 2C               inc  l
ROM0:206E FA 13 C2         ld   a,(C213)             ;load next Tetromino in accumulator
ROM0:2071 77               ld   (hl),a               ;wC203 = Tetromino
ROM0:2072 E6 FC            and  a,FC                 ;Tetromino & 252
ROM0:2074 4F               ld   c,a
ROM0:2075 F0 E4            ld   a,(ff00+E4)
ROM0:2077 A7               and  a
ROM0:2078 20 05            jr   nz,207F
ROM0:207A F0 C5            ld   a,(ff00+C5)
ROM0:207C A7               and  a
ROM0:207D 28 1D            jr   z,209C
ROM0:207F 26 C3            ld   h,C3
ROM0:2081 F0 B0            ld   a,(ff00+B0)
ROM0:2083 6F               ld   l,a
ROM0:2084 5E               ld   e,(hl)
ROM0:2085 23               inc  hl
ROM0:2086 7C               ld   a,h
ROM0:2087 FE C4            cp   a,C4
ROM0:2089 20 03            jr   nz,208E
ROM0:208B 21 00 C3         ld   hl,C300
ROM0:208E 7D               ld   a,l
ROM0:208F E0 B0            ld   (ff00+B0),a
ROM0:2091 F0 D3            ld   a,(ff00+D3)
ROM0:2093 A7               and  a
ROM0:2094 28 2A            jr   z,20C0
ROM0:2096 F6 80            or   a,80
ROM0:2098 E0 D3            ld   (ff00+D3),a
ROM0:209A 18 24            jr   20C0
ROM0:209C 26 03            ld   h,03
ROM0:209E F0 04            ld   a,(ff00+04)
ROM0:20A0 47               ld   b,a
ROM0:20A1 AF               xor  a
ROM0:20A2 05               dec  b
ROM0:20A3 28 0A            jr   z,20AF
ROM0:20A5 3C               inc  a
ROM0:20A6 3C               inc  a
ROM0:20A7 3C               inc  a
ROM0:20A8 3C               inc  a
ROM0:20A9 FE 1C            cp   a,1C
ROM0:20AB 28 F4            jr   z,20A1
ROM0:20AD 18 F3            jr   20A2
ROM0:20AF 57               ld   d,a
ROM0:20B0 F0 AE            ld   a,(ff00+AE)
ROM0:20B2 5F               ld   e,a
ROM0:20B3 25               dec  h
ROM0:20B4 28 07            jr   z,20BD
ROM0:20B6 B2               or   d
ROM0:20B7 B1               or   c
ROM0:20B8 E6 FC            and  a,FC
ROM0:20BA B9               cp   c
ROM0:20BB 28 E1            jr   z,209E
ROM0:20BD 7A               ld   a,d
ROM0:20BE E0 AE            ld   (ff00+AE),a
ROM0:20C0 7B               ld   a,e
ROM0:20C1 EA 13 C2         ld   (C213),a             ;write next Tetromino to wC213
ROM0:20C4 CD EA 26         call 26EA
ROM0:20C7 F0 9A            ld   a,(ff00+9A)
ROM0:20C9 E0 99            ld   (ff00+99),a
ROM0:20CB C9               ret