diff --git a/emulator/src/shim/Arduino.h b/emulator/src/shim/Arduino.h index 1dd3a7f..caacd1b 100644 --- a/emulator/src/shim/Arduino.h +++ b/emulator/src/shim/Arduino.h @@ -9,6 +9,10 @@ // a much richer edge rate than a real roll on the device). #define EMULATOR 1 +// Host flash is memory-mapped, so flash-resident data needs no special read +// macro (same as on ESP32; real AVR pgm_read is not used by our sketches). +#define PROGMEM + #include #include #include diff --git a/emulator/src/shim/TFT_eSPI.h b/emulator/src/shim/TFT_eSPI.h index 0716580..dd66191 100644 --- a/emulator/src/shim/TFT_eSPI.h +++ b/emulator/src/shim/TFT_eSPI.h @@ -107,6 +107,22 @@ public: } } + // Blit a 16bpp (RGB565) image — the pattern-stamp primitive that the + // device-side TFT_eSPI / TFT_eSprite pushImage() provides. Clipped. + void pushImage(int32_t x, int32_t y, int32_t w, int32_t h, const uint16_t *data) + { + for (int32_t j = 0; j < h; j++) { + int32_t ty = y + j; + if (ty < 0 || ty >= emuGfx::H) continue; + for (int32_t i = 0; i < w; i++) { + int32_t tx = x + i; + if (tx < 0 || tx >= emuGfx::W) continue; + emuGfx::fb[ty * emuGfx::W + tx] = rgb565to888(data[j * w + i]); + } + } + emuGfx::dirty = true; + } + void fillCircle(int32_t x0, int32_t y0, int32_t r, uint32_t c) { for (int dy = -r; dy <= r; dy++) { diff --git a/emulator/tests/e2e_tests.cpp b/emulator/tests/e2e_tests.cpp index 6877c7f..200aaef 100644 --- a/emulator/tests/e2e_tests.cpp +++ b/emulator/tests/e2e_tests.cpp @@ -114,10 +114,12 @@ TEST(e2e/boot_and_controls) // HUD separator rendered across the top of the HUD bar EXPECT(test::pixelIs565(160, nd::HUD_Y, nd::C_BORDER)); - // paused -> freeze scanlines: every 3rd view row is black - EXPECT(test::pixelIs565(50, 0, 0x0000)); - EXPECT(test::pixelIs565(50, 3, 0x0000)); - EXPECT(!test::pixelIs565(50, 1, 0x0000)); + // paused -> checkered freeze tint: 2px checker of black + dark teal + // P(x,y): black when ((x>>1)+(y>>1)) is even + EXPECT(test::pixelIs565(50, 0, 0x1F1F)); // (25+0) odd -> teal + EXPECT(test::pixelIs565(50, 2, 0x0000)); // (25+1) even -> black + EXPECT(test::pixelIs565(52, 0, 0x0000)); // (26+0) even -> black + EXPECT(!test::pixelIs565(52, 0, 0x1F1F)); } TEST(e2e/network_journey) diff --git a/src/netdeck/NetDeck.ino b/src/netdeck/NetDeck.ino index cac9876..900aa7e 100644 --- a/src/netdeck/NetDeck.ino +++ b/src/netdeck/NetDeck.ino @@ -1264,10 +1264,29 @@ static void renderCursor() } } +// 8x8 stamp for the tactical-freeze tint: 2px checkerboard of black and a +// dark teal (the map stays readable underneath). RGB565 has no alpha, so a +// dither is the way to "tint" — same trick the old scanlines used. +static const uint16_t PROGMEM checkered8x8[64] = { + 0x0000, 0x0000, 0x1F1F, 0x1F1F, 0x0000, 0x0000, 0x1F1F, 0x1F1F, + 0x0000, 0x0000, 0x1F1F, 0x1F1F, 0x0000, 0x0000, 0x1F1F, 0x1F1F, + 0x1F1F, 0x1F1F, 0x0000, 0x0000, 0x1F1F, 0x1F1F, 0x0000, 0x0000, + 0x1F1F, 0x1F1F, 0x0000, 0x0000, 0x1F1F, 0x1F1F, 0x0000, 0x0000, + 0x0000, 0x0000, 0x1F1F, 0x1F1F, 0x0000, 0x0000, 0x1F1F, 0x1F1F, + 0x0000, 0x0000, 0x1F1F, 0x1F1F, 0x0000, 0x0000, 0x1F1F, 0x1F1F, + 0x1F1F, 0x1F1F, 0x0000, 0x0000, 0x1F1F, 0x1F1F, 0x0000, 0x0000, + 0x1F1F, 0x1F1F, 0x0000, 0x0000, 0x1F1F, 0x1F1F, 0x0000, 0x0000, +}; + static void renderFreezeTint() { - for (int y = 0; y < nd::VIEW_H; y += 3) { - GFXP->drawFastHLine(0, y, nd::VIEW_W, 0x0000); + // Stamp the checkered 8x8 pattern across the view. pushImage() exists on + // BOTH backends: device = TFT_eSprite::pushImage (blits into the fb + // sprite RAM), emulator = the shim blit into the host framebuffer. + for (int by = 0; by < nd::VIEW_H; by += 8) { + for (int bx = 0; bx < nd::VIEW_W; bx += 8) { + GFXP->pushImage(bx, by, 8, 8, checkered8x8); + } } GFXP->setTextDatum(TR_DATUM); GFXP->setTextColor(nd::C_FREEZE, 0x0000);