feos

mame lua test

Oct 28th, 2018
355
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.08 KB | None | 0 0
  1. -- launch with a scrpt:
  2. --     mame btoads -autoboot_script test.lua
  3.  
  4. screen = manager:machine().screens[":screen"]
  5. memory = manager:machine().devices[":maincpu"].spaces["program"]
  6. --screen:draw_box(20, 20, 80, 80, 0xdd000022, 0xffffffff)
  7.  
  8. function thing()
  9.     local astart = 0x4800
  10.     local asize  = 0x0400
  11.     local aend   = astart + asize - 1
  12.     local line   = 16
  13.     local word   = 2
  14.     local height = 0x0200
  15.     local chw    = 12
  16.     local chh    = 6
  17.     local chcol  = 0xffff0000
  18.     local blw    = chw*20
  19.     local blh    = chh*32
  20.    
  21.     for i=astart,aend,line do
  22.         local x = (i%line)*chw + math.floor(i/height)*blw - math.floor(i/asize)*blw*2 + 10
  23.         local y = chh*math.floor(i/line) - math.floor(i/height)*blh + 5
  24.         screen:draw_text(x, y, string.format("%04X:", i), chcol)
  25.     end
  26.    
  27.     for i=astart,aend,word do
  28.         local v = memory:read_u16(i)
  29.         local x = (i%line)*chw + math.floor(i/height)*blw - math.floor(i/asize)*blw*2 + 40
  30.         local y = chh*math.floor(i/line) - math.floor(i/height)*blh + 5
  31.         screen:draw_text(x, y, string.format("%04X", v), chcol)
  32.     end
  33. end
  34.  
  35. emu.register_frame_done(thing, "frame")
Advertisement
Add Comment
Please, Sign In to add comment