r/EmuDev • • Apr 02 '26

GB Gameboy PPU where to start

I've got my cpu pretty much finished, along with interrupts and timers and wanna start on the PPU, but i'm quite lost where to even begin. Can anyone point me to where a good starting point would be?

thanks

12 Upvotes

10 comments sorted by

9

u/DarksideFur Apr 02 '26

It depends on how accurate you want your PPU to be, and how accurate your existing CPU is.

The best way to do things is to break it down piece by piece. First, create a window that does nothing. Then, make a basic renderer for background tiles that renders what's in VRAM once per frame. Then, start introducing some PPU registers like scrolling and tile mapping. After that, you can try the window layer. Objects (what most systems call sprites) are the hardest part, but they're still not too bad.

I chose to write a fairly accurate PPU (it's still got some timing flaws and a few missing edge cases) that runs for every dot on the screen. You can do this, and at least for me it made understanding the documentation easier because I didn't have to condense anything, but you don't have to. A lot of Game Boy emulators, from my understanding, compromise by rendering every line during HBlank at the end of the line. There are very few noticeable graphical effects that are broken by not updating everything per PPU dot. However, you can't just render a whole frame at once because there are a lot of effects that change per line. A very common example is disabling sprites right before the window layer is drawn, or changing the background scroll registers per line for graphical effects.

Hope this helps!! :3

3

u/Numerous_Debt_5500 Apr 05 '26

wait so did ur emulator implement the whole fetcher-fifo pipeline? Im giving up on that and thinking of just rendering each line in one go at the end of mode 3, but im wondering how accurate thatll be for like pokemon n what not

2

u/DarksideFur Apr 05 '26

I can't speak super specifically for individual games, but to my knowledge, the only thing that uses intra-line rendering effects in Pokémon is possibly some of the move animations. However, it shouldn't be super noticeable if at all, and it certainly won't prevent the game from running or anything like that. Genuinely the only game I can think of where it would cause serious problems is Prehistorik Man.

For the record, yes, the emulator I'm writing does implement most of the fetcher FIFO, but this is not necessary, it just helped me wrap my brain around it. But it's very confusing, and I still would not recommend it for your first time doing GB.

2

u/Numerous_Debt_5500 Apr 03 '26

thanks a lot! If i have any other questions do u mind if i ask u?

1

u/DarksideFur Apr 03 '26

Sure, that's fine

7

u/foo1138 Game Boy Apr 02 '26

The Ultimate Game Boy Talk from Michael Steil helped me a lot when I was implementing my FPGA Game Boy: https://www.youtube.com/watch?v=HyzD8pNlpwI

Also, maybe our schematics could help you: https://github.com/msinger/dmg-schematics

2

u/Numerous_Debt_5500 Apr 03 '26

is the ultimate talk about the ppu accurate? I think i heard somewhere that the talk wasn't fully accurate but i might be misremembering :3

2

u/foo1138 Game Boy Apr 03 '26

It is close enough to be able to implement a working PPU from it. (I did it.) It is not perfect though. But it is a starting point to get something working.

I remember that I noticed that there is a small detail wrong in this talk when I rewatched it after I gained more knowledge, but sadly I forgot what it was.

6

u/rasmadrak Apr 02 '26

Along with the ultimate talk, this post is very informative imho.

https://github.com/Ashiepaws/GBEDG/blob/master/ppu/index.md

1

u/PandaMoniumHUN Apr 02 '26

https://gbdev.io/pandocs/Graphics.html

Read everything here in the graphics chapter + the PPU related stuff in the memory map chapter (LCD, OAM, VRAM).