Last active
August 29, 2015 14:07
-
-
Save oupo/a0c5d20cdb59fe9ee043 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
require "myutil" | |
printf = function() end -- printfを呼ぶものはデバッグメッセージという扱い | |
IN_BATTLE = false | |
COUNT = 351 | |
OK = nil | |
END = true | |
MOVIE_MODE = true | |
E(0x0223800A, function () | |
if read16(PC()) == 0x49A0 then | |
printf("戦闘時seedの保存 seed=%.8x", reg(0)) | |
IN_BATTLE = true | |
OK = nil | |
end | |
end) | |
E(0x02237C5A, function () | |
printf("戦闘後のseed復帰: %.8x", reg(0)) | |
IN_BATTLE = false | |
end) | |
E(0x02257258, function () | |
regw(1, 1) | |
printf("set! 急所") | |
end) | |
E(0x0224B51C, function () | |
regw(0, 99) -- 一番外れやすい | |
printf("set! 命中") | |
end) | |
E(0x02257182, function () | |
regw(0, 15) -- ダメージ小 | |
printf("set! ダメージ") | |
end) | |
E(0x0226431A, function () | |
local x = reg(0) | |
local hp = read32(x+0x28) | |
local maxhp = read32(x+0x2c) | |
local damage = read32(x+0x30) | |
printf("damage %.8x %d %d %d", x, hp, maxhp, damage) | |
-- xが相手のHPだったらというつもりだがメモリアドレスは変動しうるかも | |
if x == 0x022cbb94 and damage == maxhp and OK ~= false then | |
OK = true | |
end | |
end) | |
E(0x0224F87C, function () | |
local lr1 = read32(reg(13)+0x6c+4*4) -- 関数0224f190 | |
local lr2 = read32(reg(13)+0x6c+5*4+0x1c+4*4) -- 関数02252284 | |
if lr1 == 0x022522e5 and lr2 == 0x02247d0f then | |
printf("すばやさ判定 %d %d", reg(6), reg(4)) | |
if reg(6) <= reg(4) then | |
OK = false | |
end | |
end | |
end) | |
E(0x02249EE0, function() | |
printf("ターン数: %d", reg(0)) | |
goto_next() | |
end) | |
E(0x02259cb4, function() | |
printf("交換画面") | |
goto_next() | |
end) | |
function goto_next() | |
if not MOVIE_MODE then return end | |
print(string.format("*%d: %s", COUNT, OK and "ok" or "ng")) | |
COUNT = COUNT + 1 | |
if COUNT == 951 then | |
error("finish!") | |
end | |
END = true | |
end | |
--function getframe() return read32(0x021d0678) end | |
getframe = emu.framecount | |
-- 自動キー入力 | |
emu.registerafter(function () | |
if not MOVIE_MODE then return end | |
if END then | |
END = false | |
savestate.load(0) | |
LAST_FRAME = getframe() | |
end | |
local frame = getframe() - LAST_FRAME | |
local frame_slow = s32(frame / 5) | |
if frame_slow % 10 == 0 then | |
-- 交換をしますか?にいいえと答える | |
if 40 <= frame_slow and frame_slow <= 60 then | |
joypad.set({B=true}) | |
else -- 後は定期的にAボタンを押す | |
joypad.set({A=true}) | |
end | |
end | |
gui.text(0, 0, frame_slow) | |
gui.text(0, 20, frame_slow % 10) | |
end) | |
E(0x022360E0, function () | |
printf("ポケモン決定 %d %d", reg(2), reg(3)) | |
-- skip処理をnopに | |
write16(0x022361BE, 0) | |
write16(0x022361EA, 0) | |
end) | |
E(0x02236198, function() | |
local addr = read32(reg(13)+0x14) | |
--printf("pokemon no = %d, item = %d", read16(addr + 0), read16(addr + 0xc)) | |
--print(inspect_bytes(read_memory_bytes(addr, 0x10))) | |
end) | |
-- まもる、みきりを消す | |
do | |
local ptr | |
-- factory entry get | |
E(0x02229434, function () | |
ptr = reg(0) | |
end) | |
E(0x02007434, function () | |
if ptr then | |
for i = 0, 3 do | |
local p = ptr + 2 + 2 * i | |
local waza = read16(p) | |
if waza == 182 or waza == 197 then | |
write16(p, 0) | |
printf("set!") | |
end | |
end | |
ptr = false | |
end | |
end) | |
end | |
E(0x02236186, function () | |
local num_skip = reg(7) | |
local index = reg(4) | |
local num_togen = read32(reg(13)+8) | |
if num_togen == 6 and index == 0 then | |
regw(0, 789) -- はちまきムクホーク | |
elseif num_togen == 3 and index == 0 then | |
regw(0, COUNT) -- フシギバナ | |
else | |
regw(0, 1) -- フシギダネ | |
end | |
end) | |
MESSAGE = {} | |
MESSAGE[0x02236007] = "トレーナー" | |
MESSAGE[0x02236007] = "トレーナー" | |
MESSAGE[0x02236179] = "ポケモン" | |
MESSAGE[0x0222f52f] = "シャッフル" | |
MESSAGE[0x0222953d] = "PID" | |
MESSAGE[0x02229543] = "PID" | |
MESSAGE[0x02229a3d] = "TID" | |
MESSAGE[0x02229a43] = "TID" | |
E(0x0201FA00, function() | |
local seed = memory.getregister("r0") | |
local rand = bit.rshift(seed, 16) | |
local message = MESSAGE[reg(14)] or "" | |
if not IN_BATTLE and message ~= "PID" and message ~= "TID" then | |
printf("lcg %.8x %s", reg(14), message) | |
end | |
end) |
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
-- gomi | |
-- Lv50連勝数 : 021D2052 | |
-- Lv50交換数 : 021D2056 | |
-- オープンレベル連勝数: 021D205A | |
-- オープンレベル交換数: 021D205E | |
write16(0x021D205A, 77) -- オープン連勝数変更 | |
-- 通常乱数のseedをランダムに書き換え | |
local seed = math.random() * 0xffffffff | |
printf("set! seed = %.8x", seed) | |
write32(0x021d0ae8, seed) | |
-- 現在HP | |
--W(0x022C55BC, function (p) printf("%.8x %d %.8x", p, read32(p), PC()) end) | |
--W(0x022CB97C, function (p) printf("%.8x %d %.8x", p, read32(p), PC()) end) | |
-- 素早さ比較を探す | |
--E(0x02000000, 0x00400000, function () | |
-- local ins = read16(PC()) | |
-- if bit.rshift(ins,6) == 0x10a then | |
-- local reg1 = bit.band(ins,7) | |
-- local reg2 = bit.band(bit.rshift(ins,3),7) | |
-- if reg(reg1) == 299 or reg(reg2) == 299 then | |
-- printf("%s %d %d %.8x", emu.disasm(PC(), true), reg(reg1), reg(reg2), PC()) | |
-- end | |
-- end | |
--end) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment