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