Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- $84 - Ryu state bits
- ?, facing left, ?, blinking, attack, in air, invincible, damage boost
- 7, 6, 5, 4, 3, 2, 1, 0
- ]]
- 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)
- xposAbs = scrnpos+xpos+scrnsub/256+memory.readbytesigned(0x52)*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))
- -- 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)
- some = memory.readbyte(0x420+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.readbytesigned(0x470+i)
- ysub = memory.readbyte(0x478+i)
- y = memory.readbyte(0x480+i)
- hp = memory.readbyte(0x490+i)
- state = memory.readbyte(0x498+i)
- if (state ~= 0) then
- gui.text(x,y,string.format("%d",i))
- 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\n%02X.%02X\n%02X.%02X",i,x,xsub,y,ysub))
- end
- gui.box(0,25,64,40,"#000000ff")
- gui.text(xpos,ypos-18,string.format("%.1f",xspd))
- gui.text(0, 25, string.format("X: %.1f\nY: %3d\nS: %.1f\nBG: %s",
- xposAbs,ypos,yspd,collision),"#44ffffff","#000000ff")
- -- gui.text(1,25,"\n\n\nInterrupt",color,"#000000ff")
- lastxposAbs = xposAbs
- if inv > 0 then gui.text(161,33,string.format("%02d",inv)) end
- if bosshp > 0 then
- if bosshp > 16
- then gui.text(177,41,string.format("%02d",abosshp))
- else gui.text(177,41,string.format("%02d",bosshp))
- 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 function box(color,text)
- gui.box(x,y+offset,x+16,y+offset+16,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+16,y+offset ,color2) end
- if (down == 1) then gui.line(x ,y+offset+16,x+16,y+offset ,color2) end
- if (left == 1) then gui.line(x ,y+offset ,x ,y+offset+16,color2) end
- if (right == 1) then gui.line(x+16,y+offset ,x+16,y+offset+16,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("#00ff0066",0) -- ladder
- elseif (arg >= 12) and (arg <= 15)
- then box("#ffffff66",0) -- exits
- else box("#00ff0066",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)
- --[[
- function GetCollision(X, Y)
- -- how the game does it
- local temp = GetCell(X,Y)
- temp = memory.readbyte(0x300+temp)
- if (AND(Y,0x10) ~= 0)
- then temp = AND(temp,0xF)
- else temp = SHIFT(temp,4)
- end
- temp = memory.readbyte(0xE782+temp)
- return temp
- end
- --]]
- --[[
- function Within(ryuX,ryuY,cellX,cellY)
- if (ryuX > cellX) and (ryuX <= cellX+16)
- and (ryuY > cellY) and (ryuY <= cellY+16)
- then return "#00ff00aa"
- else return "#00ff0044"
- end
- end
- --]]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement