PPU producing repeating pattern

Discuss emulation of the Nintendo Entertainment System and Famicom.

Moderator: Moderators

Post Reply
densming
Posts: 2
Joined: Thu Feb 11, 2021 8:25 am

PPU producing repeating pattern

Post by densming » Thu Feb 11, 2021 8:30 am

Just for fun, I'm writing a NES emulator based on javidx9's awesome YouTube series. I'm writing mine in Swift instead of C, just for the challenge. Anyway, my PPU isn't generating the proper image. It seems to be creating a repeated pattern (see below for a screenshot of Super Mario Bros title screen). I've tripe checked the code and all looks right but I didn't know if this is maybe an obvious problem that someone might know where to look.

Thanks!
smb.png

User avatar
nesrocks
Posts: 481
Joined: Thu Aug 13, 2015 4:40 pm
Location: Rio de Janeiro - Brazil
Contact:

Re: PPU producing repeating pattern

Post by nesrocks » Thu Feb 11, 2021 8:36 am

It is repeated 8 times, so that must be a clue. It seems you're only drawing the first line of each tile instead of all 8 lines.
https://twitter.com/bitinkstudios <- Follow me on twitter! Thanks!

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

Re: PPU producing repeating pattern

Post by tokumaru » Thu Feb 11, 2021 8:40 am

The obvious thing here is that the pattern is repeated 8 times, and tiles are 8 pixels tall... It looks like you're rendering every 8th scanline for whatever reason. Check the vertical PPU address increment at the end of the scanline, it should be incrementing the fine Y scroll by 1, but it looks like you're incrementing the coarse Y scroll instead.

densming
Posts: 2
Joined: Thu Feb 11, 2021 8:25 am

Re: PPU producing repeating pattern

Post by densming » Thu Feb 11, 2021 9:14 am

Yes! That was it! I had a bug in setting one of the loopy registers which was setting the fineY to 0b111. Thank you!

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

Re: PPU producing repeating pattern

Post by Dwedit » Thu Feb 11, 2021 9:42 am

Also, I can see that the background color is wrong, it should not be separate for each group of 4 colors, it should be the same background color.
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!

User avatar
Quietust
Posts: 1685
Joined: Sun Sep 19, 2004 10:59 pm
Contact:

Re: PPU producing repeating pattern

Post by Quietust » Thu Feb 11, 2021 9:53 am

Dwedit wrote:
Thu Feb 11, 2021 9:42 am
Also, I can see that the background color is wrong, it should not be separate for each group of 4 colors, it should be the same background color.
Specifically, the background color should always be the value at PPU $3F00 (not $3F04/$3F08/$3F0C). Additionally, writes to PPU $3F10 should overwrite the value at $3F00.
Quietust, QMT Productions
P.S. If you don't get this note, let me know and I'll write you another.

stan423321
Posts: 33
Joined: Wed Sep 09, 2020 3:08 am

Re: PPU producing repeating pattern

Post by stan423321 » Thu Feb 11, 2021 10:05 am

Funnily enough, the multiple background color setup sounds like what GBC does.

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

Re: PPU producing repeating pattern

Post by tokumaru » Thu Feb 11, 2021 12:25 pm

stan423321 wrote:
Thu Feb 11, 2021 10:05 am
Funnily enough, the multiple background color setup sounds like what GBC does.
Things would be slightly more versatile if the NES worked like that... The PPU even stores unique color values in those addresses, it just never uses them (apart from when you turn rendering off and point the VRAM address at them).

User avatar
Controllerhead
Posts: 214
Joined: Tue Nov 13, 2018 4:58 am
Location: $4016
Contact:

Re: PPU producing repeating pattern

Post by Controllerhead » Thu Feb 11, 2021 1:25 pm

densming wrote:
Thu Feb 11, 2021 9:14 am
background color
Image
Image

Post Reply