Replace equipment with u16

This commit is contained in:
Aly 2021-03-09 16:39:59 -08:00
parent 2cb81461d8
commit 1628d2ea55
3 changed files with 304 additions and 66 deletions

View file

@ -1,4 +1,9 @@
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 }
@ -13,6 +18,9 @@ do
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)
@ -30,6 +38,7 @@ do
return kne()
end
end
local NoItem = { __tag = "NoItem" }
local function _Typeable_app(pair)
local ta, tb = pair._1[1], pair._2[1]
return {
@ -40,12 +49,12 @@ do
}
end
local string_of_int = tostring
local function _dollardExceptionljv(tmp)
local function _dollardExceptionlln(tmp)
return {
from_exception = function(x)
return Some(x)
end,
["Exception$lae"] = _Typeable_app({
["Exception$law"] = _Typeable_app({
_1 = (function(tmp0)
return _TypeRep({
fingerprint = 271,
@ -67,45 +76,45 @@ do
end
}
end
local function from_exception(mdm, mgf)
local function from_exception(mfe, mhx)
local tmp = (function(tmp)
return _TypeRep({
fingerprint = 304,
name = "user_error"
})
end)()
local x = mgf[2]
local x = mhx[2]
return __eq_type_rep((function()
return mgf[1]["Exception$lae"]
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(mdm)
return function(mgf)
return from_exception(mdm, mgf)
local function from_exception0(mfe)
return function(mhx)
return from_exception(mfe, mhx)
end
end
local function _dollardExceptionmcp(tmp)
local function _dollardExceptionmeh(tmp)
return {
from_exception = from_exception0(tmp),
describe_exception = function(tmp0)
return "User error: " .. tmp0
end,
["Exception$lae"] = (function(tmp0)
["Exception$law"] = (function(tmp0)
return _TypeRep({
fingerprint = 304,
name = "user_error"
})
end)(),
into_exception = function(mgv)
return MkSome(_dollardExceptionmcp(nil))(mgv)
end,
from_exception = from_exception0(tmp)
into_exception = function(min)
return MkSome(_dollardExceptionmeh(nil))(min)
end
}
end
local function _dollarfoldr(ukg)
local function _dollarfoldr(uly)
return function(f)
return function(z)
local function loop(k, x)
@ -126,26 +135,26 @@ do
end
end
end
local _dollardFoldableujg, foldl1, foldl10
_dollardFoldableujg = function(tmp)
local _dollardFoldableuky, foldl1, foldl10
_dollardFoldableuky = function(tmp)
return {
foldl1 = foldl1(tmp),
foldr = _dollarfoldr(tmp),
["Foldable$tre"] = function(f)
["Foldable$tsw"] = function(f)
return function(xs)
local function avi(xss)
local function axa(xss)
if xss.__tag ~= "Cons" then
return Nil
end
local tmp0 = xss[1]
return {
{ _1 = f(tmp0._1), _2 = avi(tmp0._2) },
{ _1 = f(tmp0._1), _2 = axa(tmp0._2) },
__tag = "Cons"
}
end
return avi(xs)
return axa(xs)
end
end,
foldl1 = foldl1(tmp),
foldr = _dollarfoldr(tmp),
foldl = function(f)
local function loop(z)
return function(x)
@ -158,25 +167,25 @@ do
end
}
end
foldl1 = function(ukg)
return function(uvw)
return function(uvx)
return foldl10(ukg, uvw, uvx)
foldl1 = function(uly)
return function(uxo)
return function(uxp)
return foldl10(uly, uxo, uxp)
end
end
end
foldl10 = function(ukg, uvw, uvx)
local tmp = _dollardFoldableujg(nil).foldl(function(m)
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(uvw(m[1])(y))
return Some(uxo(m[1])(y))
end
end)(None)(uvx)
end)(None)(uxp)
if tmp.__tag == "None" then
return error(setmetatable(_dollardExceptionmcp(nil).into_exception("foldl1: empty structure"), {
__tostring = _dollardExceptionljv(nil).describe_exception
return error(setmetatable(_dollardExceptionmeh(nil).into_exception("foldl1: empty structure"), {
__tostring = _dollardExceptionlln(nil).describe_exception
}))
end
return tmp[1]
@ -184,17 +193,18 @@ do
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(agyo, a, w)
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 = agyo.fields(a)
local rf = ahag.fields(a)
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)
local name = f._1
local field = f._2
@ -205,6 +215,250 @@ do
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
@ -212,34 +466,14 @@ do
return nil
end
local function onScriptUpdate(tmp)
local u16 = read_value_16(17295140)
local function tmp0(save_ctx)
return set_screen_text(pretty_from_record({
fields = function(tmp0)
return {
{
_2 = Nil,
_1 = {
_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 })
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

View file

@ -38,6 +38,10 @@ instance show u16 begin
let show (U16 x) = (show x) ^ "_u16"
end
instance decode u16 begin
let decode addr = U16 (Dolphin.read_value_16 addr)
end
type s16 =
S16 of int

View file

@ -13,7 +13,7 @@ type item_equips = ItemEquips of {
button_slot_c_left: u8,
button_slot_c_down: u8,
button_slot_c_right: u8,
equipment: equipment
equipment: u16
}
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_down", S x.button_slot_c_down),
("button_slot_c_right", S x.button_slot_c_right),
("equipment", P x.equipment)
("equipment", S x.equipment)
]
end