PPU filler/init

Discuss emulation of the Nintendo Entertainment System and Famicom.

Moderator: Moderators

Post Reply
Concurser
Posts: 5
Joined: Fri Mar 06, 2020 12:30 pm

PPU filler/init

Post by Concurser » Tue Mar 24, 2020 6:42 am

Hi, the code below is the very beggining of Donkey Kong (World).

My code is not exiting the BEQ-LDA loop even after the estimated 27399 cycles on Mesen debugger.

SEI
CLD
LDA #$10
STA PpuControl_2000 = $90 (was $10 before 27395)
LDX #$FF
TXS
$C7A8 LDA PpuStatus_2002 = $10 (in the 27391th cycle running this it changes PpuControl_2000 to $90! How? The Z flag is cleared and then I get a condition to get out from the loop)
AND #$80
BEQ $C7A8
LDY #$07

My guess is that the PPU registers (specially PpuControl_2000) get filled with something else, from some sort of PPU init code by itself.

Checking the memory on the debugger shows that the PPU area (2000-2007 and even beyond) is filled with $90s and other stuff. Should I implement this on the PPU? This content is thrown from where?

User avatar
Dwedit
Posts: 4306
Joined: Fri Nov 19, 2004 7:35 pm
Contact:

Re: PPU filler/init

Post by Dwedit » Tue Mar 24, 2020 12:43 pm

PPU Status is a memory-mapped register, you are asking the PPU what its status is. The code there is waiting for the "Vblank" flag to be set in the PPU status.

The PPU itself is responsible for updating the status flag. So if it never changes, the code runs forever.
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!

User avatar
tokumaru
Posts: 11691
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Re: PPU filler/init

Post by tokumaru » Tue Mar 24, 2020 5:52 pm

Concurser wrote:
Tue Mar 24, 2020 6:42 am
Checking the memory on the debugger shows that the PPU area (2000-2007 and even beyond) is filled with $90s and other stuff.
$2000-$2007 (and its mirrors) are not memory, those are memory-mapped registers. Nothing is "stored" there, these addresses act as communication ports with the PPU.
Should I implement this on the PPU? This content is thrown from where?
Just like your CPU is stuck in a loop reading instructions from memory and executing them, your PPU should be stuck in a loop fetching data from VRAM and rendering images based on that. The 2 are supposed to run in parallel, and whenever the CPU asks the PPU "has vblank started yet?", the PPU has to respond according to what it's doing at that moment.

Post Reply