]> git.sur5r.net Git - cc65/blob - doc/vic20.sgml
Merge pull request #100 from greg-king5/default-drivers
[cc65] / doc / vic20.sgml
1 <!doctype linuxdoc system>
2
3 <article>
4
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"><newline>
7 Stefan A. Haubenthal, <htmlurl url="mailto:polluks@sdf.lonestar.org" name="polluks@sdf.lonestar.org">
8 <date>2014-03-26
9
10 <abstract>
11 An overview over the VIC20 runtime system as it is implemented for the cc65 C
12 compiler.
13 </abstract>
14
15 <!-- Table of contents -->
16 <toc>
17
18 <!-- Begin the document -->
19
20 <sect>Overview<p>
21
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.
25
26 Please note that VIC20-specific functions are just mentioned here, they are
27 described in detail in the separate <url 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
30 information.
31
32
33 <sect>Binary format<p>
34
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, which calls the
37 machine language part via SYS. This means that a program can be loaded as
38 BASIC program and started with RUN. It is of course possible to change this
39 behaviour by using a modified startup file and linker config.
40
41
42 <sect>Memory layout<p>
43
44 cc65 generated programs with the default setup run with unexpanded memory
45 (RAM at &dollar;A000 - &dollar;BFFF may be used for the heap),
46 which gives a usable memory range of &dollar;1000 - &dollar;1DFF.
47 All ROM entry points may be called directly without additional code.
48
49 Special locations:
50
51 <descrip>
52   <tag/Text screen/
53   The text screen is located at &dollar;1E00 (as in the standard setup).
54
55   <tag/Stack/
56   The C runtime stack is located at &dollar;1DFF and growing downwards.
57
58   <tag/Heap/
59   The C heap is located at the end of the program and grows towards the C
60   runtime stack.
61
62 </descrip><p>
63
64
65
66 <sect>Platform-specific header files<p>
67
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.
72
73
74 <sect1>VIC20-specific functions<p>
75
76 There are currently no special VIC20 functions.
77
78
79
80 <sect1>CBM-specific functions<p>
81
82 Some functions are available for all (or at least most) of the Commodore
83 machines. See the <url url="funcref.html" name="function reference"> for
84 declaration and usage.
85
86 <itemize>
87 <item>cbm_close
88 <item>cbm_closedir
89 <item>cbm_k_setlfs
90 <item>cbm_k_setnam
91 <item>cbm_k_load
92 <item>cbm_k_save
93 <item>cbm_k_open
94 <item>cbm_k_close
95 <item>cbm_k_readst
96 <item>cbm_k_chkin
97 <item>cbm_k_ckout
98 <item>cbm_k_basin
99 <item>cbm_k_bsout
100 <item>cbm_k_clrch
101 <item>cbm_load
102 <item>cbm_open
103 <item>cbm_opendir
104 <item>cbm_read
105 <item>cbm_readdir
106 <item>cbm_save
107 <item>cbm_write
108 <item>get_tv
109 </itemize>
110
111
112 <sect1>Hardware access<p>
113
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.
117
118 <descrip>
119
120   <tag><tt/VIC/</tag>
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.
124
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/.
129
130   <tag><tt/COLOR_RAM/</tag>
131   A character array that mirrors the color RAM of the VIC20 at &dollar;9600.
132
133 </descrip><p>
134
135
136
137 <sect>Loadable drivers<p>
138
139 The names in the parentheses denote the symbols to be used for static linking of the drivers.
140
141
142 <sect1>Graphics drivers<p>
143
144 No graphics drivers are currently available for the VIC20.
145
146
147 <sect1>Extended memory drivers<p>
148
149 No extended memory drivers are currently available for the VIC20.
150
151
152 <sect1>Joystick drivers<p>
153
154 The default drivers, <tt/joy_stddrv (joy_static_stddrv)/, point to <tt/vic20-stdjoy.joy (vic20_stdjoy_joy)/.
155
156 <descrip>
157
158   <tag><tt/vic20-stdjoy.joy (vic20_stdjoy_joy)/</tag>
159   Supports one standard joystick connected to the joysticks port of the VIC20.
160
161   <tag><tt/vic20-ptvjoy.joy (vic20_ptvjoy_joy)/</tag>
162   Driver for the Protovision 4-player adapter contributed by Groepaz. See
163   <htmlurl url="http://www.protovision-online.de/hardw/hardwstart.htm"
164   name="http://www.protovision-online.de/hardw/hardwstart.htm"> for prices and
165   building instructions. Up to three joysticks are supported.
166
167 </descrip><p>
168
169
170 <sect1>Mouse drivers<p>
171
172 No mouse drivers are currently available for the VIC20.
173
174
175 <sect1>RS232 device drivers<p>
176
177 No VIC1011 drivers are currently available for the VIC20.
178
179
180
181 <sect>Limitations<p>
182
183
184
185 <sect>Other hints<p>
186
187
188 <sect1>Escape code<p>
189
190 For an Esc, press CTRL and the <tt/[/ key.
191
192
193 <sect1>Passing arguments to the program<p>
194
195 Command-line arguments can be passed to <tt/main()/. Since that is not
196 supported directly by BASIC, the following syntax was chosen:
197
198 <tscreen><verb>
199     RUN:REM ARG1 " ARG2 IS QUOTED" ARG3 "" ARG5
200 </verb></tscreen>
201
202 <enum>
203 <item>Arguments are separated by spaces.
204 <item>Arguments may be quoted.
205 <item>Leading and trailing spaces around an argument are ignored. Spaces within
206       a quoted argument are allowed.
207 <item>The first argument passed to <tt/main()/ is the program name.
208 <item>A maximum number of 10 arguments (including the program name) are
209       supported.
210 </enum>
211
212
213 <sect1>Program return code<p>
214
215 The program return code (low byte) is passed back to BASIC by use of the
216 <tt/ST/ variable.
217
218
219 <sect1>Using extended memory<p>
220
221 The extended memory at $A000 may be added to the heap by using the following
222 code:
223
224 <tscreen><verb>
225     /* Check for the existence of RAM */
226     if (PEEK(0xA000) == POKE(0xA000, PEEK(0xA000)+1)) {
227         /* Add it to the heap */
228         _heapadd ((void *) 0xA000, 0x2000);
229     }
230 </verb></tscreen>
231
232
233 <sect1>Interrupts<p>
234
235 The runtime for the VIC20 uses routines marked as <tt/.INTERRUPTOR/ for
236 interrupt handlers. Such routines must be written as simple machine language
237 subroutines and will be called automatically by the interrupt handler code
238 when they are linked into a program. See the discussion of the <tt/.CONDES/
239 feature in the <url url="ca65.html" name="assembler manual">.
240
241
242
243 <sect>License<p>
244
245 This software is provided 'as-is', without any expressed or implied
246 warranty.  In no event will the authors be held liable for any damages
247 arising from the use of this software.
248
249 Permission is granted to anyone to use this software for any purpose,
250 including commercial applications, and to alter it and redistribute it
251 freely, subject to the following restrictions:
252
253 <enum>
254 <item>  The origin of this software must not be misrepresented; you must not
255         claim that you wrote the original software. If you use this software
256         in a product, an acknowledgment in the product documentation would be
257         appreciated but is not required.
258 <item>  Altered source versions must be plainly marked as such, and must not
259         be misrepresented as being the original software.
260 <item>  This notice may not be removed or altered from any source
261         distribution.
262 </enum>
263
264 </article>