diff --git a/build/oot/main.lua b/build/oot/main.lua new file mode 100644 index 0000000..8dc24cc --- /dev/null +++ b/build/oot/main.lua @@ -0,0 +1,2814 @@ +do + local RedPotionBottle = { + __tag = "RedPotionBottle" + } + local DinsFire = { __tag = "DinsFire" } + local EyeballFrog = { + __tag = "EyeballFrog" + } + local SkullMask = { + __tag = "SkullMask" + } + local NoItem = { __tag = "NoItem" } + local HylianShield = { + __tag = "HylianShield" + } + local EmptyBottle = { + __tag = "EmptyBottle" + } + local FireArrow = { + __tag = "FireArrow" + } + local Prescription = { + __tag = "Prescription" + } + local KeatonMask = { + __tag = "KeatonMask" + } + local function UnknownItem(a) + return { __tag = "UnknownItem", a } + end + local function UnknownBoots(a) + return { __tag = "UnknownBoots", a } + end + local function P(a) + return function(b) + return { __tag = "P", a, b } + end + end + local DekuShield = { + __tag = "DekuShield" + } + local NayrusLove = { + __tag = "NayrusLove" + } + local FairyBow = { __tag = "FairyBow" } + local BrokenGoronsSword = { + __tag = "BrokenGoronsSword" + } + local ZeldasLetter = { + __tag = "ZeldasLetter" + } + local HoverBoots = { + __tag = "HoverBoots" + } + local function S(a) + return function(b) + return { __tag = "S", a, b } + end + end + local NoShield = { __tag = "NoShield" } + local function MkSome(a) + return function(b) + return { __tag = "MkSome", a, b } + end + end + local LightArrow = { + __tag = "LightArrow" + } + local Bomb = { __tag = "Bomb" } + local PoachersSaw = { + __tag = "PoachersSaw" + } + local Chicken = { __tag = "Chicken" } + local IronBoots = { + __tag = "IronBoots" + } + local Proxy = { __tag = "Proxy" } + local FishBottle = { + __tag = "FishBottle" + } + local Bombchu_10 = { + __tag = "Bombchu_10" + } + local FairyBowAndIceArrow = { + __tag = "FairyBowAndIceArrow" + } + local ZoraMask = { __tag = "ZoraMask" } + local function Some(a) + return { __tag = "Some", a } + end + local KokiriTunic = { + __tag = "KokiriTunic" + } + local FairyBottle = { + __tag = "FairyBottle" + } + local OcarinaOfTime = { + __tag = "OcarinaOfTime" + } + local FairyBowAndFireArrow = { + __tag = "FairyBowAndFireArrow" + } + local GoronMask = { + __tag = "GoronMask" + } + local BluePotionBottle = { + __tag = "BluePotionBottle" + } + local FairyOcarina = { + __tag = "FairyOcarina" + } + local ClaimCheck = { + __tag = "ClaimCheck" + } + local BunnyHood = { + __tag = "BunnyHood" + } + local GreenPotionBottle = { + __tag = "GreenPotionBottle" + } + local FairySlingshot = { + __tag = "FairySlingshot" + } + local EyeDrops = { __tag = "EyeDrops" } + local SpookyMask = { + __tag = "SpookyMask" + } + local MirrorShield = { + __tag = "MirrorShield" + } + local BugBottle = { + __tag = "BugBottle" + } + local FaroresWind = { + __tag = "FaroresWind" + } + local GoronsSword = { + __tag = "GoronsSword" + } + local Nil = { __tag = "Nil" } + local PocketEgg = { + __tag = "PocketEgg" + } + local NoSword = { __tag = "NoSword" } + local BlueFireBottle = { + __tag = "BlueFireBottle" + } + local IceArrow = { __tag = "IceArrow" } + local MasterSword0 = { + __tag = "MasterSword0" + } + local SoldOut = { __tag = "SoldOut" } + local function UnknownTunic(a) + return { __tag = "UnknownTunic", a } + end + local RutosLetterBottle = { + __tag = "RutosLetterBottle" + } + local Longshot = { __tag = "Longshot" } + local KokiriSword0 = { + __tag = "KokiriSword0" + } + local MaskOfTruth = { + __tag = "MaskOfTruth" + } + local ZoraTunic = { + __tag = "ZoraTunic" + } + local FullMilkBottle = { + __tag = "FullMilkBottle" + } + local Hookshot = { __tag = "Hookshot" } + local FairyBowAndLightArrow = { + __tag = "FairyBowAndLightArrow" + } + local GerudoMask = { + __tag = "GerudoMask" + } + local None = { __tag = "None" } + local GoronTunic = { + __tag = "GoronTunic" + } + local WeirdEgg = { __tag = "WeirdEgg" } + local MegatonHammer = { + __tag = "MegatonHammer" + } + local OddPotion = { + __tag = "OddPotion" + } + local DekuNut = { __tag = "DekuNut" } + local KokiriBoots = { + __tag = "KokiriBoots" + } + local PoeBottle = { + __tag = "PoeBottle" + } + local function _TypeRep(x) + return { + { + name = x.name .. "#" .. x.fingerprint + }, + __tag = "TypeRep" + } + end + local MagicBean = { + __tag = "MagicBean" + } + local OddMushroom = { + __tag = "OddMushroom" + } + local DekuStick = { + __tag = "DekuStick" + } + local BiggoronsSword = { + __tag = "BiggoronsSword" + } + local HalfMilkBottle = { + __tag = "HalfMilkBottle" + } + local function __eq_type_rep(tr_a, tr_b, keq, kne) + if tr_a[1].name == tr_b[1].name then + return keq()() + else + return kne() + end + end + local LensOfTruth = { + __tag = "LensOfTruth" + } + local Cojiro = { __tag = "Cojiro" } + local function Array(a) + return { __tag = "Array", a } + end + local MasterSword = { + __tag = "MasterSword" + } + local BigPoeBottle = { + __tag = "BigPoeBottle" + } + local function _Typeable_app(pair) + local ta, tb = pair._1[1], pair._2[1] + return { + { + name = "(" .. ta.name .. ") :$ (" .. tb.name .. ")" + }, + __tag = "TypeRep" + } + end + local Boomerang = { + __tag = "Boomerang" + } + local PocketCucco = { + __tag = "PocketCucco" + } + local KokiriSword = { + __tag = "KokiriSword" + } + local string_of_int = tostring + local function _dollarshow(htw) + local function loop(acc, x) + if x.__tag ~= "Cons" then + return acc .. "]" + end + local tmp = x[1] + local x0, xs = tmp._1, tmp._2 + if acc == "" then + return loop(htw(x0), xs) + end + return loop(acc .. ", " .. htw(x0), xs) + end + return function(x) + return "[" .. loop("", x) + end + end + local function _colon_colon(x) + return function(xs) + return { + { _1 = x, _2 = xs }, + __tag = "Cons" + } + end + end + local function _dollardExceptionlxh(tmp) + return { + from_exception = function(x) + return Some(x) + end, + ["Exception$lmq"] = _Typeable_app({ + _1 = (function(tmp0) + return _TypeRep({ + fingerprint = 271, + name = "some" + }) + end)(), + _2 = (function(tmp0) + return _TypeRep({ + fingerprint = 276, + name = "exception" + }) + end)() + }), + describe_exception = function(tmp0) + return tmp0[1].describe_exception(tmp0[2]) + end, + into_exception = function(x) + return x + end + } + end + local function from_exception(mqy, mtr) + local tmp = (function(tmp) + return _TypeRep({ + fingerprint = 304, + name = "user_error" + }) + end)() + local x = mtr[2] + return __eq_type_rep((function() + return mtr[1]["Exception$lmq"] + end)(Proxy), (function() + return tmp + end)(Proxy), function(tmp0) + return function(tmp1) return Some(x) end + end, function(tmp0) return None end) + end + local function from_exception0(mqy) + return function(mtr) + return from_exception(mqy, mtr) + end + end + local function _dollardExceptionmqb(tmp) + return { + describe_exception = function(tmp0) + return "User error: " .. tmp0 + end, + ["Exception$lmq"] = (function(tmp0) + return _TypeRep({ + fingerprint = 304, + name = "user_error" + }) + end)(), + into_exception = function(muh) + return MkSome(_dollardExceptionmqb(nil))(muh) + end, + from_exception = from_exception0(tmp) + } + end + local function from_exception1(npl, nse) + local x = nse[2] + local tmp = (function(tmp) + return _TypeRep({ + fingerprint = 314, + name = "invalid_arg" + }) + end)() + return __eq_type_rep((function() + return nse[1]["Exception$lmq"] + end)(Proxy), (function() + return tmp + end)(Proxy), function(tmp0) + return function(tmp1) return Some(x) end + end, function(tmp0) return None end) + end + local function from_exception2(npl) + return function(nse) + return from_exception1(npl, nse) + end + end + local function _dollardExceptionnoo(tmp) + return { + into_exception = function(nsu) + return MkSome(_dollardExceptionnoo(nil))(nsu) + end, + from_exception = from_exception2(tmp), + describe_exception = function(tmp0) + return "Invalid argument to function " .. tmp0 + end, + ["Exception$lmq"] = (function(tmp0) + return _TypeRep({ + fingerprint = 314, + name = "invalid_arg" + }) + end)() + } + end + local function _dollarfoldr(uxs) + return function(f) + return function(z) + local function loop(k, x) + if x.__tag ~= "Cons" then + return k(z) + end + local tmp = x[1] + local x0 = tmp._1 + return loop(function(r) + return k(f(x0)(r)) + end, tmp._2) + end + return function(x) + return loop(function(x0) + return x0 + end, x) + end + end + end + end + local _dollardFoldableuws, foldl1, foldl10 + _dollardFoldableuws = function(tmp) + return { + foldl1 = foldl1(tmp), + foldr = _dollarfoldr(tmp), + ["Foldable$ueq"] = function(f) + return function(xs) + local function biu(xss) + if xss.__tag ~= "Cons" then + return Nil + end + local tmp0 = xss[1] + return { + { _1 = f(tmp0._1), _2 = biu(tmp0._2) }, + __tag = "Cons" + } + end + return biu(xs) + end + end, + foldl = function(f) + local function loop(z) + return function(x) + if x.__tag ~= "Cons" then return z end + local tmp0 = x[1] + return loop(f(z)(tmp0._1))(tmp0._2) + end + end + return loop + end + } + end + foldl1 = function(uxs) + return function(vji) + return function(vjj) + return foldl10(uxs, vji, vjj) + end + end + end + foldl10 = function(uxs, vji, vjj) + local tmp = _dollardFoldableuws(nil).foldl(function(m) + return function(y) + if m.__tag == "None" then + return Some(y) + end + return Some(vji(m[1])(y)) + end + end)(None)(vjj) + if tmp.__tag == "None" then + return error(setmetatable(_dollardExceptionmqb(nil).into_exception("foldl1: empty structure"), { + __tostring = _dollardExceptionlxh(nil).describe_exception + })) + end + return tmp[1] + end + local io_stdout = io.stdout + local io_stderr = io.stderr + local io_stdin = io.stdin + local read_value_8 = ReadValue8 + local read_value_16 = ReadValue16 + local read_value_32 = ReadValue32 + local set_screen_text = SetScreenText + local tabulate = function(index, cont) + local r = {} + for i = 1 , index , 1 do + r[i] = cont(i) + end + return r + end + local geti = rawget + local function init(len, gen) + if not (len < 0) then + return Array({ + length = len, + backing = tabulate(len, function(i) + return gen(i - 1) + end) + }) + end + error(setmetatable(_dollardExceptionnoo(nil).into_exception("init: can't initialise array of size " .. string_of_int(len)), { + __tostring = _dollardExceptionlxh(nil).describe_exception + })) + return Array({ + length = len, + backing = tabulate(len, function(i) + return gen(i - 1) + end) + }) + end + local function _dollarfoldl(aptq) + return function(func) + return function(acc) + return function(tmp) + local tmp0 = tmp[1] + local backing, length = tmp0.backing, tmp0.length + local function loop(acc0, i) + if i > length then return acc0 end + return loop(func(acc0)(geti(backing, i)), i + 1) + end + return loop(acc, 1) + end + end + end + end + local function _dollarfoldr0(aptq) + return function(func) + return function(acc) + return function(tmp) + local tmp0 = tmp[1] + local backing = tmp0.backing + local function loop(acc0, i) + if i < 1 then return acc0 end + return loop(func(geti(backing, i))(acc0), i - 1) + end + return loop(acc, tmp0.length) + end + end + end + end + local _dollardFoldableapsn, foldl11, foldl12 + _dollardFoldableapsn = function(tmp) + return { + foldl1 = foldl11(tmp), + foldr = _dollarfoldr0(tmp), + foldl = _dollarfoldl(tmp), + ["Foldable$ueq"] = function(f) + return function(tmp0) + local tmp1 = tmp0[1] + local backing, length = tmp1.backing, tmp1.length + return Array({ + length = length, + backing = tabulate(length, function(i) + return f(geti(backing, i)) + end) + }) + end + end + } + end + foldl11 = function(aptq) + return function(aqhu) + return function(aqhv) + return foldl12(aptq, aqhu, aqhv) + end + end + end + foldl12 = function(aptq, aqhu, aqhv) + local tmp = _dollardFoldableapsn(nil).foldl(function(m) + return function(y) + if m.__tag == "None" then + return Some(y) + end + return Some(aqhu(m[1])(y)) + end + end)(None)(aqhv) + if tmp.__tag == "None" then + return error(setmetatable(_dollardExceptionmqb(nil).into_exception("foldl1: empty structure"), { + __tostring = _dollardExceptionlxh(nil).describe_exception + })) + end + return tmp[1] + end + local function pretty_from_record(ahma, a, w) + local function smul(s, n) + if n <= 0 then return "" end + return s .. smul(s, n - 1) + end + local prep = smul(" ", w) + local rf = ahma.fields(a) + local x = w + 2 + return ahma.name(a) .. " {\n" .. _dollardFoldableuws(nil).foldl(function(acc) + return function(f) + local name = f._1 + local field = f._2 + if field.__tag == "S" then + return acc .. prep .. " " .. (name .. " = " .. field[1](field[2])) .. ",\n" + end + return acc .. prep .. " " .. (name .. " = " .. field[1](field[2])(x)) .. ",\n" + end + end)("")(rf) .. prep .. "}" + end + local function pretty_from_record0(ahma) + return function(a) + return function(w) + return pretty_from_record(ahma, a, w) + end + end + end + local function _dollardecode(asjd, addr) + local tmp2 = init(24, function(i) + return read_value_8(addr + i) + end) + local tmp4 = init(16, function(i) + local u8 = read_value_8(addr + 24 + i) + if u8 > 255 then + return 0 - (256 - u8) + end + return u8 + end) + local tmp3 = read_value_16(addr + 40) + local tmp = read_value_32(addr + 44) + local tmp5 = read_value_32(addr + 48) + local tmp0 = init(20, function(i) + return read_value_8(addr + 52 + i) + end) + local tmp1 = init(19, function(i) + local u8 = read_value_8(addr + 72 + i) + if u8 > 255 then + return 0 - (256 - u8) + end + return u8 + end) + local u8 = read_value_8(addr + 91) + local function tmp6(tmp6) + local u16 = read_value_16(addr + 92) + if u16 > 65535 then + return { + items = tmp2, + ammo = tmp4, + equipment = tmp3, + upgrades = tmp, + quest_items = tmp5, + dungeon_items = tmp0, + dungeon_keys = tmp1, + defense_hearts = tmp6, + gs_tokens = 0 - (65536 - u16) + } + end + return { + items = tmp2, + ammo = tmp4, + equipment = tmp3, + upgrades = tmp, + quest_items = tmp5, + dungeon_items = tmp0, + dungeon_keys = tmp1, + defense_hearts = tmp6, + gs_tokens = u16 + } + end + if u8 > 255 then + return tmp6(0 - (256 - u8)) + end + return tmp6(u8) + end + local function _dollarfields(assv, tmp) + local function tmp0(tmp0) + return string_of_int(tmp0) .. "_u8" + end + local function tmp2(tmp2) + return string_of_int(tmp2) .. "_u8" + end + local function tmp3(tmp3) + return string_of_int(tmp3) .. "_s8" + end + local function tmp1(tmp1) + return string_of_int(tmp1) .. "_s8" + end + return { + { + _1 = { + _1 = "items", + _2 = S(function(arr) + return "to_list " .. _dollarshow(tmp0)(_dollardFoldableapsn(nil).foldr(_colon_colon)(Nil)(arr)) + end)(tmp.items) + }, + _2 = { + { + _2 = { + { + _1 = { + _1 = "equipment", + _2 = S(function(tmp2) + return string_of_int(tmp2) .. "_u16" + end)(tmp.equipment) + }, + _2 = { + { + _2 = { + { + _2 = { + { + _1 = { + _1 = "dungeon_items", + _2 = S(function(arr) + return "to_list " .. _dollarshow(tmp2)(_dollardFoldableapsn(nil).foldr(_colon_colon)(Nil)(arr)) + end)(tmp.dungeon_items) + }, + _2 = { + { + _1 = { + _1 = "dungeon_keys", + _2 = S(function(arr) + return "to_list " .. _dollarshow(tmp3)(_dollardFoldableapsn(nil).foldr(_colon_colon)(Nil)(arr)) + end)(tmp.dungeon_keys) + }, + _2 = { + { + _2 = { + { + _1 = { + _1 = "gs_tokens", + _2 = S(function(tmp4) + return string_of_int(tmp4) .. "_s16" + end)(tmp.gs_tokens) + }, + _2 = Nil + }, + __tag = "Cons" + }, + _1 = { + _1 = "defense_hearts", + _2 = S(function(tmp4) + return string_of_int(tmp4) .. "_s8" + end)(tmp.defense_hearts) + } + }, + __tag = "Cons" + } + }, + __tag = "Cons" + } + }, + __tag = "Cons" + }, + _1 = { + _1 = "quest_items", + _2 = S(function(tmp2) + return string_of_int(tmp2) .. "_u32" + end)(tmp.quest_items) + } + }, + __tag = "Cons" + }, + _1 = { + _1 = "upgrades", + _2 = S(function(tmp2) + return string_of_int(tmp2) .. "_u32" + end)(tmp.upgrades) + } + }, + __tag = "Cons" + } + }, + __tag = "Cons" + }, + _1 = { + _1 = "ammo", + _2 = S(function(arr) + return "to_list " .. _dollarshow(tmp1)(_dollardFoldableapsn(nil).foldr(_colon_colon)(Nil)(arr)) + end)(tmp.ammo) + } + }, + __tag = "Cons" + } + }, + __tag = "Cons" + } + end + local _dot_greater_greater_dot = function(a, b) return a >> b end + local _dot_amp_dot = function(a, b) return a & b end + local function _dollardecode0(allb, addr) + local code = read_value_16(addr) + local sword_index = _dot_amp_dot(_dot_greater_greater_dot(code, 0), 15) + local shield_index = _dot_amp_dot(_dot_greater_greater_dot(code, 4), 15) + local tunic_index = _dot_amp_dot(_dot_greater_greater_dot(code, 8), 15) + local boots_index = _dot_amp_dot(_dot_greater_greater_dot(code, 12), 15) + local function tmp(tmp) + local function tmp0(tmp0) + if tunic_index == 1 then + if boots_index == 1 then + return { + sword = tmp, + shield = tmp0, + tunic = KokiriTunic, + boots = KokiriBoots + } + elseif boots_index == 2 then + return { + sword = tmp, + shield = tmp0, + tunic = KokiriTunic, + boots = IronBoots + } + elseif boots_index == 3 then + return { + sword = tmp, + shield = tmp0, + tunic = KokiriTunic, + boots = HoverBoots + } + else + return { + sword = tmp, + shield = tmp0, + tunic = KokiriTunic, + boots = UnknownBoots(boots_index) + } + end + elseif tunic_index == 2 then + if boots_index == 1 then + return { + sword = tmp, + shield = tmp0, + tunic = GoronTunic, + boots = KokiriBoots + } + elseif boots_index == 2 then + return { + sword = tmp, + shield = tmp0, + tunic = GoronTunic, + boots = IronBoots + } + elseif boots_index == 3 then + return { + sword = tmp, + shield = tmp0, + tunic = GoronTunic, + boots = HoverBoots + } + else + return { + sword = tmp, + shield = tmp0, + tunic = GoronTunic, + boots = UnknownBoots(boots_index) + } + end + elseif tunic_index == 3 then + if boots_index == 1 then + return { + sword = tmp, + shield = tmp0, + tunic = ZoraTunic, + boots = KokiriBoots + } + elseif boots_index == 2 then + return { + sword = tmp, + shield = tmp0, + tunic = ZoraTunic, + boots = IronBoots + } + elseif boots_index == 3 then + return { + sword = tmp, + shield = tmp0, + tunic = ZoraTunic, + boots = HoverBoots + } + else + return { + sword = tmp, + shield = tmp0, + tunic = ZoraTunic, + boots = UnknownBoots(boots_index) + } + end + else + local tmp1 = UnknownTunic(tunic_index) + if boots_index == 1 then + return { + sword = tmp, + shield = tmp0, + tunic = tmp1, + boots = KokiriBoots + } + elseif boots_index == 2 then + return { + sword = tmp, + shield = tmp0, + tunic = tmp1, + boots = IronBoots + } + elseif boots_index == 3 then + return { + sword = tmp, + shield = tmp0, + tunic = tmp1, + boots = HoverBoots + } + else + return { + sword = tmp, + shield = tmp0, + tunic = tmp1, + boots = UnknownBoots(boots_index) + } + end + end + end + if shield_index == 0 then + return tmp0(NoShield) + elseif shield_index == 1 then + return tmp0(DekuShield) + elseif shield_index == 2 then + return tmp0(HylianShield) + elseif shield_index == 3 then + return tmp0(MirrorShield) + else + return error("Pattern matching failure in match expression at oot\\equipment.ml[41:25 ..45:19]") + end + end + if sword_index == 0 then + return tmp(NoSword) + elseif sword_index == 1 then + return tmp(KokiriSword) + elseif sword_index == 2 then + return tmp(MasterSword) + elseif sword_index == 3 then + return tmp(BiggoronsSword) + else + return error("Pattern matching failure in match expression at oot\\equipment.ml[21:24 ..25:21]") + end + end + local function _dollarfields0(alrp, tmp) + return { + { + _2 = { + { + _2 = { + { + _2 = { + { + _2 = Nil, + _1 = { + _1 = "boots", + _2 = S(function(x) + if x.__tag == "KokiriBoots" then + return "Kokiri Boots" + elseif x.__tag == "IronBoots" then + return "Iron Boots" + elseif x.__tag == "HoverBoots" then + return "Hover Boots" + elseif x.__tag == "UnknownBoots" then + return "Unknown Boots " .. string_of_int(x[1]) + end + end)(tmp.boots) + } + }, + __tag = "Cons" + }, + _1 = { + _1 = "tunic", + _2 = S(function(x) + if x.__tag == "GoronTunic" then + return "Goron Tunic" + elseif x.__tag == "ZoraTunic" then + return "Zora Tunic" + elseif x.__tag == "UnknownTunic" then + return "Unknown Tunic " .. string_of_int(x[1]) + elseif x.__tag == "KokiriTunic" then + return "Kokiri Tunic" + end + end)(tmp.tunic) + } + }, + __tag = "Cons" + }, + _1 = { + _1 = "shield", + _2 = S(function(x) + if x.__tag == "MirrorShield" then + return "Mirror Shield" + elseif x.__tag == "NoShield" then + return "No Shield" + elseif x.__tag == "DekuShield" then + return "Deku Shield" + elseif x.__tag == "HylianShield" then + return "Hylian Shield" + end + end)(tmp.shield) + } + }, + __tag = "Cons" + }, + _1 = { + _1 = "sword", + _2 = S(function(x) + if x.__tag == "KokiriSword" then + return "Kokiri Sword" + elseif x.__tag == "MasterSword" then + return "Master Sword" + elseif x.__tag == "BiggoronsSword" then + return "Biggoron's Sword" + elseif x.__tag == "NoSword" then + return "No Sword" + end + end)(tmp.sword) + } + }, + __tag = "Cons" + } + end + local function _dollardShowakjw(tmp) + return function(x) + if x.__tag == "PocketCucco" then + return "Pocket Cucco" + elseif x.__tag == "Boomerang" then + return "Boomerang" + elseif x.__tag == "BigPoeBottle" then + return "Big Poe" + elseif x.__tag == "Cojiro" then + return "Cojiro" + elseif x.__tag == "LensOfTruth" then + return "Lens of Truth" + elseif x.__tag == "HalfMilkBottle" then + return "Half Lon Lon Milk" + elseif x.__tag == "DekuStick" then + return "Deku Stick" + elseif x.__tag == "OddMushroom" then + return "Odd Mushroom" + elseif x.__tag == "MagicBean" then + return "Magic Bean" + elseif x.__tag == "PoeBottle" then + return "Poe" + elseif x.__tag == "DekuNut" then + return "Deku Nut" + elseif x.__tag == "OddPotion" then + return "Odd Potion" + elseif x.__tag == "MegatonHammer" then + return "Megaton Hammer" + elseif x.__tag == "WeirdEgg" then + return "Weird Egg" + elseif x.__tag == "GerudoMask" then + return "Gerudo Mask" + elseif x.__tag == "FairyBowAndLightArrow" then + return "Fairy Bow & Light Arrow" + elseif x.__tag == "Hookshot" then + return "Hookshot" + elseif x.__tag == "FullMilkBottle" then + return "Lon Lon Milk" + elseif x.__tag == "MaskOfTruth" then + return "Mask of Truth" + elseif x.__tag == "KokiriSword0" then + return "Kokiri Sword" + elseif x.__tag == "Longshot" then + return "Longshot" + elseif x.__tag == "RutosLetterBottle" then + return "Ruto's Letter" + elseif x.__tag == "SoldOut" then + return "SOLD OUT" + elseif x.__tag == "MasterSword0" then + return "Master Sword" + elseif x.__tag == "IceArrow" then + return "Ice Arrow" + elseif x.__tag == "BlueFireBottle" then + return "Blue Fire" + elseif x.__tag == "PocketEgg" then + return "Pocket Egg" + elseif x.__tag == "GoronsSword" then + return "Giant's Knife & Biggoron's Sword" + elseif x.__tag == "FaroresWind" then + return "Farore's Wind" + elseif x.__tag == "BugBottle" then + return "Bug" + elseif x.__tag == "SpookyMask" then + return "Spooky Mask" + elseif x.__tag == "EyeDrops" then + return "Eye Drops" + elseif x.__tag == "FairySlingshot" then + return "Fairy Slingshot" + elseif x.__tag == "GreenPotionBottle" then + return "Green Potion" + elseif x.__tag == "BunnyHood" then + return "Bunny Hood" + elseif x.__tag == "ClaimCheck" then + return "Claim Check" + elseif x.__tag == "FairyOcarina" then + return "Fairy Ocarina" + elseif x.__tag == "BluePotionBottle" then + return "Blue Potion" + elseif x.__tag == "GoronMask" then + return "Goron Mask" + elseif x.__tag == "FairyBowAndFireArrow" then + return "Fairy Bow & Fire Arrow" + elseif x.__tag == "OcarinaOfTime" then + return "Ocarina of Time" + elseif x.__tag == "FairyBottle" then + return "Bottled Fairy" + elseif x.__tag == "ZoraMask" then + return "Zora Mask" + elseif x.__tag == "FairyBowAndIceArrow" then + return "Fairy Bow & Ice Arrow" + elseif x.__tag == "Bombchu_10" then + return "Bombchu (10)" + elseif x.__tag == "FishBottle" then + return "Fish" + elseif x.__tag == "Chicken" then + return "Chicken" + elseif x.__tag == "PoachersSaw" then + return "Poacher's Saw" + elseif x.__tag == "Bomb" then + return "Bomb" + elseif x.__tag == "LightArrow" then + return "Light Arrow" + elseif x.__tag == "ZeldasLetter" then + return "Zelda's Letter" + elseif x.__tag == "BrokenGoronsSword" then + return "Broken Giant's Knife" + elseif x.__tag == "FairyBow" then + return "Fairy Bow" + elseif x.__tag == "NayrusLove" then + return "Nayru's Love" + elseif x.__tag == "UnknownItem" then + return "Unknown Item " .. string_of_int(x[1]) + elseif x.__tag == "KeatonMask" then + return "Keaton Mask" + elseif x.__tag == "Prescription" then + return "Prescription" + elseif x.__tag == "FireArrow" then + return "Fire Arrow" + elseif x.__tag == "EmptyBottle" then + return "Empty Bottle" + elseif x.__tag == "NoItem" then + return "No Item" + elseif x.__tag == "SkullMask" then + return "Skull Mask" + elseif x.__tag == "EyeballFrog" then + return "Eyeball Frog" + elseif x.__tag == "DinsFire" then + return "Din's Fire" + elseif x.__tag == "RedPotionBottle" then + return "Red Potion" + else + return error("Pattern matching failure in match expression at oot\\item.ml[232:14 ..296:53]") + end + end + end + local function _dollardecode1(alyz, addr) + local code = read_value_8(addr) + local function tmp(tmp) + local code = read_value_8(addr + 1) + local function tmp0(tmp0) + local code = read_value_8(addr + 2) + local function tmp1(tmp1) + local code = read_value_8(addr + 3) + if code == 0 then + return { + button_slot_c_left = read_value_8(addr + 4), + button_slot_c_down = read_value_8(addr + 5), + button_slot_c_right = read_value_8(addr + 6), + equipment = _dollardecode0(nil, addr + 8), + button_item_b = tmp, + button_item_c_left = tmp0, + button_item_c_down = tmp1, + button_item_c_right = DekuStick + } + elseif code == 1 then + return { + button_slot_c_left = read_value_8(addr + 4), + button_slot_c_down = read_value_8(addr + 5), + button_slot_c_right = read_value_8(addr + 6), + equipment = _dollardecode0(nil, addr + 8), + button_item_b = tmp, + button_item_c_left = tmp0, + button_item_c_down = tmp1, + button_item_c_right = DekuNut + } + elseif code == 2 then + return { + button_slot_c_left = read_value_8(addr + 4), + button_slot_c_down = read_value_8(addr + 5), + button_slot_c_right = read_value_8(addr + 6), + equipment = _dollardecode0(nil, addr + 8), + button_item_b = tmp, + button_item_c_left = tmp0, + button_item_c_down = tmp1, + button_item_c_right = Bomb + } + elseif code == 3 then + return { + button_slot_c_left = read_value_8(addr + 4), + button_slot_c_down = read_value_8(addr + 5), + button_slot_c_right = read_value_8(addr + 6), + equipment = _dollardecode0(nil, addr + 8), + button_item_b = tmp, + button_item_c_left = tmp0, + button_item_c_down = tmp1, + button_item_c_right = FairyBow + } + elseif code == 4 then + return { + button_slot_c_left = read_value_8(addr + 4), + button_slot_c_down = read_value_8(addr + 5), + button_slot_c_right = read_value_8(addr + 6), + equipment = _dollardecode0(nil, addr + 8), + button_item_b = tmp, + button_item_c_left = tmp0, + button_item_c_down = tmp1, + button_item_c_right = FireArrow + } + elseif code == 5 then + return { + button_slot_c_left = read_value_8(addr + 4), + button_slot_c_down = read_value_8(addr + 5), + button_slot_c_right = read_value_8(addr + 6), + equipment = _dollardecode0(nil, addr + 8), + button_item_b = tmp, + button_item_c_left = tmp0, + button_item_c_down = tmp1, + button_item_c_right = DinsFire + } + elseif code == 6 then + return { + button_slot_c_left = read_value_8(addr + 4), + button_slot_c_down = read_value_8(addr + 5), + button_slot_c_right = read_value_8(addr + 6), + equipment = _dollardecode0(nil, addr + 8), + button_item_b = tmp, + button_item_c_left = tmp0, + button_item_c_down = tmp1, + button_item_c_right = FairySlingshot + } + elseif code == 7 then + return { + button_slot_c_left = read_value_8(addr + 4), + button_slot_c_down = read_value_8(addr + 5), + button_slot_c_right = read_value_8(addr + 6), + equipment = _dollardecode0(nil, addr + 8), + button_item_b = tmp, + button_item_c_left = tmp0, + button_item_c_down = tmp1, + button_item_c_right = FairyOcarina + } + elseif code == 8 then + return { + button_slot_c_left = read_value_8(addr + 4), + button_slot_c_down = read_value_8(addr + 5), + button_slot_c_right = read_value_8(addr + 6), + equipment = _dollardecode0(nil, addr + 8), + button_item_b = tmp, + button_item_c_left = tmp0, + button_item_c_down = tmp1, + button_item_c_right = OcarinaOfTime + } + elseif code == 9 then + return { + button_slot_c_left = read_value_8(addr + 4), + button_slot_c_down = read_value_8(addr + 5), + button_slot_c_right = read_value_8(addr + 6), + equipment = _dollardecode0(nil, addr + 8), + button_item_b = tmp, + button_item_c_left = tmp0, + button_item_c_down = tmp1, + button_item_c_right = Bombchu_10 + } + elseif code == 10 then + return { + button_slot_c_left = read_value_8(addr + 4), + button_slot_c_down = read_value_8(addr + 5), + button_slot_c_right = read_value_8(addr + 6), + equipment = _dollardecode0(nil, addr + 8), + button_item_b = tmp, + button_item_c_left = tmp0, + button_item_c_down = tmp1, + button_item_c_right = Hookshot + } + elseif code == 11 then + return { + button_slot_c_left = read_value_8(addr + 4), + button_slot_c_down = read_value_8(addr + 5), + button_slot_c_right = read_value_8(addr + 6), + equipment = _dollardecode0(nil, addr + 8), + button_item_b = tmp, + button_item_c_left = tmp0, + button_item_c_down = tmp1, + button_item_c_right = Longshot + } + elseif code == 12 then + return { + button_slot_c_left = read_value_8(addr + 4), + button_slot_c_down = read_value_8(addr + 5), + button_slot_c_right = read_value_8(addr + 6), + equipment = _dollardecode0(nil, addr + 8), + button_item_b = tmp, + button_item_c_left = tmp0, + button_item_c_down = tmp1, + button_item_c_right = IceArrow + } + elseif code == 13 then + return { + button_slot_c_left = read_value_8(addr + 4), + button_slot_c_down = read_value_8(addr + 5), + button_slot_c_right = read_value_8(addr + 6), + equipment = _dollardecode0(nil, addr + 8), + button_item_b = tmp, + button_item_c_left = tmp0, + button_item_c_down = tmp1, + button_item_c_right = FaroresWind + } + elseif code == 14 then + return { + button_slot_c_left = read_value_8(addr + 4), + button_slot_c_down = read_value_8(addr + 5), + button_slot_c_right = read_value_8(addr + 6), + equipment = _dollardecode0(nil, addr + 8), + button_item_b = tmp, + button_item_c_left = tmp0, + button_item_c_down = tmp1, + button_item_c_right = Boomerang + } + elseif code == 15 then + return { + button_slot_c_left = read_value_8(addr + 4), + button_slot_c_down = read_value_8(addr + 5), + button_slot_c_right = read_value_8(addr + 6), + equipment = _dollardecode0(nil, addr + 8), + button_item_b = tmp, + button_item_c_left = tmp0, + button_item_c_down = tmp1, + button_item_c_right = LensOfTruth + } + elseif code == 16 then + return { + button_slot_c_left = read_value_8(addr + 4), + button_slot_c_down = read_value_8(addr + 5), + button_slot_c_right = read_value_8(addr + 6), + equipment = _dollardecode0(nil, addr + 8), + button_item_b = tmp, + button_item_c_left = tmp0, + button_item_c_down = tmp1, + button_item_c_right = MagicBean + } + elseif code == 17 then + return { + button_slot_c_left = read_value_8(addr + 4), + button_slot_c_down = read_value_8(addr + 5), + button_slot_c_right = read_value_8(addr + 6), + equipment = _dollardecode0(nil, addr + 8), + button_item_b = tmp, + button_item_c_left = tmp0, + button_item_c_down = tmp1, + button_item_c_right = MegatonHammer + } + elseif code == 18 then + return { + button_slot_c_left = read_value_8(addr + 4), + button_slot_c_down = read_value_8(addr + 5), + button_slot_c_right = read_value_8(addr + 6), + equipment = _dollardecode0(nil, addr + 8), + button_item_b = tmp, + button_item_c_left = tmp0, + button_item_c_down = tmp1, + button_item_c_right = LightArrow + } + elseif code == 19 then + return { + button_slot_c_left = read_value_8(addr + 4), + button_slot_c_down = read_value_8(addr + 5), + button_slot_c_right = read_value_8(addr + 6), + equipment = _dollardecode0(nil, addr + 8), + button_item_b = tmp, + button_item_c_left = tmp0, + button_item_c_down = tmp1, + button_item_c_right = NayrusLove + } + elseif code == 20 then + return { + button_slot_c_left = read_value_8(addr + 4), + button_slot_c_down = read_value_8(addr + 5), + button_slot_c_right = read_value_8(addr + 6), + equipment = _dollardecode0(nil, addr + 8), + button_item_b = tmp, + button_item_c_left = tmp0, + button_item_c_down = tmp1, + button_item_c_right = EmptyBottle + } + elseif code == 21 then + return { + button_slot_c_left = read_value_8(addr + 4), + button_slot_c_down = read_value_8(addr + 5), + button_slot_c_right = read_value_8(addr + 6), + equipment = _dollardecode0(nil, addr + 8), + button_item_b = tmp, + button_item_c_left = tmp0, + button_item_c_down = tmp1, + button_item_c_right = RedPotionBottle + } + elseif code == 22 then + return { + button_slot_c_left = read_value_8(addr + 4), + button_slot_c_down = read_value_8(addr + 5), + button_slot_c_right = read_value_8(addr + 6), + equipment = _dollardecode0(nil, addr + 8), + button_item_b = tmp, + button_item_c_left = tmp0, + button_item_c_down = tmp1, + button_item_c_right = GreenPotionBottle + } + elseif code == 23 then + return { + button_slot_c_left = read_value_8(addr + 4), + button_slot_c_down = read_value_8(addr + 5), + button_slot_c_right = read_value_8(addr + 6), + equipment = _dollardecode0(nil, addr + 8), + button_item_b = tmp, + button_item_c_left = tmp0, + button_item_c_down = tmp1, + button_item_c_right = BluePotionBottle + } + elseif code == 24 then + return { + button_slot_c_left = read_value_8(addr + 4), + button_slot_c_down = read_value_8(addr + 5), + button_slot_c_right = read_value_8(addr + 6), + equipment = _dollardecode0(nil, addr + 8), + button_item_b = tmp, + button_item_c_left = tmp0, + button_item_c_down = tmp1, + button_item_c_right = FairyBottle + } + elseif code == 25 then + return { + button_slot_c_left = read_value_8(addr + 4), + button_slot_c_down = read_value_8(addr + 5), + button_slot_c_right = read_value_8(addr + 6), + equipment = _dollardecode0(nil, addr + 8), + button_item_b = tmp, + button_item_c_left = tmp0, + button_item_c_down = tmp1, + button_item_c_right = FishBottle + } + elseif code == 26 then + return { + button_slot_c_left = read_value_8(addr + 4), + button_slot_c_down = read_value_8(addr + 5), + button_slot_c_right = read_value_8(addr + 6), + equipment = _dollardecode0(nil, addr + 8), + button_item_b = tmp, + button_item_c_left = tmp0, + button_item_c_down = tmp1, + button_item_c_right = FullMilkBottle + } + elseif code == 27 then + return { + button_slot_c_left = read_value_8(addr + 4), + button_slot_c_down = read_value_8(addr + 5), + button_slot_c_right = read_value_8(addr + 6), + equipment = _dollardecode0(nil, addr + 8), + button_item_b = tmp, + button_item_c_left = tmp0, + button_item_c_down = tmp1, + button_item_c_right = RutosLetterBottle + } + elseif code == 28 then + return { + button_slot_c_left = read_value_8(addr + 4), + button_slot_c_down = read_value_8(addr + 5), + button_slot_c_right = read_value_8(addr + 6), + equipment = _dollardecode0(nil, addr + 8), + button_item_b = tmp, + button_item_c_left = tmp0, + button_item_c_down = tmp1, + button_item_c_right = BlueFireBottle + } + elseif code == 29 then + return { + button_slot_c_left = read_value_8(addr + 4), + button_slot_c_down = read_value_8(addr + 5), + button_slot_c_right = read_value_8(addr + 6), + equipment = _dollardecode0(nil, addr + 8), + button_item_b = tmp, + button_item_c_left = tmp0, + button_item_c_down = tmp1, + button_item_c_right = BugBottle + } + elseif code == 30 then + return { + button_slot_c_left = read_value_8(addr + 4), + button_slot_c_down = read_value_8(addr + 5), + button_slot_c_right = read_value_8(addr + 6), + equipment = _dollardecode0(nil, addr + 8), + button_item_b = tmp, + button_item_c_left = tmp0, + button_item_c_down = tmp1, + button_item_c_right = BigPoeBottle + } + elseif code == 31 then + return { + button_slot_c_left = read_value_8(addr + 4), + button_slot_c_down = read_value_8(addr + 5), + button_slot_c_right = read_value_8(addr + 6), + equipment = _dollardecode0(nil, addr + 8), + button_item_b = tmp, + button_item_c_left = tmp0, + button_item_c_down = tmp1, + button_item_c_right = HalfMilkBottle + } + elseif code == 32 then + return { + button_slot_c_left = read_value_8(addr + 4), + button_slot_c_down = read_value_8(addr + 5), + button_slot_c_right = read_value_8(addr + 6), + equipment = _dollardecode0(nil, addr + 8), + button_item_b = tmp, + button_item_c_left = tmp0, + button_item_c_down = tmp1, + button_item_c_right = PoeBottle + } + elseif code == 33 then + return { + button_slot_c_left = read_value_8(addr + 4), + button_slot_c_down = read_value_8(addr + 5), + button_slot_c_right = read_value_8(addr + 6), + equipment = _dollardecode0(nil, addr + 8), + button_item_b = tmp, + button_item_c_left = tmp0, + button_item_c_down = tmp1, + button_item_c_right = WeirdEgg + } + elseif code == 34 then + return { + button_slot_c_left = read_value_8(addr + 4), + button_slot_c_down = read_value_8(addr + 5), + button_slot_c_right = read_value_8(addr + 6), + equipment = _dollardecode0(nil, addr + 8), + button_item_b = tmp, + button_item_c_left = tmp0, + button_item_c_down = tmp1, + button_item_c_right = Chicken + } + elseif code == 35 then + return { + button_slot_c_left = read_value_8(addr + 4), + button_slot_c_down = read_value_8(addr + 5), + button_slot_c_right = read_value_8(addr + 6), + equipment = _dollardecode0(nil, addr + 8), + button_item_b = tmp, + button_item_c_left = tmp0, + button_item_c_down = tmp1, + button_item_c_right = ZeldasLetter + } + elseif code == 36 then + return { + button_slot_c_left = read_value_8(addr + 4), + button_slot_c_down = read_value_8(addr + 5), + button_slot_c_right = read_value_8(addr + 6), + equipment = _dollardecode0(nil, addr + 8), + button_item_b = tmp, + button_item_c_left = tmp0, + button_item_c_down = tmp1, + button_item_c_right = KeatonMask + } + elseif code == 37 then + return { + button_slot_c_left = read_value_8(addr + 4), + button_slot_c_down = read_value_8(addr + 5), + button_slot_c_right = read_value_8(addr + 6), + equipment = _dollardecode0(nil, addr + 8), + button_item_b = tmp, + button_item_c_left = tmp0, + button_item_c_down = tmp1, + button_item_c_right = SkullMask + } + elseif code == 38 then + return { + button_slot_c_left = read_value_8(addr + 4), + button_slot_c_down = read_value_8(addr + 5), + button_slot_c_right = read_value_8(addr + 6), + equipment = _dollardecode0(nil, addr + 8), + button_item_b = tmp, + button_item_c_left = tmp0, + button_item_c_down = tmp1, + button_item_c_right = SpookyMask + } + elseif code == 39 then + return { + button_slot_c_left = read_value_8(addr + 4), + button_slot_c_down = read_value_8(addr + 5), + button_slot_c_right = read_value_8(addr + 6), + equipment = _dollardecode0(nil, addr + 8), + button_item_b = tmp, + button_item_c_left = tmp0, + button_item_c_down = tmp1, + button_item_c_right = BunnyHood + } + elseif code == 40 then + return { + button_slot_c_left = read_value_8(addr + 4), + button_slot_c_down = read_value_8(addr + 5), + button_slot_c_right = read_value_8(addr + 6), + equipment = _dollardecode0(nil, addr + 8), + button_item_b = tmp, + button_item_c_left = tmp0, + button_item_c_down = tmp1, + button_item_c_right = GoronMask + } + elseif code == 41 then + return { + button_slot_c_left = read_value_8(addr + 4), + button_slot_c_down = read_value_8(addr + 5), + button_slot_c_right = read_value_8(addr + 6), + equipment = _dollardecode0(nil, addr + 8), + button_item_b = tmp, + button_item_c_left = tmp0, + button_item_c_down = tmp1, + button_item_c_right = ZoraMask + } + elseif code == 42 then + return { + button_slot_c_left = read_value_8(addr + 4), + button_slot_c_down = read_value_8(addr + 5), + button_slot_c_right = read_value_8(addr + 6), + equipment = _dollardecode0(nil, addr + 8), + button_item_b = tmp, + button_item_c_left = tmp0, + button_item_c_down = tmp1, + button_item_c_right = GerudoMask + } + elseif code == 43 then + return { + button_slot_c_left = read_value_8(addr + 4), + button_slot_c_down = read_value_8(addr + 5), + button_slot_c_right = read_value_8(addr + 6), + equipment = _dollardecode0(nil, addr + 8), + button_item_b = tmp, + button_item_c_left = tmp0, + button_item_c_down = tmp1, + button_item_c_right = MaskOfTruth + } + elseif code == 44 then + return { + button_slot_c_left = read_value_8(addr + 4), + button_slot_c_down = read_value_8(addr + 5), + button_slot_c_right = read_value_8(addr + 6), + equipment = _dollardecode0(nil, addr + 8), + button_item_b = tmp, + button_item_c_left = tmp0, + button_item_c_down = tmp1, + button_item_c_right = SoldOut + } + elseif code == 45 then + return { + button_slot_c_left = read_value_8(addr + 4), + button_slot_c_down = read_value_8(addr + 5), + button_slot_c_right = read_value_8(addr + 6), + equipment = _dollardecode0(nil, addr + 8), + button_item_b = tmp, + button_item_c_left = tmp0, + button_item_c_down = tmp1, + button_item_c_right = PocketEgg + } + elseif code == 46 then + return { + button_slot_c_left = read_value_8(addr + 4), + button_slot_c_down = read_value_8(addr + 5), + button_slot_c_right = read_value_8(addr + 6), + equipment = _dollardecode0(nil, addr + 8), + button_item_b = tmp, + button_item_c_left = tmp0, + button_item_c_down = tmp1, + button_item_c_right = PocketCucco + } + elseif code == 47 then + return { + button_slot_c_left = read_value_8(addr + 4), + button_slot_c_down = read_value_8(addr + 5), + button_slot_c_right = read_value_8(addr + 6), + equipment = _dollardecode0(nil, addr + 8), + button_item_b = tmp, + button_item_c_left = tmp0, + button_item_c_down = tmp1, + button_item_c_right = Cojiro + } + elseif code == 48 then + return { + button_slot_c_left = read_value_8(addr + 4), + button_slot_c_down = read_value_8(addr + 5), + button_slot_c_right = read_value_8(addr + 6), + equipment = _dollardecode0(nil, addr + 8), + button_item_b = tmp, + button_item_c_left = tmp0, + button_item_c_down = tmp1, + button_item_c_right = OddMushroom + } + elseif code == 49 then + return { + button_slot_c_left = read_value_8(addr + 4), + button_slot_c_down = read_value_8(addr + 5), + button_slot_c_right = read_value_8(addr + 6), + equipment = _dollardecode0(nil, addr + 8), + button_item_b = tmp, + button_item_c_left = tmp0, + button_item_c_down = tmp1, + button_item_c_right = OddPotion + } + elseif code == 50 then + return { + button_slot_c_left = read_value_8(addr + 4), + button_slot_c_down = read_value_8(addr + 5), + button_slot_c_right = read_value_8(addr + 6), + equipment = _dollardecode0(nil, addr + 8), + button_item_b = tmp, + button_item_c_left = tmp0, + button_item_c_down = tmp1, + button_item_c_right = PoachersSaw + } + elseif code == 51 then + return { + button_slot_c_left = read_value_8(addr + 4), + button_slot_c_down = read_value_8(addr + 5), + button_slot_c_right = read_value_8(addr + 6), + equipment = _dollardecode0(nil, addr + 8), + button_item_b = tmp, + button_item_c_left = tmp0, + button_item_c_down = tmp1, + button_item_c_right = BrokenGoronsSword + } + elseif code == 52 then + return { + button_slot_c_left = read_value_8(addr + 4), + button_slot_c_down = read_value_8(addr + 5), + button_slot_c_right = read_value_8(addr + 6), + equipment = _dollardecode0(nil, addr + 8), + button_item_b = tmp, + button_item_c_left = tmp0, + button_item_c_down = tmp1, + button_item_c_right = Prescription + } + elseif code == 53 then + return { + button_slot_c_left = read_value_8(addr + 4), + button_slot_c_down = read_value_8(addr + 5), + button_slot_c_right = read_value_8(addr + 6), + equipment = _dollardecode0(nil, addr + 8), + button_item_b = tmp, + button_item_c_left = tmp0, + button_item_c_down = tmp1, + button_item_c_right = EyeballFrog + } + elseif code == 54 then + return { + button_slot_c_left = read_value_8(addr + 4), + button_slot_c_down = read_value_8(addr + 5), + button_slot_c_right = read_value_8(addr + 6), + equipment = _dollardecode0(nil, addr + 8), + button_item_b = tmp, + button_item_c_left = tmp0, + button_item_c_down = tmp1, + button_item_c_right = EyeDrops + } + elseif code == 55 then + return { + button_slot_c_left = read_value_8(addr + 4), + button_slot_c_down = read_value_8(addr + 5), + button_slot_c_right = read_value_8(addr + 6), + equipment = _dollardecode0(nil, addr + 8), + button_item_b = tmp, + button_item_c_left = tmp0, + button_item_c_down = tmp1, + button_item_c_right = ClaimCheck + } + elseif code == 56 then + return { + button_slot_c_left = read_value_8(addr + 4), + button_slot_c_down = read_value_8(addr + 5), + button_slot_c_right = read_value_8(addr + 6), + equipment = _dollardecode0(nil, addr + 8), + button_item_b = tmp, + button_item_c_left = tmp0, + button_item_c_down = tmp1, + button_item_c_right = FairyBowAndFireArrow + } + elseif code == 57 then + return { + button_slot_c_left = read_value_8(addr + 4), + button_slot_c_down = read_value_8(addr + 5), + button_slot_c_right = read_value_8(addr + 6), + equipment = _dollardecode0(nil, addr + 8), + button_item_b = tmp, + button_item_c_left = tmp0, + button_item_c_down = tmp1, + button_item_c_right = FairyBowAndIceArrow + } + elseif code == 58 then + return { + button_slot_c_left = read_value_8(addr + 4), + button_slot_c_down = read_value_8(addr + 5), + button_slot_c_right = read_value_8(addr + 6), + equipment = _dollardecode0(nil, addr + 8), + button_item_b = tmp, + button_item_c_left = tmp0, + button_item_c_down = tmp1, + button_item_c_right = FairyBowAndLightArrow + } + elseif code == 59 then + return { + button_slot_c_left = read_value_8(addr + 4), + button_slot_c_down = read_value_8(addr + 5), + button_slot_c_right = read_value_8(addr + 6), + equipment = _dollardecode0(nil, addr + 8), + button_item_b = tmp, + button_item_c_left = tmp0, + button_item_c_down = tmp1, + button_item_c_right = KokiriSword0 + } + elseif code == 60 then + return { + button_slot_c_left = read_value_8(addr + 4), + button_slot_c_down = read_value_8(addr + 5), + button_slot_c_right = read_value_8(addr + 6), + equipment = _dollardecode0(nil, addr + 8), + button_item_b = tmp, + button_item_c_left = tmp0, + button_item_c_down = tmp1, + button_item_c_right = MasterSword0 + } + elseif code == 61 then + return { + button_slot_c_left = read_value_8(addr + 4), + button_slot_c_down = read_value_8(addr + 5), + button_slot_c_right = read_value_8(addr + 6), + equipment = _dollardecode0(nil, addr + 8), + button_item_b = tmp, + button_item_c_left = tmp0, + button_item_c_down = tmp1, + button_item_c_right = GoronsSword + } + elseif code == 255 then + return { + button_slot_c_left = read_value_8(addr + 4), + button_slot_c_down = read_value_8(addr + 5), + button_slot_c_right = read_value_8(addr + 6), + equipment = _dollardecode0(nil, addr + 8), + button_item_b = tmp, + button_item_c_left = tmp0, + button_item_c_down = tmp1, + button_item_c_right = NoItem + } + else + return { + button_slot_c_left = read_value_8(addr + 4), + button_slot_c_down = read_value_8(addr + 5), + button_slot_c_right = read_value_8(addr + 6), + equipment = _dollardecode0(nil, addr + 8), + button_item_c_right = UnknownItem(code), + button_item_b = tmp, + button_item_c_left = tmp0, + button_item_c_down = tmp1 + } + end + end + if code == 0 then + return tmp1(DekuStick) + elseif code == 1 then + return tmp1(DekuNut) + elseif code == 2 then + return tmp1(Bomb) + elseif code == 3 then + return tmp1(FairyBow) + elseif code == 4 then + return tmp1(FireArrow) + elseif code == 5 then + return tmp1(DinsFire) + elseif code == 6 then + return tmp1(FairySlingshot) + elseif code == 7 then + return tmp1(FairyOcarina) + elseif code == 8 then + return tmp1(OcarinaOfTime) + elseif code == 9 then + return tmp1(Bombchu_10) + elseif code == 10 then + return tmp1(Hookshot) + elseif code == 11 then + return tmp1(Longshot) + elseif code == 12 then + return tmp1(IceArrow) + elseif code == 13 then + return tmp1(FaroresWind) + elseif code == 14 then + return tmp1(Boomerang) + elseif code == 15 then + return tmp1(LensOfTruth) + elseif code == 16 then + return tmp1(MagicBean) + elseif code == 17 then + return tmp1(MegatonHammer) + elseif code == 18 then + return tmp1(LightArrow) + elseif code == 19 then + return tmp1(NayrusLove) + elseif code == 20 then + return tmp1(EmptyBottle) + elseif code == 21 then + return tmp1(RedPotionBottle) + elseif code == 22 then + return tmp1(GreenPotionBottle) + elseif code == 23 then + return tmp1(BluePotionBottle) + elseif code == 24 then + return tmp1(FairyBottle) + elseif code == 25 then + return tmp1(FishBottle) + elseif code == 26 then + return tmp1(FullMilkBottle) + elseif code == 27 then + return tmp1(RutosLetterBottle) + elseif code == 28 then + return tmp1(BlueFireBottle) + elseif code == 29 then + return tmp1(BugBottle) + elseif code == 30 then + return tmp1(BigPoeBottle) + elseif code == 31 then + return tmp1(HalfMilkBottle) + elseif code == 32 then + return tmp1(PoeBottle) + elseif code == 33 then + return tmp1(WeirdEgg) + elseif code == 34 then + return tmp1(Chicken) + elseif code == 35 then + return tmp1(ZeldasLetter) + elseif code == 36 then + return tmp1(KeatonMask) + elseif code == 37 then + return tmp1(SkullMask) + elseif code == 38 then + return tmp1(SpookyMask) + elseif code == 39 then + return tmp1(BunnyHood) + elseif code == 40 then + return tmp1(GoronMask) + elseif code == 41 then + return tmp1(ZoraMask) + elseif code == 42 then + return tmp1(GerudoMask) + elseif code == 43 then + return tmp1(MaskOfTruth) + elseif code == 44 then + return tmp1(SoldOut) + elseif code == 45 then + return tmp1(PocketEgg) + elseif code == 46 then + return tmp1(PocketCucco) + elseif code == 47 then + return tmp1(Cojiro) + elseif code == 48 then + return tmp1(OddMushroom) + elseif code == 49 then + return tmp1(OddPotion) + elseif code == 50 then + return tmp1(PoachersSaw) + elseif code == 51 then + return tmp1(BrokenGoronsSword) + elseif code == 52 then + return tmp1(Prescription) + elseif code == 53 then + return tmp1(EyeballFrog) + elseif code == 54 then + return tmp1(EyeDrops) + elseif code == 55 then + return tmp1(ClaimCheck) + elseif code == 56 then + return tmp1(FairyBowAndFireArrow) + elseif code == 57 then + return tmp1(FairyBowAndIceArrow) + elseif code == 58 then + return tmp1(FairyBowAndLightArrow) + elseif code == 59 then + return tmp1(KokiriSword0) + elseif code == 60 then + return tmp1(MasterSword0) + elseif code == 61 then + return tmp1(GoronsSword) + elseif code == 255 then + return tmp1(NoItem) + else + return tmp1(UnknownItem(code)) + end + end + if code == 0 then + return tmp0(DekuStick) + elseif code == 1 then + return tmp0(DekuNut) + elseif code == 2 then + return tmp0(Bomb) + elseif code == 3 then + return tmp0(FairyBow) + elseif code == 4 then + return tmp0(FireArrow) + elseif code == 5 then + return tmp0(DinsFire) + elseif code == 6 then + return tmp0(FairySlingshot) + elseif code == 7 then + return tmp0(FairyOcarina) + elseif code == 8 then + return tmp0(OcarinaOfTime) + elseif code == 9 then + return tmp0(Bombchu_10) + elseif code == 10 then + return tmp0(Hookshot) + elseif code == 11 then + return tmp0(Longshot) + elseif code == 12 then + return tmp0(IceArrow) + elseif code == 13 then + return tmp0(FaroresWind) + elseif code == 14 then + return tmp0(Boomerang) + elseif code == 15 then + return tmp0(LensOfTruth) + elseif code == 16 then + return tmp0(MagicBean) + elseif code == 17 then + return tmp0(MegatonHammer) + elseif code == 18 then + return tmp0(LightArrow) + elseif code == 19 then + return tmp0(NayrusLove) + elseif code == 20 then + return tmp0(EmptyBottle) + elseif code == 21 then + return tmp0(RedPotionBottle) + elseif code == 22 then + return tmp0(GreenPotionBottle) + elseif code == 23 then + return tmp0(BluePotionBottle) + elseif code == 24 then + return tmp0(FairyBottle) + elseif code == 25 then + return tmp0(FishBottle) + elseif code == 26 then + return tmp0(FullMilkBottle) + elseif code == 27 then + return tmp0(RutosLetterBottle) + elseif code == 28 then + return tmp0(BlueFireBottle) + elseif code == 29 then + return tmp0(BugBottle) + elseif code == 30 then + return tmp0(BigPoeBottle) + elseif code == 31 then + return tmp0(HalfMilkBottle) + elseif code == 32 then + return tmp0(PoeBottle) + elseif code == 33 then + return tmp0(WeirdEgg) + elseif code == 34 then + return tmp0(Chicken) + elseif code == 35 then + return tmp0(ZeldasLetter) + elseif code == 36 then + return tmp0(KeatonMask) + elseif code == 37 then + return tmp0(SkullMask) + elseif code == 38 then + return tmp0(SpookyMask) + elseif code == 39 then + return tmp0(BunnyHood) + elseif code == 40 then + return tmp0(GoronMask) + elseif code == 41 then + return tmp0(ZoraMask) + elseif code == 42 then + return tmp0(GerudoMask) + elseif code == 43 then + return tmp0(MaskOfTruth) + elseif code == 44 then + return tmp0(SoldOut) + elseif code == 45 then + return tmp0(PocketEgg) + elseif code == 46 then + return tmp0(PocketCucco) + elseif code == 47 then + return tmp0(Cojiro) + elseif code == 48 then + return tmp0(OddMushroom) + elseif code == 49 then + return tmp0(OddPotion) + elseif code == 50 then + return tmp0(PoachersSaw) + elseif code == 51 then + return tmp0(BrokenGoronsSword) + elseif code == 52 then + return tmp0(Prescription) + elseif code == 53 then + return tmp0(EyeballFrog) + elseif code == 54 then + return tmp0(EyeDrops) + elseif code == 55 then + return tmp0(ClaimCheck) + elseif code == 56 then + return tmp0(FairyBowAndFireArrow) + elseif code == 57 then + return tmp0(FairyBowAndIceArrow) + elseif code == 58 then + return tmp0(FairyBowAndLightArrow) + elseif code == 59 then + return tmp0(KokiriSword0) + elseif code == 60 then + return tmp0(MasterSword0) + elseif code == 61 then + return tmp0(GoronsSword) + elseif code == 255 then + return tmp0(NoItem) + else + return tmp0(UnknownItem(code)) + end + end + if code == 0 then + return tmp(DekuStick) + elseif code == 1 then + return tmp(DekuNut) + elseif code == 2 then + return tmp(Bomb) + elseif code == 3 then + return tmp(FairyBow) + elseif code == 4 then + return tmp(FireArrow) + elseif code == 5 then + return tmp(DinsFire) + elseif code == 6 then + return tmp(FairySlingshot) + elseif code == 7 then + return tmp(FairyOcarina) + elseif code == 8 then + return tmp(OcarinaOfTime) + elseif code == 9 then + return tmp(Bombchu_10) + elseif code == 10 then + return tmp(Hookshot) + elseif code == 11 then + return tmp(Longshot) + elseif code == 12 then + return tmp(IceArrow) + elseif code == 13 then + return tmp(FaroresWind) + elseif code == 14 then + return tmp(Boomerang) + elseif code == 15 then + return tmp(LensOfTruth) + elseif code == 16 then + return tmp(MagicBean) + elseif code == 17 then + return tmp(MegatonHammer) + elseif code == 18 then + return tmp(LightArrow) + elseif code == 19 then + return tmp(NayrusLove) + elseif code == 20 then + return tmp(EmptyBottle) + elseif code == 21 then + return tmp(RedPotionBottle) + elseif code == 22 then + return tmp(GreenPotionBottle) + elseif code == 23 then + return tmp(BluePotionBottle) + elseif code == 24 then + return tmp(FairyBottle) + elseif code == 25 then + return tmp(FishBottle) + elseif code == 26 then + return tmp(FullMilkBottle) + elseif code == 27 then + return tmp(RutosLetterBottle) + elseif code == 28 then + return tmp(BlueFireBottle) + elseif code == 29 then + return tmp(BugBottle) + elseif code == 30 then + return tmp(BigPoeBottle) + elseif code == 31 then + return tmp(HalfMilkBottle) + elseif code == 32 then + return tmp(PoeBottle) + elseif code == 33 then + return tmp(WeirdEgg) + elseif code == 34 then + return tmp(Chicken) + elseif code == 35 then + return tmp(ZeldasLetter) + elseif code == 36 then + return tmp(KeatonMask) + elseif code == 37 then + return tmp(SkullMask) + elseif code == 38 then + return tmp(SpookyMask) + elseif code == 39 then + return tmp(BunnyHood) + elseif code == 40 then + return tmp(GoronMask) + elseif code == 41 then + return tmp(ZoraMask) + elseif code == 42 then + return tmp(GerudoMask) + elseif code == 43 then + return tmp(MaskOfTruth) + elseif code == 44 then + return tmp(SoldOut) + elseif code == 45 then + return tmp(PocketEgg) + elseif code == 46 then + return tmp(PocketCucco) + elseif code == 47 then + return tmp(Cojiro) + elseif code == 48 then + return tmp(OddMushroom) + elseif code == 49 then + return tmp(OddPotion) + elseif code == 50 then + return tmp(PoachersSaw) + elseif code == 51 then + return tmp(BrokenGoronsSword) + elseif code == 52 then + return tmp(Prescription) + elseif code == 53 then + return tmp(EyeballFrog) + elseif code == 54 then + return tmp(EyeDrops) + elseif code == 55 then + return tmp(ClaimCheck) + elseif code == 56 then + return tmp(FairyBowAndFireArrow) + elseif code == 57 then + return tmp(FairyBowAndIceArrow) + elseif code == 58 then + return tmp(FairyBowAndLightArrow) + elseif code == 59 then + return tmp(KokiriSword0) + elseif code == 60 then + return tmp(MasterSword0) + elseif code == 61 then + return tmp(GoronsSword) + elseif code == 255 then + return tmp(NoItem) + else + return tmp(UnknownItem(code)) + end + end + local function _dollarfields1(amex, tmp) + local tmp0 = { + fields = function(tmp0) + return _dollarfields0(nil, tmp0) + end, + name = function(tmp0) + return "Equipment" + end + } + return { + { + _1 = { + _1 = "button_item_b", + _2 = S(_dollardShowakjw(nil))(tmp.button_item_b) + }, + _2 = { + { + _1 = { + _1 = "button_item_c_left", + _2 = S(_dollardShowakjw(nil))(tmp.button_item_c_left) + }, + _2 = { + { + _1 = { + _1 = "button_item_c_down", + _2 = S(_dollardShowakjw(nil))(tmp.button_item_c_down) + }, + _2 = { + { + _1 = { + _1 = "button_item_c_right", + _2 = S(_dollardShowakjw(nil))(tmp.button_item_c_right) + }, + _2 = { + { + _2 = { + { + _2 = { + { + _2 = { + { + _2 = Nil, + _1 = { + _1 = "equipment", + _2 = P(function(a) + return function(w) + return pretty_from_record(tmp0, a, w) + end + end)(tmp.equipment) + } + }, + __tag = "Cons" + }, + _1 = { + _1 = "button_slot_c_right", + _2 = S(function(tmp0) + return string_of_int(tmp0) .. "_u8" + end)(tmp.button_slot_c_right) + } + }, + __tag = "Cons" + }, + _1 = { + _1 = "button_slot_c_down", + _2 = S(function(tmp0) + return string_of_int(tmp0) .. "_u8" + end)(tmp.button_slot_c_down) + } + }, + __tag = "Cons" + }, + _1 = { + _1 = "button_slot_c_left", + _2 = S(function(tmp0) + return string_of_int(tmp0) .. "_u8" + end)(tmp.button_slot_c_left) + } + }, + __tag = "Cons" + } + }, + __tag = "Cons" + } + }, + __tag = "Cons" + } + }, + __tag = "Cons" + } + }, + __tag = "Cons" + } + end + local function _dollardecode2(atfa, addr) + local function tmp(tmp) + local u320 = read_value_32(addr + 4) + local function tmp0(tmp0) + local u321 = read_value_32(addr + 8) + local function tmp1(tmp1) + local tmp2 = read_value_16(addr + 12) + local u322 = read_value_32(addr + 16) + local function tmp3(tmp3) + local u323 = read_value_32(addr + 20) + local function tmp4(tmp4) + local function tmp5(tmp5) + local u16 = read_value_16(addr + 34) + local function tmp6(tmp6) + local u160 = read_value_16(addr + 44) + local function tmp7(tmp7) + local u161 = read_value_16(addr + 46) + local function tmp8(tmp8) + local function tmp9(tmp9) + local function tmp10(tmp10) + local u80 = read_value_8(addr + 51) + local function tmp11(tmp11) + local u163 = read_value_16(addr + 52) + local function tmp12(tmp12) + local tmp16 = read_value_16(addr + 54) + local tmp20 = read_value_16(addr + 56) + local tmp19 = read_value_8(addr + 58) + local tmp13 = read_value_8(addr + 60) + local tmp21 = read_value_8(addr + 61) + local tmp15 = read_value_8(addr + 62) + local tmp14 = read_value_8(addr + 63) + local tmp18 = _dollardecode1(nil, addr + 64) + local tmp17 = _dollardecode1(nil, addr + 74) + local u164 = read_value_16(addr + 102) + local function tmp22(tmp22) + return { + equips = _dollardecode1(nil, addr + 104), + inventory = _dollardecode(nil, addr + 116), + entrance_index = tmp, + link_age = tmp0, + cutscene_index = tmp1, + day_time = tmp2, + night_flag = tmp3, + num_days = tmp4, + claim_days = tmp5, + deaths = tmp6, + n64dd_flag = tmp7, + health_capacity = tmp8, + health = tmp9, + magic_level = tmp10, + magic = tmp11, + rupees = tmp12, + sword_health = tmp16, + navi_timer = tmp20, + magic_acquired = tmp19, + double_magic = tmp13, + double_defense = tmp21, + bgs_flag = tmp15, + ocarina_game_reward = tmp14, + child_equips = tmp18, + adult_equips = tmp17, + saved_scene_num = tmp22 + } + end + if u164 > 65535 then + return tmp22(0 - (65536 - u164)) + end + return tmp22(u164) + end + if u163 > 65535 then + return tmp12(0 - (65536 - u163)) + end + return tmp12(u163) + end + if u80 > 255 then + return tmp11(0 - (256 - u80)) + end + return tmp11(u80) + end + local u8 = read_value_8(addr + 50) + if u8 > 255 then + return tmp10(0 - (256 - u8)) + end + return tmp10(u8) + end + local u162 = read_value_16(addr + 48) + if u162 > 65535 then + return tmp9(0 - (65536 - u162)) + end + return tmp9(u162) + end + if u161 > 65535 then + return tmp8(0 - (65536 - u161)) + end + return tmp8(u161) + end + if u160 > 65535 then + return tmp7(0 - (65536 - u160)) + end + return tmp7(u160) + end + if u16 > 65535 then + return tmp6(0 - (65536 - u16)) + end + return tmp6(u16) + end + local u324 = read_value_32(addr + 24) + if u324 > 4294967295 then + return tmp5(0 - (4294967296 - u324)) + end + return tmp5(u324) + end + if u323 > 4294967295 then + return tmp4(0 - (4294967296 - u323)) + end + return tmp4(u323) + end + if u322 > 4294967295 then + return tmp3(0 - (4294967296 - u322)) + end + return tmp3(u322) + end + if u321 > 4294967295 then + return tmp1(0 - (4294967296 - u321)) + end + return tmp1(u321) + end + if u320 > 4294967295 then + return tmp0(0 - (4294967296 - u320)) + end + return tmp0(u320) + end + local u32 = read_value_32(addr) + if u32 > 4294967295 then + return tmp(0 - (4294967296 - u32)) + end + return tmp(u32) + end + local function _dollarfields2(atuq, tmp) + local function tmp0(tmp0) + return _dollarfields1(nil, tmp0) + end + local tmp1 = { + fields = function(tmp1) + return _dollarfields(nil, tmp1) + end, + name = function(tmp1) + return "Inventory" + end + } + return { + { + _2 = { + { + _2 = { + { + _2 = { + { + _1 = { + _1 = "day_time", + _2 = S(function(tmp0) + return string_of_int(tmp0) .. "_u16" + end)(tmp.day_time) + }, + _2 = { + { + _1 = { + _1 = "night_flag", + _2 = S(function(tmp0) + return string_of_int(tmp0) .. "_s32" + end)(tmp.night_flag) + }, + _2 = { + { + _1 = { + _1 = "num_days", + _2 = S(function(tmp0) + return string_of_int(tmp0) .. "_s32" + end)(tmp.num_days) + }, + _2 = { + { + _1 = { + _1 = "claim_days", + _2 = S(function(tmp0) + return string_of_int(tmp0) .. "_s32" + end)(tmp.claim_days) + }, + _2 = { + { + _2 = { + { + _1 = { + _1 = "n64dd_flag", + _2 = S(function(tmp0) + return string_of_int(tmp0) .. "_s16" + end)(tmp.n64dd_flag) + }, + _2 = { + { + _2 = { + { + _2 = { + { + _1 = { + _1 = "magic_level", + _2 = S(function(tmp0) + return string_of_int(tmp0) .. "_s8" + end)(tmp.magic_level) + }, + _2 = { + { + _1 = { + _1 = "magic", + _2 = S(function(tmp0) + return string_of_int(tmp0) .. "_s8" + end)(tmp.magic) + }, + _2 = { + { + _2 = { + { + _2 = { + { + _2 = { + { + _2 = { + { + _2 = { + { + _2 = { + { + _1 = { + _1 = "bgs_flag", + _2 = S(function(tmp0) + return string_of_int(tmp0) .. "_u8" + end)(tmp.bgs_flag) + }, + _2 = { + { + _1 = { + _1 = "ocarina_game_reward", + _2 = S(function(tmp0) + return string_of_int(tmp0) .. "_u8" + end)(tmp.ocarina_game_reward) + }, + _2 = { + { + _1 = { + _1 = "child_equips", + _2 = P(pretty_from_record0({ + fields = tmp0, + name = function(tmp0) + return "ItemEquips" + end + }))(tmp.child_equips) + }, + _2 = { + { + _1 = { + _1 = "adult_equips", + _2 = P(pretty_from_record0({ + fields = tmp0, + name = function(tmp1) + return "ItemEquips" + end + }))(tmp.adult_equips) + }, + _2 = { + { + _2 = { + { + _1 = { + _1 = "equips", + _2 = P(pretty_from_record0({ + fields = tmp0, + name = function(tmp1) + return "ItemEquips" + end + }))(tmp.equips) + }, + _2 = { + { + _2 = Nil, + _1 = { + _1 = "inventory", + _2 = P(function(a) + return function(w) + return pretty_from_record(tmp1, a, w) + end + end)(tmp.inventory) + } + }, + __tag = "Cons" + } + }, + __tag = "Cons" + }, + _1 = { + _1 = "saved_scene_num", + _2 = S(function(tmp1) + return string_of_int(tmp1) .. "_s16" + end)(tmp.saved_scene_num) + } + }, + __tag = "Cons" + } + }, + __tag = "Cons" + } + }, + __tag = "Cons" + } + }, + __tag = "Cons" + } + }, + __tag = "Cons" + }, + _1 = { + _1 = "double_defense", + _2 = S(function(tmp0) + return string_of_int(tmp0) .. "_u8" + end)(tmp.double_defense) + } + }, + __tag = "Cons" + }, + _1 = { + _1 = "double_magic", + _2 = S(function(tmp0) + return string_of_int(tmp0) .. "_u8" + end)(tmp.double_magic) + } + }, + __tag = "Cons" + }, + _1 = { + _1 = "magic_acquired", + _2 = S(function(tmp0) + return string_of_int(tmp0) .. "_u8" + end)(tmp.magic_acquired) + } + }, + __tag = "Cons" + }, + _1 = { + _1 = "navi_timer", + _2 = S(function(tmp0) + return string_of_int(tmp0) .. "_u16" + end)(tmp.navi_timer) + } + }, + __tag = "Cons" + }, + _1 = { + _1 = "sword_health", + _2 = S(function(tmp0) + return string_of_int(tmp0) .. "_u16" + end)(tmp.sword_health) + } + }, + __tag = "Cons" + }, + _1 = { + _1 = "rupees", + _2 = S(function(tmp0) + return string_of_int(tmp0) .. "_s16" + end)(tmp.rupees) + } + }, + __tag = "Cons" + } + }, + __tag = "Cons" + } + }, + __tag = "Cons" + }, + _1 = { + _1 = "health", + _2 = S(function(tmp0) + return string_of_int(tmp0) .. "_s16" + end)(tmp.health) + } + }, + __tag = "Cons" + }, + _1 = { + _1 = "health_capacity", + _2 = S(function(tmp0) + return string_of_int(tmp0) .. "_s16" + end)(tmp.health_capacity) + } + }, + __tag = "Cons" + } + }, + __tag = "Cons" + }, + _1 = { + _1 = "deaths", + _2 = S(function(tmp0) + return string_of_int(tmp0) .. "_s16" + end)(tmp.deaths) + } + }, + __tag = "Cons" + } + }, + __tag = "Cons" + } + }, + __tag = "Cons" + } + }, + __tag = "Cons" + } + }, + __tag = "Cons" + }, + _1 = { + _1 = "cutscene_index", + _2 = S(function(tmp0) + return string_of_int(tmp0) .. "_s32" + end)(tmp.cutscene_index) + } + }, + __tag = "Cons" + }, + _1 = { + _1 = "link_age", + _2 = S(function(tmp0) + return string_of_int(tmp0) .. "_s32" + end)(tmp.link_age) + } + }, + __tag = "Cons" + }, + _1 = { + _1 = "entrance_index", + _2 = S(function(tmp0) + return string_of_int(tmp0) .. "_s32" + end)(tmp.entrance_index) + } + }, + __tag = "Cons" + } + end + local function onScriptStart(tmp) + return nil + end + local function onScriptCancel(tmp) + return nil + end + local function onScriptUpdate(tmp) + return set_screen_text(pretty_from_record({ + fields = function(tmp0) + return _dollarfields2(nil, tmp0) + end, + name = function(tmp0) + return "SaveContext" + end + }, _dollardecode2(nil, 17295088), 0)) + end + local function onStateLoaded(tmp) + return nil + end + local function onStateSaved(tmp) + return nil + end + return { + base_address = 16138528, + g_save_ctx_address = 1156560, + onScriptCancel = onScriptCancel, + onScriptStart = onScriptStart, + onScriptUpdate = onScriptUpdate, + onStateLoaded = onStateLoaded, + onStateSaved = onStateSaved + } +end \ No newline at end of file diff --git a/build/ootAI.lua b/build/ootAI.lua new file mode 100644 index 0000000..a2b9762 --- /dev/null +++ b/build/ootAI.lua @@ -0,0 +1,23 @@ +package.path = GetScriptsDir() .. "oot/main.lua" +local main = require("main") + +function onScriptStart() + main.onScriptStart() +end + +function onScriptCancel() + main.onScriptCancel() +end + +function onScriptUpdate() + main.onScriptUpdate() +end + +function onStateLoaded() + main.onStateLoaded() +end + +function onStateSaved() + main.onStateSaved() +end + diff --git a/mem/int.ml b/mem/int.ml index f9f2efb..e5e9749 100644 --- a/mem/int.ml +++ b/mem/int.ml @@ -24,8 +24,8 @@ instance decode s8 begin let decode addr = let u8 = Dolphin.read_value_8 addr let signfix = - if u8 > 127 then - negate (256 - u8) + if u8 > 0xFF then + negate (0x100 - u8) else u8 S8 signfix @@ -53,8 +53,8 @@ instance decode s16 begin let decode addr = let u16 = Dolphin.read_value_16 addr let signfix = - if u16 > 32767 then - negate (65536 - u16) + if u16 > 0xFFFF then + negate (0x10000 - u16) else u16 S16 signfix @@ -67,15 +67,24 @@ instance show u32 begin let show (U32 x) = (show x) ^ "_u32" end +instance decode u32 begin + let decode addr = U32 (Dolphin.read_value_32 addr) +end + type s32 = S32 of int instance show s32 begin - let show (S32 x) = - let signfix = - if x > 2147483647 then - negate (4294967296 - x) - else - x - (show signfix) ^ "_s32" + let show (S32 x) = (show x) ^ "_s32" +end + +instance decode s32 begin + let decode addr = + let u32 = Dolphin.read_value_32 addr + let signfix = + if u32 > 0xFFFFFFFF then + negate (0x100000000 - u32) + else + u32 + S32 signfix end diff --git a/oot/equipment.ml b/oot/equipment.ml index a2b1591..4ecf9dd 100644 --- a/oot/equipment.ml +++ b/oot/equipment.ml @@ -48,35 +48,41 @@ type tunic = | KokiriTunic | GoronTunic | ZoraTunic +| UnknownTunic of int instance show tunic begin let show = function | KokiriTunic -> "Kokiri Tunic" | GoronTunic -> "Goron Tunic" | ZoraTunic -> "Zora Tunic" + | UnknownTunic x -> "Unknown Tunic " ^ (show x) end let tunic_from_index = function | 1 -> KokiriTunic | 2 -> GoronTunic | 3 -> ZoraTunic +| x -> UnknownTunic x type boots = | KokiriBoots | IronBoots | HoverBoots +| UnknownBoots of int instance show boots begin let show = function | KokiriBoots -> "Kokiri Boots" | IronBoots -> "Iron Boots" | HoverBoots -> "Hover Boots" + | UnknownBoots x -> "Unknown Boots " ^ (show x) end let boots_from_index = function | 1 -> KokiriBoots | 2 -> IronBoots | 3 -> HoverBoots +| x -> UnknownBoots x type equipment = Equipment of { sword: sword, @@ -85,6 +91,11 @@ type equipment = Equipment of { boots: boots } +external private val ( .>>. ) : int -> int -> int + = "function(a, b) return a >> b end" +external private val ( .&. ) : int -> int -> int + = "function(a, b) return a & b end" + instance decode equipment begin let decode addr = let code = Dolphin.read_value_16 addr diff --git a/oot/inventory.ml b/oot/inventory.ml new file mode 100644 index 0000000..4ebad64 --- /dev/null +++ b/oot/inventory.ml @@ -0,0 +1,51 @@ +open import "prelude.ml" +open import "data/array.ml" +open import "../pretty.ml" +open import "../mem/decode.ml" +open import "../mem/int.ml" + +type inventory = Inventory of { + items: array u8, + ammo: array s8, + equipment: u16, + upgrades: u32, + quest_items: u32, + dungeon_items: array u8, + dungeon_keys: array s8, + defense_hearts: s8, + gs_tokens: s16 +} + +instance decode inventory begin + let decode addr = Inventory { + items = init 24 (fun i -> decode (addr + 0x00 + i)), + ammo = init 16 (fun i -> decode (addr + 0x18 + i)), + equipment = decode (addr + 0x28), + upgrades = decode (addr + 0x2C), + quest_items = decode (addr + 0x30), + dungeon_items = init 20 (fun i -> decode (addr + 0x34 + i)), + dungeon_keys = init 19 (fun i -> decode (addr + 0x48 + i)), + defense_hearts = decode (addr + 0x5B), + gs_tokens = decode (addr + 0x5C) + } +end + +instance prettyrecord inventory begin + let name _ = "Inventory" + let fields (Inventory x) = + [ + ("items", S x.items), + ("ammo", S x.ammo), + ("equipment", S x.equipment), + ("upgrades", S x.upgrades), + ("quest_items", S x.quest_items), + ("dungeon_items", S x.dungeon_items), + ("dungeon_keys", S x.dungeon_keys), + ("defense_hearts", S x.defense_hearts), + ("gs_tokens", S x.gs_tokens) + ] +end + +instance pretty inventory begin + let pretty = pretty_from_record +end diff --git a/oot/item.ml b/oot/item.ml index d077ea2..1ed2170 100644 --- a/oot/item.ml +++ b/oot/item.ml @@ -5,22 +5,293 @@ open import "../mem/decode.ml" open import "../mem/int.ml" type item = -| DekuSticks -| NoItem +| DekuStick +| DekuNut +| Bomb +| FairyBow +| FireArrow +| DinsFire +| FairySlingshot +| FairyOcarina +| OcarinaOfTime +| Bombchu_10 +| Hookshot +| Longshot +| IceArrow +| FaroresWind +| Boomerang +| LensOfTruth +| MagicBean +| MegatonHammer +| LightArrow +| NayrusLove +| EmptyBottle +| RedPotionBottle +| GreenPotionBottle +| BluePotionBottle +| FairyBottle +| FishBottle +| FullMilkBottle +| RutosLetterBottle +| BlueFireBottle +| BugBottle +| BigPoeBottle +| HalfMilkBottle +| PoeBottle +| WeirdEgg +| Chicken +| ZeldasLetter +| KeatonMask +| SkullMask +| SpookyMask +| BunnyHood +| GoronMask +| ZoraMask +| GerudoMask +| MaskOfTruth +| SoldOut +| PocketEgg +| PocketCucco +| Cojiro +| OddMushroom +| OddPotion +| PoachersSaw +| BrokenGoronsSword +| Prescription +| EyeballFrog +| EyeDrops +| ClaimCheck +| FairyBowAndFireArrow +| FairyBowAndIceArrow +| FairyBowAndLightArrow +| KokiriSword +| MasterSword +| GoronsSword +| DekuShield +| HylianShield +| MirrorShield +| KokiriTunic +| GoronTunic +| ZoraTunic +| KokiriBoots +| IronBoots +| HoverBoots +| BulletBag_30 +| BulletBag_40 +| BulletBag_50 +| Quiver_30 +| BigQuiver_40 +| BiggestQuiver_50 +| BombBag_20 +| BigBombBag_30 +| BiggestBombBag_40 +| GoronsBracelet +| SilverGauntlets +| GoldenGauntlets +| SilverScale +| GoldenScale +| BrokenGiantsKnife +| AdultsWallet +| GiantsWallet +| DekuSeeds_5 +| FishingPole +| MinuetOfForest +| BoleroOfFire +| SerenadeOfWater +| RequiemOfSpirit +| NocturneOfShadow +| PreludeOfLight +| ZeldasLullaby +| EponasSong +| SariasSong +| SunsSong +| SongOfTime +| SongOfStorms +| ForestMedallion +| FireMedallion +| WaterMedallion +| SpiritMedallion +| ShadowMedallion +| LightMedallion +| KokirisEmerald +| GoronsRuby +| ZorasSapphire +| StoneOfAgony +| GerudosCard +| GoldSkulltulaToken +| HeartContainer +| PieceOfHeart_ +| BossKey +| Compass +| DungeonMap +| SmallKey +| SmallMagicJar +| LargeMagicJar +| PieceOfHeart +| LonLonMilk +| RecoveryHeart +| GreenRupee +| BlueRupee +| RedRupee +| PurpleRupee +| HugeRupee +| DekuSticks_5 +| DekuSticks_10 +| DekuNuts_5 +| DekuNuts_10 +| Bombs_5 +| Bombs_10 +| Bombs_20 +| Bombs_30 +| Arrows_5_10 +| Arrows_10_30 +| Arrows_30_50 +| DekuSeeds_30 +| Bombchu_5 +| Bombchu_20 +| DekuStickCapacity_20 +| DekuStickCapacity_30 +| DekuNutCapacity_30 +| DekuNutCapacity_40 | UnknownItem of int +| NoItem instance decode item begin let decode addr = let code = Dolphin.read_value_8 addr match code with - | 0 -> DekuSticks - | 255 -> NoItem + | 0x00 -> DekuStick + | 0x01 -> DekuNut + | 0x02 -> Bomb + | 0x03 -> FairyBow + | 0x04 -> FireArrow + | 0x05 -> DinsFire + | 0x06 -> FairySlingshot + | 0x07 -> FairyOcarina + | 0x08 -> OcarinaOfTime + | 0x09 -> Bombchu_10 + | 0x0A -> Hookshot + | 0x0B -> Longshot + | 0x0C -> IceArrow + | 0x0D -> FaroresWind + | 0x0E -> Boomerang + | 0x0F -> LensOfTruth + | 0x10 -> MagicBean + | 0x11 -> MegatonHammer + | 0x12 -> LightArrow + | 0x13 -> NayrusLove + | 0x14 -> EmptyBottle + | 0x15 -> RedPotionBottle + | 0x16 -> GreenPotionBottle + | 0x17 -> BluePotionBottle + | 0x18 -> FairyBottle + | 0x19 -> FishBottle + | 0x1A -> FullMilkBottle + | 0x1B -> RutosLetterBottle + | 0x1C -> BlueFireBottle + | 0x1D -> BugBottle + | 0x1E -> BigPoeBottle + | 0x1F -> HalfMilkBottle + | 0x20 -> PoeBottle + | 0x21 -> WeirdEgg + | 0x22 -> Chicken + | 0x23 -> ZeldasLetter + | 0x24 -> KeatonMask + | 0x25 -> SkullMask + | 0x26 -> SpookyMask + | 0x27 -> BunnyHood + | 0x28 -> GoronMask + | 0x29 -> ZoraMask + | 0x2A -> GerudoMask + | 0x2B -> MaskOfTruth + | 0x2C -> SoldOut + | 0x2D -> PocketEgg + | 0x2E -> PocketCucco + | 0x2F -> Cojiro + | 0x30 -> OddMushroom + | 0x31 -> OddPotion + | 0x32 -> PoachersSaw + | 0x33 -> BrokenGoronsSword + | 0x34 -> Prescription + | 0x35 -> EyeballFrog + | 0x36 -> EyeDrops + | 0x37 -> ClaimCheck + | 0x38 -> FairyBowAndFireArrow + | 0x39 -> FairyBowAndIceArrow + | 0x3A -> FairyBowAndLightArrow + | 0x3B -> KokiriSword + | 0x3C -> MasterSword + | 0x3D -> GoronsSword + | 0xFF -> NoItem | x -> UnknownItem x end +let dummy_show : int -> string = show + instance show item begin let show = function - | DekuSticks -> "Deku Sticks" + | DekuStick -> "Deku Stick" + | DekuNut -> "Deku Nut" + | Bomb -> "Bomb" + | FairyBow -> "Fairy Bow" + | FireArrow -> "Fire Arrow" + | DinsFire -> "Din's Fire" + | FairySlingshot -> "Fairy Slingshot" + | FairyOcarina -> "Fairy Ocarina" + | OcarinaOfTime -> "Ocarina of Time" + | Bombchu_10 -> "Bombchu (10)" + | Hookshot -> "Hookshot" + | Longshot -> "Longshot" + | IceArrow -> "Ice Arrow" + | FaroresWind -> "Farore's Wind" + | Boomerang -> "Boomerang" + | LensOfTruth -> "Lens of Truth" + | MagicBean -> "Magic Bean" + | MegatonHammer -> "Megaton Hammer" + | LightArrow -> "Light Arrow" + | NayrusLove -> "Nayru's Love" + | EmptyBottle -> "Empty Bottle" + | RedPotionBottle -> "Red Potion" + | GreenPotionBottle -> "Green Potion" + | BluePotionBottle -> "Blue Potion" + | FairyBottle -> "Bottled Fairy" + | FishBottle -> "Fish" + | FullMilkBottle -> "Lon Lon Milk" + | RutosLetterBottle -> "Ruto's Letter" + | BlueFireBottle -> "Blue Fire" + | BugBottle -> "Bug" + | BigPoeBottle -> "Big Poe" + | HalfMilkBottle -> "Half Lon Lon Milk" + | PoeBottle -> "Poe" + | WeirdEgg -> "Weird Egg" + | Chicken -> "Chicken" + | ZeldasLetter -> "Zelda's Letter" + | KeatonMask -> "Keaton Mask" + | SkullMask -> "Skull Mask" + | SpookyMask -> "Spooky Mask" + | BunnyHood -> "Bunny Hood" + | GoronMask -> "Goron Mask" + | ZoraMask -> "Zora Mask" + | GerudoMask -> "Gerudo Mask" + | MaskOfTruth -> "Mask of Truth" + | SoldOut -> "SOLD OUT" + | PocketEgg -> "Pocket Egg" + | PocketCucco -> "Pocket Cucco" + | Cojiro -> "Cojiro" + | OddMushroom -> "Odd Mushroom" + | OddPotion -> "Odd Potion" + | PoachersSaw -> "Poacher's Saw" + | BrokenGoronsSword -> "Broken Giant's Knife" + | Prescription -> "Prescription" + | EyeballFrog -> "Eyeball Frog" + | EyeDrops -> "Eye Drops" + | ClaimCheck -> "Claim Check" + | FairyBowAndFireArrow -> "Fairy Bow & Fire Arrow" + | FairyBowAndIceArrow -> "Fairy Bow & Ice Arrow" + | FairyBowAndLightArrow -> "Fairy Bow & Light Arrow" + | KokiriSword -> "Kokiri Sword" + | MasterSword -> "Master Sword" + | GoronsSword -> "Giant's Knife & Biggoron's Sword" | NoItem -> "No Item" - | UnknownItem x -> "Unknown Item " ^ (show x) + | UnknownItem x -> "Unknown Item " ^ (dummy_show x) end diff --git a/oot/item_equips.ml b/oot/item_equips.ml index a4374e3..23fe408 100644 --- a/oot/item_equips.ml +++ b/oot/item_equips.ml @@ -3,6 +3,7 @@ open import "../pretty.ml" open import "../mem/decode.ml" open import "../mem/int.ml" open import "./item.ml" +open import "./equipment.ml" type item_equips = ItemEquips of { button_item_b: item, @@ -12,7 +13,7 @@ type item_equips = ItemEquips of { button_slot_c_left: u8, button_slot_c_down: u8, button_slot_c_right: u8, - equipment: u16 + equipment: equipment } instance decode item_equips begin @@ -39,7 +40,7 @@ instance prettyrecord item_equips begin ("button_slot_c_left", S x.button_slot_c_left), ("button_slot_c_down", S x.button_slot_c_down), ("button_slot_c_right", S x.button_slot_c_right), - ("equipment", S x.equipment) + ("equipment", P x.equipment) ] end diff --git a/oot/save_context.ml b/oot/save_context.ml index 16ac10d..88cb764 100644 --- a/oot/save_context.ml +++ b/oot/save_context.ml @@ -3,20 +3,74 @@ open import "../pretty.ml" open import "../mem/decode.ml" open import "../mem/int.ml" open import "./item_equips.ml" +open import "./inventory.ml" type save_context = SaveContext of { + entrance_index: s32, + link_age: s32, + cutscene_index: s32, + day_time: u16, + night_flag: s32, + num_days: s32, + claim_days: s32, + (* char newf[6], *) + deaths: s16, + (* char playerName[8], *) + n64dd_flag: s16, + health_capacity: s16, + health: s16, + magic_level: s8, + magic: s8, rupees: s16, + sword_health: u16, + navi_timer: u16, + magic_acquired: u8, + (* char unk_3B[0x01], *) + double_magic: u8, + double_defense: u8, + bgs_flag: u8, + ocarina_game_reward: u8, child_equips: item_equips, adult_equips: item_equips, - equips: item_equips + (* u32 unk_54, *) + (* char unk_58[0x0E], *) + saved_scene_num: s16, + equips: item_equips, + inventory: inventory } instance decode save_context begin let decode addr = SaveContext { + entrance_index = decode (addr + 0x0000), + link_age = decode (addr + 0x0004), + cutscene_index = decode (addr + 0x0008), + day_time = decode (addr + 0x000C), + night_flag = decode (addr + 0x0010), + num_days = decode (addr + 0x0014), + claim_days = decode (addr + 0x0018), + (* newf, *) + deaths = decode (addr + 0x0022), + (* player_name, *) + n64dd_flag = decode (addr + 0x002C), + health_capacity = decode (addr + 0x002E), + health = decode (addr + 0x0030), + magic_level = decode (addr + 0x0032), + magic = decode (addr + 0x0033), rupees = decode (addr + 0x0034), + sword_health = decode (addr + 0x0036), + navi_timer = decode (addr + 0x0038), + magic_acquired = decode (addr + 0x003A), + (* unk_3B *) + double_magic = decode (addr + 0x003C), + double_defense = decode (addr + 0x003D), + bgs_flag = decode (addr + 0x003E), + ocarina_game_reward = decode (addr + 0x003F), child_equips = decode (addr + 0x0040), adult_equips = decode (addr + 0x004A), - equips = decode (addr + 0x0068) + (* unk_54, *) + saved_scene_num = decode (addr + 0x0066), + equips = decode (addr + 0x0068), + inventory = decode (addr + 0x0074) } end @@ -24,10 +78,37 @@ instance prettyrecord save_context begin let name _ = "SaveContext" let fields (SaveContext x) = [ + ("entrance_index", S x.entrance_index), + ("link_age", S x.link_age), + ("cutscene_index", S x.cutscene_index), + ("day_time", S x.day_time), + ("night_flag", S x.night_flag), + ("num_days", S x.num_days), + ("claim_days", S x.claim_days), + (* ("newf", S x.newf ), *) + ("deaths", S x.deaths), + (* ("player_name", S x.player_name) *) + ("n64dd_flag", S x.n64dd_flag), + ("health_capacity", S x.health_capacity), + ("health", S x.health), + ("magic_level", S x.magic_level), + ("magic", S x.magic), ("rupees", S x.rupees), + ("sword_health", S x.sword_health), + ("navi_timer", S x.navi_timer), + ("magic_acquired", S x.magic_acquired), + (* ("unk_3B", *) + ("double_magic", S x.double_magic), + ("double_defense", S x.double_defense), + ("bgs_flag", S x.bgs_flag), + ("ocarina_game_reward", S x.ocarina_game_reward), ("child_equips", P x.child_equips), ("adult_equips", P x.adult_equips), - ("equips", P x.equips) + (* ("unk_54" *) + (* ("unk_58" *) + ("saved_scene_num", S x.saved_scene_num), + ("equips", P x.equips), + ("inventory", P x.inventory) ] end diff --git a/save_context.ml b/save_context.ml deleted file mode 100644 index 7542d15..0000000 --- a/save_context.ml +++ /dev/null @@ -1,466 +0,0 @@ -open import "prelude.ml" -open import "data/array.ml" - -open import "./pretty.ml" - -open import "./dolphin.ml" - -type item = -| DekuStick -| DekuNut -| Bomb -| FairyBow -| FireArrow -| DinsFire -| FairySlingshot -| FairyOcarina -| OcarinaOfTime -| Bombchu_10 -| Hookshot -| Longshot -| IceArrow -| FaroresWind -| Boomerang -| LensOfTruth -| MagicBean -| MegatonHammer -| LightArrow -| NayrusLove -| EmptyBottle -| RedPotionBottle -| GreenPotionBottle -| BluePotionBottle -| FairyBottle -| FishBottle -| FullMilkBottle -| RutosLetterBottle -| BlueFireBottle -| BugBottle -| BigPoeBottle -| HalfMilkBottle -| PoeBottle -| WeirdEgg -| Chicken -| ZeldasLetter -| KeatonMask -| SkullMask -| SpookyMask -| BunnyHood -| GoronMask -| ZoraMask -| GerudoMask -| MaskOfTruth -| SoldOut -| PocketEgg -| PocketCucco -| Cojiro -| OddMushroom -| OddPotion -| PoachersSaw -| BrokenGoronsSword -| Prescription -| EyeballFrog -| EyeDrops -| ClaimCheck -| FairyBowAndFireArrow -| FairyBowAndIceArrow -| FairyBowAndLightArrow -| KokiriSword -| MasterSword -| GiantsKnifeAndBiggoronsSword -| DekuShield -| HylianShield -| MirrorShield -| KokiriTunic -| GoronTunic -| ZoraTunic -| KokiriBoots -| IronBoots -| HoverBoots -| BulletBag_30 -| BulletBag_40 -| BulletBag_50 -| Quiver_30 -| BigQuiver_40 -| BiggestQuiver_50 -| BombBag_20 -| BigBombBag_30 -| BiggestBombBag_40 -| GoronsBracelet -| SilverGauntlets -| GoldenGauntlets -| SilverScale -| GoldenScale -| BrokenGiantsKnife -| AdultsWallet -| GiantsWallet -| DekuSeeds_5 -| FishingPole -| MinuetOfForest -| BoleroOfFire -| SerenadeOfWater -| RequiemOfSpirit -| NocturneOfShadow -| PreludeOfLight -| ZeldasLullaby -| EponasSong -| SariasSong -| SunsSong -| SongOfTime -| SongOfStorms -| ForestMedallion -| FireMedallion -| WaterMedallion -| SpiritMedallion -| ShadowMedallion -| LightMedallion -| KokirisEmerald -| GoronsRuby -| ZorasSapphire -| StoneOfAgony -| GerudosCard -| GoldSkulltulaToken -| HeartContainer -| PieceOfHeart_ -| BossKey -| Compass -| DungeonMap -| SmallKey -| SmallMagicJar -| LargeMagicJar -| PieceOfHeart -| LonLonMilk -| RecoveryHeart -| GreenRupee -| BlueRupee -| RedRupee -| PurpleRupee -| HugeRupee -| DekuSticks_5 -| DekuSticks_10 -| DekuNuts_5 -| DekuNuts_10 -| Bombs_5 -| Bombs_10 -| Bombs_20 -| Bombs_30 -| Arrows_5_10 -| Arrows_10_30 -| Arrows_30_50 -| DekuSeeds_30 -| Bombchu_5 -| Bombchu_20 -| DekuStickCapacity_20 -| DekuStickCapacity_30 -| DekuNutCapacity_30 -| DekuNutCapacity_40 -| UnknownItem of u8 -| NoItem - -instance decode item begin - let decode addr x = - let (U8 id) = decode addr x - match id with - | 0xFF -> NoItem -end - -instance show item begin - let show = function - | NoItem -> "No Item" -end - -type sword = -| NoSword -| KokiriSword -| MasterSword -| BiggoronsSword -| UnknownSword of int - -instance show sword begin - let show = function - | NoSword -> "No Sword" - | KokiriSword -> "Kokiri Sword" - | MasterSword -> "Master Sword" - | BiggoronsSword -> "Biggoron's Sword" - | UnknownSword x -> "Unknown Sword " ^ (show x) -end - -type shield = -| NoShield -| DekuShield -| HylianShield -| MirrorShield -| UnknownShield of int - -instance show shield begin - let show = function - | NoShield -> "No Shield" - | DekuShield -> "Deku Shield" - | HylianShield -> "Hylian Shield" - | MirrorShield -> "Mirror Shield" - | UnknownShield x -> "Unknown Shield " ^ (show x) -end - -type tunic = -| KokiriTunic -| GoronTunic -| ZoraTunic -| UnknownTunic of int - -instance show tunic begin - let show = function - | KokiriTunic -> "Kokiri Tunic" - | GoronTunic -> "Goron Tunic" - | ZoraTunic -> "Zora Tunic" - | UnknownTunic x -> "Unknown Tunic " ^ (show x) -end - -type boots = -| KokiriBoots -| IronBoots -| HoverBoots -| UnknownBoots of int - -instance show boots begin - let show = function - | KokiriBoots -> "Kokiri Boots" - | IronBoots -> "Iron Boots" - | HoverBoots -> "Hover Boots" - | UnknownBoots x -> "Unknown Boots " ^ (show x) -end - -type equipment = Equipment of { - swordv: sword, - shieldv: shield, - tunicv: tunic, - bootsv: boots -} - -external private val ( %% ) : int -> int -> int = "function(a, b) return a % b end" - -instance decode equipment begin - let decode addr x = - let (U16 fields) = decode addr x - let swords = fields %% (0x000F + 1) - let shields = (fields // 8) %% (0x00F + 1) - let tunics = (fields // 16) %% (0x0F + 1) - let boots = (fields // 24) %% (0xF + 1) - let fsword = - match swords with - | 0 -> NoSword - | 1 -> KokiriSword - | 2 -> MasterSword - | 3 -> BiggoronsSword - | x -> UnknownSword x - let fshield = - match shields with - | 0 -> NoShield - | 1 -> DekuShield - | 2 -> HylianShield - | 3 -> MirrorShield - | x -> UnknownShield x - let ftunic = - match tunics with - | 1 -> KokiriTunic - | 2 -> GoronTunic - | 3 -> ZoraTunic - | x -> UnknownTunic x - let fboot = - match boots with - | 1 -> KokiriBoots - | 2 -> IronBoots - | 3 -> HoverBoots - | x -> UnknownBoots x - Equipment { - swordv = fsword, - shieldv = fshield, - tunicv = ftunic, - bootsv = fboot - } -end - -instance prettyrecord equipment begin - let name _ = "Equipment" - let fields (Equipment x) = - [] -end - -type item_equips = ItemEquips of { - button_item_b: u8, - button_item_c_left: u8, - button_item_c_down: u8, - button_item_c_right: u8, - button_slot_c_left: u8, - button_slot_c_down: u8, - button_slot_c_right: u8, - equips: equipment -} - -instance decode item_equips begin - let decode addr x = ItemEquips { - button_item_b = decode (addr + 0x00) x, - button_item_c_left = decode (addr + 0x01) x, - button_item_c_down = decode (addr + 0x02) x, - button_item_c_right = decode (addr + 0x03) x, - button_slot_c_left = decode (addr + 0x04) x, - button_slot_c_down = decode (addr + 0x05) x, - button_slot_c_right = decode (addr + 0x06) x, - equips = decode (addr + 0x08) x - } -end - -instance prettyrecord item_equips begin - let name _ = "ItemEquips" - let fields (ItemEquips x) = - [ - ("button_item_b", S x.button_item_b), - ("button_item_c_left", S x.button_item_c_left), - ("button_item_c_down", S x.button_item_c_down), - ("button_item_c_right", S x.button_item_c_right), - ("button_slot_c_left", S x.button_slot_c_left), - ("button_slot_c_down", S x.button_slot_c_down), - ("button_slot_c_right", S x.button_slot_c_right), - ("equips", P x.equips) - ] -end - -type inventory = Inventory of { - items: array u8, - ammo: array s8, - equipment: u16, - upgrades: u32, - quest_items: u32, - dungeon_items: array u8, - dungeon_keys: array s8, - defense_hearts: s8, - gs_tokens: s16 -} - -instance decode inventory begin - let decode addr x = Inventory { - items = init 24 (fun i -> decode (addr + 0x00 + i) x), - ammo = init 16 (fun i -> decode (addr + 0x18 + i) x), - equipment = decode (addr + 0x28) x, - upgrades = decode (addr + 0x2C) x, - quest_items = decode (addr + 0x30) x, - dungeon_items = init 20 (fun i -> decode (addr + 0x34 + i) x), - dungeon_keys = init 19 (fun i -> decode (addr + 0x48 + i) x), - defense_hearts = decode (addr + 0x5B) x, - gs_tokens = decode (addr + 0x5C) x - } -end - -instance prettyrecord inventory begin - let name _ = "Inventory" - let fields (Inventory x) = - [ - ("items", S x.items), - ("ammo", S x.ammo), - ("equipment", S x.equipment), - ("upgrades", S x.upgrades), - ("quest_items", S x.quest_items), - ("dungeon_items", S x.dungeon_items), - ("dungeon_keys", S x.dungeon_keys), - ("defense_hearts", S x.defense_hearts), - ("gs_tokens", S x.gs_tokens) - ] -end - -type save_context = SaveContext of { - entrance_index: s32, - link_age: s32, - cutscene_index: s32, - day_time: u16, - night_flag: s32, - num_days: s32, - claim_days: s32, - (* char newf[6], *) - deaths: s16, - (* char playerName[8], *) - n64dd_flag: s16, - health_capacity: s16, - health: s16, - magic_level: s8, - magic: s8, - rupees: s16, - sword_health: u16, - navi_timer: u16, - magic_acquired: u8, - (* char unk_3B[0x01], *) - double_magic: u8, - double_defense: u8, - bgs_flag: u8, - ocarina_game_reward: u8, - child_equips: item_equips, - adult_equips: item_equips, - (* u32 unk_54, *) - (* char unk_58[0x0E], *) - saved_scene_num: s16, - equips: item_equips, - inventory: inventory -} - -instance decode save_context begin - let decode addr x = SaveContext { - entrance_index = decode (addr + 0x0000) x, - link_age = decode (addr + 0x0004) x, - cutscene_index = decode (addr + 0x0008) x, - day_time = decode (addr + 0x000C) x, - night_flag = decode (addr + 0x0010) x, - num_days = decode (addr + 0x0014) x, - claim_days = decode (addr + 0x0018) x, - (* newf, *) - deaths = decode (addr + 0x0022) x, - n64dd_flag = decode (addr + 0x002C) x, - health_capacity = decode (addr + 0x002E) x, - health = decode (addr + 0x0030) x, - magic_level = decode (addr + 0x0032) x, - magic = decode (addr + 0x0033) x, - rupees = decode (addr + 0x0034) x, - sword_health = decode (addr + 0x0036) x, - navi_timer = decode (addr + 0x0038) x, - magic_acquired = decode (addr + 0x003A) x, - double_magic = decode (addr + 0x003C) x, - double_defense = decode (addr + 0x003D) x, - bgs_flag = decode (addr + 0x003E) x, - ocarina_game_reward = decode (addr + 0x003F) x, - child_equips = decode (addr + 0x0040) x, - adult_equips = decode (addr + 0x004A) x, - saved_scene_num = decode (addr + 0x0066) x, - equips = decode (addr + 0x0068) x, - inventory = decode (addr + 0x0074) x - } -end - -instance prettyrecord save_context begin - let name _ = "SaveContext" - let fields (SaveContext x) = - [ - ("entrance_index", S x.entrance_index), - ("link_age", S x.link_age), - ("cutscene_index", S x.cutscene_index), - ("day_time", S x.day_time), - ("night_flag", S x.night_flag), - ("num_days", S x.num_days), - ("claim_days", S x.claim_days), - ("deaths", S x.deaths), - ("n64dd_flag", S x.n64dd_flag), - ("health_capacity", S x.health_capacity), - ("health", S x.health), - ("magic_level", S x.magic_level), - ("magic", S x.magic), - ("rupees", S x.rupees), - ("sword_health", S x.sword_health), - ("navi_timer", S x.navi_timer), - ("magic_acquired", S x.magic_acquired), - ("double_magic", S x.double_magic), - ("double_defense", S x.double_defense), - ("bgs_flag", S x.bgs_flag), - ("ocarina_game_reward", S x.ocarina_game_reward), - ("child_equips", P x.child_equips), - ("adult_equips", P x.adult_equips), - ("saved_scene_num", S x.saved_scene_num), - ("equips", P x.equips), - ("inventory", P x.inventory) - ] -end