Tetris (NES):ROM map

From Data Crystal
Jump to: navigation, search

All addresses are in CPU address space, not iNES file space. Subtract $7FF0 for addresses within the iNES file, or use a more sophisticated algorithm for addresses within the UNIF file.

; Code:

reset           = $FF00
main            = $8000
soundWaitVBL    = $AA45  ; Run sound code and wait for vblank NMI
turnOnNMI       = $AA6B  ; Turn on interrupt at scanline 241
turnOffNMI      = $AA78  ; Turn off interrupt at scanline 241
clearNametable  = $AA82  ; Clear nametable whose base address is A
clearVRAM       = $AC1C  ; If A < $1F, clear Y pages of VRAM to X
                         ; Otherwise, clear 4 pages of VRAM to X and clear attribute table to Y
clearRAM        = $AC6A  ; Clear pages X to Y of CPU RAM to value in A
switch          = $AC82  ; Jumps to the Ath 16-bit address in the following jump table,
                         ; similar to the "magic jump" in Super Mario Bros.
playSound       = $E000  ; Appears to be sound code, called every frame
spawn           = $988E  ; Spawn the next piece

; Data:
rotationTable   = $88EE  ; Actually 2 tables interlaced: evens for CCW and odds for CW rotation.
                         ; Determines the next piece+orientation value based off the current value.
tetriminoTable  = $8A9C  ; Each piece is encoded as a sequence of 12 bytes that can be broken down
                         ; into triplets (Y, tile, X) describing each square within the piece. Hex
                         ; coordinate values above $7F represent negative integers ($FF = −1 and $FE = −2).
garbageLines    = $9B53  ; In the nonfinished 2 player vs mode, this is the number of lines to add to the opponent player
                         ; 00 00 01 02 04 
spawnTable1     = $993B  ; 00 00 00 00 01 01 01 01 02 02 03 04 04 05 05 05 05 06 06
                         ; Maps index into tetriminoTable to Tetrimino type. 
spawnTable2     = $994E  ; 02 07 08 0A 0B 0E 12; offsets into tetriminoTable for spawning each Tetrimino type
spawnTable3     = $9956  ; 02 02 02 02 07 07 07 07 08 08 0A 0B 0B 0E 0E 0E 0E 12 12
                         ; Maps index into tetriminoTable to the spawn orientation.
scoreIncTable   = $9CA5  ; 40 00 00 01 00 03 00 12 (1 = 40, 2 = 100, 3 = 300, 4 = 1200); read by 9C3B: LDA $9CA5,X
columnClears    = $97FE  ; Sequence used during the clear animation: 04 03 02 01 00, 05 06 07 08 09
levelNumTable   = $96B8  ; 00 01 02 03 ... 26 27 28 29; the code erroneously reads past this table for level 30+
LevelSpeedTable = $898E  ; 30 2B 26 21 ... 02 01 01 01; Level speeds. Number of frames before a piece drops for each successive level.
initHiScores    = $AD67  ; High score table, copied to $0700 on boot


Internal Data for Tetris (NES)

ROM MapRAM MapText TableNotesTutorials