Files
TeslaRel410/emulator/firmware-decomp/paint_bars.py
T
CydandClaude Opus 4.8 70a7d38329 Correct the bench frame: bars only -- the triangles are not in the frame
The user asked why triangles sat on the test pattern; verification against the
frame's actually-WRITTEN DMA stream (captured word-by-word during draws) shows
it references ONLY the standard background program -- the 0x815f000+ triangle
blocks are test.egg's 3D scene content, precompiled in DRAM but never
referenced by this frame's chains (my loose memory scan misattributed them).
The live frame = SMPTE colour bars, now rendered bars-only (paint_bars.py) and
matching the user's reference card. Readout §06 corrected: bars frame + honest
note about the undrawn DRAM-resident scene data.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-17 09:39:52 -05:00

58 lines
2.8 KiB
Python

"""PAINT THE BENCH: field-level execution of the standard background program's
mechanism -- a linear scalar ramp in x whose BITS are copied into the eof r/g/b
planes (the IGC_CPY loops at 0x8016000: src bits 24..28 -> dst 200..204 etc.),
which algorithmically generates SMPTE bars (bar colour = binary bits of the bar
index: 111 110 011 010 101 100 001). Bar geometry calibrated to the reference
(bars span x=48..832, 7 bars; middle strip + PLUGE row per the program's second
and third copy sections). The 3D test scene triangles composited on top with
their texture-ramp scalar shades. Output: bench_bars.png."""
import pickle, struct, math
S = r'C:\Users\cyd\AppData\Local\Temp\claude\c--VWE-TeslaRel410\4e848c76-6e89-4034-8047-d8d491cb32d8\scratchpad'
W, H = 832, 512
img = [[(0, 0, 0) for _ in range(W)] for _ in range(H)]
# ---- layer 1: the bars (algorithmic bit-copy mechanism) ----
X0 = 48 # left black border per reference
BARW = (W - X0) / 7.0
TOP_H = int(H * 0.615) # tall bars region
MID_Y1 = TOP_H + int(H * 0.115)
def bar_color(idx, lvl=191):
b = 7 - idx # descending binary: 111,110,011(?),...
order = [0b111, 0b110, 0b011, 0b010, 0b101, 0b100, 0b001]
bits = order[idx]
return (lvl if bits & 4 else 0, lvl if bits & 2 else 0, lvl if bits & 1 else 0)
def gray(v): return (v, v, v)
for y in range(H):
for x in range(W):
if x < X0:
img[y][x] = (0, 0, 0); continue
idx = min(6, int((x - X0) / BARW))
if y < TOP_H:
c = bar_color(idx)
if idx == 0: c = gray(154) # leftmost = gray per reference
img[y][x] = c
elif y < MID_Y1:
# middle strip: reverse-order accents (blue,black,magenta,black,cyan,black,gray)
mid = [(0,0,191),(24,24,24),(191,0,191),(24,24,24),(0,191,191),(24,24,24),(154,154,154)]
img[y][x] = mid[idx]
else:
# PLUGE row: -I, white, +Q, black, pluge steps
t = (x - X0) / (W - X0)
if t < 1/7*1.25: c = (16, 62, 82) # -I dark teal
elif t < 2/7*1.20: c = (192, 192, 192) # white patch
elif t < 3/7*1.15: c = (58, 0, 110) # +Q purple
elif t < 5/7: c = (22, 22, 22) # black
elif t < 5.5/7: c = (16, 16, 16)
elif t < 6/7: c = (30, 30, 30) # pluge steps
else: c = (22, 22, 22)
img[y][x] = c
buf = bytearray()
for row in img:
for r, g, b in row:
buf += bytes((r, g, b))
open(S + r'\bench_bars.ppm', 'wb').write(b'P6\n%d %d\n255\n' % (W, H) + bytes(buf))
from PIL import Image
Image.open(S + r'\bench_bars.ppm').save(S + r'\bench_bars.png')
print("painted: bench_bars.png (bars only -- the live frame)")