Gameboy FPGA Cartridge

Discussion of programming and development for the original Game Boy and Game Boy Color.
Rüdiger
Posts: 12
Joined: Fri Oct 16, 2015 1:14 pm

Re: Gameboy FPGA Cartridge

Post by Rüdiger »

It's a STM32F072. The requirements were 2 SPI ports (one for the FPGA and one for the SD card), battery backed RTC, USB, and a TQFP48 package.
I recently discovered the STM32L433 which is even more powerful and pin-compatible. I still have to check how fast the SD card access is,
but the F072 should be fast enough.
User avatar
infiniteneslives
Posts: 2104
Joined: Mon Apr 04, 2011 11:49 am
Location: WhereverIparkIt, USA
Contact:

Re: Gameboy FPGA Cartridge

Post by infiniteneslives »

Great choice, the stm32f07x series is a great mcu for USB. I recently upgraded to some of my designs to the same chip family and have been enjoying getting to know the chip.
If you're gonna play the Game Boy, you gotta learn to play it right. -Kenny Rogers
Rüdiger
Posts: 12
Joined: Fri Oct 16, 2015 1:14 pm

Re: Gameboy FPGA Cartridge

Post by Rüdiger »

I didn't post here for quite a while, but I'm still working on it from time to time and did some bigger improvements over the holidays.

A lot of small changes to the FPGA and ARM code. I can load games from the SD card and run them. The FPGA provides a SPI interface to the ARM to read and write the cartridge memory independent of the GB CPU,
and I wrote a small logic analyzer for the FPGA to capture the GB bus and record 1024 compressed samples, which corresponds to about 200-300us of data.
Last weekend I also started working on a file browser on the GB, so that I don't have to use the USB shell for everything.

Thanks to the logic analyzer, I also managed to figure out why it didn't work on the DMG and SGB.
I didn't decode adresses properly in all cases and would drive the bus when /rd goes low, even if the adress is not in external memory. This wasn't an issue on the GBA (and probably CGB), but on the older models the internal and external buses are apparently not completely isolated and the CPU would get a wrong value when trying to read from internal RAM.
So it would execute fine most of the time, but CALLing a subroutine and the RET would read garbage from the cartridge instead of the proper return adress from the stack...

Now I'm checking the adress properly and it works.
I also looked at the double speed switch, but I don't see anything wrong with it. It just hangs after the STOP instruction, but the registers look fine. There is also nothing obvious in the firmware, that part is virtually identical to the one from the older working cartridge version. :?

And I added more improvements to the PCB layout. Reading from the SD card produces noise on the speaker, so I improved the decoupling. But I don't see any significant noise on the supply, so I'm not sure if it helps.
I also want to connect the DAC to the GB audio input and upgrade to the faster STM32 while I'm at it.

Image Image Image
Post Reply