Skip to content

Commit

Permalink
Add support for flags 2 and 4 for 4-bit Jaguar Images (#1611)
Browse files Browse the repository at this point in the history
* Add support for flags 2 and 4 for 4-bit Jaguar Images

The new values for the 'flags' are supposed to extend functionality
of the 4-bit images.

Enabled bit 1 indicates that the base palette index is odd.
If bit 2 is enabled, palette indices must be doubled. This allows
creating images with more contrast.

* Fix writing of column-major Jag images
  • Loading branch information
viciious authored Dec 19, 2023
1 parent ef0df8b commit fd80652
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions src/Graphics/SImage/Formats/SIFDoom.h
Original file line number Diff line number Diff line change
Expand Up @@ -937,12 +937,21 @@ class SIFDoomJaguar : public SIFormat
}
else if (depth == 2)
{
int pixshift = 0;

if (shift == 0)
shift = 40;
shift <<= 1;

if (flags & 2)
shift++;
if (flags & 4)
pixshift++;

for (int p = 0; p < width * height / 2; ++p)
{
img_data[p * 2] = ((data[16 + p] & 0xF0) >> 4) + (shift << 1);
img_data[p * 2 + 1] = (data[16 + p] & 0x0F) + (shift << 1);
img_data[p * 2] = shift + (((data[16 + p] & 0xF0) >> 4) << pixshift);
img_data[p * 2 + 1] = shift + ((data[16 + p] & 0x0F) << pixshift);
}
}
else
Expand Down Expand Up @@ -982,18 +991,12 @@ class SIFDoomJaguar : public SIFormat
// Write the image data
if (colmajor)
{
SImage cmimage;
image.copyImage(&cmimage);

cmimage.mirror(false);
cmimage.rotate(270);
cmimage.putIndexedData(out);
}
else
{
image.putIndexedData(out);
image.mirror(false);
image.rotate(270);
}

image.putIndexedData(out);

return true;
}

Expand Down

0 comments on commit fd80652

Please sign in to comment.