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

49 lines
1.4 KiB
Lua
Raw Normal View History

2016-01-12 15:54:42 -08:00
require "lib.setup"
2015-12-28 22:04:39 -08:00
require "boilerplate"
2016-01-13 07:56:18 -08:00
require "addrs"
2015-12-28 22:04:39 -08:00
require "messages"
require "actors"
local actor_names = require "data.actor names"
local epona_addr = 0
while true do
local nearest = {}
local offset = 0x800000
for at, ai, addr in iter_actors() do
local actor_number = R2(addr)
2015-12-30 02:35:58 -08:00
local name = actor_names[actor_number] or "[error]"
2015-12-28 22:04:39 -08:00
local size = R4(addr - 0xC) -- read linked list data above the actor
if actor_number == 0x00D then
epona_addr = addr
end
if epona_addr then
local diff = addr - epona_addr
if diff >= 0 and diff < offset then
offset = diff
2015-12-30 02:35:58 -08:00
nearest.name = name
2015-12-28 22:04:39 -08:00
nearest.addr = addr
nearest.at = at
nearest.ai = ai
nearest.size = size
end
end
end
if nearest.addr then
local color = offset <= nearest.size and 'white' or 'yellow'
T_BR(0, 4, 'white', 'Epona: %06X', epona_addr)
T_BR(0, 3, 'white', '%s: %06X', nearest.name, nearest.addr)
T_BR(0, 2, color, 'Offset: %06X', offset)
T_BR(0, 1, color, 'Size: %06X', nearest.size)
T_BR(0, 0, 'white', 'Type, Index: %2i, %2i', nearest.at, nearest.ai)
else
T_BR(0, 0, 'yellow', 'Epona not found')
2015-12-30 02:35:58 -08:00
epona_addr = nil
2015-12-28 22:04:39 -08:00
end
emu.frameadvance()
end