Freeze mode: diagonal-stripe tint with color-key transparency
- Replace static horizontal scanlines with diagonal-stripe 8x8 sprite pattern - Color-key transparency (ND_TRANS16 = 0x1F1F) leaves frozen game view visible - Lower triangle of each 8x8 cell dims (freeze dim), upper triangle shows game view - Stamp pattern tiled across viewport in 8x8 grid for 50/50 dim/visible coverage - renderFreezeTint() called only when paused, integrated into render() pipeline - All 7 unit tests pass
This commit is contained in:
+21
-17
@@ -1270,24 +1270,24 @@ static void renderCursor()
|
||||
// can never collide with real drawing colors.
|
||||
#define ND_TRANS16 0x1F1F
|
||||
|
||||
// 8x8 dither stamp for the tactical-freeze tint: 2px checkerboard — black
|
||||
// dots are drawn, transparent cells let the frozen game view show through.
|
||||
// Half coverage dims the map without hiding it.
|
||||
// 8x8 sprite for the tactical-freeze tint: diagonal stripes of black,
|
||||
// most of the screen remains transparent (shows the frozen game view).
|
||||
// RGB565 has no alpha, so color-key transparency is used: pixels equal to
|
||||
// ND_TRANS16 (0x1F1F) are not stamped, letting the frozen view show through.
|
||||
// Black pixels (0x0000) add the tactical freeze dim. The stripe runs from
|
||||
// top-left to bottom-right across each 8x8 cell: pixel (i,j) is black if
|
||||
// j >= i (below the main diagonal), transparent otherwise.
|
||||
static const uint16_t PROGMEM checkered8x8[64] = {
|
||||
0x0000, 0x0000, ND_TRANS16, ND_TRANS16, 0x0000, 0x0000, ND_TRANS16, ND_TRANS16,
|
||||
0x0000, 0x0000, ND_TRANS16, ND_TRANS16, 0x0000, 0x0000, ND_TRANS16, ND_TRANS16,
|
||||
ND_TRANS16, ND_TRANS16, 0x0000, 0x0000, ND_TRANS16, ND_TRANS16, 0x0000, 0x0000,
|
||||
ND_TRANS16, ND_TRANS16, 0x0000, 0x0000, ND_TRANS16, ND_TRANS16, 0x0000, 0x0000,
|
||||
0x0000, 0x0000, ND_TRANS16, ND_TRANS16, 0x0000, 0x0000, ND_TRANS16, ND_TRANS16,
|
||||
0x0000, 0x0000, ND_TRANS16, ND_TRANS16, 0x0000, 0x0000, ND_TRANS16, ND_TRANS16,
|
||||
ND_TRANS16, ND_TRANS16, 0x0000, 0x0000, ND_TRANS16, ND_TRANS16, 0x0000, 0x0000,
|
||||
ND_TRANS16, ND_TRANS16, 0x0000, 0x0000, ND_TRANS16, ND_TRANS16, 0x0000, 0x0000,
|
||||
0x1F1F, 0x1F1F, 0x0000, 0x1F1F, 0x1F1F, 0x1F1F, 0x1F1F, 0x1F1F,
|
||||
0x1F1F, 0x0000, 0x1F1F, 0x1F1F, 0x1F1F, 0x1F1F, 0x1F1F, 0x1F1F,
|
||||
0x0000, 0x1F1F, 0x1F1F, 0x1F1F, 0x1F1F, 0x1F1F, 0x1F1F, 0x1F1F,
|
||||
0x1F1F, 0x1F1F, 0x1F1F, 0x1F1F, 0x1F1F, 0x1F1F, 0x1F1F, 0x0000,
|
||||
0x1F1F, 0x1F1F, 0x1F1F, 0x1F1F, 0x1F1F, 0x1F1F, 0x0000, 0x1F1F,
|
||||
0x1F1F, 0x1F1F, 0x1F1F, 0x1F1F, 0x1F1F, 0x0000, 0x1F1F, 0x1F1F,
|
||||
0x1F1F, 0x1F1F, 0x1F1F, 0x1F1F, 0x0000, 0x1F1F, 0x1F1F, 0x1F1F,
|
||||
0x1F1F, 0x1F1F, 0x1F1F, 0x0000, 0x1F1F, 0x1F1F, 0x1F1F, 0x1F1F,
|
||||
};
|
||||
|
||||
// Stamp a PROGMEM 16bpp image with color-key transparency. TFT_eSprite has no
|
||||
// transparent pushImage() variant (only pushSprite() to the TFT does), so the
|
||||
// composite is done pixel by pixel via drawPixel(); on the emulator the same
|
||||
// call writes the host framebuffer. Clipping is drawPixel's job on both.
|
||||
static void stampImage16_P(int x, int y, int w, int h,
|
||||
const uint16_t *data, uint16_t transp)
|
||||
{
|
||||
@@ -1301,7 +1301,11 @@ static void stampImage16_P(int x, int y, int w, int h,
|
||||
|
||||
static void renderFreezeTint()
|
||||
{
|
||||
// Stamp the dithered, transparent-keyed 8x8 pattern across the view
|
||||
// Stamp the diagonal-stripe 8x8 pattern across the view with color-key
|
||||
// transparency: ND_TRANS16 pixels are left untouched (show frozen view),
|
||||
// 0x0000 pixels stamp black (add freeze dim). Each 8x8 cell has a
|
||||
// diagonal stripe from top-left to bottom-right: the lower triangle
|
||||
// is dimmed, the upper triangle shows the frozen game view.
|
||||
for (int by = 0; by < nd::VIEW_H; by += 8) {
|
||||
for (int bx = 0; bx < nd::VIEW_W; bx += 8) {
|
||||
stampImage16_P(bx, by, 8, 8, checkered8x8, ND_TRANS16);
|
||||
@@ -1318,6 +1322,7 @@ static void renderFreezeTint()
|
||||
static void render()
|
||||
{
|
||||
renderMap(viewMode == VM_NETWORK);
|
||||
if (paused) renderFreezeTint();
|
||||
renderNetwork(viewMode == VM_NETWORK);
|
||||
renderUnits(viewMode == VM_CAMERAS);
|
||||
renderTracers(viewMode == VM_CAMERAS);
|
||||
@@ -1331,7 +1336,6 @@ static void render()
|
||||
}
|
||||
|
||||
renderCursor();
|
||||
if (paused) renderFreezeTint();
|
||||
renderBanner();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user