Programming in Action!: A Practical Introduction

Action! was the language serious Atari hobbyists graduated to when BASIC ran out of steam and assembler felt like too much work. Sold on cartridge by Optimized Systems Software (OSS), with its manual dated August 1983, it packages a full-screen editor, a compiler, a monitor and a runtime library into one ROM. Programs are written in a structured, procedure-based language a little like C or Pascal and compiled to real 6502 machine code — so fast that the manual itself describes it as "almost as fast as assembly language" for execution. Antic published games written in it, such as Greg Knauss's Killer Chess, Frog and Reardoor, and it is still used today: modern projects include a FujiNet bulletin-board system written entirely in Action!.

You will learn: the edit–compile–run cycle, the data types, declarations, procedures and functions, loops and conditions, the most useful library routines, a complete joystick program, and how to save programs that run without the cartridge.

You need: an Action! cartridge (or cartridge image in an emulator) on any 8-bit Atari, plus a disk drive for saving work. The manual is essential — it is a reference rather than a tutorial.

1. The parts of the system

Action! has five components, all in the cartridge:

  • Editor — a full-screen text editor. It knows nothing about the language, so you can use it for any text.
  • Monitor — the "boss", from which you call the compiler, run programs, go to DOS or set options.
  • Language — what you write.
  • Compiler — turns your source in the editor buffer into machine code in memory.
  • Library — ready-made routines for printing, input, files, graphics, sound and strings.

When you enter Action! from DOS you land in the editor. CTRL+SHIFT+M takes you to the monitor, whose one-letter commands include C (compile), R (run), E (back to the editor), D (DOS), O (options menu) and W (write a compiled program to disk). X executes an Action! statement directly, and ? shows the contents of an address — useful for debugging.

2. Hello, world

Type this into the editor:

PROC Hello()
  PrintE("Hello World")
RETURN

Press CTRL+SHIFT+M, type C and RETURN to compile, then R and RETURN to run. If the compiler finds a mistake it reports an error code (listed in the manual's Appendix C); type E and you will find the editor cursor sitting where the compiler stopped.

PROC ... RETURN is the skeleton of every routine. PrintE is a library procedure that prints a string followed by RETURN.

Important rule: when a program has several procedures, the last one in the source is the main program — the one RUN starts. Put your helpers first and your main routine last.

3. Data types and declarations

Action! has no floating point; everything is integer, which is a big reason it is fast.

Type Size Range
BYTE (or CHAR) 1 byte 0 to 255
CARD 2 bytes, unsigned 0 to 65,535
INT 2 bytes, signed −32,768 to 32,767

Variables must be declared before use, at the start of a procedure (or after a MODULE directive for globals). Here is the most important syntax subtlety in the language:

BYTE count=[0]      ; a variable whose initial value is 0
BYTE clock=20       ; a variable that LIVES AT ADDRESS 20
CARD screen=88      ; a two-byte variable at addresses 88-89

Square brackets give an initial value; a bare number gives the variable's address. That second form is wonderful for hardware access — clock above is the low byte of the system jiffy clock, and screen reads the screen-memory pointer directly — but forget the brackets by accident and you will be writing to some random location.

Also, do not put a comma after the last variable in a declaration list, or strange things will happen.

Arrays and strings: BYTE ARRAY buf(100), INT ARRAY x(10), and BYTE ARRAY msg="Text" for a string constant. There are also POINTER types (BYTE POINTER p) and TYPE record declarations for structures.

Comments start with a semicolon.

4. Statements

Assignment uses =, and there is a handy shorthand for updating a variable: i==+1 adds one to i (==-, ==* and friends work too).

Conditions end with FI, and may contain ELSEIF and ELSE:

IF guess<num THEN
  PrintE("Too low")
ELSEIF guess>num THEN
  PrintE("Too high")
ELSE
  PrintE("You got it")
FI

Loops all use DO ... OD:

FOR i=1 TO 10 DO
  PrintBE(i)
OD

WHILE x<100 DO
  x==+7
OD

DO
  ; ...repeats until UNTIL is satisfied
  UNTIL guess=num
OD

A bare DO ... OD loops forever unless an EXIT or (as the last statement before OD) an UNTIL ends it. Operators include the usual arithmetic, MOD, LSH/RSH shifts and AND/OR/XOR; "not equal" is written <> or #.

Functions return a value with RETURN(value) and declare their result type: BYTE FUNC Max(BYTE a, BYTE b).

5. The library

The built-in library routines fall into groups by job. Some you will use constantly:

  • Output: Print, PrintE (with RETURN), PrintB/PrintBE for BYTEs, PrintC/PrintCE for CARDs, PrintI/PrintIE for INTs; D variants (PrintD, PrintBD ...) print to a channel.
  • Input: InputB() and friends read numbers; InputS reads a string.
  • Files: Open, Close, XIO, Note, Point.
  • Graphics: Graphics(mode), SetColor(register,hue,luminance), the Color variable, Plot(x,y), DrawTo(x,y), Fill, Position, Locate.
  • Sound and controllers: Sound(voice,pitch,distortion,volume), SndRst(), Stick(port), Strig(port), Paddle(port), PTrig(port).
  • Strings and conversions: SCompare, SCopy, StrB/StrC/StrI (number to string) and ValB/ValC/ValI (string to number).
  • Miscellaneous: Rand, Peek/PeekC, Poke/PokeC, and the memory routines Zero, SetBlock and MoveBlock.

These mirror Atari BASIC's statements closely, so BASIC programmers feel at home quickly (the manual even has an appendix of BASIC-to-Action! conversions).

6. A complete program: joystick sketch pad

; SKETCH.ACT - draw with the joystick, fire button quits
PROC Main()
  BYTE s, t, y=[48]
  BYTE clock=20
  CARD x=[80]

  Graphics(23)
  SetColor(0,12,10)
  Color=1
  DO
    s=Stick(0)
    IF s=5 OR s=6 OR s=7 THEN
      IF x<159 THEN x==+1 FI
    ELSEIF s=9 OR s=10 OR s=11 THEN
      IF x>0 THEN x==-1 FI
    FI
    IF s=6 OR s=10 OR s=14 THEN
      IF y>0 THEN y==-1 FI
    ELSEIF s=5 OR s=9 OR s=13 THEN
      IF y<95 THEN y==+1 FI
    FI
    Plot(x,y)
    t=clock
    WHILE clock=t DO OD
    IF Strig(0)=0 THEN EXIT FI
  OD
RETURN

Graphics(23) is GRAPHICS 7+16 (160 × 96, no text window). The stick values are the standard ones (7 = right, 11 = left, 14 = up, 13 = down, diagonals in between). The WHILE clock=t DO OD line waits for the jiffy clock at location 20 to tick, limiting movement to one pixel per frame — without it, compiled Action! code would race across the screen. Pressing the fire button EXITs the loop and returns to the monitor.

7. Saving and distributing programs

Save your source from the editor as a text file (.ACT is the conventional extension). To save the compiled program, compile it and use the monitor's WRITE command:

WRITE "D:SKETCH.COM"

There is a catch: compiled code calls routines inside the cartridge, so a WRITTEN program still needs the Action! cartridge present. For distribution, OSS licensed a runtime version that removes that dependency — which is how Antic could ship Killer Chess, Frog and Reardoor as runnable files "on any 8-bit Atari computer without the OSS ACTION! cartridge" while also supplying the source for Action! owners. Today, community-maintained builds of the Action! cartridge and runtime are widely circulated, and current projects (such as jihem's Action! libraries, developed and tested on a real 800XL running SpartaDOS X) target recent builds such as Action! 3.7X.

Troubleshooting

  • The wrong procedure runs: the main routine must be the last one in the file.
  • Variables change by themselves / the machine crashes: you wrote BYTE x=5 (address 5!) when you meant BYTE x=[5].
  • "Strange things" after a declaration: a trailing comma at the end of a declaration list.
  • Compiled program will not run from DOS: it needs the cartridge, or must be built with the runtime package.
  • Program never returns to the monitor: an infinite loop; press SYSTEM RESET.
  • Keyword case errors: by default the compiler is not case-sensitive; if the "Case sensitive?" option is set to Y, keywords must be typed in upper case.

Further reading

  • The Action! Reference Manual (OSS, 1983); a revised third edition dated 2015 and credited to GBXL is available on the Internet Archive, alongside a German Action!-Handbuch.
  • Antic's published Action! programs, for example "8 Queens ACTION!" by Dave Oblad (September 1985), which solved and displayed all 92 solutions to the eight-queens problem in about 40 seconds.

Credits