mirror of
https://github.com/isledecomp/isle.git
synced 2025-10-23 08:24:16 +00:00
Match DecodeSS2
(#1476)
--------- Co-authored-by: jonschz <jonschz@users.noreply.github.com>
This commit is contained in:
@@ -355,64 +355,99 @@ void DecodeLC(LPBITMAPINFOHEADER p_bitmapHeader, BYTE* p_pixelData, BYTE* p_data
|
|||||||
// FUNCTION: BETA10 0x1013e61d
|
// FUNCTION: BETA10 0x1013e61d
|
||||||
void DecodeSS2(LPBITMAPINFOHEADER p_bitmapHeader, BYTE* p_pixelData, BYTE* p_data, FLIC_HEADER* p_flcHeader)
|
void DecodeSS2(LPBITMAPINFOHEADER p_bitmapHeader, BYTE* p_pixelData, BYTE* p_data, FLIC_HEADER* p_flcHeader)
|
||||||
{
|
{
|
||||||
short width = (short) p_flcHeader->width - 1;
|
short xofs = 0;
|
||||||
short row = (short) p_flcHeader->height - 1;
|
short yofs = 0;
|
||||||
short lines = *((short*) p_data);
|
|
||||||
BYTE* data = p_data + 2;
|
|
||||||
|
|
||||||
while (--lines > 0) {
|
short width = p_flcHeader->width;
|
||||||
short token;
|
short token = 0;
|
||||||
|
|
||||||
while (TRUE) {
|
// LINE: BETA10 0x1013e643
|
||||||
token = *((short*) data);
|
short xmax = xofs + width - 1;
|
||||||
data += 2;
|
|
||||||
|
|
||||||
if (token < 0) {
|
// LINE: BETA10 0x1013e652
|
||||||
if (token & 0x4000) {
|
union {
|
||||||
row += token;
|
BYTE* byte;
|
||||||
}
|
WORD* word;
|
||||||
else {
|
} data = {p_data};
|
||||||
WritePixel(p_bitmapHeader, p_pixelData, width, row, token);
|
|
||||||
token = *((WORD*) data);
|
|
||||||
data += 2;
|
|
||||||
|
|
||||||
if (!token) {
|
// The first word in the data following the chunk header contains the number of lines in the chunk.
|
||||||
row--;
|
// The line count does not include skipped lines.
|
||||||
if (--lines <= 0) {
|
short lines = *(short*) data.word++;
|
||||||
return;
|
|
||||||
}
|
// LINE: BETA10 0x1013e666
|
||||||
}
|
short row = p_flcHeader->height - yofs - 1;
|
||||||
else {
|
|
||||||
break;
|
goto start_packet;
|
||||||
}
|
|
||||||
}
|
skip_lines:
|
||||||
|
// The layout in BETA10 strongly suggests that lots of `goto`s are used.
|
||||||
|
// LINE: BETA10 0x1013e684
|
||||||
|
row += token;
|
||||||
|
|
||||||
|
start_packet:
|
||||||
|
// LINE: BETA10 0x1013e692
|
||||||
|
token = *(short*) data.word++;
|
||||||
|
|
||||||
|
if (token >= 0) {
|
||||||
|
goto column_loop;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((unsigned short) token & 0x4000) {
|
||||||
|
goto skip_lines;
|
||||||
|
}
|
||||||
|
|
||||||
|
WritePixel(p_bitmapHeader, p_pixelData, xmax, row, token);
|
||||||
|
token = *(short*) data.word++;
|
||||||
|
|
||||||
|
// LINE: BETA10 0x1013e6ef
|
||||||
|
if (!token) {
|
||||||
|
row--;
|
||||||
|
if (--lines > 0) {
|
||||||
|
goto start_packet;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
|
||||||
|
column_loop:
|
||||||
|
// LINE: BETA10 0x1013e71e
|
||||||
|
short column = xofs;
|
||||||
|
|
||||||
|
column_loop_inner:
|
||||||
|
// LINE: BETA10 0x1013e726
|
||||||
|
column += *data.byte++;
|
||||||
|
// LINE: BETA10 0x1013e73a
|
||||||
|
short type = *(char*) data.byte++;
|
||||||
|
type += type;
|
||||||
|
|
||||||
|
if (type >= 0) {
|
||||||
|
WritePixels(p_bitmapHeader, p_pixelData, column, row, data.byte, type);
|
||||||
|
column += type;
|
||||||
|
data.byte += type;
|
||||||
|
// LINE: BETA10 0x1013e797
|
||||||
|
if (--token != 0) {
|
||||||
|
goto column_loop_inner;
|
||||||
}
|
}
|
||||||
else {
|
row--;
|
||||||
break;
|
if (--lines > 0) {
|
||||||
|
goto start_packet;
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
short column = 0;
|
type = -type;
|
||||||
do {
|
WORD* p_pixel = data.word++;
|
||||||
column += *(data++);
|
WritePixelPairs(p_bitmapHeader, p_pixelData, column, row, *p_pixel, type >> 1);
|
||||||
short type = *((char*) data++);
|
column += type;
|
||||||
type += type;
|
// LINE: BETA10 0x1013e813
|
||||||
|
if (--token != 0) {
|
||||||
if (type >= 0) {
|
goto column_loop_inner;
|
||||||
WritePixels(p_bitmapHeader, p_pixelData, column, row, data, type);
|
}
|
||||||
column += type;
|
|
||||||
data += type;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
type = -type;
|
|
||||||
short p_pixel = *((WORD*) data);
|
|
||||||
data += 2;
|
|
||||||
WritePixelPairs(p_bitmapHeader, p_pixelData, column, row, p_pixel, type >> 1);
|
|
||||||
column += type;
|
|
||||||
}
|
|
||||||
} while (--token);
|
|
||||||
|
|
||||||
row--;
|
row--;
|
||||||
|
if (--lines > 0) {
|
||||||
|
goto start_packet;
|
||||||
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user