Last active
November 15, 2015 07:39
-
-
Save oupo/58b2a858360b574661a3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- vba-rerecording, ポケモン赤用 | |
function printf(...) print(string.format(...)) end | |
reg = memory.getregister | |
regw = memory.setregister | |
read8 = memory.readbyte | |
read16 = memory.readword | |
write8 = memory.writebyte | |
-- トレーナーID書き込みのトレース | |
memory.registerwrite(0xd2d8, 2, function (addr) | |
printf("トレーナーID pc = %x, addr=%x %.2x", reg("pc"), addr, read8(addr)) | |
end) | |
-- 乱数ルーチンの最後の命令 | |
memory.registerexec(0x3E9C, function () | |
local lr = read16(reg("sp")) -- 呼び出し元 | |
-- 戻り値を0に固定する | |
-- 0ae9からは毎フレーム呼ばれる模様 | |
-- 0に固定していると戦闘で6981から呼ばれ続け無限ループしてしまうため6981のときは0に固定しないことにする | |
if lr ~= 0x0ae9 and lr ~= 0x6981 then | |
printf("%d %d %d %x", reg("a"), read8(0xffd3), read8(0xffd4), lr) | |
regw("a", 0) | |
write8(0xffd3, 0) | |
write8(0xffd4, 0) | |
end | |
end) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment