]> git.sur5r.net Git - cc65/blob - doc/apple2.sgml
359793077ec86ae153f8d7d360d09abb5b8feb68
[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 it's 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;8E00, so 33.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 &dollar;8DFF and growing downwards.
67
68   <tag/Heap/
69   The C heap is located at the end of the program and grows towards the C
70   runtime stack.
71 </descrip><p>
72
73
74
75 <sect>Platform specific header files<p>
76
77 Programs containing Apple&nbsp;&rsqb;&lsqb; specific code may use the
78 <tt/apple2.h/ header file.
79
80
81 <sect1>Apple&nbsp;&rsqb;&lsqb; specific functions<p>
82
83 The functions listed below are special for the Apple&nbsp;&rsqb;&lsqb;. See
84 the <htmlurl url="funcref.html" name="function reference"> for declaration and
85 usage.
86
87 <itemize>
88 <item>get_ostype
89 </itemize>
90
91
92
93 <sect1>Hardware access<p>
94
95 There's currently no support for direct hardware access. This does not mean
96 you cannot do it, it just means that there's no help.
97
98
99
100 <sect>Loadable drivers<p>
101
102 <em>Note:</em> Since the Apple&nbsp;&rsqb;&lsqb; doesn't have working disk I/O
103 (see <ref id="limitations" name="section &quot;Limitations&quot;">), the
104 available drivers cannot be loaded at runtime (so the term "loadable drivers"
105 is somewhat misleading). Instead, the drivers have to be converted using the
106 <htmlurl url="co65.html" name="co65 utility"> and statically linked. While
107 this may seem overhead, it has two advantages:
108
109 <enum>
110 <item>The interface is identical to the one used for other platforms
111       and to the one for the Apple&nbsp;&rsqb;&lsqb; once it has disk I/O.
112 <item>Once disk I/O is available, existing code can be changed to load drivers
113       at runtime with almost no effort.
114 </enum>
115
116
117
118 <sect1>Graphics drivers<p>
119
120 <em>Note:</em> Since memory for the graphics has to be allocated, programs
121 using graphics drivers will have to be linked using a special linker
122 configuration. See the <tt/apple2-tgi.cfg/ file in the documentation
123 directory, and the <htmlurl url="ld65.html" name="linker documentation"> on
124 how to use it.
125
126 <descrip>
127
128   <tag><tt/a2-lo.tgi/</tag>
129   This driver features a resolution of 40x40 with 16 colors. At the bottom of
130   the screen, 4 additional text lines are available.
131
132   <tag><tt/a2-hi.tgi/</tag>
133   This driver features a resolution of 280x192 with 6 colors.
134
135 </descrip><p>
136
137
138 <sect1>Extended memory drivers<p>
139
140 No extended memory drivers are currently available for the 
141 Apple&nbsp;&rsqb;&lsqb;.
142
143
144
145 <sect1>Joystick drivers<p>
146
147 <descrip>
148
149   <tag><tt/a2-stdjoy.joy/</tag>
150   Supports up to two standard joysticks connected to the joysticks port of
151   the Apple&nbsp;&rsqb;&lsqb;.
152
153 </descrip><p>
154
155
156
157 <sect1>Mouse drivers<p>
158
159 Currently no drivers available (in fact, the API for loadable mouse drivers
160 does not exist).
161
162
163 <sect1>RS232 device drivers<p>
164
165 No serial drivers are currently available for the Apple&nbsp;&rsqb;&lsqb;.
166
167
168
169 <sect>Limitations<label id="limitations"><p>
170
171 <sect1>Disk I/O<p>
172
173 The existing library for the Apple&nbsp;&rsqb;&lsqb; doesn't implement C file
174 I/O. There are two hacks for the <tt/read()/ and <tt/write()/ routines in
175 place, which will make functions work that read from or write to <tt/stdout/
176 (like <tt/printf()/). However, these functions have some shortcomings which
177 won't be fixed, because they're going to be replaced anyway.
178
179 To be more concrete, this limitation means that you cannot use any of the
180 following functions (and a few others):
181
182 <itemize>
183 <item>fclose
184 <item>fopen
185 <item>fread
186 <item>fprintf
187 <item>fputc
188 <item>fscanf
189 <item>fwrite
190 <item>...
191 </itemize>
192
193
194 <sect>Other hints<p>
195
196 <sect1>Passing arguments to the program<p>
197
198 Command line argument passing is currently not supported for the
199 Apple&nbsp;&rsqb;&lsqb;.
200
201
202
203 <sect>Bugs/Feedback<p>
204
205 If you have problems using the library, if you find any bugs, or if you're
206 doing something interesting with it, I would be glad to hear from you. Feel
207 free to contact me by email (<htmlurl url="mailto:uz@cc65.org"
208 name="uz@cc65.org">).
209
210
211
212 <sect>License<p>
213
214 This software is provided 'as-is', without any expressed or implied
215 warranty.  In no event will the authors be held liable for any damages
216 arising from the use of this software.
217
218 Permission is granted to anyone to use this software for any purpose,
219 including commercial applications, and to alter it and redistribute it
220 freely, subject to the following restrictions:
221
222 <enum>
223 <item>  The origin of this software must not be misrepresented; you must not
224         claim that you wrote the original software. If you use this software
225         in a product, an acknowledgment in the product documentation would be
226         appreciated but is not required.
227 <item>  Altered source versions must be plainly marked as such, and must not
228         be misrepresented as being the original software.
229 <item>  This notice may not be removed or altered from any source
230         distribution.
231 </enum>
232
233 </article>
234
235
236