Porting Quake to the iPod Classic
fwei.tk
fwei.tk
The original video demo has been taken down by the author (not me) due to some concerns of his, but he is reportedly planning to reshoot it soon.
In the meantime, though, a Duke3D demo (running on the same software stack) is available here: https://www.youtube.com/watch?v=OV8etSGH86M
EDIT: I've gotten a quick recording up: https://www.youtube.com/watch?v=r6V-4AZ7pkA (apologies for the mirrored video)
> I spent at least a day rooting out this bug,"
---
For a days work I'd say he did pretty good!
Resolving that bug took quite a bit of serendipity. The break came when I was on the verge of giving up on the assembly rewrite and reverting back to C. I'd left my "frozen" iPod sitting around for a while. ~15 minutes later, I came back, and everything was back to normal -- this was evidence that I was not seeing a true lockup, but rather an extremely long delay (consistent with an integer wraparound).
There are virtually no good ways to debug code on-device with Rockbox, short of adding in a bunch of function calls to print variable values to the device's screen. This usual method, though slow, works surprisingly well with most bugs -- but this assumes that the code is in a sane enough state to be able to write to the screen properly (stack corruption, for example, would render it unusable).
There were a few bugs which were not debuggable with this "trace all the things" method, and those were the ones which required the most ingenuity. I remember having to root out a few bugs which absolutely trashed the processor state and made complex things (like function calls to print things) fail miserably.
One such class of bug was the unaligned read (this is ARM, remember). Thankfully, ARM has a way to set an "alignment trap" to trigger an interrupt when an invalid unaligned read happens. The only problem was that, of course, I couldn't figure out what code was responsible for the unaligned read.
My solution to this was quite the gem -- I modified the ARM exception handler to use the iPod's internal piezo buzzer to beep out the faulting PC address in a sequence of 32 high/low pitched beeps. The piezo, driven by a single memory-mapped register, could be controlled with minimal code (and most importantly, no function calls).
This is why I miss working with C in embedded.
Rockbox is a really, really cool project, and it's unfortunate that the age of MP3 players is basically over. I guess the spirit sort of lives on in the Android ecosystem but there was something so incredible about getting half of the functionality on a device a tenth as powerful.
I feel like the true successor to that ecosystem is the Chinese "emulation portables" market. I have a BittBoy (PocketGo), and it's a perfect "hobbyist homebrew" platform; it's got a nice screen, takes SDXC cards, and has "enough" RAM to have a pixel-addressable framebuffer; but otherwise it's just slightly more powerful than a Nintendo DS, and that "enough" RAM is still only 32MB (and it's probably taking up some of that memory running Linux, unless you've compiled your own unikernel for it.) So it's not like you can get away with un-optimized code.
I think what lwb means is how cool it is to get something running on a device you're technically not supposed to do that to.
I really enjoyed that little diversion too, wonderful project. Just enough detail in the article that you get a nice little taste of the complexity without getting lost in the detail. Bravo all round.
That video was recorded by another developer, who had some personal (non-legal) concerns with it and plans to reshoot.
Hope we can see a vid of Quake on iPod soon!
The devs on those teams really pushed that little MP3 player to do things it was never intended to do.
I run Nethack and Doom among more powerful games on the Zipit Z2. 32MB, ARMv5, too.