This PR is chock full of small but significant tweaks and bug fixes to get a suite of tests to pass, namely the ppu_vbl_nmi.nes ROM file authored by Shay Green aka blargg. These tests check various aspects of enabling and resetting of the vertical blank flag, as well as the generation and canceling of NMI interrupts. There are many comment blocks spread throughout the codebase that include references to either discussion threads on the relevant topic or even source code on GitHub on which part of my implementation is based.
Some other notable changes made here are:
PPU cycles are still zero-based but the rendering takes place on cycles 1-256 instead of 0-255. This was to bring my code in closer alignment with other emulators and to help debug various problems.
The CPU now has a stall property which is now properly managed and incorporated into the logic in CPU.tick(). Additionally, writing 256 bytes in bulk to the PPU's OAM buffer results in stalling the CPU for 513/514 cycles.
Both IRQ and NMI interrupts now properly incur seven cycles instead of the two originally implemented.
There are two new properties in PPU: frameCycles and frameNumber. Neither is used in any core logic but I found myself needing to use them while debugging various issues that I felt they were too useful to remove.
PPU.tick() has been significantly refactored by breaking it up into multiple smaller functions, each with a distinct purpose. Doing so makes reading and understanding what is going on inside tick()so much easier.
This PR is chock full of small but significant tweaks and bug fixes to get a suite of tests to pass, namely the
ppu_vbl_nmi.nes
ROM file authored by Shay Green aka blargg. These tests check various aspects of enabling and resetting of the vertical blank flag, as well as the generation and canceling of NMI interrupts. There are many comment blocks spread throughout the codebase that include references to either discussion threads on the relevant topic or even source code on GitHub on which part of my implementation is based.Some other notable changes made here are:
stall
property which is now properly managed and incorporated into the logic inCPU.tick()
. Additionally, writing 256 bytes in bulk to the PPU's OAM buffer results in stalling the CPU for 513/514 cycles.PPU
:frameCycles
andframeNumber
. Neither is used in any core logic but I found myself needing to use them while debugging various issues that I felt they were too useful to remove.PPU.tick()
has been significantly refactored by breaking it up into multiple smaller functions, each with a distinct purpose. Doing so makes reading and understanding what is going on insidetick()
so much easier.