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="reset_irq" name="reset_irq">
62 <item><ref id="set_brk" name="set_brk">
63 <item><ref id="set_irq" name="set_irq">
67 <sect1><tt/apple2.h/<label id="apple2.h"><p>
71 <item><ref id="get_ostype" name="get_ostype">
76 <sect1><tt/apple2enh.h/<label id="apple2enh.h"><p>
80 <item><ref id="get_ostype" name="get_ostype">
84 <item><ref id="videomode" name="videomode">
88 <sect1><tt/assert.h/<label id="assert.h"><p>
91 <item><ref id="assert" name="assert">
95 <sect1><tt/atari.h/<label id="atari.h"><p>
98 <!-- <item><ref id="_getcolor" name="_getcolor"> -->
99 <!-- <item><ref id="_getdefdev" name="_getdefdev"> -->
100 <!-- <item><ref id="_graphics" name="_graphics"> -->
101 <!-- <item><ref id="_rest_vecs" name="_rest_vecs"> -->
102 <!-- <item><ref id="_save_vecs" name="_save_vecs"> -->
103 <!-- <item><ref id="_scroll" name="_scroll"> -->
104 <!-- <item><ref id="_setcolor" name="_setcolor"> -->
105 <!-- <item><ref id="_setcolor_low" name="_setcolor_low"> -->
106 <item><ref id="get_ostype" name="get_ostype">
107 <!-- <item><ref id="get_tv" name="get_tv"> -->
113 <sect1><tt/atmos.h/<label id="atmos.h"><p>
116 <item><ref id="atmos_load" name="atmos_load">
117 <item><ref id="atmos_save" name="atmos_save">
121 <sect1><tt/c128.h/<label id="c128.h"><p>
124 <item><ref id="c64mode" name="c64mode">
125 <item><ref id="fast" name="fast">
126 <item><ref id="slow" name="slow">
127 <item><ref id="toggle_videomode" name="toggle_videomode">
128 <item><ref id="videomode" name="videomode">
132 <sect1><tt/c16.h/<label id="c16.h"><p>
137 <sect1><tt/c64.h/<label id="c64.h"><p>
140 <item><ref id="get_ostype" name="get_ostype">
144 <sect1><tt/cbm.h/<label id="cbm.h"><p>
147 <!-- <item><ref id="cbm_clall" name="cbm_clall"> -->
148 <!-- <item><ref id="cbm_close" name="cbm_close"> -->
149 <!-- <item><ref id="cbm_closedir" name="cbm_closedir"> -->
150 <!-- <item><ref id="cbm_k_basin" name="cbm_k_basin"> -->
151 <!-- <item><ref id="cbm_k_bsout" name="cbm_k_bsout"> -->
152 <!-- <item><ref id="cbm_k_chkin" name="cbm_k_chkin"> -->
153 <!-- <item><ref id="cbm_k_ckout" name="cbm_k_ckout"> -->
154 <!-- <item><ref id="cbm_k_close" name="cbm_k_close"> -->
155 <!-- <item><ref id="cbm_k_clrch" name="cbm_k_clrch"> -->
156 <!-- <item><ref id="cbm_k_getin" name="cbm_k_getin"> -->
157 <!-- <item><ref id="cbm_k_load" name="cbm_k_load"> -->
158 <!-- <item><ref id="cbm_k_open" name="cbm_k_open"> -->
159 <!-- <item><ref id="cbm_k_readst" name="cbm_k_readst"> -->
160 <!-- <item><ref id="cbm_k_save" name="cbm_k_save"> -->
161 <!-- <item><ref id="cbm_k_setlfs" name="cbm_k_setlfs"> -->
162 <!-- <item><ref id="cbm_k_setnam" name="cbm_k_setnam"> -->
163 <!-- <item><ref id="cbm_load" name="cbm_load"> -->
164 <!-- <item><ref id="cbm_open" name="cbm_open"> -->
165 <!-- <item><ref id="cbm_opendir" name="cbm_opendir"> -->
166 <!-- <item><ref id="cbm_read" name="cbm_read"> -->
167 <!-- <item><ref id="cbm_readdir" name="cbm_readdir"> -->
168 <!-- <item><ref id="cbm_save" name="cbm_save"> -->
169 <!-- <item><ref id="cbm_write" name="cbm_write"> -->
175 <sect1><tt/cbm510.h/<label id="cbm510.h"><p>
178 <item><ref id="peekbsys" name="peekbsys">
179 <item><ref id="peekwsys" name="peekwsys">
180 <item><ref id="pokebsys" name="pokebsys">
181 <item><ref id="pokewsys" name="pokewsys">
185 <sect1><tt/cbm610.h/<label id="cbm610.h"><p>
188 <item><ref id="peekbsys" name="peekbsys">
189 <item><ref id="peekwsys" name="peekwsys">
190 <item><ref id="pokebsys" name="pokebsys">
191 <item><ref id="pokewsys" name="pokewsys">
195 <sect1><tt/cc65.h/<label id="cc65.h"><p>
198 <!-- <item><ref id="cc65_cos" name="cc65_cos"> -->
199 <!-- <item><ref id="cc65_idiv32by16r16" name="cc65_idiv32by16r16"> -->
200 <!-- <item><ref id="cc65_imul16x16r32" name="cc65_imul16x16r32"> -->
201 <!-- <item><ref id="cc65_imul8x8r16" name="cc65_imul8x8r16"> -->
202 <!-- <item><ref id="cc65_sin" name="cc65_sin"> -->
203 <!-- <item><ref id="cc65_udiv32by16r16" name="cc65_udiv32by16r16"> -->
204 <!-- <item><ref id="cc65_umul16x16r32" name="cc65_umul16x16r32"> -->
205 <!-- <item><ref id="cc65_umul16x8r32" name="cc65_umul16x8r32"> -->
206 <!-- <item><ref id="cc65_umul8x8r16" name="cc65_umul8x8r16"> -->
212 <sect1><tt/conio.h/<label id="conio.h"><p>
215 <item><ref id="bgcolor" name="bgcolor">
216 <item><ref id="bordercolor" name="bordercolor">
217 <item><ref id="cclear" name="cclear">
218 <item><ref id="cclearxy" name="cclearxy">
219 <item><ref id="cgetc" name="cgetc">
220 <item><ref id="chline" name="chline">
221 <item><ref id="chlinexy" name="chlinexy">
222 <item><ref id="clrscr" name="clrscr">
223 <item><ref id="cprintf" name="cprintf">
224 <item><ref id="cputc" name="cputc">
225 <item><ref id="cputcxy" name="cputcxy">
226 <item><ref id="cputs" name="cputs">
227 <item><ref id="cputsxy" name="cputsxy">
228 <item><ref id="cursor" name="cursor">
229 <item><ref id="cvline" name="cvline">
230 <item><ref id="cvlinexy" name="cvlinexy">
231 <item><ref id="gotox" name="gotox">
232 <item><ref id="gotoxy" name="gotoxy">
233 <item><ref id="gotoy" name="gotoy">
234 <item><ref id="kbhit" name="kbhit">
235 <item><ref id="revers" name="revers">
236 <item><ref id="screensize" name="screensize">
237 <item><ref id="textcolor" name="textcolor">
238 <item><ref id="vcprintf" name="vcprintf">
239 <item><ref id="wherex" name="wherex">
240 <item><ref id="wherey" name="wherey">
244 <sect1><tt/ctype.h/<label id="ctype.h"><p>
247 <item><ref id="isalnum" name="isalnum">
248 <item><ref id="isalpha" name="isalpha">
249 <item><ref id="isascii" name="isascii">
250 <item><ref id="isblank" name="isblank">
251 <item><ref id="iscntrl" name="iscntrl">
252 <item><ref id="isdigit" name="isdigit">
253 <item><ref id="isgraph" name="isgraph">
254 <item><ref id="islower" name="islower">
255 <item><ref id="isprint" name="isprint">
256 <item><ref id="ispunct" name="ispunct">
257 <item><ref id="isspace" name="isspace">
258 <item><ref id="isupper" name="isupper">
259 <item><ref id="isxdigit" name="isxdigit">
260 <item><ref id="tolower" name="tolower">
261 <item><ref id="toupper" name="toupper">
265 <sect1><tt/dbg.h/<label id="dbg.h"><p>
268 <!-- <item><ref id="DbgInit" name="DbgInit"> -->
274 <sect1><tt/dio.h/<label id="dio.h"><p>
276 <htmlurl url="dio.html" name="dio.html">
277 Low-level disk I/O API.
280 <sect1><tt/dirent.h/<label id="dirent.h"><p>
283 <item><ref id="closedir" name="closedir">
284 <item><ref id="opendir" name="opendir">
285 <item><ref id="readdir" name="readdir">
286 <item><ref id="rewinddir" name="rewinddir">
287 <item><ref id="seekdir" name="seekdir">
288 <item><ref id="telldir" name="telldir">
294 <sect1><tt/em.h/<label id="em.h"><p>
297 <item><ref id="em_commit" name="em_commit">
298 <item><ref id="em_copyfrom" name="em_copyfrom">
299 <item><ref id="em_copyto" name="em_copyto">
300 <item><ref id="em_install" name="em_install">
301 <item><ref id="em_load_driver" name="em_load_driver">
302 <item><ref id="em_map" name="em_map">
303 <item><ref id="em_pagecount" name="em_pagecount">
304 <item><ref id="em_uninstall" name="em_uninstall">
305 <item><ref id="em_unload" name="em_unload">
306 <item><ref id="em_use" name="em_use">
310 <sect1><tt/errno.h/<label id="errno.h"><p>
313 <!-- <item><ref id="_directerrno" name="_directerrno"> -->
314 <!-- <item><ref id="_mappederrno" name="_mappederrno"> -->
315 <!-- <item><ref id="_osmaperrno" name="_osmaperrno"> -->
316 <!-- <item><ref id="_seterrno" name="_seterrno"> -->
322 <sect1><tt/fcntl.h/<label id="fcntl.h"><p>
325 <item><ref id="close" name="close">
326 <item><ref id="creat" name="creat">
327 <item><ref id="open" name="open">
331 <sect1><tt/geos.h/<label id="geos.h"><p>
336 <sect1><tt/joystick.h/<label id="joystick.h"><p>
339 <item><ref id="joy_count" name="joy_count">
340 <item><ref id="joy_install" name="joy_install">
341 <item><ref id="joy_load_driver" name="joy_load_driver">
342 <item><ref id="joy_read" name="joy_read">
343 <item><ref id="joy_uninstall" name="joy_uninstall">
344 <item><ref id="joy_unload" name="joy_unload">
348 <sect1><tt/locale.h/<label id="locale.h"><p>
351 <item><ref id="localeconv" name="localeconv">
352 <item><ref id="setlocale" name="setlocale">
356 <sect1><tt/lynx.h/<label id="lynx.h"><p>
359 <!-- <item><ref id="lynx_eeprom_erase" name="lynx_eeprom_erase"> -->
360 <!-- <item><ref id="lynx_eeprom_read" name="lynx_eeprom_read"> -->
361 <!-- <item><ref id="lynx_eeprom_write" name="lynx_eeprom_write"> -->
362 <!-- <item><ref id="lynx_eeread" name="lynx_eeread"> -->
363 <!-- <item><ref id="lynx_eewrite" name="lynx_eewrite"> -->
364 <!-- <item><ref id="lynx_exec" name="lynx_exec"> -->
365 <!-- <item><ref id="lynx_load" name="lynx_load"> -->
371 <sect1><tt/modload.h/<label id="modload.h"><p>
374 <item><ref id="mod_load" name="mod_load">
375 <item><ref id="mod_free" name="mod_free">
379 <sect1><tt/mouse.h/<label id="mouse.h"><p>
382 <item><ref id="mouse_buttons" name="mouse_buttons">
383 <item><ref id="mouse_getbox" name="mouse_getbox">
384 <item><ref id="mouse_geterrormsg" name="mouse_geterrormsg">
385 <item><ref id="mouse_hide" name="mouse_hide">
386 <item><ref id="mouse_info" name="mouse_info">
387 <item><ref id="mouse_install" name="mouse_install">
388 <item><ref id="mouse_ioctl" name="mouse_ioctl">
389 <item><ref id="mouse_load_driver" name="mouse_load_driver">
390 <item><ref id="mouse_move" name="mouse_move">
391 <item><ref id="mouse_pos" name="mouse_pos">
392 <item><ref id="mouse_setbox" name="mouse_setbox">
393 <item><ref id="mouse_show" name="mouse_show">
394 <item><ref id="mouse_uninstall" name="mouse_uninstall">
395 <item><ref id="mouse_unload" name="mouse_unload">
399 <sect1><tt/nes.h/<label id="nes.h"><p>
402 <!-- <item><ref id="get_tv" name="get_tv"> -->
403 <!-- <item><ref id="waitvblank" name="waitvblank"> -->
409 <sect1><tt/o65.h/<label id="o65.h"><p>
411 The <tt/o65.h/ header file contains structure and constant definitions that
412 may be used when dealing with files in <htmlurl
413 url="http://www.6502.org/users/andre/o65/fileformat.html" name="o65 format">.
414 It does not declare any functions.
417 <sect1><tt/peekpoke.h/<label id="peekpoke.h"><p>
420 <item><ref id="PEEK" name="PEEK">
421 <item><ref id="PEEKW" name="PEEKW">
422 <item><ref id="POKE" name="POKE">
423 <item><ref id="POKEW" name="POKEW">
427 <sect1><tt/pet.h/<label id="pet.h"><p>
432 <sect1><tt/plus4.h/<label id="plus4.h"><p>
437 <sect1><tt/serial.h/<label id="serial.h"><p>
439 The <tt/serial.h/ header file contains definitions for initializing serial
443 <item><ref id="ser_close" name="ser_close">
444 <item><ref id="ser_get" name="ser_get">
445 <item><ref id="ser_install" name="ser_install">
446 <item><ref id="ser_ioctl" name="ser_ioctl">
447 <item><ref id="ser_load_driver" name="ser_load_driver">
448 <item><ref id="ser_open" name="ser_open">
449 <item><ref id="ser_put" name="ser_put">
450 <item><ref id="ser_status" name="ser_status">
451 <item><ref id="ser_uninstall" name="ser_uninstall">
452 <item><ref id="ser_unload" name="ser_unload">
456 <sect1><tt/setjmp.h/<label id="setjmp.h"><p>
459 <item><ref id="setjmp" name="setjmp">
460 <item><ref id="longjmp" name="longjmp">
464 <sect1><tt/signal.h/<label id="signal.h"><p>
467 <item><ref id="raise" name="raise">
468 <item><ref id="signal" name="signal">
472 <sect1><tt/stdarg.h/<label id="stdarg.h"><p>
477 <sect1><tt/stdbool.h/<label id="stdbool.h"><p>
482 <sect1><tt/stddef.h/<label id="stddef.h"><p>
485 <item><ref id="offsetof" name="offsetof">
489 <sect1><tt/stdio.h/<label id="stdio.h"><p>
492 <item><ref id="_poserror" name="_poserror">
493 <item><ref id="clearerr" name="clearerr">
494 <!-- <item><ref id="fclose" name="fclose"> -->
495 <!-- <item><ref id="fdopen" name="fdopen"> -->
496 <item><ref id="feof" name="feof">
497 <item><ref id="ferror" name="ferror">
498 <!-- <item><ref id="fflush" name="fflush"> -->
499 <!-- <item><ref id="fgetc" name="fgetc"> -->
500 <!-- <item><ref id="fgetpos" name="fgetpos"> -->
501 <!-- <item><ref id="fgets" name="fgets"> -->
502 <item><ref id="fileno" name="fileno">
503 <!-- <item><ref id="fopen" name="fopen"> -->
504 <!-- <item><ref id="fprintf" name="fprintf"> -->
505 <!-- <item><ref id="fputc" name="fputc"> -->
506 <!-- <item><ref id="fputs" name="fputs"> -->
507 <!-- <item><ref id="fread" name="fread"> -->
508 <!-- <item><ref id="freopen" name="freopen"> -->
509 <!-- <item><ref id="fscanf" name="fscanf"> -->
510 <!-- <item><ref id="fseek" name="fseek"> -->
511 <!-- <item><ref id="fsetpos" name="fsetpos"> -->
512 <!-- <item><ref id="ftell" name="ftell"> -->
513 <!-- <item><ref id="fwrite" name="fwrite"> -->
514 <!-- <item><ref id="getc" name="getc"> -->
515 <!-- <item><ref id="getchar" name="getchar"> -->
516 <!-- <item><ref id="gets" name="gets"> -->
517 <!-- <item><ref id="printf" name="printf"> -->
518 <!-- <item><ref id="putc" name="putc"> -->
519 <!-- <item><ref id="putchar" name="putchar"> -->
520 <!-- <item><ref id="puts" name="puts"> -->
521 <item><ref id="rename" name="rename">
522 <item><ref id="remove" name="remove">
523 <!-- <item><ref id="rewind" name="rewind"> -->
524 <!-- <item><ref id="scanf" name="scanf"> -->
525 <!-- <item><ref id="snprintf" name="snprintf"> -->
526 <!-- <item><ref id="sprintf" name="sprintf"> -->
527 <!-- <item><ref id="sscanf" name="sscanf"> -->
528 <!-- <item><ref id="vfprintf" name="vfprintf"> -->
529 <!-- <item><ref id="vfscanf" name="vfscanf"> -->
530 <!-- <item><ref id="vprintf" name="vprintf"> -->
531 <!-- <item><ref id="vscanf" name="vscanf"> -->
532 <!-- <item><ref id="vsnprintf" name="vsnprintf"> -->
533 <!-- <item><ref id="vsprintf" name="vsprintf"> -->
534 <!-- <item><ref id="vsscanf" name="vsscanf"> -->
540 <sect1><tt/stdlib.h/<label id="stdlib.h"><p>
543 <item><ref id="_heapadd" name="_heapadd">
544 <item><ref id="_heapblocksize" name="_heapblocksize">
545 <item><ref id="_heapmaxavail" name="_heapmaxavail">
546 <item><ref id="_heapmemavail" name="_heapmemavail">
547 <item><ref id="_randomize" name="_randomize">
548 <item><ref id="_swap" name="_swap">
549 <item><ref id="abort" name="abort">
550 <item><ref id="abs" name="abs">
551 <item><ref id="atexit" name="atexit">
552 <item><ref id="atoi" name="atoi">
553 <item><ref id="atol" name="atol">
554 <item><ref id="bsearch" name="bsearch">
555 <item><ref id="calloc" name="calloc">
556 <item><ref id="div" name="div">
557 <item><ref id="exit" name="exit">
558 <item><ref id="free" name="free">
559 <item><ref id="getenv" name="getenv">
560 <item><ref id="itoa" name="itoa">
561 <item><ref id="labs" name="labs">
562 <item><ref id="ltoa" name="ltoa">
563 <item><ref id="malloc" name="malloc">
564 <item><ref id="perror" name="perror">
565 <!-- <item><ref id="posix_memalign" name="posix_memalign"> -->
566 <!-- <item><ref id="putenv" name="putenv"> -->
567 <item><ref id="qsort" name="qsort">
568 <item><ref id="rand" name="rand">
569 <item><ref id="realloc" name="realloc">
570 <item><ref id="srand" name="srand">
571 <!-- <item><ref id="system" name="system"> -->
572 <item><ref id="ultoa" name="ultoa">
573 <item><ref id="utoa" name="utoa">
579 <sect1><tt/string.h/<label id="string.h"><p>
582 <item><ref id="_stroserror" name="_stroserror">
583 <item><ref id="bzero" name="bzero">
584 <item><ref id="memchr" name="memchr">
585 <item><ref id="memcmp" name="memcmp">
586 <item><ref id="memcpy" name="memcpy">
587 <item><ref id="memmove" name="memmove">
588 <item><ref id="memset" name="memset">
589 <item><ref id="strcasecmp" name="strcasecmp">
590 <item><ref id="strcat" name="strcat">
591 <item><ref id="strchr" name="strchr">
592 <item><ref id="strcmp" name="strcmp">
593 <item><ref id="strcoll" name="strcoll">
594 <item><ref id="strcpy" name="strcpy">
595 <item><ref id="strcspn" name="strcspn">
596 <item><ref id="strdup" name="strdup">
597 <item><ref id="strerror" name="strerror">
598 <item><ref id="stricmp" name="stricmp">
599 <item><ref id="strlen" name="strlen">
600 <item><ref id="strlower" name="strlower">
601 <item><ref id="strlwr" name="strlwr">
602 <item><ref id="strncat" name="strncat">
603 <item><ref id="strncmp" name="strncmp">
604 <item><ref id="strncpy" name="strncpy">
605 <item><ref id="strrchr" name="strrchr">
606 <item><ref id="strspn" name="strspn">
607 <item><ref id="strstr" name="strstr">
608 <item><ref id="strtok" name="strtok">
609 <item><ref id="strxfrm" name="strxfrm">
610 <item><ref id="strupper" name="strupper">
611 <item><ref id="strupr" name="strupr">
617 <sect1><tt/tgi.h/<label id="tgi.h"><p>
620 <item><ref id="tgi_arc" name="tgi_arc">
621 <item><ref id="tgi_bar" name="tgi_bar">
622 <item><ref id="tgi_circle" name="tgi_circle">
623 <item><ref id="tgi_clear" name="tgi_clear">
624 <item><ref id="tgi_done" name="tgi_done">
625 <item><ref id="tgi_ellipse" name="tgi_ellipse">
626 <item><ref id="tgi_getaspectratio" name="tgi_getaspectratio">
627 <item><ref id="tgi_getcolor" name="tgi_getcolor">
628 <item><ref id="tgi_getcolorcount" name="tgi_getcolorcount">
629 <item><ref id="tgi_getdefpalette" name="tgi_getdefpalette">
630 <item><ref id="tgi_geterror" name="tgi_geterror">
631 <item><ref id="tgi_geterrormsg" name="tgi_geterrormsg">
632 <item><ref id="tgi_getmaxcolor" name="tgi_getmaxcolor">
633 <item><ref id="tgi_getmaxx" name="tgi_getmaxx">
634 <item><ref id="tgi_getmaxy" name="tgi_getmaxy">
635 <item><ref id="tgi_getpagecount" name="tgi_getpagecount">
636 <item><ref id="tgi_getpalette" name="tgi_getpalette">
637 <item><ref id="tgi_getpixel" name="tgi_getpixel">
638 <item><ref id="tgi_getxres" name="tgi_getxres">
639 <item><ref id="tgi_getyres" name="tgi_getyres">
640 <item><ref id="tgi_gotoxy" name="tgi_gotoxy">
641 <item><ref id="tgi_init" name="tgi_init">
642 <item><ref id="tgi_install" name="tgi_install">
643 <item><ref id="tgi_ioctl" name="tgi_ioctl">
644 <item><ref id="tgi_line" name="tgi_line">
645 <item><ref id="tgi_lineto" name="tgi_lineto">
646 <item><ref id="tgi_load_driver" name="tgi_load_driver">
647 <item><ref id="tgi_outtext" name="tgi_outtext">
648 <item><ref id="tgi_outtextxy" name="tgi_outtextxy">
649 <item><ref id="tgi_setaspectratio" name="tgi_setaspectratio">
650 <item><ref id="tgi_setcolor" name="tgi_setcolor">
651 <item><ref id="tgi_setdrawpage" name="tgi_setdrawpage">
652 <item><ref id="tgi_setpalette" name="tgi_setpalette">
653 <item><ref id="tgi_setpixel" name="tgi_setpixel">
654 <item><ref id="tgi_setviewpage" name="tgi_setviewpage">
655 <item><ref id="tgi_gettextheight" name="tgi_gettextheight">
656 <item><ref id="tgi_settextstyle" name="tgi_settextstyle">
657 <item><ref id="tgi_gettextwidth" name="tgi_gettextwidth">
658 <item><ref id="tgi_uninstall" name="tgi_uninstall">
659 <item><ref id="tgi_unload" name="tgi_unload">
662 <sect1><tt/time.h/<label id="time.h"><p>
665 <!-- <item><ref id="_systime" name="_systime"> -->
666 <!-- <item><ref id="asctime" name="asctime"> -->
667 <item><ref id="clock" name="clock">
668 <!-- <item><ref id="ctime" name="ctime"> -->
669 <!-- <item><ref id="gmtime" name="gmtime"> -->
670 <!-- <item><ref id="localtime" name="localtime"> -->
671 <!-- <item><ref id="mktime" name="mktime"> -->
672 <!-- <item><ref id="strftime" name="strftime"> -->
673 <item><ref id="time" name="time">
679 <sect1><tt/unistd.h/<label id="unistd.h"><p>
682 <!-- <item><ref id="chdir" name="chdir"> -->
683 <item><ref id="exec" name="exec">
684 <!-- <item><ref id="getcwd" name="getcwd"> -->
685 <item><ref id="getopt" name="getopt">
686 <!-- <item><ref id="lseek" name="lseek"> -->
687 <!-- <item><ref id="mkdir" name="mkdir"> -->
688 <!-- <item><ref id="read" name="read"> -->
689 <!-- <item><ref id="rmdir" name="rmdir"> -->
690 <item><ref id="sleep" name="sleep">
691 <item><ref id="unlink" name="unlink">
692 <!-- <item><ref id="write" name="write"> -->
698 <sect1><tt/vic20.h/<label id="vic20.h"><p>
703 <sect1><tt/zlib.h/<label id="zlib.h"><p>
706 <!-- <item><ref id="adler32" name="adler32"> -->
707 <!-- <item><ref id="crc32" name="crc32"> -->
708 <!-- <item><ref id="inflatemem" name="inflatemem"> -->
709 <!-- <item><ref id="uncompress" name="uncompress"> -->
715 <sect>Alphabetical function reference<p>
717 <sect1>_heapadd<label id="_heapadd"><p>
721 <tag/Function/Add a block to the heap.
722 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
723 <tag/Declaration/<tt/void __fastcall__ _heapadd (void* mem, size_t size);/
724 <tag/Description/The function adds a block of raw memory to the heap.
727 <item>The minimum blocksize that can be added is 6 bytes; the function will
728 ignore smaller blocks.
730 <tag/Availability/cc65
732 <ref id="_heapblocksize" name="_heapblocksize">,
733 <ref id="_heapmaxavail" name="_heapmaxavail">,
734 <ref id="_heapmemavail" name="_heapmemavail">,
735 <ref id="calloc" name="calloc">,
736 <ref id="free" name="free">,
737 <ref id="malloc" name="malloc">,
738 <ref id="realloc" name="realloc">
744 <sect1>_heapblocksize<label id="_heapblocksize"><p>
748 <tag/Function/Return the size of an allocated block.
749 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
750 <tag/Declaration/<tt/size_t __fastcall__ _heapblocksize (const void* block);/
751 <tag/Description/The function returns the size of a block that must have
752 previously been allocated by <tt/<ref id="malloc" name="malloc">/, <tt/<ref
753 id="calloc" name="calloc">/ or <tt/<ref id="realloc" name="realloc">/.
756 <item>Passing a pointer to a block that was is not the result of one of the
757 allocation functions, or that has been free'd will give unpredicable results.
759 <tag/Availability/cc65
761 <ref id="_heapadd" name="_heapadd">,
762 <ref id="_heapmaxavail" name="_heapmaxavail">,
763 <ref id="_heapmemavail" name="_heapmemavail">,
764 <ref id="calloc" name="calloc">,
765 <ref id="free" name="free">,
766 <ref id="malloc" name="malloc">,
767 <ref id="realloc" name="realloc">
773 <sect1>_heapmaxavail<label id="_heapmaxavail"><p>
777 <tag/Function/Return the largest block that is available on the heap.
778 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
779 <tag/Declaration/<tt/size_t _heapmaxavail (void);/
780 <tag/Description/The function returns the size of the largest block that may
781 be allocated from the heap using <tt/<ref id="malloc" name="malloc">/.
782 <tag/Availability/cc65
784 <ref id="_heapadd" name="_heapadd">,
785 <ref id="_heapblocksize" name="_heapblocksize">,
786 <ref id="_heapmemavail" name="_heapmemavail">,
787 <ref id="calloc" name="calloc">,
788 <ref id="free" name="free">,
789 <ref id="malloc" name="malloc">,
790 <ref id="realloc" name="realloc">
796 <sect1>_heapmemavail<label id="_heapmemavail"><p>
800 <tag/Function/Return the total available space on the heap.
801 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
802 <tag/Declaration/<tt/size_t __fastcall__ _heapmemavail (void);/
803 <tag/Description/The function returns the total number of bytes available on
807 <item>This function is of less use than usually assumed, since the returned
808 heap space may be available but not in one block. So even if this function
809 says that several times more heap space is available than needed, <ref
810 id="malloc" name="malloc"> may still return <tt/NULL/.
812 <tag/Availability/cc65
814 <ref id="_heapadd" name="_heapadd">,
815 <ref id="_heapblocksize" name="_heapblocksize">,
816 <ref id="_heapmaxavail" name="_heapmaxavail">,
817 <ref id="calloc" name="calloc">,
818 <ref id="free" name="free">,
819 <ref id="malloc" name="malloc">,
820 <ref id="realloc" name="realloc">
826 <sect1>_poserror<label id="_poserror"><p>
830 <tag/Function/Print an error message for the error in <tt/_oserror/.
831 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
832 <tag/Declaration/<tt/void __fastcall__ _poserror (const char* msg);/
833 <tag/Description/<tt/_poserror/ prints an error message to <tt/stderr/. If
834 <tt/msg/ is not <tt/NULL/ and not an empty string, it is printed followed by
835 a colon and a blank. Then the error message for the current contents of
836 <tt/_oserror/ are printed followed by a newline. The message output is the
837 same as returned by <tt/<ref id="_stroserror" name="_stroserror">/ with an
838 argument of <tt/_oserror/.
841 <item>Since operating system specific error code are - you guessed it -
842 operating system specific, the value in <tt/_oserror/ and the message that is
843 printed depends on the cc65 target.
844 <item>The function is only available as fastcall function, so it may only
845 be used in presence of a prototype.
847 <tag/Availability/cc65
849 <ref id="_stroserror" name="_stroserror">,
850 <ref id="perror" name="perror">
856 <sect1>_randomize<label id="_randomize"><p>
860 <tag/Function/Initialize the pseudo random number generator.
861 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
862 <tag/Declaration/<tt/void _randomize (void);/
863 <tag/Description/The function initializes the random number generator with
864 a seed derived from fast changing hardware events, so the seed itself can be
865 considered random to a certain degree.
866 <tag/Limits/<itemize>
867 <item>The randomness of the seed depends on the machine hardware.
869 <tag/Availability/cc65
871 <ref id="rand" name="rand">,
872 <ref id="srand" name="srand">
878 <sect1>_stroserror<label id="_stroserror"><p>
882 <tag/Function/Return a string describing an OS specific error code.
883 <tag/Header/<tt/<ref id="string.h" name="string.h">/
884 <tag/Declaration/<tt/const char* __fastcall__ _stroserror (unsigned char errcode);/
885 <tag/Description/<tt/_stroserror/ will return a string describing the given
886 operating system specific error code.
887 <tag/Limits/<itemize>
888 <item>Since operating system specific error code are - you guessed it -
889 operating system specific, the parameter and the string returned depend on the
891 <item>The function is only available as fastcall function, so it may only be
892 used in presence of a prototype.
894 <tag/Availability/cc65
896 <ref id="strerror" name="strerror">
902 <sect1>_swap<label id="_swap"><p>
906 <tag/Function/Swap the contents of memory areas.
907 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
908 <tag/Declaration/<tt/void __fastcall__ _swap (void* p, void* q, size_t size);/
909 <tag/Description/<tt/_swap/ will swap (exchange) the contents of the two memory
910 areas pointed to by <tt/p/ and <tt/q/. Both memory areas are assumed to be
911 <tt/size/ bytes in size.
912 <tag/Limits/<itemize>
913 <item>The memory areas may not overlap, otherwise the results are undefined.
914 <item>The function is only available as fastcall function, so it may only be
915 used in presence of a prototype.
917 <tag/Availability/cc65
919 <ref id="memcpy" name="memcpy">,
920 <ref id="memmove" name="memmove">
926 <sect1>_sys<label id="_sys"><p>
930 <tag/Function/Call a subroutine passing register values.
931 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
932 <tag/Declaration/<tt/void __fastcall__ _sys (struct regs* r);/
933 <tag/Description/The function will call the subroutine at the address
934 specified in the <tt/pc/ member of the passed <tt/regs/ structure. All
935 registers and the CPU flags are set to the values given in the <tt/regs/
936 structure. On return from the subroutine, the new values of the registers and
937 flags are stored back overwriting the old values.
938 <tag/Limits/<itemize>
939 <item>Bits 4 and 5 of the flags value in the <tt/regs/ structure are ignored
940 when calling the subroutine (they are unchanged from their current values).
941 <item>The function is only available as fastcall function, so it may only be
942 used in presence of a prototype.
944 <tag/Availability/cc65
950 <sect1>BRK<label id="BRK"><p>
954 <tag/Function/Insert a 6502 BRK instrunction into the code.
955 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
956 <tag/Declaration/<tt/void BRK (void);/
957 <tag/Description/The function will insert a 6502 BRK instruction into the code
958 which may be used to trigger a debugger.
959 <tag/Limits/<itemize>
960 <item>The function is actually a macro.
961 <item>The inserted instruction may lead to unexpected results if no debugger
964 <tag/Availability/cc65
966 <ref id="CLI" name="CLI">,
967 <ref id="SEI" name="SEI">
973 <sect1>CLI<label id="CLI"><p>
977 <tag/Function/Insert a 6502 CLI instrunction into the code.
978 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
979 <tag/Declaration/<tt/void CLI (void);/
980 <tag/Description/The function will insert a 6502 CLI instruction into the code,
981 so interrupts are enabled. Enabling interrupts has no effects if they are
982 already enabled (the default).
983 <tag/Limits/<itemize>
984 <item>The function is actually a macro.
985 <item>Disabling interrupts may lead to unexpected results.
987 <tag/Availability/cc65
989 <ref id="BRK" name="BRK">,
990 <ref id="SEI" name="SEI">
996 <sect1>PEEK<label id="PEEK"><p>
1000 <tag/Function/Read a byte from memory.
1001 <tag/Header/<tt/<ref id="peekpoke.h" name="peekpoke.h">/
1002 <tag/Declaration/<tt/unsigned char PEEK (unsigned addr);/
1003 <tag/Description/The function will read the absolute memory given by <tt/addr/
1004 and return the value read.
1005 <tag/Limits/<itemize>
1006 <item>The function is actually a macro.
1007 <item>This function depends highly on the platform and environment.
1009 <tag/Availability/cc65
1011 <ref id="PEEKW" name="PEEKW">,
1012 <ref id="POKE" name="POKE">
1018 <sect1>PEEKW<label id="PEEKW"><p>
1022 <tag/Function/Read a word (two bytes) from memory.
1023 <tag/Header/<tt/<ref id="peekpoke.h" name="peekpoke.h">/
1024 <tag/Declaration/<tt/unsigned PEEKW (unsigned addr);/
1025 <tag/Description/The function will read the absolute memory given by <tt/addr/
1026 and return the value read. The byte read from the higher address is the high
1027 byte of the return value.
1028 <tag/Limits/<itemize>
1029 <item>The function is actually a macro.
1030 <item>This function depends highly on the platform and environment.
1031 <item>The order in which the two bytes are read is unspecified and may
1032 depend of the address expression used.
1034 <tag/Availability/cc65
1036 <ref id="PEEK" name="PEEK">,
1037 <ref id="POKE" name="POKE">
1043 <sect1>POKE<label id="POKE"><p>
1047 <tag/Function/Write a byte to memory.
1048 <tag/Header/<tt/<ref id="peekpoke.h" name="peekpoke.h">/
1049 <tag/Declaration/<tt/void POKE (unsigned addr, unsigned char val);/
1050 <tag/Description/The function writes the value <tt/val/ to the absolute
1051 memory address given by <tt/addr/.
1052 <tag/Limits/<itemize>
1053 <item>The function is actually a macro.
1054 <item>This function depends highly on the platform and environment.
1055 <item>Careless use will cause the program to act strange or may crash the
1058 <tag/Availability/cc65
1060 <ref id="PEEK" name="PEEK">,
1061 <ref id="POKEW" name="POKEW">
1067 <sect1>POKEW<label id="POKEW"><p>
1071 <tag/Function/Write a word (two bytes) to memory.
1072 <tag/Header/<tt/<ref id="peekpoke.h" name="peekpoke.h">/
1073 <tag/Declaration/<tt/void POKEW (unsigned addr, unsigned val);/
1074 <tag/Description/The function writes the value <tt/val/ to the absolute
1075 memory address given by <tt/addr/. The low byte of <tt/val/ is written to
1076 the <tt/addr/, the high byte is written to <tt/addr+1/.
1077 <tag/Limits/<itemize>
1078 <item>The function is actually a macro.
1079 <item>This function depends highly on the platform and environment.
1080 <item>Careless use will cause the program to act strange or may crash the
1082 <item>The order in which the two bytes are written is unspecified and may
1083 depend of the address expression used.
1085 <tag/Availability/cc65
1087 <ref id="PEEK" name="PEEK">,
1088 <ref id="POKE" name="POKE">
1094 <sect1>SEI<label id="SEI"><p>
1098 <tag/Function/Insert a 6502 SEI instrunction into the code.
1099 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
1100 <tag/Declaration/<tt/void SEI (void);/
1101 <tag/Description/The function will insert a 6502 SEI instruction into the code,
1102 so interrupts are disabled. Note that non maskable interrupts cannot be
1104 <tag/Limits/<itemize>
1105 <item>The function is actually a macro.
1106 <item>Disabling interrupts may lead to unexpected results.
1108 <tag/Availability/cc65
1110 <ref id="BRK" name="BRK">,
1111 <ref id="CLI" name="CLI">
1117 <sect1>abort<label id="abort"><p>
1121 <tag/Function/Terminates a program abnormally.
1122 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1123 <tag/Declaration/<tt/void abort (void);/
1124 <tag/Description/<tt/abort/ raises <tt/SIGABRT/, writes a termination message
1125 on stderr, then terminates the program with an exit code of 3.
1126 <tag/Availability/ISO 9899
1128 <ref id="assert" name="assert">,
1129 <ref id="exit" name="exit">,
1130 <ref id="raise" name="raise">
1136 <sect1>abs<label id="abs"><p>
1140 <tag/Function/Returns the absolute value of an integer.
1141 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1142 <tag/Declaration/<tt/int __fastcall__ abs (int v);/
1143 <tag/Description/<tt/abs/ returns the absolute value of the argument passed to
1145 <tag/Limits/<itemize>
1146 <item>The return value is undefined if <tt/INT_MIN/ is passed to the function.
1147 <item>The function is only available as fastcall function, so it may only be
1148 used in presence of a prototype.
1150 <tag/Availability/ISO 9899
1152 <ref id="labs" name="labs">
1158 <sect1>assert<label id="assert"><p>
1162 <tag/Function/Test a condition and possibly abort.
1163 <tag/Header/<tt/<ref id="assert.h" name="assert.h">/
1164 <tag/Declaration/<tt/void assert (int cond);/
1165 <tag/Description/<tt/assert/ is a macro that expands to a <tt/id/
1166 statement. If the condition evaluates t zero (false), assert prints a message
1167 on stderr and aborts the program.
1168 <tag/Limits/<itemize>
1169 <item>The function is actually a macro.
1171 <tag/Availability/ISO 9899
1173 <ref id="abort" name="abort">,
1174 <ref id="exit" name="exit">
1180 <sect1>atexit<label id="atexit"><p>
1184 <tag/Function/Register an exit function.
1185 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1186 <tag/Declaration/<tt/int __fastcall__ atexit (void (*exitfunc) (void));/
1187 <tag/Description/<tt/atexit/ registers the function pointed to by
1188 <tt/exitfunc/ as an exit function. Exit functions are called when the program
1189 terminates, they are called in LIFO order (the last function registered is
1190 called first). <tt/atexit/ returns zero on success and a nonzero value on
1192 <tag/Limits/<itemize>
1193 <item>A maximum of 5 exit functions can be registered.
1194 <item>There is no way to unregister an exit function.
1195 <item>The function is only available as fastcall function, so it may only be
1196 used in presence of a prototype.
1198 <tag/Availability/ISO 9899
1200 <ref id="abort" name="abort">,
1201 <ref id="exit" name="exit">
1207 <sect1>atmos_load<label id="atmos_load"><p>
1211 <tag/Function/Load Atmos tape.
1212 <tag/Header/<tt/<ref id="atmos.h" name="atmos.h">/
1213 <tag/Declaration/<tt/void __fastcall__ atmos_load(const char* name);/
1214 <tag/Description/<tt/atmos_load/ reads a memory block from tape.
1215 <tag/Availability/cc65
1217 <ref id="atmos_save" name="atmos_save">
1223 <sect1>atmos_save<label id="atmos_save"><p>
1227 <tag/Function/Save Atmos tape.
1228 <tag/Header/<tt/<ref id="atmos.h" name="atmos.h">/
1229 <tag/Declaration/<tt/void __fastcall__ atmos_save(const char* name, const void* start, const void* end);/
1230 <tag/Description/<tt/atmos_save/ writes a memory block to tape.
1231 <tag/Availability/cc65
1233 <ref id="atmos_load" name="atmos_load">
1235 atmos_save("hires", 0xa000, 0xc000);
1241 <sect1>atoi<label id="atoi"><p>
1245 <tag/Function/Convert a string to an integer.
1246 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1247 <tag/Declaration/<tt/int __fastcall__ atoi (const char* s);/
1248 <tag/Description/<tt/atoi/ converts the given string into an integer.
1249 Conversion stops as soon as any invalid character is encountered.
1250 <tag/Limits/<itemize>
1251 <item>There is no way to detect any conversion errors.
1252 <item>The function does not check for an numerical overflow when converting.
1253 <item>The function is only available as fastcall function, so it may only be
1254 used in presence of a prototype.
1256 <tag/Availability/ISO 9899
1258 <ref id="atol" name="atol">,
1259 <ref id="itoa" name="itoa">,
1260 <ref id="ltoa" name="ltoa">,
1261 <ref id="ultoa" name="ultoa">,
1262 <ref id="utoa" name="utoa">
1268 <sect1>atol<label id="atol"><p>
1272 <tag/Function/Convert a string to a long integer.
1273 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1274 <tag/Declaration/<tt/long __fastcall__ atol (const char* s);/
1275 <tag/Description/<tt/atol/ converts the given string into a long integer.
1276 Conversion stops as soon as any invalid character is encountered.
1277 <tag/Limits/<itemize>
1278 <item>There is no way to detect any conversion errors.
1279 <item>The function does not check for an numerical overflow when converting.
1280 <item>The function is only available as fastcall function, so it may only be
1281 used in presence of a prototype.
1283 <tag/Availability/ISO 9899
1285 <ref id="atoi" name="atoi">,
1286 <ref id="itoa" name="itoa">,
1287 <ref id="ltoa" name="ltoa">,
1288 <ref id="ultoa" name="ultoa">,
1289 <ref id="utoa" name="utoa">
1295 <sect1>bgcolor<label id="bgcolor"><p>
1299 <tag/Function/Set the background text color.
1300 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1301 <tag/Declaration/<tt/unsigned char __fastcall__ bgcolor (unsigned char color);/
1302 <tag/Description/The function will set a new background color and return the
1303 old (current) one. The background color is valid for the whole text output
1304 area of the screen, not just for new text.
1305 <tag/Limits/<itemize>
1306 <item>Background colors are system dependent. The function may have no effect
1307 on systems where the background color cannot be changed.
1308 <item>The function is only available as fastcall function, so it may only be
1309 used in presence of a prototype.
1311 <tag/Availability/cc65
1313 <ref id="bordercolor" name="bordercolor">,
1314 <ref id="textcolor" name="textcolor">
1320 <sect1>bordercolor<label id="bordercolor"><p>
1324 <tag/Function/Set the border (frame) color.
1325 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1326 <tag/Declaration/<tt/unsigned char __fastcall__ bordercolor (unsigned char color);/
1327 <tag/Description/The function will set a new border color. It returns the old
1328 (current) border color.
1329 <tag/Limits/<itemize>
1330 <item>Border colors are system dependent. The function may have no effect
1331 on systems where the border color cannot be changed.
1332 <item>The function is only available as fastcall function, so it may only
1333 be used in presence of a prototype.
1335 <tag/Availability/cc65
1337 <ref id="bgcolor" name="bgcolor">,
1338 <ref id="textcolor" name="textcolor">
1344 <sect1>bsearch<label id="bsearch"><p>
1348 <tag/Function/Do a binary search in a sorted array.
1349 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1350 <tag/Declaration/<tt/void* __fastcall__ bsearch (const void* key,
1351 const void* base, size_t n, size_t size,
1352 int (*cmp) (const void*, const void*));/
1353 <tag/Description/<tt/bsearch/ searches a sorted array for a member that
1354 matches the one pointed to by <tt/key/. <tt/base/ is the address of the array,
1355 <tt/n/ is the number of elements, <tt/size/ the size of an element and <tt/cmp/
1356 the function used to compare the members against the key. The function returns
1357 a pointer to the member found, or <tt/NULL/ if there was no match.
1360 <item>The contents of the array must be sorted in ascending order according to
1361 the compare function given.
1362 <item>If there are multiple members that match the key, the function will
1363 return one of the members.
1364 <item>The function is only available as fastcall function, so it may only
1365 be used in presence of a prototype.
1367 <tag/Availability/ISO 9899
1369 <ref id="qsort" name="qsort">
1375 <sect1>bzero<label id="bzero"><p>
1379 <tag/Function/Fill a memory area with zeroes.
1380 <tag/Header/<tt/<ref id="string.h" name="string.h">/
1381 <tag/Declaration/<tt/void __fastcall__ bzero (void* p, size_t count);/
1382 <tag/Description/<tt/bzero/ fills the memory area pointed to by <tt/p/ with
1386 <item>The function is non standard and therefore only available in non ANSI
1387 mode. You should use <tt/<ref id="memset" name="memset">/ instead.
1388 <item>The function is only available as fastcall function, so it may only
1389 be used in presence of a prototype.
1391 <tag/Availability/cc65
1393 <ref id="_swap" name="_swap">,
1394 <ref id="memcpy" name="memcpy">,
1395 <ref id="memmove" name="memmove">,
1396 <ref id="memset" name="memset">,
1402 <sect1>c64mode<label id="c64mode"><p>
1406 <tag/Function/Switch the C128 into C64 compatible mode.
1407 <tag/Header/<tt/<ref id="c128.h" name="c128.h">/
1408 <tag/Declaration/<tt/void c64mode (void);/
1409 <tag/Description/The function will cause the machine to reboot into C64 mode.
1410 <tag/Limits/<itemize>
1411 <item>The function is specific to the C128.
1412 <item>The function will not return to the caller.
1414 <tag/Availability/C128
1420 <sect1>calloc<label id="calloc"><p>
1424 <tag/Function/Allocate and clear memory.
1425 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1426 <tag/Declaration/<tt/void* __fastcall__ calloc (size_t n, size_t size);/
1427 <tag/Description/<tt/calloc/ allocates memory for an array of <tt/n/ elements
1428 of size <tt/size/, clears the whole block with binary zeroes and returns a
1429 pointer to it. On error (not enough memory available), <tt/calloc/ returns
1433 <item>Clearing the memory may not have the expected effect on all platforms:
1434 pointers in the block may not be <tt/NULL/ and floating point variables may
1435 not be zero (0.0). In other words: The "clearing" effect of this function
1436 should be used with care for portable programs.
1437 <item>The function is only available as fastcall function, so it may only
1438 be used in presence of a prototype.
1440 <tag/Availability/ISO 9899
1442 <ref id="_heapadd" name="_heapadd">,
1443 <ref id="_heapblocksize" name="_heapblocksize">,
1444 <ref id="_heapmaxavail" name="_heapmaxavail">,
1445 <ref id="_heapmemavail" name="_heapmemavail">,
1446 <ref id="free" name="free">,
1447 <ref id="malloc" name="malloc">,
1448 <ref id="realloc" name="realloc">
1454 <sect1>cclear<label id="cclear"><p>
1458 <tag/Function/Clear part of a line (write a given number of spaces).
1459 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1460 <tag/Declaration/<tt/void __fastcall__ cclear (unsigned char length);/
1461 <tag/Description/The function clears part of a line by writing <tt/length/
1462 spaces in the current text color.
1463 <tag/Limits/<itemize>
1464 <item>The function is only available as fastcall function, so it may
1465 only be used in presence of a prototype.
1467 <tag/Availability/cc65
1469 <ref id="cclearxy" name="cclearxy">,
1470 <ref id="clrscr" name="clrscr">
1476 <sect1>cclearxy<label id="cclearxy"><p>
1480 <tag/Function/Clear part of a line (write a given number of spaces) starting
1481 at a specific screen position.
1482 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1483 <tag/Declaration/<tt/void __fastcall__ cclearxy (unsigned char x, unsigned char y, unsigned char length);/
1484 <tag/Description/The function moves the cursor to a specific position, and
1485 will then clear part of the line by writing <tt/length/ spaces in the current
1487 <tag/Limits/<itemize>
1488 <item>The function is only available as fastcall function, so it may
1489 only be used in presence of a prototype.
1491 <tag/Availability/cc65
1493 <ref id="cclear" name="cclear">,
1494 <ref id="clrscr" name="clrscr">
1500 <sect1>cgetc<label id="cgetc"><p>
1504 <tag/Function/Read a character from the keyboard.
1505 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1506 <tag/Declaration/<tt/char cgetc (void);/
1507 <tag/Description/The function reads a character from the keyboard. If there is
1508 no character available, <tt/cgetc/ waits until the user presses a key. If the
1509 cursor is enabled by use of the <tt/cursor/ function, a blinking cursor is
1510 displayed while waiting.
1511 <tag/Limits/<itemize>
1512 <item>If the system supports a keyboard buffer, <tt/cgetc/ will fetch a key
1513 from this buffer and wait only if the buffer is empty.
1515 <tag/Availability/cc65
1517 <ref id="cursor" name="cursor">,
1518 <ref id="kbhit" name="kbhit">
1524 <sect1>chline<label id="chline"><p>
1528 <tag/Function/Output a horizontal line in text mode.
1529 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1530 <tag/Declaration/<tt/void __fastcall__ chline (unsigned char length);/
1531 <tag/Description/The function outputs a horizontal line with the given length
1532 starting at the current cursor position.
1533 <tag/Limits/<itemize>
1534 <item>The character used to draw the horizontal line is system dependent.
1535 If available, a line drawing character is used. Drawing a line that is partially
1536 off screen leads to undefined behaviour.
1537 <item>The function is only available as fastcall function, so it may only be
1538 used in presence of a prototype.
1540 <tag/Availability/cc65
1542 <ref id="chlinexy" name="chlinexy">,
1543 <ref id="cvline" name="cvline">,
1544 <ref id="cvlinexy" name="cvlinexy">
1550 <sect1>chlinexy<label id="chlinexy"><p>
1554 <tag/Function/Output a horizontal line at a given position in text mode.
1555 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1556 <tag/Declaration/<tt/void __fastcall__ chlinexy (unsigned char x, unsigned char y, unsigned char length);/
1557 <tag/Description/The function outputs a horizontal line with the given length
1558 starting at a given position.
1559 <tag/Limits/<itemize>
1560 <item>The character used to draw the horizontal line is system dependent.
1561 If available, a line drawing character is used. Drawing a line that is partially
1562 off screen leads to undefined behaviour.
1563 <item>The function is only available as fastcall function, so it may only be
1564 used in presence of a prototype.
1566 <tag/Availability/cc65
1568 <ref id="chline" name="chline">,
1569 <ref id="cvline" name="cvline">,
1570 <ref id="cvlinexy" name="cvlinexy">
1576 <sect1>clearerr<label id="clearerr"><p>
1580 <tag/Function/Clear error and end-of-file status of a stream.
1581 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
1582 <tag/Declaration/<tt/void __fastcall__ clearerr (FILE* f);/
1583 <tag/Description/<tt/clearerr/ clears the error and end-of-file status
1584 indicators for the stream <tt/f/.
1585 <tag/Limits/<itemize>
1586 <item>The function is only available as fastcall function, so it may only be
1587 used in presence of a prototype.
1589 <tag/Availability/ISO 9899
1591 <ref id="feof" name="feof">,
1592 <ref id="ferror" name="ferror">
1598 <sect1>clock<label id="clock"><p>
1602 <tag/Function/Determine the processor time used.
1603 <tag/Header/<tt/<ref id="time.h" name="time.h">/
1604 <tag/Declaration/<tt/clock_t clock (void);/
1605 <tag/Description/The <tt/clock/ function returns an approximaton of processor
1606 time used by the program. The time is returned in implementation defined
1607 units. It can be converted to seconds by dividing by the value of the macro
1608 <tt/CLOCKS_PER_SEC/.
1609 <tag/Limits/<itemize>
1610 <item>Since the machines, cc65 generated programs run on, cannot run multiple
1611 processes, the function will actually return the time since some
1612 implementation defined point in the past.
1614 <tag/Availability/ISO 9899
1616 <ref id="time" name="time">
1622 <sect1>clrscr<label id="clrscr"><p>
1626 <tag/Function/Clear the text screen.
1627 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1628 <tag/Declaration/<tt/void clrscr (void);/
1629 <tag/Description/The function clears the text screen and moves the cursor to
1630 the upper left corner.
1631 <tag/Availability/cc65
1633 <ref id="cclear" name="cclear">,
1634 <ref id="cclearxy" name="cclearxy">
1640 <sect1>close<label id="close"><p>
1644 <tag/Function/Close a file descriptor.
1645 <tag/Header/<tt/<ref id="fcntl.h" name="fcntl.h">/
1646 <tag/Declaration/<tt/int __fastcall__ close (int fd);/
1647 <tag/Description/The function closes the given file descriptor. It returns zero
1648 on success and -1 on error. If an error occurs, the cause can be determined by
1649 reading the <tt/errno/ variable.
1650 <tag/Limits/<itemize>
1651 <item>The function is only available as fastcall function, so it may only
1652 be used in presence of a prototype.
1654 <tag/Availability/POSIX 1003.1
1656 <ref id="creat" name="creat">,
1657 <ref id="open" name="open">
1663 <sect1>closedir<label id="closedir"><p>
1667 <tag/Function/Close a directory.
1668 <tag/Header/<tt/<ref id="dirent.h" name="dirent.h">/
1669 <tag/Declaration/<tt/int __fastcall__ closedir (DIR* dir);/
1670 <tag/Description/The function closes the given directory descriptor. It returns
1671 zero on success and -1 on error. If an error occurs, the cause can be determined
1672 by reading the <tt/errno/ variable.
1673 <tag/Limits/<itemize>
1674 <item>The function is only available as fastcall function, so it may only
1675 be used in presence of a prototype.
1677 <tag/Availability/POSIX 1003.1
1679 <ref id="opendir" name="opendir">,
1680 <ref id="readdir" name="readdir">
1686 <sect1>creat<label id="creat"><p>
1690 <tag/Function/Create a file.
1691 <tag/Header/<tt/<ref id="fcntl.h" name="fcntl.h">/
1692 <tag/Declaration/<tt/int __fastcall__ creat (const char* name, unsigned mode);/
1693 <tag/Description/<tt/creat/ creates a new file and returns the file descriptor
1694 associated with it. On error, -1 is returned and an error code is stored in
1696 <tag/Limits/<itemize>
1697 <item><tt/creat/ is identical to calling <tt/<ref id="open" name="open">/ with
1698 <tt/flags/ equal to <tt/O_WRONLY | O_CREAT | O_TRUNC/.
1699 <item>The function is only available as fastcall function, so it may only
1700 be used in presence of a prototype.
1702 <tag/Availability/POSIX 1003.1
1704 <ref id="close" name="close">,
1705 <ref id="open" name="open">
1711 <sect1>cprintf<label id="cprintf"><p>
1715 <tag/Function/Formatted output to the console.
1716 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1717 <tag/Declaration/<tt/int cprintf (const char* format, ...);/
1718 <tag/Description/The arguments are converted to text where necessary and
1719 formatted according to the format string given. The resulting string is output
1720 to the console. <tt/cprintf/ supports the same format specifiers as
1721 <tt/printf/. <!-- <tt/<ref id="printf" name="printf">/. -->
1722 <tag/Limits/<itemize>
1723 <item>Like all other <tt/conio/ output functions, <tt/cprintf/ distinguishes
1724 between <tt/\r/ and <tt/\n/.
1726 <tag/Availability/cc65
1728 <ref id="cputc" name="cputc">,
1729 <ref id="cputcxy" name="cputcxy">,
1730 <ref id="cputs" name="cputs">,
1731 <ref id="cputsxy" name="cputsxy">,
1732 <ref id="vcprintf" name="vcprintf">
1738 <sect1>cputc<label id="cputc"><p>
1742 <tag/Function/Output a character directly to the console.
1743 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1744 <tag/Declaration/<tt/void __fastcall__ cputc (char c);/
1745 <tag/Description/Output one character to the console at the current cursor
1747 <tag/Limits/<itemize>
1748 <item>Like all other <tt/conio/ output functions, <tt/cputc/ distinguishes
1749 between <tt/\r/ and <tt/\n/.
1750 <item>The function is only available as fastcall function, so it may only
1751 be used in presence of a prototype.
1753 <tag/Availability/cc65
1755 <ref id="cprintf" name="cprintf">,
1756 <ref id="cputcxy" name="cputcxy">,
1757 <ref id="cputs" name="cputs">,
1758 <ref id="cputsxy" name="cputsxy">,
1759 <ref id="vcprintf" name="vcprintf">
1765 <sect1>cputcxy<label id="cputcxy"><p>
1769 <tag/Function/Output a character at a specific screen position.
1770 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1771 <tag/Declaration/<tt/void __fastcall__ cputcxy (unsigned char x, unsigned char y, char c);/
1772 <tag/Description/<tt/cputcxy/ moves the cursor to the given x/y position on
1773 the screen and outputs one character.
1774 <tag/Limits/<itemize>
1775 <item>Like all other <tt/conio/ output functions, <tt/cputcxy/ distinguishes
1776 between <tt/\r/ and <tt/\n/.
1777 <item>The function is only available as fastcall function, so it may only
1778 be used in presence of a prototype.
1780 <tag/Availability/cc65
1782 <ref id="cprintf" name="cprintf">,
1783 <ref id="cputc" name="cputc">,
1784 <ref id="cputs" name="cputs">,
1785 <ref id="cputsxy" name="cputsxy">,
1786 <ref id="vcprintf" name="vcprintf">
1792 <sect1>cputs<label id="cputs"><p>
1796 <tag/Function/Output a string directly to the console.
1797 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1798 <tag/Declaration/<tt/void __fastcall__ cputs (const char* s);/
1799 <tag/Description/The function outputs the given string on the console at the
1800 current cursor position.
1801 <tag/Limits/<itemize>
1802 <item>Like all other <tt/conio/ output functions, <tt/cputs/ distinguishes
1803 between <tt/\r/ and <tt/\n/.
1804 <item>The function is only available as fastcall function, so it may only
1805 be used in presence of a prototype.
1807 <tag/Availability/cc65
1809 <ref id="cprintf" name="cprintf">,
1810 <ref id="cputc" name="cputc">,
1811 <ref id="cputcxy" name="cputcxy">,
1812 <ref id="cputsxy" name="cputsxy">,
1813 <ref id="vcprintf" name="vcprintf">
1819 <sect1>cputsxy<label id="cputsxy"><p>
1823 <tag/Function/Output a string to the console at a given position.
1824 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1825 <tag/Declaration/<tt/void __fastcall__ cputsxy (unsigned char x, unsigned char y, const char* s);/
1826 <tag/Description/<tt/cputsxy/ moves the cursor to the given x/y position,
1827 and outputs the string <tt/s/.
1828 <tag/Limits/<itemize>
1829 <item>Like all other <tt/conio/ output functions, <tt/cputsxy/ distinguishes
1830 between <tt/\r/ and <tt/\n/.
1831 <item>The function is only available as fastcall function, so it may only
1832 be used in presence of a prototype.
1834 <tag/Availability/cc65
1836 <ref id="cprintf" name="cprintf">,
1837 <ref id="cputc" name="cputc">,
1838 <ref id="cputcxy" name="cputcxy">,
1839 <ref id="cputs" name="cputs">,
1840 <ref id="vcprintf" name="vcprintf">
1846 <sect1>cursor<label id="cursor"><p>
1850 <tag/Function/Enable/disable a blinking cursor when waiting for keyboard input.
1851 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1852 <tag/Declaration/<tt/unsigned char __fastcall__ cursor (unsigned char onoff);/
1853 <tag/Description/If the argument to the function is non zero, a blinking cursor
1854 will be enabled when the <tt/cgetc/ function waits for input from the keyboard.
1855 If the argument is zero, <tt/cgetc/ will wait without a blinking cursor.
1856 <tag/Limits/<itemize>
1857 <item>The function is only available as fastcall function, so it may only
1858 be used in presence of a prototype.
1860 <tag/Availability/cc65
1862 <ref id="cgetc" name="cgetc">,
1863 <ref id="kbhit" name="kbhit">
1869 <sect1>cvline<label id="cvline"><p>
1873 <tag/Function/Output a vertical line in text mode.
1874 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1875 <tag/Declaration/<tt/void __fastcall__ cvline (unsigned char length);/
1876 <tag/Description/The function outputs a vertical line with the given length
1877 starting at the current cursor position.
1878 <tag/Limits/<itemize>
1879 <item>The character used to draw the vertical line is system dependent.
1880 If available, a line drawing character is used. Drawing a line that is partially
1881 off screen leads to undefined behaviour.
1882 <item>The function is only available as fastcall function, so it may only be
1883 used in presence of a prototype.
1885 <tag/Availability/cc65
1887 <ref id="chline" name="chline">,
1888 <ref id="chlinexy" name="chlinexy">,
1889 <ref id="cvlinexy" name="cvlinexy">
1895 <sect1>cvlinexy<label id="cvlinexy"><p>
1899 <tag/Function/Output a vertical line at a given position in text mode.
1900 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1901 <tag/Declaration/<tt/void __fastcall__ cvlinexy (unsigned char x, unsigned char y, unsigned char length);/
1902 <tag/Description/The function outputs a vertical line with the given length
1903 starting at a given position.
1904 <tag/Limits/<itemize>
1905 <item>The character used to draw the vertical line is system dependent.
1906 If available, a line drawing character is used. Drawing a line that is partially
1907 off screen leads to undefined behaviour.
1908 <item>The function is only available as fastcall function, so it may only be
1909 used in presence of a prototype.
1911 <tag/Availability/cc65
1913 <ref id="chline" name="chline">,
1914 <ref id="chlinexy" name="chlinexy">,
1915 <ref id="cvline" name="cvline">
1921 <sect1>div<label id="div"><p>
1925 <tag/Function/Divide two ints and return quotient and remainder.
1926 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1927 <tag/Declaration/<tt/div_t __fastcall__ div (int numer, int denom);/
1928 <tag/Description/<tt/div/ divides <tt/numer/ by <tt/denom/ and returns the
1929 quotient and remainder in a <tt/div_t/ structure.
1932 <item>The function is only available as fastcall function, so it may only
1933 be used in presence of a prototype.
1935 <tag/Availability/ISO 9899
1943 <sect1>em_commit<label id="em_commit"><p>
1947 <tag/Function/Commit changes into extended memory.
1948 <tag/Header/<tt/<ref id="em.h" name="em.h">/
1949 <tag/Declaration/<tt/void em_commit (void);/
1950 <tag/Description/Commit changes in the memory window to extended storage. If
1951 the contents of the memory window have been changed, these changes may be lost
1952 if <tt/<ref id="em_map" name="em_map">/, <tt/<ref id="em_use" name="em_use">/,
1953 <tt/<ref id="em_copyfrom" name="em_copyfrom">/ or <tt/<ref id="em_copyto"
1954 name="em_copyto">/ are called without calling <tt/em_commit/ first.
1955 <tag/Limits/<itemize>
1956 <item>Calling <tt/em_commit/ does not necessarily mean that changes to the
1957 memory window are discarded, it does just mean that the drivers is allowed
1959 <item>The function is only available as fastcall function, so it may only be
1960 used in presence of a prototype.
1961 <item>The function produces undefined results if no extended memory driver is
1964 <tag/Availability/cc65
1966 <ref id="em_load_driver" name="em_load_driver">,
1967 <ref id="em_map" name="em_map">,
1968 <ref id="em_use" name="em_use">
1974 <sect1>em_copyfrom<label id="em_copyfrom"><p>
1978 <tag/Function/Copy from extended into normal memory.
1979 <tag/Header/<tt/<ref id="em.h" name="em.h">/
1980 <tag/Declaration/<tt/void __fastcall__ em_copyfrom (const struct em_copy* copy_data);/
1981 <tag/Description/Copy data from extended memory into linear memory. Source and
1982 target addresses as well as the number of bytes to transfer are specified in
1983 the <tt/em_copy/ structure that is passed as a parameter.
1984 <tag/Limits/<itemize>
1985 <item>Calling <tt/em_copyfrom/ will invalidate the memory window, so if you
1986 made any changes to the data in the window, call <tt/<ref id="em_commit"
1987 name="em_commit">/ first, or the changes are lost.
1988 <item>The function is only available as fastcall function, so it may only be
1989 used in presence of a prototype.
1990 <item>The function produces undefined results if no extended memory driver is
1993 <tag/Availability/cc65
1995 <ref id="em_commit" name="em_commit">,
1996 <ref id="em_copyto" name="em_copyto">,
1997 <ref id="em_load_driver" name="em_load_driver">
2003 <sect1>em_copyto<label id="em_copyto"><p>
2007 <tag/Function/Copy from normal into extended memory.
2008 <tag/Header/<tt/<ref id="em.h" name="em.h">/
2009 <tag/Declaration/<tt/void __fastcall__ em_copyto (const struct em_copy* copy_data);/
2010 <tag/Description/Copy data from linear into extended memory. Source and
2011 target addresses as well as the number of bytes to transfer are specified in
2012 the <tt/em_copy/ structure that is passed as a parameter.
2013 <tag/Limits/<itemize>
2014 <item>Calling <tt/em_copyto/ will invalidate the memory window, so if you
2015 made any changes to the data in the window, call <tt/<ref id="em_commit"
2016 name="em_commit">/ first, or the changes are lost.
2017 <item>The function is only available as fastcall function, so it may only be
2018 used in presence of a prototype.
2019 <item>The function produces undefined results if no extended memory driver is
2022 <tag/Availability/cc65
2024 <ref id="em_commit" name="em_commit">,
2025 <ref id="em_copyfrom" name="em_copyfrom">,
2026 <ref id="em_load_driver" name="em_load_driver">
2032 <sect1>em_install<label id="em_install"><p>
2036 <tag/Function/Install an already loaded extended memory driver.
2037 <tag/Header/<tt/<ref id="em.h" name="em.h">/
2038 <tag/Declaration/<tt/unsigned char _fastcall__ em_install (void* driver);/
2039 <tag/Description/The function installs an already loaded extended memory driver
2040 and returns an error code. The function may be used to install a driver linked
2041 statically to the program.
2042 <tag/Limits/<itemize>
2043 <item>Not all drivers are able to detect if the supported hardware is really
2045 <item>The function is only available as fastcall function, so it may only be
2046 used in presence of a prototype.
2048 <tag/Availability/cc65
2050 <ref id="em_load_driver" name="em_load_driver">,
2051 <ref id="em_uninstall" name="em_uninstall">,
2052 <ref id="em_unload" name="em_unload">
2058 <sect1>em_load_driver<label id="em_load_driver"><p>
2062 <tag/Function/Load and initialize an extended memory driver.
2063 <tag/Header/<tt/<ref id="em.h" name="em.h">/
2064 <tag/Declaration/<tt/void __fastcall__ em_load_driver (const char* name);/
2065 <tag/Description/Load an extended memory driver into memory and initialize
2066 it. The function returns an error code that tells if all this has been
2068 <tag/Limits/<itemize>
2069 <item>Not all drivers are able to detect if the supported hardware is really
2071 <item>The function is only available as fastcall function, so it may only be
2072 used in presence of a prototype.
2073 <item>The driver is loaded by name, so currently you must know the type of
2074 extended memory that should be supported. There is no autodetect capability.
2076 <tag/Availability/cc65
2078 <ref id="em_unload" name="em_unload">
2084 <sect1>em_map<label id="em_map"><p>
2088 <tag/Function/Make a page of extended memory accessible.
2089 <tag/Header/<tt/<ref id="em.h" name="em.h">/
2090 <tag/Declaration/<tt/void* __fastcall__ em_map (unsigned page);/
2091 <tag/Description/The function maps one page of extended memory into linear
2092 memory and returns a pointer to the page frame. Depending on the hardware
2093 and driver, the data is either mapped into the address space or transfered
2094 into a buffer. If you don't need the actual contents of the page (for example
2095 because you're going to overwrite it completely), it is better to call
2096 <tt/<ref id="em_use" name="em_use">/ instead. <tt/em_use/ will not transfer the
2097 data if it is possible to avoid that.
2098 <tag/Limits/<itemize>
2099 <item>Calling <tt/em_map/ will invalidate the memory window, so if you
2100 made any changes to the data in the window, call <tt/<ref id="em_commit"
2101 name="em_commit">/ first, or the changes are lost.
2102 <item>The function is only available as fastcall function, so it may only be
2103 used in presence of a prototype.
2104 <item>The function produces undefined results if no extended memory driver is
2107 <tag/Availability/cc65
2109 <ref id="em_commit" name="em_commit">,
2110 <ref id="em_load_driver" name="em_load_driver">,
2111 <ref id="em_use" name="em_use">
2117 <sect1>em_pagecount<label id="em_pagecount"><p>
2121 <tag/Function/Return the number of available extended memory pages.
2122 <tag/Header/<tt/<ref id="em.h" name="em.h">/
2123 <tag/Declaration/<tt/unsigned em_pagecount (void);/
2124 <tag/Description/The function returns the size of the extended memory supported
2125 by the driver in 256 byte pages.
2126 <tag/Limits/<itemize>
2127 <item>The function returns zero if no extended memory driver is loaded.
2128 <item>The function may return zero if the supported hardware was not detected.
2130 <tag/Availability/cc65
2132 <ref id="em_load_driver" name="em_load_driver">
2138 <sect1>em_uninstall<label id="em_uninstall"><p>
2142 <tag/Function/Uninstall an already loaded extended memory driver.
2143 <tag/Header/<tt/<ref id="em.h" name="em.h">/
2144 <tag/Declaration/<tt/unsigned char em_uninstall (void);/
2145 <tag/Description/The function uninstalls an already loaded extended memory
2146 driver but doesn't remove it from memory.
2147 <tag/Limits/<itemize>
2148 <item>If the driver has been loaded using <tt/<ref id="em_load_driver"
2149 name="em_load_driver">/, <tt/<ref id="em_unload" name="em_unload">/
2150 should be used instead of <tt/em_uninstall/ so the driver is also removed
2153 <tag/Availability/cc65
2155 <ref id="em_install" name="em_install">,
2156 <ref id="em_load_driver" name="em_load_driver">,
2157 <ref id="em_unload" name="em_unload">
2163 <sect1>em_unload<label id="em_unload"><p>
2167 <tag/Function/Unload an extended memory driver.
2168 <tag/Header/<tt/<ref id="em.h" name="em.h">/
2169 <tag/Declaration/<tt/unsigned char em_unload (void);/
2170 <tag/Description/The function unloads a loaded extended memory driver and
2171 frees all memory allocated for the driver.
2172 <tag/Limits/<itemize>
2173 <item>The function does nothing if no driver is loaded.
2175 <tag/Availability/cc65
2177 <ref id="em_load_driver" name="em_load_driver">
2183 <sect1>em_use<label id="em_use"><p>
2187 <tag/Function/Prepare an extended memory page for use.
2188 <tag/Header/<tt/<ref id="em.h" name="em.h">/
2189 <tag/Declaration/<tt/void* __fastcall__ em_use (unsigned page);/
2190 <tag/Description/The function maps one page of extended memory into linear
2191 memory and returns a pointer to the page frame. This function is similar to
2192 <tt/<ref id="em_map" name="em_map">/, but will not transfer data into the
2193 actual memory window in the assumption that the existing data is wrong or
2194 will get overwritten.
2195 <tag/Limits/<itemize>
2196 <item>Calling <tt/em_use/ will invalidate the memory window, so if you
2197 made any changes to the data in the window, call <tt/<ref id="em_commit"
2198 name="em_commit">/ first, or the changes are lost.
2199 <item>The function is only available as fastcall function, so it may only be
2200 used in presence of a prototype.
2201 <item>The function produces undefined results if no extended memory driver is
2204 <tag/Availability/cc65
2206 <ref id="em_commit" name="em_commit">,
2207 <ref id="em_load_driver" name="em_load_driver">,
2208 <ref id="em_map" name="em_map">
2214 <sect1>exit<label id="exit"><p>
2218 <tag/Function/Terminate the program.
2219 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
2220 <tag/Declaration/<tt/void __fastcall__ exit (int status);/
2221 <tag/Description/<tt/exit/ terminates the program. The argument specifies the
2222 return code of the program. Before termination, all files are closed, buffered
2223 output is written and any functions registered with <tt/<ref id="atexit"
2224 name="atexit">/ are called. Common values for status are <tt/EXIT_SUCCESS/ and
2225 <tt/EXIT_FAILURE/ which are also defined in <tt/<ref id="stdlib.h"
2227 <tag/Limits/<itemize>
2228 <item>The function is only available as fastcall function, so it may only
2229 be used in presence of a prototype.
2230 <item>It depends on the host machine if the program return code can be
2231 evaluated or is ignored.
2233 <tag/Availability/ISO 9899
2235 <ref id="abort" name="abort">,
2236 <ref id="exit" name="exit">
2242 <sect1>exec<label id="exec"><p>
2246 <tag/Function/Execute a program file.
2247 <tag/Header/<tt/<ref id="unistd.h" name="unistd.h">/
2248 <tag/Declaration/<tt/int __fastcall__ exec (const char* progname, const char* cmdline);/
2249 <tag/Description/<tt/exec/ replaces the currently running program by a new one.
2250 Calling <tt/exec()/ is identical to calling <tt/<ref id="exit" name="exit()">/,
2251 then loading and starting the program named in the first argument, passing
2252 the command line specified as second argument. Instead of an empty string,
2253 a <tt/NULL/ pointer may be passed as second parameter.
2254 On success, the function does not return. On failure, -1 is returned and
2255 <tt/errno/ contains an error code.
2256 <tag/Limits/<itemize>
2257 <item>The function is only available as fastcall function, so it may only
2258 be used in presence of a prototype.
2259 <item>On most platforms, the function needs to copy a small stub loader to
2260 some memory area outside the program space. This may collide with other
2261 programs. See the platform specific docs on this.
2262 <item>Because it is necessary to terminate the running program before the
2263 memory can be reused to load the new one, there is a high chance that the
2264 function may not be able to return on errors.
2265 <item>The command line is passed to the new program in the same way as cc65
2266 programs expect the command line. If the new program is not a cc65 generated
2267 program, it may not be able to read it.
2269 <tag/Availability/cc65
2271 <ref id="exit" name="exit">
2277 <sect1>fast<label id="fast"><p>
2281 <tag/Function/Switch the C128 into 2MHz mode.
2282 <tag/Header/<tt/<ref id="c128.h" name="c128.h">/
2283 <tag/Declaration/<tt/void fast (void);/
2284 <tag/Description/The function will switch the clock of the C128 to 2MHz. This
2285 will nearly double the speed compared to slow mode.
2286 <tag/Limits/<itemize>
2287 <item>The function is specific to the C128.
2288 <item>2MHz clock will not work in 40 column mode.
2290 <tag/Availability/C128
2292 <ref id="slow" name="slow">,
2293 <ref id="toggle_videomode" name="toggle_videomode">,
2294 <ref id="videomode" name="videomode">
2300 <sect1>feof<label id="feof"><p>
2304 <tag/Function/Return the end-of-file indicator of a stream.
2305 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
2306 <tag/Declaration/<tt/int __fastcall__ feof (FILE* f);/
2307 <tag/Description/<tt/feof/ tests the end-of-file indicator ofthe stream
2308 <tt/f/, and returns a non zero value if it is set.
2309 <tag/Limits/<itemize>
2310 <item>The indicator is set only after a read past the end of a file is
2312 <item>The function is only available as fastcall function, so it may only be
2313 used in presence of a prototype.
2315 <tag/Availability/ISO 9899
2317 <ref id="feof" name="clearerr">,
2318 <ref id="ferror" name="ferror">
2324 <sect1>ferror<label id="ferror"><p>
2328 <tag/Function/Return the error indicator of a stream.
2329 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
2330 <tag/Declaration/<tt/int __fastcall__ ferror (FILE* f);/
2331 <tag/Description/<tt/ferror/ tests the error indicator of the stream
2332 <tt/f/, and returns a non zero value if it is set.
2333 <tag/Limits/<itemize>
2334 <item>The function is only available as fastcall function, so it may only be
2335 used in presence of a prototype.
2337 <tag/Availability/ISO 9899
2339 <ref id="feof" name="clearerr">,
2340 <ref id="ferror" name="feof">
2346 <sect1>fileno<label id="fileno"><p>
2350 <tag/Function/Return the file handle used by a stream.
2351 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
2352 <tag/Declaration/<tt/int __fastcall__ fileno (FILE* f);/
2353 <tag/Description/The <tt/fileno/ function returns the file handle used
2354 internally by a C stream. This file handle (an integer) can be used as a
2355 handle for the POSIX input/output functions.
2356 <tag/Limits/<itemize>
2357 <item>The function is only available as fastcall function, so it may only be
2358 used in presence of a prototype.
2359 <item>Mixing C file I/O functions and POSIX file I/O functions for the same
2360 file may have unpredictable results.
2362 <tag/Availability/POSIX 1003.1
2364 <ref id="creat" name="creat">,
2365 <ref id="open" name="open"> <!-- , -->
2366 <!-- <ref id="read" name="read">, -->
2367 <!-- <ref id="write" name="write"> -->
2373 <sect1>free<label id="free"><p>
2377 <tag/Function/Free a block of dynamic memory.
2378 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
2379 <tag/Declaration/<tt/void __fastcall__ free (void* block);/
2380 <tag/Description/Free a block of dynamic memory previously allocated with
2381 <tt/<ref id="malloc" name="malloc">/, <tt/<ref id="calloc" name="calloc">/
2382 or <tt/<ref id="realloc" name="realloc">/. As an exception, if the passed
2383 pointer is <tt/NULL/, no action is performed.
2386 <item>Passing an already free'd block to <tt/free/ again will cause undefined
2387 behaviour and may crash your program.
2388 <item>The function is only available as fastcall function, so it may only
2389 be used in presence of a prototype.
2391 <tag/Availability/ISO 9899
2393 <ref id="_heapadd" name="_heapadd">,
2394 <ref id="_heapblocksize" name="_heapblocksize">,
2395 <ref id="_heapmaxavail" name="_heapmaxavail">,
2396 <ref id="_heapmemavail" name="_heapmemavail">,
2397 <ref id="calloc" name="calloc">,
2398 <ref id="malloc" name="malloc">,
2399 <ref id="realloc" name="realloc">
2405 <sect1>get_ostype<label id="get_ostype"><p>
2409 <tag/Function/The function returns the operating system, the program runs on.
2410 <tag/Header/<tt/<ref id="apple2.h" name="apple2.h">,
2411 <ref id="atari.h" name="atari.h">, <ref id="c64.h" name="c64.h">/
2412 <tag/Declaration/<tt/unsigned char get_ostype (void);/
2413 <tag/Description/<tt/get_ostype/ is machine dependent and does not exist for
2414 all supported targets. If it exists, it returns a number that identifies the
2415 operating system or machine type, the program runs on. The machine dependent
2416 header files define constants that can be used to check the return code.
2417 <tag/Limits/<itemize>
2418 <item>The function does not exist on all platforms.
2419 <item>The return codes are platform dependent.
2421 <tag/Availability/cc65 (not all platforms)
2427 <sect1>getcpu<label id="getcpu"><p>
2431 <tag/Function/Determine on which CPU the program is running.
2432 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
2433 <tag/Declaration/<tt/unsigned char getcpu (void);/
2434 <tag/Description/The function checks on which CPU the code is running. It
2435 returns one of the constants<itemize>
2437 <item><tt/CPU_65C02/
2438 <item><tt/CPU_65816/
2440 <tag/Limits/<itemize>
2441 <item>Other, more exotic CPU types are not disinguished.
2443 <tag/Availability/cc65
2449 <sect1>getenv<label id="getenv"><p>
2453 <tag/Function/Return a value from the environment.
2454 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
2455 <tag/Declaration/<tt/char* __fastcall__ getenv (const char* name);/
2456 <tag/Description/The function searches the environment for an entry that
2457 matches <tt/name/ and returns its value. The environment consists of a list
2458 of strings in the form <tt/name=value/. If there is no match, <tt/getenv/
2460 <tag/Limits/<itemize>
2461 <item>What exactly is stored in the environment depends on the machine the
2462 program is running on.
2463 <item>The function is only available as fastcall function, so it may only
2464 be used in presence of a prototype.
2466 <tag/Availability/ISO 9899
2472 <sect1>getopt<label id="getopt"><p>
2476 <tag/Function/Parse command line options.
2477 <tag/Header/<tt/<ref id="unistd.h" name="unistd.h">/
2478 <tag/Declaration/<tt/int __fastcall__ getopt (int argc, char* const* argv,
2479 const char* optstring);/
2480 <tag/Description/The function parses command line arguments, <tt/argc/ and
2481 <tt/argv/ are the argument count and array passed to <tt/main/. <tt/optstring/
2482 is a string that contains command line option characters. If a character in
2483 <tt/optstring/ is followed by a colon, the option requires an argument. An
2484 option on the command line is recognized if it is one of the option characters
2486 <tt/getopt/ must be called repeatedly. It will return each option character
2487 found on the command line and <tt/EOF/ (-1) if there is no other option. An
2488 option argument is placed in <tt/optarg/, the index of the next element on the
2489 command line to be processed is placed in <tt/optind/.
2490 <tag/Limits/<itemize>
2491 <item>The implementation will not reorder options. A non option on the command
2492 line will terminate option processing. All remaining arguments are not
2493 recognized as options, even if the start with a '-' character.
2494 <item>The function is only available as fastcall function, so it may only
2495 be used in presence of a prototype.
2497 <tag/Availability/POSIX.2
2503 <sect1>gotox<label id="gotox"><p>
2507 <tag/Function/Move the text mode cursor to a new X position.
2508 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2509 <tag/Declaration/<tt/void __fastcall__ gotox (unsigned char x);/
2510 <tag/Description/The function moves the text mode cursor to the specified X
2511 position while leaving the Y position untouched. The leftmost position on the
2512 screen has the coordinate 0.
2513 <tag/Limits/<itemize>
2514 <item>The function is only available as fastcall function, so it may
2515 only be used in presence of a prototype.
2516 <item>Invalid values for the X position (out of screen coordinates) may
2517 lead to undefined behaviour.
2519 <tag/Availability/cc65
2521 <ref id="gotoy" name="gotoy">,
2522 <ref id="gotoxy" name="gotoxy">,
2523 <ref id="wherex" name="wherex">,
2524 <ref id="wherey" name="wherey">
2530 <sect1>gotoxy<label id="gotoxy"><p>
2534 <tag/Function/Move the text mode cursor to a new position.
2535 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2536 <tag/Declaration/<tt/void __fastcall__ gotoxy (unsigned char x, unsigned char y);/
2537 <tag/Description/The function moves the text mode cursor to the specified
2538 position. The leftmost position on the screen has the X coordinate 0, the
2539 topmost line has the Y coordinate 0.
2540 <tag/Limits/<itemize>
2541 <item>The function is only available as fastcall function, so it may only be
2542 used in presence of a prototype.
2543 <item>Invalid values for any of both coordinates (out of screen positions) may
2544 lead to undefined behaviour.
2546 <tag/Availability/cc65
2548 <ref id="gotox" name="gotox">,
2549 <ref id="gotoy" name="gotoy">,
2550 <ref id="wherex" name="wherex">,
2551 <ref id="wherey" name="wherey">
2557 <sect1>gotoy<label id="gotoy"><p>
2561 <tag/Function/Move the text mode cursor to a new Y position.
2562 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2563 <tag/Declaration/<tt/void __fastcall__ gotoy (unsigned char x);/
2564 <tag/Description/The function moves the text mode cursor to the specified Y
2565 position while leaving the X position untouched. The uppermost position on the
2566 screen has the coordinate 0.
2567 <tag/Limits/<itemize>
2568 <item>The function is only available as fastcall function, so it may
2569 only be used in presence of a prototype.
2570 <item>Invalid values for the Y position (out of screen coordinates) may lead
2571 to undefined behaviour.
2573 <tag/Availability/cc65
2575 <ref id="gotox" name="gotox">,
2576 <ref id="gotoxy" name="gotoxy">,
2577 <ref id="wherex" name="wherex">,
2578 <ref id="wherey" name="wherey">
2584 <sect1>isalnum<label id="isalnum"><p>
2588 <tag/Function/Check if a given character is a letter or digit.
2589 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2590 <tag/Declaration/<tt/int __fastcall__ isalnum (int c);/
2591 <tag/Description/The function returns a non zero value if the given argument
2592 is a letter or digit. The return value is zero if the character is anything
2594 <tag/Limits/<itemize>
2595 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2596 inline sequence generated by the macro will not work correctly for values
2597 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2598 this range. The non inline function may be accessed by <tt/#undef/'ing
2600 <item>When compiling without <tt/-Os/, the function is only available as
2601 fastcall function, so it may only be used in presence of a prototype.
2603 <tag/Availability/ISO 9899
2605 <ref id="isalpha" name="isalpha">,
2606 <ref id="isascii" name="isascii">,
2607 <ref id="isblank" name="isblank">,
2608 <ref id="iscntrl" name="iscntrl">,
2609 <ref id="isdigit" name="isdigit">,
2610 <ref id="isgraph" name="isgraph">,
2611 <ref id="islower" name="islower">,
2612 <ref id="isprint" name="isprint">,
2613 <ref id="ispunct" name="ispunct">,
2614 <ref id="isspace" name="isspace">,
2615 <ref id="isupper" name="isupper">,
2616 <ref id="isxdigit" name="isxdigit">
2622 <sect1>isalpha<label id="isalpha"><p>
2626 <tag/Function/Check if a given character is a letter.
2627 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2628 <tag/Declaration/<tt/int __fastcall__ isalpha (int c);/
2629 <tag/Description/The function returns a non zero value if the given argument
2630 is a letter. The return value is zero if the character is anything else.
2631 <tag/Limits/<itemize>
2632 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2633 inline sequence generated by the macro will not work correctly for values
2634 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2635 this range. The non inline function may be accessed by <tt/#undef/'ing the
2637 <item>When compiling without <tt/-Os/, the function is only available as
2638 fastcall function, so it may only be used in presence of a prototype.
2640 <tag/Availability/ISO 9899
2642 <ref id="isalnum" name="isalnum">,
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="isprint" name="isprint">,
2650 <ref id="ispunct" name="ispunct">,
2651 <ref id="isspace" name="isspace">,
2652 <ref id="isupper" name="isupper">,
2653 <ref id="isxdigit" name="isxdigit">
2659 <sect1>isascii<label id="isascii"><p>
2663 <tag/Function/Check if a given character is in the ASCII (0..127) range.
2664 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2665 <tag/Declaration/<tt/int __fastcall__ isascii (int c);/
2666 <tag/Description/The function returns a non zero value if the given argument
2667 is in the range 0..127 (the range of valid ASCII characters) and zero if not.
2668 <tag/Limits/<itemize>
2669 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2670 inline sequence generated by the macro will not work correctly for values
2671 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2672 this range. The non inline function may be accessed by <tt/#undef/'ing the
2674 <item>When compiling without <tt/-Os/, the function is only available as
2675 fastcall function, so it may only be used in presence of a prototype.
2677 <tag/Availability/ISO 9899
2679 <ref id="isalnum" name="isalnum">,
2680 <ref id="isalpha" name="isalpha">,
2681 <ref id="isblank" name="isblank">,
2682 <ref id="iscntrl" name="iscntrl">,
2683 <ref id="isdigit" name="isdigit">,
2684 <ref id="isgraph" name="isgraph">,
2685 <ref id="islower" name="islower">,
2686 <ref id="isprint" name="isprint">,
2687 <ref id="ispunct" name="ispunct">,
2688 <ref id="isspace" name="isspace">,
2689 <ref id="isupper" name="isupper">,
2690 <ref id="isxdigit" name="isxdigit">
2696 <sect1>isblank<label id="isblank"><p>
2700 <tag/Function/Check if a given character is a space or tab.
2701 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2702 <tag/Declaration/<tt/int __fastcall__ isblank (int c);/
2703 <tag/Description/The function returns a non zero value if the given argument
2704 is a space or tab character. The return value is zero if the character is
2706 <tag/Limits/<itemize>
2707 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2708 inline sequence generated by the macro will not work correctly for values
2709 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2710 this range. The non inline function may be accessed by <tt/#undef/'ing the
2712 <item>When compiling without <tt/-Os/, the function is only available as
2713 fastcall function, so it may only be used in presence of a prototype.
2715 <tag/Availability/cc65
2717 <ref id="isalnum" name="isalnum">,
2718 <ref id="isalpha" name="isalpha">,
2719 <ref id="isascii" name="isascii">,
2720 <ref id="iscntrl" name="iscntrl">,
2721 <ref id="isdigit" name="isdigit">,
2722 <ref id="isgraph" name="isgraph">,
2723 <ref id="islower" name="islower">,
2724 <ref id="isprint" name="isprint">,
2725 <ref id="ispunct" name="ispunct">,
2726 <ref id="isspace" name="isspace">,
2727 <ref id="isupper" name="isupper">,
2728 <ref id="isxdigit" name="isxdigit">
2734 <sect1>iscntrl<label id="iscntrl"><p>
2738 <tag/Function/Check if a given character is a control character.
2739 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2740 <tag/Declaration/<tt/int __fastcall__ iscntrl (int c);/
2741 <tag/Description/The function returns a non zero value if the given argument
2742 is a control character. The return value is zero if the character is anything
2744 <tag/Limits/<itemize>
2745 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2746 inline sequence generated by the macro will not work correctly for values
2747 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2748 this range. The non inline function may be accessed by <tt/#undef/'ing the
2750 <item>When compiling without <tt/-Os/, the function is only available as
2751 fastcall function, so it may only be used in presence of a prototype.
2753 <tag/Availability/ISO 9899
2755 <ref id="isalnum" name="isalnum">,
2756 <ref id="isalpha" name="isalpha">,
2757 <ref id="isascii" name="isascii">,
2758 <ref id="isblank" name="isblank">,
2759 <ref id="isdigit" name="isdigit">,
2760 <ref id="isgraph" name="isgraph">,
2761 <ref id="islower" name="islower">,
2762 <ref id="isprint" name="isprint">,
2763 <ref id="ispunct" name="ispunct">,
2764 <ref id="isspace" name="isspace">,
2765 <ref id="isupper" name="isupper">,
2766 <ref id="isxdigit" name="isxdigit">
2772 <sect1>isdigit<label id="isdigit"><p>
2776 <tag/Function/Check if a given character is a digit.
2777 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2778 <tag/Declaration/<tt/int __fastcall__ isdigit (int c);/
2779 <tag/Description/The function returns a non zero value if the given argument
2780 is a digit. The return value is zero if the character is anything else.
2781 <tag/Limits/<itemize>
2782 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2783 inline sequence generated by the macro will not work correctly for values
2784 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2785 this range. The non inline function may be accessed by <tt/#undef/'ing the
2787 <item>When compiling without <tt/-Os/, the function is only available as
2788 fastcall function, so it may only be used in presence of a prototype.
2790 <tag/Availability/ISO 9899
2792 <ref id="isalnum" name="isalnum">,
2793 <ref id="isalpha" name="isalpha">,
2794 <ref id="isascii" name="isascii">,
2795 <ref id="isblank" name="isblank">,
2796 <ref id="iscntrl" name="iscntrl">,
2797 <ref id="isgraph" name="isgraph">,
2798 <ref id="islower" name="islower">,
2799 <ref id="isprint" name="isprint">,
2800 <ref id="ispunct" name="ispunct">,
2801 <ref id="isspace" name="isspace">,
2802 <ref id="isupper" name="isupper">,
2803 <ref id="isxdigit" name="isxdigit">
2809 <sect1>isgraph<label id="isgraph"><p>
2813 <tag/Function/Check if a given character is a printable character (except
2815 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2816 <tag/Declaration/<tt/int __fastcall__ isgraph (int c);/
2817 <tag/Description/The function returns a non zero value if the given argument
2818 is a printable character with the exception of space. The return value is zero
2819 if the character is anything else.
2820 <tag/Limits/<itemize>
2821 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2822 inline sequence generated by the macro will not work correctly for values
2823 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2824 this range. The non inline function may be accessed by <tt/#undef/'ing the
2826 <item>When compiling without <tt/-Os/, the function is only available as
2827 fastcall function, so it may only be used in presence of a prototype.
2829 <tag/Availability/ISO 9899
2831 <ref id="isalnum" name="isalnum">,
2832 <ref id="isalpha" name="isalpha">,
2833 <ref id="isascii" name="isascii">,
2834 <ref id="isblank" name="isblank">,
2835 <ref id="iscntrl" name="iscntrl">,
2836 <ref id="isdigit" name="isdigit">,
2837 <ref id="islower" name="islower">,
2838 <ref id="isprint" name="isprint">,
2839 <ref id="ispunct" name="ispunct">,
2840 <ref id="isspace" name="isspace">,
2841 <ref id="isupper" name="isupper">,
2842 <ref id="isxdigit" name="isxdigit">
2848 <sect1>islower<label id="islower"><p>
2852 <tag/Function/Check if a given character is a lower case letter.
2853 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2854 <tag/Declaration/<tt/int __fastcall__ islower (int c);/
2855 <tag/Description/The function returns a non zero value if the given argument
2856 is a lower case letter. The return value is zero if the character is anything
2858 <tag/Limits/<itemize>
2859 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2860 inline sequence generated by the macro will not work correctly for values
2861 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2862 this range. The non inline function may be accessed by <tt/#undef/'ing the
2864 <item>When compiling without <tt/-Os/, the function is only available as
2865 fastcall function, so it may only be used in presence of a prototype.
2867 <tag/Availability/ISO 9899
2869 <ref id="isalnum" name="isalnum">,
2870 <ref id="isalpha" name="isalpha">,
2871 <ref id="isascii" name="isascii">,
2872 <ref id="isblank" name="isblank">,
2873 <ref id="iscntrl" name="iscntrl">,
2874 <ref id="isdigit" name="isdigit">,
2875 <ref id="isgraph" name="isgraph">,
2876 <ref id="isprint" name="isprint">,
2877 <ref id="ispunct" name="ispunct">,
2878 <ref id="isspace" name="isspace">,
2879 <ref id="isupper" name="isupper">,
2880 <ref id="isxdigit" name="isxdigit">
2886 <sect1>isprint<label id="isprint"><p>
2890 <tag/Function/Check if a given character is a printable character.
2891 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2892 <tag/Declaration/<tt/int __fastcall__ isprint (int c);/
2893 <tag/Description/The function returns a non zero value if the given argument
2894 is a printable character (this includes the space character). The return value
2895 is zero if the character is anything else.
2896 <tag/Limits/<itemize>
2897 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2898 inline sequence generated by the macro will not work correctly for values
2899 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2900 this range. The non inline function may be accessed by <tt/#undef/'ing the
2902 <item>When compiling without <tt/-Os/, the function is only available as
2903 fastcall function, so it may only be used in presence of a prototype.
2905 <tag/Availability/ISO 9899
2907 <ref id="isalnum" name="isalnum">,
2908 <ref id="isalpha" name="isalpha">,
2909 <ref id="isascii" name="isascii">,
2910 <ref id="isblank" name="isblank">,
2911 <ref id="iscntrl" name="iscntrl">,
2912 <ref id="isdigit" name="isdigit">,
2913 <ref id="isgraph" name="isgraph">,
2914 <ref id="islower" name="islower">,
2915 <ref id="ispunct" name="ispunct">,
2916 <ref id="isspace" name="isspace">,
2917 <ref id="isupper" name="isupper">,
2918 <ref id="isxdigit" name="isxdigit">
2924 <sect1>ispunct<label id="ispunct"><p>
2928 <tag/Function/Check if a given character is a printable character but not a
2929 space or an alphanumeric character.
2930 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2931 <tag/Declaration/<tt/int __fastcall__ ispunct (int c);/
2932 <tag/Description/The function returns a non zero value if the given argument
2933 is a printable character, but not a space or anything alphanumeric. The return
2934 value is zero if the character is anything else.
2935 <tag/Limits/<itemize>
2936 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2937 inline sequence generated by the macro will not work correctly for values
2938 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2939 this range. The non inline function may be accessed by <tt/#undef/'ing the
2941 <item>When compiling without <tt/-Os/, the function is only available as
2942 fastcall function, so it may only be used in presence of a prototype.
2944 <tag/Availability/ISO 9899
2946 <ref id="isalnum" name="isalnum">,
2947 <ref id="isalpha" name="isalpha">,
2948 <ref id="isascii" name="isascii">,
2949 <ref id="isblank" name="isblank">,
2950 <ref id="iscntrl" name="iscntrl">,
2951 <ref id="isdigit" name="isdigit">,
2952 <ref id="isgraph" name="isgraph">,
2953 <ref id="islower" name="islower">,
2954 <ref id="isprint" name="isprint">,
2955 <ref id="isspace" name="isspace">,
2956 <ref id="isupper" name="isupper">,
2957 <ref id="isxdigit" name="isxdigit">
2963 <sect1>isspace<label id="isspace"><p>
2967 <tag/Function/Check if a given character is a a white-space character.
2968 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2969 <tag/Declaration/<tt/int __fastcall__ isspace (int c);/
2970 <tag/Description/The function returns a non zero value if the given argument
2971 is a white space character. The return value is zero if the character is
2972 anything else. The standard white space characters are: space, formfeed ('\f'),
2973 newline ('\n'), carriage return ('\r'), horizontal tab ('\t'), and vertical tab
2975 <tag/Limits/<itemize>
2976 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2977 inline sequence generated by the macro will not work correctly for values
2978 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2979 this range. The non inline function may be accessed by <tt/#undef/'ing the
2981 <item>When compiling without <tt/-Os/, the function is only available as
2982 fastcall function, so it may only be used in presence of a prototype.
2984 <tag/Availability/ISO 9899
2986 <ref id="isalnum" name="isalnum">,
2987 <ref id="isalpha" name="isalpha">,
2988 <ref id="isascii" name="isascii">,
2989 <ref id="isblank" name="isblank">,
2990 <ref id="iscntrl" name="iscntrl">,
2991 <ref id="isdigit" name="isdigit">,
2992 <ref id="isgraph" name="isgraph">,
2993 <ref id="islower" name="islower">,
2994 <ref id="isprint" name="isprint">,
2995 <ref id="ispunct" name="ispunct">,
2996 <ref id="isupper" name="isupper">,
2997 <ref id="isxdigit" name="isxdigit">
3003 <sect1>isupper<label id="isupper"><p>
3007 <tag/Function/Check if a given character is an upper case letter.
3008 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
3009 <tag/Declaration/<tt/int __fastcall__ isupper (int c);/
3010 <tag/Description/The function returns a non zero value if the given argument
3011 is an upper case letter. The return value is zero if the character is anything
3013 <tag/Limits/<itemize>
3014 <item>When compiling with <tt/-Os/ the function is actually a macro. The
3015 inline sequence generated by the macro will not work correctly for values
3016 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
3017 this range. The non inline function may be accessed by <tt/#undef/'ing the
3019 <item>When compiling without <tt/-Os/, the function is only available as
3020 fastcall function, so it may only be used in presence of a prototype.
3022 <tag/Availability/ISO 9899
3024 <ref id="isalnum" name="isalnum">,
3025 <ref id="isalpha" name="isalpha">,
3026 <ref id="isascii" name="isascii">,
3027 <ref id="isblank" name="isblank">,
3028 <ref id="iscntrl" name="iscntrl">,
3029 <ref id="isdigit" name="isdigit">,
3030 <ref id="isgraph" name="isgraph">,
3031 <ref id="islower" name="islower">,
3032 <ref id="isprint" name="isprint">,
3033 <ref id="ispunct" name="ispunct">,
3034 <ref id="isspace" name="isspace">,
3035 <ref id="isxdigit" name="isxdigit">
3041 <sect1>isxdigit<label id="isxdigit"><p>
3045 <tag/Function/Check if a given character is a hexadecimal digit.
3046 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
3047 <tag/Declaration/<tt/int __fastcall__ isxdigit (int c);/
3048 <tag/Description/The function returns a non zero value if the given argument
3049 is a hexadecimal digit (0..9, a..f and A..F). The return value is zero if the
3050 character is anything else.
3051 <tag/Limits/<itemize>
3052 <item>When compiling with <tt/-Os/ the function is actually a macro. The
3053 inline sequence generated by the macro will not work correctly for values
3054 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
3055 this range. The non inline function may be accessed by <tt/#undef/'ing the
3057 <item>When compiling without <tt/-Os/, the function is only available as
3058 fastcall function, so it may only be used in presence of a prototype.
3060 <tag/Availability/ISO 9899
3062 <ref id="isalnum" name="isalnum">,
3063 <ref id="isalpha" name="isalpha">,
3064 <ref id="isascii" name="isascii">,
3065 <ref id="isblank" name="isblank">,
3066 <ref id="iscntrl" name="iscntrl">,
3067 <ref id="isdigit" name="isdigit">,
3068 <ref id="isgraph" name="isgraph">,
3069 <ref id="islower" name="islower">,
3070 <ref id="isprint" name="isprint">,
3071 <ref id="ispunct" name="ispunct">,
3072 <ref id="isspace" name="isspace">,
3073 <ref id="isupper" name="isupper">
3079 <sect1>itoa<label id="itoa"><p>
3083 <tag/Function/Convert an integer into a string.
3084 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
3085 <tag/Declaration/<tt/char* __fastcall__ itoa (int val, char* buf, int radix);/
3086 <tag/Description/<tt/itoa/ converts the integer <tt/val/ into a string using
3087 <tt/radix/ as the base.
3088 <tag/Limits/<itemize>
3089 <item>There are no provisions to prevent a buffer overflow.
3090 <item>If <tt/val/ contains <tt/INT_MIN/, the behaviour is undefined.
3091 <item>The function is non standard, so it is not available in strict ANSI mode.
3092 You should probably use <tt/sprintf/ instead.
3093 <item>The function is only available as fastcall function, so it may only be
3094 used in presence of a prototype.
3096 <tag/Availability/cc65
3098 <ref id="atoi" name="atoi">,
3099 <ref id="atol" name="atol">,
3100 <ref id="ltoa" name="ltoa">,
3101 <ref id="ultoa" name="ultoa">,
3102 <ref id="utoa" name="utoa">
3108 <sect1>joy_count<label id="joy_count"><p>
3112 <tag/Function/Return the number of joysticks supported by the current driver.
3113 <tag/Header/<tt/<ref id="joystick.h" name="joystick.h">/
3114 <tag/Declaration/<tt/unsigned char joy_count (void);/
3115 <tag/Description/The function returns a the number of joysticks supported
3116 by the current joystick driver.
3117 <tag/Limits/<itemize>
3118 <item>A joystick driver must be loaded using <ref id="joy_load_driver"
3119 name="joy_load_driver"> before calling this function.
3120 <item>The function returns the number of joysticks supported by the driver.
3121 There's no way to check for the number of actually connected joysticks.
3123 <tag/Availability/cc65
3125 <ref id="joy_load_driver" name="joy_load_driver">,
3126 <ref id="joy_read" name="joy_read">
3132 <sect1>joy_install<label id="joy_install"><p>
3136 <tag/Function/Install an already loaded driver and return an error code.
3137 <tag/Header/<tt/<ref id="joystick.h" name="joystick.h">/
3138 <tag/Declaration/<tt/unsigned char __fastcall__ joy_install (void* driver);/
3139 <tag/Description/The function installs a driver that was already loaded into
3140 memory (or linked statically to the program). It returns an error code
3141 (<tt/JOY_ERR_OK/ in case of success).
3142 <tag/Limits/<itemize>
3143 <item>The function is only available as fastcall function, so it may only be
3144 used in presence of a prototype.
3146 <tag/Availability/cc65
3148 <ref id="joy_load_driver" name="joy_load_driver">,
3149 <ref id="joy_uninstall" name="joy_uninstall">,
3150 <ref id="joy_unload" name="joy_unload">
3156 <sect1>joy_load_driver<label id="joy_load_driver"><p>
3160 <tag/Function/Load a driver from disk and install it.
3161 <tag/Header/<tt/<ref id="joystick.h" name="joystick.h">/
3162 <tag/Declaration/<tt/unsigned char __fastcall__ joy_load_driver (const char* driver);/
3163 <tag/Description/The function loads a driver with the given name from disk
3164 and installs it. An error code is returned, which is <tt/JOY_ERR_OK/ if the
3165 driver was successfully loaded and installed.
3166 <tag/Limits/<itemize>
3167 <item>The function is only available as fastcall function, so it may only be
3168 used in presence of a prototype.
3170 <tag/Availability/cc65
3172 <ref id="joy_install" name="joy_install">,
3173 <ref id="joy_uninstall" name="joy_uninstall">,
3174 <ref id="joy_unload" name="joy_unload">
3180 <sect1>joy_read<label id="joy_read"><p>
3184 <tag/Function/Read the status of a joystick.
3185 <tag/Header/<tt/<ref id="joystick.h" name="joystick.h">/
3186 <tag/Declaration/<tt/unsigned char __fastcall__ joy_read (unsigned char joystick);/
3187 <tag/Description/The function reads the status bits for a joystick. The number
3188 of the joystick is passed as parameter. The result may be examined by using one
3189 of the <tt/JOY_xxx/ macros from <ref id="joystick.h" name="joystick.h">.
3190 <tag/Limits/<itemize>
3191 <item>A joystick driver must be loaded using <ref id="joy_load_driver"
3192 name="joy_load_driver"> before calling this function.
3193 <item>The function is only available as fastcall function, so it may only be
3194 used in presence of a prototype.
3196 <tag/Availability/cc65
3198 <ref id="joy_count" name="joy_count">,
3199 <ref id="joy_load_driver" name="joy_load_driver">,
3200 <ref id="joy_unload" name="joy_unload">
3206 <sect1>joy_uninstall<label id="joy_uninstall"><p>
3210 <tag/Function/Uninstall the current joystick driver.
3211 <tag/Header/<tt/<ref id="joystick.h" name="joystick.h">/
3212 <tag/Declaration/<tt/unsigned char joy_uninstall (void);/
3213 <tag/Description/The function uninstalls the currently installed joystick
3214 driver. It does not remove the driver from memory. The function returns an
3215 error code, which is <tt/JOY_ERR_OK/ if the driver was successfully uninstalled.
3216 <tag/Limits/<itemize>
3217 <item>A joystick driver must be installed using <ref id="joy_install"
3218 name="joy_install"> before calling this function.
3220 <tag/Availability/cc65
3222 <ref id="joy_install" name="joy_install">,
3223 <ref id="joy_load_driver" name="joy_load_driver">,
3224 <ref id="joy_unload" name="joy_unload">
3230 <sect1>joy_unload<label id="joy_unload"><p>
3234 <tag/Function/Uninstall, then unload the current joystick driver.
3235 <tag/Header/<tt/<ref id="joystick.h" name="joystick.h">/
3236 <tag/Declaration/<tt/unsigned char joy_unload (void);/
3237 <tag/Description/The function uninstalls the currently installed joystick
3238 driver and removes it from memory. An error code is returned, which is
3239 <tt/JOY_ERR_OK/ if the driver was successfully uninstalled.
3240 <tag/Limits/<itemize>
3241 <item>A joystick driver must be loaded using <ref id="joy_load_driver"
3242 name="joy_load_driver"> before calling this function.
3244 <tag/Availability/cc65
3246 <ref id="joy_load_driver" name="joy_load_driver">
3252 <sect1>kbhit<label id="kbhit"><p>
3256 <tag/Function/Check if there's a key waiting in the keyboard buffer.
3257 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
3258 <tag/Declaration/<tt/unsigned char kbhit (void);/
3259 <tag/Description/The function returns a value of zero if there is no character
3260 waiting to be read from the keyboard. It returns non zero otherwise.
3261 <tag/Limits/<itemize>
3262 <item>If the system does not support a keyboard buffer (most systems
3263 do), the function is rather useless.
3265 <tag/Availability/cc65
3267 <ref id="cgetc" name="cgetc">,
3268 <ref id="cursor" name="cursor">
3274 <sect1>labs<label id="labs"><p>
3278 <tag/Function/Returns the absolute value of a long integer.
3279 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
3280 <tag/Declaration/<tt/long __fastcall__ labs (long v);/
3281 <tag/Description/<tt/labs/ returns the absolute value of the argument passed to
3283 <tag/Limits/<itemize>
3284 <item>The return value is undefined if <tt/LONG_MIN/ is passed to the function.
3285 <item>The function is only available as fastcall function, so it may only be
3286 used in presence of a prototype.
3288 <tag/Availability/ISO 9899
3290 <ref id="abs" name="abs">
3296 <sect1>ltoa<label id="ltoa"><p>
3300 <tag/Function/Convert a long integer into a string.
3301 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
3302 <tag/Declaration/<tt/char* __fastcall__ ltoa (long val, char* buf, int radix);/
3303 <tag/Description/<tt/itoa/ converts the long integer <tt/val/ into a string
3304 using <tt/radix/ as the base.
3305 <tag/Limits/<itemize>
3306 <item>There are no provisions to prevent a buffer overflow.
3307 <item>If <tt/val/ contains <tt/LONG_MIN/, the behaviour is undefined.
3308 <item>The function is non standard, so it is not available in strict ANSI mode.
3309 You should probably use <tt/sprintf/ instead.
3310 <item>The function is only available as fastcall function, so it may only be
3311 used in presence of a prototype.
3313 <tag/Availability/cc65
3315 <ref id="atoi" name="atoi">,
3316 <ref id="atol" name="atol">,
3317 <ref id="itoa" name="itoa">,
3318 <ref id="ultoa" name="ultoa">,
3319 <ref id="utoa" name="utoa">
3325 <sect1>localeconv<label id="localeconv"><p>
3329 <tag/Function/Returns a pointer to the current locale structure.
3330 <tag/Header/<tt/<ref id="locale.h" name="locale.h">/
3331 <tag/Declaration/<tt/struct lconv* localeconv (void);/
3332 <tag/Description/<tt/localeconv/ returns a pointer to the current locale
3334 <tag/Limits/<itemize>
3335 <item>cc65 supports only the "C" locale, so even after setting a new locale
3336 using <tt/<ref id="setlocale" name="setlocale">/, the structure returned will
3339 <tag/Availability/ISO 9899
3341 <ref id="setlocale" name="setlocale">
3347 <sect1>longjmp<label id="longjmp"><p>
3351 <tag/Function/Non local goto.
3352 <tag/Header/<tt/<ref id="setjmp.h" name="setjmp.h">/
3353 <tag/Declaration/<tt/void __fastcall__ longjmp (jmp_buf buf, int retval);/
3354 <tag/Description/The <tt/longjmp/ function restores a program context from the
3355 data in <tt/buf/, which must have been set by a preceeding call to
3356 <tt/<ref id="setjmp" name="setjmp">/. Program execution continues as if the
3357 call to <tt/<ref id="setjmp" name="setjmp">/ has just returned the value
3361 <item>If the parameter <tt/retval/ is zero, the function will behave as if it
3362 was called with a value of one.
3363 <item>The function is only available as fastcall function, so it may only
3364 be used in presence of a prototype.
3366 <tag/Availability/ISO 9899
3368 <ref id="setjmp" name="setjmp">
3374 <sect1>malloc<label id="malloc"><p>
3378 <tag/Function/Allocate dynamic memory.
3379 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
3380 <tag/Declaration/<tt/void* __fastcall__ malloc (size_t size);/
3381 <tag/Description/<tt/malloc/ allocates size bytes on the heap and returns a
3382 pointer to the allocated memory block. On error (not enough memory available),
3383 <tt/malloc/ returns <tt/NULL/.
3386 <item>The function is only available as fastcall function, so it may only
3387 be used in presence of a prototype.
3389 <tag/Availability/ISO 9899
3391 <ref id="_heapadd" name="_heapadd">,
3392 <ref id="_heapblocksize" name="_heapblocksize">,
3393 <ref id="_heapmaxavail" name="_heapmaxavail">,
3394 <ref id="_heapmemavail" name="_heapmemavail">,
3395 <ref id="calloc" name="calloc">,
3396 <ref id="free" name="free">,
3397 <ref id="realloc" name="realloc">,
3398 <ref id="strdup" name="strdup">
3404 <sect1>memchr<label id="memchr"><p>
3408 <tag/Function/Search for a character in a block of raw memory.
3409 <tag/Header/<tt/<ref id="string.h" name="string.h">/
3410 <tag/Declaration/<tt/void* __fastcall__ strchr (const void* mem, int c, size_t count);/
3411 <tag/Description/The <tt/memchr/ function locates the first occurrence of <tt/c/
3412 (converted to a char) in the block of raw memory string pointed to by <tt/mem/
3413 that is of size <tt/count/. Upon completion, the function returns a pointer to
3414 the character found, or a null pointer if the character was not found.
3415 <tag/Limits/<itemize>
3416 <item>The function is only available as fastcall function, so it may only
3417 be used in presence of a prototype.
3419 <tag/Availability/ISO 9899
3421 <ref id="strchr" name="strchr">
3427 <sect1>memcmp<label id="memcmp"><p>
3431 <tag/Function/Compare two memory areas.
3432 <tag/Header/<tt/<ref id="string.h" name="string.h">/
3433 <tag/Declaration/<tt/int __fastcall__ memcmp (const void* p1, const void* p2, size_t count);/
3434 <tag/Description/<tt/memcmp/ compares <tt/count/ bytes from the memory area
3435 pointed to by <tt/p1/ into the memory area pointed to by <tt/p2/. It returns a value that is less than
3436 zero if <tt/p1/ is less than <tt/p2/, zero if <tt/p1/ is the same as <tt/p2/,
3437 and a value greater than zero if <tt/p1/ is greater than <tt/p2/.
3440 <item>The function is only available as fastcall function, so it may only
3441 be used in presence of a prototype.
3443 <tag/Availability/ISO 9899
3445 <ref id="strcmp" name="strcmp">,
3446 <ref id="memmove" name="memmove">,
3447 <ref id="memset" name="memset">
3453 <sect1>memcpy<label id="memcpy"><p>
3457 <tag/Function/Copy a memory area.
3458 <tag/Header/<tt/<ref id="string.h" name="string.h">/
3459 <tag/Declaration/<tt/void* __fastcall__ memcpy (void* dest, const void* src, size_t count);/
3460 <tag/Description/<tt/memcpy/ copies <tt/count/ bytes from the memory area
3461 pointed to by <tt/src/ into the memory area pointed to by <tt/dest/. It returns
3465 <item>The result is undefined if the memory areas do overlap. Use
3466 <tt/<ref id="memmove" name="memmove">/ to copy overlapping memory areas.
3467 <item>The function is only available as fastcall function, so it may only
3468 be used in presence of a prototype.
3470 <tag/Availability/ISO 9899
3472 <ref id="_swap" name="_swap">,
3473 <ref id="memmove" name="memmove">,
3474 <ref id="memset" name="memset">
3480 <sect1>memmove<label id="memmove"><p>
3484 <tag/Function/Copy a memory area.
3485 <tag/Header/<tt/<ref id="string.h" name="string.h">/
3486 <tag/Declaration/<tt/void* __fastcall__ memmove (void* dest, const void* src, size_t count);/
3487 <tag/Description/<tt/memmove/ copies <tt/count/ bytes from the memory area
3488 pointed to by <tt/src/ into the memory area pointed to by <tt/dest/. It returns
3492 <item>While <tt/memmove/ allows the memory areas to overlap, it has some
3493 additional overhead compared to <tt/<ref id="memcpy" name="memcpy">/.
3494 <item>The function is only available as fastcall function, so it may only
3495 be used in presence of a prototype.
3497 <tag/Availability/ISO 9899
3499 <ref id="_swap" name="_swap">,
3500 <ref id="memcpy" name="memcpy">,
3501 <ref id="memset" name="memset">
3507 <sect1>memset<label id="memset"><p>
3511 <tag/Function/Fill a memory area.
3512 <tag/Header/<tt/<ref id="string.h" name="string.h">/
3513 <tag/Declaration/<tt/void* __fastcall__ memset (void* p, int val, size_t count);/
3514 <tag/Description/<tt/memset/ fills the memory area pointed to by <tt/p/ with
3515 the value <tt/val/. The function returns <tt/p/.
3518 <item>The function is only available as fastcall function, so it may only
3519 be used in presence of a prototype.
3521 <tag/Availability/ISO 9899
3523 <ref id="_swap" name="_swap">,
3524 <ref id="bzero" name="bzero">,
3525 <ref id="memcpy" name="memcpy">,
3526 <ref id="memmove" name="memmove">
3532 <sect1>mod_free<label id="mod_free"><p>
3536 <tag/Function/Free a relocatable module.
3537 <tag/Header/<tt/<ref id="modload.h" name="modload.h">/
3538 <tag/Declaration/<tt/void __fastcall__ mod_free (void* module);/
3539 <tag/Description/The function will free a module loaded into memory by use of
3540 the <tt/<ref id="mod_load" name="mod_load">/ function.
3541 <tag/Limits/<itemize>
3542 <item>The pointer passed as parameter is the pointer to the module memory,
3543 not the pointer to the control structure.
3545 <tag/Availability/cc65
3547 <ref id="mod_load" name="mod_load">
3553 <sect1>mod_load<label id="mod_load"><p>
3557 <tag/Function/Load a relocatable module.
3558 <tag/Header/<tt/<ref id="modload.h" name="modload.h">/
3559 <tag/Declaration/<tt/unsigned char mod_load (struct mod_ctrl* ctrl);/
3560 <tag/Description/The function will load a code module into memory and relocate
3561 it. The function will return an error code. If <tt/MLOAD_OK/ is returned, the
3562 outgoing fields in the passed <tt/mod_ctrl/ struct contain information about
3563 the module just loaded. Possible error codes are:
3565 <item><tt/MLOAD_OK/ - Module load successful
3566 <item><tt/MLOAD_ERR_READ/ - Read error
3567 <item><tt/MLOAD_ERR_HDR/ - Header error
3568 <item><tt/MLOAD_ERR_OS/ - Wrong operating system
3569 <item><tt/MLOAD_ERR_FMT/ - Data format error
3570 <item><tt/MLOAD_ERR_MEM/ - Not enough memory
3572 <tag/Limits/<itemize>
3573 <item>The <htmlurl url="ld65.html" name="ld65"> linker is needed to create
3574 relocatable o65 modules for use with this function.
3576 <tag/Availability/cc65
3578 <ref id="mod_free" name="mod_free">
3584 <sect1>mouse_setbox<label id="mouse_setbox"><p>
3588 <tag/Function/Specify a bounding box for the mouse cursor.
3589 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3590 <tag/Declaration/<tt/void __fastcall__ mouse_setbox (const struct mouse_box* box);/
3591 <tag/Description/The function allows to set a bounding box for mouse movement.
3592 <tag/Limits/<itemize>
3593 <item>The function does not check if the mouse cursor is currently within the
3594 given rectangle. Placing the mouse cursor within the bounding box is the
3595 responsibility of the programmer.
3596 <item>While the bounding box may be larger than the actual screen size, the
3597 standard mouse cursor draw routines may fail to set the cursor to coordinates
3598 outside of the screen area. Depending on the platform, you may have to supply
3599 your own mouse cursor routines.
3600 <item>The function is only available as fastcall function, so it may only be
3601 used in presence of a prototype.
3603 <tag/Availability/cc65
3605 <ref id="mouse_getbox" name="mouse_getbox">,
3606 <ref id="mouse_move" name="mouse_move">
3612 <sect1>mouse_getbox<label id="mouse_getbox"><p>
3616 <tag/Function/Return the current bounding box for the mouse cursor.
3617 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3618 <tag/Declaration/<tt/void __fastcall__ mouse_getbox (struct mouse_box* box);/
3619 <tag/Description/The function queries the current bounding box for mouse
3621 <tag/Limits/<itemize>
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_move" name="mouse_move">,
3628 <ref id="mouse_setbox" name="mouse_setbox">
3634 <sect1>mouse_buttons<label id="mouse_buttons"><p>
3638 <tag/Function/Return a bit mask encoding the state of the mouse buttons.
3639 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3640 <tag/Declaration/<tt/unsigned char mouse_buttons (void);/
3641 <tag/Description/The function returns a bit mask that encodes the state of the
3642 mouse buttons. You may use the <tt/MOUSE_BTN_XXX/ flags to decode the function
3644 <tag/Availability/cc65
3646 <ref id="mouse_info" name="mouse_info">,
3647 <ref id="mouse_pos" name="mouse_pos">
3653 <sect1>mouse_geterrormsg<label id="mouse_geterrormsg"><p>
3657 <tag/Function/Return a readable error message for an error code.
3658 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3659 <tag/Declaration/<tt/const char* __fastcall__ mouse_geterrormsg (unsigned char
3661 <tag/Description/The function returns an error message (in english) for the
3662 error code passed parameter.
3663 <tag/Limits/<itemize>
3664 <item>The function will return "Unknown error" for invalid error codes.
3665 <item>The function is only available as fastcall function, so it may only be
3666 used in presence of a prototype.
3668 <tag/Availability/cc65
3670 <ref id="mouse_load_driver" name="mouse_load_driver">,
3671 <ref id="mouse_uninstall" name="mouse_uninstall">,
3672 <ref id="mouse_unload" name="mouse_unload">
3678 <sect1>mouse_hide<label id="mouse_hide"><p>
3682 <tag/Function/Hide the mouse pointer.
3683 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3684 <tag/Declaration/<tt/void mouse_hide (void);/
3685 <tag/Description/The function hides the mouse pointer. It manages a counter
3686 that is shared between <tt/<ref id="mouse_show" name="mouse_show">/ and
3687 <tt/mouse_hide/ so that every call call to <tt/mouse_hide/ must be followed by
3688 a call to <tt/<ref id="mouse_show" name="mouse_show">/ to make the mouse cursor
3690 <tag/Availability/cc65
3692 <ref id="mouse_show" name="mouse_show">
3698 <sect1>mouse_info<label id="mouse_info"><p>
3702 <tag/Function/Return the state of the mouse buttons and the position of the
3704 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3705 <tag/Declaration/<tt/void __fastcall__ mouse_info (struct mouse_info* info);/
3706 <tag/Description/The function returns the state of the mouse buttons and the
3707 position of the mouse in the <tt/mouse_info/ structure passed as parameter.
3708 <tag/Limits/<itemize>
3709 <item>The <tt/mouse_info/ struct is a superset of the <tt/mouse_pos/ struct,
3710 so if you just need the mouse position, call <tt/<ref id="mouse_pos"
3711 name="mouse_pos">/ instead.
3712 <item>The function is only available as fastcall function, so it may only be
3713 used in presence of a prototype.
3715 <tag/Availability/cc65
3717 <ref id="mouse_buttons" name="mouse_buttons">,
3718 <ref id="mouse_pos" name="mouse_pos">
3724 <sect1>mouse_install<label id="mouse_install"><p>
3728 <tag/Function/Install an already loaded mouse driver.
3729 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3730 <tag/Declaration/<tt/unsigned char __fastcall__ mouse_install (const struct
3731 mouse_callbacks* c, void* driver);/
3732 <tag/Description/The function installs an already loaded mouse driver and
3733 returns an error code. The <tt/mouse_callbacks/ structure passed as first
3734 parameter contains pointers to routines needed to move or hide/show the mouse
3735 pointer. Defaults for these routines are supplied by the library, so if you
3736 can live with these defaults (which are platform specific), just pass a
3737 pointer to <tt/mouse_def_callbacks/. The function may be used to install a
3738 driver linked statically to the program.
3739 <tag/Limits/<itemize>
3740 <item>Not all drivers are able to detect if the supported hardware is really
3742 <item>After installing a driver, the mouse cursor is hidden.
3743 <item>The function is only available as fastcall function, so it may only be
3744 used in presence of a prototype.
3746 <tag/Availability/cc65
3748 <ref id="mouse_load_driver" name="mouse_load_driver">,
3749 <ref id="mouse_uninstall" name="mouse_uninstall">,
3750 <ref id="mouse_unload" name="mouse_unload">
3756 <sect1>mouse_ioctl<label id="mouse_ioctl"><p>
3760 <tag/Function/Call the driver specific ioctl function.
3761 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3762 <tag/Declaration/<tt/unsigned char __fastcall__ mouse_ioctl (unsigned char code, void* data);/
3763 <tag/Description/The function calls the IOCTL entry in the mouse driver,
3764 which is driver specific. The <tt/code/ parameter will choose between
3765 different IOCTL functions, and the <tt/data/ depends on code. The
3766 function returns an error code. The purpose of this function is to allow
3767 for driver specific extensions. See the documentation for a specific mouse
3768 driver for supported ioctl calls.
3769 <tag/Limits/<itemize>
3770 <item>Calling this function is non portable, because each driver may
3771 implement different ioctl calls (or none at all).
3772 <item>The function is only available as fastcall function, so it may only be
3773 used in presence of a prototype.
3775 <tag/Availability/cc65
3781 <sect1>mouse_load_driver<label id="mouse_load_driver"><p>
3785 <tag/Function/Load and initialize a mouse driver.
3786 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3787 <tag/Declaration/<tt/unsigned char __fastcall__ mouse_load_driver (const struct
3788 mouse_callbacks* c, const char* driver);/
3789 <tag/Description/Load a mouse driver into memory and initialize it. The
3790 function returns an error code that tells if the call has been successful. The
3791 <tt/mouse_callbacks/ structure passed as first parameter contains pointers to
3792 routines needed to move or hide/show the mouse pointer. Defaults for these
3793 routines are supplied by the library, so if you can live with these defaults
3794 (which are platform specific), just pass a pointer to <tt/mouse_def_callbacks/.
3795 <tag/Limits/<itemize>
3796 <item>The driver is loaded by name, so currently you must know the type of
3797 mouse that should be supported. There is no autodetect capability.
3798 <item>Not all drivers are able to detect if the supported hardware is really
3800 <item>After installing a driver, the mouse cursor is hidden.
3801 <item>The function is only available as fastcall function, so it may only be
3802 used in presence of a prototype.
3804 <tag/Availability/cc65
3806 <ref id="mouse_install" name="mouse_install">,
3807 <ref id="mouse_uninstall" name="mouse_uninstall">,
3808 <ref id="mouse_unload" name="mouse_unload">
3814 <sect1>mouse_move<label id="mouse_move"><p>
3818 <tag/Function/Move the mouse cursor to a specific position.
3819 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3820 <tag/Declaration/<tt/void __fastcall__ mouse_move (int x, int y);/
3821 <tag/Description/The function updates the mouse position. If the mouse cursor
3822 is visible, it is shown at the new position.
3823 <tag/Limits/<itemize>
3824 <item>The function does not check if the new position is within the bounding
3825 box specified with <tt/<ref id="mouse_setbox" name="mouse_setbox">/.
3826 <item>The function is only available as fastcall function, so it may only be
3827 used in presence of a prototype.
3829 <tag/Availability/cc65
3831 <ref id="mouse_getbox" name="mouse_getbox">,
3832 <ref id="mouse_setbox" name="mouse_setbox">
3838 <sect1>mouse_pos<label id="mouse_pos"><p>
3842 <tag/Function/Return the position of the mouse.
3843 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3844 <tag/Declaration/<tt/void __fastcall__ mouse_pos (struct mouse_pos* pos);/
3845 <tag/Description/The function returns the position of the mouse in the
3846 <tt/mouse_pos/ structure passed as parameter.
3847 <tag/Limits/<itemize>
3848 <item>The <tt/mouse_pos/ struct is a subset of the <tt/mouse_info/ struct,
3849 so if you do also need the mouse buttons, call <tt/<ref id="mouse_info"
3850 name="mouse_info">/ instead.
3851 <item>The function is only available as fastcall function, so it may only be
3852 used in presence of a prototype.
3854 <tag/Availability/cc65
3856 <ref id="mouse_buttons" name="mouse_buttons">,
3857 <ref id="mouse_info" name="mouse_info">
3863 <sect1>mouse_show<label id="mouse_show"><p>
3867 <tag/Function/Show the mouse pointer.
3868 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3869 <tag/Declaration/<tt/void mouse_show (void);/
3870 <tag/Description/The function shows the mouse pointer. It manages a counter
3871 that is shared between <tt/<ref id="mouse_hide" name="mouse_hide">/ and
3872 <tt/mouse_show/. The mouse cursor is visible if there was one more call to
3873 <tt/mouse_show/ than to <tt/<ref id="mouse_hide" name="mouse_hide">/.
3874 <tag/Availability/cc65
3876 <ref id="mouse_hide" name="mouse_hide">
3882 <sect1>mouse_uninstall<label id="mouse_uninstall"><p>
3886 <tag/Function/Uninstall an already loaded mouse driver.
3887 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3888 <tag/Declaration/<tt/unsigned char mouse_uninstall (void);/
3889 <tag/Description/The function uninstalls an already loaded mouse driver but
3890 don't removes it from memory.
3891 <tag/Limits/<itemize>
3892 <item>If the driver has been loaded using <tt/<ref id="mouse_load_driver"
3893 name="mouse_load_driver">/, <tt/<ref id="mouse_unload" name="mouse_unload">/
3894 should be used instead of <tt/mouse_uninstall/ so the driver is also removed
3897 <tag/Availability/cc65
3899 <ref id="mouse_install" name="mouse_install">,
3900 <ref id="mouse_load_driver" name="mouse_load_driver">,
3901 <ref id="mouse_unload" name="mouse_unload">
3907 <sect1>mouse_unload<label id="mouse_unload"><p>
3911 <tag/Function/Unload a mouse driver.
3912 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3913 <tag/Declaration/<tt/unsigned char __fastcall__ mouse_unload (void);/
3914 <tag/Description/The function unloads a loaded mouse driver and frees all
3915 memory allocated for the driver.
3916 <tag/Limits/<itemize>
3917 <item>The function does nothing if no driver is loaded.
3919 <tag/Availability/cc65
3921 <ref id="mouse_install" name="mouse_install">,
3922 <ref id="mouse_load_driver" name="mouse_load_driver">,
3923 <ref id="mouse_uninstall" name="mouse_uninstall">
3929 <sect1>offsetof<label id="offsetof"><p>
3933 <tag/Function/Calculate the offset of a struct or union member.
3934 <tag/Header/<tt/<ref id="stddef.h" name="stddef.h">/
3935 <tag/Declaration/<tt/size_t offsetof (type, member);/
3936 <tag/Description/<tt/offsetof/ calculates the address offset of a <tt/struct/
3937 or <tt/union/ member.
3938 <tag/Limits/<itemize>
3939 <item>The function is actually a macro.
3941 <tag/Availability/ISO 9899
3947 <sect1>open<label id="open"><p>
3951 <tag/Function/Open and possibly create a file.
3952 <tag/Header/<tt/<ref id="fcntl.h" name="fcntl.h">/
3953 <tag/Declaration/<tt/int open (const char* name, int flags, ...);/
3954 <tag/Description/<tt/open/ opens a file and returns the file descriptor
3955 associated with it. On error, -1 is returned and an error code is stored in
3956 <tt/errno/. Several flags may be passed to <tt/open/ that change the behaviour.
3957 <tag/Limits/<itemize>
3958 <item>POSIX specifies an additional <tt/mode/ argument that may be passed to
3959 open, which is used as the permission mask when a new file is created. While
3960 cc65 allows to pass this argument, it is ignored.
3962 <tag/Availability/POSIX 1003.1
3964 <ref id="close" name="close">,
3965 <ref id="creat" name="creat">
3971 <sect1>opendir<label id="opendir"><p>
3975 <tag/Function/Open a directory.
3976 <tag/Header/<tt/<ref id="dirent.h" name="dirent.h">/
3977 <tag/Declaration/<tt/DIR* __fastcall__ opendir (const char* name);/
3978 <tag/Description/<tt/opendir/ opens a directory and returns the direcory
3979 descriptor associated with it. On error, NULL is returned and an error code is
3980 stored in <tt/errno/.
3981 <tag/Limits/<itemize>
3982 <item>The function is only available as fastcall function, so it may only
3983 be used in presence of a prototype.
3985 <tag/Availability/POSIX 1003.1
3987 <ref id="closedir" name="closedir">,
3988 <ref id="readdir" name="readdir">
3994 <sect1>peekbsys<label id="peekbsys"><p>
3998 <tag/Function/Read one byte from a location in the system bank.
3999 <tag/Header/<tt/<ref id="cbm610.h" name="cbm610.h">/,
4000 <tt/<ref id="cbm510.h" name="cbm510.h">/
4001 <tag/Declaration/<tt/unsigned char __fastcall__ peekbsys (unsigned addr);/
4002 <tag/Description/<tt/peekbsys/ reads one byte from the given address in the
4003 system bank (bank 15) of the CBM PET-II machines and returns it.
4006 <item>The function is only available as fastcall function, so it may only
4007 be used in presence of a prototype.
4008 <item>This function may be a macro depending on the compiler options. The
4009 actual function is accessible by #undef'ing the macro.
4011 <tag/Availability/cc65
4013 <ref id="PEEK" name="PEEK">,
4014 <ref id="PEEKW" name="PEEKW">,
4015 <ref id="peekwsys" name="peekwsys">,
4016 <ref id="pokebsys" name="pokebsys">,
4017 <ref id="pokewsys" name="pokewsys">
4023 <sect1>peekwsys<label id="peekwsys"><p>
4027 <tag/Function/Read one word from a location in the system bank.
4028 <tag/Header/<tt/<ref id="cbm610.h" name="cbm610.h">/,
4029 <tt/<ref id="cbm510.h" name="cbm510.h">/
4030 <tag/Declaration/<tt/unsigned __fastcall__ peekwsys (unsigned addr);/
4031 <tag/Description/<tt/peekwsys/ reads one word from the given address in the
4032 system bank (bank 15) of the CBM PET-II machines and returns it. Following
4033 the usual 6502 conventions, the low byte is read from <tt/addr/, and the
4034 high byte is read from <tt/addr+1/.
4037 <item>The function is only available as fastcall function, so it may only
4038 be used in presence of a prototype.
4039 <item>The order in which the two bytes are read is undefined.
4041 <tag/Availability/cc65
4043 <ref id="PEEK" name="PEEK">,
4044 <ref id="PEEKW" name="PEEKW">,
4045 <ref id="peekbsys" name="peekbsys">,
4046 <ref id="pokebsys" name="pokebsys">,
4047 <ref id="pokewsys" name="pokewsys">
4053 <sect1>perror<label id="perror"><p>
4057 <tag/Function/Print an error message for the error in <tt/errno/.
4058 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
4059 <tag/Declaration/<tt/void __fastcall__ perror (const char* s);/
4060 <tag/Description/<tt/perror/ prints an error message to <tt/stderr/. If <tt/s/
4061 is not <tt/NULL/ and not an empty string, it is printed followed by a colon and
4062 a blank. Then the error message for the current contents of <tt/errno/ is
4063 printed followed by a newline. The message output is the same as returned by
4064 <tt/<ref id="strerror" name="strerror">/ with an argument of <tt/errno/.
4067 <item>The function is only available as fastcall function, so it may only
4068 be used in presence of a prototype.
4070 <tag/Availability/ISO 9899
4072 <ref id="_poserror" name="_poserror">,
4073 <ref id="strerror" name="strerror">
4079 <sect1>pokebsys<label id="pokebsys"><p>
4083 <tag/Function/Write one byte to a location in the system bank.
4084 <tag/Header/<tt/<ref id="cbm610.h" name="cbm610.h">/,
4085 <tt/<ref id="cbm510.h" name="cbm510.h">/
4086 <tag/Declaration/<tt/void __fastcall__ pokebsys (unsigned addr, unsigned char val);/
4087 <tag/Description/<tt/pokebsys/ writes one byte to the given address in the
4088 system bank (bank 15) of the CBM PET-II machines.
4091 <item>The function is only available as fastcall function, so it may only
4092 be used in presence of a prototype.
4094 <tag/Availability/cc65
4096 <ref id="POKE" name="POKE">,
4097 <ref id="POKEW" name="POKEW">,
4098 <ref id="peekbsys" name="peekbsys">,
4099 <ref id="peekwsys" name="peekwsys">,
4100 <ref id="pokewsys" name="pokewsys">
4106 <sect1>pokewsys<label id="pokewsys"><p>
4110 <tag/Function/Write one word to a location in the system bank.
4111 <tag/Header/<tt/<ref id="cbm610.h" name="cbm610.h">/,
4112 <tt/<ref id="cbm510.h" name="cbm510.h">/
4113 <tag/Declaration/<tt/void __fastcall__ pokewsys (unsigned addr, unsigned val);/
4114 <tag/Description/<tt/pokewsys/ writes one word to the given address in the
4115 system bank (bank 15) of the CBM PET-II machines. Following the usual 6502
4116 conventions, the low byte of <tt/val/ is written to <tt/addr/, and the
4117 high byte is written to <tt/addr+1/.
4120 <item>The function is only available as fastcall function, so it may only
4121 be used in presence of a prototype.
4122 <item>The order in which the two bytes are written is undefined.
4124 <tag/Availability/cc65
4126 <ref id="POKE" name="POKE">,
4127 <ref id="POKEW" name="POKEW">,
4128 <ref id="peekbsys" name="peekbsys">,
4129 <ref id="peekwsys" name="peekwsys">,
4130 <ref id="pokebsys" name="pokebsys">
4136 <sect1>qsort<label id="qsort"><p>
4140 <tag/Function/Sort an array.
4141 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
4142 <tag/Declaration/<tt/void __fastcall__ qsort (void* base, size_t count,
4143 size_t size, int (*compare) (const void*, const void*));/
4144 <tag/Description/<tt/qsort/ sorts an array according to a given compare
4145 function <tt/compare/. <tt/base/ is the address of the array, <tt/count/
4146 is the number of elements, <tt/size/ the size of an element and <tt/compare/
4147 the function used to compare the members.
4150 <item>If there are multiple members with the same key, the order after calling
4151 the function is undefined.
4152 <item>The function is only available as fastcall function, so it may only
4153 be used in presence of a prototype.
4155 <tag/Availability/ISO 9899
4157 <ref id="bsearch" name="bsearch">
4163 <sect1>raise<label id="raise"><p>
4167 <tag/Function/Send a signal to the executing program.
4168 <tag/Header/<tt/<ref id="signal.h" name="signal.h">/
4169 <tag/Declaration/<tt/int __fastcall__ raise (int sig);/
4170 <tag/Description/<tt/raise/ sends the given signal to the program. If the
4171 program has installed a signal handler for the signal, this signal handler
4172 will be executed. If no handler has been installed, the default action for
4173 the raised signal will be taken. The function returns zero on success,
4175 <tag/Limits/<itemize>
4176 <item>The function is only available as fastcall function, so it may only
4177 be used in presence of a prototype.
4179 <tag/Availability/ISO 9899
4181 <ref id="abort" name="abort">,
4182 <ref id="signal" name="signal">
4188 <sect1>rand<label id="rand"><p>
4192 <tag/Function/Return a pseudo random number.
4193 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
4194 <tag/Declaration/<tt/int rand (void);/
4195 <tag/Description/The function returns a pseudo random number
4196 between 0 and <tt/RAND_MAX/ (exclusive).
4197 <tag/Limits/<itemize>
4198 <item>Without using <tt><ref id="srand" name="srand"></tt>, always the same
4199 flow of numbers is generated.
4200 <item>On startup, the function behaves as if <ref id="srand" name="srand">
4201 had been used with an argument of 1.
4203 <tag/Availability/ISO 9899
4205 <ref id="_randomize" name="_randomize">,
4206 <ref id="srand" name="srand">
4212 <sect1>readdir<label id="readdir"><p>
4216 <tag/Function/Read a directory.
4217 <tag/Header/<tt/<ref id="dirent.h" name="dirent.h">/
4218 <tag/Declaration/<tt/struct dirent* __fastcall__ readdir (DIR* dir);/
4219 <tag/Description/<tt/readdir/ reads the next directory entry from the directory
4220 stream pointed to by <tt/dir/. It stores the data in a <tt/dirent/ structure
4221 and returns a pointer to it. If the end of directory is reached, or an error
4222 occurs, NULL is returned. In case of errors, an error code is stored into
4224 <tag/Limits/<itemize>
4225 <item>The function is only available as fastcall function, so it may only
4226 be used in presence of a prototype.
4227 <item>The returned pointer may point to a statically allocated instance of
4228 <tt/struct dirent/, so it may get overwritten by subsequent calls to
4231 <tag/Availability/POSIX 1003.1
4233 <ref id="closedir" name="closedir">,
4234 <ref id="opendir" name="opendir">
4240 <sect1>realloc<label id="realloc"><p>
4244 <tag/Function/Change the size of an allocated memory block.
4245 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
4246 <tag/Declaration/<tt/void* __fastcall__ realloc (void* block, size_t size);/
4247 <tag/Description/<tt/realloc/ changes the size of the memory block pointed to
4248 by <tt/block/ to <tt/size/ bytes. If <tt/block/ is <tt/NULL/, <tt/realloc/
4249 behaves as if <tt/malloc/ had been called. If <tt/size/ is zero, <tt/realloc/
4250 behaves as if <tt/free/ had been called. On error (not enough memory
4251 available), <tt/realloc/ returns <tt/NULL/.
4254 <item>The part of the memory block that is returned will have its contents
4256 <item>This function is somewhat dangerous to use. Be careful to save the
4257 pointer you're passing somewhere else, otherwise
4259 ptr = realloc (ptr, size);
4261 will loose your only copy of <tt/ptr/ if <tt/realloc/ returns <tt/NULL/.
4262 <item>The function is only available as fastcall function, so it may only
4263 be used in presence of a prototype.
4265 <tag/Availability/ISO 9899
4267 <ref id="_heapadd" name="_heapadd">,
4268 <ref id="_heapblocksize" name="_heapblocksize">,
4269 <ref id="_heapmaxavail" name="_heapmaxavail">,
4270 <ref id="_heapmemavail" name="_heapmemavail">,
4271 <ref id="calloc" name="calloc">,
4272 <ref id="free" name="free">,
4273 <ref id="realloc" name="realloc">
4279 <sect1>remove<label id="remove"><p>
4283 <tag/Function/Delete a file.
4284 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
4285 <tag/Declaration/<tt/int __fastcall__ remove (const char* name);/
4286 <tag/Description/<tt/remove/ deletes the file with the given name. On success,
4287 zero is returned. On error, -1 is returned and <tt/errno/ is set to an error
4288 code describing the reason for the failure.
4291 <item>This function is not available on all cc65 targets (depends on the
4292 availability of file I/O).
4293 <item>The function is only available as fastcall function, so it may only
4294 be used in presence of a prototype.
4296 <tag/Availability/ISO 9899
4298 <ref id="rename" name="rename">,
4299 <ref id="unlink" name="unlink">
4302 #include <stdio.h>
4304 #define FILENAME "helloworld"
4306 if (remove (FILENAME) == 0) {
4307 printf ("We deleted %s successfully\n", FILENAME);
4309 printf ("There was a problem deleting %s\n", FILENAME);
4316 <sect1>rename<label id="rename"><p>
4320 <tag/Function/Rename a file.
4321 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
4322 <tag/Declaration/<tt/int __fastcall__ rename (const char* oldname, const char* newname);/
4323 <tag/Description/<tt/rename/ renames a file (gives it a new name). On success,
4324 zero is returned. On error, -1 is returned and <tt/errno/ is set to an error
4325 code describing the reason for the failure.
4328 <item>This function is not available on all cc65 targets (depends on the
4329 capabilities of the storage devices).
4330 <item>The function is only available as fastcall function, so it may only
4331 be used in presence of a prototype.
4333 <tag/Availability/ISO 9899
4335 <ref id="remove" name="remove">
4338 #include <stdio.h>
4340 #define OLDNAME "textfile.txt"
4341 #define NEWNAME "textfile.bak"
4343 if (rename (OLDNAME, NEWNAME) == 0) {
4344 printf ("Renamed %s to %s\n", OLDNAME, NEWNAME);
4346 printf ("Error renaming %s to %s\n", OLDNAME, NEWNAME);
4353 <sect1>reset_brk<label id="reset_brk"><p>
4357 <tag/Function/Resets the break vector to its original value.
4358 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
4359 <tag/Declaration/<tt/void reset_brk (void);/
4360 <tag/Description/<tt/reset_brk/ resets the break vector to the value it had
4361 before a call to <tt/set_brk/.
4364 <item>Since <tt/<ref id="set_brk" name="set_brk">/ installs an exit handler,
4365 it is not strictly necessary to call this function as part of the cleanup when
4368 <tag/Availability/cc65
4370 <ref id="reset_irq" name="reset_irq">,
4371 <ref id="set_brk" name="set_brk">,
4372 <ref id="set_irq" name="set_irq">
4378 <sect1>reset_irq<label id="reset_irq"><p>
4382 <tag/Function/Resets the C level interrupt request vector.
4383 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
4384 <tag/Declaration/<tt/void reset_irq (void);/
4385 <tag/Description/<tt/reset_irq/ resets the C level interrupt request vector.
4388 <item>The original IRQ vector is restored on program termination even without
4389 calling this function.
4391 <tag/Availability/cc65
4393 <ref id="reset_brk" name="reset_brk">,
4394 <ref id="set_brk" name="set_brk">,
4395 <ref id="set_irq" name="set_irq">
4401 <sect1>revers<label id="revers"><p>
4405 <tag/Function/Control revers character display.
4406 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
4407 <tag/Declaration/<tt/unsigned char __fastcall__ revers (unsigned char onoff);/
4408 <tag/Description/If the argument is non zero, the function enables reverse
4409 character display. If the argument is zero, reverse character display is
4410 switched off. The old value of the setting is returned.
4411 <tag/Limits/<itemize>
4412 <item>The function may not be supported by the hardware, in which case
4413 the call is ignored.
4414 <item>The function is only available as fastcall function, so it may only
4415 be used in presence of a prototype.
4417 <tag/Availability/cc65
4419 <ref id="textcolor" name="textcolor">
4425 <sect1>rewinddir<label id="rewinddir"><p>
4429 <tag/Function/Reset a directory stream.
4430 <tag/Header/<tt/<ref id="dirent.h" name="dirent.h">/
4431 <tag/Declaration/<tt/void __fastcall__ rewinddir (DIR* dir);/
4432 <tag/Description/<tt/rewinddir/ sets the position of the directory stream
4433 pointed to by <tt/dir/ to the start of the directory.
4434 <tag/Limits/<itemize>
4435 <item>The function is only available as fastcall function, so it may only
4436 be used in presence of a prototype.
4438 <tag/Availability/POSIX 1003.1
4440 <ref id="seekdir" name="seekdir">,
4441 <ref id="telldir" name="telldir">
4447 <sect1>screensize<label id="screensize"><p>
4451 <tag/Function/Return the dimensions of the text mode screen.
4452 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
4453 <tag/Declaration/<tt/void __fastcall__ screensize (unsigned char* x, unsigned char* y);/
4454 <tag/Description/The function returns the dimensions of the text mode screen.
4455 <tag/Limits/<itemize>
4456 <item>The function is only available as fastcall function, so it may only
4457 be used in presence of a prototype.
4459 <tag/Availability/cc65
4461 <ref id="gotox" name="gotox">,
4462 <ref id="gotoxy" name="gotoxy">,
4463 <ref id="gotoy" name="gotoy">,
4464 <ref id="wherex" name="wherex">,
4465 <ref id="wherey" name="wherey">
4471 <sect1>seekdir<label id="seekdir"><p>
4475 <tag/Function/Set the position of a directory stream.
4476 <tag/Header/<tt/<ref id="dirent.h" name="dirent.h">/
4477 <tag/Declaration/<tt/void __fastcall__ seekdir (DIR* dir, long offset);/
4478 <tag/Description/<tt/seekdir/ sets the position of the directory stream
4479 pointed to by <tt/dir/ to the value given in <tt/offset/, which should be a
4480 value returned by <tt/<ref id="telldir" name="telldir">/.
4481 <tag/Limits/<itemize>
4482 <item>The function is only available as fastcall function, so it may only
4483 be used in presence of a prototype.
4485 <tag/Availability/POSIX 1003.1
4487 <ref id="rewinddir" name="rewinddir">,
4488 <ref id="telldir" name="telldir">
4494 <sect1>ser_close<label id="ser_close"><p>
4498 <tag/Function/Close the port and disable interrupts
4499 <tag/Header/<tt/<ref id="serial.h" name="serial.h">/
4500 <tag/Declaration/<tt/unsigned char ser_close (void);/
4501 <tag/Description/Close the port by clearing buffers and disable interrupts.
4502 <tag/Availability/cc65
4503 <tag/See also/Other serial functions.
4508 extern char comlynx[];
4510 static void initialize(){
4511 struct ser_params params = {
4518 ser_install(&comlynx); // This will activate the ComLynx
4520 ser_open(&params);
4527 <sect1>ser_get<label id="ser_get"><p>
4531 <tag/Function/Read a character from serial port.
4532 <tag/Header/<tt/<ref id="serial.h" name="serial.h">/
4533 <tag/Declaration/<tt/unsigned char __fastcall__ ser_get (char* b);/
4534 <tag/Description/Get a character from the serial port. If no characters are
4535 available, the function will return SER_ERR_NO_DATA, so this is not a fatal
4537 <tag/Limits/<itemize>
4538 <item>The function is only available as fastcall function, so it may only
4539 be used in presence of a prototype.
4541 <tag/Availability/cc65
4542 <tag/See also/Other serial functions.
4544 Wait for a character to be available from a serial port.
4547 while (ser_get(&ch) == SER_ERR_NO_DATA)
4554 <sect1>ser_install<label id="ser_install"><p>
4558 <tag/Function/Install an already loaded driver and return an error code.
4559 <tag/Header/<tt/<ref id="serial.h" name="serial.h">/
4560 <tag/Declaration/<tt/unsigned char __fastcall__ ser_install (void* driver);/
4561 <tag/Description/The function installs a driver that was already loaded into
4562 memory (or linked statically to the program). It returns an error code
4563 (<tt/SER_ERR_OK/ in case of success).
4564 <tag/Limits/<itemize>
4565 <item>The function is only available as fastcall function, so it may only be
4566 used in presence of a prototype.
4568 <tag/Availability/cc65
4570 <ref id="ser_load_driver" name="ser_load_driver">,
4571 <ref id="ser_uninstall" name="ser_uninstall">,
4572 <ref id="ser_unload" name="ser_unload">
4574 extern char lynxser[]; //Include the driver statically instead of loading it.
4576 ser_install(&lynxser);
4582 <sect1>ser_ioctl<label id="ser_ioctl"><p>
4586 <tag/Function/Platform dependent code extensions.
4587 <tag/Header/<tt/<ref id="serial.h" name="serial.h">/
4588 <tag/Declaration/<tt/unsigned __fastcall__ ser_ioctl (unsigned char code, void* data);/
4589 <tag/Description/Some platforms have extra serial functions that are not
4590 supported by standard serial driver functions. You can extend the driver to support
4591 this extra functionality bt using ser_ioctl functions.
4592 <tag/Limits/<itemize>
4593 <item>The function is only available as fastcall function, so it may only
4594 be used in presence of a prototype.
4595 <item>These functions are not easily portable to other cc65 platforms.
4597 <tag/Availability/cc65
4598 <tag/See also/Other serial functions.
4603 <sect1>ser_load_driver<label id="ser_load_driver"><p>
4607 <tag/Function/Load and install a serial driver.
4608 <tag/Header/<tt/<ref id="serial.h" name="serial.h">/
4609 <tag/Declaration/<tt/unsigned char __fastcall__ ser_load_driver (const char *name);/
4610 <tag/Description/Load and install the driver by name.
4611 Will just load the driver and check if loading was successful.
4612 <tag/Limits/<itemize>
4613 <item>The function is only available as fastcall function, so it may only
4614 be used in presence of a prototype.
4616 <tag/Availability/cc65
4617 <tag/See also/Other serial functions.
4623 <sect1>ser_open<label id="ser_open"><p>
4627 <tag/Function/Open the port by setting the port parameters and enable interrupts
4628 <tag/Header/<tt/<ref id="serial.h" name="serial.h">/
4629 <tag/Declaration/<tt/unsigned char __fastcall__ ser_open (const struct ser_params* params);/
4630 <tag/Description/Open the port by setting the port parameters and enable interrupts.
4631 <tag/Limits/<itemize>
4632 <item>The function is only available as fastcall function, so it may only
4633 be used in presence of a prototype.
4635 <tag/Availability/cc65
4636 <tag/See also/Other serial functions.
4641 extern char comlynx[];
4643 static void initialize(){
4644 struct ser_params params = {
4651 ser_install(&comlynx); // This will activate the ComLynx
4653 ser_open(&params);
4660 <sect1>ser_put<label id="ser_put"><p>
4664 <tag/Function/Write a character to a serial port.
4665 <tag/Header/<tt/<ref id="serial.h" name="serial.h">/
4666 <tag/Declaration/<tt/unsigned char __fastcall__ ser_put (char b);/
4667 <tag/Description/Send a character via the serial port. There is a transmit
4668 buffer, but transmitting is not done via interrupt. The function returns
4669 SER_ERR_OVERFLOW if there is no space left in the transmit buffer.
4670 <tag/Limits/<itemize>
4671 <item>The function is only available as fastcall function, so it may only
4672 be used in presence of a prototype.
4674 <tag/Availability/cc65
4675 <tag/See also/Other serial functions.
4684 <sect1>ser_status<label id="ser_status"><p>
4688 <tag/Function/Return the serial port status.
4689 <tag/Header/<tt/<ref id="serial.h" name="serial.h">/
4690 <tag/Declaration/<tt/unsigned char __fastcall__ ser_status (unsigned char* status);/
4691 <tag/Description/Return the serial port status.
4692 <tag/Limits/<itemize>
4693 <item>The function is only available as fastcall function, so it may only
4694 be used in presence of a prototype.
4696 <tag/Availability/cc65
4697 <tag/See also/Other serial functions.
4703 <sect1>ser_uninstall<label id="ser_uninstall"><p>
4707 <tag/Function/Uninstall the currently loaded driver but do not unload it.
4708 <tag/Header/<tt/<ref id="serial.h" name="serial.h">/
4709 <tag/Declaration/<tt/unsigned char ser_uninstall (void);/
4710 <tag/Description/Uninstall the currently loaded driver but do not unload it.
4711 <tag/Availability/cc65
4712 <tag/See also/Other serial functions.
4717 <sect1>ser_unload<label id="ser_unload"><p>
4721 <tag/Function/Uninstall, then unload the currently loaded driver.
4722 <tag/Header/<tt/<ref id="serial.h" name="serial.h">/
4723 <tag/Declaration/<tt/unsigned char ser_unload (void);/
4724 <tag/Description/Uninstall, then unload the currently loaded driver.
4725 <tag/Availability/cc65
4726 <tag/See also/Other serial functions.
4732 <sect1>set_brk<label id="set_brk"><p>
4736 <tag/Function/Set the break vector to a user function.
4737 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
4738 <tag/Declaration/<tt/void __fastcall__ set_brk (brk_handler func);/
4739 <tag/Description/<tt/set_brk/ allows a user program to handle breaks within the
4740 program code by letting the vector point to a user written C function. The
4741 runtime library installs a small stub that saves the registers into global
4742 variables that may be accessed (and changed) by the break handler.
4745 <item>The function is only available as fastcall function, so it may only
4746 be used in presence of a prototype.
4747 <item>The stub saves the zero page registers used by the C runtime and switches
4748 to a small break handler stack. This means that it is safe to execute C code,
4749 even if C code was interrupted. Be careful however not to use too many local
4750 variables, and do not enable stack checks for the handler function or any other
4751 function called from it.
4752 <item>The <tt/brk_pc/ variable points to the <tt/BRK/ instruction. If you want
4753 the continue with the interrupted code, you have to adjust <tt/brk_pc/,
4754 otherwise the <tt/BRK/ instruction will get executed over and over again.
4755 <item>Since <tt/set_brk/ installs an exit handler, it is not strictly necessary
4756 to call <tt/<ref id="reset_brk" name="reset_brk">/ as part of the cleanup when
4757 the program terminates.
4759 <tag/Availability/cc65
4761 <ref id="reset_brk" name="reset_brk">
4767 <sect1>set_irq<label id="set_irq"><p>
4771 <tag/Function/Set the C level interrupt request vector to the given address.
4772 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
4773 <tag/Declaration/<tt/void __fastcall__ set_irq (irq_handler f, void *stack_addr, size_t stack_size);/
4774 <tag/Description/<tt/set_irq/ allows a user program to handle interrupt requests
4775 (IRQs) within the program code by letting the vector point to a user written C
4776 function. The runtime library installs a small stub that saves the zero page
4777 registers used by the C runtime before calling the handler function and restores
4778 them after the handler function returns. Additionally the stub temporarily switches
4779 the C runtime stack to the stack area provided as parameter. If the handler function
4780 was set up to handle a "private", "exclusive" interrupt request source it must
4781 return the value <tt/IRQ_HANDLED/ if and only if it has verified that the current
4782 interrupt request actually stems from that source. In all other cases it must return
4783 the value <tt/IRQ_NOT_HANDLED/.
4786 <item>The function is only available as fastcall function, so it may only
4787 be used in presence of a prototype.
4788 <item>The stub saves the registers and zero page locations used by the C runtime
4789 and switches to the provided stack area. As a consequence, there is some
4790 runtime overhead, but it it is safe to execute C code, even if other C code
4791 was interrupted. Be careful however not to call C library functions, and do not
4792 enable stack checks for the handler function or any other function called from
4794 <item>The interrupt vector is reset on function termination, so it's not
4795 strictly necessary to call <tt/<ref id="reset_irq" name="reset_irq">/ as part
4796 of the cleanup when the program terminates.
4798 <tag/Availability/cc65
4800 <ref id="reset_brk" name="reset_brk">,
4801 <ref id="reset_irq" name="reset_irq">,
4802 <ref id="set_brk" name="set_brk">
4808 <sect1>setjmp<label id="setjmp"><p>
4812 <tag/Function/Save the context for use with <tt/longjmp/.
4813 <tag/Header/<tt/<ref id="setjmp.h" name="setjmp.h">/
4814 <tag/Declaration/<tt/int __fastcall__ setjmp (jmp_buf buf);/
4815 <tag/Description/The <tt/setjmp/ function saves the current context in <tt/buf/
4816 for subsequent use by the <tt/<ref id="longjmp" name="longjmp">/ function and
4820 <item>The function is only available as fastcall function, so it may only
4821 be used in presence of a prototype.
4822 <item><tt/setjmp/ is actually a macro as required by the ISO standard.
4823 <item><tt/setjmp/ will not save the signal context.
4825 <tag/Availability/ISO 9899
4827 <ref id="longjmp" name="longjmp">
4833 <sect1>setlocale<label id="setlocale"><p>
4837 <tag/Function/Selects a locale.
4838 <tag/Header/<tt/<ref id="locale.h" name="locale.h">/
4839 <tag/Declaration/<tt/char* __fastcall__ setlocale (int category, const char* locale);/
4840 <tag/Description/<tt/setlocale/ sets or queries the program's locale.
4843 <item>The function is only available as fastcall function, so it may only
4844 be used in presence of a prototype.
4845 <item>cc65 supports only the "C" locale, so calling this function to set a
4846 different locale has no effect.
4848 <tag/Availability/ISO 9899
4850 <ref id="localeconv" name="localeconv">,
4851 <ref id="strcoll" name="strcoll">
4852 <ref id="strxfrm" name="strxfrm">
4858 <sect1>signal<label id="signal"><p>
4862 <tag/Function/Install a signal handler.
4863 <tag/Header/<tt/<ref id="signal.h" name="signal.h">/
4864 <tag/Declaration/<tt/__sigfunc __fastcall__ signal (int sig, __sigfunc func);/
4865 <tag/Description/<tt/signal/ installs a handler for the given signal. The
4866 handler may either be a user supplied function, or one of the predefined
4867 signal handlers <tt/SIG_IGN/ or <tt/SIG_DFL/. The function returns the
4868 previous value if the signal , or the special function vector SIG_ERR in
4870 <tag/Limits/<itemize>
4871 <item>The function is only available as fastcall function, so it may only
4872 be used in presence of a prototype.
4874 <tag/Availability/ISO 9899
4876 <ref id="abort" name="abort">,
4877 <ref id="raise" name="raise">
4883 <sect1>sleep<label id="sleep"><p>
4887 <tag/Function/Sleep for a specified amount of time.
4888 <tag/Header/<tt/<ref id="unistd.h" name="unistd.h">/
4889 <tag/Declaration/<tt/void __fastcall__ sleep (unsigned seconds);/
4890 <tag/Description/The function will return after the specified number of
4891 seconds have elapsed.
4892 <tag/Limits/<itemize>
4893 <item>The function is only available as fastcall function, so it may only
4894 be used in presence of a prototype.
4896 <tag/Availability/POSIX 1003.1
4902 <sect1>slow<label id="slow"><p>
4906 <tag/Function/Switch the C128 into 1MHz mode.
4907 <tag/Header/<tt/<ref id="c128.h" name="c128.h">/
4908 <tag/Declaration/<tt/void slow (void);/
4909 <tag/Description/The function will switch the clock of the C128 to 1MHz. This
4910 will halve the speed compared to fast mode.
4911 <tag/Limits/<itemize>
4912 <item>The function is specific to the C128.
4914 <tag/Availability/C128
4916 <ref id="fast" name="fast">,
4917 <ref id="toggle_videomode" name="toggle_videomode">,
4918 <ref id="videomode" name="videomode">
4924 <sect1>srand<label id="srand"><p>
4928 <tag/Function/Initialize the pseudo random number generator.
4929 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
4930 <tag/Declaration/<tt/void __fastcall__ srand (unsigned seed);/
4931 <tag/Description/The function initializes the random number generator using
4932 the given seed. On program startup, the generator behaves as if <tt/srand/ has
4933 been called with an argument of 1.
4934 <tag/Limits/<itemize>
4935 <item>The function is only available as fastcall function, so it may only
4936 be used in presence of a prototype.
4938 <tag/Availability/ISO 9899
4940 <ref id="_randomize" name="_randomize">,
4941 <ref id="rand" name="rand">
4947 <sect1>strcasecmp<label id="strcasecmp"><p>
4951 <tag/Function/Compare two strings case insensitive.
4952 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4953 <tag/Declaration/<tt/int __fastcall__ strcasecmp (const char* s1, const char* s2);/
4954 <tag/Description/The <tt/strcasecmp/ function compares the two strings passed
4955 as parameters without case sensitivity. It returns a value that is less than
4956 zero if <tt/s1/ is less than <tt/s2/, zero if <tt/s1/ is the same as <tt/s2/,
4957 and a value greater than zero if <tt/s1/ is greater than <tt/s2/.
4958 <tag/Limits/<itemize>
4959 <item>The function is only available as fastcall function, so it may only
4960 be used in presence of a prototype.
4961 <item>The function is not available in strict ANSI mode.
4963 <tag/Availability/cc65
4965 <ref id="strcmp" name="strcmp">,
4966 <ref id="strcoll" name="strcoll">,
4967 <ref id="stricmp" name="stricmp">,
4968 <ref id="strncmp" name="strncmp">,
4969 <ref id="strxfrm" name="strxfrm">
4975 <sect1>strcat<label id="strcat"><p>
4979 <tag/Function/Concatentate two strings.
4980 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4981 <tag/Declaration/<tt/char* __fastcall__ strcat (char* s1, const char* s2);/
4982 <tag/Description/The <tt/strcat/ function appends a copy of the string
4983 pointed to by s2 (including the terminating null byte) to the end of the
4984 string pointed to by s1. The initial byte of s2 overwrites the null byte at
4986 <tag/Limits/<itemize>
4987 <item>The function is only available as fastcall function, so it may only
4988 be used in presence of a prototype.
4989 <item>If copying takes place between objects that overlap, the behaviour
4992 <tag/Availability/ISO 9899
4994 <ref id="strcpy" name="strcpy">,
4995 <ref id="strncat" name="strncat">,
4996 <ref id="strncpy" name="strncpy">
5002 <sect1>strchr<label id="strchr"><p>
5006 <tag/Function/Search for a character in a string.
5007 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5008 <tag/Declaration/<tt/char* __fastcall__ strchr (const char* s, int c);/
5009 <tag/Description/The <tt/strchr/ function locates the first occurrence of <tt/c/
5010 (converted to a char) in the string pointed to by <tt/s/. The terminating null
5011 byte is considered to be part of the string. Upon completion, the function
5012 returns a pointer to the byte, or a null pointer if the byte was not found.
5013 <tag/Limits/<itemize>
5014 <item>The function is only available as fastcall function, so it may only
5015 be used in presence of a prototype.
5017 <tag/Availability/ISO 9899
5019 <ref id="memchr" name="memchr">,
5020 <ref id="strrchr" name="strrchr">
5026 <sect1>strcmp<label id="strcmp"><p>
5030 <tag/Function/Compare two strings.
5031 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5032 <tag/Declaration/<tt/int __fastcall__ strcmp (const char* s1, const char* s2);/
5033 <tag/Description/The <tt/strcmp/ function compares the two strings passed as
5034 parameters. It returns a value that is less than zero if <tt/s1/ is less than
5035 <tt/s2/, zero if <tt/s1/ is the same as <tt/s2/, and a value greater than zero
5036 if <tt/s1/ is greater than <tt/s2/.
5037 <tag/Limits/<itemize>
5038 <item>The function is only available as fastcall function, so it may only
5039 be used in presence of a prototype.
5041 <tag/Availability/ISO 9899
5043 <ref id="strcasecmp" name="strcasecmp">,
5044 <ref id="strcoll" name="strcoll">,
5045 <ref id="stricmp" name="stricmp">,
5046 <ref id="strncmp" name="strncmp">
5047 <ref id="strxfrm" name="strxfrm">
5053 <sect1>strcoll<label id="strcoll"><p>
5057 <tag/Function/Compare two strings.
5058 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5059 <tag/Declaration/<tt/int __fastcall__ strcoll (const char* s1, const char* s2);/
5060 <tag/Description/The <tt/strcoll/ function compares the two strings passed as
5061 parameters, according to the collating sequence set by <tt/<ref id="setlocale"
5062 name="setlocale">/. It returns a value that is less than zero if <tt/s1/ is
5063 less than <tt/s2/, zero if <tt/s1/ is the same as <tt/s2/, and a value greater
5064 than zero if <tt/s1/ is greater than <tt/s2/.
5065 <tag/Limits/<itemize>
5066 <item>The function is only available as fastcall function, so it may only
5067 be used in presence of a prototype.
5069 <tag/Availability/ISO 9899
5071 <ref id="setlocale" name="setlocale">,
5072 <ref id="strcasecmp" name="strcasecmp">,
5073 <ref id="strcmp" name="strcmp">,
5074 <ref id="stricmp" name="stricmp">,
5075 <ref id="strncmp" name="strncmp">,
5076 <ref id="strxfrm" name="strxfrm">
5082 <sect1>strcpy<label id="strcpy"><p>
5086 <tag/Function/Copy a string.
5087 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5088 <tag/Declaration/<tt/char* __fastcall__ strcpy (char* s1, const char* s2);/
5089 <tag/Description/The <tt/strcpy/ function copies the string pointed to by
5090 <tt/s2/ (including the terminating null byte) into the array pointed to by
5091 <tt/s1/. The function will always return <tt/s1/.
5092 <tag/Limits/<itemize>
5093 <item>The function is only available as fastcall function, so it may only
5094 be used in presence of a prototype.
5095 <item>If copying takes place between objects that overlap, the behaviour
5098 <tag/Availability/ISO 9899
5100 <ref id="strcat" name="strcat">,
5101 <ref id="strncat" name="strncat">,
5102 <ref id="strncpy" name="strncpy">
5105 #include <string.h>
5107 static char hello[14];
5109 strcpy (hello, "Hello world!\n");
5115 <sect1>strcspn<label id="strcspn"><p>
5119 <tag/Function/Compute the length of a substring.
5120 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5121 <tag/Declaration/<tt/size_t __fastcall__ strcspn (const char* s, const char* set);/
5122 <tag/Description/The <tt/strcspn/ function computes and returns the length of
5123 the substring pointed to by <tt/s/ which does <em>not</em> consist of
5124 characters contained in the string <tt/set/.
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/ISO 9899
5131 <ref id="strspn" name="strspn">,
5132 <ref id="strstr" name="strstr">,
5133 <ref id="strtok" name="strtok">
5139 <sect1>strdup<label id="strdup"><p>
5143 <tag/Function/Allocate a copy of a string on the heap.
5144 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5145 <tag/Declaration/<tt/char* __fastcall__ strdup (const char* s);/
5146 <tag/Description/<tt/strdup/ allocates a memory block on the heap, big enough
5147 to hold a copy of <tt/s/ including the terminating zero. If the allocation
5148 fails, <tt/NULL/ is returned, otherwise <tt/s/ is copied into the allocated
5149 memory block, and a pointer to the block is returned.
5150 <tag/Limits/<itemize>
5151 <item>The function is only available as fastcall function, so it may only
5152 be used in presence of a prototype.
5153 <item>It is up to the caller to free the allocated memory block.
5155 <tag/Availability/ISO 9899
5157 <ref id="free" name="free">,
5158 <ref id="malloc" name="malloc">
5164 <sect1>strerror<label id="strerror"><p>
5168 <tag/Function/Return a string describing an error code.
5169 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5170 <tag/Declaration/<tt/char* __fastcall__ strerror (int errcode);/
5171 <tag/Description/The <tt/strerror/ function returns a string describing the
5172 given error code. If an invalid error code is passed, the string "Unknown
5173 error" is returned, and <tt/errno/ is set to <tt/EINVAL/. In all other cases,
5174 <tt/errno/ is left untouched.
5175 <tag/Limits/<itemize>
5176 <item>The function is only available as fastcall function, so it may only
5177 be used in presence of a prototype.
5178 <item>While the return type of the function is a <tt/char*/, the returned
5179 string must not be modified by the caller!
5181 <tag/Availability/ISO 9899
5183 <ref id="_stroserror" name="_stroserror">
5189 <sect1>stricmp<label id="stricmp"><p>
5193 <tag/Function/Compare two strings case insensitive.
5194 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5195 <tag/Declaration/<tt/int __fastcall__ stricmp (const char* s1, const char* s2);/
5196 <tag/Description/The <tt/stricmp/ function compares the two strings passed as
5197 parameters without case sensitivity. It returns a value that is less than zero
5198 if <tt/s1/ is less than <tt/s2/, zero if <tt/s1/ is the same as <tt/s2/, and a
5199 value greater than zero if <tt/s1/ is greater than <tt/s2/.
5200 <tag/Limits/<itemize>
5201 <item>The function is only available as fastcall function, so it may only
5202 be used in presence of a prototype.
5203 <item>The function is not available in strict ANSI mode.
5205 <tag/Availability/cc65
5207 <ref id="strcasecmp" name="strcasecmp">,
5208 <ref id="strcmp" name="strcmp">,
5209 <ref id="strcoll" name="strcoll">,
5210 <ref id="strncmp" name="strncmp">,
5211 <ref id="strxfrm" name="strxfrm">
5217 <sect1>strlen<label id="strlen"><p>
5221 <tag/Function/Return the length of a string.
5222 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5223 <tag/Declaration/<tt/size_t __fastcall__ strlen (const char* s);/
5224 <tag/Description/The <tt/strlen/ function computes the number of bytes in the
5225 string to which s points, not including the terminating null byte.
5226 <tag/Limits/<itemize>
5227 <item>The function is only available as fastcall function, so it may only
5228 be used in presence of a prototype.
5229 <item>When compiling with <tt/-Os/ (inline known standard functions), the
5230 function does not work correctly for strings with more than 255 characters.
5232 <tag/Availability/ISO 9899
5234 <ref id="strcpy" name="strcpy">
5240 <sect1>strlower<label id="strlower"><p>
5244 <tag/Function/Make a string lower case.
5245 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5246 <tag/Declaration/<tt/char* __fastcall__ strlower (char* s);/
5247 <tag/Description/The <tt/strlower/ function will apply the <tt/tolower/
5248 function to each character of a string. The function will always return <tt/s/.
5249 <tag/Limits/<itemize>
5250 <item>The function is only available as fastcall function, so it may only
5251 be used in presence of a prototype.
5252 <item>The function prototype is unavailable when compiling in strict ANSI mode.
5253 <item>An alias name for this function is <tt/strlwr/.
5255 <tag/Availability/cc65
5257 <ref id="strupper" name="strupper">,
5258 <ref id="tolower" name="tolower">
5264 <sect1>strlwr<label id="strlwr"><p>
5271 <sect1>strncat<label id="strncat"><p>
5275 <tag/Function/Concatentate two strings.
5276 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5277 <tag/Declaration/<tt/char* __fastcall__ strncat (char* s1, const char* s2, size_t n);/
5278 <tag/Description/The <tt/strncat/ function appends not more than n characters
5279 of the string pointed to by s2 to the end of the string pointed to by s1. The
5280 terminating null character at the end of s1 is overwritten. A terminating null
5281 character is appended to the result, even if not all of s2 is appended to s1.
5282 <tag/Limits/<itemize>
5283 <item>The function is only available as fastcall function, so it may only
5284 be used in presence of a prototype.
5285 <item>If copying takes place between objects that overlap, the behaviour
5288 <tag/Availability/ISO 9899
5290 <ref id="strcpy" name="strcpy">,
5291 <ref id="strncat" name="strncat">,
5292 <ref id="strncpy" name="strncpy">
5298 <sect1>strncmp<label id="strncmp"><p>
5302 <tag/Function/Compare two strings.
5303 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5304 <tag/Declaration/<tt/int __fastcall__ strncmp (const char* s1, const char* s2, size_t count);/
5305 <tag/Description/The <tt/strncmp/ function compares not more than <tt/count/
5306 characters of the two strings passed as parameters. It returns a value that is
5307 less than zero if the first <tt/count/ characters of <tt/s1/ are less than
5308 <tt/s2/, zero if they are identical, and a value greater than zero they are
5310 <tag/Limits/<itemize>
5311 <item>The function is only available as fastcall function, so it may only
5312 be used in presence of a prototype.
5314 <tag/Availability/ISO 9899
5316 <ref id="strcasecmp" name="strcasecmp">,
5317 <ref id="strcmp" name="strcmp">,
5318 <ref id="strcoll" name="strcoll">,
5319 <ref id="stricmp" name="stricmp">,
5320 <ref id="strxfrm" name="strxfrm">
5326 <sect1>strncpy<label id="strncpy"><p>
5330 <tag/Function/Copy part of a string.
5331 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5332 <tag/Declaration/<tt/char* __fastcall__ strcpy (char* s1, const char* s2, size_t n);/
5333 <tag/Description/The <tt/strncpy/ function copies not more than n bytes from
5334 the array pointed to by <tt/s2/ to the array pointed to by <tt/s1/. If the array
5335 pointed to by <tt/s2/ is a string that is shorter than n bytes, null bytes are
5336 appended to the copy in the array pointed to by <tt/s1/, until <tt/n/ bytes are
5337 written. The function will always return <tt/s1/.
5338 <tag/Limits/<itemize>
5339 <item>The function is only available as fastcall function, so it may only
5340 be used in presence of a prototype. If there is no null byte in the first <tt/n/
5341 bytes of the array pointed to by <tt/s2/, the result is not null-terminated.
5342 <item>If copying takes place between objects that overlap, the behaviour is
5345 <tag/Availability/ISO 9899
5347 <ref id="strcat" name="strcat">,
5348 <ref id="strcpy" name="strcpy">,
5349 <ref id="strncat" name="strncat">
5354 static char hello[6];
5356 strcpy (hello, "Hello world!\n", sizeof (hello) - 1);
5363 <sect1>strrchr<label id="strrchr"><p>
5367 <tag/Function/Search for a character in a string.
5368 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5369 <tag/Declaration/<tt/char* __fastcall__ strrchr (const char* s, int c);/
5370 <tag/Description/The <tt/strrchr/ function locates the last occurrence of <tt/c/
5371 (converted to a char) in the string pointed to by <tt/s/. The terminating null
5372 byte is considered to be part of the string. Upon completion, the function
5373 returns a pointer to the byte, or a null pointer if the byte was not found.
5374 <tag/Limits/<itemize>
5375 <item>The function is only available as fastcall function, so it may only
5376 be used in presence of a prototype.
5378 <tag/Availability/ISO 9899
5380 <ref id="strchr" name="strchr">
5386 <sect1>strspn<label id="strspn"><p>
5390 <tag/Function/Compute the length of a substring.
5391 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5392 <tag/Declaration/<tt/size_t __fastcall__ strspn (const char* s, const char* set);/
5393 <tag/Description/The <tt/strspn/ function computes and returns the length of
5394 the substring pointed to by <tt/s/ which does consist only of characters
5395 contained in the string <tt/set/.
5396 <tag/Limits/<itemize>
5397 <item>The function is only available as fastcall function, so it may only
5398 be used in presence of a prototype.
5400 <tag/Availability/ISO 9899
5402 <ref id="strcspn" name="strcspn">,
5403 <ref id="strstr" name="strstr">
5409 <sect1>strstr<label id="strstr"><p>
5413 <tag/Function/Find a substring.
5414 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5415 <tag/Declaration/<tt/char* __fastcall__ strstr (const char* str, const char* substr);/
5416 <tag/Description/<tt/strstr/ searches for the first occurance of the string
5417 <tt/substr/ within <tt/str/. If found, it returns a pointer to the copy,
5418 otherwise it returns <tt/NULL/.
5419 <tag/Limits/<itemize>
5420 <item>The function is only available as fastcall function, so it may only
5421 be used in presence of a prototype.
5423 <tag/Availability/ISO 9899
5425 <ref id="strcspn" name="strcspn">,
5426 <ref id="strspn" name="strspn">
5432 <sect1>strtok<label id="strtok"><p>
5436 <tag/Function/Break a string into tokens.
5437 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5438 <tag/Declaration/<tt/char* __fastcall__ strtok (char* s1, const char* s2);/
5439 <tag/Description/<tt/strtok/ will break the string s1 into a sequence of
5440 tokens, which are delimited by characters from the string s2. The first call
5441 to <tt/strtok/ will return a pointer to the first token in the string s1.
5442 Following calls must pass a <tt/NULL/ pointer as s1 in order to get the next
5443 token in the string. Different sets of delimiters may be used for the
5444 subsequent calls to <tt/strtok/.
5445 <tag/Limits/<itemize>
5446 <item>The function is only available as fastcall function, so it may only
5447 be used in presence of a prototype.
5448 <item><tt/strtok/ will modify the string s1.
5450 <tag/Availability/ISO 9899
5452 <ref id="strcspn" name="strcspn">,
5453 <!-- <ref id="strpbrk" name="strpbrk"> -->
5459 <sect1>strxfrm<label id="strxfrm"><p>
5463 <tag/Function/Transform a string.
5464 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5465 <tag/Declaration/<tt/size_t __fastcall__ strxfrm (char* s1, const char* s2, size_t n);/
5466 <tag/Description/The <tt/strxfrm/ function transforms the string pointed to by
5467 s2 and places the resulting string into the string pointed to by s1. The
5468 transformation is such that if the <tt/strcmp/ function is applied to two
5469 transformed strings, it returns a value greater than, equal to, or less than
5470 zero, corresponding to the result of the <tt/strcoll/ function applied to the
5471 same two original strings. No more than n characters are placed into the
5472 resulting array pointed to by s1, including the terminating null character.
5473 <tag/Limits/<itemize>
5474 <item><tt/s1/ and <tt/s2/ must not point to the same memory area, otherwise
5475 the behaviour is undefined.
5476 <item>If <tt/n/ is zero, <tt/s1/ may be a NULL pointer.
5477 <item>The function is only available as fastcall function, so it may only
5478 be used in presence of a prototype.
5479 <item>Since cc65 doesn't support different charcter sets, <tt/strxfrm/ will
5480 just copy s2 to s1 using <tt><ref id="strncpy" name="strncpy"></tt>.
5482 <tag/Availability/ISO 9899
5484 <ref id="strcmp" name="strcmp">,
5485 <ref id="strcoll" name="strcoll">,
5486 <ref id="strncpy" name="strncpy">
5492 <sect1>strupper<label id="strupper"><p>
5496 <tag/Function/Make a string upper case.
5497 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5498 <tag/Declaration/<tt/char* __fastcall__ strupper (char* s);/
5499 <tag/Description/The <tt/strupper/ function will apply the <tt/toupper/
5500 function to each character of a string. The function will always return <tt/s/.
5501 <tag/Limits/<itemize>
5502 <item>The function is only available as fastcall function, so it may only
5503 be used in presence of a prototype.
5504 <item>The function prototype is unavailable when compiling in strict ANSI mode.
5505 <item>An alias name for this function is <tt/strupr/.
5507 <tag/Availability/cc65
5509 <ref id="strlower" name="strlower">
5510 <ref id="toupper" name="toupper">
5516 <sect1>strupr<label id="strupr"><p>
5523 <sect1>telldir<label id="telldir"><p>
5527 <tag/Function/Return the current position of a directory stream.
5528 <tag/Header/<tt/<ref id="dirent.h" name="dirent.h">/
5529 <tag/Declaration/<tt/long __fastcall__ telldir (DIR* dir);/
5530 <tag/Description/<tt/telldir/ returns the current position of a directory
5531 stream. The return value may be used in subsequent calls to
5532 <tt/<ref id="seekdir" name="seekdir">/.
5533 <tag/Limits/<itemize>
5534 <item>The function is only available as fastcall function, so it may only
5535 be used in presence of a prototype.
5537 <tag/Availability/POSIX 1003.1
5539 <ref id="seekdir" name="seekdir">,
5540 <ref id="telldir" name="telldir">
5546 <sect1>textcolor<label id="textcolor"><p>
5550 <tag/Function/Set the text color.
5551 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
5552 <tag/Declaration/<tt/unsigned char __fastcall__ textcolor (unsigned char color);/
5553 <tag/Description/The function will set a new text color. It returns the old
5554 (current) text color. Text output using any <tt/conio.h/ function will use
5555 the color set by this function.
5556 <tag/Limits/<itemize>
5557 <item>Text colors are system dependent. The function may have no effect
5558 on systems where the text color cannot be changed.
5559 <item>The function is only available as fastcall function, so it may only
5560 be used in presence of a prototype.
5562 <tag/Availability/cc65
5564 <ref id="bgcolor" name="bgcolor">,
5565 <ref id="bordercolor" name="bordercolor">
5571 <sect1>tgi_arc<label id="tgi_arc"><p>
5575 <tag/Function/Draw an elliptic arc in the current color.
5576 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5577 <tag/Declaration/<tt/void __fastcall__ tgi_arc (int x, int y,
5578 unsigned char rx, unsigned char ry, unsigned sa, unsigned ea);/
5579 <tag/Description/The function draws an elliptic arc with center at x/y and
5580 radii rx/ry using the current drawing color. The arc covers the angle
5581 between sa and ea (startangle and endangle), which must be in the range
5583 <tag/Limits/<itemize>
5584 <item>The function is only available as fastcall function, so it may only
5585 be used in presence of a prototype.
5586 <item>The function behaves unexpectedly or may crash if the angles are out
5589 <tag/Availability/cc65
5591 <ref id="tgi_bar" name="tgi_bar">,
5592 <ref id="tgi_circle" name="tgi_circle">,
5593 <ref id="tgi_ellipse" name="tgi_ellipse">,
5594 <ref id="tgi_pieslice" name="tgi_pieslice">,
5595 <ref id="tgi_setcolor" name="tgi_setcolor">
5597 /* Draw the upper half of an ellipse */
5598 tgi_setcolor(TGI_COLOR_BLUE);
5599 tgi_arc (50, 50, 40, 20, 0, 180);
5605 <sect1>tgi_bar<label id="tgi_bar"><p>
5609 <tag/Function/The function fills a rectangle on the drawpage with the current
5611 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5612 <tag/Declaration/<tt/void __fastcall__ tgi_bar (int x1, int y1, int x2, int y2);/
5613 <tag/Description/The function fills a rectangle on the drawpage with the current
5615 <tag/Limits/<itemize>
5616 <item>The function is only available as fastcall function, so it may only
5617 be used in presence of a prototype.
5619 <tag/Availability/cc65
5620 <tag/See also/Other tgi function
5622 tgi_setcolor(TGI_COLOR_GREEN);
5623 tgi_bar(10, 10, 100, 60);
5629 <sect1>tgi_circle<label id="tgi_circle"><p>
5633 <tag/Function/The function draws a circle in the current color.
5634 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5635 <tag/Declaration/<tt/void __fastcall__ tgi_circle (int x, int y, unsigned char radius);/
5636 <tag/Description/The function draws a circle in the current color.
5637 <tag/Limits/<itemize>
5638 <item>The function is only available as fastcall function, so it may only
5639 be used in presence of a prototype.
5641 <tag/Availability/cc65
5643 <ref id="tgi_arc" name="tgi_arc">,
5644 <ref id="tgi_bar" name="tgi_bar">,
5645 <ref id="tgi_ellipse" name="tgi_ellipse">,
5646 <ref id="tgi_pieslice" name="tgi_pieslice">,
5647 <ref id="tgi_setcolor" name="tgi_setcolor">
5649 tgi_setcolor(TGI_COLOR_BLACK);
5650 tgi_circle(50, 40, 40);
5656 <sect1>tgi_clear<label id="tgi_clear"><p>
5660 <tag/Function/Clear the drawpage
5661 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5662 <tag/Declaration/<tt/void tgi_clear (void);/
5663 <tag/Description/Clear the drawpage
5664 <tag/Availability/cc65
5665 <tag/See also/Other tgi functions
5671 <sect1>tgi_done<label id="tgi_done"><p>
5675 <tag/Function/End graphics mode, switch back to text mode.
5676 Will NOT uninstall or unload the driver!
5677 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5678 <tag/Declaration/<tt/void tgi_done (void);/
5679 <tag/Description/End graphics mode, switch back to text mode.
5680 Will NOT uninstall or unload the driver!
5681 <tag/Availability/cc65
5682 <tag/See also/Other tgi functions
5688 <sect1>tgi_ellipse<label id="tgi_ellipse"><p>
5692 <tag/Function/The function draws an ellipse in the current color.
5693 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5694 <tag/Declaration/<tt/void __fastcall__ tgi_ellipse (int x, int y, unsigned char rx, unsigned char ry);/
5695 <tag/Description/The function draws an ellipse at position x/y with radii
5696 rx and ry, using the current drawing color.
5697 <tag/Limits/<itemize>
5698 <item>The function is only available as fastcall function, so it may only
5699 be used in presence of a prototype.
5701 <tag/Availability/cc65
5703 <ref id="tgi_arc" name="tgi_arc">,
5704 <ref id="tgi_bar" name="tgi_bar">,
5705 <ref id="tgi_circle" name="tgi_circle">,
5706 <ref id="tgi_pieslice" name="tgi_pieslice">,
5707 <ref id="tgi_setcolor" name="tgi_setcolor">
5709 tgi_setcolor(TGI_COLOR_RED);
5710 tgi_ellipse (50, 40, 40, 20);
5716 <sect1>tgi_getaspectratio<label id="tgi_getaspectratio"><p>
5718 <quote> <descrip> <tag/Function/Return the pixel aspect ratio.
5719 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5720 <tag/Declaration/<tt/unsigned tgi_getaspectratio (void);/
5721 <tag/Description/The function returns the pixel aspect ratio for the current
5722 driver and display as an 8.8 fixed point value. It may be used to correct
5723 geometric shapes so they look correct on the display. As an example, a circle
5724 with a radius of 100 pixels may look elliptic on some driver/display
5725 combinations if the aspect ratio is not 1.00.
5726 <tag/Limits/<itemize>
5727 <item>The aspect ratio is encoded in the TGI driver which assumes a "standard"
5728 monitor for the given platform. The aspect ratio may be wrong if another
5730 <item>No TGI function will use the aspect ratio. It is up to the programmer to
5732 <item>The <ref id="tgi_setaspectratio" name="tgi_setaspectratio"> function can
5733 be used to change the aspect ratio for a loaded driver. The value is not reset
5734 by <ref id="tgi_init" name="tgi_init">, so if a driver is linked statically to
5735 an application, switching into and out of graphics mode will not restore the
5736 original aspect ratio.
5738 <tag/Availability/cc65
5740 <ref id="tgi_setaspectratio" name="tgi_setaspectratio">
5746 <sect1>tgi_getcolor<label id="tgi_getcolor"><p>
5750 <tag/Function/Return the current drawing color.
5751 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5752 <tag/Declaration/<tt/unsigned char tgi_getcolor (void);/
5753 <tag/Description/The actual color is an index to a palette. During tgi_init
5754 you will get a default palette. The number of colors depend on the platform.
5755 All platforms recognize at least TGI_COLOR_BLACK and TGI_COLOR_WHITE. But some
5756 platforms have many more predefined colors. If you paint using TGI_COLOR_GREEN
5757 and then you change the green of the palette to blue using tgi_setpalette then
5758 after this painting in TGI_COLOR_GREEN will actually be blue.
5759 <tag/Availability/cc65
5760 <tag/See also/Other tgi functions
5762 color = tgi_getcolor();
5768 <sect1>tgi_getcolorcount<label id="tgi_getcolorcount"><p>
5772 <tag/Function/Get the number of available colors.
5773 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5774 <tag/Declaration/<tt/unsigned char tgi_getcolorcount (void);/
5775 <tag/Description/Tgi platforms use indexed color palettes. This function
5776 returns the number of entries we can use in the palette.
5777 <tag/Availability/cc65
5778 <tag/See also/Other tgi functions
5780 if (tgi_getcolorcount() == 2) {
5781 printf("Only monochrome graphics is supported\n");
5788 <sect1>tgi_getdefpalette<label id="tgi_getdefpalette"><p>
5792 <tag/Function/Get the palette installed by default.
5793 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5794 <tag/Declaration/<tt/const unsigned char* tgi_getdefpalette (void);/
5795 <tag/Description/The tgi driver has a default palette that is active at startup.
5796 The named colors TGI_COLOR_BLACK, TGI_COLOR_WHITE, TGI_COLOR_RED... need this
5797 palette to work correctly.
5798 <tag/Availability/cc65
5799 <tag/See also/Other tgi functions
5805 <sect1>tgi_geterror<label id="tgi_geterror"><p>
5809 <tag/Function/Return the error code for the last operation.
5810 This will also clear the error.
5811 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5812 <tag/Declaration/<tt/unsigned char tgi_geterror (void);/
5813 <tag/Description/Return the error code for the last operation.
5814 This will also clear the error.
5815 <tag/Availability/cc65
5816 <tag/See also/Other tgi functions
5822 <sect1>tgi_geterrormsg<label id="tgi_geterrormsg"><p>
5826 <tag/Function/Get an error message describing the error.
5827 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5828 <tag/Declaration/<tt/const char* __fastcall__ tgi_geterrormsg (unsigned char code);/
5829 <tag/Description/Get an error message describing the error.
5830 <tag/Limits/<itemize>
5831 <item>The function is only available as fastcall function, so it may only
5832 be used in presence of a prototype.
5834 <tag/Availability/cc65
5835 <tag/See also/Other tgi functions
5841 <sect1>tgi_getmaxcolor<label id="tgi_getmaxcolor"><p>
5845 <tag/Function/Get the highest index of the palette.
5846 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5847 <tag/Declaration/<tt/unsigned char tgi_getmaxcolor (void);/
5848 <tag/Description/Get the highest index of the palette.
5849 <tag/Availability/cc65
5850 <tag/See also/Other tgi functions
5856 <sect1>tgi_getmaxx<label id="tgi_getmaxx"><p>
5860 <tag/Function/Get the maximum x coordinate that can be used on this screen.
5861 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5862 <tag/Declaration/<tt/unsigned tgi_getmaxx (void);/
5863 <tag/Description/Get the maximum x coordinate that can be used on this screen.
5864 <tag/Availability/cc65
5865 <tag/See also/Other tgi functions
5871 <sect1>tgi_getmaxy<label id="tgi_getmaxy"><p>
5875 <tag/Function/Get the maximum y coordinate that can be used on this screen.
5876 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5877 <tag/Declaration/<tt/unsigned tgi_getmaxy (void);/
5878 <tag/Description/Get the maximum y coordinate that can be used on this screen.
5879 <tag/Availability/cc65
5880 <tag/See also/Other tgi functions
5886 <sect1>tgi_getpagecount<label id="tgi_getpagecount"><p>
5890 <tag/Function/Return the number of screen pages available.
5891 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5892 <tag/Declaration/<tt/unsigned tgi_getpagecount (void);/
5893 <tag/Description/Return the number of screen pages available.
5894 <tag/Availability/cc65
5896 <ref id="tgi_setdrawpage" name="tgi_setdrawpage">,
5897 <ref id="tgi_setviewpage" name="tgi_setviewpage">
5903 <sect1>tgi_getpalette<label id="tgi_getpalette"><p>
5907 <tag/Function/Get the palette installed.
5908 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5909 <tag/Declaration/<tt/const unsigned char* tgi_getpalette (void);/
5910 <tag/Description/Get the palette installed.
5911 <tag/Availability/cc65
5912 <tag/See also/Other tgi functions
5918 <sect1>tgi_getpixel<label id="tgi_getpixel"><p>
5922 <tag/Function/Get the color of a pixel from the viewpage.
5923 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5924 <tag/Declaration/<tt/unsigned char __fastcall__ tgi_getpixel (int x, int y);/
5925 <tag/Description/Get the color of a pixel from the viewpage.
5926 <tag/Limits/<itemize>
5927 <item>The function is only available as fastcall function, so it may only
5928 be used in presence of a prototype.
5930 <tag/Availability/cc65
5931 <tag/See also/Other tgi functions.
5937 <sect1>tgi_getxres<label id="tgi_getxres"><p>
5941 <tag/Function/Get number of horisontal pixels on the screen.
5942 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5943 <tag/Declaration/<tt/unsigned tgi_getxres (void);/
5944 <tag/Description/Get number of horisontal pixels on the screen.
5945 This is same as tgi_maxx()+1.
5946 <tag/Availability/cc65
5947 <tag/See also/Other tgi functions.
5953 <sect1>tgi_getyres<label id="tgi_getyres"><p>
5957 <tag/Function/Get number of vertical pixels on the screen.
5958 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5959 <tag/Declaration/<tt/unsigned tgi_getyres (void);/
5960 <tag/Description/Get number of vertical pixels on the screen.
5961 This is same as tgi_maxy()+1.
5962 <tag/Availability/cc65
5963 <tag/See also/Other tgi functions.
5969 <sect1>tgi_gotoxy<label id="tgi_gotoxy"><p>
5973 <tag/Function/Set graphics cursor at x, y.
5974 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5975 <tag/Declaration/<tt/void __fastcall__ tgi_gotoxy (int x, int y);/
5976 <tag/Description/Set graphics cursor at x, y.
5977 <tag/Limits/<itemize>
5978 <item>The function is only available as fastcall function, so it may only
5979 be used in presence of a prototype.
5981 <tag/Availability/cc65
5982 <tag/See also/Other tgi functions.
5988 <sect1>tgi_init<label id="tgi_init"><p>
5992 <tag/Function/Initialize the already loaded graphics driver.
5993 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5994 <tag/Declaration/<tt/void tgi_init (void);/
5995 <tag/Description/The tgi_init function will set the default palette to the
5997 <tag/Limits/<itemize>
5998 <item><tt/tgi_init/ will not clear the screen. This allows switching between
5999 text and graphics mode on platforms that have separate memory areas for the
6000 screens. If you want the screen cleared, call <tt/<ref id="tgi_clear"
6001 name="tgi_clear">/ after <tt/tgi_init/.
6003 <tag/Availability/cc65
6004 <tag/See also/Other tgi functions.
6006 extern char lynxtgi[]; //Include the driver statically instead of loading it.
6007 tgi_install(&lynxtgi);
6008 tgi_init(); //Set up the default palette and clear the screen.
6014 <sect1>tgi_install<label id="tgi_install"><p>
6018 <tag/Function/Install an already loaded driver and return an error code.
6019 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6020 <tag/Declaration/<tt/unsigned char __fastcall__ tgi_install (void* driver);/
6021 <tag/Description/The function installs a driver that was already loaded into
6022 memory (or linked statically to the program). It returns an error code
6023 (<tt/TGI_ERR_OK/ in case of success).
6024 <tag/Limits/<itemize>
6025 <item>The function is only available as fastcall function, so it may only be
6026 used in presence of a prototype.
6028 <tag/Availability/cc65
6030 <ref id="tgi_load_driver" name="tgi_load_driver">,
6031 <ref id="tgi_uninstall" name="tgi_uninstall">,
6032 <ref id="tgi_unload" name="tgi_unload">
6034 extern char lynxtgi[]; //Include the driver statically instead of loading it.
6036 tgi_install(&lynxtgi);
6037 tgi_init(); //Set up the default palette and clear the screen.
6043 <sect1>tgi_ioctl<label id="tgi_ioctl"><p>
6047 <tag/Function/Platform dependent code extensions.
6048 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6049 <tag/Declaration/<tt/unsigned __fastcall__ tgi_ioctl (unsigned char code, void* data);/
6050 <tag/Description/Some platforms have extra display hardware that is not
6051 supported by standard tgi functions. You can extend the driver to support
6052 this extra hardware using tgi_ioctl functions.
6053 <tag/Limits/<itemize>
6054 <item>The function is only available as fastcall function, so it may only
6055 be used in presence of a prototype.
6056 <item>These functions are not easily portable to other cc65 platforms.
6058 <tag/Availability/cc65
6059 <tag/See also/Other tgi functions.
6061 #define tgi_sprite(spr) tgi_ioctl(0, (void*)(spr))
6062 #define tgi_flip() tgi_ioctl(1, (void*)0)
6063 #define tgi_setbgcolor(bgcol) tgi_ioctl(2, (void*)(bgcol))
6064 #define tgi_setframerate(rate) tgi_ioctl(3, (void*)(rate))
6065 #define tgi_busy() tgi_ioctl(4, (void*)0)
6066 #define tgi_updatedisplay() tgi_ioctl(4, (void*)1)
6068 tgi_sprite(&background);
6069 tgi_setcolor(TGI_COLOR_BLUE);
6070 tgi_outttextxy(20,40,"Hello World");
6071 tgi_updatedisplay();
6078 <sect1>tgi_line<label id="tgi_line"><p>
6082 <tag/Function/Draw a line in the current drawing color.
6083 The graphics cursor will be set to x2/y2 by this call.
6084 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6085 <tag/Declaration/<tt/void __fastcall__ tgi_line (int x1, int y1, int x2, int y2);/
6086 <tag/Description/Draw a line in the current drawing color.
6087 The graphics cursor will be set to x2/y2 by this call.
6088 <tag/Limits/<itemize>
6089 <item>The function is only available as fastcall function, so it may only
6090 be used in presence of a prototype.
6092 <tag/Availability/cc65
6093 <tag/See also/Other tgi functions.
6099 <sect1>tgi_lineto<label id="tgi_lineto"><p>
6103 <tag/Function/Draw a line in the current drawing color from the graphics
6104 cursor to the new end point. The graphics cursor will be updated to x2/y2.
6105 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6106 <tag/Declaration/<tt/void __fastcall__ tgi_lineto (int x2, int y2);/
6107 <tag/Description/Draw a line in the current drawing color from the graphics
6108 cursor to the new end point. The graphics cursor will be updated to x2/y2.
6109 <tag/Limits/<itemize>
6110 <item>The function is only available as fastcall function, so it may only
6111 be used in presence of a prototype.
6113 <tag/Availability/cc65
6114 <tag/See also/Other tgi functions.
6120 <sect1>tgi_load_driver<label id="tgi_load_driver"><p>
6124 <tag/Function/Load and install the given driver.
6125 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6126 <tag/Declaration/<tt/void __fastcall__ tgi_load_driver (const char *name);/
6127 <tag/Description/Load and install the driver by name.
6128 Will just load the driver and check if loading was successful.
6129 Will not switch to graphics mode.
6130 <tag/Limits/<itemize>
6131 <item>The function is only available as fastcall function, so it may only
6132 be used in presence of a prototype.
6134 <tag/Availability/cc65
6135 <tag/See also/Other tgi functions.
6141 <sect1>tgi_outtext<label id="tgi_outtext"><p>
6145 <tag/Function/Output text at the current graphics cursor position.
6146 The graphics cursor is moved to the end of the text.
6147 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6148 <tag/Declaration/<tt/void __fastcall__ tgi_outtext (const char* s);/
6149 <tag/Description/Output text at the current graphics cursor position.
6150 The graphics cursor is moved to the end of the text.
6151 <tag/Limits/<itemize>
6152 <item>The function is only available as fastcall function, so it may only
6153 be used in presence of a prototype.
6155 <tag/Availability/cc65
6156 <tag/See also/Other tgi functions.
6162 <sect1>tgi_outtextxy<label id="tgi_outtextxy"><p>
6166 <tag/Function/Output text at the given cursor position.
6167 The graphics cursor is moved to the end of the text.
6168 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6169 <tag/Declaration/<tt/void __fastcall__ tgi_outtextxy (int x, int y, const char* s);/
6170 <tag/Description/Output text at the given cursor position.
6171 The graphics cursor is moved to the end of the text.
6172 <tag/Limits/<itemize>
6173 <item>The function is only available as fastcall function, so it may only
6174 be used in presence of a prototype.
6176 <tag/Availability/cc65
6177 <tag/See also/Other tgi functions.
6183 <sect1>tgi_pieslice<label id="tgi_pieslice"><p>
6187 <tag/Function/Draw an elliptic pie slice in the current color.
6188 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6189 <tag/Declaration/<tt/void __fastcall__ tgi_pie slice (int x, int y,
6190 unsigned char rx, unsigned char ry, unsigned sa, unsigned ea);/
6191 <tag/Description/The function draws an elliptic pie slice with center at x/y
6192 and radii rx/ry using the current drawing color. The pie slice covers the angle
6193 between sa and ea (startangle and endangle), which must be in the range
6195 <tag/Limits/<itemize>
6196 <item>The function is only available as fastcall function, so it may only
6197 be used in presence of a prototype.
6198 <item>The function behaves unexpectedly or may crash if the angles are out
6201 <tag/Availability/cc65
6203 <ref id="tgi_bar" name="tgi_arc">,
6204 <ref id="tgi_bar" name="tgi_bar">,
6205 <ref id="tgi_circle" name="tgi_circle">,
6206 <ref id="tgi_ellipse" name="tgi_ellipse">,
6207 <ref id="tgi_setcolor" name="tgi_setcolor">
6209 /* Draw the closed upper half of an ellipse */
6210 tgi_setcolor(TGI_COLOR_BLUE);
6211 tgi_pieslice (50, 50, 40, 20, 0, 180);
6217 <sect1>tgi_setaspectratio<label id="tgi_setaspectratio"><p>
6219 <quote> <descrip> <tag/Function/Set the pixel aspect ratio.
6220 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6221 <tag/Declaration/<tt/void __fastcall__ tgi_setaspectratio (unsigned ratio);/
6222 <tag/Description/The function sets the pixel aspect ratio for the current
6223 driver and display. The argument is an 8.8 fixed point value. The aspect ratio
6224 may be used to correct geometric shapes so they look correct on a given
6225 display. As an example, a circle with a radius of 100 pixels may look elliptic
6226 on some driver/display combinations if the aspect ratio is not 1.00.
6227 <tag/Limits/<itemize>
6228 <item>The aspect ratio is encoded in the TGI driver which assumes a "standard"
6229 monitor for the given platform. The aspect ratio may be wrong if another
6231 <item>No TGI function will use the aspect ratio. It is up to the programmer to
6233 <item>The <tt/tgi_setaspectratio/ function can be used to change the aspect
6234 ratio for a loaded driver. The value is not reset by <ref id="tgi_init"
6235 name="tgi_init">, so if a driver is linked statically to an application,
6236 switching into and out of graphics mode will not restore the original aspect
6239 <tag/Availability/cc65
6241 <ref id="tgi_getaspectratio" name="tgi_getaspectratio">
6247 <sect1>tgi_setcolor<label id="tgi_setcolor"><p>
6251 <tag/Function/Set color to be used in future draw operations.
6252 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6253 <tag/Declaration/<tt/void __fastcall__ tgi_setcolor (unsigned char color);/
6254 <tag/Description/Set color to be used in future draw operations.
6255 <tag/Limits/<itemize>
6256 <item>The function is only available as fastcall function, so it may only
6257 be used in presence of a prototype.
6259 <tag/Availability/cc65
6260 <tag/See also/Other tgi functions.
6262 tgi_setcolor(TGI_COLOR_BLACK);
6264 tgi_setcolor(TGI_COLOR_WHITE);
6265 tgi_bar(10,10,20,20);
6270 <sect1>tgi_setdrawpage<label id="tgi_setdrawpage"><p>
6274 <tag/Function/Set the page for drawing.
6275 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6276 <tag/Declaration/<tt/void __fastcall__ tgi_setdrawpage (unsigned char page);/
6277 <tag/Description/If the drawpage and the viewpage are the same then all drawing
6278 is seen immediately as it is drawn. For double buffered games you can set the
6279 drawpage to a different page than the viewpage. This lets you draw the next
6280 screen in the background and when the screen is ready you display it.
6281 <tag/Limits/<itemize>
6282 <item>The function is only available as fastcall function, so it may only
6283 be used in presence of a prototype.
6285 <tag/Availability/cc65
6286 <tag/See also/Other tgi functions.
6289 tgi_outtextxy(10, 10, "Hello World");
6290 tgi_setviewpage(1); // Show page 1
6292 tgi_outtextxy(10, 10, "Creating next frame");
6294 tgi_setviewpage(0); // Show page 0
6299 <sect1>tgi_setpalette<label id="tgi_setpalette"><p>
6303 <tag/Function/Set the palette (not available with all drivers/hardware).
6304 Palette is a pointer to as many entries as there are colors.
6305 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6306 <tag/Declaration/<tt/void __fastcall__ tgi_setpalette (const unsigned char* palette);/
6307 <tag/Description/Set the palette (not available with all drivers/hardware).
6308 Palette is a pointer to as many entries as there are colors.
6309 <tag/Limits/<itemize>
6310 <item>The function is only available as fastcall function, so it may only
6311 be used in presence of a prototype.
6313 <tag/Availability/cc65
6314 <tag/See also/Other tgi functions.
6319 <sect1>tgi_setpixel<label id="tgi_setpixel"><p>
6323 <tag/Function/Plot a pixel on the drawpage with the current color.
6324 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6325 <tag/Declaration/<tt/void __fastcall__ tgi_setpixel (int x, int y);/
6326 <tag/Description/Plot a pixel on the drawpage with the current color.
6327 <tag/Limits/<itemize>
6328 <item>The function is only available as fastcall function, so it may only
6329 be used in presence of a prototype.
6331 <tag/Availability/cc65
6332 <tag/See also/Other tgi functions.
6337 <sect1>tgi_setviewpage<label id="tgi_setviewpage"><p>
6341 <tag/Function/Set page to be visible on screen.
6342 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6343 <tag/Declaration/<tt/void __fastcall__ tgi_setviewpage (unsigned char page);/
6344 <tag/Description/If the drawpage and the viewpage are the same then all drawing
6345 is seen immediately as it is drawn. For double buffered games you can set the
6346 drawpage to a different page than the viewpage. This lets you draw the next
6347 screen in the background and when the screen is ready you display it.
6348 <tag/Limits/<itemize>
6349 <item>The function is only available as fastcall function, so it may only
6350 be used in presence of a prototype.
6352 <tag/Availability/cc65
6353 <tag/See also/Other tgi functions.
6356 tgi_outtextxy(10, 10, "Hello World");
6357 tgi_setviewpage(1); // Show page 1
6359 tgi_outtextxy(10, 10, "Creating next frame");
6361 tgi_setviewpage(0); // Show page 0
6366 <sect1>tgi_gettextheight<label id="tgi_gettextheight"><p>
6370 <tag/Function/Calculate the height of the text in pixels according to
6371 the current text style.
6372 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6373 <tag/Declaration/<tt/unsigned __fastcall__ tgi_gettextheight (const char* s);/
6374 <tag/Description/Calculate the height of the text in pixels according to
6375 the current text style.
6376 <tag/Limits/<itemize>
6377 <item>The function is only available as fastcall function, so it may only
6378 be used in presence of a prototype.
6380 <tag/Availability/cc65
6381 <tag/See also/Other tgi functions.
6386 <sect1>tgi_settextstyle<label id="tgi_settextstyle"><p>
6390 <tag/Function/Set the style for text output.
6391 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6392 <tag/Declaration/<tt/void __fastcall__ tgi_settextstyle (unsigned char magx, unsigned char magy, unsigned char dir);/
6393 <tag/Description/Set the style for text output.
6394 <tag/Limits/<itemize>
6395 <item>The function is only available as fastcall function, so it may only
6396 be used in presence of a prototype.
6398 <tag/Availability/cc65
6399 <tag/See also/Other tgi functions.
6404 <sect1>tgi_gettextwidth<label id="tgi_gettextwidth"><p>
6408 <tag/Function/Calculate the width of the text in pixels according to the current text style.
6409 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6410 <tag/Declaration/<tt/unsigned __fastcall__ tgi_gettextwidth (const char* s);/
6411 <tag/Function/Calculate the width of the text in pixels according to the current text style.
6412 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6413 <tag/Description/Calculate the width of the text in pixels according to the current text style.
6414 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6415 <tag/Limits/<itemize>
6416 <item>The function is only available as fastcall function, so it may only
6417 be used in presence of a prototype.
6419 <tag/Availability/cc65
6420 <tag/See also/Other tgi functions.
6425 <sect1>tgi_uninstall<label id="tgi_uninstall"><p>
6429 <tag/Function/Uninstall the currently loaded driver but do not unload it.
6430 Will call tgi_done if necessary.
6431 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6432 <tag/Declaration/<tt/void tgi_uninstall (void);/
6433 <tag/Description/Uninstall the currently loaded driver but do not unload it.
6434 Will call tgi_done if necessary.
6435 <tag/Availability/cc65
6436 <tag/See also/Other tgi functions.
6441 <sect1>tgi_unload<label id="tgi_unload"><p>
6445 <tag/Function/Uninstall, then unload the currently loaded driver.
6446 Will call tgi_done if necessary.
6447 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6448 <tag/Declaration/<tt/void tgi_unload (void);/
6449 <tag/Description/Uninstall, then unload the currently loaded driver.
6450 Will call tgi_done if necessary.
6451 <tag/Availability/cc65
6452 <tag/See also/Other tgi functions.
6457 <sect1>time<label id="time"><p>
6461 <tag/Function/Get the time.
6462 <tag/Header/<tt/<ref id="time.h" name="time.h">/
6463 <tag/Declaration/<tt/time_t __fastcall__ time (time_t* t);/
6464 <tag/Description/The function returns the time since the 1970-01-01 00:00:00
6465 measured in seconds. If the pointer <tt/t/ is not <tt/NULL/, the function
6466 result will also be stored there. If no time is available, <tt/(time_t)-1/ is
6467 returned and <tt/errno/ is set to <tt/ENOSYS/.
6468 <tag/Limits/<itemize>
6469 <item>The function is only available as fastcall function, so it may
6470 only be used in presence of a prototype.
6471 <item>Many platforms supported by cc65 do not have a realtime clock, so the
6472 returned value may not be valid.
6474 <tag/Availability/ISO 9899
6476 <ref id="clock" name="clock">
6482 <sect1>toggle_videomode<label id="toggle_videomode"><p>
6486 <tag/Function/Toggle between 40 and 80 column mode.
6487 <tag/Header/<tt/<ref id="c128.h" name="c128.h">/
6488 <tag/Declaration/<tt/void toggle_videomode (void);/
6489 <tag/Description/Toggle between 40 and 80 column mode. The settings for the
6490 old mode (cursor position, color and so on) are saved and restored together
6492 <tag/Limits/<itemize>
6493 <item>The function is specific to the C128.
6494 <item>This function is deprecated. Please use <ref id="videomode"
6495 name="videomode"> instead!
6497 <tag/Availability/C128
6499 <ref id="fast" name="fast">,
6500 <ref id="slow" name="slow">,
6501 <ref id="videomode" name="videomode">
6507 <sect1>tolower<label id="tolower"><p>
6511 <tag/Function/Convert a character into its lower case representation.
6512 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
6513 <tag/Declaration/<tt/int __fastcall__ tolower (int c);/
6514 <tag/Description/The function returns the given character converted to lower
6515 case. If the given character is not a letter, it is returned unchanged.
6516 <tag/Limits/<itemize>
6517 <item>The function is only available as fastcall function, so it may
6518 only be used in presence of a prototype.
6520 <tag/Availability/ISO 9899
6522 <ref id="islower" name="islower">,
6523 <ref id="isupper" name="isupper">,
6524 <ref id="toupper" name="toupper">
6530 <sect1>toupper<label id="toupper"><p>
6534 <tag/Function/Convert a character into its upper case representation.
6535 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
6536 <tag/Declaration/<tt/int __fastcall__ toupper (int c);/
6537 <tag/Description/The function returns the given character converted to upper
6538 case. If the given character is not a letter, it is returned unchanged.
6539 <tag/Limits/<itemize>
6540 <item>The function is only available as fastcall function, so it may
6541 only be used in presence of a prototype.
6543 <tag/Availability/ISO 9899
6545 <ref id="islower" name="islower">,
6546 <ref id="isupper" name="isupper">,
6547 <ref id="tolower" name="tolower">
6553 <sect1>ultoa<label id="ultoa"><p>
6557 <tag/Function/Convert an unsigned long integer into a string.
6558 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
6559 <tag/Declaration/<tt/char* __fastcall__ ultoa (unsigned long val, char* buf, int radix);/
6560 <tag/Description/<tt/itoa/ converts the unsigned long integer <tt/val/ into a
6561 string using <tt/radix/ as the base.
6562 <tag/Limits/<itemize>
6563 <item>There are no provisions to prevent a buffer overflow.
6564 <item>The function is non standard, so it is not available in strict ANSI mode.
6565 You should probably use <tt/sprintf/ instead.
6566 <item>The function is only available as fastcall function, so it may only be
6567 used in presence of a prototype.
6569 <tag/Availability/cc65
6571 <ref id="atoi" name="atoi">,
6572 <ref id="atol" name="atol">,
6573 <ref id="itoa" name="itoa">,
6574 <ref id="ltoa" name="ltoa">,
6575 <ref id="utoa" name="utoa">
6581 <sect1>unlink<label id="unlink"><p>
6585 <tag/Function/Delete a file.
6586 <tag/Header/<tt/<ref id="unistd.h" name="unistd.h">/
6587 <tag/Declaration/<tt/int __fastcall__ unlink (const char* name);/
6588 <tag/Description/<tt/unlink/ deletes the file with the given name. On success,
6589 zero is returned. On error, -1 is returned and <tt/errno/ is set to an error
6590 code describing the reason for the failure.
6593 <item>The use of this function is discouraged. Please use <tt/<ref id="remove"
6594 name="remove">/ instead, which is a native ANSI C function and does the same.
6595 <item>This function is not available on all cc65 targets (depends on the
6596 availability of file I/O).
6597 <item>The function is only available as fastcall function, so it may only
6598 be used in presence of a prototype.
6599 <item>Instead of <tt/unlink/, <tt/<ref id="remove" name="remove">/ should be
6600 used, which has the same semantics, but is more portable, because it conforms
6601 to the ISO C standard.
6603 <tag/Availability/POSIX 1003.1
6605 <ref id="remove" name="remove">
6608 #include <stdio.h>
6609 #include <unistd.h>
6611 #define FILENAME "helloworld"
6613 if (unlink (FILENAME) == 0) {
6614 printf ("We deleted %s successfully\n", FILENAME);
6616 printf ("There was a problem deleting %s\n", FILENAME);
6623 <sect1>utoa<label id="utoa"><p>
6627 <tag/Function/Convert an unsigned integer into a string.
6628 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
6629 <tag/Declaration/<tt/char* __fastcall__ utoa (unsigned val, char* buf, int radix);/
6630 <tag/Description/<tt/itoa/ converts the unsigned integer <tt/val/ into a string
6631 using <tt/radix/ as the base.
6632 <tag/Limits/<itemize>
6633 <item>There are no provisions to prevent a buffer overflow.
6634 <item>The function is non standard, so it is not available in strict ANSI mode.
6635 You should probably use <tt/sprintf/ instead.
6636 <item>The function is only available as fastcall function, so it may only be
6637 used in presence of a prototype.
6639 <tag/Availability/cc65
6641 <ref id="atoi" name="atoi">,
6642 <ref id="atol" name="atol">,
6643 <ref id="itoa" name="itoa">,
6644 <ref id="ltoa" name="ltoa">,
6645 <ref id="ultoa" name="ultoa">
6651 <sect1>vcprintf<label id="vcprintf"><p>
6655 <tag/Function/Formatted output to the console.
6656 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
6657 <tag/Declaration/<tt/int __fastcall__ vcprintf (const char* format, va_list ap);/
6658 <tag/Description/The arguments specified as a <tt/va_list/ are converted to
6659 text where necessary and formatted according to the format string given. The
6660 resulting string is output to the console. <tt/vcprintf/ supports the same
6661 format specifiers as <tt/vprintf/. <!-- <tt/<ref id="vprintf" name="vprintf">/. -->
6662 <tag/Limits/<itemize>
6663 <item>Like all other <tt/conio/ output functions, <tt/vcprintf/ distinguishes
6664 between <tt/\r/ and <tt/\n/.
6665 <item>The function is only available as fastcall function, so it may only be
6666 used in presence of a prototype.
6668 <tag/Availability/cc65
6670 <ref id="cprintf" name="cprintf">,
6671 <ref id="cputc" name="cputc">,
6672 <ref id="cputcxy" name="cputcxy">,
6673 <ref id="cputs" name="cputs">,
6674 <ref id="cputsxy" name="cputsxy">
6680 <sect1>videomode<label id="videomode"><p>
6684 <tag/Function/Switch to either 40 or 80 column mode.
6685 <tag/Header/<tt/<ref id="apple2enh.h" name="apple2enh.h">,
6686 <ref id="c128.h" name="c128.h">/
6687 <tag/Declaration/<tt/unsigned __fastcall__ videomode (unsigned Mode);/
6688 <tag/Description/Switch to 40 or 80 column mode depending on the argument. If
6689 the requested mode is already active, nothing happens. The old mode is returned
6691 <tag/Limits/<itemize>
6692 <item>The function is specific to the C128 and enhanced Apple //e.
6693 <item>This function replaces <ref id="toggle_videomode"
6694 name="toggle_videomode">.
6695 <item>The function is only available as fastcall function, so it may only be
6696 used in presence of a prototype.
6698 <tag/Availability/C128 and enhanced Apple //e
6700 <ref id="fast" name="fast">,
6701 <ref id="slow" name="slow">,
6702 <ref id="toggle_videomode" name="toggle_videomode">
6708 <sect1>wherex<label id="wherex"><p>
6712 <tag/Function/Return the current X position of the text mode cursor.
6713 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
6714 <tag/Declaration/<tt/unsigned char wherex (void);/
6715 <tag/Description/The function returns the current X position of the text mode
6716 cursor. Zero is returned for the leftmost screen position.
6717 <tag/Availability/cc65
6719 <ref id="gotox" name="gotox">,
6720 <ref id="gotoy" name="gotoy">,
6721 <ref id="gotoxy" name="gotoxy">,
6722 <ref id="wherey" name="wherey">
6728 <sect1>wherey<label id="wherey"><p>
6732 <tag/Function/Return the current Y position of the text mode cursor.
6733 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
6734 <tag/Declaration/<tt/unsigned char wherey (void);/
6735 <tag/Description/The function returns the current Y position of the text mode
6736 cursor. Zero is returned for the uppermost screen position.
6737 <tag/Availability/cc65
6739 <ref id="gotox" name="gotox">,
6740 <ref id="gotoy" name="gotoy">,
6741 <ref id="gotoxy" name="gotoxy">,
6742 <ref id="wherex" name="wherex">