~nybble/Langtons-Ant-68k-Mac

An implementation of Langton's Ant for 68k Macs.
6a76d85b — Steve Sprang 1 year, 1 month ago
Add compressed disk image.
a47440d0 — Steve Sprang 1 year, 1 month ago
Initial commit.

clone

read-only
https://git.sr.ht/~nybble/Langtons-Ant-68k-Mac
read/write
git@git.sr.ht:~nybble/Langtons-Ant-68k-Mac

You can also use your local clone with git send-email.

#Langtons-Ant-68k-Mac License: GPLv3

This is an implementation of Langton's ant for classic 68000-based Macintosh computers.

I developed it on a modern Linux machine using the Retro68 project. I tested it under System 6.0.8 on the Mini vMac emulator and on a real Mac Plus. The code was written such that it can also be compiled using THINK C 5.0, an era appropriate compiler running directly on a 68k-based Mac. See the sections on building below for more details.

The app allows you to start the ant with an empty grid, a grid filled with random dots, or a grid filled with random shapes. You can reverse the ant's movement (rewinding time), and paste in images for the ant to destroy. You can also draw lines and erase portions of the grid. The ant moves the fastest when running without MultiFinder.

This app was developed as part of a project to explore implementations of Langton's ant on multiple platforms (Classic Mac, Commodore 64, and a modern terminal emulator). See the article at nybble.org for more details.

Langtons-Ant-68k-Mac Screenshot

#Running

Disk Image Contents

The project includes an 800k disk image ready to run: LangtonsAnt.dsk.zip

It bundles the application, the source code, and a THINK C project.

The disk image can be dragged and dropped on a running instance of Mini vMac or copied to an SD card and read on an actual classic Mac using the floppy drive emulator from Big Mess o' Wires.

You can also try the app in your web browser by running one of the emulated systems at Infinite Mac, and dragging and dropping the disk image there.

#Building with Retro68 (on Linux)

First, make sure you've downloaded and successfully built Retro68.

Then, open build.sh and edit the line that says

RETRO68_BUILD=~/code/Retro68/Retro68-build/

so that it points to the appropriate path on your system.

Execute the build script:

$ ./build.sh

If successful, the new disk image appears as build/LangtonsAnt.dsk

If you have LaunchAPPL set up (see the Retro68 description), you can automatically launch the app in an emulator by running:

$ ./build.sh --launch

#Notes

The resource file for this project (src/LangtonsAnt.proj.rsrc.bin) was created and edited in the classic Mac environment with ResEdit. If you wish to make changes to the resource file, you can edit it in the emulator and then copy it from the disk image to the top-level src directory using:

$ ./scripts/get_resource_file.sh

Similarly, you can copy the THINK C project file from the disk image to the top-level src directory:

$ ./scripts/get_think_c_project.sh

Both scripts use the disk image in the build directory and assume that path/to/Retro68-build/toolchain/bin is in your PATH.

Also, be aware that simply opening the src folder from the disk image in the Finder (via the emulator or an actual Mac) can cause LangtonsAnt.proj.rsrc and LangtonsAnt.proj to change. Even if you don't explicitly edit these files, copying them over from the disk image may cause them to change from git's perspective.

#Building with THINK C 5.0

If you have THINK C installed on your classic Mac, building should be as easy as opening LangtonsAnt.proj in the src folder of the disk image, and choosing Project > Run or Project > Build Application...

#Notes

The binary generated by Retro68 (18kB) is about 2x larger than the one generated by THINK C (9kB). The ant moves more than twice as fast with the Retro68 build.

The nifty MacFlim project has a bundled disk image that includes THINK C, ResEdit, and some other handy tools. It can even be used as a boot disk for your emulator. Thanks to Fred Stark for releasing the source code to this project.

Because this compiler is quite old, you can't use modern niceties like declaring variables wherever you want. All variables have to be declared at the top of the block in which they're used. This is probably most annoying in for loops, where it's become convenient to declare the loop variable in the initialization step.

I had to modify CMakeLists.txt to define OLDROUTINENAMES in order to choose compatibly named versions of a few functions (AddResMenu(), GetItem(), SetItem(), GetMHandle()).

I spent more than a few hours trying to figure out what I assumed was a bizarre memory problem when the app kept crashing with an Illegal Instruction error. Eventually it occurred to me to look at the project settings in THINK C (Edit > Options...). If you're targeting really old Macs, make sure you've turned off Generate 68020 Instructions. Also, turn on 4-byte ints for good measure:

THINK C 5.0 Settings

#License

Langtons-Ant-68k-Mac is released under the GNU General Public License v3.