Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- this outputs some information related to the map loading procedure when the screen scrolls,
- -- hopefully helpful for researching and recreating the scroll bug
- -- script by mugg ; with help from ais523, Sand
- console.clear()
- memory.usememorydomain("System Bus")
- local cycles_at_frame_start = emu.totalexecutedcycles()
- local cycles_at_frame_end = emu.totalexecutedcycles()
- local print_after_this_frame = emu.framecount() + 1
- local game_version = "-"
- local t = ""
- if gameinfo.getromhash() == "3A4DDB39B234A67FFB361EE7ABC3D23E0A8B1C89" then
- game_version = "1.0"
- elseif gameinfo.getromhash() == "418203621B887CAA090215D97E3F509B79AFFD3E" then
- game_version = "1.1"
- else
- print("This script will work only with GB Super Mario Land v1.0 or v1.1.")
- return
- end
- function text(x, y, text, color, backcolor)
- gui.pixelText(x, y, text, color, backcolor)
- end
- event.onframestart(function()
- cycles_at_frame_start = emu.totalexecutedcycles()
- end)
- event.onframeend(function()
- if emu.framecount() > print_after_this_frame then
- t = t .. "\nCycles this frame: " .. emu.totalexecutedcycles() - cycles_at_frame_end
- end
- if emu.islagged() then
- t = t .. "\n*** LAG ***"
- end
- cycles_at_frame_end = emu.totalexecutedcycles()
- t = t .. "\n\n----- Frame " .. emu.framecount() + 1 .. " -----"
- print(t)
- t = ""
- loadedstate = false
- end)
- tastudio.onbranchload(function()
- print_after_this_frame = emu.framecount() + 1
- console.clear()
- end)
- event.onloadstate(function()
- print_after_this_frame = emu.framecount() + 1
- console.clear()
- end)
- -- Write to $FFEA
- -- passed val is always 0, it seems, hinting that this hook is not fully implemented
- event.on_bus_write(function(addr, val, flags)
- if emu.framecount() > print_after_this_frame then
- local val = string.upper(string.format("%02x",memory.read_u8(0xFFEA)))
- t = t .. "\nWrite $FFEA (" .. val .. ") - current cycle: " .. emu.totalexecutedcycles() - cycles_at_frame_start
- end
- end, 0xFFEA)
- -- Exec $0040
- event.on_bus_exec(function(addr, val, flags)
- if emu.framecount() > print_after_this_frame then
- t = t .. "\nExecu $0040 (VBLANK) - current cycle: " .. emu.totalexecutedcycles() - cycles_at_frame_start
- end
- end, 0x0040)
- -- game version dependent execs
- if game_version == "1.0" then
- event.on_bus_exec(function(addr, val, flags)
- if emu.framecount() > print_after_this_frame then
- t = t .. "\nExecu $2258 (READ $FFEA) - current cycle: " .. emu.totalexecutedcycles() - cycles_at_frame_start
- end
- end, 0x224F)
- event.on_bus_exec(function(addr, val, flags)
- if emu.framecount() > print_after_this_frame then
- t = t .. "\nExecu $2254 (READ $FFE9) - current cycle: " .. emu.totalexecutedcycles() - cycles_at_frame_start
- end
- end, 0x2254)
- elseif game_version == "1.1" then
- event.on_bus_exec(function(addr, val, flags)
- if emu.framecount() > print_after_this_frame then
- t = t .. "\nExecu $2258 (READ $FFEA) - current cycle: " .. emu.totalexecutedcycles() - cycles_at_frame_start
- end
- end, 0x2258)
- event.on_bus_exec(function(addr, val, flags)
- if emu.framecount() > print_after_this_frame then
- t = t .. "\nExecu $225D (READ $FFE9) - current cycle: " .. emu.totalexecutedcycles() - cycles_at_frame_start
- end
- end, 0x225D)
- end
- --[[
- Read hook seems broken, maybe I should be using execution from ROM instead.
- -- Read $FFEA
- event.on_bus_read(function(addr, val, flags)
- if emu.framecount() > print_after_this_frame then
- local val = string.upper(string.format("%02x",memory.read_u8(0xFFEA)))
- print("Read $FFEA (" .. val .. ") - current cycle: " .. emu.totalexecutedcycles() - cycles_at_frame_start)
- end
- end, 0xFFEA)
- -- Read $FFE9
- event.on_bus_read(function(addr, val, flags)
- if emu.framecount() > print_after_this_frame then
- local val = string.upper(string.format("%02x",memory.read_u8(0xFFE9)))
- print("Read $FFE9 (" .. val .. ") - current cycle: " .. emu.totalexecutedcycles() - cycles_at_frame_start)
- end
- end, 0xFFE9)
- ]]
- while true do
- emu.frameadvance()
- end
Advertisement
Add Comment
Please, Sign In to add comment