Skip to content

About

A CPLD implementation of the MBC5 mapper with SRAM saving

Resources

Stars

1 star

Watchers

1 watching

Forks

Repository files navigation

GAMEBOY-CPLD-SRAM-2MB

Warning

Current circuit board revision does not include support for the MAX7000 or ATF150x CPLD without bodges.

Introduction:

This is my take of a CPLD based flash cart for the Gameboy.

The whole project is based from Alex's project from years back. Without that project, I would never have picked this up and spend my time figuring out how to work with CPLDs. I am not a programmer and do not claim to be. Picking up Alex's code I can see how things work with my previous knowledge of how carts operate.

This version uses SRAM like Alex's did originally. As much as I love using FRAM to bring this old technology towards the modern age, it is technically not compatible due to timing and different glue logic requirments. Not to mention it's really expensive new, China sells cheap factory rejects, and on the whole it's a pain in the ass. Embrace SRAM, it's cheap and available. The battery life is not an issue as people want to think, my original Pokemon Red, Blue and Yellow carts are still using the original batteries with over 3v in them after 28 years.

The newest update has been done with the help of AI. I just wanted to get this thing done so it is off my active project list. Even though AI has helped, I have learned a little bit more about how CPLDs work because of it. In the future I'd like to use the knowledge to do another project.

Some reasons to build this project are:

+ No need for sourcing a donor cartridge
+ Multi MBC compatibility
+ Cheaper to build vs a donor cart (initially not, more made, more saved)
+ No messing with expensive FRAM or dodgy back ally FRAM

Important

This project is designed with MBC5 functionality as the main priority. Compatibility with MBC1 is added on top, therefore, compatibility is not guaranteed. Super Mario Land 2 & Zelda: Link's Awakening work here, where they have issues running on a normal MBC5 chip. However, Donkey Kong Land does not work. Maybe one day I can create an MBC1 CPLD mapper.

Note

For updates, see towards the end of the readme

🟦 Project State:

🟒 Done

- Get a cartridge that works well enough
- Make the Altera 3032A & 3064A both work
- Fix SRAM problems with MAX7000 and edge case MAX3000
- Fix this readme after half updating and rage quitting. Remove V2.0 PCB pics.
- Write draft of instructions for programming Atmel chips

🟑 In Progress

- Do some power tests of carts I have built so far.

βšͺ To Do

- Test flashing Atmel chips in circuit
- Design some hardware to flash Atmel chips in circuit
- Update PCB to include solder jumper for different CPLD families.
- Some issues with SRAM in FlashGBX with Atmel 1502A. Check hardware over & adjust WinCUPL settings.

🟨 Prerequisites

* The full components parts list and cart PCB
* (Optional) JTAG adaptor PCB
* Altera USB Blaster or FT232 for JTAG (cheap clones work)
* Windows PC with Quartus II Programmer, Quartus II Web Edition or OpenOCD
* GBxCart and related software
* Modified Gameboy cart shell or (optional) 3D printed Game Gear cart adaptor
* Equipment to solder tiny SMD components
* Skills to solder tiny SMD components reliably

πŸ”Œ CPLD Information

Prices vary, these are typical.

Model Cost x1 Vendor
3032A: €1.16 Aliexpress
3064A: €1.60 Aliexpress
7032S: €1.85 Aliexpress
1504A: €1.97 Mouser

Depending on the model, the AP2127K-3.3TRG1 may not be needed.

Model AP2127K Jumper
3032A YES NO
3064A YES NO
7032S NO YES
1502A NO YES

🟦 Parts List

Cartridge x1

Important

When ordering cartridge PCBs, make sure to choose 0.8mm thickness and gold plating.
Altera MAX3000 & MAX7000 CPLDs are obselete and only found on Aliexpress. I suggest the 3032A. (MAX7000 is a relic at this point).
If ordering MAX7000, get the S version, otherwise throw your money in a fire. Eg, EPM7032S
Atmel ATF150x parts can be bought new from reputable sellers. However they are trickier to program for the average person.
Order FRAM from Aliexpress & eBay at your own risk, they are known to be extremely unreliable.

Part No. Package Qty
29F016 TSOP48 1
IS62C256* SOIC28 1
CPLD** TQFP44 1
AP2127K-3.3TRG1*** SOT23-5 1
TPS3613-01DGSR 10VSSOP 1
2N7002 SOT23 1
Cap 100nF 0603 5
Cap 1uF 0603 1
Res 10K 0603 1
Res 49K9 0603 1
Res 130K 0603 1
Bat Holder AliExp 1

**Other alternatives include, but are not limited to: AS6C6256, CY62256, R1LP5256.
***EPM3064A, EPM3032A, EPM7064S, EPM7032S, ATF1504A or ATF1502A.
***See CPLD info

JTAG Adaptor

Part No. Qty
DS Lite Cart Conn 1
USB C USB4125 1
Pin Headers 2x5-P2.54mm
GG Adaptor or Shell 1
USB Blaster 1

Tip

Link to Game Gear Adaptor

Build Photos

CPLDcartcomp

Different CPLD
CPLDcartclose

Update June 2026

I've picked this back up again when I found a PCB laying about. I had to wonder if AI was good enough now to help improve things. It is fortunately.

The previous update I was naive to think programming in C++ was anything like Verilog. I mean it is, but the device being programmed works so differently to other CPU based systems.

The issue that has been plaguing the 7032S & 1504A, is the save RAM functionality. Games would not save, or correctly use the cartridge as work RAM. This was on the Gameboy and cart readers. I tested this over a few carts and the first one kinda worked. It was flaky but saving, yet only on the GB and not the cart reader. There worst problem is that this problem crept into some of the 3032A and 3064A carts also.

This code refactor seems to have fixed all these problems, not only the MAX3000 but the MAX7000 also. As of now, the ATF1504 is untested. I am hopeful that it will work also. Programming those is more complex and I've since forgotten how to do it.

The smaller EPM3032A, EPM7032S & ATF1502 with 32 macro cells are now more than big enough to fit the program, no longer is it so tight. This is thanks to removing the 128KB RAM functionality, reducing the amount of registers required to address that has gained a lot of space. Additional code can be added for more functionality such as moving the FRAM gate logic into the CPLD and making it user programmable with a solder bridge on the PCB.

This is all very nice as the smaller chips tend to use less power than the larger counterparts, even though they use the same quantity of macro cells. I'll add more detailed information on the changes in its own readme.

When the Atmel part is confirmed working, I'll update the rest of the readme to walk though programming those. Ideally the PCB could use a revision to add the FRAM mode jumper and a jumper to bypass the 3.3v regulator when using the MAX7000 and ATF15xx chips. Again, I'll get to that when testing is complete.

Firmware Versions

Version Status Notes
V1.0.0 Initial Original code from Alex's blog
V1.0.1 Fix Removed internal FRAM chip select logic to lower cartridge power consumption 1 to 3%
V2.0.0 Fix Changed project compiler settings to lower cartridge power consumption 36 to 41%
V3.0.0 Current AI helper to teach me and structure code better. Use of macro cells more efficient. Logic split into smaller sections. More reliable, cleaner code, better output waveforms (I need to confirm that).

🩷 Links

πŸ”§ Driver Install: https://www.terasic.com.tw/wiki/Intel_USB_Blaster_Driver_Installation_Instructions
⬇️ Driver Download: https://github.com/sudhamshu091/USB-Blaster-Driver-for-DE10-lite
πŸ–¨οΈ Game gear Adaptor: https://www.thingiverse.com/thing:5830799
⏬ Alt Link Quartus: https://archive.org/details/quartus-iiprogrammer-and-signal-tap-ii-13.1.0.162.7z
πŸ›οΈ Inside Gadgets Shop: https://shop.insidegadgets.com
πŸ“Ž Inside Gadgets GitHub: https://github.com/insidegadgets
πŸ“· Inside Gadgets Insta: https://www.instagram.com/inside.gadgets
πŸ–‡οΈ Bytendo Mods GitHub: https://github.com/bytendomods
🐭 Bucket Mouse: https://github.com/Bucket-Mouse
πŸ›’ Natalie Shop: https://nataliethenerd.com/
πŸ€“ Natalie GitHub: https://github.com/natalie-lang/natalie

Thanks to Xukkorz, Drew, Jamo, Alex, Deceptive Thinker, Natalie the Nerd & anyone else who I may have forgotten.

License

This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License. You are able to copy and redistribute the material in any medium or format, as well as remix, transform, or build upon the material for any purpose (even commercial) - but you must give appropriate credit, provide a link to the license, and indicate if any changes were made.

About

A CPLD implementation of the MBC5 mapper with SRAM saving

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages