Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Chrono Trigger Infoscope for Snes9x(1.51-rr) AND BIZHAWK 1.11.5
- -- 2016/08/23 Redslash
- -- Features:
- -- Top: timing from Title Screen (with 60.09fps vs 59.94fps offset); framecount below
- -- Bottom: RNG "Timeline" with markers for jumps
- -- Left: Treasure counter, Battle Speed, Crit value (color-coded to match RNG chart)
- -- Right Side: Room timing -> these are posted to the Lua console
- -- out-of-menu + in-menu = total time
- -- Battle: HP, ATB, Damage Dealt (easier to check damage numbers), Runaway counter (120 frames = escape)
- -- Pause+Select: Hitboxes/triggers, w/ Object IDs (optional); Input Display shows press vs held
- --HOW TO USE:
- -- 1. get specific emulator http://tasvideos.org/EmulatorResources/Snes9x.html (top link)
- -- 2. download this pastebin (as .LUA file), and open it from Bizhawk or Snes9x: File > Lua Scripting > New Lua Script Window
- -- older versions:
- -- 2016/05/23 http://pastebin.com/RgWyzGpR
- -- 2016/02/02 http://pastebin.com/epGpuMy0
- -- 2015/10/30 http://pastebin.com/J0C5kDnF
- -- OPTIONS ( 1=enable, 0=disable )
- local autotext = 1 -- hold Select to auto-close text
- local dispObjectID = 1 -- view Sprite (Object) IDs
- local dispCronoBox = 0 -- view PC's hitboxes
- local BIZ
- function emutest() gui.pixel(0,0,"#000000") end
- if pcall(emutest) then
- BIZ = false
- button = {'R','L','X','A','right','left','down','up','start','select','Y','B'}
- else
- BIZ = true
- button = {'P1 R','P1 L','P1 X','P1 A','P1 Right','P1 Left','P1 Down','P1 Up','P1 Start','P1 Select','P1 Y','P1 B'}
- memory.usememorydomain("CARTROM")
- end
- function ReadByte(i)
- if BIZ then return mainmemory.read_u8(i)
- else return memory.readbyte(0x7e0000 + i) end
- end
- function ReadWord(i)
- if BIZ then return mainmemory.read_u16_le(i)
- else return memory.readword(0x7e0000 + i) end
- end
- function ReadByte_ROM(i)
- if BIZ then return memory.read_u8(i)
- else return memory.readbyte(0xc00000 + i) end
- end
- function ReadWord_ROM(i)
- if BIZ then return memory.read_u16_le(i)
- else return memory.readword(0xc00000 + i) end
- end
- function DrawPixel(x,y,color)
- if BIZ then return gui.drawPixel(x,y,color)
- else return gui.pixel(x,y,fixColor(color)) end
- end
- function DrawBox(x1,y1,x2,y2,color,fill)
- if BIZ then return gui.drawBox(x1,y1,x2,y2,color,fill)
- else return gui.box(x1,y1,x2,y2,fixColor(color),fixColor(fill)) end
- end
- function DrawText(x,y,text,color,back)
- if BIZ then
- if back == "shadow" then back = nil end
- return gui.pixelText(x,y,text,color,back)
- else return gui.text(x,y,text,fixColor(color),fixColor(back)) end
- end
- function Pause()
- if BIZ then return client.pause()
- else return emu.pause() end
- end
- local lowfade = 0x20000000
- local infade = 0x80000000
- local outfade = 0xc0000000
- local nofade = 0xff000000
- local dispy = 191
- local yoffset = 168
- local xoffset = 70 -- 89 = button display centered
- local button = {}
- local inputs = joypad.get()
- local btnlabel= {' r','l','X','A','>','<','v','^','S','-','Y','B'}
- local xcoords = { 8.6, 0.4, 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 press = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
- local unpress = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
- local turbo = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
- local selectheld = 0
- local s9xcolor = {
- ["red"] ="#FF0000", ["darkred"] ="#a00000",
- ["green"] ="#00FF00", ["darkgreen"] ="#008000",
- ["blue"] ="#0000FF", ["navy"] ="#2020FF",
- ["yellow"] ="#FFFF00", ["goldenrod"] ="#808000",
- ["cyan"] ="#00FFFF", ["darkcyan"] ="#008080",
- ["magenta"] ="#FF00FF", ["darkmagenta"] ="#a000a0",
- ["white"] ="#FFFFFF", ["silver"] ="#a0a0a0",
- ["gold"] ="#ffd700", ["darkorange"] ="#FF950E",
- ["gray"] ="#808080", ["darkgray"] ="#404040",
- ["brown"] ="#a52a2a",
- ["none"] ="#00000000",["shadow"]="#00000080"}
- function fixColor(c)
- if type(c) == "number" then
- alpha = math.floor(c/1000000)
- return (c%0x1000000)*0x100 + alpha
- else return s9xcolor[c] end
- end
- local CT_Ver = "J" -- determine "U" or "J" to subtract Title Screen
- if ReadWord_ROM(0x0C650B) == 0xBEB1 then CT_Ver = "U" end
- local CT_button = {["10"]=button[1],["20"]=button[2],["40"]=button[3],["80"]=button[4],
- ["1"]=button[9],["2"]=button[10],["4"]=button[11],["8"]=button[12]}
- local MENU_POS = 0x00ec
- local BATTLE_FLAG = 0x0117
- local battleflag = 0
- local battlecopy = 0
- local FACING = 0x1600
- local MOVING = 0x1680
- local facing = {}
- local moving = {}
- local faceoffset = 5 -- experimental
- local MAP_X = 0x1800
- local MAP_Y = 0x1880
- local mapx = {}
- local mapy = {}
- local mapoffsetx = 0
- local mapoffsety = 0
- local SCREEN_X = 0x0A00
- local SCREEN_Y = 0x0A80
- local mainsprite = 0
- local farsprite = 0
- local xsign,ysign = "",""
- local xcolor,ycolor = 0,0
- local CHAR_ID = 0x2980 -- 3 in-party then 6 reserve (e.g. for 1-on-1 bosses)
- local CHAR_WEAP = 0x2629
- local CHAR_HELM = 0x2627
- local CHAR_VEST = 0x2628
- local CHAR_ACC = 0x262A
- local crits = "0737062067712743017053012106621026206760245002737143667207070014"..
- "1101674231747620560305126422403270125313166113731602620666773021"..
- "1714114244363074011420427072702021156152710015037100071773030063"..
- "3110560024303132144471071671003163600200333701061633241110004006"..
- "0737062067" --wrap-around
- local critcolor = {"gray","gray","darkgreen","magenta",
- "cyan","green","darkorange","white"}
- local LOCATION = 0x0100
- local loc = ReadWord(LOCATION)
- local loc_P = ReadWord(LOCATION+5)
- local locs = {} --http://datacrystal.romhacking.net/wiki/Chrono_Trigger/List_of_Locations
- locs[0x000] = "Load Screen"
- local frame = 0
- local locstart = 0
- local menutime = 0
- local timeend,menuend = 0,0
- local recentload = 1
- local segcount = 0
- local MENU_INDICATOR = 0x06fe
- local menu_state = 0
- local totalsecond,menusecond,diffsecond = 0,0,0
- function UpdateTime()
- loc0 = string.char(65+math.floor(loc_P/26))..string.char(65+loc_P%26)
- loc1 = string.char(65+math.floor(loc/26))..string.char(65+loc%26)
- loc2 = ReadWord(LOCATION)
- if loc ~= loc2 then
- loc2 = loc0..">"..loc1..">"..string.char(65+math.floor(loc2/26))..string.char(65+loc2%26)
- else loc2 = loc0..">"..loc1.." ("..segcount..")" end
- if recentload == 1 then
- loc2 = "*"..loc2
- else loc2 = " "..loc2 end
- totalsecond = timeend / 60
- menusecond = menuend / 60
- diffsecond = (timeend - menuend) / 60
- if BIZ then
- print(string.format("%06.2f ",diffsecond)..
- string.format("%06.2f ",menusecond)..
- string.format("%06.2f ",totalsecond)..loc2)
- else
- print(string.format("%06.2f",diffsecond).."\t"..
- string.format("%06.2f",menusecond).."\t"..
- string.format("%06.2f",totalsecond).."\t"..loc2)
- end
- recentload = 0
- end
- function displayTime()
- frame = frame + 1
- --Catch menu state change
- menu_ind = ReadByte(MENU_INDICATOR)
- if (menu_state == 0 and (menu_ind == 0xA3 or menu_ind == 0x84 )) then
- menu_state = 1
- end
- if (menu_state == 1 and (menu_ind == 0xA9
- or menu_ind == 0xB9 or menu_ind == 0xD1 )) then
- menu_state = 0
- end
- if (menu_state == 1) then menutime = menutime + 1 end
- --catch change in Battleflag or Location
- if battleflag ~= ReadByte(BATTLE_FLAG) % 2 then
- timeend = frame - locstart
- menuend = menutime
- menutime = 0
- segcount = segcount + 1
- UpdateTime()
- locstart = frame
- elseif loc ~= ReadWord(LOCATION) then
- timeend = frame - locstart
- menuend = menutime
- menutime = 0
- segcount = 0
- UpdateTime()
- locstart = frame
- end
- battleflag = ReadByte(BATTLE_FLAG) % 2
- loc = ReadWord(LOCATION)
- loc_P = ReadWord(LOCATION+5)
- p_y = 1
- if (ReadByte(MENU_POS) == 0) then p_y = yoffset + 21 end
- DrawText(xoffset+153,p_y," "..string.format("%6.2f",diffsecond),"silver","shadow")
- DrawText(xoffset+153,p_y+8," "..string.format("%6.2f",menusecond),"silver","shadow")
- DrawText(xoffset+153,p_y+16," "..string.format("%6.2f",totalsecond),"silver","shadow")
- end
- local redbox = {}
- redbox[0x70] = {0x14,0x2e,0x30,0x32,0x28}
- redbox[0x77] = {0x32,0x34,0x3c,0x3e,0x28,0x2a,0x46,0x1c,0x1e}
- redbox[0x91] = {0x14,0x16}
- redbox[0x8c] = {0x20,0x22,0x24,0x2e,0x30,0x1e,0x1a} --3 frogs are friendly
- redbox[0x1d5] = {0x1c,0x26}
- redbox[0xb0] = {0x20,0x22}
- --redbox[0xa8] = {0x14,0x16,0x18,0x1a,0x1c,0x1e} --ozzie pits
- redbox[0x8e] = {0x24}
- redbox[0x92] = {0x10,0x18}
- redbox[0x93] = {0x10,0x18,0x1a}
- redbox[0x96] = {0x10}
- redbox[0x90] = {0x10,0x12,0x1a}
- redbox[0x94] = {0x10,0x12}
- redbox[0x8f] = {0x28,0x2a,0x1c,0x2c}
- redbox[0x82] = {0x3c,0x44,0x40,0x26,0x28,0X32,0x38,0x24,0x30,0x34,0x36,0x10,0x16,0x18}
- redbox[0x83] = {0x66,0x68,0x5e,0x1c,0x2c,0x32,0x40,0x4c,0x4e,0x50}
- redbox[0x84] = {0x1a,0x1c,0x1e,0x20,0x22,0x24,}
- redbox[0x78] = {0x16}
- redbox[0x13] = {0x1c,0x24,0x26,0x28,0x2a,0x2c,0x2e,0x30,0x3c,0x3e,0x40}
- redbox[0x1C] = {0x4}
- redbox[0x15] = {0x22}
- redbox[0xd4] = {0x24,0x26,0x28,0x2a,0x3a,0x3c,0x3e,0x40,0x42,0x12,0x14,0x16,0x18,0x1a,0x1c}
- redbox[0xd7] = {0x10,0x12,0x14,0x16,0x18,0x1a,0x1c}
- redbox[0xd9] = {0x20,0x22,0x24,0x26,0x18,0x1a,0x1c,0x1e,0x14,0x16}
- redbox[0xe4] = {0x16,0x18,0x1a}
- redbox[0x1d1] = {0x20,0x22,0x24,0x26,0x28}
- redbox[0x112] = {0x12,0x14,0x16,0x18,0x1c,0x1e,0x22,0x24,0x26,0x28,0x2a,0x2c}
- redbox[0x11a] = {0x2a,0x2c,0x2e,0x30,0x32,0x34,0x36,0x38}
- redbox[0x11d] = {0x20,0x22}
- redbox[0x11e] = {0x10}
- redbox[0x11f] = {0x1a,0x1c,0x1e,0x20,0x22,0x24}
- redbox[0x120] = {0x14,0x16,0x18}
- redbox[0x11c] = {0x12,0x14,0x16,0x18}
- redbox[0xa4] = {0x16,0x18,0x1a}
- redbox[0x7d] = {0x12,0x22,0x1e}
- redbox[0x1be] = {0x24,0x26,0x28,0x2a,0x2c,0x2e}
- redbox[0x1bf] = {0x30,0x32,0x34,0x36,0x38,0x3a}
- redbox[0x125] = {0x18,0x1a,0x1c,0x1e,0x22,0x24,0x28,0x2c,0x26,0x30}
- redbox[0x126] = {0x16,0x1a,0x1c,0x28}
- redbox[0x12a] = {0x22,0x24,0x26,0x28,0x2c,0x2e,0x30,0x3e,0x42,0x40,0x5c,0x5e,0x60,0x62,0x6e,0x70,0x72}
- redbox[0x12b] = {0x14,0x12,0x16,0x18}
- redbox[0x131] = {0x10,0x12,0x14,0x1c,0x24,0x20}
- redbox[0x130] = {0x12,0x14}
- redbox[0x12f] = {0x1a,0x18}
- redbox[0xdb] = {0x10,0x12}
- redbox[0xa0] = {0x02,0x04,0x06,0x08,0x0a}
- redbox[0xa1] = {0x20}
- redbox[0xec] = {0x1c,0x36,0x3c,0x22,0x24,0x26,0x3e,0x46,0x28,0x16,0x18,0x14} --sewer
- redbox[0xed] = {0x2c} --sewer
- redbox[0x18a]= {0x16} --woe
- redbox[0x188]= {0x32,0x34} --woe
- redbox[0x189]= {0x2c} --woe
- redbox[0x195]= {0x14,0x16,0x1e,0x20,0x2a,0x18,0x1a,0x1c} --op
- redbox[0x196]= {0x14,0x1a,0x1c,0x2e,0x30,0x32,0x36,0x38,0x3a} --op
- redbox[0x197]= {0x1c,0x1e,0x30,0x36,0x24,0x2a} --op
- redbox[0x198]= {0x0e,0x10,0x12} --op
- redbox[0x199]= {0x26,0x28,0x2a,0x2c,0x30,0x32,0x34,0x36} --op
- redbox[0x19a]= {0x0e,0x10} --op
- redbox[0x171]= {0x1e} --blackbird
- redbox[0x16b]= {0x30,0x32,0x34,0x36,0x38,0x3a} -- giant's claw
- redbox[0xc3] = {0x1c,0x1e} -- giant's claw
- redbox[0x139]= {0x10,0x18,0x1e,0x26,0x28,0x2a,0x2c,0x2e} -- omen
- redbox[0x13a]= {0x10,0x12,0x14,0x1a,0x1c,0x1e,0x24,0x2c,0x2e,0x30,0x32,0x34,0x36,0x38,0x3e,0x40,0x42,0x44,0x46,0x48,0x4a} -- omen
- redbox[0x13d]= {0x1a,0x26,0x28,0x2a,0x2c}
- redbox[0x142]= {0x10,0x12,0x14,0x2a,0x2c,0x2e}
- redbox[0x143]= {0x12,0x14} -- gigamute
- redbox[0x144]= {0x1a,0x1c}
- redbox[0xf5]= {0x10,0x12,0x14,0x16,0x18} -- deathpeak
- redbox[0xf6]= {0x16,0x12,0x14,0x1a,0x1c} -- deathpeak
- redbox[0x107]= {0x10,0x12,0x14} -- deathpeak
- redbox[0x108]= {0x16,0x18,0x14,0x20} -- deathpeak
- redbox[0x104]= {0x10,0x12,0x14,0x16,0x18,0x1a,0x1c,0x1e} -- deathpeak
- redbox[0x1a]= {0x18} -- yakra13
- redbox[0x1b8]= {0x1a,0x1c} -- yakra13
- local trigger = {}
- trigger[0xc6] = {0x010d,0x020d,0x030d,0x040d,0x050d,0x060d,0x070d,0x080d,0x090d,0x0a0d,0x0b0d,0x0c0d,0x0d0d}
- trigger[0xd4] = {0x0c34,0x0d34,0x0e34,0x0f34,0x1034,
- 0x0c33,0x0d33,0x0e33,0x0f33,0x1033,
- 0x0c32,0x0d32,0x0e32,0x0f32,0x1032,
- 0x0c31,0x0d31,0x0e31,0x0f31,0x1031,
- 0x0c30,0x0d30,0x0e30,0x0f30,0x1030,
- 0x1727,0x1827,0x1927,
- 0x0714,0x0715,0x0716,0x0717,0x0718,0x0719,0x071a,0x071b,0x071c}
- trigger[0xd5] = {0x2622,0x2623,0x2624,0x2625,0x2626,
- 0x2d37,0x2d38,0x2d39,0x2d3a,0x2d3b,
- 0x2e31,0x2e30,
- 0x3925,0x3a25,0x3b25,0x3c25,0x3d25,
- 0x3437,0x3438,0x3439,0x343a,0x343b}
- trigger[0xda] = {0x352a,0x362a,0x372a,0x382a,0x392a,0x3a2a}
- trigger[0xe2] = {0x3424,0x3524,0x3624,0x3724,0x3824,0x3924,0x3a24,
- 0x3423,0x3523,0x3623,0x3723,0x3823,0x3923,0x3a23,0x3b23,
- 0x3422,0x3522,0x3622,0x3722,0x3822,0x3922,0x3a22,0x3b22,
- 0x3421,0x3521,0x3621,0x3721,0x3821,0x3921,0x3a21}
- trigger[0xe6] = {0x1323,0x1324,0x1325,0x1326,
- 0x0d23,0x0d24,0x0d25,0x0d26,0x0431,0x0d3d,0x0d3c}
- trigger[0x30] = {0x0914,0x0915,0x0916,0x0917,0x0918,0x0919,0x091a}
- trigger[0x31] = {0x1f2f,0x202f,0x212f,0x222f,0x232f,0x242f,0x252f,0x262f,0x272f,
- 0x1f30,0x1f31,0x1f32,0x1f33,0x1f34,
- 0x122b,0x122c,0x122d,0x122e,0x122f}
- trigger[0x2f] = {0x3235,0x3335,0x3435,0x3535,0x3635,0x3735,0x3835,0x3935,0x3a35,0x3b35,0x3c35,
- 0x2933,0x2932,0x2931,0x2833,0x2832,0x2831,0x2a33,0x2a32,0x2a31,
- 0x102c,0x0f2c,0x0e2c,0x0d2c,0x0c2c,0x0b2c,
- 0x301f,0x311f,0x321f,0x331f,0x341f,0x351f,0x361f,0x371f,0x381f,0x391f}
- trigger[0x87] = {0x3308,0x3309,0x330a,0x2a07,0x2a08,0x2a09,0x2a0a}
- trigger[0x91] = {0x0e02,0x0e03,0x0e04,0x0e05,0x0d05,0x0c05,0x0b05,0x0a05,0x0905}
- trigger[0x8e] = {0x0518,0x0618,0x0418,0x0318,0x0218}
- trigger[0x2a] = {0x0712,0x0612,0x0512,0x0812,0x1012,0x0912}
- trigger[0xa8] = {0x320a,0x3310,0x390f,0x390c,0x3a08,0x3c0b,
- 0x320b,0x3311,0x3910,0x390d,0x3a09,0x3c0c,
- 0x330a,0x3410,0x3a0f,0x3a0c,0x3b08,0x3d0b,
- 0x330b,0x3411,0x3a10,0x3a0d,0x3b09,0x3d0c}
- trigger[0x124] = {0x080e,0x090e,0x0a0e,0x0b0e,0x070e,0x060e,0x050e,0x030e,0x020e,0x010e,0x000e,0x0d0e,0x0e0e}
- trigger[0x12e] = {0x0f0d,0x0f0e,0x0f0f,0x0f10,0x0f11}
- trigger[0xa0] = {0x0e10,0x0d10,0x0c10,0x0b10,0x0a10,0x0910,0x0f10,0x1010,0x1110,0x1210,0x1310,0x1410,0x1510,
- 0x0909,0x090a,0x090b,0x090c,0x090d,0x090e,0x090f}
- trigger[0x1d6] = {0x252e,0x262e,0x272e,0x282e,0x292e,
- 0x2522,0x2622,0x2722,0x2822,0x2922,
- 0x2516,0x2616,0x2716,0x2816,0x2916,
- 0x250a,0x260a,0x270a,0x280a,0x290a,0x2705}
- trigger[0xe0] = {0x0707,0x0708,0x0709,0x070a,0x070b,0x070c,0x070d,0x1d0a,0x1d0b,0x1d0c,0x1d0d}
- trigger[0x184]= {0x072f,0x062f,0x052f,0x082f,0x092f,0x0a2f,
- 0x061d,0x051d,0x041d,0x031d,
- 0x0811,0x0911,0x0a11,0x0b11} --beasts
- trigger[0x18a]= {0x232d,0x242d,0x252d,0x262d,0x272d,0x282d,0x292d}
- trigger[0x188]= {0x2407,0x2408,0x2409,0x240a,0x240b,
- 0x0f13,0x1013,0x1113,0x1213,0x1313,0x1413,
- 0x3210,0x3211,0x3212,0x3213,0x3214,0x3215,0x3216,
- 0x2e1e,0x2e1f,0x2e20,0x2e21,0x2e22,0x2e23,0x2e24,0x2e25,
- 0x302d,0x302d,0x302e,0x302f,0x302d,0x3030,0x3031,0x3032,0x3033,0x3034,0x3035,0x3036,0x3037,0x3038,0x3039}
- trigger[0x189]= {0x0c29,0x0d29,0x0e29,0x0f29,0x1029,0x1129,0x1229,
- 0x1911,0x1912}
- trigger[0x199]= {0x010d,0x020d,0x030d,0x040d,0x050d,0x060d,0x070d,0x080d,0x090d,0x0a0d,0x0b0d,0x0c0d,0x0d0d,0x0e0d,
- 0x116d,0x126d,0x136d,0x146d,0x156d,0x166d,0x176d,0x186d,0x196d,0x1a6d,0x1b6d,0x1c6d,0x1d6d,0x1e6d}
- trigger[0x19b]= {0x0013,0x0113,0x0213,0x0313,0x0413,0x0513,0x0613,0x0713,0x0813,0x0913,0x0a13,0x0b13,0x0c13,0x0d13,0x0e13,0x0f13}
- trigger[0x16b]= {0x1019,0x0f19,0x0e19,0x0d19,0x0c19} -- giant's claw
- trigger[0xc4] = {0x163a,0x163b,0x163c,0x0a3a,0x0a3b,0x0a3c} -- giant's claw
- trigger[0x128]= {0x3338,0x3438,0x3538,0x3638,0x3738,0x3838} -- giant's claw
- trigger[0x6d] = {0x1c0d,0x1c0e,0x1c0f,0x1c10,0x1c11} -- giant's claw
- trigger[0xc5] = {0x0b29,0x0c29,0x0d29} -- giant's claw
- trigger[0xb7] = {0x2128,0x2228,0x2328,0x2428,0x2528,0x2628,0x2728,0x2828,0x2928,0x2a28,0x2b28,0x2c28,0x2d28} -- ozzie
- trigger[0xb2] = {0x1411,0x1511,0x1611,0x1711,0x1811,0x1911,0x1a11} -- ozzie
- trigger[0xb8] = {0x2128,0x2228,0x2328,0x2428,0x2528,0x2628,0x2728,0x2828,0x2928,0x2a28,0x2b28,0x2c28,0x2d28} -- ozzie
- trigger[0xb3] = {0x0124,0x0224,0x0324,0x0824,0x0924,0x0a24,0x0b24,0x0c24,0x0d24} -- ozzie
- --final ozzie
- trigger[0x13e]= {0x1808,0x1809,0x180a,0x180b,0x180c,0x1b08,0x1b09,0x1b0a,0x1b0b,0x1b0c, -- omen
- 0x3508,0x3509,0x350a,0x350b,0x350c,0x3808,0x3809,0x380a,0x380b,0x380c}
- local warning = {}
- warning[0x92] = {0x081b}
- warning[0x70] = {0x0d09,0x0c09,0x0b09,0x0e09,0x0712,0x0912,0x0812,0x0b0d,0x0c0d}
- warning[0x7a] = {0x30,0x32,0x34}
- warning[0x48] = {0x1211,0x1212,0x1213,0x1207,0x1208,0x1209}
- warning[0x8e] = {0x1235,0x0f35,0x0e35,0x0d35,
- 0x1234,0x1134,0x1034,0x0f34,0x0d34}
- warning[0x120] ={0x0622,0x0623,0x0624,0x0625,0x0626,0x0627,0x0628,0x0629,0x062a,0x062b,0x062c,0x062d,0x062e,0x062f,0x0630,0x0631,0x0632,
- 0x0722,0x0723,0x0724,0x0725,0x0726,0x0727,0x0728,0x0729,0x072a,0x072b,0x072c,0x072d,0x072e,0x072f,0x0730,0x0731,0x0732,
- 0x0822,0x0823,0x0824,0x0825,0x0826,0x0827,0x0828,0x0829,0x082a,0x082b,0x082c,0x082d,0x082e,0x082f,0x0830,0x0831,0x0832,
- 0x0436,0x0536,0x0636,0x0736,
- 0x0437,0x0537,0x0637,0x0737,
- 0x0438,0x0538,0x0638,0x0738}
- warning[0x196]= {0x240a,0x240b,0x240c,0x240d,0x240e,0x240f,0x2410}
- warning[0x135]= {0x0727,0x0827,0x0927,0x0a27,0x0627,0x0628,0x0629,0x062a,0x062b,0x062c,0x062d,0x071b,0x081b} --omen
- warning[0x137]= {0x071a,0x081a,0x0706,0x0806} --omen
- warning[0x138]= {0x061e,0x061d,0x061c,0x071e,0x071d,0x071c,0x081e,0x081d,0x081c,0x091e,0x091d,0x091c,0x0a1e,0x0a1d,0x0a1c,0x0b1d,0x0b1c,
- 0x031f,0x041f,0x051f,0x061f,0x071f,0x081f,0x091f,0x0a1f,0x0b1f,
- 0x0320,0x0420,0x0520,0x0620,0x0720,0x0820,0x0920,0x0a20,0x0b20,0x0c20, --omen
- 0x0421,0x0521,0x0621,0x0721,0x0821,0x0921,0x0a21,0x0b21,0x0c21,0x0d21, --omen
- 0x0522,0x0622,0x0722,0x0822,0x0922,0x0a22,0x0b22,0x0c22,0x0d22,0x0e22, --omen
- 0x0623,0x0723,0x0823,0x0923,0x0a23,0x0b23,0x0c23,0x0d23,0x0e23, --omen
- 0x0724,0x0824,0x0924,0x0a24,0x0b24,0x0c24,0x0d24,0x0e24, --omen
- 0x0825,0x0925,0x0a25,0x0b25,0x0c25,0x0d25,0x0e25,
- 0x0926,0x0a26,0x0b26,0x0c26,0x0d26,
- 0x0927,0x0a27,0x0b27}
- warning[0x13f]= {0x3735,0x3835,0x3636,0x3736,0x3836,0x3936,0x3637,0x3737,0x3837,0x3937} -- omen
- warning[0xf4]= {0x3731,0x3732,0x3820,0x3821} -- deathpeak
- function displayHitbox()
- for i = 1,64 do
- mapx[i] = math.floor(ReadWord(MAP_X + 2*(i-1))/16)
- mapy[i] = math.floor(ReadWord(MAP_Y + 2*(i-1))/16)
- facing[i] = ReadByte(FACING + 2*(i-1))
- if ReadByte(MOVING + 2*(i-1)) > 0 then
- moving[i] = 1
- else moving[i] = 0 end
- end
- spritex = {}
- spritey = {}
- mainsprite = 0
- farsprite = 0
- for i = 1,16 do -- get one sprite to compare
- spritex[i] = ReadWord(SCREEN_X + 2*(i-1))
- spritey[i] = ReadWord(SCREEN_Y + 2*(i-1))
- if loc == 0xa0 then mainsprite = 7
- elseif loc == 0xa1 then mainsprite = 8
- elseif mainsprite == 0 and spritex[i] > 0 and spritey[i] > 0 and mapx[i] ~= 0xFF0 and
- (mapy[i] ~= 0xff0 and mapx[i] ~= 0x178) and
- (mapy[i] ~= 0xff0 and mapx[i] ~= 0x088) and
- (mapy[i] ~= 0xff0 and mapx[i] ~= 0x298) and
- (mapy[i] ~= 0xff0 and mapx[i] ~= 0x368) and
- (mapy[i] ~= 0xff0 and mapx[i] ~= 0x268) and
- (mapy[i] ~= 0xff0 and mapx[i] ~= 0x2b8) and
- (mapy[i] ~= 0xff0 and mapx[i] ~= 0x0c8) and
- (mapy[i] ~= 0xff0 and mapx[i] ~= 0xff8) then
- mainsprite = i
- end
- end
- if mainsprite ~= 0 then
- mapoffsetx = mapx[mainsprite] - spritex[mainsprite]
- mapoffsety = mapy[mainsprite] - spritey[mainsprite]
- end
- if warning[loc] ~= nil then
- if table.getn(warning[loc]) ~= nil then
- for j = 1,table.getn(warning[loc]) do
- screenx = math.floor(warning[loc][j] / 0x100)*0x10 - mapoffsetx
- screeny = (warning[loc][j] % 0x100)*0x10 - mapoffsety
- DrawBox(screenx,screeny,screenx+16,screeny+16,0x20ffff00,outfade+0xffff00) --outfade
- end
- end
- end
- if mainsprite ~= 0 and trigger[loc] ~= nil then
- special = 0
- if loc == 0xa8 then special = 8 end
- if table.getn(trigger[loc]) ~= nil then
- for j = 1,table.getn(trigger[loc]) do
- screenx = math.floor(trigger[loc][j] / 0x100)*0x10 - mapoffsetx --+ special
- screeny = (trigger[loc][j] % 0x100)*0x10 - mapoffsety
- DrawBox(screenx,screeny,screenx+15,screeny+7,infade+0x404040,outfade+0x404040)
- if screenx -1 < spritex[mainsprite] then
- DrawBox(screenx,screeny,screenx+7,screeny+7,infade+0xff0000,outfade+0xff0000)
- else DrawBox(screenx+8,screeny,screenx+15,screeny+7,infade+0xff0000,outfade+0xff0000) end
- end
- end
- end
- boxlimit = 64
- if loc == 0xa8 then boxlimit = 8 end
- for i = 1,boxlimit do
- isred = 0
- screenx = mapx[i] - mapoffsetx - 8
- screeny = mapy[i] - mapoffsety - 16
- if screenx < 260 and screeny < 216 then
- if i < 9 then color = nofade+0x0000ff else color = nofade+0x00ff00 end
- if redbox[loc] ~= nil then
- if table.getn(redbox[loc]) ~= nil then
- for j = 1,table.getn(redbox[loc]) do
- if i == redbox[loc][j]/2+1 then
- color = infade+0xff0000
- isred = 1
- end
- end
- end
- end
- if isred == 1 or dispCronoBox == 1 then
- screenx2 = screenx + 15
- screeny2 = screeny + 15
- if facing[i] == 0 then --up
- screeny = screeny - faceoffset*moving[i]
- screeny2= screeny2- faceoffset
- elseif facing[i] == 1 then --down
- screeny = screeny + faceoffset
- screeny2= screeny2+ faceoffset*moving[i]
- elseif facing[i] == 2 then --left
- screenx = screenx - faceoffset*moving[i]
- screenx2= screenx2- faceoffset
- elseif facing[i] == 3 then --right
- screenx = screenx + faceoffset
- screenx2= screenx2+ faceoffset*moving[i]
- end
- DrawBox(screenx-7,screeny-7,screenx2+7,screeny2+7, lowfade+0x408040,outfade+0xC0C040)
- DrawBox(screenx,screeny,screenx2,screeny2,color,outfade+0xff0000)
- end
- if (dispObjectID == 1) then
- DrawText(screenx+faceoffset, screeny+faceoffset, string.format("%x",2*(i-1)),"white","shadow")
- end
- end
- end
- DrawBox(0,211,256,224,"none")
- end
- local BATTLE_VALUE = 0x0026
- local BATTLE_STORE = 0x29AD
- local CRIT_VALUE = 0xB3E6
- local MENU_TIME = 0x0D00
- local loadmenutime = 0
- local menuopen = 0
- local CHAR_ID = 0x2980 -- 3 in-party, 6 reserve
- local chars = {}
- local ATB = 0xAFAB
- local atb = {}
- for i = 0,10 do atb[i] = ReadByte(ATB+i) end
- local windowname = {}
- windowname[0] = {"00","01","02","05","07","09","11","14","18","23","26","28","33","36","39","41"}
- windowname[1] = {"00","01","02","05","09","12","15","16","19","22","25","28","31","35","39","42"}
- windowname[2] = {"00","02","03","05","07","11","15","16","18","20","24","28","32","35","39","41"}
- local battlewindow = {} --set of windows for 0, 1, and 2 empty characters
- battlewindow[0] = { 0,0x09,0x0d,0x1d,0x2e,0x37,0x3e,0x58,0x61,0x88,0x98,0xab,0xb9,0xdc,0xe3,0xfb,256}
- battlewindow[1] = { 0,0x0d,0x12,0x17,0x35,0x40,0x5c,0x67,0x6a,0x88,0x8f,0xad,0xb3,0xd0,0xe4,0xfd,256}
- battlewindow[2] = { 0,0x0b,0x18,0x1d,0x2c,0x33,0x64,0x66,0x6d,0x79,0x85,0xa7,0xb6,0xd3,0xe6,0xf7,256}
- local bvrec = {}
- local bvrecsav = {}
- local bvprev = 0
- function Saving()
- -- bvrecsav = bvrec
- -- battleflagsav = battleflag
- -- locsav = loc
- -- framesav = frame
- -- locstsav = locstart
- -- batstartsav = batstart
- -- menusav = menutime
- -- menu_statesav = menu_state
- end
- if BIZ then event.onsavestate(Saving)
- else savestate.registersave(Saving) end
- -- for room timing, only works with MOST RECENT state
- function Reload()
- bvrec = bvrecsav
- battleflag = ReadByte(BATTLE_FLAG) % 2
- if battlecopy == 0 and battleflag == 1 then
- battlecopy = 1
- elseif battleflag == 0 then
- battlecopy = 0
- end
- loc = ReadWord(LOCATION)
- loc_P = ReadWord(LOCATION+5)
- frame = 0
- locstart = 0
- -- batstart = batstartsav
- menutime = 0
- recentload = 1
- end
- if BIZ then event.onloadstate(Reload)
- else savestate.registerload(Reload) end
- bvreccolor = {}
- for i = 0,255 do bvreccolor[i] = 8 end
- rulecolors={"darkred","red",
- "darkgreen","green",
- "blue","navy",
- "silver","white",
- "darkmagenta","magenta",
- "goldenrod","yellow",
- "darkcyan","cyan",
- "darkgray","gray"}
- function getValues()
- --Catch the BV copy
- if battlecopy == 0 and battleflag == 1 and ReadByte(BATTLE_VALUE) == ReadByte(BATTLE_STORE) then
- battlecopy = 1
- elseif battleflag == 0 then
- battlecopy = 0
- end
- --Get the active PCs
- mtchars = 0
- for i = 1,3 do
- chars[i] = ReadByte(CHAR_ID+i-1)
- if chars[i] >= 0x07 then mtchars = mtchars + 1 end
- end
- --Value is at different address for in-battle, out-of-battle, & load menu:
- if battlecopy == 1 then
- bv = ReadByte(BATTLE_VALUE)
- cv = ReadByte(CRIT_VALUE)
- else
- if (ReadByte(MENU_TIME) > 0 and ReadByte(BATTLE_STORE) == 0 and mtchars == 0) then
- --menutime is for ALL menus, BV is 0 for entire beginning... but load menu has "3 Crono's" (000000)
- bv = ReadByte(MENU_TIME)
- bvrec = {}
- else bv = ReadByte(BATTLE_STORE) end
- cv = bv
- end
- --overwrite interval between each BV change
- if bv > bvprev then
- for i = bvprev+1,bv-1 do bvrec[i] = 0 end
- bvrec[bv] = 1
- bvprev = bv
- bvreccolor[bv] = 8
- elseif bv < bvprev then
- for i = bvprev+1,255 do bvrec[i] = 0 end
- for i = 0,bv-1 do bvrec[i] = 0 end
- bvrec[bv] = 1
- bvprev = bv
- bvreccolor[bv] = 8
- end
- --catch ATB reset to determine whose action it was (for color-coding)
- newatb = {}
- for i = 0,10 do
- newatb[i] = ReadByte(ATB+i)
- if atb[i] == 0 and newatb[i] ~= 0 and newatb[i] ~= 0x80 then
- if bvreccolor[bv] == 8 then
- if i < 3 then
- bvreccolor[bv] = chars[i+1]
- else
- bvreccolor[bv] = 7
- end
- end
- end
- atb[i] = newatb[i]
- end
- end
- local charcolor = {"gold","blue","darkred","gray","darkgreen","brown","gray","gray","gray"}
- function displayValues()
- rulecolor = 1
- for j = 1,16 do
- if bv >= battlewindow[mtchars][j] and bv < battlewindow[mtchars][j+1] then
- rulecolor = j
- end
- end
- DrawText(bv-3,dispy+26,string.format("%02x",bv),rulecolors[rulecolor],"none")
- DrawText(bv-259,dispy+26,string.format("%02x",bv),rulecolors[rulecolor],"none") --wrap-around
- for i = 0,255 do
- for j = 1,16 do
- if i >= battlewindow[mtchars][j] and i < battlewindow[mtchars][j+1] then
- rulecolor = j
- end
- end
- DrawPixel(i,dispy+24,rulecolors[rulecolor])
- if i%4 == 0 then DrawPixel(i,dispy+25,rulecolors[rulecolor]) end
- if i%16 == 0 then
- DrawPixel(i,dispy+26,rulecolors[rulecolor])
- DrawPixel(i,dispy+27,rulecolors[rulecolor]) end
- if bvrec[i] == 1 then
- DrawPixel(i,dispy+23,charcolor[bvreccolor[i]+1])
- if bvreccolor[i] < 7 then
- DrawPixel(i,dispy+22,charcolor[bvreccolor[i]+1])
- end
- end
- end
- DrawPixel(bv,dispy+21,charcolor[bvreccolor[bv]+1])
- DrawPixel(bv,dispy+22,charcolor[bvreccolor[bv]+1])
- DrawPixel(bv,dispy+23,charcolor[bvreccolor[bv]+1])
- end
- local emuframe = 0
- local moviedata = {}
- local movieoffset = 0
- function ReadSMV()
- emuframe = emu.framecount() + 1
- --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
- movielen = (table.getn(moviedata) - movieoffset) / 2
- end
- --Get inputs either from movie or user:
- if movie.mode() == "playback" and emuframe < movielen 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
- end
- end
- function displayJoypad()
- --Draw each button (color it based on hold duration):
- for i = 1, 12 do
- if inputs[button[i]] then
- if unpress[i] > 0 then
- press[i] = 0
- if unpress[i] == 6 then
- turbo[i] = 1
- else
- turbo[i] = 0
- end
- unpress[i] = 0
- end
- if press[i] < 240 then
- press[i] = press[i] + 6
- end
- else
- if unpress[i] ~= 0 then -- i.e. was pressed in previous frame
- turbo[i] = 0
- end
- if unpress[i] < 240 then
- unpress[i] = unpress[i] + 6
- end
- end
- shoulder = 0
- if i == 1 or i == 2 then shoulder = 1 end
- buttontext = 0xc0000000
- buttoncolor = 0
- if inputs[button[i]] then
- buttoncolor = 0xa0000000 + (0xF0-press[i])*0x10000 + 0xff80
- elseif press[i] > 0 then
- buttoncolor = (160-math.floor(unpress[i]*2/3))*0x1000000 + press[i]*0x10000 + 0 + (0xF0-press[i])
- end
- if turbo[i] == 1 then
- buttontext = outfade+0xff0000
- buttoncolor = 0xa0ffffff
- end
- bx = 10
- by = 8
- DrawBox(
- xoffset+xcoords[i]*bx, yoffset+ycoords[i]*by,
- xoffset+xcoords[i]*bx+bx +shoulder*bx, yoffset+ycoords[i]*by+by -shoulder*3, buttoncolor, buttoncolor)
- DrawText(xoffset+xcoords[i]*bx+4, yoffset+ycoords[i]*by+0,btnlabel[i],buttontext,0)
- end
- end
- local BATTLES_X = 0x975a
- local BATTLES_Y = 0x9765
- local HP = 0x5e30
- local DAMAGE_SIGN = 0xb328 -- 7eb354
- local DAMAGE_ABS = 0xad9c
- function displayHP()
- for i = 3, 10 do
- atb2 = ReadByte(ATB+i)
- if (atb2 < 100) then
- DrawText(ReadByte(BATTLES_X+i)+12,ReadByte(BATTLES_Y+i)+4,
- atb2,"gray","shadow")
- DrawText(ReadByte(BATTLES_X+i)-18,ReadByte(BATTLES_Y+i)+4,
- string.format("%5d",ReadWord(HP+0x80*i)),"silver","shadow")
- end
- end
- for i = 0, 2 do
- atb2 = ReadByte(ATB+i)
- if (atb2 < 100) then
- DrawText(xoffset+177,19+12*i+(yoffset-16)*ReadByte(MENU_POS),
- string.format("%2d",ReadByte(ATB+i)),"gray","shadow")
- end
- end
- for i = 0, 10 do
- dcolor = "red"
- dabs = ReadWord(DAMAGE_ABS+i*4)
- if (dabs ~= 0 and dabs < 0x8000) then
- if (ReadWord(DAMAGE_SIGN+i*4) > 32768) then dcolor = "green" end
- DrawText(ReadByte(BATTLES_X+i)-18,ReadByte(BATTLES_Y+i)-4,
- string.format("%5d",dabs),dcolor,"shadow")
- end
- end
- end
- local ran = 0
- local rundisp = 0
- local run_got = 0x99cd
- local run_count = 0x99cf
- local battle_end = 0x020c -- "Ran away!" message called
- function displayRunaway()
- if (ReadByte(battle_end) ~= 8) then
- ran = ReadByte(run_got)
- rundisp = ReadByte(run_count)
- end
- runcolor = "gray"
- if (ran > 0) then
- rundisp = ran+120
- runcolor = "green"
- end
- DrawText(120,yoffset+37,string.format("%3d",rundisp),runcolor,"shadow")
- end
- function TreasureCount()
- ccount = 0
- for i = 1,20 do
- chest = ReadByte(0x10000+i)
- for j = 1,8 do
- if chest%2 == 1 then
- ccount = ccount + 1
- chest = chest-1
- end
- chest = chest/2
- end
- end
- return ccount
- end
- function displayFrameCount()
- eframe = emuframe + 1
- if (eframe > 188) and CT_Ver == "U" then eframe = eframe - 189 end
- if (eframe > 138) and CT_VER == "J" then eframe = eframe - 139 end
- t0 = eframe * 60/60.098813
- t_fr = ""..string.format("%.1d",(t0 % 60)/6)
- t_sec = ""..string.format("%02d",(t0/60) % 60)
- t_min = ""..string.format("%02d",(t0/3600) % 60)
- t_hr = ""..string.format("%02d",(t0/216000))
- DrawText(1,0,string.lower(CT_Ver),"silver")
- DrawText(7,0,t_hr,"silver")
- DrawText(14,0,":","silver")
- DrawText(17,0,t_min,"silver")
- DrawText(24,0,":","silver")
- DrawText(27,0,t_sec,"silver")
- DrawText(34,0,".","silver")
- DrawText(37,0,t_fr,"silver")
- DrawText(42,0,string.format("|%02d",t0%60),"silver")
- DrawText(56,0,string.format("-%d",math.abs(t0-eframe*60/59.94)),"silver")
- DrawText(1,8,emuframe,"silver")
- end
- local PAUSE = 0x0407
- local dispbox = 4
- while true do
- emuframe = emu.framecount()
- inputs = joypad.get()
- getValues()
- pause = ReadByte(PAUSE)
- --Catch <select> pressed
- if inputs[button[10]] then
- if ReadByte(0x0129) == 7 and autotext then
- confirm_button = CT_button[string.format("%x",ReadByte(0x2993))]
- joypad.set( {[confirm_button]=true} )
- end
- if selectheld == 0 then
- selectheld = 1
- if pause == 0xF5 or pause == 0xFF then -- toggle if Paused
- if dispbox == 4 then
- dispbox = 1
- else dispbox = dispbox + 1 end
- end
- end
- else selectheld = 0 end
- if loadmenutime ~= ReadByte(MENU_TIME) then
- if menuopen == 0 then
- menuopen = 1 end
- else menuopen = 0 end
- loadmenutime = ReadByte(MENU_TIME)
- --Display all
- if dispbox < 3 and loc < 0x1F0
- and menuopen == 0 and battleflag == 0 then
- displayHitbox()
- end
- if dispbox % 2 > 0 then
- if BIZ == false then ReadSMV() end
- displayJoypad()
- end
- if battlecopy == 1 then
- displayHP()
- displayRunaway()
- end
- if mtchars < 3 then
- displayValues()
- displayTime()
- --Crit Value
- DrawText(1,yoffset+37,string.format("%02x",cv),critcolor[tonumber(crits:sub(cv+1,cv+1))+1],"shadow")
- --BattleSpeed
- DrawText(1,yoffset+29,"bs"..ReadByte(0x2990)%8+1,"gray","shadow")
- DrawText(1,yoffset+21,"t"..TreasureCount(),"gray","shadow")
- end
- displayFrameCount()
- emu.frameadvance()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement