Creating a Classic Mac Application

, Classic Macintosh, Programming

I am no stranger to Macintosh programming. I started to program in the 1990s, and the Macintosh is what we had at home. At the time, my dad taught computer science at the University of Portland, so I had a lot of resources available when I wanted to learn—books, software, and real live experts who would answer questions or explain how pointers worked.

If I feel nostalgia towards any era or brand in computing, it would have to be the Macintosh System 7–Mac OS 8.5 era.

Aside: Are Classic Macintosh Games Worth Playing?

A few.

The DOS and Windows markets had a better library, no contest. There were a handful of Mac-only or Mac-first developers and publishers that stood out. Bungie, Ambrosia Software, Spiderweb Software, Storm Impact, Cyan Worlds, etc. Most of the good games got a PC port. Many of the classic games I remember were ports from DOS or Atari ST.

Some classic Mac games I like:

Hello, World

Unlike the Nintendo 64 series, I am not figuring out how to write code for classic Macintosh. Classic Macintosh programming is well-documented. There are books, there are open-source projects, and most importantly, I’ve done it before.

I have a copy of Basilisk II which I compiled from source, a ROM file of dubious origin, and a disk image containing Mac OS 7.5.3 and MPW. I mostly used CodeWarrior back in the day, but I’m going to start with MPW.

My Hello World program will display an alert dialog on screen and quit.

The C code is fairly short, it just needs to initialize a bunch of stuff and then call the Alert() function:

#include <Dialogs.h>
#include <Fonts.h>
#include <MacMemory.h>
#include <Menus.h>
#include <Processes.h>
#include <QuickDraw.h>
#include <TextEdit.h>

QDGlobals qd;

void main(void) {
  Alert(128, NULL);

The actual alert dialog must be created as a resource, using a ALRT and DITL. The string is just long so it fills the alert box.

#include "Dialogs.r"

resource 'ALRT' (128, purgeable) {
  { 40, 40, 137, 360 },
  128, /* DITL ID */
    OK, visible, silent,
    OK, visible, silent,
    OK, visible, silent,
    OK, visible, silent

/* See Macintosh Human Interface Guidelines (1992) */
/* p. 197 "Basic Dialog Box Layout" */
resource 'DITL' (128, purgeable) {{
  /* Quit button */
  { 67, 242, 87, 312 },
  Button { enabled, "Quit" },
  /* Error text */
  { 7, 73, 54, 312 },
  StaticText { enabled,
    "Error occurred. Some crazy error. "
    "Pad this out, we want it to stretch "
    "across three lines of texty!" },
  /* Icon */
  { 10, 20, 42, 52 },
  Icon { enabled, 128 }

To build, run the following commands in MPW. Note that the character is the escape character for MPW’s shell syntax.

SC main.c
Link -t APPL -c '????' -o HelloWorld ∂
    main.c.o "{Libraries}Interface.o" "{Libraries}MacRuntime.o"
Rez -a -o HelloWorld resources.r icons.r

The spacing in the UI follows the Human Interface Guidelines (23 pixels and 13 pixels of between elements). Here’s what it looks like on-screen, with a custom icon:

Mac System 7 alert window with long text

For now, I’m not making a project out of this, but I might do some more experimentation.