Classic Mac Programming

2026-01-02

I am keeping a list here of resources for Classic Mac programming. This will be updated with more info as I casually tinker.

Motivation

I used classic Mac from System 7.1 to Mac OS 9.x from 1994-2000 before moving to Mac OS X. I wanted to write programs on it, but my own teenage head was too lazy to proceed.

I don't have much of an interest in maintaining old hardware. I don't have the room or skills to do that. Emulation is perfectly fine. I would get hardware if Classic Mac OS became free software and new hardware was made for it, but that's unlikely.

I wanted to use CodeWarrior (I had the "Academic" version) for school work in Pascal, but I don't understand why I didn't. CodeWarrior did support Pascal and the Turbo Pascal dialect.

I printed out Inside Macintosh, but felt overwhelmed. I don't think I was ever taught at the time to digest large volumes of text properly.

This might be unproductive since the only appeal is the retro computing "community", but as GenX and millenials retire, there is going to be more of interest in this, which is already growing in places.

Emulation

I am using SheepSaver. I am not interested really before System 7, except as it applies to development tools, since I never had a Mac before System 7.1. I followed this guide: https://www.emaculation.com/doku.php/sheepshaverbasiliskiilinux.

I had to find New World ROMs and find the one that works and then also a copy of Mac OS 9. They can be procured on macintoshgarden.org.

Is this legal? I don't think Apple cares anymore, but they are not going to open the code up, for sure. Classic Mac still has a lot of stored value behind it. But, the retro Mac community still thrives.

Development

This is still an open question on the type of things to do here.

First, I downloaded Metrowerks CodeWarrior Pro 4. There are later versions, for sure. I think it can go up to Pro 10, to support Carbon. This comes with MPW also (I haven't dug into that) and other Apple tools, like ResEdit. It comes with the C, C++ and Pascal compilers.

There will also probably be a lot of .sit files to open. Stuffit Expander is already in the OS install, but I found that unar, which is probably already installed on Linux machines is pretty much fine for that task. Also, KDE's Ark opens the .sit files just fine. SheepSaver maps your local drive, which is probably more stable than the disk images.

Documentation

I find using Inside Macintosh via a web browser easiest. These HTML files are probably found on developer CDs, but they are better than using Apple's DocViewer (pre-PDF).

Inside Macintosh (two different places): 1. https://dev.os9.ca/ 2. https://preterhuman.net/macstuff/

This is useful for finding function docs: https://ioi-xd.net/os9docs/.

This might be interesting, a semi-reimplementation of Toolbox: https://github.com/jorio/Pomme.

First program

I copied this program from Inside Macintosh: Overview. However, their Pascal example was incomplete, leaving me to guess the unit names. But I got it to work, with some tweaks while reading Inside Macintosh.

This simple program shows in a plain window "Hello World". The original example started off simpler, but this is using ResEdit* to encode the string name.

Inside Macintosh uses Pascal exclusively, but it is possible to translate back and forth from C, particularly if you can sling around both languages. This is important for modern documentation, since Apple was not very keen on writing indices of function calls it seems.

gAppsResourceFile := CurResFile;

(Had to guess the type ... pff) that specifies that the "current resource file" is the one currently local to the application.

const
    kMessages = 128;
    kGreetingString = 1;

and ...

GetIndString(gString, kMessages, kGreetingString);

are used to look up the data in the resource fork. Technically, the whole thing can be written with resource fork calls, but it is possible to call Toolbox functions directly.

program GreetMe;

uses Types, QuickDraw, OSUtils, SegLoad, Fonts, Windows, Menus, TextEdit, Dialogs,
        Processes, Events, QuickDrawText, Sound, Resources, ToolUtils, TextUtils;

const
    kMessages = 128;
    kGreetingString = 1;
var
    gWindow: WindowPtr;
    gString: Str255;
    gRect: Rect;
    gAppsResourceFile: Integer;
begin
    gAppsResourceFile := CurResFile;

    InitGraf(@qd.thePort); {initialize QuickDraw}
    InitFonts; {initialize Font manager}
    InitWindows; {initial Window manager}
    InitCursor; {initialize cursor to arrow}

    SetRect(gRect, 100, 100, 400, 200);

    // gString := 'Hello World';
    GetIndString(gString, kMessages, kGreetingString);
    gWindow := NewWindow(NIL, gRect, '', TRUE, dBoxProc, WindowPtr (-1), FALSE, 0);
    SetPort(gWindow);

    with gWindow^.portRect do
        MoveTo(((right - left) DIV 2) - (StringWidth(gString) DIV 2),
                (bottom - top) DIV 2);
    TextFont(systemFont);
    DrawString(gString);

    repeat
    until Button;

    end.

In: mac programming