FinalZero wrote:You're supposed to use SEI on start up, not CLI. CLI allows interrupts to happen, and you don't want that during initialization. After initializing everything, you should only enable interrupts (CLI) if you actually use them.
What do you mean "if you actually use them"? I thought I just read that they're used to draw to the screen.
I think you're confusing things, but it's normal.
NMIs are very simmilar to IRQs, but on the NES it is specifically wired to the PPU and, when activated, fires when VBLank begins, basically. Code at the NMI vector is then executed, and then you can
update the tiles, sprites and other stuff (or just set a flag, sometimes).
IRQs are often mapper-specific (we exclude here DMC and frame IRQs which come from the APU part of the 2A03). In a 4-way scrolling game (ex:Super Mario Bros. 3), IRQs (from the MMC3 mapper) are used to
set the scroll somewhere within a frame, so to perform a 4-way scrolling effect, to give an example.
So as you can see, NMIs and IRQs look similar but they're differents things. And I can expect that other members will emphatize the difference between IRQs and NMIs
FinalZero wrote:
You're supposed to write $00 to the PPU registers, not $FF. Also, you have to give the PPU some time to warm up (2 frames is enough).
How long is a "frame"?
Approximatively 1/60 seconds (NTSC) or 1/50 (PAL), which is the time a
frame appears on your TV. Assume your TV displays 60 frames per sec. on a NTSC system.
FinalZero wrote:
Usually we poll the VBlank flag in $2002 for this (actually this is the only time when using $2002 to wait for VBlank is acceptable). After the warm up you can configure the PPU as you wish (this is when you enable NMIs). If you don't let the PPU warm up, it behaves erratically.
What does "poll" mean?
It means basically to simply look at a [software/hardware] flag/condition, normally periodically. You can see "by polling" the alternative of "by interrupts". Normally, "by interrupts" is better, but because, at power on, the PPU isn't reliable, it's better to "poll" the state of the VBlank flag.