llemarie’s weblog

Programming, tinkering – Lionel Lemarié

Archive for the ‘Programming’ 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 »

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 »

Programming: Beanie Fighter

Posted by llemarie on March 23, 2008

Dancing NinjasLive greetings from Breakpoint!

After a year of on and off development, with serious on development in the last few months, I finally got to submit my new 96KB game entry for Breakpoint. It ended up in a huge anti-climax, when nobody else submitted an entry and the 96KB game competition had to be canceled. The game was shown in glorious 12m wide 1080p though, in front of a great crowd!

I also gave a seminar, called Multicore Mayhem, presenting a technique for distributing code to the available CPUs. The video will be available on the Breakpoint website after the event.

Update: Due to a technical problem during the recording, the video is not available unfortunately…


Download the game here.

Posted in Beanie Fighter, Programming | Tagged: , | 12 Comments »

Breakpoint ’08 Seminar: Multicore Mayhem

Posted by llemarie on February 27, 2008

The seminar page for Breakpoint ’08 is up!

I’ll be giving a talk at Breakpoint in Bingen on multicore programming on Windows. A lot of lessons can be learnt from console programming and applied to the PC now that CPUs have 2, 4 or 8 cores… I’ll be discussing design and pitfalls (with solutions) and I’ll give away an in-game profiler for free!

Stay tuned (to the RSS feed) for more details about the entry in the next few weeks.

Posted in Blogroll, Breakpoint, Programming, Teenage Mutant Ninja Puppets | 5 Comments »

Programming: ezTunnel SSH – Port Forwarding Made Easy

Posted by llemarie on November 25, 2007

Update: Windows and Linux binaries, as well as open-source code under GPL are available here.

The freeware “ezTunnel SSH” is a GUI application for Windows and Linux that makes it easy to manage multiple SSH tunnels in the background. The interface is simple: creating a tunnel takes a few seconds, connecting to an existing tunnel is instant!

“Why would I want to do that?” you might ask… To make a secure connection to your home or to your office of course! If you wanted to control your home computer via Remote Desktop from work for example, you certainly don’t want to open port 3389 on your home firewall! Instead you set-up an SSH server at home (with a Linux box, or using cygwin under Windows, it’s easy either way) then you “tunnel” your connection via the port 22 (default for SSH) and you don’t have to open any other ports on your firewall. With one SSH server on your home network, you can access any computer on your network simply by creating a tunnel to it.

Now imagine you want to securely control your home PC from anywhere in the world, stream your home MP3s (using Jinzora, it’s brilliant), occasionally connect to a secure server at work, punch a hole through a local firewall administrated by somebody else, etc… That will take a few tunnels to set-up. No worries: with ezTunnel SSH it only take minutes and it all sits in one icon in the system tray.

Simply put, a tunnel works this way:

  • Tell it where the SSH server is (this is your home address, probably a static IP from your ISP or a dyndns address).
  • Tell it which computer you want to access on your home network (this is the internal IP, probably 192.168.0… ).
  • Specify the remote port (for remote desktop that’s 3389, for a web server it’s 80, etc…).
  • Choose a local port (that’s your choice, I tend to use ports in the 5000-6000 range).
  • Start the tunnel and connect to “localhost:5000” (if you chose 5000 as the local port).

That’s it, now you can access all your home computers from anywhere completely securely!

Get “ezTunnelSSH” for free here.

Posted in Blogroll, Programming | Tagged: | 8 Comments »

Programming: Updated Teenage Mutant Ninja Puppets

Posted by llemarie on November 11, 2007

I’ve received a few requests to post the full version of Teenage Mutant Ninja Puppets as shown in the YouTube video I posted a few months ago.

This version has the high resolution textures and character position editor enabled.

Update: Network support now works and the editor can save the current pose of the ghost (the pale guy) by pressing ‘R’ on the keyboard, then during the game you can use the pose by pressing ‘T’.

Download it free here (5MiB).

Screenshots on flickr.

Posted in Blogroll, Programming, Teenage Mutant Ninja Puppets | Tagged: , | 56 Comments »

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 »

Programming: Teenage Mutant Ninja Puppets

Posted by llemarie on August 31, 2007

This is a little physics game that I presented at Breakpoint 2007 at Easter. It’s a 96KB executable for Windows.

I had originally designed it for PLAYSTATION®3 and had no intentions to enter at it a demo party, but some friends of mine convinced me to reduce the size from >3.5MB to the required 96KB. Needless to say some features had to go. The nice 2kx2k texture for the font: gone. The detailed texture for the curtains: vanished. The multiple layers of backgrounds larger than the screen: history. Ah well.
So it features:

  1. My own physics engine based on the Verlet integrator.
    1. Characters have no predefined animation, you move the head and the movements of the body are procedurally generated accordingly.
    2. The characters have a skeleton made off springs. Hard springs link make up the bones, soft springs link parts like the hands to the feet.
    3. Collisions generate slow-motion and motion-blur, matrix-style. Cheesy, but I like it (:
    4. Cloth animation for the curtain.
  2. Weapons: Whip, chains, stick, nunchucks, sword (buggy, looks like a screwdriver).
  3. Cell-shading, reflections, shadows, pows – all fake.
  4. A.I. Easy to hard, where hard is *hard*. Kicks your ass.
  5. Big boss. Literally. It’s twice your size.
  6. Story mode.
    1. You start off as a regular Jo and you gotta save the girl.
    2. As you progress through the levels, you get more enemies at once and they get tougher.
    3. Then you fight ninjas, and when you beat them, you become a ninja!
    4. Then comes the big boss.
    5. There’s also a custom mode where you choose the number of human players, CPUs, bosses, weapons, etc…
  7. Poor sound effects, music *
  8. Keyboard or analog stick controls.
  9. Network support, up to 32 players *
  10. Menu, mapped on the faces of a cube. It’s simple, but effective, I would do it again.
  11. More that I forget, I spent months on it.

Features marked with the * had to be removed from the build to fit in the 96KB version.
Get it from pouet.net. (There’s a better video of it there too).

Updated: I posted the big version here.

See the video after the jump.

Read the rest of this entry »

Posted in Programming, Teenage Mutant Ninja Puppets | 12 Comments »