Atari ST Programming: Cross-Development with Modern IDEs

in Retro Technologylast year


Previously we installed an Atari ST emulator and STOS/Pure C. Today, as well as looking at those, I want to show you a cross-development approach so you can use your modern desktop IDE but still run your compiled programs on the ST.

STOS and Visual Studio Code Extension

There is a neat Visual Studio Code Extension for STOS that offers modern conveniences such as IntelliSense and syntax colour highlighting!

While the built-in IDE isn't terrible, another convenience offered by the extension is it does away with requiring you to number your lines. Before "loading" your code into STOS, you can run the file through a tokenization program built with Java.

Screen Shot 2022-04-01 at 2.30.10 PM.png

I don't know if it doesn't work on my Mac due to me using M1 chip or if I didn't have some permissions set, but I could only get it working on my Windows machine.

When I get an answer back from their Facebook group I will try again.

STOS Hello World

After installing the Visual Studio Code extension, you can start a new STOS project by invoking CTRL-SHIFT-P (or CMD-SHIFT-P in Mac) and entering STOS new.

Screen Shot 2022-04-01 at 3.13.23 PM.png

A new BASIC code listing will be created as main.stos, and that will be tokenized when you hit save then use CTRL-SHIFT-B to build. Your output will be in the stos folder, which you can then load in STOS.

Screen Shot 2022-04-01 at 3.16.45 PM.png

Navigating the directories in STOS is a little counter-intuitive until you remember it is a programming environment (kind of like a REPL) rather than a command line shell. Set your current directory using the variable declaration, for example dir$="stos", then you can use dir to list the current directory. load "build.asc" (or whatever your output was called) to load your code.

Alternatively, use fload "*.asc" to use a dialog navigation.

Screen Shot 2022-04-01 at 3.24.04 PM.png

Pure/Turbo C

As is pretty standard with C, the various tools that make up Pure C can be used individually with command parameters, but again the built-in IDE isn't particularly terrible, especially in high resolution.

Screen Shot 2022-04-01 at 2.47.44 PM.png

The main program you would use in your workflow is PCC.TTP, the pure C compiler.

You might be wondering how you get to the command line on the ST. Well ... usually you ... don't! But there are a whole bunch of programs that provide that functionality, my favourite being Okami Shell which is very similar to the Linux/Unix shells we are familiar with.

Screen Shot 2022-04-01 at 3.00.30 PM.png

Hello World in Pure C

A confusing aspect of Pure C is you have to have a project file for each program you want to create. It's a pain, but fortunately they do include a default.prj that you can copy and reuse.

Screen Shot 2022-04-01 at 3.30.43 PM.png

This default worked for me once I commented out the E_GEM.LIB line which seems missing on my copy.

Once you have a .C file and your .PRJ you can then compile and Project/Build or run.

Naturally, the code is a little more involved in C. First we have to include the Standard IO library, then we need a Main function which simply outputs our text and returns.

#include <stdio.h>

int main()
    printf("\n\n\nHello World!");


Notice we didn't have to open any new windows or screens?

Ordinarily this would blow up in our faces, but part of the default project is including the necessary helpers to allow us to run this text output in a GEM window system friendly way!

VBCC C Compiler for Mac/Linux/Windows Atari ST Cross Development

Now we get to the real cross-development workflow - edit and compile on your desktop then run your program with your emulator.

VBCC is one of the three main C compilers for retro computer programming, along with CC65 and Z88DK.

I can't say enough good things about this tool, and the man-myth-legend that is Dr. Volker Barthelmann, the guy who put this (and the rest of the amazing toolchain) together.

Not only can you code for 68000 machines such as ST and Amiga, it also supports everything from the PDP-11 up to MEGA65 and Commander X16!

Hello World in VBCC for Atari ST

Same code as before, but this time we are going to compile on our regular desktop computer.

Once you have VBCC extracted onto your machine, you can use the following command line where vbcc.c is my C source code file:

vc +tos16 vbcc.c -lgem16

This will produce a binary file called a.out which you can then move to your Atari ST hard disk folder, renamed with a .prg extension.

Screen Shot 2022-04-01 at 3.49.36 PM.png