1 <!doctype linuxdoc system>
5 <title>enhanced Apple //e specific information for cc65
6 <author>Ullrich von Bassewitz, <htmlurl url="mailto:uz@cc65.org" name="uz@cc65.org">
10 An overview over the enhanced Apple //e 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 enhanced Apple //e runtime system
22 as it comes with the cc65 C compiler. It describes the memory layout,
23 enhanced Apple //e specific header files, available drivers, and any
24 pitfalls specific to that platform.
26 Please note that enhanced Apple //e 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 enhanced Apple //e target is a machine language program with a 4 byte DOS
38 3.3 header containing the load address and load size. The standard load address
41 The DOS 3.3 header is in its own segment named <tt/EXEHDR/. If you don't want
42 the header for some reason, you can change
45 HEADER: start = $0000, size = $0004, file = %O;
51 HEADER: start = $0000, size = $0004, file = "";
54 in the linker configuration to have the linker remove it.
56 <bf/AppleCommander 1.3.5/ or later (available at <url
57 url="http://applecommander.sourceforge.net/">) includes an option <tt/-cc65/
58 that allows to put binary files with the DOS 3.3 header onto disk images
59 containing either DOS 3.3 or ProDOS 8.
61 Please note that there is an <bf/Apple ][ ProDOS 8 system program
62 for loading binary programs/ available in the cc65 User Contributions section.
63 It adds all benefits of a ProDOS 8 system program to the standard binary
64 program generated by the linker for the enhanced Apple //e target.
68 <sect>Memory layout<p>
70 In the standard setup, cc65 generated programs use the memory from
71 $803 to $95FF, so 35.5KB of RAM are available. While running
72 <tt/main()/ the Language Card bank 2 is enabled for read access. However while
73 running module constructors/destructors the Language Card is disabled.
79 The C runtime stack is located at HIMEM and grows downwards, regardless of
80 how your linker config file is setup.
83 The C heap is located at the end of the program and grows towards the C
87 Enabling the Language Card allows to use it as additional memory for executable
88 code. Actually doing so requires either to compile code with the option
89 <tt/--code-name HIGHCODE/ or to use <tt/#pragma codeseg ("HIGHCODE")/.
91 The amount of memory available in the Language Card for executable code depends
92 on the chosen program environment. A plain vanilla ProDOS 8 doesn't actually
93 use the Language Card bank 2 memory from $D400 to $DFFF.
94 Therefore the builtin linker configuration defines these 3KB as <tt/LC/ memory
95 area for executable code.
97 A plain vanilla DOS 3.3 doesn't make use of the Language Card at all. So you
101 LC: start = $D400, size = $0C00, define = yes;
107 LC: start = $D000, size = $3000, define = yes;
110 in the linker configuration to define the whole 12KB Language Card address
111 space as memory area for executable code.
115 <sect>Platform specific header files<p>
117 Programs containing enhanced Apple //e specific code may use the
118 <tt/apple2enh.h/ header file.
121 <sect1>enhanced Apple //e specific functions<p>
123 The functions listed below are special for the enhanced Apple //e. See
124 the <htmlurl url="funcref.html" name="function reference"> for declaration and
130 <item>rebootafterexit
137 <sect1>Hardware access<p>
139 There's currently no support for direct hardware access. This does not mean
140 you cannot do it, it just means that there's no help.
144 <sect>Loadable drivers<p>
147 <sect1>Graphics drivers<p>
151 <tag><tt/a2e.lo.tgi/</tag>
152 This driver features a resolution of 40×48 with 16 colors.
154 <tag><tt/a2e.hi.tgi/</tag>
155 This driver features a resolution of 280×192 with 8 colors and two
156 hires pages. Note that programs using this driver will have to be linked
157 with <tt/--start-addr $4000/ to reserve the first hires page or with
158 <tt/--start-addr $6000/ to reserve both hires pages.
160 In memory constrained situations the memory from $803 to $1FFF
161 can be made available to a program by executing <tt/_heapadd ((void *) 0x0803, 0x17FD);/
162 at the beginning of <tt/main()/. Doing so is beneficial even if the program
163 doesn't use the the heap explicitly because loading the driver (and in fact
164 already opening the driver file) uses the heap implicitly.
169 <sect1>Extended memory drivers<p>
173 <tag><tt/a2e.auxmem.emd/</tag>
174 Gives access to 47,5 KB RAM (190 pages of 256 bytes each) on an Extended
177 Note that this driver doesn't check for the actual existence of the memory
178 and that it doesn't check for ProDOS 8 RAM disk content!
183 <sect1>Joystick drivers<p>
187 <tag><tt/a2e.stdjoy.joy/</tag>
188 Supports up to two standard analog joysticks connected to the game port of
189 the enhanced Apple //e.
194 <sect1>Mouse drivers<p>
198 <tag><tt/a2e.stdmou.mou/</tag>
199 Driver for the AppleMouse II Card. Searches all Apple II slots
200 for an AppleMouse II Card compatible firmware. The default bounding
201 box is [0..279,0..191].
203 Note that the enhanced Apple //e default mouse callbacks support
209 <sect1>RS232 device drivers<p>
213 <tag><tt/a2e.ssc.ser/</tag>
214 Driver for the Apple II Super Serial Card. Supports up to 19200 baud,
215 hardware flow control (RTS/CTS) and interrupt driven receives. Note
216 that because of the peculiarities of the 6551 chip transmits are not
217 interrupt driven, and the transceiver blocks if the receiver asserts
218 flow control because of a full buffer.
220 The driver defaults to slot 2. Call <tt/ser_ioctl(0, <slot>)/ prior to
221 <tt/ser_open()/ in order to select a different slot. <tt/ser_ioctl()/
222 succeeds for all Apple II slots, but <tt/ser_open()/ fails with
223 <tt/SER_ERR_NO_DEVICE/ if there's no SSC firmware found in the selected slot.
234 Although the standard binaries generated by the linker for the enhanced Apple //e
235 generally run both on DOS 3.3 (with Applesoft BASIC) and on ProDOS 8 (with
236 BASIC.SYSTEM) there are some limitations for DOS 3.3:
240 <tag>Disk File I/O</tag>
241 There's no disk file I/O support. Any attempt to use it yields an error with
242 <tt/errno/ set to <tt/ENOSYS/. This implicitly means that loadable drivers
243 are in general not functional as they depend on disk file I/O. However they
244 may be converted to statically linked drivers using the co65 object-file
247 <tag>Interrupts</tag>
248 There's no <tt/interruptor/ support. Any attempt to use it yields the message
249 'Failed to alloc interrupt' on program startup. This implicitly means that
250 <tt/a2e.stdmou.mou/ and <tt/a2e.ssc.ser/ are not functional as they depend on
258 Although <htmlurl url="dio.html" name="DIO"> generally works with all ProDOS 8
259 devices, the function <htmlurl url="dio-3.html" name="dio_query_sectcount()">
260 simply always return 280 (which is only correct for a 140KB disk).
263 <sect1>Direct console I/O<p>
268 The enhanced Apple //e has no color text mode. Therefore the functions
269 <htmlurl url="funcref-205.html" name="textcolor()">,
270 <htmlurl url="funcref-68.html" name="bgcolor()"> and
271 <htmlurl url="funcref-69.html" name="bordercolor()"> have no effect.
274 The enhanced Apple //e has no hardware cursor. Therefore the function
275 <htmlurl url="funcref-88.html" name="cursor()"> has no effect.
284 <sect1>Passing arguments to the program<p>
286 Command line arguments can be passed to <tt/main()/ after BLOAD. Since this is not
287 supported by BASIC, the following syntax was chosen:
290 ]CALL2051:REM ARG1 " ARG2 IS QUOTED" ARG3 "" ARG5
294 <item>Arguments are separated by spaces.
295 <item>Arguments may be quoted.
296 <item>Leading and trailing spaces around an argument are ignored. Spaces within
297 a quoted argument are allowed.
298 <item>The first argument passed to <tt/main/ is the program name.
299 <item>A maximum number of 10 arguments (including the program name) are
304 <sect1>Function keys<p>
306 These are defined to be OpenApple + number key.
311 The runtime for the enhanced Apple //e uses routines marked as <tt/.CONDES/
312 type <tt/interruptor/ for ProDOS 8 interrupt handlers. Such routines must be
313 written as simple machine language subroutines and will be called automatically
314 by the interrupt handler code when they are linked into a program. See the
315 discussion of the <tt/.CONDES/ feature in the <htmlurl url="ca65.html"
316 name="assembler manual">.
321 The function <htmlurl url="dio-1.html" name="dio_open()"> has the single parameter
322 <tt/drive_id/ to identify the drive to be opened. Therefore an Apple II
323 slot and drive pair is mapped to that <tt/drive_id/ according to the formula
326 drive_id = (slot * 2) + (drive - 1)
329 so that for example slot 6 drive 1 is mapped to <tt/drive_id/ 12.
331 The function <htmlurl url="dio-1.html" name="dio_open()"> succeeds only if a
332 formatted disk is present in the drive. However intentionally no check is
333 performed on the presence of a ProDOS 8 disk. Therefore access to all standard
334 16-sector disks (as for instance DOS 3.3) is possible.
338 <sect>Bugs/Feedback<p>
340 If you have problems using the library, if you find any bugs, or if you're
341 doing something interesting with it, I would be glad to hear from you. Feel
342 free to contact me by email (<htmlurl url="mailto:uz@cc65.org"
343 name="uz@cc65.org">).
349 This software is provided 'as-is', without any expressed or implied
350 warranty. In no event will the authors be held liable for any damages
351 arising from the use of this software.
353 Permission is granted to anyone to use this software for any purpose,
354 including commercial applications, and to alter it and redistribute it
355 freely, subject to the following restrictions:
358 <item> The origin of this software must not be misrepresented; you must not
359 claim that you wrote the original software. If you use this software
360 in a product, an acknowledgment in the product documentation would be
361 appreciated but is not required.
362 <item> Altered source versions must be plainly marked as such, and must not
363 be misrepresented as being the original software.
364 <item> This notice may not be removed or altered from any source