So I’ve been able to read/write to a Gameboy cartridge so the next step is emulating one using an Arduino. I wasn’t be able to emulate the whole cartridge using my current methods but I did emulate the cartridge sending the Gameboy the Nintendo Logo. I’ll show you how we can analyse the data coming from the Gameboy and the various steps I went through to get it working.
Let’s jump to the Youtube video straight away to see the results.
The first thing required is a Gameboy that we can solder some wires to; the Gameboy that I took the cartridge header from was perfect for this and then just place those wires into a breadboard.
GBCartRead the Arduino based Gameboy Cart Reader project is now completed. I’ve done everything I set out in terms of saving and restoring my Gameboy saves :). GBCartRead has been updated to version 1.3 which has all the features of reading the ROM, reading RAM and writing to RAM.
The video above shows all features being used.
Now I just need to think about what my next project will be… the logical thing would be do the same with the SNES or I was thinking of working more on the gameboy by emulating a gameboy cartridge with the Arduino 😉
So what good is reading the RAM if we can’t write back to it? This is what we’ll cover in Part 3: Write to RAM.
Writing to the RAM is quite similar to reading the RAM except instead of reading the data pins you write to them. This part won’t be as large as our previous parts because we’re really just re-using our Reading the RAM code. Let’s jump right to the code.
I hope you’ve gotten a feel of how we can access the Gameboy Cartridge in Part 1 and now it’s time for the real part that I was looking forward to: Reading the RAM of the cartridge. Before we start I recommend you read Part 1: Reading the ROM.
In this tutorial I’ll still be using my F1RACE game that uses MBC2 which is actually simpler compared to others because some of the other MBC’s use RAM banking; which is just like ROM banking as you should already know if you read Part 1. I’ll also cover another MBC to show how RAM banking works.
When we want to access the SRAM for reading or writing we firstly have to enable the SRAM, this is done by setting RD/WR and sending a specific command to the MBC. The command is called “initialise MBC” which is found on the VBG website and is given to us as 0x0A, this translates to data pins D1 & D3 should be on (00001010). The other thing to take note of is that RD needs to be set to 1 (off) and WR to be set to 0 (on) when we give the 0x0A command.
Recently I’ve been collecting retro gaming consoles such as the Gameboy and SNES and whilst playing a game on the SNES I actually lost all my saves when I turned it off (turns out the battery got disconnected from the cartridge). The thought came to me, how can I backup the save game from these devices? There are cart readers around but they seem to be harder to find in this day and age so I thought why not make one myself using the Arduino as it’s so versatile!
Before I begin looking into extracting the save games I’ll look into dumping the ROM which was a way for me to learn how to communicate with the Gameboy cartridge. I’ll now guide you in how to communicate with the Gameboy cartridge to read the ROM so without further delay, let’s begin!
Gameboy Cartridge
Let’s firstly take a look inside a Gameboy cartridge. A typical Gameboy cartridge contains:
ROM is where the game’s data is stored
SRAM is where your save games/high scores are keep. Some cartridges (like the one of the left) don’t have this chip because they don’t store any data or it’s built into the MBC
MBC is the memory bank controller, it allows us switch ROM banks to read the game’s data from the ROM.
MM1134 IC to control when SRAM should be run from battery or not
Ever wanted to know how to reduce the power consumption of your Atmel microcontroller when it’s not doing anything? The 2 videos below will step you though how you can reduce the power consumption of your Atmel microcontroller (in this case the ATtiny85) by using the power down sleep mode with the Watchdog timer.
The beauty of the watchdog timer is it allows us to not require an external interrupt to wake up the microcontroller, instead it wakes up after a certain amount of time by itself.
I thought I’d look into reading data from an EEPROM that is I2C capable from a PCB, the PCB is from a KVM which is a device that allows you to use your keyboard, video (monitor) and mouse on different PCs without switching out the cables.
Below is the PCB and the EEPROM which we’ll be looking at.
If you can make it out it’s a Atmel 24C32A, a 32Kbit EEPROM, datasheet here: atmel 24c32a
I’ve now gotten a feel for the LED Matrix and have made a Road Runner game for it too, similar to the LCD Road Runner except you don’t have enemies and don’t shoot. I’ve optimised the way levels are stored better than LCD Road Runner so we don’t have to use PROMEM any more. The main highlight is that you can make your own level very easily which I’ll show you how to do near the end of this post.
LED Matrix Road Runner v1.0 (10 December 2010) – Initial Release with 1 level
Instructions
You control the dot and you need to avoid the walls, you can move in all directions.
I’ve finally got around to wiring up my 8×8 LED Matrix and now it’s time for some fun with it. Though out playing with this I’ve learnt about shift registers and how we can use them along with a transistor array chip.
First things first, have a read and look through the Arduino’s ShiftOut guide as they are very well put together (keep re-reading it if it doesn’t make sense): http://www.arduino.cc/en/Tutorial/ShiftOut
To summarise the guide:
A shift register allows you to have 8 outputs while only using 3 pins on the Arduino
You send a byte to the shift register which has 8 bits (e.g. 10010000)
You can combine shift registers so instead of having only 8 outputs you can have 16 when using 2, 24 when using 3, and so on
When combining shift registers, instead of sending out the 8 bits to the first register and 8 to the second register it’s actually reversed, so the first 8 bits you send are actually for the second register and the next 8 bits go to the first register
We know how to control our 2 motors in both directions and we also know how to use our Phototransistors to detect if an object is close, now we put both of these together to form our robot. In this part we focus more on producing the code as we’ve already put our robot together as below.
AdvanceVGA – Play your GBA on the big screen! Swap out the LCD for our board, solder some wires, connect 5V USB and VGA and you’re ready to go.
GBxCart RW allows you to backup GB/GBC/GBA ROMs, save or restore game saves and re-write supported flash carts. Mini RW option available for GB/GBC only.
Wireless Gameboy Controller – Use your Gameboy, mGB, GBC, GBA, GBA SP, GB Micro, NDS and NDS Lite as a wireless controller on Windows, Linux, Raspberry Pi, etc, and on your NES, SNES, N64, Gamecube and Wii.