Code: Show/Hide // next 2 bytes: // i12 Display Time - How long will display for, in 1/10th of a second. unsigned short displayTime = 0; // 16 bit int, will hold a 12 bit number memcpy(&displayTime, &uncompressedDATA[dataPointer], 2); // read 16 bits/2 bytes. Only interested in the first 12 bits though. dataPointer += 1; // move the dataPointer only one byte because the next item shares some of the 2nd byte displayTime <<= 4; // push the last 4 bits off of the number displayTime >>= 4; // move the significant 12 bits back to the beginning of the number printf(" object loop: displayTime is %i 1/100ths of a second\n", displayTime); // i4 Display Mode - Which display mode this object uses. Values later. unsigned char displayMode = 0; // 8 bit int, unsigned so bit shift is predictable memcpy(&displayMode, &uncompressedDATA[dataPointer], 1); // read 8 bits/1 byte, only interested last 4 bits. dataPointer += 1; displayMode >>= 4; // push the rightmost 4 bits of the 8bit number off, so only the last 4 bits represent the number. |
Code: Show/Hide // next 2 bytes after mapOrScreenObject and objectID bytes: // u4 X Type - Which part of the screen the X coord is offset from (see OffsetTypes lower down). unsigned char xScreenOffsetType = 0; // will hold 4 significant bits only. memcpy(&xScreenOffsetType, &uncompressedDATA[dataPointer], 1); // read 1 byte // ++dataPointer; // do not move the pointer, still need to read part of the 1st byte. xScreenOffsetType <<= 4; // push 4 leftmost bits off the 8 bit number xScreenOffsetType >>= 4; // move the significant 4 bits back to the significant side of the number. printf(" object loop: xScreenOffsetType is %i\n", xScreenOffsetType); // i12 X Coord - The X coord value, in pixels, this object will be displayed on. More info later. /*unsigned */ short xCoord = 0; // 16 bit int, only 12 significant bits will be put into it. This value can be negative. memcpy(&xCoord, &uncompressedDATA[dataPointer], 2); // read 16 bits/2 bytes from the uncompressedDATA. dataPointer += 2; xCoord >>= 4; // push the 4bits from the previous variable off of this 16bit number, to get the significant 12 bits of this variable. Bitshifting a signed int! printf(" object loop: xCoord at %i pixel\n", xCoord); |
Code: Show/Hide ./lvzreader "./test lvz information/akoth5.lvz" |
Code: Show/Hide #pragma pack(1)
struct PacketObjectInfo2Map { unsigned short mapobject : 1; unsigned short id : 15; short x; short y; unsigned char imagenumber; unsigned char layer; unsigned short displaytime : 12; unsigned short timermode : 4; }; #pragma pack() |
Code: Show/Hide struct PacketObjectInfo2Map *objinfo;
objinfo = (struct PacketObjectInfo2Map*)myCharArray; printf("Object ID: %d Location: (%d,%d)\n", objinfo->id, objinfo->x, objinfo->y); |
grazzhoppa wrote: |
I don't have a Windows computer, so I can't make a new .lvz to test a .lvz that uses negative numbers for those items. |