===== Sprite format ===== |[[omf2097_file_formats| A table of loaded sprite data is maintained. Each loaded frame with a non-zero index is stored into the table in entry number (index + frame number). When the sprite loading code is called, if the g_indexOfReusedSprite value is not -1, and the loaded sprite has //data missing// == 0, //width// != 0, //index// != 0, the data in the file apart from the index will be ignored, and the sprite at the corresponding index in the reuse table will be used instead. 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 X to 0 - Set Y to DATA - End of sprite data Alternative: 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 X to 0 Set Y to DATA End of sprite data