I am just trying to get the nametable to be written for Donkey Kong -- for something simple first...

If my understanding is correct, the NMI bit is controlled in BIT_7 in $2000. I am turning on this bit when my scanlines hit 241. I set the NMI bit, then the Vblank bit in 2002.

So my cycle is like this (in pseudo-code):

Code: Select all

```
run() {
fetchOpcode();
executeOpcode();
ppuRun();
// check NMI here. and execute NMI.
}
ppuRun() {
incrementPPUCycles();
if(cycles === 341) ppuScanlines++;
if(ppuScanlines >= 241 && ppuScanlines <= 260) {
ppuSetNmi(1);
ppuSetVblank(1);
}
if(ppuScanlines == 261) {
ppuSetNmi(0);
ppuSetVblank(0);
}
if(ppuScanlines == 262) {
outputFrame();
ppuScanlines = 0;
}
}
```

Code: Select all

`PHA`