Atari 2600 specific information for cc65

Florent Flament


An overview over the Atari 2600 runtime system as it is implemented for the cc65 C compiler.

1. Overview

2. Binary format

3. Memory layout

4. Start-up condition

5. Platform specific header files

6. Loadable drivers

7. Limitations

8. Other hints

9. License


1. Overview

This file contains an overview of the Atari 2600 runtime system as it comes with the cc65 C compiler. It describes the memory layout, Atari 2600 specific header files and any pitfalls specific to that platform.

2. Binary format

The default binary output format generated by the linker for the Atari 2600 target is a 4K cartridge image.

3. Memory layout

cc65 generated programs with the default setup can use RAM from $0080 to $00FF - __STACKSIZE__, where __STACKSIZE__ is the size of the system stack with a default value of 16 bytes. The size of the system stack can be customized by defining the __STACKSIZE__ linker variable.

Special locations:

Stack

The C runtime stack is located at $00FF - __STACKSIZE__ and growing downwards.

Heap

The C heap is located at $0080 and grows upwards.

4. Start-up condition

When powered-up, the Atari 2600 TIA registers contain random values. During the initialization phase, the start-up code needs to initialize the TIA registers to sound values (or else the console has an unpredictable behavior). In this implementation, zeros are written to all of TIA registers during the start-up phase.

Note that RIOT registers (mostly timers) are left uninitialized, as they don't have any consequence on the console behavior.

5. Platform specific header files

Programs containing Atari 2600 specific code may use the atari2600.h header file.

The following pseudo variables declared in the atari2600.h header file allow access to the Atari 2600 TIA & RIOT chips registers.

TIA

The TIA structure allows read/write access to the Atari 2600 TIA chip registers. See the _tia.h header file located in the include directory for the declaration of the structure. Also refer to the Stella Programmer's Guide by Steve Wright for a detailed description of the chip and its registers.

RIOT

The RIOT structure allows read/write access to the Atari 2600 RIOT chip registers. See the _riot.h header file located in the include directory for the declaration of the structure. Also refer to the Stella Programmer's Guide by Steve Wright for a detailed description of the chip and its registers.

6. Loadable drivers

There are no drivers for the Atari 2600.

7. Limitations

TBD

8. Other hints

One may write a custom linker configuration file to tune the memory layout of a program. See the atari2600.cfg file in the cfg directory as a starting point.

9. License

This software is provided 'as-is', without any expressed or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software.

Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:

  1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
  2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
  3. This notice may not be removed or altered from any source distribution.