Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Chrono Trigger Infoscope for Snes9x(1.51-rr)
- -- 2015-06-10 Redslash
- --RNG Display shows how much window remains; Input Display shows press vs. hold (works with movies!); Room Timer can use a savestate (most recent only); Upcoming Crits (next 6); Hitbox Viewer (experimental, kinda laggy); and Coordinates highlight odd/even pixel.
- --<Select> hides some displays.
- local inputs = joypad.get()
- local button = {'R','L','X','A','right','left','down','up','start','select','Y','B'}
- local xcoords = { 8.6, 0.5, 9,10, 2, 0, 1, 1, 6, 4, 8, 9}
- local ycoords = { 1, 1, 2, 3, 3, 3, 4, 2, 3, 3, 3, 4}
- local pressdur = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
- local selectheld = 0
- local dispbox = 3 -- (press select to toggle)
- local yoffset = 191
- local xoffset = 97 -- 89 = button display centered
- local regcolor = "#CCCCCC"
- local BATTLE_FLAG = 0x7e0117
- local battleflag = 0
- local battlecopy = 0
- local LOCATION = 0x7e0100
- local loc = 0
- local frame,batstart,locstart = 0,0,0
- local timesav,batsav,locsav = 0,0,0
- local timeend = 0
- local recentload = 0
- function displayTime()
- frame = frame + 1
- --Catch battleflag change
- if battleflag ~= memory.readbyte(BATTLE_FLAG) % 2 then
- battleflag = memory.readbyte(BATTLE_FLAG) % 2
- if battleflag == 0 then
- timeend = frame - batstart
- else timeend = frame - locstart end
- if battleflag == 1 and recentload == 0 then batstart = frame end
- end
- --Catch location change
- if loc ~= memory.readword(LOCATION) then
- loc = memory.readword(LOCATION)
- timeend = frame - locstart
- if recentload == 0 then locstart = frame end
- end
- recentload = 0
- gui.text(xoffset+14,yoffset+26," "..string.format("%2d'%02d\"%02d",
- (timeend + 1) % 216000 / 3600, ((timeend + 1) % 3600) / 60, (timeend + 1) % 60), regcolor)
- end
- local BATTLE_VALUE = 0x7e0026
- local BATTLE_STORE = 0x7e29AD
- local CRIT_VALUE = 0x7eB3E6
- local MENU_TIME = 0x7e0D00
- local menutime = 0
- local menuopen = 0
- local CHAR_ID = 0x7e2980 -- 3 in-party then 6 reserve (e.g. for 1-on-1 bosses)
- local CHAR_WEAP = 0x7e2629
- local CHAR_ACC = 0x7e262A
- local chars = {}
- local charname = {"C","M","L","R","F","A","J"}
- local windowname = {"1-","1+","2-","2+","3-","3+","4-","4+","5-","5+","6-","6+","7-","7+","8-","8+"}
- local battlewindow = {0x00,0x09,0x0d,0x1d,0x2e,0x37,0x3e,0x58,0x61,0x88,0x98,0xab,0xb9,0xdc,0xe3,0xfb,0x100,
- 0x00,0x0d,0x12,0x17,0x35,0x40,0x5c,0x67,0x6a,0x88,0x8f,0xad,0xb3,0xd0,0xe4,0xfd,0x100,
- 0x00,0x0b,0x18,0x1d,0x2c,0x33,0x64,0x66,0x6d,0x79,0x85,0xa7,0xb6,0xd3,0xe6,0xf7,0x100,0x00}
- --set of windows for 0, 1, and 2 empty characters
- local crits = "0737062067712743017053012106621026206760245002737143667207070014"..
- "1101674231747620560305126422403270125313166113731602620666773021"..
- "1714114244363074011420427072702021156152710015037100071773030063"..
- "3110560024303132144471071671003163600200333701061633241110004006"..
- "0737062067" --wrap-around
- function displayValues()
- --Catch the BV copy
- if battlecopy == 0 and battleflag == 1 and memory.readbyte(BATTLE_VALUE) == memory.readbyte(BATTLE_STORE) then
- battlecopy = 1
- elseif battleflag == 0 then
- battlecopy = 0
- end
- --Value is at different address for in-battle, out-of-battle, & load menu:
- if battlecopy == 1 then
- bv = memory.readbyte(BATTLE_VALUE)
- cv = memory.readbyte(CRIT_VALUE)
- else
- if (memory.readbyte(MENU_TIME) > 0 and memory.readbyte(BATTLE_STORE) == 0 and emptychars == 0) then
- --menutime is for ALL menus, BV is 0 for entire beginning... but load menu has "3 Crono's" (000000)
- bv = memory.readbyte(MENU_TIME)
- else bv = memory.readbyte(BATTLE_STORE) end
- cv = bv
- end
- --Get the active PCs
- emptychars = 0
- for i = 1,3 do
- chars[i] = memory.readbyte(CHAR_ID+i-1)
- if chars[i] >= 0x07 then emptychars = emptychars + 1 end
- end
- --Draw values:
- if emptychars < 3 then
- for i = 1, 16 do
- if bv >= battlewindow[emptychars*17 + i] and bv < battlewindow[emptychars*17 + i + 1] then
- gui.text(4, yoffset+18, "RNG: " .. string.format("%2X",bv)..
- " (left " .. string.format("%2d", battlewindow[emptychars*17+ i + 1] - bv) .. ")",regcolor)
- gui.text(4, yoffset+26, "Load Window: " .. windowname[i],regcolor)
- end
- end
- end
- end
- function displayCrits()
- --Get equipment and their crit chance
- chance = 0
- crittext = ""
- for i = 1,3 do
- if chars[i] < 0x07 then
- weap = memory.readbyte(CHAR_WEAP + 0x50*(chars[i]))
- acc = memory.readbyte(CHAR_ACC + 0x50*(chars[i]))
- if weap == 0x55 then chance = 1 -- rainbow
- elseif acc == 0xB3 and (weap == 0x42 or weap == 0x3D) then chance = 2 -- masamune + heromedal
- elseif weap == 0x40 or weap == 0x19 or weap == 0x1A then chance = 3 -- wonder, siren, valkerye
- elseif weap == 0x53 then chance = 4 -- swallow
- elseif weap == 0x54 or charname[chars[i]+1] == "F" or charname[chars[i]+1] == "A" then chance = 5 -- slasher2 (22)
- elseif weap == 0x0D or charname[chars[i]+1] == "M" or charname[chars[i]+1] == "L" then chance = 6 -- kaliblade
- elseif charname[chars[i]+1] == "C" or charname[chars[i]+1] == "R" or charname[chars[i]+1] == "J" then chance = 7 end
- space = " "
- if chance ~= 7 then space = "+ " end
- crittext = crittext .. charname[chars[i]+1] .. "=" .. chance .. space
- end
- end
- gui.text(202,yoffset+18,"Crits: "..string.sub(crits, cv+1, cv+6), regcolor)
- if emptychars == 2 then
- gui.text(202, yoffset+26, " Crono=7 ",regcolor)
- else gui.text(202, yoffset+26, crittext, regcolor) end
- end
- local FACING = 0x7e1600
- local MOVING = 0x7e1680
- local facing = {}
- local moving = {}
- local faceoffset = 5 -- experimental
- local MAP_X = 0x7e1800
- local MAP_Y = 0x7e1880
- local mapx = {}
- local mapy = {}
- local mapoffsetx = 0
- local mapoffsety = 0
- local SCREEN_X = 0x7e0A00
- local SCREEN_Y = 0x7e0A80
- local mainsprite = 0
- local farsprite = 0
- local xsign,ysign = "",""
- local xcolor,ycolor = 0,0
- function displayHitbox()
- for i = 1,64 do
- mapx[i] = math.floor(memory.readword(MAP_X + 2*(i-1))/16)
- mapy[i] = math.floor(memory.readword(MAP_Y + 2*(i-1))/16)
- facing[i] = memory.readbyte(FACING + 2*(i-1))
- if memory.readbyte(MOVING + 2*(i-1)) > 0 then
- moving[i] = 1
- else moving[i] = 0 end
- end
- mainsprite = 0
- farsprite = 0
- for i = 1,16 do -- get one sprite to compare
- spritex = memory.readword(SCREEN_X + 2*(i-1))
- spritey = memory.readword(SCREEN_Y + 2*(i-1))
- if spritex > 0 and spritey > 0 and mapx[i] ~= 0xFF0 and mapx[i] ~= 0xFF8 and mapx[i] ~= 0x178 and mapx[i] ~= 0x088 then
- if mainsprite == 0 then
- mapoffsetx = mapx[i] - spritex
- mapoffsety = mapy[i] - spritey
- mainsprite = i
- elseif farsprite == 0 then
- farsprite = i
- elseif farsprite > 0 and i < 9 then
- if (mapx[i]-mapx[mainsprite])^2 + (mapy[i]-mapy[mainsprite])^2 >
- (mapx[farsprite]-mapx[mainsprite])^2 + (mapy[farsprite]-mapy[mainsprite])^2 then
- farsprite = i
- break
- end
- end
- end
- end
- if mapx[mainsprite] ~= nil then
- if mapx[mainsprite]%2 == 1 then xcolor = "#CC4040" else xcolor = regcolor end
- if mapy[mainsprite]%2 == 1 then ycolor = "#CC4040" else ycolor = regcolor end
- gui.text(210,yoffset+18, "P1: ",regcolor)
- gui.text(226,yoffset+18,string.format("%03X",mapx[mainsprite]),xcolor)
- gui.text(242,yoffset+18,string.format("%03X",mapy[mainsprite]),ycolor)
- end
- if mapx[farsprite] ~= nil then
- xdiff = mapx[farsprite] - mapx[mainsprite]
- ydiff = mapy[farsprite] - mapy[mainsprite]
- if xdiff > 0 then xsign = "+" else xsign = "-" end
- if ydiff > 0 then ysign = "+" else ysign = "-" end
- gui.text(206,yoffset+26, " P3: "..xsign..string.format("%2X",math.abs(xdiff)).." "..
- ysign..string.format("%2X",math.abs(ydiff)),regcolor)
- end
- for i = 1,64 do
- screenx = mapx[i] - mapoffsetx - 8
- screeny = mapy[i] - mapoffsety - 16
- if screenx < 240 and screeny < 208 then
- --[[
- if i < 9 then color = "#0000ff00" else color = "#00ff0000" end
- if facing[i] == 0 then
- gui.box(screenx+0, screeny-faceoffset*moving[i], screenx+15, screeny+15-faceoffset, color) --up
- elseif facing[i] == 1 then
- gui.box(screenx+0, screeny+faceoffset, screenx+15, screeny+15+faceoffset*moving[i], color) --down
- elseif facing[i] == 2 then
- gui.box(screenx-faceoffset*moving[i], screeny+0, screenx+15-faceoffset, screeny+15, color) --left
- elseif facing[i] == 3 then
- gui.box(screenx+faceoffset, screeny+0, screenx+15+faceoffset*moving[i], screeny+15, color) --right
- else
- gui.box(screenx+0, screeny+0, screenx+15, screeny+15, color) end
- ]]
- gui.text(screenx+faceoffset, screeny+faceoffset, string.format("%x",2*(i-1)),"#80808080","#00000000")
- end
- end
- end
- local emuframe = 0
- local moviedata = {}
- local movieoffset = 0
- function displayJoypad()
- emuframe = emu.framecount()
- --Read in movie file:
- if movie.mode() == "playback" and movieoffset == 0 then
- f = io.open(movie.name(), "rb")
- byte = f:read(1)
- while byte ~= nil do
- byte = string.byte(byte)
- table.insert(moviedata, byte)
- byte = f:read(1)
- end
- f:close()
- for i = 0,3 do
- movieoffset = movieoffset + moviedata[0x1C+1+i]*(0x100^i)
- end
- end
- --Get inputs either from movie or user:
- if movie.mode() == "playback" then
- word = moviedata[movieoffset + emuframe*2 + 1] + moviedata[movieoffset + emuframe*2]*0x100
- word = math.floor(word / 16) --discard 4 lowest bits; Lua uses all doubles (floating point)
- for i = 1, 12 do
- if word % 2 == 1 then
- inputs[ button[i] ] = true
- else inputs[ button[i] ] = nil end
- word = math.floor(word / 2)
- end
- else inputs = joypad.get() end
- --Draw each button (color it based on hold duration):
- for i = 1, 12 do
- if inputs[button[i]] then
- if pressdur[i] > 0 then
- if pressdur[i] < 250 then
- pressdur[i] = pressdur[i] + 4
- end
- else pressdur[i] = 4 end
- else
- if pressdur[i] < 0 then
- if pressdur[i] > -250 then
- pressdur[i] = pressdur[i] - 4
- end
- else pressdur[i] = -4 end
- end
- shoulder = 0
- if i == 1 or i == 2 then shoulder = 1 end
- if pressdur[i] > 0 then
- gui.box(
- xoffset+xcoords[i]*7, yoffset+ycoords[i]*6,
- xoffset+xcoords[i]*7+7 + shoulder*7, yoffset+ycoords[i]*6+6 - shoulder*3,
- "#ff"..string.format("%02x",pressdur[i]).."00".."ff", "#FFFFFFFF")
- else darken = string.rep(string.format("%02x",0xFF + pressdur[i]/4),3)
- gui.box(
- xoffset+xcoords[i]*7, yoffset+ycoords[i]*6,
- xoffset+xcoords[i]*7+7 + shoulder*7, yoffset+ycoords[i]*6+6 - shoulder*3,
- "#00".."00".."FF"..string.format("%02x",0xFF+pressdur[i]), "#"..darken.."FF") end
- end
- gui.text(xoffset+30,209,"-",regcolor,"#00000000") --attn: select button
- end
- function Saving()
- timesav = frame
- locsav = locstart
- batsav = batstart end
- savestate.registersave(Saving) -- for room timing, only works with MOST RECENT state
- function Reload()
- frame = timesav
- locstart = locsav
- batstart = batsav
- recentload = 1 end
- savestate.registerload(Reload)
- while true do
- inputs = joypad.get()
- --Catch <select> pressed
- if inputs[ button[10] ] then
- if selectheld == 0 then
- selectheld = 1
- if dispbox == 3 then
- dispbox = 0
- else dispbox = dispbox + 1 end
- end
- else selectheld = 0 end
- --Catch menu
- if menutime ~= memory.readbyte(MENU_TIME) then
- if menuopen == 0 then
- menuopen = 1 end
- else menuopen = 0 end
- menutime = memory.readbyte(MENU_TIME)
- --Display all
- displayValues()
- displayTime()
- if (dispbox == 2 or dispbox == 3) and battleflag == 0 and loc < 0x1F0 and menuopen == 0 then
- displayHitbox()
- else displayCrits() end
- -- if dispbox == 1 or dispbox == 3 then displayJoypad()
- -- else gui.text(xoffset, 208, " room/battle time","#808080") end
- emu.frameadvance()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement