-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathatari7800.html
More file actions
206 lines (148 loc) · 6.88 KB
/
atari7800.html
File metadata and controls
206 lines (148 loc) · 6.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML>
<HEAD>
<LINK REL="stylesheet" TYPE="text/css" HREF="doc.css">
<META NAME="GENERATOR" CONTENT="LinuxDoc-Tools 0.9.83">
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<TITLE>Atari 7800 specific information for cc65</TITLE>
</HEAD>
<BODY>
<H1>Atari 7800 specific information for cc65</H1>
<H2>
<A HREF="mailto:karri@sipo.fi">Karri Kaksonen</A><BR></H2>
<HR>
<EM>An overview over the Atari 7800 runtime system as it is implemented
for the cc65 C compiler.</EM>
<HR>
<P>
<H2><A NAME="toc1">1.</A> <A HREF="atari7800.html#s1">Overview</A></H2>
<P>
<H2><A NAME="toc2">2.</A> <A HREF="atari7800.html#s2">Binary format</A></H2>
<P>
<H2><A NAME="toc3">3.</A> <A HREF="atari7800.html#s3">A78 header</A></H2>
<P>
<H2><A NAME="toc4">4.</A> <A HREF="atari7800.html#s4">Encryption</A></H2>
<P>
<H2><A NAME="toc5">5.</A> <A HREF="atari7800.html#s5">Memory layout</A></H2>
<P>
<H2><A NAME="toc6">6.</A> <A HREF="atari7800.html#s6">Start-up condition</A></H2>
<P>
<H2><A NAME="toc7">7.</A> <A HREF="atari7800.html#s7">Platform specific header files</A></H2>
<P>
<H2><A NAME="toc8">8.</A> <A HREF="atari7800.html#s8">Loadable drivers</A></H2>
<P>
<H2><A NAME="toc9">9.</A> <A HREF="atari7800.html#s9">Limitations</A></H2>
<P>
<H2><A NAME="toc10">10.</A> <A HREF="atari7800.html#s10">Other hints</A></H2>
<P>
<H2><A NAME="toc11">11.</A> <A HREF="atari7800.html#s11">License</A></H2>
<HR>
<H2><A NAME="s1">1.</A> <A HREF="#toc1">Overview</A></H2>
<P>This file contains an overview of the Atari 7800 runtime system as it
comes with the cc65 C compiler. It describes the memory layout, Atari
7800 specific header files and any pitfalls specific to that platform.</P>
<H2><A NAME="s2">2.</A> <A HREF="#toc2">Binary format</A></H2>
<P>The default binary output format generated by the linker for the Atari
7800 target is a 48K cartridge image.</P>
<H2><A NAME="s3">3.</A> <A HREF="#toc3">A78 header</A></H2>
<P>There is lots of different cart hardware available for the atari7800.
Some carts have ROM, RAM, sound hardware, non-volatile high score chips.
In order to know what kind of hardware the cart build requires there is
a header file of 128 bytes in front of the binary.</P>
<P>The default build creates a cart file for a 48K rom cart without any
extra features like the pokey audio chip or extra RAM.</P>
<P>In order to make cc65 more user friendly the build will add the a78
header automatically. This allows you to run the binary on emulators
and flash carts on the real console.</P>
<H2><A NAME="s4">4.</A> <A HREF="#toc4">Encryption</A></H2>
<P>In order to boot the game in a mode that supports atari7800 functions
the cart must be encrypted after the linking phase.
There is a program called sign7800 that can be used to sign the cart.
The encryption is not required for running the cart on emulators.
You can also run atari2600 games without encryption.</P>
<H2><A NAME="s5">5.</A> <A HREF="#toc5">Memory layout</A></H2>
<P>cc65 generated programs with the default setup can use RAM from
from $1800 to $203f.
The 4k RAM is then mapped to zero page area.
$2040 to $20ff is visible as zero page.
After that we have a vero small RAM area that is unused.
$2100 to $213f.
Then we mirror a second block from the RAM to become the hardware stack.
This would be from $2140 to $21ff.</P>
<P>The C-stack starts at $2800 and it can grow down to $2200.</P>
<P>size of the system stack can be customized by defining the
__STACKSIZE__ linker variable.</P>
<P>Special locations:</P>
<P>
<DL>
<DT><B>Stack</B><DD>
<P>The C runtime stack is located at $2800 -
__STACKSIZE__ and growing downwards.</P>
<DT><B>Heap</B><DD>
<P>The C heap is located at $2200 and grows upwards.</P>
</DL>
</P>
<H2><A NAME="s6">6.</A> <A HREF="#toc6">Start-up condition</A></H2>
<P>When powered-up, the Atari 7800 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.</P>
<P>Note that RIOT registers (mostly timers) are left uninitialized, as
they don't have any consequence on the console behavior.</P>
<H2><A NAME="s7">7.</A> <A HREF="#toc7">Platform specific header files</A></H2>
<P>Programs containing Atari 7800 specific code may use the
<CODE>atari7800.h</CODE> header file.</P>
<P>The following pseudo variables declared in the <CODE>atari7800.h</CODE> header
file allow access to the Atari 7800 TIA, MARIA & RIOT chips registers.</P>
<P>
<DL>
<DT><B><CODE>TIA</CODE></B><DD>
<P>The <CODE>TIA</CODE> structure allows read/write access
to the Atari 7800 TIA chip registers. See the <CODE>_tia.h</CODE> 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.</P>
<DT><B><CODE>RIOT</CODE></B><DD>
<P>The <CODE>RIOT</CODE> structure allows read/write
access to the Atari 7800 RIOT chip registers. See the
<CODE>_riot.h</CODE> 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.</P>
<DT><B><CODE>MARIA</CODE></B><DD>
<P>The <CODE>MARIA</CODE> structure allows read/write
access to the Atari 7800 MARIA chip registers. See the
<CODE>_maria.h</CODE> header file located in the include directory for the
declaration of the structure.</P>
</DL>
</P>
<H2><A NAME="s8">8.</A> <A HREF="#toc8">Loadable drivers</A></H2>
<P>There are no drivers for the Atari 7800.</P>
<H2><A NAME="s9">9.</A> <A HREF="#toc9">Limitations</A></H2>
<P>TBD</P>
<H2><A NAME="s10">10.</A> <A HREF="#toc10">Other hints</A></H2>
<P>One may write a custom linker configuration file to tune the memory
layout of a program. See the <CODE>atari7800.cfg</CODE> file in the cfg
directory as a starting point.</P>
<H2><A NAME="s11">11.</A> <A HREF="#toc11">License</A></H2>
<P>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.</P>
<P>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:</P>
<P>
<OL>
<LI> 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.</LI>
<LI> Altered source versions must be plainly marked as such, and must not
be misrepresented as being the original software.</LI>
<LI> This notice may not be removed or altered from any source
distribution.</LI>
</OL>
</P>
</BODY>
</HTML>