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_done" name="tgi_done">
514 <item><ref id="tgi_ellipse" name="tgi_ellipse">
515 <item><ref id="tgi_getaspectratio" name="tgi_getaspectratio">
516 <item><ref id="tgi_getcolor" name="tgi_getcolor">
517 <item><ref id="tgi_getcolorcount" name="tgi_getcolorcount">
518 <item><ref id="tgi_getdefpalette" name="tgi_getdefpalette">
519 <item><ref id="tgi_geterror" name="tgi_geterror">
520 <item><ref id="tgi_geterrormsg" name="tgi_geterrormsg">
521 <item><ref id="tgi_getmaxcolor" name="tgi_getmaxcolor">
522 <item><ref id="tgi_getmaxx" name="tgi_getmaxx">
523 <item><ref id="tgi_getmaxy" name="tgi_getmaxy">
524 <item><ref id="tgi_getpagecount" name="tgi_getpagecount">
525 <item><ref id="tgi_getpalette" name="tgi_getpalette">
526 <item><ref id="tgi_getpixel" name="tgi_getpixel">
527 <item><ref id="tgi_getxres" name="tgi_getxres">
528 <item><ref id="tgi_getyres" name="tgi_getyres">
529 <item><ref id="tgi_gotoxy" name="tgi_gotoxy">
530 <item><ref id="tgi_init" name="tgi_init">
531 <item><ref id="tgi_install" name="tgi_install">
532 <item><ref id="tgi_ioctl" name="tgi_ioctl">
533 <item><ref id="tgi_line" name="tgi_line">
534 <item><ref id="tgi_lineto" name="tgi_lineto">
535 <item><ref id="tgi_load_driver" name="tgi_load_driver">
536 <item><ref id="tgi_outtext" name="tgi_outtext">
537 <item><ref id="tgi_outtextxy" name="tgi_outtextxy">
538 <item><ref id="tgi_setaspectratio" name="tgi_setaspectratio">
539 <item><ref id="tgi_setcolor" name="tgi_setcolor">
540 <item><ref id="tgi_setdrawpage" name="tgi_setdrawpage">
541 <item><ref id="tgi_setpalette" name="tgi_setpalette">
542 <item><ref id="tgi_setpixel" name="tgi_setpixel">
543 <item><ref id="tgi_setviewpage" name="tgi_setviewpage">
544 <item><ref id="tgi_gettextheight" name="tgi_gettextheight">
545 <item><ref id="tgi_settextstyle" name="tgi_settextstyle">
546 <item><ref id="tgi_gettextwidth" name="tgi_gettextwidth">
547 <item><ref id="tgi_uninstall" name="tgi_uninstall">
548 <item><ref id="tgi_unload" name="tgi_unload">
551 <sect1><tt/time.h/<label id="time.h"><p>
554 <!-- <item><ref id="_systime" name="_systime"> -->
555 <!-- <item><ref id="asctime" name="asctime"> -->
556 <!-- <item><ref id="clock" name="clock"> -->
557 <!-- <item><ref id="ctime" name="ctime"> -->
558 <!-- <item><ref id="gmtime" name="gmtime"> -->
559 <!-- <item><ref id="localtime" name="localtime"> -->
560 <!-- <item><ref id="mktime" name="mktime"> -->
561 <!-- <item><ref id="strftime" name="strftime"> -->
562 <item><ref id="time" name="time">
568 <sect1><tt/unistd.h/<label id="unistd.h"><p>
571 <!-- <item><ref id="chdir" name="chdir"> -->
572 <item><ref id="exec" name="exec">
573 <!-- <item><ref id="getcwd" name="getcwd"> -->
574 <item><ref id="getopt" name="getopt">
575 <!-- <item><ref id="lseek" name="lseek"> -->
576 <!-- <item><ref id="mkdir" name="mkdir"> -->
577 <!-- <item><ref id="read" name="read"> -->
578 <!-- <item><ref id="rmdir" name="rmdir"> -->
579 <item><ref id="sleep" name="sleep">
580 <item><ref id="unlink" name="unlink">
581 <!-- <item><ref id="write" name="write"> -->
587 <sect1><tt/vic20.h/<label id="vic20.h"><p>
592 <sect1><tt/zlib.h/<label id="zlib.h"><p>
597 <sect>Alphabetical function reference<p>
599 <sect1>_heapadd<label id="_heapadd"><p>
603 <tag/Function/Add a block to the heap.
604 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
605 <tag/Declaration/<tt/void __fastcall__ _heapadd (void* mem, size_t size);/
606 <tag/Description/The function adds a block of raw memory to the heap.
609 <item>The minimum blocksize that can be added is 6 bytes; the function will
610 ignore smaller blocks.
612 <tag/Availability/cc65
614 <ref id="_heapblocksize" name="_heapblocksize">,
615 <ref id="_heapmaxavail" name="_heapmaxavail">,
616 <ref id="_heapmemavail" name="_heapmemavail">,
617 <ref id="calloc" name="calloc">,
618 <ref id="free" name="free">,
619 <ref id="malloc" name="malloc">,
620 <ref id="realloc" name="realloc">
626 <sect1>_heapblocksize<label id="_heapblocksize"><p>
630 <tag/Function/Return the size of an allocated block.
631 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
632 <tag/Declaration/<tt/size_t __fastcall__ _heapblocksize (const void* block);/
633 <tag/Description/The function returns the size of a block that must have
634 previously been allocated by <tt/<ref id="malloc" name="malloc">/, <tt/<ref
635 id="calloc" name="calloc">/ or <tt/<ref id="realloc" name="realloc">/.
638 <item>Passing a pointer to a block that was is not the result of one of the
639 allocation functions, or that has been free'd will give unpredicable results.
641 <tag/Availability/cc65
643 <ref id="_heapadd" name="_heapadd">,
644 <ref id="_heapmaxavail" name="_heapmaxavail">,
645 <ref id="_heapmemavail" name="_heapmemavail">,
646 <ref id="calloc" name="calloc">,
647 <ref id="free" name="free">,
648 <ref id="malloc" name="malloc">,
649 <ref id="realloc" name="realloc">
655 <sect1>_heapmaxavail<label id="_heapmaxavail"><p>
659 <tag/Function/Return the largest block that is available on the heap.
660 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
661 <tag/Declaration/<tt/size_t __fastcall__ _heapmaxavail (void);/
662 <tag/Description/The function returns the size of the largest block that may
663 be allocated from the heap using <tt/<ref id="malloc" name="malloc">/.
664 <tag/Availability/cc65
666 <ref id="_heapadd" name="_heapadd">,
667 <ref id="_heapblocksize" name="_heapblocksize">,
668 <ref id="_heapmemavail" name="_heapmemavail">,
669 <ref id="calloc" name="calloc">,
670 <ref id="free" name="free">,
671 <ref id="malloc" name="malloc">,
672 <ref id="realloc" name="realloc">
678 <sect1>_heapmemavail<label id="_heapmemavail"><p>
682 <tag/Function/Return the total available space on the heap.
683 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
684 <tag/Declaration/<tt/size_t __fastcall__ _heapmemavail (void);/
685 <tag/Description/The function returns the total number of bytes available on
689 <item>This function is of less use than usually assumed, since the returned
690 heap space may be available but not in one block. So even if this function
691 says that several times more heap space is available than needed, <ref
692 id="malloc" name="malloc"> may still return <tt/NULL/.
694 <tag/Availability/cc65
696 <ref id="_heapadd" name="_heapadd">,
697 <ref id="_heapblocksize" name="_heapblocksize">,
698 <ref id="_heapmaxavail" name="_heapmaxavail">,
699 <ref id="calloc" name="calloc">,
700 <ref id="free" name="free">,
701 <ref id="malloc" name="malloc">,
702 <ref id="realloc" name="realloc">
708 <sect1>_poserror<label id="_poserror"><p>
712 <tag/Function/Print an error message for the error in <tt/_oserror/.
713 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
714 <tag/Declaration/<tt/void __fastcall__ _poserror (const char* msg);/
715 <tag/Description/<tt/_poserror/ prints an error message to <tt/stderr/. If
716 <tt/msg/ is not <tt/NULL/ and not an empty string, it is printed followed by
717 a colon and a blank. Then the error message for the current contents of
718 <tt/_oserror/ are printed followed by a newline. The message output is the
719 same as returned by <tt/<ref id="_stroserror" name="_stroserror">/ with an
720 argument of <tt/_oserror/.
723 <item>Since operating system specific error code are - you guessed it -
724 operating system specific, the value in <tt/_oserror/ and the message that is
725 printed depends on the cc65 target.
726 <item>The function is only available as fastcall function, so it may only
727 be used in presence of a prototype.
729 <tag/Availability/cc65
731 <ref id="_stroserror" name="_stroserror">,
732 <ref id="perror" name="perror">
738 <sect1>_randomize<label id="_randomize"><p>
742 <tag/Function/Initialize the pseudo random number generator.
743 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
744 <tag/Declaration/<tt/void _randomize (void);/
745 <tag/Description/The function initializes the random number generator with
746 a seed derived from fast changing hardware events, so the seed itself can be
747 considered random to a certain degree.
748 <tag/Limits/<itemize>
749 <item>The randomness of the seed depends on the machine hardware.
751 <tag/Availability/cc65
753 <ref id="rand" name="rand">,
754 <ref id="srand" name="srand">
760 <sect1>_stroserror<label id="_stroserror"><p>
764 <tag/Function/Return a string describing an OS specific error code.
765 <tag/Header/<tt/<ref id="string.h" name="string.h">/
766 <tag/Declaration/<tt/const char* __fastcall__ _stroserror (unsigned char errcode);/
767 <tag/Description/<tt/_stroserror/ will return a string describing the given
768 operating system specific error code.
769 <tag/Limits/<itemize>
770 <item>Since operating system specific error code are - you guessed it -
771 operating system specific, the parameter and the string returned depend on the
773 <item>The function is only available as fastcall function, so it may only be
774 used in presence of a prototype.
776 <tag/Availability/cc65
778 <ref id="strerror" name="strerror">
784 <sect1>_swap<label id="_swap"><p>
788 <tag/Function/Swap the contents of memory areas.
789 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
790 <tag/Declaration/<tt/void __fastcall__ _swap (void* p, void* q, size_t size);/
791 <tag/Description/<tt/_swap/ will swap (exchange) the contents of the two memory
792 areas pointed to by <tt/p/ and <tt/q/. Both memory areas are assumed to be
793 <tt/size/ bytes in size.
794 <tag/Limits/<itemize>
795 <item>The memory areas may not overlap, otherwise the results are undefined.
796 <item>The function is only available as fastcall function, so it may only be
797 used in presence of a prototype.
799 <tag/Availability/cc65
801 <ref id="memcpy" name="memcpy">,
802 <ref id="memmove" name="memmove">
808 <sect1>_sys<label id="_sys"><p>
812 <tag/Function/Call a subroutine passing register values.
813 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
814 <tag/Declaration/<tt/void __fastcall__ _sys (struct regs* r);/
815 <tag/Description/The function will call the subroutine at the address
816 specified in the <tt/pc/ member of the passed <tt/regs/ structure. All
817 registers and the CPU flags are set to the values given in the <tt/regs/
818 structure. On return from the subroutine, the new values of the registers and
819 flags are stored back overwriting the old values.
820 <tag/Limits/<itemize>
821 <item>Bits 4 and 5 of the flags value in the <tt/regs/ structure are ignored
822 when calling the subroutine (they are unchanged from their current values).
823 <item>The function is only available as fastcall function, so it may only be
824 used in presence of a prototype.
826 <tag/Availability/cc65
832 <sect1>BRK<label id="BRK"><p>
836 <tag/Function/Insert a 6502 BRK instrunction into the code.
837 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
838 <tag/Declaration/<tt/void BRK (void);/
839 <tag/Description/The function will insert a 6502 BRK instruction into the code
840 which may be used to trigger a debugger.
841 <tag/Limits/<itemize>
842 <item>The function is actually a macro.
843 <item>The inserted instruction may lead to unexpected results if no debugger
846 <tag/Availability/cc65
848 <ref id="CLI" name="CLI">,
849 <ref id="SEI" name="SEI">
855 <sect1>CLI<label id="CLI"><p>
859 <tag/Function/Insert a 6502 CLI instrunction into the code.
860 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
861 <tag/Declaration/<tt/void CLI (void);/
862 <tag/Description/The function will insert a 6502 CLI instruction into the code,
863 so interrupts are enabled. Enabling interrupts has no effects if they are
864 already enabled (the default).
865 <tag/Limits/<itemize>
866 <item>The function is actually a macro.
867 <item>Disabling interrupts may lead to unexpected results.
869 <tag/Availability/cc65
871 <ref id="BRK" name="BRK">,
872 <ref id="SEI" name="SEI">
878 <sect1>PEEK<label id="PEEK"><p>
882 <tag/Function/Read a byte from memory.
883 <tag/Header/<tt/<ref id="peekpoke.h" name="peekpoke.h">/
884 <tag/Declaration/<tt/unsigned char PEEK (unsigned addr);/
885 <tag/Description/The function will read the absolute memory given by <tt/addr/
886 and return the value read.
887 <tag/Limits/<itemize>
888 <item>The function is actually a macro.
889 <item>This function depends highly on the platform and environment.
891 <tag/Availability/cc65
893 <ref id="PEEKW" name="PEEKW">,
894 <ref id="POKE" name="POKE">
900 <sect1>PEEKW<label id="PEEKW"><p>
904 <tag/Function/Read a word (two bytes) from memory.
905 <tag/Header/<tt/<ref id="peekpoke.h" name="peekpoke.h">/
906 <tag/Declaration/<tt/unsigned PEEKW (unsigned addr);/
907 <tag/Description/The function will read the absolute memory given by <tt/addr/
908 and return the value read. The byte read from the higher address is the high
909 byte of the return value.
910 <tag/Limits/<itemize>
911 <item>The function is actually a macro.
912 <item>This function depends highly on the platform and environment.
913 <item>The order in which the two bytes are read is unspecified and may
914 depend of the address expression used.
916 <tag/Availability/cc65
918 <ref id="PEEK" name="PEEK">,
919 <ref id="POKE" name="POKE">
925 <sect1>POKE<label id="POKE"><p>
929 <tag/Function/Write a byte to memory.
930 <tag/Header/<tt/<ref id="peekpoke.h" name="peekpoke.h">/
931 <tag/Declaration/<tt/void POKE (unsigned addr, unsigned char val);/
932 <tag/Description/The function writes the value <tt/val/ to the absolute
933 memory address given by <tt/addr/.
934 <tag/Limits/<itemize>
935 <item>The function is actually a macro.
936 <item>This function depends highly on the platform and environment.
937 <item>Careless use will cause the program to act strange or may crash the
940 <tag/Availability/cc65
942 <ref id="PEEK" name="PEEK">,
943 <ref id="POKEW" name="POKEW">
949 <sect1>POKEW<label id="POKEW"><p>
953 <tag/Function/Write a word (two bytes) to memory.
954 <tag/Header/<tt/<ref id="peekpoke.h" name="peekpoke.h">/
955 <tag/Declaration/<tt/void POKEW (unsigned addr, unsigned val);/
956 <tag/Description/The function writes the value <tt/val/ to the absolute
957 memory address given by <tt/addr/. The low byte of <tt/val/ is written to
958 the <tt/addr/, the high byte is written to <tt/addr+1/.
959 <tag/Limits/<itemize>
960 <item>The function is actually a macro.
961 <item>This function depends highly on the platform and environment.
962 <item>Careless use will cause the program to act strange or may crash the
964 <item>The order in which the two bytes are written is unspecified and may
965 depend of the address expression used.
967 <tag/Availability/cc65
969 <ref id="PEEK" name="PEEK">,
970 <ref id="POKE" name="POKE">
976 <sect1>SEI<label id="SEI"><p>
980 <tag/Function/Insert a 6502 SEI instrunction into the code.
981 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
982 <tag/Declaration/<tt/void SEI (void);/
983 <tag/Description/The function will insert a 6502 SEI instruction into the code,
984 so interrupts are disabled. Note that non maskable interrupts cannot be
986 <tag/Limits/<itemize>
987 <item>The function is actually a macro.
988 <item>Disabling interrupts may lead to unexpected results.
990 <tag/Availability/cc65
992 <ref id="BRK" name="BRK">,
993 <ref id="CLI" name="CLI">
999 <sect1>abort<label id="abort"><p>
1003 <tag/Function/Terminates a program abnormally.
1004 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1005 <tag/Declaration/<tt/void abort (void);/
1006 <tag/Description/<tt/abort/ raises <tt/SIGABRT/, writes a termination message
1007 on stderr, then terminates the program with an exit code of 3.
1008 <tag/Availability/ISO 9899
1010 <ref id="assert" name="assert">,
1011 <ref id="exit" name="exit">,
1012 <ref id="raise" name="raise">
1018 <sect1>abs<label id="abs"><p>
1022 <tag/Function/Returns the absolute value of an integer.
1023 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1024 <tag/Declaration/<tt/int __fastcall__ abs (int v);/
1025 <tag/Description/<tt/abs/ returns the absolute value of the argument passed to
1027 <tag/Limits/<itemize>
1028 <item>The return value is undefined if <tt/INT_MIN/ is passed to the function.
1029 <item>The function is only available as fastcall function, so it may only be
1030 used in presence of a prototype.
1032 <tag/Availability/ISO 9899
1034 <ref id="labs" name="labs">
1040 <sect1>assert<label id="assert"><p>
1044 <tag/Function/Test a condition and possibly abort.
1045 <tag/Header/<tt/<ref id="assert.h" name="assert.h">/
1046 <tag/Declaration/<tt/void assert (int cond);/
1047 <tag/Description/<tt/assert/ is a macro that expands to a <tt/id/
1048 statement. If the condition evaluates t zero (false), assert prints a message
1049 on stderr and aborts the program.
1050 <tag/Limits/<itemize>
1051 <item>The function is actually a macro.
1053 <tag/Availability/ISO 9899
1055 <ref id="abort" name="abort">,
1056 <ref id="exit" name="exit">
1062 <sect1>atexit<label id="atexit"><p>
1066 <tag/Function/Register an exit function.
1067 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1068 <tag/Declaration/<tt/int __fastcall__ atexit (void (*exitfunc) (void));/
1069 <tag/Description/<tt/atexit/ registers the function pointed to by
1070 <tt/exitfunc/ as an exit function. Exit functions are called when the program
1071 terminates, they are called in LIFO order (the last function registered is
1072 called first). <tt/atexit/ returns zero on success and a nonzero value on
1074 <tag/Limits/<itemize>
1075 <item>A maximum of 5 exit functions can be registered.
1076 <item>There is no way to unregister an exit function.
1077 <item>The function is only available as fastcall function, so it may only be
1078 used in presence of a prototype.
1080 <tag/Availability/ISO 9899
1082 <ref id="abort" name="abort">,
1083 <ref id="exit" name="exit">
1089 <sect1>atoi<label id="atoi"><p>
1093 <tag/Function/Convert a string to an integer.
1094 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1095 <tag/Declaration/<tt/int __fastcall__ atoi (const char* s);/
1096 <tag/Description/<tt/atoi/ converts the given string into an integer.
1097 Conversion stops as soon as any invalid character is encountered.
1098 <tag/Limits/<itemize>
1099 <item>There is no way to detect any conversion errors.
1100 <item>The function does not check for an numerical overflow when converting.
1101 <item>The function is only available as fastcall function, so it may only be
1102 used in presence of a prototype.
1104 <tag/Availability/ISO 9899
1106 <ref id="atol" name="atol">,
1107 <ref id="itoa" name="itoa">,
1108 <ref id="ltoa" name="ltoa">,
1109 <ref id="ultoa" name="ultoa">,
1110 <ref id="utoa" name="utoa">
1116 <sect1>atol<label id="atol"><p>
1120 <tag/Function/Convert a string to a long integer.
1121 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1122 <tag/Declaration/<tt/long __fastcall__ atol (const char* s);/
1123 <tag/Description/<tt/atol/ converts the given string into a long integer.
1124 Conversion stops as soon as any invalid character is encountered.
1125 <tag/Limits/<itemize>
1126 <item>There is no way to detect any conversion errors.
1127 <item>The function does not check for an numerical overflow when converting.
1128 <item>The function is only available as fastcall function, so it may only be
1129 used in presence of a prototype.
1131 <tag/Availability/ISO 9899
1133 <ref id="atoi" name="atoi">,
1134 <ref id="itoa" name="itoa">,
1135 <ref id="ltoa" name="ltoa">,
1136 <ref id="ultoa" name="ultoa">,
1137 <ref id="utoa" name="utoa">
1143 <sect1>bgcolor<label id="bgcolor"><p>
1147 <tag/Function/Set the background text color.
1148 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1149 <tag/Declaration/<tt/unsigned char __fastcall__ bgcolor (unsigned char color);/
1150 <tag/Description/The function will set a new background color and return the
1151 old (current) one. The background color is valid for the whole text output
1152 area of the screen, not just for new text.
1153 <tag/Limits/<itemize>
1154 <item>Background colors are system dependent. The function may have no effect
1155 on systems where the background color cannot be changed.
1156 <item>The function is only available as fastcall function, so it may only be
1157 used in presence of a prototype.
1159 <tag/Availability/cc65
1161 <ref id="bordercolor" name="bordercolor">,
1162 <ref id="textcolor" name="textcolor">
1168 <sect1>bordercolor<label id="bordercolor"><p>
1172 <tag/Function/Set the border (frame) color.
1173 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1174 <tag/Declaration/<tt/unsigned char __fastcall__ bordercolor (unsigned char color);/
1175 <tag/Description/The function will set a new border color. It returns the old
1176 (current) border color.
1177 <tag/Limits/<itemize>
1178 <item>Border colors are system dependent. The function may have no effect
1179 on systems where the border color cannot be changed.
1180 <item>The function is only available as fastcall function, so it may only
1181 be used in presence of a prototype.
1183 <tag/Availability/cc65
1185 <ref id="bgcolor" name="bgcolor">,
1186 <ref id="textcolor" name="textcolor">
1192 <sect1>bsearch<label id="bsearch"><p>
1196 <tag/Function/Do a binary search in a sorted array.
1197 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1198 <tag/Declaration/<tt/void* __fastcall__ bsearch (const void* key,
1199 const void* base, size_t n, size_t size,
1200 int (*cmp) (const void*, const void*));/
1201 <tag/Description/<tt/bsearch/ searches a sorted array for a member that
1202 matches the one pointed to by <tt/key/. <tt/base/ is the address of the array,
1203 <tt/n/ is the number of elements, <tt/size/ the size of an element and <tt/cmp/
1204 the function used to compare the members against the key. The function returns
1205 a pointer to the member found, or <tt/NULL/ if there was no match.
1208 <item>The contents of the array must be sorted in ascending order according to
1209 the compare function given.
1210 <item>If there are multiple members that match the key, the function will
1211 return one of the members.
1212 <item>The function is only available as fastcall function, so it may only
1213 be used in presence of a prototype.
1215 <tag/Availability/ISO 9899
1217 <ref id="qsort" name="qsort">
1223 <sect1>bzero<label id="bzero"><p>
1227 <tag/Function/Fill a memory area with zeroes.
1228 <tag/Header/<tt/<ref id="string.h" name="string.h">/
1229 <tag/Declaration/<tt/void __fastcall__ bzero (void* p, size_t count);/
1230 <tag/Description/<tt/bzero/ fills the memory area pointed to by <tt/p/ with
1234 <item>The function is non standard and therefore only available in non ANSI
1235 mode. You should use <tt/<ref id="memset" name="memset">/ instead.
1236 <item>The function is only available as fastcall function, so it may only
1237 be used in presence of a prototype.
1239 <tag/Availability/cc65
1241 <ref id="_swap" name="_swap">,
1242 <ref id="memcpy" name="memcpy">,
1243 <ref id="memmove" name="memmove">,
1244 <ref id="memset" name="memset">,
1250 <sect1>c64mode<label id="c64mode"><p>
1254 <tag/Function/Switch the C128 into C64 compatible mode.
1255 <tag/Header/<tt/<ref id="c128.h" name="c128.h">/
1256 <tag/Declaration/<tt/void c64mode (void);/
1257 <tag/Description/The function will cause the machine to reboot into C64 mode.
1258 <tag/Limits/<itemize>
1259 <item>The function is specific to the C128.
1260 <item>The function will not return to the caller.
1262 <tag/Availability/C128
1268 <sect1>calloc<label id="calloc"><p>
1272 <tag/Function/Allocate and clear memory.
1273 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1274 <tag/Declaration/<tt/void* __fastcall__ calloc (size_t n, size_t size);/
1275 <tag/Description/<tt/calloc/ allocates memory for an array of <tt/n/ elements
1276 of size <tt/size/, clears the whole block with binary zeroes and returns a
1277 pointer to it. On error (not enough memory available), <tt/calloc/ returns
1281 <item>Clearing the memory may not have the expected effect on all platforms:
1282 pointers in the block may not be <tt/NULL/ and floating point variables may
1283 not be zero (0.0). In other words: The "clearing" effect of this function
1284 should be used with care for portable programs.
1285 <item>The function is only available as fastcall function, so it may only
1286 be used in presence of a prototype.
1288 <tag/Availability/ISO 9899
1290 <ref id="_heapadd" name="_heapadd">,
1291 <ref id="_heapblocksize" name="_heapblocksize">,
1292 <ref id="_heapmaxavail" name="_heapmaxavail">,
1293 <ref id="_heapmemavail" name="_heapmemavail">,
1294 <ref id="free" name="free">,
1295 <ref id="malloc" name="malloc">,
1296 <ref id="realloc" name="realloc">
1302 <sect1>cclear<label id="cclear"><p>
1306 <tag/Function/Clear part of a line (write a given number of spaces).
1307 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1308 <tag/Declaration/<tt/void __fastcall__ cclear (unsigned char length);/
1309 <tag/Description/The function clears part of a line by writing <tt/length/
1310 spaces in the current text color.
1311 <tag/Limits/<itemize>
1312 <item>The function is only available as fastcall function, so it may
1313 only be used in presence of a prototype.
1315 <tag/Availability/cc65
1317 <ref id="cclearxy" name="cclearxy">,
1318 <ref id="clrscr" name="clrscr">
1324 <sect1>cclearxy<label id="cclearxy"><p>
1328 <tag/Function/Clear part of a line (write a given number of spaces) starting
1329 at a specific screen position.
1330 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1331 <tag/Declaration/<tt/void __fastcall__ cclearxy (unsigned char x, unsigned char y, unsigned char length);/
1332 <tag/Description/The function moves the cursor to a specific position, and
1333 will then clear part of the line by writing <tt/length/ spaces in the current
1335 <tag/Limits/<itemize>
1336 <item>The function is only available as fastcall function, so it may
1337 only be used in presence of a prototype.
1339 <tag/Availability/cc65
1341 <ref id="cclear" name="cclear">,
1342 <ref id="clrscr" name="clrscr">
1348 <sect1>cgetc<label id="cgetc"><p>
1352 <tag/Function/Read a character from the keyboard.
1353 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1354 <tag/Declaration/<tt/char cgetc (void);/
1355 <tag/Description/The function reads a character from the keyboard. If there is
1356 no character available, <tt/cgetc/ waits until the user presses a key. If the
1357 cursor is enabled by use of the <tt/cursor/ function, a blinking cursor is
1358 displayed while waiting.
1359 <tag/Limits/<itemize>
1360 <item>If the system supports a keyboard buffer, <tt/cgetc/ will fetch a key
1361 from this buffer and wait only if the buffer is empty.
1363 <tag/Availability/cc65
1365 <ref id="cursor" name="cursor">,
1366 <ref id="kbhit" name="kbhit">
1372 <sect1>chline<label id="chline"><p>
1376 <tag/Function/Output a horizontal line in text mode.
1377 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1378 <tag/Declaration/<tt/void __fastcall__ chline (unsigned char length);/
1379 <tag/Description/The function outputs a horizontal line with the given length
1380 starting at the current cursor position.
1381 <tag/Limits/<itemize>
1382 <item>The character used to draw the horizontal line is system dependent.
1383 If available, a line drawing character is used. Drawing a line that is partially
1384 off screen leads to undefined behaviour.
1385 <item>The function is only available as fastcall function, so it may only be
1386 used in presence of a prototype.
1388 <tag/Availability/cc65
1390 <ref id="chlinexy" name="chlinexy">,
1391 <ref id="cvline" name="cvline">,
1392 <ref id="cvlinexy" name="cvlinexy">
1398 <sect1>chlinexy<label id="chlinexy"><p>
1402 <tag/Function/Output a horizontal line at a given position in text mode.
1403 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1404 <tag/Declaration/<tt/void __fastcall__ chlinexy (unsigned char x, unsigned char y, unsigned char length);/
1405 <tag/Description/The function outputs a horizontal line with the given length
1406 starting at a given position.
1407 <tag/Limits/<itemize>
1408 <item>The character used to draw the horizontal line is system dependent.
1409 If available, a line drawing character is used. Drawing a line that is partially
1410 off screen leads to undefined behaviour.
1411 <item>The function is only available as fastcall function, so it may only be
1412 used in presence of a prototype.
1414 <tag/Availability/cc65
1416 <ref id="chline" name="chline">,
1417 <ref id="cvline" name="cvline">,
1418 <ref id="cvlinexy" name="cvlinexy">
1424 <sect1>clearerr<label id="clearerr"><p>
1428 <tag/Function/Clear error and end-of-file status of a stream.
1429 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
1430 <tag/Declaration/<tt/void __fastcall__ clearerr (FILE* f);/
1431 <tag/Description/<tt/clearerr/ clears the error and end-of-file status
1432 indicators for the stream <tt/f/.
1433 <tag/Limits/<itemize>
1434 <item>The function is only available as fastcall function, so it may only be
1435 used in presence of a prototype.
1437 <tag/Availability/ISO 9899
1439 <ref id="feof" name="feof">,
1440 <ref id="ferror" name="ferror">
1446 <sect1>clrscr<label id="clrscr"><p>
1450 <tag/Function/Clear the text screen.
1451 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1452 <tag/Declaration/<tt/void clrscr (void);/
1453 <tag/Description/The function clears the text screen and moves the cursor to
1454 the upper left corner.
1455 <tag/Availability/cc65
1457 <ref id="cclear" name="cclear">,
1458 <ref id="cclearxy" name="cclearxy">
1464 <sect1>close<label id="close"><p>
1468 <tag/Function/Close a file descriptor.
1469 <tag/Header/<tt/<ref id="fcntl.h" name="fcntl.h">/
1470 <tag/Declaration/<tt/int __fastcall__ close (int fd);/
1471 <tag/Description/The function closes the given file descriptor. It returns zero
1472 on success and -1 on error. If an error occurs, the cause can be determined by
1473 reading the <tt/errno/ variable.
1474 <tag/Limits/<itemize>
1475 <item>The function is only available as fastcall function, so it may only
1476 be used in presence of a prototype.
1478 <tag/Availability/POSIX 1003.1
1480 <ref id="creat" name="creat">,
1481 <ref id="open" name="open">
1487 <sect1>creat<label id="creat"><p>
1491 <tag/Function/Create a file.
1492 <tag/Header/<tt/<ref id="fcntl.h" name="fcntl.h">/
1493 <tag/Declaration/<tt/int __fastcall__ creat (const char* name, unsigned mode);/
1494 <tag/Description/<tt/creat/ creates a new file and returns the file descriptor
1495 associated with it. On error, -1 is returned and an error code is stored in
1497 <tag/Limits/<itemize>
1498 <item><tt/creat/ is identical to calling <tt/<ref id="open" name="open">/ with
1499 <tt/flags/ equal to <tt/O_WRONLY | O_CREAT | O_TRUNC/.
1500 <item>The function is only available as fastcall function, so it may only
1501 be used in presence of a prototype.
1503 <tag/Availability/POSIX 1003.1
1505 <ref id="close" name="close">,
1506 <ref id="open" name="open">
1512 <sect1>cprintf<label id="cprintf"><p>
1516 <tag/Function/Formatted output to the console.
1517 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1518 <tag/Declaration/<tt/int cprintf (const char* format, ...);/
1519 <tag/Description/The arguments are converted to text where necessary and
1520 formatted according to the format string given. The resulting string is output
1521 to the console. <tt/cprintf/ supports the same format specifiers as
1522 <tt/printf/. <!-- <tt/<ref id="printf" name="printf">/. -->
1523 <tag/Limits/<itemize>
1524 <item>Like all other <tt/conio/ output functions, <tt/cprintf/ distinguishes
1525 between <tt/\r/ and <tt/\n/.
1527 <tag/Availability/cc65
1529 <ref id="cputc" name="cputc">,
1530 <ref id="cputcxy" name="cputcxy">,
1531 <ref id="cputs" name="cputs">,
1532 <ref id="cputsxy" name="cputsxy">,
1533 <ref id="vcprintf" name="vcprintf">
1539 <sect1>cputc<label id="cputc"><p>
1543 <tag/Function/Output a character directly to the console.
1544 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1545 <tag/Declaration/<tt/void __fastcall__ cputc (char c);/
1546 <tag/Description/Output one character to the console at the current cursor
1548 <tag/Limits/<itemize>
1549 <item>Like all other <tt/conio/ output functions, <tt/cputc/ distinguishes
1550 between <tt/\r/ and <tt/\n/.
1551 <item>The function is only available as fastcall function, so it may only
1552 be used in presence of a prototype.
1554 <tag/Availability/cc65
1556 <ref id="cprintf" name="cprintf">,
1557 <ref id="cputcxy" name="cputcxy">,
1558 <ref id="cputs" name="cputs">,
1559 <ref id="cputsxy" name="cputsxy">,
1560 <ref id="vcprintf" name="vcprintf">
1566 <sect1>cputcxy<label id="cputcxy"><p>
1570 <tag/Function/Output a character at a specific screen position.
1571 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1572 <tag/Declaration/<tt/void __fastcall__ cputcxy (unsigned char x, unsigned char y, char c);/
1573 <tag/Description/<tt/cputcxy/ moves the cursor to the given x/y position on
1574 the screen and outputs one character.
1575 <tag/Limits/<itemize>
1576 <item>Like all other <tt/conio/ output functions, <tt/cputcxy/ distinguishes
1577 between <tt/\r/ and <tt/\n/.
1578 <item>The function is only available as fastcall function, so it may only
1579 be used in presence of a prototype.
1581 <tag/Availability/cc65
1583 <ref id="cprintf" name="cprintf">,
1584 <ref id="cputc" name="cputc">,
1585 <ref id="cputs" name="cputs">,
1586 <ref id="cputsxy" name="cputsxy">,
1587 <ref id="vcprintf" name="vcprintf">
1593 <sect1>cputs<label id="cputs"><p>
1597 <tag/Function/Output a string directly to the console.
1598 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1599 <tag/Declaration/<tt/void __fastcall__ cputs (const char* s);/
1600 <tag/Description/The function outputs the given string on the console at the
1601 current cursor position.
1602 <tag/Limits/<itemize>
1603 <item>Like all other <tt/conio/ output functions, <tt/cputs/ distinguishes
1604 between <tt/\r/ and <tt/\n/.
1605 <item>The function is only available as fastcall function, so it may only
1606 be used in presence of a prototype.
1608 <tag/Availability/cc65
1610 <ref id="cprintf" name="cprintf">,
1611 <ref id="cputc" name="cputc">,
1612 <ref id="cputcxy" name="cputcxy">,
1613 <ref id="cputsxy" name="cputsxy">,
1614 <ref id="vcprintf" name="vcprintf">
1620 <sect1>cputsxy<label id="cputsxy"><p>
1624 <tag/Function/Output a string to the console at a given position.
1625 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1626 <tag/Declaration/<tt/void __fastcall__ cputsxy (unsigned char x, unsigned char y, const char* s);/
1627 <tag/Description/<tt/cputsxy/ moves the cursor to the given x/y position,
1628 and outputs the string <tt/s/.
1629 <tag/Limits/<itemize>
1630 <item>Like all other <tt/conio/ output functions, <tt/cputsxy/ distinguishes
1631 between <tt/\r/ and <tt/\n/.
1632 <item>The function is only available as fastcall function, so it may only
1633 be used in presence of a prototype.
1635 <tag/Availability/cc65
1637 <ref id="cprintf" name="cprintf">,
1638 <ref id="cputc" name="cputc">,
1639 <ref id="cputcxy" name="cputcxy">,
1640 <ref id="cputs" name="cputs">,
1641 <ref id="vcprintf" name="vcprintf">
1647 <sect1>cursor<label id="cursor"><p>
1651 <tag/Function/Enable/disable a blinking cursor when waiting for keyboard input.
1652 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1653 <tag/Declaration/<tt/unsigned char __fastcall__ cursor (unsigned char onoff);/
1654 <tag/Description/If the argument to the function is non zero, a blinking cursor
1655 will be enabled when the <tt/cgetc/ function waits for input from the keyboard.
1656 If the argument is zero, <tt/cgetc/ will wait without a blinking cursor.
1657 <tag/Limits/<itemize>
1658 <item>The function is only available as fastcall function, so it may only
1659 be used in presence of a prototype.
1661 <tag/Availability/cc65
1663 <ref id="cgetc" name="cgetc">,
1664 <ref id="kbhit" name="kbhit">
1670 <sect1>cvline<label id="cvline"><p>
1674 <tag/Function/Output a vertical line in text mode.
1675 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1676 <tag/Declaration/<tt/void __fastcall__ cvline (unsigned char length);/
1677 <tag/Description/The function outputs a vertical line with the given length
1678 starting at the current cursor position.
1679 <tag/Limits/<itemize>
1680 <item>The character used to draw the vertical line is system dependent.
1681 If available, a line drawing character is used. Drawing a line that is partially
1682 off screen leads to undefined behaviour.
1683 <item>The function is only available as fastcall function, so it may only be
1684 used in presence of a prototype.
1686 <tag/Availability/cc65
1688 <ref id="chline" name="chline">,
1689 <ref id="chlinexy" name="chlinexy">,
1690 <ref id="cvlinexy" name="cvlinexy">
1696 <sect1>cvlinexy<label id="cvlinexy"><p>
1700 <tag/Function/Output a vertical line at a given position in text mode.
1701 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1702 <tag/Declaration/<tt/void __fastcall__ cvlinexy (unsigned char x, unsigned char y, unsigned char length);/
1703 <tag/Description/The function outputs a vertical line with the given length
1704 starting at a given position.
1705 <tag/Limits/<itemize>
1706 <item>The character used to draw the vertical line is system dependent.
1707 If available, a line drawing character is used. Drawing a line that is partially
1708 off screen leads to undefined behaviour.
1709 <item>The function is only available as fastcall function, so it may only be
1710 used in presence of a prototype.
1712 <tag/Availability/cc65
1714 <ref id="chline" name="chline">,
1715 <ref id="chlinexy" name="chlinexy">,
1716 <ref id="cvline" name="cvline">
1722 <sect1>div<label id="div"><p>
1726 <tag/Function/Divide two ints and return quotient and remainder.
1727 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1728 <tag/Declaration/<tt/div_t __fastcall__ div (int numer, int denom);/
1729 <tag/Description/<tt/div/ divides <tt/numer/ by <tt/denom/ and returns the
1730 quotient and remainder in a <tt/div_t/ structure.
1733 <item>The function is only available as fastcall function, so it may only
1734 be used in presence of a prototype.
1736 <tag/Availability/ISO 9899
1744 <sect1>em_commit<label id="em_commit"><p>
1748 <tag/Function/Commit changes into extended memory.
1749 <tag/Header/<tt/<ref id="em.h" name="em.h">/
1750 <tag/Declaration/<tt/void __fastcall__ em_commit (void);/
1751 <tag/Description/Commit changes in the memory window to extended storage. If
1752 the contents of the memory window have been changed, these changes may be lost
1753 if <tt/<ref id="em_map" name="em_map">/, <tt/<ref id="em_use" name="em_use">/,
1754 <tt/<ref id="em_copyfrom" name="em_copyfrom">/ or <tt/<ref id="em_copyto"
1755 name="em_copyto">/ are called without calling <tt/em_commit/ first.
1756 <tag/Limits/<itemize>
1757 <item>Calling <tt/em_commit/ does not necessarily mean that changes to the
1758 memory window are discarded, it does just mean that the drivers is allowed
1760 <item>The function is only available as fastcall function, so it may only be
1761 used in presence of a prototype.
1762 <item>The function produces undefined results if no extended memory driver is
1765 <tag/Availability/cc65
1767 <ref id="em_load_driver" name="em_load_driver">,
1768 <ref id="em_map" name="em_map">,
1769 <ref id="em_use" name="em_use">
1775 <sect1>em_copyfrom<label id="em_copyfrom"><p>
1779 <tag/Function/Copy from extended into normal memory.
1780 <tag/Header/<tt/<ref id="em.h" name="em.h">/
1781 <tag/Declaration/<tt/void __fastcall__ em_copyfrom (const struct em_copy* copy_data);/
1782 <tag/Description/Copy data from extended memory into linear memory. Source and
1783 target addresses as well as the number of bytes to transfer are specified in
1784 the <tt/em_copy/ structure that is passed as a parameter.
1785 <tag/Limits/<itemize>
1786 <item>Calling <tt/em_copyfrom/ will invalidate the memory window, so if you
1787 made any changes to the data in the window, call <tt/<ref id="em_commit"
1788 name="em_commit">/ first, or the changes are lost.
1789 <item>The function is only available as fastcall function, so it may only be
1790 used in presence of a prototype.
1791 <item>The function produces undefined results if no extended memory driver is
1794 <tag/Availability/cc65
1796 <ref id="em_commit" name="em_commit">,
1797 <ref id="em_copyto" name="em_copyto">,
1798 <ref id="em_load_driver" name="em_load_driver">
1804 <sect1>em_copyto<label id="em_copyto"><p>
1808 <tag/Function/Copy from normal into extended memory.
1809 <tag/Header/<tt/<ref id="em.h" name="em.h">/
1810 <tag/Declaration/<tt/void __fastcall__ em_copyto (const struct em_copy* copy_data);/
1811 <tag/Description/Copy data from linear into extended memory. Source and
1812 target addresses as well as the number of bytes to transfer are specified in
1813 the <tt/em_copy/ structure that is passed as a parameter.
1814 <tag/Limits/<itemize>
1815 <item>Calling <tt/em_copyto/ will invalidate the memory window, so if you
1816 made any changes to the data in the window, call <tt/<ref id="em_commit"
1817 name="em_commit">/ first, or the changes are lost.
1818 <item>The function is only available as fastcall function, so it may only be
1819 used in presence of a prototype.
1820 <item>The function produces undefined results if no extended memory driver is
1823 <tag/Availability/cc65
1825 <ref id="em_commit" name="em_commit">,
1826 <ref id="em_copyfrom" name="em_copyfrom">,
1827 <ref id="em_load_driver" name="em_load_driver">
1833 <sect1>em_install<label id="em_install"><p>
1837 <tag/Function/Install an already loaded extended memory driver.
1838 <tag/Header/<tt/<ref id="em.h" name="em.h">/
1839 <tag/Declaration/<tt/unsigned char _fastcall__ em_install (void* driver);/
1840 <tag/Description/The function installs an already loaded extended memory driver
1841 and returns an error code. The function may be used to install a driver linked
1842 statically to the program.
1843 <tag/Limits/<itemize>
1844 <item>Not all drivers are able to detect if the supported hardware is really
1846 <item>The function is only available as fastcall function, so it may only be
1847 used in presence of a prototype.
1849 <tag/Availability/cc65
1851 <ref id="em_load_driver" name="em_load_driver">,
1852 <ref id="em_uninstall" name="em_uninstall">,
1853 <ref id="em_unload" name="em_unload">
1859 <sect1>em_load_driver<label id="em_load_driver"><p>
1863 <tag/Function/Load and initialize an extended memory driver.
1864 <tag/Header/<tt/<ref id="em.h" name="em.h">/
1865 <tag/Declaration/<tt/void __fastcall__ em_load_driver (const char* name);/
1866 <tag/Description/Load an extended memory driver into memory and initialize
1867 it. The function returns an error code that tells if all this has been
1869 <tag/Limits/<itemize>
1870 <item>Not all drivers are able to detect if the supported hardware is really
1872 <item>The function is only available as fastcall function, so it may only be
1873 used in presence of a prototype.
1874 <item>The driver is loaded by name, so currently you must know the type of
1875 extended memory that should be supported. There is no autodetect capability.
1877 <tag/Availability/cc65
1879 <ref id="em_unload" name="em_unload">
1885 <sect1>em_map<label id="em_map"><p>
1889 <tag/Function/Make a page of extended memory accessible.
1890 <tag/Header/<tt/<ref id="em.h" name="em.h">/
1891 <tag/Declaration/<tt/void* __fastcall__ em_map (unsigned page);/
1892 <tag/Description/The function maps one page of extended memory into linear
1893 memory and returns a pointer to the page frame. Depending on the hardware
1894 and driver, the data is either mapped into the address space or transfered
1895 into a buffer. If you don't need the actual contents of the page (for example
1896 because you're going to overwrite it completely), it is better to call
1897 <tt/<ref id="em_use" name="em_use">/ instead. <tt/em_use/ will not transfer the
1898 data if it is possible to avoid that.
1899 <tag/Limits/<itemize>
1900 <item>Calling <tt/em_map/ will invalidate the memory window, so if you
1901 made any changes to the data in the window, call <tt/<ref id="em_commit"
1902 name="em_commit">/ first, or the changes are lost.
1903 <item>The function is only available as fastcall function, so it may only be
1904 used in presence of a prototype.
1905 <item>The function produces undefined results if no extended memory driver is
1908 <tag/Availability/cc65
1910 <ref id="em_commit" name="em_commit">,
1911 <ref id="em_load_driver" name="em_load_driver">,
1912 <ref id="em_use" name="em_use">
1918 <sect1>em_pagecount<label id="em_pagecount"><p>
1922 <tag/Function/Return the number of available extended memory pages.
1923 <tag/Header/<tt/<ref id="em.h" name="em.h">/
1924 <tag/Declaration/<tt/unsigned __fastcall__ em_pagecount (void);/
1925 <tag/Description/The function returns the size of the extended memory supported
1926 by the driver in 256 byte pages.
1927 <tag/Limits/<itemize>
1928 <item>The function returns zero if no extended memory driver is loaded.
1929 <item>The function may return zero if the supported hardware was not detected.
1931 <tag/Availability/cc65
1933 <ref id="em_load_driver" name="em_load_driver">
1939 <sect1>em_uninstall<label id="em_uninstall"><p>
1943 <tag/Function/Uninstall an already loaded extended memory driver.
1944 <tag/Header/<tt/<ref id="em.h" name="em.h">/
1945 <tag/Declaration/<tt/unsigned char __fastcall__ em_install (void);/
1946 <tag/Description/The function uninstalls an already loaded extended memory
1947 driver but doesn't remove it from memory.
1948 <tag/Limits/<itemize>
1949 <item>If the driver has been loaded using <tt/<ref id="em_load_driver"
1950 name="em_load_driver">/, <tt/<ref id="em_unload" name="em_unload">/
1951 should be used instead of <tt/em_uninstall/ so the driver is also removed
1953 <item>The function is only available as fastcall function, so it may only be
1954 used in presence of a prototype.
1956 <tag/Availability/cc65
1958 <ref id="em_install" name="em_install">,
1959 <ref id="em_load_driver" name="em_load_driver">,
1960 <ref id="em_unload" name="em_unload">
1966 <sect1>em_unload<label id="em_unload"><p>
1970 <tag/Function/Unload an extended memory driver.
1971 <tag/Header/<tt/<ref id="em.h" name="em.h">/
1972 <tag/Declaration/<tt/unsigned char __fastcall__ em_unload (void);/
1973 <tag/Description/The function unloads a loaded extended memory driver and
1974 frees all memory allocated for the driver.
1975 <tag/Limits/<itemize>
1976 <item>The function does nothing if no driver is loaded.
1978 <tag/Availability/cc65
1980 <ref id="em_load_driver" name="em_load_driver">
1986 <sect1>em_use<label id="em_use"><p>
1990 <tag/Function/Prepare an extended memory page for use.
1991 <tag/Header/<tt/<ref id="em.h" name="em.h">/
1992 <tag/Declaration/<tt/void* __fastcall__ em_use (unsigned page);/
1993 <tag/Description/The function maps one page of extended memory into linear
1994 memory and returns a pointer to the page frame. This function is similar to
1995 <tt/<ref id="em_map" name="em_map">/, but will not transfer data into the
1996 actual memory window in the assumption that the existing data is wrong or
1997 will get overwritten.
1998 <tag/Limits/<itemize>
1999 <item>Calling <tt/em_use/ will invalidate the memory window, so if you
2000 made any changes to the data in the window, call <tt/<ref id="em_commit"
2001 name="em_commit">/ first, or the changes are lost.
2002 <item>The function is only available as fastcall function, so it may only be
2003 used in presence of a prototype.
2004 <item>The function produces undefined results if no extended memory driver is
2007 <tag/Availability/cc65
2009 <ref id="em_commit" name="em_commit">,
2010 <ref id="em_load_driver" name="em_load_driver">,
2011 <ref id="em_map" name="em_map">
2017 <sect1>exit<label id="exit"><p>
2021 <tag/Function/Terminate the program.
2022 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
2023 <tag/Declaration/<tt/void __fastcall__ exit (int status);/
2024 <tag/Description/<tt/exit/ terminates the program. The argument specifies the
2025 return code of the program. Before termination, all files are closed, buffered
2026 output is written and any functions registered with <tt/<ref id="atexit"
2027 name="atexit">/ are called. Common values for status are <tt/EXIT_SUCCESS/ and
2028 <tt/EXIT_FAILURE/ which are also defined in <tt/<ref id="stdlib.h"
2030 <tag/Limits/<itemize>
2031 <item>The function is only available as fastcall function, so it may only
2032 be used in presence of a prototype.
2033 <item>It depends on the host machine if the program return code can be
2034 evaluated or is ignored.
2036 <tag/Availability/ISO 9899
2038 <ref id="abort" name="abort">,
2039 <ref id="exit" name="exit">
2045 <sect1>exec<label id="exec"><p>
2049 <tag/Function/Execute a program file.
2050 <tag/Header/<tt/<ref id="unistd.h" name="unistd.h">/
2051 <tag/Declaration/<tt/int __fastcall__ exec (const char* progname, const char* cmdline);/
2052 <tag/Description/<tt/exec/ replaces the currently running program by a new one.
2053 Calling <tt/exec()/ is identical to calling <tt/<ref id="exit" name="exit()">/,
2054 then loading and starting the program named in the first argument, passing
2055 the command line specified as second argument. Instead of an empty string,
2056 a <tt/NULL/ pointer may be passed as second parameter.
2057 On success, the function does not return. On failure, -1 is returned and
2058 <tt/errno/ contains an error code.
2059 <tag/Limits/<itemize>
2060 <item>The function is only available as fastcall function, so it may only
2061 be used in presence of a prototype.
2062 <item>On most platforms, the function needs to copy a small stub loader to
2063 some memory area outside the program space. This may collide with other
2064 programs. See the platform specific docs on this.
2065 <item>Because it is necessary to terminate the running program before the
2066 memory can be reused to load the new one, there is a high chance that the
2067 function may not be able to return on errors.
2068 <item>The command line is passed to the new program in the same way as cc65
2069 programs expect the command line. If the new program is not a cc65 generated
2070 program, it may not be able to read it.
2072 <tag/Availability/cc65
2074 <ref id="exit" name="exit">
2080 <sect1>fast<label id="fast"><p>
2084 <tag/Function/Switch the C128 into 2MHz mode.
2085 <tag/Header/<tt/<ref id="c128.h" name="c128.h">/
2086 <tag/Declaration/<tt/void fast (void);/
2087 <tag/Description/The function will switch the clock of the C128 to 2MHz. This
2088 will nearly double the speed compared to slow mode.
2089 <tag/Limits/<itemize>
2090 <item>The function is specific to the C128.
2091 <item>2MHz clock will not work in 40 column mode.
2093 <tag/Availability/C128
2095 <ref id="slow" name="slow">,
2096 <ref id="toggle_videomode" name="toggle_videomode">,
2097 <ref id="videomode" name="videomode">
2103 <sect1>feof<label id="feof"><p>
2107 <tag/Function/Return the end-of-file indicator of a stream.
2108 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
2109 <tag/Declaration/<tt/int __fastcall__ feof (FILE* f);/
2110 <tag/Description/<tt/feof/ tests the end-of-file indicator ofthe stream
2111 <tt/f/, and returns a non zero value if it is set.
2112 <tag/Limits/<itemize>
2113 <item>The indicator is set only after a read past the end of a file is
2115 <item>The function is only available as fastcall function, so it may only be
2116 used in presence of a prototype.
2118 <tag/Availability/ISO 9899
2120 <ref id="feof" name="clearerr">,
2121 <ref id="ferror" name="ferror">
2127 <sect1>ferror<label id="ferror"><p>
2131 <tag/Function/Return the error indicator of a stream.
2132 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
2133 <tag/Declaration/<tt/int __fastcall__ ferror (FILE* f);/
2134 <tag/Description/<tt/ferror/ tests the error indicator of the stream
2135 <tt/f/, and returns a non zero value if it is set.
2136 <tag/Limits/<itemize>
2137 <item>The function is only available as fastcall function, so it may only be
2138 used in presence of a prototype.
2140 <tag/Availability/ISO 9899
2142 <ref id="feof" name="clearerr">,
2143 <ref id="ferror" name="feof">
2149 <sect1>fileno<label id="fileno"><p>
2153 <tag/Function/Return the file handle used by a stream.
2154 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
2155 <tag/Declaration/<tt/int __fastcall__ fileno (FILE* f);/
2156 <tag/Description/The <tt/fileno/ function returns the file handle used
2157 internally by a C stream. This file handle (an integer) can be used as a
2158 handle for the POSIX input/output functions.
2159 <tag/Limits/<itemize>
2160 <item>The function is only available as fastcall function, so it may only be
2161 used in presence of a prototype.
2162 <item>Mixing C file I/O functions and POSIX file I/O functions for the same
2163 file may have unpredictable results.
2165 <tag/Availability/POSIX 1003.1
2167 <ref id="creat" name="creat">,
2168 <ref id="open" name="open"> <!-- , -->
2169 <!-- <ref id="read" name="read">, -->
2170 <!-- <ref id="write" name="write"> -->
2176 <sect1>free<label id="free"><p>
2180 <tag/Function/Free a block of dynamic memory.
2181 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
2182 <tag/Declaration/<tt/void __fastcall__ free (void* block);/
2183 <tag/Description/Free a block of dynamic memory previously allocated with
2184 <tt/<ref id="malloc" name="malloc">/, <tt/<ref id="calloc" name="calloc">/
2185 or <tt/<ref id="realloc" name="realloc">/. As an exception, if the passed
2186 pointer is <tt/NULL/, no action is performed.
2189 <item>Passing an already free'd block to <tt/free/ again will cause undefined
2190 behaviour and may crash your program.
2191 <item>The function is only available as fastcall function, so it may only
2192 be used in presence of a prototype.
2194 <tag/Availability/ISO 9899
2196 <ref id="_heapadd" name="_heapadd">,
2197 <ref id="_heapblocksize" name="_heapblocksize">,
2198 <ref id="_heapmaxavail" name="_heapmaxavail">,
2199 <ref id="_heapmemavail" name="_heapmemavail">,
2200 <ref id="calloc" name="calloc">,
2201 <ref id="malloc" name="malloc">,
2202 <ref id="realloc" name="realloc">
2208 <sect1>get_ostype<label id="get_ostype"><p>
2212 <tag/Function/The function returns the operating system, the program runs on.
2213 <tag/Header/<tt/<ref id="apple2.h" name="apple2.h">,
2214 <ref id="atari.h" name="atari.h">, <ref id="c64.h" name="c64.h">/
2215 <tag/Declaration/<tt/unsigned char get_ostype (void);/
2216 <tag/Description/<tt/get_ostype/ is machine dependent and does not exist for
2217 all supported targets. If it exists, it returns a number that identifies the
2218 operating system or machine type, the program runs on. The machine dependent
2219 header files define constants that can be used to check the return code.
2220 <tag/Limits/<itemize>
2221 <item>The function does not exist on all platforms.
2222 <item>The return codes are platform dependent.
2224 <tag/Availability/cc65 (not all platforms)
2230 <sect1>getcpu<label id="getcpu"><p>
2234 <tag/Function/Determine on which CPU the program is running.
2235 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
2236 <tag/Declaration/<tt/unsigned char getcpu (void);/
2237 <tag/Description/The function checks on which CPU the code is running. It
2238 returns one of the constants<itemize>
2240 <item><tt/CPU_65C02/
2241 <item><tt/CPU_65816/
2243 <tag/Limits/<itemize>
2244 <item>Other, more exotic CPU types are not disinguished.
2246 <tag/Availability/cc65
2252 <sect1>getenv<label id="getenv"><p>
2256 <tag/Function/Return a value from the environment.
2257 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
2258 <tag/Declaration/<tt/char* __fastcall__ getenv (const char* name);/
2259 <tag/Description/The function searches the environment for an entry that
2260 matches <tt/name/ and returns its value. The environment consists of a list
2261 of strings in the form <tt/name=value/. If there is no match, <tt/getenv/
2263 <tag/Limits/<itemize>
2264 <item>What exactly is stored in the environment depends on the machine the
2265 program is running on.
2266 <item>The function is only available as fastcall function, so it may only
2267 be used in presence of a prototype.
2269 <tag/Availability/ISO 9899
2275 <sect1>getopt<label id="getopt"><p>
2279 <tag/Function/Parse command line options.
2280 <tag/Header/<tt/<ref id="unistd.h" name="unistd.h">/
2281 <tag/Declaration/<tt/int __fastcall__ getopt (int argc, char* const* argv,
2282 const char* optstring);/
2283 <tag/Description/The function parses command line arguments, <tt/argc/ and
2284 <tt/argv/ are the argument count and array passed to <tt/main/. <tt/optstring/
2285 is a string that contains command line option characters. If a character in
2286 <tt/optstring/ is followed by a colon, the option requires an argument. An
2287 option on the command line is recognized if it is one of the option characters
2289 <tt/getopt/ must be called repeatedly. It will return each option character
2290 found on the command line and <tt/EOF/ (-1) if there is no other option. An
2291 option argument is placed in <tt/optarg/, the index of the next element on the
2292 command line to be processed is placed in <tt/optind/.
2293 <tag/Limits/<itemize>
2294 <item>The implementation will not reorder options. A non option on the command
2295 line will terminate option processing. All remaining arguments are not
2296 recognized as options, even if the start with a '-' character.
2297 <item>The function is only available as fastcall function, so it may only
2298 be used in presence of a prototype.
2300 <tag/Availability/POSIX.2
2306 <sect1>gotox<label id="gotox"><p>
2310 <tag/Function/Move the text mode cursor to a new X position.
2311 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2312 <tag/Declaration/<tt/void __fastcall__ gotox (unsigned char x);/
2313 <tag/Description/The function moves the text mode cursor to the specified X
2314 position while leaving the Y position untouched. The leftmost position on the
2315 screen has the coordinate 0.
2316 <tag/Limits/<itemize>
2317 <item>The function is only available as fastcall function, so it may
2318 only be used in presence of a prototype.
2319 <item>Invalid values for the X position (out of screen coordinates) may
2320 lead to undefined behaviour.
2322 <tag/Availability/cc65
2324 <ref id="gotoy" name="gotoy">,
2325 <ref id="gotoxy" name="gotoxy">,
2326 <ref id="wherex" name="wherex">,
2327 <ref id="wherey" name="wherey">
2333 <sect1>gotoxy<label id="gotoxy"><p>
2337 <tag/Function/Move the text mode cursor to a new position.
2338 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2339 <tag/Declaration/<tt/void __fastcall__ gotoxy (unsigned char x, unsigned char y);/
2340 <tag/Description/The function moves the text mode cursor to the specified
2341 position. The leftmost position on the screen has the X coordinate 0, the
2342 topmost line has the Y coordinate 0.
2343 <tag/Limits/<itemize>
2344 <item>The function is only available as fastcall function, so it may only be
2345 used in presence of a prototype.
2346 <item>Invalid values for any of both coordinates (out of screen positions) may
2347 lead to undefined behaviour.
2349 <tag/Availability/cc65
2351 <ref id="gotox" name="gotox">,
2352 <ref id="gotoy" name="gotoy">,
2353 <ref id="wherex" name="wherex">,
2354 <ref id="wherey" name="wherey">
2360 <sect1>gotoy<label id="gotoy"><p>
2364 <tag/Function/Move the text mode cursor to a new Y position.
2365 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2366 <tag/Declaration/<tt/void __fastcall__ gotoy (unsigned char x);/
2367 <tag/Description/The function moves the text mode cursor to the specified Y
2368 position while leaving the X position untouched. The uppermost position on the
2369 screen has the coordinate 0.
2370 <tag/Limits/<itemize>
2371 <item>The function is only available as fastcall function, so it may
2372 only be used in presence of a prototype.
2373 <item>Invalid values for the Y position (out of screen coordinates) may lead
2374 to undefined behaviour.
2376 <tag/Availability/cc65
2378 <ref id="gotox" name="gotox">,
2379 <ref id="gotoxy" name="gotoxy">,
2380 <ref id="wherex" name="wherex">,
2381 <ref id="wherey" name="wherey">
2387 <sect1>isalnum<label id="isalnum"><p>
2391 <tag/Function/Check if a given character is a letter or digit.
2392 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2393 <tag/Declaration/<tt/int __fastcall__ isalnum (int c);/
2394 <tag/Description/The function returns a non zero value if the given argument
2395 is a letter or digit. The return value is zero if the character is anything
2397 <tag/Limits/<itemize>
2398 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2399 inline sequence generated by the macro will not work correctly for values
2400 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2401 this range. The non inline function may be accessed by <tt/#undef/'ing
2403 <item>When compiling without <tt/-Os/, the function is only available as
2404 fastcall function, so it may only be used in presence of a prototype.
2406 <tag/Availability/ISO 9899
2408 <ref id="isalpha" name="isalpha">,
2409 <ref id="isascii" name="isascii">,
2410 <ref id="isblank" name="isblank">,
2411 <ref id="iscntrl" name="iscntrl">,
2412 <ref id="isdigit" name="isdigit">,
2413 <ref id="isgraph" name="isgraph">,
2414 <ref id="islower" name="islower">,
2415 <ref id="isprint" name="isprint">,
2416 <ref id="ispunct" name="ispunct">,
2417 <ref id="isspace" name="isspace">,
2418 <ref id="isupper" name="isupper">,
2419 <ref id="isxdigit" name="isxdigit">
2425 <sect1>isalpha<label id="isalpha"><p>
2429 <tag/Function/Check if a given character is a letter.
2430 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2431 <tag/Declaration/<tt/int __fastcall__ isalpha (int c);/
2432 <tag/Description/The function returns a non zero value if the given argument
2433 is a letter. The return value is zero if the character is anything else.
2434 <tag/Limits/<itemize>
2435 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2436 inline sequence generated by the macro will not work correctly for values
2437 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2438 this range. The non inline function may be accessed by <tt/#undef/'ing the
2440 <item>When compiling without <tt/-Os/, the function is only available as
2441 fastcall function, so it may only be used in presence of a prototype.
2443 <tag/Availability/ISO 9899
2445 <ref id="isalnum" name="isalnum">,
2446 <ref id="isascii" name="isascii">,
2447 <ref id="isblank" name="isblank">,
2448 <ref id="iscntrl" name="iscntrl">,
2449 <ref id="isdigit" name="isdigit">,
2450 <ref id="isgraph" name="isgraph">,
2451 <ref id="islower" name="islower">,
2452 <ref id="isprint" name="isprint">,
2453 <ref id="ispunct" name="ispunct">,
2454 <ref id="isspace" name="isspace">,
2455 <ref id="isupper" name="isupper">,
2456 <ref id="isxdigit" name="isxdigit">
2462 <sect1>isascii<label id="isascii"><p>
2466 <tag/Function/Check if a given character is in the ASCII (0..127) range.
2467 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2468 <tag/Declaration/<tt/int __fastcall__ isascii (int c);/
2469 <tag/Description/The function returns a non zero value if the given argument
2470 is in the range 0..127 (the range of valid ASCII characters) and zero if not.
2471 <tag/Limits/<itemize>
2472 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2473 inline sequence generated by the macro will not work correctly for values
2474 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2475 this range. The non inline function may be accessed by <tt/#undef/'ing the
2477 <item>When compiling without <tt/-Os/, the function is only available as
2478 fastcall function, so it may only be used in presence of a prototype.
2480 <tag/Availability/ISO 9899
2482 <ref id="isalnum" name="isalnum">,
2483 <ref id="isalpha" name="isalpha">,
2484 <ref id="isblank" name="isblank">,
2485 <ref id="iscntrl" name="iscntrl">,
2486 <ref id="isdigit" name="isdigit">,
2487 <ref id="isgraph" name="isgraph">,
2488 <ref id="islower" name="islower">,
2489 <ref id="isprint" name="isprint">,
2490 <ref id="ispunct" name="ispunct">,
2491 <ref id="isspace" name="isspace">,
2492 <ref id="isupper" name="isupper">,
2493 <ref id="isxdigit" name="isxdigit">
2499 <sect1>isblank<label id="isblank"><p>
2503 <tag/Function/Check if a given character is a space or tab.
2504 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2505 <tag/Declaration/<tt/int __fastcall__ isblank (int c);/
2506 <tag/Description/The function returns a non zero value if the given argument
2507 is a space or tab character. The return value is zero if the character is
2509 <tag/Limits/<itemize>
2510 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2511 inline sequence generated by the macro will not work correctly for values
2512 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2513 this range. The non inline function may be accessed by <tt/#undef/'ing the
2515 <item>When compiling without <tt/-Os/, the function is only available as
2516 fastcall function, so it may only be used in presence of a prototype.
2518 <tag/Availability/cc65
2520 <ref id="isalnum" name="isalnum">,
2521 <ref id="isalpha" name="isalpha">,
2522 <ref id="isascii" name="isascii">,
2523 <ref id="iscntrl" name="iscntrl">,
2524 <ref id="isdigit" name="isdigit">,
2525 <ref id="isgraph" name="isgraph">,
2526 <ref id="islower" name="islower">,
2527 <ref id="isprint" name="isprint">,
2528 <ref id="ispunct" name="ispunct">,
2529 <ref id="isspace" name="isspace">,
2530 <ref id="isupper" name="isupper">,
2531 <ref id="isxdigit" name="isxdigit">
2537 <sect1>iscntrl<label id="iscntrl"><p>
2541 <tag/Function/Check if a given character is a control character.
2542 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2543 <tag/Declaration/<tt/int __fastcall__ iscntrl (int c);/
2544 <tag/Description/The function returns a non zero value if the given argument
2545 is a control character. The return value is zero if the character is anything
2547 <tag/Limits/<itemize>
2548 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2549 inline sequence generated by the macro will not work correctly for values
2550 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2551 this range. The non inline function may be accessed by <tt/#undef/'ing the
2553 <item>When compiling without <tt/-Os/, the function is only available as
2554 fastcall function, so it may only be used in presence of a prototype.
2556 <tag/Availability/ISO 9899
2558 <ref id="isalnum" name="isalnum">,
2559 <ref id="isalpha" name="isalpha">,
2560 <ref id="isascii" name="isascii">,
2561 <ref id="isblank" name="isblank">,
2562 <ref id="isdigit" name="isdigit">,
2563 <ref id="isgraph" name="isgraph">,
2564 <ref id="islower" name="islower">,
2565 <ref id="isprint" name="isprint">,
2566 <ref id="ispunct" name="ispunct">,
2567 <ref id="isspace" name="isspace">,
2568 <ref id="isupper" name="isupper">,
2569 <ref id="isxdigit" name="isxdigit">
2575 <sect1>isdigit<label id="isdigit"><p>
2579 <tag/Function/Check if a given character is a digit.
2580 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2581 <tag/Declaration/<tt/int __fastcall__ isdigit (int c);/
2582 <tag/Description/The function returns a non zero value if the given argument
2583 is a digit. The return value is zero if the character is anything else.
2584 <tag/Limits/<itemize>
2585 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2586 inline sequence generated by the macro will not work correctly for values
2587 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2588 this range. The non inline function may be accessed by <tt/#undef/'ing the
2590 <item>When compiling without <tt/-Os/, the function is only available as
2591 fastcall function, so it may only be used in presence of a prototype.
2593 <tag/Availability/ISO 9899
2595 <ref id="isalnum" name="isalnum">,
2596 <ref id="isalpha" name="isalpha">,
2597 <ref id="isascii" name="isascii">,
2598 <ref id="isblank" name="isblank">,
2599 <ref id="iscntrl" name="iscntrl">,
2600 <ref id="isgraph" name="isgraph">,
2601 <ref id="islower" name="islower">,
2602 <ref id="isprint" name="isprint">,
2603 <ref id="ispunct" name="ispunct">,
2604 <ref id="isspace" name="isspace">,
2605 <ref id="isupper" name="isupper">,
2606 <ref id="isxdigit" name="isxdigit">
2612 <sect1>isgraph<label id="isgraph"><p>
2616 <tag/Function/Check if a given character is a printable character (except
2618 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2619 <tag/Declaration/<tt/int __fastcall__ isgraph (int c);/
2620 <tag/Description/The function returns a non zero value if the given argument
2621 is a printable character with the exception of space. The return value is zero
2622 if the character is anything else.
2623 <tag/Limits/<itemize>
2624 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2625 inline sequence generated by the macro will not work correctly for values
2626 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2627 this range. The non inline function may be accessed by <tt/#undef/'ing the
2629 <item>When compiling without <tt/-Os/, the function is only available as
2630 fastcall function, so it may only be used in presence of a prototype.
2632 <tag/Availability/ISO 9899
2634 <ref id="isalnum" name="isalnum">,
2635 <ref id="isalpha" name="isalpha">,
2636 <ref id="isascii" name="isascii">,
2637 <ref id="isblank" name="isblank">,
2638 <ref id="iscntrl" name="iscntrl">,
2639 <ref id="isdigit" name="isdigit">,
2640 <ref id="islower" name="islower">,
2641 <ref id="isprint" name="isprint">,
2642 <ref id="ispunct" name="ispunct">,
2643 <ref id="isspace" name="isspace">,
2644 <ref id="isupper" name="isupper">,
2645 <ref id="isxdigit" name="isxdigit">
2651 <sect1>islower<label id="islower"><p>
2655 <tag/Function/Check if a given character is a lower case letter.
2656 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2657 <tag/Declaration/<tt/int __fastcall__ islower (int c);/
2658 <tag/Description/The function returns a non zero value if the given argument
2659 is a lower case letter. The return value is zero if the character is anything
2661 <tag/Limits/<itemize>
2662 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2663 inline sequence generated by the macro will not work correctly for values
2664 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2665 this range. The non inline function may be accessed by <tt/#undef/'ing the
2667 <item>When compiling without <tt/-Os/, the function is only available as
2668 fastcall function, so it may only be used in presence of a prototype.
2670 <tag/Availability/ISO 9899
2672 <ref id="isalnum" name="isalnum">,
2673 <ref id="isalpha" name="isalpha">,
2674 <ref id="isascii" name="isascii">,
2675 <ref id="isblank" name="isblank">,
2676 <ref id="iscntrl" name="iscntrl">,
2677 <ref id="isdigit" name="isdigit">,
2678 <ref id="isgraph" name="isgraph">,
2679 <ref id="isprint" name="isprint">,
2680 <ref id="ispunct" name="ispunct">,
2681 <ref id="isspace" name="isspace">,
2682 <ref id="isupper" name="isupper">,
2683 <ref id="isxdigit" name="isxdigit">
2689 <sect1>isprint<label id="isprint"><p>
2693 <tag/Function/Check if a given character is a printable character.
2694 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2695 <tag/Declaration/<tt/int __fastcall__ isprint (int c);/
2696 <tag/Description/The function returns a non zero value if the given argument
2697 is a printable character (this includes the space character). The return value
2698 is zero if the character is anything else.
2699 <tag/Limits/<itemize>
2700 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2701 inline sequence generated by the macro will not work correctly for values
2702 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2703 this range. The non inline function may be accessed by <tt/#undef/'ing the
2705 <item>When compiling without <tt/-Os/, the function is only available as
2706 fastcall function, so it may only be used in presence of a prototype.
2708 <tag/Availability/ISO 9899
2710 <ref id="isalnum" name="isalnum">,
2711 <ref id="isalpha" name="isalpha">,
2712 <ref id="isascii" name="isascii">,
2713 <ref id="isblank" name="isblank">,
2714 <ref id="iscntrl" name="iscntrl">,
2715 <ref id="isdigit" name="isdigit">,
2716 <ref id="isgraph" name="isgraph">,
2717 <ref id="islower" name="islower">,
2718 <ref id="ispunct" name="ispunct">,
2719 <ref id="isspace" name="isspace">,
2720 <ref id="isupper" name="isupper">,
2721 <ref id="isxdigit" name="isxdigit">
2727 <sect1>ispunct<label id="ispunct"><p>
2731 <tag/Function/Check if a given character is a printable character but not a
2732 space or an alphanumeric character.
2733 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2734 <tag/Declaration/<tt/int __fastcall__ ispunct (int c);/
2735 <tag/Description/The function returns a non zero value if the given argument
2736 is a printable character, but not a space or anything alphanumeric. The return
2737 value is zero if the character is anything else.
2738 <tag/Limits/<itemize>
2739 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2740 inline sequence generated by the macro will not work correctly for values
2741 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2742 this range. The non inline function may be accessed by <tt/#undef/'ing the
2744 <item>When compiling without <tt/-Os/, the function is only available as
2745 fastcall function, so it may only be used in presence of a prototype.
2747 <tag/Availability/ISO 9899
2749 <ref id="isalnum" name="isalnum">,
2750 <ref id="isalpha" name="isalpha">,
2751 <ref id="isascii" name="isascii">,
2752 <ref id="isblank" name="isblank">,
2753 <ref id="iscntrl" name="iscntrl">,
2754 <ref id="isdigit" name="isdigit">,
2755 <ref id="isgraph" name="isgraph">,
2756 <ref id="islower" name="islower">,
2757 <ref id="isprint" name="isprint">,
2758 <ref id="isspace" name="isspace">,
2759 <ref id="isupper" name="isupper">,
2760 <ref id="isxdigit" name="isxdigit">
2766 <sect1>isspace<label id="isspace"><p>
2770 <tag/Function/Check if a given character is a a white-space character.
2771 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2772 <tag/Declaration/<tt/int __fastcall__ isspace (int c);/
2773 <tag/Description/The function returns a non zero value if the given argument
2774 is a white space character. The return value is zero if the character is
2775 anything else. The standard white space characters are: space, formfeed ('\f'),
2776 newline ('\n'), carriage return ('\r'), horizontal tab ('\t'), and vertical tab
2778 <tag/Limits/<itemize>
2779 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2780 inline sequence generated by the macro will not work correctly for values
2781 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2782 this range. The non inline function may be accessed by <tt/#undef/'ing the
2784 <item>When compiling without <tt/-Os/, the function is only available as
2785 fastcall function, so it may only be used in presence of a prototype.
2787 <tag/Availability/ISO 9899
2789 <ref id="isalnum" name="isalnum">,
2790 <ref id="isalpha" name="isalpha">,
2791 <ref id="isascii" name="isascii">,
2792 <ref id="isblank" name="isblank">,
2793 <ref id="iscntrl" name="iscntrl">,
2794 <ref id="isdigit" name="isdigit">,
2795 <ref id="isgraph" name="isgraph">,
2796 <ref id="islower" name="islower">,
2797 <ref id="isprint" name="isprint">,
2798 <ref id="ispunct" name="ispunct">,
2799 <ref id="isupper" name="isupper">,
2800 <ref id="isxdigit" name="isxdigit">
2806 <sect1>isupper<label id="isupper"><p>
2810 <tag/Function/Check if a given character is an upper case letter.
2811 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2812 <tag/Declaration/<tt/int __fastcall__ isupper (int c);/
2813 <tag/Description/The function returns a non zero value if the given argument
2814 is an upper case letter. The return value is zero if the character is anything
2816 <tag/Limits/<itemize>
2817 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2818 inline sequence generated by the macro will not work correctly for values
2819 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2820 this range. The non inline function may be accessed by <tt/#undef/'ing the
2822 <item>When compiling without <tt/-Os/, the function is only available as
2823 fastcall function, so it may only be used in presence of a prototype.
2825 <tag/Availability/ISO 9899
2827 <ref id="isalnum" name="isalnum">,
2828 <ref id="isalpha" name="isalpha">,
2829 <ref id="isascii" name="isascii">,
2830 <ref id="isblank" name="isblank">,
2831 <ref id="iscntrl" name="iscntrl">,
2832 <ref id="isdigit" name="isdigit">,
2833 <ref id="isgraph" name="isgraph">,
2834 <ref id="islower" name="islower">,
2835 <ref id="isprint" name="isprint">,
2836 <ref id="ispunct" name="ispunct">,
2837 <ref id="isspace" name="isspace">,
2838 <ref id="isxdigit" name="isxdigit">
2844 <sect1>isxdigit<label id="isxdigit"><p>
2848 <tag/Function/Check if a given character is a hexadecimal digit.
2849 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2850 <tag/Declaration/<tt/int __fastcall__ isxdigit (int c);/
2851 <tag/Description/The function returns a non zero value if the given argument
2852 is a hexadecimal digit (0..9, a..f and A..F). The return value is zero if the
2853 character is anything else.
2854 <tag/Limits/<itemize>
2855 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2856 inline sequence generated by the macro will not work correctly for values
2857 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2858 this range. The non inline function may be accessed by <tt/#undef/'ing the
2860 <item>When compiling without <tt/-Os/, the function is only available as
2861 fastcall function, so it may only be used in presence of a prototype.
2863 <tag/Availability/ISO 9899
2865 <ref id="isalnum" name="isalnum">,
2866 <ref id="isalpha" name="isalpha">,
2867 <ref id="isascii" name="isascii">,
2868 <ref id="isblank" name="isblank">,
2869 <ref id="iscntrl" name="iscntrl">,
2870 <ref id="isdigit" name="isdigit">,
2871 <ref id="isgraph" name="isgraph">,
2872 <ref id="islower" name="islower">,
2873 <ref id="isprint" name="isprint">,
2874 <ref id="ispunct" name="ispunct">,
2875 <ref id="isspace" name="isspace">,
2876 <ref id="isupper" name="isupper">
2882 <sect1>itoa<label id="itoa"><p>
2886 <tag/Function/Convert an integer into a string.
2887 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
2888 <tag/Declaration/<tt/char* __fastcall__ itoa (int val, char* buf, int radix);/
2889 <tag/Description/<tt/itoa/ converts the integer <tt/val/ into a string using
2890 <tt/radix/ as the base.
2891 <tag/Limits/<itemize>
2892 <item>There are no provisions to prevent a buffer overflow.
2893 <item>If <tt/val/ contains <tt/INT_MIN/, the behaviour is undefined.
2894 <item>The function is non standard, so it is not available in strict ANSI mode.
2895 You should probably use <tt/sprintf/ instead.
2896 <item>The function is only available as fastcall function, so it may only be
2897 used in presence of a prototype.
2899 <tag/Availability/cc65
2901 <ref id="atoi" name="atoi">,
2902 <ref id="atol" name="atol">,
2903 <ref id="ltoa" name="ltoa">,
2904 <ref id="ultoa" name="ultoa">,
2905 <ref id="utoa" name="utoa">
2911 <sect1>joy_count<label id="joy_count"><p>
2915 <tag/Function/Return the number of joysticks supported by the current driver.
2916 <tag/Header/<tt/<ref id="joystick.h" name="joystick.h">/
2917 <tag/Declaration/<tt/unsigned char __fastcall__ joy_count (void);/
2918 <tag/Description/The function returns a the number of joysticks supported
2919 by the current joystick driver.
2920 <tag/Limits/<itemize>
2921 <item>A joystick driver must be loaded using <ref id="joy_load_driver"
2922 name="joy_load_driver"> before calling this function.
2923 <item>The function returns the number of joysticks supported by the driver.
2924 There's no way to check for the number of actually connected joysticks.
2925 <item>The function is only available as fastcall function, so it may only be
2926 used in presence of a prototype.
2928 <tag/Availability/cc65
2930 <ref id="joy_load_driver" name="joy_load_driver">,
2931 <ref id="joy_read" name="joy_read">
2937 <sect1>joy_install<label id="joy_install"><p>
2941 <tag/Function/Install an already loaded driver and return an error code.
2942 <tag/Header/<tt/<ref id="joystick.h" name="joystick.h">/
2943 <tag/Declaration/<tt/unsigned char __fastcall__ joy_install (void* driver);/
2944 <tag/Description/The function installs a driver that was already loaded into
2945 memory (or linked statically to the program). It returns an error code
2946 (<tt/JOY_ERR_OK/ in case of success).
2947 <tag/Limits/<itemize>
2948 <item>The function is only available as fastcall function, so it may only be
2949 used in presence of a prototype.
2951 <tag/Availability/cc65
2953 <ref id="joy_load_driver" name="joy_load_driver">,
2954 <ref id="joy_uninstall" name="joy_uninstall">,
2955 <ref id="joy_unload" name="joy_unload">
2961 <sect1>joy_load_driver<label id="joy_load_driver"><p>
2965 <tag/Function/Load a driver from disk and install it.
2966 <tag/Header/<tt/<ref id="joystick.h" name="joystick.h">/
2967 <tag/Declaration/<tt/unsigned char __fastcall__ joy_load_driver (const char* driver);/
2968 <tag/Description/The function loads a driver with the given name from disk
2969 and installs it. An error code is returned, which is <tt/JOY_ERR_OK/ if the
2970 driver was successfully loaded and installed.
2971 <tag/Limits/<itemize>
2972 <item>The function is only available as fastcall function, so it may only be
2973 used in presence of a prototype.
2975 <tag/Availability/cc65
2977 <ref id="joy_install" name="joy_install">,
2978 <ref id="joy_uninstall" name="joy_uninstall">,
2979 <ref id="joy_unload" name="joy_unload">
2985 <sect1>joy_read<label id="joy_read"><p>
2989 <tag/Function/Read the status of a joystick.
2990 <tag/Header/<tt/<ref id="joystick.h" name="joystick.h">/
2991 <tag/Declaration/<tt/unsigned char __fastcall__ joy_read (unsigned char joystick);/
2992 <tag/Description/The function reads the status bits for a joystick. The number
2993 of the joystick is passed as parameter. The result may be examined by using one
2994 of the <tt/JOY_xxx/ macros from <ref id="joystick.h" name="joystick.h">.
2995 <tag/Limits/<itemize>
2996 <item>A joystick driver must be loaded using <ref id="joy_load_driver"
2997 name="joy_load_driver"> before calling this function.
2998 <item>The function is only available as fastcall function, so it may only be
2999 used in presence of a prototype.
3001 <tag/Availability/cc65
3003 <ref id="joy_count" name="joy_count">,
3004 <ref id="joy_load_driver" name="joy_load_driver">,
3005 <ref id="joy_unload" name="joy_unload">
3011 <sect1>joy_uninstall<label id="joy_uninstall"><p>
3015 <tag/Function/Uninstall the current joystick driver.
3016 <tag/Header/<tt/<ref id="joystick.h" name="joystick.h">/
3017 <tag/Declaration/<tt/unsigned char __fastcall__ joy_uninstall (void);/
3018 <tag/Description/The function uninstalls the currently installed joystick
3019 driver. It does not remove the driver from memory. The function returns an
3020 error code, which is <tt/JOY_ERR_OK/ if the driver was successfully uninstalled.
3021 <tag/Limits/<itemize>
3022 <item>A joystick driver must be installed using <ref id="joy_install"
3023 name="joy_install"> before calling this function.
3024 <item>The function is only available as fastcall function, so it may only be
3025 used in presence of a prototype.
3027 <tag/Availability/cc65
3029 <ref id="joy_install" name="joy_install">,
3030 <ref id="joy_load_driver" name="joy_load_driver">,
3031 <ref id="joy_unload" name="joy_unload">
3037 <sect1>joy_unload<label id="joy_unload"><p>
3041 <tag/Function/Uninstall, then unload the current joystick driver.
3042 <tag/Header/<tt/<ref id="joystick.h" name="joystick.h">/
3043 <tag/Declaration/<tt/unsigned char __fastcall__ joy_unload (void);/
3044 <tag/Description/The function uninstalls the currently installed joystick
3045 driver and removes it from memory. An error code is returned, which is
3046 <tt/JOY_ERR_OK/ if the driver was successfully uninstalled.
3047 <tag/Limits/<itemize>
3048 <item>A joystick driver must be loaded using <ref id="joy_load_driver"
3049 name="joy_load_driver"> before calling this function.
3050 <item>The function is only available as fastcall function, so it may only be
3051 used in presence of a prototype.
3053 <tag/Availability/cc65
3055 <ref id="joy_load_driver" name="joy_load_driver">
3061 <sect1>kbhit<label id="kbhit"><p>
3065 <tag/Function/Check if there's a key waiting in the keyboard buffer.
3066 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
3067 <tag/Declaration/<tt/unsigned char kbhit (void);/
3068 <tag/Description/The function returns a value of zero if there is no character
3069 waiting to be read from the keyboard. It returns non zero otherwise.
3070 <tag/Limits/<itemize>
3071 <item>If the system does not support a keyboard buffer (most systems
3072 do), the function is rather useless.
3074 <tag/Availability/cc65
3076 <ref id="cgetc" name="cgetc">,
3077 <ref id="cursor" name="cursor">
3083 <sect1>labs<label id="labs"><p>
3087 <tag/Function/Returns the absolute value of a long integer.
3088 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
3089 <tag/Declaration/<tt/long __fastcall__ labs (long v);/
3090 <tag/Description/<tt/labs/ returns the absolute value of the argument passed to
3092 <tag/Limits/<itemize>
3093 <item>The return value is undefined if <tt/LONG_MIN/ is passed to the function.
3094 <item>The function is only available as fastcall function, so it may only be
3095 used in presence of a prototype.
3097 <tag/Availability/ISO 9899
3099 <ref id="abs" name="abs">
3105 <sect1>ltoa<label id="ltoa"><p>
3109 <tag/Function/Convert a long integer into a string.
3110 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
3111 <tag/Declaration/<tt/char* __fastcall__ ltoa (long val, char* buf, int radix);/
3112 <tag/Description/<tt/itoa/ converts the long integer <tt/val/ into a string
3113 using <tt/radix/ as the base.
3114 <tag/Limits/<itemize>
3115 <item>There are no provisions to prevent a buffer overflow.
3116 <item>If <tt/val/ contains <tt/LONG_MIN/, the behaviour is undefined.
3117 <item>The function is non standard, so it is not available in strict ANSI mode.
3118 You should probably use <tt/sprintf/ instead.
3119 <item>The function is only available as fastcall function, so it may only be
3120 used in presence of a prototype.
3122 <tag/Availability/cc65
3124 <ref id="atoi" name="atoi">,
3125 <ref id="atol" name="atol">,
3126 <ref id="itoa" name="itoa">,
3127 <ref id="ultoa" name="ultoa">,
3128 <ref id="utoa" name="utoa">
3134 <sect1>localeconv<label id="localeconv"><p>
3138 <tag/Function/Returns a pointer to the current locale structure.
3139 <tag/Header/<tt/<ref id="locale.h" name="locale.h">/
3140 <tag/Declaration/<tt/struct lconv* localeconv (void);/
3141 <tag/Description/<tt/localeconv/ returns a pointer to the current locale
3143 <tag/Limits/<itemize>
3144 <item>cc65 supports only the "C" locale, so even after setting a new locale
3145 using <tt/<ref id="setlocale" name="setlocale">/, the structure returned will
3148 <tag/Availability/ISO 9899
3150 <ref id="setlocale" name="setlocale">
3156 <sect1>longjmp<label id="longjmp"><p>
3160 <tag/Function/Non local goto.
3161 <tag/Header/<tt/<ref id="setjmp.h" name="setjmp.h">/
3162 <tag/Declaration/<tt/void __fastcall__ longjmp (jmp_buf buf, int retval);/
3163 <tag/Description/The <tt/longjmp/ function restores a program context from the
3164 data in <tt/buf/, which must have been set by a preceeding call to
3165 <tt/<ref id="setjmp" name="setjmp">/. Program execution continues as if the
3166 call to <tt/<ref id="setjmp" name="setjmp">/ has just returned the value
3170 <item>If the parameter <tt/retval/ is zero, the function will behave as if it
3171 was called with a value of one.
3172 <item>The function is only available as fastcall function, so it may only
3173 be used in presence of a prototype.
3175 <tag/Availability/ISO 9899
3177 <ref id="setjmp" name="setjmp">
3183 <sect1>malloc<label id="malloc"><p>
3187 <tag/Function/Allocate dynamic memory.
3188 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
3189 <tag/Declaration/<tt/void* __fastcall__ malloc (size_t size);/
3190 <tag/Description/<tt/malloc/ allocates size bytes on the heap and returns a
3191 pointer to the allocated memory block. On error (not enough memory available),
3192 <tt/malloc/ returns <tt/NULL/.
3195 <item>The function is only available as fastcall function, so it may only
3196 be used in presence of a prototype.
3198 <tag/Availability/ISO 9899
3200 <ref id="_heapadd" name="_heapadd">,
3201 <ref id="_heapblocksize" name="_heapblocksize">,
3202 <ref id="_heapmaxavail" name="_heapmaxavail">,
3203 <ref id="_heapmemavail" name="_heapmemavail">,
3204 <ref id="calloc" name="calloc">,
3205 <ref id="free" name="free">,
3206 <ref id="realloc" name="realloc">,
3207 <ref id="strdup" name="strdup">
3213 <sect1>memchr<label id="memchr"><p>
3217 <tag/Function/Search for a character in a block of raw memory.
3218 <tag/Header/<tt/<ref id="string.h" name="string.h">/
3219 <tag/Declaration/<tt/void* __fastcall__ strchr (const void* mem, int c, size_t count);/
3220 <tag/Description/The <tt/memchr/ function locates the first occurrence of <tt/c/
3221 (converted to a char) in the block of raw memory string pointed to by <tt/mem/
3222 that is of size <tt/count/. Upon completion, the function returns a pointer to
3223 the character found, or a null pointer if the character was not found.
3224 <tag/Limits/<itemize>
3225 <item>The function is only available as fastcall function, so it may only
3226 be used in presence of a prototype.
3228 <tag/Availability/ISO 9899
3230 <ref id="strchr" name="strchr">
3236 <sect1>memcpy<label id="memcpy"><p>
3240 <tag/Function/Copy a memory area.
3241 <tag/Header/<tt/<ref id="string.h" name="string.h">/
3242 <tag/Declaration/<tt/void* __fastcall__ memcpy (void* dest, const void* src, size_t count);/
3243 <tag/Description/<tt/memcpy/ copies <tt/count/ bytes from the memory area
3244 pointed to by <tt/src/ into the memory area pointed to by <tt/dest/. It returns
3248 <item>The result is undefined if the memory areas do overlap. Use
3249 <tt/<ref id="memmove" name="memmove">/ to copy overlapping memory areas.
3250 <item>The function is only available as fastcall function, so it may only
3251 be used in presence of a prototype.
3253 <tag/Availability/ISO 9899
3255 <ref id="_swap" name="_swap">,
3256 <ref id="memmove" name="memmove">,
3257 <ref id="memset" name="memset">
3263 <sect1>memmove<label id="memmove"><p>
3267 <tag/Function/Copy a memory area.
3268 <tag/Header/<tt/<ref id="string.h" name="string.h">/
3269 <tag/Declaration/<tt/void* __fastcall__ memmove (void* dest, const void* src, size_t count);/
3270 <tag/Description/<tt/memmove/ copies <tt/count/ bytes from the memory area
3271 pointed to by <tt/src/ into the memory area pointed to by <tt/dest/. It returns
3275 <item>While <tt/memmove/ allows the memory areas to overlap, it has some
3276 additional overhead compared to <tt/<ref id="memcpy" name="memcpy">/.
3277 <item>The function is only available as fastcall function, so it may only
3278 be used in presence of a prototype.
3280 <tag/Availability/ISO 9899
3282 <ref id="_swap" name="_swap">,
3283 <ref id="memcpy" name="memcpy">,
3284 <ref id="memset" name="memset">
3290 <sect1>memset<label id="memset"><p>
3294 <tag/Function/Fill a memory area.
3295 <tag/Header/<tt/<ref id="string.h" name="string.h">/
3296 <tag/Declaration/<tt/void* __fastcall__ memset (void* p, int val, size_t count);/
3297 <tag/Description/<tt/memset/ fills the memory area pointed to by <tt/p/ with
3298 the value <tt/val/. The function returns <tt/p/.
3301 <item>The function is only available as fastcall function, so it may only
3302 be used in presence of a prototype.
3304 <tag/Availability/ISO 9899
3306 <ref id="_swap" name="_swap">,
3307 <ref id="bzero" name="bzero">,
3308 <ref id="memcpy" name="memcpy">,
3309 <ref id="memmove" name="memmove">
3315 <sect1>mod_free<label id="mod_free"><p>
3319 <tag/Function/Free a relocatable module.
3320 <tag/Header/<tt/<ref id="modload.h" name="modload.h">/
3321 <tag/Declaration/<tt/void __fastcall__ mod_free (void* module);/
3322 <tag/Description/The function will free a module loaded into memory by use of
3323 the <tt/<ref id="mod_load" name="mod_load">/ function.
3324 <tag/Limits/<itemize>
3325 <item>The pointer passed as parameter is the pointer to the module memory,
3326 not the pointer to the control structure.
3328 <tag/Availability/cc65
3330 <ref id="mod_load" name="mod_load">
3336 <sect1>mod_load<label id="mod_load"><p>
3340 <tag/Function/Load a relocatable module.
3341 <tag/Header/<tt/<ref id="modload.h" name="modload.h">/
3342 <tag/Declaration/<tt/unsigned char mod_load (struct mod_ctrl* ctrl);/
3343 <tag/Description/The function will load a code module into memory and relocate
3344 it. The function will return an error code. If <tt/MLOAD_OK/ is returned, the
3345 outgoing fields in the passed <tt/mod_ctrl/ struct contain information about
3346 the module just loaded. Possible error codes are:
3348 <item><tt/MLOAD_OK/ - Module load successful
3349 <item><tt/MLOAD_ERR_READ/ - Read error
3350 <item><tt/MLOAD_ERR_HDR/ - Header error
3351 <item><tt/MLOAD_ERR_OS/ - Wrong operating system
3352 <item><tt/MLOAD_ERR_FMT/ - Data format error
3353 <item><tt/MLOAD_ERR_MEM/ - Not enough memory
3355 <tag/Limits/<itemize>
3356 <item>The <htmlurl url="ld65.html" name="ld65"> linker is needed to create
3357 relocatable o65 modules for use with this function.
3359 <tag/Availability/cc65
3361 <ref id="mod_free" name="mod_free">
3367 <sect1>mouse_setbox<label id="mouse_setbox"><p>
3371 <tag/Function/Specify a bounding box for the mouse cursor.
3372 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3373 <tag/Declaration/<tt/void __fastcall__ mouse_setbox (const struct mouse_box* box);/
3374 <tag/Description/The function allows to set a bounding box for mouse movement.
3375 <tag/Limits/<itemize>
3376 <item>The function does not check if the mouse cursor is currently within the
3377 given rectangle. Placing the mouse cursor within the bounding box is the
3378 responsibility of the programmer.
3379 <item>While the bounding box may be larger than the actual screen size, the
3380 standard mouse cursor draw routines may fail to set the cursor to coordinates
3381 outside of the screen area. Depending on the platform, you may have to supply
3382 your own mouse cursor routines.
3383 <item>The function is only available as fastcall function, so it may only be
3384 used in presence of a prototype.
3386 <tag/Availability/cc65
3388 <ref id="mouse_getbox" name="mouse_getbox">,
3389 <ref id="mouse_move" name="mouse_move">
3395 <sect1>mouse_getbox<label id="mouse_getbox"><p>
3399 <tag/Function/Return the current bounding box for the mouse cursor.
3400 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3401 <tag/Declaration/<tt/void __fastcall__ mouse_getbox (struct mouse_box* box);/
3402 <tag/Description/The function queries the current bounding box for mouse
3404 <tag/Limits/<itemize>
3405 <item>The function is only available as fastcall function, so it may only be
3406 used in presence of a prototype.
3408 <tag/Availability/cc65
3410 <ref id="mouse_move" name="mouse_move">,
3411 <ref id="mouse_setbox" name="mouse_setbox">
3417 <sect1>mouse_buttons<label id="mouse_buttons"><p>
3421 <tag/Function/Return a bit mask encoding the state of the mouse buttons.
3422 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3423 <tag/Declaration/<tt/unsigned char __fastcall__ mouse_buttons (void);/
3424 <tag/Description/The function returns a bit mask that encodes the state of the
3425 mouse buttons. You may use the <tt/MOUSE_BTN_XXX/ flags to decode the function
3427 <tag/Limits/<itemize>
3428 <item>The function is only available as fastcall function, so it may only be
3429 used in presence of a prototype.
3431 <tag/Availability/cc65
3433 <ref id="mouse_info" name="mouse_info">,
3434 <ref id="mouse_pos" name="mouse_pos">
3440 <sect1>mouse_geterrormsg<label id="mouse_geterrormsg"><p>
3444 <tag/Function/Return a readable error message for an error code.
3445 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3446 <tag/Declaration/<tt/const char* __fastcall__ mouse_geterrormsg (unsigned char
3448 <tag/Description/The function returns an error message (in english) for the
3449 error code passed parameter.
3450 <tag/Limits/<itemize>
3451 <item>The function will return "Unknown error" for invalid error codes.
3452 <item>The function is only available as fastcall function, so it may only be
3453 used in presence of a prototype.
3455 <tag/Availability/cc65
3457 <ref id="mouse_load_driver" name="mouse_load_driver">,
3458 <ref id="mouse_uninstall" name="mouse_uninstall">,
3459 <ref id="mouse_unload" name="mouse_unload">
3465 <sect1>mouse_hide<label id="mouse_hide"><p>
3469 <tag/Function/Hide the mouse pointer.
3470 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3471 <tag/Declaration/<tt/void __fastcall__ mouse_hide (void);/
3472 <tag/Description/The function hides the mouse pointer. It manages a counter
3473 that is shared between <tt/<ref id="mouse_show" name="mouse_show">/ and
3474 <tt/mouse_hide/ so that every call call to <tt/mouse_hide/ must be followed by
3475 a call to <tt/<ref id="mouse_show" name="mouse_show">/ to make the mouse cursor
3477 <tag/Limits/<itemize>
3478 <item>The function is only available as fastcall function, so it may only be
3479 used in presence of a prototype.
3481 <tag/Availability/cc65
3483 <ref id="mouse_show" name="mouse_show">
3489 <sect1>mouse_info<label id="mouse_info"><p>
3493 <tag/Function/Return the state of the mouse buttons and the position of the
3495 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3496 <tag/Declaration/<tt/void __fastcall__ mouse_info (struct mouse_info* info);/
3497 <tag/Description/The function returns the state of the mouse buttons and the
3498 position of the mouse in the <tt/mouse_info/ structure passed as parameter.
3499 <tag/Limits/<itemize>
3500 <item>The <tt/mouse_info/ struct is a superset of the <tt/mouse_pos/ struct,
3501 so if you just need the mouse position, call <tt/<ref id="mouse_pos"
3502 name="mouse_pos">/ instead.
3503 <item>The function is only available as fastcall function, so it may only be
3504 used in presence of a prototype.
3506 <tag/Availability/cc65
3508 <ref id="mouse_buttons" name="mouse_buttons">,
3509 <ref id="mouse_pos" name="mouse_pos">
3515 <sect1>mouse_install<label id="mouse_install"><p>
3519 <tag/Function/Install an already loaded mouse driver.
3520 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3521 <tag/Declaration/<tt/unsigned char __fastcall__ mouse_install (const struct
3522 mouse_callbacks* c, void* driver);/
3523 <tag/Description/The function installs an already loaded mouse driver and
3524 returns an error code. The <tt/mouse_callbacks/ structure passed as first
3525 parameter contains pointers to routines needed to move or hide/show the mouse
3526 pointer. Defaults for these routines are supplied by the library, so if you
3527 can live with these defaults (which are platform specific), just pass a
3528 pointer to <tt/mouse_def_callbacks/. The function may be used to install a
3529 driver linked statically to the program.
3530 <tag/Limits/<itemize>
3531 <item>Not all drivers are able to detect if the supported hardware is really
3533 <item>After installing a driver, the mouse cursor is hidden.
3534 <item>The function is only available as fastcall function, so it may only be
3535 used in presence of a prototype.
3537 <tag/Availability/cc65
3539 <ref id="mouse_load_driver" name="mouse_load_driver">,
3540 <ref id="mouse_uninstall" name="mouse_uninstall">,
3541 <ref id="mouse_unload" name="mouse_unload">
3547 <sect1>mouse_ioctl<label id="mouse_ioctl"><p>
3551 <tag/Function/Call the driver specific ioctl function.
3552 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3553 <tag/Declaration/<tt/unsigned char __fastcall__ mouse_ioctl (unsigned char code, void* data);/
3554 <tag/Description/The function calls the IOCTL entry in the mouse driver,
3555 which is driver specific. The <tt/code/ parameter will choose between
3556 different IOCTL functions, and the <tt/data/ depends on code. The
3557 function returns an error code. The purpose of this function is to allow
3558 for driver specific extensions. See the documentation for a specific mouse
3559 driver for supported ioctl calls.
3560 <tag/Limits/<itemize>
3561 <item>Calling this function is non portable, because each driver may
3562 implement different ioctl calls (or none at all).
3563 <item>The function is only available as fastcall function, so it may only be
3564 used in presence of a prototype.
3566 <tag/Availability/cc65
3572 <sect1>mouse_load_driver<label id="mouse_load_driver"><p>
3576 <tag/Function/Load and initialize a mouse driver.
3577 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3578 <tag/Declaration/<tt/unsigned char __fastcall__ mouse_load_driver (const struct
3579 mouse_callbacks* c, const char* driver);/
3580 <tag/Description/Load a mouse driver into memory and initialize it. The
3581 function returns an error code that tells if the call has been successful. The
3582 <tt/mouse_callbacks/ structure passed as first parameter contains pointers to
3583 routines needed to move or hide/show the mouse pointer. Defaults for these
3584 routines are supplied by the library, so if you can live with these defaults
3585 (which are platform specific), just pass a pointer to <tt/mouse_def_callbacks/.
3586 <tag/Limits/<itemize>
3587 <item>The driver is loaded by name, so currently you must know the type of
3588 mouse that should be supported. There is no autodetect capability.
3589 <item>Not all drivers are able to detect if the supported hardware is really
3591 <item>After installing a driver, the mouse cursor is hidden.
3592 <item>The function is only available as fastcall function, so it may only be
3593 used in presence of a prototype.
3595 <tag/Availability/cc65
3597 <ref id="mouse_install" name="mouse_install">,
3598 <ref id="mouse_uninstall" name="mouse_uninstall">,
3599 <ref id="mouse_unload" name="mouse_unload">
3605 <sect1>mouse_move<label id="mouse_move"><p>
3609 <tag/Function/Move the mouse cursor to a specific position.
3610 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3611 <tag/Declaration/<tt/void __fastcall__ mouse_move (int x, int y);/
3612 <tag/Description/The function updates the mouse position. If the mouse cursor
3613 is visible, it is shown at the new position.
3614 <tag/Limits/<itemize>
3615 <item>The function does not check if the new position is within the bounding
3616 box specified with <tt/<ref id="mouse_setbox" name="mouse_setbox">/.
3617 <item>The function is only available as fastcall function, so it may only be
3618 used in presence of a prototype.
3620 <tag/Availability/cc65
3622 <ref id="mouse_getbox" name="mouse_getbox">,
3623 <ref id="mouse_setbox" name="mouse_setbox">
3629 <sect1>mouse_pos<label id="mouse_pos"><p>
3633 <tag/Function/Return the position of the mouse.
3634 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3635 <tag/Declaration/<tt/void __fastcall__ mouse_pos (struct mouse_pos* pos);/
3636 <tag/Description/The function returns the position of the mouse in the
3637 <tt/mouse_pos/ structure passed as parameter.
3638 <tag/Limits/<itemize>
3639 <item>The <tt/mouse_pos/ struct is a subset of the <tt/mouse_info/ struct,
3640 so if you do also need the mouse buttons, call <tt/<ref id="mouse_info"
3641 name="mouse_info">/ instead.
3642 <item>The function is only available as fastcall function, so it may only be
3643 used in presence of a prototype.
3645 <tag/Availability/cc65
3647 <ref id="mouse_buttons" name="mouse_buttons">,
3648 <ref id="mouse_info" name="mouse_info">
3654 <sect1>mouse_show<label id="mouse_show"><p>
3658 <tag/Function/Show the mouse pointer.
3659 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3660 <tag/Declaration/<tt/void __fastcall__ mouse_show (void);/
3661 <tag/Description/The function shows the mouse pointer. It manages a counter
3662 that is shared between <tt/<ref id="mouse_hide" name="mouse_hide">/ and
3663 <tt/mouse_show/. The mouse cursor is visible if there was one more call to
3664 <tt/mouse_show/ than to <tt/<ref id="mouse_hide" name="mouse_hide">/.
3665 <tag/Limits/<itemize>
3666 <item>The function is only available as fastcall function, so it may only be
3667 used in presence of a prototype.
3669 <tag/Availability/cc65
3671 <ref id="mouse_hide" name="mouse_hide">
3677 <sect1>mouse_uninstall<label id="mouse_uninstall"><p>
3681 <tag/Function/Uninstall an already loaded mouse driver.
3682 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3683 <tag/Declaration/<tt/unsigned char __fastcall__ mouse_install (void);/
3684 <tag/Description/The function uninstalls an already loaded mouse driver but
3685 don't removes it from memory.
3686 <tag/Limits/<itemize>
3687 <item>If the driver has been loaded using <tt/<ref id="mouse_load_driver"
3688 name="mouse_load_driver">/, <tt/<ref id="mouse_unload" name="mouse_unload">/
3689 should be used instead of <tt/mouse_uninstall/ so the driver is also removed
3691 <item>The function is only available as fastcall function, so it may only be
3692 used in presence of a prototype.
3694 <tag/Availability/cc65
3696 <ref id="mouse_install" name="mouse_install">,
3697 <ref id="mouse_load_driver" name="mouse_load_driver">,
3698 <ref id="mouse_unload" name="mouse_unload">
3704 <sect1>mouse_unload<label id="mouse_unload"><p>
3708 <tag/Function/Unload a mouse driver.
3709 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3710 <tag/Declaration/<tt/unsigned char __fastcall__ mouse_unload (void);/
3711 <tag/Description/The function unloads a loaded mouse driver and frees all
3712 memory allocated for the driver.
3713 <tag/Limits/<itemize>
3714 <item>The function does nothing if no driver is loaded.
3716 <tag/Availability/cc65
3718 <ref id="mouse_install" name="mouse_install">,
3719 <ref id="mouse_load_driver" name="mouse_load_driver">,
3720 <ref id="mouse_uninstall" name="mouse_uninstall">
3726 <sect1>offsetof<label id="offsetof"><p>
3730 <tag/Function/Calculate the offset of a struct or union member.
3731 <tag/Header/<tt/<ref id="stddef.h" name="stddef.h">/
3732 <tag/Declaration/<tt/size_t offsetof (type, member);/
3733 <tag/Description/<tt/offsetof/ calculates the address offset of a <tt/struct/
3734 or <tt/union/ member.
3735 <tag/Limits/<itemize>
3736 <item>The function is actually a macro.
3738 <tag/Availability/ISO 9899
3744 <sect1>open<label id="open"><p>
3748 <tag/Function/Open and possibly create a file.
3749 <tag/Header/<tt/<ref id="fcntl.h" name="fcntl.h">/
3750 <tag/Declaration/<tt/int open (const char* name, int flags, ...);/
3751 <tag/Description/<tt/open/ opens a file and returns the file descriptor
3752 associated with it. On error, -1 is returned and an error code is stored in
3753 <tt/errno/. Several flags may be passed to <tt/open/ that change the behaviour.
3754 <tag/Limits/<itemize>
3755 <item>POSIX specifies an additional <tt/mode/ argument that may be passed to
3756 open, which is used as the permission mask when a new file is created. While
3757 cc65 allows to pass this argument, it is ignored.
3759 <tag/Availability/POSIX 1003.1
3761 <ref id="close" name="close">,
3762 <ref id="creat" name="creat">
3768 <sect1>peekbsys<label id="peekbsys"><p>
3772 <tag/Function/Read one byte from a location in the system bank.
3773 <tag/Header/<tt/<ref id="cbm610.h" name="cbm610.h">/,
3774 <tt/<ref id="cbm510.h" name="cbm510.h">/
3775 <tag/Declaration/<tt/unsigned char __fastcall__ peekbsys (unsigned addr);/
3776 <tag/Description/<tt/peekbsys/ reads one byte from the given address in the
3777 system bank (bank 15) of the CBM PET-II machines and returns it.
3780 <item>The function is only available as fastcall function, so it may only
3781 be used in presence of a prototype.
3782 <item>This function may be a macro depending on the compiler options. The
3783 actual function is accessible by #undef'ing the macro.
3785 <tag/Availability/cc65
3787 <ref id="PEEK" name="PEEK">,
3788 <ref id="PEEKW" name="PEEKW">,
3789 <ref id="peekwsys" name="peekwsys">,
3790 <ref id="pokebsys" name="pokebsys">,
3791 <ref id="pokewsys" name="pokewsys">
3797 <sect1>peekwsys<label id="peekwsys"><p>
3801 <tag/Function/Read one word from a location in the system bank.
3802 <tag/Header/<tt/<ref id="cbm610.h" name="cbm610.h">/,
3803 <tt/<ref id="cbm510.h" name="cbm510.h">/
3804 <tag/Declaration/<tt/unsigned __fastcall__ peekwsys (unsigned addr);/
3805 <tag/Description/<tt/peekwsys/ reads one word from the given address in the
3806 system bank (bank 15) of the CBM PET-II machines and returns it. Following
3807 the usual 6502 conventions, the low byte is read from <tt/addr/, and the
3808 high byte is read from <tt/addr+1/.
3811 <item>The function is only available as fastcall function, so it may only
3812 be used in presence of a prototype.
3813 <item>The order in which the two bytes are read is undefined.
3815 <tag/Availability/cc65
3817 <ref id="PEEK" name="PEEK">,
3818 <ref id="PEEKW" name="PEEKW">,
3819 <ref id="peekbsys" name="peekbsys">,
3820 <ref id="pokebsys" name="pokebsys">,
3821 <ref id="pokewsys" name="pokewsys">
3827 <sect1>perror<label id="perror"><p>
3831 <tag/Function/Print an error message for the error in <tt/errno/.
3832 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
3833 <tag/Declaration/<tt/void __fastcall__ perror (const char* s);/
3834 <tag/Description/<tt/perror/ prints an error message to <tt/stderr/. If <tt/s/
3835 is not <tt/NULL/ and not an empty string, it is printed followed by a colon and
3836 a blank. Then the error message for the current contents of <tt/errno/ is
3837 printed followed by a newline. The message output is the same as returned by
3838 <tt/<ref id="strerror" name="strerror">/ with an argument of <tt/errno/.
3841 <item>The function is only available as fastcall function, so it may only
3842 be used in presence of a prototype.
3844 <tag/Availability/ISO 9899
3846 <ref id="_poserror" name="_poserror">,
3847 <ref id="strerror" name="strerror">
3853 <sect1>pokebsys<label id="pokebsys"><p>
3857 <tag/Function/Write one byte to a location in the system bank.
3858 <tag/Header/<tt/<ref id="cbm610.h" name="cbm610.h">/,
3859 <tt/<ref id="cbm510.h" name="cbm510.h">/
3860 <tag/Declaration/<tt/void __fastcall__ pokebsys (unsigned addr, unsigned char val);/
3861 <tag/Description/<tt/pokebsys/ writes one byte to the given address in the
3862 system bank (bank 15) of the CBM PET-II machines.
3865 <item>The function is only available as fastcall function, so it may only
3866 be used in presence of a prototype.
3868 <tag/Availability/cc65
3870 <ref id="POKE" name="POKE">,
3871 <ref id="POKEW" name="POKEW">,
3872 <ref id="peekbsys" name="peekbsys">,
3873 <ref id="peekwsys" name="peekwsys">,
3874 <ref id="pokewsys" name="pokewsys">
3880 <sect1>pokewsys<label id="pokewsys"><p>
3884 <tag/Function/Write one word to a location in the system bank.
3885 <tag/Header/<tt/<ref id="cbm610.h" name="cbm610.h">/,
3886 <tt/<ref id="cbm510.h" name="cbm510.h">/
3887 <tag/Declaration/<tt/void __fastcall__ pokewsys (unsigned addr, unsigned val);/
3888 <tag/Description/<tt/pokewsys/ writes one word to the given address in the
3889 system bank (bank 15) of the CBM PET-II machines. Following the usual 6502
3890 conventions, the low byte of <tt/val/ is written to <tt/addr/, and the
3891 high byte is written to <tt/addr+1/.
3894 <item>The function is only available as fastcall function, so it may only
3895 be used in presence of a prototype.
3896 <item>The order in which the two bytes are written is undefined.
3898 <tag/Availability/cc65
3900 <ref id="POKE" name="POKE">,
3901 <ref id="POKEW" name="POKEW">,
3902 <ref id="peekbsys" name="peekbsys">,
3903 <ref id="peekwsys" name="peekwsys">,
3904 <ref id="pokebsys" name="pokebsys">
3910 <sect1>qsort<label id="qsort"><p>
3914 <tag/Function/Sort an array.
3915 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
3916 <tag/Declaration/<tt/void __fastcall__ qsort (void* base, size_t count,
3917 size_t size, int (*compare) (const void*, const void*));/
3918 <tag/Description/<tt/qsort/ sorts an array according to a given compare
3919 function <tt/compare/. <tt/base/ is the address of the array, <tt/count/
3920 is the number of elements, <tt/size/ the size of an element and <tt/compare/
3921 the function used to compare the members.
3924 <item>If there are multiple members with the same key, the order after calling
3925 the function is undefined.
3926 <item>The function is only available as fastcall function, so it may only
3927 be used in presence of a prototype.
3929 <tag/Availability/ISO 9899
3931 <ref id="bsearch" name="bsearch">
3937 <sect1>raise<label id="raise"><p>
3941 <tag/Function/Send a signal to the executing program.
3942 <tag/Header/<tt/<ref id="signal.h" name="signal.h">/
3943 <tag/Declaration/<tt/int __fastcall__ raise (int sig);/
3944 <tag/Description/<tt/raise/ sends the given signal to the program. If the
3945 program has installed a signal handler for the signal, this signal handler
3946 will be executed. If no handler has been installed, the default action for
3947 the raised signal will be taken. The function returns zero on success,
3949 <tag/Limits/<itemize>
3950 <item>The function is only available as fastcall function, so it may only
3951 be used in presence of a prototype.
3953 <tag/Availability/ISO 9899
3955 <ref id="abort" name="abort">,
3956 <ref id="signal" name="signal">
3962 <sect1>rand<label id="rand"><p>
3966 <tag/Function/Return a pseudo random number.
3967 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
3968 <tag/Declaration/<tt/int rand (void);/
3969 <tag/Description/The function returns a pseudo random number
3970 between 0 and <tt/RAND_MAX/ (exclusive).
3971 <tag/Limits/<itemize>
3972 <item>Without using <tt><ref id="srand" name="srand"></tt>, always the same
3973 flow of numbers is generated.
3974 <item>On startup, the function behaves as if <ref id="srand" name="srand">
3975 had been used with an argument of 1.
3977 <tag/Availability/ISO 9899
3979 <ref id="_randomize" name="_randomize">,
3980 <ref id="srand" name="srand">
3986 <sect1>realloc<label id="realloc"><p>
3990 <tag/Function/Change the size of an allocated memory block.
3991 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
3992 <tag/Declaration/<tt/void* __fastcall__ realloc (void* block, size_t size);/
3993 <tag/Description/<tt/realloc/ changes the size of the memory block pointed to
3994 by <tt/block/ to <tt/size/ bytes. If <tt/block/ is <tt/NULL/, <tt/realloc/
3995 behaves as if <tt/malloc/ had been called. If <tt/size/ is zero, <tt/realloc/
3996 behaves as if <tt/free/ had been called. On error (not enough memory
3997 available), <tt/realloc/ returns <tt/NULL/.
4000 <item>The part of the memory block that is returned will have its contents
4002 <item>This function is somewhat dangerous to use. Be careful to save the
4003 pointer you're passing somewhere else, otherwise
4005 ptr = realloc (ptr, size);
4007 will loose your only copy of <tt/ptr/ if <tt/realloc/ returns <tt/NULL/.
4008 <item>The function is only available as fastcall function, so it may only
4009 be used in presence of a prototype.
4011 <tag/Availability/ISO 9899
4013 <ref id="_heapadd" name="_heapadd">,
4014 <ref id="_heapblocksize" name="_heapblocksize">,
4015 <ref id="_heapmaxavail" name="_heapmaxavail">,
4016 <ref id="_heapmemavail" name="_heapmemavail">,
4017 <ref id="calloc" name="calloc">,
4018 <ref id="free" name="free">,
4019 <ref id="realloc" name="realloc">
4025 <sect1>remove<label id="remove"><p>
4029 <tag/Function/Delete a file.
4030 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
4031 <tag/Declaration/<tt/int __fastcall__ remove (const char* name);/
4032 <tag/Description/<tt/remove/ deletes the file with the given name. On success,
4033 zero is returned. On error, -1 is returned and <tt/errno/ is set to an error
4034 code describing the reason for the failure.
4037 <item>This function is not available on all cc65 targets (depends on the
4038 availability of file I/O).
4039 <item>The function is only available as fastcall function, so it may only
4040 be used in presence of a prototype.
4042 <tag/Availability/ISO 9899
4044 <ref id="rename" name="rename">,
4045 <ref id="unlink" name="unlink">
4048 #include <stdio.h>
4050 #define FILENAME "helloworld"
4052 if (remove (FILENAME) == 0) {
4053 printf ("We deleted %s successfully\n", FILENAME);
4055 printf ("There was a problem deleting %s\n", FILENAME);
4062 <sect1>rename<label id="rename"><p>
4066 <tag/Function/Rename a file.
4067 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
4068 <tag/Declaration/<tt/int __fastcall__ rename (const char* oldname, const char* newname);/
4069 <tag/Description/<tt/rename/ renames a file (gives it a new name). On success,
4070 zero is returned. On error, -1 is returned and <tt/errno/ is set to an error
4071 code describing the reason for the failure.
4074 <item>This function is not available on all cc65 targets (depends on the
4075 capabilities of the storage devices).
4076 <item>The function is only available as fastcall function, so it may only
4077 be used in presence of a prototype.
4079 <tag/Availability/ISO 9899
4081 <ref id="remove" name="remove">
4084 #include <stdio.h>
4086 #define OLDNAME "textfile.txt"
4087 #define NEWNAME "textfile.bak"
4089 if (rename (OLDNAME, NEWNAME) == 0) {
4090 printf ("Renamed %s to %s\n", OLDNAME, NEWNAME);
4092 printf ("Error renaming %s to %s\n", OLDNAME, NEWNAME);
4099 <sect1>reset_brk<label id="reset_brk"><p>
4103 <tag/Function/Resets the break vector to its original value.
4104 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
4105 <tag/Declaration/<tt/void __fastcall__ reset_brk (void);/
4106 <tag/Description/<tt/reset_brk/ resets the break vector to the value it had
4107 before a call to <tt/set_brk/.
4110 <item>Since <tt/<ref id="set_brk" name="set_brk">/ installs an exit handler,
4111 it is not strictly necessary to call this function as part of the cleanup when
4114 <tag/Availability/cc65
4116 <ref id="set_brk" name="set_brk">
4122 <sect1>revers<label id="revers"><p>
4126 <tag/Function/Control revers character display.
4127 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
4128 <tag/Declaration/<tt/unsigned char __fastcall__ revers (unsigned char onoff);/
4129 <tag/Description/If the argument is non zero, the function enables reverse
4130 character display. If the argument is zero, reverse character display is
4131 switched off. The old value of the setting is returned.
4132 <tag/Limits/<itemize>
4133 <item>The function may not be supported by the hardware, in which case
4134 the call is ignored.
4135 <item>The function is only available as fastcall function, so it may only
4136 be used in presence of a prototype.
4138 <tag/Availability/cc65
4140 <ref id="textcolor" name="textcolor">
4146 <sect1>screensize<label id="screensize"><p>
4150 <tag/Function/Return the dimensions of the text mode screen.
4151 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
4152 <tag/Declaration/<tt/void __fastcall__ screensize (unsigned char* x, unsigned char* y);/
4153 <tag/Description/The function returns the dimensions of the text mode screen.
4154 <tag/Limits/<itemize>
4155 <item>The function is only available as fastcall function, so it may only
4156 be used in presence of a prototype.
4158 <tag/Availability/cc65
4160 <ref id="gotox" name="gotox">,
4161 <ref id="gotoxy" name="gotoxy">,
4162 <ref id="gotoy" name="gotoy">,
4163 <ref id="wherex" name="wherex">,
4164 <ref id="wherey" name="wherey">
4170 <sect1>ser_close<label id="ser_close"><p>
4174 <tag/Function/Close the port and disable interrupts
4175 <tag/Header/<tt/<ref id="serial.h" name="serial.h">/
4176 <tag/Declaration/<tt/unsigned char __fastcall__ ser_close (const struct ser_params* params);/
4177 <tag/Description/Open the port by setting the port parameters and enable interrupts.
4178 <tag/Limits/<itemize>
4179 <item>The function is only available as fastcall function, so it may only
4180 be used in presence of a prototype.
4182 <tag/Availability/cc65
4183 <tag/See also/Other serial functions.
4188 extern char comlynx[];
4190 static void initialize(){
4191 struct ser_params params = {
4198 ser_install(&comlynx); // This will activate the ComLynx
4200 ser_open(&params);
4207 <sect1>ser_get<label id="ser_get"><p>
4211 <tag/Function/Read a character from serial port.
4212 <tag/Header/<tt/<ref id="serial.h" name="serial.h">/
4213 <tag/Declaration/<tt/unsigned char __fastcall__ ser_get (char* b);/
4214 <tag/Description/Get a character from the serial port. If no characters are
4215 available, the function will return SER_ERR_NO_DATA, so this is not a fatal
4217 <tag/Limits/<itemize>
4218 <item>The function is only available as fastcall function, so it may only
4219 be used in presence of a prototype.
4221 <tag/Availability/cc65
4222 <tag/See also/Other serial functions.
4224 Wait for a character to be available from a serial port.
4227 while (ser_get(&ch) == SER_ERR_NO_DATA)
4234 <sect1>ser_install<label id="ser_install"><p>
4238 <tag/Function/Install an already loaded driver and return an error code.
4239 <tag/Header/<tt/<ref id="serial.h" name="serial.h">/
4240 <tag/Declaration/<tt/unsigned char __fastcall__ ser_install (void* driver);/
4241 <tag/Description/The function installs a driver that was already loaded into
4242 memory (or linked statically to the program). It returns an error code
4243 (<tt/SER_ERR_OK/ in case of success).
4244 <tag/Limits/<itemize>
4245 <item>The function is only available as fastcall function, so it may only be
4246 used in presence of a prototype.
4248 <tag/Availability/cc65
4250 <ref id="ser_load_driver" name="ser_load_driver">,
4251 <ref id="ser_uninstall" name="ser_uninstall">,
4252 <ref id="ser_unload" name="ser_unload">
4254 extern char lynxser[]; //Include the driver statically instead of loading it.
4256 ser_install(&lynxser);
4262 <sect1>ser_ioctl<label id="ser_ioctl"><p>
4266 <tag/Function/Platform dependent code extensions.
4267 <tag/Header/<tt/<ref id="serial.h" name="serial.h">/
4268 <tag/Declaration/<tt/unsigned __fastcall__ ser_ioctl (unsigned char code, void* data);/
4269 <tag/Description/Some platforms have extra serial functions that are not
4270 supported by standard serial driver functions. You can extend the driver to support
4271 this extra functionality bt using ser_ioctl functions.
4272 <tag/Limits/<itemize>
4273 <item>The function is only available as fastcall function, so it may only
4274 be used in presence of a prototype.
4275 <item>These functions are not easily portable to other cc65 platforms.
4277 <tag/Availability/cc65
4278 <tag/See also/Other serial functions.
4283 <sect1>ser_load_driver<label id="ser_load_driver"><p>
4287 <tag/Function/Load and install a serial driver.
4288 <tag/Header/<tt/<ref id="serial.h" name="serial.h">/
4289 <tag/Declaration/<tt/void __fastcall__ ser_load_driver (const char *name);/
4290 <tag/Description/Load and install the driver by name.
4291 Will just load the driver and check if loading was successful.
4292 <tag/Limits/<itemize>
4293 <item>The function is only available as fastcall function, so it may only
4294 be used in presence of a prototype.
4296 <tag/Availability/cc65
4297 <tag/See also/Other serial functions.
4303 <sect1>ser_open<label id="ser_open"><p>
4307 <tag/Function/Open the port by setting the port parameters and enable interrupts
4308 <tag/Header/<tt/<ref id="serial.h" name="serial.h">/
4309 <tag/Declaration/<tt/unsigned char __fastcall__ ser_open (const struct ser_params* params);/
4310 <tag/Description/Open the port by setting the port parameters and enable interrupts.
4311 <tag/Limits/<itemize>
4312 <item>The function is only available as fastcall function, so it may only
4313 be used in presence of a prototype.
4315 <tag/Availability/cc65
4316 <tag/See also/Other serial functions.
4321 extern char comlynx[];
4323 static void initialize(){
4324 struct ser_params params = {
4331 ser_install(&comlynx); // This will activate the ComLynx
4333 ser_open(&params);
4340 <sect1>ser_put<label id="ser_put"><p>
4344 <tag/Function/Write a character to a serial port.
4345 <tag/Header/<tt/<ref id="serial.h" name="serial.h">/
4346 <tag/Declaration/<tt/unsigned char __fastcall__ ser_put (char b);/
4347 <tag/Description/Send a character via the serial port. There is a transmit
4348 buffer, but transmitting is not done via interrupt. The function returns
4349 SER_ERR_OVERFLOW if there is no space left in the transmit buffer.
4350 <tag/Limits/<itemize>
4351 <item>The function is only available as fastcall function, so it may only
4352 be used in presence of a prototype.
4354 <tag/Availability/cc65
4355 <tag/See also/Other serial functions.
4364 <sect1>ser_status<label id="ser_status"><p>
4368 <tag/Function/Return the serial port status.
4369 <tag/Header/<tt/<ref id="serial.h" name="serial.h">/
4370 <tag/Declaration/<tt/unsigned char __fastcall__ ser_put (unsigned char* status);/
4371 <tag/Description/Return the serial port status.
4372 <tag/Limits/<itemize>
4373 <item>The function is only available as fastcall function, so it may only
4374 be used in presence of a prototype.
4376 <tag/Availability/cc65
4377 <tag/See also/Other serial functions.
4383 <sect1>ser_uninstall<label id="ser_uninstall"><p>
4387 <tag/Function/Uninstall the currently loaded driver but do not unload it.
4388 <tag/Header/<tt/<ref id="serial.h" name="serial.h">/
4389 <tag/Declaration/<tt/void __fastcall__ ser_uninstall (void);/
4390 <tag/Description/Uninstall the currently loaded driver but do not unload it.
4391 <tag/Limits/<itemize>
4392 <item>The function is only available as fastcall function, so it may only
4393 be used in presence of a prototype.
4395 <tag/Availability/cc65
4396 <tag/See also/Other serial functions.
4401 <sect1>ser_unload<label id="ser_unload"><p>
4405 <tag/Function/Uninstall, then unload the currently loaded driver.
4406 <tag/Header/<tt/<ref id="serial.h" name="serial.h">/
4407 <tag/Declaration/<tt/void __fastcall__ ser_unload (void);/
4408 <tag/Description/Uninstall, then unload the currently loaded driver.
4409 <tag/Limits/<itemize>
4410 <item>The function is only available as fastcall function, so it may only
4411 be used in presence of a prototype.
4413 <tag/Availability/cc65
4414 <tag/See also/Other serial functions.
4420 <sect1>set_brk<label id="set_brk"><p>
4424 <tag/Function/Set the break vector to a user function.
4425 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
4426 <tag/Declaration/<tt/void __fastcall__ set_brk (brk_handler func);/
4427 <tag/Description/<tt/set_brk/ allows a user program to handle breaks within the
4428 program code by letting the vector point to a user written C function. The
4429 runtime library installs a small stub that saves the registers into global
4430 variables that may be accessed (and changed) by the break handler.
4433 <item>The function is only available as fastcall function, so it may only
4434 be used in presence of a prototype.
4435 <item>The stub saves the zero page registers used by the C runtime and switches
4436 to a small break handler stack. This means that it is safe to execute C code,
4437 even if C code was interrupted. Be careful however not to use too many local
4438 variables, and do not enable stack checks for the handler function or any other
4439 function called from it.
4440 <item>The <tt/brk_pc/ variable points to the <tt/BRK/ instruction. If you want
4441 the continue with the interrupted code, you have to adjust <tt/brk_pc/,
4442 otherwise the <tt/BRK/ instruction will get executed over and over again.
4443 <item>Since <tt/set_brk/ installs an exit handler, it is not strictly necessary
4444 to call <tt/<ref id="reset_brk" name="reset_brk">/ as part of the cleanup when
4445 the program terminates.
4447 <tag/Availability/cc65
4449 <ref id="reset_brk" name="reset_brk">
4455 <sect1>setjmp<label id="setjmp"><p>
4459 <tag/Function/Save the context for use with <tt/longjmp/.
4460 <tag/Header/<tt/<ref id="setjmp.h" name="setjmp.h">/
4461 <tag/Declaration/<tt/int __fastcall__ setjmp (jmp_buf buf);/
4462 <tag/Description/The <tt/setjmp/ function saves the current context in <tt/buf/
4463 for subsequent use by the <tt/<ref id="longjmp" name="longjmp">/ function and
4467 <item>The function is only available as fastcall function, so it may only
4468 be used in presence of a prototype.
4469 <item><tt/setjmp/ is actually a macro as required by the ISO standard.
4470 <item><tt/setjmp/ will not save the signal context.
4472 <tag/Availability/ISO 9899
4474 <ref id="longjmp" name="longjmp">
4480 <sect1>setlocale<label id="setlocale"><p>
4484 <tag/Function/Selects a locale.
4485 <tag/Header/<tt/<ref id="locale.h" name="locale.h">/
4486 <tag/Declaration/<tt/char* __fastcall__ setlocale (int category, const char* locale);/
4487 <tag/Description/<tt/setlocale/ sets or queries the program's locale.
4490 <item>The function is only available as fastcall function, so it may only
4491 be used in presence of a prototype.
4492 <item>cc65 supports only the "C" locale, so calling this function to set a
4493 different locale has no effect.
4495 <tag/Availability/ISO 9899
4497 <ref id="localeconv" name="localeconv">,
4498 <ref id="strcoll" name="strcoll">
4499 <ref id="strxfrm" name="strxfrm">
4505 <sect1>signal<label id="signal"><p>
4509 <tag/Function/Install a signal handler.
4510 <tag/Header/<tt/<ref id="signal.h" name="signal.h">/
4511 <tag/Declaration/<tt/__sigfunc __fastcall__ signal (int sig, __sigfunc func);/
4512 <tag/Description/<tt/signal/ installs a handler for the given signal. The
4513 handler may either be a user supplied function, or one of the predefined
4514 signal handlers <tt/SIG_IGN/ or <tt/SIG_DFL/. The function returns the
4515 previous value if the signal , or the special function vector SIG_ERR in
4517 <tag/Limits/<itemize>
4518 <item>The function is only available as fastcall function, so it may only
4519 be used in presence of a prototype.
4521 <tag/Availability/ISO 9899
4523 <ref id="abort" name="abort">,
4524 <ref id="raise" name="raise">
4530 <sect1>sleep<label id="sleep"><p>
4534 <tag/Function/Sleep for a specified amount of time.
4535 <tag/Header/<tt/<ref id="unistd.h" name="unistd.h">/
4536 <tag/Declaration/<tt/void __fastcall__ sleep (unsigned seconds);/
4537 <tag/Description/The function will return after the specified number of
4538 seconds have elapsed.
4539 <tag/Limits/<itemize>
4540 <item>The function is only available as fastcall function, so it may only
4541 be used in presence of a prototype.
4543 <tag/Availability/POSIX 1003.1
4549 <sect1>slow<label id="slow"><p>
4553 <tag/Function/Switch the C128 into 1MHz mode.
4554 <tag/Header/<tt/<ref id="c128.h" name="c128.h">/
4555 <tag/Declaration/<tt/void slow (void);/
4556 <tag/Description/The function will switch the clock of the C128 to 1MHz. This
4557 will halve the speed compared to fast mode.
4558 <tag/Limits/<itemize>
4559 <item>The function is specific to the C128.
4561 <tag/Availability/C128
4563 <ref id="fast" name="fast">,
4564 <ref id="toggle_videomode" name="toggle_videomode">,
4565 <ref id="videomode" name="videomode">
4571 <sect1>srand<label id="srand"><p>
4575 <tag/Function/Initialize the pseudo random number generator.
4576 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
4577 <tag/Declaration/<tt/void __fastcall__ srand (unsigned seed);/
4578 <tag/Description/The function initializes the random number generator using
4579 the given seed. On program startup, the generator behaves as if <tt/srand/ has
4580 been called with an argument of 1.
4581 <tag/Limits/<itemize>
4582 <item>The function is only available as fastcall function, so it may only
4583 be used in presence of a prototype.
4585 <tag/Availability/ISO 9899
4587 <ref id="_randomize" name="_randomize">,
4588 <ref id="rand" name="rand">
4594 <sect1>strcasecmp<label id="strcasecmp"><p>
4598 <tag/Function/Compare two strings case insensitive.
4599 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4600 <tag/Declaration/<tt/int __fastcall__ strcasecmp (const char* s1, const char* s2);/
4601 <tag/Description/The <tt/strcasecmp/ function compares the two strings passed
4602 as parameters without case sensitivity. It returns a value that is less than
4603 zero if <tt/s1/ is less than <tt/s2/, zero if <tt/s1/ is the same as <tt/s2/,
4604 and a value greater than zero if <tt/s1/ is greater than <tt/s2/.
4605 <tag/Limits/<itemize>
4606 <item>The function is only available as fastcall function, so it may only
4607 be used in presence of a prototype.
4608 <item>The function is not available in strict ANSI mode.
4610 <tag/Availability/cc65
4612 <ref id="strcmp" name="strcmp">,
4613 <ref id="strcoll" name="strcoll">,
4614 <ref id="stricmp" name="stricmp">,
4615 <ref id="strncmp" name="strncmp">
4616 <ref id="strxfrm" name="strxfrm">
4622 <sect1>strcat<label id="strcat"><p>
4626 <tag/Function/Concatentate two strings.
4627 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4628 <tag/Declaration/<tt/char* __fastcall__ strcat (char* s1, const char* s2);/
4629 <tag/Description/The <tt/strcat/ function appends a copy of the string
4630 pointed to by s2 (including the terminating null byte) to the end of the
4631 string pointed to by s1. The initial byte of s2 overwrites the null byte at
4633 <tag/Limits/<itemize>
4634 <item>The function is only available as fastcall function, so it may only
4635 be used in presence of a prototype.
4636 <item>If copying takes place between objects that overlap, the behaviour
4639 <tag/Availability/ISO 9899
4641 <ref id="strcpy" name="strcpy">,
4642 <ref id="strncat" name="strncat">,
4643 <ref id="strncpy" name="strncpy">
4649 <sect1>strchr<label id="strchr"><p>
4653 <tag/Function/Search for a character in a string.
4654 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4655 <tag/Declaration/<tt/char* __fastcall__ strchr (const char* s, int c);/
4656 <tag/Description/The <tt/strchr/ function locates the first occurrence of <tt/c/
4657 (converted to a char) in the string pointed to by <tt/s/. The terminating null
4658 byte is considered to be part of the string. Upon completion, the function
4659 returns a pointer to the byte, or a null pointer if the byte was not found.
4660 <tag/Limits/<itemize>
4661 <item>The function is only available as fastcall function, so it may only
4662 be used in presence of a prototype.
4664 <tag/Availability/ISO 9899
4666 <ref id="memchr" name="memchr">,
4667 <ref id="strrchr" name="strrchr">
4673 <sect1>strcmp<label id="strcmp"><p>
4677 <tag/Function/Compare two strings.
4678 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4679 <tag/Declaration/<tt/int __fastcall__ strcmp (const char* s1, const char* s2);/
4680 <tag/Description/The <tt/strcmp/ function compares the two strings passed as
4681 parameters. It returns a value that is less than zero if <tt/s1/ is less than
4682 <tt/s2/, zero if <tt/s1/ is the same as <tt/s2/, and a value greater than zero
4683 if <tt/s1/ is greater than <tt/s2/.
4684 <tag/Limits/<itemize>
4685 <item>The function is only available as fastcall function, so it may only
4686 be used in presence of a prototype.
4688 <tag/Availability/ISO 9899
4690 <ref id="strcasecmp" name="strcasecmp">,
4691 <ref id="strcoll" name="strcoll">,
4692 <ref id="stricmp" name="stricmp">,
4693 <ref id="strncmp" name="strncmp">
4694 <ref id="strxfrm" name="strxfrm">
4700 <sect1>strcoll<label id="strcoll"><p>
4704 <tag/Function/Compare two strings.
4705 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4706 <tag/Declaration/<tt/int __fastcall__ strcoll (const char* s1, const char* s2);/
4707 <tag/Description/The <tt/strcoll/ function compares the two strings passed as
4708 parameters, according to the collating sequence set by <tt/<ref id="setlocale"
4709 name="setlocale">/. It returns a value that is less than zero if <tt/s1/ is
4710 less than <tt/s2/, zero if <tt/s1/ is the same as <tt/s2/, and a value greater
4711 than zero if <tt/s1/ is greater than <tt/s2/.
4712 <tag/Limits/<itemize>
4713 <item>The function is only available as fastcall function, so it may only
4714 be used in presence of a prototype.
4716 <tag/Availability/ISO 9899
4718 <ref id="setlocale" name="setlocale">,
4719 <ref id="strcasecmp" name="strcasecmp">,
4720 <ref id="strcmp" name="strcmp">,
4721 <ref id="stricmp" name="stricmp">,
4722 <ref id="strncmp" name="strncmp">
4723 <ref id="strxfrm" name="strxfrm">
4729 <sect1>strcpy<label id="strcpy"><p>
4733 <tag/Function/Copy a string.
4734 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4735 <tag/Declaration/<tt/char* __fastcall__ strcpy (char* s1, const char* s2);/
4736 <tag/Description/The <tt/strcpy/ function copies the string pointed to by
4737 <tt/s2/ (including the terminating null byte) into the array pointed to by
4738 <tt/s1/. The function will always return <tt/s1/.
4739 <tag/Limits/<itemize>
4740 <item>The function is only available as fastcall function, so it may only
4741 be used in presence of a prototype.
4742 <item>If copying takes place between objects that overlap, the behaviour
4745 <tag/Availability/ISO 9899
4747 <ref id="strcat" name="strcat">,
4748 <ref id="strncat" name="strncat">,
4749 <ref id="strncpy" name="strncpy">
4752 #include <string.h>
4754 static char hello[14];
4756 strcpy (hello, "Hello world!\n");
4762 <sect1>strcspn<label id="strcspn"><p>
4766 <tag/Function/Compute the length of a substring.
4767 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4768 <tag/Declaration/<tt/size_t __fastcall__ strcspn (const char* s, const char* set);/
4769 <tag/Description/The <tt/strcspn/ function computes and returns the length of
4770 the substring pointed to by <tt/s/ which does <em>not</em> consist of
4771 characters contained in the string <tt/set/.
4772 <tag/Limits/<itemize>
4773 <item>The function is only available as fastcall function, so it may only
4774 be used in presence of a prototype.
4776 <tag/Availability/ISO 9899
4778 <ref id="strspn" name="strspn">,
4779 <ref id="strstr" name="strstr">,
4780 <ref id="strtok" name="strtok">
4786 <sect1>strdup<label id="strdup"><p>
4790 <tag/Function/Allocate a copy of a string on the heap.
4791 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4792 <tag/Declaration/<tt/char* __fastcall__ strdup (const char* s);/
4793 <tag/Description/<tt/strdup/ allocates a memory block on the heap, big enough
4794 to hold a copy of <tt/s/ including the terminating zero. If the allocation
4795 fails, <tt/NULL/ is returned, otherwise <tt/s/ is copied into the allocated
4796 memory block, and a pointer to the block is returned.
4797 <tag/Limits/<itemize>
4798 <item>The function is only available as fastcall function, so it may only
4799 be used in presence of a prototype.
4800 <item>It is up to the caller to free the allocated memory block.
4802 <tag/Availability/ISO 9899
4804 <ref id="free" name="free">,
4805 <ref id="malloc" name="malloc">
4811 <sect1>strerror<label id="strerror"><p>
4815 <tag/Function/Return a string describing an error code.
4816 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4817 <tag/Declaration/<tt/char* __fastcall__ strerror (int errcode);/
4818 <tag/Description/The <tt/strerror/ function returns a string describing the
4819 given error code. If an invalid error code is passed, the string "Unknown
4820 error" is returned, and <tt/errno/ is set to <tt/EINVAL/. In all other cases,
4821 <tt/errno/ is left untouched.
4822 <tag/Limits/<itemize>
4823 <item>The function is only available as fastcall function, so it may only
4824 be used in presence of a prototype.
4825 <item>While the return type of the function is a <tt/char*/, the returned
4826 string must not be modified by the caller!
4828 <tag/Availability/ISO 9899
4830 <ref id="_stroserror" name="_stroserror">
4836 <sect1>stricmp<label id="stricmp"><p>
4840 <tag/Function/Compare two strings case insensitive.
4841 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4842 <tag/Declaration/<tt/int __fastcall__ stricmp (const char* s1, const char* s2);/
4843 <tag/Description/The <tt/stricmp/ function compares the two strings passed as
4844 parameters without case sensitivity. It returns a value that is less than zero
4845 if <tt/s1/ is less than <tt/s2/, zero if <tt/s1/ is the same as <tt/s2/, and a
4846 value greater than zero if <tt/s1/ is greater than <tt/s2/.
4847 <tag/Limits/<itemize>
4848 <item>The function is only available as fastcall function, so it may only
4849 be used in presence of a prototype.
4850 <item>The function is not available in strict ANSI mode.
4852 <tag/Availability/cc65
4854 <ref id="strcasecmp" name="strcasecmp">,
4855 <ref id="strcmp" name="strcmp">,
4856 <ref id="strcoll" name="strcoll">,
4857 <ref id="strncmp" name="strncmp">
4858 <ref id="strxfrm" name="strxfrm">
4864 <sect1>strlen<label id="strlen"><p>
4868 <tag/Function/Return the length of a string.
4869 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4870 <tag/Declaration/<tt/size_t __fastcall__ strlen (const char* s);/
4871 <tag/Description/The <tt/strlen/ function computes the number of bytes in the
4872 string to which s points, not including the terminating null byte.
4873 <tag/Limits/<itemize>
4874 <item>The function is only available as fastcall function, so it may only
4875 be used in presence of a prototype.
4876 <item>When compiling with <tt/-Os/ (inline known standard functions), the
4877 function does not work correctly for strings with more than 255 characters.
4879 <tag/Availability/ISO 9899
4881 <ref id="strcpy" name="strcpy">
4887 <sect1>strlower<label id="strlower"><p>
4891 <tag/Function/Make a string lower case.
4892 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4893 <tag/Declaration/<tt/char* __fastcall__ strlower (char* s);/
4894 <tag/Description/The <tt/strlower/ function will apply the <tt/tolower/
4895 function to each character of a string. The function will always return <tt/s/.
4896 <tag/Limits/<itemize>
4897 <item>The function is only available as fastcall function, so it may only
4898 be used in presence of a prototype.
4899 <item>The function prototype is unavailable when compiling in strict ANSI mode.
4900 <item>An alias name for this function is <tt/strlwr/.
4902 <tag/Availability/cc65
4904 <ref id="strupper" name="strupper">,
4905 <ref id="tolower" name="tolower">
4911 <sect1>strlwr<label id="strlwr"><p>
4918 <sect1>strncat<label id="strncat"><p>
4922 <tag/Function/Concatentate two strings.
4923 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4924 <tag/Declaration/<tt/char* __fastcall__ strncat (char* s1, const char* s2, size_t n);/
4925 <tag/Description/The <tt/strncat/ function appends not more than n characters
4926 of the string pointed to by s2 to the end of the string pointed to by s1. The
4927 terminating null character at the end of s1 is overwritten. A terminating null
4928 character is appended to the result, even if not all of s2 is appended to s1.
4929 <tag/Limits/<itemize>
4930 <item>The function is only available as fastcall function, so it may only
4931 be used in presence of a prototype.
4932 <item>If copying takes place between objects that overlap, the behaviour
4935 <tag/Availability/ISO 9899
4937 <ref id="strcpy" name="strcpy">,
4938 <ref id="strncat" name="strncat">,
4939 <ref id="strncpy" name="strncpy">
4945 <sect1>strncmp<label id="strncmp"><p>
4949 <tag/Function/Compare two strings.
4950 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4951 <tag/Declaration/<tt/int __fastcall__ strncmp (const char* s1, const char* s2, size_t count);/
4952 <tag/Description/The <tt/strncmp/ function compares not more than <tt/count/
4953 characters of the two strings passed as parameters. It returns a value that is
4954 less than zero if the first <tt/count/ characters of <tt/s1/ are less than
4955 <tt/s2/, zero if they are identical, and a value greater than zero they are
4957 <tag/Limits/<itemize>
4958 <item>The function is only available as fastcall function, so it may only
4959 be used in presence of a prototype.
4961 <tag/Availability/ISO 9899
4963 <ref id="strcasecmp" name="strcasecmp">,
4964 <ref id="strcmp" name="strcmp">,
4965 <ref id="strcoll" name="strcoll">,
4966 <ref id="stricmp" name="stricmp">
4967 <ref id="strxfrm" name="strxfrm">
4973 <sect1>strncpy<label id="strncpy"><p>
4977 <tag/Function/Copy part of a string.
4978 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4979 <tag/Declaration/<tt/char* __fastcall__ strcpy (char* s1, const char* s2, size_t n);/
4980 <tag/Description/The <tt/strncpy/ function copies not more than n bytes from
4981 the array pointed to by <tt/s2/ to the array pointed to by <tt/s1/. If the array
4982 pointed to by <tt/s2/ is a string that is shorter than n bytes, null bytes are
4983 appended to the copy in the array pointed to by <tt/s1/, until <tt/n/ bytes are
4984 written. The function will always return <tt/s1/.
4985 <tag/Limits/<itemize>
4986 <item>The function is only available as fastcall function, so it may only
4987 be used in presence of a prototype. If there is no null byte in the first <tt/n/
4988 bytes of the array pointed to by <tt/s2/, the result is not null-terminated.
4989 <item>If copying takes place between objects that overlap, the behaviour is
4992 <tag/Availability/ISO 9899
4994 <ref id="strcat" name="strcat">,
4995 <ref id="strcpy" name="strcpy">,
4996 <ref id="strncat" name="strncat">
5001 static char hello[6];
5003 strcpy (hello, "Hello world!\n", sizeof (hello) - 1);
5010 <sect1>strrchr<label id="strrchr"><p>
5014 <tag/Function/Search for a character in a string.
5015 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5016 <tag/Declaration/<tt/char* __fastcall__ strrchr (const char* s, int c);/
5017 <tag/Description/The <tt/strrchr/ function locates the last occurrence of <tt/c/
5018 (converted to a char) in the string pointed to by <tt/s/. The terminating null
5019 byte is considered to be part of the string. Upon completion, the function
5020 returns a pointer to the byte, or a null pointer if the byte was not found.
5021 <tag/Limits/<itemize>
5022 <item>The function is only available as fastcall function, so it may only
5023 be used in presence of a prototype.
5025 <tag/Availability/ISO 9899
5027 <ref id="strchr" name="strchr">
5033 <sect1>strspn<label id="strspn"><p>
5037 <tag/Function/Compute the length of a substring.
5038 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5039 <tag/Declaration/<tt/size_t __fastcall__ strspn (const char* s, const char* set);/
5040 <tag/Description/The <tt/strspn/ function computes and returns the length of
5041 the substring pointed to by <tt/s/ which does consist only of characters
5042 contained in the string <tt/set/.
5043 <tag/Limits/<itemize>
5044 <item>The function is only available as fastcall function, so it may only
5045 be used in presence of a prototype.
5047 <tag/Availability/ISO 9899
5049 <ref id="strcspn" name="strcspn">,
5050 <ref id="strstr" name="strstr">
5056 <sect1>strstr<label id="strstr"><p>
5060 <tag/Function/Find a substring.
5061 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5062 <tag/Declaration/<tt/char* __fastcall__ strstr (const char* str, const char* substr);/
5063 <tag/Description/<tt/strstr/ searches for the first occurance of the string
5064 <tt/substr/ within <tt/str/. If found, it returns a pointer to the copy,
5065 otherwise it returns <tt/NULL/.
5066 <tag/Limits/<itemize>
5067 <item>The function is only available as fastcall function, so it may only
5068 be used in presence of a prototype.
5070 <tag/Availability/ISO 9899
5072 <ref id="strcspn" name="strcspn">,
5073 <ref id="strspn" name="strspn">
5079 <sect1>strtok<label id="strtok"><p>
5083 <tag/Function/Break a string into tokens.
5084 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5085 <tag/Declaration/<tt/char* __fastcall__ strtok (char* s1, const char* s2);/
5086 <tag/Description/<tt/strtok/ will break the string s1 into a sequence of
5087 tokens, which are delimited by characters from the string s2. The first call
5088 to <tt/strtok/ will return a pointer to the first token in the string s1.
5089 Following calls must pass a <tt/NULL/ pointer as s1 in order to get the next
5090 token in the string. Different sets of delimiters may be used for the
5091 subsequent calls to <tt/strtok/.
5092 <tag/Limits/<itemize>
5093 <item>The function is only available as fastcall function, so it may only
5094 be used in presence of a prototype.
5095 <item><tt/strtok/ will modify the string s1.
5097 <tag/Availability/ISO 9899
5099 <ref id="strcspn" name="strcspn">,
5100 <!-- <ref id="strpbrk" name="strpbrk"> -->
5106 <sect1>strxfrm<label id="strxfrm"><p>
5110 <tag/Function/Transform a string.
5111 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5112 <tag/Declaration/<tt/size_t __fastcall__ strxfrm (char* s1, const char* s2, size_t n);/
5113 <tag/Description/The <tt/strxfrm/ function transforms the string pointed to by
5114 s2 and places the resulting string into the string pointed to by s1. The
5115 transformation is such that if the <tt/strcmp/ function is applied to two
5116 transformed strings, it returns a value greater than, equal to, or less than
5117 zero, corresponding to the result of the <tt/strcoll/ function applied to the
5118 same two original strings. No more than n characters are placed into the
5119 resulting array pointed to by s1, including the terminating null character.
5120 <tag/Limits/<itemize>
5121 <item><tt/s1/ and <tt/s2/ must not point to the same memory area, otherwise
5122 the behaviour is undefined.
5123 <item>If <tt/n/ is zero, <tt/s1/ may be a NULL pointer.
5124 <item>The function is only available as fastcall function, so it may only
5125 be used in presence of a prototype.
5126 <item>Since cc65 doesn't support different charcter sets, <tt/strxfrm/ will
5127 just copy s2 to s1 using <tt><ref id="strncpy" name="strncpy"></tt>.
5129 <tag/Availability/ISO 9899
5131 <ref id="strcmp" name="strcmp">,
5132 <ref id="strcoll" name="strcoll">,
5133 <ref id="strncpy" name="strncpy">,
5139 <sect1>strupper<label id="strupper"><p>
5143 <tag/Function/Make a string upper case.
5144 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5145 <tag/Declaration/<tt/char* __fastcall__ strupper (char* s);/
5146 <tag/Description/The <tt/strupper/ function will apply the <tt/toupper/
5147 function to each character of a string. The function will always return <tt/s/.
5148 <tag/Limits/<itemize>
5149 <item>The function is only available as fastcall function, so it may only
5150 be used in presence of a prototype.
5151 <item>The function prototype is unavailable when compiling in strict ANSI mode.
5152 <item>An alias name for this function is <tt/strupr/.
5154 <tag/Availability/cc65
5156 <ref id="strlower" name="strlower">
5157 <ref id="toupper" name="toupper">
5163 <sect1>strupr<label id="strupr"><p>
5170 <sect1>textcolor<label id="textcolor"><p>
5174 <tag/Function/Set the text color.
5175 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
5176 <tag/Declaration/<tt/unsigned char __fastcall__ textcolor (unsigned char color);/
5177 <tag/Description/The function will set a new text color. It returns the old
5178 (current) text color. Text output using any <tt/conio.h/ function will use
5179 the color set by this function.
5180 <tag/Limits/<itemize>
5181 <item>Text colors are system dependent. The function may have no effect
5182 on systems where the text color cannot be changed.
5183 <item>The function is only available as fastcall function, so it may only
5184 be used in presence of a prototype.
5186 <tag/Availability/cc65
5188 <ref id="bgcolor" name="bgcolor">,
5189 <ref id="bordercolor" name="bordercolor">
5195 <sect1>tgi_arc<label id="tgi_arc"><p>
5199 <tag/Function/Draw an elliptic arc in the current color.
5200 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5201 <tag/Declaration/<tt/void __fastcall__ tgi_arc (int x, int y,
5202 unsigned char rx, unsigned char ry, unsigned sa, unsigned ea);/
5203 <tag/Description/The function draws an elliptic arc with center at x/y and
5204 radii rx/ry using the current drawing color. The arc covers the angle
5205 between sa and ea (startangle and endangle), which must be in the range
5207 <tag/Limits/<itemize>
5208 <item>The function is only available as fastcall function, so it may only
5209 be used in presence of a prototype.
5210 <item>The function behaves unexpectedly or may crash if the angles are out
5213 <tag/Availability/cc65
5215 <ref id="tgi_bar" name="tgi_bar">,
5216 <ref id="tgi_circle" name="tgi_circle">,
5217 <ref id="tgi_ellipse" name="tgi_ellipse">,
5218 <ref id="tgi_pieslice" name="tgi_pieslice">,
5219 <ref id="tgi_setcolor" name="tgi_setcolor">
5221 /* Draw the upper half of an ellipse */
5222 tgi_setcolor(TGI_COLOR_BLUE);
5223 tgi_arc (50, 50, 40, 20, 0, 180);
5229 <sect1>tgi_bar<label id="tgi_bar"><p>
5233 <tag/Function/The function fills a rectangle on the drawpage with the current
5235 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5236 <tag/Declaration/<tt/void __fastcall__ tgi_bar (int x1, int y1, int x2, int y2);/
5237 <tag/Description/The function fills a rectangle on the drawpage with the current
5239 <tag/Limits/<itemize>
5240 <item>The function is only available as fastcall function, so it may only
5241 be used in presence of a prototype.
5243 <tag/Availability/cc65
5244 <tag/See also/Other tgi function
5246 tgi_setcolor(TGI_COLOR_GREEN);
5247 tgi_bar(10, 10, 100, 60);
5253 <sect1>tgi_circle<label id="tgi_circle"><p>
5257 <tag/Function/The function draws a circle in the current color.
5258 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5259 <tag/Declaration/<tt/void __fastcall__ tgi_circle (int x, int y, unsigned char radius);/
5260 <tag/Description/The function draws a circle in the current color.
5261 <tag/Limits/<itemize>
5262 <item>The function is only available as fastcall function, so it may only
5263 be used in presence of a prototype.
5265 <tag/Availability/cc65
5267 <ref id="tgi_arc" name="tgi_arc">,
5268 <ref id="tgi_bar" name="tgi_bar">,
5269 <ref id="tgi_ellipse" name="tgi_ellipse">,
5270 <ref id="tgi_pieslice" name="tgi_pieslice">,
5271 <ref id="tgi_setcolor" name="tgi_setcolor">
5273 tgi_setcolor(TGI_COLOR_BLACK);
5274 tgi_circle(50, 40, 40);
5280 <sect1>tgi_clear<label id="tgi_clear"><p>
5284 <tag/Function/Clear the drawpage
5285 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5286 <tag/Declaration/<tt/void tgi_clear (void);/
5287 <tag/Description/Clear the drawpage
5288 <tag/Availability/cc65
5289 <tag/See also/Other tgi functions
5295 <sect1>tgi_done<label id="tgi_done"><p>
5299 <tag/Function/End graphics mode, switch back to text mode.
5300 Will NOT uninstall or unload the driver!
5301 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5302 <tag/Declaration/<tt/void tgi_done (void);/
5303 <tag/Description/End graphics mode, switch back to text mode.
5304 Will NOT uninstall or unload the driver!
5305 <tag/Availability/cc65
5306 <tag/See also/Other tgi functions
5312 <sect1>tgi_ellipse<label id="tgi_ellipse"><p>
5316 <tag/Function/The function draws an ellipse in the current color.
5317 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5318 <tag/Declaration/<tt/void __fastcall__ tgi_ellipse (int x, int y, unsigned char rx, unsigned char ry);/
5319 <tag/Description/The function draws an ellipse at position x/y with radii
5320 rx and ry, using the current drawing color.
5321 <tag/Limits/<itemize>
5322 <item>The function is only available as fastcall function, so it may only
5323 be used in presence of a prototype.
5325 <tag/Availability/cc65
5327 <ref id="tgi_arc" name="tgi_arc">,
5328 <ref id="tgi_bar" name="tgi_bar">,
5329 <ref id="tgi_circle" name="tgi_circle">,
5330 <ref id="tgi_pieslice" name="tgi_pieslice">,
5331 <ref id="tgi_setcolor" name="tgi_setcolor">
5333 tgi_setcolor(TGI_COLOR_RED);
5334 tgi_ellipse (50, 40, 40, 20);
5340 <sect1>tgi_getaspectratio<label id="tgi_getaspectratio"><p>
5342 <quote> <descrip> <tag/Function/Return the pixel aspect ratio.
5343 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5344 <tag/Declaration/<tt/unsigned tgi_getaspectratio (void);/
5345 <tag/Description/The function returns the pixel aspect ratio for the current
5346 driver and display as an 8.8 fixed point value. It may be used to correct
5347 geometric shapes so they look correct on the display. As an example, a circle
5348 with a radius of 100 pixels may look elliptic on some driver/display
5349 combinations if the aspect ratio is not 1.00.
5350 <tag/Limits/<itemize>
5351 <item>The aspect ratio is encoded in the TGI driver which assumes a "standard"
5352 monitor for the given platform. The aspect ratio may be wrong if another
5354 <item>No TGI function will use the aspect ratio. It is up to the programmer to
5356 <item>The <ref id="tgi_setaspectratio" name="tgi_setaspectratio"> function can
5357 be used to change the aspect ratio for a loaded driver. The value is not reset
5358 by <ref id="tgi_init" name="tgi_init">, so if a driver is linked statically to
5359 an application, switching into and out of graphics mode will not restore the
5360 original aspect ratio.
5362 <tag/Availability/cc65
5364 <ref id="tgi_setaspectratio" name="tgi_setaspectratio">
5370 <sect1>tgi_getcolor<label id="tgi_getcolor"><p>
5374 <tag/Function/Return the current drawing color.
5375 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5376 <tag/Declaration/<tt/unsigned char tgi_getcolor (void);/
5377 <tag/Description/The actual color is an index to a palette. During tgi_init
5378 you will get a default palette. The number of colors depend on the platform.
5379 All platforms recognize at least TGI_COLOR_BLACK and TGI_COLOR_WHITE. But some
5380 platforms have many more predefined colors. If you paint using TGI_COLOR_GREEN
5381 and then you change the green of the palette to blue using tgi_setpalette then
5382 after this painting in TGI_COLOR_GREEN will actually be blue.
5383 <tag/Availability/cc65
5384 <tag/See also/Other tgi functions
5386 color = tgi_getcolor();
5392 <sect1>tgi_getcolorcount<label id="tgi_getcolorcount"><p>
5396 <tag/Function/Get the number of available colors.
5397 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5398 <tag/Declaration/<tt/unsigned char tgi_getcolorcount (void);/
5399 <tag/Description/Tgi platforms use indexed color palettes. This function
5400 returns the number of entries we can use in the palette.
5401 <tag/Availability/cc65
5402 <tag/See also/Other tgi functions
5404 if (tgi_getcolorcount() == 2) {
5405 printf("Only monochrome graphics is supported\n");
5412 <sect1>tgi_getdefpalette<label id="tgi_getdefpalette"><p>
5416 <tag/Function/Get the palette installed by default.
5417 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5418 <tag/Declaration/<tt/const unsigned char* tgi_getdefpalette (void);/
5419 <tag/Description/The tgi driver has a default palette that is active at startup.
5420 The named colors TGI_COLOR_BLACK, TGI_COLOR_WHITE, TGI_COLOR_RED... need this
5421 palette to work correctly.
5422 <tag/Availability/cc65
5423 <tag/See also/Other tgi functions
5429 <sect1>tgi_geterror<label id="tgi_geterror"><p>
5433 <tag/Function/Return the error code for the last operation.
5434 This will also clear the error.
5435 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5436 <tag/Declaration/<tt/unsigned char tgi_geterror (void);/
5437 <tag/Description/Return the error code for the last operation.
5438 This will also clear the error.
5439 <tag/Availability/cc65
5440 <tag/See also/Other tgi functions
5446 <sect1>tgi_geterrormsg<label id="tgi_geterrormsg"><p>
5450 <tag/Function/Get an error message describing the error.
5451 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5452 <tag/Declaration/<tt/const char* __fastcall__ tgi_geterrormsg (unsigned char code);/
5453 <tag/Description/Get an error message describing the error.
5454 <tag/Limits/<itemize>
5455 <item>The function is only available as fastcall function, so it may only
5456 be used in presence of a prototype.
5458 <tag/Availability/cc65
5459 <tag/See also/Other tgi functions
5465 <sect1>tgi_getmaxcolor<label id="tgi_getmaxcolor"><p>
5469 <tag/Function/Get the highest index of the palette.
5470 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5471 <tag/Declaration/<tt/unsigned char tgi_getmaxcolor (void);/
5472 <tag/Description/Get the highest index of the palette.
5473 <tag/Availability/cc65
5474 <tag/See also/Other tgi functions
5480 <sect1>tgi_getmaxx<label id="tgi_getmaxx"><p>
5484 <tag/Function/Get the maximum x coordinate that can be used on this screen.
5485 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5486 <tag/Declaration/<tt/unsigned tgi_getmaxx (void);/
5487 <tag/Description/Get the maximum x coordinate that can be used on this screen.
5488 <tag/Availability/cc65
5489 <tag/See also/Other tgi functions
5495 <sect1>tgi_getmaxy<label id="tgi_getmaxy"><p>
5499 <tag/Function/Get the maximum y coordinate that can be used on this screen.
5500 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5501 <tag/Declaration/<tt/unsigned tgi_getmaxy (void);/
5502 <tag/Description/Get the maximum y coordinate that can be used on this screen.
5503 <tag/Availability/cc65
5504 <tag/See also/Other tgi functions
5510 <sect1>tgi_getpagecount<label id="tgi_getpagecount"><p>
5514 <tag/Function/Return the number of screen pages available.
5515 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5516 <tag/Declaration/<tt/unsigned tgi_getpagecount (void);/
5517 <tag/Description/Return the number of screen pages available.
5518 <tag/Availability/cc65
5520 <ref id="tgi_setdrawpage" name="tgi_setdrawpage">,
5521 <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* tgi_getpalette (void);/
5534 <tag/Description/Get the palette installed.
5535 <tag/Availability/cc65
5536 <tag/See also/Other tgi functions
5542 <sect1>tgi_getpixel<label id="tgi_getpixel"><p>
5546 <tag/Function/Get the color of a pixel from the viewpage.
5547 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5548 <tag/Declaration/<tt/unsigned char __fastcall__ tgi_getpixel (int x, int y);/
5549 <tag/Description/Get the color of a pixel from the viewpage.
5550 <tag/Limits/<itemize>
5551 <item>The function is only available as fastcall function, so it may only
5552 be used in presence of a prototype.
5554 <tag/Availability/cc65
5555 <tag/See also/Other tgi functions.
5561 <sect1>tgi_getxres<label id="tgi_getxres"><p>
5565 <tag/Function/Get number of horisontal pixels on the screen.
5566 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5567 <tag/Declaration/<tt/unsigned tgi_getxres (void);/
5568 <tag/Description/Get number of horisontal pixels on the screen.
5569 This is same as tgi_maxx()+1.
5570 <tag/Availability/cc65
5571 <tag/See also/Other tgi functions.
5577 <sect1>tgi_getyres<label id="tgi_getyres"><p>
5581 <tag/Function/Get number of vertical pixels on the screen.
5582 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5583 <tag/Declaration/<tt/unsigned tgi_getyres (void);/
5584 <tag/Description/Get number of vertical pixels on the screen.
5585 This is same as tgi_maxy()+1.
5586 <tag/Availability/cc65
5587 <tag/See also/Other tgi functions.
5593 <sect1>tgi_gotoxy<label id="tgi_gotoxy"><p>
5597 <tag/Function/Set graphics cursor at x, y.
5598 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5599 <tag/Declaration/<tt/void __fastcall__ tgi_gotoxy (int x, int y);/
5600 <tag/Description/Set graphics cursor at x, y.
5601 <tag/Limits/<itemize>
5602 <item>The function is only available as fastcall function, so it may only
5603 be used in presence of a prototype.
5605 <tag/Availability/cc65
5606 <tag/See also/Other tgi functions.
5612 <sect1>tgi_init<label id="tgi_init"><p>
5616 <tag/Function/Initialize the already loaded graphics driver.
5617 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5618 <tag/Declaration/<tt/void tgi_init (void);/
5619 <tag/Description/The tgi_init function will set the default palette to the
5621 <tag/Limits/<itemize>
5622 <item><tt/tgi_init/ will not clear the screen. This allows switching between
5623 text and graphics mode on platforms that have separate memory areas for the
5624 screens. If you want the screen cleared, call <tt/<ref id="tgi_clear"
5625 name="tgi_clear">/ after <tt/tgi_init/.
5627 <tag/Availability/cc65
5628 <tag/See also/Other tgi functions.
5630 extern char lynxtgi[]; //Include the driver statically instead of loading it.
5631 tgi_install(&lynxtgi);
5632 tgi_init(); //Set up the default palette and clear the screen.
5638 <sect1>tgi_install<label id="tgi_install"><p>
5642 <tag/Function/Install an already loaded driver and return an error code.
5643 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5644 <tag/Declaration/<tt/unsigned char __fastcall__ tgi_install (void* driver);/
5645 <tag/Description/The function installs a driver that was already loaded into
5646 memory (or linked statically to the program). It returns an error code
5647 (<tt/TGI_ERR_OK/ in case of success).
5648 <tag/Limits/<itemize>
5649 <item>The function is only available as fastcall function, so it may only be
5650 used in presence of a prototype.
5652 <tag/Availability/cc65
5654 <ref id="tgi_load_driver" name="tgi_load_driver">,
5655 <ref id="tgi_uninstall" name="tgi_uninstall">,
5656 <ref id="tgi_unload" name="tgi_unload">
5658 extern char lynxtgi[]; //Include the driver statically instead of loading it.
5660 tgi_install(&lynxtgi);
5661 tgi_init(); //Set up the default palette and clear the screen.
5667 <sect1>tgi_ioctl<label id="tgi_ioctl"><p>
5671 <tag/Function/Platform dependent code extensions.
5672 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5673 <tag/Declaration/<tt/unsigned __fastcall__ tgi_ioctl (unsigned char code, void* data);/
5674 <tag/Description/Some platforms have extra display hardware that is not
5675 supported by standard tgi functions. You can extend the driver to support
5676 this extra hardware using tgi_ioctl functions.
5677 <tag/Limits/<itemize>
5678 <item>The function is only available as fastcall function, so it may only
5679 be used in presence of a prototype.
5680 <item>These functions are not easily portable to other cc65 platforms.
5682 <tag/Availability/cc65
5683 <tag/See also/Other tgi functions.
5685 #define tgi_sprite(spr) tgi_ioctl(0, (void*)(spr))
5686 #define tgi_flip() tgi_ioctl(1, (void*)0)
5687 #define tgi_setbgcolor(bgcol) tgi_ioctl(2, (void*)(bgcol))
5688 #define tgi_setframerate(rate) tgi_ioctl(3, (void*)(rate))
5689 #define tgi_busy() tgi_ioctl(4, (void*)0)
5690 #define tgi_updatedisplay() tgi_ioctl(4, (void*)1)
5692 tgi_sprite(&background);
5693 tgi_setcolor(TGI_COLOR_BLUE);
5694 tgi_outttextxy(20,40,"Hello World");
5695 tgi_updatedisplay();
5702 <sect1>tgi_line<label id="tgi_line"><p>
5706 <tag/Function/Draw a line in the current drawing color.
5707 The graphics cursor will be set to x2/y2 by this call.
5708 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5709 <tag/Declaration/<tt/void __fastcall__ tgi_line (int x1, int y1, int x2, int y2);/
5710 <tag/Description/Draw a line in the current drawing color.
5711 The graphics cursor will be set to x2/y2 by this call.
5712 <tag/Limits/<itemize>
5713 <item>The function is only available as fastcall function, so it may only
5714 be used in presence of a prototype.
5716 <tag/Availability/cc65
5717 <tag/See also/Other tgi functions.
5723 <sect1>tgi_lineto<label id="tgi_lineto"><p>
5727 <tag/Function/Draw a line in the current drawing color from the graphics
5728 cursor to the new end point. The graphics cursor will be updated to x2/y2.
5729 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5730 <tag/Declaration/<tt/void __fastcall__ tgi_lineto (int x2, int y2);/
5731 <tag/Description/Draw a line in the current drawing color from the graphics
5732 cursor to the new end point. The graphics cursor will be updated to x2/y2.
5733 <tag/Limits/<itemize>
5734 <item>The function is only available as fastcall function, so it may only
5735 be used in presence of a prototype.
5737 <tag/Availability/cc65
5738 <tag/See also/Other tgi functions.
5744 <sect1>tgi_load_driver<label id="tgi_load_driver"><p>
5748 <tag/Function/Load and install the given driver.
5749 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5750 <tag/Declaration/<tt/void __fastcall__ tgi_load_driver (const char *name);/
5751 <tag/Description/Load and install the driver by name.
5752 Will just load the driver and check if loading was successful.
5753 Will not switch to graphics mode.
5754 <tag/Limits/<itemize>
5755 <item>The function is only available as fastcall function, so it may only
5756 be used in presence of a prototype.
5758 <tag/Availability/cc65
5759 <tag/See also/Other tgi functions.
5765 <sect1>tgi_outtext<label id="tgi_outtext"><p>
5769 <tag/Function/Output text at the current graphics cursor position.
5770 The graphics cursor is moved to the end of the text.
5771 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5772 <tag/Declaration/<tt/void __fastcall__ tgi_outtext (const char* s);/
5773 <tag/Description/Output text at the current graphics cursor position.
5774 The graphics cursor is moved to the end of the text.
5775 <tag/Limits/<itemize>
5776 <item>The function is only available as fastcall function, so it may only
5777 be used in presence of a prototype.
5779 <tag/Availability/cc65
5780 <tag/See also/Other tgi functions.
5786 <sect1>tgi_outtextxy<label id="tgi_outtextxy"><p>
5790 <tag/Function/Output text at the given cursor position.
5791 The graphics cursor is moved to the end of the text.
5792 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5793 <tag/Declaration/<tt/void __fastcall__ tgi_outtextxy (int x, int y, const char* s);/
5794 <tag/Description/Output text at the given cursor position.
5795 The graphics cursor is moved to the end of the text.
5796 <tag/Limits/<itemize>
5797 <item>The function is only available as fastcall function, so it may only
5798 be used in presence of a prototype.
5800 <tag/Availability/cc65
5801 <tag/See also/Other tgi functions.
5807 <sect1>tgi_pieslice<label id="tgi_pieslice"><p>
5811 <tag/Function/Draw an elliptic pie slice in the current color.
5812 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5813 <tag/Declaration/<tt/void __fastcall__ tgi_pie slice (int x, int y,
5814 unsigned char rx, unsigned char ry, unsigned sa, unsigned ea);/
5815 <tag/Description/The function draws an elliptic pie slice with center at x/y
5816 and radii rx/ry using the current drawing color. The pie slice covers the angle
5817 between sa and ea (startangle and endangle), which must be in the range
5819 <tag/Limits/<itemize>
5820 <item>The function is only available as fastcall function, so it may only
5821 be used in presence of a prototype.
5822 <item>The function behaves unexpectedly or may crash if the angles are out
5825 <tag/Availability/cc65
5827 <ref id="tgi_bar" name="tgi_arc">,
5828 <ref id="tgi_bar" name="tgi_bar">,
5829 <ref id="tgi_circle" name="tgi_circle">,
5830 <ref id="tgi_ellipse" name="tgi_ellipse">,
5831 <ref id="tgi_setcolor" name="tgi_setcolor">
5833 /* Draw the closed upper half of an ellipse */
5834 tgi_setcolor(TGI_COLOR_BLUE);
5835 tgi_pieslice (50, 50, 40, 20, 0, 180);
5841 <sect1>tgi_setaspectratio<label id="tgi_setaspectratio"><p>
5843 <quote> <descrip> <tag/Function/Set the pixel aspect ratio.
5844 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5845 <tag/Declaration/<tt/void __fastcall__ tgi_setaspectratio (unsigned ratio);/
5846 <tag/Description/The function sets the pixel aspect ratio for the current
5847 driver and display. The argument is an 8.8 fixed point value. The aspect ratio
5848 may be used to correct geometric shapes so they look correct on a given
5849 display. As an example, a circle with a radius of 100 pixels may look elliptic
5850 on some driver/display combinations if the aspect ratio is not 1.00.
5851 <tag/Limits/<itemize>
5852 <item>The aspect ratio is encoded in the TGI driver which assumes a "standard"
5853 monitor for the given platform. The aspect ratio may be wrong if another
5855 <item>No TGI function will use the aspect ratio. It is up to the programmer to
5857 <item>The <tt/tgi_setaspectratio/ function can be used to change the aspect
5858 ratio for a loaded driver. The value is not reset by <ref id="tgi_init"
5859 name="tgi_init">, so if a driver is linked statically to an application,
5860 switching into and out of graphics mode will not restore the original aspect
5863 <tag/Availability/cc65
5865 <ref id="tgi_getaspectratio" name="tgi_getaspectratio">
5871 <sect1>tgi_setcolor<label id="tgi_setcolor"><p>
5875 <tag/Function/Set color to be used in future draw operations.
5876 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5877 <tag/Declaration/<tt/void __fastcall__ tgi_setcolor (unsigned char color);/
5878 <tag/Description/Set color to be used in future draw operations.
5879 <tag/Limits/<itemize>
5880 <item>The function is only available as fastcall function, so it may only
5881 be used in presence of a prototype.
5883 <tag/Availability/cc65
5884 <tag/See also/Other tgi functions.
5886 tgi_setcolor(TGI_COLOR_BLACK);
5888 tgi_setcolor(TGI_COLOR_WHITE);
5889 tgi_bar(10,10,20,20);
5894 <sect1>tgi_setdrawpage<label id="tgi_setdrawpage"><p>
5898 <tag/Function/Set the page for drawing.
5899 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5900 <tag/Declaration/<tt/void __fastcall__ tgi_setdrawpage (unsigned char page);/
5901 <tag/Description/If the drawpage and the viewpage are the same then all drawing
5902 is seen immediately as it is drawn. For double buffered games you can set the
5903 drawpage to a different page than the viewpage. This lets you draw the next
5904 screen in the background and when the screen is ready you display it.
5905 <tag/Limits/<itemize>
5906 <item>The function is only available as fastcall function, so it may only
5907 be used in presence of a prototype.
5909 <tag/Availability/cc65
5910 <tag/See also/Other tgi functions.
5913 tgi_outtextxy(10, 10, "Hello World");
5914 tgi_setviewpage(1); // Show page 1
5916 tgi_outtextxy(10, 10, "Creating next frame");
5918 tgi_setviewpage(0); // Show page 0
5923 <sect1>tgi_setpalette<label id="tgi_setpalette"><p>
5927 <tag/Function/Set the palette (not available with all drivers/hardware).
5928 Palette is a pointer to as many entries as there are colors.
5929 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5930 <tag/Declaration/<tt/void __fastcall__ tgi_setpalette (const unsigned char* palette);/
5931 <tag/Description/Set the palette (not available with all drivers/hardware).
5932 Palette is a pointer to as many entries as there are colors.
5933 <tag/Limits/<itemize>
5934 <item>The function is only available as fastcall function, so it may only
5935 be used in presence of a prototype.
5937 <tag/Availability/cc65
5938 <tag/See also/Other tgi functions.
5943 <sect1>tgi_setpixel<label id="tgi_setpixel"><p>
5947 <tag/Function/Plot a pixel on the drawpage with the current color.
5948 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5949 <tag/Declaration/<tt/void __fastcall__ tgi_setpixel (int x, int y);/
5950 <tag/Description/Plot a pixel on the drawpage with the current color.
5951 <tag/Limits/<itemize>
5952 <item>The function is only available as fastcall function, so it may only
5953 be used in presence of a prototype.
5955 <tag/Availability/cc65
5956 <tag/See also/Other tgi functions.
5961 <sect1>tgi_setviewpage<label id="tgi_setviewpage"><p>
5965 <tag/Function/Set page to be visible on screen.
5966 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5967 <tag/Declaration/<tt/void __fastcall__ tgi_setviewpage (unsigned char page);/
5968 <tag/Description/If the drawpage and the viewpage are the same then all drawing
5969 is seen immediately as it is drawn. For double buffered games you can set the
5970 drawpage to a different page than the viewpage. This lets you draw the next
5971 screen in the background and when the screen is ready you display it.
5972 <tag/Limits/<itemize>
5973 <item>The function is only available as fastcall function, so it may only
5974 be used in presence of a prototype.
5976 <tag/Availability/cc65
5977 <tag/See also/Other tgi functions.
5980 tgi_outtextxy(10, 10, "Hello World");
5981 tgi_setviewpage(1); // Show page 1
5983 tgi_outtextxy(10, 10, "Creating next frame");
5985 tgi_setviewpage(0); // Show page 0
5990 <sect1>tgi_gettextheight<label id="tgi_gettextheight"><p>
5994 <tag/Function/Calculate the height of the text in pixels according to
5995 the current text style.
5996 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5997 <tag/Declaration/<tt/unsigned __fastcall__ tgi_gettextheight (const char* s);/
5998 <tag/Description/Calculate the height of the text in pixels according to
5999 the current text style.
6000 <tag/Limits/<itemize>
6001 <item>The function is only available as fastcall function, so it may only
6002 be used in presence of a prototype.
6004 <tag/Availability/cc65
6005 <tag/See also/Other tgi functions.
6010 <sect1>tgi_settextstyle<label id="tgi_settextstyle"><p>
6014 <tag/Function/Set the style for text output.
6015 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6016 <tag/Declaration/<tt/void __fastcall__ tgi_settextstyle (unsigned char magx, unsigned char magy, unsigned char dir);/
6017 <tag/Description/Set the style for text output.
6018 <tag/Limits/<itemize>
6019 <item>The function is only available as fastcall function, so it may only
6020 be used in presence of a prototype.
6022 <tag/Availability/cc65
6023 <tag/See also/Other tgi functions.
6028 <sect1>tgi_gettextwidth<label id="tgi_gettextwidth"><p>
6032 <tag/Function/Calculate the width of the text in pixels according to the current text style.
6033 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6034 <tag/Declaration/<tt/unsigned __fastcall__ tgi_gettextwidth (const char* s);/
6035 <tag/Function/Calculate the width of the text in pixels according to the current text style.
6036 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6037 <tag/Description/Calculate the width of the text in pixels according to the current text style.
6038 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6039 <tag/Limits/<itemize>
6040 <item>The function is only available as fastcall function, so it may only
6041 be used in presence of a prototype.
6043 <tag/Availability/cc65
6044 <tag/See also/Other tgi functions.
6049 <sect1>tgi_uninstall<label id="tgi_uninstall"><p>
6053 <tag/Function/Uninstall the currently loaded driver but do not unload it.
6054 Will call tgi_done if necessary.
6055 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6056 <tag/Declaration/<tt/void tgi_uninstall (void);/
6057 <tag/Description/Uninstall the currently loaded driver but do not unload it.
6058 Will call tgi_done if necessary.
6059 <tag/Availability/cc65
6060 <tag/See also/Other tgi functions.
6065 <sect1>tgi_unload<label id="tgi_unload"><p>
6069 <tag/Function/Uninstall, then unload the currently loaded driver.
6070 Will call tgi_done if necessary.
6071 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6072 <tag/Declaration/<tt/void tgi_unload (void);/
6073 <tag/Description/Uninstall, then unload the currently loaded driver.
6074 Will call tgi_done if necessary.
6075 <tag/Availability/cc65
6076 <tag/See also/Other tgi functions.
6081 <sect1>time<label id="time"><p>
6085 <tag/Function/Get the time.
6086 <tag/Header/<tt/<ref id="time.h" name="time.h">/
6087 <tag/Declaration/<tt/time_t __fastcall__ time (time_t* t);/
6088 <tag/Description/The function returns the time since the 1970-01-01 00:00:00
6089 measured in seconds. If the pointer <tt/t/ is not <tt/NULL/, the function
6090 result will also be stored there. If no time is available, <tt/(time_t)-1/ is
6091 returned and <tt/errno/ is set to <tt/ENOSYS/.
6092 <tag/Limits/<itemize>
6093 <item>The function is only available as fastcall function, so it may
6094 only be used in presence of a prototype.
6095 <item>Many platforms supported by cc65 do not have a realtime clock, so the
6096 returned value may not be valid.
6098 <tag/Availability/ISO 9899
6104 <sect1>toggle_videomode<label id="toggle_videomode"><p>
6108 <tag/Function/Toggle between 40 and 80 column mode.
6109 <tag/Header/<tt/<ref id="c128.h" name="c128.h">/
6110 <tag/Declaration/<tt/void toggle_videomode (void);/
6111 <tag/Description/Toggle between 40 and 80 column mode. The settings for the
6112 old mode (cursor position, color and so on) are saved and restored together
6114 <tag/Limits/<itemize>
6115 <item>The function is specific to the C128.
6116 <item>This function is deprecated. Please use <ref id="videomode"
6117 name="videomode"> instead!
6119 <tag/Availability/C128
6121 <ref id="fast" name="fast">,
6122 <ref id="slow" name="slow">,
6123 <ref id="videomode" name="videomode">
6129 <sect1>tolower<label id="tolower"><p>
6133 <tag/Function/Convert a character into its lower case representation.
6134 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
6135 <tag/Declaration/<tt/int __fastcall__ tolower (int c);/
6136 <tag/Description/The function returns the given character converted to lower
6137 case. If the given character is not a letter, it is returned unchanged.
6138 <tag/Limits/<itemize>
6139 <item>The function is only available as fastcall function, so it may
6140 only be used in presence of a prototype.
6142 <tag/Availability/ISO 9899
6144 <ref id="islower" name="islower">,
6145 <ref id="isupper" name="isupper">,
6146 <ref id="toupper" name="toupper">
6152 <sect1>toupper<label id="toupper"><p>
6156 <tag/Function/Convert a character into its upper case representation.
6157 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
6158 <tag/Declaration/<tt/int __fastcall__ toupper (int c);/
6159 <tag/Description/The function returns the given character converted to upper
6160 case. If the given character is not a letter, it is returned unchanged.
6161 <tag/Limits/<itemize>
6162 <item>The function is only available as fastcall function, so it may
6163 only be used in presence of a prototype.
6165 <tag/Availability/ISO 9899
6167 <ref id="islower" name="islower">,
6168 <ref id="isupper" name="isupper">,
6169 <ref id="tolower" name="tolower">
6175 <sect1>ultoa<label id="ultoa"><p>
6179 <tag/Function/Convert an unsigned long integer into a string.
6180 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
6181 <tag/Declaration/<tt/char* __fastcall__ ultoa (unsigned long val, char* buf, int radix);/
6182 <tag/Description/<tt/itoa/ converts the unsigned long integer <tt/val/ into a
6183 string using <tt/radix/ as the base.
6184 <tag/Limits/<itemize>
6185 <item>There are no provisions to prevent a buffer overflow.
6186 <item>The function is non standard, so it is not available in strict ANSI mode.
6187 You should probably use <tt/sprintf/ instead.
6188 <item>The function is only available as fastcall function, so it may only be
6189 used in presence of a prototype.
6191 <tag/Availability/cc65
6193 <ref id="atoi" name="atoi">,
6194 <ref id="atol" name="atol">,
6195 <ref id="itoa" name="itoa">,
6196 <ref id="ltoa" name="ltoa">,
6197 <ref id="utoa" name="utoa">
6203 <sect1>unlink<label id="unlink"><p>
6207 <tag/Function/Delete a file.
6208 <tag/Header/<tt/<ref id="unistd.h" name="unistd.h">/
6209 <tag/Declaration/<tt/int __fastcall__ unlink (const char* name);/
6210 <tag/Description/<tt/unlink/ deletes the file with the given name. On success,
6211 zero is returned. On error, -1 is returned and <tt/errno/ is set to an error
6212 code describing the reason for the failure.
6215 <item>The use of this function is discouraged. Please use <tt/<ref id="remove"
6216 name="remove">/ instead, which is a native ANSI C function and does the same.
6217 <item>This function is not available on all cc65 targets (depends on the
6218 availability of file I/O).
6219 <item>The function is only available as fastcall function, so it may only
6220 be used in presence of a prototype.
6221 <item>Instead of <tt/unlink/, <tt/<ref id="remove" name="remove">/ should be
6222 used, which has the same semantics, but is more portable, because it conforms
6223 to the ISO C standard.
6225 <tag/Availability/POSIX 1003.1
6227 <ref id="remove" name="remove">
6230 #include <stdio.h>
6231 #include <unistd.h>
6233 #define FILENAME "helloworld"
6235 if (unlink (FILENAME) == 0) {
6236 printf ("We deleted %s successfully\n", FILENAME);
6238 printf ("There was a problem deleting %s\n", FILENAME);
6245 <sect1>utoa<label id="utoa"><p>
6249 <tag/Function/Convert an unsigned integer into a string.
6250 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
6251 <tag/Declaration/<tt/char* __fastcall__ utoa (unsigned val, char* buf, int radix);/
6252 <tag/Description/<tt/itoa/ converts the unsigned integer <tt/val/ into a string
6253 using <tt/radix/ as the base.
6254 <tag/Limits/<itemize>
6255 <item>There are no provisions to prevent a buffer overflow.
6256 <item>The function is non standard, so it is not available in strict ANSI mode.
6257 You should probably use <tt/sprintf/ instead.
6258 <item>The function is only available as fastcall function, so it may only be
6259 used in presence of a prototype.
6261 <tag/Availability/cc65
6263 <ref id="atoi" name="atoi">,
6264 <ref id="atol" name="atol">,
6265 <ref id="itoa" name="itoa">,
6266 <ref id="ltoa" name="ltoa">,
6267 <ref id="ultoa" name="ultoa">
6273 <sect1>vcprintf<label id="vcprintf"><p>
6277 <tag/Function/Formatted output to the console.
6278 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
6279 <tag/Declaration/<tt/int __fastcall__ vcprintf (const char* format, va_list ap);/
6280 <tag/Description/The arguments specified as a <tt/va_list/ are converted to
6281 text where necessary and formatted according to the format string given. The
6282 resulting string is output to the console. <tt/vcprintf/ supports the same
6283 format specifiers as <tt/vprintf/. <!-- <tt/<ref id="vprintf" name="vprintf">/. -->
6284 <tag/Limits/<itemize>
6285 <item>Like all other <tt/conio/ output functions, <tt/vcprintf/ distinguishes
6286 between <tt/\r/ and <tt/\n/.
6287 <item>The function is only available as fastcall function, so it may only be
6288 used in presence of a prototype.
6290 <tag/Availability/cc65
6292 <ref id="cprintf" name="cprintf">,
6293 <ref id="cputc" name="cputc">,
6294 <ref id="cputcxy" name="cputcxy">,
6295 <ref id="cputs" name="cputs">,
6296 <ref id="cputsxy" name="cputsxy">
6302 <sect1>videomode<label id="videomode"><p>
6306 <tag/Function/Switch to either 40 or 80 column mode.
6307 <tag/Header/<tt/<ref id="apple2enh.h" name="apple2enh.h">,
6308 <ref id="c128.h" name="c128.h">/
6309 <tag/Declaration/<tt/unsigned __fastcall__ videomode (unsigned Mode);/
6310 <tag/Description/Switch to 40 or 80 column mode depending on the argument. If
6311 the requested mode is already active, nothing happens. The old mode is returned
6313 <tag/Limits/<itemize>
6314 <item>The function is specific to the C128 and enhanced Apple //e.
6315 <item>This function replaces <ref id="toggle_videomode"
6316 name="toggle_videomode">.
6317 <item>The function is only available as fastcall function, so it may only be
6318 used in presence of a prototype.
6320 <tag/Availability/C128 and enhanced Apple //e
6322 <ref id="fast" name="fast">,
6323 <ref id="slow" name="slow">,
6324 <ref id="toggle_videomode" name="toggle_videomode">
6330 <sect1>wherex<label id="wherex"><p>
6334 <tag/Function/Return the current X position of the text mode cursor.
6335 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
6336 <tag/Declaration/<tt/unsigned char wherex (void);/
6337 <tag/Description/The function returns the current X position of the text mode
6338 cursor. Zero is returned for the leftmost screen position.
6339 <tag/Availability/cc65
6341 <ref id="gotox" name="gotox">,
6342 <ref id="gotoy" name="gotoy">,
6343 <ref id="gotoxy" name="gotoxy">,
6344 <ref id="wherey" name="wherey">
6350 <sect1>wherey<label id="wherey"><p>
6354 <tag/Function/Return the current Y position of the text mode cursor.
6355 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
6356 <tag/Declaration/<tt/unsigned char wherey (void);/
6357 <tag/Description/The function returns the current Y position of the text mode
6358 cursor. Zero is returned for the uppermost screen position.
6359 <tag/Availability/cc65
6361 <ref id="gotox" name="gotox">,
6362 <ref id="gotoy" name="gotoy">,
6363 <ref id="gotoxy" name="gotoxy">,
6364 <ref id="wherex" name="wherex">