fix 4bpp screen rendering

This commit is contained in:
Ash Wolf 2019-12-20 01:00:00 +00:00
parent e96c438003
commit d1bc50448f
2 changed files with 2 additions and 8 deletions

View File

@ -26,7 +26,6 @@ Known issues:
- State is not saved (just like a real Psion :p) - State is not saved (just like a real Psion :p)
- LCD controller is almost entirely unimplemented aside from the very basics to display the framebuffer - LCD controller is almost entirely unimplemented aside from the very basics to display the framebuffer
- EPOC misbehaves massively with memory banks larger than 0x800000 (may be an OS design flaw? need to confirm) - EPOC misbehaves massively with memory banks larger than 0x800000 (may be an OS design flaw? need to confirm)
- 4bpp display mode does not decode correctly
Copyright Copyright
--------- ---------

View File

@ -93,15 +93,10 @@ void MainWindow::updateScreen()
for (int x = 0; x < img.width(); x++) { for (int x = 0; x < img.width(); x++) {
uint8_t byte = lcdBuf[lineOffs + (x / ppb)]; uint8_t byte = lcdBuf[lineOffs + (x / ppb)];
int shift = (x & (ppb - 1)) * bpp; int shift = (x & (ppb - 1)) * bpp;
int mask = (bpp << 1) - 1; int mask = (1 << bpp) - 1;
int palIdx = (byte >> shift) & mask; int palIdx = (byte >> shift) & mask;
int palValue = palette[palIdx]; int palValue = palette[palIdx];
if (bpp <= 1)
palValue |= (palValue << 1);
if (bpp <= 2)
palValue |= (palValue << 2);
if (bpp <= 4)
palValue |= (palValue << 4); palValue |= (palValue << 4);
scanline[x] = palValue ^ 0xFF; scanline[x] = palValue ^ 0xFF;
} }