From a26f2674fa316d1b5a586a956433d312ae393782 Mon Sep 17 00:00:00 2001 From: George Wright Date: Sat, 7 Dec 2024 11:50:16 -0800 Subject: [PATCH] lcd read framebuffer fixes --- WindCore/sa1100.cpp | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/WindCore/sa1100.cpp b/WindCore/sa1100.cpp index 8938d28..0a8864f 100644 --- a/WindCore/sa1100.cpp +++ b/WindCore/sa1100.cpp @@ -1179,6 +1179,10 @@ uint16_t getHWordIdx(uint32_t word, int idx) { void Emulator::readLCDIntoBuffer(uint8_t **lines, bool is32BitOutput) { if (!lcdController->isLCDEnabled()) { + for (int i = 0; i < 480; i++) { + uint8_t* line = reinterpret_cast(lines[i]); + memset(line, 0x0AAA, 2*640); + } return; } @@ -1198,15 +1202,15 @@ void Emulator::readLCDIntoBuffer(uint8_t **lines, bool is32BitOutput) { std::vector pixels; for (int i = 0; i < 640*240; i += 4) { - LOAD_32LE(test, (framebufferTopHalfBase + (4*i)) & memoryMask, MemoryBlockC0); + LOAD_32LE(test, (framebufferTopHalfBase + (i)) & memoryMask, MemoryBlockC0); for (int j = 0; j < 4; j++) { - pixels.emplace_back(getByteIdx(test, 3-j)); + pixels.emplace_back(getByteIdx(test, j)); } } for (int i = 0; i < 640*240; i += 4) { - LOAD_32LE(test, (framebufferBottomHalfBase + (4*i)) & memoryMask, MemoryBlockC0); + LOAD_32LE(test, (framebufferBottomHalfBase + (i)) & memoryMask, MemoryBlockC0); for (int j = 0; j < 4; j++) { - pixels.emplace_back(getByteIdx(test, 3-j)); + pixels.emplace_back(getByteIdx(test, j)); } } @@ -1234,24 +1238,25 @@ void Emulator::readLCDIntoBuffer(uint8_t **lines, bool is32BitOutput) { // } // printf("\n"); - printf("Pixel count %d\n", pixels.size()); + // printf("Pixel count %d\n", pixels.size()); - printf("PBS: %x\n", (palette[0] >> 12) & 0x3); + // printf("PBS: %x\n", (palette[0] >> 12) & 0x3); - uint8_t* framebufferTopHalf = &MemoryBlockC0[framebufferTopHalfBase]; - uint8_t* framebufferBottomHalf = &MemoryBlockC0[framebufferBottomHalfBase]; + // uint8_t* framebufferTopHalf = &MemoryBlockC0[512]; + // uint8_t* framebufferBottomHalf = &MemoryBlockC0[512 + (640*240)]; - printf("Display Size %dx%d\n", lcdController->getWidth(), lcdController->getHeight()); + //printf("Display Size %dx%d\n", lcdController->getWidth(), lcdController->getHeight()); for (int i = 0; i < 480; i++) { - uint8_t* line = reinterpret_cast(lines[i]); + uint16_t* line = reinterpret_cast(lines[i]); + memset(line, 0, 2*640); for (int j = 0; j < 640; j++) { - //line[j] = palette[pixels[(480*i)+j]]; - uint8_t pixel = pixels[(480*i)+j]; + line[j] = palette[pixels[(480*i)+j] & 0x0FFF]; + //uint8_t pixel = pixels[(480*i)+j]; // if (pixel != 0) { // printf("Pixel data is %02x\n", pixel); // } - line[j] = pixel; + //line[j] = pixel; //printf("Pixel %08x\n", line[j]); } } -- 2.45.2