Files
siegeandClaude Opus 5.5 12ee5d17c6 re: big clear, danger, round-win mark, pause-screen moods, stock orbs/netting, preview minis
re/notes/anim_battle_extra.md + re/tools/anim_extra.py (ROM-only renders, flight path validated
frame-exact vs capture) + re/lua/anim_pause.lua. Corrects battle.md: stocks are netted at each
state 00 (81:D6AE), confirmed in Mesen.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-21 17:03:39 -05:00

58 lines
3.2 KiB
Lua

-- Pause-screen capture: from TBG_LOAD, writes TBG_B1/TBG_B2 boards, P1 presses Start at frame 30, then the
-- TBG_SEQ presses ("frame:button[:pad]" list, pad 0/1), screenshots every TBG_SHOTEVERY frames, CGRAM/VRAM dumps
-- at TBG_VRAMAT frames, TBG_POKE "addr=val,..." at frame 3, TBG_WATCH write log. Env: TBG_LIB TBG_LOAD TBG_OUT TBG_SPAN
local L = dofile(os.getenv("TBG_LIB"))
local out = os.getenv("TBG_OUT")
local W = emu.memType.snesWorkRam
local span = tonumber(os.getenv("TBG_SPAN") or "300")
local every = tonumber(os.getenv("TBG_SHOTEVERY") or "4")
local vramat = {}
for f in (os.getenv("TBG_VRAMAT") or ""):gmatch("%d+") do vramat[tonumber(f)] = true end
local seq = {}
for f, b, p in (os.getenv("TBG_SEQ") or "30:start"):gmatch("(%d+):(%a+):?(%d?)") do
seq[#seq + 1] = {tonumber(f), b, tonumber(p ~= "" and p or "0")}
end
local function readfile(p) if not p or p == "" then return nil end local h = io.open(p, "rb"); local d = h:read("a"); h:close(); return d end
local b1, b2 = readfile(os.getenv("TBG_B1")), readfile(os.getenv("TBG_B2"))
local function dumpmem(path, mt, size)
local t = {}
for i = 0, size - 1 do t[#t + 1] = string.char(emu.read(i, mt)) end
local h = io.open(path, "wb"); h:write(table.concat(t)); h:close()
end
local frame = 0
local st = io.open(out .. "/state.txt", "w")
L.load(os.getenv("TBG_LOAD"))
-- TBG_WATCH "hex,hex": log writes to these low-RAM addresses (all bank mirrors) with the writing PC
for a in (os.getenv("TBG_WATCH") or ""):gmatch("%x+") do
local ad = tonumber(a, 16)
local function cb(addr, v) st:write(string.format("W %d %04X=%02X pc=%06X\n", frame, ad, v, L.pc())) end
emu.addMemoryCallback(cb, emu.callbackType.write, 0x7E0000 | ad, 0x7E0000 | ad)
for _, base in ipairs({0x00, 0x80}) do
for bank = base, base + 0x3F do emu.addMemoryCallback(cb, emu.callbackType.write, (bank << 16) | ad, (bank << 16) | ad) end
end
end
emu.addEventCallback(function()
local t = {{}, {}}
for _, s in ipairs(seq) do if frame >= s[1] and frame < s[1] + 3 then t[s[3] + 1][s[2]] = true end end
emu.setInput(t[1], 0); emu.setInput(t[2], 1)
end, emu.eventType.inputPolled)
emu.addEventCallback(function()
frame = frame + 1
if frame == 3 then
if b1 then for i = 1, 220 do emu.write(0x295 + i, b1:byte(i), W) end end
if b2 then for i = 1, 220 do emu.write(0x4F5 + i, b2:byte(i), W) end end
for a, v in (os.getenv("TBG_POKE") or ""):gmatch("(%x+)=(%x+)") do emu.write(tonumber(a, 16), tonumber(v, 16), W) end
end
local s = {}
for _, a in ipairs({0xD0, 0x20D, 0x46D, 0x139, 0x13A, 0x170, 0x22D, 0xCF, 0xDE, 0xE0, 0xE1}) do
s[#s + 1] = string.format("%02X", emu.read(a, W))
end
st:write(frame .. " " .. table.concat(s, " ") .. " " .. string.format("%02X %02X", emu.read(0x7E2630, emu.memType.snesMemory), emu.read(0x7E2631, emu.memType.snesMemory)) .. "\n")
if every > 0 and frame % every == 0 then L.shot(string.format("%s/s%04d.png", out, frame)) end
if vramat[frame] then
dumpmem(string.format("%s/v%04d.vram", out, frame), emu.memType.snesVideoRam, 0x10000)
dumpmem(string.format("%s/c%04d.cgram", out, frame), emu.memType.snesCgRam, 0x200)
end
if frame >= span then st:close(); emu.stop(0) end
end, emu.eventType.endFrame)