Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- memory.usememorydomain("68K RAM")
- gui.defaultPixelFont("fceux")
- green = 0xFF00FF00
- red = 0xFFFF0000
- white = 0xFFFFFFFF
- black = 0xFF000000
- blank = 0x00000000
- --canvas = gui.createcanvas(600,600)
- --client.SetGameExtraPadding(0,0,0,0)
- --480x270? aka 1920x1080 x4
- pleft = 60
- ptop = 23
- pright = 100
- pbottom = 23
- client.SetGameExtraPadding(pleft,ptop,pright,pbottom)
- camera = memory.read_u16_be(0x582A)
- enemyHPs = {}
- for i=1,16 do
- enemyHPs[i] = memory.readbyte(0x1E96 + (i*0x70))
- end
- --X range: 500 to startingX
- --Y range: 300 to 1000
- function fastSpeed()
- movie.setrerecordcounting(false)
- client.speedmode(6399) --maximum?
- client.SetSoundOn(false)
- client.unpause()
- end
- function normalSpeed()
- movie.setrerecordcounting(true)
- client.speedmode(100)
- client.SetSoundOn(true)
- client.pause()
- end
- function drawFlyoffs()
- life = 30
- for i=#flyoffs,1,-1 do
- diff = emu.framecount() - flyoffs[i][2]
- if (diff >= 0) then
- gui.drawText(flyoffs[1][4]+pleft, flyoffs[1][5]+ptop - diff*(30/life), flyoffs[i][1], 0xFF000000 - math.floor((diff/life)*0xFF) * 0x1000000, 0x00000000, 10, "Lucida Sans Typewriter", null, "right")
- gui.drawText(flyoffs[1][4]-1+pleft, flyoffs[1][5]-1+ptop - diff*(30/life), flyoffs[i][1], flyoffs[i][3] - math.floor((diff/life)*0xFF) * 0x1000000, 0x00000000, 10, "Lucida Sans Typewriter", null, "right")
- if (diff >= life) then
- table.remove(flyoffs,i)
- end
- else table.remove(flyoffs,i)
- end
- end
- end
- function drawHitbox(addr,color,fill,firstTripleFrame,isMisc)
- color = color or white
- fill = fill or blank
- firstTripleFrame = firstTripleFrame or false
- debugThis = debugThis or false
- if (memory.readbyte(addr) > 0) then
- xpos = memory.read_s16_be(addr+0x07)
- ypos = memory.read_s16_be(addr+0x0B)
- xoffset = memory.read_s16_be(addr+0x43)
- yoffset = memory.read_s16_be(addr+0x47)
- width = memory.read_u16_be(addr+0x4B)
- height = memory.read_u16_be(addr+0x4F)
- --hacky but I can't find the RAM address that accounts for the oddity of triple jump's first frame hitbox
- --it definitely goes 200 units right, it seems like it goes down a bit too
- --0A88-0A8A seem suspect, but at the very least, they seem to let me know if it's leftward or rightward
- if (firstTripleFrame and width == 400) then
- if (memory.readbyte(0x0A8A) == 224) then
- xpos = xpos + 200
- else
- xpos = xpos - 200
- end
- ypos = ypos + 16
- end
- x1 = (xpos+xoffset)/4 - camera
- x2 = (xpos+xoffset+width)/4 - camera
- y1 = (ypos+yoffset)/4
- y2 = (ypos+yoffset+height)/4
- if (isMisc) then
- x1 = (xpos+xoffset)/4 - camera - 2
- x2 = (xpos+xoffset+width)/4 - camera +2
- y1 = (ypos+yoffset)/4 - 2
- y2 = (ypos+yoffset+height)/4 + 2
- end
- --gui.drawPixel(xpos/4-camera,ypos/4,green)
- gui.drawBox(x1+pleft,y1+ptop,x2+pleft,y2+ptop,color,fill)
- --canvas.DrawBox(x1,y1,x2,y2,color,fill)
- --if (debugThis) then print(x1 .. " " .. x2 .. " " .. y1 .. " " .. y2) end
- end
- end
- --drawHitbox(0x0A7A,red)
- --drawHitbox(0x4CEE,0xFFFF00FF)
- --testHitbox()
- prevcamera = memory.read_u16_be(0x582A)
- prevgold = memory.readbyte(0x1E85)
- prevjumps = memory.readbyte(0x4D52)
- PrevFrameTimer = memory.readbyte(0x5541);
- PrevFrame = emu.framecount()
- PrevX = 0
- XDiff = 0
- PrevY = 0
- YDiff = 0
- XColor = "white"
- XDiffColor = "white"
- XSpdColor = "white"
- YColor = "white"
- YDiffColor = "white"
- YSpdColor = "white"
- XPosTable = {}
- flyoffs = {}
- while true do
- camera = memory.read_u16_be(0x582A)
- X = memory.read_u16_be(0x4CF5)
- Y = memory.read_u16_be(0x4CF9)
- playerActive = memory.readbyte(0x4CEE)
- bossActive = memory.readbyte(0x2CEA)
- --draw player hitboxes
- drawHitbox(0x4CEE,0x80FF00FF,0x40FF00FF)
- totalEnemies = 0
- totalProjectiles = 0
- totalMisc = 0
- totalItem = 0
- totalAttack = 0
- --draw 16 enemy slot hitboxes
- for i = 0, 15 do
- if (memory.readbyte(0x1782 + (i*0x70)) > 0) then
- totalEnemies = totalEnemies + 1
- drawHitbox((0x1782 + (i*0x70)),0x80FFFFFF,0x40FFFFFF)
- local enemyhp = memory.read_s16_be(0x17C0 + (i*0x70))
- local lostthisframe = ""
- if enemyhp > 0 then
- hpcolor = white
- if (enemyhp < enemyHPs[i+1]) then
- hpcolor = red
- lostthisframe = enemyhp - enemyHPs[i+1]
- end
- enemyHPs[i+1] = enemyhp
- enemyHPy = y2+1+ptop
- if (enemyHPy > 265) then enemyHPy = y1-9+ptop end
- gui.pixelText(x1+pleft, enemyHPy, enemyhp, hpcolor, 0x80000000)
- if (lostthisframe ~= "") then gui.pixelText(x1+pleft, enemyHPy+9, lostthisframe, hpcolor, 0x80000000) end
- end
- end
- end
- --draw 16 projectile slot hitboxes
- for i = 0, 15 do
- if (memory.readbyte(0x1E96 + (i*0x70)) > 0) then
- totalProjectiles = totalProjectiles + 1
- drawHitbox((0x1E96 + (i*0x70)),0xB0000000,0x80000000)
- end
- end
- --draw 18 misc visual hitboxes
- for i = 0, 17 do
- if (memory.readbyte(0x0C46 + (i*0x70)) > 0) then
- totalMisc = totalMisc + 1
- drawHitbox((0x0C46 + (i*0x70)),0x8000FF00,0x6000FF00,false,true)
- end
- end
- --draw 16 item hitboxes
- for i = 0, 15 do
- if (memory.readbyte(0x037A + (i*0x70)) > 0) then
- totalItem = totalItem + 1
- drawHitbox((0x037A + (i*0x70)),0x60FFFF00,0x30FFFF00)
- end
- end
- --draw 4 player attack hitboxes
- for i = 0, 3 do
- if (memory.readbyte(0x0A7A + (i*0x70)) > 0) then
- totalAttack = totalAttack + 1
- isTriple = false
- if (memory.readbyte(0x4D05) == 7 and i == 0) then isTriple = true end
- drawHitbox(0x0A7A + (i*0x70),0x80FF0000,0x40FF0000,isTriple)
- end
- end
- XDiff = X - PrevX;
- if (emu.framecount() - 1 ~= PrevFrame and XPosTable[emu.framecount()-1] ~= nil) then XDiff = X - XPosTable[emu.framecount()-1] end
- PrevX = X;
- YDiff = Y - PrevY;
- PrevY = Y;
- if (XPosTable[emu.framecount()] == null) then
- XPosTable[emu.framecount()] = X;
- XColor = "white";
- elseif (XPosTable[emu.framecount()] == X) then
- XColor = "white";
- elseif (XPosTable[emu.framecount()] < X) then
- XPosTable[emu.framecount()] = X;
- XColor = "green";
- else
- XColor = "red";
- end
- if XDiff>16 then
- XDiffColor = "green"
- elseif XDiff<16 and emu.framecount() - 1 == PrevFrame then
- XDiffColor = "red"
- --if (playerActive == 1 and camera ~= 0 and (bossActive ~= 1 or #flyoffs == 0)) then table.insert(flyoffs, {"moved " .. XDiff .. " at " .. emu.framecount(), emu.framecount(), red, 215,40}) end
- else
- XDiffColor = "white"
- end
- --if (bossActive == 1) then gui.pixelText(130+pleft,2+ptop, "boss active?",red) end
- gui.pixelText(3+pleft, 2+ptop, string.format("% 6d",X),XColor)
- --gui.pixelText(10, 18, string.format("% 9.3f",XSpd),XSpdColor)
- gui.pixelText(3+pleft, 11+ptop, string.format("% 6d",XDiff),XDiffColor)
- gui.pixelText(40+pleft, 2+ptop, string.format("% 6d",Y),YColor)
- --gui.pixelText(65, 18, string.format("% 9.3f",YSpd))
- gui.pixelText(40+pleft, 11+ptop, string.format("% 6d",YDiff),YDiffColor)
- cameraX = memory.readbyte(0x1E85)
- cameracolor = white
- if (camera - prevcamera < 4) then
- cameracolor = "red"
- if (camera - prevcamera > 0) then table.insert(flyoffs, {"camera moved " .. (camera-prevcamera) .. " at " .. emu.framecount(), emu.framecount(), red, 215,40}) end
- elseif (camera - prevcamera > 4) then cameracolor = "green" end
- prevcamera = camera
- gold = memory.read_u16_be(0x1E84)
- goldcolor = white
- if (gold > prevgold) then goldcolor = "gold" end
- prevgold = gold
- jumps = memory.readbyte(0x4D52)
- if (memory.readbyte(0x8124) == 186 and memory.readbyte(0x8125) == 186) then
- jumps = 3
- end
- jumpcolor = white
- if (jumps > prevjumps) then jumpcolor = "green" end
- if (jumps == 0) then jumpcolor = "red" end
- prevjumps = jumps
- attackFrames = memory.readbyte(0x4D05)
- specialBar = memory.readbyte(0x0374)
- specialTenths = memory.readbyte(0x261B)
- specialcolor = red
- if (specialBar == 24) then specialcolor = white
- specialTenths = 0 end
- spawngroup = memory.readbyte(0x15DF)
- timercolor = white
- BigFrameTimer = memory.read_u16_be(0x5540);
- FrameTimer = memory.readbyte(0x5541);
- --Check if the player object is active and camera isn't 0 before we tamper with lag frames
- if (playerActive == 1 and camera ~= 0) then
- --Determine Lag
- tastudio.setlag(emu.framecount(),false)
- if (BigFrameTimer ~= 0 and FrameTimer == PrevFrameTimer and PrevFrame ~= emu.framecount()) then
- tastudio.setlag(emu.framecount(),true)
- end
- end
- if (BigFrameTimer ~= 0 and FrameTimer == PrevFrameTimer and PrevFrame ~= emu.framecount()) then
- timercolor = red
- end
- PrevFrameTimer = FrameTimer
- PrevFrame = emu.framecount()
- textx = 3 + pleft
- texty = 20 + ptop
- gui.pixelText(textx, texty, string.format(" camera:%4d",camera),cameracolor)
- texty = texty+9
- gui.pixelText(textx, texty, string.format(" gold: %3d",gold),goldcolor)
- texty = texty+9
- gui.pixelText(textx, texty, " jumps: " .. jumps,jumpcolor)
- texty = texty+9
- gui.pixelText(textx, texty, " attack: " .. attackFrames,white)
- texty = texty+9
- gui.pixelText(textx, texty, string.format("special:%2d.%1d",specialBar,specialTenths), specialcolor)
- texty = texty+9
- gui.pixelText(textx, texty, string.format(" timer:%4d",BigFrameTimer), timercolor)
- texty = 166 + ptop
- gui.pixelText(textx, texty, string.format("spawn: %2d",spawngroup),white)
- texty = texty+9
- gui.pixelText(textx, texty, string.format("enemy: %2d/16",totalEnemies),white)
- texty = texty+9
- gui.pixelText(textx, texty, string.format(" proj: %2d/16",totalProjectiles),white)
- texty = texty+9
- gui.pixelText(textx, texty, string.format(" misc: %2d/18",totalMisc),white)
- texty = texty+9
- gui.pixelText(textx, texty, string.format(" item: %2d/16",totalItem),white)
- texty = texty+9
- gui.pixelText(textx, texty, string.format(" attk: %2d/4",totalAttack),white)
- texty = texty+9
- drawFlyoffs()
- emu.frameadvance()
- end
Advertisement
Add Comment
Please, Sign In to add comment