├── apple2.html ├── apple2enh.html ├── ar65.html ├── atari.html ├── atari2600.html ├── atari5200.html ├── atari7800.html ├── atmos.html ├── c128.html ├── c16.html ├── c64.html ├── ca65.html ├── cbm510.html ├── cbm610.html ├── cc65-intern.html ├── cc65.html ├── chrcvt65.html ├── cl65.html ├── co65.html ├── coding.html ├── creativision.html ├── customizing.html ├── cx16.html ├── da65.html ├── debugging.html ├── dio.html ├── doc.css ├── doc.png ├── funcref.html ├── gamate.html ├── geos.html ├── grc65.html ├── index.html ├── intro.html ├── kim1.html ├── ld65.html ├── library.html ├── lynx.html ├── nes.html ├── od65.html ├── osi.html ├── pce.html ├── pet.html ├── plus4.html ├── rp6502.html ├── sim65.html ├── smc.html ├── sp65.html ├── supervision.html ├── sym1.html ├── telestrat.html ├── tgi.html ├── using-make.html └── vic20.html /ar65.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | ar65 Users Guide 8 | 9 | 10 |

ar65 Users Guide

11 | 12 |

13 | Ullrich von Bassewitz

14 |
15 | ar65 is an archiver for object files generated by ca65. It allows to create 16 | archives, add or remove modules from archives, and to extract modules from 17 | existing archives. 18 |
19 |

20 |

1. Overview

21 | 22 |

23 |

2. Usage

24 | 25 |

26 |

3. Copyright

27 | 28 | 29 |
30 |

1. Overview

31 | 32 | 33 | 34 |

ar65 is a replacement for the libr65 archiver that was part of the cc65 C 35 | compiler suite developed by John R. Dunning. libr65 had some problems and 36 | the copyright does not permit some things which I wanted to be possible, 37 | so I decided to write a completely new assembler/linker/archiver suite 38 | for the cc65 compiler. ar65 is part of this suite.

39 | 40 |

2. Usage

41 | 42 | 43 | 44 |

The archiver is called as follows:

45 |

46 |

47 |
 48 |         Usage: ar65 <operation ...> lib file|module ...
 49 |         Operations are some of:
 50 |                 r       Add modules
 51 |                 d       Delete modules
 52 |                 t       List library table
 53 |                 v       Increase verbosity (put before other operation)
 54 |                 x       Extract modules
 55 |                 V       Print the archiver version
 56 | 
57 |
58 |

59 |

You may add modules to a library using the 'r' command ('a' is deprecated). If the library 60 | does not exist, it is created (and a warning message is printed which you 61 | may ignore if creation of the library was your intention). You may 62 | specify any number of modules on the command line following the library.

63 |

If a module with the same name exists in the library, it is replaced by 64 | the new one. The archiver prints a warning, if the module in the library 65 | has a newer timestamp than the one to add.

66 |

Here's an example:

67 |

68 |

69 |
 70 |         ar65 r mysubs.lib sub1.o sub2.o
 71 | 
72 |
73 |

74 |

This will add two modules to the library 'mysubs.lib' creating the 75 | library if necessary. If the library contains modules named sub1.o or 76 | sub2.o, they are replaced by the new ones.

77 |

Modules names in the library are stored without the path, so, using

78 |

79 |

80 |
 81 |         ar65 v v r mysubs.lib ofiles/sub1.o ofiles/sub2.o
 82 | 
83 |
84 |

85 |

will verbose add two modules named 'sub1.o' and 'sub2.o' to the library.

86 |

Deleting modules from a library is done with the 'd' command. You may not 87 | give a path when naming the modules.

88 |

Example:

89 |

90 |

91 |
 92 |         ar65 d mysubs.lib sub1.o
 93 | 
94 |
95 |

96 |

This will delete the module named 'sub1.o' from the library, printing an 97 | error if the library does not contain that module.

98 | 99 |

The 't' command prints a table of all modules in the library ('l' is deprecated). 100 | Any module names on the command line are ignored.

101 |

Example:

102 |

103 |

104 |
105 |         ar65 tv mysubs.lib
106 | 
107 |
108 |

109 | 110 |

Using the 'x' command, you may extract modules from the library. The 111 | modules named on the command line are extracted from the library and put 112 | into the current directory.

113 |

Note: Because of the indexing done by the archiver, the modules may have 114 | a changed binary layout, that is, a binary compare with the old module 115 | (before importing it into the library) may yield differences. The 116 | extracted modules are accepted by the linker and archiver, however, so 117 | this is not a problem.

118 |

Example for extracting a module from the library:

119 |

120 |

121 |
122 |         ar65 x mysubs.lib sub1.o
123 | 
124 |
125 |

126 | 127 |

The 'V' command prints the version number of the assembler. If you send 128 | any suggestions or bugfixes, please include your version number.

129 |

In addition to these operations, the archiver will check for, and warn 130 | about duplicate external symbols in the library, every time when an 131 | operation does update the library. This is only a warning, the linker 132 | will ignore one of the duplicate symbols (which one is unspecified).

133 | 134 | 135 |

3. Copyright

136 | 137 | 138 |

ar65 (and all cc65 binutils) are (C) Copyright 1998-2000 Ullrich von 139 | Bassewitz. For usage of the binaries and/or sources the following conditions 140 | do apply:

141 |

This software is provided 'as-is', without any expressed or implied 142 | warranty. In no event will the authors be held liable for any damages 143 | arising from the use of this software.

144 |

Permission is granted to anyone to use this software for any purpose, 145 | including commercial applications, and to alter it and redistribute it 146 | freely, subject to the following restrictions:

147 |

148 |

    149 |
  1. The origin of this software must not be misrepresented; you must not 150 | claim that you wrote the original software. If you use this software 151 | in a product, an acknowledgment in the product documentation would be 152 | appreciated but is not required.
  2. 153 |
  3. Altered source versions must be plainly marked as such, and must not 154 | be misrepresented as being the original software.
  4. 155 |
  5. This notice may not be removed or altered from any source 156 | distribution.
  6. 157 |
158 |

159 | 160 | 161 | 162 | -------------------------------------------------------------------------------- /atari2600.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Atari 2600 specific information for cc65 8 | 9 | 10 |

Atari 2600 specific information for cc65

11 | 12 |

13 | Florent Flament

14 |
15 | An overview over the Atari 2600 runtime system as it is implemented 16 | for the cc65 C compiler. 17 |
18 |

19 |

1. Overview

20 | 21 |

22 |

2. Binary format

23 | 24 |

25 |

3. Memory layout

26 | 27 |

28 |

4. Start-up condition

29 | 30 |

31 |

5. Platform specific header files

32 | 33 |

34 |

6. Loadable drivers

35 | 36 |

37 |

7. Limitations

38 | 39 |

40 |

8. Other hints

41 | 42 |

43 |

9. License

44 | 45 | 46 |
47 |

1. Overview

48 | 49 | 50 |

This file contains an overview of the Atari 2600 runtime system as it 51 | comes with the cc65 C compiler. It describes the memory layout, Atari 52 | 2600 specific header files and any pitfalls specific to that platform.

53 | 54 |

2. Binary format

55 | 56 | 57 |

The default binary output format generated by the linker for the Atari 58 | 2600 target is a 4K cartridge image.

59 | 60 |

3. Memory layout

61 | 62 | 63 |

cc65 generated programs with the default setup can use RAM from 64 | $0080 to $00FF - __STACKSIZE__, where __STACKSIZE__ is 65 | the size of the system stack with a default value of 16 bytes. The 66 | size of the system stack can be customized by defining the 67 | __STACKSIZE__ linker variable.

68 |

Special locations:

69 |

70 |

71 |
Stack
72 |

The C runtime stack is located at $00FF - 73 | __STACKSIZE__ and growing downwards.

74 | 75 |
Heap
76 |

The C heap is located at $0080 and grows upwards.

77 | 78 |
79 |

80 | 81 | 82 |

4. Start-up condition

83 | 84 | 85 |

When powered-up, the Atari 2600 TIA registers contain random 86 | values. During the initialization phase, the start-up code needs to 87 | initialize the TIA registers to sound values (or else the console has 88 | an unpredictable behavior). In this implementation, zeros are written 89 | to all of TIA registers during the start-up phase.

90 |

Note that RIOT registers (mostly timers) are left uninitialized, as 91 | they don't have any consequence on the console behavior.

92 | 93 |

5. Platform specific header files

94 | 95 | 96 |

Programs containing Atari 2600 specific code may use the 97 | atari2600.h header file.

98 |

The following pseudo variables declared in the atari2600.h header 99 | file allow access to the Atari 2600 TIA & RIOT chips registers.

100 |

101 |

102 | 103 |
TIA
104 |

The TIA structure allows read/write access 105 | to the Atari 2600 TIA chip registers. See the _tia.h header 106 | file located in the include directory for the declaration of the 107 | structure. Also refer to the Stella Programmer's Guide by Steve 108 | Wright for a detailed description of the chip and its registers.

109 | 110 |
RIOT
111 |

The RIOT structure allows read/write 112 | access to the Atari 2600 RIOT chip registers. See the 113 | _riot.h header file located in the include directory for the 114 | declaration of the structure. Also refer to the Stella Programmer's 115 | Guide by Steve Wright for a detailed description of the chip and its 116 | registers.

117 | 118 |
119 |

120 | 121 | 122 | 123 |

6. Loadable drivers

124 | 125 | 126 |

There are no drivers for the Atari 2600.

127 | 128 | 129 |

7. Limitations

130 | 131 | 132 |

TBD

133 | 134 | 135 |

8. Other hints

136 | 137 | 138 |

One may write a custom linker configuration file to tune the memory 139 | layout of a program. See the atari2600.cfg file in the cfg 140 | directory as a starting point.

141 | 142 | 143 |

9. License

144 | 145 | 146 |

This software is provided 'as-is', without any expressed or implied 147 | warranty. In no event will the authors be held liable for any damages 148 | arising from the use of this software.

149 |

Permission is granted to anyone to use this software for any purpose, 150 | including commercial applications, and to alter it and redistribute it 151 | freely, subject to the following restrictions:

152 |

153 |

    154 |
  1. The origin of this software must not be misrepresented; you must not 155 | claim that you wrote the original software. If you use this software 156 | in a product, an acknowledgment in the product documentation would be 157 | appreciated but is not required.
  2. 158 |
  3. Altered source versions must be plainly marked as such, and must not 159 | be misrepresented as being the original software.
  4. 160 |
  5. This notice may not be removed or altered from any source 161 | distribution.
  6. 162 |
163 |

164 | 165 | 166 | 167 | -------------------------------------------------------------------------------- /atari7800.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Atari 7800 specific information for cc65 8 | 9 | 10 |

Atari 7800 specific information for cc65

11 | 12 |

13 | Karri Kaksonen

14 |
15 | An overview over the Atari 7800 runtime system as it is implemented 16 | for the cc65 C compiler. 17 |
18 |

19 |

1. Overview

20 | 21 |

22 |

2. Binary format

23 | 24 |

25 |

3. A78 header

26 | 27 |

28 |

4. Encryption

29 | 30 |

31 |

5. Memory layout

32 | 33 |

34 |

6. Start-up condition

35 | 36 |

37 |

7. Platform specific header files

38 | 39 |

40 |

8. Loadable drivers

41 | 42 |

43 |

9. Limitations

44 | 45 |

46 |

10. Other hints

47 | 48 |

49 |

11. License

50 | 51 | 52 |
53 |

1. Overview

54 | 55 | 56 |

This file contains an overview of the Atari 7800 runtime system as it 57 | comes with the cc65 C compiler. It describes the memory layout, Atari 58 | 7800 specific header files and any pitfalls specific to that platform.

59 | 60 |

2. Binary format

61 | 62 | 63 |

The default binary output format generated by the linker for the Atari 64 | 7800 target is a 48K cartridge image.

65 | 66 |

3. A78 header

67 | 68 | 69 |

There is lots of different cart hardware available for the atari7800. 70 | Some carts have ROM, RAM, sound hardware, non-volatile high score chips. 71 | In order to know what kind of hardware the cart build requires there is 72 | a header file of 128 bytes in front of the binary.

73 |

The default build creates a cart file for a 48K rom cart without any 74 | extra features like the pokey audio chip or extra RAM.

75 |

In order to make cc65 more user friendly the build will add the a78 76 | header automatically. This allows you to run the binary on emulators 77 | and flash carts on the real console.

78 | 79 |

4. Encryption

80 | 81 | 82 |

In order to boot the game in a mode that supports atari7800 functions 83 | the cart must be encrypted after the linking phase. 84 | There is a program called sign7800 that can be used to sign the cart. 85 | The encryption is not required for running the cart on emulators. 86 | You can also run atari2600 games without encryption.

87 | 88 |

5. Memory layout

89 | 90 | 91 |

cc65 generated programs with the default setup can use RAM from 92 | from $1800 to $203f. 93 | The 4k RAM is then mapped to zero page area. 94 | $2040 to $20ff is visible as zero page. 95 | After that we have a vero small RAM area that is unused. 96 | $2100 to $213f. 97 | Then we mirror a second block from the RAM to become the hardware stack. 98 | This would be from $2140 to $21ff.

99 |

The C-stack starts at $2800 and it can grow down to $2200.

100 |

size of the system stack can be customized by defining the 101 | __STACKSIZE__ linker variable.

102 |

Special locations:

103 |

104 |

105 |
Stack
106 |

The C runtime stack is located at $2800 - 107 | __STACKSIZE__ and growing downwards.

108 | 109 |
Heap
110 |

The C heap is located at $2200 and grows upwards.

111 | 112 |
113 |

114 | 115 | 116 |

6. Start-up condition

117 | 118 | 119 |

When powered-up, the Atari 7800 TIA registers contain random 120 | values. During the initialization phase, the start-up code needs to 121 | initialize the TIA registers to sound values (or else the console has 122 | an unpredictable behavior). In this implementation, zeros are written 123 | to all of TIA registers during the start-up phase.

124 |

Note that RIOT registers (mostly timers) are left uninitialized, as 125 | they don't have any consequence on the console behavior.

126 | 127 |

7. Platform specific header files

128 | 129 | 130 |

Programs containing Atari 7800 specific code may use the 131 | atari7800.h header file.

132 |

The following pseudo variables declared in the atari7800.h header 133 | file allow access to the Atari 7800 TIA, MARIA & RIOT chips registers.

134 |

135 |

136 | 137 |
TIA
138 |

The TIA structure allows read/write access 139 | to the Atari 7800 TIA chip registers. See the _tia.h header 140 | file located in the include directory for the declaration of the 141 | structure. Also refer to the Stella Programmer's Guide by Steve 142 | Wright for a detailed description of the chip and its registers.

143 | 144 |
RIOT
145 |

The RIOT structure allows read/write 146 | access to the Atari 7800 RIOT chip registers. See the 147 | _riot.h header file located in the include directory for the 148 | declaration of the structure. Also refer to the Stella Programmer's 149 | Guide by Steve Wright for a detailed description of the chip and its 150 | registers.

151 | 152 |
MARIA
153 |

The MARIA structure allows read/write 154 | access to the Atari 7800 MARIA chip registers. See the 155 | _maria.h header file located in the include directory for the 156 | declaration of the structure.

157 | 158 |
159 |

160 | 161 | 162 | 163 |

8. Loadable drivers

164 | 165 | 166 |

There are no drivers for the Atari 7800.

167 | 168 | 169 |

9. Limitations

170 | 171 | 172 |

TBD

173 | 174 | 175 |

10. Other hints

176 | 177 | 178 |

One may write a custom linker configuration file to tune the memory 179 | layout of a program. See the atari7800.cfg file in the cfg 180 | directory as a starting point.

181 | 182 | 183 |

11. License

184 | 185 | 186 |

This software is provided 'as-is', without any expressed or implied 187 | warranty. In no event will the authors be held liable for any damages 188 | arising from the use of this software.

189 |

Permission is granted to anyone to use this software for any purpose, 190 | including commercial applications, and to alter it and redistribute it 191 | freely, subject to the following restrictions:

192 |

193 |

    194 |
  1. The origin of this software must not be misrepresented; you must not 195 | claim that you wrote the original software. If you use this software 196 | in a product, an acknowledgment in the product documentation would be 197 | appreciated but is not required.
  2. 198 |
  3. Altered source versions must be plainly marked as such, and must not 199 | be misrepresented as being the original software.
  4. 200 |
  5. This notice may not be removed or altered from any source 201 | distribution.
  6. 202 |
203 |

204 | 205 | 206 | 207 | -------------------------------------------------------------------------------- /c16.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Commodore 16/116 specific information for cc65 8 | 9 | 10 |

Commodore 16/116 specific information for cc65

11 | 12 |

13 | Ullrich von Bassewitz

14 |
15 | An overview over the C16 runtime system as it is implemented for the cc65 C 16 | compiler. 17 |
18 |

19 |

1. Overview

20 | 21 |

22 |

2. Binary format

23 | 24 |

25 |

3. Memory layout

26 | 27 |

28 |

4. Platform specific header files

29 | 30 | 36 |

37 |

5. Loadable drivers

38 | 39 | 46 |

47 |

6. Limitations

48 | 49 |

50 |

7. Other hints

51 | 52 | 57 |

58 |

8. License

59 | 60 | 61 |
62 |

1. Overview

63 | 64 | 65 |

This file contains an overview of the C16 runtime system as it comes with the 66 | cc65 C compiler. It describes the memory layout, C16/116 specific header 67 | files, available drivers, and any pitfalls specific to that platform.

68 |

Please note that C16 specific functions are just mentioned here, they are 69 | described in detail in the separate 70 | function reference. Even functions marked as "platform dependent" may be available on 71 | more than one platform. Please see the function reference for more 72 | information.

73 |

Since the C16/C116 and the Commodore Plus/4 are almost identical (the former 74 | don't have the 6551 ACIA and only 16KB of memory), the 75 | Plus/4 documentation is also worth a look. The 76 | difference between both cc65 targets is that the Plus/4 runtime uses banking 77 | to support full 64K RAM, while the C16 does not use banking and supports up to 78 | 32K RAM. Because banking is not needed, most C16 programs will be somewhat 79 | smaller than the same program compiled for the Plus/4. However, programs C16 80 | will always run on the Plus/4, while the reverse is not necessarily true.

81 | 82 | 83 |

2. Binary format

84 | 85 | 86 |

The standard binary output format generated by the linker for the C16/116 87 | target is a machine language program with a one line BASIC stub which, calls 88 | the machine language part via SYS. This means that a program can be loaded as 89 | BASIC program and started with RUN. It is of course possible to change this 90 | behaviour by using a modified startup file and linker config.

91 | 92 | 93 |

3. Memory layout

94 | 95 | 96 |

cc65 generated programs with the default setup run with the kernal and basic 97 | banked in. This gives a usable memory range of $1000 - $4000 98 | (or $8000 if the machine is equipped with 32K RAM or more). Having the 99 | kernal and basic ROMs banked in means, that ROM entry points may be called 100 | directly from user code.

101 |

Special locations:

102 |

103 |

104 |
Text screen
105 |

The text screen is located at $C00 (as in the standard setup).

106 | 107 |
Color RAM
108 |

The color RAM is located at $800 (standard location).

109 | 110 |
Stack
111 |

The C runtime stack is located at $3FFF ($7FFF in case of a 112 | machine with 32K of memory or more) and growing downwards.

113 | 114 |
Heap
115 |

The C heap is located at the end of the program and grows towards the C 116 | runtime stack.

117 | 118 |
119 |

120 | 121 | 122 | 123 | 124 |

4. Platform specific header files

125 | 126 | 127 |

Programs containing C16 specific code may use the c16.h or cbm.h 128 | header files. Using the later may be an option when writing code for more than 129 | one CBM platform, since it includes c16.h and declares several functions 130 | common to all CBM platforms.

131 |

Please note that most of the header file declarations from the c16.h 132 | header file are shared between the C16 and Plus/4 configurations. For this 133 | reason, most of it is located in a common header file named cbm264.h.

134 | 135 | 136 | 137 |

4.1 C16/C116 specific functions 138 |

139 | 140 | 141 |

There are currently no special C16/C116 functions.

142 | 143 | 144 |

4.2 CBM specific functions 145 |

146 | 147 | 148 |

Some functions are available for all (or at least most) of the Commodore 149 | machines. See the 150 | function reference for 151 | declaration and usage.

152 |

153 |

180 |

181 | 182 | 183 |

4.3 CBM specific CPU functions 184 |

185 | 186 | 187 |

Some CPU related functions are available for some of the Commodore 188 | machines. See the 189 | function reference for 190 | declaration and usage.

191 |

192 |

197 |

198 | 199 |

4.4 Hardware access 200 |

201 | 202 | 203 |

The following pseudo variables declared in the c16.h header file do 204 | allow access to hardware located in the address space. Some variables are 205 | structures, accessing the struct fields will access the chip registers.

206 |

207 |

208 | 209 |
TED
210 |

The TED structure allows access to the TED chip. See the 211 | _ted.h header file located in the include directory for the 212 | declaration of the structure.

213 | 214 |
COLOR_RAM
215 |

A character array that mirrors the color RAM of the C16 at $0800.

216 | 217 |
218 |

219 | 220 | 221 | 222 | 223 |

5. Loadable drivers

224 | 225 | 226 |

The names in the parentheses denote the symbols to be used for static linking of the drivers.

227 | 228 | 229 |

5.1 Graphics drivers 230 |

231 | 232 | 233 |

No graphics drivers are currently available for the C16/C116.

234 | 235 | 236 |

5.2 Extended memory drivers 237 |

238 | 239 | 240 |

241 |

242 | 243 |
c16-ram.emd (c16_ram_emd)
244 |

A driver for the hidden RAM below the BASIC and KERNAL ROMs. Supports 125 245 | pages with 256 bytes each if the machine is equipped with 64K of memory 246 | (a Plus/4 or a memory extended C16/116).

247 | 248 |
249 |

250 | 251 | 252 | 253 | 254 |

5.3 Joystick drivers 255 |

256 | 257 | 258 |

259 |

260 | 261 |
c16-stdjoy.joy (c16_stdjoy_joy)
262 |

Supports up to two joysticks connected to the standard joysticks port of 263 | the Commodore 16/116.

264 | 265 |
266 |

267 | 268 | 269 | 270 | 271 |

5.4 Mouse drivers 272 |

273 | 274 | 275 |

No mouse drivers are currently available for the C16/C116.

276 | 277 | 278 |

5.5 RS232 device drivers 279 |

280 | 281 | 282 |

The Commodore 16 does not have a builtin ACIA and no RS232 extensions are 283 | known. For this reason, there are no RS232 drivers available. Please note that 284 | the standard Plus/4 driver will not run together with the C16 285 | library, because the latter does not support interrupts needed by the driver.

286 | 287 | 288 |

6. Limitations

289 | 290 | 291 | 292 | 293 | 294 |

7. Other hints

295 | 296 | 297 | 298 |

7.1 Passing arguments to the program 299 |

300 | 301 | 302 |

Command line arguments can be passed to main(). Since this is not 303 | supported by BASIC, the following syntax was chosen:

304 |

305 |

306 |
307 |     RUN:REM ARG1 " ARG2 IS QUOTED" ARG3 "" ARG5
308 | 
309 |
310 |

311 |

312 |

    313 |
  1. Arguments are separated by spaces.
  2. 314 |
  3. Arguments may be quoted.
  4. 315 |
  5. Leading and trailing spaces around an argument are ignored. Spaces within 316 | a quoted argument are allowed.
  6. 317 |
  7. The first argument passed to main is the program name.
  8. 318 |
  9. A maximum number of 10 arguments (including the program name) are 319 | supported.
  10. 320 |
321 |

322 | 323 | 324 |

7.2 Program return code 325 |

326 | 327 | 328 |

The program return code (low byte) is passed back to BASIC by use of the 329 | ST variable.

330 | 331 | 332 |

7.3 Interrupts 333 |

334 | 335 | 336 |

The runtime for the C16 uses routines marked as .INTERRUPTOR for 337 | interrupt handlers. Such routines must be written as simple machine language 338 | subroutines and will be called automatically by the interrupt handler code 339 | when they are linked into a program. See the discussion of the .CONDES 340 | feature in the 341 | assembler manual.

342 | 343 | 344 | 345 |

8. License

346 | 347 | 348 |

This software is provided 'as-is', without any expressed or implied 349 | warranty. In no event will the authors be held liable for any damages 350 | arising from the use of this software.

351 |

Permission is granted to anyone to use this software for any purpose, 352 | including commercial applications, and to alter it and redistribute it 353 | freely, subject to the following restrictions:

354 |

355 |

    356 |
  1. The origin of this software must not be misrepresented; you must not 357 | claim that you wrote the original software. If you use this software 358 | in a product, an acknowledgment in the product documentation would be 359 | appreciated but is not required.
  2. 360 |
  3. Altered source versions must be plainly marked as such, and must not 361 | be misrepresented as being the original software.
  4. 362 |
  5. This notice may not be removed or altered from any source 363 | distribution.
  6. 364 |
365 |

366 | 367 | 368 | 369 | -------------------------------------------------------------------------------- /cc65-intern.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | cc65 internals 8 | 9 | 10 |

cc65 internals

11 | 12 |

13 | Brad Smith

14 |
15 | Internal details of cc65 code generation, 16 | such as the expected linker configuration, 17 | and calling assembly functions from C. 18 |
19 |

20 |

1. Linker configuration

21 | 22 | 31 |

32 |

2. Calling assembly functions from C

33 | 34 | 39 | 40 |
41 |

1. Linker configuration

42 | 43 | 44 |

The C libraries and code generation depend directly on a suitable linker configuration. 45 | There are premade configuration files in the cfg/ directory, normally chosen by the 46 | linker's selected target. These can be used as a template for customization.

47 |

The C libraries depend on several special segments to be defined in your linker configuration. 48 | Generated code will also use some of them by default. 49 | Some platform libraries have additional special segments.

50 |

Memory areas are free to be defined in a way that is appropriate to each platform, 51 | and the segments they contain are used as a layer of semantics and abstraction, 52 | to allow much of the reorganization to be done with the linker config, 53 | rather than requiring platform-specific code source changes.

54 | 55 |

1.1 ZEROPAGE segment 56 |

57 | 58 | 59 |

Used by the C library and generated code for efficient internal and temporary state storage, 60 | also called "pseudo-registers".

61 | 62 |

1.2 STARTUP segment 63 |

64 | 65 | 66 |

Used by each platform instance of the C library in crt0.s to contain the entry point 67 | of the program.

68 |

The startup module will export __STARTUP__ : absolute = 1 to force the linker to 69 | always include crt0.s from the library.

70 | 71 |

1.3 CODE segment 72 |

73 | 74 | 75 |

The default segment for generated code, and most C library code will be located here.

76 |

Use #pragma code-name to redirect generated code to another segment.

77 | 78 |

1.4 BSS segment 79 |

80 | 81 | 82 |

Used for uninitialized variables. 83 | Originally an acronym for "Block Started by Symbol", but the meaning of this is now obscure.

84 |

Use #pragma bss-name to redirect uninitialized variables to another segment.

85 | 86 |

1.5 DATA segment 87 |

88 | 89 | 90 |

Used for initialized variables.

91 |

On some platforms, this may be initialized as part of the program loading process, 92 | but on others it may have a separate LOAD and RUN address, 93 | allowing copydata to copy the initialization from the loaded location 94 | into their run destination in RAM.

95 |

Use #pragma data-name to redirect initialized variables to another segment.

96 | 97 |

1.6 RODATA segment 98 |

99 | 100 | 101 |

Used for read-only (constant) data.

102 |

Use #pragma rodata-name to redirect constant data to another segment.

103 | 104 |

1.7 FEATURES table 105 |

106 | 107 | 108 |

This currently defines table locations for the CONDES 109 | constructor, destructor, and interruptor features. 110 | Some platform libraries use these.

111 |

The constructors will be called with initlib at startup, 112 | and the destructors with donelib at program exit. 113 | Interruptors are called with callirq.

114 | 115 | 116 | 117 |

2. Calling assembly functions from C

118 | 119 | 120 | 121 |

2.1 Calling conventions 122 |

123 | 124 | 125 |

There are two calling conventions used in cc65:

126 |

127 |

136 |

137 |

The default convention is fastcall, but this can be changed with 138 | the --all-cdecl command line option. If a convention is specified in 139 | the function's declaration, that convention will be used instead. 140 | Variadic functions will always use cdecl convention.

141 |

If the --standard command line option is used, 142 | the cdecl and fastcall keywords will not be available. 143 | The standard compliant variations __cdecl__ and __fastcall__ are always available.

144 |

If a function has a prototype, parameters are pushed to the C-stack as their respective types 145 | (i.e. a char parameter will push 1 byte), but if a function has no prototype, default 146 | promotions will apply. This means that with no prototype, char will be promoted 147 | to int and be pushed as 2 bytes. "K & R"-style forward declarations may be used, 148 | but they will function the same as if no prototype was used.

149 | 150 |

2.2 Prologue, before the function call 151 |

152 | 153 | 154 |

If the function is declared as fastcall, the rightmost argument will be loaded into 155 | the A/X/sreg registers:

156 |

157 |

168 |

169 |

All other parameters will be pushed to the C-stack from left to right. 170 | The rightmost parameter will have the lowest address on the stack, 171 | and multi-byte parameters will have their least significant byte at the lower address.

172 |

The sp pseudo-register is a zeropage pointer to the base of the C-stack. 173 | If the function is variadic, the Y register will contain the number of 174 | bytes pushed to the stack for this function.

175 |

Example: 176 |

177 |
178 | // C prototype
179 | void cdecl foo(unsigned bar, unsigned char baz);
180 | 
181 | ; C-stack layout within the function:
182 | ;
183 | ;            +------------------+
184 | ;            | High byte of bar |
185 | ; Offset 2 ->+------------------+
186 | ;            | Low byte of bar  |
187 | ; Offset 1 ->+------------------+
188 | ;            | baz              |
189 | ; Offset 0 ->+------------------+
190 | 
191 | ; Example code for accessing bar. The variable is in A/X after this code snippet:
192 | ;
193 |     ldy     #2      ; Offset of high byte of bar
194 |     lda     (sp),y  ; High byte now in A
195 |     tax             ; High byte now in X
196 |     dey             ; Offset of low byte of bar
197 |     lda     (sp),y  ; Low byte now in A
198 | 
199 |
200 |

201 | 202 |

2.3 Epilogue, after the function call 203 |

204 | 205 | 206 | 207 |

Return requirements

208 | 209 | 210 |

If the function has a return value, it will appear in the A/X/sreg registers.

211 |

Functions with an 8-bit return value (char or unsigned char) are expected 212 | to promote this value to a 16-bit integer on return, and store the high byte in X. 213 | The compiler will depend on the promoted value in some cases (e.g. implicit conversion to int), 214 | and failure to return the high byte in X will cause unexpected errors. 215 | This problem does not apply to the sreg pseudo-register, which is only 216 | used if the return type is 32-bit.

217 |

If the function has a void return type, the compiler will not depend on the result 218 | of A/X/sreg, so these may be clobbered by the function.

219 |

The C-stack pointer sp must be restored by the function to its value before the 220 | function call prologue. It may pop all of its parameters from the C-stack 221 | (e.g. using the runtime function popa), 222 | or it could adjust sp directly. 223 | If the function is variadic, the Y register contains the number of bytes 224 | pushed to the stack on entry, which may be added to sp to restore its 225 | original state.

226 |

The internal pseudo-register regbank must not be changed by the function.

227 | 228 |

Clobbered state

229 | 230 | 231 |

The Y register may be clobbered by the function. 232 | The compiler will not depend on its state after a function call.

233 |

The A/X/sreg registers may be clobbered if any of them 234 | are not used by the return value (see above).

235 |

Many of the internal pseudo-registers used by cc65 are available for 236 | free use by any function called by C, and do not need to be preserved. 237 | Note that if another C function is called from your assembly function, 238 | it may clobber any of these itself:

239 |

240 |

254 |

255 | 256 | 257 | 258 | 259 | 260 | -------------------------------------------------------------------------------- /chrcvt65.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | chrcvt65 Users Guide 8 | 9 | 10 |

chrcvt65 Users Guide

11 | 12 |

13 | Stefan A. Haubenthal

14 |
15 | chrcvt65 is the vector font converter. It is able to convert a foreign font into 16 | the native format. 17 |
18 |

19 |

1. Overview

20 | 21 |

22 |

2. Usage

23 | 24 | 28 |

29 |

3. Input and output

30 | 31 |

32 |

4. Copyright

33 | 34 | 35 |
36 |

1. Overview

37 | 38 | 39 |

chrcvt65 is a vector font converter. It is able to convert a "BGI Stroked 40 | Font" to a compact TGI native vector font. See the function 41 | tgi_load_vectorfont for usage.

42 | 43 | 44 | 45 |

2. Usage

46 | 47 | 48 |

The chrcvt65 utility converts the font of one Borland file to its cc65 equivalent.

49 | 50 | 51 |

2.1 Command line option overview 52 |

53 | 54 | 55 |

The program may be called as follows:

56 |

57 |

58 |
 59 | ---------------------------------------------------------------------------
 60 | Usage: chrcvt65 [options] file [options] [file]
 61 | Short options:
 62 |   -h                    Help (this text)
 63 |   -v                    Be more verbose
 64 |   -V                    Print the version number and exit
 65 | 
 66 | Long options:
 67 |   --help                Help (this text)
 68 |   --verbose             Be more verbose
 69 |   --version             Print the version number and exit
 70 | ---------------------------------------------------------------------------
 71 | 
72 |
73 |

74 | 75 | 76 |

2.2 Command line options in detail 77 |

78 | 79 | 80 |

Here is a description of all the command line options:

81 |

82 |

83 | 84 |
-v, --verbose
85 |

Increase the converter verbosity.

86 | 87 | 88 |
-h, --help
89 |

Print the short option summary shown above.

90 | 91 | 92 |
-V, --version
93 |

Print the version number of the utility. When submitting a bug report, 94 | please include the operating system you're using, and the compiler 95 | version.

96 |
97 |

98 | 99 | 100 |

3. Input and output

101 | 102 | 103 |

The converter will read one CHR file per invocation and write the font 104 | in TCH format to a new file.

105 |

Example output for the command 106 |

107 |
108 | chrcvt65 --verbose LITT.CHR
109 | 
110 |
111 | 112 |
113 |
114 | BGI Stroked Font V1.1 - Aug 12, 1991
115 | Copyright (c) 1987,1988 Borland International
116 | 
117 |
118 |

119 | 120 | 121 | 122 |

4. Copyright

123 | 124 | 125 |

chrcvt65 is (C) Copyright 2009, Ullrich von Bassewitz. For usage of the 126 | binaries and/or sources the following conditions apply:

127 |

This software is provided 'as-is', without any expressed or implied 128 | warranty. In no event will the authors be held liable for any damages 129 | arising from the use of this software.

130 |

Permission is granted to anyone to use this software for any purpose, 131 | including commercial applications, and to alter it and redistribute it 132 | freely, subject to the following restrictions:

133 |

134 |

    135 |
  1. The origin of this software must not be misrepresented; you must not 136 | claim that you wrote the original software. If you use this software 137 | in a product, an acknowledgment in the product documentation would be 138 | appreciated but is not required.
  2. 139 |
  3. Altered source versions must be plainly marked as such, and must not 140 | be misrepresented as being the original software.
  4. 141 |
  5. This notice may not be removed or altered from any source 142 | distribution.
  6. 143 |
144 |

145 | 146 | 147 | 148 | -------------------------------------------------------------------------------- /coding.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | cc65 coding hints 8 | 9 | 10 |

cc65 coding hints

11 | 12 |

13 | Ullrich von Bassewitz

14 |
15 | How to generate the most effective code with cc65. 16 |
17 |

1. Use prototypes

18 | 19 | 20 |

This will not only help to find errors between separate modules, it will also 21 | generate better code, since the compiler must not assume that a variable sized 22 | parameter list is in place and must not pass the argument count to the called 23 | function. This will lead to shorter and faster code.

24 | 25 | 26 | 27 |

2. Don't declare auto variables in nested function blocks

28 | 29 | 30 |

Variable declarations in nested blocks are usually a good thing. But with 31 | cc65, there is a drawback: Since the compiler generates code in one pass, it 32 | must create the variables on the stack each time the block is entered and 33 | destroy them when the block is left. This causes a speed penalty and larger 34 | code.

35 | 36 | 37 | 38 |

3. Remember that the compiler does no high level optimizations

39 | 40 | 41 |

The compiler needs hints from you about the code to generate. It will try to 42 | optimize the generated code, but follow the outline you gave in your C 43 | program. So for example, when accessing indexed data structures, get a pointer 44 | to the element and use this pointer instead of calculating the index again and 45 | again. If you want to have your loops unrolled, or loop invariant code moved 46 | outside the loop, you have to do that yourself.

47 | 48 | 49 | 50 |

4. Longs are slow!

51 | 52 | 53 |

While long support is necessary for some things, it's really, really slow on 54 | the 6502. Remember that any long variable will use 4 bytes of memory, and any 55 | operation works on double the data compared to an int.

56 | 57 | 58 | 59 |

5. Use unsigned types wherever possible

60 | 61 | 62 |

The 6502 CPU has no opcodes to handle signed values greater than 8 bit. So 63 | sign extension, test of signedness etc. has to be done with extra code. As a 64 | consequence, the code to handle signed operations is usually a bit larger and 65 | slower than the same code for unsigned types.

66 | 67 | 68 | 69 |

6. Use chars instead of ints if possible

70 | 71 | 72 |

While in arithmetic operations, chars are immediately promoted to ints, they 73 | are passed as chars in parameter lists and are accessed as chars in variables. 74 | The code generated is usually not much smaller, but it is faster, since 75 | accessing chars is faster. For several operations, the generated code may be 76 | better if intermediate results that are known not to be larger than 8 bit are 77 | casted to chars.

78 |

You should especially use unsigned chars for loop control variables if the 79 | loop is known not to execute more than 255 times.

80 | 81 | 82 | 83 |

7. Make the size of your array elements one of 1, 2, 4, 8

84 | 85 | 86 |

When indexing into an array, the compiler has to calculate the byte offset 87 | into the array, which is the index multiplied by the size of one element. When 88 | doing the multiplication, the compiler will do a strength reduction, that is, 89 | replace the multiplication by a shift if possible. For the values 2, 4 and 8, 90 | there are even more specialized subroutines available. So, array access is 91 | fastest when using one of these sizes.

92 | 93 | 94 | 95 |

8. Expressions are evaluated from left to right

96 | 97 | 98 |

Since cc65 is not building an explicit expression tree when parsing an 99 | expression, constant subexpressions may not be detected and optimized properly 100 | if you don't help. Look at this example:

101 |

102 |

103 |
104 |       #define OFFS   4
105 |       int  i;
106 |       i = i + OFFS + 3;
107 | 
108 |
109 |

110 |

The expression is parsed from left to right, that means, the compiler sees 'i', 111 | and puts it contents into the secondary register. Next is OFFS, which is 112 | constant. The compiler emits code to add a constant to the secondary register. 113 | Same thing again for the constant 3. So the code produced contains a fetch 114 | of 'i', two additions of constants, and a store (into 'i'). Unfortunately, the 115 | compiler does not see, that "OFFS + 3" is a constant for itself, since it does 116 | its evaluation from left to right. There are some ways to help the compiler 117 | to recognize expression like this:

118 |

119 |

    120 |
  1. Write "i = OFFS + 3 + i;". Since the first and second operand are 121 | constant, the compiler will evaluate them at compile time reducing the code to 122 | a fetch, one addition (secondary + constant) and one store. 123 |
  2. 124 |
  3. Write "i = i + (OFFS + 3)". When seeing the opening parenthesis, the 125 | compiler will start a new expression evaluation for the stuff in the braces, 126 | and since all operands in the subexpression are constant, it will detect this 127 | and reduce the code to one fetch, one addition and one store. 128 |
  4. 129 |
130 |

131 | 132 | 133 |

9. Use the preincrement and predecrement operators

134 | 135 | 136 |

The compiler is not always smart enough to figure out, if the rvalue of an 137 | increment is used or not. So it has to save and restore that value when 138 | producing code for the postincrement and postdecrement operators, even if this 139 | value is never used. To avoid the additional overhead, use the preincrement 140 | and predecrement operators if you don't need the resulting value. That means, 141 | use

142 |

143 |

144 |
145 |         ...
146 |         ++i;
147 |         ...
148 | 
149 |
150 |

151 |

instead of

152 |

153 |

154 |
155 |         ...
156 |         i++;
157 |         ...
158 | 
159 |
160 |

161 | 162 | 163 | 164 |

10. Use constants to access absolute memory locations

165 | 166 | 167 |

The compiler produces optimized code, if the value of a pointer is a constant. 168 | So, to access direct memory locations, use

169 |

170 |

171 |
172 |         #define VDC_STATUS 0xD601
173 |         *(char*)VDC_STATUS = 0x01;
174 | 
175 |
176 |

177 |

That will be translated to

178 |

179 |

180 |
181 |         lda     #$01
182 |         sta     $D601
183 | 
184 |
185 |

186 |

The constant value detection works also for struct pointers and arrays, if the 187 | subscript is a constant. So

188 |

189 |

190 |
191 |         #define VDC     ((unsigned char*)0xD600)
192 |         #define STATUS  0x01
193 |         VDC[STATUS] = 0x01;
194 | 
195 |
196 |

197 |

will also work.

198 |

If you first load the constant into a variable and use that variable to access 199 | an absolute memory location, the generated code will be much slower, since the 200 | compiler does not know anything about the contents of the variable.

201 | 202 | 203 | 204 |

11. Use initialized local variables

205 | 206 | 207 |

Initialization of local variables when declaring them gives shorter and faster 208 | code. So, use

209 |

210 |

211 |
212 |         int i = 1;
213 | 
214 |
215 |

216 |

instead of

217 |

218 |

219 |
220 |         int i;
221 |         i = 1;
222 | 
223 |
224 |

225 |

But beware: To maximize your savings, don't mix uninitialized and initialized 226 | variables. Create one block of initialized variables and one of uniniitalized 227 | ones. The reason for this is, that the compiler will sum up the space needed 228 | for uninitialized variables as long as possible, and then allocate the space 229 | once for all these variables. If you mix uninitialized and initialized 230 | variables, you force the compiler to allocate space for the uninitialized 231 | variables each time, it parses an initialized one. So do this:

232 |

233 |

234 |
235 |         int i, j;
236 |         int a = 3;
237 |         int b = 0;
238 | 
239 |
240 |

241 |

instead of

242 |

243 |

244 |
245 |         int i;
246 |         int a = 3;
247 |         int j;
248 |         int b = 0;
249 | 
250 |
251 |

252 |

The latter will work, but will create larger and slower code.

253 | 254 | 255 | 256 |

12. Use the array operator [] even for pointers

257 | 258 | 259 |

When addressing an array via a pointer, don't use the plus and dereference 260 | operators, but the array operator. This will generate better code in some 261 | common cases.

262 |

Don't use

263 |

264 |

265 |
266 |         char* a;
267 |         char b, c;
268 |         char b = *(a + c);
269 | 
270 |
271 |

272 |

Use

273 |

274 |

275 |
276 |         char* a;
277 |         char b, c;
278 |         char b = a[c];
279 | 
280 |
281 |

282 |

instead.

283 | 284 | 285 | 286 |

13. Use register variables with care

287 | 288 | 289 |

Register variables may give faster and shorter code, but they do also have an 290 | overhead. Register variables are actually zero page locations, so using them 291 | saves roughly one cycle per access. The calling routine may also use register 292 | variables, so the old values have to be saved on function entry and restored 293 | on exit. Saving and restoring has an overhead of about 70 cycles per 2 byte 294 | variable. It is easy to see, that - apart from the additional code that is 295 | needed to save and restore the values - you need to make heavy use of a 296 | variable to justify the overhead.

297 |

As a general rule: Use register variables only for pointers that are 298 | dereferenced several times in your function, or for heavily used induction 299 | variables in a loop (with several 100 accesses).

300 |

When declaring register variables, try to keep them together, because this 301 | will allow the compiler to save and restore the old values in one chunk, and 302 | not in several.

303 |

And remember: Register variables must be enabled with -r or -Or.

304 | 305 | 306 | 307 |

14. Decimal constants greater than 0x7FFF are actually long ints

308 | 309 | 310 |

The language rules for constant numeric values specify that decimal constants 311 | without a type suffix that are not in integer range must be of type long int 312 | or unsigned long int. So a simple constant like 40000 is of type long int! 313 | This is often unexpected and may cause an expression to be evaluated with 32 314 | bits. While in many cases the compiler takes care about it, in some places it 315 | can't. So be careful when you get a warning like

316 |

317 |

318 |
319 |         test.c(7): Warning: Constant is long
320 | 
321 |
322 |

323 |

Use the U, L or UL suffixes to tell the compiler the desired 324 | type of a numeric constant.

325 | 326 | 327 | 328 |

15. Access to parameters in variadic functions is expensive

329 | 330 | 331 |

Since cc65 has the "wrong" calling order, the location of the fixed parameters 332 | in a variadic function (a function with a variable parameter list) depends on 333 | the number and size of variable arguments passed. Since this number and size 334 | is unknown at compile time, the compiler will generate code to calculate the 335 | location on the stack when needed.

336 |

Because of this additional code, accessing the fixed parameters in a variadic 337 | function is much more expensive than access to parameters in a "normal" 338 | function. Unfortunately, this additional code is also invisible to the 339 | programmer, so it is easy to forget.

340 |

As a rule of thumb, if you access such a parameter more than once, you should 341 | think about copying it into a normal variable and using this variable instead.

342 | 343 | 344 | 345 | 346 | -------------------------------------------------------------------------------- /creativision.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | VTech Creativision (aka Funvision) specific information for cc65 8 | 9 | 10 |

VTech Creativision (aka Funvision) specific information for cc65

11 | 12 |

13 | Stefan A. Haubenthal

14 |
15 | An overview over the Creativision runtime system as it is implemented for the 16 | cc65 C compiler. 17 |
18 |

19 |

1. Overview

20 | 21 |

22 |

2. Binary format

23 | 24 |

25 |

3. Memory layout

26 | 27 |

28 |

4. Platform specific header files

29 | 30 | 33 |

34 |

5. Loadable drivers

35 | 36 | 43 |

44 |

6. Limitations

45 | 46 | 49 |

50 |

7. Other hints

51 | 52 |

53 |

8. License

54 | 55 | 56 |
57 |

1. Overview

58 | 59 | 60 |

This file contains an overview of the Creativision runtime system as it comes 61 | with the cc65 C compiler. It describes the memory layout, Creativision specific header 62 | files, available drivers, and any pitfalls specific to that platform.

63 |

Please note that Creativision specific functions are just mentioned here, they are 64 | described in detail in the separate 65 | function reference. Even functions marked as "platform dependent" may be available on 66 | more than one platform. Please see the function reference for more information.

67 | 68 | 69 |

2. Binary format

70 | 71 | 72 |

The standard binary output format generated by the linker for the Creativision target 73 | is a 4 KB ROM image. To create an 8 KB ROM a custom linker script has 74 | to be used.

75 | 76 |

3. Memory layout

77 | 78 | 79 |

cc65 generated programs with the default setup are 4 KB in size, 80 | occupying $B000 - $BFFF. Usable memory space for the 81 | user program is $B000 - $BEFF. $BF00 - 82 | $BFFF is reserved for the runtime and cartridge configuration 83 | area.

84 |

Special locations:

85 |

86 |

87 |
Text screen
88 |

The text screen is located at VRAM $1000.

89 | 90 |
Stack
91 |

The C runtime stack is located at $03FF and growing downwards.

92 | 93 |
RAM
94 |

The available RAM for cc65 programs of an unexpanded Creativision 95 | starts at $01FA and ends at $03FF.

96 | 97 |
Heap
98 |

The C heap is located at the end of the program's data area and 99 | grows towards the C runtime stack.

100 | 101 |
102 |

103 | 104 | 105 | 106 | 107 |

4. Platform specific header files

108 | 109 | 110 |

Programs containing Creativision specific code may use the creativision.h header file.

111 | 112 | 113 |

4.1 Creativision specific functions 114 |

115 | 116 | 117 |

118 |

124 |

125 | 126 | 127 | 128 | 129 | 130 | 131 |

5. Loadable drivers

132 | 133 | 134 | 135 |

5.1 Graphics drivers 136 |

137 | 138 | 139 |

No graphics drivers are currently available for the Creativision.

140 | 141 | 142 |

5.2 Extended memory drivers 143 |

144 | 145 | 146 |

No extended memory drivers are currently available for the Creativision.

147 | 148 | 149 |

5.3 Joystick drivers 150 |

151 | 152 | 153 |

154 |

155 | 156 |
creativision-stdjoy.joy (creativisionstd_joy)
157 |

A joystick driver for the standard joystick is available.

158 | 159 |
160 |

161 | 162 | 163 |

5.4 Mouse drivers 164 |

165 | 166 | 167 |

No mouse drivers are currently available for the Creativision.

168 | 169 | 170 |

5.5 RS232 device drivers 171 |

172 | 173 | 174 |

No communication port drivers are currently available for the Creativision.

175 | 176 | 177 | 178 |

6. Limitations

179 | 180 | 181 | 182 |

6.1 Disk I/O 183 |

184 | 185 | 186 |

The existing library for the Creativision doesn't implement C file 187 | I/O. There are even no hacks for the read() and write() routines.

188 |

To be more concrete, this limitation means that you cannot use any of the 189 | following functions (and a few others):

190 |

191 |

201 |

202 | 203 | 204 | 205 |

7. Other hints

206 | 207 | 208 | 209 | 210 | 211 |

8. License

212 | 213 | 214 |

This software is provided 'as-is', without any expressed or implied 215 | warranty. In no event will the authors be held liable for any damages 216 | arising from the use of this software.

217 |

Permission is granted to anyone to use this software for any purpose, 218 | including commercial applications, and to alter it and redistribute it 219 | freely, subject to the following restrictions:

220 |

221 |

    222 |
  1. The origin of this software must not be misrepresented; you must not 223 | claim that you wrote the original software. If you use this software 224 | in a product, an acknowledgment in the product documentation would be 225 | appreciated but is not required.
  2. 226 |
  3. Altered source versions must be plainly marked as such, and must not 227 | be misrepresented as being the original software.
  4. 228 |
  5. This notice may not be removed or altered from any source 229 | distribution.
  6. 230 |
231 |

232 | 233 | 234 | 235 | -------------------------------------------------------------------------------- /debugging.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Using emulators with cc65 8 | 9 | 10 |

Using emulators with cc65

11 | 12 |

13 | Ullrich von Bassewitz

14 |
15 | How to debug your code using the VICE and Oricutron emulators. 16 |
17 |

18 |

1. Overview

19 | 20 |

21 |

2. What is VICE?

22 | 23 |

24 |

3. How to prepare your programs

25 | 26 |

27 |

4. How to use the label file with VICE

28 | 29 |

30 |

5. How to use the label file with Oricutron

31 | 32 | 33 |
34 |

1. Overview

35 | 36 | 37 |

This document describes how to debug your programs using the cc65 development 38 | tools and the VICE or Oricutron emulator.

39 | 40 | 41 | 42 |

2. What is VICE?

43 | 44 | 45 |

VICE is an emulator for many of the CBM machines. It runs on Unix, MS-DOS, 46 | Win32, OS/2, Acorn RISC OS, BeOS, QNX 6.x, Amiga, GP2X and Mac OS X. It emulates 47 | the Commodore 64, 128, VIC20, PET and the 600/700 machines. For more information 48 | see the VICE home page:

49 |

50 | http://vice-emu.sourceforge.net/.

51 |

VICE has a builtin machine language monitor that may be used for debugging 52 | your programs. Using an emulator for debugging has some advantages:

53 |

54 |

67 |

68 | 69 | 70 | 71 |

3. How to prepare your programs

72 | 73 | 74 |

VICE support is mostly done via a label file that is generated by the linker 75 | and that may be read by the VICE monitor, so it knows about your program. 76 | Source level debugging is not available, you have to debug your programs 77 | in the assembler view.

78 |

The first step is to generate object files that contain information about 79 | all labels in your sources, not just the exported ones. This can be done 80 | by several means:

81 |

82 |

98 |

99 |

So, if you have just C code, all you need is to invoke the compiler with 100 | -g. If you're using assembler code, you have to use -g for the 101 | assembler, or add ".debuginfo on" to your source files. Since the 102 | generated debug info is not appended to the generated executables, it is a 103 | good idea to always use -g. It makes the object files and libraries 104 | slightly larger (~30%), but this is usually not a problem.

105 |

The second step is to tell the linker that it should generate a VICE label 106 | file. This is done by the -Ln switch followed by the name of the label 107 | file (I'm usually using a .lbl extension for these files). An example for 108 | a linker command line would be:

109 |

110 |

111 |
112 |     ld65 -o hello -t c64 -Ln hello.lbl -m hello.map hello.o c64.lib
113 | 
114 |
115 | 116 | or 117 |
118 |
119 |     ld65 -o hello.tap -t atmos -Ln hello.sym -m hello.map hello.o atmos.lib
120 | 
121 |
122 |

123 |

This will generate a file named hello.lbl that contains all symbols used in 124 | your program.

125 |

Note: The runtime libraries and startup files were generated with 126 | debug info, so you don't have to care about this.

127 | 128 | 129 | 130 |

4. How to use the label file with VICE

131 | 132 | 133 |

Load your program, then enter the monitor and use the "ll" command to 134 | load your label file like this:

135 |

136 |

137 |
138 |         ll "hello.lbl"
139 | 
140 |
141 |

142 |

You will get lots of warnings and even a few errors. You may ignore safely all 143 | these warnings and errors as long as they reference any problems VICE thinks 144 | it has with the labels.

145 |

After loading the labels, they are used by VICE in the disassembler listing, 146 | and you may use them wherever you need to specify an address. Try

147 |

148 |

149 |
150 |         d ._main
151 | 
152 |
153 |

154 |

as an example (note that VICE needs a leading dot before all labels, and that 155 | the compiler prepends an underline under most named labels).

156 |

If you start the emulator from the commandline, you can also load the labels 157 | directly using something like this:

158 |

159 |

160 |
161 |         x64sc -moncommands hello.lbl hello.prg
162 | 
163 |
164 |

165 | 166 | 167 |

5. How to use the label file with Oricutron

168 | 169 | 170 |

Load your program, then enter the monitor and use the "sl" command to 171 | load your label file like this:

172 |

173 |

174 |
175 |         sl hello.sym
176 | 
177 |
178 |

179 |

After loading the labels, they are used by Oricutron in the disassembler listing, 180 | and you may use them wherever you need to specify an address. Try

181 |

182 |

183 |
184 |         d ._main
185 | 
186 |
187 |

188 |

as an example.

189 | 190 | 191 | 192 | 193 | 194 | -------------------------------------------------------------------------------- /dio.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Diskette Sector I/O Routines 8 | 9 | 10 |

Diskette Sector I/O Routines

11 | 12 |

13 | Christian Groessler

14 |
15 | The cc65 library provides functions to read and write raw disk sectors. 16 | Include the dio.h header file to get the necessary definitions. 17 |
18 |

19 |

1. Opening the disk for low level I/O

20 | 21 |

22 |

2. Reading and writing sectors

23 | 24 |

25 |

3. Querying sector size and count

26 | 27 |

28 |

4. Converting sector numbers

29 | 30 | 31 |
32 |

1. Opening the disk for low level I/O

33 | 34 | 35 |

Prior to using these functions a handle to the device has to be obtained. This 36 | is done with the dio_open function. After use, the handle should be 37 | released with the dio_close function.

38 |

39 |

40 |
 41 |     dhandle_t __fastcall__ dio_open (unsigned char device);
 42 | 
43 |
44 |

45 |

The device specifies the device to access.

46 |

47 |

48 |
 49 |     unsigned char __fastcall__ dio_close (dhandle_t handle);
 50 | 
51 |
52 |

53 |

Closes a handle obtained by dio_open. Returns status code.

54 | 55 | 56 |

2. Reading and writing sectors

57 | 58 | 59 |

The read and write functions are:

60 |

61 |

62 |
 63 |     unsigned char __fastcall__ dio_read (dhandle_t handle,
 64 |                                          unsigned sect_num,
 65 |                                          void *buffer);
 66 | 
67 |
68 |

69 |

This function will read the sector specified by sect_num into the memory 70 | location at buffer.

71 |

72 |

73 |
 74 |     unsigned char __fastcall__ dio_write (dhandle_t handle,
 75 |                                           unsigned sect_num,
 76 |                                           const void *buffer);
 77 | 
78 |
79 |

80 |

This function will write the memory contents at buffer to the sector specified 81 | by sect_num. No verify is performed.

82 |

83 |

84 |
 85 |     unsigned char __fastcall__ dio_write_verify (dhandle_t handle,
 86 |                                                  unsigned sect_num,
 87 |                                                  const void *buffer);
 88 | 
89 |
90 |

91 |

This function will write the memory contents at buffer to the sector specified 92 | by sect_num. A verification is performed.

93 | 94 |

Use the 95 | dio_query_sectsize function to query 96 | the size of a sector and the 97 | dio_query_sectcount 98 | function to query the number of available sectors.

99 | 100 |

All these functions will return 0 for success and an OS specific error code in 101 | case of failure.

102 | 103 | 104 |

3. Querying sector size and count

105 | 106 | 107 |

Some systems support multiple diskette formats which have different sector sizes 108 | and/or different sector counts.

109 | 110 |

The following function returns the sector size of the currently inserted disk:

111 |

112 |

113 |
114 |     unsigned __fastcall__ dio_query_sectsize (dhandle_t handle);
115 | 
116 |
117 |

118 |

On the Atari platform, the sector size is handled specially. Please refer 119 | to the DIO section in the 120 | Atari-specific platform documentation.

121 | 122 |

The following function returns the sector count of the currently inserted disk:

123 |

124 |

125 |
126 |     unsigned __fastcall__ dio_query_sectcount (dhandle_t handle);
127 | 
128 |
129 |

130 | 131 |

4. Converting sector numbers

132 | 133 | 134 |

Since the read and write functions expect a sector number, for systems where 135 | the sectors aren't addressed by a logical sector number (e.g. CBM devices), 136 | there are 2 conversion functions. One of them converts a logical sector number 137 | to a head/track/sector triple. The other conversion function works the other 138 | way round.

139 |

140 |

141 |
142 |     unsigned char __fastcall__ dio_phys_to_log (dhandle_t handle,
143 |                                                 const dio_phys_pos *physpos,
144 |                                                 unsigned *sectnum);
145 | 
146 |
147 |

148 |

This function converts track/head/sector to logical sector number.

149 |

150 |

151 |
152 |     unsigned char __fastcall__ dio_log_to_phys (dhandle_t handle,
153 |                                                 const unsigned *sectnum,
154 |                                                 dio_phys_pos *physpos);
155 | 
156 |
157 |

158 |

This function converts a logical sector number to track/head/sector notation.

159 | 160 |

Note, that on systems which natively use logical sector numbers (e.g. Atari), 161 | the conversion functions are dummies. They ignore head/track 162 | (dio_phys_to_log) or return them as zero (dio_log_to_phys). 163 | The logical sector number is returned as physical sector and vice versa.

164 | 165 | 166 | 167 | 168 | 169 | -------------------------------------------------------------------------------- /doc.css: -------------------------------------------------------------------------------- 1 | body { 2 | font-family: arial, helvetica, sans-serif; 3 | font-size: 100%; 4 | text-align: justify; 5 | margin: 0px; 6 | padding-left: 110px; 7 | padding-top: 10px; 8 | padding-right: 30px; 9 | padding-bottom: 10px; 10 | background-image: url(doc.png); 11 | background-repeat: repeat-y; 12 | background-position:left top; 13 | } 14 | 15 | h1, h2, h2 a:link, h2 a:active, h2 a:visited { 16 | font-weight: bold; 17 | font-style: italic; 18 | text-align: left; 19 | color: #DB3232; 20 | } 21 | 22 | h1 { 23 | font-size: 250%; 24 | text-shadow: 2px 2px 6px #505050; 25 | letter-spacing: 2px; 26 | padding-top: 40px; 27 | } 28 | 29 | h2 { 30 | font-size: 150%; 31 | text-shadow: 1px 1px 3px #303030; 32 | letter-spacing: 1px; 33 | margin-top: 2em; 34 | margin-bottom: 1em; 35 | } 36 | -------------------------------------------------------------------------------- /doc.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cc65/doc/87e0a21324393706b1958ed8295ca5c788ae1af1/doc.png -------------------------------------------------------------------------------- /gamate.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Gamate System specific information for cc65 8 | 9 | 10 |

Gamate System specific information for cc65

11 | 12 |

13 | Groepaz

14 |
15 | An overview over the Gamate runtime system as it is implemented for the 16 | cc65 C compiler. 17 |
18 |

19 |

1. Overview

20 | 21 |

22 |

2. Binary format

23 | 24 |

25 |

3. Platform specific header files

26 | 27 | 30 |

31 |

4. Loadable drivers

32 | 33 | 40 |

41 |

5. Limitations

42 | 43 | 46 |

47 |

6. Other hints

48 | 49 |

50 |

7. License

51 | 52 | 53 |
54 |

1. Overview

55 | 56 | 57 |

This file contains an overview of the Gamate runtime system as it comes 58 | with the cc65 C compiler. It describes the memory layout, Gamate specific header 59 | files, available drivers, and any pitfalls specific to that platform.

60 |

Please note that Gamate specific functions are just mentioned here, they are 61 | described in detail in the separate 62 | function reference. Even functions marked as "platform dependent" may be available on 63 | more than one platform. Please see the function reference for more 64 | information.

65 | 66 | 67 |

2. Binary format

68 | 69 | 70 |

The standard binary output format generated by the linker for the Gamate target 71 | is a cartridge image with header. It is of course possible to change this 72 | behaviour by using a modified startup file and linker config.

73 |

Note: the first two bytes of the header contain a checksum that must be inserted 74 | by an external program. Such an utility is provided in util/gamate/gamate-fixcart.c

75 | 76 |

3. Platform specific header files

77 | 78 | 79 |

Programs containing Gamate specific code may use the gamate.h header file.

80 | 81 | 82 |

3.1 Gamate specific functions 83 |

84 | 85 | 86 |

87 |

90 |

91 | 92 | 93 | 94 |

4. Loadable drivers

95 | 96 | 97 |

All drivers must be statically linked because no file I/O is available. 98 | The names in the parentheses denote the symbols to be used for static linking of the drivers.

99 | 100 | 101 |

4.1 Graphics drivers 102 |

103 | 104 | 105 |

No TGI graphics drivers are currently available for the Gamate.

106 | 107 | 108 |

4.2 Extended memory drivers 109 |

110 | 111 | 112 |

No extended memory drivers are currently available for the Gamate.

113 | 114 | 115 |

4.3 Joystick drivers 116 |

117 | 118 | 119 |

120 |

121 | 122 |
gamate-stdjoy.joy (gamate_stdjoy)
123 |

A joystick driver for the standard two buttons joypad is available.

124 | 125 |
126 |

127 | 128 | 129 | 130 |

4.4 Mouse drivers 131 |

132 | 133 | 134 |

No mouse drivers are currently available for the Gamate.

135 | 136 | 137 |

4.5 RS232 device drivers 138 |

139 | 140 | 141 |

No serial drivers are currently available for the Gamate.

142 | 143 | 144 | 145 |

5. Limitations

146 | 147 | 148 |

149 |

153 |

154 | 155 |

5.1 Disk I/O 156 |

157 | 158 | 159 |

The existing library for the Gamate doesn't implement C file 160 | I/O. There are no hacks for the read() and write() routines.

161 |

To be more concrete, this limitation means that you cannot use any of the 162 | following functions (and a few others):

163 |

164 |

175 |

176 | 177 |

6. Other hints

178 | 179 | 180 |

181 |

185 |

186 | 187 |

7. License

188 | 189 | 190 |

This software is provided 'as-is', without any expressed or implied 191 | warranty. In no event will the authors be held liable for any damages 192 | arising from the use of this software.

193 |

Permission is granted to anyone to use this software for any purpose, 194 | including commercial applications, and to alter it and redistribute it 195 | freely, subject to the following restrictions:

196 |

197 |

    198 |
  1. The origin of this software must not be misrepresented; you must not 199 | claim that you wrote the original software. If you use this software 200 | in a product, an acknowledgment in the product documentation would be 201 | appreciated but is not required.
  2. 202 |
  3. Altered source versions must be plainly marked as such, and must not 203 | be misrepresented as being the original software.
  4. 204 |
  5. This notice may not be removed or altered from any source 205 | distribution.
  6. 206 |
207 |

208 | 209 | 210 | 211 | -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | cc65 Documentation Overview 8 | 9 | 10 |

cc65 Documentation Overview

11 | 12 |

13 | https://cc65.github.io/doc

14 |

1. Program documentation

15 | 16 | 17 |

18 |

19 | 20 |
21 | ar65.html
22 |

Describes the ar65 archiver.

23 | 24 |
25 | ca65.html
26 |

Describes the ca65 macro assembler.

27 | 28 |
29 | cc65.html
30 |

Describes the cc65 C compiler.

31 | 32 |
33 | chrcvt65.html
34 |

Describes the vector font converter.

35 | 36 |
37 | cl65.html
38 |

Describes the cl65 compile & link utility.

39 | 40 |
41 | co65.html
42 |

Describes the co65 object-file converter.

43 | 44 |
45 | da65.html
46 |

Describes the da65 6502/65C02 disassembler.

47 | 48 |
49 | grc65.html
50 |

Describes the GEOS resource compiler.

51 | 52 |
53 | ld65.html
54 |

Describes the ld65 linker.

55 | 56 |
57 | od65.html
58 |

Describes the od65 object-file analyzer.

59 | 60 |
61 | sim65.html
62 |

Describes the 6502 and 65C02 simulator.

63 | 64 |
65 | sp65.html
66 |

Describes the sprite and bitmap utility.

67 | 68 |
69 |

70 | 71 | 72 |

2. Usage

73 | 74 | 75 |

76 |

77 | 78 |
79 | intro.html
80 |

Describes the use of the tools, by building a short "hello world" 81 | example.

82 | 83 |
84 | coding.html
85 |

Contains hints on creating the most effective code with cc65.

86 | 87 |
88 | cc65-intern.html
89 |

Describes internal details of cc65: linker configuration, calling conventions, etc.

90 | 91 |
92 | using-make.html
93 |

Build programs, using the GNU Make utility.

94 | 95 |
96 | customizing.html
97 |

How to use the cc65 toolset for a custom hardware platform (a target system 98 | not currently supported by the cc65 library set).

99 | 100 |
101 | debugging.html
102 |

Debug programs, using the VICE emulator.

103 | 104 |
105 |

106 | 107 | 108 |

3. Library information and other references

109 | 110 | 111 |

112 |

113 | 114 |
115 | funcref.html
116 |

A (currently incomplete) function reference.

117 | 118 |
119 | dio.html
120 |

Low-level disk I/O API.

121 | 122 |
123 | tgi.html
124 |

Tiny Graphics Interface.

125 | 126 |
127 | geos.html
128 |

The GEOSLib manual.

129 | 130 |
131 | library.html
132 |

An overview over the cc65 runtime and C libraries.

133 | 134 |
135 | smc.html
136 |

Describes Christian Krüger's macro package for writing self modifying 137 | assembler code.

138 | 139 |
140 | 6502 Binary Relocation Format document
141 |

Describes the o65 file format that is used for dynamically loadable modules 142 | and LUnix programs.

143 | 144 |
145 |

146 | 147 | 148 |

4. Platform-specific information

149 | 150 | 151 |

152 |

153 | 154 |
155 | apple2.html
156 |

Topics specific to the Apple ][.

157 | 158 |
159 | apple2enh.html
160 |

Topics specific to the enhanced Apple //e.

161 | 162 |
163 | atari.html
164 |

Topics specific to the Atari 8-bit machines.

165 | 166 |
167 | atari2600.html
168 |

Topics specific to the Atari 2600 Game Console.

169 | 170 |
171 | atari5200.html
172 |

Topics specific to the Atari 5200 Game Console.

173 | 174 |
175 | atari7800.html
176 |

Topics specific to the Atari 7800 Game Console.

177 | 178 |
179 | atmos.html
180 |

Topics specific to the Oric Atmos.

181 | 182 |
183 | c128.html
184 |

Topics specific to the Commodore 128.

185 | 186 |
187 | c16.html
188 |

Topics specific to the Commodore 16/116.

189 | 190 |
191 | c64.html
192 |

Topics specific to the Commodore 64.

193 | 194 |
195 | cbm510.html
196 |

Topics specific to the Commodore 510.

197 | 198 |
199 | cbm610.html
200 |

Topics specific to the Commodore 610.

201 | 202 |
203 | creativision.html
204 |

Topics specific to the Creativision Console.

205 | 206 |
207 | cx16.html
208 |

Topics specific to the Commander X16.

209 | 210 |
211 | gamate.html
212 |

Topics specific to the Bit Corporation Gamate Console.

213 | 214 |
215 | kim1.html
216 |

Topics specific to the MOS Technology KIM-1.

217 | 218 |
219 | lynx.html
220 |

Topics specific to the Atari Lynx Game Console.

221 | 222 |
223 | nes.html
224 |

Topics specific to the Nintendo Entertainment System.

225 | 226 |
227 | osi.html
228 |

Topics specific to the Ohio Scientific machines.

229 | 230 |
231 | pce.html
232 |

Topics specific to the NEC PC-Engine (TurboGrafx-16) Console.

233 | 234 |
235 | pet.html
236 |

Topics specific to the Commodore PET machines.

237 | 238 |
239 | plus4.html
240 |

Topics specific to the Commodore Plus/4.

241 | 242 |
243 | rp6502.html
244 |

Topics specific to the Picocomputer 6502.

245 | 246 |
247 | supervision.html
248 |

Topics specific to the Watara Supervision Console.

249 | 250 |
251 | sym1.html
252 |

Topics specific to the Synertek Systems Sym-1.

253 | 254 |
255 | telestrat.html
256 |

Topics specific to the Oric Telestrat.

257 | 258 |
259 | vic20.html
260 |

Topics specific to the Commodore VIC20.

261 | 262 |
263 |

264 | 265 | 266 | 267 | 268 | -------------------------------------------------------------------------------- /kim1.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | MOS Technology KIM-1 specific information for cc65 8 | 9 | 10 |

MOS Technology KIM-1 specific information for cc65

11 | 12 |

13 | Dave Plummer

14 |
15 | An overview of the KIM-1 runtime system as it is implemented for the cc65 C compiler. 16 |
17 |

18 |

1. Overview

19 | 20 |

21 |

2. Binary format

22 | 23 |

24 |

3. Memory layout

25 | 26 |

27 |

4. Platform specific header files

28 | 29 |

30 |

5. Loadable drivers

31 | 32 | 38 |

39 |

6. Limitations

40 | 41 | 44 |

45 |

7. Other hints

46 | 47 | 52 |

53 |

8. License

54 | 55 | 56 |
57 |

1. Overview

58 | 59 | 60 |

This file contains an overview of the KIM-1 runtime system as it comes with the cc65 C compiler. 61 | It describes the memory layout, KIM-1 specific header files, available drivers, and any pitfalls 62 | specific to the platform.

63 |

Please note that KIM-1 specific functions are just mentioned here, they are described in detail 64 | in the separate 65 | function reference. Even functions marked as 66 | "platform dependent" may be available on more than one platform. Please see the 67 | function reference for more information.

68 | 69 |

2. Binary format

70 | 71 | 72 |

The output format generated by the linker for the KIM-1 target is a raw binary BIN file, which 73 | is essentially a memory image. You can convert this to a papertape format file using 74 | Convert8bithexformat or KIMPaper, which are open-source conversion utility programs. 75 | A papertape format files can be transferred to the KIM-1 using the RS-232 terminal port (TTY), 76 | just as if the machine-code was entered by hand. Enter 'L' in the TTY and start the paper tape file 77 | transfer.

78 | 79 | 80 |

Included with this distribution is a 4k configuration file and a 60k config file. The KIM-1 81 | on-board memory is limited to 4 kbytes but system memory can be increased to 60 kbytes of 82 | contiguous RAM with aftermarket add-on boards. So choose the config file that matches your 83 | system configuration before compiling and linking user programs.

84 | 85 |

3. Memory layout

86 | 87 | 88 |

The ROMs and I/O areas are defined in the configuration files, as are most of the entry points 89 | for useful subroutines in the KIM-1 monitor ROM. cc65 generated programs compiled and linked 90 | using 4k config run in the memory range of $200 - $0FFF. The 60k config expands 91 | this range to $DFFF. When using the 4k config the starting memory location and entry point 92 | for running the program is $200, so when the program is transferred to the KIM-1, it is 93 | executed by typing '200 G'. With the 60k config the default starting memory location and entry 94 | point is $2000.

95 |

Special locations:

96 |

97 |

98 |
Text screen
99 |

Conio support is not currently available for the KIM-1. But stdio console functions are available.

100 | 101 |
Stack
102 |

The C runtime stack is located at $0FFF on 4kb KIM-1s, or at $DFFF for 60kb systems. 103 | The stack always grows downwards.

104 | 105 |
Heap
106 |

The C heap is located at the end of the program and grows towards the C runtime stack.

107 | 108 |
109 |

110 | 111 | 112 |

4. Platform specific header files

113 | 114 | 115 |

Programs containing KIM-1 code may use the kim1.h header file. See the header file for more information.

116 | 117 |

5. Loadable drivers

118 | 119 | 120 | 121 |

5.1 Graphics drivers 122 |

123 | 124 | 125 |

No graphics drivers are currently available for the KIM-1.

126 | 127 |

5.2 Joystick drivers 128 |

129 | 130 | 131 |

No joystick driver is currently available for the KIM-1.

132 | 133 |

5.3 Mouse drivers 134 |

135 | 136 | 137 |

No mouse drivers are currently available for the KIM-1.

138 | 139 |

5.4 RS232 device drivers 140 |

141 | 142 | 143 |

No communication port drivers are currently available for the KIM-1. It has only the "master console" 144 | e.g. stdin and stdout.

145 | 146 |

6. Limitations

147 | 148 | 149 | 150 |

6.1 Disk I/O 151 |

152 | 153 | 154 |

The existing library for the KIM-1 doesn't implement C file I/O.

155 |

To be more specific, this limitation means that you cannot use any of the following functions (and a few others):

156 |

157 |

164 |

165 | 166 |

7. Other hints

167 | 168 | 169 | 170 |

7.1 kim1.h 171 |

172 | 173 |

This header exposes KIM-1 specific I/O functions that are useful for reading and writing its ports and front panel. 174 | See the kim1.h include file for a list of the functions available.

175 | 176 |

7.2 Limited memory applications 177 |

178 | 179 | 180 |

As stated earlier, there are config files for 4kb and 60kb systems. If you have 60kb RAM, then you will probably 181 | want to use the kim1-60k configuration, but if not - if you are using the kim1-4k configuration - then you may 182 | want to use functions like getchar, putchar, gets and puts rather than functions like scanf and printf. 183 | Printf, for example, requires about 1KB because it needs to know how to process all the format specifiers.

184 | 185 |

7.3 Sample programs 186 |

187 | 188 | 189 |

These sample programs can be found in the samples/kim1 directory:

190 |

191 |

197 |

198 | 199 |

8. License

200 | 201 | 202 |

This software is provided 'as-is', without any expressed or implied warranty. In no event will the authors be held 203 | liable for any damages arising from the use of this software.

204 |

Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter 205 | it and redistribute it freely, subject to the following restrictions:

206 |

207 |

    208 |
  1. The origin of this software must not be misrepresented; you must not 209 | claim that you wrote the original software. If you use this software 210 | in a product, an acknowledgment in the product documentation would be 211 | appreciated but is not required.
  2. 212 |
  3. Altered source versions must be plainly marked as such, and must not 213 | be misrepresented as being the original software.
  4. 214 |
  5. This notice may not be removed or altered from any source 215 | distribution.
  6. 216 |
217 |

218 | 219 | 220 | 221 | -------------------------------------------------------------------------------- /library.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | cc65 Library Overview 8 | 9 | 10 |

cc65 Library Overview

11 | 12 |

13 | Ullrich von Bassewitz

14 |
15 | An overview over the runtime and C libraries that come with the cc65 compiler, 16 | including a discussion of the differences to the ISO standard. 17 |
18 |

19 |

1. Overview

20 | 21 |

22 |

2. ISO C compatible library

23 | 24 |

25 |

3. CPU-specific stuff - 6502.h

26 | 27 |

28 |

4. Target-specific stuff

29 | 30 |

31 |

5. Direct console I/O - conio.h

32 | 33 |

34 |

6. Using the joystick - joystick.h

35 | 36 |

37 |

7. Using a mouse - mouse.h

38 | 39 |

40 |

8. Copyright

41 | 42 | 43 |
44 |

1. Overview

45 | 46 | 47 |

This file contains a short overview of the libraries available for the cc65 C 48 | compiler. Please have a look at the 49 | function reference for a function-by-function list. Because the function reference is 50 | not complete (we're working on that), it may happen that you don't find a 51 | specific function. In that case, have a look into the header files. All 52 | functions, that are not defined by the ISO C standard, have a short comment in 53 | the headers, explaining their use.

54 | 55 | 56 | 57 |

2. ISO C compatible library

58 | 59 | 60 |

The C library contains a large subset of the ISO C library. Functions usually 61 | are missing in areas where there are no support on typical 6502 systems. 62 | Wide-character sets are an example for that.

63 |

I will not go into detail about the ISO functions. If a function is not 64 | mentioned here explicitly, expect it to be available, and to behave as defined 65 | in the C standard.

66 |

Functions that are not available:

67 |

68 |

91 |

92 |

Functions not available on all supported systems:

93 |

94 |

116 |

117 | 118 |

Functions that are limited in any way:

119 |

120 |

135 |

136 | 137 |

In addition to those limitations, some more functions are limited if inlined 138 | versions are requested by using the -Os command-line option:

139 |

140 |

152 |

153 | 154 | 155 | 156 |

3. CPU-specific stuff - 6502.h

157 | 158 | 159 |

The header file 6502.h contains some functions that make sense only with the 160 | 6502 CPU. Examples are macros to insert more or less useful instructions into 161 | your C code, or a function to call arbitrary machine language subroutines, 162 | passing registers in and out.

163 | 164 | 165 | 166 |

4. Target-specific stuff

167 | 168 | 169 |

For each supported system, there's a header file that contains calls or 170 | defines specific for that system. So, when programming for the C64, include 171 | <c64.h>, for the C128, include <c128.h>, and so on. 172 | To make the task for the Commodore systems easier, there is also a header file 173 | named <cbm.h> that will define stuff common for all CBM systems, 174 | and include the header file for the specific target system.

175 |

The header files contain

176 |

177 |

195 |

196 | 197 | 198 | 199 |

5. Direct console I/O - conio.h

200 | 201 | 202 |

The conio.h header file contains a large set of functions that do screen 203 | and keyboard I/O. The functions will write directly to the screen or poll the 204 | keyboard directly with no more help from the operating system than needed. 205 | This has some disadvantages, but on the other side it's fast and reasonably 206 | portable. Conio implementations exist for the following targets:

207 |

208 |

233 |

234 |

The conio.h header file does include the system-specific header files also, 235 | which define constants for special characters and keys.

236 | 237 | 238 | 239 |

6. Using the joystick - joystick.h

240 | 241 | 242 |

For systems that have a joystick, joystick.h will define a subroutine to 243 | read the current value, including constants to evaluate the result of that 244 | function.

245 | 246 | 247 | 248 |

7. Using a mouse - mouse.h

249 | 250 | 251 |

Some target machines support a mouse. Mouse support currently is available for 252 | the following targets:

253 |

254 |

264 |

265 |

The available functions are declared in mouse.h.

266 | 267 | 268 | 269 |

8. Copyright

270 | 271 | 272 |

This C runtime library implementation for the cc65 compiler is (C) 273 | Copyright 1998-2002 Ullrich von Bassewitz. For usage of the binaries 274 | and/or sources, the following conditions do apply:

275 |

This software is provided 'as-is', without any expressed or implied 276 | warranty. In no event will the authors be held liable for any damages 277 | arising from the use of this software.

278 |

Permission is granted to anyone to use this software for any purpose, 279 | including commercial applications, and to alter it and redistribute it 280 | freely, subject to the following restrictions:

281 |

282 |

    283 |
  1. The origin of this software must not be misrepresented; you must not 284 | claim that you wrote the original software. If you use this software 285 | in a product, an acknowledgment in the product documentation would be 286 | appreciated, but is not required.
  2. 287 |
  3. Altered source versions must be marked plainly as such, and must not 288 | be misrepresented as being the original software.
  4. 289 |
  5. This notice may not be removed or altered from any source 290 | distribution.
  6. 291 |
292 |

293 | 294 | 295 | 296 | -------------------------------------------------------------------------------- /nes.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Nintendo Entertainment System specific information for cc65 8 | 9 | 10 |

Nintendo Entertainment System specific information for cc65

11 | 12 |

13 | Ullrich von Bassewitz,
14 | Stefan A. Haubenthal

15 |
16 | An overview over the NES runtime system as it is implemented for the 17 | cc65 C compiler. 18 |
19 |

20 |

1. Overview

21 | 22 |

23 |

2. Binary format

24 | 25 |

26 |

3. Memory layout

27 | 28 |

29 |

4. Platform specific header files

30 | 31 | 35 |

36 |

5. Loadable drivers

37 | 38 | 45 |

46 |

6. Limitations

47 | 48 | 51 |

52 |

7. Other hints

53 | 54 |

55 |

8. License

56 | 57 | 58 |
59 |

1. Overview

60 | 61 | 62 |

This file contains an overview of the NES runtime system as it comes 63 | with the cc65 C compiler. It describes the memory layout, NES specific header 64 | files, available drivers, and any pitfalls specific to that platform.

65 |

Please note that NES specific functions are just mentioned here, they are 66 | described in detail in the separate 67 | function reference. Even functions marked as "platform dependent" may be available on 68 | more than one platform. Please see the function reference for more 69 | information.

70 | 71 | 72 |

2. Binary format

73 | 74 | 75 |

The standard binary output format generated by the linker for the NES target 76 | is a machine language program with an INES cartridge header. It is of course 77 | possible to change this behaviour by using a modified startup file and linker 78 | config.

79 | 80 |

3. Memory layout

81 | 82 | 83 |

cc65 generated programs with the default setup run with the I/O area and a 84 | CHR bank enabled, which gives a usable memory range of $8000 - $FFF3. 85 | All boot ROM entry points may be called directly without additional code.

86 |

Special locations:

87 |

88 |

89 |
Text screen
90 |

The text screen is located at VRAM $2000.

91 | 92 |
Stack
93 |

The C runtime stack is located at $7FFF and growing downwards.

94 | 95 |
Heap
96 |

The C heap is located at the end of the program and grows towards the C 97 | runtime stack.

98 | 99 |
100 |

101 | 102 | 103 | 104 | 105 |

4. Platform specific header files

106 | 107 | 108 |

Programs containing NES specific code may use the nes.h header file.

109 | 110 | 111 |

4.1 NES specific functions 112 |

113 | 114 | 115 |

116 |

120 |

121 | 122 | 123 | 124 |

4.2 Hardware access 125 |

126 | 127 | 128 |

The following pseudo variables declared in the nes.inc include file do 129 | allow access to hardware located in the address space.

130 |

131 |

132 | 133 |
PPU
134 |

The PPU defines allow access to the PPU chip.

135 | 136 |
APU
137 |

The APU defines allow access to the APU chip.

138 | 139 |
140 |

141 | 142 | 143 | 144 | 145 |

5. Loadable drivers

146 | 147 | 148 |

All drivers must be statically linked because no file I/O is available. 149 | The names in the parentheses denote the symbols to be used for static linking of the drivers.

150 | 151 | 152 |

5.1 Graphics drivers 153 |

154 | 155 | 156 |

157 |

158 | 159 |
nes-64-56-2.tgi (nes_64_56_2)
160 |

This driver features a resolution of 64×56 with 2 colors using the 161 | CHR bank.

162 | 163 |
164 |

165 | 166 | 167 | 168 |

5.2 Extended memory drivers 169 |

170 | 171 | 172 |

No extended memory drivers are currently available for the NES.

173 | 174 | 175 |

5.3 Joystick drivers 176 |

177 | 178 | 179 |

180 |

181 | 182 |
nes-stdjoy.joy (nes_stdjoy)
183 |

A joystick driver for the standard four buttons joypad is available.

184 | 185 |
186 |

187 | 188 |

The generic interface doesn't export the start and select buttons. To 189 | test for those, use the defines in nes.h instead of the generic masks.

190 |

Example: 191 |

192 |
193 | if (joy_read(0) & KEY_A)
194 | 
195 |
196 |

197 | 198 | 199 |

5.4 Mouse drivers 200 |

201 | 202 | 203 |

No mouse drivers are currently available for the NES.

204 | 205 | 206 |

5.5 RS232 device drivers 207 |

208 | 209 | 210 |

No serial drivers are currently available for the NES.

211 | 212 | 213 | 214 |

6. Limitations

215 | 216 | 217 | 218 |

6.1 Disk I/O 219 |

220 | 221 | 222 |

The existing library for the NES doesn't implement C file 223 | I/O. There are no hacks for the read() and write() routines.

224 |

To be more concrete, this limitation means that you cannot use any of the 225 | following functions (and a few others):

226 |

227 |

237 |

238 | 239 | 240 | 241 |

7. Other hints

242 | 243 | 244 | 245 | 246 | 247 |

8. License

248 | 249 | 250 |

This software is provided 'as-is', without any expressed or implied 251 | warranty. In no event will the authors be held liable for any damages 252 | arising from the use of this software.

253 |

Permission is granted to anyone to use this software for any purpose, 254 | including commercial applications, and to alter it and redistribute it 255 | freely, subject to the following restrictions:

256 |

257 |

    258 |
  1. The origin of this software must not be misrepresented; you must not 259 | claim that you wrote the original software. If you use this software 260 | in a product, an acknowledgment in the product documentation would be 261 | appreciated but is not required.
  2. 262 |
  3. Altered source versions must be plainly marked as such, and must not 263 | be misrepresented as being the original software.
  4. 264 |
  5. This notice may not be removed or altered from any source 265 | distribution.
  6. 266 |
267 |

268 | 269 | 270 | 271 | -------------------------------------------------------------------------------- /od65.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | od65 Users Guide 8 | 9 | 10 |

od65 Users Guide

11 | 12 |

13 | Ullrich von Bassewitz

14 |
15 | od65 is the object file dump utility. It is able to output most parts of 16 | ca65-generated object files in readable form. 17 |
18 |

19 |

1. Overview

20 | 21 |

22 |

2. Usage

23 | 24 | 28 |

29 |

3. Input and output

30 | 31 |

32 |

4. Copyright

33 | 34 | 35 |
36 |

1. Overview

37 | 38 | 39 |

od65 is an object file dump utility. It is able to output most parts of 40 | ca65-generated object files in readable form. 41 | Since the contents and format of the object files are not documented 42 | elsewhere and may change at any time, this tool is a portable way to look at 43 | the contents.

44 |

Apart from curiosity, most people don't need to use this tool.

45 | 46 | 47 | 48 |

2. Usage

49 | 50 | 51 |

The od65 utility dumps contents of one or more ca65 generated object file to 52 | standard output. It has no cross-version compatibility, so you have to use 53 | a version that matches the version of ca65 used to create the object files.

54 | 55 | 56 |

2.1 Command line option overview 57 |

58 | 59 | 60 |

The program may be called as follows:

61 |

62 |

63 |
 64 | ---------------------------------------------------------------------------
 65 | Usage: od65 [options] file [options] [file]
 66 | Short options:
 67 |   -h                    Help (this text)
 68 |   -H                    Dump the object file header
 69 |   -S                    Dump segments sizes
 70 |   -V                    Print the version number and exit
 71 | 
 72 | Long options:
 73 |   --dump-all            Dump all object file information
 74 |   --dump-dbgsyms        Dump debug symbols
 75 |   --dump-exports        Dump exported symbols
 76 |   --dump-files          Dump the source files
 77 |   --dump-header         Dump the object file header
 78 |   --dump-imports        Dump imported symbols
 79 |   --dump-lineinfo       Dump line information
 80 |   --dump-options        Dump object file options
 81 |   --dump-segments       Dump the segments in the file
 82 |   --dump-segsize        Dump segments sizes
 83 |   --help                Help (this text)
 84 |   --version             Print the version number and exit
 85 | ---------------------------------------------------------------------------
 86 | 
87 |
88 |

89 | 90 | 91 |

2.2 Command line options in detail 92 |

93 | 94 | 95 |

Here is a description of all the command line options:

96 |

97 |

98 | 99 |
--dump-all
100 |

This will output all information, od65 is able to process. The option is a 101 | shortcut for specifying all the other --dump options.

102 | 103 | 104 |
--dump-dbgsyms
105 |

Dump all debug symbols contained in the object file.

106 | 107 | 108 |
--dump-exports
109 |

Dump all exported symbols contained in the object file.

110 | 111 | 112 |
--dump-files
113 |

Dump the file table contained in the object file.

114 | 115 | 116 |
-H, --dump-header
117 |

Dump the object file header.

118 | 119 | 120 |
--dump-imports
121 |

Dump the list of imported symbols contained in the object file.

122 | 123 | 124 |
--dump-lineinfo
125 |

Dump the line info contained in the object file.

126 | 127 | 128 |
--dump-segments
129 |

Dump the list of segments contained in the object file.

130 | 131 | 132 |
--dump-scopes
133 |

Dump the scope (lexical level) information contained in the object file.

134 | 135 | 136 |
-S, --dump-segsize
137 |

Dump the sizes of all segments contained in the object file. This option is 138 | quite useful to determine the effect of measures that increase or decrease 139 | code size.

140 | 141 | 142 |
-h, --help
143 |

Print the short option summary shown above.

144 | 145 | 146 |
-V, --version
147 |

Print the version number of the compiler. When submitting a bug report, 148 | please include the operating system you're using, and the compiler 149 | version.

150 |
151 |

152 | 153 | 154 |

3. Input and output

155 | 156 | 157 |

The converter will read one or more object files per invocation and write the 158 | contents in readable format to standard output. Please note that you need to 159 | specify any of the --dump options listed 160 | above, otherwise no useful output will be generated.

161 |

Example output for the command 162 |

163 |
164 | od65 --dump-header --dump-files t.o
165 | 
166 |
167 | 168 |
169 |
170 | t.o:
171 |   Header:
172 |     Magic:                 0x616E7A55
173 |     Version:                       12
174 |     Flags:                     0x0001  (OBJ_FLAGS_DBGINFO)
175 |     Options:
176 |       Offset:                      88
177 |       Size:                         9
178 |     Files:
179 |       Offset:                      97
180 |       Size:                        10
181 |     Segments:
182 |       Offset:                     107
183 |       Size:                       101
184 |     Imports:
185 |       Offset:                     208
186 |       Size:                         1
187 |     Exports:
188 |       Offset:                     209
189 |       Size:                         1
190 |     Debug symbols:
191 |       Offset:                     210
192 |       Size:                        55
193 |     Line infos:
194 |       Offset:                     265
195 |       Size:                         1
196 |     String pool:
197 |       Offset:                     266
198 |       Size:                        80
199 |   Files:
200 |     Count:                          1
201 |     Index:                          0
202 |       Name:                     "t.s"
203 |       Size:                       402
204 |       Modification time:   1280498435  (Fri Jul 30 16:00:35 2010)
205 | 
206 |
207 |

208 | 209 | 210 |

4. Copyright

211 | 212 | 213 |

od65 is (C) Copyright 2000-2009, Ullrich von Bassewitz. For usage of the 214 | binaries and/or sources the following conditions apply:

215 |

This software is provided 'as-is', without any expressed or implied 216 | warranty. In no event will the authors be held liable for any damages 217 | arising from the use of this software.

218 |

Permission is granted to anyone to use this software for any purpose, 219 | including commercial applications, and to alter it and redistribute it 220 | freely, subject to the following restrictions:

221 |

222 |

    223 |
  1. The origin of this software must not be misrepresented; you must not 224 | claim that you wrote the original software. If you use this software 225 | in a product, an acknowledgment in the product documentation would be 226 | appreciated but is not required.
  2. 227 |
  3. Altered source versions must be plainly marked as such, and must not 228 | be misrepresented as being the original software.
  4. 229 |
  5. This notice may not be removed or altered from any source 230 | distribution.
  6. 231 |
232 |

233 | 234 | 235 | 236 | -------------------------------------------------------------------------------- /osi.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Ohio Scientific-specific information for cc65 8 | 9 | 10 |

Ohio Scientific-specific information for cc65

11 | 12 |

13 | Stephan Mühlstrasser,
14 | Greg King

15 |
16 | An overview over the Ohio Scientific runtime system as it is implemented for the cc65 C 17 | compiler. 18 |
19 |

20 |

1. Overview

21 | 22 |

23 |

2. Targets

24 | 25 |

26 |

3. Program file formats

27 | 28 |

29 |

4. Memory layout

30 | 31 |

32 |

5. Linker configurations

33 | 34 | 38 |

39 |

6. Platform-specific header files

40 | 41 | 45 |

46 |

7. Loadable drivers

47 | 48 |

49 |

8. Support for different screen layouts

50 | 51 |

52 |

9. Limitations

53 | 54 | 57 |

58 |

10. Other hints

59 | 60 | 64 |

65 |

11. License

66 | 67 | 68 |
69 |

1. Overview

70 | 71 | 72 |

This file contains an overview of the Ohio Scientific runtime system as it comes with the 73 | cc65 C compiler. It describes the memory layout, Ohio Scientific-specific header files, 74 | and any pitfalls specific to that platform.

75 |

Please note that Ohio Scientific-specific functions are just mentioned here, they are 76 | described in detail in the separate 77 | function reference. Even functions marked as "platform dependent" may be available on 78 | more than one platform. Please see the function reference for more 79 | information.

80 | 81 |

2. Targets

82 | 83 | 84 |

Currently the target "osic1p" is implemented. This works for the Ohio Scientific 85 | Challenger 1P machine and for the Briel Superboard /// replica.

86 | 87 |

3. Program file formats

88 | 89 | 90 |

91 |

92 |
Binary, then text
93 |

The standard binary output format generated by the linker for the osic1p 94 | target is a pure machine language program.

95 |

For uploading into a real machine over its serial port or into an emulator, 96 | that program must be converted into a text file that can be understood by 97 | the 65V PROM monitor. For that purpose, the srec_cat program from 98 | the SRecord tool collection 99 | can be used.

100 |

Care must be taken that the -offset and -execution-start-address 101 | options for the srec_cat program correspond to the start address 102 | of the executable.

103 |

Example for converting an executable "hello" file that was built for the 104 | default start address $0200 to an uploadable file "hello.c1p":

105 |

106 |

107 |
108 |   srec_cat hello -bin -of 0x200 -o hello.c1p -os -esa=0x200
109 |   
110 | 
111 |
112 |

113 | 114 |
Hybrid
115 |

The linker can create an alternate format that contains two parts: 116 |

    117 |
  1. A text header that is understood by the 65V PROM monitor. 118 | It is a boot loader that reads the second part.
  2. 119 |
  3. The default binary code that is described above.
  4. 120 |
121 |

122 |

You can make the alternate format by adding the option -u __BOOT__ to 123 | cl65's or ld65's command lines.

124 |

This format doesn't need to be converted. It is smaller than the text-only 125 | format. But, it cannot be loaded by 126 | C1Pjs; you must use the 127 | SRecord-produced text-only format with that emulator. (However, if you know 128 | that you never will use C1Pjs, then you can edit the 129 | cfg/osic1p*.cfg files; uncomment the lines that import __BOOT__. 130 | Then, you won't need to use -u __BOOT__ on your command lines.)

131 | 132 |
133 |

134 | 135 |

4. Memory layout

136 | 137 | 138 |

By default programs compiled for the osic1p target are configured for 32 kB RAM. 139 | The RAM size can be configured via the symbol __HIMEM__.

140 |

Special locations:

141 |

142 |

143 |
Program start address
144 |

The default start address is $0200. The start address is configurable 145 | via the linker option --start-addr.

146 | 147 |
Stack
148 |

The C runtime stack is located at the top of RAM and growing downwards. 149 | The size is configurable via the symbol __STACKSIZE__. The default 150 | stack size is $0400.

151 | 152 |
Heap
153 |

The C heap is located at the end of the program and grows towards the C 154 | runtime stack.

155 | 156 |
Video RAM
157 |

The 1 kB video RAM is located at $D000. On the monitor, only a subset 158 | of the available video RAM is visible. The address of the upper left corner 159 | of the visible area is $D085 and corresponds to conio cursor 160 | position (0, 0).

161 | 162 |
163 |

164 | 165 |

Example for building a program with start address $0300, stack size 166 | $0200 and RAM size $2000:

167 |

168 |

169 |
170 | cl65 --start-addr 0x300 -Wl -D,__HIMEM__=$2000,-D,__STACKSIZE__=$0200 -t osic1p hello.c
171 | 
172 |
173 |

174 | 175 |

5. Linker configurations

176 | 177 | 178 |

The ld65 linker comes with a default config file "osic1p.cfg" for the Ohio Scientific 179 | Challenger 1P, which is implicitly used via -t osic1p. The 180 | osic1p package comes with additional secondary linker config files, which are 181 | used via -t osic1p -C <configfile>.

182 | 183 |

5.1 Default config file (osic1p.cfg) 184 |

185 | 186 | 187 |

The default configuration is tailored to C programs.

188 | 189 |

5.2 osic1p-asm.cfg 190 |

191 | 192 | 193 |

This configuration is made for assembler programmers who don't need a special 194 | setup.

195 |

To use this config file, assemble with -t osic1p and link with 196 | -C osic1p-asm.cfg. The former will make sure that correct runtime library 197 | is used, while the latter supplies the actual config. When using cl65, 198 | use both command line options.

199 |

Sample command lines for cl65:

200 |

201 |

202 |
203 | cl65 -t osic1p -C osic1p-asm.cfg -o program source.s
204 | cl65 -t osic1p -C osic1p-asm.cfg -u __BOOT__ -o program.lod source.s
205 | 
206 |
207 |

208 | 209 |

6. Platform-specific header files

210 | 211 | 212 |

Programs containing Ohio Scientific-specific code may use the osic1p.h 213 | header file.

214 | 215 |

6.1 Ohio Scientific-specific functions 216 |

217 | 218 | 219 |

There are currently no special Ohio Scientific functions.

220 | 221 |

6.2 Hardware access 222 |

223 | 224 | 225 |

There is no specific support for direct hardware access.

226 | 227 |

7. Loadable drivers

228 | 229 | 230 |

There are no loadable drivers available.

231 | 232 |

8. Support for different screen layouts

233 | 234 | 235 |

By default the conio library uses a 24 columns by 24 lines screen layout 236 | for the Challenger 1P, like under BASIC. In addition to that there is support 237 | for other screen layouts with extra modules.

238 |

There is a module screen-c1p-24x24.o in the OSI-specific 239 | cc65 runtime library that contains all conio functions that depend 240 | on the screen layout. No further configuration is needed for using the 241 | default screen layout of the Challenger 1P.

242 |

For other screen layouts additional versions of the screen module are 243 | available. The linker finds these modules without further configuration 244 | if they are specified on the compiler or linker command line. The 245 | extra module then overrides the default module.

246 |

Sample cl65 command line to override the default screen 247 | module with the module osic1p-screen-s3-32x28.o:

248 |

249 |

250 |
251 | cl65 -o hello -t osic1p osic1p-screen-s3-32x28.o hello.c
252 | 
253 |
254 |

255 |

Currently the following extra screen configuration modules are implemented:

256 |

257 |

263 |

264 |

On the Briel Superboard /// you enter 32 column mode by holding down 265 | the BREAK key on powerup.

266 |

On the Challenger 1P you can enable 48 column mode by writing a 1 to 267 | bit 0 of address $D800, and writing a 0 to go back to 24 column mode. 268 | You can use code like the following to do this:

269 |

270 |

271 |
272 | *(char*)0xd800 = 1; /* Switch to 48 column mode */
273 | 
274 |
275 |

276 | 277 |

9. Limitations

278 | 279 | 280 | 281 |

9.1 stdio implementation 282 |

283 | 284 | 285 |

There is no support for stdio at the moment.

286 | 287 |

10. Other hints

288 | 289 | 290 | 291 |

10.1 Passing arguments to the program 292 |

293 | 294 | 295 |

There is currently no support for passing arguments to a program.

296 | 297 |

10.2 Program return code 298 |

299 | 300 | 301 |

The program return code currently has no effect. When the main() function 302 | finishes, the boot prompt is shown again.

303 | 304 |

11. License

305 | 306 | 307 |

This software is provided 'as-is', without any expressed or implied 308 | warranty. In no event will the authors be held liable for any damages 309 | arising from the use of this software.

310 |

Permission is granted to anyone to use this software for any purpose, 311 | including commercial applications, and to alter it and redistribute it 312 | freely, subject to the following restrictions:

313 |

314 |

    315 |
  1. The origin of this software must not be misrepresented; you must not 316 | claim that you wrote the original software. If you use this software 317 | in a product, an acknowledgment in the product documentation would be 318 | appreciated but is not required.
  2. 319 |
  3. Altered source versions must be plainly marked as such, and must not 320 | be misrepresented as being the original software.
  4. 321 |
  5. This notice may not be removed or altered from any source 322 | distribution.
  6. 323 |
324 |

325 | 326 | 327 | 328 | -------------------------------------------------------------------------------- /pce.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | PC-Engine (TurboGrafx 16) System-specific information for cc65 8 | 9 | 10 |

PC-Engine (TurboGrafx 16) System-specific information for cc65

11 | 12 |

13 | Groepaz,
14 | Greg King

15 |
16 | An overview over the PCE runtime system as it is implemented for the 17 | cc65 C compiler. 18 |
19 |

20 |

1. Overview

21 | 22 |

23 |

2. Binary format

24 | 25 |

26 |

3. Memory layout

27 | 28 |

29 |

4. Platform-specific header files

30 | 31 | 35 |

36 |

5. Loadable drivers

37 | 38 | 45 |

46 |

6. Limitations

47 | 48 | 51 |

52 |

7. Other hints

53 | 54 |

55 |

8. License

56 | 57 | 58 |
59 |

1. Overview

60 | 61 | 62 |

This file contains an overview of the PCE runtime system as it comes 63 | with the cc65 C compiler. It describes the memory layout, PCE-specific header 64 | files, available drivers, and any pitfalls specific to that platform.

65 |

Please note that PCE-specific functions are just mentioned here; they are 66 | described, in detail, in the separate 67 | function reference. Even functions marked as "platform dependent" might be available on 68 | more than one platform. Please see the function reference for more 69 | information.

70 | 71 | 72 | 73 |

2. Binary format

74 | 75 | 76 |

The binary output file generated by the linker, for the PCE target, is an 77 | image, with no header, that has 8K bytes in the wrong place. That file must be 78 | post-processed; the 8K at the end must be moved to the front of the image.

79 |

On POSIX systems, the dd command and the shell give a convenient way to do 80 | it. Here is an example of their use: 81 |

82 |
 83 | dd if=conio.bin bs=8K skip=3 > conio.pce
 84 | dd if=conio.bin bs=8K count=3 >> conio.pce
 85 | 
86 |
87 | 88 | The first command grabs the last 8K of a 32K file, and writes it as the first 89 | part of a new file. The second command reads all but the last part of the old 90 | file, and appends it to the new file. 91 |
92 |
 93 | +--------+--------+--------+--------+
 94 | | Bank 1 | Bank 2 | Bank 3 | Bank 0 |  <-- "conio.bin"
 95 | +--------+--------+--------+--------+
 96 | 
 97 | +--------+--------+--------+--------+
 98 | | Bank 0 | Bank 1 | Bank 2 | Bank 3 |  <-- "conio.pce"
 99 | +--------+--------+--------+--------+
100 | 
101 |
102 | 103 | Note: That .pce file shows the format of the ROM cartridge that is 104 | plugged into a PC-Engine. But, that .bin file shows what programs 105 | actually see when they execute the code in that cartridge.

106 | 107 | 108 | 109 |

3. Memory layout

110 | 111 | 112 |

cc65-generated programs with the default setup run with the memory map that was 113 | used by many PC-Engine games: 114 |

125 |

126 |

Special locations:

127 |

128 |

129 |
Text screen and Font
130 |

The text screen is located at Video RAM (VRAM) address $0000; 131 | the Font is located at VRAM address $2000.

132 | 133 |
Stack
134 |

The C run-time stack is located in system RAM at $3FFF; 135 | and, grows downwards.

136 | 137 |
Data and BSS
138 |

The Data (initialized variables) and BSS (uninitialized variables) sections are 139 | placed one after the other into system RAM at $2200.

140 | 141 |
Heap
142 |

The C heap is located after the end of the BSS section; 143 | and, extends up to the C run-time stack.

144 | 145 |
Code
146 |

In an 8K ROM cartridge, code and read-only data are located between 147 | $E000 and $FFF5 in the System bank.

148 |

In a 16K cartridge, code and read-only data are located between $C000 149 | and $FFF5.

150 |

In a 32K cartridge, code and read-only data are located between $8000 151 | and $FFF5.

152 |
153 |

154 | 155 | 156 | 157 |

4. Platform-specific header files

158 | 159 | 160 |

Programs containing PCE-specific code may use the pce.h header file.

161 | 162 | 163 |

4.1 PCE-specific functions 164 |

165 | 166 | 167 |

168 |

172 |

173 | 174 | 175 |

4.2 Hardware access 176 |

177 | 178 | 179 |

The following constants, defined in the pce.inc include file, do 180 | allow access to hardware that is located in the address space.

181 |

182 |

183 | 184 |
PSG
185 |

The PSG defines allow access to the PSG (Programmable Sound Generator).

186 | 187 |
VCE
188 |

The VCE defines allow access to the VCE chip (Video Color Encoder).

189 | 190 |
VDC
191 |

The VDC defines allow access to the VDC chip (Video Display Controller).
192 | 32K of 16-bit words of Video RAM can be accessed only through this chip.

193 | 194 |
195 |

196 | 197 | 198 | 199 |

5. Loadable drivers

200 | 201 | 202 |

All drivers must be statically linked because no file I/O is available. 203 | The names in the parentheses denote the symbols to be used for static linking of the drivers.

204 | 205 | 206 |

5.1 Graphics drivers 207 |

208 | 209 | 210 |

No TGI graphics drivers are currently available for the PCE.

211 | 212 | 213 |

5.2 Extended memory drivers 214 |

215 | 216 | 217 |

No extended memory drivers are currently available for the PCE.

218 | 219 | 220 |

5.3 Joystick drivers 221 |

222 | 223 | 224 |

225 |

226 | 227 |
pce-stdjoy.joy (pce_stdjoy)
228 |

A joystick driver for the standard two-button joypad is available.

229 |

Note that the Japanese 6-button pad currently is not supported.

230 | 231 |
232 |

233 | 234 | 235 |

5.4 Mouse drivers 236 |

237 | 238 | 239 |

No mouse drivers are currently available for the PCE.

240 | 241 | 242 |

5.5 RS232 device drivers 243 |

244 | 245 | 246 |

No serial drivers are currently available for the PCE.

247 | 248 | 249 | 250 |

6. Limitations

251 | 252 | 253 | 254 | 255 |

6.1 Disk I/O 256 |

257 | 258 | 259 |

The existing library for the PCE doesn't implement C file 260 | I/O. There are no hacks for the read() and write() routines.

261 |

To be more concrete, that limitation means that you cannot use any of the 262 | following functions (and a few others):

263 |

264 |

275 |

276 | 277 | 278 | 279 |

7. Other hints

280 | 281 | 282 |

Some useful resources on PCE coding:

283 |

284 |

302 |

303 | 304 | 305 | 306 |

8. License

307 | 308 | 309 |

This software is provided "as-is", without any expressed or implied 310 | warranty. In no event will the authors be held liable for any damages 311 | arising from the use of this software.

312 |

Permission is granted to anyone to use this software for any purpose, 313 | including commercial applications, and to alter it and redistribute it 314 | freely, subject to the following restrictions:

315 |

316 |

    317 |
  1. The origin of this software must not be misrepresented; you must not 318 | claim that you wrote the original software. If you use this software 319 | in a product, an acknowledgment in the product documentation would be 320 | appreciated, but is not required.
  2. 321 |
  3. Altered source versions must be marked plainly as such; and, must not 322 | be misrepresented as being the original software.
  4. 323 |
  5. This notice may not be removed or altered from any source 324 | distribution.
  6. 325 |
326 |

327 | 328 | 329 | 330 | -------------------------------------------------------------------------------- /pet.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Commodore PET-specific information for cc65 8 | 9 | 10 |

Commodore PET-specific information for cc65

11 | 12 |

13 | Ullrich von Bassewitz,
14 | Stefan A. Haubenthal

15 |
16 | An overview over the PET runtime system as it is implemented for the cc65 C 17 | compiler. 18 |
19 |

20 |

1. Overview

21 | 22 |

23 |

2. Binary format

24 | 25 |

26 |

3. Memory layout

27 | 28 |

29 |

4. Platform-specific header files

30 | 31 | 36 |

37 |

5. Loadable drivers

38 | 39 | 46 |

47 |

6. Limitations

48 | 49 |

50 |

7. Other hints

51 | 52 | 58 |

59 |

8. License

60 | 61 | 62 |
63 |

1. Overview

64 | 65 | 66 |

This file contains an overview of the PET runtime system as it comes with the 67 | cc65 C compiler. It describes the memory layout, PET-specific header files, 68 | available drivers, and any pitfalls specific to that platform.

69 |

Please note that PET-specific functions are just mentioned here, they are 70 | described in detail in the separate 71 | function reference. Even functions marked as "platform dependent" may be available on 72 | more than one platform. Please see the function reference for more 73 | information.

74 | 75 | 76 |

2. Binary format

77 | 78 | 79 |

The standard binary output format generated by the linker for the PET target 80 | is a machine language program with a one line BASIC stub, which calls the 81 | machine language part via SYS. This means that a program can be loaded as 82 | BASIC program and started with RUN. It is of course possible to change this 83 | behaviour by using a modified startup file and linker config.

84 | 85 | 86 |

3. Memory layout

87 | 88 | 89 |

cc65 generated programs with the default setup run with the I/O area and the 90 | kernal and BASIC ROM enabled, which gives a usable memory range of 91 | $0400 - $7FFF (32KB machine). 92 | All ROM entry points may be called directly without additional code.

93 |

Special locations:

94 |

95 |

96 |
Text screen
97 |

The text screen is located at $8000.

98 | 99 |
Stack
100 |

The C runtime stack is located at $7FFF and growing downwards.

101 | 102 |
Heap
103 |

The C heap is located at the end of the program and grows towards the C 104 | runtime stack.

105 | 106 |
107 |

108 | 109 | 110 | 111 | 112 |

4. Platform-specific header files

113 | 114 | 115 |

Programs containing PET-specific code may use the pet.h or cbm.h 116 | header files. Using the later may be an option when writing code for more than 117 | one CBM platform, since it includes pet.h and declares several functions 118 | common to all CBM platforms.

119 | 120 | 121 |

4.1 PET-specific functions 122 |

123 | 124 | 125 |

There are currently no special PET functions.

126 | 127 | 128 | 129 |

4.2 CBM-specific functions 130 |

131 | 132 | 133 |

Some functions are available for all (or at least most) of the Commodore 134 | machines. See the 135 | function reference for 136 | declaration and usage.

137 |

138 |

163 |

164 | 165 | 166 |

4.3 Hardware access 167 |

168 | 169 | 170 |

The following pseudo variables declared in the pet.h header file do allow 171 | access to hardware located in the address space. Some variables are 172 | structures, accessing the struct fields will access the chip registers.

173 |

174 |

175 | 176 |
PIA1, PIA2
177 |

Access to the two PIA (peripheral interface adapter) chips is available via 178 | the PIA1 and PIA2 variables. The structure behind these variables 179 | is explained in _pia.h.

180 | 181 |
VIA
182 |

The VIA structure allows access to the VIA (versatile interface 183 | adapter). See the _6522.h header file located in the include 184 | directory for the declaration of the structure.

185 | 186 |
187 |

188 | 189 | 190 | 191 | 192 |

5. Loadable drivers

193 | 194 | 195 |

The names in the parentheses denote the symbols to be used for static linking of the drivers.

196 | 197 | 198 |

5.1 Graphics drivers 199 |

200 | 201 | 202 |

No graphics drivers are currently available for the PET.

203 | 204 | 205 |

5.2 Extended memory drivers 206 |

207 | 208 | 209 |

No extended memory drivers are currently available for the PET.

210 | 211 | 212 |

5.3 Joystick drivers 213 |

214 | 215 | 216 |

The default drivers, joy_stddrv (joy_static_stddrv), point to pet-stdjoy.joy (pet_stdjoy_joy).

217 |

218 |

219 | 220 |
pet-ptvjoy.joy (pet_ptvjoy_joy)
221 |

Driver for the Protovision 4-player adapter contributed by Groepaz. See 222 | Protovision shop for prices and building instructions. Up to two 223 | joysticks are supported.

224 | 225 |
pet-stdjoy.joy (pet_stdjoy_joy)
226 |

Driver for the standard PET userport joystick.

227 | 228 |
229 |

230 | 231 | 232 | 233 |

5.4 Mouse drivers 234 |

235 | 236 | 237 |

No mouse drivers are currently available for the PET.

238 | 239 | 240 |

5.5 RS232 device drivers 241 |

242 | 243 | 244 |

No serial drivers are currently available for the PET.

245 | 246 | 247 | 248 |

6. Limitations

249 | 250 | 251 | 252 | 253 | 254 |

7. Other hints

255 | 256 | 257 | 258 | 259 |

7.1 Passing arguments to the program 260 |

261 | 262 | 263 |

Command-line arguments can be passed to main(). Since that is not 264 | supported directly by BASIC, the following syntax was chosen:

265 |

266 |

267 |
268 |     RUN:REM ARG1 " ARG2 IS QUOTED" ARG3 "" ARG5
269 | 
270 |
271 |

272 |

273 |

    274 |
  1. Arguments are separated by spaces.
  2. 275 |
  3. Arguments may be quoted.
  4. 276 |
  5. Leading and trailing spaces around an argument are ignored. Spaces within 277 | a quoted argument are allowed.
  6. 278 |
  7. The first argument passed to main() is the program name.
  8. 279 |
  9. A maximum number of 10 arguments (including the program name) are 280 | supported.
  10. 281 |
282 |

283 | 284 | 285 |

7.2 Program return code 286 |

287 | 288 | 289 |

The program return code (low byte) is passed back to BASIC by use of the 290 | ST variable.

291 | 292 | 293 |

7.3 Interrupts 294 |

295 | 296 | 297 |

The runtime for the PET uses routines marked as .INTERRUPTOR for 298 | interrupt handlers. Such routines must be written as simple machine language 299 | subroutines and will be called automatically by the interrupt handler code 300 | when they are linked into a program. See the discussion of the .CONDES 301 | feature in the 302 | assembler manual.

303 | 304 | 305 |

7.4 Using extended memory 306 |

307 | 308 | 309 |

The extended memory at $9000 of the CBM 8x96 may be added to the heap by using 310 | the following code:

311 |

312 |

313 |
314 |     /* Check for the existence of RAM */
315 |     if (PEEK(0x9000) == POKE(0x9000, PEEK(0x9000)+1)) {
316 |         /* Add it to the heap */
317 |         _heapadd ((void *) 0x9000, 0x2000);
318 |     }
319 | 
320 |
321 |

322 | 323 | 324 | 325 |

8. License

326 | 327 | 328 |

This software is provided 'as-is', without any expressed or implied 329 | warranty. In no event will the authors be held liable for any damages 330 | arising from the use of this software.

331 |

Permission is granted to anyone to use this software for any purpose, 332 | including commercial applications, and to alter it and redistribute it 333 | freely, subject to the following restrictions:

334 |

335 |

    336 |
  1. The origin of this software must not be misrepresented; you must not 337 | claim that you wrote the original software. If you use this software 338 | in a product, an acknowledgment in the product documentation would be 339 | appreciated but is not required.
  2. 340 |
  3. Altered source versions must be plainly marked as such, and must not 341 | be misrepresented as being the original software.
  4. 342 |
  5. This notice may not be removed or altered from any source 343 | distribution.
  6. 344 |
345 |

346 | 347 | 348 | 349 | -------------------------------------------------------------------------------- /plus4.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Commodore Plus/4 specific information for cc65 8 | 9 | 10 |

Commodore Plus/4 specific information for cc65

11 | 12 |

13 | Ullrich von Bassewitz

14 |
15 | An overview over the Plus/4 runtime system as it is implemented for the cc65 C 16 | compiler. 17 |
18 |

19 |

1. Overview

20 | 21 |

22 |

2. Binary format

23 | 24 |

25 |

3. Memory layout

26 | 27 |

28 |

4. Platform specific header files

29 | 30 | 36 |

37 |

5. Loadable drivers

38 | 39 | 46 |

47 |

6. Limitations

48 | 49 |

50 |

7. Other hints

51 | 52 | 57 |

58 |

8. License

59 | 60 | 61 |
62 |

1. Overview

63 | 64 | 65 |

This file contains an overview of the Plus/4 runtime system as it comes with the 66 | cc65 C compiler. It describes the memory layout, Plus/4 specific header files, 67 | available drivers, and any pitfalls specific to that platform.

68 |

Please note that Plus/4 specific functions are just mentioned here, they are 69 | described in detail in the separate 70 | function reference. Even functions marked as "platform dependent" may be available on 71 | more than one platform. Please see the function reference for more 72 | information.

73 |

Since the Plus/4 and the Commodore 16/116 are almost identical (the latter are 74 | missing the 6551 ACIA and do only have 16KB of memory), the 75 | C16 documentation is also worth a look. The difference 76 | between both cc65 targets is that the Plus/4 runtime uses banking to support 77 | full 64K RAM, while the C16 does not use banking and supports up to 32K RAM. 78 | Because banking is not needed, most C16 programs will be somewhat smaller than 79 | the same program compiled for the Plus/4. However, programs compiled for the 80 | C16 will always run on the Plus/4, while the reverse is not necessarily true.

81 | 82 | 83 |

2. Binary format

84 | 85 | 86 |

The standard binary output format generated by the linker for the Plus/4 87 | target is a machine language program with a one line BASIC stub, which calls 88 | the machine language part via SYS. This means that a program can be loaded as 89 | BASIC program and started with RUN. It is of course possible to change this 90 | behaviour by using a modified startup file and linker config.

91 | 92 | 93 |

3. Memory layout

94 | 95 | 96 |

cc65 generated programs with the default setup run with the kernal and basic 97 | banked out. This gives a usable memory range of $1000 - $FD00. 98 | Having the kernal and basic ROMs banked out means, that no ROM entry points 99 | may be called directly from user code.

100 |

Special locations:

101 |

102 |

103 |
Text screen
104 |

The text screen is located at $C00 (as in the standard setup).

105 | 106 |
Color RAM
107 |

The color RAM is located at $800 (standard location).

108 | 109 |
Stack
110 |

The C runtime stack is located at $FCFF and growing downwards.

111 | 112 |
Heap
113 |

The C heap is located at the end of the program and grows towards the C 114 | runtime stack.

115 | 116 |
117 |

118 | 119 | 120 | 121 | 122 |

4. Platform specific header files

123 | 124 | 125 |

Programs containing Plus/4 specific code may use the plus4.h or cbm.h 126 | header files. Using the later may be an option when writing code for more than 127 | one CBM platform, since it includes plus4.h and declares several functions 128 | common to all CBM platforms.

129 |

Please note that most of the header file declarations from the plus4.h 130 | header file are shared between the C16 and Plus/4 configurations. For this 131 | reason, most of it is located in a common header file named cbm264.h.

132 | 133 | 134 | 135 |

4.1 Plus/4 specific functions 136 |

137 | 138 | 139 |

There are currently no special Plus/4 functions.

140 | 141 | 142 |

4.2 CBM specific functions 143 |

144 | 145 | 146 |

Some functions are available for all (or at least most) of the Commodore 147 | machines. See the 148 | function reference for 149 | declaration and usage.

150 |

151 |

178 |

179 | 180 | 181 |

4.3 CBM specific CPU functions 182 |

183 | 184 | 185 |

Some CPU related functions are available for some of the Commodore 186 | machines. See the 187 | function reference for 188 | declaration and usage.

189 |

190 |

195 |

196 | 197 | 198 |

4.4 Hardware access 199 |

200 | 201 | 202 |

The following pseudo variables declared in the plus4.h header file do 203 | allow access to hardware located in the address space. Some variables are 204 | structures, accessing the struct fields will access the chip registers.

205 |

206 |

207 | 208 |
TED
209 |

The TED structure allows access to the TED chip. See the 210 | _ted.h header file located in the include directory for the 211 | declaration of the structure.

212 | 213 |
COLOR_RAM
214 |

A character array that mirrors the color RAM of the Plus/4 at $0800.

215 | 216 |
217 |

218 | 219 | 220 | 221 | 222 |

5. Loadable drivers

223 | 224 | 225 |

The names in the parentheses denote the symbols to be used for static linking of the drivers.

226 | 227 | 228 |

5.1 Graphics drivers 229 |

230 | 231 | 232 |

No graphics drivers are currently available for the Plus/4.

233 | 234 | 235 |

5.2 Extended memory drivers 236 |

237 | 238 | 239 |

No extended memory drivers are currently available for the Plus/4.

240 | 241 | 242 |

5.3 Joystick drivers 243 |

244 | 245 | 246 |

247 |

248 | 249 |
plus4-stdjoy.joy (plus4_stdjoy_joy)
250 |

Supports up to two joysticks connected to the standard joysticks port of 251 | the Plus/4.

252 | 253 |
254 |

255 | 256 | 257 | 258 |

5.4 Mouse drivers 259 |

260 | 261 | 262 |

No mouse drivers are currently available for the Plus/4.

263 | 264 | 265 |

5.5 RS232 device drivers 266 |

267 | 268 | 269 |

270 |

271 | 272 |
plus4-stdser.ser (plus4_stdser_ser)
273 |

Driver for the 6551 ACIA chip built into the Plus/4. Supports up to 19200 274 | baud, requires hardware flow control (RTS/CTS) and does interrupt driven 275 | receives. Note that because of the peculiarities of the 6551 chip transmits 276 | are not interrupt driven, and the transceiver blocks if the receiver asserts 277 | flow control because of a full buffer.

278 |

You need an adapter to use the builtin port, since the output levels 279 | available at the user port don't follow the RS232 standard.

280 | 281 |
282 |

283 | 284 | 285 | 286 | 287 |

6. Limitations

288 | 289 | 290 | 291 | 292 | 293 |

7. Other hints

294 | 295 | 296 | 297 |

7.1 Passing arguments to the program 298 |

299 | 300 | 301 |

Command line arguments can be passed to main(). Since this is not 302 | supported by BASIC, the following syntax was chosen:

303 |

304 |

305 |
306 |     RUN:REM ARG1 " ARG2 IS QUOTED" ARG3 "" ARG5
307 | 
308 |
309 |

310 |

311 |

    312 |
  1. Arguments are separated by spaces.
  2. 313 |
  3. Arguments may be quoted.
  4. 314 |
  5. Leading and trailing spaces around an argument are ignored. Spaces within 315 | a quoted argument are allowed.
  6. 316 |
  7. The first argument passed to main is the program name.
  8. 317 |
  9. A maximum number of 10 arguments (including the program name) are 318 | supported.
  10. 319 |
320 |

321 | 322 | 323 | 324 |

7.2 Program return code 325 |

326 | 327 | 328 |

The program return code (low byte) is passed back to BASIC by use of the 329 | ST variable.

330 | 331 | 332 |

7.3 Interrupts 333 |

334 | 335 | 336 |

The runtime for the Plus/4 uses routines marked as .INTERRUPTOR for 337 | interrupt handlers. Such routines must be written as simple machine language 338 | subroutines and will be called automatically by the interrupt handler code 339 | when they are linked into a program. See the discussion of the .CONDES 340 | feature in the 341 | assembler manual.

342 | 343 | 344 | 345 |

8. License

346 | 347 | 348 |

This software is provided 'as-is', without any expressed or implied 349 | warranty. In no event will the authors be held liable for any damages 350 | arising from the use of this software.

351 |

Permission is granted to anyone to use this software for any purpose, 352 | including commercial applications, and to alter it and redistribute it 353 | freely, subject to the following restrictions:

354 |

355 |

    356 |
  1. The origin of this software must not be misrepresented; you must not 357 | claim that you wrote the original software. If you use this software 358 | in a product, an acknowledgment in the product documentation would be 359 | appreciated but is not required.
  2. 360 |
  3. Altered source versions must be plainly marked as such, and must not 361 | be misrepresented as being the original software.
  4. 362 |
  5. This notice may not be removed or altered from any source 363 | distribution.
  6. 364 |
365 |

366 | 367 | 368 | 369 | -------------------------------------------------------------------------------- /rp6502.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Picocomputer 6502 - specific information for cc65 8 | 9 | 10 |

Picocomputer 6502 - specific information for cc65

11 | 12 |

13 | Ullrich von Bassewitz

14 |
15 | An overview over the Picocomputer 6502 and its interfaces to the cc65 C 16 | compiler. 17 |
18 |

19 |

1. Overview

20 | 21 |

22 |

2. Binary format

23 | 24 |

25 |

3. Memory layout

26 | 27 |

28 |

4. Platform-specific header files

29 | 30 |

31 |

5. License

32 | 33 | 34 |
35 |

1. Overview

36 | 37 | 38 |

The Picocomputer 6502 is a modern W65C02S computer with a custom operating 39 | system designed to be POSIX-like. The reference design includes a W65C02S, 40 | W65C22S, RP6502-RIA, and optionally a RP6502-VGA. Peripheral devices like 41 | keyboards, mice, and flash storage are connected by USB to the RP6502-RIA. 42 | Audio is generated by the RP6502-RIA. Video is generated by the RP6502-VGA.

43 | 44 | 45 | 46 |

2. Binary format

47 | 48 | 49 |

The standard binary output format generated by the linker for the RP6502 target 50 | is a plain machine language program without any prefix or postfix.

51 |

The RP6502 Integrated Development Environment, based on Visual Studio Code, 52 | will convert the cc65 binary output into RP6502 ROM files that can be loaded 53 | directly from the RP6502 monitor or installed on the RIA to be loaded at boot.

54 | 55 | 56 | 57 |

3. Memory layout

58 | 59 | 60 |

61 |

62 |
Stack
63 |

The C run-time stack is located at $FEFF, and grows downward.

64 | 65 |
Heap
66 |

The C heap is located at the end of the program, and grows toward the C 67 | run-time stack.

68 | 69 |
RAM
70 |

RAM is located at $0000 - $FEFF. Default binaries load and 71 | start at $0200.

72 | 73 |
ROM
74 |

The RP6502 is designed with no ROM in the 6502 address space.

75 | 76 |
VIA
77 |

A Versatile Interface Adapter (6522) is 16 registers located 78 | at $FFD0.

79 | 80 |
RIA
81 |

The RP6502 Interface Adapter is 32 registers located at $FFE0.

82 | 83 |
User
84 |

User I/O expansion is from $FF00 to $FFCF.

85 | 86 |
87 |

88 | 89 | 90 | 91 | 92 |

4. Platform-specific header files

93 | 94 | 95 |

Programs containing RP6502-specific code may use the rp6502.h or 96 | rp6502.inc include files.

97 | 98 | 99 | 100 |

5. License

101 | 102 | 103 |

This software is provided "as-is", without any expressed or implied 104 | warranty. In no event will the authors be held liable for any damages 105 | arising from the use of this software.

106 |

Permission is granted to anyone to use this software for any purpose, 107 | including commercial applications, and to alter it and redistribute it 108 | freely, subject to the following restrictions: 109 |

    110 |
  1. The origin of this software must not be misrepresented; you must not 111 | claim that you wrote the original software. If you use this software 112 | in a product, an acknowledgment in the product documentation would be 113 | appreciated, but is not required.
  2. 114 |
  3. Altered source versions must be plainly marked as such, and must not 115 | be misrepresented as being the original software.
  4. 116 |
  5. This notice may not be removed or altered from any source 117 | distribution.
  6. 118 |
119 |

120 | 121 | 122 | 123 | -------------------------------------------------------------------------------- /supervision.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Watara Supervision specific information for cc65 8 | 9 | 10 |

Watara Supervision specific information for cc65

11 | 12 |

13 | Stefan A. Haubenthal

14 |
15 | An overview over the Supervision runtime system as it is implemented for the 16 | cc65 C compiler. 17 |
18 |

19 |

1. Overview

20 | 21 |

22 |

2. Binary format

23 | 24 |

25 |

3. Memory layout

26 | 27 |

28 |

4. Platform specific header files

29 | 30 | 33 |

34 |

5. Loadable drivers

35 | 36 | 43 |

44 |

6. Limitations

45 | 46 | 49 |

50 |

7. Other hints

51 | 52 |

53 |

8. License

54 | 55 | 56 |
57 |

1. Overview

58 | 59 | 60 |

This file contains an overview of the Supervision runtime system as it comes 61 | with the cc65 C compiler. It describes the memory layout, Supervision specific header 62 | files, available drivers, and any pitfalls specific to that platform.

63 |

Please note that Supervision specific functions are just mentioned here, they are 64 | described in detail in the separate 65 | function reference. Even functions marked as "platform dependent" may be available on 66 | more than one platform. Please see the function reference for more information.

67 | 68 | 69 |

2. Binary format

70 | 71 | 72 |

The standard binary output format generated by the linker for the Supervision target 73 | is a 2×16 kbyte machine language program. It is of course 74 | possible to change this behaviour by using one of the different linker configs.

75 | 76 |

3. Memory layout

77 | 78 | 79 |

cc65 generated programs with the default setup run with the I/O area enabled, 80 | which gives a usable memory range of $8000 - $FFF9. 81 | More ROM may need additional bankswitching code.

82 |

Special locations:

83 |

84 |

85 |
Text screen
86 |

No conio support is currently available for the Supervision.

87 | 88 |
Stack
89 |

The C runtime stack is located at $1FFF and growing downwards.

90 | 91 |
Heap
92 |

The C heap is located at the end of the program and grows towards the C 93 | runtime stack.

94 | 95 |
96 |

97 | 98 | 99 | 100 | 101 |

4. Platform specific header files

102 | 103 | 104 |

Programs containing Supervision specific code may use the supervision.h header file.

105 | 106 | 107 |

4.1 Hardware access 108 |

109 | 110 | 111 |

The following pseudo variables declared in the supervision.inc include file do 112 | allow access to hardware located in the address space.

113 |

114 |

115 | 116 |
IO
117 |

The IO defines allow access to the IO chip.

118 | 119 |
120 |

121 | 122 | 123 | 124 | 125 |

5. Loadable drivers

126 | 127 | 128 | 129 |

5.1 Graphics drivers 130 |

131 | 132 | 133 |

No graphics drivers are currently available for the Supervision.

134 | 135 |

5.2 Extended memory drivers 136 |

137 | 138 | 139 |

No extended memory drivers are currently available for the Supervision.

140 | 141 | 142 |

5.3 Joystick drivers 143 |

144 | 145 | 146 |

147 |

148 | 149 |
supervision-stdjoy.joy (supervision_stdjoy_joy)
150 |

A joystick driver for the standard two buttons joypad is available.

151 | 152 |
153 |

154 | 155 | 156 |

5.4 Mouse drivers 157 |

158 | 159 | 160 |

No mouse drivers are currently available for the Supervision.

161 | 162 | 163 |

5.5 RS232 device drivers 164 |

165 | 166 | 167 |

No communication port drivers are currently available for the Supervision.

168 | 169 | 170 | 171 |

6. Limitations

172 | 173 | 174 | 175 |

6.1 Disk I/O 176 |

177 | 178 | 179 |

The existing library for the Supervision doesn't implement C file 180 | I/O. There are even no hacks for the read() and write() routines.

181 |

To be more concrete, this limitation means that you cannot use any of the 182 | following functions (and a few others):

183 |

184 |

194 |

195 | 196 | 197 | 198 |

7. Other hints

199 | 200 | 201 | 202 | 203 | 204 |

8. License

205 | 206 | 207 |

This software is provided 'as-is', without any expressed or implied 208 | warranty. In no event will the authors be held liable for any damages 209 | arising from the use of this software.

210 |

Permission is granted to anyone to use this software for any purpose, 211 | including commercial applications, and to alter it and redistribute it 212 | freely, subject to the following restrictions:

213 |

214 |

    215 |
  1. The origin of this software must not be misrepresented; you must not 216 | claim that you wrote the original software. If you use this software 217 | in a product, an acknowledgment in the product documentation would be 218 | appreciated but is not required.
  2. 219 |
  3. Altered source versions must be plainly marked as such, and must not 220 | be misrepresented as being the original software.
  4. 221 |
  5. This notice may not be removed or altered from any source 222 | distribution.
  6. 223 |
224 |

225 | 226 | 227 | 228 | -------------------------------------------------------------------------------- /sym1.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Synertek Systems Sym-1 specific information for cc65 8 | 9 | 10 |

Synertek Systems Sym-1 specific information for cc65

11 | 12 |

13 | Wayne Parham

14 |
15 | An overview over the Sym-1 runtime system as it is implemented for the cc65 C compiler. 16 |
17 |

18 |

1. Overview

19 | 20 |

21 |

2. Binary format

22 | 23 |

24 |

3. Memory layout

25 | 26 |

27 |

4. Platform specific header files

28 | 29 | 32 |

33 |

5. Loadable drivers

34 | 35 | 42 |

43 |

6. Limitations

44 | 45 | 48 |

49 |

7. Other hints

50 | 51 | 54 |

55 |

8. License

56 | 57 | 58 |
59 |

1. Overview

60 | 61 | 62 |

This file contains an overview of the Sym-1 runtime system as it comes with the cc65 C compiler. 63 | It describes the memory layout, Sym-1 specific header files, available drivers, and any pitfalls 64 | specific to the platform.

65 |

Please note that Sym-1 specific functions are just mentioned here, they are described in detail 66 | in the separate 67 | function reference. Even functions marked as 68 | "platform dependent" may be available on more than one platform. Please see the 69 | function reference for more information.

70 | 71 |

2. Binary format

72 | 73 | 74 |

The output format generated by the linker for the Sym-1 target is a raw binary BIN file, which 75 | is essentially a memory image. You can convert this to a HEX file using BIN2HEX, which is a 76 | popular open-source conversion utility program. A HEX file has ASCII representations of the 77 | hexadecimal byte values of the machine-language program. So the HEX file can be transferred 78 | to the Sym-1 using the RS-232 terminal port, just as if the machine-code was entered by hand. 79 | Enter 'm 200' in the monitor and start the HEX file transfer.

80 | 81 | 82 |

Included with this distribution is a 4k configuration file and a 32k config file. The Sym-1 83 | on-board memory is limited to 4 kbytes but system memory can be increased to 32 kbytes of 84 | contiguous RAM with aftermarket add-on boards. So choose the config file that matches your 85 | system configuration before compiling and linking user programs.

86 | 87 |

3. Memory layout

88 | 89 | 90 |

The ROMs and I/O areas are defined in the configuration files, as are most of the entry points 91 | for useful subroutines in the Sym-1 monitor ROM. cc65 generated programs compiled and linked 92 | using 4k config run in the memory range of $200 - $0FFF. The 32k config expands 93 | this range to $7FFF. Memory above 32k can be used to extend the heap, as described below. 94 | The starting memory location and entry point for running the program is $200, so when the 95 | program is transferred to the Sym-1, it is executed by typing 'g 200'. The system returns control 96 | back to the monitor ROM when the program terminates, providing the '.' prompt.

97 |

Special locations:

98 |

99 |

100 |
Text screen
101 |

Conio support is not currently available for the Sym-1. But stdio console functions are available.

102 | 103 |
Stack
104 |

The C runtime stack is located at $0FFF on 4kb Syms, or at $7FFF for 32kb systems. 105 | The stack always grows downwards.

106 | 107 |
Heap
108 |

The C heap is located at the end of the program and grows towards the C runtime stack. Extended 109 | memory can be added to the heap, as described below.

110 | 111 |
112 |

113 | 114 | 115 |

4. Platform specific header files

116 | 117 | 118 |

Programs containing Sym-1 code may use the sym1.h header file. See the header file for more information.

119 | 120 |

4.1 Hardware access 121 |

122 | 123 | 124 |

The pseudo variables declared in the sym1.inc include file allow access to hardware located in the 125 | address space. See the include file for more information.

126 | 127 |

5. Loadable drivers

128 | 129 | 130 | 131 |

5.1 Graphics drivers 132 |

133 | 134 | 135 |

No graphics drivers are currently available for the Sym-1.

136 | 137 |

5.2 Extended memory drivers 138 |

139 | 140 | 141 |

There are no extended memory drivers for the Sym-1. However, there is a way to access memory beyond the 142 | 32kb boundary, if extended memory is physically present in the system. See the example program, 143 | symExtendedMemory, in the samples directory.

144 | 145 |

5.3 Joystick drivers 146 |

147 | 148 | 149 |

No joystick driver is currently available for the Sym-1.

150 | 151 |

5.4 Mouse drivers 152 |

153 | 154 | 155 |

No mouse drivers are currently available for the Sym-1.

156 | 157 |

5.5 RS232 device drivers 158 |

159 | 160 | 161 |

No communication port drivers are currently available for the Sym-1. It has only the "master console" 162 | e.g. stdin and stdout.

163 | 164 |

6. Limitations

165 | 166 | 167 | 168 |

6.1 Disk I/O 169 |

170 | 171 | 172 |

The existing library for the Sym-1 doesn't implement C file I/O.

173 |

To be more specific, this limitation means that you cannot use any of the following functions (and a few others):

174 |

175 |

182 |

183 | 184 |

7. Other hints

185 | 186 | 187 | 188 |

7.1 sym1.h 189 |

190 | 191 |

This header exposes Sym-specific I/O functions that are useful for reading and writing its ports and front panel. 192 | See the sym1.h include file for a list of the functions available.

193 | 194 |

Limited memory applications

195 | 196 | 197 |

As stated earlier, there are config files for 4kb and 32kb systems. If you have 32kb RAM, then you will probably 198 | want to use the sym1-32k configuration, but if not - if you are using the sym1-4k configuration - then you may 199 | want to use functions like getchar, putchar, gets and puts rather than functions like scanf and printf. 200 | Printf, for example, requires about 1KB because it needs to know how to process all the format specifiers.

201 | 202 |

Using extended memory

203 | 204 | 205 |

Memory may be physically present that is addressed at locations above the monitor ROM at $8000. This extended 206 | memory is accessible by adding to the heap, as described in the symExtendedMemory sample program.

207 | 208 |

Sample programs

209 | 210 | 211 |

All the samples will run on the "stock" 4kb Sym-1, except for symIO and symNotepad, which require 32kb. 212 | Additionally, symExtendedMemory shows how to access memory above 32kb, so it expects more than 32kb. 213 | These sample programs can be found in the samples/sym1 directory:

214 |

215 |

225 |

226 | 227 |

8. License

228 | 229 | 230 |

This software is provided 'as-is', without any expressed or implied warranty. In no event will the authors be held 231 | liable for any damages arising from the use of this software.

232 |

Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter 233 | it and redistribute it freely, subject to the following restrictions:

234 |

235 |

    236 |
  1. The origin of this software must not be misrepresented; you must not 237 | claim that you wrote the original software. If you use this software 238 | in a product, an acknowledgment in the product documentation would be 239 | appreciated but is not required.
  2. 240 |
  3. Altered source versions must be plainly marked as such, and must not 241 | be misrepresented as being the original software.
  4. 242 |
  5. This notice may not be removed or altered from any source 243 | distribution.
  6. 244 |
245 |

246 | 247 | 248 | 249 | -------------------------------------------------------------------------------- /telestrat.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Oric Telestrat-specific information for cc65 8 | 9 | 10 |

Oric Telestrat-specific information for cc65

11 | 12 |

13 | Jede

14 |
15 | An overview over the Telestrat (Telemon 2.4 & Telemon 3.x : http://orix.oric.org) runtime system as it is implemented for the cc65 C compiler. 16 |
17 |

18 |

1. Overview

19 | 20 |

21 |

2. Binary format

22 | 23 |

24 |

3. Memory layout

25 | 26 |

27 |

4. Platform-specific header files

28 | 29 | 33 |

34 |

5. Loadable drivers

35 | 36 | 43 |

44 |

6. Limitations

45 | 46 | 50 |

51 |

7. Other hints

52 | 53 |

54 |

8. License

55 | 56 | 57 |
58 |

1. Overview

59 | 60 | 61 |

This file contains an overview of the Telestrat runtime system as it comes 62 | with the cc65 C compiler. It describes the memory layout, Telestrat-specific 63 | header files, available drivers, and any pitfalls specific to that platform.

64 |

Please note that Telestrat-specific functions are just mentioned here, they are 65 | described in detail in the separate 66 | function reference. Even functions marked as "platform dependent" may be available on 67 | more than one platform. Please see the function reference for more 68 | information.

69 |

Oric Telestrat is the last Oric computer (Released in 1986, mainly in France). 70 | This computer is an Atmos with extra hardware: RS232, cardridge(banking system), 71 | joysticks (2 ports) or mouse (on joystick port), FDC.

72 |

Video chip, CPU, keyboard management, tape hardware are the same than Atmos.

73 |

Telestrat can start in Atmos mode with Atmos Cardridge (which is only the atmos 74 | Basic 1.1 ROM).

75 |

Telestrat can start in Sedoric (Atmos OS) and Atmos mode with Stratoric Cardridge. 76 | This Cardridge has 3 banks of 16KB of rom with: 77 |

82 |

83 |

The main Telestrat's configuration is the Telemon/Hyperbasic Cardridge inserted 84 | with Stratsed in floppy drive.

85 |

Anyway, there is no way to load a tape file in Telemon/Hyperbasic mode without 86 | alternative program.

87 |

There is also no software to write a Stratsed dsk file on PC.

88 |

This Telestrat target build an Orix binary file. But, in the future, it will be possible 89 | to build a Stratsed disk. Orix uses the same systems calls than Telemon mode.

90 |

That is why if you need to do software for telestrat target, you have the choice to: 91 |

99 |

100 |

Telestrat (from cardridge) can handle 8 banks (from $C000 to $FFFF): Bank 0 is the overlay ram. Others banks can be ROM or RAM.

101 | 102 |

2. Binary format

103 | 104 | 105 |

The standard binary output format generated the linker for the Telestrat 106 | target is a machine language program with a 20 bytes header described 107 | here

108 |

This header is used for Telemon 3.0.

109 |

Anyway, for Telemon 2.4, there is no file management, there is no TAPE routine 110 | in Telemon, there is no way to load a binary easily.

111 |

Stratsed (the Telestrat operating system) handles files management. Stratsed 112 | is loaded to memory from floppy disk. Stratsed vector are declared in asminc/telestrat.inc. 113 | But, reverse engineering is required to find how these vectors works. Please, note that 114 | Stratsed is located in overlay memory (bank 0)

115 |

There is no tool to insert a binary in a Stratsed floppy disk.

116 |

The only way to load a binary (for Telemon 2.4) is to: 117 |

125 |

126 |

Please note also, that the binary converted into TAP file, will not produce 127 | a right stratsed file when tap2dsk and old2mfm are used. You will be in the 128 | case that Telestrat/Stratsed crashed when you do "DIR" command.

129 |

If you know the Stratsed disk format, please contact the author of this doc.

130 | 131 | 132 |

3. Memory layout

133 | 134 | 135 |

In the standard setup, cc65-generated programs use the memory from 136 | $0801 to $9800; so, nearly 37K of memory (including the stack) is 137 | available. ROM calls are possible with BRK feature.

138 | 139 |

Special locations:

140 |

141 |

142 |
Stack
143 |

The C runtime stack is located at $97FF (or $B3FF), and grows 144 | downwards.

145 | 146 |
Heap
147 |

The C heap is located at the end of the program, and grows towards the C 148 | runtime stack.

149 | 150 |
151 |

152 | 153 | 154 | 155 | 156 |

4. Platform-specific header files

157 | 158 | 159 |

Programs containing Telestrat-specific code may use the telestrat.h header file.

160 | 161 | 162 |

4.1 Telestrat-specific functions 163 |

164 | 165 | 166 |

The functions listed below are special for the Telestrat. See the 167 | function reference for declaration and usage.

168 |

169 |

176 |

177 | 178 | 179 |

4.2 Hardware access 180 |

181 | 182 | 183 |

The following pseudo variables declared in the telestrat.h header file do allow 184 | access to hardware located in the address space. Some variables are 185 | structures; accessing the struct fields will access the chip registers.

186 |

187 |

188 | 189 |
VIA
190 |

Access to the VIA (Versatile Interface Adapter) chip is available via the 191 | VIA variable. The structure behind this variable is explained in _6522.h.

192 | 193 |
VIA2
194 |

Access to the VIA2 (Versatile Interface Adapter) chip is available via the 195 | VIA2 variable. The structure behind this variable is explained in _6522.h.

196 | 197 |
ACIA
198 |

Access to the 6551 ACIA chip is available via the 199 | ACIA variable. The structure behind this variable is explained in _6551.h.

200 | 201 |
202 |

203 | 204 | 205 | 206 |

5. Loadable drivers

207 | 208 | 209 | 210 |

5.1 TGI 211 |

212 | 213 | 214 |

TGI drivers is available on Oric Telestrat with some functions:

215 |

216 |

225 |

226 | 227 | 228 |

5.2 Extended memory drivers 229 |

230 | 231 | 232 |

No extended memory drivers are currently available for the Telestrat. 233 | This feature could be done because telestrat can manage RAM inserted in his 234 | port cardridge.

235 | 236 |

5.3 Joystick drivers 237 |

238 | 239 | 240 |

Telemon 2.4 returns in keyboard buffer the direction of the joysticks. This means that 241 | if you get input from keyboard by conio cgetc function, you will get direction from joysticks.

242 |

Anyway, if you don't want to use ROM, you can use joysticks standard drivers in your code.

243 |

The standard driver manages two joysticks. Only one button is managed for these joysticks.

244 |

Telestrat can handle one button for the left port, and three buttons for the right port (but this port was designed for a mouse).

245 |

If you find a Telestrat mouse (which is almost impossible :), these driver will work too because there is some extra hardware in the mouse to send direction.

246 | 247 |

5.4 Mouse drivers 248 |

249 | 250 | 251 |

Telestrat manages also mouse (Joystick port) 252 | Telestrat mouse is really difficult to find.

253 | 254 |

5.5 RS232 device drivers 255 |

256 | 257 | 258 |

Telestrat has a RS232 port, but it's not usable in cc65. It is possible to use 259 | RS232 port with Telemon calls (see XSOUT primitive for example)

260 | 261 |

6. Limitations

262 | 263 | 264 | 265 |

6.1 Disk I/O 266 |

267 | 268 | 269 |

Telemon 3.0 handles fopen, fread, fclose primitives. It means that this 270 | function will crash the Telestrat because Telemon 2.4 does not have these 271 | primitives. By the way, Telemon 3.0 uses an extension "ch376 card" which 272 | handles sdcard and FAT 32 usb key. In the next version of Telemon, FT DOS, 273 | Sedoric, Stratsed will be handled in these 3 primitives (fopen, fread, fclose).

274 |

275 |

280 |

281 | 282 |

6.2 conio 283 |

284 | 285 |

Functions textcolor and bgcolor are available only with Telemon 3.0 (Orix). 286 | Telemon 2.4 primitives can't handle any change of colors in text mode except with XINK or 287 | XPAPER primitives which put on the first and second columns ink and paper attributes. 288 | The only way to change color on the same line for text is to handle it in pure assembly 289 | without systems calls.

290 | 291 |

7. Other hints

292 | 293 | 294 | 295 | 296 |

8. License

297 | 298 | 299 |

This software is provided 'as-is', without any expressed or implied 300 | warranty. In no event will the authors be held liable for any damages 301 | arising from the use of this software.

302 |

Permission is granted to anyone to use this software for any purpose, 303 | including commercial applications, and to alter it and redistribute it 304 | freely, subject to the following restrictions:

305 |

306 |

    307 |
  1. The origin of this software must not be misrepresented; you must not 308 | claim that you wrote the original software. If you use this software 309 | in a product, an acknowledgment in the product documentation would be 310 | appreciated but is not required.
  2. 311 |
  3. Altered source versions must be plainly marked as such, and must not 312 | be misrepresented as being the original software.
  4. 313 |
  5. This notice may not be removed or altered from any source 314 | distribution.
  6. 315 |
316 |

317 | 318 | 319 | 320 | -------------------------------------------------------------------------------- /using-make.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Using GNU Make with cc65 8 | 9 | 10 |

Using GNU Make with cc65

11 | 12 |

13 | Oliver Schmidt

14 |
15 | How to build your program using the GNU Make utility. 16 |
17 |

18 |

1. Overview

19 | 20 |

21 |

2. What is GNU Make?

22 | 23 |

24 |

3. A sample Makefile

25 | 26 | 31 |

32 |

4. Target-specific Variable Values

33 | 34 | 35 |
36 |

1. Overview

37 | 38 | 39 |

This document describes how to build your programs using the cc65 development 40 | tools and the GNU Make utility.

41 |

The cc65 development package doesn't come with a make utility. However this is 42 | no issue because GNU Make works very nicely with cc65.

43 | 44 | 45 | 46 |

2. What is GNU Make?

47 | 48 | 49 |

GNU Make is a both very powerful and very popular make utility. It might even 50 | be called the de facto standard for make utilities. For more information see 51 | the GNU Make home page:

52 |

53 | http://www.gnu.org/software/make/

54 |

The cc65 development package is available as binaries for several host systems 55 | and can easily built for quite some additional systems. The very same is true 56 | for GNU Make so a cc65-based project coming with a GNU Make Makefile can easily 57 | be built by any cc65 developer no matter what host system is used.

58 |

Because of the strong alignment of the cc65 compiler with the ISO C standard it 59 | is very well feasible to compile a single C code base both with the cc65 60 | compiler and other C compilers like for example GCC. GNU Make turns out to be 61 | very well suited to build projects for several target systems using multiple 62 | compilers as it isn't tied to any C compiler.

63 | 64 | 65 | 66 |

3. A sample Makefile

67 | 68 | 69 |

This Makefile is a fully functional sample for compiling several C sources 70 | (here foo.c and bar.c) and link the resulting object files into an 71 | executable program (here foobar):

72 |

73 |

74 |
 75 | SOURCES = foo.c bar.c
 76 | 
 77 | PROGRAM = foobar
 78 | 
 79 | ifdef CC65_TARGET
 80 | CC      = cl65
 81 | CFLAGS  = -t $(CC65_TARGET) --create-dep $(<:.c=.d) -O
 82 | LDFLAGS = -t $(CC65_TARGET) -m $(PROGRAM).map
 83 | else
 84 | CC      = gcc
 85 | CFLAGS  = -MMD -MP -O
 86 | LDFLAGS = -Wl,-Map,$(PROGRAM).map
 87 | endif
 88 | 
 89 | ########################################
 90 | 
 91 | .SUFFIXES:
 92 | .PHONY: all clean
 93 | all: $(PROGRAM)
 94 | 
 95 | ifneq ($(MAKECMDGOALS),clean)
 96 | -include $(SOURCES:.c=.d)
 97 | endif
 98 | 
 99 | %.o: %.c
100 |         $(CC) -c $(CFLAGS) -o $@ $<
101 | 
102 | $(PROGRAM): $(SOURCES:.c=.o)
103 |         $(CC) $(LDFLAGS) -o $@ $^
104 | 
105 | clean:
106 |         $(RM) $(SOURCES:.c=.o) $(SOURCES:.c=.d) $(PROGRAM) $(PROGRAM).map
107 | 
108 |
109 |

110 |

Important: When using the sample Makefile above via copy & paste it is 111 | important to make sure that command lines (lines 26, 29 and 32) start 112 | with a tab character (ASCII code 9).

113 | 114 | 115 |

3.1 Invoking the sample Makefile 116 |

117 | 118 | 119 |

Without any specific configuration the sample Makefile will compile and link 120 | using GCC. In order to rather use cc65 the variable CC65_TARGET needs to be 121 | defined. This may by done as an environment variable or simply as part of the 122 | Makefile. However to quickly switch between compilers and/or cc65 targets it is 123 | best done on the GNU Make command line like this:

124 |

125 |

126 |
127 | make CC65_TARGET=c64
128 | 
129 |
130 |

131 | 132 | 133 |

3.2 Understanding the sample Makefile 134 |

135 | 136 | 137 |

Most parts of the sample Makefile follow the guidelines in the 138 | GNU Make Manual 139 | that can be searched online for background information. The automatic generation of 140 | dependency however rather works as described by the GNU Make maintainer Paul D. Smith in 141 | "Advanced Auto-Dependencies". 142 | Fortunately both GCC and cc65 directly support this method in the meantime.

143 | 144 | 145 |

3.3 Invoking the sample Makefile on Windows 146 |

147 | 148 | 149 |

The recommended way to use GNU Make on Windows is to install it as part of a 150 | Cygwin environment. For more information see the Cygwin home page:

151 |

152 | http://www.cygwin.com/

153 |

If however installing Cygwin shouldn't be an option for one or the other reason 154 | then the sample Makefile may be invoked from the Windows Command Prompt (cmd.exe) 155 | by downloading the following programs:

156 |

157 |

163 |

164 | 165 | 166 | 167 |

4. Target-specific Variable Values

168 | 169 | 170 |

The very limited resources of the cc65 target machines now and then require 171 | manual optimization of the build process by compiling individual source files 172 | with different compiler options. GNU Make offers 173 | Target-specific Variable Values 174 | perfectly suited for doing so. For example placing the code of the two modules 175 | foo and bar in the segment FOOBAR can be achieved with this 176 | target-specific variable definition:

177 |

178 |

179 |
180 | foo.o bar.o: CFLAGS += --code-name FOOBAR
181 | 
182 |
183 |

184 | 185 | 186 | 187 | --------------------------------------------------------------------------------