Skip to content

Commit

Permalink
additional rendering at scanlines, where is midframe writing
Browse files Browse the repository at this point in the history
  • Loading branch information
spiiin committed Apr 16, 2018
1 parent e32ae1e commit 0dfcdc5
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions Stuff/nes_lua/mesen_chrRamWriteCounter.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ writeToChr1 = 0;
writedBetweenFrames0 = 0;
writedBetweenFrames1 = 0;

colorCode = 0x4000FF00;

function onStartFrame()
--old frame ended, and new started.
--we can measure byte counts writen only between frames
Expand All @@ -22,6 +24,13 @@ function onEndFrame()
writeToChr1 = 0;
end

function highlightScanline()
local state = emu.getState();
local color = colorCode + state.ppu.scanline;
--emu.log("scanline: "..tostring(state.ppu.scanline));
emu.drawLine(0, state.ppu.scanline, 256, state.ppu.scanline, color, 1);
end

function onChrWrite(address, value)
if (address < 0x1000) then
writeToChr0 = writeToChr0 + 1;
Expand All @@ -34,5 +43,6 @@ end
emu.addEventCallback(onStartFrame, emu.eventType.startFrame);
emu.addEventCallback(onEndFrame, emu.eventType.endFrame);
emu.addMemoryCallback(onChrWrite, emu.memCallbackType.ppuWrite, 0x0000, 0x1FFF);
emu.addMemoryCallback(highlightScanline, emu.memCallbackType.ppuWrite, 0x0000, 0x3FFF);

emu.displayMessage("Script", "Script loaded.")

0 comments on commit 0dfcdc5

Please sign in to comment.