Advertisement
Guest User

Untitled

a guest
Apr 3rd, 2016
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.42 KB | None | 0 0
  1. -- Luascript for bizhawk 1.11.6
  2. -- by mugg1991
  3. -- Motocross Maniacs gb
  4.  
  5. function text(x, y, text, color)
  6.     gui.pixelText(x, y, text,color,0x00000000)
  7. end
  8.  
  9. ----------------------------------------------------------------------
  10. local drawFrameCountAndInput = function(x,y)
  11.  
  12.     if movie.mode()=="PLAY" then
  13.         text(x, y,emu.framecount().."/"..movie.length(),0xFFFFFFFF)
  14.     else
  15.         text(x, y,emu.framecount(),0xFFFFFFFF)
  16.     end
  17.        
  18.     text(x, y+8,emu.lagcount(),0xFFF05050)
  19.  
  20.     if emu.islagged() then
  21.         text(x-5, y+8,"*",0xFFF05050)
  22.     end
  23.    
  24.     local inputtable = {}
  25.    
  26.     if movie.mode()=="INACTIVE" then
  27.         inputtable = joypad.getimmediate()
  28.     elseif movie.mode()=="PLAY" or movie.mode()=="RECORD" then
  29.         inputtable = movie.getinput(emu.framecount()-1)
  30.     end
  31.    
  32.     local buttons = {["Up"]="^", ["Down"]="v", ["Left"]="<", ["Right"]=">", ["Select"]="s", ["Start"]="S", ["A"]="A", ["B"]="B", ["L"]="L", ["R"]="R"}
  33.     local s = ""
  34.     for k,v in pairs(inputtable) do
  35.         if v==true then
  36.             s=s..buttons[k]
  37.         end
  38.     end
  39.     text(x,y+16,s,0xFFffffff)
  40.  
  41. end
  42.  
  43. function hex(num)
  44.    local dig = 2
  45.    local hexstr = '0123456789ABCDEF'
  46.    local s = ''
  47.    --while num > 0 do
  48.    while dig > 0 do -- use digit instead so there is padding
  49.        local mod = math.fmod(num, 16)
  50.        s = string.sub(hexstr, mod+1, mod+1) .. s
  51.        num = math.floor(num / 16)
  52.        dig = dig - 1
  53.    end
  54.    if s == '' then s = '0' end
  55.    return s
  56. end
  57.  
  58. client.SetGameExtraPadding(0,28,0,0)
  59.  
  60. memory.usememorydomain("System Bus")
  61.  
  62. itemTable = {
  63. [-1] = "?",
  64. [2] = "S",
  65. [3] = "T",
  66. [4] = "N",
  67. [5] = "R",
  68. [6] = "J",
  69. [7] = "Biker",
  70. }
  71.  
  72. while true do
  73.    
  74.     --declare values:
  75.     Minutes = memory.read_u8(0xc804)
  76.     Seconds = memory.read_u8(0xc803)
  77.     Milliseconds = memory.read_u8(0xc802)
  78.     MinutesLeft = memory.read_u8(0xc882)
  79.     SecondsLeft = memory.read_u8(0xc881)
  80.     MillisecondsLeft = memory.read_u8(0xc880)
  81.     Speed1 = memory.read_s8(0xc810) -- pixels to advance screen
  82.     Speed2 = memory.read_u16_le(0xc38a)
  83.     Nitros1 = memory.read_u8(0xc792)
  84.     Nitros2 = memory.read_u8(0xc812)
  85.     Indicator = memory.read_u8(0xc780)
  86.     if Indicator==1 then Nitros=Nitros1 else Nitros=Nitros2 end
  87.     X = memory.read_u16_le(0xe903)
  88.     --Y = ?
  89.     Xcam = memory.read_u24_le(0xc902)
  90.     Ycam = memory.read_u16_le(0xc900)
  91.    
  92.     --display values:
  93.     text(45,2,"Time",0x80FFFFFF)   
  94.     text(65,2,hex(Minutes)..":"..hex(Seconds).."."..hex(Milliseconds),0xFFFFFFFF)  
  95.    
  96.     text(49,10,"Gas",0x80FFFFFF)
  97.     text(65,10,hex(MinutesLeft)..":"..hex(SecondsLeft).."."..hex(MillisecondsLeft),0xFFFFFFFF)
  98.    
  99.     text(118,2,"Spd",0x80FFFFFF)
  100.     text(134,2,Speed2,0xFFFFFFFF)
  101.    
  102.     text(118,10,"Ntr",0x80FFFFFF)  
  103.     text(134,10,Nitros,0xFFFFFFFF) 
  104.    
  105.     text(118,18,"pos",0x80FFFFFF)  
  106.     text(134,18,X,0xFFFFFFFF)  
  107.    
  108.     text(33,18,"cam",0x80FFFFFF)   
  109.     text(48,18,Xcam,0xFFFFFFFF)
  110.     text(80,18,Ycam,0xFFFFFFFF)
  111.    
  112.     --display items:
  113.     for i=0,64,4 do
  114.        
  115.         item_type = memory.read_u8(0xca00+i)
  116.         if item_type < 2 or item_type > 7 then item_type=-1 end
  117.         item_status = memory.read_u8(0xca01+i)
  118.         item_x = memory.read_u8(0xca03+i)
  119.         item_y = memory.read_u8(0xca02+i)
  120.         item_xcam = item_x-Xcam/256
  121.         item_ycam = item_y-Ycam/256+28
  122.    
  123.         if item_status~=0 or item_y~=0 then
  124.             gui.drawBox(item_xcam,item_ycam,item_xcam+16,item_ycam+16,0x80FF0000,0xD0FFFFFF)
  125.             text(item_xcam+1,item_ycam+1,itemTable[item_type],0xFF000000)
  126.             text(item_xcam+1,item_ycam+8,item_status,0xFF000000)
  127.         end
  128.        
  129.     end
  130.    
  131.    
  132.     drawFrameCountAndInput(10,2)
  133.     emu.frameadvance()
  134.  
  135. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement