]> git.sur5r.net Git - cc65/blob - doc/vic20.sgml
Info about using additional memory
[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">
7 Stefan A. Haubenthal, <htmlurl url="mailto:polluks@sdf.lonestar.org" name="polluks@sdf.lonestar.org">
8 <date>2004-09-13
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 <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
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. 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
39 config.
40
41
42 <sect>Memory layout<p>
43
44 cc65 generated programs with the default setup run with the I/O area and the
45 kernal and BASIC ROM enabled (RAM at &dollar;A000 - &dollar;BFFF may be used
46 for the heap), 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 The functions listed below are special for the VIC20. See the <htmlurl
77 url="funcref.html" name="function reference"> for declaration and usage.
78
79 <itemize>
80 <item>get_ostype
81 </itemize>
82
83
84 <sect1>CBM specific functions<p>
85
86 Some functions are available for all (or at least most) of the Commodore
87 machines. See the <htmlurl url="funcref.html" name="function reference"> for
88 declaration and usage.
89
90 <itemize>
91 <item>cbm_close
92 <item>cbm_closedir
93 <item>cbm_k_setlfs
94 <item>cbm_k_setnam
95 <item>cbm_k_load
96 <item>cbm_k_save
97 <item>cbm_k_open
98 <item>cbm_k_close
99 <item>cbm_k_readst
100 <item>cbm_k_chkin
101 <item>cbm_k_ckout
102 <item>cbm_k_basin
103 <item>cbm_k_bsout
104 <item>cbm_k_clrch
105 <item>cbm_load
106 <item>cbm_open
107 <item>cbm_opendir
108 <item>cbm_read
109 <item>cbm_readdir
110 <item>cbm_save
111 <item>cbm_write
112 <item>get_tv
113 </itemize>
114
115
116 <sect1>Hardware access<p>
117
118 The following pseudo variables declared in the <tt/vic20.h/ header file do allow
119 access to hardware located in the address space. Some variables are
120 structures, accessing the struct fields will access the chip registers.
121
122 <descrip>
123
124   <tag><tt/VIC/</tag>
125   The <tt/VIC/ structure allows access to the VIC (the graphics
126   controller). See the <tt/_vic.h/ header file located in the include
127   directory for the declaration of the structure.
128
129   <tag><tt/VIA1, VIA2/</tag>
130   Access to the two VIA (versatile interface adapter) chips is available via
131   the <tt/VIA1/ and <tt/VIA2/ variables. The structure behind these variables
132   is explained in <tt/_6522.h/.
133
134   <tag><tt/COLOR_RAM/</tag>
135   A character array that mirrors the color RAM of the VIC20 at &dollar;9600.
136
137 </descrip><p>
138
139
140
141 <sect>Loadable drivers<p>
142
143 <sect1>Graphics drivers<p>
144
145 No graphics drivers are currently available for the VIC20.
146
147
148 <sect1>Extended memory drivers<p>
149
150 No extended memory drivers are currently available for the VIC20.
151
152
153 <sect1>Joystick drivers<p>
154
155 <descrip>
156
157   <tag><tt/vic20-stdjoy.joy/</tag>
158   Supports one standard joystick connected to the joysticks port of the VIC20.
159
160 </descrip><p>
161
162
163
164 <sect1>Mouse drivers<p>
165
166 No mouse drivers are currently available for the VIC20.
167
168
169 <sect1>RS232 device drivers<p>
170
171 No VIC1011 drivers are currently available for the VIC20.
172
173
174
175 <sect>Limitations<p>
176
177
178
179 <sect>Other hints<p>
180
181 <sect1>Passing arguments to the program<p>
182
183 Command line arguments can be passed to <tt/main()/. Since this is not
184 supported by BASIC, the following syntax was chosen:
185
186 <tscreen><verb>
187     RUN:REM ARG1 " ARG2 IS QUOTED" ARG3 "" ARG5
188 </verb></tscreen>
189
190 <enum>
191 <item>Arguments are separated by spaces.
192 <item>Arguments may be quoted.
193 <item>Leading and trailing spaces around an argument are ignored. Spaces within
194       a quoted argument are allowed.
195 <item>The first argument passed to <tt/main/ is the program name.
196 <item>A maximum number of 10 arguments (including the program name) are
197       supported.
198 </enum>
199
200
201 <sect1>Program return code<p>
202
203 The program return code (low byte) is passed back to BASIC by use of the
204 <tt/ST/ variable.
205
206
207 <sect1>Using extended memory<p>
208
209 The extended memory at $A000 may be added to the heap by using the following
210 code:
211
212 <tscreen><verb>
213     /* Check for the existence of RAM */
214     if (PEEK(0xA000) == POKE(0xA000, PEEK(0xA000)+1)) {<br>
215         /* Add it to the heap */
216         _heapadd ((void *) 0xA000, 0x2000);
217     }
218 </verb></tscreen>
219
220
221
222
223 <sect>Bugs/Feedback<p>
224
225 If you have problems using the library, if you find any bugs, or if you're
226 doing something interesting with it, I would be glad to hear from you. Feel
227 free to contact me by email (<htmlurl url="mailto:uz@cc65.org"
228 name="uz@cc65.org">).
229
230
231
232 <sect>License<p>
233
234 This software is provided 'as-is', without any expressed or implied
235 warranty.  In no event will the authors be held liable for any damages
236 arising from the use of this software.
237
238 Permission is granted to anyone to use this software for any purpose,
239 including commercial applications, and to alter it and redistribute it
240 freely, subject to the following restrictions:
241
242 <enum>
243 <item>  The origin of this software must not be misrepresented; you must not
244         claim that you wrote the original software. If you use this software
245         in a product, an acknowledgment in the product documentation would be
246         appreciated but is not required.
247 <item>  Altered source versions must be plainly marked as such, and must not
248         be misrepresented as being the original software.
249 <item>  This notice may not be removed or altered from any source
250         distribution.
251 </enum>
252
253 </article>
254
255
256