AMOS programming language

This article by Dan Polansky briefly looks at AMOS programming language for the Amiga line of computers (Motorola 68k-based computers strong on graphics and sound for games at their heyday), which is a structured and procedural dialect of BASIC with certain batteries included, especially those suitable for programming of simple games. The article intends to go beyond the Wikipedia article in providing a better idea about the language and supporting anyone curious enough to want to run AMOS in an Amiga emulator for Windows and play around with it.

AMOS was originally interpreted, but later, a compiler was made for it.

The source code files are stored in a binary form rather than as plain text file.

The source code editor features folding of procedures.

AMOS facilities:
 * Structured and procedural programming: procedure, if, while loop, repeat until loop, etc.
 * Call to assembly loaded from a binary file into a memory bank.
 * Direct memory access via poke and peek.
 * Create screens.
 * Plot on screens.
 * Load images from files and place them on screens.
 * Play animations.
 * Control hardware sprites.
 * Play sound samples loaded from files.
 * Play music modules loaded from files in the background.
 * Read keyboard and joystick.
 * Etc.

Example code
Variables, data types and literals: 'Integer COUNT=30 COUNT2=$20 'Floating-point number PI#=3.141592 'String NAME$ = "Joe Hoe" 'Zero-indexed arrays Dim INT(9), FLT#(9), STRING$(9), MULTIDIM(9, 1)

Control structures: If X ... End If

Repeat ... Until X

While X ... Wend

Procedures: Procedure PROC_NAME[ARG_NAME, ARG_NAME2] ... End Proc

Plotting graphics: 'A single point Plot 10, 10 'A line Draw 245,24*5+20 To 250,24*5+20 'A rectangle outline Box 0, 0 To 10, 10 'A circle outline Circle 10, 10, 5

Music and samples: 'Load and play a tracker module Track Load FILEPATH, 1 Track Play 1 'Play a sound sample number 5 at a certain frequency Sam Play CHANNEL, 5, 7000

Low-level access : 'Read: 8-bit, 16-bit and 32-bit Peek(ADDR) Peek$(ADDR, LENGTH) Deek(ADDR) Leek(ADDR) 'Write: 8-bit, 16-bit and 32-bit Poke ADDR, VAR Doke ADDR, VAR Loke ADDR, VAR 'Take address of a variable Varptr(VAR) 'Load machine code into a memory bank Pload FILENAME$, BANKNR 'Start of a memory bank Start(BANKNR) 'Call machine code Call(ADDR) 'Access 68k CPU registers VAR=Dreg(REGNR) Dreg(REGNR)=VAR VAR=Areg(REGNR) Areg(REGNR)=VAR 'Copy a byte sequence Copy STARTADDR,ENDADDR To DESTADDR

See Game Duenix for Amiga computers for more plentiful examples of various AMOS facilities.

Complete guides to the language from the original language publishers are in the further reading at the end.

Limitations
Limitations include the following:
 * No support for pointers.
 * No support for data structures (struct in C language).
 * No support of control of Amiga Workbench (windowing for AmigaOS) windows, unlike Amiga Basic by Microsoft. Instead, AMOS operated on its own fully controlled screens, taking over the complete display.

Software developed in AMOS
Based on Wikipedia:
 * Flight of the Amazon Queen, a point-and-click adventure game
 * Scorched Tanks, a game
 * Valhalla game trilogy
 * Ultimate Domain, also called Genesia, a game
 * Jetstrike, a game
 * Black Dawn, a game

Further reading:
 * Games made in AMOS, mobygames.com
 * Amiga Longplay Flight Of The Amazon Queen, youtube.com
 * Flight of the Amazon Queen — A 20th Anniversary Retrospective by John Passfield, 2015, medium.com -- mentions AMOS

Alternatives and competition
Alternative BASIC implementations for the Amiga, competing with AMOS during its heyday:
 * Amiga Basic from Microsoft. Allows control of and painting on Amiga Workbench windows.
 * Blitz Basic, in which e.g. an early version of the Worms game by Team17 was written.
 * GFA BASIC

Performance
Given the kind of facilities AMOS has, there seems to be no obvious reason why compiled AMOS could not be as fast as the C language. An empirical performance comparison is missing. It seems unlikely that compiled AMOS was as fast as C, but it is unclear what the case actually is and why that is. AMOS compiler itself was not written in C but in assembly.

One area where AMOS is expected to get slow is strings and their operations such as concatenation. I (Dan Polansky) remember writing a text format conversion tool in AMOS; I started using the built-in string facilities, but it was very slow and I could only make it perform well by switching to low-level facilities directly working with bytes and their sequences.

Compared to Blitz Basic, user Predseda tells us Blitz Basic is faster than AMOS (merely a hint since hearsay, but plausible enough).