Magic Pockets Tileset Format

From ModdingWiki
Jump to navigation Jump to search
Magic Pockets Tileset Format
There is no image of a tileset in this format — upload one!
Format typeTileset
HardwareEGA, VGA
Max tile count120
PaletteExternal
Tile names?No
Minimum tile size (pixels)32×16
Maximum tile size (pixels)32×16
Plane count4
Plane arrangementConsecutive complete planes within each tile
Transparent pixels?No
Hitmap pixels?No
Metadata?None
Supports sub-tilesets?No
Compressed tiles?Yes
Hidden data?No
Games

Background tiles in Magic Pockets are stored in blocks1.pak through blocks4.pak, one tileset for each world. Decompress the RNC method 1 wrapper first. These files share an extension with sprite banks, but have a different layout.

File format

Each decompressed file is 30720 bytes: 120 tiles of 256 bytes each. There is no header or palette. Each tile is 32×16 pixels with four consecutive 64-byte colour planes, and no mask plane.

Offset within tile Size Contents
0x00 64 Colour plane 0
0x40 64 Colour plane 1
0x80 64 Colour plane 2
0xC0 64 Colour plane 3

Rows within each plane contain four bytes. A byte's most significant bit is the leftmost pixel; plane k supplies bit k of the palette index. The byte for tile t, plane k, pixel (x, y) is:

offset = t * 256 + k * 64 + y * 4 + floor(x / 8)
bit number = 7 - (x % 8)

Tile numbering

Tiles in the bank are numbered 0-119. A cell value v in a PAP map selects tile v - 1, so the map's normal values are 1-120. Each world uses its matching blocksN.pak bank.

Palette

The palette is external, in the game's executable. Use the world palette and the VGA DAC conversion implemented by the palette decoder. The same world palette is used for the corresponding sprite banks.

Collision

No collision mask or hitmap is stored in a tileset or in a separate plane of a PAP map. The executable's ground table at GAMEU DS:F189 supplies tile classifications, interpreted by the ground-collision code. Changing only the artwork does not change a tile's collision behaviour.

Source code

From re-magicpockets, the open-source browser port and reverse-engineering project:

Credits

This file format was reverse engineered by VorticonCmdr. Please credit this work in projects that use it; a link back to this wiki is appreciated.