Pacman in C99 that runs in the browser

PacmanSuch a simple game yet still incredibly popular. Pacman is now 40 years old. I must confess, its not one that I was great at (that would be Battle Zone- the 3D wireframe tanks on the moon game- I could play that for an hour for just 10p),

This cross-platform implementation by German programmer Andre Weissflog (aka Flooh) looks spot on and plays it as well. Most of the game has been implemented in one C source file and its definitely worth reading the comments at the top of that file to see how things are done.

For instance “audio output works through an actual Namco WSG emulator which generates sound samples for 3 hardware voices from a 20-bit frequency counter,¬† 4-bit volume and 3-bit wave type (for 8 wavetables made of 32 sample values each stored in a ROM dump)”.

The game uses the author’s Sokol libraries which are Simple¬†STB-style cross-platform libraries for C and C++, written in C. It’s the first time I'[d come across these and they’re worthy of a separate look at. STB is a another library that I’ll also look at in the future. I’ve added a link to this Pacman to the C Code library. Happy Christmas!

PS. Also included in the GitHub download is The Pac-man dossier by Jamey Pittman, which is a 48 page PDF and tells you everything about playing Pacman. Stuff like the logic of gameplay, mechanics, easter eggs and the hardware specs of the original game boards not to mention the infamous level 255 overflow.

Interestingly the original hardware was a 3MHZ Z80A with 2 KB of RAM and 16KB of ROM on a 224 x 288 16 colour screen .