President's architecture is heavily inspired by that of Super Mario Bros. (SMB1).
Like SMB1:
Unlike SMB1:
To decode column x of screen s
Each screen's map data has a 32-entry table giving the length in bytes of each screen's map data. When the decoder seeks to the previous or next screen, it follows the chain of lengths when modifying curMapPageDataStart.
A cloud pattern has
Format of each column entry:
7654 3210 |||| |||| |||| ++++- Pattern number ++++------ Height at which pattern is drawn
A "wall" is a horizontal strip of identical tiles placed behind empty metatiles. This can represent water, a long castle wall, etc. It is defined as a 1x12, 2x12, 4x12, or 8x12 tile repeating block.
Most scenery in a level that the player can interact with is stored in a list of objects. Each level has a list of the lengths in bytes of each screen's data, consisting of the objects whose leftmost tile lies within that page.
7654 3210 Background object: first byte |||| |||| |||| ++++- Vertical position of object (0 to 11) ++++------ Horizontal position of object (0 to 15) 7654 3210 Background object: second byte |||| |||| |||| ||++- Argument; some uses this as a size argument (1, 2, 4, or 8 tiles) ++++-++--- Index into table of decoder procedures
The decoder for a background object is called with (x - o.x, y, obj), and it is responsible for overwriting metatiles in the column buffer.
A background object can never be wider than 16 tiles, because then it could sit across more than the two screens that the decoder considers.
There are two 192-byte buffers, each holding 16x12 bytes, where each byte controls what metatile is placed there. This is used for redrawing and collision. Columns of even screens go in buffer 0; columns of odd screens go in buffer 1.
Between the two buffers of the sliding window is a destruction buffer organized as a 512-bit array. When a block is destroyed, the corresponding bit turns on.
The map decoder has a set of four 64-entry tables, one for each subspace, defining which tiles become which when destroyed. For example, if table[0][$19] = $8B, then all tiles of attribute 0 and value $19 become attribute 2 and value $0B in a destroyed column. This happens before Markov.
Each subspace has a table of up to 64 entries from each tile to the most common tile below it. For example, if table[0][$23] = $64, then the most common tile below a tile of attribute 0 and value $23 is attribute 1 and value $24. Empty metatiles are replaced with the most common tile below the tile above them.
The top 2 bits of a metatile number are the subspace number, and each subspace is hardcoded to one of the four color sets. Each subspace has a set of four lookup tables of up to 64 entries, each entry being 4 bytes, from each tile to the top left, bottom left, top right, and bottom right nametable entries making up a metatile. Which table is used depends on the metatile's attribute number.
To be written.
Categories: President (video game)