Skip to content

Latest commit

 

History

History
131 lines (97 loc) · 4.39 KB

a5200.md

File metadata and controls

131 lines (97 loc) · 4.39 KB

Atari 5200 console support

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:

Key Controller 1 Controller 2 Controller 3 Controller 4
0 0 16 32 48
1 1 17 33 49
2 2 18 34 50
3 3 19 35 51
4 4 20 36 52
5 5 21 37 53
6 6 22 38 54
7 7 23 39 55
8 8 24 40 56
9 9 25 41 57
* 10 26 42 58
# 11 27 43 59
Start 12 28 44 60
Pause 13 29 45 61
Reset 14 30 46 62

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 $D200 to $D800) and GTIA (from $D000 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:

Address Register
$C000 Player 0 horizontal pos.
$C001 Player 1 horizontal pos.
$C002 Player 2 horizontal pos.
$C003 Player 3 horizontal pos.
$C004 Missile 0 horizontal pos.
$C005 Missile 1 horizontal pos.
$C006 Missile 2 horizontal pos.
$C007 Missile 3 horizontal pos.
$C012 Color of player/missile 0
$C013 Color of player/missile 1
$C014 Color of player/missile 2
$C015 Color of player/missile 3
$C016 Color register 0
$C017 Color register 1
$C018 Color register 2
$C019 Color register 3
$C01A Color of background