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>
332 The <tt/serial.h/ header file contains definitions for initializing serial
336 <item><ref id="ser_close" name="ser_close">
337 <item><ref id="ser_get" name="ser_get">
338 <item><ref id="ser_install" name="ser_install">
339 <item><ref id="ser_ioctl" name="ser_ioctl">
340 <item><ref id="ser_load_driver" name="ser_load_driver">
341 <item><ref id="ser_open" name="ser_open">
342 <item><ref id="ser_put" name="ser_put">
343 <item><ref id="ser_status" name="ser_status">
344 <item><ref id="ser_uninstall" name="ser_uninstall">
345 <item><ref id="ser_unload" name="ser_unload">
351 <sect1><tt/setjmp.h/<label id="setjmp.h"><p>
354 <item><ref id="setjmp" name="setjmp">
355 <item><ref id="longjmp" name="longjmp">
359 <sect1><tt/signal.h/<label id="signal.h"><p>
362 <item><ref id="raise" name="raise">
363 <item><ref id="signal" name="signal">
367 <sect1><tt/stdarg.h/<label id="stdarg.h"><p>
372 <sect1><tt/stdbool.h/<label id="stdbool.h"><p>
377 <sect1><tt/stddef.h/<label id="stddef.h"><p>
380 <item><ref id="offsetof" name="offsetof">
384 <sect1><tt/stdio.h/<label id="stdio.h"><p>
387 <item><ref id="_poserror" name="_poserror">
388 <item><ref id="clearerr" name="clearerr">
389 <!-- <item><ref id="fclose" name="fclose"> -->
390 <!-- <item><ref id="fdopen" name="fdopen"> -->
391 <item><ref id="feof" name="feof">
392 <item><ref id="ferror" name="ferror">
393 <!-- <item><ref id="fflush" name="fflush"> -->
394 <!-- <item><ref id="fgetc" name="fgetc"> -->
395 <!-- <item><ref id="fgetpos" name="fgetpos"> -->
396 <!-- <item><ref id="fgets" name="fgets"> -->
397 <item><ref id="fileno" name="fileno">
398 <!-- <item><ref id="fopen" name="fopen"> -->
399 <!-- <item><ref id="fprintf" name="fprintf"> -->
400 <!-- <item><ref id="fputc" name="fputc"> -->
401 <!-- <item><ref id="fputs" name="fputs"> -->
402 <!-- <item><ref id="fread" name="fread"> -->
403 <!-- <item><ref id="freopen" name="freopen"> -->
404 <!-- <item><ref id="fscanf" name="fscanf"> -->
405 <!-- <item><ref id="fseek" name="fseek"> -->
406 <!-- <item><ref id="fsetpos" name="fsetpos"> -->
407 <!-- <item><ref id="ftell" name="ftell"> -->
408 <!-- <item><ref id="fwrite" name="fwrite"> -->
409 <!-- <item><ref id="getc" name="getc"> -->
410 <!-- <item><ref id="getchar" name="getchar"> -->
411 <!-- <item><ref id="gets" name="gets"> -->
412 <!-- <item><ref id="printf" name="printf"> -->
413 <!-- <item><ref id="putc" name="putc"> -->
414 <!-- <item><ref id="putchar" name="putchar"> -->
415 <!-- <item><ref id="puts" name="puts"> -->
416 <item><ref id="rename" name="rename">
417 <item><ref id="remove" name="remove">
418 <!-- <item><ref id="rewind" name="rewind"> -->
419 <!-- <item><ref id="scanf" name="scanf"> -->
420 <!-- <item><ref id="snprintf" name="snprintf"> -->
421 <!-- <item><ref id="sprintf" name="sprintf"> -->
422 <!-- <item><ref id="sscanf" name="sscanf"> -->
423 <!-- <item><ref id="vfprintf" name="vfprintf"> -->
424 <!-- <item><ref id="vfscanf" name="vfscanf"> -->
425 <!-- <item><ref id="vprintf" name="vprintf"> -->
426 <!-- <item><ref id="vscanf" name="vscanf"> -->
427 <!-- <item><ref id="vsnprintf" name="vsnprintf"> -->
428 <!-- <item><ref id="vsprintf" name="vsprintf"> -->
429 <!-- <item><ref id="vsscanf" name="vsscanf"> -->
435 <sect1><tt/stdlib.h/<label id="stdlib.h"><p>
438 <item><ref id="_heapadd" name="_heapadd">
439 <item><ref id="_heapblocksize" name="_heapblocksize">
440 <item><ref id="_heapmaxavail" name="_heapmaxavail">
441 <item><ref id="_heapmemavail" name="_heapmemavail">
442 <item><ref id="_randomize" name="_randomize">
443 <item><ref id="_swap" name="_swap">
444 <item><ref id="abort" name="abort">
445 <item><ref id="abs" name="abs">
446 <item><ref id="atexit" name="atexit">
447 <item><ref id="atoi" name="atoi">
448 <item><ref id="atol" name="atol">
449 <item><ref id="bsearch" name="bsearch">
450 <item><ref id="calloc" name="calloc">
451 <item><ref id="div" name="div">
452 <item><ref id="exit" name="exit">
453 <item><ref id="free" name="free">
454 <item><ref id="getenv" name="getenv">
455 <item><ref id="itoa" name="itoa">
456 <item><ref id="labs" name="labs">
457 <item><ref id="ltoa" name="ltoa">
458 <item><ref id="malloc" name="malloc">
459 <item><ref id="perror" name="perror">
460 <item><ref id="qsort" name="qsort">
461 <item><ref id="rand" name="rand">
462 <item><ref id="realloc" name="realloc">
463 <item><ref id="srand" name="srand">
464 <item><ref id="ultoa" name="ultoa">
465 <item><ref id="utoa" name="utoa">
469 <sect1><tt/string.h/<label id="string.h"><p>
472 <item><ref id="_stroserror" name="_stroserror">
473 <item><ref id="bzero" name="bzero">
474 <item><ref id="memchr" name="memchr">
475 <item><ref id="memcpy" name="memcpy">
476 <item><ref id="memmove" name="memmove">
477 <item><ref id="memset" name="memset">
478 <item><ref id="strcasecmp" name="strcasecmp">
479 <item><ref id="strcat" name="strcat">
480 <item><ref id="strchr" name="strchr">
481 <item><ref id="strcmp" name="strcmp">
482 <item><ref id="strcoll" name="strcoll">
483 <item><ref id="strcpy" name="strcpy">
484 <item><ref id="strcspn" name="strcspn">
485 <item><ref id="strdup" name="strdup">
486 <item><ref id="strerror" name="strerror">
487 <item><ref id="stricmp" name="stricmp">
488 <item><ref id="strlen" name="strlen">
489 <item><ref id="strlower" name="strlower">
490 <item><ref id="strlwr" name="strlwr">
491 <item><ref id="strncat" name="strncat">
492 <item><ref id="strncmp" name="strncmp">
493 <item><ref id="strncpy" name="strncpy">
494 <item><ref id="strrchr" name="strrchr">
495 <item><ref id="strspn" name="strspn">
496 <item><ref id="strstr" name="strstr">
497 <item><ref id="strtok" name="strtok">
498 <item><ref id="strxfrm" name="strxfrm">
499 <item><ref id="strupper" name="strupper">
500 <item><ref id="strupr" name="strupr">
506 <sect1><tt/tgi.h/<label id="tgi.h"><p>
509 <item><ref id="tgi_arc" name="tgi_arc">
510 <item><ref id="tgi_bar" name="tgi_bar">
511 <item><ref id="tgi_circle" name="tgi_circle">
512 <item><ref id="tgi_clear" name="tgi_clear">
513 <item><ref id="tgi_getcolor" name="tgi_getcolor">
514 <item><ref id="tgi_getcolorcount" name="tgi_getcolorcount">
515 <item><ref id="tgi_getdefpalette" name="tgi_getdefpalette">
516 <item><ref id="tgi_done" name="tgi_done">
517 <item><ref id="tgi_ellipse" name="tgi_ellipse">
518 <item><ref id="tgi_geterror" name="tgi_geterror">
519 <item><ref id="tgi_geterrormsg" name="tgi_geterrormsg">
520 <item><ref id="tgi_getmaxcolor" name="tgi_getmaxcolor">
521 <item><ref id="tgi_getmaxx" name="tgi_getmaxx">
522 <item><ref id="tgi_getmaxy" name="tgi_getmaxy">
523 <item><ref id="tgi_getpagecount" name="tgi_getpagecount">
524 <item><ref id="tgi_getpalette" name="tgi_getpalette">
525 <item><ref id="tgi_getpixel" name="tgi_getpixel">
526 <item><ref id="tgi_getxres" name="tgi_getxres">
527 <item><ref id="tgi_getyres" name="tgi_getyres">
528 <item><ref id="tgi_gotoxy" name="tgi_gotoxy">
529 <item><ref id="tgi_init" name="tgi_init">
530 <item><ref id="tgi_install" name="tgi_install">
531 <item><ref id="tgi_ioctl" name="tgi_ioctl">
532 <item><ref id="tgi_line" name="tgi_line">
533 <item><ref id="tgi_lineto" name="tgi_lineto">
534 <item><ref id="tgi_load_driver" name="tgi_load_driver">
535 <item><ref id="tgi_outtext" name="tgi_outtext">
536 <item><ref id="tgi_outtextxy" name="tgi_outtextxy">
537 <item><ref id="tgi_setcolor" name="tgi_setcolor">
538 <item><ref id="tgi_setdrawpage" name="tgi_setdrawpage">
539 <item><ref id="tgi_setpalette" name="tgi_setpalette">
540 <item><ref id="tgi_setpixel" name="tgi_setpixel">
541 <item><ref id="tgi_setviewpage" name="tgi_setviewpage">
542 <item><ref id="tgi_textheight" name="tgi_textheight">
543 <item><ref id="tgi_textstyle" name="tgi_textstyle">
544 <item><ref id="tgi_textwidth" name="tgi_textwidth">
545 <item><ref id="tgi_uninstall" name="tgi_uninstall">
546 <item><ref id="tgi_unload" name="tgi_unload">
549 <sect1><tt/time.h/<label id="time.h"><p>
552 <!-- <item><ref id="_systime" name="_systime"> -->
553 <!-- <item><ref id="asctime" name="asctime"> -->
554 <!-- <item><ref id="clock" name="clock"> -->
555 <!-- <item><ref id="ctime" name="ctime"> -->
556 <!-- <item><ref id="gmtime" name="gmtime"> -->
557 <!-- <item><ref id="localtime" name="localtime"> -->
558 <!-- <item><ref id="mktime" name="mktime"> -->
559 <!-- <item><ref id="strftime" name="strftime"> -->
560 <item><ref id="time" name="time">
566 <sect1><tt/unistd.h/<label id="unistd.h"><p>
569 <!-- <item><ref id="chdir" name="chdir"> -->
570 <item><ref id="exec" name="exec">
571 <!-- <item><ref id="getcwd" name="getcwd"> -->
572 <item><ref id="getopt" name="getopt">
573 <!-- <item><ref id="lseek" name="lseek"> -->
574 <!-- <item><ref id="mkdir" name="mkdir"> -->
575 <!-- <item><ref id="read" name="read"> -->
576 <!-- <item><ref id="rmdir" name="rmdir"> -->
577 <item><ref id="sleep" name="sleep">
578 <item><ref id="unlink" name="unlink">
579 <!-- <item><ref id="write" name="write"> -->
585 <sect1><tt/vic20.h/<label id="vic20.h"><p>
590 <sect1><tt/zlib.h/<label id="zlib.h"><p>
595 <sect>Alphabetical function reference<p>
597 <sect1>_heapadd<label id="_heapadd"><p>
601 <tag/Function/Add a block to the heap.
602 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
603 <tag/Declaration/<tt/void __fastcall__ _heapadd (void* mem, size_t size);/
604 <tag/Description/The function adds a block of raw memory to the heap.
607 <item>The minimum blocksize that can be added is 6 bytes; the function will
608 ignore smaller blocks.
610 <tag/Availability/cc65
612 <ref id="_heapblocksize" name="_heapblocksize">,
613 <ref id="_heapmaxavail" name="_heapmaxavail">,
614 <ref id="_heapmemavail" name="_heapmemavail">,
615 <ref id="calloc" name="calloc">,
616 <ref id="free" name="free">,
617 <ref id="malloc" name="malloc">,
618 <ref id="realloc" name="realloc">
624 <sect1>_heapblocksize<label id="_heapblocksize"><p>
628 <tag/Function/Return the size of an allocated block.
629 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
630 <tag/Declaration/<tt/size_t __fastcall__ _heapblocksize (const void* block);/
631 <tag/Description/The function returns the size of a block that must have
632 previously been allocated by <tt/<ref id="malloc" name="malloc">/, <tt/<ref
633 id="calloc" name="calloc">/ or <tt/<ref id="realloc" name="realloc">/.
636 <item>Passing a pointer to a block that was is not the result of one of the
637 allocation functions, or that has been free'd will give unpredicable results.
639 <tag/Availability/cc65
641 <ref id="_heapadd" name="_heapadd">,
642 <ref id="_heapmaxavail" name="_heapmaxavail">,
643 <ref id="_heapmemavail" name="_heapmemavail">,
644 <ref id="calloc" name="calloc">,
645 <ref id="free" name="free">,
646 <ref id="malloc" name="malloc">,
647 <ref id="realloc" name="realloc">
653 <sect1>_heapmaxavail<label id="_heapmaxavail"><p>
657 <tag/Function/Return the largest block that is available on the heap.
658 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
659 <tag/Declaration/<tt/size_t __fastcall__ _heapmaxavail (void);/
660 <tag/Description/The function returns the size of the largest block that may
661 be allocated from the heap using <tt/<ref id="malloc" name="malloc">/.
662 <tag/Availability/cc65
664 <ref id="_heapadd" name="_heapadd">,
665 <ref id="_heapblocksize" name="_heapblocksize">,
666 <ref id="_heapmemavail" name="_heapmemavail">,
667 <ref id="calloc" name="calloc">,
668 <ref id="free" name="free">,
669 <ref id="malloc" name="malloc">,
670 <ref id="realloc" name="realloc">
676 <sect1>_heapmemavail<label id="_heapmemavail"><p>
680 <tag/Function/Return the total available space on the heap.
681 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
682 <tag/Declaration/<tt/size_t __fastcall__ _heapmemavail (void);/
683 <tag/Description/The function returns the total number of bytes available on
687 <item>This function is of less use than usually assumed, since the returned
688 heap space may be available but not in one block. So even if this function
689 says that several times more heap space is available than needed, <ref
690 id="malloc" name="malloc"> may still return <tt/NULL/.
692 <tag/Availability/cc65
694 <ref id="_heapadd" name="_heapadd">,
695 <ref id="_heapblocksize" name="_heapblocksize">,
696 <ref id="_heapmaxavail" name="_heapmaxavail">,
697 <ref id="calloc" name="calloc">,
698 <ref id="free" name="free">,
699 <ref id="malloc" name="malloc">,
700 <ref id="realloc" name="realloc">
706 <sect1>_poserror<label id="_poserror"><p>
710 <tag/Function/Print an error message for the error in <tt/_oserror/.
711 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
712 <tag/Declaration/<tt/void __fastcall__ _poserror (const char* msg);/
713 <tag/Description/<tt/_poserror/ prints an error message to <tt/stderr/. If
714 <tt/msg/ is not <tt/NULL/ and not an empty string, it is printed followed by
715 a colon and a blank. Then the error message for the current contents of
716 <tt/_oserror/ are printed followed by a newline. The message output is the
717 same as returned by <tt/<ref id="_stroserror" name="_stroserror">/ with an
718 argument of <tt/_oserror/.
721 <item>Since operating system specific error code are - you guessed it -
722 operating system specific, the value in <tt/_oserror/ and the message that is
723 printed depends on the cc65 target.
724 <item>The function is only available as fastcall function, so it may only
725 be used in presence of a prototype.
727 <tag/Availability/cc65
729 <ref id="_stroserror" name="_stroserror">,
730 <ref id="perror" name="perror">
736 <sect1>_randomize<label id="_randomize"><p>
740 <tag/Function/Initialize the pseudo random number generator.
741 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
742 <tag/Declaration/<tt/void _randomize (void);/
743 <tag/Description/The function initializes the random number generator with
744 a seed derived from fast changing hardware events, so the seed itself can be
745 considered random to a certain degree.
746 <tag/Limits/<itemize>
747 <item>The randomness of the seed depends on the machine hardware.
749 <tag/Availability/cc65
751 <ref id="rand" name="rand">,
752 <ref id="srand" name="srand">
758 <sect1>_stroserror<label id="_stroserror"><p>
762 <tag/Function/Return a string describing an OS specific error code.
763 <tag/Header/<tt/<ref id="string.h" name="string.h">/
764 <tag/Declaration/<tt/const char* __fastcall__ _stroserror (unsigned char errcode);/
765 <tag/Description/<tt/_stroserror/ will return a string describing the given
766 operating system specific error code.
767 <tag/Limits/<itemize>
768 <item>Since operating system specific error code are - you guessed it -
769 operating system specific, the parameter and the string returned depend on the
771 <item>The function is only available as fastcall function, so it may only be
772 used in presence of a prototype.
774 <tag/Availability/cc65
776 <ref id="strerror" name="strerror">
782 <sect1>_swap<label id="_swap"><p>
786 <tag/Function/Swap the contents of memory areas.
787 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
788 <tag/Declaration/<tt/void __fastcall__ _swap (void* p, void* q, size_t size);/
789 <tag/Description/<tt/_swap/ will swap (exchange) the contents of the two memory
790 areas pointed to by <tt/p/ and <tt/q/. Both memory areas are assumed to be
791 <tt/size/ bytes in size.
792 <tag/Limits/<itemize>
793 <item>The memory areas may not overlap, otherwise the results are undefined.
794 <item>The function is only available as fastcall function, so it may only be
795 used in presence of a prototype.
797 <tag/Availability/cc65
799 <ref id="memcpy" name="memcpy">,
800 <ref id="memmove" name="memmove">
806 <sect1>_sys<label id="_sys"><p>
810 <tag/Function/Call a subroutine passing register values.
811 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
812 <tag/Declaration/<tt/void __fastcall__ _sys (struct regs* r);/
813 <tag/Description/The function will call the subroutine at the address
814 specified in the <tt/pc/ member of the passed <tt/regs/ structure. All
815 registers and the CPU flags are set to the values given in the <tt/regs/
816 structure. On return from the subroutine, the new values of the registers and
817 flags are stored back overwriting the old values.
818 <tag/Limits/<itemize>
819 <item>Bits 4 and 5 of the flags value in the <tt/regs/ structure are ignored
820 when calling the subroutine (they are unchanged from their current values).
821 <item>The function is only available as fastcall function, so it may only be
822 used in presence of a prototype.
824 <tag/Availability/cc65
830 <sect1>BRK<label id="BRK"><p>
834 <tag/Function/Insert a 6502 BRK instrunction into the code.
835 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
836 <tag/Declaration/<tt/void BRK (void);/
837 <tag/Description/The function will insert a 6502 BRK instruction into the code
838 which may be used to trigger a debugger.
839 <tag/Limits/<itemize>
840 <item>The function is actually a macro.
841 <item>The inserted instruction may lead to unexpected results if no debugger
844 <tag/Availability/cc65
846 <ref id="CLI" name="CLI">,
847 <ref id="SEI" name="SEI">
853 <sect1>CLI<label id="CLI"><p>
857 <tag/Function/Insert a 6502 CLI instrunction into the code.
858 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
859 <tag/Declaration/<tt/void CLI (void);/
860 <tag/Description/The function will insert a 6502 CLI instruction into the code,
861 so interrupts are enabled. Enabling interrupts has no effects if they are
862 already enabled (the default).
863 <tag/Limits/<itemize>
864 <item>The function is actually a macro.
865 <item>Disabling interrupts may lead to unexpected results.
867 <tag/Availability/cc65
869 <ref id="BRK" name="BRK">,
870 <ref id="SEI" name="SEI">
876 <sect1>PEEK<label id="PEEK"><p>
880 <tag/Function/Read a byte from memory.
881 <tag/Header/<tt/<ref id="peekpoke.h" name="peekpoke.h">/
882 <tag/Declaration/<tt/unsigned char PEEK (unsigned addr);/
883 <tag/Description/The function will read the absolute memory given by <tt/addr/
884 and return the value read.
885 <tag/Limits/<itemize>
886 <item>The function is actually a macro.
887 <item>This function depends highly on the platform and environment.
889 <tag/Availability/cc65
891 <ref id="PEEKW" name="PEEKW">,
892 <ref id="POKE" name="POKE">
898 <sect1>PEEKW<label id="PEEKW"><p>
902 <tag/Function/Read a word (two bytes) from memory.
903 <tag/Header/<tt/<ref id="peekpoke.h" name="peekpoke.h">/
904 <tag/Declaration/<tt/unsigned PEEKW (unsigned addr);/
905 <tag/Description/The function will read the absolute memory given by <tt/addr/
906 and return the value read. The byte read from the higher address is the high
907 byte of the return value.
908 <tag/Limits/<itemize>
909 <item>The function is actually a macro.
910 <item>This function depends highly on the platform and environment.
911 <item>The order in which the two bytes are read is unspecified and may
912 depend of the address expression used.
914 <tag/Availability/cc65
916 <ref id="PEEK" name="PEEK">,
917 <ref id="POKE" name="POKE">
923 <sect1>POKE<label id="POKE"><p>
927 <tag/Function/Write a byte to memory.
928 <tag/Header/<tt/<ref id="peekpoke.h" name="peekpoke.h">/
929 <tag/Declaration/<tt/void POKE (unsigned addr, unsigned char val);/
930 <tag/Description/The function writes the value <tt/val/ to the absolute
931 memory address given by <tt/addr/.
932 <tag/Limits/<itemize>
933 <item>The function is actually a macro.
934 <item>This function depends highly on the platform and environment.
935 <item>Careless use will cause the program to act strange or may crash the
938 <tag/Availability/cc65
940 <ref id="PEEK" name="PEEK">,
941 <ref id="POKEW" name="POKEW">
947 <sect1>POKEW<label id="POKEW"><p>
951 <tag/Function/Write a word (two bytes) to memory.
952 <tag/Header/<tt/<ref id="peekpoke.h" name="peekpoke.h">/
953 <tag/Declaration/<tt/void POKEW (unsigned addr, unsigned val);/
954 <tag/Description/The function writes the value <tt/val/ to the absolute
955 memory address given by <tt/addr/. The low byte of <tt/val/ is written to
956 the <tt/addr/, the high byte is written to <tt/addr+1/.
957 <tag/Limits/<itemize>
958 <item>The function is actually a macro.
959 <item>This function depends highly on the platform and environment.
960 <item>Careless use will cause the program to act strange or may crash the
962 <item>The order in which the two bytes are written is unspecified and may
963 depend of the address expression used.
965 <tag/Availability/cc65
967 <ref id="PEEK" name="PEEK">,
968 <ref id="POKE" name="POKE">
974 <sect1>SEI<label id="SEI"><p>
978 <tag/Function/Insert a 6502 SEI instrunction into the code.
979 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
980 <tag/Declaration/<tt/void SEI (void);/
981 <tag/Description/The function will insert a 6502 SEI instruction into the code,
982 so interrupts are disabled. Note that non maskable interrupts cannot be
984 <tag/Limits/<itemize>
985 <item>The function is actually a macro.
986 <item>Disabling interrupts may lead to unexpected results.
988 <tag/Availability/cc65
990 <ref id="BRK" name="BRK">,
991 <ref id="CLI" name="CLI">
997 <sect1>abort<label id="abort"><p>
1001 <tag/Function/Terminates a program abnormally.
1002 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1003 <tag/Declaration/<tt/void abort (void);/
1004 <tag/Description/<tt/abort/ raises <tt/SIGABRT/, writes a termination message
1005 on stderr, then terminates the program with an exit code of 3.
1006 <tag/Availability/ISO 9899
1008 <ref id="assert" name="assert">,
1009 <ref id="exit" name="exit">,
1010 <ref id="raise" name="raise">
1016 <sect1>abs<label id="abs"><p>
1020 <tag/Function/Returns the absolute value of an integer.
1021 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1022 <tag/Declaration/<tt/int __fastcall__ abs (int v);/
1023 <tag/Description/<tt/abs/ returns the absolute value of the argument passed to
1025 <tag/Limits/<itemize>
1026 <item>The return value is undefined if <tt/INT_MIN/ is passed to the function.
1027 <item>The function is only available as fastcall function, so it may only be
1028 used in presence of a prototype.
1030 <tag/Availability/ISO 9899
1032 <ref id="labs" name="labs">
1038 <sect1>assert<label id="assert"><p>
1042 <tag/Function/Test a condition and possibly abort.
1043 <tag/Header/<tt/<ref id="assert.h" name="assert.h">/
1044 <tag/Declaration/<tt/void assert (int cond);/
1045 <tag/Description/<tt/assert/ is a macro that expands to a <tt/id/
1046 statement. If the condition evaluates t zero (false), assert prints a message
1047 on stderr and aborts the program.
1048 <tag/Limits/<itemize>
1049 <item>The function is actually a macro.
1051 <tag/Availability/ISO 9899
1053 <ref id="abort" name="abort">,
1054 <ref id="exit" name="exit">
1060 <sect1>atexit<label id="atexit"><p>
1064 <tag/Function/Register an exit function.
1065 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1066 <tag/Declaration/<tt/int __fastcall__ atexit (void (*exitfunc) (void));/
1067 <tag/Description/<tt/atexit/ registers the function pointed to by
1068 <tt/exitfunc/ as an exit function. Exit functions are called when the program
1069 terminates, they are called in LIFO order (the last function registered is
1070 called first). <tt/atexit/ returns zero on success and a nonzero value on
1072 <tag/Limits/<itemize>
1073 <item>A maximum of 5 exit functions can be registered.
1074 <item>There is no way to unregister an exit function.
1075 <item>The function is only available as fastcall function, so it may only be
1076 used in presence of a prototype.
1078 <tag/Availability/ISO 9899
1080 <ref id="abort" name="abort">,
1081 <ref id="exit" name="exit">
1087 <sect1>atoi<label id="atoi"><p>
1091 <tag/Function/Convert a string to an integer.
1092 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1093 <tag/Declaration/<tt/int __fastcall__ atoi (const char* s);/
1094 <tag/Description/<tt/atoi/ converts the given string into an integer.
1095 Conversion stops as soon as any invalid character is encountered.
1096 <tag/Limits/<itemize>
1097 <item>There is no way to detect any conversion errors.
1098 <item>The function does not check for an numerical overflow when converting.
1099 <item>The function is only available as fastcall function, so it may only be
1100 used in presence of a prototype.
1102 <tag/Availability/ISO 9899
1104 <ref id="atol" name="atol">,
1105 <ref id="itoa" name="itoa">,
1106 <ref id="ltoa" name="ltoa">,
1107 <ref id="ultoa" name="ultoa">,
1108 <ref id="utoa" name="utoa">
1114 <sect1>atol<label id="atol"><p>
1118 <tag/Function/Convert a string to a long integer.
1119 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1120 <tag/Declaration/<tt/long __fastcall__ atol (const char* s);/
1121 <tag/Description/<tt/atol/ converts the given string into a long integer.
1122 Conversion stops as soon as any invalid character is encountered.
1123 <tag/Limits/<itemize>
1124 <item>There is no way to detect any conversion errors.
1125 <item>The function does not check for an numerical overflow when converting.
1126 <item>The function is only available as fastcall function, so it may only be
1127 used in presence of a prototype.
1129 <tag/Availability/ISO 9899
1131 <ref id="atoi" name="atoi">,
1132 <ref id="itoa" name="itoa">,
1133 <ref id="ltoa" name="ltoa">,
1134 <ref id="ultoa" name="ultoa">,
1135 <ref id="utoa" name="utoa">
1141 <sect1>bgcolor<label id="bgcolor"><p>
1145 <tag/Function/Set the background text color.
1146 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1147 <tag/Declaration/<tt/unsigned char __fastcall__ bgcolor (unsigned char color);/
1148 <tag/Description/The function will set a new background color and return the
1149 old (current) one. The background color is valid for the whole text output
1150 area of the screen, not just for new text.
1151 <tag/Limits/<itemize>
1152 <item>Background colors are system dependent. The function may have no effect
1153 on systems where the background color cannot be changed.
1154 <item>The function is only available as fastcall function, so it may only be
1155 used in presence of a prototype.
1157 <tag/Availability/cc65
1159 <ref id="bordercolor" name="bordercolor">,
1160 <ref id="textcolor" name="textcolor">
1166 <sect1>bordercolor<label id="bordercolor"><p>
1170 <tag/Function/Set the border (frame) color.
1171 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1172 <tag/Declaration/<tt/unsigned char __fastcall__ bordercolor (unsigned char color);/
1173 <tag/Description/The function will set a new border color. It returns the old
1174 (current) border color.
1175 <tag/Limits/<itemize>
1176 <item>Border colors are system dependent. The function may have no effect
1177 on systems where the border color cannot be changed.
1178 <item>The function is only available as fastcall function, so it may only
1179 be used in presence of a prototype.
1181 <tag/Availability/cc65
1183 <ref id="bgcolor" name="bgcolor">,
1184 <ref id="textcolor" name="textcolor">
1190 <sect1>bsearch<label id="bsearch"><p>
1194 <tag/Function/Do a binary search in a sorted array.
1195 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1196 <tag/Declaration/<tt/void* __fastcall__ bsearch (const void* key,
1197 const void* base, size_t n, size_t size,
1198 int (*cmp) (const void*, const void*));/
1199 <tag/Description/<tt/bsearch/ searches a sorted array for a member that
1200 matches the one pointed to by <tt/key/. <tt/base/ is the address of the array,
1201 <tt/n/ is the number of elements, <tt/size/ the size of an element and <tt/cmp/
1202 the function used to compare the members against the key. The function returns
1203 a pointer to the member found, or <tt/NULL/ if there was no match.
1206 <item>The contents of the array must be sorted in ascending order according to
1207 the compare function given.
1208 <item>If there are multiple members that match the key, the function will
1209 return one of the members.
1210 <item>The function is only available as fastcall function, so it may only
1211 be used in presence of a prototype.
1213 <tag/Availability/ISO 9899
1215 <ref id="qsort" name="qsort">
1221 <sect1>bzero<label id="bzero"><p>
1225 <tag/Function/Fill a memory area with zeroes.
1226 <tag/Header/<tt/<ref id="string.h" name="string.h">/
1227 <tag/Declaration/<tt/void __fastcall__ bzero (void* p, size_t count);/
1228 <tag/Description/<tt/bzero/ fills the memory area pointed to by <tt/p/ with
1232 <item>The function is non standard and therefore only available in non ANSI
1233 mode. You should use <tt/<ref id="memset" name="memset">/ instead.
1234 <item>The function is only available as fastcall function, so it may only
1235 be used in presence of a prototype.
1237 <tag/Availability/cc65
1239 <ref id="_swap" name="_swap">,
1240 <ref id="memcpy" name="memcpy">,
1241 <ref id="memmove" name="memmove">,
1242 <ref id="memset" name="memset">,
1248 <sect1>c64mode<label id="c64mode"><p>
1252 <tag/Function/Switch the C128 into C64 compatible mode.
1253 <tag/Header/<tt/<ref id="c128.h" name="c128.h">/
1254 <tag/Declaration/<tt/void c64mode (void);/
1255 <tag/Description/The function will cause the machine to reboot into C64 mode.
1256 <tag/Limits/<itemize>
1257 <item>The function is specific to the C128.
1258 <item>The function will not return to the caller.
1260 <tag/Availability/C128
1266 <sect1>calloc<label id="calloc"><p>
1270 <tag/Function/Allocate and clear memory.
1271 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1272 <tag/Declaration/<tt/void* __fastcall__ calloc (size_t n, size_t size);/
1273 <tag/Description/<tt/calloc/ allocates memory for an array of <tt/n/ elements
1274 of size <tt/size/, clears the whole block with binary zeroes and returns a
1275 pointer to it. On error (not enough memory available), <tt/calloc/ returns
1279 <item>Clearing the memory may not have the expected effect on all platforms:
1280 pointers in the block may not be <tt/NULL/ and floating point variables may
1281 not be zero (0.0). In other words: The "clearing" effect of this function
1282 should be used with care for portable programs.
1283 <item>The function is only available as fastcall function, so it may only
1284 be used in presence of a prototype.
1286 <tag/Availability/ISO 9899
1288 <ref id="_heapadd" name="_heapadd">,
1289 <ref id="_heapblocksize" name="_heapblocksize">,
1290 <ref id="_heapmaxavail" name="_heapmaxavail">,
1291 <ref id="_heapmemavail" name="_heapmemavail">,
1292 <ref id="free" name="free">,
1293 <ref id="malloc" name="malloc">,
1294 <ref id="realloc" name="realloc">
1300 <sect1>cclear<label id="cclear"><p>
1304 <tag/Function/Clear part of a line (write a given number of spaces).
1305 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1306 <tag/Declaration/<tt/void __fastcall__ cclear (unsigned char length);/
1307 <tag/Description/The function clears part of a line by writing <tt/length/
1308 spaces in the current text color.
1309 <tag/Limits/<itemize>
1310 <item>The function is only available as fastcall function, so it may
1311 only be used in presence of a prototype.
1313 <tag/Availability/cc65
1315 <ref id="cclearxy" name="cclearxy">,
1316 <ref id="clrscr" name="clrscr">
1322 <sect1>cclearxy<label id="cclearxy"><p>
1326 <tag/Function/Clear part of a line (write a given number of spaces) starting
1327 at a specific screen position.
1328 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1329 <tag/Declaration/<tt/void __fastcall__ cclearxy (unsigned char x, unsigned char y, unsigned char length);/
1330 <tag/Description/The function moves the cursor to a specific position, and
1331 will then clear part of the line by writing <tt/length/ spaces in the current
1333 <tag/Limits/<itemize>
1334 <item>The function is only available as fastcall function, so it may
1335 only be used in presence of a prototype.
1337 <tag/Availability/cc65
1339 <ref id="cclear" name="cclear">,
1340 <ref id="clrscr" name="clrscr">
1346 <sect1>cgetc<label id="cgetc"><p>
1350 <tag/Function/Read a character from the keyboard.
1351 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1352 <tag/Declaration/<tt/char cgetc (void);/
1353 <tag/Description/The function reads a character from the keyboard. If there is
1354 no character available, <tt/cgetc/ waits until the user presses a key. If the
1355 cursor is enabled by use of the <tt/cursor/ function, a blinking cursor is
1356 displayed while waiting.
1357 <tag/Limits/<itemize>
1358 <item>If the system supports a keyboard buffer, <tt/cgetc/ will fetch a key
1359 from this buffer and wait only if the buffer is empty.
1361 <tag/Availability/cc65
1363 <ref id="cursor" name="cursor">,
1364 <ref id="kbhit" name="kbhit">
1370 <sect1>chline<label id="chline"><p>
1374 <tag/Function/Output a horizontal line in text mode.
1375 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1376 <tag/Declaration/<tt/void __fastcall__ chline (unsigned char length);/
1377 <tag/Description/The function outputs a horizontal line with the given length
1378 starting at the current cursor position.
1379 <tag/Limits/<itemize>
1380 <item>The character used to draw the horizontal line is system dependent.
1381 If available, a line drawing character is used. Drawing a line that is partially
1382 off screen leads to undefined behaviour.
1383 <item>The function is only available as fastcall function, so it may only be
1384 used in presence of a prototype.
1386 <tag/Availability/cc65
1388 <ref id="chlinexy" name="chlinexy">,
1389 <ref id="cvline" name="cvline">,
1390 <ref id="cvlinexy" name="cvlinexy">
1396 <sect1>chlinexy<label id="chlinexy"><p>
1400 <tag/Function/Output a horizontal line at a given position in text mode.
1401 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1402 <tag/Declaration/<tt/void __fastcall__ chlinexy (unsigned char x, unsigned char y, unsigned char length);/
1403 <tag/Description/The function outputs a horizontal line with the given length
1404 starting at a given position.
1405 <tag/Limits/<itemize>
1406 <item>The character used to draw the horizontal line is system dependent.
1407 If available, a line drawing character is used. Drawing a line that is partially
1408 off screen leads to undefined behaviour.
1409 <item>The function is only available as fastcall function, so it may only be
1410 used in presence of a prototype.
1412 <tag/Availability/cc65
1414 <ref id="chline" name="chline">,
1415 <ref id="cvline" name="cvline">,
1416 <ref id="cvlinexy" name="cvlinexy">
1422 <sect1>clearerr<label id="clearerr"><p>
1426 <tag/Function/Clear error and end-of-file status of a stream.
1427 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
1428 <tag/Declaration/<tt/void __fastcall__ clearerr (FILE* f);/
1429 <tag/Description/<tt/clearerr/ clears the error and end-of-file status
1430 indicators for the stream <tt/f/.
1431 <tag/Limits/<itemize>
1432 <item>The function is only available as fastcall function, so it may only be
1433 used in presence of a prototype.
1435 <tag/Availability/ISO 9899
1437 <ref id="feof" name="feof">,
1438 <ref id="ferror" name="ferror">
1444 <sect1>clrscr<label id="clrscr"><p>
1448 <tag/Function/Clear the text screen.
1449 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1450 <tag/Declaration/<tt/void clrscr (void);/
1451 <tag/Description/The function clears the text screen and moves the cursor to
1452 the upper left corner.
1453 <tag/Availability/cc65
1455 <ref id="cclear" name="cclear">,
1456 <ref id="cclearxy" name="cclearxy">
1462 <sect1>close<label id="close"><p>
1466 <tag/Function/Close a file descriptor.
1467 <tag/Header/<tt/<ref id="fcntl.h" name="fcntl.h">/
1468 <tag/Declaration/<tt/int __fastcall__ close (int fd);/
1469 <tag/Description/The function closes the given file descriptor. It returns zero
1470 on success and -1 on error. If an error occurs, the cause can be determined by
1471 reading the <tt/errno/ variable.
1472 <tag/Limits/<itemize>
1473 <item>The function is only available as fastcall function, so it may only
1474 be used in presence of a prototype.
1476 <tag/Availability/POSIX 1003.1
1478 <ref id="creat" name="creat">,
1479 <ref id="open" name="open">
1485 <sect1>creat<label id="creat"><p>
1489 <tag/Function/Create a file.
1490 <tag/Header/<tt/<ref id="fcntl.h" name="fcntl.h">/
1491 <tag/Declaration/<tt/int __fastcall__ creat (const char* name, unsigned mode);/
1492 <tag/Description/<tt/creat/ creates a new file and returns the file descriptor
1493 associated with it. On error, -1 is returned and an error code is stored in
1495 <tag/Limits/<itemize>
1496 <item><tt/creat/ is identical to calling <tt/<ref id="open" name="open">/ with
1497 <tt/flags/ equal to <tt/O_WRONLY | O_CREAT | O_TRUNC/.
1498 <item>The function is only available as fastcall function, so it may only
1499 be used in presence of a prototype.
1501 <tag/Availability/POSIX 1003.1
1503 <ref id="close" name="close">,
1504 <ref id="open" name="open">
1510 <sect1>cprintf<label id="cprintf"><p>
1514 <tag/Function/Formatted output to the console.
1515 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1516 <tag/Declaration/<tt/int cprintf (const char* format, ...);/
1517 <tag/Description/The arguments are converted to text where necessary and
1518 formatted according to the format string given. The resulting string is output
1519 to the console. <tt/cprintf/ supports the same format specifiers as
1520 <tt/printf/. <!-- <tt/<ref id="printf" name="printf">/. -->
1521 <tag/Limits/<itemize>
1522 <item>Like all other <tt/conio/ output functions, <tt/cprintf/ distinguishes
1523 between <tt/\r/ and <tt/\n/.
1525 <tag/Availability/cc65
1527 <ref id="cputc" name="cputc">,
1528 <ref id="cputcxy" name="cputcxy">,
1529 <ref id="cputs" name="cputs">,
1530 <ref id="cputsxy" name="cputsxy">,
1531 <ref id="vcprintf" name="vcprintf">
1537 <sect1>cputc<label id="cputc"><p>
1541 <tag/Function/Output a character directly to the console.
1542 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1543 <tag/Declaration/<tt/void __fastcall__ cputc (char c);/
1544 <tag/Description/Output one character to the console at the current cursor
1546 <tag/Limits/<itemize>
1547 <item>Like all other <tt/conio/ output functions, <tt/cputc/ distinguishes
1548 between <tt/\r/ and <tt/\n/.
1549 <item>The function is only available as fastcall function, so it may only
1550 be used in presence of a prototype.
1552 <tag/Availability/cc65
1554 <ref id="cprintf" name="cprintf">,
1555 <ref id="cputcxy" name="cputcxy">,
1556 <ref id="cputs" name="cputs">,
1557 <ref id="cputsxy" name="cputsxy">,
1558 <ref id="vcprintf" name="vcprintf">
1564 <sect1>cputcxy<label id="cputcxy"><p>
1568 <tag/Function/Output a character at a specific screen position.
1569 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1570 <tag/Declaration/<tt/void __fastcall__ cputcxy (unsigned char x, unsigned char y, char c);/
1571 <tag/Description/<tt/cputcxy/ moves the cursor to the given x/y position on
1572 the screen and outputs one character.
1573 <tag/Limits/<itemize>
1574 <item>Like all other <tt/conio/ output functions, <tt/cputcxy/ distinguishes
1575 between <tt/\r/ and <tt/\n/.
1576 <item>The function is only available as fastcall function, so it may only
1577 be used in presence of a prototype.
1579 <tag/Availability/cc65
1581 <ref id="cprintf" name="cprintf">,
1582 <ref id="cputc" name="cputc">,
1583 <ref id="cputs" name="cputs">,
1584 <ref id="cputsxy" name="cputsxy">,
1585 <ref id="vcprintf" name="vcprintf">
1591 <sect1>cputs<label id="cputs"><p>
1595 <tag/Function/Output a string directly to the console.
1596 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1597 <tag/Declaration/<tt/void __fastcall__ cputs (const char* s);/
1598 <tag/Description/The function outputs the given string on the console at the
1599 current cursor position.
1600 <tag/Limits/<itemize>
1601 <item>Like all other <tt/conio/ output functions, <tt/cputs/ distinguishes
1602 between <tt/\r/ and <tt/\n/.
1603 <item>The function is only available as fastcall function, so it may only
1604 be used in presence of a prototype.
1606 <tag/Availability/cc65
1608 <ref id="cprintf" name="cprintf">,
1609 <ref id="cputc" name="cputc">,
1610 <ref id="cputcxy" name="cputcxy">,
1611 <ref id="cputsxy" name="cputsxy">,
1612 <ref id="vcprintf" name="vcprintf">
1618 <sect1>cputsxy<label id="cputsxy"><p>
1622 <tag/Function/Output a string to the console at a given position.
1623 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1624 <tag/Declaration/<tt/void __fastcall__ cputsxy (unsigned char x, unsigned char y, const char* s);/
1625 <tag/Description/<tt/cputsxy/ moves the cursor to the given x/y position,
1626 and outputs the string <tt/s/.
1627 <tag/Limits/<itemize>
1628 <item>Like all other <tt/conio/ output functions, <tt/cputsxy/ distinguishes
1629 between <tt/\r/ and <tt/\n/.
1630 <item>The function is only available as fastcall function, so it may only
1631 be used in presence of a prototype.
1633 <tag/Availability/cc65
1635 <ref id="cprintf" name="cprintf">,
1636 <ref id="cputc" name="cputc">,
1637 <ref id="cputcxy" name="cputcxy">,
1638 <ref id="cputs" name="cputs">,
1639 <ref id="vcprintf" name="vcprintf">
1645 <sect1>cursor<label id="cursor"><p>
1649 <tag/Function/Enable/disable a blinking cursor when waiting for keyboard input.
1650 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1651 <tag/Declaration/<tt/unsigned char __fastcall__ cursor (unsigned char onoff);/
1652 <tag/Description/If the argument to the function is non zero, a blinking cursor
1653 will be enabled when the <tt/cgetc/ function waits for input from the keyboard.
1654 If the argument is zero, <tt/cgetc/ will wait without a blinking cursor.
1655 <tag/Limits/<itemize>
1656 <item>The function is only available as fastcall function, so it may only
1657 be used in presence of a prototype.
1659 <tag/Availability/cc65
1661 <ref id="cgetc" name="cgetc">,
1662 <ref id="kbhit" name="kbhit">
1668 <sect1>cvline<label id="cvline"><p>
1672 <tag/Function/Output a vertical line in text mode.
1673 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1674 <tag/Declaration/<tt/void __fastcall__ cvline (unsigned char length);/
1675 <tag/Description/The function outputs a vertical line with the given length
1676 starting at the current cursor position.
1677 <tag/Limits/<itemize>
1678 <item>The character used to draw the vertical line is system dependent.
1679 If available, a line drawing character is used. Drawing a line that is partially
1680 off screen leads to undefined behaviour.
1681 <item>The function is only available as fastcall function, so it may only be
1682 used in presence of a prototype.
1684 <tag/Availability/cc65
1686 <ref id="chline" name="chline">,
1687 <ref id="chlinexy" name="chlinexy">,
1688 <ref id="cvlinexy" name="cvlinexy">
1694 <sect1>cvlinexy<label id="cvlinexy"><p>
1698 <tag/Function/Output a vertical line at a given position in text mode.
1699 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1700 <tag/Declaration/<tt/void __fastcall__ cvlinexy (unsigned char x, unsigned char y, unsigned char length);/
1701 <tag/Description/The function outputs a vertical line with the given length
1702 starting at a given position.
1703 <tag/Limits/<itemize>
1704 <item>The character used to draw the vertical line is system dependent.
1705 If available, a line drawing character is used. Drawing a line that is partially
1706 off screen leads to undefined behaviour.
1707 <item>The function is only available as fastcall function, so it may only be
1708 used in presence of a prototype.
1710 <tag/Availability/cc65
1712 <ref id="chline" name="chline">,
1713 <ref id="chlinexy" name="chlinexy">,
1714 <ref id="cvline" name="cvline">
1720 <sect1>div<label id="div"><p>
1724 <tag/Function/Divide two ints and return quotient and remainder.
1725 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1726 <tag/Declaration/<tt/div_t __fastcall__ div (int numer, int denom);/
1727 <tag/Description/<tt/div/ divides <tt/numer/ by <tt/denom/ and returns the
1728 quotient and remainder in a <tt/div_t/ structure.
1731 <item>The function is only available as fastcall function, so it may only
1732 be used in presence of a prototype.
1734 <tag/Availability/ISO 9899
1742 <sect1>em_commit<label id="em_commit"><p>
1746 <tag/Function/Commit changes into extended memory.
1747 <tag/Header/<tt/<ref id="em.h" name="em.h">/
1748 <tag/Declaration/<tt/void __fastcall__ em_commit (void);/
1749 <tag/Description/Commit changes in the memory window to extended storage. If
1750 the contents of the memory window have been changed, these changes may be lost
1751 if <tt/<ref id="em_map" name="em_map">/, <tt/<ref id="em_use" name="em_use">/,
1752 <tt/<ref id="em_copyfrom" name="em_copyfrom">/ or <tt/<ref id="em_copyto"
1753 name="em_copyto">/ are called without calling <tt/em_commit/ first.
1754 <tag/Limits/<itemize>
1755 <item>Calling <tt/em_commit/ does not necessarily mean that changes to the
1756 memory window are discarded, it does just mean that the drivers is allowed
1758 <item>The function is only available as fastcall function, so it may only be
1759 used in presence of a prototype.
1760 <item>The function produces undefined results if no extended memory driver is
1763 <tag/Availability/cc65
1765 <ref id="em_load_driver" name="em_load_driver">,
1766 <ref id="em_map" name="em_map">,
1767 <ref id="em_use" name="em_use">
1773 <sect1>em_copyfrom<label id="em_copyfrom"><p>
1777 <tag/Function/Copy from extended into normal memory.
1778 <tag/Header/<tt/<ref id="em.h" name="em.h">/
1779 <tag/Declaration/<tt/void __fastcall__ em_copyfrom (const struct em_copy* copy_data);/
1780 <tag/Description/Copy data from extended memory into linear memory. Source and
1781 target addresses as well as the number of bytes to transfer are specified in
1782 the <tt/em_copy/ structure that is passed as a parameter.
1783 <tag/Limits/<itemize>
1784 <item>Calling <tt/em_copyfrom/ will invalidate the memory window, so if you
1785 made any changes to the data in the window, call <tt/<ref id="em_commit"
1786 name="em_commit">/ first, or the changes are lost.
1787 <item>The function is only available as fastcall function, so it may only be
1788 used in presence of a prototype.
1789 <item>The function produces undefined results if no extended memory driver is
1792 <tag/Availability/cc65
1794 <ref id="em_commit" name="em_commit">,
1795 <ref id="em_copyto" name="em_copyto">,
1796 <ref id="em_load_driver" name="em_load_driver">
1802 <sect1>em_copyto<label id="em_copyto"><p>
1806 <tag/Function/Copy from normal into extended memory.
1807 <tag/Header/<tt/<ref id="em.h" name="em.h">/
1808 <tag/Declaration/<tt/void __fastcall__ em_copyto (const struct em_copy* copy_data);/
1809 <tag/Description/Copy data from linear into extended memory. Source and
1810 target addresses as well as the number of bytes to transfer are specified in
1811 the <tt/em_copy/ structure that is passed as a parameter.
1812 <tag/Limits/<itemize>
1813 <item>Calling <tt/em_copyto/ will invalidate the memory window, so if you
1814 made any changes to the data in the window, call <tt/<ref id="em_commit"
1815 name="em_commit">/ first, or the changes are lost.
1816 <item>The function is only available as fastcall function, so it may only be
1817 used in presence of a prototype.
1818 <item>The function produces undefined results if no extended memory driver is
1821 <tag/Availability/cc65
1823 <ref id="em_commit" name="em_commit">,
1824 <ref id="em_copyfrom" name="em_copyfrom">,
1825 <ref id="em_load_driver" name="em_load_driver">
1831 <sect1>em_install<label id="em_install"><p>
1835 <tag/Function/Install an already loaded extended memory driver.
1836 <tag/Header/<tt/<ref id="em.h" name="em.h">/
1837 <tag/Declaration/<tt/unsigned char _fastcall__ em_install (void* driver);/
1838 <tag/Description/The function installs an already loaded extended memory driver
1839 and returns an error code. The function may be used to install a driver linked
1840 statically to the program.
1841 <tag/Limits/<itemize>
1842 <item>Not all drivers are able to detect if the supported hardware is really
1844 <item>The function is only available as fastcall function, so it may only be
1845 used in presence of a prototype.
1847 <tag/Availability/cc65
1849 <ref id="em_load_driver" name="em_load_driver">,
1850 <ref id="em_uninstall" name="em_uninstall">,
1851 <ref id="em_unload" name="em_unload">
1857 <sect1>em_load_driver<label id="em_load_driver"><p>
1861 <tag/Function/Load and initialize an extended memory driver.
1862 <tag/Header/<tt/<ref id="em.h" name="em.h">/
1863 <tag/Declaration/<tt/void __fastcall__ em_load_driver (const char* name);/
1864 <tag/Description/Load an extended memory driver into memory and initialize
1865 it. The function returns an error code that tells if all this has been
1867 <tag/Limits/<itemize>
1868 <item>Not all drivers are able to detect if the supported hardware is really
1870 <item>The function is only available as fastcall function, so it may only be
1871 used in presence of a prototype.
1872 <item>The driver is loaded by name, so currently you must know the type of
1873 extended memory that should be supported. There is no autodetect capability.
1875 <tag/Availability/cc65
1877 <ref id="em_unload" name="em_unload">
1883 <sect1>em_map<label id="em_map"><p>
1887 <tag/Function/Make a page of extended memory accessible.
1888 <tag/Header/<tt/<ref id="em.h" name="em.h">/
1889 <tag/Declaration/<tt/void* __fastcall__ em_map (unsigned page);/
1890 <tag/Description/The function maps one page of extended memory into linear
1891 memory and returns a pointer to the page frame. Depending on the hardware
1892 and driver, the data is either mapped into the address space or transfered
1893 into a buffer. If you don't need the actual contents of the page (for example
1894 because you're going to overwrite it completely), it is better to call
1895 <tt/<ref id="em_use" name="em_use">/ instead. <tt/em_use/ will not transfer the
1896 data if it is possible to avoid that.
1897 <tag/Limits/<itemize>
1898 <item>Calling <tt/em_map/ will invalidate the memory window, so if you
1899 made any changes to the data in the window, call <tt/<ref id="em_commit"
1900 name="em_commit">/ first, or the changes are lost.
1901 <item>The function is only available as fastcall function, so it may only be
1902 used in presence of a prototype.
1903 <item>The function produces undefined results if no extended memory driver is
1906 <tag/Availability/cc65
1908 <ref id="em_commit" name="em_commit">,
1909 <ref id="em_load_driver" name="em_load_driver">,
1910 <ref id="em_use" name="em_use">
1916 <sect1>em_pagecount<label id="em_pagecount"><p>
1920 <tag/Function/Return the number of available extended memory pages.
1921 <tag/Header/<tt/<ref id="em.h" name="em.h">/
1922 <tag/Declaration/<tt/unsigned __fastcall__ em_pagecount (void);/
1923 <tag/Description/The function returns the size of the extended memory supported
1924 by the driver in 256 byte pages.
1925 <tag/Limits/<itemize>
1926 <item>The function returns zero if no extended memory driver is loaded.
1927 <item>The function may return zero if the supported hardware was not detected.
1929 <tag/Availability/cc65
1931 <ref id="em_load_driver" name="em_load_driver">
1937 <sect1>em_uninstall<label id="em_uninstall"><p>
1941 <tag/Function/Uninstall an already loaded extended memory driver.
1942 <tag/Header/<tt/<ref id="em.h" name="em.h">/
1943 <tag/Declaration/<tt/unsigned char __fastcall__ em_install (void);/
1944 <tag/Description/The function uninstalls an already loaded extended memory
1945 driver but doesn't remove it from memory.
1946 <tag/Limits/<itemize>
1947 <item>If the driver has been loaded using <tt/<ref id="em_load_driver"
1948 name="em_load_driver">/, <tt/<ref id="em_unload" name="em_unload">/
1949 should be used instead of <tt/em_uninstall/ so the driver is also removed
1951 <item>The function is only available as fastcall function, so it may only be
1952 used in presence of a prototype.
1954 <tag/Availability/cc65
1956 <ref id="em_install" name="em_install">,
1957 <ref id="em_load_driver" name="em_load_driver">,
1958 <ref id="em_unload" name="em_unload">
1964 <sect1>em_unload<label id="em_unload"><p>
1968 <tag/Function/Unload an extended memory driver.
1969 <tag/Header/<tt/<ref id="em.h" name="em.h">/
1970 <tag/Declaration/<tt/unsigned char __fastcall__ em_unload (void);/
1971 <tag/Description/The function unloads a loaded extended memory driver and
1972 frees all memory allocated for the driver.
1973 <tag/Limits/<itemize>
1974 <item>The function does nothing if no driver is loaded.
1976 <tag/Availability/cc65
1978 <ref id="em_load_driver" name="em_load_driver">
1984 <sect1>em_use<label id="em_use"><p>
1988 <tag/Function/Prepare an extended memory page for use.
1989 <tag/Header/<tt/<ref id="em.h" name="em.h">/
1990 <tag/Declaration/<tt/void* __fastcall__ em_use (unsigned page);/
1991 <tag/Description/The function maps one page of extended memory into linear
1992 memory and returns a pointer to the page frame. This function is similar to
1993 <tt/<ref id="em_map" name="em_map">/, but will not transfer data into the
1994 actual memory window in the assumption that the existing data is wrong or
1995 will get overwritten.
1996 <tag/Limits/<itemize>
1997 <item>Calling <tt/em_use/ will invalidate the memory window, so if you
1998 made any changes to the data in the window, call <tt/<ref id="em_commit"
1999 name="em_commit">/ first, or the changes are lost.
2000 <item>The function is only available as fastcall function, so it may only be
2001 used in presence of a prototype.
2002 <item>The function produces undefined results if no extended memory driver is
2005 <tag/Availability/cc65
2007 <ref id="em_commit" name="em_commit">,
2008 <ref id="em_load_driver" name="em_load_driver">,
2009 <ref id="em_map" name="em_map">
2015 <sect1>exit<label id="exit"><p>
2019 <tag/Function/Terminate the program.
2020 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
2021 <tag/Declaration/<tt/void __fastcall__ exit (int status);/
2022 <tag/Description/<tt/exit/ terminates the program. The argument specifies the
2023 return code of the program. Before termination, all files are closed, buffered
2024 output is written and any functions registered with <tt/<ref id="atexit"
2025 name="atexit">/ are called. Common values for status are <tt/EXIT_SUCCESS/ and
2026 <tt/EXIT_FAILURE/ which are also defined in <tt/<ref id="stdlib.h"
2028 <tag/Limits/<itemize>
2029 <item>The function is only available as fastcall function, so it may only
2030 be used in presence of a prototype.
2031 <item>It depends on the host machine if the program return code can be
2032 evaluated or is ignored.
2034 <tag/Availability/ISO 9899
2036 <ref id="abort" name="abort">,
2037 <ref id="exit" name="exit">
2043 <sect1>exec<label id="exec"><p>
2047 <tag/Function/Execute a program file.
2048 <tag/Header/<tt/<ref id="unistd.h" name="unistd.h">/
2049 <tag/Declaration/<tt/int __fastcall__ exec (const char* progname, const char* cmdline);/
2050 <tag/Description/<tt/exec/ replaces the currently running program by a new one.
2051 Calling <tt/exec()/ is identical to calling <tt/<ref id="exit" name="exit()">/,
2052 then loading and starting the program named in the first argument, passing
2053 the command line specified as second argument. Instead of an empty string,
2054 a <tt/NULL/ pointer may be passed as second parameter.
2055 On success, the function does not return. On failure, -1 is returned and
2056 <tt/errno/ contains an error code.
2057 <tag/Limits/<itemize>
2058 <item>The function is only available as fastcall function, so it may only
2059 be used in presence of a prototype.
2060 <item>On most platforms, the function needs to copy a small stub loader to
2061 some memory area outside the program space. This may collide with other
2062 programs. See the platform specific docs on this.
2063 <item>Because it is necessary to terminate the running program before the
2064 memory can be reused to load the new one, there is a high chance that the
2065 function may not be able to return on errors.
2066 <item>The command line is passed to the new program in the same way as cc65
2067 programs expect the command line. If the new program is not a cc65 generated
2068 program, it may not be able to read it.
2070 <tag/Availability/cc65
2072 <ref id="exit" name="exit">
2078 <sect1>fast<label id="fast"><p>
2082 <tag/Function/Switch the C128 into 2MHz mode.
2083 <tag/Header/<tt/<ref id="c128.h" name="c128.h">/
2084 <tag/Declaration/<tt/void fast (void);/
2085 <tag/Description/The function will switch the clock of the C128 to 2MHz. This
2086 will nearly double the speed compared to slow mode.
2087 <tag/Limits/<itemize>
2088 <item>The function is specific to the C128.
2089 <item>2MHz clock will not work in 40 column mode.
2091 <tag/Availability/C128
2093 <ref id="slow" name="slow">,
2094 <ref id="toggle_videomode" name="toggle_videomode">,
2095 <ref id="videomode" name="videomode">
2101 <sect1>feof<label id="feof"><p>
2105 <tag/Function/Return the end-of-file indicator of a stream.
2106 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
2107 <tag/Declaration/<tt/int __fastcall__ feof (FILE* f);/
2108 <tag/Description/<tt/feof/ tests the end-of-file indicator ofthe stream
2109 <tt/f/, and returns a non zero value if it is set.
2110 <tag/Limits/<itemize>
2111 <item>The indicator is set only after a read past the end of a file is
2113 <item>The function is only available as fastcall function, so it may only be
2114 used in presence of a prototype.
2116 <tag/Availability/ISO 9899
2118 <ref id="feof" name="clearerr">,
2119 <ref id="ferror" name="ferror">
2125 <sect1>ferror<label id="ferror"><p>
2129 <tag/Function/Return the error indicator of a stream.
2130 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
2131 <tag/Declaration/<tt/int __fastcall__ ferror (FILE* f);/
2132 <tag/Description/<tt/ferror/ tests the error indicator of the stream
2133 <tt/f/, and returns a non zero value if it is set.
2134 <tag/Limits/<itemize>
2135 <item>The function is only available as fastcall function, so it may only be
2136 used in presence of a prototype.
2138 <tag/Availability/ISO 9899
2140 <ref id="feof" name="clearerr">,
2141 <ref id="ferror" name="feof">
2147 <sect1>fileno<label id="fileno"><p>
2151 <tag/Function/Return the file handle used by a stream.
2152 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
2153 <tag/Declaration/<tt/int __fastcall__ fileno (FILE* f);/
2154 <tag/Description/The <tt/fileno/ function returns the file handle used
2155 internally by a C stream. This file handle (an integer) can be used as a
2156 handle for the POSIX input/output functions.
2157 <tag/Limits/<itemize>
2158 <item>The function is only available as fastcall function, so it may only be
2159 used in presence of a prototype.
2160 <item>Mixing C file I/O functions and POSIX file I/O functions for the same
2161 file may have unpredictable results.
2163 <tag/Availability/POSIX 1003.1
2165 <ref id="creat" name="creat">,
2166 <ref id="open" name="open"> <!-- , -->
2167 <!-- <ref id="read" name="read">, -->
2168 <!-- <ref id="write" name="write"> -->
2174 <sect1>free<label id="free"><p>
2178 <tag/Function/Free a block of dynamic memory.
2179 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
2180 <tag/Declaration/<tt/void __fastcall__ free (void* block);/
2181 <tag/Description/Free a block of dynamic memory previously allocated with
2182 <tt/<ref id="malloc" name="malloc">/, <tt/<ref id="calloc" name="calloc">/
2183 or <tt/<ref id="realloc" name="realloc">/. As an exception, if the passed
2184 pointer is <tt/NULL/, no action is performed.
2187 <item>Passing an already free'd block to <tt/free/ again will cause undefined
2188 behaviour and may crash your program.
2189 <item>The function is only available as fastcall function, so it may only
2190 be used in presence of a prototype.
2192 <tag/Availability/ISO 9899
2194 <ref id="_heapadd" name="_heapadd">,
2195 <ref id="_heapblocksize" name="_heapblocksize">,
2196 <ref id="_heapmaxavail" name="_heapmaxavail">,
2197 <ref id="_heapmemavail" name="_heapmemavail">,
2198 <ref id="calloc" name="calloc">,
2199 <ref id="malloc" name="malloc">,
2200 <ref id="realloc" name="realloc">
2206 <sect1>get_ostype<label id="get_ostype"><p>
2210 <tag/Function/The function returns the operating system, the program runs on.
2211 <tag/Header/<tt/<ref id="apple2.h" name="apple2.h">,
2212 <ref id="atari.h" name="atari.h">, <ref id="c64.h" name="c64.h">/
2213 <tag/Declaration/<tt/unsigned char get_ostype (void);/
2214 <tag/Description/<tt/get_ostype/ is machine dependent and does not exist for
2215 all supported targets. If it exists, it returns a number that identifies the
2216 operating system or machine type, the program runs on. The machine dependent
2217 header files define constants that can be used to check the return code.
2218 <tag/Limits/<itemize>
2219 <item>The function does not exist on all platforms.
2220 <item>The return codes are platform dependent.
2222 <tag/Availability/cc65 (not all platforms)
2228 <sect1>getcpu<label id="getcpu"><p>
2232 <tag/Function/Determine on which CPU the program is running.
2233 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
2234 <tag/Declaration/<tt/unsigned char getcpu (void);/
2235 <tag/Description/The function checks on which CPU the code is running. It
2236 returns one of the constants<itemize>
2238 <item><tt/CPU_65C02/
2239 <item><tt/CPU_65816/
2241 <tag/Limits/<itemize>
2242 <item>Other, more exotic CPU types are not disinguished.
2244 <tag/Availability/cc65
2250 <sect1>getenv<label id="getenv"><p>
2254 <tag/Function/Return a value from the environment.
2255 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
2256 <tag/Declaration/<tt/char* __fastcall__ getenv (const char* name);/
2257 <tag/Description/The function searches the environment for an entry that
2258 matches <tt/name/ and returns its value. The environment consists of a list
2259 of strings in the form <tt/name=value/. If there is no match, <tt/getenv/
2261 <tag/Limits/<itemize>
2262 <item>What exactly is stored in the environment depends on the machine the
2263 program is running on.
2264 <item>The function is only available as fastcall function, so it may only
2265 be used in presence of a prototype.
2267 <tag/Availability/ISO 9899
2273 <sect1>getopt<label id="getopt"><p>
2277 <tag/Function/Parse command line options.
2278 <tag/Header/<tt/<ref id="unistd.h" name="unistd.h">/
2279 <tag/Declaration/<tt/int __fastcall__ getopt (int argc, char* const* argv,
2280 const char* optstring);/
2281 <tag/Description/The function parses command line arguments, <tt/argc/ and
2282 <tt/argv/ are the argument count and array passed to <tt/main/. <tt/optstring/
2283 is a string that contains command line option characters. If a character in
2284 <tt/optstring/ is followed by a colon, the option requires an argument. An
2285 option on the command line is recognized if it is one of the option characters
2287 <tt/getopt/ must be called repeatedly. It will return each option character
2288 found on the command line and <tt/EOF/ (-1) if there is no other option. An
2289 option argument is placed in <tt/optarg/, the index of the next element on the
2290 command line to be processed is placed in <tt/optind/.
2291 <tag/Limits/<itemize>
2292 <item>The implementation will not reorder options. A non option on the command
2293 line will terminate option processing. All remaining arguments are not
2294 recognized as options, even if the start with a '-' character.
2295 <item>The function is only available as fastcall function, so it may only
2296 be used in presence of a prototype.
2298 <tag/Availability/POSIX.2
2304 <sect1>gotox<label id="gotox"><p>
2308 <tag/Function/Move the text mode cursor to a new X position.
2309 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2310 <tag/Declaration/<tt/void __fastcall__ gotox (unsigned char x);/
2311 <tag/Description/The function moves the text mode cursor to the specified X
2312 position while leaving the Y position untouched. The leftmost position on the
2313 screen has the coordinate 0.
2314 <tag/Limits/<itemize>
2315 <item>The function is only available as fastcall function, so it may
2316 only be used in presence of a prototype.
2317 <item>Invalid values for the X position (out of screen coordinates) may
2318 lead to undefined behaviour.
2320 <tag/Availability/cc65
2322 <ref id="gotoy" name="gotoy">,
2323 <ref id="gotoxy" name="gotoxy">,
2324 <ref id="wherex" name="wherex">,
2325 <ref id="wherey" name="wherey">
2331 <sect1>gotoxy<label id="gotoxy"><p>
2335 <tag/Function/Move the text mode cursor to a new position.
2336 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2337 <tag/Declaration/<tt/void __fastcall__ gotoxy (unsigned char x, unsigned char y);/
2338 <tag/Description/The function moves the text mode cursor to the specified
2339 position. The leftmost position on the screen has the X coordinate 0, the
2340 topmost line has the Y coordinate 0.
2341 <tag/Limits/<itemize>
2342 <item>The function is only available as fastcall function, so it may only be
2343 used in presence of a prototype.
2344 <item>Invalid values for any of both coordinates (out of screen positions) may
2345 lead to undefined behaviour.
2347 <tag/Availability/cc65
2349 <ref id="gotox" name="gotox">,
2350 <ref id="gotoy" name="gotoy">,
2351 <ref id="wherex" name="wherex">,
2352 <ref id="wherey" name="wherey">
2358 <sect1>gotoy<label id="gotoy"><p>
2362 <tag/Function/Move the text mode cursor to a new Y position.
2363 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2364 <tag/Declaration/<tt/void __fastcall__ gotoy (unsigned char x);/
2365 <tag/Description/The function moves the text mode cursor to the specified Y
2366 position while leaving the X position untouched. The uppermost position on the
2367 screen has the coordinate 0.
2368 <tag/Limits/<itemize>
2369 <item>The function is only available as fastcall function, so it may
2370 only be used in presence of a prototype.
2371 <item>Invalid values for the Y position (out of screen coordinates) may lead
2372 to undefined behaviour.
2374 <tag/Availability/cc65
2376 <ref id="gotox" name="gotox">,
2377 <ref id="gotoxy" name="gotoxy">,
2378 <ref id="wherex" name="wherex">,
2379 <ref id="wherey" name="wherey">
2385 <sect1>isalnum<label id="isalnum"><p>
2389 <tag/Function/Check if a given character is a letter or digit.
2390 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2391 <tag/Declaration/<tt/int __fastcall__ isalnum (int c);/
2392 <tag/Description/The function returns a non zero value if the given argument
2393 is a letter or digit. The return value is zero if the character is anything
2395 <tag/Limits/<itemize>
2396 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2397 inline sequence generated by the macro will not work correctly for values
2398 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2399 this range. The non inline function may be accessed by <tt/#undef/'ing
2401 <item>When compiling without <tt/-Os/, the function is only available as
2402 fastcall function, so it may only be used in presence of a prototype.
2404 <tag/Availability/ISO 9899
2406 <ref id="isalpha" name="isalpha">,
2407 <ref id="isascii" name="isascii">,
2408 <ref id="isblank" name="isblank">,
2409 <ref id="iscntrl" name="iscntrl">,
2410 <ref id="isdigit" name="isdigit">,
2411 <ref id="isgraph" name="isgraph">,
2412 <ref id="islower" name="islower">,
2413 <ref id="isprint" name="isprint">,
2414 <ref id="ispunct" name="ispunct">,
2415 <ref id="isspace" name="isspace">,
2416 <ref id="isupper" name="isupper">,
2417 <ref id="isxdigit" name="isxdigit">
2423 <sect1>isalpha<label id="isalpha"><p>
2427 <tag/Function/Check if a given character is a letter.
2428 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2429 <tag/Declaration/<tt/int __fastcall__ isalpha (int c);/
2430 <tag/Description/The function returns a non zero value if the given argument
2431 is a letter. The return value is zero if the character is anything else.
2432 <tag/Limits/<itemize>
2433 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2434 inline sequence generated by the macro will not work correctly for values
2435 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2436 this range. The non inline function may be accessed by <tt/#undef/'ing the
2438 <item>When compiling without <tt/-Os/, the function is only available as
2439 fastcall function, so it may only be used in presence of a prototype.
2441 <tag/Availability/ISO 9899
2443 <ref id="isalnum" name="isalnum">,
2444 <ref id="isascii" name="isascii">,
2445 <ref id="isblank" name="isblank">,
2446 <ref id="iscntrl" name="iscntrl">,
2447 <ref id="isdigit" name="isdigit">,
2448 <ref id="isgraph" name="isgraph">,
2449 <ref id="islower" name="islower">,
2450 <ref id="isprint" name="isprint">,
2451 <ref id="ispunct" name="ispunct">,
2452 <ref id="isspace" name="isspace">,
2453 <ref id="isupper" name="isupper">,
2454 <ref id="isxdigit" name="isxdigit">
2460 <sect1>isascii<label id="isascii"><p>
2464 <tag/Function/Check if a given character is in the ASCII (0..127) range.
2465 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2466 <tag/Declaration/<tt/int __fastcall__ isascii (int c);/
2467 <tag/Description/The function returns a non zero value if the given argument
2468 is in the range 0..127 (the range of valid ASCII characters) and zero if not.
2469 <tag/Limits/<itemize>
2470 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2471 inline sequence generated by the macro will not work correctly for values
2472 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2473 this range. The non inline function may be accessed by <tt/#undef/'ing the
2475 <item>When compiling without <tt/-Os/, the function is only available as
2476 fastcall function, so it may only be used in presence of a prototype.
2478 <tag/Availability/ISO 9899
2480 <ref id="isalnum" name="isalnum">,
2481 <ref id="isalpha" name="isalpha">,
2482 <ref id="isblank" name="isblank">,
2483 <ref id="iscntrl" name="iscntrl">,
2484 <ref id="isdigit" name="isdigit">,
2485 <ref id="isgraph" name="isgraph">,
2486 <ref id="islower" name="islower">,
2487 <ref id="isprint" name="isprint">,
2488 <ref id="ispunct" name="ispunct">,
2489 <ref id="isspace" name="isspace">,
2490 <ref id="isupper" name="isupper">,
2491 <ref id="isxdigit" name="isxdigit">
2497 <sect1>isblank<label id="isblank"><p>
2501 <tag/Function/Check if a given character is a space or tab.
2502 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2503 <tag/Declaration/<tt/int __fastcall__ isblank (int c);/
2504 <tag/Description/The function returns a non zero value if the given argument
2505 is a space or tab character. The return value is zero if the character is
2507 <tag/Limits/<itemize>
2508 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2509 inline sequence generated by the macro will not work correctly for values
2510 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2511 this range. The non inline function may be accessed by <tt/#undef/'ing the
2513 <item>When compiling without <tt/-Os/, the function is only available as
2514 fastcall function, so it may only be used in presence of a prototype.
2516 <tag/Availability/cc65
2518 <ref id="isalnum" name="isalnum">,
2519 <ref id="isalpha" name="isalpha">,
2520 <ref id="isascii" name="isascii">,
2521 <ref id="iscntrl" name="iscntrl">,
2522 <ref id="isdigit" name="isdigit">,
2523 <ref id="isgraph" name="isgraph">,
2524 <ref id="islower" name="islower">,
2525 <ref id="isprint" name="isprint">,
2526 <ref id="ispunct" name="ispunct">,
2527 <ref id="isspace" name="isspace">,
2528 <ref id="isupper" name="isupper">,
2529 <ref id="isxdigit" name="isxdigit">
2535 <sect1>iscntrl<label id="iscntrl"><p>
2539 <tag/Function/Check if a given character is a control character.
2540 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2541 <tag/Declaration/<tt/int __fastcall__ iscntrl (int c);/
2542 <tag/Description/The function returns a non zero value if the given argument
2543 is a control character. The return value is zero if the character is anything
2545 <tag/Limits/<itemize>
2546 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2547 inline sequence generated by the macro will not work correctly for values
2548 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2549 this range. The non inline function may be accessed by <tt/#undef/'ing the
2551 <item>When compiling without <tt/-Os/, the function is only available as
2552 fastcall function, so it may only be used in presence of a prototype.
2554 <tag/Availability/ISO 9899
2556 <ref id="isalnum" name="isalnum">,
2557 <ref id="isalpha" name="isalpha">,
2558 <ref id="isascii" name="isascii">,
2559 <ref id="isblank" name="isblank">,
2560 <ref id="isdigit" name="isdigit">,
2561 <ref id="isgraph" name="isgraph">,
2562 <ref id="islower" name="islower">,
2563 <ref id="isprint" name="isprint">,
2564 <ref id="ispunct" name="ispunct">,
2565 <ref id="isspace" name="isspace">,
2566 <ref id="isupper" name="isupper">,
2567 <ref id="isxdigit" name="isxdigit">
2573 <sect1>isdigit<label id="isdigit"><p>
2577 <tag/Function/Check if a given character is a digit.
2578 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2579 <tag/Declaration/<tt/int __fastcall__ isdigit (int c);/
2580 <tag/Description/The function returns a non zero value if the given argument
2581 is a digit. The return value is zero if the character is anything else.
2582 <tag/Limits/<itemize>
2583 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2584 inline sequence generated by the macro will not work correctly for values
2585 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2586 this range. The non inline function may be accessed by <tt/#undef/'ing the
2588 <item>When compiling without <tt/-Os/, the function is only available as
2589 fastcall function, so it may only be used in presence of a prototype.
2591 <tag/Availability/ISO 9899
2593 <ref id="isalnum" name="isalnum">,
2594 <ref id="isalpha" name="isalpha">,
2595 <ref id="isascii" name="isascii">,
2596 <ref id="isblank" name="isblank">,
2597 <ref id="iscntrl" name="iscntrl">,
2598 <ref id="isgraph" name="isgraph">,
2599 <ref id="islower" name="islower">,
2600 <ref id="isprint" name="isprint">,
2601 <ref id="ispunct" name="ispunct">,
2602 <ref id="isspace" name="isspace">,
2603 <ref id="isupper" name="isupper">,
2604 <ref id="isxdigit" name="isxdigit">
2610 <sect1>isgraph<label id="isgraph"><p>
2614 <tag/Function/Check if a given character is a printable character (except
2616 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2617 <tag/Declaration/<tt/int __fastcall__ isgraph (int c);/
2618 <tag/Description/The function returns a non zero value if the given argument
2619 is a printable character with the exception of space. The return value is zero
2620 if the character is anything else.
2621 <tag/Limits/<itemize>
2622 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2623 inline sequence generated by the macro will not work correctly for values
2624 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2625 this range. The non inline function may be accessed by <tt/#undef/'ing the
2627 <item>When compiling without <tt/-Os/, the function is only available as
2628 fastcall function, so it may only be used in presence of a prototype.
2630 <tag/Availability/ISO 9899
2632 <ref id="isalnum" name="isalnum">,
2633 <ref id="isalpha" name="isalpha">,
2634 <ref id="isascii" name="isascii">,
2635 <ref id="isblank" name="isblank">,
2636 <ref id="iscntrl" name="iscntrl">,
2637 <ref id="isdigit" name="isdigit">,
2638 <ref id="islower" name="islower">,
2639 <ref id="isprint" name="isprint">,
2640 <ref id="ispunct" name="ispunct">,
2641 <ref id="isspace" name="isspace">,
2642 <ref id="isupper" name="isupper">,
2643 <ref id="isxdigit" name="isxdigit">
2649 <sect1>islower<label id="islower"><p>
2653 <tag/Function/Check if a given character is a lower case letter.
2654 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2655 <tag/Declaration/<tt/int __fastcall__ islower (int c);/
2656 <tag/Description/The function returns a non zero value if the given argument
2657 is a lower case letter. The return value is zero if the character is anything
2659 <tag/Limits/<itemize>
2660 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2661 inline sequence generated by the macro will not work correctly for values
2662 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2663 this range. The non inline function may be accessed by <tt/#undef/'ing the
2665 <item>When compiling without <tt/-Os/, the function is only available as
2666 fastcall function, so it may only be used in presence of a prototype.
2668 <tag/Availability/ISO 9899
2670 <ref id="isalnum" name="isalnum">,
2671 <ref id="isalpha" name="isalpha">,
2672 <ref id="isascii" name="isascii">,
2673 <ref id="isblank" name="isblank">,
2674 <ref id="iscntrl" name="iscntrl">,
2675 <ref id="isdigit" name="isdigit">,
2676 <ref id="isgraph" name="isgraph">,
2677 <ref id="isprint" name="isprint">,
2678 <ref id="ispunct" name="ispunct">,
2679 <ref id="isspace" name="isspace">,
2680 <ref id="isupper" name="isupper">,
2681 <ref id="isxdigit" name="isxdigit">
2687 <sect1>isprint<label id="isprint"><p>
2691 <tag/Function/Check if a given character is a printable character.
2692 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2693 <tag/Declaration/<tt/int __fastcall__ isprint (int c);/
2694 <tag/Description/The function returns a non zero value if the given argument
2695 is a printable character (this includes the space character). The return value
2696 is zero if the character is anything else.
2697 <tag/Limits/<itemize>
2698 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2699 inline sequence generated by the macro will not work correctly for values
2700 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2701 this range. The non inline function may be accessed by <tt/#undef/'ing the
2703 <item>When compiling without <tt/-Os/, the function is only available as
2704 fastcall function, so it may only be used in presence of a prototype.
2706 <tag/Availability/ISO 9899
2708 <ref id="isalnum" name="isalnum">,
2709 <ref id="isalpha" name="isalpha">,
2710 <ref id="isascii" name="isascii">,
2711 <ref id="isblank" name="isblank">,
2712 <ref id="iscntrl" name="iscntrl">,
2713 <ref id="isdigit" name="isdigit">,
2714 <ref id="isgraph" name="isgraph">,
2715 <ref id="islower" name="islower">,
2716 <ref id="ispunct" name="ispunct">,
2717 <ref id="isspace" name="isspace">,
2718 <ref id="isupper" name="isupper">,
2719 <ref id="isxdigit" name="isxdigit">
2725 <sect1>ispunct<label id="ispunct"><p>
2729 <tag/Function/Check if a given character is a printable character but not a
2730 space or an alphanumeric character.
2731 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2732 <tag/Declaration/<tt/int __fastcall__ ispunct (int c);/
2733 <tag/Description/The function returns a non zero value if the given argument
2734 is a printable character, but not a space or anything alphanumeric. The return
2735 value is zero if the character is anything else.
2736 <tag/Limits/<itemize>
2737 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2738 inline sequence generated by the macro will not work correctly for values
2739 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2740 this range. The non inline function may be accessed by <tt/#undef/'ing the
2742 <item>When compiling without <tt/-Os/, the function is only available as
2743 fastcall function, so it may only be used in presence of a prototype.
2745 <tag/Availability/ISO 9899
2747 <ref id="isalnum" name="isalnum">,
2748 <ref id="isalpha" name="isalpha">,
2749 <ref id="isascii" name="isascii">,
2750 <ref id="isblank" name="isblank">,
2751 <ref id="iscntrl" name="iscntrl">,
2752 <ref id="isdigit" name="isdigit">,
2753 <ref id="isgraph" name="isgraph">,
2754 <ref id="islower" name="islower">,
2755 <ref id="isprint" name="isprint">,
2756 <ref id="isspace" name="isspace">,
2757 <ref id="isupper" name="isupper">,
2758 <ref id="isxdigit" name="isxdigit">
2764 <sect1>isspace<label id="isspace"><p>
2768 <tag/Function/Check if a given character is a a white-space character.
2769 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2770 <tag/Declaration/<tt/int __fastcall__ isspace (int c);/
2771 <tag/Description/The function returns a non zero value if the given argument
2772 is a white space character. The return value is zero if the character is
2773 anything else. The standard white space characters are: space, formfeed ('\f'),
2774 newline ('\n'), carriage return ('\r'), horizontal tab ('\t'), and vertical tab
2776 <tag/Limits/<itemize>
2777 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2778 inline sequence generated by the macro will not work correctly for values
2779 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2780 this range. The non inline function may be accessed by <tt/#undef/'ing the
2782 <item>When compiling without <tt/-Os/, the function is only available as
2783 fastcall function, so it may only be used in presence of a prototype.
2785 <tag/Availability/ISO 9899
2787 <ref id="isalnum" name="isalnum">,
2788 <ref id="isalpha" name="isalpha">,
2789 <ref id="isascii" name="isascii">,
2790 <ref id="isblank" name="isblank">,
2791 <ref id="iscntrl" name="iscntrl">,
2792 <ref id="isdigit" name="isdigit">,
2793 <ref id="isgraph" name="isgraph">,
2794 <ref id="islower" name="islower">,
2795 <ref id="isprint" name="isprint">,
2796 <ref id="ispunct" name="ispunct">,
2797 <ref id="isupper" name="isupper">,
2798 <ref id="isxdigit" name="isxdigit">
2804 <sect1>isupper<label id="isupper"><p>
2808 <tag/Function/Check if a given character is an upper case letter.
2809 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2810 <tag/Declaration/<tt/int __fastcall__ isupper (int c);/
2811 <tag/Description/The function returns a non zero value if the given argument
2812 is an upper case letter. The return value is zero if the character is anything
2814 <tag/Limits/<itemize>
2815 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2816 inline sequence generated by the macro will not work correctly for values
2817 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2818 this range. The non inline function may be accessed by <tt/#undef/'ing the
2820 <item>When compiling without <tt/-Os/, the function is only available as
2821 fastcall function, so it may only be used in presence of a prototype.
2823 <tag/Availability/ISO 9899
2825 <ref id="isalnum" name="isalnum">,
2826 <ref id="isalpha" name="isalpha">,
2827 <ref id="isascii" name="isascii">,
2828 <ref id="isblank" name="isblank">,
2829 <ref id="iscntrl" name="iscntrl">,
2830 <ref id="isdigit" name="isdigit">,
2831 <ref id="isgraph" name="isgraph">,
2832 <ref id="islower" name="islower">,
2833 <ref id="isprint" name="isprint">,
2834 <ref id="ispunct" name="ispunct">,
2835 <ref id="isspace" name="isspace">,
2836 <ref id="isxdigit" name="isxdigit">
2842 <sect1>isxdigit<label id="isxdigit"><p>
2846 <tag/Function/Check if a given character is a hexadecimal digit.
2847 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2848 <tag/Declaration/<tt/int __fastcall__ isxdigit (int c);/
2849 <tag/Description/The function returns a non zero value if the given argument
2850 is a hexadecimal digit (0..9, a..f and A..F). The return value is zero if the
2851 character is anything else.
2852 <tag/Limits/<itemize>
2853 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2854 inline sequence generated by the macro will not work correctly for values
2855 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2856 this range. The non inline function may be accessed by <tt/#undef/'ing the
2858 <item>When compiling without <tt/-Os/, the function is only available as
2859 fastcall function, so it may only be used in presence of a prototype.
2861 <tag/Availability/ISO 9899
2863 <ref id="isalnum" name="isalnum">,
2864 <ref id="isalpha" name="isalpha">,
2865 <ref id="isascii" name="isascii">,
2866 <ref id="isblank" name="isblank">,
2867 <ref id="iscntrl" name="iscntrl">,
2868 <ref id="isdigit" name="isdigit">,
2869 <ref id="isgraph" name="isgraph">,
2870 <ref id="islower" name="islower">,
2871 <ref id="isprint" name="isprint">,
2872 <ref id="ispunct" name="ispunct">,
2873 <ref id="isspace" name="isspace">,
2874 <ref id="isupper" name="isupper">
2880 <sect1>itoa<label id="itoa"><p>
2884 <tag/Function/Convert an integer into a string.
2885 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
2886 <tag/Declaration/<tt/char* __fastcall__ itoa (int val, char* buf, int radix);/
2887 <tag/Description/<tt/itoa/ converts the integer <tt/val/ into a string using
2888 <tt/radix/ as the base.
2889 <tag/Limits/<itemize>
2890 <item>There are no provisions to prevent a buffer overflow.
2891 <item>If <tt/val/ contains <tt/INT_MIN/, the behaviour is undefined.
2892 <item>The function is non standard, so it is not available in strict ANSI mode.
2893 You should probably use <tt/sprintf/ instead.
2894 <item>The function is only available as fastcall function, so it may only be
2895 used in presence of a prototype.
2897 <tag/Availability/cc65
2899 <ref id="atoi" name="atoi">,
2900 <ref id="atol" name="atol">,
2901 <ref id="ltoa" name="ltoa">,
2902 <ref id="ultoa" name="ultoa">,
2903 <ref id="utoa" name="utoa">
2909 <sect1>joy_count<label id="joy_count"><p>
2913 <tag/Function/Return the number of joysticks supported by the current driver.
2914 <tag/Header/<tt/<ref id="joystick.h" name="joystick.h">/
2915 <tag/Declaration/<tt/unsigned char __fastcall__ joy_count (void);/
2916 <tag/Description/The function returns a the number of joysticks supported
2917 by the current joystick driver.
2918 <tag/Limits/<itemize>
2919 <item>A joystick driver must be loaded using <ref id="joy_load_driver"
2920 name="joy_load_driver"> before calling this function.
2921 <item>The function returns the number of joysticks supported by the driver.
2922 There's no way to check for the number of actually connected joysticks.
2923 <item>The function is only available as fastcall function, so it may only be
2924 used in presence of a prototype.
2926 <tag/Availability/cc65
2928 <ref id="joy_load_driver" name="joy_load_driver">,
2929 <ref id="joy_read" name="joy_read">
2935 <sect1>joy_install<label id="joy_install"><p>
2939 <tag/Function/Install an already loaded driver and return an error code.
2940 <tag/Header/<tt/<ref id="joystick.h" name="joystick.h">/
2941 <tag/Declaration/<tt/unsigned char __fastcall__ joy_install (void* driver);/
2942 <tag/Description/The function installs a driver that was already loaded into
2943 memory (or linked statically to the program). It returns an error code
2944 (<tt/JOY_ERR_OK/ in case of success).
2945 <tag/Limits/<itemize>
2946 <item>The function is only available as fastcall function, so it may only be
2947 used in presence of a prototype.
2949 <tag/Availability/cc65
2951 <ref id="joy_load_driver" name="joy_load_driver">,
2952 <ref id="joy_uninstall" name="joy_uninstall">,
2953 <ref id="joy_unload" name="joy_unload">
2959 <sect1>joy_load_driver<label id="joy_load_driver"><p>
2963 <tag/Function/Load a driver from disk and install it.
2964 <tag/Header/<tt/<ref id="joystick.h" name="joystick.h">/
2965 <tag/Declaration/<tt/unsigned char __fastcall__ joy_load_driver (const char* driver);/
2966 <tag/Description/The function loads a driver with the given name from disk
2967 and installs it. An error code is returned, which is <tt/JOY_ERR_OK/ if the
2968 driver was successfully loaded and installed.
2969 <tag/Limits/<itemize>
2970 <item>The function is only available as fastcall function, so it may only be
2971 used in presence of a prototype.
2973 <tag/Availability/cc65
2975 <ref id="joy_install" name="joy_install">,
2976 <ref id="joy_uninstall" name="joy_uninstall">,
2977 <ref id="joy_unload" name="joy_unload">
2983 <sect1>joy_read<label id="joy_read"><p>
2987 <tag/Function/Read the status of a joystick.
2988 <tag/Header/<tt/<ref id="joystick.h" name="joystick.h">/
2989 <tag/Declaration/<tt/unsigned char __fastcall__ joy_read (unsigned char joystick);/
2990 <tag/Description/The function reads the status bits for a joystick. The number
2991 of the joystick is passed as parameter. The result may be examined by using one
2992 of the <tt/JOY_xxx/ macros from <ref id="joystick.h" name="joystick.h">.
2993 <tag/Limits/<itemize>
2994 <item>A joystick driver must be loaded using <ref id="joy_load_driver"
2995 name="joy_load_driver"> before calling this function.
2996 <item>The function is only available as fastcall function, so it may only be
2997 used in presence of a prototype.
2999 <tag/Availability/cc65
3001 <ref id="joy_count" name="joy_count">,
3002 <ref id="joy_load_driver" name="joy_load_driver">,
3003 <ref id="joy_unload" name="joy_unload">
3009 <sect1>joy_uninstall<label id="joy_uninstall"><p>
3013 <tag/Function/Uninstall the current joystick driver.
3014 <tag/Header/<tt/<ref id="joystick.h" name="joystick.h">/
3015 <tag/Declaration/<tt/unsigned char __fastcall__ joy_uninstall (void);/
3016 <tag/Description/The function uninstalls the currently installed joystick
3017 driver. It does not remove the driver from memory. The function returns an
3018 error code, which is <tt/JOY_ERR_OK/ if the driver was successfully uninstalled.
3019 <tag/Limits/<itemize>
3020 <item>A joystick driver must be installed using <ref id="joy_install"
3021 name="joy_install"> before calling this function.
3022 <item>The function is only available as fastcall function, so it may only be
3023 used in presence of a prototype.
3025 <tag/Availability/cc65
3027 <ref id="joy_install" name="joy_install">,
3028 <ref id="joy_load_driver" name="joy_load_driver">,
3029 <ref id="joy_unload" name="joy_unload">
3035 <sect1>joy_unload<label id="joy_unload"><p>
3039 <tag/Function/Uninstall, then unload the current joystick driver.
3040 <tag/Header/<tt/<ref id="joystick.h" name="joystick.h">/
3041 <tag/Declaration/<tt/unsigned char __fastcall__ joy_unload (void);/
3042 <tag/Description/The function uninstalls the currently installed joystick
3043 driver and removes it from memory. An error code is returned, which is
3044 <tt/JOY_ERR_OK/ if the driver was successfully uninstalled.
3045 <tag/Limits/<itemize>
3046 <item>A joystick driver must be loaded using <ref id="joy_load_driver"
3047 name="joy_load_driver"> before calling this function.
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="joy_load_driver" name="joy_load_driver">
3059 <sect1>kbhit<label id="kbhit"><p>
3063 <tag/Function/Check if there's a key waiting in the keyboard buffer.
3064 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
3065 <tag/Declaration/<tt/unsigned char kbhit (void);/
3066 <tag/Description/The function returns a value of zero if there is no character
3067 waiting to be read from the keyboard. It returns non zero otherwise.
3068 <tag/Limits/<itemize>
3069 <item>If the system does not support a keyboard buffer (most systems
3070 do), the function is rather useless.
3072 <tag/Availability/cc65
3074 <ref id="cgetc" name="cgetc">,
3075 <ref id="cursor" name="cursor">
3081 <sect1>labs<label id="labs"><p>
3085 <tag/Function/Returns the absolute value of a long integer.
3086 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
3087 <tag/Declaration/<tt/long __fastcall__ labs (long v);/
3088 <tag/Description/<tt/labs/ returns the absolute value of the argument passed to
3090 <tag/Limits/<itemize>
3091 <item>The return value is undefined if <tt/LONG_MIN/ is passed to the function.
3092 <item>The function is only available as fastcall function, so it may only be
3093 used in presence of a prototype.
3095 <tag/Availability/ISO 9899
3097 <ref id="abs" name="abs">
3103 <sect1>ltoa<label id="ltoa"><p>
3107 <tag/Function/Convert a long integer into a string.
3108 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
3109 <tag/Declaration/<tt/char* __fastcall__ ltoa (long val, char* buf, int radix);/
3110 <tag/Description/<tt/itoa/ converts the long integer <tt/val/ into a string
3111 using <tt/radix/ as the base.
3112 <tag/Limits/<itemize>
3113 <item>There are no provisions to prevent a buffer overflow.
3114 <item>If <tt/val/ contains <tt/LONG_MIN/, the behaviour is undefined.
3115 <item>The function is non standard, so it is not available in strict ANSI mode.
3116 You should probably use <tt/sprintf/ instead.
3117 <item>The function is only available as fastcall function, so it may only be
3118 used in presence of a prototype.
3120 <tag/Availability/cc65
3122 <ref id="atoi" name="atoi">,
3123 <ref id="atol" name="atol">,
3124 <ref id="itoa" name="itoa">,
3125 <ref id="ultoa" name="ultoa">,
3126 <ref id="utoa" name="utoa">
3132 <sect1>localeconv<label id="localeconv"><p>
3136 <tag/Function/Returns a pointer to the current locale structure.
3137 <tag/Header/<tt/<ref id="locale.h" name="locale.h">/
3138 <tag/Declaration/<tt/struct lconv* localeconv (void);/
3139 <tag/Description/<tt/localeconv/ returns a pointer to the current locale
3141 <tag/Limits/<itemize>
3142 <item>cc65 supports only the "C" locale, so even after setting a new locale
3143 using <tt/<ref id="setlocale" name="setlocale">/, the structure returned will
3146 <tag/Availability/ISO 9899
3148 <ref id="setlocale" name="setlocale">
3154 <sect1>longjmp<label id="longjmp"><p>
3158 <tag/Function/Non local goto.
3159 <tag/Header/<tt/<ref id="setjmp.h" name="setjmp.h">/
3160 <tag/Declaration/<tt/void __fastcall__ longjmp (jmp_buf buf, int retval);/
3161 <tag/Description/The <tt/longjmp/ function restores a program context from the
3162 data in <tt/buf/, which must have been set by a preceeding call to
3163 <tt/<ref id="setjmp" name="setjmp">/. Program execution continues as if the
3164 call to <tt/<ref id="setjmp" name="setjmp">/ has just returned the value
3168 <item>If the parameter <tt/retval/ is zero, the function will behave as if it
3169 was called with a value of one.
3170 <item>The function is only available as fastcall function, so it may only
3171 be used in presence of a prototype.
3173 <tag/Availability/ISO 9899
3175 <ref id="setjmp" name="setjmp">
3181 <sect1>malloc<label id="malloc"><p>
3185 <tag/Function/Allocate dynamic memory.
3186 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
3187 <tag/Declaration/<tt/void* __fastcall__ malloc (size_t size);/
3188 <tag/Description/<tt/malloc/ allocates size bytes on the heap and returns a
3189 pointer to the allocated memory block. On error (not enough memory available),
3190 <tt/malloc/ returns <tt/NULL/.
3193 <item>The function is only available as fastcall function, so it may only
3194 be used in presence of a prototype.
3196 <tag/Availability/ISO 9899
3198 <ref id="_heapadd" name="_heapadd">,
3199 <ref id="_heapblocksize" name="_heapblocksize">,
3200 <ref id="_heapmaxavail" name="_heapmaxavail">,
3201 <ref id="_heapmemavail" name="_heapmemavail">,
3202 <ref id="calloc" name="calloc">,
3203 <ref id="free" name="free">,
3204 <ref id="realloc" name="realloc">,
3205 <ref id="strdup" name="strdup">
3211 <sect1>memchr<label id="memchr"><p>
3215 <tag/Function/Search for a character in a block of raw memory.
3216 <tag/Header/<tt/<ref id="string.h" name="string.h">/
3217 <tag/Declaration/<tt/void* __fastcall__ strchr (const void* mem, int c, size_t count);/
3218 <tag/Description/The <tt/memchr/ function locates the first occurrence of <tt/c/
3219 (converted to a char) in the block of raw memory string pointed to by <tt/mem/
3220 that is of size <tt/count/. Upon completion, the function returns a pointer to
3221 the character found, or a null pointer if the character was not found.
3222 <tag/Limits/<itemize>
3223 <item>The function is only available as fastcall function, so it may only
3224 be used in presence of a prototype.
3226 <tag/Availability/ISO 9899
3228 <ref id="strchr" name="strchr">
3234 <sect1>memcpy<label id="memcpy"><p>
3238 <tag/Function/Copy a memory area.
3239 <tag/Header/<tt/<ref id="string.h" name="string.h">/
3240 <tag/Declaration/<tt/void* __fastcall__ memcpy (void* dest, const void* src, size_t count);/
3241 <tag/Description/<tt/memcpy/ copies <tt/count/ bytes from the memory area
3242 pointed to by <tt/src/ into the memory area pointed to by <tt/dest/. It returns
3246 <item>The result is undefined if the memory areas do overlap. Use
3247 <tt/<ref id="memmove" name="memmove">/ to copy overlapping memory areas.
3248 <item>The function is only available as fastcall function, so it may only
3249 be used in presence of a prototype.
3251 <tag/Availability/ISO 9899
3253 <ref id="_swap" name="_swap">,
3254 <ref id="memmove" name="memmove">,
3255 <ref id="memset" name="memset">
3261 <sect1>memmove<label id="memmove"><p>
3265 <tag/Function/Copy a memory area.
3266 <tag/Header/<tt/<ref id="string.h" name="string.h">/
3267 <tag/Declaration/<tt/void* __fastcall__ memmove (void* dest, const void* src, size_t count);/
3268 <tag/Description/<tt/memmove/ copies <tt/count/ bytes from the memory area
3269 pointed to by <tt/src/ into the memory area pointed to by <tt/dest/. It returns
3273 <item>While <tt/memmove/ allows the memory areas to overlap, it has some
3274 additional overhead compared to <tt/<ref id="memcpy" name="memcpy">/.
3275 <item>The function is only available as fastcall function, so it may only
3276 be used in presence of a prototype.
3278 <tag/Availability/ISO 9899
3280 <ref id="_swap" name="_swap">,
3281 <ref id="memcpy" name="memcpy">,
3282 <ref id="memset" name="memset">
3288 <sect1>memset<label id="memset"><p>
3292 <tag/Function/Fill a memory area.
3293 <tag/Header/<tt/<ref id="string.h" name="string.h">/
3294 <tag/Declaration/<tt/void* __fastcall__ memset (void* p, int val, size_t count);/
3295 <tag/Description/<tt/memset/ fills the memory area pointed to by <tt/p/ with
3296 the value <tt/val/. The function returns <tt/p/.
3299 <item>The function is only available as fastcall function, so it may only
3300 be used in presence of a prototype.
3302 <tag/Availability/ISO 9899
3304 <ref id="_swap" name="_swap">,
3305 <ref id="bzero" name="bzero">,
3306 <ref id="memcpy" name="memcpy">,
3307 <ref id="memmove" name="memmove">
3313 <sect1>mod_free<label id="mod_free"><p>
3317 <tag/Function/Free a relocatable module.
3318 <tag/Header/<tt/<ref id="modload.h" name="modload.h">/
3319 <tag/Declaration/<tt/void __fastcall__ mod_free (void* module);/
3320 <tag/Description/The function will free a module loaded into memory by use of
3321 the <tt/<ref id="mod_load" name="mod_load">/ function.
3322 <tag/Limits/<itemize>
3323 <item>The pointer passed as parameter is the pointer to the module memory,
3324 not the pointer to the control structure.
3326 <tag/Availability/cc65
3328 <ref id="mod_load" name="mod_load">
3334 <sect1>mod_load<label id="mod_load"><p>
3338 <tag/Function/Load a relocatable module.
3339 <tag/Header/<tt/<ref id="modload.h" name="modload.h">/
3340 <tag/Declaration/<tt/unsigned char mod_load (struct mod_ctrl* ctrl);/
3341 <tag/Description/The function will load a code module into memory and relocate
3342 it. The function will return an error code. If <tt/MLOAD_OK/ is returned, the
3343 outgoing fields in the passed <tt/mod_ctrl/ struct contain information about
3344 the module just loaded. Possible error codes are:
3346 <item><tt/MLOAD_OK/ - Module load successful
3347 <item><tt/MLOAD_ERR_READ/ - Read error
3348 <item><tt/MLOAD_ERR_HDR/ - Header error
3349 <item><tt/MLOAD_ERR_OS/ - Wrong operating system
3350 <item><tt/MLOAD_ERR_FMT/ - Data format error
3351 <item><tt/MLOAD_ERR_MEM/ - Not enough memory
3353 <tag/Limits/<itemize>
3354 <item>The <htmlurl url="ld65.html" name="ld65"> linker is needed to create
3355 relocatable o65 modules for use with this function.
3357 <tag/Availability/cc65
3359 <ref id="mod_free" name="mod_free">
3365 <sect1>mouse_setbox<label id="mouse_setbox"><p>
3369 <tag/Function/Specify a bounding box for the mouse cursor.
3370 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3371 <tag/Declaration/<tt/void __fastcall__ mouse_setbox (const struct mouse_box* box);/
3372 <tag/Description/The function allows to set a bounding box for mouse movement.
3373 <tag/Limits/<itemize>
3374 <item>The function does not check if the mouse cursor is currently within the
3375 given rectangle. Placing the mouse cursor within the bounding box is the
3376 responsibility of the programmer.
3377 <item>While the bounding box may be larger than the actual screen size, the
3378 standard mouse cursor draw routines may fail to set the cursor to coordinates
3379 outside of the screen area. Depending on the platform, you may have to supply
3380 your own mouse cursor routines.
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_getbox" name="mouse_getbox">,
3387 <ref id="mouse_move" name="mouse_move">
3393 <sect1>mouse_getbox<label id="mouse_getbox"><p>
3397 <tag/Function/Return the current bounding box for the mouse cursor.
3398 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3399 <tag/Declaration/<tt/void __fastcall__ mouse_getbox (struct mouse_box* box);/
3400 <tag/Description/The function queries the current bounding box for mouse
3402 <tag/Limits/<itemize>
3403 <item>The function is only available as fastcall function, so it may only be
3404 used in presence of a prototype.
3406 <tag/Availability/cc65
3408 <ref id="mouse_move" name="mouse_move">,
3409 <ref id="mouse_setbox" name="mouse_setbox">
3415 <sect1>mouse_buttons<label id="mouse_buttons"><p>
3419 <tag/Function/Return a bit mask encoding the state of the mouse buttons.
3420 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3421 <tag/Declaration/<tt/unsigned char __fastcall__ mouse_buttons (void);/
3422 <tag/Description/The function returns a bit mask that encodes the state of the
3423 mouse buttons. You may use the <tt/MOUSE_BTN_XXX/ flags to decode the function
3425 <tag/Limits/<itemize>
3426 <item>The function is only available as fastcall function, so it may only be
3427 used in presence of a prototype.
3429 <tag/Availability/cc65
3431 <ref id="mouse_info" name="mouse_info">,
3432 <ref id="mouse_pos" name="mouse_pos">
3438 <sect1>mouse_geterrormsg<label id="mouse_geterrormsg"><p>
3442 <tag/Function/Return a readable error message for an error code.
3443 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3444 <tag/Declaration/<tt/const char* __fastcall__ mouse_geterrormsg (unsigned char
3446 <tag/Description/The function returns an error message (in english) for the
3447 error code passed parameter.
3448 <tag/Limits/<itemize>
3449 <item>The function will return "Unknown error" for invalid error codes.
3450 <item>The function is only available as fastcall function, so it may only be
3451 used in presence of a prototype.
3453 <tag/Availability/cc65
3455 <ref id="mouse_load_driver" name="mouse_load_driver">,
3456 <ref id="mouse_uninstall" name="mouse_uninstall">,
3457 <ref id="mouse_unload" name="mouse_unload">
3463 <sect1>mouse_hide<label id="mouse_hide"><p>
3467 <tag/Function/Hide the mouse pointer.
3468 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3469 <tag/Declaration/<tt/void __fastcall__ mouse_hide (void);/
3470 <tag/Description/The function hides the mouse pointer. It manages a counter
3471 that is shared between <tt/<ref id="mouse_show" name="mouse_show">/ and
3472 <tt/mouse_hide/ so that every call call to <tt/mouse_hide/ must be followed by
3473 a call to <tt/<ref id="mouse_show" name="mouse_show">/ to make the mouse cursor
3475 <tag/Limits/<itemize>
3476 <item>The function is only available as fastcall function, so it may only be
3477 used in presence of a prototype.
3479 <tag/Availability/cc65
3481 <ref id="mouse_show" name="mouse_show">
3487 <sect1>mouse_info<label id="mouse_info"><p>
3491 <tag/Function/Return the state of the mouse buttons and the position of the
3493 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3494 <tag/Declaration/<tt/void __fastcall__ mouse_info (struct mouse_info* info);/
3495 <tag/Description/The function returns the state of the mouse buttons and the
3496 position of the mouse in the <tt/mouse_info/ structure passed as parameter.
3497 <tag/Limits/<itemize>
3498 <item>The <tt/mouse_info/ struct is a superset of the <tt/mouse_pos/ struct,
3499 so if you just need the mouse position, call <tt/<ref id="mouse_pos"
3500 name="mouse_pos">/ instead.
3501 <item>The function is only available as fastcall function, so it may only be
3502 used in presence of a prototype.
3504 <tag/Availability/cc65
3506 <ref id="mouse_buttons" name="mouse_buttons">,
3507 <ref id="mouse_pos" name="mouse_pos">
3513 <sect1>mouse_install<label id="mouse_install"><p>
3517 <tag/Function/Install an already loaded mouse driver.
3518 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3519 <tag/Declaration/<tt/unsigned char __fastcall__ mouse_install (const struct
3520 mouse_callbacks* c, void* driver);/
3521 <tag/Description/The function installs an already loaded mouse driver and
3522 returns an error code. The <tt/mouse_callbacks/ structure passed as first
3523 parameter contains pointers to routines needed to move or hide/show the mouse
3524 pointer. Defaults for these routines are supplied by the library, so if you
3525 can live with these defaults (which are platform specific), just pass a
3526 pointer to <tt/mouse_def_callbacks/. The function may be used to install a
3527 driver linked statically to the program.
3528 <tag/Limits/<itemize>
3529 <item>Not all drivers are able to detect if the supported hardware is really
3531 <item>After installing a driver, the mouse cursor is hidden.
3532 <item>The function is only available as fastcall function, so it may only be
3533 used in presence of a prototype.
3535 <tag/Availability/cc65
3537 <ref id="mouse_load_driver" name="mouse_load_driver">,
3538 <ref id="mouse_uninstall" name="mouse_uninstall">,
3539 <ref id="mouse_unload" name="mouse_unload">
3545 <sect1>mouse_ioctl<label id="mouse_ioctl"><p>
3549 <tag/Function/Call the driver specific ioctl function.
3550 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3551 <tag/Declaration/<tt/unsigned char __fastcall__ mouse_ioctl (unsigned char code, void* data);/
3552 <tag/Description/The function calls the IOCTL entry in the mouse driver,
3553 which is driver specific. The <tt/code/ parameter will choose between
3554 different IOCTL functions, and the <tt/data/ depends on code. The
3555 function returns an error code. The purpose of this function is to allow
3556 for driver specific extensions. See the documentation for a specific mouse
3557 driver for supported ioctl calls.
3558 <tag/Limits/<itemize>
3559 <item>Calling this function is non portable, because each driver may
3560 implement different ioctl calls (or none at all).
3561 <item>The function is only available as fastcall function, so it may only be
3562 used in presence of a prototype.
3564 <tag/Availability/cc65
3570 <sect1>mouse_load_driver<label id="mouse_load_driver"><p>
3574 <tag/Function/Load and initialize a mouse driver.
3575 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3576 <tag/Declaration/<tt/unsigned char __fastcall__ mouse_load_driver (const struct
3577 mouse_callbacks* c, const char* driver);/
3578 <tag/Description/Load a mouse driver into memory and initialize it. The
3579 function returns an error code that tells if the call has been successful. The
3580 <tt/mouse_callbacks/ structure passed as first parameter contains pointers to
3581 routines needed to move or hide/show the mouse pointer. Defaults for these
3582 routines are supplied by the library, so if you can live with these defaults
3583 (which are platform specific), just pass a pointer to <tt/mouse_def_callbacks/.
3584 <tag/Limits/<itemize>
3585 <item>The driver is loaded by name, so currently you must know the type of
3586 mouse that should be supported. There is no autodetect capability.
3587 <item>Not all drivers are able to detect if the supported hardware is really
3589 <item>After installing a driver, the mouse cursor is hidden.
3590 <item>The function is only available as fastcall function, so it may only be
3591 used in presence of a prototype.
3593 <tag/Availability/cc65
3595 <ref id="mouse_install" name="mouse_install">,
3596 <ref id="mouse_uninstall" name="mouse_uninstall">,
3597 <ref id="mouse_unload" name="mouse_unload">
3603 <sect1>mouse_move<label id="mouse_move"><p>
3607 <tag/Function/Move the mouse cursor to a specific position.
3608 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3609 <tag/Declaration/<tt/void __fastcall__ mouse_move (int x, int y);/
3610 <tag/Description/The function updates the mouse position. If the mouse cursor
3611 is visible, it is shown at the new position.
3612 <tag/Limits/<itemize>
3613 <item>The function does not check if the new position is within the bounding
3614 box specified with <tt/<ref id="mouse_setbox" name="mouse_setbox">/.
3615 <item>The function is only available as fastcall function, so it may only be
3616 used in presence of a prototype.
3618 <tag/Availability/cc65
3620 <ref id="mouse_getbox" name="mouse_getbox">,
3621 <ref id="mouse_setbox" name="mouse_setbox">
3627 <sect1>mouse_pos<label id="mouse_pos"><p>
3631 <tag/Function/Return the position of the mouse.
3632 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3633 <tag/Declaration/<tt/void __fastcall__ mouse_pos (struct mouse_pos* pos);/
3634 <tag/Description/The function returns the position of the mouse in the
3635 <tt/mouse_pos/ structure passed as parameter.
3636 <tag/Limits/<itemize>
3637 <item>The <tt/mouse_pos/ struct is a subset of the <tt/mouse_info/ struct,
3638 so if you do also need the mouse buttons, call <tt/<ref id="mouse_info"
3639 name="mouse_info">/ instead.
3640 <item>The function is only available as fastcall function, so it may only be
3641 used in presence of a prototype.
3643 <tag/Availability/cc65
3645 <ref id="mouse_buttons" name="mouse_buttons">,
3646 <ref id="mouse_info" name="mouse_info">
3652 <sect1>mouse_show<label id="mouse_show"><p>
3656 <tag/Function/Show the mouse pointer.
3657 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3658 <tag/Declaration/<tt/void __fastcall__ mouse_show (void);/
3659 <tag/Description/The function shows the mouse pointer. It manages a counter
3660 that is shared between <tt/<ref id="mouse_hide" name="mouse_hide">/ and
3661 <tt/mouse_show/. The mouse cursor is visible if there was one more call to
3662 <tt/mouse_show/ than to <tt/<ref id="mouse_hide" name="mouse_hide">/.
3663 <tag/Limits/<itemize>
3664 <item>The function is only available as fastcall function, so it may only be
3665 used in presence of a prototype.
3667 <tag/Availability/cc65
3669 <ref id="mouse_hide" name="mouse_hide">
3675 <sect1>mouse_uninstall<label id="mouse_uninstall"><p>
3679 <tag/Function/Uninstall an already loaded mouse driver.
3680 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3681 <tag/Declaration/<tt/unsigned char __fastcall__ mouse_install (void);/
3682 <tag/Description/The function uninstalls an already loaded mouse driver but
3683 don't removes it from memory.
3684 <tag/Limits/<itemize>
3685 <item>If the driver has been loaded using <tt/<ref id="mouse_load_driver"
3686 name="mouse_load_driver">/, <tt/<ref id="mouse_unload" name="mouse_unload">/
3687 should be used instead of <tt/mouse_uninstall/ so the driver is also removed
3689 <item>The function is only available as fastcall function, so it may only be
3690 used in presence of a prototype.
3692 <tag/Availability/cc65
3694 <ref id="mouse_install" name="mouse_install">,
3695 <ref id="mouse_load_driver" name="mouse_load_driver">,
3696 <ref id="mouse_unload" name="mouse_unload">
3702 <sect1>mouse_unload<label id="mouse_unload"><p>
3706 <tag/Function/Unload a mouse driver.
3707 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3708 <tag/Declaration/<tt/unsigned char __fastcall__ mouse_unload (void);/
3709 <tag/Description/The function unloads a loaded mouse driver and frees all
3710 memory allocated for the driver.
3711 <tag/Limits/<itemize>
3712 <item>The function does nothing if no driver is loaded.
3714 <tag/Availability/cc65
3716 <ref id="mouse_install" name="mouse_install">,
3717 <ref id="mouse_load_driver" name="mouse_load_driver">,
3718 <ref id="mouse_uninstall" name="mouse_uninstall">
3724 <sect1>offsetof<label id="offsetof"><p>
3728 <tag/Function/Calculate the offset of a struct or union member.
3729 <tag/Header/<tt/<ref id="stddef.h" name="stddef.h">/
3730 <tag/Declaration/<tt/size_t offsetof (type, member);/
3731 <tag/Description/<tt/offsetof/ calculates the address offset of a <tt/struct/
3732 or <tt/union/ member.
3733 <tag/Limits/<itemize>
3734 <item>The function is actually a macro.
3736 <tag/Availability/ISO 9899
3742 <sect1>open<label id="open"><p>
3746 <tag/Function/Open and possibly create a file.
3747 <tag/Header/<tt/<ref id="fcntl.h" name="fcntl.h">/
3748 <tag/Declaration/<tt/int open (const char* name, int flags, ...);/
3749 <tag/Description/<tt/open/ opens a file and returns the file descriptor
3750 associated with it. On error, -1 is returned and an error code is stored in
3751 <tt/errno/. Several flags may be passed to <tt/open/ that change the behaviour.
3752 <tag/Limits/<itemize>
3753 <item>POSIX specifies an additional <tt/mode/ argument that may be passed to
3754 open, which is used as the permission mask when a new file is created. While
3755 cc65 allows to pass this argument, it is ignored.
3757 <tag/Availability/POSIX 1003.1
3759 <ref id="close" name="close">,
3760 <ref id="creat" name="creat">
3766 <sect1>peekbsys<label id="peekbsys"><p>
3770 <tag/Function/Read one byte from a location in the system bank.
3771 <tag/Header/<tt/<ref id="cbm610.h" name="cbm610.h">/,
3772 <tt/<ref id="cbm510.h" name="cbm510.h">/
3773 <tag/Declaration/<tt/unsigned char __fastcall__ peekbsys (unsigned addr);/
3774 <tag/Description/<tt/peekbsys/ reads one byte from the given address in the
3775 system bank (bank 15) of the CBM PET-II machines and returns it.
3778 <item>The function is only available as fastcall function, so it may only
3779 be used in presence of a prototype.
3780 <item>This function may be a macro depending on the compiler options. The
3781 actual function is accessible by #undef'ing the macro.
3783 <tag/Availability/cc65
3785 <ref id="PEEK" name="PEEK">,
3786 <ref id="PEEKW" name="PEEKW">,
3787 <ref id="peekwsys" name="peekwsys">,
3788 <ref id="pokebsys" name="pokebsys">,
3789 <ref id="pokewsys" name="pokewsys">
3795 <sect1>peekwsys<label id="peekwsys"><p>
3799 <tag/Function/Read one word from a location in the system bank.
3800 <tag/Header/<tt/<ref id="cbm610.h" name="cbm610.h">/,
3801 <tt/<ref id="cbm510.h" name="cbm510.h">/
3802 <tag/Declaration/<tt/unsigned __fastcall__ peekwsys (unsigned addr);/
3803 <tag/Description/<tt/peekwsys/ reads one word from the given address in the
3804 system bank (bank 15) of the CBM PET-II machines and returns it. Following
3805 the usual 6502 conventions, the low byte is read from <tt/addr/, and the
3806 high byte is read from <tt/addr+1/.
3809 <item>The function is only available as fastcall function, so it may only
3810 be used in presence of a prototype.
3811 <item>The order in which the two bytes are read is undefined.
3813 <tag/Availability/cc65
3815 <ref id="PEEK" name="PEEK">,
3816 <ref id="PEEKW" name="PEEKW">,
3817 <ref id="peekbsys" name="peekbsys">,
3818 <ref id="pokebsys" name="pokebsys">,
3819 <ref id="pokewsys" name="pokewsys">
3825 <sect1>perror<label id="perror"><p>
3829 <tag/Function/Print an error message for the error in <tt/errno/.
3830 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
3831 <tag/Declaration/<tt/void __fastcall__ perror (const char* s);/
3832 <tag/Description/<tt/perror/ prints an error message to <tt/stderr/. If <tt/s/
3833 is not <tt/NULL/ and not an empty string, it is printed followed by a colon and
3834 a blank. Then the error message for the current contents of <tt/errno/ is
3835 printed followed by a newline. The message output is the same as returned by
3836 <tt/<ref id="strerror" name="strerror">/ with an argument of <tt/errno/.
3839 <item>The function is only available as fastcall function, so it may only
3840 be used in presence of a prototype.
3842 <tag/Availability/ISO 9899
3844 <ref id="_poserror" name="_poserror">,
3845 <ref id="strerror" name="strerror">
3851 <sect1>pokebsys<label id="pokebsys"><p>
3855 <tag/Function/Write one byte to a location in the system bank.
3856 <tag/Header/<tt/<ref id="cbm610.h" name="cbm610.h">/,
3857 <tt/<ref id="cbm510.h" name="cbm510.h">/
3858 <tag/Declaration/<tt/void __fastcall__ pokebsys (unsigned addr, unsigned char val);/
3859 <tag/Description/<tt/pokebsys/ writes one byte to the given address in the
3860 system bank (bank 15) of the CBM PET-II machines.
3863 <item>The function is only available as fastcall function, so it may only
3864 be used in presence of a prototype.
3866 <tag/Availability/cc65
3868 <ref id="POKE" name="POKE">,
3869 <ref id="POKEW" name="POKEW">,
3870 <ref id="peekbsys" name="peekbsys">,
3871 <ref id="peekwsys" name="peekwsys">,
3872 <ref id="pokewsys" name="pokewsys">
3878 <sect1>pokewsys<label id="pokewsys"><p>
3882 <tag/Function/Write one word to a location in the system bank.
3883 <tag/Header/<tt/<ref id="cbm610.h" name="cbm610.h">/,
3884 <tt/<ref id="cbm510.h" name="cbm510.h">/
3885 <tag/Declaration/<tt/void __fastcall__ pokewsys (unsigned addr, unsigned val);/
3886 <tag/Description/<tt/pokewsys/ writes one word to the given address in the
3887 system bank (bank 15) of the CBM PET-II machines. Following the usual 6502
3888 conventions, the low byte of <tt/val/ is written to <tt/addr/, and the
3889 high byte is written to <tt/addr+1/.
3892 <item>The function is only available as fastcall function, so it may only
3893 be used in presence of a prototype.
3894 <item>The order in which the two bytes are written is undefined.
3896 <tag/Availability/cc65
3898 <ref id="POKE" name="POKE">,
3899 <ref id="POKEW" name="POKEW">,
3900 <ref id="peekbsys" name="peekbsys">,
3901 <ref id="peekwsys" name="peekwsys">,
3902 <ref id="pokebsys" name="pokebsys">
3908 <sect1>qsort<label id="qsort"><p>
3912 <tag/Function/Sort an array.
3913 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
3914 <tag/Declaration/<tt/void __fastcall__ qsort (void* base, size_t count,
3915 size_t size, int (*compare) (const void*, const void*));/
3916 <tag/Description/<tt/qsort/ sorts an array according to a given compare
3917 function <tt/compare/. <tt/base/ is the address of the array, <tt/count/
3918 is the number of elements, <tt/size/ the size of an element and <tt/compare/
3919 the function used to compare the members.
3922 <item>If there are multiple members with the same key, the order after calling
3923 the function is undefined.
3924 <item>The function is only available as fastcall function, so it may only
3925 be used in presence of a prototype.
3927 <tag/Availability/ISO 9899
3929 <ref id="bsearch" name="bsearch">
3935 <sect1>raise<label id="raise"><p>
3939 <tag/Function/Send a signal to the executing program.
3940 <tag/Header/<tt/<ref id="signal.h" name="signal.h">/
3941 <tag/Declaration/<tt/int __fastcall__ raise (int sig);/
3942 <tag/Description/<tt/raise/ sends the given signal to the program. If the
3943 program has installed a signal handler for the signal, this signal handler
3944 will be executed. If no handler has been installed, the default action for
3945 the raised signal will be taken. The function returns zero on success,
3947 <tag/Limits/<itemize>
3948 <item>The function is only available as fastcall function, so it may only
3949 be used in presence of a prototype.
3951 <tag/Availability/ISO 9899
3953 <ref id="abort" name="abort">,
3954 <ref id="signal" name="signal">
3960 <sect1>rand<label id="rand"><p>
3964 <tag/Function/Return a pseudo random number.
3965 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
3966 <tag/Declaration/<tt/int rand (void);/
3967 <tag/Description/The function returns a pseudo random number
3968 between 0 and <tt/RAND_MAX/ (exclusive).
3969 <tag/Limits/<itemize>
3970 <item>Without using <tt><ref id="srand" name="srand"></tt>, always the same
3971 flow of numbers is generated.
3972 <item>On startup, the function behaves as if <ref id="srand" name="srand">
3973 had been used with an argument of 1.
3975 <tag/Availability/ISO 9899
3977 <ref id="_randomize" name="_randomize">,
3978 <ref id="srand" name="srand">
3984 <sect1>realloc<label id="realloc"><p>
3988 <tag/Function/Change the size of an allocated memory block.
3989 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
3990 <tag/Declaration/<tt/void* __fastcall__ realloc (void* block, size_t size);/
3991 <tag/Description/<tt/realloc/ changes the size of the memory block pointed to
3992 by <tt/block/ to <tt/size/ bytes. If <tt/block/ is <tt/NULL/, <tt/realloc/
3993 behaves as if <tt/malloc/ had been called. If <tt/size/ is zero, <tt/realloc/
3994 behaves as if <tt/free/ had been called. On error (not enough memory
3995 available), <tt/realloc/ returns <tt/NULL/.
3998 <item>The part of the memory block that is returned will have its contents
4000 <item>This function is somewhat dangerous to use. Be careful to save the
4001 pointer you're passing somewhere else, otherwise
4003 ptr = realloc (ptr, size);
4005 will loose your only copy of <tt/ptr/ if <tt/realloc/ returns <tt/NULL/.
4006 <item>The function is only available as fastcall function, so it may only
4007 be used in presence of a prototype.
4009 <tag/Availability/ISO 9899
4011 <ref id="_heapadd" name="_heapadd">,
4012 <ref id="_heapblocksize" name="_heapblocksize">,
4013 <ref id="_heapmaxavail" name="_heapmaxavail">,
4014 <ref id="_heapmemavail" name="_heapmemavail">,
4015 <ref id="calloc" name="calloc">,
4016 <ref id="free" name="free">,
4017 <ref id="realloc" name="realloc">
4023 <sect1>remove<label id="remove"><p>
4027 <tag/Function/Delete a file.
4028 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
4029 <tag/Declaration/<tt/int __fastcall__ remove (const char* name);/
4030 <tag/Description/<tt/remove/ deletes the file with the given name. On success,
4031 zero is returned. On error, -1 is returned and <tt/errno/ is set to an error
4032 code describing the reason for the failure.
4035 <item>This function is not available on all cc65 targets (depends on the
4036 availability of file I/O).
4037 <item>The function is only available as fastcall function, so it may only
4038 be used in presence of a prototype.
4040 <tag/Availability/ISO 9899
4042 <ref id="rename" name="rename">,
4043 <ref id="unlink" name="unlink">
4046 #include <stdio.h>
4048 #define FILENAME "helloworld"
4050 if (remove (FILENAME) == 0) {
4051 printf ("We deleted %s successfully\n", FILENAME);
4053 printf ("There was a problem deleting %s\n", FILENAME);
4060 <sect1>rename<label id="rename"><p>
4064 <tag/Function/Rename a file.
4065 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
4066 <tag/Declaration/<tt/int __fastcall__ rename (const char* oldname, const char* newname);/
4067 <tag/Description/<tt/rename/ renames a file (gives it a new name). On success,
4068 zero is returned. On error, -1 is returned and <tt/errno/ is set to an error
4069 code describing the reason for the failure.
4072 <item>This function is not available on all cc65 targets (depends on the
4073 capabilities of the storage devices).
4074 <item>The function is only available as fastcall function, so it may only
4075 be used in presence of a prototype.
4077 <tag/Availability/ISO 9899
4079 <ref id="remove" name="remove">
4082 #include <stdio.h>
4084 #define OLDNAME "textfile.txt"
4085 #define NEWNAME "textfile.bak"
4087 if (rename (OLDNAME, NEWNAME) == 0) {
4088 printf ("Renamed %s to %s\n", OLDNAME, NEWNAME);
4090 printf ("Error renaming %s to %s\n", OLDNAME, NEWNAME);
4097 <sect1>reset_brk<label id="reset_brk"><p>
4101 <tag/Function/Resets the break vector to its original value.
4102 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
4103 <tag/Declaration/<tt/void __fastcall__ reset_brk (void);/
4104 <tag/Description/<tt/reset_brk/ resets the break vector to the value it had
4105 before a call to <tt/set_brk/.
4108 <item>Since <tt/<ref id="set_brk" name="set_brk">/ installs an exit handler,
4109 it is not strictly necessary to call this function as part of the cleanup when
4112 <tag/Availability/cc65
4114 <ref id="set_brk" name="set_brk">
4120 <sect1>revers<label id="revers"><p>
4124 <tag/Function/Control revers character display.
4125 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
4126 <tag/Declaration/<tt/unsigned char __fastcall__ revers (unsigned char onoff);/
4127 <tag/Description/If the argument is non zero, the function enables reverse
4128 character display. If the argument is zero, reverse character display is
4129 switched off. The old value of the setting is returned.
4130 <tag/Limits/<itemize>
4131 <item>The function may not be supported by the hardware, in which case
4132 the call is ignored.
4133 <item>The function is only available as fastcall function, so it may only
4134 be used in presence of a prototype.
4136 <tag/Availability/cc65
4138 <ref id="textcolor" name="textcolor">
4144 <sect1>screensize<label id="screensize"><p>
4148 <tag/Function/Return the dimensions of the text mode screen.
4149 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
4150 <tag/Declaration/<tt/void __fastcall__ screensize (unsigned char* x, unsigned char* y);/
4151 <tag/Description/The function returns the dimensions of the text mode screen.
4152 <tag/Limits/<itemize>
4153 <item>The function is only available as fastcall function, so it may only
4154 be used in presence of a prototype.
4156 <tag/Availability/cc65
4158 <ref id="gotox" name="gotox">,
4159 <ref id="gotoxy" name="gotoxy">,
4160 <ref id="gotoy" name="gotoy">,
4161 <ref id="wherex" name="wherex">,
4162 <ref id="wherey" name="wherey">
4168 <sect1>ser_close<label id="ser_close"><p>
4172 <tag/Function/Close the port and disable interrupts
4173 <tag/Header/<tt/<ref id="serial.h" name="serial.h">/
4174 <tag/Declaration/<tt/unsigned char __fastcall__ ser_close (const struct ser_params* params);/
4175 <tag/Description/Open the port by setting the port parameters and enable interrupts.
4176 <tag/Limits/<itemize>
4177 <item>The function is only available as fastcall function, so it may only
4178 be used in presence of a prototype.
4180 <tag/Availability/cc65
4181 <tag/See also/Other serial functions.
4186 extern char comlynx[];
4188 static void initialize(){
4189 struct ser_params params = {
4196 ser_install(&comlynx); // This will activate the ComLynx
4198 ser_open(&params);
4205 <sect1>ser_get<label id="ser_get"><p>
4209 <tag/Function/Read a character from serial port.
4210 <tag/Header/<tt/<ref id="serial.h" name="serial.h">/
4211 <tag/Declaration/<tt/unsigned char __fastcall__ ser_get (char* b);/
4212 <tag/Description/Get a character from the serial port. If no characters are
4213 available, the function will return SER_ERR_NO_DATA, so this is not a fatal
4215 <tag/Limits/<itemize>
4216 <item>The function is only available as fastcall function, so it may only
4217 be used in presence of a prototype.
4219 <tag/Availability/cc65
4220 <tag/See also/Other serial functions.
4222 Wait for a character to be available from a serial port.
4225 while (ser_get(&ch) == SER_ERR_NO_DATA)
4232 <sect1>ser_install<label id="ser_install"><p>
4236 <tag/Function/Install an already loaded driver and return an error code.
4237 <tag/Header/<tt/<ref id="serial.h" name="serial.h">/
4238 <tag/Declaration/<tt/unsigned char __fastcall__ ser_install (void* driver);/
4239 <tag/Description/The function installs a driver that was already loaded into
4240 memory (or linked statically to the program). It returns an error code
4241 (<tt/SER_ERR_OK/ in case of success).
4242 <tag/Limits/<itemize>
4243 <item>The function is only available as fastcall function, so it may only be
4244 used in presence of a prototype.
4246 <tag/Availability/cc65
4248 <ref id="ser_load_driver" name="ser_load_driver">,
4249 <ref id="ser_uninstall" name="ser_uninstall">,
4250 <ref id="ser_unload" name="ser_unload">
4252 extern char lynxser[]; //Include the driver statically instead of loading it.
4254 ser_install(&lynxser);
4260 <sect1>ser_ioctl<label id="ser_ioctl"><p>
4264 <tag/Function/Platform dependent code extensions.
4265 <tag/Header/<tt/<ref id="serial.h" name="serial.h">/
4266 <tag/Declaration/<tt/unsigned __fastcall__ ser_ioctl (unsigned char code, void* data);/
4267 <tag/Description/Some platforms have extra serial functions that are not
4268 supported by standard serial driver functions. You can extend the driver to support
4269 this extra functionality bt using ser_ioctl functions.
4270 <tag/Limits/<itemize>
4271 <item>The function is only available as fastcall function, so it may only
4272 be used in presence of a prototype.
4273 <item>These functions are not easily portable to other cc65 platforms.
4275 <tag/Availability/cc65
4276 <tag/See also/Other serial functions.
4281 <sect1>ser_load_driver<label id="ser_load_driver"><p>
4285 <tag/Function/Load and install a serial driver.
4286 <tag/Header/<tt/<ref id="serial.h" name="serial.h">/
4287 <tag/Declaration/<tt/void __fastcall__ ser_load_driver (const char *name);/
4288 <tag/Description/Load and install the driver by name.
4289 Will just load the driver and check if loading was successul.
4290 <tag/Limits/<itemize>
4291 <item>The function is only available as fastcall function, so it may only
4292 be used in presence of a prototype.
4294 <tag/Availability/cc65
4295 <tag/See also/Other serial functions.
4301 <sect1>ser_open<label id="ser_open"><p>
4305 <tag/Function/Open the port by setting the port parameters and enable interrupts
4306 <tag/Header/<tt/<ref id="serial.h" name="serial.h">/
4307 <tag/Declaration/<tt/unsigned char __fastcall__ ser_open (const struct ser_params* params);/
4308 <tag/Description/Open the port by setting the port parameters and enable interrupts.
4309 <tag/Limits/<itemize>
4310 <item>The function is only available as fastcall function, so it may only
4311 be used in presence of a prototype.
4313 <tag/Availability/cc65
4314 <tag/See also/Other serial functions.
4319 extern char comlynx[];
4321 static void initialize(){
4322 struct ser_params params = {
4329 ser_install(&comlynx); // This will activate the ComLynx
4331 ser_open(&params);
4338 <sect1>ser_put<label id="ser_put"><p>
4342 <tag/Function/Write a character to a serial port.
4343 <tag/Header/<tt/<ref id="serial.h" name="serial.h">/
4344 <tag/Declaration/<tt/unsigned char __fastcall__ ser_put (char b);/
4345 <tag/Description/Send a character via the serial port. There is a transmit
4346 buffer, but transmitting is not done via interrupt. The function returns
4347 SER_ERR_OVERFLOW if there is no space left in the transmit buffer.
4348 <tag/Limits/<itemize>
4349 <item>The function is only available as fastcall function, so it may only
4350 be used in presence of a prototype.
4352 <tag/Availability/cc65
4353 <tag/See also/Other serial functions.
4362 <sect1>ser_status<label id="ser_status"><p>
4366 <tag/Function/Return the serial port status.
4367 <tag/Header/<tt/<ref id="serial.h" name="serial.h">/
4368 <tag/Declaration/<tt/unsigned char __fastcall__ ser_put (unsigned char* status);/
4369 <tag/Description/Return the serial port status.
4370 <tag/Limits/<itemize>
4371 <item>The function is only available as fastcall function, so it may only
4372 be used in presence of a prototype.
4374 <tag/Availability/cc65
4375 <tag/See also/Other serial functions.
4381 <sect1>ser_uninstall<label id="ser_uninstall"><p>
4385 <tag/Function/Uninstall the currently loaded driver but do not unload it.
4386 <tag/Header/<tt/<ref id="serial.h" name="serial.h">/
4387 <tag/Declaration/<tt/void __fastcall__ ser_uninstall (void);/
4388 <tag/Description/Uninstall the currently loaded driver but do not unload it.
4389 <tag/Limits/<itemize>
4390 <item>The function is only available as fastcall function, so it may only
4391 be used in presence of a prototype.
4393 <tag/Availability/cc65
4394 <tag/See also/Other serial functions.
4399 <sect1>ser_unload<label id="ser_unload"><p>
4403 <tag/Function/Uninstall, then unload the currently loaded driver.
4404 <tag/Header/<tt/<ref id="serial.h" name="serial.h">/
4405 <tag/Declaration/<tt/void __fastcall__ ser_unload (void);/
4406 <tag/Description/Uninstall, then unload the currently loaded driver.
4407 <tag/Limits/<itemize>
4408 <item>The function is only available as fastcall function, so it may only
4409 be used in presence of a prototype.
4411 <tag/Availability/cc65
4412 <tag/See also/Other serial functions.
4418 <sect1>set_brk<label id="set_brk"><p>
4422 <tag/Function/Set the break vector to a user function.
4423 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
4424 <tag/Declaration/<tt/void __fastcall__ set_brk (brk_handler func);/
4425 <tag/Description/<tt/set_brk/ allows a user program to handle breaks within the
4426 program code by letting the vector point to a user written C function. The
4427 runtime library installs a small stub that saves the registers into global
4428 variables that may be accessed (and changed) by the break handler.
4431 <item>The function is only available as fastcall function, so it may only
4432 be used in presence of a prototype.
4433 <item>The stub saves the zero page registers used by the C runtime and switches
4434 to a small break handler stack. This means that it is safe to execute C code,
4435 even if C code was interrupted. Be careful however not to use too many local
4436 variables, and do not enable stack checks for the handler function or any other
4437 function called from it.
4438 <item>The <tt/brk_pc/ variable points to the <tt/BRK/ instruction. If you want
4439 the continue with the interrupted code, you have to adjust <tt/brk_pc/,
4440 otherwise the <tt/BRK/ instruction will get executed over and over again.
4441 <item>Since <tt/set_brk/ installs an exit handler, it is not strictly necessary
4442 to call <tt/<ref id="reset_brk" name="reset_brk">/ as part of the cleanup when
4443 the program terminates.
4445 <tag/Availability/cc65
4447 <ref id="reset_brk" name="reset_brk">
4453 <sect1>setjmp<label id="setjmp"><p>
4457 <tag/Function/Save the context for use with <tt/longjmp/.
4458 <tag/Header/<tt/<ref id="setjmp.h" name="setjmp.h">/
4459 <tag/Declaration/<tt/int __fastcall__ setjmp (jmp_buf buf);/
4460 <tag/Description/The <tt/setjmp/ function saves the current context in <tt/buf/
4461 for subsequent use by the <tt/<ref id="longjmp" name="longjmp">/ function and
4465 <item>The function is only available as fastcall function, so it may only
4466 be used in presence of a prototype.
4467 <item><tt/setjmp/ is actually a macro as required by the ISO standard.
4468 <item><tt/setjmp/ will not save the signal context.
4470 <tag/Availability/ISO 9899
4472 <ref id="longjmp" name="longjmp">
4478 <sect1>setlocale<label id="setlocale"><p>
4482 <tag/Function/Selects a locale.
4483 <tag/Header/<tt/<ref id="locale.h" name="locale.h">/
4484 <tag/Declaration/<tt/char* __fastcall__ setlocale (int category, const char* locale);/
4485 <tag/Description/<tt/setlocale/ sets or queries the program's locale.
4488 <item>The function is only available as fastcall function, so it may only
4489 be used in presence of a prototype.
4490 <item>cc65 supports only the "C" locale, so calling this function to set a
4491 different locale has no effect.
4493 <tag/Availability/ISO 9899
4495 <ref id="localeconv" name="localeconv">,
4496 <ref id="strcoll" name="strcoll">
4497 <ref id="strxfrm" name="strxfrm">
4503 <sect1>signal<label id="signal"><p>
4507 <tag/Function/Install a signal handler.
4508 <tag/Header/<tt/<ref id="signal.h" name="signal.h">/
4509 <tag/Declaration/<tt/__sigfunc __fastcall__ signal (int sig, __sigfunc func);/
4510 <tag/Description/<tt/signal/ installs a handler for the given signal. The
4511 handler may either be a user supplied function, or one of the predefined
4512 signal handlers <tt/SIG_IGN/ or <tt/SIG_DFL/. The function returns the
4513 previous value if the signal , or the special function vector SIG_ERR in
4515 <tag/Limits/<itemize>
4516 <item>The function is only available as fastcall function, so it may only
4517 be used in presence of a prototype.
4519 <tag/Availability/ISO 9899
4521 <ref id="abort" name="abort">,
4522 <ref id="raise" name="raise">
4528 <sect1>sleep<label id="sleep"><p>
4532 <tag/Function/Sleep for a specified amount of time.
4533 <tag/Header/<tt/<ref id="unistd.h" name="unistd.h">/
4534 <tag/Declaration/<tt/void __fastcall__ sleep (unsigned seconds);/
4535 <tag/Description/The function will return after the specified number of
4536 seconds have elapsed.
4537 <tag/Limits/<itemize>
4538 <item>The function is only available as fastcall function, so it may only
4539 be used in presence of a prototype.
4541 <tag/Availability/POSIX 1003.1
4547 <sect1>slow<label id="slow"><p>
4551 <tag/Function/Switch the C128 into 1MHz mode.
4552 <tag/Header/<tt/<ref id="c128.h" name="c128.h">/
4553 <tag/Declaration/<tt/void slow (void);/
4554 <tag/Description/The function will switch the clock of the C128 to 1MHz. This
4555 will halve the speed compared to fast mode.
4556 <tag/Limits/<itemize>
4557 <item>The function is specific to the C128.
4559 <tag/Availability/C128
4561 <ref id="fast" name="fast">,
4562 <ref id="toggle_videomode" name="toggle_videomode">,
4563 <ref id="videomode" name="videomode">
4569 <sect1>srand<label id="srand"><p>
4573 <tag/Function/Initialize the pseudo random number generator.
4574 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
4575 <tag/Declaration/<tt/void __fastcall__ srand (unsigned seed);/
4576 <tag/Description/The function initializes the random number generator using
4577 the given seed. On program startup, the generator behaves as if <tt/srand/ has
4578 been called with an argument of 1.
4579 <tag/Limits/<itemize>
4580 <item>The function is only available as fastcall function, so it may only
4581 be used in presence of a prototype.
4583 <tag/Availability/ISO 9899
4585 <ref id="_randomize" name="_randomize">,
4586 <ref id="rand" name="rand">
4592 <sect1>strcasecmp<label id="strcasecmp"><p>
4596 <tag/Function/Compare two strings case insensitive.
4597 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4598 <tag/Declaration/<tt/int __fastcall__ strcasecmp (const char* s1, const char* s2);/
4599 <tag/Description/The <tt/strcasecmp/ function compares the two strings passed
4600 as parameters without case sensitivity. It returns a value that is less than
4601 zero if <tt/s1/ is less than <tt/s2/, zero if <tt/s1/ is the same as <tt/s2/,
4602 and a value greater than zero if <tt/s1/ is greater than <tt/s2/.
4603 <tag/Limits/<itemize>
4604 <item>The function is only available as fastcall function, so it may only
4605 be used in presence of a prototype.
4606 <item>The function is not available in strict ANSI mode.
4608 <tag/Availability/cc65
4610 <ref id="strcmp" name="strcmp">,
4611 <ref id="strcoll" name="strcoll">,
4612 <ref id="stricmp" name="stricmp">,
4613 <ref id="strncmp" name="strncmp">
4614 <ref id="strxfrm" name="strxfrm">
4620 <sect1>strcat<label id="strcat"><p>
4624 <tag/Function/Concatentate two strings.
4625 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4626 <tag/Declaration/<tt/char* __fastcall__ strcat (char* s1, const char* s2);/
4627 <tag/Description/The <tt/strcat/ function appends a copy of the string
4628 pointed to by s2 (including the terminating null byte) to the end of the
4629 string pointed to by s1. The initial byte of s2 overwrites the null byte at
4631 <tag/Limits/<itemize>
4632 <item>The function is only available as fastcall function, so it may only
4633 be used in presence of a prototype.
4634 <item>If copying takes place between objects that overlap, the behaviour
4637 <tag/Availability/ISO 9899
4639 <ref id="strcpy" name="strcpy">,
4640 <ref id="strncat" name="strncat">,
4641 <ref id="strncpy" name="strncpy">
4647 <sect1>strchr<label id="strchr"><p>
4651 <tag/Function/Search for a character in a string.
4652 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4653 <tag/Declaration/<tt/char* __fastcall__ strchr (const char* s, int c);/
4654 <tag/Description/The <tt/strchr/ function locates the first occurrence of <tt/c/
4655 (converted to a char) in the string pointed to by <tt/s/. The terminating null
4656 byte is considered to be part of the string. Upon completion, the function
4657 returns a pointer to the byte, or a null pointer if the byte was not found.
4658 <tag/Limits/<itemize>
4659 <item>The function is only available as fastcall function, so it may only
4660 be used in presence of a prototype.
4662 <tag/Availability/ISO 9899
4664 <ref id="memchr" name="memchr">,
4665 <ref id="strrchr" name="strrchr">
4671 <sect1>strcmp<label id="strcmp"><p>
4675 <tag/Function/Compare two strings.
4676 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4677 <tag/Declaration/<tt/int __fastcall__ strcmp (const char* s1, const char* s2);/
4678 <tag/Description/The <tt/strcmp/ function compares the two strings passed as
4679 parameters. It returns a value that is less than zero if <tt/s1/ is less than
4680 <tt/s2/, zero if <tt/s1/ is the same as <tt/s2/, and a value greater than zero
4681 if <tt/s1/ is greater than <tt/s2/.
4682 <tag/Limits/<itemize>
4683 <item>The function is only available as fastcall function, so it may only
4684 be used in presence of a prototype.
4686 <tag/Availability/ISO 9899
4688 <ref id="strcasecmp" name="strcasecmp">,
4689 <ref id="strcoll" name="strcoll">,
4690 <ref id="stricmp" name="stricmp">,
4691 <ref id="strncmp" name="strncmp">
4692 <ref id="strxfrm" name="strxfrm">
4698 <sect1>strcoll<label id="strcoll"><p>
4702 <tag/Function/Compare two strings.
4703 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4704 <tag/Declaration/<tt/int __fastcall__ strcoll (const char* s1, const char* s2);/
4705 <tag/Description/The <tt/strcoll/ function compares the two strings passed as
4706 parameters, according to the collating sequence set by <tt/<ref id="setlocale"
4707 name="setlocale">/. It returns a value that is less than zero if <tt/s1/ is
4708 less than <tt/s2/, zero if <tt/s1/ is the same as <tt/s2/, and a value greater
4709 than zero if <tt/s1/ is greater than <tt/s2/.
4710 <tag/Limits/<itemize>
4711 <item>The function is only available as fastcall function, so it may only
4712 be used in presence of a prototype.
4714 <tag/Availability/ISO 9899
4716 <ref id="setlocale" name="setlocale">,
4717 <ref id="strcasecmp" name="strcasecmp">,
4718 <ref id="strcmp" name="strcmp">,
4719 <ref id="stricmp" name="stricmp">,
4720 <ref id="strncmp" name="strncmp">
4721 <ref id="strxfrm" name="strxfrm">
4727 <sect1>strcpy<label id="strcpy"><p>
4731 <tag/Function/Copy a string.
4732 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4733 <tag/Declaration/<tt/char* __fastcall__ strcpy (char* s1, const char* s2);/
4734 <tag/Description/The <tt/strcpy/ function copies the string pointed to by
4735 <tt/s2/ (including the terminating null byte) into the array pointed to by
4736 <tt/s1/. The function will always return <tt/s1/.
4737 <tag/Limits/<itemize>
4738 <item>The function is only available as fastcall function, so it may only
4739 be used in presence of a prototype.
4740 <item>If copying takes place between objects that overlap, the behaviour
4743 <tag/Availability/ISO 9899
4745 <ref id="strcat" name="strcat">,
4746 <ref id="strncat" name="strncat">,
4747 <ref id="strncpy" name="strncpy">
4750 #include <string.h>
4752 static char hello[14];
4754 strcpy (hello, "Hello world!\n");
4760 <sect1>strcspn<label id="strcspn"><p>
4764 <tag/Function/Compute the length of a substring.
4765 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4766 <tag/Declaration/<tt/size_t __fastcall__ strcspn (const char* s, const char* set);/
4767 <tag/Description/The <tt/strcspn/ function computes and returns the length of
4768 the substring pointed to by <tt/s/ which does <em>not</em> consist of
4769 characters contained in the string <tt/set/.
4770 <tag/Limits/<itemize>
4771 <item>The function is only available as fastcall function, so it may only
4772 be used in presence of a prototype.
4774 <tag/Availability/ISO 9899
4776 <ref id="strspn" name="strspn">,
4777 <ref id="strstr" name="strstr">,
4778 <ref id="strtok" name="strtok">
4784 <sect1>strdup<label id="strdup"><p>
4788 <tag/Function/Allocate a copy of a string on the heap.
4789 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4790 <tag/Declaration/<tt/char* __fastcall__ strdup (const char* s);/
4791 <tag/Description/<tt/strdup/ allocates a memory block on the heap, big enough
4792 to hold a copy of <tt/s/ including the terminating zero. If the allocation
4793 fails, <tt/NULL/ is returned, otherwise <tt/s/ is copied into the allocated
4794 memory block, and a pointer to the block is returned.
4795 <tag/Limits/<itemize>
4796 <item>The function is only available as fastcall function, so it may only
4797 be used in presence of a prototype.
4798 <item>It is up to the caller to free the allocated memory block.
4800 <tag/Availability/ISO 9899
4802 <ref id="free" name="free">,
4803 <ref id="malloc" name="malloc">
4809 <sect1>strerror<label id="strerror"><p>
4813 <tag/Function/Return a string describing an error code.
4814 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4815 <tag/Declaration/<tt/char* __fastcall__ strerror (int errcode);/
4816 <tag/Description/The <tt/strerror/ function returns a string describing the
4817 given error code. If an invalid error code is passed, the string "Unknown
4818 error" is returned, and <tt/errno/ is set to <tt/EINVAL/. In all other cases,
4819 <tt/errno/ is left untouched.
4820 <tag/Limits/<itemize>
4821 <item>The function is only available as fastcall function, so it may only
4822 be used in presence of a prototype.
4823 <item>While the return type of the function is a <tt/char*/, the returned
4824 string must not be modified by the caller!
4826 <tag/Availability/ISO 9899
4828 <ref id="_stroserror" name="_stroserror">
4834 <sect1>stricmp<label id="stricmp"><p>
4838 <tag/Function/Compare two strings case insensitive.
4839 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4840 <tag/Declaration/<tt/int __fastcall__ stricmp (const char* s1, const char* s2);/
4841 <tag/Description/The <tt/stricmp/ function compares the two strings passed as
4842 parameters without case sensitivity. It returns a value that is less than zero
4843 if <tt/s1/ is less than <tt/s2/, zero if <tt/s1/ is the same as <tt/s2/, and a
4844 value greater than zero if <tt/s1/ is greater than <tt/s2/.
4845 <tag/Limits/<itemize>
4846 <item>The function is only available as fastcall function, so it may only
4847 be used in presence of a prototype.
4848 <item>The function is not available in strict ANSI mode.
4850 <tag/Availability/cc65
4852 <ref id="strcasecmp" name="strcasecmp">,
4853 <ref id="strcmp" name="strcmp">,
4854 <ref id="strcoll" name="strcoll">,
4855 <ref id="strncmp" name="strncmp">
4856 <ref id="strxfrm" name="strxfrm">
4862 <sect1>strlen<label id="strlen"><p>
4866 <tag/Function/Return the length of a string.
4867 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4868 <tag/Declaration/<tt/size_t __fastcall__ strlen (const char* s);/
4869 <tag/Description/The <tt/strlen/ function computes the number of bytes in the
4870 string to which s points, not including the terminating null byte.
4871 <tag/Limits/<itemize>
4872 <item>The function is only available as fastcall function, so it may only
4873 be used in presence of a prototype.
4874 <item>When compiling with <tt/-Os/ (inline known standard functions), the
4875 function does not work correctly for strings with more than 255 characters.
4877 <tag/Availability/ISO 9899
4879 <ref id="strcpy" name="strcpy">
4885 <sect1>strlower<label id="strlower"><p>
4889 <tag/Function/Make a string lower case.
4890 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4891 <tag/Declaration/<tt/char* __fastcall__ strlower (char* s);/
4892 <tag/Description/The <tt/strlower/ function will apply the <tt/tolower/
4893 function to each character of a string. The function will always return <tt/s/.
4894 <tag/Limits/<itemize>
4895 <item>The function is only available as fastcall function, so it may only
4896 be used in presence of a prototype.
4897 <item>The function prototype is unavailable when compiling in strict ANSI mode.
4898 <item>An alias name for this function is <tt/strlwr/.
4900 <tag/Availability/cc65
4902 <ref id="strupper" name="strupper">,
4903 <ref id="tolower" name="tolower">
4909 <sect1>strlwr<label id="strlwr"><p>
4916 <sect1>strncat<label id="strncat"><p>
4920 <tag/Function/Concatentate two strings.
4921 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4922 <tag/Declaration/<tt/char* __fastcall__ strncat (char* s1, const char* s2, size_t n);/
4923 <tag/Description/The <tt/strncat/ function appends not more than n characters
4924 of the string pointed to by s2 to the end of the string pointed to by s1. The
4925 terminating null character at the end of s1 is overwritten. A terminating null
4926 character is appended to the result, even if not all of s2 is appended to s1.
4927 <tag/Limits/<itemize>
4928 <item>The function is only available as fastcall function, so it may only
4929 be used in presence of a prototype.
4930 <item>If copying takes place between objects that overlap, the behaviour
4933 <tag/Availability/ISO 9899
4935 <ref id="strcpy" name="strcpy">,
4936 <ref id="strncat" name="strncat">,
4937 <ref id="strncpy" name="strncpy">
4943 <sect1>strncmp<label id="strncmp"><p>
4947 <tag/Function/Compare two strings.
4948 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4949 <tag/Declaration/<tt/int __fastcall__ strncmp (const char* s1, const char* s2, size_t count);/
4950 <tag/Description/The <tt/strncmp/ function compares not more than <tt/count/
4951 characters of the two strings passed as parameters. It returns a value that is
4952 less than zero if the first <tt/count/ characters of <tt/s1/ are less than
4953 <tt/s2/, zero if they are identical, and a value greater than zero they are
4955 <tag/Limits/<itemize>
4956 <item>The function is only available as fastcall function, so it may only
4957 be used in presence of a prototype.
4959 <tag/Availability/ISO 9899
4961 <ref id="strcasecmp" name="strcasecmp">,
4962 <ref id="strcmp" name="strcmp">,
4963 <ref id="strcoll" name="strcoll">,
4964 <ref id="stricmp" name="stricmp">
4965 <ref id="strxfrm" name="strxfrm">
4971 <sect1>strncpy<label id="strncpy"><p>
4975 <tag/Function/Copy part of a string.
4976 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4977 <tag/Declaration/<tt/char* __fastcall__ strcpy (char* s1, const char* s2, size_t n);/
4978 <tag/Description/The <tt/strncpy/ function copies not more than n bytes from
4979 the array pointed to by <tt/s2/ to the array pointed to by <tt/s1/. If the array
4980 pointed to by <tt/s2/ is a string that is shorter than n bytes, null bytes are
4981 appended to the copy in the array pointed to by <tt/s1/, until <tt/n/ bytes are
4982 written. The function will always return <tt/s1/.
4983 <tag/Limits/<itemize>
4984 <item>The function is only available as fastcall function, so it may only
4985 be used in presence of a prototype. If there is no null byte in the first <tt/n/
4986 bytes of the array pointed to by <tt/s2/, the result is not null-terminated.
4987 <item>If copying takes place between objects that overlap, the behaviour is
4990 <tag/Availability/ISO 9899
4992 <ref id="strcat" name="strcat">,
4993 <ref id="strcpy" name="strcpy">,
4994 <ref id="strncat" name="strncat">
4999 static char hello[6];
5001 strcpy (hello, "Hello world!\n", sizeof (hello) - 1);
5008 <sect1>strrchr<label id="strrchr"><p>
5012 <tag/Function/Search for a character in a string.
5013 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5014 <tag/Declaration/<tt/char* __fastcall__ strrchr (const char* s, int c);/
5015 <tag/Description/The <tt/strrchr/ function locates the last occurrence of <tt/c/
5016 (converted to a char) in the string pointed to by <tt/s/. The terminating null
5017 byte is considered to be part of the string. Upon completion, the function
5018 returns a pointer to the byte, or a null pointer if the byte was not found.
5019 <tag/Limits/<itemize>
5020 <item>The function is only available as fastcall function, so it may only
5021 be used in presence of a prototype.
5023 <tag/Availability/ISO 9899
5025 <ref id="strchr" name="strchr">
5031 <sect1>strspn<label id="strspn"><p>
5035 <tag/Function/Compute the length of a substring.
5036 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5037 <tag/Declaration/<tt/size_t __fastcall__ strspn (const char* s, const char* set);/
5038 <tag/Description/The <tt/strspn/ function computes and returns the length of
5039 the substring pointed to by <tt/s/ which does consist only of characters
5040 contained in the string <tt/set/.
5041 <tag/Limits/<itemize>
5042 <item>The function is only available as fastcall function, so it may only
5043 be used in presence of a prototype.
5045 <tag/Availability/ISO 9899
5047 <ref id="strcspn" name="strcspn">,
5048 <ref id="strstr" name="strstr">
5054 <sect1>strstr<label id="strstr"><p>
5058 <tag/Function/Find a substring.
5059 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5060 <tag/Declaration/<tt/char* __fastcall__ strstr (const char* str, const char* substr);/
5061 <tag/Description/<tt/strstr/ searches for the first occurance of the string
5062 <tt/substr/ within <tt/str/. If found, it returns a pointer to the copy,
5063 otherwise it returns <tt/NULL/.
5064 <tag/Limits/<itemize>
5065 <item>The function is only available as fastcall function, so it may only
5066 be used in presence of a prototype.
5068 <tag/Availability/ISO 9899
5070 <ref id="strcspn" name="strcspn">,
5071 <ref id="strspn" name="strspn">
5077 <sect1>strtok<label id="strtok"><p>
5081 <tag/Function/Break a string into tokens.
5082 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5083 <tag/Declaration/<tt/char* __fastcall__ strtok (char* s1, const char* s2);/
5084 <tag/Description/<tt/strtok/ will break the string s1 into a sequence of
5085 tokens, which are delimited by characters from the string s2. The first call
5086 to <tt/strtok/ will return a pointer to the first token in the string s1.
5087 Following calls must pass a <tt/NULL/ pointer as s1 in order to get the next
5088 token in the string. Different sets of delimiters may be used for the
5089 subsequent calls to <tt/strtok/.
5090 <tag/Limits/<itemize>
5091 <item>The function is only available as fastcall function, so it may only
5092 be used in presence of a prototype.
5093 <item><tt/strtok/ will modify the string s1.
5095 <tag/Availability/ISO 9899
5097 <ref id="strcspn" name="strcspn">,
5098 <!-- <ref id="strpbrk" name="strpbrk"> -->
5104 <sect1>strxfrm<label id="strxfrm"><p>
5108 <tag/Function/Transform a string.
5109 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5110 <tag/Declaration/<tt/size_t __fastcall__ strxfrm (char* s1, const char* s2, size_t n);/
5111 <tag/Description/The <tt/strxfrm/ function transforms the string pointed to by
5112 s2 and places the resulting string into the string pointed to by s1. The
5113 transformation is such that if the <tt/strcmp/ function is applied to two
5114 transformed strings, it returns a value greater than, equal to, or less than
5115 zero, corresponding to the result of the <tt/strcoll/ function applied to the
5116 same two original strings. No more than n characters are placed into the
5117 resulting array pointed to by s1, including the terminating null character.
5118 <tag/Limits/<itemize>
5119 <item><tt/s1/ and <tt/s2/ must not point to the same memory area, otherwise
5120 the behaviour is undefined.
5121 <item>If <tt/n/ is zero, <tt/s1/ may be a NULL pointer.
5122 <item>The function is only available as fastcall function, so it may only
5123 be used in presence of a prototype.
5124 <item>Since cc65 doesn't support different charcter sets, <tt/strxfrm/ will
5125 just copy s2 to s1 using <tt><ref id="strncpy" name="strncpy"></tt>.
5127 <tag/Availability/ISO 9899
5129 <ref id="strcmp" name="strcmp">,
5130 <ref id="strcoll" name="strcoll">,
5131 <ref id="strncpy" name="strncpy">,
5137 <sect1>strupper<label id="strupper"><p>
5141 <tag/Function/Make a string upper case.
5142 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5143 <tag/Declaration/<tt/char* __fastcall__ strupper (char* s);/
5144 <tag/Description/The <tt/strupper/ function will apply the <tt/toupper/
5145 function to each character of a string. The function will always return <tt/s/.
5146 <tag/Limits/<itemize>
5147 <item>The function is only available as fastcall function, so it may only
5148 be used in presence of a prototype.
5149 <item>The function prototype is unavailable when compiling in strict ANSI mode.
5150 <item>An alias name for this function is <tt/strupr/.
5152 <tag/Availability/cc65
5154 <ref id="strlower" name="strlower">
5155 <ref id="toupper" name="toupper">
5161 <sect1>strupr<label id="strupr"><p>
5168 <sect1>textcolor<label id="textcolor"><p>
5172 <tag/Function/Set the text color.
5173 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
5174 <tag/Declaration/<tt/unsigned char __fastcall__ textcolor (unsigned char color);/
5175 <tag/Description/The function will set a new text color. It returns the old
5176 (current) text color. Text output using any <tt/conio.h/ function will use
5177 the color set by this function.
5178 <tag/Limits/<itemize>
5179 <item>Text colors are system dependent. The function may have no effect
5180 on systems where the text color cannot be changed.
5181 <item>The function is only available as fastcall function, so it may only
5182 be used in presence of a prototype.
5184 <tag/Availability/cc65
5186 <ref id="bgcolor" name="bgcolor">,
5187 <ref id="bordercolor" name="bordercolor">
5193 <sect1>tgi_arc<label id="tgi_arc"><p>
5197 <tag/Function/Draw an elliptic arc in the current color.
5198 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5199 <tag/Declaration/<tt/void __fastcall__ tgi_arc (int x, int y,
5200 unsigned char rx, unsigned char ry, unsigned sa, unsigned ea);/
5201 <tag/Description/The function draws an elliptic arc with center at x/y and
5202 radii rx/ry using the current drawing color. The arc covers the angle
5203 between sa and ea (startangle and endangle), which must be in the range
5205 <tag/Limits/<itemize>
5206 <item>The function is only available as fastcall function, so it may only
5207 be used in presence of a prototype.
5208 <item>The function behaves unexpectedly or may crash if the angles are out
5211 <tag/Availability/cc65
5213 <ref id="tgi_bar" name="tgi_bar">,
5214 <ref id="tgi_circle" name="tgi_circle">,
5215 <ref id="tgi_ellipse" name="tgi_ellipse">,
5216 <ref id="tgi_pieslice" name="tgi_pieslice">,
5217 <ref id="tgi_setcolor" name="tgi_setcolor">
5219 /* Draw the upper half of an ellipse */
5220 tgi_setcolor(TGI_COLOR_BLUE);
5221 tgi_arc (50, 50, 40, 20, 0, 180);
5227 <sect1>tgi_bar<label id="tgi_bar"><p>
5231 <tag/Function/The function fills a rectangle on the drawpage with the current
5233 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5234 <tag/Declaration/<tt/void __fastcall__ tgi_bar (int x1, int y1, int x2, int y2);/
5235 <tag/Description/The function fills a rectangle on the drawpage with the current
5237 <tag/Limits/<itemize>
5238 <item>The function is only available as fastcall function, so it may only
5239 be used in presence of a prototype.
5241 <tag/Availability/cc65
5242 <tag/See also/Other tgi function
5244 tgi_setcolor(TGI_COLOR_GREEN);
5245 tgi_bar(10, 10, 100, 60);
5251 <sect1>tgi_circle<label id="tgi_circle"><p>
5255 <tag/Function/The function draws a circle in the current color.
5256 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5257 <tag/Declaration/<tt/void __fastcall__ tgi_circle (int x, int y, unsigned char radius);/
5258 <tag/Description/The function draws a circle in the current color.
5259 <tag/Limits/<itemize>
5260 <item>The function is only available as fastcall function, so it may only
5261 be used in presence of a prototype.
5263 <tag/Availability/cc65
5265 <ref id="tgi_arc" name="tgi_arc">,
5266 <ref id="tgi_bar" name="tgi_bar">,
5267 <ref id="tgi_ellipse" name="tgi_ellipse">,
5268 <ref id="tgi_pieslice" name="tgi_pieslice">,
5269 <ref id="tgi_setcolor" name="tgi_setcolor">
5271 tgi_setcolor(TGI_COLOR_BLACK);
5272 tgi_circle(50, 40, 40);
5278 <sect1>tgi_clear<label id="tgi_clear"><p>
5282 <tag/Function/Clear the drawpage
5283 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5284 <tag/Declaration/<tt/void __fastcall__ tgi_clear (void);/
5285 <tag/Description/Clear the drawpage
5286 <tag/Limits/<itemize>
5287 <item>The function is only available as fastcall function, so it may only
5288 be used in presence of a prototype.
5290 <tag/Availability/cc65
5291 <tag/See also/Other tgi functions
5297 <sect1>tgi_done<label id="tgi_done"><p>
5301 <tag/Function/End graphics mode, switch back to text mode.
5302 Will NOT uninstall or unload the driver!
5303 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5304 <tag/Declaration/<tt/void __fastcall__ tgi_done (void);/
5305 <tag/Description/End graphics mode, switch back to text mode.
5306 Will NOT uninstall or unload the driver!
5307 <tag/Limits/<itemize>
5308 <item>The function is only available as fastcall function, so it may only
5309 be used in presence of a prototype.
5311 <tag/Availability/cc65
5312 <tag/See also/Other tgi functions
5318 <sect1>tgi_ellipse<label id="tgi_ellipse"><p>
5322 <tag/Function/The function draws an ellipse in the current color.
5323 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5324 <tag/Declaration/<tt/void __fastcall__ tgi_ellipse (int x, int y, unsigned char rx, unsigned char ry);/
5325 <tag/Description/The function draws an ellipse at position x/y with radii
5326 rx and ry, using the current drawing color.
5327 <tag/Limits/<itemize>
5328 <item>The function is only available as fastcall function, so it may only
5329 be used in presence of a prototype.
5331 <tag/Availability/cc65
5333 <ref id="tgi_arc" name="tgi_arc">,
5334 <ref id="tgi_bar" name="tgi_bar">,
5335 <ref id="tgi_circle" name="tgi_circle">,
5336 <ref id="tgi_pieslice" name="tgi_pieslice">,
5337 <ref id="tgi_setcolor" name="tgi_setcolor">
5339 tgi_setcolor(TGI_COLOR_RED);
5340 tgi_ellipse (50, 40, 40, 20);
5346 <sect1>tgi_getcolor<label id="tgi_getcolor"><p>
5350 <tag/Function/Return the current drawing color.
5351 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5352 <tag/Declaration/<tt/unsigned char __fastcall__ tgi_getcolor (void);/
5353 <tag/Description/The actual color is an index to a palette. During tgi_init
5354 you will get a default palette. The number of colors depend on the platform.
5355 All platforms recognize at least TGI_COLOR_BLACK and TGI_COLOR_WHITE. But some
5356 platforms have many more predefined colors. If you paint using TGI_COLOR_GREEN
5357 and then you change the green of the palette to blue using tgi_setpalette then
5358 after this painting in TGI_COLOR_GREEN will actually be blue.
5359 <tag/Limits/<itemize>
5360 <item>The function is only available as fastcall function, so it may only
5361 be used in presence of a prototype.
5363 <tag/Availability/cc65
5364 <tag/See also/Other tgi functions
5366 color = tgi_getcolor();
5371 <sect1>tgi_getcolorcount<label id="tgi_getcolorcount"><p>
5375 <tag/Function/Get the number of available colors.
5376 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5377 <tag/Declaration/<tt/unsigned char __fastcall__ tgi_getcolorcount (void);/
5378 <tag/Description/Tgi platforms use indexed color palettes. This function
5379 returns the number of entries we can use in the palette.
5380 <tag/Limits/<itemize>
5381 <item>The function is only available as fastcall function, so it may only
5382 be used in presence of a prototype.
5384 <tag/Availability/cc65
5385 <tag/See also/Other tgi functions
5387 if (tgi_getcolorcount() == 2) {
5388 printf("Only monochrome graphics is supported\n");
5394 <sect1>tgi_getdefpalette<label id="tgi_getdefpalette"><p>
5398 <tag/Function/Get the palette installed by default.
5399 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5400 <tag/Declaration/<tt/const unsigned char* __fastcall__ tgi_getdefpalette (void);/
5401 <tag/Description/The tgi driver has a default palette that is active at startup.
5402 The named colors TGI_COLOR_BLACK, TGI_COLOR_WHITE, TGI_COLOR_RED... need this
5403 palette to work correctly.
5404 <tag/Limits/<itemize>
5405 <item>The function is only available as fastcall function, so it may only
5406 be used in presence of a prototype.
5408 <tag/Availability/cc65
5409 <tag/See also/Other tgi functions
5414 <sect1>tgi_geterror<label id="tgi_geterror"><p>
5418 <tag/Function/Return the error code for the last operation.
5419 This will also clear the error.
5420 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5421 <tag/Declaration/<tt/unsigned char __fastcall__ tgi_geterror (void);/
5422 <tag/Description/Return the error code for the last operation.
5423 This will also clear the error.
5424 <tag/Limits/<itemize>
5425 <item>The function is only available as fastcall function, so it may only
5426 be used in presence of a prototype.
5428 <tag/Availability/cc65
5429 <tag/See also/Other tgi functions
5434 <sect1>tgi_geterrormsg<label id="tgi_geterrormsg"><p>
5438 <tag/Function/Get an error message describing the error.
5439 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5440 <tag/Declaration/<tt/const char* __fastcall__ tgi_geterrormsg (unsigned char code);/
5441 <tag/Description/Get an error message describing the error.
5442 <tag/Limits/<itemize>
5443 <item>The function is only available as fastcall function, so it may only
5444 be used in presence of a prototype.
5446 <tag/Availability/cc65
5447 <tag/See also/Other tgi functions
5452 <sect1>tgi_getmaxcolor<label id="tgi_getmaxcolor"><p>
5456 <tag/Function/Get the highest index of the palette.
5457 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5458 <tag/Declaration/<tt/unsigned char __fastcall__ tgi_getmaxcolor (void);/
5459 <tag/Description/Get the highest index of the palette.
5460 <tag/Limits/<itemize>
5461 <item>The function is only available as fastcall function, so it may only
5462 be used in presence of a prototype.
5464 <tag/Availability/cc65
5465 <tag/See also/Other tgi functions
5470 <sect1>tgi_getmaxx<label id="tgi_getmaxx"><p>
5474 <tag/Function/Get the maximum x coordinate that can be used on this screen.
5475 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5476 <tag/Declaration/<tt/unsigned __fastcall__ tgi_getmaxx (void);/
5477 <tag/Description/Get the maximum x coordinate that can be used on this screen.
5478 <tag/Limits/<itemize>
5479 <item>The function is only available as fastcall function, so it may only
5480 be used in presence of a prototype.
5482 <tag/Availability/cc65
5483 <tag/Availability/cc65
5484 <tag/See also/Other tgi functions
5489 <sect1>tgi_getmaxy<label id="tgi_getmaxy"><p>
5493 <tag/Function/Get the maximum y coordinate that can be used on this screen.
5494 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5495 <tag/Declaration/<tt/unsigned __fastcall__ tgi_getmaxy (void);/
5496 <tag/Description/Get the maximum y coordinate that can be used on this screen.
5497 <tag/Limits/<itemize>
5498 <item>The function is only available as fastcall function, so it may only
5499 be used in presence of a prototype.
5501 <tag/Availability/cc65
5502 <tag/See also/Other tgi functions
5507 <sect1>tgi_getpagecount<label id="tgi_getpagecount"><p>
5511 <tag/Function/Return the number of screen pages available.
5512 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5513 <tag/Declaration/<tt/unsigned __fastcall__ tgi_getpagecount (void);/
5514 <tag/Description/Return the number of screen pages available.
5515 <tag/Limits/<itemize>
5516 <item>The function is only available as fastcall function, so it may only
5517 be used in presence of a prototype.
5519 <tag/Availability/cc65
5521 <ref id="tgi_setdrawpage" name="tgi_setdrawpage">,
5522 <ref id="tgi_setviewpage" name="tgi_setviewpage">
5527 <sect1>tgi_getpalette<label id="tgi_getpalette"><p>
5531 <tag/Function/Get the palette installed.
5532 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5533 <tag/Declaration/<tt/const unsigned char* __fastcall__ tgi_getpalette (void);/
5534 <tag/Description/Get the palette installed.
5535 <tag/Limits/<itemize>
5536 <item>The function is only available as fastcall function, so it may only
5537 be used in presence of a prototype.
5539 <tag/Availability/cc65
5540 <tag/See also/Other tgi functions
5545 <sect1>tgi_getpixel<label id="tgi_getpixel"><p>
5549 <tag/Function/Get the color of a pixel from the viewpage.
5550 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5551 <tag/Declaration/<tt/unsigned char __fastcall__ tgi_getpixel (int x, int y);/
5552 <tag/Description/Get the color of a pixel from the viewpage.
5553 <tag/Limits/<itemize>
5554 <item>The function is only available as fastcall function, so it may only
5555 be used in presence of a prototype.
5557 <tag/Availability/cc65
5558 <tag/See also/Other tgi functions.
5563 <sect1>tgi_getxres<label id="tgi_getxres"><p>
5567 <tag/Function/Get number of horisontal pixels on the screen.
5568 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5569 <tag/Declaration/<tt/unsigned __fastcall__ tgi_getxres (void);/
5570 <tag/Description/Get number of horisontal pixels on the screen.
5571 This is same as tgi_maxx()+1.
5572 <tag/Limits/<itemize>
5573 <item>The function is only available as fastcall function, so it may only
5574 be used in presence of a prototype.
5576 <tag/Availability/cc65
5577 <tag/See also/Other tgi functions.
5582 <sect1>tgi_getyres<label id="tgi_getyres"><p>
5586 <tag/Function/Get number of vertical pixels on the screen.
5587 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5588 <tag/Declaration/<tt/unsigned __fastcall__ tgi_getyres (void);/
5589 <tag/Description/Get number of vertical pixels on the screen.
5590 This is same as tgi_maxy()+1.
5591 <tag/Limits/<itemize>
5592 <item>The function is only available as fastcall function, so it may only
5593 be used in presence of a prototype.
5595 <tag/Availability/cc65
5596 <tag/See also/Other tgi functions.
5601 <sect1>tgi_gotoxy<label id="tgi_gotoxy"><p>
5605 <tag/Function/Set graphics cursor at x, y.
5606 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5607 <tag/Declaration/<tt/void __fastcall__ tgi_gotoxy (int x, int y);/
5608 <tag/Description/Set graphics cursor at x, y.
5609 <tag/Limits/<itemize>
5610 <item>The function is only available as fastcall function, so it may only
5611 be used in presence of a prototype.
5613 <tag/Availability/cc65
5614 <tag/See also/Other tgi functions.
5619 <sect1>tgi_init<label id="tgi_init"><p>
5623 <tag/Function/Initialize the already loaded graphics driver.
5624 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5625 <tag/Declaration/<tt/void __fastcall__ tgi_init (void);/
5626 <tag/Description/The tgi_init function will set the default palette to the
5628 <tag/Limits/<itemize>
5629 <item>The function is only available as fastcall function, so it may only
5630 be used in presence of a prototype.
5631 <item><tt/tgi_init/ will not clear the screen. This allows switching between
5632 text and graphics mode on platforms that have separate memory areas for the
5633 screens. If you want the screen cleared, call <tt/<ref id="tgi_clear"
5634 name="tgi_clear">/ after <tt/tgi_init/.
5636 <tag/Availability/cc65
5637 <tag/See also/Other tgi functions.
5639 extern char lynxtgi[]; //Include the driver statically instead of loading it.
5640 tgi_install(&lynxtgi);
5641 tgi_init(); //Set up the default palette and clear the screen.
5646 <sect1>tgi_install<label id="tgi_install"><p>
5650 <tag/Function/Install an already loaded driver and return an error code.
5651 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5652 <tag/Declaration/<tt/unsigned char __fastcall__ tgi_install (void* driver);/
5653 <tag/Description/The function installs a driver that was already loaded into
5654 memory (or linked statically to the program). It returns an error code
5655 (<tt/TGI_ERR_OK/ in case of success).
5656 <tag/Limits/<itemize>
5657 <item>The function is only available as fastcall function, so it may only be
5658 used in presence of a prototype.
5660 <tag/Availability/cc65
5662 <ref id="tgi_load_driver" name="tgi_load_driver">,
5663 <ref id="tgi_uninstall" name="tgi_uninstall">,
5664 <ref id="tgi_unload" name="tgi_unload">
5666 extern char lynxtgi[]; //Include the driver statically instead of loading it.
5668 tgi_install(&lynxtgi);
5669 tgi_init(); //Set up the default palette and clear the screen.
5675 <sect1>tgi_ioctl<label id="tgi_ioctl"><p>
5679 <tag/Function/Platform dependent code extensions.
5680 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5681 <tag/Declaration/<tt/unsigned __fastcall__ tgi_ioctl (unsigned char code, void* data);/
5682 <tag/Description/Some platforms have extra display hardware that is not
5683 supported by standard tgi functions. You can extend the driver to support
5684 this extra hardware using tgi_ioctl functions.
5685 <tag/Limits/<itemize>
5686 <item>The function is only available as fastcall function, so it may only
5687 be used in presence of a prototype.
5688 <item>These functions are not easily portable to other cc65 platforms.
5690 <tag/Availability/cc65
5691 <tag/See also/Other tgi functions.
5693 #define tgi_sprite(spr) tgi_ioctl(0, (void*)(spr))
5694 #define tgi_flip() tgi_ioctl(1, (void*)0)
5695 #define tgi_setbgcolor(bgcol) tgi_ioctl(2, (void*)(bgcol))
5696 #define tgi_setframerate(rate) tgi_ioctl(3, (void*)(rate))
5697 #define tgi_busy() tgi_ioctl(4, (void*)0)
5698 #define tgi_updatedisplay() tgi_ioctl(4, (void*)1)
5700 tgi_sprite(&background);
5701 tgi_setcolor(TGI_COLOR_BLUE);
5702 tgi_outttextxy(20,40,"Hello World");
5703 tgi_updatedisplay();
5710 <sect1>tgi_line<label id="tgi_line"><p>
5714 <tag/Function/Draw a line in the current drawing color.
5715 The graphics cursor will be set to x2/y2 by this call.
5716 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5717 <tag/Declaration/<tt/void __fastcall__ tgi_line (int x1, int y1, int x2, int y2);/
5718 <tag/Description/Draw a line in the current drawing color.
5719 The graphics cursor will be set to x2/y2 by this call.
5720 <tag/Limits/<itemize>
5721 <item>The function is only available as fastcall function, so it may only
5722 be used in presence of a prototype.
5724 <tag/Availability/cc65
5725 <tag/See also/Other tgi functions.
5731 <sect1>tgi_lineto<label id="tgi_lineto"><p>
5735 <tag/Function/Draw a line in the current drawing color from the graphics
5736 cursor to the new end point. The graphics cursor will be updated to x2/y2.
5737 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5738 <tag/Declaration/<tt/void __fastcall__ tgi_lineto (int x2, int y2);/
5739 <tag/Description/Draw a line in the current drawing color from the graphics
5740 cursor to the new end point. The graphics cursor will be updated to x2/y2.
5741 <tag/Limits/<itemize>
5742 <item>The function is only available as fastcall function, so it may only
5743 be used in presence of a prototype.
5745 <tag/Availability/cc65
5746 <tag/See also/Other tgi functions.
5752 <sect1>tgi_load_driver<label id="tgi_load_driver"><p>
5756 <tag/Function/Load and install the given driver.
5757 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5758 <tag/Declaration/<tt/void __fastcall__ tgi_load_driver (const char *name);/
5759 <tag/Description/Load and install the driver by name.
5760 Will just load the driver and check if loading was successul.
5761 Will not switch to graphics mode.
5762 <tag/Limits/<itemize>
5763 <item>The function is only available as fastcall function, so it may only
5764 be used in presence of a prototype.
5766 <tag/Availability/cc65
5767 <tag/See also/Other tgi functions.
5773 <sect1>tgi_outtext<label id="tgi_outtext"><p>
5777 <tag/Function/Output text at the current graphics cursor position.
5778 The graphics cursor is moved to the end of the text.
5779 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5780 <tag/Declaration/<tt/void __fastcall__ tgi_outtext (const char* s);/
5781 <tag/Description/Output text at the current graphics cursor position.
5782 The graphics cursor is moved to the end of the text.
5783 <tag/Limits/<itemize>
5784 <item>The function is only available as fastcall function, so it may only
5785 be used in presence of a prototype.
5787 <tag/Availability/cc65
5788 <tag/See also/Other tgi functions.
5794 <sect1>tgi_outtextxy<label id="tgi_outtextxy"><p>
5798 <tag/Function/Output text at the given cursor position.
5799 The graphics cursor is moved to the end of the text.
5800 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5801 <tag/Declaration/<tt/void __fastcall__ tgi_outtextxy (int x, int y, const char* s);/
5802 <tag/Description/Output text at the given cursor position.
5803 The graphics cursor is moved to the end of the text.
5804 <tag/Limits/<itemize>
5805 <item>The function is only available as fastcall function, so it may only
5806 be used in presence of a prototype.
5808 <tag/Availability/cc65
5809 <tag/See also/Other tgi functions.
5815 <sect1>tgi_pieslice<label id="tgi_pieslice"><p>
5819 <tag/Function/Draw an elliptic pie slice in the current color.
5820 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5821 <tag/Declaration/<tt/void __fastcall__ tgi_pie slice (int x, int y,
5822 unsigned char rx, unsigned char ry, unsigned sa, unsigned ea);/
5823 <tag/Description/The function draws an elliptic pie slice with center at x/y
5824 and radii rx/ry using the current drawing color. The pie slice covers the angle
5825 between sa and ea (startangle and endangle), which must be in the range
5827 <tag/Limits/<itemize>
5828 <item>The function is only available as fastcall function, so it may only
5829 be used in presence of a prototype.
5830 <item>The function behaves unexpectedly or may crash if the angles are out
5833 <tag/Availability/cc65
5835 <ref id="tgi_bar" name="tgi_arc">,
5836 <ref id="tgi_bar" name="tgi_bar">,
5837 <ref id="tgi_circle" name="tgi_circle">,
5838 <ref id="tgi_ellipse" name="tgi_ellipse">,
5839 <ref id="tgi_setcolor" name="tgi_setcolor">
5841 /* Draw the closed upper half of an ellipse */
5842 tgi_setcolor(TGI_COLOR_BLUE);
5843 tgi_pieslice (50, 50, 40, 20, 0, 180);
5849 <sect1>tgi_setcolor<label id="tgi_setcolor"><p>
5853 <tag/Function/Set color to be used in future draw operations.
5854 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5855 <tag/Declaration/<tt/void __fastcall__ tgi_setcolor (unsigned char color);/
5856 <tag/Description/Set color to be used in future draw operations.
5857 <tag/Limits/<itemize>
5858 <item>The function is only available as fastcall function, so it may only
5859 be used in presence of a prototype.
5861 <tag/Availability/cc65
5862 <tag/See also/Other tgi functions.
5864 tgi_setcolor(TGI_COLOR_BLACK);
5866 tgi_setcolor(TGI_COLOR_WHITE);
5867 tgi_bar(10,10,20,20);
5872 <sect1>tgi_setdrawpage<label id="tgi_setdrawpage"><p>
5876 <tag/Function/Set the page for drawing.
5877 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5878 <tag/Declaration/<tt/void __fastcall__ tgi_setdrawpage (unsigned char page);/
5879 <tag/Description/If the drawpage and the viewpage are the same then all drawing
5880 is seen immediately as it is drawn. For double buffered games you can set the
5881 drawpage to a different page than the viewpage. This lets you draw the next
5882 screen in the background and when the screen is ready you display it.
5883 <tag/Limits/<itemize>
5884 <item>The function is only available as fastcall function, so it may only
5885 be used in presence of a prototype.
5887 <tag/Availability/cc65
5888 <tag/See also/Other tgi functions.
5891 tgi_outtextxy(10, 10, "Hello World");
5892 tgi_setviewpage(1); // Show page 1
5894 tgi_outtextxy(10, 10, "Creating next frame");
5896 tgi_setviewpage(0); // Show page 0
5901 <sect1>tgi_setpalette<label id="tgi_setpalette"><p>
5905 <tag/Function/Set the palette (not available with all drivers/hardware).
5906 Palette is a pointer to as many entries as there are colors.
5907 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5908 <tag/Declaration/<tt/void __fastcall__ tgi_setpalette (const unsigned char* palette);/
5909 <tag/Description/Set the palette (not available with all drivers/hardware).
5910 Palette is a pointer to as many entries as there are colors.
5911 <tag/Limits/<itemize>
5912 <item>The function is only available as fastcall function, so it may only
5913 be used in presence of a prototype.
5915 <tag/Availability/cc65
5916 <tag/See also/Other tgi functions.
5921 <sect1>tgi_setpixel<label id="tgi_setpixel"><p>
5925 <tag/Function/Plot a pixel on the drawpage with the current color.
5926 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5927 <tag/Declaration/<tt/void __fastcall__ tgi_setpixel (int x, int y);/
5928 <tag/Description/Plot a pixel on the drawpage with the current color.
5929 <tag/Limits/<itemize>
5930 <item>The function is only available as fastcall function, so it may only
5931 be used in presence of a prototype.
5933 <tag/Availability/cc65
5934 <tag/See also/Other tgi functions.
5939 <sect1>tgi_setviewpage<label id="tgi_setviewpage"><p>
5943 <tag/Function/Set page to be visible on screen.
5944 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5945 <tag/Declaration/<tt/void __fastcall__ tgi_setviewpage (unsigned char page);/
5946 <tag/Description/If the drawpage and the viewpage are the same then all drawing
5947 is seen immediately as it is drawn. For double buffered games you can set the
5948 drawpage to a different page than the viewpage. This lets you draw the next
5949 screen in the background and when the screen is ready you display it.
5950 <tag/Limits/<itemize>
5951 <item>The function is only available as fastcall function, so it may only
5952 be used in presence of a prototype.
5954 <tag/Availability/cc65
5955 <tag/See also/Other tgi functions.
5958 tgi_outtextxy(10, 10, "Hello World");
5959 tgi_setviewpage(1); // Show page 1
5961 tgi_outtextxy(10, 10, "Creating next frame");
5963 tgi_setviewpage(0); // Show page 0
5968 <sect1>tgi_textheight<label id="tgi_textheight"><p>
5972 <tag/Function/Calculate the height of the text in pixels according to
5973 the current text style.
5974 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5975 <tag/Declaration/<tt/unsigned __fastcall__ tgi_textheight (const char* s);/
5976 <tag/Description/Calculate the height of the text in pixels according to
5977 the current text style.
5978 <tag/Limits/<itemize>
5979 <item>The function is only available as fastcall function, so it may only
5980 be used in presence of a prototype.
5982 <tag/Availability/cc65
5983 <tag/See also/Other tgi functions.
5988 <sect1>tgi_textstyle<label id="tgi_textstyle"><p>
5992 <tag/Function/Set the style for text output.
5993 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5994 <tag/Declaration/<tt/void __fastcall__ tgi_textstyle (unsigned char magx, unsigned char magy, unsigned char dir);/
5995 <tag/Description/Set the style for text output.
5996 <tag/Limits/<itemize>
5997 <item>The function is only available as fastcall function, so it may only
5998 be used in presence of a prototype.
6000 <tag/Availability/cc65
6001 <tag/See also/Other tgi functions.
6006 <sect1>tgi_textwidth<label id="tgi_textwidth"><p>
6010 <tag/Function/Calculate the width of the text in pixels according to the current text style.
6011 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6012 <tag/Declaration/<tt/unsigned __fastcall__ tgi_textwidth (const char* s);/
6013 <tag/Function/Calculate the width of the text in pixels according to the current text style.
6014 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6015 <tag/Description/Calculate the width of the text in pixels according to the current text style.
6016 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6017 <tag/Limits/<itemize>
6018 <item>The function is only available as fastcall function, so it may only
6019 be used in presence of a prototype.
6021 <tag/Availability/cc65
6022 <tag/See also/Other tgi functions.
6027 <sect1>tgi_uninstall<label id="tgi_uninstall"><p>
6031 <tag/Function/Uninstall the currently loaded driver but do not unload it.
6032 Will call tgi_done if necessary.
6033 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6034 <tag/Declaration/<tt/void __fastcall__ tgi_uninstall (void);/
6035 <tag/Description/Uninstall the currently loaded driver but do not unload it.
6036 Will call tgi_done if necessary.
6037 <tag/Limits/<itemize>
6038 <item>The function is only available as fastcall function, so it may only
6039 be used in presence of a prototype.
6041 <tag/Availability/cc65
6042 <tag/See also/Other tgi functions.
6047 <sect1>tgi_unload<label id="tgi_unload"><p>
6051 <tag/Function/Uninstall, then unload the currently loaded driver.
6052 Will call tgi_done if necessary.
6053 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6054 <tag/Declaration/<tt/void __fastcall__ tgi_unload (void);/
6055 <tag/Description/Uninstall, then unload the currently loaded driver.
6056 Will call tgi_done if necessary.
6057 <tag/Limits/<itemize>
6058 <item>The function is only available as fastcall function, so it may only
6059 be used in presence of a prototype.
6061 <tag/Availability/cc65
6062 <tag/See also/Other tgi functions.
6067 <sect1>time<label id="time"><p>
6071 <tag/Function/Get the time.
6072 <tag/Header/<tt/<ref id="time.h" name="time.h">/
6073 <tag/Declaration/<tt/time_t __fastcall__ time (time_t* t);/
6074 <tag/Description/The function returns the time since the 1970-01-01 00:00:00
6075 measured in seconds. If the pointer <tt/t/ is not <tt/NULL/, the function
6076 result will also be stored there. If no time is available, <tt/(time_t)-1/ is
6077 returned and <tt/errno/ is set to <tt/ENOSYS/.
6078 <tag/Limits/<itemize>
6079 <item>The function is only available as fastcall function, so it may
6080 only be used in presence of a prototype.
6081 <item>Many platforms supported by cc65 do not have a realtime clock, so the
6082 returned value may not be valid.
6084 <tag/Availability/ISO 9899
6090 <sect1>toggle_videomode<label id="toggle_videomode"><p>
6094 <tag/Function/Toggle between 40 and 80 column mode.
6095 <tag/Header/<tt/<ref id="c128.h" name="c128.h">/
6096 <tag/Declaration/<tt/void toggle_videomode (void);/
6097 <tag/Description/Toggle between 40 and 80 column mode. The settings for the
6098 old mode (cursor position, color and so on) are saved and restored together
6100 <tag/Limits/<itemize>
6101 <item>The function is specific to the C128.
6102 <item>This function is deprecated. Please use <ref id="videomode"
6103 name="videomode"> instead!
6105 <tag/Availability/C128
6107 <ref id="fast" name="fast">,
6108 <ref id="slow" name="slow">,
6109 <ref id="videomode" name="videomode">
6115 <sect1>tolower<label id="tolower"><p>
6119 <tag/Function/Convert a character into its lower case representation.
6120 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
6121 <tag/Declaration/<tt/int __fastcall__ tolower (int c);/
6122 <tag/Description/The function returns the given character converted to lower
6123 case. If the given character is not a letter, it is returned unchanged.
6124 <tag/Limits/<itemize>
6125 <item>The function is only available as fastcall function, so it may
6126 only be used in presence of a prototype.
6128 <tag/Availability/ISO 9899
6130 <ref id="islower" name="islower">,
6131 <ref id="isupper" name="isupper">,
6132 <ref id="toupper" name="toupper">
6138 <sect1>toupper<label id="toupper"><p>
6142 <tag/Function/Convert a character into its upper case representation.
6143 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
6144 <tag/Declaration/<tt/int __fastcall__ toupper (int c);/
6145 <tag/Description/The function returns the given character converted to upper
6146 case. If the given character is not a letter, it is returned unchanged.
6147 <tag/Limits/<itemize>
6148 <item>The function is only available as fastcall function, so it may
6149 only be used in presence of a prototype.
6151 <tag/Availability/ISO 9899
6153 <ref id="islower" name="islower">,
6154 <ref id="isupper" name="isupper">,
6155 <ref id="tolower" name="tolower">
6161 <sect1>ultoa<label id="ultoa"><p>
6165 <tag/Function/Convert an unsigned long integer into a string.
6166 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
6167 <tag/Declaration/<tt/char* __fastcall__ ultoa (unsigned long val, char* buf, int radix);/
6168 <tag/Description/<tt/itoa/ converts the unsigned long integer <tt/val/ into a
6169 string using <tt/radix/ as the base.
6170 <tag/Limits/<itemize>
6171 <item>There are no provisions to prevent a buffer overflow.
6172 <item>The function is non standard, so it is not available in strict ANSI mode.
6173 You should probably use <tt/sprintf/ instead.
6174 <item>The function is only available as fastcall function, so it may only be
6175 used in presence of a prototype.
6177 <tag/Availability/cc65
6179 <ref id="atoi" name="atoi">,
6180 <ref id="atol" name="atol">,
6181 <ref id="itoa" name="itoa">,
6182 <ref id="ltoa" name="ltoa">,
6183 <ref id="utoa" name="utoa">
6189 <sect1>unlink<label id="unlink"><p>
6193 <tag/Function/Delete a file.
6194 <tag/Header/<tt/<ref id="unistd.h" name="unistd.h">/
6195 <tag/Declaration/<tt/int __fastcall__ unlink (const char* name);/
6196 <tag/Description/<tt/unlink/ deletes the file with the given name. On success,
6197 zero is returned. On error, -1 is returned and <tt/errno/ is set to an error
6198 code describing the reason for the failure.
6201 <item>The use of this function is discouraged. Please use <tt/<ref id="remove"
6202 name="remove">/ instead, which is a native ANSI C function and does the same.
6203 <item>This function is not available on all cc65 targets (depends on the
6204 availability of file I/O).
6205 <item>The function is only available as fastcall function, so it may only
6206 be used in presence of a prototype.
6207 <item>Instead of <tt/unlink/, <tt/<ref id="remove" name="remove">/ should be
6208 used, which has the same semantics, but is more portable, because it conforms
6209 to the ISO C standard.
6211 <tag/Availability/POSIX 1003.1
6213 <ref id="remove" name="remove">
6216 #include <stdio.h>
6217 #include <unistd.h>
6219 #define FILENAME "helloworld"
6221 if (unlink (FILENAME) == 0) {
6222 printf ("We deleted %s successfully\n", FILENAME);
6224 printf ("There was a problem deleting %s\n", FILENAME);
6231 <sect1>utoa<label id="utoa"><p>
6235 <tag/Function/Convert an unsigned integer into a string.
6236 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
6237 <tag/Declaration/<tt/char* __fastcall__ utoa (unsigned val, char* buf, int radix);/
6238 <tag/Description/<tt/itoa/ converts the unsigned integer <tt/val/ into a string
6239 using <tt/radix/ as the base.
6240 <tag/Limits/<itemize>
6241 <item>There are no provisions to prevent a buffer overflow.
6242 <item>The function is non standard, so it is not available in strict ANSI mode.
6243 You should probably use <tt/sprintf/ instead.
6244 <item>The function is only available as fastcall function, so it may only be
6245 used in presence of a prototype.
6247 <tag/Availability/cc65
6249 <ref id="atoi" name="atoi">,
6250 <ref id="atol" name="atol">,
6251 <ref id="itoa" name="itoa">,
6252 <ref id="ltoa" name="ltoa">,
6253 <ref id="ultoa" name="ultoa">
6259 <sect1>vcprintf<label id="vcprintf"><p>
6263 <tag/Function/Formatted output to the console.
6264 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
6265 <tag/Declaration/<tt/int __fastcall__ vcprintf (const char* format, va_list ap);/
6266 <tag/Description/The arguments specified as a <tt/va_list/ are converted to
6267 text where necessary and formatted according to the format string given. The
6268 resulting string is output to the console. <tt/vcprintf/ supports the same
6269 format specifiers as <tt/vprintf/. <!-- <tt/<ref id="vprintf" name="vprintf">/. -->
6270 <tag/Limits/<itemize>
6271 <item>Like all other <tt/conio/ output functions, <tt/vcprintf/ distinguishes
6272 between <tt/\r/ and <tt/\n/.
6273 <item>The function is only available as fastcall function, so it may only be
6274 used in presence of a prototype.
6276 <tag/Availability/cc65
6278 <ref id="cprintf" name="cprintf">,
6279 <ref id="cputc" name="cputc">,
6280 <ref id="cputcxy" name="cputcxy">,
6281 <ref id="cputs" name="cputs">,
6282 <ref id="cputsxy" name="cputsxy">
6288 <sect1>videomode<label id="videomode"><p>
6292 <tag/Function/Switch to either 40 or 80 column mode.
6293 <tag/Header/<tt/<ref id="apple2enh.h" name="apple2enh.h">,
6294 <ref id="c128.h" name="c128.h">/
6295 <tag/Declaration/<tt/unsigned __fastcall__ videomode (unsigned Mode);/
6296 <tag/Description/Switch to 40 or 80 column mode depending on the argument. If
6297 the requested mode is already active, nothing happens. The old mode is returned
6299 <tag/Limits/<itemize>
6300 <item>The function is specific to the C128 and enhanced Apple //e.
6301 <item>This function replaces <ref id="toggle_videomode"
6302 name="toggle_videomode">.
6303 <item>The function is only available as fastcall function, so it may only be
6304 used in presence of a prototype.
6306 <tag/Availability/C128 and enhanced Apple //e
6308 <ref id="fast" name="fast">,
6309 <ref id="slow" name="slow">,
6310 <ref id="toggle_videomode" name="toggle_videomode">
6316 <sect1>wherex<label id="wherex"><p>
6320 <tag/Function/Return the current X position of the text mode cursor.
6321 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
6322 <tag/Declaration/<tt/unsigned char wherex (void);/
6323 <tag/Description/The function returns the current X position of the text mode
6324 cursor. Zero is returned for the leftmost screen position.
6325 <tag/Availability/cc65
6327 <ref id="gotox" name="gotox">,
6328 <ref id="gotoy" name="gotoy">,
6329 <ref id="gotoxy" name="gotoxy">,
6330 <ref id="wherey" name="wherey">
6336 <sect1>wherey<label id="wherey"><p>
6340 <tag/Function/Return the current Y position of the text mode cursor.
6341 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
6342 <tag/Declaration/<tt/unsigned char wherey (void);/
6343 <tag/Description/The function returns the current Y position of the text mode
6344 cursor. Zero is returned for the uppermost screen position.
6345 <tag/Availability/cc65
6347 <ref id="gotox" name="gotox">,
6348 <ref id="gotoy" name="gotoy">,
6349 <ref id="gotoxy" name="gotoxy">,
6350 <ref id="wherex" name="wherex">