1 <!doctype linuxdoc system>
4 <title>cc65 function reference
5 <author>Ullrich von Bassewitz, <htmlurl url="mailto:uz@cc65.org" name="uz@cc65.org">
9 cc65 is a C compiler for 6502 based systems. This function reference describes
10 the C functions available in the standard library.
13 <!-- Table of contents -->
16 <!-- Begin the document -->
20 cc65 is a C compiler for 6502 based systems. It implements a subset of the ISO
21 C standard plus additional functions specially crafted for 6502 systems or
22 just some of the supported machines. This function refrence describes the
23 available functions together with any limitations.
25 For an overview about the available libraries, their purpose, and any
26 differences to the ISO standard, please have a look at the <htmlurl
27 url="library.html" name="cc65 Library Overview">.
29 <bf/Note:/ Standard C functions are listed here, but not described in detail.
30 Since these functions behave identical on all standard compliant systems, they
31 are described in any book covering standard C.
33 Each entry for a function contains a detailed description
37 <tag/Function/Summary of what <bf/function/ does.
38 <tag/Header/The header file that contains the declaration.
39 <tag/Declaration/Describes the needed header files and declaration of the
41 <tag/Description/Description of the function.
43 <tag/Availability/The availability of the function.
44 <tag/See also/Other related functions.
45 <tag/Example/A piece of actual code using the function.
50 <sect>Functions by header file<p>
52 <sect1><tt/6502.h/<label id="6502.h"><p>
55 <item><ref id="BRK" name="BRK">
56 <item><ref id="CLI" name="CLI">
57 <item><ref id="SEI" name="SEI">
58 <item><ref id="_sys" name="_sys">
59 <item><ref id="getcpu" name="getcpu">
60 <item><ref id="reset_brk" name="reset_brk">
61 <item><ref id="set_brk" name="set_brk">
65 <sect1><tt/apple2.h/<label id="apple2.h"><p>
68 <item><ref id="get_ostype" name="get_ostype">
72 <sect1><tt/apple2enh.h/<label id="apple2enh.h"><p>
77 <sect1><tt/assert.h/<label id="assert.h"><p>
80 <item><ref id="assert" name="assert">
84 <sect1><tt/atari.h/<label id="atari.h"><p>
87 <item><ref id="get_ostype" name="get_ostype">
93 <sect1><tt/atmos.h/<label id="atmos.h"><p>
98 <sect1><tt/c128.h/<label id="c128.h"><p>
101 <item><ref id="c64mode" name="c64mode">
102 <item><ref id="fast" name="fast">
103 <item><ref id="toggle_videomode" name="toggle_videomode">
104 <item><ref id="slow" name="slow">
108 <sect1><tt/c16.h/<label id="c16.h"><p>
113 <sect1><tt/c64.h/<label id="c64.h"><p>
116 <item><ref id="get_ostype" name="get_ostype">
120 <sect1><tt/cbm510.h/<label id="cbm510.h"><p>
123 <item><ref id="peekbsys" name="peekbsys">
124 <item><ref id="peekwsys" name="peekwsys">
125 <item><ref id="pokebsys" name="pokebsys">
126 <item><ref id="pokewsys" name="pokewsys">
130 <sect1><tt/cbm610.h/<label id="cbm610.h"><p>
133 <item><ref id="peekbsys" name="peekbsys">
134 <item><ref id="peekwsys" name="peekwsys">
135 <item><ref id="pokebsys" name="pokebsys">
136 <item><ref id="pokewsys" name="pokewsys">
140 <sect1><tt/conio.h/<label id="conio.h"><p>
143 <item><ref id="bgcolor" name="bgcolor">
144 <item><ref id="bordercolor" name="bordercolor">
145 <item><ref id="cclear" name="cclear">
146 <item><ref id="cclearxy" name="cclearxy">
147 <item><ref id="cgetc" name="cgetc">
148 <item><ref id="chline" name="chline">
149 <item><ref id="chlinexy" name="chlinexy">
150 <item><ref id="clrscr" name="clrscr">
151 <item><ref id="cprintf" name="cprintf">
152 <item><ref id="cputc" name="cputc">
153 <item><ref id="cputcxy" name="cputcxy">
154 <item><ref id="cputs" name="cputs">
155 <item><ref id="cputsxy" name="cputsxy">
156 <item><ref id="cursor" name="cursor">
157 <item><ref id="cvline" name="cvline">
158 <item><ref id="cvlinexy" name="cvlinexy">
159 <item><ref id="gotox" name="gotox">
160 <item><ref id="gotoxy" name="gotoxy">
161 <item><ref id="gotoy" name="gotoy">
162 <item><ref id="kbhit" name="kbhit">
163 <item><ref id="revers" name="revers">
164 <item><ref id="screensize" name="screensize">
165 <item><ref id="textcolor" name="textcolor">
166 <item><ref id="vcprintf" name="vcprintf">
167 <item><ref id="wherex" name="wherex">
168 <item><ref id="wherey" name="wherey">
172 <sect1><tt/ctype.h/<label id="ctype.h"><p>
175 <item><ref id="isalnum" name="isalnum">
176 <item><ref id="isalpha" name="isalpha">
177 <item><ref id="isascii" name="isascii">
178 <item><ref id="isblank" name="isblank">
179 <item><ref id="iscntrl" name="iscntrl">
180 <item><ref id="isdigit" name="isdigit">
181 <item><ref id="isgraph" name="isgraph">
182 <item><ref id="islower" name="islower">
183 <item><ref id="isprint" name="isprint">
184 <item><ref id="ispunct" name="ispunct">
185 <item><ref id="isspace" name="isspace">
186 <item><ref id="isupper" name="isupper">
187 <item><ref id="isxdigit" name="isxdigit">
188 <item><ref id="tolower" name="tolower">
189 <item><ref id="toupper" name="toupper">
193 <sect1><tt/dbg.h/<label id="dbg.h"><p>
198 <sect1><tt/dio.h/<label id="dio.h"><p>
203 <sect1><tt/em.h/<label id="em.h"><p>
206 <item><ref id="em_commit" name="em_commit">
207 <item><ref id="em_copyfrom" name="em_copyfrom">
208 <item><ref id="em_copyto" name="em_copyto">
209 <item><ref id="em_install" name="em_install">
210 <item><ref id="em_load_driver" name="em_load_driver">
211 <item><ref id="em_map" name="em_map">
212 <item><ref id="em_pagecount" name="em_pagecount">
213 <item><ref id="em_uninstall" name="em_uninstall">
214 <item><ref id="em_unload" name="em_unload">
215 <item><ref id="em_use" name="em_use">
219 <sect1><tt/errno.h/<label id="errno.h"><p>
224 <sect1><tt/fcntl.h/<label id="fcntl.h"><p>
227 <item><ref id="close" name="close">
228 <item><ref id="creat" name="creat">
229 <item><ref id="open" name="open">
233 <sect1><tt/geos.h/<label id="geos.h"><p>
238 <sect1><tt/joystick.h/<label id="joystick.h"><p>
241 <item><ref id="joy_count" name="joy_count">
242 <item><ref id="joy_install" name="joy_install">
243 <item><ref id="joy_load_driver" name="joy_load_driver">
244 <item><ref id="joy_read" name="joy_read">
245 <item><ref id="joy_uninstall" name="joy_uninstall">
246 <item><ref id="joy_unload" name="joy_unload">
250 <sect1><tt/locale.h/<label id="locale.h"><p>
253 <item><ref id="localeconv" name="localeconv">
254 <item><ref id="setlocale" name="setlocale">
258 <sect1><tt/modload.h/<label id="modload.h"><p>
261 <item><ref id="mod_load" name="mod_load">
262 <item><ref id="mod_free" name="mod_free">
266 <sect1><tt/mouse.h/<label id="mouse.h"><p>
269 <item><ref id="mouse_load_driver" name="mouse_load_driver">
270 <item><ref id="mouse_unload" name="mouse_unload">
271 <item><ref id="mouse_install" name="mouse_install">
272 <item><ref id="mouse_uninstall" name="mouse_uninstall">
273 <item><ref id="mouse_hide" name="mouse_hide">
274 <item><ref id="mouse_show" name="mouse_show">
275 <item><ref id="mouse_box" name="mouse_box">
276 <item><ref id="mouse_move" name="mouse_move">
277 <item><ref id="mouse_buttons" name="mouse_buttons">
278 <item><ref id="mouse_pos" name="mouse_pos">
279 <item><ref id="mouse_info" name="mouse_info">
280 <item><ref id="mouse_ioctl" name="mouse_ioctl">
286 <sect1><tt/nes.h/<label id="nes.h"><p>
291 <sect1><tt/o65.h/<label id="o65.h"><p>
293 The <tt/o65.h/ header file contains structure and constant definitions that
294 may be used when dealing with files in <htmlurl
295 url="http://www.6502.org/users/andre/o65/fileformat.html" name="o65 format">.
296 It does not declare any functions.
299 <sect1><tt/peekpoke.h/<label id="peekpoke.h"><p>
302 <item><ref id="PEEK" name="PEEK">
303 <item><ref id="PEEKW" name="PEEKW">
304 <item><ref id="POKE" name="POKE">
305 <item><ref id="POKEW" name="POKEW">
309 <sect1><tt/pet.h/<label id="pet.h"><p>
314 <sect1><tt/plus4.h/<label id="plus4.h"><p>
319 <sect1><tt/serial.h/<label id="serial.h"><p>
323 <item><ref id="ser_load_driver" name="ser_load_driver">
324 <item><ref id="ser_unload" name="ser_unload">
325 <item><ref id="ser_install" name="ser_install">
326 <item><ref id="ser_uninstall" name="ser_uninstall">
327 <item><ref id="ser_open" name="ser_open">
328 <item><ref id="ser_close" name="ser_close">
329 <item><ref id="ser_get" name="ser_get">
330 <item><ref id="ser_put" name="ser_put">
331 <item><ref id="ser_status" name="ser_status">
332 <item><ref id="ser_ioctl" name="ser_ioctl">
339 <sect1><tt/setjmp.h/<label id="setjmp.h"><p>
342 <item><ref id="setjmp" name="setjmp">
343 <item><ref id="longjmp" name="longjmp">
347 <sect1><tt/signal.h/<label id="signal.h"><p>
350 <item><ref id="raise" name="raise">
351 <item><ref id="signal" name="signal">
355 <sect1><tt/stdarg.h/<label id="stdarg.h"><p>
360 <sect1><tt/stdbool.h/<label id="stdbool.h"><p>
365 <sect1><tt/stddef.h/<label id="stddef.h"><p>
368 <item><ref id="offsetof" name="offsetof">
372 <sect1><tt/stdio.h/<label id="stdio.h"><p>
375 <item><ref id="clearerr" name="clearerr">
376 <!-- <item><ref id="fclose" name="fclose"> -->
377 <!-- <item><ref id="fdopen" name="fdopen"> -->
378 <item><ref id="feof" name="feof">
379 <item><ref id="ferror" name="ferror">
380 <!-- <item><ref id="fflush" name="fflush"> -->
381 <!-- <item><ref id="fgetc" name="fgetc"> -->
382 <!-- <item><ref id="fgetpos" name="fgetpos"> -->
383 <!-- <item><ref id="fgets" name="fgets"> -->
384 <item><ref id="fileno" name="fileno">
385 <!-- <item><ref id="flushall" name="flushall"> -->
386 <!-- <item><ref id="fopen" name="fopen"> -->
387 <!-- <item><ref id="fprintf" name="fprintf"> -->
388 <!-- <item><ref id="fputc" name="fputc"> -->
389 <!-- <item><ref id="fputs" name="fputs"> -->
390 <!-- <item><ref id="fread" name="fread"> -->
391 <!-- <item><ref id="freopen" name="freopen"> -->
392 <!-- <item><ref id="fscanf" name="fscanf"> -->
393 <!-- <item><ref id="fseek" name="fseek"> -->
394 <!-- <item><ref id="fsetpos" name="fsetpos"> -->
395 <!-- <item><ref id="ftell" name="ftell"> -->
396 <!-- <item><ref id="fwrite" name="fwrite"> -->
397 <!-- <item><ref id="getc" name="getc"> -->
398 <!-- <item><ref id="getchar" name="getchar"> -->
399 <!-- <item><ref id="gets" name="gets"> -->
400 <!-- <item><ref id="printf" name="printf"> -->
401 <!-- <item><ref id="putc" name="putc"> -->
402 <!-- <item><ref id="putchar" name="putchar"> -->
403 <!-- <item><ref id="puts" name="puts"> -->
404 <!-- <item><ref id="rename" name="rename"> -->
405 <!-- <item><ref id="rewind" name="rewind"> -->
406 <!-- <item><ref id="scanf" name="scanf"> -->
407 <!-- <item><ref id="sprintf" name="sprintf"> -->
408 <!-- <item><ref id="sscanf" name="sscanf"> -->
409 <!-- <item><ref id="vfprintf" name="vfprintf"> -->
410 <!-- <item><ref id="vfscanf" name="vfscanf"> -->
411 <!-- <item><ref id="vprintf" name="vprintf"> -->
412 <!-- <item><ref id="vscanf" name="vscanf"> -->
413 <!-- <item><ref id="vsprintf" name="vsprintf"> -->
414 <!-- <item><ref id="vsscanf" name="vsscanf"> -->
420 <sect1><tt/stdlib.h/<label id="stdlib.h"><p>
423 <item><ref id="_heapadd" name="_heapadd">
424 <item><ref id="_heapblocksize" name="_heapblocksize">
425 <item><ref id="_heapmaxavail" name="_heapmaxavail">
426 <item><ref id="_heapmemavail" name="_heapmemavail">
427 <item><ref id="_poserror" name="_poserror">
428 <item><ref id="_randomize" name="_randomize">
429 <item><ref id="_swap" name="_swap">
430 <item><ref id="abort" name="abort">
431 <item><ref id="abs" name="abs">
432 <item><ref id="atexit" name="atexit">
433 <item><ref id="atoi" name="atoi">
434 <item><ref id="atol" name="atol">
435 <item><ref id="bsearch" name="bsearch">
436 <item><ref id="calloc" name="calloc">
437 <item><ref id="div" name="div">
438 <item><ref id="exit" name="exit">
439 <item><ref id="free" name="free">
440 <item><ref id="getenv" name="getenv">
441 <item><ref id="itoa" name="itoa">
442 <item><ref id="labs" name="labs">
443 <item><ref id="ltoa" name="ltoa">
444 <item><ref id="malloc" name="malloc">
445 <item><ref id="perror" name="perror">
446 <item><ref id="qsort" name="qsort">
447 <item><ref id="rand" name="rand">
448 <item><ref id="realloc" name="realloc">
449 <item><ref id="remove" name="remove">
450 <item><ref id="srand" name="srand">
451 <item><ref id="ultoa" name="ultoa">
452 <item><ref id="utoa" name="utoa">
456 <sect1><tt/string.h/<label id="string.h"><p>
459 <item><ref id="_stroserror" name="_stroserror">
460 <item><ref id="bzero" name="bzero">
461 <item><ref id="memchr" name="memchr">
462 <item><ref id="memcpy" name="memcpy">
463 <item><ref id="memmove" name="memmove">
464 <item><ref id="memset" name="memset">
465 <item><ref id="strcasecmp" name="strcasecmp">
466 <item><ref id="strcat" name="strcat">
467 <item><ref id="strchr" name="strchr">
468 <item><ref id="strcmp" name="strcmp">
469 <item><ref id="strcoll" name="strcoll">
470 <item><ref id="strcpy" name="strcpy">
471 <item><ref id="strcspn" name="strcspn">
472 <item><ref id="strdup" name="strdup">
473 <item><ref id="strerror" name="strerror">
474 <item><ref id="stricmp" name="stricmp">
475 <item><ref id="strlen" name="strlen">
476 <item><ref id="strlower" name="strlower">
477 <item><ref id="strlwr" name="strlwr">
478 <item><ref id="strncat" name="strncat">
479 <item><ref id="strncmp" name="strncmp">
480 <item><ref id="strncpy" name="strncpy">
481 <item><ref id="strrchr" name="strrchr">
482 <item><ref id="strspn" name="strspn">
483 <item><ref id="strstr" name="strstr">
484 <item><ref id="strtok" name="strtok">
485 <!-- <item><ref id="strxfrm" name="strxfrm"> -->
486 <item><ref id="strupper" name="strupper">
487 <item><ref id="strupr" name="strupr">
493 <sect1><tt/tgi.h/<label id="tgi.h"><p>
498 <sect1><tt/time.h/<label id="time.h"><p>
501 <!-- <item><ref id="_systime" name="_systime"> -->
502 <!-- <item><ref id="asctime" name="asctime"> -->
503 <!-- <item><ref id="clock" name="clock"> -->
504 <!-- <item><ref id="ctime" name="ctime"> -->
505 <!-- <item><ref id="gmtime" name="gmtime"> -->
506 <!-- <item><ref id="localtime" name="localtime"> -->
507 <!-- <item><ref id="mktime" name="mktime"> -->
508 <!-- <item><ref id="strftime" name="strftime"> -->
509 <item><ref id="time" name="time">
515 <sect1><tt/unistd.h/<label id="unistd.h"><p>
518 <!-- <item><ref id="chdir" name="chdir"> -->
519 <!-- <item><ref id="getcwd" name="getcwd"> -->
520 <!-- <item><ref id="lseek" name="lseek"> -->
521 <!-- <item><ref id="mkdir" name="mkdir"> -->
522 <!-- <item><ref id="read" name="read"> -->
523 <!-- <item><ref id="rmdir" name="rmdir"> -->
524 <item><ref id="sleep" name="sleep">
525 <item><ref id="unlink" name="unlink">
526 <!-- <item><ref id="write" name="write"> -->
532 <sect1><tt/vic20.h/<label id="vic20.h"><p>
537 <sect1><tt/zlib.h/<label id="zlib.h"><p>
542 <sect>Alphabetical function reference<p>
544 <sect1>_heapadd<label id="_heapadd"><p>
548 <tag/Function/Add a block to the heap.
549 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
550 <tag/Declaration/<tt/void __fastcall__ _heapadd (void* mem, size_t size);/
551 <tag/Description/The function adds a block of raw memory to the heap.
554 <item>The minimum blocksize that can be added is 6 bytes; the function will
555 ignore smaller blocks.
557 <tag/Availability/cc65
559 <ref id="_heapblocksize" name="_heapblocksize">,
560 <ref id="_heapmaxavail" name="_heapmaxavail">,
561 <ref id="_heapmemavail" name="_heapmemavail">,
562 <ref id="calloc" name="calloc">,
563 <ref id="free" name="free">,
564 <ref id="malloc" name="malloc">,
565 <ref id="realloc" name="realloc">
571 <sect1>_heapblocksize<label id="_heapblocksize"><p>
575 <tag/Function/Return the size of an allocated block.
576 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
577 <tag/Declaration/<tt/size_t __fastcall__ _heapblocksize (const void* block);/
578 <tag/Description/The function returns the size of a block that must have
579 previously been allocated by <tt/<ref id="malloc" name="malloc">/, <tt/<ref
580 id="calloc" name="calloc">/ or <tt/<ref id="realloc" name="realloc">/.
583 <item>Passing a pointer to a block that was is not the result of one of the
584 allocation functions, or that has been free'd will give unpredicable results.
586 <tag/Availability/cc65
588 <ref id="_heapadd" name="_heapadd">,
589 <ref id="_heapmaxavail" name="_heapmaxavail">,
590 <ref id="_heapmemavail" name="_heapmemavail">,
591 <ref id="calloc" name="calloc">,
592 <ref id="free" name="free">,
593 <ref id="malloc" name="malloc">,
594 <ref id="realloc" name="realloc">
600 <sect1>_heapmaxavail<label id="_heapmaxavail"><p>
604 <tag/Function/Return the largest block that is available on the heap.
605 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
606 <tag/Declaration/<tt/size_t __fastcall__ _heapmaxavail (void);/
607 <tag/Description/The function returns the size of the largest block that may
608 be allocated from the heap using <tt/<ref id="malloc" name="malloc">/.
609 <tag/Availability/cc65
611 <ref id="_heapadd" name="_heapadd">,
612 <ref id="_heapblocksize" name="_heapblocksize">,
613 <ref id="_heapmemavail" name="_heapmemavail">,
614 <ref id="calloc" name="calloc">,
615 <ref id="free" name="free">,
616 <ref id="malloc" name="malloc">,
617 <ref id="realloc" name="realloc">
623 <sect1>_heapmemavail<label id="_heapmemavail"><p>
627 <tag/Function/Return the total available space on the heap.
628 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
629 <tag/Declaration/<tt/size_t __fastcall__ _heapmemavail (void);/
630 <tag/Description/The function returns the total number of bytes available on
634 <item>This function is of less use than usually assumed, since the returned
635 heap space may be available but not in one block. So even if this function
636 says that several times more heap space is available than needed, <ref
637 id="malloc" name="malloc"> may still return <tt/NULL/.
639 <tag/Availability/cc65
641 <ref id="_heapadd" name="_heapadd">,
642 <ref id="_heapblocksize" name="_heapblocksize">,
643 <ref id="_heapmaxavail" name="_heapmaxavail">,
644 <ref id="calloc" name="calloc">,
645 <ref id="free" name="free">,
646 <ref id="malloc" name="malloc">,
647 <ref id="realloc" name="realloc">
653 <sect1>_poserror<label id="_poserror"><p>
657 <tag/Function/Print an error message for the error in <tt/_oserrno/.
658 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
659 <tag/Declaration/<tt/void __fastcall__ _poserror (const char* msg);/
660 <tag/Description/<tt/_poserror/ prints an error message to <tt/stderr/. If
661 <tt/msg/ is not <tt/NULL/ and not an empty string, it is printed followed by
662 a colon and a blank. Then the error message for the current contents of
663 <tt/_oserrno/ are printed followed by a newline. The message output is the
664 same as returned by <tt/<ref id="_stroserror" name="_stroserror">/ with an
665 argument of <tt/_oserrno/.
668 <item>Since operating system specific error code are - you guessed it -
669 operating system specific, the value in <tt/_oserror/ and the message that is
670 printed depend on the cc65 target.
671 <item>The function is only available as fastcall function, so it may only
672 be used in presence of a prototype.
674 <tag/Availability/cc65
676 <ref id="_stroserror" name="_stroserror">,
677 <ref id="perror" name="perror">
683 <sect1>_randomize<label id="_randomize"><p>
687 <tag/Function/Initialize the pseudo random number generator.
688 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
689 <tag/Declaration/<tt/void _randomize (void);/
690 <tag/Description/The function initializes the random number generator with
691 a seed derived from fast changing hardware events, so the seed itself can be
692 considered random to a certain degree.
693 <tag/Limits/<itemize>
694 <item>The randomness of the seed depends on the machine hardware.
696 <tag/Availability/cc65
698 <ref id="rand" name="rand">,
699 <ref id="srand" name="srand">
705 <sect1>_stroserror<label id="_stroserror"><p>
709 <tag/Function/Return a string describing an OS specific error code.
710 <tag/Header/<tt/<ref id="string.h" name="string.h">/
711 <tag/Declaration/<tt/const char* __fastcall__ _stroserror (unsigned char errcode);/
712 <tag/Description/<tt/_stroserror/ will return a string describing the given
713 operating system specific error code.
714 <tag/Limits/<itemize>
715 <item>Since operating system specific error code are - you guessed it -
716 operating system specific, the parameter and the string returned depend on the
718 <item>The function is only available as fastcall function, so it may only be
719 used in presence of a prototype.
721 <tag/Availability/cc65
723 <ref id="strerror" name="strerror">
729 <sect1>_swap<label id="_swap"><p>
733 <tag/Function/Swap the contents of memory areas.
734 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
735 <tag/Declaration/<tt/void __fastcall__ _swap (void* p, void* q, size_t size);/
736 <tag/Description/<tt/_swap/ will swap (exchange) the contents of the two memory
737 areas pointed to by <tt/p/ and <tt/q/. Both memory areas are assumed to be
738 <tt/size/ bytes in size.
739 <tag/Limits/<itemize>
740 <item>The memory areas may not overlap, otherwise the results are undefined.
741 <item>The function is only available as fastcall function, so it may only be
742 used in presence of a prototype.
744 <tag/Availability/cc65
746 <ref id="memcpy" name="memcpy">,
747 <ref id="memmove" name="memmove">
753 <sect1>_sys<label id="_sys"><p>
757 <tag/Function/Call a subroutine passing register values.
758 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
759 <tag/Declaration/<tt/void __fastcall__ _sys (struct regs* r);/
760 <tag/Description/The function will call the subroutine at the address
761 specified in the <tt/pc/ member of the passed <tt/regs/ structure. All
762 registers and the CPU flags are set to the values given in the <tt/regs/
763 structure. On return from the subroutine, the new values of the registers and
764 flags are stored back overwriting the old values.
765 <tag/Limits/<itemize>
766 <item>Bits 4 and 5 of the flags value in the <tt/regs/ structure are ignored
767 when calling the subroutine (they are unchanged from their current values).
768 <item>The function is only available as fastcall function, so it may only be
769 used in presence of a prototype.
771 <tag/Availability/cc65
777 <sect1>BRK<label id="BRK"><p>
781 <tag/Function/Insert a 6502 BRK instrunction into the code.
782 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
783 <tag/Declaration/<tt/void BRK (void);/
784 <tag/Description/The function will insert a 6502 BRK instruction into the code
785 which may be used to trigger a debugger.
786 <tag/Limits/<itemize>
787 <item>The function is actually a macro.
788 <item>The inserted instruction may lead to unexpected results if no debugger
791 <tag/Availability/cc65
793 <ref id="CLI" name="CLI">,
794 <ref id="SEI" name="SEI">
800 <sect1>CLI<label id="CLI"><p>
804 <tag/Function/Insert a 6502 CLI instrunction into the code.
805 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
806 <tag/Declaration/<tt/void CLI (void);/
807 <tag/Description/The function will insert a 6502 CLI instruction into the code,
808 so interrupts are disabled. Note that non maskable interrupts cannot be
810 <tag/Limits/<itemize>
811 <item>The function is actually a macro.
812 <item>Disabling interrupts may lead to unexpected results.
814 <tag/Availability/cc65
816 <ref id="BRK" name="BRK">,
817 <ref id="SEI" name="SEI">
823 <sect1>PEEK<label id="PEEK"><p>
827 <tag/Function/Read a byte from memory.
828 <tag/Header/<tt/<ref id="peekpoke.h" name="peekpoke.h">/
829 <tag/Declaration/<tt/unsigned char PEEK (unsigned addr);/
830 <tag/Description/The function will read the absolute memory given by <tt/addr/
831 and return the value read.
832 <tag/Limits/<itemize>
833 <item>The function is actually a macro.
834 <item>This function depends highly on the platform and environment.
836 <tag/Availability/cc65
838 <ref id="PEEKW" name="PEEKW">,
839 <ref id="POKE" name="POKE">
845 <sect1>PEEKW<label id="PEEKW"><p>
849 <tag/Function/Read a word (two bytes) from memory.
850 <tag/Header/<tt/<ref id="peekpoke.h" name="peekpoke.h">/
851 <tag/Declaration/<tt/unsigned PEEKW (unsigned addr);/
852 <tag/Description/The function will read the absolute memory given by <tt/addr/
853 and return the value read. The byte read from the higher address is the high
854 byte of the return value.
855 <tag/Limits/<itemize>
856 <item>The function is actually a macro.
857 <item>This function depends highly on the platform and environment.
858 <item>The order in which the two bytes are read is unspecified and may
859 depend of the address expression used.
861 <tag/Availability/cc65
863 <ref id="PEEK" name="PEEK">,
864 <ref id="POKE" name="POKE">
870 <sect1>POKE<label id="POKE"><p>
874 <tag/Function/Write a byte to memory.
875 <tag/Header/<tt/<ref id="peekpoke.h" name="peekpoke.h">/
876 <tag/Declaration/<tt/void POKE (unsigned addr, unsigned char val);/
877 <tag/Description/The function writes the value <tt/val/ to the absolute
878 memory address given by <tt/addr/.
879 <tag/Limits/<itemize>
880 <item>The function is actually a macro.
881 <item>This function depends highly on the platform and environment.
882 <item>Careless use will cause the program to act strange or may crash the
885 <tag/Availability/cc65
887 <ref id="PEEK" name="PEEK">,
888 <ref id="POKEW" name="POKEW">
894 <sect1>POKEW<label id="POKEW"><p>
898 <tag/Function/Write a word (two bytes) to memory.
899 <tag/Header/<tt/<ref id="peekpoke.h" name="peekpoke.h">/
900 <tag/Declaration/<tt/void POKEW (unsigned addr, unsigned val);/
901 <tag/Description/The function writes the value <tt/val/ to the absolute
902 memory address given by <tt/addr/. The low byte of <tt/val/ is written to
903 the <tt/addr/, the high byte is written to <tt/addr+1/.
904 <tag/Limits/<itemize>
905 <item>The function is actually a macro.
906 <item>This function depends highly on the platform and environment.
907 <item>Careless use will cause the program to act strange or may crash the
909 <item>The order in which the two bytes are written is unspecified and may
910 depend of the address expression used.
912 <tag/Availability/cc65
914 <ref id="PEEK" name="PEEK">,
915 <ref id="POKE" name="POKE">
921 <sect1>SEI<label id="SEI"><p>
925 <tag/Function/Insert a 6502 SEI instrunction into the code.
926 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
927 <tag/Declaration/<tt/void SEI (void);/
928 <tag/Description/The function will insert a 6502 SEI instruction into the code,
929 so interrupts are enabled. Enabling interrupts has no effects if they are
930 already enabled (the default).
931 <tag/Limits/<itemize>
932 <item>The function is actually a macro.
934 <tag/Availability/cc65
936 <ref id="BRK" name="BRK">,
937 <ref id="CLI" name="CLI">
943 <sect1>abort<label id="abort"><p>
947 <tag/Function/Terminates a program abnormally.
948 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
949 <tag/Declaration/<tt/void abort (void);/
950 <tag/Description/<tt/abort/ raises <tt/SIGABRT/, writes a termination message
951 on stderr, then terminates the program with an exit code of 3.
952 <tag/Availability/ISO 9899
954 <ref id="assert" name="assert">,
955 <ref id="exit" name="exit">,
956 <ref id="raise" name="raise">
962 <sect1>abs<label id="abs"><p>
966 <tag/Function/Returns the absolute value of an integer.
967 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
968 <tag/Declaration/<tt/int __fastcall__ abs (int v);/
969 <tag/Description/<tt/abs/ returns the absolute value of the argument passed to
971 <tag/Limits/<itemize>
972 <item>The return value is undefined if <tt/INT_MIN/ is passed to the function.
973 <item>The function is only available as fastcall function, so it may only be
974 used in presence of a prototype.
976 <tag/Availability/ISO 9899
978 <ref id="labs" name="labs">
984 <sect1>assert<label id="assert"><p>
988 <tag/Function/Test a condition and possibly abort.
989 <tag/Header/<tt/<ref id="assert.h" name="assert.h">/
990 <tag/Declaration/<tt/void assert (int cond);/
991 <tag/Description/<tt/assert/ is a macro that expands to a <tt/id/
992 statement. If the condition evaluates t zero (false), assert prints a message
993 on stderr and aborts the program.
994 <tag/Limits/<itemize>
995 <item>The function is actually a macro.
997 <tag/Availability/ISO 9899
999 <ref id="abort" name="abort">,
1000 <ref id="exit" name="exit">
1006 <sect1>atexit<label id="atexit"><p>
1010 <tag/Function/Register an exit function.
1011 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1012 <tag/Declaration/<tt/int __fastcall__ atexit (void (*exitfunc) (void));/
1013 <tag/Description/<tt/atexit/ registers the function pointed to by
1014 <tt/exitfunc/ as an exit function. Exit functions are called when the program
1015 terminates, they are called in LIFO order (the last function registered is
1016 called first). <tt/atexit/ returns zero on success and a nonzero value on
1018 <tag/Limits/<itemize>
1019 <item>A maximum of 5 exit functions can be registered.
1020 <item>There is no way to unregister an exit function.
1021 <item>The function is only available as fastcall function, so it may only be
1022 used in presence of a prototype.
1024 <tag/Availability/ISO 9899
1026 <ref id="abort" name="abort">,
1027 <ref id="exit" name="exit">
1033 <sect1>atoi<label id="atoi"><p>
1037 <tag/Function/Convert a string to an integer.
1038 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1039 <tag/Declaration/<tt/int __fastcall__ atoi (const char* s);/
1040 <tag/Description/<tt/atoi/ converts the given string into an integer.
1041 Conversion stops as soon as any invalid character is encountered.
1042 <tag/Limits/<itemize>
1043 <item>There is no way to detect any conversion errors.
1044 <item>The function does not check for an numerical overflow when converting.
1045 <item>The function is only available as fastcall function, so it may only be
1046 used in presence of a prototype.
1048 <tag/Availability/ISO 9899
1050 <ref id="atol" name="atol">,
1051 <ref id="itoa" name="itoa">,
1052 <ref id="ltoa" name="ltoa">,
1053 <ref id="ultoa" name="ultoa">,
1054 <ref id="utoa" name="utoa">
1060 <sect1>atol<label id="atol"><p>
1064 <tag/Function/Convert a string to a long integer.
1065 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1066 <tag/Declaration/<tt/long __fastcall__ atol (const char* s);/
1067 <tag/Description/<tt/atol/ converts the given string into a long integer.
1068 Conversion stops as soon as any invalid character is encountered.
1069 <tag/Limits/<itemize>
1070 <item>There is no way to detect any conversion errors.
1071 <item>The function does not check for an numerical overflow when converting.
1072 <item>The function is only available as fastcall function, so it may only be
1073 used in presence of a prototype.
1075 <tag/Availability/ISO 9899
1077 <ref id="atoi" name="atoi">,
1078 <ref id="itoa" name="itoa">,
1079 <ref id="ltoa" name="ltoa">,
1080 <ref id="ultoa" name="ultoa">,
1081 <ref id="utoa" name="utoa">
1087 <sect1>bgcolor<label id="bgcolor"><p>
1091 <tag/Function/Set the background text color.
1092 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1093 <tag/Declaration/<tt/unsigned char __fastcall__ bgcolor (unsigned char color);/
1094 <tag/Description/The function will set a new background color and return the
1095 old (current) one. The background color is valid for the whole text output
1096 area of the screen, not just for new text.
1097 <tag/Limits/<itemize>
1098 <item>Background colors are system dependent. The function may have no effect
1099 on systems where the background color cannot be changed.
1100 <item>The function is only available as fastcall function, so it may only be
1101 used in presence of a prototype.
1103 <tag/Availability/cc65
1105 <ref id="bordercolor" name="bordercolor">,
1106 <ref id="textcolor" name="textcolor">
1112 <sect1>bordercolor<label id="bordercolor"><p>
1116 <tag/Function/Set the border (frame) color.
1117 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1118 <tag/Declaration/<tt/unsigned char __fastcall__ bordercolor (unsigned char color);/
1119 <tag/Description/The function will set a new border color. It returns the old
1120 (current) border color.
1121 <tag/Limits/<itemize>
1122 <item>Border colors are system dependent. The function may have no effect
1123 on systems where the border color cannot be changed.
1124 <item>The function is only available as fastcall function, so it may only
1125 be used in presence of a prototype.
1127 <tag/Availability/cc65
1129 <ref id="bgcolor" name="bgcolor">,
1130 <ref id="textcolor" name="textcolor">
1136 <sect1>bsearch<label id="bsearch"><p>
1140 <tag/Function/Do a binary search in a sorted array.
1141 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1142 <tag/Declaration/<tt/void* __fastcall__ bsearch (const void* key,
1143 const void* base, size_t n, size_t size,
1144 int (*cmp) (const void*, const void*));/
1145 <tag/Description/<tt/bsearch/ searches a sorted array for a member that
1146 matches the one pointed to by <tt/key/. <tt/base/ is the address of the array,
1147 <tt/n/ is the number of elements, <tt/size/ the size of an element and <tt/cmp/
1148 the function used to compare the members against the key. The function returns
1149 a pointer to the member found, or <tt/NULL/ if there was no match.
1152 <item>The contents of the array must be sorted in ascending order according to
1153 the compare function given.
1154 <item>If there are multiple members that match the key, the function will
1155 return one of the members.
1156 <item>The function is only available as fastcall function, so it may only
1157 be used in presence of a prototype.
1159 <tag/Availability/ISO 9899
1161 <ref id="qsort" name="qsort">
1167 <sect1>bzero<label id="bzero"><p>
1171 <tag/Function/Fill a memory area with zeroes.
1172 <tag/Header/<tt/<ref id="string.h" name="string.h">/
1173 <tag/Declaration/<tt/void __fastcall__ bzero (void* p, size_t count);/
1174 <tag/Description/<tt/bzero/ fills the memory area pointed to by <tt/p/ with
1178 <item>The function is non standard and therefore only available in non ANSI
1179 mode. You should use <tt/<ref id="memset" name="memset">/ instead.
1180 <item>The function is only available as fastcall function, so it may only
1181 be used in presence of a prototype.
1183 <tag/Availability/cc65
1185 <ref id="_swap" name="_swap">,
1186 <ref id="memcpy" name="memcpy">,
1187 <ref id="memmove" name="memmove">,
1188 <ref id="memset" name="memset">,
1194 <sect1>c64mode<label id="c64mode"><p>
1198 <tag/Function/Switch the C128 into C64 compatible mode.
1199 <tag/Header/<tt/<ref id="c128.h" name="c128.h">/
1200 <tag/Declaration/<tt/void c64mode (void);/
1201 <tag/Description/The function will cause the machine to reboot into C64 mode.
1202 <tag/Limits/<itemize>
1203 <item>The function is specific to the C128.
1204 <item>The function will not return to the caller.
1206 <tag/Availability/C128
1212 <sect1>calloc<label id="calloc"><p>
1216 <tag/Function/Allocate and clear memory.
1217 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1218 <tag/Declaration/<tt/void* __fastcall__ calloc (size_t n, size_t size);/
1219 <tag/Description/<tt/calloc/ allocates memory for an array of <tt/n/ elements
1220 of size <tt/size/, clears the whole block with binary zeroes and returns a
1221 pointer to it. On error (not enough memory available), <tt/calloc/ returns
1225 <item>Clearing the memory may not have the expected effect on all platforms:
1226 pointers in the block may not be <tt/NULL/ and floating point variables may
1227 not be zero (0.0). In other words: The "clearing" effect of this function
1228 should be used with care for portable programs.
1229 <item>The function is only available as fastcall function, so it may only
1230 be used in presence of a prototype.
1232 <tag/Availability/ISO 9899
1234 <ref id="_heapadd" name="_heapadd">,
1235 <ref id="_heapblocksize" name="_heapblocksize">,
1236 <ref id="_heapmaxavail" name="_heapmaxavail">,
1237 <ref id="_heapmemavail" name="_heapmemavail">,
1238 <ref id="free" name="free">,
1239 <ref id="malloc" name="malloc">,
1240 <ref id="realloc" name="realloc">
1246 <sect1>cclear<label id="cclear"><p>
1250 <tag/Function/Clear part of a line (write a given number of spaces).
1251 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1252 <tag/Declaration/<tt/void __fastcall__ cclear (unsigned char length);/
1253 <tag/Description/The function clears part of a line by writing <tt/length/
1254 spaces in the current text color.
1255 <tag/Limits/<itemize>
1256 <item>The function is only available as fastcall function, so it may
1257 only be used in presence of a prototype.
1259 <tag/Availability/cc65
1261 <ref id="cclearxy" name="cclearxy">,
1262 <ref id="clrscr" name="clrscr">
1268 <sect1>cclearxy<label id="cclearxy"><p>
1272 <tag/Function/Clear part of a line (write a given number of spaces) starting
1273 at a specific screen position.
1274 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1275 <tag/Declaration/<tt/void __fastcall__ cclearxy (unsigned char x, unsigned char y, unsigned char length);/
1276 <tag/Description/The function moves the cursor to a specific position, and
1277 will then clear part of the line by writing <tt/length/ spaces in the current
1279 <tag/Limits/<itemize>
1280 <item>The function is only available as fastcall function, so it may
1281 only be used in presence of a prototype.
1283 <tag/Availability/cc65
1285 <ref id="cclear" name="cclear">,
1286 <ref id="clrscr" name="clrscr">
1292 <sect1>cgetc<label id="cgetc"><p>
1296 <tag/Function/Read a character from the keyboard.
1297 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1298 <tag/Declaration/<tt/char cgetc (void);/
1299 <tag/Description/The function reads a character from the keyboard. If there is
1300 no character available, <tt/cgetc/ waits until the user presses a key. If the
1301 cursor is enabled by use of the <tt/cursor/ function, a blinking cursor is
1302 displayed while waiting.
1303 <tag/Limits/<itemize>
1304 <item>If the system supports a keyboard buffer, <tt/cgetc/ will fetch a key
1305 from this buffer and wait only if the buffer is empty.
1307 <tag/Availability/cc65
1309 <ref id="cursor" name="cursor">,
1310 <ref id="kbhit" name="kbhit">
1316 <sect1>chline<label id="chline"><p>
1320 <tag/Function/Output a horizontal line in text mode.
1321 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1322 <tag/Declaration/<tt/void __fastcall__ chline (unsigned char length);/
1323 <tag/Description/The function outputs a horizontal line with the given length
1324 starting at the current cursor position.
1325 <tag/Limits/<itemize>
1326 <item>The character used to draw the horizontal line is system dependent.
1327 If available, a line drawing character is used. Drawing a line that is partially
1328 off screen leads to undefined behaviour.
1329 <item>The function is only available as fastcall function, so it may only be
1330 used in presence of a prototype.
1332 <tag/Availability/cc65
1334 <ref id="chlinexy" name="chlinexy">,
1335 <ref id="cvline" name="cvline">,
1336 <ref id="cvlinexy" name="cvlinexy">
1342 <sect1>chlinexy<label id="chlinexy"><p>
1346 <tag/Function/Output a horizontal line at a given position in text mode.
1347 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1348 <tag/Declaration/<tt/void __fastcall__ chlinexy (unsigned char x, unsigned char y, unsigned char length);/
1349 <tag/Description/The function outputs a horizontal line with the given length
1350 starting at a given position.
1351 <tag/Limits/<itemize>
1352 <item>The character used to draw the horizontal line is system dependent.
1353 If available, a line drawing character is used. Drawing a line that is partially
1354 off screen leads to undefined behaviour.
1355 <item>The function is only available as fastcall function, so it may only be
1356 used in presence of a prototype.
1358 <tag/Availability/cc65
1360 <ref id="chline" name="chline">,
1361 <ref id="cvline" name="cvline">,
1362 <ref id="cvlinexy" name="cvlinexy">
1368 <sect1>clearerr<label id="clearerr"><p>
1372 <tag/Function/Clear error and end-of-file status of a stream.
1373 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
1374 <tag/Declaration/<tt/void __fastcall__ clearerr (FILE* f);/
1375 <tag/Description/<tt/clearerr/ clears the error and end-of-file status
1376 indicators for the stream <tt/f/.
1377 <tag/Limits/<itemize>
1378 <item>The function is only available as fastcall function, so it may only be
1379 used in presence of a prototype.
1381 <tag/Availability/ISO 9899
1383 <ref id="feof" name="feof">,
1384 <ref id="ferror" name="ferror">
1390 <sect1>clrscr<label id="clrscr"><p>
1394 <tag/Function/Clear the text screen.
1395 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1396 <tag/Declaration/<tt/void clrscr (void);/
1397 <tag/Description/The function clears the text screen and moves the cursor to
1398 the upper left corner.
1399 <tag/Availability/cc65
1401 <ref id="cclear" name="cclear">,
1402 <ref id="cclearxy" name="cclearxy">
1408 <sect1>close<label id="close"><p>
1412 <tag/Function/Close a file descriptor.
1413 <tag/Header/<tt/<ref id="fcntl.h" name="fcntl.h">/
1414 <tag/Declaration/<tt/int __fastcall__ close (int fd);/
1415 <tag/Description/The function closes the given file descriptor. It returns zero
1416 on success and -1 on error. If an error occurs, the cause can be determined by
1417 reading the <tt/errno/ variable.
1418 <tag/Limits/<itemize>
1419 <item>The function is only available as fastcall function, so it may only
1420 be used in presence of a prototype.
1422 <tag/Availability/POSIX 1003.1
1424 <ref id="creat" name="creat">,
1425 <ref id="open" name="open">
1431 <sect1>creat<label id="creat"><p>
1435 <tag/Function/Create a file.
1436 <tag/Header/<tt/<ref id="fcntl.h" name="fcntl.h">/
1437 <tag/Declaration/<tt/int __fastcall__ creat (const char* name, unsigned mode);/
1438 <tag/Description/<tt/creat/ creates a new file and returns the file descriptor
1439 associated with it. On error, -1 is returned and an error code is stored in
1441 <tag/Limits/<itemize>
1442 <item><tt/creat/ is identical to calling <tt/<ref id="open" name="open">/ with
1443 <tt/flags/ equal to <tt/O_WRONLY | O_CREAT | O_TRUNC/.
1444 <item>The function is only available as fastcall function, so it may only
1445 be used in presence of a prototype.
1447 <tag/Availability/POSIX 1003.1
1449 <ref id="close" name="close">,
1450 <ref id="open" name="open">
1456 <sect1>cprintf<label id="cprintf"><p>
1460 <tag/Function/Formatted output to the console.
1461 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1462 <tag/Declaration/<tt/int cprintf (const char* format, ...);/
1463 <tag/Description/The arguments are converted to text where necessary and
1464 formatted according to the format string given. The resulting string is output
1465 to the console. <tt/cprintf/ supports the same format specifiers as
1466 <tt/printf/. <!-- <tt/<ref id="printf" name="printf">/. -->
1467 <tag/Limits/<itemize>
1468 <item>Like all other <tt/conio/ output functions, <tt/cprintf/ distinguishes
1469 between <tt/\r/ and <tt/\n/.
1471 <tag/Availability/cc65
1473 <ref id="cputc" name="cputc">,
1474 <ref id="cputcxy" name="cputcxy">,
1475 <ref id="cputs" name="cputs">,
1476 <ref id="cputsxy" name="cputsxy">,
1477 <ref id="vcprintf" name="vcprintf">
1483 <sect1>cputc<label id="cputc"><p>
1487 <tag/Function/Output a character directly to the console.
1488 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1489 <tag/Declaration/<tt/void __fastcall__ cputc (char c);/
1490 <tag/Description/Output one character to the console at the current cursor
1492 <tag/Limits/<itemize>
1493 <item>Like all other <tt/conio/ output functions, <tt/cputc/ distinguishes
1494 between <tt/\r/ and <tt/\n/.
1495 <item>The function is only available as fastcall function, so it may only
1496 be used in presence of a prototype.
1498 <tag/Availability/cc65
1500 <ref id="cprintf" name="cprintf">,
1501 <ref id="cputcxy" name="cputcxy">,
1502 <ref id="cputs" name="cputs">,
1503 <ref id="cputsxy" name="cputsxy">,
1504 <ref id="vcprintf" name="vcprintf">
1510 <sect1>cputcxy<label id="cputcxy"><p>
1514 <tag/Function/Output a character at a specific screen position.
1515 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1516 <tag/Declaration/<tt/void __fastcall__ cputcxy (unsigned char x, unsigned char y, char c);/
1517 <tag/Description/<tt/cputcxy/ moves the cursor to the given x/y position on
1518 the screen and outputs one character.
1519 <tag/Limits/<itemize>
1520 <item>Like all other <tt/conio/ output functions, <tt/cputcxy/ distinguishes
1521 between <tt/\r/ and <tt/\n/.
1522 <item>The function is only available as fastcall function, so it may only
1523 be used in presence of a prototype.
1525 <tag/Availability/cc65
1527 <ref id="cprintf" name="cprintf">,
1528 <ref id="cputc" name="cputc">,
1529 <ref id="cputs" name="cputs">,
1530 <ref id="cputsxy" name="cputsxy">,
1531 <ref id="vcprintf" name="vcprintf">
1537 <sect1>cputs<label id="cputs"><p>
1541 <tag/Function/Output a string directly to the console.
1542 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1543 <tag/Declaration/<tt/void __fastcall__ cputs (const char* s);/
1544 <tag/Description/The function outputs the given string on the console at the
1545 current cursor position.
1546 <tag/Limits/<itemize>
1547 <item>Like all other <tt/conio/ output functions, <tt/cputs/ distinguishes
1548 between <tt/\r/ and <tt/\n/.
1549 <item>The function is only available as fastcall function, so it may only
1550 be used in presence of a prototype.
1552 <tag/Availability/cc65
1554 <ref id="cprintf" name="cprintf">,
1555 <ref id="cputc" name="cputc">,
1556 <ref id="cputcxy" name="cputcxy">,
1557 <ref id="cputsxy" name="cputsxy">,
1558 <ref id="vcprintf" name="vcprintf">
1564 <sect1>cputsxy<label id="cputsxy"><p>
1568 <tag/Function/Output a string to the console at a given position.
1569 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1570 <tag/Declaration/<tt/void __fastcall__ cputsxy (unsigned char x, unsigned char y, const char* s);/
1571 <tag/Description/<tt/cputsxy/ moves the cursor to the given x/y position,
1572 and outputs the string <tt/s/.
1573 <tag/Limits/<itemize>
1574 <item>Like all other <tt/conio/ output functions, <tt/cputsxy/ distinguishes
1575 between <tt/\r/ and <tt/\n/.
1576 <item>The function is only available as fastcall function, so it may only
1577 be used in presence of a prototype.
1579 <tag/Availability/cc65
1581 <ref id="cprintf" name="cprintf">,
1582 <ref id="cputc" name="cputc">,
1583 <ref id="cputcxy" name="cputcxy">,
1584 <ref id="cputs" name="cputs">,
1585 <ref id="vcprintf" name="vcprintf">
1591 <sect1>cursor<label id="cursor"><p>
1595 <tag/Function/Enable/disable a blinking cursor when waiting for keyboard input.
1596 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1597 <tag/Declaration/<tt/unsigned char __fastcall__ cursor (unsigned char onoff);/
1598 <tag/Description/If the argument to the function is non zero, a blinking cursor
1599 will be enabled when the <tt/cgetc/ function waits for input from the keyboard.
1600 If the argument is zero, <tt/cgetc/ will wait without a blinking cursor.
1601 <tag/Limits/<itemize>
1602 <item>The function is only available as fastcall function, so it may only
1603 be used in presence of a prototype.
1605 <tag/Availability/cc65
1607 <ref id="cgetc" name="cgetc">,
1608 <ref id="kbhit" name="kbhit">
1614 <sect1>cvline<label id="cvline"><p>
1618 <tag/Function/Output a vertical line in text mode.
1619 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1620 <tag/Declaration/<tt/void __fastcall__ cvline (unsigned char length);/
1621 <tag/Description/The function outputs a vertical line with the given length
1622 starting at the current cursor position.
1623 <tag/Limits/<itemize>
1624 <item>The character used to draw the vertical line is system dependent.
1625 If available, a line drawing character is used. Drawing a line that is partially
1626 off screen leads to undefined behaviour.
1627 <item>The function is only available as fastcall function, so it may only be
1628 used in presence of a prototype.
1630 <tag/Availability/cc65
1632 <ref id="chline" name="chline">,
1633 <ref id="chlinexy" name="chlinexy">,
1634 <ref id="cvlinexy" name="cvlinexy">
1640 <sect1>cvlinexy<label id="cvlinexy"><p>
1644 <tag/Function/Output a vertical line at a given position in text mode.
1645 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1646 <tag/Declaration/<tt/void __fastcall__ cvlinexy (unsigned char x, unsigned char y, unsigned char length);/
1647 <tag/Description/The function outputs a vertical line with the given length
1648 starting at a given position.
1649 <tag/Limits/<itemize>
1650 <item>The character used to draw the vertical line is system dependent.
1651 If available, a line drawing character is used. Drawing a line that is partially
1652 off screen leads to undefined behaviour.
1653 <item>The function is only available as fastcall function, so it may only be
1654 used in presence of a prototype.
1656 <tag/Availability/cc65
1658 <ref id="chline" name="chline">,
1659 <ref id="chlinexy" name="chlinexy">,
1660 <ref id="cvline" name="cvline">
1666 <sect1>div<label id="div"><p>
1670 <tag/Function/Divide two ints and return quotient and remainder.
1671 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1672 <tag/Declaration/<tt/div_t __fastcall__ div (int numer, int denom);/
1673 <tag/Description/<tt/div/ divides <tt/numer/ by <tt/denom/ and returns the
1674 quotient and remainder in a <tt/div_t/ structure.
1677 <item>The function is only available as fastcall function, so it may only
1678 be used in presence of a prototype.
1680 <tag/Availability/ISO 9899
1688 <sect1>em_commit<label id="em_commit"><p>
1692 <tag/Function/Commit changes into extended memory.
1693 <tag/Header/<tt/<ref id="em.h" name="em.h">/
1694 <tag/Declaration/<tt/void __fastcall__ em_commit (void);/
1695 <tag/Description/Commit changes in the memory window to extended storage. If
1696 the contents of the memory window have been changed, these changes may be lost
1697 if <tt/<ref id="em_map" name="em_map">/, <tt/<ref id="em_use" name="em_use">/,
1698 <tt/<ref id="em_copyfrom" name="em_copyfrom">/ or <tt/<ref id="em_copyto"
1699 name="em_copyto">/ are called without calling <tt/em_commit/ first.
1700 <tag/Limits/<itemize>
1701 <item>Calling <tt/em_commit/ does not necessarily mean that changes to the
1702 memory window are discarded, it does just mean that the drivers is allowed
1704 <item>The function is only available as fastcall function, so it may only be
1705 used in presence of a prototype.
1706 <item>The function produces undefined results if no extended memory driver is
1709 <tag/Availability/cc65
1711 <ref id="em_load_driver" name="em_load_driver">,
1712 <ref id="em_map" name="em_map">,
1713 <ref id="em_use" name="em_use">
1719 <sect1>em_copyfrom<label id="em_copyfrom"><p>
1723 <tag/Function/Copy from extended into normal memory.
1724 <tag/Header/<tt/<ref id="em.h" name="em.h">/
1725 <tag/Declaration/<tt/void __fastcall__ em_copyfrom (const struct em_copy* copy_data);/
1726 <tag/Description/Copy data from extended memory into linear memory. Source and
1727 target addresses as well as the number of bytes to transfer are specified in
1728 the <tt/em_copy/ structure that is passed as a parameter.
1729 <tag/Limits/<itemize>
1730 <item>Calling <tt/em_copyfrom/ will invalidate the memory window, so if you
1731 made any changes to the data in the window, call <tt/<ref id="em_commit"
1732 name="em_commit">/ first, or the changes are lost.
1733 <item>The function is only available as fastcall function, so it may only be
1734 used in presence of a prototype.
1735 <item>The function produces undefined results if no extended memory driver is
1738 <tag/Availability/cc65
1740 <ref id="em_commit" name="em_commit">,
1741 <ref id="em_copyto" name="em_copyto">,
1742 <ref id="em_load_driver" name="em_load_driver">
1748 <sect1>em_copyto<label id="em_copyto"><p>
1752 <tag/Function/Copy from normal into extended memory.
1753 <tag/Header/<tt/<ref id="em.h" name="em.h">/
1754 <tag/Declaration/<tt/void __fastcall__ em_copyto (const struct em_copy* copy_data);/
1755 <tag/Description/Copy data from linear into extended memory. Source and
1756 target addresses as well as the number of bytes to transfer are specified in
1757 the <tt/em_copy/ structure that is passed as a parameter.
1758 <tag/Limits/<itemize>
1759 <item>Calling <tt/em_copyto/ will invalidate the memory window, so if you
1760 made any changes to the data in the window, call <tt/<ref id="em_commit"
1761 name="em_commit">/ first, or the changes are lost.
1762 <item>The function is only available as fastcall function, so it may only be
1763 used in presence of a prototype.
1764 <item>The function produces undefined results if no extended memory driver is
1767 <tag/Availability/cc65
1769 <ref id="em_commit" name="em_commit">,
1770 <ref id="em_copyfrom" name="em_copyfrom">,
1771 <ref id="em_load_driver" name="em_load_driver">
1777 <sect1>em_install<label id="em_install"><p>
1781 <tag/Function/Install an already loaded extended memory driver.
1782 <tag/Header/<tt/<ref id="em.h" name="em.h">/
1783 <tag/Declaration/<tt/unsigned char _fastcall__ em_install (void* driver);/
1784 <tag/Description/The function installs an already loaded extended memory driver
1785 and returns an error code. The function may be used to install a driver linked
1786 statically to the program.
1787 <tag/Limits/<itemize>
1788 <item>Not all drivers are able to detect if the supported hardware is really
1790 <item>The function is only available as fastcall function, so it may only be
1791 used in presence of a prototype.
1793 <tag/Availability/cc65
1795 <ref id="em_load_driver" name="em_load_driver">,
1796 <ref id="em_uninstall" name="em_uninstall">,
1797 <ref id="em_unload" name="em_unload">
1803 <sect1>em_load_driver<label id="em_load_driver"><p>
1807 <tag/Function/Load and initialize an extended memory driver.
1808 <tag/Header/<tt/<ref id="em.h" name="em.h">/
1809 <tag/Declaration/<tt/void __fastcall__ em_load_driver (const char* name);/
1810 <tag/Description/Load an extended memory driver into memory and initialize
1811 it. The function returns an error code that tells if all this has been
1813 <tag/Limits/<itemize>
1814 <item>Not all drivers are able to detect if the supported hardware is really
1816 <item>The function is only available as fastcall function, so it may only be
1817 used in presence of a prototype.
1818 <item>The driver is loaded by name, so currently you must know the type of
1819 extended memory that should be supported. There is no autodetect capability.
1821 <tag/Availability/cc65
1823 <ref id="em_unload" name="em_unload">
1829 <sect1>em_map<label id="em_map"><p>
1833 <tag/Function/Make a page of extended memory accessible.
1834 <tag/Header/<tt/<ref id="em.h" name="em.h">/
1835 <tag/Declaration/<tt/void* __fastcall__ em_map (unsigned page);/
1836 <tag/Description/The function maps one page of extended memory into linear
1837 memory and returns a pointer to the page frame. Depending on the hardware
1838 and driver, the data is either mapped into the address space or transfered
1839 into a buffer. If you don't need the actual contents of the page (for example
1840 because you're going to overwrite it completely, it is better to call
1841 <tt/<ref id="em_use" name="em_use">/ instead. <tt/em_use/ will not transfer the
1842 data if it is possible to avoid that.
1843 <tag/Limits/<itemize>
1844 <item>Calling <tt/em_map/ will invalidate the memory window, so if you
1845 made any changes to the data in the window, call <tt/<ref id="em_commit"
1846 name="em_commit">/ first, or the changes are lost.
1847 <item>The function is only available as fastcall function, so it may only be
1848 used in presence of a prototype.
1849 <item>The function produces undefined results if no extended memory driver is
1852 <tag/Availability/cc65
1854 <ref id="em_commit" name="em_commit">,
1855 <ref id="em_load_driver" name="em_load_driver">,
1856 <ref id="em_use" name="em_use">
1862 <sect1>em_pagecount<label id="em_pagecount"><p>
1866 <tag/Function/Return the number of available extended memory pages.
1867 <tag/Header/<tt/<ref id="em.h" name="em.h">/
1868 <tag/Declaration/<tt/unsigned __fastcall__ em_pagecount (void);/
1869 <tag/Description/The function returns the size of the extended memory supported
1870 by the driver in 256 byte pages.
1871 <tag/Limits/<itemize>
1872 <item>The function returns zero if no extended memory driver is loaded.
1873 <item>The function may return zero if the supported hardware was not detected.
1875 <tag/Availability/cc65
1877 <ref id="em_load_driver" name="em_load_driver">
1883 <sect1>em_uninstall<label id="em_uninstall"><p>
1887 <tag/Function/Uninstall an already loaded extended memory driver.
1888 <tag/Header/<tt/<ref id="em.h" name="em.h">/
1889 <tag/Declaration/<tt/unsigned char __fastcall__ em_install (void);/
1890 <tag/Description/The function uninstalls an already loaded extended memory
1891 driver but doesn't remove it from memory.
1892 <tag/Limits/<itemize>
1893 <item>If the driver has been loaded using <tt/<ref id="em_load_driver"
1894 name="em_load_driver">/, <tt/<ref id="em_unload" name="em_unload">/
1895 should be used instead of <tt/em_uninstall/ so the driver is also removed
1897 <item>The function is only available as fastcall function, so it may only be
1898 used in presence of a prototype.
1900 <tag/Availability/cc65
1902 <ref id="em_install" name="em_install">,
1903 <ref id="em_load_driver" name="em_load_driver">,
1904 <ref id="em_unload" name="em_unload">
1910 <sect1>em_unload<label id="em_unload"><p>
1914 <tag/Function/Unload an extended memory driver.
1915 <tag/Header/<tt/<ref id="em.h" name="em.h">/
1916 <tag/Declaration/<tt/unsigned char __fastcall__ em_unload (void);/
1917 <tag/Description/The function unloads a loaded extended memory driver and
1918 frees all memory allocated for the driver.
1919 <tag/Limits/<itemize>
1920 <item>The function does nothing if no driver is loaded.
1922 <tag/Availability/cc65
1924 <ref id="em_load_driver" name="em_load_driver">
1930 <sect1>em_use<label id="em_use"><p>
1934 <tag/Function/Prepare an extended memory page for use.
1935 <tag/Header/<tt/<ref id="em.h" name="em.h">/
1936 <tag/Declaration/<tt/void* __fastcall__ em_use (unsigned page);/
1937 <tag/Description/The function maps one page of extended memory into linear
1938 memory and returns a pointer to the page frame. This function is similar to
1939 <tt/<ref id="em_map" name="em_map">/, but will not transfer data into the
1940 actual memory window in the assumption that the existing data is wrong or
1941 will get overwritten.
1942 <tag/Limits/<itemize>
1943 <item>Calling <tt/em_use/ will invalidate the memory window, so if you
1944 made any changes to the data in the window, call <tt/<ref id="em_commit"
1945 name="em_commit">/ first, or the changes are lost.
1946 <item>The function is only available as fastcall function, so it may only be
1947 used in presence of a prototype.
1948 <item>The function produces undefined results if no extended memory driver is
1951 <tag/Availability/cc65
1953 <ref id="em_commit" name="em_commit">,
1954 <ref id="em_load_driver" name="em_load_driver">,
1955 <ref id="em_map" name="em_map">
1961 <sect1>exit<label id="exit"><p>
1965 <tag/Function/Terminate the program.
1966 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1967 <tag/Declaration/<tt/void __fastcall__ exit (int status);/
1968 <tag/Description/<tt/exit/ terminates the program. The argument specifies the
1969 return code of the program. Before termination, all files are closed, buffered
1970 output is written and any functions registered with <tt/<ref id="atexit"
1971 name="atexit">/ are called. Common values for status are <tt/EXIT_SUCCESS/ and
1972 <tt/EXIT_FAILURE/ which are also defined in <tt/<ref id="stdlib.h"
1974 <tag/Limits/<itemize>
1975 <item>The function is only available as fastcall function, so it may only
1976 be used in presence of a prototype.
1977 <item>It depends on the host machine if the program return code can be
1978 evaluated or is ignored.
1980 <tag/Availability/ISO 9899
1982 <ref id="abort" name="abort">,
1983 <ref id="exit" name="exit">
1989 <sect1>fast<label id="fast"><p>
1993 <tag/Function/Switch the C128 into 2MHz mode.
1994 <tag/Header/<tt/<ref id="c128.h" name="c128.h">/
1995 <tag/Declaration/<tt/void fast (void);/
1996 <tag/Description/The function will switch the clock of the C128 to 2MHz. This
1997 will nearly double the speed compared to slow mode.
1998 <tag/Limits/<itemize>
1999 <item>The function is specific to the C128.
2000 <item>2MHz clock will not work in 40 column mode.
2002 <tag/Availability/C128
2004 <ref id="slow" name="slow">,
2005 <ref id="toggle_videomode" name="toggle_videomode">
2011 <sect1>feof<label id="feof"><p>
2015 <tag/Function/Return the end-of-file indicator of a stream.
2016 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
2017 <tag/Declaration/<tt/int __fastcall__ feof (FILE* f);/
2018 <tag/Description/<tt/feof/ tests the end-of-file indicator ofthe stream
2019 <tt/f/, and returns a non zero value if it is set.
2020 <tag/Limits/<itemize>
2021 <item>The indicator is set only after a read past the end of a file is
2023 <item>The function is only available as fastcall function, so it may only be
2024 used in presence of a prototype.
2026 <tag/Availability/ISO 9899
2028 <ref id="feof" name="clearerr">,
2029 <ref id="ferror" name="ferror">
2035 <sect1>ferror<label id="ferror"><p>
2039 <tag/Function/Return the error indicator of a stream.
2040 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
2041 <tag/Declaration/<tt/int __fastcall__ ferror (FILE* f);/
2042 <tag/Description/<tt/ferror/ tests the error indicator of the stream
2043 <tt/f/, and returns a non zero value if it is set.
2044 <tag/Limits/<itemize>
2045 <item>The function is only available as fastcall function, so it may only be
2046 used in presence of a prototype.
2048 <tag/Availability/ISO 9899
2050 <ref id="feof" name="clearerr">,
2051 <ref id="ferror" name="feof">
2057 <sect1>fileno<label id="fileno"><p>
2061 <tag/Function/Return the file handle used by a stream.
2062 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
2063 <tag/Declaration/<tt/int __fastcall__ fileno (FILE* f);/
2064 <tag/Description/The <tt/fileno/ function returns the file handle used
2065 internally by a C stream. This file handle (an integer) can be used as a
2066 handle for the POSIX input/output functions.
2067 <tag/Limits/<itemize>
2068 <item>The function is only available as fastcall function, so it may only be
2069 used in presence of a prototype.
2070 <item>Mixing C file I/O functions and POSIX file I/O functions for the same
2071 file may have unpredictable results.
2073 <tag/Availability/POSIX 1003.1
2075 <ref id="creat" name="creat">,
2076 <ref id="open" name="open"> <!-- , -->
2077 <!-- <ref id="read" name="read">, -->
2078 <!-- <ref id="write" name="write"> -->
2084 <sect1>free<label id="free"><p>
2088 <tag/Function/Free a block of dynamic memory.
2089 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
2090 <tag/Declaration/<tt/void __fastcall__ free (void* block);/
2091 <tag/Description/Free a block of dynamic memory previously allocated with
2092 <tt/<ref id="malloc" name="malloc">/, <tt/<ref id="calloc" name="calloc">/
2093 or <tt/<ref id="realloc" name="realloc">/. As an exception, if the passed
2094 pointer is <tt/NULL/, no action is performed.
2097 <item>Passing an already free'd block to <tt/free/ again will cause undefined
2098 behaviour and may crash your program.
2099 <item>The function is only available as fastcall function, so it may only
2100 be used in presence of a prototype.
2102 <tag/Availability/ISO 9899
2104 <ref id="_heapadd" name="_heapadd">,
2105 <ref id="_heapblocksize" name="_heapblocksize">,
2106 <ref id="_heapmaxavail" name="_heapmaxavail">,
2107 <ref id="_heapmemavail" name="_heapmemavail">,
2108 <ref id="calloc" name="calloc">,
2109 <ref id="malloc" name="malloc">,
2110 <ref id="realloc" name="realloc">
2116 <sect1>get_ostype<label id="get_ostype"><p>
2120 <tag/Function/The function returns the operating system, the program runs on.
2121 <tag/Header/<tt/<ref id="apple2.h" name="apple2.h">,
2122 <ref id="atari.h" name="atari.h">, <ref id="c64.h" name="c64.h">/
2123 <tag/Declaration/<tt/unsigned char get_ostype (void);/
2124 <tag/Description/<tt/get_ostype/ is machine dependent and does not exist for
2125 all supported targets. If it exists, it returns a number that identifies the
2126 operating system or machine type, the program runs on. The machine dependent
2127 header files define constants that can be used to check the return code.
2128 <tag/Limits/<itemize>
2129 <item>The function does not exist on all platforms.
2130 <item>The return codes are platform dependent.
2132 <tag/Availability/cc65 (not all platforms)
2138 <sect1>getenv<label id="getenv"><p>
2142 <tag/Function/Return a value from the environment.
2143 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
2144 <tag/Declaration/<tt/char* __fastcall__ getenv (const char* name);/
2145 <tag/Description/The function searches the environment for an entry that
2146 matches <tt/name/ and returns its value. The environment consists of a list
2147 of strings in the form <tt/name=value/. If there is no match, <tt/getenv/
2149 <tag/Limits/<itemize>
2150 <item>What exactly is stored in the environment depends on the machine the
2151 program is running on.
2152 <item>The function is only available as fastcall function, so it may only
2153 be used in presence of a prototype.
2155 <tag/Availability/ISO 9899
2161 <sect1>getcpu<label id="getcpu"><p>
2165 <tag/Function/Determine on which CPU the program is running.
2166 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
2167 <tag/Declaration/<tt/unsigned char getcpu (void);/
2168 <tag/Description/The function checks on which CPU the code is running. It
2169 returns one of the constants<itemize>
2171 <item><tt/CPU_65C02/
2172 <item><tt/CPU_65816/
2174 <tag/Limits/<itemize>
2175 <item>Other, more exotic CPU types are not disinguished.
2177 <tag/Availability/cc65
2183 <sect1>gotox<label id="gotox"><p>
2187 <tag/Function/Move the text mode cursor to a new X position.
2188 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2189 <tag/Declaration/<tt/void __fastcall__ gotox (unsigned char x);/
2190 <tag/Description/The function moves the text mode cursor to the specified X
2191 position while leaving the Y position untouched. The leftmost position on the
2192 screen has the coordinate 0.
2193 <tag/Limits/<itemize>
2194 <item>The function is only available as fastcall function, so it may
2195 only be used in presence of a prototype.
2196 <item>Invalid values for the X position (out of screen coordinates) may
2197 lead to undefined behaviour.
2199 <tag/Availability/cc65
2201 <ref id="gotoy" name="gotoy">,
2202 <ref id="gotoxy" name="gotoxy">,
2203 <ref id="wherex" name="wherex">,
2204 <ref id="wherey" name="wherey">
2210 <sect1>gotoxy<label id="gotoxy"><p>
2214 <tag/Function/Move the text mode cursor to a new position.
2215 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2216 <tag/Declaration/<tt/void __fastcall__ gotoxy (unsigned char x, unsigned char y);/
2217 <tag/Description/The function moves the text mode cursor to the specified
2218 position. The leftmost position on the screen has the X coordinate 0, the
2219 topmost line has the Y coordinate 0.
2220 <tag/Limits/<itemize>
2221 <item>The function is only available as fastcall function, so it may only be
2222 used in presence of a prototype.
2223 <item>Invalid values for any of both coordinates (out of screen positions) may
2224 lead to undefined behaviour.
2226 <tag/Availability/cc65
2228 <ref id="gotox" name="gotox">,
2229 <ref id="gotoy" name="gotoy">,
2230 <ref id="wherex" name="wherex">,
2231 <ref id="wherey" name="wherey">
2237 <sect1>gotoy<label id="gotoy"><p>
2241 <tag/Function/Move the text mode cursor to a new Y position.
2242 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2243 <tag/Declaration/<tt/void __fastcall__ gotoy (unsigned char x);/
2244 <tag/Description/The function moves the text mode cursor to the specified Y
2245 position while leaving the X position untouched. The uppermost position on the
2246 screen has the coordinate 0.
2247 <tag/Limits/<itemize>
2248 <item>The function is only available as fastcall function, so it may
2249 only be used in presence of a prototype.
2250 <item>Invalid values for the Y position (out of screen coordinates) may lead
2251 to undefined behaviour.
2253 <tag/Availability/cc65
2255 <ref id="gotox" name="gotox">,
2256 <ref id="gotoxy" name="gotoxy">,
2257 <ref id="wherex" name="wherex">,
2258 <ref id="wherey" name="wherey">
2264 <sect1>isalnum<label id="isalnum"><p>
2268 <tag/Function/Check if a given character is a letter or digit.
2269 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2270 <tag/Declaration/<tt/int __fastcall__ isalnum (int c);/
2271 <tag/Description/The function returns a value of zero if the given argument
2272 is a letter or digit. The return value is non zero if the character
2274 <tag/Limits/<itemize>
2275 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2276 inline sequence generated by the macro will not work correctly for values
2277 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2278 this range. The non inline function may be accessed by <tt/#undef/'ing
2280 <item>When compiling without <tt/-Os/, the function is only available as
2281 fastcall function, so it may only be used in presence of a prototype.
2283 <tag/Availability/ISO 9899
2285 <ref id="isalpha" name="isalpha">,
2286 <ref id="isascii" name="isascii">,
2287 <ref id="isblank" name="isblank">,
2288 <ref id="iscntrl" name="iscntrl">,
2289 <ref id="isdigit" name="isdigit">,
2290 <ref id="isgraph" name="isgraph">,
2291 <ref id="islower" name="islower">,
2292 <ref id="isprint" name="isprint">,
2293 <ref id="ispunct" name="ispunct">,
2294 <ref id="isspace" name="isspace">,
2295 <ref id="isupper" name="isupper">,
2296 <ref id="isxdigit" name="isxdigit">
2302 <sect1>isalpha<label id="isalpha"><p>
2306 <tag/Function/Check if a given character is a letter.
2307 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2308 <tag/Declaration/<tt/int __fastcall__ isalpha (int c);/
2309 <tag/Description/The function returns a value of zero if the given argument
2310 is a letter. The return value is non zero if the character is anything else.
2311 <tag/Limits/<itemize>
2312 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2313 inline sequence generated by the macro will not work correctly for values
2314 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2315 this range. The non inline function may be accessed by <tt/#undef/'ing the
2317 <item>When compiling without <tt/-Os/, the function is only available as
2318 fastcall function, so it may only be used in presence of a prototype.
2320 <tag/Availability/ISO 9899
2322 <ref id="isalnum" name="isalnum">,
2323 <ref id="isascii" name="isascii">,
2324 <ref id="isblank" name="isblank">,
2325 <ref id="iscntrl" name="iscntrl">,
2326 <ref id="isdigit" name="isdigit">,
2327 <ref id="isgraph" name="isgraph">,
2328 <ref id="islower" name="islower">,
2329 <ref id="isprint" name="isprint">,
2330 <ref id="ispunct" name="ispunct">,
2331 <ref id="isspace" name="isspace">,
2332 <ref id="isupper" name="isupper">,
2333 <ref id="isxdigit" name="isxdigit">
2339 <sect1>isascii<label id="isascii"><p>
2343 <tag/Function/Check if a given character is in the ASCII (0..127) range.
2344 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2345 <tag/Declaration/<tt/int __fastcall__ isascii (int c);/
2346 <tag/Description/The function returns a value of zero if the given argument
2347 is in the range 0..127 (the range of valid ASCII characters) and a non zero
2349 <tag/Limits/<itemize>
2350 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2351 inline sequence generated by the macro will not work correctly for values
2352 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2353 this range. The non inline function may be accessed by <tt/#undef/'ing the
2355 <item>When compiling without <tt/-Os/, the function is only available as
2356 fastcall function, so it may only be used in presence of a prototype.
2358 <tag/Availability/ISO 9899
2360 <ref id="isalnum" name="isalnum">,
2361 <ref id="isalpha" name="isalpha">,
2362 <ref id="isblank" name="isblank">,
2363 <ref id="iscntrl" name="iscntrl">,
2364 <ref id="isdigit" name="isdigit">,
2365 <ref id="isgraph" name="isgraph">,
2366 <ref id="islower" name="islower">,
2367 <ref id="isprint" name="isprint">,
2368 <ref id="ispunct" name="ispunct">,
2369 <ref id="isspace" name="isspace">,
2370 <ref id="isupper" name="isupper">,
2371 <ref id="isxdigit" name="isxdigit">
2377 <sect1>isblank<label id="isblank"><p>
2381 <tag/Function/Check if a given character is a space or tab.
2382 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2383 <tag/Declaration/<tt/int __fastcall__ isblank (int c);/
2384 <tag/Description/The function returns a value of zero if the given argument
2385 is a space or tab character. The return value is non zero if the character
2387 <tag/Limits/<itemize>
2388 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2389 inline sequence generated by the macro will not work correctly for values
2390 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2391 this range. The non inline function may be accessed by <tt/#undef/'ing the
2393 <item>When compiling without <tt/-Os/, the function is only available as
2394 fastcall function, so it may only be used in presence of a prototype.
2396 <tag/Availability/cc65
2398 <ref id="isalnum" name="isalnum">,
2399 <ref id="isalpha" name="isalpha">,
2400 <ref id="isascii" name="isascii">,
2401 <ref id="iscntrl" name="iscntrl">,
2402 <ref id="isdigit" name="isdigit">,
2403 <ref id="isgraph" name="isgraph">,
2404 <ref id="islower" name="islower">,
2405 <ref id="isprint" name="isprint">,
2406 <ref id="ispunct" name="ispunct">,
2407 <ref id="isspace" name="isspace">,
2408 <ref id="isupper" name="isupper">,
2409 <ref id="isxdigit" name="isxdigit">
2415 <sect1>iscntrl<label id="iscntrl"><p>
2419 <tag/Function/Check if a given character is a control character.
2420 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2421 <tag/Declaration/<tt/int __fastcall__ iscntrl (int c);/
2422 <tag/Description/The function returns a value of zero if the given argument
2423 is a control character. The return value is non zero if the character
2425 <tag/Limits/<itemize>
2426 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2427 inline sequence generated by the macro will not work correctly for values
2428 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2429 this range. The non inline function may be accessed by <tt/#undef/'ing the
2431 <item>When compiling without <tt/-Os/, the function is only available as
2432 fastcall function, so it may only be used in presence of a prototype.
2434 <tag/Availability/ISO 9899
2436 <ref id="isalnum" name="isalnum">,
2437 <ref id="isalpha" name="isalpha">,
2438 <ref id="isascii" name="isascii">,
2439 <ref id="isblank" name="isblank">,
2440 <ref id="isdigit" name="isdigit">,
2441 <ref id="isgraph" name="isgraph">,
2442 <ref id="islower" name="islower">,
2443 <ref id="isprint" name="isprint">,
2444 <ref id="ispunct" name="ispunct">,
2445 <ref id="isspace" name="isspace">,
2446 <ref id="isupper" name="isupper">,
2447 <ref id="isxdigit" name="isxdigit">
2453 <sect1>isdigit<label id="isdigit"><p>
2457 <tag/Function/Check if a given character is a digit.
2458 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2459 <tag/Declaration/<tt/int __fastcall__ isdigit (int c);/
2460 <tag/Description/The function returns a value of zero if the given argument
2461 is a digit. The return value is non zero if the character is anything else.
2462 <tag/Limits/<itemize>
2463 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2464 inline sequence generated by the macro will not work correctly for values
2465 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2466 this range. The non inline function may be accessed by <tt/#undef/'ing the
2468 <item>When compiling without <tt/-Os/, the function is only available as
2469 fastcall function, so it may only be used in presence of a prototype.
2471 <tag/Availability/ISO 9899
2473 <ref id="isalnum" name="isalnum">,
2474 <ref id="isalpha" name="isalpha">,
2475 <ref id="isascii" name="isascii">,
2476 <ref id="isblank" name="isblank">,
2477 <ref id="iscntrl" name="iscntrl">,
2478 <ref id="isgraph" name="isgraph">,
2479 <ref id="islower" name="islower">,
2480 <ref id="isprint" name="isprint">,
2481 <ref id="ispunct" name="ispunct">,
2482 <ref id="isspace" name="isspace">,
2483 <ref id="isupper" name="isupper">,
2484 <ref id="isxdigit" name="isxdigit">
2490 <sect1>isgraph<label id="isgraph"><p>
2494 <tag/Function/Check if a given character is a printable character (except
2496 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2497 <tag/Declaration/<tt/int __fastcall__ isgraph (int c);/
2498 <tag/Description/The function returns a value of zero if the given argument
2499 is a printable character with the exception of space. The return value is non
2500 zero if the character is anything else.
2501 <tag/Limits/<itemize>
2502 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2503 inline sequence generated by the macro will not work correctly for values
2504 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2505 this range. The non inline function may be accessed by <tt/#undef/'ing the
2507 <item>When compiling without <tt/-Os/, the function is only available as
2508 fastcall function, so it may only be used in presence of a prototype.
2510 <tag/Availability/ISO 9899
2512 <ref id="isalnum" name="isalnum">,
2513 <ref id="isalpha" name="isalpha">,
2514 <ref id="isascii" name="isascii">,
2515 <ref id="isblank" name="isblank">,
2516 <ref id="iscntrl" name="iscntrl">,
2517 <ref id="isdigit" name="isdigit">,
2518 <ref id="islower" name="islower">,
2519 <ref id="isprint" name="isprint">,
2520 <ref id="ispunct" name="ispunct">,
2521 <ref id="isspace" name="isspace">,
2522 <ref id="isupper" name="isupper">,
2523 <ref id="isxdigit" name="isxdigit">
2529 <sect1>islower<label id="islower"><p>
2533 <tag/Function/Check if a given character is a lower case letter.
2534 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2535 <tag/Declaration/<tt/int __fastcall__ islower (int c);/
2536 <tag/Description/The function returns a value of zero if the given argument
2537 is a lower case letter. The return value is non zero if the character is
2539 <tag/Limits/<itemize>
2540 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2541 inline sequence generated by the macro will not work correctly for values
2542 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2543 this range. The non inline function may be accessed by <tt/#undef/'ing the
2545 <item>When compiling without <tt/-Os/, the function is only available as
2546 fastcall function, so it may only be used in presence of a prototype.
2548 <tag/Availability/ISO 9899
2550 <ref id="isalnum" name="isalnum">,
2551 <ref id="isalpha" name="isalpha">,
2552 <ref id="isascii" name="isascii">,
2553 <ref id="isblank" name="isblank">,
2554 <ref id="iscntrl" name="iscntrl">,
2555 <ref id="isdigit" name="isdigit">,
2556 <ref id="isgraph" name="isgraph">,
2557 <ref id="isprint" name="isprint">,
2558 <ref id="ispunct" name="ispunct">,
2559 <ref id="isspace" name="isspace">,
2560 <ref id="isupper" name="isupper">,
2561 <ref id="isxdigit" name="isxdigit">
2567 <sect1>isprint<label id="isprint"><p>
2571 <tag/Function/Check if a given character is a printable character.
2572 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2573 <tag/Declaration/<tt/int __fastcall__ isprint (int c);/
2574 <tag/Description/The function returns a value of zero if the given argument
2575 is a printable character (this includes the space character). The return value
2576 is non zero if the character is anything else.
2577 <tag/Limits/<itemize>
2578 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2579 inline sequence generated by the macro will not work correctly for values
2580 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2581 this range. The non inline function may be accessed by <tt/#undef/'ing the
2583 <item>When compiling without <tt/-Os/, the function is only available as
2584 fastcall function, so it may only be used in presence of a prototype.
2586 <tag/Availability/ISO 9899
2588 <ref id="isalnum" name="isalnum">,
2589 <ref id="isalpha" name="isalpha">,
2590 <ref id="isascii" name="isascii">,
2591 <ref id="isblank" name="isblank">,
2592 <ref id="iscntrl" name="iscntrl">,
2593 <ref id="isdigit" name="isdigit">,
2594 <ref id="isgraph" name="isgraph">,
2595 <ref id="islower" name="islower">,
2596 <ref id="ispunct" name="ispunct">,
2597 <ref id="isspace" name="isspace">,
2598 <ref id="isupper" name="isupper">,
2599 <ref id="isxdigit" name="isxdigit">
2605 <sect1>ispunct<label id="ispunct"><p>
2609 <tag/Function/Check if a given character is a printable character but not a
2610 space or an alphanumeric character.
2611 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2612 <tag/Declaration/<tt/int __fastcall__ ispunct (int c);/
2613 <tag/Description/The function returns a value of zero if the given argument
2614 is a printable character, but not a space or anything alphanumeric. The return
2615 value is non zero if the character is anything else.
2616 <tag/Limits/<itemize>
2617 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2618 inline sequence generated by the macro will not work correctly for values
2619 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2620 this range. The non inline function may be accessed by <tt/#undef/'ing the
2622 <item>When compiling without <tt/-Os/, the function is only available as
2623 fastcall function, so it may only be used in presence of a prototype.
2625 <tag/Availability/ISO 9899
2627 <ref id="isalnum" name="isalnum">,
2628 <ref id="isalpha" name="isalpha">,
2629 <ref id="isascii" name="isascii">,
2630 <ref id="isblank" name="isblank">,
2631 <ref id="iscntrl" name="iscntrl">,
2632 <ref id="isdigit" name="isdigit">,
2633 <ref id="isgraph" name="isgraph">,
2634 <ref id="islower" name="islower">,
2635 <ref id="isprint" name="isprint">,
2636 <ref id="isspace" name="isspace">,
2637 <ref id="isupper" name="isupper">,
2638 <ref id="isxdigit" name="isxdigit">
2644 <sect1>isspace<label id="isspace"><p>
2648 <tag/Function/Check if a given character is a a white-space character.
2649 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2650 <tag/Declaration/<tt/int __fastcall__ isspace (int c);/
2651 <tag/Description/The function returns a value of zero if the given argument
2652 is a white space character. The return value is non zero if the character is
2653 anything else. The standard white space characters are: space, formfeed ('\f'),
2654 newline ('\n'), carriage return ('\r'), horizontal tab ('\t'), and vertical tab
2656 <tag/Limits/<itemize>
2657 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2658 inline sequence generated by the macro will not work correctly for values
2659 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2660 this range. The non inline function may be accessed by <tt/#undef/'ing the
2662 <item>When compiling without <tt/-Os/, the function is only available as
2663 fastcall function, so it may only be used in presence of a prototype.
2665 <tag/Availability/ISO 9899
2667 <ref id="isalnum" name="isalnum">,
2668 <ref id="isalpha" name="isalpha">,
2669 <ref id="isascii" name="isascii">,
2670 <ref id="isblank" name="isblank">,
2671 <ref id="iscntrl" name="iscntrl">,
2672 <ref id="isdigit" name="isdigit">,
2673 <ref id="isgraph" name="isgraph">,
2674 <ref id="islower" name="islower">,
2675 <ref id="isprint" name="isprint">,
2676 <ref id="ispunct" name="ispunct">,
2677 <ref id="isupper" name="isupper">,
2678 <ref id="isxdigit" name="isxdigit">
2684 <sect1>isupper<label id="isupper"><p>
2688 <tag/Function/Check if a given character is an upper case letter.
2689 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2690 <tag/Declaration/<tt/int __fastcall__ isupper (int c);/
2691 <tag/Description/The function returns a value of zero if the given argument
2692 is an upper case letter. The return value is non zero if the character is
2694 <tag/Limits/<itemize>
2695 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2696 inline sequence generated by the macro will not work correctly for values
2697 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2698 this range. The non inline function may be accessed by <tt/#undef/'ing the
2700 <item>When compiling without <tt/-Os/, the function is only available as
2701 fastcall function, so it may only be used in presence of a prototype.
2703 <tag/Availability/ISO 9899
2705 <ref id="isalnum" name="isalnum">,
2706 <ref id="isalpha" name="isalpha">,
2707 <ref id="isascii" name="isascii">,
2708 <ref id="isblank" name="isblank">,
2709 <ref id="iscntrl" name="iscntrl">,
2710 <ref id="isdigit" name="isdigit">,
2711 <ref id="isgraph" name="isgraph">,
2712 <ref id="islower" name="islower">,
2713 <ref id="isprint" name="isprint">,
2714 <ref id="ispunct" name="ispunct">,
2715 <ref id="isspace" name="isspace">,
2716 <ref id="isxdigit" name="isxdigit">
2722 <sect1>isxdigit<label id="isxdigit"><p>
2726 <tag/Function/Check if a given character is a hexadecimal digit.
2727 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2728 <tag/Declaration/<tt/int __fastcall__ isxdigit (int c);/
2729 <tag/Description/The function returns a value of zero if the given argument
2730 is a hexadecimal digit (0..9, a..f and A..F). The return value is non zero
2731 if the character is anything else.
2732 <tag/Limits/<itemize>
2733 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2734 inline sequence generated by the macro will not work correctly for values
2735 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2736 this range. The non inline function may be accessed by <tt/#undef/'ing the
2738 <item>When compiling without <tt/-Os/, the function is only available as
2739 fastcall function, so it may only be used in presence of a prototype.
2741 <tag/Availability/ISO 9899
2743 <ref id="isalnum" name="isalnum">,
2744 <ref id="isalpha" name="isalpha">,
2745 <ref id="isascii" name="isascii">,
2746 <ref id="isblank" name="isblank">,
2747 <ref id="iscntrl" name="iscntrl">,
2748 <ref id="isdigit" name="isdigit">,
2749 <ref id="isgraph" name="isgraph">,
2750 <ref id="islower" name="islower">,
2751 <ref id="isprint" name="isprint">,
2752 <ref id="ispunct" name="ispunct">,
2753 <ref id="isspace" name="isspace">,
2754 <ref id="isupper" name="isupper">
2760 <sect1>itoa<label id="itoa"><p>
2764 <tag/Function/Convert an integer into a string.
2765 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
2766 <tag/Declaration/<tt/char* __fastcall__ itoa (int val, char* buf, int radix);/
2767 <tag/Description/<tt/itoa/ converts the integer <tt/val/ into a string using
2768 <tt/radix/ as the base.
2769 <tag/Limits/<itemize>
2770 <item>There are no provisions to prevent a buffer overflow.
2771 <item>If <tt/val/ contains <tt/INT_MIN/, the behaviour is undefined.
2772 <item>The function is non standard, so it is not available in strict ANSI mode.
2773 You should probably use <tt/sprintf/ instead.
2774 <item>The function is only available as fastcall function, so it may only be
2775 used in presence of a prototype.
2777 <tag/Availability/cc65
2779 <ref id="atoi" name="atoi">,
2780 <ref id="atol" name="atol">,
2781 <ref id="ltoa" name="ltoa">,
2782 <ref id="ultoa" name="ultoa">,
2783 <ref id="utoa" name="utoa">
2789 <sect1>joy_count<label id="joy_count"><p>
2793 <tag/Function/Return the number of joysticks supported by the current driver.
2794 <tag/Header/<tt/<ref id="joystick.h" name="joystick.h">/
2795 <tag/Declaration/<tt/unsigned char __fastcall__ joy_count (void);/
2796 <tag/Description/The function returns a the number of joysticks supported
2797 by the current joystick driver.
2798 <tag/Limits/<itemize>
2799 <item>A joystick driver must be loaded using <ref id="joy_load_driver"
2800 name="joy_load_driver"> before calling this function.
2801 <item>The function returns the number of joysticks supported by the driver.
2802 There's no way to check for the number of actually connected joysticks.
2803 <item>The function is only available as fastcall function, so it may only be
2804 used in presence of a prototype.
2806 <tag/Availability/cc65
2808 <ref id="joy_load_driver" name="joy_load_driver">,
2809 <ref id="joy_read" name="joy_read">
2815 <sect1>joy_install<label id="joy_install"><p>
2819 <tag/Function/Install an already loaded driver and return an error code.
2820 <tag/Header/<tt/<ref id="joystick.h" name="joystick.h">/
2821 <tag/Declaration/<tt/unsigned char __fastcall__ joy_install (void* driver);/
2822 <tag/Description/The function installs a driver that was already loaded into
2823 memory (or linked statically to the program). It returns an error code
2824 (<tt/JOY_ERR_OK/ in case of success).
2825 <tag/Limits/<itemize>
2826 <item>The function is only available as fastcall function, so it may only be
2827 used in presence of a prototype.
2829 <tag/Availability/cc65
2831 <ref id="joy_load_driver" name="joy_load_driver">,
2832 <ref id="joy_uninstall" name="joy_uninstall">,
2833 <ref id="joy_unload" name="joy_unload">
2839 <sect1>joy_load_driver<label id="joy_load_driver"><p>
2843 <tag/Function/Load a driver from disk and install it.
2844 <tag/Header/<tt/<ref id="joystick.h" name="joystick.h">/
2845 <tag/Declaration/<tt/unsigned char __fastcall__ joy_load_driver (const char* driver);/
2846 <tag/Description/The function loads a driver with the given name from disk
2847 and installs it. An error code is returned, which is <tt/JOY_ERR_OK/ if the
2848 driver was successfully loaded and installed.
2849 <tag/Limits/<itemize>
2850 <item>The function is only available as fastcall function, so it may only be
2851 used in presence of a prototype.
2853 <tag/Availability/cc65
2855 <ref id="joy_install" name="joy_install">,
2856 <ref id="joy_uninstall" name="joy_uninstall">,
2857 <ref id="joy_unload" name="joy_unload">
2863 <sect1>joy_read<label id="joy_read"><p>
2867 <tag/Function/Read the status of a joystick.
2868 <tag/Header/<tt/<ref id="joystick.h" name="joystick.h">/
2869 <tag/Declaration/<tt/unsigned char __fastcall__ joy_read (unsigned char joystick);/
2870 <tag/Description/The function reads the status bits for a joystick. The number
2871 of the joystick is passed as parameter. The result may be examined by using one
2872 of the <tt/JOY_xxx/ macros from <ref id="joystick.h" name="joystick.h">.
2873 <tag/Limits/<itemize>
2874 <item>A joystick driver must be loaded using <ref id="joy_load_driver"
2875 name="joy_load_driver"> before calling this function.
2876 <item>The function is only available as fastcall function, so it may only be
2877 used in presence of a prototype.
2879 <tag/Availability/cc65
2881 <ref id="joy_count" name="joy_count">,
2882 <ref id="joy_load_driver" name="joy_load_driver">,
2883 <ref id="joy_unload" name="joy_unload">
2889 <sect1>joy_uninstall<label id="joy_uninstall"><p>
2893 <tag/Function/Uninstall the current joystick driver.
2894 <tag/Header/<tt/<ref id="joystick.h" name="joystick.h">/
2895 <tag/Declaration/<tt/unsigned char __fastcall__ joy_uninstall (void);/
2896 <tag/Description/The function uninstalls the currently installed joystick
2897 driver. It does not remove the driver from memory. The function returns an
2898 error code, which is <tt/JOY_ERR_OK/ if the driver was successfully uninstalled.
2899 <tag/Limits/<itemize>
2900 <item>A joystick driver must be installed using <ref id="joy_install"
2901 name="joy_install"> before calling this function.
2902 <item>The function is only available as fastcall function, so it may only be
2903 used in presence of a prototype.
2905 <tag/Availability/cc65
2907 <ref id="joy_install" name="joy_install">,
2908 <ref id="joy_load_driver" name="joy_load_driver">,
2909 <ref id="joy_unload" name="joy_unload">
2915 <sect1>joy_unload<label id="joy_unload"><p>
2919 <tag/Function/Uninstall, then unload the current joystick driver.
2920 <tag/Header/<tt/<ref id="joystick.h" name="joystick.h">/
2921 <tag/Declaration/<tt/unsigned char __fastcall__ joy_unload (void);/
2922 <tag/Description/The function uninstalls the currently installed joystick
2923 driver and removes it from memory. An error code is returned, which is
2924 <tt/JOY_ERR_OK/ if the driver was successfully uninstalled.
2925 <tag/Limits/<itemize>
2926 <item>A joystick driver must be loaded using <ref id="joy_load_driver"
2927 name="joy_load_driver"> before calling this function.
2928 <item>The function is only available as fastcall function, so it may only be
2929 used in presence of a prototype.
2931 <tag/Availability/cc65
2933 <ref id="joy_load_driver" name="joy_load_driver">
2939 <sect1>kbhit<label id="kbhit"><p>
2943 <tag/Function/Check if there's a key waiting in the keyboard buffer.
2944 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2945 <tag/Declaration/<tt/unsigned char kbhit (void);/
2946 <tag/Description/The function returns a value of zero if there is no character
2947 waiting to be read from the keyboard. It returns non zero otherwise.
2948 <tag/Limits/<itemize>
2949 <item>If the system does not support a keyboard buffer (most systems
2950 do), the function is rather useless.
2952 <tag/Availability/cc65
2954 <ref id="cgetc" name="cgetc">,
2955 <ref id="cursor" name="cursor">
2961 <sect1>labs<label id="labs"><p>
2965 <tag/Function/Returns the absolute value of a long integer.
2966 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
2967 <tag/Declaration/<tt/long __fastcall__ labs (long v);/
2968 <tag/Description/<tt/labs/ returns the absolute value of the argument passed to
2970 <tag/Limits/<itemize>
2971 <item>The return value is undefined if <tt/LONG_MIN/ is passed to the function.
2972 <item>The function is only available as fastcall function, so it may only be
2973 used in presence of a prototype.
2975 <tag/Availability/ISO 9899
2977 <ref id="abs" name="abs">
2983 <sect1>ltoa<label id="ltoa"><p>
2987 <tag/Function/Convert a long integer into a string.
2988 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
2989 <tag/Declaration/<tt/char* __fastcall__ ltoa (long val, char* buf, int radix);/
2990 <tag/Description/<tt/itoa/ converts the long integer <tt/val/ into a string
2991 using <tt/radix/ as the base.
2992 <tag/Limits/<itemize>
2993 <item>There are no provisions to prevent a buffer overflow.
2994 <item>If <tt/val/ contains <tt/LONG_MIN/, the behaviour is undefined.
2995 <item>The function is non standard, so it is not available in strict ANSI mode.
2996 You should probably use <tt/sprintf/ instead.
2997 <item>The function is only available as fastcall function, so it may only be
2998 used in presence of a prototype.
3000 <tag/Availability/cc65
3002 <ref id="atoi" name="atoi">,
3003 <ref id="atol" name="atol">,
3004 <ref id="itoa" name="itoa">,
3005 <ref id="ultoa" name="ultoa">,
3006 <ref id="utoa" name="utoa">
3012 <sect1>localeconv<label id="localeconv"><p>
3016 <tag/Function/Returns a pointer to the current locale structure.
3017 <tag/Header/<tt/<ref id="locale.h" name="locale.h">/
3018 <tag/Declaration/<tt/struct lconv* localeconv (void);/
3019 <tag/Description/<tt/localeconv/ returns a pointer to the current locale
3021 <tag/Limits/<itemize>
3022 <item>cc65 supports only the "C" locale, so even after setting a new locale
3023 using <tt/<ref id="setlocale" name="setlocale">/, the structure returned will
3026 <tag/Availability/ISO 9899
3028 <ref id="setlocale" name="setlocale">
3034 <sect1>longjmp<label id="longjmp"><p>
3038 <tag/Function/Non local goto.
3039 <tag/Header/<tt/<ref id="setjmp.h" name="setjmp.h">/
3040 <tag/Declaration/<tt/void __fastcall__ longjmp (jmp_buf buf, int retval);/
3041 <tag/Description/The <tt/longjmp/ function restores a program context from the
3042 data in <tt/buf/, which must have been set by a preceeding call to
3043 <tt/<ref id="setjmp" name="setjmp">/. Program execution continues as if the
3044 call to <tt/<ref id="setjmp" name="setjmp">/ has just returned the value
3048 <item>If the parameter <tt/retval/ is zero, the function will behave as if it
3049 was called with a value of one.
3050 <item>The function is only available as fastcall function, so it may only
3051 be used in presence of a prototype.
3053 <tag/Availability/ISO 9899
3055 <ref id="setjmp" name="setjmp">
3061 <sect1>malloc<label id="malloc"><p>
3065 <tag/Function/Allocate dynamic memory.
3066 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
3067 <tag/Declaration/<tt/void* __fastcall__ malloc (size_t size);/
3068 <tag/Description/<tt/malloc/ allocates size bytes on the heap and returns a
3069 pointer to the allocated memory block. On error (not enough memory available),
3070 <tt/malloc/ returns <tt/NULL/.
3073 <item>The function is only available as fastcall function, so it may only
3074 be used in presence of a prototype.
3076 <tag/Availability/ISO 9899
3078 <ref id="_heapadd" name="_heapadd">,
3079 <ref id="_heapblocksize" name="_heapblocksize">,
3080 <ref id="_heapmaxavail" name="_heapmaxavail">,
3081 <ref id="_heapmemavail" name="_heapmemavail">,
3082 <ref id="calloc" name="calloc">,
3083 <ref id="free" name="free">,
3084 <ref id="realloc" name="realloc">,
3085 <ref id="strdup" name="strdup">
3091 <sect1>memchr<label id="memchr"><p>
3095 <tag/Function/Search for a character in a block of raw memory.
3096 <tag/Header/<tt/<ref id="string.h" name="string.h">/
3097 <tag/Declaration/<tt/void* __fastcall__ strchr (const void* mem, int c, size_t count);/
3098 <tag/Description/The <tt/memchr/ function locates the first occurrence of <tt/c/
3099 (converted to a char) in the block of raw memory string pointed to by <tt/mem/
3100 that is of size <tt/count/. Upon completion, the function returns a pointer to
3101 the character found, or a null pointer if the character was not found.
3102 <tag/Limits/<itemize>
3103 <item>The function is only available as fastcall function, so it may only
3104 be used in presence of a prototype.
3106 <tag/Availability/ISO 9899
3108 <ref id="strchr" name="strchr">
3114 <sect1>memcpy<label id="memcpy"><p>
3118 <tag/Function/Copy a memory area.
3119 <tag/Header/<tt/<ref id="string.h" name="string.h">/
3120 <tag/Declaration/<tt/void* __fastcall__ memcpy (void* dest, const void* src, size_t count);/
3121 <tag/Description/<tt/memcpy/ copies <tt/count/ bytes from the memory area
3122 pointed to by <tt/src/ into the memory area pointed to by <tt/dest/. It returns
3126 <item>The result is undefined if the memory areas do overlap. Use
3127 <tt/<ref id="memmove" name="memmove">/ to copy overlapping memory areas.
3128 <item>The function is only available as fastcall function, so it may only
3129 be used in presence of a prototype.
3131 <tag/Availability/ISO 9899
3133 <ref id="_swap" name="_swap">,
3134 <ref id="memmove" name="memmove">,
3135 <ref id="memset" name="memset">
3141 <sect1>memmove<label id="memmove"><p>
3145 <tag/Function/Copy a memory area.
3146 <tag/Header/<tt/<ref id="string.h" name="string.h">/
3147 <tag/Declaration/<tt/void* __fastcall__ memmove (void* dest, const void* src, size_t count);/
3148 <tag/Description/<tt/memmove/ copies <tt/count/ bytes from the memory area
3149 pointed to by <tt/src/ into the memory area pointed to by <tt/dest/. It returns
3153 <item>While <tt/memmove/ allows the memory areas to overlap, it has some
3154 additional overhead compared to <tt/<ref id="memcpy" name="memcpy">/.
3155 <item>The function is only available as fastcall function, so it may only
3156 be used in presence of a prototype.
3158 <tag/Availability/ISO 9899
3160 <ref id="_swap" name="_swap">,
3161 <ref id="memcpy" name="memcpy">,
3162 <ref id="memset" name="memset">
3168 <sect1>memset<label id="memset"><p>
3172 <tag/Function/Fill a memory area.
3173 <tag/Header/<tt/<ref id="string.h" name="string.h">/
3174 <tag/Declaration/<tt/void* __fastcall__ memset (void* p, int val, size_t count);/
3175 <tag/Description/<tt/memset/ fills the memory area pointed to by <tt/p/ with
3176 the value <tt/val/. The function returns <tt/p/.
3179 <item>The function is only available as fastcall function, so it may only
3180 be used in presence of a prototype.
3182 <tag/Availability/ISO 9899
3184 <ref id="_swap" name="_swap">,
3185 <ref id="bzero" name="bzero">,
3186 <ref id="memcpy" name="memcpy">,
3187 <ref id="memmove" name="memmove">
3193 <sect1>mod_free<label id="mod_free"><p>
3197 <tag/Function/Free a relocatable module.
3198 <tag/Header/<tt/<ref id="modload.h" name="modload.h">/
3199 <tag/Declaration/<tt/void __fastcall__ mod_free (void* module);/
3200 <tag/Description/The function will free a module loaded into memory by use of
3201 the <tt/<ref id="mod_load" name="mod_load">/ function.
3202 <tag/Limits/<itemize>
3203 <item>The pointer passed as parameter is the pointer to the module memory,
3204 not the pointer to the control structure.
3206 <tag/Availability/cc65
3208 <ref id="mod_load" name="mod_load">
3214 <sect1>mod_load<label id="mod_load"><p>
3218 <tag/Function/Load a relocatable module.
3219 <tag/Header/<tt/<ref id="modload.h" name="modload.h">/
3220 <tag/Declaration/<tt/unsigned char mod_load (struct mod_ctrl* ctrl);/
3221 <tag/Description/The function will load a code module into memory and relocate
3222 it. The function will return an error code. If <tt/MLOAD_OK/ is returned, the
3223 outgoing fields in the passed <tt/mod_ctrl/ struct contain information about
3224 the module just loaded. Possible error codes are:
3226 <item><tt/MLOAD_OK/ - Module load successful
3227 <item><tt/MLOAD_ERR_READ/ - Read error
3228 <item><tt/MLOAD_ERR_HDR/ - Header error
3229 <item><tt/MLOAD_ERR_OS/ - Wrong operating system
3230 <item><tt/MLOAD_ERR_FMT/ - Data format error
3231 <item><tt/MLOAD_ERR_MEM/ - Not enough memory
3233 <tag/Limits/<itemize>
3234 <item>The <htmlurl url="ld65.html" name="ld65"> linker is needed to create
3235 relocatable o65 modules for use with this function.
3237 <tag/Availability/cc65
3239 <ref id="mod_free" name="mod_free">
3245 <sect1>mouse_box<label id="mouse_box"><p>
3249 <tag/Function/Specify a bounding box for the mouse cursor.
3250 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3251 <tag/Declaration/<tt/void __fastcall__ mouse_box (int minx, int miny,
3252 int maxx, int maxy);/
3253 <tag/Description/The function allows to set a bounding box for mouse movement.
3254 <tag/Limits/<itemize>
3255 <item>The function does not check if the mouse cursor is currently within the
3256 given rectangle. Placing the mouse cursor within the bounding box is the
3257 responsibility of the programmer.
3258 <item>While the bounding box may be larger than the actual screen size, the
3259 standard mouse cursor draw routines may fail to set the cursor to coordinates
3260 outside of the screen area. Depending on the platform, you may have to supply
3261 your own mouse cursor routines.
3262 <item>The function is only available as fastcall function, so it may only be
3263 used in presence of a prototype.
3265 <tag/Availability/cc65
3267 <ref id="mouse_move" name="mouse_move">
3273 <sect1>mouse_buttons<label id="mouse_buttons"><p>
3277 <tag/Function/Return a bit mask encoding the state of the mouse buttons.
3278 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3279 <tag/Declaration/<tt/unsigned char __fastcall__ mouse_buttons (void);/
3280 <tag/Description/The function returns a bit mask that encodes the state of the
3281 mouse buttons. You may use the <tt/MOUSE_BTN_XXX/ flags to decode the function
3283 <tag/Limits/<itemize>
3284 <item>The function is only available as fastcall function, so it may only be
3285 used in presence of a prototype.
3287 <tag/Availability/cc65
3289 <ref id="mouse_info" name="mouse_info">,
3290 <ref id="mouse_pos" name="mouse_pos">
3296 <sect1>mouse_geterrormsg<label id="mouse_geterrormsg"><p>
3300 <tag/Function/Return a readable error message for an error code.
3301 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3302 <tag/Declaration/<tt/const char* __fastcall__ mouse_geterrormsg (unsigned char
3304 <tag/Description/The function returns an error message (in english) for the
3305 error code passed parameter.
3306 <tag/Limits/<itemize>
3307 <item>The function will return "Unknown error" for invalid error codes.
3308 <item>The function is only available as fastcall function, so it may only be
3309 used in presence of a prototype.
3311 <tag/Availability/cc65
3313 <ref id="mouse_load_driver" name="mouse_load_driver">,
3314 <ref id="mouse_uninstall" name="mouse_uninstall">,
3315 <ref id="mouse_unload" name="mouse_unload">
3321 <sect1>mouse_hide<label id="mouse_hide"><p>
3325 <tag/Function/Hide the mouse pointer.
3326 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3327 <tag/Declaration/<tt/void __fastcall__ mouse_hide (void);/
3328 <tag/Description/The function hides the mouse pointer. It manages a counter
3329 that is shared between <tt/<ref id="mouse_show" name="mouse_show">/ and
3330 <tt/mouse_hide/ so that every call call to <tt/mouse_hide/ must be followed by
3331 a call to <tt/<ref id="mouse_show" name="mouse_show">/ to make the mouse cursor
3333 <tag/Limits/<itemize>
3334 <item>The function is only available as fastcall function, so it may only be
3335 used in presence of a prototype.
3337 <tag/Availability/cc65
3339 <ref id="mouse_show" name="mouse_show">
3345 <sect1>mouse_info<label id="mouse_info"><p>
3349 <tag/Function/Return the state of the mouse buttons and the position of the
3351 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3352 <tag/Declaration/<tt/void __fastcall__ mouse_info (struct mouse_info* info);/
3353 <tag/Description/The function returns the state of the mouse buttons and the
3354 position of the mouse in the <tt/mouse_info/ structure passed as parameter.
3355 <tag/Limits/<itemize>
3356 <item>The <tt/mouse_info/ struct is a superset of the <tt/mouse_pos/ struct,
3357 so if you just need the mouse position, call <tt/<ref id="mouse_pos"
3358 name="mouse_pos">/ instead.
3359 <item>The function is only available as fastcall function, so it may only be
3360 used in presence of a prototype.
3362 <tag/Availability/cc65
3364 <ref id="mouse_buttons" name="mouse_buttons">,
3365 <ref id="mouse_pos" name="mouse_pos">
3371 <sect1>mouse_install<label id="mouse_install"><p>
3375 <tag/Function/Install an already loaded mouse driver.
3376 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3377 <tag/Declaration/<tt/unsigned char __fastcall__ mouse_install (const struct
3378 mouse_callbacks* c, void* driver);/
3379 <tag/Description/The function installs an already loaded mouse driver and
3380 returns an error code. The <tt/mouse_callbacks/ structure passed as first
3381 parameter contains pointers to routines needed to move or hide/show the mouse
3382 pointer. Defaults for these routines are supplied by the library, so if you
3383 can live with these defaults (which are platform specific), just pass a
3384 pointer to <tt/mouse_def_callbacks/. The function may be used to install a
3385 driver linked statically to the program.
3386 <tag/Limits/<itemize>
3387 <item>Not all drivers are able to detect if the supported hardware is really
3389 <item>After installing a driver, the mouse cursor is hidden.
3390 <item>The function is only available as fastcall function, so it may only be
3391 used in presence of a prototype.
3393 <tag/Availability/cc65
3395 <ref id="mouse_load_driver" name="mouse_load_driver">,
3396 <ref id="mouse_uninstall" name="mouse_uninstall">,
3397 <ref id="mouse_unload" name="mouse_unload">
3403 <sect1>mouse_ioctl<label id="mouse_ioctl"><p>
3407 <tag/Function/Call the driver specific ioctl function.
3408 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3409 <tag/Declaration/<tt/unsigned char __fastcall__ mouse_ioctl (unsigned char code, void* data);/
3410 <tag/Description/The function calls the IOCTL entry in the mouse driver,
3411 which is driver specific. The <tt/code/ parameter will choose between
3412 different IOCTL functions, and the <tt/data/ depends on code. The
3413 function returns an error code. The purpose of this function is to allow
3414 for driver specific extensions. See the documentation for a specific mouse
3415 driver for supported ioctl calls.
3416 <tag/Limits/<itemize>
3417 <item>Calling this function is non portable, because each driver may
3418 implement different ioctl calls (or none at all).
3419 <item>The function is only available as fastcall function, so it may only be
3420 used in presence of a prototype.
3422 <tag/Availability/cc65
3428 <sect1>mouse_load_driver<label id="mouse_load_driver"><p>
3432 <tag/Function/Load and initialize a mouse driver.
3433 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3434 <tag/Declaration/<tt/unsigned char __fastcall__ mouse_load_driver (const struct
3435 mouse_callbacks* c, const char* driver);/
3436 <tag/Description/Load a mouse driver into memory and initialize it. The
3437 function returns an error code that tells if the call has been successful. The
3438 <tt/mouse_callbacks/ structure passed as first parameter contains pointers to
3439 routines needed to move or hide/show the mouse pointer. Defaults for these
3440 routines are supplied by the library, so if you can live with these defaults
3441 (which are platform specific), just pass a pointer to <tt/mouse_def_callbacks/.
3442 <tag/Limits/<itemize>
3443 <item>The driver is loaded by name, so currently you must know the type of
3444 mouse that should be supported. There is no autodetect capability.
3445 <item>Not all drivers are able to detect if the supported hardware is really
3447 <item>After installing a driver, the mouse cursor is hidden.
3448 <item>The function is only available as fastcall function, so it may only be
3449 used in presence of a prototype.
3451 <tag/Availability/cc65
3453 <ref id="mouse_install" name="mouse_install">,
3454 <ref id="mouse_uninstall" name="mouse_uninstall">,
3455 <ref id="mouse_unload" name="mouse_unload">
3461 <sect1>mouse_move<label id="mouse_move"><p>
3465 <tag/Function/Move the mouse cursor to a specific position.
3466 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3467 <tag/Declaration/<tt/void __fastcall__ mouse_move (int x, int y);/
3468 <tag/Description/The function updates the mouse position. If the mouse cursor
3469 is visible, it is shown at the new position.
3470 <tag/Limits/<itemize>
3471 <item>The function does not check if the new position is within the bounding
3472 box specified with <tt/<ref id="mouse_box" name="mouse_box">/.
3473 <item>The function is only available as fastcall function, so it may only be
3474 used in presence of a prototype.
3476 <tag/Availability/cc65
3478 <ref id="mouse_box" name="mouse_box">
3484 <sect1>mouse_pos<label id="mouse_pos"><p>
3488 <tag/Function/Return the position of the mouse.
3489 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3490 <tag/Declaration/<tt/void __fastcall__ mouse_pos (struct mouse_pos* pos);/
3491 <tag/Description/The function returns the position of the mouse in the
3492 <tt/mouse_pos/ structure passed as parameter.
3493 <tag/Limits/<itemize>
3494 <item>The <tt/mouse_pos/ struct is a subset of the <tt/mouse_info/ struct,
3495 so if you do also need the mouse buttons, call <tt/<ref id="mouse_info"
3496 name="mouse_info">/ instead.
3497 <item>The function is only available as fastcall function, so it may only be
3498 used in presence of a prototype.
3500 <tag/Availability/cc65
3502 <ref id="mouse_buttons" name="mouse_buttons">,
3503 <ref id="mouse_info" name="mouse_info">
3509 <sect1>mouse_show<label id="mouse_show"><p>
3513 <tag/Function/Show the mouse pointer.
3514 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3515 <tag/Declaration/<tt/void __fastcall__ mouse_show (void);/
3516 <tag/Description/The function shows the mouse pointer. It manages a counter
3517 that is shared between <tt/<ref id="mouse_hide" name="mouse_hide">/ and
3518 <tt/mouse_show/. The mouse cursor is visible if there was one more call to
3519 <tt/mouse_show/ than to <tt/<ref id="mouse_hide" name="mouse_hide">/.
3520 <tag/Limits/<itemize>
3521 <item>The function is only available as fastcall function, so it may only be
3522 used in presence of a prototype.
3524 <tag/Availability/cc65
3526 <ref id="mouse_hide" name="mouse_hide">
3532 <sect1>mouse_uninstall<label id="mouse_uninstall"><p>
3536 <tag/Function/Uninstall an already loaded mouse driver.
3537 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3538 <tag/Declaration/<tt/unsigned char __fastcall__ mouse_install (void);/
3539 <tag/Description/The function uninstalls an already loaded mouse driver but
3540 don't removes it from memory.
3541 <tag/Limits/<itemize>
3542 <item>If the driver has been loaded using <tt/<ref id="mouse_load_driver"
3543 name="mouse_load_driver">/, <tt/<ref id="mouse_unload" name="mouse_unload">/
3544 should be used instead of <tt/mouse_uninstall/ so the driver is also removed
3546 <item>The function is only available as fastcall function, so it may only be
3547 used in presence of a prototype.
3549 <tag/Availability/cc65
3551 <ref id="mouse_install" name="mouse_install">,
3552 <ref id="mouse_load_driver" name="mouse_load_driver">,
3553 <ref id="mouse_unload" name="mouse_unload">
3559 <sect1>mouse_unload<label id="mouse_unload"><p>
3563 <tag/Function/Unload a mouse driver.
3564 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3565 <tag/Declaration/<tt/unsigned char __fastcall__ mouse_unload (void);/
3566 <tag/Description/The function unloads a loaded mouse driver and frees all
3567 memory allocated for the driver.
3568 <tag/Limits/<itemize>
3569 <item>The function does nothing if no driver is loaded.
3571 <tag/Availability/cc65
3573 <ref id="mouse_install" name="mouse_install">,
3574 <ref id="mouse_load_driver" name="mouse_load_driver">,
3575 <ref id="mouse_uninstall" name="mouse_uninstall">
3581 <sect1>offsetof<label id="offsetof"><p>
3585 <tag/Function/Calculate the offset of a struct or union member.
3586 <tag/Header/<tt/<ref id="stddef.h" name="stddef.h">/
3587 <tag/Declaration/<tt/size_t offsetof (type, member);/
3588 <tag/Description/<tt/offsetof/ calculates the address offset of a <tt/struct/
3589 or <tt/union/ member.
3590 <tag/Limits/<itemize>
3591 <item>The function is actually a macro.
3593 <tag/Availability/ISO 9899
3599 <sect1>open<label id="open"><p>
3603 <tag/Function/Open and possibly create a file.
3604 <tag/Header/<tt/<ref id="fcntl.h" name="fcntl.h">/
3605 <tag/Declaration/<tt/int open (const char* name, int flags, ...);/
3606 <tag/Description/<tt/open/ opens a file and returns the file descriptor
3607 associated with it. On error, -1 is returned and an error code is stored in
3608 <tt/errno/. Several flags may be passed to <tt/open/ that change the behaviour.
3609 <tag/Limits/<itemize>
3610 <item>POSIX specifies an additional <tt/mode/ argument that may be passed to
3611 open, which is used as the permission mask when a new file is created. While
3612 cc65 allows to pass this argument, it is ignored.
3614 <tag/Availability/POSIX 1003.1
3616 <ref id="close" name="close">,
3617 <ref id="creat" name="creat">
3623 <sect1>peekbsys<label id="peekbsys"><p>
3627 <tag/Function/Read one byte from a location in the system bank.
3628 <tag/Header/<tt/<ref id="cbm610.h" name="cbm610.h">/,
3629 <tt/<ref id="cbm510.h" name="cbm510.h">/
3630 <tag/Declaration/<tt/unsigned char __fastcall__ peekbsys (unsigned addr);/
3631 <tag/Description/<tt/peekbsys/ reads one byte from the given address in the
3632 system bank (bank 15) of the CBM PET-II machines and returns it.
3635 <item>The function is only available as fastcall function, so it may only
3636 be used in presence of a prototype.
3637 <item>This function may be a macro depending on the compiler options. The
3638 actual function is accessible by #undef'ing the macro.
3640 <tag/Availability/cc65
3642 <ref id="PEEK" name="PEEK">,
3643 <ref id="PEEKW" name="PEEKW">,
3644 <ref id="peekwsys" name="peekwsys">,
3645 <ref id="pokebsys" name="pokebsys">,
3646 <ref id="pokewsys" name="pokewsys">
3652 <sect1>peekwsys<label id="peekwsys"><p>
3656 <tag/Function/Read one word from a location in the system bank.
3657 <tag/Header/<tt/<ref id="cbm610.h" name="cbm610.h">/,
3658 <tt/<ref id="cbm510.h" name="cbm510.h">/
3659 <tag/Declaration/<tt/unsigned __fastcall__ peekwsys (unsigned addr);/
3660 <tag/Description/<tt/peekwsys/ reads one word from the given address in the
3661 system bank (bank 15) of the CBM PET-II machines and returns it. Following
3662 the usual 6502 conventions, the low byte is read from <tt/addr/, and the
3663 high byte is read from <tt/addr+1/.
3666 <item>The function is only available as fastcall function, so it may only
3667 be used in presence of a prototype.
3668 <item>The order in which the two bytes are read is undefined.
3670 <tag/Availability/cc65
3672 <ref id="PEEK" name="PEEK">,
3673 <ref id="PEEKW" name="PEEKW">,
3674 <ref id="peekbsys" name="peekbsys">,
3675 <ref id="pokebsys" name="pokebsys">,
3676 <ref id="pokewsys" name="pokewsys">
3682 <sect1>perror<label id="perror"><p>
3686 <tag/Function/Print an error message for the error in <tt/errno/.
3687 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
3688 <tag/Declaration/<tt/void __fastcall__ perror (const char* s);/
3689 <tag/Description/<tt/perror/ prints an error message to <tt/stderr/. If <tt/s/
3690 is not <tt/NULL/ and not an empty string, it is printed followed by a colon and
3691 a blank. Then the error message for the current contents of <tt/errno/ is
3692 printed followed by a newline. The message output is the same as returned by
3693 <tt/<ref id="strerror" name="strerror">/ with an argument of <tt/errno/.
3696 <item>The function is only available as fastcall function, so it may only
3697 be used in presence of a prototype.
3699 <tag/Availability/ISO 9899
3701 <ref id="_poserror" name="_poserror">,
3702 <ref id="strerror" name="strerror">
3708 <sect1>pokebsys<label id="pokebsys"><p>
3712 <tag/Function/Write one byte to a location in the system bank.
3713 <tag/Header/<tt/<ref id="cbm610.h" name="cbm610.h">/,
3714 <tt/<ref id="cbm510.h" name="cbm510.h">/
3715 <tag/Declaration/<tt/void __fastcall__ pokebsys (unsigned addr, unsigned char val);/
3716 <tag/Description/<tt/pokebsys/ writes one byte to the given address in the
3717 system bank (bank 15) of the CBM PET-II machines.
3720 <item>The function is only available as fastcall function, so it may only
3721 be used in presence of a prototype.
3723 <tag/Availability/cc65
3725 <ref id="POKE" name="POKE">,
3726 <ref id="POKEW" name="POKEW">,
3727 <ref id="peekbsys" name="peekbsys">,
3728 <ref id="peekwsys" name="peekwsys">,
3729 <ref id="pokewsys" name="pokewsys">
3735 <sect1>pokewsys<label id="pokewsys"><p>
3739 <tag/Function/Write one word to a location in the system bank.
3740 <tag/Header/<tt/<ref id="cbm610.h" name="cbm610.h">/,
3741 <tt/<ref id="cbm510.h" name="cbm510.h">/
3742 <tag/Declaration/<tt/void __fastcall__ pokewsys (unsigned addr, unsigned val);/
3743 <tag/Description/<tt/pokewsys/ writes one word to the given address in the
3744 system bank (bank 15) of the CBM PET-II machines. Following the usual 6502
3745 conventions, the low byte of <tt/val/ is written to <tt/addr/, and the
3746 high byte is written to <tt/addr+1/.
3749 <item>The function is only available as fastcall function, so it may only
3750 be used in presence of a prototype.
3751 <item>The order in which the two bytes are written is undefined.
3753 <tag/Availability/cc65
3755 <ref id="POKE" name="POKE">,
3756 <ref id="POKEW" name="POKEW">,
3757 <ref id="peekbsys" name="peekbsys">,
3758 <ref id="peekwsys" name="peekwsys">,
3759 <ref id="pokebsys" name="pokebsys">
3765 <sect1>qsort<label id="qsort"><p>
3769 <tag/Function/Sort an array.
3770 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
3771 <tag/Declaration/<tt/void __fastcall__ qsort (void* base, size_t count,
3772 size_t size, int (*compare) (const void*, const void*));/
3773 <tag/Description/<tt/qsort/ sorts an array according to a given compare
3774 function <tt/compare/. <tt/base/ is the address of the array, <tt/count/
3775 is the number of elements, <tt/size/ the size of an element and <tt/compare/
3776 the function used to compare the members.
3779 <item>If there are multiple members with the same key, the order after calling
3780 the function is undefined.
3781 <item>The function is only available as fastcall function, so it may only
3782 be used in presence of a prototype.
3784 <tag/Availability/ISO 9899
3786 <ref id="bsearch" name="bsearch">
3792 <sect1>raise<label id="raise"><p>
3796 <tag/Function/Send a signal to the executing program.
3797 <tag/Header/<tt/<ref id="signal.h" name="signal.h">/
3798 <tag/Declaration/<tt/int __fastcall__ raise (int sig);/
3799 <tag/Description/<tt/raise/ sends the given signal to the program. If the
3800 program has installed a signal handler for the signal, this signal handler
3801 will be executed. If no handler has been installed, the default action for
3802 the raised signal will be taken. The function returns zero on success,
3804 <tag/Limits/<itemize>
3805 <item>The function is only available as fastcall function, so it may only
3806 be used in presence of a prototype.
3808 <tag/Availability/ISO 9899
3810 <ref id="abort" name="abort">,
3811 <ref id="signal" name="signal">
3817 <sect1>rand<label id="rand"><p>
3821 <tag/Function/Return a pseudo random number.
3822 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
3823 <tag/Declaration/<tt/int rand (void);/
3824 <tag/Description/The function returns a pseudo random number
3825 between 0 and <tt/RAND_MAX/ (exclusive).
3826 <tag/Limits/<itemize>
3827 <item>Without using <tt><ref id="srand" name="srand"></tt>, always the same
3828 flow of numbers is generated.
3829 <item>On startup, the function behaves as if <ref id="srand" name="srand">
3830 had been used with an argument of 1.
3832 <tag/Availability/ISO 9899
3834 <ref id="_randomize" name="_randomize">,
3835 <ref id="srand" name="srand">
3841 <sect1>realloc<label id="realloc"><p>
3845 <tag/Function/Change the size of an allocated memory block.
3846 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
3847 <tag/Declaration/<tt/void* __fastcall__ realloc (void* block, size_t size);/
3848 <tag/Description/<tt/realloc/ changes the size of the memory block pointed to
3849 by <tt/block/ to <tt/size/ bytes. If <tt/block/ is <tt/NULL/, <tt/realloc/
3850 behaves as if <tt/malloc/ had been called. If <tt/size/ is zero, <tt/realloc/
3851 behaves as if <tt/free/ had been called. On error (not enough memory
3852 available), <tt/realloc/ returns <tt/NULL/.
3855 <item>The part of the memory block that is returned will have its contents
3857 <item>This function is somewhat dangerous to use. Be careful to save the
3858 pointer you're passing somewhere else, otherwise
3860 ptr = realloc (ptr, size);
3862 will loose your only copy of <tt/ptr/ if <tt/realloc/ returns <tt/NULL/.
3863 <item>The function is only available as fastcall function, so it may only
3864 be used in presence of a prototype.
3866 <tag/Availability/ISO 9899
3868 <ref id="_heapadd" name="_heapadd">,
3869 <ref id="_heapblocksize" name="_heapblocksize">,
3870 <ref id="_heapmaxavail" name="_heapmaxavail">,
3871 <ref id="_heapmemavail" name="_heapmemavail">,
3872 <ref id="calloc" name="calloc">,
3873 <ref id="free" name="free">,
3874 <ref id="realloc" name="realloc">
3880 <sect1>remove<label id="remove"><p>
3884 <tag/Function/Delete a file.
3885 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
3886 <tag/Declaration/<tt/int __fastcall__ remove (const char* name);/
3887 <tag/Description/<tt/remove/ deletes the file with the given name. On success,
3888 zero is returned. On error, -1 is returned and <tt/errno/ is set to an error
3889 code describing the reason for the failure.
3892 <item>This function is not available on all cc65 targets (depends on the
3893 availability of file I/O).
3894 <item>The function is only available as fastcall function, so it may only
3895 be used in presence of a prototype.
3897 <tag/Availability/ISO 9899
3899 <ref id="unlink" name="unlink">
3901 #include <stdio.h>
3903 #define FILENAME "helloworld"
3905 if (remove (FILENAME) == 0) {
3906 printf ("We deleted %s successfully\n", FILENAME);
3908 printf ("There was a problem deleting %s\n", FILENAME);
3914 <sect1>reset_brk<label id="reset_brk"><p>
3918 <tag/Function/Resets the break vector to its original value.
3919 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
3920 <tag/Declaration/<tt/void __fastcall__ reset_brk (void);/
3921 <tag/Description/<tt/reset_brk/ resets the break vector to the value it had
3922 before a call to <tt/set_brk/.
3925 <item>Since <tt/<ref id="set_brk" name="set_brk">/ installs an exit handler,
3926 it is not strictly necessary to call this function as part of the cleanup when
3929 <tag/Availability/cc65
3931 <ref id="set_brk" name="set_brk">
3937 <sect1>revers<label id="revers"><p>
3941 <tag/Function/Control revers character display.
3942 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
3943 <tag/Declaration/<tt/unsigned char __fastcall__ revers (unsigned char onoff);/
3944 <tag/Description/If the argument is non zero, the function enables reverse
3945 character display. If the argument is zero, reverse character display is
3946 switched off. The old value of the setting is returned.
3947 <tag/Limits/<itemize>
3948 <item>The function may not be supported by the hardware, in which case
3949 the call is ignored.
3950 <item>The function is only available as fastcall function, so it may only
3951 be used in presence of a prototype.
3953 <tag/Availability/cc65
3955 <ref id="textcolor" name="textcolor">
3961 <sect1>screensize<label id="screensize"><p>
3965 <tag/Function/Return the dimensions of the text mode screen.
3966 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
3967 <tag/Declaration/<tt/void __fastcall__ screensize (unsigned char* x, unsigned char* y);/
3968 <tag/Description/The function returns the dimensions of the text mode screen.
3969 <tag/Limits/<itemize>
3970 <item>The function is only available as fastcall function, so it may only
3971 be used in presence of a prototype.
3973 <tag/Availability/cc65
3975 <ref id="gotox" name="gotox">,
3976 <ref id="gotoxy" name="gotoxy">,
3977 <ref id="gotoy" name="gotoy">,
3978 <ref id="wherex" name="wherex">,
3979 <ref id="wherey" name="wherey">
3985 <sect1>set_brk<label id="set_brk"><p>
3989 <tag/Function/Set the break vector to a user function.
3990 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
3991 <tag/Declaration/<tt/void __fastcall__ set_brk (brk_handler func);/
3992 <tag/Description/<tt/set_brk/ allows a user program to handle breaks within the
3993 program code by letting the vector point to a user written C function. The
3994 runtime library installs a small stub that saves the registers into global
3995 variables that may be accessed (and changed) by the break handler.
3998 <item>The function is only available as fastcall function, so it may only
3999 be used in presence of a prototype.
4000 <item>The stub saves the zero page registers used by the C runtime and switches
4001 to a small break handler stack. This means that it is safe to execute C code,
4002 even if C code was interrupted. Be careful however not to use too many local
4003 variables, and do not enable stack checks for the handler function or any other
4004 function called from it.
4005 <item>The <tt/brk_pc/ variable points to the <tt/BRK/ instruction. If you want
4006 the continue with the interrupted code, you have to adjust <tt/brk_pc/,
4007 otherwise the <tt/BRK/ instruction will get executed over and over again.
4008 <item>Since <tt/set_brk/ installs an exit handler, it is not strictly necessary
4009 to call <tt/<ref id="reset_brk" name="reset_brk">/ as part of the cleanup when
4010 the program terminates.
4012 <tag/Availability/cc65
4014 <ref id="reset_brk" name="reset_brk">
4020 <sect1>setjmp<label id="setjmp"><p>
4024 <tag/Function/Save the context for use with <tt/longjmp/.
4025 <tag/Header/<tt/<ref id="setjmp.h" name="setjmp.h">/
4026 <tag/Declaration/<tt/int __fastcall__ setjmp (jmp_buf buf);/
4027 <tag/Description/The <tt/setjmp/ function saves the current context in <tt/buf/
4028 for subsequent use by the <tt/<ref id="longjmp" name="longjmp">/ function and
4032 <item>The function is only available as fastcall function, so it may only
4033 be used in presence of a prototype.
4034 <item><tt/setjmp/ is actually a macro as required by the ISO standard.
4035 <item><tt/setjmp/ will not save the signal context.
4037 <tag/Availability/ISO 9899
4039 <ref id="longjmp" name="longjmp">
4045 <sect1>setlocale<label id="setlocale"><p>
4049 <tag/Function/Selects a locale.
4050 <tag/Header/<tt/<ref id="locale.h" name="locale.h">/
4051 <tag/Declaration/<tt/char* __fastcall__ setlocale (int category, const char* locale);/
4052 <tag/Description/<tt/setlocale/ sets or queries the program's locale.
4055 <item>The function is only available as fastcall function, so it may only
4056 be used in presence of a prototype.
4057 <item>cc65 supports only the "C" locale, so calling this function to set a
4058 different locale has no effect.
4060 <tag/Availability/ISO 9899
4062 <ref id="localeconv" name="localeconv">,
4063 <ref id="strcoll" name="strcoll">
4069 <sect1>signal<label id="signal"><p>
4073 <tag/Function/Install a signal handler.
4074 <tag/Header/<tt/<ref id="signal.h" name="signal.h">/
4075 <tag/Declaration/<tt/__sigfunc __fastcall__ signal (int sig, __sigfunc func);/
4076 <tag/Description/<tt/signal/ installs a handler for the given signal. The
4077 handler may either be a user supplied function, or one of the predefined
4078 signal handlers <tt/SIG_IGN/ or <tt/SIG_DFL/. The function returns the
4079 previous value if the signal , or the special function vector SIG_ERR in
4081 <tag/Limits/<itemize>
4082 <item>The function is only available as fastcall function, so it may only
4083 be used in presence of a prototype.
4085 <tag/Availability/ISO 9899
4087 <ref id="abort" name="abort">,
4088 <ref id="raise" name="raise">
4094 <sect1>sleep<label id="sleep"><p>
4098 <tag/Function/Sleep for a specified amount of time.
4099 <tag/Header/<tt/<ref id="unistd.h" name="unistd.h">/
4100 <tag/Declaration/<tt/void __fastcall__ sleep (unsigned seconds);/
4101 <tag/Description/The function will return after the specified number of
4102 seconds have elapsed.
4103 <tag/Limits/<itemize>
4104 <item>The function is only available as fastcall function, so it may only
4105 be used in presence of a prototype.
4107 <tag/Availability/POSIX 1003.1
4113 <sect1>slow<label id="slow"><p>
4117 <tag/Function/Switch the C128 into 1MHz mode.
4118 <tag/Header/<tt/<ref id="c128.h" name="c128.h">/
4119 <tag/Declaration/<tt/void slow (void);/
4120 <tag/Description/The function will switch the clock of the C128 to 1MHz. This
4121 will halve the speed compared to fast mode.
4122 <tag/Limits/<itemize>
4123 <item>The function is specific to the C128.
4125 <tag/Availability/C128
4127 <ref id="fast" name="fast">,
4128 <ref id="toggle_videomode" name="toggle_videomode">
4134 <sect1>srand<label id="srand"><p>
4138 <tag/Function/Initialize the pseudo random number generator.
4139 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
4140 <tag/Declaration/<tt/void __fastcall__ srand (unsigned seed);/
4141 <tag/Description/The function initializes the random number generator using
4142 the given seed. On program startup, the generator behaves as if <tt/srand/ has
4143 been called with an argument of 1.
4144 <tag/Limits/<itemize>
4145 <item>The function is only available as fastcall function, so it may only
4146 be used in presence of a prototype.
4148 <tag/Availability/ISO 9899
4150 <ref id="_randomize" name="_randomize">,
4151 <ref id="rand" name="rand">
4157 <sect1>strcasecmp<label id="strcasecmp"><p>
4161 <tag/Function/Compare two strings case insensitive.
4162 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4163 <tag/Declaration/<tt/int __fastcall__ strcasecmp (const char* s1, const char* s2);/
4164 <tag/Description/The <tt/strcasecmp/ function compares the two strings passed
4165 as parameters without case sensitivity. It returns a value that is less than
4166 zero if <tt/s1/ is less than <tt/s2/, zero if <tt/s1/ is the same as <tt/s2/,
4167 and a value greater than zero if <tt/s1/ is greater than <tt/s2/.
4168 <tag/Limits/<itemize>
4169 <item>The function is only available as fastcall function, so it may only
4170 be used in presence of a prototype.
4171 <item>The function is not available in strict ANSI mode.
4173 <tag/Availability/cc65
4175 <ref id="strcmp" name="strcmp">,
4176 <ref id="strcoll" name="strcoll">,
4177 <ref id="stricmp" name="stricmp">,
4178 <ref id="strncmp" name="strncmp">
4184 <sect1>strcat<label id="strcat"><p>
4188 <tag/Function/Concatentate two strings.
4189 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4190 <tag/Declaration/<tt/char* __fastcall__ strcat (char* s1, const char* s2);/
4191 <tag/Description/The <tt/strcat/ function appends a copy of the string
4192 pointed to by s2 (including the terminating null byte) to the end of the
4193 string pointed to by s1. The initial byte of s2 overwrites the null byte at
4195 <tag/Limits/<itemize>
4196 <item>The function is only available as fastcall function, so it may only
4197 be used in presence of a prototype.
4198 <item>If copying takes place between objects that overlap, the behaviour
4201 <tag/Availability/ISO 9899
4203 <ref id="strcpy" name="strcpy">,
4204 <ref id="strncat" name="strncat">,
4205 <ref id="strncpy" name="strncpy">
4211 <sect1>strchr<label id="strchr"><p>
4215 <tag/Function/Search for a character in a string.
4216 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4217 <tag/Declaration/<tt/char* __fastcall__ strchr (const char* s, int c);/
4218 <tag/Description/The <tt/strchr/ function locates the first occurrence of <tt/c/
4219 (converted to a char) in the string pointed to by <tt/s/. The terminating null
4220 byte is considered to be part of the string. Upon completion, the function
4221 returns a pointer to the byte, or a null pointer if the byte was not found.
4222 <tag/Limits/<itemize>
4223 <item>The function is only available as fastcall function, so it may only
4224 be used in presence of a prototype.
4226 <tag/Availability/ISO 9899
4228 <ref id="memchr" name="memchr">,
4229 <ref id="strrchr" name="strrchr">
4235 <sect1>strcmp<label id="strcmp"><p>
4239 <tag/Function/Compare two strings.
4240 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4241 <tag/Declaration/<tt/int __fastcall__ strcmp (const char* s1, const char* s2);/
4242 <tag/Description/The <tt/strcmp/ function compares the two strings passed as
4243 parameters. It returns a value that is less than zero if <tt/s1/ is less than
4244 <tt/s2/, zero if <tt/s1/ is the same as <tt/s2/, and a value greater than zero
4245 if <tt/s1/ is greater than <tt/s2/.
4246 <tag/Limits/<itemize>
4247 <item>The function is only available as fastcall function, so it may only
4248 be used in presence of a prototype.
4250 <tag/Availability/ISO 9899
4252 <ref id="strcasecmp" name="strcasecmp">,
4253 <ref id="strcoll" name="strcoll">,
4254 <ref id="stricmp" name="stricmp">,
4255 <ref id="strncmp" name="strncmp">
4261 <sect1>strcoll<label id="strcoll"><p>
4265 <tag/Function/Compare two strings.
4266 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4267 <tag/Declaration/<tt/int __fastcall__ strcoll (const char* s1, const char* s2);/
4268 <tag/Description/The <tt/strcoll/ function compares the two strings passed as
4269 parameters, according to the collating sequence set by <tt/<ref id="setlocale"
4270 name="setlocale">/. It returns a value that is less than zero if <tt/s1/ is
4271 less than <tt/s2/, zero if <tt/s1/ is the same as <tt/s2/, and a value greater
4272 than zero if <tt/s1/ is greater than <tt/s2/.
4273 <tag/Limits/<itemize>
4274 <item>The function is only available as fastcall function, so it may only
4275 be used in presence of a prototype.
4277 <tag/Availability/ISO 9899
4279 <ref id="setlocale" name="setlocale">,
4280 <ref id="strcasecmp" name="strcasecmp">,
4281 <ref id="strcmp" name="strcmp">,
4282 <ref id="stricmp" name="stricmp">,
4283 <ref id="strncmp" name="strncmp">
4289 <sect1>strcpy<label id="strcpy"><p>
4293 <tag/Function/Copy a string.
4294 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4295 <tag/Declaration/<tt/char* __fastcall__ strcpy (char* s1, const char* s2);/
4296 <tag/Description/The <tt/strcpy/ function copies the string pointed to by
4297 <tt/s2/ (including the terminating null byte) into the array pointed to by
4298 <tt/s1/. The function will always return <tt/s1/.
4299 <tag/Limits/<itemize>
4300 <item>The function is only available as fastcall function, so it may only
4301 be used in presence of a prototype.
4302 <item>If copying takes place between objects that overlap, the behaviour
4305 <tag/Availability/ISO 9899
4307 <ref id="strcat" name="strcat">,
4308 <ref id="strncat" name="strncat">,
4309 <ref id="strncpy" name="strncpy">
4312 #include <string.h>
4314 static char hello[14];
4316 strcpy (hello, "Hello world!\n");
4322 <sect1>strcspn<label id="strcspn"><p>
4326 <tag/Function/Compute the length of a substring.
4327 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4328 <tag/Declaration/<tt/size_t __fastcall__ strcspn (const char* s, const char* set);/
4329 <tag/Description/The <tt/strcspn/ function computes and returns the length of
4330 the substring pointed to by <tt/s/ which does <em>not</em> consist of
4331 characters contained in the string <tt/set/.
4332 <tag/Limits/<itemize>
4333 <item>The function is only available as fastcall function, so it may only
4334 be used in presence of a prototype.
4336 <tag/Availability/ISO 9899
4338 <ref id="strspn" name="strspn">,
4339 <ref id="strstr" name="strstr">,
4340 <ref id="strtok" name="strtok">
4346 <sect1>strdup<label id="strdup"><p>
4350 <tag/Function/Allocate a copy of a string on the heap.
4351 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4352 <tag/Declaration/<tt/char* __fastcall__ strdup (const char* s);/
4353 <tag/Description/<tt/strdup/ allocates a memory block on the heap, big enough
4354 to hold a copy of <tt/s/ including the terminating zero. If the allocation
4355 fails, <tt/NULL/ is returned, otherwise <tt/s/ is copied into the allocated
4356 memory block, and a pointer to the block is returned.
4357 <tag/Limits/<itemize>
4358 <item>The function is only available as fastcall function, so it may only
4359 be used in presence of a prototype.
4360 <item>It is up to the caller to free the allocated memory block.
4362 <tag/Availability/ISO 9899
4364 <ref id="free" name="free">,
4365 <ref id="malloc" name="malloc">
4371 <sect1>strerror<label id="strerror"><p>
4375 <tag/Function/Return a string describing an error code.
4376 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4377 <tag/Declaration/<tt/char* __fastcall__ strerror (int errcode);/
4378 <tag/Description/The <tt/strerror/ function returns a string describing the
4379 given error code. If an invalid error code is passed, the string "Unknown
4380 error" is returned, and <tt/errno/ is set to <tt/EINVAL/. In all other cases,
4381 <tt/errno/ is left untouched.
4382 <tag/Limits/<itemize>
4383 <item>The function is only available as fastcall function, so it may only
4384 be used in presence of a prototype.
4385 <item>While the return type of the function is a <tt/char*/, the returned
4386 string must not be modified by the caller!
4388 <tag/Availability/ISO 9899
4390 <ref id="_stroserror" name="_stroserror">
4396 <sect1>stricmp<label id="stricmp"><p>
4400 <tag/Function/Compare two strings case insensitive.
4401 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4402 <tag/Declaration/<tt/int __fastcall__ stricmp (const char* s1, const char* s2);/
4403 <tag/Description/The <tt/stricmp/ function compares the two strings passed as
4404 parameters without case sensitivity. It returns a value that is less than zero
4405 if <tt/s1/ is less than <tt/s2/, zero if <tt/s1/ is the same as <tt/s2/, and a
4406 value greater than zero if <tt/s1/ is greater than <tt/s2/.
4407 <tag/Limits/<itemize>
4408 <item>The function is only available as fastcall function, so it may only
4409 be used in presence of a prototype.
4410 <item>The function is not available in strict ANSI mode.
4412 <tag/Availability/cc65
4414 <ref id="strcasecmp" name="strcasecmp">,
4415 <ref id="strcmp" name="strcmp">,
4416 <ref id="strcoll" name="strcoll">,
4417 <ref id="strncmp" name="strncmp">
4423 <sect1>strlen<label id="strlen"><p>
4427 <tag/Function/Return the length of a string.
4428 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4429 <tag/Declaration/<tt/size_t __fastcall__ strlen (const char* s);/
4430 <tag/Description/The <tt/strlen/ function computes the number of bytes in the
4431 string to which s points, not including the terminating null byte.
4432 <tag/Limits/<itemize>
4433 <item>The function is only available as fastcall function, so it may only
4434 be used in presence of a prototype.
4435 <item>When compiling with <tt/-Os/ (inline known standard functions), the
4436 function does not work correctly for strings with more than 255 characters.
4438 <tag/Availability/ISO 9899
4440 <ref id="strcpy" name="strcpy">
4446 <sect1>strlower<label id="strlower"><p>
4450 <tag/Function/Make a string lower case.
4451 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4452 <tag/Declaration/<tt/char* __fastcall__ strlower (char* s);/
4453 <tag/Description/The <tt/strlower/ function will apply the <tt/tolower/
4454 function to each character of a string. The function will always return <tt/s/.
4455 <tag/Limits/<itemize>
4456 <item>The function is only available as fastcall function, so it may only
4457 be used in presence of a prototype.
4458 <item>The function prototype is unavailable when compiling in strict ANSI mode.
4459 <item>An alias name for this function is <tt/strlwr/.
4461 <tag/Availability/cc65
4463 <ref id="strupper" name="strupper">,
4464 <ref id="tolower" name="tolower">
4470 <sect1>strlwr<label id="strlwr"><p>
4477 <sect1>strncat<label id="strncat"><p>
4481 <tag/Function/Concatentate two strings.
4482 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4483 <tag/Declaration/<tt/char* __fastcall__ strncat (char* s1, const char* s2, size_t n);/
4484 <tag/Description/The <tt/strncat/ function appends not more than n characters
4485 of the string pointed to by s2 to the end of the string pointed to by s1. The
4486 terminating null character at the end of s1 is overwritten. A terminating null
4487 character is appended to the result, even if not all of s2 is appended to s1.
4488 <tag/Limits/<itemize>
4489 <item>The function is only available as fastcall function, so it may only
4490 be used in presence of a prototype.
4491 <item>If copying takes place between objects that overlap, the behaviour
4494 <tag/Availability/ISO 9899
4496 <ref id="strcpy" name="strcpy">,
4497 <ref id="strncat" name="strncat">,
4498 <ref id="strncpy" name="strncpy">
4504 <sect1>strncmp<label id="strncmp"><p>
4508 <tag/Function/Compare two strings.
4509 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4510 <tag/Declaration/<tt/int __fastcall__ strncmp (const char* s1, const char* s2, size_t count);/
4511 <tag/Description/The <tt/strncmp/ function compares not more than <tt/count/
4512 characters of the two strings passed as parameters. It returns a value that is
4513 less than zero if the first <tt/count/ characters of <tt/s1/ are less than
4514 <tt/s2/, zero if they are identical, and a value greater than zero they are
4516 <tag/Limits/<itemize>
4517 <item>The function is only available as fastcall function, so it may only
4518 be used in presence of a prototype.
4520 <tag/Availability/ISO 9899
4522 <ref id="strcasecmp" name="strcasecmp">,
4523 <ref id="strcmp" name="strcmp">,
4524 <ref id="strcoll" name="strcoll">,
4525 <ref id="stricmp" name="stricmp">
4531 <sect1>strncpy<label id="strncpy"><p>
4535 <tag/Function/Copy part of a string.
4536 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4537 <tag/Declaration/<tt/char* __fastcall__ strcpy (char* s1, const char* s2, size_t n);/
4538 <tag/Description/The <tt/strncpy/ function copies not more than n bytes from
4539 the array pointed to by <tt/s2/ to the array pointed to by <tt/s1/. If the array
4540 pointed to by <tt/s2/ is a string that is shorter than n bytes, null bytes are
4541 appended to the copy in the array pointed to by <tt/s1/, until <tt/n/ bytes are
4542 written. The function will always return <tt/s1/.
4543 <tag/Limits/<itemize>
4544 <item>The function is only available as fastcall function, so it may only
4545 be used in presence of a prototype. If there is no null byte in the first <tt/n/
4546 bytes of the array pointed to by <tt/s2/, the result is not null-terminated.
4547 <item>If copying takes place between objects that overlap, the behaviour is
4550 <tag/Availability/ISO 9899
4552 <ref id="strcat" name="strcat">,
4553 <ref id="strcpy" name="strcpy">,
4554 <ref id="strncat" name="strncat">
4559 static char hello[6];
4561 strcpy (hello, "Hello world!\n", sizeof (hello) - 1);
4568 <sect1>strrchr<label id="strrchr"><p>
4572 <tag/Function/Search for a character in a string.
4573 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4574 <tag/Declaration/<tt/char* __fastcall__ strrchr (const char* s, int c);/
4575 <tag/Description/The <tt/strrchr/ function locates the last occurrence of <tt/c/
4576 (converted to a char) in the string pointed to by <tt/s/. The terminating null
4577 byte is considered to be part of the string. Upon completion, the function
4578 returns a pointer to the byte, or a null pointer if the byte was not found.
4579 <tag/Limits/<itemize>
4580 <item>The function is only available as fastcall function, so it may only
4581 be used in presence of a prototype.
4583 <tag/Availability/ISO 9899
4585 <ref id="strchr" name="strchr">
4591 <sect1>strspn<label id="strspn"><p>
4595 <tag/Function/Compute the length of a substring.
4596 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4597 <tag/Declaration/<tt/size_t __fastcall__ strspn (const char* s, const char* set);/
4598 <tag/Description/The <tt/strspn/ function computes and returns the length of
4599 the substring pointed to by <tt/s/ which does consist only of characters
4600 contained in the string <tt/set/.
4601 <tag/Limits/<itemize>
4602 <item>The function is only available as fastcall function, so it may only
4603 be used in presence of a prototype.
4605 <tag/Availability/ISO 9899
4607 <ref id="strcspn" name="strcspn">,
4608 <ref id="strstr" name="strstr">
4614 <sect1>strstr<label id="strstr"><p>
4618 <tag/Function/Find a substring.
4619 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4620 <tag/Declaration/<tt/char* __fastcall__ strstr (const char* str, const char* substr);/
4621 <tag/Description/<tt/strstr/ searches for the first occurance of the string
4622 <tt/substr/ within <tt/str/. If found, it returns a pointer to the copy,
4623 otherwise it returns <tt/NULL/.
4624 <tag/Limits/<itemize>
4625 <item>The function is only available as fastcall function, so it may only
4626 be used in presence of a prototype.
4628 <tag/Availability/ISO 9899
4630 <ref id="strcspn" name="strcspn">,
4631 <ref id="strspn" name="strspn">
4637 <sect1>strtok<label id="strtok"><p>
4641 <tag/Function/Break a string into tokens.
4642 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4643 <tag/Declaration/<tt/char* __fastcall__ strtok (char* s1, const char* s2);/
4644 <tag/Description/<tt/strtok/ will break the string s1 into a sequence of
4645 tokens, which are delimited by characters from the string s2. The first call
4646 to <tt/strtok/ will return a pointer to the first token in the string s1.
4647 Following calls must pass a <tt/NULL/ pointer as s1 in order to get the next
4648 token in the string. Different sets of delimiters may be used for the
4649 subsequent calls to <tt/strtok/.
4650 <tag/Limits/<itemize>
4651 <item>The function is only available as fastcall function, so it may only
4652 be used in presence of a prototype.
4653 <item><tt/strtok/ will modify the string s1.
4655 <tag/Availability/ISO 9899
4657 <ref id="strcspn" name="strcspn">,
4658 <!-- <ref id="strpbrk" name="strpbrk"> -->
4664 <sect1>strupper<label id="strupper"><p>
4668 <tag/Function/Make a string upper case.
4669 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4670 <tag/Declaration/<tt/char* __fastcall__ strupper (char* s);/
4671 <tag/Description/The <tt/strupper/ function will apply the <tt/toupper/
4672 function to each character of a string. The function will always return <tt/s/.
4673 <tag/Limits/<itemize>
4674 <item>The function is only available as fastcall function, so it may only
4675 be used in presence of a prototype.
4676 <item>The function prototype is unavailable when compiling in strict ANSI mode.
4677 <item>An alias name for this function is <tt/strupr/.
4679 <tag/Availability/cc65
4681 <ref id="strlower" name="strlower">
4682 <ref id="toupper" name="toupper">
4688 <sect1>strupr<label id="strupr"><p>
4695 <sect1>textcolor<label id="textcolor"><p>
4699 <tag/Function/Set the text color.
4700 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
4701 <tag/Declaration/<tt/unsigned char __fastcall__ textcolor (unsigned char color);/
4702 <tag/Description/The function will set a new text color. It returns the old
4703 (current) text color. Text output using any <tt/conio.h/ function will use
4704 the color set by this function.
4705 <tag/Limits/<itemize>
4706 <item>Text colors are system dependent. The function may have no effect
4707 on systems where the text color cannot be changed.
4708 <item>The function is only available as fastcall function, so it may only
4709 be used in presence of a prototype.
4711 <tag/Availability/cc65
4713 <ref id="bgcolor" name="bgcolor">,
4714 <ref id="bordercolor" name="bordercolor">
4720 <sect1>time<label id="time"><p>
4724 <tag/Function/Get the time.
4725 <tag/Header/<tt/<ref id="time.h" name="time.h">/
4726 <tag/Declaration/<tt/time_t __fastcall__ time (time_t* t);/
4727 <tag/Description/The function returns the time since the 1970-01-01 00:00:00
4728 measured in seconds. If the pointer <tt/t/ is not <tt/NULL/, the function
4729 result will also be stored there. If no time is available, <tt/(time_t)-1/ is
4730 returned and <tt/errno/ is set to <tt/ENOSYS/.
4731 <tag/Limits/<itemize>
4732 <item>The function is only available as fastcall function, so it may
4733 only be used in presence of a prototype.
4734 <item>Many platforms supported by cc65 do not have a realtime clock, so the
4735 returned value may not be valid.
4737 <tag/Availability/ISO 9899
4743 <sect1>toggle_videomode<label id="toggle_videomode"><p>
4747 <tag/Function/Toggle between 40 and 80 column mode.
4748 <tag/Header/<tt/<ref id="c128.h" name="c128.h">/
4749 <tag/Declaration/<tt/void toggle_videomode (void);/
4750 <tag/Description/Toggle between 40 and 80 column mode. The settings for the
4751 old mode (cursor position, color and so on) are saved and restored together
4753 <tag/Limits/<itemize>
4754 <item>The function is specific to the C128.
4756 <tag/Availability/C128
4758 <ref id="fast" name="fast">,
4759 <ref id="slow" name="slow">
4765 <sect1>tolower<label id="tolower"><p>
4769 <tag/Function/Convert a character into its lower case representation.
4770 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
4771 <tag/Declaration/<tt/int __fastcall__ tolower (int c);/
4772 <tag/Description/The function returns the given character converted to lower
4773 case. If the given character is not a letter, it is returned unchanged.
4774 <tag/Limits/<itemize>
4775 <item>The function is only available as fastcall function, so it may
4776 only be used in presence of a prototype.
4778 <tag/Availability/ISO 9899
4780 <ref id="islower" name="islower">,
4781 <ref id="isupper" name="isupper">,
4782 <ref id="toupper" name="toupper">
4788 <sect1>toupper<label id="toupper"><p>
4792 <tag/Function/Convert a character into its upper case representation.
4793 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
4794 <tag/Declaration/<tt/int __fastcall__ toupper (int c);/
4795 <tag/Description/The function returns the given character converted to upper
4796 case. If the given character is not a letter, it is returned unchanged.
4797 <tag/Limits/<itemize>
4798 <item>The function is only available as fastcall function, so it may
4799 only be used in presence of a prototype.
4801 <tag/Availability/ISO 9899
4803 <ref id="islower" name="islower">,
4804 <ref id="isupper" name="isupper">,
4805 <ref id="tolower" name="tolower">
4811 <sect1>ultoa<label id="ultoa"><p>
4815 <tag/Function/Convert an unsigned long integer into a string.
4816 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
4817 <tag/Declaration/<tt/char* __fastcall__ ultoa (unsigned long val, char* buf, int radix);/
4818 <tag/Description/<tt/itoa/ converts the unsigned long integer <tt/val/ into a
4819 string using <tt/radix/ as the base.
4820 <tag/Limits/<itemize>
4821 <item>There are no provisions to prevent a buffer overflow.
4822 <item>The function is non standard, so it is not available in strict ANSI mode.
4823 You should probably use <tt/sprintf/ instead.
4824 <item>The function is only available as fastcall function, so it may only be
4825 used in presence of a prototype.
4827 <tag/Availability/cc65
4829 <ref id="atoi" name="atoi">,
4830 <ref id="atol" name="atol">,
4831 <ref id="itoa" name="itoa">,
4832 <ref id="ltoa" name="ltoa">,
4833 <ref id="utoa" name="utoa">
4839 <sect1>unlink<label id="unlink"><p>
4843 <tag/Function/Delete a file.
4844 <tag/Header/<tt/<ref id="unistd.h" name="unistd.h">/
4845 <tag/Declaration/<tt/int __fastcall__ unlink (const char* name);/
4846 <tag/Description/<tt/unlink/ deletes the file with the given name. On success,
4847 zero is returned. On error, -1 is returned and <tt/errno/ is set to an error
4848 code describing the reason for the failure.
4851 <item>The use of this function is discouraged. Please use <tt/<ref id="remove"
4852 name="remove">/ instead, which is a native ANSI C function and does the same.
4853 <item>This function is not available on all cc65 targets (depends on the
4854 availability of file I/O).
4855 <item>The function is only available as fastcall function, so it may only
4856 be used in presence of a prototype.
4857 <item>Instead of <tt/unlink/, <tt/<ref id="remove" name="remove">/ should be
4858 used, which has the same semantics, but is more portable, because it conforms
4859 to the ISO C standard.
4861 <tag/Availability/POSIX 1003.1
4863 <ref id="remove" name="remove">
4865 #include <stdio.h>
4866 #include <unistd.h>
4868 #define FILENAME "helloworld"
4870 if (unlink (FILENAME) == 0) {
4871 printf ("We deleted %s successfully\n", FILENAME);
4873 printf ("There was a problem deleting %s\n", FILENAME);
4879 <sect1>utoa<label id="utoa"><p>
4883 <tag/Function/Convert an unsigned integer into a string.
4884 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
4885 <tag/Declaration/<tt/char* __fastcall__ utoa (unsigned val, char* buf, int radix);/
4886 <tag/Description/<tt/itoa/ converts the unsigned integer <tt/val/ into a string
4887 using <tt/radix/ as the base.
4888 <tag/Limits/<itemize>
4889 <item>There are no provisions to prevent a buffer overflow.
4890 <item>The function is non standard, so it is not available in strict ANSI mode.
4891 You should probably use <tt/sprintf/ instead.
4892 <item>The function is only available as fastcall function, so it may only be
4893 used in presence of a prototype.
4895 <tag/Availability/cc65
4897 <ref id="atoi" name="atoi">,
4898 <ref id="atol" name="atol">,
4899 <ref id="itoa" name="itoa">,
4900 <ref id="ltoa" name="ltoa">,
4901 <ref id="ultoa" name="ultoa">
4907 <sect1>vcprintf<label id="vcprintf"><p>
4911 <tag/Function/Formatted output to the console.
4912 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
4913 <tag/Declaration/<tt/int __fastcall__ vcprintf (const char* format, va_list ap);/
4914 <tag/Description/The arguments specified as a <tt/va_list/ are converted to
4915 text where necessary and formatted according to the format string given. The
4916 resulting string is output to the console. <tt/vcprintf/ supports the same
4917 format specifiers as <tt/vprintf/. <!-- <tt/<ref id="vprintf" name="vprintf">/. -->
4918 <tag/Limits/<itemize>
4919 <item>Like all other <tt/conio/ output functions, <tt/vcprintf/ distinguishes
4920 between <tt/\r/ and <tt/\n/.
4921 <item>The function is only available as fastcall function, so it may only be
4922 used in presence of a prototype.
4924 <tag/Availability/cc65
4926 <ref id="cprintf" name="cprintf">,
4927 <ref id="cputc" name="cputc">,
4928 <ref id="cputcxy" name="cputcxy">,
4929 <ref id="cputs" name="cputs">,
4930 <ref id="cputsxy" name="cputsxy">
4936 <sect1>wherex<label id="wherex"><p>
4940 <tag/Function/Return the current X position of the text mode cursor.
4941 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
4942 <tag/Declaration/<tt/unsigned char wherex (void);/
4943 <tag/Description/The function returns the current X position of the text mode
4944 cursor. Zero is returned for the leftmost screen position.
4945 <tag/Availability/cc65
4947 <ref id="gotox" name="gotox">,
4948 <ref id="gotoy" name="gotoy">,
4949 <ref id="gotoxy" name="gotoxy">,
4950 <ref id="wherey" name="wherey">
4956 <sect1>wherey<label id="wherey"><p>
4960 <tag/Function/Return the current Y position of the text mode cursor.
4961 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
4962 <tag/Declaration/<tt/unsigned char wherey (void);/
4963 <tag/Description/The function returns the current Y position of the text mode
4964 cursor. Zero is returned for the uppermost screen position.
4965 <tag/Availability/cc65
4967 <ref id="gotox" name="gotox">,
4968 <ref id="gotoy" name="gotoy">,
4969 <ref id="gotoxy" name="gotoxy">,
4970 <ref id="wherex" name="wherex">