Skip to content

Instantly share code, notes, and snippets.

@taotao54321
Created August 9, 2018 12:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save taotao54321/65190bcd58bad955c584e6551b9a47b7 to your computer and use it in GitHub Desktop.
Save taotao54321/65190bcd58bad955c584e6551b9a47b7 to your computer and use it in GitHub Desktop.
ドクターマリオ スコア加算ルーチンの処理量 (概算値)
#n LOW MED HI
1 121 121 121
2 211 211 211
3 391 404 404
4 764 764 777
5 1484 1510 1536
6 2950 2989 3028
7 2950 2989 3028
8 2950 2989 3028
9 2950 2989 3028
10 2950 2989 3028
11 2950 2989 3028
12 944 957 970
13 301 301 314
14 23422 23799 24163
15 121 121 121
local function measure(speed, n)
local cycle_start = nil
local cycle_end = nil
local done = false
memory.registerexec(0x8FF4, function()
cycle_start = debugger.getcyclescount()
memory.writebyte(0x8B, speed)
memory.writebyte(0xAD, n)
memory.writebyte(0x2000, bit.band(0x7F,memory.readbyte(0xFF)))
--memory.registerexec(0x8005, function() print("NMI") end)
end)
memory.registerexec(0x901B, function()
--memory.registerexec(0x8005, nil)
cycle_end = debugger.getcyclescount()
done = true
end)
while not done do
emu.frameadvance()
end
memory.registerexec(0x901B, nil)
memory.registerexec(0x8FF4, nil)
--print(cycle_start)
--print(cycle_end)
return cycle_end - cycle_start
end
local function main()
local state = savestate.object()
savestate.save(state)
local out = io.open("score_add_cycle.log", "w")
out:write("#n\tLOW\tMED\tHI\n")
for n = 0, 14 do
out:write(string.format("%d", n+1))
for speed = 0, 2 do
duration = measure(speed, n)
out:write(string.format("\t%d", duration))
savestate.load(state)
end
out:write("\n")
end
out:close()
end
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment