SHOW:
|
|
- or go back to the newest paste.
1 | - | local inputlabels = {"A", "B", "Select", "Start", "Right", "Left", "Up", "Down"} |
1 | + | local coreName = movie.getheader()["Core"] |
2 | local gameName = string.gsub(movie.getheader()["GameName"], "%s+", "") | |
3 | - | function getinputbyte() |
3 | + | local powerOnCycles = 0 |
4 | local inputlabels | |
5 | local powerButtonLabel | |
6 | local coreToGBAAudioSampleRatio | |
7 | ||
8 | if coreName == "Gambatte" then | |
9 | inputlabels = {"A", "B", "Select", "Start", "Right", "Left", "Up", "Down"} | |
10 | powerButtonLabel = "Power" | |
11 | coreToGBAAudioSampleRatio = 512 | |
12 | elseif coreName == "GBHawk" or coreName == "SubGBHawk" then | |
13 | inputlabels = {"P1 A", "P1 B", "P1 Select", "P1 Start", "P1 Right", "P1 Left", "P1 Up", "P1 Down"} | |
14 | powerButtonLabel = "P1 Power" | |
15 | coreToGBAAudioSampleRatio = 1024 | |
16 | else | |
17 | error("Unknown Emulator Core") | |
18 | end | |
19 | ||
20 | - | function tryinput() |
20 | + | function getinputbyte(t) |
21 | - | local input = getinputbyte() |
21 | + | |
22 | return 0 | |
23 | end | |
24 | - | io.write(string.format("%08X %02X", emu.totalexecutedcycles(), input)) |
24 | + | |
25 | local b = 0 | |
26 | ||
27 | for i = 0, 7 do | |
28 | if t[inputlabels[i + 1]] then | |
29 | - | local timestamps = io.open("timestamps.txt", "w") |
29 | + | |
30 | end | |
31 | end | |
32 | - | io.output(timestamps) |
32 | + | |
33 | - | tryinput() |
33 | + | |
34 | end | |
35 | ||
36 | - | if emu.getregister("PC") == 0x40 then |
36 | + | function tryinput(file) |
37 | - | tryinput() |
37 | + | |
38 | local input = getinputbyte(t) | |
39 | local cycles = emu.totalexecutedcycles() | |
40 | if t[powerButtonLabel] then | |
41 | powerOnCycles = cycles | |
42 | end | |
43 | - | tryinput() |
43 | + | |
44 | - | io.close() |
44 | + | |
45 | cycles = math.ceil((cycles - powerOnCycles) / coreToGBAAudioSampleRatio) | |
46 | file:write(string.format("%08X %04X", cycles, input)) | |
47 | file:write("\n") | |
48 | lastinput = input | |
49 | end | |
50 | end | |
51 | ||
52 | local timestamps = io.open(gameName .. ".txt", "w") | |
53 | local lastinput = -1 | |
54 | ||
55 | tryinput(timestamps) | |
56 | ||
57 | while emu.framecount() <= movie.length() do | |
58 | ||
59 | tryinput(timestamps) | |
60 | ||
61 | emu.frameadvance() | |
62 | end | |
63 | ||
64 | tryinput(timestamps) | |
65 | timestamps:close() | |
66 | ||
67 | client.pause() |