Sunday, November 16, 2014

Can't Fake the Funk

I'm a bit of a sucker for puzzle games like sokoban, especially when they play the oldschool chiptunes for background music.  So a long time ago when my kids went through school and they had some fancy TI graphing calculators, I thought maybe I'd eventually inherit one and hack it to play some silly puzzle games like blockdude.  But, kids being kids, they either lost or broke the darn things and I forgot about it.

Time passed, and then a year or so ago I'd just finished patching up a zipitized build of the Funktracker Gold music tracker (and mod file player) when I spotted a gp2x version of blockdude.  I tweaked the keyboard settings and compiled it for the zipit but couldn't quite get the bleeping sound to work.  My blog post at the time had the title "Game Sounds" so providing blockdude without sound was never gonna fly.  Worse yet, I could not even solve the first level.  Embarrassing!
So I moved on and built some silent console games instead.  I don't think I've passed the first or second level on any of those either (I sense a trend here...) but at least everything seems to work.

Recently I was thinking about fixed point math again, which led me to discover the ancient gp2x version of SDL includes a really nice fixed point math module, with arm assembler code.  Nice.  That in turn led me to some opengl implementations which also incorporate the fixed point module.  I absolutely must explore that some day, but meanwhile it got me thinking again about chiptunes, mod trackers, and eventually my problems with blockdude.

This time I realized the first sound blockdude plays is from a mod file with the title soundtrack.  I remembered that I'd done a quick and dirty build of libmikmod, way, way back when I was trying to compile sdlbasic.  At the time, I only needed libmikmod because it was required to build the SDL_mixer library.  But I didn't have any mod files handy to test it, so I simply used the default config to fake it, and then promptly forgot about it.

So now I did some testing with blockdude and the SDL_mixer playmus utility and discovered that not only did my build of libmikmod refuse to make a peep, it also locked up the sound driver so that nothing else could use it either.  Not good.  So I fetched the latest libmikmod-3.1.18 bugfix release code and applied the config settings from the zipit openwrt makefile.  With the new libmikmod installed, playmus and blockdude could crank out the cheezy chiptunes in all their funky low-fi glory on my zipit.  I'm still stuck in level 1 though...

Here's the goodies.

libmikmod-3.1.18-iz2s.zip  (also includes the playmus utility from SDL_mixer)

blockdude-iz2s.zip

Update:

Made it to level 2.  I feel much smarter now.