Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Luascript for Bizhawk 1.11.6
- -- by mugg1991 17th Aug 2016
- -- Hyper Lode Runner (W) (v1.1).gb
- memory.usememorydomain("System Bus")
- client.setwindowsize(2)
- function text(x, y, text, col1, col2)
- if col2==nil then col2=0x00000000 end
- gui.pixelText(x, y, text,col1,col2)
- end
- function box(x,y,x2,y2,col1,col2)
- gui.drawBox(x,y,x2,y2,col1,col2)
- end
- function line(x,y,x2,y2,col)
- gui.drawLine(x,y,x2,y2,col)
- end
- function pixel(x,y,col)
- gui.drawPixel(x,y,col)
- end
- function img(x,y,path)
- gui.drawImage(path,x,y)
- end
- function drawButton(posx,posy,width,height,color,frequency,label,clickedfunction)
- if MouseX>posx and MouseX<posx+width and MouseY>posy and MouseY<posy+height then
- if clicked and clickedFrames%frequency==1 then
- clickedfunction()
- end
- gui.drawBox(posx,posy,posx+width,posy+height,0xFF808080,color+0xFF303030)
- else
- gui.drawBox(posx,posy,posx+width,posy+height,0xFF808080,color)
- end
- text(posx+1,posy+1,label,0xFFFFFFFF)
- end
- levelMap={}
- room2_timerBefore=memory.read_u8(0xc049)
- BoolDisplayLevelMap=true
- BoolDisplayPlayers=true
- BoolDisplayCameraOutline=false
- BoolHighlightRespawnLocations=false
- clickedFrames=0
- clicked=false
- local drawFramecountAndInput = function(x,y)
- if movie.mode()=="PLAY" then
- text(x, y,emu.framecount().."/"..movie.length(),0xFFFFFFFF)
- else
- text(x, y,emu.framecount(),0xFFFFFFFF)
- end
- text(x, y+8,emu.lagcount(),0xFFF08080)
- if emu.islagged() then
- text(x+14, y+8,"*",0xFFF08080)
- end
- local inputtable = {}
- if movie.mode()=="INACTIVE" then
- inputtable = joypad.getimmediate()
- elseif movie.mode()=="PLAY" or movie.mode()=="RECORD" then
- inputtable = movie.getinput(emu.framecount()-1)
- end
- local buttons = {["Up"]="^", ["Down"]="v", ["Left"]="<", ["Right"]=">", ["Select"]="s", ["Start"]="S", ["A"]="A", ["B"]="B", ["L"]="L", ["R"]="R"}
- local s = ""
- for k,v in pairs(inputtable) do
- if v==true then
- s=s..buttons[k]
- end
- end
- text(x+26,y+8,s,0xFFffffff)
- end
- local updateLevelMap = function()
- levelMap={}
- for i=0,288,1 do
- value=memory.read_s8(0xC96B+i)
- value=string.format("%X",value)
- table.insert(levelMap,value)
- end
- end
- local drawCameraOutline = function()
- box(10,49,83,50+camy,0x00000000,0xA0000000) -- top
- if camy < 16 then box(10,98+camy,83,114,0x00000000,0xA0000000) end -- bottom
- if camx > 5 then box(10,49+camy,5+camx,math.min(99+camy,114),0x00000000,0xA0000000) end -- left
- if camx < 34 then box(camx+59,camy+49,83,math.min(99+camy,114),0x00000000,0xA0000000) end -- right
- box(math.max(5+camx,10),49+camy,math.min(54+camx+5,83),math.min(98+camy,114),0xFFA0A020,0x08FFFFFF)
- --text(100,50,camx,0x80000000,0xFFFFFFFF)
- --text(100,60,camy,0x80000000,0xFFFFFFFF)
- end
- local drawPlayers = function()
- text(10+player_xpos,49+player_ypos,"x",0xFF00FF00)
- if enemy1_exists then
- text(10+enemy1_xpos,49+enemy1_ypos,"1",0xFFFFFFFF)
- end
- if enemy2_exists then
- text(10+enemy2_xpos,49+enemy2_ypos,"2",0xFFFFFFFF)
- end
- if enemy3_exists then
- text(10+enemy3_xpos,49+enemy3_ypos,"3",0xFFFFFFFF)
- end
- end
- local drawLevelMap = function()
- if emu.framecount()%15==0 then
- updateLevelMap()
- end
- index=1
- if table.getn(levelMap)~=0 then
- for a=1,16,1 do
- for b=1,18,1 do
- if levelMap[index] ..""==0 .."" then --brick
- box(6+b*4,45+a*4,11+b*4,50+a*4,0x00000000,0xFF805010)
- elseif levelMap[index] ..""==1 .."" then --block
- box(6+b*4,45+a*4,11+b*4,50+a*4,0x00000000,0xFF606060)
- elseif levelMap[index] ..""==2 .."" then --ladder
- line(7+b*4,46+a*4,7+b*4,49+a*4,0xFFC04040)
- line(10+b*4,46+a*4,10+b*4,49+a*4,0xFFC04040)
- line(7+b*4,46+a*4,10+b*4,46+a*4,0xFFC04040)
- line(7+b*4,48+a*4,10+b*4,48+a*4,0xFFC04040)
- elseif levelMap[index] ..""==3 .."" then --hanging rope
- line(7+b*4,47+a*4,10+b*4,47+a*4,0xFFC0A070)
- elseif levelMap[index] ..""==4 .."" then --gold
- line(8+b*4,47+a*4,9+b*4,47+a*4,0xFFC0A020)
- line(7+b*4,48+a*4,10+b*4,48+a*4,0xFFC0A020)
- line(7+b*4,49+a*4,10+b*4,49+a*4,0xFFC0A020)
- elseif levelMap[index] ..""==25 .."" then --hidden ladder
- line(7+b*4,46+a*4,7+b*4,49+a*4,0xFF702020)
- line(10+b*4,46+a*4,10+b*4,49+a*4,0xFF702020)
- line(7+b*4,46+a*4,10+b*4,46+a*4,0xFF702020)
- line(7+b*4,48+a*4,10+b*4,48+a*4,0xFF702020)
- elseif levelMap[index] ..""==9 .."" then --key
- line(6+b*4,47+a*4,8+b*4,47+a*4,0xFF904090)
- pixel(6+b*4,48+a*4,0xFF904090)
- pixel(10+b*4,47+a*4,0xFF904090)
- line(9+b*4,48+a*4,10+b*4,48+a*4,0xFF904090)
- line(8+b*4,46+a*4,10+b*4,46+a*4,0xFF904090)
- elseif levelMap[index] ..""==8 .."" then --door
- box(7+b*4,46+a*4,10+b*4,50+a*4,0x00000000,0xFF600060)
- line(7+b*4,47+a*4,7+b*4,49+a*4,0xFF904090)
- line(8+b*4,46+a*4,9+b*4,46+a*4,0xFF904090)
- line(10+b*4,47+a*4,10+b*4,49+a*4,0xFF904090)
- elseif levelMap[index] ..""==10 .."" then --trap block
- box(6+b*4,45+a*4,11+b*4,50+a*4,0x00000000,0xFF104010)
- end
- index=index+1
- if index>table.getn(levelMap) then index=table.getn(levelMap) end
- end
- end
- end
- end
- event.onloadstate(function()
- updateLevelMap()
- room2_timerBefore=memory.read_u8(0xc049)
- end)
- event.onexit(function()
- client.SetGameExtraPadding(0,0,0,0)
- client.SetClientExtraPadding(0,0,0,0)
- end)
- client.SetGameExtraPadding(95,0,0,0)
- updateLevelMap()
- while true do
- MouseX = input.getmouse().X+95
- MouseY = input.getmouse().Y
- clicked = input.getmouse().Left
- if clicked then clickedFrames = clickedFrames + 1
- else clickedFrames = 0 end
- player_xpos= (memory.read_u8(0xc003)-22)/3
- player_ypos= memory.read_u8(0xc005)/3
- enemy1_xpos= (memory.read_u8(0xc013)-22)/3
- enemy1_ypos= memory.read_u8(0xc015)/3
- enemy2_xpos= (memory.read_u8(0xc023)-22)/3
- enemy2_ypos= memory.read_u8(0xc025)/3
- enemy3_xpos= (memory.read_u8(0xc033)-22)/3
- enemy3_ypos= memory.read_u8(0xc035)/3
- camx= memory.read_u8(0xffcc)/3
- camy= memory.read_u8(0xffce)/3
- camx_restriction= memory.read_u8(0xffd2)/3
- camy_restriction= memory.read_u8(0xffd3)/3
- enemy1_droptimer=0
- enemy2_droptimer=0
- enemy3_droptimer=0
- if memory.read_u8(0xc010)>0 then
- enemy1_exists=true
- else enemy1_exists=false end
- if memory.read_u8(0xc020)>0 then
- enemy2_exists=true
- else enemy2_exists=false end
- if memory.read_u8(0xc030)>0 then
- enemy3_exists=true
- else enemy3_exists=false end
- if enemy1_exists and memory.read_u8(0xc01F)==0xFF then
- enemy1_droptimer= memory.read_u8(0xc019)
- end
- if enemy2_exists and memory.read_u8(0xc02F)==0xFF then
- enemy2_droptimer= memory.read_u8(0xc029)
- end
- if enemy3_exists and memory.read_u8(0xc03F)==0xFF then
- enemy3_droptimer= memory.read_u8(0xc039)
- end
- globaltimer= memory.read_u8(0xffd4)
- room2_timer= memory.read_u8(0xc049)
- if memory.read_u8(0xc1b0)==0 then
- room=1
- elseif memory.read_u8(0xc1b0)==3 then
- room=2
- else
- room=-1
- end
- level= memory.read_u8(0xff9d)+1 .. "-" .. room
- if memory.read_u8(0xff96)==0 and room==2 then
- if room2_timer==0 then
- room2_timer=-1
- room2_timerBefore=room2_timer
- elseif room2_timer==30 and room2_timerBefore==0 then
- room2_timer=-1
- room2_timerBefore=room2_timer
- elseif room2_timerBefore==-1 then
- room2_timer=-1
- else
- room2_timerBefore=room2_timer-1
- room2_timer=room2_timer-1 .. ":" .. 64-(globaltimer-1)%64 -1
- end
- else
- room2_timer="-"
- end
- gold_left= memory.read_u8(0xffb4)
- if gold_left==0xFF then gold_left="done!" end
- -- background gradient
- for s=1,18,1 do
- col=0x80606060 - s*0x07000000
- box(-5+4*s,-1,4*s,160,0x00000000,col)
- end
- -- framecount, lag, input
- drawFramecountAndInput(52,4)
- -- level display
- box(9,48,84,115,0xFF404000,0xFF000000)
- box(10,49,83,114,0xFFA0A040,0xFF000000)
- if BoolDisplayLevelMap then
- drawLevelMap()
- mapcol=0xFF606060
- else
- mapcol=0xFF000000
- end
- -- camera outline display
- if BoolDisplayCameraOutline then
- drawCameraOutline()
- camcol=0xFF606060
- else
- camcol=0xFF000000
- end
- -- player display
- if BoolDisplayPlayers then
- drawPlayers()
- playercol=0xFF606060
- else
- playercol=0xFF000000
- end
- -- respawn locations
- --todo
- -- buttons
- drawButton(85,49,7,9,mapcol,10,"m", function()
- updateLevelMap()
- BoolDisplayLevelMap=not BoolDisplayLevelMap
- end)
- drawButton(85,62,7,9,playercol,10,"p", function()
- BoolDisplayPlayers=not BoolDisplayPlayers
- end)
- drawButton(85,75,7,9,camcol,10,"c", function()
- BoolDisplayCameraOutline=not BoolDisplayCameraOutline
- end)
- -- stuff
- if room2_timer==-1 then
- box(10,29,82,40,0xFF404040,0xFF202020)
- text(14,31," unwinnable! ",0xFFFF0000)
- else
- text(10,23,"globaltimer: "..globaltimer,0xFF808080)
- text(10,31,"room2 timer: "..room2_timer,0xFF808080)
- text(10,39,"gold left: "..gold_left,0xFF808080)
- end
- if enemy1_exists then
- if enemy1_droptimer>0 then
- col=0xFFFF8080
- else
- col=0xFF80FF80
- end
- text(10,118,"enemy1 drop: "..enemy1_droptimer,col)
- end
- if enemy2_exists then
- if enemy2_droptimer>0 then
- col=0xFFFF8080
- else
- col=0xFF80FF80
- end
- text(10,126,"enemy2 drop: "..enemy2_droptimer,col)
- end
- if enemy3_exists then
- if enemy3_droptimer>0 then
- col=0xFFFF8080
- else
- col=0xFF80FF80
- end
- text(10,134,"enemy3 drop: "..enemy3_droptimer,col)
- end
- text(10,5,"Level\n"..level,0xFFD0A020)
- --text(100,0,memory.read_u8(0xffd7),0xFF000000,0xFFFFFFFF)
- --text(100,0,string.format("x: %03s", tostring(memory.read_u8(0xc003))).. string.format(" y: %03s", tostring(memory.read_u8(0xc005))),0xFFFFFFFF,0x80000000)
- emu.frameadvance()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement