493 lines
14 KiB
Lua
493 lines
14 KiB
Lua
do
|
|
local function P(a)
|
|
return function(b)
|
|
return { __tag = "P", a, b }
|
|
end
|
|
end
|
|
local function S(a)
|
|
return function(b)
|
|
return { __tag = "S", a, b }
|
|
end
|
|
end
|
|
local function MkSome(a)
|
|
return function(b)
|
|
return { __tag = "MkSome", a, b }
|
|
end
|
|
end
|
|
local Proxy = { __tag = "Proxy" }
|
|
local function Some(a)
|
|
return { __tag = "Some", a }
|
|
end
|
|
local DekuSticks = {
|
|
__tag = "DekuSticks"
|
|
}
|
|
local Nil = { __tag = "Nil" }
|
|
local None = { __tag = "None" }
|
|
local function _TypeRep(x)
|
|
return {
|
|
{
|
|
name = x.name .. "#" .. x.fingerprint
|
|
},
|
|
__tag = "TypeRep"
|
|
}
|
|
end
|
|
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 NoItem = { __tag = "NoItem" }
|
|
local function _Typeable_app(pair)
|
|
local ta, tb = pair._1[1], pair._2[1]
|
|
return {
|
|
{
|
|
name = "(" .. ta.name .. ") :$ (" .. tb.name .. ")"
|
|
},
|
|
__tag = "TypeRep"
|
|
}
|
|
end
|
|
local string_of_int = tostring
|
|
local function _dollardExceptionlln(tmp)
|
|
return {
|
|
from_exception = function(x)
|
|
return Some(x)
|
|
end,
|
|
["Exception$law"] = _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(mfe, mhx)
|
|
local tmp = (function(tmp)
|
|
return _TypeRep({
|
|
fingerprint = 304,
|
|
name = "user_error"
|
|
})
|
|
end)()
|
|
local x = mhx[2]
|
|
return __eq_type_rep((function()
|
|
return mhx[1]["Exception$law"]
|
|
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(mfe)
|
|
return function(mhx)
|
|
return from_exception(mfe, mhx)
|
|
end
|
|
end
|
|
local function _dollardExceptionmeh(tmp)
|
|
return {
|
|
from_exception = from_exception0(tmp),
|
|
describe_exception = function(tmp0)
|
|
return "User error: " .. tmp0
|
|
end,
|
|
["Exception$law"] = (function(tmp0)
|
|
return _TypeRep({
|
|
fingerprint = 304,
|
|
name = "user_error"
|
|
})
|
|
end)(),
|
|
into_exception = function(min)
|
|
return MkSome(_dollardExceptionmeh(nil))(min)
|
|
end
|
|
}
|
|
end
|
|
local function _dollarfoldr(uly)
|
|
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 _dollardFoldableuky, foldl1, foldl10
|
|
_dollardFoldableuky = function(tmp)
|
|
return {
|
|
["Foldable$tsw"] = function(f)
|
|
return function(xs)
|
|
local function axa(xss)
|
|
if xss.__tag ~= "Cons" then
|
|
return Nil
|
|
end
|
|
local tmp0 = xss[1]
|
|
return {
|
|
{ _1 = f(tmp0._1), _2 = axa(tmp0._2) },
|
|
__tag = "Cons"
|
|
}
|
|
end
|
|
return axa(xs)
|
|
end
|
|
end,
|
|
foldl1 = foldl1(tmp),
|
|
foldr = _dollarfoldr(tmp),
|
|
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(uly)
|
|
return function(uxo)
|
|
return function(uxp)
|
|
return foldl10(uly, uxo, uxp)
|
|
end
|
|
end
|
|
end
|
|
foldl10 = function(uly, uxo, uxp)
|
|
local tmp = _dollardFoldableuky(nil).foldl(function(m)
|
|
return function(y)
|
|
if m.__tag == "None" then
|
|
return Some(y)
|
|
end
|
|
return Some(uxo(m[1])(y))
|
|
end
|
|
end)(None)(uxp)
|
|
if tmp.__tag == "None" then
|
|
return error(setmetatable(_dollardExceptionmeh(nil).into_exception("foldl1: empty structure"), {
|
|
__tostring = _dollardExceptionlln(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 set_screen_text = SetScreenText
|
|
local function pretty_from_record(ahag, 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 = ahag.fields(a)
|
|
local x = w + 2
|
|
return ahag.name(a) .. " {\n" .. _dollardFoldableuky(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(ahag)
|
|
return function(a)
|
|
return function(w)
|
|
return pretty_from_record(ahag, a, w)
|
|
end
|
|
end
|
|
end
|
|
local function _dollardecode(akdt, addr)
|
|
local code = read_value_8(addr)
|
|
local function tmp(tmp)
|
|
local function tmp0(tmp0)
|
|
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 = read_value_16(addr + 8),
|
|
button_item_b = tmp,
|
|
button_item_c_left = tmp0,
|
|
button_item_c_down = tmp1,
|
|
button_item_c_right = DekuSticks
|
|
}
|
|
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 = read_value_16(addr + 8),
|
|
button_item_b = tmp,
|
|
button_item_c_left = tmp0,
|
|
button_item_c_down = tmp1,
|
|
button_item_c_right = NoItem
|
|
}
|
|
else
|
|
return error("Pattern matching failure in match expression at oot\\item.ml[14:5 ..16:19]")
|
|
end
|
|
end
|
|
local code = read_value_8(addr + 2)
|
|
if code == 0 then
|
|
return tmp1(DekuSticks)
|
|
elseif code == 255 then
|
|
return tmp1(NoItem)
|
|
else
|
|
return error("Pattern matching failure in match expression at oot\\item.ml[14:5 ..16:19]")
|
|
end
|
|
end
|
|
local code = read_value_8(addr + 1)
|
|
if code == 0 then
|
|
return tmp0(DekuSticks)
|
|
elseif code == 255 then
|
|
return tmp0(NoItem)
|
|
else
|
|
return error("Pattern matching failure in match expression at oot\\item.ml[14:5 ..16:19]")
|
|
end
|
|
end
|
|
if code == 0 then
|
|
return tmp(DekuSticks)
|
|
elseif code == 255 then
|
|
return tmp(NoItem)
|
|
else
|
|
return error("Pattern matching failure in match expression at oot\\item.ml[14:5 ..16:19]")
|
|
end
|
|
end
|
|
local function _dollarfields(akjr, tmp)
|
|
return {
|
|
{
|
|
_2 = {
|
|
{
|
|
_1 = {
|
|
_1 = "button_item_c_left",
|
|
_2 = S(function(x)
|
|
if x.__tag == "NoItem" then
|
|
return "No Item"
|
|
end
|
|
return "Deku Sticks"
|
|
end)(tmp.button_item_c_left)
|
|
},
|
|
_2 = {
|
|
{
|
|
_2 = {
|
|
{
|
|
_2 = {
|
|
{
|
|
_1 = {
|
|
_1 = "button_slot_c_left",
|
|
_2 = S(function(tmp0)
|
|
return string_of_int(tmp0) .. "_u8"
|
|
end)(tmp.button_slot_c_left)
|
|
},
|
|
_2 = {
|
|
{
|
|
_1 = {
|
|
_1 = "button_slot_c_down",
|
|
_2 = S(function(tmp0)
|
|
return string_of_int(tmp0) .. "_u8"
|
|
end)(tmp.button_slot_c_down)
|
|
},
|
|
_2 = {
|
|
{
|
|
_2 = {
|
|
{
|
|
_2 = Nil,
|
|
_1 = {
|
|
_1 = "equipment",
|
|
_2 = S(function(tmp0)
|
|
return string_of_int(tmp0) .. "_u16"
|
|
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"
|
|
}
|
|
},
|
|
__tag = "Cons"
|
|
}
|
|
},
|
|
__tag = "Cons"
|
|
},
|
|
_1 = {
|
|
_1 = "button_item_c_right",
|
|
_2 = S(function(x)
|
|
if x.__tag == "NoItem" then
|
|
return "No Item"
|
|
end
|
|
return "Deku Sticks"
|
|
end)(tmp.button_item_c_right)
|
|
}
|
|
},
|
|
__tag = "Cons"
|
|
},
|
|
_1 = {
|
|
_1 = "button_item_c_down",
|
|
_2 = S(function(x)
|
|
if x.__tag == "NoItem" then
|
|
return "No Item"
|
|
end
|
|
return "Deku Sticks"
|
|
end)(tmp.button_item_c_down)
|
|
}
|
|
},
|
|
__tag = "Cons"
|
|
}
|
|
},
|
|
__tag = "Cons"
|
|
},
|
|
_1 = {
|
|
_1 = "button_item_b",
|
|
_2 = S(function(x)
|
|
if x.__tag == "NoItem" then
|
|
return "No Item"
|
|
end
|
|
return "Deku Sticks"
|
|
end)(tmp.button_item_b)
|
|
}
|
|
},
|
|
__tag = "Cons"
|
|
}
|
|
end
|
|
local function _dollardecode0(aksh, addr)
|
|
local u16 = read_value_16(addr + 52)
|
|
if u16 > 32767 then
|
|
return {
|
|
child_equips = _dollardecode(nil, addr + 64),
|
|
adult_equips = _dollardecode(nil, addr + 74),
|
|
equips = _dollardecode(nil, addr + 104),
|
|
rupees = 0 - (65536 - u16)
|
|
}
|
|
end
|
|
return {
|
|
rupees = u16,
|
|
child_equips = _dollardecode(nil, addr + 64),
|
|
adult_equips = _dollardecode(nil, addr + 74),
|
|
equips = _dollardecode(nil, addr + 104)
|
|
}
|
|
end
|
|
local function _dollarfields0(akwb, tmp)
|
|
local function tmp0(tmp0)
|
|
return _dollarfields(nil, tmp0)
|
|
end
|
|
return {
|
|
{
|
|
_2 = {
|
|
{
|
|
_2 = {
|
|
{
|
|
_1 = {
|
|
_1 = "adult_equips",
|
|
_2 = P(pretty_from_record0({
|
|
fields = tmp0,
|
|
name = function(tmp1)
|
|
return "ItemEquips"
|
|
end
|
|
}))(tmp.adult_equips)
|
|
},
|
|
_2 = {
|
|
{
|
|
_1 = {
|
|
_1 = "equips",
|
|
_2 = P(pretty_from_record0({
|
|
fields = tmp0,
|
|
name = function(tmp1)
|
|
return "ItemEquips"
|
|
end
|
|
}))(tmp.equips)
|
|
},
|
|
_2 = Nil
|
|
},
|
|
__tag = "Cons"
|
|
}
|
|
},
|
|
__tag = "Cons"
|
|
},
|
|
_1 = {
|
|
_1 = "child_equips",
|
|
_2 = P(pretty_from_record0({
|
|
fields = tmp0,
|
|
name = function(tmp0)
|
|
return "ItemEquips"
|
|
end
|
|
}))(tmp.child_equips)
|
|
}
|
|
},
|
|
__tag = "Cons"
|
|
},
|
|
_1 = {
|
|
_1 = "rupees",
|
|
_2 = S(function(tmp0)
|
|
return string_of_int(tmp0) .. "_s16"
|
|
end)(tmp.rupees)
|
|
}
|
|
},
|
|
__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 _dollarfields0(nil, tmp0)
|
|
end,
|
|
name = function(tmp0)
|
|
return "SaveContext"
|
|
end
|
|
}, _dollardecode0(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 |