Advertisement
redslash

ctinfoscope20160523

May 24th, 2016
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 47.81 KB | None | 0 0
  1. --Chrono Trigger Infoscope for Snes9x(1.51-rr)
  2. -- 2016/05/23 Redslash
  3. -- testing some new stuff! ATB/HP view, Runaway counter, new Crit display, (Battlespeed in top corner)
  4. -- (still need to clean this up in a big way (and edit room names))
  5.  
  6. --HOW TO USE:
  7. -- 1. get the emulator here http://tasvideos.org/EmulatorResources/Snes9x.html (it's the top link)
  8. -- 2. download this paste (.LUA file), and open it from Snes9x (File > Lua Scripting > New Lua Script Window)
  9.  
  10. -- older versions:
  11. -- 2016/02/02 http://pastebin.com/epGpuMy0
  12. -- 2015/10/30 http://pastebin.com/J0C5kDnF
  13.  
  14. local dispbox = 1   -- press Select to toggle
  15. local dispboxID = 0     -- CHANGE THIS TO SEE NPC IDs
  16. local dispCronobox = 0  -- CHANGE THIS TO TO SEE PC BOXES
  17.  
  18. local infade = "80"
  19. local outfade = "c0"
  20.  
  21. local inputs = joypad.get()
  22. local button =  {'R','L','X','A','right','left','down','up','start','select','Y','B'}
  23. local btnlabel= {'  r','l','X','A','>','<','v','^','S','-','Y','B'}
  24. local xcoords = { 8.6, 0.4, 9,10, 2, 0, 1, 1, 6, 4, 8, 9}
  25. local ycoords = {  1,   1,  2, 3, 3, 3, 4, 2, 3, 3, 3, 4}
  26. local press= {  0,   0,  0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
  27. local unpress = {  0,   0,  0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
  28. local turbo   = {  0,   0,  0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
  29. local selectheld = 0
  30.  
  31. local dispy = 191
  32. local yoffset = 168
  33. local xoffset = 70  -- 89 = button display centered
  34. local regcolor = {"#CCCCCC","#00CCCC","#CCCCCC"}
  35. local regshade = {"#444444","#004444","#444444"}
  36. local nocolor = "#00000000"
  37. local charname = {"C","M","L","R","F","A","J"}
  38. local charcolor = {"#CCCC00","#0000FF","#CC0000","#808080","#00CC00","#CC4400","#808080","#808080","#808080"}
  39. local charshade = {"#444400","#000044","#440000","#444400","#004400","#441100","#404040"}
  40.  
  41. local BATTLE_FLAG = 0x7e0117
  42. local battleflag = 0
  43. local battlecopy = 0
  44.  
  45. local FACING = 0x7e1600
  46. local MOVING = 0x7e1680
  47. local facing = {}
  48. local moving = {}
  49. local faceoffset = 5    -- experimental
  50. local MAP_X = 0x7e1800
  51. local MAP_Y = 0x7e1880
  52. local mapx = {}
  53. local mapy = {}
  54. local mapoffsetx = 0
  55. local mapoffsety = 0
  56. local SCREEN_X = 0x7e0A00
  57. local SCREEN_Y = 0x7e0A80
  58. local mainsprite = 0
  59. local farsprite = 0
  60. local xsign,ysign = "",""
  61. local xcolor,ycolor = 0,0
  62.  
  63. local LOCATION = 0x7e0100
  64. local loc = memory.readword(LOCATION)
  65.  
  66. local locs = {} --http://datacrystal.romhacking.net/wiki/Chrono_Trigger/List_of_Locations
  67. locs[0x000] = "Load Screen"
  68. locs[0x001] = "Crono's Kitchen"
  69. locs[0x002] = "Crono's Room"
  70. locs[0x003] = "Lucca's Kitchen"
  71. locs[0x004] = "Lucca's Workshop"
  72. locs[0x005] = "Millenial Fair"
  73. locs[0x006] = "Gato's Exhibit"
  74. locs[0x007] = "Prehistoric Exhibit"
  75. locs[0x008] = "Telepod Exhibit"
  76. locs[0x009] = "Lara's Room"
  77. locs[0x00A] = "Lucca's Room"
  78. locs[0x00B] = "Ending Selector"
  79. locs[0x00C] = "Truce Inn (Present)"
  80. locs[0x00D] = "Truce Mayor's Manor 1F"
  81. locs[0x00E] = "Truce Mayor's Manor 2F"
  82. locs[0x00F] = "Truce Single Woman Residence"
  83. locs[0x010] = "Truce Happy Screaming Couple Residence"
  84. locs[0x011] = "Truce Market (Present)"
  85. locs[0x012] = "Truce Ticket Office"
  86. locs[0x013] = "Guardia Forest (Present)"
  87. locs[0x014] = "Guardia Forest Dead End"
  88. locs[0x015] = "Guardia Throneroom (Present)"
  89. locs[0x016] = "King's Chamber (Present)"
  90. locs[0x017] = "Queen's Chamber (Present)"
  91. locs[0x018] = "Guardia Kitchen (Present)"
  92. locs[0x019] = "Guardia Barracks (Present)"
  93. locs[0x01A] = "Guardia Basement"
  94. locs[0x01B] = "Courtroom"
  95. locs[0x01C] = "Prison Catwalks"
  96. locs[0x01D] = "Prison Supervisor's Office"
  97. locs[0x01E] = "Prison Torture Storage Room"
  98. locs[0x01F] = "Medina Square"
  99. locs[0x020] = "Zenan Bridge (Present)"
  100. locs[0x021] = "Medina Elder's House 1F"
  101. locs[0x022] = "Medina Elder's House 2F"
  102. locs[0x023] = "Medina Inn"
  103. locs[0x024] = "Medina Portal"
  104. locs[0x025] = "Ending: Legendary Hero"
  105. locs[0x026] = "Guardia Throneroom (Ending: Legendary Hero)"
  106. locs[0x027] = "Medina Market"
  107. locs[0x028] = "Melchior's Kitchen"
  108. locs[0x029] = "Melchior's Workshop"
  109. locs[0x02A] = "Forest Ruins"
  110. locs[0x02B] = "Cursed Woods (Ending: The Unknown Past)"
  111. locs[0x02C] = "Leene Square (Future)"
  112. locs[0x02D] = "Denadoro Mountain Vista (Ending: Legendary Hero)"
  113. locs[0x02E] = "Castle Magus Throne of Defense (Ending: Legendary Hero)"
  114. locs[0x02F] = "Heckran Cave Passageways"
  115. locs[0x030] = "Heckran Cave Entrance"
  116. locs[0x031] = "Heckran Cave Underground River"
  117. locs[0x032] = "Porre Mayor's Manor 1F (Present)"
  118. locs[0x033] = "Porre Mayor's Manor 2F (Present)"
  119. locs[0x034] = "Porre Residence (Present)"
  120. locs[0x035] = "Snail Stop"
  121. locs[0x036] = "Porre Market (Present)"
  122. locs[0x037] = "Porre Inn (Present)"
  123. locs[0x038] = "Porre Ticket Office"
  124. locs[0x039] = "Fiona's Shrine"
  125. locs[0x03A] = "Choras Mayor's Manor 1F"
  126. locs[0x03B] = "Choras Mayor's Manor 2F"
  127. locs[0x03C] = "Castle Magus Hall of Aggression (Ending: Legendary Hero)"
  128. locs[0x03D] = "Choras Carpenter's Residence (Present)"
  129. locs[0x03E] = "Choras Inn (Present)"
  130. locs[0x03F] = "West Cape"
  131. locs[0x040] = "Sun Keep (Present)"
  132. locs[0x041] = "Northern Ruins Entrance (Present)"
  133. locs[0x042] = "Northern Ruins Basement Corridor (Present)"
  134. locs[0x043] = "Northern Ruins Landing (Present)"
  135. locs[0x044] = "Northern Ruins Antechamber (Present)"
  136. locs[0x045] = "Northern Ruins Vestibule (Present)"
  137. locs[0x046] = "Northern Ruins Back Room (Present)"
  138. locs[0x047] = "Prison Cells"
  139. locs[0x048] = "Prison Stairwells"
  140. locs[0x049] = "Northern Ruins Hero's Grave (Present)"
  141. locs[0x04A] = "Unknown"
  142. locs[0x04B] = "Prison Exterior"
  143. locs[0x04C] = "Unknown (Lavos Spawn)"
  144. locs[0x04D] = "Unknown (Lavos Spawn)"
  145. locs[0x04E] = "Unknown (Lavos Spawn)"
  146. locs[0x04F] = "Guardia Throneroom (Ending: Moonlight Parade)"
  147. locs[0x050] = "Millenial Fair (Ending: Moonlight Parade)"
  148. locs[0x051] = "Leene Square (Ending: Moonlight Parade)"
  149. locs[0x052] = "Ending Selector"
  150. locs[0x053] = "Fiona's Forest Recriminations"
  151. locs[0x054] = "End of Time (Ending: Moonlight Parade)"
  152. locs[0x055] = "Telepod Exhibit (Ending: Moonlight Parade)"
  153. locs[0x056] = "Death Peak Summit (Ending: Moonlight Parade)"
  154. locs[0x057] = "Manoria Sanctuary (Ending: The Successor of Guardia)"
  155. locs[0x058] = "The End"
  156. locs[0x059] = "Zenan Bridge (Ending: Moonlight Parade)"
  157. locs[0x05A] = "Prison Catwalks (Ending: Moonlight Parade)"
  158. locs[0x05B] = "Ending: People of the Times (Part 1)"
  159. locs[0x05C] = "Ending: People of the Times (Part 2)"
  160. locs[0x05D] = "Ending: People of the Times (Part 3)"
  161. locs[0x05E] = "Ending: People of the Times (Part 4)"
  162. locs[0x05F] = "Ending: People of the Times (Part 5)"
  163. locs[0x060] = "Black Omen Lavos Spawn"
  164. locs[0x061] = "Black Omen 3F Teleporter (no exits)"
  165. locs[0x062] = "Black Omen 45F Teleporter"
  166. locs[0x063] = "Black Omen Platform (no exit)"
  167. locs[0x064] = "Black Omen Platform Shaft (Downward)"
  168. locs[0x065] = "Black Omen Platform Shaft (Upward)"
  169. locs[0x066] = "Black Omen Celestial Gate (no map)"
  170. locs[0x067] = "Black Omen Celestial Gate (no map)"
  171. locs[0x068] = "Black Omen Celestial Gate (no map)"
  172. locs[0x069] = "Black Omen Celestial Gate (no map)"
  173. locs[0x06A] = "Black Omen Celestial Gate (no map)"
  174. locs[0x06B] = "Black Omen Celestial Gate"
  175. locs[0x06C] = "Lucca Explains Paradoxes"
  176. locs[0x06D] = "Ancient Tyrano Lair"
  177. locs[0x06E] = "Ancient Tyrano Lair Traps"
  178. locs[0x06F] = "Ancient Tyrano Lair Nizbel's Room"
  179. locs[0x070] = "Truce Canyon"
  180. locs[0x071] = "Truce Canyon Portal"
  181. locs[0x072] = "Truce Couple's Residence (Middle Ages)"
  182. locs[0x073] = "Truce Smithy's Residence"
  183. locs[0x074] = "Truce Inn 1F (Middle Ages)"
  184. locs[0x075] = "Truce Inn 2F (Middle Ages)"
  185. locs[0x076] = "Truce Market (Middle Ages)"
  186. locs[0x077] = "Guardia Forest (Middle Ages)"
  187. locs[0x078] = "Guardia Throneroom (Middle Ages)"
  188. locs[0x079] = "Guardia King's Chamber (Middle Ages)"
  189. locs[0x07A] = "Guardia Queen's Chamber (Middle Ages)"
  190. locs[0x07B] = "Guardia Kitchen (Middle Ages)"
  191. locs[0x07C] = "Guardia Barracks (Middle Ages)"
  192. locs[0x07D] = "Castle Magus Doppleganger Corridor"
  193. locs[0x07E] = "Geno Dome Main Conveyor"
  194. locs[0x07F] = "Geno Dome Elevator"
  195. locs[0x080] = "Geno Dome Long Corridor"
  196. locs[0x081] = "Manoria Sanctuary"
  197. locs[0x082] = "Manoria Main Hall"
  198. locs[0x083] = "Manoria Headquarters"
  199. locs[0x084] = "Manoria Royal Guard Hall"
  200. locs[0x085] = "Zenan Bridge (Wrecked)"
  201. locs[0x086] = "Zenan Bridge (Middle Ages, no map)"
  202. locs[0x087] = "Zenan Bridge (Middle Ages)"
  203. locs[0x088] = "Sandorino Pervert Residence"
  204. locs[0x089] = "Sandorino Elder's House"
  205. locs[0x08A] = "Sandorino Inn"
  206. locs[0x08B] = "Sandorino Market"
  207. locs[0x08C] = "Cursed Woods"
  208. locs[0x08D] = "Frog's Burrow"
  209. locs[0x08E] = "Denadoro South Face"
  210. locs[0x08F] = "Denadoro Cave of the Masamune Exterior"
  211. locs[0x090] = "Denadoro North Face"
  212. locs[0x091] = "Denadoro Entrance"
  213. locs[0x092] = "Denadoro Lower East Face"
  214. locs[0x093] = "Denadoro Upper East Face"
  215. locs[0x094] = "Denadoro Mountain Vista"
  216. locs[0x095] = "Denadoro West Face"
  217. locs[0x096] = "Denadoro Gauntlet"
  218. locs[0x097] = "Denadoro Cave of the Masamune"
  219. locs[0x098] = "Tata's House 1F"
  220. locs[0x099] = "Tata's House 2F"
  221. locs[0x09A] = "Porre Elder's House (Middle Ages)"
  222. locs[0x09B] = "Porre Cafe (Middle Ages)"
  223. locs[0x09C] = "Porre Inn (Middle Ages)"
  224. locs[0x09D] = "Porre Market (Middle Ages)"
  225. locs[0x09E] = "Fiona's Villa"
  226. locs[0x09F] = "Sunken Desert Entrance"
  227. locs[0x0A0] = "Sunken Desert Parasytes"
  228. locs[0x0A1] = "Sunken Desert Devourer"
  229. locs[0x0A2] = "Ozzie's Fort Entrance (no map)"
  230. locs[0x0A3] = "Magic Cave Exterior"
  231. locs[0x0A4] = "Magic Cave Interior"
  232. locs[0x0A5] = "Castle Magus Exterior"
  233. locs[0x0A6] = "Castle Magus Entrance"
  234. locs[0x0A7] = "Castle Magus Chamber of Guillotines"
  235. locs[0x0A8] = "Castle Magus Chamber of Pits"
  236. locs[0x0A9] = "Castle Magus Throne of Strength"
  237. locs[0x0AA] = "Castle Magus Hall of Aggression"
  238. locs[0x0AB] = "Castle Magus Hall of Deceit"
  239. locs[0x0AC] = "Castle Magus Inner Sanctum"
  240. locs[0x0AD] = "Castle Magus Throne of Magic"
  241. locs[0x0AE] = "Castle Magus Throne of Defense"
  242. locs[0x0AF] = "Castle Magus Hall of Apprehension"
  243. locs[0x0B0] = "Castle Magus Lower Battlements"
  244. locs[0x0B1] = "Ozzie's Fort Entrance"
  245. locs[0x0B2] = "Ozzie's Fort Hall of Disregard"
  246. locs[0x0B3] = "Ozzie's Fort Chamber of Kitchen Knives"
  247. locs[0x0B4] = "Ozzie's Fort Last Stand"
  248. locs[0x0B5] = "Ozzie's Fort Throne of Incompetence"
  249. locs[0x0B6] = "Ozzie's Fort Throne of Impertinence (wrong map)"
  250. locs[0x0B7] = "Ozzie's Fort Throne of Impertinence"
  251. locs[0x0B8] = "Ozzie's Fort Throne of Ineptitude"
  252. locs[0x0B9] = "Choras Old Couple Residence (Middle Ages)"
  253. locs[0x0BA] = "Choras Carpenter's Residence 1F (Middle Ages)"
  254. locs[0x0BB] = "Choras Carpenter's Residence 2F (Middle Ages)"
  255. locs[0x0BC] = "Choras Cafe"
  256. locs[0x0BD] = "Choras Inn (Middle Ages)"
  257. locs[0x0BE] = "Choras Market (Middle Ages)"
  258. locs[0x0BF] = "Sun Keep (Middle Ages)"
  259. locs[0x0C0] = "(empty map)"
  260. locs[0x0C1] = "(empty map)"
  261. locs[0x0C2] = "(empty map)"
  262. locs[0x0C3] = "Giant's Claw Entrance"
  263. locs[0x0C4] = "Giant's Claw Caverns"
  264. locs[0x0C5] = "Giant's Claw Last Tyranno"
  265. locs[0x0C6] = "Manoria Command"
  266. locs[0x0C7] = "Manoria Confinement"
  267. locs[0x0C8] = "Manoria Shrine Antechamber"
  268. locs[0x0C9] = "Manoria Storage"
  269. locs[0x0CA] = "Manoria Kitchen"
  270. locs[0x0CB] = "Manoria Shrine"
  271. locs[0x0CC] = "Guardia Forest Frog King Battle"
  272. locs[0x0CD] = "Denadoro Cyrus's Last Battle"
  273. locs[0x0CE] = "Guardia Throneroom Cyrus's Final Mission"
  274. locs[0x0CF] = "Schala's Room (no map)"
  275. locs[0x0D0] = "Bangor Dome"
  276. locs[0x0D1] = "Bangor Dome Sealed Room"
  277. locs[0x0D2] = "Trann Dome"
  278. locs[0x0D3] = "Trann Dome Sealed Room"
  279. locs[0x0D4] = "Lab 16 West"
  280. locs[0x0D5] = "Lab 16 East"
  281. locs[0x0D6] = "Arris Dome"
  282. locs[0x0D7] = "Arris Dome Infestation"
  283. locs[0x0D8] = "Arris Dome Auxiliary Console"
  284. locs[0x0D9] = "Arris Dome Lower Commons"
  285. locs[0x0DA] = "Arris Dome Command Central"
  286. locs[0x0DB] = "Arris Dome Guardian Chamber"
  287. locs[0x0DC] = "Arris Dome Sealed Room"
  288. locs[0x0DD] = "Arris Dome Rafters"
  289. locs[0x0DE] = "Reptite Lair 2F"
  290. locs[0x0DF] = "Lab 32 West Entrance"
  291. locs[0x0E0] = "Lab 32"
  292. locs[0x0E1] = "Lab 32 East Entrance"
  293. locs[0x0E2] = "Proto Dome"
  294. locs[0x0E3] = "Proto Dome Portal"
  295. locs[0x0E4] = "Factory Ruins Entrance"
  296. locs[0x0E5] = "Factory Ruins Auxiliary Console"
  297. locs[0x0E6] = "Factory Ruins Security Center"
  298. locs[0x0E7] = "Factory Ruins Crane Room"
  299. locs[0x0E8] = "Factory Ruins Infestation"
  300. locs[0x0E9] = "Factory Ruins Crane Control Room"
  301. locs[0x0EA] = "Factory Ruins Information Archive"
  302. locs[0x0EB] = "Factory Ruins Power Core"
  303. locs[0x0EC] = "Sewer Access B1"
  304. locs[0x0ED] = "Sewer Access B2"
  305. locs[0x0EE] = "Ending: Dream Team (no map) (TBD)"
  306. locs[0x0EF] = "Ending: A Slide Show?"
  307. locs[0x0F0] = "Ending: Goodnight"
  308. locs[0x0F1] = "Keeper's Dome"
  309. locs[0x0F2] = "Keeper's Dome Corridor"
  310. locs[0x0F3] = "Keeper's Dome Hanger"
  311. locs[0x0F4] = "Death Peak Entrance"
  312. locs[0x0F5] = "Death Peak South Face"
  313. locs[0x0F6] = "Death Peak Southeast Face"
  314. locs[0x0F7] = "Death Peak Northeast Face"
  315. locs[0x0F8] = "Geno Dome Entrance"
  316. locs[0x0F9] = "Geno Dome Conveyor Entrance"
  317. locs[0x0FA] = "Geno Dome Conveyor Exit"
  318. locs[0x0FB] = "Sun Palace"
  319. locs[0x0FC] = "Millenial Fair (Ending: Dino Age)"
  320. locs[0x0FD] = "Sun Keep (Last Village)"
  321. locs[0x0FE] = "Skill Tutorial"
  322. locs[0x0FF] = "Sun Keep (Future)"
  323. locs[0x100] = "Geno Dome Labs"
  324. locs[0x101] = "Geno Dome Storage"
  325. locs[0x102] = "Geno Dome Robot Hub"
  326. locs[0x103] = "Factory Ruins Data Core"
  327. locs[0x104] = "Death Peak Northwest Face"
  328. locs[0x105] = "Prehistoric Canyon"
  329. locs[0x106] = "Death Peak Upper North Face"
  330. locs[0x107] = "Death Peak Lower North Face"
  331. locs[0x108] = "Death Peak Cave"
  332. locs[0x109] = "Death Peak Summit"
  333. locs[0x10A] = "Ending: Dream Team (no map) (TBD)"
  334. locs[0x10B] = "Geno Dome Robot Elevator Access"
  335. locs[0x10C] = "Geno Dome Mainframe"
  336. locs[0x10D] = "Geno Dome Waste Disposal"
  337. locs[0x10E] = "Leene's Square (Ending: Dino Age)"
  338. locs[0x10F] = "Special Purpose Area"
  339. locs[0x110] = "Mystic Mtn Portal"
  340. locs[0x111] = "Mystic Mtn Base"
  341. locs[0x112] = "Mystic Mtn Gulch"
  342. locs[0x113] = "Chief's Hut"
  343. locs[0x114] = "Ioka Southwestern Hut"
  344. locs[0x115] = "Ioka Trading Post"
  345. locs[0x116] = "Ioka Sweet Water Hut"
  346. locs[0x117] = "Ioka Meeting Site"
  347. locs[0x118] = "Ioka Meeting Site (Party)"
  348. locs[0x119] = "Forest Maze Entrance"
  349. locs[0x11A] = "Forest Maze"
  350. locs[0x11B] = "Reptite Lair Entrance"
  351. locs[0x11C] = "Reptite Lair 1F"
  352. locs[0x11D] = "Reptite Lair Weevil Burrows B1"
  353. locs[0x11E] = "Reptite Lair Weevil Burrows B2"
  354. locs[0x11F] = "Reptite Lair Commons"
  355. locs[0x120] = "Reptite Lair Tunnel"
  356. locs[0x121] = "Reptite Lair Azala's Room"
  357. locs[0x122] = "Reptite Lair Access Shaft"
  358. locs[0x123] = "Hunting Range"
  359. locs[0x124] = "Laruba Ruins"
  360. locs[0x125] = "Dactyl Nest, Lower"
  361. locs[0x126] = "Dactyl Nest, Upper"
  362. locs[0x127] = "Dactyl Nest Summit"
  363. locs[0x128] = "Giant's Claw Lair Entrance"
  364. locs[0x129] = "Giant's Claw Lair Throneroom"
  365. locs[0x12A] = "Tyrano Lair Exterior"
  366. locs[0x12B] = "Tyrano Lair Entrance"
  367. locs[0x12C] = "Tyrano Lair Throneroom"
  368. locs[0x12D] = "Tyrano Lair Keep"
  369. locs[0x12E] = "Tyrano Lair Antechambers"
  370. locs[0x12F] = "Tyrano Lair Storage"
  371. locs[0x130] = "Tyrano Lair Nizbel's Room"
  372. locs[0x131] = "Tyrano Lair Room of Vertigo"
  373. locs[0x132] = "Debug Room?"
  374. locs[0x133] = "Lair Ruins Portal"
  375. locs[0x134] = "Black Omen 1F Entrance"
  376. locs[0x135] = "Black Omen 1F Walkway"
  377. locs[0x136] = "Black Omen 1F Defense Corridor"
  378. locs[0x137] = "Black Omen 1F Stairway"
  379. locs[0x138] = "Black Omen 3F Walkway"
  380. locs[0x139] = "Black Omen Auxilary Command"
  381. locs[0x13A] = "Black Omen (TBD)"
  382. locs[0x13B] = "Black Omen (TBD)"
  383. locs[0x13C] = "Black Omen (TBD)"
  384. locs[0x13D] = "Black Omen (TBD)"
  385. locs[0x13E] = "Black Omen (TBD)"
  386. locs[0x13F] = "Black Omen (TBD)"
  387. locs[0x140] = "Black Omen (TBD)"
  388. locs[0x141] = "Black Omen (TBD)"
  389. locs[0x142] = "Black Omen (TBD)"
  390. locs[0x143] = "Black Omen (TBD)"
  391. locs[0x144] = "Black Omen (TBD)"
  392. locs[0x145] = "Black Omen (TBD)"
  393. locs[0x146] = "Black Omen (TBD)"
  394. locs[0x147] = "Sunkeep (Prehistoric)"
  395. locs[0x148] = "Zeal Palace Schala's Room"
  396. locs[0x149] = "Zeal Palace Regal Hall"
  397. locs[0x14A] = "Zeal Palace Corridor to the Mammon Machine"
  398. locs[0x14B] = "Zeal Palace Hall of the Mammon Machine"
  399. locs[0x14C] = "Zeal Palace Zeal Throneroom"
  400. locs[0x14D] = "Zeal Palace Hall of the Mammon Machine (Night)"
  401. locs[0x14E] = "Zeal Palace Zeal Throneroom (Night)"
  402. locs[0x14F] = "Enhasa (wrong map)"
  403. locs[0x150] = "Land Bridge (TBD)"
  404. locs[0x151] = "Skyway? (TBD)"
  405. locs[0x152] = "Present Age Home Room (Ending: The Dream Project)"
  406. locs[0x153] = "Prehistoric Age Jungle (Ending: The Dream Project)"
  407. locs[0x154] = "Dark Age Ocean Palace Room (Ending: The Dream Project)"
  408. locs[0x155] = "Present Age Jail Cell (Ending: The Dream Project)"
  409. locs[0x156] = "Dark Age Earthbound Room (Ending: The Dream Project)"
  410. locs[0x157] = "Present Age Northern Ruins Room (Ending: The Dream Project)"
  411. locs[0x158] = "Arris Dome Food Locker"
  412. locs[0x159] = "Lucca's Workshop (Ending: The Oath)"
  413. locs[0x15A] = "Arris Dome Guardian Chamber (Battle with Lavos)"
  414. locs[0x15B] = "Prison Catwalks (Battle with Lavos)"
  415. locs[0x15C] = "Heckran Cave (Battle with Lavos)"
  416. locs[0x15D] = "Zenan Bridge (Battle with Lavos)"
  417. locs[0x15E] = "Cave of the Masamune (Battle with Lavos)"
  418. locs[0x15F] = "Dark Ages Portal"
  419. locs[0x160] = "Land Bridge (TBD)"
  420. locs[0x161] = "Land Bridge (TBD)"
  421. locs[0x162] = "Skyway (TBD)"
  422. locs[0x163] = "Enhasa"
  423. locs[0x164] = "Skyway (TBD)"
  424. locs[0x165] = "Kajar"
  425. locs[0x166] = "Kajar Study"
  426. locs[0x167] = "Kajar Belthasar's Private Room"
  427. locs[0x168] = "Kajar Magic Lab"
  428. locs[0x169] = "Zeal Palace Belthasar's Private Room"
  429. locs[0x16A] = "Blackbird Scaffolding"
  430. locs[0x16B] = "Blackbird Left Wing"
  431. locs[0x16C] = "Blackbird Right Port"
  432. locs[0x16D] = "Blackbird Left Port"
  433. locs[0x16E] = "Blackbird Overhead"
  434. locs[0x16F] = "Blackbird Hanger"
  435. locs[0x170] = "Blackbird Rear Halls"
  436. locs[0x171] = "Blackbird Forward Halls"
  437. locs[0x172] = "Blackbird Treasury"
  438. locs[0x173] = "Blackbird Cell"
  439. locs[0x174] = "Blackbird Barracks"
  440. locs[0x175] = "Blackbird Armory 3"
  441. locs[0x176] = "Blackbird Inventory"
  442. locs[0x177] = "Blackbird Lounge"
  443. locs[0x178] = "Blackbird Ducts"
  444. locs[0x179] = "Reborn Epoch"
  445. locs[0x17A] = "Future Age Room (Ending: The Dream Project)"
  446. locs[0x17B] = "End of Time (Ending: The Dream Project)"
  447. locs[0x17C] = "Algetty"
  448. locs[0x17D] = "Algetty Inn"
  449. locs[0x17E] = "Algetty Elder's Grotto"
  450. locs[0x17F] = "Algetty Commoner Grotto"
  451. locs[0x180] = "Algetty Shop"
  452. locs[0x181] = "Algetty Tsunami (wrong map)"
  453. locs[0x182] = "Algetty Entrance"
  454. locs[0x183] = "The Beast's Nest (wrong map)"
  455. locs[0x184] = "The Beast's Nest"
  456. locs[0x185] = "Zeal Teleporters"
  457. locs[0x186] = "Prehistoric Hut (Ending: The Dream Project)"
  458. locs[0x187] = "Castle Magus Room (Ending: The Dream Project)"
  459. locs[0x188] = "Mt. Woe Western Face"
  460. locs[0x189] = "Mt. Woe Lower Eastern Face"
  461. locs[0x18A] = "Mt. Woe Middle Eastern Face"
  462. locs[0x18B] = "Mt. Woe Upper Eastern Face"
  463. locs[0x18C] = "Mt. Woe Summit (wrong map)"
  464. locs[0x18D] = "Mt. Woe Summit"
  465. locs[0x18E] = "Leene Square (Ending: What the Prophet Seeks)"
  466. locs[0x18F] = "Crono's Kitchen (Ending: What the Prophet Seeks)"
  467. locs[0x190] = "The End (Ending: Multiple?)"
  468. locs[0x191] = "Zeal Palace"
  469. locs[0x192] = "Zeal Palace Hallway"
  470. locs[0x193] = "Zeal Palace Study"
  471. locs[0x194] = "Ocean Palace Entrance"
  472. locs[0x195] = "Ocean Palace Piazza"
  473. locs[0x196] = "Ocean Palace Side Rooms"
  474. locs[0x197] = "Ocean Palace Forward Area"
  475. locs[0x198] = "Ocean Palace B3 Landing"
  476. locs[0x199] = "Ocean Palace Grand Stairwell"
  477. locs[0x19A] = "Ocean Palace B20 Landing"
  478. locs[0x19B] = "Ocean Palace Southern Access Lift"
  479. locs[0x19C] = "Ocean Palace Security Pool"
  480. locs[0x19D] = "Ocean Palace Security Esplanade"
  481. locs[0x19E] = "Ocean Palace Regal Antechamber"
  482. locs[0x19F] = "Ocean Palace Throneroom"
  483. locs[0x1A0] = "Ocean Palace (TBD)"
  484. locs[0x1A1] = "Ocean Palace Eastern Access Lift"
  485. locs[0x1A2] = "Ocean Palace Western Access Lift"
  486. locs[0x1A3] = "Ocean Palace Time Freeze (wrong map)"
  487. locs[0x1A4] = "Ocean Palace Time Freeze (wrong map)"
  488. locs[0x1A5] = "Ocean Palace Time Freeze (wrong map)"
  489. locs[0x1A6] = "Time Distortion Mammon Machine"
  490. locs[0x1A7] = "Ocean Palace Time Freeze"
  491. locs[0x1A8] = "Last Village Commons"
  492. locs[0x1A9] = "Last Village Empty Hut"
  493. locs[0x1AA] = "Last Village Shop"
  494. locs[0x1AB] = "Last Village Residence"
  495. locs[0x1AC] = "North Cape"
  496. locs[0x1AD] = "Death Peak Summit"
  497. locs[0x1AE] = "Tyrano Lair Main Cell"
  498. locs[0x1AF] = "Title Screen (wrong map)"
  499. locs[0x1B0] = "Flying Epoch"
  500. locs[0x1B1] = "Title Screen"
  501. locs[0x1B2] = "Bekkler's Lab"
  502. locs[0x1B3] = "Magic Cave Exterior (after cutscene)"
  503. locs[0x1B4] = "Fiona's Forest Campfire"
  504. locs[0x1B5] = "Factory Ruins (TBD)"
  505. locs[0x1B6] = "Courtroom King's Trial"
  506. locs[0x1B7] = "Leene Square"
  507. locs[0x1B8] = "Guardia Rear Storage"
  508. locs[0x1B9] = "Courtroom Lobby"
  509. locs[0x1BA] = "Blackbird Access Shaft"
  510. locs[0x1BB] = "Blackbird Armory 2"
  511. locs[0x1BC] = "Blackbird Armory 1"
  512. locs[0x1BD] = "Blackbird Storage"
  513. locs[0x1BE] = "Castle Magus Upper Battlements"
  514. locs[0x1BF] = "Castle Magus Grand Stairway"
  515. locs[0x1C0] = "(Bad Event Data Packet)"
  516. locs[0x1C1] = "Black Omen Entrance"
  517. locs[0x1C2] = "Black Omen Omega Defense"
  518. locs[0x1C3] = "Black Omen Seat of Agelessness"
  519. locs[0x1C4] = "(Bad Event Data Packet)"
  520. locs[0x1C5] = "(Bad Event Data Packet)"
  521. locs[0x1C6] = "(Bad Event Data Packet)"
  522. locs[0x1C7] = "(Bad Event Data Packet)"
  523. locs[0x1C8] = "Reptite Lair (Battle with Lavos)"
  524. locs[0x1C9] = "Castle Magus Inner Sanctum (Battle with Lavos)"
  525. locs[0x1CA] = "Tyrano Lair Keep (Battle with Lavos)"
  526. locs[0x1CB] = "Mt. Woe Summit (Battle with Lavos)"
  527. locs[0x1CC] = "Credits (TBD)"
  528. locs[0x1CD] = "(Empty Data)"
  529. locs[0x1CE] = "(Empty Data)"
  530. locs[0x1CF] = "(Empty Data)"
  531. locs[0x1D0] = "End of Time"
  532. locs[0x1D1] = "Spekkio"
  533. locs[0x1D2] = "Apocalypse Lavos"
  534. locs[0x1D3] = "Lavos"
  535. locs[0x1D4] = "Guardia Queen's Tower (Middle Ages)"
  536. locs[0x1D5] = "Castle Magus Corridor of Combat"
  537. locs[0x1D6] = "Castle Magus Hall of Ambush"
  538. locs[0x1D7] = "Castle Magus Dungeon"
  539. locs[0x1D8] = "Apocalypse Epoch"
  540. locs[0x1D9] = "End of Time Epoch"
  541. locs[0x1DA] = "Lavos Tunnel"
  542. locs[0x1DB] = "Lavos Core"
  543. locs[0x1DC] = "Truce Dome"
  544. locs[0x1DD] = "Emergence of the Black Omen"
  545. locs[0x1DE] = "Blackbird Wing Access"
  546. locs[0x1DF] = "Tesseract"
  547. locs[0x1E0] = "Guardia King's Tower (Middle Ages)"
  548. locs[0x1E1] = "Death of the Blackbird"
  549. locs[0x1E2] = "Blackbird (no exits)"
  550. locs[0x1E3] = "Blackbird (no exits)"
  551. locs[0x1E4] = "Blackbird (no exits)"
  552. locs[0x1E5] = "Blackbird (no exits)"
  553. locs[0x1E6] = "Guardia King's Tower (Present)"
  554. locs[0x1E7] = "Guardia Queen's Tower (Present)"
  555. locs[0x1E8] = "Guardia Lawgiver's Tower"
  556. locs[0x1E9] = "Guardia Prison Tower"
  557. locs[0x1EA] = "Ancient Tyrano Lair Room of Vertigo"
  558. locs[0x1EB] = "(empty map)"
  559. locs[0x1EC] = "(empty map)"
  560. locs[0x1ED] = "Algetty Tsunami"
  561. locs[0x1EE] = "Paradise Lost"
  562. locs[0x1EF] = "Death Peak Guardian Spawn"
  563. locs[0x1F0] = "Present"
  564. locs[0x1F1] = "Middle Ages"
  565. locs[0x1F2] = "Future"
  566. locs[0x1F3] = "Prehistoric"
  567. locs[0x1F4] = "Dark Ages"
  568. locs[0x1F5] = "Kingdom of Zeal"
  569. locs[0x1F6] = "Last Village"
  570. locs[0x1F7] = "Apocalypse"
  571. locs[0x1F8] = "(empty map)"
  572. locs[0x1F9] = "(empty map)"
  573. locs[0x1FA] = "(empty map)"
  574. locs[0x1FB] = "(empty map)"
  575. locs[0x1FC] = "(empty map)"
  576. locs[0x1FD] = "(empty map)"
  577. locs[0x1FE] = "(empty map)"
  578. locs[0x1FF] = "(empty map)"
  579.  
  580. local frame,locstart = 0,0
  581. local timesav,locsav = 0,0
  582. local timeend = 0
  583. local recentload = 0
  584. local second = 0
  585. local segcount = 0
  586.  
  587. function displayTime()
  588.     frame = frame + 1
  589.    
  590. --Catch battleflag change
  591.     if battleflag ~= memory.readbyte(BATTLE_FLAG) % 2 then
  592.         timeend = frame - locstart
  593.         second = timeend / 60
  594.         print(string.format("%6.2f",second).."\t"..locs[loc].." ("..segcount..")")
  595.         segcount = segcount + 1
  596.  
  597.         battleflag = memory.readbyte(BATTLE_FLAG) % 2
  598.         if recentload == 0 then locstart = frame end       
  599.     end
  600.    
  601. --Catch location change
  602.     if loc ~= memory.readword(LOCATION) then
  603.         timeend = frame - locstart
  604.         second = timeend / 60      
  605.         print(string.format("%6.2f",second).."\t"..locs[loc].." ("..segcount..")")
  606.         segcount = 0
  607.  
  608.         loc = memory.readword(LOCATION)
  609.         if recentload == 0 then locstart = frame end
  610.     end
  611.     recentload = 0
  612.  
  613.     gui.text(xoffset+153,yoffset+37,"  "..string.format("%6.2f",second), "#808080")
  614.  
  615. end
  616.  
  617. function Saving()
  618.     timesav = frame
  619.     locsav = locstart
  620.     batsav = batstart
  621. end
  622. savestate.registersave(Saving) -- for room timing, only works with MOST RECENT state
  623.  
  624. function Reload()
  625.     frame = timesav
  626.     locstart = locsav
  627.     batstart = batsav
  628.     recentload = 1
  629. end
  630. savestate.registerload(Reload)
  631.  
  632.  
  633. local redbox = {}
  634. redbox[0x70] = {0x14,0x2e,0x30,0x32,0x28}
  635. redbox[0x77] = {0x32,0x34,0x3c,0x3e,0x28,0x2a,0x46,0x1c,0x1e}
  636. redbox[0x91] = {0x14,0x16}
  637. redbox[0x8c] = {0x20,0x22,0x24,0x2e,0x30,0x1e,0x1a} --3 frogs are friendly
  638. redbox[0x1d5] = {0x1c,0x26}
  639. redbox[0xb0] = {0x20,0x22}
  640. --redbox[0xa8] = {0x14,0x16,0x18,0x1a,0x1c,0x1e} --ozzie pits
  641. redbox[0x8e] = {0x24}
  642. redbox[0x92] = {0x10,0x18}
  643. redbox[0x93] = {0x10,0x18,0x1a}
  644. redbox[0x96] = {0x10}
  645. redbox[0x90] = {0x10,0x12,0x1a}
  646. redbox[0x94] = {0x10,0x12}
  647. redbox[0x8f] = {0x28,0x2a,0x1c,0x2c}
  648. redbox[0x82] = {0x3c,0x44,0x40,0x26,0x28,0X32,0x38,0x24,0x30,0x34,0x36,0x10,0x16,0x18}
  649. redbox[0x83] = {0x66,0x68,0x5e,0x1c,0x2c,0x32,0x40,0x4c,0x4e,0x50}
  650. redbox[0x84] = {0x1a,0x1c,0x1e,0x20,0x22,0x24,}
  651. redbox[0x78] = {0x16}
  652. redbox[0x13] = {0x1c,0x24,0x26,0x28,0x2a,0x2c,0x2e,0x30,0x3c,0x3e,0x40}
  653. redbox[0x1C] = {0x4}
  654. redbox[0x15] = {0x22}
  655. redbox[0xd4] = {0x24,0x26,0x28,0x2a,0x3a,0x3c,0x3e,0x40,0x42,0x12,0x14,0x16,0x18,0x1a,0x1c}
  656. redbox[0xd7] = {0x10,0x12,0x14,0x16,0x18,0x1a,0x1c}
  657. redbox[0xd9] = {0x20,0x22,0x24,0x26,0x18,0x1a,0x1c,0x1e,0x14,0x16}
  658. redbox[0xe4] = {0x16,0x18,0x1a}
  659. redbox[0x1d1] = {0x20,0x22,0x24,0x26,0x28}
  660. redbox[0x112] = {0x12,0x14,0x16,0x18,0x1c,0x1e,0x22,0x24,0x26,0x28,0x2a,0x2c}
  661. redbox[0x11a] = {0x2a,0x2c,0x2e,0x30,0x32,0x34,0x36,0x38}
  662. redbox[0x11d] = {0x20,0x22}
  663. redbox[0x11e] = {0x10}
  664. redbox[0x11f] = {0x1a,0x1c,0x1e,0x20,0x22,0x24}
  665. redbox[0x120] = {0x14,0x16,0x18}
  666. redbox[0x11c] = {0x12,0x14,0x16,0x18}
  667. redbox[0xa4] = {0x16,0x18,0x1a}
  668. redbox[0x7d] = {0x12,0x22,0x1e}
  669. redbox[0x1be] = {0x24,0x26,0x28,0x2a,0x2c,0x2e}
  670. redbox[0x1bf] = {0x30,0x32,0x34,0x36,0x38,0x3a}
  671. redbox[0x125] = {0x18,0x1a,0x1c,0x1e,0x22,0x24,0x28,0x2c,0x26,0x30}
  672. redbox[0x126] = {0x16,0x1a,0x1c,0x28}
  673. redbox[0x12a] = {0x22,0x24,0x26,0x28,0x2c,0x2e,0x30,0x3e,0x42,0x40,0x5c,0x5e,0x60,0x62,0x6e,0x70,0x72}
  674. redbox[0x12b] = {0x14,0x12,0x16,0x18}
  675. redbox[0x131] = {0x10,0x12,0x14,0x1c,0x24,0x20}
  676. redbox[0x130] = {0x12,0x14}
  677. redbox[0x12f] = {0x1a,0x18}
  678. redbox[0xdb] = {0x10,0x12}
  679. redbox[0xa0] = {0x02,0x04,0x06,0x08,0x0a}
  680. redbox[0xa1] = {0x20}
  681. redbox[0xec] = {0x1c,0x36,0x3c,0x22,0x24,0x26,0x3e,0x46,0x28,0x16,0x18,0x14}    --sewer
  682. redbox[0xed] = {0x2c}   --sewer
  683. redbox[0x18a]= {0x16}   --woe
  684. redbox[0x188]= {0x32,0x34}  --woe
  685. redbox[0x189]= {0x2c}   --woe
  686. redbox[0x195]= {0x14,0x16,0x1e,0x20,0x2a,0x18,0x1a,0x1c}    --op
  687. redbox[0x196]= {0x14,0x1a,0x1c,0x2e,0x30,0x32,0x36,0x38,0x3a}   --op
  688. redbox[0x197]= {0x1c,0x1e,0x30,0x36,0x24,0x2a}  --op
  689. redbox[0x198]= {0x0e,0x10,0x12} --op
  690. redbox[0x199]= {0x26,0x28,0x2a,0x2c,0x30,0x32,0x34,0x36}    --op
  691. redbox[0x19a]= {0x0e,0x10}  --op
  692. redbox[0x171]= {0x1e}   --blackbird
  693. redbox[0x16b]= {0x30,0x32,0x34,0x36,0x38,0x3a}   -- giant's claw
  694. redbox[0xc3] = {0x1c,0x1e}   -- giant's claw
  695. redbox[0x139]= {0x10,0x18,0x1e,0x26,0x28,0x2a,0x2c,0x2e}     -- omen
  696. redbox[0x13a]= {0x10,0x12,0x14,0x1a,0x1c,0x1e,0x24,0x2c,0x2e,0x30,0x32,0x34,0x36,0x38,0x3e,0x40,0x42,0x44,0x46,0x48,0x4a}    -- omen
  697. redbox[0x13d]= {0x1a,0x26,0x28,0x2a,0x2c}
  698. redbox[0x142]= {0x10,0x12,0x14,0x2a,0x2c,0x2e}
  699. redbox[0x143]= {0x12,0x14} -- gigamute
  700. redbox[0x144]= {0x1a,0x1c}
  701. redbox[0xf5]= {0x10,0x12,0x14,0x16,0x18} -- deathpeak
  702. redbox[0xf6]= {0x16,0x12,0x14,0x1a,0x1c} -- deathpeak
  703. redbox[0x107]= {0x10,0x12,0x14} -- deathpeak
  704. redbox[0x108]= {0x16,0x18,0x14,0x20} -- deathpeak
  705. redbox[0x104]= {0x10,0x12,0x14,0x16,0x18,0x1a,0x1c,0x1e} -- deathpeak
  706. redbox[0x1a]= {0x18} -- yakra13
  707. redbox[0x1b8]= {0x1a,0x1c} -- yakra13
  708.  
  709. local trigger = {}
  710. trigger[0xc6] = {0x010d,0x020d,0x030d,0x040d,0x050d,0x060d,0x070d,0x080d,0x090d,0x0a0d,0x0b0d,0x0c0d,0x0d0d}
  711. trigger[0xd4] = {0x0c34,0x0d34,0x0e34,0x0f34,0x1034,
  712.                  0x0c33,0x0d33,0x0e33,0x0f33,0x1033,
  713.                  0x0c32,0x0d32,0x0e32,0x0f32,0x1032,
  714.                  0x0c31,0x0d31,0x0e31,0x0f31,0x1031,
  715.                  0x0c30,0x0d30,0x0e30,0x0f30,0x1030,
  716.                  0x1727,0x1827,0x1927,
  717.                  0x0714,0x0715,0x0716,0x0717,0x0718,0x0719,0x071a,0x071b,0x071c}
  718. trigger[0xd5] = {0x2622,0x2623,0x2624,0x2625,0x2626,
  719.                  0x2d37,0x2d38,0x2d39,0x2d3a,0x2d3b,
  720.                  0x2e31,0x2e30,
  721.                  0x3925,0x3a25,0x3b25,0x3c25,0x3d25,
  722.                  0x3437,0x3438,0x3439,0x343a,0x343b}
  723. trigger[0xda] = {0x352a,0x362a,0x372a,0x382a,0x392a,0x3a2a}
  724. trigger[0xe2] = {0x3424,0x3524,0x3624,0x3724,0x3824,0x3924,0x3a24,
  725.                  0x3423,0x3523,0x3623,0x3723,0x3823,0x3923,0x3a23,0x3b23,
  726.                  0x3422,0x3522,0x3622,0x3722,0x3822,0x3922,0x3a22,0x3b22,
  727.                  0x3421,0x3521,0x3621,0x3721,0x3821,0x3921,0x3a21}
  728. trigger[0xe6] = {0x1323,0x1324,0x1325,0x1326,
  729.                  0x0d23,0x0d24,0x0d25,0x0d26,0x0431,0x0d3d,0x0d3c}
  730. trigger[0x30] = {0x0914,0x0915,0x0916,0x0917,0x0918,0x0919,0x091a}
  731. trigger[0x31] = {0x1f2f,0x202f,0x212f,0x222f,0x232f,0x242f,0x252f,0x262f,0x272f,
  732.                  0x1f30,0x1f31,0x1f32,0x1f33,0x1f34,
  733.                  0x122b,0x122c,0x122d,0x122e,0x122f}
  734. trigger[0x2f] = {0x3235,0x3335,0x3435,0x3535,0x3635,0x3735,0x3835,0x3935,0x3a35,0x3b35,0x3c35,
  735.                  0x2933,0x2932,0x2931,0x2833,0x2832,0x2831,0x2a33,0x2a32,0x2a31,
  736.                  0x102c,0x0f2c,0x0e2c,0x0d2c,0x0c2c,0x0b2c,
  737.                  0x301f,0x311f,0x321f,0x331f,0x341f,0x351f,0x361f,0x371f,0x381f,0x391f}
  738. trigger[0x87] = {0x3308,0x3309,0x330a,0x2a07,0x2a08,0x2a09,0x2a0a}
  739. trigger[0x91] = {0x0e02,0x0e03,0x0e04,0x0e05,0x0d05,0x0c05,0x0b05,0x0a05,0x0905}
  740. trigger[0x8e] = {0x0518,0x0618,0x0418,0x0318,0x0218}
  741. trigger[0x2a] = {0x0712,0x0612,0x0512,0x0812,0x1012,0x0912}
  742. trigger[0xa8] = {0x320a,0x3310,0x390f,0x390c,0x3a08,0x3c0b,
  743.                  0x320b,0x3311,0x3910,0x390d,0x3a09,0x3c0c,
  744.                  0x330a,0x3410,0x3a0f,0x3a0c,0x3b08,0x3d0b,
  745.                  0x330b,0x3411,0x3a10,0x3a0d,0x3b09,0x3d0c}
  746. trigger[0x124] = {0x080e,0x090e,0x0a0e,0x0b0e,0x070e,0x060e,0x050e,0x030e,0x020e,0x010e,0x000e,0x0d0e,0x0e0e}
  747. trigger[0x12e] = {0x0f0d,0x0f0e,0x0f0f,0x0f10,0x0f11}
  748. trigger[0xa0] = {0x0e10,0x0d10,0x0c10,0x0b10,0x0a10,0x0910,0x0f10,0x1010,0x1110,0x1210,0x1310,0x1410,0x1510,
  749.                  0x0909,0x090a,0x090b,0x090c,0x090d,0x090e,0x090f}
  750. trigger[0x1d6] = {0x252e,0x262e,0x272e,0x282e,0x292e,
  751.                  0x2522,0x2622,0x2722,0x2822,0x2922,
  752.                  0x2516,0x2616,0x2716,0x2816,0x2916,
  753.                  0x250a,0x260a,0x270a,0x280a,0x290a,0x2705}              
  754. trigger[0xe0] = {0x0707,0x0708,0x0709,0x070a,0x070b,0x070c,0x070d,0x1d0a,0x1d0b,0x1d0c,0x1d0d}
  755. trigger[0x184]= {0x072f,0x062f,0x052f,0x082f,0x092f,0x0a2f,
  756.                  0x061d,0x051d,0x041d,0x031d,
  757.                  0x0811,0x0911,0x0a11,0x0b11} --beasts
  758. trigger[0x18a]= {0x232d,0x242d,0x252d,0x262d,0x272d,0x282d,0x292d}
  759. trigger[0x188]= {0x2407,0x2408,0x2409,0x240a,0x240b,
  760.                  0x0f13,0x1013,0x1113,0x1213,0x1313,0x1413,
  761.                  0x3210,0x3211,0x3212,0x3213,0x3214,0x3215,0x3216,
  762.                  0x2e1e,0x2e1f,0x2e20,0x2e21,0x2e22,0x2e23,0x2e24,0x2e25,
  763.                  0x302d,0x302d,0x302e,0x302f,0x302d,0x3030,0x3031,0x3032,0x3033,0x3034,0x3035,0x3036,0x3037,0x3038,0x3039}
  764. trigger[0x189]= {0x0c29,0x0d29,0x0e29,0x0f29,0x1029,0x1129,0x1229,
  765.                  0x1911,0x1912}
  766. trigger[0x199]= {0x010d,0x020d,0x030d,0x040d,0x050d,0x060d,0x070d,0x080d,0x090d,0x0a0d,0x0b0d,0x0c0d,0x0d0d,0x0e0d,
  767.                  0x116d,0x126d,0x136d,0x146d,0x156d,0x166d,0x176d,0x186d,0x196d,0x1a6d,0x1b6d,0x1c6d,0x1d6d,0x1e6d}
  768. trigger[0x19b]= {0x0013,0x0113,0x0213,0x0313,0x0413,0x0513,0x0613,0x0713,0x0813,0x0913,0x0a13,0x0b13,0x0c13,0x0d13,0x0e13,0x0f13}
  769. trigger[0x16b]= {0x1019,0x0f19,0x0e19,0x0d19,0x0c19} -- giant's claw
  770. trigger[0xc4] = {0x163a,0x163b,0x163c,0x0a3a,0x0a3b,0x0a3c} -- giant's claw
  771. trigger[0x128]= {0x3338,0x3438,0x3538,0x3638,0x3738,0x3838} -- giant's claw
  772. trigger[0x6d] = {0x1c0d,0x1c0e,0x1c0f,0x1c10,0x1c11} -- giant's claw
  773. trigger[0xc5] = {0x0b29,0x0c29,0x0d29} -- giant's claw
  774. trigger[0xb7] = {0x2128,0x2228,0x2328,0x2428,0x2528,0x2628,0x2728,0x2828,0x2928,0x2a28,0x2b28,0x2c28,0x2d28} -- ozzie
  775. trigger[0xb2] = {0x1411,0x1511,0x1611,0x1711,0x1811,0x1911,0x1a11} -- ozzie
  776. trigger[0xb8] = {0x2128,0x2228,0x2328,0x2428,0x2528,0x2628,0x2728,0x2828,0x2928,0x2a28,0x2b28,0x2c28,0x2d28} -- ozzie
  777. trigger[0xb3] = {0x0124,0x0224,0x0324,0x0824,0x0924,0x0a24,0x0b24,0x0c24,0x0d24} -- ozzie
  778. --final ozzie
  779. trigger[0x13e]= {0x1808,0x1809,0x180a,0x180b,0x180c,0x1b08,0x1b09,0x1b0a,0x1b0b,0x1b0c, -- omen
  780.                  0x3508,0x3509,0x350a,0x350b,0x350c,0x3808,0x3809,0x380a,0x380b,0x380c}
  781.  
  782.  
  783. local warning = {}
  784. warning[0x92] = {0x081b}
  785. warning[0x70] = {0x0d09,0x0c09,0x0b09,0x0e09,0x0712,0x0912,0x0812,0x0b0d,0x0c0d}
  786. warning[0x7a] = {0x30,0x32,0x34}
  787. warning[0x48] = {0x1211,0x1212,0x1213,0x1207,0x1208,0x1209}
  788. warning[0x8e] = {0x1235,0x0f35,0x0e35,0x0d35,
  789.                  0x1234,0x1134,0x1034,0x0f34,0x0d34}
  790. warning[0x120] ={0x0622,0x0623,0x0624,0x0625,0x0626,0x0627,0x0628,0x0629,0x062a,0x062b,0x062c,0x062d,0x062e,0x062f,0x0630,0x0631,0x0632,
  791.                  0x0722,0x0723,0x0724,0x0725,0x0726,0x0727,0x0728,0x0729,0x072a,0x072b,0x072c,0x072d,0x072e,0x072f,0x0730,0x0731,0x0732,
  792.                  0x0822,0x0823,0x0824,0x0825,0x0826,0x0827,0x0828,0x0829,0x082a,0x082b,0x082c,0x082d,0x082e,0x082f,0x0830,0x0831,0x0832,
  793.                  0x0436,0x0536,0x0636,0x0736,
  794.                  0x0437,0x0537,0x0637,0x0737,
  795.                  0x0438,0x0538,0x0638,0x0738}
  796. warning[0x196]= {0x240a,0x240b,0x240c,0x240d,0x240e,0x240f,0x2410}
  797. warning[0x135]= {0x0727,0x0827,0x0927,0x0a27,0x0627,0x0628,0x0629,0x062a,0x062b,0x062c,0x062d,0x071b,0x081b} --omen
  798. warning[0x137]= {0x071a,0x081a,0x0706,0x0806} --omen
  799. warning[0x138]= {0x061e,0x061d,0x061c,0x071e,0x071d,0x071c,0x081e,0x081d,0x081c,0x091e,0x091d,0x091c,0x0a1e,0x0a1d,0x0a1c,0x0b1d,0x0b1c,
  800.                  0x031f,0x041f,0x051f,0x061f,0x071f,0x081f,0x091f,0x0a1f,0x0b1f,
  801.                  0x0320,0x0420,0x0520,0x0620,0x0720,0x0820,0x0920,0x0a20,0x0b20,0x0c20, --omen
  802.                  0x0421,0x0521,0x0621,0x0721,0x0821,0x0921,0x0a21,0x0b21,0x0c21,0x0d21, --omen
  803.                  0x0522,0x0622,0x0722,0x0822,0x0922,0x0a22,0x0b22,0x0c22,0x0d22,0x0e22, --omen
  804.                  0x0623,0x0723,0x0823,0x0923,0x0a23,0x0b23,0x0c23,0x0d23,0x0e23, --omen
  805.                  0x0724,0x0824,0x0924,0x0a24,0x0b24,0x0c24,0x0d24,0x0e24, --omen
  806.                  0x0825,0x0925,0x0a25,0x0b25,0x0c25,0x0d25,0x0e25,
  807.                  0x0926,0x0a26,0x0b26,0x0c26,0x0d26,
  808.                  0x0927,0x0a27,0x0b27}
  809. warning[0x13f]= {0x3735,0x3835,0x3636,0x3736,0x3836,0x3936,0x3637,0x3737,0x3837,0x3937} -- omen
  810. warning[0xf4]= {0x3731,0x3732,0x3820,0x3821} -- deathpeak
  811.                  
  812. function displayHitbox()
  813.  
  814.     for i = 1,64 do
  815.         mapx[i] = math.floor(memory.readword(MAP_X + 2*(i-1))/16)
  816.         mapy[i] = math.floor(memory.readword(MAP_Y + 2*(i-1))/16)
  817.         facing[i] = memory.readbyte(FACING + 2*(i-1))
  818.         if memory.readbyte(MOVING + 2*(i-1)) > 0 then
  819.             moving[i] = 1
  820.         else moving[i] = 0 end
  821.     end
  822.        
  823.     spritex = {}
  824.     spritey = {}
  825.     mainsprite = 0
  826.     farsprite = 0
  827.     for i = 1,16 do     -- get one sprite to compare
  828.         spritex[i] = memory.readword(SCREEN_X + 2*(i-1))
  829.         spritey[i] = memory.readword(SCREEN_Y + 2*(i-1))
  830.         if loc == 0xa0 then mainsprite = 7
  831.         elseif loc == 0xa1 then mainsprite = 8
  832.         elseif mainsprite == 0 and spritex[i] > 0 and spritey[i] > 0 and mapx[i] ~= 0xFF0 and
  833.             (mapy[i] ~= 0xff0 and mapx[i] ~= 0x178) and
  834.             (mapy[i] ~= 0xff0 and mapx[i] ~= 0x088) and
  835.             (mapy[i] ~= 0xff0 and mapx[i] ~= 0x298) and
  836.             (mapy[i] ~= 0xff0 and mapx[i] ~= 0x368) and
  837.             (mapy[i] ~= 0xff0 and mapx[i] ~= 0x268) and
  838.             (mapy[i] ~= 0xff0 and mapx[i] ~= 0x2b8) and
  839.             (mapy[i] ~= 0xff0 and mapx[i] ~= 0x0c8) and
  840.             (mapy[i] ~= 0xff0 and mapx[i] ~= 0xff8) then
  841.                 mainsprite = i
  842.         end
  843.     end
  844.     if mainsprite ~= 0 then
  845.         mapoffsetx = mapx[mainsprite] - spritex[mainsprite]
  846.         mapoffsety = mapy[mainsprite] - spritey[mainsprite]
  847.     end
  848.  
  849.     if warning[loc] ~= nil then
  850.         if table.getn(warning[loc]) ~= nil then
  851.             for j = 1,table.getn(warning[loc]) do
  852.                 screenx = math.floor(warning[loc][j] / 0x100)*0x10 - mapoffsetx
  853.                 screeny = (warning[loc][j] % 0x100)*0x10 - mapoffsety
  854.                 gui.box(screenx,screeny,screenx+16,screeny+16,"#ffff0020","#ffff00"..outfade)
  855.             end
  856.         end
  857.     end
  858.     if mainsprite ~= 0 and trigger[loc] ~= nil then
  859.         special = 0
  860.         if loc == 0xa8 then special = 8 end
  861.         if table.getn(trigger[loc]) ~= nil then
  862.             for j = 1,table.getn(trigger[loc]) do
  863.                 screenx = math.floor(trigger[loc][j] / 0x100)*0x10 - mapoffsetx --+ special
  864.                 screeny = (trigger[loc][j] % 0x100)*0x10 - mapoffsety
  865.                 gui.box(screenx,screeny,screenx+15,screeny+7,"#404040"..infade,"#404040"..outfade)
  866.                 if screenx -1 < spritex[mainsprite] then
  867.                     gui.box(screenx,screeny,screenx+7,screeny+7,"#ff0000"..infade,"#ff0000"..outfade)
  868.                 else gui.box(screenx+8,screeny,screenx+15,screeny+7,"#ff0000"..infade,"#ff0000"..outfade) end
  869.             end
  870.         end
  871.     end
  872.     boxlimit = 64
  873.     if loc == 0xa8 then boxlimit = 8 end
  874.     for i = 1,boxlimit do
  875.         isred = 0
  876.         screenx = mapx[i] - mapoffsetx - 8
  877.         screeny = mapy[i] - mapoffsety - 16
  878.         if screenx < 260 and screeny < 216 then
  879.             if i < 9 then color = "#0000ff00" else color = "#00ff0000" end
  880.             if redbox[loc] ~= nil then
  881.                 if table.getn(redbox[loc]) ~= nil then
  882.                     for j = 1,table.getn(redbox[loc]) do
  883.                         if i == redbox[loc][j]/2+1 then
  884.                             color = "#ff0000"..infade
  885.                             isred = 1
  886.                         end
  887.                     end
  888.                 end
  889.             end
  890.             if isred == 1 or dispCronobox == 1 then
  891.                 screenx2 = screenx + 15
  892.                 screeny2 = screeny + 15
  893.                 if     facing[i] == 0 then --up
  894.                     screeny = screeny - faceoffset*moving[i]
  895.                     screeny2= screeny2- faceoffset
  896.                 elseif facing[i] == 1 then --down
  897.                     screeny = screeny + faceoffset
  898.                     screeny2= screeny2+ faceoffset*moving[i]
  899.                 elseif facing[i] == 2 then --left
  900.                     screenx = screenx - faceoffset*moving[i]
  901.                     screenx2= screenx2- faceoffset
  902.                 elseif facing[i] == 3 then  --right
  903.                     screenx = screenx + faceoffset
  904.                     screenx2= screenx2+ faceoffset*moving[i]
  905.                 end
  906.            
  907.                 gui.box(screenx-7,screeny-7,screenx2+7,screeny2+7, "#40804020","#C0C040"..outfade)
  908.                 gui.box(screenx,screeny,screenx2,screeny2,color,"#ff0000"..outfade)
  909.             end
  910.             if (dispboxID == 1) then
  911.                 gui.text(screenx+faceoffset, screeny+faceoffset, string.format("%x",2*(i-1)),"#FFFFFF","#00000000")
  912.             end
  913.         end
  914.     end
  915.     gui.box(0,211,256,224,"#000000")
  916. end
  917.  
  918.  
  919. local BATTLE_VALUE = 0x7e0026
  920. local BATTLE_STORE = 0x7e29AD
  921. local CRIT_VALUE = 0x7eB3E6
  922. local MENU_TIME = 0x7e0D00
  923. local menutime = 0
  924. local menuopen = 0
  925. local CHAR_ID = 0x7e2980  -- 3 in-party, 6 reserve
  926. local chars = {}
  927. local ATB = 0x7eAFAB
  928. local atb = {}
  929. for i = 0,10 do atb[i] = memory.readbyte(ATB+i) end
  930.  
  931. local windowname = {}
  932.     windowname[0] = {"00","01","02","05","07","09","11","14","18","23","26","28","33","36","39","41"}
  933.     windowname[1] = {"00","01","02","05","09","12","15","16","19","22","25","28","31","35","39","42"}
  934.     windowname[2] = {"00","02","03","05","07","11","15","16","18","20","24","28","32","35","39","41"}
  935.  
  936. local battlewindow = {} --set of windows for 0, 1, and 2 empty characters
  937.     battlewindow[0] = { 0,0x09,0x0d,0x1d,0x2e,0x37,0x3e,0x58,0x61,0x88,0x98,0xab,0xb9,0xdc,0xe3,0xfb,256}
  938.     battlewindow[1] = { 0,0x0d,0x12,0x17,0x35,0x40,0x5c,0x67,0x6a,0x88,0x8f,0xad,0xb3,0xd0,0xe4,0xfd,256}
  939.     battlewindow[2] = { 0,0x0b,0x18,0x1d,0x2c,0x33,0x64,0x66,0x6d,0x79,0x85,0xa7,0xb6,0xd3,0xe6,0xf7,256}
  940.  
  941. local bvrec = {}
  942. local bvsave = 0
  943. function Reload()
  944.     bvrec = {}
  945. end
  946. savestate.registerload(Reload)
  947. bvreccolor = {}
  948. for i = 0,255 do bvreccolor[i] = 8 end
  949.  
  950.     secrange = {"0",".5","1","1.5","2","2.5","3","3.5","4"}
  951.     rulecolors={"#A00000","#FF0000",
  952.                 "#008000","#00FF00",
  953.                 "#0000FF","#2020FF",
  954.                 "#A0A0A0","#FFFFFF",
  955.                 "#A000A0","#FF00FF",
  956.                 "#808000","#FFFF00",
  957.                 "#008080","#00FFFF",
  958.                 "#404040","#808080"}
  959.                
  960. function getValues()
  961.    
  962. --Catch the BV copy
  963.     if battlecopy == 0 and battleflag == 1 and memory.readbyte(BATTLE_VALUE) == memory.readbyte(BATTLE_STORE) then
  964.             battlecopy = 1
  965.     elseif battleflag == 0 then
  966.         battlecopy = 0
  967.     end
  968.  
  969. --Get the active PCs
  970.     mtchars = 0
  971.     for i = 1,3 do
  972.         chars[i] = memory.readbyte(CHAR_ID+i-1)
  973.         if chars[i] >= 0x07 then mtchars = mtchars + 1 end
  974.     end
  975.    
  976. --Value is at different address for in-battle, out-of-battle, & load menu:
  977.     if battlecopy == 1 then
  978.         bv = memory.readbyte(BATTLE_VALUE)
  979.         cv = memory.readbyte(CRIT_VALUE)
  980.     else
  981.         if (memory.readbyte(MENU_TIME) > 0 and memory.readbyte(BATTLE_STORE) == 0 and mtchars == 0) then
  982.         --menutime is for ALL menus, BV is 0 for entire beginning... but load menu has "3 Crono's" (000000)
  983.             bv = memory.readbyte(MENU_TIME)
  984.             bvrec = {}
  985.         else bv = memory.readbyte(BATTLE_STORE) end
  986.         cv = bv
  987.     end
  988.    
  989.     if bv > bvsave then
  990.         for i = bvsave+1,bv-1 do bvrec[i] = 0 end
  991.         bvrec[bv] = 1
  992.         bvsave = bv
  993.         bvreccolor[bv] = 8
  994.     elseif bv < bvsave then
  995.         for i = bvsave+1,255 do bvrec[i] = 0 end
  996.         for i = 0,bv-1 do bvrec[i] = 0 end
  997.         bvrec[bv] = 1
  998.         bvsave = bv
  999.         bvreccolor[bv] = 8
  1000.     end
  1001.  
  1002. --catch ATB reset
  1003.     newatb = {}
  1004.     for i = 0,10 do
  1005.         newatb[i] = memory.readbyte(ATB+i)
  1006.         if atb[i] == 0 and newatb[i] ~= 0 and newatb[i] ~= 0x80 then
  1007.             if bvreccolor[bv] == 8 then
  1008.                 if i < 3 then
  1009.                     bvreccolor[bv] = chars[i+1]
  1010.                 else
  1011.                     bvreccolor[bv] = 7
  1012.                 end
  1013.             end
  1014.         end
  1015.         atb[i] = newatb[i]
  1016.     end
  1017. end
  1018.  
  1019. function displayValues()
  1020.  
  1021.     rulecolor = 1
  1022.     for j = 1,16 do
  1023.         if bv >= battlewindow[mtchars][j] and bv < battlewindow[mtchars][j+1] then
  1024.             rulecolor = j
  1025.         end
  1026.     end
  1027.     gui.text(bv-3,dispy+26,string.format("%02x",bv),rulecolors[rulecolor],"#00000000")
  1028.     gui.text(bv-259,dispy+26,string.format("%02x",bv),rulecolors[rulecolor],"#00000000") --wrap-around
  1029.    
  1030.     for i = 0,255 do
  1031.         for j = 1,16 do
  1032.             if i >= battlewindow[mtchars][j] and i < battlewindow[mtchars][j+1] then
  1033.                 rulecolor = j
  1034.             end
  1035.         end
  1036.  
  1037.         gui.pixel(i,dispy+24,rulecolors[rulecolor])
  1038.         if i%4 == 0 then gui.pixel(i,dispy+25,rulecolors[rulecolor]) end
  1039.         if i%16 == 0 then
  1040.             gui.pixel(i,dispy+26,rulecolors[rulecolor])
  1041.             gui.pixel(i,dispy+27,rulecolors[rulecolor]) end
  1042.         if bvrec[i] == 1 then
  1043.             gui.pixel(i,dispy+23,charcolor[bvreccolor[i]+1])
  1044.             if bvreccolor[i] < 7 then
  1045.                 gui.pixel(i,dispy+22,charcolor[bvreccolor[i]+1])
  1046.             end
  1047.         end
  1048.     end
  1049.     gui.pixel(bv,dispy+21,charcolor[bvreccolor[bv]+1])
  1050.     gui.pixel(bv,dispy+22,charcolor[bvreccolor[bv]+1])
  1051.     gui.pixel(bv,dispy+23,charcolor[bvreccolor[bv]+1]) 
  1052. end
  1053.  
  1054.  
  1055. local CHAR_ID = 0x7e2980  -- 3 in-party then 6 reserve (e.g. for 1-on-1 bosses)
  1056. local CHAR_WEAP = 0x7e2629
  1057. local CHAR_ACC = 0x7e262A
  1058. local crits =   "0737062067712743017053012106621026206760245002737143667207070014"..
  1059.                 "1101674231747620560305126422403270125313166113731602620666773021"..
  1060.                 "1714114244363074011420427072702021156152710015037100071773030063"..
  1061.                 "3110560024303132144471071671003163600200333701061633241110004006"..
  1062.                 "0737062067" --wrap-around
  1063. local critcolor = {"#808080","#808080","#008000","#FF00FF",
  1064.                 "#00FFFF","#00FF00","#FF950E","#FFFFFF"}
  1065. function displayCrits()
  1066.  
  1067. --Get equipment and their crit chance
  1068.     chance = {}
  1069.     crittext = ""
  1070.     for i = 1,3 do
  1071.         if chars[i] < 0x07 then
  1072.             weap = memory.readbyte(CHAR_WEAP + 0x50*(chars[i]))
  1073.             acc = memory.readbyte(CHAR_ACC + 0x50*(chars[i]))
  1074.             if     weap == 0x55 then -- rainbow
  1075.                 chance[i] = 1      
  1076.             elseif acc  == 0xB3 and (weap == 0x42 or weap == 0x3D) then -- masamune+heromedal
  1077.                 chance[i] = 2  
  1078.             elseif weap == 0x40 or   weap == 0x19 or weap == 0x1A  then -- wonder, siren, valkerye
  1079.                 chance[i] = 3  
  1080.             elseif weap == 0x53 then -- swallow
  1081.                 chance[i] = 4      
  1082.             elseif weap == 0x54 or chars[i] == 4 then -- slasher2 (22)
  1083.                 chance[i] = 5
  1084.             elseif weap == 0x0D or chars[i] == 1 or chars[i] == 2 or chars[i] == 5 then -- kaliblade
  1085.                 chance[i] = 6
  1086.             elseif chars[i] == 0 or chars[i] == 3 or chars[i] == 6 then
  1087.                 chance[i] = 7 end
  1088.         else    chance[i] = 8 end
  1089.     end
  1090.  
  1091.     for i = 1,6 do
  1092.         cc = 7
  1093.         critconf = 0       
  1094.         cv = cv + 1
  1095.         for j = 1,3 do
  1096.             if chance[j] <= tonumber(crits:sub(cv,cv)) then
  1097.                 critconf = critconf + 1
  1098.                 if critconf == 1 then
  1099.                     cc = chars[j] + 1
  1100.                 elseif critconf > 1 then
  1101.                 end
  1102.             end
  1103.         end
  1104.         writeDigit(tonumber(crits:sub(cv,cv)),184+i*10,charcolor[cc],charshade[cc])
  1105.     end
  1106. end
  1107.  
  1108.  
  1109. local emuframe = 0
  1110. local moviedata = {}
  1111. local movieoffset = 0
  1112.  
  1113. function displayJoypad()
  1114.  
  1115.     emuframe = emu.framecount()
  1116.  
  1117. --Read in movie file:
  1118.     if movie.mode() == "playback" and movieoffset == 0 then
  1119.         f = io.open(movie.name(), "rb")
  1120.         byte = f:read(1)
  1121.         while byte ~= nil do
  1122.             byte = string.byte(byte)
  1123.             table.insert(moviedata, byte)
  1124.             byte = f:read(1)
  1125.         end
  1126.         f:close()
  1127.         for i = 0,3 do
  1128.             movieoffset = movieoffset + moviedata[0x1C+1+i]*(0x100^i)
  1129.         end
  1130.     end
  1131.    
  1132. --Get inputs either from movie or user:
  1133.     if movie.mode() == "playback" then
  1134.         word = moviedata[movieoffset + emuframe*2 + 1] + moviedata[movieoffset + emuframe*2]*0x100
  1135.         word = math.floor(word / 16)  --discard 4 lowest bits; Lua uses all doubles (floating point)
  1136.         for i = 1, 12 do
  1137.             if word % 2 == 1 then
  1138.                 inputs[ button[i] ] = true
  1139.             else inputs[ button[i] ] = nil end
  1140.             word = math.floor(word / 2)
  1141.         end
  1142.     else inputs = joypad.get() end
  1143.  
  1144. --Draw each button (color it based on hold duration):
  1145.     for i = 1, 12 do
  1146.         if inputs[button[i]] then
  1147.             if unpress[i] > 0 then
  1148.                 press[i] = 0
  1149.                 if unpress[i] == 6 then
  1150.                     turbo[i] = 1
  1151.                 else
  1152.                     turbo[i] = 0
  1153.                 end
  1154.                 unpress[i] = 0
  1155.             end
  1156.             if press[i] < 240 then
  1157.                 press[i] = press[i] + 6
  1158.             end
  1159.         else
  1160.             if unpress[i] ~= 0 then -- i.e. was pressed in previous frame
  1161.                 turbo[i] = 0
  1162.             end
  1163.             if unpress[i] < 240 then
  1164.                 unpress[i] = unpress[i] + 6
  1165.             end
  1166.         end
  1167.  
  1168.         shoulder = 0
  1169.         if i == 1 or i == 2 then shoulder = 1 end
  1170.        
  1171.         buttontext = "#000000c0"
  1172.         buttoncolor = "#00000000"
  1173.         if inputs[button[i]] then
  1174.             buttoncolor = "#"..string.format("%02x",0xF0-press[i]).."ff80".."a0"
  1175.         elseif press[i] > 0 then
  1176.             darken = string.rep(string.format("%02x",0xF0-press[i]),3)
  1177.             buttoncolor = "#"..string.format("%02x",press[i]).."00"..string.format("%02x",0xF0-press[i])..string.format("%02x",160-unpress[i]/3*2)
  1178.         end
  1179.         if turbo[i] == 1 then
  1180.             buttontext = "#ff0000c0"
  1181.             buttoncolor = "#ffffffa0"
  1182.         end
  1183.  
  1184.         bx = 10
  1185.         by = 8
  1186.         gui.box(
  1187.             xoffset+xcoords[i]*bx, yoffset+ycoords[i]*by,
  1188.             xoffset+xcoords[i]*bx+bx +shoulder*bx, yoffset+ycoords[i]*by+by -shoulder*3, buttoncolor, buttoncolor)
  1189.         gui.text(xoffset+xcoords[i]*bx+4, yoffset+ycoords[i]*by+0,btnlabel[i],buttontext,"#00000000")
  1190.     end
  1191. end
  1192.  
  1193.  
  1194. local BATTLES_X = 0x7e975a
  1195. local BATTLES_Y = 0x7e9765
  1196. local HP = 0x7e5e30
  1197. local MENU_POS = 0x7e00ec
  1198. function displayHP()
  1199.     for i = 3, 10 do
  1200.         atb2 = memory.readbyte(ATB+i)
  1201.         if (atb2 ~= 0xFF) then
  1202.             gui.text(memory.readbyte(BATTLES_X+i)+12,memory.readbyte(BATTLES_Y+i)+4,
  1203.             atb2,"#808080")
  1204.             gui.text(memory.readbyte(BATTLES_X+i)-18,memory.readbyte(BATTLES_Y+i)+4,
  1205.             string.format("%6d",memory.readword(HP+0x80*i)),"#C0C0C0")
  1206.         end
  1207.     end
  1208.     for i = 0, 2 do
  1209.         atb2 = memory.readbyte(ATB+i)
  1210.         if (atb2 ~= 0xFF) then
  1211.             gui.text(xoffset+177,19+12*i+(yoffset-16)*memory.readbyte(MENU_POS),
  1212.             memory.readbyte(ATB+i),"#808080")
  1213.         end
  1214.     end
  1215. end
  1216.  
  1217. local run_got = 0x7e99cd
  1218. local run_count = 0x7e99cf
  1219. local battle_end = 0x7e020c -- "Ran away!" message called
  1220. function displayRunaway()
  1221.     if (memory.readbyte(battle_end) ~= 8) then
  1222.         ran = memory.readbyte(run_got)
  1223.         rundisp = memory.readbyte(run_count)
  1224.     end
  1225.     runcolor = "#808080"
  1226.     if (ran > 0) then
  1227.         rundisp = ran+120
  1228.         runcolor = "#00FF00"
  1229.     end
  1230.     gui.text(120,yoffset+37,string.format("%3d",rundisp),runcolor)
  1231. end
  1232.  
  1233. while true do
  1234.  
  1235.     inputs = joypad.get()
  1236.     getValues()
  1237.  
  1238.     --Catch <select> pressed
  1239.     if inputs[ button[10] ] then
  1240.         if selectheld == 0 then
  1241.             selectheld = 1
  1242.             if dispbox == 4 then
  1243.                 dispbox = 1
  1244.             else dispbox = dispbox + 1 end
  1245.         end
  1246.     else selectheld = 0 end
  1247.    
  1248.    
  1249.     if menutime ~= memory.readbyte(MENU_TIME) then
  1250.         if menuopen == 0 then
  1251.             menuopen = 1 end
  1252.     else menuopen = 0 end
  1253.     menutime = memory.readbyte(MENU_TIME)
  1254.  
  1255. --Display all
  1256.     if (dispbox < 3) and loc < 0x1F0 and menuopen == 0 and battleflag == 0 then
  1257.         displayHitbox()
  1258.     end
  1259.     if dispbox % 2 > 0 then
  1260.         displayJoypad()
  1261.     end
  1262.     if battlecopy == 1 then
  1263.         displayHP()
  1264.         displayRunaway()
  1265.     end
  1266.     if dispbox > 0 and mtchars < 3 then
  1267.         displayValues()
  1268.         displayTime()
  1269.     --  displayCrits()
  1270.         gui.text(1,yoffset+37,string.format("%02x",cv),critcolor[tonumber(crits:sub(cv+1,cv+1))+1])
  1271.     end
  1272.     --BattleSpeed
  1273.     gui.text(1,0,"bs"..memory.readbyte(0x7e2990)%8+1,"#808080")
  1274.  
  1275.     emu.frameadvance()
  1276. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement