1 <!doctype linuxdoc system>
5 <title>Commodore Plus/4 specific information for cc65
6 <author>Ullrich von Bassewitz, <htmlurl url="mailto:uz@cc65.org" name="uz@cc65.org">
10 An overview over the Plus/4 runtime system as it is implemented for the cc65 C
14 <!-- Table of contents -->
17 <!-- Begin the document -->
21 This file contains an overview of the Plus/4 runtime system as it comes with the
22 cc65 C compiler. It describes the memory layout, Plus/4 specific header files,
23 available drivers, and any pitfalls specific to that platform.
25 Please note that Plus/4 specific functions are just mentioned here, they are
26 described in detail in the separate <htmlurl url="funcref.html" name="function
27 reference">. Even functions marked as "platform dependent" may be available on
28 more than one platform. Please see the function reference for more
31 Since the Plus/4 and the Commodore 16/116 are almost identical (the latter are
32 missing the 6551 ACIA and do only have 16KB of memory), the <htmlurl
33 url="c16.html" name="C16 documentation"> is also worth a look. The difference
34 between both cc65 targets is that the Plus/4 runtime uses banking to support
35 full 64K RAM, while the C16 does not use banking and supports up to 32K RAM.
36 Because banking is not needed, most C16 programs will be somewhat smaller than
37 the same program compiled for the Plus/4. However, programs compiled for the
38 C16 will always run on the Plus/4, while the reverse is not necessarily true.
41 <sect>Binary format<p>
43 The standard binary output format generated by the linker for the Plus/4
44 target is a machine language program with a one line BASIC stub, which calls
45 the machine language part via SYS. This means that a program can be loaded as
46 BASIC program and started with RUN. It is of course possible to change this
47 behaviour by using a modified startup file and linker config.
50 <sect>Memory layout<p>
52 cc65 generated programs with the default setup run with the kernal and basic
53 banked out. This gives a usable memory range of $1000 - $FD00.
54 Having the kernal and basic ROMs banked out means, that no ROM entry points
55 may be called directly from user code.
61 The text screen is located at $C00 (as in the standard setup).
64 The color RAM is located at $800 (standard location).
67 The C runtime stack is located at $FCFF and growing downwards.
70 The C heap is located at the end of the program and grows towards the C
77 <sect>Platform specific header files<p>
79 Programs containing Plus/4 specific code may use the <tt/plus4.h/ or <tt/cbm.h/
80 header files. Using the later may be an option when writing code for more than
81 one CBM platform, since it includes <tt/plus4.h/ and declares several functions
82 common to all CBM platforms.
84 Please note that most of the header file declarations from the <tt/plus4.h/
85 header file are shared between the C16 and Plus/4 configurations. For this
86 reason, most of it is located in a common header file named <tt/cbm264.h/.
90 <sect1>Plus/4 specific functions<p>
92 There are currently no special Plus/4 functions.
95 <sect1>CBM specific functions<p>
97 Some functions are available for all (or at least most) of the Commodore
98 machines. See the <htmlurl url="funcref.html" name="function reference"> for
99 declaration and usage.
127 <sect1>Hardware access<p>
129 The following pseudo variables declared in the <tt/plus4.h/ header file do
130 allow access to hardware located in the address space. Some variables are
131 structures, accessing the struct fields will access the chip registers.
136 The <tt/TED/ structure allows access to the TED chip. See the
137 <tt/_ted.h/ header file located in the include directory for the
138 declaration of the structure.
140 <tag><tt/COLOR_RAM/</tag>
141 A character array that mirrors the color RAM of the Plus/4 at $0800.
147 <sect>Loadable drivers<p>
149 <sect1>Graphics drivers<p>
151 No graphics drivers are currently available for the Plus/4.
154 <sect1>Extended memory drivers<p>
156 No extended memory drivers are currently available for the Plus/4.
160 <sect1>Joystick drivers<p>
164 <tag><tt/plus4-stdjoy.joy/</tag>
165 Supports up to two joysticks connected to the standard joysticks port of
172 <sect1>Mouse drivers<p>
174 Currently no drivers available (in fact, the API for loadable mouse drivers
178 <sect1>RS232 device drivers<p>
182 <tag><tt/plus4-stdser.ser/</tag>
183 Driver for the 6551 ACIA chip built into the Plus/4. Supports up to 19200
184 baud, hardware flow control (RTS/CTS) and interrupt driven receives. Note
185 that because of the peculiarities of the 6551 chip transmits are not
186 interrupt driven, and the transceiver blocks if the receiver asserts flow
187 control because of a full buffer.
189 You need an adapter to use the builtin port, since the output levels
190 available at the user port don't follow the RS232 standard.
202 <sect1>Passing arguments to the program<p>
204 Command line arguments can be passed to <tt/main()/. Since this is not
205 supported by BASIC, the following syntax was chosen:
208 RUN:REM ARG1 " ARG2 IS QUOTED" ARG3 "" ARG5
212 <item>Arguments are separated by spaces.
213 <item>Arguments may be quoted.
214 <item>Leading and trailing spaces around an argument are ignored. Spaces within
215 a quoted argument are allowed.
216 <item>The first argument passed to <tt/main/ is the program name.
217 <item>A maximum number of 10 arguments (including the program name) are
223 <sect1>Program return code<p>
225 The program return code (low byte) is passed back to BASIC by use of the
231 The runtime for the Plus/4 uses routines marked as <tt/.CONDES/ type 2 for
232 interrupt handlers. Such routines must be written as simple machine language
233 subroutines and will be called automatically by the interrupt handler code
234 when they are linked into a program. See the discussion of the <tt/.CONDES/
235 feature in the <htmlurl url="ca65.html" name="assembler manual">.
239 <sect>Bugs/Feedback<p>
241 If you have problems using the library, if you find any bugs, or if you're
242 doing something interesting with it, I would be glad to hear from you. Feel
243 free to contact me by email (<htmlurl url="mailto:uz@cc65.org"
244 name="uz@cc65.org">).
250 This software is provided 'as-is', without any expressed or implied
251 warranty. In no event will the authors be held liable for any damages
252 arising from the use of this software.
254 Permission is granted to anyone to use this software for any purpose,
255 including commercial applications, and to alter it and redistribute it
256 freely, subject to the following restrictions:
259 <item> The origin of this software must not be misrepresented; you must not
260 claim that you wrote the original software. If you use this software
261 in a product, an acknowledgment in the product documentation would be
262 appreciated but is not required.
263 <item> Altered source versions must be plainly marked as such, and must not
264 be misrepresented as being the original software.
265 <item> This notice may not be removed or altered from any source