r/pygame • u/Creepy_Sherbert_1179 • 3h ago
Added sound to my GameBoy Color emulator written in purely python and pygame (full handwritten)
Hello everyone, I wanted to update you on my GameBoy Color emulator I wrote with pygame! It has been an extremely fun project. I have used PyGame for the PPU (visuals) and the APU (sound). GameBoy Color emulation uses 18 bit surfaces with masks for rgb555 which the actual gameboy color uses. GameBoy emulation uses 8 bit surfaces with palettes. You can also set custom palettes for the GameBoy! I have used 44100 PCM for audio emulation. I use pygame's mixer to initialize 8 bit unsigned audio, then accumulate actual gameboy channel amplitudes (which are 4 bit) then feed buffers the averages. At each buffer fill, a sound object is generated etc. It is not the best at the moment but it works :D I plan to write documentation about the overall architecture.
And of course it is open source: https://github.com/atifcodesalot/hazelnut-gb-emu
Clone and play it yourself! Enjoy!
AI usage disclaimer: This is a handwritten project. AI was used only for debugging and disassembly of ROM's. No agentic code or AI generated code was used.
