mirror of
https://github.com/notwa/mm
synced 2024-11-05 02:29:03 -08:00
merge actor change into actor lister
This commit is contained in:
parent
9bfad76e3d
commit
e4a32dd945
5 changed files with 195 additions and 236 deletions
|
@ -47,8 +47,8 @@ function Actor(addr)
|
|||
z_vel = AA(0x64, 'f'),
|
||||
--lin_vel_old = AA(0x70, 'f'),
|
||||
--ground_y = AA(0x88, 'f'),
|
||||
damage_table = AA(0xA0, 4), -- FIXME
|
||||
--hp = AA(0xB7, 1), -- FIXME
|
||||
damage_table = AA(0x98, 4),
|
||||
hp = AA(0xAF, 1),
|
||||
--angle = AA(0xBA, 2),
|
||||
--foot_left_x = AA(0xD4, 'f'),
|
||||
--foot_left_y = AA(0xD8, 'f'),
|
||||
|
@ -118,30 +118,30 @@ local common = {
|
|||
c_right_slot = AL(0x6E, 1),
|
||||
b_button_slot = AL(0x6F, 1), -- unused?
|
||||
|
||||
ocarina = AL(0x74, 1),
|
||||
bow = AL(0x75, 1), -- FIXME
|
||||
fire_arrows = AL(0x76, 1),
|
||||
ice_arrows = AL(0x77, 1),
|
||||
light_arrows = AL(0x78, 1),
|
||||
event_1 = AL(0x79, 1),
|
||||
bombs = AL(0x7A, 1),
|
||||
bombchu = AL(0x7B, 1),
|
||||
deku_stick = AL(0x7C, 1),
|
||||
deku_nut = AL(0x7D, 1),
|
||||
magic_beans = AL(0x7E, 1),
|
||||
event_2 = AL(0x7F, 1),
|
||||
powder_keg = AL(0x80, 1),
|
||||
pictograph = AL(0x81, 1),
|
||||
lens_of_truth = AL(0x82, 1),
|
||||
hookshot = AL(0x83, 1),
|
||||
fairy_sword = AL(0x84, 1),
|
||||
event_3 = AL(0x85, 1),
|
||||
deku_stick = AL(0x74, 1),
|
||||
deku_nut = AL(0x75, 1),
|
||||
bombs = AL(0x76, 1),
|
||||
bow = AL(0x77, 1),
|
||||
fire_arrows = AL(0x78, 1),
|
||||
dins_fire = AL(0x79, 1),
|
||||
slingshot = AL(0x7A, 1),
|
||||
ocarina = AL(0x7B, 1),
|
||||
bombchu = AL(0x7C, 1),
|
||||
hookshot = AL(0x7D, 1),
|
||||
ice_arrows = AL(0x7E, 1),
|
||||
farores_wind = AL(0x7F, 1),
|
||||
boomerang = AL(0x80, 1),
|
||||
lens_of_truth = AL(0x81, 1),
|
||||
magic_beans = AL(0x82, 1),
|
||||
hammer = AL(0x83, 1),
|
||||
light_arrows = AL(0x84, 1),
|
||||
nayrus_love = AL(0x85, 1),
|
||||
bottle_1 = AL(0x85, 1),
|
||||
bottle_2 = AL(0x86, 1),
|
||||
bottle_3 = AL(0x87, 1),
|
||||
bottle_4 = AL(0x88, 1),
|
||||
bottle_5 = AL(0x89, 1),
|
||||
bottle_6 = AL(0x8A, 1),
|
||||
trade_1 = AL(0x89, 1),
|
||||
trade_2 = AL(0x8A, 1),
|
||||
},
|
||||
quantities = {
|
||||
arrows = AL(0xA1, 1), -- FIXME
|
||||
|
|
|
@ -1,180 +0,0 @@
|
|||
require "boilerplate"
|
||||
local addrs = require "addrs"
|
||||
local actor_names = require "actor names"
|
||||
|
||||
local actor_t = Actor(0) -- lolololol memory leaks
|
||||
|
||||
local actor_type = 2
|
||||
local actor_index = 0
|
||||
|
||||
local pressed = {}
|
||||
local old_ctrl = {}
|
||||
|
||||
function get_actor_count(i)
|
||||
return R4(addrs.actor_count_0.addr + i*0xC)
|
||||
end
|
||||
|
||||
function get_first_actor(i)
|
||||
return bit.band(R4(addrs.actor_first_0.addr + i*0xC), 0x7FFFFFFF)
|
||||
end
|
||||
|
||||
function get_next_actor(addr)
|
||||
--return bit.band(Actor(addr).next(), 0x7FFFFFFF)
|
||||
return bit.band(R4(addr + actor_t.next.addr), 0x7FFFFFFF)
|
||||
end
|
||||
|
||||
function T(x, y, s, color, pos)
|
||||
color = color or "white"
|
||||
pos = pos or "bottomright"
|
||||
gui.text(10*x + 2, 16*y + 4, s, nil, color, pos)
|
||||
end
|
||||
|
||||
damage_names = {
|
||||
[0]="Nut",
|
||||
"Stick",
|
||||
"Epona",
|
||||
"Bomb",
|
||||
"(Z)Fins",
|
||||
"Bow",
|
||||
"Mirror?",
|
||||
"Hook",
|
||||
"(G)Punch",
|
||||
"Sword",
|
||||
"(G)Pound",
|
||||
"Fire",
|
||||
"Ice",
|
||||
"Light",
|
||||
"(G)Spikes",
|
||||
"(D)Spin",
|
||||
"(D)Shoot",
|
||||
"(D)Dive",
|
||||
"(D)Bomb",
|
||||
"(Z)Barrier",
|
||||
"?",
|
||||
"?",
|
||||
"Bush",
|
||||
"(Z)Karate",
|
||||
"M. Spin",
|
||||
"(F)Beam",
|
||||
"Roll",
|
||||
"?",
|
||||
"?",
|
||||
"?",
|
||||
"?",
|
||||
"Keg",
|
||||
}
|
||||
|
||||
while true do
|
||||
local j = joypad.getimmediate()
|
||||
|
||||
local ctrl = {
|
||||
enter = j["P1 L"],
|
||||
up = j["P1 DPad U"],
|
||||
down = j["P1 DPad D"],
|
||||
left = j["P1 DPad L"],
|
||||
right = j["P1 DPad R"],
|
||||
}
|
||||
|
||||
for k, v in pairs(ctrl) do
|
||||
pressed[k] = ctrl[k] and not old_ctrl[k]
|
||||
end
|
||||
|
||||
if pressed.left or ctrl.enter then
|
||||
actor_index = actor_index - 1
|
||||
end
|
||||
if pressed.right then
|
||||
actor_index = actor_index + 1
|
||||
end
|
||||
if pressed.down then
|
||||
-- follow Link again
|
||||
actor_type = 2
|
||||
actor_index = 0
|
||||
end
|
||||
|
||||
local any = 0
|
||||
for i = 0, 11 do
|
||||
local count = get_actor_count(i)
|
||||
T(0, 12 - i, ("#%2i: %2i"):format(i, count), "white", "bottomleft")
|
||||
any = any + count
|
||||
end
|
||||
T(0, 0, ("sum:%3i"):format(any), "white", "bottomleft")
|
||||
|
||||
local actor_count = get_actor_count(actor_type)
|
||||
if any > 0 then
|
||||
while actor_index < 0 do
|
||||
actor_type = (actor_type - 1) % 12
|
||||
actor_count = get_actor_count(actor_type)
|
||||
actor_index = actor_count - 1
|
||||
end
|
||||
while actor_index >= actor_count do
|
||||
actor_type = (actor_type + 1) % 12
|
||||
actor_count = get_actor_count(actor_type)
|
||||
actor_index = 0
|
||||
end
|
||||
|
||||
local addr = get_first_actor(actor_type)
|
||||
T(0, 2, ('type: %02X'):format(actor_type))
|
||||
T(0, 1, ('index: %02X'):format(actor_index))
|
||||
T(0, 0, ('count: %02X'):format(actor_count))
|
||||
if actor_index > 0 then
|
||||
for i = 0, actor_index - 1 do
|
||||
addr = get_next_actor(addr)
|
||||
if addr == 0 then
|
||||
T(0, 3, "no actor found", "yellow")
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
if addr ~= 0 then
|
||||
--local actor = Actor(addr)
|
||||
local num = R2(addr + actor_t.num.addr)
|
||||
local var = R2(addr + actor_t.var.addr)
|
||||
local hp = R1(addr + actor_t.hp.addr)
|
||||
T(0, 3, ('80%06X'):format(addr))
|
||||
T(0, 5, ('No.: %03X'):format(num), 'cyan')
|
||||
T(0, 4, ('Var: %04X'):format(var))
|
||||
T(0, 6, ('HP: %02X'):format(hp))
|
||||
local name = actor_names[num]
|
||||
if name then
|
||||
local color = name == "TODO" and "red" or "orange"
|
||||
T(0, 8, name, color)
|
||||
else
|
||||
actor_names[num] = "TODO"
|
||||
print(('\t[0x%03X]="???",'):format(num))
|
||||
end
|
||||
--T(0, 3, ('Type: %02X'):format(R1(addr+2)))
|
||||
|
||||
local dmg_t = R4(addr + actor_t.damage_table.addr)
|
||||
local dmg = bit.band(dmg_t, 0x7FFFFFFF)
|
||||
if dmg == 0 then
|
||||
T(0, 7, "no damage table")
|
||||
else
|
||||
for i = 0, 31 do
|
||||
--T(0, 11 - i/4, ('dmg %02i: %08X'):format(i, R4(dmg + i)))
|
||||
local name = damage_names[i]
|
||||
local str = ('%9s: %02X'):format(name, R1(dmg + i))
|
||||
local pos = 'topleft'
|
||||
if i >= 16 then i = i - 16; pos = 'topright' end
|
||||
T(0, i, str, 'white', pos)
|
||||
end
|
||||
|
||||
if pressed.up then
|
||||
console.clear()
|
||||
s = ('%04X\t%02X\t%02X'):format(num, actor_type, hp)
|
||||
for i = 0, 31 do
|
||||
s = s..('\t%02X'):format(R1(dmg + i))
|
||||
end
|
||||
print(s)
|
||||
end
|
||||
end
|
||||
|
||||
--T(0, 12, ("%08X"):format(addrs.camera_target()), 'white', 'bottomleft')
|
||||
-- avoid floating point error by our write small
|
||||
W1(addrs.camera_target.addr, 0x80)
|
||||
W3(addrs.camera_target.addr + 1, addr)
|
||||
end
|
||||
end
|
||||
|
||||
old_ctrl = ctrl
|
||||
emu.frameadvance()
|
||||
end
|
|
@ -1,5 +1,5 @@
|
|||
require "boilerplate"
|
||||
local addrs = require "addrs"
|
||||
require "addrs"
|
||||
|
||||
-- bizhawk lua has some nasty memory leaks at the moment,
|
||||
-- so instead of creating an object every time,
|
||||
|
@ -9,11 +9,13 @@ local actor_t = Actor(0)
|
|||
local oot = version:sub(1, 2) == "O "
|
||||
local al_next = addrs.actor_count_1.addr - addrs.actor_count_0.addr
|
||||
|
||||
local actor_names
|
||||
local actor_names, damage_names
|
||||
if oot then
|
||||
actor_names = require "actor names oot"
|
||||
damage_names = require "damage names oot"
|
||||
else
|
||||
actor_names = require "actor names"
|
||||
damage_names = require "damage names"
|
||||
end
|
||||
|
||||
function T(x, y, s, color, pos)
|
||||
|
@ -56,6 +58,7 @@ function iter_actors(counts)
|
|||
local once = false
|
||||
local addr
|
||||
return function()
|
||||
if not counts then return nil end
|
||||
if once then ai = ai + 1 end
|
||||
once = true
|
||||
|
||||
|
@ -79,11 +82,35 @@ function iter_actors(counts)
|
|||
end
|
||||
end
|
||||
|
||||
local ctrl
|
||||
local pressed = {}
|
||||
local old_ctrl = {}
|
||||
function update_input()
|
||||
local j = joypad.getimmediate()
|
||||
|
||||
ctrl = {
|
||||
enter = j["P1 L"],
|
||||
up = j["P1 DPad U"],
|
||||
down = j["P1 DPad D"],
|
||||
left = j["P1 DPad L"],
|
||||
right = j["P1 DPad R"],
|
||||
}
|
||||
|
||||
for k, v in pairs(ctrl) do
|
||||
pressed[k] = ctrl[k] and not old_ctrl[k]
|
||||
end
|
||||
|
||||
old_ctrl = ctrl
|
||||
end
|
||||
|
||||
local seen = {}
|
||||
local seen_strs = {}
|
||||
local seen_strs_sorted = {}
|
||||
local last_any = 0
|
||||
|
||||
local focus_at = 2
|
||||
local focus_ai = 0
|
||||
|
||||
-- hack to avoid N64 logo spitting errors
|
||||
local stupid = addrs.actor_count_0.addr - 0x8
|
||||
|
||||
|
@ -92,6 +119,20 @@ while true do
|
|||
local game_count = 0
|
||||
local counts = nil
|
||||
|
||||
update_input()
|
||||
|
||||
if pressed.left then
|
||||
focus_ai = focus_ai - 1
|
||||
end
|
||||
if pressed.right then
|
||||
focus_ai = focus_ai + 1
|
||||
end
|
||||
if pressed.down then
|
||||
-- follow Link again
|
||||
focus_at = 2
|
||||
focus_ai = 0
|
||||
end
|
||||
|
||||
if R4(stupid) ~= 0 then
|
||||
T_BR(0, 14, "stupid", "red")
|
||||
any = 0
|
||||
|
@ -120,43 +161,31 @@ while true do
|
|||
print("# actors wiped #")
|
||||
print()
|
||||
end
|
||||
else
|
||||
while focus_ai < 0 do
|
||||
focus_at = (focus_at - 1) % 12
|
||||
focus_ai = counts[focus_at] - 1
|
||||
end
|
||||
while focus_ai >= counts[focus_at] do
|
||||
focus_at = (focus_at + 1) % 12
|
||||
focus_ai = 0
|
||||
end
|
||||
end
|
||||
|
||||
local focus_link = focus_at == 2 and focus_ai == 0
|
||||
|
||||
local needs_update = false
|
||||
local at = 2
|
||||
local ai = 0
|
||||
local j = 0
|
||||
for at, ai, addr in iter_actors(counts) do
|
||||
--T(0, 0, ("%02i:%02i"):format(at, ai))
|
||||
--print(("%02i:%02i"):format(at, ai))
|
||||
--local num = R2(addr + actor_t.num.addr)
|
||||
local num = R2(addr)
|
||||
local num = R2(addr + actor_t.num.addr)
|
||||
local name = actor_names[num]
|
||||
|
||||
if name == nil and num < 0x300 then
|
||||
if not name then
|
||||
name = "NEW"
|
||||
actor_names[num] = name
|
||||
print(("\t[0x%03X]=\"NEW\","):format(num))
|
||||
|
||||
if actor_t.damage_table and actor_t.hp then
|
||||
local dmg = pmask(addr + actor_t.damage_table.addr)
|
||||
if dmg == 0 then
|
||||
print("(no damage table)")
|
||||
else
|
||||
local hp = R1(addr + actor_t.hp.addr)
|
||||
s = ("%04X\t%02X\t%02X"):format(num, at, hp)
|
||||
for i = 0, 31 do
|
||||
s = s..("\t%02X"):format(R1(dmg + i))
|
||||
end
|
||||
print(s)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if num > 0x300 then
|
||||
print(("BAD %06X %04X (%2i:%2i)"):format(addr, num, at, ai))
|
||||
actor_names[num] = "BAD"
|
||||
elseif not seen[num] then
|
||||
if not seen[num] then
|
||||
seen[num] = true
|
||||
needs_update = true
|
||||
local str
|
||||
|
@ -169,10 +198,49 @@ while true do
|
|||
print(str)
|
||||
end
|
||||
|
||||
j = j + 1
|
||||
if j > 255 then
|
||||
print("something went terribly wrong")
|
||||
do return end
|
||||
local focus_this = at == focus_at and ai == focus_ai
|
||||
|
||||
if focus_this and not focus_link then
|
||||
T_BL(0, 2, ('type: %02X'):format(at))
|
||||
T_BL(0, 1, ('index: %02X'):format(ai))
|
||||
T_BL(0, 0, ('count: %02X'):format(counts[at]))
|
||||
|
||||
local var = R2(addr + actor_t.var.addr)
|
||||
local hp = R1(addr + actor_t.hp.addr)
|
||||
T_BL(0, 3, ('80%06X'):format(addr))
|
||||
T_BL(0, 5, ('No.: %03X'):format(num), 'cyan')
|
||||
T_BL(0, 4, ('Var: %04X'):format(var))
|
||||
T_BL(0, 6, ('HP: %02X'):format(hp))
|
||||
|
||||
local color = name:sub(1,1) == "?" and "red" or "orange"
|
||||
T_BL(0, 7, name, color)
|
||||
|
||||
local dmg = pmask(R4(addr + actor_t.damage_table.addr))
|
||||
if dmg > 0 then
|
||||
for i = 0, 31 do
|
||||
local name = damage_names[i]
|
||||
local str = ('%9s: %02X'):format(name, R1(dmg + i))
|
||||
local pos = 'topleft'
|
||||
if i >= 16 then i = i - 16; pos = 'topright' end
|
||||
T(0, i, str, nil, pos)
|
||||
end
|
||||
end
|
||||
|
||||
if pressed.up then
|
||||
console.clear()
|
||||
s = ("%04X\t%02X\t%02X"):format(num, at, hp)
|
||||
if dmg > 0 then
|
||||
for i = 0, 31 do
|
||||
s = s..("\t%02X"):format(R1(dmg + i))
|
||||
end
|
||||
end
|
||||
print(s)
|
||||
end
|
||||
end
|
||||
|
||||
if focus_this then
|
||||
W1(addrs.camera_target.addr, 0x80)
|
||||
W3(addrs.camera_target.addr + 1, addr)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -192,8 +260,11 @@ while true do
|
|||
if needs_update then
|
||||
seen_strs_sorted = sort_by_key(seen_strs)
|
||||
end
|
||||
for i, t in ipairs(seen_strs_sorted) do
|
||||
T_TL(0, i - 1, t.v)
|
||||
|
||||
if focus_link then
|
||||
for i, t in ipairs(seen_strs_sorted) do
|
||||
T_TL(0, i - 1, t.v)
|
||||
end
|
||||
end
|
||||
|
||||
T_BR(0, 0, ("unique:%3i"):format(#seen_strs_sorted))
|
||||
|
|
34
Lua/damage names oot.lua
Normal file
34
Lua/damage names oot.lua
Normal file
|
@ -0,0 +1,34 @@
|
|||
return {
|
||||
[0]="Nut",
|
||||
"Stick/Pot",
|
||||
"Slingshot",
|
||||
"Explosion",
|
||||
"Boomerang",
|
||||
"Arrow",
|
||||
"Hammer",
|
||||
"Hookshot",
|
||||
"(K)Slash",
|
||||
"(K)Jump/(M)Slash", -- Spin/Jump
|
||||
"(B)Slash",
|
||||
"(A)Fire",
|
||||
"(A)Ice",
|
||||
"(A)Light",
|
||||
"(A)4",
|
||||
"(A)5",
|
||||
"(A)6",
|
||||
"Din's Fire",
|
||||
"Ice Magic",
|
||||
"Light Magic",
|
||||
"?",
|
||||
"?",
|
||||
"(K)Spin", -- Blue Spin
|
||||
"(G)Spin",
|
||||
"(M)Spin",
|
||||
"(BG)Jump", -- Spin/Jump?
|
||||
"(G)Jump", -- Spin/Jump
|
||||
"(M)Jump",
|
||||
"?",
|
||||
"?",
|
||||
"(H)Jump",
|
||||
"?",
|
||||
}
|
34
Lua/damage names.lua
Normal file
34
Lua/damage names.lua
Normal file
|
@ -0,0 +1,34 @@
|
|||
return {
|
||||
[0]="Nut",
|
||||
"Stick",
|
||||
"Epona",
|
||||
"Bomb",
|
||||
"(Z)Fins",
|
||||
"Bow",
|
||||
"Mirror?",
|
||||
"Hook",
|
||||
"(G)Punch",
|
||||
"Sword",
|
||||
"(G)Pound",
|
||||
"Fire",
|
||||
"Ice",
|
||||
"Light",
|
||||
"(G)Spikes",
|
||||
"(D)Spin",
|
||||
"(D)Shoot",
|
||||
"(D)Dive",
|
||||
"(D)Bomb",
|
||||
"(Z)Barrier",
|
||||
"?",
|
||||
"?",
|
||||
"Bush",
|
||||
"(Z)Karate",
|
||||
"M. Spin", -- ???
|
||||
"(F)Beam",
|
||||
"Roll",
|
||||
"?",
|
||||
"?",
|
||||
"?",
|
||||
"?",
|
||||
"Keg",
|
||||
}
|
Loading…
Reference in a new issue