Friday 29 November 2013

Publishing Java Games on Facebook

I am appalled at the lack of resources dealing with creating and distributing games made in Java on Facebook. Perhaps it is because no-one makes on-line games in Java, perhaps it is because the process is actually so easy it doesn't need documented or perhaps the people who have managed it want to keep the process a secret so they can make all the monies themselves! Whatever the reason, this post aims to buck the trend and document what is in fact a really easy process.

Just as a quick heads up here is what this post will and won't cover:

It will cover:
  • Deploying your Java applet to the web.
    • This is a pretty easy step and if you've made an applet before you probably know how to do this.
  • Making the applet accessible via Facebook.
    • This is also an easy step it just doesn't seem to be written anywhere else on-line!

Saturday 31 August 2013

Arduino Game Player - Sega Master System (2 of 2)

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:

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?

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:

Tuesday 20 August 2013

Internet Camera in a Bird House (1 of ?)

After the Time Lapse Videos of the Garden project I got thinking about how to get round the issue of nothing being visible at night. If you haven't looked at that project the basic issue is that the infared light generated by the camera is reflecting off the glass of the window making it impossible to see outside.

Two solutions instantly came to mind:
  1. Turn the IR on the camera off and flood the garden with infared light from a source already outside.
  2. Move the whole camera outside.
From the two I've decided to go with the 2nd one. The first idea may actually be easier as you can already buy outdoor infared lights and all I'd have to do is connect the power to them and set up some sort of timer to turn them on and night and off during the day. However, I can't really justify the expense on what is just a 'for fun' project so I'm really stuck with option 2 regardless.

Wednesday 8 May 2013

Time Lapse Videos of the Garden (3 of 3)

This is the last video in this time lapse series.

In this video I've removed all the images taken between 8pm and 5am. Don't worry, I didn't have to do this by hand! All the videos save with a similar file name which has the date and time in it so I wrote a little regular expression that deleted all the files with a 00 - 04 or a 20 - 23 in the hour slot. The commands looked like this:

rm 00A8F9005FCC\(IPCamera\)_0_2013????0{0..4}*
rm 00A8F9005FCC\(IPCamera\)_0_2013????{20..23}*

The rm command you should be familiar with, then it is the camera's MAC address (I think) followed by the name in brackets then _0_ (for some reason, maybe camera number) then the 4 digit year, 2 digit month (single digit wildcards), 2 digit date (single digit wildcards) then the 2 digit hour. Notice in the first command I put the first digit of the hour outside the curly bracket, I just wasn't sure 00..04 would work so opted for 0..4 instead. What came after the hour digits didn't matter so I just dropped in a multi digit wildcard.

Thursday 18 April 2013

Time Lapse Videos of the Garden (2 of 3)

The camera looking out to the garden has been running for a while now. Since about the 28th of March given the date of my last post on it. As you can imagine it has gathered quite a large collection of images, 18,000 at the last count! So I thought it would be a good a time as any to give another time lapse video a try.

I used the same script as last time but made a slight change so it would create a copy of each image with a 5 digit number rather than 4 (cause we have over 9999 images) and out the video with a greater frame rate (20fps instead of 4).

x=0; for i in *jpg; do counter=$(printf %05d $x); cp "$i" /tmp/img"$counter".jpg; x=$(($x+1)); done
ffmpeg -f image2 -r 20 -y -i /tmp/img%05d.jpg garden.avi
rm /tmp/img*

The results were less than satisfactory (don't watch the whole video, the first minute or so gets the point across):

Tuesday 9 April 2013

Germinating the Veg

I was going around the shop the other day and it suddenly dawned on me just how late in the planting season it is getting. The terrible weather recently (terrible for gardening that is) has made it impossible to get into the garden which would have been a perfect time to get some germinating on the go but the bad weather also made it feel a lot earlier in the year than it actually is.

Thankfully it's not too late and most of what I'm looking to plant out can still be planted in April. I dare say with the low temperatures planting out a little later than usual may even be beneficial.

So here is what I bought:

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):

Thursday 28 March 2013

Time Lapse Videos of the Garden (1 of 3)

I've gotten quite into hillwalking this year. In fact I even have another blog dedicated purely to that which I will shameless plug here: it is munrochallenge.wordpress.com and it details me and my friend Martyn's attempt to climb 52 munros this year. (We've managed 3 so far.) As part of this new hobby I signed up to a few on-line forums to meet other people with similar interests and one of the forums I go on frequently is the one at walkhighlands.co.uk.

It was on here that a user known as Alastair S (probably his real name!) posted up a thread talking about a little computer program he had made. What it does is connects to public internet cameras anywhere in the world you point it to and downloads an image from them once every minute. When it has a large collection of these images it creates a video out of them which is played back at 20 frames per second. This hence lets you watch an entire days, weeks, months or even years worth of footage in just a few minutes. It's a technique known as 'time lapse video' and it can make for some very interesting videos. Here are a couple he has produced so far:


Sunday 24 March 2013

Fixing the Sankey Water Butt

So given its mostly good reviews I bought a Sankey 210L Water butt from B&Q and was pretty happy with the purchase given the size of it and the fairly sturdy design. It is a bit on the expensive side and having to buy the stand separately was a bit annoying but I weighed it up and decided to go for it anyway. Big mistake!

The Sankey 210L Water butt 
After having it in the garden for a few weeks I found it kept falling over. Not sure if it was being pushed or blowing over because of the wind so I decided to fill it about a quarter of the way with tap water to weight it down a little. It was at this point I found that the water butt leaked through the tap!

Thursday 21 March 2013

Gardening Plans for 2013


So as you can see from this picture taken today (21st March) even though we are officially in Spring it still isn't quite gardening weather.



So instead I thought I'd share my plans for this year with you.

This year is going to be all about colour! What I want to do is create a rainbow effect round the border of the garden going from violet colours on the left round to reds on the right with all the colours in between in the middle.

Really this shouldn't be too hard since I plan on purchasing plants this year rather than growing them myself. I know, I know, it's cheating, but I just don't have the time to dedicate to growing from seed just now and especially not for the amount of plants I think I'm going to need.


The plant of choice is going to be Primulas; they are colourful, readily available, quite hardy and don't cost the earth.

Other than the border I'll probably give some vegetables a try again. Most of the hard work of digging up the lawn to make space for a vegetable patch was done last year so hopefully I can give more time to the tending of the veg and actually get something to show for it this year. We'll see...

Finally I'm going to plant some roses in the little strip of garden I have to the left of the house. Putting the water butt there (which needs the seal fixed btw) isn't enough as it keep getting blown or pushed over. Some thorny roses should do the job and I'll spend the little bit extra money to get fragrant ones which will hopefully add to the garden overall.

Or at least that's the plan if the snow ever leaves...

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.

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
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
Back
Front

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
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) BA6162SN74HC00NGM76C88AL.

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
As you can see below, it still isn't open despite me sliding my 2 screws drivers all the way down the side.
Un-openable J-cart
Clearly there is more to it. Upon investigation of my other games I found this:
Screw poking out the front of a J-cart
Close up
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!
Pete Sampras Tennis with additional control ports
The secret screw
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!
The start shaped T10 bit
So with the case open and the PCB removed this is what we are left with:

Front
Back
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.

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.

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.