Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- PARAMETERS
- local END_OF_VBLANK = 0x2C3
- local END_OF_GAME_LOOP = 0x75
- -- location in ROM space, e.g. $0082C3 = 0x2C3
- -------------
- local V_TOP = 1
- local V_BOTTOM = 38
- local H_LEFT = 22
- local H_RIGHT = 62
- local vv, vh = -20, -30
- local gv, gh = -20, -30
- local lag = 0
- local function get_vblank_scan()
- lag = lag + 1
- vh = memory.getregister("hcounter")
- vv = memory.getregister("vcounter")
- end
- memory.registerexec("ROM",END_OF_VBLANK,get_vblank_scan)
- local function get_game_scan()
- lag = 0
- gv = memory.getregister("vcounter")
- gh = memory.getregister("hcounter")
- end
- memory.registerexec("ROM",END_OF_GAME_LOOP,get_game_scan)
- function on_paint()
- gui.top_gap(2*V_TOP)
- gui.left_gap(2*H_LEFT)
- gui.right_gap(2*H_RIGHT)
- gui.bottom_gap(2*V_BOTTOM)
- if lag ~= 0 then
- gui.rectangle(2*(0-H_LEFT),2*(0-V_TOP),2*340,2*263,0x6000FF00,0x6000FF00)
- else
- if gv < 0xE1 then
- gui.rectangle(2*(0-H_LEFT),2*(0xE1-V_TOP),2*340,2*38,0x6000FF00,0x6000FF00)
- gui.rectangle(2*(0-H_LEFT),2*(0-V_TOP),2*340,2*gv,0x6000FF00,0x6000FF00)
- gui.rectangle(2*(0-H_LEFT),2*(gv-V_TOP),2*(math.floor(gh/4)),2*1,0x6000FF00,0x6000FF00)
- else
- gui.rectangle(2*(0-H_LEFT),2*(0xE1-V_TOP),2*340,2*(gv-0xE1),0x6000FF00,0x6000FF00)
- gui.rectangle(2*(0-H_LEFT),2*(gv-V_TOP),2*(math.floor(gh/4)),2*1,0x6000FF00,0x6000FF00)
- end
- end
- if vv < 0xE1 then
- gui.rectangle(2*(0-H_LEFT),2*(0xE1-V_TOP),2*340,2*38,0x60FF0000,0x60FF0000)
- gui.rectangle(2*(0-H_LEFT),2*(0-V_TOP),2*340,2*vv,0x60FF0000,0x60FF0000)
- gui.rectangle(2*(0-H_LEFT),2*(vv-V_TOP),2*(math.floor(vh/4)),2*1,0x60FF0000,0x60FF0000)
- else
- gui.rectangle(2*(0-H_LEFT),2*(0xE1-V_TOP),2*340,2*(vv-0xE1),0x60FF0000,0x60FF0000)
- gui.rectangle(2*(0-H_LEFT),2*(vv-V_TOP),2*(math.floor(vh/4)),2*1,0x60FF0000,0x60FF0000)
- end
- gui.text(10,10,"lag: " .. lag)
- gui.text(10,30,"game: (" .. gv .. "," .. gh .. ")")
- gui.text(10,50,"vblank: (" .. vv .. "," .. vh .. ")")
- end
- gui.repaint()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement