1
0
Fork 0
mirror of https://github.com/notwa/mm synced 2024-11-05 03:19:02 -08:00

refactor to one loop for both games

This commit is contained in:
Connor Olding 2015-05-14 21:32:46 -07:00
parent 5f2babaef4
commit c142f4558c

View file

@ -32,7 +32,7 @@ function FlagMonitor: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 str local str
if oot then if self.oot then
local row = math.floor(i/2) local row = math.floor(i/2)
local col = which + (1 - (i % 2))*8 local col = which + (1 - (i % 2))*8
str = ('%02i,%X=%i (%s)'):format(row, col, state, self.name) str = ('%02i,%X=%i (%s)'):format(row, col, state, self.name)
@ -56,7 +56,7 @@ end
function FlagMonitor:dump(current) function FlagMonitor:dump(current)
local t = current and self:read() or self.modified local t = current and self:read() or self.modified
local size = mm and 8 or 16 local size = self.oot and 16 or 8
local rows = math.floor(self.len/size*8) local rows = math.floor(self.len/size*8)
local buff = self.name..'\n' local buff = self.name..'\n'
@ -90,18 +90,10 @@ end
if mm then if mm then
weg = FlagMonitor('weg', addrs.week_event_reg) weg = FlagMonitor('weg', addrs.week_event_reg)
inf = FlagMonitor('inf', addrs.event_inf) inf = FlagMonitor('inf', addrs.event_inf)
mmb = FlagMonitor('mmb', addrs.mask_mask_bit) --mmb = FlagMonitor('mmb', addrs.mask_mask_bit) -- 100% known, no point
weg:load('data/_weg.lua') weg:load('data/_weg.lua')
inf:load('data/_inf.lua') inf:load('data/_inf.lua')
while mm do fms = {weg, inf}
weg:diff()
inf:diff()
mmb:diff()
weg:save()
inf:save()
draw_messages()
emu.frameadvance()
end
elseif oot then elseif oot then
eci = FlagMonitor('eci', AL(0xED4, 0x1C)) eci = FlagMonitor('eci', AL(0xED4, 0x1C))
igi = FlagMonitor('igi', AL(0xEF0, 0x8)) igi = FlagMonitor('igi', AL(0xEF0, 0x8))
@ -111,21 +103,16 @@ elseif oot then
igi:load('data/_igi.lua') igi:load('data/_igi.lua')
it_:load('data/_it.lua') it_:load('data/_it.lua')
ei_:load('data/_ei.lua') ei_:load('data/_ei.lua')
eci.oot = true fms = {eci, igi, it_, ei_}
igi.oot = true for i, fm in ipairs(fms) do fm.oot = true end
it_.oot = true end
ei_.oot = true
while oot do while mm or oot do
eci:diff() for i, fm in ipairs(fms) do
igi:diff() fm:diff()
it_:diff() fm:save()
ei_:diff() end
eci:save() print_deferred()
igi:save() draw_messages()
it_:save() emu.frameadvance()
ei_:save()
print_deferred()
draw_messages()
emu.frameadvance()
end
end end