1 <!doctype linuxdoc system>
4 <title>cc65 function reference
5 <author>Ullrich von Bassewitz, <htmlurl url="mailto:uz@cc65.org" name="uz@cc65.org">
9 cc65 is a C compiler for 6502 based systems. This function reference describes
10 the C functions available in the standard library.
13 <!-- Table of contents -->
16 <!-- Begin the document -->
20 cc65 is a C compiler for 6502 based systems. It implements a subset of the ISO
21 C standard plus additional functions specially crafted for 6502 systems or
22 just some of the supported machines. This function refrence describes the
23 available functions together with any limitations.
25 For an overview about the available libraries, their purpose, and any
26 differences to the ISO standard, please have a look at the <htmlurl
27 url="library.html" name="cc65 Library Overview">.
29 <bf/Note:/ Standard C functions are listed here, but not described in detail.
30 Since these functions behave identical on all standard compliant systems, they
31 are described in any book covering standard C.
33 Each entry for a function contains a detailed description
37 <tag/Function/Summary of what <bf/function/ does.
38 <tag/Header/The header file that contains the declaration.
39 <tag/Declaration/Describes the needed header files and declaration of the
41 <tag/Description/Description of the function.
43 <tag/Availability/The availability of the function.
44 <tag/See also/Other related functions.
45 <tag/Example/A piece of actual code using the function.
50 <sect>Functions by header file<p>
52 <sect1><tt/6502.h/<label id="6502.h"><p>
55 <item><ref id="BRK" name="BRK">
56 <item><ref id="CLI" name="CLI">
57 <item><ref id="SEI" name="SEI">
58 <item><ref id="_sys" name="_sys">
59 <item><ref id="getcpu" name="getcpu">
60 <item><ref id="reset_brk" name="reset_brk">
61 <item><ref id="set_brk" name="set_brk">
65 <sect1><tt/apple2.h/<label id="apple2.h"><p>
69 <item><ref id="get_ostype" name="get_ostype">
74 <sect1><tt/apple2enh.h/<label id="apple2enh.h"><p>
78 <item><ref id="get_ostype" name="get_ostype">
82 <item><ref id="videomode" name="videomode">
86 <sect1><tt/assert.h/<label id="assert.h"><p>
89 <item><ref id="assert" name="assert">
93 <sect1><tt/atari.h/<label id="atari.h"><p>
96 <item><ref id="get_ostype" name="get_ostype">
102 <sect1><tt/atmos.h/<label id="atmos.h"><p>
107 <sect1><tt/c128.h/<label id="c128.h"><p>
110 <item><ref id="c64mode" name="c64mode">
111 <item><ref id="fast" name="fast">
112 <item><ref id="slow" name="slow">
113 <item><ref id="toggle_videomode" name="toggle_videomode">
114 <item><ref id="videomode" name="videomode">
118 <sect1><tt/c16.h/<label id="c16.h"><p>
123 <sect1><tt/c64.h/<label id="c64.h"><p>
126 <item><ref id="get_ostype" name="get_ostype">
130 <sect1><tt/cbm510.h/<label id="cbm510.h"><p>
133 <item><ref id="peekbsys" name="peekbsys">
134 <item><ref id="peekwsys" name="peekwsys">
135 <item><ref id="pokebsys" name="pokebsys">
136 <item><ref id="pokewsys" name="pokewsys">
140 <sect1><tt/cbm610.h/<label id="cbm610.h"><p>
143 <item><ref id="peekbsys" name="peekbsys">
144 <item><ref id="peekwsys" name="peekwsys">
145 <item><ref id="pokebsys" name="pokebsys">
146 <item><ref id="pokewsys" name="pokewsys">
150 <sect1><tt/conio.h/<label id="conio.h"><p>
153 <item><ref id="bgcolor" name="bgcolor">
154 <item><ref id="bordercolor" name="bordercolor">
155 <item><ref id="cclear" name="cclear">
156 <item><ref id="cclearxy" name="cclearxy">
157 <item><ref id="cgetc" name="cgetc">
158 <item><ref id="chline" name="chline">
159 <item><ref id="chlinexy" name="chlinexy">
160 <item><ref id="clrscr" name="clrscr">
161 <item><ref id="cprintf" name="cprintf">
162 <item><ref id="cputc" name="cputc">
163 <item><ref id="cputcxy" name="cputcxy">
164 <item><ref id="cputs" name="cputs">
165 <item><ref id="cputsxy" name="cputsxy">
166 <item><ref id="cursor" name="cursor">
167 <item><ref id="cvline" name="cvline">
168 <item><ref id="cvlinexy" name="cvlinexy">
169 <item><ref id="gotox" name="gotox">
170 <item><ref id="gotoxy" name="gotoxy">
171 <item><ref id="gotoy" name="gotoy">
172 <item><ref id="kbhit" name="kbhit">
173 <item><ref id="revers" name="revers">
174 <item><ref id="screensize" name="screensize">
175 <item><ref id="textcolor" name="textcolor">
176 <item><ref id="vcprintf" name="vcprintf">
177 <item><ref id="wherex" name="wherex">
178 <item><ref id="wherey" name="wherey">
182 <sect1><tt/ctype.h/<label id="ctype.h"><p>
185 <item><ref id="isalnum" name="isalnum">
186 <item><ref id="isalpha" name="isalpha">
187 <item><ref id="isascii" name="isascii">
188 <item><ref id="isblank" name="isblank">
189 <item><ref id="iscntrl" name="iscntrl">
190 <item><ref id="isdigit" name="isdigit">
191 <item><ref id="isgraph" name="isgraph">
192 <item><ref id="islower" name="islower">
193 <item><ref id="isprint" name="isprint">
194 <item><ref id="ispunct" name="ispunct">
195 <item><ref id="isspace" name="isspace">
196 <item><ref id="isupper" name="isupper">
197 <item><ref id="isxdigit" name="isxdigit">
198 <item><ref id="tolower" name="tolower">
199 <item><ref id="toupper" name="toupper">
203 <sect1><tt/dbg.h/<label id="dbg.h"><p>
208 <sect1><tt/dio.h/<label id="dio.h"><p>
213 <sect1><tt/em.h/<label id="em.h"><p>
216 <item><ref id="em_commit" name="em_commit">
217 <item><ref id="em_copyfrom" name="em_copyfrom">
218 <item><ref id="em_copyto" name="em_copyto">
219 <item><ref id="em_install" name="em_install">
220 <item><ref id="em_load_driver" name="em_load_driver">
221 <item><ref id="em_map" name="em_map">
222 <item><ref id="em_pagecount" name="em_pagecount">
223 <item><ref id="em_uninstall" name="em_uninstall">
224 <item><ref id="em_unload" name="em_unload">
225 <item><ref id="em_use" name="em_use">
229 <sect1><tt/errno.h/<label id="errno.h"><p>
234 <sect1><tt/fcntl.h/<label id="fcntl.h"><p>
237 <item><ref id="close" name="close">
238 <item><ref id="creat" name="creat">
239 <item><ref id="open" name="open">
243 <sect1><tt/geos.h/<label id="geos.h"><p>
248 <sect1><tt/joystick.h/<label id="joystick.h"><p>
251 <item><ref id="joy_count" name="joy_count">
252 <item><ref id="joy_install" name="joy_install">
253 <item><ref id="joy_load_driver" name="joy_load_driver">
254 <item><ref id="joy_read" name="joy_read">
255 <item><ref id="joy_uninstall" name="joy_uninstall">
256 <item><ref id="joy_unload" name="joy_unload">
260 <sect1><tt/locale.h/<label id="locale.h"><p>
263 <item><ref id="localeconv" name="localeconv">
264 <item><ref id="setlocale" name="setlocale">
268 <sect1><tt/modload.h/<label id="modload.h"><p>
271 <item><ref id="mod_load" name="mod_load">
272 <item><ref id="mod_free" name="mod_free">
276 <sect1><tt/mouse.h/<label id="mouse.h"><p>
279 <item><ref id="mouse_load_driver" name="mouse_load_driver">
280 <item><ref id="mouse_unload" name="mouse_unload">
281 <item><ref id="mouse_install" name="mouse_install">
282 <item><ref id="mouse_uninstall" name="mouse_uninstall">
283 <item><ref id="mouse_hide" name="mouse_hide">
284 <item><ref id="mouse_show" name="mouse_show">
285 <item><ref id="mouse_setbox" name="mouse_setbox">
286 <item><ref id="mouse_getbox" name="mouse_getbox">
287 <item><ref id="mouse_move" name="mouse_move">
288 <item><ref id="mouse_buttons" name="mouse_buttons">
289 <item><ref id="mouse_pos" name="mouse_pos">
290 <item><ref id="mouse_info" name="mouse_info">
291 <item><ref id="mouse_ioctl" name="mouse_ioctl">
297 <sect1><tt/nes.h/<label id="nes.h"><p>
302 <sect1><tt/o65.h/<label id="o65.h"><p>
304 The <tt/o65.h/ header file contains structure and constant definitions that
305 may be used when dealing with files in <htmlurl
306 url="http://www.6502.org/users/andre/o65/fileformat.html" name="o65 format">.
307 It does not declare any functions.
310 <sect1><tt/peekpoke.h/<label id="peekpoke.h"><p>
313 <item><ref id="PEEK" name="PEEK">
314 <item><ref id="PEEKW" name="PEEKW">
315 <item><ref id="POKE" name="POKE">
316 <item><ref id="POKEW" name="POKEW">
320 <sect1><tt/pet.h/<label id="pet.h"><p>
325 <sect1><tt/plus4.h/<label id="plus4.h"><p>
330 <sect1><tt/serial.h/<label id="serial.h"><p>
334 <item><ref id="ser_load_driver" name="ser_load_driver">
335 <item><ref id="ser_unload" name="ser_unload">
336 <item><ref id="ser_install" name="ser_install">
337 <item><ref id="ser_uninstall" name="ser_uninstall">
338 <item><ref id="ser_open" name="ser_open">
339 <item><ref id="ser_close" name="ser_close">
340 <item><ref id="ser_get" name="ser_get">
341 <item><ref id="ser_put" name="ser_put">
342 <item><ref id="ser_status" name="ser_status">
343 <item><ref id="ser_ioctl" name="ser_ioctl">
350 <sect1><tt/setjmp.h/<label id="setjmp.h"><p>
353 <item><ref id="setjmp" name="setjmp">
354 <item><ref id="longjmp" name="longjmp">
358 <sect1><tt/signal.h/<label id="signal.h"><p>
361 <item><ref id="raise" name="raise">
362 <item><ref id="signal" name="signal">
366 <sect1><tt/stdarg.h/<label id="stdarg.h"><p>
371 <sect1><tt/stdbool.h/<label id="stdbool.h"><p>
376 <sect1><tt/stddef.h/<label id="stddef.h"><p>
379 <item><ref id="offsetof" name="offsetof">
383 <sect1><tt/stdio.h/<label id="stdio.h"><p>
386 <item><ref id="clearerr" name="clearerr">
387 <!-- <item><ref id="fclose" name="fclose"> -->
388 <!-- <item><ref id="fdopen" name="fdopen"> -->
389 <item><ref id="feof" name="feof">
390 <item><ref id="ferror" name="ferror">
391 <!-- <item><ref id="fflush" name="fflush"> -->
392 <!-- <item><ref id="fgetc" name="fgetc"> -->
393 <!-- <item><ref id="fgetpos" name="fgetpos"> -->
394 <!-- <item><ref id="fgets" name="fgets"> -->
395 <item><ref id="fileno" name="fileno">
396 <!-- <item><ref id="fopen" name="fopen"> -->
397 <!-- <item><ref id="fprintf" name="fprintf"> -->
398 <!-- <item><ref id="fputc" name="fputc"> -->
399 <!-- <item><ref id="fputs" name="fputs"> -->
400 <!-- <item><ref id="fread" name="fread"> -->
401 <!-- <item><ref id="freopen" name="freopen"> -->
402 <!-- <item><ref id="fscanf" name="fscanf"> -->
403 <!-- <item><ref id="fseek" name="fseek"> -->
404 <!-- <item><ref id="fsetpos" name="fsetpos"> -->
405 <!-- <item><ref id="ftell" name="ftell"> -->
406 <!-- <item><ref id="fwrite" name="fwrite"> -->
407 <!-- <item><ref id="getc" name="getc"> -->
408 <!-- <item><ref id="getchar" name="getchar"> -->
409 <!-- <item><ref id="gets" name="gets"> -->
410 <!-- <item><ref id="printf" name="printf"> -->
411 <!-- <item><ref id="putc" name="putc"> -->
412 <!-- <item><ref id="putchar" name="putchar"> -->
413 <!-- <item><ref id="puts" name="puts"> -->
414 <item><ref id="rename" name="rename">
415 <item><ref id="remove" name="remove">
416 <!-- <item><ref id="rewind" name="rewind"> -->
417 <!-- <item><ref id="scanf" name="scanf"> -->
418 <!-- <item><ref id="snprintf" name="snprintf"> -->
419 <!-- <item><ref id="sprintf" name="sprintf"> -->
420 <!-- <item><ref id="sscanf" name="sscanf"> -->
421 <!-- <item><ref id="vfprintf" name="vfprintf"> -->
422 <!-- <item><ref id="vfscanf" name="vfscanf"> -->
423 <!-- <item><ref id="vprintf" name="vprintf"> -->
424 <!-- <item><ref id="vscanf" name="vscanf"> -->
425 <!-- <item><ref id="vsnprintf" name="vsnprintf"> -->
426 <!-- <item><ref id="vsprintf" name="vsprintf"> -->
427 <!-- <item><ref id="vsscanf" name="vsscanf"> -->
433 <sect1><tt/stdlib.h/<label id="stdlib.h"><p>
436 <item><ref id="_heapadd" name="_heapadd">
437 <item><ref id="_heapblocksize" name="_heapblocksize">
438 <item><ref id="_heapmaxavail" name="_heapmaxavail">
439 <item><ref id="_heapmemavail" name="_heapmemavail">
440 <item><ref id="_poserror" name="_poserror">
441 <item><ref id="_randomize" name="_randomize">
442 <item><ref id="_swap" name="_swap">
443 <item><ref id="abort" name="abort">
444 <item><ref id="abs" name="abs">
445 <item><ref id="atexit" name="atexit">
446 <item><ref id="atoi" name="atoi">
447 <item><ref id="atol" name="atol">
448 <item><ref id="bsearch" name="bsearch">
449 <item><ref id="calloc" name="calloc">
450 <item><ref id="div" name="div">
451 <item><ref id="exit" name="exit">
452 <item><ref id="free" name="free">
453 <item><ref id="getenv" name="getenv">
454 <item><ref id="itoa" name="itoa">
455 <item><ref id="labs" name="labs">
456 <item><ref id="ltoa" name="ltoa">
457 <item><ref id="malloc" name="malloc">
458 <item><ref id="perror" name="perror">
459 <item><ref id="qsort" name="qsort">
460 <item><ref id="rand" name="rand">
461 <item><ref id="realloc" name="realloc">
462 <item><ref id="srand" name="srand">
463 <item><ref id="ultoa" name="ultoa">
464 <item><ref id="utoa" name="utoa">
468 <sect1><tt/string.h/<label id="string.h"><p>
471 <item><ref id="_stroserror" name="_stroserror">
472 <item><ref id="bzero" name="bzero">
473 <item><ref id="memchr" name="memchr">
474 <item><ref id="memcpy" name="memcpy">
475 <item><ref id="memmove" name="memmove">
476 <item><ref id="memset" name="memset">
477 <item><ref id="strcasecmp" name="strcasecmp">
478 <item><ref id="strcat" name="strcat">
479 <item><ref id="strchr" name="strchr">
480 <item><ref id="strcmp" name="strcmp">
481 <item><ref id="strcoll" name="strcoll">
482 <item><ref id="strcpy" name="strcpy">
483 <item><ref id="strcspn" name="strcspn">
484 <item><ref id="strdup" name="strdup">
485 <item><ref id="strerror" name="strerror">
486 <item><ref id="stricmp" name="stricmp">
487 <item><ref id="strlen" name="strlen">
488 <item><ref id="strlower" name="strlower">
489 <item><ref id="strlwr" name="strlwr">
490 <item><ref id="strncat" name="strncat">
491 <item><ref id="strncmp" name="strncmp">
492 <item><ref id="strncpy" name="strncpy">
493 <item><ref id="strrchr" name="strrchr">
494 <item><ref id="strspn" name="strspn">
495 <item><ref id="strstr" name="strstr">
496 <item><ref id="strtok" name="strtok">
497 <item><ref id="strxfrm" name="strxfrm">
498 <item><ref id="strupper" name="strupper">
499 <item><ref id="strupr" name="strupr">
505 <sect1><tt/tgi.h/<label id="tgi.h"><p>
508 <item><ref id="tgi_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="lseek" name="lseek"> -->
572 <!-- <item><ref id="mkdir" name="mkdir"> -->
573 <!-- <item><ref id="read" name="read"> -->
574 <!-- <item><ref id="rmdir" name="rmdir"> -->
575 <item><ref id="sleep" name="sleep">
576 <item><ref id="unlink" name="unlink">
577 <!-- <item><ref id="write" name="write"> -->
583 <sect1><tt/vic20.h/<label id="vic20.h"><p>
588 <sect1><tt/zlib.h/<label id="zlib.h"><p>
593 <sect>Alphabetical function reference<p>
595 <sect1>_heapadd<label id="_heapadd"><p>
599 <tag/Function/Add a block to the heap.
600 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
601 <tag/Declaration/<tt/void __fastcall__ _heapadd (void* mem, size_t size);/
602 <tag/Description/The function adds a block of raw memory to the heap.
605 <item>The minimum blocksize that can be added is 6 bytes; the function will
606 ignore smaller blocks.
608 <tag/Availability/cc65
610 <ref id="_heapblocksize" name="_heapblocksize">,
611 <ref id="_heapmaxavail" name="_heapmaxavail">,
612 <ref id="_heapmemavail" name="_heapmemavail">,
613 <ref id="calloc" name="calloc">,
614 <ref id="free" name="free">,
615 <ref id="malloc" name="malloc">,
616 <ref id="realloc" name="realloc">
622 <sect1>_heapblocksize<label id="_heapblocksize"><p>
626 <tag/Function/Return the size of an allocated block.
627 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
628 <tag/Declaration/<tt/size_t __fastcall__ _heapblocksize (const void* block);/
629 <tag/Description/The function returns the size of a block that must have
630 previously been allocated by <tt/<ref id="malloc" name="malloc">/, <tt/<ref
631 id="calloc" name="calloc">/ or <tt/<ref id="realloc" name="realloc">/.
634 <item>Passing a pointer to a block that was is not the result of one of the
635 allocation functions, or that has been free'd will give unpredicable results.
637 <tag/Availability/cc65
639 <ref id="_heapadd" name="_heapadd">,
640 <ref id="_heapmaxavail" name="_heapmaxavail">,
641 <ref id="_heapmemavail" name="_heapmemavail">,
642 <ref id="calloc" name="calloc">,
643 <ref id="free" name="free">,
644 <ref id="malloc" name="malloc">,
645 <ref id="realloc" name="realloc">
651 <sect1>_heapmaxavail<label id="_heapmaxavail"><p>
655 <tag/Function/Return the largest block that is available on the heap.
656 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
657 <tag/Declaration/<tt/size_t __fastcall__ _heapmaxavail (void);/
658 <tag/Description/The function returns the size of the largest block that may
659 be allocated from the heap using <tt/<ref id="malloc" name="malloc">/.
660 <tag/Availability/cc65
662 <ref id="_heapadd" name="_heapadd">,
663 <ref id="_heapblocksize" name="_heapblocksize">,
664 <ref id="_heapmemavail" name="_heapmemavail">,
665 <ref id="calloc" name="calloc">,
666 <ref id="free" name="free">,
667 <ref id="malloc" name="malloc">,
668 <ref id="realloc" name="realloc">
674 <sect1>_heapmemavail<label id="_heapmemavail"><p>
678 <tag/Function/Return the total available space on the heap.
679 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
680 <tag/Declaration/<tt/size_t __fastcall__ _heapmemavail (void);/
681 <tag/Description/The function returns the total number of bytes available on
685 <item>This function is of less use than usually assumed, since the returned
686 heap space may be available but not in one block. So even if this function
687 says that several times more heap space is available than needed, <ref
688 id="malloc" name="malloc"> may still return <tt/NULL/.
690 <tag/Availability/cc65
692 <ref id="_heapadd" name="_heapadd">,
693 <ref id="_heapblocksize" name="_heapblocksize">,
694 <ref id="_heapmaxavail" name="_heapmaxavail">,
695 <ref id="calloc" name="calloc">,
696 <ref id="free" name="free">,
697 <ref id="malloc" name="malloc">,
698 <ref id="realloc" name="realloc">
704 <sect1>_poserror<label id="_poserror"><p>
708 <tag/Function/Print an error message for the error in <tt/_oserrno/.
709 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
710 <tag/Declaration/<tt/void __fastcall__ _poserror (const char* msg);/
711 <tag/Description/<tt/_poserror/ prints an error message to <tt/stderr/. If
712 <tt/msg/ is not <tt/NULL/ and not an empty string, it is printed followed by
713 a colon and a blank. Then the error message for the current contents of
714 <tt/_oserrno/ are printed followed by a newline. The message output is the
715 same as returned by <tt/<ref id="_stroserror" name="_stroserror">/ with an
716 argument of <tt/_oserrno/.
719 <item>Since operating system specific error code are - you guessed it -
720 operating system specific, the value in <tt/_oserror/ and the message that is
721 printed depend on the cc65 target.
722 <item>The function is only available as fastcall function, so it may only
723 be used in presence of a prototype.
725 <tag/Availability/cc65
727 <ref id="_stroserror" name="_stroserror">,
728 <ref id="perror" name="perror">
734 <sect1>_randomize<label id="_randomize"><p>
738 <tag/Function/Initialize the pseudo random number generator.
739 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
740 <tag/Declaration/<tt/void _randomize (void);/
741 <tag/Description/The function initializes the random number generator with
742 a seed derived from fast changing hardware events, so the seed itself can be
743 considered random to a certain degree.
744 <tag/Limits/<itemize>
745 <item>The randomness of the seed depends on the machine hardware.
747 <tag/Availability/cc65
749 <ref id="rand" name="rand">,
750 <ref id="srand" name="srand">
756 <sect1>_stroserror<label id="_stroserror"><p>
760 <tag/Function/Return a string describing an OS specific error code.
761 <tag/Header/<tt/<ref id="string.h" name="string.h">/
762 <tag/Declaration/<tt/const char* __fastcall__ _stroserror (unsigned char errcode);/
763 <tag/Description/<tt/_stroserror/ will return a string describing the given
764 operating system specific error code.
765 <tag/Limits/<itemize>
766 <item>Since operating system specific error code are - you guessed it -
767 operating system specific, the parameter and the string returned depend on the
769 <item>The function is only available as fastcall function, so it may only be
770 used in presence of a prototype.
772 <tag/Availability/cc65
774 <ref id="strerror" name="strerror">
780 <sect1>_swap<label id="_swap"><p>
784 <tag/Function/Swap the contents of memory areas.
785 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
786 <tag/Declaration/<tt/void __fastcall__ _swap (void* p, void* q, size_t size);/
787 <tag/Description/<tt/_swap/ will swap (exchange) the contents of the two memory
788 areas pointed to by <tt/p/ and <tt/q/. Both memory areas are assumed to be
789 <tt/size/ bytes in size.
790 <tag/Limits/<itemize>
791 <item>The memory areas may not overlap, otherwise the results are undefined.
792 <item>The function is only available as fastcall function, so it may only be
793 used in presence of a prototype.
795 <tag/Availability/cc65
797 <ref id="memcpy" name="memcpy">,
798 <ref id="memmove" name="memmove">
804 <sect1>_sys<label id="_sys"><p>
808 <tag/Function/Call a subroutine passing register values.
809 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
810 <tag/Declaration/<tt/void __fastcall__ _sys (struct regs* r);/
811 <tag/Description/The function will call the subroutine at the address
812 specified in the <tt/pc/ member of the passed <tt/regs/ structure. All
813 registers and the CPU flags are set to the values given in the <tt/regs/
814 structure. On return from the subroutine, the new values of the registers and
815 flags are stored back overwriting the old values.
816 <tag/Limits/<itemize>
817 <item>Bits 4 and 5 of the flags value in the <tt/regs/ structure are ignored
818 when calling the subroutine (they are unchanged from their current values).
819 <item>The function is only available as fastcall function, so it may only be
820 used in presence of a prototype.
822 <tag/Availability/cc65
828 <sect1>BRK<label id="BRK"><p>
832 <tag/Function/Insert a 6502 BRK instrunction into the code.
833 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
834 <tag/Declaration/<tt/void BRK (void);/
835 <tag/Description/The function will insert a 6502 BRK instruction into the code
836 which may be used to trigger a debugger.
837 <tag/Limits/<itemize>
838 <item>The function is actually a macro.
839 <item>The inserted instruction may lead to unexpected results if no debugger
842 <tag/Availability/cc65
844 <ref id="CLI" name="CLI">,
845 <ref id="SEI" name="SEI">
851 <sect1>CLI<label id="CLI"><p>
855 <tag/Function/Insert a 6502 CLI instrunction into the code.
856 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
857 <tag/Declaration/<tt/void CLI (void);/
858 <tag/Description/The function will insert a 6502 CLI instruction into the code,
859 so interrupts are enabled. Enabling interrupts has no effects if they are
860 already enabled (the default).
861 <tag/Limits/<itemize>
862 <item>The function is actually a macro.
863 <item>Disabling interrupts may lead to unexpected results.
865 <tag/Availability/cc65
867 <ref id="BRK" name="BRK">,
868 <ref id="SEI" name="SEI">
874 <sect1>PEEK<label id="PEEK"><p>
878 <tag/Function/Read a byte from memory.
879 <tag/Header/<tt/<ref id="peekpoke.h" name="peekpoke.h">/
880 <tag/Declaration/<tt/unsigned char PEEK (unsigned addr);/
881 <tag/Description/The function will read the absolute memory given by <tt/addr/
882 and return the value read.
883 <tag/Limits/<itemize>
884 <item>The function is actually a macro.
885 <item>This function depends highly on the platform and environment.
887 <tag/Availability/cc65
889 <ref id="PEEKW" name="PEEKW">,
890 <ref id="POKE" name="POKE">
896 <sect1>PEEKW<label id="PEEKW"><p>
900 <tag/Function/Read a word (two bytes) from memory.
901 <tag/Header/<tt/<ref id="peekpoke.h" name="peekpoke.h">/
902 <tag/Declaration/<tt/unsigned PEEKW (unsigned addr);/
903 <tag/Description/The function will read the absolute memory given by <tt/addr/
904 and return the value read. The byte read from the higher address is the high
905 byte of the return value.
906 <tag/Limits/<itemize>
907 <item>The function is actually a macro.
908 <item>This function depends highly on the platform and environment.
909 <item>The order in which the two bytes are read is unspecified and may
910 depend of the address expression used.
912 <tag/Availability/cc65
914 <ref id="PEEK" name="PEEK">,
915 <ref id="POKE" name="POKE">
921 <sect1>POKE<label id="POKE"><p>
925 <tag/Function/Write a byte to memory.
926 <tag/Header/<tt/<ref id="peekpoke.h" name="peekpoke.h">/
927 <tag/Declaration/<tt/void POKE (unsigned addr, unsigned char val);/
928 <tag/Description/The function writes the value <tt/val/ to the absolute
929 memory address given by <tt/addr/.
930 <tag/Limits/<itemize>
931 <item>The function is actually a macro.
932 <item>This function depends highly on the platform and environment.
933 <item>Careless use will cause the program to act strange or may crash the
936 <tag/Availability/cc65
938 <ref id="PEEK" name="PEEK">,
939 <ref id="POKEW" name="POKEW">
945 <sect1>POKEW<label id="POKEW"><p>
949 <tag/Function/Write a word (two bytes) to memory.
950 <tag/Header/<tt/<ref id="peekpoke.h" name="peekpoke.h">/
951 <tag/Declaration/<tt/void POKEW (unsigned addr, unsigned val);/
952 <tag/Description/The function writes the value <tt/val/ to the absolute
953 memory address given by <tt/addr/. The low byte of <tt/val/ is written to
954 the <tt/addr/, the high byte is written to <tt/addr+1/.
955 <tag/Limits/<itemize>
956 <item>The function is actually a macro.
957 <item>This function depends highly on the platform and environment.
958 <item>Careless use will cause the program to act strange or may crash the
960 <item>The order in which the two bytes are written is unspecified and may
961 depend of the address expression used.
963 <tag/Availability/cc65
965 <ref id="PEEK" name="PEEK">,
966 <ref id="POKE" name="POKE">
972 <sect1>SEI<label id="SEI"><p>
976 <tag/Function/Insert a 6502 SEI instrunction into the code.
977 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
978 <tag/Declaration/<tt/void SEI (void);/
979 <tag/Description/The function will insert a 6502 SEI instruction into the code,
980 so interrupts are disabled. Note that non maskable interrupts cannot be
982 <tag/Limits/<itemize>
983 <item>The function is actually a macro.
984 <item>Disabling interrupts may lead to unexpected results.
986 <tag/Availability/cc65
988 <ref id="BRK" name="BRK">,
989 <ref id="CLI" name="CLI">
995 <sect1>abort<label id="abort"><p>
999 <tag/Function/Terminates a program abnormally.
1000 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1001 <tag/Declaration/<tt/void abort (void);/
1002 <tag/Description/<tt/abort/ raises <tt/SIGABRT/, writes a termination message
1003 on stderr, then terminates the program with an exit code of 3.
1004 <tag/Availability/ISO 9899
1006 <ref id="assert" name="assert">,
1007 <ref id="exit" name="exit">,
1008 <ref id="raise" name="raise">
1014 <sect1>abs<label id="abs"><p>
1018 <tag/Function/Returns the absolute value of an integer.
1019 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1020 <tag/Declaration/<tt/int __fastcall__ abs (int v);/
1021 <tag/Description/<tt/abs/ returns the absolute value of the argument passed to
1023 <tag/Limits/<itemize>
1024 <item>The return value is undefined if <tt/INT_MIN/ is passed to the function.
1025 <item>The function is only available as fastcall function, so it may only be
1026 used in presence of a prototype.
1028 <tag/Availability/ISO 9899
1030 <ref id="labs" name="labs">
1036 <sect1>assert<label id="assert"><p>
1040 <tag/Function/Test a condition and possibly abort.
1041 <tag/Header/<tt/<ref id="assert.h" name="assert.h">/
1042 <tag/Declaration/<tt/void assert (int cond);/
1043 <tag/Description/<tt/assert/ is a macro that expands to a <tt/id/
1044 statement. If the condition evaluates t zero (false), assert prints a message
1045 on stderr and aborts the program.
1046 <tag/Limits/<itemize>
1047 <item>The function is actually a macro.
1049 <tag/Availability/ISO 9899
1051 <ref id="abort" name="abort">,
1052 <ref id="exit" name="exit">
1058 <sect1>atexit<label id="atexit"><p>
1062 <tag/Function/Register an exit function.
1063 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1064 <tag/Declaration/<tt/int __fastcall__ atexit (void (*exitfunc) (void));/
1065 <tag/Description/<tt/atexit/ registers the function pointed to by
1066 <tt/exitfunc/ as an exit function. Exit functions are called when the program
1067 terminates, they are called in LIFO order (the last function registered is
1068 called first). <tt/atexit/ returns zero on success and a nonzero value on
1070 <tag/Limits/<itemize>
1071 <item>A maximum of 5 exit functions can be registered.
1072 <item>There is no way to unregister an exit function.
1073 <item>The function is only available as fastcall function, so it may only be
1074 used in presence of a prototype.
1076 <tag/Availability/ISO 9899
1078 <ref id="abort" name="abort">,
1079 <ref id="exit" name="exit">
1085 <sect1>atoi<label id="atoi"><p>
1089 <tag/Function/Convert a string to an integer.
1090 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1091 <tag/Declaration/<tt/int __fastcall__ atoi (const char* s);/
1092 <tag/Description/<tt/atoi/ converts the given string into an integer.
1093 Conversion stops as soon as any invalid character is encountered.
1094 <tag/Limits/<itemize>
1095 <item>There is no way to detect any conversion errors.
1096 <item>The function does not check for an numerical overflow when converting.
1097 <item>The function is only available as fastcall function, so it may only be
1098 used in presence of a prototype.
1100 <tag/Availability/ISO 9899
1102 <ref id="atol" name="atol">,
1103 <ref id="itoa" name="itoa">,
1104 <ref id="ltoa" name="ltoa">,
1105 <ref id="ultoa" name="ultoa">,
1106 <ref id="utoa" name="utoa">
1112 <sect1>atol<label id="atol"><p>
1116 <tag/Function/Convert a string to a long integer.
1117 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1118 <tag/Declaration/<tt/long __fastcall__ atol (const char* s);/
1119 <tag/Description/<tt/atol/ converts the given string into a long integer.
1120 Conversion stops as soon as any invalid character is encountered.
1121 <tag/Limits/<itemize>
1122 <item>There is no way to detect any conversion errors.
1123 <item>The function does not check for an numerical overflow when converting.
1124 <item>The function is only available as fastcall function, so it may only be
1125 used in presence of a prototype.
1127 <tag/Availability/ISO 9899
1129 <ref id="atoi" name="atoi">,
1130 <ref id="itoa" name="itoa">,
1131 <ref id="ltoa" name="ltoa">,
1132 <ref id="ultoa" name="ultoa">,
1133 <ref id="utoa" name="utoa">
1139 <sect1>bgcolor<label id="bgcolor"><p>
1143 <tag/Function/Set the background text color.
1144 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1145 <tag/Declaration/<tt/unsigned char __fastcall__ bgcolor (unsigned char color);/
1146 <tag/Description/The function will set a new background color and return the
1147 old (current) one. The background color is valid for the whole text output
1148 area of the screen, not just for new text.
1149 <tag/Limits/<itemize>
1150 <item>Background colors are system dependent. The function may have no effect
1151 on systems where the background color cannot be changed.
1152 <item>The function is only available as fastcall function, so it may only be
1153 used in presence of a prototype.
1155 <tag/Availability/cc65
1157 <ref id="bordercolor" name="bordercolor">,
1158 <ref id="textcolor" name="textcolor">
1164 <sect1>bordercolor<label id="bordercolor"><p>
1168 <tag/Function/Set the border (frame) color.
1169 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1170 <tag/Declaration/<tt/unsigned char __fastcall__ bordercolor (unsigned char color);/
1171 <tag/Description/The function will set a new border color. It returns the old
1172 (current) border color.
1173 <tag/Limits/<itemize>
1174 <item>Border colors are system dependent. The function may have no effect
1175 on systems where the border color cannot be changed.
1176 <item>The function is only available as fastcall function, so it may only
1177 be used in presence of a prototype.
1179 <tag/Availability/cc65
1181 <ref id="bgcolor" name="bgcolor">,
1182 <ref id="textcolor" name="textcolor">
1188 <sect1>bsearch<label id="bsearch"><p>
1192 <tag/Function/Do a binary search in a sorted array.
1193 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1194 <tag/Declaration/<tt/void* __fastcall__ bsearch (const void* key,
1195 const void* base, size_t n, size_t size,
1196 int (*cmp) (const void*, const void*));/
1197 <tag/Description/<tt/bsearch/ searches a sorted array for a member that
1198 matches the one pointed to by <tt/key/. <tt/base/ is the address of the array,
1199 <tt/n/ is the number of elements, <tt/size/ the size of an element and <tt/cmp/
1200 the function used to compare the members against the key. The function returns
1201 a pointer to the member found, or <tt/NULL/ if there was no match.
1204 <item>The contents of the array must be sorted in ascending order according to
1205 the compare function given.
1206 <item>If there are multiple members that match the key, the function will
1207 return one of the members.
1208 <item>The function is only available as fastcall function, so it may only
1209 be used in presence of a prototype.
1211 <tag/Availability/ISO 9899
1213 <ref id="qsort" name="qsort">
1219 <sect1>bzero<label id="bzero"><p>
1223 <tag/Function/Fill a memory area with zeroes.
1224 <tag/Header/<tt/<ref id="string.h" name="string.h">/
1225 <tag/Declaration/<tt/void __fastcall__ bzero (void* p, size_t count);/
1226 <tag/Description/<tt/bzero/ fills the memory area pointed to by <tt/p/ with
1230 <item>The function is non standard and therefore only available in non ANSI
1231 mode. You should use <tt/<ref id="memset" name="memset">/ instead.
1232 <item>The function is only available as fastcall function, so it may only
1233 be used in presence of a prototype.
1235 <tag/Availability/cc65
1237 <ref id="_swap" name="_swap">,
1238 <ref id="memcpy" name="memcpy">,
1239 <ref id="memmove" name="memmove">,
1240 <ref id="memset" name="memset">,
1246 <sect1>c64mode<label id="c64mode"><p>
1250 <tag/Function/Switch the C128 into C64 compatible mode.
1251 <tag/Header/<tt/<ref id="c128.h" name="c128.h">/
1252 <tag/Declaration/<tt/void c64mode (void);/
1253 <tag/Description/The function will cause the machine to reboot into C64 mode.
1254 <tag/Limits/<itemize>
1255 <item>The function is specific to the C128.
1256 <item>The function will not return to the caller.
1258 <tag/Availability/C128
1264 <sect1>calloc<label id="calloc"><p>
1268 <tag/Function/Allocate and clear memory.
1269 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1270 <tag/Declaration/<tt/void* __fastcall__ calloc (size_t n, size_t size);/
1271 <tag/Description/<tt/calloc/ allocates memory for an array of <tt/n/ elements
1272 of size <tt/size/, clears the whole block with binary zeroes and returns a
1273 pointer to it. On error (not enough memory available), <tt/calloc/ returns
1277 <item>Clearing the memory may not have the expected effect on all platforms:
1278 pointers in the block may not be <tt/NULL/ and floating point variables may
1279 not be zero (0.0). In other words: The "clearing" effect of this function
1280 should be used with care for portable programs.
1281 <item>The function is only available as fastcall function, so it may only
1282 be used in presence of a prototype.
1284 <tag/Availability/ISO 9899
1286 <ref id="_heapadd" name="_heapadd">,
1287 <ref id="_heapblocksize" name="_heapblocksize">,
1288 <ref id="_heapmaxavail" name="_heapmaxavail">,
1289 <ref id="_heapmemavail" name="_heapmemavail">,
1290 <ref id="free" name="free">,
1291 <ref id="malloc" name="malloc">,
1292 <ref id="realloc" name="realloc">
1298 <sect1>cclear<label id="cclear"><p>
1302 <tag/Function/Clear part of a line (write a given number of spaces).
1303 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1304 <tag/Declaration/<tt/void __fastcall__ cclear (unsigned char length);/
1305 <tag/Description/The function clears part of a line by writing <tt/length/
1306 spaces in the current text color.
1307 <tag/Limits/<itemize>
1308 <item>The function is only available as fastcall function, so it may
1309 only be used in presence of a prototype.
1311 <tag/Availability/cc65
1313 <ref id="cclearxy" name="cclearxy">,
1314 <ref id="clrscr" name="clrscr">
1320 <sect1>cclearxy<label id="cclearxy"><p>
1324 <tag/Function/Clear part of a line (write a given number of spaces) starting
1325 at a specific screen position.
1326 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1327 <tag/Declaration/<tt/void __fastcall__ cclearxy (unsigned char x, unsigned char y, unsigned char length);/
1328 <tag/Description/The function moves the cursor to a specific position, and
1329 will then clear part of the line by writing <tt/length/ spaces in the current
1331 <tag/Limits/<itemize>
1332 <item>The function is only available as fastcall function, so it may
1333 only be used in presence of a prototype.
1335 <tag/Availability/cc65
1337 <ref id="cclear" name="cclear">,
1338 <ref id="clrscr" name="clrscr">
1344 <sect1>cgetc<label id="cgetc"><p>
1348 <tag/Function/Read a character from the keyboard.
1349 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1350 <tag/Declaration/<tt/char cgetc (void);/
1351 <tag/Description/The function reads a character from the keyboard. If there is
1352 no character available, <tt/cgetc/ waits until the user presses a key. If the
1353 cursor is enabled by use of the <tt/cursor/ function, a blinking cursor is
1354 displayed while waiting.
1355 <tag/Limits/<itemize>
1356 <item>If the system supports a keyboard buffer, <tt/cgetc/ will fetch a key
1357 from this buffer and wait only if the buffer is empty.
1359 <tag/Availability/cc65
1361 <ref id="cursor" name="cursor">,
1362 <ref id="kbhit" name="kbhit">
1368 <sect1>chline<label id="chline"><p>
1372 <tag/Function/Output a horizontal line in text mode.
1373 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1374 <tag/Declaration/<tt/void __fastcall__ chline (unsigned char length);/
1375 <tag/Description/The function outputs a horizontal line with the given length
1376 starting at the current cursor position.
1377 <tag/Limits/<itemize>
1378 <item>The character used to draw the horizontal line is system dependent.
1379 If available, a line drawing character is used. Drawing a line that is partially
1380 off screen leads to undefined behaviour.
1381 <item>The function is only available as fastcall function, so it may only be
1382 used in presence of a prototype.
1384 <tag/Availability/cc65
1386 <ref id="chlinexy" name="chlinexy">,
1387 <ref id="cvline" name="cvline">,
1388 <ref id="cvlinexy" name="cvlinexy">
1394 <sect1>chlinexy<label id="chlinexy"><p>
1398 <tag/Function/Output a horizontal line at a given position in text mode.
1399 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1400 <tag/Declaration/<tt/void __fastcall__ chlinexy (unsigned char x, unsigned char y, unsigned char length);/
1401 <tag/Description/The function outputs a horizontal line with the given length
1402 starting at a given position.
1403 <tag/Limits/<itemize>
1404 <item>The character used to draw the horizontal line is system dependent.
1405 If available, a line drawing character is used. Drawing a line that is partially
1406 off screen leads to undefined behaviour.
1407 <item>The function is only available as fastcall function, so it may only be
1408 used in presence of a prototype.
1410 <tag/Availability/cc65
1412 <ref id="chline" name="chline">,
1413 <ref id="cvline" name="cvline">,
1414 <ref id="cvlinexy" name="cvlinexy">
1420 <sect1>clearerr<label id="clearerr"><p>
1424 <tag/Function/Clear error and end-of-file status of a stream.
1425 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
1426 <tag/Declaration/<tt/void __fastcall__ clearerr (FILE* f);/
1427 <tag/Description/<tt/clearerr/ clears the error and end-of-file status
1428 indicators for the stream <tt/f/.
1429 <tag/Limits/<itemize>
1430 <item>The function is only available as fastcall function, so it may only be
1431 used in presence of a prototype.
1433 <tag/Availability/ISO 9899
1435 <ref id="feof" name="feof">,
1436 <ref id="ferror" name="ferror">
1442 <sect1>clrscr<label id="clrscr"><p>
1446 <tag/Function/Clear the text screen.
1447 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1448 <tag/Declaration/<tt/void clrscr (void);/
1449 <tag/Description/The function clears the text screen and moves the cursor to
1450 the upper left corner.
1451 <tag/Availability/cc65
1453 <ref id="cclear" name="cclear">,
1454 <ref id="cclearxy" name="cclearxy">
1460 <sect1>close<label id="close"><p>
1464 <tag/Function/Close a file descriptor.
1465 <tag/Header/<tt/<ref id="fcntl.h" name="fcntl.h">/
1466 <tag/Declaration/<tt/int __fastcall__ close (int fd);/
1467 <tag/Description/The function closes the given file descriptor. It returns zero
1468 on success and -1 on error. If an error occurs, the cause can be determined by
1469 reading the <tt/errno/ variable.
1470 <tag/Limits/<itemize>
1471 <item>The function is only available as fastcall function, so it may only
1472 be used in presence of a prototype.
1474 <tag/Availability/POSIX 1003.1
1476 <ref id="creat" name="creat">,
1477 <ref id="open" name="open">
1483 <sect1>creat<label id="creat"><p>
1487 <tag/Function/Create a file.
1488 <tag/Header/<tt/<ref id="fcntl.h" name="fcntl.h">/
1489 <tag/Declaration/<tt/int __fastcall__ creat (const char* name, unsigned mode);/
1490 <tag/Description/<tt/creat/ creates a new file and returns the file descriptor
1491 associated with it. On error, -1 is returned and an error code is stored in
1493 <tag/Limits/<itemize>
1494 <item><tt/creat/ is identical to calling <tt/<ref id="open" name="open">/ with
1495 <tt/flags/ equal to <tt/O_WRONLY | O_CREAT | O_TRUNC/.
1496 <item>The function is only available as fastcall function, so it may only
1497 be used in presence of a prototype.
1499 <tag/Availability/POSIX 1003.1
1501 <ref id="close" name="close">,
1502 <ref id="open" name="open">
1508 <sect1>cprintf<label id="cprintf"><p>
1512 <tag/Function/Formatted output to the console.
1513 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1514 <tag/Declaration/<tt/int cprintf (const char* format, ...);/
1515 <tag/Description/The arguments are converted to text where necessary and
1516 formatted according to the format string given. The resulting string is output
1517 to the console. <tt/cprintf/ supports the same format specifiers as
1518 <tt/printf/. <!-- <tt/<ref id="printf" name="printf">/. -->
1519 <tag/Limits/<itemize>
1520 <item>Like all other <tt/conio/ output functions, <tt/cprintf/ distinguishes
1521 between <tt/\r/ and <tt/\n/.
1523 <tag/Availability/cc65
1525 <ref id="cputc" name="cputc">,
1526 <ref id="cputcxy" name="cputcxy">,
1527 <ref id="cputs" name="cputs">,
1528 <ref id="cputsxy" name="cputsxy">,
1529 <ref id="vcprintf" name="vcprintf">
1535 <sect1>cputc<label id="cputc"><p>
1539 <tag/Function/Output a character directly to the console.
1540 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1541 <tag/Declaration/<tt/void __fastcall__ cputc (char c);/
1542 <tag/Description/Output one character to the console at the current cursor
1544 <tag/Limits/<itemize>
1545 <item>Like all other <tt/conio/ output functions, <tt/cputc/ distinguishes
1546 between <tt/\r/ and <tt/\n/.
1547 <item>The function is only available as fastcall function, so it may only
1548 be used in presence of a prototype.
1550 <tag/Availability/cc65
1552 <ref id="cprintf" name="cprintf">,
1553 <ref id="cputcxy" name="cputcxy">,
1554 <ref id="cputs" name="cputs">,
1555 <ref id="cputsxy" name="cputsxy">,
1556 <ref id="vcprintf" name="vcprintf">
1562 <sect1>cputcxy<label id="cputcxy"><p>
1566 <tag/Function/Output a character at a specific screen position.
1567 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1568 <tag/Declaration/<tt/void __fastcall__ cputcxy (unsigned char x, unsigned char y, char c);/
1569 <tag/Description/<tt/cputcxy/ moves the cursor to the given x/y position on
1570 the screen and outputs one character.
1571 <tag/Limits/<itemize>
1572 <item>Like all other <tt/conio/ output functions, <tt/cputcxy/ distinguishes
1573 between <tt/\r/ and <tt/\n/.
1574 <item>The function is only available as fastcall function, so it may only
1575 be used in presence of a prototype.
1577 <tag/Availability/cc65
1579 <ref id="cprintf" name="cprintf">,
1580 <ref id="cputc" name="cputc">,
1581 <ref id="cputs" name="cputs">,
1582 <ref id="cputsxy" name="cputsxy">,
1583 <ref id="vcprintf" name="vcprintf">
1589 <sect1>cputs<label id="cputs"><p>
1593 <tag/Function/Output a string directly to the console.
1594 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1595 <tag/Declaration/<tt/void __fastcall__ cputs (const char* s);/
1596 <tag/Description/The function outputs the given string on the console at the
1597 current cursor position.
1598 <tag/Limits/<itemize>
1599 <item>Like all other <tt/conio/ output functions, <tt/cputs/ distinguishes
1600 between <tt/\r/ and <tt/\n/.
1601 <item>The function is only available as fastcall function, so it may only
1602 be used in presence of a prototype.
1604 <tag/Availability/cc65
1606 <ref id="cprintf" name="cprintf">,
1607 <ref id="cputc" name="cputc">,
1608 <ref id="cputcxy" name="cputcxy">,
1609 <ref id="cputsxy" name="cputsxy">,
1610 <ref id="vcprintf" name="vcprintf">
1616 <sect1>cputsxy<label id="cputsxy"><p>
1620 <tag/Function/Output a string to the console at a given position.
1621 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1622 <tag/Declaration/<tt/void __fastcall__ cputsxy (unsigned char x, unsigned char y, const char* s);/
1623 <tag/Description/<tt/cputsxy/ moves the cursor to the given x/y position,
1624 and outputs the string <tt/s/.
1625 <tag/Limits/<itemize>
1626 <item>Like all other <tt/conio/ output functions, <tt/cputsxy/ distinguishes
1627 between <tt/\r/ and <tt/\n/.
1628 <item>The function is only available as fastcall function, so it may only
1629 be used in presence of a prototype.
1631 <tag/Availability/cc65
1633 <ref id="cprintf" name="cprintf">,
1634 <ref id="cputc" name="cputc">,
1635 <ref id="cputcxy" name="cputcxy">,
1636 <ref id="cputs" name="cputs">,
1637 <ref id="vcprintf" name="vcprintf">
1643 <sect1>cursor<label id="cursor"><p>
1647 <tag/Function/Enable/disable a blinking cursor when waiting for keyboard input.
1648 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1649 <tag/Declaration/<tt/unsigned char __fastcall__ cursor (unsigned char onoff);/
1650 <tag/Description/If the argument to the function is non zero, a blinking cursor
1651 will be enabled when the <tt/cgetc/ function waits for input from the keyboard.
1652 If the argument is zero, <tt/cgetc/ will wait without a blinking cursor.
1653 <tag/Limits/<itemize>
1654 <item>The function is only available as fastcall function, so it may only
1655 be used in presence of a prototype.
1657 <tag/Availability/cc65
1659 <ref id="cgetc" name="cgetc">,
1660 <ref id="kbhit" name="kbhit">
1666 <sect1>cvline<label id="cvline"><p>
1670 <tag/Function/Output a vertical line in text mode.
1671 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1672 <tag/Declaration/<tt/void __fastcall__ cvline (unsigned char length);/
1673 <tag/Description/The function outputs a vertical line with the given length
1674 starting at the current cursor position.
1675 <tag/Limits/<itemize>
1676 <item>The character used to draw the vertical line is system dependent.
1677 If available, a line drawing character is used. Drawing a line that is partially
1678 off screen leads to undefined behaviour.
1679 <item>The function is only available as fastcall function, so it may only be
1680 used in presence of a prototype.
1682 <tag/Availability/cc65
1684 <ref id="chline" name="chline">,
1685 <ref id="chlinexy" name="chlinexy">,
1686 <ref id="cvlinexy" name="cvlinexy">
1692 <sect1>cvlinexy<label id="cvlinexy"><p>
1696 <tag/Function/Output a vertical line at a given position in text mode.
1697 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1698 <tag/Declaration/<tt/void __fastcall__ cvlinexy (unsigned char x, unsigned char y, unsigned char length);/
1699 <tag/Description/The function outputs a vertical line with the given length
1700 starting at a given position.
1701 <tag/Limits/<itemize>
1702 <item>The character used to draw the vertical line is system dependent.
1703 If available, a line drawing character is used. Drawing a line that is partially
1704 off screen leads to undefined behaviour.
1705 <item>The function is only available as fastcall function, so it may only be
1706 used in presence of a prototype.
1708 <tag/Availability/cc65
1710 <ref id="chline" name="chline">,
1711 <ref id="chlinexy" name="chlinexy">,
1712 <ref id="cvline" name="cvline">
1718 <sect1>div<label id="div"><p>
1722 <tag/Function/Divide two ints and return quotient and remainder.
1723 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1724 <tag/Declaration/<tt/div_t __fastcall__ div (int numer, int denom);/
1725 <tag/Description/<tt/div/ divides <tt/numer/ by <tt/denom/ and returns the
1726 quotient and remainder in a <tt/div_t/ structure.
1729 <item>The function is only available as fastcall function, so it may only
1730 be used in presence of a prototype.
1732 <tag/Availability/ISO 9899
1740 <sect1>em_commit<label id="em_commit"><p>
1744 <tag/Function/Commit changes into extended memory.
1745 <tag/Header/<tt/<ref id="em.h" name="em.h">/
1746 <tag/Declaration/<tt/void __fastcall__ em_commit (void);/
1747 <tag/Description/Commit changes in the memory window to extended storage. If
1748 the contents of the memory window have been changed, these changes may be lost
1749 if <tt/<ref id="em_map" name="em_map">/, <tt/<ref id="em_use" name="em_use">/,
1750 <tt/<ref id="em_copyfrom" name="em_copyfrom">/ or <tt/<ref id="em_copyto"
1751 name="em_copyto">/ are called without calling <tt/em_commit/ first.
1752 <tag/Limits/<itemize>
1753 <item>Calling <tt/em_commit/ does not necessarily mean that changes to the
1754 memory window are discarded, it does just mean that the drivers is allowed
1756 <item>The function is only available as fastcall function, so it may only be
1757 used in presence of a prototype.
1758 <item>The function produces undefined results if no extended memory driver is
1761 <tag/Availability/cc65
1763 <ref id="em_load_driver" name="em_load_driver">,
1764 <ref id="em_map" name="em_map">,
1765 <ref id="em_use" name="em_use">
1771 <sect1>em_copyfrom<label id="em_copyfrom"><p>
1775 <tag/Function/Copy from extended into normal memory.
1776 <tag/Header/<tt/<ref id="em.h" name="em.h">/
1777 <tag/Declaration/<tt/void __fastcall__ em_copyfrom (const struct em_copy* copy_data);/
1778 <tag/Description/Copy data from extended memory into linear memory. Source and
1779 target addresses as well as the number of bytes to transfer are specified in
1780 the <tt/em_copy/ structure that is passed as a parameter.
1781 <tag/Limits/<itemize>
1782 <item>Calling <tt/em_copyfrom/ will invalidate the memory window, so if you
1783 made any changes to the data in the window, call <tt/<ref id="em_commit"
1784 name="em_commit">/ first, or the changes are lost.
1785 <item>The function is only available as fastcall function, so it may only be
1786 used in presence of a prototype.
1787 <item>The function produces undefined results if no extended memory driver is
1790 <tag/Availability/cc65
1792 <ref id="em_commit" name="em_commit">,
1793 <ref id="em_copyto" name="em_copyto">,
1794 <ref id="em_load_driver" name="em_load_driver">
1800 <sect1>em_copyto<label id="em_copyto"><p>
1804 <tag/Function/Copy from normal into extended memory.
1805 <tag/Header/<tt/<ref id="em.h" name="em.h">/
1806 <tag/Declaration/<tt/void __fastcall__ em_copyto (const struct em_copy* copy_data);/
1807 <tag/Description/Copy data from linear into extended memory. Source and
1808 target addresses as well as the number of bytes to transfer are specified in
1809 the <tt/em_copy/ structure that is passed as a parameter.
1810 <tag/Limits/<itemize>
1811 <item>Calling <tt/em_copyto/ will invalidate the memory window, so if you
1812 made any changes to the data in the window, call <tt/<ref id="em_commit"
1813 name="em_commit">/ first, or the changes are lost.
1814 <item>The function is only available as fastcall function, so it may only be
1815 used in presence of a prototype.
1816 <item>The function produces undefined results if no extended memory driver is
1819 <tag/Availability/cc65
1821 <ref id="em_commit" name="em_commit">,
1822 <ref id="em_copyfrom" name="em_copyfrom">,
1823 <ref id="em_load_driver" name="em_load_driver">
1829 <sect1>em_install<label id="em_install"><p>
1833 <tag/Function/Install an already loaded extended memory driver.
1834 <tag/Header/<tt/<ref id="em.h" name="em.h">/
1835 <tag/Declaration/<tt/unsigned char _fastcall__ em_install (void* driver);/
1836 <tag/Description/The function installs an already loaded extended memory driver
1837 and returns an error code. The function may be used to install a driver linked
1838 statically to the program.
1839 <tag/Limits/<itemize>
1840 <item>Not all drivers are able to detect if the supported hardware is really
1842 <item>The function is only available as fastcall function, so it may only be
1843 used in presence of a prototype.
1845 <tag/Availability/cc65
1847 <ref id="em_load_driver" name="em_load_driver">,
1848 <ref id="em_uninstall" name="em_uninstall">,
1849 <ref id="em_unload" name="em_unload">
1855 <sect1>em_load_driver<label id="em_load_driver"><p>
1859 <tag/Function/Load and initialize an extended memory driver.
1860 <tag/Header/<tt/<ref id="em.h" name="em.h">/
1861 <tag/Declaration/<tt/void __fastcall__ em_load_driver (const char* name);/
1862 <tag/Description/Load an extended memory driver into memory and initialize
1863 it. The function returns an error code that tells if all this has been
1865 <tag/Limits/<itemize>
1866 <item>Not all drivers are able to detect if the supported hardware is really
1868 <item>The function is only available as fastcall function, so it may only be
1869 used in presence of a prototype.
1870 <item>The driver is loaded by name, so currently you must know the type of
1871 extended memory that should be supported. There is no autodetect capability.
1873 <tag/Availability/cc65
1875 <ref id="em_unload" name="em_unload">
1881 <sect1>em_map<label id="em_map"><p>
1885 <tag/Function/Make a page of extended memory accessible.
1886 <tag/Header/<tt/<ref id="em.h" name="em.h">/
1887 <tag/Declaration/<tt/void* __fastcall__ em_map (unsigned page);/
1888 <tag/Description/The function maps one page of extended memory into linear
1889 memory and returns a pointer to the page frame. Depending on the hardware
1890 and driver, the data is either mapped into the address space or transfered
1891 into a buffer. If you don't need the actual contents of the page (for example
1892 because you're going to overwrite it completely), it is better to call
1893 <tt/<ref id="em_use" name="em_use">/ instead. <tt/em_use/ will not transfer the
1894 data if it is possible to avoid that.
1895 <tag/Limits/<itemize>
1896 <item>Calling <tt/em_map/ will invalidate the memory window, so if you
1897 made any changes to the data in the window, call <tt/<ref id="em_commit"
1898 name="em_commit">/ first, or the changes are lost.
1899 <item>The function is only available as fastcall function, so it may only be
1900 used in presence of a prototype.
1901 <item>The function produces undefined results if no extended memory driver is
1904 <tag/Availability/cc65
1906 <ref id="em_commit" name="em_commit">,
1907 <ref id="em_load_driver" name="em_load_driver">,
1908 <ref id="em_use" name="em_use">
1914 <sect1>em_pagecount<label id="em_pagecount"><p>
1918 <tag/Function/Return the number of available extended memory pages.
1919 <tag/Header/<tt/<ref id="em.h" name="em.h">/
1920 <tag/Declaration/<tt/unsigned __fastcall__ em_pagecount (void);/
1921 <tag/Description/The function returns the size of the extended memory supported
1922 by the driver in 256 byte pages.
1923 <tag/Limits/<itemize>
1924 <item>The function returns zero if no extended memory driver is loaded.
1925 <item>The function may return zero if the supported hardware was not detected.
1927 <tag/Availability/cc65
1929 <ref id="em_load_driver" name="em_load_driver">
1935 <sect1>em_uninstall<label id="em_uninstall"><p>
1939 <tag/Function/Uninstall an already loaded extended memory driver.
1940 <tag/Header/<tt/<ref id="em.h" name="em.h">/
1941 <tag/Declaration/<tt/unsigned char __fastcall__ em_install (void);/
1942 <tag/Description/The function uninstalls an already loaded extended memory
1943 driver but doesn't remove it from memory.
1944 <tag/Limits/<itemize>
1945 <item>If the driver has been loaded using <tt/<ref id="em_load_driver"
1946 name="em_load_driver">/, <tt/<ref id="em_unload" name="em_unload">/
1947 should be used instead of <tt/em_uninstall/ so the driver is also removed
1949 <item>The function is only available as fastcall function, so it may only be
1950 used in presence of a prototype.
1952 <tag/Availability/cc65
1954 <ref id="em_install" name="em_install">,
1955 <ref id="em_load_driver" name="em_load_driver">,
1956 <ref id="em_unload" name="em_unload">
1962 <sect1>em_unload<label id="em_unload"><p>
1966 <tag/Function/Unload an extended memory driver.
1967 <tag/Header/<tt/<ref id="em.h" name="em.h">/
1968 <tag/Declaration/<tt/unsigned char __fastcall__ em_unload (void);/
1969 <tag/Description/The function unloads a loaded extended memory driver and
1970 frees all memory allocated for the driver.
1971 <tag/Limits/<itemize>
1972 <item>The function does nothing if no driver is loaded.
1974 <tag/Availability/cc65
1976 <ref id="em_load_driver" name="em_load_driver">
1982 <sect1>em_use<label id="em_use"><p>
1986 <tag/Function/Prepare an extended memory page for use.
1987 <tag/Header/<tt/<ref id="em.h" name="em.h">/
1988 <tag/Declaration/<tt/void* __fastcall__ em_use (unsigned page);/
1989 <tag/Description/The function maps one page of extended memory into linear
1990 memory and returns a pointer to the page frame. This function is similar to
1991 <tt/<ref id="em_map" name="em_map">/, but will not transfer data into the
1992 actual memory window in the assumption that the existing data is wrong or
1993 will get overwritten.
1994 <tag/Limits/<itemize>
1995 <item>Calling <tt/em_use/ will invalidate the memory window, so if you
1996 made any changes to the data in the window, call <tt/<ref id="em_commit"
1997 name="em_commit">/ first, or the changes are lost.
1998 <item>The function is only available as fastcall function, so it may only be
1999 used in presence of a prototype.
2000 <item>The function produces undefined results if no extended memory driver is
2003 <tag/Availability/cc65
2005 <ref id="em_commit" name="em_commit">,
2006 <ref id="em_load_driver" name="em_load_driver">,
2007 <ref id="em_map" name="em_map">
2013 <sect1>exit<label id="exit"><p>
2017 <tag/Function/Terminate the program.
2018 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
2019 <tag/Declaration/<tt/void __fastcall__ exit (int status);/
2020 <tag/Description/<tt/exit/ terminates the program. The argument specifies the
2021 return code of the program. Before termination, all files are closed, buffered
2022 output is written and any functions registered with <tt/<ref id="atexit"
2023 name="atexit">/ are called. Common values for status are <tt/EXIT_SUCCESS/ and
2024 <tt/EXIT_FAILURE/ which are also defined in <tt/<ref id="stdlib.h"
2026 <tag/Limits/<itemize>
2027 <item>The function is only available as fastcall function, so it may only
2028 be used in presence of a prototype.
2029 <item>It depends on the host machine if the program return code can be
2030 evaluated or is ignored.
2032 <tag/Availability/ISO 9899
2034 <ref id="abort" name="abort">,
2035 <ref id="exit" name="exit">
2041 <sect1>fast<label id="fast"><p>
2045 <tag/Function/Switch the C128 into 2MHz mode.
2046 <tag/Header/<tt/<ref id="c128.h" name="c128.h">/
2047 <tag/Declaration/<tt/void fast (void);/
2048 <tag/Description/The function will switch the clock of the C128 to 2MHz. This
2049 will nearly double the speed compared to slow mode.
2050 <tag/Limits/<itemize>
2051 <item>The function is specific to the C128.
2052 <item>2MHz clock will not work in 40 column mode.
2054 <tag/Availability/C128
2056 <ref id="slow" name="slow">,
2057 <ref id="toggle_videomode" name="toggle_videomode">,
2058 <ref id="videomode" name="videomode">
2064 <sect1>feof<label id="feof"><p>
2068 <tag/Function/Return the end-of-file indicator of a stream.
2069 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
2070 <tag/Declaration/<tt/int __fastcall__ feof (FILE* f);/
2071 <tag/Description/<tt/feof/ tests the end-of-file indicator ofthe stream
2072 <tt/f/, and returns a non zero value if it is set.
2073 <tag/Limits/<itemize>
2074 <item>The indicator is set only after a read past the end of a file is
2076 <item>The function is only available as fastcall function, so it may only be
2077 used in presence of a prototype.
2079 <tag/Availability/ISO 9899
2081 <ref id="feof" name="clearerr">,
2082 <ref id="ferror" name="ferror">
2088 <sect1>ferror<label id="ferror"><p>
2092 <tag/Function/Return the error indicator of a stream.
2093 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
2094 <tag/Declaration/<tt/int __fastcall__ ferror (FILE* f);/
2095 <tag/Description/<tt/ferror/ tests the error indicator of the stream
2096 <tt/f/, and returns a non zero value if it is set.
2097 <tag/Limits/<itemize>
2098 <item>The function is only available as fastcall function, so it may only be
2099 used in presence of a prototype.
2101 <tag/Availability/ISO 9899
2103 <ref id="feof" name="clearerr">,
2104 <ref id="ferror" name="feof">
2110 <sect1>fileno<label id="fileno"><p>
2114 <tag/Function/Return the file handle used by a stream.
2115 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
2116 <tag/Declaration/<tt/int __fastcall__ fileno (FILE* f);/
2117 <tag/Description/The <tt/fileno/ function returns the file handle used
2118 internally by a C stream. This file handle (an integer) can be used as a
2119 handle for the POSIX input/output functions.
2120 <tag/Limits/<itemize>
2121 <item>The function is only available as fastcall function, so it may only be
2122 used in presence of a prototype.
2123 <item>Mixing C file I/O functions and POSIX file I/O functions for the same
2124 file may have unpredictable results.
2126 <tag/Availability/POSIX 1003.1
2128 <ref id="creat" name="creat">,
2129 <ref id="open" name="open"> <!-- , -->
2130 <!-- <ref id="read" name="read">, -->
2131 <!-- <ref id="write" name="write"> -->
2137 <sect1>free<label id="free"><p>
2141 <tag/Function/Free a block of dynamic memory.
2142 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
2143 <tag/Declaration/<tt/void __fastcall__ free (void* block);/
2144 <tag/Description/Free a block of dynamic memory previously allocated with
2145 <tt/<ref id="malloc" name="malloc">/, <tt/<ref id="calloc" name="calloc">/
2146 or <tt/<ref id="realloc" name="realloc">/. As an exception, if the passed
2147 pointer is <tt/NULL/, no action is performed.
2150 <item>Passing an already free'd block to <tt/free/ again will cause undefined
2151 behaviour and may crash your program.
2152 <item>The function is only available as fastcall function, so it may only
2153 be used in presence of a prototype.
2155 <tag/Availability/ISO 9899
2157 <ref id="_heapadd" name="_heapadd">,
2158 <ref id="_heapblocksize" name="_heapblocksize">,
2159 <ref id="_heapmaxavail" name="_heapmaxavail">,
2160 <ref id="_heapmemavail" name="_heapmemavail">,
2161 <ref id="calloc" name="calloc">,
2162 <ref id="malloc" name="malloc">,
2163 <ref id="realloc" name="realloc">
2169 <sect1>get_ostype<label id="get_ostype"><p>
2173 <tag/Function/The function returns the operating system, the program runs on.
2174 <tag/Header/<tt/<ref id="apple2.h" name="apple2.h">,
2175 <ref id="atari.h" name="atari.h">, <ref id="c64.h" name="c64.h">/
2176 <tag/Declaration/<tt/unsigned char get_ostype (void);/
2177 <tag/Description/<tt/get_ostype/ is machine dependent and does not exist for
2178 all supported targets. If it exists, it returns a number that identifies the
2179 operating system or machine type, the program runs on. The machine dependent
2180 header files define constants that can be used to check the return code.
2181 <tag/Limits/<itemize>
2182 <item>The function does not exist on all platforms.
2183 <item>The return codes are platform dependent.
2185 <tag/Availability/cc65 (not all platforms)
2191 <sect1>getenv<label id="getenv"><p>
2195 <tag/Function/Return a value from the environment.
2196 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
2197 <tag/Declaration/<tt/char* __fastcall__ getenv (const char* name);/
2198 <tag/Description/The function searches the environment for an entry that
2199 matches <tt/name/ and returns its value. The environment consists of a list
2200 of strings in the form <tt/name=value/. If there is no match, <tt/getenv/
2202 <tag/Limits/<itemize>
2203 <item>What exactly is stored in the environment depends on the machine the
2204 program is running on.
2205 <item>The function is only available as fastcall function, so it may only
2206 be used in presence of a prototype.
2208 <tag/Availability/ISO 9899
2214 <sect1>getcpu<label id="getcpu"><p>
2218 <tag/Function/Determine on which CPU the program is running.
2219 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
2220 <tag/Declaration/<tt/unsigned char getcpu (void);/
2221 <tag/Description/The function checks on which CPU the code is running. It
2222 returns one of the constants<itemize>
2224 <item><tt/CPU_65C02/
2225 <item><tt/CPU_65816/
2227 <tag/Limits/<itemize>
2228 <item>Other, more exotic CPU types are not disinguished.
2230 <tag/Availability/cc65
2236 <sect1>gotox<label id="gotox"><p>
2240 <tag/Function/Move the text mode cursor to a new X position.
2241 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2242 <tag/Declaration/<tt/void __fastcall__ gotox (unsigned char x);/
2243 <tag/Description/The function moves the text mode cursor to the specified X
2244 position while leaving the Y position untouched. The leftmost position on the
2245 screen has the coordinate 0.
2246 <tag/Limits/<itemize>
2247 <item>The function is only available as fastcall function, so it may
2248 only be used in presence of a prototype.
2249 <item>Invalid values for the X position (out of screen coordinates) may
2250 lead to undefined behaviour.
2252 <tag/Availability/cc65
2254 <ref id="gotoy" name="gotoy">,
2255 <ref id="gotoxy" name="gotoxy">,
2256 <ref id="wherex" name="wherex">,
2257 <ref id="wherey" name="wherey">
2263 <sect1>gotoxy<label id="gotoxy"><p>
2267 <tag/Function/Move the text mode cursor to a new position.
2268 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2269 <tag/Declaration/<tt/void __fastcall__ gotoxy (unsigned char x, unsigned char y);/
2270 <tag/Description/The function moves the text mode cursor to the specified
2271 position. The leftmost position on the screen has the X coordinate 0, the
2272 topmost line has the Y coordinate 0.
2273 <tag/Limits/<itemize>
2274 <item>The function is only available as fastcall function, so it may only be
2275 used in presence of a prototype.
2276 <item>Invalid values for any of both coordinates (out of screen positions) may
2277 lead to undefined behaviour.
2279 <tag/Availability/cc65
2281 <ref id="gotox" name="gotox">,
2282 <ref id="gotoy" name="gotoy">,
2283 <ref id="wherex" name="wherex">,
2284 <ref id="wherey" name="wherey">
2290 <sect1>gotoy<label id="gotoy"><p>
2294 <tag/Function/Move the text mode cursor to a new Y position.
2295 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2296 <tag/Declaration/<tt/void __fastcall__ gotoy (unsigned char x);/
2297 <tag/Description/The function moves the text mode cursor to the specified Y
2298 position while leaving the X position untouched. The uppermost position on the
2299 screen has the coordinate 0.
2300 <tag/Limits/<itemize>
2301 <item>The function is only available as fastcall function, so it may
2302 only be used in presence of a prototype.
2303 <item>Invalid values for the Y position (out of screen coordinates) may lead
2304 to undefined behaviour.
2306 <tag/Availability/cc65
2308 <ref id="gotox" name="gotox">,
2309 <ref id="gotoxy" name="gotoxy">,
2310 <ref id="wherex" name="wherex">,
2311 <ref id="wherey" name="wherey">
2317 <sect1>isalnum<label id="isalnum"><p>
2321 <tag/Function/Check if a given character is a letter or digit.
2322 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2323 <tag/Declaration/<tt/int __fastcall__ isalnum (int c);/
2324 <tag/Description/The function returns a non zero value if the given argument
2325 is a letter or digit. The return value is zero if the character is anything
2327 <tag/Limits/<itemize>
2328 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2329 inline sequence generated by the macro will not work correctly for values
2330 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2331 this range. The non inline function may be accessed by <tt/#undef/'ing
2333 <item>When compiling without <tt/-Os/, the function is only available as
2334 fastcall function, so it may only be used in presence of a prototype.
2336 <tag/Availability/ISO 9899
2338 <ref id="isalpha" name="isalpha">,
2339 <ref id="isascii" name="isascii">,
2340 <ref id="isblank" name="isblank">,
2341 <ref id="iscntrl" name="iscntrl">,
2342 <ref id="isdigit" name="isdigit">,
2343 <ref id="isgraph" name="isgraph">,
2344 <ref id="islower" name="islower">,
2345 <ref id="isprint" name="isprint">,
2346 <ref id="ispunct" name="ispunct">,
2347 <ref id="isspace" name="isspace">,
2348 <ref id="isupper" name="isupper">,
2349 <ref id="isxdigit" name="isxdigit">
2355 <sect1>isalpha<label id="isalpha"><p>
2359 <tag/Function/Check if a given character is a letter.
2360 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2361 <tag/Declaration/<tt/int __fastcall__ isalpha (int c);/
2362 <tag/Description/The function returns a non zero value if the given argument
2363 is a letter. The return value is zero if the character is anything else.
2364 <tag/Limits/<itemize>
2365 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2366 inline sequence generated by the macro will not work correctly for values
2367 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2368 this range. The non inline function may be accessed by <tt/#undef/'ing the
2370 <item>When compiling without <tt/-Os/, the function is only available as
2371 fastcall function, so it may only be used in presence of a prototype.
2373 <tag/Availability/ISO 9899
2375 <ref id="isalnum" name="isalnum">,
2376 <ref id="isascii" name="isascii">,
2377 <ref id="isblank" name="isblank">,
2378 <ref id="iscntrl" name="iscntrl">,
2379 <ref id="isdigit" name="isdigit">,
2380 <ref id="isgraph" name="isgraph">,
2381 <ref id="islower" name="islower">,
2382 <ref id="isprint" name="isprint">,
2383 <ref id="ispunct" name="ispunct">,
2384 <ref id="isspace" name="isspace">,
2385 <ref id="isupper" name="isupper">,
2386 <ref id="isxdigit" name="isxdigit">
2392 <sect1>isascii<label id="isascii"><p>
2396 <tag/Function/Check if a given character is in the ASCII (0..127) range.
2397 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2398 <tag/Declaration/<tt/int __fastcall__ isascii (int c);/
2399 <tag/Description/The function returns a non zero value if the given argument
2400 is in the range 0..127 (the range of valid ASCII characters) and zero if not.
2401 <tag/Limits/<itemize>
2402 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2403 inline sequence generated by the macro will not work correctly for values
2404 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2405 this range. The non inline function may be accessed by <tt/#undef/'ing the
2407 <item>When compiling without <tt/-Os/, the function is only available as
2408 fastcall function, so it may only be used in presence of a prototype.
2410 <tag/Availability/ISO 9899
2412 <ref id="isalnum" name="isalnum">,
2413 <ref id="isalpha" name="isalpha">,
2414 <ref id="isblank" name="isblank">,
2415 <ref id="iscntrl" name="iscntrl">,
2416 <ref id="isdigit" name="isdigit">,
2417 <ref id="isgraph" name="isgraph">,
2418 <ref id="islower" name="islower">,
2419 <ref id="isprint" name="isprint">,
2420 <ref id="ispunct" name="ispunct">,
2421 <ref id="isspace" name="isspace">,
2422 <ref id="isupper" name="isupper">,
2423 <ref id="isxdigit" name="isxdigit">
2429 <sect1>isblank<label id="isblank"><p>
2433 <tag/Function/Check if a given character is a space or tab.
2434 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2435 <tag/Declaration/<tt/int __fastcall__ isblank (int c);/
2436 <tag/Description/The function returns a non zero value if the given argument
2437 is a space or tab character. The return value is zero if the character is
2439 <tag/Limits/<itemize>
2440 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2441 inline sequence generated by the macro will not work correctly for values
2442 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2443 this range. The non inline function may be accessed by <tt/#undef/'ing the
2445 <item>When compiling without <tt/-Os/, the function is only available as
2446 fastcall function, so it may only be used in presence of a prototype.
2448 <tag/Availability/cc65
2450 <ref id="isalnum" name="isalnum">,
2451 <ref id="isalpha" name="isalpha">,
2452 <ref id="isascii" name="isascii">,
2453 <ref id="iscntrl" name="iscntrl">,
2454 <ref id="isdigit" name="isdigit">,
2455 <ref id="isgraph" name="isgraph">,
2456 <ref id="islower" name="islower">,
2457 <ref id="isprint" name="isprint">,
2458 <ref id="ispunct" name="ispunct">,
2459 <ref id="isspace" name="isspace">,
2460 <ref id="isupper" name="isupper">,
2461 <ref id="isxdigit" name="isxdigit">
2467 <sect1>iscntrl<label id="iscntrl"><p>
2471 <tag/Function/Check if a given character is a control character.
2472 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2473 <tag/Declaration/<tt/int __fastcall__ iscntrl (int c);/
2474 <tag/Description/The function returns a non zero value if the given argument
2475 is a control character. The return value is zero if the character is anything
2477 <tag/Limits/<itemize>
2478 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2479 inline sequence generated by the macro will not work correctly for values
2480 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2481 this range. The non inline function may be accessed by <tt/#undef/'ing the
2483 <item>When compiling without <tt/-Os/, the function is only available as
2484 fastcall function, so it may only be used in presence of a prototype.
2486 <tag/Availability/ISO 9899
2488 <ref id="isalnum" name="isalnum">,
2489 <ref id="isalpha" name="isalpha">,
2490 <ref id="isascii" name="isascii">,
2491 <ref id="isblank" name="isblank">,
2492 <ref id="isdigit" name="isdigit">,
2493 <ref id="isgraph" name="isgraph">,
2494 <ref id="islower" name="islower">,
2495 <ref id="isprint" name="isprint">,
2496 <ref id="ispunct" name="ispunct">,
2497 <ref id="isspace" name="isspace">,
2498 <ref id="isupper" name="isupper">,
2499 <ref id="isxdigit" name="isxdigit">
2505 <sect1>isdigit<label id="isdigit"><p>
2509 <tag/Function/Check if a given character is a digit.
2510 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2511 <tag/Declaration/<tt/int __fastcall__ isdigit (int c);/
2512 <tag/Description/The function returns a non zero value if the given argument
2513 is a digit. The return value is zero if the character is anything else.
2514 <tag/Limits/<itemize>
2515 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2516 inline sequence generated by the macro will not work correctly for values
2517 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2518 this range. The non inline function may be accessed by <tt/#undef/'ing the
2520 <item>When compiling without <tt/-Os/, the function is only available as
2521 fastcall function, so it may only be used in presence of a prototype.
2523 <tag/Availability/ISO 9899
2525 <ref id="isalnum" name="isalnum">,
2526 <ref id="isalpha" name="isalpha">,
2527 <ref id="isascii" name="isascii">,
2528 <ref id="isblank" name="isblank">,
2529 <ref id="iscntrl" name="iscntrl">,
2530 <ref id="isgraph" name="isgraph">,
2531 <ref id="islower" name="islower">,
2532 <ref id="isprint" name="isprint">,
2533 <ref id="ispunct" name="ispunct">,
2534 <ref id="isspace" name="isspace">,
2535 <ref id="isupper" name="isupper">,
2536 <ref id="isxdigit" name="isxdigit">
2542 <sect1>isgraph<label id="isgraph"><p>
2546 <tag/Function/Check if a given character is a printable character (except
2548 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2549 <tag/Declaration/<tt/int __fastcall__ isgraph (int c);/
2550 <tag/Description/The function returns a non zero value if the given argument
2551 is a printable character with the exception of space. The return value is zero
2552 if the character is anything else.
2553 <tag/Limits/<itemize>
2554 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2555 inline sequence generated by the macro will not work correctly for values
2556 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2557 this range. The non inline function may be accessed by <tt/#undef/'ing the
2559 <item>When compiling without <tt/-Os/, the function is only available as
2560 fastcall function, so it may only be used in presence of a prototype.
2562 <tag/Availability/ISO 9899
2564 <ref id="isalnum" name="isalnum">,
2565 <ref id="isalpha" name="isalpha">,
2566 <ref id="isascii" name="isascii">,
2567 <ref id="isblank" name="isblank">,
2568 <ref id="iscntrl" name="iscntrl">,
2569 <ref id="isdigit" name="isdigit">,
2570 <ref id="islower" name="islower">,
2571 <ref id="isprint" name="isprint">,
2572 <ref id="ispunct" name="ispunct">,
2573 <ref id="isspace" name="isspace">,
2574 <ref id="isupper" name="isupper">,
2575 <ref id="isxdigit" name="isxdigit">
2581 <sect1>islower<label id="islower"><p>
2585 <tag/Function/Check if a given character is a lower case letter.
2586 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2587 <tag/Declaration/<tt/int __fastcall__ islower (int c);/
2588 <tag/Description/The function returns a non zero value if the given argument
2589 is a lower case letter. The return value is zero if the character is anything
2591 <tag/Limits/<itemize>
2592 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2593 inline sequence generated by the macro will not work correctly for values
2594 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2595 this range. The non inline function may be accessed by <tt/#undef/'ing the
2597 <item>When compiling without <tt/-Os/, the function is only available as
2598 fastcall function, so it may only be used in presence of a prototype.
2600 <tag/Availability/ISO 9899
2602 <ref id="isalnum" name="isalnum">,
2603 <ref id="isalpha" name="isalpha">,
2604 <ref id="isascii" name="isascii">,
2605 <ref id="isblank" name="isblank">,
2606 <ref id="iscntrl" name="iscntrl">,
2607 <ref id="isdigit" name="isdigit">,
2608 <ref id="isgraph" name="isgraph">,
2609 <ref id="isprint" name="isprint">,
2610 <ref id="ispunct" name="ispunct">,
2611 <ref id="isspace" name="isspace">,
2612 <ref id="isupper" name="isupper">,
2613 <ref id="isxdigit" name="isxdigit">
2619 <sect1>isprint<label id="isprint"><p>
2623 <tag/Function/Check if a given character is a printable character.
2624 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2625 <tag/Declaration/<tt/int __fastcall__ isprint (int c);/
2626 <tag/Description/The function returns a non zero value if the given argument
2627 is a printable character (this includes the space character). The return value
2628 is zero if the character is anything else.
2629 <tag/Limits/<itemize>
2630 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2631 inline sequence generated by the macro will not work correctly for values
2632 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2633 this range. The non inline function may be accessed by <tt/#undef/'ing the
2635 <item>When compiling without <tt/-Os/, the function is only available as
2636 fastcall function, so it may only be used in presence of a prototype.
2638 <tag/Availability/ISO 9899
2640 <ref id="isalnum" name="isalnum">,
2641 <ref id="isalpha" name="isalpha">,
2642 <ref id="isascii" name="isascii">,
2643 <ref id="isblank" name="isblank">,
2644 <ref id="iscntrl" name="iscntrl">,
2645 <ref id="isdigit" name="isdigit">,
2646 <ref id="isgraph" name="isgraph">,
2647 <ref id="islower" name="islower">,
2648 <ref id="ispunct" name="ispunct">,
2649 <ref id="isspace" name="isspace">,
2650 <ref id="isupper" name="isupper">,
2651 <ref id="isxdigit" name="isxdigit">
2657 <sect1>ispunct<label id="ispunct"><p>
2661 <tag/Function/Check if a given character is a printable character but not a
2662 space or an alphanumeric character.
2663 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2664 <tag/Declaration/<tt/int __fastcall__ ispunct (int c);/
2665 <tag/Description/The function returns a non zero value if the given argument
2666 is a printable character, but not a space or anything alphanumeric. The return
2667 value is zero if the character is anything else.
2668 <tag/Limits/<itemize>
2669 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2670 inline sequence generated by the macro will not work correctly for values
2671 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2672 this range. The non inline function may be accessed by <tt/#undef/'ing the
2674 <item>When compiling without <tt/-Os/, the function is only available as
2675 fastcall function, so it may only be used in presence of a prototype.
2677 <tag/Availability/ISO 9899
2679 <ref id="isalnum" name="isalnum">,
2680 <ref id="isalpha" name="isalpha">,
2681 <ref id="isascii" name="isascii">,
2682 <ref id="isblank" name="isblank">,
2683 <ref id="iscntrl" name="iscntrl">,
2684 <ref id="isdigit" name="isdigit">,
2685 <ref id="isgraph" name="isgraph">,
2686 <ref id="islower" name="islower">,
2687 <ref id="isprint" name="isprint">,
2688 <ref id="isspace" name="isspace">,
2689 <ref id="isupper" name="isupper">,
2690 <ref id="isxdigit" name="isxdigit">
2696 <sect1>isspace<label id="isspace"><p>
2700 <tag/Function/Check if a given character is a a white-space character.
2701 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2702 <tag/Declaration/<tt/int __fastcall__ isspace (int c);/
2703 <tag/Description/The function returns a non zero value if the given argument
2704 is a white space character. The return value is zero if the character is
2705 anything else. The standard white space characters are: space, formfeed ('\f'),
2706 newline ('\n'), carriage return ('\r'), horizontal tab ('\t'), and vertical tab
2708 <tag/Limits/<itemize>
2709 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2710 inline sequence generated by the macro will not work correctly for values
2711 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2712 this range. The non inline function may be accessed by <tt/#undef/'ing the
2714 <item>When compiling without <tt/-Os/, the function is only available as
2715 fastcall function, so it may only be used in presence of a prototype.
2717 <tag/Availability/ISO 9899
2719 <ref id="isalnum" name="isalnum">,
2720 <ref id="isalpha" name="isalpha">,
2721 <ref id="isascii" name="isascii">,
2722 <ref id="isblank" name="isblank">,
2723 <ref id="iscntrl" name="iscntrl">,
2724 <ref id="isdigit" name="isdigit">,
2725 <ref id="isgraph" name="isgraph">,
2726 <ref id="islower" name="islower">,
2727 <ref id="isprint" name="isprint">,
2728 <ref id="ispunct" name="ispunct">,
2729 <ref id="isupper" name="isupper">,
2730 <ref id="isxdigit" name="isxdigit">
2736 <sect1>isupper<label id="isupper"><p>
2740 <tag/Function/Check if a given character is an upper case letter.
2741 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2742 <tag/Declaration/<tt/int __fastcall__ isupper (int c);/
2743 <tag/Description/The function returns a non zero value if the given argument
2744 is an upper case letter. The return value is zero if the character is anything
2746 <tag/Limits/<itemize>
2747 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2748 inline sequence generated by the macro will not work correctly for values
2749 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2750 this range. The non inline function may be accessed by <tt/#undef/'ing the
2752 <item>When compiling without <tt/-Os/, the function is only available as
2753 fastcall function, so it may only be used in presence of a prototype.
2755 <tag/Availability/ISO 9899
2757 <ref id="isalnum" name="isalnum">,
2758 <ref id="isalpha" name="isalpha">,
2759 <ref id="isascii" name="isascii">,
2760 <ref id="isblank" name="isblank">,
2761 <ref id="iscntrl" name="iscntrl">,
2762 <ref id="isdigit" name="isdigit">,
2763 <ref id="isgraph" name="isgraph">,
2764 <ref id="islower" name="islower">,
2765 <ref id="isprint" name="isprint">,
2766 <ref id="ispunct" name="ispunct">,
2767 <ref id="isspace" name="isspace">,
2768 <ref id="isxdigit" name="isxdigit">
2774 <sect1>isxdigit<label id="isxdigit"><p>
2778 <tag/Function/Check if a given character is a hexadecimal digit.
2779 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2780 <tag/Declaration/<tt/int __fastcall__ isxdigit (int c);/
2781 <tag/Description/The function returns a non zero value if the given argument
2782 is a hexadecimal digit (0..9, a..f and A..F). The return value is zero if the
2783 character is anything else.
2784 <tag/Limits/<itemize>
2785 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2786 inline sequence generated by the macro will not work correctly for values
2787 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2788 this range. The non inline function may be accessed by <tt/#undef/'ing the
2790 <item>When compiling without <tt/-Os/, the function is only available as
2791 fastcall function, so it may only be used in presence of a prototype.
2793 <tag/Availability/ISO 9899
2795 <ref id="isalnum" name="isalnum">,
2796 <ref id="isalpha" name="isalpha">,
2797 <ref id="isascii" name="isascii">,
2798 <ref id="isblank" name="isblank">,
2799 <ref id="iscntrl" name="iscntrl">,
2800 <ref id="isdigit" name="isdigit">,
2801 <ref id="isgraph" name="isgraph">,
2802 <ref id="islower" name="islower">,
2803 <ref id="isprint" name="isprint">,
2804 <ref id="ispunct" name="ispunct">,
2805 <ref id="isspace" name="isspace">,
2806 <ref id="isupper" name="isupper">
2812 <sect1>itoa<label id="itoa"><p>
2816 <tag/Function/Convert an integer into a string.
2817 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
2818 <tag/Declaration/<tt/char* __fastcall__ itoa (int val, char* buf, int radix);/
2819 <tag/Description/<tt/itoa/ converts the integer <tt/val/ into a string using
2820 <tt/radix/ as the base.
2821 <tag/Limits/<itemize>
2822 <item>There are no provisions to prevent a buffer overflow.
2823 <item>If <tt/val/ contains <tt/INT_MIN/, the behaviour is undefined.
2824 <item>The function is non standard, so it is not available in strict ANSI mode.
2825 You should probably use <tt/sprintf/ instead.
2826 <item>The function is only available as fastcall function, so it may only be
2827 used in presence of a prototype.
2829 <tag/Availability/cc65
2831 <ref id="atoi" name="atoi">,
2832 <ref id="atol" name="atol">,
2833 <ref id="ltoa" name="ltoa">,
2834 <ref id="ultoa" name="ultoa">,
2835 <ref id="utoa" name="utoa">
2841 <sect1>joy_count<label id="joy_count"><p>
2845 <tag/Function/Return the number of joysticks supported by the current driver.
2846 <tag/Header/<tt/<ref id="joystick.h" name="joystick.h">/
2847 <tag/Declaration/<tt/unsigned char __fastcall__ joy_count (void);/
2848 <tag/Description/The function returns a the number of joysticks supported
2849 by the current joystick driver.
2850 <tag/Limits/<itemize>
2851 <item>A joystick driver must be loaded using <ref id="joy_load_driver"
2852 name="joy_load_driver"> before calling this function.
2853 <item>The function returns the number of joysticks supported by the driver.
2854 There's no way to check for the number of actually connected joysticks.
2855 <item>The function is only available as fastcall function, so it may only be
2856 used in presence of a prototype.
2858 <tag/Availability/cc65
2860 <ref id="joy_load_driver" name="joy_load_driver">,
2861 <ref id="joy_read" name="joy_read">
2867 <sect1>joy_install<label id="joy_install"><p>
2871 <tag/Function/Install an already loaded driver and return an error code.
2872 <tag/Header/<tt/<ref id="joystick.h" name="joystick.h">/
2873 <tag/Declaration/<tt/unsigned char __fastcall__ joy_install (void* driver);/
2874 <tag/Description/The function installs a driver that was already loaded into
2875 memory (or linked statically to the program). It returns an error code
2876 (<tt/JOY_ERR_OK/ in case of success).
2877 <tag/Limits/<itemize>
2878 <item>The function is only available as fastcall function, so it may only be
2879 used in presence of a prototype.
2881 <tag/Availability/cc65
2883 <ref id="joy_load_driver" name="joy_load_driver">,
2884 <ref id="joy_uninstall" name="joy_uninstall">,
2885 <ref id="joy_unload" name="joy_unload">
2891 <sect1>joy_load_driver<label id="joy_load_driver"><p>
2895 <tag/Function/Load a driver from disk and install it.
2896 <tag/Header/<tt/<ref id="joystick.h" name="joystick.h">/
2897 <tag/Declaration/<tt/unsigned char __fastcall__ joy_load_driver (const char* driver);/
2898 <tag/Description/The function loads a driver with the given name from disk
2899 and installs it. An error code is returned, which is <tt/JOY_ERR_OK/ if the
2900 driver was successfully loaded and installed.
2901 <tag/Limits/<itemize>
2902 <item>The function is only available as fastcall function, so it may only be
2903 used in presence of a prototype.
2905 <tag/Availability/cc65
2907 <ref id="joy_install" name="joy_install">,
2908 <ref id="joy_uninstall" name="joy_uninstall">,
2909 <ref id="joy_unload" name="joy_unload">
2915 <sect1>joy_read<label id="joy_read"><p>
2919 <tag/Function/Read the status of a joystick.
2920 <tag/Header/<tt/<ref id="joystick.h" name="joystick.h">/
2921 <tag/Declaration/<tt/unsigned char __fastcall__ joy_read (unsigned char joystick);/
2922 <tag/Description/The function reads the status bits for a joystick. The number
2923 of the joystick is passed as parameter. The result may be examined by using one
2924 of the <tt/JOY_xxx/ macros from <ref id="joystick.h" name="joystick.h">.
2925 <tag/Limits/<itemize>
2926 <item>A joystick driver must be loaded using <ref id="joy_load_driver"
2927 name="joy_load_driver"> before calling this function.
2928 <item>The function is only available as fastcall function, so it may only be
2929 used in presence of a prototype.
2931 <tag/Availability/cc65
2933 <ref id="joy_count" name="joy_count">,
2934 <ref id="joy_load_driver" name="joy_load_driver">,
2935 <ref id="joy_unload" name="joy_unload">
2941 <sect1>joy_uninstall<label id="joy_uninstall"><p>
2945 <tag/Function/Uninstall the current joystick driver.
2946 <tag/Header/<tt/<ref id="joystick.h" name="joystick.h">/
2947 <tag/Declaration/<tt/unsigned char __fastcall__ joy_uninstall (void);/
2948 <tag/Description/The function uninstalls the currently installed joystick
2949 driver. It does not remove the driver from memory. The function returns an
2950 error code, which is <tt/JOY_ERR_OK/ if the driver was successfully uninstalled.
2951 <tag/Limits/<itemize>
2952 <item>A joystick driver must be installed using <ref id="joy_install"
2953 name="joy_install"> before calling this function.
2954 <item>The function is only available as fastcall function, so it may only be
2955 used in presence of a prototype.
2957 <tag/Availability/cc65
2959 <ref id="joy_install" name="joy_install">,
2960 <ref id="joy_load_driver" name="joy_load_driver">,
2961 <ref id="joy_unload" name="joy_unload">
2967 <sect1>joy_unload<label id="joy_unload"><p>
2971 <tag/Function/Uninstall, then unload the current joystick driver.
2972 <tag/Header/<tt/<ref id="joystick.h" name="joystick.h">/
2973 <tag/Declaration/<tt/unsigned char __fastcall__ joy_unload (void);/
2974 <tag/Description/The function uninstalls the currently installed joystick
2975 driver and removes it from memory. An error code is returned, which is
2976 <tt/JOY_ERR_OK/ if the driver was successfully uninstalled.
2977 <tag/Limits/<itemize>
2978 <item>A joystick driver must be loaded using <ref id="joy_load_driver"
2979 name="joy_load_driver"> before calling this function.
2980 <item>The function is only available as fastcall function, so it may only be
2981 used in presence of a prototype.
2983 <tag/Availability/cc65
2985 <ref id="joy_load_driver" name="joy_load_driver">
2991 <sect1>kbhit<label id="kbhit"><p>
2995 <tag/Function/Check if there's a key waiting in the keyboard buffer.
2996 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2997 <tag/Declaration/<tt/unsigned char kbhit (void);/
2998 <tag/Description/The function returns a value of zero if there is no character
2999 waiting to be read from the keyboard. It returns non zero otherwise.
3000 <tag/Limits/<itemize>
3001 <item>If the system does not support a keyboard buffer (most systems
3002 do), the function is rather useless.
3004 <tag/Availability/cc65
3006 <ref id="cgetc" name="cgetc">,
3007 <ref id="cursor" name="cursor">
3013 <sect1>labs<label id="labs"><p>
3017 <tag/Function/Returns the absolute value of a long integer.
3018 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
3019 <tag/Declaration/<tt/long __fastcall__ labs (long v);/
3020 <tag/Description/<tt/labs/ returns the absolute value of the argument passed to
3022 <tag/Limits/<itemize>
3023 <item>The return value is undefined if <tt/LONG_MIN/ is passed to the function.
3024 <item>The function is only available as fastcall function, so it may only be
3025 used in presence of a prototype.
3027 <tag/Availability/ISO 9899
3029 <ref id="abs" name="abs">
3035 <sect1>ltoa<label id="ltoa"><p>
3039 <tag/Function/Convert a long integer into a string.
3040 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
3041 <tag/Declaration/<tt/char* __fastcall__ ltoa (long val, char* buf, int radix);/
3042 <tag/Description/<tt/itoa/ converts the long integer <tt/val/ into a string
3043 using <tt/radix/ as the base.
3044 <tag/Limits/<itemize>
3045 <item>There are no provisions to prevent a buffer overflow.
3046 <item>If <tt/val/ contains <tt/LONG_MIN/, the behaviour is undefined.
3047 <item>The function is non standard, so it is not available in strict ANSI mode.
3048 You should probably use <tt/sprintf/ instead.
3049 <item>The function is only available as fastcall function, so it may only be
3050 used in presence of a prototype.
3052 <tag/Availability/cc65
3054 <ref id="atoi" name="atoi">,
3055 <ref id="atol" name="atol">,
3056 <ref id="itoa" name="itoa">,
3057 <ref id="ultoa" name="ultoa">,
3058 <ref id="utoa" name="utoa">
3064 <sect1>localeconv<label id="localeconv"><p>
3068 <tag/Function/Returns a pointer to the current locale structure.
3069 <tag/Header/<tt/<ref id="locale.h" name="locale.h">/
3070 <tag/Declaration/<tt/struct lconv* localeconv (void);/
3071 <tag/Description/<tt/localeconv/ returns a pointer to the current locale
3073 <tag/Limits/<itemize>
3074 <item>cc65 supports only the "C" locale, so even after setting a new locale
3075 using <tt/<ref id="setlocale" name="setlocale">/, the structure returned will
3078 <tag/Availability/ISO 9899
3080 <ref id="setlocale" name="setlocale">
3086 <sect1>longjmp<label id="longjmp"><p>
3090 <tag/Function/Non local goto.
3091 <tag/Header/<tt/<ref id="setjmp.h" name="setjmp.h">/
3092 <tag/Declaration/<tt/void __fastcall__ longjmp (jmp_buf buf, int retval);/
3093 <tag/Description/The <tt/longjmp/ function restores a program context from the
3094 data in <tt/buf/, which must have been set by a preceeding call to
3095 <tt/<ref id="setjmp" name="setjmp">/. Program execution continues as if the
3096 call to <tt/<ref id="setjmp" name="setjmp">/ has just returned the value
3100 <item>If the parameter <tt/retval/ is zero, the function will behave as if it
3101 was called with a value of one.
3102 <item>The function is only available as fastcall function, so it may only
3103 be used in presence of a prototype.
3105 <tag/Availability/ISO 9899
3107 <ref id="setjmp" name="setjmp">
3113 <sect1>malloc<label id="malloc"><p>
3117 <tag/Function/Allocate dynamic memory.
3118 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
3119 <tag/Declaration/<tt/void* __fastcall__ malloc (size_t size);/
3120 <tag/Description/<tt/malloc/ allocates size bytes on the heap and returns a
3121 pointer to the allocated memory block. On error (not enough memory available),
3122 <tt/malloc/ returns <tt/NULL/.
3125 <item>The function is only available as fastcall function, so it may only
3126 be used in presence of a prototype.
3128 <tag/Availability/ISO 9899
3130 <ref id="_heapadd" name="_heapadd">,
3131 <ref id="_heapblocksize" name="_heapblocksize">,
3132 <ref id="_heapmaxavail" name="_heapmaxavail">,
3133 <ref id="_heapmemavail" name="_heapmemavail">,
3134 <ref id="calloc" name="calloc">,
3135 <ref id="free" name="free">,
3136 <ref id="realloc" name="realloc">,
3137 <ref id="strdup" name="strdup">
3143 <sect1>memchr<label id="memchr"><p>
3147 <tag/Function/Search for a character in a block of raw memory.
3148 <tag/Header/<tt/<ref id="string.h" name="string.h">/
3149 <tag/Declaration/<tt/void* __fastcall__ strchr (const void* mem, int c, size_t count);/
3150 <tag/Description/The <tt/memchr/ function locates the first occurrence of <tt/c/
3151 (converted to a char) in the block of raw memory string pointed to by <tt/mem/
3152 that is of size <tt/count/. Upon completion, the function returns a pointer to
3153 the character found, or a null pointer if the character was not found.
3154 <tag/Limits/<itemize>
3155 <item>The function is only available as fastcall function, so it may only
3156 be used in presence of a prototype.
3158 <tag/Availability/ISO 9899
3160 <ref id="strchr" name="strchr">
3166 <sect1>memcpy<label id="memcpy"><p>
3170 <tag/Function/Copy a memory area.
3171 <tag/Header/<tt/<ref id="string.h" name="string.h">/
3172 <tag/Declaration/<tt/void* __fastcall__ memcpy (void* dest, const void* src, size_t count);/
3173 <tag/Description/<tt/memcpy/ copies <tt/count/ bytes from the memory area
3174 pointed to by <tt/src/ into the memory area pointed to by <tt/dest/. It returns
3178 <item>The result is undefined if the memory areas do overlap. Use
3179 <tt/<ref id="memmove" name="memmove">/ to copy overlapping memory areas.
3180 <item>The function is only available as fastcall function, so it may only
3181 be used in presence of a prototype.
3183 <tag/Availability/ISO 9899
3185 <ref id="_swap" name="_swap">,
3186 <ref id="memmove" name="memmove">,
3187 <ref id="memset" name="memset">
3193 <sect1>memmove<label id="memmove"><p>
3197 <tag/Function/Copy a memory area.
3198 <tag/Header/<tt/<ref id="string.h" name="string.h">/
3199 <tag/Declaration/<tt/void* __fastcall__ memmove (void* dest, const void* src, size_t count);/
3200 <tag/Description/<tt/memmove/ copies <tt/count/ bytes from the memory area
3201 pointed to by <tt/src/ into the memory area pointed to by <tt/dest/. It returns
3205 <item>While <tt/memmove/ allows the memory areas to overlap, it has some
3206 additional overhead compared to <tt/<ref id="memcpy" name="memcpy">/.
3207 <item>The function is only available as fastcall function, so it may only
3208 be used in presence of a prototype.
3210 <tag/Availability/ISO 9899
3212 <ref id="_swap" name="_swap">,
3213 <ref id="memcpy" name="memcpy">,
3214 <ref id="memset" name="memset">
3220 <sect1>memset<label id="memset"><p>
3224 <tag/Function/Fill a memory area.
3225 <tag/Header/<tt/<ref id="string.h" name="string.h">/
3226 <tag/Declaration/<tt/void* __fastcall__ memset (void* p, int val, size_t count);/
3227 <tag/Description/<tt/memset/ fills the memory area pointed to by <tt/p/ with
3228 the value <tt/val/. The function returns <tt/p/.
3231 <item>The function is only available as fastcall function, so it may only
3232 be used in presence of a prototype.
3234 <tag/Availability/ISO 9899
3236 <ref id="_swap" name="_swap">,
3237 <ref id="bzero" name="bzero">,
3238 <ref id="memcpy" name="memcpy">,
3239 <ref id="memmove" name="memmove">
3245 <sect1>mod_free<label id="mod_free"><p>
3249 <tag/Function/Free a relocatable module.
3250 <tag/Header/<tt/<ref id="modload.h" name="modload.h">/
3251 <tag/Declaration/<tt/void __fastcall__ mod_free (void* module);/
3252 <tag/Description/The function will free a module loaded into memory by use of
3253 the <tt/<ref id="mod_load" name="mod_load">/ function.
3254 <tag/Limits/<itemize>
3255 <item>The pointer passed as parameter is the pointer to the module memory,
3256 not the pointer to the control structure.
3258 <tag/Availability/cc65
3260 <ref id="mod_load" name="mod_load">
3266 <sect1>mod_load<label id="mod_load"><p>
3270 <tag/Function/Load a relocatable module.
3271 <tag/Header/<tt/<ref id="modload.h" name="modload.h">/
3272 <tag/Declaration/<tt/unsigned char mod_load (struct mod_ctrl* ctrl);/
3273 <tag/Description/The function will load a code module into memory and relocate
3274 it. The function will return an error code. If <tt/MLOAD_OK/ is returned, the
3275 outgoing fields in the passed <tt/mod_ctrl/ struct contain information about
3276 the module just loaded. Possible error codes are:
3278 <item><tt/MLOAD_OK/ - Module load successful
3279 <item><tt/MLOAD_ERR_READ/ - Read error
3280 <item><tt/MLOAD_ERR_HDR/ - Header error
3281 <item><tt/MLOAD_ERR_OS/ - Wrong operating system
3282 <item><tt/MLOAD_ERR_FMT/ - Data format error
3283 <item><tt/MLOAD_ERR_MEM/ - Not enough memory
3285 <tag/Limits/<itemize>
3286 <item>The <htmlurl url="ld65.html" name="ld65"> linker is needed to create
3287 relocatable o65 modules for use with this function.
3289 <tag/Availability/cc65
3291 <ref id="mod_free" name="mod_free">
3297 <sect1>mouse_setbox<label id="mouse_setbox"><p>
3301 <tag/Function/Specify a bounding box for the mouse cursor.
3302 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3303 <tag/Declaration/<tt/void __fastcall__ mouse_setbox (const struct mouse_box* box);/
3304 <tag/Description/The function allows to set a bounding box for mouse movement.
3305 <tag/Limits/<itemize>
3306 <item>The function does not check if the mouse cursor is currently within the
3307 given rectangle. Placing the mouse cursor within the bounding box is the
3308 responsibility of the programmer.
3309 <item>While the bounding box may be larger than the actual screen size, the
3310 standard mouse cursor draw routines may fail to set the cursor to coordinates
3311 outside of the screen area. Depending on the platform, you may have to supply
3312 your own mouse cursor routines.
3313 <item>The function is only available as fastcall function, so it may only be
3314 used in presence of a prototype.
3316 <tag/Availability/cc65
3318 <ref id="mouse_getbox" name="mouse_getbox">,
3319 <ref id="mouse_move" name="mouse_move">
3325 <sect1>mouse_getbox<label id="mouse_getbox"><p>
3329 <tag/Function/Return the current bounding box for the mouse cursor.
3330 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3331 <tag/Declaration/<tt/void __fastcall__ mouse_getbox (struct mouse_box* box);/
3332 <tag/Description/The function queries the current bounding box for mouse
3334 <tag/Limits/<itemize>
3335 <item>The function is only available as fastcall function, so it may only be
3336 used in presence of a prototype.
3338 <tag/Availability/cc65
3340 <ref id="mouse_move" name="mouse_move">,
3341 <ref id="mouse_setbox" name="mouse_setbox">
3347 <sect1>mouse_buttons<label id="mouse_buttons"><p>
3351 <tag/Function/Return a bit mask encoding the state of the mouse buttons.
3352 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3353 <tag/Declaration/<tt/unsigned char __fastcall__ mouse_buttons (void);/
3354 <tag/Description/The function returns a bit mask that encodes the state of the
3355 mouse buttons. You may use the <tt/MOUSE_BTN_XXX/ flags to decode the function
3357 <tag/Limits/<itemize>
3358 <item>The function is only available as fastcall function, so it may only be
3359 used in presence of a prototype.
3361 <tag/Availability/cc65
3363 <ref id="mouse_info" name="mouse_info">,
3364 <ref id="mouse_pos" name="mouse_pos">
3370 <sect1>mouse_geterrormsg<label id="mouse_geterrormsg"><p>
3374 <tag/Function/Return a readable error message for an error code.
3375 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3376 <tag/Declaration/<tt/const char* __fastcall__ mouse_geterrormsg (unsigned char
3378 <tag/Description/The function returns an error message (in english) for the
3379 error code passed parameter.
3380 <tag/Limits/<itemize>
3381 <item>The function will return "Unknown error" for invalid error codes.
3382 <item>The function is only available as fastcall function, so it may only be
3383 used in presence of a prototype.
3385 <tag/Availability/cc65
3387 <ref id="mouse_load_driver" name="mouse_load_driver">,
3388 <ref id="mouse_uninstall" name="mouse_uninstall">,
3389 <ref id="mouse_unload" name="mouse_unload">
3395 <sect1>mouse_hide<label id="mouse_hide"><p>
3399 <tag/Function/Hide the mouse pointer.
3400 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3401 <tag/Declaration/<tt/void __fastcall__ mouse_hide (void);/
3402 <tag/Description/The function hides the mouse pointer. It manages a counter
3403 that is shared between <tt/<ref id="mouse_show" name="mouse_show">/ and
3404 <tt/mouse_hide/ so that every call call to <tt/mouse_hide/ must be followed by
3405 a call to <tt/<ref id="mouse_show" name="mouse_show">/ to make the mouse cursor
3407 <tag/Limits/<itemize>
3408 <item>The function is only available as fastcall function, so it may only be
3409 used in presence of a prototype.
3411 <tag/Availability/cc65
3413 <ref id="mouse_show" name="mouse_show">
3419 <sect1>mouse_info<label id="mouse_info"><p>
3423 <tag/Function/Return the state of the mouse buttons and the position of the
3425 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3426 <tag/Declaration/<tt/void __fastcall__ mouse_info (struct mouse_info* info);/
3427 <tag/Description/The function returns the state of the mouse buttons and the
3428 position of the mouse in the <tt/mouse_info/ structure passed as parameter.
3429 <tag/Limits/<itemize>
3430 <item>The <tt/mouse_info/ struct is a superset of the <tt/mouse_pos/ struct,
3431 so if you just need the mouse position, call <tt/<ref id="mouse_pos"
3432 name="mouse_pos">/ instead.
3433 <item>The function is only available as fastcall function, so it may only be
3434 used in presence of a prototype.
3436 <tag/Availability/cc65
3438 <ref id="mouse_buttons" name="mouse_buttons">,
3439 <ref id="mouse_pos" name="mouse_pos">
3445 <sect1>mouse_install<label id="mouse_install"><p>
3449 <tag/Function/Install an already loaded mouse driver.
3450 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3451 <tag/Declaration/<tt/unsigned char __fastcall__ mouse_install (const struct
3452 mouse_callbacks* c, void* driver);/
3453 <tag/Description/The function installs an already loaded mouse driver and
3454 returns an error code. The <tt/mouse_callbacks/ structure passed as first
3455 parameter contains pointers to routines needed to move or hide/show the mouse
3456 pointer. Defaults for these routines are supplied by the library, so if you
3457 can live with these defaults (which are platform specific), just pass a
3458 pointer to <tt/mouse_def_callbacks/. The function may be used to install a
3459 driver linked statically to the program.
3460 <tag/Limits/<itemize>
3461 <item>Not all drivers are able to detect if the supported hardware is really
3463 <item>After installing a driver, the mouse cursor is hidden.
3464 <item>The function is only available as fastcall function, so it may only be
3465 used in presence of a prototype.
3467 <tag/Availability/cc65
3469 <ref id="mouse_load_driver" name="mouse_load_driver">,
3470 <ref id="mouse_uninstall" name="mouse_uninstall">,
3471 <ref id="mouse_unload" name="mouse_unload">
3477 <sect1>mouse_ioctl<label id="mouse_ioctl"><p>
3481 <tag/Function/Call the driver specific ioctl function.
3482 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3483 <tag/Declaration/<tt/unsigned char __fastcall__ mouse_ioctl (unsigned char code, void* data);/
3484 <tag/Description/The function calls the IOCTL entry in the mouse driver,
3485 which is driver specific. The <tt/code/ parameter will choose between
3486 different IOCTL functions, and the <tt/data/ depends on code. The
3487 function returns an error code. The purpose of this function is to allow
3488 for driver specific extensions. See the documentation for a specific mouse
3489 driver for supported ioctl calls.
3490 <tag/Limits/<itemize>
3491 <item>Calling this function is non portable, because each driver may
3492 implement different ioctl calls (or none at all).
3493 <item>The function is only available as fastcall function, so it may only be
3494 used in presence of a prototype.
3496 <tag/Availability/cc65
3502 <sect1>mouse_load_driver<label id="mouse_load_driver"><p>
3506 <tag/Function/Load and initialize a mouse driver.
3507 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3508 <tag/Declaration/<tt/unsigned char __fastcall__ mouse_load_driver (const struct
3509 mouse_callbacks* c, const char* driver);/
3510 <tag/Description/Load a mouse driver into memory and initialize it. The
3511 function returns an error code that tells if the call has been successful. The
3512 <tt/mouse_callbacks/ structure passed as first parameter contains pointers to
3513 routines needed to move or hide/show the mouse pointer. Defaults for these
3514 routines are supplied by the library, so if you can live with these defaults
3515 (which are platform specific), just pass a pointer to <tt/mouse_def_callbacks/.
3516 <tag/Limits/<itemize>
3517 <item>The driver is loaded by name, so currently you must know the type of
3518 mouse that should be supported. There is no autodetect capability.
3519 <item>Not all drivers are able to detect if the supported hardware is really
3521 <item>After installing a driver, the mouse cursor is hidden.
3522 <item>The function is only available as fastcall function, so it may only be
3523 used in presence of a prototype.
3525 <tag/Availability/cc65
3527 <ref id="mouse_install" name="mouse_install">,
3528 <ref id="mouse_uninstall" name="mouse_uninstall">,
3529 <ref id="mouse_unload" name="mouse_unload">
3535 <sect1>mouse_move<label id="mouse_move"><p>
3539 <tag/Function/Move the mouse cursor to a specific position.
3540 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3541 <tag/Declaration/<tt/void __fastcall__ mouse_move (int x, int y);/
3542 <tag/Description/The function updates the mouse position. If the mouse cursor
3543 is visible, it is shown at the new position.
3544 <tag/Limits/<itemize>
3545 <item>The function does not check if the new position is within the bounding
3546 box specified with <tt/<ref id="mouse_setbox" name="mouse_setbox">/.
3547 <item>The function is only available as fastcall function, so it may only be
3548 used in presence of a prototype.
3550 <tag/Availability/cc65
3552 <ref id="mouse_getbox" name="mouse_getbox">,
3553 <ref id="mouse_setbox" name="mouse_setbox">
3559 <sect1>mouse_pos<label id="mouse_pos"><p>
3563 <tag/Function/Return the position of the mouse.
3564 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3565 <tag/Declaration/<tt/void __fastcall__ mouse_pos (struct mouse_pos* pos);/
3566 <tag/Description/The function returns the position of the mouse in the
3567 <tt/mouse_pos/ structure passed as parameter.
3568 <tag/Limits/<itemize>
3569 <item>The <tt/mouse_pos/ struct is a subset of the <tt/mouse_info/ struct,
3570 so if you do also need the mouse buttons, call <tt/<ref id="mouse_info"
3571 name="mouse_info">/ instead.
3572 <item>The function is only available as fastcall function, so it may only be
3573 used in presence of a prototype.
3575 <tag/Availability/cc65
3577 <ref id="mouse_buttons" name="mouse_buttons">,
3578 <ref id="mouse_info" name="mouse_info">
3584 <sect1>mouse_show<label id="mouse_show"><p>
3588 <tag/Function/Show the mouse pointer.
3589 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3590 <tag/Declaration/<tt/void __fastcall__ mouse_show (void);/
3591 <tag/Description/The function shows the mouse pointer. It manages a counter
3592 that is shared between <tt/<ref id="mouse_hide" name="mouse_hide">/ and
3593 <tt/mouse_show/. The mouse cursor is visible if there was one more call to
3594 <tt/mouse_show/ than to <tt/<ref id="mouse_hide" name="mouse_hide">/.
3595 <tag/Limits/<itemize>
3596 <item>The function is only available as fastcall function, so it may only be
3597 used in presence of a prototype.
3599 <tag/Availability/cc65
3601 <ref id="mouse_hide" name="mouse_hide">
3607 <sect1>mouse_uninstall<label id="mouse_uninstall"><p>
3611 <tag/Function/Uninstall an already loaded mouse driver.
3612 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3613 <tag/Declaration/<tt/unsigned char __fastcall__ mouse_install (void);/
3614 <tag/Description/The function uninstalls an already loaded mouse driver but
3615 don't removes it from memory.
3616 <tag/Limits/<itemize>
3617 <item>If the driver has been loaded using <tt/<ref id="mouse_load_driver"
3618 name="mouse_load_driver">/, <tt/<ref id="mouse_unload" name="mouse_unload">/
3619 should be used instead of <tt/mouse_uninstall/ so the driver is also removed
3621 <item>The function is only available as fastcall function, so it may only be
3622 used in presence of a prototype.
3624 <tag/Availability/cc65
3626 <ref id="mouse_install" name="mouse_install">,
3627 <ref id="mouse_load_driver" name="mouse_load_driver">,
3628 <ref id="mouse_unload" name="mouse_unload">
3634 <sect1>mouse_unload<label id="mouse_unload"><p>
3638 <tag/Function/Unload a mouse driver.
3639 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3640 <tag/Declaration/<tt/unsigned char __fastcall__ mouse_unload (void);/
3641 <tag/Description/The function unloads a loaded mouse driver and frees all
3642 memory allocated for the driver.
3643 <tag/Limits/<itemize>
3644 <item>The function does nothing if no driver is loaded.
3646 <tag/Availability/cc65
3648 <ref id="mouse_install" name="mouse_install">,
3649 <ref id="mouse_load_driver" name="mouse_load_driver">,
3650 <ref id="mouse_uninstall" name="mouse_uninstall">
3656 <sect1>offsetof<label id="offsetof"><p>
3660 <tag/Function/Calculate the offset of a struct or union member.
3661 <tag/Header/<tt/<ref id="stddef.h" name="stddef.h">/
3662 <tag/Declaration/<tt/size_t offsetof (type, member);/
3663 <tag/Description/<tt/offsetof/ calculates the address offset of a <tt/struct/
3664 or <tt/union/ member.
3665 <tag/Limits/<itemize>
3666 <item>The function is actually a macro.
3668 <tag/Availability/ISO 9899
3674 <sect1>open<label id="open"><p>
3678 <tag/Function/Open and possibly create a file.
3679 <tag/Header/<tt/<ref id="fcntl.h" name="fcntl.h">/
3680 <tag/Declaration/<tt/int open (const char* name, int flags, ...);/
3681 <tag/Description/<tt/open/ opens a file and returns the file descriptor
3682 associated with it. On error, -1 is returned and an error code is stored in
3683 <tt/errno/. Several flags may be passed to <tt/open/ that change the behaviour.
3684 <tag/Limits/<itemize>
3685 <item>POSIX specifies an additional <tt/mode/ argument that may be passed to
3686 open, which is used as the permission mask when a new file is created. While
3687 cc65 allows to pass this argument, it is ignored.
3689 <tag/Availability/POSIX 1003.1
3691 <ref id="close" name="close">,
3692 <ref id="creat" name="creat">
3698 <sect1>peekbsys<label id="peekbsys"><p>
3702 <tag/Function/Read one byte from a location in the system bank.
3703 <tag/Header/<tt/<ref id="cbm610.h" name="cbm610.h">/,
3704 <tt/<ref id="cbm510.h" name="cbm510.h">/
3705 <tag/Declaration/<tt/unsigned char __fastcall__ peekbsys (unsigned addr);/
3706 <tag/Description/<tt/peekbsys/ reads one byte from the given address in the
3707 system bank (bank 15) of the CBM PET-II machines and returns it.
3710 <item>The function is only available as fastcall function, so it may only
3711 be used in presence of a prototype.
3712 <item>This function may be a macro depending on the compiler options. The
3713 actual function is accessible by #undef'ing the macro.
3715 <tag/Availability/cc65
3717 <ref id="PEEK" name="PEEK">,
3718 <ref id="PEEKW" name="PEEKW">,
3719 <ref id="peekwsys" name="peekwsys">,
3720 <ref id="pokebsys" name="pokebsys">,
3721 <ref id="pokewsys" name="pokewsys">
3727 <sect1>peekwsys<label id="peekwsys"><p>
3731 <tag/Function/Read one word from a location in the system bank.
3732 <tag/Header/<tt/<ref id="cbm610.h" name="cbm610.h">/,
3733 <tt/<ref id="cbm510.h" name="cbm510.h">/
3734 <tag/Declaration/<tt/unsigned __fastcall__ peekwsys (unsigned addr);/
3735 <tag/Description/<tt/peekwsys/ reads one word from the given address in the
3736 system bank (bank 15) of the CBM PET-II machines and returns it. Following
3737 the usual 6502 conventions, the low byte is read from <tt/addr/, and the
3738 high byte is read from <tt/addr+1/.
3741 <item>The function is only available as fastcall function, so it may only
3742 be used in presence of a prototype.
3743 <item>The order in which the two bytes are read is undefined.
3745 <tag/Availability/cc65
3747 <ref id="PEEK" name="PEEK">,
3748 <ref id="PEEKW" name="PEEKW">,
3749 <ref id="peekbsys" name="peekbsys">,
3750 <ref id="pokebsys" name="pokebsys">,
3751 <ref id="pokewsys" name="pokewsys">
3757 <sect1>perror<label id="perror"><p>
3761 <tag/Function/Print an error message for the error in <tt/errno/.
3762 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
3763 <tag/Declaration/<tt/void __fastcall__ perror (const char* s);/
3764 <tag/Description/<tt/perror/ prints an error message to <tt/stderr/. If <tt/s/
3765 is not <tt/NULL/ and not an empty string, it is printed followed by a colon and
3766 a blank. Then the error message for the current contents of <tt/errno/ is
3767 printed followed by a newline. The message output is the same as returned by
3768 <tt/<ref id="strerror" name="strerror">/ with an argument of <tt/errno/.
3771 <item>The function is only available as fastcall function, so it may only
3772 be used in presence of a prototype.
3774 <tag/Availability/ISO 9899
3776 <ref id="_poserror" name="_poserror">,
3777 <ref id="strerror" name="strerror">
3783 <sect1>pokebsys<label id="pokebsys"><p>
3787 <tag/Function/Write one byte to a location in the system bank.
3788 <tag/Header/<tt/<ref id="cbm610.h" name="cbm610.h">/,
3789 <tt/<ref id="cbm510.h" name="cbm510.h">/
3790 <tag/Declaration/<tt/void __fastcall__ pokebsys (unsigned addr, unsigned char val);/
3791 <tag/Description/<tt/pokebsys/ writes one byte to the given address in the
3792 system bank (bank 15) of the CBM PET-II machines.
3795 <item>The function is only available as fastcall function, so it may only
3796 be used in presence of a prototype.
3798 <tag/Availability/cc65
3800 <ref id="POKE" name="POKE">,
3801 <ref id="POKEW" name="POKEW">,
3802 <ref id="peekbsys" name="peekbsys">,
3803 <ref id="peekwsys" name="peekwsys">,
3804 <ref id="pokewsys" name="pokewsys">
3810 <sect1>pokewsys<label id="pokewsys"><p>
3814 <tag/Function/Write one word to a location in the system bank.
3815 <tag/Header/<tt/<ref id="cbm610.h" name="cbm610.h">/,
3816 <tt/<ref id="cbm510.h" name="cbm510.h">/
3817 <tag/Declaration/<tt/void __fastcall__ pokewsys (unsigned addr, unsigned val);/
3818 <tag/Description/<tt/pokewsys/ writes one word to the given address in the
3819 system bank (bank 15) of the CBM PET-II machines. Following the usual 6502
3820 conventions, the low byte of <tt/val/ is written to <tt/addr/, and the
3821 high byte is written to <tt/addr+1/.
3824 <item>The function is only available as fastcall function, so it may only
3825 be used in presence of a prototype.
3826 <item>The order in which the two bytes are written is undefined.
3828 <tag/Availability/cc65
3830 <ref id="POKE" name="POKE">,
3831 <ref id="POKEW" name="POKEW">,
3832 <ref id="peekbsys" name="peekbsys">,
3833 <ref id="peekwsys" name="peekwsys">,
3834 <ref id="pokebsys" name="pokebsys">
3840 <sect1>qsort<label id="qsort"><p>
3844 <tag/Function/Sort an array.
3845 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
3846 <tag/Declaration/<tt/void __fastcall__ qsort (void* base, size_t count,
3847 size_t size, int (*compare) (const void*, const void*));/
3848 <tag/Description/<tt/qsort/ sorts an array according to a given compare
3849 function <tt/compare/. <tt/base/ is the address of the array, <tt/count/
3850 is the number of elements, <tt/size/ the size of an element and <tt/compare/
3851 the function used to compare the members.
3854 <item>If there are multiple members with the same key, the order after calling
3855 the function is undefined.
3856 <item>The function is only available as fastcall function, so it may only
3857 be used in presence of a prototype.
3859 <tag/Availability/ISO 9899
3861 <ref id="bsearch" name="bsearch">
3867 <sect1>raise<label id="raise"><p>
3871 <tag/Function/Send a signal to the executing program.
3872 <tag/Header/<tt/<ref id="signal.h" name="signal.h">/
3873 <tag/Declaration/<tt/int __fastcall__ raise (int sig);/
3874 <tag/Description/<tt/raise/ sends the given signal to the program. If the
3875 program has installed a signal handler for the signal, this signal handler
3876 will be executed. If no handler has been installed, the default action for
3877 the raised signal will be taken. The function returns zero on success,
3879 <tag/Limits/<itemize>
3880 <item>The function is only available as fastcall function, so it may only
3881 be used in presence of a prototype.
3883 <tag/Availability/ISO 9899
3885 <ref id="abort" name="abort">,
3886 <ref id="signal" name="signal">
3892 <sect1>rand<label id="rand"><p>
3896 <tag/Function/Return a pseudo random number.
3897 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
3898 <tag/Declaration/<tt/int rand (void);/
3899 <tag/Description/The function returns a pseudo random number
3900 between 0 and <tt/RAND_MAX/ (exclusive).
3901 <tag/Limits/<itemize>
3902 <item>Without using <tt><ref id="srand" name="srand"></tt>, always the same
3903 flow of numbers is generated.
3904 <item>On startup, the function behaves as if <ref id="srand" name="srand">
3905 had been used with an argument of 1.
3907 <tag/Availability/ISO 9899
3909 <ref id="_randomize" name="_randomize">,
3910 <ref id="srand" name="srand">
3916 <sect1>realloc<label id="realloc"><p>
3920 <tag/Function/Change the size of an allocated memory block.
3921 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
3922 <tag/Declaration/<tt/void* __fastcall__ realloc (void* block, size_t size);/
3923 <tag/Description/<tt/realloc/ changes the size of the memory block pointed to
3924 by <tt/block/ to <tt/size/ bytes. If <tt/block/ is <tt/NULL/, <tt/realloc/
3925 behaves as if <tt/malloc/ had been called. If <tt/size/ is zero, <tt/realloc/
3926 behaves as if <tt/free/ had been called. On error (not enough memory
3927 available), <tt/realloc/ returns <tt/NULL/.
3930 <item>The part of the memory block that is returned will have its contents
3932 <item>This function is somewhat dangerous to use. Be careful to save the
3933 pointer you're passing somewhere else, otherwise
3935 ptr = realloc (ptr, size);
3937 will loose your only copy of <tt/ptr/ if <tt/realloc/ returns <tt/NULL/.
3938 <item>The function is only available as fastcall function, so it may only
3939 be used in presence of a prototype.
3941 <tag/Availability/ISO 9899
3943 <ref id="_heapadd" name="_heapadd">,
3944 <ref id="_heapblocksize" name="_heapblocksize">,
3945 <ref id="_heapmaxavail" name="_heapmaxavail">,
3946 <ref id="_heapmemavail" name="_heapmemavail">,
3947 <ref id="calloc" name="calloc">,
3948 <ref id="free" name="free">,
3949 <ref id="realloc" name="realloc">
3955 <sect1>remove<label id="remove"><p>
3959 <tag/Function/Delete a file.
3960 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
3961 <tag/Declaration/<tt/int __fastcall__ remove (const char* name);/
3962 <tag/Description/<tt/remove/ deletes the file with the given name. On success,
3963 zero is returned. On error, -1 is returned and <tt/errno/ is set to an error
3964 code describing the reason for the failure.
3967 <item>This function is not available on all cc65 targets (depends on the
3968 availability of file I/O).
3969 <item>The function is only available as fastcall function, so it may only
3970 be used in presence of a prototype.
3972 <tag/Availability/ISO 9899
3974 <ref id="rename" name="rename">,
3975 <ref id="unlink" name="unlink">
3978 #include <stdio.h>
3980 #define FILENAME "helloworld"
3982 if (remove (FILENAME) == 0) {
3983 printf ("We deleted %s successfully\n", FILENAME);
3985 printf ("There was a problem deleting %s\n", FILENAME);
3992 <sect1>rename<label id="rename"><p>
3996 <tag/Function/Rename a file.
3997 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
3998 <tag/Declaration/<tt/int __fastcall__ rename (const char* oldname, const char* newname);/
3999 <tag/Description/<tt/rename/ renames a file (gives it a new name). On success,
4000 zero is returned. On error, -1 is returned and <tt/errno/ is set to an error
4001 code describing the reason for the failure.
4004 <item>This function is not available on all cc65 targets (depends on the
4005 capabilities of the storage devices).
4006 <item>The function is only available as fastcall function, so it may only
4007 be used in presence of a prototype.
4009 <tag/Availability/ISO 9899
4011 <ref id="remove" name="remove">
4014 #include <stdio.h>
4016 #define OLDNAME "textfile.txt"
4017 #define NEWNAME "textfile.bak"
4019 if (rename (OLDNAME, NEWNAME) == 0) {
4020 printf ("Renamed %s to %s\n", OLDNAME, NEWNAME);
4022 printf ("Error renaming %s to %s\n", OLDNAME, NEWNAME);
4029 <sect1>reset_brk<label id="reset_brk"><p>
4033 <tag/Function/Resets the break vector to its original value.
4034 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
4035 <tag/Declaration/<tt/void __fastcall__ reset_brk (void);/
4036 <tag/Description/<tt/reset_brk/ resets the break vector to the value it had
4037 before a call to <tt/set_brk/.
4040 <item>Since <tt/<ref id="set_brk" name="set_brk">/ installs an exit handler,
4041 it is not strictly necessary to call this function as part of the cleanup when
4044 <tag/Availability/cc65
4046 <ref id="set_brk" name="set_brk">
4052 <sect1>revers<label id="revers"><p>
4056 <tag/Function/Control revers character display.
4057 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
4058 <tag/Declaration/<tt/unsigned char __fastcall__ revers (unsigned char onoff);/
4059 <tag/Description/If the argument is non zero, the function enables reverse
4060 character display. If the argument is zero, reverse character display is
4061 switched off. The old value of the setting is returned.
4062 <tag/Limits/<itemize>
4063 <item>The function may not be supported by the hardware, in which case
4064 the call is ignored.
4065 <item>The function is only available as fastcall function, so it may only
4066 be used in presence of a prototype.
4068 <tag/Availability/cc65
4070 <ref id="textcolor" name="textcolor">
4076 <sect1>screensize<label id="screensize"><p>
4080 <tag/Function/Return the dimensions of the text mode screen.
4081 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
4082 <tag/Declaration/<tt/void __fastcall__ screensize (unsigned char* x, unsigned char* y);/
4083 <tag/Description/The function returns the dimensions of the text mode screen.
4084 <tag/Limits/<itemize>
4085 <item>The function is only available as fastcall function, so it may only
4086 be used in presence of a prototype.
4088 <tag/Availability/cc65
4090 <ref id="gotox" name="gotox">,
4091 <ref id="gotoxy" name="gotoxy">,
4092 <ref id="gotoy" name="gotoy">,
4093 <ref id="wherex" name="wherex">,
4094 <ref id="wherey" name="wherey">
4100 <sect1>set_brk<label id="set_brk"><p>
4104 <tag/Function/Set the break vector to a user function.
4105 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
4106 <tag/Declaration/<tt/void __fastcall__ set_brk (brk_handler func);/
4107 <tag/Description/<tt/set_brk/ allows a user program to handle breaks within the
4108 program code by letting the vector point to a user written C function. The
4109 runtime library installs a small stub that saves the registers into global
4110 variables that may be accessed (and changed) by the break handler.
4113 <item>The function is only available as fastcall function, so it may only
4114 be used in presence of a prototype.
4115 <item>The stub saves the zero page registers used by the C runtime and switches
4116 to a small break handler stack. This means that it is safe to execute C code,
4117 even if C code was interrupted. Be careful however not to use too many local
4118 variables, and do not enable stack checks for the handler function or any other
4119 function called from it.
4120 <item>The <tt/brk_pc/ variable points to the <tt/BRK/ instruction. If you want
4121 the continue with the interrupted code, you have to adjust <tt/brk_pc/,
4122 otherwise the <tt/BRK/ instruction will get executed over and over again.
4123 <item>Since <tt/set_brk/ installs an exit handler, it is not strictly necessary
4124 to call <tt/<ref id="reset_brk" name="reset_brk">/ as part of the cleanup when
4125 the program terminates.
4127 <tag/Availability/cc65
4129 <ref id="reset_brk" name="reset_brk">
4135 <sect1>setjmp<label id="setjmp"><p>
4139 <tag/Function/Save the context for use with <tt/longjmp/.
4140 <tag/Header/<tt/<ref id="setjmp.h" name="setjmp.h">/
4141 <tag/Declaration/<tt/int __fastcall__ setjmp (jmp_buf buf);/
4142 <tag/Description/The <tt/setjmp/ function saves the current context in <tt/buf/
4143 for subsequent use by the <tt/<ref id="longjmp" name="longjmp">/ function and
4147 <item>The function is only available as fastcall function, so it may only
4148 be used in presence of a prototype.
4149 <item><tt/setjmp/ is actually a macro as required by the ISO standard.
4150 <item><tt/setjmp/ will not save the signal context.
4152 <tag/Availability/ISO 9899
4154 <ref id="longjmp" name="longjmp">
4160 <sect1>setlocale<label id="setlocale"><p>
4164 <tag/Function/Selects a locale.
4165 <tag/Header/<tt/<ref id="locale.h" name="locale.h">/
4166 <tag/Declaration/<tt/char* __fastcall__ setlocale (int category, const char* locale);/
4167 <tag/Description/<tt/setlocale/ sets or queries the program's locale.
4170 <item>The function is only available as fastcall function, so it may only
4171 be used in presence of a prototype.
4172 <item>cc65 supports only the "C" locale, so calling this function to set a
4173 different locale has no effect.
4175 <tag/Availability/ISO 9899
4177 <ref id="localeconv" name="localeconv">,
4178 <ref id="strcoll" name="strcoll">
4179 <ref id="strxfrm" name="strxfrm">
4185 <sect1>signal<label id="signal"><p>
4189 <tag/Function/Install a signal handler.
4190 <tag/Header/<tt/<ref id="signal.h" name="signal.h">/
4191 <tag/Declaration/<tt/__sigfunc __fastcall__ signal (int sig, __sigfunc func);/
4192 <tag/Description/<tt/signal/ installs a handler for the given signal. The
4193 handler may either be a user supplied function, or one of the predefined
4194 signal handlers <tt/SIG_IGN/ or <tt/SIG_DFL/. The function returns the
4195 previous value if the signal , or the special function vector SIG_ERR in
4197 <tag/Limits/<itemize>
4198 <item>The function is only available as fastcall function, so it may only
4199 be used in presence of a prototype.
4201 <tag/Availability/ISO 9899
4203 <ref id="abort" name="abort">,
4204 <ref id="raise" name="raise">
4210 <sect1>sleep<label id="sleep"><p>
4214 <tag/Function/Sleep for a specified amount of time.
4215 <tag/Header/<tt/<ref id="unistd.h" name="unistd.h">/
4216 <tag/Declaration/<tt/void __fastcall__ sleep (unsigned seconds);/
4217 <tag/Description/The function will return after the specified number of
4218 seconds have elapsed.
4219 <tag/Limits/<itemize>
4220 <item>The function is only available as fastcall function, so it may only
4221 be used in presence of a prototype.
4223 <tag/Availability/POSIX 1003.1
4229 <sect1>slow<label id="slow"><p>
4233 <tag/Function/Switch the C128 into 1MHz mode.
4234 <tag/Header/<tt/<ref id="c128.h" name="c128.h">/
4235 <tag/Declaration/<tt/void slow (void);/
4236 <tag/Description/The function will switch the clock of the C128 to 1MHz. This
4237 will halve the speed compared to fast mode.
4238 <tag/Limits/<itemize>
4239 <item>The function is specific to the C128.
4241 <tag/Availability/C128
4243 <ref id="fast" name="fast">,
4244 <ref id="toggle_videomode" name="toggle_videomode">,
4245 <ref id="videomode" name="videomode">
4251 <sect1>srand<label id="srand"><p>
4255 <tag/Function/Initialize the pseudo random number generator.
4256 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
4257 <tag/Declaration/<tt/void __fastcall__ srand (unsigned seed);/
4258 <tag/Description/The function initializes the random number generator using
4259 the given seed. On program startup, the generator behaves as if <tt/srand/ has
4260 been called with an argument of 1.
4261 <tag/Limits/<itemize>
4262 <item>The function is only available as fastcall function, so it may only
4263 be used in presence of a prototype.
4265 <tag/Availability/ISO 9899
4267 <ref id="_randomize" name="_randomize">,
4268 <ref id="rand" name="rand">
4274 <sect1>strcasecmp<label id="strcasecmp"><p>
4278 <tag/Function/Compare two strings case insensitive.
4279 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4280 <tag/Declaration/<tt/int __fastcall__ strcasecmp (const char* s1, const char* s2);/
4281 <tag/Description/The <tt/strcasecmp/ function compares the two strings passed
4282 as parameters without case sensitivity. It returns a value that is less than
4283 zero if <tt/s1/ is less than <tt/s2/, zero if <tt/s1/ is the same as <tt/s2/,
4284 and a value greater than zero if <tt/s1/ is greater than <tt/s2/.
4285 <tag/Limits/<itemize>
4286 <item>The function is only available as fastcall function, so it may only
4287 be used in presence of a prototype.
4288 <item>The function is not available in strict ANSI mode.
4290 <tag/Availability/cc65
4292 <ref id="strcmp" name="strcmp">,
4293 <ref id="strcoll" name="strcoll">,
4294 <ref id="stricmp" name="stricmp">,
4295 <ref id="strncmp" name="strncmp">
4296 <ref id="strxfrm" name="strxfrm">
4302 <sect1>strcat<label id="strcat"><p>
4306 <tag/Function/Concatentate two strings.
4307 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4308 <tag/Declaration/<tt/char* __fastcall__ strcat (char* s1, const char* s2);/
4309 <tag/Description/The <tt/strcat/ function appends a copy of the string
4310 pointed to by s2 (including the terminating null byte) to the end of the
4311 string pointed to by s1. The initial byte of s2 overwrites the null byte at
4313 <tag/Limits/<itemize>
4314 <item>The function is only available as fastcall function, so it may only
4315 be used in presence of a prototype.
4316 <item>If copying takes place between objects that overlap, the behaviour
4319 <tag/Availability/ISO 9899
4321 <ref id="strcpy" name="strcpy">,
4322 <ref id="strncat" name="strncat">,
4323 <ref id="strncpy" name="strncpy">
4329 <sect1>strchr<label id="strchr"><p>
4333 <tag/Function/Search for a character in a string.
4334 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4335 <tag/Declaration/<tt/char* __fastcall__ strchr (const char* s, int c);/
4336 <tag/Description/The <tt/strchr/ function locates the first occurrence of <tt/c/
4337 (converted to a char) in the string pointed to by <tt/s/. The terminating null
4338 byte is considered to be part of the string. Upon completion, the function
4339 returns a pointer to the byte, or a null pointer if the byte was not found.
4340 <tag/Limits/<itemize>
4341 <item>The function is only available as fastcall function, so it may only
4342 be used in presence of a prototype.
4344 <tag/Availability/ISO 9899
4346 <ref id="memchr" name="memchr">,
4347 <ref id="strrchr" name="strrchr">
4353 <sect1>strcmp<label id="strcmp"><p>
4357 <tag/Function/Compare two strings.
4358 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4359 <tag/Declaration/<tt/int __fastcall__ strcmp (const char* s1, const char* s2);/
4360 <tag/Description/The <tt/strcmp/ function compares the two strings passed as
4361 parameters. It returns a value that is less than zero if <tt/s1/ is less than
4362 <tt/s2/, zero if <tt/s1/ is the same as <tt/s2/, and a value greater than zero
4363 if <tt/s1/ is greater than <tt/s2/.
4364 <tag/Limits/<itemize>
4365 <item>The function is only available as fastcall function, so it may only
4366 be used in presence of a prototype.
4368 <tag/Availability/ISO 9899
4370 <ref id="strcasecmp" name="strcasecmp">,
4371 <ref id="strcoll" name="strcoll">,
4372 <ref id="stricmp" name="stricmp">,
4373 <ref id="strncmp" name="strncmp">
4374 <ref id="strxfrm" name="strxfrm">
4380 <sect1>strcoll<label id="strcoll"><p>
4384 <tag/Function/Compare two strings.
4385 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4386 <tag/Declaration/<tt/int __fastcall__ strcoll (const char* s1, const char* s2);/
4387 <tag/Description/The <tt/strcoll/ function compares the two strings passed as
4388 parameters, according to the collating sequence set by <tt/<ref id="setlocale"
4389 name="setlocale">/. It returns a value that is less than zero if <tt/s1/ is
4390 less than <tt/s2/, zero if <tt/s1/ is the same as <tt/s2/, and a value greater
4391 than zero if <tt/s1/ is greater than <tt/s2/.
4392 <tag/Limits/<itemize>
4393 <item>The function is only available as fastcall function, so it may only
4394 be used in presence of a prototype.
4396 <tag/Availability/ISO 9899
4398 <ref id="setlocale" name="setlocale">,
4399 <ref id="strcasecmp" name="strcasecmp">,
4400 <ref id="strcmp" name="strcmp">,
4401 <ref id="stricmp" name="stricmp">,
4402 <ref id="strncmp" name="strncmp">
4403 <ref id="strxfrm" name="strxfrm">
4409 <sect1>strcpy<label id="strcpy"><p>
4413 <tag/Function/Copy a string.
4414 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4415 <tag/Declaration/<tt/char* __fastcall__ strcpy (char* s1, const char* s2);/
4416 <tag/Description/The <tt/strcpy/ function copies the string pointed to by
4417 <tt/s2/ (including the terminating null byte) into the array pointed to by
4418 <tt/s1/. The function will always return <tt/s1/.
4419 <tag/Limits/<itemize>
4420 <item>The function is only available as fastcall function, so it may only
4421 be used in presence of a prototype.
4422 <item>If copying takes place between objects that overlap, the behaviour
4425 <tag/Availability/ISO 9899
4427 <ref id="strcat" name="strcat">,
4428 <ref id="strncat" name="strncat">,
4429 <ref id="strncpy" name="strncpy">
4432 #include <string.h>
4434 static char hello[14];
4436 strcpy (hello, "Hello world!\n");
4442 <sect1>strcspn<label id="strcspn"><p>
4446 <tag/Function/Compute the length of a substring.
4447 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4448 <tag/Declaration/<tt/size_t __fastcall__ strcspn (const char* s, const char* set);/
4449 <tag/Description/The <tt/strcspn/ function computes and returns the length of
4450 the substring pointed to by <tt/s/ which does <em>not</em> consist of
4451 characters contained in the string <tt/set/.
4452 <tag/Limits/<itemize>
4453 <item>The function is only available as fastcall function, so it may only
4454 be used in presence of a prototype.
4456 <tag/Availability/ISO 9899
4458 <ref id="strspn" name="strspn">,
4459 <ref id="strstr" name="strstr">,
4460 <ref id="strtok" name="strtok">
4466 <sect1>strdup<label id="strdup"><p>
4470 <tag/Function/Allocate a copy of a string on the heap.
4471 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4472 <tag/Declaration/<tt/char* __fastcall__ strdup (const char* s);/
4473 <tag/Description/<tt/strdup/ allocates a memory block on the heap, big enough
4474 to hold a copy of <tt/s/ including the terminating zero. If the allocation
4475 fails, <tt/NULL/ is returned, otherwise <tt/s/ is copied into the allocated
4476 memory block, and a pointer to the block is returned.
4477 <tag/Limits/<itemize>
4478 <item>The function is only available as fastcall function, so it may only
4479 be used in presence of a prototype.
4480 <item>It is up to the caller to free the allocated memory block.
4482 <tag/Availability/ISO 9899
4484 <ref id="free" name="free">,
4485 <ref id="malloc" name="malloc">
4491 <sect1>strerror<label id="strerror"><p>
4495 <tag/Function/Return a string describing an error code.
4496 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4497 <tag/Declaration/<tt/char* __fastcall__ strerror (int errcode);/
4498 <tag/Description/The <tt/strerror/ function returns a string describing the
4499 given error code. If an invalid error code is passed, the string "Unknown
4500 error" is returned, and <tt/errno/ is set to <tt/EINVAL/. In all other cases,
4501 <tt/errno/ is left untouched.
4502 <tag/Limits/<itemize>
4503 <item>The function is only available as fastcall function, so it may only
4504 be used in presence of a prototype.
4505 <item>While the return type of the function is a <tt/char*/, the returned
4506 string must not be modified by the caller!
4508 <tag/Availability/ISO 9899
4510 <ref id="_stroserror" name="_stroserror">
4516 <sect1>stricmp<label id="stricmp"><p>
4520 <tag/Function/Compare two strings case insensitive.
4521 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4522 <tag/Declaration/<tt/int __fastcall__ stricmp (const char* s1, const char* s2);/
4523 <tag/Description/The <tt/stricmp/ function compares the two strings passed as
4524 parameters without case sensitivity. It returns a value that is less than zero
4525 if <tt/s1/ is less than <tt/s2/, zero if <tt/s1/ is the same as <tt/s2/, and a
4526 value greater than zero if <tt/s1/ is greater than <tt/s2/.
4527 <tag/Limits/<itemize>
4528 <item>The function is only available as fastcall function, so it may only
4529 be used in presence of a prototype.
4530 <item>The function is not available in strict ANSI mode.
4532 <tag/Availability/cc65
4534 <ref id="strcasecmp" name="strcasecmp">,
4535 <ref id="strcmp" name="strcmp">,
4536 <ref id="strcoll" name="strcoll">,
4537 <ref id="strncmp" name="strncmp">
4538 <ref id="strxfrm" name="strxfrm">
4544 <sect1>strlen<label id="strlen"><p>
4548 <tag/Function/Return the length of a string.
4549 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4550 <tag/Declaration/<tt/size_t __fastcall__ strlen (const char* s);/
4551 <tag/Description/The <tt/strlen/ function computes the number of bytes in the
4552 string to which s points, not including the terminating null byte.
4553 <tag/Limits/<itemize>
4554 <item>The function is only available as fastcall function, so it may only
4555 be used in presence of a prototype.
4556 <item>When compiling with <tt/-Os/ (inline known standard functions), the
4557 function does not work correctly for strings with more than 255 characters.
4559 <tag/Availability/ISO 9899
4561 <ref id="strcpy" name="strcpy">
4567 <sect1>strlower<label id="strlower"><p>
4571 <tag/Function/Make a string lower case.
4572 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4573 <tag/Declaration/<tt/char* __fastcall__ strlower (char* s);/
4574 <tag/Description/The <tt/strlower/ function will apply the <tt/tolower/
4575 function to each character of a string. The function will always return <tt/s/.
4576 <tag/Limits/<itemize>
4577 <item>The function is only available as fastcall function, so it may only
4578 be used in presence of a prototype.
4579 <item>The function prototype is unavailable when compiling in strict ANSI mode.
4580 <item>An alias name for this function is <tt/strlwr/.
4582 <tag/Availability/cc65
4584 <ref id="strupper" name="strupper">,
4585 <ref id="tolower" name="tolower">
4591 <sect1>strlwr<label id="strlwr"><p>
4598 <sect1>strncat<label id="strncat"><p>
4602 <tag/Function/Concatentate two strings.
4603 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4604 <tag/Declaration/<tt/char* __fastcall__ strncat (char* s1, const char* s2, size_t n);/
4605 <tag/Description/The <tt/strncat/ function appends not more than n characters
4606 of the string pointed to by s2 to the end of the string pointed to by s1. The
4607 terminating null character at the end of s1 is overwritten. A terminating null
4608 character is appended to the result, even if not all of s2 is appended to s1.
4609 <tag/Limits/<itemize>
4610 <item>The function is only available as fastcall function, so it may only
4611 be used in presence of a prototype.
4612 <item>If copying takes place between objects that overlap, the behaviour
4615 <tag/Availability/ISO 9899
4617 <ref id="strcpy" name="strcpy">,
4618 <ref id="strncat" name="strncat">,
4619 <ref id="strncpy" name="strncpy">
4625 <sect1>strncmp<label id="strncmp"><p>
4629 <tag/Function/Compare two strings.
4630 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4631 <tag/Declaration/<tt/int __fastcall__ strncmp (const char* s1, const char* s2, size_t count);/
4632 <tag/Description/The <tt/strncmp/ function compares not more than <tt/count/
4633 characters of the two strings passed as parameters. It returns a value that is
4634 less than zero if the first <tt/count/ characters of <tt/s1/ are less than
4635 <tt/s2/, zero if they are identical, and a value greater than zero they are
4637 <tag/Limits/<itemize>
4638 <item>The function is only available as fastcall function, so it may only
4639 be used in presence of a prototype.
4641 <tag/Availability/ISO 9899
4643 <ref id="strcasecmp" name="strcasecmp">,
4644 <ref id="strcmp" name="strcmp">,
4645 <ref id="strcoll" name="strcoll">,
4646 <ref id="stricmp" name="stricmp">
4647 <ref id="strxfrm" name="strxfrm">
4653 <sect1>strncpy<label id="strncpy"><p>
4657 <tag/Function/Copy part of a string.
4658 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4659 <tag/Declaration/<tt/char* __fastcall__ strcpy (char* s1, const char* s2, size_t n);/
4660 <tag/Description/The <tt/strncpy/ function copies not more than n bytes from
4661 the array pointed to by <tt/s2/ to the array pointed to by <tt/s1/. If the array
4662 pointed to by <tt/s2/ is a string that is shorter than n bytes, null bytes are
4663 appended to the copy in the array pointed to by <tt/s1/, until <tt/n/ bytes are
4664 written. The function will always return <tt/s1/.
4665 <tag/Limits/<itemize>
4666 <item>The function is only available as fastcall function, so it may only
4667 be used in presence of a prototype. If there is no null byte in the first <tt/n/
4668 bytes of the array pointed to by <tt/s2/, the result is not null-terminated.
4669 <item>If copying takes place between objects that overlap, the behaviour is
4672 <tag/Availability/ISO 9899
4674 <ref id="strcat" name="strcat">,
4675 <ref id="strcpy" name="strcpy">,
4676 <ref id="strncat" name="strncat">
4681 static char hello[6];
4683 strcpy (hello, "Hello world!\n", sizeof (hello) - 1);
4690 <sect1>strrchr<label id="strrchr"><p>
4694 <tag/Function/Search for a character in a string.
4695 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4696 <tag/Declaration/<tt/char* __fastcall__ strrchr (const char* s, int c);/
4697 <tag/Description/The <tt/strrchr/ function locates the last occurrence of <tt/c/
4698 (converted to a char) in the string pointed to by <tt/s/. The terminating null
4699 byte is considered to be part of the string. Upon completion, the function
4700 returns a pointer to the byte, or a null pointer if the byte was not found.
4701 <tag/Limits/<itemize>
4702 <item>The function is only available as fastcall function, so it may only
4703 be used in presence of a prototype.
4705 <tag/Availability/ISO 9899
4707 <ref id="strchr" name="strchr">
4713 <sect1>strspn<label id="strspn"><p>
4717 <tag/Function/Compute the length of a substring.
4718 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4719 <tag/Declaration/<tt/size_t __fastcall__ strspn (const char* s, const char* set);/
4720 <tag/Description/The <tt/strspn/ function computes and returns the length of
4721 the substring pointed to by <tt/s/ which does consist only of characters
4722 contained in the string <tt/set/.
4723 <tag/Limits/<itemize>
4724 <item>The function is only available as fastcall function, so it may only
4725 be used in presence of a prototype.
4727 <tag/Availability/ISO 9899
4729 <ref id="strcspn" name="strcspn">,
4730 <ref id="strstr" name="strstr">
4736 <sect1>strstr<label id="strstr"><p>
4740 <tag/Function/Find a substring.
4741 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4742 <tag/Declaration/<tt/char* __fastcall__ strstr (const char* str, const char* substr);/
4743 <tag/Description/<tt/strstr/ searches for the first occurance of the string
4744 <tt/substr/ within <tt/str/. If found, it returns a pointer to the copy,
4745 otherwise it returns <tt/NULL/.
4746 <tag/Limits/<itemize>
4747 <item>The function is only available as fastcall function, so it may only
4748 be used in presence of a prototype.
4750 <tag/Availability/ISO 9899
4752 <ref id="strcspn" name="strcspn">,
4753 <ref id="strspn" name="strspn">
4759 <sect1>strtok<label id="strtok"><p>
4763 <tag/Function/Break a string into tokens.
4764 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4765 <tag/Declaration/<tt/char* __fastcall__ strtok (char* s1, const char* s2);/
4766 <tag/Description/<tt/strtok/ will break the string s1 into a sequence of
4767 tokens, which are delimited by characters from the string s2. The first call
4768 to <tt/strtok/ will return a pointer to the first token in the string s1.
4769 Following calls must pass a <tt/NULL/ pointer as s1 in order to get the next
4770 token in the string. Different sets of delimiters may be used for the
4771 subsequent calls to <tt/strtok/.
4772 <tag/Limits/<itemize>
4773 <item>The function is only available as fastcall function, so it may only
4774 be used in presence of a prototype.
4775 <item><tt/strtok/ will modify the string s1.
4777 <tag/Availability/ISO 9899
4779 <ref id="strcspn" name="strcspn">,
4780 <!-- <ref id="strpbrk" name="strpbrk"> -->
4786 <sect1>strxfrm<label id="strxfrm"><p>
4790 <tag/Function/Transform a string.
4791 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4792 <tag/Declaration/<tt/size_t __fastcall__ strxfrm (char* s1, const char* s2, size_t n);/
4793 <tag/Description/The <tt/strxfrm/ function transforms the string pointed to by
4794 s2 and places the resulting string into the string pointed to by s1. The
4795 transformation is such that if the <tt/strcmp/ function is applied to two
4796 transformed strings, it returns a value greater than, equal to, or less than
4797 zero, corresponding to the result of the <tt/strcoll/ function applied to the
4798 same two original strings. No more than n characters are placed into the
4799 resulting array pointed to by s1, including the terminating null character.
4800 <tag/Limits/<itemize>
4801 <item><tt/s1/ and <tt/s2/ must not point to the same memory area, otherwise
4802 the behaviour is undefined.
4803 <item>If <tt/n/ is zero, <tt/s1/ may be a NULL pointer.
4804 <item>The function is only available as fastcall function, so it may only
4805 be used in presence of a prototype.
4806 <item>Since cc65 doesn't support different charcter sets, <tt/strxfrm/ will
4807 just copy s2 to s1 using <tt><ref id="strncpy" name="strncpy"></tt>.
4809 <tag/Availability/ISO 9899
4811 <ref id="strcmp" name="strcmp">,
4812 <ref id="strcoll" name="strcoll">,
4813 <ref id="strncpy" name="strncpy">,
4819 <sect1>strupper<label id="strupper"><p>
4823 <tag/Function/Make a string upper case.
4824 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4825 <tag/Declaration/<tt/char* __fastcall__ strupper (char* s);/
4826 <tag/Description/The <tt/strupper/ function will apply the <tt/toupper/
4827 function to each character of a string. The function will always return <tt/s/.
4828 <tag/Limits/<itemize>
4829 <item>The function is only available as fastcall function, so it may only
4830 be used in presence of a prototype.
4831 <item>The function prototype is unavailable when compiling in strict ANSI mode.
4832 <item>An alias name for this function is <tt/strupr/.
4834 <tag/Availability/cc65
4836 <ref id="strlower" name="strlower">
4837 <ref id="toupper" name="toupper">
4843 <sect1>strupr<label id="strupr"><p>
4850 <sect1>textcolor<label id="textcolor"><p>
4854 <tag/Function/Set the text color.
4855 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
4856 <tag/Declaration/<tt/unsigned char __fastcall__ textcolor (unsigned char color);/
4857 <tag/Description/The function will set a new text color. It returns the old
4858 (current) text color. Text output using any <tt/conio.h/ function will use
4859 the color set by this function.
4860 <tag/Limits/<itemize>
4861 <item>Text colors are system dependent. The function may have no effect
4862 on systems where the text color cannot be changed.
4863 <item>The function is only available as fastcall function, so it may only
4864 be used in presence of a prototype.
4866 <tag/Availability/cc65
4868 <ref id="bgcolor" name="bgcolor">,
4869 <ref id="bordercolor" name="bordercolor">
4875 <sect1>tgi_arc<label id="tgi_arc"><p>
4879 <tag/Function/Draw an elliptic arc in the current color.
4880 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
4881 <tag/Declaration/<tt/void __fastcall__ tgi_arc (int x, int y,
4882 unsigned char rx, unsigned char ry, unsigned sa, unsigned ea);/
4883 <tag/Description/The function draws an elliptic arc with center at x/y and
4884 radii rx/ry using the current drawing color. The arc covers the angle
4885 between sa and ea (startangle and endangle), which must be in the range
4887 <tag/Limits/<itemize>
4888 <item>The function is only available as fastcall function, so it may only
4889 be used in presence of a prototype.
4890 <item>The function behaves unexpectedly or may crash if the angles are out
4893 <tag/Availability/cc65
4895 <ref id="tgi_bar" name="tgi_bar">,
4896 <ref id="tgi_circle" name="tgi_circle">,
4897 <ref id="tgi_ellipse" name="tgi_ellipse">,
4898 <ref id="tgi_pieslice" name="tgi_pieslice">,
4899 <ref id="tgi_setcolor" name="tgi_setcolor">
4901 /* Draw the upper half of an ellipse */
4902 tgi_setcolor(TGI_COLOR_BLUE);
4903 tgi_arc (50, 50, 40, 20, 0, 180);
4909 <sect1>tgi_bar<label id="tgi_bar"><p>
4913 <tag/Function/The function fills a rectangle on the drawpage with the current
4915 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
4916 <tag/Declaration/<tt/void __fastcall__ tgi_bar (int x1, int y1, int x2, int y2);/
4917 <tag/Description/The function fills a rectangle on the drawpage with the current
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.
4923 <tag/Availability/cc65
4924 <tag/See also/Other tgi function
4926 tgi_setcolor(TGI_COLOR_GREEN);
4927 tgi_bar(10, 10, 100, 60);
4933 <sect1>tgi_circle<label id="tgi_circle"><p>
4937 <tag/Function/The function draws a circle in the current color.
4938 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
4939 <tag/Declaration/<tt/void __fastcall__ tgi_circle (int x, int y, unsigned char radius);/
4940 <tag/Description/The function draws a circle in the current color.
4941 <tag/Limits/<itemize>
4942 <item>The function is only available as fastcall function, so it may only
4943 be used in presence of a prototype.
4945 <tag/Availability/cc65
4947 <ref id="tgi_arc" name="tgi_arc">,
4948 <ref id="tgi_bar" name="tgi_bar">,
4949 <ref id="tgi_ellipse" name="tgi_ellipse">,
4950 <ref id="tgi_pieslice" name="tgi_pieslice">,
4951 <ref id="tgi_setcolor" name="tgi_setcolor">
4953 tgi_setcolor(TGI_COLOR_BLACK);
4954 tgi_circle(50, 40, 40);
4960 <sect1>tgi_clear<label id="tgi_clear"><p>
4964 <tag/Function/Clear the drawpage
4965 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
4966 <tag/Declaration/<tt/void __fastcall__ tgi_clear (void);/
4967 <tag/Description/Clear the drawpage
4968 <tag/Limits/<itemize>
4969 <item>The function is only available as fastcall function, so it may only
4970 be used in presence of a prototype.
4972 <tag/Availability/cc65
4973 <tag/See also/Other tgi functions
4979 <sect1>tgi_done<label id="tgi_done"><p>
4983 <tag/Function/End graphics mode, switch back to text mode.
4984 Will NOT uninstall or unload the driver!
4985 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
4986 <tag/Declaration/<tt/void __fastcall__ tgi_done (void);/
4987 <tag/Description/End graphics mode, switch back to text mode.
4988 Will NOT uninstall or unload the driver!
4989 <tag/Limits/<itemize>
4990 <item>The function is only available as fastcall function, so it may only
4991 be used in presence of a prototype.
4993 <tag/Availability/cc65
4994 <tag/See also/Other tgi functions
5000 <sect1>tgi_ellipse<label id="tgi_ellipse"><p>
5004 <tag/Function/The function draws an ellipse in the current color.
5005 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5006 <tag/Declaration/<tt/void __fastcall__ tgi_ellipse (int x, int y, unsigned char rx, unsigned char ry);/
5007 <tag/Description/The function draws an ellipse at position x/y with radii
5008 rx and ry, using the current drawing color.
5009 <tag/Limits/<itemize>
5010 <item>The function is only available as fastcall function, so it may only
5011 be used in presence of a prototype.
5013 <tag/Availability/cc65
5015 <ref id="tgi_arc" name="tgi_arc">,
5016 <ref id="tgi_bar" name="tgi_bar">,
5017 <ref id="tgi_circle" name="tgi_circle">,
5018 <ref id="tgi_pieslice" name="tgi_pieslice">,
5019 <ref id="tgi_setcolor" name="tgi_setcolor">
5021 tgi_setcolor(TGI_COLOR_RED);
5022 tgi_ellipse (50, 40, 40, 20);
5028 <sect1>tgi_getcolor<label id="tgi_getcolor"><p>
5032 <tag/Function/Return the current drawing color.
5033 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5034 <tag/Declaration/<tt/unsigned char __fastcall__ tgi_getcolor (void);/
5035 <tag/Description/The actual color is an index to a palette. During tgi_init
5036 you will get a default palette. The number of colors depend on the platform.
5037 All platforms recognize at least TGI_COLOR_BLACK and TGI_COLOR_WHITE. But some
5038 platforms have many more predefined colors. If you paint using TGI_COLOR_GREEN
5039 and then you change the green of the palette to blue using tgi_setpalette then
5040 after this painting in TGI_COLOR_GREEN will actually be blue.
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
5046 <tag/See also/Other tgi functions
5048 color = tgi_getcolor();
5053 <sect1>tgi_getcolorcount<label id="tgi_getcolorcount"><p>
5057 <tag/Function/Get the number of available colors.
5058 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5059 <tag/Declaration/<tt/unsigned char __fastcall__ tgi_getcolorcount (void);/
5060 <tag/Description/Tgi platforms use indexed color palettes. This function
5061 returns the number of entries we can use in the palette.
5062 <tag/Limits/<itemize>
5063 <item>The function is only available as fastcall function, so it may only
5064 be used in presence of a prototype.
5066 <tag/Availability/cc65
5067 <tag/See also/Other tgi functions
5069 if (tgi_getcolorcount() == 2) {
5070 printf("Only monochrome graphics is supported\n");
5076 <sect1>tgi_getdefpalette<label id="tgi_getdefpalette"><p>
5080 <tag/Function/Get the palette installed by default.
5081 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5082 <tag/Declaration/<tt/const unsigned char* __fastcall__ tgi_getdefpalette (void);/
5083 <tag/Description/The tgi driver has a default palette that is active at startup.
5084 The named colors TGI_COLOR_BLACK, TGI_COLOR_WHITE, TGI_COLOR_RED... need this
5085 palette to work correctly.
5086 <tag/Limits/<itemize>
5087 <item>The function is only available as fastcall function, so it may only
5088 be used in presence of a prototype.
5090 <tag/Availability/cc65
5091 <tag/See also/Other tgi functions
5096 <sect1>tgi_geterror<label id="tgi_geterror"><p>
5100 <tag/Function/Return the error code for the last operation.
5101 This will also clear the error.
5102 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5103 <tag/Declaration/<tt/unsigned char __fastcall__ tgi_geterror (void);/
5104 <tag/Description/Return the error code for the last operation.
5105 This will also clear the error.
5106 <tag/Limits/<itemize>
5107 <item>The function is only available as fastcall function, so it may only
5108 be used in presence of a prototype.
5110 <tag/Availability/cc65
5111 <tag/See also/Other tgi functions
5116 <sect1>tgi_geterrormsg<label id="tgi_geterrormsg"><p>
5120 <tag/Function/Get an error message describing the error.
5121 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5122 <tag/Declaration/<tt/const char* __fastcall__ tgi_geterrormsg (unsigned char code);/
5123 <tag/Description/Get an error message describing the error.
5124 <tag/Limits/<itemize>
5125 <item>The function is only available as fastcall function, so it may only
5126 be used in presence of a prototype.
5128 <tag/Availability/cc65
5129 <tag/See also/Other tgi functions
5134 <sect1>tgi_getmaxcolor<label id="tgi_getmaxcolor"><p>
5138 <tag/Function/Get the highest index of the palette.
5139 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5140 <tag/Declaration/<tt/unsigned char __fastcall__ tgi_getmaxcolor (void);/
5141 <tag/Description/Get the highest index of the palette.
5142 <tag/Limits/<itemize>
5143 <item>The function is only available as fastcall function, so it may only
5144 be used in presence of a prototype.
5146 <tag/Availability/cc65
5147 <tag/See also/Other tgi functions
5152 <sect1>tgi_getmaxx<label id="tgi_getmaxx"><p>
5156 <tag/Function/Get the maximum x coordinate that can be used on this screen.
5157 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5158 <tag/Declaration/<tt/unsigned __fastcall__ tgi_getmaxx (void);/
5159 <tag/Description/Get the maximum x coordinate that can be used on this screen.
5160 <tag/Limits/<itemize>
5161 <item>The function is only available as fastcall function, so it may only
5162 be used in presence of a prototype.
5164 <tag/Availability/cc65
5165 <tag/Availability/cc65
5166 <tag/See also/Other tgi functions
5171 <sect1>tgi_getmaxy<label id="tgi_getmaxy"><p>
5175 <tag/Function/Get the maximum y coordinate that can be used on this screen.
5176 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5177 <tag/Declaration/<tt/unsigned __fastcall__ tgi_getmaxy (void);/
5178 <tag/Description/Get the maximum y coordinate that can be used on this screen.
5179 <tag/Limits/<itemize>
5180 <item>The function is only available as fastcall function, so it may only
5181 be used in presence of a prototype.
5183 <tag/Availability/cc65
5184 <tag/See also/Other tgi functions
5189 <sect1>tgi_getpagecount<label id="tgi_getpagecount"><p>
5193 <tag/Function/Return the number of screen pages available.
5194 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5195 <tag/Declaration/<tt/unsigned __fastcall__ tgi_getpagecount (void);/
5196 <tag/Description/Return the number of screen pages available.
5197 <tag/Limits/<itemize>
5198 <item>The function is only available as fastcall function, so it may only
5199 be used in presence of a prototype.
5201 <tag/Availability/cc65
5203 <ref id="tgi_setdrawpage" name="tgi_setdrawpage">,
5204 <ref id="tgi_setviewpage" name="tgi_setviewpage">
5209 <sect1>tgi_getpalette<label id="tgi_getpalette"><p>
5213 <tag/Function/Get the palette installed.
5214 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5215 <tag/Declaration/<tt/const unsigned char* __fastcall__ tgi_getpalette (void);/
5216 <tag/Description/Get the palette installed.
5217 <tag/Limits/<itemize>
5218 <item>The function is only available as fastcall function, so it may only
5219 be used in presence of a prototype.
5221 <tag/Availability/cc65
5222 <tag/See also/Other tgi functions
5227 <sect1>tgi_getpixel<label id="tgi_getpixel"><p>
5231 <tag/Function/Get the color of a pixel from the viewpage.
5232 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5233 <tag/Declaration/<tt/unsigned char __fastcall__ tgi_getpixel (int x, int y);/
5234 <tag/Description/Get the color of a pixel from the viewpage.
5235 <tag/Limits/<itemize>
5236 <item>The function is only available as fastcall function, so it may only
5237 be used in presence of a prototype.
5239 <tag/Availability/cc65
5240 <tag/See also/Other tgi functions.
5245 <sect1>tgi_getxres<label id="tgi_getxres"><p>
5249 <tag/Function/Get number of horisontal pixels on the screen.
5250 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5251 <tag/Declaration/<tt/unsigned __fastcall__ tgi_getxres (void);/
5252 <tag/Description/Get number of horisontal pixels on the screen.
5253 This is same as tgi_maxx()+1.
5254 <tag/Limits/<itemize>
5255 <item>The function is only available as fastcall function, so it may only
5256 be used in presence of a prototype.
5258 <tag/Availability/cc65
5259 <tag/See also/Other tgi functions.
5264 <sect1>tgi_getyres<label id="tgi_getyres"><p>
5268 <tag/Function/Get number of vertical pixels on the screen.
5269 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5270 <tag/Declaration/<tt/unsigned __fastcall__ tgi_getyres (void);/
5271 <tag/Description/Get number of vertical pixels on the screen.
5272 This is same as tgi_maxy()+1.
5273 <tag/Limits/<itemize>
5274 <item>The function is only available as fastcall function, so it may only
5275 be used in presence of a prototype.
5277 <tag/Availability/cc65
5278 <tag/See also/Other tgi functions.
5283 <sect1>tgi_gotoxy<label id="tgi_gotoxy"><p>
5287 <tag/Function/Set graphics cursor at x, y.
5288 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5289 <tag/Declaration/<tt/void __fastcall__ tgi_gotoxy (int x, int y);/
5290 <tag/Description/Set graphics cursor at x, y.
5291 <tag/Limits/<itemize>
5292 <item>The function is only available as fastcall function, so it may only
5293 be used in presence of a prototype.
5295 <tag/Availability/cc65
5296 <tag/See also/Other tgi functions.
5301 <sect1>tgi_init<label id="tgi_init"><p>
5305 <tag/Function/Initialize the already loaded graphics driver.
5306 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5307 <tag/Declaration/<tt/void __fastcall__ tgi_init (void);/
5308 <tag/Description/The tgi_init function will set the default palette to the
5309 hardware and clear the screen.
5310 <tag/Limits/<itemize>
5311 <item>The function is only available as fastcall function, so it may only
5312 be used in presence of a prototype.
5314 <tag/Availability/cc65
5315 <tag/See also/Other tgi functions.
5317 extern char lynxtgi[]; //Include the driver statically instead of loading it.
5318 tgi_install(&lynxtgi);
5319 tgi_init(); //Set up the default palette and clear the screen.
5324 <sect1>tgi_install<label id="tgi_install"><p>
5328 <tag/Function/Install an already loaded driver and return an error code.
5329 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5330 <tag/Declaration/<tt/unsigned char __fastcall__ tgi_install (void* driver);/
5331 <tag/Description/The function installs a driver that was already loaded into
5332 memory (or linked statically to the program). It returns an error code
5333 (<tt/TGI_ERR_OK/ in case of success).
5334 <tag/Limits/<itemize>
5335 <item>The function is only available as fastcall function, so it may only be
5336 used in presence of a prototype.
5338 <tag/Availability/cc65
5340 <ref id="tgi_load_driver" name="tgi_load_driver">,
5341 <ref id="tgi_uninstall" name="tgi_uninstall">,
5342 <ref id="tgi_unload" name="tgi_unload">
5344 extern char lynxtgi[]; //Include the driver statically instead of loading it.
5346 tgi_install(&lynxtgi);
5347 tgi_init(); //Set up the default palette and clear the screen.
5353 <sect1>tgi_ioctl<label id="tgi_ioctl"><p>
5357 <tag/Function/Platform dependent code extensions.
5358 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5359 <tag/Declaration/<tt/unsigned __fastcall__ tgi_ioctl (unsigned char code, void* data);/
5360 <tag/Description/Some platforms have extra display hardware that is not
5361 supported by standard tgi functions. You can extend the driver to support
5362 this extra hardware using tgi_ioctl functions.
5363 <tag/Limits/<itemize>
5364 <item>The function is only available as fastcall function, so it may only
5365 be used in presence of a prototype.
5366 <item>These functions are not easily portable to other cc65 platforms.
5368 <tag/Availability/cc65
5369 <tag/See also/Other tgi functions.
5371 #define tgi_sprite(spr) tgi_ioctl(0, (void*)(spr))
5372 #define tgi_flip() tgi_ioctl(1, (void*)0)
5373 #define tgi_setbgcolor(bgcol) tgi_ioctl(2, (void*)(bgcol))
5374 #define tgi_setframerate(rate) tgi_ioctl(3, (void*)(rate))
5375 #define tgi_busy() tgi_ioctl(4, (void*)0)
5376 #define tgi_updatedisplay() tgi_ioctl(4, (void*)1)
5378 tgi_sprite(&background);
5379 tgi_setcolor(TGI_COLOR_BLUE);
5380 tgi_outttextxy(20,40,"Hello World");
5381 tgi_updatedisplay();
5388 <sect1>tgi_line<label id="tgi_line"><p>
5392 <tag/Function/Draw a line in the current drawing color.
5393 The graphics cursor will be set to x2/y2 by this call.
5394 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5395 <tag/Declaration/<tt/void __fastcall__ tgi_line (int x1, int y1, int x2, int y2);/
5396 <tag/Description/Draw a line in the current drawing color.
5397 The graphics cursor will be set to x2/y2 by this call.
5398 <tag/Limits/<itemize>
5399 <item>The function is only available as fastcall function, so it may only
5400 be used in presence of a prototype.
5402 <tag/Availability/cc65
5403 <tag/See also/Other tgi functions.
5409 <sect1>tgi_lineto<label id="tgi_lineto"><p>
5413 <tag/Function/Draw a line in the current drawing color from the graphics
5414 cursor to the new end point. The graphics cursor will be updated to x2/y2.
5415 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5416 <tag/Declaration/<tt/void __fastcall__ tgi_lineto (int x2, int y2);/
5417 <tag/Description/Draw a line in the current drawing color from the graphics
5418 cursor to the new end point. The graphics cursor will be updated to x2/y2.
5419 <tag/Limits/<itemize>
5420 <item>The function is only available as fastcall function, so it may only
5421 be used in presence of a prototype.
5423 <tag/Availability/cc65
5424 <tag/See also/Other tgi functions.
5430 <sect1>tgi_load<label id="tgi_load"><p>
5434 <tag/Function/Load and install the matching driver for the given mode.
5435 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5436 <tag/Declaration/<tt/void __fastcall__ tgi_load (unsigned char mode);/
5437 <tag/Description/Load and install the matching driver for the given mode.
5438 Will just load the driver and check if loading was successul.
5439 Will not switch to graphics mode.
5440 <tag/Limits/<itemize>
5441 <item>The function is only available as fastcall function, so it may only
5442 be used in presence of a prototype.
5444 <tag/Availability/cc65
5445 <tag/See also/Other tgi functions.
5451 <sect1>tgi_load_driver<label id="tgi_load_driver"><p>
5455 <tag/Function/Load and install the given driver. This function is identical
5456 to tgi_load with the only difference that the name of the driver is specified
5458 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5459 <tag/Declaration/<tt/void __fastcall__ tgi_load_driver (const char *name);/
5460 <tag/Description/Load and install the driver by name.
5461 Will just load the driver and check if loading was successul.
5462 Will not switch to graphics mode.
5463 <tag/Limits/<itemize>
5464 <item>The function is only available as fastcall function, so it may only
5465 be used in presence of a prototype.
5467 <tag/Availability/cc65
5468 <tag/See also/Other tgi functions.
5474 <sect1>tgi_outtext<label id="tgi_outtext"><p>
5478 <tag/Function/Output text at the current graphics cursor position.
5479 The graphics cursor is moved to the end of the text.
5480 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5481 <tag/Declaration/<tt/void __fastcall__ tgi_outtext (const char* s);/
5482 <tag/Description/Output text at the current graphics cursor position.
5483 The graphics cursor is moved to the end of the text.
5484 <tag/Limits/<itemize>
5485 <item>The function is only available as fastcall function, so it may only
5486 be used in presence of a prototype.
5488 <tag/Availability/cc65
5489 <tag/See also/Other tgi functions.
5495 <sect1>tgi_outtextxy<label id="tgi_outtextxy"><p>
5499 <tag/Function/Output text at the given cursor position.
5500 The graphics cursor is moved to the end of the text.
5501 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5502 <tag/Declaration/<tt/void __fastcall__ tgi_outtextxy (int x, int y, const char* s);/
5503 <tag/Description/Output text at the given cursor position.
5504 The graphics cursor is moved to the end of the text.
5505 <tag/Limits/<itemize>
5506 <item>The function is only available as fastcall function, so it may only
5507 be used in presence of a prototype.
5509 <tag/Availability/cc65
5510 <tag/See also/Other tgi functions.
5516 <sect1>tgi_pieslice<label id="tgi_pieslice"><p>
5520 <tag/Function/Draw an elliptic pie slice in the current color.
5521 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5522 <tag/Declaration/<tt/void __fastcall__ tgi_pie slice (int x, int y,
5523 unsigned char rx, unsigned char ry, unsigned sa, unsigned ea);/
5524 <tag/Description/The function draws an elliptic pie slice with center at x/y
5525 and radii rx/ry using the current drawing color. The pie slice covers the angle
5526 between sa and ea (startangle and endangle), which must be in the range
5528 <tag/Limits/<itemize>
5529 <item>The function is only available as fastcall function, so it may only
5530 be used in presence of a prototype.
5531 <item>The function behaves unexpectedly or may crash if the angles are out
5534 <tag/Availability/cc65
5536 <ref id="tgi_bar" name="tgi_arc">,
5537 <ref id="tgi_bar" name="tgi_bar">,
5538 <ref id="tgi_circle" name="tgi_circle">,
5539 <ref id="tgi_ellipse" name="tgi_ellipse">,
5540 <ref id="tgi_setcolor" name="tgi_setcolor">
5542 /* Draw the closed upper half of an ellipse */
5543 tgi_setcolor(TGI_COLOR_BLUE);
5544 tgi_pieslice (50, 50, 40, 20, 0, 180);
5550 <sect1>tgi_setcolor<label id="tgi_setcolor"><p>
5554 <tag/Function/Set color to be used in future draw operations.
5555 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5556 <tag/Declaration/<tt/void __fastcall__ tgi_setcolor (unsigned char color);/
5557 <tag/Description/Set color to be used in future draw operations.
5558 <tag/Limits/<itemize>
5559 <item>The function is only available as fastcall function, so it may only
5560 be used in presence of a prototype.
5562 <tag/Availability/cc65
5563 <tag/See also/Other tgi functions.
5565 tgi_setcolor(TGI_COLOR_BLACK);
5567 tgi_setcolor(TGI_COLOR_WHITE);
5568 tgi_bar(10,10,20,20);
5573 <sect1>tgi_setdrawpage<label id="tgi_setdrawpage"><p>
5577 <tag/Function/Set the page for drawing.
5578 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5579 <tag/Declaration/<tt/void __fastcall__ tgi_setdrawpage (unsigned char page);/
5580 <tag/Description/If the drawpage and the viewpage are the same then all drawing
5581 is seen immediately as it is drawn. For double buffered games you can set the
5582 drawpage to a different page than the viewpage. This lets you draw the next
5583 screen in the background and when the screen is ready you display it.
5584 <tag/Limits/<itemize>
5585 <item>The function is only available as fastcall function, so it may only
5586 be used in presence of a prototype.
5588 <tag/Availability/cc65
5589 <tag/See also/Other tgi functions.
5592 tgi_outtextxy(10, 10, "Hello World");
5593 tgi_setviewpage(1); // Show page 1
5595 tgi_outtextxy(10, 10, "Creating next frame");
5597 tgi_setviewpage(0); // Show page 0
5602 <sect1>tgi_setpalette<label id="tgi_setpalette"><p>
5606 <tag/Function/Set the palette (not available with all drivers/hardware).
5607 Palette is a pointer to as many entries as there are colors.
5608 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5609 <tag/Declaration/<tt/void __fastcall__ tgi_setpalette (const unsigned char* palette);/
5610 <tag/Description/Set the palette (not available with all drivers/hardware).
5611 Palette is a pointer to as many entries as there are colors.
5612 <tag/Limits/<itemize>
5613 <item>The function is only available as fastcall function, so it may only
5614 be used in presence of a prototype.
5616 <tag/Availability/cc65
5617 <tag/See also/Other tgi functions.
5622 <sect1>tgi_setpixel<label id="tgi_setpixel"><p>
5626 <tag/Function/Plot a pixel on the drawpage with the current color.
5627 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5628 <tag/Declaration/<tt/void __fastcall__ tgi_setpixel (int x, int y);/
5629 <tag/Description/Plot a pixel on the drawpage with the current color.
5630 <tag/Limits/<itemize>
5631 <item>The function is only available as fastcall function, so it may only
5632 be used in presence of a prototype.
5634 <tag/Availability/cc65
5635 <tag/See also/Other tgi functions.
5640 <sect1>tgi_setviewpage<label id="tgi_setviewpage"><p>
5644 <tag/Function/Set page to be visible on screen.
5645 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5646 <tag/Declaration/<tt/void __fastcall__ tgi_setviewpage (unsigned char page);/
5647 <tag/Description/If the drawpage and the viewpage are the same then all drawing
5648 is seen immediately as it is drawn. For double buffered games you can set the
5649 drawpage to a different page than the viewpage. This lets you draw the next
5650 screen in the background and when the screen is ready you display it.
5651 <tag/Limits/<itemize>
5652 <item>The function is only available as fastcall function, so it may only
5653 be used in presence of a prototype.
5655 <tag/Availability/cc65
5656 <tag/See also/Other tgi functions.
5659 tgi_outtextxy(10, 10, "Hello World");
5660 tgi_setviewpage(1); // Show page 1
5662 tgi_outtextxy(10, 10, "Creating next frame");
5664 tgi_setviewpage(0); // Show page 0
5669 <sect1>tgi_textheight<label id="tgi_textheight"><p>
5673 <tag/Function/Calculate the height of the text in pixels according to
5674 the current text style.
5675 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5676 <tag/Declaration/<tt/unsigned __fastcall__ tgi_textheight (const char* s);/
5677 <tag/Description/Calculate the height of the text in pixels according to
5678 the current text style.
5679 <tag/Limits/<itemize>
5680 <item>The function is only available as fastcall function, so it may only
5681 be used in presence of a prototype.
5683 <tag/Availability/cc65
5684 <tag/See also/Other tgi functions.
5689 <sect1>tgi_textstyle<label id="tgi_textstyle"><p>
5693 <tag/Function/Set the style for text output.
5694 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5695 <tag/Declaration/<tt/void __fastcall__ tgi_textstyle (unsigned char magx, unsigned char magy, unsigned char dir);/
5696 <tag/Description/Set the style for text output.
5697 <tag/Limits/<itemize>
5698 <item>The function is only available as fastcall function, so it may only
5699 be used in presence of a prototype.
5701 <tag/Availability/cc65
5702 <tag/See also/Other tgi functions.
5707 <sect1>tgi_textwidth<label id="tgi_textwidth"><p>
5711 <tag/Function/Calculate the width of the text in pixels according to the current text style.
5712 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5713 <tag/Declaration/<tt/unsigned __fastcall__ tgi_textwidth (const char* s);/
5714 <tag/Function/Calculate the width of the text in pixels according to the current text style.
5715 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5716 <tag/Description/Calculate the width of the text in pixels according to the current text style.
5717 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5718 <tag/Limits/<itemize>
5719 <item>The function is only available as fastcall function, so it may only
5720 be used in presence of a prototype.
5722 <tag/Availability/cc65
5723 <tag/See also/Other tgi functions.
5728 <sect1>tgi_uninstall<label id="tgi_uninstall"><p>
5732 <tag/Function/Uninstall the currently loaded driver but do not unload it.
5733 Will call tgi_done if necessary.
5734 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5735 <tag/Declaration/<tt/void __fastcall__ tgi_uninstall (void);/
5736 <tag/Description/Uninstall the currently loaded driver but do not unload it.
5737 Will call tgi_done if necessary.
5738 <tag/Limits/<itemize>
5739 <item>The function is only available as fastcall function, so it may only
5740 be used in presence of a prototype.
5742 <tag/Availability/cc65
5743 <tag/See also/Other tgi functions.
5748 <sect1>tgi_unload<label id="tgi_unload"><p>
5752 <tag/Function/Uninstall, then unload the currently loaded driver.
5753 Will call tgi_done if necessary.
5754 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5755 <tag/Declaration/<tt/void __fastcall__ tgi_unload (void);/
5756 <tag/Description/Uninstall, then unload the currently loaded driver.
5757 Will call tgi_done if necessary.
5758 <tag/Limits/<itemize>
5759 <item>The function is only available as fastcall function, so it may only
5760 be used in presence of a prototype.
5762 <tag/Availability/cc65
5763 <tag/See also/Other tgi functions.
5768 <sect1>time<label id="time"><p>
5772 <tag/Function/Get the time.
5773 <tag/Header/<tt/<ref id="time.h" name="time.h">/
5774 <tag/Declaration/<tt/time_t __fastcall__ time (time_t* t);/
5775 <tag/Description/The function returns the time since the 1970-01-01 00:00:00
5776 measured in seconds. If the pointer <tt/t/ is not <tt/NULL/, the function
5777 result will also be stored there. If no time is available, <tt/(time_t)-1/ is
5778 returned and <tt/errno/ is set to <tt/ENOSYS/.
5779 <tag/Limits/<itemize>
5780 <item>The function is only available as fastcall function, so it may
5781 only be used in presence of a prototype.
5782 <item>Many platforms supported by cc65 do not have a realtime clock, so the
5783 returned value may not be valid.
5785 <tag/Availability/ISO 9899
5791 <sect1>toggle_videomode<label id="toggle_videomode"><p>
5795 <tag/Function/Toggle between 40 and 80 column mode.
5796 <tag/Header/<tt/<ref id="c128.h" name="c128.h">/
5797 <tag/Declaration/<tt/void toggle_videomode (void);/
5798 <tag/Description/Toggle between 40 and 80 column mode. The settings for the
5799 old mode (cursor position, color and so on) are saved and restored together
5801 <tag/Limits/<itemize>
5802 <item>The function is specific to the C128.
5803 <item>This function is deprecated. Please use <ref id="videomode"
5804 name="videomode"> instead!
5806 <tag/Availability/C128
5808 <ref id="fast" name="fast">,
5809 <ref id="slow" name="slow">,
5810 <ref id="videomode" name="videomode">
5816 <sect1>tolower<label id="tolower"><p>
5820 <tag/Function/Convert a character into its lower case representation.
5821 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
5822 <tag/Declaration/<tt/int __fastcall__ tolower (int c);/
5823 <tag/Description/The function returns the given character converted to lower
5824 case. If the given character is not a letter, it is returned unchanged.
5825 <tag/Limits/<itemize>
5826 <item>The function is only available as fastcall function, so it may
5827 only be used in presence of a prototype.
5829 <tag/Availability/ISO 9899
5831 <ref id="islower" name="islower">,
5832 <ref id="isupper" name="isupper">,
5833 <ref id="toupper" name="toupper">
5839 <sect1>toupper<label id="toupper"><p>
5843 <tag/Function/Convert a character into its upper case representation.
5844 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
5845 <tag/Declaration/<tt/int __fastcall__ toupper (int c);/
5846 <tag/Description/The function returns the given character converted to upper
5847 case. If the given character is not a letter, it is returned unchanged.
5848 <tag/Limits/<itemize>
5849 <item>The function is only available as fastcall function, so it may
5850 only be used in presence of a prototype.
5852 <tag/Availability/ISO 9899
5854 <ref id="islower" name="islower">,
5855 <ref id="isupper" name="isupper">,
5856 <ref id="tolower" name="tolower">
5862 <sect1>ultoa<label id="ultoa"><p>
5866 <tag/Function/Convert an unsigned long integer into a string.
5867 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
5868 <tag/Declaration/<tt/char* __fastcall__ ultoa (unsigned long val, char* buf, int radix);/
5869 <tag/Description/<tt/itoa/ converts the unsigned long integer <tt/val/ into a
5870 string using <tt/radix/ as the base.
5871 <tag/Limits/<itemize>
5872 <item>There are no provisions to prevent a buffer overflow.
5873 <item>The function is non standard, so it is not available in strict ANSI mode.
5874 You should probably use <tt/sprintf/ instead.
5875 <item>The function is only available as fastcall function, so it may only be
5876 used in presence of a prototype.
5878 <tag/Availability/cc65
5880 <ref id="atoi" name="atoi">,
5881 <ref id="atol" name="atol">,
5882 <ref id="itoa" name="itoa">,
5883 <ref id="ltoa" name="ltoa">,
5884 <ref id="utoa" name="utoa">
5890 <sect1>unlink<label id="unlink"><p>
5894 <tag/Function/Delete a file.
5895 <tag/Header/<tt/<ref id="unistd.h" name="unistd.h">/
5896 <tag/Declaration/<tt/int __fastcall__ unlink (const char* name);/
5897 <tag/Description/<tt/unlink/ deletes the file with the given name. On success,
5898 zero is returned. On error, -1 is returned and <tt/errno/ is set to an error
5899 code describing the reason for the failure.
5902 <item>The use of this function is discouraged. Please use <tt/<ref id="remove"
5903 name="remove">/ instead, which is a native ANSI C function and does the same.
5904 <item>This function is not available on all cc65 targets (depends on the
5905 availability of file I/O).
5906 <item>The function is only available as fastcall function, so it may only
5907 be used in presence of a prototype.
5908 <item>Instead of <tt/unlink/, <tt/<ref id="remove" name="remove">/ should be
5909 used, which has the same semantics, but is more portable, because it conforms
5910 to the ISO C standard.
5912 <tag/Availability/POSIX 1003.1
5914 <ref id="remove" name="remove">
5917 #include <stdio.h>
5918 #include <unistd.h>
5920 #define FILENAME "helloworld"
5922 if (unlink (FILENAME) == 0) {
5923 printf ("We deleted %s successfully\n", FILENAME);
5925 printf ("There was a problem deleting %s\n", FILENAME);
5932 <sect1>utoa<label id="utoa"><p>
5936 <tag/Function/Convert an unsigned integer into a string.
5937 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
5938 <tag/Declaration/<tt/char* __fastcall__ utoa (unsigned val, char* buf, int radix);/
5939 <tag/Description/<tt/itoa/ converts the unsigned integer <tt/val/ into a string
5940 using <tt/radix/ as the base.
5941 <tag/Limits/<itemize>
5942 <item>There are no provisions to prevent a buffer overflow.
5943 <item>The function is non standard, so it is not available in strict ANSI mode.
5944 You should probably use <tt/sprintf/ instead.
5945 <item>The function is only available as fastcall function, so it may only be
5946 used in presence of a prototype.
5948 <tag/Availability/cc65
5950 <ref id="atoi" name="atoi">,
5951 <ref id="atol" name="atol">,
5952 <ref id="itoa" name="itoa">,
5953 <ref id="ltoa" name="ltoa">,
5954 <ref id="ultoa" name="ultoa">
5960 <sect1>vcprintf<label id="vcprintf"><p>
5964 <tag/Function/Formatted output to the console.
5965 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
5966 <tag/Declaration/<tt/int __fastcall__ vcprintf (const char* format, va_list ap);/
5967 <tag/Description/The arguments specified as a <tt/va_list/ are converted to
5968 text where necessary and formatted according to the format string given. The
5969 resulting string is output to the console. <tt/vcprintf/ supports the same
5970 format specifiers as <tt/vprintf/. <!-- <tt/<ref id="vprintf" name="vprintf">/. -->
5971 <tag/Limits/<itemize>
5972 <item>Like all other <tt/conio/ output functions, <tt/vcprintf/ distinguishes
5973 between <tt/\r/ and <tt/\n/.
5974 <item>The function is only available as fastcall function, so it may only be
5975 used in presence of a prototype.
5977 <tag/Availability/cc65
5979 <ref id="cprintf" name="cprintf">,
5980 <ref id="cputc" name="cputc">,
5981 <ref id="cputcxy" name="cputcxy">,
5982 <ref id="cputs" name="cputs">,
5983 <ref id="cputsxy" name="cputsxy">
5989 <sect1>videomode<label id="videomode"><p>
5993 <tag/Function/Switch to either 40 or 80 column mode.
5994 <tag/Header/<tt/<ref id="apple2enh.h" name="apple2enh.h">,
5995 <ref id="c128.h" name="c128.h">/
5996 <tag/Declaration/<tt/unsigned __fastcall__ videomode (unsigned Mode);/
5997 <tag/Description/Switch to 40 or 80 column mode depending on the argument. If
5998 the requested mode is already active, nothing happens. The old mode is returned
6000 <tag/Limits/<itemize>
6001 <item>The function is specific to the C128 and enhanced Apple //e.
6002 <item>This function replaces <ref id="toggle_videomode"
6003 name="toggle_videomode">.
6004 <item>The function is only available as fastcall function, so it may only be
6005 used in presence of a prototype.
6007 <tag/Availability/C128 and enhanced Apple //e
6009 <ref id="fast" name="fast">,
6010 <ref id="slow" name="slow">,
6011 <ref id="toggle_videomode" name="toggle_videomode">
6017 <sect1>wherex<label id="wherex"><p>
6021 <tag/Function/Return the current X position of the text mode cursor.
6022 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
6023 <tag/Declaration/<tt/unsigned char wherex (void);/
6024 <tag/Description/The function returns the current X position of the text mode
6025 cursor. Zero is returned for the leftmost screen position.
6026 <tag/Availability/cc65
6028 <ref id="gotox" name="gotox">,
6029 <ref id="gotoy" name="gotoy">,
6030 <ref id="gotoxy" name="gotoxy">,
6031 <ref id="wherey" name="wherey">
6037 <sect1>wherey<label id="wherey"><p>
6041 <tag/Function/Return the current Y position of the text mode cursor.
6042 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
6043 <tag/Declaration/<tt/unsigned char wherey (void);/
6044 <tag/Description/The function returns the current Y position of the text mode
6045 cursor. Zero is returned for the uppermost screen position.
6046 <tag/Availability/cc65
6048 <ref id="gotox" name="gotox">,
6049 <ref id="gotoy" name="gotoy">,
6050 <ref id="gotoxy" name="gotoxy">,
6051 <ref id="wherex" name="wherex">