1 <!doctype linuxdoc system>
4 <title>cc65 function reference
5 <author>Ullrich von Bassewitz, <htmlurl url="mailto:uz@cc65.org" name="uz@cc65.org">
9 cc65 is a C compiler for 6502 based systems. This function reference describes
10 the C functions available in the standard library.
13 <!-- Table of contents -->
16 <!-- Begin the document -->
20 cc65 is a C compiler for 6502 based systems. It implements a subset of the ISO
21 C standard plus additional functions specially crafted for 6502 systems or
22 just some of the supported machines. This function refrence describes the
23 available functions together with any limitations.
25 For an overview about the available libraries, their purpose, and any
26 differences to the ISO standard, please have a look at the <htmlurl
27 url="library.html" name="cc65 Library Overview">.
29 <bf/Note:/ Standard C functions are listed here, but not described in detail.
30 Since these functions behave identical on all standard compliant systems, they
31 are described in any book covering standard C.
33 Each entry for a function contains a detailed description
37 <tag/Function/Summary of what <bf/function/ does.
38 <tag/Header/The header file that contains the declaration.
39 <tag/Declaration/Describes the needed header files and declaration of the
41 <tag/Description/Description of the function.
43 <tag/Availability/The availability of the function.
44 <tag/See also/Other related functions.
45 <tag/Example/A piece of actual code using the function.
50 <sect>Functions by header file<p>
52 <sect1><tt/6502.h/<label id="6502.h"><p>
55 <item><ref id="BRK" name="BRK">
56 <item><ref id="CLI" name="CLI">
57 <item><ref id="SEI" name="SEI">
58 <item><ref id="_sys" name="_sys">
59 <item><ref id="getcpu" name="getcpu">
60 <item><ref id="reset_brk" name="reset_brk">
61 <item><ref id="set_brk" name="set_brk">
65 <sect1><tt/apple2.h/<label id="apple2.h"><p>
69 <item><ref id="get_ostype" name="get_ostype">
74 <sect1><tt/apple2enh.h/<label id="apple2enh.h"><p>
78 <item><ref id="get_ostype" name="get_ostype">
82 <item><ref id="videomode" name="videomode">
86 <sect1><tt/assert.h/<label id="assert.h"><p>
89 <item><ref id="assert" name="assert">
93 <sect1><tt/atari.h/<label id="atari.h"><p>
96 <item><ref id="get_ostype" name="get_ostype">
102 <sect1><tt/atmos.h/<label id="atmos.h"><p>
107 <sect1><tt/c128.h/<label id="c128.h"><p>
110 <item><ref id="c64mode" name="c64mode">
111 <item><ref id="fast" name="fast">
112 <item><ref id="slow" name="slow">
113 <item><ref id="toggle_videomode" name="toggle_videomode">
114 <item><ref id="videomode" name="videomode">
118 <sect1><tt/c16.h/<label id="c16.h"><p>
123 <sect1><tt/c64.h/<label id="c64.h"><p>
126 <item><ref id="get_ostype" name="get_ostype">
130 <sect1><tt/cbm510.h/<label id="cbm510.h"><p>
133 <item><ref id="peekbsys" name="peekbsys">
134 <item><ref id="peekwsys" name="peekwsys">
135 <item><ref id="pokebsys" name="pokebsys">
136 <item><ref id="pokewsys" name="pokewsys">
140 <sect1><tt/cbm610.h/<label id="cbm610.h"><p>
143 <item><ref id="peekbsys" name="peekbsys">
144 <item><ref id="peekwsys" name="peekwsys">
145 <item><ref id="pokebsys" name="pokebsys">
146 <item><ref id="pokewsys" name="pokewsys">
150 <sect1><tt/conio.h/<label id="conio.h"><p>
153 <item><ref id="bgcolor" name="bgcolor">
154 <item><ref id="bordercolor" name="bordercolor">
155 <item><ref id="cclear" name="cclear">
156 <item><ref id="cclearxy" name="cclearxy">
157 <item><ref id="cgetc" name="cgetc">
158 <item><ref id="chline" name="chline">
159 <item><ref id="chlinexy" name="chlinexy">
160 <item><ref id="clrscr" name="clrscr">
161 <item><ref id="cprintf" name="cprintf">
162 <item><ref id="cputc" name="cputc">
163 <item><ref id="cputcxy" name="cputcxy">
164 <item><ref id="cputs" name="cputs">
165 <item><ref id="cputsxy" name="cputsxy">
166 <item><ref id="cursor" name="cursor">
167 <item><ref id="cvline" name="cvline">
168 <item><ref id="cvlinexy" name="cvlinexy">
169 <item><ref id="gotox" name="gotox">
170 <item><ref id="gotoxy" name="gotoxy">
171 <item><ref id="gotoy" name="gotoy">
172 <item><ref id="kbhit" name="kbhit">
173 <item><ref id="revers" name="revers">
174 <item><ref id="screensize" name="screensize">
175 <item><ref id="textcolor" name="textcolor">
176 <item><ref id="vcprintf" name="vcprintf">
177 <item><ref id="wherex" name="wherex">
178 <item><ref id="wherey" name="wherey">
182 <sect1><tt/ctype.h/<label id="ctype.h"><p>
185 <item><ref id="isalnum" name="isalnum">
186 <item><ref id="isalpha" name="isalpha">
187 <item><ref id="isascii" name="isascii">
188 <item><ref id="isblank" name="isblank">
189 <item><ref id="iscntrl" name="iscntrl">
190 <item><ref id="isdigit" name="isdigit">
191 <item><ref id="isgraph" name="isgraph">
192 <item><ref id="islower" name="islower">
193 <item><ref id="isprint" name="isprint">
194 <item><ref id="ispunct" name="ispunct">
195 <item><ref id="isspace" name="isspace">
196 <item><ref id="isupper" name="isupper">
197 <item><ref id="isxdigit" name="isxdigit">
198 <item><ref id="tolower" name="tolower">
199 <item><ref id="toupper" name="toupper">
203 <sect1><tt/dbg.h/<label id="dbg.h"><p>
208 <sect1><tt/dio.h/<label id="dio.h"><p>
213 <sect1><tt/em.h/<label id="em.h"><p>
216 <item><ref id="em_commit" name="em_commit">
217 <item><ref id="em_copyfrom" name="em_copyfrom">
218 <item><ref id="em_copyto" name="em_copyto">
219 <item><ref id="em_install" name="em_install">
220 <item><ref id="em_load_driver" name="em_load_driver">
221 <item><ref id="em_map" name="em_map">
222 <item><ref id="em_pagecount" name="em_pagecount">
223 <item><ref id="em_uninstall" name="em_uninstall">
224 <item><ref id="em_unload" name="em_unload">
225 <item><ref id="em_use" name="em_use">
229 <sect1><tt/errno.h/<label id="errno.h"><p>
234 <sect1><tt/fcntl.h/<label id="fcntl.h"><p>
237 <item><ref id="close" name="close">
238 <item><ref id="creat" name="creat">
239 <item><ref id="open" name="open">
243 <sect1><tt/geos.h/<label id="geos.h"><p>
248 <sect1><tt/joystick.h/<label id="joystick.h"><p>
251 <item><ref id="joy_count" name="joy_count">
252 <item><ref id="joy_install" name="joy_install">
253 <item><ref id="joy_load_driver" name="joy_load_driver">
254 <item><ref id="joy_read" name="joy_read">
255 <item><ref id="joy_uninstall" name="joy_uninstall">
256 <item><ref id="joy_unload" name="joy_unload">
260 <sect1><tt/locale.h/<label id="locale.h"><p>
263 <item><ref id="localeconv" name="localeconv">
264 <item><ref id="setlocale" name="setlocale">
268 <sect1><tt/modload.h/<label id="modload.h"><p>
271 <item><ref id="mod_load" name="mod_load">
272 <item><ref id="mod_free" name="mod_free">
276 <sect1><tt/mouse.h/<label id="mouse.h"><p>
279 <item><ref id="mouse_load_driver" name="mouse_load_driver">
280 <item><ref id="mouse_unload" name="mouse_unload">
281 <item><ref id="mouse_install" name="mouse_install">
282 <item><ref id="mouse_uninstall" name="mouse_uninstall">
283 <item><ref id="mouse_hide" name="mouse_hide">
284 <item><ref id="mouse_show" name="mouse_show">
285 <item><ref id="mouse_setbox" name="mouse_setbox">
286 <item><ref id="mouse_getbox" name="mouse_getbox">
287 <item><ref id="mouse_move" name="mouse_move">
288 <item><ref id="mouse_buttons" name="mouse_buttons">
289 <item><ref id="mouse_pos" name="mouse_pos">
290 <item><ref id="mouse_info" name="mouse_info">
291 <item><ref id="mouse_ioctl" name="mouse_ioctl">
297 <sect1><tt/nes.h/<label id="nes.h"><p>
302 <sect1><tt/o65.h/<label id="o65.h"><p>
304 The <tt/o65.h/ header file contains structure and constant definitions that
305 may be used when dealing with files in <htmlurl
306 url="http://www.6502.org/users/andre/o65/fileformat.html" name="o65 format">.
307 It does not declare any functions.
310 <sect1><tt/peekpoke.h/<label id="peekpoke.h"><p>
313 <item><ref id="PEEK" name="PEEK">
314 <item><ref id="PEEKW" name="PEEKW">
315 <item><ref id="POKE" name="POKE">
316 <item><ref id="POKEW" name="POKEW">
320 <sect1><tt/pet.h/<label id="pet.h"><p>
325 <sect1><tt/plus4.h/<label id="plus4.h"><p>
330 <sect1><tt/serial.h/<label id="serial.h"><p>
334 <item><ref id="ser_load_driver" name="ser_load_driver">
335 <item><ref id="ser_unload" name="ser_unload">
336 <item><ref id="ser_install" name="ser_install">
337 <item><ref id="ser_uninstall" name="ser_uninstall">
338 <item><ref id="ser_open" name="ser_open">
339 <item><ref id="ser_close" name="ser_close">
340 <item><ref id="ser_get" name="ser_get">
341 <item><ref id="ser_put" name="ser_put">
342 <item><ref id="ser_status" name="ser_status">
343 <item><ref id="ser_ioctl" name="ser_ioctl">
350 <sect1><tt/setjmp.h/<label id="setjmp.h"><p>
353 <item><ref id="setjmp" name="setjmp">
354 <item><ref id="longjmp" name="longjmp">
358 <sect1><tt/signal.h/<label id="signal.h"><p>
361 <item><ref id="raise" name="raise">
362 <item><ref id="signal" name="signal">
366 <sect1><tt/stdarg.h/<label id="stdarg.h"><p>
371 <sect1><tt/stdbool.h/<label id="stdbool.h"><p>
376 <sect1><tt/stddef.h/<label id="stddef.h"><p>
379 <item><ref id="offsetof" name="offsetof">
383 <sect1><tt/stdio.h/<label id="stdio.h"><p>
386 <item><ref id="_poserror" name="_poserror">
387 <item><ref id="clearerr" name="clearerr">
388 <!-- <item><ref id="fclose" name="fclose"> -->
389 <!-- <item><ref id="fdopen" name="fdopen"> -->
390 <item><ref id="feof" name="feof">
391 <item><ref id="ferror" name="ferror">
392 <!-- <item><ref id="fflush" name="fflush"> -->
393 <!-- <item><ref id="fgetc" name="fgetc"> -->
394 <!-- <item><ref id="fgetpos" name="fgetpos"> -->
395 <!-- <item><ref id="fgets" name="fgets"> -->
396 <item><ref id="fileno" name="fileno">
397 <!-- <item><ref id="fopen" name="fopen"> -->
398 <!-- <item><ref id="fprintf" name="fprintf"> -->
399 <!-- <item><ref id="fputc" name="fputc"> -->
400 <!-- <item><ref id="fputs" name="fputs"> -->
401 <!-- <item><ref id="fread" name="fread"> -->
402 <!-- <item><ref id="freopen" name="freopen"> -->
403 <!-- <item><ref id="fscanf" name="fscanf"> -->
404 <!-- <item><ref id="fseek" name="fseek"> -->
405 <!-- <item><ref id="fsetpos" name="fsetpos"> -->
406 <!-- <item><ref id="ftell" name="ftell"> -->
407 <!-- <item><ref id="fwrite" name="fwrite"> -->
408 <!-- <item><ref id="getc" name="getc"> -->
409 <!-- <item><ref id="getchar" name="getchar"> -->
410 <!-- <item><ref id="gets" name="gets"> -->
411 <!-- <item><ref id="printf" name="printf"> -->
412 <!-- <item><ref id="putc" name="putc"> -->
413 <!-- <item><ref id="putchar" name="putchar"> -->
414 <!-- <item><ref id="puts" name="puts"> -->
415 <item><ref id="rename" name="rename">
416 <item><ref id="remove" name="remove">
417 <!-- <item><ref id="rewind" name="rewind"> -->
418 <!-- <item><ref id="scanf" name="scanf"> -->
419 <!-- <item><ref id="snprintf" name="snprintf"> -->
420 <!-- <item><ref id="sprintf" name="sprintf"> -->
421 <!-- <item><ref id="sscanf" name="sscanf"> -->
422 <!-- <item><ref id="vfprintf" name="vfprintf"> -->
423 <!-- <item><ref id="vfscanf" name="vfscanf"> -->
424 <!-- <item><ref id="vprintf" name="vprintf"> -->
425 <!-- <item><ref id="vscanf" name="vscanf"> -->
426 <!-- <item><ref id="vsnprintf" name="vsnprintf"> -->
427 <!-- <item><ref id="vsprintf" name="vsprintf"> -->
428 <!-- <item><ref id="vsscanf" name="vsscanf"> -->
434 <sect1><tt/stdlib.h/<label id="stdlib.h"><p>
437 <item><ref id="_heapadd" name="_heapadd">
438 <item><ref id="_heapblocksize" name="_heapblocksize">
439 <item><ref id="_heapmaxavail" name="_heapmaxavail">
440 <item><ref id="_heapmemavail" name="_heapmemavail">
441 <item><ref id="_randomize" name="_randomize">
442 <item><ref id="_swap" name="_swap">
443 <item><ref id="abort" name="abort">
444 <item><ref id="abs" name="abs">
445 <item><ref id="atexit" name="atexit">
446 <item><ref id="atoi" name="atoi">
447 <item><ref id="atol" name="atol">
448 <item><ref id="bsearch" name="bsearch">
449 <item><ref id="calloc" name="calloc">
450 <item><ref id="div" name="div">
451 <item><ref id="exit" name="exit">
452 <item><ref id="free" name="free">
453 <item><ref id="getenv" name="getenv">
454 <item><ref id="itoa" name="itoa">
455 <item><ref id="labs" name="labs">
456 <item><ref id="ltoa" name="ltoa">
457 <item><ref id="malloc" name="malloc">
458 <item><ref id="perror" name="perror">
459 <item><ref id="qsort" name="qsort">
460 <item><ref id="rand" name="rand">
461 <item><ref id="realloc" name="realloc">
462 <item><ref id="srand" name="srand">
463 <item><ref id="ultoa" name="ultoa">
464 <item><ref id="utoa" name="utoa">
468 <sect1><tt/string.h/<label id="string.h"><p>
471 <item><ref id="_stroserror" name="_stroserror">
472 <item><ref id="bzero" name="bzero">
473 <item><ref id="memchr" name="memchr">
474 <item><ref id="memcpy" name="memcpy">
475 <item><ref id="memmove" name="memmove">
476 <item><ref id="memset" name="memset">
477 <item><ref id="strcasecmp" name="strcasecmp">
478 <item><ref id="strcat" name="strcat">
479 <item><ref id="strchr" name="strchr">
480 <item><ref id="strcmp" name="strcmp">
481 <item><ref id="strcoll" name="strcoll">
482 <item><ref id="strcpy" name="strcpy">
483 <item><ref id="strcspn" name="strcspn">
484 <item><ref id="strdup" name="strdup">
485 <item><ref id="strerror" name="strerror">
486 <item><ref id="stricmp" name="stricmp">
487 <item><ref id="strlen" name="strlen">
488 <item><ref id="strlower" name="strlower">
489 <item><ref id="strlwr" name="strlwr">
490 <item><ref id="strncat" name="strncat">
491 <item><ref id="strncmp" name="strncmp">
492 <item><ref id="strncpy" name="strncpy">
493 <item><ref id="strrchr" name="strrchr">
494 <item><ref id="strspn" name="strspn">
495 <item><ref id="strstr" name="strstr">
496 <item><ref id="strtok" name="strtok">
497 <item><ref id="strxfrm" name="strxfrm">
498 <item><ref id="strupper" name="strupper">
499 <item><ref id="strupr" name="strupr">
505 <sect1><tt/tgi.h/<label id="tgi.h"><p>
508 <item><ref id="tgi_arc" name="tgi_arc">
509 <item><ref id="tgi_bar" name="tgi_bar">
510 <item><ref id="tgi_circle" name="tgi_circle">
511 <item><ref id="tgi_clear" name="tgi_clear">
512 <item><ref id="tgi_getcolor" name="tgi_getcolor">
513 <item><ref id="tgi_getcolorcount" name="tgi_getcolorcount">
514 <item><ref id="tgi_getdefpalette" name="tgi_getdefpalette">
515 <item><ref id="tgi_done" name="tgi_done">
516 <item><ref id="tgi_ellipse" name="tgi_ellipse">
517 <item><ref id="tgi_geterror" name="tgi_geterror">
518 <item><ref id="tgi_geterrormsg" name="tgi_geterrormsg">
519 <item><ref id="tgi_getmaxcolor" name="tgi_getmaxcolor">
520 <item><ref id="tgi_getmaxx" name="tgi_getmaxx">
521 <item><ref id="tgi_getmaxy" name="tgi_getmaxy">
522 <item><ref id="tgi_getpagecount" name="tgi_getpagecount">
523 <item><ref id="tgi_getpalette" name="tgi_getpalette">
524 <item><ref id="tgi_getpixel" name="tgi_getpixel">
525 <item><ref id="tgi_getxres" name="tgi_getxres">
526 <item><ref id="tgi_getyres" name="tgi_getyres">
527 <item><ref id="tgi_gotoxy" name="tgi_gotoxy">
528 <item><ref id="tgi_init" name="tgi_init">
529 <item><ref id="tgi_install" name="tgi_install">
530 <item><ref id="tgi_ioctl" name="tgi_ioctl">
531 <item><ref id="tgi_line" name="tgi_line">
532 <item><ref id="tgi_lineto" name="tgi_lineto">
533 <item><ref id="tgi_load" name="tgi_load">
534 <item><ref id="tgi_load_driver" name="tgi_load_driver">
535 <item><ref id="tgi_outtext" name="tgi_outtext">
536 <item><ref id="tgi_outtextxy" name="tgi_outtextxy">
537 <item><ref id="tgi_setcolor" name="tgi_setcolor">
538 <item><ref id="tgi_setdrawpage" name="tgi_setdrawpage">
539 <item><ref id="tgi_setpalette" name="tgi_setpalette">
540 <item><ref id="tgi_setpixel" name="tgi_setpixel">
541 <item><ref id="tgi_setviewpage" name="tgi_setviewpage">
542 <item><ref id="tgi_textheight" name="tgi_textheight">
543 <item><ref id="tgi_textstyle" name="tgi_textstyle">
544 <item><ref id="tgi_textwidth" name="tgi_textwidth">
545 <item><ref id="tgi_uninstall" name="tgi_uninstall">
546 <item><ref id="tgi_unload" name="tgi_unload">
549 <sect1><tt/time.h/<label id="time.h"><p>
552 <!-- <item><ref id="_systime" name="_systime"> -->
553 <!-- <item><ref id="asctime" name="asctime"> -->
554 <!-- <item><ref id="clock" name="clock"> -->
555 <!-- <item><ref id="ctime" name="ctime"> -->
556 <!-- <item><ref id="gmtime" name="gmtime"> -->
557 <!-- <item><ref id="localtime" name="localtime"> -->
558 <!-- <item><ref id="mktime" name="mktime"> -->
559 <!-- <item><ref id="strftime" name="strftime"> -->
560 <item><ref id="time" name="time">
566 <sect1><tt/unistd.h/<label id="unistd.h"><p>
569 <!-- <item><ref id="chdir" name="chdir"> -->
570 <!-- <item><ref id="getcwd" name="getcwd"> -->
571 <item><ref id="getopt" name="getopt">
572 <!-- <item><ref id="lseek" name="lseek"> -->
573 <!-- <item><ref id="mkdir" name="mkdir"> -->
574 <!-- <item><ref id="read" name="read"> -->
575 <!-- <item><ref id="rmdir" name="rmdir"> -->
576 <item><ref id="sleep" name="sleep">
577 <item><ref id="unlink" name="unlink">
578 <!-- <item><ref id="write" name="write"> -->
584 <sect1><tt/vic20.h/<label id="vic20.h"><p>
589 <sect1><tt/zlib.h/<label id="zlib.h"><p>
594 <sect>Alphabetical function reference<p>
596 <sect1>_heapadd<label id="_heapadd"><p>
600 <tag/Function/Add a block to the heap.
601 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
602 <tag/Declaration/<tt/void __fastcall__ _heapadd (void* mem, size_t size);/
603 <tag/Description/The function adds a block of raw memory to the heap.
606 <item>The minimum blocksize that can be added is 6 bytes; the function will
607 ignore smaller blocks.
609 <tag/Availability/cc65
611 <ref id="_heapblocksize" name="_heapblocksize">,
612 <ref id="_heapmaxavail" name="_heapmaxavail">,
613 <ref id="_heapmemavail" name="_heapmemavail">,
614 <ref id="calloc" name="calloc">,
615 <ref id="free" name="free">,
616 <ref id="malloc" name="malloc">,
617 <ref id="realloc" name="realloc">
623 <sect1>_heapblocksize<label id="_heapblocksize"><p>
627 <tag/Function/Return the size of an allocated block.
628 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
629 <tag/Declaration/<tt/size_t __fastcall__ _heapblocksize (const void* block);/
630 <tag/Description/The function returns the size of a block that must have
631 previously been allocated by <tt/<ref id="malloc" name="malloc">/, <tt/<ref
632 id="calloc" name="calloc">/ or <tt/<ref id="realloc" name="realloc">/.
635 <item>Passing a pointer to a block that was is not the result of one of the
636 allocation functions, or that has been free'd will give unpredicable results.
638 <tag/Availability/cc65
640 <ref id="_heapadd" name="_heapadd">,
641 <ref id="_heapmaxavail" name="_heapmaxavail">,
642 <ref id="_heapmemavail" name="_heapmemavail">,
643 <ref id="calloc" name="calloc">,
644 <ref id="free" name="free">,
645 <ref id="malloc" name="malloc">,
646 <ref id="realloc" name="realloc">
652 <sect1>_heapmaxavail<label id="_heapmaxavail"><p>
656 <tag/Function/Return the largest block that is available on the heap.
657 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
658 <tag/Declaration/<tt/size_t __fastcall__ _heapmaxavail (void);/
659 <tag/Description/The function returns the size of the largest block that may
660 be allocated from the heap using <tt/<ref id="malloc" name="malloc">/.
661 <tag/Availability/cc65
663 <ref id="_heapadd" name="_heapadd">,
664 <ref id="_heapblocksize" name="_heapblocksize">,
665 <ref id="_heapmemavail" name="_heapmemavail">,
666 <ref id="calloc" name="calloc">,
667 <ref id="free" name="free">,
668 <ref id="malloc" name="malloc">,
669 <ref id="realloc" name="realloc">
675 <sect1>_heapmemavail<label id="_heapmemavail"><p>
679 <tag/Function/Return the total available space on the heap.
680 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
681 <tag/Declaration/<tt/size_t __fastcall__ _heapmemavail (void);/
682 <tag/Description/The function returns the total number of bytes available on
686 <item>This function is of less use than usually assumed, since the returned
687 heap space may be available but not in one block. So even if this function
688 says that several times more heap space is available than needed, <ref
689 id="malloc" name="malloc"> may still return <tt/NULL/.
691 <tag/Availability/cc65
693 <ref id="_heapadd" name="_heapadd">,
694 <ref id="_heapblocksize" name="_heapblocksize">,
695 <ref id="_heapmaxavail" name="_heapmaxavail">,
696 <ref id="calloc" name="calloc">,
697 <ref id="free" name="free">,
698 <ref id="malloc" name="malloc">,
699 <ref id="realloc" name="realloc">
705 <sect1>_poserror<label id="_poserror"><p>
709 <tag/Function/Print an error message for the error in <tt/_oserror/.
710 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
711 <tag/Declaration/<tt/void __fastcall__ _poserror (const char* msg);/
712 <tag/Description/<tt/_poserror/ prints an error message to <tt/stderr/. If
713 <tt/msg/ is not <tt/NULL/ and not an empty string, it is printed followed by
714 a colon and a blank. Then the error message for the current contents of
715 <tt/_oserror/ are printed followed by a newline. The message output is the
716 same as returned by <tt/<ref id="_stroserror" name="_stroserror">/ with an
717 argument of <tt/_oserror/.
720 <item>Since operating system specific error code are - you guessed it -
721 operating system specific, the value in <tt/_oserror/ and the message that is
722 printed depends on the cc65 target.
723 <item>The function is only available as fastcall function, so it may only
724 be used in presence of a prototype.
726 <tag/Availability/cc65
728 <ref id="_stroserror" name="_stroserror">,
729 <ref id="perror" name="perror">
735 <sect1>_randomize<label id="_randomize"><p>
739 <tag/Function/Initialize the pseudo random number generator.
740 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
741 <tag/Declaration/<tt/void _randomize (void);/
742 <tag/Description/The function initializes the random number generator with
743 a seed derived from fast changing hardware events, so the seed itself can be
744 considered random to a certain degree.
745 <tag/Limits/<itemize>
746 <item>The randomness of the seed depends on the machine hardware.
748 <tag/Availability/cc65
750 <ref id="rand" name="rand">,
751 <ref id="srand" name="srand">
757 <sect1>_stroserror<label id="_stroserror"><p>
761 <tag/Function/Return a string describing an OS specific error code.
762 <tag/Header/<tt/<ref id="string.h" name="string.h">/
763 <tag/Declaration/<tt/const char* __fastcall__ _stroserror (unsigned char errcode);/
764 <tag/Description/<tt/_stroserror/ will return a string describing the given
765 operating system specific error code.
766 <tag/Limits/<itemize>
767 <item>Since operating system specific error code are - you guessed it -
768 operating system specific, the parameter and the string returned depend on the
770 <item>The function is only available as fastcall function, so it may only be
771 used in presence of a prototype.
773 <tag/Availability/cc65
775 <ref id="strerror" name="strerror">
781 <sect1>_swap<label id="_swap"><p>
785 <tag/Function/Swap the contents of memory areas.
786 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
787 <tag/Declaration/<tt/void __fastcall__ _swap (void* p, void* q, size_t size);/
788 <tag/Description/<tt/_swap/ will swap (exchange) the contents of the two memory
789 areas pointed to by <tt/p/ and <tt/q/. Both memory areas are assumed to be
790 <tt/size/ bytes in size.
791 <tag/Limits/<itemize>
792 <item>The memory areas may not overlap, otherwise the results are undefined.
793 <item>The function is only available as fastcall function, so it may only be
794 used in presence of a prototype.
796 <tag/Availability/cc65
798 <ref id="memcpy" name="memcpy">,
799 <ref id="memmove" name="memmove">
805 <sect1>_sys<label id="_sys"><p>
809 <tag/Function/Call a subroutine passing register values.
810 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
811 <tag/Declaration/<tt/void __fastcall__ _sys (struct regs* r);/
812 <tag/Description/The function will call the subroutine at the address
813 specified in the <tt/pc/ member of the passed <tt/regs/ structure. All
814 registers and the CPU flags are set to the values given in the <tt/regs/
815 structure. On return from the subroutine, the new values of the registers and
816 flags are stored back overwriting the old values.
817 <tag/Limits/<itemize>
818 <item>Bits 4 and 5 of the flags value in the <tt/regs/ structure are ignored
819 when calling the subroutine (they are unchanged from their current values).
820 <item>The function is only available as fastcall function, so it may only be
821 used in presence of a prototype.
823 <tag/Availability/cc65
829 <sect1>BRK<label id="BRK"><p>
833 <tag/Function/Insert a 6502 BRK instrunction into the code.
834 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
835 <tag/Declaration/<tt/void BRK (void);/
836 <tag/Description/The function will insert a 6502 BRK instruction into the code
837 which may be used to trigger a debugger.
838 <tag/Limits/<itemize>
839 <item>The function is actually a macro.
840 <item>The inserted instruction may lead to unexpected results if no debugger
843 <tag/Availability/cc65
845 <ref id="CLI" name="CLI">,
846 <ref id="SEI" name="SEI">
852 <sect1>CLI<label id="CLI"><p>
856 <tag/Function/Insert a 6502 CLI instrunction into the code.
857 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
858 <tag/Declaration/<tt/void CLI (void);/
859 <tag/Description/The function will insert a 6502 CLI instruction into the code,
860 so interrupts are enabled. Enabling interrupts has no effects if they are
861 already enabled (the default).
862 <tag/Limits/<itemize>
863 <item>The function is actually a macro.
864 <item>Disabling interrupts may lead to unexpected results.
866 <tag/Availability/cc65
868 <ref id="BRK" name="BRK">,
869 <ref id="SEI" name="SEI">
875 <sect1>PEEK<label id="PEEK"><p>
879 <tag/Function/Read a byte from memory.
880 <tag/Header/<tt/<ref id="peekpoke.h" name="peekpoke.h">/
881 <tag/Declaration/<tt/unsigned char PEEK (unsigned addr);/
882 <tag/Description/The function will read the absolute memory given by <tt/addr/
883 and return the value read.
884 <tag/Limits/<itemize>
885 <item>The function is actually a macro.
886 <item>This function depends highly on the platform and environment.
888 <tag/Availability/cc65
890 <ref id="PEEKW" name="PEEKW">,
891 <ref id="POKE" name="POKE">
897 <sect1>PEEKW<label id="PEEKW"><p>
901 <tag/Function/Read a word (two bytes) from memory.
902 <tag/Header/<tt/<ref id="peekpoke.h" name="peekpoke.h">/
903 <tag/Declaration/<tt/unsigned PEEKW (unsigned addr);/
904 <tag/Description/The function will read the absolute memory given by <tt/addr/
905 and return the value read. The byte read from the higher address is the high
906 byte of the return value.
907 <tag/Limits/<itemize>
908 <item>The function is actually a macro.
909 <item>This function depends highly on the platform and environment.
910 <item>The order in which the two bytes are read is unspecified and may
911 depend of the address expression used.
913 <tag/Availability/cc65
915 <ref id="PEEK" name="PEEK">,
916 <ref id="POKE" name="POKE">
922 <sect1>POKE<label id="POKE"><p>
926 <tag/Function/Write a byte to memory.
927 <tag/Header/<tt/<ref id="peekpoke.h" name="peekpoke.h">/
928 <tag/Declaration/<tt/void POKE (unsigned addr, unsigned char val);/
929 <tag/Description/The function writes the value <tt/val/ to the absolute
930 memory address given by <tt/addr/.
931 <tag/Limits/<itemize>
932 <item>The function is actually a macro.
933 <item>This function depends highly on the platform and environment.
934 <item>Careless use will cause the program to act strange or may crash the
937 <tag/Availability/cc65
939 <ref id="PEEK" name="PEEK">,
940 <ref id="POKEW" name="POKEW">
946 <sect1>POKEW<label id="POKEW"><p>
950 <tag/Function/Write a word (two bytes) to memory.
951 <tag/Header/<tt/<ref id="peekpoke.h" name="peekpoke.h">/
952 <tag/Declaration/<tt/void POKEW (unsigned addr, unsigned val);/
953 <tag/Description/The function writes the value <tt/val/ to the absolute
954 memory address given by <tt/addr/. The low byte of <tt/val/ is written to
955 the <tt/addr/, the high byte is written to <tt/addr+1/.
956 <tag/Limits/<itemize>
957 <item>The function is actually a macro.
958 <item>This function depends highly on the platform and environment.
959 <item>Careless use will cause the program to act strange or may crash the
961 <item>The order in which the two bytes are written is unspecified and may
962 depend of the address expression used.
964 <tag/Availability/cc65
966 <ref id="PEEK" name="PEEK">,
967 <ref id="POKE" name="POKE">
973 <sect1>SEI<label id="SEI"><p>
977 <tag/Function/Insert a 6502 SEI instrunction into the code.
978 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
979 <tag/Declaration/<tt/void SEI (void);/
980 <tag/Description/The function will insert a 6502 SEI instruction into the code,
981 so interrupts are disabled. Note that non maskable interrupts cannot be
983 <tag/Limits/<itemize>
984 <item>The function is actually a macro.
985 <item>Disabling interrupts may lead to unexpected results.
987 <tag/Availability/cc65
989 <ref id="BRK" name="BRK">,
990 <ref id="CLI" name="CLI">
996 <sect1>abort<label id="abort"><p>
1000 <tag/Function/Terminates a program abnormally.
1001 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1002 <tag/Declaration/<tt/void abort (void);/
1003 <tag/Description/<tt/abort/ raises <tt/SIGABRT/, writes a termination message
1004 on stderr, then terminates the program with an exit code of 3.
1005 <tag/Availability/ISO 9899
1007 <ref id="assert" name="assert">,
1008 <ref id="exit" name="exit">,
1009 <ref id="raise" name="raise">
1015 <sect1>abs<label id="abs"><p>
1019 <tag/Function/Returns the absolute value of an integer.
1020 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1021 <tag/Declaration/<tt/int __fastcall__ abs (int v);/
1022 <tag/Description/<tt/abs/ returns the absolute value of the argument passed to
1024 <tag/Limits/<itemize>
1025 <item>The return value is undefined if <tt/INT_MIN/ is passed to the function.
1026 <item>The function is only available as fastcall function, so it may only be
1027 used in presence of a prototype.
1029 <tag/Availability/ISO 9899
1031 <ref id="labs" name="labs">
1037 <sect1>assert<label id="assert"><p>
1041 <tag/Function/Test a condition and possibly abort.
1042 <tag/Header/<tt/<ref id="assert.h" name="assert.h">/
1043 <tag/Declaration/<tt/void assert (int cond);/
1044 <tag/Description/<tt/assert/ is a macro that expands to a <tt/id/
1045 statement. If the condition evaluates t zero (false), assert prints a message
1046 on stderr and aborts the program.
1047 <tag/Limits/<itemize>
1048 <item>The function is actually a macro.
1050 <tag/Availability/ISO 9899
1052 <ref id="abort" name="abort">,
1053 <ref id="exit" name="exit">
1059 <sect1>atexit<label id="atexit"><p>
1063 <tag/Function/Register an exit function.
1064 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1065 <tag/Declaration/<tt/int __fastcall__ atexit (void (*exitfunc) (void));/
1066 <tag/Description/<tt/atexit/ registers the function pointed to by
1067 <tt/exitfunc/ as an exit function. Exit functions are called when the program
1068 terminates, they are called in LIFO order (the last function registered is
1069 called first). <tt/atexit/ returns zero on success and a nonzero value on
1071 <tag/Limits/<itemize>
1072 <item>A maximum of 5 exit functions can be registered.
1073 <item>There is no way to unregister an exit function.
1074 <item>The function is only available as fastcall function, so it may only be
1075 used in presence of a prototype.
1077 <tag/Availability/ISO 9899
1079 <ref id="abort" name="abort">,
1080 <ref id="exit" name="exit">
1086 <sect1>atoi<label id="atoi"><p>
1090 <tag/Function/Convert a string to an integer.
1091 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1092 <tag/Declaration/<tt/int __fastcall__ atoi (const char* s);/
1093 <tag/Description/<tt/atoi/ converts the given string into an integer.
1094 Conversion stops as soon as any invalid character is encountered.
1095 <tag/Limits/<itemize>
1096 <item>There is no way to detect any conversion errors.
1097 <item>The function does not check for an numerical overflow when converting.
1098 <item>The function is only available as fastcall function, so it may only be
1099 used in presence of a prototype.
1101 <tag/Availability/ISO 9899
1103 <ref id="atol" name="atol">,
1104 <ref id="itoa" name="itoa">,
1105 <ref id="ltoa" name="ltoa">,
1106 <ref id="ultoa" name="ultoa">,
1107 <ref id="utoa" name="utoa">
1113 <sect1>atol<label id="atol"><p>
1117 <tag/Function/Convert a string to a long integer.
1118 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1119 <tag/Declaration/<tt/long __fastcall__ atol (const char* s);/
1120 <tag/Description/<tt/atol/ converts the given string into a long integer.
1121 Conversion stops as soon as any invalid character is encountered.
1122 <tag/Limits/<itemize>
1123 <item>There is no way to detect any conversion errors.
1124 <item>The function does not check for an numerical overflow when converting.
1125 <item>The function is only available as fastcall function, so it may only be
1126 used in presence of a prototype.
1128 <tag/Availability/ISO 9899
1130 <ref id="atoi" name="atoi">,
1131 <ref id="itoa" name="itoa">,
1132 <ref id="ltoa" name="ltoa">,
1133 <ref id="ultoa" name="ultoa">,
1134 <ref id="utoa" name="utoa">
1140 <sect1>bgcolor<label id="bgcolor"><p>
1144 <tag/Function/Set the background text color.
1145 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1146 <tag/Declaration/<tt/unsigned char __fastcall__ bgcolor (unsigned char color);/
1147 <tag/Description/The function will set a new background color and return the
1148 old (current) one. The background color is valid for the whole text output
1149 area of the screen, not just for new text.
1150 <tag/Limits/<itemize>
1151 <item>Background colors are system dependent. The function may have no effect
1152 on systems where the background color cannot be changed.
1153 <item>The function is only available as fastcall function, so it may only be
1154 used in presence of a prototype.
1156 <tag/Availability/cc65
1158 <ref id="bordercolor" name="bordercolor">,
1159 <ref id="textcolor" name="textcolor">
1165 <sect1>bordercolor<label id="bordercolor"><p>
1169 <tag/Function/Set the border (frame) color.
1170 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1171 <tag/Declaration/<tt/unsigned char __fastcall__ bordercolor (unsigned char color);/
1172 <tag/Description/The function will set a new border color. It returns the old
1173 (current) border color.
1174 <tag/Limits/<itemize>
1175 <item>Border colors are system dependent. The function may have no effect
1176 on systems where the border color cannot be changed.
1177 <item>The function is only available as fastcall function, so it may only
1178 be used in presence of a prototype.
1180 <tag/Availability/cc65
1182 <ref id="bgcolor" name="bgcolor">,
1183 <ref id="textcolor" name="textcolor">
1189 <sect1>bsearch<label id="bsearch"><p>
1193 <tag/Function/Do a binary search in a sorted array.
1194 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1195 <tag/Declaration/<tt/void* __fastcall__ bsearch (const void* key,
1196 const void* base, size_t n, size_t size,
1197 int (*cmp) (const void*, const void*));/
1198 <tag/Description/<tt/bsearch/ searches a sorted array for a member that
1199 matches the one pointed to by <tt/key/. <tt/base/ is the address of the array,
1200 <tt/n/ is the number of elements, <tt/size/ the size of an element and <tt/cmp/
1201 the function used to compare the members against the key. The function returns
1202 a pointer to the member found, or <tt/NULL/ if there was no match.
1205 <item>The contents of the array must be sorted in ascending order according to
1206 the compare function given.
1207 <item>If there are multiple members that match the key, the function will
1208 return one of the members.
1209 <item>The function is only available as fastcall function, so it may only
1210 be used in presence of a prototype.
1212 <tag/Availability/ISO 9899
1214 <ref id="qsort" name="qsort">
1220 <sect1>bzero<label id="bzero"><p>
1224 <tag/Function/Fill a memory area with zeroes.
1225 <tag/Header/<tt/<ref id="string.h" name="string.h">/
1226 <tag/Declaration/<tt/void __fastcall__ bzero (void* p, size_t count);/
1227 <tag/Description/<tt/bzero/ fills the memory area pointed to by <tt/p/ with
1231 <item>The function is non standard and therefore only available in non ANSI
1232 mode. You should use <tt/<ref id="memset" name="memset">/ instead.
1233 <item>The function is only available as fastcall function, so it may only
1234 be used in presence of a prototype.
1236 <tag/Availability/cc65
1238 <ref id="_swap" name="_swap">,
1239 <ref id="memcpy" name="memcpy">,
1240 <ref id="memmove" name="memmove">,
1241 <ref id="memset" name="memset">,
1247 <sect1>c64mode<label id="c64mode"><p>
1251 <tag/Function/Switch the C128 into C64 compatible mode.
1252 <tag/Header/<tt/<ref id="c128.h" name="c128.h">/
1253 <tag/Declaration/<tt/void c64mode (void);/
1254 <tag/Description/The function will cause the machine to reboot into C64 mode.
1255 <tag/Limits/<itemize>
1256 <item>The function is specific to the C128.
1257 <item>The function will not return to the caller.
1259 <tag/Availability/C128
1265 <sect1>calloc<label id="calloc"><p>
1269 <tag/Function/Allocate and clear memory.
1270 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1271 <tag/Declaration/<tt/void* __fastcall__ calloc (size_t n, size_t size);/
1272 <tag/Description/<tt/calloc/ allocates memory for an array of <tt/n/ elements
1273 of size <tt/size/, clears the whole block with binary zeroes and returns a
1274 pointer to it. On error (not enough memory available), <tt/calloc/ returns
1278 <item>Clearing the memory may not have the expected effect on all platforms:
1279 pointers in the block may not be <tt/NULL/ and floating point variables may
1280 not be zero (0.0). In other words: The "clearing" effect of this function
1281 should be used with care for portable programs.
1282 <item>The function is only available as fastcall function, so it may only
1283 be used in presence of a prototype.
1285 <tag/Availability/ISO 9899
1287 <ref id="_heapadd" name="_heapadd">,
1288 <ref id="_heapblocksize" name="_heapblocksize">,
1289 <ref id="_heapmaxavail" name="_heapmaxavail">,
1290 <ref id="_heapmemavail" name="_heapmemavail">,
1291 <ref id="free" name="free">,
1292 <ref id="malloc" name="malloc">,
1293 <ref id="realloc" name="realloc">
1299 <sect1>cclear<label id="cclear"><p>
1303 <tag/Function/Clear part of a line (write a given number of spaces).
1304 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1305 <tag/Declaration/<tt/void __fastcall__ cclear (unsigned char length);/
1306 <tag/Description/The function clears part of a line by writing <tt/length/
1307 spaces in the current text color.
1308 <tag/Limits/<itemize>
1309 <item>The function is only available as fastcall function, so it may
1310 only be used in presence of a prototype.
1312 <tag/Availability/cc65
1314 <ref id="cclearxy" name="cclearxy">,
1315 <ref id="clrscr" name="clrscr">
1321 <sect1>cclearxy<label id="cclearxy"><p>
1325 <tag/Function/Clear part of a line (write a given number of spaces) starting
1326 at a specific screen position.
1327 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1328 <tag/Declaration/<tt/void __fastcall__ cclearxy (unsigned char x, unsigned char y, unsigned char length);/
1329 <tag/Description/The function moves the cursor to a specific position, and
1330 will then clear part of the line by writing <tt/length/ spaces in the current
1332 <tag/Limits/<itemize>
1333 <item>The function is only available as fastcall function, so it may
1334 only be used in presence of a prototype.
1336 <tag/Availability/cc65
1338 <ref id="cclear" name="cclear">,
1339 <ref id="clrscr" name="clrscr">
1345 <sect1>cgetc<label id="cgetc"><p>
1349 <tag/Function/Read a character from the keyboard.
1350 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1351 <tag/Declaration/<tt/char cgetc (void);/
1352 <tag/Description/The function reads a character from the keyboard. If there is
1353 no character available, <tt/cgetc/ waits until the user presses a key. If the
1354 cursor is enabled by use of the <tt/cursor/ function, a blinking cursor is
1355 displayed while waiting.
1356 <tag/Limits/<itemize>
1357 <item>If the system supports a keyboard buffer, <tt/cgetc/ will fetch a key
1358 from this buffer and wait only if the buffer is empty.
1360 <tag/Availability/cc65
1362 <ref id="cursor" name="cursor">,
1363 <ref id="kbhit" name="kbhit">
1369 <sect1>chline<label id="chline"><p>
1373 <tag/Function/Output a horizontal line in text mode.
1374 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1375 <tag/Declaration/<tt/void __fastcall__ chline (unsigned char length);/
1376 <tag/Description/The function outputs a horizontal line with the given length
1377 starting at the current cursor position.
1378 <tag/Limits/<itemize>
1379 <item>The character used to draw the horizontal line is system dependent.
1380 If available, a line drawing character is used. Drawing a line that is partially
1381 off screen leads to undefined behaviour.
1382 <item>The function is only available as fastcall function, so it may only be
1383 used in presence of a prototype.
1385 <tag/Availability/cc65
1387 <ref id="chlinexy" name="chlinexy">,
1388 <ref id="cvline" name="cvline">,
1389 <ref id="cvlinexy" name="cvlinexy">
1395 <sect1>chlinexy<label id="chlinexy"><p>
1399 <tag/Function/Output a horizontal line at a given position in text mode.
1400 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1401 <tag/Declaration/<tt/void __fastcall__ chlinexy (unsigned char x, unsigned char y, unsigned char length);/
1402 <tag/Description/The function outputs a horizontal line with the given length
1403 starting at a given position.
1404 <tag/Limits/<itemize>
1405 <item>The character used to draw the horizontal line is system dependent.
1406 If available, a line drawing character is used. Drawing a line that is partially
1407 off screen leads to undefined behaviour.
1408 <item>The function is only available as fastcall function, so it may only be
1409 used in presence of a prototype.
1411 <tag/Availability/cc65
1413 <ref id="chline" name="chline">,
1414 <ref id="cvline" name="cvline">,
1415 <ref id="cvlinexy" name="cvlinexy">
1421 <sect1>clearerr<label id="clearerr"><p>
1425 <tag/Function/Clear error and end-of-file status of a stream.
1426 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
1427 <tag/Declaration/<tt/void __fastcall__ clearerr (FILE* f);/
1428 <tag/Description/<tt/clearerr/ clears the error and end-of-file status
1429 indicators for the stream <tt/f/.
1430 <tag/Limits/<itemize>
1431 <item>The function is only available as fastcall function, so it may only be
1432 used in presence of a prototype.
1434 <tag/Availability/ISO 9899
1436 <ref id="feof" name="feof">,
1437 <ref id="ferror" name="ferror">
1443 <sect1>clrscr<label id="clrscr"><p>
1447 <tag/Function/Clear the text screen.
1448 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1449 <tag/Declaration/<tt/void clrscr (void);/
1450 <tag/Description/The function clears the text screen and moves the cursor to
1451 the upper left corner.
1452 <tag/Availability/cc65
1454 <ref id="cclear" name="cclear">,
1455 <ref id="cclearxy" name="cclearxy">
1461 <sect1>close<label id="close"><p>
1465 <tag/Function/Close a file descriptor.
1466 <tag/Header/<tt/<ref id="fcntl.h" name="fcntl.h">/
1467 <tag/Declaration/<tt/int __fastcall__ close (int fd);/
1468 <tag/Description/The function closes the given file descriptor. It returns zero
1469 on success and -1 on error. If an error occurs, the cause can be determined by
1470 reading the <tt/errno/ variable.
1471 <tag/Limits/<itemize>
1472 <item>The function is only available as fastcall function, so it may only
1473 be used in presence of a prototype.
1475 <tag/Availability/POSIX 1003.1
1477 <ref id="creat" name="creat">,
1478 <ref id="open" name="open">
1484 <sect1>creat<label id="creat"><p>
1488 <tag/Function/Create a file.
1489 <tag/Header/<tt/<ref id="fcntl.h" name="fcntl.h">/
1490 <tag/Declaration/<tt/int __fastcall__ creat (const char* name, unsigned mode);/
1491 <tag/Description/<tt/creat/ creates a new file and returns the file descriptor
1492 associated with it. On error, -1 is returned and an error code is stored in
1494 <tag/Limits/<itemize>
1495 <item><tt/creat/ is identical to calling <tt/<ref id="open" name="open">/ with
1496 <tt/flags/ equal to <tt/O_WRONLY | O_CREAT | O_TRUNC/.
1497 <item>The function is only available as fastcall function, so it may only
1498 be used in presence of a prototype.
1500 <tag/Availability/POSIX 1003.1
1502 <ref id="close" name="close">,
1503 <ref id="open" name="open">
1509 <sect1>cprintf<label id="cprintf"><p>
1513 <tag/Function/Formatted output to the console.
1514 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1515 <tag/Declaration/<tt/int cprintf (const char* format, ...);/
1516 <tag/Description/The arguments are converted to text where necessary and
1517 formatted according to the format string given. The resulting string is output
1518 to the console. <tt/cprintf/ supports the same format specifiers as
1519 <tt/printf/. <!-- <tt/<ref id="printf" name="printf">/. -->
1520 <tag/Limits/<itemize>
1521 <item>Like all other <tt/conio/ output functions, <tt/cprintf/ distinguishes
1522 between <tt/\r/ and <tt/\n/.
1524 <tag/Availability/cc65
1526 <ref id="cputc" name="cputc">,
1527 <ref id="cputcxy" name="cputcxy">,
1528 <ref id="cputs" name="cputs">,
1529 <ref id="cputsxy" name="cputsxy">,
1530 <ref id="vcprintf" name="vcprintf">
1536 <sect1>cputc<label id="cputc"><p>
1540 <tag/Function/Output a character directly to the console.
1541 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1542 <tag/Declaration/<tt/void __fastcall__ cputc (char c);/
1543 <tag/Description/Output one character to the console at the current cursor
1545 <tag/Limits/<itemize>
1546 <item>Like all other <tt/conio/ output functions, <tt/cputc/ distinguishes
1547 between <tt/\r/ and <tt/\n/.
1548 <item>The function is only available as fastcall function, so it may only
1549 be used in presence of a prototype.
1551 <tag/Availability/cc65
1553 <ref id="cprintf" name="cprintf">,
1554 <ref id="cputcxy" name="cputcxy">,
1555 <ref id="cputs" name="cputs">,
1556 <ref id="cputsxy" name="cputsxy">,
1557 <ref id="vcprintf" name="vcprintf">
1563 <sect1>cputcxy<label id="cputcxy"><p>
1567 <tag/Function/Output a character at a specific screen position.
1568 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1569 <tag/Declaration/<tt/void __fastcall__ cputcxy (unsigned char x, unsigned char y, char c);/
1570 <tag/Description/<tt/cputcxy/ moves the cursor to the given x/y position on
1571 the screen and outputs one character.
1572 <tag/Limits/<itemize>
1573 <item>Like all other <tt/conio/ output functions, <tt/cputcxy/ distinguishes
1574 between <tt/\r/ and <tt/\n/.
1575 <item>The function is only available as fastcall function, so it may only
1576 be used in presence of a prototype.
1578 <tag/Availability/cc65
1580 <ref id="cprintf" name="cprintf">,
1581 <ref id="cputc" name="cputc">,
1582 <ref id="cputs" name="cputs">,
1583 <ref id="cputsxy" name="cputsxy">,
1584 <ref id="vcprintf" name="vcprintf">
1590 <sect1>cputs<label id="cputs"><p>
1594 <tag/Function/Output a string directly to the console.
1595 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1596 <tag/Declaration/<tt/void __fastcall__ cputs (const char* s);/
1597 <tag/Description/The function outputs the given string on the console at the
1598 current cursor position.
1599 <tag/Limits/<itemize>
1600 <item>Like all other <tt/conio/ output functions, <tt/cputs/ distinguishes
1601 between <tt/\r/ and <tt/\n/.
1602 <item>The function is only available as fastcall function, so it may only
1603 be used in presence of a prototype.
1605 <tag/Availability/cc65
1607 <ref id="cprintf" name="cprintf">,
1608 <ref id="cputc" name="cputc">,
1609 <ref id="cputcxy" name="cputcxy">,
1610 <ref id="cputsxy" name="cputsxy">,
1611 <ref id="vcprintf" name="vcprintf">
1617 <sect1>cputsxy<label id="cputsxy"><p>
1621 <tag/Function/Output a string to the console at a given position.
1622 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1623 <tag/Declaration/<tt/void __fastcall__ cputsxy (unsigned char x, unsigned char y, const char* s);/
1624 <tag/Description/<tt/cputsxy/ moves the cursor to the given x/y position,
1625 and outputs the string <tt/s/.
1626 <tag/Limits/<itemize>
1627 <item>Like all other <tt/conio/ output functions, <tt/cputsxy/ distinguishes
1628 between <tt/\r/ and <tt/\n/.
1629 <item>The function is only available as fastcall function, so it may only
1630 be used in presence of a prototype.
1632 <tag/Availability/cc65
1634 <ref id="cprintf" name="cprintf">,
1635 <ref id="cputc" name="cputc">,
1636 <ref id="cputcxy" name="cputcxy">,
1637 <ref id="cputs" name="cputs">,
1638 <ref id="vcprintf" name="vcprintf">
1644 <sect1>cursor<label id="cursor"><p>
1648 <tag/Function/Enable/disable a blinking cursor when waiting for keyboard input.
1649 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1650 <tag/Declaration/<tt/unsigned char __fastcall__ cursor (unsigned char onoff);/
1651 <tag/Description/If the argument to the function is non zero, a blinking cursor
1652 will be enabled when the <tt/cgetc/ function waits for input from the keyboard.
1653 If the argument is zero, <tt/cgetc/ will wait without a blinking cursor.
1654 <tag/Limits/<itemize>
1655 <item>The function is only available as fastcall function, so it may only
1656 be used in presence of a prototype.
1658 <tag/Availability/cc65
1660 <ref id="cgetc" name="cgetc">,
1661 <ref id="kbhit" name="kbhit">
1667 <sect1>cvline<label id="cvline"><p>
1671 <tag/Function/Output a vertical line in text mode.
1672 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1673 <tag/Declaration/<tt/void __fastcall__ cvline (unsigned char length);/
1674 <tag/Description/The function outputs a vertical line with the given length
1675 starting at the current cursor position.
1676 <tag/Limits/<itemize>
1677 <item>The character used to draw the vertical line is system dependent.
1678 If available, a line drawing character is used. Drawing a line that is partially
1679 off screen leads to undefined behaviour.
1680 <item>The function is only available as fastcall function, so it may only be
1681 used in presence of a prototype.
1683 <tag/Availability/cc65
1685 <ref id="chline" name="chline">,
1686 <ref id="chlinexy" name="chlinexy">,
1687 <ref id="cvlinexy" name="cvlinexy">
1693 <sect1>cvlinexy<label id="cvlinexy"><p>
1697 <tag/Function/Output a vertical line at a given position in text mode.
1698 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1699 <tag/Declaration/<tt/void __fastcall__ cvlinexy (unsigned char x, unsigned char y, unsigned char length);/
1700 <tag/Description/The function outputs a vertical line with the given length
1701 starting at a given position.
1702 <tag/Limits/<itemize>
1703 <item>The character used to draw the vertical line is system dependent.
1704 If available, a line drawing character is used. Drawing a line that is partially
1705 off screen leads to undefined behaviour.
1706 <item>The function is only available as fastcall function, so it may only be
1707 used in presence of a prototype.
1709 <tag/Availability/cc65
1711 <ref id="chline" name="chline">,
1712 <ref id="chlinexy" name="chlinexy">,
1713 <ref id="cvline" name="cvline">
1719 <sect1>div<label id="div"><p>
1723 <tag/Function/Divide two ints and return quotient and remainder.
1724 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1725 <tag/Declaration/<tt/div_t __fastcall__ div (int numer, int denom);/
1726 <tag/Description/<tt/div/ divides <tt/numer/ by <tt/denom/ and returns the
1727 quotient and remainder in a <tt/div_t/ structure.
1730 <item>The function is only available as fastcall function, so it may only
1731 be used in presence of a prototype.
1733 <tag/Availability/ISO 9899
1741 <sect1>em_commit<label id="em_commit"><p>
1745 <tag/Function/Commit changes into extended memory.
1746 <tag/Header/<tt/<ref id="em.h" name="em.h">/
1747 <tag/Declaration/<tt/void __fastcall__ em_commit (void);/
1748 <tag/Description/Commit changes in the memory window to extended storage. If
1749 the contents of the memory window have been changed, these changes may be lost
1750 if <tt/<ref id="em_map" name="em_map">/, <tt/<ref id="em_use" name="em_use">/,
1751 <tt/<ref id="em_copyfrom" name="em_copyfrom">/ or <tt/<ref id="em_copyto"
1752 name="em_copyto">/ are called without calling <tt/em_commit/ first.
1753 <tag/Limits/<itemize>
1754 <item>Calling <tt/em_commit/ does not necessarily mean that changes to the
1755 memory window are discarded, it does just mean that the drivers is allowed
1757 <item>The function is only available as fastcall function, so it may only be
1758 used in presence of a prototype.
1759 <item>The function produces undefined results if no extended memory driver is
1762 <tag/Availability/cc65
1764 <ref id="em_load_driver" name="em_load_driver">,
1765 <ref id="em_map" name="em_map">,
1766 <ref id="em_use" name="em_use">
1772 <sect1>em_copyfrom<label id="em_copyfrom"><p>
1776 <tag/Function/Copy from extended into normal memory.
1777 <tag/Header/<tt/<ref id="em.h" name="em.h">/
1778 <tag/Declaration/<tt/void __fastcall__ em_copyfrom (const struct em_copy* copy_data);/
1779 <tag/Description/Copy data from extended memory into linear memory. Source and
1780 target addresses as well as the number of bytes to transfer are specified in
1781 the <tt/em_copy/ structure that is passed as a parameter.
1782 <tag/Limits/<itemize>
1783 <item>Calling <tt/em_copyfrom/ will invalidate the memory window, so if you
1784 made any changes to the data in the window, call <tt/<ref id="em_commit"
1785 name="em_commit">/ first, or the changes are lost.
1786 <item>The function is only available as fastcall function, so it may only be
1787 used in presence of a prototype.
1788 <item>The function produces undefined results if no extended memory driver is
1791 <tag/Availability/cc65
1793 <ref id="em_commit" name="em_commit">,
1794 <ref id="em_copyto" name="em_copyto">,
1795 <ref id="em_load_driver" name="em_load_driver">
1801 <sect1>em_copyto<label id="em_copyto"><p>
1805 <tag/Function/Copy from normal into extended memory.
1806 <tag/Header/<tt/<ref id="em.h" name="em.h">/
1807 <tag/Declaration/<tt/void __fastcall__ em_copyto (const struct em_copy* copy_data);/
1808 <tag/Description/Copy data from linear into extended memory. Source and
1809 target addresses as well as the number of bytes to transfer are specified in
1810 the <tt/em_copy/ structure that is passed as a parameter.
1811 <tag/Limits/<itemize>
1812 <item>Calling <tt/em_copyto/ will invalidate the memory window, so if you
1813 made any changes to the data in the window, call <tt/<ref id="em_commit"
1814 name="em_commit">/ first, or the changes are lost.
1815 <item>The function is only available as fastcall function, so it may only be
1816 used in presence of a prototype.
1817 <item>The function produces undefined results if no extended memory driver is
1820 <tag/Availability/cc65
1822 <ref id="em_commit" name="em_commit">,
1823 <ref id="em_copyfrom" name="em_copyfrom">,
1824 <ref id="em_load_driver" name="em_load_driver">
1830 <sect1>em_install<label id="em_install"><p>
1834 <tag/Function/Install an already loaded extended memory driver.
1835 <tag/Header/<tt/<ref id="em.h" name="em.h">/
1836 <tag/Declaration/<tt/unsigned char _fastcall__ em_install (void* driver);/
1837 <tag/Description/The function installs an already loaded extended memory driver
1838 and returns an error code. The function may be used to install a driver linked
1839 statically to the program.
1840 <tag/Limits/<itemize>
1841 <item>Not all drivers are able to detect if the supported hardware is really
1843 <item>The function is only available as fastcall function, so it may only be
1844 used in presence of a prototype.
1846 <tag/Availability/cc65
1848 <ref id="em_load_driver" name="em_load_driver">,
1849 <ref id="em_uninstall" name="em_uninstall">,
1850 <ref id="em_unload" name="em_unload">
1856 <sect1>em_load_driver<label id="em_load_driver"><p>
1860 <tag/Function/Load and initialize an extended memory driver.
1861 <tag/Header/<tt/<ref id="em.h" name="em.h">/
1862 <tag/Declaration/<tt/void __fastcall__ em_load_driver (const char* name);/
1863 <tag/Description/Load an extended memory driver into memory and initialize
1864 it. The function returns an error code that tells if all this has been
1866 <tag/Limits/<itemize>
1867 <item>Not all drivers are able to detect if the supported hardware is really
1869 <item>The function is only available as fastcall function, so it may only be
1870 used in presence of a prototype.
1871 <item>The driver is loaded by name, so currently you must know the type of
1872 extended memory that should be supported. There is no autodetect capability.
1874 <tag/Availability/cc65
1876 <ref id="em_unload" name="em_unload">
1882 <sect1>em_map<label id="em_map"><p>
1886 <tag/Function/Make a page of extended memory accessible.
1887 <tag/Header/<tt/<ref id="em.h" name="em.h">/
1888 <tag/Declaration/<tt/void* __fastcall__ em_map (unsigned page);/
1889 <tag/Description/The function maps one page of extended memory into linear
1890 memory and returns a pointer to the page frame. Depending on the hardware
1891 and driver, the data is either mapped into the address space or transfered
1892 into a buffer. If you don't need the actual contents of the page (for example
1893 because you're going to overwrite it completely), it is better to call
1894 <tt/<ref id="em_use" name="em_use">/ instead. <tt/em_use/ will not transfer the
1895 data if it is possible to avoid that.
1896 <tag/Limits/<itemize>
1897 <item>Calling <tt/em_map/ will invalidate the memory window, so if you
1898 made any changes to the data in the window, call <tt/<ref id="em_commit"
1899 name="em_commit">/ first, or the changes are lost.
1900 <item>The function is only available as fastcall function, so it may only be
1901 used in presence of a prototype.
1902 <item>The function produces undefined results if no extended memory driver is
1905 <tag/Availability/cc65
1907 <ref id="em_commit" name="em_commit">,
1908 <ref id="em_load_driver" name="em_load_driver">,
1909 <ref id="em_use" name="em_use">
1915 <sect1>em_pagecount<label id="em_pagecount"><p>
1919 <tag/Function/Return the number of available extended memory pages.
1920 <tag/Header/<tt/<ref id="em.h" name="em.h">/
1921 <tag/Declaration/<tt/unsigned __fastcall__ em_pagecount (void);/
1922 <tag/Description/The function returns the size of the extended memory supported
1923 by the driver in 256 byte pages.
1924 <tag/Limits/<itemize>
1925 <item>The function returns zero if no extended memory driver is loaded.
1926 <item>The function may return zero if the supported hardware was not detected.
1928 <tag/Availability/cc65
1930 <ref id="em_load_driver" name="em_load_driver">
1936 <sect1>em_uninstall<label id="em_uninstall"><p>
1940 <tag/Function/Uninstall an already loaded extended memory driver.
1941 <tag/Header/<tt/<ref id="em.h" name="em.h">/
1942 <tag/Declaration/<tt/unsigned char __fastcall__ em_install (void);/
1943 <tag/Description/The function uninstalls an already loaded extended memory
1944 driver but doesn't remove it from memory.
1945 <tag/Limits/<itemize>
1946 <item>If the driver has been loaded using <tt/<ref id="em_load_driver"
1947 name="em_load_driver">/, <tt/<ref id="em_unload" name="em_unload">/
1948 should be used instead of <tt/em_uninstall/ so the driver is also removed
1950 <item>The function is only available as fastcall function, so it may only be
1951 used in presence of a prototype.
1953 <tag/Availability/cc65
1955 <ref id="em_install" name="em_install">,
1956 <ref id="em_load_driver" name="em_load_driver">,
1957 <ref id="em_unload" name="em_unload">
1963 <sect1>em_unload<label id="em_unload"><p>
1967 <tag/Function/Unload an extended memory driver.
1968 <tag/Header/<tt/<ref id="em.h" name="em.h">/
1969 <tag/Declaration/<tt/unsigned char __fastcall__ em_unload (void);/
1970 <tag/Description/The function unloads a loaded extended memory driver and
1971 frees all memory allocated for the driver.
1972 <tag/Limits/<itemize>
1973 <item>The function does nothing if no driver is loaded.
1975 <tag/Availability/cc65
1977 <ref id="em_load_driver" name="em_load_driver">
1983 <sect1>em_use<label id="em_use"><p>
1987 <tag/Function/Prepare an extended memory page for use.
1988 <tag/Header/<tt/<ref id="em.h" name="em.h">/
1989 <tag/Declaration/<tt/void* __fastcall__ em_use (unsigned page);/
1990 <tag/Description/The function maps one page of extended memory into linear
1991 memory and returns a pointer to the page frame. This function is similar to
1992 <tt/<ref id="em_map" name="em_map">/, but will not transfer data into the
1993 actual memory window in the assumption that the existing data is wrong or
1994 will get overwritten.
1995 <tag/Limits/<itemize>
1996 <item>Calling <tt/em_use/ will invalidate the memory window, so if you
1997 made any changes to the data in the window, call <tt/<ref id="em_commit"
1998 name="em_commit">/ first, or the changes are lost.
1999 <item>The function is only available as fastcall function, so it may only be
2000 used in presence of a prototype.
2001 <item>The function produces undefined results if no extended memory driver is
2004 <tag/Availability/cc65
2006 <ref id="em_commit" name="em_commit">,
2007 <ref id="em_load_driver" name="em_load_driver">,
2008 <ref id="em_map" name="em_map">
2014 <sect1>exit<label id="exit"><p>
2018 <tag/Function/Terminate the program.
2019 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
2020 <tag/Declaration/<tt/void __fastcall__ exit (int status);/
2021 <tag/Description/<tt/exit/ terminates the program. The argument specifies the
2022 return code of the program. Before termination, all files are closed, buffered
2023 output is written and any functions registered with <tt/<ref id="atexit"
2024 name="atexit">/ are called. Common values for status are <tt/EXIT_SUCCESS/ and
2025 <tt/EXIT_FAILURE/ which are also defined in <tt/<ref id="stdlib.h"
2027 <tag/Limits/<itemize>
2028 <item>The function is only available as fastcall function, so it may only
2029 be used in presence of a prototype.
2030 <item>It depends on the host machine if the program return code can be
2031 evaluated or is ignored.
2033 <tag/Availability/ISO 9899
2035 <ref id="abort" name="abort">,
2036 <ref id="exit" name="exit">
2042 <sect1>fast<label id="fast"><p>
2046 <tag/Function/Switch the C128 into 2MHz mode.
2047 <tag/Header/<tt/<ref id="c128.h" name="c128.h">/
2048 <tag/Declaration/<tt/void fast (void);/
2049 <tag/Description/The function will switch the clock of the C128 to 2MHz. This
2050 will nearly double the speed compared to slow mode.
2051 <tag/Limits/<itemize>
2052 <item>The function is specific to the C128.
2053 <item>2MHz clock will not work in 40 column mode.
2055 <tag/Availability/C128
2057 <ref id="slow" name="slow">,
2058 <ref id="toggle_videomode" name="toggle_videomode">,
2059 <ref id="videomode" name="videomode">
2065 <sect1>feof<label id="feof"><p>
2069 <tag/Function/Return the end-of-file indicator of a stream.
2070 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
2071 <tag/Declaration/<tt/int __fastcall__ feof (FILE* f);/
2072 <tag/Description/<tt/feof/ tests the end-of-file indicator ofthe stream
2073 <tt/f/, and returns a non zero value if it is set.
2074 <tag/Limits/<itemize>
2075 <item>The indicator is set only after a read past the end of a file is
2077 <item>The function is only available as fastcall function, so it may only be
2078 used in presence of a prototype.
2080 <tag/Availability/ISO 9899
2082 <ref id="feof" name="clearerr">,
2083 <ref id="ferror" name="ferror">
2089 <sect1>ferror<label id="ferror"><p>
2093 <tag/Function/Return the error indicator of a stream.
2094 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
2095 <tag/Declaration/<tt/int __fastcall__ ferror (FILE* f);/
2096 <tag/Description/<tt/ferror/ tests the error indicator of the stream
2097 <tt/f/, and returns a non zero value if it is set.
2098 <tag/Limits/<itemize>
2099 <item>The function is only available as fastcall function, so it may only be
2100 used in presence of a prototype.
2102 <tag/Availability/ISO 9899
2104 <ref id="feof" name="clearerr">,
2105 <ref id="ferror" name="feof">
2111 <sect1>fileno<label id="fileno"><p>
2115 <tag/Function/Return the file handle used by a stream.
2116 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
2117 <tag/Declaration/<tt/int __fastcall__ fileno (FILE* f);/
2118 <tag/Description/The <tt/fileno/ function returns the file handle used
2119 internally by a C stream. This file handle (an integer) can be used as a
2120 handle for the POSIX input/output functions.
2121 <tag/Limits/<itemize>
2122 <item>The function is only available as fastcall function, so it may only be
2123 used in presence of a prototype.
2124 <item>Mixing C file I/O functions and POSIX file I/O functions for the same
2125 file may have unpredictable results.
2127 <tag/Availability/POSIX 1003.1
2129 <ref id="creat" name="creat">,
2130 <ref id="open" name="open"> <!-- , -->
2131 <!-- <ref id="read" name="read">, -->
2132 <!-- <ref id="write" name="write"> -->
2138 <sect1>free<label id="free"><p>
2142 <tag/Function/Free a block of dynamic memory.
2143 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
2144 <tag/Declaration/<tt/void __fastcall__ free (void* block);/
2145 <tag/Description/Free a block of dynamic memory previously allocated with
2146 <tt/<ref id="malloc" name="malloc">/, <tt/<ref id="calloc" name="calloc">/
2147 or <tt/<ref id="realloc" name="realloc">/. As an exception, if the passed
2148 pointer is <tt/NULL/, no action is performed.
2151 <item>Passing an already free'd block to <tt/free/ again will cause undefined
2152 behaviour and may crash your program.
2153 <item>The function is only available as fastcall function, so it may only
2154 be used in presence of a prototype.
2156 <tag/Availability/ISO 9899
2158 <ref id="_heapadd" name="_heapadd">,
2159 <ref id="_heapblocksize" name="_heapblocksize">,
2160 <ref id="_heapmaxavail" name="_heapmaxavail">,
2161 <ref id="_heapmemavail" name="_heapmemavail">,
2162 <ref id="calloc" name="calloc">,
2163 <ref id="malloc" name="malloc">,
2164 <ref id="realloc" name="realloc">
2170 <sect1>get_ostype<label id="get_ostype"><p>
2174 <tag/Function/The function returns the operating system, the program runs on.
2175 <tag/Header/<tt/<ref id="apple2.h" name="apple2.h">,
2176 <ref id="atari.h" name="atari.h">, <ref id="c64.h" name="c64.h">/
2177 <tag/Declaration/<tt/unsigned char get_ostype (void);/
2178 <tag/Description/<tt/get_ostype/ is machine dependent and does not exist for
2179 all supported targets. If it exists, it returns a number that identifies the
2180 operating system or machine type, the program runs on. The machine dependent
2181 header files define constants that can be used to check the return code.
2182 <tag/Limits/<itemize>
2183 <item>The function does not exist on all platforms.
2184 <item>The return codes are platform dependent.
2186 <tag/Availability/cc65 (not all platforms)
2192 <sect1>getcpu<label id="getcpu"><p>
2196 <tag/Function/Determine on which CPU the program is running.
2197 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
2198 <tag/Declaration/<tt/unsigned char getcpu (void);/
2199 <tag/Description/The function checks on which CPU the code is running. It
2200 returns one of the constants<itemize>
2202 <item><tt/CPU_65C02/
2203 <item><tt/CPU_65816/
2205 <tag/Limits/<itemize>
2206 <item>Other, more exotic CPU types are not disinguished.
2208 <tag/Availability/cc65
2214 <sect1>getenv<label id="getenv"><p>
2218 <tag/Function/Return a value from the environment.
2219 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
2220 <tag/Declaration/<tt/char* __fastcall__ getenv (const char* name);/
2221 <tag/Description/The function searches the environment for an entry that
2222 matches <tt/name/ and returns its value. The environment consists of a list
2223 of strings in the form <tt/name=value/. If there is no match, <tt/getenv/
2225 <tag/Limits/<itemize>
2226 <item>What exactly is stored in the environment depends on the machine the
2227 program is running on.
2228 <item>The function is only available as fastcall function, so it may only
2229 be used in presence of a prototype.
2231 <tag/Availability/ISO 9899
2237 <sect1>getopt<label id="getopt"><p>
2241 <tag/Function/Parse command line options.
2242 <tag/Header/<tt/<ref id="unistd.h" name="unistd.h">/
2243 <tag/Declaration/<tt/int __fastcall__ getopt (int argc, char* const* argv,
2244 const char* optstring);/
2245 <tag/Description/The function parses command line arguments, <tt/argc/ and
2246 <tt/argv/ are the argument count and array passed to <tt/main/. <tt/optstring/
2247 is a string that contains command line option characters. If a character in
2248 <tt/optstring/ is followed by a colon, the option requires an argument. An
2249 option on the command line is recognized if it is one of the option characters
2251 <tt/getopt/ must be called repeatedly. It will return each option character
2252 found on the command line and <tt/EOF/ (-1) if there is no other option. An
2253 option argument is placed in <tt/optarg/, the index of the next element on the
2254 command line to be processed is placed in <tt/optind/.
2255 <tag/Limits/<itemize>
2256 <item>The implementation will not reorder options. A non option on the command
2257 line will terminate option processing. All remaining arguments are not
2258 recognized as options, even if the start with a '-' character.
2259 <item>The function is only available as fastcall function, so it may only
2260 be used in presence of a prototype.
2262 <tag/Availability/POSIX.2
2268 <sect1>gotox<label id="gotox"><p>
2272 <tag/Function/Move the text mode cursor to a new X position.
2273 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2274 <tag/Declaration/<tt/void __fastcall__ gotox (unsigned char x);/
2275 <tag/Description/The function moves the text mode cursor to the specified X
2276 position while leaving the Y position untouched. The leftmost position on the
2277 screen has the coordinate 0.
2278 <tag/Limits/<itemize>
2279 <item>The function is only available as fastcall function, so it may
2280 only be used in presence of a prototype.
2281 <item>Invalid values for the X position (out of screen coordinates) may
2282 lead to undefined behaviour.
2284 <tag/Availability/cc65
2286 <ref id="gotoy" name="gotoy">,
2287 <ref id="gotoxy" name="gotoxy">,
2288 <ref id="wherex" name="wherex">,
2289 <ref id="wherey" name="wherey">
2295 <sect1>gotoxy<label id="gotoxy"><p>
2299 <tag/Function/Move the text mode cursor to a new position.
2300 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2301 <tag/Declaration/<tt/void __fastcall__ gotoxy (unsigned char x, unsigned char y);/
2302 <tag/Description/The function moves the text mode cursor to the specified
2303 position. The leftmost position on the screen has the X coordinate 0, the
2304 topmost line has the Y coordinate 0.
2305 <tag/Limits/<itemize>
2306 <item>The function is only available as fastcall function, so it may only be
2307 used in presence of a prototype.
2308 <item>Invalid values for any of both coordinates (out of screen positions) may
2309 lead to undefined behaviour.
2311 <tag/Availability/cc65
2313 <ref id="gotox" name="gotox">,
2314 <ref id="gotoy" name="gotoy">,
2315 <ref id="wherex" name="wherex">,
2316 <ref id="wherey" name="wherey">
2322 <sect1>gotoy<label id="gotoy"><p>
2326 <tag/Function/Move the text mode cursor to a new Y position.
2327 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2328 <tag/Declaration/<tt/void __fastcall__ gotoy (unsigned char x);/
2329 <tag/Description/The function moves the text mode cursor to the specified Y
2330 position while leaving the X position untouched. The uppermost position on the
2331 screen has the coordinate 0.
2332 <tag/Limits/<itemize>
2333 <item>The function is only available as fastcall function, so it may
2334 only be used in presence of a prototype.
2335 <item>Invalid values for the Y position (out of screen coordinates) may lead
2336 to undefined behaviour.
2338 <tag/Availability/cc65
2340 <ref id="gotox" name="gotox">,
2341 <ref id="gotoxy" name="gotoxy">,
2342 <ref id="wherex" name="wherex">,
2343 <ref id="wherey" name="wherey">
2349 <sect1>isalnum<label id="isalnum"><p>
2353 <tag/Function/Check if a given character is a letter or digit.
2354 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2355 <tag/Declaration/<tt/int __fastcall__ isalnum (int c);/
2356 <tag/Description/The function returns a non zero value if the given argument
2357 is a letter or digit. The return value is zero if the character is anything
2359 <tag/Limits/<itemize>
2360 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2361 inline sequence generated by the macro will not work correctly for values
2362 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2363 this range. The non inline function may be accessed by <tt/#undef/'ing
2365 <item>When compiling without <tt/-Os/, the function is only available as
2366 fastcall function, so it may only be used in presence of a prototype.
2368 <tag/Availability/ISO 9899
2370 <ref id="isalpha" name="isalpha">,
2371 <ref id="isascii" name="isascii">,
2372 <ref id="isblank" name="isblank">,
2373 <ref id="iscntrl" name="iscntrl">,
2374 <ref id="isdigit" name="isdigit">,
2375 <ref id="isgraph" name="isgraph">,
2376 <ref id="islower" name="islower">,
2377 <ref id="isprint" name="isprint">,
2378 <ref id="ispunct" name="ispunct">,
2379 <ref id="isspace" name="isspace">,
2380 <ref id="isupper" name="isupper">,
2381 <ref id="isxdigit" name="isxdigit">
2387 <sect1>isalpha<label id="isalpha"><p>
2391 <tag/Function/Check if a given character is a letter.
2392 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2393 <tag/Declaration/<tt/int __fastcall__ isalpha (int c);/
2394 <tag/Description/The function returns a non zero value if the given argument
2395 is a letter. The return value is zero if the character is anything else.
2396 <tag/Limits/<itemize>
2397 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2398 inline sequence generated by the macro will not work correctly for values
2399 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2400 this range. The non inline function may be accessed by <tt/#undef/'ing the
2402 <item>When compiling without <tt/-Os/, the function is only available as
2403 fastcall function, so it may only be used in presence of a prototype.
2405 <tag/Availability/ISO 9899
2407 <ref id="isalnum" name="isalnum">,
2408 <ref id="isascii" name="isascii">,
2409 <ref id="isblank" name="isblank">,
2410 <ref id="iscntrl" name="iscntrl">,
2411 <ref id="isdigit" name="isdigit">,
2412 <ref id="isgraph" name="isgraph">,
2413 <ref id="islower" name="islower">,
2414 <ref id="isprint" name="isprint">,
2415 <ref id="ispunct" name="ispunct">,
2416 <ref id="isspace" name="isspace">,
2417 <ref id="isupper" name="isupper">,
2418 <ref id="isxdigit" name="isxdigit">
2424 <sect1>isascii<label id="isascii"><p>
2428 <tag/Function/Check if a given character is in the ASCII (0..127) range.
2429 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2430 <tag/Declaration/<tt/int __fastcall__ isascii (int c);/
2431 <tag/Description/The function returns a non zero value if the given argument
2432 is in the range 0..127 (the range of valid ASCII characters) and zero if not.
2433 <tag/Limits/<itemize>
2434 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2435 inline sequence generated by the macro will not work correctly for values
2436 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2437 this range. The non inline function may be accessed by <tt/#undef/'ing the
2439 <item>When compiling without <tt/-Os/, the function is only available as
2440 fastcall function, so it may only be used in presence of a prototype.
2442 <tag/Availability/ISO 9899
2444 <ref id="isalnum" name="isalnum">,
2445 <ref id="isalpha" name="isalpha">,
2446 <ref id="isblank" name="isblank">,
2447 <ref id="iscntrl" name="iscntrl">,
2448 <ref id="isdigit" name="isdigit">,
2449 <ref id="isgraph" name="isgraph">,
2450 <ref id="islower" name="islower">,
2451 <ref id="isprint" name="isprint">,
2452 <ref id="ispunct" name="ispunct">,
2453 <ref id="isspace" name="isspace">,
2454 <ref id="isupper" name="isupper">,
2455 <ref id="isxdigit" name="isxdigit">
2461 <sect1>isblank<label id="isblank"><p>
2465 <tag/Function/Check if a given character is a space or tab.
2466 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2467 <tag/Declaration/<tt/int __fastcall__ isblank (int c);/
2468 <tag/Description/The function returns a non zero value if the given argument
2469 is a space or tab character. The return value is zero if the character is
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/cc65
2482 <ref id="isalnum" name="isalnum">,
2483 <ref id="isalpha" name="isalpha">,
2484 <ref id="isascii" name="isascii">,
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>iscntrl<label id="iscntrl"><p>
2503 <tag/Function/Check if a given character is a control character.
2504 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2505 <tag/Declaration/<tt/int __fastcall__ iscntrl (int c);/
2506 <tag/Description/The function returns a non zero value if the given argument
2507 is a control character. The return value is zero if the character is anything
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/ISO 9899
2520 <ref id="isalnum" name="isalnum">,
2521 <ref id="isalpha" name="isalpha">,
2522 <ref id="isascii" name="isascii">,
2523 <ref id="isblank" name="isblank">,
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>isdigit<label id="isdigit"><p>
2541 <tag/Function/Check if a given character is a digit.
2542 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2543 <tag/Declaration/<tt/int __fastcall__ isdigit (int c);/
2544 <tag/Description/The function returns a non zero value if the given argument
2545 is a digit. The return value is zero if the character is anything else.
2546 <tag/Limits/<itemize>
2547 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2548 inline sequence generated by the macro will not work correctly for values
2549 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2550 this range. The non inline function may be accessed by <tt/#undef/'ing the
2552 <item>When compiling without <tt/-Os/, the function is only available as
2553 fastcall function, so it may only be used in presence of a prototype.
2555 <tag/Availability/ISO 9899
2557 <ref id="isalnum" name="isalnum">,
2558 <ref id="isalpha" name="isalpha">,
2559 <ref id="isascii" name="isascii">,
2560 <ref id="isblank" name="isblank">,
2561 <ref id="iscntrl" name="iscntrl">,
2562 <ref id="isgraph" name="isgraph">,
2563 <ref id="islower" name="islower">,
2564 <ref id="isprint" name="isprint">,
2565 <ref id="ispunct" name="ispunct">,
2566 <ref id="isspace" name="isspace">,
2567 <ref id="isupper" name="isupper">,
2568 <ref id="isxdigit" name="isxdigit">
2574 <sect1>isgraph<label id="isgraph"><p>
2578 <tag/Function/Check if a given character is a printable character (except
2580 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2581 <tag/Declaration/<tt/int __fastcall__ isgraph (int c);/
2582 <tag/Description/The function returns a non zero value if the given argument
2583 is a printable character with the exception of space. The return value is zero
2584 if the character is anything else.
2585 <tag/Limits/<itemize>
2586 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2587 inline sequence generated by the macro will not work correctly for values
2588 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2589 this range. The non inline function may be accessed by <tt/#undef/'ing the
2591 <item>When compiling without <tt/-Os/, the function is only available as
2592 fastcall function, so it may only be used in presence of a prototype.
2594 <tag/Availability/ISO 9899
2596 <ref id="isalnum" name="isalnum">,
2597 <ref id="isalpha" name="isalpha">,
2598 <ref id="isascii" name="isascii">,
2599 <ref id="isblank" name="isblank">,
2600 <ref id="iscntrl" name="iscntrl">,
2601 <ref id="isdigit" name="isdigit">,
2602 <ref id="islower" name="islower">,
2603 <ref id="isprint" name="isprint">,
2604 <ref id="ispunct" name="ispunct">,
2605 <ref id="isspace" name="isspace">,
2606 <ref id="isupper" name="isupper">,
2607 <ref id="isxdigit" name="isxdigit">
2613 <sect1>islower<label id="islower"><p>
2617 <tag/Function/Check if a given character is a lower case letter.
2618 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2619 <tag/Declaration/<tt/int __fastcall__ islower (int c);/
2620 <tag/Description/The function returns a non zero value if the given argument
2621 is a lower case letter. The return value is zero if the character is anything
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="isgraph" name="isgraph">,
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>isprint<label id="isprint"><p>
2655 <tag/Function/Check if a given character is a printable character.
2656 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2657 <tag/Declaration/<tt/int __fastcall__ isprint (int c);/
2658 <tag/Description/The function returns a non zero value if the given argument
2659 is a printable character (this includes the space character). The return value
2660 is zero if the character is anything else.
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="islower" name="islower">,
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>ispunct<label id="ispunct"><p>
2693 <tag/Function/Check if a given character is a printable character but not a
2694 space or an alphanumeric character.
2695 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2696 <tag/Declaration/<tt/int __fastcall__ ispunct (int c);/
2697 <tag/Description/The function returns a non zero value if the given argument
2698 is a printable character, but not a space or anything alphanumeric. The return
2699 value is zero if the character is anything else.
2700 <tag/Limits/<itemize>
2701 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2702 inline sequence generated by the macro will not work correctly for values
2703 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2704 this range. The non inline function may be accessed by <tt/#undef/'ing the
2706 <item>When compiling without <tt/-Os/, the function is only available as
2707 fastcall function, so it may only be used in presence of a prototype.
2709 <tag/Availability/ISO 9899
2711 <ref id="isalnum" name="isalnum">,
2712 <ref id="isalpha" name="isalpha">,
2713 <ref id="isascii" name="isascii">,
2714 <ref id="isblank" name="isblank">,
2715 <ref id="iscntrl" name="iscntrl">,
2716 <ref id="isdigit" name="isdigit">,
2717 <ref id="isgraph" name="isgraph">,
2718 <ref id="islower" name="islower">,
2719 <ref id="isprint" name="isprint">,
2720 <ref id="isspace" name="isspace">,
2721 <ref id="isupper" name="isupper">,
2722 <ref id="isxdigit" name="isxdigit">
2728 <sect1>isspace<label id="isspace"><p>
2732 <tag/Function/Check if a given character is a a white-space character.
2733 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2734 <tag/Declaration/<tt/int __fastcall__ isspace (int c);/
2735 <tag/Description/The function returns a non zero value if the given argument
2736 is a white space character. The return value is zero if the character is
2737 anything else. The standard white space characters are: space, formfeed ('\f'),
2738 newline ('\n'), carriage return ('\r'), horizontal tab ('\t'), and vertical tab
2740 <tag/Limits/<itemize>
2741 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2742 inline sequence generated by the macro will not work correctly for values
2743 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2744 this range. The non inline function may be accessed by <tt/#undef/'ing the
2746 <item>When compiling without <tt/-Os/, the function is only available as
2747 fastcall function, so it may only be used in presence of a prototype.
2749 <tag/Availability/ISO 9899
2751 <ref id="isalnum" name="isalnum">,
2752 <ref id="isalpha" name="isalpha">,
2753 <ref id="isascii" name="isascii">,
2754 <ref id="isblank" name="isblank">,
2755 <ref id="iscntrl" name="iscntrl">,
2756 <ref id="isdigit" name="isdigit">,
2757 <ref id="isgraph" name="isgraph">,
2758 <ref id="islower" name="islower">,
2759 <ref id="isprint" name="isprint">,
2760 <ref id="ispunct" name="ispunct">,
2761 <ref id="isupper" name="isupper">,
2762 <ref id="isxdigit" name="isxdigit">
2768 <sect1>isupper<label id="isupper"><p>
2772 <tag/Function/Check if a given character is an upper case letter.
2773 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2774 <tag/Declaration/<tt/int __fastcall__ isupper (int c);/
2775 <tag/Description/The function returns a non zero value if the given argument
2776 is an upper case letter. The return value is zero if the character is anything
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="isspace" name="isspace">,
2800 <ref id="isxdigit" name="isxdigit">
2806 <sect1>isxdigit<label id="isxdigit"><p>
2810 <tag/Function/Check if a given character is a hexadecimal digit.
2811 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2812 <tag/Declaration/<tt/int __fastcall__ isxdigit (int c);/
2813 <tag/Description/The function returns a non zero value if the given argument
2814 is a hexadecimal digit (0..9, a..f and A..F). The return value is zero if the
2815 character is anything else.
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="isupper" name="isupper">
2844 <sect1>itoa<label id="itoa"><p>
2848 <tag/Function/Convert an integer into a string.
2849 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
2850 <tag/Declaration/<tt/char* __fastcall__ itoa (int val, char* buf, int radix);/
2851 <tag/Description/<tt/itoa/ converts the integer <tt/val/ into a string using
2852 <tt/radix/ as the base.
2853 <tag/Limits/<itemize>
2854 <item>There are no provisions to prevent a buffer overflow.
2855 <item>If <tt/val/ contains <tt/INT_MIN/, the behaviour is undefined.
2856 <item>The function is non standard, so it is not available in strict ANSI mode.
2857 You should probably use <tt/sprintf/ instead.
2858 <item>The function is only available as fastcall function, so it may only be
2859 used in presence of a prototype.
2861 <tag/Availability/cc65
2863 <ref id="atoi" name="atoi">,
2864 <ref id="atol" name="atol">,
2865 <ref id="ltoa" name="ltoa">,
2866 <ref id="ultoa" name="ultoa">,
2867 <ref id="utoa" name="utoa">
2873 <sect1>joy_count<label id="joy_count"><p>
2877 <tag/Function/Return the number of joysticks supported by the current driver.
2878 <tag/Header/<tt/<ref id="joystick.h" name="joystick.h">/
2879 <tag/Declaration/<tt/unsigned char __fastcall__ joy_count (void);/
2880 <tag/Description/The function returns a the number of joysticks supported
2881 by the current joystick driver.
2882 <tag/Limits/<itemize>
2883 <item>A joystick driver must be loaded using <ref id="joy_load_driver"
2884 name="joy_load_driver"> before calling this function.
2885 <item>The function returns the number of joysticks supported by the driver.
2886 There's no way to check for the number of actually connected joysticks.
2887 <item>The function is only available as fastcall function, so it may only be
2888 used in presence of a prototype.
2890 <tag/Availability/cc65
2892 <ref id="joy_load_driver" name="joy_load_driver">,
2893 <ref id="joy_read" name="joy_read">
2899 <sect1>joy_install<label id="joy_install"><p>
2903 <tag/Function/Install an already loaded driver and return an error code.
2904 <tag/Header/<tt/<ref id="joystick.h" name="joystick.h">/
2905 <tag/Declaration/<tt/unsigned char __fastcall__ joy_install (void* driver);/
2906 <tag/Description/The function installs a driver that was already loaded into
2907 memory (or linked statically to the program). It returns an error code
2908 (<tt/JOY_ERR_OK/ in case of success).
2909 <tag/Limits/<itemize>
2910 <item>The function is only available as fastcall function, so it may only be
2911 used in presence of a prototype.
2913 <tag/Availability/cc65
2915 <ref id="joy_load_driver" name="joy_load_driver">,
2916 <ref id="joy_uninstall" name="joy_uninstall">,
2917 <ref id="joy_unload" name="joy_unload">
2923 <sect1>joy_load_driver<label id="joy_load_driver"><p>
2927 <tag/Function/Load a driver from disk and install it.
2928 <tag/Header/<tt/<ref id="joystick.h" name="joystick.h">/
2929 <tag/Declaration/<tt/unsigned char __fastcall__ joy_load_driver (const char* driver);/
2930 <tag/Description/The function loads a driver with the given name from disk
2931 and installs it. An error code is returned, which is <tt/JOY_ERR_OK/ if the
2932 driver was successfully loaded and installed.
2933 <tag/Limits/<itemize>
2934 <item>The function is only available as fastcall function, so it may only be
2935 used in presence of a prototype.
2937 <tag/Availability/cc65
2939 <ref id="joy_install" name="joy_install">,
2940 <ref id="joy_uninstall" name="joy_uninstall">,
2941 <ref id="joy_unload" name="joy_unload">
2947 <sect1>joy_read<label id="joy_read"><p>
2951 <tag/Function/Read the status of a joystick.
2952 <tag/Header/<tt/<ref id="joystick.h" name="joystick.h">/
2953 <tag/Declaration/<tt/unsigned char __fastcall__ joy_read (unsigned char joystick);/
2954 <tag/Description/The function reads the status bits for a joystick. The number
2955 of the joystick is passed as parameter. The result may be examined by using one
2956 of the <tt/JOY_xxx/ macros from <ref id="joystick.h" name="joystick.h">.
2957 <tag/Limits/<itemize>
2958 <item>A joystick driver must be loaded using <ref id="joy_load_driver"
2959 name="joy_load_driver"> before calling this function.
2960 <item>The function is only available as fastcall function, so it may only be
2961 used in presence of a prototype.
2963 <tag/Availability/cc65
2965 <ref id="joy_count" name="joy_count">,
2966 <ref id="joy_load_driver" name="joy_load_driver">,
2967 <ref id="joy_unload" name="joy_unload">
2973 <sect1>joy_uninstall<label id="joy_uninstall"><p>
2977 <tag/Function/Uninstall the current joystick driver.
2978 <tag/Header/<tt/<ref id="joystick.h" name="joystick.h">/
2979 <tag/Declaration/<tt/unsigned char __fastcall__ joy_uninstall (void);/
2980 <tag/Description/The function uninstalls the currently installed joystick
2981 driver. It does not remove the driver from memory. The function returns an
2982 error code, which is <tt/JOY_ERR_OK/ if the driver was successfully uninstalled.
2983 <tag/Limits/<itemize>
2984 <item>A joystick driver must be installed using <ref id="joy_install"
2985 name="joy_install"> before calling this function.
2986 <item>The function is only available as fastcall function, so it may only be
2987 used in presence of a prototype.
2989 <tag/Availability/cc65
2991 <ref id="joy_install" name="joy_install">,
2992 <ref id="joy_load_driver" name="joy_load_driver">,
2993 <ref id="joy_unload" name="joy_unload">
2999 <sect1>joy_unload<label id="joy_unload"><p>
3003 <tag/Function/Uninstall, then unload the current joystick driver.
3004 <tag/Header/<tt/<ref id="joystick.h" name="joystick.h">/
3005 <tag/Declaration/<tt/unsigned char __fastcall__ joy_unload (void);/
3006 <tag/Description/The function uninstalls the currently installed joystick
3007 driver and removes it from memory. An error code is returned, which is
3008 <tt/JOY_ERR_OK/ if the driver was successfully uninstalled.
3009 <tag/Limits/<itemize>
3010 <item>A joystick driver must be loaded using <ref id="joy_load_driver"
3011 name="joy_load_driver"> before calling this function.
3012 <item>The function is only available as fastcall function, so it may only be
3013 used in presence of a prototype.
3015 <tag/Availability/cc65
3017 <ref id="joy_load_driver" name="joy_load_driver">
3023 <sect1>kbhit<label id="kbhit"><p>
3027 <tag/Function/Check if there's a key waiting in the keyboard buffer.
3028 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
3029 <tag/Declaration/<tt/unsigned char kbhit (void);/
3030 <tag/Description/The function returns a value of zero if there is no character
3031 waiting to be read from the keyboard. It returns non zero otherwise.
3032 <tag/Limits/<itemize>
3033 <item>If the system does not support a keyboard buffer (most systems
3034 do), the function is rather useless.
3036 <tag/Availability/cc65
3038 <ref id="cgetc" name="cgetc">,
3039 <ref id="cursor" name="cursor">
3045 <sect1>labs<label id="labs"><p>
3049 <tag/Function/Returns the absolute value of a long integer.
3050 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
3051 <tag/Declaration/<tt/long __fastcall__ labs (long v);/
3052 <tag/Description/<tt/labs/ returns the absolute value of the argument passed to
3054 <tag/Limits/<itemize>
3055 <item>The return value is undefined if <tt/LONG_MIN/ is passed to the function.
3056 <item>The function is only available as fastcall function, so it may only be
3057 used in presence of a prototype.
3059 <tag/Availability/ISO 9899
3061 <ref id="abs" name="abs">
3067 <sect1>ltoa<label id="ltoa"><p>
3071 <tag/Function/Convert a long integer into a string.
3072 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
3073 <tag/Declaration/<tt/char* __fastcall__ ltoa (long val, char* buf, int radix);/
3074 <tag/Description/<tt/itoa/ converts the long integer <tt/val/ into a string
3075 using <tt/radix/ as the base.
3076 <tag/Limits/<itemize>
3077 <item>There are no provisions to prevent a buffer overflow.
3078 <item>If <tt/val/ contains <tt/LONG_MIN/, the behaviour is undefined.
3079 <item>The function is non standard, so it is not available in strict ANSI mode.
3080 You should probably use <tt/sprintf/ instead.
3081 <item>The function is only available as fastcall function, so it may only be
3082 used in presence of a prototype.
3084 <tag/Availability/cc65
3086 <ref id="atoi" name="atoi">,
3087 <ref id="atol" name="atol">,
3088 <ref id="itoa" name="itoa">,
3089 <ref id="ultoa" name="ultoa">,
3090 <ref id="utoa" name="utoa">
3096 <sect1>localeconv<label id="localeconv"><p>
3100 <tag/Function/Returns a pointer to the current locale structure.
3101 <tag/Header/<tt/<ref id="locale.h" name="locale.h">/
3102 <tag/Declaration/<tt/struct lconv* localeconv (void);/
3103 <tag/Description/<tt/localeconv/ returns a pointer to the current locale
3105 <tag/Limits/<itemize>
3106 <item>cc65 supports only the "C" locale, so even after setting a new locale
3107 using <tt/<ref id="setlocale" name="setlocale">/, the structure returned will
3110 <tag/Availability/ISO 9899
3112 <ref id="setlocale" name="setlocale">
3118 <sect1>longjmp<label id="longjmp"><p>
3122 <tag/Function/Non local goto.
3123 <tag/Header/<tt/<ref id="setjmp.h" name="setjmp.h">/
3124 <tag/Declaration/<tt/void __fastcall__ longjmp (jmp_buf buf, int retval);/
3125 <tag/Description/The <tt/longjmp/ function restores a program context from the
3126 data in <tt/buf/, which must have been set by a preceeding call to
3127 <tt/<ref id="setjmp" name="setjmp">/. Program execution continues as if the
3128 call to <tt/<ref id="setjmp" name="setjmp">/ has just returned the value
3132 <item>If the parameter <tt/retval/ is zero, the function will behave as if it
3133 was called with a value of one.
3134 <item>The function is only available as fastcall function, so it may only
3135 be used in presence of a prototype.
3137 <tag/Availability/ISO 9899
3139 <ref id="setjmp" name="setjmp">
3145 <sect1>malloc<label id="malloc"><p>
3149 <tag/Function/Allocate dynamic memory.
3150 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
3151 <tag/Declaration/<tt/void* __fastcall__ malloc (size_t size);/
3152 <tag/Description/<tt/malloc/ allocates size bytes on the heap and returns a
3153 pointer to the allocated memory block. On error (not enough memory available),
3154 <tt/malloc/ returns <tt/NULL/.
3157 <item>The function is only available as fastcall function, so it may only
3158 be used in presence of a prototype.
3160 <tag/Availability/ISO 9899
3162 <ref id="_heapadd" name="_heapadd">,
3163 <ref id="_heapblocksize" name="_heapblocksize">,
3164 <ref id="_heapmaxavail" name="_heapmaxavail">,
3165 <ref id="_heapmemavail" name="_heapmemavail">,
3166 <ref id="calloc" name="calloc">,
3167 <ref id="free" name="free">,
3168 <ref id="realloc" name="realloc">,
3169 <ref id="strdup" name="strdup">
3175 <sect1>memchr<label id="memchr"><p>
3179 <tag/Function/Search for a character in a block of raw memory.
3180 <tag/Header/<tt/<ref id="string.h" name="string.h">/
3181 <tag/Declaration/<tt/void* __fastcall__ strchr (const void* mem, int c, size_t count);/
3182 <tag/Description/The <tt/memchr/ function locates the first occurrence of <tt/c/
3183 (converted to a char) in the block of raw memory string pointed to by <tt/mem/
3184 that is of size <tt/count/. Upon completion, the function returns a pointer to
3185 the character found, or a null pointer if the character was not found.
3186 <tag/Limits/<itemize>
3187 <item>The function is only available as fastcall function, so it may only
3188 be used in presence of a prototype.
3190 <tag/Availability/ISO 9899
3192 <ref id="strchr" name="strchr">
3198 <sect1>memcpy<label id="memcpy"><p>
3202 <tag/Function/Copy a memory area.
3203 <tag/Header/<tt/<ref id="string.h" name="string.h">/
3204 <tag/Declaration/<tt/void* __fastcall__ memcpy (void* dest, const void* src, size_t count);/
3205 <tag/Description/<tt/memcpy/ copies <tt/count/ bytes from the memory area
3206 pointed to by <tt/src/ into the memory area pointed to by <tt/dest/. It returns
3210 <item>The result is undefined if the memory areas do overlap. Use
3211 <tt/<ref id="memmove" name="memmove">/ to copy overlapping memory areas.
3212 <item>The function is only available as fastcall function, so it may only
3213 be used in presence of a prototype.
3215 <tag/Availability/ISO 9899
3217 <ref id="_swap" name="_swap">,
3218 <ref id="memmove" name="memmove">,
3219 <ref id="memset" name="memset">
3225 <sect1>memmove<label id="memmove"><p>
3229 <tag/Function/Copy a memory area.
3230 <tag/Header/<tt/<ref id="string.h" name="string.h">/
3231 <tag/Declaration/<tt/void* __fastcall__ memmove (void* dest, const void* src, size_t count);/
3232 <tag/Description/<tt/memmove/ copies <tt/count/ bytes from the memory area
3233 pointed to by <tt/src/ into the memory area pointed to by <tt/dest/. It returns
3237 <item>While <tt/memmove/ allows the memory areas to overlap, it has some
3238 additional overhead compared to <tt/<ref id="memcpy" name="memcpy">/.
3239 <item>The function is only available as fastcall function, so it may only
3240 be used in presence of a prototype.
3242 <tag/Availability/ISO 9899
3244 <ref id="_swap" name="_swap">,
3245 <ref id="memcpy" name="memcpy">,
3246 <ref id="memset" name="memset">
3252 <sect1>memset<label id="memset"><p>
3256 <tag/Function/Fill a memory area.
3257 <tag/Header/<tt/<ref id="string.h" name="string.h">/
3258 <tag/Declaration/<tt/void* __fastcall__ memset (void* p, int val, size_t count);/
3259 <tag/Description/<tt/memset/ fills the memory area pointed to by <tt/p/ with
3260 the value <tt/val/. The function returns <tt/p/.
3263 <item>The function is only available as fastcall function, so it may only
3264 be used in presence of a prototype.
3266 <tag/Availability/ISO 9899
3268 <ref id="_swap" name="_swap">,
3269 <ref id="bzero" name="bzero">,
3270 <ref id="memcpy" name="memcpy">,
3271 <ref id="memmove" name="memmove">
3277 <sect1>mod_free<label id="mod_free"><p>
3281 <tag/Function/Free a relocatable module.
3282 <tag/Header/<tt/<ref id="modload.h" name="modload.h">/
3283 <tag/Declaration/<tt/void __fastcall__ mod_free (void* module);/
3284 <tag/Description/The function will free a module loaded into memory by use of
3285 the <tt/<ref id="mod_load" name="mod_load">/ function.
3286 <tag/Limits/<itemize>
3287 <item>The pointer passed as parameter is the pointer to the module memory,
3288 not the pointer to the control structure.
3290 <tag/Availability/cc65
3292 <ref id="mod_load" name="mod_load">
3298 <sect1>mod_load<label id="mod_load"><p>
3302 <tag/Function/Load a relocatable module.
3303 <tag/Header/<tt/<ref id="modload.h" name="modload.h">/
3304 <tag/Declaration/<tt/unsigned char mod_load (struct mod_ctrl* ctrl);/
3305 <tag/Description/The function will load a code module into memory and relocate
3306 it. The function will return an error code. If <tt/MLOAD_OK/ is returned, the
3307 outgoing fields in the passed <tt/mod_ctrl/ struct contain information about
3308 the module just loaded. Possible error codes are:
3310 <item><tt/MLOAD_OK/ - Module load successful
3311 <item><tt/MLOAD_ERR_READ/ - Read error
3312 <item><tt/MLOAD_ERR_HDR/ - Header error
3313 <item><tt/MLOAD_ERR_OS/ - Wrong operating system
3314 <item><tt/MLOAD_ERR_FMT/ - Data format error
3315 <item><tt/MLOAD_ERR_MEM/ - Not enough memory
3317 <tag/Limits/<itemize>
3318 <item>The <htmlurl url="ld65.html" name="ld65"> linker is needed to create
3319 relocatable o65 modules for use with this function.
3321 <tag/Availability/cc65
3323 <ref id="mod_free" name="mod_free">
3329 <sect1>mouse_setbox<label id="mouse_setbox"><p>
3333 <tag/Function/Specify a bounding box for the mouse cursor.
3334 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3335 <tag/Declaration/<tt/void __fastcall__ mouse_setbox (const struct mouse_box* box);/
3336 <tag/Description/The function allows to set a bounding box for mouse movement.
3337 <tag/Limits/<itemize>
3338 <item>The function does not check if the mouse cursor is currently within the
3339 given rectangle. Placing the mouse cursor within the bounding box is the
3340 responsibility of the programmer.
3341 <item>While the bounding box may be larger than the actual screen size, the
3342 standard mouse cursor draw routines may fail to set the cursor to coordinates
3343 outside of the screen area. Depending on the platform, you may have to supply
3344 your own mouse cursor routines.
3345 <item>The function is only available as fastcall function, so it may only be
3346 used in presence of a prototype.
3348 <tag/Availability/cc65
3350 <ref id="mouse_getbox" name="mouse_getbox">,
3351 <ref id="mouse_move" name="mouse_move">
3357 <sect1>mouse_getbox<label id="mouse_getbox"><p>
3361 <tag/Function/Return the current bounding box for the mouse cursor.
3362 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3363 <tag/Declaration/<tt/void __fastcall__ mouse_getbox (struct mouse_box* box);/
3364 <tag/Description/The function queries the current bounding box for mouse
3366 <tag/Limits/<itemize>
3367 <item>The function is only available as fastcall function, so it may only be
3368 used in presence of a prototype.
3370 <tag/Availability/cc65
3372 <ref id="mouse_move" name="mouse_move">,
3373 <ref id="mouse_setbox" name="mouse_setbox">
3379 <sect1>mouse_buttons<label id="mouse_buttons"><p>
3383 <tag/Function/Return a bit mask encoding the state of the mouse buttons.
3384 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3385 <tag/Declaration/<tt/unsigned char __fastcall__ mouse_buttons (void);/
3386 <tag/Description/The function returns a bit mask that encodes the state of the
3387 mouse buttons. You may use the <tt/MOUSE_BTN_XXX/ flags to decode the function
3389 <tag/Limits/<itemize>
3390 <item>The function is only available as fastcall function, so it may only be
3391 used in presence of a prototype.
3393 <tag/Availability/cc65
3395 <ref id="mouse_info" name="mouse_info">,
3396 <ref id="mouse_pos" name="mouse_pos">
3402 <sect1>mouse_geterrormsg<label id="mouse_geterrormsg"><p>
3406 <tag/Function/Return a readable error message for an error code.
3407 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3408 <tag/Declaration/<tt/const char* __fastcall__ mouse_geterrormsg (unsigned char
3410 <tag/Description/The function returns an error message (in english) for the
3411 error code passed parameter.
3412 <tag/Limits/<itemize>
3413 <item>The function will return "Unknown error" for invalid error codes.
3414 <item>The function is only available as fastcall function, so it may only be
3415 used in presence of a prototype.
3417 <tag/Availability/cc65
3419 <ref id="mouse_load_driver" name="mouse_load_driver">,
3420 <ref id="mouse_uninstall" name="mouse_uninstall">,
3421 <ref id="mouse_unload" name="mouse_unload">
3427 <sect1>mouse_hide<label id="mouse_hide"><p>
3431 <tag/Function/Hide the mouse pointer.
3432 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3433 <tag/Declaration/<tt/void __fastcall__ mouse_hide (void);/
3434 <tag/Description/The function hides the mouse pointer. It manages a counter
3435 that is shared between <tt/<ref id="mouse_show" name="mouse_show">/ and
3436 <tt/mouse_hide/ so that every call call to <tt/mouse_hide/ must be followed by
3437 a call to <tt/<ref id="mouse_show" name="mouse_show">/ to make the mouse cursor
3439 <tag/Limits/<itemize>
3440 <item>The function is only available as fastcall function, so it may only be
3441 used in presence of a prototype.
3443 <tag/Availability/cc65
3445 <ref id="mouse_show" name="mouse_show">
3451 <sect1>mouse_info<label id="mouse_info"><p>
3455 <tag/Function/Return the state of the mouse buttons and the position of the
3457 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3458 <tag/Declaration/<tt/void __fastcall__ mouse_info (struct mouse_info* info);/
3459 <tag/Description/The function returns the state of the mouse buttons and the
3460 position of the mouse in the <tt/mouse_info/ structure passed as parameter.
3461 <tag/Limits/<itemize>
3462 <item>The <tt/mouse_info/ struct is a superset of the <tt/mouse_pos/ struct,
3463 so if you just need the mouse position, call <tt/<ref id="mouse_pos"
3464 name="mouse_pos">/ instead.
3465 <item>The function is only available as fastcall function, so it may only be
3466 used in presence of a prototype.
3468 <tag/Availability/cc65
3470 <ref id="mouse_buttons" name="mouse_buttons">,
3471 <ref id="mouse_pos" name="mouse_pos">
3477 <sect1>mouse_install<label id="mouse_install"><p>
3481 <tag/Function/Install an already loaded mouse driver.
3482 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3483 <tag/Declaration/<tt/unsigned char __fastcall__ mouse_install (const struct
3484 mouse_callbacks* c, void* driver);/
3485 <tag/Description/The function installs an already loaded mouse driver and
3486 returns an error code. The <tt/mouse_callbacks/ structure passed as first
3487 parameter contains pointers to routines needed to move or hide/show the mouse
3488 pointer. Defaults for these routines are supplied by the library, so if you
3489 can live with these defaults (which are platform specific), just pass a
3490 pointer to <tt/mouse_def_callbacks/. The function may be used to install a
3491 driver linked statically to the program.
3492 <tag/Limits/<itemize>
3493 <item>Not all drivers are able to detect if the supported hardware is really
3495 <item>After installing a driver, the mouse cursor is hidden.
3496 <item>The function is only available as fastcall function, so it may only be
3497 used in presence of a prototype.
3499 <tag/Availability/cc65
3501 <ref id="mouse_load_driver" name="mouse_load_driver">,
3502 <ref id="mouse_uninstall" name="mouse_uninstall">,
3503 <ref id="mouse_unload" name="mouse_unload">
3509 <sect1>mouse_ioctl<label id="mouse_ioctl"><p>
3513 <tag/Function/Call the driver specific ioctl function.
3514 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3515 <tag/Declaration/<tt/unsigned char __fastcall__ mouse_ioctl (unsigned char code, void* data);/
3516 <tag/Description/The function calls the IOCTL entry in the mouse driver,
3517 which is driver specific. The <tt/code/ parameter will choose between
3518 different IOCTL functions, and the <tt/data/ depends on code. The
3519 function returns an error code. The purpose of this function is to allow
3520 for driver specific extensions. See the documentation for a specific mouse
3521 driver for supported ioctl calls.
3522 <tag/Limits/<itemize>
3523 <item>Calling this function is non portable, because each driver may
3524 implement different ioctl calls (or none at all).
3525 <item>The function is only available as fastcall function, so it may only be
3526 used in presence of a prototype.
3528 <tag/Availability/cc65
3534 <sect1>mouse_load_driver<label id="mouse_load_driver"><p>
3538 <tag/Function/Load and initialize a mouse driver.
3539 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3540 <tag/Declaration/<tt/unsigned char __fastcall__ mouse_load_driver (const struct
3541 mouse_callbacks* c, const char* driver);/
3542 <tag/Description/Load a mouse driver into memory and initialize it. The
3543 function returns an error code that tells if the call has been successful. The
3544 <tt/mouse_callbacks/ structure passed as first parameter contains pointers to
3545 routines needed to move or hide/show the mouse pointer. Defaults for these
3546 routines are supplied by the library, so if you can live with these defaults
3547 (which are platform specific), just pass a pointer to <tt/mouse_def_callbacks/.
3548 <tag/Limits/<itemize>
3549 <item>The driver is loaded by name, so currently you must know the type of
3550 mouse that should be supported. There is no autodetect capability.
3551 <item>Not all drivers are able to detect if the supported hardware is really
3553 <item>After installing a driver, the mouse cursor is hidden.
3554 <item>The function is only available as fastcall function, so it may only be
3555 used in presence of a prototype.
3557 <tag/Availability/cc65
3559 <ref id="mouse_install" name="mouse_install">,
3560 <ref id="mouse_uninstall" name="mouse_uninstall">,
3561 <ref id="mouse_unload" name="mouse_unload">
3567 <sect1>mouse_move<label id="mouse_move"><p>
3571 <tag/Function/Move the mouse cursor to a specific position.
3572 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3573 <tag/Declaration/<tt/void __fastcall__ mouse_move (int x, int y);/
3574 <tag/Description/The function updates the mouse position. If the mouse cursor
3575 is visible, it is shown at the new position.
3576 <tag/Limits/<itemize>
3577 <item>The function does not check if the new position is within the bounding
3578 box specified with <tt/<ref id="mouse_setbox" name="mouse_setbox">/.
3579 <item>The function is only available as fastcall function, so it may only be
3580 used in presence of a prototype.
3582 <tag/Availability/cc65
3584 <ref id="mouse_getbox" name="mouse_getbox">,
3585 <ref id="mouse_setbox" name="mouse_setbox">
3591 <sect1>mouse_pos<label id="mouse_pos"><p>
3595 <tag/Function/Return the position of the mouse.
3596 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3597 <tag/Declaration/<tt/void __fastcall__ mouse_pos (struct mouse_pos* pos);/
3598 <tag/Description/The function returns the position of the mouse in the
3599 <tt/mouse_pos/ structure passed as parameter.
3600 <tag/Limits/<itemize>
3601 <item>The <tt/mouse_pos/ struct is a subset of the <tt/mouse_info/ struct,
3602 so if you do also need the mouse buttons, call <tt/<ref id="mouse_info"
3603 name="mouse_info">/ instead.
3604 <item>The function is only available as fastcall function, so it may only be
3605 used in presence of a prototype.
3607 <tag/Availability/cc65
3609 <ref id="mouse_buttons" name="mouse_buttons">,
3610 <ref id="mouse_info" name="mouse_info">
3616 <sect1>mouse_show<label id="mouse_show"><p>
3620 <tag/Function/Show the mouse pointer.
3621 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3622 <tag/Declaration/<tt/void __fastcall__ mouse_show (void);/
3623 <tag/Description/The function shows the mouse pointer. It manages a counter
3624 that is shared between <tt/<ref id="mouse_hide" name="mouse_hide">/ and
3625 <tt/mouse_show/. The mouse cursor is visible if there was one more call to
3626 <tt/mouse_show/ than to <tt/<ref id="mouse_hide" name="mouse_hide">/.
3627 <tag/Limits/<itemize>
3628 <item>The function is only available as fastcall function, so it may only be
3629 used in presence of a prototype.
3631 <tag/Availability/cc65
3633 <ref id="mouse_hide" name="mouse_hide">
3639 <sect1>mouse_uninstall<label id="mouse_uninstall"><p>
3643 <tag/Function/Uninstall an already loaded mouse driver.
3644 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3645 <tag/Declaration/<tt/unsigned char __fastcall__ mouse_install (void);/
3646 <tag/Description/The function uninstalls an already loaded mouse driver but
3647 don't removes it from memory.
3648 <tag/Limits/<itemize>
3649 <item>If the driver has been loaded using <tt/<ref id="mouse_load_driver"
3650 name="mouse_load_driver">/, <tt/<ref id="mouse_unload" name="mouse_unload">/
3651 should be used instead of <tt/mouse_uninstall/ so the driver is also removed
3653 <item>The function is only available as fastcall function, so it may only be
3654 used in presence of a prototype.
3656 <tag/Availability/cc65
3658 <ref id="mouse_install" name="mouse_install">,
3659 <ref id="mouse_load_driver" name="mouse_load_driver">,
3660 <ref id="mouse_unload" name="mouse_unload">
3666 <sect1>mouse_unload<label id="mouse_unload"><p>
3670 <tag/Function/Unload a mouse driver.
3671 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3672 <tag/Declaration/<tt/unsigned char __fastcall__ mouse_unload (void);/
3673 <tag/Description/The function unloads a loaded mouse driver and frees all
3674 memory allocated for the driver.
3675 <tag/Limits/<itemize>
3676 <item>The function does nothing if no driver is loaded.
3678 <tag/Availability/cc65
3680 <ref id="mouse_install" name="mouse_install">,
3681 <ref id="mouse_load_driver" name="mouse_load_driver">,
3682 <ref id="mouse_uninstall" name="mouse_uninstall">
3688 <sect1>offsetof<label id="offsetof"><p>
3692 <tag/Function/Calculate the offset of a struct or union member.
3693 <tag/Header/<tt/<ref id="stddef.h" name="stddef.h">/
3694 <tag/Declaration/<tt/size_t offsetof (type, member);/
3695 <tag/Description/<tt/offsetof/ calculates the address offset of a <tt/struct/
3696 or <tt/union/ member.
3697 <tag/Limits/<itemize>
3698 <item>The function is actually a macro.
3700 <tag/Availability/ISO 9899
3706 <sect1>open<label id="open"><p>
3710 <tag/Function/Open and possibly create a file.
3711 <tag/Header/<tt/<ref id="fcntl.h" name="fcntl.h">/
3712 <tag/Declaration/<tt/int open (const char* name, int flags, ...);/
3713 <tag/Description/<tt/open/ opens a file and returns the file descriptor
3714 associated with it. On error, -1 is returned and an error code is stored in
3715 <tt/errno/. Several flags may be passed to <tt/open/ that change the behaviour.
3716 <tag/Limits/<itemize>
3717 <item>POSIX specifies an additional <tt/mode/ argument that may be passed to
3718 open, which is used as the permission mask when a new file is created. While
3719 cc65 allows to pass this argument, it is ignored.
3721 <tag/Availability/POSIX 1003.1
3723 <ref id="close" name="close">,
3724 <ref id="creat" name="creat">
3730 <sect1>peekbsys<label id="peekbsys"><p>
3734 <tag/Function/Read one byte from a location in the system bank.
3735 <tag/Header/<tt/<ref id="cbm610.h" name="cbm610.h">/,
3736 <tt/<ref id="cbm510.h" name="cbm510.h">/
3737 <tag/Declaration/<tt/unsigned char __fastcall__ peekbsys (unsigned addr);/
3738 <tag/Description/<tt/peekbsys/ reads one byte from the given address in the
3739 system bank (bank 15) of the CBM PET-II machines and returns it.
3742 <item>The function is only available as fastcall function, so it may only
3743 be used in presence of a prototype.
3744 <item>This function may be a macro depending on the compiler options. The
3745 actual function is accessible by #undef'ing the macro.
3747 <tag/Availability/cc65
3749 <ref id="PEEK" name="PEEK">,
3750 <ref id="PEEKW" name="PEEKW">,
3751 <ref id="peekwsys" name="peekwsys">,
3752 <ref id="pokebsys" name="pokebsys">,
3753 <ref id="pokewsys" name="pokewsys">
3759 <sect1>peekwsys<label id="peekwsys"><p>
3763 <tag/Function/Read one word from a location in the system bank.
3764 <tag/Header/<tt/<ref id="cbm610.h" name="cbm610.h">/,
3765 <tt/<ref id="cbm510.h" name="cbm510.h">/
3766 <tag/Declaration/<tt/unsigned __fastcall__ peekwsys (unsigned addr);/
3767 <tag/Description/<tt/peekwsys/ reads one word from the given address in the
3768 system bank (bank 15) of the CBM PET-II machines and returns it. Following
3769 the usual 6502 conventions, the low byte is read from <tt/addr/, and the
3770 high byte is read from <tt/addr+1/.
3773 <item>The function is only available as fastcall function, so it may only
3774 be used in presence of a prototype.
3775 <item>The order in which the two bytes are read is undefined.
3777 <tag/Availability/cc65
3779 <ref id="PEEK" name="PEEK">,
3780 <ref id="PEEKW" name="PEEKW">,
3781 <ref id="peekbsys" name="peekbsys">,
3782 <ref id="pokebsys" name="pokebsys">,
3783 <ref id="pokewsys" name="pokewsys">
3789 <sect1>perror<label id="perror"><p>
3793 <tag/Function/Print an error message for the error in <tt/errno/.
3794 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
3795 <tag/Declaration/<tt/void __fastcall__ perror (const char* s);/
3796 <tag/Description/<tt/perror/ prints an error message to <tt/stderr/. If <tt/s/
3797 is not <tt/NULL/ and not an empty string, it is printed followed by a colon and
3798 a blank. Then the error message for the current contents of <tt/errno/ is
3799 printed followed by a newline. The message output is the same as returned by
3800 <tt/<ref id="strerror" name="strerror">/ with an argument of <tt/errno/.
3803 <item>The function is only available as fastcall function, so it may only
3804 be used in presence of a prototype.
3806 <tag/Availability/ISO 9899
3808 <ref id="_poserror" name="_poserror">,
3809 <ref id="strerror" name="strerror">
3815 <sect1>pokebsys<label id="pokebsys"><p>
3819 <tag/Function/Write one byte to a location in the system bank.
3820 <tag/Header/<tt/<ref id="cbm610.h" name="cbm610.h">/,
3821 <tt/<ref id="cbm510.h" name="cbm510.h">/
3822 <tag/Declaration/<tt/void __fastcall__ pokebsys (unsigned addr, unsigned char val);/
3823 <tag/Description/<tt/pokebsys/ writes one byte to the given address in the
3824 system bank (bank 15) of the CBM PET-II machines.
3827 <item>The function is only available as fastcall function, so it may only
3828 be used in presence of a prototype.
3830 <tag/Availability/cc65
3832 <ref id="POKE" name="POKE">,
3833 <ref id="POKEW" name="POKEW">,
3834 <ref id="peekbsys" name="peekbsys">,
3835 <ref id="peekwsys" name="peekwsys">,
3836 <ref id="pokewsys" name="pokewsys">
3842 <sect1>pokewsys<label id="pokewsys"><p>
3846 <tag/Function/Write one word to a location in the system bank.
3847 <tag/Header/<tt/<ref id="cbm610.h" name="cbm610.h">/,
3848 <tt/<ref id="cbm510.h" name="cbm510.h">/
3849 <tag/Declaration/<tt/void __fastcall__ pokewsys (unsigned addr, unsigned val);/
3850 <tag/Description/<tt/pokewsys/ writes one word to the given address in the
3851 system bank (bank 15) of the CBM PET-II machines. Following the usual 6502
3852 conventions, the low byte of <tt/val/ is written to <tt/addr/, and the
3853 high byte is written to <tt/addr+1/.
3856 <item>The function is only available as fastcall function, so it may only
3857 be used in presence of a prototype.
3858 <item>The order in which the two bytes are written is undefined.
3860 <tag/Availability/cc65
3862 <ref id="POKE" name="POKE">,
3863 <ref id="POKEW" name="POKEW">,
3864 <ref id="peekbsys" name="peekbsys">,
3865 <ref id="peekwsys" name="peekwsys">,
3866 <ref id="pokebsys" name="pokebsys">
3872 <sect1>qsort<label id="qsort"><p>
3876 <tag/Function/Sort an array.
3877 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
3878 <tag/Declaration/<tt/void __fastcall__ qsort (void* base, size_t count,
3879 size_t size, int (*compare) (const void*, const void*));/
3880 <tag/Description/<tt/qsort/ sorts an array according to a given compare
3881 function <tt/compare/. <tt/base/ is the address of the array, <tt/count/
3882 is the number of elements, <tt/size/ the size of an element and <tt/compare/
3883 the function used to compare the members.
3886 <item>If there are multiple members with the same key, the order after calling
3887 the function is undefined.
3888 <item>The function is only available as fastcall function, so it may only
3889 be used in presence of a prototype.
3891 <tag/Availability/ISO 9899
3893 <ref id="bsearch" name="bsearch">
3899 <sect1>raise<label id="raise"><p>
3903 <tag/Function/Send a signal to the executing program.
3904 <tag/Header/<tt/<ref id="signal.h" name="signal.h">/
3905 <tag/Declaration/<tt/int __fastcall__ raise (int sig);/
3906 <tag/Description/<tt/raise/ sends the given signal to the program. If the
3907 program has installed a signal handler for the signal, this signal handler
3908 will be executed. If no handler has been installed, the default action for
3909 the raised signal will be taken. The function returns zero on success,
3911 <tag/Limits/<itemize>
3912 <item>The function is only available as fastcall function, so it may only
3913 be used in presence of a prototype.
3915 <tag/Availability/ISO 9899
3917 <ref id="abort" name="abort">,
3918 <ref id="signal" name="signal">
3924 <sect1>rand<label id="rand"><p>
3928 <tag/Function/Return a pseudo random number.
3929 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
3930 <tag/Declaration/<tt/int rand (void);/
3931 <tag/Description/The function returns a pseudo random number
3932 between 0 and <tt/RAND_MAX/ (exclusive).
3933 <tag/Limits/<itemize>
3934 <item>Without using <tt><ref id="srand" name="srand"></tt>, always the same
3935 flow of numbers is generated.
3936 <item>On startup, the function behaves as if <ref id="srand" name="srand">
3937 had been used with an argument of 1.
3939 <tag/Availability/ISO 9899
3941 <ref id="_randomize" name="_randomize">,
3942 <ref id="srand" name="srand">
3948 <sect1>realloc<label id="realloc"><p>
3952 <tag/Function/Change the size of an allocated memory block.
3953 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
3954 <tag/Declaration/<tt/void* __fastcall__ realloc (void* block, size_t size);/
3955 <tag/Description/<tt/realloc/ changes the size of the memory block pointed to
3956 by <tt/block/ to <tt/size/ bytes. If <tt/block/ is <tt/NULL/, <tt/realloc/
3957 behaves as if <tt/malloc/ had been called. If <tt/size/ is zero, <tt/realloc/
3958 behaves as if <tt/free/ had been called. On error (not enough memory
3959 available), <tt/realloc/ returns <tt/NULL/.
3962 <item>The part of the memory block that is returned will have its contents
3964 <item>This function is somewhat dangerous to use. Be careful to save the
3965 pointer you're passing somewhere else, otherwise
3967 ptr = realloc (ptr, size);
3969 will loose your only copy of <tt/ptr/ if <tt/realloc/ returns <tt/NULL/.
3970 <item>The function is only available as fastcall function, so it may only
3971 be used in presence of a prototype.
3973 <tag/Availability/ISO 9899
3975 <ref id="_heapadd" name="_heapadd">,
3976 <ref id="_heapblocksize" name="_heapblocksize">,
3977 <ref id="_heapmaxavail" name="_heapmaxavail">,
3978 <ref id="_heapmemavail" name="_heapmemavail">,
3979 <ref id="calloc" name="calloc">,
3980 <ref id="free" name="free">,
3981 <ref id="realloc" name="realloc">
3987 <sect1>remove<label id="remove"><p>
3991 <tag/Function/Delete a file.
3992 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
3993 <tag/Declaration/<tt/int __fastcall__ remove (const char* name);/
3994 <tag/Description/<tt/remove/ deletes the file with the given name. On success,
3995 zero is returned. On error, -1 is returned and <tt/errno/ is set to an error
3996 code describing the reason for the failure.
3999 <item>This function is not available on all cc65 targets (depends on the
4000 availability of file I/O).
4001 <item>The function is only available as fastcall function, so it may only
4002 be used in presence of a prototype.
4004 <tag/Availability/ISO 9899
4006 <ref id="rename" name="rename">,
4007 <ref id="unlink" name="unlink">
4010 #include <stdio.h>
4012 #define FILENAME "helloworld"
4014 if (remove (FILENAME) == 0) {
4015 printf ("We deleted %s successfully\n", FILENAME);
4017 printf ("There was a problem deleting %s\n", FILENAME);
4024 <sect1>rename<label id="rename"><p>
4028 <tag/Function/Rename a file.
4029 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
4030 <tag/Declaration/<tt/int __fastcall__ rename (const char* oldname, const char* newname);/
4031 <tag/Description/<tt/rename/ renames a file (gives it a new name). On success,
4032 zero is returned. On error, -1 is returned and <tt/errno/ is set to an error
4033 code describing the reason for the failure.
4036 <item>This function is not available on all cc65 targets (depends on the
4037 capabilities of the storage devices).
4038 <item>The function is only available as fastcall function, so it may only
4039 be used in presence of a prototype.
4041 <tag/Availability/ISO 9899
4043 <ref id="remove" name="remove">
4046 #include <stdio.h>
4048 #define OLDNAME "textfile.txt"
4049 #define NEWNAME "textfile.bak"
4051 if (rename (OLDNAME, NEWNAME) == 0) {
4052 printf ("Renamed %s to %s\n", OLDNAME, NEWNAME);
4054 printf ("Error renaming %s to %s\n", OLDNAME, NEWNAME);
4061 <sect1>reset_brk<label id="reset_brk"><p>
4065 <tag/Function/Resets the break vector to its original value.
4066 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
4067 <tag/Declaration/<tt/void __fastcall__ reset_brk (void);/
4068 <tag/Description/<tt/reset_brk/ resets the break vector to the value it had
4069 before a call to <tt/set_brk/.
4072 <item>Since <tt/<ref id="set_brk" name="set_brk">/ installs an exit handler,
4073 it is not strictly necessary to call this function as part of the cleanup when
4076 <tag/Availability/cc65
4078 <ref id="set_brk" name="set_brk">
4084 <sect1>revers<label id="revers"><p>
4088 <tag/Function/Control revers character display.
4089 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
4090 <tag/Declaration/<tt/unsigned char __fastcall__ revers (unsigned char onoff);/
4091 <tag/Description/If the argument is non zero, the function enables reverse
4092 character display. If the argument is zero, reverse character display is
4093 switched off. The old value of the setting is returned.
4094 <tag/Limits/<itemize>
4095 <item>The function may not be supported by the hardware, in which case
4096 the call is ignored.
4097 <item>The function is only available as fastcall function, so it may only
4098 be used in presence of a prototype.
4100 <tag/Availability/cc65
4102 <ref id="textcolor" name="textcolor">
4108 <sect1>screensize<label id="screensize"><p>
4112 <tag/Function/Return the dimensions of the text mode screen.
4113 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
4114 <tag/Declaration/<tt/void __fastcall__ screensize (unsigned char* x, unsigned char* y);/
4115 <tag/Description/The function returns the dimensions of the text mode screen.
4116 <tag/Limits/<itemize>
4117 <item>The function is only available as fastcall function, so it may only
4118 be used in presence of a prototype.
4120 <tag/Availability/cc65
4122 <ref id="gotox" name="gotox">,
4123 <ref id="gotoxy" name="gotoxy">,
4124 <ref id="gotoy" name="gotoy">,
4125 <ref id="wherex" name="wherex">,
4126 <ref id="wherey" name="wherey">
4132 <sect1>set_brk<label id="set_brk"><p>
4136 <tag/Function/Set the break vector to a user function.
4137 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
4138 <tag/Declaration/<tt/void __fastcall__ set_brk (brk_handler func);/
4139 <tag/Description/<tt/set_brk/ allows a user program to handle breaks within the
4140 program code by letting the vector point to a user written C function. The
4141 runtime library installs a small stub that saves the registers into global
4142 variables that may be accessed (and changed) by the break handler.
4145 <item>The function is only available as fastcall function, so it may only
4146 be used in presence of a prototype.
4147 <item>The stub saves the zero page registers used by the C runtime and switches
4148 to a small break handler stack. This means that it is safe to execute C code,
4149 even if C code was interrupted. Be careful however not to use too many local
4150 variables, and do not enable stack checks for the handler function or any other
4151 function called from it.
4152 <item>The <tt/brk_pc/ variable points to the <tt/BRK/ instruction. If you want
4153 the continue with the interrupted code, you have to adjust <tt/brk_pc/,
4154 otherwise the <tt/BRK/ instruction will get executed over and over again.
4155 <item>Since <tt/set_brk/ installs an exit handler, it is not strictly necessary
4156 to call <tt/<ref id="reset_brk" name="reset_brk">/ as part of the cleanup when
4157 the program terminates.
4159 <tag/Availability/cc65
4161 <ref id="reset_brk" name="reset_brk">
4167 <sect1>setjmp<label id="setjmp"><p>
4171 <tag/Function/Save the context for use with <tt/longjmp/.
4172 <tag/Header/<tt/<ref id="setjmp.h" name="setjmp.h">/
4173 <tag/Declaration/<tt/int __fastcall__ setjmp (jmp_buf buf);/
4174 <tag/Description/The <tt/setjmp/ function saves the current context in <tt/buf/
4175 for subsequent use by the <tt/<ref id="longjmp" name="longjmp">/ function and
4179 <item>The function is only available as fastcall function, so it may only
4180 be used in presence of a prototype.
4181 <item><tt/setjmp/ is actually a macro as required by the ISO standard.
4182 <item><tt/setjmp/ will not save the signal context.
4184 <tag/Availability/ISO 9899
4186 <ref id="longjmp" name="longjmp">
4192 <sect1>setlocale<label id="setlocale"><p>
4196 <tag/Function/Selects a locale.
4197 <tag/Header/<tt/<ref id="locale.h" name="locale.h">/
4198 <tag/Declaration/<tt/char* __fastcall__ setlocale (int category, const char* locale);/
4199 <tag/Description/<tt/setlocale/ sets or queries the program's locale.
4202 <item>The function is only available as fastcall function, so it may only
4203 be used in presence of a prototype.
4204 <item>cc65 supports only the "C" locale, so calling this function to set a
4205 different locale has no effect.
4207 <tag/Availability/ISO 9899
4209 <ref id="localeconv" name="localeconv">,
4210 <ref id="strcoll" name="strcoll">
4211 <ref id="strxfrm" name="strxfrm">
4217 <sect1>signal<label id="signal"><p>
4221 <tag/Function/Install a signal handler.
4222 <tag/Header/<tt/<ref id="signal.h" name="signal.h">/
4223 <tag/Declaration/<tt/__sigfunc __fastcall__ signal (int sig, __sigfunc func);/
4224 <tag/Description/<tt/signal/ installs a handler for the given signal. The
4225 handler may either be a user supplied function, or one of the predefined
4226 signal handlers <tt/SIG_IGN/ or <tt/SIG_DFL/. The function returns the
4227 previous value if the signal , or the special function vector SIG_ERR in
4229 <tag/Limits/<itemize>
4230 <item>The function is only available as fastcall function, so it may only
4231 be used in presence of a prototype.
4233 <tag/Availability/ISO 9899
4235 <ref id="abort" name="abort">,
4236 <ref id="raise" name="raise">
4242 <sect1>sleep<label id="sleep"><p>
4246 <tag/Function/Sleep for a specified amount of time.
4247 <tag/Header/<tt/<ref id="unistd.h" name="unistd.h">/
4248 <tag/Declaration/<tt/void __fastcall__ sleep (unsigned seconds);/
4249 <tag/Description/The function will return after the specified number of
4250 seconds have elapsed.
4251 <tag/Limits/<itemize>
4252 <item>The function is only available as fastcall function, so it may only
4253 be used in presence of a prototype.
4255 <tag/Availability/POSIX 1003.1
4261 <sect1>slow<label id="slow"><p>
4265 <tag/Function/Switch the C128 into 1MHz mode.
4266 <tag/Header/<tt/<ref id="c128.h" name="c128.h">/
4267 <tag/Declaration/<tt/void slow (void);/
4268 <tag/Description/The function will switch the clock of the C128 to 1MHz. This
4269 will halve the speed compared to fast mode.
4270 <tag/Limits/<itemize>
4271 <item>The function is specific to the C128.
4273 <tag/Availability/C128
4275 <ref id="fast" name="fast">,
4276 <ref id="toggle_videomode" name="toggle_videomode">,
4277 <ref id="videomode" name="videomode">
4283 <sect1>srand<label id="srand"><p>
4287 <tag/Function/Initialize the pseudo random number generator.
4288 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
4289 <tag/Declaration/<tt/void __fastcall__ srand (unsigned seed);/
4290 <tag/Description/The function initializes the random number generator using
4291 the given seed. On program startup, the generator behaves as if <tt/srand/ has
4292 been called with an argument of 1.
4293 <tag/Limits/<itemize>
4294 <item>The function is only available as fastcall function, so it may only
4295 be used in presence of a prototype.
4297 <tag/Availability/ISO 9899
4299 <ref id="_randomize" name="_randomize">,
4300 <ref id="rand" name="rand">
4306 <sect1>strcasecmp<label id="strcasecmp"><p>
4310 <tag/Function/Compare two strings case insensitive.
4311 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4312 <tag/Declaration/<tt/int __fastcall__ strcasecmp (const char* s1, const char* s2);/
4313 <tag/Description/The <tt/strcasecmp/ function compares the two strings passed
4314 as parameters without case sensitivity. It returns a value that is less than
4315 zero if <tt/s1/ is less than <tt/s2/, zero if <tt/s1/ is the same as <tt/s2/,
4316 and a value greater than zero if <tt/s1/ is greater than <tt/s2/.
4317 <tag/Limits/<itemize>
4318 <item>The function is only available as fastcall function, so it may only
4319 be used in presence of a prototype.
4320 <item>The function is not available in strict ANSI mode.
4322 <tag/Availability/cc65
4324 <ref id="strcmp" name="strcmp">,
4325 <ref id="strcoll" name="strcoll">,
4326 <ref id="stricmp" name="stricmp">,
4327 <ref id="strncmp" name="strncmp">
4328 <ref id="strxfrm" name="strxfrm">
4334 <sect1>strcat<label id="strcat"><p>
4338 <tag/Function/Concatentate two strings.
4339 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4340 <tag/Declaration/<tt/char* __fastcall__ strcat (char* s1, const char* s2);/
4341 <tag/Description/The <tt/strcat/ function appends a copy of the string
4342 pointed to by s2 (including the terminating null byte) to the end of the
4343 string pointed to by s1. The initial byte of s2 overwrites the null byte at
4345 <tag/Limits/<itemize>
4346 <item>The function is only available as fastcall function, so it may only
4347 be used in presence of a prototype.
4348 <item>If copying takes place between objects that overlap, the behaviour
4351 <tag/Availability/ISO 9899
4353 <ref id="strcpy" name="strcpy">,
4354 <ref id="strncat" name="strncat">,
4355 <ref id="strncpy" name="strncpy">
4361 <sect1>strchr<label id="strchr"><p>
4365 <tag/Function/Search for a character in a string.
4366 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4367 <tag/Declaration/<tt/char* __fastcall__ strchr (const char* s, int c);/
4368 <tag/Description/The <tt/strchr/ function locates the first occurrence of <tt/c/
4369 (converted to a char) in the string pointed to by <tt/s/. The terminating null
4370 byte is considered to be part of the string. Upon completion, the function
4371 returns a pointer to the byte, or a null pointer if the byte was not found.
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/ISO 9899
4378 <ref id="memchr" name="memchr">,
4379 <ref id="strrchr" name="strrchr">
4385 <sect1>strcmp<label id="strcmp"><p>
4389 <tag/Function/Compare two strings.
4390 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4391 <tag/Declaration/<tt/int __fastcall__ strcmp (const char* s1, const char* s2);/
4392 <tag/Description/The <tt/strcmp/ function compares the two strings passed as
4393 parameters. It returns a value that is less than zero if <tt/s1/ is less than
4394 <tt/s2/, zero if <tt/s1/ is the same as <tt/s2/, and a value greater than zero
4395 if <tt/s1/ is greater than <tt/s2/.
4396 <tag/Limits/<itemize>
4397 <item>The function is only available as fastcall function, so it may only
4398 be used in presence of a prototype.
4400 <tag/Availability/ISO 9899
4402 <ref id="strcasecmp" name="strcasecmp">,
4403 <ref id="strcoll" name="strcoll">,
4404 <ref id="stricmp" name="stricmp">,
4405 <ref id="strncmp" name="strncmp">
4406 <ref id="strxfrm" name="strxfrm">
4412 <sect1>strcoll<label id="strcoll"><p>
4416 <tag/Function/Compare two strings.
4417 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4418 <tag/Declaration/<tt/int __fastcall__ strcoll (const char* s1, const char* s2);/
4419 <tag/Description/The <tt/strcoll/ function compares the two strings passed as
4420 parameters, according to the collating sequence set by <tt/<ref id="setlocale"
4421 name="setlocale">/. It returns a value that is less than zero if <tt/s1/ is
4422 less than <tt/s2/, zero if <tt/s1/ is the same as <tt/s2/, and a value greater
4423 than zero if <tt/s1/ is greater than <tt/s2/.
4424 <tag/Limits/<itemize>
4425 <item>The function is only available as fastcall function, so it may only
4426 be used in presence of a prototype.
4428 <tag/Availability/ISO 9899
4430 <ref id="setlocale" name="setlocale">,
4431 <ref id="strcasecmp" name="strcasecmp">,
4432 <ref id="strcmp" name="strcmp">,
4433 <ref id="stricmp" name="stricmp">,
4434 <ref id="strncmp" name="strncmp">
4435 <ref id="strxfrm" name="strxfrm">
4441 <sect1>strcpy<label id="strcpy"><p>
4445 <tag/Function/Copy a string.
4446 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4447 <tag/Declaration/<tt/char* __fastcall__ strcpy (char* s1, const char* s2);/
4448 <tag/Description/The <tt/strcpy/ function copies the string pointed to by
4449 <tt/s2/ (including the terminating null byte) into the array pointed to by
4450 <tt/s1/. The function will always return <tt/s1/.
4451 <tag/Limits/<itemize>
4452 <item>The function is only available as fastcall function, so it may only
4453 be used in presence of a prototype.
4454 <item>If copying takes place between objects that overlap, the behaviour
4457 <tag/Availability/ISO 9899
4459 <ref id="strcat" name="strcat">,
4460 <ref id="strncat" name="strncat">,
4461 <ref id="strncpy" name="strncpy">
4464 #include <string.h>
4466 static char hello[14];
4468 strcpy (hello, "Hello world!\n");
4474 <sect1>strcspn<label id="strcspn"><p>
4478 <tag/Function/Compute the length of a substring.
4479 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4480 <tag/Declaration/<tt/size_t __fastcall__ strcspn (const char* s, const char* set);/
4481 <tag/Description/The <tt/strcspn/ function computes and returns the length of
4482 the substring pointed to by <tt/s/ which does <em>not</em> consist of
4483 characters contained in the string <tt/set/.
4484 <tag/Limits/<itemize>
4485 <item>The function is only available as fastcall function, so it may only
4486 be used in presence of a prototype.
4488 <tag/Availability/ISO 9899
4490 <ref id="strspn" name="strspn">,
4491 <ref id="strstr" name="strstr">,
4492 <ref id="strtok" name="strtok">
4498 <sect1>strdup<label id="strdup"><p>
4502 <tag/Function/Allocate a copy of a string on the heap.
4503 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4504 <tag/Declaration/<tt/char* __fastcall__ strdup (const char* s);/
4505 <tag/Description/<tt/strdup/ allocates a memory block on the heap, big enough
4506 to hold a copy of <tt/s/ including the terminating zero. If the allocation
4507 fails, <tt/NULL/ is returned, otherwise <tt/s/ is copied into the allocated
4508 memory block, and a pointer to the block is returned.
4509 <tag/Limits/<itemize>
4510 <item>The function is only available as fastcall function, so it may only
4511 be used in presence of a prototype.
4512 <item>It is up to the caller to free the allocated memory block.
4514 <tag/Availability/ISO 9899
4516 <ref id="free" name="free">,
4517 <ref id="malloc" name="malloc">
4523 <sect1>strerror<label id="strerror"><p>
4527 <tag/Function/Return a string describing an error code.
4528 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4529 <tag/Declaration/<tt/char* __fastcall__ strerror (int errcode);/
4530 <tag/Description/The <tt/strerror/ function returns a string describing the
4531 given error code. If an invalid error code is passed, the string "Unknown
4532 error" is returned, and <tt/errno/ is set to <tt/EINVAL/. In all other cases,
4533 <tt/errno/ is left untouched.
4534 <tag/Limits/<itemize>
4535 <item>The function is only available as fastcall function, so it may only
4536 be used in presence of a prototype.
4537 <item>While the return type of the function is a <tt/char*/, the returned
4538 string must not be modified by the caller!
4540 <tag/Availability/ISO 9899
4542 <ref id="_stroserror" name="_stroserror">
4548 <sect1>stricmp<label id="stricmp"><p>
4552 <tag/Function/Compare two strings case insensitive.
4553 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4554 <tag/Declaration/<tt/int __fastcall__ stricmp (const char* s1, const char* s2);/
4555 <tag/Description/The <tt/stricmp/ function compares the two strings passed as
4556 parameters without case sensitivity. It returns a value that is less than zero
4557 if <tt/s1/ is less than <tt/s2/, zero if <tt/s1/ is the same as <tt/s2/, and a
4558 value greater than zero if <tt/s1/ is greater than <tt/s2/.
4559 <tag/Limits/<itemize>
4560 <item>The function is only available as fastcall function, so it may only
4561 be used in presence of a prototype.
4562 <item>The function is not available in strict ANSI mode.
4564 <tag/Availability/cc65
4566 <ref id="strcasecmp" name="strcasecmp">,
4567 <ref id="strcmp" name="strcmp">,
4568 <ref id="strcoll" name="strcoll">,
4569 <ref id="strncmp" name="strncmp">
4570 <ref id="strxfrm" name="strxfrm">
4576 <sect1>strlen<label id="strlen"><p>
4580 <tag/Function/Return the length of a string.
4581 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4582 <tag/Declaration/<tt/size_t __fastcall__ strlen (const char* s);/
4583 <tag/Description/The <tt/strlen/ function computes the number of bytes in the
4584 string to which s points, not including the terminating null byte.
4585 <tag/Limits/<itemize>
4586 <item>The function is only available as fastcall function, so it may only
4587 be used in presence of a prototype.
4588 <item>When compiling with <tt/-Os/ (inline known standard functions), the
4589 function does not work correctly for strings with more than 255 characters.
4591 <tag/Availability/ISO 9899
4593 <ref id="strcpy" name="strcpy">
4599 <sect1>strlower<label id="strlower"><p>
4603 <tag/Function/Make a string lower case.
4604 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4605 <tag/Declaration/<tt/char* __fastcall__ strlower (char* s);/
4606 <tag/Description/The <tt/strlower/ function will apply the <tt/tolower/
4607 function to each character of a string. The function will always return <tt/s/.
4608 <tag/Limits/<itemize>
4609 <item>The function is only available as fastcall function, so it may only
4610 be used in presence of a prototype.
4611 <item>The function prototype is unavailable when compiling in strict ANSI mode.
4612 <item>An alias name for this function is <tt/strlwr/.
4614 <tag/Availability/cc65
4616 <ref id="strupper" name="strupper">,
4617 <ref id="tolower" name="tolower">
4623 <sect1>strlwr<label id="strlwr"><p>
4630 <sect1>strncat<label id="strncat"><p>
4634 <tag/Function/Concatentate two strings.
4635 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4636 <tag/Declaration/<tt/char* __fastcall__ strncat (char* s1, const char* s2, size_t n);/
4637 <tag/Description/The <tt/strncat/ function appends not more than n characters
4638 of the string pointed to by s2 to the end of the string pointed to by s1. The
4639 terminating null character at the end of s1 is overwritten. A terminating null
4640 character is appended to the result, even if not all of s2 is appended to s1.
4641 <tag/Limits/<itemize>
4642 <item>The function is only available as fastcall function, so it may only
4643 be used in presence of a prototype.
4644 <item>If copying takes place between objects that overlap, the behaviour
4647 <tag/Availability/ISO 9899
4649 <ref id="strcpy" name="strcpy">,
4650 <ref id="strncat" name="strncat">,
4651 <ref id="strncpy" name="strncpy">
4657 <sect1>strncmp<label id="strncmp"><p>
4661 <tag/Function/Compare two strings.
4662 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4663 <tag/Declaration/<tt/int __fastcall__ strncmp (const char* s1, const char* s2, size_t count);/
4664 <tag/Description/The <tt/strncmp/ function compares not more than <tt/count/
4665 characters of the two strings passed as parameters. It returns a value that is
4666 less than zero if the first <tt/count/ characters of <tt/s1/ are less than
4667 <tt/s2/, zero if they are identical, and a value greater than zero they are
4669 <tag/Limits/<itemize>
4670 <item>The function is only available as fastcall function, so it may only
4671 be used in presence of a prototype.
4673 <tag/Availability/ISO 9899
4675 <ref id="strcasecmp" name="strcasecmp">,
4676 <ref id="strcmp" name="strcmp">,
4677 <ref id="strcoll" name="strcoll">,
4678 <ref id="stricmp" name="stricmp">
4679 <ref id="strxfrm" name="strxfrm">
4685 <sect1>strncpy<label id="strncpy"><p>
4689 <tag/Function/Copy part of a string.
4690 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4691 <tag/Declaration/<tt/char* __fastcall__ strcpy (char* s1, const char* s2, size_t n);/
4692 <tag/Description/The <tt/strncpy/ function copies not more than n bytes from
4693 the array pointed to by <tt/s2/ to the array pointed to by <tt/s1/. If the array
4694 pointed to by <tt/s2/ is a string that is shorter than n bytes, null bytes are
4695 appended to the copy in the array pointed to by <tt/s1/, until <tt/n/ bytes are
4696 written. The function will always return <tt/s1/.
4697 <tag/Limits/<itemize>
4698 <item>The function is only available as fastcall function, so it may only
4699 be used in presence of a prototype. If there is no null byte in the first <tt/n/
4700 bytes of the array pointed to by <tt/s2/, the result is not null-terminated.
4701 <item>If copying takes place between objects that overlap, the behaviour is
4704 <tag/Availability/ISO 9899
4706 <ref id="strcat" name="strcat">,
4707 <ref id="strcpy" name="strcpy">,
4708 <ref id="strncat" name="strncat">
4713 static char hello[6];
4715 strcpy (hello, "Hello world!\n", sizeof (hello) - 1);
4722 <sect1>strrchr<label id="strrchr"><p>
4726 <tag/Function/Search for a character in a string.
4727 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4728 <tag/Declaration/<tt/char* __fastcall__ strrchr (const char* s, int c);/
4729 <tag/Description/The <tt/strrchr/ function locates the last occurrence of <tt/c/
4730 (converted to a char) in the string pointed to by <tt/s/. The terminating null
4731 byte is considered to be part of the string. Upon completion, the function
4732 returns a pointer to the byte, or a null pointer if the byte was not found.
4733 <tag/Limits/<itemize>
4734 <item>The function is only available as fastcall function, so it may only
4735 be used in presence of a prototype.
4737 <tag/Availability/ISO 9899
4739 <ref id="strchr" name="strchr">
4745 <sect1>strspn<label id="strspn"><p>
4749 <tag/Function/Compute the length of a substring.
4750 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4751 <tag/Declaration/<tt/size_t __fastcall__ strspn (const char* s, const char* set);/
4752 <tag/Description/The <tt/strspn/ function computes and returns the length of
4753 the substring pointed to by <tt/s/ which does consist only of characters
4754 contained in the string <tt/set/.
4755 <tag/Limits/<itemize>
4756 <item>The function is only available as fastcall function, so it may only
4757 be used in presence of a prototype.
4759 <tag/Availability/ISO 9899
4761 <ref id="strcspn" name="strcspn">,
4762 <ref id="strstr" name="strstr">
4768 <sect1>strstr<label id="strstr"><p>
4772 <tag/Function/Find a substring.
4773 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4774 <tag/Declaration/<tt/char* __fastcall__ strstr (const char* str, const char* substr);/
4775 <tag/Description/<tt/strstr/ searches for the first occurance of the string
4776 <tt/substr/ within <tt/str/. If found, it returns a pointer to the copy,
4777 otherwise it returns <tt/NULL/.
4778 <tag/Limits/<itemize>
4779 <item>The function is only available as fastcall function, so it may only
4780 be used in presence of a prototype.
4782 <tag/Availability/ISO 9899
4784 <ref id="strcspn" name="strcspn">,
4785 <ref id="strspn" name="strspn">
4791 <sect1>strtok<label id="strtok"><p>
4795 <tag/Function/Break a string into tokens.
4796 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4797 <tag/Declaration/<tt/char* __fastcall__ strtok (char* s1, const char* s2);/
4798 <tag/Description/<tt/strtok/ will break the string s1 into a sequence of
4799 tokens, which are delimited by characters from the string s2. The first call
4800 to <tt/strtok/ will return a pointer to the first token in the string s1.
4801 Following calls must pass a <tt/NULL/ pointer as s1 in order to get the next
4802 token in the string. Different sets of delimiters may be used for the
4803 subsequent calls to <tt/strtok/.
4804 <tag/Limits/<itemize>
4805 <item>The function is only available as fastcall function, so it may only
4806 be used in presence of a prototype.
4807 <item><tt/strtok/ will modify the string s1.
4809 <tag/Availability/ISO 9899
4811 <ref id="strcspn" name="strcspn">,
4812 <!-- <ref id="strpbrk" name="strpbrk"> -->
4818 <sect1>strxfrm<label id="strxfrm"><p>
4822 <tag/Function/Transform a string.
4823 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4824 <tag/Declaration/<tt/size_t __fastcall__ strxfrm (char* s1, const char* s2, size_t n);/
4825 <tag/Description/The <tt/strxfrm/ function transforms the string pointed to by
4826 s2 and places the resulting string into the string pointed to by s1. The
4827 transformation is such that if the <tt/strcmp/ function is applied to two
4828 transformed strings, it returns a value greater than, equal to, or less than
4829 zero, corresponding to the result of the <tt/strcoll/ function applied to the
4830 same two original strings. No more than n characters are placed into the
4831 resulting array pointed to by s1, including the terminating null character.
4832 <tag/Limits/<itemize>
4833 <item><tt/s1/ and <tt/s2/ must not point to the same memory area, otherwise
4834 the behaviour is undefined.
4835 <item>If <tt/n/ is zero, <tt/s1/ may be a NULL pointer.
4836 <item>The function is only available as fastcall function, so it may only
4837 be used in presence of a prototype.
4838 <item>Since cc65 doesn't support different charcter sets, <tt/strxfrm/ will
4839 just copy s2 to s1 using <tt><ref id="strncpy" name="strncpy"></tt>.
4841 <tag/Availability/ISO 9899
4843 <ref id="strcmp" name="strcmp">,
4844 <ref id="strcoll" name="strcoll">,
4845 <ref id="strncpy" name="strncpy">,
4851 <sect1>strupper<label id="strupper"><p>
4855 <tag/Function/Make a string upper case.
4856 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4857 <tag/Declaration/<tt/char* __fastcall__ strupper (char* s);/
4858 <tag/Description/The <tt/strupper/ function will apply the <tt/toupper/
4859 function to each character of a string. The function will always return <tt/s/.
4860 <tag/Limits/<itemize>
4861 <item>The function is only available as fastcall function, so it may only
4862 be used in presence of a prototype.
4863 <item>The function prototype is unavailable when compiling in strict ANSI mode.
4864 <item>An alias name for this function is <tt/strupr/.
4866 <tag/Availability/cc65
4868 <ref id="strlower" name="strlower">
4869 <ref id="toupper" name="toupper">
4875 <sect1>strupr<label id="strupr"><p>
4882 <sect1>textcolor<label id="textcolor"><p>
4886 <tag/Function/Set the text color.
4887 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
4888 <tag/Declaration/<tt/unsigned char __fastcall__ textcolor (unsigned char color);/
4889 <tag/Description/The function will set a new text color. It returns the old
4890 (current) text color. Text output using any <tt/conio.h/ function will use
4891 the color set by this function.
4892 <tag/Limits/<itemize>
4893 <item>Text colors are system dependent. The function may have no effect
4894 on systems where the text color cannot be changed.
4895 <item>The function is only available as fastcall function, so it may only
4896 be used in presence of a prototype.
4898 <tag/Availability/cc65
4900 <ref id="bgcolor" name="bgcolor">,
4901 <ref id="bordercolor" name="bordercolor">
4907 <sect1>tgi_arc<label id="tgi_arc"><p>
4911 <tag/Function/Draw an elliptic arc in the current color.
4912 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
4913 <tag/Declaration/<tt/void __fastcall__ tgi_arc (int x, int y,
4914 unsigned char rx, unsigned char ry, unsigned sa, unsigned ea);/
4915 <tag/Description/The function draws an elliptic arc with center at x/y and
4916 radii rx/ry using the current drawing color. The arc covers the angle
4917 between sa and ea (startangle and endangle), which must be in the range
4919 <tag/Limits/<itemize>
4920 <item>The function is only available as fastcall function, so it may only
4921 be used in presence of a prototype.
4922 <item>The function behaves unexpectedly or may crash if the angles are out
4925 <tag/Availability/cc65
4927 <ref id="tgi_bar" name="tgi_bar">,
4928 <ref id="tgi_circle" name="tgi_circle">,
4929 <ref id="tgi_ellipse" name="tgi_ellipse">,
4930 <ref id="tgi_pieslice" name="tgi_pieslice">,
4931 <ref id="tgi_setcolor" name="tgi_setcolor">
4933 /* Draw the upper half of an ellipse */
4934 tgi_setcolor(TGI_COLOR_BLUE);
4935 tgi_arc (50, 50, 40, 20, 0, 180);
4941 <sect1>tgi_bar<label id="tgi_bar"><p>
4945 <tag/Function/The function fills a rectangle on the drawpage with the current
4947 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
4948 <tag/Declaration/<tt/void __fastcall__ tgi_bar (int x1, int y1, int x2, int y2);/
4949 <tag/Description/The function fills a rectangle on the drawpage with the current
4951 <tag/Limits/<itemize>
4952 <item>The function is only available as fastcall function, so it may only
4953 be used in presence of a prototype.
4955 <tag/Availability/cc65
4956 <tag/See also/Other tgi function
4958 tgi_setcolor(TGI_COLOR_GREEN);
4959 tgi_bar(10, 10, 100, 60);
4965 <sect1>tgi_circle<label id="tgi_circle"><p>
4969 <tag/Function/The function draws a circle in the current color.
4970 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
4971 <tag/Declaration/<tt/void __fastcall__ tgi_circle (int x, int y, unsigned char radius);/
4972 <tag/Description/The function draws a circle in the current color.
4973 <tag/Limits/<itemize>
4974 <item>The function is only available as fastcall function, so it may only
4975 be used in presence of a prototype.
4977 <tag/Availability/cc65
4979 <ref id="tgi_arc" name="tgi_arc">,
4980 <ref id="tgi_bar" name="tgi_bar">,
4981 <ref id="tgi_ellipse" name="tgi_ellipse">,
4982 <ref id="tgi_pieslice" name="tgi_pieslice">,
4983 <ref id="tgi_setcolor" name="tgi_setcolor">
4985 tgi_setcolor(TGI_COLOR_BLACK);
4986 tgi_circle(50, 40, 40);
4992 <sect1>tgi_clear<label id="tgi_clear"><p>
4996 <tag/Function/Clear the drawpage
4997 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
4998 <tag/Declaration/<tt/void __fastcall__ tgi_clear (void);/
4999 <tag/Description/Clear the drawpage
5000 <tag/Limits/<itemize>
5001 <item>The function is only available as fastcall function, so it may only
5002 be used in presence of a prototype.
5004 <tag/Availability/cc65
5005 <tag/See also/Other tgi functions
5011 <sect1>tgi_done<label id="tgi_done"><p>
5015 <tag/Function/End graphics mode, switch back to text mode.
5016 Will NOT uninstall or unload the driver!
5017 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5018 <tag/Declaration/<tt/void __fastcall__ tgi_done (void);/
5019 <tag/Description/End graphics mode, switch back to text mode.
5020 Will NOT uninstall or unload the driver!
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/cc65
5026 <tag/See also/Other tgi functions
5032 <sect1>tgi_ellipse<label id="tgi_ellipse"><p>
5036 <tag/Function/The function draws an ellipse in the current color.
5037 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5038 <tag/Declaration/<tt/void __fastcall__ tgi_ellipse (int x, int y, unsigned char rx, unsigned char ry);/
5039 <tag/Description/The function draws an ellipse at position x/y with radii
5040 rx and ry, using the current drawing color.
5041 <tag/Limits/<itemize>
5042 <item>The function is only available as fastcall function, so it may only
5043 be used in presence of a prototype.
5045 <tag/Availability/cc65
5047 <ref id="tgi_arc" name="tgi_arc">,
5048 <ref id="tgi_bar" name="tgi_bar">,
5049 <ref id="tgi_circle" name="tgi_circle">,
5050 <ref id="tgi_pieslice" name="tgi_pieslice">,
5051 <ref id="tgi_setcolor" name="tgi_setcolor">
5053 tgi_setcolor(TGI_COLOR_RED);
5054 tgi_ellipse (50, 40, 40, 20);
5060 <sect1>tgi_getcolor<label id="tgi_getcolor"><p>
5064 <tag/Function/Return the current drawing color.
5065 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5066 <tag/Declaration/<tt/unsigned char __fastcall__ tgi_getcolor (void);/
5067 <tag/Description/The actual color is an index to a palette. During tgi_init
5068 you will get a default palette. The number of colors depend on the platform.
5069 All platforms recognize at least TGI_COLOR_BLACK and TGI_COLOR_WHITE. But some
5070 platforms have many more predefined colors. If you paint using TGI_COLOR_GREEN
5071 and then you change the green of the palette to blue using tgi_setpalette then
5072 after this painting in TGI_COLOR_GREEN will actually be blue.
5073 <tag/Limits/<itemize>
5074 <item>The function is only available as fastcall function, so it may only
5075 be used in presence of a prototype.
5077 <tag/Availability/cc65
5078 <tag/See also/Other tgi functions
5080 color = tgi_getcolor();
5085 <sect1>tgi_getcolorcount<label id="tgi_getcolorcount"><p>
5089 <tag/Function/Get the number of available colors.
5090 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5091 <tag/Declaration/<tt/unsigned char __fastcall__ tgi_getcolorcount (void);/
5092 <tag/Description/Tgi platforms use indexed color palettes. This function
5093 returns the number of entries we can use in the palette.
5094 <tag/Limits/<itemize>
5095 <item>The function is only available as fastcall function, so it may only
5096 be used in presence of a prototype.
5098 <tag/Availability/cc65
5099 <tag/See also/Other tgi functions
5101 if (tgi_getcolorcount() == 2) {
5102 printf("Only monochrome graphics is supported\n");
5108 <sect1>tgi_getdefpalette<label id="tgi_getdefpalette"><p>
5112 <tag/Function/Get the palette installed by default.
5113 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5114 <tag/Declaration/<tt/const unsigned char* __fastcall__ tgi_getdefpalette (void);/
5115 <tag/Description/The tgi driver has a default palette that is active at startup.
5116 The named colors TGI_COLOR_BLACK, TGI_COLOR_WHITE, TGI_COLOR_RED... need this
5117 palette to work correctly.
5118 <tag/Limits/<itemize>
5119 <item>The function is only available as fastcall function, so it may only
5120 be used in presence of a prototype.
5122 <tag/Availability/cc65
5123 <tag/See also/Other tgi functions
5128 <sect1>tgi_geterror<label id="tgi_geterror"><p>
5132 <tag/Function/Return the error code for the last operation.
5133 This will also clear the error.
5134 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5135 <tag/Declaration/<tt/unsigned char __fastcall__ tgi_geterror (void);/
5136 <tag/Description/Return the error code for the last operation.
5137 This will also clear the error.
5138 <tag/Limits/<itemize>
5139 <item>The function is only available as fastcall function, so it may only
5140 be used in presence of a prototype.
5142 <tag/Availability/cc65
5143 <tag/See also/Other tgi functions
5148 <sect1>tgi_geterrormsg<label id="tgi_geterrormsg"><p>
5152 <tag/Function/Get an error message describing the error.
5153 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5154 <tag/Declaration/<tt/const char* __fastcall__ tgi_geterrormsg (unsigned char code);/
5155 <tag/Description/Get an error message describing the error.
5156 <tag/Limits/<itemize>
5157 <item>The function is only available as fastcall function, so it may only
5158 be used in presence of a prototype.
5160 <tag/Availability/cc65
5161 <tag/See also/Other tgi functions
5166 <sect1>tgi_getmaxcolor<label id="tgi_getmaxcolor"><p>
5170 <tag/Function/Get the highest index of the palette.
5171 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5172 <tag/Declaration/<tt/unsigned char __fastcall__ tgi_getmaxcolor (void);/
5173 <tag/Description/Get the highest index of the palette.
5174 <tag/Limits/<itemize>
5175 <item>The function is only available as fastcall function, so it may only
5176 be used in presence of a prototype.
5178 <tag/Availability/cc65
5179 <tag/See also/Other tgi functions
5184 <sect1>tgi_getmaxx<label id="tgi_getmaxx"><p>
5188 <tag/Function/Get the maximum x coordinate that can be used on this screen.
5189 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5190 <tag/Declaration/<tt/unsigned __fastcall__ tgi_getmaxx (void);/
5191 <tag/Description/Get the maximum x coordinate that can be used on this screen.
5192 <tag/Limits/<itemize>
5193 <item>The function is only available as fastcall function, so it may only
5194 be used in presence of a prototype.
5196 <tag/Availability/cc65
5197 <tag/Availability/cc65
5198 <tag/See also/Other tgi functions
5203 <sect1>tgi_getmaxy<label id="tgi_getmaxy"><p>
5207 <tag/Function/Get the maximum y coordinate that can be used on this screen.
5208 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5209 <tag/Declaration/<tt/unsigned __fastcall__ tgi_getmaxy (void);/
5210 <tag/Description/Get the maximum y coordinate that can be used on this screen.
5211 <tag/Limits/<itemize>
5212 <item>The function is only available as fastcall function, so it may only
5213 be used in presence of a prototype.
5215 <tag/Availability/cc65
5216 <tag/See also/Other tgi functions
5221 <sect1>tgi_getpagecount<label id="tgi_getpagecount"><p>
5225 <tag/Function/Return the number of screen pages available.
5226 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5227 <tag/Declaration/<tt/unsigned __fastcall__ tgi_getpagecount (void);/
5228 <tag/Description/Return the number of screen pages available.
5229 <tag/Limits/<itemize>
5230 <item>The function is only available as fastcall function, so it may only
5231 be used in presence of a prototype.
5233 <tag/Availability/cc65
5235 <ref id="tgi_setdrawpage" name="tgi_setdrawpage">,
5236 <ref id="tgi_setviewpage" name="tgi_setviewpage">
5241 <sect1>tgi_getpalette<label id="tgi_getpalette"><p>
5245 <tag/Function/Get the palette installed.
5246 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5247 <tag/Declaration/<tt/const unsigned char* __fastcall__ tgi_getpalette (void);/
5248 <tag/Description/Get the palette installed.
5249 <tag/Limits/<itemize>
5250 <item>The function is only available as fastcall function, so it may only
5251 be used in presence of a prototype.
5253 <tag/Availability/cc65
5254 <tag/See also/Other tgi functions
5259 <sect1>tgi_getpixel<label id="tgi_getpixel"><p>
5263 <tag/Function/Get the color of a pixel from the viewpage.
5264 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5265 <tag/Declaration/<tt/unsigned char __fastcall__ tgi_getpixel (int x, int y);/
5266 <tag/Description/Get the color of a pixel from the viewpage.
5267 <tag/Limits/<itemize>
5268 <item>The function is only available as fastcall function, so it may only
5269 be used in presence of a prototype.
5271 <tag/Availability/cc65
5272 <tag/See also/Other tgi functions.
5277 <sect1>tgi_getxres<label id="tgi_getxres"><p>
5281 <tag/Function/Get number of horisontal pixels on the screen.
5282 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5283 <tag/Declaration/<tt/unsigned __fastcall__ tgi_getxres (void);/
5284 <tag/Description/Get number of horisontal pixels on the screen.
5285 This is same as tgi_maxx()+1.
5286 <tag/Limits/<itemize>
5287 <item>The function is only available as fastcall function, so it may only
5288 be used in presence of a prototype.
5290 <tag/Availability/cc65
5291 <tag/See also/Other tgi functions.
5296 <sect1>tgi_getyres<label id="tgi_getyres"><p>
5300 <tag/Function/Get number of vertical pixels on the screen.
5301 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5302 <tag/Declaration/<tt/unsigned __fastcall__ tgi_getyres (void);/
5303 <tag/Description/Get number of vertical pixels on the screen.
5304 This is same as tgi_maxy()+1.
5305 <tag/Limits/<itemize>
5306 <item>The function is only available as fastcall function, so it may only
5307 be used in presence of a prototype.
5309 <tag/Availability/cc65
5310 <tag/See also/Other tgi functions.
5315 <sect1>tgi_gotoxy<label id="tgi_gotoxy"><p>
5319 <tag/Function/Set graphics cursor at x, y.
5320 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5321 <tag/Declaration/<tt/void __fastcall__ tgi_gotoxy (int x, int y);/
5322 <tag/Description/Set graphics cursor at x, y.
5323 <tag/Limits/<itemize>
5324 <item>The function is only available as fastcall function, so it may only
5325 be used in presence of a prototype.
5327 <tag/Availability/cc65
5328 <tag/See also/Other tgi functions.
5333 <sect1>tgi_init<label id="tgi_init"><p>
5337 <tag/Function/Initialize the already loaded graphics driver.
5338 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5339 <tag/Declaration/<tt/void __fastcall__ tgi_init (void);/
5340 <tag/Description/The tgi_init function will set the default palette to the
5342 <tag/Limits/<itemize>
5343 <item>The function is only available as fastcall function, so it may only
5344 be used in presence of a prototype.
5345 <item><tt/tgi_init/ will not clear the screen. This allows switching between
5346 text and graphics mode on platforms that have separate memory areas for the
5347 screens. If you want the screen cleared, call <tt/<ref id="tgi_clear"
5348 name="tgi_clear">/ after <tt/tgi_init/.
5350 <tag/Availability/cc65
5351 <tag/See also/Other tgi functions.
5353 extern char lynxtgi[]; //Include the driver statically instead of loading it.
5354 tgi_install(&lynxtgi);
5355 tgi_init(); //Set up the default palette and clear the screen.
5360 <sect1>tgi_install<label id="tgi_install"><p>
5364 <tag/Function/Install an already loaded driver and return an error code.
5365 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5366 <tag/Declaration/<tt/unsigned char __fastcall__ tgi_install (void* driver);/
5367 <tag/Description/The function installs a driver that was already loaded into
5368 memory (or linked statically to the program). It returns an error code
5369 (<tt/TGI_ERR_OK/ in case of success).
5370 <tag/Limits/<itemize>
5371 <item>The function is only available as fastcall function, so it may only be
5372 used in presence of a prototype.
5374 <tag/Availability/cc65
5376 <ref id="tgi_load_driver" name="tgi_load_driver">,
5377 <ref id="tgi_uninstall" name="tgi_uninstall">,
5378 <ref id="tgi_unload" name="tgi_unload">
5380 extern char lynxtgi[]; //Include the driver statically instead of loading it.
5382 tgi_install(&lynxtgi);
5383 tgi_init(); //Set up the default palette and clear the screen.
5389 <sect1>tgi_ioctl<label id="tgi_ioctl"><p>
5393 <tag/Function/Platform dependent code extensions.
5394 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5395 <tag/Declaration/<tt/unsigned __fastcall__ tgi_ioctl (unsigned char code, void* data);/
5396 <tag/Description/Some platforms have extra display hardware that is not
5397 supported by standard tgi functions. You can extend the driver to support
5398 this extra hardware using tgi_ioctl functions.
5399 <tag/Limits/<itemize>
5400 <item>The function is only available as fastcall function, so it may only
5401 be used in presence of a prototype.
5402 <item>These functions are not easily portable to other cc65 platforms.
5404 <tag/Availability/cc65
5405 <tag/See also/Other tgi functions.
5407 #define tgi_sprite(spr) tgi_ioctl(0, (void*)(spr))
5408 #define tgi_flip() tgi_ioctl(1, (void*)0)
5409 #define tgi_setbgcolor(bgcol) tgi_ioctl(2, (void*)(bgcol))
5410 #define tgi_setframerate(rate) tgi_ioctl(3, (void*)(rate))
5411 #define tgi_busy() tgi_ioctl(4, (void*)0)
5412 #define tgi_updatedisplay() tgi_ioctl(4, (void*)1)
5414 tgi_sprite(&background);
5415 tgi_setcolor(TGI_COLOR_BLUE);
5416 tgi_outttextxy(20,40,"Hello World");
5417 tgi_updatedisplay();
5424 <sect1>tgi_line<label id="tgi_line"><p>
5428 <tag/Function/Draw a line in the current drawing color.
5429 The graphics cursor will be set to x2/y2 by this call.
5430 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5431 <tag/Declaration/<tt/void __fastcall__ tgi_line (int x1, int y1, int x2, int y2);/
5432 <tag/Description/Draw a line in the current drawing color.
5433 The graphics cursor will be set to x2/y2 by this call.
5434 <tag/Limits/<itemize>
5435 <item>The function is only available as fastcall function, so it may only
5436 be used in presence of a prototype.
5438 <tag/Availability/cc65
5439 <tag/See also/Other tgi functions.
5445 <sect1>tgi_lineto<label id="tgi_lineto"><p>
5449 <tag/Function/Draw a line in the current drawing color from the graphics
5450 cursor to the new end point. The graphics cursor will be updated to x2/y2.
5451 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5452 <tag/Declaration/<tt/void __fastcall__ tgi_lineto (int x2, int y2);/
5453 <tag/Description/Draw a line in the current drawing color from the graphics
5454 cursor to the new end point. The graphics cursor will be updated to x2/y2.
5455 <tag/Limits/<itemize>
5456 <item>The function is only available as fastcall function, so it may only
5457 be used in presence of a prototype.
5459 <tag/Availability/cc65
5460 <tag/See also/Other tgi functions.
5466 <sect1>tgi_load<label id="tgi_load"><p>
5470 <tag/Function/Load and install the matching driver for the given mode.
5471 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5472 <tag/Declaration/<tt/void __fastcall__ tgi_load (unsigned char mode);/
5473 <tag/Description/Load and install the matching driver for the given mode.
5474 Will just load the driver and check if loading was successul.
5475 Will not switch to graphics mode.
5476 <tag/Limits/<itemize>
5477 <item>The function is only available as fastcall function, so it may only
5478 be used in presence of a prototype.
5480 <tag/Availability/cc65
5481 <tag/See also/Other tgi functions.
5487 <sect1>tgi_load_driver<label id="tgi_load_driver"><p>
5491 <tag/Function/Load and install the given driver. This function is identical
5492 to tgi_load with the only difference that the name of the driver is specified
5494 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5495 <tag/Declaration/<tt/void __fastcall__ tgi_load_driver (const char *name);/
5496 <tag/Description/Load and install the driver by name.
5497 Will just load the driver and check if loading was successul.
5498 Will not switch to graphics mode.
5499 <tag/Limits/<itemize>
5500 <item>The function is only available as fastcall function, so it may only
5501 be used in presence of a prototype.
5503 <tag/Availability/cc65
5504 <tag/See also/Other tgi functions.
5510 <sect1>tgi_outtext<label id="tgi_outtext"><p>
5514 <tag/Function/Output text at the current graphics cursor position.
5515 The graphics cursor is moved to the end of the text.
5516 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5517 <tag/Declaration/<tt/void __fastcall__ tgi_outtext (const char* s);/
5518 <tag/Description/Output text at the current graphics cursor position.
5519 The graphics cursor is moved to the end of the text.
5520 <tag/Limits/<itemize>
5521 <item>The function is only available as fastcall function, so it may only
5522 be used in presence of a prototype.
5524 <tag/Availability/cc65
5525 <tag/See also/Other tgi functions.
5531 <sect1>tgi_outtextxy<label id="tgi_outtextxy"><p>
5535 <tag/Function/Output text at the given cursor position.
5536 The graphics cursor is moved to the end of the text.
5537 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5538 <tag/Declaration/<tt/void __fastcall__ tgi_outtextxy (int x, int y, const char* s);/
5539 <tag/Description/Output text at the given cursor position.
5540 The graphics cursor is moved to the end of the text.
5541 <tag/Limits/<itemize>
5542 <item>The function is only available as fastcall function, so it may only
5543 be used in presence of a prototype.
5545 <tag/Availability/cc65
5546 <tag/See also/Other tgi functions.
5552 <sect1>tgi_pieslice<label id="tgi_pieslice"><p>
5556 <tag/Function/Draw an elliptic pie slice in the current color.
5557 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5558 <tag/Declaration/<tt/void __fastcall__ tgi_pie slice (int x, int y,
5559 unsigned char rx, unsigned char ry, unsigned sa, unsigned ea);/
5560 <tag/Description/The function draws an elliptic pie slice with center at x/y
5561 and radii rx/ry using the current drawing color. The pie slice covers the angle
5562 between sa and ea (startangle and endangle), which must be in the range
5564 <tag/Limits/<itemize>
5565 <item>The function is only available as fastcall function, so it may only
5566 be used in presence of a prototype.
5567 <item>The function behaves unexpectedly or may crash if the angles are out
5570 <tag/Availability/cc65
5572 <ref id="tgi_bar" name="tgi_arc">,
5573 <ref id="tgi_bar" name="tgi_bar">,
5574 <ref id="tgi_circle" name="tgi_circle">,
5575 <ref id="tgi_ellipse" name="tgi_ellipse">,
5576 <ref id="tgi_setcolor" name="tgi_setcolor">
5578 /* Draw the closed upper half of an ellipse */
5579 tgi_setcolor(TGI_COLOR_BLUE);
5580 tgi_pieslice (50, 50, 40, 20, 0, 180);
5586 <sect1>tgi_setcolor<label id="tgi_setcolor"><p>
5590 <tag/Function/Set color to be used in future draw operations.
5591 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5592 <tag/Declaration/<tt/void __fastcall__ tgi_setcolor (unsigned char color);/
5593 <tag/Description/Set color to be used in future draw operations.
5594 <tag/Limits/<itemize>
5595 <item>The function is only available as fastcall function, so it may only
5596 be used in presence of a prototype.
5598 <tag/Availability/cc65
5599 <tag/See also/Other tgi functions.
5601 tgi_setcolor(TGI_COLOR_BLACK);
5603 tgi_setcolor(TGI_COLOR_WHITE);
5604 tgi_bar(10,10,20,20);
5609 <sect1>tgi_setdrawpage<label id="tgi_setdrawpage"><p>
5613 <tag/Function/Set the page for drawing.
5614 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5615 <tag/Declaration/<tt/void __fastcall__ tgi_setdrawpage (unsigned char page);/
5616 <tag/Description/If the drawpage and the viewpage are the same then all drawing
5617 is seen immediately as it is drawn. For double buffered games you can set the
5618 drawpage to a different page than the viewpage. This lets you draw the next
5619 screen in the background and when the screen is ready you display it.
5620 <tag/Limits/<itemize>
5621 <item>The function is only available as fastcall function, so it may only
5622 be used in presence of a prototype.
5624 <tag/Availability/cc65
5625 <tag/See also/Other tgi functions.
5628 tgi_outtextxy(10, 10, "Hello World");
5629 tgi_setviewpage(1); // Show page 1
5631 tgi_outtextxy(10, 10, "Creating next frame");
5633 tgi_setviewpage(0); // Show page 0
5638 <sect1>tgi_setpalette<label id="tgi_setpalette"><p>
5642 <tag/Function/Set the palette (not available with all drivers/hardware).
5643 Palette is a pointer to as many entries as there are colors.
5644 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5645 <tag/Declaration/<tt/void __fastcall__ tgi_setpalette (const unsigned char* palette);/
5646 <tag/Description/Set the palette (not available with all drivers/hardware).
5647 Palette is a pointer to as many entries as there are colors.
5648 <tag/Limits/<itemize>
5649 <item>The function is only available as fastcall function, so it may only
5650 be used in presence of a prototype.
5652 <tag/Availability/cc65
5653 <tag/See also/Other tgi functions.
5658 <sect1>tgi_setpixel<label id="tgi_setpixel"><p>
5662 <tag/Function/Plot a pixel on the drawpage with the current color.
5663 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5664 <tag/Declaration/<tt/void __fastcall__ tgi_setpixel (int x, int y);/
5665 <tag/Description/Plot a pixel on the drawpage with the current color.
5666 <tag/Limits/<itemize>
5667 <item>The function is only available as fastcall function, so it may only
5668 be used in presence of a prototype.
5670 <tag/Availability/cc65
5671 <tag/See also/Other tgi functions.
5676 <sect1>tgi_setviewpage<label id="tgi_setviewpage"><p>
5680 <tag/Function/Set page to be visible on screen.
5681 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5682 <tag/Declaration/<tt/void __fastcall__ tgi_setviewpage (unsigned char page);/
5683 <tag/Description/If the drawpage and the viewpage are the same then all drawing
5684 is seen immediately as it is drawn. For double buffered games you can set the
5685 drawpage to a different page than the viewpage. This lets you draw the next
5686 screen in the background and when the screen is ready you display it.
5687 <tag/Limits/<itemize>
5688 <item>The function is only available as fastcall function, so it may only
5689 be used in presence of a prototype.
5691 <tag/Availability/cc65
5692 <tag/See also/Other tgi functions.
5695 tgi_outtextxy(10, 10, "Hello World");
5696 tgi_setviewpage(1); // Show page 1
5698 tgi_outtextxy(10, 10, "Creating next frame");
5700 tgi_setviewpage(0); // Show page 0
5705 <sect1>tgi_textheight<label id="tgi_textheight"><p>
5709 <tag/Function/Calculate the height of the text in pixels according to
5710 the current text style.
5711 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5712 <tag/Declaration/<tt/unsigned __fastcall__ tgi_textheight (const char* s);/
5713 <tag/Description/Calculate the height of the text in pixels according to
5714 the current text style.
5715 <tag/Limits/<itemize>
5716 <item>The function is only available as fastcall function, so it may only
5717 be used in presence of a prototype.
5719 <tag/Availability/cc65
5720 <tag/See also/Other tgi functions.
5725 <sect1>tgi_textstyle<label id="tgi_textstyle"><p>
5729 <tag/Function/Set the style for text output.
5730 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5731 <tag/Declaration/<tt/void __fastcall__ tgi_textstyle (unsigned char magx, unsigned char magy, unsigned char dir);/
5732 <tag/Description/Set the style for text output.
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.
5743 <sect1>tgi_textwidth<label id="tgi_textwidth"><p>
5747 <tag/Function/Calculate the width of the text in pixels according to the current text style.
5748 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5749 <tag/Declaration/<tt/unsigned __fastcall__ tgi_textwidth (const char* s);/
5750 <tag/Function/Calculate the width of the text in pixels according to the current text style.
5751 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5752 <tag/Description/Calculate the width of the text in pixels according to the current text style.
5753 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
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.
5764 <sect1>tgi_uninstall<label id="tgi_uninstall"><p>
5768 <tag/Function/Uninstall the currently loaded driver but do not unload it.
5769 Will call tgi_done if necessary.
5770 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5771 <tag/Declaration/<tt/void __fastcall__ tgi_uninstall (void);/
5772 <tag/Description/Uninstall the currently loaded driver but do not unload it.
5773 Will call tgi_done if necessary.
5774 <tag/Limits/<itemize>
5775 <item>The function is only available as fastcall function, so it may only
5776 be used in presence of a prototype.
5778 <tag/Availability/cc65
5779 <tag/See also/Other tgi functions.
5784 <sect1>tgi_unload<label id="tgi_unload"><p>
5788 <tag/Function/Uninstall, then unload the currently loaded driver.
5789 Will call tgi_done if necessary.
5790 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5791 <tag/Declaration/<tt/void __fastcall__ tgi_unload (void);/
5792 <tag/Description/Uninstall, then unload the currently loaded driver.
5793 Will call tgi_done if necessary.
5794 <tag/Limits/<itemize>
5795 <item>The function is only available as fastcall function, so it may only
5796 be used in presence of a prototype.
5798 <tag/Availability/cc65
5799 <tag/See also/Other tgi functions.
5804 <sect1>time<label id="time"><p>
5808 <tag/Function/Get the time.
5809 <tag/Header/<tt/<ref id="time.h" name="time.h">/
5810 <tag/Declaration/<tt/time_t __fastcall__ time (time_t* t);/
5811 <tag/Description/The function returns the time since the 1970-01-01 00:00:00
5812 measured in seconds. If the pointer <tt/t/ is not <tt/NULL/, the function
5813 result will also be stored there. If no time is available, <tt/(time_t)-1/ is
5814 returned and <tt/errno/ is set to <tt/ENOSYS/.
5815 <tag/Limits/<itemize>
5816 <item>The function is only available as fastcall function, so it may
5817 only be used in presence of a prototype.
5818 <item>Many platforms supported by cc65 do not have a realtime clock, so the
5819 returned value may not be valid.
5821 <tag/Availability/ISO 9899
5827 <sect1>toggle_videomode<label id="toggle_videomode"><p>
5831 <tag/Function/Toggle between 40 and 80 column mode.
5832 <tag/Header/<tt/<ref id="c128.h" name="c128.h">/
5833 <tag/Declaration/<tt/void toggle_videomode (void);/
5834 <tag/Description/Toggle between 40 and 80 column mode. The settings for the
5835 old mode (cursor position, color and so on) are saved and restored together
5837 <tag/Limits/<itemize>
5838 <item>The function is specific to the C128.
5839 <item>This function is deprecated. Please use <ref id="videomode"
5840 name="videomode"> instead!
5842 <tag/Availability/C128
5844 <ref id="fast" name="fast">,
5845 <ref id="slow" name="slow">,
5846 <ref id="videomode" name="videomode">
5852 <sect1>tolower<label id="tolower"><p>
5856 <tag/Function/Convert a character into its lower case representation.
5857 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
5858 <tag/Declaration/<tt/int __fastcall__ tolower (int c);/
5859 <tag/Description/The function returns the given character converted to lower
5860 case. If the given character is not a letter, it is returned unchanged.
5861 <tag/Limits/<itemize>
5862 <item>The function is only available as fastcall function, so it may
5863 only be used in presence of a prototype.
5865 <tag/Availability/ISO 9899
5867 <ref id="islower" name="islower">,
5868 <ref id="isupper" name="isupper">,
5869 <ref id="toupper" name="toupper">
5875 <sect1>toupper<label id="toupper"><p>
5879 <tag/Function/Convert a character into its upper case representation.
5880 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
5881 <tag/Declaration/<tt/int __fastcall__ toupper (int c);/
5882 <tag/Description/The function returns the given character converted to upper
5883 case. If the given character is not a letter, it is returned unchanged.
5884 <tag/Limits/<itemize>
5885 <item>The function is only available as fastcall function, so it may
5886 only be used in presence of a prototype.
5888 <tag/Availability/ISO 9899
5890 <ref id="islower" name="islower">,
5891 <ref id="isupper" name="isupper">,
5892 <ref id="tolower" name="tolower">
5898 <sect1>ultoa<label id="ultoa"><p>
5902 <tag/Function/Convert an unsigned long integer into a string.
5903 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
5904 <tag/Declaration/<tt/char* __fastcall__ ultoa (unsigned long val, char* buf, int radix);/
5905 <tag/Description/<tt/itoa/ converts the unsigned long integer <tt/val/ into a
5906 string using <tt/radix/ as the base.
5907 <tag/Limits/<itemize>
5908 <item>There are no provisions to prevent a buffer overflow.
5909 <item>The function is non standard, so it is not available in strict ANSI mode.
5910 You should probably use <tt/sprintf/ instead.
5911 <item>The function is only available as fastcall function, so it may only be
5912 used in presence of a prototype.
5914 <tag/Availability/cc65
5916 <ref id="atoi" name="atoi">,
5917 <ref id="atol" name="atol">,
5918 <ref id="itoa" name="itoa">,
5919 <ref id="ltoa" name="ltoa">,
5920 <ref id="utoa" name="utoa">
5926 <sect1>unlink<label id="unlink"><p>
5930 <tag/Function/Delete a file.
5931 <tag/Header/<tt/<ref id="unistd.h" name="unistd.h">/
5932 <tag/Declaration/<tt/int __fastcall__ unlink (const char* name);/
5933 <tag/Description/<tt/unlink/ deletes the file with the given name. On success,
5934 zero is returned. On error, -1 is returned and <tt/errno/ is set to an error
5935 code describing the reason for the failure.
5938 <item>The use of this function is discouraged. Please use <tt/<ref id="remove"
5939 name="remove">/ instead, which is a native ANSI C function and does the same.
5940 <item>This function is not available on all cc65 targets (depends on the
5941 availability of file I/O).
5942 <item>The function is only available as fastcall function, so it may only
5943 be used in presence of a prototype.
5944 <item>Instead of <tt/unlink/, <tt/<ref id="remove" name="remove">/ should be
5945 used, which has the same semantics, but is more portable, because it conforms
5946 to the ISO C standard.
5948 <tag/Availability/POSIX 1003.1
5950 <ref id="remove" name="remove">
5953 #include <stdio.h>
5954 #include <unistd.h>
5956 #define FILENAME "helloworld"
5958 if (unlink (FILENAME) == 0) {
5959 printf ("We deleted %s successfully\n", FILENAME);
5961 printf ("There was a problem deleting %s\n", FILENAME);
5968 <sect1>utoa<label id="utoa"><p>
5972 <tag/Function/Convert an unsigned integer into a string.
5973 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
5974 <tag/Declaration/<tt/char* __fastcall__ utoa (unsigned val, char* buf, int radix);/
5975 <tag/Description/<tt/itoa/ converts the unsigned integer <tt/val/ into a string
5976 using <tt/radix/ as the base.
5977 <tag/Limits/<itemize>
5978 <item>There are no provisions to prevent a buffer overflow.
5979 <item>The function is non standard, so it is not available in strict ANSI mode.
5980 You should probably use <tt/sprintf/ instead.
5981 <item>The function is only available as fastcall function, so it may only be
5982 used in presence of a prototype.
5984 <tag/Availability/cc65
5986 <ref id="atoi" name="atoi">,
5987 <ref id="atol" name="atol">,
5988 <ref id="itoa" name="itoa">,
5989 <ref id="ltoa" name="ltoa">,
5990 <ref id="ultoa" name="ultoa">
5996 <sect1>vcprintf<label id="vcprintf"><p>
6000 <tag/Function/Formatted output to the console.
6001 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
6002 <tag/Declaration/<tt/int __fastcall__ vcprintf (const char* format, va_list ap);/
6003 <tag/Description/The arguments specified as a <tt/va_list/ are converted to
6004 text where necessary and formatted according to the format string given. The
6005 resulting string is output to the console. <tt/vcprintf/ supports the same
6006 format specifiers as <tt/vprintf/. <!-- <tt/<ref id="vprintf" name="vprintf">/. -->
6007 <tag/Limits/<itemize>
6008 <item>Like all other <tt/conio/ output functions, <tt/vcprintf/ distinguishes
6009 between <tt/\r/ and <tt/\n/.
6010 <item>The function is only available as fastcall function, so it may only be
6011 used in presence of a prototype.
6013 <tag/Availability/cc65
6015 <ref id="cprintf" name="cprintf">,
6016 <ref id="cputc" name="cputc">,
6017 <ref id="cputcxy" name="cputcxy">,
6018 <ref id="cputs" name="cputs">,
6019 <ref id="cputsxy" name="cputsxy">
6025 <sect1>videomode<label id="videomode"><p>
6029 <tag/Function/Switch to either 40 or 80 column mode.
6030 <tag/Header/<tt/<ref id="apple2enh.h" name="apple2enh.h">,
6031 <ref id="c128.h" name="c128.h">/
6032 <tag/Declaration/<tt/unsigned __fastcall__ videomode (unsigned Mode);/
6033 <tag/Description/Switch to 40 or 80 column mode depending on the argument. If
6034 the requested mode is already active, nothing happens. The old mode is returned
6036 <tag/Limits/<itemize>
6037 <item>The function is specific to the C128 and enhanced Apple //e.
6038 <item>This function replaces <ref id="toggle_videomode"
6039 name="toggle_videomode">.
6040 <item>The function is only available as fastcall function, so it may only be
6041 used in presence of a prototype.
6043 <tag/Availability/C128 and enhanced Apple //e
6045 <ref id="fast" name="fast">,
6046 <ref id="slow" name="slow">,
6047 <ref id="toggle_videomode" name="toggle_videomode">
6053 <sect1>wherex<label id="wherex"><p>
6057 <tag/Function/Return the current X position of the text mode cursor.
6058 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
6059 <tag/Declaration/<tt/unsigned char wherex (void);/
6060 <tag/Description/The function returns the current X position of the text mode
6061 cursor. Zero is returned for the leftmost screen position.
6062 <tag/Availability/cc65
6064 <ref id="gotox" name="gotox">,
6065 <ref id="gotoy" name="gotoy">,
6066 <ref id="gotoxy" name="gotoxy">,
6067 <ref id="wherey" name="wherey">
6073 <sect1>wherey<label id="wherey"><p>
6077 <tag/Function/Return the current Y position of the text mode cursor.
6078 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
6079 <tag/Declaration/<tt/unsigned char wherey (void);/
6080 <tag/Description/The function returns the current Y position of the text mode
6081 cursor. Zero is returned for the uppermost screen position.
6082 <tag/Availability/cc65
6084 <ref id="gotox" name="gotox">,
6085 <ref id="gotoy" name="gotoy">,
6086 <ref id="gotoxy" name="gotoxy">,
6087 <ref id="wherex" name="wherex">