
“Volume control” is a single bullet point in the feature list for the upcoming Boxer 1.2.3, but I thought it would be interesting (read “validating”) to give a behind-the-scenes tour of what actually goes into a simple feature like this.
First things first is deciding the scope of the feature. I chose early on to make the volume control apply application-wide to every game, rather than tracking it for each individual game, so that its behaviour would be consistent and predictable. The use case I targeted was one I faced daily: muting Boxer to listen to other music or videos in the background.
I chose not to target a more sophisticated use case: tweaking the volume of a specific game, such as one with annoying beeper-speaker effects or really loud MIDI music. I felt this was too complex for a single volume control.
Instead I made plans to add a separate mixer panel later, which would let you tweak the volume of each individual “channel”: PC speaker, digital audio, MIDI and CD audio and so on. The volumes you’ve set for individual channels would be remembered for each game, and scaled by the application’s master volume. But that will have to wait for a future release.
Now I'm ready to start on the physical volume control UI that the user manipulates.
I decided to add a slider to the DOS window's status bar, so it would be obvious and immediately accessible. I made the speaker icons at either end of the slider minimize/maximize the volume when clicked, like they do in iTunes. (And because the volume control is sharing space with the “Click to lock the mouse” help text, I also had to make sure the latter is hidden at small window sizes so they won’t overlap.)

But wait: OS X’s standard slider widget was designed for pale backgrounds, and looks dumb against the darker status bar area. We need a custom slider widget that’s restyled to fit. Good thing I had some custom widget code already for the Inspector panel sliders; unfortunately it needed a lot of rework before it was suitable.

Wait, what if the user is in fullscreen or has the status bar hidden? They won’t be able to access the control. So I added a “Sound” menu containing its own slider, which can be accessed from anywhere. The menu also lets me expose keyboard shortcuts with which the user can nudge the volume up or down.

Because the user can nudge the volume with those shortcuts while no volume slider is visible, we need some way to give them feedback that something has happened. Time for a new notification bezel! (Though we should only show the bezel if the volume slider isn't already visible, otherwise it’s redundant: so check for that too.)
I wanted the bezel to show a speaker that changes according to the current volume, so I snapped screenshots of OS X's menubar volume icon in each of its states and recreated them as vector versions in Photoshop.

So now the UI for our volume control is pretty much ready, but it doesn't actually do anything yet. Time to hit the emulation layer.
First, we need to control the volume of the DOSBox mixer: this component mixes together all of the audio produced by the emulated PC speaker, Sound Blaster etc. This means injecting some more code into DOSBox so that Boxer can dictate the master volume.
But General MIDI output doesn’t pass through the DOSBox mixer: it goes straight to OS X’s CoreAudio MIDI synth. Time to dust off my CoreAudio documentation and figure out how to manipulate the volume on audio units.
If we’re sending MIDI music to a real MIDI device, like an MT-32 plugged into your Mac, this uses a different system again: we need to send actual MIDI commands to the device to change its own master volume. Time to dust off the General MIDI spec. (Of course MT-32s don’t respond to General MIDI volume commands, so we need to send a different message to those instead: time to dust off the MT-32 spec too!)
Because MIDI is a low-bandwidth realtime medium, we need to take care not to spam a real MIDI device with tiny volume changes that would crowd out other MIDI messages. This means coalescing volume updates and sending them at certain intervals, once the device isn’t otherwise busy.
Another wrinkle: many MT-32-compatible DOS games send their own MIDI commands to set the master volume. If we let those go through to the external MIDI device they’ll override our own volume: so we need to detect and intercept those commands, and scale them by our own volume before sending them on their way.
And one final snag: Audio tracks from physical CDs are played back through yet another system, a decrepit and awful SDL API, whose playback volume is beyond the reach of Boxer altogether. I decided this was a bridge too far for this release, since Boxer usually rips CD audio anyway to play back in a manner it can control.
Instead, I swore a dark and solemn oath to rewrite the DOSBox audio architecture for Boxer 1.3: to remove the lingering dependencies on SDL and to unify the disparate outputs under my own roof.
So that’s what goes into a simple application volume control. This is something of an extreme case: some simple features really are trivial to implement, and most don’t have to cover quite so many bases. But they do usually involve a lot of unexpected edge-cases and layers of complexity hidden beneath the surface.
Judging from the discussion upon Boxer’s future post-1.0, passions run pretty high about the Mac App Store. This was originally a comment there, but I’m expanding it into a post of its own, as I want everyone’s thoughts upon it.
App Store skeptics: rest assured that I’m none too taken with the MAS either, and it doesn’t make my life as a developer any easier. The only reason I would stop distributing Boxer separately is if/when it gets simply too hard for me to maintain two separate distributions, and I plan to stick that out as long as possible.
However: the App Store’s not going anywhere, and it will eventually become the only port-of-call for most Mac users looking to find quality software. If Boxer is to be rescued from obscurity, then it needs to be available there sooner or later, however else it continues to be available.
Moreover, most of the restrictions Apple have placed on the behaviour of apps in the App Store make sense and are beneficial to the health of the OS. Private API usage is simply A Bad Idea; centralised application updates are A Good Idea (awkward though this currently is through the MAS); and fostering an overt concern over the physical arrangement of files on one's hard disk is an anachronism that belongs back in the 90s.
To recap, Apple’s app store guidelines mandate that applications keep their supporting folders in ~/Library/Application Support/, and never create folders within the system’s folder space (Home, Documents, Applications etc.) without asking first. Currently Boxer’s default DOS Games folder location is ~/DOS Games/, which would have to change.
I fully recognise the usefulness of choosing the location of this folder—e.g. to be on an external disk or a Dropbox folder—and Boxer will continue to support this. But, it would be saner and safer for Boxer to default to a suitable Apple-friendly location automatically, and let you migrate it afterwards, rather than demanding up-front where and how you want to organise your collection. It’s worth noting that the only real reason Boxer does so now is to draw attention to the sample games it has given you.
One instance came to light post-1.0 of a user choosing their Documents folder itself as the game storage location, and Boxer overriding its icon and appearance as a result. Choosing a system folder is now prevented in Boxer 1.0.1, but this demonstrates how risky and error-prone it can be, to give users the choice of where to put required folders whose contents are controlled by an application.
Boxer's long-term plan is to offer an in-app game browser to work alongside the Finder model. The browser would unify the welcome, import and games-folder UIs; allow you quicker access to recent games; and allow you to display your DOS games by metadata: genre, publisher, year etc.
This is quite clearly Apple’s preferred approach for apps that deal with document-like objects, and would render their physical location irrelevant: which would be a necessity if their actual location is buried deep within a library folder and beyond the reach of Finder. As a further complication, OS X 10.7 Lion hides the Library folders altogether from Finder, and can optionally sandbox an app’s files so they don’t even live there anymore. This, I have grave reservations about.
The rise of the App Store distribution model, and the push towards an iOS-style sandboxed approach to the filesystem, are going to see a lot of pushback from Mac developers and Mac users alike in the coming year. As someone who grew up with the old paradigms, I’m reluctant to change and can’t tell to what extent the new paradigms will actually improve and simplify the Mac desktop experience.
My concern is to make sure Boxer continues to work the way the Mac works; but without alienating users who prefer the way the Mac used to work. Above all, I don’t want to discard the old when embracing the new—except where the old really did suck.
So, what do you think?
In this week’s episode, the Inspector panel gets some more sweet hot lovin’. Download the new build here, and read more below.

Now that Boxer stores per-user-per-gamebox settings, we can have some much-needed tweaks for mouse behaviour:
A slider for mouse speed, to fix games that get it wrong and don’t let you adjust it in-game. This applies only while the mouse is locked: while unlocked, Boxer sticks to OS X’s mouse speed to keep the OS X and DOS cursors in sync.
A toggle to ignore the mouse until it’s locked. When enabled, the mouse does nothing until you click on the window, at which point it is automatically locked. (This is analogous to DOSBox’s original “autolock” mode.)
This latter setting is vital for games where moving the mouse also moves the game view: Boxer’s regular behaviour can be frustrating as hell, if the game goes spinning or scrolling off into oblivion while you reach for a menu.
I’ve been humming and hawing for some time over how to present the option. It’s clear that it’s necessary, but it may be worth going further and making it the default; or making it Boxer-wide instead of per-gamebox, like rendering settings; or making it per-gamebox instead of per-user, like CPU settings. Time will tell where it should best live.
For the moment though, I feel that Boxer’s regular mouse behaviour does a good job for most games; and I find I only want to change it for one or two that misbehave. So for me, it strikes the best balance to have it as a per-user-per-gamebox option that’s disabled by default.

I’ve been primping and preening it to within an inch of its life. Besides aesthetic improvements, I’ve put in buttons to add, eject and manipulate drives, making the panel’s functionality more obvious and accessible.
The biggest addition though is the ability to import drives into the gamebox straight from the Drives panel. This copies an entire volume or disc image into the gamebox, so it comes along for the ride and gets mounted whenever you play the game.
Of course, this is just like Boxer 0.8x used to do when installing games, and will be a key feature of Boxer 1.0’s upcoming game installer too. It’s not often that you’ll need to use it outside of game installation; but I want to ensure that anything you can do during installation, you can do afterwards too.
This will hopefully be the last alpha build before Boxer 1.0 goes beta. That will be a Boxer feature-complete and mere weeks away from a final release. After one-and-a-half years, the time is nigh.
There’s two core features left to (re)implement before then: game installation, and the DOS Games folder. I’ll be working furiously through August to get these ready, and I’m very excited for what we’ll have to play with at the end of it.
Today’s new build is all about gameboxes and game configuration:
This build also fixes a number of recent UI bugs in OS X 10.5 which had busted the program panel and drive list. There’s no reason not to be downloading the new build right now dammit.
These improvements were all blockers for 1.0 final, and are more pieces of the game-installation IKEA wall unit screwed firmly in place. While none of these features are very visible, they do pave the way for exciting new things in Boxer’s future.
Yup, gameboxes have been extended to add a new metadata file, Game Info.plist, which is stored in the gamebox’s root folder alongside DOSBox Preferences.conf.
In future Boxer versions, this file will store things like the game’s developer, publisher, year, genre, Mobygames page etc. This metadata would be used for Spotlight and Quicklook integration, and for a snazzy game manager UI I’ve been thinking about for a while.
For the moment however, this file only stores the game’s unique identifier.
Many long-planned Boxer features have needed a way to unambiguously identify gameboxes, in order to associate external data with them: data that cannot be stored inside the gamebox itself for whatever reason.
For this purpose, Boxer now creates and stores a “unique” identifier for each gamebox, by generating an SHA-1 hash out of every executable file inside it. I put “unique” in quotation marks, because this approach has the desirable effect that the hash will be the same each time it is generated, and the same for anyone in the world running that version of that game.
This latter fact is crucial for another long-planned Boxer feature: integration with an online game repository. The idea is a kind of CDDB for games: to let Boxer automatically retrieve user-submitted metadata and configurations for newly-minted gameboxes. More on this in a future blog post!
Boxer has had automatic game detection for most of its life, and it works by scanning the folder or gamebox you opened for files that match known games. This behaviour has been improved in this build to detect games outside of gameboxes once again, the same as Boxer 0.8x does.
Boxer has to be careful about how deep it scans for games, though. If you open a floppy disk, CD-ROM or gamebox then Boxer will scan the whole file heirarchy inside it, since it is known to be a manageable size. The rest of the time however, Boxer will only scan the base folder it is opening and will not search into any subfolders.
This is necessary to avoid massive slowdowns if you open (for example) your Home folder in Boxer. However, this does make Boxer less reliable at detecting games outside of gameboxes, since it may stop looking too early.
For historical reasons, Boxer 0.8x would save the autodetected configuration into the gamebox. Boxer 1.0 no longer does this: Boxer runs the auto-detection at every launch regardless, so it would be redundant to store it, and a stored configuration could get in the way of future corrections to the autodetected version. The gamebox configuration file is now meant solely for persisting a user’s own adjustments of the emulation settings.
When you adjust emulation settings from the CPU panel, Boxer works out what DOSBox configuration parameters would represent the changed settings and then writes those parameters back to the gamebox’s own configuration file.
Boxer now also compares against the parameters that are in the game’s auto-detected configuration file; if any are the same, they are stripped from the gamebox configuration file instead. This way, Boxer won’t store redundant settings.
Not all emulation settings are created equal of course. Some, like CPU speed and core optimization, concern the game itself and should apply to anyone playing it; these do belong in the gamebox configuration file. Others, like framerate or window size, are about your own Mac and your own personal preferences, and should only apply to you.
Such settings are not stored inside the gamebox configuration file anymore: instead, Boxer stores them inside its own application preferences, keyed to each gamebox by its unique identifier. This way, they don’t come along for the ride if you pass the gamebox on to someone else.
A new Boxer 1.0 alpha build is fresh out of the oven. Since this build has ended up focusing on UI refinement, a few gratuitous screenshots seemed in order:
Opening additional gameboxes or DOS windows will launch additional Boxer instances to handle them. More on this below.

Besides looking cleaner, the panel now highlights the default program and bumps it to the start of the list. It also slides away after clicking the default program, instead of hanging around taking up space.
button now enlarges the window to fit all the available space, instead of fitting it to a multiple of the DOS resolution.So what are you waiting for? Go grab it already.
A limitation which has dogged Boxer 1.0 from the very beginning is DOSBox’s one-shot nature. Because DOSBox is compiled into Boxer, Boxer’s memory is DOSBox’s memory; and DOSBox stores its emulation state in a vast hive of global variables, which it doesn’t bother cleaning up afterwards.
This prevents DOSBox from handling two emulation sessions at once — because each session clobbers the other one’s state — and from starting up a second emulation session after finishing the first — because the subsequent session inherits a hopelessly polluted state from the first one. Imagine a living room the morning after a student party.
This is of no concern to a hard-living Windows transplant like DOSBox, which was designed to quit as soon as the emulation exits. But it is of concern to a well-behaved native app like Boxer, which wants to stay open in the Dock, and to be able to open and reopen as many windows as it needs, just like all its other Mac chums.
Boxer was a sad panda. Until now.
Would be for Boxer to move the DOSBox emulator core to a separate child process with its own isolated memory space, and spawn instances of this emulator process for each window. This way DOSBox could shit in its own sandpit as much as it likes, it could run alongside other emulator processes without fear of cross-pollution, and it could be terminated or paused or restarted at will by the parent application (Boxer) without ruining everyone else’s day.
This was the approach that Google Chrome took for its tabs, that OpenEMU adopted for its multi-emulator cores, and that Boxer will eventually use for its DOS sessions.
However, restructuring Boxer to manage this parent-child process relationship is complex and has a lot of pitfalls. The groundwork for it is pretty far along, but it’s unlikely to be ready in time for Boxer 1.0.
Is for Boxer to simply launch more Boxers. When Boxer has a DOS window open and it gets a request to open another, it just spawns a new Boxer instance and tells that to open the window instead. If you try to open a new window after closing one, then Boxer quits and immediately relaunches to open the new window with a clean slate.
This approach has disadvantages. Each Boxer instance is a separate application as far as OS X is concerned: so they appear separately in the Dock and CmdTab switcher. Instances can’t coordinate with each other: so windows tend to open exactly over the top of existing ones, and preference changes in one don’t take effect immediately in another. This is very much a stopgap solution.
But, grubby and hackish though this is, it’s so dramatically better than before that I wanted to get it out there for people to play with right away.