mirror of
https://github.com/notwa/mm
synced 2024-11-04 20:09:03 -08:00
27 lines
631 B
Lua
27 lines
631 B
Lua
|
Monitor = Class()
|
||
|
function Monitor:init(name, a)
|
||
|
self.name = name
|
||
|
self.begin = a.addr
|
||
|
self.len = a.type
|
||
|
self.once = false
|
||
|
self.old_bytes = {}
|
||
|
end
|
||
|
|
||
|
function Monitor:diff()
|
||
|
local bytes = mainmemory.readbyterange(self.begin, self.len)
|
||
|
local old_bytes = self.old_bytes
|
||
|
if self.once then
|
||
|
for k, v in pairs(bytes) do
|
||
|
local i = tonumber(k) - self.begin
|
||
|
local x = tonumber(v)
|
||
|
local x1 = tonumber(old_bytes[k])
|
||
|
if x ~= x1 then
|
||
|
self:mark(i, x, x1)
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
self.old_bytes = bytes
|
||
|
self.once = true
|
||
|
end
|
||
|
|