Guest User

Untitled

a guest
Jun 24th, 2018
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.27 KB | None | 0 0
  1. screen = {w=256,h=231}
  2.  
  3. pads = {
  4. {num=1,on=true, color="white", x=9, y=220,w=34,h=10,toggle="numpad1"},
  5. {num=2,on=false, color="yellow",x=54, y=220,w=34,h=10,toggle="numpad2"},
  6. {num=3,on=false,color="green", x=99, y=220,w=34,h=10,toggle="numpad3"},
  7. {num=4,on=false,color="orange",x=144,y=220,w=34,h=10,toggle="numpad4"}
  8. }
  9.  
  10. buttons = {
  11. A = {x=30,y=5,w=3,h=3},
  12. B = {x=24,y=5,w=3,h=3},
  13. select = {x=18,y=7,w=3,h=1},
  14. start = {x=12,y=7,w=3,h=1},
  15. up = {x=4, y=1,w=2,h=2},
  16. down = {x=4, y=7,w=2,h=2},
  17. left = {x=1, y=4,w=2,h=2},
  18. right = {x=7, y=4,w=2,h=2}
  19. }
  20.  
  21. text = {on=false,x=1, y=9,w=30,h=16,toggle="numpad5"}
  22. timer = {on=true,x=193,y=220,w=58,h= 7,toggle="numpad6"}
  23.  
  24. function drawpad(pad)
  25. gui.drawbox( pad.x, pad.y, pad.x+pad.w, pad.y+pad.h, "#3070ffb0" )
  26. gui.drawbox( pad.x+4, pad.y+4, pad.x+6, pad.y+6, "black" )
  27. controller = joypad.read(pad.num)
  28. for name, b in pairs(buttons) do
  29. gui.drawbox( pad.x + b.x, pad.y + b.y, pad.x + b.x + b.w, pad.y + b.y + b.h,
  30. controller[name] and pad.color or "black" )
  31. end
  32. end
  33.  
  34. function mouseover(pad, margin)
  35. return keys.xmouse >= pad.x-margin and keys.xmouse <= pad.x+pad.w+margin and
  36. keys.ymouse >= pad.y-margin and keys.ymouse <= pad.y+pad.h+margin
  37. end
  38.  
  39. function inrange(upper, lower, testval)
  40. if testval >= upper then return upper
  41. elseif testval <= lower then return lower
  42. else return testval
  43. end
  44. end
  45.  
  46. function concat(tables)
  47. local res = {}
  48. for _, tab in ipairs(tables) do
  49. for _, val in ipairs(tab) do
  50. table.insert(res, val)
  51. end
  52. end
  53. return res
  54. end
  55.  
  56. prev_keys = input.get()
  57. objects = concat({pads, {text, timer}})
  58.  
  59. function everything()
  60. keys = input.get()
  61.  
  62.  
  63. -- Actually draw the stuff
  64. if timer.on then
  65. mins = math.floor(movie.framecount()/3600)
  66. secs = movie.framecount()/60-mins*60
  67. gui.text( timer.x, timer.y, string.format("%s:%05.2f",os.date("!%H:%M",mins*60),secs), "white" )
  68. end
  69.  
  70. if text.on then
  71. local done = movie.mode() == "finished" or movie.mode() == nil
  72. gui.text( text.x, text.y, movie.framecount(), done and "white" )
  73. gui.text( text.x, text.y + 9, FCEU.lagcount(), FCEU.lagged() and "red" )
  74. end
  75.  
  76. for _, pad in ipairs(pads) do
  77. if pad.on then drawpad(pad) end
  78. end
  79.  
  80. prev_keys = keys
  81. end
  82.  
  83. gui.register(everything)
  84.  
  85. while (true) do
  86. FCEU.frameadvance()
  87. end
Add Comment
Please, Sign In to add comment