TAP

From OHRRPGCE-Wiki
Jump to navigation Jump to search

Tile Animation Patterns come in binsized (since ichorescent) records currently 157 INTs (314 bytes) long. There is no header and there are two per tileset (the binsize is the size of a single pattern). Records 2*n and 2*n+1 are the animation patterns for tileset n.

Each pattern can contain up to 50 animation operators ("ops"), each of which has an opcode and up to two arguments. The animation loops through the pattern until a 'Wait' is encountered (breaking out of infinite loops harmlessly), wrapping around to Op 0 when an 'End of Animation', 'Loop' or failed 'Check Tag' op is executed, or after Op 49. Looping back to the beginning doesn't cause a wait.

Before ichorescent, the records were 20 INTs (40 bytes), containing 9 ops with a single parameter each, with opcodes up to 6.

Each pattern defines a range of animated tiles (pattern 0 is tiles 160-207 in the tileset, pattern 1 is tiles 208-255). The range has a Range Start, Length (always 48), and Stride (always 1), which defines the initial tile for each of the animated tiles.

In future the Tileset, Range Length and Range Stride fields are intended for supporting a variable number of animation patterns per tileset, in the same way as menu item records (breaking the current correspondence between tileset numbers and TAP record numbers), and maybe sharing of patterns between tilesets, without having to replace .TAP. For now, these three fields are saved but ignored, and reset to the fixed values when loaded and resaved by the editor.

Formal Specs[edit]

If the fixExtendedTileAnims bit in FIXBITS.BIN is off, then the following upgrades are needed: initialise Op 9 opcode to 'Loop' (which will only be used if none of Ops 0-8 are 'End of Animation'), Range Length to 48 and Range Stride to 1.

About Formal Specs

Offset Data Meaning
0 INT range start (tileset tile number of the pattern's range
1 INT disable if tag (0 = n/a, -n = tag n is off, +n = tag n is on)
2-10 INT(9) opcode for ops 0-8
11-19 INT(9) parameter 1 for ops 0-8
20-28 INT(9) parameter 2 for ops 0-8
29 INT tileset number (currently always n for TAP records 2*n and 2*n+1)
30 INT range length (currently always 48)
31 INT range stride (currently always 1)
32-33 INT(2) reserved
34-156 ANIMOP(41) 41 animation op structures for ops 9-49 (see below)
ANIMOP (3 INTs)
Offset Data Meaning
+0 INT opcode
+1 INT parameter 1
+2 INT parameter 2

Explanation of the animation opcodes[edit]

All tile numbers are calculated modulo 160, meaning they wrap around the top and bottom of the tileset, but going over the left/right edge goes to the previous/next row of tiles.

Type Explanation
0 End of Animation: go back to Op 0 and reset tile offset. Does not reset the draw offset!
1 Move Up <arg> number of tiles, wrapping around before the last tile
2 Move Down <arg> number of tiles, wrapping around after the last tile
3 Move Right <arg> number of tiles
4 Move Left <arg> number of tiles
5 Wait for <arg> amount of ticks
6 Check Tag, continue only if tag <arg> (0 = n/a, -n = tag n is off, +n = tag n is on)
else, performs an End of Animation
7 Reset to the initial tile. Does not reset the draw offset!
8 Loop back to Op 0, without resetting anything
9 Shift Tile: Set the display offset where the tile is drawn. Arg 1 & 2 are X and Y offset in pixels. Should be in the range -20 to 20, otherwise the graphical glitches occur at screen edges.