Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- This script is for a Japanese version of 'A Link to the Past', or 'Zelda no Densetsu - Kamigami no Triforce'.
- -- for fastforwarding to the frame
- function toFrame(frame)
- if movie.framecount() -1 > frame then
- emu.pause()
- end
- end
- -- for rough indication of the next input frame
- lastLagFr = 0
- function lastLag()
- if emu.lagged() then
- lastLagFr = movie.framecount() - 2
- end
- gui.text(0, 0, string.format("%d",lastLagFr))
- end
- local eHP={} -- enemy HP
- local eHPDisp={} -- enemy HP Display
- local itemDrop={} -- item Drop (prize pack manipulation)
- local eX = {} -- enemy's X position
- local eY = {} -- enemy's Y position
- local relEneX = {} -- relative enemy's X position, (enemy's X postion) - (camara's X position), actually means top-left X position of enemy's hitbox
- local relEneY = {} -- relative enemy's Y position, (enemy's Y postion) - (camara's Y position), actually means top-left Y position of enemy's hitbox
- -- reads RAM
- function ramRead()
- rupee = memory.readword(0x7EF360) -- rupee
- numBomb = memory.readbyte(0x7EF343) -- number of bombs for after YBA with spin attack
- numArrows = memory.readbyte(0x7EF377) -- number of arrows for after YBA with spin attack
- x = memory.readbyte(0x7E0022) -- Link's X position
- y = memory.readbyte(0x7E0020) -- Link's Y position
- pos = string.format("(%2x,%2x)",x,y) -- means Link's position, (X, Y). I think HEXed value is more useful.
- cameraX = memory.readbyte(0x7E011E) -- camera's X
- cameraY = memory.readbyte(0x7E0122) -- camera's Y
- hitX = (x-cameraX) % 256 -- top-left X position of Link's hitbox
- hitY = (y-cameraY) % 256 -- top-left Y position of Link's hitbox
- gui.box(hitX, hitY, hitX+16, hitY+24) -- displaying Link's hitbox
- -- assigns enemy's HP, X and Y position, and top-left X and Y position of enemy's hitbox
- for i=0,8 do
- eHP[i] = memory.readbyte(0x7E0E50+i)
- eHPDisp[i]=string.format("%3d",eHP[i])
- eX[i] = memory.readbyte(0x7E0D10+i)
- eY[i] = memory.readbyte(0x7E0D00+i)
- relEneX[i] = (eX[i] - cameraX) % 256
- relEneY[i] = (eY[i] - cameraY) % 256
- end
- HP=memory.readbyte(0x7EF36D) -- Link's HP
- string.format("%3d",HP)
- MP=memory.readbyte(0x7EF36E) -- Link's MP
- string.format("%3d",MP)
- xSpeed=memory.readbytesigned(0x7E0031) -- Link's X speed
- ySpeed=memory.readbytesigned(0x7E0030) -- Link's Y speed
- posSpeed = string.format(" %2d,%2d ",xSpeed,ySpeed) -- means Link's (X speed, Y speed)
- peg=memory.readbyte(0x7E0374) -- 0=pegasus boots dash; 29=spin dash
- bomb=memory.readbyte(0x7E03A0) -- timer for exploding a bomb
- spinAttack=memory.readbyte(0x7E0079) -- charging time for spin attack
- rng=memory.readword(0x7E0FA0) -- RNG
- grab=memory.readbyte(0x7E0DFF) -- timer for grabbing
- --[[ -- assigns prize pack manipulation, but this code does not display for the lack of gui.text. should use 'RAM Watch.'
- for i=0,6 do
- itemDrop[i]=memory.readbyte(0x7E0FC7+i)
- end
- -- Quards, Rupees, Magic, Bombs, Arrows, Skeleton, Big
- --]]
- --[[
- layer=memory.readbyte(0x7E0476) -- Link's current Layer
- 0x7E00A0 -- Link's current room for EG. HEXed value should be used on 'RAM Watch.'
- -]]
- p=string.format("peg %2d",peg)
- s=string.format("spn %2x",spinAttack)
- b=string.format("bom %2d",bomb)
- r=string.format("rng %4x",rng)
- g=string.format("grb %2d",grab)
- status = memory.readbyte(0x7E004D) -- Link's current status. 0=able to be inputted.
- recoil = memory.readbyte(0x7E0046) -- Link's current recoiling status. 0=able to be inputted.
- push = memory.readbyte(0x7E0371) - 13 -- state of pushing a block. 0=begin to move the block.
- ledge = memory.readbyte(0x7E0375) -- Link's current ledge off status. 0=begin to ledge off. used when you don't have pegasus boots.
- motion = memory.readbyte(0x7E0354) -- Link's current motion (slashing, using staff, arrow, etc). 0=able to be inputted.
- gui.text(116,0,string.format("mtn %d ldg %d sta %d rcl %d psh %d",motion,ledge,status,recoil,push)) -- displaying above 5 things.
- end
- -- auto scroll text messages. when msgWait is not 0, you have to scroll them manually.
- function autoMsg()
- windowBox = memory.readword(0x7E0010)
- msg = memory.readbyte(0x7E1CE9) - 1
- msgWait = memory.readbyte(0x7E1CE0)
- gui.text(40, 0, string.format("%d %d %X", msg, msgWait, windowBox))
- if windowBox == 0x20E then
- if msg == 0 then
- joypad.set(1, {A=1})
- end
- --[[
- if (msgWait > 0) then
- joypad.set(1, {A=1})
- -- emu.pause()
- end
- --]]
- end
- end
- -- the next function is auto-displaying the last frame of no input available
- lastGameMode = 0
- lastStatus = 0
- lastRecoil = 0
- lastMotion = 0
- function chkNoInput()
- gameMode = bit.band(windowBox,0xFF00)
- if gameMode > 0 then
- lastGameMode = movie.framecount()+1
- end
- if status > 0 then
- lastStatus = movie.framecount()+1
- end
- if recoil > 0 then
- lastRecoil = movie.framecount()+1
- end
- if motion > 0 then
- lastMotion = movie.framecount()
- end
- gui.text(80,0,string.format("%d",lastGameMode))
- gui.text(204,7,string.format("%d",lastStatus))
- gui.text(128,7,string.format("%d",lastMotion))
- -- gui.text(210,7,string.format("%d",lastRecoil))
- end
- -- displays Link's position and |velocity|
- function position()
- gui.text(228,208,pos)
- gui.text(228,200,posSpeed)
- end
- -- displays enemie's HP and a hitbox
- function eHPF()
- for j=0,8 do
- if (eHP[j] ~= 0) and (eHP[j] < 250) then
- gui.text(240,0+(j)*8,eHPDisp[j])
- gui.box(relEneX[j], relEneY[j], relEneX[j]+16, relEneY[j]+24)
- -- this meant to target enemies with arrows or stuffs.
- --[[
- gui.line(relEneX[j]+8, 0, relEneX[j]+8, 225)
- gui.line(0, relEneY[j]+12, 255, relEneY[j]+12)
- --]]
- --[[
- gui.line(relEneX[j], 0, relEneX[j], 225)
- gui.line(0, relEneY[j], 255, relEneY[j])
- gui.line(relEneX[j]+16, 0, relEneX[j]+16, 225)
- gui.line(0, relEneY[j]+24, 255, relEneY[j]+24)
- --]]
- end
- end
- end
- -- displays Link's HP and MP
- function HPDisp()
- gui.text(166,14,HP)
- gui.text(22,60,MP)
- end
- -- displays Link's various states
- function state()
- gui.text(220,152,p) -- 0=pegasus boots dash; 29=spin dash
- gui.text(220,160,s) -- charging time for spin attack
- gui.text(220,168,b) -- timer for exploding a bomb
- gui.text(220,176,g) -- timer for grabbing
- gui.text(220,188,r) -- RNG
- end
- -- displays the number of rupees, bombs and arrows for after YBA with spin attack
- function RupeeBombArrow()
- gui.text(80,16,rupee)
- gui.text(108,16,numBomb)
- gui.text(128,16,numArrows)
- end
- -- for chest game and digging game or something. repeats input with one frame delay
- function try()
- emu.speedmode("turbo")
- local state = savestate.create()
- savestate.save(state)
- local try1=0
- for i=1,1000 do
- savestate.load(state)
- emu.frameadvance()
- savestate.save(state)
- for j=1,500 do
- -- joypad.set(1,{A=1})
- joypad.set(1,{Y=1})
- gui.text(16,52,try1)
- emu.frameadvance()
- end
- try1=try1+1
- end
- end
- while true do
- lastLag() -- for rough indication of the next input frame
- ramRead() -- reads RAM
- autoMsg() -- auto scroll text messages. when msgWait is not 0, you have to scroll them manually.
- RupeeBombArrow() -- displays the number of rupees, bombs and arrows for after YBA with spin attack
- position() -- displays Link's position and |velocity|
- eHPF() -- displays enemie's HP and a hitbox
- HPDisp() -- displays Link's HP and MP
- -- toFrame(205000) -- for fastforwarding to the frame
- state() -- displays Link's various states
- chkNoInput() -- the next function is auto-displaying the last frame of no input available.
- -- try() -- for chest game and digging game or something. repeats input with one frame delay
- emu.frameadvance()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement