Skip to content
Permalink
Newer
Older
100644 39 lines (30 sloc) 972 Bytes
1
--Script for render scanlines, where horizontal scroll changed
2
--Emulator: Mesen 0.9.4
3
--Rom: any
4
--Author: spiiin
5
6
PPUSCROLL = 0x2005;
7
8
colorCode = 0x4000FF00;
9
10
function onStartFrame()
11
emu.log("New frame");
12
end
13
14
function onEndFrame()
15
emu.log("End frame");
16
end
17
18
function onIrq()
19
emu.log("Irq");
20
end
21
22
function hex(arg)
23
return string.format("%02x", arg)
24
end
25
26
function onScroll(address, value)
27
local state = emu.getState();
28
emu.log("Scrolling change. Scanline: "..state.ppu.scanline.." Value:"..value);
29
local color = colorCode + state.ppu.scanline;
30
emu.drawLine(0, state.ppu.scanline, 256, state.ppu.scanline, color, 1)
31
end;
32
33
emu.addEventCallback(onStartFrame, emu.eventType.startFrame);
34
emu.addEventCallback(onEndFrame, emu.eventType.endFrame);
35
emu.addEventCallback(onIrq, emu.eventType.irq);
36
emu.addMemoryCallback(onScroll, emu.memCallbackType.cpuWrite, PPUSCROLL, PPUSCROLL+1);
37
38
--Display a startup message
39
emu.displayMessage("Script", "Script loaded.")