llemarie’s weblog

Programming, tinkering – Lionel Lemarié

Archive for the ‘Projects’ Category

Project: Javascript Game Boy Emulator

Posted by llemarie on February 6, 2011

Game Boy Emulator in Javascript

Game Boy Emulator in Javascript

A quick and dirty Game Boy emulator in Javascript.

- Can run Super Mario Land and Tetris (and not much else).
- Full speed (60fps) in Chrome 9.
- Menu to switch cartridges.
- Fast debugger.
- Register view.
- Code and data breakpoints.
- Memory view.
- Program flow trace with disassembler.
- Runs super-slow on iPhone.
- Comes as a single HTML file, data is embedded.

Give it a try here: Game Boy Emulator in Javascript. You’ll probably need Chrome or Safari.


- Game Boy CPU Manual

- Pan Docs

- Game Boy Emulation in Javascript article series

Other implementations of the emulator:


Posted in Gameboy Emulator, Programming, Projects | 1 Comment »

Project: The Black Art of Video Game Console Design

Posted by llemarie on April 11, 2010

XGS PEFor Christmas I got a game console: an XGameStation Pico Edition. It’s a small kit with all the components needed to build an 8-bit console. It comes with a breadboard and an optional swish PCB. The accompanying book The Black Art of Video Game Console Design, by André LaMothe, is a thousand page brick that takes you from what an electron is, through how to read resistors, how to read and draw schematics, how to use and interface logic gates, what’s in the power supply, what different 8-bit microprocessors and microcontrollers are offering (Z80, 6502, SX52), how to generate the video and sound signals in hardware with and without dedicated chips, to the final complete design of a working video game console. The final chapter takes you through the steps of building the XGS PE on a breadboard.
That was a very good read (although the first few chapters really are quite basic), and gave me a lot of ideas for a design of my own.

The XGS uses a SX52 microcontroller at 80MHz, which is quite powerful. I’m eying a 6502 and possibly 6581 for sound for my next project. I’ve got everything I need, all I need to do now is design it on paper to use a NES joystick and output mono sound and a PAL signal, lay it out in Eagle CAD, etch and drill the PCB, solder the chips and components, write a game in assembly, burn the machine code to the EEPROM, power the thing with a 9V battery and switch it on. Should work first time, I don’t see what could possibly cause trouble.

Posted in Projects, Propeller SX, Video Game Console | Leave a Comment »

Projects: ASCII keyboard emulator for Apple I Replica

Posted by llemarie on February 20, 2010

ArduinoASCII keyboard emulator

Last week I built an Apple I Replica from a Briel Computers kit. While I loved the completed machine, I suffered a bit from the fact that backspace doesn’t work (you have to type the assembly *exactly* correct), and of course it loses the RAM contents when shut down.

I wanted to make an interface to the PC so I could use a modern editor and simply copy-paste to the Apple I. As a quick and dirty solution to the problem, I used an Arduino, wired it to the ASCII keyboard port of the Apple I and wrote a small sketch that listens on the serial port and sets the data pins accordingly.

Photos on Flickr.

Here’s the Arduino sketch, real simple:

   ASCII keyboard
   Lionel Lemarie

   Listens on the serial port for characters from a PC.
   Outputs the codes like an ASCII keyboard.
   Compatible with Apple I Replica.

// The order of the pins is chosen for minimal wire crossing
// when connected to an ASCII keyboard socket.
int ASCII0 = 7;
int ASCII1 = 8;
int ASCII2 = 3;
int ASCII3 = 5;
int ASCII4 = 4;
int ASCII5 = 6;
int ASCII6 = 2;
int STROBE = 10;
int NRESET = 9; //reset active low

// LED will blink when a character is emitted
int LED = 13;
unsigned long previousMillis = 0;
unsigned long interval = 200;

void setup()
	analogReference(EXTERNAL); // Is this needed? 

	// Initialize the digital pins as output
	pinMode(ASCII0, OUTPUT);    
	pinMode(ASCII1, OUTPUT);    
	pinMode(ASCII2, OUTPUT);    
	pinMode(ASCII3, OUTPUT);    
	pinMode(ASCII4, OUTPUT);    
	pinMode(ASCII5, OUTPUT);    
	pinMode(ASCII6, OUTPUT);    
	pinMode(STROBE, OUTPUT);    
	pinMode(NRESET, OUTPUT);    

	pinMode(LED, OUTPUT);

	digitalWrite(STROBE, LOW);   // set the STROBE pin to inactive
	digitalWrite(NRESET, HIGH);  // set the RESET  pin to inactive


void loop()                    
	unsigned long currentMillis = millis();

	if (Serial.available() > 0)
		int iInput = Serial.read();
		iInput &= 127;

		if (iInput)
			if (iInput>='a' && iInput<='z')
				iInput = iInput - 'a' + 'A';

			int D6 = LOW;
			int D5 = LOW;
			int D4 = LOW;
			int D3 = LOW;
			int D2 = LOW;
			int D1 = LOW;
			int D0 = LOW;

			if ( iInput & 64 ) D6 = HIGH;
			if ( iInput & 32 ) D5 = HIGH;
			if ( iInput & 16 ) D4 = HIGH;
			if ( iInput &  8 ) D3 = HIGH;
			if ( iInput &  4 ) D2 = HIGH;
			if ( iInput &  2 ) D1 = HIGH;
			if ( iInput &  1 ) D0 = HIGH;

			digitalWrite(LED, HIGH);
			previousMillis = currentMillis;

			// Output an A (100 0001)
			digitalWrite(ASCII6, D6);
			digitalWrite(ASCII5, D5);
			digitalWrite(ASCII4, D4);
			digitalWrite(ASCII3, D3);
			digitalWrite(ASCII2, D2);
			digitalWrite(ASCII1, D1);
			digitalWrite(ASCII0, D0);
			digitalWrite(STROBE, HIGH);
			delay(40);  // strobe for 40ms
			digitalWrite(STROBE, LOW); 

	if ( (previousMillis>0) && (currentMillis-previousMillis>interval) )
		digitalWrite(LED, LOW);
		previousMillis = 0;

Posted in Apple I Replica, Arduino, Blogroll, Programming, Projects | 3 Comments »

Projects: Apple I Replica

Posted by llemarie on February 14, 2010

Apple I Replica

So last august I came across and bought an Apple I Replica kit, from Briel Computers. It’s a very cool little kit which includes a smallish PCB, a handful of components, all the ICs required (including the 6502 microprocessor and a Parallax microcontroller) and very easy instructions. The EEPROM has BASIC and an Assembler already in, so once you assemble the whole thing it’s ready to use. The schematics and manuals are included on a CD, although the package on the website is slightly more recent.

I had a couple of mishaps (dry solder joints, couldn’t find a suitable power supply, plugged in the ROM in the wrong slot). But nothing that destroyed the board, which is a bonus.

See all the steps in pictures in the Flickr set.

Next: make a hardware interface to connect a PC to the ASCII keyboard socket. I want to be able to type on the PC and send the keystrokes to the board, as if it was receiving it from a keyboard. The point being that I would type the programs in vi or notepad and “copy/paste” the code to the Apple I Replica. I plan to use an Atmel microcontroller to listen to the PC on USB or serial and simulate the keystroke for the ASCII keyboard port. Details on the (proper) ASCII keyboard can be found here.

Posted in Apple I Replica, Blogroll, Projects | Leave a Comment »

Project: Change Housing on Z610i

Posted by slemarie on March 2, 2008

phone(Posted by Sarah)

So, after inadvertently stealing Lionel’s thunder when he bluetoothed his headphones and the world gave me all the credit, I thought I better get a project on here to prove that I can totally do stuff too. And also because Lionel wrote on my (retired) blog one time, and I need to get revenge return the favour.

So here’s the first thing I did. Inspired by my husband’s penchant for doing so, I took something apart. But then in a ground breaking revelation, I put it back together again! And now with my super helpful flickr set to follow, you can too.

My unwitting victim was a Sony Ericsson Z610i. They are cellphones of the supershiny clamshell variety, google for ‘z610i’ and you will most likely hit 1001 forums with dudes talking about how they just bought one for their wife. Please understand that usually, I lust after a phone with some pointless great new feature that I will never use, but it will destroy my battery life (cf. wifi on my N80, which I have successfully used outside my own home approximately 0 times. But I still changed my cell phone number, just to get this phone). Anyhow this time around, I just wanted a straight up clamshell, that would not cost the earth, and maybe even look nice.

So I bought the most badly abused phone you have ever seen on eBay. If Bride of Chucky had a cellphone, this is what it would look like. It was cheap, OK?

I blame eBay for most of my failings in life, and this time was no different. If there weren’t a vast array of very accessible alternative phone housings on eBay, I’d never have found myself musing one day how fascinating it would be to take my cell phone to pieces, check out the guts, and then while I’m at it rebuild it back into a shiny new case. What fun! Two weeks and one package from Hong Kong later, my vision was realised and with no thought for the possible consequences whatsoever I set about taking my phone apart.

I learned several things while doing this project.

1. Don’t just look for screws. Look for screw covers. Under screw covers, ye will find more screws.
2. It’s really hard to take phones apart until all the screws are out.
3. Screws 1, plastic wedge tool 0.

If you’re patient enough to try this at home, check out the flickr set photo descriptions for some running commentary and obvious statements such as “take this out of the old housing and put it in the new housing, in the same place”.

Most steps are fairly straightforward. I began by removing the casing on the base half first to minimise the amount of time that I was waving around the naked LCD displays. This seemed to work as an approach. When you begin, prize apart the new casing your ordered first (WHY do they piece it together!?) and take your time. Prizing casings apart works best if you run slowly and gently around the entire casing seam in slow gentle movements. Thin cheap plastic bends if you so much as sigh in frustration near it, so take your time and never tug something too far in any one direction unless you’re totally confident about the consequences.

It’s hard to tell from the final finished photos, but I actually broke my new casing in two places while opening/fitting it. The upper half of the keypad housing is particularly vulnerable at each side, as you only have two thin struts of plastic there while you’re levering off the ends of the casing. One snapped almost instantly in the first 30 seconds of my phone destruction newbie-ism, one gave up during my base-half reopening session as I attempted to reunite the keypad with its underlay. Fortunately both breaks were clean and reseated into each other well once held in place by the rest of the housing.

On the second snap, that half of the casing was suddenly freed by both breaks and allowed me to sit the Franken-phone down with case components sticking out in all directions rather casually.

“I’m nearly done. Honest. Just a few bits to finish.”

All in all I spent about four hours messing with it, involving far too long believing I had removed all the screws, and far too long rebuilding the base without first putting in the keypad underlay. You really want the keypad underlay, it’s what makes your keys work, as it turns out.

Would I do it again? Actually, yes. Paying a small amount for a new housing of decent quality and then cleaning your phone out definitely beats carrying your phone around in some second skin housing that will never look as great as your phone does on its own. For the last 18 months I’ve carried an N80 in a crystal case covering, and while it has preserved the phone excellently, it’s been even bigger and fatter than all its phone peers for the duration. Naff.

Did it go totally smoothly? No. I snapped the casing – recoverable in my case, fortunately – and now the camera isn’t working. All other features work as advertised, but the camera does nothing. There’s a fairly large connector near the hinge that you can disconnect, and I did – I highly suspect this is the source of my problem. Sometime when I decide a camera on a cell phone beats a Nikon D40, I’ll get around to looking at that.

The Z610i is a strange beast. Its features are utterly average and yet for some reason I have an irrational love of it as a phone. And now that it’s a shiny as it was always meant to be, I am complete!

Tune in next week for ‘Changing the housing on your husband’s macbook’. Am I kidding? Am I?

Posted in Blogroll, Projects, Z610i | Tagged: | 8 Comments »

Project: Head-tracking on PS3 – Now without glasses

Posted by llemarie on February 28, 2008

Well, the R&D guys at SCEA went and did it. They’re using facial recognition to track on head on the screen, instead of using IR LEDs strapped to your head. They demonstrated it at GDC, cool stuff!

The feat was reported by Kotaku, Gizmodo, Joystiq and others, but essentially they all point to the same video on mtv.com which has a silly IP ban for UK, Japan and Canada. Those countries clearly have no right to know about glassless headtracking.

Same video on youtube with no IP ban:

Posted in Blogroll, Head Tracking, Projects | Tagged: , , | Leave a Comment »

Project: Head-tracking on PS3

Posted by llemarie on February 9, 2008

IR LED glassesThomas Miller IV from SCEA game studios posted a cool video about his Desktop VR port to the PS3 (embedded below). This is a very interesting concept and well worth watching.

It uses the Playstation Eye webcam to track IR LEDs that you wear on your head on the side of a pair of glasses. As you move your head, it moves the 3D view on the screen accordingly, giving you a great impression of depth. When you look at the face of a cube and lean left to look at its side, you actually see its side.

I built the glasses out of junk remote controls lying around. Took the IR LEDs, the remote battery compartment, even the on/off switch. Glued the lot together on my friend’s sunglasses and added a couple of wires. Job done. No resistors needed that I could tell, the IR LEDs use 1.6V, so they should be fine wired straight to a couple of 1.5V batteries in series. Post in the comments to tell me otherwise before they blow up and I’ll owe you one. I could have used button batteries to make it swish and subtle, but then it would have blown my budget of £0, so I went for the fat ones from the remote controls.

We taped developed film on the Playstation Eye as an IR filter (see photos), as recommended in the video. It works pretty well. To improve the image quality it’s recommended to open the webcam, and remove the IR filter (it’s a pale green film on the lens), but it’s not strictly necessary to do it. (Note that the IR filter inside the webcam prevents IR light from passing through, whereas our developed film tends to only let the IR light through, not sure what the proper vocabulary is there, they probably have different names).

The PS3 demo written by tmiv is pretty simple, and neat in that way. It takes the image from the webcam and looks for the two dots of light from the IR LEDs (also supports one dot for controlling using a normal remote control). As the dots move on the X/Y plane, it moves the camera accordingly, giving you the impression that you are looking on the side of the object. The effect is pretty uncanny! By using the distance between the points, it knows when you’re getting closer or further from the webcam, and changes the depth too.

Video from Thomas:

Posted in Head Tracking, Projects | 11 Comments »

Project: Musical Caps-Lock Key

Posted by llemarie on November 7, 2007

I posted my first Instructables after I received a comment on my Frankenphones post saying that I should have pusblished the instructions for the headphones.

For this project I took the idea from a Kipkay video and wired a greeting card musical module to the caps-lock key of a colleague’s keyboard, unbeknownst to him, and waited for him to press caps-lock by mistake. Music!

He googled for a virus that plays music on your keyboard, looked for accessibility settings, searched for the source of the Jingle Bells music: is it the PC? is it the monitor? no, it’s the keyboard! This prank is hilarious!

Read all about it on Instructables.

Photos on flickr.

Lire en français.

Posted in Blogroll, Musical CapsLock Key, Prank, Projects | Tagged: | Leave a Comment »

Software: LeDimmer – Unclutter your screen

Posted by llemarie on November 1, 2007

LeDimmer is a small Windows application (<200KB) that sits in the system tray and simply dims the screen around the foreground window. The numerous advantages include being able to focus on the task at hand, finding the window in focus at first glance even on multi-monitors, and it even looks nice. General Windows usage is not changed at all: click or alt-tab into a dimmed window and it brightens into focus.

You can specify a bitmap as the dimming picture to get a nice glossy effect on your screen, embed your company logo, admire your dulcine, etc…

It couldn’t be simpler to use: start it, it sits in the system tray, quit it with the tray menu or the shortcut ctrl-shift-q. That’s it…

LeDimmer works on Windows 2000, XP and Vista. Grab it free from the home page.

Comments, feature requests and bug reports are appreciated.

Posted in Blogroll, LeDimmer, Programming, Projects | Tagged: , , , , , , | 1 Comment »

Projects: Fixed my boots

Posted by llemarie on October 14, 2007

Exciting! I fixed my boots.

I’ve been a walking fashion faux-pas for weeks now, since a metal plate broke at the back of my boots then fell off altogether. We couldn’t have that. New Rock was kind enough to send me a set of replacement plates and rivets with no instructions to take the broken plate off and put the new one in.

The solution: walk about with the broken plate hanging until a piece falls off a few months later and use brute force to pry the remaining bits off. Of course, I should have thought about it before: nothing beats brute force.

After that it took me weeks to finally get my act together and replace the thing. I had to learn how to use a rivet machine – I had to buy a rivet machine. Scary. The whole thing took 10 minutes.

Pixels on flickr.

Posted in NewRock Boots, Projects | 4 Comments »


Get every new post delivered to your Inbox.