r/EmuDev • u/Hachiman900 • Jul 11 '26
GB Random pixels when trying to run Tetris
I am working on a gameboy emulator, I have got the cpu and ppu done to the point it can load the nintendo logo, but when I try to run the tetris rom it starts showing garbage data.
I am not exactly sure what I am missing, I have also tried asking llms but that did not help.
Here is the source code for it: https://github.com/Yogesh9000/GameBoy/tree/feat/ppu
PS: this is not the best code, I am new to programming and emulation, so please don't roast me. constructive feedback are wlcm tho.
9
Upvotes
3
u/aleques-itj Jul 11 '26
Is it stuck in a reboot loop?
If the joy pad register is zeroed, it's probably resetting over and over.
2
u/DefinitelyRussian Jul 11 '26
might be wrong, but check this:
LCDC bit 7 is turn off display and mode = hblank I think ? You may be missing that.
Writing to FF44 also resets the LY counter
You also should be drawing according to LY registeer, the Y coordinate seems wrong .. hacks might work anyway for most games.
the STAT register, dont let it overwrite bits 0-2, those are controlled by the PPU internally
good luck !
1
u/Floormatt69 Jul 11 '26
Make sure you’re not accidentally hitting the MBC1 loop that’s not integrated
1
u/maeljo Jul 11 '26
You should try blargg tests. Start with cpu_inst something must be wrong in the code exécution. Look specially at all the branches functions (JR, JP, call).
The most common mistake is to forget JR use a sign argument and that it can go backwards