1 <!doctype linuxdoc system> <!-- -*- text-mode -*- -->
4 <title>cc65 function reference
5 <author><url url="mailto:uz@cc65.org" name="Ullrich von Bassewitz">,<newline>
6 <url url="mailto:greg.king5@verizon.net" name="Greg King">
10 cc65 is a C compiler for 6502 based systems. This function reference describes
11 the C functions available in the standard library.
14 <!-- Table of contents -->
17 <!-- Begin the document -->
21 cc65 is a C compiler for 6502 based systems. It implements a subset of the ISO
22 C standard plus additional functions specially crafted for 6502 systems or
23 just some of the supported machines. This function refrence describes the
24 available functions together with any limitations.
26 For an overview about the available libraries, their purpose, and any
27 differences to the ISO standard, please have a look at the <url
28 url="library.html" name="cc65 Library Overview">.
30 <em/Note:/ Standard C functions are listed here, but not described in detail.
31 Since these functions behave identical on all standard compliant systems, they
32 are described in any book covering standard C.
34 Each entry for a function contains a detailed description
38 <tag/Function/Summary of what <bf/function/ does.
39 <tag/Header/The header file that contains the declaration.
40 <tag/Declaration/Describes the needed header files and declaration of the
42 <tag/Description/Description of the function.
43 <tag/Notes/Notes on the function.
44 <tag/Availability/The availability of the function.
45 <tag/See also/Other related functions.
46 <tag/Example/A piece of actual code using the function.
51 <sect>Functions by header file<p>
53 <sect1><tt/6502.h/<label id="6502.h"><p>
56 <item><ref id="BRK" name="BRK">
57 <item><ref id="CLI" name="CLI">
58 <item><ref id="SEI" name="SEI">
59 <item><ref id="_sys" name="_sys">
60 <item><ref id="getcpu" name="getcpu">
61 <item><ref id="reset_brk" name="reset_brk">
62 <item><ref id="reset_irq" name="reset_irq">
63 <item><ref id="set_brk" name="set_brk">
64 <item><ref id="set_irq" name="set_irq">
68 <sect1><tt/accelerator.h/<label id="accelerator.h"><p>
71 <item><ref id="detect_c128" name="detect_c128">
72 <item><ref id="detect_c64dtv" name="detect_c64dtv">
73 <item><ref id="detect_c65" name="detect_c65">
74 <item><ref id="detect_chameleon" name="detect_chameleon">
75 <item><ref id="detect_scpu" name="detect_scpu">
76 <item><ref id="get_c128_speed" name="get_c128_speed">
77 <item><ref id="get_c64dtv_speed" name="get_c64dtv_speed">
78 <item><ref id="get_c65_speed" name="get_c65_speed">
79 <item><ref id="get_chameleon_speed" name="get_chameleon_speed">
80 <item><ref id="get_scpu_speed" name="get_scpu_speed">
81 <item><ref id="set_c128_speed" name="set_c128_speed">
82 <item><ref id="set_c64dtv_speed" name="set_c64dtv_speed">
83 <item><ref id="set_c65_speed" name="set_c65_speed">
84 <item><ref id="set_chameleon_speed" name="set_chameleon_speed">
85 <item><ref id="set_scpu_speed" name="set_scpu_speed">
89 <sect1><tt/apple2.h/<label id="apple2.h"><p>
93 <item><ref id="get_ostype" name="get_ostype">
98 <sect1><tt/apple2enh.h/<label id="apple2enh.h"><p>
102 <item><ref id="get_ostype" name="get_ostype">
103 <item>rebootafterexit
106 <item><ref id="videomode" name="videomode">
110 <sect1><tt/assert.h/<label id="assert.h"><p>
113 <item><ref id="assert" name="assert">
117 <sect1><tt/atari.h/<label id="atari.h"><p>
120 <!-- <item><ref id="_getcolor" name="_getcolor"> -->
121 <!-- <item><ref id="_getdefdev" name="_getdefdev"> -->
122 <!-- <item><ref id="_graphics" name="_graphics"> -->
123 <item><ref id="_is_cmdline_dos" name="_is_cmdline_dos">
124 <!-- <item><ref id="_rest_vecs" name="_rest_vecs"> -->
125 <!-- <item><ref id="_save_vecs" name="_save_vecs"> -->
126 <!-- <item><ref id="_scroll" name="_scroll"> -->
127 <!-- <item><ref id="_setcolor" name="_setcolor"> -->
128 <!-- <item><ref id="_setcolor_low" name="_setcolor_low"> -->
129 <item><ref id="get_ostype" name="get_ostype">
130 <!-- <item><ref id="get_tv" name="get_tv"> -->
136 <sect1><tt/atmos.h/<label id="atmos.h"><p>
139 <item><ref id="atmos_explode" name="atmos_explode">
140 <item><ref id="atmos_load" name="atmos_load">
141 <item><ref id="atmos_ping" name="atmos_ping">
142 <item><ref id="atmos_save" name="atmos_save">
143 <item><ref id="atmos_shoot" name="atmos_shoot">
144 <item><ref id="atmos_tick" name="atmos_tick">
145 <item><ref id="atmos_tock" name="atmos_tock">
146 <item><ref id="atmos_zap" name="atmos_zap">
150 <sect1><tt/c128.h/<label id="c128.h"><p>
153 <item><ref id="c64mode" name="c64mode">
154 <item><ref id="fast" name="fast">
155 <item><ref id="isfast" name="isfast">
156 <item><ref id="slow" name="slow">
157 <item><ref id="toggle_videomode" name="toggle_videomode">
158 <item><ref id="videomode" name="videomode">
162 <sect1><tt/c16.h/<label id="c16.h"><p>
165 <item><ref id="fast" name="fast">
166 <item><ref id="isfast" name="isfast">
167 <item><ref id="slow" name="slow">
173 <sect1><tt/c64.h/<label id="c64.h"><p>
176 <item><ref id="get_ostype" name="get_ostype">
180 <sect1><tt/cbm.h/<label id="cbm.h"><p>
183 <item><ref id="cbm_k_acptr" name="cbm_k_acptr">
184 <item><ref id="cbm_k_basin" name="cbm_k_basin">
185 <item><ref id="cbm_k_bsout" name="cbm_k_bsout">
186 <item><ref id="cbm_k_chkin" name="cbm_k_chkin">
187 <item><ref id="cbm_k_ciout" name="cbm_k_ciout">
188 <item><ref id="cbm_k_ckout" name="cbm_k_ckout">
189 <item><ref id="cbm_k_clall" name="cbm_k_clall">
190 <item><ref id="cbm_k_close" name="cbm_k_close">
191 <item><ref id="cbm_k_clrch" name="cbm_k_clrch">
192 <item><ref id="cbm_k_getin" name="cbm_k_getin">
193 <item><ref id="cbm_k_iobase" name="cbm_k_iobase">
194 <item><ref id="cbm_k_listen" name="cbm_k_listen">
195 <item><ref id="cbm_k_load" name="cbm_k_load">
196 <item><ref id="cbm_k_open" name="cbm_k_open">
197 <item><ref id="cbm_k_readst" name="cbm_k_readst">
198 <item><ref id="cbm_k_save" name="cbm_k_save">
199 <item><ref id="cbm_k_scnkey" name="cbm_k_scnkey">
200 <item><ref id="cbm_k_setlfs" name="cbm_k_setlfs">
201 <item><ref id="cbm_k_setnam" name="cbm_k_setnam">
202 <item><ref id="cbm_k_talk" name="cbm_k_talk">
203 <item><ref id="cbm_k_udtim" name="cbm_k_udtim">
204 <item><ref id="cbm_k_unlsn" name="cbm_k_unlsn">
205 <!-- <item><ref id="cbm_load" name="cbm_load"> -->
206 <!-- <item><ref id="cbm_open" name="cbm_open"> -->
207 <!-- <item><ref id="cbm_opendir" name="cbm_opendir"> -->
208 <!-- <item><ref id="cbm_read" name="cbm_read"> -->
209 <!-- <item><ref id="cbm_readdir" name="cbm_readdir"> -->
210 <!-- <item><ref id="cbm_save" name="cbm_save"> -->
211 <!-- <item><ref id="cbm_write" name="cbm_write"> -->
212 <!-- <item><ref id="get_tv" name="get_tv"> -->
213 <item><ref id="waitvsync" name="waitvsync">
214 <item><ref id="kbrepeat" name="kbrepeat">
220 <sect1><tt/cbm510.h/<label id="cbm510.h"><p>
223 <item><ref id="peekbsys" name="peekbsys">
224 <item><ref id="peekwsys" name="peekwsys">
225 <item><ref id="pokebsys" name="pokebsys">
226 <item><ref id="pokewsys" name="pokewsys">
230 <sect1><tt/cbm610.h/<label id="cbm610.h"><p>
233 <item><ref id="peekbsys" name="peekbsys">
234 <item><ref id="peekwsys" name="peekwsys">
235 <item><ref id="pokebsys" name="pokebsys">
236 <item><ref id="pokewsys" name="pokewsys">
240 <sect1><tt/cc65.h/<label id="cc65.h"><p>
243 <!-- <item><ref id="cc65_cos" name="cc65_cos"> -->
244 <!-- <item><ref id="cc65_idiv32by16r16" name="cc65_idiv32by16r16"> -->
245 <!-- <item><ref id="cc65_imul16x16r32" name="cc65_imul16x16r32"> -->
246 <!-- <item><ref id="cc65_imul8x8r16" name="cc65_imul8x8r16"> -->
247 <!-- <item><ref id="cc65_sin" name="cc65_sin"> -->
248 <!-- <item><ref id="cc65_udiv32by16r16" name="cc65_udiv32by16r16"> -->
249 <!-- <item><ref id="cc65_umul16x16r32" name="cc65_umul16x16r32"> -->
250 <!-- <item><ref id="cc65_umul16x8r32" name="cc65_umul16x8r32"> -->
251 <!-- <item><ref id="cc65_umul8x8r16" name="cc65_umul8x8r16"> -->
252 <item><ref id="doesclrscrafterexit" name="doesclrscrafterexit">
258 <sect1><tt/conio.h/<label id="conio.h"><p>
261 <item><ref id="bgcolor" name="bgcolor">
262 <item><ref id="bordercolor" name="bordercolor">
263 <item><ref id="cclear" name="cclear">
264 <item><ref id="cclearxy" name="cclearxy">
265 <item><ref id="cgetc" name="cgetc">
266 <item><ref id="chline" name="chline">
267 <item><ref id="chlinexy" name="chlinexy">
268 <item><ref id="clrscr" name="clrscr">
269 <item><ref id="cpeekc" name="cpeekc">
270 <item><ref id="cpeekcolor" name="cpeekcolor">
271 <item><ref id="cpeekrevers" name="cpeekrevers">
272 <item><ref id="cpeeks" name="cpeeks">
273 <item><ref id="cprintf" name="cprintf">
274 <item><ref id="cputc" name="cputc">
275 <item><ref id="cputcxy" name="cputcxy">
276 <item><ref id="cputs" name="cputs">
277 <item><ref id="cputsxy" name="cputsxy">
278 <item><ref id="cursor" name="cursor">
279 <item><ref id="cvline" name="cvline">
280 <item><ref id="cvlinexy" name="cvlinexy">
281 <item><ref id="gotox" name="gotox">
282 <item><ref id="gotoxy" name="gotoxy">
283 <item><ref id="gotoy" name="gotoy">
284 <item><ref id="kbhit" name="kbhit">
285 <item><ref id="revers" name="revers">
286 <item><ref id="screensize" name="screensize">
287 <item><ref id="textcolor" name="textcolor">
288 <item><ref id="vcprintf" name="vcprintf">
289 <item><ref id="wherex" name="wherex">
290 <item><ref id="wherey" name="wherey">
294 <sect1><tt/ctype.h/<label id="ctype.h"><p>
297 <item><ref id="isalnum" name="isalnum">
298 <item><ref id="isalpha" name="isalpha">
299 <item><ref id="isascii" name="isascii">
300 <item><ref id="isblank" name="isblank">
301 <item><ref id="iscntrl" name="iscntrl">
302 <item><ref id="isdigit" name="isdigit">
303 <item><ref id="isgraph" name="isgraph">
304 <item><ref id="islower" name="islower">
305 <item><ref id="isprint" name="isprint">
306 <item><ref id="ispunct" name="ispunct">
307 <item><ref id="isspace" name="isspace">
308 <item><ref id="isupper" name="isupper">
309 <item><ref id="isxdigit" name="isxdigit">
310 <item><ref id="tolower" name="tolower">
311 <item><ref id="toupper" name="toupper">
315 <sect1><tt/dbg.h/<label id="dbg.h"><p>
318 <!-- <item><ref id="DbgInit" name="DbgInit"> -->
324 <sect1><tt/device.h/<label id="device.h"><p>
327 <item><ref id="getcurrentdevice" name="getcurrentdevice">
328 <item><ref id="getdevicedir" name="getdevicedir">
329 <item><ref id="getfirstdevice" name="getfirstdevice">
330 <item><ref id="getnextdevice" name="getnextdevice">
334 <sect1><tt/dio.h/<label id="dio.h"><p>
336 <url url="dio.html" name="Low-level disk I/O API">.
339 <sect1><tt/dirent.h/<label id="dirent.h"><p>
342 <item><ref id="_DE_ISDIR" name="_DE_ISDIR">
343 <item><ref id="_DE_ISLBL" name="_DE_ISLBL">
344 <item><ref id="_DE_ISLNK" name="_DE_ISLNK">
345 <item><ref id="_DE_ISREG" name="_DE_ISREG">
346 <item><ref id="closedir" name="closedir">
347 <item><ref id="opendir" name="opendir">
348 <item><ref id="readdir" name="readdir">
349 <item><ref id="rewinddir" name="rewinddir">
350 <item><ref id="seekdir" name="seekdir">
351 <item><ref id="telldir" name="telldir">
355 <sect1><tt/em.h/<label id="em.h"><p>
358 <item><ref id="em_commit" name="em_commit">
359 <item><ref id="em_copyfrom" name="em_copyfrom">
360 <item><ref id="em_copyto" name="em_copyto">
361 <item><ref id="em_install" name="em_install">
362 <item><ref id="em_load_driver" name="em_load_driver">
363 <item><ref id="em_map" name="em_map">
364 <item><ref id="em_pagecount" name="em_pagecount">
365 <item><ref id="em_uninstall" name="em_uninstall">
366 <item><ref id="em_unload" name="em_unload">
367 <item><ref id="em_use" name="em_use">
371 <sect1><tt/errno.h/<label id="errno.h"><p>
374 <!-- <item><ref id="_directerrno" name="_directerrno"> -->
375 <!-- <item><ref id="_mappederrno" name="_mappederrno"> -->
376 <!-- <item><ref id="_osmaperrno" name="_osmaperrno"> -->
377 <!-- <item><ref id="_seterrno" name="_seterrno"> -->
383 <sect1><tt/fcntl.h/<label id="fcntl.h"><p>
386 <item><ref id="close" name="close">
387 <item><ref id="creat" name="creat">
388 <item><ref id="open" name="open">
392 <sect1><tt/gamate.h/<label id="gamate.h"><p>
395 <!-- <item><ref id="get_tv" name="get_tv"> -->
396 <item><ref id="waitvsync" name="waitvsync">
402 <sect1><tt/geos.h/<label id="geos.h"><p>
404 <url url="geos.html" name="GEOS API">.
407 <sect1><tt/joystick.h/<label id="joystick.h"><p>
410 <item><ref id="joy_count" name="joy_count">
411 <item><ref id="joy_install" name="joy_install">
412 <item><ref id="joy_load_driver" name="joy_load_driver">
413 <item><ref id="joy_read" name="joy_read">
414 <item><ref id="joy_uninstall" name="joy_uninstall">
415 <item><ref id="joy_unload" name="joy_unload">
419 <sect1><tt/locale.h/<label id="locale.h"><p>
422 <item><ref id="localeconv" name="localeconv">
423 <item><ref id="setlocale" name="setlocale">
427 <sect1><tt/lynx.h/<label id="lynx.h"><p>
430 <!-- <item><ref id="lynx_eeprom_erase" name="lynx_eeprom_erase"> -->
431 <!-- <item><ref id="lynx_eeprom_read" name="lynx_eeprom_read"> -->
432 <!-- <item><ref id="lynx_eeprom_write" name="lynx_eeprom_write"> -->
433 <!-- <item><ref id="lynx_eeread" name="lynx_eeread"> -->
434 <!-- <item><ref id="lynx_eewrite" name="lynx_eewrite"> -->
435 <!-- <item><ref id="lynx_exec" name="lynx_exec"> -->
436 <!-- <item><ref id="lynx_load" name="lynx_load"> -->
442 <sect1><tt/lz4.h/<label id="lz4.h"><p>
445 <item><ref id="decompress_lz4" name="decompress_lz4">
449 <sect1><tt/modload.h/<label id="modload.h"><p>
452 <item><ref id="mod_load" name="mod_load">
453 <item><ref id="mod_free" name="mod_free">
457 <sect1><tt/mouse.h/<label id="mouse.h"><p>
460 <item><ref id="mouse_buttons" name="mouse_buttons">
461 <item><ref id="mouse_getbox" name="mouse_getbox">
462 <item><ref id="mouse_geterrormsg" name="mouse_geterrormsg">
463 <item><ref id="mouse_hide" name="mouse_hide">
464 <item><ref id="mouse_info" name="mouse_info">
465 <item><ref id="mouse_install" name="mouse_install">
466 <item><ref id="mouse_ioctl" name="mouse_ioctl">
467 <item><ref id="mouse_load_driver" name="mouse_load_driver">
468 <item><ref id="mouse_move" name="mouse_move">
469 <item><ref id="mouse_pos" name="mouse_pos">
470 <item><ref id="mouse_setbox" name="mouse_setbox">
471 <item><ref id="mouse_show" name="mouse_show">
472 <item><ref id="mouse_uninstall" name="mouse_uninstall">
473 <item><ref id="mouse_unload" name="mouse_unload">
477 <sect1><tt/nes.h/<label id="nes.h"><p>
480 <!-- <item><ref id="get_tv" name="get_tv"> -->
481 <item><ref id="waitvsync" name="waitvsync">
487 <sect1><tt/o65.h/<label id="o65.h"><p>
489 The <tt/o65.h/ header file contains structure and constant definitions that
490 may be used when dealing with files in <url
491 url="http://www.6502.org/users/andre/o65/fileformat.html" name="the o65 format">.
492 It does not declare any functions.
495 <sect1><tt/pce.h/<label id="pce.h"><p>
498 <!-- <item><ref id="get_tv" name="get_tv"> -->
499 <item><ref id="waitvsync" name="waitvsync">
505 <sect1><tt/peekpoke.h/<label id="peekpoke.h"><p>
508 <item><ref id="PEEK" name="PEEK">
509 <item><ref id="PEEKW" name="PEEKW">
510 <item><ref id="POKE" name="POKE">
511 <item><ref id="POKEW" name="POKEW">
515 <sect1><tt/pen.h/<label id="pen.h"><p>
518 <!-- <item><ref id="pen_adjust" name="pen_adjust"> -->
519 <!-- <item><ref id="pen_calibrate" name="pen_calibrate"> -->
525 <sect1><tt/pet.h/<label id="pet.h"><p>
530 <sect1><tt/plus4.h/<label id="plus4.h"><p>
533 <item><ref id="fast" name="fast">
534 <item><ref id="isfast" name="isfast">
535 <item><ref id="slow" name="slow">
541 <sect1><tt/serial.h/<label id="serial.h"><p>
543 The <tt/serial.h/ header file contains definitions for initializing serial
547 <item><ref id="ser_close" name="ser_close">
548 <item><ref id="ser_get" name="ser_get">
549 <item><ref id="ser_install" name="ser_install">
550 <item><ref id="ser_ioctl" name="ser_ioctl">
551 <item><ref id="ser_load_driver" name="ser_load_driver">
552 <item><ref id="ser_open" name="ser_open">
553 <item><ref id="ser_put" name="ser_put">
554 <item><ref id="ser_status" name="ser_status">
555 <item><ref id="ser_uninstall" name="ser_uninstall">
556 <item><ref id="ser_unload" name="ser_unload">
560 <sect1><tt/setjmp.h/<label id="setjmp.h"><p>
563 <item><ref id="setjmp" name="setjmp">
564 <item><ref id="longjmp" name="longjmp">
568 <sect1><tt/signal.h/<label id="signal.h"><p>
571 <item><ref id="raise" name="raise">
572 <item><ref id="signal" name="signal">
576 <sect1><tt/stdarg.h/<label id="stdarg.h"><p>
581 <sect1><tt/stdbool.h/<label id="stdbool.h"><p>
586 <sect1><tt/stddef.h/<label id="stddef.h"><p>
589 <item><ref id="offsetof" name="offsetof">
593 <sect1><tt/stdio.h/<label id="stdio.h"><p>
596 <item><ref id="_poserror" name="_poserror">
597 <item><ref id="clearerr" name="clearerr">
598 <!-- <item><ref id="fclose" name="fclose"> -->
599 <!-- <item><ref id="fdopen" name="fdopen"> -->
600 <item><ref id="feof" name="feof">
601 <item><ref id="ferror" name="ferror">
602 <!-- <item><ref id="fflush" name="fflush"> -->
603 <!-- <item><ref id="fgetc" name="fgetc"> -->
604 <!-- <item><ref id="fgetpos" name="fgetpos"> -->
605 <!-- <item><ref id="fgets" name="fgets"> -->
606 <item><ref id="fileno" name="fileno">
607 <!-- <item><ref id="fopen" name="fopen"> -->
608 <!-- <item><ref id="fprintf" name="fprintf"> -->
609 <!-- <item><ref id="fputc" name="fputc"> -->
610 <!-- <item><ref id="fputs" name="fputs"> -->
611 <!-- <item><ref id="fread" name="fread"> -->
612 <!-- <item><ref id="freopen" name="freopen"> -->
613 <!-- <item><ref id="fscanf" name="fscanf"> -->
614 <!-- <item><ref id="fseek" name="fseek"> -->
615 <!-- <item><ref id="fsetpos" name="fsetpos"> -->
616 <!-- <item><ref id="ftell" name="ftell"> -->
617 <!-- <item><ref id="fwrite" name="fwrite"> -->
618 <!-- <item><ref id="getc" name="getc"> -->
619 <!-- <item><ref id="getchar" name="getchar"> -->
620 <!-- <item><ref id="gets" name="gets"> -->
621 <!-- <item><ref id="printf" name="printf"> -->
622 <!-- <item><ref id="putc" name="putc"> -->
623 <!-- <item><ref id="putchar" name="putchar"> -->
624 <!-- <item><ref id="puts" name="puts"> -->
625 <item><ref id="rename" name="rename">
626 <item><ref id="remove" name="remove">
627 <!-- <item><ref id="rewind" name="rewind"> -->
628 <!-- <item><ref id="scanf" name="scanf"> -->
629 <!-- <item><ref id="snprintf" name="snprintf"> -->
630 <!-- <item><ref id="sprintf" name="sprintf"> -->
631 <!-- <item><ref id="sscanf" name="sscanf"> -->
632 <!-- <item><ref id="vfprintf" name="vfprintf"> -->
633 <!-- <item><ref id="vfscanf" name="vfscanf"> -->
634 <!-- <item><ref id="vprintf" name="vprintf"> -->
635 <!-- <item><ref id="vscanf" name="vscanf"> -->
636 <!-- <item><ref id="vsnprintf" name="vsnprintf"> -->
637 <!-- <item><ref id="vsprintf" name="vsprintf"> -->
638 <!-- <item><ref id="vsscanf" name="vsscanf"> -->
644 <sect1><tt/stdlib.h/<label id="stdlib.h"><p>
647 <item><ref id="_heapadd" name="_heapadd">
648 <item><ref id="_heapblocksize" name="_heapblocksize">
649 <item><ref id="_heapmaxavail" name="_heapmaxavail">
650 <item><ref id="_heapmemavail" name="_heapmemavail">
651 <item><ref id="_randomize" name="_randomize">
652 <item><ref id="_swap" name="_swap">
653 <item><ref id="abort" name="abort">
654 <item><ref id="abs" name="abs">
655 <item><ref id="atexit" name="atexit">
656 <item><ref id="atoi" name="atoi">
657 <item><ref id="atol" name="atol">
658 <item><ref id="bsearch" name="bsearch">
659 <item><ref id="calloc" name="calloc">
660 <item><ref id="div" name="div">
661 <item><ref id="exit" name="exit">
662 <item><ref id="free" name="free">
663 <item><ref id="getenv" name="getenv">
664 <item><ref id="itoa" name="itoa">
665 <item><ref id="labs" name="labs">
666 <item><ref id="ltoa" name="ltoa">
667 <item><ref id="malloc" name="malloc">
668 <item><ref id="perror" name="perror">
669 <!-- <item><ref id="posix_memalign" name="posix_memalign"> -->
670 <!-- <item><ref id="putenv" name="putenv"> -->
671 <item><ref id="qsort" name="qsort">
672 <item><ref id="rand" name="rand">
673 <item><ref id="realloc" name="realloc">
674 <item><ref id="srand" name="srand">
675 <!-- <item><ref id="system" name="system"> -->
676 <item><ref id="ultoa" name="ultoa">
677 <item><ref id="utoa" name="utoa">
683 <sect1><tt/string.h/<label id="string.h"><p>
686 <item><ref id="_stroserror" name="_stroserror">
687 <item><ref id="bzero" name="bzero">
688 <item><ref id="memchr" name="memchr">
689 <item><ref id="memcmp" name="memcmp">
690 <item><ref id="memcpy" name="memcpy">
691 <item><ref id="memmove" name="memmove">
692 <item><ref id="memset" name="memset">
693 <item><ref id="strcasecmp" name="strcasecmp">
694 <item><ref id="strcat" name="strcat">
695 <item><ref id="strchr" name="strchr">
696 <item><ref id="strcmp" name="strcmp">
697 <item><ref id="strcoll" name="strcoll">
698 <item><ref id="strcpy" name="strcpy">
699 <item><ref id="strcspn" name="strcspn">
700 <item><ref id="strdup" name="strdup">
701 <item><ref id="strerror" name="strerror">
702 <item><ref id="stricmp" name="stricmp">
703 <item><ref id="strlen" name="strlen">
704 <item><ref id="strlower" name="strlower">
705 <item><ref id="strlwr" name="strlwr">
706 <item><ref id="strncasecmp" name="strncasecmp">
707 <item><ref id="strncat" name="strncat">
708 <item><ref id="strncmp" name="strncmp">
709 <item><ref id="strncpy" name="strncpy">
710 <item><ref id="strnicmp" name="strnicmp">
711 <item><ref id="strqtok" name="strqtok">
712 <item><ref id="strrchr" name="strrchr">
713 <item><ref id="strspn" name="strspn">
714 <item><ref id="strstr" name="strstr">
715 <item><ref id="strtok" name="strtok">
716 <item><ref id="strxfrm" name="strxfrm">
717 <item><ref id="strupper" name="strupper">
718 <item><ref id="strupr" name="strupr">
722 <sect1><tt/telestrat.h/<label id="telestrat.h"><p>
725 <item><ref id="atmos_explode" name="explode">
726 <item><ref id="atmos_ping" name="ping">
727 <item><ref id="atmos_shoot" name="shoot">
728 <item><ref id="atmos_zap" name="zap">
729 <!-- <item><ref id="kbdclick1" name="kbdclick1"> -->
730 <!-- <item><ref id="oups" name="oups"> -->
736 <sect1><tt/tgi.h/<label id="tgi.h"><p>
738 <url url="tgi.html" name="Tiny Graphics Interface">.
741 <sect1><tt/time.h/<label id="time.h"><p>
744 <!-- <item><ref id="_systime" name="_systime"> -->
745 <!-- <item><ref id="asctime" name="asctime"> -->
746 <item><ref id="clock" name="clock">
747 <!-- <item><ref id="ctime" name="ctime"> -->
748 <!-- <item><ref id="gmtime" name="gmtime"> -->
749 <!-- <item><ref id="localtime" name="localtime"> -->
750 <!-- <item><ref id="mktime" name="mktime"> -->
751 <!-- <item><ref id="strftime" name="strftime"> -->
752 <item><ref id="time" name="time">
758 <sect1><tt/unistd.h/<label id="unistd.h"><p>
761 <!-- <item><ref id="chdir" name="chdir"> -->
762 <item><ref id="exec" name="exec">
763 <item><ref id="getcwd" name="getcwd">
764 <item><ref id="getopt" name="getopt">
765 <!-- <item><ref id="lseek" name="lseek"> -->
766 <!-- <item><ref id="mkdir" name="mkdir"> -->
767 <!-- <item><ref id="read" name="read"> -->
768 <!-- <item><ref id="rmdir" name="rmdir"> -->
769 <item><ref id="sleep" name="sleep">
770 <item><ref id="unlink" name="unlink">
771 <!-- <item><ref id="write" name="write"> -->
777 <sect1><tt/vic20.h/<label id="vic20.h"><p>
782 <sect1><tt/zlib.h/<label id="zlib.h"><p>
785 <!-- <item><ref id="adler32" name="adler32"> -->
786 <!-- <item><ref id="crc32" name="crc32"> -->
787 <!-- <item><ref id="inflatemem" name="inflatemem"> -->
788 <!-- <item><ref id="uncompress" name="uncompress"> -->
794 <sect>Alphabetical function reference<p>
796 <sect1>_DE_ISDIR<label id="_DE_ISDIR"><p>
800 <tag/Function/Determine if a directory entry specifies a directory.
801 <tag/Header/<tt/<ref id="dirent.h" name="dirent.h">/
802 <tag/Declaration/<tt/int _DE_ISDIR(unsigned char type);/
803 <tag/Description/The function is called with the type of a directory entry
804 taken from a <tt/struct dirent/ and returns true if the entry designates
807 <item>The function is actually a macro.
809 <tag/Availability/cc65
811 <ref id="_DE_ISLBL" name="_DE_ISLBL">,
812 <ref id="_DE_ISLNK" name="_DE_ISLNK">,
813 <ref id="_DE_ISREG" name="_DE_ISREG">
819 <sect1>_DE_ISLBL<label id="_DE_ISLBL"><p>
823 <tag/Function/Determine if a directory entry specifies a disk label.
824 <tag/Header/<tt/<ref id="dirent.h" name="dirent.h">/
825 <tag/Declaration/<tt/int _DE_ISLBL(unsigned char type);/
826 <tag/Description/The function is called with the type of a directory entry
827 taken from a <tt/struct dirent/ and returns true if the entry designates
830 <item>The function is actually a macro.
832 <tag/Availability/cc65
834 <ref id="_DE_ISDIR" name="_DE_ISDIR">,
835 <ref id="_DE_ISLNK" name="_DE_ISLNK">,
836 <ref id="_DE_ISREG" name="_DE_ISREG">
842 <sect1>_DE_ISLNK<label id="_DE_ISLNK"><p>
846 <tag/Function/Determine if a directory entry specifies a link.
847 <tag/Header/<tt/<ref id="dirent.h" name="dirent.h">/
848 <tag/Declaration/<tt/int _DE_ISLNK(unsigned char type);/
849 <tag/Description/The function is called with the type of a directory entry
850 taken from a <tt/struct dirent/ and returns true if the entry designates
853 <item>The function is actually a macro.
855 <tag/Availability/cc65
857 <ref id="_DE_ISDIR" name="_DE_ISDIR">,
858 <ref id="_DE_ISLBL" name="_DE_ISLBL">,
859 <ref id="_DE_ISREG" name="_DE_ISREG">
865 <sect1>_DE_ISREG<label id="_DE_ISREG"><p>
869 <tag/Function/Determine if a directory entry specifies a regular file.
870 <tag/Header/<tt/<ref id="dirent.h" name="dirent.h">/
871 <tag/Declaration/<tt/int _DE_ISREG(unsigned char type);/
872 <tag/Description/The function is called with the type of a directory entry
873 taken from a <tt/struct dirent/ and returns true if the entry designates
876 <item>The function is actually a macro.
877 <item>A "regular file" means anything with data in it. This might still mean
878 that special processing is needed, when accessing the file. Relative files of
879 the CBM systems are classified as being "regular" files, for example.
881 <tag/Availability/cc65
883 <ref id="_DE_ISDIR" name="_DE_ISDIR">,
884 <ref id="_DE_ISLBL" name="_DE_ISLBL">,
885 <ref id="_DE_ISLNK" name="_DE_ISLNK">
891 <sect1>_heapadd<label id="_heapadd"><p>
895 <tag/Function/Add a block to the heap.
896 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
897 <tag/Declaration/<tt/void __fastcall__ _heapadd (void* mem, size_t size);/
898 <tag/Description/The function adds a block of raw memory to the heap.
900 <item>The minimum blocksize that can be added is 6 bytes; the function will
901 ignore smaller blocks.
902 <item>The function is available only as a fastcall function; so, it may be used
903 only in the presence of a prototype.
905 <tag/Availability/cc65
907 <ref id="_heapblocksize" name="_heapblocksize">,
908 <ref id="_heapmaxavail" name="_heapmaxavail">,
909 <ref id="_heapmemavail" name="_heapmemavail">,
910 <ref id="calloc" name="calloc">,
911 <ref id="free" name="free">,
912 <ref id="malloc" name="malloc">,
913 <ref id="realloc" name="realloc">
919 <sect1>_heapblocksize<label id="_heapblocksize"><p>
923 <tag/Function/Return the size of an allocated block.
924 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
925 <tag/Declaration/<tt/size_t __fastcall__ _heapblocksize (const void* block);/
926 <tag/Description/The function returns the size of a block that must have
927 previously been allocated by <tt/<ref id="malloc" name="malloc">/, <tt/<ref
928 id="calloc" name="calloc">/ or <tt/<ref id="realloc" name="realloc">/.
930 <item>Passing a pointer to a block that was is not the result of one of the
931 allocation functions, or that has been free'd will give unpredicable results.
932 <item>The function is available only as a fastcall function; so, it may be used
933 only in the presence of a prototype.
935 <tag/Availability/cc65
937 <ref id="_heapadd" name="_heapadd">,
938 <ref id="_heapmaxavail" name="_heapmaxavail">,
939 <ref id="_heapmemavail" name="_heapmemavail">,
940 <ref id="calloc" name="calloc">,
941 <ref id="free" name="free">,
942 <ref id="malloc" name="malloc">,
943 <ref id="realloc" name="realloc">
949 <sect1>_heapmaxavail<label id="_heapmaxavail"><p>
953 <tag/Function/Return the largest block that is available on the heap.
954 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
955 <tag/Declaration/<tt/size_t _heapmaxavail (void);/
956 <tag/Description/The function returns the size of the largest block that may
957 be allocated from the heap using <tt/<ref id="malloc" name="malloc">/.
958 <tag/Availability/cc65
960 <ref id="_heapadd" name="_heapadd">,
961 <ref id="_heapblocksize" name="_heapblocksize">,
962 <ref id="_heapmemavail" name="_heapmemavail">,
963 <ref id="calloc" name="calloc">,
964 <ref id="free" name="free">,
965 <ref id="malloc" name="malloc">,
966 <ref id="realloc" name="realloc">
972 <sect1>_heapmemavail<label id="_heapmemavail"><p>
976 <tag/Function/Return the total available space on the heap.
977 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
978 <tag/Declaration/<tt/size_t _heapmemavail (void);/
979 <tag/Description/The function returns the total number of bytes available on
982 <item>This function is of less use than usually assumed, since the returned
983 heap space may be available but not in one block. So even if this function
984 says that several times more heap space is available than needed, <ref
985 id="malloc" name="malloc"> may still return <tt/NULL/.
987 <tag/Availability/cc65
989 <ref id="_heapadd" name="_heapadd">,
990 <ref id="_heapblocksize" name="_heapblocksize">,
991 <ref id="_heapmaxavail" name="_heapmaxavail">,
992 <ref id="calloc" name="calloc">,
993 <ref id="free" name="free">,
994 <ref id="malloc" name="malloc">,
995 <ref id="realloc" name="realloc">
1001 <sect1>_is_cmdline_dos<label id="_is_cmdline_dos"><p>
1005 <tag/Function/Determines whether the underlying DOS supports command line arguments.
1006 <tag/Header/<tt/<ref id="atari.h" name="atari.h">/
1007 <tag/Declaration/<tt/unsigned char _is_cmdline_dos (void);/
1008 <tag/Description/The function returns 0 if the DOS doesn't support command line arguments.
1009 It returns 1 if it does.
1010 <tag/Availability/cc65 (<tt/atari/ and <tt/atarixl/ platforms)
1015 <sect1>_poserror<label id="_poserror"><p>
1019 <tag/Function/Print an error message for the error in <tt/_oserror/.
1020 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
1021 <tag/Declaration/<tt/void __fastcall__ _poserror (const char* msg);/
1022 <tag/Description/<tt/_poserror/ prints an error message to <tt/stderr/. If
1023 <tt/msg/ is not <tt/NULL/ and not an empty string, it is printed followed by
1024 a colon and a blank. Then the error message for the current contents of
1025 <tt/_oserror/ are printed followed by a newline. The message output is the
1026 same as returned by <tt/<ref id="_stroserror" name="_stroserror">/ with an
1027 argument of <tt/_oserror/.
1028 <tag/Notes/<itemize>
1029 <item>Since operating system specific error code are - you guessed it -
1030 operating system specific, the value in <tt/_oserror/ and the message that is
1031 printed depends on the cc65 target.
1032 <item>The function is only available as fastcall function, so it may only
1033 be used in presence of a prototype.
1035 <tag/Availability/cc65
1037 <ref id="_stroserror" name="_stroserror">,
1038 <ref id="perror" name="perror">
1044 <sect1>_randomize<label id="_randomize"><p>
1048 <tag/Function/Initialize the pseudo random number generator.
1049 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1050 <tag/Declaration/<tt/void _randomize (void);/
1051 <tag/Description/The function initializes the random number generator with
1052 a seed derived from fast changing hardware events, so the seed itself can be
1053 considered random to a certain degree.
1054 <tag/Notes/<itemize>
1055 <item>The randomness of the seed depends on the machine hardware.
1057 <tag/Availability/cc65
1059 <ref id="rand" name="rand">,
1060 <ref id="srand" name="srand">
1066 <sect1>_stroserror<label id="_stroserror"><p>
1070 <tag/Function/Return a string describing an OS specific error code.
1071 <tag/Header/<tt/<ref id="string.h" name="string.h">/
1072 <tag/Declaration/<tt/const char* __fastcall__ _stroserror (unsigned char errcode);/
1073 <tag/Description/<tt/_stroserror/ will return a string describing the given
1074 operating system specific error code.
1075 <tag/Notes/<itemize>
1076 <item>Since operating system specific error code are - you guessed it -
1077 operating system specific, the parameter and the string returned depend on the
1079 <item>The function is only available as fastcall function, so it may only be
1080 used in presence of a prototype.
1082 <tag/Availability/cc65
1084 <ref id="strerror" name="strerror">
1090 <sect1>_swap<label id="_swap"><p>
1094 <tag/Function/Swap the contents of memory areas.
1095 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1096 <tag/Declaration/<tt/void __fastcall__ _swap (void* p, void* q, size_t size);/
1097 <tag/Description/<tt/_swap/ will swap (exchange) the contents of the two memory
1098 areas pointed to by <tt/p/ and <tt/q/. Both memory areas are assumed to be
1099 <tt/size/ bytes in size.
1100 <tag/Notes/<itemize>
1101 <item>The memory areas may not overlap, otherwise the results are undefined.
1102 <item>The function is only available as fastcall function, so it may only be
1103 used in presence of a prototype.
1105 <tag/Availability/cc65
1107 <ref id="memcpy" name="memcpy">,
1108 <ref id="memmove" name="memmove">
1114 <sect1>_sys<label id="_sys"><p>
1118 <tag/Function/Call a subroutine passing register values.
1119 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
1120 <tag/Declaration/<tt/void __fastcall__ _sys (struct regs* r);/
1121 <tag/Description/The function will call the subroutine at the address
1122 specified in the <tt/pc/ member of the passed <tt/regs/ structure. All
1123 registers and the CPU flags are set to the values given in the <tt/regs/
1124 structure. On return from the subroutine, the new values of the registers and
1125 flags are stored back overwriting the old values.
1126 <tag/Notes/<itemize>
1127 <item>Bits 4 and 5 of the flags value in the <tt/regs/ structure are ignored
1128 when calling the subroutine (they are unchanged from their current values).
1129 <item>The function is only available as fastcall function, so it may only be
1130 used in presence of a prototype.
1132 <tag/Availability/cc65
1138 <sect1>BRK<label id="BRK"><p>
1142 <tag/Function/Insert a 6502 BRK instrunction into the code.
1143 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
1144 <tag/Declaration/<tt/void BRK (void);/
1145 <tag/Description/The function will insert a 6502 BRK instruction into the code
1146 which may be used to trigger a debugger.
1147 <tag/Notes/<itemize>
1148 <item>The function is actually a macro.
1149 <item>The inserted instruction may lead to unexpected results if no debugger
1152 <tag/Availability/cc65
1154 <ref id="CLI" name="CLI">,
1155 <ref id="SEI" name="SEI">
1161 <sect1>CLI<label id="CLI"><p>
1165 <tag/Function/Insert a 6502 CLI instrunction into the code.
1166 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
1167 <tag/Declaration/<tt/void CLI (void);/
1168 <tag/Description/The function will insert a 6502 CLI instruction into the code,
1169 so interrupts are enabled. Enabling interrupts has no effects if they are
1170 already enabled (the default).
1171 <tag/Notes/<itemize>
1172 <item>The function is actually a macro.
1173 <item>Disabling interrupts may lead to unexpected results.
1175 <tag/Availability/cc65
1177 <ref id="BRK" name="BRK">,
1178 <ref id="SEI" name="SEI">
1184 <sect1>PEEK<label id="PEEK"><p>
1188 <tag/Function/Read a byte from memory.
1189 <tag/Header/<tt/<ref id="peekpoke.h" name="peekpoke.h">/
1190 <tag/Declaration/<tt/unsigned char PEEK (unsigned addr);/
1191 <tag/Description/The function will read the absolute memory given by <tt/addr/
1192 and return the value read.
1193 <tag/Notes/<itemize>
1194 <item>The function is actually a macro.
1195 <item>This function depends highly on the platform and environment.
1197 <tag/Availability/cc65
1199 <ref id="PEEKW" name="PEEKW">,
1200 <ref id="POKE" name="POKE">
1206 <sect1>PEEKW<label id="PEEKW"><p>
1210 <tag/Function/Read a word (two bytes) from memory.
1211 <tag/Header/<tt/<ref id="peekpoke.h" name="peekpoke.h">/
1212 <tag/Declaration/<tt/unsigned PEEKW (unsigned addr);/
1213 <tag/Description/The function will read the absolute memory given by <tt/addr/
1214 and return the value read. The byte read from the higher address is the high
1215 byte of the return value.
1216 <tag/Notes/<itemize>
1217 <item>The function is actually a macro.
1218 <item>This function depends highly on the platform and environment.
1219 <item>The order in which the two bytes are read is unspecified and may
1220 depend of the address expression used.
1222 <tag/Availability/cc65
1224 <ref id="PEEK" name="PEEK">,
1225 <ref id="POKE" name="POKE">
1231 <sect1>POKE<label id="POKE"><p>
1235 <tag/Function/Write a byte to memory.
1236 <tag/Header/<tt/<ref id="peekpoke.h" name="peekpoke.h">/
1237 <tag/Declaration/<tt/void POKE (unsigned addr, unsigned char val);/
1238 <tag/Description/The function writes the value <tt/val/ to the absolute
1239 memory address given by <tt/addr/.
1240 <tag/Notes/<itemize>
1241 <item>The function is actually a macro.
1242 <item>This function depends highly on the platform and environment.
1243 <item>Careless use will cause the program to act strange or may crash the
1246 <tag/Availability/cc65
1248 <ref id="PEEK" name="PEEK">,
1249 <ref id="POKEW" name="POKEW">
1255 <sect1>POKEW<label id="POKEW"><p>
1259 <tag/Function/Write a word (two bytes) to memory.
1260 <tag/Header/<tt/<ref id="peekpoke.h" name="peekpoke.h">/
1261 <tag/Declaration/<tt/void POKEW (unsigned addr, unsigned val);/
1262 <tag/Description/The function writes the value <tt/val/ to the absolute
1263 memory address given by <tt/addr/. The low byte of <tt/val/ is written to
1264 the <tt/addr/, the high byte is written to <tt/addr+1/.
1265 <tag/Notes/<itemize>
1266 <item>The function is actually a macro.
1267 <item>This function depends highly on the platform and environment.
1268 <item>Careless use will cause the program to act strange or may crash the
1270 <item>The order in which the two bytes are written is unspecified and may
1271 depend of the address expression used.
1273 <tag/Availability/cc65
1275 <ref id="PEEK" name="PEEK">,
1276 <ref id="POKE" name="POKE">
1282 <sect1>SEI<label id="SEI"><p>
1286 <tag/Function/Insert a 6502 SEI instrunction into the code.
1287 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
1288 <tag/Declaration/<tt/void SEI (void);/
1289 <tag/Description/The function will insert a 6502 SEI instruction into the code,
1290 so interrupts are disabled. Note that non maskable interrupts cannot be
1292 <tag/Notes/<itemize>
1293 <item>The function is actually a macro.
1294 <item>Disabling interrupts may lead to unexpected results.
1296 <tag/Availability/cc65
1298 <ref id="BRK" name="BRK">,
1299 <ref id="CLI" name="CLI">
1305 <sect1>abort<label id="abort"><p>
1309 <tag/Function/Terminates a program abnormally.
1310 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1311 <tag/Declaration/<tt/void abort (void);/
1312 <tag/Description/<tt/abort/ raises <tt/SIGABRT/, writes a termination message
1313 on stderr, then terminates the program with an exit code of 3.
1314 <tag/Availability/ISO 9899
1316 <ref id="assert" name="assert">,
1317 <ref id="exit" name="exit">,
1318 <ref id="raise" name="raise">
1324 <sect1>abs<label id="abs"><p>
1328 <tag/Function/Returns the absolute value of an integer.
1329 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1330 <tag/Declaration/<tt/int __fastcall__ abs (int v);/
1331 <tag/Description/<tt/abs/ returns the absolute value of the argument passed to
1333 <tag/Notes/<itemize>
1334 <item>The return value is undefined if <tt/INT_MIN/ is passed to the function.
1335 <item>The function is only available as fastcall function, so it may only be
1336 used in presence of a prototype.
1338 <tag/Availability/ISO 9899
1340 <ref id="labs" name="labs">
1346 <sect1>assert<label id="assert"><p>
1350 <tag/Function/Test a condition and possibly abort.
1351 <tag/Header/<tt/<ref id="assert.h" name="assert.h">/
1352 <tag/Declaration/<tt/void assert (int cond);/
1353 <tag/Description/<tt/assert/ is a macro that expands to a <tt/id/
1354 statement. If the condition evaluates t zero (false), assert prints a message
1355 on stderr and aborts the program.
1356 <tag/Notes/<itemize>
1357 <item>The function is actually a macro.
1359 <tag/Availability/ISO 9899
1361 <ref id="abort" name="abort">,
1362 <ref id="exit" name="exit">
1368 <sect1>atexit<label id="atexit"><p>
1372 <tag/Function/Register an exit function.
1373 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1374 <tag/Declaration/<tt/int __fastcall__ atexit (void (*exitfunc) (void));/
1375 <tag/Description/<tt/atexit/ registers the function pointed to by
1376 <tt/exitfunc/ as an exit function. Exit functions are called when the program
1377 terminates, they are called in LIFO order (the last function registered is
1378 called first). <tt/atexit/ returns zero on success and a nonzero value on
1380 <tag/Notes/<itemize>
1381 <item>A maximum of 5 exit functions can be registered.
1382 <item>There is no way to unregister an exit function.
1383 <item>The function is only available as fastcall function, so it may only be
1384 used in presence of a prototype.
1386 <tag/Availability/ISO 9899
1388 <ref id="abort" name="abort">,
1389 <ref id="exit" name="exit">
1395 <sect1>atmos_explode<label id="atmos_explode"><p>
1399 <tag/Function/Bomb sound effect.
1400 <tag/Header/<tt/<ref id="atmos.h" name="atmos.h">/
1401 <tag/Declaration/<tt/void __fastcall__ atmos_explode(void);/
1402 <tag/Description/<tt/atmos_explode/ plays the BASIC sound.
1403 <tag/Notes/<itemize>
1404 <item>The function is available only as a fastcall function; so, it may be used
1405 only in the presence of a prototype.
1407 <tag/Availability/cc65
1409 <ref id="atmos_ping" name="atmos_ping">,
1410 <ref id="atmos_shoot" name="atmos_shoot">,
1411 <ref id="atmos_tick" name="atmos_tick">,
1412 <ref id="atmos_tock" name="atmos_tock">,
1413 <ref id="atmos_zap" name="atmos_zap">
1419 <sect1>atmos_load<label id="atmos_load"><p>
1423 <tag/Function/Load Atmos tape.
1424 <tag/Header/<tt/<ref id="atmos.h" name="atmos.h">/
1425 <tag/Declaration/<tt/void __fastcall__ atmos_load(const char* name);/
1426 <tag/Description/<tt/atmos_load/ reads a memory block from tape.
1427 <tag/Notes/<itemize>
1428 <item>The function is available only as a fastcall function; so, it may be used
1429 only in the presence of a prototype.
1431 <tag/Availability/cc65
1433 <ref id="atmos_save" name="atmos_save">
1439 <sect1>atmos_ping<label id="atmos_ping"><p>
1443 <tag/Function/Bell or ricochet sound effect.
1444 <tag/Header/<tt/<ref id="atmos.h" name="atmos.h">/
1445 <tag/Declaration/<tt/void __fastcall__ atmos_ping(void);/
1446 <tag/Description/<tt/atmos_ping/ plays the BASIC sound.
1447 <tag/Notes/<itemize>
1448 <item>The function is available only as a fastcall function; so, it may be used
1449 only in the presence of a prototype.
1451 <tag/Availability/cc65
1453 <ref id="atmos_explode" name="atmos_explode">,
1454 <ref id="atmos_shoot" name="atmos_shoot">,
1455 <ref id="atmos_tick" name="atmos_tick">,
1456 <ref id="atmos_tock" name="atmos_tock">,
1457 <ref id="atmos_zap" name="atmos_zap">
1463 <sect1>atmos_save<label id="atmos_save"><p>
1467 <tag/Function/Save Atmos tape.
1468 <tag/Header/<tt/<ref id="atmos.h" name="atmos.h">/
1469 <tag/Declaration/<tt/void __fastcall__ atmos_save(const char* name, const void* start, const void* end);/
1470 <tag/Description/<tt/atmos_save/ writes a memory block to tape.
1471 <tag/Notes/<itemize>
1472 <item>The function is available only as a fastcall function; so, it may be used
1473 only in the presence of a prototype.
1475 <tag/Availability/cc65
1477 <ref id="atmos_load" name="atmos_load">
1479 atmos_save("hires", 0xa000, 0xc000);
1485 <sect1>atmos_shoot<label id="atmos_shoot"><p>
1489 <tag/Function/Pistol sound effect.
1490 <tag/Header/<tt/<ref id="atmos.h" name="atmos.h">/
1491 <tag/Declaration/<tt/void __fastcall__ atmos_shoot(void);/
1492 <tag/Description/<tt/atmos_shoot/ plays the BASIC sound.
1493 <tag/Notes/<itemize>
1494 <item>The function is available only as a fastcall function; so, it may be used
1495 only in the presence of a prototype.
1497 <tag/Availability/cc65
1499 <ref id="atmos_explode" name="atmos_explode">,
1500 <ref id="atmos_ping" name="atmos_ping">,
1501 <ref id="atmos_tick" name="atmos_tick">,
1502 <ref id="atmos_tock" name="atmos_tock">,
1503 <ref id="atmos_zap" name="atmos_zap">
1509 <sect1>atmos_tick<label id="atmos_tick"><p>
1513 <tag/Function/High-pitch click.
1514 <tag/Header/<tt/<ref id="atmos.h" name="atmos.h">/
1515 <tag/Declaration/<tt/void __fastcall__ atmos_tick(void);/
1516 <tag/Description/<tt/atmos_tick/ plays the system sound.
1517 <tag/Notes/<itemize>
1518 <item>The function is available only as a fastcall function; so, it may be used
1519 only in the presence of a prototype.
1521 <tag/Availability/cc65
1523 <ref id="atmos_explode" name="atmos_explode">,
1524 <ref id="atmos_ping" name="atmos_ping">,
1525 <ref id="atmos_shoot" name="atmos_shoot">,
1526 <ref id="atmos_tock" name="atmos_tock">,
1527 <ref id="atmos_zap" name="atmos_zap">
1533 <sect1>atmos_tock<label id="atmos_tock"><p>
1537 <tag/Function/Low-pitch click.
1538 <tag/Header/<tt/<ref id="atmos.h" name="atmos.h">/
1539 <tag/Declaration/<tt/void __fastcall__ atmos_tock(void);/
1540 <tag/Description/<tt/atmos_tock/ plays the system sound.
1541 <tag/Notes/<itemize>
1542 <item>The function is available only as a fastcall function; so, it may be used
1543 only in the presence of a prototype.
1545 <tag/Availability/cc65
1547 <ref id="atmos_explode" name="atmos_explode">,
1548 <ref id="atmos_ping" name="atmos_ping">,
1549 <ref id="atmos_shoot" name="atmos_shoot">,
1550 <ref id="atmos_tick" name="atmos_tick">,
1551 <ref id="atmos_zap" name="atmos_zap">
1557 <sect1>atmos_zap<label id="atmos_zap"><p>
1561 <tag/Function/Raygun sound effect.
1562 <tag/Header/<tt/<ref id="atmos.h" name="atmos.h">/
1563 <tag/Declaration/<tt/void __fastcall__ atmos_zap(void);/
1564 <tag/Description/<tt/atmos_zap/ plays the BASIC sound.
1565 <tag/Notes/<itemize>
1566 <item>The function is available only as a fastcall function; so, it may be used
1567 only in the presence of a prototype.
1569 <tag/Availability/cc65
1571 <ref id="atmos_explode" name="atmos_explode">,
1572 <ref id="atmos_ping" name="atmos_ping">,
1573 <ref id="atmos_shoot" name="atmos_shoot">,
1574 <ref id="atmos_tick" name="atmos_tick">,
1575 <ref id="atmos_tock" name="atmos_tock">
1581 <sect1>atoi<label id="atoi"><p>
1585 <tag/Function/Convert a string to an integer.
1586 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1587 <tag/Declaration/<tt/int __fastcall__ atoi (const char* s);/
1588 <tag/Description/<tt/atoi/ converts the given string into an integer.
1589 Conversion stops as soon as any invalid character is encountered.
1590 <tag/Notes/<itemize>
1591 <item>There is no way to detect any conversion errors.
1592 <item>The function does not check for an numerical overflow when converting.
1593 <item>The function is only available as fastcall function, so it may only be
1594 used in presence of a prototype.
1596 <tag/Availability/ISO 9899
1598 <ref id="atol" name="atol">,
1599 <ref id="itoa" name="itoa">,
1600 <ref id="ltoa" name="ltoa">,
1601 <ref id="ultoa" name="ultoa">,
1602 <ref id="utoa" name="utoa">
1608 <sect1>atol<label id="atol"><p>
1612 <tag/Function/Convert a string to a long integer.
1613 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1614 <tag/Declaration/<tt/long __fastcall__ atol (const char* s);/
1615 <tag/Description/<tt/atol/ converts the given string into a long integer.
1616 Conversion stops as soon as any invalid character is encountered.
1617 <tag/Notes/<itemize>
1618 <item>There is no way to detect any conversion errors.
1619 <item>The function does not check for an numerical overflow when converting.
1620 <item>The function is only available as fastcall function, so it may only be
1621 used in presence of a prototype.
1623 <tag/Availability/ISO 9899
1625 <ref id="atoi" name="atoi">,
1626 <ref id="itoa" name="itoa">,
1627 <ref id="ltoa" name="ltoa">,
1628 <ref id="ultoa" name="ultoa">,
1629 <ref id="utoa" name="utoa">
1635 <sect1>bgcolor<label id="bgcolor"><p>
1639 <tag/Function/Set the background text color.
1640 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1641 <tag/Declaration/<tt/unsigned char __fastcall__ bgcolor (unsigned char color);/
1642 <tag/Description/The function will set a new background color and return the
1643 old (current) one. The background color is valid for the whole text output
1644 area of the screen, not just for new text.
1645 <tag/Notes/<itemize>
1646 <item>Background colors are system dependent. The function may have no effect
1647 on systems where the background color cannot be changed.
1648 <item>The function is only available as fastcall function, so it may only be
1649 used in presence of a prototype.
1651 <tag/Availability/cc65
1653 <ref id="bordercolor" name="bordercolor">,
1654 <ref id="textcolor" name="textcolor">
1660 <sect1>bordercolor<label id="bordercolor"><p>
1664 <tag/Function/Set the border (frame) color.
1665 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1666 <tag/Declaration/<tt/unsigned char __fastcall__ bordercolor (unsigned char color);/
1667 <tag/Description/The function will set a new border color. It returns the old
1668 (current) border color.
1669 <tag/Notes/<itemize>
1670 <item>Border colors are system dependent. The function may have no effect
1671 on systems where the border color cannot be changed.
1672 <item>The function is only available as fastcall function, so it may only
1673 be used in presence of a prototype.
1675 <tag/Availability/cc65
1677 <ref id="bgcolor" name="bgcolor">,
1678 <ref id="textcolor" name="textcolor">
1684 <sect1>bsearch<label id="bsearch"><p>
1688 <tag/Function/Do a binary search in a sorted array.
1689 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1690 <tag/Declaration/<tt/void* __fastcall__ bsearch (const void* key,
1691 const void* base, size_t n, size_t size,
1692 int __fastcall__ (* cmp) (const void*, const void*));/
1693 <tag/Description/<tt/bsearch/ searches a sorted array for a member that
1694 matches the one pointed to by <tt/key/. <tt/base/ is the address of the array,
1695 <tt/n/ is the number of elements, <tt/size/ the size of an element and <tt/cmp/
1696 the function used to compare the members against the key. The function returns
1697 a pointer to the member found, or <tt/NULL/ if there was no match.
1698 <tag/Notes/<itemize>
1699 <item>The contents of the array must be sorted in ascending order according to
1700 the compare function given.
1701 <item>If there are multiple members that match the key, the function will
1702 return one of the members.
1703 <item>The function is only available as fastcall function, so it may only
1704 be used in presence of a prototype.
1705 <item>The function to which <tt/cmp/ points must have the <tt/fastcall/ calling
1708 <tag/Availability/ISO 9899
1710 <ref id="qsort" name="qsort">
1716 <sect1>bzero<label id="bzero"><p>
1720 <tag/Function/Fill a memory area with zeroes.
1721 <tag/Header/<tt/<ref id="string.h" name="string.h">/
1722 <tag/Declaration/<tt/void __fastcall__ bzero (void* p, size_t count);/
1723 <tag/Description/<tt/bzero/ fills the memory area pointed to by <tt/p/ with
1725 <tag/Notes/<itemize>
1726 <item>The function is non standard and therefore only available in non ANSI
1727 mode. You should use <tt/<ref id="memset" name="memset">/ instead.
1728 <item>The function is only available as fastcall function, so it may only
1729 be used in presence of a prototype.
1731 <tag/Availability/cc65
1733 <ref id="_swap" name="_swap">,
1734 <ref id="memcpy" name="memcpy">,
1735 <ref id="memmove" name="memmove">,
1736 <ref id="memset" name="memset">,
1742 <sect1>c64mode<label id="c64mode"><p>
1746 <tag/Function/Switch the C128 into C64 compatible mode.
1747 <tag/Header/<tt/<ref id="c128.h" name="c128.h">/
1748 <tag/Declaration/<tt/void c64mode (void);/
1749 <tag/Description/The function will cause the machine to reboot into C64 mode.
1750 <tag/Notes/<itemize>
1751 <item>The function is specific to the C128.
1752 <item>The function will not return to the caller.
1754 <tag/Availability/C128
1760 <sect1>calloc<label id="calloc"><p>
1764 <tag/Function/Allocate and clear memory.
1765 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1766 <tag/Declaration/<tt/void* __fastcall__ calloc (size_t n, size_t size);/
1767 <tag/Description/<tt/calloc/ allocates memory for an array of <tt/n/ elements
1768 of size <tt/size/, clears the whole block with binary zeroes and returns a
1769 pointer to it. On error (not enough memory available), <tt/calloc/ returns
1771 <tag/Notes/<itemize>
1772 <item>Clearing the memory may not have the expected effect on all platforms:
1773 pointers in the block may not be <tt/NULL/ and floating point variables may
1774 not be zero (0.0). In other words: The "clearing" effect of this function
1775 should be used with care for portable programs.
1776 <item>The function is only available as fastcall function, so it may only
1777 be used in presence of a prototype.
1779 <tag/Availability/ISO 9899
1781 <ref id="_heapadd" name="_heapadd">,
1782 <ref id="_heapblocksize" name="_heapblocksize">,
1783 <ref id="_heapmaxavail" name="_heapmaxavail">,
1784 <ref id="_heapmemavail" name="_heapmemavail">,
1785 <ref id="free" name="free">,
1786 <ref id="malloc" name="malloc">,
1787 <ref id="realloc" name="realloc">
1793 <sect1>cbm_k_acptr<label id="cbm_k_acptr"><p>
1797 <tag/Function/Input byte from serial bus
1798 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
1799 <tag/Declaration/<tt/unsigned char cbm_k_acptr (void);/
1800 <tag/Description/The function returns a byte of data, which it
1801 gets from the current TALKer on the serial bus.
1802 In order to receive the data, the device must have previously been
1803 sent a command to TALK and a secondary address if it needs one.
1804 <tag/Notes/<itemize>
1807 <tag/Availability/cc65
1809 <ref id="cbm_k_talk" name="cbm_k_talk">,
1815 <sect1>cbm_k_basin<label id="cbm_k_basin"><p>
1819 <tag/Function/Input a Character from the Current Device
1820 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
1821 <tag/Declaration/<tt/unsigned char cbm_k_basin (void);/
1822 <tag/Description/The function returns a character from the current input device.
1823 Device must first have been OPENed and then designated as the input channel by the CHKIN routine.
1824 When this function is called, the next byte of data available from the device is returned.
1825 Exception is the routine for the keyboard device (which is the default input device).
1826 <tag/Notes/<itemize>
1829 <tag/Availability/cc65
1831 <ref id="cbm_k_open" name="cbm_k_open">,
1832 <ref id="cbm_k_chkin" name="cbm_k_chkin">
1838 <sect1>cbm_k_bsout<label id="cbm_k_bsout"><p>
1842 <tag/Function/Output a byte
1843 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
1844 <tag/Declaration/<tt/void __fastcall__ cbm_k_bsout (unsigned char C);/
1845 <tag/Description/Function sends the character to the current output device.
1846 Unless a device has been OPENed and designated as the
1847 current output channel using the CHKOUT routine, the character is
1848 printed to the screen, which is the default output device. If the
1849 cassette is the current device, outputting a byte will only add it to
1850 the buffer. No actual transmission of data will occur until the
1851 192-byte buffer is full.
1852 <tag/Notes/<itemize>
1853 <item>The function is only available as fastcall function, so it may
1854 only be used in presence of a prototype.
1856 <tag/Availability/cc65
1858 <ref id="cbm_k_open" name="cbm_k_open">,
1859 <ref id="cbm_k_chkin" name="cbm_k_chkout">
1865 <sect1>cbm_k_chkin<label id="cbm_k_chkin"><p>
1869 <tag/Function/Designate a Logical File As the Current Input Channel
1870 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
1871 <tag/Declaration/<tt/unsigned char __fastcall__ cbm_k_chkin (unsigned char FN);/
1872 <tag/Description/If you wish to
1873 get data from any device other than the keyboard, this function must be
1874 called after OPENing the device, before you can get a data byte with
1875 the cbm_k_basin or cbm_k_getin routine. When called, the routine will designate
1876 the logical file whose file number was supplied as the
1877 current file, its device as the current device, and its secondary
1878 address as the current secondary address. If the device on the
1879 channel is a serial device, which requires a TALK command and
1880 sometimes a secondary address, function will send them over the
1882 <tag/Notes/<itemize>
1883 <item>The function is only available as fastcall function, so it may
1884 only be used in presence of a prototype.
1886 <tag/Availability/cc65
1888 <ref id="cbm_k_open" name="cbm_k_open">,
1889 <ref id="cbm_k_basin" name="cbm_k_basin">,
1890 <ref id="cbm_k_getin" name="cbm_k_getin">
1896 <sect1>cbm_k_ciout<label id="cbm_k_ciout"><p>
1900 <tag/Function/Transmit a byte over the serial bus
1901 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
1902 <tag/Declaration/<tt/void __fastcall__ cbm_k_ciout (unsigned char C);/
1903 <tag/Description/Purpose of this function is to send a byte of data over
1904 the serial bus. In order for the data to be received, the serial
1905 device must have first been commanded to LISTEN and been given a
1906 secondary address if necessary. This routine always buffers the
1907 current character, and defers sending it until the next byte is
1908 buffered. When the UNLISTEN command is sent, the last byte will be
1909 sent with an End or Identify (EOI).
1910 <tag/Notes/<itemize>
1911 <item>The function is only available as fastcall function, so it may
1912 only be used in presence of a prototype.
1914 <tag/Availability/cc65
1916 <ref id="cbm_k_listen" name="cbm_k_listen">,
1917 <ref id="cbm_k_unlsn" name="cbm_k_unlsn">
1923 <sect1>cbm_k_ckout<label id="cbm_k_ckout"><p>
1927 <tag/Function/Designate a Logical File As the Current Output Channel
1928 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
1929 <tag/Declaration/<tt/unsigned char __fastcall__ cbm_k_ckout (unsigned char FN);/
1930 <tag/Description/If you wish to
1931 output data to any device other than the screen, this routine must be
1932 called after OPENing the device, and before you output a data byte
1933 with the cbm_k_bsout() function. When called, the function will designate the
1934 logical file whose file number was supplied as the current
1935 file, its device as the current device, and its secondary address as
1936 the current secondary address. If the device on the channel uses the
1937 serial bus, and therefore requires a LISTEN command and possibly a
1938 secondary address, this information will be sent on the bus.
1939 <tag/Notes/<itemize>
1940 <item>The function is only available as fastcall function, so it may
1941 only be used in presence of a prototype.
1943 <tag/Availability/cc65
1945 <ref id="cbm_k_bsout" name="cbm_k_bsout">,
1946 <ref id="cbm_k_listen" name="cbm_k_listen">
1952 <sect1>cbm_k_clall<label id="cbm_k_clall"><p>
1956 <tag/Function/Close All Logical I/O Files
1957 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
1958 <tag/Declaration/<tt/void cbm_k_clall (void);/
1959 <tag/Description/It closes all
1960 open files, by resetting the index into open files to
1961 zero and restores the default I/O devices.
1962 <tag/Notes/<itemize>
1965 <tag/Availability/cc65
1967 <ref id="cbm_k_open" name="cbm_k_open">,
1968 <ref id="cbm_k_close" name="cbm_k_close">
1974 <sect1>cbm_k_close<label id="cbm_k_close"><p>
1978 <tag/Function/Close a Logical I/O File
1979 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
1980 <tag/Declaration/<tt/void __fastcall__ cbm_k_close (unsigned char FN);/
1981 <tag/Description/It is used to
1982 close a logical file after all I/O operations involving that file have
1984 <tag/Notes/<itemize>
1985 <item>The function is only available as fastcall function, so it may
1986 only be used in presence of a prototype.
1988 <tag/Availability/cc65
1990 <ref id="cbm_k_open" name="cbm_k_open">,
1991 <ref id="cbm_k_clall" name="cbm_k_clall">
1997 <sect1>cbm_k_clrch<label id="cbm_k_clrch"><p>
2001 <tag/Function/Restore Current Input and Output Devices to the Default Devices
2002 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
2003 <tag/Declaration/<tt/void cbm_k_clrch (void);/
2004 <tag/Description/It sets the
2005 current input device to the keyboard, and the current output device to
2006 the screen. Also, if the current input device was formerly a serial
2007 device, the routine sends it an UNTALK command on the serial bus, and
2008 if a serial device was formerly the current output device, the routine
2009 sends it an UNLISTEN command.
2010 <tag/Notes/<itemize>
2013 <tag/Availability/cc65
2015 <ref id="cbm_k_chkin" name="cbm_k_chkin">,
2016 <ref id="cbm_k_ckout" name="cbm_k_ckout">
2022 <sect1>cbm_k_getin<label id="cbm_k_getin"><p>
2026 <tag/Function/Get One Byte from the Input Device
2027 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
2028 <tag/Declaration/<tt/unsigned char cbm_k_getin (void);/
2029 <tag/Description/Function gets a character from the current input device.
2030 <tag/Notes/<itemize>
2033 <tag/Availability/cc65
2035 <ref id="cbm_k_basin" name="cbm_k_basin">
2041 <sect1>cbm_k_iobase<label id="cbm_k_iobase"><p>
2045 <tag/Function/Return Base Address of Memory-Mapped I/O Devices
2046 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
2047 <tag/Declaration/<tt/unsigned cbm_k_iobase (void);/
2048 <tag/Description/This function returns the address of
2049 the memory section where the memory mapped I/O devices are located. This
2050 address can then be used with an offset to access the memory mapped I/O
2051 devices in the Commodore 64. The offset is the number of locations from
2052 the beginning of the page on which the I/O register you want is located.
2053 This function exists to provide compatibility between the Commodore 64,
2054 VIC-20, and future models of the Commodore 64. If the I/O locations for
2055 a program are set by a call to this function, they should
2056 still remain compatible with future versions of the Commodore 64, the
2058 <tag/Notes/<itemize>
2061 <tag/Availability/cc65
2069 <sect1>cbm_k_listen<label id="cbm_k_listen"><p>
2073 <tag/Function/Command a device on the serial bus to LISTEN
2074 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
2075 <tag/Declaration/<tt/void __fastcall__ cbm_k_listen (unsigned char dev);/
2076 <tag/Description/This function will command a device on the serial bus to
2077 receive data. The KERNAL routine will OR the supplied device number bit by bit
2078 to convert it to a listen address, then transmits this data as a command on
2079 the serial bus. The specified device will then go into listen mode, and
2080 be ready to accept information.
2081 <tag/Notes/<itemize>
2082 <item>The function is only available as fastcall function, so it may
2083 only be used in presence of a prototype.
2085 <tag/Availability/cc65
2087 <ref id="cbm_k_unlsn" name="cbm_k_unlsn">,
2093 <sect1>cbm_k_load<label id="cbm_k_load"><p>
2097 <tag/Function/Load RAM from a Device
2098 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
2099 <tag/Declaration/<tt/unsigned int __fastcall__ cbm_k_load(unsigned char flag, unsigned addr);/
2100 <tag/Description/This function LOADs data bytes from any input device directly into the memory.
2101 It can also be used for a verify operation, comparing data from a device with the data already in
2102 memory, while leaving the data stored in RAM unchanged.
2103 The flag must be set to 0 for a LOAD operation, or 1 for a
2104 verify, If the input device is OPENed with a secondary address (SA) of 0
2105 the header information from the device is ignored. In this case, the starting address for the load must be supplied.
2106 If the device is addressed with a secondary address of 1, then the data is
2107 loaded into memory starting at the location specified by the header.
2108 Function returns the address of the highest RAM location loaded.
2109 Before this function can be called, the KERNAL SETLFS, and SETNAM
2110 routines must be called.
2111 <tag/Notes/<itemize>
2112 <item>The function is only available as fastcall function, so it may
2113 only be used in presence of a prototype.
2115 <tag/Availability/cc65
2117 <ref id="cbm_k_save" name="cbm_k_save">,
2118 <ref id="cbm_k_setlfs" name="cbm_k_setlfs">,
2119 <ref id="cbm_k_setnam" name="cbm_k_setnam">
2125 <sect1>cbm_k_open<label id="cbm_k_open"><p>
2129 <tag/Function/Open a Logical I/O File
2130 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
2131 <tag/Declaration/<tt/unsigned char cbm_k_open (void);/
2132 <tag/Description/This function assigns a logical file to a device, so that it can be used for
2133 Input/Output operations. In order to specify the logical file number,
2134 the device number, and the secondary address if any, the cbm_k_setlfs() function must first be called.
2135 Likewise, in order to designate the filename, the cbm_k_setnam() function must be used first. After these two
2136 functions are called, cbm_k_open() is then called.
2137 <tag/Notes/<itemize>
2140 <tag/Availability/cc65
2142 <ref id="cbm_k_close" name="cbm_k_close">,
2143 <ref id="cbm_k_setlfs" name="cbm_k_setlfs">,
2144 <ref id="cbm_k_setnam" name="cbm_k_setnam">
2150 <sect1>cbm_k_readst<label id="cbm_k_readst"><p>
2154 <tag/Function/Read status word
2155 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
2156 <tag/Declaration/<tt/unsigned char cbm_k_readst (void);/
2157 <tag/Description/This function returns the current status of the I/O devices. It is usually called after new communication to an I/O device and gives information about device status, or errors that have occurred during the I/O operation.
2158 <tag/Notes/<itemize>
2161 <tag/Availability/cc65
2169 <sect1>cbm_k_save<label id="cbm_k_save"><p>
2173 <tag/Function/Save RAM to a Device
2174 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
2175 <tag/Declaration/<tt/unsigned char __fastcall__ cbm_k_save(unsigned int start, unsigned int end)/
2176 <tag/Description/This function saves a section of memory. The cbm_k_setlfs() and cbm_k_setnam() functions must be
2177 used before calling this function. However, a file name is not required to
2178 SAVE to device 1 (the Datassette(TM) recorder). Any attempt to save to
2179 other devices without using a file name results in an error. NOTE: Device 0 (the keyboard), device 2 (RS-232), and device 3 (the screen) cannot be SAVEd to. If the attempt is made, an error occurs, and the SAVE is stopped.
2180 <tag/Notes/<itemize>
2181 <item>The function is only available as fastcall function, so it may
2182 only be used in presence of a prototype.
2184 <tag/Availability/cc65
2186 <ref id="cbm_k_load" name="cbm_k_load">,
2187 <ref id="cbm_k_setlfs" name="cbm_k_setlfs">,
2188 <ref id="cbm_k_setnam" name="cbm_k_setnam">
2194 <sect1>cbm_k_scnkey<label id="cbm_k_scnkey"><p>
2198 <tag/Function/Scan the keyboard matrix.
2199 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
2200 <tag/Declaration/<tt/void cbm_k_scnkey (void);/
2201 <tag/Description/This function looks at the switches in the keyboard, to see
2202 if any of them are being pressed. If they are, then code numbers for them are
2203 stored in RAM. Other functions use those numbers to input text. Normally,
2204 the keyboard is scanned by the Kernal's Interrupt Service Routine. But, if
2205 you divert the "Jiffy interrupt" to a C-code ISR, then that ISR must call this
2206 function, in order to provide input from the keyboard.
2207 <tag/Availability/cc65
2209 <ref id="cbm_k_getin" name="cbm_k_getin">,
2210 <ref id="cbm_k_udtim" name="cbm_k_udtim">,
2211 <ref id="cgetc" name="cgetc">,
2212 <!-- <ref id="getc" name="getc"> -->
2213 <!-- <ref id="getchar" name="getchar"> -->
2219 <sect1>cbm_k_setlfs<label id="cbm_k_setlfs"><p>
2223 <tag/Function/Set up a logical file
2224 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
2225 <tag/Declaration/<tt/void __fastcall__ cbm_k_setlfs (unsigned char LFN, unsigned char DEV, unsigned char SA);/
2226 <tag/Description/This functions sets up the logical file by setting its number, device address,
2227 and secondary address.
2228 <tag/Notes/<itemize>
2229 <item>The function is only available as fastcall function, so it may
2230 only be used in presence of a prototype.
2232 <tag/Availability/cc65
2234 <ref id="cbm_k_setnam" name="cbm_k_setnam">
2240 <sect1>cbm_k_setnam<label id="cbm_k_setnam"><p>
2244 <tag/Function/Set Filename Parameters
2245 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
2246 <tag/Declaration/<tt/void __fastcall__ cbm_k_setnam (const char* Name);/
2247 <tag/Description/This function is used to set up the file name for the OPEN,
2248 SAVE, or LOAD operations.
2249 <tag/Notes/<itemize>
2250 <item>The function is only available as fastcall function, so it may
2251 only be used in presence of a prototype.
2253 <tag/Availability/cc65
2255 <ref id="cbm_k_open" name="cbm_k_open">,
2256 <ref id="cbm_k_load" name="cbm_k_load">,
2257 <ref id="cbm_k_save" name="cbm_k_save">
2263 <sect1>cbm_k_talk<label id="cbm_k_talk"><p>
2267 <tag/Function/Commands device to TALK
2268 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
2269 <tag/Declaration/<tt/void __fastcall__ cbm_k_talk (unsigned char dev);/
2270 <tag/Description/When called, it ORs the device number with the TALK code (64, $40) and sends it on the serial
2271 bus. This commands the device to TALK.
2272 <tag/Notes/<itemize>
2273 <item>The function is only available as fastcall function, so it may
2274 only be used in presence of a prototype.
2276 <tag/Availability/cc65
2278 <ref id="cbm_k_acptr" name="cbm_k_acptr">
2284 <sect1>cbm_k_udtim<label id="cbm_k_udtim"><p>
2288 <tag/Function/Update the Jiffy clock.
2289 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
2290 <tag/Declaration/<tt/void cbm_k_udtim (void);/
2291 <tag/Description/This function adds one count to the Jiffy clock. That clock
2292 counts sixtieths of a second. It is used by the library's <tt/clock()/
2293 function. Normally, the Jiffy clock is updated by the Kernal's Interrupt
2294 Service Routine. But, if you divert the "Jiffy interrupt" to a C-code ISR,
2295 then that ISR must call this function, in order to keep the clock valid.
2296 <tag/Availability/cc65
2298 <ref id="cbm_k_scnkey" name="cbm_k_scnkey">,
2299 <ref id="clock" name="clock">
2305 <sect1>cbm_k_unlsn<label id="cbm_k_unlsn"><p>
2309 <tag/Function/Send an UNLISTEN command
2310 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
2311 <tag/Declaration/<tt/void cbm_k_unlsn (void);/
2312 <tag/Description/This function commands all devices on the serial bus to
2313 stop receiving data from the host computer (i.e., UNLISTEN). Calling this
2314 function results in an UNLISTEN command being transmitted on the serial
2315 bus. Only devices previously commanded to LISTEN are affected. This
2316 function is normally used after the host computer is finished sending data
2317 to external devices. Sending the UNLISTEN commands the listening devices
2318 to get off the serial bus so it can be used for other purposes.
2319 <tag/Notes/<itemize>
2322 <tag/Availability/cc65
2324 <ref id="cbm_k_listen" name="cbm_k_listen">
2330 <sect1>cclear<label id="cclear"><p>
2334 <tag/Function/Clear part of a line (write a given number of spaces).
2335 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2336 <tag/Declaration/<tt/void __fastcall__ cclear (unsigned char length);/
2337 <tag/Description/The function clears part of a line by writing <tt/length/
2338 spaces in the current text color.
2339 <tag/Notes/<itemize>
2340 <item>The function is only available as fastcall function, so it may
2341 only be used in presence of a prototype.
2343 <tag/Availability/cc65
2345 <ref id="cclearxy" name="cclearxy">,
2346 <ref id="clrscr" name="clrscr">
2352 <sect1>cclearxy<label id="cclearxy"><p>
2356 <tag/Function/Clear part of a line (write a given number of spaces) starting
2357 at a specific screen position.
2358 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2359 <tag/Declaration/<tt/void __fastcall__ cclearxy (unsigned char x, unsigned char y, unsigned char length);/
2360 <tag/Description/The function moves the cursor to a specific position, and
2361 will then clear part of the line by writing <tt/length/ spaces in the current
2363 <tag/Notes/<itemize>
2364 <item>The function is only available as fastcall function, so it may
2365 only be used in presence of a prototype.
2367 <tag/Availability/cc65
2369 <ref id="cclear" name="cclear">,
2370 <ref id="clrscr" name="clrscr">
2376 <sect1>cgetc<label id="cgetc"><p>
2380 <tag/Function/Read a character from the keyboard.
2381 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2382 <tag/Declaration/<tt/char cgetc (void);/
2383 <tag/Description/The function reads a character from the keyboard. If there is
2384 no character available, <tt/cgetc()/ waits until the user presses a key. If the
2385 cursor is enabled by use of the <tt/cursor/ function, a blinking cursor is
2386 displayed while waiting.
2387 <tag/Notes/<itemize>
2388 <item>If the system supports a keyboard buffer, <tt/cgetc()/ will fetch a key
2389 from that buffer; and, wait only if the buffer is empty.
2390 <item>The keyboard must be scanned periodically, in order for this function to
2391 see anything that you type. (See the description of <tt/cbm_k_scnkey()/.)
2393 <tag/Availability/cc65
2395 <ref id="cbm_k_scnkey" name="cbm_k_scnkey">,
2396 <ref id="cursor" name="cursor">,
2397 <ref id="kbhit" name="kbhit">
2403 <sect1>chline<label id="chline"><p>
2407 <tag/Function/Output a horizontal line in text mode.
2408 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2409 <tag/Declaration/<tt/void __fastcall__ chline (unsigned char length);/
2410 <tag/Description/The function outputs a horizontal line with the given length
2411 starting at the current cursor position.
2412 <tag/Notes/<itemize>
2413 <item>The character used to draw the horizontal line is system dependent.
2414 If available, a line drawing character is used. Drawing a line that is partially
2415 off screen leads to undefined behaviour.
2416 <item>The function is only available as fastcall function, so it may only be
2417 used in presence of a prototype.
2419 <tag/Availability/cc65
2421 <ref id="chlinexy" name="chlinexy">,
2422 <ref id="cvline" name="cvline">,
2423 <ref id="cvlinexy" name="cvlinexy">
2429 <sect1>chlinexy<label id="chlinexy"><p>
2433 <tag/Function/Output a horizontal line at a given position in text mode.
2434 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2435 <tag/Declaration/<tt/void __fastcall__ chlinexy (unsigned char x, unsigned char y, unsigned char length);/
2436 <tag/Description/The function outputs a horizontal line with the given length
2437 starting at a given position.
2438 <tag/Notes/<itemize>
2439 <item>The character used to draw the horizontal line is system dependent.
2440 If available, a line drawing character is used. Drawing a line that is partially
2441 off screen leads to undefined behaviour.
2442 <item>The function is only available as fastcall function, so it may only be
2443 used in presence of a prototype.
2445 <tag/Availability/cc65
2447 <ref id="chline" name="chline">,
2448 <ref id="cvline" name="cvline">,
2449 <ref id="cvlinexy" name="cvlinexy">
2455 <sect1>clearerr<label id="clearerr"><p>
2459 <tag/Function/Clear error and end-of-file status of a stream.
2460 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
2461 <tag/Declaration/<tt/void __fastcall__ clearerr (FILE* f);/
2462 <tag/Description/<tt/clearerr/ clears the error and end-of-file status
2463 indicators for the stream <tt/f/.
2464 <tag/Notes/<itemize>
2465 <item>The function is only available as fastcall function, so it may only be
2466 used in presence of a prototype.
2468 <tag/Availability/ISO 9899
2470 <ref id="feof" name="feof">,
2471 <ref id="ferror" name="ferror">
2477 <sect1>clock<label id="clock"><p>
2481 <tag/Function/Determine the processor time used.
2482 <tag/Header/<tt/<ref id="time.h" name="time.h">/
2483 <tag/Declaration/<tt/clock_t clock (void);/
2484 <tag/Description/The <tt/clock/ function returns an approximaton of processor
2485 time used by the program. The time is returned in implementation-defined
2486 units. It can be converted to seconds by dividing by the value of the macro
2487 <tt/CLOCKS_PER_SEC/.
2488 <tag/Notes/<itemize>
2489 <item>Since the machines that cc65-generated programs run on cannot run multiple
2490 processes, the function actually will return the time since some
2491 implementation-defined point in the past.
2492 <item>The Jiffy clock must be "running", in order for this function to return
2493 changing values. (See the description of <tt/cbm_k_udtim()/.)
2495 <tag/Availability/ISO 9899
2497 <ref id="cbm_k_udtim" name="cbm_k_udtim">,
2498 <ref id="time" name="time">
2504 <sect1>clrscr<label id="clrscr"><p>
2508 <tag/Function/Clear the text screen.
2509 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2510 <tag/Declaration/<tt/void clrscr (void);/
2511 <tag/Description/The function clears the text screen and moves the cursor to
2512 the upper left corner.
2513 <tag/Availability/cc65
2515 <ref id="cclear" name="cclear">,
2516 <ref id="cclearxy" name="cclearxy">
2522 <sect1>close<label id="close"><p>
2526 <tag/Function/Close a file descriptor.
2527 <tag/Header/<tt/<ref id="fcntl.h" name="fcntl.h">/
2528 <tag/Declaration/<tt/int __fastcall__ close (int fd);/
2529 <tag/Description/The function closes the given file descriptor. It returns zero
2530 on success and -1 on error. If an error occurs, the cause can be determined by
2531 reading the <tt/errno/ variable.
2532 <tag/Notes/<itemize>
2533 <item>The function is only available as fastcall function, so it may only
2534 be used in presence of a prototype.
2536 <tag/Availability/POSIX 1003.1
2538 <ref id="creat" name="creat">,
2539 <ref id="open" name="open">
2545 <sect1>closedir<label id="closedir"><p>
2549 <tag/Function/Close a directory.
2550 <tag/Header/<tt/<ref id="dirent.h" name="dirent.h">/
2551 <tag/Declaration/<tt/int __fastcall__ closedir (DIR* dir);/
2552 <tag/Description/The function closes the given directory descriptor. It returns
2553 zero on success and -1 on error. If an error occurs, the cause can be determined
2554 by reading the <tt/errno/ variable.
2555 <tag/Notes/<itemize>
2556 <item>The function is only available as fastcall function, so it may only
2557 be used in presence of a prototype.
2559 <tag/Availability/POSIX 1003.1
2561 <ref id="opendir" name="opendir">,
2562 <ref id="readdir" name="readdir">
2568 <sect1>cpeekc<label id="cpeekc"><p>
2572 <tag/Function/Get a character from the display memory.
2573 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2574 <tag/Declaration/<tt/char cpeekc (void);/
2575 <tag/Description/The function gets the character that's at the current location
2576 of the cursor in the display screen RAM. That character is converted, if
2577 needed, into the encoding that can be passed to <tt/cputc()/.
2578 <tag/Notes/<itemize>
2579 <item>Conio peek functions don't have <tt/cpeek...xy()/ versions. That was
2580 done to make it obvious that peeking doesn't move the cursor in any way. Your
2581 program must place the cursor where it wants to peek before it calls any of
2584 <tag/Availability/cc65
2586 <ref id="cpeekcolor" name="cpeekcolor">,
2587 <ref id="cpeekrevers" name="cpeekrevers">,
2588 <ref id="cpeeks" name="cpeeks">,
2589 <ref id="cputc" name="cputc">
2595 <sect1>cpeekcolor<label id="cpeekcolor"><p>
2599 <tag/Function/Get a color from the display memory.
2600 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2601 <tag/Declaration/<tt/unsigned char cpeekcolor (void);/
2602 <tag/Description/The function gets the color number that's at the current
2603 location of the cursor in the display screen RAM. That number can be passed to
2605 <tag/Notes/<itemize>
2606 <item>Conio peek functions don't have <tt/cpeek...xy()/ versions. That was
2607 done to make it obvious that peeking doesn't move the cursor in any way. Your
2608 program must place the cursor where it wants to peek before it calls any of
2611 <tag/Availability/cc65
2613 <ref id="cpeekc" name="cpeekc">,
2614 <ref id="cpeekrevers" name="cpeekrevers">,
2615 <ref id="cpeeks" name="cpeeks">,
2616 <ref id="cputc" name="cputc">,
2617 <ref id="textcolor" name="textcolor">
2623 <sect1>cpeekrevers<label id="cpeekrevers"><p>
2627 <tag/Function/Get a reverse-character attribute from the display memory.
2628 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2629 <tag/Declaration/<tt/unsigned char cpeekrevers (void);/
2630 <tag/Description/The function gets the "reverse-mode" attribute of the
2631 character that's at the current location of the cursor in the display screen
2632 RAM. It returns a boolean value (0/1) that can be passed to <tt/revers()/.
2633 <tag/Notes/<itemize>
2634 <item>Conio peek functions don't have <tt/cpeek...xy()/ versions. That was
2635 done to make it obvious that peeking doesn't move the cursor in any way. Your
2636 program must place the cursor where it wants to peek before it calls any of
2639 <tag/Availability/cc65
2641 <ref id="cpeekc" name="cpeekc">,
2642 <ref id="cpeekcolor" name="cpeekcolor">,
2643 <ref id="cpeeks" name="cpeeks">,
2644 <ref id="cputc" name="cputc">,
2645 <ref id="revers" name="revers">
2651 <sect1>cpeeks<label id="cpeeks"><p>
2655 <tag/Function/Get a string from the display memory.
2656 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2657 <tag/Declaration/<tt/void __fastcall__ cpeeks (char* s, unsigned length);/
2658 <tag/Description/The function gets a fixed-length string ('\0'-terminated) of
2659 characters that start at the current location of the cursor in the display
2660 screen RAM. Those characters are converted, if needed, into the encoding that
2661 can be passed to <tt/cputs()/. The first argument must point to a RAM area
2662 that's large enough to hold "length + 1" bytes.
2663 <tag/Notes/<itemize>
2664 <item>Conio peek functions don't have <tt/cpeek...xy()/ versions. That was
2665 done to make it obvious that peeking doesn't move the cursor in any way. Your
2666 program must place the cursor where it wants to peek before it calls any of
2668 <item>The function is available as only a fastcall function;
2669 so, it may be used only in the presence of a prototype.
2671 <tag/Availability/cc65
2673 <ref id="cpeekc" name="cpeekc">,
2674 <ref id="cpeekcolor" name="cpeekcolor">,
2675 <ref id="cpeekrevers" name="cpeekrevers">,
2676 <ref id="cputc" name="cputc">,
2677 <ref id="cputs" name="cputs">
2683 <sect1>creat<label id="creat"><p>
2687 <tag/Function/Create a file.
2688 <tag/Header/<tt/<ref id="fcntl.h" name="fcntl.h">/
2689 <tag/Declaration/<tt/int __fastcall__ creat (const char* name, unsigned mode);/
2690 <tag/Description/<tt/creat/ creates a new file and returns the file descriptor
2691 associated with it. On error, -1 is returned and an error code is stored in
2693 <tag/Notes/<itemize>
2694 <item><tt/creat/ is identical to calling <tt/<ref id="open" name="open">/ with
2695 <tt/flags/ equal to <tt/O_WRONLY | O_CREAT | O_TRUNC/.
2696 <item>The function is only available as fastcall function, so it may only
2697 be used in presence of a prototype.
2699 <tag/Availability/POSIX 1003.1
2701 <ref id="close" name="close">,
2702 <ref id="open" name="open">
2708 <sect1>cprintf<label id="cprintf"><p>
2712 <tag/Function/Formatted output to the console.
2713 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2714 <tag/Declaration/<tt/int cprintf (const char* format, ...);/
2715 <tag/Description/The arguments are converted to text where necessary and
2716 formatted according to the format string given. The resulting string is output
2717 to the console. <tt/cprintf/ supports the same format specifiers as
2718 <tt/printf/. <!-- <tt/<ref id="printf" name="printf">/. -->
2719 <tag/Notes/<itemize>
2720 <item>Like all other <tt/conio/ output functions, <tt/cprintf/ distinguishes
2721 between <tt/\r/ and <tt/\n/.
2723 <tag/Availability/cc65
2725 <ref id="cputc" name="cputc">,
2726 <ref id="cputcxy" name="cputcxy">,
2727 <ref id="cputs" name="cputs">,
2728 <ref id="cputsxy" name="cputsxy">,
2729 <ref id="vcprintf" name="vcprintf">
2735 <sect1>cputc<label id="cputc"><p>
2739 <tag/Function/Output a character directly to the console.
2740 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2741 <tag/Declaration/<tt/void __fastcall__ cputc (char c);/
2742 <tag/Description/Output one character to the console at the current cursor
2744 <tag/Notes/<itemize>
2745 <item>Like all other <tt/conio/ output functions, <tt/cputc/ distinguishes
2746 between <tt/\r/ and <tt/\n/.
2747 <item>The function is only available as fastcall function, so it may only
2748 be used in presence of a prototype.
2750 <tag/Availability/cc65
2752 <ref id="cprintf" name="cprintf">,
2753 <ref id="cputcxy" name="cputcxy">,
2754 <ref id="cputs" name="cputs">,
2755 <ref id="cputsxy" name="cputsxy">,
2756 <ref id="vcprintf" name="vcprintf">
2762 <sect1>cputcxy<label id="cputcxy"><p>
2766 <tag/Function/Output a character at a specific screen position.
2767 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2768 <tag/Declaration/<tt/void __fastcall__ cputcxy (unsigned char x, unsigned char y, char c);/
2769 <tag/Description/<tt/cputcxy/ moves the cursor to the given x/y position on
2770 the screen and outputs one character.
2771 <tag/Notes/<itemize>
2772 <item>Like all other <tt/conio/ output functions, <tt/cputcxy/ distinguishes
2773 between <tt/\r/ and <tt/\n/.
2774 <item>The function is only available as fastcall function, so it may only
2775 be used in presence of a prototype.
2777 <tag/Availability/cc65
2779 <ref id="cprintf" name="cprintf">,
2780 <ref id="cputc" name="cputc">,
2781 <ref id="cputs" name="cputs">,
2782 <ref id="cputsxy" name="cputsxy">,
2783 <ref id="vcprintf" name="vcprintf">
2789 <sect1>cputs<label id="cputs"><p>
2793 <tag/Function/Output a string directly to the console.
2794 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2795 <tag/Declaration/<tt/void __fastcall__ cputs (const char* s);/
2796 <tag/Description/The function outputs the given string on the console at the
2797 current cursor position.
2798 <tag/Notes/<itemize>
2799 <item>Like all other <tt/conio/ output functions, <tt/cputs/ distinguishes
2800 between <tt/\r/ and <tt/\n/.
2801 <item>The function is only available as fastcall function, so it may only
2802 be used in presence of a prototype.
2804 <tag/Availability/cc65
2806 <ref id="cprintf" name="cprintf">,
2807 <ref id="cputc" name="cputc">,
2808 <ref id="cputcxy" name="cputcxy">,
2809 <ref id="cputsxy" name="cputsxy">,
2810 <ref id="vcprintf" name="vcprintf">
2816 <sect1>cputsxy<label id="cputsxy"><p>
2820 <tag/Function/Output a string to the console at a given position.
2821 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2822 <tag/Declaration/<tt/void __fastcall__ cputsxy (unsigned char x, unsigned char y, const char* s);/
2823 <tag/Description/<tt/cputsxy/ moves the cursor to the given x/y position,
2824 and outputs the string <tt/s/.
2825 <tag/Notes/<itemize>
2826 <item>Like all other <tt/conio/ output functions, <tt/cputsxy/ distinguishes
2827 between <tt/\r/ and <tt/\n/.
2828 <item>The function is only available as fastcall function, so it may only
2829 be used in presence of a prototype.
2831 <tag/Availability/cc65
2833 <ref id="cprintf" name="cprintf">,
2834 <ref id="cputc" name="cputc">,
2835 <ref id="cputcxy" name="cputcxy">,
2836 <ref id="cputs" name="cputs">,
2837 <ref id="vcprintf" name="vcprintf">
2843 <sect1>cursor<label id="cursor"><p>
2847 <tag/Function/Enable/disable a blinking cursor when waiting for keyboard input.
2848 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2849 <tag/Declaration/<tt/unsigned char __fastcall__ cursor (unsigned char onoff);/
2850 <tag/Description/If the argument to the function is non zero, a blinking cursor
2851 will be enabled when the <tt/cgetc/ function waits for input from the keyboard.
2852 If the argument is zero, <tt/cgetc/ will wait without a blinking cursor.
2853 <tag/Notes/<itemize>
2854 <item>The function is only available as fastcall function, so it may only
2855 be used in presence of a prototype.
2857 <tag/Availability/cc65
2859 <ref id="cgetc" name="cgetc">,
2860 <ref id="kbhit" name="kbhit">
2866 <sect1>cvline<label id="cvline"><p>
2870 <tag/Function/Output a vertical line in text mode.
2871 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2872 <tag/Declaration/<tt/void __fastcall__ cvline (unsigned char length);/
2873 <tag/Description/The function outputs a vertical line with the given length
2874 starting at the current cursor position.
2875 <tag/Notes/<itemize>
2876 <item>The character used to draw the vertical line is system dependent.
2877 If available, a line drawing character is used. Drawing a line that is partially
2878 off screen leads to undefined behaviour.
2879 <item>The function is only available as fastcall function, so it may only be
2880 used in presence of a prototype.
2882 <tag/Availability/cc65
2884 <ref id="chline" name="chline">,
2885 <ref id="chlinexy" name="chlinexy">,
2886 <ref id="cvlinexy" name="cvlinexy">
2892 <sect1>cvlinexy<label id="cvlinexy"><p>
2896 <tag/Function/Output a vertical line at a given position in text mode.
2897 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2898 <tag/Declaration/<tt/void __fastcall__ cvlinexy (unsigned char x, unsigned char y, unsigned char length);/
2899 <tag/Description/The function outputs a vertical line with the given length
2900 starting at a given position.
2901 <tag/Notes/<itemize>
2902 <item>The character used to draw the vertical line is system dependent.
2903 If available, a line drawing character is used. Drawing a line that is partially
2904 off screen leads to undefined behaviour.
2905 <item>The function is only available as fastcall function, so it may only be
2906 used in presence of a prototype.
2908 <tag/Availability/cc65
2910 <ref id="chline" name="chline">,
2911 <ref id="chlinexy" name="chlinexy">,
2912 <ref id="cvline" name="cvline">
2918 <sect1>decompress_lz4<label id="decompress_lz4"><p>
2922 <tag/Function/Uncompress a LZ4-compressed buffer.
2923 <tag/Header/<tt/<ref id="lz4.h" name="lz4.h">/
2924 <tag/Declaration/<tt/void decompress_lz4 (const unsigned char* src, unsigned char* const dst, const unsigned short uncompressed_size);/
2925 <tag/Description/<tt/decompress_lz4/ uncompresses a LZ4-compressed buffer.
2926 <tag/Notes/<itemize>
2927 <item>Use LZ4_compress_HC with compression level 16 for best compression.
2929 <tag/Availability/cc65
2935 <sect1>detect_c128<label id="detect_c128"><p>
2939 <tag/Function/Check if a C128 CPU is the current CPU.
2940 <tag/Header/<tt/<ref id="accelerator.h" name="accelerator.h">/
2941 <tag/Declaration/<tt/unsigned char detect_c128 (void);/
2942 <tag/Description/The function returns a 1 if a C128 CPU is the current CPU.
2943 <tag/Notes/<itemize>
2944 <item>The function is specific to the C64 and C128.
2946 <tag/Availability/cc65 (not all platforms)
2948 <ref id="get_c128_speed" name="get_c128_speed">,
2949 <ref id="set_c128_speed" name="set_c128_speed">,
2955 <sect1>detect_c64dtv<label id="detect_c64dtv"><p>
2959 <tag/Function/Check for the presence of the C64DTV.
2960 <tag/Header/<tt/<ref id="accelerator.h" name="accelerator.h">/
2961 <tag/Declaration/<tt/unsigned char detect_c64dtv (void);/
2962 <tag/Description/The function returns a 1 if a C64DTV has been detected.
2963 <tag/Notes/<itemize>
2964 <item>The function is specific to the C64.
2966 <tag/Availability/cc65 (not all platforms)
2968 <ref id="get_c64dtv_speed" name="get_c64dtv_speed">,
2969 <ref id="set_c64dtv_speed" name="set_c64dtv_speed">,
2975 <sect1>detect_c65<label id="detect_c65"><p>
2979 <tag/Function/Check for the presence of a C65/C64DX in C64 mode.
2980 <tag/Header/<tt/<ref id="accelerator.h" name="accelerator.h">/
2981 <tag/Declaration/<tt/unsigned char detect_c65 (void);/
2982 <tag/Description/The function returns a 1 if a C65/C64DX in C64 mode has been detected.
2983 <tag/Notes/<itemize>
2984 <item>The function is specific to the C64.
2986 <tag/Availability/cc65 (not all platforms)
2988 <ref id="get_c65_speed" name="get_c65_speed">,
2989 <ref id="set_c65_speed" name="set_c65_speed">,
2995 <sect1>detect_chameleon<label id="detect_chameleon"><p>
2999 <tag/Function/Check for the presence of the C64 Chameleon cartridge.
3000 <tag/Header/<tt/<ref id="accelerator.h" name="accelerator.h">/
3001 <tag/Declaration/<tt/unsigned char detect_chameleon (void);/
3002 <tag/Description/The function returns a 1 if a C64 Chameleon cartridge has been detected.
3003 <tag/Notes/<itemize>
3004 <item>The function is specific to the C64.
3006 <tag/Availability/cc65 (not all platforms)
3008 <ref id="get_chameleon_speed" name="get_chameleon_speed">,
3009 <ref id="set_chameleon_speed" name="set_chameleon_speed">,
3015 <sect1>detect_scpu<label id="detect_scpu"><p>
3019 <tag/Function/Check for the presence of the C64/C128 SuperCPU cartridge.
3020 <tag/Header/<tt/<ref id="accelerator.h" name="accelerator.h">/
3021 <tag/Declaration/<tt/unsigned char detect_scpu (void);/
3022 <tag/Description/The function returns a 1 if a SuperCPU cartridge has been detected.
3023 <tag/Notes/<itemize>
3024 <item>The function is specific to the C128 and C64.
3026 <tag/Availability/cc65 (not all platforms)
3028 <ref id="get_scpu_speed" name="get_scpu_speed">,
3029 <ref id="set_scpu_speed" name="set_scpu_speed">,
3035 <sect1>div<label id="div"><p>
3039 <tag/Function/Divide two ints and return quotient and remainder.
3040 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
3041 <tag/Declaration/<tt/div_t __fastcall__ div (int numer, int denom);/
3042 <tag/Description/<tt/div/ divides <tt/numer/ by <tt/denom/ and returns the
3043 quotient and remainder in a <tt/div_t/ structure.
3044 <tag/Notes/<itemize>
3045 <item>The function is only available as fastcall function, so it may only
3046 be used in presence of a prototype.
3048 <tag/Availability/ISO 9899
3056 <sect1>doesclrscrafterexit<label id="doesclrscrafterexit"><p>
3060 <tag/Function/Determines whether the screen is going to be cleared after program exit.
3061 <tag/Header/<tt/<ref id="cc65.h" name="cc65.h">/
3062 <tag/Declaration/<tt/unsigned char doesclrscrafterexit (void);/
3063 <tag/Description/The function returns zero if the screen won't be cleared immediately after
3064 program termination. It returns a non-zero value if it will.
3065 <tag/Notes/<itemize>
3066 <item>Some systems, maybe depending on configuration, immediately clear the screen
3067 after a program exits. Therefore it might be difficult to read
3068 the last messages printed by the program prior to its exit. This function can be used
3069 to decide if a delay or wait for a key press should be executed when then program
3072 <tag/Availability/cc65
3075 #include <stdio.h>
3076 #include <unistd.h>
3077 #include <cc65.h>
3080 printf("Hello World\n");
3081 if (doesclrscrafterexit())
3090 <sect1>em_commit<label id="em_commit"><p>
3094 <tag/Function/Commit changes into extended memory.
3095 <tag/Header/<tt/<ref id="em.h" name="em.h">/
3096 <tag/Declaration/<tt/void em_commit (void);/
3097 <tag/Description/Commit changes in the memory window to extended storage. If
3098 the contents of the memory window have been changed, these changes may be lost
3099 if <tt/<ref id="em_map" name="em_map">/, <tt/<ref id="em_use" name="em_use">/,
3100 <tt/<ref id="em_copyfrom" name="em_copyfrom">/ or <tt/<ref id="em_copyto"
3101 name="em_copyto">/ are called without calling <tt/em_commit/ first.
3102 <tag/Notes/<itemize>
3103 <item>Calling <tt/em_commit/ does not necessarily mean that changes to the
3104 memory window are discarded, it does just mean that the drivers is allowed
3106 <item>The function is only available as fastcall function, so it may only be
3107 used in presence of a prototype.
3108 <item>The function produces undefined results if no extended memory driver is
3111 <tag/Availability/cc65
3113 <ref id="em_load_driver" name="em_load_driver">,
3114 <ref id="em_map" name="em_map">,
3115 <ref id="em_use" name="em_use">
3121 <sect1>em_copyfrom<label id="em_copyfrom"><p>
3125 <tag/Function/Copy from extended into normal memory.
3126 <tag/Header/<tt/<ref id="em.h" name="em.h">/
3127 <tag/Declaration/<tt/void __fastcall__ em_copyfrom (const struct em_copy* copy_data);/
3128 <tag/Description/Copy data from extended memory into linear memory. Source and
3129 target addresses as well as the number of bytes to transfer are specified in
3130 the <tt/em_copy/ structure that is passed as a parameter.
3131 <tag/Notes/<itemize>
3132 <item>Calling <tt/em_copyfrom/ will invalidate the memory window, so if you
3133 made any changes to the data in the window, call <tt/<ref id="em_commit"
3134 name="em_commit">/ first, or the changes are lost.
3135 <item>The function is only available as fastcall function, so it may only be
3136 used in presence of a prototype.
3137 <item>The function produces undefined results if no extended memory driver is
3140 <tag/Availability/cc65
3142 <ref id="em_commit" name="em_commit">,
3143 <ref id="em_copyto" name="em_copyto">,
3144 <ref id="em_load_driver" name="em_load_driver">
3150 <sect1>em_copyto<label id="em_copyto"><p>
3154 <tag/Function/Copy from normal into extended memory.
3155 <tag/Header/<tt/<ref id="em.h" name="em.h">/
3156 <tag/Declaration/<tt/void __fastcall__ em_copyto (const struct em_copy* copy_data);/
3157 <tag/Description/Copy data from linear into extended memory. Source and
3158 target addresses as well as the number of bytes to transfer are specified in
3159 the <tt/em_copy/ structure that is passed as a parameter.
3160 <tag/Notes/<itemize>
3161 <item>Calling <tt/em_copyto/ will invalidate the memory window, so if you
3162 made any changes to the data in the window, call <tt/<ref id="em_commit"
3163 name="em_commit">/ first, or the changes are lost.
3164 <item>The function is only available as fastcall function, so it may only be
3165 used in presence of a prototype.
3166 <item>The function produces undefined results if no extended memory driver is
3169 <tag/Availability/cc65
3171 <ref id="em_commit" name="em_commit">,
3172 <ref id="em_copyfrom" name="em_copyfrom">,
3173 <ref id="em_load_driver" name="em_load_driver">
3179 <sect1>em_install<label id="em_install"><p>
3183 <tag/Function/Install an already loaded extended memory driver.
3184 <tag/Header/<tt/<ref id="em.h" name="em.h">/
3185 <tag/Declaration/<tt/unsigned char _fastcall__ em_install (void* driver);/
3186 <tag/Description/The function installs an already loaded extended memory driver
3187 and returns an error code. The function may be used to install a driver linked
3188 statically to the program.
3189 <tag/Notes/<itemize>
3190 <item>Not all drivers are able to detect if the supported hardware is really
3192 <item>The function is only available as fastcall function, so it may only be
3193 used in presence of a prototype.
3195 <tag/Availability/cc65
3197 <ref id="em_load_driver" name="em_load_driver">,
3198 <ref id="em_uninstall" name="em_uninstall">,
3199 <ref id="em_unload" name="em_unload">
3205 <sect1>em_load_driver<label id="em_load_driver"><p>
3209 <tag/Function/Load and initialize an extended memory driver.
3210 <tag/Header/<tt/<ref id="em.h" name="em.h">/
3211 <tag/Declaration/<tt/void __fastcall__ em_load_driver (const char* name);/
3212 <tag/Description/Load an extended memory driver into memory and initialize
3213 it. The function returns an error code that tells if all this has been
3215 <tag/Notes/<itemize>
3216 <item>Not all drivers are able to detect if the supported hardware is really
3218 <item>The function is only available as fastcall function, so it may only be
3219 used in presence of a prototype.
3220 <item>The driver is loaded by name, so currently you must know the type of
3221 extended memory that should be supported. There is no autodetect capability.
3223 <tag/Availability/cc65
3225 <ref id="em_unload" name="em_unload">
3231 <sect1>em_map<label id="em_map"><p>
3235 <tag/Function/Make a page of extended memory accessible.
3236 <tag/Header/<tt/<ref id="em.h" name="em.h">/
3237 <tag/Declaration/<tt/void* __fastcall__ em_map (unsigned page);/
3238 <tag/Description/The function maps one page of extended memory into linear
3239 memory and returns a pointer to the page frame. Depending on the hardware
3240 and driver, the data is either mapped into the address space or transfered
3241 into a buffer. If you don't need the actual contents of the page (for example
3242 because you're going to overwrite it completely), it is better to call
3243 <tt/<ref id="em_use" name="em_use">/ instead. <tt/em_use/ will not transfer the
3244 data if it is possible to avoid that.
3245 <tag/Notes/<itemize>
3246 <item>Calling <tt/em_map/ will invalidate the memory window, so if you
3247 made any changes to the data in the window, call <tt/<ref id="em_commit"
3248 name="em_commit">/ first, or the changes are lost.
3249 <item>The function is only available as fastcall function, so it may only be
3250 used in presence of a prototype.
3251 <item>The function produces undefined results if no extended memory driver is
3254 <tag/Availability/cc65
3256 <ref id="em_commit" name="em_commit">,
3257 <ref id="em_load_driver" name="em_load_driver">,
3258 <ref id="em_use" name="em_use">
3264 <sect1>em_pagecount<label id="em_pagecount"><p>
3268 <tag/Function/Return the number of available extended memory pages.
3269 <tag/Header/<tt/<ref id="em.h" name="em.h">/
3270 <tag/Declaration/<tt/unsigned em_pagecount (void);/
3271 <tag/Description/The function returns the size of the extended memory supported
3272 by the driver in 256 byte pages.
3273 <tag/Notes/<itemize>
3274 <item>The function returns zero if no extended memory driver is loaded.
3275 <item>The function may return zero if the supported hardware was not detected.
3277 <tag/Availability/cc65
3279 <ref id="em_load_driver" name="em_load_driver">
3285 <sect1>em_uninstall<label id="em_uninstall"><p>
3289 <tag/Function/Uninstall an already loaded extended memory driver.
3290 <tag/Header/<tt/<ref id="em.h" name="em.h">/
3291 <tag/Declaration/<tt/unsigned char em_uninstall (void);/
3292 <tag/Description/The function uninstalls an already loaded extended memory
3293 driver but doesn't remove it from memory.
3294 <tag/Notes/<itemize>
3295 <item>If the driver has been loaded using <tt/<ref id="em_load_driver"
3296 name="em_load_driver">/, <tt/<ref id="em_unload" name="em_unload">/
3297 should be used instead of <tt/em_uninstall/ so the driver is also removed
3300 <tag/Availability/cc65
3302 <ref id="em_install" name="em_install">,
3303 <ref id="em_load_driver" name="em_load_driver">,
3304 <ref id="em_unload" name="em_unload">
3310 <sect1>em_unload<label id="em_unload"><p>
3314 <tag/Function/Unload an extended memory driver.
3315 <tag/Header/<tt/<ref id="em.h" name="em.h">/
3316 <tag/Declaration/<tt/unsigned char em_unload (void);/
3317 <tag/Description/The function unloads a loaded extended memory driver and
3318 frees all memory allocated for the driver.
3319 <tag/Notes/<itemize>
3320 <item>The function does nothing if no driver is loaded.
3322 <tag/Availability/cc65
3324 <ref id="em_load_driver" name="em_load_driver">
3330 <sect1>em_use<label id="em_use"><p>
3334 <tag/Function/Prepare an extended memory page for use.
3335 <tag/Header/<tt/<ref id="em.h" name="em.h">/
3336 <tag/Declaration/<tt/void* __fastcall__ em_use (unsigned page);/
3337 <tag/Description/The function maps one page of extended memory into linear
3338 memory and returns a pointer to the page frame. This function is similar to
3339 <tt/<ref id="em_map" name="em_map">/, but will not transfer data into the
3340 actual memory window in the assumption that the existing data is wrong or
3341 will get overwritten.
3342 <tag/Notes/<itemize>
3343 <item>Calling <tt/em_use/ will invalidate the memory window, so if you
3344 made any changes to the data in the window, call <tt/<ref id="em_commit"
3345 name="em_commit">/ first, or the changes are lost.
3346 <item>The function is only available as fastcall function, so it may only be
3347 used in presence of a prototype.
3348 <item>The function produces undefined results if no extended memory driver is
3351 <tag/Availability/cc65
3353 <ref id="em_commit" name="em_commit">,
3354 <ref id="em_load_driver" name="em_load_driver">,
3355 <ref id="em_map" name="em_map">
3361 <sect1>exit<label id="exit"><p>
3365 <tag/Function/Terminate the program.
3366 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
3367 <tag/Declaration/<tt/void __fastcall__ exit (int status);/
3368 <tag/Description/<tt/exit/ terminates the program. The argument specifies the
3369 return code of the program. Before termination, all files are closed, buffered
3370 output is written and any functions registered with <tt/<ref id="atexit"
3371 name="atexit">/ are called. Common values for status are <tt/EXIT_SUCCESS/ and
3372 <tt/EXIT_FAILURE/ which are also defined in <tt/<ref id="stdlib.h"
3374 <tag/Notes/<itemize>
3375 <item>The function is only available as fastcall function, so it may only
3376 be used in presence of a prototype.
3377 <item>It depends on the host machine if the program return code can be
3378 evaluated or is ignored.
3380 <tag/Availability/ISO 9899
3382 <ref id="abort" name="abort">,
3383 <ref id="exit" name="exit">
3389 <sect1>exec<label id="exec"><p>
3393 <tag/Function/Execute a program file.
3394 <tag/Header/<tt/<ref id="unistd.h" name="unistd.h">/
3395 <tag/Declaration/<tt/int __fastcall__ exec (const char* progname, const char* cmdline);/
3396 <tag/Description/<tt/exec/ replaces the currently running program by a new one.
3397 Calling <tt/exec()/ is identical to calling <tt/<ref id="exit" name="exit()">/,
3398 then loading and starting the program named in the first argument, passing
3399 the command line specified as second argument. Instead of an empty string,
3400 a <tt/NULL/ pointer may be passed as second parameter.
3401 On success, the function does not return. On failure, -1 is returned and
3402 <tt/errno/ contains an error code.
3403 <tag/Notes/<itemize>
3404 <item>The function is only available as fastcall function, so it may only
3405 be used in presence of a prototype.
3406 <item>On most platforms, the function needs to copy a small stub loader to
3407 some memory area outside the program space. This may collide with other
3408 programs. See the platform specific docs on this.
3409 <item>Because it is necessary to terminate the running program before the
3410 memory can be reused to load the new one, there is a high chance that the
3411 function may not be able to return on errors.
3412 <item>The command line is passed to the new program in the same way as cc65
3413 programs expect the command line. If the new program is not a cc65 generated
3414 program, it may not be able to read it.
3416 <tag/Availability/cc65
3418 <ref id="exit" name="exit">
3424 <sect1>fast<label id="fast"><p>
3428 <tag/Function/Switch the CPU into fast mode (C128: 2MHz mode, C16/Plus4: double clock mode).
3429 <tag/Header/<tt/<ref id="c128.h" name="c128.h">,
3430 <ref id="c16.h" name="c16.h">, <ref id="plus4.h" name="plus4.h">/
3431 <tag/Declaration/<tt/void fast (void);/
3432 <tag/Description/The function will switch the clock of the CPU to fast mode. For the C128
3433 target it means switching the CPU into 2MHz mode. For the C16/Plus4 target it means
3434 switching the CPU into double clock mode.
3435 <tag/Notes/<itemize>
3436 <item>The function is specific to the C128, C16 and Plus4.
3437 <item>On the C128 the 2MHz clock will not work in 40 column mode.
3439 <tag/Availability/cc65 (not all platforms)
3441 <ref id="isfast" name="isfast">,
3442 <ref id="slow" name="slow">,
3448 <sect1>feof<label id="feof"><p>
3452 <tag/Function/Return the end-of-file indicator of a stream.
3453 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
3454 <tag/Declaration/<tt/int __fastcall__ feof (FILE* f);/
3455 <tag/Description/<tt/feof/ tests the end-of-file indicator ofthe stream
3456 <tt/f/, and returns a non zero value if it is set.
3457 <tag/Notes/<itemize>
3458 <item>The indicator is set only after a read past the end of a file is
3460 <item>The function is only available as fastcall function, so it may only be
3461 used in presence of a prototype.
3463 <tag/Availability/ISO 9899
3465 <ref id="feof" name="clearerr">,
3466 <ref id="ferror" name="ferror">
3472 <sect1>ferror<label id="ferror"><p>
3476 <tag/Function/Return the error indicator of a stream.
3477 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
3478 <tag/Declaration/<tt/int __fastcall__ ferror (FILE* f);/
3479 <tag/Description/<tt/ferror/ tests the error indicator of the stream
3480 <tt/f/, and returns a non zero value if it is set.
3481 <tag/Notes/<itemize>
3482 <item>The function is only available as fastcall function, so it may only be
3483 used in presence of a prototype.
3485 <tag/Availability/ISO 9899
3487 <ref id="feof" name="clearerr">,
3488 <ref id="ferror" name="feof">
3494 <sect1>fileno<label id="fileno"><p>
3498 <tag/Function/Return the file handle used by a stream.
3499 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
3500 <tag/Declaration/<tt/int __fastcall__ fileno (FILE* f);/
3501 <tag/Description/The <tt/fileno/ function returns the file handle used
3502 internally by a C stream. This file handle (an integer) can be used as a
3503 handle for the POSIX input/output functions.
3504 <tag/Notes/<itemize>
3505 <item>The function is only available as fastcall function, so it may only be
3506 used in presence of a prototype.
3507 <item>Mixing C file I/O functions and POSIX file I/O functions for the same
3508 file may have unpredictable results.
3510 <tag/Availability/POSIX 1003.1
3512 <ref id="creat" name="creat">,
3513 <ref id="open" name="open"> <!-- , -->
3514 <!-- <ref id="read" name="read">, -->
3515 <!-- <ref id="write" name="write"> -->
3521 <sect1>free<label id="free"><p>
3525 <tag/Function/Free a block of dynamic memory.
3526 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
3527 <tag/Declaration/<tt/void __fastcall__ free (void* block);/
3528 <tag/Description/Free a block of dynamic memory previously allocated with
3529 <tt/<ref id="malloc" name="malloc">/, <tt/<ref id="calloc" name="calloc">/
3530 or <tt/<ref id="realloc" name="realloc">/. As an exception, if the passed
3531 pointer is <tt/NULL/, no action is performed.
3532 <tag/Notes/<itemize>
3533 <item>Passing an already free'd block to <tt/free/ again will cause undefined
3534 behaviour and may crash your program.
3535 <item>The function is only available as fastcall function, so it may only
3536 be used in presence of a prototype.
3538 <tag/Availability/ISO 9899
3540 <ref id="_heapadd" name="_heapadd">,
3541 <ref id="_heapblocksize" name="_heapblocksize">,
3542 <ref id="_heapmaxavail" name="_heapmaxavail">,
3543 <ref id="_heapmemavail" name="_heapmemavail">,
3544 <ref id="calloc" name="calloc">,
3545 <ref id="malloc" name="malloc">,
3546 <ref id="realloc" name="realloc">
3552 <sect1>get_ostype<label id="get_ostype"><p>
3556 <tag/Function/The function returns the operating system, the program runs on.
3557 <tag/Header/<tt/<ref id="apple2.h" name="apple2.h">,
3558 <ref id="atari.h" name="atari.h">, <ref id="c64.h" name="c64.h">/
3559 <tag/Declaration/<tt/unsigned char get_ostype (void);/
3560 <tag/Description/<tt/get_ostype/ is machine dependent and does not exist for
3561 all supported targets. If it exists, it returns a number that identifies the
3562 operating system or machine type, the program runs on. The machine dependent
3563 header files define constants that can be used to check the return code.
3564 <tag/Notes/<itemize>
3565 <item>The function does not exist on all platforms.
3566 <item>The return codes are platform dependent.
3568 <tag/Availability/cc65 (not all platforms)
3574 <sect1>get_c128_speed<label id="get_c128_speed"><p>
3578 <tag/Function/Get the current speed of the C128 CPU.
3579 <tag/Header/<tt/<ref id="accelerator.h" name="accelerator.h">/
3580 <tag/Declaration/<tt/unsigned char get_c128_speed (void);/
3581 <tag/Description/The function returns the current speed of the C128 CPU.
3582 <tag/Notes/<itemize>
3583 <item>The function is specific to the C64 and C128.
3584 <item>The function does not check if the C128 CPU is the current CPU.
3585 <item>See the accelerator.h header for the speed definitions.
3587 <tag/Availability/cc65 (not all platforms)
3589 <ref id="detect_c128" name="detect_c128">,
3590 <ref id="set_c128_speed" name="set_c128_speed">,
3596 <sect1>get_c64dtv_speed<label id="get_c64dtv_speed"><p>
3600 <tag/Function/Get the current speed of the C64DTV.
3601 <tag/Header/<tt/<ref id="accelerator.h" name="accelerator.h">/
3602 <tag/Declaration/<tt/unsigned char get_c64dtv_speed (void);/
3603 <tag/Description/The function returns the current speed of the C64DTV.
3604 <tag/Notes/<itemize>
3605 <item>The function is specific to the C64.
3606 <item>The function does not check for the presence of the C64DTV.
3607 <item>See the accelerator.h header for the speed definitions.
3609 <tag/Availability/cc65 (not all platforms)
3611 <ref id="detect_c64dtv" name="detect_c64dtv">,
3612 <ref id="set_c64dtv_speed" name="set_c64dtv_speed">,
3618 <sect1>get_c65_speed<label id="get_c65_speed"><p>
3622 <tag/Function/Get the current speed of the C65/C64DX in C64 mode.
3623 <tag/Header/<tt/<ref id="accelerator.h" name="accelerator.h">/
3624 <tag/Declaration/<tt/unsigned char get_c65_speed (void);/
3625 <tag/Description/The function returns the current speed of the C65/C64DX in C64 mode.
3626 <tag/Notes/<itemize>
3627 <item>The function is specific to the C64.
3628 <item>The function does not check for the presence of a C65/C64DX in C64 mode.
3629 <item>See the accelerator.h header for the speed definitions.
3631 <tag/Availability/cc65 (not all platforms)
3633 <ref id="detect_c65" name="detect_c65">,
3634 <ref id="set_c65_speed" name="set_c65_speed">,
3640 <sect1>get_chameleon_speed<label id="get_chameleon_speed"><p>
3644 <tag/Function/Get the current speed of the C64 Chameleon cartridge.
3645 <tag/Header/<tt/<ref id="accelerator.h" name="accelerator.h">/
3646 <tag/Declaration/<tt/unsigned char get_chameleon_speed (void);/
3647 <tag/Description/The function returns the current speed of the C64 Chameleon cartridge.
3648 <tag/Notes/<itemize>
3649 <item>The function is specific to the C64.
3650 <item>The function does not check for the presence of the C64 Chameleon cartridge.
3651 <item>See the accelerator.h header for the speed definitions.
3653 <tag/Availability/cc65 (not all platforms)
3655 <ref id="detect_chameleon" name="detect_chameleon">,
3656 <ref id="set_chameleon_speed" name="set_chameleon_speed">,
3662 <sect1>get_scpu_speed<label id="get_scpu_speed"><p>
3666 <tag/Function/Get the current speed of the C64/C128 SuperCPU cartridge.
3667 <tag/Header/<tt/<ref id="accelerator.h" name="accelerator.h">/
3668 <tag/Declaration/<tt/unsigned char get_scpu_speed (void);/
3669 <tag/Description/The function returns the current speed of the SuperCPU cartridge.
3670 <tag/Notes/<itemize>
3671 <item>The function is specific to the C128 and C64.
3672 <item>The function does not check for the presence of the cartridge.
3673 <item>See the accelerator.h header for the speed definitions.
3675 <tag/Availability/cc65 (not all platforms)
3677 <ref id="detect_scpu" name="detect_scpu">,
3678 <ref id="set_scpu_speed" name="set_scpu_speed">,
3684 <sect1>getcpu<label id="getcpu"><p>
3688 <tag/Function/Determine on which CPU the program is running.
3689 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
3690 <tag/Declaration/<tt/unsigned char getcpu (void);/
3691 <tag/Description/The function checks on which CPU the code is running. It
3692 returns one of the constants<itemize>
3694 <item><tt/CPU_65C02/
3695 <item><tt/CPU_65816/
3697 <item><tt/CPU_65SC02/
3698 <item><tt/CPU_65CE02/
3699 <item><tt/CPU_HUC6280/
3702 <tag/Notes/<itemize>
3703 <item>Other, more exotic CPU types are not disinguished.
3705 <tag/Availability/cc65
3711 <sect1>getcurrentdevice<label id="getcurrentdevice"><p>
3715 <tag/Function/Get current device.
3716 <tag/Header/<tt/<ref id="device.h" name="device.h">/
3717 <tag/Declaration/<tt/unsigned char getcurrentdevice (void);/
3718 <tag/Description/The function returns the current device.
3719 It allows to access the current device with the <ref id="dio.h"
3720 name="Low-level disk I/O API"> or <ref id="cbm.h" name="cbm_* I/O
3721 functions"> requiring a 'device' parameter.
3722 <tag/Availability/cc65
3724 <ref id="getdevicedir" name="getdevicedir">,
3725 <ref id="getfirstdevice" name="getfirstdevice">,
3726 <ref id="getnextdevice" name="getnextdevice">
3728 dio_open (getcurrentdevice ());
3734 <sect1>getcwd<label id="getcwd"><p>
3738 <tag/Function/Get current working directory.
3739 <tag/Header/<tt/<ref id="unistd.h" name="unistd.h">/
3740 <tag/Declaration/<tt/char* __fastcall__ getcwd (char* buf, size_t size);/
3741 <tag/Description/The function will return the current working directory.
3742 <tag/Notes/<itemize>
3743 <item>The function is only available as fastcall function, so it may only
3744 be used in presence of a prototype.
3746 <tag/Availability/POSIX 1003.1
3752 <sect1>getdevicedir<label id="getdevicedir"><p>
3756 <tag/Function/Get device directory.
3757 <tag/Header/<tt/<ref id="device.h" name="device.h">/
3758 <tag/Declaration/<tt/char* __fastcall__ getdevicedir (unsigned char device, char* buf, size_t size);/
3759 <tag/Description/The function returns the directory representing <tt/device/.
3760 It allows to access the device on filesystem level by calling chdir() with
3761 the directory returned.
3762 <tag/Notes/<itemize>
3763 <item>Calling getdevicedir() <em/does/ check for a (formatted) disk in a
3764 floppy-disk-type device and returns NULL if that check fails.
3765 <item>The function is only available as fastcall function, so it may only
3766 be used in presence of a prototype.
3768 <tag/Availability/cc65
3770 <ref id="getcwd" name="getcwd">,
3771 <ref id="getcurrentdevice" name="getcurrentdevice">,
3772 <ref id="getfirstdevice" name="getfirstdevice">,
3773 <ref id="getnextdevice" name="getnextdevice">
3775 chdir (getdevicedir (device, buf, sizeof buf));
3777 cf. <tt/samples/enumdevdir.c/
3782 <sect1>getenv<label id="getenv"><p>
3786 <tag/Function/Return a value from the environment.
3787 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
3788 <tag/Declaration/<tt/char* __fastcall__ getenv (const char* name);/
3789 <tag/Description/The function searches the environment for an entry that
3790 matches <tt/name/ and returns its value. The environment consists of a list
3791 of strings in the form <tt/name=value/. If there is no match, <tt/getenv/
3793 <tag/Notes/<itemize>
3794 <item>What exactly is stored in the environment depends on the machine the
3795 program is running on.
3796 <item>The function is only available as fastcall function, so it may only
3797 be used in presence of a prototype.
3799 <tag/Availability/ISO 9899
3805 <sect1>getfirstdevice<label id="getfirstdevice"><p>
3809 <tag/Function/Get first device.
3810 <tag/Header/<tt/<ref id="device.h" name="device.h">/
3811 <tag/Declaration/<tt/unsigned char getfirstdevice (void);/
3812 <tag/Description/The function returns the first device.
3813 The constant <tt/INVALID_DEVICE/ indicates no device.
3814 <tag/Notes/<itemize>
3815 <item>Calling getfirstdevice() does <em/not/ turn on the motor of a
3816 drive-type device and does <em/not/ check for a disk in the drive.
3818 <tag/Availability/cc65
3820 <ref id="getcurrentdevice" name="getcurrentdevice">,
3821 <ref id="getdevicedir" name="getdevicedir">,
3822 <ref id="getnextdevice" name="getnextdevice">
3824 unsigned char dev = getfirstdevice ();
3825 while (dev != INVALID_DEVICE) {
3826 printf ("%d\n", dev);
3827 dev = getnextdevice (dev);
3834 <sect1>getnextdevice<label id="getnextdevice"><p>
3838 <tag/Function/Get next device.
3839 <tag/Header/<tt/<ref id="device.h" name="device.h">/
3840 <tag/Declaration/<tt/unsigned char __fastcall__ getnextdevice (unsigned char device);/
3841 <tag/Description/The function returns the next device after <tt/device/.
3842 The constant <tt/INVALID_DEVICE/ indicates no further device.
3843 <tag/Notes/<itemize>
3844 <item>Calling getnextdevice() does <em/not/ turn on the motor of a
3845 drive-type device and does <em/not/ check for a disk in the drive.
3846 <item>The function is only available as fastcall function, so it may only
3847 be used in presence of a prototype.
3849 <tag/Availability/cc65
3851 <ref id="getcurrentdevice" name="getcurrentdevice">,
3852 <ref id="getdevicedir" name="getdevicedir">,
3853 <ref id="getfirstdevice" name="getfirstdevice">
3855 unsigned char dev = getfirstdevice ();
3856 while (dev != INVALID_DEVICE) {
3857 printf ("%d\n", dev);
3858 dev = getnextdevice (dev);
3865 <sect1>getopt<label id="getopt"><p>
3869 <tag/Function/Parse command line options.
3870 <tag/Header/<tt/<ref id="unistd.h" name="unistd.h">/
3871 <tag/Declaration/<tt/int __fastcall__ getopt (int argc, char* const* argv,
3872 const char* optstring);/
3873 <tag/Description/The function parses command line arguments, <tt/argc/ and
3874 <tt/argv/ are the argument count and array passed to <tt/main/. <tt/optstring/
3875 is a string that contains command line option characters. If a character in
3876 <tt/optstring/ is followed by a colon, the option requires an argument. An
3877 option on the command line is recognized if it is one of the option characters
3879 <tt/getopt/ must be called repeatedly. It will return each option character
3880 found on the command line and <tt/EOF/ (-1) if there is no other option. An
3881 option argument is placed in <tt/optarg/, the index of the next element on the
3882 command line to be processed is placed in <tt/optind/.
3883 <tag/Notes/<itemize>
3884 <item>The implementation will not reorder options. A non option on the command
3885 line will terminate option processing. All remaining arguments are not
3886 recognized as options, even if the start with a '-' character.
3887 <item>The function is only available as fastcall function, so it may only
3888 be used in presence of a prototype.
3890 <tag/Availability/POSIX.2
3896 <sect1>gotox<label id="gotox"><p>
3900 <tag/Function/Move the text mode cursor to a new X position.
3901 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
3902 <tag/Declaration/<tt/void __fastcall__ gotox (unsigned char x);/
3903 <tag/Description/The function moves the text mode cursor to the specified X
3904 position while leaving the Y position untouched. The leftmost position on the
3905 screen has the coordinate 0.
3906 <tag/Notes/<itemize>
3907 <item>The function is only available as fastcall function, so it may
3908 only be used in presence of a prototype.
3909 <item>Invalid values for the X position (out of screen coordinates) may
3910 lead to undefined behaviour.
3912 <tag/Availability/cc65
3914 <ref id="gotoy" name="gotoy">,
3915 <ref id="gotoxy" name="gotoxy">,
3916 <ref id="wherex" name="wherex">,
3917 <ref id="wherey" name="wherey">
3923 <sect1>gotoxy<label id="gotoxy"><p>
3927 <tag/Function/Move the text mode cursor to a new position.
3928 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
3929 <tag/Declaration/<tt/void __fastcall__ gotoxy (unsigned char x, unsigned char y);/
3930 <tag/Description/The function moves the text mode cursor to the specified
3931 position. The leftmost position on the screen has the X coordinate 0, the
3932 topmost line has the Y coordinate 0.
3933 <tag/Notes/<itemize>
3934 <item>The function is only available as fastcall function, so it may only be
3935 used in presence of a prototype.
3936 <item>Invalid values for any of both coordinates (out of screen positions) may
3937 lead to undefined behaviour.
3939 <tag/Availability/cc65
3941 <ref id="gotox" name="gotox">,
3942 <ref id="gotoy" name="gotoy">,
3943 <ref id="wherex" name="wherex">,
3944 <ref id="wherey" name="wherey">
3950 <sect1>gotoy<label id="gotoy"><p>
3954 <tag/Function/Move the text mode cursor to a new Y position.
3955 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
3956 <tag/Declaration/<tt/void __fastcall__ gotoy (unsigned char x);/
3957 <tag/Description/The function moves the text mode cursor to the specified Y
3958 position while leaving the X position untouched. The uppermost position on the
3959 screen has the coordinate 0.
3960 <tag/Notes/<itemize>
3961 <item>The function is only available as fastcall function, so it may
3962 only be used in presence of a prototype.
3963 <item>Invalid values for the Y position (out of screen coordinates) may lead
3964 to undefined behaviour.
3966 <tag/Availability/cc65
3968 <ref id="gotox" name="gotox">,
3969 <ref id="gotoxy" name="gotoxy">,
3970 <ref id="wherex" name="wherex">,
3971 <ref id="wherey" name="wherey">
3977 <sect1>isalnum<label id="isalnum"><p>
3981 <tag/Function/Check if a given character is a letter or digit.
3982 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
3983 <tag/Declaration/<tt/int __fastcall__ isalnum (int c);/
3984 <tag/Description/The function returns a non zero value if the given argument
3985 is a letter or digit. The return value is zero if the character is anything
3987 <tag/Notes/<itemize>
3988 <item>When compiling with <tt/-Os/ the function is actually a macro. The
3989 inline sequence generated by the macro will not work correctly for values
3990 outside the range 0..255. <em/Note:/ The constant <tt/EOF/ is not part of
3991 this range. The non inline function may be accessed by <tt/#undef/'ing
3993 <item>When compiling without <tt/-Os/, the function is only available as
3994 fastcall function, so it may only be used in presence of a prototype.
3996 <tag/Availability/ISO 9899
3998 <ref id="isalpha" name="isalpha">,
3999 <ref id="isascii" name="isascii">,
4000 <ref id="isblank" name="isblank">,
4001 <ref id="iscntrl" name="iscntrl">,
4002 <ref id="isdigit" name="isdigit">,
4003 <ref id="isgraph" name="isgraph">,
4004 <ref id="islower" name="islower">,
4005 <ref id="isprint" name="isprint">,
4006 <ref id="ispunct" name="ispunct">,
4007 <ref id="isspace" name="isspace">,
4008 <ref id="isupper" name="isupper">,
4009 <ref id="isxdigit" name="isxdigit">
4015 <sect1>isalpha<label id="isalpha"><p>
4019 <tag/Function/Check if a given character is a letter.
4020 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
4021 <tag/Declaration/<tt/int __fastcall__ isalpha (int c);/
4022 <tag/Description/The function returns a non zero value if the given argument
4023 is a letter. The return value is zero if the character is anything else.
4024 <tag/Notes/<itemize>
4025 <item>When compiling with <tt/-Os/ the function is actually a macro. The
4026 inline sequence generated by the macro will not work correctly for values
4027 outside the range 0..255. <em/Note:/ The constant <tt/EOF/ is not part of
4028 this range. The non inline function may be accessed by <tt/#undef/'ing the
4030 <item>When compiling without <tt/-Os/, the function is only available as
4031 fastcall function, so it may only be used in presence of a prototype.
4033 <tag/Availability/ISO 9899
4035 <ref id="isalnum" name="isalnum">,
4036 <ref id="isascii" name="isascii">,
4037 <ref id="isblank" name="isblank">,
4038 <ref id="iscntrl" name="iscntrl">,
4039 <ref id="isdigit" name="isdigit">,
4040 <ref id="isgraph" name="isgraph">,
4041 <ref id="islower" name="islower">,
4042 <ref id="isprint" name="isprint">,
4043 <ref id="ispunct" name="ispunct">,
4044 <ref id="isspace" name="isspace">,
4045 <ref id="isupper" name="isupper">,
4046 <ref id="isxdigit" name="isxdigit">
4052 <sect1>isascii<label id="isascii"><p>
4056 <tag/Function/Check if a given character is in the ASCII (0..127) range.
4057 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
4058 <tag/Declaration/<tt/int __fastcall__ isascii (int c);/
4059 <tag/Description/The function returns a non zero value if the given argument
4060 is in the range 0..127 (the range of valid ASCII characters) and zero if not.
4061 <tag/Notes/<itemize>
4062 <item>When compiling with <tt/-Os/ the function is actually a macro. The
4063 inline sequence generated by the macro will not work correctly for values
4064 outside the range 0..255. <em/Note:/ The constant <tt/EOF/ is not part of
4065 this range. The non inline function may be accessed by <tt/#undef/'ing the
4067 <item>When compiling without <tt/-Os/, the function is only available as
4068 fastcall function, so it may only be used in presence of a prototype.
4070 <tag/Availability/ISO 9899
4072 <ref id="isalnum" name="isalnum">,
4073 <ref id="isalpha" name="isalpha">,
4074 <ref id="isblank" name="isblank">,
4075 <ref id="iscntrl" name="iscntrl">,
4076 <ref id="isdigit" name="isdigit">,
4077 <ref id="isgraph" name="isgraph">,
4078 <ref id="islower" name="islower">,
4079 <ref id="isprint" name="isprint">,
4080 <ref id="ispunct" name="ispunct">,
4081 <ref id="isspace" name="isspace">,
4082 <ref id="isupper" name="isupper">,
4083 <ref id="isxdigit" name="isxdigit">
4089 <sect1>isblank<label id="isblank"><p>
4093 <tag/Function/Check if a given character is a space or tab.
4094 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
4095 <tag/Declaration/<tt/int __fastcall__ isblank (int c);/
4096 <tag/Description/The function returns a non zero value if the given argument
4097 is a space or tab character. The return value is zero if the character is
4099 <tag/Notes/<itemize>
4100 <item>When compiling with <tt/-Os/ the function is actually a macro. The
4101 inline sequence generated by the macro will not work correctly for values
4102 outside the range 0..255. <em/Note:/ The constant <tt/EOF/ is not part of
4103 this range. The non inline function may be accessed by <tt/#undef/'ing the
4105 <item>When compiling without <tt/-Os/, the function is only available as
4106 fastcall function, so it may only be used in presence of a prototype.
4108 <tag/Availability/ISO 9899
4110 <ref id="isalnum" name="isalnum">,
4111 <ref id="isalpha" name="isalpha">,
4112 <ref id="isascii" name="isascii">,
4113 <ref id="iscntrl" name="iscntrl">,
4114 <ref id="isdigit" name="isdigit">,
4115 <ref id="isgraph" name="isgraph">,
4116 <ref id="islower" name="islower">,
4117 <ref id="isprint" name="isprint">,
4118 <ref id="ispunct" name="ispunct">,
4119 <ref id="isspace" name="isspace">,
4120 <ref id="isupper" name="isupper">,
4121 <ref id="isxdigit" name="isxdigit">
4127 <sect1>iscntrl<label id="iscntrl"><p>
4131 <tag/Function/Check if a given character is a control character.
4132 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
4133 <tag/Declaration/<tt/int __fastcall__ iscntrl (int c);/
4134 <tag/Description/The function returns a non zero value if the given argument
4135 is a control character. The return value is zero if the character is anything
4137 <tag/Notes/<itemize>
4138 <item>When compiling with <tt/-Os/ the function is actually a macro. The
4139 inline sequence generated by the macro will not work correctly for values
4140 outside the range 0..255. <em/Note:/ The constant <tt/EOF/ is not part of
4141 this range. The non inline function may be accessed by <tt/#undef/'ing the
4143 <item>When compiling without <tt/-Os/, the function is only available as
4144 fastcall function, so it may only be used in presence of a prototype.
4146 <tag/Availability/ISO 9899
4148 <ref id="isalnum" name="isalnum">,
4149 <ref id="isalpha" name="isalpha">,
4150 <ref id="isascii" name="isascii">,
4151 <ref id="isblank" name="isblank">,
4152 <ref id="isdigit" name="isdigit">,
4153 <ref id="isgraph" name="isgraph">,
4154 <ref id="islower" name="islower">,
4155 <ref id="isprint" name="isprint">,
4156 <ref id="ispunct" name="ispunct">,
4157 <ref id="isspace" name="isspace">,
4158 <ref id="isupper" name="isupper">,
4159 <ref id="isxdigit" name="isxdigit">
4165 <sect1>isdigit<label id="isdigit"><p>
4169 <tag/Function/Check if a given character is a digit.
4170 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
4171 <tag/Declaration/<tt/int __fastcall__ isdigit (int c);/
4172 <tag/Description/The function returns a non zero value if the given argument
4173 is a digit. The return value is zero if the character is anything else.
4174 <tag/Notes/<itemize>
4175 <item>When compiling with <tt/-Os/ the function is actually a macro. The
4176 inline sequence generated by the macro will not work correctly for values
4177 outside the range 0..255. <em/Note:/ The constant <tt/EOF/ is not part of
4178 this range. The non inline function may be accessed by <tt/#undef/'ing the
4180 <item>When compiling without <tt/-Os/, the function is only available as
4181 fastcall function, so it may only be used in presence of a prototype.
4183 <tag/Availability/ISO 9899
4185 <ref id="isalnum" name="isalnum">,
4186 <ref id="isalpha" name="isalpha">,
4187 <ref id="isascii" name="isascii">,
4188 <ref id="isblank" name="isblank">,
4189 <ref id="iscntrl" name="iscntrl">,
4190 <ref id="isgraph" name="isgraph">,
4191 <ref id="islower" name="islower">,
4192 <ref id="isprint" name="isprint">,
4193 <ref id="ispunct" name="ispunct">,
4194 <ref id="isspace" name="isspace">,
4195 <ref id="isupper" name="isupper">,
4196 <ref id="isxdigit" name="isxdigit">
4202 <sect1>isfast<label id="isfast"><p>
4206 <tag/Function/Check if the CPU is in fast mode (C128: 2MHz mode, C16/Plus4: double clock mode).
4207 <tag/Header/<tt/<ref id="c128.h" name="c128.h">,
4208 <ref id="c16.h" name="c16.h">, <ref id="plus4.h" name="plus4.h">/
4209 <tag/Declaration/<tt/unsigned char isfast (void);/
4210 <tag/Description/The function returns a 1 if the CPU is in fast mode (C128: 2MHz mode, C16/Plus4: double clock mode).
4211 <tag/Notes/<itemize>
4212 <item>The function is specific to the C128, C16 and Plus4.
4214 <tag/Availability/cc65 (not all platforms)
4216 <ref id="fast" name="fast">,
4217 <ref id="slow" name="slow">,
4223 <sect1>isgraph<label id="isgraph"><p>
4227 <tag/Function/Check if a given character is a printable character (except
4229 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
4230 <tag/Declaration/<tt/int __fastcall__ isgraph (int c);/
4231 <tag/Description/The function returns a non zero value if the given argument
4232 is a printable character with the exception of space. The return value is zero
4233 if the character is anything else.
4234 <tag/Notes/<itemize>
4235 <item>When compiling with <tt/-Os/ the function is actually a macro. The
4236 inline sequence generated by the macro will not work correctly for values
4237 outside the range 0..255. <em/Note:/ The constant <tt/EOF/ is not part of
4238 this range. The non inline function may be accessed by <tt/#undef/'ing the
4240 <item>When compiling without <tt/-Os/, the function is only available as
4241 fastcall function, so it may only be used in presence of a prototype.
4243 <tag/Availability/ISO 9899
4245 <ref id="isalnum" name="isalnum">,
4246 <ref id="isalpha" name="isalpha">,
4247 <ref id="isascii" name="isascii">,
4248 <ref id="isblank" name="isblank">,
4249 <ref id="iscntrl" name="iscntrl">,
4250 <ref id="isdigit" name="isdigit">,
4251 <ref id="islower" name="islower">,
4252 <ref id="isprint" name="isprint">,
4253 <ref id="ispunct" name="ispunct">,
4254 <ref id="isspace" name="isspace">,
4255 <ref id="isupper" name="isupper">,
4256 <ref id="isxdigit" name="isxdigit">
4262 <sect1>islower<label id="islower"><p>
4266 <tag/Function/Check if a given character is a lower case letter.
4267 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
4268 <tag/Declaration/<tt/int __fastcall__ islower (int c);/
4269 <tag/Description/The function returns a non zero value if the given argument
4270 is a lower case letter. The return value is zero if the character is anything
4272 <tag/Notes/<itemize>
4273 <item>When compiling with <tt/-Os/ the function is actually a macro. The
4274 inline sequence generated by the macro will not work correctly for values
4275 outside the range 0..255. <em/Note:/ The constant <tt/EOF/ is not part of
4276 this range. The non inline function may be accessed by <tt/#undef/'ing the
4278 <item>When compiling without <tt/-Os/, the function is only available as
4279 fastcall function, so it may only be used in presence of a prototype.
4281 <tag/Availability/ISO 9899
4283 <ref id="isalnum" name="isalnum">,
4284 <ref id="isalpha" name="isalpha">,
4285 <ref id="isascii" name="isascii">,
4286 <ref id="isblank" name="isblank">,
4287 <ref id="iscntrl" name="iscntrl">,
4288 <ref id="isdigit" name="isdigit">,
4289 <ref id="isgraph" name="isgraph">,
4290 <ref id="isprint" name="isprint">,
4291 <ref id="ispunct" name="ispunct">,
4292 <ref id="isspace" name="isspace">,
4293 <ref id="isupper" name="isupper">,
4294 <ref id="isxdigit" name="isxdigit">
4300 <sect1>isprint<label id="isprint"><p>
4304 <tag/Function/Check if a given character is a printable character.
4305 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
4306 <tag/Declaration/<tt/int __fastcall__ isprint (int c);/
4307 <tag/Description/The function returns a non zero value if the given argument
4308 is a printable character (this includes the space character). The return value
4309 is zero if the character is anything else.
4310 <tag/Notes/<itemize>
4311 <item>When compiling with <tt/-Os/ the function is actually a macro. The
4312 inline sequence generated by the macro will not work correctly for values
4313 outside the range 0..255. <em/Note:/ The constant <tt/EOF/ is not part of
4314 this range. The non inline function may be accessed by <tt/#undef/'ing the
4316 <item>When compiling without <tt/-Os/, the function is only available as
4317 fastcall function, so it may only be used in presence of a prototype.
4319 <tag/Availability/ISO 9899
4321 <ref id="isalnum" name="isalnum">,
4322 <ref id="isalpha" name="isalpha">,
4323 <ref id="isascii" name="isascii">,
4324 <ref id="isblank" name="isblank">,
4325 <ref id="iscntrl" name="iscntrl">,
4326 <ref id="isdigit" name="isdigit">,
4327 <ref id="isgraph" name="isgraph">,
4328 <ref id="islower" name="islower">,
4329 <ref id="ispunct" name="ispunct">,
4330 <ref id="isspace" name="isspace">,
4331 <ref id="isupper" name="isupper">,
4332 <ref id="isxdigit" name="isxdigit">
4338 <sect1>ispunct<label id="ispunct"><p>
4342 <tag/Function/Check if a given character is a printable character but not a
4343 space or an alphanumeric character.
4344 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
4345 <tag/Declaration/<tt/int __fastcall__ ispunct (int c);/
4346 <tag/Description/The function returns a non zero value if the given argument
4347 is a printable character, but not a space or anything alphanumeric. The return
4348 value is zero if the character is anything else.
4349 <tag/Notes/<itemize>
4350 <item>When compiling with <tt/-Os/ the function is actually a macro. The
4351 inline sequence generated by the macro will not work correctly for values
4352 outside the range 0..255. <em/Note:/ The constant <tt/EOF/ is not part of
4353 this range. The non inline function may be accessed by <tt/#undef/'ing the
4355 <item>When compiling without <tt/-Os/, the function is only available as
4356 fastcall function, so it may only be used in presence of a prototype.
4358 <tag/Availability/ISO 9899
4360 <ref id="isalnum" name="isalnum">,
4361 <ref id="isalpha" name="isalpha">,
4362 <ref id="isascii" name="isascii">,
4363 <ref id="isblank" name="isblank">,
4364 <ref id="iscntrl" name="iscntrl">,
4365 <ref id="isdigit" name="isdigit">,
4366 <ref id="isgraph" name="isgraph">,
4367 <ref id="islower" name="islower">,
4368 <ref id="isprint" name="isprint">,
4369 <ref id="isspace" name="isspace">,
4370 <ref id="isupper" name="isupper">,
4371 <ref id="isxdigit" name="isxdigit">
4377 <sect1>isspace<label id="isspace"><p>
4381 <tag/Function/Check if a given character is a white-space character.
4382 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
4383 <tag/Declaration/<tt/int __fastcall__ isspace (int c);/
4384 <tag/Description/The function returns a non zero value if the given argument
4385 is a white space character. The return value is zero if the character is
4386 anything else. The standard white space characters are: space, formfeed ('\f'),
4387 newline ('\n'), carriage return ('\r'), horizontal tab ('\t'), and vertical tab
4389 <tag/Notes/<itemize>
4390 <item>When compiling with <tt/-Os/ the function is actually a macro. The
4391 inline sequence generated by the macro will not work correctly for values
4392 outside the range 0..255. <em/Note:/ The constant <tt/EOF/ is not part of
4393 this range. The non inline function may be accessed by <tt/#undef/'ing the
4395 <item>When compiling without <tt/-Os/, the function is only available as
4396 fastcall function, so it may only be used in presence of a prototype.
4398 <tag/Availability/ISO 9899
4400 <ref id="isalnum" name="isalnum">,
4401 <ref id="isalpha" name="isalpha">,
4402 <ref id="isascii" name="isascii">,
4403 <ref id="isblank" name="isblank">,
4404 <ref id="iscntrl" name="iscntrl">,
4405 <ref id="isdigit" name="isdigit">,
4406 <ref id="isgraph" name="isgraph">,
4407 <ref id="islower" name="islower">,
4408 <ref id="isprint" name="isprint">,
4409 <ref id="ispunct" name="ispunct">,
4410 <ref id="isupper" name="isupper">,
4411 <ref id="isxdigit" name="isxdigit">
4417 <sect1>isupper<label id="isupper"><p>
4421 <tag/Function/Check if a given character is an upper case letter.
4422 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
4423 <tag/Declaration/<tt/int __fastcall__ isupper (int c);/
4424 <tag/Description/The function returns a non zero value if the given argument
4425 is an upper case letter. The return value is zero if the character is anything
4427 <tag/Notes/<itemize>
4428 <item>When compiling with <tt/-Os/ the function is actually a macro. The
4429 inline sequence generated by the macro will not work correctly for values
4430 outside the range 0..255. <em/Note:/ The constant <tt/EOF/ is not part of
4431 this range. The non inline function may be accessed by <tt/#undef/'ing the
4433 <item>When compiling without <tt/-Os/, the function is only available as
4434 fastcall function, so it may only be used in presence of a prototype.
4436 <tag/Availability/ISO 9899
4438 <ref id="isalnum" name="isalnum">,
4439 <ref id="isalpha" name="isalpha">,
4440 <ref id="isascii" name="isascii">,
4441 <ref id="isblank" name="isblank">,
4442 <ref id="iscntrl" name="iscntrl">,
4443 <ref id="isdigit" name="isdigit">,
4444 <ref id="isgraph" name="isgraph">,
4445 <ref id="islower" name="islower">,
4446 <ref id="isprint" name="isprint">,
4447 <ref id="ispunct" name="ispunct">,
4448 <ref id="isspace" name="isspace">,
4449 <ref id="isxdigit" name="isxdigit">
4455 <sect1>isxdigit<label id="isxdigit"><p>
4459 <tag/Function/Check if a given character is a hexadecimal digit.
4460 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
4461 <tag/Declaration/<tt/int __fastcall__ isxdigit (int c);/
4462 <tag/Description/The function returns a non zero value if the given argument
4463 is a hexadecimal digit (0..9, a..f and A..F). The return value is zero if the
4464 character is anything else.
4465 <tag/Notes/<itemize>
4466 <item>When compiling with <tt/-Os/ the function is actually a macro. The
4467 inline sequence generated by the macro will not work correctly for values
4468 outside the range 0..255. <em/Note:/ The constant <tt/EOF/ is not part of
4469 this range. The non inline function may be accessed by <tt/#undef/'ing the
4471 <item>When compiling without <tt/-Os/, the function is only available as
4472 fastcall function, so it may only be used in presence of a prototype.
4474 <tag/Availability/ISO 9899
4476 <ref id="isalnum" name="isalnum">,
4477 <ref id="isalpha" name="isalpha">,
4478 <ref id="isascii" name="isascii">,
4479 <ref id="isblank" name="isblank">,
4480 <ref id="iscntrl" name="iscntrl">,
4481 <ref id="isdigit" name="isdigit">,
4482 <ref id="isgraph" name="isgraph">,
4483 <ref id="islower" name="islower">,
4484 <ref id="isprint" name="isprint">,
4485 <ref id="ispunct" name="ispunct">,
4486 <ref id="isspace" name="isspace">,
4487 <ref id="isupper" name="isupper">
4493 <sect1>itoa<label id="itoa"><p>
4497 <tag/Function/Convert an integer into a string.
4498 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
4499 <tag/Declaration/<tt/char* __fastcall__ itoa (int val, char* buf, int radix);/
4500 <tag/Description/<tt/itoa/ converts the integer <tt/val/ into a string using
4501 <tt/radix/ as the base.
4502 <tag/Notes/<itemize>
4503 <item>There are no provisions to prevent a buffer overflow.
4504 <item>If <tt/val/ contains <tt/INT_MIN/, the behaviour is undefined.
4505 <item>The function is non standard, so it is not available in strict ANSI mode.
4506 You should probably use <tt/sprintf/ instead.
4507 <item>The function is only available as fastcall function, so it may only be
4508 used in presence of a prototype.
4510 <tag/Availability/cc65
4512 <ref id="atoi" name="atoi">,
4513 <ref id="atol" name="atol">,
4514 <ref id="ltoa" name="ltoa">,
4515 <ref id="ultoa" name="ultoa">,
4516 <ref id="utoa" name="utoa">
4522 <sect1>joy_count<label id="joy_count"><p>
4526 <tag/Function/Return the number of joysticks supported by the current driver.
4527 <tag/Header/<tt/<ref id="joystick.h" name="joystick.h">/
4528 <tag/Declaration/<tt/unsigned char joy_count (void);/
4529 <tag/Description/The function returns a the number of joysticks supported
4530 by the current joystick driver.
4531 <tag/Notes/<itemize>
4532 <item>A joystick driver must be loaded using <ref id="joy_load_driver"
4533 name="joy_load_driver"> before calling this function.
4534 <item>The function returns the number of joysticks supported by the driver.
4535 There's no way to check for the number of actually connected joysticks.
4537 <tag/Availability/cc65
4539 <ref id="joy_load_driver" name="joy_load_driver">,
4540 <ref id="joy_read" name="joy_read">
4546 <sect1>joy_install<label id="joy_install"><p>
4550 <tag/Function/Install an already loaded driver and return an error code.
4551 <tag/Header/<tt/<ref id="joystick.h" name="joystick.h">/
4552 <tag/Declaration/<tt/unsigned char __fastcall__ joy_install (void* driver);/
4553 <tag/Description/The function installs a driver that was already loaded into
4554 memory (or linked statically to the program). It returns an error code
4555 (<tt/JOY_ERR_OK/ in case of success).
4556 <tag/Notes/<itemize>
4557 <item>The function is only available as fastcall function, so it may only be
4558 used in presence of a prototype.
4560 <tag/Availability/cc65
4562 <ref id="joy_load_driver" name="joy_load_driver">,
4563 <ref id="joy_uninstall" name="joy_uninstall">,
4564 <ref id="joy_unload" name="joy_unload">
4570 <sect1>joy_load_driver<label id="joy_load_driver"><p>
4574 <tag/Function/Load a driver from disk and install it.
4575 <tag/Header/<tt/<ref id="joystick.h" name="joystick.h">/
4576 <tag/Declaration/<tt/unsigned char __fastcall__ joy_load_driver (const char* driver);/
4577 <tag/Description/The function loads a driver with the given name from disk
4578 and installs it. An error code is returned, which is <tt/JOY_ERR_OK/ if the
4579 driver was successfully loaded and installed.
4580 <tag/Notes/<itemize>
4581 <item>The function is only available as fastcall function, so it may only be
4582 used in presence of a prototype.
4584 <tag/Availability/cc65
4586 <ref id="joy_install" name="joy_install">,
4587 <ref id="joy_uninstall" name="joy_uninstall">,
4588 <ref id="joy_unload" name="joy_unload">
4594 <sect1>joy_read<label id="joy_read"><p>
4598 <tag/Function/Read the status of a joystick.
4599 <tag/Header/<tt/<ref id="joystick.h" name="joystick.h">/
4600 <tag/Declaration/<tt/unsigned char __fastcall__ joy_read (unsigned char joystick);/
4601 <tag/Description/The function reads the status bits for a joystick. The number
4602 of the joystick is passed as parameter. The result may be examined by using one
4603 of the <tt/JOY_xxx/ macros from <ref id="joystick.h" name="joystick.h">.
4604 <tag/Notes/<itemize>
4605 <item>A joystick driver must be loaded using <ref id="joy_load_driver"
4606 name="joy_load_driver"> before calling this function.
4607 <item>The function is only available as fastcall function, so it may only be
4608 used in presence of a prototype.
4610 <tag/Availability/cc65
4612 <ref id="joy_count" name="joy_count">,
4613 <ref id="joy_load_driver" name="joy_load_driver">,
4614 <ref id="joy_unload" name="joy_unload">
4620 <sect1>joy_uninstall<label id="joy_uninstall"><p>
4624 <tag/Function/Uninstall the current joystick driver.
4625 <tag/Header/<tt/<ref id="joystick.h" name="joystick.h">/
4626 <tag/Declaration/<tt/unsigned char joy_uninstall (void);/
4627 <tag/Description/The function uninstalls the currently installed joystick
4628 driver. It does not remove the driver from memory. The function returns an
4629 error code, which is <tt/JOY_ERR_OK/ if the driver was successfully uninstalled.
4630 <tag/Notes/<itemize>
4631 <item>A joystick driver must be installed using <ref id="joy_install"
4632 name="joy_install"> before calling this function.
4634 <tag/Availability/cc65
4636 <ref id="joy_install" name="joy_install">,
4637 <ref id="joy_load_driver" name="joy_load_driver">,
4638 <ref id="joy_unload" name="joy_unload">
4644 <sect1>joy_unload<label id="joy_unload"><p>
4648 <tag/Function/Uninstall, then unload the current joystick driver.
4649 <tag/Header/<tt/<ref id="joystick.h" name="joystick.h">/
4650 <tag/Declaration/<tt/unsigned char joy_unload (void);/
4651 <tag/Description/The function uninstalls the currently installed joystick
4652 driver and removes it from memory. An error code is returned, which is
4653 <tt/JOY_ERR_OK/ if the driver was successfully uninstalled.
4654 <tag/Notes/<itemize>
4655 <item>A joystick driver must be loaded using <ref id="joy_load_driver"
4656 name="joy_load_driver"> before calling this function.
4658 <tag/Availability/cc65
4660 <ref id="joy_load_driver" name="joy_load_driver">
4666 <sect1>kbhit<label id="kbhit"><p>
4670 <tag/Function/Check if there's a key waiting in the keyboard buffer.
4671 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
4672 <tag/Declaration/<tt/unsigned char kbhit (void);/
4673 <tag/Description/The function returns a value of zero if there is no character
4674 waiting to be read from the keyboard. It returns non zero otherwise.
4675 <tag/Notes/<itemize>
4676 <item>If the system does not support a keyboard buffer (most systems
4677 do), the function is rather useless.
4679 <tag/Availability/cc65
4681 <ref id="cgetc" name="cgetc">,
4682 <ref id="cursor" name="cursor">
4688 <sect1>kbrepeat<label id="kbrepeat"><p>
4692 <tag/Function/Set the keyboard repeat mode.
4693 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
4694 <tag/Declaration/<tt/unsigned char __fastcall__ kbrepeat (unsigned char mode);/
4695 <tag/Description/This function changes which keys have automatic repeat when
4696 being held down for a certain time. Possible values are <tt/KBREPEAT_CURSOR/
4697 (repeat only cursor-related keys), <tt/KBREPEAT_NONE/ (no repeat for any
4698 keys), and <tt/KBREPEAT_ALL/ (repeat all keys). The old mode is returned, so
4699 it can be restored later.
4700 <tag/Notes/<itemize>
4701 <item>The function is available only as a fastcall function; so, it may be used
4702 only in the presence of a prototype.
4704 <tag/Availability/cc65
4710 <sect1>labs<label id="labs"><p>
4714 <tag/Function/Returns the absolute value of a long integer.
4715 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
4716 <tag/Declaration/<tt/long __fastcall__ labs (long v);/
4717 <tag/Description/<tt/labs/ returns the absolute value of the argument passed to
4719 <tag/Notes/<itemize>
4720 <item>The return value is undefined if <tt/LONG_MIN/ is passed to the function.
4721 <item>The function is only available as fastcall function, so it may only be
4722 used in presence of a prototype.
4724 <tag/Availability/ISO 9899
4726 <ref id="abs" name="abs">
4732 <sect1>ltoa<label id="ltoa"><p>
4736 <tag/Function/Convert a long integer into a string.
4737 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
4738 <tag/Declaration/<tt/char* __fastcall__ ltoa (long val, char* buf, int radix);/
4739 <tag/Description/<tt/itoa/ converts the long integer <tt/val/ into a string
4740 using <tt/radix/ as the base.
4741 <tag/Notes/<itemize>
4742 <item>There are no provisions to prevent a buffer overflow.
4743 <item>If <tt/val/ contains <tt/LONG_MIN/, the behaviour is undefined.
4744 <item>The function is non standard, so it is not available in strict ANSI mode.
4745 You should probably use <tt/sprintf/ instead.
4746 <item>The function is only available as fastcall function, so it may only be
4747 used in presence of a prototype.
4749 <tag/Availability/cc65
4751 <ref id="atoi" name="atoi">,
4752 <ref id="atol" name="atol">,
4753 <ref id="itoa" name="itoa">,
4754 <ref id="ultoa" name="ultoa">,
4755 <ref id="utoa" name="utoa">
4761 <sect1>localeconv<label id="localeconv"><p>
4765 <tag/Function/Returns a pointer to the current locale structure.
4766 <tag/Header/<tt/<ref id="locale.h" name="locale.h">/
4767 <tag/Declaration/<tt/struct lconv* localeconv (void);/
4768 <tag/Description/<tt/localeconv/ returns a pointer to the current locale
4770 <tag/Notes/<itemize>
4771 <item>cc65 supports only the "C" locale, so even after setting a new locale
4772 using <tt/<ref id="setlocale" name="setlocale">/, the structure returned will
4775 <tag/Availability/ISO 9899
4777 <ref id="setlocale" name="setlocale">
4783 <sect1>longjmp<label id="longjmp"><p>
4787 <tag/Function/Non local goto.
4788 <tag/Header/<tt/<ref id="setjmp.h" name="setjmp.h">/
4789 <tag/Declaration/<tt/void __fastcall__ longjmp (jmp_buf buf, int retval);/
4790 <tag/Description/The <tt/longjmp/ function restores a program context from the
4791 data in <tt/buf/, which must have been set by a preceeding call to
4792 <tt/<ref id="setjmp" name="setjmp">/. Program execution continues as if the
4793 call to <tt/<ref id="setjmp" name="setjmp">/ has just returned the value
4795 <tag/Notes/<itemize>
4796 <item>If the parameter <tt/retval/ is zero, the function will behave as if it
4797 was called with a value of one.
4798 <item>The function is only available as fastcall function, so it may only
4799 be used in presence of a prototype.
4801 <tag/Availability/ISO 9899
4803 <ref id="setjmp" name="setjmp">
4809 <sect1>malloc<label id="malloc"><p>
4813 <tag/Function/Allocate dynamic memory.
4814 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
4815 <tag/Declaration/<tt/void* __fastcall__ malloc (size_t size);/
4816 <tag/Description/<tt/malloc/ allocates size bytes on the heap and returns a
4817 pointer to the allocated memory block. On error (not enough memory available),
4818 <tt/malloc/ returns <tt/NULL/.
4819 <tag/Notes/<itemize>
4820 <item>The function is only available as fastcall function, so it may only
4821 be used in presence of a prototype.
4823 <tag/Availability/ISO 9899
4825 <ref id="_heapadd" name="_heapadd">,
4826 <ref id="_heapblocksize" name="_heapblocksize">,
4827 <ref id="_heapmaxavail" name="_heapmaxavail">,
4828 <ref id="_heapmemavail" name="_heapmemavail">,
4829 <ref id="calloc" name="calloc">,
4830 <ref id="free" name="free">,
4831 <ref id="realloc" name="realloc">,
4832 <ref id="strdup" name="strdup">
4838 <sect1>memchr<label id="memchr"><p>
4842 <tag/Function/Search for a character in a block of raw memory.
4843 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4844 <tag/Declaration/<tt/void* __fastcall__ strchr (const void* mem, int c, size_t count);/
4845 <tag/Description/The <tt/memchr/ function locates the first occurrence of <tt/c/
4846 (converted to a char) in the block of raw memory string pointed to by <tt/mem/
4847 that is of size <tt/count/. Upon completion, the function returns a pointer to
4848 the character found, or a null pointer if the character was not found.
4849 <tag/Notes/<itemize>
4850 <item>The function is only available as fastcall function, so it may only
4851 be used in presence of a prototype.
4853 <tag/Availability/ISO 9899
4855 <ref id="strchr" name="strchr">
4861 <sect1>memcmp<label id="memcmp"><p>
4865 <tag/Function/Compare two memory areas.
4866 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4867 <tag/Declaration/<tt/int __fastcall__ memcmp (const void* p1, const void* p2, size_t count);/
4868 <tag/Description/<tt/memcmp/ compares <tt/count/ bytes from the memory area
4869 pointed to by <tt/p1/ into the memory area pointed to by <tt/p2/. It returns a value that is less than
4870 zero if <tt/p1/ is less than <tt/p2/, zero if <tt/p1/ is the same as <tt/p2/,
4871 and a value greater than zero if <tt/p1/ is greater than <tt/p2/.
4872 <tag/Notes/<itemize>
4873 <item>The function is only available as fastcall function, so it may only
4874 be used in presence of a prototype.
4876 <tag/Availability/ISO 9899
4878 <ref id="strcmp" name="strcmp">,
4879 <ref id="memmove" name="memmove">,
4880 <ref id="memset" name="memset">
4886 <sect1>memcpy<label id="memcpy"><p>
4890 <tag/Function/Copy a memory area.
4891 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4892 <tag/Declaration/<tt/void* __fastcall__ memcpy (void* dest, const void* src, size_t count);/
4893 <tag/Description/<tt/memcpy/ copies <tt/count/ bytes from the memory area
4894 pointed to by <tt/src/ into the memory area pointed to by <tt/dest/. It returns
4896 <tag/Notes/<itemize>
4897 <item>The result is undefined if the memory areas do overlap. Use
4898 <tt/<ref id="memmove" name="memmove">/ to copy overlapping memory areas.
4899 <item>The function is only available as fastcall function, so it may only
4900 be used in presence of a prototype.
4902 <tag/Availability/ISO 9899
4904 <ref id="_swap" name="_swap">,
4905 <ref id="memmove" name="memmove">,
4906 <ref id="memset" name="memset">
4912 <sect1>memmove<label id="memmove"><p>
4916 <tag/Function/Copy a memory area.
4917 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4918 <tag/Declaration/<tt/void* __fastcall__ memmove (void* dest, const void* src, size_t count);/
4919 <tag/Description/<tt/memmove/ copies <tt/count/ bytes from the memory area
4920 pointed to by <tt/src/ into the memory area pointed to by <tt/dest/. It returns
4922 <tag/Notes/<itemize>
4923 <item>While <tt/memmove/ allows the memory areas to overlap, it has some
4924 additional overhead compared to <tt/<ref id="memcpy" name="memcpy">/.
4925 <item>The function is only available as fastcall function, so it may only
4926 be used in presence of a prototype.
4928 <tag/Availability/ISO 9899
4930 <ref id="_swap" name="_swap">,
4931 <ref id="memcpy" name="memcpy">,
4932 <ref id="memset" name="memset">
4938 <sect1>memset<label id="memset"><p>
4942 <tag/Function/Fill a memory area.
4943 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4944 <tag/Declaration/<tt/void* __fastcall__ memset (void* p, int val, size_t count);/
4945 <tag/Description/<tt/memset/ fills the memory area pointed to by <tt/p/ with
4946 the value <tt/val/. The function returns <tt/p/.
4947 <tag/Notes/<itemize>
4948 <item>The function is only available as fastcall function, so it may only
4949 be used in presence of a prototype.
4951 <tag/Availability/ISO 9899
4953 <ref id="_swap" name="_swap">,
4954 <ref id="bzero" name="bzero">,
4955 <ref id="memcpy" name="memcpy">,
4956 <ref id="memmove" name="memmove">
4962 <sect1>mod_free<label id="mod_free"><p>
4966 <tag/Function/Free a relocatable module.
4967 <tag/Header/<tt/<ref id="modload.h" name="modload.h">/
4968 <tag/Declaration/<tt/void __fastcall__ mod_free (void* module);/
4969 <tag/Description/The function will free a module loaded into memory by use of
4970 the <tt/<ref id="mod_load" name="mod_load">/ function.
4971 <tag/Notes/<itemize>
4972 <item>The pointer passed as parameter is the pointer to the module memory,
4973 not the pointer to the control structure.
4974 <item>The function is available only as a fastcall function; so, it may be used
4975 only in the presence of a prototype.
4977 <tag/Availability/cc65
4979 <ref id="mod_load" name="mod_load">
4985 <sect1>mod_load<label id="mod_load"><p>
4989 <tag/Function/Load a relocatable module.
4990 <tag/Header/<tt/<ref id="modload.h" name="modload.h">/
4991 <tag/Declaration/<tt/unsigned char __fastcall__ mod_load (struct mod_ctrl* ctrl);/
4992 <tag/Description/The function will load a code module into memory and relocate
4993 it. The function will return an error code. If <tt/MLOAD_OK/ is returned, the
4994 outgoing fields in the passed <tt/mod_ctrl/ struct contain information about
4995 the module just loaded. Possible error codes are:
4997 <item><tt/MLOAD_OK/ - Module load successful
4998 <item><tt/MLOAD_ERR_READ/ - Read error
4999 <item><tt/MLOAD_ERR_HDR/ - Header error
5000 <item><tt/MLOAD_ERR_OS/ - Wrong operating system
5001 <item><tt/MLOAD_ERR_FMT/ - Data format error
5002 <item><tt/MLOAD_ERR_MEM/ - Not enough memory
5004 <tag/Notes/<itemize>
5005 <item>The <htmlurl url="ld65.html" name="ld65"> linker is needed to create
5006 relocatable o65 modules for use with this function.
5007 <item>The function is available only as a fastcall function; so, it may be used
5008 only in the presence of a prototype.
5010 <tag/Availability/cc65
5012 <ref id="mod_free" name="mod_free">
5018 <sect1>mouse_setbox<label id="mouse_setbox"><p>
5022 <tag/Function/Specify a bounding box for the mouse cursor.
5023 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
5024 <tag/Declaration/<tt/void __fastcall__ mouse_setbox (const struct mouse_box* box);/
5025 <tag/Description/The function allows to set a bounding box for mouse movement.
5026 <tag/Notes/<itemize>
5027 <item>The function does not check if the mouse cursor is currently within the
5028 given rectangle. Placing the mouse cursor within the bounding box is the
5029 responsibility of the programmer.
5030 <item>While the bounding box may be larger than the actual screen size, the
5031 standard mouse cursor draw routines may fail to set the cursor to coordinates
5032 outside of the screen area. Depending on the platform, you may have to supply
5033 your own mouse cursor routines.
5034 <item>The function is only available as fastcall function, so it may only be
5035 used in presence of a prototype.
5037 <tag/Availability/cc65
5039 <ref id="mouse_getbox" name="mouse_getbox">,
5040 <ref id="mouse_move" name="mouse_move">
5046 <sect1>mouse_getbox<label id="mouse_getbox"><p>
5050 <tag/Function/Return the current bounding box for the mouse cursor.
5051 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
5052 <tag/Declaration/<tt/void __fastcall__ mouse_getbox (struct mouse_box* box);/
5053 <tag/Description/The function queries the current bounding box for mouse
5055 <tag/Notes/<itemize>
5056 <item>The function is only available as fastcall function, so it may only be
5057 used in presence of a prototype.
5059 <tag/Availability/cc65
5061 <ref id="mouse_move" name="mouse_move">,
5062 <ref id="mouse_setbox" name="mouse_setbox">
5068 <sect1>mouse_buttons<label id="mouse_buttons"><p>
5072 <tag/Function/Return a bit mask encoding the state of the mouse buttons.
5073 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
5074 <tag/Declaration/<tt/unsigned char mouse_buttons (void);/
5075 <tag/Description/The function returns a bit mask that encodes the state of the
5076 mouse buttons. You may use the <tt/MOUSE_BTN_XXX/ flags to decode the function
5078 <tag/Availability/cc65
5080 <ref id="mouse_info" name="mouse_info">,
5081 <ref id="mouse_pos" name="mouse_pos">
5087 <sect1>mouse_geterrormsg<label id="mouse_geterrormsg"><p>
5091 <tag/Function/Return a readable error message for an error code.
5092 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
5093 <tag/Declaration/<tt/const char* __fastcall__ mouse_geterrormsg (unsigned char
5095 <tag/Description/The function returns an error message (in english) for the
5096 error code passed parameter.
5097 <tag/Notes/<itemize>
5098 <item>The function will return "Unknown error" for invalid error codes.
5099 <item>The function is only available as fastcall function, so it may only be
5100 used in presence of a prototype.
5102 <tag/Availability/cc65
5104 <ref id="mouse_load_driver" name="mouse_load_driver">,
5105 <ref id="mouse_uninstall" name="mouse_uninstall">,
5106 <ref id="mouse_unload" name="mouse_unload">
5112 <sect1>mouse_hide<label id="mouse_hide"><p>
5116 <tag/Function/Hide the mouse pointer.
5117 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
5118 <tag/Declaration/<tt/void mouse_hide (void);/
5119 <tag/Description/The function hides the mouse pointer. It manages a counter
5120 that is shared between <tt/<ref id="mouse_show" name="mouse_show">/ and
5121 <tt/mouse_hide/ so that every call call to <tt/mouse_hide/ must be followed by
5122 a call to <tt/<ref id="mouse_show" name="mouse_show">/ to make the mouse cursor
5124 <tag/Availability/cc65
5126 <ref id="mouse_show" name="mouse_show">
5132 <sect1>mouse_info<label id="mouse_info"><p>
5136 <tag/Function/Return the state of the mouse buttons and the position of the
5138 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
5139 <tag/Declaration/<tt/void __fastcall__ mouse_info (struct mouse_info* info);/
5140 <tag/Description/The function returns the state of the mouse buttons and the
5141 position of the mouse in the <tt/mouse_info/ structure passed as parameter.
5142 <tag/Notes/<itemize>
5143 <item>The <tt/mouse_info/ struct is a superset of the <tt/mouse_pos/ struct,
5144 so if you just need the mouse position, call <tt/<ref id="mouse_pos"
5145 name="mouse_pos">/ instead.
5146 <item>The function is only available as fastcall function, so it may only be
5147 used in presence of a prototype.
5149 <tag/Availability/cc65
5151 <ref id="mouse_buttons" name="mouse_buttons">,
5152 <ref id="mouse_pos" name="mouse_pos">
5158 <sect1>mouse_install<label id="mouse_install"><p>
5162 <tag/Function/Install an already loaded mouse driver.
5163 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
5164 <tag/Declaration/<tt/unsigned char __fastcall__ mouse_install (const struct
5165 mouse_callbacks* c, void* driver);/
5166 <tag/Description/The function installs an already loaded mouse driver and
5167 returns an error code. The <tt/mouse_callbacks/ structure passed as first
5168 parameter contains pointers to routines needed to move or hide/show the mouse
5169 pointer. Defaults for these routines are supplied by the library, so if you
5170 can live with these defaults (which are platform specific), just pass a
5171 pointer to <tt/mouse_def_callbacks/. The function may be used to install a
5172 driver linked statically to the program.
5173 <tag/Notes/<itemize>
5174 <item>Not all drivers are able to detect if the supported hardware is really
5176 <item>After installing a driver, the mouse cursor is hidden.
5177 <item>The function is only available as fastcall function, so it may only be
5178 used in presence of a prototype.
5180 <tag/Availability/cc65
5182 <ref id="mouse_load_driver" name="mouse_load_driver">,
5183 <ref id="mouse_uninstall" name="mouse_uninstall">,
5184 <ref id="mouse_unload" name="mouse_unload">
5190 <sect1>mouse_ioctl<label id="mouse_ioctl"><p>
5194 <tag/Function/Call the driver specific ioctl function.
5195 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
5196 <tag/Declaration/<tt/unsigned char __fastcall__ mouse_ioctl (unsigned char code, void* data);/
5197 <tag/Description/The function calls the IOCTL entry in the mouse driver,
5198 which is driver specific. The <tt/code/ parameter will choose between
5199 different IOCTL functions, and the <tt/data/ depends on code. The
5200 function returns an error code. The purpose of this function is to allow
5201 for driver specific extensions. See the documentation for a specific mouse
5202 driver for supported ioctl calls.
5203 <tag/Notes/<itemize>
5204 <item>Calling this function is non portable, because each driver may
5205 implement different ioctl calls (or none at all).
5206 <item>The function is only available as fastcall function, so it may only be
5207 used in presence of a prototype.
5209 <tag/Availability/cc65
5215 <sect1>mouse_load_driver<label id="mouse_load_driver"><p>
5219 <tag/Function/Load and initialize a mouse driver.
5220 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
5221 <tag/Declaration/<tt/unsigned char __fastcall__ mouse_load_driver (const struct
5222 mouse_callbacks* c, const char* driver);/
5223 <tag/Description/Load a mouse driver into memory and initialize it. The
5224 function returns an error code that tells if the call has been successful. The
5225 <tt/mouse_callbacks/ structure passed as first parameter contains pointers to
5226 routines needed to move or hide/show the mouse pointer. Defaults for these
5227 routines are supplied by the library, so if you can live with these defaults
5228 (which are platform specific), just pass a pointer to <tt/mouse_def_callbacks/.
5229 <tag/Notes/<itemize>
5230 <item>The driver is loaded by name, so currently you must know the type of
5231 mouse that should be supported. There is no autodetect capability.
5232 <item>Not all drivers are able to detect if the supported hardware is really
5234 <item>After installing a driver, the mouse cursor is hidden.
5235 <item>The function is only available as fastcall function, so it may only be
5236 used in presence of a prototype.
5238 <tag/Availability/cc65
5240 <ref id="mouse_install" name="mouse_install">,
5241 <ref id="mouse_uninstall" name="mouse_uninstall">,
5242 <ref id="mouse_unload" name="mouse_unload">
5248 <sect1>mouse_move<label id="mouse_move"><p>
5252 <tag/Function/Move the mouse cursor to a specific position.
5253 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
5254 <tag/Declaration/<tt/void __fastcall__ mouse_move (int x, int y);/
5255 <tag/Description/The function updates the mouse position. If the mouse cursor
5256 is visible, it is shown at the new position.
5257 <tag/Notes/<itemize>
5258 <item>The function does not check if the new position is within the bounding
5259 box specified with <tt/<ref id="mouse_setbox" name="mouse_setbox">/.
5260 <item>The function is only available as fastcall function, so it may only be
5261 used in presence of a prototype.
5263 <tag/Availability/cc65
5265 <ref id="mouse_getbox" name="mouse_getbox">,
5266 <ref id="mouse_setbox" name="mouse_setbox">
5272 <sect1>mouse_pos<label id="mouse_pos"><p>
5276 <tag/Function/Return the position of the mouse.
5277 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
5278 <tag/Declaration/<tt/void __fastcall__ mouse_pos (struct mouse_pos* pos);/
5279 <tag/Description/The function returns the position of the mouse in the
5280 <tt/mouse_pos/ structure passed as parameter.
5281 <tag/Notes/<itemize>
5282 <item>The <tt/mouse_pos/ struct is a subset of the <tt/mouse_info/ struct,
5283 so if you do also need the mouse buttons, call <tt/<ref id="mouse_info"
5284 name="mouse_info">/ instead.
5285 <item>The function is only available as fastcall function, so it may only be
5286 used in presence of a prototype.
5288 <tag/Availability/cc65
5290 <ref id="mouse_buttons" name="mouse_buttons">,
5291 <ref id="mouse_info" name="mouse_info">
5297 <sect1>mouse_show<label id="mouse_show"><p>
5301 <tag/Function/Show the mouse pointer.
5302 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
5303 <tag/Declaration/<tt/void mouse_show (void);/
5304 <tag/Description/The function shows the mouse pointer. It manages a counter
5305 that is shared between <tt/<ref id="mouse_hide" name="mouse_hide">/ and
5306 <tt/mouse_show/. The mouse cursor is visible if there was one more call to
5307 <tt/mouse_show/ than to <tt/<ref id="mouse_hide" name="mouse_hide">/.
5308 <tag/Availability/cc65
5310 <ref id="mouse_hide" name="mouse_hide">
5316 <sect1>mouse_uninstall<label id="mouse_uninstall"><p>
5320 <tag/Function/Uninstall an already loaded mouse driver.
5321 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
5322 <tag/Declaration/<tt/unsigned char mouse_uninstall (void);/
5323 <tag/Description/The function uninstalls an already loaded mouse driver but
5324 don't removes it from memory.
5325 <tag/Notes/<itemize>
5326 <item>If the driver has been loaded using <tt/<ref id="mouse_load_driver"
5327 name="mouse_load_driver">/, <tt/<ref id="mouse_unload" name="mouse_unload">/
5328 should be used instead of <tt/mouse_uninstall/ so the driver is also removed
5331 <tag/Availability/cc65
5333 <ref id="mouse_install" name="mouse_install">,
5334 <ref id="mouse_load_driver" name="mouse_load_driver">,
5335 <ref id="mouse_unload" name="mouse_unload">
5341 <sect1>mouse_unload<label id="mouse_unload"><p>
5345 <tag/Function/Unload a mouse driver.
5346 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
5347 <tag/Declaration/<tt/unsigned char mouse_unload (void);/
5348 <tag/Description/The function unloads a loaded mouse driver and frees all
5349 memory allocated for the driver.
5350 <tag/Notes/<itemize>
5351 <item>The function does nothing if no driver is loaded.
5353 <tag/Availability/cc65
5355 <ref id="mouse_install" name="mouse_install">,
5356 <ref id="mouse_load_driver" name="mouse_load_driver">,
5357 <ref id="mouse_uninstall" name="mouse_uninstall">
5363 <sect1>offsetof<label id="offsetof"><p>
5367 <tag/Function/Calculate the offset of a struct or union member.
5368 <tag/Header/<tt/<ref id="stddef.h" name="stddef.h">/
5369 <tag/Declaration/<tt/size_t offsetof (type, member);/
5370 <tag/Description/<tt/offsetof/ calculates the address offset of a <tt/struct/
5371 or <tt/union/ member.
5372 <tag/Notes/<itemize>
5373 <item>The function is actually a macro.
5375 <tag/Availability/ISO 9899
5381 <sect1>open<label id="open"><p>
5385 <tag/Function/Open and possibly create a file.
5386 <tag/Header/<tt/<ref id="fcntl.h" name="fcntl.h">/
5387 <tag/Declaration/<tt/int open (const char* name, int flags, ...);/
5388 <tag/Description/<tt/open/ opens a file and returns the file descriptor
5389 associated with it. On error, -1 is returned and an error code is stored in
5390 <tt/errno/. Several flags may be passed to <tt/open/ that change the behaviour.
5391 <tag/Notes/<itemize>
5392 <item>POSIX specifies an additional <tt/mode/ argument that may be passed to
5393 open, which is used as the permission mask when a new file is created. While
5394 cc65 allows to pass this argument, it is ignored.
5396 <tag/Availability/POSIX 1003.1
5398 <ref id="close" name="close">,
5399 <ref id="creat" name="creat">
5405 <sect1>opendir<label id="opendir"><p>
5409 <tag/Function/Open a directory.
5410 <tag/Header/<tt/<ref id="dirent.h" name="dirent.h">/
5411 <tag/Declaration/<tt/DIR* __fastcall__ opendir (const char* name);/
5412 <tag/Description/<tt/opendir/ opens a directory and returns the direcory
5413 descriptor associated with it. On error, NULL is returned and an error code is
5414 stored in <tt/errno/.
5415 <tag/Notes/<itemize>
5416 <item>The function is only available as fastcall function, so it may only
5417 be used in presence of a prototype.
5419 <tag/Availability/POSIX 1003.1
5421 <ref id="closedir" name="closedir">,
5422 <ref id="readdir" name="readdir">
5428 <sect1>peekbsys<label id="peekbsys"><p>
5432 <tag/Function/Read one byte from a location in the system bank.
5433 <tag/Header/<tt/<ref id="cbm610.h" name="cbm610.h">/,
5434 <tt/<ref id="cbm510.h" name="cbm510.h">/
5435 <tag/Declaration/<tt/unsigned char __fastcall__ peekbsys (unsigned addr);/
5436 <tag/Description/<tt/peekbsys/ reads one byte from the given address in the
5437 system bank (bank 15) of the CBM PET-II machines and returns it.
5438 <tag/Notes/<itemize>
5439 <item>The function is only available as fastcall function, so it may only
5440 be used in presence of a prototype.
5441 <item>This function may be a macro depending on the compiler options. The
5442 actual function is accessible by #undef'ing the macro.
5444 <tag/Availability/cc65
5446 <ref id="PEEK" name="PEEK">,
5447 <ref id="PEEKW" name="PEEKW">,
5448 <ref id="peekwsys" name="peekwsys">,
5449 <ref id="pokebsys" name="pokebsys">,
5450 <ref id="pokewsys" name="pokewsys">
5456 <sect1>peekwsys<label id="peekwsys"><p>
5460 <tag/Function/Read one word from a location in the system bank.
5461 <tag/Header/<tt/<ref id="cbm610.h" name="cbm610.h">/,
5462 <tt/<ref id="cbm510.h" name="cbm510.h">/
5463 <tag/Declaration/<tt/unsigned __fastcall__ peekwsys (unsigned addr);/
5464 <tag/Description/<tt/peekwsys/ reads one word from the given address in the
5465 system bank (bank 15) of the CBM PET-II machines and returns it. Following
5466 the usual 6502 conventions, the low byte is read from <tt/addr/, and the
5467 high byte is read from <tt/addr+1/.
5468 <tag/Notes/<itemize>
5469 <item>The function is only available as fastcall function, so it may only
5470 be used in presence of a prototype.
5471 <item>The order in which the two bytes are read is undefined.
5473 <tag/Availability/cc65
5475 <ref id="PEEK" name="PEEK">,
5476 <ref id="PEEKW" name="PEEKW">,
5477 <ref id="peekbsys" name="peekbsys">,
5478 <ref id="pokebsys" name="pokebsys">,
5479 <ref id="pokewsys" name="pokewsys">
5485 <sect1>perror<label id="perror"><p>
5489 <tag/Function/Print an error message for the error in <tt/errno/.
5490 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
5491 <tag/Declaration/<tt/void __fastcall__ perror (const char* s);/
5492 <tag/Description/<tt/perror/ prints an error message to <tt/stderr/. If <tt/s/
5493 is not <tt/NULL/ and not an empty string, it is printed followed by a colon and
5494 a blank. Then the error message for the current contents of <tt/errno/ is
5495 printed followed by a newline. The message output is the same as returned by
5496 <tt/<ref id="strerror" name="strerror">/ with an argument of <tt/errno/.
5497 <tag/Notes/<itemize>
5498 <item>The function is only available as fastcall function, so it may only
5499 be used in presence of a prototype.
5501 <tag/Availability/ISO 9899
5503 <ref id="_poserror" name="_poserror">,
5504 <ref id="strerror" name="strerror">
5510 <sect1>pokebsys<label id="pokebsys"><p>
5514 <tag/Function/Write one byte to a location in the system bank.
5515 <tag/Header/<tt/<ref id="cbm610.h" name="cbm610.h">/,
5516 <tt/<ref id="cbm510.h" name="cbm510.h">/
5517 <tag/Declaration/<tt/void __fastcall__ pokebsys (unsigned addr, unsigned char val);/
5518 <tag/Description/<tt/pokebsys/ writes one byte to the given address in the
5519 system bank (bank 15) of the CBM PET-II machines.
5520 <tag/Notes/<itemize>
5521 <item>The function is only available as fastcall function, so it may only
5522 be used in presence of a prototype.
5524 <tag/Availability/cc65
5526 <ref id="POKE" name="POKE">,
5527 <ref id="POKEW" name="POKEW">,
5528 <ref id="peekbsys" name="peekbsys">,
5529 <ref id="peekwsys" name="peekwsys">,
5530 <ref id="pokewsys" name="pokewsys">
5536 <sect1>pokewsys<label id="pokewsys"><p>
5540 <tag/Function/Write one word to a location in the system bank.
5541 <tag/Header/<tt/<ref id="cbm610.h" name="cbm610.h">/,
5542 <tt/<ref id="cbm510.h" name="cbm510.h">/
5543 <tag/Declaration/<tt/void __fastcall__ pokewsys (unsigned addr, unsigned val);/
5544 <tag/Description/<tt/pokewsys/ writes one word to the given address in the
5545 system bank (bank 15) of the CBM PET-II machines. Following the usual 6502
5546 conventions, the low byte of <tt/val/ is written to <tt/addr/, and the
5547 high byte is written to <tt/addr+1/.
5548 <tag/Notes/<itemize>
5549 <item>The function is only available as fastcall function, so it may only
5550 be used in presence of a prototype.
5551 <item>The order in which the two bytes are written is undefined.
5553 <tag/Availability/cc65
5555 <ref id="POKE" name="POKE">,
5556 <ref id="POKEW" name="POKEW">,
5557 <ref id="peekbsys" name="peekbsys">,
5558 <ref id="peekwsys" name="peekwsys">,
5559 <ref id="pokebsys" name="pokebsys">
5565 <sect1>qsort<label id="qsort"><p>
5569 <tag/Function/Sort an array.
5570 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
5571 <tag/Declaration/<tt/void __fastcall__ qsort (void* base, size_t count,
5572 size_t size, int __fastcall__ (* compare) (const void*, const void*));/
5573 <tag/Description/<tt/qsort/ sorts an array according to a given compare
5574 function <tt/compare/. <tt/base/ is the address of the array, <tt/count/
5575 is the number of elements, <tt/size/ the size of an element and <tt/compare/
5576 the function used to compare the members.
5577 <tag/Notes/<itemize>
5578 <item>If there are multiple members with the same key, the order after calling
5579 the function is undefined.
5580 <item>The function is only available as fastcall function, so it may only
5581 be used in presence of a prototype.
5582 <item>The function to which <tt/compare/ points must have the <tt/fastcall/
5585 <tag/Availability/ISO 9899
5587 <ref id="bsearch" name="bsearch">
5593 <sect1>raise<label id="raise"><p>
5597 <tag/Function/Send a signal to the executing program.
5598 <tag/Header/<tt/<ref id="signal.h" name="signal.h">/
5599 <tag/Declaration/<tt/int __fastcall__ raise (int sig);/
5600 <tag/Description/<tt/raise/ sends the given signal to the program. If the
5601 program has installed a signal handler for the signal, this signal handler
5602 will be executed. If no handler has been installed, the default action for
5603 the raised signal will be taken. The function returns zero on success,
5605 <tag/Notes/<itemize>
5606 <item>The function is only available as fastcall function, so it may only
5607 be used in presence of a prototype.
5609 <tag/Availability/ISO 9899
5611 <ref id="abort" name="abort">,
5612 <ref id="signal" name="signal">
5618 <sect1>rand<label id="rand"><p>
5622 <tag/Function/Return a pseudo random number.
5623 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
5624 <tag/Declaration/<tt/int rand (void);/
5625 <tag/Description/The function returns a pseudo random number
5626 between 0 and <tt/RAND_MAX/ (exclusive).
5627 <tag/Notes/<itemize>
5628 <item>Without using <tt><ref id="srand" name="srand"></tt>, always the same
5629 flow of numbers is generated.
5630 <item>On startup, the function behaves as if <ref id="srand" name="srand">
5631 had been used with an argument of 1.
5633 <tag/Availability/ISO 9899
5635 <ref id="_randomize" name="_randomize">,
5636 <ref id="srand" name="srand">
5642 <sect1>readdir<label id="readdir"><p>
5646 <tag/Function/Read a directory.
5647 <tag/Header/<tt/<ref id="dirent.h" name="dirent.h">/
5648 <tag/Declaration/<tt/struct dirent* __fastcall__ readdir (DIR* dir);/
5649 <tag/Description/<tt/readdir/ reads the next directory entry from the directory
5650 stream pointed to by <tt/dir/. It stores the data in a <tt/dirent/ structure
5651 and returns a pointer to it. If the end of directory is reached, or an error
5652 occurs, NULL is returned. In case of errors, an error code is stored into
5654 <tag/Notes/<itemize>
5655 <item>The function is only available as fastcall function, so it may only
5656 be used in presence of a prototype.
5657 <item>The returned pointer may point to a statically allocated instance of
5658 <tt/struct dirent/, so it may get overwritten by subsequent calls to
5660 <item>On several platforms, namely the CBMs and the Atari, the disk drives get
5661 confused when opening/closing files between directory reads. So for example a
5662 program that reads the list of files on a disk, and after each call to
5663 <tt/readdir/, opens the file to process it, will fail.<newline>
5664 Possible solutions are reading the directory into memory before processing the
5665 file list, or to reset the directory by seeking to the correct position after
5666 opening/closing a file:
5668 seekdir (DIR, telldir (DIR));
5670 Platforms known to work without problems are: Apple.
5672 <tag/Availability/POSIX 1003.1
5674 <ref id="closedir" name="closedir">,
5675 <ref id="opendir" name="opendir">
5681 <sect1>realloc<label id="realloc"><p>
5685 <tag/Function/Change the size of an allocated memory block.
5686 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
5687 <tag/Declaration/<tt/void* __fastcall__ realloc (void* block, size_t size);/
5688 <tag/Description/<tt/realloc/ changes the size of the memory block pointed to
5689 by <tt/block/ to <tt/size/ bytes. If <tt/block/ is <tt/NULL/, <tt/realloc/
5690 behaves as if <tt/malloc/ had been called. If <tt/size/ is zero, <tt/realloc/
5691 behaves as if <tt/free/ had been called. On error (not enough memory
5692 available), <tt/realloc/ returns <tt/NULL/.
5693 <tag/Notes/<itemize>
5694 <item>The part of the memory block that is returned will have its contents
5696 <item>This function is somewhat dangerous to use. Be careful to save the
5697 pointer you're passing somewhere else, otherwise
5699 ptr = realloc (ptr, size);
5701 will loose your only copy of <tt/ptr/ if <tt/realloc/ returns <tt/NULL/.
5702 <item>The function is only available as fastcall function, so it may only
5703 be used in presence of a prototype.
5705 <tag/Availability/ISO 9899
5707 <ref id="_heapadd" name="_heapadd">,
5708 <ref id="_heapblocksize" name="_heapblocksize">,
5709 <ref id="_heapmaxavail" name="_heapmaxavail">,
5710 <ref id="_heapmemavail" name="_heapmemavail">,
5711 <ref id="calloc" name="calloc">,
5712 <ref id="free" name="free">,
5713 <ref id="realloc" name="realloc">
5719 <sect1>remove<label id="remove"><p>
5723 <tag/Function/Delete a file.
5724 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
5725 <tag/Declaration/<tt/int __fastcall__ remove (const char* name);/
5726 <tag/Description/<tt/remove/ deletes the file with the given name. On success,
5727 zero is returned. On error, -1 is returned and <tt/errno/ is set to an error
5728 code describing the reason for the failure.
5729 <tag/Notes/<itemize>
5730 <item>This function is not available on all cc65 targets (depends on the
5731 availability of file I/O).
5732 <item>The function is only available as fastcall function, so it may only
5733 be used in presence of a prototype.
5735 <tag/Availability/ISO 9899
5737 <ref id="rename" name="rename">,
5738 <ref id="unlink" name="unlink">
5741 #include <stdio.h>
5743 #define FILENAME "helloworld"
5745 if (remove (FILENAME) == 0) {
5746 printf ("We deleted %s successfully\n", FILENAME);
5748 printf ("There was a problem deleting %s\n", FILENAME);
5755 <sect1>rename<label id="rename"><p>
5759 <tag/Function/Rename a file.
5760 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
5761 <tag/Declaration/<tt/int __fastcall__ rename (const char* oldname, const char* newname);/
5762 <tag/Description/<tt/rename/ renames a file (gives it a new name). On success,
5763 zero is returned. On error, -1 is returned and <tt/errno/ is set to an error
5764 code describing the reason for the failure.
5765 <tag/Notes/<itemize>
5766 <item>This function is not available on all cc65 targets (depends on the
5767 capabilities of the storage devices).
5768 <item>The function is only available as fastcall function, so it may only
5769 be used in presence of a prototype.
5771 <tag/Availability/ISO 9899
5773 <ref id="remove" name="remove">
5776 #include <stdio.h>
5778 #define OLDNAME "textfile.txt"
5779 #define NEWNAME "textfile.bak"
5781 if (rename (OLDNAME, NEWNAME) == 0) {
5782 printf ("Renamed %s to %s\n", OLDNAME, NEWNAME);
5784 printf ("Error renaming %s to %s\n", OLDNAME, NEWNAME);
5791 <sect1>reset_brk<label id="reset_brk"><p>
5795 <tag/Function/Resets the break vector to its original value.
5796 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
5797 <tag/Declaration/<tt/void reset_brk (void);/
5798 <tag/Description/<tt/reset_brk/ resets the break vector to the value it had
5799 before a call to <tt/set_brk/.
5800 <tag/Notes/<itemize>
5801 <item>The break vector is reset on program termination, so it's not strictly
5802 necessary to call this function as a part of your clean-up when exitting the program.
5804 <tag/Availability/cc65
5806 <ref id="reset_irq" name="reset_irq">,
5807 <ref id="set_brk" name="set_brk">,
5808 <ref id="set_irq" name="set_irq">
5814 <sect1>reset_irq<label id="reset_irq"><p>
5818 <tag/Function/Resets the C level interrupt request vector.
5819 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
5820 <tag/Declaration/<tt/void reset_irq (void);/
5821 <tag/Description/<tt/reset_irq/ resets the C level interrupt request vector.
5822 <tag/Notes/<itemize>
5823 <item>The interrupt vector is reset on program termination, so it's not strictly
5824 necessary to call this function as a part of your clean-up when exitting the program.
5826 <tag/Availability/cc65
5828 <ref id="reset_brk" name="reset_brk">,
5829 <ref id="set_brk" name="set_brk">,
5830 <ref id="set_irq" name="set_irq">
5836 <sect1>revers<label id="revers"><p>
5840 <tag/Function/Control revers character display.
5841 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
5842 <tag/Declaration/<tt/unsigned char __fastcall__ revers (unsigned char onoff);/
5843 <tag/Description/If the argument is non zero, the function enables reverse
5844 character display. If the argument is zero, reverse character display is
5845 switched off. The old value of the setting is returned.
5846 <tag/Notes/<itemize>
5847 <item>The function may not be supported by the hardware, in which case
5848 the call is ignored.
5849 <item>The function is only available as fastcall function, so it may only
5850 be used in presence of a prototype.
5852 <tag/Availability/cc65
5854 <ref id="textcolor" name="textcolor">
5860 <sect1>rewinddir<label id="rewinddir"><p>
5864 <tag/Function/Reset a directory stream.
5865 <tag/Header/<tt/<ref id="dirent.h" name="dirent.h">/
5866 <tag/Declaration/<tt/void __fastcall__ rewinddir (DIR* dir);/
5867 <tag/Description/<tt/rewinddir/ sets the position of the directory stream
5868 pointed to by <tt/dir/ to the start of the directory.
5869 <tag/Notes/<itemize>
5870 <item>The function is only available as fastcall function, so it may only
5871 be used in presence of a prototype.
5873 <tag/Availability/POSIX 1003.1
5875 <ref id="seekdir" name="seekdir">,
5876 <ref id="telldir" name="telldir">
5882 <sect1>screensize<label id="screensize"><p>
5886 <tag/Function/Return the dimensions of the text mode screen.
5887 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
5888 <tag/Declaration/<tt/void __fastcall__ screensize (unsigned char* x, unsigned char* y);/
5889 <tag/Description/The function returns the dimensions of the text mode screen.
5890 <tag/Notes/<itemize>
5891 <item>The function is only available as fastcall function, so it may only
5892 be used in presence of a prototype.
5894 <tag/Availability/cc65
5896 <ref id="gotox" name="gotox">,
5897 <ref id="gotoxy" name="gotoxy">,
5898 <ref id="gotoy" name="gotoy">,
5899 <ref id="wherex" name="wherex">,
5900 <ref id="wherey" name="wherey">
5906 <sect1>seekdir<label id="seekdir"><p>
5910 <tag/Function/Set the position of a directory stream.
5911 <tag/Header/<tt/<ref id="dirent.h" name="dirent.h">/
5912 <tag/Declaration/<tt/void __fastcall__ seekdir (DIR* dir, long offset);/
5913 <tag/Description/<tt/seekdir/ sets the position of the directory stream
5914 pointed to by <tt/dir/ to the value given in <tt/offset/, which should be a
5915 value returned by <tt/<ref id="telldir" name="telldir">/.
5916 <tag/Notes/<itemize>
5917 <item>The function is only available as fastcall function, so it may only
5918 be used in presence of a prototype.
5920 <tag/Availability/POSIX 1003.1
5922 <ref id="rewinddir" name="rewinddir">,
5923 <ref id="telldir" name="telldir">
5929 <sect1>ser_close<label id="ser_close"><p>
5933 <tag/Function/Close the port and disable interrupts
5934 <tag/Header/<tt/<ref id="serial.h" name="serial.h">/
5935 <tag/Declaration/<tt/unsigned char ser_close (void);/
5936 <tag/Description/Close the port by clearing buffers and disable interrupts.
5937 <tag/Availability/cc65
5938 <tag/See also/Other serial functions.
5943 static void initialize(){
5944 struct ser_params params = {
5951 ser_install(lynx_comlynx); // This will activate the ComLynx
5953 ser_open(&params);
5960 <sect1>ser_get<label id="ser_get"><p>
5964 <tag/Function/Read a character from serial port.
5965 <tag/Header/<tt/<ref id="serial.h" name="serial.h">/
5966 <tag/Declaration/<tt/unsigned char __fastcall__ ser_get (char* b);/
5967 <tag/Description/Get a character from the serial port. If no characters are
5968 available, the function will return SER_ERR_NO_DATA, so this is not a fatal
5970 <tag/Notes/<itemize>
5971 <item>The function is only available as fastcall function, so it may only
5972 be used in presence of a prototype.
5974 <tag/Availability/cc65
5975 <tag/See also/Other serial functions.
5977 Wait for a character to be available from a serial port.
5980 while (ser_get(&ch) == SER_ERR_NO_DATA)
5987 <sect1>ser_install<label id="ser_install"><p>
5991 <tag/Function/Install an already loaded driver and return an error code.
5992 <tag/Header/<tt/<ref id="serial.h" name="serial.h">/
5993 <tag/Declaration/<tt/unsigned char __fastcall__ ser_install (void* driver);/
5994 <tag/Description/The function installs a driver that was already loaded into
5995 memory (or linked statically to the program). It returns an error code
5996 (<tt/SER_ERR_OK/ in case of success).
5997 <tag/Notes/<itemize>
5998 <item>The function is only available as fastcall function, so it may only be
5999 used in presence of a prototype.
6001 <tag/Availability/cc65
6003 <ref id="ser_load_driver" name="ser_load_driver">,
6004 <ref id="ser_uninstall" name="ser_uninstall">,
6005 <ref id="ser_unload" name="ser_unload">
6007 ser_install(lynx_comlynx); //Include the driver statically instead of loading it.
6013 <sect1>ser_ioctl<label id="ser_ioctl"><p>
6017 <tag/Function/Platform dependent code extensions.
6018 <tag/Header/<tt/<ref id="serial.h" name="serial.h">/
6019 <tag/Declaration/<tt/unsigned __fastcall__ ser_ioctl (unsigned char code, void* data);/
6020 <tag/Description/Some platforms have extra serial functions that are not
6021 supported by standard serial driver functions. You can extend the driver to support
6022 this extra functionality bt using ser_ioctl functions.
6023 <tag/Notes/<itemize>
6024 <item>The function is only available as fastcall function, so it may only
6025 be used in presence of a prototype.
6026 <item>These functions are not easily portable to other cc65 platforms.
6028 <tag/Availability/cc65
6029 <tag/See also/Other serial functions.
6034 <sect1>ser_load_driver<label id="ser_load_driver"><p>
6038 <tag/Function/Load and install a serial driver.
6039 <tag/Header/<tt/<ref id="serial.h" name="serial.h">/
6040 <tag/Declaration/<tt/unsigned char __fastcall__ ser_load_driver (const char *name);/
6041 <tag/Description/Load and install the driver by name.
6042 Will just load the driver and check if loading was successful.
6043 <tag/Notes/<itemize>
6044 <item>The function is only available as fastcall function, so it may only
6045 be used in presence of a prototype.
6047 <tag/Availability/cc65
6048 <tag/See also/Other serial functions.
6054 <sect1>ser_open<label id="ser_open"><p>
6058 <tag/Function/Open the port by setting the port parameters and enable interrupts
6059 <tag/Header/<tt/<ref id="serial.h" name="serial.h">/
6060 <tag/Declaration/<tt/unsigned char __fastcall__ ser_open (const struct ser_params* params);/
6061 <tag/Description/Open the port by setting the port parameters and enable interrupts.
6062 <tag/Notes/<itemize>
6063 <item>The function is only available as fastcall function, so it may only
6064 be used in presence of a prototype.
6066 <tag/Availability/cc65
6067 <tag/See also/Other serial functions.
6072 static void initialize(){
6073 struct ser_params params = {
6080 ser_install(lynx_comlynx); // This will activate the ComLynx
6082 ser_open(&params);
6089 <sect1>ser_put<label id="ser_put"><p>
6093 <tag/Function/Write a character to a serial port.
6094 <tag/Header/<tt/<ref id="serial.h" name="serial.h">/
6095 <tag/Declaration/<tt/unsigned char __fastcall__ ser_put (char b);/
6096 <tag/Description/Send a character via the serial port. There is a transmit
6097 buffer, but transmitting is not done via interrupt. The function returns
6098 SER_ERR_OVERFLOW if there is no space left in the transmit buffer.
6099 <tag/Notes/<itemize>
6100 <item>The function is only available as fastcall function, so it may only
6101 be used in presence of a prototype.
6103 <tag/Availability/cc65
6104 <tag/See also/Other serial functions.
6113 <sect1>ser_status<label id="ser_status"><p>
6117 <tag/Function/Return the serial port status.
6118 <tag/Header/<tt/<ref id="serial.h" name="serial.h">/
6119 <tag/Declaration/<tt/unsigned char __fastcall__ ser_status (unsigned char* status);/
6120 <tag/Description/Return the serial port status.
6121 <tag/Notes/<itemize>
6122 <item>The function is only available as fastcall function, so it may only
6123 be used in presence of a prototype.
6125 <tag/Availability/cc65
6126 <tag/See also/Other serial functions.
6132 <sect1>ser_uninstall<label id="ser_uninstall"><p>
6136 <tag/Function/Uninstall the currently loaded driver but do not unload it.
6137 <tag/Header/<tt/<ref id="serial.h" name="serial.h">/
6138 <tag/Declaration/<tt/unsigned char ser_uninstall (void);/
6139 <tag/Description/Uninstall the currently loaded driver but do not unload it.
6140 <tag/Availability/cc65
6141 <tag/See also/Other serial functions.
6146 <sect1>ser_unload<label id="ser_unload"><p>
6150 <tag/Function/Uninstall, then unload the currently loaded driver.
6151 <tag/Header/<tt/<ref id="serial.h" name="serial.h">/
6152 <tag/Declaration/<tt/unsigned char ser_unload (void);/
6153 <tag/Description/Uninstall, then unload the currently loaded driver.
6154 <tag/Availability/cc65
6155 <tag/See also/Other serial functions.
6161 <sect1>set_brk<label id="set_brk"><p>
6165 <tag/Function/Set the break vector to a user function.
6166 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
6167 <tag/Declaration/<tt/void __fastcall__ set_brk (brk_handler func);/
6168 <tag/Description/<tt/set_brk/ allows a user program to handle breaks within the
6169 program code by letting the vector point to a user written C function. The
6170 runtime library installs a small stub that saves the registers into global
6171 variables that may be accessed (and changed) by the break handler.
6172 <tag/Notes/<itemize>
6173 <item>The function is only available as fastcall function, so it may only
6174 be used in presence of a prototype.
6175 <item>The stub saves the zero page registers used by the C runtime and switches
6176 to a small break handler stack. This means that it is safe to execute C code,
6177 even if C code was interrupted. Be careful however not to use too many local
6178 variables, and do not enable stack checks for the handler function or any other
6179 function called from it.
6180 <item>The <tt/brk_pc/ variable points to the <tt/BRK/ instruction. If you want
6181 the continue with the interrupted code, you have to adjust <tt/brk_pc/,
6182 otherwise the <tt/BRK/ instruction will get executed over and over again.
6183 <item>The break vector is reset on program termination, so it's not strictly
6184 necessary to call <tt/<ref id="reset_brk" name="reset_brk">/ as a part of your
6185 clean-up when exitting the program.
6187 <tag/Availability/cc65
6189 <ref id="reset_brk" name="reset_brk">
6195 <sect1>set_irq<label id="set_irq"><p>
6199 <tag/Function/Set the C level interrupt request vector to the given address.
6200 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
6201 <tag/Declaration/<tt/void __fastcall__ set_irq (irq_handler f, void *stack_addr, size_t stack_size);/
6202 <tag/Description/<tt/set_irq/ allows a user program to handle interrupt requests
6203 (IRQs) within the program code by letting the vector point to a user written C
6204 function. The runtime library installs a small stub that saves the zero page
6205 registers used by the C runtime before calling the handler function and restores
6206 them after the handler function returns. Additionally the stub temporarily switches
6207 the C runtime stack to the stack area provided as parameter. If the handler function
6208 was set up to handle a "private", "exclusive" interrupt request source it must
6209 return the value <tt/IRQ_HANDLED/ if and only if it has verified that the current
6210 interrupt request actually stems from that source. In all other cases it must return
6211 the value <tt/IRQ_NOT_HANDLED/.
6212 <tag/Notes/<itemize>
6213 <item>The function is only available as fastcall function, so it may only
6214 be used in presence of a prototype.
6215 <item>The stub saves the registers and zero page locations used by the C runtime
6216 and switches to the provided stack area. As a consequence, there is some
6217 runtime overhead, but it it is safe to execute C code, even if other C code
6218 was interrupted. Be careful however not to call C library functions, and do not
6219 enable stack checks for the handler function or any other function called from
6221 <item>The interrupt vector is reset on program termination, so it's not strictly
6222 necessary to call <tt/<ref id="reset_irq" name="reset_irq">/ as a part of your
6223 clean-up when exitting the program.
6225 <tag/Availability/cc65
6227 <ref id="reset_brk" name="reset_brk">,
6228 <ref id="reset_irq" name="reset_irq">,
6229 <ref id="set_brk" name="set_brk">
6235 <sect1>set_c128_speed<label id="set_c128_speed"><p>
6239 <tag/Function/Set the current speed of a C128 CPU.
6240 <tag/Header/<tt/<ref id="accelerator.h" name="accelerator.h">/
6241 <tag/Declaration/<tt/unsigned char __fastcall__ set_c128_speed (unsigned char speed);/
6242 <tag/Description/The function returns the speed after trying to set the speed of the C128 CPU.
6243 <tag/Notes/<itemize>
6244 <item>The function is specific to the C64 and C128.
6245 <item>The function does not check if the C128 CPU is the current CPU.
6246 <item>See the accelerator.h header for the speed definitions.
6248 <tag/Availability/cc65 (not all platforms)
6250 <ref id="detect_c128" name="detect_c128">,
6251 <ref id="get_c128_speed" name="get_c128_speed">,
6257 <sect1>set_c64dtv_speed<label id="set_c64dtv_speed"><p>
6261 <tag/Function/Set the current speed of the C64DTV.
6262 <tag/Header/<tt/<ref id="accelerator.h" name="accelerator.h">/
6263 <tag/Declaration/<tt/unsigned char __fastcall__ set_c64dtv_speed (unsigned char speed);/
6264 <tag/Description/The function returns the speed after trying to set the speed of the C64DTV.
6265 <tag/Notes/<itemize>
6266 <item>The function is specific to the C64.
6267 <item>The function does not check for the presence of the C64DTV.
6268 <item>See the accelerator.h header for the speed definitions.
6270 <tag/Availability/cc65 (not all platforms)
6272 <ref id="detect_c64dtv" name="detect_c64dtv">,
6273 <ref id="get_c64dtv_speed" name="get_c64dtv_speed">,
6279 <sect1>set_c65_speed<label id="set_c65_speed"><p>
6283 <tag/Function/Set the current speed of the C65/C64DX in C64 mode.
6284 <tag/Header/<tt/<ref id="accelerator.h" name="accelerator.h">/
6285 <tag/Declaration/<tt/unsigned char __fastcall__ set_c65_speed (unsigned char speed);/
6286 <tag/Description/The function returns the speed after trying to set the speed of the C65/C64DX in C64 mode.
6287 <tag/Notes/<itemize>
6288 <item>The function is specific to the C64.
6289 <item>The function does not check for the presence of a C65/C64DX in C64 mode.
6290 <item>See the accelerator.h header for the speed definitions.
6292 <tag/Availability/cc65 (not all platforms)
6294 <ref id="detect_c65" name="detect_c65">,
6295 <ref id="get_c65_speed" name="get_c65_speed">,
6301 <sect1>set_chameleon_speed<label id="set_chameleon_speed"><p>
6305 <tag/Function/Set the current speed of the C64 Chameleon cartridge.
6306 <tag/Header/<tt/<ref id="accelerator.h" name="accelerator.h">/
6307 <tag/Declaration/<tt/unsigned char __fastcall__ set_chameleon_speed (unsigned char speed);/
6308 <tag/Description/The function returns the speed after trying to set the speed of the C64 Chameleon cartridge.
6309 <tag/Notes/<itemize>
6310 <item>The function is specific to the C64.
6311 <item>The function does not check for the presence of the C64 Chameleon cartridge.
6312 <item>See the accelerator.h header for the speed definitions.
6314 <tag/Availability/cc65 (not all platforms)
6316 <ref id="detect_chameleon" name="detect_chameleon">,
6317 <ref id="get_chameleon_speed" name="get_chameleon_speed">,
6323 <sect1>set_scpu_speed<label id="set_scpu_speed"><p>
6327 <tag/Function/Set the current speed of the C64/C128 SuperCPU cartridge.
6328 <tag/Header/<tt/<ref id="accelerator.h" name="accelerator.h">/
6329 <tag/Declaration/<tt/unsigned char __fastcall__ set_scpu_speed (unsigned char speed);/
6330 <tag/Description/The function returns the speed after trying to set the speed of the SuperCPU cartridge.
6331 <tag/Notes/<itemize>
6332 <item>The function is specific to the C128 and C64.
6333 <item>The function does not check for the presence of the cartridge.
6334 <item>See the accelerator.h header for the speed definitions.
6336 <tag/Availability/cc65 (not all platforms)
6338 <ref id="detect_scpu" name="detect_scpu">,
6339 <ref id="get_scpu_speed" name="get_scpu_speed">,
6345 <sect1>setjmp<label id="setjmp"><p>
6349 <tag/Function/Save the context for use with <tt/longjmp/.
6350 <tag/Header/<tt/<ref id="setjmp.h" name="setjmp.h">/
6351 <tag/Declaration/<tt/int __fastcall__ setjmp (jmp_buf buf);/
6352 <tag/Description/The <tt/setjmp/ function saves the current context in <tt/buf/
6353 for subsequent use by the <tt/<ref id="longjmp" name="longjmp">/ function and
6355 <tag/Notes/<itemize>
6356 <item>The function is only available as fastcall function, so it may only
6357 be used in presence of a prototype.
6358 <item><tt/setjmp/ is actually a macro as required by the ISO standard.
6359 <item><tt/setjmp/ will not save the signal context.
6361 <tag/Availability/ISO 9899
6363 <ref id="longjmp" name="longjmp">
6369 <sect1>setlocale<label id="setlocale"><p>
6373 <tag/Function/Selects a locale.
6374 <tag/Header/<tt/<ref id="locale.h" name="locale.h">/
6375 <tag/Declaration/<tt/char* __fastcall__ setlocale (int category, const char* locale);/
6376 <tag/Description/<tt/setlocale/ sets or queries the program's locale.
6377 <tag/Notes/<itemize>
6378 <item>The function is only available as fastcall function, so it may only
6379 be used in presence of a prototype.
6380 <item>cc65 supports only the "C" locale, so calling this function to set a
6381 different locale has no effect.
6383 <tag/Availability/ISO 9899
6385 <ref id="localeconv" name="localeconv">,
6386 <ref id="strcoll" name="strcoll">
6387 <ref id="strxfrm" name="strxfrm">
6393 <sect1>signal<label id="signal"><p>
6397 <tag/Function/Install a signal handler.
6398 <tag/Header/<tt/<ref id="signal.h" name="signal.h">/
6399 <tag/Declaration/<tt/__sigfunc __fastcall__ signal (int sig, __sigfunc func);/
6400 <tag/Description/<tt/signal/ installs a handler for the given signal. The
6401 handler may either be a user supplied function, or one of the predefined
6402 signal handlers <tt/SIG_IGN/ or <tt/SIG_DFL/. The function returns the
6403 previous value if the signal , or the special function vector SIG_ERR in
6405 <tag/Notes/<itemize>
6406 <item>The function is only available as fastcall function, so it may only
6407 be used in presence of a prototype.
6409 <tag/Availability/ISO 9899
6411 <ref id="abort" name="abort">,
6412 <ref id="raise" name="raise">
6418 <sect1>sleep<label id="sleep"><p>
6422 <tag/Function/Sleep for a specified amount of time.
6423 <tag/Header/<tt/<ref id="unistd.h" name="unistd.h">/
6424 <tag/Declaration/<tt/void __fastcall__ sleep (unsigned seconds);/
6425 <tag/Description/The function will return after the specified number of
6426 seconds have elapsed.
6427 <tag/Notes/<itemize>
6428 <item>The function is only available as fastcall function, so it may only
6429 be used in presence of a prototype.
6431 <tag/Availability/POSIX 1003.1
6437 <sect1>slow<label id="slow"><p>
6441 <tag/Function/Switch the CPU into slow mode (C128: 1MHz mode, C16/Plus4: single clock mode).
6442 <tag/Header/<tt/<ref id="c128.h" name="c128.h">,
6443 <ref id="c16.h" name="c16.h">, <ref id="plus4.h" name="plus4.h">/
6444 <tag/Declaration/<tt/void slow (void);/
6445 <tag/Description/The function will switch the clock of the CPU to slow mode. for the C128
6446 target it means switching the CPU into 1MHz mode. for the C16/Plus4 target it means
6447 switching the CPU into single clock mode.
6448 <tag/Notes/<itemize>
6449 <item>The function is specific to the C128, C16 and Plus4.
6451 <tag/Availability/cc65 (not all platforms)
6453 <ref id="fast" name="fast">,
6454 <ref id="isfast" name="isfast">,
6460 <sect1>srand<label id="srand"><p>
6464 <tag/Function/Initialize the pseudo random number generator.
6465 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
6466 <tag/Declaration/<tt/void __fastcall__ srand (unsigned seed);/
6467 <tag/Description/The function initializes the random number generator using
6468 the given seed. On program startup, the generator behaves as if <tt/srand/ has
6469 been called with an argument of 1.
6470 <tag/Notes/<itemize>
6471 <item>The function is only available as fastcall function, so it may only
6472 be used in presence of a prototype.
6474 <tag/Availability/ISO 9899
6476 <ref id="_randomize" name="_randomize">,
6477 <ref id="rand" name="rand">
6483 <sect1>strcasecmp<label id="strcasecmp"><p>
6487 <tag/Function/Compare two strings case insensitive.
6488 <tag/Header/<tt/<ref id="string.h" name="string.h">/
6489 <tag/Declaration/<tt/int __fastcall__ strcasecmp (const char* s1, const char* s2);/
6490 <tag/Description/The <tt/strcasecmp/ function compares the two strings passed
6491 as parameters without case sensitivity. It returns a value that is less than
6492 zero if <tt/s1/ is less than <tt/s2/, zero if <tt/s1/ is the same as <tt/s2/,
6493 and a value greater than zero if <tt/s1/ is greater than <tt/s2/.
6494 <tag/Notes/<itemize>
6495 <item>The function is only available as fastcall function, so it may only
6496 be used in presence of a prototype.
6497 <item>The function is not available in strict ANSI mode.
6499 <tag/Availability/cc65
6501 <ref id="strcmp" name="strcmp">,
6502 <ref id="strcoll" name="strcoll">,
6503 <ref id="stricmp" name="stricmp">,
6504 <ref id="strncmp" name="strncmp">,
6505 <ref id="strxfrm" name="strxfrm">
6511 <sect1>strcat<label id="strcat"><p>
6515 <tag/Function/Concatentate two strings.
6516 <tag/Header/<tt/<ref id="string.h" name="string.h">/
6517 <tag/Declaration/<tt/char* __fastcall__ strcat (char* s1, const char* s2);/
6518 <tag/Description/The <tt/strcat/ function appends a copy of the string
6519 pointed to by s2 (including the terminating null byte) to the end of the
6520 string pointed to by s1. The initial byte of s2 overwrites the null byte at
6522 <tag/Notes/<itemize>
6523 <item>The function is only available as fastcall function, so it may only
6524 be used in presence of a prototype.
6525 <item>If copying takes place between objects that overlap, the behaviour
6528 <tag/Availability/ISO 9899
6530 <ref id="strcpy" name="strcpy">,
6531 <ref id="strncat" name="strncat">,
6532 <ref id="strncpy" name="strncpy">
6538 <sect1>strchr<label id="strchr"><p>
6542 <tag/Function/Search for a character in a string.
6543 <tag/Header/<tt/<ref id="string.h" name="string.h">/
6544 <tag/Declaration/<tt/char* __fastcall__ strchr (const char* s, int c);/
6545 <tag/Description/The <tt/strchr/ function locates the first occurrence of <tt/c/
6546 (converted to a char) in the string pointed to by <tt/s/. The terminating null
6547 byte is considered to be part of the string. Upon completion, the function
6548 returns a pointer to the byte, or a null pointer if the byte was not found.
6549 <tag/Notes/<itemize>
6550 <item>The function is only available as fastcall function, so it may only
6551 be used in presence of a prototype.
6553 <tag/Availability/ISO 9899
6555 <ref id="memchr" name="memchr">,
6556 <ref id="strrchr" name="strrchr">
6562 <sect1>strcmp<label id="strcmp"><p>
6566 <tag/Function/Compare two strings.
6567 <tag/Header/<tt/<ref id="string.h" name="string.h">/
6568 <tag/Declaration/<tt/int __fastcall__ strcmp (const char* s1, const char* s2);/
6569 <tag/Description/The <tt/strcmp/ function compares the two strings passed as
6570 parameters. It returns a value that is less than zero if <tt/s1/ is less than
6571 <tt/s2/, zero if <tt/s1/ is the same as <tt/s2/, and a value greater than zero
6572 if <tt/s1/ is greater than <tt/s2/.
6573 <tag/Notes/<itemize>
6574 <item>The function is only available as fastcall function, so it may only
6575 be used in presence of a prototype.
6577 <tag/Availability/ISO 9899
6579 <ref id="strcasecmp" name="strcasecmp">,
6580 <ref id="strcoll" name="strcoll">,
6581 <ref id="stricmp" name="stricmp">,
6582 <ref id="strncmp" name="strncmp">
6583 <ref id="strxfrm" name="strxfrm">
6589 <sect1>strcoll<label id="strcoll"><p>
6593 <tag/Function/Compare two strings.
6594 <tag/Header/<tt/<ref id="string.h" name="string.h">/
6595 <tag/Declaration/<tt/int __fastcall__ strcoll (const char* s1, const char* s2);/
6596 <tag/Description/The <tt/strcoll/ function compares the two strings passed as
6597 parameters, according to the collating sequence set by <tt/<ref id="setlocale"
6598 name="setlocale">/. It returns a value that is less than zero if <tt/s1/ is
6599 less than <tt/s2/, zero if <tt/s1/ is the same as <tt/s2/, and a value greater
6600 than zero if <tt/s1/ is greater than <tt/s2/.
6601 <tag/Notes/<itemize>
6602 <item>The function is only available as fastcall function, so it may only
6603 be used in presence of a prototype.
6605 <tag/Availability/ISO 9899
6607 <ref id="setlocale" name="setlocale">,
6608 <ref id="strcasecmp" name="strcasecmp">,
6609 <ref id="strcmp" name="strcmp">,
6610 <ref id="stricmp" name="stricmp">,
6611 <ref id="strncmp" name="strncmp">,
6612 <ref id="strxfrm" name="strxfrm">
6618 <sect1>strcpy<label id="strcpy"><p>
6622 <tag/Function/Copy a string.
6623 <tag/Header/<tt/<ref id="string.h" name="string.h">/
6624 <tag/Declaration/<tt/char* __fastcall__ strcpy (char* s1, const char* s2);/
6625 <tag/Description/The <tt/strcpy/ function copies the string pointed to by
6626 <tt/s2/ (including the terminating null byte) into the array pointed to by
6627 <tt/s1/. The function will always return <tt/s1/.
6628 <tag/Notes/<itemize>
6629 <item>The function is only available as fastcall function, so it may only
6630 be used in presence of a prototype.
6631 <item>If copying takes place between objects that overlap, the behaviour
6634 <tag/Availability/ISO 9899
6636 <ref id="strcat" name="strcat">,
6637 <ref id="strncat" name="strncat">,
6638 <ref id="strncpy" name="strncpy">
6641 #include <string.h>
6643 static char hello[14];
6645 strcpy (hello, "Hello world!\n");
6651 <sect1>strcspn<label id="strcspn"><p>
6655 <tag/Function/Compute the length of a substring.
6656 <tag/Header/<tt/<ref id="string.h" name="string.h">/
6657 <tag/Declaration/<tt/size_t __fastcall__ strcspn (const char* s, const char* set);/
6658 <tag/Description/The <tt/strcspn/ function computes and returns the length of
6659 the substring pointed to by <tt/s/ which does <em>not</em> consist of
6660 characters contained in the string <tt/set/.
6661 <tag/Notes/<itemize>
6662 <item>The function is only available as fastcall function, so it may only
6663 be used in presence of a prototype.
6665 <tag/Availability/ISO 9899
6667 <ref id="strqtok" name="strqtok">,
6668 <ref id="strspn" name="strspn">,
6669 <ref id="strstr" name="strstr">,
6670 <ref id="strtok" name="strtok">
6676 <sect1>strdup<label id="strdup"><p>
6680 <tag/Function/Allocate a copy of a string on the heap.
6681 <tag/Header/<tt/<ref id="string.h" name="string.h">/
6682 <tag/Declaration/<tt/char* __fastcall__ strdup (const char* s);/
6683 <tag/Description/<tt/strdup/ allocates a memory block on the heap, big enough
6684 to hold a copy of <tt/s/ including the terminating zero. If the allocation
6685 fails, <tt/NULL/ is returned, otherwise <tt/s/ is copied into the allocated
6686 memory block, and a pointer to the block is returned.
6687 <tag/Notes/<itemize>
6688 <item>The function is only available as fastcall function, so it may only
6689 be used in presence of a prototype.
6690 <item>It is up to the caller to free the allocated memory block.
6692 <tag/Availability/ISO 9899
6694 <ref id="free" name="free">,
6695 <ref id="malloc" name="malloc">
6701 <sect1>strerror<label id="strerror"><p>
6705 <tag/Function/Return a string describing an error code.
6706 <tag/Header/<tt/<ref id="string.h" name="string.h">/
6707 <tag/Declaration/<tt/char* __fastcall__ strerror (int errcode);/
6708 <tag/Description/The <tt/strerror/ function returns a string describing the
6709 given error code. If an invalid error code is passed, the string "Unknown
6710 error" is returned, and <tt/errno/ is set to <tt/EINVAL/. In all other cases,
6711 <tt/errno/ is left untouched.
6712 <tag/Notes/<itemize>
6713 <item>The function is only available as fastcall function, so it may only
6714 be used in presence of a prototype.
6715 <item>While the return type of the function is a <tt/char*/, the returned
6716 string must not be modified by the caller!
6718 <tag/Availability/ISO 9899
6720 <ref id="_stroserror" name="_stroserror">
6726 <sect1>stricmp<label id="stricmp"><p>
6730 <tag/Function/Compare two strings case insensitive.
6731 <tag/Header/<tt/<ref id="string.h" name="string.h">/
6732 <tag/Declaration/<tt/int __fastcall__ stricmp (const char* s1, const char* s2);/
6733 <tag/Description/The <tt/stricmp/ function compares the two strings passed as
6734 parameters without case sensitivity. It returns a value that is less than zero
6735 if <tt/s1/ is less than <tt/s2/, zero if <tt/s1/ is the same as <tt/s2/, and a
6736 value greater than zero if <tt/s1/ is greater than <tt/s2/.
6737 <tag/Notes/<itemize>
6738 <item>The function is only available as fastcall function, so it may only
6739 be used in presence of a prototype.
6740 <item>The function is not available in strict ANSI mode.
6742 <tag/Availability/cc65
6744 <ref id="strcasecmp" name="strcasecmp">,
6745 <ref id="strcmp" name="strcmp">,
6746 <ref id="strcoll" name="strcoll">,
6747 <ref id="strncmp" name="strncmp">,
6748 <ref id="strxfrm" name="strxfrm">
6754 <sect1>strlen<label id="strlen"><p>
6758 <tag/Function/Return the length of a string.
6759 <tag/Header/<tt/<ref id="string.h" name="string.h">/
6760 <tag/Declaration/<tt/size_t __fastcall__ strlen (const char* s);/
6761 <tag/Description/The <tt/strlen/ function computes the number of bytes in the
6762 string to which s points, not including the terminating null byte.
6763 <tag/Notes/<itemize>
6764 <item>The function is only available as fastcall function, so it may only
6765 be used in presence of a prototype.
6766 <item>When compiling with <tt/-Os/ (inline known standard functions), the
6767 function does not work correctly for strings with more than 255 characters.
6769 <tag/Availability/ISO 9899
6771 <ref id="strcpy" name="strcpy">
6777 <sect1>strlower<label id="strlower"><p>
6781 <tag/Function/Make a string lower case.
6782 <tag/Header/<tt/<ref id="string.h" name="string.h">/
6783 <tag/Declaration/<tt/char* __fastcall__ strlower (char* s);/
6784 <tag/Description/The <tt/strlower/ function will apply the <tt/tolower/
6785 function to each character of a string. The function will always return <tt/s/.
6786 <tag/Notes/<itemize>
6787 <item>The function is only available as fastcall function, so it may only
6788 be used in presence of a prototype.
6789 <item>The function prototype is unavailable when compiling in strict ANSI mode.
6790 <item>An alias name for this function is <tt/strlwr/.
6792 <tag/Availability/cc65
6794 <ref id="strupper" name="strupper">,
6795 <ref id="tolower" name="tolower">
6801 <sect1>strlwr<label id="strlwr"><p>
6808 <sect1>strncasecmp<label id="strncasecmp"><p>
6812 <tag/Function/Compare two strings case insensitive.
6813 <tag/Header/<tt/<ref id="string.h" name="string.h">/
6814 <tag/Declaration/<tt/int __fastcall__ strncasecmp (const char* s1, const char* s2, size_t count);/
6815 <tag/Description/The <tt/strncasecmp/ function compares the two strings passed
6816 as parameters without case sensitivity. It returns a value that is less than
6817 zero if <tt/s1/ is less than <tt/s2/, zero if <tt/s1/ is the same as <tt/s2/,
6818 and a value greater than zero if <tt/s1/ is greater than <tt/s2/.
6819 <tag/Notes/<itemize>
6820 <item>The function is only available as fastcall function, so it may only
6821 be used in presence of a prototype.
6822 <item>The function is not available in strict ANSI mode.
6824 <tag/Availability/cc65
6826 <ref id="strcmp" name="strcmp">,
6827 <ref id="strcoll" name="strcoll">,
6828 <ref id="stricmp" name="stricmp">,
6829 <ref id="strncmp" name="strncmp">,
6830 <ref id="strxfrm" name="strxfrm">
6836 <sect1>strncat<label id="strncat"><p>
6840 <tag/Function/Concatentate two strings.
6841 <tag/Header/<tt/<ref id="string.h" name="string.h">/
6842 <tag/Declaration/<tt/char* __fastcall__ strncat (char* s1, const char* s2, size_t n);/
6843 <tag/Description/The <tt/strncat/ function appends not more than n characters
6844 of the string pointed to by s2 to the end of the string pointed to by s1. The
6845 terminating null character at the end of s1 is overwritten. A terminating null
6846 character is appended to the result, even if not all of s2 is appended to s1.
6847 <tag/Notes/<itemize>
6848 <item>The function is only available as fastcall function, so it may only
6849 be used in presence of a prototype.
6850 <item>If copying takes place between objects that overlap, the behaviour
6853 <tag/Availability/ISO 9899
6855 <ref id="strcpy" name="strcpy">,
6856 <ref id="strncat" name="strncat">,
6857 <ref id="strncpy" name="strncpy">
6863 <sect1>strncmp<label id="strncmp"><p>
6867 <tag/Function/Compare two strings.
6868 <tag/Header/<tt/<ref id="string.h" name="string.h">/
6869 <tag/Declaration/<tt/int __fastcall__ strncmp (const char* s1, const char* s2, size_t count);/
6870 <tag/Description/The <tt/strncmp/ function compares not more than <tt/count/
6871 characters of the two strings passed as parameters. It returns a value that is
6872 less than zero if the first <tt/count/ characters of <tt/s1/ are less than
6873 <tt/s2/, zero if they are identical, and a value greater than zero they are
6875 <tag/Notes/<itemize>
6876 <item>The function is only available as fastcall function, so it may only
6877 be used in presence of a prototype.
6879 <tag/Availability/ISO 9899
6881 <ref id="strcasecmp" name="strcasecmp">,
6882 <ref id="strcmp" name="strcmp">,
6883 <ref id="strcoll" name="strcoll">,
6884 <ref id="stricmp" name="stricmp">,
6885 <ref id="strxfrm" name="strxfrm">
6891 <sect1>strncpy<label id="strncpy"><p>
6895 <tag/Function/Copy part of a string.
6896 <tag/Header/<tt/<ref id="string.h" name="string.h">/
6897 <tag/Declaration/<tt/char* __fastcall__ strncpy (char* s1, const char* s2, size_t n);/
6898 <tag/Description/The <tt/strncpy/ function copies not more than <tt/n/ bytes from
6899 the array pointed to by <tt/s2/ to the array pointed to by <tt/s1/. If the array
6900 pointed to by <tt/s2/ is a string that is shorter than <tt/n/ bytes, null bytes are
6901 appended to the copy in the array pointed to by <tt/s1/, until <tt/n/ bytes are
6902 written. The function always will return <tt/s1/.
6903 <tag/Notes/<itemize>
6904 <item>The function is available only as a fastcall function; so, it may be used
6905 only in the presence of a prototype.
6906 <item>If there is no null byte in the first <tt/n/ bytes of the array pointed
6907 to by <tt/s2/, the result is <em/not/ null-terminated!
6908 <item>If copying takes place between objects that overlap, the behaviour is
6911 <tag/Availability/ISO 9899
6913 <ref id="memcpy" name="memcpy">,
6914 <ref id="strcat" name="strcat">,
6915 <ref id="strcpy" name="strcpy">,
6916 <ref id="strncat" name="strncat">
6921 static char hello[6];
6923 strncpy (hello, "Hello world!\n", sizeof hello - 1)[5] = '\0';
6929 <sect1>strnicmp<label id="strnicmp"><p>
6933 <tag/Function/Compare two strings case insensitive.
6934 <tag/Header/<tt/<ref id="string.h" name="string.h">/
6935 <tag/Declaration/<tt/int __fastcall__ strnicmp (const char* s1, const char* s2, size_t count);/
6936 <tag/Description/The <tt/strnicmp/ function compares the two strings passed as
6937 parameters without case sensitivity. It returns a value that is less than zero
6938 if <tt/s1/ is less than <tt/s2/, zero if <tt/s1/ is the same as <tt/s2/, and a
6939 value greater than zero if <tt/s1/ is greater than <tt/s2/.
6940 <tag/Notes/<itemize>
6941 <item>The function is only available as fastcall function, so it may only
6942 be used in presence of a prototype.
6943 <item>The function is not available in strict ANSI mode.
6945 <tag/Availability/cc65
6947 <ref id="strcasecmp" name="strcasecmp">,
6948 <ref id="strcmp" name="strcmp">,
6949 <ref id="strcoll" name="strcoll">,
6950 <ref id="strncmp" name="strncmp">,
6951 <ref id="strxfrm" name="strxfrm">
6957 <sect1>strqtok<label id="strqtok"><p>
6961 <tag/Function/Break a string into tokens.
6962 <tag/Header/<tt/<ref id="string.h" name="string.h">/
6963 <tag/Declaration/<tt/char* __fastcall__ strqtok (char* s1, const char* s2);/
6964 <tag/Description/<tt/strqtok()/ will break the string <tt/s1/ into a sequence of
6965 tokens, which are delimited by either quotation marks or characters from the
6966 string <tt/s2/. Tokens inside quotation marks may contain characters from <tt/s2/
6967 (they aren't delimiters there). The first call to <tt/strqtok()/ will return a
6968 pointer to the first token in the string <tt/s1/. The following calls must pass
6969 a <tt/NULL/ pointer as <tt/s1/, in order to get the next token in the string.
6970 Different sets of delimiters may be used for the subsequent calls to <tt/strqtok()/.
6971 <tag/Notes/<itemize>
6972 <item>The function is available only as a fastcall function; so, it may be used
6973 only in the presence of a prototype.
6974 <item><tt/strqtok()/ will modify the string <tt/s1/.
6975 <item>The function will forget where it is in the <tt/s1/ string if it is given
6976 a second <tt/s1/ string before it finishes the first one.
6978 <tag/Availability/cc65
6980 <ref id="strcspn" name="strcspn">,
6981 <!-- <ref id="strpbrk" name="strpbrk">, -->
6982 <ref id="strspn" name="strspn">,
6983 <ref id="strtok" name="strtok">
6989 <sect1>strrchr<label id="strrchr"><p>
6993 <tag/Function/Search for a character in a string.
6994 <tag/Header/<tt/<ref id="string.h" name="string.h">/
6995 <tag/Declaration/<tt/char* __fastcall__ strrchr (const char* s, int c);/
6996 <tag/Description/The <tt/strrchr/ function locates the last occurrence of <tt/c/
6997 (converted to a char) in the string pointed to by <tt/s/. The terminating null
6998 byte is considered to be part of the string. Upon completion, the function
6999 returns a pointer to the byte, or a null pointer if the byte was not found.
7000 <tag/Notes/<itemize>
7001 <item>The function is only available as fastcall function, so it may only
7002 be used in presence of a prototype.
7004 <tag/Availability/ISO 9899
7006 <ref id="strchr" name="strchr">
7012 <sect1>strspn<label id="strspn"><p>
7016 <tag/Function/Compute the length of a substring.
7017 <tag/Header/<tt/<ref id="string.h" name="string.h">/
7018 <tag/Declaration/<tt/size_t __fastcall__ strspn (const char* s, const char* set);/
7019 <tag/Description/The <tt/strspn/ function computes and returns the length of
7020 the substring pointed to by <tt/s/ which does consist only of characters
7021 contained in the string <tt/set/.
7022 <tag/Notes/<itemize>
7023 <item>The function is only available as fastcall function, so it may only
7024 be used in presence of a prototype.
7026 <tag/Availability/ISO 9899
7028 <ref id="strcspn" name="strcspn">,
7029 <ref id="strstr" name="strstr">
7035 <sect1>strstr<label id="strstr"><p>
7039 <tag/Function/Find a substring.
7040 <tag/Header/<tt/<ref id="string.h" name="string.h">/
7041 <tag/Declaration/<tt/char* __fastcall__ strstr (const char* str, const char* substr);/
7042 <tag/Description/<tt/strstr/ searches for the first occurance of the string
7043 <tt/substr/ within <tt/str/. If found, it returns a pointer to the copy,
7044 otherwise it returns <tt/NULL/.
7045 <tag/Notes/<itemize>
7046 <item>The function is only available as fastcall function, so it may only
7047 be used in presence of a prototype.
7049 <tag/Availability/ISO 9899
7051 <ref id="strcspn" name="strcspn">,
7052 <ref id="strspn" name="strspn">
7058 <sect1>strtok<label id="strtok"><p>
7062 <tag/Function/Break a string into tokens.
7063 <tag/Header/<tt/<ref id="string.h" name="string.h">/
7064 <tag/Declaration/<tt/char* __fastcall__ strtok (char* s1, const char* s2);/
7065 <tag/Description/<tt/strtok()/ will break the string <tt/s1/ into a sequence of
7066 tokens, which are delimited by characters from the string <tt/s2/. The first call
7067 to <tt/strtok()/ will return a pointer to the first token in the string <tt/s1/.
7068 The following calls must pass a <tt/NULL/ pointer as <tt/s1/, in order to get
7069 the next token in the string. Different sets of delimiters may be used for the
7070 subsequent calls to <tt/strtok()/.
7071 <tag/Notes/<itemize>
7072 <item>The function is only available as fastcall function, so it may only
7073 be used in presence of a prototype.
7074 <item><tt/strtok()/ will modify the string <tt/s1/.
7075 <item>The function will forget where it is in the <tt/s1/ string if it is given
7076 a second <tt/s1/ string before it finishes the first one.
7078 <tag/Availability/ISO 9899
7080 <ref id="strcspn" name="strcspn">,
7081 <!-- <ref id="strpbrk" name="strpbrk">, -->
7082 <ref id="strqtok" name="strqtok">,
7083 <ref id="strspn" name="strspn">
7089 <sect1>strxfrm<label id="strxfrm"><p>
7093 <tag/Function/Transform a string.
7094 <tag/Header/<tt/<ref id="string.h" name="string.h">/
7095 <tag/Declaration/<tt/size_t __fastcall__ strxfrm (char* s1, const char* s2, size_t n);/
7096 <tag/Description/The <tt/strxfrm/ function transforms the string pointed to by
7097 s2 and places the resulting string into the string pointed to by s1. The
7098 transformation is such that if the <tt/strcmp/ function is applied to two
7099 transformed strings, it returns a value greater than, equal to, or less than
7100 zero, corresponding to the result of the <tt/strcoll/ function applied to the
7101 same two original strings. No more than n characters are placed into the
7102 resulting array pointed to by s1, including the terminating null character.
7103 <tag/Notes/<itemize>
7104 <item><tt/s1/ and <tt/s2/ must not point to the same memory area, otherwise
7105 the behaviour is undefined.
7106 <item>If <tt/n/ is zero, <tt/s1/ may be a NULL pointer.
7107 <item>The function is only available as fastcall function, so it may only
7108 be used in presence of a prototype.
7109 <item>Since cc65 doesn't support different charcter sets, <tt/strxfrm/ will
7110 just copy s2 to s1 using <tt><ref id="strncpy" name="strncpy"></tt>.
7112 <tag/Availability/ISO 9899
7114 <ref id="strcmp" name="strcmp">,
7115 <ref id="strcoll" name="strcoll">,
7116 <ref id="strncpy" name="strncpy">
7122 <sect1>strupper<label id="strupper"><p>
7126 <tag/Function/Make a string upper case.
7127 <tag/Header/<tt/<ref id="string.h" name="string.h">/
7128 <tag/Declaration/<tt/char* __fastcall__ strupper (char* s);/
7129 <tag/Description/The <tt/strupper/ function will apply the <tt/toupper/
7130 function to each character of a string. The function will always return <tt/s/.
7131 <tag/Notes/<itemize>
7132 <item>The function is only available as fastcall function, so it may only
7133 be used in presence of a prototype.
7134 <item>The function prototype is unavailable when compiling in strict ANSI mode.
7135 <item>An alias name for this function is <tt/strupr/.
7137 <tag/Availability/cc65
7139 <ref id="strlower" name="strlower">
7140 <ref id="toupper" name="toupper">
7146 <sect1>strupr<label id="strupr"><p>
7153 <sect1>telldir<label id="telldir"><p>
7157 <tag/Function/Return the current position of a directory stream.
7158 <tag/Header/<tt/<ref id="dirent.h" name="dirent.h">/
7159 <tag/Declaration/<tt/long __fastcall__ telldir (DIR* dir);/
7160 <tag/Description/<tt/telldir/ returns the current position of a directory
7161 stream. The return value may be used in subsequent calls to
7162 <tt/<ref id="seekdir" name="seekdir">/.
7163 <tag/Notes/<itemize>
7164 <item>The function is only available as fastcall function, so it may only
7165 be used in presence of a prototype.
7167 <tag/Availability/POSIX 1003.1
7169 <ref id="seekdir" name="seekdir">,
7170 <ref id="telldir" name="telldir">
7176 <sect1>textcolor<label id="textcolor"><p>
7180 <tag/Function/Set the text color.
7181 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
7182 <tag/Declaration/<tt/unsigned char __fastcall__ textcolor (unsigned char color);/
7183 <tag/Description/The function will set a new text color. It returns the old
7184 (current) text color. Text output using any <tt/conio.h/ function will use
7185 the color set by this function.
7186 <tag/Notes/<itemize>
7187 <item>Text colors are system dependent. The function may have no effect
7188 on systems where the text color cannot be changed.
7189 <item>The function is only available as fastcall function, so it may only
7190 be used in presence of a prototype.
7192 <tag/Availability/cc65
7194 <ref id="bgcolor" name="bgcolor">,
7195 <ref id="bordercolor" name="bordercolor">
7201 <sect1>time<label id="time"><p>
7205 <tag/Function/Get the time.
7206 <tag/Header/<tt/<ref id="time.h" name="time.h">/
7207 <tag/Declaration/<tt/time_t __fastcall__ time (time_t* t);/
7208 <tag/Description/The function returns the time since the 1970-01-01 00:00:00
7209 measured in seconds. If the pointer <tt/t/ is not <tt/NULL/, the function
7210 result will also be stored there. If no time is available, <tt/(time_t)-1/ is
7211 returned and <tt/errno/ is set to <tt/ENOSYS/.
7212 <tag/Notes/<itemize>
7213 <item>The function is only available as fastcall function, so it may
7214 only be used in presence of a prototype.
7215 <item>Many platforms supported by cc65 do not have a realtime clock, so the
7216 returned value may not be valid.
7218 <tag/Availability/ISO 9899
7220 <ref id="clock" name="clock">
7226 <sect1>toggle_videomode<label id="toggle_videomode"><p>
7230 <tag/Function/Toggle between 40 and 80 column mode.
7231 <tag/Header/<tt/<ref id="c128.h" name="c128.h">/
7232 <tag/Declaration/<tt/void toggle_videomode (void);/
7233 <tag/Description/Toggle between 40 and 80 column mode. The settings for the
7234 old mode (cursor position, color and so on) are saved and restored together
7236 <tag/Notes/<itemize>
7237 <item>The function is specific to the C128.
7238 <item>This function is deprecated. Please use <ref id="videomode"
7239 name="videomode"> instead!
7241 <tag/Availability/C128
7243 <ref id="fast" name="fast">,
7244 <ref id="isfast" name="isfast">,
7245 <ref id="slow" name="slow">,
7246 <ref id="videomode" name="videomode">
7252 <sect1>tolower<label id="tolower"><p>
7256 <tag/Function/Convert a character into its lower case representation.
7257 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
7258 <tag/Declaration/<tt/int __fastcall__ tolower (int c);/
7259 <tag/Description/The function returns the given character converted to lower
7260 case. If the given character is not a letter, it is returned unchanged.
7261 <tag/Notes/<itemize>
7262 <item>The function is only available as fastcall function, so it may
7263 only be used in presence of a prototype.
7265 <tag/Availability/ISO 9899
7267 <ref id="islower" name="islower">,
7268 <ref id="isupper" name="isupper">,
7269 <ref id="toupper" name="toupper">
7275 <sect1>toupper<label id="toupper"><p>
7279 <tag/Function/Convert a character into its upper case representation.
7280 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
7281 <tag/Declaration/<tt/int __fastcall__ toupper (int c);/
7282 <tag/Description/The function returns the given character converted to upper
7283 case. If the given character is not a letter, it is returned unchanged.
7284 <tag/Notes/<itemize>
7285 <item>The function is only available as fastcall function, so it may
7286 only be used in presence of a prototype.
7288 <tag/Availability/ISO 9899
7290 <ref id="islower" name="islower">,
7291 <ref id="isupper" name="isupper">,
7292 <ref id="tolower" name="tolower">
7298 <sect1>ultoa<label id="ultoa"><p>
7302 <tag/Function/Convert an unsigned long integer into a string.
7303 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
7304 <tag/Declaration/<tt/char* __fastcall__ ultoa (unsigned long val, char* buf, int radix);/
7305 <tag/Description/<tt/itoa/ converts the unsigned long integer <tt/val/ into a
7306 string using <tt/radix/ as the base.
7307 <tag/Notes/<itemize>
7308 <item>There are no provisions to prevent a buffer overflow.
7309 <item>The function is non standard, so it is not available in strict ANSI mode.
7310 You should probably use <tt/sprintf/ instead.
7311 <item>The function is only available as fastcall function, so it may only be
7312 used in presence of a prototype.
7314 <tag/Availability/cc65
7316 <ref id="atoi" name="atoi">,
7317 <ref id="atol" name="atol">,
7318 <ref id="itoa" name="itoa">,
7319 <ref id="ltoa" name="ltoa">,
7320 <ref id="utoa" name="utoa">
7326 <sect1>unlink<label id="unlink"><p>
7330 <tag/Function/Delete a file.
7331 <tag/Header/<tt/<ref id="unistd.h" name="unistd.h">/
7332 <tag/Declaration/<tt/int __fastcall__ unlink (const char* name);/
7333 <tag/Description/<tt/unlink/ deletes the file with the given name. On success,
7334 zero is returned. On error, -1 is returned and <tt/errno/ is set to an error
7335 code describing the reason for the failure.
7336 <tag/Notes/<itemize>
7337 <item>The use of this function is discouraged. Please use <tt/<ref id="remove"
7338 name="remove">/ instead, which is a native ANSI C function and does the same.
7339 <item>This function is not available on all cc65 targets (depends on the
7340 availability of file I/O).
7341 <item>The function is only available as fastcall function, so it may only
7342 be used in presence of a prototype.
7343 <item>Instead of <tt/unlink/, <tt/<ref id="remove" name="remove">/ should be
7344 used, which has the same semantics, but is more portable, because it conforms
7345 to the ISO C standard.
7347 <tag/Availability/POSIX 1003.1
7349 <ref id="remove" name="remove">
7352 #include <stdio.h>
7353 #include <unistd.h>
7355 #define FILENAME "helloworld"
7357 if (unlink (FILENAME) == 0) {
7358 printf ("We deleted %s successfully\n", FILENAME);
7360 printf ("There was a problem deleting %s\n", FILENAME);
7367 <sect1>utoa<label id="utoa"><p>
7371 <tag/Function/Convert an unsigned integer into a string.
7372 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
7373 <tag/Declaration/<tt/char* __fastcall__ utoa (unsigned val, char* buf, int radix);/
7374 <tag/Description/<tt/itoa/ converts the unsigned integer <tt/val/ into a string
7375 using <tt/radix/ as the base.
7376 <tag/Notes/<itemize>
7377 <item>There are no provisions to prevent a buffer overflow.
7378 <item>The function is non standard, so it is not available in strict ANSI mode.
7379 You should probably use <tt/sprintf/ instead.
7380 <item>The function is only available as fastcall function, so it may only be
7381 used in presence of a prototype.
7383 <tag/Availability/cc65
7385 <ref id="atoi" name="atoi">,
7386 <ref id="atol" name="atol">,
7387 <ref id="itoa" name="itoa">,
7388 <ref id="ltoa" name="ltoa">,
7389 <ref id="ultoa" name="ultoa">
7395 <sect1>vcprintf<label id="vcprintf"><p>
7399 <tag/Function/Formatted output to the console.
7400 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
7401 <tag/Declaration/<tt/int __fastcall__ vcprintf (const char* format, va_list ap);/
7402 <tag/Description/The arguments specified as a <tt/va_list/ are converted to
7403 text where necessary and formatted according to the format string given. The
7404 resulting string is output to the console. <tt/vcprintf/ supports the same
7405 format specifiers as <tt/vprintf/. <!-- <tt/<ref id="vprintf" name="vprintf">/. -->
7406 <tag/Notes/<itemize>
7407 <item>Like all other <tt/conio/ output functions, <tt/vcprintf/ distinguishes
7408 between <tt/\r/ and <tt/\n/.
7409 <item>The function is only available as fastcall function, so it may only be
7410 used in presence of a prototype.
7412 <tag/Availability/cc65
7414 <ref id="cprintf" name="cprintf">,
7415 <ref id="cputc" name="cputc">,
7416 <ref id="cputcxy" name="cputcxy">,
7417 <ref id="cputs" name="cputs">,
7418 <ref id="cputsxy" name="cputsxy">
7424 <sect1>videomode<label id="videomode"><p>
7428 <tag/Function/Switch to either 40 or 80 column mode.
7429 <tag/Header/<tt/<ref id="apple2enh.h" name="apple2enh.h">,
7430 <ref id="c128.h" name="c128.h">/
7431 <tag/Declaration/<tt/unsigned __fastcall__ videomode (unsigned Mode);/
7432 <tag/Description/Switch to 40 or 80 column mode depending on the argument. If
7433 the requested mode is already active, nothing happens. The old mode is returned
7435 <tag/Notes/<itemize>
7436 <item>The function is specific to the C128 and enhanced Apple //e.
7437 <item>This function replaces <ref id="toggle_videomode"
7438 name="toggle_videomode">.
7439 <item>The function is only available as fastcall function, so it may only be
7440 used in presence of a prototype.
7442 <tag/Availability/C128 and enhanced Apple //e
7444 <ref id="fast" name="fast">,
7445 <ref id="isfast" name="isfast">,
7446 <ref id="slow" name="slow">,
7447 <ref id="toggle_videomode" name="toggle_videomode">
7453 <sect1>waitvsync<label id="waitvsync"><p>
7457 <tag/Function/Wait until the start of the next frame.
7459 <tt/<ref id="cbm.h" name="cbm.h">/,
7460 <tt/<ref id="gamate.h" name="gamate.h">/,
7461 <tt/<ref id="nes.h" name="nes.h">/,
7462 <tt/<ref id="pce.h" name="pce.h">/
7463 <tag/Declaration/<tt/void waitvsync (void);/
7464 <tag/Description/Wait for vertical sync to reduce flickering.
7465 <tag/Availability/Platforms above
7471 <sect1>wherex<label id="wherex"><p>
7475 <tag/Function/Return the current X position of the text mode cursor.
7476 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
7477 <tag/Declaration/<tt/unsigned char wherex (void);/
7478 <tag/Description/The function returns the current X position of the text mode
7479 cursor. Zero is returned for the leftmost screen position.
7480 <tag/Availability/cc65
7482 <ref id="gotox" name="gotox">,
7483 <ref id="gotoy" name="gotoy">,
7484 <ref id="gotoxy" name="gotoxy">,
7485 <ref id="wherey" name="wherey">
7491 <sect1>wherey<label id="wherey"><p>
7495 <tag/Function/Return the current Y position of the text mode cursor.
7496 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
7497 <tag/Declaration/<tt/unsigned char wherey (void);/
7498 <tag/Description/The function returns the current Y position of the text mode
7499 cursor. Zero is returned for the uppermost screen position.
7500 <tag/Availability/cc65
7502 <ref id="gotox" name="gotox">,
7503 <ref id="gotoy" name="gotoy">,
7504 <ref id="gotoxy" name="gotoxy">,
7505 <ref id="wherex" name="wherex">