1
0
Fork 0
mirror of https://github.com/notwa/mm synced 2024-05-16 12:43:24 -07:00

get older scripts up to speed; refactor

This commit is contained in:
Connor Olding 2015-05-01 11:15:53 -07:00
parent b29e57b57a
commit 013b4d015a
7 changed files with 38 additions and 165 deletions

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
lua chest test
lua movement test
_ootmemod.lua
_anims_seen.lua

View File

@ -23,7 +23,7 @@ function Actor(addr)
ground_y = AA(0x88, 'f'),
damage_table = AA(0xA0, 4),
hp = AA(0xB7, 1),
angle = AA(0xBA, 2),
angle = AA(0xBE, 2),
foot_left_x = AA(0xD4, 'f'), -- tested on Link, may be other things
foot_left_y = AA(0xD8, 'f'),
foot_left_z = AA(0xDC, 'f'),
@ -300,14 +300,12 @@ return {
warp_destination = AG(0x1887A, 2),
entrance_entered = AG(0x18B48, 1),
--[[ FIXME
link_actor = merge(Actor(AA(0,0).addr), {
link_actor = setmetatable({
item_in_hand = AA(0x148, 1),
animation_id = AA(0x24A, 2),
link_flags = AA(0xA6C, 0xC),
lin_vel = AA(0xAD0, 'f'),
movement_angle = AA(0xAD4, 2),
active_sword = AA(0xADB, 1),
}),
--]]
}, {__index = Actor(AA(0,0).addr)})
}

View File

@ -21,14 +21,18 @@ function hamming_of(addr, size)
return weight
end
function hamming_of_A(a)
return hamming_of(a.addr, a.type)
end
print("###")
local current = 0
for i = 1, 5 do
local addr = addrs['current_scene_flags_'..tostring(i)].addr
current = current + hamming_of(addr, 4)
end
local ingame = hamming_of(addrs.scene_flags_ingame.addr, 0x960)
local save = hamming_of(addrs.scene_flags_save.addr, 0x960)
local ingame = hamming_of_A(addrs.scene_flags_ingame)
local save = hamming_of_A(addrs.scene_flags_save)
print("current", current)
print("ingame ", ingame)
print("save ", save)

View File

@ -1,8 +1,8 @@
-- movement speed testing in Majora's Mask
-- by notwa, for Bizhawk 1.9.1, ROM version US 1.0
--
-- go to the fairy's fountain in clock town as human link and run this script.
require "addrs.init"
local length = 70 -- in frames
local print_each = true
@ -56,13 +56,10 @@ local tests = {
},
}
local x_ptr = 0x3FFDD4 -- my x and y pointers
local y_ptr = 0x3FFDDC -- might be backwards
local z_ptr = 0x3FFDD8
local a_ptr = 0x3FFE6E
local link = addrs.link_actor
local pos = {2400, 375, 20}
local angle = 180/360*65536
local pos = {2400, 20, 375}
local angle = 180
local fn = 'lua movement test'
@ -75,8 +72,8 @@ function reset_stick()
end
function find_displacement()
local x = mainmemory.readfloat(x_ptr, true)
local y = mainmemory.readfloat(y_ptr, true)
local x = link.x()
local y = link.z() -- FIXME
return pythag(pos[1] - x, pos[2] - y)
end
@ -84,10 +81,15 @@ function setup()
client.unpause()
for _=1, 2 do
reset_stick()
mainmemory.write_s16_be(a_ptr, angle)
mainmemory.writefloat(x_ptr, pos[1], true)
mainmemory.writefloat(y_ptr, pos[2], true)
mainmemory.writefloat(z_ptr, pos[3], true)
local angle = (angle/360*65536) % 65536
--link.angle_old(angle_old)
link.angle(angle)
link.x(pos[1])
link.y(pos[2])
link.z(pos[3])
link.x_copy(pos[1])
link.y_copy(pos[2])
link.z_copy(pos[3])
for i=1, 3*21 do
emu.frameadvance()
joypad.set({A=i % 4 > 0, Z=i > 9 and i <= 12}, 1)

View File

@ -14,7 +14,7 @@ local blocknames = {
'Rb',
}
function butts(ih)
function distribute_index(ih)
local block = math.floor(ih/16/6)
local ir = ih - block*16*6
local page = math.floor(ir/16)
@ -39,7 +39,7 @@ function ShortMonitor:mark(i, x, x1)
if not self.modified[ih] then
self.modified[ih] = true
self.dirty = true
local block, page, row = butts(ih)
local block, page, row = distribute_index(ih)
printf('%2s Page %1i Row %3i', blocknames[block+1], page+1, row+1)
end
end
@ -48,7 +48,7 @@ function ShortMonitor:dump()
local buff = ''
for i=0, self.len/2 - 1 do
local ih = i
local block, page, row = butts(ih)
local block, page, row = distribute_index(ih)
local mod = self.modified[ih]
local value = R2(self.begin + ih)
local vs = mod and 'n/a' or ('%04X'):format(value)

View File

@ -1,5 +1,5 @@
local A = require "boilerplate"
local addrs = require "addrs.init"
require "boilerplate"
require "addrs.init"
function gs2(addr, value)
printf("81%06X %04X", addr, value)

View File

@ -1,142 +1,9 @@
local addrs = require "addrs.init"
local anim_addr = addrs.link_actor.animation_id.addr
require "addrs.init"
require "serialize"
local anims_seen = {
[0xCF68] = true,
[0xCF70] = true,
[0xCFE0] = true,
[0xCFE8] = true,
[0xD068] = true,
[0xD088] = true,
[0xD090] = true,
[0xD098] = true,
[0xD0A8] = true,
[0xD0C8] = true,
[0xD0D0] = true,
[0xD0D8] = true,
[0xD140] = true,
[0xD148] = true,
[0xD308] = true,
[0xD448] = true,
[0xD450] = true,
[0xD5A0] = true,
[0xD5A8] = true,
[0xD5B0] = true,
[0xD698] = true,
[0xD6A0] = true,
[0xD6A8] = true,
[0xD720] = true,
[0xD728] = true,
[0xD730] = true,
[0xD770] = true,
[0xD780] = true,
[0xD788] = true,
[0xD790] = true,
[0xD7A8] = true,
[0xD7B8] = true,
[0xD7F0] = true,
[0xD800] = true,
[0xD858] = true,
[0xD868] = true,
[0xD878] = true,
[0xD890] = true,
[0xD898] = true,
[0xD8B0] = true,
[0xD8C8] = true,
[0xD8D8] = true,
[0xD918] = true,
[0xD920] = true,
[0xD928] = true,
[0xD930] = true,
[0xD938] = true,
[0xD988] = true,
[0xD990] = true,
[0xD998] = true,
[0xD9A0] = true,
[0xDA60] = true,
[0xDA68] = true,
[0xDA70] = true,
[0xDA78] = true,
[0xDA80] = true,
[0xDAC0] = true,
[0xDB10] = true,
[0xDB18] = true,
[0xDB28] = true,
[0xDC00] = true,
[0xDC08] = true,
[0xDC30] = true,
[0xDC40] = true,
[0xDCD8] = true,
[0xDCE0] = true,
[0xDCE8] = true,
[0xDCF0] = true,
[0xDCF8] = true,
[0xDD10] = true,
[0xDD18] = true,
[0xDD20] = true,
[0xDD28] = true,
[0xDD30] = true,
[0xDDB0] = true,
[0xDDB8] = true,
[0xDE40] = true,
[0xDE48] = true,
[0xDE50] = true,
[0xDE68] = true,
[0xDE70] = true,
[0xDE78] = true,
[0xDE80] = true,
[0xDE88] = true,
[0xDE90] = true,
[0xDEA0] = true,
[0xDEA8] = true,
[0xDEB8] = true,
[0xDEC8] = true,
[0xDED0] = true,
[0xDEE0] = true,
[0xDEE8] = true,
[0xDF20] = true,
[0xDF28] = true,
[0xDF30] = true,
[0xDF48] = true,
[0xDF50] = true,
[0xDF58] = true,
[0xDF60] = true,
[0xDF68] = true,
[0xDF70] = true,
[0xDFC8] = true,
[0xDFD0] = true,
[0xDFD8] = true,
[0xDFE0] = true,
[0xDFE8] = true,
[0xE000] = true,
[0xE0B0] = true,
[0xE0B8] = true,
[0xE0D8] = true,
[0xE0E0] = true,
[0xE0E8] = true,
[0xE0F0] = true,
[0xE208] = true,
[0xE210] = true,
[0xE218] = true,
[0xE228] = true,
[0xE230] = true,
[0xE240] = true,
[0xE248] = true,
[0xE258] = true,
[0xE260] = true,
[0xE270] = true,
[0xE2E0] = true,
[0xE308] = true,
[0xE320] = true,
[0xE338] = true,
[0xE348] = true,
[0xE3A8] = true,
[0xE3F0] = true,
[0xE3F8] = true,
[0xE400] = true,
[0xE410] = true,
[0xE450] = true,
}
local anim_addr = addrs.link_actor.animation_id.addr
local fn = 'data/_anims_seen.lua'
local anims_seen = deserialize(fn) or {}
while true do
local anim_id = mainmemory.read_u16_be(anim_addr)
@ -148,7 +15,8 @@ while true do
if not anims_seen[anim_id] then
anims_seen[anim_id] = true
print(frame, hexid)
serialize(anims_seen, fn)
end
end
emu.yield()
emu.frameadvance()
end