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/apple2.h/<label id="apple2.h"><p>
72 <item><ref id="get_ostype" name="get_ostype">
77 <sect1><tt/apple2enh.h/<label id="apple2enh.h"><p>
81 <item><ref id="get_ostype" name="get_ostype">
85 <item><ref id="videomode" name="videomode">
89 <sect1><tt/assert.h/<label id="assert.h"><p>
92 <item><ref id="assert" name="assert">
96 <sect1><tt/atari.h/<label id="atari.h"><p>
99 <!-- <item><ref id="_getcolor" name="_getcolor"> -->
100 <!-- <item><ref id="_getdefdev" name="_getdefdev"> -->
101 <!-- <item><ref id="_graphics" name="_graphics"> -->
102 <item><ref id="_is_cmdline_dos" name="_is_cmdline_dos">
103 <!-- <item><ref id="_rest_vecs" name="_rest_vecs"> -->
104 <!-- <item><ref id="_save_vecs" name="_save_vecs"> -->
105 <!-- <item><ref id="_scroll" name="_scroll"> -->
106 <!-- <item><ref id="_setcolor" name="_setcolor"> -->
107 <!-- <item><ref id="_setcolor_low" name="_setcolor_low"> -->
108 <item><ref id="get_ostype" name="get_ostype">
109 <!-- <item><ref id="get_tv" name="get_tv"> -->
115 <sect1><tt/atmos.h/<label id="atmos.h"><p>
118 <item><ref id="atmos_explode" name="atmos_explode">
119 <item><ref id="atmos_load" name="atmos_load">
120 <item><ref id="atmos_ping" name="atmos_ping">
121 <item><ref id="atmos_save" name="atmos_save">
122 <item><ref id="atmos_shoot" name="atmos_shoot">
123 <item><ref id="atmos_tick" name="atmos_tick">
124 <item><ref id="atmos_tock" name="atmos_tock">
125 <item><ref id="atmos_zap" name="atmos_zap">
129 <sect1><tt/c128.h/<label id="c128.h"><p>
132 <item><ref id="c64mode" name="c64mode">
133 <item><ref id="fast" name="fast">
134 <item><ref id="slow" name="slow">
135 <item><ref id="toggle_videomode" name="toggle_videomode">
136 <item><ref id="videomode" name="videomode">
140 <sect1><tt/c16.h/<label id="c16.h"><p>
145 <sect1><tt/c64.h/<label id="c64.h"><p>
148 <item><ref id="get_ostype" name="get_ostype">
152 <sect1><tt/cbm.h/<label id="cbm.h"><p>
155 <item><ref id="cbm_k_acptr" name="cbm_k_acptr">
156 <item><ref id="cbm_k_basin" name="cbm_k_basin">
157 <item><ref id="cbm_k_bsout" name="cbm_k_bsout">
158 <item><ref id="cbm_k_chkin" name="cbm_k_chkin">
159 <item><ref id="cbm_k_ciout" name="cbm_k_ciout">
160 <item><ref id="cbm_k_ckout" name="cbm_k_ckout">
161 <item><ref id="cbm_k_clall" name="cbm_k_clall">
162 <item><ref id="cbm_k_close" name="cbm_k_close">
163 <item><ref id="cbm_k_clrch" name="cbm_k_clrch">
164 <item><ref id="cbm_k_getin" name="cbm_k_getin">
165 <item><ref id="cbm_k_iobase" name="cbm_k_iobase">
166 <item><ref id="cbm_k_listen" name="cbm_k_listen">
167 <item><ref id="cbm_k_load" name="cbm_k_load">
168 <item><ref id="cbm_k_open" name="cbm_k_open">
169 <item><ref id="cbm_k_readst" name="cbm_k_readst">
170 <item><ref id="cbm_k_save" name="cbm_k_save">
171 <item><ref id="cbm_k_scnkey" name="cbm_k_scnkey">
172 <item><ref id="cbm_k_setlfs" name="cbm_k_setlfs">
173 <item><ref id="cbm_k_setnam" name="cbm_k_setnam">
174 <item><ref id="cbm_k_talk" name="cbm_k_talk">
175 <item><ref id="cbm_k_udtim" name="cbm_k_udtim">
176 <item><ref id="cbm_k_unlsn" name="cbm_k_unlsn">
177 <!-- <item><ref id="cbm_load" name="cbm_load"> -->
178 <!-- <item><ref id="cbm_open" name="cbm_open"> -->
179 <!-- <item><ref id="cbm_opendir" name="cbm_opendir"> -->
180 <!-- <item><ref id="cbm_read" name="cbm_read"> -->
181 <!-- <item><ref id="cbm_readdir" name="cbm_readdir"> -->
182 <!-- <item><ref id="cbm_save" name="cbm_save"> -->
183 <!-- <item><ref id="cbm_write" name="cbm_write"> -->
184 <!-- <item><ref id="get_tv" name="get_tv"> -->
185 <item><ref id="kbrepeat" name="kbrepeat">
191 <sect1><tt/cbm510.h/<label id="cbm510.h"><p>
194 <item><ref id="peekbsys" name="peekbsys">
195 <item><ref id="peekwsys" name="peekwsys">
196 <item><ref id="pokebsys" name="pokebsys">
197 <item><ref id="pokewsys" name="pokewsys">
201 <sect1><tt/cbm610.h/<label id="cbm610.h"><p>
204 <item><ref id="peekbsys" name="peekbsys">
205 <item><ref id="peekwsys" name="peekwsys">
206 <item><ref id="pokebsys" name="pokebsys">
207 <item><ref id="pokewsys" name="pokewsys">
211 <sect1><tt/cc65.h/<label id="cc65.h"><p>
214 <!-- <item><ref id="cc65_cos" name="cc65_cos"> -->
215 <!-- <item><ref id="cc65_idiv32by16r16" name="cc65_idiv32by16r16"> -->
216 <!-- <item><ref id="cc65_imul16x16r32" name="cc65_imul16x16r32"> -->
217 <!-- <item><ref id="cc65_imul8x8r16" name="cc65_imul8x8r16"> -->
218 <!-- <item><ref id="cc65_sin" name="cc65_sin"> -->
219 <!-- <item><ref id="cc65_udiv32by16r16" name="cc65_udiv32by16r16"> -->
220 <!-- <item><ref id="cc65_umul16x16r32" name="cc65_umul16x16r32"> -->
221 <!-- <item><ref id="cc65_umul16x8r32" name="cc65_umul16x8r32"> -->
222 <!-- <item><ref id="cc65_umul8x8r16" name="cc65_umul8x8r16"> -->
223 <item><ref id="doesclrscrafterexit" name="doesclrscrafterexit">
229 <sect1><tt/conio.h/<label id="conio.h"><p>
232 <item><ref id="bgcolor" name="bgcolor">
233 <item><ref id="bordercolor" name="bordercolor">
234 <item><ref id="cclear" name="cclear">
235 <item><ref id="cclearxy" name="cclearxy">
236 <item><ref id="cgetc" name="cgetc">
237 <item><ref id="chline" name="chline">
238 <item><ref id="chlinexy" name="chlinexy">
239 <item><ref id="clrscr" name="clrscr">
240 <item><ref id="cprintf" name="cprintf">
241 <item><ref id="cputc" name="cputc">
242 <item><ref id="cputcxy" name="cputcxy">
243 <item><ref id="cputs" name="cputs">
244 <item><ref id="cputsxy" name="cputsxy">
245 <item><ref id="cursor" name="cursor">
246 <item><ref id="cvline" name="cvline">
247 <item><ref id="cvlinexy" name="cvlinexy">
248 <item><ref id="gotox" name="gotox">
249 <item><ref id="gotoxy" name="gotoxy">
250 <item><ref id="gotoy" name="gotoy">
251 <item><ref id="kbhit" name="kbhit">
252 <item><ref id="revers" name="revers">
253 <item><ref id="screensize" name="screensize">
254 <item><ref id="textcolor" name="textcolor">
255 <item><ref id="vcprintf" name="vcprintf">
256 <item><ref id="wherex" name="wherex">
257 <item><ref id="wherey" name="wherey">
261 <sect1><tt/ctype.h/<label id="ctype.h"><p>
264 <item><ref id="isalnum" name="isalnum">
265 <item><ref id="isalpha" name="isalpha">
266 <item><ref id="isascii" name="isascii">
267 <item><ref id="isblank" name="isblank">
268 <item><ref id="iscntrl" name="iscntrl">
269 <item><ref id="isdigit" name="isdigit">
270 <item><ref id="isgraph" name="isgraph">
271 <item><ref id="islower" name="islower">
272 <item><ref id="isprint" name="isprint">
273 <item><ref id="ispunct" name="ispunct">
274 <item><ref id="isspace" name="isspace">
275 <item><ref id="isupper" name="isupper">
276 <item><ref id="isxdigit" name="isxdigit">
277 <item><ref id="tolower" name="tolower">
278 <item><ref id="toupper" name="toupper">
282 <sect1><tt/dbg.h/<label id="dbg.h"><p>
285 <!-- <item><ref id="DbgInit" name="DbgInit"> -->
291 <sect1><tt/dio.h/<label id="dio.h"><p>
293 <url url="dio.html" name="Low-level disk I/O API">.
296 <sect1><tt/dirent.h/<label id="dirent.h"><p>
299 <item><ref id="_DE_ISDIR" name="_DE_ISDIR">
300 <item><ref id="_DE_ISLBL" name="_DE_ISLBL">
301 <item><ref id="_DE_ISLNK" name="_DE_ISLNK">
302 <item><ref id="_DE_ISREG" name="_DE_ISREG">
303 <item><ref id="closedir" name="closedir">
304 <item><ref id="opendir" name="opendir">
305 <item><ref id="readdir" name="readdir">
306 <item><ref id="rewinddir" name="rewinddir">
307 <item><ref id="seekdir" name="seekdir">
308 <item><ref id="telldir" name="telldir">
314 <sect1><tt/em.h/<label id="em.h"><p>
317 <item><ref id="em_commit" name="em_commit">
318 <item><ref id="em_copyfrom" name="em_copyfrom">
319 <item><ref id="em_copyto" name="em_copyto">
320 <item><ref id="em_install" name="em_install">
321 <item><ref id="em_load_driver" name="em_load_driver">
322 <item><ref id="em_map" name="em_map">
323 <item><ref id="em_pagecount" name="em_pagecount">
324 <item><ref id="em_uninstall" name="em_uninstall">
325 <item><ref id="em_unload" name="em_unload">
326 <item><ref id="em_use" name="em_use">
330 <sect1><tt/errno.h/<label id="errno.h"><p>
333 <!-- <item><ref id="_directerrno" name="_directerrno"> -->
334 <!-- <item><ref id="_mappederrno" name="_mappederrno"> -->
335 <!-- <item><ref id="_osmaperrno" name="_osmaperrno"> -->
336 <!-- <item><ref id="_seterrno" name="_seterrno"> -->
342 <sect1><tt/fcntl.h/<label id="fcntl.h"><p>
345 <item><ref id="close" name="close">
346 <item><ref id="creat" name="creat">
347 <item><ref id="open" name="open">
351 <sect1><tt/gamate.h/<label id="gamate.h"><p>
354 <!-- <item><ref id="get_tv" name="get_tv"> -->
355 <item><ref id="waitvsync" name="waitvsync">
361 <sect1><tt/geos.h/<label id="geos.h"><p>
366 <sect1><tt/joystick.h/<label id="joystick.h"><p>
369 <item><ref id="joy_count" name="joy_count">
370 <item><ref id="joy_install" name="joy_install">
371 <item><ref id="joy_load_driver" name="joy_load_driver">
372 <item><ref id="joy_read" name="joy_read">
373 <item><ref id="joy_uninstall" name="joy_uninstall">
374 <item><ref id="joy_unload" name="joy_unload">
378 <sect1><tt/locale.h/<label id="locale.h"><p>
381 <item><ref id="localeconv" name="localeconv">
382 <item><ref id="setlocale" name="setlocale">
386 <sect1><tt/lynx.h/<label id="lynx.h"><p>
389 <!-- <item><ref id="lynx_eeprom_erase" name="lynx_eeprom_erase"> -->
390 <!-- <item><ref id="lynx_eeprom_read" name="lynx_eeprom_read"> -->
391 <!-- <item><ref id="lynx_eeprom_write" name="lynx_eeprom_write"> -->
392 <!-- <item><ref id="lynx_eeread" name="lynx_eeread"> -->
393 <!-- <item><ref id="lynx_eewrite" name="lynx_eewrite"> -->
394 <!-- <item><ref id="lynx_exec" name="lynx_exec"> -->
395 <!-- <item><ref id="lynx_load" name="lynx_load"> -->
401 <sect1><tt/lz4.h/<label id="lz4.h"><p>
404 <item><ref id="decompress_lz4" name="decompress_lz4">
408 <sect1><tt/modload.h/<label id="modload.h"><p>
411 <item><ref id="mod_load" name="mod_load">
412 <item><ref id="mod_free" name="mod_free">
416 <sect1><tt/mouse.h/<label id="mouse.h"><p>
419 <item><ref id="mouse_buttons" name="mouse_buttons">
420 <item><ref id="mouse_getbox" name="mouse_getbox">
421 <item><ref id="mouse_geterrormsg" name="mouse_geterrormsg">
422 <item><ref id="mouse_hide" name="mouse_hide">
423 <item><ref id="mouse_info" name="mouse_info">
424 <item><ref id="mouse_install" name="mouse_install">
425 <item><ref id="mouse_ioctl" name="mouse_ioctl">
426 <item><ref id="mouse_load_driver" name="mouse_load_driver">
427 <item><ref id="mouse_move" name="mouse_move">
428 <item><ref id="mouse_pos" name="mouse_pos">
429 <item><ref id="mouse_setbox" name="mouse_setbox">
430 <item><ref id="mouse_show" name="mouse_show">
431 <item><ref id="mouse_uninstall" name="mouse_uninstall">
432 <item><ref id="mouse_unload" name="mouse_unload">
436 <sect1><tt/nes.h/<label id="nes.h"><p>
439 <!-- <item><ref id="get_tv" name="get_tv"> -->
440 <item><ref id="waitvsync" name="waitvsync">
446 <sect1><tt/o65.h/<label id="o65.h"><p>
448 The <tt/o65.h/ header file contains structure and constant definitions that
449 may be used when dealing with files in <url
450 url="http://www.6502.org/users/andre/o65/fileformat.html" name="the o65 format">.
451 It does not declare any functions.
454 <sect1><tt/pce.h/<label id="pce.h"><p>
457 <!-- <item><ref id="get_tv" name="get_tv"> -->
458 <item><ref id="waitvsync" name="waitvsync">
464 <sect1><tt/peekpoke.h/<label id="peekpoke.h"><p>
467 <item><ref id="PEEK" name="PEEK">
468 <item><ref id="PEEKW" name="PEEKW">
469 <item><ref id="POKE" name="POKE">
470 <item><ref id="POKEW" name="POKEW">
474 <sect1><tt/pen.h/<label id="pen.h"><p>
477 <!-- <item><ref id="pen_adjust" name="pen_adjust"> -->
478 <!-- <item><ref id="pen_calibrate" name="pen_calibrate"> -->
484 <sect1><tt/pet.h/<label id="pet.h"><p>
489 <sect1><tt/plus4.h/<label id="plus4.h"><p>
494 <sect1><tt/serial.h/<label id="serial.h"><p>
496 The <tt/serial.h/ header file contains definitions for initializing serial
500 <item><ref id="ser_close" name="ser_close">
501 <item><ref id="ser_get" name="ser_get">
502 <item><ref id="ser_install" name="ser_install">
503 <item><ref id="ser_ioctl" name="ser_ioctl">
504 <item><ref id="ser_load_driver" name="ser_load_driver">
505 <item><ref id="ser_open" name="ser_open">
506 <item><ref id="ser_put" name="ser_put">
507 <item><ref id="ser_status" name="ser_status">
508 <item><ref id="ser_uninstall" name="ser_uninstall">
509 <item><ref id="ser_unload" name="ser_unload">
513 <sect1><tt/setjmp.h/<label id="setjmp.h"><p>
516 <item><ref id="setjmp" name="setjmp">
517 <item><ref id="longjmp" name="longjmp">
521 <sect1><tt/signal.h/<label id="signal.h"><p>
524 <item><ref id="raise" name="raise">
525 <item><ref id="signal" name="signal">
529 <sect1><tt/stdarg.h/<label id="stdarg.h"><p>
534 <sect1><tt/stdbool.h/<label id="stdbool.h"><p>
539 <sect1><tt/stddef.h/<label id="stddef.h"><p>
542 <item><ref id="offsetof" name="offsetof">
546 <sect1><tt/stdio.h/<label id="stdio.h"><p>
549 <item><ref id="_poserror" name="_poserror">
550 <item><ref id="clearerr" name="clearerr">
551 <!-- <item><ref id="fclose" name="fclose"> -->
552 <!-- <item><ref id="fdopen" name="fdopen"> -->
553 <item><ref id="feof" name="feof">
554 <item><ref id="ferror" name="ferror">
555 <!-- <item><ref id="fflush" name="fflush"> -->
556 <!-- <item><ref id="fgetc" name="fgetc"> -->
557 <!-- <item><ref id="fgetpos" name="fgetpos"> -->
558 <!-- <item><ref id="fgets" name="fgets"> -->
559 <item><ref id="fileno" name="fileno">
560 <!-- <item><ref id="fopen" name="fopen"> -->
561 <!-- <item><ref id="fprintf" name="fprintf"> -->
562 <!-- <item><ref id="fputc" name="fputc"> -->
563 <!-- <item><ref id="fputs" name="fputs"> -->
564 <!-- <item><ref id="fread" name="fread"> -->
565 <!-- <item><ref id="freopen" name="freopen"> -->
566 <!-- <item><ref id="fscanf" name="fscanf"> -->
567 <!-- <item><ref id="fseek" name="fseek"> -->
568 <!-- <item><ref id="fsetpos" name="fsetpos"> -->
569 <!-- <item><ref id="ftell" name="ftell"> -->
570 <!-- <item><ref id="fwrite" name="fwrite"> -->
571 <!-- <item><ref id="getc" name="getc"> -->
572 <!-- <item><ref id="getchar" name="getchar"> -->
573 <!-- <item><ref id="gets" name="gets"> -->
574 <!-- <item><ref id="printf" name="printf"> -->
575 <!-- <item><ref id="putc" name="putc"> -->
576 <!-- <item><ref id="putchar" name="putchar"> -->
577 <!-- <item><ref id="puts" name="puts"> -->
578 <item><ref id="rename" name="rename">
579 <item><ref id="remove" name="remove">
580 <!-- <item><ref id="rewind" name="rewind"> -->
581 <!-- <item><ref id="scanf" name="scanf"> -->
582 <!-- <item><ref id="snprintf" name="snprintf"> -->
583 <!-- <item><ref id="sprintf" name="sprintf"> -->
584 <!-- <item><ref id="sscanf" name="sscanf"> -->
585 <!-- <item><ref id="vfprintf" name="vfprintf"> -->
586 <!-- <item><ref id="vfscanf" name="vfscanf"> -->
587 <!-- <item><ref id="vprintf" name="vprintf"> -->
588 <!-- <item><ref id="vscanf" name="vscanf"> -->
589 <!-- <item><ref id="vsnprintf" name="vsnprintf"> -->
590 <!-- <item><ref id="vsprintf" name="vsprintf"> -->
591 <!-- <item><ref id="vsscanf" name="vsscanf"> -->
597 <sect1><tt/stdlib.h/<label id="stdlib.h"><p>
600 <item><ref id="_heapadd" name="_heapadd">
601 <item><ref id="_heapblocksize" name="_heapblocksize">
602 <item><ref id="_heapmaxavail" name="_heapmaxavail">
603 <item><ref id="_heapmemavail" name="_heapmemavail">
604 <item><ref id="_randomize" name="_randomize">
605 <item><ref id="_swap" name="_swap">
606 <item><ref id="abort" name="abort">
607 <item><ref id="abs" name="abs">
608 <item><ref id="atexit" name="atexit">
609 <item><ref id="atoi" name="atoi">
610 <item><ref id="atol" name="atol">
611 <item><ref id="bsearch" name="bsearch">
612 <item><ref id="calloc" name="calloc">
613 <item><ref id="div" name="div">
614 <item><ref id="exit" name="exit">
615 <item><ref id="free" name="free">
616 <item><ref id="getenv" name="getenv">
617 <item><ref id="itoa" name="itoa">
618 <item><ref id="labs" name="labs">
619 <item><ref id="ltoa" name="ltoa">
620 <item><ref id="malloc" name="malloc">
621 <item><ref id="perror" name="perror">
622 <!-- <item><ref id="posix_memalign" name="posix_memalign"> -->
623 <!-- <item><ref id="putenv" name="putenv"> -->
624 <item><ref id="qsort" name="qsort">
625 <item><ref id="rand" name="rand">
626 <item><ref id="realloc" name="realloc">
627 <item><ref id="srand" name="srand">
628 <!-- <item><ref id="system" name="system"> -->
629 <item><ref id="ultoa" name="ultoa">
630 <item><ref id="utoa" name="utoa">
636 <sect1><tt/string.h/<label id="string.h"><p>
639 <item><ref id="_stroserror" name="_stroserror">
640 <item><ref id="bzero" name="bzero">
641 <item><ref id="memchr" name="memchr">
642 <item><ref id="memcmp" name="memcmp">
643 <item><ref id="memcpy" name="memcpy">
644 <item><ref id="memmove" name="memmove">
645 <item><ref id="memset" name="memset">
646 <item><ref id="strcasecmp" name="strcasecmp">
647 <item><ref id="strcat" name="strcat">
648 <item><ref id="strchr" name="strchr">
649 <item><ref id="strcmp" name="strcmp">
650 <item><ref id="strcoll" name="strcoll">
651 <item><ref id="strcpy" name="strcpy">
652 <item><ref id="strcspn" name="strcspn">
653 <item><ref id="strdup" name="strdup">
654 <item><ref id="strerror" name="strerror">
655 <item><ref id="stricmp" name="stricmp">
656 <item><ref id="strlen" name="strlen">
657 <item><ref id="strlower" name="strlower">
658 <item><ref id="strlwr" name="strlwr">
659 <item><ref id="strncat" name="strncat">
660 <item><ref id="strncmp" name="strncmp">
661 <item><ref id="strncpy" name="strncpy">
662 <item><ref id="strqtok" name="strqtok">
663 <item><ref id="strrchr" name="strrchr">
664 <item><ref id="strspn" name="strspn">
665 <item><ref id="strstr" name="strstr">
666 <item><ref id="strtok" name="strtok">
667 <item><ref id="strxfrm" name="strxfrm">
668 <item><ref id="strupper" name="strupper">
669 <item><ref id="strupr" name="strupr">
675 <sect1><tt/telestrat.h/<label id="telestrat.h"><p>
678 <item><ref id="atmos_explode" name="explode">
679 <item><ref id="atmos_ping" name="ping">
680 <item><ref id="atmos_shoot" name="shoot">
681 <item><ref id="atmos_zap" name="zap">
682 <!-- <item><ref id="kbdclick1" name="kbdclick1"> -->
683 <!-- <item><ref id="oups" name="oups"> -->
689 <sect1><tt/tgi.h/<label id="tgi.h"><p>
691 <url url="tgi.html" name="Tiny Graphics Interface">.
694 <sect1><tt/time.h/<label id="time.h"><p>
697 <!-- <item><ref id="_systime" name="_systime"> -->
698 <!-- <item><ref id="asctime" name="asctime"> -->
699 <item><ref id="clock" name="clock">
700 <!-- <item><ref id="ctime" name="ctime"> -->
701 <!-- <item><ref id="gmtime" name="gmtime"> -->
702 <!-- <item><ref id="localtime" name="localtime"> -->
703 <!-- <item><ref id="mktime" name="mktime"> -->
704 <!-- <item><ref id="strftime" name="strftime"> -->
705 <item><ref id="time" name="time">
711 <sect1><tt/unistd.h/<label id="unistd.h"><p>
714 <!-- <item><ref id="chdir" name="chdir"> -->
715 <item><ref id="exec" name="exec">
716 <!-- <item><ref id="getcwd" name="getcwd"> -->
717 <item><ref id="getopt" name="getopt">
718 <!-- <item><ref id="lseek" name="lseek"> -->
719 <!-- <item><ref id="mkdir" name="mkdir"> -->
720 <!-- <item><ref id="read" name="read"> -->
721 <!-- <item><ref id="rmdir" name="rmdir"> -->
722 <item><ref id="sleep" name="sleep">
723 <item><ref id="unlink" name="unlink">
724 <!-- <item><ref id="write" name="write"> -->
730 <sect1><tt/vic20.h/<label id="vic20.h"><p>
735 <sect1><tt/zlib.h/<label id="zlib.h"><p>
738 <!-- <item><ref id="adler32" name="adler32"> -->
739 <!-- <item><ref id="crc32" name="crc32"> -->
740 <!-- <item><ref id="inflatemem" name="inflatemem"> -->
741 <!-- <item><ref id="uncompress" name="uncompress"> -->
747 <sect>Alphabetical function reference<p>
749 <sect1>_DE_ISDIR<label id="_DE_ISDIR"><p>
753 <tag/Function/Determine if a directory entry specifies a directory.
754 <tag/Header/<tt/<ref id="dirent.h" name="dirent.h">/
755 <tag/Declaration/<tt/int _DE_ISDIR(unsigned char type);/
756 <tag/Description/The function is called with the type of a directory entry
757 taken from a <tt/struct dirent/ and returns true if the entry designates
760 <item>The function is actually a macro.
762 <tag/Availability/cc65
764 <ref id="_DE_ISLBL" name="_DE_ISLBL">,
765 <ref id="_DE_ISLNK" name="_DE_ISLNK">,
766 <ref id="_DE_ISREG" name="_DE_ISREG">
772 <sect1>_DE_ISLBL<label id="_DE_ISLBL"><p>
776 <tag/Function/Determine if a directory entry specifies a disk label.
777 <tag/Header/<tt/<ref id="dirent.h" name="dirent.h">/
778 <tag/Declaration/<tt/int _DE_ISLBL(unsigned char type);/
779 <tag/Description/The function is called with the type of a directory entry
780 taken from a <tt/struct dirent/ and returns true if the entry designates
783 <item>The function is actually a macro.
785 <tag/Availability/cc65
787 <ref id="_DE_ISDIR" name="_DE_ISDIR">,
788 <ref id="_DE_ISLNK" name="_DE_ISLNK">,
789 <ref id="_DE_ISREG" name="_DE_ISREG">
795 <sect1>_DE_ISLNK<label id="_DE_ISLNK"><p>
799 <tag/Function/Determine if a directory entry specifies a link.
800 <tag/Header/<tt/<ref id="dirent.h" name="dirent.h">/
801 <tag/Declaration/<tt/int _DE_ISLNK(unsigned char type);/
802 <tag/Description/The function is called with the type of a directory entry
803 taken from a <tt/struct dirent/ and returns true if the entry designates
806 <item>The function is actually a macro.
808 <tag/Availability/cc65
810 <ref id="_DE_ISDIR" name="_DE_ISDIR">,
811 <ref id="_DE_ISLBL" name="_DE_ISLBL">,
812 <ref id="_DE_ISREG" name="_DE_ISREG">
818 <sect1>_DE_ISREG<label id="_DE_ISREG"><p>
822 <tag/Function/Determine if a directory entry specifies a regular file.
823 <tag/Header/<tt/<ref id="dirent.h" name="dirent.h">/
824 <tag/Declaration/<tt/int _DE_ISREG(unsigned char type);/
825 <tag/Description/The function is called with the type of a directory entry
826 taken from a <tt/struct dirent/ and returns true if the entry designates
829 <item>The function is actually a macro.
830 <item>A "regular file" means anything with data in it. This might still mean
831 that special processing is needed, when accessing the file. Relative files of
832 the CBM systems are classified as being "regular" files, for example.
834 <tag/Availability/cc65
836 <ref id="_DE_ISDIR" name="_DE_ISDIR">,
837 <ref id="_DE_ISLBL" name="_DE_ISLBL">,
838 <ref id="_DE_ISLNK" name="_DE_ISLNK">
844 <sect1>_heapadd<label id="_heapadd"><p>
848 <tag/Function/Add a block to the heap.
849 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
850 <tag/Declaration/<tt/void __fastcall__ _heapadd (void* mem, size_t size);/
851 <tag/Description/The function adds a block of raw memory to the heap.
853 <item>The minimum blocksize that can be added is 6 bytes; the function will
854 ignore smaller blocks.
855 <item>The function is available only as a fastcall function; so, it may be used
856 only in the presence of a prototype.
858 <tag/Availability/cc65
860 <ref id="_heapblocksize" name="_heapblocksize">,
861 <ref id="_heapmaxavail" name="_heapmaxavail">,
862 <ref id="_heapmemavail" name="_heapmemavail">,
863 <ref id="calloc" name="calloc">,
864 <ref id="free" name="free">,
865 <ref id="malloc" name="malloc">,
866 <ref id="realloc" name="realloc">
872 <sect1>_heapblocksize<label id="_heapblocksize"><p>
876 <tag/Function/Return the size of an allocated block.
877 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
878 <tag/Declaration/<tt/size_t __fastcall__ _heapblocksize (const void* block);/
879 <tag/Description/The function returns the size of a block that must have
880 previously been allocated by <tt/<ref id="malloc" name="malloc">/, <tt/<ref
881 id="calloc" name="calloc">/ or <tt/<ref id="realloc" name="realloc">/.
883 <item>Passing a pointer to a block that was is not the result of one of the
884 allocation functions, or that has been free'd will give unpredicable results.
885 <item>The function is available only as a fastcall function; so, it may be used
886 only in the presence of a prototype.
888 <tag/Availability/cc65
890 <ref id="_heapadd" name="_heapadd">,
891 <ref id="_heapmaxavail" name="_heapmaxavail">,
892 <ref id="_heapmemavail" name="_heapmemavail">,
893 <ref id="calloc" name="calloc">,
894 <ref id="free" name="free">,
895 <ref id="malloc" name="malloc">,
896 <ref id="realloc" name="realloc">
902 <sect1>_heapmaxavail<label id="_heapmaxavail"><p>
906 <tag/Function/Return the largest block that is available on the heap.
907 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
908 <tag/Declaration/<tt/size_t _heapmaxavail (void);/
909 <tag/Description/The function returns the size of the largest block that may
910 be allocated from the heap using <tt/<ref id="malloc" name="malloc">/.
911 <tag/Availability/cc65
913 <ref id="_heapadd" name="_heapadd">,
914 <ref id="_heapblocksize" name="_heapblocksize">,
915 <ref id="_heapmemavail" name="_heapmemavail">,
916 <ref id="calloc" name="calloc">,
917 <ref id="free" name="free">,
918 <ref id="malloc" name="malloc">,
919 <ref id="realloc" name="realloc">
925 <sect1>_heapmemavail<label id="_heapmemavail"><p>
929 <tag/Function/Return the total available space on the heap.
930 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
931 <tag/Declaration/<tt/size_t _heapmemavail (void);/
932 <tag/Description/The function returns the total number of bytes available on
935 <item>This function is of less use than usually assumed, since the returned
936 heap space may be available but not in one block. So even if this function
937 says that several times more heap space is available than needed, <ref
938 id="malloc" name="malloc"> may still return <tt/NULL/.
940 <tag/Availability/cc65
942 <ref id="_heapadd" name="_heapadd">,
943 <ref id="_heapblocksize" name="_heapblocksize">,
944 <ref id="_heapmaxavail" name="_heapmaxavail">,
945 <ref id="calloc" name="calloc">,
946 <ref id="free" name="free">,
947 <ref id="malloc" name="malloc">,
948 <ref id="realloc" name="realloc">
954 <sect1>_is_cmdline_dos<label id="_is_cmdline_dos"><p>
958 <tag/Function/Determines whether the underlying DOS supports command line arguments.
959 <tag/Header/<tt/<ref id="atari.h" name="atari.h">/
960 <tag/Declaration/<tt/unsigned char _is_cmdline_dos (void);/
961 <tag/Description/The function returns 0 if the DOS doesn't support command line arguments.
962 It returns 1 if it does.
963 <tag/Availability/cc65 (<tt/atari/ and <tt/atarixl/ platforms)
968 <sect1>_poserror<label id="_poserror"><p>
972 <tag/Function/Print an error message for the error in <tt/_oserror/.
973 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
974 <tag/Declaration/<tt/void __fastcall__ _poserror (const char* msg);/
975 <tag/Description/<tt/_poserror/ prints an error message to <tt/stderr/. If
976 <tt/msg/ is not <tt/NULL/ and not an empty string, it is printed followed by
977 a colon and a blank. Then the error message for the current contents of
978 <tt/_oserror/ are printed followed by a newline. The message output is the
979 same as returned by <tt/<ref id="_stroserror" name="_stroserror">/ with an
980 argument of <tt/_oserror/.
982 <item>Since operating system specific error code are - you guessed it -
983 operating system specific, the value in <tt/_oserror/ and the message that is
984 printed depends on the cc65 target.
985 <item>The function is only available as fastcall function, so it may only
986 be used in presence of a prototype.
988 <tag/Availability/cc65
990 <ref id="_stroserror" name="_stroserror">,
991 <ref id="perror" name="perror">
997 <sect1>_randomize<label id="_randomize"><p>
1001 <tag/Function/Initialize the pseudo random number generator.
1002 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1003 <tag/Declaration/<tt/void _randomize (void);/
1004 <tag/Description/The function initializes the random number generator with
1005 a seed derived from fast changing hardware events, so the seed itself can be
1006 considered random to a certain degree.
1007 <tag/Notes/<itemize>
1008 <item>The randomness of the seed depends on the machine hardware.
1010 <tag/Availability/cc65
1012 <ref id="rand" name="rand">,
1013 <ref id="srand" name="srand">
1019 <sect1>_stroserror<label id="_stroserror"><p>
1023 <tag/Function/Return a string describing an OS specific error code.
1024 <tag/Header/<tt/<ref id="string.h" name="string.h">/
1025 <tag/Declaration/<tt/const char* __fastcall__ _stroserror (unsigned char errcode);/
1026 <tag/Description/<tt/_stroserror/ will return a string describing the given
1027 operating system specific error code.
1028 <tag/Notes/<itemize>
1029 <item>Since operating system specific error code are - you guessed it -
1030 operating system specific, the parameter and the string returned depend on the
1032 <item>The function is only available as fastcall function, so it may only be
1033 used in presence of a prototype.
1035 <tag/Availability/cc65
1037 <ref id="strerror" name="strerror">
1043 <sect1>_swap<label id="_swap"><p>
1047 <tag/Function/Swap the contents of memory areas.
1048 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1049 <tag/Declaration/<tt/void __fastcall__ _swap (void* p, void* q, size_t size);/
1050 <tag/Description/<tt/_swap/ will swap (exchange) the contents of the two memory
1051 areas pointed to by <tt/p/ and <tt/q/. Both memory areas are assumed to be
1052 <tt/size/ bytes in size.
1053 <tag/Notes/<itemize>
1054 <item>The memory areas may not overlap, otherwise the results are undefined.
1055 <item>The function is only available as fastcall function, so it may only be
1056 used in presence of a prototype.
1058 <tag/Availability/cc65
1060 <ref id="memcpy" name="memcpy">,
1061 <ref id="memmove" name="memmove">
1067 <sect1>_sys<label id="_sys"><p>
1071 <tag/Function/Call a subroutine passing register values.
1072 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
1073 <tag/Declaration/<tt/void __fastcall__ _sys (struct regs* r);/
1074 <tag/Description/The function will call the subroutine at the address
1075 specified in the <tt/pc/ member of the passed <tt/regs/ structure. All
1076 registers and the CPU flags are set to the values given in the <tt/regs/
1077 structure. On return from the subroutine, the new values of the registers and
1078 flags are stored back overwriting the old values.
1079 <tag/Notes/<itemize>
1080 <item>Bits 4 and 5 of the flags value in the <tt/regs/ structure are ignored
1081 when calling the subroutine (they are unchanged from their current values).
1082 <item>The function is only available as fastcall function, so it may only be
1083 used in presence of a prototype.
1085 <tag/Availability/cc65
1091 <sect1>BRK<label id="BRK"><p>
1095 <tag/Function/Insert a 6502 BRK instrunction into the code.
1096 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
1097 <tag/Declaration/<tt/void BRK (void);/
1098 <tag/Description/The function will insert a 6502 BRK instruction into the code
1099 which may be used to trigger a debugger.
1100 <tag/Notes/<itemize>
1101 <item>The function is actually a macro.
1102 <item>The inserted instruction may lead to unexpected results if no debugger
1105 <tag/Availability/cc65
1107 <ref id="CLI" name="CLI">,
1108 <ref id="SEI" name="SEI">
1114 <sect1>CLI<label id="CLI"><p>
1118 <tag/Function/Insert a 6502 CLI instrunction into the code.
1119 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
1120 <tag/Declaration/<tt/void CLI (void);/
1121 <tag/Description/The function will insert a 6502 CLI instruction into the code,
1122 so interrupts are enabled. Enabling interrupts has no effects if they are
1123 already enabled (the default).
1124 <tag/Notes/<itemize>
1125 <item>The function is actually a macro.
1126 <item>Disabling interrupts may lead to unexpected results.
1128 <tag/Availability/cc65
1130 <ref id="BRK" name="BRK">,
1131 <ref id="SEI" name="SEI">
1137 <sect1>PEEK<label id="PEEK"><p>
1141 <tag/Function/Read a byte from memory.
1142 <tag/Header/<tt/<ref id="peekpoke.h" name="peekpoke.h">/
1143 <tag/Declaration/<tt/unsigned char PEEK (unsigned addr);/
1144 <tag/Description/The function will read the absolute memory given by <tt/addr/
1145 and return the value read.
1146 <tag/Notes/<itemize>
1147 <item>The function is actually a macro.
1148 <item>This function depends highly on the platform and environment.
1150 <tag/Availability/cc65
1152 <ref id="PEEKW" name="PEEKW">,
1153 <ref id="POKE" name="POKE">
1159 <sect1>PEEKW<label id="PEEKW"><p>
1163 <tag/Function/Read a word (two bytes) from memory.
1164 <tag/Header/<tt/<ref id="peekpoke.h" name="peekpoke.h">/
1165 <tag/Declaration/<tt/unsigned PEEKW (unsigned addr);/
1166 <tag/Description/The function will read the absolute memory given by <tt/addr/
1167 and return the value read. The byte read from the higher address is the high
1168 byte of the return value.
1169 <tag/Notes/<itemize>
1170 <item>The function is actually a macro.
1171 <item>This function depends highly on the platform and environment.
1172 <item>The order in which the two bytes are read is unspecified and may
1173 depend of the address expression used.
1175 <tag/Availability/cc65
1177 <ref id="PEEK" name="PEEK">,
1178 <ref id="POKE" name="POKE">
1184 <sect1>POKE<label id="POKE"><p>
1188 <tag/Function/Write a byte to memory.
1189 <tag/Header/<tt/<ref id="peekpoke.h" name="peekpoke.h">/
1190 <tag/Declaration/<tt/void POKE (unsigned addr, unsigned char val);/
1191 <tag/Description/The function writes the value <tt/val/ to the absolute
1192 memory address given by <tt/addr/.
1193 <tag/Notes/<itemize>
1194 <item>The function is actually a macro.
1195 <item>This function depends highly on the platform and environment.
1196 <item>Careless use will cause the program to act strange or may crash the
1199 <tag/Availability/cc65
1201 <ref id="PEEK" name="PEEK">,
1202 <ref id="POKEW" name="POKEW">
1208 <sect1>POKEW<label id="POKEW"><p>
1212 <tag/Function/Write a word (two bytes) to memory.
1213 <tag/Header/<tt/<ref id="peekpoke.h" name="peekpoke.h">/
1214 <tag/Declaration/<tt/void POKEW (unsigned addr, unsigned val);/
1215 <tag/Description/The function writes the value <tt/val/ to the absolute
1216 memory address given by <tt/addr/. The low byte of <tt/val/ is written to
1217 the <tt/addr/, the high byte is written to <tt/addr+1/.
1218 <tag/Notes/<itemize>
1219 <item>The function is actually a macro.
1220 <item>This function depends highly on the platform and environment.
1221 <item>Careless use will cause the program to act strange or may crash the
1223 <item>The order in which the two bytes are written is unspecified and may
1224 depend of the address expression used.
1226 <tag/Availability/cc65
1228 <ref id="PEEK" name="PEEK">,
1229 <ref id="POKE" name="POKE">
1235 <sect1>SEI<label id="SEI"><p>
1239 <tag/Function/Insert a 6502 SEI instrunction into the code.
1240 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
1241 <tag/Declaration/<tt/void SEI (void);/
1242 <tag/Description/The function will insert a 6502 SEI instruction into the code,
1243 so interrupts are disabled. Note that non maskable interrupts cannot be
1245 <tag/Notes/<itemize>
1246 <item>The function is actually a macro.
1247 <item>Disabling interrupts may lead to unexpected results.
1249 <tag/Availability/cc65
1251 <ref id="BRK" name="BRK">,
1252 <ref id="CLI" name="CLI">
1258 <sect1>abort<label id="abort"><p>
1262 <tag/Function/Terminates a program abnormally.
1263 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1264 <tag/Declaration/<tt/void abort (void);/
1265 <tag/Description/<tt/abort/ raises <tt/SIGABRT/, writes a termination message
1266 on stderr, then terminates the program with an exit code of 3.
1267 <tag/Availability/ISO 9899
1269 <ref id="assert" name="assert">,
1270 <ref id="exit" name="exit">,
1271 <ref id="raise" name="raise">
1277 <sect1>abs<label id="abs"><p>
1281 <tag/Function/Returns the absolute value of an integer.
1282 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1283 <tag/Declaration/<tt/int __fastcall__ abs (int v);/
1284 <tag/Description/<tt/abs/ returns the absolute value of the argument passed to
1286 <tag/Notes/<itemize>
1287 <item>The return value is undefined if <tt/INT_MIN/ is passed to the function.
1288 <item>The function is only available as fastcall function, so it may only be
1289 used in presence of a prototype.
1291 <tag/Availability/ISO 9899
1293 <ref id="labs" name="labs">
1299 <sect1>assert<label id="assert"><p>
1303 <tag/Function/Test a condition and possibly abort.
1304 <tag/Header/<tt/<ref id="assert.h" name="assert.h">/
1305 <tag/Declaration/<tt/void assert (int cond);/
1306 <tag/Description/<tt/assert/ is a macro that expands to a <tt/id/
1307 statement. If the condition evaluates t zero (false), assert prints a message
1308 on stderr and aborts the program.
1309 <tag/Notes/<itemize>
1310 <item>The function is actually a macro.
1312 <tag/Availability/ISO 9899
1314 <ref id="abort" name="abort">,
1315 <ref id="exit" name="exit">
1321 <sect1>atexit<label id="atexit"><p>
1325 <tag/Function/Register an exit function.
1326 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1327 <tag/Declaration/<tt/int __fastcall__ atexit (void (*exitfunc) (void));/
1328 <tag/Description/<tt/atexit/ registers the function pointed to by
1329 <tt/exitfunc/ as an exit function. Exit functions are called when the program
1330 terminates, they are called in LIFO order (the last function registered is
1331 called first). <tt/atexit/ returns zero on success and a nonzero value on
1333 <tag/Notes/<itemize>
1334 <item>A maximum of 5 exit functions can be registered.
1335 <item>There is no way to unregister an exit function.
1336 <item>The function is only available as fastcall function, so it may only be
1337 used in presence of a prototype.
1339 <tag/Availability/ISO 9899
1341 <ref id="abort" name="abort">,
1342 <ref id="exit" name="exit">
1348 <sect1>atmos_explode<label id="atmos_explode"><p>
1352 <tag/Function/Bomb sound effect.
1353 <tag/Header/<tt/<ref id="atmos.h" name="atmos.h">/
1354 <tag/Declaration/<tt/void __fastcall__ atmos_explode(void);/
1355 <tag/Description/<tt/atmos_explode/ plays the BASIC sound.
1356 <tag/Notes/<itemize>
1357 <item>The function is available only as a fastcall function; so, it may be used
1358 only in the presence of a prototype.
1360 <tag/Availability/cc65
1362 <ref id="atmos_ping" name="atmos_ping">,
1363 <ref id="atmos_shoot" name="atmos_shoot">,
1364 <ref id="atmos_tick" name="atmos_tick">,
1365 <ref id="atmos_tock" name="atmos_tock">,
1366 <ref id="atmos_zap" name="atmos_zap">
1372 <sect1>atmos_load<label id="atmos_load"><p>
1376 <tag/Function/Load Atmos tape.
1377 <tag/Header/<tt/<ref id="atmos.h" name="atmos.h">/
1378 <tag/Declaration/<tt/void __fastcall__ atmos_load(const char* name);/
1379 <tag/Description/<tt/atmos_load/ reads a memory block from tape.
1380 <tag/Notes/<itemize>
1381 <item>The function is available only as a fastcall function; so, it may be used
1382 only in the presence of a prototype.
1384 <tag/Availability/cc65
1386 <ref id="atmos_save" name="atmos_save">
1392 <sect1>atmos_ping<label id="atmos_ping"><p>
1396 <tag/Function/Bell or ricochet sound effect.
1397 <tag/Header/<tt/<ref id="atmos.h" name="atmos.h">/
1398 <tag/Declaration/<tt/void __fastcall__ atmos_ping(void);/
1399 <tag/Description/<tt/atmos_ping/ plays the BASIC sound.
1400 <tag/Notes/<itemize>
1401 <item>The function is available only as a fastcall function; so, it may be used
1402 only in the presence of a prototype.
1404 <tag/Availability/cc65
1406 <ref id="atmos_explode" name="atmos_explode">,
1407 <ref id="atmos_shoot" name="atmos_shoot">,
1408 <ref id="atmos_tick" name="atmos_tick">,
1409 <ref id="atmos_tock" name="atmos_tock">,
1410 <ref id="atmos_zap" name="atmos_zap">
1416 <sect1>atmos_save<label id="atmos_save"><p>
1420 <tag/Function/Save Atmos tape.
1421 <tag/Header/<tt/<ref id="atmos.h" name="atmos.h">/
1422 <tag/Declaration/<tt/void __fastcall__ atmos_save(const char* name, const void* start, const void* end);/
1423 <tag/Description/<tt/atmos_save/ writes a memory block to tape.
1424 <tag/Notes/<itemize>
1425 <item>The function is available only as a fastcall function; so, it may be used
1426 only in the presence of a prototype.
1428 <tag/Availability/cc65
1430 <ref id="atmos_load" name="atmos_load">
1432 atmos_save("hires", 0xa000, 0xc000);
1438 <sect1>atmos_shoot<label id="atmos_shoot"><p>
1442 <tag/Function/Pistol sound effect.
1443 <tag/Header/<tt/<ref id="atmos.h" name="atmos.h">/
1444 <tag/Declaration/<tt/void __fastcall__ atmos_shoot(void);/
1445 <tag/Description/<tt/atmos_shoot/ plays the BASIC sound.
1446 <tag/Notes/<itemize>
1447 <item>The function is available only as a fastcall function; so, it may be used
1448 only in the presence of a prototype.
1450 <tag/Availability/cc65
1452 <ref id="atmos_explode" name="atmos_explode">,
1453 <ref id="atmos_ping" name="atmos_ping">,
1454 <ref id="atmos_tick" name="atmos_tick">,
1455 <ref id="atmos_tock" name="atmos_tock">,
1456 <ref id="atmos_zap" name="atmos_zap">
1462 <sect1>atmos_tick<label id="atmos_tick"><p>
1466 <tag/Function/High-pitch click.
1467 <tag/Header/<tt/<ref id="atmos.h" name="atmos.h">/
1468 <tag/Declaration/<tt/void __fastcall__ atmos_tick(void);/
1469 <tag/Description/<tt/atmos_tick/ plays the system sound.
1470 <tag/Notes/<itemize>
1471 <item>The function is available only as a fastcall function; so, it may be used
1472 only in the presence of a prototype.
1474 <tag/Availability/cc65
1476 <ref id="atmos_explode" name="atmos_explode">,
1477 <ref id="atmos_ping" name="atmos_ping">,
1478 <ref id="atmos_shoot" name="atmos_shoot">,
1479 <ref id="atmos_tock" name="atmos_tock">,
1480 <ref id="atmos_zap" name="atmos_zap">
1486 <sect1>atmos_tock<label id="atmos_tock"><p>
1490 <tag/Function/Low-pitch click.
1491 <tag/Header/<tt/<ref id="atmos.h" name="atmos.h">/
1492 <tag/Declaration/<tt/void __fastcall__ atmos_tock(void);/
1493 <tag/Description/<tt/atmos_tock/ plays the system sound.
1494 <tag/Notes/<itemize>
1495 <item>The function is available only as a fastcall function; so, it may be used
1496 only in the presence of a prototype.
1498 <tag/Availability/cc65
1500 <ref id="atmos_explode" name="atmos_explode">,
1501 <ref id="atmos_ping" name="atmos_ping">,
1502 <ref id="atmos_shoot" name="atmos_shoot">,
1503 <ref id="atmos_tick" name="atmos_tick">,
1504 <ref id="atmos_zap" name="atmos_zap">
1510 <sect1>atmos_zap<label id="atmos_zap"><p>
1514 <tag/Function/Raygun sound effect.
1515 <tag/Header/<tt/<ref id="atmos.h" name="atmos.h">/
1516 <tag/Declaration/<tt/void __fastcall__ atmos_zap(void);/
1517 <tag/Description/<tt/atmos_zap/ plays the BASIC sound.
1518 <tag/Notes/<itemize>
1519 <item>The function is available only as a fastcall function; so, it may be used
1520 only in the presence of a prototype.
1522 <tag/Availability/cc65
1524 <ref id="atmos_explode" name="atmos_explode">,
1525 <ref id="atmos_ping" name="atmos_ping">,
1526 <ref id="atmos_shoot" name="atmos_shoot">,
1527 <ref id="atmos_tick" name="atmos_tick">,
1528 <ref id="atmos_tock" name="atmos_tock">
1534 <sect1>atoi<label id="atoi"><p>
1538 <tag/Function/Convert a string to an integer.
1539 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1540 <tag/Declaration/<tt/int __fastcall__ atoi (const char* s);/
1541 <tag/Description/<tt/atoi/ converts the given string into an integer.
1542 Conversion stops as soon as any invalid character is encountered.
1543 <tag/Notes/<itemize>
1544 <item>There is no way to detect any conversion errors.
1545 <item>The function does not check for an numerical overflow when converting.
1546 <item>The function is only available as fastcall function, so it may only be
1547 used in presence of a prototype.
1549 <tag/Availability/ISO 9899
1551 <ref id="atol" name="atol">,
1552 <ref id="itoa" name="itoa">,
1553 <ref id="ltoa" name="ltoa">,
1554 <ref id="ultoa" name="ultoa">,
1555 <ref id="utoa" name="utoa">
1561 <sect1>atol<label id="atol"><p>
1565 <tag/Function/Convert a string to a long integer.
1566 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1567 <tag/Declaration/<tt/long __fastcall__ atol (const char* s);/
1568 <tag/Description/<tt/atol/ converts the given string into a long integer.
1569 Conversion stops as soon as any invalid character is encountered.
1570 <tag/Notes/<itemize>
1571 <item>There is no way to detect any conversion errors.
1572 <item>The function does not check for an numerical overflow when converting.
1573 <item>The function is only available as fastcall function, so it may only be
1574 used in presence of a prototype.
1576 <tag/Availability/ISO 9899
1578 <ref id="atoi" name="atoi">,
1579 <ref id="itoa" name="itoa">,
1580 <ref id="ltoa" name="ltoa">,
1581 <ref id="ultoa" name="ultoa">,
1582 <ref id="utoa" name="utoa">
1588 <sect1>bgcolor<label id="bgcolor"><p>
1592 <tag/Function/Set the background text color.
1593 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1594 <tag/Declaration/<tt/unsigned char __fastcall__ bgcolor (unsigned char color);/
1595 <tag/Description/The function will set a new background color and return the
1596 old (current) one. The background color is valid for the whole text output
1597 area of the screen, not just for new text.
1598 <tag/Notes/<itemize>
1599 <item>Background colors are system dependent. The function may have no effect
1600 on systems where the background color cannot be changed.
1601 <item>The function is only available as fastcall function, so it may only be
1602 used in presence of a prototype.
1604 <tag/Availability/cc65
1606 <ref id="bordercolor" name="bordercolor">,
1607 <ref id="textcolor" name="textcolor">
1613 <sect1>bordercolor<label id="bordercolor"><p>
1617 <tag/Function/Set the border (frame) color.
1618 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1619 <tag/Declaration/<tt/unsigned char __fastcall__ bordercolor (unsigned char color);/
1620 <tag/Description/The function will set a new border color. It returns the old
1621 (current) border color.
1622 <tag/Notes/<itemize>
1623 <item>Border colors are system dependent. The function may have no effect
1624 on systems where the border color cannot be changed.
1625 <item>The function is only available as fastcall function, so it may only
1626 be used in presence of a prototype.
1628 <tag/Availability/cc65
1630 <ref id="bgcolor" name="bgcolor">,
1631 <ref id="textcolor" name="textcolor">
1637 <sect1>bsearch<label id="bsearch"><p>
1641 <tag/Function/Do a binary search in a sorted array.
1642 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1643 <tag/Declaration/<tt/void* __fastcall__ bsearch (const void* key,
1644 const void* base, size_t n, size_t size,
1645 int __fastcall__ (* cmp) (const void*, const void*));/
1646 <tag/Description/<tt/bsearch/ searches a sorted array for a member that
1647 matches the one pointed to by <tt/key/. <tt/base/ is the address of the array,
1648 <tt/n/ is the number of elements, <tt/size/ the size of an element and <tt/cmp/
1649 the function used to compare the members against the key. The function returns
1650 a pointer to the member found, or <tt/NULL/ if there was no match.
1651 <tag/Notes/<itemize>
1652 <item>The contents of the array must be sorted in ascending order according to
1653 the compare function given.
1654 <item>If there are multiple members that match the key, the function will
1655 return one of the members.
1656 <item>The function is only available as fastcall function, so it may only
1657 be used in presence of a prototype.
1658 <item>The function to which <tt/cmp/ points must have the <tt/fastcall/ calling
1661 <tag/Availability/ISO 9899
1663 <ref id="qsort" name="qsort">
1669 <sect1>bzero<label id="bzero"><p>
1673 <tag/Function/Fill a memory area with zeroes.
1674 <tag/Header/<tt/<ref id="string.h" name="string.h">/
1675 <tag/Declaration/<tt/void __fastcall__ bzero (void* p, size_t count);/
1676 <tag/Description/<tt/bzero/ fills the memory area pointed to by <tt/p/ with
1678 <tag/Notes/<itemize>
1679 <item>The function is non standard and therefore only available in non ANSI
1680 mode. You should use <tt/<ref id="memset" name="memset">/ instead.
1681 <item>The function is only available as fastcall function, so it may only
1682 be used in presence of a prototype.
1684 <tag/Availability/cc65
1686 <ref id="_swap" name="_swap">,
1687 <ref id="memcpy" name="memcpy">,
1688 <ref id="memmove" name="memmove">,
1689 <ref id="memset" name="memset">,
1695 <sect1>c64mode<label id="c64mode"><p>
1699 <tag/Function/Switch the C128 into C64 compatible mode.
1700 <tag/Header/<tt/<ref id="c128.h" name="c128.h">/
1701 <tag/Declaration/<tt/void c64mode (void);/
1702 <tag/Description/The function will cause the machine to reboot into C64 mode.
1703 <tag/Notes/<itemize>
1704 <item>The function is specific to the C128.
1705 <item>The function will not return to the caller.
1707 <tag/Availability/C128
1713 <sect1>calloc<label id="calloc"><p>
1717 <tag/Function/Allocate and clear memory.
1718 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1719 <tag/Declaration/<tt/void* __fastcall__ calloc (size_t n, size_t size);/
1720 <tag/Description/<tt/calloc/ allocates memory for an array of <tt/n/ elements
1721 of size <tt/size/, clears the whole block with binary zeroes and returns a
1722 pointer to it. On error (not enough memory available), <tt/calloc/ returns
1724 <tag/Notes/<itemize>
1725 <item>Clearing the memory may not have the expected effect on all platforms:
1726 pointers in the block may not be <tt/NULL/ and floating point variables may
1727 not be zero (0.0). In other words: The "clearing" effect of this function
1728 should be used with care for portable programs.
1729 <item>The function is only available as fastcall function, so it may only
1730 be used in presence of a prototype.
1732 <tag/Availability/ISO 9899
1734 <ref id="_heapadd" name="_heapadd">,
1735 <ref id="_heapblocksize" name="_heapblocksize">,
1736 <ref id="_heapmaxavail" name="_heapmaxavail">,
1737 <ref id="_heapmemavail" name="_heapmemavail">,
1738 <ref id="free" name="free">,
1739 <ref id="malloc" name="malloc">,
1740 <ref id="realloc" name="realloc">
1746 <sect1>cbm_k_acptr<label id="cbm_k_acptr"><p>
1750 <tag/Function/Input byte from serial bus
1751 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
1752 <tag/Declaration/<tt/unsigned char cbm_k_acptr (void);/
1753 <tag/Description/The function returns a byte of data, which it
1754 gets from the current TALKer on the serial bus.
1755 In order to receive the data, the device must have previously been
1756 sent a command to TALK and a secondary address if it needs one.
1757 <tag/Notes/<itemize>
1760 <tag/Availability/cc65
1762 <ref id="cbm_k_talk" name="cbm_k_talk">,
1768 <sect1>cbm_k_basin<label id="cbm_k_basin"><p>
1772 <tag/Function/Input a Character from the Current Device
1773 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
1774 <tag/Declaration/<tt/unsigned char cbm_k_basin (void);/
1775 <tag/Description/The function returns a character from the current input device.
1776 Device must first have been OPENed and then designated as the input channel by the CHKIN routine.
1777 When this function is called, the next byte of data available from the device is returned.
1778 Exception is the routine for the keyboard device (which is the default input device).
1779 <tag/Notes/<itemize>
1782 <tag/Availability/cc65
1784 <ref id="cbm_k_open" name="cbm_k_open">,
1785 <ref id="cbm_k_chkin" name="cbm_k_chkin">
1791 <sect1>cbm_k_bsout<label id="cbm_k_bsout"><p>
1795 <tag/Function/Output a byte
1796 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
1797 <tag/Declaration/<tt/void __fastcall__ cbm_k_bsout (unsigned char C);/
1798 <tag/Description/Function sends the character to the current output device.
1799 Unless a device has been OPENed and designated as the
1800 current output channel using the CHKOUT routine, the character is
1801 printed to the screen, which is the default output device. If the
1802 cassette is the current device, outputting a byte will only add it to
1803 the buffer. No actual transmission of data will occur until the
1804 192-byte buffer is full.
1805 <tag/Notes/<itemize>
1806 <item>The function is only available as fastcall function, so it may
1807 only be used in presence of a prototype.
1809 <tag/Availability/cc65
1811 <ref id="cbm_k_open" name="cbm_k_open">,
1812 <ref id="cbm_k_chkin" name="cbm_k_chkout">
1818 <sect1>cbm_k_chkin<label id="cbm_k_chkin"><p>
1822 <tag/Function/Designate a Logical File As the Current Input Channel
1823 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
1824 <tag/Declaration/<tt/unsigned char __fastcall__ cbm_k_chkin (unsigned char FN);/
1825 <tag/Description/If you wish to
1826 get data from any device other than the keyboard, this function must be
1827 called after OPENing the device, before you can get a data byte with
1828 the cbm_k_basin or cbm_k_getin routine. When called, the routine will designate
1829 the logical file whose file number was supplied as the
1830 current file, its device as the current device, and its secondary
1831 address as the current secondary address. If the device on the
1832 channel is a serial device, which requires a TALK command and
1833 sometimes a secondary address, function will send them over the
1835 <tag/Notes/<itemize>
1836 <item>The function is only available as fastcall function, so it may
1837 only be used in presence of a prototype.
1839 <tag/Availability/cc65
1841 <ref id="cbm_k_open" name="cbm_k_open">,
1842 <ref id="cbm_k_basin" name="cbm_k_basin">,
1843 <ref id="cbm_k_getin" name="cbm_k_getin">
1849 <sect1>cbm_k_ciout<label id="cbm_k_ciout"><p>
1853 <tag/Function/Transmit a byte over the serial bus
1854 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
1855 <tag/Declaration/<tt/void __fastcall__ cbm_k_ciout (unsigned char C);/
1856 <tag/Description/Purpose of this function is to send a byte of data over
1857 the serial bus. In order for the data to be received, the serial
1858 device must have first been commanded to LISTEN and been given a
1859 secondary address if necessary. This routine always buffers the
1860 current character, and defers sending it until the next byte is
1861 buffered. When the UNLISTEN command is sent, the last byte will be
1862 sent with an End or Identify (EOI).
1863 <tag/Notes/<itemize>
1864 <item>The function is only available as fastcall function, so it may
1865 only be used in presence of a prototype.
1867 <tag/Availability/cc65
1869 <ref id="cbm_k_listen" name="cbm_k_listen">,
1870 <ref id="cbm_k_unlsn" name="cbm_k_unlsn">
1876 <sect1>cbm_k_ckout<label id="cbm_k_ckout"><p>
1880 <tag/Function/Designate a Logical File As the Current Output Channel
1881 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
1882 <tag/Declaration/<tt/unsigned char __fastcall__ cbm_k_ckout (unsigned char FN);/
1883 <tag/Description/If you wish to
1884 output data to any device other than the screen, this routine must be
1885 called after OPENing the device, and before you output a data byte
1886 with the cbm_k_bsout() function. When called, the function will designate the
1887 logical file whose file number was supplied as the current
1888 file, its device as the current device, and its secondary address as
1889 the current secondary address. If the device on the channel uses the
1890 serial bus, and therefore requires a LISTEN command and possibly a
1891 secondary address, this information will be sent on the bus.
1892 <tag/Notes/<itemize>
1893 <item>The function is only available as fastcall function, so it may
1894 only be used in presence of a prototype.
1896 <tag/Availability/cc65
1898 <ref id="cbm_k_bsout" name="cbm_k_bsout">,
1899 <ref id="cbm_k_listen" name="cbm_k_listen">
1905 <sect1>cbm_k_clall<label id="cbm_k_clall"><p>
1909 <tag/Function/Close All Logical I/O Files
1910 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
1911 <tag/Declaration/<tt/void cbm_k_clall (void);/
1912 <tag/Description/It closes all
1913 open files, by resetting the index into open files to
1914 zero and restores the default I/O devices.
1915 <tag/Notes/<itemize>
1918 <tag/Availability/cc65
1920 <ref id="cbm_k_open" name="cbm_k_open">,
1921 <ref id="cbm_k_close" name="cbm_k_close">
1927 <sect1>cbm_k_close<label id="cbm_k_close"><p>
1931 <tag/Function/Close a Logical I/O File
1932 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
1933 <tag/Declaration/<tt/void __fastcall__ cbm_k_close (unsigned char FN);/
1934 <tag/Description/It is used to
1935 close a logical file after all I/O operations involving that file have
1937 <tag/Notes/<itemize>
1938 <item>The function is only available as fastcall function, so it may
1939 only be used in presence of a prototype.
1941 <tag/Availability/cc65
1943 <ref id="cbm_k_open" name="cbm_k_open">,
1944 <ref id="cbm_k_clall" name="cbm_k_clall">
1950 <sect1>cbm_k_clrch<label id="cbm_k_clrch"><p>
1954 <tag/Function/Restore Current Input and Output Devices to the Default Devices
1955 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
1956 <tag/Declaration/<tt/void cbm_k_clrch (void);/
1957 <tag/Description/It sets the
1958 current input device to the keyboard, and the current output device to
1959 the screen. Also, if the current input device was formerly a serial
1960 device, the routine sends it an UNTALK command on the serial bus, and
1961 if a serial device was formerly the current output device, the routine
1962 sends it an UNLISTEN command.
1963 <tag/Notes/<itemize>
1966 <tag/Availability/cc65
1968 <ref id="cbm_k_chkin" name="cbm_k_chkin">,
1969 <ref id="cbm_k_ckout" name="cbm_k_ckout">
1975 <sect1>cbm_k_getin<label id="cbm_k_getin"><p>
1979 <tag/Function/Get One Byte from the Input Device
1980 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
1981 <tag/Declaration/<tt/unsigned char cbm_k_getin (void);/
1982 <tag/Description/Function gets a character from the current input device.
1983 <tag/Notes/<itemize>
1986 <tag/Availability/cc65
1988 <ref id="cbm_k_basin" name="cbm_k_basin">
1994 <sect1>cbm_k_iobase<label id="cbm_k_iobase"><p>
1998 <tag/Function/Return Base Address of Memory-Mapped I/O Devices
1999 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
2000 <tag/Declaration/<tt/unsigned cbm_k_iobase (void);/
2001 <tag/Description/This function returns the address of
2002 the memory section where the memory mapped I/O devices are located. This
2003 address can then be used with an offset to access the memory mapped I/O
2004 devices in the Commodore 64. The offset is the number of locations from
2005 the beginning of the page on which the I/O register you want is located.
2006 This function exists to provide compatibility between the Commodore 64,
2007 VIC-20, and future models of the Commodore 64. If the I/O locations for
2008 a program are set by a call to this function, they should
2009 still remain compatible with future versions of the Commodore 64, the
2011 <tag/Notes/<itemize>
2014 <tag/Availability/cc65
2022 <sect1>cbm_k_listen<label id="cbm_k_listen"><p>
2026 <tag/Function/Command a device on the serial bus to LISTEN
2027 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
2028 <tag/Declaration/<tt/void __fastcall__ cbm_k_listen (unsigned char dev);/
2029 <tag/Description/This function will command a device on the serial bus to
2030 receive data. The KERNAL routine will OR the supplied device number bit by bit
2031 to convert it to a listen address, then transmits this data as a command on
2032 the serial bus. The specified device will then go into listen mode, and
2033 be ready to accept information.
2034 <tag/Notes/<itemize>
2035 <item>The function is only available as fastcall function, so it may
2036 only be used in presence of a prototype.
2038 <tag/Availability/cc65
2040 <ref id="cbm_k_unlsn" name="cbm_k_unlsn">,
2046 <sect1>cbm_k_load<label id="cbm_k_load"><p>
2050 <tag/Function/Load RAM from a Device
2051 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
2052 <tag/Declaration/<tt/unsigned int __fastcall__ cbm_k_load(unsigned char flag, unsigned addr);/
2053 <tag/Description/This function LOADs data bytes from any input device directly into the memory.
2054 It can also be used for a verify operation, comparing data from a device with the data already in
2055 memory, while leaving the data stored in RAM unchanged.
2056 The flag must be set to 0 for a LOAD operation, or 1 for a
2057 verify, If the input device is OPENed with a secondary address (SA) of 0
2058 the header information from the device is ignored. In this case, the starting address for the load must be supplied.
2059 If the device is addressed with a secondary address of 1, then the data is
2060 loaded into memory starting at the location specified by the header.
2061 Function returns the address of the highest RAM location loaded.
2062 Before this function can be called, the KERNAL SETLFS, and SETNAM
2063 routines must be called.
2064 <tag/Notes/<itemize>
2065 <item>The function is only available as fastcall function, so it may
2066 only be used in presence of a prototype.
2068 <tag/Availability/cc65
2070 <ref id="cbm_k_save" name="cbm_k_save">,
2071 <ref id="cbm_k_setlfs" name="cbm_k_setlfs">,
2072 <ref id="cbm_k_setnam" name="cbm_k_setnam">
2078 <sect1>cbm_k_open<label id="cbm_k_open"><p>
2082 <tag/Function/Open a Logical I/O File
2083 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
2084 <tag/Declaration/<tt/unsigned char cbm_k_open (void);/
2085 <tag/Description/This function assigns a logical file to a device, so that it can be used for
2086 Input/Output operations. In order to specify the logical file number,
2087 the device number, and the secondary address if any, the cbm_k_setlfs() function must first be called.
2088 Likewise, in order to designate the filename, the cbm_k_setnam() function must be used first. After these two
2089 functions are called, cbm_k_open() is then called.
2090 <tag/Notes/<itemize>
2093 <tag/Availability/cc65
2095 <ref id="cbm_k_close" name="cbm_k_close">,
2096 <ref id="cbm_k_setlfs" name="cbm_k_setlfs">,
2097 <ref id="cbm_k_setnam" name="cbm_k_setnam">
2103 <sect1>cbm_k_readst<label id="cbm_k_readst"><p>
2107 <tag/Function/Read status word
2108 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
2109 <tag/Declaration/<tt/unsigned char cbm_k_readst (void);/
2110 <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.
2111 <tag/Notes/<itemize>
2114 <tag/Availability/cc65
2122 <sect1>cbm_k_save<label id="cbm_k_save"><p>
2126 <tag/Function/Save RAM to a Device
2127 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
2128 <tag/Declaration/<tt/unsigned char __fastcall__ cbm_k_save(unsigned int start, unsigned int end)/
2129 <tag/Description/This function saves a section of memory. The cbm_k_setlfs() and cbm_k_setnam() functions must be
2130 used before calling this function. However, a file name is not required to
2131 SAVE to device 1 (the Datassette(TM) recorder). Any attempt to save to
2132 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.
2133 <tag/Notes/<itemize>
2134 <item>The function is only available as fastcall function, so it may
2135 only be used in presence of a prototype.
2137 <tag/Availability/cc65
2139 <ref id="cbm_k_load" name="cbm_k_load">,
2140 <ref id="cbm_k_setlfs" name="cbm_k_setlfs">,
2141 <ref id="cbm_k_setnam" name="cbm_k_setnam">
2147 <sect1>cbm_k_scnkey<label id="cbm_k_scnkey"><p>
2151 <tag/Function/Scan the keyboard matrix.
2152 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
2153 <tag/Declaration/<tt/void cbm_k_scnkey (void);/
2154 <tag/Description/This function looks at the switches in the keyboard, to see
2155 if any of them are being pressed. If they are, then code numbers for them are
2156 stored in RAM. Other functions use those numbers to input text. Normally,
2157 the keyboard is scanned by the Kernal's Interrupt Service Routine. But, if
2158 you divert the "Jiffy interrupt" to a C-code ISR, then that ISR must call this
2159 function, in order to provide input from the keyboard.
2160 <tag/Availability/cc65
2162 <ref id="cbm_k_getin" name="cbm_k_getin">,
2163 <ref id="cbm_k_udtim" name="cbm_k_udtim">,
2164 <ref id="cgetc" name="cgetc">,
2165 <!-- <ref id="getc" name="getc"> -->
2166 <!-- <ref id="getchar" name="getchar"> -->
2172 <sect1>cbm_k_setlfs<label id="cbm_k_setlfs"><p>
2176 <tag/Function/Set up a logical file
2177 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
2178 <tag/Declaration/<tt/void __fastcall__ cbm_k_setlfs (unsigned char LFN, unsigned char DEV, unsigned char SA);/
2179 <tag/Description/This functions sets up the logical file by setting its number, device address,
2180 and secondary address.
2181 <tag/Notes/<itemize>
2182 <item>The function is only available as fastcall function, so it may
2183 only be used in presence of a prototype.
2185 <tag/Availability/cc65
2187 <ref id="cbm_k_setnam" name="cbm_k_setnam">
2193 <sect1>cbm_k_setnam<label id="cbm_k_setnam"><p>
2197 <tag/Function/Set Filename Parameters
2198 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
2199 <tag/Declaration/<tt/void __fastcall__ cbm_k_setnam (const char* Name);/
2200 <tag/Description/This function is used to set up the file name for the OPEN,
2201 SAVE, or LOAD operations.
2202 <tag/Notes/<itemize>
2203 <item>The function is only available as fastcall function, so it may
2204 only be used in presence of a prototype.
2206 <tag/Availability/cc65
2208 <ref id="cbm_k_open" name="cbm_k_open">,
2209 <ref id="cbm_k_load" name="cbm_k_load">,
2210 <ref id="cbm_k_save" name="cbm_k_save">
2216 <sect1>cbm_k_talk<label id="cbm_k_talk"><p>
2220 <tag/Function/Commands device to TALK
2221 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
2222 <tag/Declaration/<tt/void __fastcall__ cbm_k_talk (unsigned char dev);/
2223 <tag/Description/When called, it ORs the device number with the TALK code (64, $40) and sends it on the serial
2224 bus. This commands the device to TALK.
2225 <tag/Notes/<itemize>
2226 <item>The function is only available as fastcall function, so it may
2227 only be used in presence of a prototype.
2229 <tag/Availability/cc65
2231 <ref id="cbm_k_acptr" name="cbm_k_acptr">
2237 <sect1>cbm_k_udtim<label id="cbm_k_udtim"><p>
2241 <tag/Function/Update the Jiffy clock.
2242 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
2243 <tag/Declaration/<tt/void cbm_k_udtim (void);/
2244 <tag/Description/This function adds one count to the Jiffy clock. That clock
2245 counts sixtieths of a second. It is used by the library's <tt/clock()/
2246 function. Normally, the Jiffy clock is updated by the Kernal's Interrupt
2247 Service Routine. But, if you divert the "Jiffy interrupt" to a C-code ISR,
2248 then that ISR must call this function, in order to keep the clock valid.
2249 <tag/Availability/cc65
2251 <ref id="cbm_k_scnkey" name="cbm_k_scnkey">,
2252 <ref id="clock" name="clock">
2258 <sect1>cbm_k_unlsn<label id="cbm_k_unlsn"><p>
2262 <tag/Function/Send an UNLISTEN command
2263 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
2264 <tag/Declaration/<tt/void cbm_k_unlsn (void);/
2265 <tag/Description/This function commands all devices on the serial bus to
2266 stop receiving data from the host computer (i.e., UNLISTEN). Calling this
2267 function results in an UNLISTEN command being transmitted on the serial
2268 bus. Only devices previously commanded to LISTEN are affected. This
2269 function is normally used after the host computer is finished sending data
2270 to external devices. Sending the UNLISTEN commands the listening devices
2271 to get off the serial bus so it can be used for other purposes.
2272 <tag/Notes/<itemize>
2275 <tag/Availability/cc65
2277 <ref id="cbm_k_listen" name="cbm_k_listen">
2283 <sect1>cclear<label id="cclear"><p>
2287 <tag/Function/Clear part of a line (write a given number of spaces).
2288 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2289 <tag/Declaration/<tt/void __fastcall__ cclear (unsigned char length);/
2290 <tag/Description/The function clears part of a line by writing <tt/length/
2291 spaces in the current text color.
2292 <tag/Notes/<itemize>
2293 <item>The function is only available as fastcall function, so it may
2294 only be used in presence of a prototype.
2296 <tag/Availability/cc65
2298 <ref id="cclearxy" name="cclearxy">,
2299 <ref id="clrscr" name="clrscr">
2305 <sect1>cclearxy<label id="cclearxy"><p>
2309 <tag/Function/Clear part of a line (write a given number of spaces) starting
2310 at a specific screen position.
2311 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2312 <tag/Declaration/<tt/void __fastcall__ cclearxy (unsigned char x, unsigned char y, unsigned char length);/
2313 <tag/Description/The function moves the cursor to a specific position, and
2314 will then clear part of the line by writing <tt/length/ spaces in the current
2316 <tag/Notes/<itemize>
2317 <item>The function is only available as fastcall function, so it may
2318 only be used in presence of a prototype.
2320 <tag/Availability/cc65
2322 <ref id="cclear" name="cclear">,
2323 <ref id="clrscr" name="clrscr">
2329 <sect1>cgetc<label id="cgetc"><p>
2333 <tag/Function/Read a character from the keyboard.
2334 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2335 <tag/Declaration/<tt/char cgetc (void);/
2336 <tag/Description/The function reads a character from the keyboard. If there is
2337 no character available, <tt/cgetc()/ waits until the user presses a key. If the
2338 cursor is enabled by use of the <tt/cursor/ function, a blinking cursor is
2339 displayed while waiting.
2340 <tag/Notes/<itemize>
2341 <item>If the system supports a keyboard buffer, <tt/cgetc()/ will fetch a key
2342 from that buffer; and, wait only if the buffer is empty.
2343 <item>The keyboard must be scanned periodically, in order for this function to
2344 see anything that you type. (See the description of <tt/cbm_k_scnkey()/.)
2346 <tag/Availability/cc65
2348 <ref id="cbm_k_scnkey" name="cbm_k_scnkey">,
2349 <ref id="cursor" name="cursor">,
2350 <ref id="kbhit" name="kbhit">
2356 <sect1>chline<label id="chline"><p>
2360 <tag/Function/Output a horizontal line in text mode.
2361 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2362 <tag/Declaration/<tt/void __fastcall__ chline (unsigned char length);/
2363 <tag/Description/The function outputs a horizontal line with the given length
2364 starting at the current cursor position.
2365 <tag/Notes/<itemize>
2366 <item>The character used to draw the horizontal line is system dependent.
2367 If available, a line drawing character is used. Drawing a line that is partially
2368 off screen leads to undefined behaviour.
2369 <item>The function is only available as fastcall function, so it may only be
2370 used in presence of a prototype.
2372 <tag/Availability/cc65
2374 <ref id="chlinexy" name="chlinexy">,
2375 <ref id="cvline" name="cvline">,
2376 <ref id="cvlinexy" name="cvlinexy">
2382 <sect1>chlinexy<label id="chlinexy"><p>
2386 <tag/Function/Output a horizontal line at a given position in text mode.
2387 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2388 <tag/Declaration/<tt/void __fastcall__ chlinexy (unsigned char x, unsigned char y, unsigned char length);/
2389 <tag/Description/The function outputs a horizontal line with the given length
2390 starting at a given position.
2391 <tag/Notes/<itemize>
2392 <item>The character used to draw the horizontal line is system dependent.
2393 If available, a line drawing character is used. Drawing a line that is partially
2394 off screen leads to undefined behaviour.
2395 <item>The function is only available as fastcall function, so it may only be
2396 used in presence of a prototype.
2398 <tag/Availability/cc65
2400 <ref id="chline" name="chline">,
2401 <ref id="cvline" name="cvline">,
2402 <ref id="cvlinexy" name="cvlinexy">
2408 <sect1>clearerr<label id="clearerr"><p>
2412 <tag/Function/Clear error and end-of-file status of a stream.
2413 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
2414 <tag/Declaration/<tt/void __fastcall__ clearerr (FILE* f);/
2415 <tag/Description/<tt/clearerr/ clears the error and end-of-file status
2416 indicators for the stream <tt/f/.
2417 <tag/Notes/<itemize>
2418 <item>The function is only available as fastcall function, so it may only be
2419 used in presence of a prototype.
2421 <tag/Availability/ISO 9899
2423 <ref id="feof" name="feof">,
2424 <ref id="ferror" name="ferror">
2430 <sect1>clock<label id="clock"><p>
2434 <tag/Function/Determine the processor time used.
2435 <tag/Header/<tt/<ref id="time.h" name="time.h">/
2436 <tag/Declaration/<tt/clock_t clock (void);/
2437 <tag/Description/The <tt/clock/ function returns an approximaton of processor
2438 time used by the program. The time is returned in implementation-defined
2439 units. It can be converted to seconds by dividing by the value of the macro
2440 <tt/CLOCKS_PER_SEC/.
2441 <tag/Notes/<itemize>
2442 <item>Since the machines that cc65-generated programs run on cannot run multiple
2443 processes, the function actually will return the time since some
2444 implementation-defined point in the past.
2445 <item>The Jiffy clock must be "running", in order for this function to return
2446 changing values. (See the description of <tt/cbm_k_udtim()/.)
2448 <tag/Availability/ISO 9899
2450 <ref id="cbm_k_udtim" name="cbm_k_udtim">,
2451 <ref id="time" name="time">
2457 <sect1>clrscr<label id="clrscr"><p>
2461 <tag/Function/Clear the text screen.
2462 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2463 <tag/Declaration/<tt/void clrscr (void);/
2464 <tag/Description/The function clears the text screen and moves the cursor to
2465 the upper left corner.
2466 <tag/Availability/cc65
2468 <ref id="cclear" name="cclear">,
2469 <ref id="cclearxy" name="cclearxy">
2475 <sect1>close<label id="close"><p>
2479 <tag/Function/Close a file descriptor.
2480 <tag/Header/<tt/<ref id="fcntl.h" name="fcntl.h">/
2481 <tag/Declaration/<tt/int __fastcall__ close (int fd);/
2482 <tag/Description/The function closes the given file descriptor. It returns zero
2483 on success and -1 on error. If an error occurs, the cause can be determined by
2484 reading the <tt/errno/ variable.
2485 <tag/Notes/<itemize>
2486 <item>The function is only available as fastcall function, so it may only
2487 be used in presence of a prototype.
2489 <tag/Availability/POSIX 1003.1
2491 <ref id="creat" name="creat">,
2492 <ref id="open" name="open">
2498 <sect1>closedir<label id="closedir"><p>
2502 <tag/Function/Close a directory.
2503 <tag/Header/<tt/<ref id="dirent.h" name="dirent.h">/
2504 <tag/Declaration/<tt/int __fastcall__ closedir (DIR* dir);/
2505 <tag/Description/The function closes the given directory descriptor. It returns
2506 zero on success and -1 on error. If an error occurs, the cause can be determined
2507 by reading the <tt/errno/ variable.
2508 <tag/Notes/<itemize>
2509 <item>The function is only available as fastcall function, so it may only
2510 be used in presence of a prototype.
2512 <tag/Availability/POSIX 1003.1
2514 <ref id="opendir" name="opendir">,
2515 <ref id="readdir" name="readdir">
2521 <sect1>creat<label id="creat"><p>
2525 <tag/Function/Create a file.
2526 <tag/Header/<tt/<ref id="fcntl.h" name="fcntl.h">/
2527 <tag/Declaration/<tt/int __fastcall__ creat (const char* name, unsigned mode);/
2528 <tag/Description/<tt/creat/ creates a new file and returns the file descriptor
2529 associated with it. On error, -1 is returned and an error code is stored in
2531 <tag/Notes/<itemize>
2532 <item><tt/creat/ is identical to calling <tt/<ref id="open" name="open">/ with
2533 <tt/flags/ equal to <tt/O_WRONLY | O_CREAT | O_TRUNC/.
2534 <item>The function is only available as fastcall function, so it may only
2535 be used in presence of a prototype.
2537 <tag/Availability/POSIX 1003.1
2539 <ref id="close" name="close">,
2540 <ref id="open" name="open">
2546 <sect1>cprintf<label id="cprintf"><p>
2550 <tag/Function/Formatted output to the console.
2551 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2552 <tag/Declaration/<tt/int cprintf (const char* format, ...);/
2553 <tag/Description/The arguments are converted to text where necessary and
2554 formatted according to the format string given. The resulting string is output
2555 to the console. <tt/cprintf/ supports the same format specifiers as
2556 <tt/printf/. <!-- <tt/<ref id="printf" name="printf">/. -->
2557 <tag/Notes/<itemize>
2558 <item>Like all other <tt/conio/ output functions, <tt/cprintf/ distinguishes
2559 between <tt/\r/ and <tt/\n/.
2561 <tag/Availability/cc65
2563 <ref id="cputc" name="cputc">,
2564 <ref id="cputcxy" name="cputcxy">,
2565 <ref id="cputs" name="cputs">,
2566 <ref id="cputsxy" name="cputsxy">,
2567 <ref id="vcprintf" name="vcprintf">
2573 <sect1>cputc<label id="cputc"><p>
2577 <tag/Function/Output a character directly to the console.
2578 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2579 <tag/Declaration/<tt/void __fastcall__ cputc (char c);/
2580 <tag/Description/Output one character to the console at the current cursor
2582 <tag/Notes/<itemize>
2583 <item>Like all other <tt/conio/ output functions, <tt/cputc/ distinguishes
2584 between <tt/\r/ and <tt/\n/.
2585 <item>The function is only available as fastcall function, so it may only
2586 be used in presence of a prototype.
2588 <tag/Availability/cc65
2590 <ref id="cprintf" name="cprintf">,
2591 <ref id="cputcxy" name="cputcxy">,
2592 <ref id="cputs" name="cputs">,
2593 <ref id="cputsxy" name="cputsxy">,
2594 <ref id="vcprintf" name="vcprintf">
2600 <sect1>cputcxy<label id="cputcxy"><p>
2604 <tag/Function/Output a character at a specific screen position.
2605 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2606 <tag/Declaration/<tt/void __fastcall__ cputcxy (unsigned char x, unsigned char y, char c);/
2607 <tag/Description/<tt/cputcxy/ moves the cursor to the given x/y position on
2608 the screen and outputs one character.
2609 <tag/Notes/<itemize>
2610 <item>Like all other <tt/conio/ output functions, <tt/cputcxy/ distinguishes
2611 between <tt/\r/ and <tt/\n/.
2612 <item>The function is only available as fastcall function, so it may only
2613 be used in presence of a prototype.
2615 <tag/Availability/cc65
2617 <ref id="cprintf" name="cprintf">,
2618 <ref id="cputc" name="cputc">,
2619 <ref id="cputs" name="cputs">,
2620 <ref id="cputsxy" name="cputsxy">,
2621 <ref id="vcprintf" name="vcprintf">
2627 <sect1>cputs<label id="cputs"><p>
2631 <tag/Function/Output a string directly to the console.
2632 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2633 <tag/Declaration/<tt/void __fastcall__ cputs (const char* s);/
2634 <tag/Description/The function outputs the given string on the console at the
2635 current cursor position.
2636 <tag/Notes/<itemize>
2637 <item>Like all other <tt/conio/ output functions, <tt/cputs/ distinguishes
2638 between <tt/\r/ and <tt/\n/.
2639 <item>The function is only available as fastcall function, so it may only
2640 be used in presence of a prototype.
2642 <tag/Availability/cc65
2644 <ref id="cprintf" name="cprintf">,
2645 <ref id="cputc" name="cputc">,
2646 <ref id="cputcxy" name="cputcxy">,
2647 <ref id="cputsxy" name="cputsxy">,
2648 <ref id="vcprintf" name="vcprintf">
2654 <sect1>cputsxy<label id="cputsxy"><p>
2658 <tag/Function/Output a string to the console at a given position.
2659 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2660 <tag/Declaration/<tt/void __fastcall__ cputsxy (unsigned char x, unsigned char y, const char* s);/
2661 <tag/Description/<tt/cputsxy/ moves the cursor to the given x/y position,
2662 and outputs the string <tt/s/.
2663 <tag/Notes/<itemize>
2664 <item>Like all other <tt/conio/ output functions, <tt/cputsxy/ distinguishes
2665 between <tt/\r/ and <tt/\n/.
2666 <item>The function is only available as fastcall function, so it may only
2667 be used in presence of a prototype.
2669 <tag/Availability/cc65
2671 <ref id="cprintf" name="cprintf">,
2672 <ref id="cputc" name="cputc">,
2673 <ref id="cputcxy" name="cputcxy">,
2674 <ref id="cputs" name="cputs">,
2675 <ref id="vcprintf" name="vcprintf">
2681 <sect1>cursor<label id="cursor"><p>
2685 <tag/Function/Enable/disable a blinking cursor when waiting for keyboard input.
2686 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2687 <tag/Declaration/<tt/unsigned char __fastcall__ cursor (unsigned char onoff);/
2688 <tag/Description/If the argument to the function is non zero, a blinking cursor
2689 will be enabled when the <tt/cgetc/ function waits for input from the keyboard.
2690 If the argument is zero, <tt/cgetc/ will wait without a blinking cursor.
2691 <tag/Notes/<itemize>
2692 <item>The function is only available as fastcall function, so it may only
2693 be used in presence of a prototype.
2695 <tag/Availability/cc65
2697 <ref id="cgetc" name="cgetc">,
2698 <ref id="kbhit" name="kbhit">
2704 <sect1>cvline<label id="cvline"><p>
2708 <tag/Function/Output a vertical line in text mode.
2709 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2710 <tag/Declaration/<tt/void __fastcall__ cvline (unsigned char length);/
2711 <tag/Description/The function outputs a vertical line with the given length
2712 starting at the current cursor position.
2713 <tag/Notes/<itemize>
2714 <item>The character used to draw the vertical line is system dependent.
2715 If available, a line drawing character is used. Drawing a line that is partially
2716 off screen leads to undefined behaviour.
2717 <item>The function is only available as fastcall function, so it may only be
2718 used in presence of a prototype.
2720 <tag/Availability/cc65
2722 <ref id="chline" name="chline">,
2723 <ref id="chlinexy" name="chlinexy">,
2724 <ref id="cvlinexy" name="cvlinexy">
2730 <sect1>cvlinexy<label id="cvlinexy"><p>
2734 <tag/Function/Output a vertical line at a given position in text mode.
2735 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2736 <tag/Declaration/<tt/void __fastcall__ cvlinexy (unsigned char x, unsigned char y, unsigned char length);/
2737 <tag/Description/The function outputs a vertical line with the given length
2738 starting at a given position.
2739 <tag/Notes/<itemize>
2740 <item>The character used to draw the vertical line is system dependent.
2741 If available, a line drawing character is used. Drawing a line that is partially
2742 off screen leads to undefined behaviour.
2743 <item>The function is only available as fastcall function, so it may only be
2744 used in presence of a prototype.
2746 <tag/Availability/cc65
2748 <ref id="chline" name="chline">,
2749 <ref id="chlinexy" name="chlinexy">,
2750 <ref id="cvline" name="cvline">
2756 <sect1>decompress_lz4<label id="decompress_lz4"><p>
2760 <tag/Function/Uncompress a LZ4-compressed buffer.
2761 <tag/Header/<tt/<ref id="lz4.h" name="lz4.h">/
2762 <tag/Declaration/<tt/void decompress_lz4 (const unsigned char* src, unsigned char* const dst, const unsigned short uncompressed_size);/
2763 <tag/Description/<tt/decompress_lz4/ uncompresses a LZ4-compressed buffer.
2764 <tag/Notes/<itemize>
2765 <item>Use LZ4_compress_HC with compression level 16 for best compression.
2767 <tag/Availability/cc65
2773 <sect1>div<label id="div"><p>
2777 <tag/Function/Divide two ints and return quotient and remainder.
2778 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
2779 <tag/Declaration/<tt/div_t __fastcall__ div (int numer, int denom);/
2780 <tag/Description/<tt/div/ divides <tt/numer/ by <tt/denom/ and returns the
2781 quotient and remainder in a <tt/div_t/ structure.
2782 <tag/Notes/<itemize>
2783 <item>The function is only available as fastcall function, so it may only
2784 be used in presence of a prototype.
2786 <tag/Availability/ISO 9899
2794 <sect1>doesclrscrafterexit<label id="doesclrscrafterexit"><p>
2798 <tag/Function/Determines whether the screen is going to be cleared after program exit.
2799 <tag/Header/<tt/<ref id="cc65.h" name="cc65.h">/
2800 <tag/Declaration/<tt/unsigned char doesclrscrafterexit (void);/
2801 <tag/Description/The function returns zero if the screen won't be cleared immediately after
2802 program termination. It returns a non-zero value if it will.
2803 <tag/Notes/<itemize>
2804 <item>Some systems, maybe depending on configuration, immediately clear the screen
2805 after a program exits. Therefore it might be difficult to read
2806 the last messages printed by the program prior to its exit. This function can be used
2807 to decide if a delay or wait for a key press should be executed when then program
2810 <tag/Availability/cc65
2818 printf("Hello World\n");
2819 if (doesclrscrafterexit())
2828 <sect1>em_commit<label id="em_commit"><p>
2832 <tag/Function/Commit changes into extended memory.
2833 <tag/Header/<tt/<ref id="em.h" name="em.h">/
2834 <tag/Declaration/<tt/void em_commit (void);/
2835 <tag/Description/Commit changes in the memory window to extended storage. If
2836 the contents of the memory window have been changed, these changes may be lost
2837 if <tt/<ref id="em_map" name="em_map">/, <tt/<ref id="em_use" name="em_use">/,
2838 <tt/<ref id="em_copyfrom" name="em_copyfrom">/ or <tt/<ref id="em_copyto"
2839 name="em_copyto">/ are called without calling <tt/em_commit/ first.
2840 <tag/Notes/<itemize>
2841 <item>Calling <tt/em_commit/ does not necessarily mean that changes to the
2842 memory window are discarded, it does just mean that the drivers is allowed
2844 <item>The function is only available as fastcall function, so it may only be
2845 used in presence of a prototype.
2846 <item>The function produces undefined results if no extended memory driver is
2849 <tag/Availability/cc65
2851 <ref id="em_load_driver" name="em_load_driver">,
2852 <ref id="em_map" name="em_map">,
2853 <ref id="em_use" name="em_use">
2859 <sect1>em_copyfrom<label id="em_copyfrom"><p>
2863 <tag/Function/Copy from extended into normal memory.
2864 <tag/Header/<tt/<ref id="em.h" name="em.h">/
2865 <tag/Declaration/<tt/void __fastcall__ em_copyfrom (const struct em_copy* copy_data);/
2866 <tag/Description/Copy data from extended memory into linear memory. Source and
2867 target addresses as well as the number of bytes to transfer are specified in
2868 the <tt/em_copy/ structure that is passed as a parameter.
2869 <tag/Notes/<itemize>
2870 <item>Calling <tt/em_copyfrom/ will invalidate the memory window, so if you
2871 made any changes to the data in the window, call <tt/<ref id="em_commit"
2872 name="em_commit">/ first, or the changes are lost.
2873 <item>The function is only available as fastcall function, so it may only be
2874 used in presence of a prototype.
2875 <item>The function produces undefined results if no extended memory driver is
2878 <tag/Availability/cc65
2880 <ref id="em_commit" name="em_commit">,
2881 <ref id="em_copyto" name="em_copyto">,
2882 <ref id="em_load_driver" name="em_load_driver">
2888 <sect1>em_copyto<label id="em_copyto"><p>
2892 <tag/Function/Copy from normal into extended memory.
2893 <tag/Header/<tt/<ref id="em.h" name="em.h">/
2894 <tag/Declaration/<tt/void __fastcall__ em_copyto (const struct em_copy* copy_data);/
2895 <tag/Description/Copy data from linear into extended memory. Source and
2896 target addresses as well as the number of bytes to transfer are specified in
2897 the <tt/em_copy/ structure that is passed as a parameter.
2898 <tag/Notes/<itemize>
2899 <item>Calling <tt/em_copyto/ will invalidate the memory window, so if you
2900 made any changes to the data in the window, call <tt/<ref id="em_commit"
2901 name="em_commit">/ first, or the changes are lost.
2902 <item>The function is only available as fastcall function, so it may only be
2903 used in presence of a prototype.
2904 <item>The function produces undefined results if no extended memory driver is
2907 <tag/Availability/cc65
2909 <ref id="em_commit" name="em_commit">,
2910 <ref id="em_copyfrom" name="em_copyfrom">,
2911 <ref id="em_load_driver" name="em_load_driver">
2917 <sect1>em_install<label id="em_install"><p>
2921 <tag/Function/Install an already loaded extended memory driver.
2922 <tag/Header/<tt/<ref id="em.h" name="em.h">/
2923 <tag/Declaration/<tt/unsigned char _fastcall__ em_install (void* driver);/
2924 <tag/Description/The function installs an already loaded extended memory driver
2925 and returns an error code. The function may be used to install a driver linked
2926 statically to the program.
2927 <tag/Notes/<itemize>
2928 <item>Not all drivers are able to detect if the supported hardware is really
2930 <item>The function is only available as fastcall function, so it may only be
2931 used in presence of a prototype.
2933 <tag/Availability/cc65
2935 <ref id="em_load_driver" name="em_load_driver">,
2936 <ref id="em_uninstall" name="em_uninstall">,
2937 <ref id="em_unload" name="em_unload">
2943 <sect1>em_load_driver<label id="em_load_driver"><p>
2947 <tag/Function/Load and initialize an extended memory driver.
2948 <tag/Header/<tt/<ref id="em.h" name="em.h">/
2949 <tag/Declaration/<tt/void __fastcall__ em_load_driver (const char* name);/
2950 <tag/Description/Load an extended memory driver into memory and initialize
2951 it. The function returns an error code that tells if all this has been
2953 <tag/Notes/<itemize>
2954 <item>Not all drivers are able to detect if the supported hardware is really
2956 <item>The function is only available as fastcall function, so it may only be
2957 used in presence of a prototype.
2958 <item>The driver is loaded by name, so currently you must know the type of
2959 extended memory that should be supported. There is no autodetect capability.
2961 <tag/Availability/cc65
2963 <ref id="em_unload" name="em_unload">
2969 <sect1>em_map<label id="em_map"><p>
2973 <tag/Function/Make a page of extended memory accessible.
2974 <tag/Header/<tt/<ref id="em.h" name="em.h">/
2975 <tag/Declaration/<tt/void* __fastcall__ em_map (unsigned page);/
2976 <tag/Description/The function maps one page of extended memory into linear
2977 memory and returns a pointer to the page frame. Depending on the hardware
2978 and driver, the data is either mapped into the address space or transfered
2979 into a buffer. If you don't need the actual contents of the page (for example
2980 because you're going to overwrite it completely), it is better to call
2981 <tt/<ref id="em_use" name="em_use">/ instead. <tt/em_use/ will not transfer the
2982 data if it is possible to avoid that.
2983 <tag/Notes/<itemize>
2984 <item>Calling <tt/em_map/ will invalidate the memory window, so if you
2985 made any changes to the data in the window, call <tt/<ref id="em_commit"
2986 name="em_commit">/ first, or the changes are lost.
2987 <item>The function is only available as fastcall function, so it may only be
2988 used in presence of a prototype.
2989 <item>The function produces undefined results if no extended memory driver is
2992 <tag/Availability/cc65
2994 <ref id="em_commit" name="em_commit">,
2995 <ref id="em_load_driver" name="em_load_driver">,
2996 <ref id="em_use" name="em_use">
3002 <sect1>em_pagecount<label id="em_pagecount"><p>
3006 <tag/Function/Return the number of available extended memory pages.
3007 <tag/Header/<tt/<ref id="em.h" name="em.h">/
3008 <tag/Declaration/<tt/unsigned em_pagecount (void);/
3009 <tag/Description/The function returns the size of the extended memory supported
3010 by the driver in 256 byte pages.
3011 <tag/Notes/<itemize>
3012 <item>The function returns zero if no extended memory driver is loaded.
3013 <item>The function may return zero if the supported hardware was not detected.
3015 <tag/Availability/cc65
3017 <ref id="em_load_driver" name="em_load_driver">
3023 <sect1>em_uninstall<label id="em_uninstall"><p>
3027 <tag/Function/Uninstall an already loaded extended memory driver.
3028 <tag/Header/<tt/<ref id="em.h" name="em.h">/
3029 <tag/Declaration/<tt/unsigned char em_uninstall (void);/
3030 <tag/Description/The function uninstalls an already loaded extended memory
3031 driver but doesn't remove it from memory.
3032 <tag/Notes/<itemize>
3033 <item>If the driver has been loaded using <tt/<ref id="em_load_driver"
3034 name="em_load_driver">/, <tt/<ref id="em_unload" name="em_unload">/
3035 should be used instead of <tt/em_uninstall/ so the driver is also removed
3038 <tag/Availability/cc65
3040 <ref id="em_install" name="em_install">,
3041 <ref id="em_load_driver" name="em_load_driver">,
3042 <ref id="em_unload" name="em_unload">
3048 <sect1>em_unload<label id="em_unload"><p>
3052 <tag/Function/Unload an extended memory driver.
3053 <tag/Header/<tt/<ref id="em.h" name="em.h">/
3054 <tag/Declaration/<tt/unsigned char em_unload (void);/
3055 <tag/Description/The function unloads a loaded extended memory driver and
3056 frees all memory allocated for the driver.
3057 <tag/Notes/<itemize>
3058 <item>The function does nothing if no driver is loaded.
3060 <tag/Availability/cc65
3062 <ref id="em_load_driver" name="em_load_driver">
3068 <sect1>em_use<label id="em_use"><p>
3072 <tag/Function/Prepare an extended memory page for use.
3073 <tag/Header/<tt/<ref id="em.h" name="em.h">/
3074 <tag/Declaration/<tt/void* __fastcall__ em_use (unsigned page);/
3075 <tag/Description/The function maps one page of extended memory into linear
3076 memory and returns a pointer to the page frame. This function is similar to
3077 <tt/<ref id="em_map" name="em_map">/, but will not transfer data into the
3078 actual memory window in the assumption that the existing data is wrong or
3079 will get overwritten.
3080 <tag/Notes/<itemize>
3081 <item>Calling <tt/em_use/ will invalidate the memory window, so if you
3082 made any changes to the data in the window, call <tt/<ref id="em_commit"
3083 name="em_commit">/ first, or the changes are lost.
3084 <item>The function is only available as fastcall function, so it may only be
3085 used in presence of a prototype.
3086 <item>The function produces undefined results if no extended memory driver is
3089 <tag/Availability/cc65
3091 <ref id="em_commit" name="em_commit">,
3092 <ref id="em_load_driver" name="em_load_driver">,
3093 <ref id="em_map" name="em_map">
3099 <sect1>exit<label id="exit"><p>
3103 <tag/Function/Terminate the program.
3104 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
3105 <tag/Declaration/<tt/void __fastcall__ exit (int status);/
3106 <tag/Description/<tt/exit/ terminates the program. The argument specifies the
3107 return code of the program. Before termination, all files are closed, buffered
3108 output is written and any functions registered with <tt/<ref id="atexit"
3109 name="atexit">/ are called. Common values for status are <tt/EXIT_SUCCESS/ and
3110 <tt/EXIT_FAILURE/ which are also defined in <tt/<ref id="stdlib.h"
3112 <tag/Notes/<itemize>
3113 <item>The function is only available as fastcall function, so it may only
3114 be used in presence of a prototype.
3115 <item>It depends on the host machine if the program return code can be
3116 evaluated or is ignored.
3118 <tag/Availability/ISO 9899
3120 <ref id="abort" name="abort">,
3121 <ref id="exit" name="exit">
3127 <sect1>exec<label id="exec"><p>
3131 <tag/Function/Execute a program file.
3132 <tag/Header/<tt/<ref id="unistd.h" name="unistd.h">/
3133 <tag/Declaration/<tt/int __fastcall__ exec (const char* progname, const char* cmdline);/
3134 <tag/Description/<tt/exec/ replaces the currently running program by a new one.
3135 Calling <tt/exec()/ is identical to calling <tt/<ref id="exit" name="exit()">/,
3136 then loading and starting the program named in the first argument, passing
3137 the command line specified as second argument. Instead of an empty string,
3138 a <tt/NULL/ pointer may be passed as second parameter.
3139 On success, the function does not return. On failure, -1 is returned and
3140 <tt/errno/ contains an error code.
3141 <tag/Notes/<itemize>
3142 <item>The function is only available as fastcall function, so it may only
3143 be used in presence of a prototype.
3144 <item>On most platforms, the function needs to copy a small stub loader to
3145 some memory area outside the program space. This may collide with other
3146 programs. See the platform specific docs on this.
3147 <item>Because it is necessary to terminate the running program before the
3148 memory can be reused to load the new one, there is a high chance that the
3149 function may not be able to return on errors.
3150 <item>The command line is passed to the new program in the same way as cc65
3151 programs expect the command line. If the new program is not a cc65 generated
3152 program, it may not be able to read it.
3154 <tag/Availability/cc65
3156 <ref id="exit" name="exit">
3162 <sect1>fast<label id="fast"><p>
3166 <tag/Function/Switch the C128 into 2MHz mode.
3167 <tag/Header/<tt/<ref id="c128.h" name="c128.h">/
3168 <tag/Declaration/<tt/void fast (void);/
3169 <tag/Description/The function will switch the clock of the C128 to 2MHz. This
3170 will nearly double the speed compared to slow mode.
3171 <tag/Notes/<itemize>
3172 <item>The function is specific to the C128.
3173 <item>2MHz clock will not work in 40 column mode.
3175 <tag/Availability/C128
3177 <ref id="slow" name="slow">,
3178 <ref id="toggle_videomode" name="toggle_videomode">,
3179 <ref id="videomode" name="videomode">
3185 <sect1>feof<label id="feof"><p>
3189 <tag/Function/Return the end-of-file indicator of a stream.
3190 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
3191 <tag/Declaration/<tt/int __fastcall__ feof (FILE* f);/
3192 <tag/Description/<tt/feof/ tests the end-of-file indicator ofthe stream
3193 <tt/f/, and returns a non zero value if it is set.
3194 <tag/Notes/<itemize>
3195 <item>The indicator is set only after a read past the end of a file is
3197 <item>The function is only available as fastcall function, so it may only be
3198 used in presence of a prototype.
3200 <tag/Availability/ISO 9899
3202 <ref id="feof" name="clearerr">,
3203 <ref id="ferror" name="ferror">
3209 <sect1>ferror<label id="ferror"><p>
3213 <tag/Function/Return the error indicator of a stream.
3214 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
3215 <tag/Declaration/<tt/int __fastcall__ ferror (FILE* f);/
3216 <tag/Description/<tt/ferror/ tests the error indicator of the stream
3217 <tt/f/, and returns a non zero value if it is set.
3218 <tag/Notes/<itemize>
3219 <item>The function is only available as fastcall function, so it may only be
3220 used in presence of a prototype.
3222 <tag/Availability/ISO 9899
3224 <ref id="feof" name="clearerr">,
3225 <ref id="ferror" name="feof">
3231 <sect1>fileno<label id="fileno"><p>
3235 <tag/Function/Return the file handle used by a stream.
3236 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
3237 <tag/Declaration/<tt/int __fastcall__ fileno (FILE* f);/
3238 <tag/Description/The <tt/fileno/ function returns the file handle used
3239 internally by a C stream. This file handle (an integer) can be used as a
3240 handle for the POSIX input/output functions.
3241 <tag/Notes/<itemize>
3242 <item>The function is only available as fastcall function, so it may only be
3243 used in presence of a prototype.
3244 <item>Mixing C file I/O functions and POSIX file I/O functions for the same
3245 file may have unpredictable results.
3247 <tag/Availability/POSIX 1003.1
3249 <ref id="creat" name="creat">,
3250 <ref id="open" name="open"> <!-- , -->
3251 <!-- <ref id="read" name="read">, -->
3252 <!-- <ref id="write" name="write"> -->
3258 <sect1>free<label id="free"><p>
3262 <tag/Function/Free a block of dynamic memory.
3263 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
3264 <tag/Declaration/<tt/void __fastcall__ free (void* block);/
3265 <tag/Description/Free a block of dynamic memory previously allocated with
3266 <tt/<ref id="malloc" name="malloc">/, <tt/<ref id="calloc" name="calloc">/
3267 or <tt/<ref id="realloc" name="realloc">/. As an exception, if the passed
3268 pointer is <tt/NULL/, no action is performed.
3269 <tag/Notes/<itemize>
3270 <item>Passing an already free'd block to <tt/free/ again will cause undefined
3271 behaviour and may crash your program.
3272 <item>The function is only available as fastcall function, so it may only
3273 be used in presence of a prototype.
3275 <tag/Availability/ISO 9899
3277 <ref id="_heapadd" name="_heapadd">,
3278 <ref id="_heapblocksize" name="_heapblocksize">,
3279 <ref id="_heapmaxavail" name="_heapmaxavail">,
3280 <ref id="_heapmemavail" name="_heapmemavail">,
3281 <ref id="calloc" name="calloc">,
3282 <ref id="malloc" name="malloc">,
3283 <ref id="realloc" name="realloc">
3289 <sect1>get_ostype<label id="get_ostype"><p>
3293 <tag/Function/The function returns the operating system, the program runs on.
3294 <tag/Header/<tt/<ref id="apple2.h" name="apple2.h">,
3295 <ref id="atari.h" name="atari.h">, <ref id="c64.h" name="c64.h">/
3296 <tag/Declaration/<tt/unsigned char get_ostype (void);/
3297 <tag/Description/<tt/get_ostype/ is machine dependent and does not exist for
3298 all supported targets. If it exists, it returns a number that identifies the
3299 operating system or machine type, the program runs on. The machine dependent
3300 header files define constants that can be used to check the return code.
3301 <tag/Notes/<itemize>
3302 <item>The function does not exist on all platforms.
3303 <item>The return codes are platform dependent.
3305 <tag/Availability/cc65 (not all platforms)
3311 <sect1>getcpu<label id="getcpu"><p>
3315 <tag/Function/Determine on which CPU the program is running.
3316 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
3317 <tag/Declaration/<tt/unsigned char getcpu (void);/
3318 <tag/Description/The function checks on which CPU the code is running. It
3319 returns one of the constants<itemize>
3321 <item><tt/CPU_65C02/
3322 <item><tt/CPU_65816/
3324 <tag/Notes/<itemize>
3325 <item>Other, more exotic CPU types are not disinguished.
3327 <tag/Availability/cc65
3333 <sect1>getenv<label id="getenv"><p>
3337 <tag/Function/Return a value from the environment.
3338 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
3339 <tag/Declaration/<tt/char* __fastcall__ getenv (const char* name);/
3340 <tag/Description/The function searches the environment for an entry that
3341 matches <tt/name/ and returns its value. The environment consists of a list
3342 of strings in the form <tt/name=value/. If there is no match, <tt/getenv/
3344 <tag/Notes/<itemize>
3345 <item>What exactly is stored in the environment depends on the machine the
3346 program is running on.
3347 <item>The function is only available as fastcall function, so it may only
3348 be used in presence of a prototype.
3350 <tag/Availability/ISO 9899
3356 <sect1>getopt<label id="getopt"><p>
3360 <tag/Function/Parse command line options.
3361 <tag/Header/<tt/<ref id="unistd.h" name="unistd.h">/
3362 <tag/Declaration/<tt/int __fastcall__ getopt (int argc, char* const* argv,
3363 const char* optstring);/
3364 <tag/Description/The function parses command line arguments, <tt/argc/ and
3365 <tt/argv/ are the argument count and array passed to <tt/main/. <tt/optstring/
3366 is a string that contains command line option characters. If a character in
3367 <tt/optstring/ is followed by a colon, the option requires an argument. An
3368 option on the command line is recognized if it is one of the option characters
3370 <tt/getopt/ must be called repeatedly. It will return each option character
3371 found on the command line and <tt/EOF/ (-1) if there is no other option. An
3372 option argument is placed in <tt/optarg/, the index of the next element on the
3373 command line to be processed is placed in <tt/optind/.
3374 <tag/Notes/<itemize>
3375 <item>The implementation will not reorder options. A non option on the command
3376 line will terminate option processing. All remaining arguments are not
3377 recognized as options, even if the start with a '-' character.
3378 <item>The function is only available as fastcall function, so it may only
3379 be used in presence of a prototype.
3381 <tag/Availability/POSIX.2
3387 <sect1>gotox<label id="gotox"><p>
3391 <tag/Function/Move the text mode cursor to a new X position.
3392 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
3393 <tag/Declaration/<tt/void __fastcall__ gotox (unsigned char x);/
3394 <tag/Description/The function moves the text mode cursor to the specified X
3395 position while leaving the Y position untouched. The leftmost position on the
3396 screen has the coordinate 0.
3397 <tag/Notes/<itemize>
3398 <item>The function is only available as fastcall function, so it may
3399 only be used in presence of a prototype.
3400 <item>Invalid values for the X position (out of screen coordinates) may
3401 lead to undefined behaviour.
3403 <tag/Availability/cc65
3405 <ref id="gotoy" name="gotoy">,
3406 <ref id="gotoxy" name="gotoxy">,
3407 <ref id="wherex" name="wherex">,
3408 <ref id="wherey" name="wherey">
3414 <sect1>gotoxy<label id="gotoxy"><p>
3418 <tag/Function/Move the text mode cursor to a new position.
3419 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
3420 <tag/Declaration/<tt/void __fastcall__ gotoxy (unsigned char x, unsigned char y);/
3421 <tag/Description/The function moves the text mode cursor to the specified
3422 position. The leftmost position on the screen has the X coordinate 0, the
3423 topmost line has the Y coordinate 0.
3424 <tag/Notes/<itemize>
3425 <item>The function is only available as fastcall function, so it may only be
3426 used in presence of a prototype.
3427 <item>Invalid values for any of both coordinates (out of screen positions) may
3428 lead to undefined behaviour.
3430 <tag/Availability/cc65
3432 <ref id="gotox" name="gotox">,
3433 <ref id="gotoy" name="gotoy">,
3434 <ref id="wherex" name="wherex">,
3435 <ref id="wherey" name="wherey">
3441 <sect1>gotoy<label id="gotoy"><p>
3445 <tag/Function/Move the text mode cursor to a new Y position.
3446 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
3447 <tag/Declaration/<tt/void __fastcall__ gotoy (unsigned char x);/
3448 <tag/Description/The function moves the text mode cursor to the specified Y
3449 position while leaving the X position untouched. The uppermost position on the
3450 screen has the coordinate 0.
3451 <tag/Notes/<itemize>
3452 <item>The function is only available as fastcall function, so it may
3453 only be used in presence of a prototype.
3454 <item>Invalid values for the Y position (out of screen coordinates) may lead
3455 to undefined behaviour.
3457 <tag/Availability/cc65
3459 <ref id="gotox" name="gotox">,
3460 <ref id="gotoxy" name="gotoxy">,
3461 <ref id="wherex" name="wherex">,
3462 <ref id="wherey" name="wherey">
3468 <sect1>isalnum<label id="isalnum"><p>
3472 <tag/Function/Check if a given character is a letter or digit.
3473 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
3474 <tag/Declaration/<tt/int __fastcall__ isalnum (int c);/
3475 <tag/Description/The function returns a non zero value if the given argument
3476 is a letter or digit. The return value is zero if the character is anything
3478 <tag/Notes/<itemize>
3479 <item>When compiling with <tt/-Os/ the function is actually a macro. The
3480 inline sequence generated by the macro will not work correctly for values
3481 outside the range 0..255. <em/Note:/ The constant <tt/EOF/ is not part of
3482 this range. The non inline function may be accessed by <tt/#undef/'ing
3484 <item>When compiling without <tt/-Os/, the function is only available as
3485 fastcall function, so it may only be used in presence of a prototype.
3487 <tag/Availability/ISO 9899
3489 <ref id="isalpha" name="isalpha">,
3490 <ref id="isascii" name="isascii">,
3491 <ref id="isblank" name="isblank">,
3492 <ref id="iscntrl" name="iscntrl">,
3493 <ref id="isdigit" name="isdigit">,
3494 <ref id="isgraph" name="isgraph">,
3495 <ref id="islower" name="islower">,
3496 <ref id="isprint" name="isprint">,
3497 <ref id="ispunct" name="ispunct">,
3498 <ref id="isspace" name="isspace">,
3499 <ref id="isupper" name="isupper">,
3500 <ref id="isxdigit" name="isxdigit">
3506 <sect1>isalpha<label id="isalpha"><p>
3510 <tag/Function/Check if a given character is a letter.
3511 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
3512 <tag/Declaration/<tt/int __fastcall__ isalpha (int c);/
3513 <tag/Description/The function returns a non zero value if the given argument
3514 is a letter. The return value is zero if the character is anything else.
3515 <tag/Notes/<itemize>
3516 <item>When compiling with <tt/-Os/ the function is actually a macro. The
3517 inline sequence generated by the macro will not work correctly for values
3518 outside the range 0..255. <em/Note:/ The constant <tt/EOF/ is not part of
3519 this range. The non inline function may be accessed by <tt/#undef/'ing the
3521 <item>When compiling without <tt/-Os/, the function is only available as
3522 fastcall function, so it may only be used in presence of a prototype.
3524 <tag/Availability/ISO 9899
3526 <ref id="isalnum" name="isalnum">,
3527 <ref id="isascii" name="isascii">,
3528 <ref id="isblank" name="isblank">,
3529 <ref id="iscntrl" name="iscntrl">,
3530 <ref id="isdigit" name="isdigit">,
3531 <ref id="isgraph" name="isgraph">,
3532 <ref id="islower" name="islower">,
3533 <ref id="isprint" name="isprint">,
3534 <ref id="ispunct" name="ispunct">,
3535 <ref id="isspace" name="isspace">,
3536 <ref id="isupper" name="isupper">,
3537 <ref id="isxdigit" name="isxdigit">
3543 <sect1>isascii<label id="isascii"><p>
3547 <tag/Function/Check if a given character is in the ASCII (0..127) range.
3548 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
3549 <tag/Declaration/<tt/int __fastcall__ isascii (int c);/
3550 <tag/Description/The function returns a non zero value if the given argument
3551 is in the range 0..127 (the range of valid ASCII characters) and zero if not.
3552 <tag/Notes/<itemize>
3553 <item>When compiling with <tt/-Os/ the function is actually a macro. The
3554 inline sequence generated by the macro will not work correctly for values
3555 outside the range 0..255. <em/Note:/ The constant <tt/EOF/ is not part of
3556 this range. The non inline function may be accessed by <tt/#undef/'ing the
3558 <item>When compiling without <tt/-Os/, the function is only available as
3559 fastcall function, so it may only be used in presence of a prototype.
3561 <tag/Availability/ISO 9899
3563 <ref id="isalnum" name="isalnum">,
3564 <ref id="isalpha" name="isalpha">,
3565 <ref id="isblank" name="isblank">,
3566 <ref id="iscntrl" name="iscntrl">,
3567 <ref id="isdigit" name="isdigit">,
3568 <ref id="isgraph" name="isgraph">,
3569 <ref id="islower" name="islower">,
3570 <ref id="isprint" name="isprint">,
3571 <ref id="ispunct" name="ispunct">,
3572 <ref id="isspace" name="isspace">,
3573 <ref id="isupper" name="isupper">,
3574 <ref id="isxdigit" name="isxdigit">
3580 <sect1>isblank<label id="isblank"><p>
3584 <tag/Function/Check if a given character is a space or tab.
3585 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
3586 <tag/Declaration/<tt/int __fastcall__ isblank (int c);/
3587 <tag/Description/The function returns a non zero value if the given argument
3588 is a space or tab character. The return value is zero if the character is
3590 <tag/Notes/<itemize>
3591 <item>When compiling with <tt/-Os/ the function is actually a macro. The
3592 inline sequence generated by the macro will not work correctly for values
3593 outside the range 0..255. <em/Note:/ The constant <tt/EOF/ is not part of
3594 this range. The non inline function may be accessed by <tt/#undef/'ing the
3596 <item>When compiling without <tt/-Os/, the function is only available as
3597 fastcall function, so it may only be used in presence of a prototype.
3599 <tag/Availability/ISO 9899
3601 <ref id="isalnum" name="isalnum">,
3602 <ref id="isalpha" name="isalpha">,
3603 <ref id="isascii" name="isascii">,
3604 <ref id="iscntrl" name="iscntrl">,
3605 <ref id="isdigit" name="isdigit">,
3606 <ref id="isgraph" name="isgraph">,
3607 <ref id="islower" name="islower">,
3608 <ref id="isprint" name="isprint">,
3609 <ref id="ispunct" name="ispunct">,
3610 <ref id="isspace" name="isspace">,
3611 <ref id="isupper" name="isupper">,
3612 <ref id="isxdigit" name="isxdigit">
3618 <sect1>iscntrl<label id="iscntrl"><p>
3622 <tag/Function/Check if a given character is a control character.
3623 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
3624 <tag/Declaration/<tt/int __fastcall__ iscntrl (int c);/
3625 <tag/Description/The function returns a non zero value if the given argument
3626 is a control character. The return value is zero if the character is anything
3628 <tag/Notes/<itemize>
3629 <item>When compiling with <tt/-Os/ the function is actually a macro. The
3630 inline sequence generated by the macro will not work correctly for values
3631 outside the range 0..255. <em/Note:/ The constant <tt/EOF/ is not part of
3632 this range. The non inline function may be accessed by <tt/#undef/'ing the
3634 <item>When compiling without <tt/-Os/, the function is only available as
3635 fastcall function, so it may only be used in presence of a prototype.
3637 <tag/Availability/ISO 9899
3639 <ref id="isalnum" name="isalnum">,
3640 <ref id="isalpha" name="isalpha">,
3641 <ref id="isascii" name="isascii">,
3642 <ref id="isblank" name="isblank">,
3643 <ref id="isdigit" name="isdigit">,
3644 <ref id="isgraph" name="isgraph">,
3645 <ref id="islower" name="islower">,
3646 <ref id="isprint" name="isprint">,
3647 <ref id="ispunct" name="ispunct">,
3648 <ref id="isspace" name="isspace">,
3649 <ref id="isupper" name="isupper">,
3650 <ref id="isxdigit" name="isxdigit">
3656 <sect1>isdigit<label id="isdigit"><p>
3660 <tag/Function/Check if a given character is a digit.
3661 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
3662 <tag/Declaration/<tt/int __fastcall__ isdigit (int c);/
3663 <tag/Description/The function returns a non zero value if the given argument
3664 is a digit. The return value is zero if the character is anything else.
3665 <tag/Notes/<itemize>
3666 <item>When compiling with <tt/-Os/ the function is actually a macro. The
3667 inline sequence generated by the macro will not work correctly for values
3668 outside the range 0..255. <em/Note:/ The constant <tt/EOF/ is not part of
3669 this range. The non inline function may be accessed by <tt/#undef/'ing the
3671 <item>When compiling without <tt/-Os/, the function is only available as
3672 fastcall function, so it may only be used in presence of a prototype.
3674 <tag/Availability/ISO 9899
3676 <ref id="isalnum" name="isalnum">,
3677 <ref id="isalpha" name="isalpha">,
3678 <ref id="isascii" name="isascii">,
3679 <ref id="isblank" name="isblank">,
3680 <ref id="iscntrl" name="iscntrl">,
3681 <ref id="isgraph" name="isgraph">,
3682 <ref id="islower" name="islower">,
3683 <ref id="isprint" name="isprint">,
3684 <ref id="ispunct" name="ispunct">,
3685 <ref id="isspace" name="isspace">,
3686 <ref id="isupper" name="isupper">,
3687 <ref id="isxdigit" name="isxdigit">
3693 <sect1>isgraph<label id="isgraph"><p>
3697 <tag/Function/Check if a given character is a printable character (except
3699 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
3700 <tag/Declaration/<tt/int __fastcall__ isgraph (int c);/
3701 <tag/Description/The function returns a non zero value if the given argument
3702 is a printable character with the exception of space. The return value is zero
3703 if the character is anything else.
3704 <tag/Notes/<itemize>
3705 <item>When compiling with <tt/-Os/ the function is actually a macro. The
3706 inline sequence generated by the macro will not work correctly for values
3707 outside the range 0..255. <em/Note:/ The constant <tt/EOF/ is not part of
3708 this range. The non inline function may be accessed by <tt/#undef/'ing the
3710 <item>When compiling without <tt/-Os/, the function is only available as
3711 fastcall function, so it may only be used in presence of a prototype.
3713 <tag/Availability/ISO 9899
3715 <ref id="isalnum" name="isalnum">,
3716 <ref id="isalpha" name="isalpha">,
3717 <ref id="isascii" name="isascii">,
3718 <ref id="isblank" name="isblank">,
3719 <ref id="iscntrl" name="iscntrl">,
3720 <ref id="isdigit" name="isdigit">,
3721 <ref id="islower" name="islower">,
3722 <ref id="isprint" name="isprint">,
3723 <ref id="ispunct" name="ispunct">,
3724 <ref id="isspace" name="isspace">,
3725 <ref id="isupper" name="isupper">,
3726 <ref id="isxdigit" name="isxdigit">
3732 <sect1>islower<label id="islower"><p>
3736 <tag/Function/Check if a given character is a lower case letter.
3737 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
3738 <tag/Declaration/<tt/int __fastcall__ islower (int c);/
3739 <tag/Description/The function returns a non zero value if the given argument
3740 is a lower case letter. The return value is zero if the character is anything
3742 <tag/Notes/<itemize>
3743 <item>When compiling with <tt/-Os/ the function is actually a macro. The
3744 inline sequence generated by the macro will not work correctly for values
3745 outside the range 0..255. <em/Note:/ The constant <tt/EOF/ is not part of
3746 this range. The non inline function may be accessed by <tt/#undef/'ing the
3748 <item>When compiling without <tt/-Os/, the function is only available as
3749 fastcall function, so it may only be used in presence of a prototype.
3751 <tag/Availability/ISO 9899
3753 <ref id="isalnum" name="isalnum">,
3754 <ref id="isalpha" name="isalpha">,
3755 <ref id="isascii" name="isascii">,
3756 <ref id="isblank" name="isblank">,
3757 <ref id="iscntrl" name="iscntrl">,
3758 <ref id="isdigit" name="isdigit">,
3759 <ref id="isgraph" name="isgraph">,
3760 <ref id="isprint" name="isprint">,
3761 <ref id="ispunct" name="ispunct">,
3762 <ref id="isspace" name="isspace">,
3763 <ref id="isupper" name="isupper">,
3764 <ref id="isxdigit" name="isxdigit">
3770 <sect1>isprint<label id="isprint"><p>
3774 <tag/Function/Check if a given character is a printable character.
3775 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
3776 <tag/Declaration/<tt/int __fastcall__ isprint (int c);/
3777 <tag/Description/The function returns a non zero value if the given argument
3778 is a printable character (this includes the space character). The return value
3779 is zero if the character is anything else.
3780 <tag/Notes/<itemize>
3781 <item>When compiling with <tt/-Os/ the function is actually a macro. The
3782 inline sequence generated by the macro will not work correctly for values
3783 outside the range 0..255. <em/Note:/ The constant <tt/EOF/ is not part of
3784 this range. The non inline function may be accessed by <tt/#undef/'ing the
3786 <item>When compiling without <tt/-Os/, the function is only available as
3787 fastcall function, so it may only be used in presence of a prototype.
3789 <tag/Availability/ISO 9899
3791 <ref id="isalnum" name="isalnum">,
3792 <ref id="isalpha" name="isalpha">,
3793 <ref id="isascii" name="isascii">,
3794 <ref id="isblank" name="isblank">,
3795 <ref id="iscntrl" name="iscntrl">,
3796 <ref id="isdigit" name="isdigit">,
3797 <ref id="isgraph" name="isgraph">,
3798 <ref id="islower" name="islower">,
3799 <ref id="ispunct" name="ispunct">,
3800 <ref id="isspace" name="isspace">,
3801 <ref id="isupper" name="isupper">,
3802 <ref id="isxdigit" name="isxdigit">
3808 <sect1>ispunct<label id="ispunct"><p>
3812 <tag/Function/Check if a given character is a printable character but not a
3813 space or an alphanumeric character.
3814 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
3815 <tag/Declaration/<tt/int __fastcall__ ispunct (int c);/
3816 <tag/Description/The function returns a non zero value if the given argument
3817 is a printable character, but not a space or anything alphanumeric. The return
3818 value is zero if the character is anything else.
3819 <tag/Notes/<itemize>
3820 <item>When compiling with <tt/-Os/ the function is actually a macro. The
3821 inline sequence generated by the macro will not work correctly for values
3822 outside the range 0..255. <em/Note:/ The constant <tt/EOF/ is not part of
3823 this range. The non inline function may be accessed by <tt/#undef/'ing the
3825 <item>When compiling without <tt/-Os/, the function is only available as
3826 fastcall function, so it may only be used in presence of a prototype.
3828 <tag/Availability/ISO 9899
3830 <ref id="isalnum" name="isalnum">,
3831 <ref id="isalpha" name="isalpha">,
3832 <ref id="isascii" name="isascii">,
3833 <ref id="isblank" name="isblank">,
3834 <ref id="iscntrl" name="iscntrl">,
3835 <ref id="isdigit" name="isdigit">,
3836 <ref id="isgraph" name="isgraph">,
3837 <ref id="islower" name="islower">,
3838 <ref id="isprint" name="isprint">,
3839 <ref id="isspace" name="isspace">,
3840 <ref id="isupper" name="isupper">,
3841 <ref id="isxdigit" name="isxdigit">
3847 <sect1>isspace<label id="isspace"><p>
3851 <tag/Function/Check if a given character is a white-space character.
3852 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
3853 <tag/Declaration/<tt/int __fastcall__ isspace (int c);/
3854 <tag/Description/The function returns a non zero value if the given argument
3855 is a white space character. The return value is zero if the character is
3856 anything else. The standard white space characters are: space, formfeed ('\f'),
3857 newline ('\n'), carriage return ('\r'), horizontal tab ('\t'), and vertical tab
3859 <tag/Notes/<itemize>
3860 <item>When compiling with <tt/-Os/ the function is actually a macro. The
3861 inline sequence generated by the macro will not work correctly for values
3862 outside the range 0..255. <em/Note:/ The constant <tt/EOF/ is not part of
3863 this range. The non inline function may be accessed by <tt/#undef/'ing the
3865 <item>When compiling without <tt/-Os/, the function is only available as
3866 fastcall function, so it may only be used in presence of a prototype.
3868 <tag/Availability/ISO 9899
3870 <ref id="isalnum" name="isalnum">,
3871 <ref id="isalpha" name="isalpha">,
3872 <ref id="isascii" name="isascii">,
3873 <ref id="isblank" name="isblank">,
3874 <ref id="iscntrl" name="iscntrl">,
3875 <ref id="isdigit" name="isdigit">,
3876 <ref id="isgraph" name="isgraph">,
3877 <ref id="islower" name="islower">,
3878 <ref id="isprint" name="isprint">,
3879 <ref id="ispunct" name="ispunct">,
3880 <ref id="isupper" name="isupper">,
3881 <ref id="isxdigit" name="isxdigit">
3887 <sect1>isupper<label id="isupper"><p>
3891 <tag/Function/Check if a given character is an upper case letter.
3892 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
3893 <tag/Declaration/<tt/int __fastcall__ isupper (int c);/
3894 <tag/Description/The function returns a non zero value if the given argument
3895 is an upper case letter. The return value is zero if the character is anything
3897 <tag/Notes/<itemize>
3898 <item>When compiling with <tt/-Os/ the function is actually a macro. The
3899 inline sequence generated by the macro will not work correctly for values
3900 outside the range 0..255. <em/Note:/ The constant <tt/EOF/ is not part of
3901 this range. The non inline function may be accessed by <tt/#undef/'ing the
3903 <item>When compiling without <tt/-Os/, the function is only available as
3904 fastcall function, so it may only be used in presence of a prototype.
3906 <tag/Availability/ISO 9899
3908 <ref id="isalnum" name="isalnum">,
3909 <ref id="isalpha" name="isalpha">,
3910 <ref id="isascii" name="isascii">,
3911 <ref id="isblank" name="isblank">,
3912 <ref id="iscntrl" name="iscntrl">,
3913 <ref id="isdigit" name="isdigit">,
3914 <ref id="isgraph" name="isgraph">,
3915 <ref id="islower" name="islower">,
3916 <ref id="isprint" name="isprint">,
3917 <ref id="ispunct" name="ispunct">,
3918 <ref id="isspace" name="isspace">,
3919 <ref id="isxdigit" name="isxdigit">
3925 <sect1>isxdigit<label id="isxdigit"><p>
3929 <tag/Function/Check if a given character is a hexadecimal digit.
3930 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
3931 <tag/Declaration/<tt/int __fastcall__ isxdigit (int c);/
3932 <tag/Description/The function returns a non zero value if the given argument
3933 is a hexadecimal digit (0..9, a..f and A..F). The return value is zero if the
3934 character is anything else.
3935 <tag/Notes/<itemize>
3936 <item>When compiling with <tt/-Os/ the function is actually a macro. The
3937 inline sequence generated by the macro will not work correctly for values
3938 outside the range 0..255. <em/Note:/ The constant <tt/EOF/ is not part of
3939 this range. The non inline function may be accessed by <tt/#undef/'ing the
3941 <item>When compiling without <tt/-Os/, the function is only available as
3942 fastcall function, so it may only be used in presence of a prototype.
3944 <tag/Availability/ISO 9899
3946 <ref id="isalnum" name="isalnum">,
3947 <ref id="isalpha" name="isalpha">,
3948 <ref id="isascii" name="isascii">,
3949 <ref id="isblank" name="isblank">,
3950 <ref id="iscntrl" name="iscntrl">,
3951 <ref id="isdigit" name="isdigit">,
3952 <ref id="isgraph" name="isgraph">,
3953 <ref id="islower" name="islower">,
3954 <ref id="isprint" name="isprint">,
3955 <ref id="ispunct" name="ispunct">,
3956 <ref id="isspace" name="isspace">,
3957 <ref id="isupper" name="isupper">
3963 <sect1>itoa<label id="itoa"><p>
3967 <tag/Function/Convert an integer into a string.
3968 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
3969 <tag/Declaration/<tt/char* __fastcall__ itoa (int val, char* buf, int radix);/
3970 <tag/Description/<tt/itoa/ converts the integer <tt/val/ into a string using
3971 <tt/radix/ as the base.
3972 <tag/Notes/<itemize>
3973 <item>There are no provisions to prevent a buffer overflow.
3974 <item>If <tt/val/ contains <tt/INT_MIN/, the behaviour is undefined.
3975 <item>The function is non standard, so it is not available in strict ANSI mode.
3976 You should probably use <tt/sprintf/ instead.
3977 <item>The function is only available as fastcall function, so it may only be
3978 used in presence of a prototype.
3980 <tag/Availability/cc65
3982 <ref id="atoi" name="atoi">,
3983 <ref id="atol" name="atol">,
3984 <ref id="ltoa" name="ltoa">,
3985 <ref id="ultoa" name="ultoa">,
3986 <ref id="utoa" name="utoa">
3992 <sect1>joy_count<label id="joy_count"><p>
3996 <tag/Function/Return the number of joysticks supported by the current driver.
3997 <tag/Header/<tt/<ref id="joystick.h" name="joystick.h">/
3998 <tag/Declaration/<tt/unsigned char joy_count (void);/
3999 <tag/Description/The function returns a the number of joysticks supported
4000 by the current joystick driver.
4001 <tag/Notes/<itemize>
4002 <item>A joystick driver must be loaded using <ref id="joy_load_driver"
4003 name="joy_load_driver"> before calling this function.
4004 <item>The function returns the number of joysticks supported by the driver.
4005 There's no way to check for the number of actually connected joysticks.
4007 <tag/Availability/cc65
4009 <ref id="joy_load_driver" name="joy_load_driver">,
4010 <ref id="joy_read" name="joy_read">
4016 <sect1>joy_install<label id="joy_install"><p>
4020 <tag/Function/Install an already loaded driver and return an error code.
4021 <tag/Header/<tt/<ref id="joystick.h" name="joystick.h">/
4022 <tag/Declaration/<tt/unsigned char __fastcall__ joy_install (void* driver);/
4023 <tag/Description/The function installs a driver that was already loaded into
4024 memory (or linked statically to the program). It returns an error code
4025 (<tt/JOY_ERR_OK/ in case of success).
4026 <tag/Notes/<itemize>
4027 <item>The function is only available as fastcall function, so it may only be
4028 used in presence of a prototype.
4030 <tag/Availability/cc65
4032 <ref id="joy_load_driver" name="joy_load_driver">,
4033 <ref id="joy_uninstall" name="joy_uninstall">,
4034 <ref id="joy_unload" name="joy_unload">
4040 <sect1>joy_load_driver<label id="joy_load_driver"><p>
4044 <tag/Function/Load a driver from disk and install it.
4045 <tag/Header/<tt/<ref id="joystick.h" name="joystick.h">/
4046 <tag/Declaration/<tt/unsigned char __fastcall__ joy_load_driver (const char* driver);/
4047 <tag/Description/The function loads a driver with the given name from disk
4048 and installs it. An error code is returned, which is <tt/JOY_ERR_OK/ if the
4049 driver was successfully loaded and installed.
4050 <tag/Notes/<itemize>
4051 <item>The function is only available as fastcall function, so it may only be
4052 used in presence of a prototype.
4054 <tag/Availability/cc65
4056 <ref id="joy_install" name="joy_install">,
4057 <ref id="joy_uninstall" name="joy_uninstall">,
4058 <ref id="joy_unload" name="joy_unload">
4064 <sect1>joy_read<label id="joy_read"><p>
4068 <tag/Function/Read the status of a joystick.
4069 <tag/Header/<tt/<ref id="joystick.h" name="joystick.h">/
4070 <tag/Declaration/<tt/unsigned char __fastcall__ joy_read (unsigned char joystick);/
4071 <tag/Description/The function reads the status bits for a joystick. The number
4072 of the joystick is passed as parameter. The result may be examined by using one
4073 of the <tt/JOY_xxx/ macros from <ref id="joystick.h" name="joystick.h">.
4074 <tag/Notes/<itemize>
4075 <item>A joystick driver must be loaded using <ref id="joy_load_driver"
4076 name="joy_load_driver"> before calling this function.
4077 <item>The function is only available as fastcall function, so it may only be
4078 used in presence of a prototype.
4080 <tag/Availability/cc65
4082 <ref id="joy_count" name="joy_count">,
4083 <ref id="joy_load_driver" name="joy_load_driver">,
4084 <ref id="joy_unload" name="joy_unload">
4090 <sect1>joy_uninstall<label id="joy_uninstall"><p>
4094 <tag/Function/Uninstall the current joystick driver.
4095 <tag/Header/<tt/<ref id="joystick.h" name="joystick.h">/
4096 <tag/Declaration/<tt/unsigned char joy_uninstall (void);/
4097 <tag/Description/The function uninstalls the currently installed joystick
4098 driver. It does not remove the driver from memory. The function returns an
4099 error code, which is <tt/JOY_ERR_OK/ if the driver was successfully uninstalled.
4100 <tag/Notes/<itemize>
4101 <item>A joystick driver must be installed using <ref id="joy_install"
4102 name="joy_install"> before calling this function.
4104 <tag/Availability/cc65
4106 <ref id="joy_install" name="joy_install">,
4107 <ref id="joy_load_driver" name="joy_load_driver">,
4108 <ref id="joy_unload" name="joy_unload">
4114 <sect1>joy_unload<label id="joy_unload"><p>
4118 <tag/Function/Uninstall, then unload the current joystick driver.
4119 <tag/Header/<tt/<ref id="joystick.h" name="joystick.h">/
4120 <tag/Declaration/<tt/unsigned char joy_unload (void);/
4121 <tag/Description/The function uninstalls the currently installed joystick
4122 driver and removes it from memory. An error code is returned, which is
4123 <tt/JOY_ERR_OK/ if the driver was successfully uninstalled.
4124 <tag/Notes/<itemize>
4125 <item>A joystick driver must be loaded using <ref id="joy_load_driver"
4126 name="joy_load_driver"> before calling this function.
4128 <tag/Availability/cc65
4130 <ref id="joy_load_driver" name="joy_load_driver">
4136 <sect1>kbhit<label id="kbhit"><p>
4140 <tag/Function/Check if there's a key waiting in the keyboard buffer.
4141 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
4142 <tag/Declaration/<tt/unsigned char kbhit (void);/
4143 <tag/Description/The function returns a value of zero if there is no character
4144 waiting to be read from the keyboard. It returns non zero otherwise.
4145 <tag/Notes/<itemize>
4146 <item>If the system does not support a keyboard buffer (most systems
4147 do), the function is rather useless.
4149 <tag/Availability/cc65
4151 <ref id="cgetc" name="cgetc">,
4152 <ref id="cursor" name="cursor">
4158 <sect1>kbrepeat<label id="kbrepeat"><p>
4162 <tag/Function/Set the keyboard repeat mode.
4163 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
4164 <tag/Declaration/<tt/unsigned char __fastcall__ kbrepeat (unsigned char mode);/
4165 <tag/Description/This function changes which keys have automatic repeat when
4166 being held down for a certain time. Possible values are <tt/KBREPEAT_CURSOR/
4167 (repeat only cursor-related keys), <tt/KBREPEAT_NONE/ (no repeat for any
4168 keys), and <tt/KBREPEAT_ALL/ (repeat all keys). The old mode is returned, so
4169 it can be restored later.
4170 <tag/Notes/<itemize>
4171 <item>The function is available only as a fastcall function; so, it may be used
4172 only in the presence of a prototype.
4174 <tag/Availability/cc65
4180 <sect1>labs<label id="labs"><p>
4184 <tag/Function/Returns the absolute value of a long integer.
4185 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
4186 <tag/Declaration/<tt/long __fastcall__ labs (long v);/
4187 <tag/Description/<tt/labs/ returns the absolute value of the argument passed to
4189 <tag/Notes/<itemize>
4190 <item>The return value is undefined if <tt/LONG_MIN/ is passed to the function.
4191 <item>The function is only available as fastcall function, so it may only be
4192 used in presence of a prototype.
4194 <tag/Availability/ISO 9899
4196 <ref id="abs" name="abs">
4202 <sect1>ltoa<label id="ltoa"><p>
4206 <tag/Function/Convert a long integer into a string.
4207 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
4208 <tag/Declaration/<tt/char* __fastcall__ ltoa (long val, char* buf, int radix);/
4209 <tag/Description/<tt/itoa/ converts the long integer <tt/val/ into a string
4210 using <tt/radix/ as the base.
4211 <tag/Notes/<itemize>
4212 <item>There are no provisions to prevent a buffer overflow.
4213 <item>If <tt/val/ contains <tt/LONG_MIN/, the behaviour is undefined.
4214 <item>The function is non standard, so it is not available in strict ANSI mode.
4215 You should probably use <tt/sprintf/ instead.
4216 <item>The function is only available as fastcall function, so it may only be
4217 used in presence of a prototype.
4219 <tag/Availability/cc65
4221 <ref id="atoi" name="atoi">,
4222 <ref id="atol" name="atol">,
4223 <ref id="itoa" name="itoa">,
4224 <ref id="ultoa" name="ultoa">,
4225 <ref id="utoa" name="utoa">
4231 <sect1>localeconv<label id="localeconv"><p>
4235 <tag/Function/Returns a pointer to the current locale structure.
4236 <tag/Header/<tt/<ref id="locale.h" name="locale.h">/
4237 <tag/Declaration/<tt/struct lconv* localeconv (void);/
4238 <tag/Description/<tt/localeconv/ returns a pointer to the current locale
4240 <tag/Notes/<itemize>
4241 <item>cc65 supports only the "C" locale, so even after setting a new locale
4242 using <tt/<ref id="setlocale" name="setlocale">/, the structure returned will
4245 <tag/Availability/ISO 9899
4247 <ref id="setlocale" name="setlocale">
4253 <sect1>longjmp<label id="longjmp"><p>
4257 <tag/Function/Non local goto.
4258 <tag/Header/<tt/<ref id="setjmp.h" name="setjmp.h">/
4259 <tag/Declaration/<tt/void __fastcall__ longjmp (jmp_buf buf, int retval);/
4260 <tag/Description/The <tt/longjmp/ function restores a program context from the
4261 data in <tt/buf/, which must have been set by a preceeding call to
4262 <tt/<ref id="setjmp" name="setjmp">/. Program execution continues as if the
4263 call to <tt/<ref id="setjmp" name="setjmp">/ has just returned the value
4265 <tag/Notes/<itemize>
4266 <item>If the parameter <tt/retval/ is zero, the function will behave as if it
4267 was called with a value of one.
4268 <item>The function is only available as fastcall function, so it may only
4269 be used in presence of a prototype.
4271 <tag/Availability/ISO 9899
4273 <ref id="setjmp" name="setjmp">
4279 <sect1>malloc<label id="malloc"><p>
4283 <tag/Function/Allocate dynamic memory.
4284 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
4285 <tag/Declaration/<tt/void* __fastcall__ malloc (size_t size);/
4286 <tag/Description/<tt/malloc/ allocates size bytes on the heap and returns a
4287 pointer to the allocated memory block. On error (not enough memory available),
4288 <tt/malloc/ returns <tt/NULL/.
4289 <tag/Notes/<itemize>
4290 <item>The function is only available as fastcall function, so it may only
4291 be used in presence of a prototype.
4293 <tag/Availability/ISO 9899
4295 <ref id="_heapadd" name="_heapadd">,
4296 <ref id="_heapblocksize" name="_heapblocksize">,
4297 <ref id="_heapmaxavail" name="_heapmaxavail">,
4298 <ref id="_heapmemavail" name="_heapmemavail">,
4299 <ref id="calloc" name="calloc">,
4300 <ref id="free" name="free">,
4301 <ref id="realloc" name="realloc">,
4302 <ref id="strdup" name="strdup">
4308 <sect1>memchr<label id="memchr"><p>
4312 <tag/Function/Search for a character in a block of raw memory.
4313 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4314 <tag/Declaration/<tt/void* __fastcall__ strchr (const void* mem, int c, size_t count);/
4315 <tag/Description/The <tt/memchr/ function locates the first occurrence of <tt/c/
4316 (converted to a char) in the block of raw memory string pointed to by <tt/mem/
4317 that is of size <tt/count/. Upon completion, the function returns a pointer to
4318 the character found, or a null pointer if the character was not found.
4319 <tag/Notes/<itemize>
4320 <item>The function is only available as fastcall function, so it may only
4321 be used in presence of a prototype.
4323 <tag/Availability/ISO 9899
4325 <ref id="strchr" name="strchr">
4331 <sect1>memcmp<label id="memcmp"><p>
4335 <tag/Function/Compare two memory areas.
4336 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4337 <tag/Declaration/<tt/int __fastcall__ memcmp (const void* p1, const void* p2, size_t count);/
4338 <tag/Description/<tt/memcmp/ compares <tt/count/ bytes from the memory area
4339 pointed to by <tt/p1/ into the memory area pointed to by <tt/p2/. It returns a value that is less than
4340 zero if <tt/p1/ is less than <tt/p2/, zero if <tt/p1/ is the same as <tt/p2/,
4341 and a value greater than zero if <tt/p1/ is greater than <tt/p2/.
4342 <tag/Notes/<itemize>
4343 <item>The function is only available as fastcall function, so it may only
4344 be used in presence of a prototype.
4346 <tag/Availability/ISO 9899
4348 <ref id="strcmp" name="strcmp">,
4349 <ref id="memmove" name="memmove">,
4350 <ref id="memset" name="memset">
4356 <sect1>memcpy<label id="memcpy"><p>
4360 <tag/Function/Copy a memory area.
4361 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4362 <tag/Declaration/<tt/void* __fastcall__ memcpy (void* dest, const void* src, size_t count);/
4363 <tag/Description/<tt/memcpy/ copies <tt/count/ bytes from the memory area
4364 pointed to by <tt/src/ into the memory area pointed to by <tt/dest/. It returns
4366 <tag/Notes/<itemize>
4367 <item>The result is undefined if the memory areas do overlap. Use
4368 <tt/<ref id="memmove" name="memmove">/ to copy overlapping memory areas.
4369 <item>The function is only available as fastcall function, so it may only
4370 be used in presence of a prototype.
4372 <tag/Availability/ISO 9899
4374 <ref id="_swap" name="_swap">,
4375 <ref id="memmove" name="memmove">,
4376 <ref id="memset" name="memset">
4382 <sect1>memmove<label id="memmove"><p>
4386 <tag/Function/Copy a memory area.
4387 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4388 <tag/Declaration/<tt/void* __fastcall__ memmove (void* dest, const void* src, size_t count);/
4389 <tag/Description/<tt/memmove/ copies <tt/count/ bytes from the memory area
4390 pointed to by <tt/src/ into the memory area pointed to by <tt/dest/. It returns
4392 <tag/Notes/<itemize>
4393 <item>While <tt/memmove/ allows the memory areas to overlap, it has some
4394 additional overhead compared to <tt/<ref id="memcpy" name="memcpy">/.
4395 <item>The function is only available as fastcall function, so it may only
4396 be used in presence of a prototype.
4398 <tag/Availability/ISO 9899
4400 <ref id="_swap" name="_swap">,
4401 <ref id="memcpy" name="memcpy">,
4402 <ref id="memset" name="memset">
4408 <sect1>memset<label id="memset"><p>
4412 <tag/Function/Fill a memory area.
4413 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4414 <tag/Declaration/<tt/void* __fastcall__ memset (void* p, int val, size_t count);/
4415 <tag/Description/<tt/memset/ fills the memory area pointed to by <tt/p/ with
4416 the value <tt/val/. The function returns <tt/p/.
4417 <tag/Notes/<itemize>
4418 <item>The function is only available as fastcall function, so it may only
4419 be used in presence of a prototype.
4421 <tag/Availability/ISO 9899
4423 <ref id="_swap" name="_swap">,
4424 <ref id="bzero" name="bzero">,
4425 <ref id="memcpy" name="memcpy">,
4426 <ref id="memmove" name="memmove">
4432 <sect1>mod_free<label id="mod_free"><p>
4436 <tag/Function/Free a relocatable module.
4437 <tag/Header/<tt/<ref id="modload.h" name="modload.h">/
4438 <tag/Declaration/<tt/void __fastcall__ mod_free (void* module);/
4439 <tag/Description/The function will free a module loaded into memory by use of
4440 the <tt/<ref id="mod_load" name="mod_load">/ function.
4441 <tag/Notes/<itemize>
4442 <item>The pointer passed as parameter is the pointer to the module memory,
4443 not the pointer to the control structure.
4444 <item>The function is available only as a fastcall function; so, it may be used
4445 only in the presence of a prototype.
4447 <tag/Availability/cc65
4449 <ref id="mod_load" name="mod_load">
4455 <sect1>mod_load<label id="mod_load"><p>
4459 <tag/Function/Load a relocatable module.
4460 <tag/Header/<tt/<ref id="modload.h" name="modload.h">/
4461 <tag/Declaration/<tt/unsigned char __fastcall__ mod_load (struct mod_ctrl* ctrl);/
4462 <tag/Description/The function will load a code module into memory and relocate
4463 it. The function will return an error code. If <tt/MLOAD_OK/ is returned, the
4464 outgoing fields in the passed <tt/mod_ctrl/ struct contain information about
4465 the module just loaded. Possible error codes are:
4467 <item><tt/MLOAD_OK/ - Module load successful
4468 <item><tt/MLOAD_ERR_READ/ - Read error
4469 <item><tt/MLOAD_ERR_HDR/ - Header error
4470 <item><tt/MLOAD_ERR_OS/ - Wrong operating system
4471 <item><tt/MLOAD_ERR_FMT/ - Data format error
4472 <item><tt/MLOAD_ERR_MEM/ - Not enough memory
4474 <tag/Notes/<itemize>
4475 <item>The <htmlurl url="ld65.html" name="ld65"> linker is needed to create
4476 relocatable o65 modules for use with this function.
4477 <item>The function is available only as a fastcall function; so, it may be used
4478 only in the presence of a prototype.
4480 <tag/Availability/cc65
4482 <ref id="mod_free" name="mod_free">
4488 <sect1>mouse_setbox<label id="mouse_setbox"><p>
4492 <tag/Function/Specify a bounding box for the mouse cursor.
4493 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
4494 <tag/Declaration/<tt/void __fastcall__ mouse_setbox (const struct mouse_box* box);/
4495 <tag/Description/The function allows to set a bounding box for mouse movement.
4496 <tag/Notes/<itemize>
4497 <item>The function does not check if the mouse cursor is currently within the
4498 given rectangle. Placing the mouse cursor within the bounding box is the
4499 responsibility of the programmer.
4500 <item>While the bounding box may be larger than the actual screen size, the
4501 standard mouse cursor draw routines may fail to set the cursor to coordinates
4502 outside of the screen area. Depending on the platform, you may have to supply
4503 your own mouse cursor routines.
4504 <item>The function is only available as fastcall function, so it may only be
4505 used in presence of a prototype.
4507 <tag/Availability/cc65
4509 <ref id="mouse_getbox" name="mouse_getbox">,
4510 <ref id="mouse_move" name="mouse_move">
4516 <sect1>mouse_getbox<label id="mouse_getbox"><p>
4520 <tag/Function/Return the current bounding box for the mouse cursor.
4521 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
4522 <tag/Declaration/<tt/void __fastcall__ mouse_getbox (struct mouse_box* box);/
4523 <tag/Description/The function queries the current bounding box for mouse
4525 <tag/Notes/<itemize>
4526 <item>The function is only available as fastcall function, so it may only be
4527 used in presence of a prototype.
4529 <tag/Availability/cc65
4531 <ref id="mouse_move" name="mouse_move">,
4532 <ref id="mouse_setbox" name="mouse_setbox">
4538 <sect1>mouse_buttons<label id="mouse_buttons"><p>
4542 <tag/Function/Return a bit mask encoding the state of the mouse buttons.
4543 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
4544 <tag/Declaration/<tt/unsigned char mouse_buttons (void);/
4545 <tag/Description/The function returns a bit mask that encodes the state of the
4546 mouse buttons. You may use the <tt/MOUSE_BTN_XXX/ flags to decode the function
4548 <tag/Availability/cc65
4550 <ref id="mouse_info" name="mouse_info">,
4551 <ref id="mouse_pos" name="mouse_pos">
4557 <sect1>mouse_geterrormsg<label id="mouse_geterrormsg"><p>
4561 <tag/Function/Return a readable error message for an error code.
4562 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
4563 <tag/Declaration/<tt/const char* __fastcall__ mouse_geterrormsg (unsigned char
4565 <tag/Description/The function returns an error message (in english) for the
4566 error code passed parameter.
4567 <tag/Notes/<itemize>
4568 <item>The function will return "Unknown error" for invalid error codes.
4569 <item>The function is only available as fastcall function, so it may only be
4570 used in presence of a prototype.
4572 <tag/Availability/cc65
4574 <ref id="mouse_load_driver" name="mouse_load_driver">,
4575 <ref id="mouse_uninstall" name="mouse_uninstall">,
4576 <ref id="mouse_unload" name="mouse_unload">
4582 <sect1>mouse_hide<label id="mouse_hide"><p>
4586 <tag/Function/Hide the mouse pointer.
4587 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
4588 <tag/Declaration/<tt/void mouse_hide (void);/
4589 <tag/Description/The function hides the mouse pointer. It manages a counter
4590 that is shared between <tt/<ref id="mouse_show" name="mouse_show">/ and
4591 <tt/mouse_hide/ so that every call call to <tt/mouse_hide/ must be followed by
4592 a call to <tt/<ref id="mouse_show" name="mouse_show">/ to make the mouse cursor
4594 <tag/Availability/cc65
4596 <ref id="mouse_show" name="mouse_show">
4602 <sect1>mouse_info<label id="mouse_info"><p>
4606 <tag/Function/Return the state of the mouse buttons and the position of the
4608 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
4609 <tag/Declaration/<tt/void __fastcall__ mouse_info (struct mouse_info* info);/
4610 <tag/Description/The function returns the state of the mouse buttons and the
4611 position of the mouse in the <tt/mouse_info/ structure passed as parameter.
4612 <tag/Notes/<itemize>
4613 <item>The <tt/mouse_info/ struct is a superset of the <tt/mouse_pos/ struct,
4614 so if you just need the mouse position, call <tt/<ref id="mouse_pos"
4615 name="mouse_pos">/ instead.
4616 <item>The function is only available as fastcall function, so it may only be
4617 used in presence of a prototype.
4619 <tag/Availability/cc65
4621 <ref id="mouse_buttons" name="mouse_buttons">,
4622 <ref id="mouse_pos" name="mouse_pos">
4628 <sect1>mouse_install<label id="mouse_install"><p>
4632 <tag/Function/Install an already loaded mouse driver.
4633 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
4634 <tag/Declaration/<tt/unsigned char __fastcall__ mouse_install (const struct
4635 mouse_callbacks* c, void* driver);/
4636 <tag/Description/The function installs an already loaded mouse driver and
4637 returns an error code. The <tt/mouse_callbacks/ structure passed as first
4638 parameter contains pointers to routines needed to move or hide/show the mouse
4639 pointer. Defaults for these routines are supplied by the library, so if you
4640 can live with these defaults (which are platform specific), just pass a
4641 pointer to <tt/mouse_def_callbacks/. The function may be used to install a
4642 driver linked statically to the program.
4643 <tag/Notes/<itemize>
4644 <item>Not all drivers are able to detect if the supported hardware is really
4646 <item>After installing a driver, the mouse cursor is hidden.
4647 <item>The function is only available as fastcall function, so it may only be
4648 used in presence of a prototype.
4650 <tag/Availability/cc65
4652 <ref id="mouse_load_driver" name="mouse_load_driver">,
4653 <ref id="mouse_uninstall" name="mouse_uninstall">,
4654 <ref id="mouse_unload" name="mouse_unload">
4660 <sect1>mouse_ioctl<label id="mouse_ioctl"><p>
4664 <tag/Function/Call the driver specific ioctl function.
4665 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
4666 <tag/Declaration/<tt/unsigned char __fastcall__ mouse_ioctl (unsigned char code, void* data);/
4667 <tag/Description/The function calls the IOCTL entry in the mouse driver,
4668 which is driver specific. The <tt/code/ parameter will choose between
4669 different IOCTL functions, and the <tt/data/ depends on code. The
4670 function returns an error code. The purpose of this function is to allow
4671 for driver specific extensions. See the documentation for a specific mouse
4672 driver for supported ioctl calls.
4673 <tag/Notes/<itemize>
4674 <item>Calling this function is non portable, because each driver may
4675 implement different ioctl calls (or none at all).
4676 <item>The function is only available as fastcall function, so it may only be
4677 used in presence of a prototype.
4679 <tag/Availability/cc65
4685 <sect1>mouse_load_driver<label id="mouse_load_driver"><p>
4689 <tag/Function/Load and initialize a mouse driver.
4690 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
4691 <tag/Declaration/<tt/unsigned char __fastcall__ mouse_load_driver (const struct
4692 mouse_callbacks* c, const char* driver);/
4693 <tag/Description/Load a mouse driver into memory and initialize it. The
4694 function returns an error code that tells if the call has been successful. The
4695 <tt/mouse_callbacks/ structure passed as first parameter contains pointers to
4696 routines needed to move or hide/show the mouse pointer. Defaults for these
4697 routines are supplied by the library, so if you can live with these defaults
4698 (which are platform specific), just pass a pointer to <tt/mouse_def_callbacks/.
4699 <tag/Notes/<itemize>
4700 <item>The driver is loaded by name, so currently you must know the type of
4701 mouse that should be supported. There is no autodetect capability.
4702 <item>Not all drivers are able to detect if the supported hardware is really
4704 <item>After installing a driver, the mouse cursor is hidden.
4705 <item>The function is only available as fastcall function, so it may only be
4706 used in presence of a prototype.
4708 <tag/Availability/cc65
4710 <ref id="mouse_install" name="mouse_install">,
4711 <ref id="mouse_uninstall" name="mouse_uninstall">,
4712 <ref id="mouse_unload" name="mouse_unload">
4718 <sect1>mouse_move<label id="mouse_move"><p>
4722 <tag/Function/Move the mouse cursor to a specific position.
4723 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
4724 <tag/Declaration/<tt/void __fastcall__ mouse_move (int x, int y);/
4725 <tag/Description/The function updates the mouse position. If the mouse cursor
4726 is visible, it is shown at the new position.
4727 <tag/Notes/<itemize>
4728 <item>The function does not check if the new position is within the bounding
4729 box specified with <tt/<ref id="mouse_setbox" name="mouse_setbox">/.
4730 <item>The function is only available as fastcall function, so it may only be
4731 used in presence of a prototype.
4733 <tag/Availability/cc65
4735 <ref id="mouse_getbox" name="mouse_getbox">,
4736 <ref id="mouse_setbox" name="mouse_setbox">
4742 <sect1>mouse_pos<label id="mouse_pos"><p>
4746 <tag/Function/Return the position of the mouse.
4747 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
4748 <tag/Declaration/<tt/void __fastcall__ mouse_pos (struct mouse_pos* pos);/
4749 <tag/Description/The function returns the position of the mouse in the
4750 <tt/mouse_pos/ structure passed as parameter.
4751 <tag/Notes/<itemize>
4752 <item>The <tt/mouse_pos/ struct is a subset of the <tt/mouse_info/ struct,
4753 so if you do also need the mouse buttons, call <tt/<ref id="mouse_info"
4754 name="mouse_info">/ instead.
4755 <item>The function is only available as fastcall function, so it may only be
4756 used in presence of a prototype.
4758 <tag/Availability/cc65
4760 <ref id="mouse_buttons" name="mouse_buttons">,
4761 <ref id="mouse_info" name="mouse_info">
4767 <sect1>mouse_show<label id="mouse_show"><p>
4771 <tag/Function/Show the mouse pointer.
4772 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
4773 <tag/Declaration/<tt/void mouse_show (void);/
4774 <tag/Description/The function shows the mouse pointer. It manages a counter
4775 that is shared between <tt/<ref id="mouse_hide" name="mouse_hide">/ and
4776 <tt/mouse_show/. The mouse cursor is visible if there was one more call to
4777 <tt/mouse_show/ than to <tt/<ref id="mouse_hide" name="mouse_hide">/.
4778 <tag/Availability/cc65
4780 <ref id="mouse_hide" name="mouse_hide">
4786 <sect1>mouse_uninstall<label id="mouse_uninstall"><p>
4790 <tag/Function/Uninstall an already loaded mouse driver.
4791 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
4792 <tag/Declaration/<tt/unsigned char mouse_uninstall (void);/
4793 <tag/Description/The function uninstalls an already loaded mouse driver but
4794 don't removes it from memory.
4795 <tag/Notes/<itemize>
4796 <item>If the driver has been loaded using <tt/<ref id="mouse_load_driver"
4797 name="mouse_load_driver">/, <tt/<ref id="mouse_unload" name="mouse_unload">/
4798 should be used instead of <tt/mouse_uninstall/ so the driver is also removed
4801 <tag/Availability/cc65
4803 <ref id="mouse_install" name="mouse_install">,
4804 <ref id="mouse_load_driver" name="mouse_load_driver">,
4805 <ref id="mouse_unload" name="mouse_unload">
4811 <sect1>mouse_unload<label id="mouse_unload"><p>
4815 <tag/Function/Unload a mouse driver.
4816 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
4817 <tag/Declaration/<tt/unsigned char mouse_unload (void);/
4818 <tag/Description/The function unloads a loaded mouse driver and frees all
4819 memory allocated for the driver.
4820 <tag/Notes/<itemize>
4821 <item>The function does nothing if no driver is loaded.
4823 <tag/Availability/cc65
4825 <ref id="mouse_install" name="mouse_install">,
4826 <ref id="mouse_load_driver" name="mouse_load_driver">,
4827 <ref id="mouse_uninstall" name="mouse_uninstall">
4833 <sect1>offsetof<label id="offsetof"><p>
4837 <tag/Function/Calculate the offset of a struct or union member.
4838 <tag/Header/<tt/<ref id="stddef.h" name="stddef.h">/
4839 <tag/Declaration/<tt/size_t offsetof (type, member);/
4840 <tag/Description/<tt/offsetof/ calculates the address offset of a <tt/struct/
4841 or <tt/union/ member.
4842 <tag/Notes/<itemize>
4843 <item>The function is actually a macro.
4845 <tag/Availability/ISO 9899
4851 <sect1>open<label id="open"><p>
4855 <tag/Function/Open and possibly create a file.
4856 <tag/Header/<tt/<ref id="fcntl.h" name="fcntl.h">/
4857 <tag/Declaration/<tt/int open (const char* name, int flags, ...);/
4858 <tag/Description/<tt/open/ opens a file and returns the file descriptor
4859 associated with it. On error, -1 is returned and an error code is stored in
4860 <tt/errno/. Several flags may be passed to <tt/open/ that change the behaviour.
4861 <tag/Notes/<itemize>
4862 <item>POSIX specifies an additional <tt/mode/ argument that may be passed to
4863 open, which is used as the permission mask when a new file is created. While
4864 cc65 allows to pass this argument, it is ignored.
4866 <tag/Availability/POSIX 1003.1
4868 <ref id="close" name="close">,
4869 <ref id="creat" name="creat">
4875 <sect1>opendir<label id="opendir"><p>
4879 <tag/Function/Open a directory.
4880 <tag/Header/<tt/<ref id="dirent.h" name="dirent.h">/
4881 <tag/Declaration/<tt/DIR* __fastcall__ opendir (const char* name);/
4882 <tag/Description/<tt/opendir/ opens a directory and returns the direcory
4883 descriptor associated with it. On error, NULL is returned and an error code is
4884 stored in <tt/errno/.
4885 <tag/Notes/<itemize>
4886 <item>The function is only available as fastcall function, so it may only
4887 be used in presence of a prototype.
4889 <tag/Availability/POSIX 1003.1
4891 <ref id="closedir" name="closedir">,
4892 <ref id="readdir" name="readdir">
4898 <sect1>peekbsys<label id="peekbsys"><p>
4902 <tag/Function/Read one byte from a location in the system bank.
4903 <tag/Header/<tt/<ref id="cbm610.h" name="cbm610.h">/,
4904 <tt/<ref id="cbm510.h" name="cbm510.h">/
4905 <tag/Declaration/<tt/unsigned char __fastcall__ peekbsys (unsigned addr);/
4906 <tag/Description/<tt/peekbsys/ reads one byte from the given address in the
4907 system bank (bank 15) of the CBM PET-II machines and returns it.
4908 <tag/Notes/<itemize>
4909 <item>The function is only available as fastcall function, so it may only
4910 be used in presence of a prototype.
4911 <item>This function may be a macro depending on the compiler options. The
4912 actual function is accessible by #undef'ing the macro.
4914 <tag/Availability/cc65
4916 <ref id="PEEK" name="PEEK">,
4917 <ref id="PEEKW" name="PEEKW">,
4918 <ref id="peekwsys" name="peekwsys">,
4919 <ref id="pokebsys" name="pokebsys">,
4920 <ref id="pokewsys" name="pokewsys">
4926 <sect1>peekwsys<label id="peekwsys"><p>
4930 <tag/Function/Read one word from a location in the system bank.
4931 <tag/Header/<tt/<ref id="cbm610.h" name="cbm610.h">/,
4932 <tt/<ref id="cbm510.h" name="cbm510.h">/
4933 <tag/Declaration/<tt/unsigned __fastcall__ peekwsys (unsigned addr);/
4934 <tag/Description/<tt/peekwsys/ reads one word from the given address in the
4935 system bank (bank 15) of the CBM PET-II machines and returns it. Following
4936 the usual 6502 conventions, the low byte is read from <tt/addr/, and the
4937 high byte is read from <tt/addr+1/.
4938 <tag/Notes/<itemize>
4939 <item>The function is only available as fastcall function, so it may only
4940 be used in presence of a prototype.
4941 <item>The order in which the two bytes are read is undefined.
4943 <tag/Availability/cc65
4945 <ref id="PEEK" name="PEEK">,
4946 <ref id="PEEKW" name="PEEKW">,
4947 <ref id="peekbsys" name="peekbsys">,
4948 <ref id="pokebsys" name="pokebsys">,
4949 <ref id="pokewsys" name="pokewsys">
4955 <sect1>perror<label id="perror"><p>
4959 <tag/Function/Print an error message for the error in <tt/errno/.
4960 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
4961 <tag/Declaration/<tt/void __fastcall__ perror (const char* s);/
4962 <tag/Description/<tt/perror/ prints an error message to <tt/stderr/. If <tt/s/
4963 is not <tt/NULL/ and not an empty string, it is printed followed by a colon and
4964 a blank. Then the error message for the current contents of <tt/errno/ is
4965 printed followed by a newline. The message output is the same as returned by
4966 <tt/<ref id="strerror" name="strerror">/ with an argument of <tt/errno/.
4967 <tag/Notes/<itemize>
4968 <item>The function is only available as fastcall function, so it may only
4969 be used in presence of a prototype.
4971 <tag/Availability/ISO 9899
4973 <ref id="_poserror" name="_poserror">,
4974 <ref id="strerror" name="strerror">
4980 <sect1>pokebsys<label id="pokebsys"><p>
4984 <tag/Function/Write one byte to a location in the system bank.
4985 <tag/Header/<tt/<ref id="cbm610.h" name="cbm610.h">/,
4986 <tt/<ref id="cbm510.h" name="cbm510.h">/
4987 <tag/Declaration/<tt/void __fastcall__ pokebsys (unsigned addr, unsigned char val);/
4988 <tag/Description/<tt/pokebsys/ writes one byte to the given address in the
4989 system bank (bank 15) of the CBM PET-II machines.
4990 <tag/Notes/<itemize>
4991 <item>The function is only available as fastcall function, so it may only
4992 be used in presence of a prototype.
4994 <tag/Availability/cc65
4996 <ref id="POKE" name="POKE">,
4997 <ref id="POKEW" name="POKEW">,
4998 <ref id="peekbsys" name="peekbsys">,
4999 <ref id="peekwsys" name="peekwsys">,
5000 <ref id="pokewsys" name="pokewsys">
5006 <sect1>pokewsys<label id="pokewsys"><p>
5010 <tag/Function/Write one word to a location in the system bank.
5011 <tag/Header/<tt/<ref id="cbm610.h" name="cbm610.h">/,
5012 <tt/<ref id="cbm510.h" name="cbm510.h">/
5013 <tag/Declaration/<tt/void __fastcall__ pokewsys (unsigned addr, unsigned val);/
5014 <tag/Description/<tt/pokewsys/ writes one word to the given address in the
5015 system bank (bank 15) of the CBM PET-II machines. Following the usual 6502
5016 conventions, the low byte of <tt/val/ is written to <tt/addr/, and the
5017 high byte is written to <tt/addr+1/.
5018 <tag/Notes/<itemize>
5019 <item>The function is only available as fastcall function, so it may only
5020 be used in presence of a prototype.
5021 <item>The order in which the two bytes are written is undefined.
5023 <tag/Availability/cc65
5025 <ref id="POKE" name="POKE">,
5026 <ref id="POKEW" name="POKEW">,
5027 <ref id="peekbsys" name="peekbsys">,
5028 <ref id="peekwsys" name="peekwsys">,
5029 <ref id="pokebsys" name="pokebsys">
5035 <sect1>qsort<label id="qsort"><p>
5039 <tag/Function/Sort an array.
5040 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
5041 <tag/Declaration/<tt/void __fastcall__ qsort (void* base, size_t count,
5042 size_t size, int __fastcall__ (* compare) (const void*, const void*));/
5043 <tag/Description/<tt/qsort/ sorts an array according to a given compare
5044 function <tt/compare/. <tt/base/ is the address of the array, <tt/count/
5045 is the number of elements, <tt/size/ the size of an element and <tt/compare/
5046 the function used to compare the members.
5047 <tag/Notes/<itemize>
5048 <item>If there are multiple members with the same key, the order after calling
5049 the function is undefined.
5050 <item>The function is only available as fastcall function, so it may only
5051 be used in presence of a prototype.
5052 <item>The function to which <tt/compare/ points must have the <tt/fastcall/
5055 <tag/Availability/ISO 9899
5057 <ref id="bsearch" name="bsearch">
5063 <sect1>raise<label id="raise"><p>
5067 <tag/Function/Send a signal to the executing program.
5068 <tag/Header/<tt/<ref id="signal.h" name="signal.h">/
5069 <tag/Declaration/<tt/int __fastcall__ raise (int sig);/
5070 <tag/Description/<tt/raise/ sends the given signal to the program. If the
5071 program has installed a signal handler for the signal, this signal handler
5072 will be executed. If no handler has been installed, the default action for
5073 the raised signal will be taken. The function returns zero on success,
5075 <tag/Notes/<itemize>
5076 <item>The function is only available as fastcall function, so it may only
5077 be used in presence of a prototype.
5079 <tag/Availability/ISO 9899
5081 <ref id="abort" name="abort">,
5082 <ref id="signal" name="signal">
5088 <sect1>rand<label id="rand"><p>
5092 <tag/Function/Return a pseudo random number.
5093 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
5094 <tag/Declaration/<tt/int rand (void);/
5095 <tag/Description/The function returns a pseudo random number
5096 between 0 and <tt/RAND_MAX/ (exclusive).
5097 <tag/Notes/<itemize>
5098 <item>Without using <tt><ref id="srand" name="srand"></tt>, always the same
5099 flow of numbers is generated.
5100 <item>On startup, the function behaves as if <ref id="srand" name="srand">
5101 had been used with an argument of 1.
5103 <tag/Availability/ISO 9899
5105 <ref id="_randomize" name="_randomize">,
5106 <ref id="srand" name="srand">
5112 <sect1>readdir<label id="readdir"><p>
5116 <tag/Function/Read a directory.
5117 <tag/Header/<tt/<ref id="dirent.h" name="dirent.h">/
5118 <tag/Declaration/<tt/struct dirent* __fastcall__ readdir (DIR* dir);/
5119 <tag/Description/<tt/readdir/ reads the next directory entry from the directory
5120 stream pointed to by <tt/dir/. It stores the data in a <tt/dirent/ structure
5121 and returns a pointer to it. If the end of directory is reached, or an error
5122 occurs, NULL is returned. In case of errors, an error code is stored into
5124 <tag/Notes/<itemize>
5125 <item>The function is only available as fastcall function, so it may only
5126 be used in presence of a prototype.
5127 <item>The returned pointer may point to a statically allocated instance of
5128 <tt/struct dirent/, so it may get overwritten by subsequent calls to
5130 <item>On several platforms, namely the CBMs and the Atari, the disk drives get
5131 confused when opening/closing files between directory reads. So for example a
5132 program that reads the list of files on a disk, and after each call to
5133 <tt/readdir/, opens the file to process it, will fail.<newline>
5134 Possible solutions are reading the directory into memory before processing the
5135 file list, or to reset the directory by seeking to the correct position after
5136 opening/closing a file:
5138 seekdir (DIR, telldir (DIR));
5140 Platforms known to work without problems are: Apple.
5142 <tag/Availability/POSIX 1003.1
5144 <ref id="closedir" name="closedir">,
5145 <ref id="opendir" name="opendir">
5151 <sect1>realloc<label id="realloc"><p>
5155 <tag/Function/Change the size of an allocated memory block.
5156 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
5157 <tag/Declaration/<tt/void* __fastcall__ realloc (void* block, size_t size);/
5158 <tag/Description/<tt/realloc/ changes the size of the memory block pointed to
5159 by <tt/block/ to <tt/size/ bytes. If <tt/block/ is <tt/NULL/, <tt/realloc/
5160 behaves as if <tt/malloc/ had been called. If <tt/size/ is zero, <tt/realloc/
5161 behaves as if <tt/free/ had been called. On error (not enough memory
5162 available), <tt/realloc/ returns <tt/NULL/.
5163 <tag/Notes/<itemize>
5164 <item>The part of the memory block that is returned will have its contents
5166 <item>This function is somewhat dangerous to use. Be careful to save the
5167 pointer you're passing somewhere else, otherwise
5169 ptr = realloc (ptr, size);
5171 will loose your only copy of <tt/ptr/ if <tt/realloc/ returns <tt/NULL/.
5172 <item>The function is only available as fastcall function, so it may only
5173 be used in presence of a prototype.
5175 <tag/Availability/ISO 9899
5177 <ref id="_heapadd" name="_heapadd">,
5178 <ref id="_heapblocksize" name="_heapblocksize">,
5179 <ref id="_heapmaxavail" name="_heapmaxavail">,
5180 <ref id="_heapmemavail" name="_heapmemavail">,
5181 <ref id="calloc" name="calloc">,
5182 <ref id="free" name="free">,
5183 <ref id="realloc" name="realloc">
5189 <sect1>remove<label id="remove"><p>
5193 <tag/Function/Delete a file.
5194 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
5195 <tag/Declaration/<tt/int __fastcall__ remove (const char* name);/
5196 <tag/Description/<tt/remove/ deletes the file with the given name. On success,
5197 zero is returned. On error, -1 is returned and <tt/errno/ is set to an error
5198 code describing the reason for the failure.
5199 <tag/Notes/<itemize>
5200 <item>This function is not available on all cc65 targets (depends on the
5201 availability of file I/O).
5202 <item>The function is only available as fastcall function, so it may only
5203 be used in presence of a prototype.
5205 <tag/Availability/ISO 9899
5207 <ref id="rename" name="rename">,
5208 <ref id="unlink" name="unlink">
5211 #include <stdio.h>
5213 #define FILENAME "helloworld"
5215 if (remove (FILENAME) == 0) {
5216 printf ("We deleted %s successfully\n", FILENAME);
5218 printf ("There was a problem deleting %s\n", FILENAME);
5225 <sect1>rename<label id="rename"><p>
5229 <tag/Function/Rename a file.
5230 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
5231 <tag/Declaration/<tt/int __fastcall__ rename (const char* oldname, const char* newname);/
5232 <tag/Description/<tt/rename/ renames a file (gives it a new name). On success,
5233 zero is returned. On error, -1 is returned and <tt/errno/ is set to an error
5234 code describing the reason for the failure.
5235 <tag/Notes/<itemize>
5236 <item>This function is not available on all cc65 targets (depends on the
5237 capabilities of the storage devices).
5238 <item>The function is only available as fastcall function, so it may only
5239 be used in presence of a prototype.
5241 <tag/Availability/ISO 9899
5243 <ref id="remove" name="remove">
5246 #include <stdio.h>
5248 #define OLDNAME "textfile.txt"
5249 #define NEWNAME "textfile.bak"
5251 if (rename (OLDNAME, NEWNAME) == 0) {
5252 printf ("Renamed %s to %s\n", OLDNAME, NEWNAME);
5254 printf ("Error renaming %s to %s\n", OLDNAME, NEWNAME);
5261 <sect1>reset_brk<label id="reset_brk"><p>
5265 <tag/Function/Resets the break vector to its original value.
5266 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
5267 <tag/Declaration/<tt/void reset_brk (void);/
5268 <tag/Description/<tt/reset_brk/ resets the break vector to the value it had
5269 before a call to <tt/set_brk/.
5270 <tag/Notes/<itemize>
5271 <item>The break vector is reset on program termination, so it's not strictly
5272 necessary to call this function as a part of your clean-up when exitting the program.
5274 <tag/Availability/cc65
5276 <ref id="reset_irq" name="reset_irq">,
5277 <ref id="set_brk" name="set_brk">,
5278 <ref id="set_irq" name="set_irq">
5284 <sect1>reset_irq<label id="reset_irq"><p>
5288 <tag/Function/Resets the C level interrupt request vector.
5289 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
5290 <tag/Declaration/<tt/void reset_irq (void);/
5291 <tag/Description/<tt/reset_irq/ resets the C level interrupt request vector.
5292 <tag/Notes/<itemize>
5293 <item>The interrupt vector is reset on program termination, so it's not strictly
5294 necessary to call this function as a part of your clean-up when exitting the program.
5296 <tag/Availability/cc65
5298 <ref id="reset_brk" name="reset_brk">,
5299 <ref id="set_brk" name="set_brk">,
5300 <ref id="set_irq" name="set_irq">
5306 <sect1>revers<label id="revers"><p>
5310 <tag/Function/Control revers character display.
5311 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
5312 <tag/Declaration/<tt/unsigned char __fastcall__ revers (unsigned char onoff);/
5313 <tag/Description/If the argument is non zero, the function enables reverse
5314 character display. If the argument is zero, reverse character display is
5315 switched off. The old value of the setting is returned.
5316 <tag/Notes/<itemize>
5317 <item>The function may not be supported by the hardware, in which case
5318 the call is ignored.
5319 <item>The function is only available as fastcall function, so it may only
5320 be used in presence of a prototype.
5322 <tag/Availability/cc65
5324 <ref id="textcolor" name="textcolor">
5330 <sect1>rewinddir<label id="rewinddir"><p>
5334 <tag/Function/Reset a directory stream.
5335 <tag/Header/<tt/<ref id="dirent.h" name="dirent.h">/
5336 <tag/Declaration/<tt/void __fastcall__ rewinddir (DIR* dir);/
5337 <tag/Description/<tt/rewinddir/ sets the position of the directory stream
5338 pointed to by <tt/dir/ to the start of the directory.
5339 <tag/Notes/<itemize>
5340 <item>The function is only available as fastcall function, so it may only
5341 be used in presence of a prototype.
5343 <tag/Availability/POSIX 1003.1
5345 <ref id="seekdir" name="seekdir">,
5346 <ref id="telldir" name="telldir">
5352 <sect1>screensize<label id="screensize"><p>
5356 <tag/Function/Return the dimensions of the text mode screen.
5357 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
5358 <tag/Declaration/<tt/void __fastcall__ screensize (unsigned char* x, unsigned char* y);/
5359 <tag/Description/The function returns the dimensions of the text mode screen.
5360 <tag/Notes/<itemize>
5361 <item>The function is only available as fastcall function, so it may only
5362 be used in presence of a prototype.
5364 <tag/Availability/cc65
5366 <ref id="gotox" name="gotox">,
5367 <ref id="gotoxy" name="gotoxy">,
5368 <ref id="gotoy" name="gotoy">,
5369 <ref id="wherex" name="wherex">,
5370 <ref id="wherey" name="wherey">
5376 <sect1>seekdir<label id="seekdir"><p>
5380 <tag/Function/Set the position of a directory stream.
5381 <tag/Header/<tt/<ref id="dirent.h" name="dirent.h">/
5382 <tag/Declaration/<tt/void __fastcall__ seekdir (DIR* dir, long offset);/
5383 <tag/Description/<tt/seekdir/ sets the position of the directory stream
5384 pointed to by <tt/dir/ to the value given in <tt/offset/, which should be a
5385 value returned by <tt/<ref id="telldir" name="telldir">/.
5386 <tag/Notes/<itemize>
5387 <item>The function is only available as fastcall function, so it may only
5388 be used in presence of a prototype.
5390 <tag/Availability/POSIX 1003.1
5392 <ref id="rewinddir" name="rewinddir">,
5393 <ref id="telldir" name="telldir">
5399 <sect1>ser_close<label id="ser_close"><p>
5403 <tag/Function/Close the port and disable interrupts
5404 <tag/Header/<tt/<ref id="serial.h" name="serial.h">/
5405 <tag/Declaration/<tt/unsigned char ser_close (void);/
5406 <tag/Description/Close the port by clearing buffers and disable interrupts.
5407 <tag/Availability/cc65
5408 <tag/See also/Other serial functions.
5413 static void initialize(){
5414 struct ser_params params = {
5421 ser_install(lynx_comlynx); // This will activate the ComLynx
5423 ser_open(&params);
5430 <sect1>ser_get<label id="ser_get"><p>
5434 <tag/Function/Read a character from serial port.
5435 <tag/Header/<tt/<ref id="serial.h" name="serial.h">/
5436 <tag/Declaration/<tt/unsigned char __fastcall__ ser_get (char* b);/
5437 <tag/Description/Get a character from the serial port. If no characters are
5438 available, the function will return SER_ERR_NO_DATA, so this is not a fatal
5440 <tag/Notes/<itemize>
5441 <item>The function is only available as fastcall function, so it may only
5442 be used in presence of a prototype.
5444 <tag/Availability/cc65
5445 <tag/See also/Other serial functions.
5447 Wait for a character to be available from a serial port.
5450 while (ser_get(&ch) == SER_ERR_NO_DATA)
5457 <sect1>ser_install<label id="ser_install"><p>
5461 <tag/Function/Install an already loaded driver and return an error code.
5462 <tag/Header/<tt/<ref id="serial.h" name="serial.h">/
5463 <tag/Declaration/<tt/unsigned char __fastcall__ ser_install (void* driver);/
5464 <tag/Description/The function installs a driver that was already loaded into
5465 memory (or linked statically to the program). It returns an error code
5466 (<tt/SER_ERR_OK/ in case of success).
5467 <tag/Notes/<itemize>
5468 <item>The function is only available as fastcall function, so it may only be
5469 used in presence of a prototype.
5471 <tag/Availability/cc65
5473 <ref id="ser_load_driver" name="ser_load_driver">,
5474 <ref id="ser_uninstall" name="ser_uninstall">,
5475 <ref id="ser_unload" name="ser_unload">
5477 ser_install(lynx_comlynx); //Include the driver statically instead of loading it.
5483 <sect1>ser_ioctl<label id="ser_ioctl"><p>
5487 <tag/Function/Platform dependent code extensions.
5488 <tag/Header/<tt/<ref id="serial.h" name="serial.h">/
5489 <tag/Declaration/<tt/unsigned __fastcall__ ser_ioctl (unsigned char code, void* data);/
5490 <tag/Description/Some platforms have extra serial functions that are not
5491 supported by standard serial driver functions. You can extend the driver to support
5492 this extra functionality bt using ser_ioctl functions.
5493 <tag/Notes/<itemize>
5494 <item>The function is only available as fastcall function, so it may only
5495 be used in presence of a prototype.
5496 <item>These functions are not easily portable to other cc65 platforms.
5498 <tag/Availability/cc65
5499 <tag/See also/Other serial functions.
5504 <sect1>ser_load_driver<label id="ser_load_driver"><p>
5508 <tag/Function/Load and install a serial driver.
5509 <tag/Header/<tt/<ref id="serial.h" name="serial.h">/
5510 <tag/Declaration/<tt/unsigned char __fastcall__ ser_load_driver (const char *name);/
5511 <tag/Description/Load and install the driver by name.
5512 Will just load the driver and check if loading was successful.
5513 <tag/Notes/<itemize>
5514 <item>The function is only available as fastcall function, so it may only
5515 be used in presence of a prototype.
5517 <tag/Availability/cc65
5518 <tag/See also/Other serial functions.
5524 <sect1>ser_open<label id="ser_open"><p>
5528 <tag/Function/Open the port by setting the port parameters and enable interrupts
5529 <tag/Header/<tt/<ref id="serial.h" name="serial.h">/
5530 <tag/Declaration/<tt/unsigned char __fastcall__ ser_open (const struct ser_params* params);/
5531 <tag/Description/Open the port by setting the port parameters and enable interrupts.
5532 <tag/Notes/<itemize>
5533 <item>The function is only available as fastcall function, so it may only
5534 be used in presence of a prototype.
5536 <tag/Availability/cc65
5537 <tag/See also/Other serial functions.
5542 static void initialize(){
5543 struct ser_params params = {
5550 ser_install(lynx_comlynx); // This will activate the ComLynx
5552 ser_open(&params);
5559 <sect1>ser_put<label id="ser_put"><p>
5563 <tag/Function/Write a character to a serial port.
5564 <tag/Header/<tt/<ref id="serial.h" name="serial.h">/
5565 <tag/Declaration/<tt/unsigned char __fastcall__ ser_put (char b);/
5566 <tag/Description/Send a character via the serial port. There is a transmit
5567 buffer, but transmitting is not done via interrupt. The function returns
5568 SER_ERR_OVERFLOW if there is no space left in the transmit buffer.
5569 <tag/Notes/<itemize>
5570 <item>The function is only available as fastcall function, so it may only
5571 be used in presence of a prototype.
5573 <tag/Availability/cc65
5574 <tag/See also/Other serial functions.
5583 <sect1>ser_status<label id="ser_status"><p>
5587 <tag/Function/Return the serial port status.
5588 <tag/Header/<tt/<ref id="serial.h" name="serial.h">/
5589 <tag/Declaration/<tt/unsigned char __fastcall__ ser_status (unsigned char* status);/
5590 <tag/Description/Return the serial port status.
5591 <tag/Notes/<itemize>
5592 <item>The function is only available as fastcall function, so it may only
5593 be used in presence of a prototype.
5595 <tag/Availability/cc65
5596 <tag/See also/Other serial functions.
5602 <sect1>ser_uninstall<label id="ser_uninstall"><p>
5606 <tag/Function/Uninstall the currently loaded driver but do not unload it.
5607 <tag/Header/<tt/<ref id="serial.h" name="serial.h">/
5608 <tag/Declaration/<tt/unsigned char ser_uninstall (void);/
5609 <tag/Description/Uninstall the currently loaded driver but do not unload it.
5610 <tag/Availability/cc65
5611 <tag/See also/Other serial functions.
5616 <sect1>ser_unload<label id="ser_unload"><p>
5620 <tag/Function/Uninstall, then unload the currently loaded driver.
5621 <tag/Header/<tt/<ref id="serial.h" name="serial.h">/
5622 <tag/Declaration/<tt/unsigned char ser_unload (void);/
5623 <tag/Description/Uninstall, then unload the currently loaded driver.
5624 <tag/Availability/cc65
5625 <tag/See also/Other serial functions.
5631 <sect1>set_brk<label id="set_brk"><p>
5635 <tag/Function/Set the break vector to a user function.
5636 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
5637 <tag/Declaration/<tt/void __fastcall__ set_brk (brk_handler func);/
5638 <tag/Description/<tt/set_brk/ allows a user program to handle breaks within the
5639 program code by letting the vector point to a user written C function. The
5640 runtime library installs a small stub that saves the registers into global
5641 variables that may be accessed (and changed) by the break handler.
5642 <tag/Notes/<itemize>
5643 <item>The function is only available as fastcall function, so it may only
5644 be used in presence of a prototype.
5645 <item>The stub saves the zero page registers used by the C runtime and switches
5646 to a small break handler stack. This means that it is safe to execute C code,
5647 even if C code was interrupted. Be careful however not to use too many local
5648 variables, and do not enable stack checks for the handler function or any other
5649 function called from it.
5650 <item>The <tt/brk_pc/ variable points to the <tt/BRK/ instruction. If you want
5651 the continue with the interrupted code, you have to adjust <tt/brk_pc/,
5652 otherwise the <tt/BRK/ instruction will get executed over and over again.
5653 <item>The break vector is reset on program termination, so it's not strictly
5654 necessary to call <tt/<ref id="reset_brk" name="reset_brk">/ as a part of your
5655 clean-up when exitting the program.
5657 <tag/Availability/cc65
5659 <ref id="reset_brk" name="reset_brk">
5665 <sect1>set_irq<label id="set_irq"><p>
5669 <tag/Function/Set the C level interrupt request vector to the given address.
5670 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
5671 <tag/Declaration/<tt/void __fastcall__ set_irq (irq_handler f, void *stack_addr, size_t stack_size);/
5672 <tag/Description/<tt/set_irq/ allows a user program to handle interrupt requests
5673 (IRQs) within the program code by letting the vector point to a user written C
5674 function. The runtime library installs a small stub that saves the zero page
5675 registers used by the C runtime before calling the handler function and restores
5676 them after the handler function returns. Additionally the stub temporarily switches
5677 the C runtime stack to the stack area provided as parameter. If the handler function
5678 was set up to handle a "private", "exclusive" interrupt request source it must
5679 return the value <tt/IRQ_HANDLED/ if and only if it has verified that the current
5680 interrupt request actually stems from that source. In all other cases it must return
5681 the value <tt/IRQ_NOT_HANDLED/.
5682 <tag/Notes/<itemize>
5683 <item>The function is only available as fastcall function, so it may only
5684 be used in presence of a prototype.
5685 <item>The stub saves the registers and zero page locations used by the C runtime
5686 and switches to the provided stack area. As a consequence, there is some
5687 runtime overhead, but it it is safe to execute C code, even if other C code
5688 was interrupted. Be careful however not to call C library functions, and do not
5689 enable stack checks for the handler function or any other function called from
5691 <item>The interrupt vector is reset on program termination, so it's not strictly
5692 necessary to call <tt/<ref id="reset_irq" name="reset_irq">/ as a part of your
5693 clean-up when exitting the program.
5695 <tag/Availability/cc65
5697 <ref id="reset_brk" name="reset_brk">,
5698 <ref id="reset_irq" name="reset_irq">,
5699 <ref id="set_brk" name="set_brk">
5705 <sect1>setjmp<label id="setjmp"><p>
5709 <tag/Function/Save the context for use with <tt/longjmp/.
5710 <tag/Header/<tt/<ref id="setjmp.h" name="setjmp.h">/
5711 <tag/Declaration/<tt/int __fastcall__ setjmp (jmp_buf buf);/
5712 <tag/Description/The <tt/setjmp/ function saves the current context in <tt/buf/
5713 for subsequent use by the <tt/<ref id="longjmp" name="longjmp">/ function and
5715 <tag/Notes/<itemize>
5716 <item>The function is only available as fastcall function, so it may only
5717 be used in presence of a prototype.
5718 <item><tt/setjmp/ is actually a macro as required by the ISO standard.
5719 <item><tt/setjmp/ will not save the signal context.
5721 <tag/Availability/ISO 9899
5723 <ref id="longjmp" name="longjmp">
5729 <sect1>setlocale<label id="setlocale"><p>
5733 <tag/Function/Selects a locale.
5734 <tag/Header/<tt/<ref id="locale.h" name="locale.h">/
5735 <tag/Declaration/<tt/char* __fastcall__ setlocale (int category, const char* locale);/
5736 <tag/Description/<tt/setlocale/ sets or queries the program's locale.
5737 <tag/Notes/<itemize>
5738 <item>The function is only available as fastcall function, so it may only
5739 be used in presence of a prototype.
5740 <item>cc65 supports only the "C" locale, so calling this function to set a
5741 different locale has no effect.
5743 <tag/Availability/ISO 9899
5745 <ref id="localeconv" name="localeconv">,
5746 <ref id="strcoll" name="strcoll">
5747 <ref id="strxfrm" name="strxfrm">
5753 <sect1>signal<label id="signal"><p>
5757 <tag/Function/Install a signal handler.
5758 <tag/Header/<tt/<ref id="signal.h" name="signal.h">/
5759 <tag/Declaration/<tt/__sigfunc __fastcall__ signal (int sig, __sigfunc func);/
5760 <tag/Description/<tt/signal/ installs a handler for the given signal. The
5761 handler may either be a user supplied function, or one of the predefined
5762 signal handlers <tt/SIG_IGN/ or <tt/SIG_DFL/. The function returns the
5763 previous value if the signal , or the special function vector SIG_ERR in
5765 <tag/Notes/<itemize>
5766 <item>The function is only available as fastcall function, so it may only
5767 be used in presence of a prototype.
5769 <tag/Availability/ISO 9899
5771 <ref id="abort" name="abort">,
5772 <ref id="raise" name="raise">
5778 <sect1>sleep<label id="sleep"><p>
5782 <tag/Function/Sleep for a specified amount of time.
5783 <tag/Header/<tt/<ref id="unistd.h" name="unistd.h">/
5784 <tag/Declaration/<tt/void __fastcall__ sleep (unsigned seconds);/
5785 <tag/Description/The function will return after the specified number of
5786 seconds have elapsed.
5787 <tag/Notes/<itemize>
5788 <item>The function is only available as fastcall function, so it may only
5789 be used in presence of a prototype.
5791 <tag/Availability/POSIX 1003.1
5797 <sect1>slow<label id="slow"><p>
5801 <tag/Function/Switch the C128 into 1MHz mode.
5802 <tag/Header/<tt/<ref id="c128.h" name="c128.h">/
5803 <tag/Declaration/<tt/void slow (void);/
5804 <tag/Description/The function will switch the clock of the C128 to 1MHz. This
5805 will halve the speed compared to fast mode.
5806 <tag/Notes/<itemize>
5807 <item>The function is specific to the C128.
5809 <tag/Availability/C128
5811 <ref id="fast" name="fast">,
5812 <ref id="toggle_videomode" name="toggle_videomode">,
5813 <ref id="videomode" name="videomode">
5819 <sect1>srand<label id="srand"><p>
5823 <tag/Function/Initialize the pseudo random number generator.
5824 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
5825 <tag/Declaration/<tt/void __fastcall__ srand (unsigned seed);/
5826 <tag/Description/The function initializes the random number generator using
5827 the given seed. On program startup, the generator behaves as if <tt/srand/ has
5828 been called with an argument of 1.
5829 <tag/Notes/<itemize>
5830 <item>The function is only available as fastcall function, so it may only
5831 be used in presence of a prototype.
5833 <tag/Availability/ISO 9899
5835 <ref id="_randomize" name="_randomize">,
5836 <ref id="rand" name="rand">
5842 <sect1>strcasecmp<label id="strcasecmp"><p>
5846 <tag/Function/Compare two strings case insensitive.
5847 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5848 <tag/Declaration/<tt/int __fastcall__ strcasecmp (const char* s1, const char* s2);/
5849 <tag/Description/The <tt/strcasecmp/ function compares the two strings passed
5850 as parameters without case sensitivity. It returns a value that is less than
5851 zero if <tt/s1/ is less than <tt/s2/, zero if <tt/s1/ is the same as <tt/s2/,
5852 and a value greater than zero if <tt/s1/ is greater than <tt/s2/.
5853 <tag/Notes/<itemize>
5854 <item>The function is only available as fastcall function, so it may only
5855 be used in presence of a prototype.
5856 <item>The function is not available in strict ANSI mode.
5858 <tag/Availability/cc65
5860 <ref id="strcmp" name="strcmp">,
5861 <ref id="strcoll" name="strcoll">,
5862 <ref id="stricmp" name="stricmp">,
5863 <ref id="strncmp" name="strncmp">,
5864 <ref id="strxfrm" name="strxfrm">
5870 <sect1>strcat<label id="strcat"><p>
5874 <tag/Function/Concatentate two strings.
5875 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5876 <tag/Declaration/<tt/char* __fastcall__ strcat (char* s1, const char* s2);/
5877 <tag/Description/The <tt/strcat/ function appends a copy of the string
5878 pointed to by s2 (including the terminating null byte) to the end of the
5879 string pointed to by s1. The initial byte of s2 overwrites the null byte at
5881 <tag/Notes/<itemize>
5882 <item>The function is only available as fastcall function, so it may only
5883 be used in presence of a prototype.
5884 <item>If copying takes place between objects that overlap, the behaviour
5887 <tag/Availability/ISO 9899
5889 <ref id="strcpy" name="strcpy">,
5890 <ref id="strncat" name="strncat">,
5891 <ref id="strncpy" name="strncpy">
5897 <sect1>strchr<label id="strchr"><p>
5901 <tag/Function/Search for a character in a string.
5902 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5903 <tag/Declaration/<tt/char* __fastcall__ strchr (const char* s, int c);/
5904 <tag/Description/The <tt/strchr/ function locates the first occurrence of <tt/c/
5905 (converted to a char) in the string pointed to by <tt/s/. The terminating null
5906 byte is considered to be part of the string. Upon completion, the function
5907 returns a pointer to the byte, or a null pointer if the byte was not found.
5908 <tag/Notes/<itemize>
5909 <item>The function is only available as fastcall function, so it may only
5910 be used in presence of a prototype.
5912 <tag/Availability/ISO 9899
5914 <ref id="memchr" name="memchr">,
5915 <ref id="strrchr" name="strrchr">
5921 <sect1>strcmp<label id="strcmp"><p>
5925 <tag/Function/Compare two strings.
5926 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5927 <tag/Declaration/<tt/int __fastcall__ strcmp (const char* s1, const char* s2);/
5928 <tag/Description/The <tt/strcmp/ function compares the two strings passed as
5929 parameters. It returns a value that is less than zero if <tt/s1/ is less than
5930 <tt/s2/, zero if <tt/s1/ is the same as <tt/s2/, and a value greater than zero
5931 if <tt/s1/ is greater than <tt/s2/.
5932 <tag/Notes/<itemize>
5933 <item>The function is only available as fastcall function, so it may only
5934 be used in presence of a prototype.
5936 <tag/Availability/ISO 9899
5938 <ref id="strcasecmp" name="strcasecmp">,
5939 <ref id="strcoll" name="strcoll">,
5940 <ref id="stricmp" name="stricmp">,
5941 <ref id="strncmp" name="strncmp">
5942 <ref id="strxfrm" name="strxfrm">
5948 <sect1>strcoll<label id="strcoll"><p>
5952 <tag/Function/Compare two strings.
5953 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5954 <tag/Declaration/<tt/int __fastcall__ strcoll (const char* s1, const char* s2);/
5955 <tag/Description/The <tt/strcoll/ function compares the two strings passed as
5956 parameters, according to the collating sequence set by <tt/<ref id="setlocale"
5957 name="setlocale">/. It returns a value that is less than zero if <tt/s1/ is
5958 less than <tt/s2/, zero if <tt/s1/ is the same as <tt/s2/, and a value greater
5959 than zero if <tt/s1/ is greater than <tt/s2/.
5960 <tag/Notes/<itemize>
5961 <item>The function is only available as fastcall function, so it may only
5962 be used in presence of a prototype.
5964 <tag/Availability/ISO 9899
5966 <ref id="setlocale" name="setlocale">,
5967 <ref id="strcasecmp" name="strcasecmp">,
5968 <ref id="strcmp" name="strcmp">,
5969 <ref id="stricmp" name="stricmp">,
5970 <ref id="strncmp" name="strncmp">,
5971 <ref id="strxfrm" name="strxfrm">
5977 <sect1>strcpy<label id="strcpy"><p>
5981 <tag/Function/Copy a string.
5982 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5983 <tag/Declaration/<tt/char* __fastcall__ strcpy (char* s1, const char* s2);/
5984 <tag/Description/The <tt/strcpy/ function copies the string pointed to by
5985 <tt/s2/ (including the terminating null byte) into the array pointed to by
5986 <tt/s1/. The function will always return <tt/s1/.
5987 <tag/Notes/<itemize>
5988 <item>The function is only available as fastcall function, so it may only
5989 be used in presence of a prototype.
5990 <item>If copying takes place between objects that overlap, the behaviour
5993 <tag/Availability/ISO 9899
5995 <ref id="strcat" name="strcat">,
5996 <ref id="strncat" name="strncat">,
5997 <ref id="strncpy" name="strncpy">
6000 #include <string.h>
6002 static char hello[14];
6004 strcpy (hello, "Hello world!\n");
6010 <sect1>strcspn<label id="strcspn"><p>
6014 <tag/Function/Compute the length of a substring.
6015 <tag/Header/<tt/<ref id="string.h" name="string.h">/
6016 <tag/Declaration/<tt/size_t __fastcall__ strcspn (const char* s, const char* set);/
6017 <tag/Description/The <tt/strcspn/ function computes and returns the length of
6018 the substring pointed to by <tt/s/ which does <em>not</em> consist of
6019 characters contained in the string <tt/set/.
6020 <tag/Notes/<itemize>
6021 <item>The function is only available as fastcall function, so it may only
6022 be used in presence of a prototype.
6024 <tag/Availability/ISO 9899
6026 <ref id="strqtok" name="strqtok">,
6027 <ref id="strspn" name="strspn">,
6028 <ref id="strstr" name="strstr">,
6029 <ref id="strtok" name="strtok">
6035 <sect1>strdup<label id="strdup"><p>
6039 <tag/Function/Allocate a copy of a string on the heap.
6040 <tag/Header/<tt/<ref id="string.h" name="string.h">/
6041 <tag/Declaration/<tt/char* __fastcall__ strdup (const char* s);/
6042 <tag/Description/<tt/strdup/ allocates a memory block on the heap, big enough
6043 to hold a copy of <tt/s/ including the terminating zero. If the allocation
6044 fails, <tt/NULL/ is returned, otherwise <tt/s/ is copied into the allocated
6045 memory block, and a pointer to the block is returned.
6046 <tag/Notes/<itemize>
6047 <item>The function is only available as fastcall function, so it may only
6048 be used in presence of a prototype.
6049 <item>It is up to the caller to free the allocated memory block.
6051 <tag/Availability/ISO 9899
6053 <ref id="free" name="free">,
6054 <ref id="malloc" name="malloc">
6060 <sect1>strerror<label id="strerror"><p>
6064 <tag/Function/Return a string describing an error code.
6065 <tag/Header/<tt/<ref id="string.h" name="string.h">/
6066 <tag/Declaration/<tt/char* __fastcall__ strerror (int errcode);/
6067 <tag/Description/The <tt/strerror/ function returns a string describing the
6068 given error code. If an invalid error code is passed, the string "Unknown
6069 error" is returned, and <tt/errno/ is set to <tt/EINVAL/. In all other cases,
6070 <tt/errno/ is left untouched.
6071 <tag/Notes/<itemize>
6072 <item>The function is only available as fastcall function, so it may only
6073 be used in presence of a prototype.
6074 <item>While the return type of the function is a <tt/char*/, the returned
6075 string must not be modified by the caller!
6077 <tag/Availability/ISO 9899
6079 <ref id="_stroserror" name="_stroserror">
6085 <sect1>stricmp<label id="stricmp"><p>
6089 <tag/Function/Compare two strings case insensitive.
6090 <tag/Header/<tt/<ref id="string.h" name="string.h">/
6091 <tag/Declaration/<tt/int __fastcall__ stricmp (const char* s1, const char* s2);/
6092 <tag/Description/The <tt/stricmp/ function compares the two strings passed as
6093 parameters without case sensitivity. It returns a value that is less than zero
6094 if <tt/s1/ is less than <tt/s2/, zero if <tt/s1/ is the same as <tt/s2/, and a
6095 value greater than zero if <tt/s1/ is greater than <tt/s2/.
6096 <tag/Notes/<itemize>
6097 <item>The function is only available as fastcall function, so it may only
6098 be used in presence of a prototype.
6099 <item>The function is not available in strict ANSI mode.
6101 <tag/Availability/cc65
6103 <ref id="strcasecmp" name="strcasecmp">,
6104 <ref id="strcmp" name="strcmp">,
6105 <ref id="strcoll" name="strcoll">,
6106 <ref id="strncmp" name="strncmp">,
6107 <ref id="strxfrm" name="strxfrm">
6113 <sect1>strlen<label id="strlen"><p>
6117 <tag/Function/Return the length of a string.
6118 <tag/Header/<tt/<ref id="string.h" name="string.h">/
6119 <tag/Declaration/<tt/size_t __fastcall__ strlen (const char* s);/
6120 <tag/Description/The <tt/strlen/ function computes the number of bytes in the
6121 string to which s points, not including the terminating null byte.
6122 <tag/Notes/<itemize>
6123 <item>The function is only available as fastcall function, so it may only
6124 be used in presence of a prototype.
6125 <item>When compiling with <tt/-Os/ (inline known standard functions), the
6126 function does not work correctly for strings with more than 255 characters.
6128 <tag/Availability/ISO 9899
6130 <ref id="strcpy" name="strcpy">
6136 <sect1>strlower<label id="strlower"><p>
6140 <tag/Function/Make a string lower case.
6141 <tag/Header/<tt/<ref id="string.h" name="string.h">/
6142 <tag/Declaration/<tt/char* __fastcall__ strlower (char* s);/
6143 <tag/Description/The <tt/strlower/ function will apply the <tt/tolower/
6144 function to each character of a string. The function will always return <tt/s/.
6145 <tag/Notes/<itemize>
6146 <item>The function is only available as fastcall function, so it may only
6147 be used in presence of a prototype.
6148 <item>The function prototype is unavailable when compiling in strict ANSI mode.
6149 <item>An alias name for this function is <tt/strlwr/.
6151 <tag/Availability/cc65
6153 <ref id="strupper" name="strupper">,
6154 <ref id="tolower" name="tolower">
6160 <sect1>strlwr<label id="strlwr"><p>
6167 <sect1>strncat<label id="strncat"><p>
6171 <tag/Function/Concatentate two strings.
6172 <tag/Header/<tt/<ref id="string.h" name="string.h">/
6173 <tag/Declaration/<tt/char* __fastcall__ strncat (char* s1, const char* s2, size_t n);/
6174 <tag/Description/The <tt/strncat/ function appends not more than n characters
6175 of the string pointed to by s2 to the end of the string pointed to by s1. The
6176 terminating null character at the end of s1 is overwritten. A terminating null
6177 character is appended to the result, even if not all of s2 is appended to s1.
6178 <tag/Notes/<itemize>
6179 <item>The function is only available as fastcall function, so it may only
6180 be used in presence of a prototype.
6181 <item>If copying takes place between objects that overlap, the behaviour
6184 <tag/Availability/ISO 9899
6186 <ref id="strcpy" name="strcpy">,
6187 <ref id="strncat" name="strncat">,
6188 <ref id="strncpy" name="strncpy">
6194 <sect1>strncmp<label id="strncmp"><p>
6198 <tag/Function/Compare two strings.
6199 <tag/Header/<tt/<ref id="string.h" name="string.h">/
6200 <tag/Declaration/<tt/int __fastcall__ strncmp (const char* s1, const char* s2, size_t count);/
6201 <tag/Description/The <tt/strncmp/ function compares not more than <tt/count/
6202 characters of the two strings passed as parameters. It returns a value that is
6203 less than zero if the first <tt/count/ characters of <tt/s1/ are less than
6204 <tt/s2/, zero if they are identical, and a value greater than zero they are
6206 <tag/Notes/<itemize>
6207 <item>The function is only available as fastcall function, so it may only
6208 be used in presence of a prototype.
6210 <tag/Availability/ISO 9899
6212 <ref id="strcasecmp" name="strcasecmp">,
6213 <ref id="strcmp" name="strcmp">,
6214 <ref id="strcoll" name="strcoll">,
6215 <ref id="stricmp" name="stricmp">,
6216 <ref id="strxfrm" name="strxfrm">
6222 <sect1>strncpy<label id="strncpy"><p>
6226 <tag/Function/Copy part of a string.
6227 <tag/Header/<tt/<ref id="string.h" name="string.h">/
6228 <tag/Declaration/<tt/char* __fastcall__ strncpy (char* s1, const char* s2, size_t n);/
6229 <tag/Description/The <tt/strncpy/ function copies not more than <tt/n/ bytes from
6230 the array pointed to by <tt/s2/ to the array pointed to by <tt/s1/. If the array
6231 pointed to by <tt/s2/ is a string that is shorter than <tt/n/ bytes, null bytes are
6232 appended to the copy in the array pointed to by <tt/s1/, until <tt/n/ bytes are
6233 written. The function always will return <tt/s1/.
6234 <tag/Notes/<itemize>
6235 <item>The function is available only as a fastcall function; so, it may be used
6236 only in the presence of a prototype.
6237 <item>If there is no null byte in the first <tt/n/ bytes of the array pointed
6238 to by <tt/s2/, the result is <em/not/ null-terminated!
6239 <item>If copying takes place between objects that overlap, the behaviour is
6242 <tag/Availability/ISO 9899
6244 <ref id="memcpy" name="memcpy">,
6245 <ref id="strcat" name="strcat">,
6246 <ref id="strcpy" name="strcpy">,
6247 <ref id="strncat" name="strncat">
6252 static char hello[6];
6254 strncpy (hello, "Hello world!\n", sizeof hello - 1)[5] = '\0';
6260 <sect1>strqtok<label id="strqtok"><p>
6264 <tag/Function/Break a string into tokens.
6265 <tag/Header/<tt/<ref id="string.h" name="string.h">/
6266 <tag/Declaration/<tt/char* __fastcall__ strqtok (char* s1, const char* s2);/
6267 <tag/Description/<tt/strqtok()/ will break the string <tt/s1/ into a sequence of
6268 tokens, which are delimited by either quotation marks or characters from the
6269 string <tt/s2/. Tokens inside quotation marks may contain characters from <tt/s2/
6270 (they aren't delimiters there). The first call to <tt/strqtok()/ will return a
6271 pointer to the first token in the string <tt/s1/. The following calls must pass
6272 a <tt/NULL/ pointer as <tt/s1/, in order to get the next token in the string.
6273 Different sets of delimiters may be used for the subsequent calls to <tt/strqtok()/.
6274 <tag/Notes/<itemize>
6275 <item>The function is available only as a fastcall function; so, it may be used
6276 only in the presence of a prototype.
6277 <item><tt/strqtok()/ will modify the string <tt/s1/.
6278 <item>The function will forget where it is in the <tt/s1/ string if it is given
6279 a second <tt/s1/ string before it finishes the first one.
6281 <tag/Availability/cc65
6283 <ref id="strcspn" name="strcspn">,
6284 <!-- <ref id="strpbrk" name="strpbrk">, -->
6285 <ref id="strspn" name="strspn">,
6286 <ref id="strtok" name="strtok">
6292 <sect1>strrchr<label id="strrchr"><p>
6296 <tag/Function/Search for a character in a string.
6297 <tag/Header/<tt/<ref id="string.h" name="string.h">/
6298 <tag/Declaration/<tt/char* __fastcall__ strrchr (const char* s, int c);/
6299 <tag/Description/The <tt/strrchr/ function locates the last occurrence of <tt/c/
6300 (converted to a char) in the string pointed to by <tt/s/. The terminating null
6301 byte is considered to be part of the string. Upon completion, the function
6302 returns a pointer to the byte, or a null pointer if the byte was not found.
6303 <tag/Notes/<itemize>
6304 <item>The function is only available as fastcall function, so it may only
6305 be used in presence of a prototype.
6307 <tag/Availability/ISO 9899
6309 <ref id="strchr" name="strchr">
6315 <sect1>strspn<label id="strspn"><p>
6319 <tag/Function/Compute the length of a substring.
6320 <tag/Header/<tt/<ref id="string.h" name="string.h">/
6321 <tag/Declaration/<tt/size_t __fastcall__ strspn (const char* s, const char* set);/
6322 <tag/Description/The <tt/strspn/ function computes and returns the length of
6323 the substring pointed to by <tt/s/ which does consist only of characters
6324 contained in the string <tt/set/.
6325 <tag/Notes/<itemize>
6326 <item>The function is only available as fastcall function, so it may only
6327 be used in presence of a prototype.
6329 <tag/Availability/ISO 9899
6331 <ref id="strcspn" name="strcspn">,
6332 <ref id="strstr" name="strstr">
6338 <sect1>strstr<label id="strstr"><p>
6342 <tag/Function/Find a substring.
6343 <tag/Header/<tt/<ref id="string.h" name="string.h">/
6344 <tag/Declaration/<tt/char* __fastcall__ strstr (const char* str, const char* substr);/
6345 <tag/Description/<tt/strstr/ searches for the first occurance of the string
6346 <tt/substr/ within <tt/str/. If found, it returns a pointer to the copy,
6347 otherwise it returns <tt/NULL/.
6348 <tag/Notes/<itemize>
6349 <item>The function is only available as fastcall function, so it may only
6350 be used in presence of a prototype.
6352 <tag/Availability/ISO 9899
6354 <ref id="strcspn" name="strcspn">,
6355 <ref id="strspn" name="strspn">
6361 <sect1>strtok<label id="strtok"><p>
6365 <tag/Function/Break a string into tokens.
6366 <tag/Header/<tt/<ref id="string.h" name="string.h">/
6367 <tag/Declaration/<tt/char* __fastcall__ strtok (char* s1, const char* s2);/
6368 <tag/Description/<tt/strtok()/ will break the string <tt/s1/ into a sequence of
6369 tokens, which are delimited by characters from the string <tt/s2/. The first call
6370 to <tt/strtok()/ will return a pointer to the first token in the string <tt/s1/.
6371 The following calls must pass a <tt/NULL/ pointer as <tt/s1/, in order to get
6372 the next token in the string. Different sets of delimiters may be used for the
6373 subsequent calls to <tt/strtok()/.
6374 <tag/Notes/<itemize>
6375 <item>The function is only available as fastcall function, so it may only
6376 be used in presence of a prototype.
6377 <item><tt/strtok()/ will modify the string <tt/s1/.
6378 <item>The function will forget where it is in the <tt/s1/ string if it is given
6379 a second <tt/s1/ string before it finishes the first one.
6381 <tag/Availability/ISO 9899
6383 <ref id="strcspn" name="strcspn">,
6384 <!-- <ref id="strpbrk" name="strpbrk">, -->
6385 <ref id="strqtok" name="strqtok">,
6386 <ref id="strspn" name="strspn">
6392 <sect1>strxfrm<label id="strxfrm"><p>
6396 <tag/Function/Transform a string.
6397 <tag/Header/<tt/<ref id="string.h" name="string.h">/
6398 <tag/Declaration/<tt/size_t __fastcall__ strxfrm (char* s1, const char* s2, size_t n);/
6399 <tag/Description/The <tt/strxfrm/ function transforms the string pointed to by
6400 s2 and places the resulting string into the string pointed to by s1. The
6401 transformation is such that if the <tt/strcmp/ function is applied to two
6402 transformed strings, it returns a value greater than, equal to, or less than
6403 zero, corresponding to the result of the <tt/strcoll/ function applied to the
6404 same two original strings. No more than n characters are placed into the
6405 resulting array pointed to by s1, including the terminating null character.
6406 <tag/Notes/<itemize>
6407 <item><tt/s1/ and <tt/s2/ must not point to the same memory area, otherwise
6408 the behaviour is undefined.
6409 <item>If <tt/n/ is zero, <tt/s1/ may be a NULL pointer.
6410 <item>The function is only available as fastcall function, so it may only
6411 be used in presence of a prototype.
6412 <item>Since cc65 doesn't support different charcter sets, <tt/strxfrm/ will
6413 just copy s2 to s1 using <tt><ref id="strncpy" name="strncpy"></tt>.
6415 <tag/Availability/ISO 9899
6417 <ref id="strcmp" name="strcmp">,
6418 <ref id="strcoll" name="strcoll">,
6419 <ref id="strncpy" name="strncpy">
6425 <sect1>strupper<label id="strupper"><p>
6429 <tag/Function/Make a string upper case.
6430 <tag/Header/<tt/<ref id="string.h" name="string.h">/
6431 <tag/Declaration/<tt/char* __fastcall__ strupper (char* s);/
6432 <tag/Description/The <tt/strupper/ function will apply the <tt/toupper/
6433 function to each character of a string. The function will always return <tt/s/.
6434 <tag/Notes/<itemize>
6435 <item>The function is only available as fastcall function, so it may only
6436 be used in presence of a prototype.
6437 <item>The function prototype is unavailable when compiling in strict ANSI mode.
6438 <item>An alias name for this function is <tt/strupr/.
6440 <tag/Availability/cc65
6442 <ref id="strlower" name="strlower">
6443 <ref id="toupper" name="toupper">
6449 <sect1>strupr<label id="strupr"><p>
6456 <sect1>telldir<label id="telldir"><p>
6460 <tag/Function/Return the current position of a directory stream.
6461 <tag/Header/<tt/<ref id="dirent.h" name="dirent.h">/
6462 <tag/Declaration/<tt/long __fastcall__ telldir (DIR* dir);/
6463 <tag/Description/<tt/telldir/ returns the current position of a directory
6464 stream. The return value may be used in subsequent calls to
6465 <tt/<ref id="seekdir" name="seekdir">/.
6466 <tag/Notes/<itemize>
6467 <item>The function is only available as fastcall function, so it may only
6468 be used in presence of a prototype.
6470 <tag/Availability/POSIX 1003.1
6472 <ref id="seekdir" name="seekdir">,
6473 <ref id="telldir" name="telldir">
6479 <sect1>textcolor<label id="textcolor"><p>
6483 <tag/Function/Set the text color.
6484 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
6485 <tag/Declaration/<tt/unsigned char __fastcall__ textcolor (unsigned char color);/
6486 <tag/Description/The function will set a new text color. It returns the old
6487 (current) text color. Text output using any <tt/conio.h/ function will use
6488 the color set by this function.
6489 <tag/Notes/<itemize>
6490 <item>Text colors are system dependent. The function may have no effect
6491 on systems where the text color cannot be changed.
6492 <item>The function is only available as fastcall function, so it may only
6493 be used in presence of a prototype.
6495 <tag/Availability/cc65
6497 <ref id="bgcolor" name="bgcolor">,
6498 <ref id="bordercolor" name="bordercolor">
6504 <sect1>time<label id="time"><p>
6508 <tag/Function/Get the time.
6509 <tag/Header/<tt/<ref id="time.h" name="time.h">/
6510 <tag/Declaration/<tt/time_t __fastcall__ time (time_t* t);/
6511 <tag/Description/The function returns the time since the 1970-01-01 00:00:00
6512 measured in seconds. If the pointer <tt/t/ is not <tt/NULL/, the function
6513 result will also be stored there. If no time is available, <tt/(time_t)-1/ is
6514 returned and <tt/errno/ is set to <tt/ENOSYS/.
6515 <tag/Notes/<itemize>
6516 <item>The function is only available as fastcall function, so it may
6517 only be used in presence of a prototype.
6518 <item>Many platforms supported by cc65 do not have a realtime clock, so the
6519 returned value may not be valid.
6521 <tag/Availability/ISO 9899
6523 <ref id="clock" name="clock">
6529 <sect1>toggle_videomode<label id="toggle_videomode"><p>
6533 <tag/Function/Toggle between 40 and 80 column mode.
6534 <tag/Header/<tt/<ref id="c128.h" name="c128.h">/
6535 <tag/Declaration/<tt/void toggle_videomode (void);/
6536 <tag/Description/Toggle between 40 and 80 column mode. The settings for the
6537 old mode (cursor position, color and so on) are saved and restored together
6539 <tag/Notes/<itemize>
6540 <item>The function is specific to the C128.
6541 <item>This function is deprecated. Please use <ref id="videomode"
6542 name="videomode"> instead!
6544 <tag/Availability/C128
6546 <ref id="fast" name="fast">,
6547 <ref id="slow" name="slow">,
6548 <ref id="videomode" name="videomode">
6554 <sect1>tolower<label id="tolower"><p>
6558 <tag/Function/Convert a character into its lower case representation.
6559 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
6560 <tag/Declaration/<tt/int __fastcall__ tolower (int c);/
6561 <tag/Description/The function returns the given character converted to lower
6562 case. If the given character is not a letter, it is returned unchanged.
6563 <tag/Notes/<itemize>
6564 <item>The function is only available as fastcall function, so it may
6565 only be used in presence of a prototype.
6567 <tag/Availability/ISO 9899
6569 <ref id="islower" name="islower">,
6570 <ref id="isupper" name="isupper">,
6571 <ref id="toupper" name="toupper">
6577 <sect1>toupper<label id="toupper"><p>
6581 <tag/Function/Convert a character into its upper case representation.
6582 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
6583 <tag/Declaration/<tt/int __fastcall__ toupper (int c);/
6584 <tag/Description/The function returns the given character converted to upper
6585 case. If the given character is not a letter, it is returned unchanged.
6586 <tag/Notes/<itemize>
6587 <item>The function is only available as fastcall function, so it may
6588 only be used in presence of a prototype.
6590 <tag/Availability/ISO 9899
6592 <ref id="islower" name="islower">,
6593 <ref id="isupper" name="isupper">,
6594 <ref id="tolower" name="tolower">
6600 <sect1>ultoa<label id="ultoa"><p>
6604 <tag/Function/Convert an unsigned long integer into a string.
6605 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
6606 <tag/Declaration/<tt/char* __fastcall__ ultoa (unsigned long val, char* buf, int radix);/
6607 <tag/Description/<tt/itoa/ converts the unsigned long integer <tt/val/ into a
6608 string using <tt/radix/ as the base.
6609 <tag/Notes/<itemize>
6610 <item>There are no provisions to prevent a buffer overflow.
6611 <item>The function is non standard, so it is not available in strict ANSI mode.
6612 You should probably use <tt/sprintf/ instead.
6613 <item>The function is only available as fastcall function, so it may only be
6614 used in presence of a prototype.
6616 <tag/Availability/cc65
6618 <ref id="atoi" name="atoi">,
6619 <ref id="atol" name="atol">,
6620 <ref id="itoa" name="itoa">,
6621 <ref id="ltoa" name="ltoa">,
6622 <ref id="utoa" name="utoa">
6628 <sect1>unlink<label id="unlink"><p>
6632 <tag/Function/Delete a file.
6633 <tag/Header/<tt/<ref id="unistd.h" name="unistd.h">/
6634 <tag/Declaration/<tt/int __fastcall__ unlink (const char* name);/
6635 <tag/Description/<tt/unlink/ deletes the file with the given name. On success,
6636 zero is returned. On error, -1 is returned and <tt/errno/ is set to an error
6637 code describing the reason for the failure.
6638 <tag/Notes/<itemize>
6639 <item>The use of this function is discouraged. Please use <tt/<ref id="remove"
6640 name="remove">/ instead, which is a native ANSI C function and does the same.
6641 <item>This function is not available on all cc65 targets (depends on the
6642 availability of file I/O).
6643 <item>The function is only available as fastcall function, so it may only
6644 be used in presence of a prototype.
6645 <item>Instead of <tt/unlink/, <tt/<ref id="remove" name="remove">/ should be
6646 used, which has the same semantics, but is more portable, because it conforms
6647 to the ISO C standard.
6649 <tag/Availability/POSIX 1003.1
6651 <ref id="remove" name="remove">
6654 #include <stdio.h>
6655 #include <unistd.h>
6657 #define FILENAME "helloworld"
6659 if (unlink (FILENAME) == 0) {
6660 printf ("We deleted %s successfully\n", FILENAME);
6662 printf ("There was a problem deleting %s\n", FILENAME);
6669 <sect1>utoa<label id="utoa"><p>
6673 <tag/Function/Convert an unsigned integer into a string.
6674 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
6675 <tag/Declaration/<tt/char* __fastcall__ utoa (unsigned val, char* buf, int radix);/
6676 <tag/Description/<tt/itoa/ converts the unsigned integer <tt/val/ into a string
6677 using <tt/radix/ as the base.
6678 <tag/Notes/<itemize>
6679 <item>There are no provisions to prevent a buffer overflow.
6680 <item>The function is non standard, so it is not available in strict ANSI mode.
6681 You should probably use <tt/sprintf/ instead.
6682 <item>The function is only available as fastcall function, so it may only be
6683 used in presence of a prototype.
6685 <tag/Availability/cc65
6687 <ref id="atoi" name="atoi">,
6688 <ref id="atol" name="atol">,
6689 <ref id="itoa" name="itoa">,
6690 <ref id="ltoa" name="ltoa">,
6691 <ref id="ultoa" name="ultoa">
6697 <sect1>vcprintf<label id="vcprintf"><p>
6701 <tag/Function/Formatted output to the console.
6702 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
6703 <tag/Declaration/<tt/int __fastcall__ vcprintf (const char* format, va_list ap);/
6704 <tag/Description/The arguments specified as a <tt/va_list/ are converted to
6705 text where necessary and formatted according to the format string given. The
6706 resulting string is output to the console. <tt/vcprintf/ supports the same
6707 format specifiers as <tt/vprintf/. <!-- <tt/<ref id="vprintf" name="vprintf">/. -->
6708 <tag/Notes/<itemize>
6709 <item>Like all other <tt/conio/ output functions, <tt/vcprintf/ distinguishes
6710 between <tt/\r/ and <tt/\n/.
6711 <item>The function is only available as fastcall function, so it may only be
6712 used in presence of a prototype.
6714 <tag/Availability/cc65
6716 <ref id="cprintf" name="cprintf">,
6717 <ref id="cputc" name="cputc">,
6718 <ref id="cputcxy" name="cputcxy">,
6719 <ref id="cputs" name="cputs">,
6720 <ref id="cputsxy" name="cputsxy">
6726 <sect1>videomode<label id="videomode"><p>
6730 <tag/Function/Switch to either 40 or 80 column mode.
6731 <tag/Header/<tt/<ref id="apple2enh.h" name="apple2enh.h">,
6732 <ref id="c128.h" name="c128.h">/
6733 <tag/Declaration/<tt/unsigned __fastcall__ videomode (unsigned Mode);/
6734 <tag/Description/Switch to 40 or 80 column mode depending on the argument. If
6735 the requested mode is already active, nothing happens. The old mode is returned
6737 <tag/Notes/<itemize>
6738 <item>The function is specific to the C128 and enhanced Apple //e.
6739 <item>This function replaces <ref id="toggle_videomode"
6740 name="toggle_videomode">.
6741 <item>The function is only available as fastcall function, so it may only be
6742 used in presence of a prototype.
6744 <tag/Availability/C128 and enhanced Apple //e
6746 <ref id="fast" name="fast">,
6747 <ref id="slow" name="slow">,
6748 <ref id="toggle_videomode" name="toggle_videomode">
6754 <sect1>waitvsync<label id="waitvsync"><p>
6758 <tag/Function/Wait until the start of the next frame.
6760 <tt/<ref id="gamate.h" name="gamate.h">/,
6761 <tt/<ref id="nes.h" name="nes.h">/,
6762 <tt/<ref id="pce.h" name="pce.h">/
6763 <tag/Declaration/<tt/void waitvsync (void);/
6764 <tag/Description/Wait for vertical sync to reduce flickering.
6765 <tag/Availability/Platforms above
6771 <sect1>wherex<label id="wherex"><p>
6775 <tag/Function/Return the current X position of the text mode cursor.
6776 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
6777 <tag/Declaration/<tt/unsigned char wherex (void);/
6778 <tag/Description/The function returns the current X position of the text mode
6779 cursor. Zero is returned for the leftmost screen position.
6780 <tag/Availability/cc65
6782 <ref id="gotox" name="gotox">,
6783 <ref id="gotoy" name="gotoy">,
6784 <ref id="gotoxy" name="gotoxy">,
6785 <ref id="wherey" name="wherey">
6791 <sect1>wherey<label id="wherey"><p>
6795 <tag/Function/Return the current Y position of the text mode cursor.
6796 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
6797 <tag/Declaration/<tt/unsigned char wherey (void);/
6798 <tag/Description/The function returns the current Y position of the text mode
6799 cursor. Zero is returned for the uppermost screen position.
6800 <tag/Availability/cc65
6802 <ref id="gotox" name="gotox">,
6803 <ref id="gotoy" name="gotoy">,
6804 <ref id="gotoxy" name="gotoxy">,
6805 <ref id="wherex" name="wherex">