Xcode icon

Code

About

Various bits of code I’ve written and which are available free to use under liberal terms. Unless otherwise specified, the code can be found at Google Code. See also: Acorn Plug-ins.

I mostly code for Mac OS X, but some of the code is intended to be cross-platform.

If you feel a pressing urge to shout at me, you can use this e-mail address, which changes from time to time.

Mac OS X – High Level

Dry Dock for Oolite icon

Dry Dock for Oolite

A 3D model post-processor to assist in making add-ons for Oolite. Development on Oolite has ceased, and significant further development on Dry Dock is unlikely. MIT/X11 license.
(Hosted at BerliOS)

Redline Plug-in Splitter icon

Redline Tools

A set of tools for working with plug-ins for Ambrosia Software’s Redline. MIT/X11 license.
  • Plug-in Splitter for Redline: a drag-and-drop tool to unpack Redline plug-in archives.
  • Plug-in Mounter for Redline: a tool to mount Redline plug-ins like disk images (using MacFUSE).
  • redlinesplit: command-line equivalent of Plug-in Splitter.
  • Map Viewer for Redline: a tool for examining Redline maps in 3D.
  • RedlineHackKit: a set of reusable classes used in the above.
(Hosted at SourceForge)

Mac OS X – Libraries and Snippets

SCDialControl screen shot

SCDialControl

An example of a Cocoa control and cell. Implements a flexible but not very beautiful dial, with an Interface Builder palette. MIT/X11 license.

SCSliderWithTextField

Not recommended! This code uses an overly clever technique that relies on details of the superclass implementation. I’m not sure what I was thinking.

A subclass of NSSlider. When it is being dragged, a text field shows the value. When dragging stops, the text field is hidden. This is inspired by the sleep time sliders in the Energy Saver control panel. Unlike those, this implementation also shows the text field temporarily if the value is set by user interaction other than dragging, e.g. with full keyboard navigation. Requires Mac OS X 10.3 or later.MIT/X11 license.

JAMultiTypeSavePanelController

A class to manage an NSSavePanel with a pop-up menu for choosing types. Uses modern, spiffy UTIs. MIT/X11 license. See also: this blog entry.

KeyNaming icon

KeyNaming

A library for generating descriptive strings from virtual key codes. Also has experimental support for USB HID usage codes for keyboards. MIT/X11 license.

C source file icon

KeyFromQWERTY

A simple library to convert character values to corresponding key codes using a predefined keyboard layout (that is, it does not use the current keyboard layout; by default is uses the U.S. layout, but tools to generate different versions are included). This can be used to hard-code default key bindings when you want to bind to physical key location rather than character value. Use KeyNaming to get an appropriate display string for a key code.

MIT/X11 license. See also: this blog entry.


Cross-Platform – Libraries and Snippets

C source file icon

S3TCDecompression

When I added texture conversion to redplugsplit, I needed a library for decompressing S3TC DXT3 textures. I couldn’t find one, so I wrote my own based on the S3TC code in DevIL. Public domain (with the permission of the DevIL crew).
Note: while it nominally supports other s3TC codecs (DXT1, DXT2, DXT4 and DXT5), it has currently only been tested on DXT3 textures.
Note 2: this code may be patent-encumbered. In particular, United States Patent 6,940,511 defines the decompression algorithm for the S3TC formats, but may only apply to specific uses. I am not your patent lawyer; if you wish to deploy this code in the United States or other countries which allow software patents, you should get legal advice.

GLSL Bindings Sample screen shot

GLSL Bindings Sample

An example of using Objective-C’s dynamism and introspection to bind object properties to GLSL shader uniforms. Why is this listed as cross-platform? Well, it’s based on code from a cross-platform game, Oolite, so clearly Objective-C and the Foundation framework qualify as cross-platform. See this blog entry for a description.

C source file icon

JAPriorityQueue

I needed a priority queue for Oolite, and Foundation doesn’t provide one. Mike Ash provides an implementation which wraps the STL, and (as I pointed out there) CoreFoundation provides CFBinaryHeap. However, I needed this to work under GNUstep, which doesn’t play nice with Objective-C++, and I didn’t want to introduce a dependency on CFLite. So here’s an Objective-C implementation. MIT/X11 license. See also: this blog entry.