Files
lilygo-t-deck/tron-room-demo/README.md
T
Dejvino 34384ac4d8 tron-room-demo: fog toward the background color (fade into the void)
The fog target is now COL_BG instead of the steel haze: far geometry
converges exactly onto the void color, so the deck dissolves seamlessly
into the background instead of glowing against it.

This exposed and fixed a channel bug in fogMix: the green channel
divided by 64 instead of 32 (blended at half strength). It was
invisible while the fog color's green level matched the walls', but
fading toward g=0 left far walls tinted green. fogMix is now a
weighted average (c*(32-f) + fog*f) with per-channel rounding, exact
at both ends and unbiased in either direction.
2026-11-16 22:55:35 +01:00

115 lines
4.3 KiB
Markdown

# tron-room-demo — RoomView
A top-down "3D" flythrough of **NetDeck's demo map**, built on the same
emulator-only template as `tron-demo` (SDL3 host, 320x240 ABGR8888
framebuffer, `setup()`/`loop()` sketch contract — see the original
template README below).
What makes this one different: the sketch renders the **real** Breach &
Board demo floorplan from the firmware tree (`src/netdeck/nd_demomap.h`,
consumed through the generic `MapSource` interface). There is no local
copy of the map — edit the demo map in `src/netdeck` and this view
follows it.
The whole render pipeline runs in **RGB565** — the ST7789 panel's native
format — with the palette taken directly from `nd_layout.h`. Shading and
fog are integer fixed-point on the 5/6/5 channels, so the visible color
banding is exactly what real hardware would produce. Only the final
blit expands 565→8888 for the desktop window (the stand-in for the SPI
push, which on the device ships the 565 buffer as-is).
## What you see
- A true 3D orbiting camera (position + look-at basis, perspective
divide) drifting over the deck on a slow orbit with breathing
radius/height.
- `#` walls, `o` cover crates, the `+` blast door and the `T` terminal
as solid shaded boxes: backface culling, painter's-algorithm depth
sort, lambert lighting from above, bright top rims, and depth fog —
geometry blends toward the background color with camera distance, so
the far deck dissolves seamlessly into the void.
- Floor tiles as lit quads with a subtle checker.
- The demo map's **network graph** as glowing pylons with teal link
lines and cyan packets traveling along the edges.
- Every entity from the demo spawn list walking its patrol route
(marines cyan, droids orange, heavy red, turrets magenta), plus a
pulsing halo over the airlock.
## Keys
| Key | Action |
|-----|--------|
| `a` / `d` | orbit faster / slower (or reverse) |
| `w` / `s` | zoom in / out |
| `r` / `f` | raise / lower the camera |
| `space` | pause the camera drift + patrols |
| `q` / ESC | quit |
## Build & Run
```bash
make run # build + open a window
make smoke # headless: 240 frames -> smoke_frame.bmp
make clean
```
The Makefile is the template's, with two changes: `APP ?= RoomView`
and `-I ../src/netdeck` on the include path.
## On the real T-Deck (ESP32-S3) — free-running benchmark
The renderer lives in `RoomViewCore.h`, device-agnostic and shared 1:1
between the emulator sketch and the firmware twin
`fw/RoomViewHW.ino`. On hardware the core draws straight into a
`TFT_eSprite`'s `frameBuffer()` (16-bit RGB565, PSRAM — the same
full-frame pipeline as NetDeck's M1 anti-flicker pattern) and pushes
with `startWrite()/pushSprite(0,0)/endWrite()`.
The loop is deliberately **free-running** — no pacing — and prints a
report over USB serial every 2 s:
```
RoomViewHW: 120 frames in 2001ms = 60.0 fps | render 12.3 ms, push 14.8 ms
```
That `render` / `push` split is the answer to "how quickly does this
run on real hardware": render is the software rasterizer, push is the
SPI transfer to the panel.
Build, flash and watch:
```bash
pio run -d tron-room-demo/fw -t upload
pio device monitor # 115200 baud
```
(The demo has its own `fw/platformio.ini` pointing at the shared
`boards/`, `lib/` and `src/netdeck` headers — NetDeck's own builds are
untouched. Keyboard input is emulator-only; on hardware the camera
drifts on its own orbit.)
## Safety hatch / CLI options
Same as the template: `--user-run` (run indefinitely), `--timeout MS`,
`--frames N`, `--dump PATH`. By default the emulator exits after 10 s;
use `./RoomView-emu --user-run` for interactive viewing.
---
# T-Deck Emulator-Only Template (original README)
A minimal, self-contained SDL3 emulator template for prototyping 320x240
graphics/engine experiments without any hardware. No TFT_eSPI, no SPI,
no I2S, no GPIO — just SDL3 and a framebuffer.
**Do not** edit `src/main.cpp` or `shim.h` — they are the host and are
app-agnostic. The sketch lives in `examples/$(APP)/$(APP).cpp` and is
compiled as a single translation unit with the host via `-DAPP_SRC=…`.
| Flag | Description |
|------|-------------|
| `--user-run` | Disable the 10 s auto-exit (interactive use) |
| `--timeout MS` | Auto-exit after MS milliseconds (default 10000) |
| `--frames N` | Exit after N frames instead |
| `--dump PATH` | Save the last frame to PATH (BMP) |