From 304790bd7e7d9d5fb87eac516979f5a066eaa1e6 Mon Sep 17 00:00:00 2001 From: Connor Olding Date: Fri, 20 Mar 2015 19:46:08 -0700 Subject: [PATCH] refactor addresses, tuck away in folder --- Lua/A EU10.lua | 12 --- Lua/A EU11.lua | 12 --- Lua/A EUGC.lua | 12 --- Lua/A JP11.lua | 12 --- Lua/A JPGC.lua | 12 --- Lua/A USDE.lua | 12 --- Lua/A USGC.lua | 12 --- Lua/actor lister.lua | 4 +- Lua/addrs.lua | 28 ------ Lua/addrs/M EU10.lua | 1 + Lua/addrs/M EU11.lua | 1 + Lua/{A EUDB.lua => addrs/M EUDB.lua} | 14 +-- Lua/addrs/M EUGC.lua | 1 + Lua/{A JP10.lua => addrs/M JP10.lua} | 14 +-- Lua/addrs/M JP11.lua | 1 + Lua/addrs/M JPGC.lua | 1 + Lua/{A US10.lua => addrs/M US10.lua} | 14 +-- Lua/addrs/M USDE.lua | 1 + Lua/addrs/M USGC.lua | 1 + Lua/{A common.lua => addrs/M common.lua} | 11 +-- Lua/addrs/O US10.lua | 3 + Lua/{A O US10.lua => addrs/O common.lua} | 24 +----- Lua/addrs/init.lua | 103 +++++++++++++++++++++++ Lua/cheat menu.lua | 2 +- Lua/count flags.lua | 2 +- Lua/oneshot.lua | 6 +- Lua/room debug.lua | 2 +- Lua/watch animations.lua | 2 +- 28 files changed, 130 insertions(+), 190 deletions(-) delete mode 100755 Lua/A EU10.lua delete mode 100755 Lua/A EU11.lua delete mode 100755 Lua/A EUGC.lua delete mode 100755 Lua/A JP11.lua delete mode 100755 Lua/A JPGC.lua delete mode 100755 Lua/A USDE.lua delete mode 100755 Lua/A USGC.lua delete mode 100755 Lua/addrs.lua create mode 100755 Lua/addrs/M EU10.lua create mode 100755 Lua/addrs/M EU11.lua rename Lua/{A EUDB.lua => addrs/M EUDB.lua} (85%) create mode 100755 Lua/addrs/M EUGC.lua rename Lua/{A JP10.lua => addrs/M JP10.lua} (88%) create mode 100755 Lua/addrs/M JP11.lua create mode 100755 Lua/addrs/M JPGC.lua rename Lua/{A US10.lua => addrs/M US10.lua} (88%) create mode 100755 Lua/addrs/M USDE.lua create mode 100755 Lua/addrs/M USGC.lua rename Lua/{A common.lua => addrs/M common.lua} (98%) create mode 100644 Lua/addrs/O US10.lua rename Lua/{A O US10.lua => addrs/O common.lua} (93%) create mode 100755 Lua/addrs/init.lua diff --git a/Lua/A EU10.lua b/Lua/A EU10.lua deleted file mode 100755 index 85c303c..0000000 --- a/Lua/A EU10.lua +++ /dev/null @@ -1,12 +0,0 @@ -local link = 0x1E6B50 -local global = 0x3DDFC0 -local actor = 0x3F7250 - -function AL(a, s) return A(link+a, s) end -function AG(a, s) return A(global+a, s) end -function AA(a, s) return A(actor+a, s) end - -local common = dofile("A common.lua") - -return merge(common, { -}) diff --git a/Lua/A EU11.lua b/Lua/A EU11.lua deleted file mode 100755 index 2cc4b43..0000000 --- a/Lua/A EU11.lua +++ /dev/null @@ -1,12 +0,0 @@ -local link = 0x1E6EF0 -local global = 0x3DE360 -local actor = 0x3F75F0 - -function AL(a, s) return A(link+a, s) end -function AG(a, s) return A(global+a, s) end -function AA(a, s) return A(actor+a, s) end - -local common = dofile("A common.lua") - -return merge(common, { -}) diff --git a/Lua/A EUGC.lua b/Lua/A EUGC.lua deleted file mode 100755 index c246348..0000000 --- a/Lua/A EUGC.lua +++ /dev/null @@ -1,12 +0,0 @@ -local link = 0x1E5480 -local global = 0x378EB0 -local actor = 0x392140 - -function AL(a, s) return A(link+a, s) end -function AG(a, s) return A(global+a, s) end -function AA(a, s) return A(actor+a, s) end - -local common = dofile("A common.lua") - -return merge(common, { -}) diff --git a/Lua/A JP11.lua b/Lua/A JP11.lua deleted file mode 100755 index b1b68f4..0000000 --- a/Lua/A JP11.lua +++ /dev/null @@ -1,12 +0,0 @@ -local link = 0x1EF710 -local global = 0x3E6FB0 -local actor = 0x400260 - -function AL(a, s) return A(link+a, s) end -function AG(a, s) return A(global+a, s) end -function AA(a, s) return A(actor+a, s) end - -local common = dofile("A common.lua") - -return merge(common, { -}) diff --git a/Lua/A JPGC.lua b/Lua/A JPGC.lua deleted file mode 100755 index 2a5e69c..0000000 --- a/Lua/A JPGC.lua +++ /dev/null @@ -1,12 +0,0 @@ -local link = 0x1ED820 -local global = 0x381250 -local actor = 0x39A4E0 - -function AL(a, s) return A(link+a, s) end -function AG(a, s) return A(global+a, s) end -function AA(a, s) return A(actor+a, s) end - -local common = dofile("A common.lua") - -return merge(common, { -}) diff --git a/Lua/A USDE.lua b/Lua/A USDE.lua deleted file mode 100755 index b5764be..0000000 --- a/Lua/A USDE.lua +++ /dev/null @@ -1,12 +0,0 @@ -local link = 0x1EEE80 -local global = 0x3E63B0 -local actor = 0x3FF680 - -function AL(a, s) return A(link+a, s) end -function AG(a, s) return A(global+a, s) end -function AA(a, s) return A(actor+a, s) end - -local common = dofile("A common.lua") - -return merge(common, { -}) diff --git a/Lua/A USGC.lua b/Lua/A USGC.lua deleted file mode 100755 index 165333f..0000000 --- a/Lua/A USGC.lua +++ /dev/null @@ -1,12 +0,0 @@ -local link = 0x1ED830 -local global = 0x381260 -local actor = 0x39A4F0 - -function AL(a, s) return A(link+a, s) end -function AG(a, s) return A(global+a, s) end -function AA(a, s) return A(actor+a, s) end - -local common = dofile("A common.lua") - -return merge(common, { -}) diff --git a/Lua/actor lister.lua b/Lua/actor lister.lua index 4bcb16c..d639d49 100755 --- a/Lua/actor lister.lua +++ b/Lua/actor lister.lua @@ -1,13 +1,11 @@ require "boilerplate" -require "addrs" +require "addrs.init" -- bizhawk lua has some nasty memory leaks at the moment, -- so instead of creating an object every time, -- using a template to offset from will do for now. local actor_t = Actor(0) -local oot = version:sub(1, 2) == "O " - local actor_names, damage_names if oot then actor_names = require "actor names oot" diff --git a/Lua/addrs.lua b/Lua/addrs.lua deleted file mode 100755 index f750241..0000000 --- a/Lua/addrs.lua +++ /dev/null @@ -1,28 +0,0 @@ -versions = { -- sha1 hashes of .z64s - -- Majora's Mask - ['D6133ACE5AFAA0882CF214CF88DABA39E266C078'] = "US10", - ['2F0744F2422B0421697A74B305CB1EF27041AB11'] = "USDE", - ['9743AA026E9269B339EB0E3044CD5830A440C1FD'] = "USGC", - ['C04599CDAFEE1C84A7AF9A71DF68F139179ADA84'] = "EU10", - ['BB4E4757D10727C7584C59C1F2E5F44196E9C293'] = "EU11", - ['B38B71D2961DFFB523020A67F4807A4B704E347A'] = "EUDB", - ['A849A65E56D57D4DD98B550524150F898DF90A9F'] = "EUGC", - ['5FB2301AACBF85278AF30DCA3E4194AD48599E36'] = "JP10", - ['41FDB879AB422EC158B4EAFEA69087F255EA8589'] = "JP11", - ['1438FD501E3E5B25461770AF88C02AB1E41D3A7E'] = "JPGC", - - -- Ocarina of Time - ['AD69C91157F6705E8AB06C79FE08AAD47BB57BA7'] = "O US10", - -- this is supposedly the same ROM, but i don't have it offhand to verify - ['79A4F053D34018E59279E6D4B83C7DACCD985C87'] = "O US10", -} - ---while version == nil do --- emu.yield() -- wait until a known ROM is loaded (doesn't work) - hash = gameinfo.getromhash() - version = versions[hash] ---end - -addrs = require("A "..version) - -return addrs diff --git a/Lua/addrs/M EU10.lua b/Lua/addrs/M EU10.lua new file mode 100755 index 0000000..a564707 --- /dev/null +++ b/Lua/addrs/M EU10.lua @@ -0,0 +1 @@ +return {} diff --git a/Lua/addrs/M EU11.lua b/Lua/addrs/M EU11.lua new file mode 100755 index 0000000..a564707 --- /dev/null +++ b/Lua/addrs/M EU11.lua @@ -0,0 +1 @@ +return {} diff --git a/Lua/A EUDB.lua b/Lua/addrs/M EUDB.lua similarity index 85% rename from Lua/A EUDB.lua rename to Lua/addrs/M EUDB.lua index d9fa2ab..7ade5c0 100755 --- a/Lua/A EUDB.lua +++ b/Lua/addrs/M EUDB.lua @@ -1,14 +1,4 @@ -local link = 0x23F790 -local global = 0x448700 -local actor = 0x4619D0 - -function AL(a, s) return A(link+a, s) end -function AG(a, s) return A(global+a, s) end -function AA(a, s) return A(actor+a, s) end - -local common = dofile("A common.lua") - -return merge(common, { +return { checksum = AL(0x100A, 2), disable_pause = AL(0x100D, 1), hookshot_ba = AL(0x100E, 1), @@ -45,4 +35,4 @@ return merge(common, { screen_scale_enable = AL(0x3F60, 1), screen_scale = AL(0x3F64, 'f'), scene_flags_ingame = AL(0x3F68, 0x960), -}) +} diff --git a/Lua/addrs/M EUGC.lua b/Lua/addrs/M EUGC.lua new file mode 100755 index 0000000..a564707 --- /dev/null +++ b/Lua/addrs/M EUGC.lua @@ -0,0 +1 @@ +return {} diff --git a/Lua/A JP10.lua b/Lua/addrs/M JP10.lua similarity index 88% rename from Lua/A JP10.lua rename to Lua/addrs/M JP10.lua index b63828d..1fd7471 100755 --- a/Lua/A JP10.lua +++ b/Lua/addrs/M JP10.lua @@ -1,14 +1,4 @@ -local link = 0x1EF460 -local global = 0x3E6CF0 -local actor = 0x3FFFA0 - -function AL(a, s) return A(link+a, s) end -function AG(a, s) return A(global+a, s) end -function AA(a, s) return A(actor+a, s) end - -local common = dofile("A common.lua") - -return merge(common, { +return { checksum = AL(0x138E, 2), --disable_pause = AL(, 1), --hookshot_ba = AL(, 1), @@ -61,4 +51,4 @@ return merge(common, { --warp_begin = A(, 1), --screen_dim = A(, 1), --warp_destination = A(, 2), -}) +} diff --git a/Lua/addrs/M JP11.lua b/Lua/addrs/M JP11.lua new file mode 100755 index 0000000..a564707 --- /dev/null +++ b/Lua/addrs/M JP11.lua @@ -0,0 +1 @@ +return {} diff --git a/Lua/addrs/M JPGC.lua b/Lua/addrs/M JPGC.lua new file mode 100755 index 0000000..a564707 --- /dev/null +++ b/Lua/addrs/M JPGC.lua @@ -0,0 +1 @@ +return {} diff --git a/Lua/A US10.lua b/Lua/addrs/M US10.lua similarity index 88% rename from Lua/A US10.lua rename to Lua/addrs/M US10.lua index 34f9573..b2f6e2e 100755 --- a/Lua/A US10.lua +++ b/Lua/addrs/M US10.lua @@ -1,14 +1,4 @@ -local link = 0x1EF670 -local global = 0x3E6B20 -local actor = 0x3FFDB0 - -function AL(a, s) return A(link+a, s) end -function AG(a, s) return A(global+a, s) end -function AA(a, s) return A(actor+a, s) end - -local common = dofile("A common.lua") - -return merge(common, { +return { checksum = AL(0x100A, 2), disable_pause = AL(0x100D, 1), hookshot_ba = AL(0x100E, 1), @@ -61,4 +51,4 @@ return merge(common, { warp_begin = A(0x3FF395, 1), screen_dim = A(0x3FF397, 1), warp_destination = A(0x3FF39A, 2), -}) +} diff --git a/Lua/addrs/M USDE.lua b/Lua/addrs/M USDE.lua new file mode 100755 index 0000000..a564707 --- /dev/null +++ b/Lua/addrs/M USDE.lua @@ -0,0 +1 @@ +return {} diff --git a/Lua/addrs/M USGC.lua b/Lua/addrs/M USGC.lua new file mode 100755 index 0000000..a564707 --- /dev/null +++ b/Lua/addrs/M USGC.lua @@ -0,0 +1 @@ +return {} diff --git a/Lua/A common.lua b/Lua/addrs/M common.lua similarity index 98% rename from Lua/A common.lua rename to Lua/addrs/M common.lua index b0ea65d..1261c02 100755 --- a/Lua/A common.lua +++ b/Lua/addrs/M common.lua @@ -1,13 +1,4 @@ -- version-agnostic addresses -A = require "boilerplate" - -function merge(t1, t2) - for k, v in pairs(t1) do - t2[k] = v - end - return t2 -end - function Actor(addr) local function AA(a, s) return A(addr+a, s) end return { @@ -245,6 +236,7 @@ return { current_scene_flags_4 = AG(0x1E6C, 4), current_scene_flags_5 = AG(0x1E74, 4), + --[[ FIXME link_actor = merge(Actor(AA(0,0).addr), { item_in_hand = AA(0x148, 1), animation_id = AA(0x24A, 2), @@ -253,4 +245,5 @@ return { movement_angle = AA(0xAD4, 2), active_sword = AA(0xADB, 1), }), + --]] } diff --git a/Lua/addrs/O US10.lua b/Lua/addrs/O US10.lua new file mode 100644 index 0000000..3e6812f --- /dev/null +++ b/Lua/addrs/O US10.lua @@ -0,0 +1,3 @@ +return { + target_style = AL(0x140C, 1), +} diff --git a/Lua/A O US10.lua b/Lua/addrs/O common.lua similarity index 93% rename from Lua/A O US10.lua rename to Lua/addrs/O common.lua index 1818d6f..76d9407 100644 --- a/Lua/A O US10.lua +++ b/Lua/addrs/O common.lua @@ -1,20 +1,4 @@ -A = require "boilerplate" - -local link = 0x11A5D0 -local global = 0x1C84A0 -local actor = 0x1DAA30 - -function AL(a, s) return A(link+a, s) end -function AG(a, s) return A(global+a, s) end -function AA(a, s) return A(actor+a, s) end - -function merge(t1, t2) - for k, v in pairs(t1) do - t2[k] = v - end - return t2 -end - +-- version-agnostic addresses function Actor(addr) local function AA(a, s) return A(addr+a, s) end return { @@ -68,7 +52,7 @@ function Actor(addr) } end -local common = { +return { exit_value = AL(0x02, 2), age_modifier = AL(0x04, 4), cutscene_status = AL(0x0A, 2), -- "cutscene number" 0xFFFx @@ -185,7 +169,3 @@ local common = { z_cursor_actor = AG(0x1CC8, 4), z_target_actor = AG(0x1CCC, 4), } - -return merge(common, { - target_style = AL(0x140C, 1), -}) diff --git a/Lua/addrs/init.lua b/Lua/addrs/init.lua new file mode 100755 index 0000000..e6d508c --- /dev/null +++ b/Lua/addrs/init.lua @@ -0,0 +1,103 @@ +local here = select("1", ...):match(".+%.") or "" + +A = require "boilerplate" + +versions = { -- sha1 hashes of .z64s + -- Majora's Mask + ["D6133ACE5AFAA0882CF214CF88DABA39E266C078"] = "M US10", + ["2F0744F2422B0421697A74B305CB1EF27041AB11"] = "M USDE", + ["9743AA026E9269B339EB0E3044CD5830A440C1FD"] = "M USGC", + ["C04599CDAFEE1C84A7AF9A71DF68F139179ADA84"] = "M EU10", + ["BB4E4757D10727C7584C59C1F2E5F44196E9C293"] = "M EU11", + ["B38B71D2961DFFB523020A67F4807A4B704E347A"] = "M EUDB", + ["A849A65E56D57D4DD98B550524150F898DF90A9F"] = "M EUGC", + ["5FB2301AACBF85278AF30DCA3E4194AD48599E36"] = "M JP10", + ["41FDB879AB422EC158B4EAFEA69087F255EA8589"] = "M JP11", + ["1438FD501E3E5B25461770AF88C02AB1E41D3A7E"] = "M JPGC", + + -- Ocarina of Time + ["AD69C91157F6705E8AB06C79FE08AAD47BB57BA7"] = "O US10", + -- this is supposedly the same ROM, but i don't have it offhand to verify + ["79A4F053D34018E59279E6D4B83C7DACCD985C87"] = "O US10", +} + +local basics = { + ["M US10"] = { + link = 0x1EF670, + global = 0x3E6B20, + actor = 0x3FFDB0, + }, + ["M USDE"] = { + link = 0x1EEE80, + global = 0x3E63B0, + actor = 0x3FF680, + }, + ["M USGC"] = { + link = 0x1ED830, + global = 0x381260, + actor = 0x39A4F0, + }, + ["M EU10"] = { + link = 0x1E6B50, + global = 0x3DDFC0, + actor = 0x3F7250, + }, + ["M EU11"] = { + link = 0x1E6EF0, + global = 0x3DE360, + actor = 0x3F75F0, + }, + ["M EUDB"] = { + link = 0x23F790, + global = 0x448700, + actor = 0x4619D0, + }, + ["M EUGC"] = { + link = 0x1E5480, + global = 0x378EB0, + actor = 0x392140, + }, + ["M JP10"] = { + link = 0x1EF460, + global = 0x3E6CF0, + actor = 0x3FFFA0, + }, + ["M JP11"] = { + link = 0x1EF710, + global = 0x3E6FB0, + actor = 0x400260, + }, + ["M JPGC"] = { + link = 0x1ED820, + global = 0x381250, + actor = 0x39A4E0, + }, + ["O US10"] = { + link = 0x11A5D0, + global = 0x1C84A0, + actor = 0x1DAA30, + }, +} + +--while version == nil do +-- emu.yield() -- wait until a known ROM is loaded (doesn't work) + hash = gameinfo.getromhash() + version = versions[hash] +--end + +local v = version:sub(1, 2) +oot = v == "O " +mm = v == "M " + +local b = basics[version] +function AL(a, s) return A(b.link + a, s) end +function AG(a, s) return A(b.global + a, s) end +function AA(a, s) return A(b.actor + a, s) end + +addrs = require(here..version) + +local common = require(here..v.."common") + +setmetatable(addrs, {__index=common}) + +return addrs diff --git a/Lua/cheat menu.lua b/Lua/cheat menu.lua index 6c70d44..f3c377f 100755 --- a/Lua/cheat menu.lua +++ b/Lua/cheat menu.lua @@ -1,5 +1,5 @@ require "boilerplate" -local addrs = require "addrs" +local addrs = require "addrs.init" local close = {text="close", type="close"} diff --git a/Lua/count flags.lua b/Lua/count flags.lua index 63df48b..762422f 100755 --- a/Lua/count flags.lua +++ b/Lua/count flags.lua @@ -1,4 +1,4 @@ -require "addrs" +require "addrs.init" -- precalculate hamming weights of bytes hamming_weight = {} diff --git a/Lua/oneshot.lua b/Lua/oneshot.lua index 7aa1cf2..d6127ac 100755 --- a/Lua/oneshot.lua +++ b/Lua/oneshot.lua @@ -1,11 +1,9 @@ -- gimme gimme gimme -local a = require "addrs" +local a = require "addrs.init" require "item values" -local oot = version:sub(1, 2) == "O " - local iv -if version == "JP10" or version == "JP11" then +if version == "M JP10" or version == "M JP11" then iv = require "item values early" elseif oot then iv = require "item values oot" diff --git a/Lua/room debug.lua b/Lua/room debug.lua index 0bf8deb..ce7c4d9 100755 --- a/Lua/room debug.lua +++ b/Lua/room debug.lua @@ -1,5 +1,5 @@ local A = require "boilerplate" -local addrs = require "addrs" +local addrs = require "addrs.init" function printf(fmt, ...) print(fmt:format(...)) diff --git a/Lua/watch animations.lua b/Lua/watch animations.lua index 25d0832..ed62ab0 100755 --- a/Lua/watch animations.lua +++ b/Lua/watch animations.lua @@ -1,4 +1,4 @@ -local addrs = require "addrs" +local addrs = require "addrs.init" local anim_addr = addrs.link_actor.animation_id.addr local anims_seen = {