1
0
Fork 0
mirror of https://github.com/notwa/mm synced 2024-11-05 00:29:02 -08:00
mm/Lua/oot memory editor monitor.lua

60 lines
1.5 KiB
Lua
Raw Normal View History

2015-05-01 06:16:44 -07:00
require "boilerplate"
require "addrs.init"
2015-05-01 08:40:32 -07:00
require "classes"
2015-05-01 06:16:44 -07:00
local blocknames = {
'R ', 'RS', 'RO', 'RP',
'RQ', 'RM', 'RY', 'RD',
'RU', 'RI', 'RZ', 'RC',
'RN', 'RK', 'RX', 'Rc',
'Rs', 'Ri', 'RW', 'RA',
'RV', 'RH', 'RG', 'Rm',
'Rn', 'RB', 'Rd', 'Rk',
'Rb',
}
function distribute_index(ih)
2015-05-01 06:16:44 -07:00
local block = math.floor(ih/16/6)
local ir = ih - block*16*6
local page = math.floor(ir/16)
local row = ir - page*16
return block, page, row
end
2015-05-01 08:40:32 -07:00
ShortMonitor = Class(Monitor)
2015-05-01 06:16:44 -07:00
function ShortMonitor:mark(i, x, x1)
local ih = math.floor(i/2)
if not self.modified[ih] then
2015-05-01 06:16:44 -07:00
self.modified[ih] = true
self.dirty = true
local block, page, row = distribute_index(ih)
2015-05-01 06:16:44 -07:00
printf('%2s Page %1i Row %3i', blocknames[block+1], page+1, row+1)
end
end
function ShortMonitor:dump()
local buff = ''
for i=0, self.len/2 - 1 do
local ih = i
local block, page, row = distribute_index(ih)
2015-05-01 06:16:44 -07:00
local mod = self.modified[ih]
2015-05-01 11:48:49 -07:00
local value = R2(self.begin + ih*2)
2015-05-01 08:40:32 -07:00
local vs = mod and 'n/a' or ('%04X'):format(value)
2015-05-01 09:37:56 -07:00
local name = ('%s%02i'):format(blocknames[block+1], page*16 + row)
local s = ('%s\t%i\t%i\t%s\n'):format(name, page+1, row+1, vs)
2015-05-01 06:16:44 -07:00
buff = buff..s
end
print(buff)
end
-- 2 bytes each, 16 values per page, 6 pages per block, 29 blocks
-- = 5568 bytes (0x15C0)
me = ShortMonitor('me', A(0x210A24, 0x15C0))
2015-05-03 10:37:45 -07:00
me:load('data/_ootmemod.lua')
2015-05-01 09:37:56 -07:00
while version == "O EUDB MQ" do
2015-05-01 06:16:44 -07:00
me:diff()
2015-05-03 10:37:45 -07:00
me:save()
2015-05-01 06:16:44 -07:00
emu.frameadvance()
end