Replace equipment with u16
This commit is contained in:
parent
2cb81461d8
commit
1628d2ea55
|
@ -1,4 +1,9 @@
|
||||||
do
|
do
|
||||||
|
local function P(a)
|
||||||
|
return function(b)
|
||||||
|
return { __tag = "P", a, b }
|
||||||
|
end
|
||||||
|
end
|
||||||
local function S(a)
|
local function S(a)
|
||||||
return function(b)
|
return function(b)
|
||||||
return { __tag = "S", a, b }
|
return { __tag = "S", a, b }
|
||||||
|
@ -13,6 +18,9 @@ do
|
||||||
local function Some(a)
|
local function Some(a)
|
||||||
return { __tag = "Some", a }
|
return { __tag = "Some", a }
|
||||||
end
|
end
|
||||||
|
local DekuSticks = {
|
||||||
|
__tag = "DekuSticks"
|
||||||
|
}
|
||||||
local Nil = { __tag = "Nil" }
|
local Nil = { __tag = "Nil" }
|
||||||
local None = { __tag = "None" }
|
local None = { __tag = "None" }
|
||||||
local function _TypeRep(x)
|
local function _TypeRep(x)
|
||||||
|
@ -30,6 +38,7 @@ do
|
||||||
return kne()
|
return kne()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
local NoItem = { __tag = "NoItem" }
|
||||||
local function _Typeable_app(pair)
|
local function _Typeable_app(pair)
|
||||||
local ta, tb = pair._1[1], pair._2[1]
|
local ta, tb = pair._1[1], pair._2[1]
|
||||||
return {
|
return {
|
||||||
|
@ -40,12 +49,12 @@ do
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
local string_of_int = tostring
|
local string_of_int = tostring
|
||||||
local function _dollardExceptionljv(tmp)
|
local function _dollardExceptionlln(tmp)
|
||||||
return {
|
return {
|
||||||
from_exception = function(x)
|
from_exception = function(x)
|
||||||
return Some(x)
|
return Some(x)
|
||||||
end,
|
end,
|
||||||
["Exception$lae"] = _Typeable_app({
|
["Exception$law"] = _Typeable_app({
|
||||||
_1 = (function(tmp0)
|
_1 = (function(tmp0)
|
||||||
return _TypeRep({
|
return _TypeRep({
|
||||||
fingerprint = 271,
|
fingerprint = 271,
|
||||||
|
@ -67,45 +76,45 @@ do
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
local function from_exception(mdm, mgf)
|
local function from_exception(mfe, mhx)
|
||||||
local tmp = (function(tmp)
|
local tmp = (function(tmp)
|
||||||
return _TypeRep({
|
return _TypeRep({
|
||||||
fingerprint = 304,
|
fingerprint = 304,
|
||||||
name = "user_error"
|
name = "user_error"
|
||||||
})
|
})
|
||||||
end)()
|
end)()
|
||||||
local x = mgf[2]
|
local x = mhx[2]
|
||||||
return __eq_type_rep((function()
|
return __eq_type_rep((function()
|
||||||
return mgf[1]["Exception$lae"]
|
return mhx[1]["Exception$law"]
|
||||||
end)(Proxy), (function()
|
end)(Proxy), (function()
|
||||||
return tmp
|
return tmp
|
||||||
end)(Proxy), function(tmp0)
|
end)(Proxy), function(tmp0)
|
||||||
return function(tmp1) return Some(x) end
|
return function(tmp1) return Some(x) end
|
||||||
end, function(tmp0) return None end)
|
end, function(tmp0) return None end)
|
||||||
end
|
end
|
||||||
local function from_exception0(mdm)
|
local function from_exception0(mfe)
|
||||||
return function(mgf)
|
return function(mhx)
|
||||||
return from_exception(mdm, mgf)
|
return from_exception(mfe, mhx)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
local function _dollardExceptionmcp(tmp)
|
local function _dollardExceptionmeh(tmp)
|
||||||
return {
|
return {
|
||||||
|
from_exception = from_exception0(tmp),
|
||||||
describe_exception = function(tmp0)
|
describe_exception = function(tmp0)
|
||||||
return "User error: " .. tmp0
|
return "User error: " .. tmp0
|
||||||
end,
|
end,
|
||||||
["Exception$lae"] = (function(tmp0)
|
["Exception$law"] = (function(tmp0)
|
||||||
return _TypeRep({
|
return _TypeRep({
|
||||||
fingerprint = 304,
|
fingerprint = 304,
|
||||||
name = "user_error"
|
name = "user_error"
|
||||||
})
|
})
|
||||||
end)(),
|
end)(),
|
||||||
into_exception = function(mgv)
|
into_exception = function(min)
|
||||||
return MkSome(_dollardExceptionmcp(nil))(mgv)
|
return MkSome(_dollardExceptionmeh(nil))(min)
|
||||||
end,
|
end
|
||||||
from_exception = from_exception0(tmp)
|
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
local function _dollarfoldr(ukg)
|
local function _dollarfoldr(uly)
|
||||||
return function(f)
|
return function(f)
|
||||||
return function(z)
|
return function(z)
|
||||||
local function loop(k, x)
|
local function loop(k, x)
|
||||||
|
@ -126,26 +135,26 @@ do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
local _dollardFoldableujg, foldl1, foldl10
|
local _dollardFoldableuky, foldl1, foldl10
|
||||||
_dollardFoldableujg = function(tmp)
|
_dollardFoldableuky = function(tmp)
|
||||||
return {
|
return {
|
||||||
foldl1 = foldl1(tmp),
|
["Foldable$tsw"] = function(f)
|
||||||
foldr = _dollarfoldr(tmp),
|
|
||||||
["Foldable$tre"] = function(f)
|
|
||||||
return function(xs)
|
return function(xs)
|
||||||
local function avi(xss)
|
local function axa(xss)
|
||||||
if xss.__tag ~= "Cons" then
|
if xss.__tag ~= "Cons" then
|
||||||
return Nil
|
return Nil
|
||||||
end
|
end
|
||||||
local tmp0 = xss[1]
|
local tmp0 = xss[1]
|
||||||
return {
|
return {
|
||||||
{ _1 = f(tmp0._1), _2 = avi(tmp0._2) },
|
{ _1 = f(tmp0._1), _2 = axa(tmp0._2) },
|
||||||
__tag = "Cons"
|
__tag = "Cons"
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
return avi(xs)
|
return axa(xs)
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
foldl1 = foldl1(tmp),
|
||||||
|
foldr = _dollarfoldr(tmp),
|
||||||
foldl = function(f)
|
foldl = function(f)
|
||||||
local function loop(z)
|
local function loop(z)
|
||||||
return function(x)
|
return function(x)
|
||||||
|
@ -158,25 +167,25 @@ do
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
foldl1 = function(ukg)
|
foldl1 = function(uly)
|
||||||
return function(uvw)
|
return function(uxo)
|
||||||
return function(uvx)
|
return function(uxp)
|
||||||
return foldl10(ukg, uvw, uvx)
|
return foldl10(uly, uxo, uxp)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
foldl10 = function(ukg, uvw, uvx)
|
foldl10 = function(uly, uxo, uxp)
|
||||||
local tmp = _dollardFoldableujg(nil).foldl(function(m)
|
local tmp = _dollardFoldableuky(nil).foldl(function(m)
|
||||||
return function(y)
|
return function(y)
|
||||||
if m.__tag == "None" then
|
if m.__tag == "None" then
|
||||||
return Some(y)
|
return Some(y)
|
||||||
end
|
end
|
||||||
return Some(uvw(m[1])(y))
|
return Some(uxo(m[1])(y))
|
||||||
end
|
end
|
||||||
end)(None)(uvx)
|
end)(None)(uxp)
|
||||||
if tmp.__tag == "None" then
|
if tmp.__tag == "None" then
|
||||||
return error(setmetatable(_dollardExceptionmcp(nil).into_exception("foldl1: empty structure"), {
|
return error(setmetatable(_dollardExceptionmeh(nil).into_exception("foldl1: empty structure"), {
|
||||||
__tostring = _dollardExceptionljv(nil).describe_exception
|
__tostring = _dollardExceptionlln(nil).describe_exception
|
||||||
}))
|
}))
|
||||||
end
|
end
|
||||||
return tmp[1]
|
return tmp[1]
|
||||||
|
@ -184,17 +193,18 @@ do
|
||||||
local io_stdout = io.stdout
|
local io_stdout = io.stdout
|
||||||
local io_stderr = io.stderr
|
local io_stderr = io.stderr
|
||||||
local io_stdin = io.stdin
|
local io_stdin = io.stdin
|
||||||
|
local read_value_8 = ReadValue8
|
||||||
local read_value_16 = ReadValue16
|
local read_value_16 = ReadValue16
|
||||||
local set_screen_text = SetScreenText
|
local set_screen_text = SetScreenText
|
||||||
local function pretty_from_record(agyo, a, w)
|
local function pretty_from_record(ahag, a, w)
|
||||||
local function smul(s, n)
|
local function smul(s, n)
|
||||||
if n <= 0 then return "" end
|
if n <= 0 then return "" end
|
||||||
return s .. smul(s, n - 1)
|
return s .. smul(s, n - 1)
|
||||||
end
|
end
|
||||||
local prep = smul(" ", w)
|
local prep = smul(" ", w)
|
||||||
local rf = agyo.fields(a)
|
local rf = ahag.fields(a)
|
||||||
local x = w + 2
|
local x = w + 2
|
||||||
return agyo.name(a) .. " {\n" .. _dollardFoldableujg(nil).foldl(function(acc)
|
return ahag.name(a) .. " {\n" .. _dollardFoldableuky(nil).foldl(function(acc)
|
||||||
return function(f)
|
return function(f)
|
||||||
local name = f._1
|
local name = f._1
|
||||||
local field = f._2
|
local field = f._2
|
||||||
|
@ -205,6 +215,250 @@ do
|
||||||
end
|
end
|
||||||
end)("")(rf) .. prep .. "}"
|
end)("")(rf) .. prep .. "}"
|
||||||
end
|
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)
|
local function onScriptStart(tmp)
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
@ -212,34 +466,14 @@ do
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
local function onScriptUpdate(tmp)
|
local function onScriptUpdate(tmp)
|
||||||
local u16 = read_value_16(17295140)
|
return set_screen_text(pretty_from_record({
|
||||||
local function tmp0(save_ctx)
|
fields = function(tmp0)
|
||||||
return set_screen_text(pretty_from_record({
|
return _dollarfields0(nil, tmp0)
|
||||||
fields = function(tmp0)
|
end,
|
||||||
return {
|
name = function(tmp0)
|
||||||
{
|
return "SaveContext"
|
||||||
_2 = Nil,
|
end
|
||||||
_1 = {
|
}, _dollardecode0(nil, 17295088), 0))
|
||||||
_1 = "rupees",
|
|
||||||
_2 = S(function(tmp1)
|
|
||||||
return string_of_int(tmp1) .. "_s16"
|
|
||||||
end)(tmp0.rupees)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
__tag = "Cons"
|
|
||||||
}
|
|
||||||
end,
|
|
||||||
name = function(tmp0)
|
|
||||||
return "SaveContext"
|
|
||||||
end
|
|
||||||
}, save_ctx, 0))
|
|
||||||
end
|
|
||||||
if u16 > 32767 then
|
|
||||||
return tmp0({
|
|
||||||
rupees = 0 - (65536 - u16)
|
|
||||||
})
|
|
||||||
end
|
|
||||||
return tmp0({ rupees = u16 })
|
|
||||||
end
|
end
|
||||||
local function onStateLoaded(tmp)
|
local function onStateLoaded(tmp)
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -38,6 +38,10 @@ instance show u16 begin
|
||||||
let show (U16 x) = (show x) ^ "_u16"
|
let show (U16 x) = (show x) ^ "_u16"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
instance decode u16 begin
|
||||||
|
let decode addr = U16 (Dolphin.read_value_16 addr)
|
||||||
|
end
|
||||||
|
|
||||||
type s16 =
|
type s16 =
|
||||||
S16 of int
|
S16 of int
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@ type item_equips = ItemEquips of {
|
||||||
button_slot_c_left: u8,
|
button_slot_c_left: u8,
|
||||||
button_slot_c_down: u8,
|
button_slot_c_down: u8,
|
||||||
button_slot_c_right: u8,
|
button_slot_c_right: u8,
|
||||||
equipment: equipment
|
equipment: u16
|
||||||
}
|
}
|
||||||
|
|
||||||
instance decode item_equips begin
|
instance decode item_equips begin
|
||||||
|
@ -40,7 +40,7 @@ instance prettyrecord item_equips begin
|
||||||
("button_slot_c_left", S x.button_slot_c_left),
|
("button_slot_c_left", S x.button_slot_c_left),
|
||||||
("button_slot_c_down", S x.button_slot_c_down),
|
("button_slot_c_down", S x.button_slot_c_down),
|
||||||
("button_slot_c_right", S x.button_slot_c_right),
|
("button_slot_c_right", S x.button_slot_c_right),
|
||||||
("equipment", P x.equipment)
|
("equipment", S x.equipment)
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue