1 <!doctype linuxdoc system>
5 <title>Apple ][ specific information for cc65
6 <author>Ullrich von Bassewitz, <htmlurl url="mailto:uz@cc65.org" name="uz@cc65.org">
10 An overview over the Apple ][ runtime system as it is
11 implemented for the cc65 C compiler.
14 <!-- Table of contents -->
17 <!-- Begin the document -->
21 This file contains an overview of the Apple ][ runtime system
22 as it comes with the cc65 C compiler. It describes the memory layout,
23 Apple ][ specific header files, available drivers, and any
24 pitfalls specific to that platform.
26 Please note that Apple ][ 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
34 <sect>Binary format<p>
36 The standard binary output format generated by the linker for the
37 Apple ][ target is a machine language program with a 4 byte DOS
38 3.3 header. The standard load address is $800.
40 The DOS header is in its own segment named <tt/EXEHDR/. If you don't want the
41 header for some reason, you can change
44 HEADER: start = $0000, size = $4, file = %O;
50 HEADER: start = $0000, size = $4, file = "";
53 in the linker configuration to have the linker remove it.
55 Please note that there is a "Apple ][ ProDOS 8 system program
56 for loading binary programs" available in the cc65 User Contributions section.
57 It adds all benefits of a ProDOS 8 system program to the standard binary
58 program generated by the linker for the Apple ][ target.
62 <sect>Memory layout<p>
64 In the standard setup, cc65 generated programs use the memory from
65 $800 to $95FF, so 35.5K of memory are available. ROM calls are
66 possible without further precautions.
72 The C runtime stack is located at HIMEM and grows downwards, regardless of
73 how your linker config file is setup.
76 The C heap is located at the end of the program and grows towards the C
82 <sect>Platform specific header files<p>
84 Programs containing Apple ][ specific code may use the
85 <tt/apple2.h/ header file.
88 <sect1>Apple ][ specific functions<p>
90 The functions listed below are special for the Apple ][. See
91 the <htmlurl url="funcref.html" name="function reference"> for declaration and
100 <sect1>Hardware access<p>
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.
107 <sect>Loadable drivers<p>
110 <sect1>Graphics drivers<p>
114 <tag><tt/a2.lo.tgi/</tag>
115 This driver was written by Stefan Haubenthal. It features a resolution of
116 40×40 with 16 colors. At the bottom of the screen, 4 additional text
119 <tag><tt/a2.hi.tgi/</tag>
120 This driver was written by Stefan Haubenthal. It features a resolution of
121 280×192 with 6 colors. Note that programs using this driver will have
122 to be linked with <tt/--start-addr $4000/ to reserve the first hires page.
127 <sect1>Extended memory drivers<p>
131 <tag><tt/a2.lc.emd/</tag>
132 Gives access to 12KB RAM (48 pages of 256 bytes each) on the
133 Apple II Language Card. The driver was contributed by Stefan Haubenthal.
134 Note that this driver is incompatible with any DOS using the Language
140 <sect1>Joystick drivers<p>
144 <tag><tt/a2.stdjoy.joy/</tag>
145 Supports up to two standard analog joysticks connected to the game port of
146 the Apple ][.
151 <sect1>Mouse drivers<p>
155 <tag><tt/a2.stdmou.mou/</tag>
156 Driver for the AppleMouse II Card. Searches all Apple II slots
157 for an AppleMouse II Card compatible firmware. The default bounding
158 box is [0..279,0..191]. Programs using this driver will have
159 to be linked with <tt/--start-addr $4000/ to reserve the first hires page
160 if they are intended to run on an Apple ][ (in contrast to
163 Note that the Apple ][ default mouse callbacks support text
169 <sect1>RS232 device drivers<p>
173 <tag><tt/a2.ssc.ser/</tag>
174 Driver for the Apple II Super Serial Card. Supports up to 19200 baud,
175 hardware flow control (RTS/CTS) and interrupt driven receives. Note
176 that because of the peculiarities of the 6551 chip transmits are not
177 interrupt driven, and the transceiver blocks if the receiver asserts
178 flow control because of a full buffer.
180 The driver defaults to slot 2. Call <tt/ser_ioctl(0, <slot>)/ prior to
181 <tt/ser_open/ in order to select a different slot. <tt/ser_ioctl/ succeeds
182 for all Apple II slots, but <tt/ser_open/ fails with
183 <tt/SER_ERR_NO_DEVICE/ if there's no SSC firmware found in the selected slot.
196 <sect1>Passing arguments to the program<p>
198 Command line arguments can be passed to <tt/main()/ after BLOAD. Since this is not
199 supported by BASIC, the following syntax was chosen:
202 ]CALL2048:REM ARG1 " ARG2 IS QUOTED" ARG3 "" ARG5
206 <item>Arguments are separated by spaces.
207 <item>Arguments may be quoted.
208 <item>Leading and trailing spaces around an argument are ignored. Spaces within
209 a quoted argument are allowed.
210 <item>The first argument passed to <tt/main/ is the program name.
211 <item>A maximum number of 10 arguments (including the program name) are
218 The runtime for the Apple ][ uses routines marked as <tt/.CONDES/
219 type 2 for ProDOS interrupt handlers. Such routines must be written as simple
220 machine language subroutines and will be called automatically by the interrupt
221 handler code when they are linked into a program. See the discussion of the
222 <tt/.CONDES/ feature in the <htmlurl url="ca65.html" name="assembler manual">.
226 <sect>Bugs/Feedback<p>
228 If you have problems using the library, if you find any bugs, or if you're
229 doing something interesting with it, I would be glad to hear from you. Feel
230 free to contact me by email (<htmlurl url="mailto:uz@cc65.org"
231 name="uz@cc65.org">).
237 This software is provided 'as-is', without any expressed or implied
238 warranty. In no event will the authors be held liable for any damages
239 arising from the use of this software.
241 Permission is granted to anyone to use this software for any purpose,
242 including commercial applications, and to alter it and redistribute it
243 freely, subject to the following restrictions:
246 <item> The origin of this software must not be misrepresented; you must not
247 claim that you wrote the original software. If you use this software
248 in a product, an acknowledgment in the product documentation would be
249 appreciated but is not required.
250 <item> Altered source versions must be plainly marked as such, and must not
251 be misrepresented as being the original software.
252 <item> This notice may not be removed or altered from any source