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>
118 <sect1><tt/c128.h/<label id="c128.h"><p>
121 <item><ref id="c64mode" name="c64mode">
122 <item><ref id="fast" name="fast">
123 <item><ref id="slow" name="slow">
124 <item><ref id="toggle_videomode" name="toggle_videomode">
125 <item><ref id="videomode" name="videomode">
129 <sect1><tt/c16.h/<label id="c16.h"><p>
134 <sect1><tt/c64.h/<label id="c64.h"><p>
137 <item><ref id="get_ostype" name="get_ostype">
141 <sect1><tt/cbm510.h/<label id="cbm510.h"><p>
144 <item><ref id="peekbsys" name="peekbsys">
145 <item><ref id="peekwsys" name="peekwsys">
146 <item><ref id="pokebsys" name="pokebsys">
147 <item><ref id="pokewsys" name="pokewsys">
151 <sect1><tt/cbm610.h/<label id="cbm610.h"><p>
154 <item><ref id="peekbsys" name="peekbsys">
155 <item><ref id="peekwsys" name="peekwsys">
156 <item><ref id="pokebsys" name="pokebsys">
157 <item><ref id="pokewsys" name="pokewsys">
161 <sect1><tt/cc65.h/<label id="cc65.h"><p>
164 <!-- <item><ref id="cc65_cos" name="cc65_cos"> -->
165 <!-- <item><ref id="cc65_idiv32by16r16" name="cc65_idiv32by16r16"> -->
166 <!-- <item><ref id="cc65_imul16x16r32" name="cc65_imul16x16r32"> -->
167 <!-- <item><ref id="cc65_imul8x8r16" name="cc65_imul8x8r16"> -->
168 <!-- <item><ref id="cc65_sin" name="cc65_sin"> -->
169 <!-- <item><ref id="cc65_udiv32by16r16" name="cc65_udiv32by16r16"> -->
170 <!-- <item><ref id="cc65_umul16x16r32" name="cc65_umul16x16r32"> -->
171 <!-- <item><ref id="cc65_umul16x8r32" name="cc65_umul16x8r32"> -->
172 <!-- <item><ref id="cc65_umul8x8r16" name="cc65_umul8x8r16"> -->
178 <sect1><tt/conio.h/<label id="conio.h"><p>
181 <item><ref id="bgcolor" name="bgcolor">
182 <item><ref id="bordercolor" name="bordercolor">
183 <item><ref id="cclear" name="cclear">
184 <item><ref id="cclearxy" name="cclearxy">
185 <item><ref id="cgetc" name="cgetc">
186 <item><ref id="chline" name="chline">
187 <item><ref id="chlinexy" name="chlinexy">
188 <item><ref id="clrscr" name="clrscr">
189 <item><ref id="cprintf" name="cprintf">
190 <item><ref id="cputc" name="cputc">
191 <item><ref id="cputcxy" name="cputcxy">
192 <item><ref id="cputs" name="cputs">
193 <item><ref id="cputsxy" name="cputsxy">
194 <item><ref id="cursor" name="cursor">
195 <item><ref id="cvline" name="cvline">
196 <item><ref id="cvlinexy" name="cvlinexy">
197 <item><ref id="gotox" name="gotox">
198 <item><ref id="gotoxy" name="gotoxy">
199 <item><ref id="gotoy" name="gotoy">
200 <item><ref id="kbhit" name="kbhit">
201 <item><ref id="revers" name="revers">
202 <item><ref id="screensize" name="screensize">
203 <item><ref id="textcolor" name="textcolor">
204 <item><ref id="vcprintf" name="vcprintf">
205 <item><ref id="wherex" name="wherex">
206 <item><ref id="wherey" name="wherey">
210 <sect1><tt/ctype.h/<label id="ctype.h"><p>
213 <item><ref id="isalnum" name="isalnum">
214 <item><ref id="isalpha" name="isalpha">
215 <item><ref id="isascii" name="isascii">
216 <item><ref id="isblank" name="isblank">
217 <item><ref id="iscntrl" name="iscntrl">
218 <item><ref id="isdigit" name="isdigit">
219 <item><ref id="isgraph" name="isgraph">
220 <item><ref id="islower" name="islower">
221 <item><ref id="isprint" name="isprint">
222 <item><ref id="ispunct" name="ispunct">
223 <item><ref id="isspace" name="isspace">
224 <item><ref id="isupper" name="isupper">
225 <item><ref id="isxdigit" name="isxdigit">
226 <item><ref id="tolower" name="tolower">
227 <item><ref id="toupper" name="toupper">
231 <sect1><tt/dbg.h/<label id="dbg.h"><p>
234 <!-- <item><ref id="DbgInit" name="DbgInit"> -->
240 <sect1><tt/dio.h/<label id="dio.h"><p>
242 <htmlurl url="dio.html" name="dio.html">
243 Low-level disk I/O API.
246 <sect1><tt/em.h/<label id="em.h"><p>
249 <item><ref id="em_commit" name="em_commit">
250 <item><ref id="em_copyfrom" name="em_copyfrom">
251 <item><ref id="em_copyto" name="em_copyto">
252 <item><ref id="em_install" name="em_install">
253 <item><ref id="em_load_driver" name="em_load_driver">
254 <item><ref id="em_map" name="em_map">
255 <item><ref id="em_pagecount" name="em_pagecount">
256 <item><ref id="em_uninstall" name="em_uninstall">
257 <item><ref id="em_unload" name="em_unload">
258 <item><ref id="em_use" name="em_use">
262 <sect1><tt/errno.h/<label id="errno.h"><p>
265 <!-- <item><ref id="_directerrno" name="_directerrno"> -->
266 <!-- <item><ref id="_mappederrno" name="_mappederrno"> -->
267 <!-- <item><ref id="_osmaperrno" name="_osmaperrno"> -->
268 <!-- <item><ref id="_seterrno" name="_seterrno"> -->
274 <sect1><tt/fcntl.h/<label id="fcntl.h"><p>
277 <item><ref id="close" name="close">
278 <item><ref id="creat" name="creat">
279 <item><ref id="open" name="open">
283 <sect1><tt/geos.h/<label id="geos.h"><p>
288 <sect1><tt/joystick.h/<label id="joystick.h"><p>
291 <item><ref id="joy_count" name="joy_count">
292 <item><ref id="joy_install" name="joy_install">
293 <item><ref id="joy_load_driver" name="joy_load_driver">
294 <item><ref id="joy_read" name="joy_read">
295 <item><ref id="joy_uninstall" name="joy_uninstall">
296 <item><ref id="joy_unload" name="joy_unload">
300 <sect1><tt/locale.h/<label id="locale.h"><p>
303 <item><ref id="localeconv" name="localeconv">
304 <item><ref id="setlocale" name="setlocale">
308 <sect1><tt/lynx.h/<label id="lynx.h"><p>
311 <!-- <item><ref id="lynx_eeprom_erase" name="lynx_eeprom_erase"> -->
312 <!-- <item><ref id="lynx_eeprom_read" name="lynx_eeprom_read"> -->
313 <!-- <item><ref id="lynx_eeprom_write" name="lynx_eeprom_write"> -->
314 <!-- <item><ref id="lynx_eeread" name="lynx_eeread"> -->
315 <!-- <item><ref id="lynx_eewrite" name="lynx_eewrite"> -->
316 <!-- <item><ref id="lynx_exec" name="lynx_exec"> -->
317 <!-- <item><ref id="lynx_load" name="lynx_load"> -->
323 <sect1><tt/modload.h/<label id="modload.h"><p>
326 <item><ref id="mod_load" name="mod_load">
327 <item><ref id="mod_free" name="mod_free">
331 <sect1><tt/mouse.h/<label id="mouse.h"><p>
334 <item><ref id="mouse_buttons" name="mouse_buttons">
335 <item><ref id="mouse_getbox" name="mouse_getbox">
336 <item><ref id="mouse_geterrormsg" name="mouse_geterrormsg">
337 <item><ref id="mouse_hide" name="mouse_hide">
338 <item><ref id="mouse_info" name="mouse_info">
339 <item><ref id="mouse_install" name="mouse_install">
340 <item><ref id="mouse_ioctl" name="mouse_ioctl">
341 <item><ref id="mouse_load_driver" name="mouse_load_driver">
342 <item><ref id="mouse_move" name="mouse_move">
343 <item><ref id="mouse_pos" name="mouse_pos">
344 <item><ref id="mouse_setbox" name="mouse_setbox">
345 <item><ref id="mouse_show" name="mouse_show">
346 <item><ref id="mouse_uninstall" name="mouse_uninstall">
347 <item><ref id="mouse_unload" name="mouse_unload">
351 <sect1><tt/nes.h/<label id="nes.h"><p>
354 <!-- <item><ref id="get_tv" name="get_tv"> -->
355 <!-- <item><ref id="waitvblank" name="waitvblank"> -->
361 <sect1><tt/o65.h/<label id="o65.h"><p>
363 The <tt/o65.h/ header file contains structure and constant definitions that
364 may be used when dealing with files in <htmlurl
365 url="http://www.6502.org/users/andre/o65/fileformat.html" name="o65 format">.
366 It does not declare any functions.
369 <sect1><tt/peekpoke.h/<label id="peekpoke.h"><p>
372 <item><ref id="PEEK" name="PEEK">
373 <item><ref id="PEEKW" name="PEEKW">
374 <item><ref id="POKE" name="POKE">
375 <item><ref id="POKEW" name="POKEW">
379 <sect1><tt/pet.h/<label id="pet.h"><p>
384 <sect1><tt/plus4.h/<label id="plus4.h"><p>
389 <sect1><tt/serial.h/<label id="serial.h"><p>
391 The <tt/serial.h/ header file contains definitions for initializing serial
395 <item><ref id="ser_close" name="ser_close">
396 <item><ref id="ser_get" name="ser_get">
397 <item><ref id="ser_install" name="ser_install">
398 <item><ref id="ser_ioctl" name="ser_ioctl">
399 <item><ref id="ser_load_driver" name="ser_load_driver">
400 <item><ref id="ser_open" name="ser_open">
401 <item><ref id="ser_put" name="ser_put">
402 <item><ref id="ser_status" name="ser_status">
403 <item><ref id="ser_uninstall" name="ser_uninstall">
404 <item><ref id="ser_unload" name="ser_unload">
408 <sect1><tt/setjmp.h/<label id="setjmp.h"><p>
411 <item><ref id="setjmp" name="setjmp">
412 <item><ref id="longjmp" name="longjmp">
416 <sect1><tt/signal.h/<label id="signal.h"><p>
419 <item><ref id="raise" name="raise">
420 <item><ref id="signal" name="signal">
424 <sect1><tt/stdarg.h/<label id="stdarg.h"><p>
429 <sect1><tt/stdbool.h/<label id="stdbool.h"><p>
434 <sect1><tt/stddef.h/<label id="stddef.h"><p>
437 <item><ref id="offsetof" name="offsetof">
441 <sect1><tt/stdio.h/<label id="stdio.h"><p>
444 <item><ref id="_poserror" name="_poserror">
445 <item><ref id="clearerr" name="clearerr">
446 <!-- <item><ref id="fclose" name="fclose"> -->
447 <!-- <item><ref id="fdopen" name="fdopen"> -->
448 <item><ref id="feof" name="feof">
449 <item><ref id="ferror" name="ferror">
450 <!-- <item><ref id="fflush" name="fflush"> -->
451 <!-- <item><ref id="fgetc" name="fgetc"> -->
452 <!-- <item><ref id="fgetpos" name="fgetpos"> -->
453 <!-- <item><ref id="fgets" name="fgets"> -->
454 <item><ref id="fileno" name="fileno">
455 <!-- <item><ref id="fopen" name="fopen"> -->
456 <!-- <item><ref id="fprintf" name="fprintf"> -->
457 <!-- <item><ref id="fputc" name="fputc"> -->
458 <!-- <item><ref id="fputs" name="fputs"> -->
459 <!-- <item><ref id="fread" name="fread"> -->
460 <!-- <item><ref id="freopen" name="freopen"> -->
461 <!-- <item><ref id="fscanf" name="fscanf"> -->
462 <!-- <item><ref id="fseek" name="fseek"> -->
463 <!-- <item><ref id="fsetpos" name="fsetpos"> -->
464 <!-- <item><ref id="ftell" name="ftell"> -->
465 <!-- <item><ref id="fwrite" name="fwrite"> -->
466 <!-- <item><ref id="getc" name="getc"> -->
467 <!-- <item><ref id="getchar" name="getchar"> -->
468 <!-- <item><ref id="gets" name="gets"> -->
469 <!-- <item><ref id="printf" name="printf"> -->
470 <!-- <item><ref id="putc" name="putc"> -->
471 <!-- <item><ref id="putchar" name="putchar"> -->
472 <!-- <item><ref id="puts" name="puts"> -->
473 <item><ref id="rename" name="rename">
474 <item><ref id="remove" name="remove">
475 <!-- <item><ref id="rewind" name="rewind"> -->
476 <!-- <item><ref id="scanf" name="scanf"> -->
477 <!-- <item><ref id="snprintf" name="snprintf"> -->
478 <!-- <item><ref id="sprintf" name="sprintf"> -->
479 <!-- <item><ref id="sscanf" name="sscanf"> -->
480 <!-- <item><ref id="vfprintf" name="vfprintf"> -->
481 <!-- <item><ref id="vfscanf" name="vfscanf"> -->
482 <!-- <item><ref id="vprintf" name="vprintf"> -->
483 <!-- <item><ref id="vscanf" name="vscanf"> -->
484 <!-- <item><ref id="vsnprintf" name="vsnprintf"> -->
485 <!-- <item><ref id="vsprintf" name="vsprintf"> -->
486 <!-- <item><ref id="vsscanf" name="vsscanf"> -->
492 <sect1><tt/stdlib.h/<label id="stdlib.h"><p>
495 <item><ref id="_heapadd" name="_heapadd">
496 <item><ref id="_heapblocksize" name="_heapblocksize">
497 <item><ref id="_heapmaxavail" name="_heapmaxavail">
498 <item><ref id="_heapmemavail" name="_heapmemavail">
499 <item><ref id="_randomize" name="_randomize">
500 <item><ref id="_swap" name="_swap">
501 <item><ref id="abort" name="abort">
502 <item><ref id="abs" name="abs">
503 <item><ref id="atexit" name="atexit">
504 <item><ref id="atoi" name="atoi">
505 <item><ref id="atol" name="atol">
506 <item><ref id="bsearch" name="bsearch">
507 <item><ref id="calloc" name="calloc">
508 <item><ref id="div" name="div">
509 <item><ref id="exit" name="exit">
510 <item><ref id="free" name="free">
511 <item><ref id="getenv" name="getenv">
512 <item><ref id="itoa" name="itoa">
513 <item><ref id="labs" name="labs">
514 <item><ref id="ltoa" name="ltoa">
515 <item><ref id="malloc" name="malloc">
516 <item><ref id="perror" name="perror">
517 <!-- <item><ref id="posix_memalign" name="posix_memalign"> -->
518 <!-- <item><ref id="putenv" name="putenv"> -->
519 <item><ref id="qsort" name="qsort">
520 <item><ref id="rand" name="rand">
521 <item><ref id="realloc" name="realloc">
522 <item><ref id="srand" name="srand">
523 <!-- <item><ref id="system" name="system"> -->
524 <item><ref id="ultoa" name="ultoa">
525 <item><ref id="utoa" name="utoa">
531 <sect1><tt/string.h/<label id="string.h"><p>
534 <item><ref id="_stroserror" name="_stroserror">
535 <item><ref id="bzero" name="bzero">
536 <item><ref id="memchr" name="memchr">
537 <item><ref id="memcmp" name="memcmp">
538 <item><ref id="memcpy" name="memcpy">
539 <item><ref id="memmove" name="memmove">
540 <item><ref id="memset" name="memset">
541 <item><ref id="strcasecmp" name="strcasecmp">
542 <item><ref id="strcat" name="strcat">
543 <item><ref id="strchr" name="strchr">
544 <item><ref id="strcmp" name="strcmp">
545 <item><ref id="strcoll" name="strcoll">
546 <item><ref id="strcpy" name="strcpy">
547 <item><ref id="strcspn" name="strcspn">
548 <item><ref id="strdup" name="strdup">
549 <item><ref id="strerror" name="strerror">
550 <item><ref id="stricmp" name="stricmp">
551 <item><ref id="strlen" name="strlen">
552 <item><ref id="strlower" name="strlower">
553 <item><ref id="strlwr" name="strlwr">
554 <item><ref id="strncat" name="strncat">
555 <item><ref id="strncmp" name="strncmp">
556 <item><ref id="strncpy" name="strncpy">
557 <item><ref id="strrchr" name="strrchr">
558 <item><ref id="strspn" name="strspn">
559 <item><ref id="strstr" name="strstr">
560 <item><ref id="strtok" name="strtok">
561 <item><ref id="strxfrm" name="strxfrm">
562 <item><ref id="strupper" name="strupper">
563 <item><ref id="strupr" name="strupr">
569 <sect1><tt/tgi.h/<label id="tgi.h"><p>
572 <item><ref id="tgi_arc" name="tgi_arc">
573 <item><ref id="tgi_bar" name="tgi_bar">
574 <item><ref id="tgi_circle" name="tgi_circle">
575 <item><ref id="tgi_clear" name="tgi_clear">
576 <item><ref id="tgi_done" name="tgi_done">
577 <item><ref id="tgi_ellipse" name="tgi_ellipse">
578 <item><ref id="tgi_getaspectratio" name="tgi_getaspectratio">
579 <item><ref id="tgi_getcolor" name="tgi_getcolor">
580 <item><ref id="tgi_getcolorcount" name="tgi_getcolorcount">
581 <item><ref id="tgi_getdefpalette" name="tgi_getdefpalette">
582 <item><ref id="tgi_geterror" name="tgi_geterror">
583 <item><ref id="tgi_geterrormsg" name="tgi_geterrormsg">
584 <item><ref id="tgi_getmaxcolor" name="tgi_getmaxcolor">
585 <item><ref id="tgi_getmaxx" name="tgi_getmaxx">
586 <item><ref id="tgi_getmaxy" name="tgi_getmaxy">
587 <item><ref id="tgi_getpagecount" name="tgi_getpagecount">
588 <item><ref id="tgi_getpalette" name="tgi_getpalette">
589 <item><ref id="tgi_getpixel" name="tgi_getpixel">
590 <item><ref id="tgi_getxres" name="tgi_getxres">
591 <item><ref id="tgi_getyres" name="tgi_getyres">
592 <item><ref id="tgi_gotoxy" name="tgi_gotoxy">
593 <item><ref id="tgi_init" name="tgi_init">
594 <item><ref id="tgi_install" name="tgi_install">
595 <item><ref id="tgi_ioctl" name="tgi_ioctl">
596 <item><ref id="tgi_line" name="tgi_line">
597 <item><ref id="tgi_lineto" name="tgi_lineto">
598 <item><ref id="tgi_load_driver" name="tgi_load_driver">
599 <item><ref id="tgi_outtext" name="tgi_outtext">
600 <item><ref id="tgi_outtextxy" name="tgi_outtextxy">
601 <item><ref id="tgi_setaspectratio" name="tgi_setaspectratio">
602 <item><ref id="tgi_setcolor" name="tgi_setcolor">
603 <item><ref id="tgi_setdrawpage" name="tgi_setdrawpage">
604 <item><ref id="tgi_setpalette" name="tgi_setpalette">
605 <item><ref id="tgi_setpixel" name="tgi_setpixel">
606 <item><ref id="tgi_setviewpage" name="tgi_setviewpage">
607 <item><ref id="tgi_gettextheight" name="tgi_gettextheight">
608 <item><ref id="tgi_settextstyle" name="tgi_settextstyle">
609 <item><ref id="tgi_gettextwidth" name="tgi_gettextwidth">
610 <item><ref id="tgi_uninstall" name="tgi_uninstall">
611 <item><ref id="tgi_unload" name="tgi_unload">
614 <sect1><tt/time.h/<label id="time.h"><p>
617 <!-- <item><ref id="_systime" name="_systime"> -->
618 <!-- <item><ref id="asctime" name="asctime"> -->
619 <!-- <item><ref id="clock" name="clock"> -->
620 <!-- <item><ref id="ctime" name="ctime"> -->
621 <!-- <item><ref id="gmtime" name="gmtime"> -->
622 <!-- <item><ref id="localtime" name="localtime"> -->
623 <!-- <item><ref id="mktime" name="mktime"> -->
624 <!-- <item><ref id="strftime" name="strftime"> -->
625 <item><ref id="time" name="time">
631 <sect1><tt/unistd.h/<label id="unistd.h"><p>
634 <!-- <item><ref id="chdir" name="chdir"> -->
635 <item><ref id="exec" name="exec">
636 <!-- <item><ref id="getcwd" name="getcwd"> -->
637 <item><ref id="getopt" name="getopt">
638 <!-- <item><ref id="lseek" name="lseek"> -->
639 <!-- <item><ref id="mkdir" name="mkdir"> -->
640 <!-- <item><ref id="read" name="read"> -->
641 <!-- <item><ref id="rmdir" name="rmdir"> -->
642 <item><ref id="sleep" name="sleep">
643 <item><ref id="unlink" name="unlink">
644 <!-- <item><ref id="write" name="write"> -->
650 <sect1><tt/vic20.h/<label id="vic20.h"><p>
655 <sect1><tt/zlib.h/<label id="zlib.h"><p>
658 <!-- <item><ref id="adler32" name="adler32"> -->
659 <!-- <item><ref id="crc32" name="crc32"> -->
660 <!-- <item><ref id="inflatemem" name="inflatemem"> -->
661 <!-- <item><ref id="uncompress" name="uncompress"> -->
667 <sect>Alphabetical function reference<p>
669 <sect1>_heapadd<label id="_heapadd"><p>
673 <tag/Function/Add a block to the heap.
674 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
675 <tag/Declaration/<tt/void __fastcall__ _heapadd (void* mem, size_t size);/
676 <tag/Description/The function adds a block of raw memory to the heap.
679 <item>The minimum blocksize that can be added is 6 bytes; the function will
680 ignore smaller blocks.
682 <tag/Availability/cc65
684 <ref id="_heapblocksize" name="_heapblocksize">,
685 <ref id="_heapmaxavail" name="_heapmaxavail">,
686 <ref id="_heapmemavail" name="_heapmemavail">,
687 <ref id="calloc" name="calloc">,
688 <ref id="free" name="free">,
689 <ref id="malloc" name="malloc">,
690 <ref id="realloc" name="realloc">
696 <sect1>_heapblocksize<label id="_heapblocksize"><p>
700 <tag/Function/Return the size of an allocated block.
701 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
702 <tag/Declaration/<tt/size_t __fastcall__ _heapblocksize (const void* block);/
703 <tag/Description/The function returns the size of a block that must have
704 previously been allocated by <tt/<ref id="malloc" name="malloc">/, <tt/<ref
705 id="calloc" name="calloc">/ or <tt/<ref id="realloc" name="realloc">/.
708 <item>Passing a pointer to a block that was is not the result of one of the
709 allocation functions, or that has been free'd will give unpredicable results.
711 <tag/Availability/cc65
713 <ref id="_heapadd" name="_heapadd">,
714 <ref id="_heapmaxavail" name="_heapmaxavail">,
715 <ref id="_heapmemavail" name="_heapmemavail">,
716 <ref id="calloc" name="calloc">,
717 <ref id="free" name="free">,
718 <ref id="malloc" name="malloc">,
719 <ref id="realloc" name="realloc">
725 <sect1>_heapmaxavail<label id="_heapmaxavail"><p>
729 <tag/Function/Return the largest block that is available on the heap.
730 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
731 <tag/Declaration/<tt/size_t __fastcall__ _heapmaxavail (void);/
732 <tag/Description/The function returns the size of the largest block that may
733 be allocated from the heap using <tt/<ref id="malloc" name="malloc">/.
734 <tag/Availability/cc65
736 <ref id="_heapadd" name="_heapadd">,
737 <ref id="_heapblocksize" name="_heapblocksize">,
738 <ref id="_heapmemavail" name="_heapmemavail">,
739 <ref id="calloc" name="calloc">,
740 <ref id="free" name="free">,
741 <ref id="malloc" name="malloc">,
742 <ref id="realloc" name="realloc">
748 <sect1>_heapmemavail<label id="_heapmemavail"><p>
752 <tag/Function/Return the total available space on the heap.
753 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
754 <tag/Declaration/<tt/size_t __fastcall__ _heapmemavail (void);/
755 <tag/Description/The function returns the total number of bytes available on
759 <item>This function is of less use than usually assumed, since the returned
760 heap space may be available but not in one block. So even if this function
761 says that several times more heap space is available than needed, <ref
762 id="malloc" name="malloc"> may still return <tt/NULL/.
764 <tag/Availability/cc65
766 <ref id="_heapadd" name="_heapadd">,
767 <ref id="_heapblocksize" name="_heapblocksize">,
768 <ref id="_heapmaxavail" name="_heapmaxavail">,
769 <ref id="calloc" name="calloc">,
770 <ref id="free" name="free">,
771 <ref id="malloc" name="malloc">,
772 <ref id="realloc" name="realloc">
778 <sect1>_poserror<label id="_poserror"><p>
782 <tag/Function/Print an error message for the error in <tt/_oserror/.
783 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
784 <tag/Declaration/<tt/void __fastcall__ _poserror (const char* msg);/
785 <tag/Description/<tt/_poserror/ prints an error message to <tt/stderr/. If
786 <tt/msg/ is not <tt/NULL/ and not an empty string, it is printed followed by
787 a colon and a blank. Then the error message for the current contents of
788 <tt/_oserror/ are printed followed by a newline. The message output is the
789 same as returned by <tt/<ref id="_stroserror" name="_stroserror">/ with an
790 argument of <tt/_oserror/.
793 <item>Since operating system specific error code are - you guessed it -
794 operating system specific, the value in <tt/_oserror/ and the message that is
795 printed depends on the cc65 target.
796 <item>The function is only available as fastcall function, so it may only
797 be used in presence of a prototype.
799 <tag/Availability/cc65
801 <ref id="_stroserror" name="_stroserror">,
802 <ref id="perror" name="perror">
808 <sect1>_randomize<label id="_randomize"><p>
812 <tag/Function/Initialize the pseudo random number generator.
813 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
814 <tag/Declaration/<tt/void _randomize (void);/
815 <tag/Description/The function initializes the random number generator with
816 a seed derived from fast changing hardware events, so the seed itself can be
817 considered random to a certain degree.
818 <tag/Limits/<itemize>
819 <item>The randomness of the seed depends on the machine hardware.
821 <tag/Availability/cc65
823 <ref id="rand" name="rand">,
824 <ref id="srand" name="srand">
830 <sect1>_stroserror<label id="_stroserror"><p>
834 <tag/Function/Return a string describing an OS specific error code.
835 <tag/Header/<tt/<ref id="string.h" name="string.h">/
836 <tag/Declaration/<tt/const char* __fastcall__ _stroserror (unsigned char errcode);/
837 <tag/Description/<tt/_stroserror/ will return a string describing the given
838 operating system specific error code.
839 <tag/Limits/<itemize>
840 <item>Since operating system specific error code are - you guessed it -
841 operating system specific, the parameter and the string returned depend on the
843 <item>The function is only available as fastcall function, so it may only be
844 used in presence of a prototype.
846 <tag/Availability/cc65
848 <ref id="strerror" name="strerror">
854 <sect1>_swap<label id="_swap"><p>
858 <tag/Function/Swap the contents of memory areas.
859 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
860 <tag/Declaration/<tt/void __fastcall__ _swap (void* p, void* q, size_t size);/
861 <tag/Description/<tt/_swap/ will swap (exchange) the contents of the two memory
862 areas pointed to by <tt/p/ and <tt/q/. Both memory areas are assumed to be
863 <tt/size/ bytes in size.
864 <tag/Limits/<itemize>
865 <item>The memory areas may not overlap, otherwise the results are undefined.
866 <item>The function is only available as fastcall function, so it may only be
867 used in presence of a prototype.
869 <tag/Availability/cc65
871 <ref id="memcpy" name="memcpy">,
872 <ref id="memmove" name="memmove">
878 <sect1>_sys<label id="_sys"><p>
882 <tag/Function/Call a subroutine passing register values.
883 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
884 <tag/Declaration/<tt/void __fastcall__ _sys (struct regs* r);/
885 <tag/Description/The function will call the subroutine at the address
886 specified in the <tt/pc/ member of the passed <tt/regs/ structure. All
887 registers and the CPU flags are set to the values given in the <tt/regs/
888 structure. On return from the subroutine, the new values of the registers and
889 flags are stored back overwriting the old values.
890 <tag/Limits/<itemize>
891 <item>Bits 4 and 5 of the flags value in the <tt/regs/ structure are ignored
892 when calling the subroutine (they are unchanged from their current values).
893 <item>The function is only available as fastcall function, so it may only be
894 used in presence of a prototype.
896 <tag/Availability/cc65
902 <sect1>BRK<label id="BRK"><p>
906 <tag/Function/Insert a 6502 BRK instrunction into the code.
907 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
908 <tag/Declaration/<tt/void BRK (void);/
909 <tag/Description/The function will insert a 6502 BRK instruction into the code
910 which may be used to trigger a debugger.
911 <tag/Limits/<itemize>
912 <item>The function is actually a macro.
913 <item>The inserted instruction may lead to unexpected results if no debugger
916 <tag/Availability/cc65
918 <ref id="CLI" name="CLI">,
919 <ref id="SEI" name="SEI">
925 <sect1>CLI<label id="CLI"><p>
929 <tag/Function/Insert a 6502 CLI instrunction into the code.
930 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
931 <tag/Declaration/<tt/void CLI (void);/
932 <tag/Description/The function will insert a 6502 CLI instruction into the code,
933 so interrupts are enabled. Enabling interrupts has no effects if they are
934 already enabled (the default).
935 <tag/Limits/<itemize>
936 <item>The function is actually a macro.
937 <item>Disabling interrupts may lead to unexpected results.
939 <tag/Availability/cc65
941 <ref id="BRK" name="BRK">,
942 <ref id="SEI" name="SEI">
948 <sect1>PEEK<label id="PEEK"><p>
952 <tag/Function/Read a byte from memory.
953 <tag/Header/<tt/<ref id="peekpoke.h" name="peekpoke.h">/
954 <tag/Declaration/<tt/unsigned char PEEK (unsigned addr);/
955 <tag/Description/The function will read the absolute memory given by <tt/addr/
956 and return the value read.
957 <tag/Limits/<itemize>
958 <item>The function is actually a macro.
959 <item>This function depends highly on the platform and environment.
961 <tag/Availability/cc65
963 <ref id="PEEKW" name="PEEKW">,
964 <ref id="POKE" name="POKE">
970 <sect1>PEEKW<label id="PEEKW"><p>
974 <tag/Function/Read a word (two bytes) from memory.
975 <tag/Header/<tt/<ref id="peekpoke.h" name="peekpoke.h">/
976 <tag/Declaration/<tt/unsigned PEEKW (unsigned addr);/
977 <tag/Description/The function will read the absolute memory given by <tt/addr/
978 and return the value read. The byte read from the higher address is the high
979 byte of the return value.
980 <tag/Limits/<itemize>
981 <item>The function is actually a macro.
982 <item>This function depends highly on the platform and environment.
983 <item>The order in which the two bytes are read is unspecified and may
984 depend of the address expression used.
986 <tag/Availability/cc65
988 <ref id="PEEK" name="PEEK">,
989 <ref id="POKE" name="POKE">
995 <sect1>POKE<label id="POKE"><p>
999 <tag/Function/Write a byte to memory.
1000 <tag/Header/<tt/<ref id="peekpoke.h" name="peekpoke.h">/
1001 <tag/Declaration/<tt/void POKE (unsigned addr, unsigned char val);/
1002 <tag/Description/The function writes the value <tt/val/ to the absolute
1003 memory address given by <tt/addr/.
1004 <tag/Limits/<itemize>
1005 <item>The function is actually a macro.
1006 <item>This function depends highly on the platform and environment.
1007 <item>Careless use will cause the program to act strange or may crash the
1010 <tag/Availability/cc65
1012 <ref id="PEEK" name="PEEK">,
1013 <ref id="POKEW" name="POKEW">
1019 <sect1>POKEW<label id="POKEW"><p>
1023 <tag/Function/Write a word (two bytes) to memory.
1024 <tag/Header/<tt/<ref id="peekpoke.h" name="peekpoke.h">/
1025 <tag/Declaration/<tt/void POKEW (unsigned addr, unsigned val);/
1026 <tag/Description/The function writes the value <tt/val/ to the absolute
1027 memory address given by <tt/addr/. The low byte of <tt/val/ is written to
1028 the <tt/addr/, the high byte is written to <tt/addr+1/.
1029 <tag/Limits/<itemize>
1030 <item>The function is actually a macro.
1031 <item>This function depends highly on the platform and environment.
1032 <item>Careless use will cause the program to act strange or may crash the
1034 <item>The order in which the two bytes are written is unspecified and may
1035 depend of the address expression used.
1037 <tag/Availability/cc65
1039 <ref id="PEEK" name="PEEK">,
1040 <ref id="POKE" name="POKE">
1046 <sect1>SEI<label id="SEI"><p>
1050 <tag/Function/Insert a 6502 SEI instrunction into the code.
1051 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
1052 <tag/Declaration/<tt/void SEI (void);/
1053 <tag/Description/The function will insert a 6502 SEI instruction into the code,
1054 so interrupts are disabled. Note that non maskable interrupts cannot be
1056 <tag/Limits/<itemize>
1057 <item>The function is actually a macro.
1058 <item>Disabling interrupts may lead to unexpected results.
1060 <tag/Availability/cc65
1062 <ref id="BRK" name="BRK">,
1063 <ref id="CLI" name="CLI">
1069 <sect1>abort<label id="abort"><p>
1073 <tag/Function/Terminates a program abnormally.
1074 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1075 <tag/Declaration/<tt/void abort (void);/
1076 <tag/Description/<tt/abort/ raises <tt/SIGABRT/, writes a termination message
1077 on stderr, then terminates the program with an exit code of 3.
1078 <tag/Availability/ISO 9899
1080 <ref id="assert" name="assert">,
1081 <ref id="exit" name="exit">,
1082 <ref id="raise" name="raise">
1088 <sect1>abs<label id="abs"><p>
1092 <tag/Function/Returns the absolute value of an integer.
1093 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1094 <tag/Declaration/<tt/int __fastcall__ abs (int v);/
1095 <tag/Description/<tt/abs/ returns the absolute value of the argument passed to
1097 <tag/Limits/<itemize>
1098 <item>The return value is undefined if <tt/INT_MIN/ is passed to the function.
1099 <item>The function is only available as fastcall function, so it may only be
1100 used in presence of a prototype.
1102 <tag/Availability/ISO 9899
1104 <ref id="labs" name="labs">
1110 <sect1>assert<label id="assert"><p>
1114 <tag/Function/Test a condition and possibly abort.
1115 <tag/Header/<tt/<ref id="assert.h" name="assert.h">/
1116 <tag/Declaration/<tt/void assert (int cond);/
1117 <tag/Description/<tt/assert/ is a macro that expands to a <tt/id/
1118 statement. If the condition evaluates t zero (false), assert prints a message
1119 on stderr and aborts the program.
1120 <tag/Limits/<itemize>
1121 <item>The function is actually a macro.
1123 <tag/Availability/ISO 9899
1125 <ref id="abort" name="abort">,
1126 <ref id="exit" name="exit">
1132 <sect1>atexit<label id="atexit"><p>
1136 <tag/Function/Register an exit function.
1137 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1138 <tag/Declaration/<tt/int __fastcall__ atexit (void (*exitfunc) (void));/
1139 <tag/Description/<tt/atexit/ registers the function pointed to by
1140 <tt/exitfunc/ as an exit function. Exit functions are called when the program
1141 terminates, they are called in LIFO order (the last function registered is
1142 called first). <tt/atexit/ returns zero on success and a nonzero value on
1144 <tag/Limits/<itemize>
1145 <item>A maximum of 5 exit functions can be registered.
1146 <item>There is no way to unregister an exit function.
1147 <item>The function is only available as fastcall function, so it may only be
1148 used in presence of a prototype.
1150 <tag/Availability/ISO 9899
1152 <ref id="abort" name="abort">,
1153 <ref id="exit" name="exit">
1159 <sect1>atoi<label id="atoi"><p>
1163 <tag/Function/Convert a string to an integer.
1164 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1165 <tag/Declaration/<tt/int __fastcall__ atoi (const char* s);/
1166 <tag/Description/<tt/atoi/ converts the given string into an integer.
1167 Conversion stops as soon as any invalid character is encountered.
1168 <tag/Limits/<itemize>
1169 <item>There is no way to detect any conversion errors.
1170 <item>The function does not check for an numerical overflow when converting.
1171 <item>The function is only available as fastcall function, so it may only be
1172 used in presence of a prototype.
1174 <tag/Availability/ISO 9899
1176 <ref id="atol" name="atol">,
1177 <ref id="itoa" name="itoa">,
1178 <ref id="ltoa" name="ltoa">,
1179 <ref id="ultoa" name="ultoa">,
1180 <ref id="utoa" name="utoa">
1186 <sect1>atol<label id="atol"><p>
1190 <tag/Function/Convert a string to a long integer.
1191 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1192 <tag/Declaration/<tt/long __fastcall__ atol (const char* s);/
1193 <tag/Description/<tt/atol/ converts the given string into a long integer.
1194 Conversion stops as soon as any invalid character is encountered.
1195 <tag/Limits/<itemize>
1196 <item>There is no way to detect any conversion errors.
1197 <item>The function does not check for an numerical overflow when converting.
1198 <item>The function is only available as fastcall function, so it may only be
1199 used in presence of a prototype.
1201 <tag/Availability/ISO 9899
1203 <ref id="atoi" name="atoi">,
1204 <ref id="itoa" name="itoa">,
1205 <ref id="ltoa" name="ltoa">,
1206 <ref id="ultoa" name="ultoa">,
1207 <ref id="utoa" name="utoa">
1213 <sect1>bgcolor<label id="bgcolor"><p>
1217 <tag/Function/Set the background text color.
1218 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1219 <tag/Declaration/<tt/unsigned char __fastcall__ bgcolor (unsigned char color);/
1220 <tag/Description/The function will set a new background color and return the
1221 old (current) one. The background color is valid for the whole text output
1222 area of the screen, not just for new text.
1223 <tag/Limits/<itemize>
1224 <item>Background colors are system dependent. The function may have no effect
1225 on systems where the background color cannot be changed.
1226 <item>The function is only available as fastcall function, so it may only be
1227 used in presence of a prototype.
1229 <tag/Availability/cc65
1231 <ref id="bordercolor" name="bordercolor">,
1232 <ref id="textcolor" name="textcolor">
1238 <sect1>bordercolor<label id="bordercolor"><p>
1242 <tag/Function/Set the border (frame) color.
1243 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1244 <tag/Declaration/<tt/unsigned char __fastcall__ bordercolor (unsigned char color);/
1245 <tag/Description/The function will set a new border color. It returns the old
1246 (current) border color.
1247 <tag/Limits/<itemize>
1248 <item>Border colors are system dependent. The function may have no effect
1249 on systems where the border color cannot be changed.
1250 <item>The function is only available as fastcall function, so it may only
1251 be used in presence of a prototype.
1253 <tag/Availability/cc65
1255 <ref id="bgcolor" name="bgcolor">,
1256 <ref id="textcolor" name="textcolor">
1262 <sect1>bsearch<label id="bsearch"><p>
1266 <tag/Function/Do a binary search in a sorted array.
1267 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1268 <tag/Declaration/<tt/void* __fastcall__ bsearch (const void* key,
1269 const void* base, size_t n, size_t size,
1270 int (*cmp) (const void*, const void*));/
1271 <tag/Description/<tt/bsearch/ searches a sorted array for a member that
1272 matches the one pointed to by <tt/key/. <tt/base/ is the address of the array,
1273 <tt/n/ is the number of elements, <tt/size/ the size of an element and <tt/cmp/
1274 the function used to compare the members against the key. The function returns
1275 a pointer to the member found, or <tt/NULL/ if there was no match.
1278 <item>The contents of the array must be sorted in ascending order according to
1279 the compare function given.
1280 <item>If there are multiple members that match the key, the function will
1281 return one of the members.
1282 <item>The function is only available as fastcall function, so it may only
1283 be used in presence of a prototype.
1285 <tag/Availability/ISO 9899
1287 <ref id="qsort" name="qsort">
1293 <sect1>bzero<label id="bzero"><p>
1297 <tag/Function/Fill a memory area with zeroes.
1298 <tag/Header/<tt/<ref id="string.h" name="string.h">/
1299 <tag/Declaration/<tt/void __fastcall__ bzero (void* p, size_t count);/
1300 <tag/Description/<tt/bzero/ fills the memory area pointed to by <tt/p/ with
1304 <item>The function is non standard and therefore only available in non ANSI
1305 mode. You should use <tt/<ref id="memset" name="memset">/ instead.
1306 <item>The function is only available as fastcall function, so it may only
1307 be used in presence of a prototype.
1309 <tag/Availability/cc65
1311 <ref id="_swap" name="_swap">,
1312 <ref id="memcpy" name="memcpy">,
1313 <ref id="memmove" name="memmove">,
1314 <ref id="memset" name="memset">,
1320 <sect1>c64mode<label id="c64mode"><p>
1324 <tag/Function/Switch the C128 into C64 compatible mode.
1325 <tag/Header/<tt/<ref id="c128.h" name="c128.h">/
1326 <tag/Declaration/<tt/void c64mode (void);/
1327 <tag/Description/The function will cause the machine to reboot into C64 mode.
1328 <tag/Limits/<itemize>
1329 <item>The function is specific to the C128.
1330 <item>The function will not return to the caller.
1332 <tag/Availability/C128
1338 <sect1>calloc<label id="calloc"><p>
1342 <tag/Function/Allocate and clear memory.
1343 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1344 <tag/Declaration/<tt/void* __fastcall__ calloc (size_t n, size_t size);/
1345 <tag/Description/<tt/calloc/ allocates memory for an array of <tt/n/ elements
1346 of size <tt/size/, clears the whole block with binary zeroes and returns a
1347 pointer to it. On error (not enough memory available), <tt/calloc/ returns
1351 <item>Clearing the memory may not have the expected effect on all platforms:
1352 pointers in the block may not be <tt/NULL/ and floating point variables may
1353 not be zero (0.0). In other words: The "clearing" effect of this function
1354 should be used with care for portable programs.
1355 <item>The function is only available as fastcall function, so it may only
1356 be used in presence of a prototype.
1358 <tag/Availability/ISO 9899
1360 <ref id="_heapadd" name="_heapadd">,
1361 <ref id="_heapblocksize" name="_heapblocksize">,
1362 <ref id="_heapmaxavail" name="_heapmaxavail">,
1363 <ref id="_heapmemavail" name="_heapmemavail">,
1364 <ref id="free" name="free">,
1365 <ref id="malloc" name="malloc">,
1366 <ref id="realloc" name="realloc">
1372 <sect1>cclear<label id="cclear"><p>
1376 <tag/Function/Clear part of a line (write a given number of spaces).
1377 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1378 <tag/Declaration/<tt/void __fastcall__ cclear (unsigned char length);/
1379 <tag/Description/The function clears part of a line by writing <tt/length/
1380 spaces in the current text color.
1381 <tag/Limits/<itemize>
1382 <item>The function is only available as fastcall function, so it may
1383 only be used in presence of a prototype.
1385 <tag/Availability/cc65
1387 <ref id="cclearxy" name="cclearxy">,
1388 <ref id="clrscr" name="clrscr">
1394 <sect1>cclearxy<label id="cclearxy"><p>
1398 <tag/Function/Clear part of a line (write a given number of spaces) starting
1399 at a specific screen position.
1400 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1401 <tag/Declaration/<tt/void __fastcall__ cclearxy (unsigned char x, unsigned char y, unsigned char length);/
1402 <tag/Description/The function moves the cursor to a specific position, and
1403 will then clear part of the line by writing <tt/length/ spaces in the current
1405 <tag/Limits/<itemize>
1406 <item>The function is only available as fastcall function, so it may
1407 only be used in presence of a prototype.
1409 <tag/Availability/cc65
1411 <ref id="cclear" name="cclear">,
1412 <ref id="clrscr" name="clrscr">
1418 <sect1>cgetc<label id="cgetc"><p>
1422 <tag/Function/Read a character from the keyboard.
1423 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1424 <tag/Declaration/<tt/char cgetc (void);/
1425 <tag/Description/The function reads a character from the keyboard. If there is
1426 no character available, <tt/cgetc/ waits until the user presses a key. If the
1427 cursor is enabled by use of the <tt/cursor/ function, a blinking cursor is
1428 displayed while waiting.
1429 <tag/Limits/<itemize>
1430 <item>If the system supports a keyboard buffer, <tt/cgetc/ will fetch a key
1431 from this buffer and wait only if the buffer is empty.
1433 <tag/Availability/cc65
1435 <ref id="cursor" name="cursor">,
1436 <ref id="kbhit" name="kbhit">
1442 <sect1>chline<label id="chline"><p>
1446 <tag/Function/Output a horizontal line in text mode.
1447 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1448 <tag/Declaration/<tt/void __fastcall__ chline (unsigned char length);/
1449 <tag/Description/The function outputs a horizontal line with the given length
1450 starting at the current cursor position.
1451 <tag/Limits/<itemize>
1452 <item>The character used to draw the horizontal line is system dependent.
1453 If available, a line drawing character is used. Drawing a line that is partially
1454 off screen leads to undefined behaviour.
1455 <item>The function is only available as fastcall function, so it may only be
1456 used in presence of a prototype.
1458 <tag/Availability/cc65
1460 <ref id="chlinexy" name="chlinexy">,
1461 <ref id="cvline" name="cvline">,
1462 <ref id="cvlinexy" name="cvlinexy">
1468 <sect1>chlinexy<label id="chlinexy"><p>
1472 <tag/Function/Output a horizontal line at a given position in text mode.
1473 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1474 <tag/Declaration/<tt/void __fastcall__ chlinexy (unsigned char x, unsigned char y, unsigned char length);/
1475 <tag/Description/The function outputs a horizontal line with the given length
1476 starting at a given position.
1477 <tag/Limits/<itemize>
1478 <item>The character used to draw the horizontal line is system dependent.
1479 If available, a line drawing character is used. Drawing a line that is partially
1480 off screen leads to undefined behaviour.
1481 <item>The function is only available as fastcall function, so it may only be
1482 used in presence of a prototype.
1484 <tag/Availability/cc65
1486 <ref id="chline" name="chline">,
1487 <ref id="cvline" name="cvline">,
1488 <ref id="cvlinexy" name="cvlinexy">
1494 <sect1>clearerr<label id="clearerr"><p>
1498 <tag/Function/Clear error and end-of-file status of a stream.
1499 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
1500 <tag/Declaration/<tt/void __fastcall__ clearerr (FILE* f);/
1501 <tag/Description/<tt/clearerr/ clears the error and end-of-file status
1502 indicators for the stream <tt/f/.
1503 <tag/Limits/<itemize>
1504 <item>The function is only available as fastcall function, so it may only be
1505 used in presence of a prototype.
1507 <tag/Availability/ISO 9899
1509 <ref id="feof" name="feof">,
1510 <ref id="ferror" name="ferror">
1516 <sect1>clrscr<label id="clrscr"><p>
1520 <tag/Function/Clear the text screen.
1521 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1522 <tag/Declaration/<tt/void clrscr (void);/
1523 <tag/Description/The function clears the text screen and moves the cursor to
1524 the upper left corner.
1525 <tag/Availability/cc65
1527 <ref id="cclear" name="cclear">,
1528 <ref id="cclearxy" name="cclearxy">
1534 <sect1>close<label id="close"><p>
1538 <tag/Function/Close a file descriptor.
1539 <tag/Header/<tt/<ref id="fcntl.h" name="fcntl.h">/
1540 <tag/Declaration/<tt/int __fastcall__ close (int fd);/
1541 <tag/Description/The function closes the given file descriptor. It returns zero
1542 on success and -1 on error. If an error occurs, the cause can be determined by
1543 reading the <tt/errno/ variable.
1544 <tag/Limits/<itemize>
1545 <item>The function is only available as fastcall function, so it may only
1546 be used in presence of a prototype.
1548 <tag/Availability/POSIX 1003.1
1550 <ref id="creat" name="creat">,
1551 <ref id="open" name="open">
1557 <sect1>creat<label id="creat"><p>
1561 <tag/Function/Create a file.
1562 <tag/Header/<tt/<ref id="fcntl.h" name="fcntl.h">/
1563 <tag/Declaration/<tt/int __fastcall__ creat (const char* name, unsigned mode);/
1564 <tag/Description/<tt/creat/ creates a new file and returns the file descriptor
1565 associated with it. On error, -1 is returned and an error code is stored in
1567 <tag/Limits/<itemize>
1568 <item><tt/creat/ is identical to calling <tt/<ref id="open" name="open">/ with
1569 <tt/flags/ equal to <tt/O_WRONLY | O_CREAT | O_TRUNC/.
1570 <item>The function is only available as fastcall function, so it may only
1571 be used in presence of a prototype.
1573 <tag/Availability/POSIX 1003.1
1575 <ref id="close" name="close">,
1576 <ref id="open" name="open">
1582 <sect1>cprintf<label id="cprintf"><p>
1586 <tag/Function/Formatted output to the console.
1587 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1588 <tag/Declaration/<tt/int cprintf (const char* format, ...);/
1589 <tag/Description/The arguments are converted to text where necessary and
1590 formatted according to the format string given. The resulting string is output
1591 to the console. <tt/cprintf/ supports the same format specifiers as
1592 <tt/printf/. <!-- <tt/<ref id="printf" name="printf">/. -->
1593 <tag/Limits/<itemize>
1594 <item>Like all other <tt/conio/ output functions, <tt/cprintf/ distinguishes
1595 between <tt/\r/ and <tt/\n/.
1597 <tag/Availability/cc65
1599 <ref id="cputc" name="cputc">,
1600 <ref id="cputcxy" name="cputcxy">,
1601 <ref id="cputs" name="cputs">,
1602 <ref id="cputsxy" name="cputsxy">,
1603 <ref id="vcprintf" name="vcprintf">
1609 <sect1>cputc<label id="cputc"><p>
1613 <tag/Function/Output a character directly to the console.
1614 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1615 <tag/Declaration/<tt/void __fastcall__ cputc (char c);/
1616 <tag/Description/Output one character to the console at the current cursor
1618 <tag/Limits/<itemize>
1619 <item>Like all other <tt/conio/ output functions, <tt/cputc/ distinguishes
1620 between <tt/\r/ and <tt/\n/.
1621 <item>The function is only available as fastcall function, so it may only
1622 be used in presence of a prototype.
1624 <tag/Availability/cc65
1626 <ref id="cprintf" name="cprintf">,
1627 <ref id="cputcxy" name="cputcxy">,
1628 <ref id="cputs" name="cputs">,
1629 <ref id="cputsxy" name="cputsxy">,
1630 <ref id="vcprintf" name="vcprintf">
1636 <sect1>cputcxy<label id="cputcxy"><p>
1640 <tag/Function/Output a character at a specific screen position.
1641 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1642 <tag/Declaration/<tt/void __fastcall__ cputcxy (unsigned char x, unsigned char y, char c);/
1643 <tag/Description/<tt/cputcxy/ moves the cursor to the given x/y position on
1644 the screen and outputs one character.
1645 <tag/Limits/<itemize>
1646 <item>Like all other <tt/conio/ output functions, <tt/cputcxy/ distinguishes
1647 between <tt/\r/ and <tt/\n/.
1648 <item>The function is only available as fastcall function, so it may only
1649 be used in presence of a prototype.
1651 <tag/Availability/cc65
1653 <ref id="cprintf" name="cprintf">,
1654 <ref id="cputc" name="cputc">,
1655 <ref id="cputs" name="cputs">,
1656 <ref id="cputsxy" name="cputsxy">,
1657 <ref id="vcprintf" name="vcprintf">
1663 <sect1>cputs<label id="cputs"><p>
1667 <tag/Function/Output a string directly to the console.
1668 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1669 <tag/Declaration/<tt/void __fastcall__ cputs (const char* s);/
1670 <tag/Description/The function outputs the given string on the console at the
1671 current cursor position.
1672 <tag/Limits/<itemize>
1673 <item>Like all other <tt/conio/ output functions, <tt/cputs/ distinguishes
1674 between <tt/\r/ and <tt/\n/.
1675 <item>The function is only available as fastcall function, so it may only
1676 be used in presence of a prototype.
1678 <tag/Availability/cc65
1680 <ref id="cprintf" name="cprintf">,
1681 <ref id="cputc" name="cputc">,
1682 <ref id="cputcxy" name="cputcxy">,
1683 <ref id="cputsxy" name="cputsxy">,
1684 <ref id="vcprintf" name="vcprintf">
1690 <sect1>cputsxy<label id="cputsxy"><p>
1694 <tag/Function/Output a string to the console at a given position.
1695 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1696 <tag/Declaration/<tt/void __fastcall__ cputsxy (unsigned char x, unsigned char y, const char* s);/
1697 <tag/Description/<tt/cputsxy/ moves the cursor to the given x/y position,
1698 and outputs the string <tt/s/.
1699 <tag/Limits/<itemize>
1700 <item>Like all other <tt/conio/ output functions, <tt/cputsxy/ distinguishes
1701 between <tt/\r/ and <tt/\n/.
1702 <item>The function is only available as fastcall function, so it may only
1703 be used in presence of a prototype.
1705 <tag/Availability/cc65
1707 <ref id="cprintf" name="cprintf">,
1708 <ref id="cputc" name="cputc">,
1709 <ref id="cputcxy" name="cputcxy">,
1710 <ref id="cputs" name="cputs">,
1711 <ref id="vcprintf" name="vcprintf">
1717 <sect1>cursor<label id="cursor"><p>
1721 <tag/Function/Enable/disable a blinking cursor when waiting for keyboard input.
1722 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1723 <tag/Declaration/<tt/unsigned char __fastcall__ cursor (unsigned char onoff);/
1724 <tag/Description/If the argument to the function is non zero, a blinking cursor
1725 will be enabled when the <tt/cgetc/ function waits for input from the keyboard.
1726 If the argument is zero, <tt/cgetc/ will wait without a blinking cursor.
1727 <tag/Limits/<itemize>
1728 <item>The function is only available as fastcall function, so it may only
1729 be used in presence of a prototype.
1731 <tag/Availability/cc65
1733 <ref id="cgetc" name="cgetc">,
1734 <ref id="kbhit" name="kbhit">
1740 <sect1>cvline<label id="cvline"><p>
1744 <tag/Function/Output a vertical line in text mode.
1745 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1746 <tag/Declaration/<tt/void __fastcall__ cvline (unsigned char length);/
1747 <tag/Description/The function outputs a vertical line with the given length
1748 starting at the current cursor position.
1749 <tag/Limits/<itemize>
1750 <item>The character used to draw the vertical line is system dependent.
1751 If available, a line drawing character is used. Drawing a line that is partially
1752 off screen leads to undefined behaviour.
1753 <item>The function is only available as fastcall function, so it may only be
1754 used in presence of a prototype.
1756 <tag/Availability/cc65
1758 <ref id="chline" name="chline">,
1759 <ref id="chlinexy" name="chlinexy">,
1760 <ref id="cvlinexy" name="cvlinexy">
1766 <sect1>cvlinexy<label id="cvlinexy"><p>
1770 <tag/Function/Output a vertical line at a given position in text mode.
1771 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1772 <tag/Declaration/<tt/void __fastcall__ cvlinexy (unsigned char x, unsigned char y, unsigned char length);/
1773 <tag/Description/The function outputs a vertical line with the given length
1774 starting at a given position.
1775 <tag/Limits/<itemize>
1776 <item>The character used to draw the vertical line is system dependent.
1777 If available, a line drawing character is used. Drawing a line that is partially
1778 off screen leads to undefined behaviour.
1779 <item>The function is only available as fastcall function, so it may only be
1780 used in presence of a prototype.
1782 <tag/Availability/cc65
1784 <ref id="chline" name="chline">,
1785 <ref id="chlinexy" name="chlinexy">,
1786 <ref id="cvline" name="cvline">
1792 <sect1>div<label id="div"><p>
1796 <tag/Function/Divide two ints and return quotient and remainder.
1797 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1798 <tag/Declaration/<tt/div_t __fastcall__ div (int numer, int denom);/
1799 <tag/Description/<tt/div/ divides <tt/numer/ by <tt/denom/ and returns the
1800 quotient and remainder in a <tt/div_t/ structure.
1803 <item>The function is only available as fastcall function, so it may only
1804 be used in presence of a prototype.
1806 <tag/Availability/ISO 9899
1814 <sect1>em_commit<label id="em_commit"><p>
1818 <tag/Function/Commit changes into extended memory.
1819 <tag/Header/<tt/<ref id="em.h" name="em.h">/
1820 <tag/Declaration/<tt/void __fastcall__ em_commit (void);/
1821 <tag/Description/Commit changes in the memory window to extended storage. If
1822 the contents of the memory window have been changed, these changes may be lost
1823 if <tt/<ref id="em_map" name="em_map">/, <tt/<ref id="em_use" name="em_use">/,
1824 <tt/<ref id="em_copyfrom" name="em_copyfrom">/ or <tt/<ref id="em_copyto"
1825 name="em_copyto">/ are called without calling <tt/em_commit/ first.
1826 <tag/Limits/<itemize>
1827 <item>Calling <tt/em_commit/ does not necessarily mean that changes to the
1828 memory window are discarded, it does just mean that the drivers is allowed
1830 <item>The function is only available as fastcall function, so it may only be
1831 used in presence of a prototype.
1832 <item>The function produces undefined results if no extended memory driver is
1835 <tag/Availability/cc65
1837 <ref id="em_load_driver" name="em_load_driver">,
1838 <ref id="em_map" name="em_map">,
1839 <ref id="em_use" name="em_use">
1845 <sect1>em_copyfrom<label id="em_copyfrom"><p>
1849 <tag/Function/Copy from extended into normal memory.
1850 <tag/Header/<tt/<ref id="em.h" name="em.h">/
1851 <tag/Declaration/<tt/void __fastcall__ em_copyfrom (const struct em_copy* copy_data);/
1852 <tag/Description/Copy data from extended memory into linear memory. Source and
1853 target addresses as well as the number of bytes to transfer are specified in
1854 the <tt/em_copy/ structure that is passed as a parameter.
1855 <tag/Limits/<itemize>
1856 <item>Calling <tt/em_copyfrom/ will invalidate the memory window, so if you
1857 made any changes to the data in the window, call <tt/<ref id="em_commit"
1858 name="em_commit">/ first, or the changes are lost.
1859 <item>The function is only available as fastcall function, so it may only be
1860 used in presence of a prototype.
1861 <item>The function produces undefined results if no extended memory driver is
1864 <tag/Availability/cc65
1866 <ref id="em_commit" name="em_commit">,
1867 <ref id="em_copyto" name="em_copyto">,
1868 <ref id="em_load_driver" name="em_load_driver">
1874 <sect1>em_copyto<label id="em_copyto"><p>
1878 <tag/Function/Copy from normal into extended memory.
1879 <tag/Header/<tt/<ref id="em.h" name="em.h">/
1880 <tag/Declaration/<tt/void __fastcall__ em_copyto (const struct em_copy* copy_data);/
1881 <tag/Description/Copy data from linear into extended memory. Source and
1882 target addresses as well as the number of bytes to transfer are specified in
1883 the <tt/em_copy/ structure that is passed as a parameter.
1884 <tag/Limits/<itemize>
1885 <item>Calling <tt/em_copyto/ will invalidate the memory window, so if you
1886 made any changes to the data in the window, call <tt/<ref id="em_commit"
1887 name="em_commit">/ first, or the changes are lost.
1888 <item>The function is only available as fastcall function, so it may only be
1889 used in presence of a prototype.
1890 <item>The function produces undefined results if no extended memory driver is
1893 <tag/Availability/cc65
1895 <ref id="em_commit" name="em_commit">,
1896 <ref id="em_copyfrom" name="em_copyfrom">,
1897 <ref id="em_load_driver" name="em_load_driver">
1903 <sect1>em_install<label id="em_install"><p>
1907 <tag/Function/Install an already loaded extended memory driver.
1908 <tag/Header/<tt/<ref id="em.h" name="em.h">/
1909 <tag/Declaration/<tt/unsigned char _fastcall__ em_install (void* driver);/
1910 <tag/Description/The function installs an already loaded extended memory driver
1911 and returns an error code. The function may be used to install a driver linked
1912 statically to the program.
1913 <tag/Limits/<itemize>
1914 <item>Not all drivers are able to detect if the supported hardware is really
1916 <item>The function is only available as fastcall function, so it may only be
1917 used in presence of a prototype.
1919 <tag/Availability/cc65
1921 <ref id="em_load_driver" name="em_load_driver">,
1922 <ref id="em_uninstall" name="em_uninstall">,
1923 <ref id="em_unload" name="em_unload">
1929 <sect1>em_load_driver<label id="em_load_driver"><p>
1933 <tag/Function/Load and initialize an extended memory driver.
1934 <tag/Header/<tt/<ref id="em.h" name="em.h">/
1935 <tag/Declaration/<tt/void __fastcall__ em_load_driver (const char* name);/
1936 <tag/Description/Load an extended memory driver into memory and initialize
1937 it. The function returns an error code that tells if all this has been
1939 <tag/Limits/<itemize>
1940 <item>Not all drivers are able to detect if the supported hardware is really
1942 <item>The function is only available as fastcall function, so it may only be
1943 used in presence of a prototype.
1944 <item>The driver is loaded by name, so currently you must know the type of
1945 extended memory that should be supported. There is no autodetect capability.
1947 <tag/Availability/cc65
1949 <ref id="em_unload" name="em_unload">
1955 <sect1>em_map<label id="em_map"><p>
1959 <tag/Function/Make a page of extended memory accessible.
1960 <tag/Header/<tt/<ref id="em.h" name="em.h">/
1961 <tag/Declaration/<tt/void* __fastcall__ em_map (unsigned page);/
1962 <tag/Description/The function maps one page of extended memory into linear
1963 memory and returns a pointer to the page frame. Depending on the hardware
1964 and driver, the data is either mapped into the address space or transfered
1965 into a buffer. If you don't need the actual contents of the page (for example
1966 because you're going to overwrite it completely), it is better to call
1967 <tt/<ref id="em_use" name="em_use">/ instead. <tt/em_use/ will not transfer the
1968 data if it is possible to avoid that.
1969 <tag/Limits/<itemize>
1970 <item>Calling <tt/em_map/ will invalidate the memory window, so if you
1971 made any changes to the data in the window, call <tt/<ref id="em_commit"
1972 name="em_commit">/ first, or the changes are lost.
1973 <item>The function is only available as fastcall function, so it may only be
1974 used in presence of a prototype.
1975 <item>The function produces undefined results if no extended memory driver is
1978 <tag/Availability/cc65
1980 <ref id="em_commit" name="em_commit">,
1981 <ref id="em_load_driver" name="em_load_driver">,
1982 <ref id="em_use" name="em_use">
1988 <sect1>em_pagecount<label id="em_pagecount"><p>
1992 <tag/Function/Return the number of available extended memory pages.
1993 <tag/Header/<tt/<ref id="em.h" name="em.h">/
1994 <tag/Declaration/<tt/unsigned __fastcall__ em_pagecount (void);/
1995 <tag/Description/The function returns the size of the extended memory supported
1996 by the driver in 256 byte pages.
1997 <tag/Limits/<itemize>
1998 <item>The function returns zero if no extended memory driver is loaded.
1999 <item>The function may return zero if the supported hardware was not detected.
2001 <tag/Availability/cc65
2003 <ref id="em_load_driver" name="em_load_driver">
2009 <sect1>em_uninstall<label id="em_uninstall"><p>
2013 <tag/Function/Uninstall an already loaded extended memory driver.
2014 <tag/Header/<tt/<ref id="em.h" name="em.h">/
2015 <tag/Declaration/<tt/unsigned char __fastcall__ em_install (void);/
2016 <tag/Description/The function uninstalls an already loaded extended memory
2017 driver but doesn't remove it from memory.
2018 <tag/Limits/<itemize>
2019 <item>If the driver has been loaded using <tt/<ref id="em_load_driver"
2020 name="em_load_driver">/, <tt/<ref id="em_unload" name="em_unload">/
2021 should be used instead of <tt/em_uninstall/ so the driver is also removed
2023 <item>The function is only available as fastcall function, so it may only be
2024 used in presence of a prototype.
2026 <tag/Availability/cc65
2028 <ref id="em_install" name="em_install">,
2029 <ref id="em_load_driver" name="em_load_driver">,
2030 <ref id="em_unload" name="em_unload">
2036 <sect1>em_unload<label id="em_unload"><p>
2040 <tag/Function/Unload an extended memory driver.
2041 <tag/Header/<tt/<ref id="em.h" name="em.h">/
2042 <tag/Declaration/<tt/unsigned char __fastcall__ em_unload (void);/
2043 <tag/Description/The function unloads a loaded extended memory driver and
2044 frees all memory allocated for the driver.
2045 <tag/Limits/<itemize>
2046 <item>The function does nothing if no driver is loaded.
2048 <tag/Availability/cc65
2050 <ref id="em_load_driver" name="em_load_driver">
2056 <sect1>em_use<label id="em_use"><p>
2060 <tag/Function/Prepare an extended memory page for use.
2061 <tag/Header/<tt/<ref id="em.h" name="em.h">/
2062 <tag/Declaration/<tt/void* __fastcall__ em_use (unsigned page);/
2063 <tag/Description/The function maps one page of extended memory into linear
2064 memory and returns a pointer to the page frame. This function is similar to
2065 <tt/<ref id="em_map" name="em_map">/, but will not transfer data into the
2066 actual memory window in the assumption that the existing data is wrong or
2067 will get overwritten.
2068 <tag/Limits/<itemize>
2069 <item>Calling <tt/em_use/ will invalidate the memory window, so if you
2070 made any changes to the data in the window, call <tt/<ref id="em_commit"
2071 name="em_commit">/ first, or the changes are lost.
2072 <item>The function is only available as fastcall function, so it may only be
2073 used in presence of a prototype.
2074 <item>The function produces undefined results if no extended memory driver is
2077 <tag/Availability/cc65
2079 <ref id="em_commit" name="em_commit">,
2080 <ref id="em_load_driver" name="em_load_driver">,
2081 <ref id="em_map" name="em_map">
2087 <sect1>exit<label id="exit"><p>
2091 <tag/Function/Terminate the program.
2092 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
2093 <tag/Declaration/<tt/void __fastcall__ exit (int status);/
2094 <tag/Description/<tt/exit/ terminates the program. The argument specifies the
2095 return code of the program. Before termination, all files are closed, buffered
2096 output is written and any functions registered with <tt/<ref id="atexit"
2097 name="atexit">/ are called. Common values for status are <tt/EXIT_SUCCESS/ and
2098 <tt/EXIT_FAILURE/ which are also defined in <tt/<ref id="stdlib.h"
2100 <tag/Limits/<itemize>
2101 <item>The function is only available as fastcall function, so it may only
2102 be used in presence of a prototype.
2103 <item>It depends on the host machine if the program return code can be
2104 evaluated or is ignored.
2106 <tag/Availability/ISO 9899
2108 <ref id="abort" name="abort">,
2109 <ref id="exit" name="exit">
2115 <sect1>exec<label id="exec"><p>
2119 <tag/Function/Execute a program file.
2120 <tag/Header/<tt/<ref id="unistd.h" name="unistd.h">/
2121 <tag/Declaration/<tt/int __fastcall__ exec (const char* progname, const char* cmdline);/
2122 <tag/Description/<tt/exec/ replaces the currently running program by a new one.
2123 Calling <tt/exec()/ is identical to calling <tt/<ref id="exit" name="exit()">/,
2124 then loading and starting the program named in the first argument, passing
2125 the command line specified as second argument. Instead of an empty string,
2126 a <tt/NULL/ pointer may be passed as second parameter.
2127 On success, the function does not return. On failure, -1 is returned and
2128 <tt/errno/ contains an error code.
2129 <tag/Limits/<itemize>
2130 <item>The function is only available as fastcall function, so it may only
2131 be used in presence of a prototype.
2132 <item>On most platforms, the function needs to copy a small stub loader to
2133 some memory area outside the program space. This may collide with other
2134 programs. See the platform specific docs on this.
2135 <item>Because it is necessary to terminate the running program before the
2136 memory can be reused to load the new one, there is a high chance that the
2137 function may not be able to return on errors.
2138 <item>The command line is passed to the new program in the same way as cc65
2139 programs expect the command line. If the new program is not a cc65 generated
2140 program, it may not be able to read it.
2142 <tag/Availability/cc65
2144 <ref id="exit" name="exit">
2150 <sect1>fast<label id="fast"><p>
2154 <tag/Function/Switch the C128 into 2MHz mode.
2155 <tag/Header/<tt/<ref id="c128.h" name="c128.h">/
2156 <tag/Declaration/<tt/void fast (void);/
2157 <tag/Description/The function will switch the clock of the C128 to 2MHz. This
2158 will nearly double the speed compared to slow mode.
2159 <tag/Limits/<itemize>
2160 <item>The function is specific to the C128.
2161 <item>2MHz clock will not work in 40 column mode.
2163 <tag/Availability/C128
2165 <ref id="slow" name="slow">,
2166 <ref id="toggle_videomode" name="toggle_videomode">,
2167 <ref id="videomode" name="videomode">
2173 <sect1>feof<label id="feof"><p>
2177 <tag/Function/Return the end-of-file indicator of a stream.
2178 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
2179 <tag/Declaration/<tt/int __fastcall__ feof (FILE* f);/
2180 <tag/Description/<tt/feof/ tests the end-of-file indicator ofthe stream
2181 <tt/f/, and returns a non zero value if it is set.
2182 <tag/Limits/<itemize>
2183 <item>The indicator is set only after a read past the end of a file is
2185 <item>The function is only available as fastcall function, so it may only be
2186 used in presence of a prototype.
2188 <tag/Availability/ISO 9899
2190 <ref id="feof" name="clearerr">,
2191 <ref id="ferror" name="ferror">
2197 <sect1>ferror<label id="ferror"><p>
2201 <tag/Function/Return the error indicator of a stream.
2202 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
2203 <tag/Declaration/<tt/int __fastcall__ ferror (FILE* f);/
2204 <tag/Description/<tt/ferror/ tests the error indicator of the stream
2205 <tt/f/, and returns a non zero value if it is set.
2206 <tag/Limits/<itemize>
2207 <item>The function is only available as fastcall function, so it may only be
2208 used in presence of a prototype.
2210 <tag/Availability/ISO 9899
2212 <ref id="feof" name="clearerr">,
2213 <ref id="ferror" name="feof">
2219 <sect1>fileno<label id="fileno"><p>
2223 <tag/Function/Return the file handle used by a stream.
2224 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
2225 <tag/Declaration/<tt/int __fastcall__ fileno (FILE* f);/
2226 <tag/Description/The <tt/fileno/ function returns the file handle used
2227 internally by a C stream. This file handle (an integer) can be used as a
2228 handle for the POSIX input/output functions.
2229 <tag/Limits/<itemize>
2230 <item>The function is only available as fastcall function, so it may only be
2231 used in presence of a prototype.
2232 <item>Mixing C file I/O functions and POSIX file I/O functions for the same
2233 file may have unpredictable results.
2235 <tag/Availability/POSIX 1003.1
2237 <ref id="creat" name="creat">,
2238 <ref id="open" name="open"> <!-- , -->
2239 <!-- <ref id="read" name="read">, -->
2240 <!-- <ref id="write" name="write"> -->
2246 <sect1>free<label id="free"><p>
2250 <tag/Function/Free a block of dynamic memory.
2251 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
2252 <tag/Declaration/<tt/void __fastcall__ free (void* block);/
2253 <tag/Description/Free a block of dynamic memory previously allocated with
2254 <tt/<ref id="malloc" name="malloc">/, <tt/<ref id="calloc" name="calloc">/
2255 or <tt/<ref id="realloc" name="realloc">/. As an exception, if the passed
2256 pointer is <tt/NULL/, no action is performed.
2259 <item>Passing an already free'd block to <tt/free/ again will cause undefined
2260 behaviour and may crash your program.
2261 <item>The function is only available as fastcall function, so it may only
2262 be used in presence of a prototype.
2264 <tag/Availability/ISO 9899
2266 <ref id="_heapadd" name="_heapadd">,
2267 <ref id="_heapblocksize" name="_heapblocksize">,
2268 <ref id="_heapmaxavail" name="_heapmaxavail">,
2269 <ref id="_heapmemavail" name="_heapmemavail">,
2270 <ref id="calloc" name="calloc">,
2271 <ref id="malloc" name="malloc">,
2272 <ref id="realloc" name="realloc">
2278 <sect1>get_ostype<label id="get_ostype"><p>
2282 <tag/Function/The function returns the operating system, the program runs on.
2283 <tag/Header/<tt/<ref id="apple2.h" name="apple2.h">,
2284 <ref id="atari.h" name="atari.h">, <ref id="c64.h" name="c64.h">/
2285 <tag/Declaration/<tt/unsigned char get_ostype (void);/
2286 <tag/Description/<tt/get_ostype/ is machine dependent and does not exist for
2287 all supported targets. If it exists, it returns a number that identifies the
2288 operating system or machine type, the program runs on. The machine dependent
2289 header files define constants that can be used to check the return code.
2290 <tag/Limits/<itemize>
2291 <item>The function does not exist on all platforms.
2292 <item>The return codes are platform dependent.
2294 <tag/Availability/cc65 (not all platforms)
2300 <sect1>getcpu<label id="getcpu"><p>
2304 <tag/Function/Determine on which CPU the program is running.
2305 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
2306 <tag/Declaration/<tt/unsigned char getcpu (void);/
2307 <tag/Description/The function checks on which CPU the code is running. It
2308 returns one of the constants<itemize>
2310 <item><tt/CPU_65C02/
2311 <item><tt/CPU_65816/
2313 <tag/Limits/<itemize>
2314 <item>Other, more exotic CPU types are not disinguished.
2316 <tag/Availability/cc65
2322 <sect1>getenv<label id="getenv"><p>
2326 <tag/Function/Return a value from the environment.
2327 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
2328 <tag/Declaration/<tt/char* __fastcall__ getenv (const char* name);/
2329 <tag/Description/The function searches the environment for an entry that
2330 matches <tt/name/ and returns its value. The environment consists of a list
2331 of strings in the form <tt/name=value/. If there is no match, <tt/getenv/
2333 <tag/Limits/<itemize>
2334 <item>What exactly is stored in the environment depends on the machine the
2335 program is running on.
2336 <item>The function is only available as fastcall function, so it may only
2337 be used in presence of a prototype.
2339 <tag/Availability/ISO 9899
2345 <sect1>getopt<label id="getopt"><p>
2349 <tag/Function/Parse command line options.
2350 <tag/Header/<tt/<ref id="unistd.h" name="unistd.h">/
2351 <tag/Declaration/<tt/int __fastcall__ getopt (int argc, char* const* argv,
2352 const char* optstring);/
2353 <tag/Description/The function parses command line arguments, <tt/argc/ and
2354 <tt/argv/ are the argument count and array passed to <tt/main/. <tt/optstring/
2355 is a string that contains command line option characters. If a character in
2356 <tt/optstring/ is followed by a colon, the option requires an argument. An
2357 option on the command line is recognized if it is one of the option characters
2359 <tt/getopt/ must be called repeatedly. It will return each option character
2360 found on the command line and <tt/EOF/ (-1) if there is no other option. An
2361 option argument is placed in <tt/optarg/, the index of the next element on the
2362 command line to be processed is placed in <tt/optind/.
2363 <tag/Limits/<itemize>
2364 <item>The implementation will not reorder options. A non option on the command
2365 line will terminate option processing. All remaining arguments are not
2366 recognized as options, even if the start with a '-' character.
2367 <item>The function is only available as fastcall function, so it may only
2368 be used in presence of a prototype.
2370 <tag/Availability/POSIX.2
2376 <sect1>gotox<label id="gotox"><p>
2380 <tag/Function/Move the text mode cursor to a new X position.
2381 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2382 <tag/Declaration/<tt/void __fastcall__ gotox (unsigned char x);/
2383 <tag/Description/The function moves the text mode cursor to the specified X
2384 position while leaving the Y position untouched. The leftmost position on the
2385 screen has the coordinate 0.
2386 <tag/Limits/<itemize>
2387 <item>The function is only available as fastcall function, so it may
2388 only be used in presence of a prototype.
2389 <item>Invalid values for the X position (out of screen coordinates) may
2390 lead to undefined behaviour.
2392 <tag/Availability/cc65
2394 <ref id="gotoy" name="gotoy">,
2395 <ref id="gotoxy" name="gotoxy">,
2396 <ref id="wherex" name="wherex">,
2397 <ref id="wherey" name="wherey">
2403 <sect1>gotoxy<label id="gotoxy"><p>
2407 <tag/Function/Move the text mode cursor to a new position.
2408 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2409 <tag/Declaration/<tt/void __fastcall__ gotoxy (unsigned char x, unsigned char y);/
2410 <tag/Description/The function moves the text mode cursor to the specified
2411 position. The leftmost position on the screen has the X coordinate 0, the
2412 topmost line has the Y coordinate 0.
2413 <tag/Limits/<itemize>
2414 <item>The function is only available as fastcall function, so it may only be
2415 used in presence of a prototype.
2416 <item>Invalid values for any of both coordinates (out of screen positions) may
2417 lead to undefined behaviour.
2419 <tag/Availability/cc65
2421 <ref id="gotox" name="gotox">,
2422 <ref id="gotoy" name="gotoy">,
2423 <ref id="wherex" name="wherex">,
2424 <ref id="wherey" name="wherey">
2430 <sect1>gotoy<label id="gotoy"><p>
2434 <tag/Function/Move the text mode cursor to a new Y position.
2435 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2436 <tag/Declaration/<tt/void __fastcall__ gotoy (unsigned char x);/
2437 <tag/Description/The function moves the text mode cursor to the specified Y
2438 position while leaving the X position untouched. The uppermost position on the
2439 screen has the coordinate 0.
2440 <tag/Limits/<itemize>
2441 <item>The function is only available as fastcall function, so it may
2442 only be used in presence of a prototype.
2443 <item>Invalid values for the Y position (out of screen coordinates) may lead
2444 to undefined behaviour.
2446 <tag/Availability/cc65
2448 <ref id="gotox" name="gotox">,
2449 <ref id="gotoxy" name="gotoxy">,
2450 <ref id="wherex" name="wherex">,
2451 <ref id="wherey" name="wherey">
2457 <sect1>isalnum<label id="isalnum"><p>
2461 <tag/Function/Check if a given character is a letter or digit.
2462 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2463 <tag/Declaration/<tt/int __fastcall__ isalnum (int c);/
2464 <tag/Description/The function returns a non zero value if the given argument
2465 is a letter or digit. The return value is zero if the character is anything
2467 <tag/Limits/<itemize>
2468 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2469 inline sequence generated by the macro will not work correctly for values
2470 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2471 this range. The non inline function may be accessed by <tt/#undef/'ing
2473 <item>When compiling without <tt/-Os/, the function is only available as
2474 fastcall function, so it may only be used in presence of a prototype.
2476 <tag/Availability/ISO 9899
2478 <ref id="isalpha" name="isalpha">,
2479 <ref id="isascii" name="isascii">,
2480 <ref id="isblank" name="isblank">,
2481 <ref id="iscntrl" name="iscntrl">,
2482 <ref id="isdigit" name="isdigit">,
2483 <ref id="isgraph" name="isgraph">,
2484 <ref id="islower" name="islower">,
2485 <ref id="isprint" name="isprint">,
2486 <ref id="ispunct" name="ispunct">,
2487 <ref id="isspace" name="isspace">,
2488 <ref id="isupper" name="isupper">,
2489 <ref id="isxdigit" name="isxdigit">
2495 <sect1>isalpha<label id="isalpha"><p>
2499 <tag/Function/Check if a given character is a letter.
2500 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2501 <tag/Declaration/<tt/int __fastcall__ isalpha (int c);/
2502 <tag/Description/The function returns a non zero value if the given argument
2503 is a letter. The return value is zero if the character is anything else.
2504 <tag/Limits/<itemize>
2505 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2506 inline sequence generated by the macro will not work correctly for values
2507 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2508 this range. The non inline function may be accessed by <tt/#undef/'ing the
2510 <item>When compiling without <tt/-Os/, the function is only available as
2511 fastcall function, so it may only be used in presence of a prototype.
2513 <tag/Availability/ISO 9899
2515 <ref id="isalnum" name="isalnum">,
2516 <ref id="isascii" name="isascii">,
2517 <ref id="isblank" name="isblank">,
2518 <ref id="iscntrl" name="iscntrl">,
2519 <ref id="isdigit" name="isdigit">,
2520 <ref id="isgraph" name="isgraph">,
2521 <ref id="islower" name="islower">,
2522 <ref id="isprint" name="isprint">,
2523 <ref id="ispunct" name="ispunct">,
2524 <ref id="isspace" name="isspace">,
2525 <ref id="isupper" name="isupper">,
2526 <ref id="isxdigit" name="isxdigit">
2532 <sect1>isascii<label id="isascii"><p>
2536 <tag/Function/Check if a given character is in the ASCII (0..127) range.
2537 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2538 <tag/Declaration/<tt/int __fastcall__ isascii (int c);/
2539 <tag/Description/The function returns a non zero value if the given argument
2540 is in the range 0..127 (the range of valid ASCII characters) and zero if not.
2541 <tag/Limits/<itemize>
2542 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2543 inline sequence generated by the macro will not work correctly for values
2544 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2545 this range. The non inline function may be accessed by <tt/#undef/'ing the
2547 <item>When compiling without <tt/-Os/, the function is only available as
2548 fastcall function, so it may only be used in presence of a prototype.
2550 <tag/Availability/ISO 9899
2552 <ref id="isalnum" name="isalnum">,
2553 <ref id="isalpha" name="isalpha">,
2554 <ref id="isblank" name="isblank">,
2555 <ref id="iscntrl" name="iscntrl">,
2556 <ref id="isdigit" name="isdigit">,
2557 <ref id="isgraph" name="isgraph">,
2558 <ref id="islower" name="islower">,
2559 <ref id="isprint" name="isprint">,
2560 <ref id="ispunct" name="ispunct">,
2561 <ref id="isspace" name="isspace">,
2562 <ref id="isupper" name="isupper">,
2563 <ref id="isxdigit" name="isxdigit">
2569 <sect1>isblank<label id="isblank"><p>
2573 <tag/Function/Check if a given character is a space or tab.
2574 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2575 <tag/Declaration/<tt/int __fastcall__ isblank (int c);/
2576 <tag/Description/The function returns a non zero value if the given argument
2577 is a space or tab character. The return value is zero if the character is
2579 <tag/Limits/<itemize>
2580 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2581 inline sequence generated by the macro will not work correctly for values
2582 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2583 this range. The non inline function may be accessed by <tt/#undef/'ing the
2585 <item>When compiling without <tt/-Os/, the function is only available as
2586 fastcall function, so it may only be used in presence of a prototype.
2588 <tag/Availability/cc65
2590 <ref id="isalnum" name="isalnum">,
2591 <ref id="isalpha" name="isalpha">,
2592 <ref id="isascii" name="isascii">,
2593 <ref id="iscntrl" name="iscntrl">,
2594 <ref id="isdigit" name="isdigit">,
2595 <ref id="isgraph" name="isgraph">,
2596 <ref id="islower" name="islower">,
2597 <ref id="isprint" name="isprint">,
2598 <ref id="ispunct" name="ispunct">,
2599 <ref id="isspace" name="isspace">,
2600 <ref id="isupper" name="isupper">,
2601 <ref id="isxdigit" name="isxdigit">
2607 <sect1>iscntrl<label id="iscntrl"><p>
2611 <tag/Function/Check if a given character is a control character.
2612 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2613 <tag/Declaration/<tt/int __fastcall__ iscntrl (int c);/
2614 <tag/Description/The function returns a non zero value if the given argument
2615 is a control character. The return value is zero if the character is anything
2617 <tag/Limits/<itemize>
2618 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2619 inline sequence generated by the macro will not work correctly for values
2620 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2621 this range. The non inline function may be accessed by <tt/#undef/'ing the
2623 <item>When compiling without <tt/-Os/, the function is only available as
2624 fastcall function, so it may only be used in presence of a prototype.
2626 <tag/Availability/ISO 9899
2628 <ref id="isalnum" name="isalnum">,
2629 <ref id="isalpha" name="isalpha">,
2630 <ref id="isascii" name="isascii">,
2631 <ref id="isblank" name="isblank">,
2632 <ref id="isdigit" name="isdigit">,
2633 <ref id="isgraph" name="isgraph">,
2634 <ref id="islower" name="islower">,
2635 <ref id="isprint" name="isprint">,
2636 <ref id="ispunct" name="ispunct">,
2637 <ref id="isspace" name="isspace">,
2638 <ref id="isupper" name="isupper">,
2639 <ref id="isxdigit" name="isxdigit">
2645 <sect1>isdigit<label id="isdigit"><p>
2649 <tag/Function/Check if a given character is a digit.
2650 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2651 <tag/Declaration/<tt/int __fastcall__ isdigit (int c);/
2652 <tag/Description/The function returns a non zero value if the given argument
2653 is a digit. The return value is zero if the character is anything else.
2654 <tag/Limits/<itemize>
2655 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2656 inline sequence generated by the macro will not work correctly for values
2657 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2658 this range. The non inline function may be accessed by <tt/#undef/'ing the
2660 <item>When compiling without <tt/-Os/, the function is only available as
2661 fastcall function, so it may only be used in presence of a prototype.
2663 <tag/Availability/ISO 9899
2665 <ref id="isalnum" name="isalnum">,
2666 <ref id="isalpha" name="isalpha">,
2667 <ref id="isascii" name="isascii">,
2668 <ref id="isblank" name="isblank">,
2669 <ref id="iscntrl" name="iscntrl">,
2670 <ref id="isgraph" name="isgraph">,
2671 <ref id="islower" name="islower">,
2672 <ref id="isprint" name="isprint">,
2673 <ref id="ispunct" name="ispunct">,
2674 <ref id="isspace" name="isspace">,
2675 <ref id="isupper" name="isupper">,
2676 <ref id="isxdigit" name="isxdigit">
2682 <sect1>isgraph<label id="isgraph"><p>
2686 <tag/Function/Check if a given character is a printable character (except
2688 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2689 <tag/Declaration/<tt/int __fastcall__ isgraph (int c);/
2690 <tag/Description/The function returns a non zero value if the given argument
2691 is a printable character with the exception of space. The return value is zero
2692 if the character is anything else.
2693 <tag/Limits/<itemize>
2694 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2695 inline sequence generated by the macro will not work correctly for values
2696 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2697 this range. The non inline function may be accessed by <tt/#undef/'ing the
2699 <item>When compiling without <tt/-Os/, the function is only available as
2700 fastcall function, so it may only be used in presence of a prototype.
2702 <tag/Availability/ISO 9899
2704 <ref id="isalnum" name="isalnum">,
2705 <ref id="isalpha" name="isalpha">,
2706 <ref id="isascii" name="isascii">,
2707 <ref id="isblank" name="isblank">,
2708 <ref id="iscntrl" name="iscntrl">,
2709 <ref id="isdigit" name="isdigit">,
2710 <ref id="islower" name="islower">,
2711 <ref id="isprint" name="isprint">,
2712 <ref id="ispunct" name="ispunct">,
2713 <ref id="isspace" name="isspace">,
2714 <ref id="isupper" name="isupper">,
2715 <ref id="isxdigit" name="isxdigit">
2721 <sect1>islower<label id="islower"><p>
2725 <tag/Function/Check if a given character is a lower case letter.
2726 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2727 <tag/Declaration/<tt/int __fastcall__ islower (int c);/
2728 <tag/Description/The function returns a non zero value if the given argument
2729 is a lower case letter. The return value is zero if the character is anything
2731 <tag/Limits/<itemize>
2732 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2733 inline sequence generated by the macro will not work correctly for values
2734 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2735 this range. The non inline function may be accessed by <tt/#undef/'ing the
2737 <item>When compiling without <tt/-Os/, the function is only available as
2738 fastcall function, so it may only be used in presence of a prototype.
2740 <tag/Availability/ISO 9899
2742 <ref id="isalnum" name="isalnum">,
2743 <ref id="isalpha" name="isalpha">,
2744 <ref id="isascii" name="isascii">,
2745 <ref id="isblank" name="isblank">,
2746 <ref id="iscntrl" name="iscntrl">,
2747 <ref id="isdigit" name="isdigit">,
2748 <ref id="isgraph" name="isgraph">,
2749 <ref id="isprint" name="isprint">,
2750 <ref id="ispunct" name="ispunct">,
2751 <ref id="isspace" name="isspace">,
2752 <ref id="isupper" name="isupper">,
2753 <ref id="isxdigit" name="isxdigit">
2759 <sect1>isprint<label id="isprint"><p>
2763 <tag/Function/Check if a given character is a printable character.
2764 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2765 <tag/Declaration/<tt/int __fastcall__ isprint (int c);/
2766 <tag/Description/The function returns a non zero value if the given argument
2767 is a printable character (this includes the space character). The return value
2768 is zero if the character is anything else.
2769 <tag/Limits/<itemize>
2770 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2771 inline sequence generated by the macro will not work correctly for values
2772 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2773 this range. The non inline function may be accessed by <tt/#undef/'ing the
2775 <item>When compiling without <tt/-Os/, the function is only available as
2776 fastcall function, so it may only be used in presence of a prototype.
2778 <tag/Availability/ISO 9899
2780 <ref id="isalnum" name="isalnum">,
2781 <ref id="isalpha" name="isalpha">,
2782 <ref id="isascii" name="isascii">,
2783 <ref id="isblank" name="isblank">,
2784 <ref id="iscntrl" name="iscntrl">,
2785 <ref id="isdigit" name="isdigit">,
2786 <ref id="isgraph" name="isgraph">,
2787 <ref id="islower" name="islower">,
2788 <ref id="ispunct" name="ispunct">,
2789 <ref id="isspace" name="isspace">,
2790 <ref id="isupper" name="isupper">,
2791 <ref id="isxdigit" name="isxdigit">
2797 <sect1>ispunct<label id="ispunct"><p>
2801 <tag/Function/Check if a given character is a printable character but not a
2802 space or an alphanumeric character.
2803 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2804 <tag/Declaration/<tt/int __fastcall__ ispunct (int c);/
2805 <tag/Description/The function returns a non zero value if the given argument
2806 is a printable character, but not a space or anything alphanumeric. The return
2807 value is zero if the character is anything else.
2808 <tag/Limits/<itemize>
2809 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2810 inline sequence generated by the macro will not work correctly for values
2811 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2812 this range. The non inline function may be accessed by <tt/#undef/'ing the
2814 <item>When compiling without <tt/-Os/, the function is only available as
2815 fastcall function, so it may only be used in presence of a prototype.
2817 <tag/Availability/ISO 9899
2819 <ref id="isalnum" name="isalnum">,
2820 <ref id="isalpha" name="isalpha">,
2821 <ref id="isascii" name="isascii">,
2822 <ref id="isblank" name="isblank">,
2823 <ref id="iscntrl" name="iscntrl">,
2824 <ref id="isdigit" name="isdigit">,
2825 <ref id="isgraph" name="isgraph">,
2826 <ref id="islower" name="islower">,
2827 <ref id="isprint" name="isprint">,
2828 <ref id="isspace" name="isspace">,
2829 <ref id="isupper" name="isupper">,
2830 <ref id="isxdigit" name="isxdigit">
2836 <sect1>isspace<label id="isspace"><p>
2840 <tag/Function/Check if a given character is a a white-space character.
2841 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2842 <tag/Declaration/<tt/int __fastcall__ isspace (int c);/
2843 <tag/Description/The function returns a non zero value if the given argument
2844 is a white space character. The return value is zero if the character is
2845 anything else. The standard white space characters are: space, formfeed ('\f'),
2846 newline ('\n'), carriage return ('\r'), horizontal tab ('\t'), and vertical tab
2848 <tag/Limits/<itemize>
2849 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2850 inline sequence generated by the macro will not work correctly for values
2851 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2852 this range. The non inline function may be accessed by <tt/#undef/'ing the
2854 <item>When compiling without <tt/-Os/, the function is only available as
2855 fastcall function, so it may only be used in presence of a prototype.
2857 <tag/Availability/ISO 9899
2859 <ref id="isalnum" name="isalnum">,
2860 <ref id="isalpha" name="isalpha">,
2861 <ref id="isascii" name="isascii">,
2862 <ref id="isblank" name="isblank">,
2863 <ref id="iscntrl" name="iscntrl">,
2864 <ref id="isdigit" name="isdigit">,
2865 <ref id="isgraph" name="isgraph">,
2866 <ref id="islower" name="islower">,
2867 <ref id="isprint" name="isprint">,
2868 <ref id="ispunct" name="ispunct">,
2869 <ref id="isupper" name="isupper">,
2870 <ref id="isxdigit" name="isxdigit">
2876 <sect1>isupper<label id="isupper"><p>
2880 <tag/Function/Check if a given character is an upper case letter.
2881 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2882 <tag/Declaration/<tt/int __fastcall__ isupper (int c);/
2883 <tag/Description/The function returns a non zero value if the given argument
2884 is an upper case letter. The return value is zero if the character is anything
2886 <tag/Limits/<itemize>
2887 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2888 inline sequence generated by the macro will not work correctly for values
2889 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2890 this range. The non inline function may be accessed by <tt/#undef/'ing the
2892 <item>When compiling without <tt/-Os/, the function is only available as
2893 fastcall function, so it may only be used in presence of a prototype.
2895 <tag/Availability/ISO 9899
2897 <ref id="isalnum" name="isalnum">,
2898 <ref id="isalpha" name="isalpha">,
2899 <ref id="isascii" name="isascii">,
2900 <ref id="isblank" name="isblank">,
2901 <ref id="iscntrl" name="iscntrl">,
2902 <ref id="isdigit" name="isdigit">,
2903 <ref id="isgraph" name="isgraph">,
2904 <ref id="islower" name="islower">,
2905 <ref id="isprint" name="isprint">,
2906 <ref id="ispunct" name="ispunct">,
2907 <ref id="isspace" name="isspace">,
2908 <ref id="isxdigit" name="isxdigit">
2914 <sect1>isxdigit<label id="isxdigit"><p>
2918 <tag/Function/Check if a given character is a hexadecimal digit.
2919 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2920 <tag/Declaration/<tt/int __fastcall__ isxdigit (int c);/
2921 <tag/Description/The function returns a non zero value if the given argument
2922 is a hexadecimal digit (0..9, a..f and A..F). The return value is zero if the
2923 character is anything else.
2924 <tag/Limits/<itemize>
2925 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2926 inline sequence generated by the macro will not work correctly for values
2927 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2928 this range. The non inline function may be accessed by <tt/#undef/'ing the
2930 <item>When compiling without <tt/-Os/, the function is only available as
2931 fastcall function, so it may only be used in presence of a prototype.
2933 <tag/Availability/ISO 9899
2935 <ref id="isalnum" name="isalnum">,
2936 <ref id="isalpha" name="isalpha">,
2937 <ref id="isascii" name="isascii">,
2938 <ref id="isblank" name="isblank">,
2939 <ref id="iscntrl" name="iscntrl">,
2940 <ref id="isdigit" name="isdigit">,
2941 <ref id="isgraph" name="isgraph">,
2942 <ref id="islower" name="islower">,
2943 <ref id="isprint" name="isprint">,
2944 <ref id="ispunct" name="ispunct">,
2945 <ref id="isspace" name="isspace">,
2946 <ref id="isupper" name="isupper">
2952 <sect1>itoa<label id="itoa"><p>
2956 <tag/Function/Convert an integer into a string.
2957 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
2958 <tag/Declaration/<tt/char* __fastcall__ itoa (int val, char* buf, int radix);/
2959 <tag/Description/<tt/itoa/ converts the integer <tt/val/ into a string using
2960 <tt/radix/ as the base.
2961 <tag/Limits/<itemize>
2962 <item>There are no provisions to prevent a buffer overflow.
2963 <item>If <tt/val/ contains <tt/INT_MIN/, the behaviour is undefined.
2964 <item>The function is non standard, so it is not available in strict ANSI mode.
2965 You should probably use <tt/sprintf/ instead.
2966 <item>The function is only available as fastcall function, so it may only be
2967 used in presence of a prototype.
2969 <tag/Availability/cc65
2971 <ref id="atoi" name="atoi">,
2972 <ref id="atol" name="atol">,
2973 <ref id="ltoa" name="ltoa">,
2974 <ref id="ultoa" name="ultoa">,
2975 <ref id="utoa" name="utoa">
2981 <sect1>joy_count<label id="joy_count"><p>
2985 <tag/Function/Return the number of joysticks supported by the current driver.
2986 <tag/Header/<tt/<ref id="joystick.h" name="joystick.h">/
2987 <tag/Declaration/<tt/unsigned char __fastcall__ joy_count (void);/
2988 <tag/Description/The function returns a the number of joysticks supported
2989 by the current joystick driver.
2990 <tag/Limits/<itemize>
2991 <item>A joystick driver must be loaded using <ref id="joy_load_driver"
2992 name="joy_load_driver"> before calling this function.
2993 <item>The function returns the number of joysticks supported by the driver.
2994 There's no way to check for the number of actually connected joysticks.
2995 <item>The function is only available as fastcall function, so it may only be
2996 used in presence of a prototype.
2998 <tag/Availability/cc65
3000 <ref id="joy_load_driver" name="joy_load_driver">,
3001 <ref id="joy_read" name="joy_read">
3007 <sect1>joy_install<label id="joy_install"><p>
3011 <tag/Function/Install an already loaded driver and return an error code.
3012 <tag/Header/<tt/<ref id="joystick.h" name="joystick.h">/
3013 <tag/Declaration/<tt/unsigned char __fastcall__ joy_install (void* driver);/
3014 <tag/Description/The function installs a driver that was already loaded into
3015 memory (or linked statically to the program). It returns an error code
3016 (<tt/JOY_ERR_OK/ in case of success).
3017 <tag/Limits/<itemize>
3018 <item>The function is only available as fastcall function, so it may only be
3019 used in presence of a prototype.
3021 <tag/Availability/cc65
3023 <ref id="joy_load_driver" name="joy_load_driver">,
3024 <ref id="joy_uninstall" name="joy_uninstall">,
3025 <ref id="joy_unload" name="joy_unload">
3031 <sect1>joy_load_driver<label id="joy_load_driver"><p>
3035 <tag/Function/Load a driver from disk and install it.
3036 <tag/Header/<tt/<ref id="joystick.h" name="joystick.h">/
3037 <tag/Declaration/<tt/unsigned char __fastcall__ joy_load_driver (const char* driver);/
3038 <tag/Description/The function loads a driver with the given name from disk
3039 and installs it. An error code is returned, which is <tt/JOY_ERR_OK/ if the
3040 driver was successfully loaded and installed.
3041 <tag/Limits/<itemize>
3042 <item>The function is only available as fastcall function, so it may only be
3043 used in presence of a prototype.
3045 <tag/Availability/cc65
3047 <ref id="joy_install" name="joy_install">,
3048 <ref id="joy_uninstall" name="joy_uninstall">,
3049 <ref id="joy_unload" name="joy_unload">
3055 <sect1>joy_read<label id="joy_read"><p>
3059 <tag/Function/Read the status of a joystick.
3060 <tag/Header/<tt/<ref id="joystick.h" name="joystick.h">/
3061 <tag/Declaration/<tt/unsigned char __fastcall__ joy_read (unsigned char joystick);/
3062 <tag/Description/The function reads the status bits for a joystick. The number
3063 of the joystick is passed as parameter. The result may be examined by using one
3064 of the <tt/JOY_xxx/ macros from <ref id="joystick.h" name="joystick.h">.
3065 <tag/Limits/<itemize>
3066 <item>A joystick driver must be loaded using <ref id="joy_load_driver"
3067 name="joy_load_driver"> before calling this function.
3068 <item>The function is only available as fastcall function, so it may only be
3069 used in presence of a prototype.
3071 <tag/Availability/cc65
3073 <ref id="joy_count" name="joy_count">,
3074 <ref id="joy_load_driver" name="joy_load_driver">,
3075 <ref id="joy_unload" name="joy_unload">
3081 <sect1>joy_uninstall<label id="joy_uninstall"><p>
3085 <tag/Function/Uninstall the current joystick driver.
3086 <tag/Header/<tt/<ref id="joystick.h" name="joystick.h">/
3087 <tag/Declaration/<tt/unsigned char __fastcall__ joy_uninstall (void);/
3088 <tag/Description/The function uninstalls the currently installed joystick
3089 driver. It does not remove the driver from memory. The function returns an
3090 error code, which is <tt/JOY_ERR_OK/ if the driver was successfully uninstalled.
3091 <tag/Limits/<itemize>
3092 <item>A joystick driver must be installed using <ref id="joy_install"
3093 name="joy_install"> before calling this function.
3094 <item>The function is only available as fastcall function, so it may only be
3095 used in presence of a prototype.
3097 <tag/Availability/cc65
3099 <ref id="joy_install" name="joy_install">,
3100 <ref id="joy_load_driver" name="joy_load_driver">,
3101 <ref id="joy_unload" name="joy_unload">
3107 <sect1>joy_unload<label id="joy_unload"><p>
3111 <tag/Function/Uninstall, then unload the current joystick driver.
3112 <tag/Header/<tt/<ref id="joystick.h" name="joystick.h">/
3113 <tag/Declaration/<tt/unsigned char __fastcall__ joy_unload (void);/
3114 <tag/Description/The function uninstalls the currently installed joystick
3115 driver and removes it from memory. An error code is returned, which is
3116 <tt/JOY_ERR_OK/ if the driver was successfully uninstalled.
3117 <tag/Limits/<itemize>
3118 <item>A joystick driver must be loaded using <ref id="joy_load_driver"
3119 name="joy_load_driver"> before calling this function.
3120 <item>The function is only available as fastcall function, so it may only be
3121 used in presence of a prototype.
3123 <tag/Availability/cc65
3125 <ref id="joy_load_driver" name="joy_load_driver">
3131 <sect1>kbhit<label id="kbhit"><p>
3135 <tag/Function/Check if there's a key waiting in the keyboard buffer.
3136 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
3137 <tag/Declaration/<tt/unsigned char kbhit (void);/
3138 <tag/Description/The function returns a value of zero if there is no character
3139 waiting to be read from the keyboard. It returns non zero otherwise.
3140 <tag/Limits/<itemize>
3141 <item>If the system does not support a keyboard buffer (most systems
3142 do), the function is rather useless.
3144 <tag/Availability/cc65
3146 <ref id="cgetc" name="cgetc">,
3147 <ref id="cursor" name="cursor">
3153 <sect1>labs<label id="labs"><p>
3157 <tag/Function/Returns the absolute value of a long integer.
3158 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
3159 <tag/Declaration/<tt/long __fastcall__ labs (long v);/
3160 <tag/Description/<tt/labs/ returns the absolute value of the argument passed to
3162 <tag/Limits/<itemize>
3163 <item>The return value is undefined if <tt/LONG_MIN/ is passed to the function.
3164 <item>The function is only available as fastcall function, so it may only be
3165 used in presence of a prototype.
3167 <tag/Availability/ISO 9899
3169 <ref id="abs" name="abs">
3175 <sect1>ltoa<label id="ltoa"><p>
3179 <tag/Function/Convert a long integer into a string.
3180 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
3181 <tag/Declaration/<tt/char* __fastcall__ ltoa (long val, char* buf, int radix);/
3182 <tag/Description/<tt/itoa/ converts the long integer <tt/val/ into a string
3183 using <tt/radix/ as the base.
3184 <tag/Limits/<itemize>
3185 <item>There are no provisions to prevent a buffer overflow.
3186 <item>If <tt/val/ contains <tt/LONG_MIN/, the behaviour is undefined.
3187 <item>The function is non standard, so it is not available in strict ANSI mode.
3188 You should probably use <tt/sprintf/ instead.
3189 <item>The function is only available as fastcall function, so it may only be
3190 used in presence of a prototype.
3192 <tag/Availability/cc65
3194 <ref id="atoi" name="atoi">,
3195 <ref id="atol" name="atol">,
3196 <ref id="itoa" name="itoa">,
3197 <ref id="ultoa" name="ultoa">,
3198 <ref id="utoa" name="utoa">
3204 <sect1>localeconv<label id="localeconv"><p>
3208 <tag/Function/Returns a pointer to the current locale structure.
3209 <tag/Header/<tt/<ref id="locale.h" name="locale.h">/
3210 <tag/Declaration/<tt/struct lconv* localeconv (void);/
3211 <tag/Description/<tt/localeconv/ returns a pointer to the current locale
3213 <tag/Limits/<itemize>
3214 <item>cc65 supports only the "C" locale, so even after setting a new locale
3215 using <tt/<ref id="setlocale" name="setlocale">/, the structure returned will
3218 <tag/Availability/ISO 9899
3220 <ref id="setlocale" name="setlocale">
3226 <sect1>longjmp<label id="longjmp"><p>
3230 <tag/Function/Non local goto.
3231 <tag/Header/<tt/<ref id="setjmp.h" name="setjmp.h">/
3232 <tag/Declaration/<tt/void __fastcall__ longjmp (jmp_buf buf, int retval);/
3233 <tag/Description/The <tt/longjmp/ function restores a program context from the
3234 data in <tt/buf/, which must have been set by a preceeding call to
3235 <tt/<ref id="setjmp" name="setjmp">/. Program execution continues as if the
3236 call to <tt/<ref id="setjmp" name="setjmp">/ has just returned the value
3240 <item>If the parameter <tt/retval/ is zero, the function will behave as if it
3241 was called with a value of one.
3242 <item>The function is only available as fastcall function, so it may only
3243 be used in presence of a prototype.
3245 <tag/Availability/ISO 9899
3247 <ref id="setjmp" name="setjmp">
3253 <sect1>malloc<label id="malloc"><p>
3257 <tag/Function/Allocate dynamic memory.
3258 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
3259 <tag/Declaration/<tt/void* __fastcall__ malloc (size_t size);/
3260 <tag/Description/<tt/malloc/ allocates size bytes on the heap and returns a
3261 pointer to the allocated memory block. On error (not enough memory available),
3262 <tt/malloc/ returns <tt/NULL/.
3265 <item>The function is only available as fastcall function, so it may only
3266 be used in presence of a prototype.
3268 <tag/Availability/ISO 9899
3270 <ref id="_heapadd" name="_heapadd">,
3271 <ref id="_heapblocksize" name="_heapblocksize">,
3272 <ref id="_heapmaxavail" name="_heapmaxavail">,
3273 <ref id="_heapmemavail" name="_heapmemavail">,
3274 <ref id="calloc" name="calloc">,
3275 <ref id="free" name="free">,
3276 <ref id="realloc" name="realloc">,
3277 <ref id="strdup" name="strdup">
3283 <sect1>memchr<label id="memchr"><p>
3287 <tag/Function/Search for a character in a block of raw memory.
3288 <tag/Header/<tt/<ref id="string.h" name="string.h">/
3289 <tag/Declaration/<tt/void* __fastcall__ strchr (const void* mem, int c, size_t count);/
3290 <tag/Description/The <tt/memchr/ function locates the first occurrence of <tt/c/
3291 (converted to a char) in the block of raw memory string pointed to by <tt/mem/
3292 that is of size <tt/count/. Upon completion, the function returns a pointer to
3293 the character found, or a null pointer if the character was not found.
3294 <tag/Limits/<itemize>
3295 <item>The function is only available as fastcall function, so it may only
3296 be used in presence of a prototype.
3298 <tag/Availability/ISO 9899
3300 <ref id="strchr" name="strchr">
3306 <sect1>memcmp<label id="memcmp"><p>
3310 <tag/Function/Compare two memory areas.
3311 <tag/Header/<tt/<ref id="string.h" name="string.h">/
3312 <tag/Declaration/<tt/int __fastcall__ memcmp (const void* p1, const void* p2, size_t count);/
3313 <tag/Description/<tt/memcmp/ compares <tt/count/ bytes from the memory area
3314 pointed to by <tt/p1/ into the memory area pointed to by <tt/p2/. It returns a value that is less than
3315 zero if <tt/p1/ is less than <tt/p2/, zero if <tt/p1/ is the same as <tt/p2/,
3316 and a value greater than zero if <tt/p1/ is greater than <tt/p2/.
3319 <item>The function is only available as fastcall function, so it may only
3320 be used in presence of a prototype.
3322 <tag/Availability/ISO 9899
3324 <ref id="strcmp" name="strcmp">,
3325 <ref id="memmove" name="memmove">,
3326 <ref id="memset" name="memset">
3332 <sect1>memcpy<label id="memcpy"><p>
3336 <tag/Function/Copy a memory area.
3337 <tag/Header/<tt/<ref id="string.h" name="string.h">/
3338 <tag/Declaration/<tt/void* __fastcall__ memcpy (void* dest, const void* src, size_t count);/
3339 <tag/Description/<tt/memcpy/ copies <tt/count/ bytes from the memory area
3340 pointed to by <tt/src/ into the memory area pointed to by <tt/dest/. It returns
3344 <item>The result is undefined if the memory areas do overlap. Use
3345 <tt/<ref id="memmove" name="memmove">/ to copy overlapping memory areas.
3346 <item>The function is only available as fastcall function, so it may only
3347 be used in presence of a prototype.
3349 <tag/Availability/ISO 9899
3351 <ref id="_swap" name="_swap">,
3352 <ref id="memmove" name="memmove">,
3353 <ref id="memset" name="memset">
3359 <sect1>memmove<label id="memmove"><p>
3363 <tag/Function/Copy a memory area.
3364 <tag/Header/<tt/<ref id="string.h" name="string.h">/
3365 <tag/Declaration/<tt/void* __fastcall__ memmove (void* dest, const void* src, size_t count);/
3366 <tag/Description/<tt/memmove/ copies <tt/count/ bytes from the memory area
3367 pointed to by <tt/src/ into the memory area pointed to by <tt/dest/. It returns
3371 <item>While <tt/memmove/ allows the memory areas to overlap, it has some
3372 additional overhead compared to <tt/<ref id="memcpy" name="memcpy">/.
3373 <item>The function is only available as fastcall function, so it may only
3374 be used in presence of a prototype.
3376 <tag/Availability/ISO 9899
3378 <ref id="_swap" name="_swap">,
3379 <ref id="memcpy" name="memcpy">,
3380 <ref id="memset" name="memset">
3386 <sect1>memset<label id="memset"><p>
3390 <tag/Function/Fill a memory area.
3391 <tag/Header/<tt/<ref id="string.h" name="string.h">/
3392 <tag/Declaration/<tt/void* __fastcall__ memset (void* p, int val, size_t count);/
3393 <tag/Description/<tt/memset/ fills the memory area pointed to by <tt/p/ with
3394 the value <tt/val/. The function returns <tt/p/.
3397 <item>The function is only available as fastcall function, so it may only
3398 be used in presence of a prototype.
3400 <tag/Availability/ISO 9899
3402 <ref id="_swap" name="_swap">,
3403 <ref id="bzero" name="bzero">,
3404 <ref id="memcpy" name="memcpy">,
3405 <ref id="memmove" name="memmove">
3411 <sect1>mod_free<label id="mod_free"><p>
3415 <tag/Function/Free a relocatable module.
3416 <tag/Header/<tt/<ref id="modload.h" name="modload.h">/
3417 <tag/Declaration/<tt/void __fastcall__ mod_free (void* module);/
3418 <tag/Description/The function will free a module loaded into memory by use of
3419 the <tt/<ref id="mod_load" name="mod_load">/ function.
3420 <tag/Limits/<itemize>
3421 <item>The pointer passed as parameter is the pointer to the module memory,
3422 not the pointer to the control structure.
3424 <tag/Availability/cc65
3426 <ref id="mod_load" name="mod_load">
3432 <sect1>mod_load<label id="mod_load"><p>
3436 <tag/Function/Load a relocatable module.
3437 <tag/Header/<tt/<ref id="modload.h" name="modload.h">/
3438 <tag/Declaration/<tt/unsigned char mod_load (struct mod_ctrl* ctrl);/
3439 <tag/Description/The function will load a code module into memory and relocate
3440 it. The function will return an error code. If <tt/MLOAD_OK/ is returned, the
3441 outgoing fields in the passed <tt/mod_ctrl/ struct contain information about
3442 the module just loaded. Possible error codes are:
3444 <item><tt/MLOAD_OK/ - Module load successful
3445 <item><tt/MLOAD_ERR_READ/ - Read error
3446 <item><tt/MLOAD_ERR_HDR/ - Header error
3447 <item><tt/MLOAD_ERR_OS/ - Wrong operating system
3448 <item><tt/MLOAD_ERR_FMT/ - Data format error
3449 <item><tt/MLOAD_ERR_MEM/ - Not enough memory
3451 <tag/Limits/<itemize>
3452 <item>The <htmlurl url="ld65.html" name="ld65"> linker is needed to create
3453 relocatable o65 modules for use with this function.
3455 <tag/Availability/cc65
3457 <ref id="mod_free" name="mod_free">
3463 <sect1>mouse_setbox<label id="mouse_setbox"><p>
3467 <tag/Function/Specify a bounding box for the mouse cursor.
3468 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3469 <tag/Declaration/<tt/void __fastcall__ mouse_setbox (const struct mouse_box* box);/
3470 <tag/Description/The function allows to set a bounding box for mouse movement.
3471 <tag/Limits/<itemize>
3472 <item>The function does not check if the mouse cursor is currently within the
3473 given rectangle. Placing the mouse cursor within the bounding box is the
3474 responsibility of the programmer.
3475 <item>While the bounding box may be larger than the actual screen size, the
3476 standard mouse cursor draw routines may fail to set the cursor to coordinates
3477 outside of the screen area. Depending on the platform, you may have to supply
3478 your own mouse cursor routines.
3479 <item>The function is only available as fastcall function, so it may only be
3480 used in presence of a prototype.
3482 <tag/Availability/cc65
3484 <ref id="mouse_getbox" name="mouse_getbox">,
3485 <ref id="mouse_move" name="mouse_move">
3491 <sect1>mouse_getbox<label id="mouse_getbox"><p>
3495 <tag/Function/Return the current bounding box for the mouse cursor.
3496 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3497 <tag/Declaration/<tt/void __fastcall__ mouse_getbox (struct mouse_box* box);/
3498 <tag/Description/The function queries the current bounding box for mouse
3500 <tag/Limits/<itemize>
3501 <item>The function is only available as fastcall function, so it may only be
3502 used in presence of a prototype.
3504 <tag/Availability/cc65
3506 <ref id="mouse_move" name="mouse_move">,
3507 <ref id="mouse_setbox" name="mouse_setbox">
3513 <sect1>mouse_buttons<label id="mouse_buttons"><p>
3517 <tag/Function/Return a bit mask encoding the state of the mouse buttons.
3518 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3519 <tag/Declaration/<tt/unsigned char __fastcall__ mouse_buttons (void);/
3520 <tag/Description/The function returns a bit mask that encodes the state of the
3521 mouse buttons. You may use the <tt/MOUSE_BTN_XXX/ flags to decode the function
3523 <tag/Limits/<itemize>
3524 <item>The function is only available as fastcall function, so it may only be
3525 used in presence of a prototype.
3527 <tag/Availability/cc65
3529 <ref id="mouse_info" name="mouse_info">,
3530 <ref id="mouse_pos" name="mouse_pos">
3536 <sect1>mouse_geterrormsg<label id="mouse_geterrormsg"><p>
3540 <tag/Function/Return a readable error message for an error code.
3541 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3542 <tag/Declaration/<tt/const char* __fastcall__ mouse_geterrormsg (unsigned char
3544 <tag/Description/The function returns an error message (in english) for the
3545 error code passed parameter.
3546 <tag/Limits/<itemize>
3547 <item>The function will return "Unknown error" for invalid error codes.
3548 <item>The function is only available as fastcall function, so it may only be
3549 used in presence of a prototype.
3551 <tag/Availability/cc65
3553 <ref id="mouse_load_driver" name="mouse_load_driver">,
3554 <ref id="mouse_uninstall" name="mouse_uninstall">,
3555 <ref id="mouse_unload" name="mouse_unload">
3561 <sect1>mouse_hide<label id="mouse_hide"><p>
3565 <tag/Function/Hide the mouse pointer.
3566 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3567 <tag/Declaration/<tt/void __fastcall__ mouse_hide (void);/
3568 <tag/Description/The function hides the mouse pointer. It manages a counter
3569 that is shared between <tt/<ref id="mouse_show" name="mouse_show">/ and
3570 <tt/mouse_hide/ so that every call call to <tt/mouse_hide/ must be followed by
3571 a call to <tt/<ref id="mouse_show" name="mouse_show">/ to make the mouse cursor
3573 <tag/Limits/<itemize>
3574 <item>The function is only available as fastcall function, so it may only be
3575 used in presence of a prototype.
3577 <tag/Availability/cc65
3579 <ref id="mouse_show" name="mouse_show">
3585 <sect1>mouse_info<label id="mouse_info"><p>
3589 <tag/Function/Return the state of the mouse buttons and the position of the
3591 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3592 <tag/Declaration/<tt/void __fastcall__ mouse_info (struct mouse_info* info);/
3593 <tag/Description/The function returns the state of the mouse buttons and the
3594 position of the mouse in the <tt/mouse_info/ structure passed as parameter.
3595 <tag/Limits/<itemize>
3596 <item>The <tt/mouse_info/ struct is a superset of the <tt/mouse_pos/ struct,
3597 so if you just need the mouse position, call <tt/<ref id="mouse_pos"
3598 name="mouse_pos">/ instead.
3599 <item>The function is only available as fastcall function, so it may only be
3600 used in presence of a prototype.
3602 <tag/Availability/cc65
3604 <ref id="mouse_buttons" name="mouse_buttons">,
3605 <ref id="mouse_pos" name="mouse_pos">
3611 <sect1>mouse_install<label id="mouse_install"><p>
3615 <tag/Function/Install an already loaded mouse driver.
3616 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3617 <tag/Declaration/<tt/unsigned char __fastcall__ mouse_install (const struct
3618 mouse_callbacks* c, void* driver);/
3619 <tag/Description/The function installs an already loaded mouse driver and
3620 returns an error code. The <tt/mouse_callbacks/ structure passed as first
3621 parameter contains pointers to routines needed to move or hide/show the mouse
3622 pointer. Defaults for these routines are supplied by the library, so if you
3623 can live with these defaults (which are platform specific), just pass a
3624 pointer to <tt/mouse_def_callbacks/. The function may be used to install a
3625 driver linked statically to the program.
3626 <tag/Limits/<itemize>
3627 <item>Not all drivers are able to detect if the supported hardware is really
3629 <item>After installing a driver, the mouse cursor is hidden.
3630 <item>The function is only available as fastcall function, so it may only be
3631 used in presence of a prototype.
3633 <tag/Availability/cc65
3635 <ref id="mouse_load_driver" name="mouse_load_driver">,
3636 <ref id="mouse_uninstall" name="mouse_uninstall">,
3637 <ref id="mouse_unload" name="mouse_unload">
3643 <sect1>mouse_ioctl<label id="mouse_ioctl"><p>
3647 <tag/Function/Call the driver specific ioctl function.
3648 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3649 <tag/Declaration/<tt/unsigned char __fastcall__ mouse_ioctl (unsigned char code, void* data);/
3650 <tag/Description/The function calls the IOCTL entry in the mouse driver,
3651 which is driver specific. The <tt/code/ parameter will choose between
3652 different IOCTL functions, and the <tt/data/ depends on code. The
3653 function returns an error code. The purpose of this function is to allow
3654 for driver specific extensions. See the documentation for a specific mouse
3655 driver for supported ioctl calls.
3656 <tag/Limits/<itemize>
3657 <item>Calling this function is non portable, because each driver may
3658 implement different ioctl calls (or none at all).
3659 <item>The function is only available as fastcall function, so it may only be
3660 used in presence of a prototype.
3662 <tag/Availability/cc65
3668 <sect1>mouse_load_driver<label id="mouse_load_driver"><p>
3672 <tag/Function/Load and initialize a mouse driver.
3673 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3674 <tag/Declaration/<tt/unsigned char __fastcall__ mouse_load_driver (const struct
3675 mouse_callbacks* c, const char* driver);/
3676 <tag/Description/Load a mouse driver into memory and initialize it. The
3677 function returns an error code that tells if the call has been successful. The
3678 <tt/mouse_callbacks/ structure passed as first parameter contains pointers to
3679 routines needed to move or hide/show the mouse pointer. Defaults for these
3680 routines are supplied by the library, so if you can live with these defaults
3681 (which are platform specific), just pass a pointer to <tt/mouse_def_callbacks/.
3682 <tag/Limits/<itemize>
3683 <item>The driver is loaded by name, so currently you must know the type of
3684 mouse that should be supported. There is no autodetect capability.
3685 <item>Not all drivers are able to detect if the supported hardware is really
3687 <item>After installing a driver, the mouse cursor is hidden.
3688 <item>The function is only available as fastcall function, so it may only be
3689 used in presence of a prototype.
3691 <tag/Availability/cc65
3693 <ref id="mouse_install" name="mouse_install">,
3694 <ref id="mouse_uninstall" name="mouse_uninstall">,
3695 <ref id="mouse_unload" name="mouse_unload">
3701 <sect1>mouse_move<label id="mouse_move"><p>
3705 <tag/Function/Move the mouse cursor to a specific position.
3706 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3707 <tag/Declaration/<tt/void __fastcall__ mouse_move (int x, int y);/
3708 <tag/Description/The function updates the mouse position. If the mouse cursor
3709 is visible, it is shown at the new position.
3710 <tag/Limits/<itemize>
3711 <item>The function does not check if the new position is within the bounding
3712 box specified with <tt/<ref id="mouse_setbox" name="mouse_setbox">/.
3713 <item>The function is only available as fastcall function, so it may only be
3714 used in presence of a prototype.
3716 <tag/Availability/cc65
3718 <ref id="mouse_getbox" name="mouse_getbox">,
3719 <ref id="mouse_setbox" name="mouse_setbox">
3725 <sect1>mouse_pos<label id="mouse_pos"><p>
3729 <tag/Function/Return the position of the mouse.
3730 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3731 <tag/Declaration/<tt/void __fastcall__ mouse_pos (struct mouse_pos* pos);/
3732 <tag/Description/The function returns the position of the mouse in the
3733 <tt/mouse_pos/ structure passed as parameter.
3734 <tag/Limits/<itemize>
3735 <item>The <tt/mouse_pos/ struct is a subset of the <tt/mouse_info/ struct,
3736 so if you do also need the mouse buttons, call <tt/<ref id="mouse_info"
3737 name="mouse_info">/ instead.
3738 <item>The function is only available as fastcall function, so it may only be
3739 used in presence of a prototype.
3741 <tag/Availability/cc65
3743 <ref id="mouse_buttons" name="mouse_buttons">,
3744 <ref id="mouse_info" name="mouse_info">
3750 <sect1>mouse_show<label id="mouse_show"><p>
3754 <tag/Function/Show the mouse pointer.
3755 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3756 <tag/Declaration/<tt/void __fastcall__ mouse_show (void);/
3757 <tag/Description/The function shows the mouse pointer. It manages a counter
3758 that is shared between <tt/<ref id="mouse_hide" name="mouse_hide">/ and
3759 <tt/mouse_show/. The mouse cursor is visible if there was one more call to
3760 <tt/mouse_show/ than to <tt/<ref id="mouse_hide" name="mouse_hide">/.
3761 <tag/Limits/<itemize>
3762 <item>The function is only available as fastcall function, so it may only be
3763 used in presence of a prototype.
3765 <tag/Availability/cc65
3767 <ref id="mouse_hide" name="mouse_hide">
3773 <sect1>mouse_uninstall<label id="mouse_uninstall"><p>
3777 <tag/Function/Uninstall an already loaded mouse driver.
3778 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3779 <tag/Declaration/<tt/unsigned char __fastcall__ mouse_install (void);/
3780 <tag/Description/The function uninstalls an already loaded mouse driver but
3781 don't removes it from memory.
3782 <tag/Limits/<itemize>
3783 <item>If the driver has been loaded using <tt/<ref id="mouse_load_driver"
3784 name="mouse_load_driver">/, <tt/<ref id="mouse_unload" name="mouse_unload">/
3785 should be used instead of <tt/mouse_uninstall/ so the driver is also removed
3787 <item>The function is only available as fastcall function, so it may only be
3788 used in presence of a prototype.
3790 <tag/Availability/cc65
3792 <ref id="mouse_install" name="mouse_install">,
3793 <ref id="mouse_load_driver" name="mouse_load_driver">,
3794 <ref id="mouse_unload" name="mouse_unload">
3800 <sect1>mouse_unload<label id="mouse_unload"><p>
3804 <tag/Function/Unload a mouse driver.
3805 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3806 <tag/Declaration/<tt/unsigned char __fastcall__ mouse_unload (void);/
3807 <tag/Description/The function unloads a loaded mouse driver and frees all
3808 memory allocated for the driver.
3809 <tag/Limits/<itemize>
3810 <item>The function does nothing if no driver is loaded.
3812 <tag/Availability/cc65
3814 <ref id="mouse_install" name="mouse_install">,
3815 <ref id="mouse_load_driver" name="mouse_load_driver">,
3816 <ref id="mouse_uninstall" name="mouse_uninstall">
3822 <sect1>offsetof<label id="offsetof"><p>
3826 <tag/Function/Calculate the offset of a struct or union member.
3827 <tag/Header/<tt/<ref id="stddef.h" name="stddef.h">/
3828 <tag/Declaration/<tt/size_t offsetof (type, member);/
3829 <tag/Description/<tt/offsetof/ calculates the address offset of a <tt/struct/
3830 or <tt/union/ member.
3831 <tag/Limits/<itemize>
3832 <item>The function is actually a macro.
3834 <tag/Availability/ISO 9899
3840 <sect1>open<label id="open"><p>
3844 <tag/Function/Open and possibly create a file.
3845 <tag/Header/<tt/<ref id="fcntl.h" name="fcntl.h">/
3846 <tag/Declaration/<tt/int open (const char* name, int flags, ...);/
3847 <tag/Description/<tt/open/ opens a file and returns the file descriptor
3848 associated with it. On error, -1 is returned and an error code is stored in
3849 <tt/errno/. Several flags may be passed to <tt/open/ that change the behaviour.
3850 <tag/Limits/<itemize>
3851 <item>POSIX specifies an additional <tt/mode/ argument that may be passed to
3852 open, which is used as the permission mask when a new file is created. While
3853 cc65 allows to pass this argument, it is ignored.
3855 <tag/Availability/POSIX 1003.1
3857 <ref id="close" name="close">,
3858 <ref id="creat" name="creat">
3864 <sect1>peekbsys<label id="peekbsys"><p>
3868 <tag/Function/Read one byte from a location in the system bank.
3869 <tag/Header/<tt/<ref id="cbm610.h" name="cbm610.h">/,
3870 <tt/<ref id="cbm510.h" name="cbm510.h">/
3871 <tag/Declaration/<tt/unsigned char __fastcall__ peekbsys (unsigned addr);/
3872 <tag/Description/<tt/peekbsys/ reads one byte from the given address in the
3873 system bank (bank 15) of the CBM PET-II machines and returns it.
3876 <item>The function is only available as fastcall function, so it may only
3877 be used in presence of a prototype.
3878 <item>This function may be a macro depending on the compiler options. The
3879 actual function is accessible by #undef'ing the macro.
3881 <tag/Availability/cc65
3883 <ref id="PEEK" name="PEEK">,
3884 <ref id="PEEKW" name="PEEKW">,
3885 <ref id="peekwsys" name="peekwsys">,
3886 <ref id="pokebsys" name="pokebsys">,
3887 <ref id="pokewsys" name="pokewsys">
3893 <sect1>peekwsys<label id="peekwsys"><p>
3897 <tag/Function/Read one word from a location in the system bank.
3898 <tag/Header/<tt/<ref id="cbm610.h" name="cbm610.h">/,
3899 <tt/<ref id="cbm510.h" name="cbm510.h">/
3900 <tag/Declaration/<tt/unsigned __fastcall__ peekwsys (unsigned addr);/
3901 <tag/Description/<tt/peekwsys/ reads one word from the given address in the
3902 system bank (bank 15) of the CBM PET-II machines and returns it. Following
3903 the usual 6502 conventions, the low byte is read from <tt/addr/, and the
3904 high byte is read from <tt/addr+1/.
3907 <item>The function is only available as fastcall function, so it may only
3908 be used in presence of a prototype.
3909 <item>The order in which the two bytes are read is undefined.
3911 <tag/Availability/cc65
3913 <ref id="PEEK" name="PEEK">,
3914 <ref id="PEEKW" name="PEEKW">,
3915 <ref id="peekbsys" name="peekbsys">,
3916 <ref id="pokebsys" name="pokebsys">,
3917 <ref id="pokewsys" name="pokewsys">
3923 <sect1>perror<label id="perror"><p>
3927 <tag/Function/Print an error message for the error in <tt/errno/.
3928 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
3929 <tag/Declaration/<tt/void __fastcall__ perror (const char* s);/
3930 <tag/Description/<tt/perror/ prints an error message to <tt/stderr/. If <tt/s/
3931 is not <tt/NULL/ and not an empty string, it is printed followed by a colon and
3932 a blank. Then the error message for the current contents of <tt/errno/ is
3933 printed followed by a newline. The message output is the same as returned by
3934 <tt/<ref id="strerror" name="strerror">/ with an argument of <tt/errno/.
3937 <item>The function is only available as fastcall function, so it may only
3938 be used in presence of a prototype.
3940 <tag/Availability/ISO 9899
3942 <ref id="_poserror" name="_poserror">,
3943 <ref id="strerror" name="strerror">
3949 <sect1>pokebsys<label id="pokebsys"><p>
3953 <tag/Function/Write one byte to a location in the system bank.
3954 <tag/Header/<tt/<ref id="cbm610.h" name="cbm610.h">/,
3955 <tt/<ref id="cbm510.h" name="cbm510.h">/
3956 <tag/Declaration/<tt/void __fastcall__ pokebsys (unsigned addr, unsigned char val);/
3957 <tag/Description/<tt/pokebsys/ writes one byte to the given address in the
3958 system bank (bank 15) of the CBM PET-II machines.
3961 <item>The function is only available as fastcall function, so it may only
3962 be used in presence of a prototype.
3964 <tag/Availability/cc65
3966 <ref id="POKE" name="POKE">,
3967 <ref id="POKEW" name="POKEW">,
3968 <ref id="peekbsys" name="peekbsys">,
3969 <ref id="peekwsys" name="peekwsys">,
3970 <ref id="pokewsys" name="pokewsys">
3976 <sect1>pokewsys<label id="pokewsys"><p>
3980 <tag/Function/Write one word to a location in the system bank.
3981 <tag/Header/<tt/<ref id="cbm610.h" name="cbm610.h">/,
3982 <tt/<ref id="cbm510.h" name="cbm510.h">/
3983 <tag/Declaration/<tt/void __fastcall__ pokewsys (unsigned addr, unsigned val);/
3984 <tag/Description/<tt/pokewsys/ writes one word to the given address in the
3985 system bank (bank 15) of the CBM PET-II machines. Following the usual 6502
3986 conventions, the low byte of <tt/val/ is written to <tt/addr/, and the
3987 high byte is written to <tt/addr+1/.
3990 <item>The function is only available as fastcall function, so it may only
3991 be used in presence of a prototype.
3992 <item>The order in which the two bytes are written is undefined.
3994 <tag/Availability/cc65
3996 <ref id="POKE" name="POKE">,
3997 <ref id="POKEW" name="POKEW">,
3998 <ref id="peekbsys" name="peekbsys">,
3999 <ref id="peekwsys" name="peekwsys">,
4000 <ref id="pokebsys" name="pokebsys">
4006 <sect1>qsort<label id="qsort"><p>
4010 <tag/Function/Sort an array.
4011 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
4012 <tag/Declaration/<tt/void __fastcall__ qsort (void* base, size_t count,
4013 size_t size, int (*compare) (const void*, const void*));/
4014 <tag/Description/<tt/qsort/ sorts an array according to a given compare
4015 function <tt/compare/. <tt/base/ is the address of the array, <tt/count/
4016 is the number of elements, <tt/size/ the size of an element and <tt/compare/
4017 the function used to compare the members.
4020 <item>If there are multiple members with the same key, the order after calling
4021 the function is undefined.
4022 <item>The function is only available as fastcall function, so it may only
4023 be used in presence of a prototype.
4025 <tag/Availability/ISO 9899
4027 <ref id="bsearch" name="bsearch">
4033 <sect1>raise<label id="raise"><p>
4037 <tag/Function/Send a signal to the executing program.
4038 <tag/Header/<tt/<ref id="signal.h" name="signal.h">/
4039 <tag/Declaration/<tt/int __fastcall__ raise (int sig);/
4040 <tag/Description/<tt/raise/ sends the given signal to the program. If the
4041 program has installed a signal handler for the signal, this signal handler
4042 will be executed. If no handler has been installed, the default action for
4043 the raised signal will be taken. The function returns zero on success,
4045 <tag/Limits/<itemize>
4046 <item>The function is only available as fastcall function, so it may only
4047 be used in presence of a prototype.
4049 <tag/Availability/ISO 9899
4051 <ref id="abort" name="abort">,
4052 <ref id="signal" name="signal">
4058 <sect1>rand<label id="rand"><p>
4062 <tag/Function/Return a pseudo random number.
4063 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
4064 <tag/Declaration/<tt/int rand (void);/
4065 <tag/Description/The function returns a pseudo random number
4066 between 0 and <tt/RAND_MAX/ (exclusive).
4067 <tag/Limits/<itemize>
4068 <item>Without using <tt><ref id="srand" name="srand"></tt>, always the same
4069 flow of numbers is generated.
4070 <item>On startup, the function behaves as if <ref id="srand" name="srand">
4071 had been used with an argument of 1.
4073 <tag/Availability/ISO 9899
4075 <ref id="_randomize" name="_randomize">,
4076 <ref id="srand" name="srand">
4082 <sect1>realloc<label id="realloc"><p>
4086 <tag/Function/Change the size of an allocated memory block.
4087 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
4088 <tag/Declaration/<tt/void* __fastcall__ realloc (void* block, size_t size);/
4089 <tag/Description/<tt/realloc/ changes the size of the memory block pointed to
4090 by <tt/block/ to <tt/size/ bytes. If <tt/block/ is <tt/NULL/, <tt/realloc/
4091 behaves as if <tt/malloc/ had been called. If <tt/size/ is zero, <tt/realloc/
4092 behaves as if <tt/free/ had been called. On error (not enough memory
4093 available), <tt/realloc/ returns <tt/NULL/.
4096 <item>The part of the memory block that is returned will have its contents
4098 <item>This function is somewhat dangerous to use. Be careful to save the
4099 pointer you're passing somewhere else, otherwise
4101 ptr = realloc (ptr, size);
4103 will loose your only copy of <tt/ptr/ if <tt/realloc/ returns <tt/NULL/.
4104 <item>The function is only available as fastcall function, so it may only
4105 be used in presence of a prototype.
4107 <tag/Availability/ISO 9899
4109 <ref id="_heapadd" name="_heapadd">,
4110 <ref id="_heapblocksize" name="_heapblocksize">,
4111 <ref id="_heapmaxavail" name="_heapmaxavail">,
4112 <ref id="_heapmemavail" name="_heapmemavail">,
4113 <ref id="calloc" name="calloc">,
4114 <ref id="free" name="free">,
4115 <ref id="realloc" name="realloc">
4121 <sect1>remove<label id="remove"><p>
4125 <tag/Function/Delete a file.
4126 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
4127 <tag/Declaration/<tt/int __fastcall__ remove (const char* name);/
4128 <tag/Description/<tt/remove/ deletes the file with the given name. On success,
4129 zero is returned. On error, -1 is returned and <tt/errno/ is set to an error
4130 code describing the reason for the failure.
4133 <item>This function is not available on all cc65 targets (depends on the
4134 availability of file I/O).
4135 <item>The function is only available as fastcall function, so it may only
4136 be used in presence of a prototype.
4138 <tag/Availability/ISO 9899
4140 <ref id="rename" name="rename">,
4141 <ref id="unlink" name="unlink">
4144 #include <stdio.h>
4146 #define FILENAME "helloworld"
4148 if (remove (FILENAME) == 0) {
4149 printf ("We deleted %s successfully\n", FILENAME);
4151 printf ("There was a problem deleting %s\n", FILENAME);
4158 <sect1>rename<label id="rename"><p>
4162 <tag/Function/Rename a file.
4163 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
4164 <tag/Declaration/<tt/int __fastcall__ rename (const char* oldname, const char* newname);/
4165 <tag/Description/<tt/rename/ renames a file (gives it a new name). On success,
4166 zero is returned. On error, -1 is returned and <tt/errno/ is set to an error
4167 code describing the reason for the failure.
4170 <item>This function is not available on all cc65 targets (depends on the
4171 capabilities of the storage devices).
4172 <item>The function is only available as fastcall function, so it may only
4173 be used in presence of a prototype.
4175 <tag/Availability/ISO 9899
4177 <ref id="remove" name="remove">
4180 #include <stdio.h>
4182 #define OLDNAME "textfile.txt"
4183 #define NEWNAME "textfile.bak"
4185 if (rename (OLDNAME, NEWNAME) == 0) {
4186 printf ("Renamed %s to %s\n", OLDNAME, NEWNAME);
4188 printf ("Error renaming %s to %s\n", OLDNAME, NEWNAME);
4195 <sect1>reset_brk<label id="reset_brk"><p>
4199 <tag/Function/Resets the break vector to its original value.
4200 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
4201 <tag/Declaration/<tt/void reset_brk (void);/
4202 <tag/Description/<tt/reset_brk/ resets the break vector to the value it had
4203 before a call to <tt/set_brk/.
4206 <item>Since <tt/<ref id="set_brk" name="set_brk">/ installs an exit handler,
4207 it is not strictly necessary to call this function as part of the cleanup when
4210 <tag/Availability/cc65
4212 <ref id="set_brk" name="set_brk">
4218 <sect1>reset_irq<label id="reset_irq"><p>
4222 <tag/Function/Resets the C level interrupt request vector.
4223 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
4224 <tag/Declaration/<tt/void reset_irq (void);/
4225 <tag/Description/<tt/reset_irq/ resets the C level interrupt request vector.
4226 <tag/Availability/cc65
4228 <ref id="set_irq" name="set_irq">
4234 <sect1>revers<label id="revers"><p>
4238 <tag/Function/Control revers character display.
4239 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
4240 <tag/Declaration/<tt/unsigned char __fastcall__ revers (unsigned char onoff);/
4241 <tag/Description/If the argument is non zero, the function enables reverse
4242 character display. If the argument is zero, reverse character display is
4243 switched off. The old value of the setting is returned.
4244 <tag/Limits/<itemize>
4245 <item>The function may not be supported by the hardware, in which case
4246 the call is ignored.
4247 <item>The function is only available as fastcall function, so it may only
4248 be used in presence of a prototype.
4250 <tag/Availability/cc65
4252 <ref id="textcolor" name="textcolor">
4258 <sect1>screensize<label id="screensize"><p>
4262 <tag/Function/Return the dimensions of the text mode screen.
4263 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
4264 <tag/Declaration/<tt/void __fastcall__ screensize (unsigned char* x, unsigned char* y);/
4265 <tag/Description/The function returns the dimensions of the text mode screen.
4266 <tag/Limits/<itemize>
4267 <item>The function is only available as fastcall function, so it may only
4268 be used in presence of a prototype.
4270 <tag/Availability/cc65
4272 <ref id="gotox" name="gotox">,
4273 <ref id="gotoxy" name="gotoxy">,
4274 <ref id="gotoy" name="gotoy">,
4275 <ref id="wherex" name="wherex">,
4276 <ref id="wherey" name="wherey">
4282 <sect1>ser_close<label id="ser_close"><p>
4286 <tag/Function/Close the port and disable interrupts
4287 <tag/Header/<tt/<ref id="serial.h" name="serial.h">/
4288 <tag/Declaration/<tt/unsigned char __fastcall__ ser_close (const struct ser_params* params);/
4289 <tag/Description/Open the port by setting the port parameters and enable interrupts.
4290 <tag/Limits/<itemize>
4291 <item>The function is only available as fastcall function, so it may only
4292 be used in presence of a prototype.
4294 <tag/Availability/cc65
4295 <tag/See also/Other serial functions.
4300 extern char comlynx[];
4302 static void initialize(){
4303 struct ser_params params = {
4310 ser_install(&comlynx); // This will activate the ComLynx
4312 ser_open(&params);
4319 <sect1>ser_get<label id="ser_get"><p>
4323 <tag/Function/Read a character from serial port.
4324 <tag/Header/<tt/<ref id="serial.h" name="serial.h">/
4325 <tag/Declaration/<tt/unsigned char __fastcall__ ser_get (char* b);/
4326 <tag/Description/Get a character from the serial port. If no characters are
4327 available, the function will return SER_ERR_NO_DATA, so this is not a fatal
4329 <tag/Limits/<itemize>
4330 <item>The function is only available as fastcall function, so it may only
4331 be used in presence of a prototype.
4333 <tag/Availability/cc65
4334 <tag/See also/Other serial functions.
4336 Wait for a character to be available from a serial port.
4339 while (ser_get(&ch) == SER_ERR_NO_DATA)
4346 <sect1>ser_install<label id="ser_install"><p>
4350 <tag/Function/Install an already loaded driver and return an error code.
4351 <tag/Header/<tt/<ref id="serial.h" name="serial.h">/
4352 <tag/Declaration/<tt/unsigned char __fastcall__ ser_install (void* driver);/
4353 <tag/Description/The function installs a driver that was already loaded into
4354 memory (or linked statically to the program). It returns an error code
4355 (<tt/SER_ERR_OK/ in case of success).
4356 <tag/Limits/<itemize>
4357 <item>The function is only available as fastcall function, so it may only be
4358 used in presence of a prototype.
4360 <tag/Availability/cc65
4362 <ref id="ser_load_driver" name="ser_load_driver">,
4363 <ref id="ser_uninstall" name="ser_uninstall">,
4364 <ref id="ser_unload" name="ser_unload">
4366 extern char lynxser[]; //Include the driver statically instead of loading it.
4368 ser_install(&lynxser);
4374 <sect1>ser_ioctl<label id="ser_ioctl"><p>
4378 <tag/Function/Platform dependent code extensions.
4379 <tag/Header/<tt/<ref id="serial.h" name="serial.h">/
4380 <tag/Declaration/<tt/unsigned __fastcall__ ser_ioctl (unsigned char code, void* data);/
4381 <tag/Description/Some platforms have extra serial functions that are not
4382 supported by standard serial driver functions. You can extend the driver to support
4383 this extra functionality bt using ser_ioctl functions.
4384 <tag/Limits/<itemize>
4385 <item>The function is only available as fastcall function, so it may only
4386 be used in presence of a prototype.
4387 <item>These functions are not easily portable to other cc65 platforms.
4389 <tag/Availability/cc65
4390 <tag/See also/Other serial functions.
4395 <sect1>ser_load_driver<label id="ser_load_driver"><p>
4399 <tag/Function/Load and install a serial driver.
4400 <tag/Header/<tt/<ref id="serial.h" name="serial.h">/
4401 <tag/Declaration/<tt/void __fastcall__ ser_load_driver (const char *name);/
4402 <tag/Description/Load and install the driver by name.
4403 Will just load the driver and check if loading was successful.
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.
4415 <sect1>ser_open<label id="ser_open"><p>
4419 <tag/Function/Open the port by setting the port parameters and enable interrupts
4420 <tag/Header/<tt/<ref id="serial.h" name="serial.h">/
4421 <tag/Declaration/<tt/unsigned char __fastcall__ ser_open (const struct ser_params* params);/
4422 <tag/Description/Open the port by setting the port parameters and enable interrupts.
4423 <tag/Limits/<itemize>
4424 <item>The function is only available as fastcall function, so it may only
4425 be used in presence of a prototype.
4427 <tag/Availability/cc65
4428 <tag/See also/Other serial functions.
4433 extern char comlynx[];
4435 static void initialize(){
4436 struct ser_params params = {
4443 ser_install(&comlynx); // This will activate the ComLynx
4445 ser_open(&params);
4452 <sect1>ser_put<label id="ser_put"><p>
4456 <tag/Function/Write a character to a serial port.
4457 <tag/Header/<tt/<ref id="serial.h" name="serial.h">/
4458 <tag/Declaration/<tt/unsigned char __fastcall__ ser_put (char b);/
4459 <tag/Description/Send a character via the serial port. There is a transmit
4460 buffer, but transmitting is not done via interrupt. The function returns
4461 SER_ERR_OVERFLOW if there is no space left in the transmit buffer.
4462 <tag/Limits/<itemize>
4463 <item>The function is only available as fastcall function, so it may only
4464 be used in presence of a prototype.
4466 <tag/Availability/cc65
4467 <tag/See also/Other serial functions.
4476 <sect1>ser_status<label id="ser_status"><p>
4480 <tag/Function/Return the serial port status.
4481 <tag/Header/<tt/<ref id="serial.h" name="serial.h">/
4482 <tag/Declaration/<tt/unsigned char __fastcall__ ser_put (unsigned char* status);/
4483 <tag/Description/Return the serial port status.
4484 <tag/Limits/<itemize>
4485 <item>The function is only available as fastcall function, so it may only
4486 be used in presence of a prototype.
4488 <tag/Availability/cc65
4489 <tag/See also/Other serial functions.
4495 <sect1>ser_uninstall<label id="ser_uninstall"><p>
4499 <tag/Function/Uninstall the currently loaded driver but do not unload it.
4500 <tag/Header/<tt/<ref id="serial.h" name="serial.h">/
4501 <tag/Declaration/<tt/void __fastcall__ ser_uninstall (void);/
4502 <tag/Description/Uninstall the currently loaded driver but do not unload it.
4503 <tag/Limits/<itemize>
4504 <item>The function is only available as fastcall function, so it may only
4505 be used in presence of a prototype.
4507 <tag/Availability/cc65
4508 <tag/See also/Other serial functions.
4513 <sect1>ser_unload<label id="ser_unload"><p>
4517 <tag/Function/Uninstall, then unload the currently loaded driver.
4518 <tag/Header/<tt/<ref id="serial.h" name="serial.h">/
4519 <tag/Declaration/<tt/void __fastcall__ ser_unload (void);/
4520 <tag/Description/Uninstall, then unload the currently loaded driver.
4521 <tag/Limits/<itemize>
4522 <item>The function is only available as fastcall function, so it may only
4523 be used in presence of a prototype.
4525 <tag/Availability/cc65
4526 <tag/See also/Other serial functions.
4532 <sect1>set_brk<label id="set_brk"><p>
4536 <tag/Function/Set the break vector to a user function.
4537 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
4538 <tag/Declaration/<tt/void __fastcall__ set_brk (brk_handler func);/
4539 <tag/Description/<tt/set_brk/ allows a user program to handle breaks within the
4540 program code by letting the vector point to a user written C function. The
4541 runtime library installs a small stub that saves the registers into global
4542 variables that may be accessed (and changed) by the break handler.
4545 <item>The function is only available as fastcall function, so it may only
4546 be used in presence of a prototype.
4547 <item>The stub saves the zero page registers used by the C runtime and switches
4548 to a small break handler stack. This means that it is safe to execute C code,
4549 even if C code was interrupted. Be careful however not to use too many local
4550 variables, and do not enable stack checks for the handler function or any other
4551 function called from it.
4552 <item>The <tt/brk_pc/ variable points to the <tt/BRK/ instruction. If you want
4553 the continue with the interrupted code, you have to adjust <tt/brk_pc/,
4554 otherwise the <tt/BRK/ instruction will get executed over and over again.
4555 <item>Since <tt/set_brk/ installs an exit handler, it is not strictly necessary
4556 to call <tt/<ref id="reset_brk" name="reset_brk">/ as part of the cleanup when
4557 the program terminates.
4559 <tag/Availability/cc65
4561 <ref id="reset_brk" name="reset_brk">
4567 <sect1>set_irq<label id="set_irq"><p>
4571 <tag/Function/Set the C level interrupt request vector to the given address.
4572 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
4573 <tag/Declaration/<tt/void __fastcall__ set_irq (irq_handler f, void *stack_addr, size_t stack_size);/
4574 <tag/Description/<tt/set_irq/ allows a user program to handle interrupt requests
4575 (IRQs) within the program code by letting the vector point to a user written C
4576 function. The runtime library installs a small stub that saves the zero page
4577 registers used by the C runtime before calling the handler function and restores
4578 them after the handler function returns. Additionally the stub temporarily switches
4579 the C runtime stack to the stack area provided as parameter. If the handler function
4580 was set up to handle a "private", "exclusive" interrupt request source it must
4581 return the value <tt/IRQ_HANDLED/ if and only if it has verified that the current
4582 interrupt request actually stems from that source. In all other cases it must return
4583 the value <tt/IRQ_NOT_HANDLED/.
4586 <item>The function is only available as fastcall function, so it may only
4587 be used in presence of a prototype.
4588 <item>The stub saves the zero page registers used by the C runtime and switches
4589 to the provided stack area. This means that it is safe to execute C code,
4590 even if C code was interrupted. Be careful however not to call into the C library,
4591 and do not enable stack checks for the handler function or any other function called
4594 <tag/Availability/cc65
4596 <ref id="reset_irq" name="reset_irq">
4602 <sect1>setjmp<label id="setjmp"><p>
4606 <tag/Function/Save the context for use with <tt/longjmp/.
4607 <tag/Header/<tt/<ref id="setjmp.h" name="setjmp.h">/
4608 <tag/Declaration/<tt/int __fastcall__ setjmp (jmp_buf buf);/
4609 <tag/Description/The <tt/setjmp/ function saves the current context in <tt/buf/
4610 for subsequent use by the <tt/<ref id="longjmp" name="longjmp">/ function and
4614 <item>The function is only available as fastcall function, so it may only
4615 be used in presence of a prototype.
4616 <item><tt/setjmp/ is actually a macro as required by the ISO standard.
4617 <item><tt/setjmp/ will not save the signal context.
4619 <tag/Availability/ISO 9899
4621 <ref id="longjmp" name="longjmp">
4627 <sect1>setlocale<label id="setlocale"><p>
4631 <tag/Function/Selects a locale.
4632 <tag/Header/<tt/<ref id="locale.h" name="locale.h">/
4633 <tag/Declaration/<tt/char* __fastcall__ setlocale (int category, const char* locale);/
4634 <tag/Description/<tt/setlocale/ sets or queries the program's locale.
4637 <item>The function is only available as fastcall function, so it may only
4638 be used in presence of a prototype.
4639 <item>cc65 supports only the "C" locale, so calling this function to set a
4640 different locale has no effect.
4642 <tag/Availability/ISO 9899
4644 <ref id="localeconv" name="localeconv">,
4645 <ref id="strcoll" name="strcoll">
4646 <ref id="strxfrm" name="strxfrm">
4652 <sect1>signal<label id="signal"><p>
4656 <tag/Function/Install a signal handler.
4657 <tag/Header/<tt/<ref id="signal.h" name="signal.h">/
4658 <tag/Declaration/<tt/__sigfunc __fastcall__ signal (int sig, __sigfunc func);/
4659 <tag/Description/<tt/signal/ installs a handler for the given signal. The
4660 handler may either be a user supplied function, or one of the predefined
4661 signal handlers <tt/SIG_IGN/ or <tt/SIG_DFL/. The function returns the
4662 previous value if the signal , or the special function vector SIG_ERR in
4664 <tag/Limits/<itemize>
4665 <item>The function is only available as fastcall function, so it may only
4666 be used in presence of a prototype.
4668 <tag/Availability/ISO 9899
4670 <ref id="abort" name="abort">,
4671 <ref id="raise" name="raise">
4677 <sect1>sleep<label id="sleep"><p>
4681 <tag/Function/Sleep for a specified amount of time.
4682 <tag/Header/<tt/<ref id="unistd.h" name="unistd.h">/
4683 <tag/Declaration/<tt/void __fastcall__ sleep (unsigned seconds);/
4684 <tag/Description/The function will return after the specified number of
4685 seconds have elapsed.
4686 <tag/Limits/<itemize>
4687 <item>The function is only available as fastcall function, so it may only
4688 be used in presence of a prototype.
4690 <tag/Availability/POSIX 1003.1
4696 <sect1>slow<label id="slow"><p>
4700 <tag/Function/Switch the C128 into 1MHz mode.
4701 <tag/Header/<tt/<ref id="c128.h" name="c128.h">/
4702 <tag/Declaration/<tt/void slow (void);/
4703 <tag/Description/The function will switch the clock of the C128 to 1MHz. This
4704 will halve the speed compared to fast mode.
4705 <tag/Limits/<itemize>
4706 <item>The function is specific to the C128.
4708 <tag/Availability/C128
4710 <ref id="fast" name="fast">,
4711 <ref id="toggle_videomode" name="toggle_videomode">,
4712 <ref id="videomode" name="videomode">
4718 <sect1>srand<label id="srand"><p>
4722 <tag/Function/Initialize the pseudo random number generator.
4723 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
4724 <tag/Declaration/<tt/void __fastcall__ srand (unsigned seed);/
4725 <tag/Description/The function initializes the random number generator using
4726 the given seed. On program startup, the generator behaves as if <tt/srand/ has
4727 been called with an argument of 1.
4728 <tag/Limits/<itemize>
4729 <item>The function is only available as fastcall function, so it may only
4730 be used in presence of a prototype.
4732 <tag/Availability/ISO 9899
4734 <ref id="_randomize" name="_randomize">,
4735 <ref id="rand" name="rand">
4741 <sect1>strcasecmp<label id="strcasecmp"><p>
4745 <tag/Function/Compare two strings case insensitive.
4746 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4747 <tag/Declaration/<tt/int __fastcall__ strcasecmp (const char* s1, const char* s2);/
4748 <tag/Description/The <tt/strcasecmp/ function compares the two strings passed
4749 as parameters without case sensitivity. It returns a value that is less than
4750 zero if <tt/s1/ is less than <tt/s2/, zero if <tt/s1/ is the same as <tt/s2/,
4751 and a value greater than zero if <tt/s1/ is greater than <tt/s2/.
4752 <tag/Limits/<itemize>
4753 <item>The function is only available as fastcall function, so it may only
4754 be used in presence of a prototype.
4755 <item>The function is not available in strict ANSI mode.
4757 <tag/Availability/cc65
4759 <ref id="strcmp" name="strcmp">,
4760 <ref id="strcoll" name="strcoll">,
4761 <ref id="stricmp" name="stricmp">,
4762 <ref id="strncmp" name="strncmp">,
4763 <ref id="strxfrm" name="strxfrm">
4769 <sect1>strcat<label id="strcat"><p>
4773 <tag/Function/Concatentate two strings.
4774 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4775 <tag/Declaration/<tt/char* __fastcall__ strcat (char* s1, const char* s2);/
4776 <tag/Description/The <tt/strcat/ function appends a copy of the string
4777 pointed to by s2 (including the terminating null byte) to the end of the
4778 string pointed to by s1. The initial byte of s2 overwrites the null byte at
4780 <tag/Limits/<itemize>
4781 <item>The function is only available as fastcall function, so it may only
4782 be used in presence of a prototype.
4783 <item>If copying takes place between objects that overlap, the behaviour
4786 <tag/Availability/ISO 9899
4788 <ref id="strcpy" name="strcpy">,
4789 <ref id="strncat" name="strncat">,
4790 <ref id="strncpy" name="strncpy">
4796 <sect1>strchr<label id="strchr"><p>
4800 <tag/Function/Search for a character in a string.
4801 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4802 <tag/Declaration/<tt/char* __fastcall__ strchr (const char* s, int c);/
4803 <tag/Description/The <tt/strchr/ function locates the first occurrence of <tt/c/
4804 (converted to a char) in the string pointed to by <tt/s/. The terminating null
4805 byte is considered to be part of the string. Upon completion, the function
4806 returns a pointer to the byte, or a null pointer if the byte was not found.
4807 <tag/Limits/<itemize>
4808 <item>The function is only available as fastcall function, so it may only
4809 be used in presence of a prototype.
4811 <tag/Availability/ISO 9899
4813 <ref id="memchr" name="memchr">,
4814 <ref id="strrchr" name="strrchr">
4820 <sect1>strcmp<label id="strcmp"><p>
4824 <tag/Function/Compare two strings.
4825 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4826 <tag/Declaration/<tt/int __fastcall__ strcmp (const char* s1, const char* s2);/
4827 <tag/Description/The <tt/strcmp/ function compares the two strings passed as
4828 parameters. It returns a value that is less than zero if <tt/s1/ is less than
4829 <tt/s2/, zero if <tt/s1/ is the same as <tt/s2/, and a value greater than zero
4830 if <tt/s1/ is greater than <tt/s2/.
4831 <tag/Limits/<itemize>
4832 <item>The function is only available as fastcall function, so it may only
4833 be used in presence of a prototype.
4835 <tag/Availability/ISO 9899
4837 <ref id="strcasecmp" name="strcasecmp">,
4838 <ref id="strcoll" name="strcoll">,
4839 <ref id="stricmp" name="stricmp">,
4840 <ref id="strncmp" name="strncmp">
4841 <ref id="strxfrm" name="strxfrm">
4847 <sect1>strcoll<label id="strcoll"><p>
4851 <tag/Function/Compare two strings.
4852 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4853 <tag/Declaration/<tt/int __fastcall__ strcoll (const char* s1, const char* s2);/
4854 <tag/Description/The <tt/strcoll/ function compares the two strings passed as
4855 parameters, according to the collating sequence set by <tt/<ref id="setlocale"
4856 name="setlocale">/. It returns a value that is less than zero if <tt/s1/ is
4857 less than <tt/s2/, zero if <tt/s1/ is the same as <tt/s2/, and a value greater
4858 than zero if <tt/s1/ is greater than <tt/s2/.
4859 <tag/Limits/<itemize>
4860 <item>The function is only available as fastcall function, so it may only
4861 be used in presence of a prototype.
4863 <tag/Availability/ISO 9899
4865 <ref id="setlocale" name="setlocale">,
4866 <ref id="strcasecmp" name="strcasecmp">,
4867 <ref id="strcmp" name="strcmp">,
4868 <ref id="stricmp" name="stricmp">,
4869 <ref id="strncmp" name="strncmp">,
4870 <ref id="strxfrm" name="strxfrm">
4876 <sect1>strcpy<label id="strcpy"><p>
4880 <tag/Function/Copy a string.
4881 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4882 <tag/Declaration/<tt/char* __fastcall__ strcpy (char* s1, const char* s2);/
4883 <tag/Description/The <tt/strcpy/ function copies the string pointed to by
4884 <tt/s2/ (including the terminating null byte) into the array pointed to by
4885 <tt/s1/. The function will always return <tt/s1/.
4886 <tag/Limits/<itemize>
4887 <item>The function is only available as fastcall function, so it may only
4888 be used in presence of a prototype.
4889 <item>If copying takes place between objects that overlap, the behaviour
4892 <tag/Availability/ISO 9899
4894 <ref id="strcat" name="strcat">,
4895 <ref id="strncat" name="strncat">,
4896 <ref id="strncpy" name="strncpy">
4899 #include <string.h>
4901 static char hello[14];
4903 strcpy (hello, "Hello world!\n");
4909 <sect1>strcspn<label id="strcspn"><p>
4913 <tag/Function/Compute the length of a substring.
4914 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4915 <tag/Declaration/<tt/size_t __fastcall__ strcspn (const char* s, const char* set);/
4916 <tag/Description/The <tt/strcspn/ function computes and returns the length of
4917 the substring pointed to by <tt/s/ which does <em>not</em> consist of
4918 characters contained in the string <tt/set/.
4919 <tag/Limits/<itemize>
4920 <item>The function is only available as fastcall function, so it may only
4921 be used in presence of a prototype.
4923 <tag/Availability/ISO 9899
4925 <ref id="strspn" name="strspn">,
4926 <ref id="strstr" name="strstr">,
4927 <ref id="strtok" name="strtok">
4933 <sect1>strdup<label id="strdup"><p>
4937 <tag/Function/Allocate a copy of a string on the heap.
4938 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4939 <tag/Declaration/<tt/char* __fastcall__ strdup (const char* s);/
4940 <tag/Description/<tt/strdup/ allocates a memory block on the heap, big enough
4941 to hold a copy of <tt/s/ including the terminating zero. If the allocation
4942 fails, <tt/NULL/ is returned, otherwise <tt/s/ is copied into the allocated
4943 memory block, and a pointer to the block is returned.
4944 <tag/Limits/<itemize>
4945 <item>The function is only available as fastcall function, so it may only
4946 be used in presence of a prototype.
4947 <item>It is up to the caller to free the allocated memory block.
4949 <tag/Availability/ISO 9899
4951 <ref id="free" name="free">,
4952 <ref id="malloc" name="malloc">
4958 <sect1>strerror<label id="strerror"><p>
4962 <tag/Function/Return a string describing an error code.
4963 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4964 <tag/Declaration/<tt/char* __fastcall__ strerror (int errcode);/
4965 <tag/Description/The <tt/strerror/ function returns a string describing the
4966 given error code. If an invalid error code is passed, the string "Unknown
4967 error" is returned, and <tt/errno/ is set to <tt/EINVAL/. In all other cases,
4968 <tt/errno/ is left untouched.
4969 <tag/Limits/<itemize>
4970 <item>The function is only available as fastcall function, so it may only
4971 be used in presence of a prototype.
4972 <item>While the return type of the function is a <tt/char*/, the returned
4973 string must not be modified by the caller!
4975 <tag/Availability/ISO 9899
4977 <ref id="_stroserror" name="_stroserror">
4983 <sect1>stricmp<label id="stricmp"><p>
4987 <tag/Function/Compare two strings case insensitive.
4988 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4989 <tag/Declaration/<tt/int __fastcall__ stricmp (const char* s1, const char* s2);/
4990 <tag/Description/The <tt/stricmp/ function compares the two strings passed as
4991 parameters without case sensitivity. It returns a value that is less than zero
4992 if <tt/s1/ is less than <tt/s2/, zero if <tt/s1/ is the same as <tt/s2/, and a
4993 value greater than zero if <tt/s1/ is greater than <tt/s2/.
4994 <tag/Limits/<itemize>
4995 <item>The function is only available as fastcall function, so it may only
4996 be used in presence of a prototype.
4997 <item>The function is not available in strict ANSI mode.
4999 <tag/Availability/cc65
5001 <ref id="strcasecmp" name="strcasecmp">,
5002 <ref id="strcmp" name="strcmp">,
5003 <ref id="strcoll" name="strcoll">,
5004 <ref id="strncmp" name="strncmp">,
5005 <ref id="strxfrm" name="strxfrm">
5011 <sect1>strlen<label id="strlen"><p>
5015 <tag/Function/Return the length of a string.
5016 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5017 <tag/Declaration/<tt/size_t __fastcall__ strlen (const char* s);/
5018 <tag/Description/The <tt/strlen/ function computes the number of bytes in the
5019 string to which s points, not including the terminating null byte.
5020 <tag/Limits/<itemize>
5021 <item>The function is only available as fastcall function, so it may only
5022 be used in presence of a prototype.
5023 <item>When compiling with <tt/-Os/ (inline known standard functions), the
5024 function does not work correctly for strings with more than 255 characters.
5026 <tag/Availability/ISO 9899
5028 <ref id="strcpy" name="strcpy">
5034 <sect1>strlower<label id="strlower"><p>
5038 <tag/Function/Make a string lower case.
5039 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5040 <tag/Declaration/<tt/char* __fastcall__ strlower (char* s);/
5041 <tag/Description/The <tt/strlower/ function will apply the <tt/tolower/
5042 function to each character of a string. The function will always return <tt/s/.
5043 <tag/Limits/<itemize>
5044 <item>The function is only available as fastcall function, so it may only
5045 be used in presence of a prototype.
5046 <item>The function prototype is unavailable when compiling in strict ANSI mode.
5047 <item>An alias name for this function is <tt/strlwr/.
5049 <tag/Availability/cc65
5051 <ref id="strupper" name="strupper">,
5052 <ref id="tolower" name="tolower">
5058 <sect1>strlwr<label id="strlwr"><p>
5065 <sect1>strncat<label id="strncat"><p>
5069 <tag/Function/Concatentate two strings.
5070 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5071 <tag/Declaration/<tt/char* __fastcall__ strncat (char* s1, const char* s2, size_t n);/
5072 <tag/Description/The <tt/strncat/ function appends not more than n characters
5073 of the string pointed to by s2 to the end of the string pointed to by s1. The
5074 terminating null character at the end of s1 is overwritten. A terminating null
5075 character is appended to the result, even if not all of s2 is appended to s1.
5076 <tag/Limits/<itemize>
5077 <item>The function is only available as fastcall function, so it may only
5078 be used in presence of a prototype.
5079 <item>If copying takes place between objects that overlap, the behaviour
5082 <tag/Availability/ISO 9899
5084 <ref id="strcpy" name="strcpy">,
5085 <ref id="strncat" name="strncat">,
5086 <ref id="strncpy" name="strncpy">
5092 <sect1>strncmp<label id="strncmp"><p>
5096 <tag/Function/Compare two strings.
5097 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5098 <tag/Declaration/<tt/int __fastcall__ strncmp (const char* s1, const char* s2, size_t count);/
5099 <tag/Description/The <tt/strncmp/ function compares not more than <tt/count/
5100 characters of the two strings passed as parameters. It returns a value that is
5101 less than zero if the first <tt/count/ characters of <tt/s1/ are less than
5102 <tt/s2/, zero if they are identical, and a value greater than zero they are
5104 <tag/Limits/<itemize>
5105 <item>The function is only available as fastcall function, so it may only
5106 be used in presence of a prototype.
5108 <tag/Availability/ISO 9899
5110 <ref id="strcasecmp" name="strcasecmp">,
5111 <ref id="strcmp" name="strcmp">,
5112 <ref id="strcoll" name="strcoll">,
5113 <ref id="stricmp" name="stricmp">,
5114 <ref id="strxfrm" name="strxfrm">
5120 <sect1>strncpy<label id="strncpy"><p>
5124 <tag/Function/Copy part of a string.
5125 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5126 <tag/Declaration/<tt/char* __fastcall__ strcpy (char* s1, const char* s2, size_t n);/
5127 <tag/Description/The <tt/strncpy/ function copies not more than n bytes from
5128 the array pointed to by <tt/s2/ to the array pointed to by <tt/s1/. If the array
5129 pointed to by <tt/s2/ is a string that is shorter than n bytes, null bytes are
5130 appended to the copy in the array pointed to by <tt/s1/, until <tt/n/ bytes are
5131 written. The function will always return <tt/s1/.
5132 <tag/Limits/<itemize>
5133 <item>The function is only available as fastcall function, so it may only
5134 be used in presence of a prototype. If there is no null byte in the first <tt/n/
5135 bytes of the array pointed to by <tt/s2/, the result is not null-terminated.
5136 <item>If copying takes place between objects that overlap, the behaviour is
5139 <tag/Availability/ISO 9899
5141 <ref id="strcat" name="strcat">,
5142 <ref id="strcpy" name="strcpy">,
5143 <ref id="strncat" name="strncat">
5148 static char hello[6];
5150 strcpy (hello, "Hello world!\n", sizeof (hello) - 1);
5157 <sect1>strrchr<label id="strrchr"><p>
5161 <tag/Function/Search for a character in a string.
5162 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5163 <tag/Declaration/<tt/char* __fastcall__ strrchr (const char* s, int c);/
5164 <tag/Description/The <tt/strrchr/ function locates the last occurrence of <tt/c/
5165 (converted to a char) in the string pointed to by <tt/s/. The terminating null
5166 byte is considered to be part of the string. Upon completion, the function
5167 returns a pointer to the byte, or a null pointer if the byte was not found.
5168 <tag/Limits/<itemize>
5169 <item>The function is only available as fastcall function, so it may only
5170 be used in presence of a prototype.
5172 <tag/Availability/ISO 9899
5174 <ref id="strchr" name="strchr">
5180 <sect1>strspn<label id="strspn"><p>
5184 <tag/Function/Compute the length of a substring.
5185 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5186 <tag/Declaration/<tt/size_t __fastcall__ strspn (const char* s, const char* set);/
5187 <tag/Description/The <tt/strspn/ function computes and returns the length of
5188 the substring pointed to by <tt/s/ which does consist only of characters
5189 contained in the string <tt/set/.
5190 <tag/Limits/<itemize>
5191 <item>The function is only available as fastcall function, so it may only
5192 be used in presence of a prototype.
5194 <tag/Availability/ISO 9899
5196 <ref id="strcspn" name="strcspn">,
5197 <ref id="strstr" name="strstr">
5203 <sect1>strstr<label id="strstr"><p>
5207 <tag/Function/Find a substring.
5208 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5209 <tag/Declaration/<tt/char* __fastcall__ strstr (const char* str, const char* substr);/
5210 <tag/Description/<tt/strstr/ searches for the first occurance of the string
5211 <tt/substr/ within <tt/str/. If found, it returns a pointer to the copy,
5212 otherwise it returns <tt/NULL/.
5213 <tag/Limits/<itemize>
5214 <item>The function is only available as fastcall function, so it may only
5215 be used in presence of a prototype.
5217 <tag/Availability/ISO 9899
5219 <ref id="strcspn" name="strcspn">,
5220 <ref id="strspn" name="strspn">
5226 <sect1>strtok<label id="strtok"><p>
5230 <tag/Function/Break a string into tokens.
5231 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5232 <tag/Declaration/<tt/char* __fastcall__ strtok (char* s1, const char* s2);/
5233 <tag/Description/<tt/strtok/ will break the string s1 into a sequence of
5234 tokens, which are delimited by characters from the string s2. The first call
5235 to <tt/strtok/ will return a pointer to the first token in the string s1.
5236 Following calls must pass a <tt/NULL/ pointer as s1 in order to get the next
5237 token in the string. Different sets of delimiters may be used for the
5238 subsequent calls to <tt/strtok/.
5239 <tag/Limits/<itemize>
5240 <item>The function is only available as fastcall function, so it may only
5241 be used in presence of a prototype.
5242 <item><tt/strtok/ will modify the string s1.
5244 <tag/Availability/ISO 9899
5246 <ref id="strcspn" name="strcspn">,
5247 <!-- <ref id="strpbrk" name="strpbrk"> -->
5253 <sect1>strxfrm<label id="strxfrm"><p>
5257 <tag/Function/Transform a string.
5258 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5259 <tag/Declaration/<tt/size_t __fastcall__ strxfrm (char* s1, const char* s2, size_t n);/
5260 <tag/Description/The <tt/strxfrm/ function transforms the string pointed to by
5261 s2 and places the resulting string into the string pointed to by s1. The
5262 transformation is such that if the <tt/strcmp/ function is applied to two
5263 transformed strings, it returns a value greater than, equal to, or less than
5264 zero, corresponding to the result of the <tt/strcoll/ function applied to the
5265 same two original strings. No more than n characters are placed into the
5266 resulting array pointed to by s1, including the terminating null character.
5267 <tag/Limits/<itemize>
5268 <item><tt/s1/ and <tt/s2/ must not point to the same memory area, otherwise
5269 the behaviour is undefined.
5270 <item>If <tt/n/ is zero, <tt/s1/ may be a NULL pointer.
5271 <item>The function is only available as fastcall function, so it may only
5272 be used in presence of a prototype.
5273 <item>Since cc65 doesn't support different charcter sets, <tt/strxfrm/ will
5274 just copy s2 to s1 using <tt><ref id="strncpy" name="strncpy"></tt>.
5276 <tag/Availability/ISO 9899
5278 <ref id="strcmp" name="strcmp">,
5279 <ref id="strcoll" name="strcoll">,
5280 <ref id="strncpy" name="strncpy">
5286 <sect1>strupper<label id="strupper"><p>
5290 <tag/Function/Make a string upper case.
5291 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5292 <tag/Declaration/<tt/char* __fastcall__ strupper (char* s);/
5293 <tag/Description/The <tt/strupper/ function will apply the <tt/toupper/
5294 function to each character of a string. The function will always return <tt/s/.
5295 <tag/Limits/<itemize>
5296 <item>The function is only available as fastcall function, so it may only
5297 be used in presence of a prototype.
5298 <item>The function prototype is unavailable when compiling in strict ANSI mode.
5299 <item>An alias name for this function is <tt/strupr/.
5301 <tag/Availability/cc65
5303 <ref id="strlower" name="strlower">
5304 <ref id="toupper" name="toupper">
5310 <sect1>strupr<label id="strupr"><p>
5317 <sect1>textcolor<label id="textcolor"><p>
5321 <tag/Function/Set the text color.
5322 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
5323 <tag/Declaration/<tt/unsigned char __fastcall__ textcolor (unsigned char color);/
5324 <tag/Description/The function will set a new text color. It returns the old
5325 (current) text color. Text output using any <tt/conio.h/ function will use
5326 the color set by this function.
5327 <tag/Limits/<itemize>
5328 <item>Text colors are system dependent. The function may have no effect
5329 on systems where the text color cannot be changed.
5330 <item>The function is only available as fastcall function, so it may only
5331 be used in presence of a prototype.
5333 <tag/Availability/cc65
5335 <ref id="bgcolor" name="bgcolor">,
5336 <ref id="bordercolor" name="bordercolor">
5342 <sect1>tgi_arc<label id="tgi_arc"><p>
5346 <tag/Function/Draw an elliptic arc in the current color.
5347 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5348 <tag/Declaration/<tt/void __fastcall__ tgi_arc (int x, int y,
5349 unsigned char rx, unsigned char ry, unsigned sa, unsigned ea);/
5350 <tag/Description/The function draws an elliptic arc with center at x/y and
5351 radii rx/ry using the current drawing color. The arc covers the angle
5352 between sa and ea (startangle and endangle), which must be in the range
5354 <tag/Limits/<itemize>
5355 <item>The function is only available as fastcall function, so it may only
5356 be used in presence of a prototype.
5357 <item>The function behaves unexpectedly or may crash if the angles are out
5360 <tag/Availability/cc65
5362 <ref id="tgi_bar" name="tgi_bar">,
5363 <ref id="tgi_circle" name="tgi_circle">,
5364 <ref id="tgi_ellipse" name="tgi_ellipse">,
5365 <ref id="tgi_pieslice" name="tgi_pieslice">,
5366 <ref id="tgi_setcolor" name="tgi_setcolor">
5368 /* Draw the upper half of an ellipse */
5369 tgi_setcolor(TGI_COLOR_BLUE);
5370 tgi_arc (50, 50, 40, 20, 0, 180);
5376 <sect1>tgi_bar<label id="tgi_bar"><p>
5380 <tag/Function/The function fills a rectangle on the drawpage with the current
5382 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5383 <tag/Declaration/<tt/void __fastcall__ tgi_bar (int x1, int y1, int x2, int y2);/
5384 <tag/Description/The function fills a rectangle on the drawpage with the current
5386 <tag/Limits/<itemize>
5387 <item>The function is only available as fastcall function, so it may only
5388 be used in presence of a prototype.
5390 <tag/Availability/cc65
5391 <tag/See also/Other tgi function
5393 tgi_setcolor(TGI_COLOR_GREEN);
5394 tgi_bar(10, 10, 100, 60);
5400 <sect1>tgi_circle<label id="tgi_circle"><p>
5404 <tag/Function/The function draws a circle in the current color.
5405 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5406 <tag/Declaration/<tt/void __fastcall__ tgi_circle (int x, int y, unsigned char radius);/
5407 <tag/Description/The function draws a circle in the current color.
5408 <tag/Limits/<itemize>
5409 <item>The function is only available as fastcall function, so it may only
5410 be used in presence of a prototype.
5412 <tag/Availability/cc65
5414 <ref id="tgi_arc" name="tgi_arc">,
5415 <ref id="tgi_bar" name="tgi_bar">,
5416 <ref id="tgi_ellipse" name="tgi_ellipse">,
5417 <ref id="tgi_pieslice" name="tgi_pieslice">,
5418 <ref id="tgi_setcolor" name="tgi_setcolor">
5420 tgi_setcolor(TGI_COLOR_BLACK);
5421 tgi_circle(50, 40, 40);
5427 <sect1>tgi_clear<label id="tgi_clear"><p>
5431 <tag/Function/Clear the drawpage
5432 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5433 <tag/Declaration/<tt/void tgi_clear (void);/
5434 <tag/Description/Clear the drawpage
5435 <tag/Availability/cc65
5436 <tag/See also/Other tgi functions
5442 <sect1>tgi_done<label id="tgi_done"><p>
5446 <tag/Function/End graphics mode, switch back to text mode.
5447 Will NOT uninstall or unload the driver!
5448 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5449 <tag/Declaration/<tt/void tgi_done (void);/
5450 <tag/Description/End graphics mode, switch back to text mode.
5451 Will NOT uninstall or unload the driver!
5452 <tag/Availability/cc65
5453 <tag/See also/Other tgi functions
5459 <sect1>tgi_ellipse<label id="tgi_ellipse"><p>
5463 <tag/Function/The function draws an ellipse in the current color.
5464 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5465 <tag/Declaration/<tt/void __fastcall__ tgi_ellipse (int x, int y, unsigned char rx, unsigned char ry);/
5466 <tag/Description/The function draws an ellipse at position x/y with radii
5467 rx and ry, using the current drawing color.
5468 <tag/Limits/<itemize>
5469 <item>The function is only available as fastcall function, so it may only
5470 be used in presence of a prototype.
5472 <tag/Availability/cc65
5474 <ref id="tgi_arc" name="tgi_arc">,
5475 <ref id="tgi_bar" name="tgi_bar">,
5476 <ref id="tgi_circle" name="tgi_circle">,
5477 <ref id="tgi_pieslice" name="tgi_pieslice">,
5478 <ref id="tgi_setcolor" name="tgi_setcolor">
5480 tgi_setcolor(TGI_COLOR_RED);
5481 tgi_ellipse (50, 40, 40, 20);
5487 <sect1>tgi_getaspectratio<label id="tgi_getaspectratio"><p>
5489 <quote> <descrip> <tag/Function/Return the pixel aspect ratio.
5490 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5491 <tag/Declaration/<tt/unsigned tgi_getaspectratio (void);/
5492 <tag/Description/The function returns the pixel aspect ratio for the current
5493 driver and display as an 8.8 fixed point value. It may be used to correct
5494 geometric shapes so they look correct on the display. As an example, a circle
5495 with a radius of 100 pixels may look elliptic on some driver/display
5496 combinations if the aspect ratio is not 1.00.
5497 <tag/Limits/<itemize>
5498 <item>The aspect ratio is encoded in the TGI driver which assumes a "standard"
5499 monitor for the given platform. The aspect ratio may be wrong if another
5501 <item>No TGI function will use the aspect ratio. It is up to the programmer to
5503 <item>The <ref id="tgi_setaspectratio" name="tgi_setaspectratio"> function can
5504 be used to change the aspect ratio for a loaded driver. The value is not reset
5505 by <ref id="tgi_init" name="tgi_init">, so if a driver is linked statically to
5506 an application, switching into and out of graphics mode will not restore the
5507 original aspect ratio.
5509 <tag/Availability/cc65
5511 <ref id="tgi_setaspectratio" name="tgi_setaspectratio">
5517 <sect1>tgi_getcolor<label id="tgi_getcolor"><p>
5521 <tag/Function/Return the current drawing color.
5522 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5523 <tag/Declaration/<tt/unsigned char tgi_getcolor (void);/
5524 <tag/Description/The actual color is an index to a palette. During tgi_init
5525 you will get a default palette. The number of colors depend on the platform.
5526 All platforms recognize at least TGI_COLOR_BLACK and TGI_COLOR_WHITE. But some
5527 platforms have many more predefined colors. If you paint using TGI_COLOR_GREEN
5528 and then you change the green of the palette to blue using tgi_setpalette then
5529 after this painting in TGI_COLOR_GREEN will actually be blue.
5530 <tag/Availability/cc65
5531 <tag/See also/Other tgi functions
5533 color = tgi_getcolor();
5539 <sect1>tgi_getcolorcount<label id="tgi_getcolorcount"><p>
5543 <tag/Function/Get the number of available colors.
5544 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5545 <tag/Declaration/<tt/unsigned char tgi_getcolorcount (void);/
5546 <tag/Description/Tgi platforms use indexed color palettes. This function
5547 returns the number of entries we can use in the palette.
5548 <tag/Availability/cc65
5549 <tag/See also/Other tgi functions
5551 if (tgi_getcolorcount() == 2) {
5552 printf("Only monochrome graphics is supported\n");
5559 <sect1>tgi_getdefpalette<label id="tgi_getdefpalette"><p>
5563 <tag/Function/Get the palette installed by default.
5564 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5565 <tag/Declaration/<tt/const unsigned char* tgi_getdefpalette (void);/
5566 <tag/Description/The tgi driver has a default palette that is active at startup.
5567 The named colors TGI_COLOR_BLACK, TGI_COLOR_WHITE, TGI_COLOR_RED... need this
5568 palette to work correctly.
5569 <tag/Availability/cc65
5570 <tag/See also/Other tgi functions
5576 <sect1>tgi_geterror<label id="tgi_geterror"><p>
5580 <tag/Function/Return the error code for the last operation.
5581 This will also clear the error.
5582 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5583 <tag/Declaration/<tt/unsigned char tgi_geterror (void);/
5584 <tag/Description/Return the error code for the last operation.
5585 This will also clear the error.
5586 <tag/Availability/cc65
5587 <tag/See also/Other tgi functions
5593 <sect1>tgi_geterrormsg<label id="tgi_geterrormsg"><p>
5597 <tag/Function/Get an error message describing the error.
5598 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5599 <tag/Declaration/<tt/const char* __fastcall__ tgi_geterrormsg (unsigned char code);/
5600 <tag/Description/Get an error message describing the error.
5601 <tag/Limits/<itemize>
5602 <item>The function is only available as fastcall function, so it may only
5603 be used in presence of a prototype.
5605 <tag/Availability/cc65
5606 <tag/See also/Other tgi functions
5612 <sect1>tgi_getmaxcolor<label id="tgi_getmaxcolor"><p>
5616 <tag/Function/Get the highest index of the palette.
5617 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5618 <tag/Declaration/<tt/unsigned char tgi_getmaxcolor (void);/
5619 <tag/Description/Get the highest index of the palette.
5620 <tag/Availability/cc65
5621 <tag/See also/Other tgi functions
5627 <sect1>tgi_getmaxx<label id="tgi_getmaxx"><p>
5631 <tag/Function/Get the maximum x coordinate that can be used on this screen.
5632 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5633 <tag/Declaration/<tt/unsigned tgi_getmaxx (void);/
5634 <tag/Description/Get the maximum x coordinate that can be used on this screen.
5635 <tag/Availability/cc65
5636 <tag/See also/Other tgi functions
5642 <sect1>tgi_getmaxy<label id="tgi_getmaxy"><p>
5646 <tag/Function/Get the maximum y coordinate that can be used on this screen.
5647 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5648 <tag/Declaration/<tt/unsigned tgi_getmaxy (void);/
5649 <tag/Description/Get the maximum y coordinate that can be used on this screen.
5650 <tag/Availability/cc65
5651 <tag/See also/Other tgi functions
5657 <sect1>tgi_getpagecount<label id="tgi_getpagecount"><p>
5661 <tag/Function/Return the number of screen pages available.
5662 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5663 <tag/Declaration/<tt/unsigned tgi_getpagecount (void);/
5664 <tag/Description/Return the number of screen pages available.
5665 <tag/Availability/cc65
5667 <ref id="tgi_setdrawpage" name="tgi_setdrawpage">,
5668 <ref id="tgi_setviewpage" name="tgi_setviewpage">
5674 <sect1>tgi_getpalette<label id="tgi_getpalette"><p>
5678 <tag/Function/Get the palette installed.
5679 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5680 <tag/Declaration/<tt/const unsigned char* tgi_getpalette (void);/
5681 <tag/Description/Get the palette installed.
5682 <tag/Availability/cc65
5683 <tag/See also/Other tgi functions
5689 <sect1>tgi_getpixel<label id="tgi_getpixel"><p>
5693 <tag/Function/Get the color of a pixel from the viewpage.
5694 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5695 <tag/Declaration/<tt/unsigned char __fastcall__ tgi_getpixel (int x, int y);/
5696 <tag/Description/Get the color of a pixel from the viewpage.
5697 <tag/Limits/<itemize>
5698 <item>The function is only available as fastcall function, so it may only
5699 be used in presence of a prototype.
5701 <tag/Availability/cc65
5702 <tag/See also/Other tgi functions.
5708 <sect1>tgi_getxres<label id="tgi_getxres"><p>
5712 <tag/Function/Get number of horisontal pixels on the screen.
5713 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5714 <tag/Declaration/<tt/unsigned tgi_getxres (void);/
5715 <tag/Description/Get number of horisontal pixels on the screen.
5716 This is same as tgi_maxx()+1.
5717 <tag/Availability/cc65
5718 <tag/See also/Other tgi functions.
5724 <sect1>tgi_getyres<label id="tgi_getyres"><p>
5728 <tag/Function/Get number of vertical pixels on the screen.
5729 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5730 <tag/Declaration/<tt/unsigned tgi_getyres (void);/
5731 <tag/Description/Get number of vertical pixels on the screen.
5732 This is same as tgi_maxy()+1.
5733 <tag/Availability/cc65
5734 <tag/See also/Other tgi functions.
5740 <sect1>tgi_gotoxy<label id="tgi_gotoxy"><p>
5744 <tag/Function/Set graphics cursor at x, y.
5745 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5746 <tag/Declaration/<tt/void __fastcall__ tgi_gotoxy (int x, int y);/
5747 <tag/Description/Set graphics cursor at x, y.
5748 <tag/Limits/<itemize>
5749 <item>The function is only available as fastcall function, so it may only
5750 be used in presence of a prototype.
5752 <tag/Availability/cc65
5753 <tag/See also/Other tgi functions.
5759 <sect1>tgi_init<label id="tgi_init"><p>
5763 <tag/Function/Initialize the already loaded graphics driver.
5764 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5765 <tag/Declaration/<tt/void tgi_init (void);/
5766 <tag/Description/The tgi_init function will set the default palette to the
5768 <tag/Limits/<itemize>
5769 <item><tt/tgi_init/ will not clear the screen. This allows switching between
5770 text and graphics mode on platforms that have separate memory areas for the
5771 screens. If you want the screen cleared, call <tt/<ref id="tgi_clear"
5772 name="tgi_clear">/ after <tt/tgi_init/.
5774 <tag/Availability/cc65
5775 <tag/See also/Other tgi functions.
5777 extern char lynxtgi[]; //Include the driver statically instead of loading it.
5778 tgi_install(&lynxtgi);
5779 tgi_init(); //Set up the default palette and clear the screen.
5785 <sect1>tgi_install<label id="tgi_install"><p>
5789 <tag/Function/Install an already loaded driver and return an error code.
5790 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5791 <tag/Declaration/<tt/unsigned char __fastcall__ tgi_install (void* driver);/
5792 <tag/Description/The function installs a driver that was already loaded into
5793 memory (or linked statically to the program). It returns an error code
5794 (<tt/TGI_ERR_OK/ in case of success).
5795 <tag/Limits/<itemize>
5796 <item>The function is only available as fastcall function, so it may only be
5797 used in presence of a prototype.
5799 <tag/Availability/cc65
5801 <ref id="tgi_load_driver" name="tgi_load_driver">,
5802 <ref id="tgi_uninstall" name="tgi_uninstall">,
5803 <ref id="tgi_unload" name="tgi_unload">
5805 extern char lynxtgi[]; //Include the driver statically instead of loading it.
5807 tgi_install(&lynxtgi);
5808 tgi_init(); //Set up the default palette and clear the screen.
5814 <sect1>tgi_ioctl<label id="tgi_ioctl"><p>
5818 <tag/Function/Platform dependent code extensions.
5819 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5820 <tag/Declaration/<tt/unsigned __fastcall__ tgi_ioctl (unsigned char code, void* data);/
5821 <tag/Description/Some platforms have extra display hardware that is not
5822 supported by standard tgi functions. You can extend the driver to support
5823 this extra hardware using tgi_ioctl functions.
5824 <tag/Limits/<itemize>
5825 <item>The function is only available as fastcall function, so it may only
5826 be used in presence of a prototype.
5827 <item>These functions are not easily portable to other cc65 platforms.
5829 <tag/Availability/cc65
5830 <tag/See also/Other tgi functions.
5832 #define tgi_sprite(spr) tgi_ioctl(0, (void*)(spr))
5833 #define tgi_flip() tgi_ioctl(1, (void*)0)
5834 #define tgi_setbgcolor(bgcol) tgi_ioctl(2, (void*)(bgcol))
5835 #define tgi_setframerate(rate) tgi_ioctl(3, (void*)(rate))
5836 #define tgi_busy() tgi_ioctl(4, (void*)0)
5837 #define tgi_updatedisplay() tgi_ioctl(4, (void*)1)
5839 tgi_sprite(&background);
5840 tgi_setcolor(TGI_COLOR_BLUE);
5841 tgi_outttextxy(20,40,"Hello World");
5842 tgi_updatedisplay();
5849 <sect1>tgi_line<label id="tgi_line"><p>
5853 <tag/Function/Draw a line in the current drawing color.
5854 The graphics cursor will be set to x2/y2 by this call.
5855 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5856 <tag/Declaration/<tt/void __fastcall__ tgi_line (int x1, int y1, int x2, int y2);/
5857 <tag/Description/Draw a line in the current drawing color.
5858 The graphics cursor will be set to x2/y2 by this call.
5859 <tag/Limits/<itemize>
5860 <item>The function is only available as fastcall function, so it may only
5861 be used in presence of a prototype.
5863 <tag/Availability/cc65
5864 <tag/See also/Other tgi functions.
5870 <sect1>tgi_lineto<label id="tgi_lineto"><p>
5874 <tag/Function/Draw a line in the current drawing color from the graphics
5875 cursor to the new end point. The graphics cursor will be updated to x2/y2.
5876 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5877 <tag/Declaration/<tt/void __fastcall__ tgi_lineto (int x2, int y2);/
5878 <tag/Description/Draw a line in the current drawing color from the graphics
5879 cursor to the new end point. The graphics cursor will be updated to x2/y2.
5880 <tag/Limits/<itemize>
5881 <item>The function is only available as fastcall function, so it may only
5882 be used in presence of a prototype.
5884 <tag/Availability/cc65
5885 <tag/See also/Other tgi functions.
5891 <sect1>tgi_load_driver<label id="tgi_load_driver"><p>
5895 <tag/Function/Load and install the given driver.
5896 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5897 <tag/Declaration/<tt/void __fastcall__ tgi_load_driver (const char *name);/
5898 <tag/Description/Load and install the driver by name.
5899 Will just load the driver and check if loading was successful.
5900 Will not switch to graphics mode.
5901 <tag/Limits/<itemize>
5902 <item>The function is only available as fastcall function, so it may only
5903 be used in presence of a prototype.
5905 <tag/Availability/cc65
5906 <tag/See also/Other tgi functions.
5912 <sect1>tgi_outtext<label id="tgi_outtext"><p>
5916 <tag/Function/Output text at the current graphics cursor position.
5917 The graphics cursor is moved to the end of the text.
5918 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5919 <tag/Declaration/<tt/void __fastcall__ tgi_outtext (const char* s);/
5920 <tag/Description/Output text at the current graphics cursor position.
5921 The graphics cursor is moved to the end of the text.
5922 <tag/Limits/<itemize>
5923 <item>The function is only available as fastcall function, so it may only
5924 be used in presence of a prototype.
5926 <tag/Availability/cc65
5927 <tag/See also/Other tgi functions.
5933 <sect1>tgi_outtextxy<label id="tgi_outtextxy"><p>
5937 <tag/Function/Output text at the given cursor position.
5938 The graphics cursor is moved to the end of the text.
5939 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5940 <tag/Declaration/<tt/void __fastcall__ tgi_outtextxy (int x, int y, const char* s);/
5941 <tag/Description/Output text at the given cursor position.
5942 The graphics cursor is moved to the end of the text.
5943 <tag/Limits/<itemize>
5944 <item>The function is only available as fastcall function, so it may only
5945 be used in presence of a prototype.
5947 <tag/Availability/cc65
5948 <tag/See also/Other tgi functions.
5954 <sect1>tgi_pieslice<label id="tgi_pieslice"><p>
5958 <tag/Function/Draw an elliptic pie slice in the current color.
5959 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5960 <tag/Declaration/<tt/void __fastcall__ tgi_pie slice (int x, int y,
5961 unsigned char rx, unsigned char ry, unsigned sa, unsigned ea);/
5962 <tag/Description/The function draws an elliptic pie slice with center at x/y
5963 and radii rx/ry using the current drawing color. The pie slice covers the angle
5964 between sa and ea (startangle and endangle), which must be in the range
5966 <tag/Limits/<itemize>
5967 <item>The function is only available as fastcall function, so it may only
5968 be used in presence of a prototype.
5969 <item>The function behaves unexpectedly or may crash if the angles are out
5972 <tag/Availability/cc65
5974 <ref id="tgi_bar" name="tgi_arc">,
5975 <ref id="tgi_bar" name="tgi_bar">,
5976 <ref id="tgi_circle" name="tgi_circle">,
5977 <ref id="tgi_ellipse" name="tgi_ellipse">,
5978 <ref id="tgi_setcolor" name="tgi_setcolor">
5980 /* Draw the closed upper half of an ellipse */
5981 tgi_setcolor(TGI_COLOR_BLUE);
5982 tgi_pieslice (50, 50, 40, 20, 0, 180);
5988 <sect1>tgi_setaspectratio<label id="tgi_setaspectratio"><p>
5990 <quote> <descrip> <tag/Function/Set the pixel aspect ratio.
5991 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5992 <tag/Declaration/<tt/void __fastcall__ tgi_setaspectratio (unsigned ratio);/
5993 <tag/Description/The function sets the pixel aspect ratio for the current
5994 driver and display. The argument is an 8.8 fixed point value. The aspect ratio
5995 may be used to correct geometric shapes so they look correct on a given
5996 display. As an example, a circle with a radius of 100 pixels may look elliptic
5997 on some driver/display combinations if the aspect ratio is not 1.00.
5998 <tag/Limits/<itemize>
5999 <item>The aspect ratio is encoded in the TGI driver which assumes a "standard"
6000 monitor for the given platform. The aspect ratio may be wrong if another
6002 <item>No TGI function will use the aspect ratio. It is up to the programmer to
6004 <item>The <tt/tgi_setaspectratio/ function can be used to change the aspect
6005 ratio for a loaded driver. The value is not reset by <ref id="tgi_init"
6006 name="tgi_init">, so if a driver is linked statically to an application,
6007 switching into and out of graphics mode will not restore the original aspect
6010 <tag/Availability/cc65
6012 <ref id="tgi_getaspectratio" name="tgi_getaspectratio">
6018 <sect1>tgi_setcolor<label id="tgi_setcolor"><p>
6022 <tag/Function/Set color to be used in future draw operations.
6023 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6024 <tag/Declaration/<tt/void __fastcall__ tgi_setcolor (unsigned char color);/
6025 <tag/Description/Set color to be used in future draw operations.
6026 <tag/Limits/<itemize>
6027 <item>The function is only available as fastcall function, so it may only
6028 be used in presence of a prototype.
6030 <tag/Availability/cc65
6031 <tag/See also/Other tgi functions.
6033 tgi_setcolor(TGI_COLOR_BLACK);
6035 tgi_setcolor(TGI_COLOR_WHITE);
6036 tgi_bar(10,10,20,20);
6041 <sect1>tgi_setdrawpage<label id="tgi_setdrawpage"><p>
6045 <tag/Function/Set the page for drawing.
6046 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6047 <tag/Declaration/<tt/void __fastcall__ tgi_setdrawpage (unsigned char page);/
6048 <tag/Description/If the drawpage and the viewpage are the same then all drawing
6049 is seen immediately as it is drawn. For double buffered games you can set the
6050 drawpage to a different page than the viewpage. This lets you draw the next
6051 screen in the background and when the screen is ready you display it.
6052 <tag/Limits/<itemize>
6053 <item>The function is only available as fastcall function, so it may only
6054 be used in presence of a prototype.
6056 <tag/Availability/cc65
6057 <tag/See also/Other tgi functions.
6060 tgi_outtextxy(10, 10, "Hello World");
6061 tgi_setviewpage(1); // Show page 1
6063 tgi_outtextxy(10, 10, "Creating next frame");
6065 tgi_setviewpage(0); // Show page 0
6070 <sect1>tgi_setpalette<label id="tgi_setpalette"><p>
6074 <tag/Function/Set the palette (not available with all drivers/hardware).
6075 Palette is a pointer to as many entries as there are colors.
6076 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6077 <tag/Declaration/<tt/void __fastcall__ tgi_setpalette (const unsigned char* palette);/
6078 <tag/Description/Set the palette (not available with all drivers/hardware).
6079 Palette is a pointer to as many entries as there are colors.
6080 <tag/Limits/<itemize>
6081 <item>The function is only available as fastcall function, so it may only
6082 be used in presence of a prototype.
6084 <tag/Availability/cc65
6085 <tag/See also/Other tgi functions.
6090 <sect1>tgi_setpixel<label id="tgi_setpixel"><p>
6094 <tag/Function/Plot a pixel on the drawpage with the current color.
6095 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6096 <tag/Declaration/<tt/void __fastcall__ tgi_setpixel (int x, int y);/
6097 <tag/Description/Plot a pixel on the drawpage with the current color.
6098 <tag/Limits/<itemize>
6099 <item>The function is only available as fastcall function, so it may only
6100 be used in presence of a prototype.
6102 <tag/Availability/cc65
6103 <tag/See also/Other tgi functions.
6108 <sect1>tgi_setviewpage<label id="tgi_setviewpage"><p>
6112 <tag/Function/Set page to be visible on screen.
6113 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6114 <tag/Declaration/<tt/void __fastcall__ tgi_setviewpage (unsigned char page);/
6115 <tag/Description/If the drawpage and the viewpage are the same then all drawing
6116 is seen immediately as it is drawn. For double buffered games you can set the
6117 drawpage to a different page than the viewpage. This lets you draw the next
6118 screen in the background and when the screen is ready you display it.
6119 <tag/Limits/<itemize>
6120 <item>The function is only available as fastcall function, so it may only
6121 be used in presence of a prototype.
6123 <tag/Availability/cc65
6124 <tag/See also/Other tgi functions.
6127 tgi_outtextxy(10, 10, "Hello World");
6128 tgi_setviewpage(1); // Show page 1
6130 tgi_outtextxy(10, 10, "Creating next frame");
6132 tgi_setviewpage(0); // Show page 0
6137 <sect1>tgi_gettextheight<label id="tgi_gettextheight"><p>
6141 <tag/Function/Calculate the height of the text in pixels according to
6142 the current text style.
6143 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6144 <tag/Declaration/<tt/unsigned __fastcall__ tgi_gettextheight (const char* s);/
6145 <tag/Description/Calculate the height of the text in pixels according to
6146 the current text style.
6147 <tag/Limits/<itemize>
6148 <item>The function is only available as fastcall function, so it may only
6149 be used in presence of a prototype.
6151 <tag/Availability/cc65
6152 <tag/See also/Other tgi functions.
6157 <sect1>tgi_settextstyle<label id="tgi_settextstyle"><p>
6161 <tag/Function/Set the style for text output.
6162 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6163 <tag/Declaration/<tt/void __fastcall__ tgi_settextstyle (unsigned char magx, unsigned char magy, unsigned char dir);/
6164 <tag/Description/Set the style for text output.
6165 <tag/Limits/<itemize>
6166 <item>The function is only available as fastcall function, so it may only
6167 be used in presence of a prototype.
6169 <tag/Availability/cc65
6170 <tag/See also/Other tgi functions.
6175 <sect1>tgi_gettextwidth<label id="tgi_gettextwidth"><p>
6179 <tag/Function/Calculate the width of the text in pixels according to the current text style.
6180 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6181 <tag/Declaration/<tt/unsigned __fastcall__ tgi_gettextwidth (const char* s);/
6182 <tag/Function/Calculate the width of the text in pixels according to the current text style.
6183 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6184 <tag/Description/Calculate the width of the text in pixels according to the current text style.
6185 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6186 <tag/Limits/<itemize>
6187 <item>The function is only available as fastcall function, so it may only
6188 be used in presence of a prototype.
6190 <tag/Availability/cc65
6191 <tag/See also/Other tgi functions.
6196 <sect1>tgi_uninstall<label id="tgi_uninstall"><p>
6200 <tag/Function/Uninstall the currently loaded driver but do not unload it.
6201 Will call tgi_done if necessary.
6202 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6203 <tag/Declaration/<tt/void tgi_uninstall (void);/
6204 <tag/Description/Uninstall the currently loaded driver but do not unload it.
6205 Will call tgi_done if necessary.
6206 <tag/Availability/cc65
6207 <tag/See also/Other tgi functions.
6212 <sect1>tgi_unload<label id="tgi_unload"><p>
6216 <tag/Function/Uninstall, then unload the currently loaded driver.
6217 Will call tgi_done if necessary.
6218 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6219 <tag/Declaration/<tt/void tgi_unload (void);/
6220 <tag/Description/Uninstall, then unload the currently loaded driver.
6221 Will call tgi_done if necessary.
6222 <tag/Availability/cc65
6223 <tag/See also/Other tgi functions.
6228 <sect1>time<label id="time"><p>
6232 <tag/Function/Get the time.
6233 <tag/Header/<tt/<ref id="time.h" name="time.h">/
6234 <tag/Declaration/<tt/time_t __fastcall__ time (time_t* t);/
6235 <tag/Description/The function returns the time since the 1970-01-01 00:00:00
6236 measured in seconds. If the pointer <tt/t/ is not <tt/NULL/, the function
6237 result will also be stored there. If no time is available, <tt/(time_t)-1/ is
6238 returned and <tt/errno/ is set to <tt/ENOSYS/.
6239 <tag/Limits/<itemize>
6240 <item>The function is only available as fastcall function, so it may
6241 only be used in presence of a prototype.
6242 <item>Many platforms supported by cc65 do not have a realtime clock, so the
6243 returned value may not be valid.
6245 <tag/Availability/ISO 9899
6251 <sect1>toggle_videomode<label id="toggle_videomode"><p>
6255 <tag/Function/Toggle between 40 and 80 column mode.
6256 <tag/Header/<tt/<ref id="c128.h" name="c128.h">/
6257 <tag/Declaration/<tt/void toggle_videomode (void);/
6258 <tag/Description/Toggle between 40 and 80 column mode. The settings for the
6259 old mode (cursor position, color and so on) are saved and restored together
6261 <tag/Limits/<itemize>
6262 <item>The function is specific to the C128.
6263 <item>This function is deprecated. Please use <ref id="videomode"
6264 name="videomode"> instead!
6266 <tag/Availability/C128
6268 <ref id="fast" name="fast">,
6269 <ref id="slow" name="slow">,
6270 <ref id="videomode" name="videomode">
6276 <sect1>tolower<label id="tolower"><p>
6280 <tag/Function/Convert a character into its lower case representation.
6281 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
6282 <tag/Declaration/<tt/int __fastcall__ tolower (int c);/
6283 <tag/Description/The function returns the given character converted to lower
6284 case. If the given character is not a letter, it is returned unchanged.
6285 <tag/Limits/<itemize>
6286 <item>The function is only available as fastcall function, so it may
6287 only be used in presence of a prototype.
6289 <tag/Availability/ISO 9899
6291 <ref id="islower" name="islower">,
6292 <ref id="isupper" name="isupper">,
6293 <ref id="toupper" name="toupper">
6299 <sect1>toupper<label id="toupper"><p>
6303 <tag/Function/Convert a character into its upper case representation.
6304 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
6305 <tag/Declaration/<tt/int __fastcall__ toupper (int c);/
6306 <tag/Description/The function returns the given character converted to upper
6307 case. If the given character is not a letter, it is returned unchanged.
6308 <tag/Limits/<itemize>
6309 <item>The function is only available as fastcall function, so it may
6310 only be used in presence of a prototype.
6312 <tag/Availability/ISO 9899
6314 <ref id="islower" name="islower">,
6315 <ref id="isupper" name="isupper">,
6316 <ref id="tolower" name="tolower">
6322 <sect1>ultoa<label id="ultoa"><p>
6326 <tag/Function/Convert an unsigned long integer into a string.
6327 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
6328 <tag/Declaration/<tt/char* __fastcall__ ultoa (unsigned long val, char* buf, int radix);/
6329 <tag/Description/<tt/itoa/ converts the unsigned long integer <tt/val/ into a
6330 string using <tt/radix/ as the base.
6331 <tag/Limits/<itemize>
6332 <item>There are no provisions to prevent a buffer overflow.
6333 <item>The function is non standard, so it is not available in strict ANSI mode.
6334 You should probably use <tt/sprintf/ instead.
6335 <item>The function is only available as fastcall function, so it may only be
6336 used in presence of a prototype.
6338 <tag/Availability/cc65
6340 <ref id="atoi" name="atoi">,
6341 <ref id="atol" name="atol">,
6342 <ref id="itoa" name="itoa">,
6343 <ref id="ltoa" name="ltoa">,
6344 <ref id="utoa" name="utoa">
6350 <sect1>unlink<label id="unlink"><p>
6354 <tag/Function/Delete a file.
6355 <tag/Header/<tt/<ref id="unistd.h" name="unistd.h">/
6356 <tag/Declaration/<tt/int __fastcall__ unlink (const char* name);/
6357 <tag/Description/<tt/unlink/ deletes the file with the given name. On success,
6358 zero is returned. On error, -1 is returned and <tt/errno/ is set to an error
6359 code describing the reason for the failure.
6362 <item>The use of this function is discouraged. Please use <tt/<ref id="remove"
6363 name="remove">/ instead, which is a native ANSI C function and does the same.
6364 <item>This function is not available on all cc65 targets (depends on the
6365 availability of file I/O).
6366 <item>The function is only available as fastcall function, so it may only
6367 be used in presence of a prototype.
6368 <item>Instead of <tt/unlink/, <tt/<ref id="remove" name="remove">/ should be
6369 used, which has the same semantics, but is more portable, because it conforms
6370 to the ISO C standard.
6372 <tag/Availability/POSIX 1003.1
6374 <ref id="remove" name="remove">
6377 #include <stdio.h>
6378 #include <unistd.h>
6380 #define FILENAME "helloworld"
6382 if (unlink (FILENAME) == 0) {
6383 printf ("We deleted %s successfully\n", FILENAME);
6385 printf ("There was a problem deleting %s\n", FILENAME);
6392 <sect1>utoa<label id="utoa"><p>
6396 <tag/Function/Convert an unsigned integer into a string.
6397 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
6398 <tag/Declaration/<tt/char* __fastcall__ utoa (unsigned val, char* buf, int radix);/
6399 <tag/Description/<tt/itoa/ converts the unsigned integer <tt/val/ into a string
6400 using <tt/radix/ as the base.
6401 <tag/Limits/<itemize>
6402 <item>There are no provisions to prevent a buffer overflow.
6403 <item>The function is non standard, so it is not available in strict ANSI mode.
6404 You should probably use <tt/sprintf/ instead.
6405 <item>The function is only available as fastcall function, so it may only be
6406 used in presence of a prototype.
6408 <tag/Availability/cc65
6410 <ref id="atoi" name="atoi">,
6411 <ref id="atol" name="atol">,
6412 <ref id="itoa" name="itoa">,
6413 <ref id="ltoa" name="ltoa">,
6414 <ref id="ultoa" name="ultoa">
6420 <sect1>vcprintf<label id="vcprintf"><p>
6424 <tag/Function/Formatted output to the console.
6425 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
6426 <tag/Declaration/<tt/int __fastcall__ vcprintf (const char* format, va_list ap);/
6427 <tag/Description/The arguments specified as a <tt/va_list/ are converted to
6428 text where necessary and formatted according to the format string given. The
6429 resulting string is output to the console. <tt/vcprintf/ supports the same
6430 format specifiers as <tt/vprintf/. <!-- <tt/<ref id="vprintf" name="vprintf">/. -->
6431 <tag/Limits/<itemize>
6432 <item>Like all other <tt/conio/ output functions, <tt/vcprintf/ distinguishes
6433 between <tt/\r/ and <tt/\n/.
6434 <item>The function is only available as fastcall function, so it may only be
6435 used in presence of a prototype.
6437 <tag/Availability/cc65
6439 <ref id="cprintf" name="cprintf">,
6440 <ref id="cputc" name="cputc">,
6441 <ref id="cputcxy" name="cputcxy">,
6442 <ref id="cputs" name="cputs">,
6443 <ref id="cputsxy" name="cputsxy">
6449 <sect1>videomode<label id="videomode"><p>
6453 <tag/Function/Switch to either 40 or 80 column mode.
6454 <tag/Header/<tt/<ref id="apple2enh.h" name="apple2enh.h">,
6455 <ref id="c128.h" name="c128.h">/
6456 <tag/Declaration/<tt/unsigned __fastcall__ videomode (unsigned Mode);/
6457 <tag/Description/Switch to 40 or 80 column mode depending on the argument. If
6458 the requested mode is already active, nothing happens. The old mode is returned
6460 <tag/Limits/<itemize>
6461 <item>The function is specific to the C128 and enhanced Apple //e.
6462 <item>This function replaces <ref id="toggle_videomode"
6463 name="toggle_videomode">.
6464 <item>The function is only available as fastcall function, so it may only be
6465 used in presence of a prototype.
6467 <tag/Availability/C128 and enhanced Apple //e
6469 <ref id="fast" name="fast">,
6470 <ref id="slow" name="slow">,
6471 <ref id="toggle_videomode" name="toggle_videomode">
6477 <sect1>wherex<label id="wherex"><p>
6481 <tag/Function/Return the current X position of the text mode cursor.
6482 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
6483 <tag/Declaration/<tt/unsigned char wherex (void);/
6484 <tag/Description/The function returns the current X position of the text mode
6485 cursor. Zero is returned for the leftmost screen position.
6486 <tag/Availability/cc65
6488 <ref id="gotox" name="gotox">,
6489 <ref id="gotoy" name="gotoy">,
6490 <ref id="gotoxy" name="gotoxy">,
6491 <ref id="wherey" name="wherey">
6497 <sect1>wherey<label id="wherey"><p>
6501 <tag/Function/Return the current Y position of the text mode cursor.
6502 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
6503 <tag/Declaration/<tt/unsigned char wherey (void);/
6504 <tag/Description/The function returns the current Y position of the text mode
6505 cursor. Zero is returned for the uppermost screen position.
6506 <tag/Availability/cc65
6508 <ref id="gotox" name="gotox">,
6509 <ref id="gotoy" name="gotoy">,
6510 <ref id="gotoxy" name="gotoxy">,
6511 <ref id="wherex" name="wherex">