1 <!doctype linuxdoc system>
5 <title>Commodore 16/116 specific information for cc65
6 <author>Ullrich von Bassewitz, <htmlurl url="mailto:uz@cc65.org" name="uz@cc65.org">
10 An overview over the C16 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 C16 runtime system as it comes with the
22 cc65 C compiler. It describes the memory layout, C16/116 specific header
23 files, available drivers, and any pitfalls specific to that platform.
25 Please note that C16 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 C16/C116 and the Commodore Plus/4 are almost identical (the former
32 don't have the 6551 ACIA and only 16KB of memory), the <htmlurl
33 url="plus4.html" name="Plus/4 documentation"> is also worth a look. The
34 difference between both cc65 targets is that the Plus/4 runtime uses banking
35 to support full 64K RAM, while the C16 does not use banking and supports up to
36 32K RAM. Because banking is not needed, most C16 programs will be somewhat
37 smaller than the same program compiled for the Plus/4. However, programs C16
38 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 C16/116
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 in. This gives a usable memory range of $1000 - $4000
54 (or $8000 if the machine is equipped with 32K RAM or more). Having the
55 kernal and basic ROMs banked in means, that ROM entry points may be called
56 directly from user code.
62 The text screen is located at $C00 (as in the standard setup).
65 The color RAM is located at $800 (standard location).
68 The C runtime stack is located at $3FFF ($7FFF in case of a
69 machine with 32K of memory or more) and growing downwards.
72 The C heap is located at the end of the program and grows towards the C
79 <sect>Platform specific header files<p>
81 Programs containing C16 specific code may use the <tt/c16.h/ or <tt/cbm.h/
82 header files. Using the later may be an option when writing code for more than
83 one CBM platform, since it includes <tt/c16.h/ and declares several functions
84 common to all CBM platforms.
86 Please note that most of the header file declarations from the <tt/c16.h/
87 header file are shared between the C16 and Plus/4 configurations. For this
88 reason, most of it is located in a common header file named <tt/cbm264.h/.
92 <sect1>C16/C116 specific functions<p>
94 There are currently no special C16/C116 functions.
97 <sect1>CBM specific functions<p>
99 Some functions are available for all (or at least most) of the Commodore
100 machines. See the <htmlurl url="funcref.html" name="function reference"> for
101 declaration and usage.
129 <sect1>Hardware access<p>
131 The following pseudo variables declared in the <tt/c16.h/ header file do
132 allow access to hardware located in the address space. Some variables are
133 structures, accessing the struct fields will access the chip registers.
138 The <tt/TED/ structure allows access to the TED chip. See the
139 <tt/_ted.h/ header file located in the include directory for the
140 declaration of the structure.
142 <tag><tt/COLOR_RAM/</tag>
143 A character array that mirrors the color RAM of the C16 at $0800.
149 <sect>Loadable drivers<p>
151 <sect1>Graphics drivers<p>
153 No graphics drivers are currently available for the C16/C116.
156 <sect1>Extended memory drivers<p>
160 <tag><tt/c16-ram.emd/</tag>
161 A driver for the hidden RAM below the BASIC and KERNAL ROMs. Supports 125
162 pages with 256 bytes each if the machine is equipped with 64K of memory
163 (a Plus/4 or a memory extended C16/116).
169 <sect1>Joystick drivers<p>
173 <tag><tt/c16-stdjoy.joy/</tag>
174 Supports up to two joysticks connected to the standard joysticks port of
175 the Commodore 16/116.
181 <sect1>Mouse drivers<p>
183 Currently no drivers available (in fact, the API for loadable mouse drivers
187 <sect1>RS232 device drivers<p>
189 The Commodore 16 does not have a builtin ACIA and no RS232 extensions are
190 known. For this reason, there are no RS232 drivers available. Please note that
191 the standard Plus/4 driver will <em>not</em> run together with the C16
192 library, because the latter does not support interrupts needed by the driver.
201 <sect1>Passing arguments to the program<p>
203 Command line arguments can be passed to <tt/main()/. Since this is not
204 supported by BASIC, the following syntax was chosen:
207 RUN:REM ARG1 " ARG2 IS QUOTED" ARG3 "" ARG5
211 <item>Arguments are separated by spaces.
212 <item>Arguments may be quoted.
213 <item>Leading and trailing spaces around an argument are ignored. Spaces within
214 a quoted argument are allowed.
215 <item>The first argument passed to <tt/main/ is the program name.
216 <item>A maximum number of 10 arguments (including the program name) are
221 <sect1>Program return code<p>
223 The program return code (low byte) is passed back to BASIC by use of the
228 <sect>Bugs/Feedback<p>
230 If you have problems using the library, if you find any bugs, or if you're
231 doing something interesting with it, I would be glad to hear from you. Feel
232 free to contact me by email (<htmlurl url="mailto:uz@cc65.org"
233 name="uz@cc65.org">).
239 This software is provided 'as-is', without any expressed or implied
240 warranty. In no event will the authors be held liable for any damages
241 arising from the use of this software.
243 Permission is granted to anyone to use this software for any purpose,
244 including commercial applications, and to alter it and redistribute it
245 freely, subject to the following restrictions:
248 <item> The origin of this software must not be misrepresented; you must not
249 claim that you wrote the original software. If you use this software
250 in a product, an acknowledgment in the product documentation would be
251 appreciated but is not required.
252 <item> Altered source versions must be plainly marked as such, and must not
253 be misrepresented as being the original software.
254 <item> This notice may not be removed or altered from any source