Question

In advance, I apologize for the open endedness, and general wishy-washiness of this question, because to be honest my knowledge of the topic is very patchy and I'm finding it hard to even describe my problem. I really didn't want to post, but I'm completely and utterly stuck.

I have started a NES emulator. It's interpreted (so no dynamic recomp).

Atm it can load and map roms (mapper 0 roms) and execute the init code right up to where I have to deal with interrupts and the PPU. That's where I'm stuck.

Here is an example output from my emu atm. Execution begins at 8000, and I hit an infinite loop at 800a where I have no idea how to progress from there.

8002: LDA #$10    ; read immediate value to set PPU control registers 
8004: STA $2000   ; store value 
8007: LDX #$FF    ; load immediate value into X register 
8009: TXS         ; store X register into stack 
800a: LDA $2002   ; read PPU flags into accumulator (set N flag based on bit 7) 
800d: BPL         ; test N flag, branch to 800a if not positive, (N is set) 
800a: LDA $2002
800d: BPL
800a: LDA $2002
800d: BPL
800a: LDA $2002
800d: BPL
etc, etc etc (inf loop)

So my question is, can someone please explain the basics of 1 iteration through a PPU render for me, including things like cycle count, interrupts etc (i.e. draw one whole 240 scanline screen and move onto the next).

Was it helpful?

Solution

There are emulators out there, have you looked at their sources for the answer? usually those are written for performance and not very readable but you might find a tidbit to get you going. is the code waiting for an interrupt to be executed and have you executed that interrupt? It may be that the interrupt modifies the return address and allows the program to continue? is the infinite loop polling a bit in a register? or is it an unconditional branch to self?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top