Next Previous Contents

2. Building your first Hello World application

Here is a small traditional Hello World program for the Atari Lynx.

#include <lynx.h>
#include <tgi.h>
#include <6502.h> 

void main(void) {
  tgi_install(tgi_static_stddrv);
  tgi_init();
  CLI();
  while (tgi_busy())
    ;
  tgi_clear();
  tgi_setcolor(COLOR_GREEN);
  tgi_outtextxy(0, 0, "Hello World");
  tgi_updatedisplay();
  while (1)
    ;
}

The lynx.h contains all kind of system dependent things.

The tgi.h contains the graphics driver functions.

The 6502.h is needed for executing the CLI() command.

As the Atari Lynx does not have ASCII characters available you need to use the Tiny Graphics Interface library for producing letters on the screen.

The cc65 compiler suite has a graphics library called "Tiny Graphics Interface". This interface has some relocatable code. In order to use this in your own program you need to load it at run time.

Unfortunately the Lynx does not have a disk drive from where to load it. Therefore you must already load it at compile time. The easiest way is to automatically link it in statically from the Lynx C library.

cl65 -t lynx -o game.lnx main.c

This will create a bootable cart image called game.lnx


Next Previous Contents