mirror of
https://github.com/notwa/mm
synced 2024-11-05 00:19:02 -08:00
flag dumping
This commit is contained in:
parent
9dc97426c7
commit
391c51575c
2 changed files with 55 additions and 12 deletions
|
@ -11,15 +11,24 @@ function Monitor:init(name, a)
|
||||||
self.dirty = false
|
self.dirty = false
|
||||||
end
|
end
|
||||||
|
|
||||||
function Monitor:diff()
|
function Monitor:read()
|
||||||
-- bizhawk has an off-by-one bug where this returns length + 1 bytes
|
-- bizhawk has an off-by-one bug where this returns length + 1 bytes
|
||||||
local bytes = mainmemory.readbyterange(self.begin, self.len-1)
|
local raw = mainmemory.readbyterange(self.begin, self.len-1)
|
||||||
|
local bytes = {}
|
||||||
|
local begin = self.begin
|
||||||
|
for k, v in pairs(raw) do
|
||||||
|
bytes[k - begin] = v
|
||||||
|
end
|
||||||
|
return bytes
|
||||||
|
end
|
||||||
|
|
||||||
|
function Monitor:diff()
|
||||||
|
local bytes = self:read()
|
||||||
local old_bytes = self.old_bytes
|
local old_bytes = self.old_bytes
|
||||||
if self.once then
|
if self.once then
|
||||||
for k, v in pairs(bytes) do
|
for i, v in pairs(bytes) do
|
||||||
local i = k - self.begin
|
|
||||||
local x = v
|
local x = v
|
||||||
local x1 = old_bytes[k]
|
local x1 = old_bytes[i]
|
||||||
if x ~= x1 then
|
if x ~= x1 then
|
||||||
self:mark(i, x, x1)
|
self:mark(i, x, x1)
|
||||||
end
|
end
|
||||||
|
|
|
@ -53,10 +53,44 @@ function FlagMonitor:mark(i, x, x1)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function FlagMonitor:dump(current)
|
||||||
|
local t = current and self:read() or self.modified
|
||||||
|
|
||||||
|
local size = mm and 8 or 16
|
||||||
|
local rows = math.floor(self.len/size*8)
|
||||||
|
|
||||||
|
local buff = self.name..'\n'
|
||||||
|
|
||||||
|
buff = buff..' \t'
|
||||||
|
for col = size-1, 0, -1 do
|
||||||
|
buff = buff..('%X'):format(col)
|
||||||
|
if col % 4 == 0 then buff = buff..' ' end
|
||||||
|
end
|
||||||
|
|
||||||
|
for row = 0, rows-1 do
|
||||||
|
s = ('%02i\t'):format(row)
|
||||||
|
for col = size-1, 0, -1 do
|
||||||
|
local B, b = row, col
|
||||||
|
if size == 16 then
|
||||||
|
B = row*2 + (col < 8 and 1 or 0)
|
||||||
|
b = col % 8
|
||||||
|
end
|
||||||
|
local ib = B*8 + b
|
||||||
|
local v
|
||||||
|
if current then v = bit.band(t[B], 2^b) > 0 else v = t[ib] end
|
||||||
|
s = s..(v and '1' or '0')
|
||||||
|
if col % 4 == 0 then s = s..' ' end
|
||||||
|
end
|
||||||
|
buff = buff..'\n'..s
|
||||||
|
end
|
||||||
|
|
||||||
|
return buff
|
||||||
|
end
|
||||||
|
|
||||||
if mm then
|
if mm then
|
||||||
local weg = FlagMonitor('weg', addrs.week_event_reg)
|
weg = FlagMonitor('weg', addrs.week_event_reg)
|
||||||
local inf = FlagMonitor('inf', addrs.event_inf)
|
inf = FlagMonitor('inf', addrs.event_inf)
|
||||||
local mmb = FlagMonitor('mmb', addrs.mask_mask_bit)
|
mmb = FlagMonitor('mmb', addrs.mask_mask_bit)
|
||||||
weg:load('data/_weg.lua')
|
weg:load('data/_weg.lua')
|
||||||
inf:load('data/_inf.lua')
|
inf:load('data/_inf.lua')
|
||||||
while mm do
|
while mm do
|
||||||
|
@ -69,10 +103,10 @@ if mm then
|
||||||
emu.frameadvance()
|
emu.frameadvance()
|
||||||
end
|
end
|
||||||
elseif oot then
|
elseif oot then
|
||||||
local eci = FlagMonitor('eci', AL(0xED4, 0x1C))
|
eci = FlagMonitor('eci', AL(0xED4, 0x1C))
|
||||||
local igi = FlagMonitor('igi', AL(0xEF0, 0x8))
|
igi = FlagMonitor('igi', AL(0xEF0, 0x8))
|
||||||
local it_ = FlagMonitor('it ', AL(0xEF8, 0x3C))
|
it_ = FlagMonitor('it ', AL(0xEF8, 0x3C))
|
||||||
local ei_ = FlagMonitor('ei ', AL(0x13FA, 0x8))
|
ei_ = FlagMonitor('ei ', AL(0x13FA, 0x8))
|
||||||
eci:load('data/_eci.lua')
|
eci:load('data/_eci.lua')
|
||||||
igi:load('data/_igi.lua')
|
igi:load('data/_igi.lua')
|
||||||
it_:load('data/_it.lua')
|
it_:load('data/_it.lua')
|
||||||
|
|
Loading…
Reference in a new issue