hiworld, "Hello world" in C, for Atari 8-bit
By Bill Kendrick
This is a simple C program that compiles on Linux and runs on an
computer. (Two great tastes, ...)
Motivation and Goals
For a very long time, I knew of the
cc65 6502 cross-compiler
for modern platforms, like Linux. (In fact, it
life in the 1980s as a compiler that ran on the Atari 8-bit.)
I also know that people occasionally use it (often with some assembly
language thrown in) to do some awesome stuff, like
His Dark Majesty.
So, beginning in August 2013, I've finally (in my "copious" free time;
2 kids and a busy day job!) began tinkering. My goals include:
- Sticking to as much straight C as I can, for a variety of reasons:
- to this day, I could not assemble my way out of a paper bag
- it helps keep things portable
- I like C, and have written countless Linux games
using C and libSDL
- to prove it can be done
- Get my Linux box to do as much heavy-lifting as possible, including:
- compiling and linking
- managing any assets (art, or whatever)
- generating a bootable disk image
- firing up "Atari800"
emulator for testing
- Final results should run on one of my real Atari 8-bits
(1200XL or 800XL, both basically stock, except for 256KB RAM) with
as little fuss as possible (via
- Stuff you'll probably need to install:
- Stuff you probably already have:
- 8- and 16-bit sound routines (a la
DSOUND in TurboBASIC XL)
- Simple DLI (Display List Interrupt) example
- Simple VBI (Vertical Blank Interrupt) example
- Embedded font
- Font loaded from disk
- Extended header files
- #defines of POKEY, ANTIC and GTIA shadow registers
- #defines of other Page 0 and Page 2 registers
- #defines of ATASCII characters (numeric and (some) as strings)
- #defines for bits and values used in hardware registers
- #defines of internal keycode values (for PEEK(764))
How it makes a bootable disk:
I'm really novice / naiive when it comes to under-the-hood stuff on the
Atari, despite having owned them since 1983 and having so many great books
and magazines sitting here. Therefore, please don't laugh too hard when
you read the following:
- Uses Franny to create a new single-density disk image
- Uses Franny to format ("initialize") that disk image
- Uses Franny to copy the "
DOS.SYS" and "
files of MyDOS 4.53/3 into this new disk image
(It is not bootable, yet. Copying files onto the disk this way is like
[C]opy command in Atari DOS or MyDOS.
We therefore need to make it know how to boot into "
as though we wrote the DOS files using the
[H] Write DOS Files
command. Franny does not seem to currently support such a method of
copying a file into a disk image.)
- Uses XXD to replace the first 3 sectors (384 bytes) of this new
disk images with those 'stolen' from a bootable, single-density
MyDOS 4.53/3 disk image.
A disk image was created and formatted with Franny, then I used Atari800,
booted into an existing MyDOS 4.53/3 disk image, to write the DOS files
to the disk image. Finally, I used XXD's "-l" option to grab a hex-dump
of the first 3 sectors of that bootable disk and stick it into a text file.
So in the end (as of January 2014, at least), I am distributing the
"hiworld" source code and Makefile, together with MyDOS's binary
.SYS" files, and a hex-dump of the first 3 sectors of a
bootable MyDOS disk (not included). Atrocious, but it works for now!
(I'm happy to learn of a more sane process for this; or perhaps someone
wants to provide the author of Franny with a boot-disk-making patch?)