Atari Lynx programming tutorial series:
- Part 2: Development environment for Windows
This is the second part of the tutorial to learn how to program Atari Lynx games. In the first part we looked at what you will need to get started. One of the requirements is a development environment.
Historically there have been three development environments that I know of:
- Original Epyx development kit with an Amiga 2000 machine.
Consists of special hardware and Amiga based development tools. This is unavailable to almost everyone and less practical in general.
- BLL (Behind Lynx Lines) kit combined with newcc65 from Bastian Schick
Bastian has recently started modernizing his tooling which can be found on GitHub here: https://github.com/42Bastian/. In particular the repositories for lyxass, sprpck, new_bll, lynx-encryption-tools and lynx_hacking are of interest.
- CC65 with some additional tooling from BLL (sprpck in particular).
The CC65 compiler suite is still in active development and seems the most modern suite. The source code can be found on GitHub at https://github.com/cc65/cc65.
Installing CC65 compiler suite on Windows
There is a Windows 32-bit specific snapshot made available at https://sourceforge.net/projects/cc65/. This download contains the binaries for the C compiler, assembler, linker and other tooling, as well as the configuration files, libraries and drivers (mouse, for various target machines it supports, include files for developing in C or assembler and documentation. It does not contain the sources for the tooling or the library files.
You can start by downloading the latest Windows snapshot of CC65 from https://sourceforge.net/projects/cc65/. Unzip all files into a single directory, such as ‘C:\Program Files\cc65’. Even though the CC65 suite is not 64 bit yet, having the Program Files folder eliminates the differences between 32 and 64 bit Windows OS machines. The result should be something like this:
It is convenient to have access to the bin folder from CC65, where all the executables (compiler, assembler, linker and more) are located. This requires editing the Path environment variable. Go to your Computer properties page (Right-click the Computer icon in Windows Explorer) and select “Advanced system settings”. From there, click on the bottom button that says “Environment Variables…”.
Pick the Path variable from the System variables list and click Edit…
Add the full path to the bin folder inside the folder where you extracted the CC65 files. This is probably ‘C:\Program Files\CC65\bin’. Also, add the path ‘C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin’ to the nmake.exe tool, so you can later run builds from the command-line as well. Close the dialog and return to the Environment Variables.
Additionally, create new environment variables that the CC65 tooling will use itself. Click the New… button in the System Variables section and add each of the variables listed below.
- CA65_INC: C:\Program Files\CC65\asminc
- CC65_INC: C:\Program Files\CC65\include
- CC65_HOME: C:\Program Files\CC65
- LD65_CFG: C:\Program Files\CC65\cfg
- LD65_LIB: C:\Program Files\CC65\lib
- LD65_OBJ: C:\Program Files\CC65\obj
The end result should look similar this:
The CC65 suite should now be ready for development. Try typing ‘CC65 –version’ from a console windows or terminal and see if something like this pops up:
As you can see CC65.exe was available. You can also try the other tools, such as ca65, ld65 and sp65.
Although you can work from here with Notepad and command prompts, we can make life easier for ourselves. The next step is optional. Pick whatever text editor you like and your favorite GUI environment like Code::Blocks, Mono, Visual Studio 2019 or Visual Studio Code.
Setting up Visual 2019 for Atari Lynx projects
First, you need to download the free Microsoft Visual Studio 2019 Community Edition from the Microsoft website: https://visualstudio.microsoft.com/. After the download, run the setup program and install Visual Studio. This should be a pretty straight forward process.
Make sure you select the Desktop Development with C++ workload. You only need the MSVC v14.2 Build tools from the optional installation details.
After the installation you have a GUI for source code and resource file management, that can work together with the CC65 compiler to provide a rich and productive environment.
If you want to give Visual Studio a spin for CC65, clone the repository at https://github.com/AtariLynx/HelloWorldCC65. You can do this easily from Visual Studio by choosing File, Clone Repository from the top-level menu:
Copy and paste the repository URL ‘https://github.com/AtariLynx/HelloWorldCC65’ in the dialog and pick a location on your development machine to store the repository and its files.
This should automatically open the solution.
You can double-click the main.c source file from the Solution Explorer and inspect the contents. Do the same for the helloworld.mak and lynxcc65.mak files that NMake uses to build the project. In order to compile the Lynx rom image, open the Build menu, choose Build Solution or press Ctrl+Shift+B and check the Output window at the bottom.
If the red squiggly lines in the code editor are bothering you, you can turn off IntelliSense information for C/C++ projects. This will help not getting too many warnings and errors from Visual Studio trying to understand what your C code is all about. IntelliSense works great for C programs targeted for Windows and not so much for CC65 tooling targeting the Atari Lynx. The option is found under the menu Tools, Options, Text Editor, C/C++, Advanced in the IntelliSense section on the right:
Simply change the value from False to True and you are good to go.
The next part of the tutorial will focus on the files inside this project, how Visual Studio and CC65 work together and what we need to do to build a working rom image.