Atari 5200 console support

July 3, 2022 ยท View on GitHub

Note: This is an appendix to the main FastBasic manual.

The FastBasic cross compiler supports the Atari 5200 console as a target, allowing to port programs from the Atari 8-bit computers with minor modifications.

Controllers Support

The Atari 5200 does not have standard digital joysticks, console keys and keyboard, all controllers are analog and have a keypad.

FastBasic emulates the standard 8-bit joystick and keyboard using the controllers for easy porting:

  • The STICK() and STRIG() functions return the same values as in the computers.

  • The PTRIG() function returns the state of the secondary button for the controllers.

  • The PADDLE() functions return the analog value of each controller axis, so PADDLE(0) and PADDLE(1) are the horizontal and vertical axis of the first controller respectively, and so on with the next 4 controllers.

  • The GET statement waits for a key pressed on any controller, the value returned is from 0 to 15 for the first controller, 16 to 31 for the second, etc.

  • The KEY() function returns the last pressed key on any controller, or 0 if no key was pressed.

The values returned by GET are given in the following table, note that you can and the number with 15 to get the number of the first controller, this is useful to accept keys from all controllers in your code:

KeyController 1Controller 2Controller 3Controller 4
00163248
11173349
22183450
33193551
44203652
55213753
66223854
77233955
88244056
99254157
*10264258
#11274359
Start12284460
Pause13294561
Reset14304662

The value returned by the KEY() function is always 255 minus the numbers above, for example, when pressing the key 4 in the second controller, KEY() will return 255-20 = 235.

RAM Usage

The Atari 5200 console has only 16kb of RAM, this means that you have to minimize RAM usage in your program.

For compatibility with most programs, DLI and DATA statements are stored in RAM, this means that you should put big DATA statements in ROM by using the construct:

DATA mydata() BYTE ROM = 1, 2, 3, ....
DATA font() BYTEFILE ROM "myfont.fnt"

Note that DATA in ROM can't be modified at runtime, so you must select the type appropriately.

Operating System support

The Atari 5200 console lacks the OS ROM of the Atari 8-bit computers, so all the functionality that depends on the OS must be reimplemented.

Currently, the target lacks:

  • Floating point support: only integer operations are supported.
  • Graphics modes: the included runtime only implements graphic modes 0, 1, 2, 7 to 13 and 15.
  • Text window: the graphic modes with a text window are not implemented.
  • Graphics statements: only PLOT, DRAWTO and LOCATE are implemented, there is no FILLTO command.
  • Input/Output: Only the screen output an keypad input are supported, there is no I/O channels, OPEN or XIO.

Hardware Registers

The Atari 5200 changes the location of hardware registers for POKEY (from D200toD200 to D800) and GTIA (from D000toD000 to C000), so direct POKEs to memory must be changed.

Also, DLI support also needs to change the address of color and P/M registers, you can use this table for useful registers:

AddressRegister
$C000Player 0 horizontal pos.
$C001Player 1 horizontal pos.
$C002Player 2 horizontal pos.
$C003Player 3 horizontal pos.
$C004Missile 0 horizontal pos.
$C005Missile 1 horizontal pos.
$C006Missile 2 horizontal pos.
$C007Missile 3 horizontal pos.
$C012Color of player/missile 0
$C013Color of player/missile 1
$C014Color of player/missile 2
$C015Color of player/missile 3
$C016Color register 0
$C017Color register 1
$C018Color register 2
$C019Color register 3
$C01AColor of background