Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- print("Life/stun damage watcher for SF2 games in MAME-rr")
- print("written by Dammit, 6/27/2011")
- --local P2_life = 30 --use this to test damage scaling
- local base, space
- local life, stun, time = 0x2C, 0x5E, 0x5C
- local old_life, old_stun, old_time = {}, {}, {}
- local function initialize()
- for p = 1,2 do
- old_life[p] = memory.readword(base + space*(p-1) + life)
- old_stun[p] = memory.readword(base + space*(p-1) + stun)
- old_time[p] = memory.readword(base + space*(p-1) + time)
- end
- end
- emu.registerstart(function()
- for _, game in ipairs({
- {base = 0xFF833C, space = 0x400, name = "hsf2"},
- {base = 0xFF844E, space = 0x400, name = "ssf2t"},
- {base = 0xFF83CE, space = 0x400, name = "ssf2"},
- {base = 0xFF83BE, space = 0x300, name = "sf2hf"},
- {base = 0xFF83BE, space = 0x300, name = "sf2ce"},
- {base = 0xFF83C6, space = 0x300, name = "sf2"},
- }) do
- if emu.romname() == game.name or emu.parentname() == game.name then
- base, space = game.base, game.space
- initialize()
- print() print("now playing " .. game.name)
- print("player\tdamage\tstun\ttimeout")
- return
- end
- end
- error(emu.romname() .. ": not an SF2 game", 0)
- end)
- savestate.registerload(function()
- initialize()
- end)
- if P2_life then
- memory.writeword(base + space + life, P2_life)
- memory.writeword(base + space + life-2, P2_life)
- end
- emu.registerafter(function()
- for p = 1,2 do
- local new = {
- life = memory.readword(base + space*(p-1) + life),
- stun = memory.readword(base + space*(p-1) + stun),
- time = memory.readword(base + space*(p-1) + time),
- }
- local diff = {
- life = new.life - old_life[p],
- stun = new.stun - old_stun[p],
- time = new.time - old_time[p],
- }
- if diff.life < 0 or diff.stun > 0 or diff.time > 0 then
- diff.time = ((old_time[p] > 0 or diff.life >= 0) and diff.time+1) or diff.time
- diff.stun = (diff.stun < 0 and "-") or diff.stun
- diff.time = (diff.time < 0 and "-") or diff.time
- print(string.format("%d\t%d\t%s\t%s", p, -diff.life, diff.stun, diff.time))
- end
- old_life[p], old_stun[p], old_time[p] = new.life, new.stun, new.time
- end
- end)
- gui.register(function()
- gui.box(-0x01, -0x01, 0x0D, 0x18, 0x44444488, 0xffffff88)
- gui.text(0x01, 0x00, string.format("%3d", old_life[1]), 0x00ff00ff)
- gui.text(0x01, 0x08, string.format("%3d", old_stun[1]), 0x00ffffff)
- gui.text(0x01, 0x10, string.format("%3d", old_time[1]), 0xffff00ff)
- gui.box(emu.screenwidth()-0x0E, -0x01, emu.screenwidth(), 0x18, 0x44444488, 0xffffff88)
- gui.text(emu.screenwidth()-0x0C, 0x00, string.format("%3d", old_life[2]), 0x00ff00ff)
- gui.text(emu.screenwidth()-0x0C, 0x08, string.format("%3d", old_stun[2]), 0x00ffffff)
- gui.text(emu.screenwidth()-0x0C, 0x10, string.format("%3d", old_time[2]), 0xffff00ff)
- end)
Add Comment
Please, Sign In to add comment