Here is the code and the sketch that I promised in part one.
You'll notice I've refactored the code a bit so that the button pressing code is now just 1 method where we pass in the buttons we want to press, the amount of buttons we want to press and the length of time we want to press them for.
This makes a lot more sense on a platform like the Arduino due it's limited memory, no point in filling it up with six methods that do pretty much the same thing. Of course it is good practice in programming in general as well since now if we want to change how we press a button we only have to change it in one place, not six.
Here is the refactored code:
Showing posts with label arduino. Show all posts
Showing posts with label arduino. Show all posts
Saturday, 31 August 2013
Sunday, 25 August 2013
Arduino Game Player - Sega Master System (1 of 2)
Here's a fun little project I've wanted to work on for a while, an automated system that is able to play console based games.
Initially I thought about making a series of wires that connected my PC to a variety of video game consoles via their control ports but since I have the Arduino I think I can throw together something simpler yet just as effective with it.
There are already a few blogs out there showing how to do this, for example this one on instructables which shows you how to tap into a Snes controller or this one also on instructables which shows you how to do the same to an Xbox 360 controller however this isn't quite what I'm looking to do. I want to connect my Arduino directly to the control port of the system, not to the controller. I will admit though using the Arduino as a controller 'expansion' to allow macros and the like is a pretty cool idea and I may come back to that at some point.
I also want to do more with this project than just connect the Arduino to the target system, I also want it to play the games on the system. I've italicised the word play as I'm not exactly certain how I'm going to define the word play yet. Is just moving the character enough or does the character have to be moved towards the goal? Does the system have to work out the goal or can it be pre-programmed in? Does the path to the goal need to be the optimum one or can it be anything as long as it is in the right direction? Does it need to learn?
Initially I thought about making a series of wires that connected my PC to a variety of video game consoles via their control ports but since I have the Arduino I think I can throw together something simpler yet just as effective with it.
There are already a few blogs out there showing how to do this, for example this one on instructables which shows you how to tap into a Snes controller or this one also on instructables which shows you how to do the same to an Xbox 360 controller however this isn't quite what I'm looking to do. I want to connect my Arduino directly to the control port of the system, not to the controller. I will admit though using the Arduino as a controller 'expansion' to allow macros and the like is a pretty cool idea and I may come back to that at some point.
I also want to do more with this project than just connect the Arduino to the target system, I also want it to play the games on the system. I've italicised the word play as I'm not exactly certain how I'm going to define the word play yet. Is just moving the character enough or does the character have to be moved towards the goal? Does the system have to work out the goal or can it be pre-programmed in? Does the path to the goal need to be the optimum one or can it be anything as long as it is in the right direction? Does it need to learn?
Friday, 23 August 2013
Arduino Mega Drive Rom Dumper (1 of ?)
You may remember at the start of the year I posted this entry on Inside Sega Megadrive Carts where I spoke briefly about an awesome project I saw on insideGadgets.
In the project Alex created an Arduino sketch that was capable of dumping the ROM data from a GameBoy cartridge as well as being able to read and write the data from RAM. This inspired me to get my own Arduino with the aim of one day creating my own dumper for the Sega Megadrive system. Well today is that day!
Ok not exactly today but today is at least the start of it!
In case you can't remember the project here are all the relevant posts from his blog, consolidated into one handy list:
In the project Alex created an Arduino sketch that was capable of dumping the ROM data from a GameBoy cartridge as well as being able to read and write the data from RAM. This inspired me to get my own Arduino with the aim of one day creating my own dumper for the Sega Megadrive system. Well today is that day!
Ok not exactly today but today is at least the start of it!
In case you can't remember the project here are all the relevant posts from his blog, consolidated into one handy list:
- Reading From an EEPROM (Consider this pre-reading, and read the guide he links to as well, it's really helpful)
- Part 1 - Read the ROM
- Part 2 - Read the RAM
- Part 3 - Write to RAM
- Project Summary
- Gameboy Cart Shield
- Emulating a Gameboy Cart (Consider this a bonus)
Monday, 1 April 2013
London Science Museum
I don't really post unless I am demonstrating something or talking about my plans but this post is a little different. (Don't worry it's only a short one.) It is also one of the few times I will post the same post on both my computer related blogs: workingwithcomputervision.blogspot.co.uk and czandg.blogspot.co.uk.
This weekend I went down to London with family and during the trip we visited the Science Museum and I thought it would be nice to share a couple of photos of the exhibits from the computing related departments.
There was some pretty cool stuff there demonstrating both the history of computing and the present day (if there were any future orientated displays I didn't notice them.)
Here are a few that caught my interest enough to get photographed (Keep in mind I'm not a huge history buff so although there is a lot there only a handful really grabbed my attention):
This weekend I went down to London with family and during the trip we visited the Science Museum and I thought it would be nice to share a couple of photos of the exhibits from the computing related departments.
There was some pretty cool stuff there demonstrating both the history of computing and the present day (if there were any future orientated displays I didn't notice them.)
Here are a few that caught my interest enough to get photographed (Keep in mind I'm not a huge history buff so although there is a lot there only a handful really grabbed my attention):
Wednesday, 2 January 2013
Inside Sega Megadrive Carts
For Christmas Santa was kind enough to bring me a great new
toy known as the Arduino to play with. If you haven’t heard of the Arduino you
can check it out at http://arduino.cc/ but
basically it is a little programmable board than can use a variety of sensors
and components to interact with its environment. It is also, I’m led to
believe, a good way to get an understanding of electrical engineering, circuits
and the like which is something I’ve wanted to know more about for a while now.
Only 1 chip, the ROM and a couple of components, a resistor on the left and a capacitor on the right I think.
This would be a 'typical' or basic cartridge. The game uses passwords for saving so doesn't need any SRAM making the insides very straight forward.
Ultimate Mortal Kombat 3
This game does use SRAM for saving and as you can see there is a lot more going on inside. The big chip at the bottom is the ROM we are used to seeing with its capacitor and resistor. Above it are all the components involved in saving, namely a battery on the right with a small chip next to it. This chip is the controller which decides if we should use the battery or not depending on the voltage across the cart.
Next to that, also at the top, is a NAND gate. I'm not sure what purpose this has at the moment but I think it is for selecting between the other chips available.
The long one below that the SRAM chip which is where all our save data is stored.
I got most this info from Googling the chip numbers which turned up the following pages from alldatasheet.com: (Same order as above) BA6162, SN74HC00N, GM76C88AL.
As you can see below, it still isn't open despite me sliding my 2 screws drivers all the way down the side.
Clearly there is more to it. Upon investigation of my other games I found this:
There are 2 screws on the front of the cart as well under the sticker! Well played Codemaster, well played!
As it stands I don't want to rip the label of my Dizzy/Cosmic game so I've bought a cheap copy of Pete Sampras Tennis which is also a J-cart just for opening up. It isn't a dual game cart but it does have 2 control ports built into the cart so should be interesting.
I'll post up what it looks like when it arrives.
[It arrives]
Pete Sampras Tennis
So here is Pete Sampras Tennis, I've no idea if it is a good game or not because that's not what we are interested in so I haven't even checked if it's working!
To open it up I used a small star key (it's like an allen key or a hex key but star shaped) which is marked T10. I really don't know much about this tool but it was part of my ratchet set and I'm glad to have finally used it!
So with the case open and the PCB removed this is what we are left with:
The control ports, some red things which I'm not sure what they are, some chips (left and right are SN74LS244 and in the middle is... I have no idea, can't get a good hit from Google) and then the ROM.
I then tried taking a hand drill to one of the carts. This worked but was a lot like using a bazooka to kill fly and unsurprisingly I could no longer claim the cart was in ‘mint condition’.
This time I order these high quality drill bits from The Video Game Museum on Ebay:
One of the very cool projects I’ve saw with the Arduino (and
a large part of the inspiration for me getting one) is this Gameboy Cart Dumper
by Alex of InsideGadgets:
What’s happening in the video is he is showing you his
project that is able to read the data stored on the ROM of the Gameboy cart to
his computer using the Arduino. He is also able to read and write to the SRAM
using exactly the same set up. Basically he has created his own ROM dumper, very
cool!
You can view more of his videos at http://www.youtube.com/user/insidegadgets or check out his blog
at http://www.insidegadgets.com/.
As you may know I’m a lot more interested in the Sega
Megadrive than the Gameboy so would like to perform the same task on Megadrive
cartridges. In order to do so it is important to see inside the carts so I know
just what I am going to have to deal with. So here is the insides of several Megadrive
carts, hopefully it will be of some use to you as well.
Mega-Lo-Mania
![]() |
| Front |
![]() |
| Back |
This would be a 'typical' or basic cartridge. The game uses passwords for saving so doesn't need any SRAM making the insides very straight forward.
Ultimate Mortal Kombat 3
I thought it was a large ROM but it doesn’t look like it is as it’s the same as Mega-Lo-Mania only the components are reversed.
Shining Force 2
![]() |
| Front |
![]() |
| Back |
Next to that, also at the top, is a NAND gate. I'm not sure what purpose this has at the moment but I think it is for selecting between the other chips available.
The long one below that the SRAM chip which is where all our save data is stored.
I got most this info from Googling the chip numbers which turned up the following pages from alldatasheet.com: (Same order as above) BA6162, SN74HC00N, GM76C88AL.
Mega Games 6
![]() |
| Front |
![]() |
| Back |
This is a cart that has 6 games on the one cartridge. We can see they are spread across 2 ROMS, we still have a capacitor and resistors dotted around the place and also another chip. This is the same chip as in the Shining Force 2 cart above, the SN74HC00N NAND gate, making me more certain that it is for choosing between chips.
Fantastic Dizzy and Cosmic Spacehead
This is a special case and I thought was worth extra mention even though I couldn't get the cart open! These two games come on the same cart but it is one of those funny J-Carts developed by Codmaster and they don't open the same as standard carts.
At first I thought it was just the 2 clasps on the top that needed pushed in to open it as there aren't any screws visible on the case.
![]() |
| J-cart top clasps |
![]() |
| Un-openable J-cart |
![]() |
| Screw poking out the front of a J-cart |
![]() |
| Close up |
As it stands I don't want to rip the label of my Dizzy/Cosmic game so I've bought a cheap copy of Pete Sampras Tennis which is also a J-cart just for opening up. It isn't a dual game cart but it does have 2 control ports built into the cart so should be interesting.
I'll post up what it looks like when it arrives.
[It arrives]
Pete Sampras Tennis
So here is Pete Sampras Tennis, I've no idea if it is a good game or not because that's not what we are interested in so I haven't even checked if it's working!
![]() |
| Pete Sampras Tennis with additional control ports |
![]() |
| The secret screw |
![]() |
| The start shaped T10 bit |
![]() |
| Front |
![]() |
| Back |
Getting in Without
Breaking the Carts
When I bought my Flash cart for the Sega I had to open one
of the cases to replace the PCB (the chip boards we've been looking at) with the one for the Flash
board. Unfortunately the Megadrive carts have some funny shaped security screws
which need a special bit to open.
Being the ever resourceful person I decided to try the ‘melted pen’ method where you get a cheap, plastic pen and melt the end into the screw then hold it till it dries. It is meant to give you a plastic screwdriver that can open any of the Megadrive cases. All it gave me is a broken pen.
Being the ever resourceful person I decided to try the ‘melted pen’ method where you get a cheap, plastic pen and melt the end into the screw then hold it till it dries. It is meant to give you a plastic screwdriver that can open any of the Megadrive cases. All it gave me is a broken pen.
I then tried taking a hand drill to one of the carts. This worked but was a lot like using a bazooka to kill fly and unsurprisingly I could no longer claim the cart was in ‘mint condition’.
This time I order these high quality drill bits from The Video Game Museum on Ebay:
| Special bits for the Nintendo and Sega cartridges |
They are really strong, fit in my Black and Decker screw
driver (I think it’s a standard size) and do the job perfectly. For less than a
tenner for both the Nintendo and the Sega bit plus 5 batteries to replace the
ones in your carts that use SRAM they are well worth investing in.
That’s it for now. I’ll have more information about ROM
dumping via the Arduino as and when I work it out and will update this entry
with more Megadrive carts insides as I discover them.
Subscribe to:
Posts (Atom)
















