]> git.sur5r.net Git - cc65/blob - doc/cbm610.sgml
Added docs for the Commodore 610
[cc65] / doc / cbm610.sgml
1 <!doctype linuxdoc system>
2
3 <article>
4
5 <title>Commodore 610 specific information for cc65
6 <author>Ullrich von Bassewitz, <htmlurl url="mailto:uz@cc65.org" name="uz@cc65.org">
7 <date>2003-12-16
8
9 <abstract>
10 An overview over the Commodore 610 runtime system as it is implemented for the
11 cc65 C compiler.
12 </abstract>
13
14 <!-- Table of contents -->
15 <toc>
16
17 <!-- Begin the document -->
18
19 <sect>Overview<p>
20
21 This file contains an overview of the CBM 610 runtime system as it comes with
22 the cc65 C compiler. It describes the memory layout, CBM 610 specific header
23 files, available drivers, and any pitfalls specific to that platform.
24
25 Please note that CBM 610 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
29 information.
30
31 In addition to the Commodore 610 (named B40 in the U.S.), several other
32 machines are supported by this cc65 target, since they have identical
33 hardware: The Commodore 620 and 630 (more memory, additional coprocessor
34 card), and the Commodore 710, 720 and 730 (same hardware in another case with
35 a builtin monitor).
36
37
38
39 <sect>Binary format<p>
40
41 The standard binary output format generated by the linker for the CBM610
42 target is a machine language program with a short BASIC stub. This means that
43 a program can be loaded as BASIC program and started with RUN. It is of course
44 possible to change this behaviour by using a modified startup file and linker
45 config.
46
47
48 <sect>Memory layout<p>
49
50 cc65 generated programs for the Commodore 610 run in bank 1, the memory bank
51 reserved for BASIC programs. Since there are no ROMs in this memory bank, the
52 program has almost full 64K for its own. A disadvantage is that kernal
53 subroutines cannot be called (at least not in a fast and effective manner), so
54 the runtime has replace kernal functionality.
55
56 The default memory configuration for the CBM 610 allocates all memory between
57 &dollar;0002 and &dollar;FFF0 in bank 1 for the compiled program. Some space
58 in low memory is lost, because a separate hardware stack is set up in page 1,
59 and the kernal replacement functions need some more memory locations. A few
60 more bytes are lost in high memory, because the runtime sets up a CBM
61 compatible jump table at &dollar;FF81. The main startup code is located at
62 &dollar;0400, so about 63K of the complete bank are actually usable for
63 applications.
64
65 <bf>Note:</bf> The zero page from &dollar;02 to &dollar;5F is free to use for
66 applications!
67
68 Special locations:
69
70 <descrip>
71   <tag/Stack/
72   The C runtime stack is located at &dollar;FF81 and growing downwards.
73
74   <tag/Heap/
75   The C heap is located at the end of the program and grows towards the C
76   runtime stack.
77 </descrip><p>
78
79
80
81 <sect>Platform specific header files<p>
82
83 Programs containing CBM 610 specific code may use the <tt/cbm610.h/ or
84 <tt/cbm.h/ header files. Using the later may be an option when writing code
85 for more than one CBM platform, since it includes <tt/cbm610.h/ and declares
86 several functions common to all CBM platforms.
87
88 Please note that because of <ref id="limitations" name="current limitations">
89 of the runtime library for the platform, several standard C and CBM functions
90 are not available.
91
92
93 <sect1>CBM 610 specific functions<p>
94
95 The functions listed below are special for the CBM 610. See the <htmlurl
96 url="funcref.html" name="function reference"> for declaration and usage.
97
98 <itemize>
99 <item>peekbsys
100 <item>peewsys
101 <item>pokebsys
102 <item>pokewsys
103 </itemize>
104
105
106 <sect1>CBM specific functions<p>
107
108 Some functions are available for all (or at least most) of the Commodore
109 machines. See the <htmlurl url="funcref.html" name="function reference"> for
110 declaration and usage.
111
112
113 <sect1>Hardware access<p>
114
115 The following pseudo variables declared in the <tt/cbm610.h/ header file do
116 allow access to hardware located in the address space. Some variables are
117 structures, accessing the struct fields will access the chip registers.
118
119 <bf>Note:</bf> All I/O chips are located in the system bank (bank 15) and can
120 therefore not be accessed like on other platforms. Please use one of the
121 <tt/peekbsys/, <tt/peewsys/, <tt/pokebsys/ and <tt/pokewsys/ functions to
122 access the I/O chips. Direct reads and writes to the structures named below
123 will <em>not</em> work!
124
125 <descrip>
126
127   <tag><tt/CRTC/</tag>
128   The <tt/CRTC/ structure allows access to the CRTC (the video controller).
129   See the <tt/_6545.h/ header file located in the include directory for the
130   declaration of the structure.
131
132   <tag><tt/SID/</tag> The <tt/SID/ structure allows access to the SID (the
133   sound interface device). See the <tt/_sid.h/ header file located in the
134   include directory for the declaration of the structure.
135
136   <tag><tt/ACIA/</tag>
137   Access to the ACIA (the RS232 chip) is available via the <tt/ACIA/ variable.
138   See the <tt/_6551.h/ header file located in the include directory for the
139   declaration of the structure.
140
141   <tag><tt/CIA/</tag>
142   Access to the CIA chip is available via the <tt/CIA/ variable. See the
143   <tt/_6526.h/ header file located in the include directory for the
144   declaration of the structure.
145
146   <tag><tt/TPI1, TPI2/</tag>
147   The two 6525 triport chips may be accessed by using this variable. See the
148   <tt/_6525.h/ header file located in the include directory for the
149   declaration of the structure.
150
151 </descrip><p>
152
153
154
155 <sect>Loadable drivers<p>
156
157 <bf>Note:</bf> Since the CBM 610 doesn't have working disk I/O (see <ref
158 id="limitations" name="section &quot;Limitations&quot;">), the available
159 drivers cannot be loaded at runtime (so the term "loadable drivers" is
160 somewhat misleading). Instead, the drivers have to be converted using the
161 <htmlurl url="co65.html" name="co65 utility"> and statically linked. While
162 this may seem overhead, it has two advantages:
163
164 <enum>
165 <item>The interface is identical to the one used for other platforms
166       and to the one for the CBM 610 once it has disk I/O.
167 <item>Once disk I/O is available, existing code can be changed to load drivers
168       at runtime with almost no effort.
169 </enum>
170
171
172 <sect1>Graphics drivers<p>
173
174 No graphics drivers are currently available for the Commodore 610 (and since
175 the machine has no graphics capabilities, chances for a graphics driver aren't
176 really good:-).
177
178
179 <sect1>Extended memory drivers<p>
180
181 <descrip>
182   <tag><tt/cbm610-ram.emd/</tag>
183   A driver for the RAM in bank 2. Supports up to 255 pages with 256 bytes
184   each. Untested!
185 </descrip><p>
186
187
188 <sect1>Joystick drivers<p>
189
190 The Commodore 610 is a business machine and doesn't have joystick ports. There
191 are no drivers for the non existing ports available.
192
193
194
195 <sect1>Mouse drivers<p>
196
197 Currently no drivers available (in fact, the API for loadable mouse drivers
198 does not exist).
199
200
201 <sect1>RS232 device drivers<p>
202
203 Currently no RS232 drivers exist for the Commodore 610.
204
205
206
207 <sect>Limitations<label id="limitations"><p>
208
209
210 <sect1>Disk I/O<p>
211
212 The existing library for the CBM 610 doesn't implement C file I/O. Please note
213 that this includes <tt/printf/! You may use the conio functions for screen I/O.
214
215 To be more concrete, this limitation means that you cannot use any of the
216 following functions (and a few others):
217
218 <itemize>
219 <item>fclose
220 <item>fgets
221 <item>fopen
222 <item>fread
223 <item>fprintf
224 <item>fputc
225 <item>fscanf
226 <item>fwrite
227 <item>gets
228 <item>printf
229 <item>...
230 </itemize>
231
232
233 <sect1>Kernal and hardware access<p>
234
235 Since the program runs in bank 1, and the kernal and all I/O chips are located
236 in bank 15, calling ROM routines or accessing hardware needs special code.
237
238
239
240 <sect>Other hints<p>
241
242 <sect1>Passing arguments to the program<p>
243
244 Command line argument passing is currently not supported for the Commodore
245 610.
246
247
248
249 <sect>Bugs/Feedback<p>
250
251 If you have problems using the library, if you find any bugs, or if you're
252 doing something interesting with it, I would be glad to hear from you. Feel
253 free to contact me by email (<htmlurl url="mailto:uz@cc65.org"
254 name="uz@cc65.org">).
255
256
257
258 <sect>License<p>
259
260 This software is provided 'as-is', without any expressed or implied
261 warranty.  In no event will the authors be held liable for any damages
262 arising from the use of this software.
263
264 Permission is granted to anyone to use this software for any purpose,
265 including commercial applications, and to alter it and redistribute it
266 freely, subject to the following restrictions:
267
268 <enum>
269 <item>  The origin of this software must not be misrepresented; you must not
270         claim that you wrote the original software. If you use this software
271         in a product, an acknowledgment in the product documentation would be
272         appreciated but is not required.
273 <item>  Altered source versions must be plainly marked as such, and must not
274         be misrepresented as being the original software.
275 <item>  This notice may not be removed or altered from any source
276         distribution.
277 </enum>
278
279 </article>
280
281
282