local dbg = manager.machine.debugger local gsu_tag = nil for tag, dev in pairs(manager.machine.devices) do if dev.shortname == "superfx1" or dev.shortname == "superfx2" then gsu_tag = tag end end if gsu_tag == nil then print("NOGSU"); manager.machine:exit(); return end print("GSU " .. gsu_tag .. " " .. manager.machine.devices[gsu_tag].shortname) dbg.visible_cpu = manager.machine.devices[gsu_tag] if true then dbg:command('dasm /data/emu/gsu-python/tests/mame_traces/StarFox_dasm_06/program.dasm,068000,8000,1,' .. gsu_tag) for _, line in ipairs(dbg.consolelog) do print("CON " .. line) end manager.machine:exit() return end local function watch(start, length, kind, cond, tag) dbg:command('wpset ' .. start .. ':maincpu,' .. length .. ',' .. kind .. ',' .. cond .. ',{logerror "' .. tag .. ' %X %X %d\\n",wpaddr,wpdata,totalcycles; g}') end -- The GSU's registers and cache RAM in the banks the S-CPU uses (all of -- 00-3F/80-BF with --all-banks: slower, every ROM read there meets the tap). for _, bank in ipairs({"00", "80"}) do watch(bank .. "3000", "500", "r", "1", "R") watch(bank .. "3000", "500", "w", "1", "W") end if false then watch("013000", "3F0500", "r", "(wpaddr & ffff) >= 3000 && (wpaddr & ffff) < 3500 && (wpaddr & ff0000) != 0", "R") watch("013000", "3F0500", "w", "(wpaddr & ffff) >= 3000 && (wpaddr & ffff) < 3500 && (wpaddr & ff0000) != 0", "W") watch("813000", "3F0500", "r", "(wpaddr & ffff) >= 3000 && (wpaddr & ffff) < 3500 && (wpaddr & ff0000) != 800000", "R") watch("813000", "3F0500", "w", "(wpaddr & ffff) >= 3000 && (wpaddr & ffff) < 3500 && (wpaddr & ff0000) != 800000", "W") end if false then watch("700000", "20000", "w", "1", "W") watch("006000", "400000", "w", "(wpaddr & e000) == 6000", "W") watch("806000", "400000", "w", "(wpaddr & e000) == 6000", "W") end if false then watch("002116", "3", "w", "1", "V") end local function start() dbg.visible_cpu = manager.machine.devices[gsu_tag] dbg:command('trace /dev/null,' .. gsu_tag .. ',noloop,{' .. 'logerror "G %X %X %X %X %X %X %X %X %X %X %X %X %X %d\\n",pc,r0,r1,r2,r3,r4,r5,r6,r7,r8,r9,r10,r11,totalcycles; ' .. 'logerror "H %X %X %X %X %X %X %X %X %X %X %X %X %d\\n",r12,r13,r14,r15,sfr,pbr,rombr,rambr,cbr,colr,por,ramaddr,totalcycles}') for _, line in ipairs(dbg.consolelog) do print("CON " .. line) end end local started = false if not started and 0 == 0 then start(); started = true end for _, line in ipairs(dbg.consolelog) do print("CON " .. line) end dbg:command("go") local screen = manager.machine.screens[":screen"] -- Button presses: {frame, field name, frames held}, matched against every input field's name. local presses = {} local fields = {} for ptag, port in pairs(manager.machine.ioport.ports) do for fname, fld in pairs(port.fields) do fields[fname] = fld if false then print("INPUT " .. ptag .. " | " .. fname) end end end for _, p in ipairs(presses) do if fields[p[2]] == nil then print("NOINPUT " .. p[2]) end end sub = emu.add_machine_frame_notifier(function() local frame = screen:frame_number() for _, p in ipairs(presses) do local fld = fields[p[2]] if fld ~= nil then if frame == p[1] then fld:set_value(1) end if frame == p[1] + p[3] then fld:clear_value() end end end if not started and frame >= 0 then started = true; start() end if 0 > 0 and frame % 0 == 0 then manager.machine.video:snapshot() end if frame >= 60 then manager.machine:exit() end end)