mirror of
https://github.com/notwa/mm
synced 2024-11-05 00:19:02 -08:00
various updates
This commit is contained in:
parent
25a0df5ded
commit
ce05421797
4 changed files with 126 additions and 60 deletions
25
MM addrs.lua
25
MM addrs.lua
|
@ -69,7 +69,7 @@ local US_10 = {
|
|||
magic_modifier = AL(0x3F28, 4), -- TODO: RE
|
||||
magic_max = AL(0x3F2E, 2),
|
||||
weird_a_graphic = AL(0x3F42, 1),
|
||||
target_style = AL(0x3F45, 1), -- 0 for switch, 1 for target
|
||||
target_style = AL(0x3F45, 1), -- 0 for switch, 1 for hold
|
||||
music_mod = AL(0x3F46, 2),
|
||||
entrance_mod_setter = AL(0x3F4A, 2), -- sets entrance mod. -10 = 0
|
||||
insta_crash = AL(0x3F4C, 1), -- TODO: RE
|
||||
|
@ -159,23 +159,38 @@ local US_10 = {
|
|||
text_open = A(0x3FD33B, 1),
|
||||
text_status = A(0x3FD34A, 1),
|
||||
room_number = A(0x3FF200, 1),
|
||||
room_ptr = A(0x3FF20C, 4),
|
||||
actor_disable = A(0x3FF366, 2), -- set to -10 and load
|
||||
warp_begin = A(0x3FF395, 1), -- set to nonzero to begin warping
|
||||
screen_dim = A(0x3FF397, 1), -- B)
|
||||
warp_destination = A(0x3FF39A, 2),
|
||||
link_scale_x = A(0x3FFE08, 2), -- need to confirm this is x
|
||||
link_scale_y = A(0x3FFE0C, 2), -- need to confirm this is y
|
||||
link_scale_z = A(0x3FFE10, 2), -- need to confirm this is z
|
||||
link_scale_x = A(0x3FFE08, 2),
|
||||
link_scale_y = A(0x3FFE0C, 2),
|
||||
link_scale_z = A(0x3FFE10, 2),
|
||||
z_vel = A(0x3FFE18, 'f'),
|
||||
quick_draw = A(0x3FFEF8, 1), -- item in link's hand
|
||||
animation_id = A(0x3FFFFA, 2),
|
||||
linear_vel = A(0x400880, 'f'),
|
||||
infinite_sword = A(0x40088B, 1),
|
||||
}
|
||||
|
||||
local hash = gameinfo.getromhash()
|
||||
local EU_DBG = {
|
||||
room_ptr = A(0x460DEC, 4),
|
||||
animation_id = A(0x461C1A, 2),
|
||||
}
|
||||
|
||||
local JP_10 = {
|
||||
room_ptr = A(0x3FF3BC, 4),
|
||||
animation_id = A(0x4001EA, 2),
|
||||
}
|
||||
|
||||
local versions = {
|
||||
['D6133ACE5AFAA0882CF214CF88DABA39E266C078'] = US_10,
|
||||
['B38B71D2961DFFB523020A67F4807A4B704E347A'] = EU_DBG,
|
||||
['5FB2301AACBF85278AF30DCA3E4194AD48599E36'] = JP_10,
|
||||
}
|
||||
|
||||
local hash = gameinfo.getromhash()
|
||||
local addrs = versions[hash]
|
||||
|
||||
return addrs
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
--
|
||||
-- go to the fairy's fountain in clock town as human link and run this script.
|
||||
|
||||
local length = 60 -- in frames
|
||||
local length = 70 -- in frames
|
||||
local print_each = true
|
||||
|
||||
local tests = {
|
||||
|
@ -143,7 +143,7 @@ function test_inputs(name, inputs, length)
|
|||
end
|
||||
end
|
||||
if action ~= nil then
|
||||
for i=1, 3 do
|
||||
for _=1, 3 do
|
||||
joypad.setanalog(action, 1)
|
||||
joypad.set(action, 1)
|
||||
emu.frameadvance()
|
||||
|
|
|
@ -1,58 +1,94 @@
|
|||
-- go to a grotto with a red rupee chest, stand in front of it and run this script
|
||||
-- US 1.0 of course
|
||||
|
||||
local start = 0x779884 -- the get item table
|
||||
local ours = 0x779896 -- the chest we're standing in front of
|
||||
local text = 0x3FCE10 -- ascii text buffer
|
||||
local hash = gameinfo.getromhash()
|
||||
local versions = {
|
||||
['D6133ACE5AFAA0882CF214CF88DABA39E266C078'] = 'US10',
|
||||
}
|
||||
local version = versions[hash]
|
||||
|
||||
local JP = version ~= 'US10'
|
||||
|
||||
local index = 84
|
||||
|
||||
local start, ours, text
|
||||
if not JP then
|
||||
-- US 1.0
|
||||
start = 0x779884 -- the get item table
|
||||
ours = 0x779896 -- the chest we're standing in front of
|
||||
text = 0x3FCE10 -- ascii text buffer
|
||||
else
|
||||
start = 0x7797E4 -- the get item table
|
||||
ours = 0x7797F6 -- the chest we're standing in front of
|
||||
text = 0x3FD660 -- ascii text buffer (not quite but close enough)
|
||||
end
|
||||
|
||||
function draw_index()
|
||||
gui.text(304, 8, ("%03i"):format(index), nil, nil, 'bottomleft')
|
||||
end
|
||||
|
||||
function advance()
|
||||
draw_index()
|
||||
emu.frameadvance()
|
||||
draw_index()
|
||||
emu.frameadvance()
|
||||
draw_index()
|
||||
emu.frameadvance()
|
||||
end
|
||||
|
||||
function read_ascii(addr, len)
|
||||
local begin = addr
|
||||
local bytes = mainmemory.readbyterange(begin, 0x100)
|
||||
local str = ""
|
||||
|
||||
-- pairs() won't give us the bytes in order
|
||||
-- so we'll set up a table we can use ipairs() on
|
||||
local ordered_bytes = {}
|
||||
for a, v in pairs(bytes) do
|
||||
ordered_bytes[tonumber(a, 16) - begin + 1] = v
|
||||
end
|
||||
|
||||
local seq = false
|
||||
for i, v in ipairs(ordered_bytes) do
|
||||
local c = tonumber(v, 16)
|
||||
if c == 9 or c == 10 or c == 13 or (c >= 32 and c < 127) then
|
||||
str = str..string.char(c)
|
||||
seq = false
|
||||
elseif seq == false then
|
||||
str = str..' '
|
||||
seq = true
|
||||
end
|
||||
end
|
||||
return str
|
||||
end
|
||||
|
||||
local fn = 'lua chest test'
|
||||
savestate.save(fn)
|
||||
client.unpause()
|
||||
for off=0, 185*6, 6 do
|
||||
savestate.save(fn)
|
||||
for off=index*6, 185*6, 6 do
|
||||
index = index + 1
|
||||
for i=0, 5 do
|
||||
local byte = mainmemory.readbyte(start + off + i)
|
||||
mainmemory.writebyte(ours + i, byte)
|
||||
end
|
||||
gui.addmessage(("%02X"):format(mainmemory.readbyte(start + off)))
|
||||
joypad.set({A=true}, 1)
|
||||
advance()
|
||||
joypad.set({A=false}, 1)
|
||||
local good = false
|
||||
for i=1, 9*20 do
|
||||
if JP and (
|
||||
(index >= 85 and index <= 88)
|
||||
) then break end -- crashes
|
||||
advance()
|
||||
if mainmemory.readbyte(text + 0xA) == 0xFF then
|
||||
local begin = text + 0xC
|
||||
local bytes = mainmemory.readbyterange(begin, 0x100)
|
||||
local str = ""
|
||||
|
||||
-- pairs() won't give us the bytes in order
|
||||
-- so we'll set up a table we can use ipairs() on
|
||||
local ordered_bytes = {}
|
||||
for a, v in pairs(bytes) do
|
||||
ordered_bytes[tonumber(a, 16) - begin + 1] = v
|
||||
end
|
||||
|
||||
local seq = false
|
||||
for i, v in ipairs(ordered_bytes) do
|
||||
local c = tonumber(v, 16)
|
||||
if c == 9 or c == 10 or c == 13 or (c >= 32 and c < 127) then
|
||||
str = str..string.char(c)
|
||||
seq = false
|
||||
elseif seq == false then
|
||||
str = str..' '
|
||||
seq = true
|
||||
if not JP then
|
||||
local begin = text + 0xC
|
||||
print(off/6 + 1, read_ascii(begin))
|
||||
good = true
|
||||
else
|
||||
for _=1, 40 do
|
||||
advance()
|
||||
end
|
||||
end
|
||||
|
||||
print(off/6 + 1, str)
|
||||
|
||||
good = true
|
||||
break
|
||||
end
|
||||
end
|
||||
|
|
|
@ -3,32 +3,47 @@
|
|||
|
||||
local mm = mainmemory
|
||||
|
||||
function M1(self, value)
|
||||
return (value and mm.writebyte or mm.readbyte)(self.addr, value)
|
||||
end
|
||||
function M2(self, value)
|
||||
return (value and mm.write_u16_be or mm.read_u16_be)(self.addr, value)
|
||||
end
|
||||
function M3(self, value)
|
||||
return (value and mm.write_u24_be or mm.read_u24_be)(self.addr, value)
|
||||
end
|
||||
function M4(self, value)
|
||||
return (value and mm.write_u32_be or mm.read_u32_be)(self.addr, value)
|
||||
end
|
||||
function MF(self, value)
|
||||
return (value and mm.writefloat or mm.readfloat)(self.addr, value or true, true)
|
||||
end
|
||||
R1 = mm.readbyte
|
||||
R2 = mm.read_u16_be
|
||||
R3 = mm.read_u24_be
|
||||
R4 = mm.read_u32_be
|
||||
RF = function(addr) mm.readfloat(addr, true) end
|
||||
|
||||
local Ms = {
|
||||
[1] = {__call = M1},
|
||||
[2] = {__call = M2},
|
||||
[3] = {__call = M3},
|
||||
[4] = {__call = M4},
|
||||
['f'] = {__call = MF},
|
||||
W1 = mm.writebyte
|
||||
W2 = mm.write_u16_be
|
||||
W3 = mm.write_u24_be
|
||||
W4 = mm.write_u32_be
|
||||
WF = function(addr, value) mm.writefloat(addr, value, true) end
|
||||
|
||||
local readers = {
|
||||
[1] = R1,
|
||||
[2] = R2,
|
||||
[3] = R3,
|
||||
[4] = R4,
|
||||
['f'] = RF,
|
||||
}
|
||||
|
||||
local writers = {
|
||||
[1] = W1,
|
||||
[2] = W2,
|
||||
[3] = W3,
|
||||
[4] = W4,
|
||||
['f'] = WF,
|
||||
}
|
||||
|
||||
local mt = {
|
||||
__call = function(self, value)
|
||||
return value and self.write(self.addr, value) or self.read(self.addr)
|
||||
end
|
||||
}
|
||||
|
||||
function A(addr, atype)
|
||||
return setmetatable({addr=addr, type=atype}, Ms[atype])
|
||||
return setmetatable({
|
||||
addr=addr,
|
||||
type=atype,
|
||||
read=readers[atype],
|
||||
write=writers[atype]
|
||||
}, mt)
|
||||
end
|
||||
|
||||
--[[
|
||||
|
|
Loading…
Reference in a new issue