1
0
Fork 0
mirror of https://github.com/notwa/mm synced 2024-11-04 13:39:03 -08:00

abstract to FlagMonitor class

This commit is contained in:
Connor Olding 2015-04-25 23:54:04 -07:00
parent 8d45fa0f42
commit 30dff10c7e
2 changed files with 25 additions and 12 deletions

View file

@ -54,6 +54,14 @@ function A(addr, atype)
}, mt) }, mt)
end end
Class = function()
return setmetatable({}, {__call = function(self, ...)
local obj = setmetatable({}, {__index = self})
obj:init(...)
return obj
end})
end
function printf(fmt, ...) function printf(fmt, ...)
print(fmt:format(...)) print(fmt:format(...))
end end

View file

@ -1,9 +1,5 @@
require "boilerplate" require "boilerplate"
function Butts(name, begin, len)
return {name=name, begin=begin, len=len, once = false, old_bytes = {}}
end
local ignore = { local ignore = {
-- every time a scene (un)loads -- every time a scene (un)loads
['92,7=0 (weg)'] = true, ['92,7=0 (weg)'] = true,
@ -39,8 +35,17 @@ function poop(x, x1, i, name)
end end
end end
-- obvious todo: use actual classes/objects FlagMonitor = Class()
function diff(self)
function FlagMonitor:init(name, begin, len)
self.name = name
self.begin = begin
self.len = len
self.once = false
self.old_bytes = {}
end
function FlagMonitor:diff()
local bytes = mainmemory.readbyterange(self.begin, self.len) local bytes = mainmemory.readbyterange(self.begin, self.len)
local old_bytes = self.old_bytes local old_bytes = self.old_bytes
if self.once then if self.once then
@ -58,12 +63,12 @@ function diff(self)
end end
-- US 1.0 addresses for the time being -- US 1.0 addresses for the time being
local region1 = Butts('weg', 0x1F0568, 100) -- week_event_reg local weg = FlagMonitor('weg', 0x1F0568, 100) -- week_event_reg
local region2 = Butts('inf', 0x1F067C, 8) -- event_inf local inf = FlagMonitor('inf', 0x1F067C, 8) -- event_inf
local region3 = Butts('mmb', 0x1F3F3A, 8) -- mask_mask_bit (bad address?) local mmb = FlagMonitor('mmb', 0x1F3F3A, 8) -- mask_mask_bit (bad address?)
while true do while true do
diff(region1) weg:diff()
diff(region2) inf:diff()
diff(region3) mmb:diff()
emu.frameadvance() emu.frameadvance()
end end