tron-room-demo: store the framebuffer in panel wire order (fixes swapped colors on HW)
The ST7789 receives pixel bytes high-byte-first, and TFT_eSprite's pushSprite sends the sprite buffer raw — which is why the sprite's own primitives store colors byte-swapped (drawPixel: color = color>>8 | color<<8). RoomViewCore wrote native little-endian values instead, so every pixel reached the panel byte-swapped: BG 0x0002 showed as green (0x0200), the fogged floor 0x0882 as pink (0x8208) — exactly the symptoms reported from hardware. The core now stores pixels in panel wire order (toWire byteswap on store, one 16-bit rotate per pixel); the emulator blit unswaps before the 565-to-8888 expansion, so its output is pixel-identical. Also add -O2 to the firmware env: PlatformIO's default -Os optimizes for size and was likely a large part of the 13 fps report.
This commit is contained in:
@@ -51,11 +51,11 @@ void loop() {
|
||||
|
||||
rvcore::rvFrame(dt, now);
|
||||
|
||||
// --- "SPI push": expand the 565 device buffer into the emulator's 8888 ---
|
||||
// texture. On the T-Deck this step doesn't exist — the 565 buffer is
|
||||
// what the panel receives. This is purely a desktop-presentation shim.
|
||||
// --- "SPI push": the buffer is in panel wire order (big-endian 565),
|
||||
// exactly what the T-Deck's ST7789 receives. For the desktop window,
|
||||
// unswap back to native RGB565 and expand to 8888.
|
||||
for (int i = 0; i < rvcore::W * rvcore::H; i++) {
|
||||
uint16_t c = fb565[i];
|
||||
uint16_t c = (uint16_t)((fb565[i] << 8) | (fb565[i] >> 8)); // wire -> native
|
||||
uint32_t r5 = (c >> 11) & 31, g6 = (c >> 5) & 63, b5 = c & 31;
|
||||
uint32_t r = (r5 << 3) | (r5 >> 2); // 5 -> 8 bit expansion
|
||||
uint32_t g = (g6 << 2) | (g6 >> 4); // 6 -> 8 bit expansion
|
||||
|
||||
Reference in New Issue
Block a user