3 Description of the C library for the cc65 C compiler
5 (C) Copyright 1998-1999 Ullrich von Bassewitz
15 2. ISO C compatible library
17 3. CPU specific stuff - 6502.h
19 4. System specific stuff
21 5. Direct console I/O - conio.h
23 6. Using the joystick - joystick.h
34 This file contains a description of the library routines available for the
35 cc65 C compiler. It is not complete in some areas, so if you miss
36 something, have a look into the header files. All functions, that are not
37 defined by the ISO C standard have a short comment in the headers,
42 2. ISO C compatible library
43 ---------------------------
45 The C library contains a large subset of the ISO C library. Functions are
46 usually missing in areas, where there is no support on typical 6502
47 systems. Wide character sets are an example for this.
49 I will not go into detail about the ISO functions. If a function is not
50 mentioned here explicitly, expect it to be available and to behave as
51 defined in the C standard.
54 Functions that are NOT available:
56 * ftell/fseek/fgetpos/fsetpos
60 * The scanf family of functions
62 * time/asctime/ctime/difftime/asctime/gmtime/localtime/mktime/strftime
66 * All functions that handle floating point numbers in some manner.
68 * The div and ldiv functions (because cc65 is not able to return
71 * All functions handling wide character strings.
73 * Signals and all related functions (having SIGSEGV would be cool:-)
75 * rename/remove/rewind
77 * setbuf/setvbuf/ungetc
81 Functions that are limited in any way:
83 * fopen/fread/fwrite/fclose/fputs/fgets/fscanf....
85 These functions are built on open/read/write/close. Neither of these
86 low level functions is currently available for the supported systems,
87 and so, fopen and friends do not work. However, the functions exist
88 and are tested to some degree under the ACE operating systems (which
89 is no longer supported).
92 * The va_... family of macros
94 The macros do not work completely as defined by the standard. Since cc65
95 has the wrong calling order, the (non-standard) va_fix macro must be used
96 to access fixed parameters in functions with a variable parameter size.
97 See newvers.txt for a discussion of the problem.
100 * The character classification functions (is...)
102 These functions have unexpected results when called with arguments that
103 are not really chars (are outside the 0..255 range).
106 * The strerror function
108 The function will return "error #n" where n is the error number.
111 * strcspn/strpbrk/strspn
113 These functions have a length limitation of 256 for the second string
114 argument. Since this string gives a character set, and there are only 256
115 distinct characters, this shouldn't be a problem.
118 * Since there is no such thing as an environment on all supported
119 systems, the getenv function will always return a NULL pointer.
122 * There is no other locale than the "C" locale. The native locale is
123 identical to the "C" locale.
127 3. CPU specific stuff - 6502.h
128 ------------------------------
130 The header file 6502.h contains some functions that make only sense with
131 the 6502 CPU. Examples are macros to insert more or less useful
132 instructions into your C code, or a function to call arbitrary machine
133 language subroutines, passing registers in and out.
137 4. System specific stuff
138 ------------------------
140 For each supported system there's a header file that contains calls or
141 defines specific for this system. So, when programming for the C64,
142 include c64.h, for the C128, include c128.h and so on. To make the task
143 for the Commodore systems easier, there is also a header file named cbm.h
144 that will define stuff common for all CBM systems, and include the header
145 file for the specific target system.
147 The header files contain
149 * Defines for special keys (like function keys)
151 * Defines for special characters (like the graphics characters)
153 * Variables with a fixed address in memory that may be used to access
154 special hardware. For the C64 and C128 there is a variable struct
155 named "sid". Writing to the fields of this struct will write to the
156 SID device instead. Using these variables will make your program more
157 readable and more portable. Don't fear ineffective code when using
158 these variables, the compiler will translate reads and writes to these
159 structs into direct memory accesses.
161 * Other routines that make only sense for a specific system. One example
162 are routines to write memory locations in the system bank for the CBM
163 600/700 family (called B128/B256 in the US).
167 5. Direct console I/O - conio.h
168 -------------------------------
170 The conio header file contains a large set of functions that do screen and
171 keyboard I/O. The functions will write directly to the screen or poll the
172 keyboard directly with no more help from the operating system than needed.
173 This has some disadvantages, but on the other side it's fast and
174 reasonably portable. conio implementations exist for the following
180 cbm610 (that is, the complete 600/700 series)
181 pet (all PETs except the 2001)
184 The conio.h header file does also include the system specific header files
185 which define constants for special characters and keys.
189 6. Using the joystick - joystick.h
190 ----------------------------------
192 For systems that have a joystick, joystick.h will define a subroutine to
193 read the current value, including constants to evaluate the result of this
194 function. To help in writing portable code, the header file will define
195 the symbol __JOYSTICK__ on systems that have a joystick.
202 If you have problems using the library, if you find any bugs, or if you've
203 written some extensions or otherwise interesting programs, I would be glad
204 to hear from you. Feel free to contact me by email (uz@musoftware.de).
211 This C runtime library implementation for the cc65 compiler is (C)
212 Copyright 1998-1999 Ullrich von Bassewitz. For usage of the binaries
213 and/or sources the following conditions do 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.
219 Permission is granted to anyone to use this software for any purpose,
220 including commercial applications, and to alter it and redistribute it
221 freely, subject to the following restrictions:
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.
227 2. Altered source versions must be plainly marked as such, and must not
228 be misrepresented as being the original software.
229 3. This notice may not be removed or altered from any source