Skip to content
Qy edited this page Jul 14, 2024 · 20 revisions

A G1 element is typically a sprite. It is basically an image.

There would appear to be two image formats that the G1 element can be.

RLE Compressed G1 Element

Run length encoded element.

The first y words are offsets to the corresponding y line. You use this to jump to the correct line if you do not require info from the first line.

[line 0 offset][line 1 offset] ...

[word][word] ...

When you have jumped to the correct line there are 2 bytes that inform you of the number of bytes in the next data section and the number of pixels it represents after it (gap length). The reason there are two values for representing the pixels is for empty pixels. To draw the correct image you have to do each section and remember to jump over each gap on the drawing surface. The gap is measured from the left edge of the sprite, not from the last group of pixels. The next line will start immediately at the end of the previous line. If the most significant bit of the no. bytes field is set then this the last data section of a line and a new line will start after this data section.

line0:[no. bytes in data 1][gap length 1][data 1 of no. bytes length][no. bytes in gap 2]...line1:...

[byte][byte][bytes*no.bytes][byte]...

Example G1 Element 4x4 pixels.

0000: 0x0008,0x000F,0x0015,0x0018        ;4 words in line offsets
0008: 0x01,0x01,0xff,0x82,0x00,0xa1,0xff ;7 bytes in line 0
000F: 0x84,0x00,0xff,0xff,0xa1,0xff      ;6 bytes in line 1
0015: 0x81,0x03,0xff                     ;3 bytes in line 2
0018: 0x81,0x03,0xa1                     ;3 bytes in line 3
Total bytes: 27

Final image. Note that blank areas will be whatever the current drawing area is.

blank,  0xff,  0xa1, 0xff
 0xff,  0xff,  0xa1, 0xff
blank, blank, blank, 0xff
blank, blank, blank, 0xa1
Total bytes of info: 32 (Assumes 1 byte for if blank or not)

Note that the final image has more bytes than the original image. For larger images with more blank areas this saving is bigger. We can therefore conclude that this technique was probably used to save on file size.

Non Compressed Bitmap G1 Element

The second type is not compressed and it is a simple one to one relationship.

Palettes

The drawing code also uses palettes to translate some of the colours. This is used for example with security guards to change their top colour. There are two palettes that are not loaded and are modified throughout the code (0x9ABE0C and 0x9ABF0C)

Clone this wiki locally