-
Notifications
You must be signed in to change notification settings - Fork 20
Level Data Format
The object data pointer contains the following (each section detailed below):
Header (10 bytes)
Object Data (4-5 bytes per object)
$FF
Screen Exit Data (5 bytes per exit)
$FF
Sprite data has a separate pointer which contains 3-byte entries and ends with $FFFF.
The level header contains information that is used to set up the level's graphics, music, items, and scrolling. It uses a bitpacked format that can be summarized as follows:
ccccc111 1ppppp22 222ppppp p333333p pppppsss sssspppp dddddaaa aaappppp rrrrrmmm miiuuuuu
c = background color
1 2 3 = BG# tileset
p = palette (for preceding tileset)
s = sprite tileset
d = level mode
a = animation tileset
r = BG scroll rate
m = music
i = item memory
u = unused
Type | Packed Length (bits) | RAM Address Destination |
---|---|---|
BG Color | 5 | $7E0134 |
BG 1 Tileset | 4 | $7E0136 |
BG 1 Palette | 5 | $7E0138 |
BG 2 Tileset | 5 | $7E013A |
BG 2 Palette | 6 | $7E013C |
BG 3 Tileset | 6 | $7E013E |
BG 3 Palette | 6 | $7E0140 |
Sprite Tileset | 7 | $7E0142 |
Sprite Palette | 4 | $7E0144 |
Level Mode | 5 | $7E0146 |
Animation Tileset | 6 | $7E0148 |
Animation Palette | 5 | $7E014A |
BG Scrolling Rate | 5 | $7E014C |
Music | 4 | $7E014E |
Item Memory | 2 | $7E0150 |
Unused | 5 | $7E0152 |
Objects can be 3 types: 4-byte, 4-byte extended, or 5-byte. The first byte of the object governs which type it shall be. $00 indicates extended, otherwise the first byte is the ID which governs whether to read in just length or width & height (4 vs. 5). The $1284EC table is what governs 4 vs. 5; the ID is used to index into it, and if the first 2 bits of the byte that's retrieved from the table are equal to 00 or 01 (binary), then it is 4-byte; otherwise, 5.
5-Byte Objects:
IIIIIIII ID (can't be 00/FF)
XXXXYYYY High X and High Y
xxxxyyyy Low X and Low Y
WWWWWWWW Width - 1, signed
HHHHHHHH Height - 1, signed
4-Byte Objects:
IIIIIIII ID (can't be 00/FF)
XXXXYYYY High X and High Y
xxxxyyyy Low X and Low Y
LLLLLLLL Length - 1, signed
4-Byte Extended Objects
00000000
XXXXYYYY High X and High Y
xxxxyyyy Low X and Low Y
IIIIIIII ID
Screen exits may be two types; each are 5 bytes.
Level warp:
TTTTTTTT Target page (between 00 and 7F)
LLLLLLLL Destination Level (between 00 and DD)
XXXXXXXX Destination X-Coordinate
YYYYYYYY Destination Y-Coordinate
EEEEEEEE Destination Entrance Type (between 00 and 0A)
Minibattle:
TTTTTTTT Target page (between 00 and 7F)
MMMMMMMM Destination Minibattle (between DE and E9)
XXXXXXXX Return X-Coordinate
YYYYYYYY Return Y-Coordinate
LLLLLLLL Return Level (between 00 and E9)
iiiiiiii Low ID
YYYYYYYI High ID and Y Tile Coordinate
XXXXXXXX X Tile Coordinate