From 4852cffa0aa73ad40e30a7a6c97c26f285f2126d Mon Sep 17 00:00:00 2001 From: Aly Date: Tue, 9 Mar 2021 17:04:59 -0800 Subject: [PATCH] This also causes the compiler to enter an infinite loop --- build/oot/main.lua | 493 --------------------------------------------- build/ootAI.lua | 23 --- oot/equipment.ml | 2 - oot/item.ml | 3 + oot/item_equips.ml | 1 - 5 files changed, 3 insertions(+), 519 deletions(-) delete mode 100644 build/oot/main.lua delete mode 100644 build/ootAI.lua diff --git a/build/oot/main.lua b/build/oot/main.lua deleted file mode 100644 index 804531a..0000000 --- a/build/oot/main.lua +++ /dev/null @@ -1,493 +0,0 @@ -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 \ No newline at end of file diff --git a/build/ootAI.lua b/build/ootAI.lua deleted file mode 100644 index a2b9762..0000000 --- a/build/ootAI.lua +++ /dev/null @@ -1,23 +0,0 @@ -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/oot/equipment.ml b/oot/equipment.ml index 5fb1b22..a2b1591 100644 --- a/oot/equipment.ml +++ b/oot/equipment.ml @@ -1,6 +1,4 @@ open import "prelude.ml" -open import "lua/bit.ml" -open Ops open import "../dolphin.ml" open import "../pretty.ml" open import "../mem/decode.ml" diff --git a/oot/item.ml b/oot/item.ml index b39ee47..d077ea2 100644 --- a/oot/item.ml +++ b/oot/item.ml @@ -7,6 +7,7 @@ open import "../mem/int.ml" type item = | DekuSticks | NoItem +| UnknownItem of int instance decode item begin let decode addr = @@ -14,10 +15,12 @@ instance decode item begin match code with | 0 -> DekuSticks | 255 -> NoItem + | x -> UnknownItem x end instance show item begin let show = function | DekuSticks -> "Deku Sticks" | NoItem -> "No Item" + | UnknownItem x -> "Unknown Item " ^ (show x) end diff --git a/oot/item_equips.ml b/oot/item_equips.ml index 018e57a..a4374e3 100644 --- a/oot/item_equips.ml +++ b/oot/item_equips.ml @@ -2,7 +2,6 @@ open import "prelude.ml" open import "../pretty.ml" open import "../mem/decode.ml" open import "../mem/int.ml" -open import "./equipment.ml" open import "./item.ml" type item_equips = ItemEquips of {