/** * RoomView — top-down "3D" flythrough of NetDeck's demo map. * * Target: T-Deck emulator (320x240, RGB565 device framebuffer). * * This file is only the emulator shell: keyboard pump, delta time, and * the 565 -> 8888 presentation blit (the stand-in for the SPI push). * The whole renderer lives in the device-agnostic RoomViewCore.h, * shared 1:1 with the ESP32-S3 firmware build (fw/RoomViewHW.ino), so * benchmark numbers measured on hardware describe exactly this code. * * Contract with the emulator host (src/main.cpp): * - implement setup() — called once at launch * - implement loop() — called once per frame (host paces at ~60 fps) * - write pixels into emuGfx::fb[] (320x240, ABGR8888 uint32) * - set emuGfx::dirty = true each frame you want presented * - read keys from emu::keyboard (ASCII queue, filled from SDL events) * * Keys: a/d orbit speed, w/s zoom, r/f altitude, space pause, q/ESC quit. */ #include "shim.h" #include "RoomViewCore.h" extern uint32_t emuGfx::fb[320 * 240]; extern bool emuGfx::dirty; extern std::deque emu::keyboard; // The "device" framebuffer the core renders into. static uint16_t fb565[rvcore::W * rvcore::H]; void setup() { rvcore::rvInit(fb565); } void loop() { // --- keyboard pump --- while (!emu::keyboard.empty()) { uint8_t k = emu::keyboard.front(); emu::keyboard.pop_front(); rvcore::rvInput(k); } if (rvcore::rvQuitRequested()) emu::quitRequested = true; // --- delta time: seconds since the previous frame --- static unsigned long lastMs = 0; unsigned long now = millis(); float dt = lastMs ? (now - lastMs) / 1000.0f : 1.0f / 60.0f; lastMs = now; if (dt > 0.1f) dt = 0.1f; // clamp after stalls (drag, breakpoint) 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. for (int i = 0; i < rvcore::W * rvcore::H; i++) { uint16_t c = fb565[i]; 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 uint32_t b = (b5 << 3) | (b5 >> 2); emuGfx::fb[i] = 0xFF000000u | (b << 16) | (g << 8) | r; } emuGfx::dirty = true; }