1
0
Fork 0
mirror of https://github.com/notwa/mm synced 2024-05-05 08:33: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:
Connor Olding 2016-01-13 09:21:24 -08:00
parent 072e8c7a7a
commit 1acbaba58c
28 changed files with 268 additions and 109 deletions

View File

@ -43,7 +43,14 @@ local function save()
serialize(fn, saved)
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()
for func, value in pairs(t) do
func(value)
@ -53,7 +60,7 @@ end
local passives = {}
Passive = Class(Callbacks)
local Passive = Class(Callbacks)
function Passive:init(...)
Callbacks.init(self, ...)
table.insert(passives, self)
@ -208,7 +215,7 @@ end
local function timestop()
-- 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
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 progress_menu = require "menus.progress"
local playas_menu = require "menus.playas"

View File

@ -1,7 +1,9 @@
require "lib.setup"
require "boilerplate"
require "addrs"
-- precalculate hamming weights of bytes
hamming_weight = {}
local hamming_weight = {}
for i = 0, 255 do
local w = 0
for b = 0, 7 do
@ -10,9 +12,9 @@ for i = 0, 255 do
hamming_weight[i] = w
end
function hamming_of(addr, size)
weight = 0
bytes = mainmemory.readbyterange(addr, size)
local function hamming_of(addr, size)
local weight = 0
local bytes = mainmemory.readbyterange(addr, size)
for k,v in pairs(bytes) do
if v ~= 0 then
weight = weight + hamming_weight[tonumber(v, 16)]
@ -21,7 +23,7 @@ function hamming_of(addr, size)
return weight
end
function hamming_of_A(a)
local function hamming_of_A(a)
return hamming_of(a.addr, a.type)
end

View File

@ -1,8 +1,7 @@
require "lib.setup"
require "boilerplate"
require "addrs"
local addrs = require "addrs"
require "messages"
require = depend
local assemble = require "lips"
local injection_points = {
@ -67,7 +66,7 @@ local hook = [[
start:
]]
function inject(fn)
local function inject(fn)
local asm_dir = bizstring and 'inject/' or './mm/Lua/inject/'
local asm_path = asm_dir..fn

View File

@ -5,7 +5,7 @@ local validate = false
-- using a template to offset from will do for now.
local actor_t = Actor(0)
function sort_by_key(t)
local function sort_by_key(t)
local sorted = {}
local i = 1
for k, v in pairs(t) do
@ -16,23 +16,23 @@ function sort_by_key(t)
return sorted
end
function get_actor_count(i)
local function get_actor_count(i)
return R4(addrs.actor_counts[i].addr)
end
function get_first_actor(i)
local function get_first_actor(i)
return deref(R4(addrs.actor_firsts[i].addr))
end
function get_next_actor(addr)
local function get_next_actor(addr)
return deref(R4(addr + actor_t.next.addr))
end
function get_prev_actor(addr)
local function get_prev_actor(addr)
return deref(R4(addr + actor_t.prev.addr))
end
function count_actors()
local function count_actors()
local counts = {}
for i = 0, 11 do
counts[i] = get_actor_count(i)
@ -40,7 +40,7 @@ function count_actors()
return counts
end
function iter_actors(counts)
local function iter_actors(counts)
local at, ai = 0, 0
local addr
@ -92,7 +92,7 @@ function iter_actors(counts)
return iterate
end
function collect_actors()
local function collect_actors()
local game_counts = count_actors()
local any = 0
for i = 0, 11 do
@ -113,3 +113,14 @@ function collect_actors()
end
return any > 0, actors_by_type, new_counts
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,
}

View File

@ -8,6 +8,8 @@ local same = {
--["O JPGC MQ"] = "O USGC", -- maybe?
}
rawset(_G, 'Actor', function() end)
return function(hash)
local version = versions[hash] or VERSION_OVERRIDE
if version == nil then
@ -18,8 +20,8 @@ return function(hash)
local rv = same[version] or version
local b = basics[rv]
function AL(a, s) return A(b.link + a, s) end
function AG(a, s)
local function AL(a, s) return A(b.link + a, s) end
local function AG(a, s)
if rv == 'M JP10' or rv == 'M JP11' then
if a >= 0x17000 then -- approximate
a = a - 0x20
@ -27,7 +29,7 @@ return function(hash)
end
return A(b.global + a, s)
end
function AA(a, s)
local function AA(a, s)
if rv == 'O EUDB MQ' then
if a >= 0x130 then -- approximate
a = a + 0x10
@ -39,6 +41,10 @@ return function(hash)
local subdir = version:sub(1, 1)
local rvs = rv:sub(3)
rawset(_G, 'AL', AL)
rawset(_G, 'AG', AG)
rawset(_G, 'AA', AA)
local addrs = require("addrs."..subdir.."."..rvs)
addrs.version = version
addrs.oot = v == "O "

View File

@ -6,8 +6,12 @@ else
end
local Game = require "addrs.addrs"
local game = Game(hash)
version = game.version
oot = game.oot
mm = game.mm
addrs = game
-- TODO: return globalize instead
globalize{
version = game.version,
oot = game.oot,
mm = game.mm,
addrs = game,
}
return game

View File

@ -2,6 +2,8 @@
require "extra"
local R1, R2, R4, RF, W1, W2, W4, WF, X1, X2, X4, XF
if bizstring then
local mm = mainmemory
local m = memory
@ -61,7 +63,7 @@ local mts = {
['f'] = {__call = HF},
}
function A(addr, atype)
local function A(addr, atype)
local mt = mts[atype]
return setmetatable({
addr=addr,
@ -69,7 +71,7 @@ function A(addr, atype)
}, mt)
end
Class = function(inherit)
local function Class(inherit)
local class = {}
local mt_obj = {__index = class}
local mt_class = {
@ -84,25 +86,25 @@ Class = function(inherit)
return setmetatable(class, mt_class)
end
function getindex(obj)
local function getindex(obj)
local gm = getmetatable(obj)
if not gm then return end
return gm.__index
end
function printf(fmt, ...)
local function printf(fmt, ...)
print(fmt:format(...))
end
function is_ptr(ptr)
local function is_ptr(ptr)
return bit.band(0xFF800000, ptr) == 0x80000000
end
function deref(ptr)
local function deref(ptr)
return is_ptr(ptr) and ptr - 0x80000000
end
function asciize(bytes)
local function asciize(bytes)
local str = ""
local seq = false
for i, v in ipairs(bytes) do
@ -118,7 +120,7 @@ function asciize(bytes)
return str
end
function hex(i)
local function hex(i)
-- convenience function for use in console
if i == nil then
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
--]]
-- 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

View File

@ -15,5 +15,5 @@ local classes = {
}
for _, class in ipairs(classes) do
_G[class] = require("classes."..class)
rawset(_G, class, require("classes."..class))
end

View File

@ -1,4 +1,4 @@
local print = dprint or print
local print = rawget(_G, 'dprint') or print
-- hack to avoid N64 logo spitting errors
local stupid = addrs.actor_counts[0].addr - 0x8

View File

@ -1,7 +1,7 @@
local Monitor = require "classes.Monitor"
local ByteMonitor = Class(Monitor)
local printf = dprintf or printf
local printf = rawget(_G, 'dprintf') or printf
function ByteMonitor:mark(i, x, x1)
if self.ignore and self:ignore(i) then return end

View File

@ -1,4 +1,4 @@
local printf = dprintf or printf
local printf = rawget(_G, 'dprintf') or printf
local Monitor = require "classes.Monitor"
local FlagMonitor = Class(Monitor)

View File

@ -9,7 +9,7 @@ function SceneFlagMonitor:mark(i, x, x1)
if bit.band(diff, 2^which) ~= 0 then
local state = bit.band(x, 2^which) ~= 0 and 1 or 0
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)
message(str, 180)
end

View File

@ -1,13 +1,13 @@
function strpad(num, count, pad)
local function strpad(num, count, pad)
num = tostring(num)
return (pad:rep(count)..num):sub(#num)
end
function add_zeros(num, count)
local function add_zeros(num, count)
return strpad(num, count - 1, '0')
end
function mixed_sorter(a, b)
local 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
@ -15,7 +15,7 @@ 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 function order_keys(t)
local oi = {}
for key in pairs(t) do
table.insert(oi, key)
@ -24,7 +24,7 @@ function order_keys(t)
return oi
end
function opairs(t, cache)
local function opairs(t, cache)
local oi = cache and cache[t] or order_keys(t)
if cache then
cache[t] = oi
@ -36,3 +36,11 @@ function opairs(t, cache)
if key then return key, t[key] end
end
end
return {
strpad = strpad,
add_zeros = add_zeros,
mixed_sorter = mixed_sorter,
order_keys = order_keys,
opairs = opairs,
}

View File

@ -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)
byte = byte + addrs.scene_flags_ingame.addr
local bitmask = bit.lshift(1, bit_ % 8)
return byte, bitmask
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_)
return bit.band(R1(byte), bitmask) ~= 0
end
-- TODO: check if current scene is scene id
-- 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_)
W1(byte, bit.band(R1(byte), 0xFF - bitmask))
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_)
W1(byte, bit.bor(R1(byte), bitmask))
end
function event_flag_get_bb(byte, bit_)
local function event_flag_get_bb(byte, bit_)
byte = byte + addrs.week_event_reg.addr
local bitmask = bit.lshift(1, bit_ % 8)
return byte, bitmask
end
function event_flag_get(byte, bit_)
local function event_flag_get(byte, bit_)
local byte, bitmask = event_flag_get_bb(byte, bit_)
return bit.band(R1(byte), bitmask) ~= 0
end
function event_flag_reset(byte, bit_)
local function event_flag_reset(byte, bit_)
local byte, bitmask = event_flag_get_bb(byte, bit_)
W1(byte, bit.band(R1(byte), 0xFF - bitmask))
end
function event_flag_set(byte, bit_)
local function event_flag_set(byte, bit_)
local byte, bitmask = event_flag_get_bb(byte, bit_)
W1(byte, bit.bor(R1(byte), bitmask))
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,
}

View File

@ -1,23 +1,25 @@
function wrap(x, around)
local function wrap(x, around)
return (x - 1) % around + 1
end
MenuItem = Class()
Text = Class(MenuItem)
Back = Class(Text)
Close = Class(Text)
LinkTo = Class(Text)
local MenuItem = Class()
local Text = Class(MenuItem)
local Back = Class(Text)
local Close = Class(Text)
local LinkTo = Class(Text)
Active = Class(Text)
Toggle = Class(Active)
Radio = Class(Active)
Hold = Class(Active)
Oneshot = Class(Active)
local Active = Class(Text)
local Toggle = Class(Active)
local Radio = Class(Active)
local Hold = Class(Active)
local Oneshot = Class(Active)
Screen = Class()
Menu = Class()
local Screen = Class()
local Menu = Class()
Callbacks = Class()
local Callbacks = Class()
local MenuHandler = Class()
function Callbacks:init()
self.state = false
@ -277,7 +279,6 @@ function Menu:draw(brush, y)
self.screens[self.screen_sel]:draw(brush, y)
end
MenuHandler = Class()
function MenuHandler:init(main_menu, brush)
self.main_menu = main_menu
self.backstack = {}
@ -332,3 +333,21 @@ function MenuHandler:update(ctrl, pressed)
end
if self.menu then self.menu:draw(self.brush, 0) 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,
}

View File

@ -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
ctrl[v] = ctrl['d_'..v]
pressed[v] = pressed['d_'..v]
@ -27,7 +27,7 @@ function handle_alt_input(handle, ctrl, pressed)
handle:update(ctrl, pressed)
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
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]
@ -51,3 +51,8 @@ function handle_eat_input(handle, ctrl, pressed)
end
handle:update(ctrl, pressed)
end
return globalize{
handle_eat_input = handle_eat_input,
handle_alt_input = handle_alt_input,
}

View File

@ -1,28 +1,28 @@
-- 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
s = s:format(...)
end
gui.text(10*x + 2, 16*y + 4, s, color or "white", nil, pos or "bottomright")
end
function T_BR(x, y, color, ...) T(x, y, color, "bottomright", ...) end
function T_BL(x, y, color, ...) T(x, y, color, "bottomleft", ...) end
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_BR(x, y, color, ...) T(x, y, color, "bottomright", ...) end
local function T_BL(x, y, color, ...) T(x, y, color, "bottomleft", ...) end
local function T_TL(x, y, color, ...) T(x, y, color, "topleft", ...) end
local function T_TR(x, y, color, ...) T(x, y, color, "topright", ...) end
messages = {}
__messages_then = 0
local messages = {}
local __messages_then = 0
function message(text, frames)
local function message(text, frames)
local now = emu.framecount()
frames = frames or 60
local when = now + frames
table.insert(messages, {text=text, when=when})
end
function draw_messages()
local function draw_messages()
local now = emu.framecount()
if now == __messages_then then
-- already drawn this frame
@ -47,18 +47,18 @@ function draw_messages()
__messages_then = now
end
__dprinted = {}
local __dprinted = {}
function dprint(...) -- defer print
local function dprint(...) -- defer print
-- helps with lag from printing directly to Bizhawk's console
table.insert(__dprinted, {...})
end
function dprintf(fmt, ...)
local function dprintf(fmt, ...)
table.insert(__dprinted, fmt:format(...))
end
function print_deferred()
local function print_deferred()
local buff = ''
for i, t in ipairs(__dprinted) do
if type(t) == 'string' then
@ -77,3 +77,16 @@ function print_deferred()
end
__dprinted = {}
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,
}

View File

@ -1,4 +1,5 @@
require 'extra'
local extra = require 'extra'
local opairs = extra.opairs
local pt = {}
pt.__index = pt

View File

@ -1,29 +1,30 @@
-- it's simple, dumb, unsafe, incomplete, and it gets the damn job done
local type = type
local pairs = opairs or pairs
local extra = require "extra"
local opairs = extra.opairs
local tostring = tostring
local open = io.open
local strfmt = string.format
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
return s:sub(4)
end
return s
end
function sanitize(v)
local function sanitize(v)
return type(v) == 'string' and strfmt('%q', v) or tostring(v)
end
function _serialize(value, writer, level)
local function _serialize(value, writer, level)
level = level or 1
if type(value) == 'table' then
local indent = strrep('\t', level)
writer('{\n')
for key,value in pairs(value) do
for key,value in opairs(value) do
local sane = sanitize(key)
local keyval = sane == '"'..key..'"' and key or '['..sane..']'
writer(indent..keyval..' = ')
@ -36,7 +37,7 @@ function _serialize(value, writer, level)
end
end
function _deserialize(script)
local function _deserialize(script)
local f = loadstring(kill_bom(script))
if f ~= nil then
return f()
@ -46,7 +47,7 @@ function _deserialize(script)
end
end
function serialize(path, value)
local function serialize(path, value)
local file = open(path, 'w')
if not file then return end
file:write("return ")
@ -57,7 +58,7 @@ function serialize(path, value)
file:close()
end
function deserialize(path)
local function deserialize(path)
local file = open(path, 'r')
if not file then return end
local script = file:read('*a')
@ -65,3 +66,8 @@ function deserialize(path)
file:close()
return value
end
return globalize{
serialize = serialize,
deserialize = deserialize,
}

View File

@ -4,9 +4,22 @@ _require = require
package.path = package.path..';./lib/?.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
package.loaded[path] = nil
end
return _require(path)
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
View 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

View File

@ -38,11 +38,11 @@ local debug_watch = mm and {
{'unk_78', '%9.3f'},
} or {}
function longbinary(x)
local function longbinary(x)
return ('%032s'):format(bizstring.binary(x))
end
function focus(actor, dump)
local function focus(actor, dump)
local color = actor.name:sub(1,1) == "?" and "red" or "orange"
local flags = longbinary(actor.flags)
local y = debug_mode and #debug_watch + 9 or 9
@ -98,7 +98,7 @@ function focus(actor, dump)
if dump then
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
for i = 0, 31 do
s = s..("\t%02X"):format(R1(dmg + i))
@ -116,6 +116,10 @@ local input_handler = InputHandler{
right = "P1 DPad R",
}
globalize{
focus = focus,
}
local al = ActorLister(input_handler, debug_mode)
event.onexit(function() al = nil end, 'actor cleanup')
event.onloadstate(function() if al then al:wipe() end end, 'actor wipe')

View File

@ -1,3 +1,5 @@
require "lib.setup"
require "boilerplate"
require "addrs"
require "serialize"

View File

@ -14,7 +14,7 @@ local blocknames = {
'Rb',
}
function distribute_index(ih)
local function distribute_index(ih)
local block = math.floor(ih/16/6)
local ir = ih - block*16*6
local page = math.floor(ir/16)
@ -22,7 +22,7 @@ function distribute_index(ih)
return block, page, row
end
ShortMonitor = Class(Monitor)
local ShortMonitor = Class(Monitor)
function ShortMonitor:mark(i, x, x1)
local ih = math.floor(i/2)
@ -51,7 +51,7 @@ end
-- 2 bytes each, 16 values per page, 6 pages per block, 29 blocks
-- = 5568 bytes (0x15C0)
me = ShortMonitor('me', A(0x210A24, 0x15C0))
local me = ShortMonitor('me', A(0x210A24, 0x15C0))
me:load('data/_ootmemod.lua')
while version == "O EUDB MQ" do
me:diff()

View File

@ -25,6 +25,8 @@ local mm_ignore = {
['28,2=1 (weg)'] = true,
}
local weg,inf,eci,igi,it_,ei_
local fms
if mm then
weg = FlagMonitor('weg', addrs.week_event_reg, 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
end
function ef_wipe()
local function ef_wipe()
for _, fm in ipairs(fms) do fm:wipe() end
end
function ef_unk()
local function ef_unk()
for _, fm in ipairs(fms) do fm:set_unknowns() end
end

View File

@ -7,20 +7,20 @@ local entrance_names = require "data.entrance names"
local open = io.open
function sdata(i)
local function sdata(i)
local a = addrs.scene_table.addr + i*4*3
-- entrance count, entrance table (ptr), name (ptr)
return {R4(a), R4(a + 4), R4(a + 8)}
end
function mirror(scene_id)
local function mirror(scene_id)
if scene_id > 0x80 then
return 0x100 - scene_id
end
return scene_id
end
function calc_dump(a, writer)
local function calc_dump(a, writer)
if type(a) ~= "number" then
writer('[crash]')
return
@ -41,11 +41,11 @@ function calc_dump(a, writer)
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)
end
function calc(exit)
local function calc(exit)
console.clear()
local scene, entrance, offset = split_exit(exit)
printf("%i, %i, %i", scene, entrance, offset)
@ -73,7 +73,7 @@ function calc(exit)
--print(asciize(mainmemory.readbyterange(deref(sd[3]), 8)))
end
function dump_all_exits(fn)
local function dump_all_exits(fn)
local f = open(fn or 'data/_exits.csv', 'w')
if f == nil then
print("couldn't open file for writing")

View File

@ -10,16 +10,16 @@ local object_names = require("data.object names"..suffix)
local print = dprint
local printf = dprintf
function gs2(addr, value)
local function gs2(addr, value)
printf("81%06X %04X", addr, value)
W2(addr, value)
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))
end
function dump_room(start, addr)
local function dump_room(start, addr)
local addr = addr or start
printf("start: %06X", start)

View File

@ -4,6 +4,7 @@
-- for Ocarina of Time:
-- go to the Temple of Time as a child and run this script.
require "setup.lib"
require "addrs"
local length = 70 -- in frames