Tetris (NES, Nintendo)/RAM map

From Data Crystal
Jump to navigation Jump to search

Chip tiny.png The following article is a RAM map for Tetris (NES, Nintendo).

0017-0018 16-bit random seed
0019 PieceID of last nextpiece generated by rng
001A number of pieces this poweron
0033 spun on in wait4vbl loop at AA37
0040 cur piece x
0041 cur piece y
0042 cur PieceID
0044 current speed level
0045 fall timer
0046 left/right autorepeat timer
0047 starting speed level
0048 Current game phase:
1 - active time
2 - start of spawn delay; update bg tilemap
3 - line clear check
4 - wait for line clear animation
5 - update score counter, etc.
6 - A-Type: dummy frame; B-Type: goal check
7 - normally a dummy frame -- contains logic for unfinished 2 player mode
8 - end of spawn delay; prepare next piece
0049 counter for bg tilemap update (used when 0048 == 2)
004A-004D line numbers being cleared
004E down autorepeat timer
004F down hold timer (cleared to 0 on release)
0050-0051 number of lines (BCD little endian)
0053-0055 score (little endian bcd)
0052 line clear animation counter (incremented when frame counter 00B1 % 4 == 0)
0056 number of lines being cleared
0057 line clear check counter (used when 0048 == 3)
0058 game over animation (negative: delay; $00: top; $14: finish)
0059 B-type height level
0060-007F mirror of 40-5F. If 00BE is forced to equal 2, this block is used for the unfinished 2 player mode.
00A8 copyright notice autoadvance time left
00AC same as 0042/0062 for collision?
00AD Playfield base address of current piece for collision?
00AE Y position of current piece in spritespace
00B1-00B2 demo time:

00B2 set to 0 when title screen appears; goes to demo at 00B5 = 5

00B5 Bits set for 1 frame when NES Controller buttons are initially pressed (ABsSUDLR)
00B6 NES Controller button states (ABsSUDLR)
00B8 Address of the playfield ($0400 for player 1, $0500 for player 2)
00BE Number of players. Always 1 by default, but forcing it to 2 enables unfinished 2 player Versus functionality.
00BF PieceID of next piece (valid ID: $02, $07, $08, $0A, $0B, $0E and $12)
00C1 game type (marathon = 0, 25lines = 1)
00C2 music type (sugarplum = 0, off = 3)
00C3 copyright notice unskippable time left
00F5 controller 1 newly pressed buttons
00F7 controller 1 state (0x80 = A pressed, 0x40 = B pressed...)
00FC vertical scroll (conjecture based on code at $80C5)
00FD horizontal scroll (conjecture based on code at $80C5)
00FE PPUMASK value
00FF PPUCTRL value
0200 Copy of OAM
03F0-03F1 number of T tetrominoes dealt (little endian BCD)
03F2-03F3 number of J tetrominoes dealt
03F4-03F5 number of Z tetrominoes dealt
03F6-03F7 number of O tetrominoes dealt
03F8-03F9 number of S tetrominoes dealt
03FA-03FB number of L tetrominoes dealt
03FC-03FD number of I tetrominoes dealt
0400-0409 Row $00 (top of playfield)
040A-0413 Row $01
04BE-04C7 Row $13 (bottom)
0680-06CF Music related
06D0-06FF Sound effects related
0700-075x high score tables
0718-071D B-type top name
071E-0723 B-type second name
0724-0729 B-type third name

PieceID

A PieceID is a number representing both a tetromino and an orientation. For instance, $11 is a I up and down, and $12 is an I across. Tetrominoes S, Z, and I have two PieceIDs; O has only one. The others have four. Because the PieceID table is "optimized" in this way, it'll take more extensive asm hacking to get Bombliss or Tetris DS rotation in.

The next piece is stored at $00BF. Poking a value into $00BF that's a valid PieceID but is not the starting orientation for that tetromino results in the next piece being drawn as a solid (not textured) O tetromino, but the next piece is dealt in the proper starting orientation.

Copy of OAM

At $0200 is a copy of OAM, the display list. Usually the falling piece occupies $0200-$020F, and the next piece occupies $0210-$021F.