Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- lastxposAbs = 0
- RyuRow = 0
- curves = {}
- function NGRAMview()
- xpos = memory.readbyte(0x86)+memory.readbyte(0x85)/256
- yspdsub = memory.readbyte(0x87)/0x37
- yspd = memory.readbytesigned(0x89)+yspdsub/5
- yspda = yspd/5
- yspdasub = yspd%5
- ypos = memory.readbyte(0x8A)
- scrnpos = memory.readbyte(0xA3)
- scrnsub = memory.readbyte(0xA2)
- scrnHi = memory.readbytesigned(0x52)
- xposAbs = scrnpos+xpos+scrnsub/256+scrnHi*256
- xspd = xposAbs-lastxposAbs
- rngb = memory.readbyte(0xBF)
- bosshp = memory.readbyte(0x497)
- abosshp = memory.readbyte(0x496)
- inv = memory.readbyte(0x95)
- interrupt = AND(memory.readbyte(0x4C),0x40)
- collision = tobitstring(memory.readbyte(0x8c))
- tmrsub = memory.readbyte(0x62)
- tmr = memory.readbyte(0x63)
- -- yposQ = AND(ypos,0x10)
- -- rnga = memory.readbyte(0xB5)
- -- shifted = bit.rshift(rngb,1)
- -- anded = bit.band(rngb,1)
- ViewBG(1)
- PredictBird()
- for i = 0, 7 do
- id = memory.readbyte(0x400+i)
- time = memory.readbyte(0x408+i)
- action = memory.readbyte(0x410+i)
- mov = memory.readbyte(0x438+i)
- xsubspd = memory.readbyte(0x448+i)/0x10
- xspeed = memory.readbytesigned(0x450+i)
- xsub = memory.readbyte(0x458+i)
- x = memory.readbyte(0x460+i)
- ysubspd = memory.readbyte(0x468+i)
- yspeed = memory.readbyte(0x470+i)
- ysub = memory.readbyte(0x478+i)
- y = memory.readbyte(0x480+i)
- BGcoll = memory.readbyte(0x488+i)
- hp = memory.readbyte(0x490+i)
- state = memory.readbyte(0x498+i)
- if (state ~= 0) then
- if (BGcoll ~= 0) then color5 = "red" else color5 = "white" end
- gui.text(x,y,string.format("%d",i))
- if (id == 0) then gui.text(x+6,y,string.format(":%X",action),color5) end
- if (time > 0) then gui.text(x,y,string.format("\n%d",time),color) end
- end
- if (interrupt > 0) then color = "red" else color = "white" end
- if (id == 18) or ((id == 11) and (state ~= 0)) then
- gui.text(x,y,string.format("%d.%d",xspeed,xsubspd))
- end
- gui.text(i*32+3,1,string.format("%d: %X\n%02X.%02X\n%02X.%02X",
- i,id,x,xsub,y,ysub),"#ffccaaff","black")
- end
- gui.box(0,25,64,40,"#000000ff")
- gui.text(xpos-8,ypos-18,string.format("%.1f",xspd))
- gui.text(73, 41,string.format("%3d:%2d",tmr,tmrsub),"#ffccaaff","black")
- gui.text(128,25,string.format("S: %.1f",scrnpos+scrnsub/256+scrnHi*256),"#44ffffff","#000000ff")
- gui.text(0, 25,string.format("X: %.1f\nY: %3d\ndY: %.1f \nBG: %s",xposAbs,ypos,yspd,collision),"#44ffffff","#000000ff")
- gui.text(212,25,"Interrupt",color,"#000000ff")
- if (inv > 0) then gui.text(242,33,string.format("%02d",inv),"#ffccaaff","black") end
- if (bosshp > 0) then
- if (bosshp > 16) then bosshp = abosshp end
- gui.text(242,41,string.format("%02d",abosshp),"#ffccaaff","black")
- end
- lastxposAbs = xposAbs
- Spawns()
- end
- function Spawns()
- -- feos, 2014
- -- uncovers which spawns will occur per frame
- local SubCur= memory.readbyte(0x50)/25.6
- local PosCur= AND(memory.readbyte(0x51),0xF)
- local BlCur = memory.readbyte(0x4E)
- local Blptr = memory.readword(0x96)
- local Yptr = memory.readword(0x98)
- local IDptr = memory.readword(0x9A)
- local Count = memory.readbyte(0xB4)
- local Iterator = memory.readbyte(0xB5)-8
- local IteratorLast = memory.readbyte(0xB5)-1
- while (Iterator < 0) do Iterator = Count+Iterator end
- if (IteratorLast < 0) then IteratorLast = Count+IteratorLast end
- local Interrupt = AND(memory.readbyte(0x4C),0x40)
- if (memory.readbyte(0x1FC) == 0x87)
- or (memory.readbyte(0x1F3) == 0xD8) then
- for i = 0,Count-1 do
- local color1 = "white"
- local block = memory.readbyte(Blptr+i)
- local ypos = memory.readbyte(Yptr +i)
- local id = memory.readbyte(IDptr+i)
- local x = i*16%256+1
- local y = 57+math.floor(i/16)*30
- if (block == BlCur) then gui.box(x-1,y-1,x+12,y+23,"#00ff0088") end
- if (i+1 >= Iterator) and (i+1 < Iterator+8)
- or (i+1 < Iterator+8-Count) then color1 = "#ffccaaff" end
- if (Interrupt > 0) then color2 = "red" else color2 = "#44ffffff" end
- gui.text(x,y,string.format("%X\n%X\n%X",block,ypos,id),color1)
- gui.text(108,41,string.format("Block: %X.%02d.%d\nIterator: %02d-%02d/%d",
- BlCur,PosCur,SubCur,Iterator,IteratorLast,Count),color2,"#000000ff")
- end
- end
- end
- function GetCell(X,Y)
- local temp = memory.readbyte(0xE7CC+SHIFT(X,4))+memory.readbyte(0x5F)
- if (temp >= 0xC0) then temp = temp-0xC0 end
- Y = Y-0x40
- if (Y < 0) then Y = 0 end
- temp = SHIFT(Y,5)+temp
- return temp
- end
- function DrawBG(arg,offset,x,y)
- local color2 = "#00ff00ff"
- local b = 16
- local function box(color,text)
- gui.box(x,y+offset,x+b,y+offset+b,color)
- if (text == 1) then
- gui.text(x+1,y+offset+1,string.format("%d",arg))
- end
- end
- local function line(up,down,left,right)
- if (up == 1) then gui.line(x ,y+offset ,x+b,y+offset ,color2) end
- if (down == 1) then gui.line(x ,y+offset+b,x+b,y+offset ,color2) end
- if (left == 1) then gui.line(x ,y+offset ,x ,y+offset+b,color2) end
- if (right == 1) then gui.line(x+b,y+offset ,x+b,y+offset+b,color2) end
- end
- if (arg ~= 0) then
- if (arg == 1) then line(0,0,0,1) -- right wall
- elseif (arg == 2) then line(0,0,1,0) -- left wall
- elseif (arg == 3) then line(0,0,1,1) -- two-sided wall
- elseif (arg == 4) then line(1,0,0,1) -- right corner
- elseif (arg == 5) then line(1,0,1,0) -- left corner
- elseif (arg == 6) then line(1,0,1,1) -- two-sided corner
- elseif (arg == 7) then line(1,0,0,0) -- floor
- elseif (arg == 8) then box("#ff000066",0) -- ejecting block
- elseif (arg == 9) then box("#00ff0000",0) -- ladder
- elseif (arg >= 12) and (arg <= 15)
- then box("#ffffff66",0) -- exits
- else box("#0000ff66",1)
- end
- end
- end
- function ViewBG(style)
- -- feos, 2014
- -- style: 0=none, 1=new, 2=old, 3=both
- local base = 0x300
- local RyuX = memory.readbyte(0x86)
- local RyuY = memory.readbyte(0x8A)
- local RyuYspeed = memory.readbytesigned(0x89)
- local RyuXspeed = memory.readbytesigned(0xAD)+memory.readbyte(0xAC)/256
- if (AND(memory.readbyte(0x84),4) == 0) then RyuYspeed = 0 end
- local RyuCell = GetCell(RyuX, RyuY+RyuYspeed)
- local RyuRow = math.floor(RyuCell/6)
- local Screen = memory.readwordsigned(0x51)
- if (AND(style,1) == 1)
- and (memory.readbyte(0x1FC) == 0x87)
- or (memory.readbyte(0x1F3) == 0xD8) then
- for tRow = RyuRow-14, RyuRow+14 do
- for tLine = 0,5 do
- local address = base+((tRow*6+tLine)%0xC0)
- local hi = SHIFT(memory.readbyte(address), 4)
- local lo = AND(memory.readbyte(address),0xF)
- local x = (tRow-RyuRow)*16+RyuX-RyuX%0x10-Screen%0x10
- local y = tLine*32+64
- DrawBG(hi, 0,x,y)
- DrawBG(lo,16,x,y)
- end
- end
- gui.box(xpos-9,ypos+RyuYspeed-1,xpos+5,ypos+RyuYspeed-5,"#0000ff66")
- end
- if (AND(style,2) == 2) then
- for cell = 0,191 do
- local hi = SHIFT(memory.readbyte(base+cell), 4)
- local lo = AND(memory.readbyte(base+cell),0xF)
- local bX = math.floor(cell/6)
- local bY = cell%6
- local rX = (RyuRow%32)*6-1
- local rY = math.floor(RyuY/16)*8-32
- if (hi == 0) then hi = " " else hi = string.format("%X",hi) end
- if (lo == 0) then lo = " " else lo = string.format("%X",lo) end
- gui.text(bX*6,bY*16+9,hi.."\n"..lo)
- gui.box(rX,rY,rX+6,rY+8,"#00ff0000")
- end
- end
- end
- function PredictBird()
- -- feos, 2014
- -- draws birds trajectories
- -- color marks direction
- for slot = 0,7 do
- if (memory.readbyte(0x400+slot) ~= 11) or (memory.readbyte(0x498+slot) == 0) then
- curves.slot = nil
- else
- if (curves.slot == nil) then curves.slot = {} end
- local ryuY = memory.readbyte(0x8A)
- local ryuX = memory.readbyte(0x86)
- local birdY = memory.readbyte(0x480+slot)
- local birdX = memory.readbyte(0x460+slot) +memory.readbyte(0x458+slot)/256
- local birdSpeed = memory.readbytesigned(0x450+slot)+memory.readbyte(0x448+slot)/256
- local newY = 0
- local newX = 0
- local newSpeed = 0
- while (#curves.slot <= 200) do
- if (#curves.slot == 0) then
- if (birdY > ryuY)
- then newY = birdY-1
- else newY = birdY+1
- end
- if (birdX > ryuX)
- then newSpeed = birdSpeed-16/256
- else newSpeed = birdSpeed+16/256
- end
- newX = birdX+newSpeed
- else
- local index = #curves.slot
- local tempY = curves.slot[index].oldY
- local tempX = curves.slot[index].oldX
- local tempSpeed = curves.slot[index].oldSpeed
- if (tempY > ryuY)
- then newY = tempY-1
- else newY = tempY+1
- end
- if (tempX > ryuX)
- then newSpeed = tempSpeed-16/256
- else newSpeed = tempSpeed+16/256
- end
- newX = tempX + newSpeed
- end
- table.insert(curves.slot,{oldY = newY,oldX = newX,oldSpeed = newSpeed})
- end
- if (#curves.slot == 200) then table.remove(curves.slot,1) end
- for index = 1,#curves.slot do
- local color = nil
- if (curves.slot[index].oldSpeed < 0) then color = "#008800" else color = "#0000ff" end
- gui.box(curves.slot[index].oldX-1, curves.slot[index].oldY-1,
- curves.slot[index].oldX+1, curves.slot[index].oldY+1, color)
- end
- for index = 1,#curves.slot do
- gui.pixel(curves.slot[index].oldX,curves.slot[index].oldY,"white")
- end
- end
- end
- end
- emu.registerafter(NGRAMview)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement