diff --git a/.gitignore b/.gitignore index 84f138a..38a0c9d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,3 @@ lua chest test lua movement test -_ootmemod.lua -_anims_seen.lua +* - Copy* diff --git a/Lua/boilerplate.lua b/Lua/boilerplate.lua index a8b7e1b..c0a4e71 100755 --- a/Lua/boilerplate.lua +++ b/Lua/boilerplate.lua @@ -1,6 +1,8 @@ -- boilerplate convenience functions -- TODO: respect little endian consoles too +require "extra" + local mm = mainmemory local m = memory m.usememorydomain("ROM") diff --git a/Lua/data/_anims_seen.lua b/Lua/data/_anims_seen.lua new file mode 100644 index 0000000..060365b --- /dev/null +++ b/Lua/data/_anims_seen.lua @@ -0,0 +1,180 @@ +return { + [53096] = true, + [53104] = true, + [53216] = true, + [53224] = true, + [53352] = true, + [53384] = true, + [53392] = true, + [53400] = true, + [53416] = true, + [53448] = true, + [53456] = true, + [53464] = true, + [53480] = true, + [53488] = true, + [53568] = true, + [53576] = true, + [54024] = true, + [54208] = true, + [54224] = true, + [54344] = true, + [54352] = true, + [54424] = true, + [54432] = true, + [54488] = true, + [54688] = true, + [54696] = true, + [54704] = true, + [54936] = true, + [54944] = true, + [54952] = true, + [55072] = true, + [55080] = true, + [55088] = true, + [55152] = true, + [55168] = true, + [55176] = true, + [55184] = true, + [55208] = true, + [55224] = true, + [55232] = true, + [55240] = true, + [55280] = true, + [55296] = true, + [55384] = true, + [55400] = true, + [55416] = true, + [55440] = true, + [55448] = true, + [55472] = true, + [55496] = true, + [55512] = true, + [55576] = true, + [55584] = true, + [55592] = true, + [55600] = true, + [55608] = true, + [55648] = true, + [55688] = true, + [55696] = true, + [55704] = true, + [55712] = true, + [55904] = true, + [55912] = true, + [55920] = true, + [55928] = true, + [55936] = true, + [56000] = true, + [56016] = true, + [56024] = true, + [56032] = true, + [56040] = true, + [56080] = true, + [56088] = true, + [56104] = true, + [56256] = true, + [56264] = true, + [56304] = true, + [56320] = true, + [56328] = true, + [56368] = true, + [56384] = true, + [56440] = true, + [56448] = true, + [56456] = true, + [56464] = true, + [56512] = true, + [56536] = true, + [56544] = true, + [56552] = true, + [56560] = true, + [56568] = true, + [56592] = true, + [56600] = true, + [56608] = true, + [56616] = true, + [56624] = true, + [56752] = true, + [56760] = true, + [56864] = true, + [56896] = true, + [56904] = true, + [56912] = true, + [56936] = true, + [56944] = true, + [56952] = true, + [56960] = true, + [56968] = true, + [56976] = true, + [56992] = true, + [57000] = true, + [57016] = true, + [57032] = true, + [57040] = true, + [57056] = true, + [57064] = true, + [57096] = true, + [57104] = true, + [57112] = true, + [57120] = true, + [57128] = true, + [57136] = true, + [57160] = true, + [57168] = true, + [57176] = true, + [57184] = true, + [57192] = true, + [57200] = true, + [57288] = true, + [57296] = true, + [57304] = true, + [57312] = true, + [57320] = true, + [57344] = true, + [57360] = true, + [57384] = true, + [57392] = true, + [57408] = true, + [57416] = true, + [57424] = true, + [57456] = true, + [57480] = true, + [57488] = true, + [57496] = true, + [57520] = true, + [57528] = true, + [57560] = true, + [57568] = true, + [57576] = true, + [57584] = true, + [57848] = true, + [57856] = true, + [57864] = true, + [57872] = true, + [57880] = true, + [57896] = true, + [57904] = true, + [57920] = true, + [57928] = true, + [57944] = true, + [57952] = true, + [57968] = true, + [58024] = true, + [58032] = true, + [58080] = true, + [58120] = true, + [58136] = true, + [58144] = true, + [58152] = true, + [58168] = true, + [58184] = true, + [58280] = true, + [58336] = true, + [58344] = true, + [58352] = true, + [58360] = true, + [58368] = true, + [58384] = true, + [58448] = true, +} diff --git a/Lua/data/_ootmemod.lua b/Lua/data/_ootmemod.lua new file mode 100644 index 0000000..4bba4ef --- /dev/null +++ b/Lua/data/_ootmemod.lua @@ -0,0 +1,129 @@ +return { + [0] = true, + [1] = true, + [2] = true, + [3] = true, + [4] = true, + [5] = true, + [6] = true, + [7] = true, + [8] = true, + [10] = true, + [11] = true, + [12] = true, + [13] = true, + [14] = true, + [34] = true, + [35] = true, + [36] = true, + [37] = true, + [38] = true, + [45] = true, + [126] = true, + [129] = true, + [187] = true, + [190] = true, + [288] = true, + [289] = true, + [290] = true, + [291] = true, + [292] = true, + [293] = true, + [294] = true, + [295] = true, + [296] = true, + [297] = true, + [298] = true, + [299] = true, + [300] = true, + [301] = true, + [302] = true, + [303] = true, + [304] = true, + [305] = true, + [307] = true, + [308] = true, + [309] = true, + [532] = true, + [533] = true, + [534] = true, + [535] = true, + [575] = true, + [576] = true, + [578] = true, + [584] = true, + [591] = true, + [592] = true, + [593] = true, + [598] = true, + [599] = true, + [607] = true, + [647] = true, + [648] = true, + [651] = true, + [930] = true, + [933] = true, + [967] = true, + [968] = true, + [1075] = true, + [1349] = true, + [1399] = true, + [1400] = true, + [1401] = true, + [1409] = true, + [1411] = true, + [1412] = true, + [1413] = true, + [1416] = true, + [1417] = true, + [1443] = true, + [1444] = true, + [1445] = true, + [1446] = true, + [1447] = true, + [1448] = true, + [1719] = true, + [1720] = true, + [1728] = true, + [1730] = true, + [1735] = true, + [1744] = true, + [1745] = true, + [1757] = true, + [1758] = true, + [1815] = true, + [1818] = true, + [1920] = true, + [1921] = true, + [1922] = true, + [1923] = true, + [1924] = true, + [1925] = true, + [1926] = true, + [1927] = true, + [1928] = true, + [1929] = true, + [1930] = true, + [1931] = true, + [1932] = true, + [1933] = true, + [1934] = true, + [1935] = true, + [1936] = true, + [1937] = true, + [1939] = true, + [1940] = true, + [1941] = true, + [1943] = true, + [1944] = true, + [1965] = true, + [1967] = true, + [1968] = true, + [1969] = true, + [1981] = true, + [1982] = true, + [1983] = true, + [2082] = true, + [2096] = true, + [2098] = true, +} diff --git a/Lua/extra.lua b/Lua/extra.lua new file mode 100644 index 0000000..68e7afb --- /dev/null +++ b/Lua/extra.lua @@ -0,0 +1,38 @@ +function strpad(num, count, pad) + num = tostring(num) + return (pad:rep(count)..num):sub(#num) +end + +function add_zeros(num, count) + return strpad(num, count - 1, '0') +end + +function mixed_sorter(a, b) + a = type(a) == 'number' and add_zeros(a, 16) or tostring(a) + b = type(b) == 'number' and add_zeros(b, 16) or tostring(b) + return a < b +end + +-- loosely based on http://lua-users.org/wiki/SortedIteration +-- the original didn't make use of closures for who knows why +function order_keys(t) + local oi = {} + for key in pairs(t) do + table.insert(oi, key) + end + table.sort(oi, mixed_sorter) + return oi +end + +function opairs(t, cache) + local oi = cache and cache[t] or order_keys(t) + if cache then + cache[t] = oi + end + local i = 0 + return function() + i = i + 1 + local key = oi[i] + if key then return key, t[key] end + end +end diff --git a/Lua/oot memory editor monitor.lua b/Lua/oot memory editor monitor.lua index e7c667a..5eb7d9a 100644 --- a/Lua/oot memory editor monitor.lua +++ b/Lua/oot memory editor monitor.lua @@ -3,6 +3,7 @@ require "addrs.init" require "classes" require "serialize" +local fn = 'data/_ootmemod.lua' local blocknames = { 'R ', 'RS', 'RO', 'RP', 'RQ', 'RM', 'RY', 'RD', @@ -63,12 +64,12 @@ end -- = 5568 bytes (0x15C0) me = ShortMonitor('me', A(0x210A24, 0x15C0)) -me.modified = deserialize('_ootmemod.lua') or {} +me.modified = deserialize(fn) or {} while version == "O EUDB MQ" do me:diff() if me.dirty then - serialize(me.modified, ('_ootmemod.lua')) + serialize(me.modified, (fn)) me.dirty = false end emu.frameadvance() diff --git a/Lua/serialize.lua b/Lua/serialize.lua index 1603d06..819d2df 100644 --- a/Lua/serialize.lua +++ b/Lua/serialize.lua @@ -1,7 +1,7 @@ -- it's simple, dumb, unsafe, incomplete, and it gets the damn job done local type = type -local pairs = pairs +local pairs = opairs or pairs local tostring = tostring local open = io.open local strfmt = string.format