1 <!doctype linuxdoc system>
4 <title>Commodore VIC20 (aka VC20 aka VIC1001) specific information for cc65
6 <url url="mailto:uz@cc65.org" name="Ullrich von Bassewitz">,<newline>
7 <url url="mailto:polluks@sdf.lonestar.org" name="Stefan A. Haubenthal">
10 An overview over the VIC20 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 VIC20 runtime system as it comes with the
22 cc65 C compiler. It describes the memory layout, VIC20-specific header files,
23 available drivers, and any pitfalls specific to that platform.
25 Please note that VIC20-specific functions are just mentioned here, they are
26 described in detail in the separate <url 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
32 <sect>Binary format<p>
34 The standard binary output format generated by the linker for the VIC20 target
35 is a machine language program with a one line BASIC stub, which calls the
36 machine language part via SYS. This means that a program can be loaded as
37 BASIC program and started with RUN. It is of course possible to change this
38 behaviour by using a modified startup file and linker config.
41 <sect>Memory layout<p>
43 cc65 generated programs with the default setup run with unexpanded memory
44 (RAM at $A000 - $BFFF may be used for the heap),
45 which gives a usable memory range of $1000 - $1DFF.
46 All ROM entry points may be called directly without additional code.
52 The text screen is located at $1E00 (as in the standard setup).
55 The C runtime stack is located at $1DFF and growing downwards.
58 The C heap is located at the end of the program and grows towards the C
65 <sect>Platform-specific header files<p>
67 Programs containing VIC20-specific code may use the <tt/vic20.h/ or <tt/cbm.h/
68 header files. Using the later may be an option when writing code for more than
69 one CBM platform, since it includes <tt/vic20.h/ and declares several functions
70 common to all CBM platforms.
73 <sect1>VIC20-specific functions<p>
75 There are currently no special VIC20 functions.
79 <sect1>CBM-specific functions<p>
81 Some functions are available for all (or at least most) of the Commodore
82 machines. See the <url url="funcref.html" name="function reference"> for
83 declaration and usage.
113 <sect1>Hardware access<p>
115 The following pseudo variables declared in the <tt/vic20.h/ header file do allow
116 access to hardware located in the address space. Some variables are
117 structures, accessing the struct fields will access the chip registers.
122 The <tt/VIC/ structure allows access to the VIC (the graphics
123 controller). See the <tt/_vic.h/ header file located in the include
124 directory for the declaration of the structure.
126 <tag><tt/VIA1, VIA2/</tag>
127 Access to the two VIA (versatile interface adapter) chips is available via
128 the <tt/VIA1/ and <tt/VIA2/ variables. The structure behind these variables
129 is explained in <tt/_6522.h/.
131 <tag><tt/COLOR_RAM/</tag>
132 A character array that mirrors the color RAM of the VIC20 at $9600.
138 <sect>Loadable drivers<p>
140 The names in the parentheses denote the symbols to be used for static linking of the drivers.
143 <sect1>Graphics drivers<p>
145 No graphics drivers are currently available for the VIC20.
148 <sect1>Extended memory drivers<p>
152 <tag><tt/vic20-rama.emd (vic20_rama_emd)/</tag>
153 A driver for any RAM at $A000-$BFFF. Supports 32 256 byte pages.
154 Written and contributed by Marco van den Heuvel.
156 <tag><tt/vic20-georam.emd (vic20_georam_emd)/</tag>
157 A driver for the Berkeley Softworks GeoRam cartridge connected by means of
158 the MasC=erade c64 cartridge adapter. The driver will determine the
159 available RAM from the connected cartridge. It supports 64KB
165 <sect1>Joystick drivers<p>
167 The default drivers, <tt/joy_stddrv (joy_static_stddrv)/, point to <tt/vic20-stdjoy.joy (vic20_stdjoy_joy)/.
171 <tag><tt/vic20-stdjoy.joy (vic20_stdjoy_joy)/</tag>
172 Supports one standard joystick connected to the joysticks port of the VIC20.
174 <tag><tt/vic20-ptvjoy.joy (vic20_ptvjoy_joy)/</tag>
175 Driver for the Protovision 4-player adapter contributed by Groepaz. See
176 <url url="https://www.protovision.games/hardw/4_player.php"
177 name="the Protovision shop"> for prices and building instructions. Up to three
178 joysticks are supported.
183 <sect1>Mouse drivers<p>
185 No mouse drivers are currently available for the VIC20.
188 <sect1>RS232 device drivers<p>
190 No VIC1011 drivers are currently available for the VIC20.
197 <sect1>Escape code<p>
199 The CTRL key cannot be used to type most control characters,
200 entering an Esc is not possible.
207 <sect1>Passing arguments to the program<p>
209 Command-line arguments can be passed to <tt/main()/. Since that is not
210 supported directly by BASIC, the following syntax was chosen:
213 RUN:REM ARG1 " ARG2 IS QUOTED" ARG3 "" ARG5
217 <item>Arguments are separated by spaces.
218 <item>Arguments may be quoted.
219 <item>Leading and trailing spaces around an argument are ignored. Spaces within
220 a quoted argument are allowed.
221 <item>The first argument passed to <tt/main()/ is the program name.
222 <item>A maximum number of 10 arguments (including the program name) are
227 <sect1>Program return code<p>
229 The program return code (low byte) is passed back to BASIC by use of the
233 <sect1>Using extended memory<p>
235 BLK5 memory may be added to the heap by using the following code:
238 /* Check for the existence of RAM */
239 if (PEEK(0xA000) == POKE(0xA000, PEEK(0xA000)+1)) {
240 /* Add it to the heap */
241 _heapadd ((void *) 0xA000, 0x2000);
248 The runtime for the VIC20 uses routines marked as <tt/.INTERRUPTOR/ for
249 interrupt handlers. Such routines must be written as simple machine language
250 subroutines and will be called automatically by the interrupt handler code
251 when they are linked into a program. See the discussion of the <tt/.CONDES/
252 feature in the <url url="ca65.html" name="assembler manual">.
258 This software is provided 'as-is', without any expressed or implied
259 warranty. In no event will the authors be held liable for any damages
260 arising from the use of this software.
262 Permission is granted to anyone to use this software for any purpose,
263 including commercial applications, and to alter it and redistribute it
264 freely, subject to the following restrictions:
267 <item> The origin of this software must not be misrepresented; you must not
268 claim that you wrote the original software. If you use this software
269 in a product, an acknowledgment in the product documentation would be
270 appreciated but is not required.
271 <item> Altered source versions must be plainly marked as such, and must not
272 be misrepresented as being the original software.
273 <item> This notice may not be removed or altered from any source