1 <!doctype linuxdoc system>
5 <title>Commodore VIC20 (aka VC20) specific information for cc65
6 <author>Ullrich von Bassewitz, <htmlurl url="mailto:uz@cc65.org" name="uz@cc65.org">
7 Stefan A. Haubenthal, <htmlurl url="mailto:polluks@sdf.lonestar.org" name="polluks@sdf.lonestar.org">
11 An overview over the VIC20 runtime system as it is implemented for the cc65 C
15 <!-- Table of contents -->
18 <!-- Begin the document -->
22 This file contains an overview of the VIC20 runtime system as it comes with the
23 cc65 C compiler. It describes the memory layout, VIC20 specific header files,
24 available drivers, and any pitfalls specific to that platform.
26 Please note that VIC20 specific functions are just mentioned here, they are
27 described in detail in the separate <htmlurl url="funcref.html" name="function
28 reference">. Even functions marked as "platform dependent" may be available on
29 more than one platform. Please see the function reference for more
33 <sect>Binary format<p>
35 The standard binary output format generated by the linker for the VIC20 target
36 is a machine language program with a one line BASIC stub. This means that a
37 program can be loaded as BASIC program and started with RUN. It is of course
38 possible to change this behaviour by using a modified startup file and linker
42 <sect>Memory layout<p>
44 cc65 generated programs with the default setup run with the I/O area and the
45 kernal and BASIC ROM enabled (RAM at $A000 - $BFFF may be used
46 for the heap), which gives a usable memory range of $1000 - $1DFF.
47 All ROM entry points may be called directly without additional code.
53 The text screen is located at $1E00 (as in the standard setup).
56 The C runtime stack is located at $1DFF and growing downwards.
59 The C heap is located at the end of the program and grows towards the C
66 <sect>Platform specific header files<p>
68 Programs containing VIC20 specific code may use the <tt/vic20.h/ or <tt/cbm.h/
69 header files. Using the later may be an option when writing code for more than
70 one CBM platform, since it includes <tt/vic20.h/ and declares several functions
71 common to all CBM platforms.
74 <sect1>VIC20 specific functions<p>
76 There are currently no special VIC20 functions.
80 <sect1>CBM specific functions<p>
82 Some functions are available for all (or at least most) of the Commodore
83 machines. See the <htmlurl url="funcref.html" name="function reference"> for
84 declaration and usage.
112 <sect1>Hardware access<p>
114 The following pseudo variables declared in the <tt/vic20.h/ header file do allow
115 access to hardware located in the address space. Some variables are
116 structures, accessing the struct fields will access the chip registers.
121 The <tt/VIC/ structure allows access to the VIC (the graphics
122 controller). See the <tt/_vic.h/ header file located in the include
123 directory for the declaration of the structure.
125 <tag><tt/VIA1, VIA2/</tag>
126 Access to the two VIA (versatile interface adapter) chips is available via
127 the <tt/VIA1/ and <tt/VIA2/ variables. The structure behind these variables
128 is explained in <tt/_6522.h/.
130 <tag><tt/COLOR_RAM/</tag>
131 A character array that mirrors the color RAM of the VIC20 at $9600.
137 <sect>Loadable drivers<p>
139 <sect1>Graphics drivers<p>
141 No graphics drivers are currently available for the VIC20.
144 <sect1>Extended memory drivers<p>
146 No extended memory drivers are currently available for the VIC20.
149 <sect1>Joystick drivers<p>
153 <tag><tt/vic20-stdjoy.joy/</tag>
154 Supports one standard joystick connected to the joysticks port of the VIC20.
160 <sect1>Mouse drivers<p>
162 No mouse drivers are currently available for the VIC20.
165 <sect1>RS232 device drivers<p>
167 No VIC1011 drivers are currently available for the VIC20.
177 <sect1>Passing arguments to the program<p>
179 Command line arguments can be passed to <tt/main()/. Since this is not
180 supported by BASIC, the following syntax was chosen:
183 RUN:REM ARG1 " ARG2 IS QUOTED" ARG3 "" ARG5
187 <item>Arguments are separated by spaces.
188 <item>Arguments may be quoted.
189 <item>Leading and trailing spaces around an argument are ignored. Spaces within
190 a quoted argument are allowed.
191 <item>The first argument passed to <tt/main/ is the program name.
192 <item>A maximum number of 10 arguments (including the program name) are
197 <sect1>Program return code<p>
199 The program return code (low byte) is passed back to BASIC by use of the
203 <sect1>Using extended memory<p>
205 The extended memory at $A000 may be added to the heap by using the following
209 /* Check for the existence of RAM */
210 if (PEEK(0xA000) == POKE(0xA000, PEEK(0xA000)+1)) {<br>
211 /* Add it to the heap */
212 _heapadd ((void *) 0xA000, 0x2000);
219 The runtime for the VIC20 uses routines marked as <tt/.CONDES/ type 2 for
220 interrupt handlers. Such routines must be written as simple machine language
221 subroutines and will be called automatically by the interrupt handler code
222 when they are linked into a program. See the discussion of the <tt/.CONDES/
223 feature in the <htmlurl url="ca65.html" name="assembler manual">.
227 <sect>Bugs/Feedback<p>
229 If you have problems using the library, if you find any bugs, or if you're
230 doing something interesting with it, I would be glad to hear from you. Feel
231 free to contact me by email (<htmlurl url="mailto:uz@cc65.org"
232 name="uz@cc65.org">).
238 This software is provided 'as-is', without any expressed or implied
239 warranty. In no event will the authors be held liable for any damages
240 arising from the use of this software.
242 Permission is granted to anyone to use this software for any purpose,
243 including commercial applications, and to alter it and redistribute it
244 freely, subject to the following restrictions:
247 <item> The origin of this software must not be misrepresented; you must not
248 claim that you wrote the original software. If you use this software
249 in a product, an acknowledgment in the product documentation would be
250 appreciated but is not required.
251 <item> Altered source versions must be plainly marked as such, and must not
252 be misrepresented as being the original software.
253 <item> This notice may not be removed or altered from any source