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/em.h/<label id="em.h"><p>
283 <item><ref id="em_commit" name="em_commit">
284 <item><ref id="em_copyfrom" name="em_copyfrom">
285 <item><ref id="em_copyto" name="em_copyto">
286 <item><ref id="em_install" name="em_install">
287 <item><ref id="em_load_driver" name="em_load_driver">
288 <item><ref id="em_map" name="em_map">
289 <item><ref id="em_pagecount" name="em_pagecount">
290 <item><ref id="em_uninstall" name="em_uninstall">
291 <item><ref id="em_unload" name="em_unload">
292 <item><ref id="em_use" name="em_use">
296 <sect1><tt/errno.h/<label id="errno.h"><p>
299 <!-- <item><ref id="_directerrno" name="_directerrno"> -->
300 <!-- <item><ref id="_mappederrno" name="_mappederrno"> -->
301 <!-- <item><ref id="_osmaperrno" name="_osmaperrno"> -->
302 <!-- <item><ref id="_seterrno" name="_seterrno"> -->
308 <sect1><tt/fcntl.h/<label id="fcntl.h"><p>
311 <item><ref id="close" name="close">
312 <item><ref id="creat" name="creat">
313 <item><ref id="open" name="open">
317 <sect1><tt/geos.h/<label id="geos.h"><p>
322 <sect1><tt/joystick.h/<label id="joystick.h"><p>
325 <item><ref id="joy_count" name="joy_count">
326 <item><ref id="joy_install" name="joy_install">
327 <item><ref id="joy_load_driver" name="joy_load_driver">
328 <item><ref id="joy_read" name="joy_read">
329 <item><ref id="joy_uninstall" name="joy_uninstall">
330 <item><ref id="joy_unload" name="joy_unload">
334 <sect1><tt/locale.h/<label id="locale.h"><p>
337 <item><ref id="localeconv" name="localeconv">
338 <item><ref id="setlocale" name="setlocale">
342 <sect1><tt/lynx.h/<label id="lynx.h"><p>
345 <!-- <item><ref id="lynx_eeprom_erase" name="lynx_eeprom_erase"> -->
346 <!-- <item><ref id="lynx_eeprom_read" name="lynx_eeprom_read"> -->
347 <!-- <item><ref id="lynx_eeprom_write" name="lynx_eeprom_write"> -->
348 <!-- <item><ref id="lynx_eeread" name="lynx_eeread"> -->
349 <!-- <item><ref id="lynx_eewrite" name="lynx_eewrite"> -->
350 <!-- <item><ref id="lynx_exec" name="lynx_exec"> -->
351 <!-- <item><ref id="lynx_load" name="lynx_load"> -->
357 <sect1><tt/modload.h/<label id="modload.h"><p>
360 <item><ref id="mod_load" name="mod_load">
361 <item><ref id="mod_free" name="mod_free">
365 <sect1><tt/mouse.h/<label id="mouse.h"><p>
368 <item><ref id="mouse_buttons" name="mouse_buttons">
369 <item><ref id="mouse_getbox" name="mouse_getbox">
370 <item><ref id="mouse_geterrormsg" name="mouse_geterrormsg">
371 <item><ref id="mouse_hide" name="mouse_hide">
372 <item><ref id="mouse_info" name="mouse_info">
373 <item><ref id="mouse_install" name="mouse_install">
374 <item><ref id="mouse_ioctl" name="mouse_ioctl">
375 <item><ref id="mouse_load_driver" name="mouse_load_driver">
376 <item><ref id="mouse_move" name="mouse_move">
377 <item><ref id="mouse_pos" name="mouse_pos">
378 <item><ref id="mouse_setbox" name="mouse_setbox">
379 <item><ref id="mouse_show" name="mouse_show">
380 <item><ref id="mouse_uninstall" name="mouse_uninstall">
381 <item><ref id="mouse_unload" name="mouse_unload">
385 <sect1><tt/nes.h/<label id="nes.h"><p>
388 <!-- <item><ref id="get_tv" name="get_tv"> -->
389 <!-- <item><ref id="waitvblank" name="waitvblank"> -->
395 <sect1><tt/o65.h/<label id="o65.h"><p>
397 The <tt/o65.h/ header file contains structure and constant definitions that
398 may be used when dealing with files in <htmlurl
399 url="http://www.6502.org/users/andre/o65/fileformat.html" name="o65 format">.
400 It does not declare any functions.
403 <sect1><tt/peekpoke.h/<label id="peekpoke.h"><p>
406 <item><ref id="PEEK" name="PEEK">
407 <item><ref id="PEEKW" name="PEEKW">
408 <item><ref id="POKE" name="POKE">
409 <item><ref id="POKEW" name="POKEW">
413 <sect1><tt/pet.h/<label id="pet.h"><p>
418 <sect1><tt/plus4.h/<label id="plus4.h"><p>
423 <sect1><tt/serial.h/<label id="serial.h"><p>
425 The <tt/serial.h/ header file contains definitions for initializing serial
429 <item><ref id="ser_close" name="ser_close">
430 <item><ref id="ser_get" name="ser_get">
431 <item><ref id="ser_install" name="ser_install">
432 <item><ref id="ser_ioctl" name="ser_ioctl">
433 <item><ref id="ser_load_driver" name="ser_load_driver">
434 <item><ref id="ser_open" name="ser_open">
435 <item><ref id="ser_put" name="ser_put">
436 <item><ref id="ser_status" name="ser_status">
437 <item><ref id="ser_uninstall" name="ser_uninstall">
438 <item><ref id="ser_unload" name="ser_unload">
442 <sect1><tt/setjmp.h/<label id="setjmp.h"><p>
445 <item><ref id="setjmp" name="setjmp">
446 <item><ref id="longjmp" name="longjmp">
450 <sect1><tt/signal.h/<label id="signal.h"><p>
453 <item><ref id="raise" name="raise">
454 <item><ref id="signal" name="signal">
458 <sect1><tt/stdarg.h/<label id="stdarg.h"><p>
463 <sect1><tt/stdbool.h/<label id="stdbool.h"><p>
468 <sect1><tt/stddef.h/<label id="stddef.h"><p>
471 <item><ref id="offsetof" name="offsetof">
475 <sect1><tt/stdio.h/<label id="stdio.h"><p>
478 <item><ref id="_poserror" name="_poserror">
479 <item><ref id="clearerr" name="clearerr">
480 <!-- <item><ref id="fclose" name="fclose"> -->
481 <!-- <item><ref id="fdopen" name="fdopen"> -->
482 <item><ref id="feof" name="feof">
483 <item><ref id="ferror" name="ferror">
484 <!-- <item><ref id="fflush" name="fflush"> -->
485 <!-- <item><ref id="fgetc" name="fgetc"> -->
486 <!-- <item><ref id="fgetpos" name="fgetpos"> -->
487 <!-- <item><ref id="fgets" name="fgets"> -->
488 <item><ref id="fileno" name="fileno">
489 <!-- <item><ref id="fopen" name="fopen"> -->
490 <!-- <item><ref id="fprintf" name="fprintf"> -->
491 <!-- <item><ref id="fputc" name="fputc"> -->
492 <!-- <item><ref id="fputs" name="fputs"> -->
493 <!-- <item><ref id="fread" name="fread"> -->
494 <!-- <item><ref id="freopen" name="freopen"> -->
495 <!-- <item><ref id="fscanf" name="fscanf"> -->
496 <!-- <item><ref id="fseek" name="fseek"> -->
497 <!-- <item><ref id="fsetpos" name="fsetpos"> -->
498 <!-- <item><ref id="ftell" name="ftell"> -->
499 <!-- <item><ref id="fwrite" name="fwrite"> -->
500 <!-- <item><ref id="getc" name="getc"> -->
501 <!-- <item><ref id="getchar" name="getchar"> -->
502 <!-- <item><ref id="gets" name="gets"> -->
503 <!-- <item><ref id="printf" name="printf"> -->
504 <!-- <item><ref id="putc" name="putc"> -->
505 <!-- <item><ref id="putchar" name="putchar"> -->
506 <!-- <item><ref id="puts" name="puts"> -->
507 <item><ref id="rename" name="rename">
508 <item><ref id="remove" name="remove">
509 <!-- <item><ref id="rewind" name="rewind"> -->
510 <!-- <item><ref id="scanf" name="scanf"> -->
511 <!-- <item><ref id="snprintf" name="snprintf"> -->
512 <!-- <item><ref id="sprintf" name="sprintf"> -->
513 <!-- <item><ref id="sscanf" name="sscanf"> -->
514 <!-- <item><ref id="vfprintf" name="vfprintf"> -->
515 <!-- <item><ref id="vfscanf" name="vfscanf"> -->
516 <!-- <item><ref id="vprintf" name="vprintf"> -->
517 <!-- <item><ref id="vscanf" name="vscanf"> -->
518 <!-- <item><ref id="vsnprintf" name="vsnprintf"> -->
519 <!-- <item><ref id="vsprintf" name="vsprintf"> -->
520 <!-- <item><ref id="vsscanf" name="vsscanf"> -->
526 <sect1><tt/stdlib.h/<label id="stdlib.h"><p>
529 <item><ref id="_heapadd" name="_heapadd">
530 <item><ref id="_heapblocksize" name="_heapblocksize">
531 <item><ref id="_heapmaxavail" name="_heapmaxavail">
532 <item><ref id="_heapmemavail" name="_heapmemavail">
533 <item><ref id="_randomize" name="_randomize">
534 <item><ref id="_swap" name="_swap">
535 <item><ref id="abort" name="abort">
536 <item><ref id="abs" name="abs">
537 <item><ref id="atexit" name="atexit">
538 <item><ref id="atoi" name="atoi">
539 <item><ref id="atol" name="atol">
540 <item><ref id="bsearch" name="bsearch">
541 <item><ref id="calloc" name="calloc">
542 <item><ref id="div" name="div">
543 <item><ref id="exit" name="exit">
544 <item><ref id="free" name="free">
545 <item><ref id="getenv" name="getenv">
546 <item><ref id="itoa" name="itoa">
547 <item><ref id="labs" name="labs">
548 <item><ref id="ltoa" name="ltoa">
549 <item><ref id="malloc" name="malloc">
550 <item><ref id="perror" name="perror">
551 <!-- <item><ref id="posix_memalign" name="posix_memalign"> -->
552 <!-- <item><ref id="putenv" name="putenv"> -->
553 <item><ref id="qsort" name="qsort">
554 <item><ref id="rand" name="rand">
555 <item><ref id="realloc" name="realloc">
556 <item><ref id="srand" name="srand">
557 <!-- <item><ref id="system" name="system"> -->
558 <item><ref id="ultoa" name="ultoa">
559 <item><ref id="utoa" name="utoa">
565 <sect1><tt/string.h/<label id="string.h"><p>
568 <item><ref id="_stroserror" name="_stroserror">
569 <item><ref id="bzero" name="bzero">
570 <item><ref id="memchr" name="memchr">
571 <item><ref id="memcmp" name="memcmp">
572 <item><ref id="memcpy" name="memcpy">
573 <item><ref id="memmove" name="memmove">
574 <item><ref id="memset" name="memset">
575 <item><ref id="strcasecmp" name="strcasecmp">
576 <item><ref id="strcat" name="strcat">
577 <item><ref id="strchr" name="strchr">
578 <item><ref id="strcmp" name="strcmp">
579 <item><ref id="strcoll" name="strcoll">
580 <item><ref id="strcpy" name="strcpy">
581 <item><ref id="strcspn" name="strcspn">
582 <item><ref id="strdup" name="strdup">
583 <item><ref id="strerror" name="strerror">
584 <item><ref id="stricmp" name="stricmp">
585 <item><ref id="strlen" name="strlen">
586 <item><ref id="strlower" name="strlower">
587 <item><ref id="strlwr" name="strlwr">
588 <item><ref id="strncat" name="strncat">
589 <item><ref id="strncmp" name="strncmp">
590 <item><ref id="strncpy" name="strncpy">
591 <item><ref id="strrchr" name="strrchr">
592 <item><ref id="strspn" name="strspn">
593 <item><ref id="strstr" name="strstr">
594 <item><ref id="strtok" name="strtok">
595 <item><ref id="strxfrm" name="strxfrm">
596 <item><ref id="strupper" name="strupper">
597 <item><ref id="strupr" name="strupr">
603 <sect1><tt/tgi.h/<label id="tgi.h"><p>
606 <item><ref id="tgi_arc" name="tgi_arc">
607 <item><ref id="tgi_bar" name="tgi_bar">
608 <item><ref id="tgi_circle" name="tgi_circle">
609 <item><ref id="tgi_clear" name="tgi_clear">
610 <item><ref id="tgi_done" name="tgi_done">
611 <item><ref id="tgi_ellipse" name="tgi_ellipse">
612 <item><ref id="tgi_getaspectratio" name="tgi_getaspectratio">
613 <item><ref id="tgi_getcolor" name="tgi_getcolor">
614 <item><ref id="tgi_getcolorcount" name="tgi_getcolorcount">
615 <item><ref id="tgi_getdefpalette" name="tgi_getdefpalette">
616 <item><ref id="tgi_geterror" name="tgi_geterror">
617 <item><ref id="tgi_geterrormsg" name="tgi_geterrormsg">
618 <item><ref id="tgi_getmaxcolor" name="tgi_getmaxcolor">
619 <item><ref id="tgi_getmaxx" name="tgi_getmaxx">
620 <item><ref id="tgi_getmaxy" name="tgi_getmaxy">
621 <item><ref id="tgi_getpagecount" name="tgi_getpagecount">
622 <item><ref id="tgi_getpalette" name="tgi_getpalette">
623 <item><ref id="tgi_getpixel" name="tgi_getpixel">
624 <item><ref id="tgi_getxres" name="tgi_getxres">
625 <item><ref id="tgi_getyres" name="tgi_getyres">
626 <item><ref id="tgi_gotoxy" name="tgi_gotoxy">
627 <item><ref id="tgi_init" name="tgi_init">
628 <item><ref id="tgi_install" name="tgi_install">
629 <item><ref id="tgi_ioctl" name="tgi_ioctl">
630 <item><ref id="tgi_line" name="tgi_line">
631 <item><ref id="tgi_lineto" name="tgi_lineto">
632 <item><ref id="tgi_load_driver" name="tgi_load_driver">
633 <item><ref id="tgi_outtext" name="tgi_outtext">
634 <item><ref id="tgi_outtextxy" name="tgi_outtextxy">
635 <item><ref id="tgi_setaspectratio" name="tgi_setaspectratio">
636 <item><ref id="tgi_setcolor" name="tgi_setcolor">
637 <item><ref id="tgi_setdrawpage" name="tgi_setdrawpage">
638 <item><ref id="tgi_setpalette" name="tgi_setpalette">
639 <item><ref id="tgi_setpixel" name="tgi_setpixel">
640 <item><ref id="tgi_setviewpage" name="tgi_setviewpage">
641 <item><ref id="tgi_gettextheight" name="tgi_gettextheight">
642 <item><ref id="tgi_settextstyle" name="tgi_settextstyle">
643 <item><ref id="tgi_gettextwidth" name="tgi_gettextwidth">
644 <item><ref id="tgi_uninstall" name="tgi_uninstall">
645 <item><ref id="tgi_unload" name="tgi_unload">
648 <sect1><tt/time.h/<label id="time.h"><p>
651 <!-- <item><ref id="_systime" name="_systime"> -->
652 <!-- <item><ref id="asctime" name="asctime"> -->
653 <item><ref id="clock" name="clock">
654 <!-- <item><ref id="ctime" name="ctime"> -->
655 <!-- <item><ref id="gmtime" name="gmtime"> -->
656 <!-- <item><ref id="localtime" name="localtime"> -->
657 <!-- <item><ref id="mktime" name="mktime"> -->
658 <!-- <item><ref id="strftime" name="strftime"> -->
659 <item><ref id="time" name="time">
665 <sect1><tt/unistd.h/<label id="unistd.h"><p>
668 <!-- <item><ref id="chdir" name="chdir"> -->
669 <item><ref id="exec" name="exec">
670 <!-- <item><ref id="getcwd" name="getcwd"> -->
671 <item><ref id="getopt" name="getopt">
672 <!-- <item><ref id="lseek" name="lseek"> -->
673 <!-- <item><ref id="mkdir" name="mkdir"> -->
674 <!-- <item><ref id="read" name="read"> -->
675 <!-- <item><ref id="rmdir" name="rmdir"> -->
676 <item><ref id="sleep" name="sleep">
677 <item><ref id="unlink" name="unlink">
678 <!-- <item><ref id="write" name="write"> -->
684 <sect1><tt/vic20.h/<label id="vic20.h"><p>
689 <sect1><tt/zlib.h/<label id="zlib.h"><p>
692 <!-- <item><ref id="adler32" name="adler32"> -->
693 <!-- <item><ref id="crc32" name="crc32"> -->
694 <!-- <item><ref id="inflatemem" name="inflatemem"> -->
695 <!-- <item><ref id="uncompress" name="uncompress"> -->
701 <sect>Alphabetical function reference<p>
703 <sect1>_heapadd<label id="_heapadd"><p>
707 <tag/Function/Add a block to the heap.
708 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
709 <tag/Declaration/<tt/void __fastcall__ _heapadd (void* mem, size_t size);/
710 <tag/Description/The function adds a block of raw memory to the heap.
713 <item>The minimum blocksize that can be added is 6 bytes; the function will
714 ignore smaller blocks.
716 <tag/Availability/cc65
718 <ref id="_heapblocksize" name="_heapblocksize">,
719 <ref id="_heapmaxavail" name="_heapmaxavail">,
720 <ref id="_heapmemavail" name="_heapmemavail">,
721 <ref id="calloc" name="calloc">,
722 <ref id="free" name="free">,
723 <ref id="malloc" name="malloc">,
724 <ref id="realloc" name="realloc">
730 <sect1>_heapblocksize<label id="_heapblocksize"><p>
734 <tag/Function/Return the size of an allocated block.
735 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
736 <tag/Declaration/<tt/size_t __fastcall__ _heapblocksize (const void* block);/
737 <tag/Description/The function returns the size of a block that must have
738 previously been allocated by <tt/<ref id="malloc" name="malloc">/, <tt/<ref
739 id="calloc" name="calloc">/ or <tt/<ref id="realloc" name="realloc">/.
742 <item>Passing a pointer to a block that was is not the result of one of the
743 allocation functions, or that has been free'd will give unpredicable results.
745 <tag/Availability/cc65
747 <ref id="_heapadd" name="_heapadd">,
748 <ref id="_heapmaxavail" name="_heapmaxavail">,
749 <ref id="_heapmemavail" name="_heapmemavail">,
750 <ref id="calloc" name="calloc">,
751 <ref id="free" name="free">,
752 <ref id="malloc" name="malloc">,
753 <ref id="realloc" name="realloc">
759 <sect1>_heapmaxavail<label id="_heapmaxavail"><p>
763 <tag/Function/Return the largest block that is available on the heap.
764 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
765 <tag/Declaration/<tt/size_t _heapmaxavail (void);/
766 <tag/Description/The function returns the size of the largest block that may
767 be allocated from the heap using <tt/<ref id="malloc" name="malloc">/.
768 <tag/Availability/cc65
770 <ref id="_heapadd" name="_heapadd">,
771 <ref id="_heapblocksize" name="_heapblocksize">,
772 <ref id="_heapmemavail" name="_heapmemavail">,
773 <ref id="calloc" name="calloc">,
774 <ref id="free" name="free">,
775 <ref id="malloc" name="malloc">,
776 <ref id="realloc" name="realloc">
782 <sect1>_heapmemavail<label id="_heapmemavail"><p>
786 <tag/Function/Return the total available space on the heap.
787 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
788 <tag/Declaration/<tt/size_t __fastcall__ _heapmemavail (void);/
789 <tag/Description/The function returns the total number of bytes available on
793 <item>This function is of less use than usually assumed, since the returned
794 heap space may be available but not in one block. So even if this function
795 says that several times more heap space is available than needed, <ref
796 id="malloc" name="malloc"> may still return <tt/NULL/.
798 <tag/Availability/cc65
800 <ref id="_heapadd" name="_heapadd">,
801 <ref id="_heapblocksize" name="_heapblocksize">,
802 <ref id="_heapmaxavail" name="_heapmaxavail">,
803 <ref id="calloc" name="calloc">,
804 <ref id="free" name="free">,
805 <ref id="malloc" name="malloc">,
806 <ref id="realloc" name="realloc">
812 <sect1>_poserror<label id="_poserror"><p>
816 <tag/Function/Print an error message for the error in <tt/_oserror/.
817 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
818 <tag/Declaration/<tt/void __fastcall__ _poserror (const char* msg);/
819 <tag/Description/<tt/_poserror/ prints an error message to <tt/stderr/. If
820 <tt/msg/ is not <tt/NULL/ and not an empty string, it is printed followed by
821 a colon and a blank. Then the error message for the current contents of
822 <tt/_oserror/ are printed followed by a newline. The message output is the
823 same as returned by <tt/<ref id="_stroserror" name="_stroserror">/ with an
824 argument of <tt/_oserror/.
827 <item>Since operating system specific error code are - you guessed it -
828 operating system specific, the value in <tt/_oserror/ and the message that is
829 printed depends on the cc65 target.
830 <item>The function is only available as fastcall function, so it may only
831 be used in presence of a prototype.
833 <tag/Availability/cc65
835 <ref id="_stroserror" name="_stroserror">,
836 <ref id="perror" name="perror">
842 <sect1>_randomize<label id="_randomize"><p>
846 <tag/Function/Initialize the pseudo random number generator.
847 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
848 <tag/Declaration/<tt/void _randomize (void);/
849 <tag/Description/The function initializes the random number generator with
850 a seed derived from fast changing hardware events, so the seed itself can be
851 considered random to a certain degree.
852 <tag/Limits/<itemize>
853 <item>The randomness of the seed depends on the machine hardware.
855 <tag/Availability/cc65
857 <ref id="rand" name="rand">,
858 <ref id="srand" name="srand">
864 <sect1>_stroserror<label id="_stroserror"><p>
868 <tag/Function/Return a string describing an OS specific error code.
869 <tag/Header/<tt/<ref id="string.h" name="string.h">/
870 <tag/Declaration/<tt/const char* __fastcall__ _stroserror (unsigned char errcode);/
871 <tag/Description/<tt/_stroserror/ will return a string describing the given
872 operating system specific error code.
873 <tag/Limits/<itemize>
874 <item>Since operating system specific error code are - you guessed it -
875 operating system specific, the parameter and the string returned depend on the
877 <item>The function is only available as fastcall function, so it may only be
878 used in presence of a prototype.
880 <tag/Availability/cc65
882 <ref id="strerror" name="strerror">
888 <sect1>_swap<label id="_swap"><p>
892 <tag/Function/Swap the contents of memory areas.
893 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
894 <tag/Declaration/<tt/void __fastcall__ _swap (void* p, void* q, size_t size);/
895 <tag/Description/<tt/_swap/ will swap (exchange) the contents of the two memory
896 areas pointed to by <tt/p/ and <tt/q/. Both memory areas are assumed to be
897 <tt/size/ bytes in size.
898 <tag/Limits/<itemize>
899 <item>The memory areas may not overlap, otherwise the results are undefined.
900 <item>The function is only available as fastcall function, so it may only be
901 used in presence of a prototype.
903 <tag/Availability/cc65
905 <ref id="memcpy" name="memcpy">,
906 <ref id="memmove" name="memmove">
912 <sect1>_sys<label id="_sys"><p>
916 <tag/Function/Call a subroutine passing register values.
917 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
918 <tag/Declaration/<tt/void __fastcall__ _sys (struct regs* r);/
919 <tag/Description/The function will call the subroutine at the address
920 specified in the <tt/pc/ member of the passed <tt/regs/ structure. All
921 registers and the CPU flags are set to the values given in the <tt/regs/
922 structure. On return from the subroutine, the new values of the registers and
923 flags are stored back overwriting the old values.
924 <tag/Limits/<itemize>
925 <item>Bits 4 and 5 of the flags value in the <tt/regs/ structure are ignored
926 when calling the subroutine (they are unchanged from their current values).
927 <item>The function is only available as fastcall function, so it may only be
928 used in presence of a prototype.
930 <tag/Availability/cc65
936 <sect1>BRK<label id="BRK"><p>
940 <tag/Function/Insert a 6502 BRK instrunction into the code.
941 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
942 <tag/Declaration/<tt/void BRK (void);/
943 <tag/Description/The function will insert a 6502 BRK instruction into the code
944 which may be used to trigger a debugger.
945 <tag/Limits/<itemize>
946 <item>The function is actually a macro.
947 <item>The inserted instruction may lead to unexpected results if no debugger
950 <tag/Availability/cc65
952 <ref id="CLI" name="CLI">,
953 <ref id="SEI" name="SEI">
959 <sect1>CLI<label id="CLI"><p>
963 <tag/Function/Insert a 6502 CLI instrunction into the code.
964 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
965 <tag/Declaration/<tt/void CLI (void);/
966 <tag/Description/The function will insert a 6502 CLI instruction into the code,
967 so interrupts are enabled. Enabling interrupts has no effects if they are
968 already enabled (the default).
969 <tag/Limits/<itemize>
970 <item>The function is actually a macro.
971 <item>Disabling interrupts may lead to unexpected results.
973 <tag/Availability/cc65
975 <ref id="BRK" name="BRK">,
976 <ref id="SEI" name="SEI">
982 <sect1>PEEK<label id="PEEK"><p>
986 <tag/Function/Read a byte from memory.
987 <tag/Header/<tt/<ref id="peekpoke.h" name="peekpoke.h">/
988 <tag/Declaration/<tt/unsigned char PEEK (unsigned addr);/
989 <tag/Description/The function will read the absolute memory given by <tt/addr/
990 and return the value read.
991 <tag/Limits/<itemize>
992 <item>The function is actually a macro.
993 <item>This function depends highly on the platform and environment.
995 <tag/Availability/cc65
997 <ref id="PEEKW" name="PEEKW">,
998 <ref id="POKE" name="POKE">
1004 <sect1>PEEKW<label id="PEEKW"><p>
1008 <tag/Function/Read a word (two bytes) from memory.
1009 <tag/Header/<tt/<ref id="peekpoke.h" name="peekpoke.h">/
1010 <tag/Declaration/<tt/unsigned PEEKW (unsigned addr);/
1011 <tag/Description/The function will read the absolute memory given by <tt/addr/
1012 and return the value read. The byte read from the higher address is the high
1013 byte of the return value.
1014 <tag/Limits/<itemize>
1015 <item>The function is actually a macro.
1016 <item>This function depends highly on the platform and environment.
1017 <item>The order in which the two bytes are read is unspecified and may
1018 depend of the address expression used.
1020 <tag/Availability/cc65
1022 <ref id="PEEK" name="PEEK">,
1023 <ref id="POKE" name="POKE">
1029 <sect1>POKE<label id="POKE"><p>
1033 <tag/Function/Write a byte to memory.
1034 <tag/Header/<tt/<ref id="peekpoke.h" name="peekpoke.h">/
1035 <tag/Declaration/<tt/void POKE (unsigned addr, unsigned char val);/
1036 <tag/Description/The function writes the value <tt/val/ to the absolute
1037 memory address given by <tt/addr/.
1038 <tag/Limits/<itemize>
1039 <item>The function is actually a macro.
1040 <item>This function depends highly on the platform and environment.
1041 <item>Careless use will cause the program to act strange or may crash the
1044 <tag/Availability/cc65
1046 <ref id="PEEK" name="PEEK">,
1047 <ref id="POKEW" name="POKEW">
1053 <sect1>POKEW<label id="POKEW"><p>
1057 <tag/Function/Write a word (two bytes) to memory.
1058 <tag/Header/<tt/<ref id="peekpoke.h" name="peekpoke.h">/
1059 <tag/Declaration/<tt/void POKEW (unsigned addr, unsigned val);/
1060 <tag/Description/The function writes the value <tt/val/ to the absolute
1061 memory address given by <tt/addr/. The low byte of <tt/val/ is written to
1062 the <tt/addr/, the high byte is written to <tt/addr+1/.
1063 <tag/Limits/<itemize>
1064 <item>The function is actually a macro.
1065 <item>This function depends highly on the platform and environment.
1066 <item>Careless use will cause the program to act strange or may crash the
1068 <item>The order in which the two bytes are written is unspecified and may
1069 depend of the address expression used.
1071 <tag/Availability/cc65
1073 <ref id="PEEK" name="PEEK">,
1074 <ref id="POKE" name="POKE">
1080 <sect1>SEI<label id="SEI"><p>
1084 <tag/Function/Insert a 6502 SEI instrunction into the code.
1085 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
1086 <tag/Declaration/<tt/void SEI (void);/
1087 <tag/Description/The function will insert a 6502 SEI instruction into the code,
1088 so interrupts are disabled. Note that non maskable interrupts cannot be
1090 <tag/Limits/<itemize>
1091 <item>The function is actually a macro.
1092 <item>Disabling interrupts may lead to unexpected results.
1094 <tag/Availability/cc65
1096 <ref id="BRK" name="BRK">,
1097 <ref id="CLI" name="CLI">
1103 <sect1>abort<label id="abort"><p>
1107 <tag/Function/Terminates a program abnormally.
1108 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1109 <tag/Declaration/<tt/void abort (void);/
1110 <tag/Description/<tt/abort/ raises <tt/SIGABRT/, writes a termination message
1111 on stderr, then terminates the program with an exit code of 3.
1112 <tag/Availability/ISO 9899
1114 <ref id="assert" name="assert">,
1115 <ref id="exit" name="exit">,
1116 <ref id="raise" name="raise">
1122 <sect1>abs<label id="abs"><p>
1126 <tag/Function/Returns the absolute value of an integer.
1127 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1128 <tag/Declaration/<tt/int __fastcall__ abs (int v);/
1129 <tag/Description/<tt/abs/ returns the absolute value of the argument passed to
1131 <tag/Limits/<itemize>
1132 <item>The return value is undefined if <tt/INT_MIN/ is passed to the function.
1133 <item>The function is only available as fastcall function, so it may only be
1134 used in presence of a prototype.
1136 <tag/Availability/ISO 9899
1138 <ref id="labs" name="labs">
1144 <sect1>assert<label id="assert"><p>
1148 <tag/Function/Test a condition and possibly abort.
1149 <tag/Header/<tt/<ref id="assert.h" name="assert.h">/
1150 <tag/Declaration/<tt/void assert (int cond);/
1151 <tag/Description/<tt/assert/ is a macro that expands to a <tt/id/
1152 statement. If the condition evaluates t zero (false), assert prints a message
1153 on stderr and aborts the program.
1154 <tag/Limits/<itemize>
1155 <item>The function is actually a macro.
1157 <tag/Availability/ISO 9899
1159 <ref id="abort" name="abort">,
1160 <ref id="exit" name="exit">
1166 <sect1>atexit<label id="atexit"><p>
1170 <tag/Function/Register an exit function.
1171 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1172 <tag/Declaration/<tt/int __fastcall__ atexit (void (*exitfunc) (void));/
1173 <tag/Description/<tt/atexit/ registers the function pointed to by
1174 <tt/exitfunc/ as an exit function. Exit functions are called when the program
1175 terminates, they are called in LIFO order (the last function registered is
1176 called first). <tt/atexit/ returns zero on success and a nonzero value on
1178 <tag/Limits/<itemize>
1179 <item>A maximum of 5 exit functions can be registered.
1180 <item>There is no way to unregister an exit function.
1181 <item>The function is only available as fastcall function, so it may only be
1182 used in presence of a prototype.
1184 <tag/Availability/ISO 9899
1186 <ref id="abort" name="abort">,
1187 <ref id="exit" name="exit">
1193 <sect1>atmos_load<label id="atmos_load"><p>
1197 <tag/Function/Load Atmos tape.
1198 <tag/Header/<tt/<ref id="atmos.h" name="atmos.h">/
1199 <tag/Declaration/<tt/void __fastcall__ atmos_load(const char* name);/
1200 <tag/Description/<tt/atmos_load/ reads a memory block from tape.
1201 <tag/Availability/cc65
1203 <ref id="atmos_save" name="atmos_save">
1209 <sect1>atmos_save<label id="atmos_save"><p>
1213 <tag/Function/Save Atmos tape.
1214 <tag/Header/<tt/<ref id="atmos.h" name="atmos.h">/
1215 <tag/Declaration/<tt/void __fastcall__ atmos_save(const char* name, const void* start, const void* end);/
1216 <tag/Description/<tt/atmos_save/ writes a memory block to tape.
1217 <tag/Availability/cc65
1219 <ref id="atmos_load" name="atmos_load">
1221 atmos_save("hires", 0xa000, 0xc000);
1227 <sect1>atoi<label id="atoi"><p>
1231 <tag/Function/Convert a string to an integer.
1232 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1233 <tag/Declaration/<tt/int __fastcall__ atoi (const char* s);/
1234 <tag/Description/<tt/atoi/ converts the given string into an integer.
1235 Conversion stops as soon as any invalid character is encountered.
1236 <tag/Limits/<itemize>
1237 <item>There is no way to detect any conversion errors.
1238 <item>The function does not check for an numerical overflow when converting.
1239 <item>The function is only available as fastcall function, so it may only be
1240 used in presence of a prototype.
1242 <tag/Availability/ISO 9899
1244 <ref id="atol" name="atol">,
1245 <ref id="itoa" name="itoa">,
1246 <ref id="ltoa" name="ltoa">,
1247 <ref id="ultoa" name="ultoa">,
1248 <ref id="utoa" name="utoa">
1254 <sect1>atol<label id="atol"><p>
1258 <tag/Function/Convert a string to a long integer.
1259 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1260 <tag/Declaration/<tt/long __fastcall__ atol (const char* s);/
1261 <tag/Description/<tt/atol/ converts the given string into a long integer.
1262 Conversion stops as soon as any invalid character is encountered.
1263 <tag/Limits/<itemize>
1264 <item>There is no way to detect any conversion errors.
1265 <item>The function does not check for an numerical overflow when converting.
1266 <item>The function is only available as fastcall function, so it may only be
1267 used in presence of a prototype.
1269 <tag/Availability/ISO 9899
1271 <ref id="atoi" name="atoi">,
1272 <ref id="itoa" name="itoa">,
1273 <ref id="ltoa" name="ltoa">,
1274 <ref id="ultoa" name="ultoa">,
1275 <ref id="utoa" name="utoa">
1281 <sect1>bgcolor<label id="bgcolor"><p>
1285 <tag/Function/Set the background text color.
1286 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1287 <tag/Declaration/<tt/unsigned char __fastcall__ bgcolor (unsigned char color);/
1288 <tag/Description/The function will set a new background color and return the
1289 old (current) one. The background color is valid for the whole text output
1290 area of the screen, not just for new text.
1291 <tag/Limits/<itemize>
1292 <item>Background colors are system dependent. The function may have no effect
1293 on systems where the background color cannot be changed.
1294 <item>The function is only available as fastcall function, so it may only be
1295 used in presence of a prototype.
1297 <tag/Availability/cc65
1299 <ref id="bordercolor" name="bordercolor">,
1300 <ref id="textcolor" name="textcolor">
1306 <sect1>bordercolor<label id="bordercolor"><p>
1310 <tag/Function/Set the border (frame) color.
1311 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1312 <tag/Declaration/<tt/unsigned char __fastcall__ bordercolor (unsigned char color);/
1313 <tag/Description/The function will set a new border color. It returns the old
1314 (current) border color.
1315 <tag/Limits/<itemize>
1316 <item>Border colors are system dependent. The function may have no effect
1317 on systems where the border color cannot be changed.
1318 <item>The function is only available as fastcall function, so it may only
1319 be used in presence of a prototype.
1321 <tag/Availability/cc65
1323 <ref id="bgcolor" name="bgcolor">,
1324 <ref id="textcolor" name="textcolor">
1330 <sect1>bsearch<label id="bsearch"><p>
1334 <tag/Function/Do a binary search in a sorted array.
1335 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1336 <tag/Declaration/<tt/void* __fastcall__ bsearch (const void* key,
1337 const void* base, size_t n, size_t size,
1338 int (*cmp) (const void*, const void*));/
1339 <tag/Description/<tt/bsearch/ searches a sorted array for a member that
1340 matches the one pointed to by <tt/key/. <tt/base/ is the address of the array,
1341 <tt/n/ is the number of elements, <tt/size/ the size of an element and <tt/cmp/
1342 the function used to compare the members against the key. The function returns
1343 a pointer to the member found, or <tt/NULL/ if there was no match.
1346 <item>The contents of the array must be sorted in ascending order according to
1347 the compare function given.
1348 <item>If there are multiple members that match the key, the function will
1349 return one of the members.
1350 <item>The function is only available as fastcall function, so it may only
1351 be used in presence of a prototype.
1353 <tag/Availability/ISO 9899
1355 <ref id="qsort" name="qsort">
1361 <sect1>bzero<label id="bzero"><p>
1365 <tag/Function/Fill a memory area with zeroes.
1366 <tag/Header/<tt/<ref id="string.h" name="string.h">/
1367 <tag/Declaration/<tt/void __fastcall__ bzero (void* p, size_t count);/
1368 <tag/Description/<tt/bzero/ fills the memory area pointed to by <tt/p/ with
1372 <item>The function is non standard and therefore only available in non ANSI
1373 mode. You should use <tt/<ref id="memset" name="memset">/ instead.
1374 <item>The function is only available as fastcall function, so it may only
1375 be used in presence of a prototype.
1377 <tag/Availability/cc65
1379 <ref id="_swap" name="_swap">,
1380 <ref id="memcpy" name="memcpy">,
1381 <ref id="memmove" name="memmove">,
1382 <ref id="memset" name="memset">,
1388 <sect1>c64mode<label id="c64mode"><p>
1392 <tag/Function/Switch the C128 into C64 compatible mode.
1393 <tag/Header/<tt/<ref id="c128.h" name="c128.h">/
1394 <tag/Declaration/<tt/void c64mode (void);/
1395 <tag/Description/The function will cause the machine to reboot into C64 mode.
1396 <tag/Limits/<itemize>
1397 <item>The function is specific to the C128.
1398 <item>The function will not return to the caller.
1400 <tag/Availability/C128
1406 <sect1>calloc<label id="calloc"><p>
1410 <tag/Function/Allocate and clear memory.
1411 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1412 <tag/Declaration/<tt/void* __fastcall__ calloc (size_t n, size_t size);/
1413 <tag/Description/<tt/calloc/ allocates memory for an array of <tt/n/ elements
1414 of size <tt/size/, clears the whole block with binary zeroes and returns a
1415 pointer to it. On error (not enough memory available), <tt/calloc/ returns
1419 <item>Clearing the memory may not have the expected effect on all platforms:
1420 pointers in the block may not be <tt/NULL/ and floating point variables may
1421 not be zero (0.0). In other words: The "clearing" effect of this function
1422 should be used with care for portable programs.
1423 <item>The function is only available as fastcall function, so it may only
1424 be used in presence of a prototype.
1426 <tag/Availability/ISO 9899
1428 <ref id="_heapadd" name="_heapadd">,
1429 <ref id="_heapblocksize" name="_heapblocksize">,
1430 <ref id="_heapmaxavail" name="_heapmaxavail">,
1431 <ref id="_heapmemavail" name="_heapmemavail">,
1432 <ref id="free" name="free">,
1433 <ref id="malloc" name="malloc">,
1434 <ref id="realloc" name="realloc">
1440 <sect1>cclear<label id="cclear"><p>
1444 <tag/Function/Clear part of a line (write a given number of spaces).
1445 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1446 <tag/Declaration/<tt/void __fastcall__ cclear (unsigned char length);/
1447 <tag/Description/The function clears part of a line by writing <tt/length/
1448 spaces in the current text color.
1449 <tag/Limits/<itemize>
1450 <item>The function is only available as fastcall function, so it may
1451 only be used in presence of a prototype.
1453 <tag/Availability/cc65
1455 <ref id="cclearxy" name="cclearxy">,
1456 <ref id="clrscr" name="clrscr">
1462 <sect1>cclearxy<label id="cclearxy"><p>
1466 <tag/Function/Clear part of a line (write a given number of spaces) starting
1467 at a specific screen position.
1468 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1469 <tag/Declaration/<tt/void __fastcall__ cclearxy (unsigned char x, unsigned char y, unsigned char length);/
1470 <tag/Description/The function moves the cursor to a specific position, and
1471 will then clear part of the line by writing <tt/length/ spaces in the current
1473 <tag/Limits/<itemize>
1474 <item>The function is only available as fastcall function, so it may
1475 only be used in presence of a prototype.
1477 <tag/Availability/cc65
1479 <ref id="cclear" name="cclear">,
1480 <ref id="clrscr" name="clrscr">
1486 <sect1>cgetc<label id="cgetc"><p>
1490 <tag/Function/Read a character from the keyboard.
1491 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1492 <tag/Declaration/<tt/char cgetc (void);/
1493 <tag/Description/The function reads a character from the keyboard. If there is
1494 no character available, <tt/cgetc/ waits until the user presses a key. If the
1495 cursor is enabled by use of the <tt/cursor/ function, a blinking cursor is
1496 displayed while waiting.
1497 <tag/Limits/<itemize>
1498 <item>If the system supports a keyboard buffer, <tt/cgetc/ will fetch a key
1499 from this buffer and wait only if the buffer is empty.
1501 <tag/Availability/cc65
1503 <ref id="cursor" name="cursor">,
1504 <ref id="kbhit" name="kbhit">
1510 <sect1>chline<label id="chline"><p>
1514 <tag/Function/Output a horizontal line in text mode.
1515 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1516 <tag/Declaration/<tt/void __fastcall__ chline (unsigned char length);/
1517 <tag/Description/The function outputs a horizontal line with the given length
1518 starting at the current cursor position.
1519 <tag/Limits/<itemize>
1520 <item>The character used to draw the horizontal line is system dependent.
1521 If available, a line drawing character is used. Drawing a line that is partially
1522 off screen leads to undefined behaviour.
1523 <item>The function is only available as fastcall function, so it may only be
1524 used in presence of a prototype.
1526 <tag/Availability/cc65
1528 <ref id="chlinexy" name="chlinexy">,
1529 <ref id="cvline" name="cvline">,
1530 <ref id="cvlinexy" name="cvlinexy">
1536 <sect1>chlinexy<label id="chlinexy"><p>
1540 <tag/Function/Output a horizontal line at a given position in text mode.
1541 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1542 <tag/Declaration/<tt/void __fastcall__ chlinexy (unsigned char x, unsigned char y, unsigned char length);/
1543 <tag/Description/The function outputs a horizontal line with the given length
1544 starting at a given position.
1545 <tag/Limits/<itemize>
1546 <item>The character used to draw the horizontal line is system dependent.
1547 If available, a line drawing character is used. Drawing a line that is partially
1548 off screen leads to undefined behaviour.
1549 <item>The function is only available as fastcall function, so it may only be
1550 used in presence of a prototype.
1552 <tag/Availability/cc65
1554 <ref id="chline" name="chline">,
1555 <ref id="cvline" name="cvline">,
1556 <ref id="cvlinexy" name="cvlinexy">
1562 <sect1>clearerr<label id="clearerr"><p>
1566 <tag/Function/Clear error and end-of-file status of a stream.
1567 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
1568 <tag/Declaration/<tt/void __fastcall__ clearerr (FILE* f);/
1569 <tag/Description/<tt/clearerr/ clears the error and end-of-file status
1570 indicators for the stream <tt/f/.
1571 <tag/Limits/<itemize>
1572 <item>The function is only available as fastcall function, so it may only be
1573 used in presence of a prototype.
1575 <tag/Availability/ISO 9899
1577 <ref id="feof" name="feof">,
1578 <ref id="ferror" name="ferror">
1584 <sect1>clock<label id="clock"><p>
1588 <tag/Function/Determine the processor time used.
1589 <tag/Header/<tt/<ref id="time.h" name="time.h">/
1590 <tag/Declaration/<tt/clock_t clock (void);/
1591 <tag/Description/The <tt/clock/ function returns an approximaton of processor
1592 time used by the program. The time is returned in implementation defined
1593 units. It can be converted to seconds by dividing by the value of the macro
1594 <tt/CLOCKS_PER_SEC/.
1595 <tag/Limits/<itemize>
1596 <item>Since the machines, cc65 generated programs run on, cannot run multiple
1597 processes, the function will actually return the time since some
1598 implementation defined point in the past.
1600 <tag/Availability/ISO 9899
1602 <ref id="time" name="time">
1608 <sect1>clrscr<label id="clrscr"><p>
1612 <tag/Function/Clear the text screen.
1613 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1614 <tag/Declaration/<tt/void clrscr (void);/
1615 <tag/Description/The function clears the text screen and moves the cursor to
1616 the upper left corner.
1617 <tag/Availability/cc65
1619 <ref id="cclear" name="cclear">,
1620 <ref id="cclearxy" name="cclearxy">
1626 <sect1>close<label id="close"><p>
1630 <tag/Function/Close a file descriptor.
1631 <tag/Header/<tt/<ref id="fcntl.h" name="fcntl.h">/
1632 <tag/Declaration/<tt/int __fastcall__ close (int fd);/
1633 <tag/Description/The function closes the given file descriptor. It returns zero
1634 on success and -1 on error. If an error occurs, the cause can be determined by
1635 reading the <tt/errno/ variable.
1636 <tag/Limits/<itemize>
1637 <item>The function is only available as fastcall function, so it may only
1638 be used in presence of a prototype.
1640 <tag/Availability/POSIX 1003.1
1642 <ref id="creat" name="creat">,
1643 <ref id="open" name="open">
1649 <sect1>creat<label id="creat"><p>
1653 <tag/Function/Create a file.
1654 <tag/Header/<tt/<ref id="fcntl.h" name="fcntl.h">/
1655 <tag/Declaration/<tt/int __fastcall__ creat (const char* name, unsigned mode);/
1656 <tag/Description/<tt/creat/ creates a new file and returns the file descriptor
1657 associated with it. On error, -1 is returned and an error code is stored in
1659 <tag/Limits/<itemize>
1660 <item><tt/creat/ is identical to calling <tt/<ref id="open" name="open">/ with
1661 <tt/flags/ equal to <tt/O_WRONLY | O_CREAT | O_TRUNC/.
1662 <item>The function is only available as fastcall function, so it may only
1663 be used in presence of a prototype.
1665 <tag/Availability/POSIX 1003.1
1667 <ref id="close" name="close">,
1668 <ref id="open" name="open">
1674 <sect1>cprintf<label id="cprintf"><p>
1678 <tag/Function/Formatted output to the console.
1679 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1680 <tag/Declaration/<tt/int cprintf (const char* format, ...);/
1681 <tag/Description/The arguments are converted to text where necessary and
1682 formatted according to the format string given. The resulting string is output
1683 to the console. <tt/cprintf/ supports the same format specifiers as
1684 <tt/printf/. <!-- <tt/<ref id="printf" name="printf">/. -->
1685 <tag/Limits/<itemize>
1686 <item>Like all other <tt/conio/ output functions, <tt/cprintf/ distinguishes
1687 between <tt/\r/ and <tt/\n/.
1689 <tag/Availability/cc65
1691 <ref id="cputc" name="cputc">,
1692 <ref id="cputcxy" name="cputcxy">,
1693 <ref id="cputs" name="cputs">,
1694 <ref id="cputsxy" name="cputsxy">,
1695 <ref id="vcprintf" name="vcprintf">
1701 <sect1>cputc<label id="cputc"><p>
1705 <tag/Function/Output a character directly to the console.
1706 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1707 <tag/Declaration/<tt/void __fastcall__ cputc (char c);/
1708 <tag/Description/Output one character to the console at the current cursor
1710 <tag/Limits/<itemize>
1711 <item>Like all other <tt/conio/ output functions, <tt/cputc/ distinguishes
1712 between <tt/\r/ and <tt/\n/.
1713 <item>The function is only available as fastcall function, so it may only
1714 be used in presence of a prototype.
1716 <tag/Availability/cc65
1718 <ref id="cprintf" name="cprintf">,
1719 <ref id="cputcxy" name="cputcxy">,
1720 <ref id="cputs" name="cputs">,
1721 <ref id="cputsxy" name="cputsxy">,
1722 <ref id="vcprintf" name="vcprintf">
1728 <sect1>cputcxy<label id="cputcxy"><p>
1732 <tag/Function/Output a character at a specific screen position.
1733 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1734 <tag/Declaration/<tt/void __fastcall__ cputcxy (unsigned char x, unsigned char y, char c);/
1735 <tag/Description/<tt/cputcxy/ moves the cursor to the given x/y position on
1736 the screen and outputs one character.
1737 <tag/Limits/<itemize>
1738 <item>Like all other <tt/conio/ output functions, <tt/cputcxy/ distinguishes
1739 between <tt/\r/ and <tt/\n/.
1740 <item>The function is only available as fastcall function, so it may only
1741 be used in presence of a prototype.
1743 <tag/Availability/cc65
1745 <ref id="cprintf" name="cprintf">,
1746 <ref id="cputc" name="cputc">,
1747 <ref id="cputs" name="cputs">,
1748 <ref id="cputsxy" name="cputsxy">,
1749 <ref id="vcprintf" name="vcprintf">
1755 <sect1>cputs<label id="cputs"><p>
1759 <tag/Function/Output a string directly to the console.
1760 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1761 <tag/Declaration/<tt/void __fastcall__ cputs (const char* s);/
1762 <tag/Description/The function outputs the given string on the console at the
1763 current cursor position.
1764 <tag/Limits/<itemize>
1765 <item>Like all other <tt/conio/ output functions, <tt/cputs/ distinguishes
1766 between <tt/\r/ and <tt/\n/.
1767 <item>The function is only available as fastcall function, so it may only
1768 be used in presence of a prototype.
1770 <tag/Availability/cc65
1772 <ref id="cprintf" name="cprintf">,
1773 <ref id="cputc" name="cputc">,
1774 <ref id="cputcxy" name="cputcxy">,
1775 <ref id="cputsxy" name="cputsxy">,
1776 <ref id="vcprintf" name="vcprintf">
1782 <sect1>cputsxy<label id="cputsxy"><p>
1786 <tag/Function/Output a string to the console at a given position.
1787 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1788 <tag/Declaration/<tt/void __fastcall__ cputsxy (unsigned char x, unsigned char y, const char* s);/
1789 <tag/Description/<tt/cputsxy/ moves the cursor to the given x/y position,
1790 and outputs the string <tt/s/.
1791 <tag/Limits/<itemize>
1792 <item>Like all other <tt/conio/ output functions, <tt/cputsxy/ distinguishes
1793 between <tt/\r/ and <tt/\n/.
1794 <item>The function is only available as fastcall function, so it may only
1795 be used in presence of a prototype.
1797 <tag/Availability/cc65
1799 <ref id="cprintf" name="cprintf">,
1800 <ref id="cputc" name="cputc">,
1801 <ref id="cputcxy" name="cputcxy">,
1802 <ref id="cputs" name="cputs">,
1803 <ref id="vcprintf" name="vcprintf">
1809 <sect1>cursor<label id="cursor"><p>
1813 <tag/Function/Enable/disable a blinking cursor when waiting for keyboard input.
1814 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1815 <tag/Declaration/<tt/unsigned char __fastcall__ cursor (unsigned char onoff);/
1816 <tag/Description/If the argument to the function is non zero, a blinking cursor
1817 will be enabled when the <tt/cgetc/ function waits for input from the keyboard.
1818 If the argument is zero, <tt/cgetc/ will wait without a blinking cursor.
1819 <tag/Limits/<itemize>
1820 <item>The function is only available as fastcall function, so it may only
1821 be used in presence of a prototype.
1823 <tag/Availability/cc65
1825 <ref id="cgetc" name="cgetc">,
1826 <ref id="kbhit" name="kbhit">
1832 <sect1>cvline<label id="cvline"><p>
1836 <tag/Function/Output a vertical line in text mode.
1837 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1838 <tag/Declaration/<tt/void __fastcall__ cvline (unsigned char length);/
1839 <tag/Description/The function outputs a vertical line with the given length
1840 starting at the current cursor position.
1841 <tag/Limits/<itemize>
1842 <item>The character used to draw the vertical line is system dependent.
1843 If available, a line drawing character is used. Drawing a line that is partially
1844 off screen leads to undefined behaviour.
1845 <item>The function is only available as fastcall function, so it may only be
1846 used in presence of a prototype.
1848 <tag/Availability/cc65
1850 <ref id="chline" name="chline">,
1851 <ref id="chlinexy" name="chlinexy">,
1852 <ref id="cvlinexy" name="cvlinexy">
1858 <sect1>cvlinexy<label id="cvlinexy"><p>
1862 <tag/Function/Output a vertical line at a given position in text mode.
1863 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1864 <tag/Declaration/<tt/void __fastcall__ cvlinexy (unsigned char x, unsigned char y, unsigned char length);/
1865 <tag/Description/The function outputs a vertical line with the given length
1866 starting at a given position.
1867 <tag/Limits/<itemize>
1868 <item>The character used to draw the vertical line is system dependent.
1869 If available, a line drawing character is used. Drawing a line that is partially
1870 off screen leads to undefined behaviour.
1871 <item>The function is only available as fastcall function, so it may only be
1872 used in presence of a prototype.
1874 <tag/Availability/cc65
1876 <ref id="chline" name="chline">,
1877 <ref id="chlinexy" name="chlinexy">,
1878 <ref id="cvline" name="cvline">
1884 <sect1>div<label id="div"><p>
1888 <tag/Function/Divide two ints and return quotient and remainder.
1889 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1890 <tag/Declaration/<tt/div_t __fastcall__ div (int numer, int denom);/
1891 <tag/Description/<tt/div/ divides <tt/numer/ by <tt/denom/ and returns the
1892 quotient and remainder in a <tt/div_t/ structure.
1895 <item>The function is only available as fastcall function, so it may only
1896 be used in presence of a prototype.
1898 <tag/Availability/ISO 9899
1906 <sect1>em_commit<label id="em_commit"><p>
1910 <tag/Function/Commit changes into extended memory.
1911 <tag/Header/<tt/<ref id="em.h" name="em.h">/
1912 <tag/Declaration/<tt/void em_commit (void);/
1913 <tag/Description/Commit changes in the memory window to extended storage. If
1914 the contents of the memory window have been changed, these changes may be lost
1915 if <tt/<ref id="em_map" name="em_map">/, <tt/<ref id="em_use" name="em_use">/,
1916 <tt/<ref id="em_copyfrom" name="em_copyfrom">/ or <tt/<ref id="em_copyto"
1917 name="em_copyto">/ are called without calling <tt/em_commit/ first.
1918 <tag/Limits/<itemize>
1919 <item>Calling <tt/em_commit/ does not necessarily mean that changes to the
1920 memory window are discarded, it does just mean that the drivers is allowed
1922 <item>The function is only available as fastcall function, so it may only be
1923 used in presence of a prototype.
1924 <item>The function produces undefined results if no extended memory driver is
1927 <tag/Availability/cc65
1929 <ref id="em_load_driver" name="em_load_driver">,
1930 <ref id="em_map" name="em_map">,
1931 <ref id="em_use" name="em_use">
1937 <sect1>em_copyfrom<label id="em_copyfrom"><p>
1941 <tag/Function/Copy from extended into normal memory.
1942 <tag/Header/<tt/<ref id="em.h" name="em.h">/
1943 <tag/Declaration/<tt/void __fastcall__ em_copyfrom (const struct em_copy* copy_data);/
1944 <tag/Description/Copy data from extended memory into linear memory. Source and
1945 target addresses as well as the number of bytes to transfer are specified in
1946 the <tt/em_copy/ structure that is passed as a parameter.
1947 <tag/Limits/<itemize>
1948 <item>Calling <tt/em_copyfrom/ will invalidate the memory window, so if you
1949 made any changes to the data in the window, call <tt/<ref id="em_commit"
1950 name="em_commit">/ first, or the changes are lost.
1951 <item>The function is only available as fastcall function, so it may only be
1952 used in presence of a prototype.
1953 <item>The function produces undefined results if no extended memory driver is
1956 <tag/Availability/cc65
1958 <ref id="em_commit" name="em_commit">,
1959 <ref id="em_copyto" name="em_copyto">,
1960 <ref id="em_load_driver" name="em_load_driver">
1966 <sect1>em_copyto<label id="em_copyto"><p>
1970 <tag/Function/Copy from normal into extended memory.
1971 <tag/Header/<tt/<ref id="em.h" name="em.h">/
1972 <tag/Declaration/<tt/void __fastcall__ em_copyto (const struct em_copy* copy_data);/
1973 <tag/Description/Copy data from linear into extended memory. Source and
1974 target addresses as well as the number of bytes to transfer are specified in
1975 the <tt/em_copy/ structure that is passed as a parameter.
1976 <tag/Limits/<itemize>
1977 <item>Calling <tt/em_copyto/ will invalidate the memory window, so if you
1978 made any changes to the data in the window, call <tt/<ref id="em_commit"
1979 name="em_commit">/ first, or the changes are lost.
1980 <item>The function is only available as fastcall function, so it may only be
1981 used in presence of a prototype.
1982 <item>The function produces undefined results if no extended memory driver is
1985 <tag/Availability/cc65
1987 <ref id="em_commit" name="em_commit">,
1988 <ref id="em_copyfrom" name="em_copyfrom">,
1989 <ref id="em_load_driver" name="em_load_driver">
1995 <sect1>em_install<label id="em_install"><p>
1999 <tag/Function/Install an already loaded extended memory driver.
2000 <tag/Header/<tt/<ref id="em.h" name="em.h">/
2001 <tag/Declaration/<tt/unsigned char _fastcall__ em_install (void* driver);/
2002 <tag/Description/The function installs an already loaded extended memory driver
2003 and returns an error code. The function may be used to install a driver linked
2004 statically to the program.
2005 <tag/Limits/<itemize>
2006 <item>Not all drivers are able to detect if the supported hardware is really
2008 <item>The function is only available as fastcall function, so it may only be
2009 used in presence of a prototype.
2011 <tag/Availability/cc65
2013 <ref id="em_load_driver" name="em_load_driver">,
2014 <ref id="em_uninstall" name="em_uninstall">,
2015 <ref id="em_unload" name="em_unload">
2021 <sect1>em_load_driver<label id="em_load_driver"><p>
2025 <tag/Function/Load and initialize an extended memory driver.
2026 <tag/Header/<tt/<ref id="em.h" name="em.h">/
2027 <tag/Declaration/<tt/void __fastcall__ em_load_driver (const char* name);/
2028 <tag/Description/Load an extended memory driver into memory and initialize
2029 it. The function returns an error code that tells if all this has been
2031 <tag/Limits/<itemize>
2032 <item>Not all drivers are able to detect if the supported hardware is really
2034 <item>The function is only available as fastcall function, so it may only be
2035 used in presence of a prototype.
2036 <item>The driver is loaded by name, so currently you must know the type of
2037 extended memory that should be supported. There is no autodetect capability.
2039 <tag/Availability/cc65
2041 <ref id="em_unload" name="em_unload">
2047 <sect1>em_map<label id="em_map"><p>
2051 <tag/Function/Make a page of extended memory accessible.
2052 <tag/Header/<tt/<ref id="em.h" name="em.h">/
2053 <tag/Declaration/<tt/void* __fastcall__ em_map (unsigned page);/
2054 <tag/Description/The function maps one page of extended memory into linear
2055 memory and returns a pointer to the page frame. Depending on the hardware
2056 and driver, the data is either mapped into the address space or transfered
2057 into a buffer. If you don't need the actual contents of the page (for example
2058 because you're going to overwrite it completely), it is better to call
2059 <tt/<ref id="em_use" name="em_use">/ instead. <tt/em_use/ will not transfer the
2060 data if it is possible to avoid that.
2061 <tag/Limits/<itemize>
2062 <item>Calling <tt/em_map/ will invalidate the memory window, so if you
2063 made any changes to the data in the window, call <tt/<ref id="em_commit"
2064 name="em_commit">/ first, or the changes are lost.
2065 <item>The function is only available as fastcall function, so it may only be
2066 used in presence of a prototype.
2067 <item>The function produces undefined results if no extended memory driver is
2070 <tag/Availability/cc65
2072 <ref id="em_commit" name="em_commit">,
2073 <ref id="em_load_driver" name="em_load_driver">,
2074 <ref id="em_use" name="em_use">
2080 <sect1>em_pagecount<label id="em_pagecount"><p>
2084 <tag/Function/Return the number of available extended memory pages.
2085 <tag/Header/<tt/<ref id="em.h" name="em.h">/
2086 <tag/Declaration/<tt/unsigned em_pagecount (void);/
2087 <tag/Description/The function returns the size of the extended memory supported
2088 by the driver in 256 byte pages.
2089 <tag/Limits/<itemize>
2090 <item>The function returns zero if no extended memory driver is loaded.
2091 <item>The function may return zero if the supported hardware was not detected.
2093 <tag/Availability/cc65
2095 <ref id="em_load_driver" name="em_load_driver">
2101 <sect1>em_uninstall<label id="em_uninstall"><p>
2105 <tag/Function/Uninstall an already loaded extended memory driver.
2106 <tag/Header/<tt/<ref id="em.h" name="em.h">/
2107 <tag/Declaration/<tt/unsigned char em_uninstall (void);/
2108 <tag/Description/The function uninstalls an already loaded extended memory
2109 driver but doesn't remove it from memory.
2110 <tag/Limits/<itemize>
2111 <item>If the driver has been loaded using <tt/<ref id="em_load_driver"
2112 name="em_load_driver">/, <tt/<ref id="em_unload" name="em_unload">/
2113 should be used instead of <tt/em_uninstall/ so the driver is also removed
2116 <tag/Availability/cc65
2118 <ref id="em_install" name="em_install">,
2119 <ref id="em_load_driver" name="em_load_driver">,
2120 <ref id="em_unload" name="em_unload">
2126 <sect1>em_unload<label id="em_unload"><p>
2130 <tag/Function/Unload an extended memory driver.
2131 <tag/Header/<tt/<ref id="em.h" name="em.h">/
2132 <tag/Declaration/<tt/unsigned char em_unload (void);/
2133 <tag/Description/The function unloads a loaded extended memory driver and
2134 frees all memory allocated for the driver.
2135 <tag/Limits/<itemize>
2136 <item>The function does nothing if no driver is loaded.
2138 <tag/Availability/cc65
2140 <ref id="em_load_driver" name="em_load_driver">
2146 <sect1>em_use<label id="em_use"><p>
2150 <tag/Function/Prepare an extended memory page for use.
2151 <tag/Header/<tt/<ref id="em.h" name="em.h">/
2152 <tag/Declaration/<tt/void* __fastcall__ em_use (unsigned page);/
2153 <tag/Description/The function maps one page of extended memory into linear
2154 memory and returns a pointer to the page frame. This function is similar to
2155 <tt/<ref id="em_map" name="em_map">/, but will not transfer data into the
2156 actual memory window in the assumption that the existing data is wrong or
2157 will get overwritten.
2158 <tag/Limits/<itemize>
2159 <item>Calling <tt/em_use/ will invalidate the memory window, so if you
2160 made any changes to the data in the window, call <tt/<ref id="em_commit"
2161 name="em_commit">/ first, or the changes are lost.
2162 <item>The function is only available as fastcall function, so it may only be
2163 used in presence of a prototype.
2164 <item>The function produces undefined results if no extended memory driver is
2167 <tag/Availability/cc65
2169 <ref id="em_commit" name="em_commit">,
2170 <ref id="em_load_driver" name="em_load_driver">,
2171 <ref id="em_map" name="em_map">
2177 <sect1>exit<label id="exit"><p>
2181 <tag/Function/Terminate the program.
2182 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
2183 <tag/Declaration/<tt/void __fastcall__ exit (int status);/
2184 <tag/Description/<tt/exit/ terminates the program. The argument specifies the
2185 return code of the program. Before termination, all files are closed, buffered
2186 output is written and any functions registered with <tt/<ref id="atexit"
2187 name="atexit">/ are called. Common values for status are <tt/EXIT_SUCCESS/ and
2188 <tt/EXIT_FAILURE/ which are also defined in <tt/<ref id="stdlib.h"
2190 <tag/Limits/<itemize>
2191 <item>The function is only available as fastcall function, so it may only
2192 be used in presence of a prototype.
2193 <item>It depends on the host machine if the program return code can be
2194 evaluated or is ignored.
2196 <tag/Availability/ISO 9899
2198 <ref id="abort" name="abort">,
2199 <ref id="exit" name="exit">
2205 <sect1>exec<label id="exec"><p>
2209 <tag/Function/Execute a program file.
2210 <tag/Header/<tt/<ref id="unistd.h" name="unistd.h">/
2211 <tag/Declaration/<tt/int __fastcall__ exec (const char* progname, const char* cmdline);/
2212 <tag/Description/<tt/exec/ replaces the currently running program by a new one.
2213 Calling <tt/exec()/ is identical to calling <tt/<ref id="exit" name="exit()">/,
2214 then loading and starting the program named in the first argument, passing
2215 the command line specified as second argument. Instead of an empty string,
2216 a <tt/NULL/ pointer may be passed as second parameter.
2217 On success, the function does not return. On failure, -1 is returned and
2218 <tt/errno/ contains an error code.
2219 <tag/Limits/<itemize>
2220 <item>The function is only available as fastcall function, so it may only
2221 be used in presence of a prototype.
2222 <item>On most platforms, the function needs to copy a small stub loader to
2223 some memory area outside the program space. This may collide with other
2224 programs. See the platform specific docs on this.
2225 <item>Because it is necessary to terminate the running program before the
2226 memory can be reused to load the new one, there is a high chance that the
2227 function may not be able to return on errors.
2228 <item>The command line is passed to the new program in the same way as cc65
2229 programs expect the command line. If the new program is not a cc65 generated
2230 program, it may not be able to read it.
2232 <tag/Availability/cc65
2234 <ref id="exit" name="exit">
2240 <sect1>fast<label id="fast"><p>
2244 <tag/Function/Switch the C128 into 2MHz mode.
2245 <tag/Header/<tt/<ref id="c128.h" name="c128.h">/
2246 <tag/Declaration/<tt/void fast (void);/
2247 <tag/Description/The function will switch the clock of the C128 to 2MHz. This
2248 will nearly double the speed compared to slow mode.
2249 <tag/Limits/<itemize>
2250 <item>The function is specific to the C128.
2251 <item>2MHz clock will not work in 40 column mode.
2253 <tag/Availability/C128
2255 <ref id="slow" name="slow">,
2256 <ref id="toggle_videomode" name="toggle_videomode">,
2257 <ref id="videomode" name="videomode">
2263 <sect1>feof<label id="feof"><p>
2267 <tag/Function/Return the end-of-file indicator of a stream.
2268 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
2269 <tag/Declaration/<tt/int __fastcall__ feof (FILE* f);/
2270 <tag/Description/<tt/feof/ tests the end-of-file indicator ofthe stream
2271 <tt/f/, and returns a non zero value if it is set.
2272 <tag/Limits/<itemize>
2273 <item>The indicator is set only after a read past the end of a file is
2275 <item>The function is only available as fastcall function, so it may only be
2276 used in presence of a prototype.
2278 <tag/Availability/ISO 9899
2280 <ref id="feof" name="clearerr">,
2281 <ref id="ferror" name="ferror">
2287 <sect1>ferror<label id="ferror"><p>
2291 <tag/Function/Return the error indicator of a stream.
2292 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
2293 <tag/Declaration/<tt/int __fastcall__ ferror (FILE* f);/
2294 <tag/Description/<tt/ferror/ tests the error indicator of the stream
2295 <tt/f/, and returns a non zero value if it is set.
2296 <tag/Limits/<itemize>
2297 <item>The function is only available as fastcall function, so it may only be
2298 used in presence of a prototype.
2300 <tag/Availability/ISO 9899
2302 <ref id="feof" name="clearerr">,
2303 <ref id="ferror" name="feof">
2309 <sect1>fileno<label id="fileno"><p>
2313 <tag/Function/Return the file handle used by a stream.
2314 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
2315 <tag/Declaration/<tt/int __fastcall__ fileno (FILE* f);/
2316 <tag/Description/The <tt/fileno/ function returns the file handle used
2317 internally by a C stream. This file handle (an integer) can be used as a
2318 handle for the POSIX input/output functions.
2319 <tag/Limits/<itemize>
2320 <item>The function is only available as fastcall function, so it may only be
2321 used in presence of a prototype.
2322 <item>Mixing C file I/O functions and POSIX file I/O functions for the same
2323 file may have unpredictable results.
2325 <tag/Availability/POSIX 1003.1
2327 <ref id="creat" name="creat">,
2328 <ref id="open" name="open"> <!-- , -->
2329 <!-- <ref id="read" name="read">, -->
2330 <!-- <ref id="write" name="write"> -->
2336 <sect1>free<label id="free"><p>
2340 <tag/Function/Free a block of dynamic memory.
2341 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
2342 <tag/Declaration/<tt/void __fastcall__ free (void* block);/
2343 <tag/Description/Free a block of dynamic memory previously allocated with
2344 <tt/<ref id="malloc" name="malloc">/, <tt/<ref id="calloc" name="calloc">/
2345 or <tt/<ref id="realloc" name="realloc">/. As an exception, if the passed
2346 pointer is <tt/NULL/, no action is performed.
2349 <item>Passing an already free'd block to <tt/free/ again will cause undefined
2350 behaviour and may crash your program.
2351 <item>The function is only available as fastcall function, so it may only
2352 be used in presence of a prototype.
2354 <tag/Availability/ISO 9899
2356 <ref id="_heapadd" name="_heapadd">,
2357 <ref id="_heapblocksize" name="_heapblocksize">,
2358 <ref id="_heapmaxavail" name="_heapmaxavail">,
2359 <ref id="_heapmemavail" name="_heapmemavail">,
2360 <ref id="calloc" name="calloc">,
2361 <ref id="malloc" name="malloc">,
2362 <ref id="realloc" name="realloc">
2368 <sect1>get_ostype<label id="get_ostype"><p>
2372 <tag/Function/The function returns the operating system, the program runs on.
2373 <tag/Header/<tt/<ref id="apple2.h" name="apple2.h">,
2374 <ref id="atari.h" name="atari.h">, <ref id="c64.h" name="c64.h">/
2375 <tag/Declaration/<tt/unsigned char get_ostype (void);/
2376 <tag/Description/<tt/get_ostype/ is machine dependent and does not exist for
2377 all supported targets. If it exists, it returns a number that identifies the
2378 operating system or machine type, the program runs on. The machine dependent
2379 header files define constants that can be used to check the return code.
2380 <tag/Limits/<itemize>
2381 <item>The function does not exist on all platforms.
2382 <item>The return codes are platform dependent.
2384 <tag/Availability/cc65 (not all platforms)
2390 <sect1>getcpu<label id="getcpu"><p>
2394 <tag/Function/Determine on which CPU the program is running.
2395 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
2396 <tag/Declaration/<tt/unsigned char getcpu (void);/
2397 <tag/Description/The function checks on which CPU the code is running. It
2398 returns one of the constants<itemize>
2400 <item><tt/CPU_65C02/
2401 <item><tt/CPU_65816/
2403 <tag/Limits/<itemize>
2404 <item>Other, more exotic CPU types are not disinguished.
2406 <tag/Availability/cc65
2412 <sect1>getenv<label id="getenv"><p>
2416 <tag/Function/Return a value from the environment.
2417 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
2418 <tag/Declaration/<tt/char* __fastcall__ getenv (const char* name);/
2419 <tag/Description/The function searches the environment for an entry that
2420 matches <tt/name/ and returns its value. The environment consists of a list
2421 of strings in the form <tt/name=value/. If there is no match, <tt/getenv/
2423 <tag/Limits/<itemize>
2424 <item>What exactly is stored in the environment depends on the machine the
2425 program is running on.
2426 <item>The function is only available as fastcall function, so it may only
2427 be used in presence of a prototype.
2429 <tag/Availability/ISO 9899
2435 <sect1>getopt<label id="getopt"><p>
2439 <tag/Function/Parse command line options.
2440 <tag/Header/<tt/<ref id="unistd.h" name="unistd.h">/
2441 <tag/Declaration/<tt/int __fastcall__ getopt (int argc, char* const* argv,
2442 const char* optstring);/
2443 <tag/Description/The function parses command line arguments, <tt/argc/ and
2444 <tt/argv/ are the argument count and array passed to <tt/main/. <tt/optstring/
2445 is a string that contains command line option characters. If a character in
2446 <tt/optstring/ is followed by a colon, the option requires an argument. An
2447 option on the command line is recognized if it is one of the option characters
2449 <tt/getopt/ must be called repeatedly. It will return each option character
2450 found on the command line and <tt/EOF/ (-1) if there is no other option. An
2451 option argument is placed in <tt/optarg/, the index of the next element on the
2452 command line to be processed is placed in <tt/optind/.
2453 <tag/Limits/<itemize>
2454 <item>The implementation will not reorder options. A non option on the command
2455 line will terminate option processing. All remaining arguments are not
2456 recognized as options, even if the start with a '-' character.
2457 <item>The function is only available as fastcall function, so it may only
2458 be used in presence of a prototype.
2460 <tag/Availability/POSIX.2
2466 <sect1>gotox<label id="gotox"><p>
2470 <tag/Function/Move the text mode cursor to a new X position.
2471 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2472 <tag/Declaration/<tt/void __fastcall__ gotox (unsigned char x);/
2473 <tag/Description/The function moves the text mode cursor to the specified X
2474 position while leaving the Y position untouched. The leftmost position on the
2475 screen has the coordinate 0.
2476 <tag/Limits/<itemize>
2477 <item>The function is only available as fastcall function, so it may
2478 only be used in presence of a prototype.
2479 <item>Invalid values for the X position (out of screen coordinates) may
2480 lead to undefined behaviour.
2482 <tag/Availability/cc65
2484 <ref id="gotoy" name="gotoy">,
2485 <ref id="gotoxy" name="gotoxy">,
2486 <ref id="wherex" name="wherex">,
2487 <ref id="wherey" name="wherey">
2493 <sect1>gotoxy<label id="gotoxy"><p>
2497 <tag/Function/Move the text mode cursor to a new position.
2498 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2499 <tag/Declaration/<tt/void __fastcall__ gotoxy (unsigned char x, unsigned char y);/
2500 <tag/Description/The function moves the text mode cursor to the specified
2501 position. The leftmost position on the screen has the X coordinate 0, the
2502 topmost line has the Y coordinate 0.
2503 <tag/Limits/<itemize>
2504 <item>The function is only available as fastcall function, so it may only be
2505 used in presence of a prototype.
2506 <item>Invalid values for any of both coordinates (out of screen positions) may
2507 lead to undefined behaviour.
2509 <tag/Availability/cc65
2511 <ref id="gotox" name="gotox">,
2512 <ref id="gotoy" name="gotoy">,
2513 <ref id="wherex" name="wherex">,
2514 <ref id="wherey" name="wherey">
2520 <sect1>gotoy<label id="gotoy"><p>
2524 <tag/Function/Move the text mode cursor to a new Y position.
2525 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2526 <tag/Declaration/<tt/void __fastcall__ gotoy (unsigned char x);/
2527 <tag/Description/The function moves the text mode cursor to the specified Y
2528 position while leaving the X position untouched. The uppermost position on the
2529 screen has the coordinate 0.
2530 <tag/Limits/<itemize>
2531 <item>The function is only available as fastcall function, so it may
2532 only be used in presence of a prototype.
2533 <item>Invalid values for the Y position (out of screen coordinates) may lead
2534 to undefined behaviour.
2536 <tag/Availability/cc65
2538 <ref id="gotox" name="gotox">,
2539 <ref id="gotoxy" name="gotoxy">,
2540 <ref id="wherex" name="wherex">,
2541 <ref id="wherey" name="wherey">
2547 <sect1>isalnum<label id="isalnum"><p>
2551 <tag/Function/Check if a given character is a letter or digit.
2552 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2553 <tag/Declaration/<tt/int __fastcall__ isalnum (int c);/
2554 <tag/Description/The function returns a non zero value if the given argument
2555 is a letter or digit. The return value is zero if the character is anything
2557 <tag/Limits/<itemize>
2558 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2559 inline sequence generated by the macro will not work correctly for values
2560 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2561 this range. The non inline function may be accessed by <tt/#undef/'ing
2563 <item>When compiling without <tt/-Os/, the function is only available as
2564 fastcall function, so it may only be used in presence of a prototype.
2566 <tag/Availability/ISO 9899
2568 <ref id="isalpha" name="isalpha">,
2569 <ref id="isascii" name="isascii">,
2570 <ref id="isblank" name="isblank">,
2571 <ref id="iscntrl" name="iscntrl">,
2572 <ref id="isdigit" name="isdigit">,
2573 <ref id="isgraph" name="isgraph">,
2574 <ref id="islower" name="islower">,
2575 <ref id="isprint" name="isprint">,
2576 <ref id="ispunct" name="ispunct">,
2577 <ref id="isspace" name="isspace">,
2578 <ref id="isupper" name="isupper">,
2579 <ref id="isxdigit" name="isxdigit">
2585 <sect1>isalpha<label id="isalpha"><p>
2589 <tag/Function/Check if a given character is a letter.
2590 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2591 <tag/Declaration/<tt/int __fastcall__ isalpha (int c);/
2592 <tag/Description/The function returns a non zero value if the given argument
2593 is a letter. The return value is zero if the character is anything else.
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 the
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="isalnum" name="isalnum">,
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>isascii<label id="isascii"><p>
2626 <tag/Function/Check if a given character is in the ASCII (0..127) range.
2627 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2628 <tag/Declaration/<tt/int __fastcall__ isascii (int c);/
2629 <tag/Description/The function returns a non zero value if the given argument
2630 is in the range 0..127 (the range of valid ASCII characters) and zero if not.
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="isalpha" name="isalpha">,
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>isblank<label id="isblank"><p>
2663 <tag/Function/Check if a given character is a space or tab.
2664 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2665 <tag/Declaration/<tt/int __fastcall__ isblank (int c);/
2666 <tag/Description/The function returns a non zero value if the given argument
2667 is a space or tab character. The return value is zero if the character is
2669 <tag/Limits/<itemize>
2670 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2671 inline sequence generated by the macro will not work correctly for values
2672 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2673 this range. The non inline function may be accessed by <tt/#undef/'ing the
2675 <item>When compiling without <tt/-Os/, the function is only available as
2676 fastcall function, so it may only be used in presence of a prototype.
2678 <tag/Availability/cc65
2680 <ref id="isalnum" name="isalnum">,
2681 <ref id="isalpha" name="isalpha">,
2682 <ref id="isascii" name="isascii">,
2683 <ref id="iscntrl" name="iscntrl">,
2684 <ref id="isdigit" name="isdigit">,
2685 <ref id="isgraph" name="isgraph">,
2686 <ref id="islower" name="islower">,
2687 <ref id="isprint" name="isprint">,
2688 <ref id="ispunct" name="ispunct">,
2689 <ref id="isspace" name="isspace">,
2690 <ref id="isupper" name="isupper">,
2691 <ref id="isxdigit" name="isxdigit">
2697 <sect1>iscntrl<label id="iscntrl"><p>
2701 <tag/Function/Check if a given character is a control character.
2702 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2703 <tag/Declaration/<tt/int __fastcall__ iscntrl (int c);/
2704 <tag/Description/The function returns a non zero value if the given argument
2705 is a control character. The return value is zero if the character is anything
2707 <tag/Limits/<itemize>
2708 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2709 inline sequence generated by the macro will not work correctly for values
2710 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2711 this range. The non inline function may be accessed by <tt/#undef/'ing the
2713 <item>When compiling without <tt/-Os/, the function is only available as
2714 fastcall function, so it may only be used in presence of a prototype.
2716 <tag/Availability/ISO 9899
2718 <ref id="isalnum" name="isalnum">,
2719 <ref id="isalpha" name="isalpha">,
2720 <ref id="isascii" name="isascii">,
2721 <ref id="isblank" name="isblank">,
2722 <ref id="isdigit" name="isdigit">,
2723 <ref id="isgraph" name="isgraph">,
2724 <ref id="islower" name="islower">,
2725 <ref id="isprint" name="isprint">,
2726 <ref id="ispunct" name="ispunct">,
2727 <ref id="isspace" name="isspace">,
2728 <ref id="isupper" name="isupper">,
2729 <ref id="isxdigit" name="isxdigit">
2735 <sect1>isdigit<label id="isdigit"><p>
2739 <tag/Function/Check if a given character is a digit.
2740 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2741 <tag/Declaration/<tt/int __fastcall__ isdigit (int c);/
2742 <tag/Description/The function returns a non zero value if the given argument
2743 is a digit. The return value is zero if the character is anything else.
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="iscntrl" name="iscntrl">,
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>isgraph<label id="isgraph"><p>
2776 <tag/Function/Check if a given character is a printable character (except
2778 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2779 <tag/Declaration/<tt/int __fastcall__ isgraph (int c);/
2780 <tag/Description/The function returns a non zero value if the given argument
2781 is a printable character with the exception of space. The return value is zero
2782 if the character is anything else.
2783 <tag/Limits/<itemize>
2784 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2785 inline sequence generated by the macro will not work correctly for values
2786 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2787 this range. The non inline function may be accessed by <tt/#undef/'ing the
2789 <item>When compiling without <tt/-Os/, the function is only available as
2790 fastcall function, so it may only be used in presence of a prototype.
2792 <tag/Availability/ISO 9899
2794 <ref id="isalnum" name="isalnum">,
2795 <ref id="isalpha" name="isalpha">,
2796 <ref id="isascii" name="isascii">,
2797 <ref id="isblank" name="isblank">,
2798 <ref id="iscntrl" name="iscntrl">,
2799 <ref id="isdigit" name="isdigit">,
2800 <ref id="islower" name="islower">,
2801 <ref id="isprint" name="isprint">,
2802 <ref id="ispunct" name="ispunct">,
2803 <ref id="isspace" name="isspace">,
2804 <ref id="isupper" name="isupper">,
2805 <ref id="isxdigit" name="isxdigit">
2811 <sect1>islower<label id="islower"><p>
2815 <tag/Function/Check if a given character is a lower case letter.
2816 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2817 <tag/Declaration/<tt/int __fastcall__ islower (int c);/
2818 <tag/Description/The function returns a non zero value if the given argument
2819 is a lower case letter. The return value is zero if the character is anything
2821 <tag/Limits/<itemize>
2822 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2823 inline sequence generated by the macro will not work correctly for values
2824 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2825 this range. The non inline function may be accessed by <tt/#undef/'ing the
2827 <item>When compiling without <tt/-Os/, the function is only available as
2828 fastcall function, so it may only be used in presence of a prototype.
2830 <tag/Availability/ISO 9899
2832 <ref id="isalnum" name="isalnum">,
2833 <ref id="isalpha" name="isalpha">,
2834 <ref id="isascii" name="isascii">,
2835 <ref id="isblank" name="isblank">,
2836 <ref id="iscntrl" name="iscntrl">,
2837 <ref id="isdigit" name="isdigit">,
2838 <ref id="isgraph" name="isgraph">,
2839 <ref id="isprint" name="isprint">,
2840 <ref id="ispunct" name="ispunct">,
2841 <ref id="isspace" name="isspace">,
2842 <ref id="isupper" name="isupper">,
2843 <ref id="isxdigit" name="isxdigit">
2849 <sect1>isprint<label id="isprint"><p>
2853 <tag/Function/Check if a given character is a printable character.
2854 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2855 <tag/Declaration/<tt/int __fastcall__ isprint (int c);/
2856 <tag/Description/The function returns a non zero value if the given argument
2857 is a printable character (this includes the space character). The return value
2858 is zero if the character is anything else.
2859 <tag/Limits/<itemize>
2860 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2861 inline sequence generated by the macro will not work correctly for values
2862 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2863 this range. The non inline function may be accessed by <tt/#undef/'ing the
2865 <item>When compiling without <tt/-Os/, the function is only available as
2866 fastcall function, so it may only be used in presence of a prototype.
2868 <tag/Availability/ISO 9899
2870 <ref id="isalnum" name="isalnum">,
2871 <ref id="isalpha" name="isalpha">,
2872 <ref id="isascii" name="isascii">,
2873 <ref id="isblank" name="isblank">,
2874 <ref id="iscntrl" name="iscntrl">,
2875 <ref id="isdigit" name="isdigit">,
2876 <ref id="isgraph" name="isgraph">,
2877 <ref id="islower" name="islower">,
2878 <ref id="ispunct" name="ispunct">,
2879 <ref id="isspace" name="isspace">,
2880 <ref id="isupper" name="isupper">,
2881 <ref id="isxdigit" name="isxdigit">
2887 <sect1>ispunct<label id="ispunct"><p>
2891 <tag/Function/Check if a given character is a printable character but not a
2892 space or an alphanumeric character.
2893 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2894 <tag/Declaration/<tt/int __fastcall__ ispunct (int c);/
2895 <tag/Description/The function returns a non zero value if the given argument
2896 is a printable character, but not a space or anything alphanumeric. The return
2897 value is zero if the character is anything else.
2898 <tag/Limits/<itemize>
2899 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2900 inline sequence generated by the macro will not work correctly for values
2901 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2902 this range. The non inline function may be accessed by <tt/#undef/'ing the
2904 <item>When compiling without <tt/-Os/, the function is only available as
2905 fastcall function, so it may only be used in presence of a prototype.
2907 <tag/Availability/ISO 9899
2909 <ref id="isalnum" name="isalnum">,
2910 <ref id="isalpha" name="isalpha">,
2911 <ref id="isascii" name="isascii">,
2912 <ref id="isblank" name="isblank">,
2913 <ref id="iscntrl" name="iscntrl">,
2914 <ref id="isdigit" name="isdigit">,
2915 <ref id="isgraph" name="isgraph">,
2916 <ref id="islower" name="islower">,
2917 <ref id="isprint" name="isprint">,
2918 <ref id="isspace" name="isspace">,
2919 <ref id="isupper" name="isupper">,
2920 <ref id="isxdigit" name="isxdigit">
2926 <sect1>isspace<label id="isspace"><p>
2930 <tag/Function/Check if a given character is a a white-space character.
2931 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2932 <tag/Declaration/<tt/int __fastcall__ isspace (int c);/
2933 <tag/Description/The function returns a non zero value if the given argument
2934 is a white space character. The return value is zero if the character is
2935 anything else. The standard white space characters are: space, formfeed ('\f'),
2936 newline ('\n'), carriage return ('\r'), horizontal tab ('\t'), and vertical tab
2938 <tag/Limits/<itemize>
2939 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2940 inline sequence generated by the macro will not work correctly for values
2941 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2942 this range. The non inline function may be accessed by <tt/#undef/'ing the
2944 <item>When compiling without <tt/-Os/, the function is only available as
2945 fastcall function, so it may only be used in presence of a prototype.
2947 <tag/Availability/ISO 9899
2949 <ref id="isalnum" name="isalnum">,
2950 <ref id="isalpha" name="isalpha">,
2951 <ref id="isascii" name="isascii">,
2952 <ref id="isblank" name="isblank">,
2953 <ref id="iscntrl" name="iscntrl">,
2954 <ref id="isdigit" name="isdigit">,
2955 <ref id="isgraph" name="isgraph">,
2956 <ref id="islower" name="islower">,
2957 <ref id="isprint" name="isprint">,
2958 <ref id="ispunct" name="ispunct">,
2959 <ref id="isupper" name="isupper">,
2960 <ref id="isxdigit" name="isxdigit">
2966 <sect1>isupper<label id="isupper"><p>
2970 <tag/Function/Check if a given character is an upper case letter.
2971 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2972 <tag/Declaration/<tt/int __fastcall__ isupper (int c);/
2973 <tag/Description/The function returns a non zero value if the given argument
2974 is an upper case letter. The return value is zero if the character is anything
2976 <tag/Limits/<itemize>
2977 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2978 inline sequence generated by the macro will not work correctly for values
2979 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2980 this range. The non inline function may be accessed by <tt/#undef/'ing the
2982 <item>When compiling without <tt/-Os/, the function is only available as
2983 fastcall function, so it may only be used in presence of a prototype.
2985 <tag/Availability/ISO 9899
2987 <ref id="isalnum" name="isalnum">,
2988 <ref id="isalpha" name="isalpha">,
2989 <ref id="isascii" name="isascii">,
2990 <ref id="isblank" name="isblank">,
2991 <ref id="iscntrl" name="iscntrl">,
2992 <ref id="isdigit" name="isdigit">,
2993 <ref id="isgraph" name="isgraph">,
2994 <ref id="islower" name="islower">,
2995 <ref id="isprint" name="isprint">,
2996 <ref id="ispunct" name="ispunct">,
2997 <ref id="isspace" name="isspace">,
2998 <ref id="isxdigit" name="isxdigit">
3004 <sect1>isxdigit<label id="isxdigit"><p>
3008 <tag/Function/Check if a given character is a hexadecimal digit.
3009 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
3010 <tag/Declaration/<tt/int __fastcall__ isxdigit (int c);/
3011 <tag/Description/The function returns a non zero value if the given argument
3012 is a hexadecimal digit (0..9, a..f and A..F). The return value is zero if the
3013 character is anything else.
3014 <tag/Limits/<itemize>
3015 <item>When compiling with <tt/-Os/ the function is actually a macro. The
3016 inline sequence generated by the macro will not work correctly for values
3017 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
3018 this range. The non inline function may be accessed by <tt/#undef/'ing the
3020 <item>When compiling without <tt/-Os/, the function is only available as
3021 fastcall function, so it may only be used in presence of a prototype.
3023 <tag/Availability/ISO 9899
3025 <ref id="isalnum" name="isalnum">,
3026 <ref id="isalpha" name="isalpha">,
3027 <ref id="isascii" name="isascii">,
3028 <ref id="isblank" name="isblank">,
3029 <ref id="iscntrl" name="iscntrl">,
3030 <ref id="isdigit" name="isdigit">,
3031 <ref id="isgraph" name="isgraph">,
3032 <ref id="islower" name="islower">,
3033 <ref id="isprint" name="isprint">,
3034 <ref id="ispunct" name="ispunct">,
3035 <ref id="isspace" name="isspace">,
3036 <ref id="isupper" name="isupper">
3042 <sect1>itoa<label id="itoa"><p>
3046 <tag/Function/Convert an integer into a string.
3047 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
3048 <tag/Declaration/<tt/char* __fastcall__ itoa (int val, char* buf, int radix);/
3049 <tag/Description/<tt/itoa/ converts the integer <tt/val/ into a string using
3050 <tt/radix/ as the base.
3051 <tag/Limits/<itemize>
3052 <item>There are no provisions to prevent a buffer overflow.
3053 <item>If <tt/val/ contains <tt/INT_MIN/, the behaviour is undefined.
3054 <item>The function is non standard, so it is not available in strict ANSI mode.
3055 You should probably use <tt/sprintf/ instead.
3056 <item>The function is only available as fastcall function, so it may only be
3057 used in presence of a prototype.
3059 <tag/Availability/cc65
3061 <ref id="atoi" name="atoi">,
3062 <ref id="atol" name="atol">,
3063 <ref id="ltoa" name="ltoa">,
3064 <ref id="ultoa" name="ultoa">,
3065 <ref id="utoa" name="utoa">
3071 <sect1>joy_count<label id="joy_count"><p>
3075 <tag/Function/Return the number of joysticks supported by the current driver.
3076 <tag/Header/<tt/<ref id="joystick.h" name="joystick.h">/
3077 <tag/Declaration/<tt/unsigned char joy_count (void);/
3078 <tag/Description/The function returns a the number of joysticks supported
3079 by the current joystick driver.
3080 <tag/Limits/<itemize>
3081 <item>A joystick driver must be loaded using <ref id="joy_load_driver"
3082 name="joy_load_driver"> before calling this function.
3083 <item>The function returns the number of joysticks supported by the driver.
3084 There's no way to check for the number of actually connected joysticks.
3086 <tag/Availability/cc65
3088 <ref id="joy_load_driver" name="joy_load_driver">,
3089 <ref id="joy_read" name="joy_read">
3095 <sect1>joy_install<label id="joy_install"><p>
3099 <tag/Function/Install an already loaded driver and return an error code.
3100 <tag/Header/<tt/<ref id="joystick.h" name="joystick.h">/
3101 <tag/Declaration/<tt/unsigned char __fastcall__ joy_install (void* driver);/
3102 <tag/Description/The function installs a driver that was already loaded into
3103 memory (or linked statically to the program). It returns an error code
3104 (<tt/JOY_ERR_OK/ in case of success).
3105 <tag/Limits/<itemize>
3106 <item>The function is only available as fastcall function, so it may only be
3107 used in presence of a prototype.
3109 <tag/Availability/cc65
3111 <ref id="joy_load_driver" name="joy_load_driver">,
3112 <ref id="joy_uninstall" name="joy_uninstall">,
3113 <ref id="joy_unload" name="joy_unload">
3119 <sect1>joy_load_driver<label id="joy_load_driver"><p>
3123 <tag/Function/Load a driver from disk and install it.
3124 <tag/Header/<tt/<ref id="joystick.h" name="joystick.h">/
3125 <tag/Declaration/<tt/unsigned char __fastcall__ joy_load_driver (const char* driver);/
3126 <tag/Description/The function loads a driver with the given name from disk
3127 and installs it. An error code is returned, which is <tt/JOY_ERR_OK/ if the
3128 driver was successfully loaded and installed.
3129 <tag/Limits/<itemize>
3130 <item>The function is only available as fastcall function, so it may only be
3131 used in presence of a prototype.
3133 <tag/Availability/cc65
3135 <ref id="joy_install" name="joy_install">,
3136 <ref id="joy_uninstall" name="joy_uninstall">,
3137 <ref id="joy_unload" name="joy_unload">
3143 <sect1>joy_read<label id="joy_read"><p>
3147 <tag/Function/Read the status of a joystick.
3148 <tag/Header/<tt/<ref id="joystick.h" name="joystick.h">/
3149 <tag/Declaration/<tt/unsigned char __fastcall__ joy_read (unsigned char joystick);/
3150 <tag/Description/The function reads the status bits for a joystick. The number
3151 of the joystick is passed as parameter. The result may be examined by using one
3152 of the <tt/JOY_xxx/ macros from <ref id="joystick.h" name="joystick.h">.
3153 <tag/Limits/<itemize>
3154 <item>A joystick driver must be loaded using <ref id="joy_load_driver"
3155 name="joy_load_driver"> before calling this function.
3156 <item>The function is only available as fastcall function, so it may only be
3157 used in presence of a prototype.
3159 <tag/Availability/cc65
3161 <ref id="joy_count" name="joy_count">,
3162 <ref id="joy_load_driver" name="joy_load_driver">,
3163 <ref id="joy_unload" name="joy_unload">
3169 <sect1>joy_uninstall<label id="joy_uninstall"><p>
3173 <tag/Function/Uninstall the current joystick driver.
3174 <tag/Header/<tt/<ref id="joystick.h" name="joystick.h">/
3175 <tag/Declaration/<tt/unsigned char joy_uninstall (void);/
3176 <tag/Description/The function uninstalls the currently installed joystick
3177 driver. It does not remove the driver from memory. The function returns an
3178 error code, which is <tt/JOY_ERR_OK/ if the driver was successfully uninstalled.
3179 <tag/Limits/<itemize>
3180 <item>A joystick driver must be installed using <ref id="joy_install"
3181 name="joy_install"> before calling this function.
3183 <tag/Availability/cc65
3185 <ref id="joy_install" name="joy_install">,
3186 <ref id="joy_load_driver" name="joy_load_driver">,
3187 <ref id="joy_unload" name="joy_unload">
3193 <sect1>joy_unload<label id="joy_unload"><p>
3197 <tag/Function/Uninstall, then unload the current joystick driver.
3198 <tag/Header/<tt/<ref id="joystick.h" name="joystick.h">/
3199 <tag/Declaration/<tt/unsigned char joy_unload (void);/
3200 <tag/Description/The function uninstalls the currently installed joystick
3201 driver and removes it from memory. An error code is returned, which is
3202 <tt/JOY_ERR_OK/ if the driver was successfully uninstalled.
3203 <tag/Limits/<itemize>
3204 <item>A joystick driver must be loaded using <ref id="joy_load_driver"
3205 name="joy_load_driver"> before calling this function.
3207 <tag/Availability/cc65
3209 <ref id="joy_load_driver" name="joy_load_driver">
3215 <sect1>kbhit<label id="kbhit"><p>
3219 <tag/Function/Check if there's a key waiting in the keyboard buffer.
3220 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
3221 <tag/Declaration/<tt/unsigned char kbhit (void);/
3222 <tag/Description/The function returns a value of zero if there is no character
3223 waiting to be read from the keyboard. It returns non zero otherwise.
3224 <tag/Limits/<itemize>
3225 <item>If the system does not support a keyboard buffer (most systems
3226 do), the function is rather useless.
3228 <tag/Availability/cc65
3230 <ref id="cgetc" name="cgetc">,
3231 <ref id="cursor" name="cursor">
3237 <sect1>labs<label id="labs"><p>
3241 <tag/Function/Returns the absolute value of a long integer.
3242 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
3243 <tag/Declaration/<tt/long __fastcall__ labs (long v);/
3244 <tag/Description/<tt/labs/ returns the absolute value of the argument passed to
3246 <tag/Limits/<itemize>
3247 <item>The return value is undefined if <tt/LONG_MIN/ is passed to the function.
3248 <item>The function is only available as fastcall function, so it may only be
3249 used in presence of a prototype.
3251 <tag/Availability/ISO 9899
3253 <ref id="abs" name="abs">
3259 <sect1>ltoa<label id="ltoa"><p>
3263 <tag/Function/Convert a long integer into a string.
3264 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
3265 <tag/Declaration/<tt/char* __fastcall__ ltoa (long val, char* buf, int radix);/
3266 <tag/Description/<tt/itoa/ converts the long integer <tt/val/ into a string
3267 using <tt/radix/ as the base.
3268 <tag/Limits/<itemize>
3269 <item>There are no provisions to prevent a buffer overflow.
3270 <item>If <tt/val/ contains <tt/LONG_MIN/, the behaviour is undefined.
3271 <item>The function is non standard, so it is not available in strict ANSI mode.
3272 You should probably use <tt/sprintf/ instead.
3273 <item>The function is only available as fastcall function, so it may only be
3274 used in presence of a prototype.
3276 <tag/Availability/cc65
3278 <ref id="atoi" name="atoi">,
3279 <ref id="atol" name="atol">,
3280 <ref id="itoa" name="itoa">,
3281 <ref id="ultoa" name="ultoa">,
3282 <ref id="utoa" name="utoa">
3288 <sect1>localeconv<label id="localeconv"><p>
3292 <tag/Function/Returns a pointer to the current locale structure.
3293 <tag/Header/<tt/<ref id="locale.h" name="locale.h">/
3294 <tag/Declaration/<tt/struct lconv* localeconv (void);/
3295 <tag/Description/<tt/localeconv/ returns a pointer to the current locale
3297 <tag/Limits/<itemize>
3298 <item>cc65 supports only the "C" locale, so even after setting a new locale
3299 using <tt/<ref id="setlocale" name="setlocale">/, the structure returned will
3302 <tag/Availability/ISO 9899
3304 <ref id="setlocale" name="setlocale">
3310 <sect1>longjmp<label id="longjmp"><p>
3314 <tag/Function/Non local goto.
3315 <tag/Header/<tt/<ref id="setjmp.h" name="setjmp.h">/
3316 <tag/Declaration/<tt/void __fastcall__ longjmp (jmp_buf buf, int retval);/
3317 <tag/Description/The <tt/longjmp/ function restores a program context from the
3318 data in <tt/buf/, which must have been set by a preceeding call to
3319 <tt/<ref id="setjmp" name="setjmp">/. Program execution continues as if the
3320 call to <tt/<ref id="setjmp" name="setjmp">/ has just returned the value
3324 <item>If the parameter <tt/retval/ is zero, the function will behave as if it
3325 was called with a value of one.
3326 <item>The function is only available as fastcall function, so it may only
3327 be used in presence of a prototype.
3329 <tag/Availability/ISO 9899
3331 <ref id="setjmp" name="setjmp">
3337 <sect1>malloc<label id="malloc"><p>
3341 <tag/Function/Allocate dynamic memory.
3342 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
3343 <tag/Declaration/<tt/void* __fastcall__ malloc (size_t size);/
3344 <tag/Description/<tt/malloc/ allocates size bytes on the heap and returns a
3345 pointer to the allocated memory block. On error (not enough memory available),
3346 <tt/malloc/ returns <tt/NULL/.
3349 <item>The function is only available as fastcall function, so it may only
3350 be used in presence of a prototype.
3352 <tag/Availability/ISO 9899
3354 <ref id="_heapadd" name="_heapadd">,
3355 <ref id="_heapblocksize" name="_heapblocksize">,
3356 <ref id="_heapmaxavail" name="_heapmaxavail">,
3357 <ref id="_heapmemavail" name="_heapmemavail">,
3358 <ref id="calloc" name="calloc">,
3359 <ref id="free" name="free">,
3360 <ref id="realloc" name="realloc">,
3361 <ref id="strdup" name="strdup">
3367 <sect1>memchr<label id="memchr"><p>
3371 <tag/Function/Search for a character in a block of raw memory.
3372 <tag/Header/<tt/<ref id="string.h" name="string.h">/
3373 <tag/Declaration/<tt/void* __fastcall__ strchr (const void* mem, int c, size_t count);/
3374 <tag/Description/The <tt/memchr/ function locates the first occurrence of <tt/c/
3375 (converted to a char) in the block of raw memory string pointed to by <tt/mem/
3376 that is of size <tt/count/. Upon completion, the function returns a pointer to
3377 the character found, or a null pointer if the character was not found.
3378 <tag/Limits/<itemize>
3379 <item>The function is only available as fastcall function, so it may only
3380 be used in presence of a prototype.
3382 <tag/Availability/ISO 9899
3384 <ref id="strchr" name="strchr">
3390 <sect1>memcmp<label id="memcmp"><p>
3394 <tag/Function/Compare two memory areas.
3395 <tag/Header/<tt/<ref id="string.h" name="string.h">/
3396 <tag/Declaration/<tt/int __fastcall__ memcmp (const void* p1, const void* p2, size_t count);/
3397 <tag/Description/<tt/memcmp/ compares <tt/count/ bytes from the memory area
3398 pointed to by <tt/p1/ into the memory area pointed to by <tt/p2/. It returns a value that is less than
3399 zero if <tt/p1/ is less than <tt/p2/, zero if <tt/p1/ is the same as <tt/p2/,
3400 and a value greater than zero if <tt/p1/ is greater than <tt/p2/.
3403 <item>The function is only available as fastcall function, so it may only
3404 be used in presence of a prototype.
3406 <tag/Availability/ISO 9899
3408 <ref id="strcmp" name="strcmp">,
3409 <ref id="memmove" name="memmove">,
3410 <ref id="memset" name="memset">
3416 <sect1>memcpy<label id="memcpy"><p>
3420 <tag/Function/Copy a memory area.
3421 <tag/Header/<tt/<ref id="string.h" name="string.h">/
3422 <tag/Declaration/<tt/void* __fastcall__ memcpy (void* dest, const void* src, size_t count);/
3423 <tag/Description/<tt/memcpy/ copies <tt/count/ bytes from the memory area
3424 pointed to by <tt/src/ into the memory area pointed to by <tt/dest/. It returns
3428 <item>The result is undefined if the memory areas do overlap. Use
3429 <tt/<ref id="memmove" name="memmove">/ to copy overlapping memory areas.
3430 <item>The function is only available as fastcall function, so it may only
3431 be used in presence of a prototype.
3433 <tag/Availability/ISO 9899
3435 <ref id="_swap" name="_swap">,
3436 <ref id="memmove" name="memmove">,
3437 <ref id="memset" name="memset">
3443 <sect1>memmove<label id="memmove"><p>
3447 <tag/Function/Copy a memory area.
3448 <tag/Header/<tt/<ref id="string.h" name="string.h">/
3449 <tag/Declaration/<tt/void* __fastcall__ memmove (void* dest, const void* src, size_t count);/
3450 <tag/Description/<tt/memmove/ copies <tt/count/ bytes from the memory area
3451 pointed to by <tt/src/ into the memory area pointed to by <tt/dest/. It returns
3455 <item>While <tt/memmove/ allows the memory areas to overlap, it has some
3456 additional overhead compared to <tt/<ref id="memcpy" name="memcpy">/.
3457 <item>The function is only available as fastcall function, so it may only
3458 be used in presence of a prototype.
3460 <tag/Availability/ISO 9899
3462 <ref id="_swap" name="_swap">,
3463 <ref id="memcpy" name="memcpy">,
3464 <ref id="memset" name="memset">
3470 <sect1>memset<label id="memset"><p>
3474 <tag/Function/Fill a memory area.
3475 <tag/Header/<tt/<ref id="string.h" name="string.h">/
3476 <tag/Declaration/<tt/void* __fastcall__ memset (void* p, int val, size_t count);/
3477 <tag/Description/<tt/memset/ fills the memory area pointed to by <tt/p/ with
3478 the value <tt/val/. The function returns <tt/p/.
3481 <item>The function is only available as fastcall function, so it may only
3482 be used in presence of a prototype.
3484 <tag/Availability/ISO 9899
3486 <ref id="_swap" name="_swap">,
3487 <ref id="bzero" name="bzero">,
3488 <ref id="memcpy" name="memcpy">,
3489 <ref id="memmove" name="memmove">
3495 <sect1>mod_free<label id="mod_free"><p>
3499 <tag/Function/Free a relocatable module.
3500 <tag/Header/<tt/<ref id="modload.h" name="modload.h">/
3501 <tag/Declaration/<tt/void __fastcall__ mod_free (void* module);/
3502 <tag/Description/The function will free a module loaded into memory by use of
3503 the <tt/<ref id="mod_load" name="mod_load">/ function.
3504 <tag/Limits/<itemize>
3505 <item>The pointer passed as parameter is the pointer to the module memory,
3506 not the pointer to the control structure.
3508 <tag/Availability/cc65
3510 <ref id="mod_load" name="mod_load">
3516 <sect1>mod_load<label id="mod_load"><p>
3520 <tag/Function/Load a relocatable module.
3521 <tag/Header/<tt/<ref id="modload.h" name="modload.h">/
3522 <tag/Declaration/<tt/unsigned char mod_load (struct mod_ctrl* ctrl);/
3523 <tag/Description/The function will load a code module into memory and relocate
3524 it. The function will return an error code. If <tt/MLOAD_OK/ is returned, the
3525 outgoing fields in the passed <tt/mod_ctrl/ struct contain information about
3526 the module just loaded. Possible error codes are:
3528 <item><tt/MLOAD_OK/ - Module load successful
3529 <item><tt/MLOAD_ERR_READ/ - Read error
3530 <item><tt/MLOAD_ERR_HDR/ - Header error
3531 <item><tt/MLOAD_ERR_OS/ - Wrong operating system
3532 <item><tt/MLOAD_ERR_FMT/ - Data format error
3533 <item><tt/MLOAD_ERR_MEM/ - Not enough memory
3535 <tag/Limits/<itemize>
3536 <item>The <htmlurl url="ld65.html" name="ld65"> linker is needed to create
3537 relocatable o65 modules for use with this function.
3539 <tag/Availability/cc65
3541 <ref id="mod_free" name="mod_free">
3547 <sect1>mouse_setbox<label id="mouse_setbox"><p>
3551 <tag/Function/Specify a bounding box for the mouse cursor.
3552 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3553 <tag/Declaration/<tt/void __fastcall__ mouse_setbox (const struct mouse_box* box);/
3554 <tag/Description/The function allows to set a bounding box for mouse movement.
3555 <tag/Limits/<itemize>
3556 <item>The function does not check if the mouse cursor is currently within the
3557 given rectangle. Placing the mouse cursor within the bounding box is the
3558 responsibility of the programmer.
3559 <item>While the bounding box may be larger than the actual screen size, the
3560 standard mouse cursor draw routines may fail to set the cursor to coordinates
3561 outside of the screen area. Depending on the platform, you may have to supply
3562 your own mouse cursor routines.
3563 <item>The function is only available as fastcall function, so it may only be
3564 used in presence of a prototype.
3566 <tag/Availability/cc65
3568 <ref id="mouse_getbox" name="mouse_getbox">,
3569 <ref id="mouse_move" name="mouse_move">
3575 <sect1>mouse_getbox<label id="mouse_getbox"><p>
3579 <tag/Function/Return the current bounding box for the mouse cursor.
3580 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3581 <tag/Declaration/<tt/void __fastcall__ mouse_getbox (struct mouse_box* box);/
3582 <tag/Description/The function queries the current bounding box for mouse
3584 <tag/Limits/<itemize>
3585 <item>The function is only available as fastcall function, so it may only be
3586 used in presence of a prototype.
3588 <tag/Availability/cc65
3590 <ref id="mouse_move" name="mouse_move">,
3591 <ref id="mouse_setbox" name="mouse_setbox">
3597 <sect1>mouse_buttons<label id="mouse_buttons"><p>
3601 <tag/Function/Return a bit mask encoding the state of the mouse buttons.
3602 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3603 <tag/Declaration/<tt/unsigned char mouse_buttons (void);/
3604 <tag/Description/The function returns a bit mask that encodes the state of the
3605 mouse buttons. You may use the <tt/MOUSE_BTN_XXX/ flags to decode the function
3607 <tag/Availability/cc65
3609 <ref id="mouse_info" name="mouse_info">,
3610 <ref id="mouse_pos" name="mouse_pos">
3616 <sect1>mouse_geterrormsg<label id="mouse_geterrormsg"><p>
3620 <tag/Function/Return a readable error message for an error code.
3621 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3622 <tag/Declaration/<tt/const char* __fastcall__ mouse_geterrormsg (unsigned char
3624 <tag/Description/The function returns an error message (in english) for the
3625 error code passed parameter.
3626 <tag/Limits/<itemize>
3627 <item>The function will return "Unknown error" for invalid error codes.
3628 <item>The function is only available as fastcall function, so it may only be
3629 used in presence of a prototype.
3631 <tag/Availability/cc65
3633 <ref id="mouse_load_driver" name="mouse_load_driver">,
3634 <ref id="mouse_uninstall" name="mouse_uninstall">,
3635 <ref id="mouse_unload" name="mouse_unload">
3641 <sect1>mouse_hide<label id="mouse_hide"><p>
3645 <tag/Function/Hide the mouse pointer.
3646 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3647 <tag/Declaration/<tt/void mouse_hide (void);/
3648 <tag/Description/The function hides the mouse pointer. It manages a counter
3649 that is shared between <tt/<ref id="mouse_show" name="mouse_show">/ and
3650 <tt/mouse_hide/ so that every call call to <tt/mouse_hide/ must be followed by
3651 a call to <tt/<ref id="mouse_show" name="mouse_show">/ to make the mouse cursor
3653 <tag/Availability/cc65
3655 <ref id="mouse_show" name="mouse_show">
3661 <sect1>mouse_info<label id="mouse_info"><p>
3665 <tag/Function/Return the state of the mouse buttons and the position of the
3667 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3668 <tag/Declaration/<tt/void __fastcall__ mouse_info (struct mouse_info* info);/
3669 <tag/Description/The function returns the state of the mouse buttons and the
3670 position of the mouse in the <tt/mouse_info/ structure passed as parameter.
3671 <tag/Limits/<itemize>
3672 <item>The <tt/mouse_info/ struct is a superset of the <tt/mouse_pos/ struct,
3673 so if you just need the mouse position, call <tt/<ref id="mouse_pos"
3674 name="mouse_pos">/ instead.
3675 <item>The function is only available as fastcall function, so it may only be
3676 used in presence of a prototype.
3678 <tag/Availability/cc65
3680 <ref id="mouse_buttons" name="mouse_buttons">,
3681 <ref id="mouse_pos" name="mouse_pos">
3687 <sect1>mouse_install<label id="mouse_install"><p>
3691 <tag/Function/Install an already loaded mouse driver.
3692 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3693 <tag/Declaration/<tt/unsigned char __fastcall__ mouse_install (const struct
3694 mouse_callbacks* c, void* driver);/
3695 <tag/Description/The function installs an already loaded mouse driver and
3696 returns an error code. The <tt/mouse_callbacks/ structure passed as first
3697 parameter contains pointers to routines needed to move or hide/show the mouse
3698 pointer. Defaults for these routines are supplied by the library, so if you
3699 can live with these defaults (which are platform specific), just pass a
3700 pointer to <tt/mouse_def_callbacks/. The function may be used to install a
3701 driver linked statically to the program.
3702 <tag/Limits/<itemize>
3703 <item>Not all drivers are able to detect if the supported hardware is really
3705 <item>After installing a driver, the mouse cursor is hidden.
3706 <item>The function is only available as fastcall function, so it may only be
3707 used in presence of a prototype.
3709 <tag/Availability/cc65
3711 <ref id="mouse_load_driver" name="mouse_load_driver">,
3712 <ref id="mouse_uninstall" name="mouse_uninstall">,
3713 <ref id="mouse_unload" name="mouse_unload">
3719 <sect1>mouse_ioctl<label id="mouse_ioctl"><p>
3723 <tag/Function/Call the driver specific ioctl function.
3724 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3725 <tag/Declaration/<tt/unsigned char __fastcall__ mouse_ioctl (unsigned char code, void* data);/
3726 <tag/Description/The function calls the IOCTL entry in the mouse driver,
3727 which is driver specific. The <tt/code/ parameter will choose between
3728 different IOCTL functions, and the <tt/data/ depends on code. The
3729 function returns an error code. The purpose of this function is to allow
3730 for driver specific extensions. See the documentation for a specific mouse
3731 driver for supported ioctl calls.
3732 <tag/Limits/<itemize>
3733 <item>Calling this function is non portable, because each driver may
3734 implement different ioctl calls (or none at all).
3735 <item>The function is only available as fastcall function, so it may only be
3736 used in presence of a prototype.
3738 <tag/Availability/cc65
3744 <sect1>mouse_load_driver<label id="mouse_load_driver"><p>
3748 <tag/Function/Load and initialize a mouse driver.
3749 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3750 <tag/Declaration/<tt/unsigned char __fastcall__ mouse_load_driver (const struct
3751 mouse_callbacks* c, const char* driver);/
3752 <tag/Description/Load a mouse driver into memory and initialize it. The
3753 function returns an error code that tells if the call has been successful. The
3754 <tt/mouse_callbacks/ structure passed as first parameter contains pointers to
3755 routines needed to move or hide/show the mouse pointer. Defaults for these
3756 routines are supplied by the library, so if you can live with these defaults
3757 (which are platform specific), just pass a pointer to <tt/mouse_def_callbacks/.
3758 <tag/Limits/<itemize>
3759 <item>The driver is loaded by name, so currently you must know the type of
3760 mouse that should be supported. There is no autodetect capability.
3761 <item>Not all drivers are able to detect if the supported hardware is really
3763 <item>After installing a driver, the mouse cursor is hidden.
3764 <item>The function is only available as fastcall function, so it may only be
3765 used in presence of a prototype.
3767 <tag/Availability/cc65
3769 <ref id="mouse_install" name="mouse_install">,
3770 <ref id="mouse_uninstall" name="mouse_uninstall">,
3771 <ref id="mouse_unload" name="mouse_unload">
3777 <sect1>mouse_move<label id="mouse_move"><p>
3781 <tag/Function/Move the mouse cursor to a specific position.
3782 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3783 <tag/Declaration/<tt/void __fastcall__ mouse_move (int x, int y);/
3784 <tag/Description/The function updates the mouse position. If the mouse cursor
3785 is visible, it is shown at the new position.
3786 <tag/Limits/<itemize>
3787 <item>The function does not check if the new position is within the bounding
3788 box specified with <tt/<ref id="mouse_setbox" name="mouse_setbox">/.
3789 <item>The function is only available as fastcall function, so it may only be
3790 used in presence of a prototype.
3792 <tag/Availability/cc65
3794 <ref id="mouse_getbox" name="mouse_getbox">,
3795 <ref id="mouse_setbox" name="mouse_setbox">
3801 <sect1>mouse_pos<label id="mouse_pos"><p>
3805 <tag/Function/Return the position of the mouse.
3806 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3807 <tag/Declaration/<tt/void __fastcall__ mouse_pos (struct mouse_pos* pos);/
3808 <tag/Description/The function returns the position of the mouse in the
3809 <tt/mouse_pos/ structure passed as parameter.
3810 <tag/Limits/<itemize>
3811 <item>The <tt/mouse_pos/ struct is a subset of the <tt/mouse_info/ struct,
3812 so if you do also need the mouse buttons, call <tt/<ref id="mouse_info"
3813 name="mouse_info">/ instead.
3814 <item>The function is only available as fastcall function, so it may only be
3815 used in presence of a prototype.
3817 <tag/Availability/cc65
3819 <ref id="mouse_buttons" name="mouse_buttons">,
3820 <ref id="mouse_info" name="mouse_info">
3826 <sect1>mouse_show<label id="mouse_show"><p>
3830 <tag/Function/Show the mouse pointer.
3831 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3832 <tag/Declaration/<tt/void mouse_show (void);/
3833 <tag/Description/The function shows the mouse pointer. It manages a counter
3834 that is shared between <tt/<ref id="mouse_hide" name="mouse_hide">/ and
3835 <tt/mouse_show/. The mouse cursor is visible if there was one more call to
3836 <tt/mouse_show/ than to <tt/<ref id="mouse_hide" name="mouse_hide">/.
3837 <tag/Availability/cc65
3839 <ref id="mouse_hide" name="mouse_hide">
3845 <sect1>mouse_uninstall<label id="mouse_uninstall"><p>
3849 <tag/Function/Uninstall an already loaded mouse driver.
3850 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3851 <tag/Declaration/<tt/unsigned char mouse_uninstall (void);/
3852 <tag/Description/The function uninstalls an already loaded mouse driver but
3853 don't removes it from memory.
3854 <tag/Limits/<itemize>
3855 <item>If the driver has been loaded using <tt/<ref id="mouse_load_driver"
3856 name="mouse_load_driver">/, <tt/<ref id="mouse_unload" name="mouse_unload">/
3857 should be used instead of <tt/mouse_uninstall/ so the driver is also removed
3860 <tag/Availability/cc65
3862 <ref id="mouse_install" name="mouse_install">,
3863 <ref id="mouse_load_driver" name="mouse_load_driver">,
3864 <ref id="mouse_unload" name="mouse_unload">
3870 <sect1>mouse_unload<label id="mouse_unload"><p>
3874 <tag/Function/Unload a mouse driver.
3875 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3876 <tag/Declaration/<tt/unsigned char __fastcall__ mouse_unload (void);/
3877 <tag/Description/The function unloads a loaded mouse driver and frees all
3878 memory allocated for the driver.
3879 <tag/Limits/<itemize>
3880 <item>The function does nothing if no driver is loaded.
3882 <tag/Availability/cc65
3884 <ref id="mouse_install" name="mouse_install">,
3885 <ref id="mouse_load_driver" name="mouse_load_driver">,
3886 <ref id="mouse_uninstall" name="mouse_uninstall">
3892 <sect1>offsetof<label id="offsetof"><p>
3896 <tag/Function/Calculate the offset of a struct or union member.
3897 <tag/Header/<tt/<ref id="stddef.h" name="stddef.h">/
3898 <tag/Declaration/<tt/size_t offsetof (type, member);/
3899 <tag/Description/<tt/offsetof/ calculates the address offset of a <tt/struct/
3900 or <tt/union/ member.
3901 <tag/Limits/<itemize>
3902 <item>The function is actually a macro.
3904 <tag/Availability/ISO 9899
3910 <sect1>open<label id="open"><p>
3914 <tag/Function/Open and possibly create a file.
3915 <tag/Header/<tt/<ref id="fcntl.h" name="fcntl.h">/
3916 <tag/Declaration/<tt/int open (const char* name, int flags, ...);/
3917 <tag/Description/<tt/open/ opens a file and returns the file descriptor
3918 associated with it. On error, -1 is returned and an error code is stored in
3919 <tt/errno/. Several flags may be passed to <tt/open/ that change the behaviour.
3920 <tag/Limits/<itemize>
3921 <item>POSIX specifies an additional <tt/mode/ argument that may be passed to
3922 open, which is used as the permission mask when a new file is created. While
3923 cc65 allows to pass this argument, it is ignored.
3925 <tag/Availability/POSIX 1003.1
3927 <ref id="close" name="close">,
3928 <ref id="creat" name="creat">
3934 <sect1>peekbsys<label id="peekbsys"><p>
3938 <tag/Function/Read one byte from a location in the system bank.
3939 <tag/Header/<tt/<ref id="cbm610.h" name="cbm610.h">/,
3940 <tt/<ref id="cbm510.h" name="cbm510.h">/
3941 <tag/Declaration/<tt/unsigned char __fastcall__ peekbsys (unsigned addr);/
3942 <tag/Description/<tt/peekbsys/ reads one byte from the given address in the
3943 system bank (bank 15) of the CBM PET-II machines and returns it.
3946 <item>The function is only available as fastcall function, so it may only
3947 be used in presence of a prototype.
3948 <item>This function may be a macro depending on the compiler options. The
3949 actual function is accessible by #undef'ing the macro.
3951 <tag/Availability/cc65
3953 <ref id="PEEK" name="PEEK">,
3954 <ref id="PEEKW" name="PEEKW">,
3955 <ref id="peekwsys" name="peekwsys">,
3956 <ref id="pokebsys" name="pokebsys">,
3957 <ref id="pokewsys" name="pokewsys">
3963 <sect1>peekwsys<label id="peekwsys"><p>
3967 <tag/Function/Read one word from a location in the system bank.
3968 <tag/Header/<tt/<ref id="cbm610.h" name="cbm610.h">/,
3969 <tt/<ref id="cbm510.h" name="cbm510.h">/
3970 <tag/Declaration/<tt/unsigned __fastcall__ peekwsys (unsigned addr);/
3971 <tag/Description/<tt/peekwsys/ reads one word from the given address in the
3972 system bank (bank 15) of the CBM PET-II machines and returns it. Following
3973 the usual 6502 conventions, the low byte is read from <tt/addr/, and the
3974 high byte is read from <tt/addr+1/.
3977 <item>The function is only available as fastcall function, so it may only
3978 be used in presence of a prototype.
3979 <item>The order in which the two bytes are read is undefined.
3981 <tag/Availability/cc65
3983 <ref id="PEEK" name="PEEK">,
3984 <ref id="PEEKW" name="PEEKW">,
3985 <ref id="peekbsys" name="peekbsys">,
3986 <ref id="pokebsys" name="pokebsys">,
3987 <ref id="pokewsys" name="pokewsys">
3993 <sect1>perror<label id="perror"><p>
3997 <tag/Function/Print an error message for the error in <tt/errno/.
3998 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
3999 <tag/Declaration/<tt/void __fastcall__ perror (const char* s);/
4000 <tag/Description/<tt/perror/ prints an error message to <tt/stderr/. If <tt/s/
4001 is not <tt/NULL/ and not an empty string, it is printed followed by a colon and
4002 a blank. Then the error message for the current contents of <tt/errno/ is
4003 printed followed by a newline. The message output is the same as returned by
4004 <tt/<ref id="strerror" name="strerror">/ with an argument of <tt/errno/.
4007 <item>The function is only available as fastcall function, so it may only
4008 be used in presence of a prototype.
4010 <tag/Availability/ISO 9899
4012 <ref id="_poserror" name="_poserror">,
4013 <ref id="strerror" name="strerror">
4019 <sect1>pokebsys<label id="pokebsys"><p>
4023 <tag/Function/Write one byte to a location in the system bank.
4024 <tag/Header/<tt/<ref id="cbm610.h" name="cbm610.h">/,
4025 <tt/<ref id="cbm510.h" name="cbm510.h">/
4026 <tag/Declaration/<tt/void __fastcall__ pokebsys (unsigned addr, unsigned char val);/
4027 <tag/Description/<tt/pokebsys/ writes one byte to the given address in the
4028 system bank (bank 15) of the CBM PET-II machines.
4031 <item>The function is only available as fastcall function, so it may only
4032 be used in presence of a prototype.
4034 <tag/Availability/cc65
4036 <ref id="POKE" name="POKE">,
4037 <ref id="POKEW" name="POKEW">,
4038 <ref id="peekbsys" name="peekbsys">,
4039 <ref id="peekwsys" name="peekwsys">,
4040 <ref id="pokewsys" name="pokewsys">
4046 <sect1>pokewsys<label id="pokewsys"><p>
4050 <tag/Function/Write one word to a location in the system bank.
4051 <tag/Header/<tt/<ref id="cbm610.h" name="cbm610.h">/,
4052 <tt/<ref id="cbm510.h" name="cbm510.h">/
4053 <tag/Declaration/<tt/void __fastcall__ pokewsys (unsigned addr, unsigned val);/
4054 <tag/Description/<tt/pokewsys/ writes one word to the given address in the
4055 system bank (bank 15) of the CBM PET-II machines. Following the usual 6502
4056 conventions, the low byte of <tt/val/ is written to <tt/addr/, and the
4057 high byte is written to <tt/addr+1/.
4060 <item>The function is only available as fastcall function, so it may only
4061 be used in presence of a prototype.
4062 <item>The order in which the two bytes are written is undefined.
4064 <tag/Availability/cc65
4066 <ref id="POKE" name="POKE">,
4067 <ref id="POKEW" name="POKEW">,
4068 <ref id="peekbsys" name="peekbsys">,
4069 <ref id="peekwsys" name="peekwsys">,
4070 <ref id="pokebsys" name="pokebsys">
4076 <sect1>qsort<label id="qsort"><p>
4080 <tag/Function/Sort an array.
4081 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
4082 <tag/Declaration/<tt/void __fastcall__ qsort (void* base, size_t count,
4083 size_t size, int (*compare) (const void*, const void*));/
4084 <tag/Description/<tt/qsort/ sorts an array according to a given compare
4085 function <tt/compare/. <tt/base/ is the address of the array, <tt/count/
4086 is the number of elements, <tt/size/ the size of an element and <tt/compare/
4087 the function used to compare the members.
4090 <item>If there are multiple members with the same key, the order after calling
4091 the function is undefined.
4092 <item>The function is only available as fastcall function, so it may only
4093 be used in presence of a prototype.
4095 <tag/Availability/ISO 9899
4097 <ref id="bsearch" name="bsearch">
4103 <sect1>raise<label id="raise"><p>
4107 <tag/Function/Send a signal to the executing program.
4108 <tag/Header/<tt/<ref id="signal.h" name="signal.h">/
4109 <tag/Declaration/<tt/int __fastcall__ raise (int sig);/
4110 <tag/Description/<tt/raise/ sends the given signal to the program. If the
4111 program has installed a signal handler for the signal, this signal handler
4112 will be executed. If no handler has been installed, the default action for
4113 the raised signal will be taken. The function returns zero on success,
4115 <tag/Limits/<itemize>
4116 <item>The function is only available as fastcall function, so it may only
4117 be used in presence of a prototype.
4119 <tag/Availability/ISO 9899
4121 <ref id="abort" name="abort">,
4122 <ref id="signal" name="signal">
4128 <sect1>rand<label id="rand"><p>
4132 <tag/Function/Return a pseudo random number.
4133 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
4134 <tag/Declaration/<tt/int rand (void);/
4135 <tag/Description/The function returns a pseudo random number
4136 between 0 and <tt/RAND_MAX/ (exclusive).
4137 <tag/Limits/<itemize>
4138 <item>Without using <tt><ref id="srand" name="srand"></tt>, always the same
4139 flow of numbers is generated.
4140 <item>On startup, the function behaves as if <ref id="srand" name="srand">
4141 had been used with an argument of 1.
4143 <tag/Availability/ISO 9899
4145 <ref id="_randomize" name="_randomize">,
4146 <ref id="srand" name="srand">
4152 <sect1>realloc<label id="realloc"><p>
4156 <tag/Function/Change the size of an allocated memory block.
4157 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
4158 <tag/Declaration/<tt/void* __fastcall__ realloc (void* block, size_t size);/
4159 <tag/Description/<tt/realloc/ changes the size of the memory block pointed to
4160 by <tt/block/ to <tt/size/ bytes. If <tt/block/ is <tt/NULL/, <tt/realloc/
4161 behaves as if <tt/malloc/ had been called. If <tt/size/ is zero, <tt/realloc/
4162 behaves as if <tt/free/ had been called. On error (not enough memory
4163 available), <tt/realloc/ returns <tt/NULL/.
4166 <item>The part of the memory block that is returned will have its contents
4168 <item>This function is somewhat dangerous to use. Be careful to save the
4169 pointer you're passing somewhere else, otherwise
4171 ptr = realloc (ptr, size);
4173 will loose your only copy of <tt/ptr/ if <tt/realloc/ returns <tt/NULL/.
4174 <item>The function is only available as fastcall function, so it may only
4175 be used in presence of a prototype.
4177 <tag/Availability/ISO 9899
4179 <ref id="_heapadd" name="_heapadd">,
4180 <ref id="_heapblocksize" name="_heapblocksize">,
4181 <ref id="_heapmaxavail" name="_heapmaxavail">,
4182 <ref id="_heapmemavail" name="_heapmemavail">,
4183 <ref id="calloc" name="calloc">,
4184 <ref id="free" name="free">,
4185 <ref id="realloc" name="realloc">
4191 <sect1>remove<label id="remove"><p>
4195 <tag/Function/Delete a file.
4196 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
4197 <tag/Declaration/<tt/int __fastcall__ remove (const char* name);/
4198 <tag/Description/<tt/remove/ deletes the file with the given name. On success,
4199 zero is returned. On error, -1 is returned and <tt/errno/ is set to an error
4200 code describing the reason for the failure.
4203 <item>This function is not available on all cc65 targets (depends on the
4204 availability of file I/O).
4205 <item>The function is only available as fastcall function, so it may only
4206 be used in presence of a prototype.
4208 <tag/Availability/ISO 9899
4210 <ref id="rename" name="rename">,
4211 <ref id="unlink" name="unlink">
4214 #include <stdio.h>
4216 #define FILENAME "helloworld"
4218 if (remove (FILENAME) == 0) {
4219 printf ("We deleted %s successfully\n", FILENAME);
4221 printf ("There was a problem deleting %s\n", FILENAME);
4228 <sect1>rename<label id="rename"><p>
4232 <tag/Function/Rename a file.
4233 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
4234 <tag/Declaration/<tt/int __fastcall__ rename (const char* oldname, const char* newname);/
4235 <tag/Description/<tt/rename/ renames a file (gives it a new name). On success,
4236 zero is returned. On error, -1 is returned and <tt/errno/ is set to an error
4237 code describing the reason for the failure.
4240 <item>This function is not available on all cc65 targets (depends on the
4241 capabilities of the storage devices).
4242 <item>The function is only available as fastcall function, so it may only
4243 be used in presence of a prototype.
4245 <tag/Availability/ISO 9899
4247 <ref id="remove" name="remove">
4250 #include <stdio.h>
4252 #define OLDNAME "textfile.txt"
4253 #define NEWNAME "textfile.bak"
4255 if (rename (OLDNAME, NEWNAME) == 0) {
4256 printf ("Renamed %s to %s\n", OLDNAME, NEWNAME);
4258 printf ("Error renaming %s to %s\n", OLDNAME, NEWNAME);
4265 <sect1>reset_brk<label id="reset_brk"><p>
4269 <tag/Function/Resets the break vector to its original value.
4270 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
4271 <tag/Declaration/<tt/void reset_brk (void);/
4272 <tag/Description/<tt/reset_brk/ resets the break vector to the value it had
4273 before a call to <tt/set_brk/.
4276 <item>Since <tt/<ref id="set_brk" name="set_brk">/ installs an exit handler,
4277 it is not strictly necessary to call this function as part of the cleanup when
4280 <tag/Availability/cc65
4282 <ref id="reset_irq" name="reset_irq">,
4283 <ref id="set_brk" name="set_brk">,
4284 <ref id="set_irq" name="set_irq">
4290 <sect1>reset_irq<label id="reset_irq"><p>
4294 <tag/Function/Resets the C level interrupt request vector.
4295 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
4296 <tag/Declaration/<tt/void reset_irq (void);/
4297 <tag/Description/<tt/reset_irq/ resets the C level interrupt request vector.
4300 <item>The original IRQ vector is restored on program termination even without
4301 calling this function.
4303 <tag/Availability/cc65
4305 <ref id="reset_brk" name="reset_brk">,
4306 <ref id="set_brk" name="set_brk">,
4307 <ref id="set_irq" name="set_irq">
4313 <sect1>revers<label id="revers"><p>
4317 <tag/Function/Control revers character display.
4318 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
4319 <tag/Declaration/<tt/unsigned char __fastcall__ revers (unsigned char onoff);/
4320 <tag/Description/If the argument is non zero, the function enables reverse
4321 character display. If the argument is zero, reverse character display is
4322 switched off. The old value of the setting is returned.
4323 <tag/Limits/<itemize>
4324 <item>The function may not be supported by the hardware, in which case
4325 the call is ignored.
4326 <item>The function is only available as fastcall function, so it may only
4327 be used in presence of a prototype.
4329 <tag/Availability/cc65
4331 <ref id="textcolor" name="textcolor">
4337 <sect1>screensize<label id="screensize"><p>
4341 <tag/Function/Return the dimensions of the text mode screen.
4342 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
4343 <tag/Declaration/<tt/void __fastcall__ screensize (unsigned char* x, unsigned char* y);/
4344 <tag/Description/The function returns the dimensions of the text mode screen.
4345 <tag/Limits/<itemize>
4346 <item>The function is only available as fastcall function, so it may only
4347 be used in presence of a prototype.
4349 <tag/Availability/cc65
4351 <ref id="gotox" name="gotox">,
4352 <ref id="gotoxy" name="gotoxy">,
4353 <ref id="gotoy" name="gotoy">,
4354 <ref id="wherex" name="wherex">,
4355 <ref id="wherey" name="wherey">
4361 <sect1>ser_close<label id="ser_close"><p>
4365 <tag/Function/Close the port and disable interrupts
4366 <tag/Header/<tt/<ref id="serial.h" name="serial.h">/
4367 <tag/Declaration/<tt/unsigned char ser_close (void);/
4368 <tag/Description/Close the port by clearing buffers and disable interrupts.
4369 <tag/Availability/cc65
4370 <tag/See also/Other serial functions.
4375 extern char comlynx[];
4377 static void initialize(){
4378 struct ser_params params = {
4385 ser_install(&comlynx); // This will activate the ComLynx
4387 ser_open(&params);
4394 <sect1>ser_get<label id="ser_get"><p>
4398 <tag/Function/Read a character from serial port.
4399 <tag/Header/<tt/<ref id="serial.h" name="serial.h">/
4400 <tag/Declaration/<tt/unsigned char __fastcall__ ser_get (char* b);/
4401 <tag/Description/Get a character from the serial port. If no characters are
4402 available, the function will return SER_ERR_NO_DATA, so this is not a fatal
4404 <tag/Limits/<itemize>
4405 <item>The function is only available as fastcall function, so it may only
4406 be used in presence of a prototype.
4408 <tag/Availability/cc65
4409 <tag/See also/Other serial functions.
4411 Wait for a character to be available from a serial port.
4414 while (ser_get(&ch) == SER_ERR_NO_DATA)
4421 <sect1>ser_install<label id="ser_install"><p>
4425 <tag/Function/Install an already loaded driver and return an error code.
4426 <tag/Header/<tt/<ref id="serial.h" name="serial.h">/
4427 <tag/Declaration/<tt/unsigned char __fastcall__ ser_install (void* driver);/
4428 <tag/Description/The function installs a driver that was already loaded into
4429 memory (or linked statically to the program). It returns an error code
4430 (<tt/SER_ERR_OK/ in case of success).
4431 <tag/Limits/<itemize>
4432 <item>The function is only available as fastcall function, so it may only be
4433 used in presence of a prototype.
4435 <tag/Availability/cc65
4437 <ref id="ser_load_driver" name="ser_load_driver">,
4438 <ref id="ser_uninstall" name="ser_uninstall">,
4439 <ref id="ser_unload" name="ser_unload">
4441 extern char lynxser[]; //Include the driver statically instead of loading it.
4443 ser_install(&lynxser);
4449 <sect1>ser_ioctl<label id="ser_ioctl"><p>
4453 <tag/Function/Platform dependent code extensions.
4454 <tag/Header/<tt/<ref id="serial.h" name="serial.h">/
4455 <tag/Declaration/<tt/unsigned __fastcall__ ser_ioctl (unsigned char code, void* data);/
4456 <tag/Description/Some platforms have extra serial functions that are not
4457 supported by standard serial driver functions. You can extend the driver to support
4458 this extra functionality bt using ser_ioctl functions.
4459 <tag/Limits/<itemize>
4460 <item>The function is only available as fastcall function, so it may only
4461 be used in presence of a prototype.
4462 <item>These functions are not easily portable to other cc65 platforms.
4464 <tag/Availability/cc65
4465 <tag/See also/Other serial functions.
4470 <sect1>ser_load_driver<label id="ser_load_driver"><p>
4474 <tag/Function/Load and install a serial driver.
4475 <tag/Header/<tt/<ref id="serial.h" name="serial.h">/
4476 <tag/Declaration/<tt/unsigned char __fastcall__ ser_load_driver (const char *name);/
4477 <tag/Description/Load and install the driver by name.
4478 Will just load the driver and check if loading was successful.
4479 <tag/Limits/<itemize>
4480 <item>The function is only available as fastcall function, so it may only
4481 be used in presence of a prototype.
4483 <tag/Availability/cc65
4484 <tag/See also/Other serial functions.
4490 <sect1>ser_open<label id="ser_open"><p>
4494 <tag/Function/Open the port by setting the port parameters and enable interrupts
4495 <tag/Header/<tt/<ref id="serial.h" name="serial.h">/
4496 <tag/Declaration/<tt/unsigned char __fastcall__ ser_open (const struct ser_params* params);/
4497 <tag/Description/Open the port by setting the port parameters and enable interrupts.
4498 <tag/Limits/<itemize>
4499 <item>The function is only available as fastcall function, so it may only
4500 be used in presence of a prototype.
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_put<label id="ser_put"><p>
4531 <tag/Function/Write a character to a serial port.
4532 <tag/Header/<tt/<ref id="serial.h" name="serial.h">/
4533 <tag/Declaration/<tt/unsigned char __fastcall__ ser_put (char b);/
4534 <tag/Description/Send a character via the serial port. There is a transmit
4535 buffer, but transmitting is not done via interrupt. The function returns
4536 SER_ERR_OVERFLOW if there is no space left in the transmit buffer.
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.
4551 <sect1>ser_status<label id="ser_status"><p>
4555 <tag/Function/Return the serial port status.
4556 <tag/Header/<tt/<ref id="serial.h" name="serial.h">/
4557 <tag/Declaration/<tt/unsigned char __fastcall__ ser_status (unsigned char* status);/
4558 <tag/Description/Return the serial port status.
4559 <tag/Limits/<itemize>
4560 <item>The function is only available as fastcall function, so it may only
4561 be used in presence of a prototype.
4563 <tag/Availability/cc65
4564 <tag/See also/Other serial functions.
4570 <sect1>ser_uninstall<label id="ser_uninstall"><p>
4574 <tag/Function/Uninstall the currently loaded driver but do not unload it.
4575 <tag/Header/<tt/<ref id="serial.h" name="serial.h">/
4576 <tag/Declaration/<tt/unsigned char ser_uninstall (void);/
4577 <tag/Description/Uninstall the currently loaded driver but do not unload it.
4578 <tag/Availability/cc65
4579 <tag/See also/Other serial functions.
4584 <sect1>ser_unload<label id="ser_unload"><p>
4588 <tag/Function/Uninstall, then unload the currently loaded driver.
4589 <tag/Header/<tt/<ref id="serial.h" name="serial.h">/
4590 <tag/Declaration/<tt/unsigned char ser_unload (void);/
4591 <tag/Description/Uninstall, then unload the currently loaded driver.
4592 <tag/Availability/cc65
4593 <tag/See also/Other serial functions.
4599 <sect1>set_brk<label id="set_brk"><p>
4603 <tag/Function/Set the break vector to a user function.
4604 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
4605 <tag/Declaration/<tt/void __fastcall__ set_brk (brk_handler func);/
4606 <tag/Description/<tt/set_brk/ allows a user program to handle breaks within the
4607 program code by letting the vector point to a user written C function. The
4608 runtime library installs a small stub that saves the registers into global
4609 variables that may be accessed (and changed) by the break handler.
4612 <item>The function is only available as fastcall function, so it may only
4613 be used in presence of a prototype.
4614 <item>The stub saves the zero page registers used by the C runtime and switches
4615 to a small break handler stack. This means that it is safe to execute C code,
4616 even if C code was interrupted. Be careful however not to use too many local
4617 variables, and do not enable stack checks for the handler function or any other
4618 function called from it.
4619 <item>The <tt/brk_pc/ variable points to the <tt/BRK/ instruction. If you want
4620 the continue with the interrupted code, you have to adjust <tt/brk_pc/,
4621 otherwise the <tt/BRK/ instruction will get executed over and over again.
4622 <item>Since <tt/set_brk/ installs an exit handler, it is not strictly necessary
4623 to call <tt/<ref id="reset_brk" name="reset_brk">/ as part of the cleanup when
4624 the program terminates.
4626 <tag/Availability/cc65
4628 <ref id="reset_brk" name="reset_brk">
4634 <sect1>set_irq<label id="set_irq"><p>
4638 <tag/Function/Set the C level interrupt request vector to the given address.
4639 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
4640 <tag/Declaration/<tt/void __fastcall__ set_irq (irq_handler f, void *stack_addr, size_t stack_size);/
4641 <tag/Description/<tt/set_irq/ allows a user program to handle interrupt requests
4642 (IRQs) within the program code by letting the vector point to a user written C
4643 function. The runtime library installs a small stub that saves the zero page
4644 registers used by the C runtime before calling the handler function and restores
4645 them after the handler function returns. Additionally the stub temporarily switches
4646 the C runtime stack to the stack area provided as parameter. If the handler function
4647 was set up to handle a "private", "exclusive" interrupt request source it must
4648 return the value <tt/IRQ_HANDLED/ if and only if it has verified that the current
4649 interrupt request actually stems from that source. In all other cases it must return
4650 the value <tt/IRQ_NOT_HANDLED/.
4653 <item>The function is only available as fastcall function, so it may only
4654 be used in presence of a prototype.
4655 <item>The stub saves the registers and zero page locations used by the C runtime
4656 and switches to the provided stack area. As a consequence, there is some
4657 runtime overhead, but it it is safe to execute C code, even if other C code
4658 was interrupted. Be careful however not to call C library functions, and do not
4659 enable stack checks for the handler function or any other function called from
4661 <item>The interrupt vector is reset on function termination, so it's not
4662 strictly necessary to call <tt/<ref id="reset_irq" name="reset_irq">/ as part
4663 of the cleanup when the program terminates.
4665 <tag/Availability/cc65
4667 <ref id="reset_brk" name="reset_brk">,
4668 <ref id="reset_irq" name="reset_irq">,
4669 <ref id="set_brk" name="set_brk">
4675 <sect1>setjmp<label id="setjmp"><p>
4679 <tag/Function/Save the context for use with <tt/longjmp/.
4680 <tag/Header/<tt/<ref id="setjmp.h" name="setjmp.h">/
4681 <tag/Declaration/<tt/int __fastcall__ setjmp (jmp_buf buf);/
4682 <tag/Description/The <tt/setjmp/ function saves the current context in <tt/buf/
4683 for subsequent use by the <tt/<ref id="longjmp" name="longjmp">/ function and
4687 <item>The function is only available as fastcall function, so it may only
4688 be used in presence of a prototype.
4689 <item><tt/setjmp/ is actually a macro as required by the ISO standard.
4690 <item><tt/setjmp/ will not save the signal context.
4692 <tag/Availability/ISO 9899
4694 <ref id="longjmp" name="longjmp">
4700 <sect1>setlocale<label id="setlocale"><p>
4704 <tag/Function/Selects a locale.
4705 <tag/Header/<tt/<ref id="locale.h" name="locale.h">/
4706 <tag/Declaration/<tt/char* __fastcall__ setlocale (int category, const char* locale);/
4707 <tag/Description/<tt/setlocale/ sets or queries the program's locale.
4710 <item>The function is only available as fastcall function, so it may only
4711 be used in presence of a prototype.
4712 <item>cc65 supports only the "C" locale, so calling this function to set a
4713 different locale has no effect.
4715 <tag/Availability/ISO 9899
4717 <ref id="localeconv" name="localeconv">,
4718 <ref id="strcoll" name="strcoll">
4719 <ref id="strxfrm" name="strxfrm">
4725 <sect1>signal<label id="signal"><p>
4729 <tag/Function/Install a signal handler.
4730 <tag/Header/<tt/<ref id="signal.h" name="signal.h">/
4731 <tag/Declaration/<tt/__sigfunc __fastcall__ signal (int sig, __sigfunc func);/
4732 <tag/Description/<tt/signal/ installs a handler for the given signal. The
4733 handler may either be a user supplied function, or one of the predefined
4734 signal handlers <tt/SIG_IGN/ or <tt/SIG_DFL/. The function returns the
4735 previous value if the signal , or the special function vector SIG_ERR in
4737 <tag/Limits/<itemize>
4738 <item>The function is only available as fastcall function, so it may only
4739 be used in presence of a prototype.
4741 <tag/Availability/ISO 9899
4743 <ref id="abort" name="abort">,
4744 <ref id="raise" name="raise">
4750 <sect1>sleep<label id="sleep"><p>
4754 <tag/Function/Sleep for a specified amount of time.
4755 <tag/Header/<tt/<ref id="unistd.h" name="unistd.h">/
4756 <tag/Declaration/<tt/void __fastcall__ sleep (unsigned seconds);/
4757 <tag/Description/The function will return after the specified number of
4758 seconds have elapsed.
4759 <tag/Limits/<itemize>
4760 <item>The function is only available as fastcall function, so it may only
4761 be used in presence of a prototype.
4763 <tag/Availability/POSIX 1003.1
4769 <sect1>slow<label id="slow"><p>
4773 <tag/Function/Switch the C128 into 1MHz mode.
4774 <tag/Header/<tt/<ref id="c128.h" name="c128.h">/
4775 <tag/Declaration/<tt/void slow (void);/
4776 <tag/Description/The function will switch the clock of the C128 to 1MHz. This
4777 will halve the speed compared to fast mode.
4778 <tag/Limits/<itemize>
4779 <item>The function is specific to the C128.
4781 <tag/Availability/C128
4783 <ref id="fast" name="fast">,
4784 <ref id="toggle_videomode" name="toggle_videomode">,
4785 <ref id="videomode" name="videomode">
4791 <sect1>srand<label id="srand"><p>
4795 <tag/Function/Initialize the pseudo random number generator.
4796 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
4797 <tag/Declaration/<tt/void __fastcall__ srand (unsigned seed);/
4798 <tag/Description/The function initializes the random number generator using
4799 the given seed. On program startup, the generator behaves as if <tt/srand/ has
4800 been called with an argument of 1.
4801 <tag/Limits/<itemize>
4802 <item>The function is only available as fastcall function, so it may only
4803 be used in presence of a prototype.
4805 <tag/Availability/ISO 9899
4807 <ref id="_randomize" name="_randomize">,
4808 <ref id="rand" name="rand">
4814 <sect1>strcasecmp<label id="strcasecmp"><p>
4818 <tag/Function/Compare two strings case insensitive.
4819 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4820 <tag/Declaration/<tt/int __fastcall__ strcasecmp (const char* s1, const char* s2);/
4821 <tag/Description/The <tt/strcasecmp/ function compares the two strings passed
4822 as parameters without case sensitivity. It returns a value that is less than
4823 zero if <tt/s1/ is less than <tt/s2/, zero if <tt/s1/ is the same as <tt/s2/,
4824 and a value greater than zero if <tt/s1/ is greater than <tt/s2/.
4825 <tag/Limits/<itemize>
4826 <item>The function is only available as fastcall function, so it may only
4827 be used in presence of a prototype.
4828 <item>The function is not available in strict ANSI mode.
4830 <tag/Availability/cc65
4832 <ref id="strcmp" name="strcmp">,
4833 <ref id="strcoll" name="strcoll">,
4834 <ref id="stricmp" name="stricmp">,
4835 <ref id="strncmp" name="strncmp">,
4836 <ref id="strxfrm" name="strxfrm">
4842 <sect1>strcat<label id="strcat"><p>
4846 <tag/Function/Concatentate two strings.
4847 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4848 <tag/Declaration/<tt/char* __fastcall__ strcat (char* s1, const char* s2);/
4849 <tag/Description/The <tt/strcat/ function appends a copy of the string
4850 pointed to by s2 (including the terminating null byte) to the end of the
4851 string pointed to by s1. The initial byte of s2 overwrites the null byte at
4853 <tag/Limits/<itemize>
4854 <item>The function is only available as fastcall function, so it may only
4855 be used in presence of a prototype.
4856 <item>If copying takes place between objects that overlap, the behaviour
4859 <tag/Availability/ISO 9899
4861 <ref id="strcpy" name="strcpy">,
4862 <ref id="strncat" name="strncat">,
4863 <ref id="strncpy" name="strncpy">
4869 <sect1>strchr<label id="strchr"><p>
4873 <tag/Function/Search for a character in a string.
4874 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4875 <tag/Declaration/<tt/char* __fastcall__ strchr (const char* s, int c);/
4876 <tag/Description/The <tt/strchr/ function locates the first occurrence of <tt/c/
4877 (converted to a char) in the string pointed to by <tt/s/. The terminating null
4878 byte is considered to be part of the string. Upon completion, the function
4879 returns a pointer to the byte, or a null pointer if the byte was not found.
4880 <tag/Limits/<itemize>
4881 <item>The function is only available as fastcall function, so it may only
4882 be used in presence of a prototype.
4884 <tag/Availability/ISO 9899
4886 <ref id="memchr" name="memchr">,
4887 <ref id="strrchr" name="strrchr">
4893 <sect1>strcmp<label id="strcmp"><p>
4897 <tag/Function/Compare two strings.
4898 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4899 <tag/Declaration/<tt/int __fastcall__ strcmp (const char* s1, const char* s2);/
4900 <tag/Description/The <tt/strcmp/ function compares the two strings passed as
4901 parameters. It returns a value that is less than zero if <tt/s1/ is less than
4902 <tt/s2/, zero if <tt/s1/ is the same as <tt/s2/, and a value greater than zero
4903 if <tt/s1/ is greater than <tt/s2/.
4904 <tag/Limits/<itemize>
4905 <item>The function is only available as fastcall function, so it may only
4906 be used in presence of a prototype.
4908 <tag/Availability/ISO 9899
4910 <ref id="strcasecmp" name="strcasecmp">,
4911 <ref id="strcoll" name="strcoll">,
4912 <ref id="stricmp" name="stricmp">,
4913 <ref id="strncmp" name="strncmp">
4914 <ref id="strxfrm" name="strxfrm">
4920 <sect1>strcoll<label id="strcoll"><p>
4924 <tag/Function/Compare two strings.
4925 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4926 <tag/Declaration/<tt/int __fastcall__ strcoll (const char* s1, const char* s2);/
4927 <tag/Description/The <tt/strcoll/ function compares the two strings passed as
4928 parameters, according to the collating sequence set by <tt/<ref id="setlocale"
4929 name="setlocale">/. It returns a value that is less than zero if <tt/s1/ is
4930 less than <tt/s2/, zero if <tt/s1/ is the same as <tt/s2/, and a value greater
4931 than zero if <tt/s1/ is greater than <tt/s2/.
4932 <tag/Limits/<itemize>
4933 <item>The function is only available as fastcall function, so it may only
4934 be used in presence of a prototype.
4936 <tag/Availability/ISO 9899
4938 <ref id="setlocale" name="setlocale">,
4939 <ref id="strcasecmp" name="strcasecmp">,
4940 <ref id="strcmp" name="strcmp">,
4941 <ref id="stricmp" name="stricmp">,
4942 <ref id="strncmp" name="strncmp">,
4943 <ref id="strxfrm" name="strxfrm">
4949 <sect1>strcpy<label id="strcpy"><p>
4953 <tag/Function/Copy a string.
4954 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4955 <tag/Declaration/<tt/char* __fastcall__ strcpy (char* s1, const char* s2);/
4956 <tag/Description/The <tt/strcpy/ function copies the string pointed to by
4957 <tt/s2/ (including the terminating null byte) into the array pointed to by
4958 <tt/s1/. The function will always return <tt/s1/.
4959 <tag/Limits/<itemize>
4960 <item>The function is only available as fastcall function, so it may only
4961 be used in presence of a prototype.
4962 <item>If copying takes place between objects that overlap, the behaviour
4965 <tag/Availability/ISO 9899
4967 <ref id="strcat" name="strcat">,
4968 <ref id="strncat" name="strncat">,
4969 <ref id="strncpy" name="strncpy">
4972 #include <string.h>
4974 static char hello[14];
4976 strcpy (hello, "Hello world!\n");
4982 <sect1>strcspn<label id="strcspn"><p>
4986 <tag/Function/Compute the length of a substring.
4987 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4988 <tag/Declaration/<tt/size_t __fastcall__ strcspn (const char* s, const char* set);/
4989 <tag/Description/The <tt/strcspn/ function computes and returns the length of
4990 the substring pointed to by <tt/s/ which does <em>not</em> consist of
4991 characters contained in the string <tt/set/.
4992 <tag/Limits/<itemize>
4993 <item>The function is only available as fastcall function, so it may only
4994 be used in presence of a prototype.
4996 <tag/Availability/ISO 9899
4998 <ref id="strspn" name="strspn">,
4999 <ref id="strstr" name="strstr">,
5000 <ref id="strtok" name="strtok">
5006 <sect1>strdup<label id="strdup"><p>
5010 <tag/Function/Allocate a copy of a string on the heap.
5011 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5012 <tag/Declaration/<tt/char* __fastcall__ strdup (const char* s);/
5013 <tag/Description/<tt/strdup/ allocates a memory block on the heap, big enough
5014 to hold a copy of <tt/s/ including the terminating zero. If the allocation
5015 fails, <tt/NULL/ is returned, otherwise <tt/s/ is copied into the allocated
5016 memory block, and a pointer to the block is returned.
5017 <tag/Limits/<itemize>
5018 <item>The function is only available as fastcall function, so it may only
5019 be used in presence of a prototype.
5020 <item>It is up to the caller to free the allocated memory block.
5022 <tag/Availability/ISO 9899
5024 <ref id="free" name="free">,
5025 <ref id="malloc" name="malloc">
5031 <sect1>strerror<label id="strerror"><p>
5035 <tag/Function/Return a string describing an error code.
5036 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5037 <tag/Declaration/<tt/char* __fastcall__ strerror (int errcode);/
5038 <tag/Description/The <tt/strerror/ function returns a string describing the
5039 given error code. If an invalid error code is passed, the string "Unknown
5040 error" is returned, and <tt/errno/ is set to <tt/EINVAL/. In all other cases,
5041 <tt/errno/ is left untouched.
5042 <tag/Limits/<itemize>
5043 <item>The function is only available as fastcall function, so it may only
5044 be used in presence of a prototype.
5045 <item>While the return type of the function is a <tt/char*/, the returned
5046 string must not be modified by the caller!
5048 <tag/Availability/ISO 9899
5050 <ref id="_stroserror" name="_stroserror">
5056 <sect1>stricmp<label id="stricmp"><p>
5060 <tag/Function/Compare two strings case insensitive.
5061 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5062 <tag/Declaration/<tt/int __fastcall__ stricmp (const char* s1, const char* s2);/
5063 <tag/Description/The <tt/stricmp/ function compares the two strings passed as
5064 parameters without case sensitivity. It returns a value that is less than zero
5065 if <tt/s1/ is less than <tt/s2/, zero if <tt/s1/ is the same as <tt/s2/, and a
5066 value greater than zero if <tt/s1/ is greater than <tt/s2/.
5067 <tag/Limits/<itemize>
5068 <item>The function is only available as fastcall function, so it may only
5069 be used in presence of a prototype.
5070 <item>The function is not available in strict ANSI mode.
5072 <tag/Availability/cc65
5074 <ref id="strcasecmp" name="strcasecmp">,
5075 <ref id="strcmp" name="strcmp">,
5076 <ref id="strcoll" name="strcoll">,
5077 <ref id="strncmp" name="strncmp">,
5078 <ref id="strxfrm" name="strxfrm">
5084 <sect1>strlen<label id="strlen"><p>
5088 <tag/Function/Return the length of a string.
5089 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5090 <tag/Declaration/<tt/size_t __fastcall__ strlen (const char* s);/
5091 <tag/Description/The <tt/strlen/ function computes the number of bytes in the
5092 string to which s points, not including the terminating null byte.
5093 <tag/Limits/<itemize>
5094 <item>The function is only available as fastcall function, so it may only
5095 be used in presence of a prototype.
5096 <item>When compiling with <tt/-Os/ (inline known standard functions), the
5097 function does not work correctly for strings with more than 255 characters.
5099 <tag/Availability/ISO 9899
5101 <ref id="strcpy" name="strcpy">
5107 <sect1>strlower<label id="strlower"><p>
5111 <tag/Function/Make a string lower case.
5112 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5113 <tag/Declaration/<tt/char* __fastcall__ strlower (char* s);/
5114 <tag/Description/The <tt/strlower/ function will apply the <tt/tolower/
5115 function to each character of a string. The function will always return <tt/s/.
5116 <tag/Limits/<itemize>
5117 <item>The function is only available as fastcall function, so it may only
5118 be used in presence of a prototype.
5119 <item>The function prototype is unavailable when compiling in strict ANSI mode.
5120 <item>An alias name for this function is <tt/strlwr/.
5122 <tag/Availability/cc65
5124 <ref id="strupper" name="strupper">,
5125 <ref id="tolower" name="tolower">
5131 <sect1>strlwr<label id="strlwr"><p>
5138 <sect1>strncat<label id="strncat"><p>
5142 <tag/Function/Concatentate two strings.
5143 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5144 <tag/Declaration/<tt/char* __fastcall__ strncat (char* s1, const char* s2, size_t n);/
5145 <tag/Description/The <tt/strncat/ function appends not more than n characters
5146 of the string pointed to by s2 to the end of the string pointed to by s1. The
5147 terminating null character at the end of s1 is overwritten. A terminating null
5148 character is appended to the result, even if not all of s2 is appended to s1.
5149 <tag/Limits/<itemize>
5150 <item>The function is only available as fastcall function, so it may only
5151 be used in presence of a prototype.
5152 <item>If copying takes place between objects that overlap, the behaviour
5155 <tag/Availability/ISO 9899
5157 <ref id="strcpy" name="strcpy">,
5158 <ref id="strncat" name="strncat">,
5159 <ref id="strncpy" name="strncpy">
5165 <sect1>strncmp<label id="strncmp"><p>
5169 <tag/Function/Compare two strings.
5170 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5171 <tag/Declaration/<tt/int __fastcall__ strncmp (const char* s1, const char* s2, size_t count);/
5172 <tag/Description/The <tt/strncmp/ function compares not more than <tt/count/
5173 characters of the two strings passed as parameters. It returns a value that is
5174 less than zero if the first <tt/count/ characters of <tt/s1/ are less than
5175 <tt/s2/, zero if they are identical, and a value greater than zero they are
5177 <tag/Limits/<itemize>
5178 <item>The function is only available as fastcall function, so it may only
5179 be used in presence of a prototype.
5181 <tag/Availability/ISO 9899
5183 <ref id="strcasecmp" name="strcasecmp">,
5184 <ref id="strcmp" name="strcmp">,
5185 <ref id="strcoll" name="strcoll">,
5186 <ref id="stricmp" name="stricmp">,
5187 <ref id="strxfrm" name="strxfrm">
5193 <sect1>strncpy<label id="strncpy"><p>
5197 <tag/Function/Copy part of a string.
5198 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5199 <tag/Declaration/<tt/char* __fastcall__ strcpy (char* s1, const char* s2, size_t n);/
5200 <tag/Description/The <tt/strncpy/ function copies not more than n bytes from
5201 the array pointed to by <tt/s2/ to the array pointed to by <tt/s1/. If the array
5202 pointed to by <tt/s2/ is a string that is shorter than n bytes, null bytes are
5203 appended to the copy in the array pointed to by <tt/s1/, until <tt/n/ bytes are
5204 written. The function will always return <tt/s1/.
5205 <tag/Limits/<itemize>
5206 <item>The function is only available as fastcall function, so it may only
5207 be used in presence of a prototype. If there is no null byte in the first <tt/n/
5208 bytes of the array pointed to by <tt/s2/, the result is not null-terminated.
5209 <item>If copying takes place between objects that overlap, the behaviour is
5212 <tag/Availability/ISO 9899
5214 <ref id="strcat" name="strcat">,
5215 <ref id="strcpy" name="strcpy">,
5216 <ref id="strncat" name="strncat">
5221 static char hello[6];
5223 strcpy (hello, "Hello world!\n", sizeof (hello) - 1);
5230 <sect1>strrchr<label id="strrchr"><p>
5234 <tag/Function/Search for a character in a string.
5235 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5236 <tag/Declaration/<tt/char* __fastcall__ strrchr (const char* s, int c);/
5237 <tag/Description/The <tt/strrchr/ function locates the last occurrence of <tt/c/
5238 (converted to a char) in the string pointed to by <tt/s/. The terminating null
5239 byte is considered to be part of the string. Upon completion, the function
5240 returns a pointer to the byte, or a null pointer if the byte was not found.
5241 <tag/Limits/<itemize>
5242 <item>The function is only available as fastcall function, so it may only
5243 be used in presence of a prototype.
5245 <tag/Availability/ISO 9899
5247 <ref id="strchr" name="strchr">
5253 <sect1>strspn<label id="strspn"><p>
5257 <tag/Function/Compute the length of a substring.
5258 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5259 <tag/Declaration/<tt/size_t __fastcall__ strspn (const char* s, const char* set);/
5260 <tag/Description/The <tt/strspn/ function computes and returns the length of
5261 the substring pointed to by <tt/s/ which does consist only of characters
5262 contained in the string <tt/set/.
5263 <tag/Limits/<itemize>
5264 <item>The function is only available as fastcall function, so it may only
5265 be used in presence of a prototype.
5267 <tag/Availability/ISO 9899
5269 <ref id="strcspn" name="strcspn">,
5270 <ref id="strstr" name="strstr">
5276 <sect1>strstr<label id="strstr"><p>
5280 <tag/Function/Find a substring.
5281 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5282 <tag/Declaration/<tt/char* __fastcall__ strstr (const char* str, const char* substr);/
5283 <tag/Description/<tt/strstr/ searches for the first occurance of the string
5284 <tt/substr/ within <tt/str/. If found, it returns a pointer to the copy,
5285 otherwise it returns <tt/NULL/.
5286 <tag/Limits/<itemize>
5287 <item>The function is only available as fastcall function, so it may only
5288 be used in presence of a prototype.
5290 <tag/Availability/ISO 9899
5292 <ref id="strcspn" name="strcspn">,
5293 <ref id="strspn" name="strspn">
5299 <sect1>strtok<label id="strtok"><p>
5303 <tag/Function/Break a string into tokens.
5304 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5305 <tag/Declaration/<tt/char* __fastcall__ strtok (char* s1, const char* s2);/
5306 <tag/Description/<tt/strtok/ will break the string s1 into a sequence of
5307 tokens, which are delimited by characters from the string s2. The first call
5308 to <tt/strtok/ will return a pointer to the first token in the string s1.
5309 Following calls must pass a <tt/NULL/ pointer as s1 in order to get the next
5310 token in the string. Different sets of delimiters may be used for the
5311 subsequent calls to <tt/strtok/.
5312 <tag/Limits/<itemize>
5313 <item>The function is only available as fastcall function, so it may only
5314 be used in presence of a prototype.
5315 <item><tt/strtok/ will modify the string s1.
5317 <tag/Availability/ISO 9899
5319 <ref id="strcspn" name="strcspn">,
5320 <!-- <ref id="strpbrk" name="strpbrk"> -->
5326 <sect1>strxfrm<label id="strxfrm"><p>
5330 <tag/Function/Transform a string.
5331 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5332 <tag/Declaration/<tt/size_t __fastcall__ strxfrm (char* s1, const char* s2, size_t n);/
5333 <tag/Description/The <tt/strxfrm/ function transforms the string pointed to by
5334 s2 and places the resulting string into the string pointed to by s1. The
5335 transformation is such that if the <tt/strcmp/ function is applied to two
5336 transformed strings, it returns a value greater than, equal to, or less than
5337 zero, corresponding to the result of the <tt/strcoll/ function applied to the
5338 same two original strings. No more than n characters are placed into the
5339 resulting array pointed to by s1, including the terminating null character.
5340 <tag/Limits/<itemize>
5341 <item><tt/s1/ and <tt/s2/ must not point to the same memory area, otherwise
5342 the behaviour is undefined.
5343 <item>If <tt/n/ is zero, <tt/s1/ may be a NULL pointer.
5344 <item>The function is only available as fastcall function, so it may only
5345 be used in presence of a prototype.
5346 <item>Since cc65 doesn't support different charcter sets, <tt/strxfrm/ will
5347 just copy s2 to s1 using <tt><ref id="strncpy" name="strncpy"></tt>.
5349 <tag/Availability/ISO 9899
5351 <ref id="strcmp" name="strcmp">,
5352 <ref id="strcoll" name="strcoll">,
5353 <ref id="strncpy" name="strncpy">
5359 <sect1>strupper<label id="strupper"><p>
5363 <tag/Function/Make a string upper case.
5364 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5365 <tag/Declaration/<tt/char* __fastcall__ strupper (char* s);/
5366 <tag/Description/The <tt/strupper/ function will apply the <tt/toupper/
5367 function to each character of a string. The function will always return <tt/s/.
5368 <tag/Limits/<itemize>
5369 <item>The function is only available as fastcall function, so it may only
5370 be used in presence of a prototype.
5371 <item>The function prototype is unavailable when compiling in strict ANSI mode.
5372 <item>An alias name for this function is <tt/strupr/.
5374 <tag/Availability/cc65
5376 <ref id="strlower" name="strlower">
5377 <ref id="toupper" name="toupper">
5383 <sect1>strupr<label id="strupr"><p>
5390 <sect1>textcolor<label id="textcolor"><p>
5394 <tag/Function/Set the text color.
5395 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
5396 <tag/Declaration/<tt/unsigned char __fastcall__ textcolor (unsigned char color);/
5397 <tag/Description/The function will set a new text color. It returns the old
5398 (current) text color. Text output using any <tt/conio.h/ function will use
5399 the color set by this function.
5400 <tag/Limits/<itemize>
5401 <item>Text colors are system dependent. The function may have no effect
5402 on systems where the text color cannot be changed.
5403 <item>The function is only available as fastcall function, so it may only
5404 be used in presence of a prototype.
5406 <tag/Availability/cc65
5408 <ref id="bgcolor" name="bgcolor">,
5409 <ref id="bordercolor" name="bordercolor">
5415 <sect1>tgi_arc<label id="tgi_arc"><p>
5419 <tag/Function/Draw an elliptic arc in the current color.
5420 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5421 <tag/Declaration/<tt/void __fastcall__ tgi_arc (int x, int y,
5422 unsigned char rx, unsigned char ry, unsigned sa, unsigned ea);/
5423 <tag/Description/The function draws an elliptic arc with center at x/y and
5424 radii rx/ry using the current drawing color. The arc covers the angle
5425 between sa and ea (startangle and endangle), which must be in the range
5427 <tag/Limits/<itemize>
5428 <item>The function is only available as fastcall function, so it may only
5429 be used in presence of a prototype.
5430 <item>The function behaves unexpectedly or may crash if the angles are out
5433 <tag/Availability/cc65
5435 <ref id="tgi_bar" name="tgi_bar">,
5436 <ref id="tgi_circle" name="tgi_circle">,
5437 <ref id="tgi_ellipse" name="tgi_ellipse">,
5438 <ref id="tgi_pieslice" name="tgi_pieslice">,
5439 <ref id="tgi_setcolor" name="tgi_setcolor">
5441 /* Draw the upper half of an ellipse */
5442 tgi_setcolor(TGI_COLOR_BLUE);
5443 tgi_arc (50, 50, 40, 20, 0, 180);
5449 <sect1>tgi_bar<label id="tgi_bar"><p>
5453 <tag/Function/The function fills a rectangle on the drawpage with the current
5455 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5456 <tag/Declaration/<tt/void __fastcall__ tgi_bar (int x1, int y1, int x2, int y2);/
5457 <tag/Description/The function fills a rectangle on the drawpage with the current
5459 <tag/Limits/<itemize>
5460 <item>The function is only available as fastcall function, so it may only
5461 be used in presence of a prototype.
5463 <tag/Availability/cc65
5464 <tag/See also/Other tgi function
5466 tgi_setcolor(TGI_COLOR_GREEN);
5467 tgi_bar(10, 10, 100, 60);
5473 <sect1>tgi_circle<label id="tgi_circle"><p>
5477 <tag/Function/The function draws a circle in the current color.
5478 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5479 <tag/Declaration/<tt/void __fastcall__ tgi_circle (int x, int y, unsigned char radius);/
5480 <tag/Description/The function draws a circle in the current color.
5481 <tag/Limits/<itemize>
5482 <item>The function is only available as fastcall function, so it may only
5483 be used in presence of a prototype.
5485 <tag/Availability/cc65
5487 <ref id="tgi_arc" name="tgi_arc">,
5488 <ref id="tgi_bar" name="tgi_bar">,
5489 <ref id="tgi_ellipse" name="tgi_ellipse">,
5490 <ref id="tgi_pieslice" name="tgi_pieslice">,
5491 <ref id="tgi_setcolor" name="tgi_setcolor">
5493 tgi_setcolor(TGI_COLOR_BLACK);
5494 tgi_circle(50, 40, 40);
5500 <sect1>tgi_clear<label id="tgi_clear"><p>
5504 <tag/Function/Clear the drawpage
5505 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5506 <tag/Declaration/<tt/void tgi_clear (void);/
5507 <tag/Description/Clear the drawpage
5508 <tag/Availability/cc65
5509 <tag/See also/Other tgi functions
5515 <sect1>tgi_done<label id="tgi_done"><p>
5519 <tag/Function/End graphics mode, switch back to text mode.
5520 Will NOT uninstall or unload the driver!
5521 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5522 <tag/Declaration/<tt/void tgi_done (void);/
5523 <tag/Description/End graphics mode, switch back to text mode.
5524 Will NOT uninstall or unload the driver!
5525 <tag/Availability/cc65
5526 <tag/See also/Other tgi functions
5532 <sect1>tgi_ellipse<label id="tgi_ellipse"><p>
5536 <tag/Function/The function draws an ellipse in the current color.
5537 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5538 <tag/Declaration/<tt/void __fastcall__ tgi_ellipse (int x, int y, unsigned char rx, unsigned char ry);/
5539 <tag/Description/The function draws an ellipse at position x/y with radii
5540 rx and ry, using the current drawing color.
5541 <tag/Limits/<itemize>
5542 <item>The function is only available as fastcall function, so it may only
5543 be used in presence of a prototype.
5545 <tag/Availability/cc65
5547 <ref id="tgi_arc" name="tgi_arc">,
5548 <ref id="tgi_bar" name="tgi_bar">,
5549 <ref id="tgi_circle" name="tgi_circle">,
5550 <ref id="tgi_pieslice" name="tgi_pieslice">,
5551 <ref id="tgi_setcolor" name="tgi_setcolor">
5553 tgi_setcolor(TGI_COLOR_RED);
5554 tgi_ellipse (50, 40, 40, 20);
5560 <sect1>tgi_getaspectratio<label id="tgi_getaspectratio"><p>
5562 <quote> <descrip> <tag/Function/Return the pixel aspect ratio.
5563 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5564 <tag/Declaration/<tt/unsigned tgi_getaspectratio (void);/
5565 <tag/Description/The function returns the pixel aspect ratio for the current
5566 driver and display as an 8.8 fixed point value. It may be used to correct
5567 geometric shapes so they look correct on the display. As an example, a circle
5568 with a radius of 100 pixels may look elliptic on some driver/display
5569 combinations if the aspect ratio is not 1.00.
5570 <tag/Limits/<itemize>
5571 <item>The aspect ratio is encoded in the TGI driver which assumes a "standard"
5572 monitor for the given platform. The aspect ratio may be wrong if another
5574 <item>No TGI function will use the aspect ratio. It is up to the programmer to
5576 <item>The <ref id="tgi_setaspectratio" name="tgi_setaspectratio"> function can
5577 be used to change the aspect ratio for a loaded driver. The value is not reset
5578 by <ref id="tgi_init" name="tgi_init">, so if a driver is linked statically to
5579 an application, switching into and out of graphics mode will not restore the
5580 original aspect ratio.
5582 <tag/Availability/cc65
5584 <ref id="tgi_setaspectratio" name="tgi_setaspectratio">
5590 <sect1>tgi_getcolor<label id="tgi_getcolor"><p>
5594 <tag/Function/Return the current drawing color.
5595 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5596 <tag/Declaration/<tt/unsigned char tgi_getcolor (void);/
5597 <tag/Description/The actual color is an index to a palette. During tgi_init
5598 you will get a default palette. The number of colors depend on the platform.
5599 All platforms recognize at least TGI_COLOR_BLACK and TGI_COLOR_WHITE. But some
5600 platforms have many more predefined colors. If you paint using TGI_COLOR_GREEN
5601 and then you change the green of the palette to blue using tgi_setpalette then
5602 after this painting in TGI_COLOR_GREEN will actually be blue.
5603 <tag/Availability/cc65
5604 <tag/See also/Other tgi functions
5606 color = tgi_getcolor();
5612 <sect1>tgi_getcolorcount<label id="tgi_getcolorcount"><p>
5616 <tag/Function/Get the number of available colors.
5617 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5618 <tag/Declaration/<tt/unsigned char tgi_getcolorcount (void);/
5619 <tag/Description/Tgi platforms use indexed color palettes. This function
5620 returns the number of entries we can use in the palette.
5621 <tag/Availability/cc65
5622 <tag/See also/Other tgi functions
5624 if (tgi_getcolorcount() == 2) {
5625 printf("Only monochrome graphics is supported\n");
5632 <sect1>tgi_getdefpalette<label id="tgi_getdefpalette"><p>
5636 <tag/Function/Get the palette installed by default.
5637 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5638 <tag/Declaration/<tt/const unsigned char* tgi_getdefpalette (void);/
5639 <tag/Description/The tgi driver has a default palette that is active at startup.
5640 The named colors TGI_COLOR_BLACK, TGI_COLOR_WHITE, TGI_COLOR_RED... need this
5641 palette to work correctly.
5642 <tag/Availability/cc65
5643 <tag/See also/Other tgi functions
5649 <sect1>tgi_geterror<label id="tgi_geterror"><p>
5653 <tag/Function/Return the error code for the last operation.
5654 This will also clear the error.
5655 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5656 <tag/Declaration/<tt/unsigned char tgi_geterror (void);/
5657 <tag/Description/Return the error code for the last operation.
5658 This will also clear the error.
5659 <tag/Availability/cc65
5660 <tag/See also/Other tgi functions
5666 <sect1>tgi_geterrormsg<label id="tgi_geterrormsg"><p>
5670 <tag/Function/Get an error message describing the error.
5671 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5672 <tag/Declaration/<tt/const char* __fastcall__ tgi_geterrormsg (unsigned char code);/
5673 <tag/Description/Get an error message describing the error.
5674 <tag/Limits/<itemize>
5675 <item>The function is only available as fastcall function, so it may only
5676 be used in presence of a prototype.
5678 <tag/Availability/cc65
5679 <tag/See also/Other tgi functions
5685 <sect1>tgi_getmaxcolor<label id="tgi_getmaxcolor"><p>
5689 <tag/Function/Get the highest index of the palette.
5690 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5691 <tag/Declaration/<tt/unsigned char tgi_getmaxcolor (void);/
5692 <tag/Description/Get the highest index of the palette.
5693 <tag/Availability/cc65
5694 <tag/See also/Other tgi functions
5700 <sect1>tgi_getmaxx<label id="tgi_getmaxx"><p>
5704 <tag/Function/Get the maximum x coordinate that can be used on this screen.
5705 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5706 <tag/Declaration/<tt/unsigned tgi_getmaxx (void);/
5707 <tag/Description/Get the maximum x coordinate that can be used on this screen.
5708 <tag/Availability/cc65
5709 <tag/See also/Other tgi functions
5715 <sect1>tgi_getmaxy<label id="tgi_getmaxy"><p>
5719 <tag/Function/Get the maximum y coordinate that can be used on this screen.
5720 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5721 <tag/Declaration/<tt/unsigned tgi_getmaxy (void);/
5722 <tag/Description/Get the maximum y coordinate that can be used on this screen.
5723 <tag/Availability/cc65
5724 <tag/See also/Other tgi functions
5730 <sect1>tgi_getpagecount<label id="tgi_getpagecount"><p>
5734 <tag/Function/Return the number of screen pages available.
5735 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5736 <tag/Declaration/<tt/unsigned tgi_getpagecount (void);/
5737 <tag/Description/Return the number of screen pages available.
5738 <tag/Availability/cc65
5740 <ref id="tgi_setdrawpage" name="tgi_setdrawpage">,
5741 <ref id="tgi_setviewpage" name="tgi_setviewpage">
5747 <sect1>tgi_getpalette<label id="tgi_getpalette"><p>
5751 <tag/Function/Get the palette installed.
5752 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5753 <tag/Declaration/<tt/const unsigned char* tgi_getpalette (void);/
5754 <tag/Description/Get the palette installed.
5755 <tag/Availability/cc65
5756 <tag/See also/Other tgi functions
5762 <sect1>tgi_getpixel<label id="tgi_getpixel"><p>
5766 <tag/Function/Get the color of a pixel from the viewpage.
5767 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5768 <tag/Declaration/<tt/unsigned char __fastcall__ tgi_getpixel (int x, int y);/
5769 <tag/Description/Get the color of a pixel from the viewpage.
5770 <tag/Limits/<itemize>
5771 <item>The function is only available as fastcall function, so it may only
5772 be used in presence of a prototype.
5774 <tag/Availability/cc65
5775 <tag/See also/Other tgi functions.
5781 <sect1>tgi_getxres<label id="tgi_getxres"><p>
5785 <tag/Function/Get number of horisontal pixels on the screen.
5786 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5787 <tag/Declaration/<tt/unsigned tgi_getxres (void);/
5788 <tag/Description/Get number of horisontal pixels on the screen.
5789 This is same as tgi_maxx()+1.
5790 <tag/Availability/cc65
5791 <tag/See also/Other tgi functions.
5797 <sect1>tgi_getyres<label id="tgi_getyres"><p>
5801 <tag/Function/Get number of vertical pixels on the screen.
5802 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5803 <tag/Declaration/<tt/unsigned tgi_getyres (void);/
5804 <tag/Description/Get number of vertical pixels on the screen.
5805 This is same as tgi_maxy()+1.
5806 <tag/Availability/cc65
5807 <tag/See also/Other tgi functions.
5813 <sect1>tgi_gotoxy<label id="tgi_gotoxy"><p>
5817 <tag/Function/Set graphics cursor at x, y.
5818 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5819 <tag/Declaration/<tt/void __fastcall__ tgi_gotoxy (int x, int y);/
5820 <tag/Description/Set graphics cursor at x, y.
5821 <tag/Limits/<itemize>
5822 <item>The function is only available as fastcall function, so it may only
5823 be used in presence of a prototype.
5825 <tag/Availability/cc65
5826 <tag/See also/Other tgi functions.
5832 <sect1>tgi_init<label id="tgi_init"><p>
5836 <tag/Function/Initialize the already loaded graphics driver.
5837 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5838 <tag/Declaration/<tt/void tgi_init (void);/
5839 <tag/Description/The tgi_init function will set the default palette to the
5841 <tag/Limits/<itemize>
5842 <item><tt/tgi_init/ will not clear the screen. This allows switching between
5843 text and graphics mode on platforms that have separate memory areas for the
5844 screens. If you want the screen cleared, call <tt/<ref id="tgi_clear"
5845 name="tgi_clear">/ after <tt/tgi_init/.
5847 <tag/Availability/cc65
5848 <tag/See also/Other tgi functions.
5850 extern char lynxtgi[]; //Include the driver statically instead of loading it.
5851 tgi_install(&lynxtgi);
5852 tgi_init(); //Set up the default palette and clear the screen.
5858 <sect1>tgi_install<label id="tgi_install"><p>
5862 <tag/Function/Install an already loaded driver and return an error code.
5863 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5864 <tag/Declaration/<tt/unsigned char __fastcall__ tgi_install (void* driver);/
5865 <tag/Description/The function installs a driver that was already loaded into
5866 memory (or linked statically to the program). It returns an error code
5867 (<tt/TGI_ERR_OK/ in case of success).
5868 <tag/Limits/<itemize>
5869 <item>The function is only available as fastcall function, so it may only be
5870 used in presence of a prototype.
5872 <tag/Availability/cc65
5874 <ref id="tgi_load_driver" name="tgi_load_driver">,
5875 <ref id="tgi_uninstall" name="tgi_uninstall">,
5876 <ref id="tgi_unload" name="tgi_unload">
5878 extern char lynxtgi[]; //Include the driver statically instead of loading it.
5880 tgi_install(&lynxtgi);
5881 tgi_init(); //Set up the default palette and clear the screen.
5887 <sect1>tgi_ioctl<label id="tgi_ioctl"><p>
5891 <tag/Function/Platform dependent code extensions.
5892 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5893 <tag/Declaration/<tt/unsigned __fastcall__ tgi_ioctl (unsigned char code, void* data);/
5894 <tag/Description/Some platforms have extra display hardware that is not
5895 supported by standard tgi functions. You can extend the driver to support
5896 this extra hardware using tgi_ioctl functions.
5897 <tag/Limits/<itemize>
5898 <item>The function is only available as fastcall function, so it may only
5899 be used in presence of a prototype.
5900 <item>These functions are not easily portable to other cc65 platforms.
5902 <tag/Availability/cc65
5903 <tag/See also/Other tgi functions.
5905 #define tgi_sprite(spr) tgi_ioctl(0, (void*)(spr))
5906 #define tgi_flip() tgi_ioctl(1, (void*)0)
5907 #define tgi_setbgcolor(bgcol) tgi_ioctl(2, (void*)(bgcol))
5908 #define tgi_setframerate(rate) tgi_ioctl(3, (void*)(rate))
5909 #define tgi_busy() tgi_ioctl(4, (void*)0)
5910 #define tgi_updatedisplay() tgi_ioctl(4, (void*)1)
5912 tgi_sprite(&background);
5913 tgi_setcolor(TGI_COLOR_BLUE);
5914 tgi_outttextxy(20,40,"Hello World");
5915 tgi_updatedisplay();
5922 <sect1>tgi_line<label id="tgi_line"><p>
5926 <tag/Function/Draw a line in the current drawing color.
5927 The graphics cursor will be set to x2/y2 by this call.
5928 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5929 <tag/Declaration/<tt/void __fastcall__ tgi_line (int x1, int y1, int x2, int y2);/
5930 <tag/Description/Draw a line in the current drawing color.
5931 The graphics cursor will be set to x2/y2 by this call.
5932 <tag/Limits/<itemize>
5933 <item>The function is only available as fastcall function, so it may only
5934 be used in presence of a prototype.
5936 <tag/Availability/cc65
5937 <tag/See also/Other tgi functions.
5943 <sect1>tgi_lineto<label id="tgi_lineto"><p>
5947 <tag/Function/Draw a line in the current drawing color from the graphics
5948 cursor to the new end point. The graphics cursor will be updated to x2/y2.
5949 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5950 <tag/Declaration/<tt/void __fastcall__ tgi_lineto (int x2, int y2);/
5951 <tag/Description/Draw a line in the current drawing color from the graphics
5952 cursor to the new end point. The graphics cursor will be updated to x2/y2.
5953 <tag/Limits/<itemize>
5954 <item>The function is only available as fastcall function, so it may only
5955 be used in presence of a prototype.
5957 <tag/Availability/cc65
5958 <tag/See also/Other tgi functions.
5964 <sect1>tgi_load_driver<label id="tgi_load_driver"><p>
5968 <tag/Function/Load and install the given driver.
5969 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5970 <tag/Declaration/<tt/void __fastcall__ tgi_load_driver (const char *name);/
5971 <tag/Description/Load and install the driver by name.
5972 Will just load the driver and check if loading was successful.
5973 Will not switch to graphics mode.
5974 <tag/Limits/<itemize>
5975 <item>The function is only available as fastcall function, so it may only
5976 be used in presence of a prototype.
5978 <tag/Availability/cc65
5979 <tag/See also/Other tgi functions.
5985 <sect1>tgi_outtext<label id="tgi_outtext"><p>
5989 <tag/Function/Output text at the current graphics cursor position.
5990 The graphics cursor is moved to the end of the text.
5991 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5992 <tag/Declaration/<tt/void __fastcall__ tgi_outtext (const char* s);/
5993 <tag/Description/Output text at the current graphics cursor position.
5994 The graphics cursor is moved to the end of the text.
5995 <tag/Limits/<itemize>
5996 <item>The function is only available as fastcall function, so it may only
5997 be used in presence of a prototype.
5999 <tag/Availability/cc65
6000 <tag/See also/Other tgi functions.
6006 <sect1>tgi_outtextxy<label id="tgi_outtextxy"><p>
6010 <tag/Function/Output text at the given cursor position.
6011 The graphics cursor is moved to the end of the text.
6012 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6013 <tag/Declaration/<tt/void __fastcall__ tgi_outtextxy (int x, int y, const char* s);/
6014 <tag/Description/Output text at the given cursor position.
6015 The graphics cursor is moved to the end of the text.
6016 <tag/Limits/<itemize>
6017 <item>The function is only available as fastcall function, so it may only
6018 be used in presence of a prototype.
6020 <tag/Availability/cc65
6021 <tag/See also/Other tgi functions.
6027 <sect1>tgi_pieslice<label id="tgi_pieslice"><p>
6031 <tag/Function/Draw an elliptic pie slice in the current color.
6032 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6033 <tag/Declaration/<tt/void __fastcall__ tgi_pie slice (int x, int y,
6034 unsigned char rx, unsigned char ry, unsigned sa, unsigned ea);/
6035 <tag/Description/The function draws an elliptic pie slice with center at x/y
6036 and radii rx/ry using the current drawing color. The pie slice covers the angle
6037 between sa and ea (startangle and endangle), which must be in the range
6039 <tag/Limits/<itemize>
6040 <item>The function is only available as fastcall function, so it may only
6041 be used in presence of a prototype.
6042 <item>The function behaves unexpectedly or may crash if the angles are out
6045 <tag/Availability/cc65
6047 <ref id="tgi_bar" name="tgi_arc">,
6048 <ref id="tgi_bar" name="tgi_bar">,
6049 <ref id="tgi_circle" name="tgi_circle">,
6050 <ref id="tgi_ellipse" name="tgi_ellipse">,
6051 <ref id="tgi_setcolor" name="tgi_setcolor">
6053 /* Draw the closed upper half of an ellipse */
6054 tgi_setcolor(TGI_COLOR_BLUE);
6055 tgi_pieslice (50, 50, 40, 20, 0, 180);
6061 <sect1>tgi_setaspectratio<label id="tgi_setaspectratio"><p>
6063 <quote> <descrip> <tag/Function/Set the pixel aspect ratio.
6064 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6065 <tag/Declaration/<tt/void __fastcall__ tgi_setaspectratio (unsigned ratio);/
6066 <tag/Description/The function sets the pixel aspect ratio for the current
6067 driver and display. The argument is an 8.8 fixed point value. The aspect ratio
6068 may be used to correct geometric shapes so they look correct on a given
6069 display. As an example, a circle with a radius of 100 pixels may look elliptic
6070 on some driver/display combinations if the aspect ratio is not 1.00.
6071 <tag/Limits/<itemize>
6072 <item>The aspect ratio is encoded in the TGI driver which assumes a "standard"
6073 monitor for the given platform. The aspect ratio may be wrong if another
6075 <item>No TGI function will use the aspect ratio. It is up to the programmer to
6077 <item>The <tt/tgi_setaspectratio/ function can be used to change the aspect
6078 ratio for a loaded driver. The value is not reset by <ref id="tgi_init"
6079 name="tgi_init">, so if a driver is linked statically to an application,
6080 switching into and out of graphics mode will not restore the original aspect
6083 <tag/Availability/cc65
6085 <ref id="tgi_getaspectratio" name="tgi_getaspectratio">
6091 <sect1>tgi_setcolor<label id="tgi_setcolor"><p>
6095 <tag/Function/Set color to be used in future draw operations.
6096 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6097 <tag/Declaration/<tt/void __fastcall__ tgi_setcolor (unsigned char color);/
6098 <tag/Description/Set color to be used in future draw operations.
6099 <tag/Limits/<itemize>
6100 <item>The function is only available as fastcall function, so it may only
6101 be used in presence of a prototype.
6103 <tag/Availability/cc65
6104 <tag/See also/Other tgi functions.
6106 tgi_setcolor(TGI_COLOR_BLACK);
6108 tgi_setcolor(TGI_COLOR_WHITE);
6109 tgi_bar(10,10,20,20);
6114 <sect1>tgi_setdrawpage<label id="tgi_setdrawpage"><p>
6118 <tag/Function/Set the page for drawing.
6119 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6120 <tag/Declaration/<tt/void __fastcall__ tgi_setdrawpage (unsigned char page);/
6121 <tag/Description/If the drawpage and the viewpage are the same then all drawing
6122 is seen immediately as it is drawn. For double buffered games you can set the
6123 drawpage to a different page than the viewpage. This lets you draw the next
6124 screen in the background and when the screen is ready you display it.
6125 <tag/Limits/<itemize>
6126 <item>The function is only available as fastcall function, so it may only
6127 be used in presence of a prototype.
6129 <tag/Availability/cc65
6130 <tag/See also/Other tgi functions.
6133 tgi_outtextxy(10, 10, "Hello World");
6134 tgi_setviewpage(1); // Show page 1
6136 tgi_outtextxy(10, 10, "Creating next frame");
6138 tgi_setviewpage(0); // Show page 0
6143 <sect1>tgi_setpalette<label id="tgi_setpalette"><p>
6147 <tag/Function/Set the palette (not available with all drivers/hardware).
6148 Palette is a pointer to as many entries as there are colors.
6149 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6150 <tag/Declaration/<tt/void __fastcall__ tgi_setpalette (const unsigned char* palette);/
6151 <tag/Description/Set the palette (not available with all drivers/hardware).
6152 Palette is a pointer to as many entries as there are colors.
6153 <tag/Limits/<itemize>
6154 <item>The function is only available as fastcall function, so it may only
6155 be used in presence of a prototype.
6157 <tag/Availability/cc65
6158 <tag/See also/Other tgi functions.
6163 <sect1>tgi_setpixel<label id="tgi_setpixel"><p>
6167 <tag/Function/Plot a pixel on the drawpage with the current color.
6168 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6169 <tag/Declaration/<tt/void __fastcall__ tgi_setpixel (int x, int y);/
6170 <tag/Description/Plot a pixel on the drawpage with the current color.
6171 <tag/Limits/<itemize>
6172 <item>The function is only available as fastcall function, so it may only
6173 be used in presence of a prototype.
6175 <tag/Availability/cc65
6176 <tag/See also/Other tgi functions.
6181 <sect1>tgi_setviewpage<label id="tgi_setviewpage"><p>
6185 <tag/Function/Set page to be visible on screen.
6186 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6187 <tag/Declaration/<tt/void __fastcall__ tgi_setviewpage (unsigned char page);/
6188 <tag/Description/If the drawpage and the viewpage are the same then all drawing
6189 is seen immediately as it is drawn. For double buffered games you can set the
6190 drawpage to a different page than the viewpage. This lets you draw the next
6191 screen in the background and when the screen is ready you display it.
6192 <tag/Limits/<itemize>
6193 <item>The function is only available as fastcall function, so it may only
6194 be used in presence of a prototype.
6196 <tag/Availability/cc65
6197 <tag/See also/Other tgi functions.
6200 tgi_outtextxy(10, 10, "Hello World");
6201 tgi_setviewpage(1); // Show page 1
6203 tgi_outtextxy(10, 10, "Creating next frame");
6205 tgi_setviewpage(0); // Show page 0
6210 <sect1>tgi_gettextheight<label id="tgi_gettextheight"><p>
6214 <tag/Function/Calculate the height of the text in pixels according to
6215 the current text style.
6216 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6217 <tag/Declaration/<tt/unsigned __fastcall__ tgi_gettextheight (const char* s);/
6218 <tag/Description/Calculate the height of the text in pixels according to
6219 the current text style.
6220 <tag/Limits/<itemize>
6221 <item>The function is only available as fastcall function, so it may only
6222 be used in presence of a prototype.
6224 <tag/Availability/cc65
6225 <tag/See also/Other tgi functions.
6230 <sect1>tgi_settextstyle<label id="tgi_settextstyle"><p>
6234 <tag/Function/Set the style for text output.
6235 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6236 <tag/Declaration/<tt/void __fastcall__ tgi_settextstyle (unsigned char magx, unsigned char magy, unsigned char dir);/
6237 <tag/Description/Set the style for text output.
6238 <tag/Limits/<itemize>
6239 <item>The function is only available as fastcall function, so it may only
6240 be used in presence of a prototype.
6242 <tag/Availability/cc65
6243 <tag/See also/Other tgi functions.
6248 <sect1>tgi_gettextwidth<label id="tgi_gettextwidth"><p>
6252 <tag/Function/Calculate the width of the text in pixels according to the current text style.
6253 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6254 <tag/Declaration/<tt/unsigned __fastcall__ tgi_gettextwidth (const char* s);/
6255 <tag/Function/Calculate the width of the text in pixels according to the current text style.
6256 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6257 <tag/Description/Calculate the width of the text in pixels according to the current text style.
6258 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6259 <tag/Limits/<itemize>
6260 <item>The function is only available as fastcall function, so it may only
6261 be used in presence of a prototype.
6263 <tag/Availability/cc65
6264 <tag/See also/Other tgi functions.
6269 <sect1>tgi_uninstall<label id="tgi_uninstall"><p>
6273 <tag/Function/Uninstall the currently loaded driver but do not unload it.
6274 Will call tgi_done if necessary.
6275 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6276 <tag/Declaration/<tt/void tgi_uninstall (void);/
6277 <tag/Description/Uninstall the currently loaded driver but do not unload it.
6278 Will call tgi_done if necessary.
6279 <tag/Availability/cc65
6280 <tag/See also/Other tgi functions.
6285 <sect1>tgi_unload<label id="tgi_unload"><p>
6289 <tag/Function/Uninstall, then unload the currently loaded driver.
6290 Will call tgi_done if necessary.
6291 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6292 <tag/Declaration/<tt/void tgi_unload (void);/
6293 <tag/Description/Uninstall, then unload the currently loaded driver.
6294 Will call tgi_done if necessary.
6295 <tag/Availability/cc65
6296 <tag/See also/Other tgi functions.
6301 <sect1>time<label id="time"><p>
6305 <tag/Function/Get the time.
6306 <tag/Header/<tt/<ref id="time.h" name="time.h">/
6307 <tag/Declaration/<tt/time_t __fastcall__ time (time_t* t);/
6308 <tag/Description/The function returns the time since the 1970-01-01 00:00:00
6309 measured in seconds. If the pointer <tt/t/ is not <tt/NULL/, the function
6310 result will also be stored there. If no time is available, <tt/(time_t)-1/ is
6311 returned and <tt/errno/ is set to <tt/ENOSYS/.
6312 <tag/Limits/<itemize>
6313 <item>The function is only available as fastcall function, so it may
6314 only be used in presence of a prototype.
6315 <item>Many platforms supported by cc65 do not have a realtime clock, so the
6316 returned value may not be valid.
6318 <tag/Availability/ISO 9899
6320 <ref id="clock" name="clock">
6326 <sect1>toggle_videomode<label id="toggle_videomode"><p>
6330 <tag/Function/Toggle between 40 and 80 column mode.
6331 <tag/Header/<tt/<ref id="c128.h" name="c128.h">/
6332 <tag/Declaration/<tt/void toggle_videomode (void);/
6333 <tag/Description/Toggle between 40 and 80 column mode. The settings for the
6334 old mode (cursor position, color and so on) are saved and restored together
6336 <tag/Limits/<itemize>
6337 <item>The function is specific to the C128.
6338 <item>This function is deprecated. Please use <ref id="videomode"
6339 name="videomode"> instead!
6341 <tag/Availability/C128
6343 <ref id="fast" name="fast">,
6344 <ref id="slow" name="slow">,
6345 <ref id="videomode" name="videomode">
6351 <sect1>tolower<label id="tolower"><p>
6355 <tag/Function/Convert a character into its lower case representation.
6356 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
6357 <tag/Declaration/<tt/int __fastcall__ tolower (int c);/
6358 <tag/Description/The function returns the given character converted to lower
6359 case. If the given character is not a letter, it is returned unchanged.
6360 <tag/Limits/<itemize>
6361 <item>The function is only available as fastcall function, so it may
6362 only be used in presence of a prototype.
6364 <tag/Availability/ISO 9899
6366 <ref id="islower" name="islower">,
6367 <ref id="isupper" name="isupper">,
6368 <ref id="toupper" name="toupper">
6374 <sect1>toupper<label id="toupper"><p>
6378 <tag/Function/Convert a character into its upper case representation.
6379 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
6380 <tag/Declaration/<tt/int __fastcall__ toupper (int c);/
6381 <tag/Description/The function returns the given character converted to upper
6382 case. If the given character is not a letter, it is returned unchanged.
6383 <tag/Limits/<itemize>
6384 <item>The function is only available as fastcall function, so it may
6385 only be used in presence of a prototype.
6387 <tag/Availability/ISO 9899
6389 <ref id="islower" name="islower">,
6390 <ref id="isupper" name="isupper">,
6391 <ref id="tolower" name="tolower">
6397 <sect1>ultoa<label id="ultoa"><p>
6401 <tag/Function/Convert an unsigned long integer into a string.
6402 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
6403 <tag/Declaration/<tt/char* __fastcall__ ultoa (unsigned long val, char* buf, int radix);/
6404 <tag/Description/<tt/itoa/ converts the unsigned long integer <tt/val/ into a
6405 string using <tt/radix/ as the base.
6406 <tag/Limits/<itemize>
6407 <item>There are no provisions to prevent a buffer overflow.
6408 <item>The function is non standard, so it is not available in strict ANSI mode.
6409 You should probably use <tt/sprintf/ instead.
6410 <item>The function is only available as fastcall function, so it may only be
6411 used in presence of a prototype.
6413 <tag/Availability/cc65
6415 <ref id="atoi" name="atoi">,
6416 <ref id="atol" name="atol">,
6417 <ref id="itoa" name="itoa">,
6418 <ref id="ltoa" name="ltoa">,
6419 <ref id="utoa" name="utoa">
6425 <sect1>unlink<label id="unlink"><p>
6429 <tag/Function/Delete a file.
6430 <tag/Header/<tt/<ref id="unistd.h" name="unistd.h">/
6431 <tag/Declaration/<tt/int __fastcall__ unlink (const char* name);/
6432 <tag/Description/<tt/unlink/ deletes the file with the given name. On success,
6433 zero is returned. On error, -1 is returned and <tt/errno/ is set to an error
6434 code describing the reason for the failure.
6437 <item>The use of this function is discouraged. Please use <tt/<ref id="remove"
6438 name="remove">/ instead, which is a native ANSI C function and does the same.
6439 <item>This function is not available on all cc65 targets (depends on the
6440 availability of file I/O).
6441 <item>The function is only available as fastcall function, so it may only
6442 be used in presence of a prototype.
6443 <item>Instead of <tt/unlink/, <tt/<ref id="remove" name="remove">/ should be
6444 used, which has the same semantics, but is more portable, because it conforms
6445 to the ISO C standard.
6447 <tag/Availability/POSIX 1003.1
6449 <ref id="remove" name="remove">
6452 #include <stdio.h>
6453 #include <unistd.h>
6455 #define FILENAME "helloworld"
6457 if (unlink (FILENAME) == 0) {
6458 printf ("We deleted %s successfully\n", FILENAME);
6460 printf ("There was a problem deleting %s\n", FILENAME);
6467 <sect1>utoa<label id="utoa"><p>
6471 <tag/Function/Convert an unsigned integer into a string.
6472 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
6473 <tag/Declaration/<tt/char* __fastcall__ utoa (unsigned val, char* buf, int radix);/
6474 <tag/Description/<tt/itoa/ converts the unsigned integer <tt/val/ into a string
6475 using <tt/radix/ as the base.
6476 <tag/Limits/<itemize>
6477 <item>There are no provisions to prevent a buffer overflow.
6478 <item>The function is non standard, so it is not available in strict ANSI mode.
6479 You should probably use <tt/sprintf/ instead.
6480 <item>The function is only available as fastcall function, so it may only be
6481 used in presence of a prototype.
6483 <tag/Availability/cc65
6485 <ref id="atoi" name="atoi">,
6486 <ref id="atol" name="atol">,
6487 <ref id="itoa" name="itoa">,
6488 <ref id="ltoa" name="ltoa">,
6489 <ref id="ultoa" name="ultoa">
6495 <sect1>vcprintf<label id="vcprintf"><p>
6499 <tag/Function/Formatted output to the console.
6500 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
6501 <tag/Declaration/<tt/int __fastcall__ vcprintf (const char* format, va_list ap);/
6502 <tag/Description/The arguments specified as a <tt/va_list/ are converted to
6503 text where necessary and formatted according to the format string given. The
6504 resulting string is output to the console. <tt/vcprintf/ supports the same
6505 format specifiers as <tt/vprintf/. <!-- <tt/<ref id="vprintf" name="vprintf">/. -->
6506 <tag/Limits/<itemize>
6507 <item>Like all other <tt/conio/ output functions, <tt/vcprintf/ distinguishes
6508 between <tt/\r/ and <tt/\n/.
6509 <item>The function is only available as fastcall function, so it may only be
6510 used in presence of a prototype.
6512 <tag/Availability/cc65
6514 <ref id="cprintf" name="cprintf">,
6515 <ref id="cputc" name="cputc">,
6516 <ref id="cputcxy" name="cputcxy">,
6517 <ref id="cputs" name="cputs">,
6518 <ref id="cputsxy" name="cputsxy">
6524 <sect1>videomode<label id="videomode"><p>
6528 <tag/Function/Switch to either 40 or 80 column mode.
6529 <tag/Header/<tt/<ref id="apple2enh.h" name="apple2enh.h">,
6530 <ref id="c128.h" name="c128.h">/
6531 <tag/Declaration/<tt/unsigned __fastcall__ videomode (unsigned Mode);/
6532 <tag/Description/Switch to 40 or 80 column mode depending on the argument. If
6533 the requested mode is already active, nothing happens. The old mode is returned
6535 <tag/Limits/<itemize>
6536 <item>The function is specific to the C128 and enhanced Apple //e.
6537 <item>This function replaces <ref id="toggle_videomode"
6538 name="toggle_videomode">.
6539 <item>The function is only available as fastcall function, so it may only be
6540 used in presence of a prototype.
6542 <tag/Availability/C128 and enhanced Apple //e
6544 <ref id="fast" name="fast">,
6545 <ref id="slow" name="slow">,
6546 <ref id="toggle_videomode" name="toggle_videomode">
6552 <sect1>wherex<label id="wherex"><p>
6556 <tag/Function/Return the current X position of the text mode cursor.
6557 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
6558 <tag/Declaration/<tt/unsigned char wherex (void);/
6559 <tag/Description/The function returns the current X position of the text mode
6560 cursor. Zero is returned for the leftmost screen position.
6561 <tag/Availability/cc65
6563 <ref id="gotox" name="gotox">,
6564 <ref id="gotoy" name="gotoy">,
6565 <ref id="gotoxy" name="gotoxy">,
6566 <ref id="wherey" name="wherey">
6572 <sect1>wherey<label id="wherey"><p>
6576 <tag/Function/Return the current Y position of the text mode cursor.
6577 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
6578 <tag/Declaration/<tt/unsigned char wherey (void);/
6579 <tag/Description/The function returns the current Y position of the text mode
6580 cursor. Zero is returned for the uppermost screen position.
6581 <tag/Availability/cc65
6583 <ref id="gotox" name="gotox">,
6584 <ref id="gotoy" name="gotoy">,
6585 <ref id="gotoxy" name="gotoxy">,
6586 <ref id="wherex" name="wherex">