Legally Getting and Running X-Com UFO Defense on OS X

I've been reading a bit about the upcoming Firaxis XCom update and I've been getting a hankering to play the original X-Com. Well, I played it on the Playstation 1, I don't know if I have the disc anymore and even if I do, that's going to be annoying. I had a mouse for the original PS1, but who knows where that is, and who knows if I can even connect it to my PS3. I don't think I've got anything to connect a PS1/PS2 controller to my the PS3. (I know I did have a gizmo for moving Memory Cards over but I don't recall if it had a controller port.) And even if I got a mouse to work somehow … I don't want to play it in my living room with a mouse on the coffee table.

Anyway, a big hat tip here to my friend Tony who had mentioned to me at some point in the past that if you buy X-Com on Steam that it just ships inside an open source project called DOSBox. And you can download a version of DOSBox for OS X. So this morning while I was watching the Apple liveblogs I did all this. It works, but there are a few tweaks I had to make to make things convenient. Here's what you do.

  1. Buy X-Com on Steam. You can get the first game for $5 or a whole bunch of them for $15. I don't know if you can actually do this from the Mac Steam client, I did it in a Windows 7 virtual machine.
  2. Install DOSBox. Download it, and then put DOSBox.app in your Applications folder.
  3. Copy the files from Windows to somewhere useful on your Mac. I made a DOSBox folder in my Documents, but wherever works for you. Assuming your Steam is working in the default place you want to copy the folder C:\Program Files\Steam\Steamapps\common\XCom UFO Defense.
  4. When you get into DOS that long file name is going to be a pain. I renamed the folder to just XCom – so I have ~/Documents/DOSBox/XCom.
  5. At this point you could just run DOSBox manually, mount the folder, and run the stuff, but there's a better way and that involves a dosbox.conf file. The folder already contains one but you need to pass that to dosbox, and that's a pain as well. Here's the whole command that I use:
    /Applications/DOSBox.app/contents/macos/dosbox -conf /Users/tsanders/Documents/DOSBox/XCom/dosbox.conf
  6. This file didn't completely work for me. There was something not right about fullscreen mode but I didn't want the app in fullscreen on my 27" monitor anyway. The conf file also defaults to a 2x interpolation and I wanted to use the 3x. Lastly the volume was way too loud for me. So here's a list of changes I made:
    • Comment out fullscreen=true (so #fullscreen=true)
    • Change scaler=advinterp2x to scaler=advinterp3x
    • At the bottom in the [autoexec] section change the mount command to the proper path. Mine is mount c /Users/tsanders/Documents/DOSBox/XCom -freesize 1024
    • Add the line "mixer master 25:25" to set the volume levels 25% of maximum
  7. OK, so far so good but that command line is a pain in the rear to enter. That's easy to fix! Run Automator, select the Application type, then in Utilities pick a "Run Shell Script" action. Paste the command over the line that says "cat". You probably don't want Automator to wait for the command to complete, so be sure to add " &" at the end of the line.
    /Applications/DOSBox.app/contents/macos/dosbox -conf /Users/tsanders/Documents/DOSBox/XCom/dosbox.conf &
  8. Save the resulting Automator action in your Applications folder and you're done!
  9. Optional bonus step: Go to images.google.com and get a nice icon image - I just looked for "x-com ufo defense box". Find the app you made in the last step, select it in the Finder and hit cmd-I. In the info window that comes up you can select the icon (it should be the little Automator robot) and just paste an image from the clipboard.

At this point you have an icon in Finder you can double-click, or something you can launch from Spotlight. No more opening Terminal, navigating to the proper directory, or remembering the syntax of the DOSBox commands. Pretty cool.

In theory this ought to work for a large number of DOS games. Of course, the devil is really in figuring out the proper settings for that DOSBox config file. That's where the cool part is that the Steam file is already mostly correctly configured. (I didn't chase the fullscreen problem but I suspect it's related to having two monitors, it might work fine with a single monitor.)

Edited to add March 7, 2012 10:21 PM:When I was working on this I had Automator open and I didn't notice this but the first version of the Automator app continued to run until I quit the game, resulting in a turning gear icon in the menubar. The fix is simple: just put the command line into the background with a simple & at the end. I adjusted step 7 to reflect this.

Oh no you didn't VoiceOver

OK, let's say you're making an iOS app. And it's new so you go to use storyboards because they are awesome and you can target iOS 5.x. Swell. And you're going to use UITableViews and storyboards have that hot new prototype thing where you can lay out your cell right there in the UITableView and you're guaranteed you'll always get a cell from dequeueReusableCellWithIdentifier. Awesome! Well not so fast partner. Go read this Radar and this Radar. Yeah, that sucks. Short version is that works fantastically unless your user has turned on VoiceOver, at which point you don't get a cell at all. The stub code Xcode generates at that point will create a generic UITableViewCell with none of your custom layout. If you're lucky you'll get a blank cell. If you're unlucky your code assumed it got a custom cell type and crashes on some property access or method call. So what do you need to do? You have to old school it and just ignore the new layout feature. You can't require your users to turn off VoiceOver, that's not reasonable. You can leave the prototypes in and they will work in the VoiceOver off case but as far as I can tell there is no way to load a prototype cell from a storyboard. I suspect that you might just be able to rummage around in the nib and find a prototype but I don't see a proper way to do that. In the VoiceOver case you have to provide code that will load a cell from a nib file. You can leave the prototype cells in and that will work in the non-VoiceOver case but now you've got two cell prototypes and that's a bad idea. I do recommend leaving the call to dequeueReusableCellWithIdentifier in place though. Even with VoiceOver on the table can recycle old cells so if you do all of the cell identifier stuff then after a while your view can get a working set of cells that it just reuses on a scroll. Here's a code snippet that rolls this all up. It's not revolutionary but it gets the job done.
TripTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
// That call is supposed to always work, but it doesn't if the user has VoiceOver on. If they do, we'll engage le hack below
if (cell == nil) {
[[NSBundle mainBundle] loadNibNamed:@"TripTableViewCell" owner:self options:nil];
// The above will load our blankCell field with a new TripTableViewCell.
cell = blankCell;

With this code you make a nib that contains your custom cell. Then in the view controller you make an IBOutlet like so:
@property (nonatomic, retain) IBOutlet TripTableViewCell* blankCell;
In the nib you set the File's Owner to the controller and connect blankCell to the cell. Like I said, nothing shocking here just some old-school-ness in the new storyboard world …

iOS Beta Testers Wanted!

I'm putting the last few VoiceOver accessibility labels in my iOS app (RoadTrip) and then it's basically done. I want to take a stab at putting some custom textures in and I'm sure I'll find some new bugs once I turn off VoiceOver and go back to the iPad version but the end of the project is visible from here. If I know you in real life, you have a iOS 5.0 device available, and you're willing to do some beta testing for me I'd appreciate it. Get in touch with me! I'm hoping to release a beta version by the weekend.

Blog–ruptcy!

Oh yeah, this thing. Here's the ridiculous thing. I've been meaning to write a whole mess of posts. And in fact it had reached a logjam of stuff. I was paralyzed on writing any given post because I knew there were so many to write. So then I decided I was going to declare "blog bankruptcy" and just write one post touching briefly on all of the topics. The thing is that I decided that in early December and I've had a task sitting in Omnifocus about it for over two months. In that time frame even more shit has transpired that needed to be in the post. In short, it wasn't going to happen. So here we are. Here's what I'm going to do. I'm going to dump a list of interesting things, no more than a couple of sentences on each. Once it's all here maybe it will free me up to write more on particular topics. Feel free to jab me if any of these catch your eye and you want to hear more.
  1. We got a new TV! We replaced the old set with a projector and an 84" retractable screen. It's pretty sweet!
  2. While doing all of the projector install and wiring I put my foot through the hall ceiling, so we had a big hole for several weeks. This was less sweet.
  3. Back in October Schrödinger got really sick and we had to take her to the Cat Hospital. Turns out she's having renal (kidney) failure and was super-dehydrated. They had to keep her there on an IV for five days, one of which we couldn't visit her at all. That super-sucked and now I have to administer fluids subcutaneously to her daily. (Translation: I have to stick a needle under her skin and give 100 mL of lactated ringer's fluid.) She's doing fine now and she's got a special diet that helps her along.
  4. Not to be outdone Heisenberg had some sort of hypoglycemic shock in January. I came in and found him passed out on the floor with his face in his food plate. He couldn't stand and when I checked his blood sugar it was drastically low. He only had to stand overnight in the hospital but we're still adjusting his insulin trying to find the right balance. He seems OK for now, so we'll see what happens.
  5. Since my last post talked about iTunes Music Match I should probably mention that I turned it on since then on my iPhone and it works well. I find that I can't stream music from the internet down to my phone and then wirelessly to the Airport Express but that's a pretty edge case. It is pretty cool to be able to search my entire music library from my phone. Macworld has a useful article describing how to upgrade crappier audio files after using Music Match. It worked for me and upgraded 4,788 tracks so that's awesome. I did notice one example later where my "explicit" CD rip had been replaced with a "clean" radio edit so keep an eye out for that.
  6. I got Skyrim for Christmas. Probably my vote for best game of 2011. So good!
  7. I also got Super Mario 3D Land for the 3DS. It's a lot of fun, but the last few worlds get ridiculously difficult. At one point I was up to well over 100 lives but I'm on the last 2-3 worlds now and I've gotten down to a bit over 25.
  8. Playing the 3DS again really drives home the odd conflict in Nintendo's hardware these days. I like the 3DS and the 3D effect does make some sections of Super Mario easier, but I've also died many times because I move my head or arm and lose the sweet spot mid-action sequence. It's weird that over with the Wii they've made this big push towards getting non-games, this "blue ocean" strategy and then their handheld is so weirdly finicky as to require serious training in how to use it.
So there you go! Hopefully this will clear the decks and I'll resume posting. I have some pictures of the projector install and ceiling repair that I intend to post at the very least.

iOS 5.0 Recommendations

I just wrote an email to my immediate family laying out my thoughts about iOS 5.0 and what they should do about upgrading and using iCloud and the like. I realized as I sent it that it might be interesting to more people so I'm going to post it here. It's worth noting a few things about the perspective. I've been running iOS 5.0 on an iPhone 3GS and WiFi iPad 2 for a bit over a month and on a fourth generation iPod Touch since June (although I don't do anything other than software debugging on the touch). So I don't have any experience with 5.0 on an iPhone 4. I suspect it's fine but I haven't tried it personally. I've been running the gold master for the week it has been available. The folks I was sending the email to have a WiFi iPad 1 and a 3GS.

Anyway, here's what I wrote:

1) You'll need iTunes 10.5. I suspect iTunes will ask about upgrading sometime today. That should be fine but be aware it will take a little time so don't do it if you're in a hurry.

2 ) The next time you sync your iPad or iPhone to the computer after the iTunes update it's likely to ask you if you want to upgrade. If you do be prepared: it will take a while to update and restore. My phone (which has more files on it than my iPad) takes about an hour to restore after a system upgrade. It's all pretty seamless but it takes a while because iTunes first backs up the phone, then downloads the system update, then wipes the device, then installs the update, then puts all of your files back from that backup.

3 ) I haven't run iOS 5.0 on an iPad 1, but I suspect it's a fine thing to install. I still would not recommend installing iOS 5.0 on a 3GS phone. I've been running the "Gold Master" released version for a week and it's faster than the betas were but the phone is still very sluggish compared to how it was on 4.3. I still feel playing real-time games on the 3GS is ugly with the quasi-random freezes. Also be aware if you install 5.0 it may be difficult or impossible to go back to 4.3 (the new version usually updates the cellular baseband firmware in ways incompatible with earlier OSes, so to roll back you have to do tricky re-flashing of very low-level chips.) I ordered a new iPhone 4S that I'm getting on Friday, but the only thing that's made running 5.0 on my 3GS acceptable was knowing it was a short-term solution. If they follow the pattern you may find that the inevitable 5.1 works better on a 3GS than 5.0 does. I would suggest waiting at least a week or two and see what shakes out with the 3GS/5.0 situation. And you have to be careful with that because iTunes will encourage you to upgrade. If you just click things without reading you'll get an upgrade.

4 ) iOS 5.0 has iCloud for file storage and you can use iTunes Music Match to stream your music library from online storage. Music Match costs $25/year. This is going to be really cool, but I'd advise staying away from both features for a while. I've tried Music Match on my iPad and it makes a real mess out of things. I told it this morning to download all of my Talking Heads music (I have ~150 tracks from Talking Heads) and my iPad started well over 400 downloads. No idea what it's doing, but it's taking quite a while. Apple cloud things tend to get overwhelmed in the first few days after launch so I'd suggest keeping all of your contacts, calendars, and data files exactly where they are for the first couple of weeks. I turned on Music Match on my iPad because most of the time I listen to my phone - which I'm still syncing manually right now. I have some files on iCloud for testing but only stuff that has multiple backups.

5 ) Having said all of that, turning on the "Sync over WiFi" option in iTunes is pretty awesome. With that your iOS device will sync (and backup!) whenever you plug it into the charger if iTunes is running on the machine you use to connect. None of that uses iCloud in any way - it's just your device and your computer talking over the local network. I recommend turning that on as soon as you can. I've been using that for months now - but I still haven't turned on backing up to iCloud because I trust THAT a lot less.