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