Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- screen = {w=256,h=231}
- pads = {
- {num=1,on=true, color="white", x=9, y=220,w=34,h=10,toggle="numpad1"},
- {num=2,on=false, color="yellow",x=54, y=220,w=34,h=10,toggle="numpad2"},
- {num=3,on=false,color="green", x=99, y=220,w=34,h=10,toggle="numpad3"},
- {num=4,on=false,color="orange",x=144,y=220,w=34,h=10,toggle="numpad4"}
- }
- buttons = {
- A = {x=30,y=5,w=3,h=3},
- B = {x=24,y=5,w=3,h=3},
- select = {x=18,y=7,w=3,h=1},
- start = {x=12,y=7,w=3,h=1},
- up = {x=4, y=1,w=2,h=2},
- down = {x=4, y=7,w=2,h=2},
- left = {x=1, y=4,w=2,h=2},
- right = {x=7, y=4,w=2,h=2}
- }
- text = {on=false,x=1, y=9,w=30,h=16,toggle="numpad5"}
- timer = {on=true,x=193,y=220,w=58,h= 7,toggle="numpad6"}
- function drawpad(pad)
- gui.drawbox( pad.x, pad.y, pad.x+pad.w, pad.y+pad.h, "#3070ffb0" )
- gui.drawbox( pad.x+4, pad.y+4, pad.x+6, pad.y+6, "black" )
- controller = joypad.read(pad.num)
- for name, b in pairs(buttons) do
- gui.drawbox( pad.x + b.x, pad.y + b.y, pad.x + b.x + b.w, pad.y + b.y + b.h,
- controller[name] and pad.color or "black" )
- end
- end
- function mouseover(pad, margin)
- return keys.xmouse >= pad.x-margin and keys.xmouse <= pad.x+pad.w+margin and
- keys.ymouse >= pad.y-margin and keys.ymouse <= pad.y+pad.h+margin
- end
- function inrange(upper, lower, testval)
- if testval >= upper then return upper
- elseif testval <= lower then return lower
- else return testval
- end
- end
- function concat(tables)
- local res = {}
- for _, tab in ipairs(tables) do
- for _, val in ipairs(tab) do
- table.insert(res, val)
- end
- end
- return res
- end
- prev_keys = input.get()
- objects = concat({pads, {text, timer}})
- function everything()
- keys = input.get()
- -- Actually draw the stuff
- if timer.on then
- mins = math.floor(movie.framecount()/3600)
- secs = movie.framecount()/60-mins*60
- gui.text( timer.x, timer.y, string.format("%s:%05.2f",os.date("!%H:%M",mins*60),secs), "white" )
- end
- if text.on then
- local done = movie.mode() == "finished" or movie.mode() == nil
- gui.text( text.x, text.y, movie.framecount(), done and "white" )
- gui.text( text.x, text.y + 9, FCEU.lagcount(), FCEU.lagged() and "red" )
- end
- for _, pad in ipairs(pads) do
- if pad.on then drawpad(pad) end
- end
- prev_keys = keys
- end
- gui.register(everything)
- while (true) do
- FCEU.frameadvance()
- end
Add Comment
Please, Sign In to add comment