I’m Old, Part XXIII: Hardware is Software

When I was in high school, I played a ton of arcade video games. There was a sub shop on the way home from school that had a set of games that changed now and again. In the time that I played there, I spent a lot of my money on Asteroids, Rip Off, Moon Cresta, and Defender. There were other games, but nothing I recall so well.

galaxian

When I was in college, I was home on break and went to a local arcade that was clearly in not good shape and offered them cash for an Asteroids machine they had in the basement. It was unplugged and apparently not working. I loaded it into the back of my folk’s Dodge Omni and drove home with it half in, half out. The car could clearly barely handle the extra load as it felt like I was driving up hill. It took a little work, but it was easy to fix up.

The machine followed me to California via my dad and I eventually moved it into my cube at Adobe on a weekend. People came by now and again to play. I also started to collect old video game circuit boards and got them running into a Radio Shack CoCo monitor I picked up at a tent sale for $10.

At the time, I was working on the Macintosh full-text search engine for Acrobat. We licensed and engine from a company that was a few blocks away. They clearly put a lot of effort into their Windows and Unix products, but not so much in their Mac products. Their Mac releases were frequently behind, buggy, and slow. I would run their software, pass in the license key and watch it crash. It was like they didn’t actually test their Init function on the Mac. Many times, in frustration, I would start disassembling their code to find out what was going on.

One of the problems we had, which bit us more than once, was that their code was compiled with the Apple C compiler and we used Think C. Although they should have been compatible, they often weren’t and the code wasn’t always as portable as it should be.

The API relied on large structs passed in. Each struct had to have a field set in it that was equal to the size of the struct. If the size passed in didn’t match what they expected, they failed.

In at least one structure, they embedded an enum like this:

enum Flags {

    One = 0x1, Two = 0x2, Three = 0x4, Four = 0x8,

    Five = 0x10, Six = 0x20, Seven = 0x40, Eight = 0x80

};

Quiz question: what is sizeof(Flags)?

If you look at the C spec, the answer it that it depends. In the guidelines, they suggest that you use the smallest integral type that can represent all the values. One compiler decided that a byte was good enough because it could hold everything. Another decided that since the value of Eight hit the sign bit of a byte, that they would use a word instead.

Whenever this kind of crap happened, I’d end up tracking down the problem in the disassembly of their code and then relay it back to my contact and then wait for a fix. And wait. And wait. I mean, I couldn’t do anything if I couldn’t successfully make the init call. What a pain.

During this time, I had picked up a game board for an oddball game called “War of the Bugs”. It was a terrible Centipede clone that was running on slightly modified Galaxian hardware. I got that running in my cube and started getting curious as to how they had achieved this. For one, Galaxian had a star field that scrolled in the background that was done in hardware. I grabbed some schematics and found that the stars could get turned on and off by flipping a bit. I found the trace from the address decoding that went to the star enable/disable and found that it had been cut. I bridged it with a paper clip and now I had War of the Bugs with stars! I kept digging at the schematics and looking at how the stars worked and as I went through it, it appeared that they had implemented a maximal linear feedback shift register and were using it at intervals to make the stars. It was ingenious, really. And the more I looked at it, the more I realized that this little chunk of hardware was really software in gates. It was elegant, really. It was as if the entirety of the star field had been expressed in haiku.

Meantime, my boss, Ken Anderson, had observed that I was not making progress (how could I? their code crashed and I reported it with an easy repro case, so I was spending my time poring over schematics). He ended up calling bosses bosses at the search engine company to find out WTF was taking them so long. I felt bad when I heard him on the phone chewing out a person at the search engine company saying, “My Mac engineer is sitting here dissecting video games because your code doesn’t work.”

Many times, we took walks over to their building to pick up another turn of code and hope for the best.

Eventually, we did get code that worked well enough to ship, but it wasn’t always easy, but that’s a story for another day.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.