Getting started with writing code for the Atari Lynx is easy. There is a number of very good resources that explain how to get going - they step through examples and get you on the way to writing simple games. Alex Thissen's programming tutorial series is probably the most easy to follow. Then for more in-depth information the Atari Lynx Programming subforum on AtariAge is a very good resource. However something that isn't covered in detail is how to set up and compile Atari Lynx code on a Mac. That's where this tutorial comes in.
This tutorial will tutorial assumes that you are already familiar with Lynx programming and simply want to start building your code on a Mac. The tutorial is a part of a series that will cover aspects of Lynx programming that haven't been covered in other places.
Since the Atari Lynx is 6502 based system. The choice of compiler is obvious - CC65. Note the website address, the current version is hosted on Github, the old version is still on its own domain over at cc65.org. This tutorial covers the current version.
Since there is no release version of CC65 available for the Mac, you have to build your own. This requires that Xcode with development tools is set up first, this blog post covers that aspect.
Building CC65 is simple. This tutorial will assume that all of the development tools involved are going to reside in the /Applications/devtools directory. So the first step is to make sure the directory exists and clone the CC65 repository using git. This is all done via the Terminal application.mkdir -p /Applications/devtools
Once all the code is downloaded it's time to build CC65 using make.cd cc65
If everything went well there should be no errors and CC65 and all its tools should have been compiled. At this point Lynx code can be compiled, but first there are a few extra items to take care of to make life easier.Additional Tools
Just the compiler is all well and good but in most cases you will need some additional tooling, especially if you are trying to build code that's out there already. One of the most frequently used tools is sprpck by Bastian Schick. There is no binary release version of it, in fact the original v1.97 source code won't build on a Mac, but there is a way to do it.
There is a "forked" version 1.98 of the tool over at GitHub that has been updated specifically to build on a Mac. It can be found here - https://github.com/kateflower/sprpck. There is no functional difference between the 1.97 and 1.98 versions apart from Mac compatibility. So lets clone, then build it...cd /Applications/devtools
Again if no errors are displayed, sprpck is built and ready to use. Note that CC65 comes with its own sp65 image tool which will be covered in more detail in the future.A Few Conveniences
With the tooling set up you can get started, but before you do that it's a good idea to set up the command line environment to make it easier to build Lynx code. It's a good idea to set up environment variables pointing to the CC65 and sprpck install locations as well as adding both to the run search path.
This is done by adding some code to end of the ~/.profile file. The easiest way to do this is via the command line...open -a /Applications/TextEdit.app ~/.profile
Add the following lines to the end of the file...export SPRPCK_HOME=/Applications/devtools/sprpck
For these changes to take effect you need to close and re-open the Terminal app (or just the current tab).Go Forth and Code
Now you should have everything you need to get started with simple game coding on the Lynx. It pays to get familiar with CC65 documentation and especially its Atari Lynx specific information section. Be sure to go through all of Alex's tutorials and have a look at the demo part of the Atari Gamer GitHub repository for some Lynx code examples.
This tutorial series will keep getting expanded so check back for more content soon.-AG