Programming tutorial: Part 2–Development environment

Atari Lynx programming tutorial series:

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:

  1. 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.
  2. 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.
  3. 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:

CC65Snapshot

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…”.

EnvironmentVariables

Pick the Path variable from the System variables list and click Edit…

EditEnvironmentVariable

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.

AddEnvironmentVariable

  1. CA65_INC: C:\Program Files\CC65\asminc
  2. CC65_INC: C:\Program Files\CC65\include
  3. CC65_HOME: C:\Program Files\CC65
  4. LD65_CFG: C:\Program Files\CC65\cfg
  5. LD65_LIB: C:\Program Files\CC65\lib
  6. LD65_OBJ: C:\Program Files\CC65\obj

The end result should look similar this:

CC65EnvironmentVariables

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:

CC65CommandPrompt

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.

VisualStudioInstaller

Make sure you select the Desktop Development with C++ workload. You only need the MSVC v14.2 Build tools from the optional installation details.

VisualStudioCPPFeatures

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:

VisualStudioFileCloneRepositoryMenu

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.

VisualStudioCloneRepository

This should automatically open the solution.

VisualStudioSolution

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.

VisualStudioBuildOutput

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:

VisualStudioDisableIntelliSense

Simply change the value from False to True and you are good to go.

Next time

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.

This entry was posted in Tutorial. Bookmark the permalink.

19 Responses to Programming tutorial: Part 2–Development environment

  1. Pingback: Programming tutorial: Part 3–Analyzing Hello World | Diary of an Atari Lynx developer

  2. Pingback: Programming tutorial: Part 4–Creating a project | Diary of an Atari Lynx developer

  3. Pingback: Programming tutorial: Part 5–Exploring TGI | Diary of an Atari Lynx developer

  4. Pingback: Programming tutorial: Part 6–Colors | Diary of an Atari Lynx developer

  5. Pingback: Programming tutorial: Part 7–The basics of sprites | Diary of an Atari Lynx developer

  6. Pingback: Programming tutorial: Part 8–Changing appearances | Diary of an Atari Lynx developer

  7. Pingback: Programming tutorial: Part 9–Advanced sprites | Diary of an Atari Lynx developer

  8. Pingback: Programming tutorial: Part 3–Analyzing Hello World | Diary of an Atari Lynx developer

  9. Pingback: Programming tutorial: Part 10–Collisions | Diary of an Atari Lynx developer

  10. Pingback: Programming tutorial: Part 11–Pens and more collisions | Diary of an Atari Lynx developer

  11. nitrofurano says:

    i’m using Linux only (Debian and Ubuntu) – what you can recommend instead?

  12. Shane Skekel says:

    Would it be possible to configure Notepad++ or Programmer’s Notepad for those who don’t have Visual Studio?

    • alexthissen says:

      Sure, that would be possible. I think you will need to combine some command-line scripts to run the MAKE utility. If you do not have Visual Studio (there are free editions for Visual C++ Express BTW), because maybe you work on a different platform, then you will also need the MAKE.exe unix tool instead of the NMake.exe from VC++. That means the *.mak files are also slightly different as the syntax of the make.exe and nmake.exe differ.
      Programmer’s Notepad allows for the definition of tools. I haven’t tried to get a setup working, but it seems doable. Let me know how you fare, so I might do a write-up on alternate tooling. There have been suggestions to look into CodeBlocks as a dev environment.

  13. aminor00 says:

    I found that my VS 2012 Express Desktop installed itself to the 32bit/x86 Program Files directory: (C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\bin).

    I amended your instructions above an added the different path to the PATH environment variable and the build stopped complaining an not finding nmake!

  14. aminor00 says:

    When I first opened the Project file VS2012 popped up a dialog box with a message about the file being created in an earlier version of VS and did I want to update it. I said No. Probably that was incorrect.

    I had to edit the “Starter” project properties and make the path changes that you talk about in Tutorial 4 under Configuration Properties > VC++ Directories and > NMake

    Also, the lynxCC65.mak file has a reference to the same place in the first line:

    CC65=”C:\Program Files (x86)\CC65″

    As I installed CC65 to the “C:\Program Files\” folder I just changed that path too and now the build completes with no errors.

  15. Steven says:

    Hello! Thank you for this great tutorial. I got my environment all set up, and I’m excited to see what’s next.

    I have a problem, though. When I go to build the Starter project in Visual Studio, I get an error MSB3073 (exit code 3) that complains about the path C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\nmake.exe …

    That path is wrong for me. I installed Visual Studio 2019, so I think the “Visual Studio 10.0” path is incorrect in my case. But I can’t find anything in the Starter project that’s defining that path. Do you what I could do next to debug this? Thanks.

  16. Steven says:

    Hmmm, maybe disregard the other comment I just made. I went into the nmake properties for the Starter project, and all the paths were set to something like . So I clicked edit on those and changed them to be something like . Now it builds successfully. If I did the incorrect then, please let me know. Thanks.

  17. Steven says:

    One last message tonight (probably): I guess I don’t know what I’m doing after all. It didn’t seem to do anything, and it only outputted this message:

    1>—— Build started: Project: Starter, Configuration: Debug Win32 ——
    1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.MakeFile.Targets(44,5): warning MSB8005: The property ‘NMakeBuildCommandLine’ doesn’t exist. Skipping…
    1>Done building project “Starter.vcxproj”.
    ========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========

    I’d appreciate any help you can give me. Thank you.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s