I made some changes to the neslib and nesdoug library files.
There was a bug where, if you called one of the sprite functions at the exact end of the frame, it could have placed only half of a sprite’s data in the sprite buffer before the nmi sent it to the OAM RAM for the next frame. This could cause an incorrect sprite to be be shown.
The nmi code has been modified so that it will only DMA the OAM (sprite data) if you have reached the next ppu_wait_frame() or ppu_wait_nmi(). Now, a lag frame will just result in the previous frame being shown twice, with no changes.
Another change — the VRAM update code will clear the VRAM buffer each frame, automatically. You don’t need to call clear_vram_buffer() unless you are changing scenes midframe, and want to cancel some pending updates.
(Originally, I removed clear_vram_buffer() but put it back in 10/31/2022, because you might need it.)
And, I changed the name of flush_vram_update_nmi() to flush_vram_update2(). The name was misleading, the way I was using it — entirely outside of the nmi (ie. pushing updates to the PPU with the screen off).
One caution — split screens still can’t handle lag frames. If you are using a sprite zero split screen, make sure that the code isn’t so complex that it runs past the bottom of the frame. I suppose you could rewrite the nmi code (in assembly) and put the split screen code directly there, to fix it.
I did make sure that the MMC3 code can handle lag frames and do split screens. That is because you can handle the split with IRQs. The nmi code still runs the IRQ function on lag frames.
Minor change — I redid the Full BG and Fade examples. The code is the same, but I thought I could make it look nicer if I used the NESIFIER tool that I made.
More changes, October 2022.
Bug fixes in the MMC1 example code. A poorly timed bank change during NMI could crash the game, and that was fixed. Also, the final bank pop wasn’t putting the default bank in. That was fixed (and also in the MMC3 code example).
SPEZ (SNES sprite editor) has been updated.
M1TE and M8TE have been updated / improved.
NESIFIER (converts an image to NES format) has been updated to 2.2.