]> git.sur5r.net Git - cc65/blob - doc/apple2.sgml
Another fix from Oliver Schmidt
[cc65] / doc / apple2.sgml
1 <!doctype linuxdoc system>
2
3 <article>
4
5 <title>Apple&nbsp;&rsqb;&lsqb; specific information for cc65
6 <author>Ullrich von Bassewitz, <htmlurl url="mailto:uz@cc65.org" name="uz@cc65.org">
7 <date>2003-12-16
8
9 <abstract>
10 An overview over the Apple&nbsp;&rsqb;&lsqb; runtime system as it is
11 implemented for the cc65 C compiler.
12 </abstract>
13
14 <!-- Table of contents -->
15 <toc>
16
17 <!-- Begin the document -->
18
19 <sect>Overview<p>
20
21 This file contains an overview of the Apple&nbsp;&rsqb;&lsqb; runtime system
22 as it comes with the cc65 C compiler. It describes the memory layout,
23 Apple&nbsp;&rsqb;&lsqb; specific header files, available drivers, and any
24 pitfalls specific to that platform.
25
26 Please note that Apple&nbsp;&rsqb;&lsqb; specific functions are just mentioned
27 here, they are described in detail in the separate <htmlurl url="funcref.html"
28 name="function reference">. Even functions marked as "platform dependent" may
29 be available on more than one platform. Please see the function reference for
30 more information.
31
32
33 <sect>Binary format<p>
34
35 The standard binary output format generated by the linker for the
36 Apple&nbsp;&rsqb;&lsqb; target is a machine language program with a 4 byte DOS
37 3.3 header. The standard load address is &dollar;800.
38
39 The DOS header is in its own segment named <tt/EXEHDR/. If you don't want the
40 header for some reason, you can change
41
42 <verb>
43     HEADER: start = $0000, size = $4, file = %O;
44 </verb>
45
46 to
47
48 <verb>
49     HEADER: start = $0000, size = $4, file = "";
50 </verb>
51
52 in the linker configuration to have the linker remove it.
53
54
55
56 <sect>Memory layout<p>
57
58 In the standard setup, cc65 generated programs use the memory from
59 &dollar;800 to &dollar;9600, so 35.5K of memory (including the stack) is
60 available. ROM calls are possible without further precautions.
61
62 Special locations:
63
64 <descrip>
65   <tag/Stack/
66   The C runtime stack is located at HIMEM and grows downwards, regardless of
67   how your linker config file is setup.
68
69   <tag/Heap/
70   The C heap is located at the end of the program and grows towards the C
71   runtime stack.
72 </descrip><p>
73
74
75
76 <sect>Platform specific header files<p>
77
78 Programs containing Apple&nbsp;&rsqb;&lsqb; specific code may use the
79 <tt/apple2.h/ header file.
80
81
82 <sect1>Apple&nbsp;&rsqb;&lsqb; specific functions<p>
83
84 The functions listed below are special for the Apple&nbsp;&rsqb;&lsqb;. See
85 the <htmlurl url="funcref.html" name="function reference"> for declaration and
86 usage.
87
88 <itemize>
89 <item>get_ostype
90 </itemize>
91
92
93
94 <sect1>Hardware access<p>
95
96 There's currently no support for direct hardware access. This does not mean
97 you cannot do it, it just means that there's no help.
98
99
100
101 <sect>Loadable drivers<p>
102
103 <em>Note:</em> Since the Apple&nbsp;&rsqb;&lsqb; doesn't have working disk I/O
104 (see <ref id="limitations" name="section &quot;Limitations&quot;">), the
105 available drivers cannot be loaded at runtime (so the term "loadable drivers"
106 is somewhat misleading). Instead, the drivers have to be converted using the
107 <htmlurl url="co65.html" name="co65 utility"> and statically linked. While
108 this may seem overhead, it has two advantages:
109
110 <enum>
111 <item>The interface is identical to the one used for other platforms
112       and to the one for the Apple&nbsp;&rsqb;&lsqb; once it has disk I/O.
113 <item>Once disk I/O is available, existing code can be changed to load drivers
114       at runtime with almost no effort.
115 </enum>
116
117
118
119 <sect1>Graphics drivers<p>
120
121 <em>Note:</em> Since memory for the high resolution graphics has to be allocated,
122 programs using graphics drivers will have to be linked using a special linker
123 configuration. See the <tt/apple2-tgi.cfg/ file in the documentation
124 directory, and the <htmlurl url="ld65.html" name="linker documentation"> on
125 how to use it.
126
127 <descrip>
128
129   <tag><tt/a2.lo.tgi/</tag>
130   This driver was written by Stefan Haubenthal. It features a resolution of
131   40&times;40 with 16 colors. At the bottom of the screen, 4 additional text lines
132   are available.
133
134   <tag><tt/a2.hi.tgi/</tag>
135   This driver was written by Stefan Haubenthal. It features a resolution of
136   280&times;192 with 6 colors.
137
138 </descrip><p>
139
140
141 <sect1>Extended memory drivers<p>
142
143 <descrip>
144
145   <tag><tt/a2.lc.emd/</tag>
146   Gives access to 12KB RAM (48 pages of 256 bytes each) on the
147   Apple&nbsp;&rsqb;&lsqb; language card. The driver was contributed by
148   Stefan Haubenthal. Note: This driver is incompatible with any DOS using
149   the language card memory!
150
151 </descrip><p>
152
153
154
155 <sect1>Joystick drivers<p>
156
157 <descrip>
158
159   <tag><tt/a2.stdjoy.joy/</tag>
160   Supports up to two standard analog joysticks connected to the game port of
161   the Apple&nbsp;&rsqb;&lsqb;.
162
163 </descrip><p>
164
165
166
167 <sect1>Mouse drivers<p>
168
169 Currently no drivers available (in fact, the API for loadable mouse drivers
170 does not exist).
171
172
173 <sect1>RS232 device drivers<p>
174
175 No serial drivers are currently available for the Apple&nbsp;&rsqb;&lsqb;.
176
177
178
179 <sect>Limitations<label id="limitations"><p>
180
181 <sect1>Disk I/O<p>
182
183 The existing library for the Apple&nbsp;&rsqb;&lsqb; doesn't implement C file
184 I/O. There are two hacks for the <tt/read()/ and <tt/write()/ routines in
185 place, which will make functions work that read from or write to <tt/stdout/
186 (like <tt/printf()/). However, these functions have some shortcomings which
187 won't be fixed, because they're going to be replaced anyway.
188
189 To be more concrete, this limitation means that you cannot use any of the
190 following functions (and a few others):
191
192 <itemize>
193 <item>fclose
194 <item>fopen
195 <item>fread
196 <item>fprintf
197 <item>fputc
198 <item>fscanf
199 <item>fwrite
200 <item>...
201 </itemize>
202
203
204 <sect>Other hints<p>
205
206 <sect1>Passing arguments to the program<p>
207
208 Command line arguments can be passed to <tt/main()/. Since this is not
209 supported by BASIC, the following syntax was choosen:
210
211 <tscreen><verb>
212     CALL2048:REM,ARG1," ARG2", ARG 3,, ARG5, ...
213 </verb></tscreen>
214
215 <enum>
216 <item>Arguments are separated by commas.
217 <item>There must be a comma after the first <tt/REM/.
218 <item>Leading spaces are ignored; trailing spaces are included unless the
219       argument was quoted.
220 <item>The first argument passed to <tt/main/ is the program name.
221 </enum>
222
223
224 <sect1>Function keys<p>
225
226 These are defined to be OpenApple + number key.
227
228
229
230 <sect>Bugs/Feedback<p>
231
232 If you have problems using the library, if you find any bugs, or if you're
233 doing something interesting with it, I would be glad to hear from you. Feel
234 free to contact me by email (<htmlurl url="mailto:uz@cc65.org"
235 name="uz@cc65.org">).
236
237
238
239 <sect>License<p>
240
241 This software is provided 'as-is', without any expressed or implied
242 warranty.  In no event will the authors be held liable for any damages
243 arising from the use of this software.
244
245 Permission is granted to anyone to use this software for any purpose,
246 including commercial applications, and to alter it and redistribute it
247 freely, subject to the following restrictions:
248
249 <enum>
250 <item>  The origin of this software must not be misrepresented; you must not
251         claim that you wrote the original software. If you use this software
252         in a product, an acknowledgment in the product documentation would be
253         appreciated but is not required.
254 <item>  Altered source versions must be plainly marked as such, and must not
255         be misrepresented as being the original software.
256 <item>  This notice may not be removed or altered from any source
257         distribution.
258 </enum>
259
260 </article>
261
262
263