Files
siegeandClaude Opus 5.5 244fd24670 Initial commit: M1 core + SDL3 skeleton, M0 RE tooling
- tbg_core: board (10x22, ROM layout), pieces, shared piece queue, player
  (gravity, DAS, lock delay, line clear); placeholder rotation/RNG/timings
- SDL3 front end: single board, 60 Hz fixed step, next-3 preview
- core tests
- RE tooling: Ghidra seed/export scripts, 65816 disassembler, headless
  Mesen2 wrapper + Lua input/snapshot driver, asm export, NOTES.md

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-20 18:55:37 -05:00

36 lines
1.6 KiB
Lua

-- Scripted input + periodic screenshots/WRAM dumps.
-- Env: TBG_OUT (output dir), TBG_PLAN = "frame:btn+btn[/hold],..." (default hold 4 frames),
-- TBG_SHOTS = "f1,f2,...", TBG_END = last frame, TBG_SAVE_AT (frame to write <out>/state.mss),
-- TBG_LOAD (savestate loaded before frame 1; frame numbering restarts at 0)
package.path = "/home/siege/Projects/tbg/re/lua/?.lua;" .. package.path
local L = require("mech_lib")
local out = os.getenv("TBG_OUT")
local plan, shots = L.plan(os.getenv("TBG_PLAN")), {}
for f in (os.getenv("TBG_SHOTS") or ""):gmatch("%d+") do shots[tonumber(f)] = true end
local last = tonumber(os.getenv("TBG_END") or "600")
local saveAt = tonumber(os.getenv("TBG_SAVE_AT") or "-1")
local frame, held, holdLeft = 0, nil, 0
local running = not os.getenv("TBG_LOAD")
if not running then L.load(os.getenv("TBG_LOAD"), function() running = true end) end
emu.addEventCallback(function()
if held and holdLeft > 0 then
local t = {}
for b in held:gmatch("[^+]+") do t[b] = true end
emu.setInput(t, 0)
end
end, emu.eventType.inputPolled)
emu.addEventCallback(function()
if not running then return end
frame = frame + 1
holdLeft = holdLeft - 1
if plan[frame] then held, holdLeft = plan[frame][1], plan[frame][2] end
if frame == saveAt then L.save(out .. "/state.mss") end
if shots[frame] then
local h = io.open(string.format("%s/f%05d.png", out, frame), "wb"); h:write(emu.takeScreenshot()); h:close()
h = io.open(string.format("%s/f%05d.wram", out, frame), "wb"); h:write(L.wram(0, 0x20000)); h:close()
end
if frame >= last then emu.stop(0) end
end, emu.eventType.endFrame)