]> git.sur5r.net Git - cc65/blob - doc/plus4.sgml
remote TABs in doc/ and test/
[cc65] / doc / plus4.sgml
1 <!doctype linuxdoc system>
2
3 <article>
4 <title>Commodore Plus/4 specific information for cc65
5 <author><url url="mailto:uz@cc65.org" name="Ullrich von Bassewitz">
6
7 <abstract>
8 An overview over the Plus/4 runtime system as it is implemented for the cc65 C
9 compiler.
10 </abstract>
11
12 <!-- Table of contents -->
13 <toc>
14
15 <!-- Begin the document -->
16
17 <sect>Overview<p>
18
19 This file contains an overview of the Plus/4 runtime system as it comes with the
20 cc65 C compiler. It describes the memory layout, Plus/4 specific header files,
21 available drivers, and any pitfalls specific to that platform.
22
23 Please note that Plus/4 specific functions are just mentioned here, they are
24 described in detail in the separate <url url="funcref.html" name="function
25 reference">. Even functions marked as "platform dependent" may be available on
26 more than one platform. Please see the function reference for more
27 information.
28
29 Since the Plus/4 and the Commodore 16/116 are almost identical (the latter are
30 missing the 6551 ACIA and do only have 16KB of memory), the <url
31 url="c16.html" name="C16 documentation"> is also worth a look. The difference
32 between both cc65 targets is that the Plus/4 runtime uses banking to support
33 full 64K RAM, while the C16 does not use banking and supports up to 32K RAM.
34 Because banking is not needed, most C16 programs will be somewhat smaller than
35 the same program compiled for the Plus/4. However, programs compiled for the
36 C16 will always run on the Plus/4, while the reverse is not necessarily true.
37
38
39 <sect>Binary format<p>
40
41 The standard binary output format generated by the linker for the Plus/4
42 target is a machine language program with a one line BASIC stub, which calls
43 the machine language part via SYS. This means that a program can be loaded as
44 BASIC program and started with RUN. It is of course possible to change this
45 behaviour by using a modified startup file and linker config.
46
47
48 <sect>Memory layout<p>
49
50 cc65 generated programs with the default setup run with the kernal and basic
51 banked out. This gives a usable memory range of &dollar;1000 - &dollar;FD00.
52 Having the kernal and basic ROMs banked out means, that no ROM entry points
53 may be called directly from user code.
54
55 Special locations:
56
57 <descrip>
58   <tag/Text screen/
59   The text screen is located at &dollar;C00 (as in the standard setup).
60
61   <tag/Color RAM/
62   The color RAM is located at &dollar;800 (standard location).
63
64   <tag/Stack/
65   The C runtime stack is located at &dollar;FCFF and growing downwards.
66
67   <tag/Heap/
68   The C heap is located at the end of the program and grows towards the C
69   runtime stack.
70
71 </descrip><p>
72
73
74
75 <sect>Platform specific header files<p>
76
77 Programs containing Plus/4 specific code may use the <tt/plus4.h/ or <tt/cbm.h/
78 header files. Using the later may be an option when writing code for more than
79 one CBM platform, since it includes <tt/plus4.h/ and declares several functions
80 common to all CBM platforms.
81
82 Please note that most of the header file declarations from the <tt/plus4.h/
83 header file are shared between the C16 and Plus/4 configurations. For this
84 reason, most of it is located in a common header file named <tt/cbm264.h/.
85
86
87
88 <sect1>Plus/4 specific functions<p>
89
90 There are currently no special Plus/4 functions.
91
92
93 <sect1>CBM specific functions<p>
94
95 Some functions are available for all (or at least most) of the Commodore
96 machines. See the <url url="funcref.html" name="function reference"> for
97 declaration and usage.
98
99 <itemize>
100 <item>cbm_close
101 <item>cbm_closedir
102 <item>cbm_k_setlfs
103 <item>cbm_k_setnam
104 <item>cbm_k_load
105 <item>cbm_k_save
106 <item>cbm_k_open
107 <item>cbm_k_close
108 <item>cbm_k_readst
109 <item>cbm_k_chkin
110 <item>cbm_k_ckout
111 <item>cbm_k_basin
112 <item>cbm_k_bsout
113 <item>cbm_k_clrch
114 <item>cbm_k_tksa
115 <item>cbm_k_second
116 <item>cbm_load
117 <item>cbm_open
118 <item>cbm_opendir
119 <item>cbm_read
120 <item>cbm_readdir
121 <item>cbm_save
122 <item>cbm_write
123 <item>get_tv
124 </itemize>
125
126
127 <sect1>CBM specific CPU functions<p>
128
129 Some CPU related functions are available for some of the Commodore
130 machines. See the <url url="funcref.html" name="function reference"> for
131 declaration and usage.
132
133 <itemize>
134 <item>fast
135 <item>slow
136 <item>isfast
137 </itemize>
138
139
140 <sect1>Hardware access<p>
141
142 The following pseudo variables declared in the <tt/plus4.h/ header file do
143 allow access to hardware located in the address space. Some variables are
144 structures, accessing the struct fields will access the chip registers.
145
146 <descrip>
147
148   <tag><tt/TED/</tag>
149   The <tt/TED/ structure allows access to the TED chip. See the
150   <tt/_ted.h/ header file located in the include directory for the
151   declaration of the structure.
152
153   <tag><tt/COLOR_RAM/</tag>
154   A character array that mirrors the color RAM of the Plus/4 at &dollar;0800.
155
156 </descrip><p>
157
158
159
160 <sect>Loadable drivers<p>
161
162 The names in the parentheses denote the symbols to be used for static linking of the drivers.
163
164
165 <sect1>Graphics drivers<p>
166
167 No graphics drivers are currently available for the Plus/4.
168
169
170 <sect1>Extended memory drivers<p>
171
172 No extended memory drivers are currently available for the Plus/4.
173
174
175 <sect1>Joystick drivers<p>
176
177 <descrip>
178
179   <tag><tt/plus4-stdjoy.joy (plus4_stdjoy_joy)/</tag>
180   Supports up to two joysticks connected to the standard joysticks port of
181   the Plus/4.
182
183 </descrip><p>
184
185
186 <sect1>Mouse drivers<p>
187
188 No mouse drivers are currently available for the Plus/4.
189
190
191 <sect1>RS232 device drivers<p>
192
193 <descrip>
194
195   <tag><tt/plus4-stdser.ser (plus4_stdser_ser)/</tag>
196   Driver for the 6551 ACIA chip built into the Plus/4. Supports up to 19200
197   baud, hardware flow control (RTS/CTS) and interrupt driven receives. Note
198   that because of the peculiarities of the 6551 chip transmits are not
199   interrupt driven, and the transceiver blocks if the receiver asserts flow
200   control because of a full buffer.
201
202   You need an adapter to use the builtin port, since the output levels
203   available at the user port don't follow the RS232 standard.
204
205 </descrip><p>
206
207
208
209 <sect>Limitations<p>
210
211
212
213 <sect>Other hints<p>
214
215 <sect1>Passing arguments to the program<p>
216
217 Command line arguments can be passed to <tt/main()/. Since this is not
218 supported by BASIC, the following syntax was chosen:
219
220 <tscreen><verb>
221     RUN:REM ARG1 " ARG2 IS QUOTED" ARG3 "" ARG5
222 </verb></tscreen>
223
224 <enum>
225 <item>Arguments are separated by spaces.
226 <item>Arguments may be quoted.
227 <item>Leading and trailing spaces around an argument are ignored. Spaces within
228       a quoted argument are allowed.
229 <item>The first argument passed to <tt/main/ is the program name.
230 <item>A maximum number of 10 arguments (including the program name) are
231       supported.
232 </enum>
233
234
235
236 <sect1>Program return code<p>
237
238 The program return code (low byte) is passed back to BASIC by use of the
239 <tt/ST/ variable.
240
241
242 <sect1>Interrupts<p>
243
244 The runtime for the Plus/4 uses routines marked as <tt/.INTERRUPTOR/ for
245 interrupt handlers. Such routines must be written as simple machine language
246 subroutines and will be called automatically by the interrupt handler code
247 when they are linked into a program. See the discussion of the <tt/.CONDES/
248 feature in the <url url="ca65.html" name="assembler manual">.
249
250
251
252 <sect>License<p>
253
254 This software is provided 'as-is', without any expressed or implied
255 warranty.  In no event will the authors be held liable for any damages
256 arising from the use of this software.
257
258 Permission is granted to anyone to use this software for any purpose,
259 including commercial applications, and to alter it and redistribute it
260 freely, subject to the following restrictions:
261
262 <enum>
263 <item>  The origin of this software must not be misrepresented; you must not
264         claim that you wrote the original software. If you use this software
265         in a product, an acknowledgment in the product documentation would be
266         appreciated but is not required.
267 <item>  Altered source versions must be plainly marked as such, and must not
268         be misrepresented as being the original software.
269 <item>  This notice may not be removed or altered from any source
270         distribution.
271 </enum>
272
273 </article>