PPU Emulation Wrong Pattern Table

Discuss emulation of the Nintendo Entertainment System and Famicom.

Moderator: Moderators

Post Reply
jotac
Posts: 12
Joined: Wed Feb 17, 2021 1:08 pm

PPU Emulation Wrong Pattern Table

Post by jotac » Sun Feb 28, 2021 5:12 pm

Hello!

I have finally gotten `nestest` to render graphically [here][https://drive.google.com/file/d/1Cl-6jT ... sp=sharing].

I tried to render Donkey Kong but the main menu renders as [this][https://drive.google.com/file/d/1b97-3w ... sp=sharing].

I found out why this screen looks so weird and basically the tiles are being picked from the first pattern table always. So instead of the tile 0x24 from the second pattern table which is an empty square for the main menu of DK, I get the tile you see repeated in cyan.

I am a bit lost as to what could make it only read from the first pattern table. All `nestest` tests pass successfully.

Here is my PPU code: https://gist.github.com/joao-conde/8f5c ... bdf483bf30

Does anyone have any hints?

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

Re: PPU Emulation Wrong Pattern Table

Post by Dwedit » Sun Feb 28, 2021 5:21 pm

PPUCTRL (register $2000) determines which pattern table to fetch the tiles from. Figure out the last timestamp and value written there before the graphics display.
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!

jotac
Posts: 12
Joined: Wed Feb 17, 2021 1:08 pm

Re: PPU Emulation Wrong Pattern Table

Post by jotac » Mon Mar 01, 2021 6:54 am

Managed to find the bug, when using the control pattern background I had

```
self.control & Control::PATTERN_BACKGROUND).bits()
```

and should be

```
(self.control & Control::PATTERN_BACKGROUND).bits() >> 4)
```

Post Reply