Atari ST / 68000

C & GEM

A C program steps into the Atari ST desktop with a small GEM dialog.

← All programming languages

C meets the GEM desktop

On the Atari ST, C programs can use GEM’s AES services for dialogs, menus, and windows, and VDI for device-independent drawing. This makes C a natural fit for desktop applications. A TOS console program and a GEM application have different interface needs, even when both are written in C.

Example: a GEM greeting

This small example targets a Pure C-style Atari ST setup with the aes.h header and AES bindings. Build it as a GEM application with the compiler’s startup code and AES library, then launch the resulting PRG from the desktop.

Atari ST C — Pure C-style AES bindings
#include <aes.h>

int main(void)
{
    if (appl_init() < 0)
        return 1;

    form_alert(1, "[1][HELLO FROM THE ATARI ST!][OK]");
    appl_exit();
    return 0;
}
Expected result: a GEM alert on the desktopIllustrative preview

The running program displays one alert with an icon, the greeting, and an OK button. Choosing OK closes it and the program exits. This is a static illustration; exact icon artwork, colors, and dimensions depend on the GEM version and screen resolution.

appl_init registers the application with AES. form_alert displays a modal dialog and waits for OK; appl_exit releases the application’s AES resources. This one-dialog program needs no event loop. A windowed program would need one to process redraws, clicks, and other messages.

Reference: The Atari Compendium — AES reference.

Professional GEM by Tim Oren

Read Tim Oren’s 15 Professional GEM columns from ANTIC Publishing, covering windows, dialogs, resources, menus, VDI graphics, events, user interfaces, and GEMDOS. The HTML editions include the original reprint notices and sample code, with links to the unchanged text files.

Compiler choices

Historical ST tools include Digital Research’s Alcyon C, Megamax C, Lattice C, and Pure C. Header names and library setup differ: other toolchains may use gem.h or gemlib bindings. Use the AES declarations supplied with your compiler.

Reference: Atari developer documentation collection.