XChip-8
This is a simple virtual machine for Chip-8 machine language. It runs on most *nix systems with X.
I'm developing this program only in my free time, so don't expect it to be perfect.
Features
- Motion blur. This makes the graphics look "smoother" and more natural for fast-moving objects.
- Resizable window. The window maintains its aspect ratio of 2:1 (width:height) when it's resized.
- Low processor usage. The virtual machine shows hardly any CPU usage in "top" (process monitor in *nix).
- Free software. I licensed this program under the GNU General Public License for anyone to inspect the source and possibly improve it.
News
- 2006-12-20: Updated XChip-8
- Cleaned up timing code
- Frame rate and instruction rate now are settable on the command line
- Added stub support for sound
- Titlebar says "[paused]" when the VM is paused
- 2006-11-04: Updated XChip-8!
- Reduced network usage.
- Sets the standard X Window Manager properties, such as the application class and name. This shows up in the KDE or GNOME task bar when xchip8 is run multiple times.
- Cleaned up the screen refreshing code. Screen re-draws only where it receives an Expose event.
- Clears memory when the virtual machine is reset.
- Compiles cleanly on at least GNU/Linux and SunOS 5.9. Also compiles in Cygwin if the "-lX11" is moved to the end of the linking phase in the Makefile.
Screenshots
Here are some screenshots of XChip-8:

Tetris. Notice the motion blur on the falling piece.

Missile.

Pong!

Tic-Tac-Toe.

Space Invaders.
Compiling and running
In order to run the program, you must first compile it. First extract the archive, then at a command prompt, type 'make'. If it compiles without errors, run it as './xchip8 program', where program is the filename of the Chip-8 program.
You can find many Chip-8 programs on-line. Some places to look are The CHIP-8 Emulator HomePage and http://www.pdc.kth.se/~lfo/chip8/CHIP8/GAMES/
Keys
The Chip-8 uses a 4x4 keypad, so I chose to use the following keys on a modern keyboard (this is subject to change in future versions):
| 7 |
8 |
9 |
0 |
| u |
i |
o |
p |
| j |
k |
l |
; |
| m |
, |
. |
/ |
I also mapped the following keys to extra functions:
| Key |
Function |
| q |
Quit |
| r |
Reset virtual machine |
| Space |
Pause the virtual machine |
| Tab |
Take a screenshot in the current directory |
Both upper- and lower-case letters work for all of the keys.
Limitations
Here are some limitations of the current version of XChip-8:
- It does not play any sound.
- Only the basic Chip-8 instructions are implemented; none of the extended Super Chip-8 instructions are understood, much less executed.
- Sprite wrap-around: I can't find any definitive answers on whether sprites actually wrap around the screen or not. Some games (e.g., Blitz) don't work well with wrap-around, while others (e.g., Syzygy) don't work well without wrap-around, or at least they doesn't seem to work how I think they ought to work.
To Do
Here's a list of items for improving XChip-8:
Move the instruction decoding/execution code from the main function to its own function.
- Improve the key-handling code to reduce polling of the X server. I'm fairly new to X programming, so I need to read more on how it works.
- Add sound, using at least XBell.
- Add command-line switches and/or configuration file to control
framerate, execution speed, key maps, debugging/disassembling, etc.
- Add support for Super Chip-8 instructions.
- Split the growing xchip8.c file into separate module files.
Download
Here is the complete source code in one download: xchip8.tgz.
License
XChip-8 is Copyright 2006 Christopher Williams.
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.