Permalink
Newer
100644
48 lines (39 sloc)
1.5 KB
1
--Script for writing to CHR-RAM count per frame
2
--Emulator: Mesen 0.9.4
3
--Rom: any with CHR-RAM
4
--Author: spiiin
5
6
writeToChr0 = 0;
7
writeToChr1 = 0;
8
15
--old frame ended, and new started.
16
--we can measure byte counts writen only between frames
17
writedBetweenFrames0 = writeToChr0;
18
writedBetweenFrames1 = writeToChr1;
22
emu.log("Frame ended, chr0 writes: "..writeToChr0.." (between frames:"..writedBetweenFrames0..")"..", chr1 writes: "..writeToChr1.." (between frames:"..writedBetweenFrames1..")");
27
function highlightScanline()
28
local state = emu.getState();
29
local color = colorCode + state.ppu.scanline;
30
--emu.log("scanline: "..tostring(state.ppu.scanline));
31
emu.drawLine(0, state.ppu.scanline, 256, state.ppu.scanline, color, 1);
32
end
33
34
function onChrWrite(address, value)
35
if (address < 0x1000) then
36
writeToChr0 = writeToChr0 + 1;
37
else
38
writeToChr1 = writeToChr1 + 1;
39
end;
41
end
42
43
emu.addEventCallback(onStartFrame, emu.eventType.startFrame);
44
emu.addEventCallback(onEndFrame, emu.eventType.endFrame);
45
emu.addMemoryCallback(onChrWrite, emu.memCallbackType.ppuWrite, 0x0000, 0x1FFF);
46
emu.addMemoryCallback(highlightScanline, emu.memCallbackType.ppuWrite, 0x0000, 0x3FFF);