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 value of zero if the given argument
2325 is a letter or digit. The return value is non zero if the character
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 value of zero if the given argument
2363 is a letter. The return value is non 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 value of zero if the given argument
2400 is in the range 0..127 (the range of valid ASCII characters) and a non zero
2402 <tag/Limits/<itemize>
2403 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2404 inline sequence generated by the macro will not work correctly for values
2405 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2406 this range. The non inline function may be accessed by <tt/#undef/'ing the
2408 <item>When compiling without <tt/-Os/, the function is only available as
2409 fastcall function, so it may only be used in presence of a prototype.
2411 <tag/Availability/ISO 9899
2413 <ref id="isalnum" name="isalnum">,
2414 <ref id="isalpha" name="isalpha">,
2415 <ref id="isblank" name="isblank">,
2416 <ref id="iscntrl" name="iscntrl">,
2417 <ref id="isdigit" name="isdigit">,
2418 <ref id="isgraph" name="isgraph">,
2419 <ref id="islower" name="islower">,
2420 <ref id="isprint" name="isprint">,
2421 <ref id="ispunct" name="ispunct">,
2422 <ref id="isspace" name="isspace">,
2423 <ref id="isupper" name="isupper">,
2424 <ref id="isxdigit" name="isxdigit">
2430 <sect1>isblank<label id="isblank"><p>
2434 <tag/Function/Check if a given character is a space or tab.
2435 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2436 <tag/Declaration/<tt/int __fastcall__ isblank (int c);/
2437 <tag/Description/The function returns a value of zero if the given argument
2438 is a space or tab character. The return value is non zero if the character
2440 <tag/Limits/<itemize>
2441 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2442 inline sequence generated by the macro will not work correctly for values
2443 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2444 this range. The non inline function may be accessed by <tt/#undef/'ing the
2446 <item>When compiling without <tt/-Os/, the function is only available as
2447 fastcall function, so it may only be used in presence of a prototype.
2449 <tag/Availability/cc65
2451 <ref id="isalnum" name="isalnum">,
2452 <ref id="isalpha" name="isalpha">,
2453 <ref id="isascii" name="isascii">,
2454 <ref id="iscntrl" name="iscntrl">,
2455 <ref id="isdigit" name="isdigit">,
2456 <ref id="isgraph" name="isgraph">,
2457 <ref id="islower" name="islower">,
2458 <ref id="isprint" name="isprint">,
2459 <ref id="ispunct" name="ispunct">,
2460 <ref id="isspace" name="isspace">,
2461 <ref id="isupper" name="isupper">,
2462 <ref id="isxdigit" name="isxdigit">
2468 <sect1>iscntrl<label id="iscntrl"><p>
2472 <tag/Function/Check if a given character is a control character.
2473 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2474 <tag/Declaration/<tt/int __fastcall__ iscntrl (int c);/
2475 <tag/Description/The function returns a value of zero if the given argument
2476 is a control character. The return value is non zero if the character
2478 <tag/Limits/<itemize>
2479 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2480 inline sequence generated by the macro will not work correctly for values
2481 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2482 this range. The non inline function may be accessed by <tt/#undef/'ing the
2484 <item>When compiling without <tt/-Os/, the function is only available as
2485 fastcall function, so it may only be used in presence of a prototype.
2487 <tag/Availability/ISO 9899
2489 <ref id="isalnum" name="isalnum">,
2490 <ref id="isalpha" name="isalpha">,
2491 <ref id="isascii" name="isascii">,
2492 <ref id="isblank" name="isblank">,
2493 <ref id="isdigit" name="isdigit">,
2494 <ref id="isgraph" name="isgraph">,
2495 <ref id="islower" name="islower">,
2496 <ref id="isprint" name="isprint">,
2497 <ref id="ispunct" name="ispunct">,
2498 <ref id="isspace" name="isspace">,
2499 <ref id="isupper" name="isupper">,
2500 <ref id="isxdigit" name="isxdigit">
2506 <sect1>isdigit<label id="isdigit"><p>
2510 <tag/Function/Check if a given character is a digit.
2511 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2512 <tag/Declaration/<tt/int __fastcall__ isdigit (int c);/
2513 <tag/Description/The function returns a value of zero if the given argument
2514 is a digit. The return value is non zero if the character is anything else.
2515 <tag/Limits/<itemize>
2516 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2517 inline sequence generated by the macro will not work correctly for values
2518 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2519 this range. The non inline function may be accessed by <tt/#undef/'ing the
2521 <item>When compiling without <tt/-Os/, the function is only available as
2522 fastcall function, so it may only be used in presence of a prototype.
2524 <tag/Availability/ISO 9899
2526 <ref id="isalnum" name="isalnum">,
2527 <ref id="isalpha" name="isalpha">,
2528 <ref id="isascii" name="isascii">,
2529 <ref id="isblank" name="isblank">,
2530 <ref id="iscntrl" name="iscntrl">,
2531 <ref id="isgraph" name="isgraph">,
2532 <ref id="islower" name="islower">,
2533 <ref id="isprint" name="isprint">,
2534 <ref id="ispunct" name="ispunct">,
2535 <ref id="isspace" name="isspace">,
2536 <ref id="isupper" name="isupper">,
2537 <ref id="isxdigit" name="isxdigit">
2543 <sect1>isgraph<label id="isgraph"><p>
2547 <tag/Function/Check if a given character is a printable character (except
2549 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2550 <tag/Declaration/<tt/int __fastcall__ isgraph (int c);/
2551 <tag/Description/The function returns a value of zero if the given argument
2552 is a printable character with the exception of space. The return value is non
2553 zero if the character is anything else.
2554 <tag/Limits/<itemize>
2555 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2556 inline sequence generated by the macro will not work correctly for values
2557 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2558 this range. The non inline function may be accessed by <tt/#undef/'ing the
2560 <item>When compiling without <tt/-Os/, the function is only available as
2561 fastcall function, so it may only be used in presence of a prototype.
2563 <tag/Availability/ISO 9899
2565 <ref id="isalnum" name="isalnum">,
2566 <ref id="isalpha" name="isalpha">,
2567 <ref id="isascii" name="isascii">,
2568 <ref id="isblank" name="isblank">,
2569 <ref id="iscntrl" name="iscntrl">,
2570 <ref id="isdigit" name="isdigit">,
2571 <ref id="islower" name="islower">,
2572 <ref id="isprint" name="isprint">,
2573 <ref id="ispunct" name="ispunct">,
2574 <ref id="isspace" name="isspace">,
2575 <ref id="isupper" name="isupper">,
2576 <ref id="isxdigit" name="isxdigit">
2582 <sect1>islower<label id="islower"><p>
2586 <tag/Function/Check if a given character is a lower case letter.
2587 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2588 <tag/Declaration/<tt/int __fastcall__ islower (int c);/
2589 <tag/Description/The function returns a value of zero if the given argument
2590 is a lower case letter. The return value is non zero if the character is
2592 <tag/Limits/<itemize>
2593 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2594 inline sequence generated by the macro will not work correctly for values
2595 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2596 this range. The non inline function may be accessed by <tt/#undef/'ing the
2598 <item>When compiling without <tt/-Os/, the function is only available as
2599 fastcall function, so it may only be used in presence of a prototype.
2601 <tag/Availability/ISO 9899
2603 <ref id="isalnum" name="isalnum">,
2604 <ref id="isalpha" name="isalpha">,
2605 <ref id="isascii" name="isascii">,
2606 <ref id="isblank" name="isblank">,
2607 <ref id="iscntrl" name="iscntrl">,
2608 <ref id="isdigit" name="isdigit">,
2609 <ref id="isgraph" name="isgraph">,
2610 <ref id="isprint" name="isprint">,
2611 <ref id="ispunct" name="ispunct">,
2612 <ref id="isspace" name="isspace">,
2613 <ref id="isupper" name="isupper">,
2614 <ref id="isxdigit" name="isxdigit">
2620 <sect1>isprint<label id="isprint"><p>
2624 <tag/Function/Check if a given character is a printable character.
2625 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2626 <tag/Declaration/<tt/int __fastcall__ isprint (int c);/
2627 <tag/Description/The function returns a value of zero if the given argument
2628 is a printable character (this includes the space character). The return value
2629 is non zero if the character is anything else.
2630 <tag/Limits/<itemize>
2631 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2632 inline sequence generated by the macro will not work correctly for values
2633 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2634 this range. The non inline function may be accessed by <tt/#undef/'ing the
2636 <item>When compiling without <tt/-Os/, the function is only available as
2637 fastcall function, so it may only be used in presence of a prototype.
2639 <tag/Availability/ISO 9899
2641 <ref id="isalnum" name="isalnum">,
2642 <ref id="isalpha" name="isalpha">,
2643 <ref id="isascii" name="isascii">,
2644 <ref id="isblank" name="isblank">,
2645 <ref id="iscntrl" name="iscntrl">,
2646 <ref id="isdigit" name="isdigit">,
2647 <ref id="isgraph" name="isgraph">,
2648 <ref id="islower" name="islower">,
2649 <ref id="ispunct" name="ispunct">,
2650 <ref id="isspace" name="isspace">,
2651 <ref id="isupper" name="isupper">,
2652 <ref id="isxdigit" name="isxdigit">
2658 <sect1>ispunct<label id="ispunct"><p>
2662 <tag/Function/Check if a given character is a printable character but not a
2663 space or an alphanumeric character.
2664 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2665 <tag/Declaration/<tt/int __fastcall__ ispunct (int c);/
2666 <tag/Description/The function returns a value of zero if the given argument
2667 is a printable character, but not a space or anything alphanumeric. The return
2668 value is non zero if the character is anything else.
2669 <tag/Limits/<itemize>
2670 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2671 inline sequence generated by the macro will not work correctly for values
2672 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2673 this range. The non inline function may be accessed by <tt/#undef/'ing the
2675 <item>When compiling without <tt/-Os/, the function is only available as
2676 fastcall function, so it may only be used in presence of a prototype.
2678 <tag/Availability/ISO 9899
2680 <ref id="isalnum" name="isalnum">,
2681 <ref id="isalpha" name="isalpha">,
2682 <ref id="isascii" name="isascii">,
2683 <ref id="isblank" name="isblank">,
2684 <ref id="iscntrl" name="iscntrl">,
2685 <ref id="isdigit" name="isdigit">,
2686 <ref id="isgraph" name="isgraph">,
2687 <ref id="islower" name="islower">,
2688 <ref id="isprint" name="isprint">,
2689 <ref id="isspace" name="isspace">,
2690 <ref id="isupper" name="isupper">,
2691 <ref id="isxdigit" name="isxdigit">
2697 <sect1>isspace<label id="isspace"><p>
2701 <tag/Function/Check if a given character is a a white-space character.
2702 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2703 <tag/Declaration/<tt/int __fastcall__ isspace (int c);/
2704 <tag/Description/The function returns a value of zero if the given argument
2705 is a white space character. The return value is non zero if the character is
2706 anything else. The standard white space characters are: space, formfeed ('\f'),
2707 newline ('\n'), carriage return ('\r'), horizontal tab ('\t'), and vertical tab
2709 <tag/Limits/<itemize>
2710 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2711 inline sequence generated by the macro will not work correctly for values
2712 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2713 this range. The non inline function may be accessed by <tt/#undef/'ing the
2715 <item>When compiling without <tt/-Os/, the function is only available as
2716 fastcall function, so it may only be used in presence of a prototype.
2718 <tag/Availability/ISO 9899
2720 <ref id="isalnum" name="isalnum">,
2721 <ref id="isalpha" name="isalpha">,
2722 <ref id="isascii" name="isascii">,
2723 <ref id="isblank" name="isblank">,
2724 <ref id="iscntrl" name="iscntrl">,
2725 <ref id="isdigit" name="isdigit">,
2726 <ref id="isgraph" name="isgraph">,
2727 <ref id="islower" name="islower">,
2728 <ref id="isprint" name="isprint">,
2729 <ref id="ispunct" name="ispunct">,
2730 <ref id="isupper" name="isupper">,
2731 <ref id="isxdigit" name="isxdigit">
2737 <sect1>isupper<label id="isupper"><p>
2741 <tag/Function/Check if a given character is an upper case letter.
2742 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2743 <tag/Declaration/<tt/int __fastcall__ isupper (int c);/
2744 <tag/Description/The function returns a value of zero if the given argument
2745 is an upper case letter. The return value is non zero if the character is
2747 <tag/Limits/<itemize>
2748 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2749 inline sequence generated by the macro will not work correctly for values
2750 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2751 this range. The non inline function may be accessed by <tt/#undef/'ing the
2753 <item>When compiling without <tt/-Os/, the function is only available as
2754 fastcall function, so it may only be used in presence of a prototype.
2756 <tag/Availability/ISO 9899
2758 <ref id="isalnum" name="isalnum">,
2759 <ref id="isalpha" name="isalpha">,
2760 <ref id="isascii" name="isascii">,
2761 <ref id="isblank" name="isblank">,
2762 <ref id="iscntrl" name="iscntrl">,
2763 <ref id="isdigit" name="isdigit">,
2764 <ref id="isgraph" name="isgraph">,
2765 <ref id="islower" name="islower">,
2766 <ref id="isprint" name="isprint">,
2767 <ref id="ispunct" name="ispunct">,
2768 <ref id="isspace" name="isspace">,
2769 <ref id="isxdigit" name="isxdigit">
2775 <sect1>isxdigit<label id="isxdigit"><p>
2779 <tag/Function/Check if a given character is a hexadecimal digit.
2780 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2781 <tag/Declaration/<tt/int __fastcall__ isxdigit (int c);/
2782 <tag/Description/The function returns a value of zero if the given argument
2783 is a hexadecimal digit (0..9, a..f and A..F). The return value is non zero
2784 if the character is anything else.
2785 <tag/Limits/<itemize>
2786 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2787 inline sequence generated by the macro will not work correctly for values
2788 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2789 this range. The non inline function may be accessed by <tt/#undef/'ing the
2791 <item>When compiling without <tt/-Os/, the function is only available as
2792 fastcall function, so it may only be used in presence of a prototype.
2794 <tag/Availability/ISO 9899
2796 <ref id="isalnum" name="isalnum">,
2797 <ref id="isalpha" name="isalpha">,
2798 <ref id="isascii" name="isascii">,
2799 <ref id="isblank" name="isblank">,
2800 <ref id="iscntrl" name="iscntrl">,
2801 <ref id="isdigit" name="isdigit">,
2802 <ref id="isgraph" name="isgraph">,
2803 <ref id="islower" name="islower">,
2804 <ref id="isprint" name="isprint">,
2805 <ref id="ispunct" name="ispunct">,
2806 <ref id="isspace" name="isspace">,
2807 <ref id="isupper" name="isupper">
2813 <sect1>itoa<label id="itoa"><p>
2817 <tag/Function/Convert an integer into a string.
2818 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
2819 <tag/Declaration/<tt/char* __fastcall__ itoa (int val, char* buf, int radix);/
2820 <tag/Description/<tt/itoa/ converts the integer <tt/val/ into a string using
2821 <tt/radix/ as the base.
2822 <tag/Limits/<itemize>
2823 <item>There are no provisions to prevent a buffer overflow.
2824 <item>If <tt/val/ contains <tt/INT_MIN/, the behaviour is undefined.
2825 <item>The function is non standard, so it is not available in strict ANSI mode.
2826 You should probably use <tt/sprintf/ instead.
2827 <item>The function is only available as fastcall function, so it may only be
2828 used in presence of a prototype.
2830 <tag/Availability/cc65
2832 <ref id="atoi" name="atoi">,
2833 <ref id="atol" name="atol">,
2834 <ref id="ltoa" name="ltoa">,
2835 <ref id="ultoa" name="ultoa">,
2836 <ref id="utoa" name="utoa">
2842 <sect1>joy_count<label id="joy_count"><p>
2846 <tag/Function/Return the number of joysticks supported by the current driver.
2847 <tag/Header/<tt/<ref id="joystick.h" name="joystick.h">/
2848 <tag/Declaration/<tt/unsigned char __fastcall__ joy_count (void);/
2849 <tag/Description/The function returns a the number of joysticks supported
2850 by the current joystick driver.
2851 <tag/Limits/<itemize>
2852 <item>A joystick driver must be loaded using <ref id="joy_load_driver"
2853 name="joy_load_driver"> before calling this function.
2854 <item>The function returns the number of joysticks supported by the driver.
2855 There's no way to check for the number of actually connected joysticks.
2856 <item>The function is only available as fastcall function, so it may only be
2857 used in presence of a prototype.
2859 <tag/Availability/cc65
2861 <ref id="joy_load_driver" name="joy_load_driver">,
2862 <ref id="joy_read" name="joy_read">
2868 <sect1>joy_install<label id="joy_install"><p>
2872 <tag/Function/Install an already loaded driver and return an error code.
2873 <tag/Header/<tt/<ref id="joystick.h" name="joystick.h">/
2874 <tag/Declaration/<tt/unsigned char __fastcall__ joy_install (void* driver);/
2875 <tag/Description/The function installs a driver that was already loaded into
2876 memory (or linked statically to the program). It returns an error code
2877 (<tt/JOY_ERR_OK/ in case of success).
2878 <tag/Limits/<itemize>
2879 <item>The function is only available as fastcall function, so it may only be
2880 used in presence of a prototype.
2882 <tag/Availability/cc65
2884 <ref id="joy_load_driver" name="joy_load_driver">,
2885 <ref id="joy_uninstall" name="joy_uninstall">,
2886 <ref id="joy_unload" name="joy_unload">
2892 <sect1>joy_load_driver<label id="joy_load_driver"><p>
2896 <tag/Function/Load a driver from disk and install it.
2897 <tag/Header/<tt/<ref id="joystick.h" name="joystick.h">/
2898 <tag/Declaration/<tt/unsigned char __fastcall__ joy_load_driver (const char* driver);/
2899 <tag/Description/The function loads a driver with the given name from disk
2900 and installs it. An error code is returned, which is <tt/JOY_ERR_OK/ if the
2901 driver was successfully loaded and installed.
2902 <tag/Limits/<itemize>
2903 <item>The function is only available as fastcall function, so it may only be
2904 used in presence of a prototype.
2906 <tag/Availability/cc65
2908 <ref id="joy_install" name="joy_install">,
2909 <ref id="joy_uninstall" name="joy_uninstall">,
2910 <ref id="joy_unload" name="joy_unload">
2916 <sect1>joy_read<label id="joy_read"><p>
2920 <tag/Function/Read the status of a joystick.
2921 <tag/Header/<tt/<ref id="joystick.h" name="joystick.h">/
2922 <tag/Declaration/<tt/unsigned char __fastcall__ joy_read (unsigned char joystick);/
2923 <tag/Description/The function reads the status bits for a joystick. The number
2924 of the joystick is passed as parameter. The result may be examined by using one
2925 of the <tt/JOY_xxx/ macros from <ref id="joystick.h" name="joystick.h">.
2926 <tag/Limits/<itemize>
2927 <item>A joystick driver must be loaded using <ref id="joy_load_driver"
2928 name="joy_load_driver"> before calling this function.
2929 <item>The function is only available as fastcall function, so it may only be
2930 used in presence of a prototype.
2932 <tag/Availability/cc65
2934 <ref id="joy_count" name="joy_count">,
2935 <ref id="joy_load_driver" name="joy_load_driver">,
2936 <ref id="joy_unload" name="joy_unload">
2942 <sect1>joy_uninstall<label id="joy_uninstall"><p>
2946 <tag/Function/Uninstall the current joystick driver.
2947 <tag/Header/<tt/<ref id="joystick.h" name="joystick.h">/
2948 <tag/Declaration/<tt/unsigned char __fastcall__ joy_uninstall (void);/
2949 <tag/Description/The function uninstalls the currently installed joystick
2950 driver. It does not remove the driver from memory. The function returns an
2951 error code, which is <tt/JOY_ERR_OK/ if the driver was successfully uninstalled.
2952 <tag/Limits/<itemize>
2953 <item>A joystick driver must be installed using <ref id="joy_install"
2954 name="joy_install"> before calling this function.
2955 <item>The function is only available as fastcall function, so it may only be
2956 used in presence of a prototype.
2958 <tag/Availability/cc65
2960 <ref id="joy_install" name="joy_install">,
2961 <ref id="joy_load_driver" name="joy_load_driver">,
2962 <ref id="joy_unload" name="joy_unload">
2968 <sect1>joy_unload<label id="joy_unload"><p>
2972 <tag/Function/Uninstall, then unload the current joystick driver.
2973 <tag/Header/<tt/<ref id="joystick.h" name="joystick.h">/
2974 <tag/Declaration/<tt/unsigned char __fastcall__ joy_unload (void);/
2975 <tag/Description/The function uninstalls the currently installed joystick
2976 driver and removes it from memory. An error code is returned, which is
2977 <tt/JOY_ERR_OK/ if the driver was successfully uninstalled.
2978 <tag/Limits/<itemize>
2979 <item>A joystick driver must be loaded using <ref id="joy_load_driver"
2980 name="joy_load_driver"> before calling this function.
2981 <item>The function is only available as fastcall function, so it may only be
2982 used in presence of a prototype.
2984 <tag/Availability/cc65
2986 <ref id="joy_load_driver" name="joy_load_driver">
2992 <sect1>kbhit<label id="kbhit"><p>
2996 <tag/Function/Check if there's a key waiting in the keyboard buffer.
2997 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2998 <tag/Declaration/<tt/unsigned char kbhit (void);/
2999 <tag/Description/The function returns a value of zero if there is no character
3000 waiting to be read from the keyboard. It returns non zero otherwise.
3001 <tag/Limits/<itemize>
3002 <item>If the system does not support a keyboard buffer (most systems
3003 do), the function is rather useless.
3005 <tag/Availability/cc65
3007 <ref id="cgetc" name="cgetc">,
3008 <ref id="cursor" name="cursor">
3014 <sect1>labs<label id="labs"><p>
3018 <tag/Function/Returns the absolute value of a long integer.
3019 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
3020 <tag/Declaration/<tt/long __fastcall__ labs (long v);/
3021 <tag/Description/<tt/labs/ returns the absolute value of the argument passed to
3023 <tag/Limits/<itemize>
3024 <item>The return value is undefined if <tt/LONG_MIN/ is passed to the function.
3025 <item>The function is only available as fastcall function, so it may only be
3026 used in presence of a prototype.
3028 <tag/Availability/ISO 9899
3030 <ref id="abs" name="abs">
3036 <sect1>ltoa<label id="ltoa"><p>
3040 <tag/Function/Convert a long integer into a string.
3041 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
3042 <tag/Declaration/<tt/char* __fastcall__ ltoa (long val, char* buf, int radix);/
3043 <tag/Description/<tt/itoa/ converts the long integer <tt/val/ into a string
3044 using <tt/radix/ as the base.
3045 <tag/Limits/<itemize>
3046 <item>There are no provisions to prevent a buffer overflow.
3047 <item>If <tt/val/ contains <tt/LONG_MIN/, the behaviour is undefined.
3048 <item>The function is non standard, so it is not available in strict ANSI mode.
3049 You should probably use <tt/sprintf/ instead.
3050 <item>The function is only available as fastcall function, so it may only be
3051 used in presence of a prototype.
3053 <tag/Availability/cc65
3055 <ref id="atoi" name="atoi">,
3056 <ref id="atol" name="atol">,
3057 <ref id="itoa" name="itoa">,
3058 <ref id="ultoa" name="ultoa">,
3059 <ref id="utoa" name="utoa">
3065 <sect1>localeconv<label id="localeconv"><p>
3069 <tag/Function/Returns a pointer to the current locale structure.
3070 <tag/Header/<tt/<ref id="locale.h" name="locale.h">/
3071 <tag/Declaration/<tt/struct lconv* localeconv (void);/
3072 <tag/Description/<tt/localeconv/ returns a pointer to the current locale
3074 <tag/Limits/<itemize>
3075 <item>cc65 supports only the "C" locale, so even after setting a new locale
3076 using <tt/<ref id="setlocale" name="setlocale">/, the structure returned will
3079 <tag/Availability/ISO 9899
3081 <ref id="setlocale" name="setlocale">
3087 <sect1>longjmp<label id="longjmp"><p>
3091 <tag/Function/Non local goto.
3092 <tag/Header/<tt/<ref id="setjmp.h" name="setjmp.h">/
3093 <tag/Declaration/<tt/void __fastcall__ longjmp (jmp_buf buf, int retval);/
3094 <tag/Description/The <tt/longjmp/ function restores a program context from the
3095 data in <tt/buf/, which must have been set by a preceeding call to
3096 <tt/<ref id="setjmp" name="setjmp">/. Program execution continues as if the
3097 call to <tt/<ref id="setjmp" name="setjmp">/ has just returned the value
3101 <item>If the parameter <tt/retval/ is zero, the function will behave as if it
3102 was called with a value of one.
3103 <item>The function is only available as fastcall function, so it may only
3104 be used in presence of a prototype.
3106 <tag/Availability/ISO 9899
3108 <ref id="setjmp" name="setjmp">
3114 <sect1>malloc<label id="malloc"><p>
3118 <tag/Function/Allocate dynamic memory.
3119 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
3120 <tag/Declaration/<tt/void* __fastcall__ malloc (size_t size);/
3121 <tag/Description/<tt/malloc/ allocates size bytes on the heap and returns a
3122 pointer to the allocated memory block. On error (not enough memory available),
3123 <tt/malloc/ returns <tt/NULL/.
3126 <item>The function is only available as fastcall function, so it may only
3127 be used in presence of a prototype.
3129 <tag/Availability/ISO 9899
3131 <ref id="_heapadd" name="_heapadd">,
3132 <ref id="_heapblocksize" name="_heapblocksize">,
3133 <ref id="_heapmaxavail" name="_heapmaxavail">,
3134 <ref id="_heapmemavail" name="_heapmemavail">,
3135 <ref id="calloc" name="calloc">,
3136 <ref id="free" name="free">,
3137 <ref id="realloc" name="realloc">,
3138 <ref id="strdup" name="strdup">
3144 <sect1>memchr<label id="memchr"><p>
3148 <tag/Function/Search for a character in a block of raw memory.
3149 <tag/Header/<tt/<ref id="string.h" name="string.h">/
3150 <tag/Declaration/<tt/void* __fastcall__ strchr (const void* mem, int c, size_t count);/
3151 <tag/Description/The <tt/memchr/ function locates the first occurrence of <tt/c/
3152 (converted to a char) in the block of raw memory string pointed to by <tt/mem/
3153 that is of size <tt/count/. Upon completion, the function returns a pointer to
3154 the character found, or a null pointer if the character was not found.
3155 <tag/Limits/<itemize>
3156 <item>The function is only available as fastcall function, so it may only
3157 be used in presence of a prototype.
3159 <tag/Availability/ISO 9899
3161 <ref id="strchr" name="strchr">
3167 <sect1>memcpy<label id="memcpy"><p>
3171 <tag/Function/Copy a memory area.
3172 <tag/Header/<tt/<ref id="string.h" name="string.h">/
3173 <tag/Declaration/<tt/void* __fastcall__ memcpy (void* dest, const void* src, size_t count);/
3174 <tag/Description/<tt/memcpy/ copies <tt/count/ bytes from the memory area
3175 pointed to by <tt/src/ into the memory area pointed to by <tt/dest/. It returns
3179 <item>The result is undefined if the memory areas do overlap. Use
3180 <tt/<ref id="memmove" name="memmove">/ to copy overlapping memory areas.
3181 <item>The function is only available as fastcall function, so it may only
3182 be used in presence of a prototype.
3184 <tag/Availability/ISO 9899
3186 <ref id="_swap" name="_swap">,
3187 <ref id="memmove" name="memmove">,
3188 <ref id="memset" name="memset">
3194 <sect1>memmove<label id="memmove"><p>
3198 <tag/Function/Copy a memory area.
3199 <tag/Header/<tt/<ref id="string.h" name="string.h">/
3200 <tag/Declaration/<tt/void* __fastcall__ memmove (void* dest, const void* src, size_t count);/
3201 <tag/Description/<tt/memmove/ copies <tt/count/ bytes from the memory area
3202 pointed to by <tt/src/ into the memory area pointed to by <tt/dest/. It returns
3206 <item>While <tt/memmove/ allows the memory areas to overlap, it has some
3207 additional overhead compared to <tt/<ref id="memcpy" name="memcpy">/.
3208 <item>The function is only available as fastcall function, so it may only
3209 be used in presence of a prototype.
3211 <tag/Availability/ISO 9899
3213 <ref id="_swap" name="_swap">,
3214 <ref id="memcpy" name="memcpy">,
3215 <ref id="memset" name="memset">
3221 <sect1>memset<label id="memset"><p>
3225 <tag/Function/Fill a memory area.
3226 <tag/Header/<tt/<ref id="string.h" name="string.h">/
3227 <tag/Declaration/<tt/void* __fastcall__ memset (void* p, int val, size_t count);/
3228 <tag/Description/<tt/memset/ fills the memory area pointed to by <tt/p/ with
3229 the value <tt/val/. The function returns <tt/p/.
3232 <item>The function is only available as fastcall function, so it may only
3233 be used in presence of a prototype.
3235 <tag/Availability/ISO 9899
3237 <ref id="_swap" name="_swap">,
3238 <ref id="bzero" name="bzero">,
3239 <ref id="memcpy" name="memcpy">,
3240 <ref id="memmove" name="memmove">
3246 <sect1>mod_free<label id="mod_free"><p>
3250 <tag/Function/Free a relocatable module.
3251 <tag/Header/<tt/<ref id="modload.h" name="modload.h">/
3252 <tag/Declaration/<tt/void __fastcall__ mod_free (void* module);/
3253 <tag/Description/The function will free a module loaded into memory by use of
3254 the <tt/<ref id="mod_load" name="mod_load">/ function.
3255 <tag/Limits/<itemize>
3256 <item>The pointer passed as parameter is the pointer to the module memory,
3257 not the pointer to the control structure.
3259 <tag/Availability/cc65
3261 <ref id="mod_load" name="mod_load">
3267 <sect1>mod_load<label id="mod_load"><p>
3271 <tag/Function/Load a relocatable module.
3272 <tag/Header/<tt/<ref id="modload.h" name="modload.h">/
3273 <tag/Declaration/<tt/unsigned char mod_load (struct mod_ctrl* ctrl);/
3274 <tag/Description/The function will load a code module into memory and relocate
3275 it. The function will return an error code. If <tt/MLOAD_OK/ is returned, the
3276 outgoing fields in the passed <tt/mod_ctrl/ struct contain information about
3277 the module just loaded. Possible error codes are:
3279 <item><tt/MLOAD_OK/ - Module load successful
3280 <item><tt/MLOAD_ERR_READ/ - Read error
3281 <item><tt/MLOAD_ERR_HDR/ - Header error
3282 <item><tt/MLOAD_ERR_OS/ - Wrong operating system
3283 <item><tt/MLOAD_ERR_FMT/ - Data format error
3284 <item><tt/MLOAD_ERR_MEM/ - Not enough memory
3286 <tag/Limits/<itemize>
3287 <item>The <htmlurl url="ld65.html" name="ld65"> linker is needed to create
3288 relocatable o65 modules for use with this function.
3290 <tag/Availability/cc65
3292 <ref id="mod_free" name="mod_free">
3298 <sect1>mouse_setbox<label id="mouse_setbox"><p>
3302 <tag/Function/Specify a bounding box for the mouse cursor.
3303 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3304 <tag/Declaration/<tt/void __fastcall__ mouse_setbox (const struct mouse_box* box);/
3305 <tag/Description/The function allows to set a bounding box for mouse movement.
3306 <tag/Limits/<itemize>
3307 <item>The function does not check if the mouse cursor is currently within the
3308 given rectangle. Placing the mouse cursor within the bounding box is the
3309 responsibility of the programmer.
3310 <item>While the bounding box may be larger than the actual screen size, the
3311 standard mouse cursor draw routines may fail to set the cursor to coordinates
3312 outside of the screen area. Depending on the platform, you may have to supply
3313 your own mouse cursor routines.
3314 <item>The function is only available as fastcall function, so it may only be
3315 used in presence of a prototype.
3317 <tag/Availability/cc65
3319 <ref id="mouse_getbox" name="mouse_getbox">,
3320 <ref id="mouse_move" name="mouse_move">
3326 <sect1>mouse_getbox<label id="mouse_getbox"><p>
3330 <tag/Function/Return the current bounding box for the mouse cursor.
3331 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3332 <tag/Declaration/<tt/void __fastcall__ mouse_getbox (struct mouse_box* box);/
3333 <tag/Description/The function queries the current bounding box for mouse
3335 <tag/Limits/<itemize>
3336 <item>The function is only available as fastcall function, so it may only be
3337 used in presence of a prototype.
3339 <tag/Availability/cc65
3341 <ref id="mouse_move" name="mouse_move">,
3342 <ref id="mouse_setbox" name="mouse_setbox">
3348 <sect1>mouse_buttons<label id="mouse_buttons"><p>
3352 <tag/Function/Return a bit mask encoding the state of the mouse buttons.
3353 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3354 <tag/Declaration/<tt/unsigned char __fastcall__ mouse_buttons (void);/
3355 <tag/Description/The function returns a bit mask that encodes the state of the
3356 mouse buttons. You may use the <tt/MOUSE_BTN_XXX/ flags to decode the function
3358 <tag/Limits/<itemize>
3359 <item>The function is only available as fastcall function, so it may only be
3360 used in presence of a prototype.
3362 <tag/Availability/cc65
3364 <ref id="mouse_info" name="mouse_info">,
3365 <ref id="mouse_pos" name="mouse_pos">
3371 <sect1>mouse_geterrormsg<label id="mouse_geterrormsg"><p>
3375 <tag/Function/Return a readable error message for an error code.
3376 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3377 <tag/Declaration/<tt/const char* __fastcall__ mouse_geterrormsg (unsigned char
3379 <tag/Description/The function returns an error message (in english) for the
3380 error code passed parameter.
3381 <tag/Limits/<itemize>
3382 <item>The function will return "Unknown error" for invalid error codes.
3383 <item>The function is only available as fastcall function, so it may only be
3384 used in presence of a prototype.
3386 <tag/Availability/cc65
3388 <ref id="mouse_load_driver" name="mouse_load_driver">,
3389 <ref id="mouse_uninstall" name="mouse_uninstall">,
3390 <ref id="mouse_unload" name="mouse_unload">
3396 <sect1>mouse_hide<label id="mouse_hide"><p>
3400 <tag/Function/Hide the mouse pointer.
3401 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3402 <tag/Declaration/<tt/void __fastcall__ mouse_hide (void);/
3403 <tag/Description/The function hides the mouse pointer. It manages a counter
3404 that is shared between <tt/<ref id="mouse_show" name="mouse_show">/ and
3405 <tt/mouse_hide/ so that every call call to <tt/mouse_hide/ must be followed by
3406 a call to <tt/<ref id="mouse_show" name="mouse_show">/ to make the mouse cursor
3408 <tag/Limits/<itemize>
3409 <item>The function is only available as fastcall function, so it may only be
3410 used in presence of a prototype.
3412 <tag/Availability/cc65
3414 <ref id="mouse_show" name="mouse_show">
3420 <sect1>mouse_info<label id="mouse_info"><p>
3424 <tag/Function/Return the state of the mouse buttons and the position of the
3426 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3427 <tag/Declaration/<tt/void __fastcall__ mouse_info (struct mouse_info* info);/
3428 <tag/Description/The function returns the state of the mouse buttons and the
3429 position of the mouse in the <tt/mouse_info/ structure passed as parameter.
3430 <tag/Limits/<itemize>
3431 <item>The <tt/mouse_info/ struct is a superset of the <tt/mouse_pos/ struct,
3432 so if you just need the mouse position, call <tt/<ref id="mouse_pos"
3433 name="mouse_pos">/ instead.
3434 <item>The function is only available as fastcall function, so it may only be
3435 used in presence of a prototype.
3437 <tag/Availability/cc65
3439 <ref id="mouse_buttons" name="mouse_buttons">,
3440 <ref id="mouse_pos" name="mouse_pos">
3446 <sect1>mouse_install<label id="mouse_install"><p>
3450 <tag/Function/Install an already loaded mouse driver.
3451 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3452 <tag/Declaration/<tt/unsigned char __fastcall__ mouse_install (const struct
3453 mouse_callbacks* c, void* driver);/
3454 <tag/Description/The function installs an already loaded mouse driver and
3455 returns an error code. The <tt/mouse_callbacks/ structure passed as first
3456 parameter contains pointers to routines needed to move or hide/show the mouse
3457 pointer. Defaults for these routines are supplied by the library, so if you
3458 can live with these defaults (which are platform specific), just pass a
3459 pointer to <tt/mouse_def_callbacks/. The function may be used to install a
3460 driver linked statically to the program.
3461 <tag/Limits/<itemize>
3462 <item>Not all drivers are able to detect if the supported hardware is really
3464 <item>After installing a driver, the mouse cursor is hidden.
3465 <item>The function is only available as fastcall function, so it may only be
3466 used in presence of a prototype.
3468 <tag/Availability/cc65
3470 <ref id="mouse_load_driver" name="mouse_load_driver">,
3471 <ref id="mouse_uninstall" name="mouse_uninstall">,
3472 <ref id="mouse_unload" name="mouse_unload">
3478 <sect1>mouse_ioctl<label id="mouse_ioctl"><p>
3482 <tag/Function/Call the driver specific ioctl function.
3483 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3484 <tag/Declaration/<tt/unsigned char __fastcall__ mouse_ioctl (unsigned char code, void* data);/
3485 <tag/Description/The function calls the IOCTL entry in the mouse driver,
3486 which is driver specific. The <tt/code/ parameter will choose between
3487 different IOCTL functions, and the <tt/data/ depends on code. The
3488 function returns an error code. The purpose of this function is to allow
3489 for driver specific extensions. See the documentation for a specific mouse
3490 driver for supported ioctl calls.
3491 <tag/Limits/<itemize>
3492 <item>Calling this function is non portable, because each driver may
3493 implement different ioctl calls (or none at all).
3494 <item>The function is only available as fastcall function, so it may only be
3495 used in presence of a prototype.
3497 <tag/Availability/cc65
3503 <sect1>mouse_load_driver<label id="mouse_load_driver"><p>
3507 <tag/Function/Load and initialize a mouse driver.
3508 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3509 <tag/Declaration/<tt/unsigned char __fastcall__ mouse_load_driver (const struct
3510 mouse_callbacks* c, const char* driver);/
3511 <tag/Description/Load a mouse driver into memory and initialize it. The
3512 function returns an error code that tells if the call has been successful. The
3513 <tt/mouse_callbacks/ structure passed as first parameter contains pointers to
3514 routines needed to move or hide/show the mouse pointer. Defaults for these
3515 routines are supplied by the library, so if you can live with these defaults
3516 (which are platform specific), just pass a pointer to <tt/mouse_def_callbacks/.
3517 <tag/Limits/<itemize>
3518 <item>The driver is loaded by name, so currently you must know the type of
3519 mouse that should be supported. There is no autodetect capability.
3520 <item>Not all drivers are able to detect if the supported hardware is really
3522 <item>After installing a driver, the mouse cursor is hidden.
3523 <item>The function is only available as fastcall function, so it may only be
3524 used in presence of a prototype.
3526 <tag/Availability/cc65
3528 <ref id="mouse_install" name="mouse_install">,
3529 <ref id="mouse_uninstall" name="mouse_uninstall">,
3530 <ref id="mouse_unload" name="mouse_unload">
3536 <sect1>mouse_move<label id="mouse_move"><p>
3540 <tag/Function/Move the mouse cursor to a specific position.
3541 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3542 <tag/Declaration/<tt/void __fastcall__ mouse_move (int x, int y);/
3543 <tag/Description/The function updates the mouse position. If the mouse cursor
3544 is visible, it is shown at the new position.
3545 <tag/Limits/<itemize>
3546 <item>The function does not check if the new position is within the bounding
3547 box specified with <tt/<ref id="mouse_setbox" name="mouse_setbox">/.
3548 <item>The function is only available as fastcall function, so it may only be
3549 used in presence of a prototype.
3551 <tag/Availability/cc65
3553 <ref id="mouse_getbox" name="mouse_getbox">,
3554 <ref id="mouse_setbox" name="mouse_setbox">
3560 <sect1>mouse_pos<label id="mouse_pos"><p>
3564 <tag/Function/Return the position of the mouse.
3565 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3566 <tag/Declaration/<tt/void __fastcall__ mouse_pos (struct mouse_pos* pos);/
3567 <tag/Description/The function returns the position of the mouse in the
3568 <tt/mouse_pos/ structure passed as parameter.
3569 <tag/Limits/<itemize>
3570 <item>The <tt/mouse_pos/ struct is a subset of the <tt/mouse_info/ struct,
3571 so if you do also need the mouse buttons, call <tt/<ref id="mouse_info"
3572 name="mouse_info">/ instead.
3573 <item>The function is only available as fastcall function, so it may only be
3574 used in presence of a prototype.
3576 <tag/Availability/cc65
3578 <ref id="mouse_buttons" name="mouse_buttons">,
3579 <ref id="mouse_info" name="mouse_info">
3585 <sect1>mouse_show<label id="mouse_show"><p>
3589 <tag/Function/Show the mouse pointer.
3590 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3591 <tag/Declaration/<tt/void __fastcall__ mouse_show (void);/
3592 <tag/Description/The function shows the mouse pointer. It manages a counter
3593 that is shared between <tt/<ref id="mouse_hide" name="mouse_hide">/ and
3594 <tt/mouse_show/. The mouse cursor is visible if there was one more call to
3595 <tt/mouse_show/ than to <tt/<ref id="mouse_hide" name="mouse_hide">/.
3596 <tag/Limits/<itemize>
3597 <item>The function is only available as fastcall function, so it may only be
3598 used in presence of a prototype.
3600 <tag/Availability/cc65
3602 <ref id="mouse_hide" name="mouse_hide">
3608 <sect1>mouse_uninstall<label id="mouse_uninstall"><p>
3612 <tag/Function/Uninstall an already loaded mouse driver.
3613 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3614 <tag/Declaration/<tt/unsigned char __fastcall__ mouse_install (void);/
3615 <tag/Description/The function uninstalls an already loaded mouse driver but
3616 don't removes it from memory.
3617 <tag/Limits/<itemize>
3618 <item>If the driver has been loaded using <tt/<ref id="mouse_load_driver"
3619 name="mouse_load_driver">/, <tt/<ref id="mouse_unload" name="mouse_unload">/
3620 should be used instead of <tt/mouse_uninstall/ so the driver is also removed
3622 <item>The function is only available as fastcall function, so it may only be
3623 used in presence of a prototype.
3625 <tag/Availability/cc65
3627 <ref id="mouse_install" name="mouse_install">,
3628 <ref id="mouse_load_driver" name="mouse_load_driver">,
3629 <ref id="mouse_unload" name="mouse_unload">
3635 <sect1>mouse_unload<label id="mouse_unload"><p>
3639 <tag/Function/Unload a mouse driver.
3640 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3641 <tag/Declaration/<tt/unsigned char __fastcall__ mouse_unload (void);/
3642 <tag/Description/The function unloads a loaded mouse driver and frees all
3643 memory allocated for the driver.
3644 <tag/Limits/<itemize>
3645 <item>The function does nothing if no driver is loaded.
3647 <tag/Availability/cc65
3649 <ref id="mouse_install" name="mouse_install">,
3650 <ref id="mouse_load_driver" name="mouse_load_driver">,
3651 <ref id="mouse_uninstall" name="mouse_uninstall">
3657 <sect1>offsetof<label id="offsetof"><p>
3661 <tag/Function/Calculate the offset of a struct or union member.
3662 <tag/Header/<tt/<ref id="stddef.h" name="stddef.h">/
3663 <tag/Declaration/<tt/size_t offsetof (type, member);/
3664 <tag/Description/<tt/offsetof/ calculates the address offset of a <tt/struct/
3665 or <tt/union/ member.
3666 <tag/Limits/<itemize>
3667 <item>The function is actually a macro.
3669 <tag/Availability/ISO 9899
3675 <sect1>open<label id="open"><p>
3679 <tag/Function/Open and possibly create a file.
3680 <tag/Header/<tt/<ref id="fcntl.h" name="fcntl.h">/
3681 <tag/Declaration/<tt/int open (const char* name, int flags, ...);/
3682 <tag/Description/<tt/open/ opens a file and returns the file descriptor
3683 associated with it. On error, -1 is returned and an error code is stored in
3684 <tt/errno/. Several flags may be passed to <tt/open/ that change the behaviour.
3685 <tag/Limits/<itemize>
3686 <item>POSIX specifies an additional <tt/mode/ argument that may be passed to
3687 open, which is used as the permission mask when a new file is created. While
3688 cc65 allows to pass this argument, it is ignored.
3690 <tag/Availability/POSIX 1003.1
3692 <ref id="close" name="close">,
3693 <ref id="creat" name="creat">
3699 <sect1>peekbsys<label id="peekbsys"><p>
3703 <tag/Function/Read one byte from a location in the system bank.
3704 <tag/Header/<tt/<ref id="cbm610.h" name="cbm610.h">/,
3705 <tt/<ref id="cbm510.h" name="cbm510.h">/
3706 <tag/Declaration/<tt/unsigned char __fastcall__ peekbsys (unsigned addr);/
3707 <tag/Description/<tt/peekbsys/ reads one byte from the given address in the
3708 system bank (bank 15) of the CBM PET-II machines and returns it.
3711 <item>The function is only available as fastcall function, so it may only
3712 be used in presence of a prototype.
3713 <item>This function may be a macro depending on the compiler options. The
3714 actual function is accessible by #undef'ing the macro.
3716 <tag/Availability/cc65
3718 <ref id="PEEK" name="PEEK">,
3719 <ref id="PEEKW" name="PEEKW">,
3720 <ref id="peekwsys" name="peekwsys">,
3721 <ref id="pokebsys" name="pokebsys">,
3722 <ref id="pokewsys" name="pokewsys">
3728 <sect1>peekwsys<label id="peekwsys"><p>
3732 <tag/Function/Read one word from a location in the system bank.
3733 <tag/Header/<tt/<ref id="cbm610.h" name="cbm610.h">/,
3734 <tt/<ref id="cbm510.h" name="cbm510.h">/
3735 <tag/Declaration/<tt/unsigned __fastcall__ peekwsys (unsigned addr);/
3736 <tag/Description/<tt/peekwsys/ reads one word from the given address in the
3737 system bank (bank 15) of the CBM PET-II machines and returns it. Following
3738 the usual 6502 conventions, the low byte is read from <tt/addr/, and the
3739 high byte is read from <tt/addr+1/.
3742 <item>The function is only available as fastcall function, so it may only
3743 be used in presence of a prototype.
3744 <item>The order in which the two bytes are read is undefined.
3746 <tag/Availability/cc65
3748 <ref id="PEEK" name="PEEK">,
3749 <ref id="PEEKW" name="PEEKW">,
3750 <ref id="peekbsys" name="peekbsys">,
3751 <ref id="pokebsys" name="pokebsys">,
3752 <ref id="pokewsys" name="pokewsys">
3758 <sect1>perror<label id="perror"><p>
3762 <tag/Function/Print an error message for the error in <tt/errno/.
3763 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
3764 <tag/Declaration/<tt/void __fastcall__ perror (const char* s);/
3765 <tag/Description/<tt/perror/ prints an error message to <tt/stderr/. If <tt/s/
3766 is not <tt/NULL/ and not an empty string, it is printed followed by a colon and
3767 a blank. Then the error message for the current contents of <tt/errno/ is
3768 printed followed by a newline. The message output is the same as returned by
3769 <tt/<ref id="strerror" name="strerror">/ with an argument of <tt/errno/.
3772 <item>The function is only available as fastcall function, so it may only
3773 be used in presence of a prototype.
3775 <tag/Availability/ISO 9899
3777 <ref id="_poserror" name="_poserror">,
3778 <ref id="strerror" name="strerror">
3784 <sect1>pokebsys<label id="pokebsys"><p>
3788 <tag/Function/Write one byte to a location in the system bank.
3789 <tag/Header/<tt/<ref id="cbm610.h" name="cbm610.h">/,
3790 <tt/<ref id="cbm510.h" name="cbm510.h">/
3791 <tag/Declaration/<tt/void __fastcall__ pokebsys (unsigned addr, unsigned char val);/
3792 <tag/Description/<tt/pokebsys/ writes one byte to the given address in the
3793 system bank (bank 15) of the CBM PET-II machines.
3796 <item>The function is only available as fastcall function, so it may only
3797 be used in presence of a prototype.
3799 <tag/Availability/cc65
3801 <ref id="POKE" name="POKE">,
3802 <ref id="POKEW" name="POKEW">,
3803 <ref id="peekbsys" name="peekbsys">,
3804 <ref id="peekwsys" name="peekwsys">,
3805 <ref id="pokewsys" name="pokewsys">
3811 <sect1>pokewsys<label id="pokewsys"><p>
3815 <tag/Function/Write one word to a location in the system bank.
3816 <tag/Header/<tt/<ref id="cbm610.h" name="cbm610.h">/,
3817 <tt/<ref id="cbm510.h" name="cbm510.h">/
3818 <tag/Declaration/<tt/void __fastcall__ pokewsys (unsigned addr, unsigned val);/
3819 <tag/Description/<tt/pokewsys/ writes one word to the given address in the
3820 system bank (bank 15) of the CBM PET-II machines. Following the usual 6502
3821 conventions, the low byte of <tt/val/ is written to <tt/addr/, and the
3822 high byte is written to <tt/addr+1/.
3825 <item>The function is only available as fastcall function, so it may only
3826 be used in presence of a prototype.
3827 <item>The order in which the two bytes are written is undefined.
3829 <tag/Availability/cc65
3831 <ref id="POKE" name="POKE">,
3832 <ref id="POKEW" name="POKEW">,
3833 <ref id="peekbsys" name="peekbsys">,
3834 <ref id="peekwsys" name="peekwsys">,
3835 <ref id="pokebsys" name="pokebsys">
3841 <sect1>qsort<label id="qsort"><p>
3845 <tag/Function/Sort an array.
3846 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
3847 <tag/Declaration/<tt/void __fastcall__ qsort (void* base, size_t count,
3848 size_t size, int (*compare) (const void*, const void*));/
3849 <tag/Description/<tt/qsort/ sorts an array according to a given compare
3850 function <tt/compare/. <tt/base/ is the address of the array, <tt/count/
3851 is the number of elements, <tt/size/ the size of an element and <tt/compare/
3852 the function used to compare the members.
3855 <item>If there are multiple members with the same key, the order after calling
3856 the function is undefined.
3857 <item>The function is only available as fastcall function, so it may only
3858 be used in presence of a prototype.
3860 <tag/Availability/ISO 9899
3862 <ref id="bsearch" name="bsearch">
3868 <sect1>raise<label id="raise"><p>
3872 <tag/Function/Send a signal to the executing program.
3873 <tag/Header/<tt/<ref id="signal.h" name="signal.h">/
3874 <tag/Declaration/<tt/int __fastcall__ raise (int sig);/
3875 <tag/Description/<tt/raise/ sends the given signal to the program. If the
3876 program has installed a signal handler for the signal, this signal handler
3877 will be executed. If no handler has been installed, the default action for
3878 the raised signal will be taken. The function returns zero on success,
3880 <tag/Limits/<itemize>
3881 <item>The function is only available as fastcall function, so it may only
3882 be used in presence of a prototype.
3884 <tag/Availability/ISO 9899
3886 <ref id="abort" name="abort">,
3887 <ref id="signal" name="signal">
3893 <sect1>rand<label id="rand"><p>
3897 <tag/Function/Return a pseudo random number.
3898 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
3899 <tag/Declaration/<tt/int rand (void);/
3900 <tag/Description/The function returns a pseudo random number
3901 between 0 and <tt/RAND_MAX/ (exclusive).
3902 <tag/Limits/<itemize>
3903 <item>Without using <tt><ref id="srand" name="srand"></tt>, always the same
3904 flow of numbers is generated.
3905 <item>On startup, the function behaves as if <ref id="srand" name="srand">
3906 had been used with an argument of 1.
3908 <tag/Availability/ISO 9899
3910 <ref id="_randomize" name="_randomize">,
3911 <ref id="srand" name="srand">
3917 <sect1>realloc<label id="realloc"><p>
3921 <tag/Function/Change the size of an allocated memory block.
3922 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
3923 <tag/Declaration/<tt/void* __fastcall__ realloc (void* block, size_t size);/
3924 <tag/Description/<tt/realloc/ changes the size of the memory block pointed to
3925 by <tt/block/ to <tt/size/ bytes. If <tt/block/ is <tt/NULL/, <tt/realloc/
3926 behaves as if <tt/malloc/ had been called. If <tt/size/ is zero, <tt/realloc/
3927 behaves as if <tt/free/ had been called. On error (not enough memory
3928 available), <tt/realloc/ returns <tt/NULL/.
3931 <item>The part of the memory block that is returned will have its contents
3933 <item>This function is somewhat dangerous to use. Be careful to save the
3934 pointer you're passing somewhere else, otherwise
3936 ptr = realloc (ptr, size);
3938 will loose your only copy of <tt/ptr/ if <tt/realloc/ returns <tt/NULL/.
3939 <item>The function is only available as fastcall function, so it may only
3940 be used in presence of a prototype.
3942 <tag/Availability/ISO 9899
3944 <ref id="_heapadd" name="_heapadd">,
3945 <ref id="_heapblocksize" name="_heapblocksize">,
3946 <ref id="_heapmaxavail" name="_heapmaxavail">,
3947 <ref id="_heapmemavail" name="_heapmemavail">,
3948 <ref id="calloc" name="calloc">,
3949 <ref id="free" name="free">,
3950 <ref id="realloc" name="realloc">
3956 <sect1>remove<label id="remove"><p>
3960 <tag/Function/Delete a file.
3961 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
3962 <tag/Declaration/<tt/int __fastcall__ remove (const char* name);/
3963 <tag/Description/<tt/remove/ deletes the file with the given name. On success,
3964 zero is returned. On error, -1 is returned and <tt/errno/ is set to an error
3965 code describing the reason for the failure.
3968 <item>This function is not available on all cc65 targets (depends on the
3969 availability of file I/O).
3970 <item>The function is only available as fastcall function, so it may only
3971 be used in presence of a prototype.
3973 <tag/Availability/ISO 9899
3975 <ref id="rename" name="rename">,
3976 <ref id="unlink" name="unlink">
3979 #include <stdio.h>
3981 #define FILENAME "helloworld"
3983 if (remove (FILENAME) == 0) {
3984 printf ("We deleted %s successfully\n", FILENAME);
3986 printf ("There was a problem deleting %s\n", FILENAME);
3993 <sect1>rename<label id="rename"><p>
3997 <tag/Function/Rename a file.
3998 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
3999 <tag/Declaration/<tt/int __fastcall__ rename (const char* oldname, const char* newname);/
4000 <tag/Description/<tt/rename/ renames a file (gives it a new name). On success,
4001 zero is returned. On error, -1 is returned and <tt/errno/ is set to an error
4002 code describing the reason for the failure.
4005 <item>This function is not available on all cc65 targets (depends on the
4006 capabilities of the storage devices).
4007 <item>The function is only available as fastcall function, so it may only
4008 be used in presence of a prototype.
4010 <tag/Availability/ISO 9899
4012 <ref id="remove" name="remove">
4015 #include <stdio.h>
4017 #define OLDNAME "textfile.txt"
4018 #define NEWNAME "textfile.bak"
4020 if (rename (OLDNAME, NEWNAME) == 0) {
4021 printf ("Renamed %s to %s\n", OLDNAME, NEWNAME);
4023 printf ("Error renaming %s to %s\n", OLDNAME, NEWNAME);
4030 <sect1>reset_brk<label id="reset_brk"><p>
4034 <tag/Function/Resets the break vector to its original value.
4035 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
4036 <tag/Declaration/<tt/void __fastcall__ reset_brk (void);/
4037 <tag/Description/<tt/reset_brk/ resets the break vector to the value it had
4038 before a call to <tt/set_brk/.
4041 <item>Since <tt/<ref id="set_brk" name="set_brk">/ installs an exit handler,
4042 it is not strictly necessary to call this function as part of the cleanup when
4045 <tag/Availability/cc65
4047 <ref id="set_brk" name="set_brk">
4053 <sect1>revers<label id="revers"><p>
4057 <tag/Function/Control revers character display.
4058 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
4059 <tag/Declaration/<tt/unsigned char __fastcall__ revers (unsigned char onoff);/
4060 <tag/Description/If the argument is non zero, the function enables reverse
4061 character display. If the argument is zero, reverse character display is
4062 switched off. The old value of the setting is returned.
4063 <tag/Limits/<itemize>
4064 <item>The function may not be supported by the hardware, in which case
4065 the call is ignored.
4066 <item>The function is only available as fastcall function, so it may only
4067 be used in presence of a prototype.
4069 <tag/Availability/cc65
4071 <ref id="textcolor" name="textcolor">
4077 <sect1>screensize<label id="screensize"><p>
4081 <tag/Function/Return the dimensions of the text mode screen.
4082 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
4083 <tag/Declaration/<tt/void __fastcall__ screensize (unsigned char* x, unsigned char* y);/
4084 <tag/Description/The function returns the dimensions of the text mode screen.
4085 <tag/Limits/<itemize>
4086 <item>The function is only available as fastcall function, so it may only
4087 be used in presence of a prototype.
4089 <tag/Availability/cc65
4091 <ref id="gotox" name="gotox">,
4092 <ref id="gotoxy" name="gotoxy">,
4093 <ref id="gotoy" name="gotoy">,
4094 <ref id="wherex" name="wherex">,
4095 <ref id="wherey" name="wherey">
4101 <sect1>set_brk<label id="set_brk"><p>
4105 <tag/Function/Set the break vector to a user function.
4106 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
4107 <tag/Declaration/<tt/void __fastcall__ set_brk (brk_handler func);/
4108 <tag/Description/<tt/set_brk/ allows a user program to handle breaks within the
4109 program code by letting the vector point to a user written C function. The
4110 runtime library installs a small stub that saves the registers into global
4111 variables that may be accessed (and changed) by the break handler.
4114 <item>The function is only available as fastcall function, so it may only
4115 be used in presence of a prototype.
4116 <item>The stub saves the zero page registers used by the C runtime and switches
4117 to a small break handler stack. This means that it is safe to execute C code,
4118 even if C code was interrupted. Be careful however not to use too many local
4119 variables, and do not enable stack checks for the handler function or any other
4120 function called from it.
4121 <item>The <tt/brk_pc/ variable points to the <tt/BRK/ instruction. If you want
4122 the continue with the interrupted code, you have to adjust <tt/brk_pc/,
4123 otherwise the <tt/BRK/ instruction will get executed over and over again.
4124 <item>Since <tt/set_brk/ installs an exit handler, it is not strictly necessary
4125 to call <tt/<ref id="reset_brk" name="reset_brk">/ as part of the cleanup when
4126 the program terminates.
4128 <tag/Availability/cc65
4130 <ref id="reset_brk" name="reset_brk">
4136 <sect1>setjmp<label id="setjmp"><p>
4140 <tag/Function/Save the context for use with <tt/longjmp/.
4141 <tag/Header/<tt/<ref id="setjmp.h" name="setjmp.h">/
4142 <tag/Declaration/<tt/int __fastcall__ setjmp (jmp_buf buf);/
4143 <tag/Description/The <tt/setjmp/ function saves the current context in <tt/buf/
4144 for subsequent use by the <tt/<ref id="longjmp" name="longjmp">/ function and
4148 <item>The function is only available as fastcall function, so it may only
4149 be used in presence of a prototype.
4150 <item><tt/setjmp/ is actually a macro as required by the ISO standard.
4151 <item><tt/setjmp/ will not save the signal context.
4153 <tag/Availability/ISO 9899
4155 <ref id="longjmp" name="longjmp">
4161 <sect1>setlocale<label id="setlocale"><p>
4165 <tag/Function/Selects a locale.
4166 <tag/Header/<tt/<ref id="locale.h" name="locale.h">/
4167 <tag/Declaration/<tt/char* __fastcall__ setlocale (int category, const char* locale);/
4168 <tag/Description/<tt/setlocale/ sets or queries the program's locale.
4171 <item>The function is only available as fastcall function, so it may only
4172 be used in presence of a prototype.
4173 <item>cc65 supports only the "C" locale, so calling this function to set a
4174 different locale has no effect.
4176 <tag/Availability/ISO 9899
4178 <ref id="localeconv" name="localeconv">,
4179 <ref id="strcoll" name="strcoll">
4180 <ref id="strxfrm" name="strxfrm">
4186 <sect1>signal<label id="signal"><p>
4190 <tag/Function/Install a signal handler.
4191 <tag/Header/<tt/<ref id="signal.h" name="signal.h">/
4192 <tag/Declaration/<tt/__sigfunc __fastcall__ signal (int sig, __sigfunc func);/
4193 <tag/Description/<tt/signal/ installs a handler for the given signal. The
4194 handler may either be a user supplied function, or one of the predefined
4195 signal handlers <tt/SIG_IGN/ or <tt/SIG_DFL/. The function returns the
4196 previous value if the signal , or the special function vector SIG_ERR in
4198 <tag/Limits/<itemize>
4199 <item>The function is only available as fastcall function, so it may only
4200 be used in presence of a prototype.
4202 <tag/Availability/ISO 9899
4204 <ref id="abort" name="abort">,
4205 <ref id="raise" name="raise">
4211 <sect1>sleep<label id="sleep"><p>
4215 <tag/Function/Sleep for a specified amount of time.
4216 <tag/Header/<tt/<ref id="unistd.h" name="unistd.h">/
4217 <tag/Declaration/<tt/void __fastcall__ sleep (unsigned seconds);/
4218 <tag/Description/The function will return after the specified number of
4219 seconds have elapsed.
4220 <tag/Limits/<itemize>
4221 <item>The function is only available as fastcall function, so it may only
4222 be used in presence of a prototype.
4224 <tag/Availability/POSIX 1003.1
4230 <sect1>slow<label id="slow"><p>
4234 <tag/Function/Switch the C128 into 1MHz mode.
4235 <tag/Header/<tt/<ref id="c128.h" name="c128.h">/
4236 <tag/Declaration/<tt/void slow (void);/
4237 <tag/Description/The function will switch the clock of the C128 to 1MHz. This
4238 will halve the speed compared to fast mode.
4239 <tag/Limits/<itemize>
4240 <item>The function is specific to the C128.
4242 <tag/Availability/C128
4244 <ref id="fast" name="fast">,
4245 <ref id="toggle_videomode" name="toggle_videomode">,
4246 <ref id="videomode" name="videomode">
4252 <sect1>srand<label id="srand"><p>
4256 <tag/Function/Initialize the pseudo random number generator.
4257 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
4258 <tag/Declaration/<tt/void __fastcall__ srand (unsigned seed);/
4259 <tag/Description/The function initializes the random number generator using
4260 the given seed. On program startup, the generator behaves as if <tt/srand/ has
4261 been called with an argument of 1.
4262 <tag/Limits/<itemize>
4263 <item>The function is only available as fastcall function, so it may only
4264 be used in presence of a prototype.
4266 <tag/Availability/ISO 9899
4268 <ref id="_randomize" name="_randomize">,
4269 <ref id="rand" name="rand">
4275 <sect1>strcasecmp<label id="strcasecmp"><p>
4279 <tag/Function/Compare two strings case insensitive.
4280 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4281 <tag/Declaration/<tt/int __fastcall__ strcasecmp (const char* s1, const char* s2);/
4282 <tag/Description/The <tt/strcasecmp/ function compares the two strings passed
4283 as parameters without case sensitivity. It returns a value that is less than
4284 zero if <tt/s1/ is less than <tt/s2/, zero if <tt/s1/ is the same as <tt/s2/,
4285 and a value greater than zero if <tt/s1/ is greater than <tt/s2/.
4286 <tag/Limits/<itemize>
4287 <item>The function is only available as fastcall function, so it may only
4288 be used in presence of a prototype.
4289 <item>The function is not available in strict ANSI mode.
4291 <tag/Availability/cc65
4293 <ref id="strcmp" name="strcmp">,
4294 <ref id="strcoll" name="strcoll">,
4295 <ref id="stricmp" name="stricmp">,
4296 <ref id="strncmp" name="strncmp">
4297 <ref id="strxfrm" name="strxfrm">
4303 <sect1>strcat<label id="strcat"><p>
4307 <tag/Function/Concatentate two strings.
4308 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4309 <tag/Declaration/<tt/char* __fastcall__ strcat (char* s1, const char* s2);/
4310 <tag/Description/The <tt/strcat/ function appends a copy of the string
4311 pointed to by s2 (including the terminating null byte) to the end of the
4312 string pointed to by s1. The initial byte of s2 overwrites the null byte at
4314 <tag/Limits/<itemize>
4315 <item>The function is only available as fastcall function, so it may only
4316 be used in presence of a prototype.
4317 <item>If copying takes place between objects that overlap, the behaviour
4320 <tag/Availability/ISO 9899
4322 <ref id="strcpy" name="strcpy">,
4323 <ref id="strncat" name="strncat">,
4324 <ref id="strncpy" name="strncpy">
4330 <sect1>strchr<label id="strchr"><p>
4334 <tag/Function/Search for a character in a string.
4335 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4336 <tag/Declaration/<tt/char* __fastcall__ strchr (const char* s, int c);/
4337 <tag/Description/The <tt/strchr/ function locates the first occurrence of <tt/c/
4338 (converted to a char) in the string pointed to by <tt/s/. The terminating null
4339 byte is considered to be part of the string. Upon completion, the function
4340 returns a pointer to the byte, or a null pointer if the byte was not found.
4341 <tag/Limits/<itemize>
4342 <item>The function is only available as fastcall function, so it may only
4343 be used in presence of a prototype.
4345 <tag/Availability/ISO 9899
4347 <ref id="memchr" name="memchr">,
4348 <ref id="strrchr" name="strrchr">
4354 <sect1>strcmp<label id="strcmp"><p>
4358 <tag/Function/Compare two strings.
4359 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4360 <tag/Declaration/<tt/int __fastcall__ strcmp (const char* s1, const char* s2);/
4361 <tag/Description/The <tt/strcmp/ function compares the two strings passed as
4362 parameters. It returns a value that is less than zero if <tt/s1/ is less than
4363 <tt/s2/, zero if <tt/s1/ is the same as <tt/s2/, and a value greater than zero
4364 if <tt/s1/ is greater than <tt/s2/.
4365 <tag/Limits/<itemize>
4366 <item>The function is only available as fastcall function, so it may only
4367 be used in presence of a prototype.
4369 <tag/Availability/ISO 9899
4371 <ref id="strcasecmp" name="strcasecmp">,
4372 <ref id="strcoll" name="strcoll">,
4373 <ref id="stricmp" name="stricmp">,
4374 <ref id="strncmp" name="strncmp">
4375 <ref id="strxfrm" name="strxfrm">
4381 <sect1>strcoll<label id="strcoll"><p>
4385 <tag/Function/Compare two strings.
4386 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4387 <tag/Declaration/<tt/int __fastcall__ strcoll (const char* s1, const char* s2);/
4388 <tag/Description/The <tt/strcoll/ function compares the two strings passed as
4389 parameters, according to the collating sequence set by <tt/<ref id="setlocale"
4390 name="setlocale">/. It returns a value that is less than zero if <tt/s1/ is
4391 less than <tt/s2/, zero if <tt/s1/ is the same as <tt/s2/, and a value greater
4392 than zero if <tt/s1/ is greater than <tt/s2/.
4393 <tag/Limits/<itemize>
4394 <item>The function is only available as fastcall function, so it may only
4395 be used in presence of a prototype.
4397 <tag/Availability/ISO 9899
4399 <ref id="setlocale" name="setlocale">,
4400 <ref id="strcasecmp" name="strcasecmp">,
4401 <ref id="strcmp" name="strcmp">,
4402 <ref id="stricmp" name="stricmp">,
4403 <ref id="strncmp" name="strncmp">
4404 <ref id="strxfrm" name="strxfrm">
4410 <sect1>strcpy<label id="strcpy"><p>
4414 <tag/Function/Copy a string.
4415 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4416 <tag/Declaration/<tt/char* __fastcall__ strcpy (char* s1, const char* s2);/
4417 <tag/Description/The <tt/strcpy/ function copies the string pointed to by
4418 <tt/s2/ (including the terminating null byte) into the array pointed to by
4419 <tt/s1/. The function will always return <tt/s1/.
4420 <tag/Limits/<itemize>
4421 <item>The function is only available as fastcall function, so it may only
4422 be used in presence of a prototype.
4423 <item>If copying takes place between objects that overlap, the behaviour
4426 <tag/Availability/ISO 9899
4428 <ref id="strcat" name="strcat">,
4429 <ref id="strncat" name="strncat">,
4430 <ref id="strncpy" name="strncpy">
4433 #include <string.h>
4435 static char hello[14];
4437 strcpy (hello, "Hello world!\n");
4443 <sect1>strcspn<label id="strcspn"><p>
4447 <tag/Function/Compute the length of a substring.
4448 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4449 <tag/Declaration/<tt/size_t __fastcall__ strcspn (const char* s, const char* set);/
4450 <tag/Description/The <tt/strcspn/ function computes and returns the length of
4451 the substring pointed to by <tt/s/ which does <em>not</em> consist of
4452 characters contained in the string <tt/set/.
4453 <tag/Limits/<itemize>
4454 <item>The function is only available as fastcall function, so it may only
4455 be used in presence of a prototype.
4457 <tag/Availability/ISO 9899
4459 <ref id="strspn" name="strspn">,
4460 <ref id="strstr" name="strstr">,
4461 <ref id="strtok" name="strtok">
4467 <sect1>strdup<label id="strdup"><p>
4471 <tag/Function/Allocate a copy of a string on the heap.
4472 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4473 <tag/Declaration/<tt/char* __fastcall__ strdup (const char* s);/
4474 <tag/Description/<tt/strdup/ allocates a memory block on the heap, big enough
4475 to hold a copy of <tt/s/ including the terminating zero. If the allocation
4476 fails, <tt/NULL/ is returned, otherwise <tt/s/ is copied into the allocated
4477 memory block, and a pointer to the block is returned.
4478 <tag/Limits/<itemize>
4479 <item>The function is only available as fastcall function, so it may only
4480 be used in presence of a prototype.
4481 <item>It is up to the caller to free the allocated memory block.
4483 <tag/Availability/ISO 9899
4485 <ref id="free" name="free">,
4486 <ref id="malloc" name="malloc">
4492 <sect1>strerror<label id="strerror"><p>
4496 <tag/Function/Return a string describing an error code.
4497 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4498 <tag/Declaration/<tt/char* __fastcall__ strerror (int errcode);/
4499 <tag/Description/The <tt/strerror/ function returns a string describing the
4500 given error code. If an invalid error code is passed, the string "Unknown
4501 error" is returned, and <tt/errno/ is set to <tt/EINVAL/. In all other cases,
4502 <tt/errno/ is left untouched.
4503 <tag/Limits/<itemize>
4504 <item>The function is only available as fastcall function, so it may only
4505 be used in presence of a prototype.
4506 <item>While the return type of the function is a <tt/char*/, the returned
4507 string must not be modified by the caller!
4509 <tag/Availability/ISO 9899
4511 <ref id="_stroserror" name="_stroserror">
4517 <sect1>stricmp<label id="stricmp"><p>
4521 <tag/Function/Compare two strings case insensitive.
4522 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4523 <tag/Declaration/<tt/int __fastcall__ stricmp (const char* s1, const char* s2);/
4524 <tag/Description/The <tt/stricmp/ function compares the two strings passed as
4525 parameters without case sensitivity. It returns a value that is less than zero
4526 if <tt/s1/ is less than <tt/s2/, zero if <tt/s1/ is the same as <tt/s2/, and a
4527 value greater than zero if <tt/s1/ is greater than <tt/s2/.
4528 <tag/Limits/<itemize>
4529 <item>The function is only available as fastcall function, so it may only
4530 be used in presence of a prototype.
4531 <item>The function is not available in strict ANSI mode.
4533 <tag/Availability/cc65
4535 <ref id="strcasecmp" name="strcasecmp">,
4536 <ref id="strcmp" name="strcmp">,
4537 <ref id="strcoll" name="strcoll">,
4538 <ref id="strncmp" name="strncmp">
4539 <ref id="strxfrm" name="strxfrm">
4545 <sect1>strlen<label id="strlen"><p>
4549 <tag/Function/Return the length of a string.
4550 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4551 <tag/Declaration/<tt/size_t __fastcall__ strlen (const char* s);/
4552 <tag/Description/The <tt/strlen/ function computes the number of bytes in the
4553 string to which s points, not including the terminating null byte.
4554 <tag/Limits/<itemize>
4555 <item>The function is only available as fastcall function, so it may only
4556 be used in presence of a prototype.
4557 <item>When compiling with <tt/-Os/ (inline known standard functions), the
4558 function does not work correctly for strings with more than 255 characters.
4560 <tag/Availability/ISO 9899
4562 <ref id="strcpy" name="strcpy">
4568 <sect1>strlower<label id="strlower"><p>
4572 <tag/Function/Make a string lower case.
4573 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4574 <tag/Declaration/<tt/char* __fastcall__ strlower (char* s);/
4575 <tag/Description/The <tt/strlower/ function will apply the <tt/tolower/
4576 function to each character of a string. The function will always return <tt/s/.
4577 <tag/Limits/<itemize>
4578 <item>The function is only available as fastcall function, so it may only
4579 be used in presence of a prototype.
4580 <item>The function prototype is unavailable when compiling in strict ANSI mode.
4581 <item>An alias name for this function is <tt/strlwr/.
4583 <tag/Availability/cc65
4585 <ref id="strupper" name="strupper">,
4586 <ref id="tolower" name="tolower">
4592 <sect1>strlwr<label id="strlwr"><p>
4599 <sect1>strncat<label id="strncat"><p>
4603 <tag/Function/Concatentate two strings.
4604 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4605 <tag/Declaration/<tt/char* __fastcall__ strncat (char* s1, const char* s2, size_t n);/
4606 <tag/Description/The <tt/strncat/ function appends not more than n characters
4607 of the string pointed to by s2 to the end of the string pointed to by s1. The
4608 terminating null character at the end of s1 is overwritten. A terminating null
4609 character is appended to the result, even if not all of s2 is appended to s1.
4610 <tag/Limits/<itemize>
4611 <item>The function is only available as fastcall function, so it may only
4612 be used in presence of a prototype.
4613 <item>If copying takes place between objects that overlap, the behaviour
4616 <tag/Availability/ISO 9899
4618 <ref id="strcpy" name="strcpy">,
4619 <ref id="strncat" name="strncat">,
4620 <ref id="strncpy" name="strncpy">
4626 <sect1>strncmp<label id="strncmp"><p>
4630 <tag/Function/Compare two strings.
4631 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4632 <tag/Declaration/<tt/int __fastcall__ strncmp (const char* s1, const char* s2, size_t count);/
4633 <tag/Description/The <tt/strncmp/ function compares not more than <tt/count/
4634 characters of the two strings passed as parameters. It returns a value that is
4635 less than zero if the first <tt/count/ characters of <tt/s1/ are less than
4636 <tt/s2/, zero if they are identical, and a value greater than zero they are
4638 <tag/Limits/<itemize>
4639 <item>The function is only available as fastcall function, so it may only
4640 be used in presence of a prototype.
4642 <tag/Availability/ISO 9899
4644 <ref id="strcasecmp" name="strcasecmp">,
4645 <ref id="strcmp" name="strcmp">,
4646 <ref id="strcoll" name="strcoll">,
4647 <ref id="stricmp" name="stricmp">
4648 <ref id="strxfrm" name="strxfrm">
4654 <sect1>strncpy<label id="strncpy"><p>
4658 <tag/Function/Copy part of a string.
4659 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4660 <tag/Declaration/<tt/char* __fastcall__ strcpy (char* s1, const char* s2, size_t n);/
4661 <tag/Description/The <tt/strncpy/ function copies not more than n bytes from
4662 the array pointed to by <tt/s2/ to the array pointed to by <tt/s1/. If the array
4663 pointed to by <tt/s2/ is a string that is shorter than n bytes, null bytes are
4664 appended to the copy in the array pointed to by <tt/s1/, until <tt/n/ bytes are
4665 written. The function will always return <tt/s1/.
4666 <tag/Limits/<itemize>
4667 <item>The function is only available as fastcall function, so it may only
4668 be used in presence of a prototype. If there is no null byte in the first <tt/n/
4669 bytes of the array pointed to by <tt/s2/, the result is not null-terminated.
4670 <item>If copying takes place between objects that overlap, the behaviour is
4673 <tag/Availability/ISO 9899
4675 <ref id="strcat" name="strcat">,
4676 <ref id="strcpy" name="strcpy">,
4677 <ref id="strncat" name="strncat">
4682 static char hello[6];
4684 strcpy (hello, "Hello world!\n", sizeof (hello) - 1);
4691 <sect1>strrchr<label id="strrchr"><p>
4695 <tag/Function/Search for a character in a string.
4696 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4697 <tag/Declaration/<tt/char* __fastcall__ strrchr (const char* s, int c);/
4698 <tag/Description/The <tt/strrchr/ function locates the last occurrence of <tt/c/
4699 (converted to a char) in the string pointed to by <tt/s/. The terminating null
4700 byte is considered to be part of the string. Upon completion, the function
4701 returns a pointer to the byte, or a null pointer if the byte was not found.
4702 <tag/Limits/<itemize>
4703 <item>The function is only available as fastcall function, so it may only
4704 be used in presence of a prototype.
4706 <tag/Availability/ISO 9899
4708 <ref id="strchr" name="strchr">
4714 <sect1>strspn<label id="strspn"><p>
4718 <tag/Function/Compute the length of a substring.
4719 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4720 <tag/Declaration/<tt/size_t __fastcall__ strspn (const char* s, const char* set);/
4721 <tag/Description/The <tt/strspn/ function computes and returns the length of
4722 the substring pointed to by <tt/s/ which does consist only of characters
4723 contained in the string <tt/set/.
4724 <tag/Limits/<itemize>
4725 <item>The function is only available as fastcall function, so it may only
4726 be used in presence of a prototype.
4728 <tag/Availability/ISO 9899
4730 <ref id="strcspn" name="strcspn">,
4731 <ref id="strstr" name="strstr">
4737 <sect1>strstr<label id="strstr"><p>
4741 <tag/Function/Find a substring.
4742 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4743 <tag/Declaration/<tt/char* __fastcall__ strstr (const char* str, const char* substr);/
4744 <tag/Description/<tt/strstr/ searches for the first occurance of the string
4745 <tt/substr/ within <tt/str/. If found, it returns a pointer to the copy,
4746 otherwise it returns <tt/NULL/.
4747 <tag/Limits/<itemize>
4748 <item>The function is only available as fastcall function, so it may only
4749 be used in presence of a prototype.
4751 <tag/Availability/ISO 9899
4753 <ref id="strcspn" name="strcspn">,
4754 <ref id="strspn" name="strspn">
4760 <sect1>strtok<label id="strtok"><p>
4764 <tag/Function/Break a string into tokens.
4765 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4766 <tag/Declaration/<tt/char* __fastcall__ strtok (char* s1, const char* s2);/
4767 <tag/Description/<tt/strtok/ will break the string s1 into a sequence of
4768 tokens, which are delimited by characters from the string s2. The first call
4769 to <tt/strtok/ will return a pointer to the first token in the string s1.
4770 Following calls must pass a <tt/NULL/ pointer as s1 in order to get the next
4771 token in the string. Different sets of delimiters may be used for the
4772 subsequent calls to <tt/strtok/.
4773 <tag/Limits/<itemize>
4774 <item>The function is only available as fastcall function, so it may only
4775 be used in presence of a prototype.
4776 <item><tt/strtok/ will modify the string s1.
4778 <tag/Availability/ISO 9899
4780 <ref id="strcspn" name="strcspn">,
4781 <!-- <ref id="strpbrk" name="strpbrk"> -->
4787 <sect1>strxfrm<label id="strxfrm"><p>
4791 <tag/Function/Transform a string.
4792 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4793 <tag/Declaration/<tt/size_t __fastcall__ strxfrm (char* s1, const char* s2, size_t n);/
4794 <tag/Description/The <tt/strxfrm/ function transforms the string pointed to by
4795 s2 and places the resulting string into the string pointed to by s1. The
4796 transformation is such that if the <tt/strcmp/ function is applied to two
4797 transformed strings, it returns a value greater than, equal to, or less than
4798 zero, corresponding to the result of the <tt/strcoll/ function applied to the
4799 same two original strings. No more than n characters are placed into the
4800 resulting array pointed to by s1, including the terminating null character.
4801 <tag/Limits/<itemize>
4802 <item><tt/s1/ and <tt/s2/ must not point to the same memory area, otherwise
4803 the behaviour is undefined.
4804 <item>If <tt/n/ is zero, <tt/s1/ may be a NULL pointer.
4805 <item>The function is only available as fastcall function, so it may only
4806 be used in presence of a prototype.
4807 <item>Since cc65 doesn't support different charcter sets, <tt/strxfrm/ will
4808 just copy s2 to s1 using <tt><ref id="strncpy" name="strncpy"></tt>.
4810 <tag/Availability/ISO 9899
4812 <ref id="strcmp" name="strcmp">,
4813 <ref id="strcoll" name="strcoll">,
4814 <ref id="strncpy" name="strncpy">,
4820 <sect1>strupper<label id="strupper"><p>
4824 <tag/Function/Make a string upper case.
4825 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4826 <tag/Declaration/<tt/char* __fastcall__ strupper (char* s);/
4827 <tag/Description/The <tt/strupper/ function will apply the <tt/toupper/
4828 function to each character of a string. The function will always return <tt/s/.
4829 <tag/Limits/<itemize>
4830 <item>The function is only available as fastcall function, so it may only
4831 be used in presence of a prototype.
4832 <item>The function prototype is unavailable when compiling in strict ANSI mode.
4833 <item>An alias name for this function is <tt/strupr/.
4835 <tag/Availability/cc65
4837 <ref id="strlower" name="strlower">
4838 <ref id="toupper" name="toupper">
4844 <sect1>strupr<label id="strupr"><p>
4851 <sect1>textcolor<label id="textcolor"><p>
4855 <tag/Function/Set the text color.
4856 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
4857 <tag/Declaration/<tt/unsigned char __fastcall__ textcolor (unsigned char color);/
4858 <tag/Description/The function will set a new text color. It returns the old
4859 (current) text color. Text output using any <tt/conio.h/ function will use
4860 the color set by this function.
4861 <tag/Limits/<itemize>
4862 <item>Text colors are system dependent. The function may have no effect
4863 on systems where the text color cannot be changed.
4864 <item>The function is only available as fastcall function, so it may only
4865 be used in presence of a prototype.
4867 <tag/Availability/cc65
4869 <ref id="bgcolor" name="bgcolor">,
4870 <ref id="bordercolor" name="bordercolor">
4876 <sect1>tgi_arc<label id="tgi_arc"><p>
4880 <tag/Function/Draw an elliptic arc in the current color.
4881 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
4882 <tag/Declaration/<tt/void __fastcall__ tgi_arc (int x, int y,
4883 unsigned char rx, unsigned char ry, unsigned sa, unsigned ea);/
4884 <tag/Description/The function draws an elliptic arc with center at x/y and
4885 radii rx/ry using the current drawing color. The arc covers the angle
4886 between sa and ea (startangle and endangle), which must be in the range
4888 <tag/Limits/<itemize>
4889 <item>The function is only available as fastcall function, so it may only
4890 be used in presence of a prototype.
4891 <item>The function behaves unexpectedly or may crash if the angles are out
4894 <tag/Availability/cc65
4896 <ref id="tgi_bar" name="tgi_bar">,
4897 <ref id="tgi_circle" name="tgi_circle">,
4898 <ref id="tgi_ellipse" name="tgi_ellipse">,
4899 <ref id="tgi_pieslice" name="tgi_pieslice">,
4900 <ref id="tgi_setcolor" name="tgi_setcolor">
4902 /* Draw the upper half of an ellipse */
4903 tgi_setcolor(TGI_COLOR_BLUE);
4904 tgi_arc (50, 50, 40, 20, 0, 180);
4910 <sect1>tgi_bar<label id="tgi_bar"><p>
4914 <tag/Function/The function fills a rectangle on the drawpage with the current
4916 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
4917 <tag/Declaration/<tt/void __fastcall__ tgi_bar (int x1, int y1, int x2, int y2);/
4918 <tag/Description/The function fills a rectangle on the drawpage with the current
4920 <tag/Limits/<itemize>
4921 <item>The function is only available as fastcall function, so it may only
4922 be used in presence of a prototype.
4924 <tag/Availability/cc65
4925 <tag/See also/Other tgi function
4927 tgi_setcolor(TGI_COLOR_GREEN);
4928 tgi_bar(10, 10, 100, 60);
4934 <sect1>tgi_circle<label id="tgi_circle"><p>
4938 <tag/Function/The function draws a circle in the current color.
4939 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
4940 <tag/Declaration/<tt/void __fastcall__ tgi_circle (int x, int y, unsigned char radius);/
4941 <tag/Description/The function draws a circle in the current color.
4942 <tag/Limits/<itemize>
4943 <item>The function is only available as fastcall function, so it may only
4944 be used in presence of a prototype.
4946 <tag/Availability/cc65
4948 <ref id="tgi_arc" name="tgi_arc">,
4949 <ref id="tgi_bar" name="tgi_bar">,
4950 <ref id="tgi_ellipse" name="tgi_ellipse">,
4951 <ref id="tgi_pieslice" name="tgi_pieslice">,
4952 <ref id="tgi_setcolor" name="tgi_setcolor">
4954 tgi_setcolor(TGI_COLOR_BLACK);
4955 tgi_circle(50, 40, 40);
4961 <sect1>tgi_clear<label id="tgi_clear"><p>
4965 <tag/Function/Clear the drawpage
4966 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
4967 <tag/Declaration/<tt/void __fastcall__ tgi_clear (void);/
4968 <tag/Description/Clear the drawpage
4969 <tag/Limits/<itemize>
4970 <item>The function is only available as fastcall function, so it may only
4971 be used in presence of a prototype.
4973 <tag/Availability/cc65
4974 <tag/See also/Other tgi functions
4980 <sect1>tgi_done<label id="tgi_done"><p>
4984 <tag/Function/End graphics mode, switch back to text mode.
4985 Will NOT uninstall or unload the driver!
4986 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
4987 <tag/Declaration/<tt/void __fastcall__ tgi_done (void);/
4988 <tag/Description/End graphics mode, switch back to text mode.
4989 Will NOT uninstall or unload the driver!
4990 <tag/Limits/<itemize>
4991 <item>The function is only available as fastcall function, so it may only
4992 be used in presence of a prototype.
4994 <tag/Availability/cc65
4995 <tag/See also/Other tgi functions
5001 <sect1>tgi_ellipse<label id="tgi_ellipse"><p>
5005 <tag/Function/The function draws an ellipse in the current color.
5006 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5007 <tag/Declaration/<tt/void __fastcall__ tgi_ellipse (int x, int y, unsigned char rx, unsigned char ry);/
5008 <tag/Description/The function draws an ellipse at position x/y with radii
5009 rx and ry, using the current drawing color.
5010 <tag/Limits/<itemize>
5011 <item>The function is only available as fastcall function, so it may only
5012 be used in presence of a prototype.
5014 <tag/Availability/cc65
5016 <ref id="tgi_arc" name="tgi_arc">,
5017 <ref id="tgi_bar" name="tgi_bar">,
5018 <ref id="tgi_circle" name="tgi_circle">,
5019 <ref id="tgi_pieslice" name="tgi_pieslice">,
5020 <ref id="tgi_setcolor" name="tgi_setcolor">
5022 tgi_setcolor(TGI_COLOR_RED);
5023 tgi_ellipse (50, 40, 40, 20);
5029 <sect1>tgi_getcolor<label id="tgi_getcolor"><p>
5033 <tag/Function/Return the current drawing color.
5034 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5035 <tag/Declaration/<tt/unsigned char __fastcall__ tgi_getcolor (void);/
5036 <tag/Description/The actual color is an index to a palette. During tgi_init
5037 you will get a default palette. The number of colors depend on the platform.
5038 All platforms recognize at least TGI_COLOR_BLACK and TGI_COLOR_WHITE. But some
5039 platforms have many more predefined colors. If you paint using TGI_COLOR_GREEN
5040 and then you change the green of the palette to blue using tgi_setpalette then
5041 after this painting in TGI_COLOR_GREEN will actually be blue.
5042 <tag/Limits/<itemize>
5043 <item>The function is only available as fastcall function, so it may only
5044 be used in presence of a prototype.
5046 <tag/Availability/cc65
5047 <tag/See also/Other tgi functions
5049 color = tgi_getcolor();
5054 <sect1>tgi_getcolorcount<label id="tgi_getcolorcount"><p>
5058 <tag/Function/Get the number of available colors.
5059 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5060 <tag/Declaration/<tt/unsigned char __fastcall__ tgi_getcolorcount (void);/
5061 <tag/Description/Tgi platforms use indexed color palettes. This function
5062 returns the number of entries we can use in the palette.
5063 <tag/Limits/<itemize>
5064 <item>The function is only available as fastcall function, so it may only
5065 be used in presence of a prototype.
5067 <tag/Availability/cc65
5068 <tag/See also/Other tgi functions
5070 if (tgi_getcolorcount() == 2) {
5071 printf("Only monochrome graphics is supported\n");
5077 <sect1>tgi_getdefpalette<label id="tgi_getdefpalette"><p>
5081 <tag/Function/Get the palette installed by default.
5082 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5083 <tag/Declaration/<tt/const unsigned char* __fastcall__ tgi_getdefpalette (void);/
5084 <tag/Description/The tgi driver has a default palette that is active at startup.
5085 The named colors TGI_COLOR_BLACK, TGI_COLOR_WHITE, TGI_COLOR_RED... need this
5086 palette to work correctly.
5087 <tag/Limits/<itemize>
5088 <item>The function is only available as fastcall function, so it may only
5089 be used in presence of a prototype.
5091 <tag/Availability/cc65
5092 <tag/See also/Other tgi functions
5097 <sect1>tgi_geterror<label id="tgi_geterror"><p>
5101 <tag/Function/Return the error code for the last operation.
5102 This will also clear the error.
5103 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5104 <tag/Declaration/<tt/unsigned char __fastcall__ tgi_geterror (void);/
5105 <tag/Description/Return the error code for the last operation.
5106 This will also clear the error.
5107 <tag/Limits/<itemize>
5108 <item>The function is only available as fastcall function, so it may only
5109 be used in presence of a prototype.
5111 <tag/Availability/cc65
5112 <tag/See also/Other tgi functions
5117 <sect1>tgi_geterrormsg<label id="tgi_geterrormsg"><p>
5121 <tag/Function/Get an error message describing the error.
5122 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5123 <tag/Declaration/<tt/const char* __fastcall__ tgi_geterrormsg (unsigned char code);/
5124 <tag/Description/Get an error message describing the error.
5125 <tag/Limits/<itemize>
5126 <item>The function is only available as fastcall function, so it may only
5127 be used in presence of a prototype.
5129 <tag/Availability/cc65
5130 <tag/See also/Other tgi functions
5135 <sect1>tgi_getmaxcolor<label id="tgi_getmaxcolor"><p>
5139 <tag/Function/Get the highest index of the palette.
5140 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5141 <tag/Declaration/<tt/unsigned char __fastcall__ tgi_getmaxcolor (void);/
5142 <tag/Description/Get the highest index of the palette.
5143 <tag/Limits/<itemize>
5144 <item>The function is only available as fastcall function, so it may only
5145 be used in presence of a prototype.
5147 <tag/Availability/cc65
5148 <tag/See also/Other tgi functions
5153 <sect1>tgi_getmaxx<label id="tgi_getmaxx"><p>
5157 <tag/Function/Get the maximum x coordinate that can be used on this screen.
5158 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5159 <tag/Declaration/<tt/unsigned __fastcall__ tgi_getmaxx (void);/
5160 <tag/Description/Get the maximum x coordinate that can be used on this screen.
5161 <tag/Limits/<itemize>
5162 <item>The function is only available as fastcall function, so it may only
5163 be used in presence of a prototype.
5165 <tag/Availability/cc65
5166 <tag/Availability/cc65
5167 <tag/See also/Other tgi functions
5172 <sect1>tgi_getmaxy<label id="tgi_getmaxy"><p>
5176 <tag/Function/Get the maximum y coordinate that can be used on this screen.
5177 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5178 <tag/Declaration/<tt/unsigned __fastcall__ tgi_getmaxy (void);/
5179 <tag/Description/Get the maximum y coordinate that can be used on this screen.
5180 <tag/Limits/<itemize>
5181 <item>The function is only available as fastcall function, so it may only
5182 be used in presence of a prototype.
5184 <tag/Availability/cc65
5185 <tag/See also/Other tgi functions
5190 <sect1>tgi_getpagecount<label id="tgi_getpagecount"><p>
5194 <tag/Function/Return the number of screen pages available.
5195 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5196 <tag/Declaration/<tt/unsigned __fastcall__ tgi_getpagecount (void);/
5197 <tag/Description/Return the number of screen pages available.
5198 <tag/Limits/<itemize>
5199 <item>The function is only available as fastcall function, so it may only
5200 be used in presence of a prototype.
5202 <tag/Availability/cc65
5204 <ref id="tgi_setdrawpage" name="tgi_setdrawpage">,
5205 <ref id="tgi_setviewpage" name="tgi_setviewpage">
5210 <sect1>tgi_getpalette<label id="tgi_getpalette"><p>
5214 <tag/Function/Get the palette installed.
5215 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5216 <tag/Declaration/<tt/const unsigned char* __fastcall__ tgi_getpalette (void);/
5217 <tag/Description/Get the palette installed.
5218 <tag/Limits/<itemize>
5219 <item>The function is only available as fastcall function, so it may only
5220 be used in presence of a prototype.
5222 <tag/Availability/cc65
5223 <tag/See also/Other tgi functions
5228 <sect1>tgi_getpixel<label id="tgi_getpixel"><p>
5232 <tag/Function/Get the color of a pixel from the viewpage.
5233 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5234 <tag/Declaration/<tt/unsigned char __fastcall__ tgi_getpixel (int x, int y);/
5235 <tag/Description/Get the color of a pixel from the viewpage.
5236 <tag/Limits/<itemize>
5237 <item>The function is only available as fastcall function, so it may only
5238 be used in presence of a prototype.
5240 <tag/Availability/cc65
5241 <tag/See also/Other tgi functions.
5246 <sect1>tgi_getxres<label id="tgi_getxres"><p>
5250 <tag/Function/Get number of horisontal pixels on the screen.
5251 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5252 <tag/Declaration/<tt/unsigned __fastcall__ tgi_getxres (void);/
5253 <tag/Description/Get number of horisontal pixels on the screen.
5254 This is same as tgi_maxx()+1.
5255 <tag/Limits/<itemize>
5256 <item>The function is only available as fastcall function, so it may only
5257 be used in presence of a prototype.
5259 <tag/Availability/cc65
5260 <tag/See also/Other tgi functions.
5265 <sect1>tgi_getyres<label id="tgi_getyres"><p>
5269 <tag/Function/Get number of vertical pixels on the screen.
5270 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5271 <tag/Declaration/<tt/unsigned __fastcall__ tgi_getyres (void);/
5272 <tag/Description/Get number of vertical pixels on the screen.
5273 This is same as tgi_maxy()+1.
5274 <tag/Limits/<itemize>
5275 <item>The function is only available as fastcall function, so it may only
5276 be used in presence of a prototype.
5278 <tag/Availability/cc65
5279 <tag/See also/Other tgi functions.
5284 <sect1>tgi_gotoxy<label id="tgi_gotoxy"><p>
5288 <tag/Function/Set graphics cursor at x, y.
5289 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5290 <tag/Declaration/<tt/void __fastcall__ tgi_gotoxy (int x, int y);/
5291 <tag/Description/Set graphics cursor at x, y.
5292 <tag/Limits/<itemize>
5293 <item>The function is only available as fastcall function, so it may only
5294 be used in presence of a prototype.
5296 <tag/Availability/cc65
5297 <tag/See also/Other tgi functions.
5302 <sect1>tgi_init<label id="tgi_init"><p>
5306 <tag/Function/Initialize the already loaded graphics driver.
5307 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5308 <tag/Declaration/<tt/void __fastcall__ tgi_init (void);/
5309 <tag/Description/The tgi_init function will set the default palette to the
5310 hardware and clear the screen.
5311 <tag/Limits/<itemize>
5312 <item>The function is only available as fastcall function, so it may only
5313 be used in presence of a prototype.
5315 <tag/Availability/cc65
5316 <tag/See also/Other tgi functions.
5318 extern char lynxtgi[]; //Include the driver statically instead of loading it.
5319 tgi_install(&lynxtgi);
5320 tgi_init(); //Set up the default palette and clear the screen.
5325 <sect1>tgi_install<label id="tgi_install"><p>
5329 <tag/Function/Install an already loaded driver and return an error code.
5330 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5331 <tag/Declaration/<tt/unsigned char __fastcall__ tgi_install (void* driver);/
5332 <tag/Description/The function installs a driver that was already loaded into
5333 memory (or linked statically to the program). It returns an error code
5334 (<tt/TGI_ERR_OK/ in case of success).
5335 <tag/Limits/<itemize>
5336 <item>The function is only available as fastcall function, so it may only be
5337 used in presence of a prototype.
5339 <tag/Availability/cc65
5341 <ref id="tgi_load_driver" name="tgi_load_driver">,
5342 <ref id="tgi_uninstall" name="tgi_uninstall">,
5343 <ref id="tgi_unload" name="tgi_unload">
5345 extern char lynxtgi[]; //Include the driver statically instead of loading it.
5347 tgi_install(&lynxtgi);
5348 tgi_init(); //Set up the default palette and clear the screen.
5354 <sect1>tgi_ioctl<label id="tgi_ioctl"><p>
5358 <tag/Function/Platform dependent code extensions.
5359 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5360 <tag/Declaration/<tt/unsigned __fastcall__ tgi_ioctl (unsigned char code, unsigned val);/
5361 <tag/Description/Some platforms have extra display hardware that is not
5362 supported by standard tgi functions. You can extend the driver to support
5363 this extra hardware using tgi_ioctl functions.
5364 <tag/Limits/<itemize>
5365 <item>The function is only available as fastcall function, so it may only
5366 be used in presence of a prototype.
5367 <item>These functions are not easily portable to other cc65 platforms.
5369 <tag/Availability/cc65
5370 <tag/See also/Other tgi functions.
5372 #define tgi_sprite(spr) tgi_ioctl(0, (unsigned)(spr))
5373 #define tgi_flip() tgi_ioctl(1, 0)
5374 #define tgi_setbgcolor(bgcol) tgi_ioctl(2, (unsigned)(bgcol))
5375 #define tgi_setframerate(rate) tgi_ioctl(3, (unsigned)(rate))
5376 #define tgi_busy() tgi_ioctl(4, 0)
5377 #define tgi_updatedisplay() tgi_ioctl(4, 1)
5379 tgi_sprite(&background);
5380 tgi_setcolor(TGI_COLOR_BLUE);
5381 tgi_outttextxy(20,40,"Hello World");
5382 tgi_updatedisplay();
5389 <sect1>tgi_line<label id="tgi_line"><p>
5393 <tag/Function/Draw a line in the current drawing color.
5394 The graphics cursor will be set to x2/y2 by this call.
5395 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5396 <tag/Declaration/<tt/void __fastcall__ tgi_line (int x1, int y1, int x2, int y2);/
5397 <tag/Description/Draw a line in the current drawing color.
5398 The graphics cursor will be set to x2/y2 by this call.
5399 <tag/Limits/<itemize>
5400 <item>The function is only available as fastcall function, so it may only
5401 be used in presence of a prototype.
5403 <tag/Availability/cc65
5404 <tag/See also/Other tgi functions.
5410 <sect1>tgi_lineto<label id="tgi_lineto"><p>
5414 <tag/Function/Draw a line in the current drawing color from the graphics
5415 cursor to the new end point. The graphics cursor will be updated to x2/y2.
5416 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5417 <tag/Declaration/<tt/void __fastcall__ tgi_lineto (int x2, int y2);/
5418 <tag/Description/Draw a line in the current drawing color from the graphics
5419 cursor to the new end point. The graphics cursor will be updated to x2/y2.
5420 <tag/Limits/<itemize>
5421 <item>The function is only available as fastcall function, so it may only
5422 be used in presence of a prototype.
5424 <tag/Availability/cc65
5425 <tag/See also/Other tgi functions.
5431 <sect1>tgi_load<label id="tgi_load"><p>
5435 <tag/Function/Load and install the matching driver for the given mode.
5436 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5437 <tag/Declaration/<tt/void __fastcall__ tgi_load (unsigned char mode);/
5438 <tag/Description/Load and install the matching driver for the given mode.
5439 Will just load the driver and check if loading was successul.
5440 Will not switch to graphics mode.
5441 <tag/Limits/<itemize>
5442 <item>The function is only available as fastcall function, so it may only
5443 be used in presence of a prototype.
5445 <tag/Availability/cc65
5446 <tag/See also/Other tgi functions.
5452 <sect1>tgi_load_driver<label id="tgi_load_driver"><p>
5456 <tag/Function/Load and install the given driver. This function is identical
5457 to tgi_load with the only difference that the name of the driver is specified
5459 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5460 <tag/Declaration/<tt/void __fastcall__ tgi_load_driver (const char *name);/
5461 <tag/Description/Load and install the driver by name.
5462 Will just load the driver and check if loading was successul.
5463 Will not switch to graphics mode.
5464 <tag/Limits/<itemize>
5465 <item>The function is only available as fastcall function, so it may only
5466 be used in presence of a prototype.
5468 <tag/Availability/cc65
5469 <tag/See also/Other tgi functions.
5475 <sect1>tgi_outtext<label id="tgi_outtext"><p>
5479 <tag/Function/Output text at the current graphics cursor position.
5480 The graphics cursor is moved to the end of the text.
5481 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5482 <tag/Declaration/<tt/void __fastcall__ tgi_outtext (const char* s);/
5483 <tag/Description/Output text at the current graphics cursor position.
5484 The graphics cursor is moved to the end of the text.
5485 <tag/Limits/<itemize>
5486 <item>The function is only available as fastcall function, so it may only
5487 be used in presence of a prototype.
5489 <tag/Availability/cc65
5490 <tag/See also/Other tgi functions.
5496 <sect1>tgi_outtextxy<label id="tgi_outtextxy"><p>
5500 <tag/Function/Output text at the given cursor position.
5501 The graphics cursor is moved to the end of the text.
5502 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5503 <tag/Declaration/<tt/void __fastcall__ tgi_outtextxy (int x, int y, const char* s);/
5504 <tag/Description/Output text at the given cursor position.
5505 The graphics cursor is moved to the end of the text.
5506 <tag/Limits/<itemize>
5507 <item>The function is only available as fastcall function, so it may only
5508 be used in presence of a prototype.
5510 <tag/Availability/cc65
5511 <tag/See also/Other tgi functions.
5517 <sect1>tgi_pieslice<label id="tgi_pieslice"><p>
5521 <tag/Function/Draw an elliptic pie slice in the current color.
5522 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5523 <tag/Declaration/<tt/void __fastcall__ tgi_pie slice (int x, int y,
5524 unsigned char rx, unsigned char ry, unsigned sa, unsigned ea);/
5525 <tag/Description/The function draws an elliptic pie slice with center at x/y
5526 and radii rx/ry using the current drawing color. The pie slice covers the angle
5527 between sa and ea (startangle and endangle), which must be in the range
5529 <tag/Limits/<itemize>
5530 <item>The function is only available as fastcall function, so it may only
5531 be used in presence of a prototype.
5532 <item>The function behaves unexpectedly or may crash if the angles are out
5535 <tag/Availability/cc65
5537 <ref id="tgi_bar" name="tgi_arc">,
5538 <ref id="tgi_bar" name="tgi_bar">,
5539 <ref id="tgi_circle" name="tgi_circle">,
5540 <ref id="tgi_ellipse" name="tgi_ellipse">,
5541 <ref id="tgi_setcolor" name="tgi_setcolor">
5543 /* Draw the closed upper half of an ellipse */
5544 tgi_setcolor(TGI_COLOR_BLUE);
5545 tgi_pieslice (50, 50, 40, 20, 0, 180);
5551 <sect1>tgi_setcolor<label id="tgi_setcolor"><p>
5555 <tag/Function/Set color to be used in future draw operations.
5556 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5557 <tag/Declaration/<tt/void __fastcall__ tgi_setcolor (unsigned char color);/
5558 <tag/Description/Set color to be used in future draw operations.
5559 <tag/Limits/<itemize>
5560 <item>The function is only available as fastcall function, so it may only
5561 be used in presence of a prototype.
5563 <tag/Availability/cc65
5564 <tag/See also/Other tgi functions.
5566 tgi_setcolor(TGI_COLOR_BLACK);
5568 tgi_setcolor(TGI_COLOR_WHITE);
5569 tgi_bar(10,10,20,20);
5574 <sect1>tgi_setdrawpage<label id="tgi_setdrawpage"><p>
5578 <tag/Function/Set the page for drawing.
5579 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5580 <tag/Declaration/<tt/void __fastcall__ tgi_setdrawpage (unsigned char page);/
5581 <tag/Description/If the drawpage and the viewpage are the same then all drawing
5582 is seen immediately as it is drawn. For double buffered games you can set the
5583 drawpage to a different page than the viewpage. This lets you draw the next
5584 screen in the background and when the screen is ready you display it.
5585 <tag/Limits/<itemize>
5586 <item>The function is only available as fastcall function, so it may only
5587 be used in presence of a prototype.
5589 <tag/Availability/cc65
5590 <tag/See also/Other tgi functions.
5593 tgi_outtextxy(10, 10, "Hello World");
5594 tgi_setviewpage(1); // Show page 1
5596 tgi_outtextxy(10, 10, "Creating next frame");
5598 tgi_setviewpage(0); // Show page 0
5603 <sect1>tgi_setpalette<label id="tgi_setpalette"><p>
5607 <tag/Function/Set the palette (not available with all drivers/hardware).
5608 Palette is a pointer to as many entries as there are colors.
5609 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5610 <tag/Declaration/<tt/void __fastcall__ tgi_setpalette (const unsigned char* palette);/
5611 <tag/Description/Set the palette (not available with all drivers/hardware).
5612 Palette is a pointer to as many entries as there are colors.
5613 <tag/Limits/<itemize>
5614 <item>The function is only available as fastcall function, so it may only
5615 be used in presence of a prototype.
5617 <tag/Availability/cc65
5618 <tag/See also/Other tgi functions.
5623 <sect1>tgi_setpixel<label id="tgi_setpixel"><p>
5627 <tag/Function/Plot a pixel on the drawpage with the current color.
5628 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5629 <tag/Declaration/<tt/void __fastcall__ tgi_setpixel (int x, int y);/
5630 <tag/Description/Plot a pixel on the drawpage with the current color.
5631 <tag/Limits/<itemize>
5632 <item>The function is only available as fastcall function, so it may only
5633 be used in presence of a prototype.
5635 <tag/Availability/cc65
5636 <tag/See also/Other tgi functions.
5641 <sect1>tgi_setviewpage<label id="tgi_setviewpage"><p>
5645 <tag/Function/Set page to be visible on screen.
5646 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5647 <tag/Declaration/<tt/void __fastcall__ tgi_setviewpage (unsigned char page);/
5648 <tag/Description/If the drawpage and the viewpage are the same then all drawing
5649 is seen immediately as it is drawn. For double buffered games you can set the
5650 drawpage to a different page than the viewpage. This lets you draw the next
5651 screen in the background and when the screen is ready you display it.
5652 <tag/Limits/<itemize>
5653 <item>The function is only available as fastcall function, so it may only
5654 be used in presence of a prototype.
5656 <tag/Availability/cc65
5657 <tag/See also/Other tgi functions.
5660 tgi_outtextxy(10, 10, "Hello World");
5661 tgi_setviewpage(1); // Show page 1
5663 tgi_outtextxy(10, 10, "Creating next frame");
5665 tgi_setviewpage(0); // Show page 0
5670 <sect1>tgi_textheight<label id="tgi_textheight"><p>
5674 <tag/Function/Calculate the height of the text in pixels according to
5675 the current text style.
5676 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5677 <tag/Declaration/<tt/unsigned __fastcall__ tgi_textheight (const char* s);/
5678 <tag/Description/Calculate the height of the text in pixels according to
5679 the current text style.
5680 <tag/Limits/<itemize>
5681 <item>The function is only available as fastcall function, so it may only
5682 be used in presence of a prototype.
5684 <tag/Availability/cc65
5685 <tag/See also/Other tgi functions.
5690 <sect1>tgi_textstyle<label id="tgi_textstyle"><p>
5694 <tag/Function/Set the style for text output.
5695 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5696 <tag/Declaration/<tt/void __fastcall__ tgi_textstyle (unsigned char magx, unsigned char magy, unsigned char dir);/
5697 <tag/Description/Set the style for text output.
5698 <tag/Limits/<itemize>
5699 <item>The function is only available as fastcall function, so it may only
5700 be used in presence of a prototype.
5702 <tag/Availability/cc65
5703 <tag/See also/Other tgi functions.
5708 <sect1>tgi_textwidth<label id="tgi_textwidth"><p>
5712 <tag/Function/Calculate the width of the text in pixels according to the current text style.
5713 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5714 <tag/Declaration/<tt/unsigned __fastcall__ tgi_textwidth (const char* s);/
5715 <tag/Function/Calculate the width of the text in pixels according to the current text style.
5716 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5717 <tag/Description/Calculate the width of the text in pixels according to the current text style.
5718 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5719 <tag/Limits/<itemize>
5720 <item>The function is only available as fastcall function, so it may only
5721 be used in presence of a prototype.
5723 <tag/Availability/cc65
5724 <tag/See also/Other tgi functions.
5729 <sect1>tgi_uninstall<label id="tgi_uninstall"><p>
5733 <tag/Function/Uninstall the currently loaded driver but do not unload it.
5734 Will call tgi_done if necessary.
5735 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5736 <tag/Declaration/<tt/void __fastcall__ tgi_uninstall (void);/
5737 <tag/Description/Uninstall the currently loaded driver but do not unload it.
5738 Will call tgi_done if necessary.
5739 <tag/Limits/<itemize>
5740 <item>The function is only available as fastcall function, so it may only
5741 be used in presence of a prototype.
5743 <tag/Availability/cc65
5744 <tag/See also/Other tgi functions.
5749 <sect1>tgi_unload<label id="tgi_unload"><p>
5753 <tag/Function/Uninstall, then unload the currently loaded driver.
5754 Will call tgi_done if necessary.
5755 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5756 <tag/Declaration/<tt/void __fastcall__ tgi_unload (void);/
5757 <tag/Description/Uninstall, then unload the currently loaded driver.
5758 Will call tgi_done if necessary.
5759 <tag/Limits/<itemize>
5760 <item>The function is only available as fastcall function, so it may only
5761 be used in presence of a prototype.
5763 <tag/Availability/cc65
5764 <tag/See also/Other tgi functions.
5769 <sect1>time<label id="time"><p>
5773 <tag/Function/Get the time.
5774 <tag/Header/<tt/<ref id="time.h" name="time.h">/
5775 <tag/Declaration/<tt/time_t __fastcall__ time (time_t* t);/
5776 <tag/Description/The function returns the time since the 1970-01-01 00:00:00
5777 measured in seconds. If the pointer <tt/t/ is not <tt/NULL/, the function
5778 result will also be stored there. If no time is available, <tt/(time_t)-1/ is
5779 returned and <tt/errno/ is set to <tt/ENOSYS/.
5780 <tag/Limits/<itemize>
5781 <item>The function is only available as fastcall function, so it may
5782 only be used in presence of a prototype.
5783 <item>Many platforms supported by cc65 do not have a realtime clock, so the
5784 returned value may not be valid.
5786 <tag/Availability/ISO 9899
5792 <sect1>toggle_videomode<label id="toggle_videomode"><p>
5796 <tag/Function/Toggle between 40 and 80 column mode.
5797 <tag/Header/<tt/<ref id="c128.h" name="c128.h">/
5798 <tag/Declaration/<tt/void toggle_videomode (void);/
5799 <tag/Description/Toggle between 40 and 80 column mode. The settings for the
5800 old mode (cursor position, color and so on) are saved and restored together
5802 <tag/Limits/<itemize>
5803 <item>The function is specific to the C128.
5804 <item>This function is deprecated. Please use <ref id="videomode"
5805 name="videomode"> instead!
5807 <tag/Availability/C128
5809 <ref id="fast" name="fast">,
5810 <ref id="slow" name="slow">,
5811 <ref id="videomode" name="videomode">
5817 <sect1>tolower<label id="tolower"><p>
5821 <tag/Function/Convert a character into its lower case representation.
5822 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
5823 <tag/Declaration/<tt/int __fastcall__ tolower (int c);/
5824 <tag/Description/The function returns the given character converted to lower
5825 case. If the given character is not a letter, it is returned unchanged.
5826 <tag/Limits/<itemize>
5827 <item>The function is only available as fastcall function, so it may
5828 only be used in presence of a prototype.
5830 <tag/Availability/ISO 9899
5832 <ref id="islower" name="islower">,
5833 <ref id="isupper" name="isupper">,
5834 <ref id="toupper" name="toupper">
5840 <sect1>toupper<label id="toupper"><p>
5844 <tag/Function/Convert a character into its upper case representation.
5845 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
5846 <tag/Declaration/<tt/int __fastcall__ toupper (int c);/
5847 <tag/Description/The function returns the given character converted to upper
5848 case. If the given character is not a letter, it is returned unchanged.
5849 <tag/Limits/<itemize>
5850 <item>The function is only available as fastcall function, so it may
5851 only be used in presence of a prototype.
5853 <tag/Availability/ISO 9899
5855 <ref id="islower" name="islower">,
5856 <ref id="isupper" name="isupper">,
5857 <ref id="tolower" name="tolower">
5863 <sect1>ultoa<label id="ultoa"><p>
5867 <tag/Function/Convert an unsigned long integer into a string.
5868 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
5869 <tag/Declaration/<tt/char* __fastcall__ ultoa (unsigned long val, char* buf, int radix);/
5870 <tag/Description/<tt/itoa/ converts the unsigned long integer <tt/val/ into a
5871 string using <tt/radix/ as the base.
5872 <tag/Limits/<itemize>
5873 <item>There are no provisions to prevent a buffer overflow.
5874 <item>The function is non standard, so it is not available in strict ANSI mode.
5875 You should probably use <tt/sprintf/ instead.
5876 <item>The function is only available as fastcall function, so it may only be
5877 used in presence of a prototype.
5879 <tag/Availability/cc65
5881 <ref id="atoi" name="atoi">,
5882 <ref id="atol" name="atol">,
5883 <ref id="itoa" name="itoa">,
5884 <ref id="ltoa" name="ltoa">,
5885 <ref id="utoa" name="utoa">
5891 <sect1>unlink<label id="unlink"><p>
5895 <tag/Function/Delete a file.
5896 <tag/Header/<tt/<ref id="unistd.h" name="unistd.h">/
5897 <tag/Declaration/<tt/int __fastcall__ unlink (const char* name);/
5898 <tag/Description/<tt/unlink/ deletes the file with the given name. On success,
5899 zero is returned. On error, -1 is returned and <tt/errno/ is set to an error
5900 code describing the reason for the failure.
5903 <item>The use of this function is discouraged. Please use <tt/<ref id="remove"
5904 name="remove">/ instead, which is a native ANSI C function and does the same.
5905 <item>This function is not available on all cc65 targets (depends on the
5906 availability of file I/O).
5907 <item>The function is only available as fastcall function, so it may only
5908 be used in presence of a prototype.
5909 <item>Instead of <tt/unlink/, <tt/<ref id="remove" name="remove">/ should be
5910 used, which has the same semantics, but is more portable, because it conforms
5911 to the ISO C standard.
5913 <tag/Availability/POSIX 1003.1
5915 <ref id="remove" name="remove">
5918 #include <stdio.h>
5919 #include <unistd.h>
5921 #define FILENAME "helloworld"
5923 if (unlink (FILENAME) == 0) {
5924 printf ("We deleted %s successfully\n", FILENAME);
5926 printf ("There was a problem deleting %s\n", FILENAME);
5933 <sect1>utoa<label id="utoa"><p>
5937 <tag/Function/Convert an unsigned integer into a string.
5938 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
5939 <tag/Declaration/<tt/char* __fastcall__ utoa (unsigned val, char* buf, int radix);/
5940 <tag/Description/<tt/itoa/ converts the unsigned integer <tt/val/ into a string
5941 using <tt/radix/ as the base.
5942 <tag/Limits/<itemize>
5943 <item>There are no provisions to prevent a buffer overflow.
5944 <item>The function is non standard, so it is not available in strict ANSI mode.
5945 You should probably use <tt/sprintf/ instead.
5946 <item>The function is only available as fastcall function, so it may only be
5947 used in presence of a prototype.
5949 <tag/Availability/cc65
5951 <ref id="atoi" name="atoi">,
5952 <ref id="atol" name="atol">,
5953 <ref id="itoa" name="itoa">,
5954 <ref id="ltoa" name="ltoa">,
5955 <ref id="ultoa" name="ultoa">
5961 <sect1>vcprintf<label id="vcprintf"><p>
5965 <tag/Function/Formatted output to the console.
5966 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
5967 <tag/Declaration/<tt/int __fastcall__ vcprintf (const char* format, va_list ap);/
5968 <tag/Description/The arguments specified as a <tt/va_list/ are converted to
5969 text where necessary and formatted according to the format string given. The
5970 resulting string is output to the console. <tt/vcprintf/ supports the same
5971 format specifiers as <tt/vprintf/. <!-- <tt/<ref id="vprintf" name="vprintf">/. -->
5972 <tag/Limits/<itemize>
5973 <item>Like all other <tt/conio/ output functions, <tt/vcprintf/ distinguishes
5974 between <tt/\r/ and <tt/\n/.
5975 <item>The function is only available as fastcall function, so it may only be
5976 used in presence of a prototype.
5978 <tag/Availability/cc65
5980 <ref id="cprintf" name="cprintf">,
5981 <ref id="cputc" name="cputc">,
5982 <ref id="cputcxy" name="cputcxy">,
5983 <ref id="cputs" name="cputs">,
5984 <ref id="cputsxy" name="cputsxy">
5990 <sect1>videomode<label id="videomode"><p>
5994 <tag/Function/Switch to either 40 or 80 column mode.
5995 <tag/Header/<tt/<ref id="apple2enh.h" name="apple2enh.h">,
5996 <ref id="c128.h" name="c128.h">/
5997 <tag/Declaration/<tt/unsigned __fastcall__ videomode (unsigned Mode);/
5998 <tag/Description/Switch to 40 or 80 column mode depending on the argument. If
5999 the requested mode is already active, nothing happens. The old mode is returned
6001 <tag/Limits/<itemize>
6002 <item>The function is specific to the C128 and enhanced Apple //e.
6003 <item>This function replaces <ref id="toggle_videomode"
6004 name="toggle_videomode">.
6005 <item>The function is only available as fastcall function, so it may only be
6006 used in presence of a prototype.
6008 <tag/Availability/C128 and enhanced Apple //e
6010 <ref id="fast" name="fast">,
6011 <ref id="slow" name="slow">,
6012 <ref id="toggle_videomode" name="toggle_videomode">
6018 <sect1>wherex<label id="wherex"><p>
6022 <tag/Function/Return the current X position of the text mode cursor.
6023 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
6024 <tag/Declaration/<tt/unsigned char wherex (void);/
6025 <tag/Description/The function returns the current X position of the text mode
6026 cursor. Zero is returned for the leftmost screen position.
6027 <tag/Availability/cc65
6029 <ref id="gotox" name="gotox">,
6030 <ref id="gotoy" name="gotoy">,
6031 <ref id="gotoxy" name="gotoxy">,
6032 <ref id="wherey" name="wherey">
6038 <sect1>wherey<label id="wherey"><p>
6042 <tag/Function/Return the current Y position of the text mode cursor.
6043 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
6044 <tag/Declaration/<tt/unsigned char wherey (void);/
6045 <tag/Description/The function returns the current Y position of the text mode
6046 cursor. Zero is returned for the uppermost screen position.
6047 <tag/Availability/cc65
6049 <ref id="gotox" name="gotox">,
6050 <ref id="gotoy" name="gotoy">,
6051 <ref id="gotoxy" name="gotoxy">,
6052 <ref id="wherex" name="wherex">