Using Retro68 on a Mac

I was looking at Retro68 for legacy Macintosh development. It is handy because I can use a modern IDE and compile stuff without coding straight into the emulator. It seems it also supports C++ beyond version 98 and it would include modern optimisations. I don't know. (I'm mediocre, not exceptional, remember? I'll figure out at some point and then I post here.)

But there are no guides for this thing anywhere. There's a bloke using Linux and another using... Linux as well, I think. I don't know, it's all wrong, so I had to figure out one step at a time.

Tutorial time!

I am on macOS 15.1. My mac is an M2 mac. I got the regular developer junk installed, you know, XCode, those xcode tools and Homebrew and all that stuff.

So first, we update Homebrew, because this thing is always outdated. (What's up with that? Stop adding shit to this tool! Weirdos.)

$ brew upgrade
# lots of unnecessary noise here
$ brew install boost cmake gmp mpfr libmpc bison texinfo
# 26 minutes worth of unnecessary noise here 

Next, Retro68 is horribly broken for some reason, but there's a fork with a fix, so I found the pull request raised by the guy from the fork and I checked out his branch and it just works. So that's the version I'm using now. Of course, if you are reading this, you are probably in the future, so maybe the thing is fixed? Check it out before anything else.

$ git clone https://github.com/autc04/Retro68.git
$ cd Retro68
$ git submodule update --init
$ git remote add kanjitalk755 git@github.com:kanjitalk755/Retro68.git
$ git fetch kanjitalk755
$ git checkout kanjitalk755/fix_for_c99
$ cd ..
$ wget https://henlin.net/images/Interfaces\&Libraries.zip
$ unzip "Interfaces&Libraries.zip" -d Retro68/InterfacesAndLibraries
$ mkdir Retro68-build
$ cd Retro68-build
$ ../Retro68/build-toolchain.bash

That's it. For the Retro68, I mean. That interfaces and libraries thing I downloaded from another guy's blog, because I'm lazy. But apparently they can be found on the Macintosh Programmer's Workshop image file. The thing used to live on the Apple's FTP. There's a bunch of mirrors about (like this one), and people are afraid of sharing that. As if Apple gives a fuck. (There's a ton of places distributing Macintosh ROMs out there and nothing happens.) Of course, it would probably need to be mounted in the emulator and copied up to the host, so that's a lot of work.

wget is not available on Mac by default. I have a Homebrew version of it. Maybe curl can be used. I dunno. Look it up.

Next, we can only transfer the binaries to the emulator, or an older mac, by creating an HFS image. To do that, we use HFS Utils. I've made a GUI for that thing many years ago, it's pretty handy. It turns out that Retro68 has the source code for it sitting right there in the repo. So let's just compile it! Starting from the Retro68 directory's parent:

$ cd Retro68
$ cd hfsutils
$ ./configure
$ mkae
$ shit
$ make

This will drop all the binaries in the same directory, making a huge mess. I used Finder to figure out the latest timestamp for every binary and just moved away from there.

My setup is like this:

I have an Applications directory on my home dir. And inside Applications I also have a bin directory. And bin is on my .zsh_profile, at the very top:

PATH=$HOME/Applications/bin

So I just dragged and dropped the HFS Utils stuff there and called it a day. It just works.

For the codebases I have, I use ~/Development, and inside that, I have a Classic directory. There's where Retro68 lives.

So now, to compile something, there's a bunch of scripts in this page. Just download and fix them. I guess.

I altered the build file like so:

# build.sh

if [ $# -ne 1 ] ; then
    echo 'Syntax: ./build.sh [project_name]'
    exit 1
fi

if [ ! -d "$1" ]; then
    echo 'The specified folder does not exist'
    exit 1
fi

cd "$1"
rm -rf build
mkdir build
cd build
cmake .. -DCMAKE_TOOLCHAIN_FILE=/Users/user/Development/Classic/Retro68-build/toolchain/m68k-apple-macos/cmake/retro68.toolchain.cmake
make

I use that and the create_hfs_disk.sh. That's enough.

The downloaded ZIP file comes with a few projects for testing. I just dropped the files in the Classic dir and built from there. (I tried HelloWorld, of course, and it's a fucking mess. It works, kind of, but it simply has no way of quitting and it takes over the processing time of Mac OS, so it locks down the machine and one is forced to shut down. I don't recommend compiling that shit.)

To compile just run:

$ ./build.sh HelloWorld

and

./create_hfs_disk.sh ./HelloWorld/build/HelloWorld.bin HelloWorldDisk.img 1440

There's a few extra scripts there, and each project has a MakeFile. But the scripts are for PCE/macplus and only 68k instructions, and I'm using QEMU and PowerPC instructions. So I have to figure out how to sort that out. And then I need to see whether QEMU can handle debugging via a serial port.

Comments

Popular posts from this blog

Catching up with QEMU

Flashback: 1991