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>
69 <item><ref id="get_ostype" name="get_ostype">
74 <sect1><tt/apple2enh.h/<label id="apple2enh.h"><p>
78 <item><ref id="get_ostype" name="get_ostype">
82 <item><ref id="videomode" name="videomode">
86 <sect1><tt/assert.h/<label id="assert.h"><p>
89 <item><ref id="assert" name="assert">
93 <sect1><tt/atari.h/<label id="atari.h"><p>
96 <item><ref id="get_ostype" name="get_ostype">
102 <sect1><tt/atmos.h/<label id="atmos.h"><p>
107 <sect1><tt/c128.h/<label id="c128.h"><p>
110 <item><ref id="c64mode" name="c64mode">
111 <item><ref id="fast" name="fast">
112 <item><ref id="slow" name="slow">
113 <item><ref id="toggle_videomode" name="toggle_videomode">
114 <item><ref id="videomode" name="videomode">
118 <sect1><tt/c16.h/<label id="c16.h"><p>
123 <sect1><tt/c64.h/<label id="c64.h"><p>
126 <item><ref id="get_ostype" name="get_ostype">
130 <sect1><tt/cbm510.h/<label id="cbm510.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/cbm610.h/<label id="cbm610.h"><p>
143 <item><ref id="peekbsys" name="peekbsys">
144 <item><ref id="peekwsys" name="peekwsys">
145 <item><ref id="pokebsys" name="pokebsys">
146 <item><ref id="pokewsys" name="pokewsys">
150 <sect1><tt/conio.h/<label id="conio.h"><p>
153 <item><ref id="bgcolor" name="bgcolor">
154 <item><ref id="bordercolor" name="bordercolor">
155 <item><ref id="cclear" name="cclear">
156 <item><ref id="cclearxy" name="cclearxy">
157 <item><ref id="cgetc" name="cgetc">
158 <item><ref id="chline" name="chline">
159 <item><ref id="chlinexy" name="chlinexy">
160 <item><ref id="clrscr" name="clrscr">
161 <item><ref id="cprintf" name="cprintf">
162 <item><ref id="cputc" name="cputc">
163 <item><ref id="cputcxy" name="cputcxy">
164 <item><ref id="cputs" name="cputs">
165 <item><ref id="cputsxy" name="cputsxy">
166 <item><ref id="cursor" name="cursor">
167 <item><ref id="cvline" name="cvline">
168 <item><ref id="cvlinexy" name="cvlinexy">
169 <item><ref id="gotox" name="gotox">
170 <item><ref id="gotoxy" name="gotoxy">
171 <item><ref id="gotoy" name="gotoy">
172 <item><ref id="kbhit" name="kbhit">
173 <item><ref id="revers" name="revers">
174 <item><ref id="screensize" name="screensize">
175 <item><ref id="textcolor" name="textcolor">
176 <item><ref id="vcprintf" name="vcprintf">
177 <item><ref id="wherex" name="wherex">
178 <item><ref id="wherey" name="wherey">
182 <sect1><tt/ctype.h/<label id="ctype.h"><p>
185 <item><ref id="isalnum" name="isalnum">
186 <item><ref id="isalpha" name="isalpha">
187 <item><ref id="isascii" name="isascii">
188 <item><ref id="isblank" name="isblank">
189 <item><ref id="iscntrl" name="iscntrl">
190 <item><ref id="isdigit" name="isdigit">
191 <item><ref id="isgraph" name="isgraph">
192 <item><ref id="islower" name="islower">
193 <item><ref id="isprint" name="isprint">
194 <item><ref id="ispunct" name="ispunct">
195 <item><ref id="isspace" name="isspace">
196 <item><ref id="isupper" name="isupper">
197 <item><ref id="isxdigit" name="isxdigit">
198 <item><ref id="tolower" name="tolower">
199 <item><ref id="toupper" name="toupper">
203 <sect1><tt/dbg.h/<label id="dbg.h"><p>
208 <sect1><tt/dio.h/<label id="dio.h"><p>
213 <sect1><tt/em.h/<label id="em.h"><p>
216 <item><ref id="em_commit" name="em_commit">
217 <item><ref id="em_copyfrom" name="em_copyfrom">
218 <item><ref id="em_copyto" name="em_copyto">
219 <item><ref id="em_install" name="em_install">
220 <item><ref id="em_load_driver" name="em_load_driver">
221 <item><ref id="em_map" name="em_map">
222 <item><ref id="em_pagecount" name="em_pagecount">
223 <item><ref id="em_uninstall" name="em_uninstall">
224 <item><ref id="em_unload" name="em_unload">
225 <item><ref id="em_use" name="em_use">
229 <sect1><tt/errno.h/<label id="errno.h"><p>
234 <sect1><tt/fcntl.h/<label id="fcntl.h"><p>
237 <item><ref id="close" name="close">
238 <item><ref id="creat" name="creat">
239 <item><ref id="open" name="open">
243 <sect1><tt/geos.h/<label id="geos.h"><p>
248 <sect1><tt/joystick.h/<label id="joystick.h"><p>
251 <item><ref id="joy_count" name="joy_count">
252 <item><ref id="joy_install" name="joy_install">
253 <item><ref id="joy_load_driver" name="joy_load_driver">
254 <item><ref id="joy_read" name="joy_read">
255 <item><ref id="joy_uninstall" name="joy_uninstall">
256 <item><ref id="joy_unload" name="joy_unload">
260 <sect1><tt/locale.h/<label id="locale.h"><p>
263 <item><ref id="localeconv" name="localeconv">
264 <item><ref id="setlocale" name="setlocale">
268 <sect1><tt/modload.h/<label id="modload.h"><p>
271 <item><ref id="mod_load" name="mod_load">
272 <item><ref id="mod_free" name="mod_free">
276 <sect1><tt/mouse.h/<label id="mouse.h"><p>
279 <item><ref id="mouse_load_driver" name="mouse_load_driver">
280 <item><ref id="mouse_unload" name="mouse_unload">
281 <item><ref id="mouse_install" name="mouse_install">
282 <item><ref id="mouse_uninstall" name="mouse_uninstall">
283 <item><ref id="mouse_hide" name="mouse_hide">
284 <item><ref id="mouse_show" name="mouse_show">
285 <item><ref id="mouse_setbox" name="mouse_setbox">
286 <item><ref id="mouse_getbox" name="mouse_getbox">
287 <item><ref id="mouse_move" name="mouse_move">
288 <item><ref id="mouse_buttons" name="mouse_buttons">
289 <item><ref id="mouse_pos" name="mouse_pos">
290 <item><ref id="mouse_info" name="mouse_info">
291 <item><ref id="mouse_ioctl" name="mouse_ioctl">
297 <sect1><tt/nes.h/<label id="nes.h"><p>
302 <sect1><tt/o65.h/<label id="o65.h"><p>
304 The <tt/o65.h/ header file contains structure and constant definitions that
305 may be used when dealing with files in <htmlurl
306 url="http://www.6502.org/users/andre/o65/fileformat.html" name="o65 format">.
307 It does not declare any functions.
310 <sect1><tt/peekpoke.h/<label id="peekpoke.h"><p>
313 <item><ref id="PEEK" name="PEEK">
314 <item><ref id="PEEKW" name="PEEKW">
315 <item><ref id="POKE" name="POKE">
316 <item><ref id="POKEW" name="POKEW">
320 <sect1><tt/pet.h/<label id="pet.h"><p>
325 <sect1><tt/plus4.h/<label id="plus4.h"><p>
330 <sect1><tt/serial.h/<label id="serial.h"><p>
334 <item><ref id="ser_load_driver" name="ser_load_driver">
335 <item><ref id="ser_unload" name="ser_unload">
336 <item><ref id="ser_install" name="ser_install">
337 <item><ref id="ser_uninstall" name="ser_uninstall">
338 <item><ref id="ser_open" name="ser_open">
339 <item><ref id="ser_close" name="ser_close">
340 <item><ref id="ser_get" name="ser_get">
341 <item><ref id="ser_put" name="ser_put">
342 <item><ref id="ser_status" name="ser_status">
343 <item><ref id="ser_ioctl" name="ser_ioctl">
350 <sect1><tt/setjmp.h/<label id="setjmp.h"><p>
353 <item><ref id="setjmp" name="setjmp">
354 <item><ref id="longjmp" name="longjmp">
358 <sect1><tt/signal.h/<label id="signal.h"><p>
361 <item><ref id="raise" name="raise">
362 <item><ref id="signal" name="signal">
366 <sect1><tt/stdarg.h/<label id="stdarg.h"><p>
371 <sect1><tt/stdbool.h/<label id="stdbool.h"><p>
376 <sect1><tt/stddef.h/<label id="stddef.h"><p>
379 <item><ref id="offsetof" name="offsetof">
383 <sect1><tt/stdio.h/<label id="stdio.h"><p>
386 <item><ref id="clearerr" name="clearerr">
387 <!-- <item><ref id="fclose" name="fclose"> -->
388 <!-- <item><ref id="fdopen" name="fdopen"> -->
389 <item><ref id="feof" name="feof">
390 <item><ref id="ferror" name="ferror">
391 <!-- <item><ref id="fflush" name="fflush"> -->
392 <!-- <item><ref id="fgetc" name="fgetc"> -->
393 <!-- <item><ref id="fgetpos" name="fgetpos"> -->
394 <!-- <item><ref id="fgets" name="fgets"> -->
395 <item><ref id="fileno" name="fileno">
396 <!-- <item><ref id="fopen" name="fopen"> -->
397 <!-- <item><ref id="fprintf" name="fprintf"> -->
398 <!-- <item><ref id="fputc" name="fputc"> -->
399 <!-- <item><ref id="fputs" name="fputs"> -->
400 <!-- <item><ref id="fread" name="fread"> -->
401 <!-- <item><ref id="freopen" name="freopen"> -->
402 <!-- <item><ref id="fscanf" name="fscanf"> -->
403 <!-- <item><ref id="fseek" name="fseek"> -->
404 <!-- <item><ref id="fsetpos" name="fsetpos"> -->
405 <!-- <item><ref id="ftell" name="ftell"> -->
406 <!-- <item><ref id="fwrite" name="fwrite"> -->
407 <!-- <item><ref id="getc" name="getc"> -->
408 <!-- <item><ref id="getchar" name="getchar"> -->
409 <!-- <item><ref id="gets" name="gets"> -->
410 <!-- <item><ref id="printf" name="printf"> -->
411 <!-- <item><ref id="putc" name="putc"> -->
412 <!-- <item><ref id="putchar" name="putchar"> -->
413 <!-- <item><ref id="puts" name="puts"> -->
414 <item><ref id="rename" name="rename">
415 <item><ref id="remove" name="remove">
416 <!-- <item><ref id="rewind" name="rewind"> -->
417 <!-- <item><ref id="scanf" name="scanf"> -->
418 <!-- <item><ref id="snprintf" name="snprintf"> -->
419 <!-- <item><ref id="sprintf" name="sprintf"> -->
420 <!-- <item><ref id="sscanf" name="sscanf"> -->
421 <!-- <item><ref id="vfprintf" name="vfprintf"> -->
422 <!-- <item><ref id="vfscanf" name="vfscanf"> -->
423 <!-- <item><ref id="vprintf" name="vprintf"> -->
424 <!-- <item><ref id="vscanf" name="vscanf"> -->
425 <!-- <item><ref id="vsnprintf" name="vsnprintf"> -->
426 <!-- <item><ref id="vsprintf" name="vsprintf"> -->
427 <!-- <item><ref id="vsscanf" name="vsscanf"> -->
433 <sect1><tt/stdlib.h/<label id="stdlib.h"><p>
436 <item><ref id="_heapadd" name="_heapadd">
437 <item><ref id="_heapblocksize" name="_heapblocksize">
438 <item><ref id="_heapmaxavail" name="_heapmaxavail">
439 <item><ref id="_heapmemavail" name="_heapmemavail">
440 <item><ref id="_poserror" name="_poserror">
441 <item><ref id="_randomize" name="_randomize">
442 <item><ref id="_swap" name="_swap">
443 <item><ref id="abort" name="abort">
444 <item><ref id="abs" name="abs">
445 <item><ref id="atexit" name="atexit">
446 <item><ref id="atoi" name="atoi">
447 <item><ref id="atol" name="atol">
448 <item><ref id="bsearch" name="bsearch">
449 <item><ref id="calloc" name="calloc">
450 <item><ref id="div" name="div">
451 <item><ref id="exit" name="exit">
452 <item><ref id="free" name="free">
453 <item><ref id="getenv" name="getenv">
454 <item><ref id="itoa" name="itoa">
455 <item><ref id="labs" name="labs">
456 <item><ref id="ltoa" name="ltoa">
457 <item><ref id="malloc" name="malloc">
458 <item><ref id="perror" name="perror">
459 <item><ref id="qsort" name="qsort">
460 <item><ref id="rand" name="rand">
461 <item><ref id="realloc" name="realloc">
462 <item><ref id="srand" name="srand">
463 <item><ref id="ultoa" name="ultoa">
464 <item><ref id="utoa" name="utoa">
468 <sect1><tt/string.h/<label id="string.h"><p>
471 <item><ref id="_stroserror" name="_stroserror">
472 <item><ref id="bzero" name="bzero">
473 <item><ref id="memchr" name="memchr">
474 <item><ref id="memcpy" name="memcpy">
475 <item><ref id="memmove" name="memmove">
476 <item><ref id="memset" name="memset">
477 <item><ref id="strcasecmp" name="strcasecmp">
478 <item><ref id="strcat" name="strcat">
479 <item><ref id="strchr" name="strchr">
480 <item><ref id="strcmp" name="strcmp">
481 <item><ref id="strcoll" name="strcoll">
482 <item><ref id="strcpy" name="strcpy">
483 <item><ref id="strcspn" name="strcspn">
484 <item><ref id="strdup" name="strdup">
485 <item><ref id="strerror" name="strerror">
486 <item><ref id="stricmp" name="stricmp">
487 <item><ref id="strlen" name="strlen">
488 <item><ref id="strlower" name="strlower">
489 <item><ref id="strlwr" name="strlwr">
490 <item><ref id="strncat" name="strncat">
491 <item><ref id="strncmp" name="strncmp">
492 <item><ref id="strncpy" name="strncpy">
493 <item><ref id="strrchr" name="strrchr">
494 <item><ref id="strspn" name="strspn">
495 <item><ref id="strstr" name="strstr">
496 <item><ref id="strtok" name="strtok">
497 <item><ref id="strxfrm" name="strxfrm">
498 <item><ref id="strupper" name="strupper">
499 <item><ref id="strupr" name="strupr">
505 <sect1><tt/tgi.h/<label id="tgi.h"><p>
508 <item><ref id="tgi_bar" name="tgi_bar">
509 <item><ref id="tgi_circle" name="tgi_circle">
510 <item><ref id="tgi_clear" name="tgi_clear">
511 <item><ref id="tgi_getcolor" name="tgi_getcolor">
512 <item><ref id="tgi_getcolorcount" name="tgi_getcolorcount">
513 <item><ref id="tgi_getdefpalette" name="tgi_getdefpalette">
514 <item><ref id="tgi_done" name="tgi_done">
515 <item><ref id="tgi_geterror" name="tgi_geterror">
516 <item><ref id="tgi_geterrormsg" name="tgi_geterrormsg">
517 <item><ref id="tgi_getmaxcolor" name="tgi_getmaxcolor">
518 <item><ref id="tgi_getmaxx" name="tgi_getmaxx">
519 <item><ref id="tgi_getmaxy" name="tgi_getmaxy">
520 <item><ref id="tgi_getpagecount" name="tgi_getpagecount">
521 <item><ref id="tgi_getpalette" name="tgi_getpalette">
522 <item><ref id="tgi_getpixel" name="tgi_getpixel">
523 <item><ref id="tgi_getxres" name="tgi_getxres">
524 <item><ref id="tgi_getyres" name="tgi_getyres">
525 <item><ref id="tgi_gotoxy" name="tgi_gotoxy">
526 <item><ref id="tgi_init" name="tgi_init">
527 <item><ref id="tgi_install" name="tgi_install">
528 <item><ref id="tgi_ioctl" name="tgi_ioctl">
529 <item><ref id="tgi_line" name="tgi_line">
530 <item><ref id="tgi_lineto" name="tgi_lineto">
531 <item><ref id="tgi_load" name="tgi_load">
532 <item><ref id="tgi_load_driver" name="tgi_load_driver">
533 <item><ref id="tgi_outtext" name="tgi_outtext">
534 <item><ref id="tgi_outtextxy" name="tgi_outtextxy">
535 <item><ref id="tgi_setcolor" name="tgi_setcolor">
536 <item><ref id="tgi_setdrawpage" name="tgi_setdrawpage">
537 <item><ref id="tgi_setpalette" name="tgi_setpalette">
538 <item><ref id="tgi_setpixel" name="tgi_setpixel">
539 <item><ref id="tgi_setviewpage" name="tgi_setviewpage">
540 <item><ref id="tgi_textheight" name="tgi_textheight">
541 <item><ref id="tgi_textstyle" name="tgi_textstyle">
542 <item><ref id="tgi_textwidth" name="tgi_textwidth">
543 <item><ref id="tgi_uninstall" name="tgi_uninstall">
544 <item><ref id="tgi_unload" name="tgi_unload">
547 <sect1><tt/time.h/<label id="time.h"><p>
550 <!-- <item><ref id="_systime" name="_systime"> -->
551 <!-- <item><ref id="asctime" name="asctime"> -->
552 <!-- <item><ref id="clock" name="clock"> -->
553 <!-- <item><ref id="ctime" name="ctime"> -->
554 <!-- <item><ref id="gmtime" name="gmtime"> -->
555 <!-- <item><ref id="localtime" name="localtime"> -->
556 <!-- <item><ref id="mktime" name="mktime"> -->
557 <!-- <item><ref id="strftime" name="strftime"> -->
558 <item><ref id="time" name="time">
564 <sect1><tt/unistd.h/<label id="unistd.h"><p>
567 <!-- <item><ref id="chdir" name="chdir"> -->
568 <!-- <item><ref id="getcwd" name="getcwd"> -->
569 <!-- <item><ref id="lseek" name="lseek"> -->
570 <!-- <item><ref id="mkdir" name="mkdir"> -->
571 <!-- <item><ref id="read" name="read"> -->
572 <!-- <item><ref id="rmdir" name="rmdir"> -->
573 <item><ref id="sleep" name="sleep">
574 <item><ref id="unlink" name="unlink">
575 <!-- <item><ref id="write" name="write"> -->
581 <sect1><tt/vic20.h/<label id="vic20.h"><p>
586 <sect1><tt/zlib.h/<label id="zlib.h"><p>
591 <sect>Alphabetical function reference<p>
593 <sect1>_heapadd<label id="_heapadd"><p>
597 <tag/Function/Add a block to the heap.
598 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
599 <tag/Declaration/<tt/void __fastcall__ _heapadd (void* mem, size_t size);/
600 <tag/Description/The function adds a block of raw memory to the heap.
603 <item>The minimum blocksize that can be added is 6 bytes; the function will
604 ignore smaller blocks.
606 <tag/Availability/cc65
608 <ref id="_heapblocksize" name="_heapblocksize">,
609 <ref id="_heapmaxavail" name="_heapmaxavail">,
610 <ref id="_heapmemavail" name="_heapmemavail">,
611 <ref id="calloc" name="calloc">,
612 <ref id="free" name="free">,
613 <ref id="malloc" name="malloc">,
614 <ref id="realloc" name="realloc">
620 <sect1>_heapblocksize<label id="_heapblocksize"><p>
624 <tag/Function/Return the size of an allocated block.
625 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
626 <tag/Declaration/<tt/size_t __fastcall__ _heapblocksize (const void* block);/
627 <tag/Description/The function returns the size of a block that must have
628 previously been allocated by <tt/<ref id="malloc" name="malloc">/, <tt/<ref
629 id="calloc" name="calloc">/ or <tt/<ref id="realloc" name="realloc">/.
632 <item>Passing a pointer to a block that was is not the result of one of the
633 allocation functions, or that has been free'd will give unpredicable results.
635 <tag/Availability/cc65
637 <ref id="_heapadd" name="_heapadd">,
638 <ref id="_heapmaxavail" name="_heapmaxavail">,
639 <ref id="_heapmemavail" name="_heapmemavail">,
640 <ref id="calloc" name="calloc">,
641 <ref id="free" name="free">,
642 <ref id="malloc" name="malloc">,
643 <ref id="realloc" name="realloc">
649 <sect1>_heapmaxavail<label id="_heapmaxavail"><p>
653 <tag/Function/Return the largest block that is available on the heap.
654 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
655 <tag/Declaration/<tt/size_t __fastcall__ _heapmaxavail (void);/
656 <tag/Description/The function returns the size of the largest block that may
657 be allocated from the heap using <tt/<ref id="malloc" name="malloc">/.
658 <tag/Availability/cc65
660 <ref id="_heapadd" name="_heapadd">,
661 <ref id="_heapblocksize" name="_heapblocksize">,
662 <ref id="_heapmemavail" name="_heapmemavail">,
663 <ref id="calloc" name="calloc">,
664 <ref id="free" name="free">,
665 <ref id="malloc" name="malloc">,
666 <ref id="realloc" name="realloc">
672 <sect1>_heapmemavail<label id="_heapmemavail"><p>
676 <tag/Function/Return the total available space on the heap.
677 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
678 <tag/Declaration/<tt/size_t __fastcall__ _heapmemavail (void);/
679 <tag/Description/The function returns the total number of bytes available on
683 <item>This function is of less use than usually assumed, since the returned
684 heap space may be available but not in one block. So even if this function
685 says that several times more heap space is available than needed, <ref
686 id="malloc" name="malloc"> may still return <tt/NULL/.
688 <tag/Availability/cc65
690 <ref id="_heapadd" name="_heapadd">,
691 <ref id="_heapblocksize" name="_heapblocksize">,
692 <ref id="_heapmaxavail" name="_heapmaxavail">,
693 <ref id="calloc" name="calloc">,
694 <ref id="free" name="free">,
695 <ref id="malloc" name="malloc">,
696 <ref id="realloc" name="realloc">
702 <sect1>_poserror<label id="_poserror"><p>
706 <tag/Function/Print an error message for the error in <tt/_oserrno/.
707 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
708 <tag/Declaration/<tt/void __fastcall__ _poserror (const char* msg);/
709 <tag/Description/<tt/_poserror/ prints an error message to <tt/stderr/. If
710 <tt/msg/ is not <tt/NULL/ and not an empty string, it is printed followed by
711 a colon and a blank. Then the error message for the current contents of
712 <tt/_oserrno/ are printed followed by a newline. The message output is the
713 same as returned by <tt/<ref id="_stroserror" name="_stroserror">/ with an
714 argument of <tt/_oserrno/.
717 <item>Since operating system specific error code are - you guessed it -
718 operating system specific, the value in <tt/_oserror/ and the message that is
719 printed depend on the cc65 target.
720 <item>The function is only available as fastcall function, so it may only
721 be used in presence of a prototype.
723 <tag/Availability/cc65
725 <ref id="_stroserror" name="_stroserror">,
726 <ref id="perror" name="perror">
732 <sect1>_randomize<label id="_randomize"><p>
736 <tag/Function/Initialize the pseudo random number generator.
737 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
738 <tag/Declaration/<tt/void _randomize (void);/
739 <tag/Description/The function initializes the random number generator with
740 a seed derived from fast changing hardware events, so the seed itself can be
741 considered random to a certain degree.
742 <tag/Limits/<itemize>
743 <item>The randomness of the seed depends on the machine hardware.
745 <tag/Availability/cc65
747 <ref id="rand" name="rand">,
748 <ref id="srand" name="srand">
754 <sect1>_stroserror<label id="_stroserror"><p>
758 <tag/Function/Return a string describing an OS specific error code.
759 <tag/Header/<tt/<ref id="string.h" name="string.h">/
760 <tag/Declaration/<tt/const char* __fastcall__ _stroserror (unsigned char errcode);/
761 <tag/Description/<tt/_stroserror/ will return a string describing the given
762 operating system specific error code.
763 <tag/Limits/<itemize>
764 <item>Since operating system specific error code are - you guessed it -
765 operating system specific, the parameter and the string returned depend on the
767 <item>The function is only available as fastcall function, so it may only be
768 used in presence of a prototype.
770 <tag/Availability/cc65
772 <ref id="strerror" name="strerror">
778 <sect1>_swap<label id="_swap"><p>
782 <tag/Function/Swap the contents of memory areas.
783 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
784 <tag/Declaration/<tt/void __fastcall__ _swap (void* p, void* q, size_t size);/
785 <tag/Description/<tt/_swap/ will swap (exchange) the contents of the two memory
786 areas pointed to by <tt/p/ and <tt/q/. Both memory areas are assumed to be
787 <tt/size/ bytes in size.
788 <tag/Limits/<itemize>
789 <item>The memory areas may not overlap, otherwise the results are undefined.
790 <item>The function is only available as fastcall function, so it may only be
791 used in presence of a prototype.
793 <tag/Availability/cc65
795 <ref id="memcpy" name="memcpy">,
796 <ref id="memmove" name="memmove">
802 <sect1>_sys<label id="_sys"><p>
806 <tag/Function/Call a subroutine passing register values.
807 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
808 <tag/Declaration/<tt/void __fastcall__ _sys (struct regs* r);/
809 <tag/Description/The function will call the subroutine at the address
810 specified in the <tt/pc/ member of the passed <tt/regs/ structure. All
811 registers and the CPU flags are set to the values given in the <tt/regs/
812 structure. On return from the subroutine, the new values of the registers and
813 flags are stored back overwriting the old values.
814 <tag/Limits/<itemize>
815 <item>Bits 4 and 5 of the flags value in the <tt/regs/ structure are ignored
816 when calling the subroutine (they are unchanged from their current values).
817 <item>The function is only available as fastcall function, so it may only be
818 used in presence of a prototype.
820 <tag/Availability/cc65
826 <sect1>BRK<label id="BRK"><p>
830 <tag/Function/Insert a 6502 BRK instrunction into the code.
831 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
832 <tag/Declaration/<tt/void BRK (void);/
833 <tag/Description/The function will insert a 6502 BRK instruction into the code
834 which may be used to trigger a debugger.
835 <tag/Limits/<itemize>
836 <item>The function is actually a macro.
837 <item>The inserted instruction may lead to unexpected results if no debugger
840 <tag/Availability/cc65
842 <ref id="CLI" name="CLI">,
843 <ref id="SEI" name="SEI">
849 <sect1>CLI<label id="CLI"><p>
853 <tag/Function/Insert a 6502 CLI instrunction into the code.
854 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
855 <tag/Declaration/<tt/void CLI (void);/
856 <tag/Description/The function will insert a 6502 CLI instruction into the code,
857 so interrupts are enabled. Enabling interrupts has no effects if they are
858 already enabled (the default).
859 <tag/Limits/<itemize>
860 <item>The function is actually a macro.
861 <item>Disabling interrupts may lead to unexpected results.
863 <tag/Availability/cc65
865 <ref id="BRK" name="BRK">,
866 <ref id="SEI" name="SEI">
872 <sect1>PEEK<label id="PEEK"><p>
876 <tag/Function/Read a byte from memory.
877 <tag/Header/<tt/<ref id="peekpoke.h" name="peekpoke.h">/
878 <tag/Declaration/<tt/unsigned char PEEK (unsigned addr);/
879 <tag/Description/The function will read the absolute memory given by <tt/addr/
880 and return the value read.
881 <tag/Limits/<itemize>
882 <item>The function is actually a macro.
883 <item>This function depends highly on the platform and environment.
885 <tag/Availability/cc65
887 <ref id="PEEKW" name="PEEKW">,
888 <ref id="POKE" name="POKE">
894 <sect1>PEEKW<label id="PEEKW"><p>
898 <tag/Function/Read a word (two bytes) from memory.
899 <tag/Header/<tt/<ref id="peekpoke.h" name="peekpoke.h">/
900 <tag/Declaration/<tt/unsigned PEEKW (unsigned addr);/
901 <tag/Description/The function will read the absolute memory given by <tt/addr/
902 and return the value read. The byte read from the higher address is the high
903 byte of the return value.
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>The order in which the two bytes are read is unspecified and may
908 depend of the address expression used.
910 <tag/Availability/cc65
912 <ref id="PEEK" name="PEEK">,
913 <ref id="POKE" name="POKE">
919 <sect1>POKE<label id="POKE"><p>
923 <tag/Function/Write a byte to memory.
924 <tag/Header/<tt/<ref id="peekpoke.h" name="peekpoke.h">/
925 <tag/Declaration/<tt/void POKE (unsigned addr, unsigned char val);/
926 <tag/Description/The function writes the value <tt/val/ to the absolute
927 memory address given by <tt/addr/.
928 <tag/Limits/<itemize>
929 <item>The function is actually a macro.
930 <item>This function depends highly on the platform and environment.
931 <item>Careless use will cause the program to act strange or may crash the
934 <tag/Availability/cc65
936 <ref id="PEEK" name="PEEK">,
937 <ref id="POKEW" name="POKEW">
943 <sect1>POKEW<label id="POKEW"><p>
947 <tag/Function/Write a word (two bytes) to memory.
948 <tag/Header/<tt/<ref id="peekpoke.h" name="peekpoke.h">/
949 <tag/Declaration/<tt/void POKEW (unsigned addr, unsigned val);/
950 <tag/Description/The function writes the value <tt/val/ to the absolute
951 memory address given by <tt/addr/. The low byte of <tt/val/ is written to
952 the <tt/addr/, the high byte is written to <tt/addr+1/.
953 <tag/Limits/<itemize>
954 <item>The function is actually a macro.
955 <item>This function depends highly on the platform and environment.
956 <item>Careless use will cause the program to act strange or may crash the
958 <item>The order in which the two bytes are written is unspecified and may
959 depend of the address expression used.
961 <tag/Availability/cc65
963 <ref id="PEEK" name="PEEK">,
964 <ref id="POKE" name="POKE">
970 <sect1>SEI<label id="SEI"><p>
974 <tag/Function/Insert a 6502 SEI instrunction into the code.
975 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
976 <tag/Declaration/<tt/void SEI (void);/
977 <tag/Description/The function will insert a 6502 SEI instruction into the code,
978 so interrupts are disabled. Note that non maskable interrupts cannot be
980 <tag/Limits/<itemize>
981 <item>The function is actually a macro.
982 <item>Disabling interrupts may lead to unexpected results.
984 <tag/Availability/cc65
986 <ref id="BRK" name="BRK">,
987 <ref id="CLI" name="CLI">
993 <sect1>abort<label id="abort"><p>
997 <tag/Function/Terminates a program abnormally.
998 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
999 <tag/Declaration/<tt/void abort (void);/
1000 <tag/Description/<tt/abort/ raises <tt/SIGABRT/, writes a termination message
1001 on stderr, then terminates the program with an exit code of 3.
1002 <tag/Availability/ISO 9899
1004 <ref id="assert" name="assert">,
1005 <ref id="exit" name="exit">,
1006 <ref id="raise" name="raise">
1012 <sect1>abs<label id="abs"><p>
1016 <tag/Function/Returns the absolute value of an integer.
1017 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1018 <tag/Declaration/<tt/int __fastcall__ abs (int v);/
1019 <tag/Description/<tt/abs/ returns the absolute value of the argument passed to
1021 <tag/Limits/<itemize>
1022 <item>The return value is undefined if <tt/INT_MIN/ is passed to the function.
1023 <item>The function is only available as fastcall function, so it may only be
1024 used in presence of a prototype.
1026 <tag/Availability/ISO 9899
1028 <ref id="labs" name="labs">
1034 <sect1>assert<label id="assert"><p>
1038 <tag/Function/Test a condition and possibly abort.
1039 <tag/Header/<tt/<ref id="assert.h" name="assert.h">/
1040 <tag/Declaration/<tt/void assert (int cond);/
1041 <tag/Description/<tt/assert/ is a macro that expands to a <tt/id/
1042 statement. If the condition evaluates t zero (false), assert prints a message
1043 on stderr and aborts the program.
1044 <tag/Limits/<itemize>
1045 <item>The function is actually a macro.
1047 <tag/Availability/ISO 9899
1049 <ref id="abort" name="abort">,
1050 <ref id="exit" name="exit">
1056 <sect1>atexit<label id="atexit"><p>
1060 <tag/Function/Register an exit function.
1061 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1062 <tag/Declaration/<tt/int __fastcall__ atexit (void (*exitfunc) (void));/
1063 <tag/Description/<tt/atexit/ registers the function pointed to by
1064 <tt/exitfunc/ as an exit function. Exit functions are called when the program
1065 terminates, they are called in LIFO order (the last function registered is
1066 called first). <tt/atexit/ returns zero on success and a nonzero value on
1068 <tag/Limits/<itemize>
1069 <item>A maximum of 5 exit functions can be registered.
1070 <item>There is no way to unregister an exit function.
1071 <item>The function is only available as fastcall function, so it may only be
1072 used in presence of a prototype.
1074 <tag/Availability/ISO 9899
1076 <ref id="abort" name="abort">,
1077 <ref id="exit" name="exit">
1083 <sect1>atoi<label id="atoi"><p>
1087 <tag/Function/Convert a string to an integer.
1088 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1089 <tag/Declaration/<tt/int __fastcall__ atoi (const char* s);/
1090 <tag/Description/<tt/atoi/ converts the given string into an integer.
1091 Conversion stops as soon as any invalid character is encountered.
1092 <tag/Limits/<itemize>
1093 <item>There is no way to detect any conversion errors.
1094 <item>The function does not check for an numerical overflow when converting.
1095 <item>The function is only available as fastcall function, so it may only be
1096 used in presence of a prototype.
1098 <tag/Availability/ISO 9899
1100 <ref id="atol" name="atol">,
1101 <ref id="itoa" name="itoa">,
1102 <ref id="ltoa" name="ltoa">,
1103 <ref id="ultoa" name="ultoa">,
1104 <ref id="utoa" name="utoa">
1110 <sect1>atol<label id="atol"><p>
1114 <tag/Function/Convert a string to a long integer.
1115 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1116 <tag/Declaration/<tt/long __fastcall__ atol (const char* s);/
1117 <tag/Description/<tt/atol/ converts the given string into a long integer.
1118 Conversion stops as soon as any invalid character is encountered.
1119 <tag/Limits/<itemize>
1120 <item>There is no way to detect any conversion errors.
1121 <item>The function does not check for an numerical overflow when converting.
1122 <item>The function is only available as fastcall function, so it may only be
1123 used in presence of a prototype.
1125 <tag/Availability/ISO 9899
1127 <ref id="atoi" name="atoi">,
1128 <ref id="itoa" name="itoa">,
1129 <ref id="ltoa" name="ltoa">,
1130 <ref id="ultoa" name="ultoa">,
1131 <ref id="utoa" name="utoa">
1137 <sect1>bgcolor<label id="bgcolor"><p>
1141 <tag/Function/Set the background text color.
1142 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1143 <tag/Declaration/<tt/unsigned char __fastcall__ bgcolor (unsigned char color);/
1144 <tag/Description/The function will set a new background color and return the
1145 old (current) one. The background color is valid for the whole text output
1146 area of the screen, not just for new text.
1147 <tag/Limits/<itemize>
1148 <item>Background colors are system dependent. The function may have no effect
1149 on systems where the background color cannot be changed.
1150 <item>The function is only available as fastcall function, so it may only be
1151 used in presence of a prototype.
1153 <tag/Availability/cc65
1155 <ref id="bordercolor" name="bordercolor">,
1156 <ref id="textcolor" name="textcolor">
1162 <sect1>bordercolor<label id="bordercolor"><p>
1166 <tag/Function/Set the border (frame) color.
1167 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1168 <tag/Declaration/<tt/unsigned char __fastcall__ bordercolor (unsigned char color);/
1169 <tag/Description/The function will set a new border color. It returns the old
1170 (current) border color.
1171 <tag/Limits/<itemize>
1172 <item>Border colors are system dependent. The function may have no effect
1173 on systems where the border color cannot be changed.
1174 <item>The function is only available as fastcall function, so it may only
1175 be used in presence of a prototype.
1177 <tag/Availability/cc65
1179 <ref id="bgcolor" name="bgcolor">,
1180 <ref id="textcolor" name="textcolor">
1186 <sect1>bsearch<label id="bsearch"><p>
1190 <tag/Function/Do a binary search in a sorted array.
1191 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1192 <tag/Declaration/<tt/void* __fastcall__ bsearch (const void* key,
1193 const void* base, size_t n, size_t size,
1194 int (*cmp) (const void*, const void*));/
1195 <tag/Description/<tt/bsearch/ searches a sorted array for a member that
1196 matches the one pointed to by <tt/key/. <tt/base/ is the address of the array,
1197 <tt/n/ is the number of elements, <tt/size/ the size of an element and <tt/cmp/
1198 the function used to compare the members against the key. The function returns
1199 a pointer to the member found, or <tt/NULL/ if there was no match.
1202 <item>The contents of the array must be sorted in ascending order according to
1203 the compare function given.
1204 <item>If there are multiple members that match the key, the function will
1205 return one of the members.
1206 <item>The function is only available as fastcall function, so it may only
1207 be used in presence of a prototype.
1209 <tag/Availability/ISO 9899
1211 <ref id="qsort" name="qsort">
1217 <sect1>bzero<label id="bzero"><p>
1221 <tag/Function/Fill a memory area with zeroes.
1222 <tag/Header/<tt/<ref id="string.h" name="string.h">/
1223 <tag/Declaration/<tt/void __fastcall__ bzero (void* p, size_t count);/
1224 <tag/Description/<tt/bzero/ fills the memory area pointed to by <tt/p/ with
1228 <item>The function is non standard and therefore only available in non ANSI
1229 mode. You should use <tt/<ref id="memset" name="memset">/ instead.
1230 <item>The function is only available as fastcall function, so it may only
1231 be used in presence of a prototype.
1233 <tag/Availability/cc65
1235 <ref id="_swap" name="_swap">,
1236 <ref id="memcpy" name="memcpy">,
1237 <ref id="memmove" name="memmove">,
1238 <ref id="memset" name="memset">,
1244 <sect1>c64mode<label id="c64mode"><p>
1248 <tag/Function/Switch the C128 into C64 compatible mode.
1249 <tag/Header/<tt/<ref id="c128.h" name="c128.h">/
1250 <tag/Declaration/<tt/void c64mode (void);/
1251 <tag/Description/The function will cause the machine to reboot into C64 mode.
1252 <tag/Limits/<itemize>
1253 <item>The function is specific to the C128.
1254 <item>The function will not return to the caller.
1256 <tag/Availability/C128
1262 <sect1>calloc<label id="calloc"><p>
1266 <tag/Function/Allocate and clear memory.
1267 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1268 <tag/Declaration/<tt/void* __fastcall__ calloc (size_t n, size_t size);/
1269 <tag/Description/<tt/calloc/ allocates memory for an array of <tt/n/ elements
1270 of size <tt/size/, clears the whole block with binary zeroes and returns a
1271 pointer to it. On error (not enough memory available), <tt/calloc/ returns
1275 <item>Clearing the memory may not have the expected effect on all platforms:
1276 pointers in the block may not be <tt/NULL/ and floating point variables may
1277 not be zero (0.0). In other words: The "clearing" effect of this function
1278 should be used with care for portable programs.
1279 <item>The function is only available as fastcall function, so it may only
1280 be used in presence of a prototype.
1282 <tag/Availability/ISO 9899
1284 <ref id="_heapadd" name="_heapadd">,
1285 <ref id="_heapblocksize" name="_heapblocksize">,
1286 <ref id="_heapmaxavail" name="_heapmaxavail">,
1287 <ref id="_heapmemavail" name="_heapmemavail">,
1288 <ref id="free" name="free">,
1289 <ref id="malloc" name="malloc">,
1290 <ref id="realloc" name="realloc">
1296 <sect1>cclear<label id="cclear"><p>
1300 <tag/Function/Clear part of a line (write a given number of spaces).
1301 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1302 <tag/Declaration/<tt/void __fastcall__ cclear (unsigned char length);/
1303 <tag/Description/The function clears part of a line by writing <tt/length/
1304 spaces in the current text color.
1305 <tag/Limits/<itemize>
1306 <item>The function is only available as fastcall function, so it may
1307 only be used in presence of a prototype.
1309 <tag/Availability/cc65
1311 <ref id="cclearxy" name="cclearxy">,
1312 <ref id="clrscr" name="clrscr">
1318 <sect1>cclearxy<label id="cclearxy"><p>
1322 <tag/Function/Clear part of a line (write a given number of spaces) starting
1323 at a specific screen position.
1324 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1325 <tag/Declaration/<tt/void __fastcall__ cclearxy (unsigned char x, unsigned char y, unsigned char length);/
1326 <tag/Description/The function moves the cursor to a specific position, and
1327 will then clear part of the line by writing <tt/length/ spaces in the current
1329 <tag/Limits/<itemize>
1330 <item>The function is only available as fastcall function, so it may
1331 only be used in presence of a prototype.
1333 <tag/Availability/cc65
1335 <ref id="cclear" name="cclear">,
1336 <ref id="clrscr" name="clrscr">
1342 <sect1>cgetc<label id="cgetc"><p>
1346 <tag/Function/Read a character from the keyboard.
1347 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1348 <tag/Declaration/<tt/char cgetc (void);/
1349 <tag/Description/The function reads a character from the keyboard. If there is
1350 no character available, <tt/cgetc/ waits until the user presses a key. If the
1351 cursor is enabled by use of the <tt/cursor/ function, a blinking cursor is
1352 displayed while waiting.
1353 <tag/Limits/<itemize>
1354 <item>If the system supports a keyboard buffer, <tt/cgetc/ will fetch a key
1355 from this buffer and wait only if the buffer is empty.
1357 <tag/Availability/cc65
1359 <ref id="cursor" name="cursor">,
1360 <ref id="kbhit" name="kbhit">
1366 <sect1>chline<label id="chline"><p>
1370 <tag/Function/Output a horizontal line in text mode.
1371 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1372 <tag/Declaration/<tt/void __fastcall__ chline (unsigned char length);/
1373 <tag/Description/The function outputs a horizontal line with the given length
1374 starting at the current cursor position.
1375 <tag/Limits/<itemize>
1376 <item>The character used to draw the horizontal line is system dependent.
1377 If available, a line drawing character is used. Drawing a line that is partially
1378 off screen leads to undefined behaviour.
1379 <item>The function is only available as fastcall function, so it may only be
1380 used in presence of a prototype.
1382 <tag/Availability/cc65
1384 <ref id="chlinexy" name="chlinexy">,
1385 <ref id="cvline" name="cvline">,
1386 <ref id="cvlinexy" name="cvlinexy">
1392 <sect1>chlinexy<label id="chlinexy"><p>
1396 <tag/Function/Output a horizontal line at a given position in text mode.
1397 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1398 <tag/Declaration/<tt/void __fastcall__ chlinexy (unsigned char x, unsigned char y, unsigned char length);/
1399 <tag/Description/The function outputs a horizontal line with the given length
1400 starting at a given position.
1401 <tag/Limits/<itemize>
1402 <item>The character used to draw the horizontal line is system dependent.
1403 If available, a line drawing character is used. Drawing a line that is partially
1404 off screen leads to undefined behaviour.
1405 <item>The function is only available as fastcall function, so it may only be
1406 used in presence of a prototype.
1408 <tag/Availability/cc65
1410 <ref id="chline" name="chline">,
1411 <ref id="cvline" name="cvline">,
1412 <ref id="cvlinexy" name="cvlinexy">
1418 <sect1>clearerr<label id="clearerr"><p>
1422 <tag/Function/Clear error and end-of-file status of a stream.
1423 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
1424 <tag/Declaration/<tt/void __fastcall__ clearerr (FILE* f);/
1425 <tag/Description/<tt/clearerr/ clears the error and end-of-file status
1426 indicators for the stream <tt/f/.
1427 <tag/Limits/<itemize>
1428 <item>The function is only available as fastcall function, so it may only be
1429 used in presence of a prototype.
1431 <tag/Availability/ISO 9899
1433 <ref id="feof" name="feof">,
1434 <ref id="ferror" name="ferror">
1440 <sect1>clrscr<label id="clrscr"><p>
1444 <tag/Function/Clear the text screen.
1445 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1446 <tag/Declaration/<tt/void clrscr (void);/
1447 <tag/Description/The function clears the text screen and moves the cursor to
1448 the upper left corner.
1449 <tag/Availability/cc65
1451 <ref id="cclear" name="cclear">,
1452 <ref id="cclearxy" name="cclearxy">
1458 <sect1>close<label id="close"><p>
1462 <tag/Function/Close a file descriptor.
1463 <tag/Header/<tt/<ref id="fcntl.h" name="fcntl.h">/
1464 <tag/Declaration/<tt/int __fastcall__ close (int fd);/
1465 <tag/Description/The function closes the given file descriptor. It returns zero
1466 on success and -1 on error. If an error occurs, the cause can be determined by
1467 reading the <tt/errno/ variable.
1468 <tag/Limits/<itemize>
1469 <item>The function is only available as fastcall function, so it may only
1470 be used in presence of a prototype.
1472 <tag/Availability/POSIX 1003.1
1474 <ref id="creat" name="creat">,
1475 <ref id="open" name="open">
1481 <sect1>creat<label id="creat"><p>
1485 <tag/Function/Create a file.
1486 <tag/Header/<tt/<ref id="fcntl.h" name="fcntl.h">/
1487 <tag/Declaration/<tt/int __fastcall__ creat (const char* name, unsigned mode);/
1488 <tag/Description/<tt/creat/ creates a new file and returns the file descriptor
1489 associated with it. On error, -1 is returned and an error code is stored in
1491 <tag/Limits/<itemize>
1492 <item><tt/creat/ is identical to calling <tt/<ref id="open" name="open">/ with
1493 <tt/flags/ equal to <tt/O_WRONLY | O_CREAT | O_TRUNC/.
1494 <item>The function is only available as fastcall function, so it may only
1495 be used in presence of a prototype.
1497 <tag/Availability/POSIX 1003.1
1499 <ref id="close" name="close">,
1500 <ref id="open" name="open">
1506 <sect1>cprintf<label id="cprintf"><p>
1510 <tag/Function/Formatted output to the console.
1511 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1512 <tag/Declaration/<tt/int cprintf (const char* format, ...);/
1513 <tag/Description/The arguments are converted to text where necessary and
1514 formatted according to the format string given. The resulting string is output
1515 to the console. <tt/cprintf/ supports the same format specifiers as
1516 <tt/printf/. <!-- <tt/<ref id="printf" name="printf">/. -->
1517 <tag/Limits/<itemize>
1518 <item>Like all other <tt/conio/ output functions, <tt/cprintf/ distinguishes
1519 between <tt/\r/ and <tt/\n/.
1521 <tag/Availability/cc65
1523 <ref id="cputc" name="cputc">,
1524 <ref id="cputcxy" name="cputcxy">,
1525 <ref id="cputs" name="cputs">,
1526 <ref id="cputsxy" name="cputsxy">,
1527 <ref id="vcprintf" name="vcprintf">
1533 <sect1>cputc<label id="cputc"><p>
1537 <tag/Function/Output a character directly to the console.
1538 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1539 <tag/Declaration/<tt/void __fastcall__ cputc (char c);/
1540 <tag/Description/Output one character to the console at the current cursor
1542 <tag/Limits/<itemize>
1543 <item>Like all other <tt/conio/ output functions, <tt/cputc/ distinguishes
1544 between <tt/\r/ and <tt/\n/.
1545 <item>The function is only available as fastcall function, so it may only
1546 be used in presence of a prototype.
1548 <tag/Availability/cc65
1550 <ref id="cprintf" name="cprintf">,
1551 <ref id="cputcxy" name="cputcxy">,
1552 <ref id="cputs" name="cputs">,
1553 <ref id="cputsxy" name="cputsxy">,
1554 <ref id="vcprintf" name="vcprintf">
1560 <sect1>cputcxy<label id="cputcxy"><p>
1564 <tag/Function/Output a character at a specific screen position.
1565 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1566 <tag/Declaration/<tt/void __fastcall__ cputcxy (unsigned char x, unsigned char y, char c);/
1567 <tag/Description/<tt/cputcxy/ moves the cursor to the given x/y position on
1568 the screen and outputs one character.
1569 <tag/Limits/<itemize>
1570 <item>Like all other <tt/conio/ output functions, <tt/cputcxy/ distinguishes
1571 between <tt/\r/ and <tt/\n/.
1572 <item>The function is only available as fastcall function, so it may only
1573 be used in presence of a prototype.
1575 <tag/Availability/cc65
1577 <ref id="cprintf" name="cprintf">,
1578 <ref id="cputc" name="cputc">,
1579 <ref id="cputs" name="cputs">,
1580 <ref id="cputsxy" name="cputsxy">,
1581 <ref id="vcprintf" name="vcprintf">
1587 <sect1>cputs<label id="cputs"><p>
1591 <tag/Function/Output a string directly to the console.
1592 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1593 <tag/Declaration/<tt/void __fastcall__ cputs (const char* s);/
1594 <tag/Description/The function outputs the given string on the console at the
1595 current cursor position.
1596 <tag/Limits/<itemize>
1597 <item>Like all other <tt/conio/ output functions, <tt/cputs/ distinguishes
1598 between <tt/\r/ and <tt/\n/.
1599 <item>The function is only available as fastcall function, so it may only
1600 be used in presence of a prototype.
1602 <tag/Availability/cc65
1604 <ref id="cprintf" name="cprintf">,
1605 <ref id="cputc" name="cputc">,
1606 <ref id="cputcxy" name="cputcxy">,
1607 <ref id="cputsxy" name="cputsxy">,
1608 <ref id="vcprintf" name="vcprintf">
1614 <sect1>cputsxy<label id="cputsxy"><p>
1618 <tag/Function/Output a string to the console at a given position.
1619 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1620 <tag/Declaration/<tt/void __fastcall__ cputsxy (unsigned char x, unsigned char y, const char* s);/
1621 <tag/Description/<tt/cputsxy/ moves the cursor to the given x/y position,
1622 and outputs the string <tt/s/.
1623 <tag/Limits/<itemize>
1624 <item>Like all other <tt/conio/ output functions, <tt/cputsxy/ distinguishes
1625 between <tt/\r/ and <tt/\n/.
1626 <item>The function is only available as fastcall function, so it may only
1627 be used in presence of a prototype.
1629 <tag/Availability/cc65
1631 <ref id="cprintf" name="cprintf">,
1632 <ref id="cputc" name="cputc">,
1633 <ref id="cputcxy" name="cputcxy">,
1634 <ref id="cputs" name="cputs">,
1635 <ref id="vcprintf" name="vcprintf">
1641 <sect1>cursor<label id="cursor"><p>
1645 <tag/Function/Enable/disable a blinking cursor when waiting for keyboard input.
1646 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1647 <tag/Declaration/<tt/unsigned char __fastcall__ cursor (unsigned char onoff);/
1648 <tag/Description/If the argument to the function is non zero, a blinking cursor
1649 will be enabled when the <tt/cgetc/ function waits for input from the keyboard.
1650 If the argument is zero, <tt/cgetc/ will wait without a blinking cursor.
1651 <tag/Limits/<itemize>
1652 <item>The function is only available as fastcall function, so it may only
1653 be used in presence of a prototype.
1655 <tag/Availability/cc65
1657 <ref id="cgetc" name="cgetc">,
1658 <ref id="kbhit" name="kbhit">
1664 <sect1>cvline<label id="cvline"><p>
1668 <tag/Function/Output a vertical line in text mode.
1669 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1670 <tag/Declaration/<tt/void __fastcall__ cvline (unsigned char length);/
1671 <tag/Description/The function outputs a vertical line with the given length
1672 starting at the current cursor position.
1673 <tag/Limits/<itemize>
1674 <item>The character used to draw the vertical line is system dependent.
1675 If available, a line drawing character is used. Drawing a line that is partially
1676 off screen leads to undefined behaviour.
1677 <item>The function is only available as fastcall function, so it may only be
1678 used in presence of a prototype.
1680 <tag/Availability/cc65
1682 <ref id="chline" name="chline">,
1683 <ref id="chlinexy" name="chlinexy">,
1684 <ref id="cvlinexy" name="cvlinexy">
1690 <sect1>cvlinexy<label id="cvlinexy"><p>
1694 <tag/Function/Output a vertical line at a given position in text mode.
1695 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1696 <tag/Declaration/<tt/void __fastcall__ cvlinexy (unsigned char x, unsigned char y, unsigned char length);/
1697 <tag/Description/The function outputs a vertical line with the given length
1698 starting at a given position.
1699 <tag/Limits/<itemize>
1700 <item>The character used to draw the vertical line is system dependent.
1701 If available, a line drawing character is used. Drawing a line that is partially
1702 off screen leads to undefined behaviour.
1703 <item>The function is only available as fastcall function, so it may only be
1704 used in presence of a prototype.
1706 <tag/Availability/cc65
1708 <ref id="chline" name="chline">,
1709 <ref id="chlinexy" name="chlinexy">,
1710 <ref id="cvline" name="cvline">
1716 <sect1>div<label id="div"><p>
1720 <tag/Function/Divide two ints and return quotient and remainder.
1721 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1722 <tag/Declaration/<tt/div_t __fastcall__ div (int numer, int denom);/
1723 <tag/Description/<tt/div/ divides <tt/numer/ by <tt/denom/ and returns the
1724 quotient and remainder in a <tt/div_t/ structure.
1727 <item>The function is only available as fastcall function, so it may only
1728 be used in presence of a prototype.
1730 <tag/Availability/ISO 9899
1738 <sect1>em_commit<label id="em_commit"><p>
1742 <tag/Function/Commit changes into extended memory.
1743 <tag/Header/<tt/<ref id="em.h" name="em.h">/
1744 <tag/Declaration/<tt/void __fastcall__ em_commit (void);/
1745 <tag/Description/Commit changes in the memory window to extended storage. If
1746 the contents of the memory window have been changed, these changes may be lost
1747 if <tt/<ref id="em_map" name="em_map">/, <tt/<ref id="em_use" name="em_use">/,
1748 <tt/<ref id="em_copyfrom" name="em_copyfrom">/ or <tt/<ref id="em_copyto"
1749 name="em_copyto">/ are called without calling <tt/em_commit/ first.
1750 <tag/Limits/<itemize>
1751 <item>Calling <tt/em_commit/ does not necessarily mean that changes to the
1752 memory window are discarded, it does just mean that the drivers is allowed
1754 <item>The function is only available as fastcall function, so it may only be
1755 used in presence of a prototype.
1756 <item>The function produces undefined results if no extended memory driver is
1759 <tag/Availability/cc65
1761 <ref id="em_load_driver" name="em_load_driver">,
1762 <ref id="em_map" name="em_map">,
1763 <ref id="em_use" name="em_use">
1769 <sect1>em_copyfrom<label id="em_copyfrom"><p>
1773 <tag/Function/Copy from extended into normal memory.
1774 <tag/Header/<tt/<ref id="em.h" name="em.h">/
1775 <tag/Declaration/<tt/void __fastcall__ em_copyfrom (const struct em_copy* copy_data);/
1776 <tag/Description/Copy data from extended memory into linear memory. Source and
1777 target addresses as well as the number of bytes to transfer are specified in
1778 the <tt/em_copy/ structure that is passed as a parameter.
1779 <tag/Limits/<itemize>
1780 <item>Calling <tt/em_copyfrom/ will invalidate the memory window, so if you
1781 made any changes to the data in the window, call <tt/<ref id="em_commit"
1782 name="em_commit">/ first, or the changes are lost.
1783 <item>The function is only available as fastcall function, so it may only be
1784 used in presence of a prototype.
1785 <item>The function produces undefined results if no extended memory driver is
1788 <tag/Availability/cc65
1790 <ref id="em_commit" name="em_commit">,
1791 <ref id="em_copyto" name="em_copyto">,
1792 <ref id="em_load_driver" name="em_load_driver">
1798 <sect1>em_copyto<label id="em_copyto"><p>
1802 <tag/Function/Copy from normal into extended memory.
1803 <tag/Header/<tt/<ref id="em.h" name="em.h">/
1804 <tag/Declaration/<tt/void __fastcall__ em_copyto (const struct em_copy* copy_data);/
1805 <tag/Description/Copy data from linear into extended memory. Source and
1806 target addresses as well as the number of bytes to transfer are specified in
1807 the <tt/em_copy/ structure that is passed as a parameter.
1808 <tag/Limits/<itemize>
1809 <item>Calling <tt/em_copyto/ will invalidate the memory window, so if you
1810 made any changes to the data in the window, call <tt/<ref id="em_commit"
1811 name="em_commit">/ first, or the changes are lost.
1812 <item>The function is only available as fastcall function, so it may only be
1813 used in presence of a prototype.
1814 <item>The function produces undefined results if no extended memory driver is
1817 <tag/Availability/cc65
1819 <ref id="em_commit" name="em_commit">,
1820 <ref id="em_copyfrom" name="em_copyfrom">,
1821 <ref id="em_load_driver" name="em_load_driver">
1827 <sect1>em_install<label id="em_install"><p>
1831 <tag/Function/Install an already loaded extended memory driver.
1832 <tag/Header/<tt/<ref id="em.h" name="em.h">/
1833 <tag/Declaration/<tt/unsigned char _fastcall__ em_install (void* driver);/
1834 <tag/Description/The function installs an already loaded extended memory driver
1835 and returns an error code. The function may be used to install a driver linked
1836 statically to the program.
1837 <tag/Limits/<itemize>
1838 <item>Not all drivers are able to detect if the supported hardware is really
1840 <item>The function is only available as fastcall function, so it may only be
1841 used in presence of a prototype.
1843 <tag/Availability/cc65
1845 <ref id="em_load_driver" name="em_load_driver">,
1846 <ref id="em_uninstall" name="em_uninstall">,
1847 <ref id="em_unload" name="em_unload">
1853 <sect1>em_load_driver<label id="em_load_driver"><p>
1857 <tag/Function/Load and initialize an extended memory driver.
1858 <tag/Header/<tt/<ref id="em.h" name="em.h">/
1859 <tag/Declaration/<tt/void __fastcall__ em_load_driver (const char* name);/
1860 <tag/Description/Load an extended memory driver into memory and initialize
1861 it. The function returns an error code that tells if all this has been
1863 <tag/Limits/<itemize>
1864 <item>Not all drivers are able to detect if the supported hardware is really
1866 <item>The function is only available as fastcall function, so it may only be
1867 used in presence of a prototype.
1868 <item>The driver is loaded by name, so currently you must know the type of
1869 extended memory that should be supported. There is no autodetect capability.
1871 <tag/Availability/cc65
1873 <ref id="em_unload" name="em_unload">
1879 <sect1>em_map<label id="em_map"><p>
1883 <tag/Function/Make a page of extended memory accessible.
1884 <tag/Header/<tt/<ref id="em.h" name="em.h">/
1885 <tag/Declaration/<tt/void* __fastcall__ em_map (unsigned page);/
1886 <tag/Description/The function maps one page of extended memory into linear
1887 memory and returns a pointer to the page frame. Depending on the hardware
1888 and driver, the data is either mapped into the address space or transfered
1889 into a buffer. If you don't need the actual contents of the page (for example
1890 because you're going to overwrite it completely), it is better to call
1891 <tt/<ref id="em_use" name="em_use">/ instead. <tt/em_use/ will not transfer the
1892 data if it is possible to avoid that.
1893 <tag/Limits/<itemize>
1894 <item>Calling <tt/em_map/ will invalidate the memory window, so if you
1895 made any changes to the data in the window, call <tt/<ref id="em_commit"
1896 name="em_commit">/ first, or the changes are lost.
1897 <item>The function is only available as fastcall function, so it may only be
1898 used in presence of a prototype.
1899 <item>The function produces undefined results if no extended memory driver is
1902 <tag/Availability/cc65
1904 <ref id="em_commit" name="em_commit">,
1905 <ref id="em_load_driver" name="em_load_driver">,
1906 <ref id="em_use" name="em_use">
1912 <sect1>em_pagecount<label id="em_pagecount"><p>
1916 <tag/Function/Return the number of available extended memory pages.
1917 <tag/Header/<tt/<ref id="em.h" name="em.h">/
1918 <tag/Declaration/<tt/unsigned __fastcall__ em_pagecount (void);/
1919 <tag/Description/The function returns the size of the extended memory supported
1920 by the driver in 256 byte pages.
1921 <tag/Limits/<itemize>
1922 <item>The function returns zero if no extended memory driver is loaded.
1923 <item>The function may return zero if the supported hardware was not detected.
1925 <tag/Availability/cc65
1927 <ref id="em_load_driver" name="em_load_driver">
1933 <sect1>em_uninstall<label id="em_uninstall"><p>
1937 <tag/Function/Uninstall an already loaded extended memory driver.
1938 <tag/Header/<tt/<ref id="em.h" name="em.h">/
1939 <tag/Declaration/<tt/unsigned char __fastcall__ em_install (void);/
1940 <tag/Description/The function uninstalls an already loaded extended memory
1941 driver but doesn't remove it from memory.
1942 <tag/Limits/<itemize>
1943 <item>If the driver has been loaded using <tt/<ref id="em_load_driver"
1944 name="em_load_driver">/, <tt/<ref id="em_unload" name="em_unload">/
1945 should be used instead of <tt/em_uninstall/ so the driver is also removed
1947 <item>The function is only available as fastcall function, so it may only be
1948 used in presence of a prototype.
1950 <tag/Availability/cc65
1952 <ref id="em_install" name="em_install">,
1953 <ref id="em_load_driver" name="em_load_driver">,
1954 <ref id="em_unload" name="em_unload">
1960 <sect1>em_unload<label id="em_unload"><p>
1964 <tag/Function/Unload an extended memory driver.
1965 <tag/Header/<tt/<ref id="em.h" name="em.h">/
1966 <tag/Declaration/<tt/unsigned char __fastcall__ em_unload (void);/
1967 <tag/Description/The function unloads a loaded extended memory driver and
1968 frees all memory allocated for the driver.
1969 <tag/Limits/<itemize>
1970 <item>The function does nothing if no driver is loaded.
1972 <tag/Availability/cc65
1974 <ref id="em_load_driver" name="em_load_driver">
1980 <sect1>em_use<label id="em_use"><p>
1984 <tag/Function/Prepare an extended memory page for use.
1985 <tag/Header/<tt/<ref id="em.h" name="em.h">/
1986 <tag/Declaration/<tt/void* __fastcall__ em_use (unsigned page);/
1987 <tag/Description/The function maps one page of extended memory into linear
1988 memory and returns a pointer to the page frame. This function is similar to
1989 <tt/<ref id="em_map" name="em_map">/, but will not transfer data into the
1990 actual memory window in the assumption that the existing data is wrong or
1991 will get overwritten.
1992 <tag/Limits/<itemize>
1993 <item>Calling <tt/em_use/ will invalidate the memory window, so if you
1994 made any changes to the data in the window, call <tt/<ref id="em_commit"
1995 name="em_commit">/ first, or the changes are lost.
1996 <item>The function is only available as fastcall function, so it may only be
1997 used in presence of a prototype.
1998 <item>The function produces undefined results if no extended memory driver is
2001 <tag/Availability/cc65
2003 <ref id="em_commit" name="em_commit">,
2004 <ref id="em_load_driver" name="em_load_driver">,
2005 <ref id="em_map" name="em_map">
2011 <sect1>exit<label id="exit"><p>
2015 <tag/Function/Terminate the program.
2016 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
2017 <tag/Declaration/<tt/void __fastcall__ exit (int status);/
2018 <tag/Description/<tt/exit/ terminates the program. The argument specifies the
2019 return code of the program. Before termination, all files are closed, buffered
2020 output is written and any functions registered with <tt/<ref id="atexit"
2021 name="atexit">/ are called. Common values for status are <tt/EXIT_SUCCESS/ and
2022 <tt/EXIT_FAILURE/ which are also defined in <tt/<ref id="stdlib.h"
2024 <tag/Limits/<itemize>
2025 <item>The function is only available as fastcall function, so it may only
2026 be used in presence of a prototype.
2027 <item>It depends on the host machine if the program return code can be
2028 evaluated or is ignored.
2030 <tag/Availability/ISO 9899
2032 <ref id="abort" name="abort">,
2033 <ref id="exit" name="exit">
2039 <sect1>fast<label id="fast"><p>
2043 <tag/Function/Switch the C128 into 2MHz mode.
2044 <tag/Header/<tt/<ref id="c128.h" name="c128.h">/
2045 <tag/Declaration/<tt/void fast (void);/
2046 <tag/Description/The function will switch the clock of the C128 to 2MHz. This
2047 will nearly double the speed compared to slow mode.
2048 <tag/Limits/<itemize>
2049 <item>The function is specific to the C128.
2050 <item>2MHz clock will not work in 40 column mode.
2052 <tag/Availability/C128
2054 <ref id="slow" name="slow">,
2055 <ref id="toggle_videomode" name="toggle_videomode">,
2056 <ref id="videomode" name="videomode">
2062 <sect1>feof<label id="feof"><p>
2066 <tag/Function/Return the end-of-file indicator of a stream.
2067 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
2068 <tag/Declaration/<tt/int __fastcall__ feof (FILE* f);/
2069 <tag/Description/<tt/feof/ tests the end-of-file indicator ofthe stream
2070 <tt/f/, and returns a non zero value if it is set.
2071 <tag/Limits/<itemize>
2072 <item>The indicator is set only after a read past the end of a file is
2074 <item>The function is only available as fastcall function, so it may only be
2075 used in presence of a prototype.
2077 <tag/Availability/ISO 9899
2079 <ref id="feof" name="clearerr">,
2080 <ref id="ferror" name="ferror">
2086 <sect1>ferror<label id="ferror"><p>
2090 <tag/Function/Return the error indicator of a stream.
2091 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
2092 <tag/Declaration/<tt/int __fastcall__ ferror (FILE* f);/
2093 <tag/Description/<tt/ferror/ tests the error indicator of the stream
2094 <tt/f/, and returns a non zero value if it is set.
2095 <tag/Limits/<itemize>
2096 <item>The function is only available as fastcall function, so it may only be
2097 used in presence of a prototype.
2099 <tag/Availability/ISO 9899
2101 <ref id="feof" name="clearerr">,
2102 <ref id="ferror" name="feof">
2108 <sect1>fileno<label id="fileno"><p>
2112 <tag/Function/Return the file handle used by a stream.
2113 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
2114 <tag/Declaration/<tt/int __fastcall__ fileno (FILE* f);/
2115 <tag/Description/The <tt/fileno/ function returns the file handle used
2116 internally by a C stream. This file handle (an integer) can be used as a
2117 handle for the POSIX input/output functions.
2118 <tag/Limits/<itemize>
2119 <item>The function is only available as fastcall function, so it may only be
2120 used in presence of a prototype.
2121 <item>Mixing C file I/O functions and POSIX file I/O functions for the same
2122 file may have unpredictable results.
2124 <tag/Availability/POSIX 1003.1
2126 <ref id="creat" name="creat">,
2127 <ref id="open" name="open"> <!-- , -->
2128 <!-- <ref id="read" name="read">, -->
2129 <!-- <ref id="write" name="write"> -->
2135 <sect1>free<label id="free"><p>
2139 <tag/Function/Free a block of dynamic memory.
2140 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
2141 <tag/Declaration/<tt/void __fastcall__ free (void* block);/
2142 <tag/Description/Free a block of dynamic memory previously allocated with
2143 <tt/<ref id="malloc" name="malloc">/, <tt/<ref id="calloc" name="calloc">/
2144 or <tt/<ref id="realloc" name="realloc">/. As an exception, if the passed
2145 pointer is <tt/NULL/, no action is performed.
2148 <item>Passing an already free'd block to <tt/free/ again will cause undefined
2149 behaviour and may crash your program.
2150 <item>The function is only available as fastcall function, so it may only
2151 be used in presence of a prototype.
2153 <tag/Availability/ISO 9899
2155 <ref id="_heapadd" name="_heapadd">,
2156 <ref id="_heapblocksize" name="_heapblocksize">,
2157 <ref id="_heapmaxavail" name="_heapmaxavail">,
2158 <ref id="_heapmemavail" name="_heapmemavail">,
2159 <ref id="calloc" name="calloc">,
2160 <ref id="malloc" name="malloc">,
2161 <ref id="realloc" name="realloc">
2167 <sect1>get_ostype<label id="get_ostype"><p>
2171 <tag/Function/The function returns the operating system, the program runs on.
2172 <tag/Header/<tt/<ref id="apple2.h" name="apple2.h">,
2173 <ref id="atari.h" name="atari.h">, <ref id="c64.h" name="c64.h">/
2174 <tag/Declaration/<tt/unsigned char get_ostype (void);/
2175 <tag/Description/<tt/get_ostype/ is machine dependent and does not exist for
2176 all supported targets. If it exists, it returns a number that identifies the
2177 operating system or machine type, the program runs on. The machine dependent
2178 header files define constants that can be used to check the return code.
2179 <tag/Limits/<itemize>
2180 <item>The function does not exist on all platforms.
2181 <item>The return codes are platform dependent.
2183 <tag/Availability/cc65 (not all platforms)
2189 <sect1>getenv<label id="getenv"><p>
2193 <tag/Function/Return a value from the environment.
2194 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
2195 <tag/Declaration/<tt/char* __fastcall__ getenv (const char* name);/
2196 <tag/Description/The function searches the environment for an entry that
2197 matches <tt/name/ and returns its value. The environment consists of a list
2198 of strings in the form <tt/name=value/. If there is no match, <tt/getenv/
2200 <tag/Limits/<itemize>
2201 <item>What exactly is stored in the environment depends on the machine the
2202 program is running on.
2203 <item>The function is only available as fastcall function, so it may only
2204 be used in presence of a prototype.
2206 <tag/Availability/ISO 9899
2212 <sect1>getcpu<label id="getcpu"><p>
2216 <tag/Function/Determine on which CPU the program is running.
2217 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
2218 <tag/Declaration/<tt/unsigned char getcpu (void);/
2219 <tag/Description/The function checks on which CPU the code is running. It
2220 returns one of the constants<itemize>
2222 <item><tt/CPU_65C02/
2223 <item><tt/CPU_65816/
2225 <tag/Limits/<itemize>
2226 <item>Other, more exotic CPU types are not disinguished.
2228 <tag/Availability/cc65
2234 <sect1>gotox<label id="gotox"><p>
2238 <tag/Function/Move the text mode cursor to a new X position.
2239 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2240 <tag/Declaration/<tt/void __fastcall__ gotox (unsigned char x);/
2241 <tag/Description/The function moves the text mode cursor to the specified X
2242 position while leaving the Y position untouched. The leftmost position on the
2243 screen has the coordinate 0.
2244 <tag/Limits/<itemize>
2245 <item>The function is only available as fastcall function, so it may
2246 only be used in presence of a prototype.
2247 <item>Invalid values for the X position (out of screen coordinates) may
2248 lead to undefined behaviour.
2250 <tag/Availability/cc65
2252 <ref id="gotoy" name="gotoy">,
2253 <ref id="gotoxy" name="gotoxy">,
2254 <ref id="wherex" name="wherex">,
2255 <ref id="wherey" name="wherey">
2261 <sect1>gotoxy<label id="gotoxy"><p>
2265 <tag/Function/Move the text mode cursor to a new position.
2266 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2267 <tag/Declaration/<tt/void __fastcall__ gotoxy (unsigned char x, unsigned char y);/
2268 <tag/Description/The function moves the text mode cursor to the specified
2269 position. The leftmost position on the screen has the X coordinate 0, the
2270 topmost line has the Y coordinate 0.
2271 <tag/Limits/<itemize>
2272 <item>The function is only available as fastcall function, so it may only be
2273 used in presence of a prototype.
2274 <item>Invalid values for any of both coordinates (out of screen positions) may
2275 lead to undefined behaviour.
2277 <tag/Availability/cc65
2279 <ref id="gotox" name="gotox">,
2280 <ref id="gotoy" name="gotoy">,
2281 <ref id="wherex" name="wherex">,
2282 <ref id="wherey" name="wherey">
2288 <sect1>gotoy<label id="gotoy"><p>
2292 <tag/Function/Move the text mode cursor to a new Y position.
2293 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2294 <tag/Declaration/<tt/void __fastcall__ gotoy (unsigned char x);/
2295 <tag/Description/The function moves the text mode cursor to the specified Y
2296 position while leaving the X position untouched. The uppermost position on the
2297 screen has the coordinate 0.
2298 <tag/Limits/<itemize>
2299 <item>The function is only available as fastcall function, so it may
2300 only be used in presence of a prototype.
2301 <item>Invalid values for the Y position (out of screen coordinates) may lead
2302 to undefined behaviour.
2304 <tag/Availability/cc65
2306 <ref id="gotox" name="gotox">,
2307 <ref id="gotoxy" name="gotoxy">,
2308 <ref id="wherex" name="wherex">,
2309 <ref id="wherey" name="wherey">
2315 <sect1>isalnum<label id="isalnum"><p>
2319 <tag/Function/Check if a given character is a letter or digit.
2320 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2321 <tag/Declaration/<tt/int __fastcall__ isalnum (int c);/
2322 <tag/Description/The function returns a value of zero if the given argument
2323 is a letter or digit. The return value is non zero if the character
2325 <tag/Limits/<itemize>
2326 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2327 inline sequence generated by the macro will not work correctly for values
2328 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2329 this range. The non inline function may be accessed by <tt/#undef/'ing
2331 <item>When compiling without <tt/-Os/, the function is only available as
2332 fastcall function, so it may only be used in presence of a prototype.
2334 <tag/Availability/ISO 9899
2336 <ref id="isalpha" name="isalpha">,
2337 <ref id="isascii" name="isascii">,
2338 <ref id="isblank" name="isblank">,
2339 <ref id="iscntrl" name="iscntrl">,
2340 <ref id="isdigit" name="isdigit">,
2341 <ref id="isgraph" name="isgraph">,
2342 <ref id="islower" name="islower">,
2343 <ref id="isprint" name="isprint">,
2344 <ref id="ispunct" name="ispunct">,
2345 <ref id="isspace" name="isspace">,
2346 <ref id="isupper" name="isupper">,
2347 <ref id="isxdigit" name="isxdigit">
2353 <sect1>isalpha<label id="isalpha"><p>
2357 <tag/Function/Check if a given character is a letter.
2358 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2359 <tag/Declaration/<tt/int __fastcall__ isalpha (int c);/
2360 <tag/Description/The function returns a value of zero if the given argument
2361 is a letter. The return value is non zero if the character is anything else.
2362 <tag/Limits/<itemize>
2363 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2364 inline sequence generated by the macro will not work correctly for values
2365 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2366 this range. The non inline function may be accessed by <tt/#undef/'ing the
2368 <item>When compiling without <tt/-Os/, the function is only available as
2369 fastcall function, so it may only be used in presence of a prototype.
2371 <tag/Availability/ISO 9899
2373 <ref id="isalnum" name="isalnum">,
2374 <ref id="isascii" name="isascii">,
2375 <ref id="isblank" name="isblank">,
2376 <ref id="iscntrl" name="iscntrl">,
2377 <ref id="isdigit" name="isdigit">,
2378 <ref id="isgraph" name="isgraph">,
2379 <ref id="islower" name="islower">,
2380 <ref id="isprint" name="isprint">,
2381 <ref id="ispunct" name="ispunct">,
2382 <ref id="isspace" name="isspace">,
2383 <ref id="isupper" name="isupper">,
2384 <ref id="isxdigit" name="isxdigit">
2390 <sect1>isascii<label id="isascii"><p>
2394 <tag/Function/Check if a given character is in the ASCII (0..127) range.
2395 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2396 <tag/Declaration/<tt/int __fastcall__ isascii (int c);/
2397 <tag/Description/The function returns a value of zero if the given argument
2398 is in the range 0..127 (the range of valid ASCII characters) and a non zero
2400 <tag/Limits/<itemize>
2401 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2402 inline sequence generated by the macro will not work correctly for values
2403 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2404 this range. The non inline function may be accessed by <tt/#undef/'ing the
2406 <item>When compiling without <tt/-Os/, the function is only available as
2407 fastcall function, so it may only be used in presence of a prototype.
2409 <tag/Availability/ISO 9899
2411 <ref id="isalnum" name="isalnum">,
2412 <ref id="isalpha" name="isalpha">,
2413 <ref id="isblank" name="isblank">,
2414 <ref id="iscntrl" name="iscntrl">,
2415 <ref id="isdigit" name="isdigit">,
2416 <ref id="isgraph" name="isgraph">,
2417 <ref id="islower" name="islower">,
2418 <ref id="isprint" name="isprint">,
2419 <ref id="ispunct" name="ispunct">,
2420 <ref id="isspace" name="isspace">,
2421 <ref id="isupper" name="isupper">,
2422 <ref id="isxdigit" name="isxdigit">
2428 <sect1>isblank<label id="isblank"><p>
2432 <tag/Function/Check if a given character is a space or tab.
2433 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2434 <tag/Declaration/<tt/int __fastcall__ isblank (int c);/
2435 <tag/Description/The function returns a value of zero if the given argument
2436 is a space or tab character. The return value is non zero if the character
2438 <tag/Limits/<itemize>
2439 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2440 inline sequence generated by the macro will not work correctly for values
2441 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2442 this range. The non inline function may be accessed by <tt/#undef/'ing the
2444 <item>When compiling without <tt/-Os/, the function is only available as
2445 fastcall function, so it may only be used in presence of a prototype.
2447 <tag/Availability/cc65
2449 <ref id="isalnum" name="isalnum">,
2450 <ref id="isalpha" name="isalpha">,
2451 <ref id="isascii" name="isascii">,
2452 <ref id="iscntrl" name="iscntrl">,
2453 <ref id="isdigit" name="isdigit">,
2454 <ref id="isgraph" name="isgraph">,
2455 <ref id="islower" name="islower">,
2456 <ref id="isprint" name="isprint">,
2457 <ref id="ispunct" name="ispunct">,
2458 <ref id="isspace" name="isspace">,
2459 <ref id="isupper" name="isupper">,
2460 <ref id="isxdigit" name="isxdigit">
2466 <sect1>iscntrl<label id="iscntrl"><p>
2470 <tag/Function/Check if a given character is a control character.
2471 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2472 <tag/Declaration/<tt/int __fastcall__ iscntrl (int c);/
2473 <tag/Description/The function returns a value of zero if the given argument
2474 is a control character. The return value is non zero if the character
2476 <tag/Limits/<itemize>
2477 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2478 inline sequence generated by the macro will not work correctly for values
2479 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2480 this range. The non inline function may be accessed by <tt/#undef/'ing the
2482 <item>When compiling without <tt/-Os/, the function is only available as
2483 fastcall function, so it may only be used in presence of a prototype.
2485 <tag/Availability/ISO 9899
2487 <ref id="isalnum" name="isalnum">,
2488 <ref id="isalpha" name="isalpha">,
2489 <ref id="isascii" name="isascii">,
2490 <ref id="isblank" name="isblank">,
2491 <ref id="isdigit" name="isdigit">,
2492 <ref id="isgraph" name="isgraph">,
2493 <ref id="islower" name="islower">,
2494 <ref id="isprint" name="isprint">,
2495 <ref id="ispunct" name="ispunct">,
2496 <ref id="isspace" name="isspace">,
2497 <ref id="isupper" name="isupper">,
2498 <ref id="isxdigit" name="isxdigit">
2504 <sect1>isdigit<label id="isdigit"><p>
2508 <tag/Function/Check if a given character is a digit.
2509 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2510 <tag/Declaration/<tt/int __fastcall__ isdigit (int c);/
2511 <tag/Description/The function returns a value of zero if the given argument
2512 is a digit. The return value is non zero if the character is anything else.
2513 <tag/Limits/<itemize>
2514 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2515 inline sequence generated by the macro will not work correctly for values
2516 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2517 this range. The non inline function may be accessed by <tt/#undef/'ing the
2519 <item>When compiling without <tt/-Os/, the function is only available as
2520 fastcall function, so it may only be used in presence of a prototype.
2522 <tag/Availability/ISO 9899
2524 <ref id="isalnum" name="isalnum">,
2525 <ref id="isalpha" name="isalpha">,
2526 <ref id="isascii" name="isascii">,
2527 <ref id="isblank" name="isblank">,
2528 <ref id="iscntrl" name="iscntrl">,
2529 <ref id="isgraph" name="isgraph">,
2530 <ref id="islower" name="islower">,
2531 <ref id="isprint" name="isprint">,
2532 <ref id="ispunct" name="ispunct">,
2533 <ref id="isspace" name="isspace">,
2534 <ref id="isupper" name="isupper">,
2535 <ref id="isxdigit" name="isxdigit">
2541 <sect1>isgraph<label id="isgraph"><p>
2545 <tag/Function/Check if a given character is a printable character (except
2547 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2548 <tag/Declaration/<tt/int __fastcall__ isgraph (int c);/
2549 <tag/Description/The function returns a value of zero if the given argument
2550 is a printable character with the exception of space. The return value is non
2551 zero if the character is anything else.
2552 <tag/Limits/<itemize>
2553 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2554 inline sequence generated by the macro will not work correctly for values
2555 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2556 this range. The non inline function may be accessed by <tt/#undef/'ing the
2558 <item>When compiling without <tt/-Os/, the function is only available as
2559 fastcall function, so it may only be used in presence of a prototype.
2561 <tag/Availability/ISO 9899
2563 <ref id="isalnum" name="isalnum">,
2564 <ref id="isalpha" name="isalpha">,
2565 <ref id="isascii" name="isascii">,
2566 <ref id="isblank" name="isblank">,
2567 <ref id="iscntrl" name="iscntrl">,
2568 <ref id="isdigit" name="isdigit">,
2569 <ref id="islower" name="islower">,
2570 <ref id="isprint" name="isprint">,
2571 <ref id="ispunct" name="ispunct">,
2572 <ref id="isspace" name="isspace">,
2573 <ref id="isupper" name="isupper">,
2574 <ref id="isxdigit" name="isxdigit">
2580 <sect1>islower<label id="islower"><p>
2584 <tag/Function/Check if a given character is a lower case letter.
2585 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2586 <tag/Declaration/<tt/int __fastcall__ islower (int c);/
2587 <tag/Description/The function returns a value of zero if the given argument
2588 is a lower case letter. The return value is non zero if the character is
2590 <tag/Limits/<itemize>
2591 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2592 inline sequence generated by the macro will not work correctly for values
2593 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2594 this range. The non inline function may be accessed by <tt/#undef/'ing the
2596 <item>When compiling without <tt/-Os/, the function is only available as
2597 fastcall function, so it may only be used in presence of a prototype.
2599 <tag/Availability/ISO 9899
2601 <ref id="isalnum" name="isalnum">,
2602 <ref id="isalpha" name="isalpha">,
2603 <ref id="isascii" name="isascii">,
2604 <ref id="isblank" name="isblank">,
2605 <ref id="iscntrl" name="iscntrl">,
2606 <ref id="isdigit" name="isdigit">,
2607 <ref id="isgraph" name="isgraph">,
2608 <ref id="isprint" name="isprint">,
2609 <ref id="ispunct" name="ispunct">,
2610 <ref id="isspace" name="isspace">,
2611 <ref id="isupper" name="isupper">,
2612 <ref id="isxdigit" name="isxdigit">
2618 <sect1>isprint<label id="isprint"><p>
2622 <tag/Function/Check if a given character is a printable character.
2623 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2624 <tag/Declaration/<tt/int __fastcall__ isprint (int c);/
2625 <tag/Description/The function returns a value of zero if the given argument
2626 is a printable character (this includes the space character). The return value
2627 is non zero if the character is anything else.
2628 <tag/Limits/<itemize>
2629 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2630 inline sequence generated by the macro will not work correctly for values
2631 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2632 this range. The non inline function may be accessed by <tt/#undef/'ing the
2634 <item>When compiling without <tt/-Os/, the function is only available as
2635 fastcall function, so it may only be used in presence of a prototype.
2637 <tag/Availability/ISO 9899
2639 <ref id="isalnum" name="isalnum">,
2640 <ref id="isalpha" name="isalpha">,
2641 <ref id="isascii" name="isascii">,
2642 <ref id="isblank" name="isblank">,
2643 <ref id="iscntrl" name="iscntrl">,
2644 <ref id="isdigit" name="isdigit">,
2645 <ref id="isgraph" name="isgraph">,
2646 <ref id="islower" name="islower">,
2647 <ref id="ispunct" name="ispunct">,
2648 <ref id="isspace" name="isspace">,
2649 <ref id="isupper" name="isupper">,
2650 <ref id="isxdigit" name="isxdigit">
2656 <sect1>ispunct<label id="ispunct"><p>
2660 <tag/Function/Check if a given character is a printable character but not a
2661 space or an alphanumeric character.
2662 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2663 <tag/Declaration/<tt/int __fastcall__ ispunct (int c);/
2664 <tag/Description/The function returns a value of zero if the given argument
2665 is a printable character, but not a space or anything alphanumeric. The return
2666 value is non zero if the character is anything else.
2667 <tag/Limits/<itemize>
2668 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2669 inline sequence generated by the macro will not work correctly for values
2670 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2671 this range. The non inline function may be accessed by <tt/#undef/'ing the
2673 <item>When compiling without <tt/-Os/, the function is only available as
2674 fastcall function, so it may only be used in presence of a prototype.
2676 <tag/Availability/ISO 9899
2678 <ref id="isalnum" name="isalnum">,
2679 <ref id="isalpha" name="isalpha">,
2680 <ref id="isascii" name="isascii">,
2681 <ref id="isblank" name="isblank">,
2682 <ref id="iscntrl" name="iscntrl">,
2683 <ref id="isdigit" name="isdigit">,
2684 <ref id="isgraph" name="isgraph">,
2685 <ref id="islower" name="islower">,
2686 <ref id="isprint" name="isprint">,
2687 <ref id="isspace" name="isspace">,
2688 <ref id="isupper" name="isupper">,
2689 <ref id="isxdigit" name="isxdigit">
2695 <sect1>isspace<label id="isspace"><p>
2699 <tag/Function/Check if a given character is a a white-space character.
2700 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2701 <tag/Declaration/<tt/int __fastcall__ isspace (int c);/
2702 <tag/Description/The function returns a value of zero if the given argument
2703 is a white space character. The return value is non zero if the character is
2704 anything else. The standard white space characters are: space, formfeed ('\f'),
2705 newline ('\n'), carriage return ('\r'), horizontal tab ('\t'), and vertical tab
2707 <tag/Limits/<itemize>
2708 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2709 inline sequence generated by the macro will not work correctly for values
2710 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2711 this range. The non inline function may be accessed by <tt/#undef/'ing the
2713 <item>When compiling without <tt/-Os/, the function is only available as
2714 fastcall function, so it may only be used in presence of a prototype.
2716 <tag/Availability/ISO 9899
2718 <ref id="isalnum" name="isalnum">,
2719 <ref id="isalpha" name="isalpha">,
2720 <ref id="isascii" name="isascii">,
2721 <ref id="isblank" name="isblank">,
2722 <ref id="iscntrl" name="iscntrl">,
2723 <ref id="isdigit" name="isdigit">,
2724 <ref id="isgraph" name="isgraph">,
2725 <ref id="islower" name="islower">,
2726 <ref id="isprint" name="isprint">,
2727 <ref id="ispunct" name="ispunct">,
2728 <ref id="isupper" name="isupper">,
2729 <ref id="isxdigit" name="isxdigit">
2735 <sect1>isupper<label id="isupper"><p>
2739 <tag/Function/Check if a given character is an upper case letter.
2740 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2741 <tag/Declaration/<tt/int __fastcall__ isupper (int c);/
2742 <tag/Description/The function returns a value of zero if the given argument
2743 is an upper case letter. The return value is non zero if the character is
2745 <tag/Limits/<itemize>
2746 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2747 inline sequence generated by the macro will not work correctly for values
2748 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2749 this range. The non inline function may be accessed by <tt/#undef/'ing the
2751 <item>When compiling without <tt/-Os/, the function is only available as
2752 fastcall function, so it may only be used in presence of a prototype.
2754 <tag/Availability/ISO 9899
2756 <ref id="isalnum" name="isalnum">,
2757 <ref id="isalpha" name="isalpha">,
2758 <ref id="isascii" name="isascii">,
2759 <ref id="isblank" name="isblank">,
2760 <ref id="iscntrl" name="iscntrl">,
2761 <ref id="isdigit" name="isdigit">,
2762 <ref id="isgraph" name="isgraph">,
2763 <ref id="islower" name="islower">,
2764 <ref id="isprint" name="isprint">,
2765 <ref id="ispunct" name="ispunct">,
2766 <ref id="isspace" name="isspace">,
2767 <ref id="isxdigit" name="isxdigit">
2773 <sect1>isxdigit<label id="isxdigit"><p>
2777 <tag/Function/Check if a given character is a hexadecimal digit.
2778 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2779 <tag/Declaration/<tt/int __fastcall__ isxdigit (int c);/
2780 <tag/Description/The function returns a value of zero if the given argument
2781 is a hexadecimal digit (0..9, a..f and A..F). The return value is non zero
2782 if the character is anything else.
2783 <tag/Limits/<itemize>
2784 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2785 inline sequence generated by the macro will not work correctly for values
2786 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2787 this range. The non inline function may be accessed by <tt/#undef/'ing the
2789 <item>When compiling without <tt/-Os/, the function is only available as
2790 fastcall function, so it may only be used in presence of a prototype.
2792 <tag/Availability/ISO 9899
2794 <ref id="isalnum" name="isalnum">,
2795 <ref id="isalpha" name="isalpha">,
2796 <ref id="isascii" name="isascii">,
2797 <ref id="isblank" name="isblank">,
2798 <ref id="iscntrl" name="iscntrl">,
2799 <ref id="isdigit" name="isdigit">,
2800 <ref id="isgraph" name="isgraph">,
2801 <ref id="islower" name="islower">,
2802 <ref id="isprint" name="isprint">,
2803 <ref id="ispunct" name="ispunct">,
2804 <ref id="isspace" name="isspace">,
2805 <ref id="isupper" name="isupper">
2811 <sect1>itoa<label id="itoa"><p>
2815 <tag/Function/Convert an integer into a string.
2816 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
2817 <tag/Declaration/<tt/char* __fastcall__ itoa (int val, char* buf, int radix);/
2818 <tag/Description/<tt/itoa/ converts the integer <tt/val/ into a string using
2819 <tt/radix/ as the base.
2820 <tag/Limits/<itemize>
2821 <item>There are no provisions to prevent a buffer overflow.
2822 <item>If <tt/val/ contains <tt/INT_MIN/, the behaviour is undefined.
2823 <item>The function is non standard, so it is not available in strict ANSI mode.
2824 You should probably use <tt/sprintf/ instead.
2825 <item>The function is only available as fastcall function, so it may only be
2826 used in presence of a prototype.
2828 <tag/Availability/cc65
2830 <ref id="atoi" name="atoi">,
2831 <ref id="atol" name="atol">,
2832 <ref id="ltoa" name="ltoa">,
2833 <ref id="ultoa" name="ultoa">,
2834 <ref id="utoa" name="utoa">
2840 <sect1>joy_count<label id="joy_count"><p>
2844 <tag/Function/Return the number of joysticks supported by the current driver.
2845 <tag/Header/<tt/<ref id="joystick.h" name="joystick.h">/
2846 <tag/Declaration/<tt/unsigned char __fastcall__ joy_count (void);/
2847 <tag/Description/The function returns a the number of joysticks supported
2848 by the current joystick driver.
2849 <tag/Limits/<itemize>
2850 <item>A joystick driver must be loaded using <ref id="joy_load_driver"
2851 name="joy_load_driver"> before calling this function.
2852 <item>The function returns the number of joysticks supported by the driver.
2853 There's no way to check for the number of actually connected joysticks.
2854 <item>The function is only available as fastcall function, so it may only be
2855 used in presence of a prototype.
2857 <tag/Availability/cc65
2859 <ref id="joy_load_driver" name="joy_load_driver">,
2860 <ref id="joy_read" name="joy_read">
2866 <sect1>joy_install<label id="joy_install"><p>
2870 <tag/Function/Install an already loaded driver and return an error code.
2871 <tag/Header/<tt/<ref id="joystick.h" name="joystick.h">/
2872 <tag/Declaration/<tt/unsigned char __fastcall__ joy_install (void* driver);/
2873 <tag/Description/The function installs a driver that was already loaded into
2874 memory (or linked statically to the program). It returns an error code
2875 (<tt/JOY_ERR_OK/ in case of success).
2876 <tag/Limits/<itemize>
2877 <item>The function is only available as fastcall function, so it may only be
2878 used in presence of a prototype.
2880 <tag/Availability/cc65
2882 <ref id="joy_load_driver" name="joy_load_driver">,
2883 <ref id="joy_uninstall" name="joy_uninstall">,
2884 <ref id="joy_unload" name="joy_unload">
2890 <sect1>joy_load_driver<label id="joy_load_driver"><p>
2894 <tag/Function/Load a driver from disk and install it.
2895 <tag/Header/<tt/<ref id="joystick.h" name="joystick.h">/
2896 <tag/Declaration/<tt/unsigned char __fastcall__ joy_load_driver (const char* driver);/
2897 <tag/Description/The function loads a driver with the given name from disk
2898 and installs it. An error code is returned, which is <tt/JOY_ERR_OK/ if the
2899 driver was successfully loaded and installed.
2900 <tag/Limits/<itemize>
2901 <item>The function is only available as fastcall function, so it may only be
2902 used in presence of a prototype.
2904 <tag/Availability/cc65
2906 <ref id="joy_install" name="joy_install">,
2907 <ref id="joy_uninstall" name="joy_uninstall">,
2908 <ref id="joy_unload" name="joy_unload">
2914 <sect1>joy_read<label id="joy_read"><p>
2918 <tag/Function/Read the status of a joystick.
2919 <tag/Header/<tt/<ref id="joystick.h" name="joystick.h">/
2920 <tag/Declaration/<tt/unsigned char __fastcall__ joy_read (unsigned char joystick);/
2921 <tag/Description/The function reads the status bits for a joystick. The number
2922 of the joystick is passed as parameter. The result may be examined by using one
2923 of the <tt/JOY_xxx/ macros from <ref id="joystick.h" name="joystick.h">.
2924 <tag/Limits/<itemize>
2925 <item>A joystick driver must be loaded using <ref id="joy_load_driver"
2926 name="joy_load_driver"> before calling this function.
2927 <item>The function is only available as fastcall function, so it may only be
2928 used in presence of a prototype.
2930 <tag/Availability/cc65
2932 <ref id="joy_count" name="joy_count">,
2933 <ref id="joy_load_driver" name="joy_load_driver">,
2934 <ref id="joy_unload" name="joy_unload">
2940 <sect1>joy_uninstall<label id="joy_uninstall"><p>
2944 <tag/Function/Uninstall the current joystick driver.
2945 <tag/Header/<tt/<ref id="joystick.h" name="joystick.h">/
2946 <tag/Declaration/<tt/unsigned char __fastcall__ joy_uninstall (void);/
2947 <tag/Description/The function uninstalls the currently installed joystick
2948 driver. It does not remove the driver from memory. The function returns an
2949 error code, which is <tt/JOY_ERR_OK/ if the driver was successfully uninstalled.
2950 <tag/Limits/<itemize>
2951 <item>A joystick driver must be installed using <ref id="joy_install"
2952 name="joy_install"> before calling this function.
2953 <item>The function is only available as fastcall function, so it may only be
2954 used in presence of a prototype.
2956 <tag/Availability/cc65
2958 <ref id="joy_install" name="joy_install">,
2959 <ref id="joy_load_driver" name="joy_load_driver">,
2960 <ref id="joy_unload" name="joy_unload">
2966 <sect1>joy_unload<label id="joy_unload"><p>
2970 <tag/Function/Uninstall, then unload the current joystick driver.
2971 <tag/Header/<tt/<ref id="joystick.h" name="joystick.h">/
2972 <tag/Declaration/<tt/unsigned char __fastcall__ joy_unload (void);/
2973 <tag/Description/The function uninstalls the currently installed joystick
2974 driver and removes it from memory. An error code is returned, which is
2975 <tt/JOY_ERR_OK/ if the driver was successfully uninstalled.
2976 <tag/Limits/<itemize>
2977 <item>A joystick driver must be loaded using <ref id="joy_load_driver"
2978 name="joy_load_driver"> before calling this function.
2979 <item>The function is only available as fastcall function, so it may only be
2980 used in presence of a prototype.
2982 <tag/Availability/cc65
2984 <ref id="joy_load_driver" name="joy_load_driver">
2990 <sect1>kbhit<label id="kbhit"><p>
2994 <tag/Function/Check if there's a key waiting in the keyboard buffer.
2995 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2996 <tag/Declaration/<tt/unsigned char kbhit (void);/
2997 <tag/Description/The function returns a value of zero if there is no character
2998 waiting to be read from the keyboard. It returns non zero otherwise.
2999 <tag/Limits/<itemize>
3000 <item>If the system does not support a keyboard buffer (most systems
3001 do), the function is rather useless.
3003 <tag/Availability/cc65
3005 <ref id="cgetc" name="cgetc">,
3006 <ref id="cursor" name="cursor">
3012 <sect1>labs<label id="labs"><p>
3016 <tag/Function/Returns the absolute value of a long integer.
3017 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
3018 <tag/Declaration/<tt/long __fastcall__ labs (long v);/
3019 <tag/Description/<tt/labs/ returns the absolute value of the argument passed to
3021 <tag/Limits/<itemize>
3022 <item>The return value is undefined if <tt/LONG_MIN/ is passed to the function.
3023 <item>The function is only available as fastcall function, so it may only be
3024 used in presence of a prototype.
3026 <tag/Availability/ISO 9899
3028 <ref id="abs" name="abs">
3034 <sect1>ltoa<label id="ltoa"><p>
3038 <tag/Function/Convert a long integer into a string.
3039 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
3040 <tag/Declaration/<tt/char* __fastcall__ ltoa (long val, char* buf, int radix);/
3041 <tag/Description/<tt/itoa/ converts the long integer <tt/val/ into a string
3042 using <tt/radix/ as the base.
3043 <tag/Limits/<itemize>
3044 <item>There are no provisions to prevent a buffer overflow.
3045 <item>If <tt/val/ contains <tt/LONG_MIN/, the behaviour is undefined.
3046 <item>The function is non standard, so it is not available in strict ANSI mode.
3047 You should probably use <tt/sprintf/ instead.
3048 <item>The function is only available as fastcall function, so it may only be
3049 used in presence of a prototype.
3051 <tag/Availability/cc65
3053 <ref id="atoi" name="atoi">,
3054 <ref id="atol" name="atol">,
3055 <ref id="itoa" name="itoa">,
3056 <ref id="ultoa" name="ultoa">,
3057 <ref id="utoa" name="utoa">
3063 <sect1>localeconv<label id="localeconv"><p>
3067 <tag/Function/Returns a pointer to the current locale structure.
3068 <tag/Header/<tt/<ref id="locale.h" name="locale.h">/
3069 <tag/Declaration/<tt/struct lconv* localeconv (void);/
3070 <tag/Description/<tt/localeconv/ returns a pointer to the current locale
3072 <tag/Limits/<itemize>
3073 <item>cc65 supports only the "C" locale, so even after setting a new locale
3074 using <tt/<ref id="setlocale" name="setlocale">/, the structure returned will
3077 <tag/Availability/ISO 9899
3079 <ref id="setlocale" name="setlocale">
3085 <sect1>longjmp<label id="longjmp"><p>
3089 <tag/Function/Non local goto.
3090 <tag/Header/<tt/<ref id="setjmp.h" name="setjmp.h">/
3091 <tag/Declaration/<tt/void __fastcall__ longjmp (jmp_buf buf, int retval);/
3092 <tag/Description/The <tt/longjmp/ function restores a program context from the
3093 data in <tt/buf/, which must have been set by a preceeding call to
3094 <tt/<ref id="setjmp" name="setjmp">/. Program execution continues as if the
3095 call to <tt/<ref id="setjmp" name="setjmp">/ has just returned the value
3099 <item>If the parameter <tt/retval/ is zero, the function will behave as if it
3100 was called with a value of one.
3101 <item>The function is only available as fastcall function, so it may only
3102 be used in presence of a prototype.
3104 <tag/Availability/ISO 9899
3106 <ref id="setjmp" name="setjmp">
3112 <sect1>malloc<label id="malloc"><p>
3116 <tag/Function/Allocate dynamic memory.
3117 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
3118 <tag/Declaration/<tt/void* __fastcall__ malloc (size_t size);/
3119 <tag/Description/<tt/malloc/ allocates size bytes on the heap and returns a
3120 pointer to the allocated memory block. On error (not enough memory available),
3121 <tt/malloc/ returns <tt/NULL/.
3124 <item>The function is only available as fastcall function, so it may only
3125 be used in presence of a prototype.
3127 <tag/Availability/ISO 9899
3129 <ref id="_heapadd" name="_heapadd">,
3130 <ref id="_heapblocksize" name="_heapblocksize">,
3131 <ref id="_heapmaxavail" name="_heapmaxavail">,
3132 <ref id="_heapmemavail" name="_heapmemavail">,
3133 <ref id="calloc" name="calloc">,
3134 <ref id="free" name="free">,
3135 <ref id="realloc" name="realloc">,
3136 <ref id="strdup" name="strdup">
3142 <sect1>memchr<label id="memchr"><p>
3146 <tag/Function/Search for a character in a block of raw memory.
3147 <tag/Header/<tt/<ref id="string.h" name="string.h">/
3148 <tag/Declaration/<tt/void* __fastcall__ strchr (const void* mem, int c, size_t count);/
3149 <tag/Description/The <tt/memchr/ function locates the first occurrence of <tt/c/
3150 (converted to a char) in the block of raw memory string pointed to by <tt/mem/
3151 that is of size <tt/count/. Upon completion, the function returns a pointer to
3152 the character found, or a null pointer if the character was not found.
3153 <tag/Limits/<itemize>
3154 <item>The function is only available as fastcall function, so it may only
3155 be used in presence of a prototype.
3157 <tag/Availability/ISO 9899
3159 <ref id="strchr" name="strchr">
3165 <sect1>memcpy<label id="memcpy"><p>
3169 <tag/Function/Copy a memory area.
3170 <tag/Header/<tt/<ref id="string.h" name="string.h">/
3171 <tag/Declaration/<tt/void* __fastcall__ memcpy (void* dest, const void* src, size_t count);/
3172 <tag/Description/<tt/memcpy/ copies <tt/count/ bytes from the memory area
3173 pointed to by <tt/src/ into the memory area pointed to by <tt/dest/. It returns
3177 <item>The result is undefined if the memory areas do overlap. Use
3178 <tt/<ref id="memmove" name="memmove">/ to copy overlapping memory areas.
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="memmove" name="memmove">,
3186 <ref id="memset" name="memset">
3192 <sect1>memmove<label id="memmove"><p>
3196 <tag/Function/Copy a memory area.
3197 <tag/Header/<tt/<ref id="string.h" name="string.h">/
3198 <tag/Declaration/<tt/void* __fastcall__ memmove (void* dest, const void* src, size_t count);/
3199 <tag/Description/<tt/memmove/ copies <tt/count/ bytes from the memory area
3200 pointed to by <tt/src/ into the memory area pointed to by <tt/dest/. It returns
3204 <item>While <tt/memmove/ allows the memory areas to overlap, it has some
3205 additional overhead compared to <tt/<ref id="memcpy" name="memcpy">/.
3206 <item>The function is only available as fastcall function, so it may only
3207 be used in presence of a prototype.
3209 <tag/Availability/ISO 9899
3211 <ref id="_swap" name="_swap">,
3212 <ref id="memcpy" name="memcpy">,
3213 <ref id="memset" name="memset">
3219 <sect1>memset<label id="memset"><p>
3223 <tag/Function/Fill a memory area.
3224 <tag/Header/<tt/<ref id="string.h" name="string.h">/
3225 <tag/Declaration/<tt/void* __fastcall__ memset (void* p, int val, size_t count);/
3226 <tag/Description/<tt/memset/ fills the memory area pointed to by <tt/p/ with
3227 the value <tt/val/. The function returns <tt/p/.
3230 <item>The function is only available as fastcall function, so it may only
3231 be used in presence of a prototype.
3233 <tag/Availability/ISO 9899
3235 <ref id="_swap" name="_swap">,
3236 <ref id="bzero" name="bzero">,
3237 <ref id="memcpy" name="memcpy">,
3238 <ref id="memmove" name="memmove">
3244 <sect1>mod_free<label id="mod_free"><p>
3248 <tag/Function/Free a relocatable module.
3249 <tag/Header/<tt/<ref id="modload.h" name="modload.h">/
3250 <tag/Declaration/<tt/void __fastcall__ mod_free (void* module);/
3251 <tag/Description/The function will free a module loaded into memory by use of
3252 the <tt/<ref id="mod_load" name="mod_load">/ function.
3253 <tag/Limits/<itemize>
3254 <item>The pointer passed as parameter is the pointer to the module memory,
3255 not the pointer to the control structure.
3257 <tag/Availability/cc65
3259 <ref id="mod_load" name="mod_load">
3265 <sect1>mod_load<label id="mod_load"><p>
3269 <tag/Function/Load a relocatable module.
3270 <tag/Header/<tt/<ref id="modload.h" name="modload.h">/
3271 <tag/Declaration/<tt/unsigned char mod_load (struct mod_ctrl* ctrl);/
3272 <tag/Description/The function will load a code module into memory and relocate
3273 it. The function will return an error code. If <tt/MLOAD_OK/ is returned, the
3274 outgoing fields in the passed <tt/mod_ctrl/ struct contain information about
3275 the module just loaded. Possible error codes are:
3277 <item><tt/MLOAD_OK/ - Module load successful
3278 <item><tt/MLOAD_ERR_READ/ - Read error
3279 <item><tt/MLOAD_ERR_HDR/ - Header error
3280 <item><tt/MLOAD_ERR_OS/ - Wrong operating system
3281 <item><tt/MLOAD_ERR_FMT/ - Data format error
3282 <item><tt/MLOAD_ERR_MEM/ - Not enough memory
3284 <tag/Limits/<itemize>
3285 <item>The <htmlurl url="ld65.html" name="ld65"> linker is needed to create
3286 relocatable o65 modules for use with this function.
3288 <tag/Availability/cc65
3290 <ref id="mod_free" name="mod_free">
3296 <sect1>mouse_setbox<label id="mouse_setbox"><p>
3300 <tag/Function/Specify a bounding box for the mouse cursor.
3301 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3302 <tag/Declaration/<tt/void __fastcall__ mouse_setbox (const struct mouse_box* box);/
3303 <tag/Description/The function allows to set a bounding box for mouse movement.
3304 <tag/Limits/<itemize>
3305 <item>The function does not check if the mouse cursor is currently within the
3306 given rectangle. Placing the mouse cursor within the bounding box is the
3307 responsibility of the programmer.
3308 <item>While the bounding box may be larger than the actual screen size, the
3309 standard mouse cursor draw routines may fail to set the cursor to coordinates
3310 outside of the screen area. Depending on the platform, you may have to supply
3311 your own mouse cursor routines.
3312 <item>The function is only available as fastcall function, so it may only be
3313 used in presence of a prototype.
3315 <tag/Availability/cc65
3317 <ref id="mouse_getbox" name="mouse_getbox">,
3318 <ref id="mouse_move" name="mouse_move">
3324 <sect1>mouse_getbox<label id="mouse_getbox"><p>
3328 <tag/Function/Return the current bounding box for the mouse cursor.
3329 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3330 <tag/Declaration/<tt/void __fastcall__ mouse_getbox (struct mouse_box* box);/
3331 <tag/Description/The function queries the current bounding box for mouse
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_move" name="mouse_move">,
3340 <ref id="mouse_setbox" name="mouse_setbox">
3346 <sect1>mouse_buttons<label id="mouse_buttons"><p>
3350 <tag/Function/Return a bit mask encoding the state of the mouse buttons.
3351 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3352 <tag/Declaration/<tt/unsigned char __fastcall__ mouse_buttons (void);/
3353 <tag/Description/The function returns a bit mask that encodes the state of the
3354 mouse buttons. You may use the <tt/MOUSE_BTN_XXX/ flags to decode the function
3356 <tag/Limits/<itemize>
3357 <item>The function is only available as fastcall function, so it may only be
3358 used in presence of a prototype.
3360 <tag/Availability/cc65
3362 <ref id="mouse_info" name="mouse_info">,
3363 <ref id="mouse_pos" name="mouse_pos">
3369 <sect1>mouse_geterrormsg<label id="mouse_geterrormsg"><p>
3373 <tag/Function/Return a readable error message for an error code.
3374 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3375 <tag/Declaration/<tt/const char* __fastcall__ mouse_geterrormsg (unsigned char
3377 <tag/Description/The function returns an error message (in english) for the
3378 error code passed parameter.
3379 <tag/Limits/<itemize>
3380 <item>The function will return "Unknown error" for invalid error codes.
3381 <item>The function is only available as fastcall function, so it may only be
3382 used in presence of a prototype.
3384 <tag/Availability/cc65
3386 <ref id="mouse_load_driver" name="mouse_load_driver">,
3387 <ref id="mouse_uninstall" name="mouse_uninstall">,
3388 <ref id="mouse_unload" name="mouse_unload">
3394 <sect1>mouse_hide<label id="mouse_hide"><p>
3398 <tag/Function/Hide the mouse pointer.
3399 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3400 <tag/Declaration/<tt/void __fastcall__ mouse_hide (void);/
3401 <tag/Description/The function hides the mouse pointer. It manages a counter
3402 that is shared between <tt/<ref id="mouse_show" name="mouse_show">/ and
3403 <tt/mouse_hide/ so that every call call to <tt/mouse_hide/ must be followed by
3404 a call to <tt/<ref id="mouse_show" name="mouse_show">/ to make the mouse cursor
3406 <tag/Limits/<itemize>
3407 <item>The function is only available as fastcall function, so it may only be
3408 used in presence of a prototype.
3410 <tag/Availability/cc65
3412 <ref id="mouse_show" name="mouse_show">
3418 <sect1>mouse_info<label id="mouse_info"><p>
3422 <tag/Function/Return the state of the mouse buttons and the position of the
3424 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3425 <tag/Declaration/<tt/void __fastcall__ mouse_info (struct mouse_info* info);/
3426 <tag/Description/The function returns the state of the mouse buttons and the
3427 position of the mouse in the <tt/mouse_info/ structure passed as parameter.
3428 <tag/Limits/<itemize>
3429 <item>The <tt/mouse_info/ struct is a superset of the <tt/mouse_pos/ struct,
3430 so if you just need the mouse position, call <tt/<ref id="mouse_pos"
3431 name="mouse_pos">/ instead.
3432 <item>The function is only available as fastcall function, so it may only be
3433 used in presence of a prototype.
3435 <tag/Availability/cc65
3437 <ref id="mouse_buttons" name="mouse_buttons">,
3438 <ref id="mouse_pos" name="mouse_pos">
3444 <sect1>mouse_install<label id="mouse_install"><p>
3448 <tag/Function/Install an already loaded mouse driver.
3449 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3450 <tag/Declaration/<tt/unsigned char __fastcall__ mouse_install (const struct
3451 mouse_callbacks* c, void* driver);/
3452 <tag/Description/The function installs an already loaded mouse driver and
3453 returns an error code. The <tt/mouse_callbacks/ structure passed as first
3454 parameter contains pointers to routines needed to move or hide/show the mouse
3455 pointer. Defaults for these routines are supplied by the library, so if you
3456 can live with these defaults (which are platform specific), just pass a
3457 pointer to <tt/mouse_def_callbacks/. The function may be used to install a
3458 driver linked statically to the program.
3459 <tag/Limits/<itemize>
3460 <item>Not all drivers are able to detect if the supported hardware is really
3462 <item>After installing a driver, the mouse cursor is hidden.
3463 <item>The function is only available as fastcall function, so it may only be
3464 used in presence of a prototype.
3466 <tag/Availability/cc65
3468 <ref id="mouse_load_driver" name="mouse_load_driver">,
3469 <ref id="mouse_uninstall" name="mouse_uninstall">,
3470 <ref id="mouse_unload" name="mouse_unload">
3476 <sect1>mouse_ioctl<label id="mouse_ioctl"><p>
3480 <tag/Function/Call the driver specific ioctl function.
3481 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3482 <tag/Declaration/<tt/unsigned char __fastcall__ mouse_ioctl (unsigned char code, void* data);/
3483 <tag/Description/The function calls the IOCTL entry in the mouse driver,
3484 which is driver specific. The <tt/code/ parameter will choose between
3485 different IOCTL functions, and the <tt/data/ depends on code. The
3486 function returns an error code. The purpose of this function is to allow
3487 for driver specific extensions. See the documentation for a specific mouse
3488 driver for supported ioctl calls.
3489 <tag/Limits/<itemize>
3490 <item>Calling this function is non portable, because each driver may
3491 implement different ioctl calls (or none at all).
3492 <item>The function is only available as fastcall function, so it may only be
3493 used in presence of a prototype.
3495 <tag/Availability/cc65
3501 <sect1>mouse_load_driver<label id="mouse_load_driver"><p>
3505 <tag/Function/Load and initialize a mouse driver.
3506 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3507 <tag/Declaration/<tt/unsigned char __fastcall__ mouse_load_driver (const struct
3508 mouse_callbacks* c, const char* driver);/
3509 <tag/Description/Load a mouse driver into memory and initialize it. The
3510 function returns an error code that tells if the call has been successful. The
3511 <tt/mouse_callbacks/ structure passed as first parameter contains pointers to
3512 routines needed to move or hide/show the mouse pointer. Defaults for these
3513 routines are supplied by the library, so if you can live with these defaults
3514 (which are platform specific), just pass a pointer to <tt/mouse_def_callbacks/.
3515 <tag/Limits/<itemize>
3516 <item>The driver is loaded by name, so currently you must know the type of
3517 mouse that should be supported. There is no autodetect capability.
3518 <item>Not all drivers are able to detect if the supported hardware is really
3520 <item>After installing a driver, the mouse cursor is hidden.
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_install" name="mouse_install">,
3527 <ref id="mouse_uninstall" name="mouse_uninstall">,
3528 <ref id="mouse_unload" name="mouse_unload">
3534 <sect1>mouse_move<label id="mouse_move"><p>
3538 <tag/Function/Move the mouse cursor to a specific position.
3539 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3540 <tag/Declaration/<tt/void __fastcall__ mouse_move (int x, int y);/
3541 <tag/Description/The function updates the mouse position. If the mouse cursor
3542 is visible, it is shown at the new position.
3543 <tag/Limits/<itemize>
3544 <item>The function does not check if the new position is within the bounding
3545 box specified with <tt/<ref id="mouse_setbox" name="mouse_setbox">/.
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_getbox" name="mouse_getbox">,
3552 <ref id="mouse_setbox" name="mouse_setbox">
3558 <sect1>mouse_pos<label id="mouse_pos"><p>
3562 <tag/Function/Return the position of the mouse.
3563 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3564 <tag/Declaration/<tt/void __fastcall__ mouse_pos (struct mouse_pos* pos);/
3565 <tag/Description/The function returns the position of the mouse in the
3566 <tt/mouse_pos/ structure passed as parameter.
3567 <tag/Limits/<itemize>
3568 <item>The <tt/mouse_pos/ struct is a subset of the <tt/mouse_info/ struct,
3569 so if you do also need the mouse buttons, call <tt/<ref id="mouse_info"
3570 name="mouse_info">/ instead.
3571 <item>The function is only available as fastcall function, so it may only be
3572 used in presence of a prototype.
3574 <tag/Availability/cc65
3576 <ref id="mouse_buttons" name="mouse_buttons">,
3577 <ref id="mouse_info" name="mouse_info">
3583 <sect1>mouse_show<label id="mouse_show"><p>
3587 <tag/Function/Show the mouse pointer.
3588 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3589 <tag/Declaration/<tt/void __fastcall__ mouse_show (void);/
3590 <tag/Description/The function shows the mouse pointer. It manages a counter
3591 that is shared between <tt/<ref id="mouse_hide" name="mouse_hide">/ and
3592 <tt/mouse_show/. The mouse cursor is visible if there was one more call to
3593 <tt/mouse_show/ than to <tt/<ref id="mouse_hide" name="mouse_hide">/.
3594 <tag/Limits/<itemize>
3595 <item>The function is only available as fastcall function, so it may only be
3596 used in presence of a prototype.
3598 <tag/Availability/cc65
3600 <ref id="mouse_hide" name="mouse_hide">
3606 <sect1>mouse_uninstall<label id="mouse_uninstall"><p>
3610 <tag/Function/Uninstall an already loaded mouse driver.
3611 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3612 <tag/Declaration/<tt/unsigned char __fastcall__ mouse_install (void);/
3613 <tag/Description/The function uninstalls an already loaded mouse driver but
3614 don't removes it from memory.
3615 <tag/Limits/<itemize>
3616 <item>If the driver has been loaded using <tt/<ref id="mouse_load_driver"
3617 name="mouse_load_driver">/, <tt/<ref id="mouse_unload" name="mouse_unload">/
3618 should be used instead of <tt/mouse_uninstall/ so the driver is also removed
3620 <item>The function is only available as fastcall function, so it may only be
3621 used in presence of a prototype.
3623 <tag/Availability/cc65
3625 <ref id="mouse_install" name="mouse_install">,
3626 <ref id="mouse_load_driver" name="mouse_load_driver">,
3627 <ref id="mouse_unload" name="mouse_unload">
3633 <sect1>mouse_unload<label id="mouse_unload"><p>
3637 <tag/Function/Unload a mouse driver.
3638 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3639 <tag/Declaration/<tt/unsigned char __fastcall__ mouse_unload (void);/
3640 <tag/Description/The function unloads a loaded mouse driver and frees all
3641 memory allocated for the driver.
3642 <tag/Limits/<itemize>
3643 <item>The function does nothing if no driver is loaded.
3645 <tag/Availability/cc65
3647 <ref id="mouse_install" name="mouse_install">,
3648 <ref id="mouse_load_driver" name="mouse_load_driver">,
3649 <ref id="mouse_uninstall" name="mouse_uninstall">
3655 <sect1>offsetof<label id="offsetof"><p>
3659 <tag/Function/Calculate the offset of a struct or union member.
3660 <tag/Header/<tt/<ref id="stddef.h" name="stddef.h">/
3661 <tag/Declaration/<tt/size_t offsetof (type, member);/
3662 <tag/Description/<tt/offsetof/ calculates the address offset of a <tt/struct/
3663 or <tt/union/ member.
3664 <tag/Limits/<itemize>
3665 <item>The function is actually a macro.
3667 <tag/Availability/ISO 9899
3673 <sect1>open<label id="open"><p>
3677 <tag/Function/Open and possibly create a file.
3678 <tag/Header/<tt/<ref id="fcntl.h" name="fcntl.h">/
3679 <tag/Declaration/<tt/int open (const char* name, int flags, ...);/
3680 <tag/Description/<tt/open/ opens a file and returns the file descriptor
3681 associated with it. On error, -1 is returned and an error code is stored in
3682 <tt/errno/. Several flags may be passed to <tt/open/ that change the behaviour.
3683 <tag/Limits/<itemize>
3684 <item>POSIX specifies an additional <tt/mode/ argument that may be passed to
3685 open, which is used as the permission mask when a new file is created. While
3686 cc65 allows to pass this argument, it is ignored.
3688 <tag/Availability/POSIX 1003.1
3690 <ref id="close" name="close">,
3691 <ref id="creat" name="creat">
3697 <sect1>peekbsys<label id="peekbsys"><p>
3701 <tag/Function/Read one byte from a location in the system bank.
3702 <tag/Header/<tt/<ref id="cbm610.h" name="cbm610.h">/,
3703 <tt/<ref id="cbm510.h" name="cbm510.h">/
3704 <tag/Declaration/<tt/unsigned char __fastcall__ peekbsys (unsigned addr);/
3705 <tag/Description/<tt/peekbsys/ reads one byte from the given address in the
3706 system bank (bank 15) of the CBM PET-II machines and returns it.
3709 <item>The function is only available as fastcall function, so it may only
3710 be used in presence of a prototype.
3711 <item>This function may be a macro depending on the compiler options. The
3712 actual function is accessible by #undef'ing the macro.
3714 <tag/Availability/cc65
3716 <ref id="PEEK" name="PEEK">,
3717 <ref id="PEEKW" name="PEEKW">,
3718 <ref id="peekwsys" name="peekwsys">,
3719 <ref id="pokebsys" name="pokebsys">,
3720 <ref id="pokewsys" name="pokewsys">
3726 <sect1>peekwsys<label id="peekwsys"><p>
3730 <tag/Function/Read one word from a location in the system bank.
3731 <tag/Header/<tt/<ref id="cbm610.h" name="cbm610.h">/,
3732 <tt/<ref id="cbm510.h" name="cbm510.h">/
3733 <tag/Declaration/<tt/unsigned __fastcall__ peekwsys (unsigned addr);/
3734 <tag/Description/<tt/peekwsys/ reads one word from the given address in the
3735 system bank (bank 15) of the CBM PET-II machines and returns it. Following
3736 the usual 6502 conventions, the low byte is read from <tt/addr/, and the
3737 high byte is read from <tt/addr+1/.
3740 <item>The function is only available as fastcall function, so it may only
3741 be used in presence of a prototype.
3742 <item>The order in which the two bytes are read is undefined.
3744 <tag/Availability/cc65
3746 <ref id="PEEK" name="PEEK">,
3747 <ref id="PEEKW" name="PEEKW">,
3748 <ref id="peekbsys" name="peekbsys">,
3749 <ref id="pokebsys" name="pokebsys">,
3750 <ref id="pokewsys" name="pokewsys">
3756 <sect1>perror<label id="perror"><p>
3760 <tag/Function/Print an error message for the error in <tt/errno/.
3761 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
3762 <tag/Declaration/<tt/void __fastcall__ perror (const char* s);/
3763 <tag/Description/<tt/perror/ prints an error message to <tt/stderr/. If <tt/s/
3764 is not <tt/NULL/ and not an empty string, it is printed followed by a colon and
3765 a blank. Then the error message for the current contents of <tt/errno/ is
3766 printed followed by a newline. The message output is the same as returned by
3767 <tt/<ref id="strerror" name="strerror">/ with an argument of <tt/errno/.
3770 <item>The function is only available as fastcall function, so it may only
3771 be used in presence of a prototype.
3773 <tag/Availability/ISO 9899
3775 <ref id="_poserror" name="_poserror">,
3776 <ref id="strerror" name="strerror">
3782 <sect1>pokebsys<label id="pokebsys"><p>
3786 <tag/Function/Write one byte to a location in the system bank.
3787 <tag/Header/<tt/<ref id="cbm610.h" name="cbm610.h">/,
3788 <tt/<ref id="cbm510.h" name="cbm510.h">/
3789 <tag/Declaration/<tt/void __fastcall__ pokebsys (unsigned addr, unsigned char val);/
3790 <tag/Description/<tt/pokebsys/ writes one byte to the given address in the
3791 system bank (bank 15) of the CBM PET-II machines.
3794 <item>The function is only available as fastcall function, so it may only
3795 be used in presence of a prototype.
3797 <tag/Availability/cc65
3799 <ref id="POKE" name="POKE">,
3800 <ref id="POKEW" name="POKEW">,
3801 <ref id="peekbsys" name="peekbsys">,
3802 <ref id="peekwsys" name="peekwsys">,
3803 <ref id="pokewsys" name="pokewsys">
3809 <sect1>pokewsys<label id="pokewsys"><p>
3813 <tag/Function/Write one word to a location in the system bank.
3814 <tag/Header/<tt/<ref id="cbm610.h" name="cbm610.h">/,
3815 <tt/<ref id="cbm510.h" name="cbm510.h">/
3816 <tag/Declaration/<tt/void __fastcall__ pokewsys (unsigned addr, unsigned val);/
3817 <tag/Description/<tt/pokewsys/ writes one word to the given address in the
3818 system bank (bank 15) of the CBM PET-II machines. Following the usual 6502
3819 conventions, the low byte of <tt/val/ is written to <tt/addr/, and the
3820 high byte is written to <tt/addr+1/.
3823 <item>The function is only available as fastcall function, so it may only
3824 be used in presence of a prototype.
3825 <item>The order in which the two bytes are written is undefined.
3827 <tag/Availability/cc65
3829 <ref id="POKE" name="POKE">,
3830 <ref id="POKEW" name="POKEW">,
3831 <ref id="peekbsys" name="peekbsys">,
3832 <ref id="peekwsys" name="peekwsys">,
3833 <ref id="pokebsys" name="pokebsys">
3839 <sect1>qsort<label id="qsort"><p>
3843 <tag/Function/Sort an array.
3844 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
3845 <tag/Declaration/<tt/void __fastcall__ qsort (void* base, size_t count,
3846 size_t size, int (*compare) (const void*, const void*));/
3847 <tag/Description/<tt/qsort/ sorts an array according to a given compare
3848 function <tt/compare/. <tt/base/ is the address of the array, <tt/count/
3849 is the number of elements, <tt/size/ the size of an element and <tt/compare/
3850 the function used to compare the members.
3853 <item>If there are multiple members with the same key, the order after calling
3854 the function is undefined.
3855 <item>The function is only available as fastcall function, so it may only
3856 be used in presence of a prototype.
3858 <tag/Availability/ISO 9899
3860 <ref id="bsearch" name="bsearch">
3866 <sect1>raise<label id="raise"><p>
3870 <tag/Function/Send a signal to the executing program.
3871 <tag/Header/<tt/<ref id="signal.h" name="signal.h">/
3872 <tag/Declaration/<tt/int __fastcall__ raise (int sig);/
3873 <tag/Description/<tt/raise/ sends the given signal to the program. If the
3874 program has installed a signal handler for the signal, this signal handler
3875 will be executed. If no handler has been installed, the default action for
3876 the raised signal will be taken. The function returns zero on success,
3878 <tag/Limits/<itemize>
3879 <item>The function is only available as fastcall function, so it may only
3880 be used in presence of a prototype.
3882 <tag/Availability/ISO 9899
3884 <ref id="abort" name="abort">,
3885 <ref id="signal" name="signal">
3891 <sect1>rand<label id="rand"><p>
3895 <tag/Function/Return a pseudo random number.
3896 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
3897 <tag/Declaration/<tt/int rand (void);/
3898 <tag/Description/The function returns a pseudo random number
3899 between 0 and <tt/RAND_MAX/ (exclusive).
3900 <tag/Limits/<itemize>
3901 <item>Without using <tt><ref id="srand" name="srand"></tt>, always the same
3902 flow of numbers is generated.
3903 <item>On startup, the function behaves as if <ref id="srand" name="srand">
3904 had been used with an argument of 1.
3906 <tag/Availability/ISO 9899
3908 <ref id="_randomize" name="_randomize">,
3909 <ref id="srand" name="srand">
3915 <sect1>realloc<label id="realloc"><p>
3919 <tag/Function/Change the size of an allocated memory block.
3920 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
3921 <tag/Declaration/<tt/void* __fastcall__ realloc (void* block, size_t size);/
3922 <tag/Description/<tt/realloc/ changes the size of the memory block pointed to
3923 by <tt/block/ to <tt/size/ bytes. If <tt/block/ is <tt/NULL/, <tt/realloc/
3924 behaves as if <tt/malloc/ had been called. If <tt/size/ is zero, <tt/realloc/
3925 behaves as if <tt/free/ had been called. On error (not enough memory
3926 available), <tt/realloc/ returns <tt/NULL/.
3929 <item>The part of the memory block that is returned will have its contents
3931 <item>This function is somewhat dangerous to use. Be careful to save the
3932 pointer you're passing somewhere else, otherwise
3934 ptr = realloc (ptr, size);
3936 will loose your only copy of <tt/ptr/ if <tt/realloc/ returns <tt/NULL/.
3937 <item>The function is only available as fastcall function, so it may only
3938 be used in presence of a prototype.
3940 <tag/Availability/ISO 9899
3942 <ref id="_heapadd" name="_heapadd">,
3943 <ref id="_heapblocksize" name="_heapblocksize">,
3944 <ref id="_heapmaxavail" name="_heapmaxavail">,
3945 <ref id="_heapmemavail" name="_heapmemavail">,
3946 <ref id="calloc" name="calloc">,
3947 <ref id="free" name="free">,
3948 <ref id="realloc" name="realloc">
3954 <sect1>remove<label id="remove"><p>
3958 <tag/Function/Delete a file.
3959 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
3960 <tag/Declaration/<tt/int __fastcall__ remove (const char* name);/
3961 <tag/Description/<tt/remove/ deletes the file with the given name. On success,
3962 zero is returned. On error, -1 is returned and <tt/errno/ is set to an error
3963 code describing the reason for the failure.
3966 <item>This function is not available on all cc65 targets (depends on the
3967 availability of file I/O).
3968 <item>The function is only available as fastcall function, so it may only
3969 be used in presence of a prototype.
3971 <tag/Availability/ISO 9899
3973 <ref id="rename" name="rename">,
3974 <ref id="unlink" name="unlink">
3977 #include <stdio.h>
3979 #define FILENAME "helloworld"
3981 if (remove (FILENAME) == 0) {
3982 printf ("We deleted %s successfully\n", FILENAME);
3984 printf ("There was a problem deleting %s\n", FILENAME);
3991 <sect1>rename<label id="rename"><p>
3995 <tag/Function/Rename a file.
3996 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
3997 <tag/Declaration/<tt/int __fastcall__ rename (const char* oldname, const char* newname);/
3998 <tag/Description/<tt/rename/ renames a file (gives it a new name). On success,
3999 zero is returned. On error, -1 is returned and <tt/errno/ is set to an error
4000 code describing the reason for the failure.
4003 <item>This function is not available on all cc65 targets (depends on the
4004 capabilities of the storage devices).
4005 <item>The function is only available as fastcall function, so it may only
4006 be used in presence of a prototype.
4008 <tag/Availability/ISO 9899
4010 <ref id="remove" name="remove">
4013 #include <stdio.h>
4015 #define OLDNAME "textfile.txt"
4016 #define NEWNAME "textfile.bak"
4018 if (rename (OLDNAME, NEWNAME) == 0) {
4019 printf ("Renamed %s to %s\n", OLDNAME, NEWNAME);
4021 printf ("Error renaming %s to %s\n", OLDNAME, NEWNAME);
4028 <sect1>reset_brk<label id="reset_brk"><p>
4032 <tag/Function/Resets the break vector to its original value.
4033 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
4034 <tag/Declaration/<tt/void __fastcall__ reset_brk (void);/
4035 <tag/Description/<tt/reset_brk/ resets the break vector to the value it had
4036 before a call to <tt/set_brk/.
4039 <item>Since <tt/<ref id="set_brk" name="set_brk">/ installs an exit handler,
4040 it is not strictly necessary to call this function as part of the cleanup when
4043 <tag/Availability/cc65
4045 <ref id="set_brk" name="set_brk">
4051 <sect1>revers<label id="revers"><p>
4055 <tag/Function/Control revers character display.
4056 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
4057 <tag/Declaration/<tt/unsigned char __fastcall__ revers (unsigned char onoff);/
4058 <tag/Description/If the argument is non zero, the function enables reverse
4059 character display. If the argument is zero, reverse character display is
4060 switched off. The old value of the setting is returned.
4061 <tag/Limits/<itemize>
4062 <item>The function may not be supported by the hardware, in which case
4063 the call is ignored.
4064 <item>The function is only available as fastcall function, so it may only
4065 be used in presence of a prototype.
4067 <tag/Availability/cc65
4069 <ref id="textcolor" name="textcolor">
4075 <sect1>screensize<label id="screensize"><p>
4079 <tag/Function/Return the dimensions of the text mode screen.
4080 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
4081 <tag/Declaration/<tt/void __fastcall__ screensize (unsigned char* x, unsigned char* y);/
4082 <tag/Description/The function returns the dimensions of the text mode screen.
4083 <tag/Limits/<itemize>
4084 <item>The function is only available as fastcall function, so it may only
4085 be used in presence of a prototype.
4087 <tag/Availability/cc65
4089 <ref id="gotox" name="gotox">,
4090 <ref id="gotoxy" name="gotoxy">,
4091 <ref id="gotoy" name="gotoy">,
4092 <ref id="wherex" name="wherex">,
4093 <ref id="wherey" name="wherey">
4099 <sect1>set_brk<label id="set_brk"><p>
4103 <tag/Function/Set the break vector to a user function.
4104 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
4105 <tag/Declaration/<tt/void __fastcall__ set_brk (brk_handler func);/
4106 <tag/Description/<tt/set_brk/ allows a user program to handle breaks within the
4107 program code by letting the vector point to a user written C function. The
4108 runtime library installs a small stub that saves the registers into global
4109 variables that may be accessed (and changed) by the break handler.
4112 <item>The function is only available as fastcall function, so it may only
4113 be used in presence of a prototype.
4114 <item>The stub saves the zero page registers used by the C runtime and switches
4115 to a small break handler stack. This means that it is safe to execute C code,
4116 even if C code was interrupted. Be careful however not to use too many local
4117 variables, and do not enable stack checks for the handler function or any other
4118 function called from it.
4119 <item>The <tt/brk_pc/ variable points to the <tt/BRK/ instruction. If you want
4120 the continue with the interrupted code, you have to adjust <tt/brk_pc/,
4121 otherwise the <tt/BRK/ instruction will get executed over and over again.
4122 <item>Since <tt/set_brk/ installs an exit handler, it is not strictly necessary
4123 to call <tt/<ref id="reset_brk" name="reset_brk">/ as part of the cleanup when
4124 the program terminates.
4126 <tag/Availability/cc65
4128 <ref id="reset_brk" name="reset_brk">
4134 <sect1>setjmp<label id="setjmp"><p>
4138 <tag/Function/Save the context for use with <tt/longjmp/.
4139 <tag/Header/<tt/<ref id="setjmp.h" name="setjmp.h">/
4140 <tag/Declaration/<tt/int __fastcall__ setjmp (jmp_buf buf);/
4141 <tag/Description/The <tt/setjmp/ function saves the current context in <tt/buf/
4142 for subsequent use by the <tt/<ref id="longjmp" name="longjmp">/ function and
4146 <item>The function is only available as fastcall function, so it may only
4147 be used in presence of a prototype.
4148 <item><tt/setjmp/ is actually a macro as required by the ISO standard.
4149 <item><tt/setjmp/ will not save the signal context.
4151 <tag/Availability/ISO 9899
4153 <ref id="longjmp" name="longjmp">
4159 <sect1>setlocale<label id="setlocale"><p>
4163 <tag/Function/Selects a locale.
4164 <tag/Header/<tt/<ref id="locale.h" name="locale.h">/
4165 <tag/Declaration/<tt/char* __fastcall__ setlocale (int category, const char* locale);/
4166 <tag/Description/<tt/setlocale/ sets or queries the program's locale.
4169 <item>The function is only available as fastcall function, so it may only
4170 be used in presence of a prototype.
4171 <item>cc65 supports only the "C" locale, so calling this function to set a
4172 different locale has no effect.
4174 <tag/Availability/ISO 9899
4176 <ref id="localeconv" name="localeconv">,
4177 <ref id="strcoll" name="strcoll">
4178 <ref id="strxfrm" name="strxfrm">
4184 <sect1>signal<label id="signal"><p>
4188 <tag/Function/Install a signal handler.
4189 <tag/Header/<tt/<ref id="signal.h" name="signal.h">/
4190 <tag/Declaration/<tt/__sigfunc __fastcall__ signal (int sig, __sigfunc func);/
4191 <tag/Description/<tt/signal/ installs a handler for the given signal. The
4192 handler may either be a user supplied function, or one of the predefined
4193 signal handlers <tt/SIG_IGN/ or <tt/SIG_DFL/. The function returns the
4194 previous value if the signal , or the special function vector SIG_ERR in
4196 <tag/Limits/<itemize>
4197 <item>The function is only available as fastcall function, so it may only
4198 be used in presence of a prototype.
4200 <tag/Availability/ISO 9899
4202 <ref id="abort" name="abort">,
4203 <ref id="raise" name="raise">
4209 <sect1>sleep<label id="sleep"><p>
4213 <tag/Function/Sleep for a specified amount of time.
4214 <tag/Header/<tt/<ref id="unistd.h" name="unistd.h">/
4215 <tag/Declaration/<tt/void __fastcall__ sleep (unsigned seconds);/
4216 <tag/Description/The function will return after the specified number of
4217 seconds have elapsed.
4218 <tag/Limits/<itemize>
4219 <item>The function is only available as fastcall function, so it may only
4220 be used in presence of a prototype.
4222 <tag/Availability/POSIX 1003.1
4228 <sect1>slow<label id="slow"><p>
4232 <tag/Function/Switch the C128 into 1MHz mode.
4233 <tag/Header/<tt/<ref id="c128.h" name="c128.h">/
4234 <tag/Declaration/<tt/void slow (void);/
4235 <tag/Description/The function will switch the clock of the C128 to 1MHz. This
4236 will halve the speed compared to fast mode.
4237 <tag/Limits/<itemize>
4238 <item>The function is specific to the C128.
4240 <tag/Availability/C128
4242 <ref id="fast" name="fast">,
4243 <ref id="toggle_videomode" name="toggle_videomode">,
4244 <ref id="videomode" name="videomode">
4250 <sect1>srand<label id="srand"><p>
4254 <tag/Function/Initialize the pseudo random number generator.
4255 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
4256 <tag/Declaration/<tt/void __fastcall__ srand (unsigned seed);/
4257 <tag/Description/The function initializes the random number generator using
4258 the given seed. On program startup, the generator behaves as if <tt/srand/ has
4259 been called with an argument of 1.
4260 <tag/Limits/<itemize>
4261 <item>The function is only available as fastcall function, so it may only
4262 be used in presence of a prototype.
4264 <tag/Availability/ISO 9899
4266 <ref id="_randomize" name="_randomize">,
4267 <ref id="rand" name="rand">
4273 <sect1>strcasecmp<label id="strcasecmp"><p>
4277 <tag/Function/Compare two strings case insensitive.
4278 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4279 <tag/Declaration/<tt/int __fastcall__ strcasecmp (const char* s1, const char* s2);/
4280 <tag/Description/The <tt/strcasecmp/ function compares the two strings passed
4281 as parameters without case sensitivity. It returns a value that is less than
4282 zero if <tt/s1/ is less than <tt/s2/, zero if <tt/s1/ is the same as <tt/s2/,
4283 and a value greater than zero if <tt/s1/ is greater than <tt/s2/.
4284 <tag/Limits/<itemize>
4285 <item>The function is only available as fastcall function, so it may only
4286 be used in presence of a prototype.
4287 <item>The function is not available in strict ANSI mode.
4289 <tag/Availability/cc65
4291 <ref id="strcmp" name="strcmp">,
4292 <ref id="strcoll" name="strcoll">,
4293 <ref id="stricmp" name="stricmp">,
4294 <ref id="strncmp" name="strncmp">
4295 <ref id="strxfrm" name="strxfrm">
4301 <sect1>strcat<label id="strcat"><p>
4305 <tag/Function/Concatentate two strings.
4306 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4307 <tag/Declaration/<tt/char* __fastcall__ strcat (char* s1, const char* s2);/
4308 <tag/Description/The <tt/strcat/ function appends a copy of the string
4309 pointed to by s2 (including the terminating null byte) to the end of the
4310 string pointed to by s1. The initial byte of s2 overwrites the null byte at
4312 <tag/Limits/<itemize>
4313 <item>The function is only available as fastcall function, so it may only
4314 be used in presence of a prototype.
4315 <item>If copying takes place between objects that overlap, the behaviour
4318 <tag/Availability/ISO 9899
4320 <ref id="strcpy" name="strcpy">,
4321 <ref id="strncat" name="strncat">,
4322 <ref id="strncpy" name="strncpy">
4328 <sect1>strchr<label id="strchr"><p>
4332 <tag/Function/Search for a character in a string.
4333 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4334 <tag/Declaration/<tt/char* __fastcall__ strchr (const char* s, int c);/
4335 <tag/Description/The <tt/strchr/ function locates the first occurrence of <tt/c/
4336 (converted to a char) in the string pointed to by <tt/s/. The terminating null
4337 byte is considered to be part of the string. Upon completion, the function
4338 returns a pointer to the byte, or a null pointer if the byte was not found.
4339 <tag/Limits/<itemize>
4340 <item>The function is only available as fastcall function, so it may only
4341 be used in presence of a prototype.
4343 <tag/Availability/ISO 9899
4345 <ref id="memchr" name="memchr">,
4346 <ref id="strrchr" name="strrchr">
4352 <sect1>strcmp<label id="strcmp"><p>
4356 <tag/Function/Compare two strings.
4357 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4358 <tag/Declaration/<tt/int __fastcall__ strcmp (const char* s1, const char* s2);/
4359 <tag/Description/The <tt/strcmp/ function compares the two strings passed as
4360 parameters. It returns a value that is less than zero if <tt/s1/ is less than
4361 <tt/s2/, zero if <tt/s1/ is the same as <tt/s2/, and a value greater than zero
4362 if <tt/s1/ is greater than <tt/s2/.
4363 <tag/Limits/<itemize>
4364 <item>The function is only available as fastcall function, so it may only
4365 be used in presence of a prototype.
4367 <tag/Availability/ISO 9899
4369 <ref id="strcasecmp" name="strcasecmp">,
4370 <ref id="strcoll" name="strcoll">,
4371 <ref id="stricmp" name="stricmp">,
4372 <ref id="strncmp" name="strncmp">
4373 <ref id="strxfrm" name="strxfrm">
4379 <sect1>strcoll<label id="strcoll"><p>
4383 <tag/Function/Compare two strings.
4384 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4385 <tag/Declaration/<tt/int __fastcall__ strcoll (const char* s1, const char* s2);/
4386 <tag/Description/The <tt/strcoll/ function compares the two strings passed as
4387 parameters, according to the collating sequence set by <tt/<ref id="setlocale"
4388 name="setlocale">/. It returns a value that is less than zero if <tt/s1/ is
4389 less than <tt/s2/, zero if <tt/s1/ is the same as <tt/s2/, and a value greater
4390 than zero if <tt/s1/ is greater than <tt/s2/.
4391 <tag/Limits/<itemize>
4392 <item>The function is only available as fastcall function, so it may only
4393 be used in presence of a prototype.
4395 <tag/Availability/ISO 9899
4397 <ref id="setlocale" name="setlocale">,
4398 <ref id="strcasecmp" name="strcasecmp">,
4399 <ref id="strcmp" name="strcmp">,
4400 <ref id="stricmp" name="stricmp">,
4401 <ref id="strncmp" name="strncmp">
4402 <ref id="strxfrm" name="strxfrm">
4408 <sect1>strcpy<label id="strcpy"><p>
4412 <tag/Function/Copy a string.
4413 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4414 <tag/Declaration/<tt/char* __fastcall__ strcpy (char* s1, const char* s2);/
4415 <tag/Description/The <tt/strcpy/ function copies the string pointed to by
4416 <tt/s2/ (including the terminating null byte) into the array pointed to by
4417 <tt/s1/. The function will always return <tt/s1/.
4418 <tag/Limits/<itemize>
4419 <item>The function is only available as fastcall function, so it may only
4420 be used in presence of a prototype.
4421 <item>If copying takes place between objects that overlap, the behaviour
4424 <tag/Availability/ISO 9899
4426 <ref id="strcat" name="strcat">,
4427 <ref id="strncat" name="strncat">,
4428 <ref id="strncpy" name="strncpy">
4431 #include <string.h>
4433 static char hello[14];
4435 strcpy (hello, "Hello world!\n");
4441 <sect1>strcspn<label id="strcspn"><p>
4445 <tag/Function/Compute the length of a substring.
4446 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4447 <tag/Declaration/<tt/size_t __fastcall__ strcspn (const char* s, const char* set);/
4448 <tag/Description/The <tt/strcspn/ function computes and returns the length of
4449 the substring pointed to by <tt/s/ which does <em>not</em> consist of
4450 characters contained in the string <tt/set/.
4451 <tag/Limits/<itemize>
4452 <item>The function is only available as fastcall function, so it may only
4453 be used in presence of a prototype.
4455 <tag/Availability/ISO 9899
4457 <ref id="strspn" name="strspn">,
4458 <ref id="strstr" name="strstr">,
4459 <ref id="strtok" name="strtok">
4465 <sect1>strdup<label id="strdup"><p>
4469 <tag/Function/Allocate a copy of a string on the heap.
4470 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4471 <tag/Declaration/<tt/char* __fastcall__ strdup (const char* s);/
4472 <tag/Description/<tt/strdup/ allocates a memory block on the heap, big enough
4473 to hold a copy of <tt/s/ including the terminating zero. If the allocation
4474 fails, <tt/NULL/ is returned, otherwise <tt/s/ is copied into the allocated
4475 memory block, and a pointer to the block is returned.
4476 <tag/Limits/<itemize>
4477 <item>The function is only available as fastcall function, so it may only
4478 be used in presence of a prototype.
4479 <item>It is up to the caller to free the allocated memory block.
4481 <tag/Availability/ISO 9899
4483 <ref id="free" name="free">,
4484 <ref id="malloc" name="malloc">
4490 <sect1>strerror<label id="strerror"><p>
4494 <tag/Function/Return a string describing an error code.
4495 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4496 <tag/Declaration/<tt/char* __fastcall__ strerror (int errcode);/
4497 <tag/Description/The <tt/strerror/ function returns a string describing the
4498 given error code. If an invalid error code is passed, the string "Unknown
4499 error" is returned, and <tt/errno/ is set to <tt/EINVAL/. In all other cases,
4500 <tt/errno/ is left untouched.
4501 <tag/Limits/<itemize>
4502 <item>The function is only available as fastcall function, so it may only
4503 be used in presence of a prototype.
4504 <item>While the return type of the function is a <tt/char*/, the returned
4505 string must not be modified by the caller!
4507 <tag/Availability/ISO 9899
4509 <ref id="_stroserror" name="_stroserror">
4515 <sect1>stricmp<label id="stricmp"><p>
4519 <tag/Function/Compare two strings case insensitive.
4520 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4521 <tag/Declaration/<tt/int __fastcall__ stricmp (const char* s1, const char* s2);/
4522 <tag/Description/The <tt/stricmp/ function compares the two strings passed as
4523 parameters without case sensitivity. It returns a value that is less than zero
4524 if <tt/s1/ is less than <tt/s2/, zero if <tt/s1/ is the same as <tt/s2/, and a
4525 value greater than zero if <tt/s1/ is greater than <tt/s2/.
4526 <tag/Limits/<itemize>
4527 <item>The function is only available as fastcall function, so it may only
4528 be used in presence of a prototype.
4529 <item>The function is not available in strict ANSI mode.
4531 <tag/Availability/cc65
4533 <ref id="strcasecmp" name="strcasecmp">,
4534 <ref id="strcmp" name="strcmp">,
4535 <ref id="strcoll" name="strcoll">,
4536 <ref id="strncmp" name="strncmp">
4537 <ref id="strxfrm" name="strxfrm">
4543 <sect1>strlen<label id="strlen"><p>
4547 <tag/Function/Return the length of a string.
4548 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4549 <tag/Declaration/<tt/size_t __fastcall__ strlen (const char* s);/
4550 <tag/Description/The <tt/strlen/ function computes the number of bytes in the
4551 string to which s points, not including the terminating null byte.
4552 <tag/Limits/<itemize>
4553 <item>The function is only available as fastcall function, so it may only
4554 be used in presence of a prototype.
4555 <item>When compiling with <tt/-Os/ (inline known standard functions), the
4556 function does not work correctly for strings with more than 255 characters.
4558 <tag/Availability/ISO 9899
4560 <ref id="strcpy" name="strcpy">
4566 <sect1>strlower<label id="strlower"><p>
4570 <tag/Function/Make a string lower case.
4571 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4572 <tag/Declaration/<tt/char* __fastcall__ strlower (char* s);/
4573 <tag/Description/The <tt/strlower/ function will apply the <tt/tolower/
4574 function to each character of a string. The function will always return <tt/s/.
4575 <tag/Limits/<itemize>
4576 <item>The function is only available as fastcall function, so it may only
4577 be used in presence of a prototype.
4578 <item>The function prototype is unavailable when compiling in strict ANSI mode.
4579 <item>An alias name for this function is <tt/strlwr/.
4581 <tag/Availability/cc65
4583 <ref id="strupper" name="strupper">,
4584 <ref id="tolower" name="tolower">
4590 <sect1>strlwr<label id="strlwr"><p>
4597 <sect1>strncat<label id="strncat"><p>
4601 <tag/Function/Concatentate two strings.
4602 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4603 <tag/Declaration/<tt/char* __fastcall__ strncat (char* s1, const char* s2, size_t n);/
4604 <tag/Description/The <tt/strncat/ function appends not more than n characters
4605 of the string pointed to by s2 to the end of the string pointed to by s1. The
4606 terminating null character at the end of s1 is overwritten. A terminating null
4607 character is appended to the result, even if not all of s2 is appended to s1.
4608 <tag/Limits/<itemize>
4609 <item>The function is only available as fastcall function, so it may only
4610 be used in presence of a prototype.
4611 <item>If copying takes place between objects that overlap, the behaviour
4614 <tag/Availability/ISO 9899
4616 <ref id="strcpy" name="strcpy">,
4617 <ref id="strncat" name="strncat">,
4618 <ref id="strncpy" name="strncpy">
4624 <sect1>strncmp<label id="strncmp"><p>
4628 <tag/Function/Compare two strings.
4629 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4630 <tag/Declaration/<tt/int __fastcall__ strncmp (const char* s1, const char* s2, size_t count);/
4631 <tag/Description/The <tt/strncmp/ function compares not more than <tt/count/
4632 characters of the two strings passed as parameters. It returns a value that is
4633 less than zero if the first <tt/count/ characters of <tt/s1/ are less than
4634 <tt/s2/, zero if they are identical, and a value greater than zero they are
4636 <tag/Limits/<itemize>
4637 <item>The function is only available as fastcall function, so it may only
4638 be used in presence of a prototype.
4640 <tag/Availability/ISO 9899
4642 <ref id="strcasecmp" name="strcasecmp">,
4643 <ref id="strcmp" name="strcmp">,
4644 <ref id="strcoll" name="strcoll">,
4645 <ref id="stricmp" name="stricmp">
4646 <ref id="strxfrm" name="strxfrm">
4652 <sect1>strncpy<label id="strncpy"><p>
4656 <tag/Function/Copy part of a string.
4657 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4658 <tag/Declaration/<tt/char* __fastcall__ strcpy (char* s1, const char* s2, size_t n);/
4659 <tag/Description/The <tt/strncpy/ function copies not more than n bytes from
4660 the array pointed to by <tt/s2/ to the array pointed to by <tt/s1/. If the array
4661 pointed to by <tt/s2/ is a string that is shorter than n bytes, null bytes are
4662 appended to the copy in the array pointed to by <tt/s1/, until <tt/n/ bytes are
4663 written. The function will always return <tt/s1/.
4664 <tag/Limits/<itemize>
4665 <item>The function is only available as fastcall function, so it may only
4666 be used in presence of a prototype. If there is no null byte in the first <tt/n/
4667 bytes of the array pointed to by <tt/s2/, the result is not null-terminated.
4668 <item>If copying takes place between objects that overlap, the behaviour is
4671 <tag/Availability/ISO 9899
4673 <ref id="strcat" name="strcat">,
4674 <ref id="strcpy" name="strcpy">,
4675 <ref id="strncat" name="strncat">
4680 static char hello[6];
4682 strcpy (hello, "Hello world!\n", sizeof (hello) - 1);
4689 <sect1>strrchr<label id="strrchr"><p>
4693 <tag/Function/Search for a character in a string.
4694 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4695 <tag/Declaration/<tt/char* __fastcall__ strrchr (const char* s, int c);/
4696 <tag/Description/The <tt/strrchr/ function locates the last occurrence of <tt/c/
4697 (converted to a char) in the string pointed to by <tt/s/. The terminating null
4698 byte is considered to be part of the string. Upon completion, the function
4699 returns a pointer to the byte, or a null pointer if the byte was not found.
4700 <tag/Limits/<itemize>
4701 <item>The function is only available as fastcall function, so it may only
4702 be used in presence of a prototype.
4704 <tag/Availability/ISO 9899
4706 <ref id="strchr" name="strchr">
4712 <sect1>strspn<label id="strspn"><p>
4716 <tag/Function/Compute the length of a substring.
4717 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4718 <tag/Declaration/<tt/size_t __fastcall__ strspn (const char* s, const char* set);/
4719 <tag/Description/The <tt/strspn/ function computes and returns the length of
4720 the substring pointed to by <tt/s/ which does consist only of characters
4721 contained in the string <tt/set/.
4722 <tag/Limits/<itemize>
4723 <item>The function is only available as fastcall function, so it may only
4724 be used in presence of a prototype.
4726 <tag/Availability/ISO 9899
4728 <ref id="strcspn" name="strcspn">,
4729 <ref id="strstr" name="strstr">
4735 <sect1>strstr<label id="strstr"><p>
4739 <tag/Function/Find a substring.
4740 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4741 <tag/Declaration/<tt/char* __fastcall__ strstr (const char* str, const char* substr);/
4742 <tag/Description/<tt/strstr/ searches for the first occurance of the string
4743 <tt/substr/ within <tt/str/. If found, it returns a pointer to the copy,
4744 otherwise it returns <tt/NULL/.
4745 <tag/Limits/<itemize>
4746 <item>The function is only available as fastcall function, so it may only
4747 be used in presence of a prototype.
4749 <tag/Availability/ISO 9899
4751 <ref id="strcspn" name="strcspn">,
4752 <ref id="strspn" name="strspn">
4758 <sect1>strtok<label id="strtok"><p>
4762 <tag/Function/Break a string into tokens.
4763 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4764 <tag/Declaration/<tt/char* __fastcall__ strtok (char* s1, const char* s2);/
4765 <tag/Description/<tt/strtok/ will break the string s1 into a sequence of
4766 tokens, which are delimited by characters from the string s2. The first call
4767 to <tt/strtok/ will return a pointer to the first token in the string s1.
4768 Following calls must pass a <tt/NULL/ pointer as s1 in order to get the next
4769 token in the string. Different sets of delimiters may be used for the
4770 subsequent calls to <tt/strtok/.
4771 <tag/Limits/<itemize>
4772 <item>The function is only available as fastcall function, so it may only
4773 be used in presence of a prototype.
4774 <item><tt/strtok/ will modify the string s1.
4776 <tag/Availability/ISO 9899
4778 <ref id="strcspn" name="strcspn">,
4779 <!-- <ref id="strpbrk" name="strpbrk"> -->
4785 <sect1>strxfrm<label id="strxfrm"><p>
4789 <tag/Function/Transform a string.
4790 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4791 <tag/Declaration/<tt/size_t __fastcall__ strxfrm (char* s1, const char* s2, size_t n);/
4792 <tag/Description/The <tt/strxfrm/ function transforms the string pointed to by
4793 s2 and places the resulting string into the string pointed to by s1. The
4794 transformation is such that if the <tt/strcmp/ function is applied to two
4795 transformed strings, it returns a value greater than, equal to, or less than
4796 zero, corresponding to the result of the <tt/strcoll/ function applied to the
4797 same two original strings. No more than n characters are placed into the
4798 resulting array pointed to by s1, including the terminating null character.
4799 <tag/Limits/<itemize>
4800 <item><tt/s1/ and <tt/s2/ must not point to the same memory area, otherwise
4801 the behaviour is undefined.
4802 <item>If <tt/n/ is zero, <tt/s1/ may be a NULL pointer.
4803 <item>The function is only available as fastcall function, so it may only
4804 be used in presence of a prototype.
4805 <item>Since cc65 doesn't support different charcter sets, <tt/strxfrm/ will
4806 just copy s2 to s1 using <tt><ref id="strncpy" name="strncpy"></tt>.
4808 <tag/Availability/ISO 9899
4810 <ref id="strcmp" name="strcmp">,
4811 <ref id="strcoll" name="strcoll">,
4812 <ref id="strncpy" name="strncpy">,
4818 <sect1>strupper<label id="strupper"><p>
4822 <tag/Function/Make a string upper case.
4823 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4824 <tag/Declaration/<tt/char* __fastcall__ strupper (char* s);/
4825 <tag/Description/The <tt/strupper/ function will apply the <tt/toupper/
4826 function to each character of a string. The function will always return <tt/s/.
4827 <tag/Limits/<itemize>
4828 <item>The function is only available as fastcall function, so it may only
4829 be used in presence of a prototype.
4830 <item>The function prototype is unavailable when compiling in strict ANSI mode.
4831 <item>An alias name for this function is <tt/strupr/.
4833 <tag/Availability/cc65
4835 <ref id="strlower" name="strlower">
4836 <ref id="toupper" name="toupper">
4842 <sect1>strupr<label id="strupr"><p>
4849 <sect1>textcolor<label id="textcolor"><p>
4853 <tag/Function/Set the text color.
4854 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
4855 <tag/Declaration/<tt/unsigned char __fastcall__ textcolor (unsigned char color);/
4856 <tag/Description/The function will set a new text color. It returns the old
4857 (current) text color. Text output using any <tt/conio.h/ function will use
4858 the color set by this function.
4859 <tag/Limits/<itemize>
4860 <item>Text colors are system dependent. The function may have no effect
4861 on systems where the text color cannot be changed.
4862 <item>The function is only available as fastcall function, so it may only
4863 be used in presence of a prototype.
4865 <tag/Availability/cc65
4867 <ref id="bgcolor" name="bgcolor">,
4868 <ref id="bordercolor" name="bordercolor">
4874 <sect1>tgi_bar<label id="tgi_bar"><p>
4878 <tag/Function/The function fills a rectangle on the drawpage with the current
4880 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
4881 <tag/Declaration/<tt/void __fastcall__ tgi_bar (int x1, int y1, int x2, int y2);/
4882 <tag/Description/The function fills a rectangle on the drawpage with the current
4884 <tag/Limits/<itemize>
4885 <item>The function is only available as fastcall function, so it may only
4886 be used in presence of a prototype.
4888 <tag/Availability/cc65
4889 <tag/See also/Other tgi function
4891 tgi_setcolor(COLOR_GREEN);
4892 tgi_bar(10, 10, 100, 60);
4897 <sect1>tgi_circle<label id="tgi_circle"><p>
4901 <tag/Function/The function draws a circle in the current color.
4902 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
4903 <tag/Declaration/<tt/void __fastcall__ tgi_circle (int x, int y, unsigned char radius);/
4904 <tag/Description/The function draws a circle in the current color.
4905 <tag/Limits/<itemize>
4906 <item>The function is only available as fastcall function, so it may only
4907 be used in presence of a prototype.
4909 <tag/Availability/cc65
4910 <tag/See also/Other tgi functions
4912 tgi_setcolor(COLOR_BLACK);
4913 tgi_circle(50, 40, 40);
4918 <sect1>tgi_clear<label id="tgi_clear"><p>
4922 <tag/Function/Clear the screen
4923 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
4924 <tag/Declaration/<tt/void __fastcall__ tgi_clear (void);/
4925 <tag/Description/Clear the screen
4926 <tag/Limits/<itemize>
4927 <item>The function is only available as fastcall function, so it may only
4928 be used in presence of a prototype.
4930 <tag/Availability/cc65
4931 <tag/See also/Other tgi functions
4936 <sect1>tgi_done<label id="tgi_done"><p>
4940 <tag/Function/End graphics mode, switch back to text mode.
4941 Will NOT uninstall or unload the driver!
4942 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
4943 <tag/Declaration/<tt/void __fastcall__ tgi_done (void);/
4944 <tag/Description/End graphics mode, switch back to text mode.
4945 Will NOT uninstall or unload the driver!
4946 <tag/Limits/<itemize>
4947 <item>The function is only available as fastcall function, so it may only
4948 be used in presence of a prototype.
4950 <tag/Availability/cc65
4951 <tag/See also/Other tgi functions
4956 <sect1>tgi_getcolor<label id="tgi_getcolor"><p>
4960 <tag/Function/Return the current drawing color.
4961 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
4962 <tag/Declaration/<tt/unsigned char __fastcall__ tgi_getcolor (void);/
4963 <tag/Description/The actual color is an index to a palette. During tgi_init
4964 you will get a default palette. The number of colors depend on the platform.
4965 All platforms recognize at least COLOR_BLACK and COLOR_WHITE. But some
4966 platforms have many more predefined colors. If you paint using COLOR_GREEN
4967 and then you change the green of the palette to blue using tgi_setpalette then
4968 after this painting in COLOR_GREEN will actually be blue.
4969 <tag/Limits/<itemize>
4970 <item>The function is only available as fastcall function, so it may only
4971 be used in presence of a prototype.
4973 <tag/Availability/cc65
4974 <tag/See also/Other tgi functions
4976 color = tgi_getcolor();
4981 <sect1>tgi_getcolorcount<label id="tgi_getcolorcount"><p>
4985 <tag/Function/Get the number of available colors.
4986 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
4987 <tag/Declaration/<tt/unsigned char __fastcall__ tgi_getcolorcount (void);/
4988 <tag/Description/Tgi platforms use indexed color palettes. This function
4989 returns the number of entries we can use in the palette.
4990 <tag/Limits/<itemize>
4991 <item>The function is only available as fastcall function, so it may only
4992 be used in presence of a prototype.
4994 <tag/Availability/cc65
4995 <tag/See also/Other tgi functions
4997 if (tgi_getcolorcount() == 2) {
4998 printf("Only monochrome graphics is supported\n");
5004 <sect1>tgi_getdefpalette<label id="tgi_getdefpalette"><p>
5008 <tag/Function/Get the palette installed by default.
5009 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5010 <tag/Declaration/<tt/const unsigned char* __fastcall__ tgi_getdefpalette (void);/
5011 <tag/Description/The tgi driver has a default palette that is active at startup.
5012 The named colors COLOR_BLACK, COLOR_WHITE, COLOR_RED... need this palette to
5014 <tag/Limits/<itemize>
5015 <item>The function is only available as fastcall function, so it may only
5016 be used in presence of a prototype.
5018 <tag/Availability/cc65
5019 <tag/See also/Other tgi functions
5024 <sect1>tgi_geterror<label id="tgi_geterror"><p>
5028 <tag/Function/Return the error code for the last operation.
5029 This will also clear the error.
5030 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5031 <tag/Declaration/<tt/unsigned char __fastcall__ tgi_geterror (void);/
5032 <tag/Description/Return the error code for the last operation.
5033 This will also clear the error.
5034 <tag/Limits/<itemize>
5035 <item>The function is only available as fastcall function, so it may only
5036 be used in presence of a prototype.
5038 <tag/Availability/cc65
5039 <tag/See also/Other tgi functions
5044 <sect1>tgi_geterrormsg<label id="tgi_geterrormsg"><p>
5048 <tag/Function/Get an error message describing the error.
5049 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5050 <tag/Declaration/<tt/const char* __fastcall__ tgi_geterrormsg (unsigned char code);/
5051 <tag/Description/Get an error message describing the error.
5052 <tag/Limits/<itemize>
5053 <item>The function is only available as fastcall function, so it may only
5054 be used in presence of a prototype.
5056 <tag/Availability/cc65
5057 <tag/See also/Other tgi functions
5062 <sect1>tgi_getmaxcolor<label id="tgi_getmaxcolor"><p>
5066 <tag/Function/Get the highest index of the palette.
5067 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5068 <tag/Declaration/<tt/unsigned char __fastcall__ tgi_getmaxcolor (void);/
5069 <tag/Description/Get the highest index of the palette.
5070 <tag/Limits/<itemize>
5071 <item>The function is only available as fastcall function, so it may only
5072 be used in presence of a prototype.
5074 <tag/Availability/cc65
5075 <tag/See also/Other tgi functions
5080 <sect1>tgi_getmaxx<label id="tgi_getmaxx"><p>
5084 <tag/Function/Get the maximum x coordinate that can be used on this screen.
5085 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5086 <tag/Declaration/<tt/unsigned __fastcall__ tgi_getmaxx (void);/
5087 <tag/Description/Get the maximum x coordinate that can be used on this screen.
5088 <tag/Limits/<itemize>
5089 <item>The function is only available as fastcall function, so it may only
5090 be used in presence of a prototype.
5092 <tag/Availability/cc65
5093 <tag/Availability/cc65
5094 <tag/See also/Other tgi functions
5099 <sect1>tgi_getmaxy<label id="tgi_getmaxy"><p>
5103 <tag/Function/Get the maximum y coordinate that can be used on this screen.
5104 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5105 <tag/Declaration/<tt/unsigned __fastcall__ tgi_getmaxy (void);/
5106 <tag/Description/Get the maximum y coordinate that can be used on this screen.
5107 <tag/Limits/<itemize>
5108 <item>The function is only available as fastcall function, so it may only
5109 be used in presence of a prototype.
5111 <tag/Availability/cc65
5112 <tag/See also/Other tgi functions
5117 <sect1>tgi_getpagecount<label id="tgi_getpagecount"><p>
5121 <tag/Function/Return the number of screen pages available.
5122 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5123 <tag/Declaration/<tt/unsigned __fastcall__ tgi_getpagecount (void);/
5124 <tag/Description/Return the number of screen pages available.
5125 <tag/Limits/<itemize>
5126 <item>The function is only available as fastcall function, so it may only
5127 be used in presence of a prototype.
5129 <tag/Availability/cc65
5131 <ref id="tgi_setdrawpage" name="tgi_setdrawpage">,
5132 <ref id="tgi_setviewpage" name="tgi_setviewpage">
5137 <sect1>tgi_getpalette<label id="tgi_getpalette"><p>
5141 <tag/Function/Get the palette installed.
5142 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5143 <tag/Declaration/<tt/const unsigned char* __fastcall__ tgi_getpalette (void);/
5144 <tag/Description/Get the palette installed.
5145 <tag/Limits/<itemize>
5146 <item>The function is only available as fastcall function, so it may only
5147 be used in presence of a prototype.
5149 <tag/Availability/cc65
5150 <tag/See also/Other tgi functions
5155 <sect1>tgi_getpixel<label id="tgi_getpixel"><p>
5159 <tag/Function/Get the color of a pixel from the viewpage.
5160 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5161 <tag/Declaration/<tt/unsigned char __fastcall__ tgi_getpixel (int x, int y);/
5162 <tag/Description/Get the color of a pixel from the viewpage.
5163 <tag/Limits/<itemize>
5164 <item>The function is only available as fastcall function, so it may only
5165 be used in presence of a prototype.
5167 <tag/Availability/cc65
5168 <tag/See also/Other tgi functions.
5173 <sect1>tgi_getxres<label id="tgi_getxres"><p>
5177 <tag/Function/Get number of horisontal pixels on the screen.
5178 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5179 <tag/Declaration/<tt/unsigned __fastcall__ tgi_getxres (void);/
5180 <tag/Description/Get number of horisontal pixels on the screen.
5181 This is same as tgi_maxx()+1.
5182 <tag/Limits/<itemize>
5183 <item>The function is only available as fastcall function, so it may only
5184 be used in presence of a prototype.
5186 <tag/Availability/cc65
5187 <tag/See also/Other tgi functions.
5192 <sect1>tgi_getyres<label id="tgi_getyres"><p>
5196 <tag/Function/Get number of vertical pixels on the screen.
5197 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5198 <tag/Declaration/<tt/unsigned __fastcall__ tgi_getyres (void);/
5199 <tag/Description/Get number of vertical pixels on the screen.
5200 This is same as tgi_maxy()+1.
5201 <tag/Limits/<itemize>
5202 <item>The function is only available as fastcall function, so it may only
5203 be used in presence of a prototype.
5205 <tag/Availability/cc65
5206 <tag/See also/Other tgi functions.
5211 <sect1>tgi_gotoxy<label id="tgi_gotoxy"><p>
5215 <tag/Function/Set graphics cursor at x, y.
5216 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5217 <tag/Declaration/<tt/void __fastcall__ tgi_gotoxy (int x, int y);/
5218 <tag/Description/Set graphics cursor at x, y.
5219 <tag/Limits/<itemize>
5220 <item>The function is only available as fastcall function, so it may only
5221 be used in presence of a prototype.
5223 <tag/Availability/cc65
5224 <tag/See also/Other tgi functions.
5229 <sect1>tgi_init<label id="tgi_init"><p>
5233 <tag/Function/Initialize the already loaded graphics driver.
5234 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5235 <tag/Declaration/<tt/void __fastcall__ tgi_init (void);/
5236 <tag/Description/The tgi_init function will set the default palette to the
5237 hardware and clear the screen.
5238 <tag/Limits/<itemize>
5239 <item>The function is only available as fastcall function, so it may only
5240 be used in presence of a prototype.
5242 <tag/Availability/cc65
5243 <tag/See also/Other tgi functions.
5245 extern char lynxtgi[]; //Include the driver statically instead of loading it.
5246 tgi_install(&lynxtgi);
5247 tgi_init(); //Set up the default palette and clear the screen.
5252 <sect1>tgi_install<label id="tgi_install"><p>
5256 <tag/Function/Install an already loaded driver and return an error code.
5257 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5258 <tag/Declaration/<tt/unsigned char __fastcall__ tgi_install (void* driver);/
5259 <tag/Description/The function installs a driver that was already loaded into
5260 memory (or linked statically to the program). It returns an error code
5261 (<tt/TGI_ERR_OK/ in case of success).
5262 <tag/Limits/<itemize>
5263 <item>The function is only available as fastcall function, so it may only be
5264 used in presence of a prototype.
5266 <tag/Availability/cc65
5268 <ref id="tgi_load_driver" name="tgi_load_driver">,
5269 <ref id="tgi_uninstall" name="tgi_uninstall">,
5270 <ref id="tgi_unload" name="tgi_unload">
5272 extern char lynxtgi[]; //Include the driver statically instead of loading it.
5274 tgi_install(&lynxtgi);
5275 tgi_init(); //Set up the default palette and clear the screen.
5280 <sect1>tgi_ioctl<label id="tgi_ioctl"><p>
5284 <tag/Function/Platform dependent code extensions.
5285 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5286 <tag/Declaration/<tt/unsigned __fastcall__ tgi_ioctl (unsigned char code, unsigned val);/
5287 <tag/Description/Some platforms have extra display hardware that is not
5288 supported by standard tgi functions. You can extend the driver to support
5289 this extra hardware using tgi_ioctl functions.
5290 <tag/Limits/<itemize>
5291 <item>The function is only available as fastcall function, so it may only
5292 be used in presence of a prototype.
5293 <item>These functions are not easily portable to other cc65 platforms.
5295 <tag/Availability/cc65
5296 <tag/See also/Other tgi functions.
5298 #define tgi_sprite(spr) tgi_ioctl(0, (unsigned)(spr))
5299 #define tgi_flip() tgi_ioctl(1, 0)
5300 #define tgi_setbgcolor(bgcol) tgi_ioctl(2, (unsigned)(bgcol))
5301 #define tgi_setframerate(rate) tgi_ioctl(3, (unsigned)(rate))
5302 #define tgi_busy() tgi_ioctl(4, 0)
5303 #define tgi_updatedisplay() tgi_ioctl(4, 1)
5305 tgi_sprite(&background);
5306 tgi_setcolor(COLOR_BLUE);
5307 tgi_outttextxy(20,40,"Hello World");
5308 tgi_updatedisplay();
5314 <sect1>tgi_line<label id="tgi_line"><p>
5318 <tag/Function/Draw a line in the current drawing color.
5319 The graphics cursor will be set to x2/y2 by this call.
5320 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5321 <tag/Declaration/<tt/void __fastcall__ tgi_line (int x1, int y1, int x2, int y2);/
5322 <tag/Description/Draw a line in the current drawing color.
5323 The graphics cursor will be set to x2/y2 by this call.
5324 <tag/Limits/<itemize>
5325 <item>The function is only available as fastcall function, so it may only
5326 be used in presence of a prototype.
5328 <tag/Availability/cc65
5329 <tag/See also/Other tgi functions.
5334 <sect1>tgi_lineto<label id="tgi_lineto"><p>
5338 <tag/Function/Draw a line in the current drawing color from the graphics
5339 cursor to the new end point. The graphics cursor will be updated to x2/y2.
5340 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5341 <tag/Declaration/<tt/void __fastcall__ tgi_lineto (int x2, int y2);/
5342 <tag/Description/Draw a line in the current drawing color from the graphics
5343 cursor to the new end point. The graphics cursor will be updated to x2/y2.
5344 <tag/Limits/<itemize>
5345 <item>The function is only available as fastcall function, so it may only
5346 be used in presence of a prototype.
5348 <tag/Availability/cc65
5349 <tag/See also/Other tgi functions.
5354 <sect1>tgi_load<label id="tgi_load"><p>
5358 <tag/Function/Load and install the matching driver for the given mode.
5359 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5360 <tag/Declaration/<tt/void __fastcall__ tgi_load (unsigned char mode);/
5361 <tag/Description/Load and install the matching driver for the given mode.
5362 Will just load the driver and check if loading was successul.
5363 Will not switch to graphics mode.
5364 <tag/Limits/<itemize>
5365 <item>The function is only available as fastcall function, so it may only
5366 be used in presence of a prototype.
5368 <tag/Availability/cc65
5369 <tag/See also/Other tgi functions.
5374 <sect1>tgi_load_driver<label id="tgi_load_driver"><p>
5378 <tag/Function/Load and install the given driver. This function is identical
5379 to tgi_load with the only difference that the name of the driver is specified
5381 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5382 <tag/Declaration/<tt/void __fastcall__ tgi_load_driver (const char *name);/
5383 <tag/Description/Load and install the driver by name.
5384 Will just load the driver and check if loading was successul.
5385 Will not switch to graphics mode.
5386 <tag/Limits/<itemize>
5387 <item>The function is only available as fastcall function, so it may only
5388 be used in presence of a prototype.
5390 <tag/Availability/cc65
5391 <tag/See also/Other tgi functions.
5396 <sect1>tgi_outtext<label id="tgi_outtext"><p>
5400 <tag/Function/Output text at the current graphics cursor position.
5401 The graphics cursor is moved to the end of the text.
5402 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5403 <tag/Declaration/<tt/void __fastcall__ tgi_outtext (const char* s);/
5404 <tag/Description/Output text at the current graphics cursor position.
5405 The graphics cursor is moved to the end of the text.
5406 <tag/Limits/<itemize>
5407 <item>The function is only available as fastcall function, so it may only
5408 be used in presence of a prototype.
5410 <tag/Availability/cc65
5411 <tag/See also/Other tgi functions.
5416 <sect1>tgi_outtextxy<label id="tgi_outtextxy"><p>
5420 <tag/Function/Output text at the given cursor position.
5421 The graphics cursor is moved to the end of the text.
5422 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5423 <tag/Declaration/<tt/void __fastcall__ tgi_outtextxy (int x, int y, const char* s);/
5424 <tag/Description/Output text at the given cursor position.
5425 The graphics cursor is moved to the end of the text.
5426 <tag/Limits/<itemize>
5427 <item>The function is only available as fastcall function, so it may only
5428 be used in presence of a prototype.
5430 <tag/Availability/cc65
5431 <tag/See also/Other tgi functions.
5436 <sect1>tgi_setcolor<label id="tgi_setcolor"><p>
5440 <tag/Function/Set color to be used in future draw operations.
5441 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5442 <tag/Declaration/<tt/void __fastcall__ tgi_setcolor (unsigned char color);/
5443 <tag/Description/Set color to be used in future draw operations.
5444 <tag/Limits/<itemize>
5445 <item>The function is only available as fastcall function, so it may only
5446 be used in presence of a prototype.
5448 <tag/Availability/cc65
5449 <tag/See also/Other tgi functions.
5451 tgi_setcolor(COLOR_BLACK);
5453 tgi_setcolor(COLOR_WHITE);
5454 tgi_bar(10,10,20,20);
5459 <sect1>tgi_setdrawpage<label id="tgi_setdrawpage"><p>
5463 <tag/Function/Set the page for drawing.
5464 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5465 <tag/Declaration/<tt/void __fastcall__ tgi_setdrawpage (unsigned char page);/
5466 <tag/Description/If the drawpage and the viewpage are the same then all drawing
5467 is seen immediately as it is drawn. For double buffered games you can set the
5468 drawpage to a different page than the viewpage. This lets you draw the next
5469 screen in the background and when the screen is ready you display it.
5470 <tag/Limits/<itemize>
5471 <item>The function is only available as fastcall function, so it may only
5472 be used in presence of a prototype.
5474 <tag/Availability/cc65
5475 <tag/See also/Other tgi functions.
5478 tgi_outtextxy(10, 10, "Hello World");
5479 tgi_setviewpage(1); // Show page 1
5481 tgi_outtextxy(10, 10, "Creating next frame");
5483 tgi_setviewpage(0); // Show page 0
5488 <sect1>tgi_setpalette<label id="tgi_setpalette"><p>
5492 <tag/Function/Set the palette (not available with all drivers/hardware).
5493 Palette is a pointer to as many entries as there are colors.
5494 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5495 <tag/Declaration/<tt/void __fastcall__ tgi_setpalette (const unsigned char* palette);/
5496 <tag/Description/Set the palette (not available with all drivers/hardware).
5497 Palette is a pointer to as many entries as there are colors.
5498 <tag/Limits/<itemize>
5499 <item>The function is only available as fastcall function, so it may only
5500 be used in presence of a prototype.
5502 <tag/Availability/cc65
5503 <tag/See also/Other tgi functions.
5508 <sect1>tgi_setpixel<label id="tgi_setpixel"><p>
5512 <tag/Function/Plot a pixel on the drawpage with the current color.
5513 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5514 <tag/Declaration/<tt/void __fastcall__ tgi_setpixel (int x, int y);/
5515 <tag/Description/Plot a pixel on the drawpage with the current color.
5516 <tag/Limits/<itemize>
5517 <item>The function is only available as fastcall function, so it may only
5518 be used in presence of a prototype.
5520 <tag/Availability/cc65
5521 <tag/See also/Other tgi functions.
5526 <sect1>tgi_setviewpage<label id="tgi_setviewpage"><p>
5530 <tag/Function/Set page to be visible on screen.
5531 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5532 <tag/Declaration/<tt/void __fastcall__ tgi_setviewpage (unsigned char page);/
5533 <tag/Description/If the drawpage and the viewpage are the same then all drawing
5534 is seen immediately as it is drawn. For double buffered games you can set the
5535 drawpage to a different page than the viewpage. This lets you draw the next
5536 screen in the background and when the screen is ready you display it.
5537 <tag/Limits/<itemize>
5538 <item>The function is only available as fastcall function, so it may only
5539 be used in presence of a prototype.
5541 <tag/Availability/cc65
5542 <tag/See also/Other tgi functions.
5545 tgi_outtextxy(10, 10, "Hello World");
5546 tgi_setviewpage(1); // Show page 1
5548 tgi_outtextxy(10, 10, "Creating next frame");
5550 tgi_setviewpage(0); // Show page 0
5555 <sect1>tgi_textheight<label id="tgi_textheight"><p>
5559 <tag/Function/Calculate the height of the text in pixels according to
5560 the current text style.
5561 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5562 <tag/Declaration/<tt/unsigned __fastcall__ tgi_textheight (const char* s);/
5563 <tag/Description/Calculate the height of the text in pixels according to
5564 the current text style.
5565 <tag/Limits/<itemize>
5566 <item>The function is only available as fastcall function, so it may only
5567 be used in presence of a prototype.
5569 <tag/Availability/cc65
5570 <tag/See also/Other tgi functions.
5575 <sect1>tgi_textstyle<label id="tgi_textstyle"><p>
5579 <tag/Function/Set the style for text output.
5580 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5581 <tag/Declaration/<tt/void __fastcall__ tgi_textstyle (unsigned char magx, unsigned char magy, unsigned char dir);/
5582 <tag/Description/Set the style for text output.
5583 <tag/Limits/<itemize>
5584 <item>The function is only available as fastcall function, so it may only
5585 be used in presence of a prototype.
5587 <tag/Availability/cc65
5588 <tag/See also/Other tgi functions.
5593 <sect1>tgi_textwidth<label id="tgi_textwidth"><p>
5597 <tag/Function/Calculate the width of the text in pixels according to the current text style.
5598 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5599 <tag/Declaration/<tt/unsigned __fastcall__ tgi_textwidth (const char* s);/
5600 <tag/Function/Calculate the width of the text in pixels according to the current text style.
5601 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5602 <tag/Description/Calculate the width of the text in pixels according to the current text style.
5603 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5604 <tag/Limits/<itemize>
5605 <item>The function is only available as fastcall function, so it may only
5606 be used in presence of a prototype.
5608 <tag/Availability/cc65
5609 <tag/See also/Other tgi functions.
5614 <sect1>tgi_uninstall<label id="tgi_uninstall"><p>
5618 <tag/Function/Uninstall the currently loaded driver but do not unload it.
5619 Will call tgi_done if necessary.
5620 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5621 <tag/Declaration/<tt/void __fastcall__ tgi_uninstall (void);/
5622 <tag/Description/Uninstall the currently loaded driver but do not unload it.
5623 Will call tgi_done if necessary.
5624 <tag/Limits/<itemize>
5625 <item>The function is only available as fastcall function, so it may only
5626 be used in presence of a prototype.
5628 <tag/Availability/cc65
5629 <tag/See also/Other tgi functions.
5634 <sect1>tgi_unload<label id="tgi_unload"><p>
5638 <tag/Function/Uninstall, then unload the currently loaded driver.
5639 Will call tgi_done if necessary.
5640 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5641 <tag/Declaration/<tt/void __fastcall__ tgi_unload (void);/
5642 <tag/Description/Uninstall, then unload the currently loaded driver.
5643 Will call tgi_done if necessary.
5644 <tag/Limits/<itemize>
5645 <item>The function is only available as fastcall function, so it may only
5646 be used in presence of a prototype.
5648 <tag/Availability/cc65
5649 <tag/See also/Other tgi functions.
5654 <sect1>time<label id="time"><p>
5658 <tag/Function/Get the time.
5659 <tag/Header/<tt/<ref id="time.h" name="time.h">/
5660 <tag/Declaration/<tt/time_t __fastcall__ time (time_t* t);/
5661 <tag/Description/The function returns the time since the 1970-01-01 00:00:00
5662 measured in seconds. If the pointer <tt/t/ is not <tt/NULL/, the function
5663 result will also be stored there. If no time is available, <tt/(time_t)-1/ is
5664 returned and <tt/errno/ is set to <tt/ENOSYS/.
5665 <tag/Limits/<itemize>
5666 <item>The function is only available as fastcall function, so it may
5667 only be used in presence of a prototype.
5668 <item>Many platforms supported by cc65 do not have a realtime clock, so the
5669 returned value may not be valid.
5671 <tag/Availability/ISO 9899
5677 <sect1>toggle_videomode<label id="toggle_videomode"><p>
5681 <tag/Function/Toggle between 40 and 80 column mode.
5682 <tag/Header/<tt/<ref id="c128.h" name="c128.h">/
5683 <tag/Declaration/<tt/void toggle_videomode (void);/
5684 <tag/Description/Toggle between 40 and 80 column mode. The settings for the
5685 old mode (cursor position, color and so on) are saved and restored together
5687 <tag/Limits/<itemize>
5688 <item>The function is specific to the C128.
5689 <item>This function is deprecated. Please use <ref id="videomode"
5690 name="videomode"> instead!
5692 <tag/Availability/C128
5694 <ref id="fast" name="fast">,
5695 <ref id="slow" name="slow">,
5696 <ref id="videomode" name="videomode">
5702 <sect1>tolower<label id="tolower"><p>
5706 <tag/Function/Convert a character into its lower case representation.
5707 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
5708 <tag/Declaration/<tt/int __fastcall__ tolower (int c);/
5709 <tag/Description/The function returns the given character converted to lower
5710 case. If the given character is not a letter, it is returned unchanged.
5711 <tag/Limits/<itemize>
5712 <item>The function is only available as fastcall function, so it may
5713 only be used in presence of a prototype.
5715 <tag/Availability/ISO 9899
5717 <ref id="islower" name="islower">,
5718 <ref id="isupper" name="isupper">,
5719 <ref id="toupper" name="toupper">
5725 <sect1>toupper<label id="toupper"><p>
5729 <tag/Function/Convert a character into its upper case representation.
5730 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
5731 <tag/Declaration/<tt/int __fastcall__ toupper (int c);/
5732 <tag/Description/The function returns the given character converted to upper
5733 case. If the given character is not a letter, it is returned unchanged.
5734 <tag/Limits/<itemize>
5735 <item>The function is only available as fastcall function, so it may
5736 only be used in presence of a prototype.
5738 <tag/Availability/ISO 9899
5740 <ref id="islower" name="islower">,
5741 <ref id="isupper" name="isupper">,
5742 <ref id="tolower" name="tolower">
5748 <sect1>ultoa<label id="ultoa"><p>
5752 <tag/Function/Convert an unsigned long integer into a string.
5753 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
5754 <tag/Declaration/<tt/char* __fastcall__ ultoa (unsigned long val, char* buf, int radix);/
5755 <tag/Description/<tt/itoa/ converts the unsigned long integer <tt/val/ into a
5756 string using <tt/radix/ as the base.
5757 <tag/Limits/<itemize>
5758 <item>There are no provisions to prevent a buffer overflow.
5759 <item>The function is non standard, so it is not available in strict ANSI mode.
5760 You should probably use <tt/sprintf/ instead.
5761 <item>The function is only available as fastcall function, so it may only be
5762 used in presence of a prototype.
5764 <tag/Availability/cc65
5766 <ref id="atoi" name="atoi">,
5767 <ref id="atol" name="atol">,
5768 <ref id="itoa" name="itoa">,
5769 <ref id="ltoa" name="ltoa">,
5770 <ref id="utoa" name="utoa">
5776 <sect1>unlink<label id="unlink"><p>
5780 <tag/Function/Delete a file.
5781 <tag/Header/<tt/<ref id="unistd.h" name="unistd.h">/
5782 <tag/Declaration/<tt/int __fastcall__ unlink (const char* name);/
5783 <tag/Description/<tt/unlink/ deletes the file with the given name. On success,
5784 zero is returned. On error, -1 is returned and <tt/errno/ is set to an error
5785 code describing the reason for the failure.
5788 <item>The use of this function is discouraged. Please use <tt/<ref id="remove"
5789 name="remove">/ instead, which is a native ANSI C function and does the same.
5790 <item>This function is not available on all cc65 targets (depends on the
5791 availability of file I/O).
5792 <item>The function is only available as fastcall function, so it may only
5793 be used in presence of a prototype.
5794 <item>Instead of <tt/unlink/, <tt/<ref id="remove" name="remove">/ should be
5795 used, which has the same semantics, but is more portable, because it conforms
5796 to the ISO C standard.
5798 <tag/Availability/POSIX 1003.1
5800 <ref id="remove" name="remove">
5803 #include <stdio.h>
5804 #include <unistd.h>
5806 #define FILENAME "helloworld"
5808 if (unlink (FILENAME) == 0) {
5809 printf ("We deleted %s successfully\n", FILENAME);
5811 printf ("There was a problem deleting %s\n", FILENAME);
5818 <sect1>utoa<label id="utoa"><p>
5822 <tag/Function/Convert an unsigned integer into a string.
5823 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
5824 <tag/Declaration/<tt/char* __fastcall__ utoa (unsigned val, char* buf, int radix);/
5825 <tag/Description/<tt/itoa/ converts the unsigned integer <tt/val/ into a string
5826 using <tt/radix/ as the base.
5827 <tag/Limits/<itemize>
5828 <item>There are no provisions to prevent a buffer overflow.
5829 <item>The function is non standard, so it is not available in strict ANSI mode.
5830 You should probably use <tt/sprintf/ instead.
5831 <item>The function is only available as fastcall function, so it may only be
5832 used in presence of a prototype.
5834 <tag/Availability/cc65
5836 <ref id="atoi" name="atoi">,
5837 <ref id="atol" name="atol">,
5838 <ref id="itoa" name="itoa">,
5839 <ref id="ltoa" name="ltoa">,
5840 <ref id="ultoa" name="ultoa">
5846 <sect1>vcprintf<label id="vcprintf"><p>
5850 <tag/Function/Formatted output to the console.
5851 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
5852 <tag/Declaration/<tt/int __fastcall__ vcprintf (const char* format, va_list ap);/
5853 <tag/Description/The arguments specified as a <tt/va_list/ are converted to
5854 text where necessary and formatted according to the format string given. The
5855 resulting string is output to the console. <tt/vcprintf/ supports the same
5856 format specifiers as <tt/vprintf/. <!-- <tt/<ref id="vprintf" name="vprintf">/. -->
5857 <tag/Limits/<itemize>
5858 <item>Like all other <tt/conio/ output functions, <tt/vcprintf/ distinguishes
5859 between <tt/\r/ and <tt/\n/.
5860 <item>The function is only available as fastcall function, so it may only be
5861 used in presence of a prototype.
5863 <tag/Availability/cc65
5865 <ref id="cprintf" name="cprintf">,
5866 <ref id="cputc" name="cputc">,
5867 <ref id="cputcxy" name="cputcxy">,
5868 <ref id="cputs" name="cputs">,
5869 <ref id="cputsxy" name="cputsxy">
5875 <sect1>videomode<label id="videomode"><p>
5879 <tag/Function/Switch to either 40 or 80 column mode.
5880 <tag/Header/<tt/<ref id="apple2enh.h" name="apple2enh.h">,
5881 <ref id="c128.h" name="c128.h">/
5882 <tag/Declaration/<tt/unsigned __fastcall__ videomode (unsigned Mode);/
5883 <tag/Description/Switch to 40 or 80 column mode depending on the argument. If
5884 the requested mode is already active, nothing happens. The old mode is returned
5886 <tag/Limits/<itemize>
5887 <item>The function is specific to the C128 and enhanced Apple //e.
5888 <item>This function replaces <ref id="toggle_videomode"
5889 name="toggle_videomode">.
5890 <item>The function is only available as fastcall function, so it may only be
5891 used in presence of a prototype.
5893 <tag/Availability/C128 and enhanced Apple //e
5895 <ref id="fast" name="fast">,
5896 <ref id="slow" name="slow">,
5897 <ref id="toggle_videomode" name="toggle_videomode">
5903 <sect1>wherex<label id="wherex"><p>
5907 <tag/Function/Return the current X position of the text mode cursor.
5908 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
5909 <tag/Declaration/<tt/unsigned char wherex (void);/
5910 <tag/Description/The function returns the current X position of the text mode
5911 cursor. Zero is returned for the leftmost screen position.
5912 <tag/Availability/cc65
5914 <ref id="gotox" name="gotox">,
5915 <ref id="gotoy" name="gotoy">,
5916 <ref id="gotoxy" name="gotoxy">,
5917 <ref id="wherey" name="wherey">
5923 <sect1>wherey<label id="wherey"><p>
5927 <tag/Function/Return the current Y position of the text mode cursor.
5928 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
5929 <tag/Declaration/<tt/unsigned char wherey (void);/
5930 <tag/Description/The function returns the current Y position of the text mode
5931 cursor. Zero is returned for the uppermost screen position.
5932 <tag/Availability/cc65
5934 <ref id="gotox" name="gotox">,
5935 <ref id="gotoy" name="gotoy">,
5936 <ref id="gotoxy" name="gotoxy">,
5937 <ref id="wherex" name="wherex">