ST CARTRIDGES
How to program plug-ins
by PATRICK BASS, Antic ST Program EditorIf you own an Atari 520ST, you have probably noticed an opening towards
the back of the left side that looks as if it might hold a program cartridge.
Well, that's what the opening is there for, pardner. And
in this article we are going to discuss not only how the two types of ST
cartridges differ-but also how the 520ST recognizes when a cartridge is
there, and how to place your own code inside a cartridge so the ST will
use it.
WHAT ARE CARTRIDGES?
These days, most programs are stored on disks. However, cartridge programs
are stored in a type of memory chip that you can only read. And ROM (Read
Only Memory) chips won't "forget" the program when power is shut off or
the cartridge is removed.
Unlike programs stored in RAM, cartridge code can't be
hurt or destroyed by accidentally writing to the memory area it lives in.
Also, since the program on a cartridge doesn't have to load in from a disk,
it is instantly available for use as soon as the computer is turned on.
Cartridges are also considerably more rugged than disks. You don't have
to worry quite so much about spilling coffee on them.
Cartridges for the Atari 8-bit computers normally store
8K to 16K programs-unless you use special tricks such as bank-selection.
Atari ST Cartridges can be as large as 128K without any trickery. Cartridge
address space in the 520ST is found in memory beginning at $FA0000 (16384000)
and ending at $FBFFFF (16515071).
There are two types of cartridges for the 520ST, Diagnostic
and Application. Application cartridges have everyday runnable programs
stored on them, and there may be more than one application on each cart.
Diagnostic cartridges, however, are a different breed and we shall examine
them first.
DIAGNOSTICS
Whenever you turn on the power or press [RESET], the operating system
inside the ST checks for a diagnostic cartridge before practically anything
else is done. This allows the diagnostic cartridge to "take over" the entire
system, if desired.
The ST can tell if a diagnostic cartridge is inserted
when the first four bytes of the cartridge (found at $ FA0000) contain
the value $FA52235F. If these four bytes are found, the computer will transfer
control to memory location $FA0004, where you should start placing your
MC68000 machine language instructions.
Address register #6 (a6) will contain a return address
if the cartridge ever wishes to return control to the regular operating
system. The stack pointer will contain garbage. Most of the hardware registers
will not have been touched, and RAM will not have been sized or cleared.
The responsibility for initializing the memory controller is up to you.
APPLICATIONS
If the four bytes at $FA0000 are $ABCDEF42 the ST assumes that an application
cartridge has been inserted, rather than a diagnostic cartridge. The ST
attempts to read in the first "application header," which is found starting
at $FA0004.
An application header contains information about the application(s)
on the cartridge. (See Figure 1.) There can be as many applications
on the cartridge as will fit into its ROM. But there must be one application
header for each application.
The header is set up as follows: CA_NEXT is a long
pointer to the next application's header, if any. If there are no more
application headers on the cartridge, this value is $00000000. CA_INIT
is the long pointer to the application's initialization code. Again, a
value of $00000000 signals that no initialization is needed.
However, if there is initialization code, it is executed
at startup time, as controlled by bits in the high byte of the CA_INIT
longword. These high bits (24... 31) are as follows:
Bit 0 (24)-If set, the initialization code is performed before the initialization of the interrupt vectors and display memory.
Bit 1 (25)-If set, cartridge initialization is performed before GEMDOS is initialized.
Bit 2 (26)-Unused.
Bit 3 (27)-If set, the initialization is performed just before a disk boot is performed. This may change in the ROMmed TOS.
Bit 4 (28)-Unused.
Bit 5 (29)-If set, the application is considered to be a desk accessory.
Bit 6 (30)-If set, the ST will treat the application as a TOS program, and it is assumed that no AES calls will be performed.
Bit 7 (31)-If set, the ST will treat the application as a "TOS-takes parameters" application.
CA_RUN is a long pointer to the application's main entry point. CA_TIME and CA_DATE are DOS-format time and date stamps for tracking when the cartridge was last updated. CA_SIZE is a longword which states the amount of bytes in the application, and CA_NAME is the DOS-acceptable filename of the application ending with a single zero byte. By DOS-acceptable, we mean a maximum of eight characters, a period, and a three-character extender.
ROLLING YOUR OWN
When you decide you want to create your own 520ST cartridge, you'll
need two basic items. At this writing, one is widely available and the
other isn't.
The first is an EPROM burner and EPROM memory chips. An
EPROM burner will "burn" a new program into the EPROM chip, which will
then remember the program (even without power) until it is erased. These
chips may be used over and over.
The other thing you need is the small circuit board you
plug the EPROM chips into and the plastic case that encloses the cartridge.
Both these items are currently pretty rare birds. Antic has been
unable to locate a manufacturer or distributor of these boards in the United
States. In fact, it was all we could do to find just one board for our
own use.
But after stalking the elusive quarry for some time, we
discovered that Computer Support of South San Francisco (an authorized
Atari repair center for Northern California) had a diagnostic cartridge.
We snapped the photo you see here just to prove its existence.
EXIT STAGE LEFT
We have described here all the information you need to decode any existing
cartridge, or create your own. Cartridges are probably the handiest and
most durable form of program storage. But although they aren't as fragile
as disks, they are more expensive to produce. This leaves the basic decision
to you. As for me? Here come the bad guys, pass me the cartridges, Ma .
. . the ST cartridges, that is.