PANL LFD Resource Type Author: Jagged Fel (jaggedfel621@gmail.com) Site: http://idmr.empirereborn.net Updated: 2009.10.05 ===== The PANL resource is image data found primarily in cockpit LFD files. These files do not contain RMAPs, although are comprised of a PANL, MASK and PLTT. The PANL is an indexed image detailing the opaque areas of the cockpit and instruments. ===== PANL Structure The following values are used through this and all of my file definitions unless otherwise specified: NAME LENGTH DESC ---- ------ ---- BYTE 1 unsigned 8-bit CHAR 1 ASCII character INT 4 signed Int32 -- Header Row[] BYTE EndImage (0xFF) -- struct Header (size 0x10) { 0x0 CHAR[4] "PANL" 0x4 CHAR[8] Name 0x8 INT Length } struct Row { OpCode[] BYTE EndRow (0xFE) } strcut OpCode { BYTE Value #if (Value==0xFC) (Repeat2) BYTE ColorIndex BYTE NumRepeat #elseif (Value==0xFD) (Repeat) BYTE NumRepeat BYTE ColorIndex #else (Short) #endif } ===== PANL Details Unlike most image resources found in the LFDs, PANL does not have a Width and Height defined in the resource itself. Presumably the image sizes if explicitly defined are in the executable, since there are two resolutions that can be used. The sizes can be determined computationally, and is much more reliable than MASK size derivations. There are three types of OpCodes that are relevant to pixel data. The first is the main Repeat code, FD. Following the Repeat op code, two bytes are required; the NumRepeat of pixels (number of repeats, so 0B is 12px), and the ColorIndex from the PLTT resource. Another OpCode immediately follows the Index value. Now, in a certain form of brilliance that I have come to expect from LA/TG, there is a second Repeat op code, FC. This works exactly the same as FD, but instead the Index value comes before NumRepeat. There appears to be no special reason for this, it's just an "ism" of the format. The PLTTs of the cockpit LFDs use indexes 00-3F (b00111111), which allow for a 1-byte OP_CODE to be used for small (1-4) lengths of pixels. This Short code is evaluated as ColorIndex << 2 + NumRepeat. Say you have 2px of Index 0x32. Then the op code will be C9 (32<<2 = C8, + NumRepeat=1). 4px of Index 35 becomes D7 (35<<2 = D4, NumRepeat=3), and so on. There's never data loss in the shift because the top two bits are never used for Index. Note: because PANL uses FC-FF as OpCodes, it's advised to avoid using the Short code for Index 3F. Affects of doing so are unknown. At the end of every row is an EndRow op code, FE. After the final row, the PANL is terminated with an EndImage op code, FF (stray bytes have been seen after the EndImage code, but are ignored). =====