mirror of
https://github.com/notwa/mm
synced 2024-05-18 13:23:23 -07:00
be super strict about globals
theres still a lot of work to do\nsince most scripts just set globals explicitly\nthis is still better than implied globals though
This commit is contained in:
parent
072e8c7a7a
commit
1acbaba58c
|
@ -43,7 +43,14 @@ local function save()
|
||||||
serialize(fn, saved)
|
serialize(fn, saved)
|
||||||
end
|
end
|
||||||
|
|
||||||
function Setter(t)
|
local fades_killed = false
|
||||||
|
|
||||||
|
local function set(f, v)
|
||||||
|
-- wrapper for addresses that *might* be undefined
|
||||||
|
if f then f(v) end
|
||||||
|
end
|
||||||
|
|
||||||
|
local function Setter(t)
|
||||||
return function()
|
return function()
|
||||||
for func, value in pairs(t) do
|
for func, value in pairs(t) do
|
||||||
func(value)
|
func(value)
|
||||||
|
@ -53,7 +60,7 @@ end
|
||||||
|
|
||||||
local passives = {}
|
local passives = {}
|
||||||
|
|
||||||
Passive = Class(Callbacks)
|
local Passive = Class(Callbacks)
|
||||||
function Passive:init(...)
|
function Passive:init(...)
|
||||||
Callbacks.init(self, ...)
|
Callbacks.init(self, ...)
|
||||||
table.insert(passives, self)
|
table.insert(passives, self)
|
||||||
|
@ -208,7 +215,7 @@ end
|
||||||
|
|
||||||
local function timestop()
|
local function timestop()
|
||||||
-- doesn't set it up quite like the glitch, but this is the main effect
|
-- doesn't set it up quite like the glitch, but this is the main effect
|
||||||
set(timestop, 4) -- normally -1
|
set(addrs.timestop, 4) -- normally -1
|
||||||
end
|
end
|
||||||
|
|
||||||
local time_menu = oot and Menu{
|
local time_menu = oot and Menu{
|
||||||
|
@ -246,6 +253,11 @@ local time_menu = oot and Menu{
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
globalize{
|
||||||
|
Setter = Setter,
|
||||||
|
Passive = Passive,
|
||||||
|
reload_scene = reload_scene,
|
||||||
|
}
|
||||||
local warp_menu = require "menus.warp"
|
local warp_menu = require "menus.warp"
|
||||||
local progress_menu = require "menus.progress"
|
local progress_menu = require "menus.progress"
|
||||||
local playas_menu = require "menus.playas"
|
local playas_menu = require "menus.playas"
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
|
require "lib.setup"
|
||||||
|
require "boilerplate"
|
||||||
require "addrs"
|
require "addrs"
|
||||||
|
|
||||||
-- precalculate hamming weights of bytes
|
-- precalculate hamming weights of bytes
|
||||||
hamming_weight = {}
|
local hamming_weight = {}
|
||||||
for i = 0, 255 do
|
for i = 0, 255 do
|
||||||
local w = 0
|
local w = 0
|
||||||
for b = 0, 7 do
|
for b = 0, 7 do
|
||||||
|
@ -10,9 +12,9 @@ for i = 0, 255 do
|
||||||
hamming_weight[i] = w
|
hamming_weight[i] = w
|
||||||
end
|
end
|
||||||
|
|
||||||
function hamming_of(addr, size)
|
local function hamming_of(addr, size)
|
||||||
weight = 0
|
local weight = 0
|
||||||
bytes = mainmemory.readbyterange(addr, size)
|
local bytes = mainmemory.readbyterange(addr, size)
|
||||||
for k,v in pairs(bytes) do
|
for k,v in pairs(bytes) do
|
||||||
if v ~= 0 then
|
if v ~= 0 then
|
||||||
weight = weight + hamming_weight[tonumber(v, 16)]
|
weight = weight + hamming_weight[tonumber(v, 16)]
|
||||||
|
@ -21,7 +23,7 @@ function hamming_of(addr, size)
|
||||||
return weight
|
return weight
|
||||||
end
|
end
|
||||||
|
|
||||||
function hamming_of_A(a)
|
local function hamming_of_A(a)
|
||||||
return hamming_of(a.addr, a.type)
|
return hamming_of(a.addr, a.type)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
require "lib.setup"
|
require "lib.setup"
|
||||||
require "boilerplate"
|
require "boilerplate"
|
||||||
require "addrs"
|
local addrs = require "addrs"
|
||||||
require "messages"
|
require "messages"
|
||||||
require = depend
|
|
||||||
local assemble = require "lips"
|
local assemble = require "lips"
|
||||||
|
|
||||||
local injection_points = {
|
local injection_points = {
|
||||||
|
@ -67,7 +66,7 @@ local hook = [[
|
||||||
start:
|
start:
|
||||||
]]
|
]]
|
||||||
|
|
||||||
function inject(fn)
|
local function inject(fn)
|
||||||
local asm_dir = bizstring and 'inject/' or './mm/Lua/inject/'
|
local asm_dir = bizstring and 'inject/' or './mm/Lua/inject/'
|
||||||
local asm_path = asm_dir..fn
|
local asm_path = asm_dir..fn
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ local validate = false
|
||||||
-- using a template to offset from will do for now.
|
-- using a template to offset from will do for now.
|
||||||
local actor_t = Actor(0)
|
local actor_t = Actor(0)
|
||||||
|
|
||||||
function sort_by_key(t)
|
local function sort_by_key(t)
|
||||||
local sorted = {}
|
local sorted = {}
|
||||||
local i = 1
|
local i = 1
|
||||||
for k, v in pairs(t) do
|
for k, v in pairs(t) do
|
||||||
|
@ -16,23 +16,23 @@ function sort_by_key(t)
|
||||||
return sorted
|
return sorted
|
||||||
end
|
end
|
||||||
|
|
||||||
function get_actor_count(i)
|
local function get_actor_count(i)
|
||||||
return R4(addrs.actor_counts[i].addr)
|
return R4(addrs.actor_counts[i].addr)
|
||||||
end
|
end
|
||||||
|
|
||||||
function get_first_actor(i)
|
local function get_first_actor(i)
|
||||||
return deref(R4(addrs.actor_firsts[i].addr))
|
return deref(R4(addrs.actor_firsts[i].addr))
|
||||||
end
|
end
|
||||||
|
|
||||||
function get_next_actor(addr)
|
local function get_next_actor(addr)
|
||||||
return deref(R4(addr + actor_t.next.addr))
|
return deref(R4(addr + actor_t.next.addr))
|
||||||
end
|
end
|
||||||
|
|
||||||
function get_prev_actor(addr)
|
local function get_prev_actor(addr)
|
||||||
return deref(R4(addr + actor_t.prev.addr))
|
return deref(R4(addr + actor_t.prev.addr))
|
||||||
end
|
end
|
||||||
|
|
||||||
function count_actors()
|
local function count_actors()
|
||||||
local counts = {}
|
local counts = {}
|
||||||
for i = 0, 11 do
|
for i = 0, 11 do
|
||||||
counts[i] = get_actor_count(i)
|
counts[i] = get_actor_count(i)
|
||||||
|
@ -40,7 +40,7 @@ function count_actors()
|
||||||
return counts
|
return counts
|
||||||
end
|
end
|
||||||
|
|
||||||
function iter_actors(counts)
|
local function iter_actors(counts)
|
||||||
local at, ai = 0, 0
|
local at, ai = 0, 0
|
||||||
local addr
|
local addr
|
||||||
|
|
||||||
|
@ -92,7 +92,7 @@ function iter_actors(counts)
|
||||||
return iterate
|
return iterate
|
||||||
end
|
end
|
||||||
|
|
||||||
function collect_actors()
|
local function collect_actors()
|
||||||
local game_counts = count_actors()
|
local game_counts = count_actors()
|
||||||
local any = 0
|
local any = 0
|
||||||
for i = 0, 11 do
|
for i = 0, 11 do
|
||||||
|
@ -113,3 +113,14 @@ function collect_actors()
|
||||||
end
|
end
|
||||||
return any > 0, actors_by_type, new_counts
|
return any > 0, actors_by_type, new_counts
|
||||||
end
|
end
|
||||||
|
|
||||||
|
return globalize{
|
||||||
|
sort_by_key = sort_by_key,
|
||||||
|
get_actor_count = get_actor_count,
|
||||||
|
get_first_actor = get_first_actor,
|
||||||
|
get_next_actor = get_next_actor,
|
||||||
|
get_prev_actor = get_prev_actor,
|
||||||
|
count_actors = count_actors,
|
||||||
|
iter_actors = iter_actors,
|
||||||
|
collect_actors = collect_actors,
|
||||||
|
}
|
||||||
|
|
|
@ -8,6 +8,8 @@ local same = {
|
||||||
--["O JPGC MQ"] = "O USGC", -- maybe?
|
--["O JPGC MQ"] = "O USGC", -- maybe?
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rawset(_G, 'Actor', function() end)
|
||||||
|
|
||||||
return function(hash)
|
return function(hash)
|
||||||
local version = versions[hash] or VERSION_OVERRIDE
|
local version = versions[hash] or VERSION_OVERRIDE
|
||||||
if version == nil then
|
if version == nil then
|
||||||
|
@ -18,8 +20,8 @@ return function(hash)
|
||||||
local rv = same[version] or version
|
local rv = same[version] or version
|
||||||
|
|
||||||
local b = basics[rv]
|
local b = basics[rv]
|
||||||
function AL(a, s) return A(b.link + a, s) end
|
local function AL(a, s) return A(b.link + a, s) end
|
||||||
function AG(a, s)
|
local function AG(a, s)
|
||||||
if rv == 'M JP10' or rv == 'M JP11' then
|
if rv == 'M JP10' or rv == 'M JP11' then
|
||||||
if a >= 0x17000 then -- approximate
|
if a >= 0x17000 then -- approximate
|
||||||
a = a - 0x20
|
a = a - 0x20
|
||||||
|
@ -27,7 +29,7 @@ return function(hash)
|
||||||
end
|
end
|
||||||
return A(b.global + a, s)
|
return A(b.global + a, s)
|
||||||
end
|
end
|
||||||
function AA(a, s)
|
local function AA(a, s)
|
||||||
if rv == 'O EUDB MQ' then
|
if rv == 'O EUDB MQ' then
|
||||||
if a >= 0x130 then -- approximate
|
if a >= 0x130 then -- approximate
|
||||||
a = a + 0x10
|
a = a + 0x10
|
||||||
|
@ -39,6 +41,10 @@ return function(hash)
|
||||||
local subdir = version:sub(1, 1)
|
local subdir = version:sub(1, 1)
|
||||||
local rvs = rv:sub(3)
|
local rvs = rv:sub(3)
|
||||||
|
|
||||||
|
rawset(_G, 'AL', AL)
|
||||||
|
rawset(_G, 'AG', AG)
|
||||||
|
rawset(_G, 'AA', AA)
|
||||||
|
|
||||||
local addrs = require("addrs."..subdir.."."..rvs)
|
local addrs = require("addrs."..subdir.."."..rvs)
|
||||||
addrs.version = version
|
addrs.version = version
|
||||||
addrs.oot = v == "O "
|
addrs.oot = v == "O "
|
||||||
|
|
|
@ -6,8 +6,12 @@ else
|
||||||
end
|
end
|
||||||
local Game = require "addrs.addrs"
|
local Game = require "addrs.addrs"
|
||||||
local game = Game(hash)
|
local game = Game(hash)
|
||||||
version = game.version
|
|
||||||
oot = game.oot
|
-- TODO: return globalize instead
|
||||||
mm = game.mm
|
globalize{
|
||||||
addrs = game
|
version = game.version,
|
||||||
|
oot = game.oot,
|
||||||
|
mm = game.mm,
|
||||||
|
addrs = game,
|
||||||
|
}
|
||||||
return game
|
return game
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
require "extra"
|
require "extra"
|
||||||
|
|
||||||
|
local R1, R2, R4, RF, W1, W2, W4, WF, X1, X2, X4, XF
|
||||||
|
|
||||||
if bizstring then
|
if bizstring then
|
||||||
local mm = mainmemory
|
local mm = mainmemory
|
||||||
local m = memory
|
local m = memory
|
||||||
|
@ -61,7 +63,7 @@ local mts = {
|
||||||
['f'] = {__call = HF},
|
['f'] = {__call = HF},
|
||||||
}
|
}
|
||||||
|
|
||||||
function A(addr, atype)
|
local function A(addr, atype)
|
||||||
local mt = mts[atype]
|
local mt = mts[atype]
|
||||||
return setmetatable({
|
return setmetatable({
|
||||||
addr=addr,
|
addr=addr,
|
||||||
|
@ -69,7 +71,7 @@ function A(addr, atype)
|
||||||
}, mt)
|
}, mt)
|
||||||
end
|
end
|
||||||
|
|
||||||
Class = function(inherit)
|
local function Class(inherit)
|
||||||
local class = {}
|
local class = {}
|
||||||
local mt_obj = {__index = class}
|
local mt_obj = {__index = class}
|
||||||
local mt_class = {
|
local mt_class = {
|
||||||
|
@ -84,25 +86,25 @@ Class = function(inherit)
|
||||||
return setmetatable(class, mt_class)
|
return setmetatable(class, mt_class)
|
||||||
end
|
end
|
||||||
|
|
||||||
function getindex(obj)
|
local function getindex(obj)
|
||||||
local gm = getmetatable(obj)
|
local gm = getmetatable(obj)
|
||||||
if not gm then return end
|
if not gm then return end
|
||||||
return gm.__index
|
return gm.__index
|
||||||
end
|
end
|
||||||
|
|
||||||
function printf(fmt, ...)
|
local function printf(fmt, ...)
|
||||||
print(fmt:format(...))
|
print(fmt:format(...))
|
||||||
end
|
end
|
||||||
|
|
||||||
function is_ptr(ptr)
|
local function is_ptr(ptr)
|
||||||
return bit.band(0xFF800000, ptr) == 0x80000000
|
return bit.band(0xFF800000, ptr) == 0x80000000
|
||||||
end
|
end
|
||||||
|
|
||||||
function deref(ptr)
|
local function deref(ptr)
|
||||||
return is_ptr(ptr) and ptr - 0x80000000
|
return is_ptr(ptr) and ptr - 0x80000000
|
||||||
end
|
end
|
||||||
|
|
||||||
function asciize(bytes)
|
local function asciize(bytes)
|
||||||
local str = ""
|
local str = ""
|
||||||
local seq = false
|
local seq = false
|
||||||
for i, v in ipairs(bytes) do
|
for i, v in ipairs(bytes) do
|
||||||
|
@ -118,7 +120,7 @@ function asciize(bytes)
|
||||||
return str
|
return str
|
||||||
end
|
end
|
||||||
|
|
||||||
function hex(i)
|
local function hex(i)
|
||||||
-- convenience function for use in console
|
-- convenience function for use in console
|
||||||
if i == nil then
|
if i == nil then
|
||||||
print('nil')
|
print('nil')
|
||||||
|
@ -146,4 +148,22 @@ A(handle.addr + 1, handle.type)(0x00) -- set the byte after our address
|
||||||
A(handle.addr, 2)(0x1234) -- set 2 bytes as opposed to our original 1
|
A(handle.addr, 2)(0x1234) -- set 2 bytes as opposed to our original 1
|
||||||
--]]
|
--]]
|
||||||
|
|
||||||
|
-- TODO: return globalize instead
|
||||||
|
globalize{
|
||||||
|
Class = Class,
|
||||||
|
|
||||||
|
R1 = R1, R2 = R2, R4 = R4,
|
||||||
|
W1 = W1, W2 = W2, W4 = W4,
|
||||||
|
X1 = X1, X2 = X2, X4 = X4,
|
||||||
|
A = A,
|
||||||
|
|
||||||
|
printf = printf,
|
||||||
|
hex = hex,
|
||||||
|
|
||||||
|
is_ptr = is_ptr,
|
||||||
|
deref = deref,
|
||||||
|
asciize = asciize,
|
||||||
|
|
||||||
|
getindex = getindex,
|
||||||
|
}
|
||||||
return A
|
return A
|
||||||
|
|
|
@ -15,5 +15,5 @@ local classes = {
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, class in ipairs(classes) do
|
for _, class in ipairs(classes) do
|
||||||
_G[class] = require("classes."..class)
|
rawset(_G, class, require("classes."..class))
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
local print = dprint or print
|
local print = rawget(_G, 'dprint') or print
|
||||||
|
|
||||||
-- hack to avoid N64 logo spitting errors
|
-- hack to avoid N64 logo spitting errors
|
||||||
local stupid = addrs.actor_counts[0].addr - 0x8
|
local stupid = addrs.actor_counts[0].addr - 0x8
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
local Monitor = require "classes.Monitor"
|
local Monitor = require "classes.Monitor"
|
||||||
local ByteMonitor = Class(Monitor)
|
local ByteMonitor = Class(Monitor)
|
||||||
|
|
||||||
local printf = dprintf or printf
|
local printf = rawget(_G, 'dprintf') or printf
|
||||||
|
|
||||||
function ByteMonitor:mark(i, x, x1)
|
function ByteMonitor:mark(i, x, x1)
|
||||||
if self.ignore and self:ignore(i) then return end
|
if self.ignore and self:ignore(i) then return end
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
local printf = dprintf or printf
|
local printf = rawget(_G, 'dprintf') or printf
|
||||||
|
|
||||||
local Monitor = require "classes.Monitor"
|
local Monitor = require "classes.Monitor"
|
||||||
local FlagMonitor = Class(Monitor)
|
local FlagMonitor = Class(Monitor)
|
||||||
|
|
|
@ -9,7 +9,7 @@ function SceneFlagMonitor:mark(i, x, x1)
|
||||||
if bit.band(diff, 2^which) ~= 0 then
|
if bit.band(diff, 2^which) ~= 0 then
|
||||||
local state = bit.band(x, 2^which) ~= 0 and 1 or 0
|
local state = bit.band(x, 2^which) ~= 0 and 1 or 0
|
||||||
local col = (3 - i)*8 + which
|
local col = (3 - i)*8 + which
|
||||||
str = ('%s: %02i=%i'):format(self.name, col, state)
|
local str = ('%s: %02i=%i'):format(self.name, col, state)
|
||||||
printf('%s @%i', str, now)
|
printf('%s @%i', str, now)
|
||||||
message(str, 180)
|
message(str, 180)
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
function strpad(num, count, pad)
|
local function strpad(num, count, pad)
|
||||||
num = tostring(num)
|
num = tostring(num)
|
||||||
return (pad:rep(count)..num):sub(#num)
|
return (pad:rep(count)..num):sub(#num)
|
||||||
end
|
end
|
||||||
|
|
||||||
function add_zeros(num, count)
|
local function add_zeros(num, count)
|
||||||
return strpad(num, count - 1, '0')
|
return strpad(num, count - 1, '0')
|
||||||
end
|
end
|
||||||
|
|
||||||
function mixed_sorter(a, b)
|
local function mixed_sorter(a, b)
|
||||||
a = type(a) == 'number' and add_zeros(a, 16) or tostring(a)
|
a = type(a) == 'number' and add_zeros(a, 16) or tostring(a)
|
||||||
b = type(b) == 'number' and add_zeros(b, 16) or tostring(b)
|
b = type(b) == 'number' and add_zeros(b, 16) or tostring(b)
|
||||||
return a < b
|
return a < b
|
||||||
|
@ -15,7 +15,7 @@ end
|
||||||
|
|
||||||
-- loosely based on http://lua-users.org/wiki/SortedIteration
|
-- loosely based on http://lua-users.org/wiki/SortedIteration
|
||||||
-- the original didn't make use of closures for who knows why
|
-- the original didn't make use of closures for who knows why
|
||||||
function order_keys(t)
|
local function order_keys(t)
|
||||||
local oi = {}
|
local oi = {}
|
||||||
for key in pairs(t) do
|
for key in pairs(t) do
|
||||||
table.insert(oi, key)
|
table.insert(oi, key)
|
||||||
|
@ -24,7 +24,7 @@ function order_keys(t)
|
||||||
return oi
|
return oi
|
||||||
end
|
end
|
||||||
|
|
||||||
function opairs(t, cache)
|
local function opairs(t, cache)
|
||||||
local oi = cache and cache[t] or order_keys(t)
|
local oi = cache and cache[t] or order_keys(t)
|
||||||
if cache then
|
if cache then
|
||||||
cache[t] = oi
|
cache[t] = oi
|
||||||
|
@ -36,3 +36,11 @@ function opairs(t, cache)
|
||||||
if key then return key, t[key] end
|
if key then return key, t[key] end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
return {
|
||||||
|
strpad = strpad,
|
||||||
|
add_zeros = add_zeros,
|
||||||
|
mixed_sorter = mixed_sorter,
|
||||||
|
order_keys = order_keys,
|
||||||
|
opairs = opairs,
|
||||||
|
}
|
||||||
|
|
|
@ -1,40 +1,51 @@
|
||||||
function scene_flag_get_bb(scene, word, bit_)
|
local function scene_flag_get_bb(scene, word, bit_)
|
||||||
local byte = scene*0x14 + word*4 + math.floor(3 - bit_/8)
|
local byte = scene*0x14 + word*4 + math.floor(3 - bit_/8)
|
||||||
byte = byte + addrs.scene_flags_ingame.addr
|
byte = byte + addrs.scene_flags_ingame.addr
|
||||||
local bitmask = bit.lshift(1, bit_ % 8)
|
local bitmask = bit.lshift(1, bit_ % 8)
|
||||||
return byte, bitmask
|
return byte, bitmask
|
||||||
end
|
end
|
||||||
|
|
||||||
function scene_flag_get(scene, word, bit_)
|
local function scene_flag_get(scene, word, bit_)
|
||||||
local byte, bitmask = scene_flag_get_bb(scene, word, bit_)
|
local byte, bitmask = scene_flag_get_bb(scene, word, bit_)
|
||||||
return bit.band(R1(byte), bitmask) ~= 0
|
return bit.band(R1(byte), bitmask) ~= 0
|
||||||
end
|
end
|
||||||
-- TODO: check if current scene is scene id
|
-- TODO: check if current scene is scene id
|
||||||
-- if it is, adjust scene_flag_current_x so it doesn't overwrite ingame flags
|
-- if it is, adjust scene_flag_current_x so it doesn't overwrite ingame flags
|
||||||
function scene_flag_reset(scene, word, bit_)
|
local function scene_flag_reset(scene, word, bit_)
|
||||||
local byte, bitmask = scene_flag_get_bb(scene, word, bit_)
|
local byte, bitmask = scene_flag_get_bb(scene, word, bit_)
|
||||||
W1(byte, bit.band(R1(byte), 0xFF - bitmask))
|
W1(byte, bit.band(R1(byte), 0xFF - bitmask))
|
||||||
end
|
end
|
||||||
function scene_flag_set(scene, word, bit_)
|
local function scene_flag_set(scene, word, bit_)
|
||||||
local byte, bitmask = scene_flag_get_bb(scene, word, bit_)
|
local byte, bitmask = scene_flag_get_bb(scene, word, bit_)
|
||||||
W1(byte, bit.bor(R1(byte), bitmask))
|
W1(byte, bit.bor(R1(byte), bitmask))
|
||||||
end
|
end
|
||||||
|
|
||||||
function event_flag_get_bb(byte, bit_)
|
local function event_flag_get_bb(byte, bit_)
|
||||||
byte = byte + addrs.week_event_reg.addr
|
byte = byte + addrs.week_event_reg.addr
|
||||||
local bitmask = bit.lshift(1, bit_ % 8)
|
local bitmask = bit.lshift(1, bit_ % 8)
|
||||||
return byte, bitmask
|
return byte, bitmask
|
||||||
end
|
end
|
||||||
|
|
||||||
function event_flag_get(byte, bit_)
|
local function event_flag_get(byte, bit_)
|
||||||
local byte, bitmask = event_flag_get_bb(byte, bit_)
|
local byte, bitmask = event_flag_get_bb(byte, bit_)
|
||||||
return bit.band(R1(byte), bitmask) ~= 0
|
return bit.band(R1(byte), bitmask) ~= 0
|
||||||
end
|
end
|
||||||
function event_flag_reset(byte, bit_)
|
local function event_flag_reset(byte, bit_)
|
||||||
local byte, bitmask = event_flag_get_bb(byte, bit_)
|
local byte, bitmask = event_flag_get_bb(byte, bit_)
|
||||||
W1(byte, bit.band(R1(byte), 0xFF - bitmask))
|
W1(byte, bit.band(R1(byte), 0xFF - bitmask))
|
||||||
end
|
end
|
||||||
function event_flag_set(byte, bit_)
|
local function event_flag_set(byte, bit_)
|
||||||
local byte, bitmask = event_flag_get_bb(byte, bit_)
|
local byte, bitmask = event_flag_get_bb(byte, bit_)
|
||||||
W1(byte, bit.bor(R1(byte), bitmask))
|
W1(byte, bit.bor(R1(byte), bitmask))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
return globalize{
|
||||||
|
scene_flag_get_bb = scene_flag_get_bb,
|
||||||
|
scene_flag_get = scene_flag_get,
|
||||||
|
scene_flag_reset = scene_flag_reset,
|
||||||
|
scene_flag_set = scene_flag_set,
|
||||||
|
event_flag_get_bb = event_flag_get_bb,
|
||||||
|
event_flag_get = event_flag_get,
|
||||||
|
event_flag_reset = event_flag_reset,
|
||||||
|
event_flag_set = event_flag_set,
|
||||||
|
}
|
||||||
|
|
|
@ -1,23 +1,25 @@
|
||||||
function wrap(x, around)
|
local function wrap(x, around)
|
||||||
return (x - 1) % around + 1
|
return (x - 1) % around + 1
|
||||||
end
|
end
|
||||||
|
|
||||||
MenuItem = Class()
|
local MenuItem = Class()
|
||||||
Text = Class(MenuItem)
|
local Text = Class(MenuItem)
|
||||||
Back = Class(Text)
|
local Back = Class(Text)
|
||||||
Close = Class(Text)
|
local Close = Class(Text)
|
||||||
LinkTo = Class(Text)
|
local LinkTo = Class(Text)
|
||||||
|
|
||||||
Active = Class(Text)
|
local Active = Class(Text)
|
||||||
Toggle = Class(Active)
|
local Toggle = Class(Active)
|
||||||
Radio = Class(Active)
|
local Radio = Class(Active)
|
||||||
Hold = Class(Active)
|
local Hold = Class(Active)
|
||||||
Oneshot = Class(Active)
|
local Oneshot = Class(Active)
|
||||||
|
|
||||||
Screen = Class()
|
local Screen = Class()
|
||||||
Menu = Class()
|
local Menu = Class()
|
||||||
|
|
||||||
Callbacks = Class()
|
local Callbacks = Class()
|
||||||
|
|
||||||
|
local MenuHandler = Class()
|
||||||
|
|
||||||
function Callbacks:init()
|
function Callbacks:init()
|
||||||
self.state = false
|
self.state = false
|
||||||
|
@ -277,7 +279,6 @@ function Menu:draw(brush, y)
|
||||||
self.screens[self.screen_sel]:draw(brush, y)
|
self.screens[self.screen_sel]:draw(brush, y)
|
||||||
end
|
end
|
||||||
|
|
||||||
MenuHandler = Class()
|
|
||||||
function MenuHandler:init(main_menu, brush)
|
function MenuHandler:init(main_menu, brush)
|
||||||
self.main_menu = main_menu
|
self.main_menu = main_menu
|
||||||
self.backstack = {}
|
self.backstack = {}
|
||||||
|
@ -332,3 +333,21 @@ function MenuHandler:update(ctrl, pressed)
|
||||||
end
|
end
|
||||||
if self.menu then self.menu:draw(self.brush, 0) end
|
if self.menu then self.menu:draw(self.brush, 0) end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
return globalize{
|
||||||
|
MenuItem = MenuItem,
|
||||||
|
Text = Text,
|
||||||
|
Back = Back,
|
||||||
|
Close = Close,
|
||||||
|
LinkTo = LinkTo,
|
||||||
|
Active = Active,
|
||||||
|
Toggle = Toggle,
|
||||||
|
Radio = Radio,
|
||||||
|
Hold = Hold,
|
||||||
|
Oneshot = Oneshot,
|
||||||
|
Screen = Screen,
|
||||||
|
Menu = Menu,
|
||||||
|
Callbacks = Callbacks,
|
||||||
|
MenuHandler = MenuHandler,
|
||||||
|
dummy = dummy,
|
||||||
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
function handle_alt_input(handle, ctrl, pressed)
|
local function handle_alt_input(handle, ctrl, pressed)
|
||||||
for _, v in ipairs{'left', 'right', 'up', 'down'} do
|
for _, v in ipairs{'left', 'right', 'up', 'down'} do
|
||||||
ctrl[v] = ctrl['d_'..v]
|
ctrl[v] = ctrl['d_'..v]
|
||||||
pressed[v] = pressed['d_'..v]
|
pressed[v] = pressed['d_'..v]
|
||||||
|
@ -27,7 +27,7 @@ function handle_alt_input(handle, ctrl, pressed)
|
||||||
handle:update(ctrl, pressed)
|
handle:update(ctrl, pressed)
|
||||||
end
|
end
|
||||||
|
|
||||||
function handle_eat_input(handle, ctrl, pressed)
|
local function handle_eat_input(handle, ctrl, pressed)
|
||||||
for _, v in ipairs{'left', 'right', 'up', 'down'} do
|
for _, v in ipairs{'left', 'right', 'up', 'down'} do
|
||||||
ctrl[v] = ctrl['d_'..v] or ctrl['j_'..v] or ctrl['c_'..v]
|
ctrl[v] = ctrl['d_'..v] or ctrl['j_'..v] or ctrl['c_'..v]
|
||||||
pressed[v] = pressed['d_'..v] or pressed['j_'..v] or pressed['c_'..v]
|
pressed[v] = pressed['d_'..v] or pressed['j_'..v] or pressed['c_'..v]
|
||||||
|
@ -51,3 +51,8 @@ function handle_eat_input(handle, ctrl, pressed)
|
||||||
end
|
end
|
||||||
handle:update(ctrl, pressed)
|
handle:update(ctrl, pressed)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
return globalize{
|
||||||
|
handle_eat_input = handle_eat_input,
|
||||||
|
handle_alt_input = handle_alt_input,
|
||||||
|
}
|
||||||
|
|
|
@ -1,28 +1,28 @@
|
||||||
-- gui.addmessage sucks so we're doing this our way
|
-- gui.addmessage sucks so we're doing this our way
|
||||||
|
|
||||||
function T(x, y, color, pos, s, ...)
|
local function T(x, y, color, pos, s, ...)
|
||||||
if #{...} > 0 then
|
if #{...} > 0 then
|
||||||
s = s:format(...)
|
s = s:format(...)
|
||||||
end
|
end
|
||||||
gui.text(10*x + 2, 16*y + 4, s, color or "white", nil, pos or "bottomright")
|
gui.text(10*x + 2, 16*y + 4, s, color or "white", nil, pos or "bottomright")
|
||||||
end
|
end
|
||||||
|
|
||||||
function T_BR(x, y, color, ...) T(x, y, color, "bottomright", ...) end
|
local function T_BR(x, y, color, ...) T(x, y, color, "bottomright", ...) end
|
||||||
function T_BL(x, y, color, ...) T(x, y, color, "bottomleft", ...) end
|
local function T_BL(x, y, color, ...) T(x, y, color, "bottomleft", ...) end
|
||||||
function T_TL(x, y, color, ...) T(x, y, color, "topleft", ...) end
|
local function T_TL(x, y, color, ...) T(x, y, color, "topleft", ...) end
|
||||||
function T_TR(x, y, color, ...) T(x, y, color, "topright", ...) end
|
local function T_TR(x, y, color, ...) T(x, y, color, "topright", ...) end
|
||||||
|
|
||||||
messages = {}
|
local messages = {}
|
||||||
__messages_then = 0
|
local __messages_then = 0
|
||||||
|
|
||||||
function message(text, frames)
|
local function message(text, frames)
|
||||||
local now = emu.framecount()
|
local now = emu.framecount()
|
||||||
frames = frames or 60
|
frames = frames or 60
|
||||||
local when = now + frames
|
local when = now + frames
|
||||||
table.insert(messages, {text=text, when=when})
|
table.insert(messages, {text=text, when=when})
|
||||||
end
|
end
|
||||||
|
|
||||||
function draw_messages()
|
local function draw_messages()
|
||||||
local now = emu.framecount()
|
local now = emu.framecount()
|
||||||
if now == __messages_then then
|
if now == __messages_then then
|
||||||
-- already drawn this frame
|
-- already drawn this frame
|
||||||
|
@ -47,18 +47,18 @@ function draw_messages()
|
||||||
__messages_then = now
|
__messages_then = now
|
||||||
end
|
end
|
||||||
|
|
||||||
__dprinted = {}
|
local __dprinted = {}
|
||||||
|
|
||||||
function dprint(...) -- defer print
|
local function dprint(...) -- defer print
|
||||||
-- helps with lag from printing directly to Bizhawk's console
|
-- helps with lag from printing directly to Bizhawk's console
|
||||||
table.insert(__dprinted, {...})
|
table.insert(__dprinted, {...})
|
||||||
end
|
end
|
||||||
|
|
||||||
function dprintf(fmt, ...)
|
local function dprintf(fmt, ...)
|
||||||
table.insert(__dprinted, fmt:format(...))
|
table.insert(__dprinted, fmt:format(...))
|
||||||
end
|
end
|
||||||
|
|
||||||
function print_deferred()
|
local function print_deferred()
|
||||||
local buff = ''
|
local buff = ''
|
||||||
for i, t in ipairs(__dprinted) do
|
for i, t in ipairs(__dprinted) do
|
||||||
if type(t) == 'string' then
|
if type(t) == 'string' then
|
||||||
|
@ -77,3 +77,16 @@ function print_deferred()
|
||||||
end
|
end
|
||||||
__dprinted = {}
|
__dprinted = {}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
return globalize{
|
||||||
|
T = T,
|
||||||
|
T_BR = T_BR,
|
||||||
|
T_BL = T_BL,
|
||||||
|
T_TL = T_TL,
|
||||||
|
T_TR = T_TR,
|
||||||
|
dprint = dprint,
|
||||||
|
dprintf = dprintf,
|
||||||
|
print_deferred = print_deferred,
|
||||||
|
message = message,
|
||||||
|
draw_messages = draw_messages,
|
||||||
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
require 'extra'
|
local extra = require 'extra'
|
||||||
|
local opairs = extra.opairs
|
||||||
|
|
||||||
local pt = {}
|
local pt = {}
|
||||||
pt.__index = pt
|
pt.__index = pt
|
||||||
|
|
|
@ -1,29 +1,30 @@
|
||||||
-- it's simple, dumb, unsafe, incomplete, and it gets the damn job done
|
-- it's simple, dumb, unsafe, incomplete, and it gets the damn job done
|
||||||
|
|
||||||
local type = type
|
local type = type
|
||||||
local pairs = opairs or pairs
|
local extra = require "extra"
|
||||||
|
local opairs = extra.opairs
|
||||||
local tostring = tostring
|
local tostring = tostring
|
||||||
local open = io.open
|
local open = io.open
|
||||||
local strfmt = string.format
|
local strfmt = string.format
|
||||||
local strrep = string.rep
|
local strrep = string.rep
|
||||||
|
|
||||||
function kill_bom(s)
|
local function kill_bom(s)
|
||||||
if #s >= 3 and s:byte(1)==0xEF and s:byte(2)==0xBB and s:byte(3)==0xBF then
|
if #s >= 3 and s:byte(1)==0xEF and s:byte(2)==0xBB and s:byte(3)==0xBF then
|
||||||
return s:sub(4)
|
return s:sub(4)
|
||||||
end
|
end
|
||||||
return s
|
return s
|
||||||
end
|
end
|
||||||
|
|
||||||
function sanitize(v)
|
local function sanitize(v)
|
||||||
return type(v) == 'string' and strfmt('%q', v) or tostring(v)
|
return type(v) == 'string' and strfmt('%q', v) or tostring(v)
|
||||||
end
|
end
|
||||||
|
|
||||||
function _serialize(value, writer, level)
|
local function _serialize(value, writer, level)
|
||||||
level = level or 1
|
level = level or 1
|
||||||
if type(value) == 'table' then
|
if type(value) == 'table' then
|
||||||
local indent = strrep('\t', level)
|
local indent = strrep('\t', level)
|
||||||
writer('{\n')
|
writer('{\n')
|
||||||
for key,value in pairs(value) do
|
for key,value in opairs(value) do
|
||||||
local sane = sanitize(key)
|
local sane = sanitize(key)
|
||||||
local keyval = sane == '"'..key..'"' and key or '['..sane..']'
|
local keyval = sane == '"'..key..'"' and key or '['..sane..']'
|
||||||
writer(indent..keyval..' = ')
|
writer(indent..keyval..' = ')
|
||||||
|
@ -36,7 +37,7 @@ function _serialize(value, writer, level)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function _deserialize(script)
|
local function _deserialize(script)
|
||||||
local f = loadstring(kill_bom(script))
|
local f = loadstring(kill_bom(script))
|
||||||
if f ~= nil then
|
if f ~= nil then
|
||||||
return f()
|
return f()
|
||||||
|
@ -46,7 +47,7 @@ function _deserialize(script)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function serialize(path, value)
|
local function serialize(path, value)
|
||||||
local file = open(path, 'w')
|
local file = open(path, 'w')
|
||||||
if not file then return end
|
if not file then return end
|
||||||
file:write("return ")
|
file:write("return ")
|
||||||
|
@ -57,7 +58,7 @@ function serialize(path, value)
|
||||||
file:close()
|
file:close()
|
||||||
end
|
end
|
||||||
|
|
||||||
function deserialize(path)
|
local function deserialize(path)
|
||||||
local file = open(path, 'r')
|
local file = open(path, 'r')
|
||||||
if not file then return end
|
if not file then return end
|
||||||
local script = file:read('*a')
|
local script = file:read('*a')
|
||||||
|
@ -65,3 +66,8 @@ function deserialize(path)
|
||||||
file:close()
|
file:close()
|
||||||
return value
|
return value
|
||||||
end
|
end
|
||||||
|
|
||||||
|
return globalize{
|
||||||
|
serialize = serialize,
|
||||||
|
deserialize = deserialize,
|
||||||
|
}
|
||||||
|
|
|
@ -4,9 +4,22 @@ _require = require
|
||||||
package.path = package.path..';./lib/?.lua'
|
package.path = package.path..';./lib/?.lua'
|
||||||
package.path = package.path..';./lib/?/init.lua'
|
package.path = package.path..';./lib/?/init.lua'
|
||||||
|
|
||||||
function depend(path)
|
require "strict"
|
||||||
|
|
||||||
|
local function depend(path)
|
||||||
if package and package.loaded and package.loaded[path] then
|
if package and package.loaded and package.loaded[path] then
|
||||||
package.loaded[path] = nil
|
package.loaded[path] = nil
|
||||||
end
|
end
|
||||||
return _require(path)
|
return _require(path)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function globalize(t)
|
||||||
|
for k, v in pairs(t) do
|
||||||
|
rawset(_G, k, v)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return globalize{
|
||||||
|
depend = depend,
|
||||||
|
globalize = globalize,
|
||||||
|
}
|
||||||
|
|
20
Lua/lib/strict.lua
Normal file
20
Lua/lib/strict.lua
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
local mt = getmetatable(_G)
|
||||||
|
if mt == nil then
|
||||||
|
mt = {}
|
||||||
|
setmetatable(_G, mt)
|
||||||
|
end
|
||||||
|
|
||||||
|
function mt.__newindex(t, n, v)
|
||||||
|
if n == '_TEMP_BIZHAWK_RULES_' then
|
||||||
|
rawset(t, n, v)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
error("cannot assign undeclared global '" .. tostring(n) .. "'", 2)
|
||||||
|
end
|
||||||
|
|
||||||
|
function mt.__index(t, n)
|
||||||
|
if n == '_TEMP_BIZHAWK_RULES_' then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
error("cannot use undeclared global '" .. tostring(n) .. "'", 2)
|
||||||
|
end
|
|
@ -38,11 +38,11 @@ local debug_watch = mm and {
|
||||||
{'unk_78', '%9.3f'},
|
{'unk_78', '%9.3f'},
|
||||||
} or {}
|
} or {}
|
||||||
|
|
||||||
function longbinary(x)
|
local function longbinary(x)
|
||||||
return ('%032s'):format(bizstring.binary(x))
|
return ('%032s'):format(bizstring.binary(x))
|
||||||
end
|
end
|
||||||
|
|
||||||
function focus(actor, dump)
|
local function focus(actor, dump)
|
||||||
local color = actor.name:sub(1,1) == "?" and "red" or "orange"
|
local color = actor.name:sub(1,1) == "?" and "red" or "orange"
|
||||||
local flags = longbinary(actor.flags)
|
local flags = longbinary(actor.flags)
|
||||||
local y = debug_mode and #debug_watch + 9 or 9
|
local y = debug_mode and #debug_watch + 9 or 9
|
||||||
|
@ -98,7 +98,7 @@ function focus(actor, dump)
|
||||||
|
|
||||||
if dump then
|
if dump then
|
||||||
console.clear()
|
console.clear()
|
||||||
s = ("%04X\t%02X\t%02X"):format(actor.num, actor.at, actor.hp)
|
local s = ("%04X\t%02X\t%02X"):format(actor.num, actor.at, actor.hp)
|
||||||
if dmg then
|
if dmg then
|
||||||
for i = 0, 31 do
|
for i = 0, 31 do
|
||||||
s = s..("\t%02X"):format(R1(dmg + i))
|
s = s..("\t%02X"):format(R1(dmg + i))
|
||||||
|
@ -116,6 +116,10 @@ local input_handler = InputHandler{
|
||||||
right = "P1 DPad R",
|
right = "P1 DPad R",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
globalize{
|
||||||
|
focus = focus,
|
||||||
|
}
|
||||||
|
|
||||||
local al = ActorLister(input_handler, debug_mode)
|
local al = ActorLister(input_handler, debug_mode)
|
||||||
event.onexit(function() al = nil end, 'actor cleanup')
|
event.onexit(function() al = nil end, 'actor cleanup')
|
||||||
event.onloadstate(function() if al then al:wipe() end end, 'actor wipe')
|
event.onloadstate(function() if al then al:wipe() end end, 'actor wipe')
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
require "lib.setup"
|
||||||
|
require "boilerplate"
|
||||||
require "addrs"
|
require "addrs"
|
||||||
require "serialize"
|
require "serialize"
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ local blocknames = {
|
||||||
'Rb',
|
'Rb',
|
||||||
}
|
}
|
||||||
|
|
||||||
function distribute_index(ih)
|
local function distribute_index(ih)
|
||||||
local block = math.floor(ih/16/6)
|
local block = math.floor(ih/16/6)
|
||||||
local ir = ih - block*16*6
|
local ir = ih - block*16*6
|
||||||
local page = math.floor(ir/16)
|
local page = math.floor(ir/16)
|
||||||
|
@ -22,7 +22,7 @@ function distribute_index(ih)
|
||||||
return block, page, row
|
return block, page, row
|
||||||
end
|
end
|
||||||
|
|
||||||
ShortMonitor = Class(Monitor)
|
local ShortMonitor = Class(Monitor)
|
||||||
|
|
||||||
function ShortMonitor:mark(i, x, x1)
|
function ShortMonitor:mark(i, x, x1)
|
||||||
local ih = math.floor(i/2)
|
local ih = math.floor(i/2)
|
||||||
|
@ -51,7 +51,7 @@ end
|
||||||
|
|
||||||
-- 2 bytes each, 16 values per page, 6 pages per block, 29 blocks
|
-- 2 bytes each, 16 values per page, 6 pages per block, 29 blocks
|
||||||
-- = 5568 bytes (0x15C0)
|
-- = 5568 bytes (0x15C0)
|
||||||
me = ShortMonitor('me', A(0x210A24, 0x15C0))
|
local me = ShortMonitor('me', A(0x210A24, 0x15C0))
|
||||||
me:load('data/_ootmemod.lua')
|
me:load('data/_ootmemod.lua')
|
||||||
while version == "O EUDB MQ" do
|
while version == "O EUDB MQ" do
|
||||||
me:diff()
|
me:diff()
|
||||||
|
|
|
@ -25,6 +25,8 @@ local mm_ignore = {
|
||||||
['28,2=1 (weg)'] = true,
|
['28,2=1 (weg)'] = true,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
local weg,inf,eci,igi,it_,ei_
|
||||||
|
local fms
|
||||||
if mm then
|
if mm then
|
||||||
weg = FlagMonitor('weg', addrs.week_event_reg, mm_ignore)
|
weg = FlagMonitor('weg', addrs.week_event_reg, mm_ignore)
|
||||||
inf = FlagMonitor('inf', addrs.event_inf, mm_ignore)
|
inf = FlagMonitor('inf', addrs.event_inf, mm_ignore)
|
||||||
|
@ -45,11 +47,11 @@ elseif oot then
|
||||||
for i, fm in ipairs(fms) do fm.oot = true end
|
for i, fm in ipairs(fms) do fm.oot = true end
|
||||||
end
|
end
|
||||||
|
|
||||||
function ef_wipe()
|
local function ef_wipe()
|
||||||
for _, fm in ipairs(fms) do fm:wipe() end
|
for _, fm in ipairs(fms) do fm:wipe() end
|
||||||
end
|
end
|
||||||
|
|
||||||
function ef_unk()
|
local function ef_unk()
|
||||||
for _, fm in ipairs(fms) do fm:set_unknowns() end
|
for _, fm in ipairs(fms) do fm:set_unknowns() end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -7,20 +7,20 @@ local entrance_names = require "data.entrance names"
|
||||||
|
|
||||||
local open = io.open
|
local open = io.open
|
||||||
|
|
||||||
function sdata(i)
|
local function sdata(i)
|
||||||
local a = addrs.scene_table.addr + i*4*3
|
local a = addrs.scene_table.addr + i*4*3
|
||||||
-- entrance count, entrance table (ptr), name (ptr)
|
-- entrance count, entrance table (ptr), name (ptr)
|
||||||
return {R4(a), R4(a + 4), R4(a + 8)}
|
return {R4(a), R4(a + 4), R4(a + 8)}
|
||||||
end
|
end
|
||||||
|
|
||||||
function mirror(scene_id)
|
local function mirror(scene_id)
|
||||||
if scene_id > 0x80 then
|
if scene_id > 0x80 then
|
||||||
return 0x100 - scene_id
|
return 0x100 - scene_id
|
||||||
end
|
end
|
||||||
return scene_id
|
return scene_id
|
||||||
end
|
end
|
||||||
|
|
||||||
function calc_dump(a, writer)
|
local function calc_dump(a, writer)
|
||||||
if type(a) ~= "number" then
|
if type(a) ~= "number" then
|
||||||
writer('[crash]')
|
writer('[crash]')
|
||||||
return
|
return
|
||||||
|
@ -41,11 +41,11 @@ function calc_dump(a, writer)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function split_exit(exit)
|
local function split_exit(exit)
|
||||||
return bit.rshift(exit, 9), bit.band(bit.rshift(exit, 4), 0x1F), bit.band(exit, 0xF)
|
return bit.rshift(exit, 9), bit.band(bit.rshift(exit, 4), 0x1F), bit.band(exit, 0xF)
|
||||||
end
|
end
|
||||||
|
|
||||||
function calc(exit)
|
local function calc(exit)
|
||||||
console.clear()
|
console.clear()
|
||||||
local scene, entrance, offset = split_exit(exit)
|
local scene, entrance, offset = split_exit(exit)
|
||||||
printf("%i, %i, %i", scene, entrance, offset)
|
printf("%i, %i, %i", scene, entrance, offset)
|
||||||
|
@ -73,7 +73,7 @@ function calc(exit)
|
||||||
--print(asciize(mainmemory.readbyterange(deref(sd[3]), 8)))
|
--print(asciize(mainmemory.readbyterange(deref(sd[3]), 8)))
|
||||||
end
|
end
|
||||||
|
|
||||||
function dump_all_exits(fn)
|
local function dump_all_exits(fn)
|
||||||
local f = open(fn or 'data/_exits.csv', 'w')
|
local f = open(fn or 'data/_exits.csv', 'w')
|
||||||
if f == nil then
|
if f == nil then
|
||||||
print("couldn't open file for writing")
|
print("couldn't open file for writing")
|
||||||
|
|
|
@ -10,16 +10,16 @@ local object_names = require("data.object names"..suffix)
|
||||||
local print = dprint
|
local print = dprint
|
||||||
local printf = dprintf
|
local printf = dprintf
|
||||||
|
|
||||||
function gs2(addr, value)
|
local function gs2(addr, value)
|
||||||
printf("81%06X %04X", addr, value)
|
printf("81%06X %04X", addr, value)
|
||||||
W2(addr, value)
|
W2(addr, value)
|
||||||
end
|
end
|
||||||
|
|
||||||
function dump_half_row(addr)
|
local function dump_half_row(addr)
|
||||||
printf("%04X %04X %04X %04X", R2(addr), R2(addr+2), R2(addr+4), R2(addr+6))
|
printf("%04X %04X %04X %04X", R2(addr), R2(addr+2), R2(addr+4), R2(addr+6))
|
||||||
end
|
end
|
||||||
|
|
||||||
function dump_room(start, addr)
|
local function dump_room(start, addr)
|
||||||
local addr = addr or start
|
local addr = addr or start
|
||||||
printf("start: %06X", start)
|
printf("start: %06X", start)
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
-- for Ocarina of Time:
|
-- for Ocarina of Time:
|
||||||
-- go to the Temple of Time as a child and run this script.
|
-- go to the Temple of Time as a child and run this script.
|
||||||
|
|
||||||
|
require "setup.lib"
|
||||||
require "addrs"
|
require "addrs"
|
||||||
|
|
||||||
local length = 70 -- in frames
|
local length = 70 -- in frames
|
||||||
|
|
Loading…
Reference in New Issue
Block a user