Difference between revisions of "Sprite format"
Jump to navigation
Jump to search
(Moving sprite description to its own page) |
m (→Sprites) |
||
Line 1: | Line 1: | ||
− | |||
− | |||
Non-rectangular images in OMF are stored in this format: | Non-rectangular images in OMF are stored in this format: | ||
− | + | == Sprite Header == | |
{| border='1' | {| border='1' | ||
Line 29: | Line 27: | ||
If the ''data missing'' flag is zero, the sprite data will follow the sprite header, as ''length'' BYTEs. In either case, element ''index'' of the sprite reuse table is consulted. If that element is present, or if no graphics data were present in the file, the data from the sprite reuse table are used. Otherwise, that slot in the table is filled with the image data just read from the file. | If the ''data missing'' flag is zero, the sprite data will follow the sprite header, as ''length'' BYTEs. In either case, element ''index'' of the sprite reuse table is consulted. If that element is present, or if no graphics data were present in the file, the data from the sprite reuse table are used. Otherwise, that slot in the table is filled with the image data just read from the file. | ||
− | + | == Sprite Data == | |
The sprite data is decoded thusly: | The sprite data is decoded thusly: | ||
Revision as of 06:30, 1 December 2009
Non-rectangular images in OMF are stored in this format:
Sprite Header
Length | 1 WORD | Length of sprite |
X Position | 1 SIGNED WORD | TODO |
Y Position | 1 SIGNED WORD | TODO |
Width | 1 WORD | Width of the sprite, in pixels |
Height | 1 WORD | Height of the sprite, in pixels |
Index | 1 BYTE | Index of the sprite in already-loaded images table |
Data missing | 1 BYTE | See below |
For animations 12, 13 and 14, the index field will be treated as if it were 0. If the index is 0, the data missing field will be treated as if it were 0.
If the data missing flag is zero, the sprite data will follow the sprite header, as length BYTEs. In either case, element index of the sprite reuse table is consulted. If that element is present, or if no graphics data were present in the file, the data from the sprite reuse table are used. Otherwise, that slot in the table is filled with the image data just read from the file.
Sprite Data
The sprite data is decoded thusly:
- Initalize X and Y to 0
- Read 1 WORD as P
- Modulus P by 4 to get OPCODE
- Integer divide P by 4 to get DATA
- Compare the OPCODE against the following and take that action
- Set X to DATA
- While DATA is greater than 0
- Read 1 BYTE
- Store that byte as the pixel at X,Y in the sprite
- Increment X
- Decrement DATA
- Set Y to DATA
- End of sprite data