1 <!doctype linuxdoc system>
4 <title>cc65 function reference
5 <author>Ullrich von Bassewitz, <htmlurl url="mailto:uz@cc65.org" name="uz@cc65.org">
9 cc65 is a C compiler for 6502 based systems. This function reference describes
10 the C functions available in the standard library.
13 <!-- Table of contents -->
16 <!-- Begin the document -->
20 cc65 is a C compiler for 6502 based systems. It implements a subset of the ISO
21 C standard plus additional functions specially crafted for 6502 systems or
22 just some of the supported machines. This function refrence describes the
23 available functions together with any limitations.
25 For an overview about the available libraries, their purpose, and any
26 differences to the ISO standard, please have a look at the <htmlurl
27 url="library.html" name="cc65 Library Overview">.
29 <bf/Note:/ Standard C functions are listed here, but not described in detail.
30 Since these functions behave identical on all standard compliant systems, they
31 are described in any book covering standard C.
33 Each entry for a function contains a detailed description
37 <tag/Function/Summary of what <bf/function/ does.
38 <tag/Header/The header file that contains the declaration.
39 <tag/Declaration/Describes the needed header files and declaration of the
41 <tag/Description/Description of the function.
43 <tag/Availability/The availability of the function.
44 <tag/See also/Other related functions.
45 <tag/Example/A piece of actual code using the function.
50 <sect>Functions by header file<p>
52 <sect1><tt/6502.h/<label id="6502.h"><p>
55 <item><ref id="BRK" name="BRK">
56 <item><ref id="CLI" name="CLI">
57 <item><ref id="SEI" name="SEI">
58 <item><ref id="_sys" name="_sys">
59 <item><ref id="getcpu" name="getcpu">
60 <item><ref id="reset_brk" name="reset_brk">
61 <item><ref id="reset_irq" name="reset_irq">
62 <item><ref id="set_brk" name="set_brk">
63 <item><ref id="set_irq" name="set_irq">
67 <sect1><tt/apple2.h/<label id="apple2.h"><p>
71 <item><ref id="get_ostype" name="get_ostype">
76 <sect1><tt/apple2enh.h/<label id="apple2enh.h"><p>
80 <item><ref id="get_ostype" name="get_ostype">
84 <item><ref id="videomode" name="videomode">
88 <sect1><tt/assert.h/<label id="assert.h"><p>
91 <item><ref id="assert" name="assert">
95 <sect1><tt/atari.h/<label id="atari.h"><p>
98 <!-- <item><ref id="_getcolor" name="_getcolor"> -->
99 <!-- <item><ref id="_getdefdev" name="_getdefdev"> -->
100 <!-- <item><ref id="_graphics" name="_graphics"> -->
101 <!-- <item><ref id="_rest_vecs" name="_rest_vecs"> -->
102 <!-- <item><ref id="_save_vecs" name="_save_vecs"> -->
103 <!-- <item><ref id="_scroll" name="_scroll"> -->
104 <!-- <item><ref id="_setcolor" name="_setcolor"> -->
105 <!-- <item><ref id="_setcolor_low" name="_setcolor_low"> -->
106 <item><ref id="get_ostype" name="get_ostype">
107 <!-- <item><ref id="get_tv" name="get_tv"> -->
113 <sect1><tt/atmos.h/<label id="atmos.h"><p>
116 <item><ref id="atmos_load" name="atmos_load">
117 <item><ref id="atmos_save" name="atmos_save">
121 <sect1><tt/c128.h/<label id="c128.h"><p>
124 <item><ref id="c64mode" name="c64mode">
125 <item><ref id="fast" name="fast">
126 <item><ref id="slow" name="slow">
127 <item><ref id="toggle_videomode" name="toggle_videomode">
128 <item><ref id="videomode" name="videomode">
132 <sect1><tt/c16.h/<label id="c16.h"><p>
137 <sect1><tt/c64.h/<label id="c64.h"><p>
140 <item><ref id="get_ostype" name="get_ostype">
144 <sect1><tt/cbm.h/<label id="cbm.h"><p>
147 <!-- <item><ref id="cbm_k_acptr" name="cbm_k_acptr"> -->
148 <!-- <item><ref id="cbm_k_basin" name="cbm_k_basin"> -->
149 <!-- <item><ref id="cbm_k_bsout" name="cbm_k_bsout"> -->
150 <!-- <item><ref id="cbm_k_chkin" name="cbm_k_chkin"> -->
151 <!-- <item><ref id="cbm_k_ciout" name="cbm_k_ciout"> -->
152 <!-- <item><ref id="cbm_k_ckout" name="cbm_k_ckout"> -->
153 <!-- <item><ref id="cbm_k_clall" name="cbm_k_clall"> -->
154 <!-- <item><ref id="cbm_k_close" name="cbm_k_close"> -->
155 <!-- <item><ref id="cbm_k_clrch" name="cbm_k_clrch"> -->
156 <!-- <item><ref id="cbm_k_getin" name="cbm_k_getin"> -->
157 <!-- <item><ref id="cbm_k_iobase" name="cbm_k_iobase"> -->
158 <!-- <item><ref id="cbm_k_listen" name="cbm_k_listen"> -->
159 <!-- <item><ref id="cbm_k_load" name="cbm_k_load"> -->
160 <!-- <item><ref id="cbm_k_open" name="cbm_k_open"> -->
161 <!-- <item><ref id="cbm_k_readst" name="cbm_k_readst"> -->
162 <!-- <item><ref id="cbm_k_save" name="cbm_k_save"> -->
163 <!-- <item><ref id="cbm_k_setlfs" name="cbm_k_setlfs"> -->
164 <!-- <item><ref id="cbm_k_setnam" name="cbm_k_setnam"> -->
165 <!-- <item><ref id="cbm_k_talk" name="cbm_k_talk"> -->
166 <!-- <item><ref id="cbm_k_unlsn" name="cbm_k_unlsn"> -->
167 <!-- <item><ref id="cbm_load" name="cbm_load"> -->
168 <!-- <item><ref id="cbm_open" name="cbm_open"> -->
169 <!-- <item><ref id="cbm_opendir" name="cbm_opendir"> -->
170 <!-- <item><ref id="cbm_read" name="cbm_read"> -->
171 <!-- <item><ref id="cbm_readdir" name="cbm_readdir"> -->
172 <!-- <item><ref id="cbm_save" name="cbm_save"> -->
173 <!-- <item><ref id="cbm_write" name="cbm_write"> -->
179 <sect1><tt/cbm510.h/<label id="cbm510.h"><p>
182 <item><ref id="peekbsys" name="peekbsys">
183 <item><ref id="peekwsys" name="peekwsys">
184 <item><ref id="pokebsys" name="pokebsys">
185 <item><ref id="pokewsys" name="pokewsys">
189 <sect1><tt/cbm610.h/<label id="cbm610.h"><p>
192 <item><ref id="peekbsys" name="peekbsys">
193 <item><ref id="peekwsys" name="peekwsys">
194 <item><ref id="pokebsys" name="pokebsys">
195 <item><ref id="pokewsys" name="pokewsys">
199 <sect1><tt/cc65.h/<label id="cc65.h"><p>
202 <!-- <item><ref id="cc65_cos" name="cc65_cos"> -->
203 <!-- <item><ref id="cc65_idiv32by16r16" name="cc65_idiv32by16r16"> -->
204 <!-- <item><ref id="cc65_imul16x16r32" name="cc65_imul16x16r32"> -->
205 <!-- <item><ref id="cc65_imul8x8r16" name="cc65_imul8x8r16"> -->
206 <!-- <item><ref id="cc65_sin" name="cc65_sin"> -->
207 <!-- <item><ref id="cc65_udiv32by16r16" name="cc65_udiv32by16r16"> -->
208 <!-- <item><ref id="cc65_umul16x16r32" name="cc65_umul16x16r32"> -->
209 <!-- <item><ref id="cc65_umul16x8r32" name="cc65_umul16x8r32"> -->
210 <!-- <item><ref id="cc65_umul8x8r16" name="cc65_umul8x8r16"> -->
216 <sect1><tt/conio.h/<label id="conio.h"><p>
219 <item><ref id="bgcolor" name="bgcolor">
220 <item><ref id="bordercolor" name="bordercolor">
221 <item><ref id="cclear" name="cclear">
222 <item><ref id="cclearxy" name="cclearxy">
223 <item><ref id="cgetc" name="cgetc">
224 <item><ref id="chline" name="chline">
225 <item><ref id="chlinexy" name="chlinexy">
226 <item><ref id="clrscr" name="clrscr">
227 <item><ref id="cprintf" name="cprintf">
228 <item><ref id="cputc" name="cputc">
229 <item><ref id="cputcxy" name="cputcxy">
230 <item><ref id="cputs" name="cputs">
231 <item><ref id="cputsxy" name="cputsxy">
232 <item><ref id="cursor" name="cursor">
233 <item><ref id="cvline" name="cvline">
234 <item><ref id="cvlinexy" name="cvlinexy">
235 <item><ref id="gotox" name="gotox">
236 <item><ref id="gotoxy" name="gotoxy">
237 <item><ref id="gotoy" name="gotoy">
238 <item><ref id="kbhit" name="kbhit">
239 <item><ref id="revers" name="revers">
240 <item><ref id="screensize" name="screensize">
241 <item><ref id="textcolor" name="textcolor">
242 <item><ref id="vcprintf" name="vcprintf">
243 <item><ref id="wherex" name="wherex">
244 <item><ref id="wherey" name="wherey">
248 <sect1><tt/ctype.h/<label id="ctype.h"><p>
251 <item><ref id="isalnum" name="isalnum">
252 <item><ref id="isalpha" name="isalpha">
253 <item><ref id="isascii" name="isascii">
254 <item><ref id="isblank" name="isblank">
255 <item><ref id="iscntrl" name="iscntrl">
256 <item><ref id="isdigit" name="isdigit">
257 <item><ref id="isgraph" name="isgraph">
258 <item><ref id="islower" name="islower">
259 <item><ref id="isprint" name="isprint">
260 <item><ref id="ispunct" name="ispunct">
261 <item><ref id="isspace" name="isspace">
262 <item><ref id="isupper" name="isupper">
263 <item><ref id="isxdigit" name="isxdigit">
264 <item><ref id="tolower" name="tolower">
265 <item><ref id="toupper" name="toupper">
269 <sect1><tt/dbg.h/<label id="dbg.h"><p>
272 <!-- <item><ref id="DbgInit" name="DbgInit"> -->
278 <sect1><tt/dio.h/<label id="dio.h"><p>
280 <htmlurl url="dio.html" name="dio.html">
281 Low-level disk I/O API.
284 <sect1><tt/dirent.h/<label id="dirent.h"><p>
287 <item><ref id="_DE_ISDIR" name="_DE_ISDIR">
288 <item><ref id="_DE_ISLBL" name="_DE_ISLBL">
289 <item><ref id="_DE_ISLNK" name="_DE_ISLNK">
290 <item><ref id="_DE_ISREG" name="_DE_ISREG">
291 <item><ref id="closedir" name="closedir">
292 <item><ref id="opendir" name="opendir">
293 <item><ref id="readdir" name="readdir">
294 <item><ref id="rewinddir" name="rewinddir">
295 <item><ref id="seekdir" name="seekdir">
296 <item><ref id="telldir" name="telldir">
302 <sect1><tt/em.h/<label id="em.h"><p>
305 <item><ref id="em_commit" name="em_commit">
306 <item><ref id="em_copyfrom" name="em_copyfrom">
307 <item><ref id="em_copyto" name="em_copyto">
308 <item><ref id="em_install" name="em_install">
309 <item><ref id="em_load_driver" name="em_load_driver">
310 <item><ref id="em_map" name="em_map">
311 <item><ref id="em_pagecount" name="em_pagecount">
312 <item><ref id="em_uninstall" name="em_uninstall">
313 <item><ref id="em_unload" name="em_unload">
314 <item><ref id="em_use" name="em_use">
318 <sect1><tt/errno.h/<label id="errno.h"><p>
321 <!-- <item><ref id="_directerrno" name="_directerrno"> -->
322 <!-- <item><ref id="_mappederrno" name="_mappederrno"> -->
323 <!-- <item><ref id="_osmaperrno" name="_osmaperrno"> -->
324 <!-- <item><ref id="_seterrno" name="_seterrno"> -->
330 <sect1><tt/fcntl.h/<label id="fcntl.h"><p>
333 <item><ref id="close" name="close">
334 <item><ref id="creat" name="creat">
335 <item><ref id="open" name="open">
339 <sect1><tt/geos.h/<label id="geos.h"><p>
344 <sect1><tt/joystick.h/<label id="joystick.h"><p>
347 <item><ref id="joy_count" name="joy_count">
348 <item><ref id="joy_install" name="joy_install">
349 <item><ref id="joy_load_driver" name="joy_load_driver">
350 <item><ref id="joy_read" name="joy_read">
351 <item><ref id="joy_uninstall" name="joy_uninstall">
352 <item><ref id="joy_unload" name="joy_unload">
356 <sect1><tt/locale.h/<label id="locale.h"><p>
359 <item><ref id="localeconv" name="localeconv">
360 <item><ref id="setlocale" name="setlocale">
364 <sect1><tt/lynx.h/<label id="lynx.h"><p>
367 <!-- <item><ref id="lynx_eeprom_erase" name="lynx_eeprom_erase"> -->
368 <!-- <item><ref id="lynx_eeprom_read" name="lynx_eeprom_read"> -->
369 <!-- <item><ref id="lynx_eeprom_write" name="lynx_eeprom_write"> -->
370 <!-- <item><ref id="lynx_eeread" name="lynx_eeread"> -->
371 <!-- <item><ref id="lynx_eewrite" name="lynx_eewrite"> -->
372 <!-- <item><ref id="lynx_exec" name="lynx_exec"> -->
373 <!-- <item><ref id="lynx_load" name="lynx_load"> -->
379 <sect1><tt/modload.h/<label id="modload.h"><p>
382 <item><ref id="mod_load" name="mod_load">
383 <item><ref id="mod_free" name="mod_free">
387 <sect1><tt/mouse.h/<label id="mouse.h"><p>
390 <item><ref id="mouse_buttons" name="mouse_buttons">
391 <item><ref id="mouse_getbox" name="mouse_getbox">
392 <item><ref id="mouse_geterrormsg" name="mouse_geterrormsg">
393 <item><ref id="mouse_hide" name="mouse_hide">
394 <item><ref id="mouse_info" name="mouse_info">
395 <item><ref id="mouse_install" name="mouse_install">
396 <item><ref id="mouse_ioctl" name="mouse_ioctl">
397 <item><ref id="mouse_load_driver" name="mouse_load_driver">
398 <item><ref id="mouse_move" name="mouse_move">
399 <item><ref id="mouse_pos" name="mouse_pos">
400 <item><ref id="mouse_setbox" name="mouse_setbox">
401 <item><ref id="mouse_show" name="mouse_show">
402 <item><ref id="mouse_uninstall" name="mouse_uninstall">
403 <item><ref id="mouse_unload" name="mouse_unload">
407 <sect1><tt/nes.h/<label id="nes.h"><p>
410 <!-- <item><ref id="get_tv" name="get_tv"> -->
411 <!-- <item><ref id="waitvblank" name="waitvblank"> -->
417 <sect1><tt/o65.h/<label id="o65.h"><p>
419 The <tt/o65.h/ header file contains structure and constant definitions that
420 may be used when dealing with files in <htmlurl
421 url="http://www.6502.org/users/andre/o65/fileformat.html" name="o65 format">.
422 It does not declare any functions.
425 <sect1><tt/peekpoke.h/<label id="peekpoke.h"><p>
428 <item><ref id="PEEK" name="PEEK">
429 <item><ref id="PEEKW" name="PEEKW">
430 <item><ref id="POKE" name="POKE">
431 <item><ref id="POKEW" name="POKEW">
435 <sect1><tt/pet.h/<label id="pet.h"><p>
440 <sect1><tt/plus4.h/<label id="plus4.h"><p>
445 <sect1><tt/serial.h/<label id="serial.h"><p>
447 The <tt/serial.h/ header file contains definitions for initializing serial
451 <item><ref id="ser_close" name="ser_close">
452 <item><ref id="ser_get" name="ser_get">
453 <item><ref id="ser_install" name="ser_install">
454 <item><ref id="ser_ioctl" name="ser_ioctl">
455 <item><ref id="ser_load_driver" name="ser_load_driver">
456 <item><ref id="ser_open" name="ser_open">
457 <item><ref id="ser_put" name="ser_put">
458 <item><ref id="ser_status" name="ser_status">
459 <item><ref id="ser_uninstall" name="ser_uninstall">
460 <item><ref id="ser_unload" name="ser_unload">
464 <sect1><tt/setjmp.h/<label id="setjmp.h"><p>
467 <item><ref id="setjmp" name="setjmp">
468 <item><ref id="longjmp" name="longjmp">
472 <sect1><tt/signal.h/<label id="signal.h"><p>
475 <item><ref id="raise" name="raise">
476 <item><ref id="signal" name="signal">
480 <sect1><tt/stdarg.h/<label id="stdarg.h"><p>
485 <sect1><tt/stdbool.h/<label id="stdbool.h"><p>
490 <sect1><tt/stddef.h/<label id="stddef.h"><p>
493 <item><ref id="offsetof" name="offsetof">
497 <sect1><tt/stdio.h/<label id="stdio.h"><p>
500 <item><ref id="_poserror" name="_poserror">
501 <item><ref id="clearerr" name="clearerr">
502 <!-- <item><ref id="fclose" name="fclose"> -->
503 <!-- <item><ref id="fdopen" name="fdopen"> -->
504 <item><ref id="feof" name="feof">
505 <item><ref id="ferror" name="ferror">
506 <!-- <item><ref id="fflush" name="fflush"> -->
507 <!-- <item><ref id="fgetc" name="fgetc"> -->
508 <!-- <item><ref id="fgetpos" name="fgetpos"> -->
509 <!-- <item><ref id="fgets" name="fgets"> -->
510 <item><ref id="fileno" name="fileno">
511 <!-- <item><ref id="fopen" name="fopen"> -->
512 <!-- <item><ref id="fprintf" name="fprintf"> -->
513 <!-- <item><ref id="fputc" name="fputc"> -->
514 <!-- <item><ref id="fputs" name="fputs"> -->
515 <!-- <item><ref id="fread" name="fread"> -->
516 <!-- <item><ref id="freopen" name="freopen"> -->
517 <!-- <item><ref id="fscanf" name="fscanf"> -->
518 <!-- <item><ref id="fseek" name="fseek"> -->
519 <!-- <item><ref id="fsetpos" name="fsetpos"> -->
520 <!-- <item><ref id="ftell" name="ftell"> -->
521 <!-- <item><ref id="fwrite" name="fwrite"> -->
522 <!-- <item><ref id="getc" name="getc"> -->
523 <!-- <item><ref id="getchar" name="getchar"> -->
524 <!-- <item><ref id="gets" name="gets"> -->
525 <!-- <item><ref id="printf" name="printf"> -->
526 <!-- <item><ref id="putc" name="putc"> -->
527 <!-- <item><ref id="putchar" name="putchar"> -->
528 <!-- <item><ref id="puts" name="puts"> -->
529 <item><ref id="rename" name="rename">
530 <item><ref id="remove" name="remove">
531 <!-- <item><ref id="rewind" name="rewind"> -->
532 <!-- <item><ref id="scanf" name="scanf"> -->
533 <!-- <item><ref id="snprintf" name="snprintf"> -->
534 <!-- <item><ref id="sprintf" name="sprintf"> -->
535 <!-- <item><ref id="sscanf" name="sscanf"> -->
536 <!-- <item><ref id="vfprintf" name="vfprintf"> -->
537 <!-- <item><ref id="vfscanf" name="vfscanf"> -->
538 <!-- <item><ref id="vprintf" name="vprintf"> -->
539 <!-- <item><ref id="vscanf" name="vscanf"> -->
540 <!-- <item><ref id="vsnprintf" name="vsnprintf"> -->
541 <!-- <item><ref id="vsprintf" name="vsprintf"> -->
542 <!-- <item><ref id="vsscanf" name="vsscanf"> -->
548 <sect1><tt/stdlib.h/<label id="stdlib.h"><p>
551 <item><ref id="_heapadd" name="_heapadd">
552 <item><ref id="_heapblocksize" name="_heapblocksize">
553 <item><ref id="_heapmaxavail" name="_heapmaxavail">
554 <item><ref id="_heapmemavail" name="_heapmemavail">
555 <item><ref id="_randomize" name="_randomize">
556 <item><ref id="_swap" name="_swap">
557 <item><ref id="abort" name="abort">
558 <item><ref id="abs" name="abs">
559 <item><ref id="atexit" name="atexit">
560 <item><ref id="atoi" name="atoi">
561 <item><ref id="atol" name="atol">
562 <item><ref id="bsearch" name="bsearch">
563 <item><ref id="calloc" name="calloc">
564 <item><ref id="div" name="div">
565 <item><ref id="exit" name="exit">
566 <item><ref id="free" name="free">
567 <item><ref id="getenv" name="getenv">
568 <item><ref id="itoa" name="itoa">
569 <item><ref id="labs" name="labs">
570 <item><ref id="ltoa" name="ltoa">
571 <item><ref id="malloc" name="malloc">
572 <item><ref id="perror" name="perror">
573 <!-- <item><ref id="posix_memalign" name="posix_memalign"> -->
574 <!-- <item><ref id="putenv" name="putenv"> -->
575 <item><ref id="qsort" name="qsort">
576 <item><ref id="rand" name="rand">
577 <item><ref id="realloc" name="realloc">
578 <item><ref id="srand" name="srand">
579 <!-- <item><ref id="system" name="system"> -->
580 <item><ref id="ultoa" name="ultoa">
581 <item><ref id="utoa" name="utoa">
587 <sect1><tt/string.h/<label id="string.h"><p>
590 <item><ref id="_stroserror" name="_stroserror">
591 <item><ref id="bzero" name="bzero">
592 <item><ref id="memchr" name="memchr">
593 <item><ref id="memcmp" name="memcmp">
594 <item><ref id="memcpy" name="memcpy">
595 <item><ref id="memmove" name="memmove">
596 <item><ref id="memset" name="memset">
597 <item><ref id="strcasecmp" name="strcasecmp">
598 <item><ref id="strcat" name="strcat">
599 <item><ref id="strchr" name="strchr">
600 <item><ref id="strcmp" name="strcmp">
601 <item><ref id="strcoll" name="strcoll">
602 <item><ref id="strcpy" name="strcpy">
603 <item><ref id="strcspn" name="strcspn">
604 <item><ref id="strdup" name="strdup">
605 <item><ref id="strerror" name="strerror">
606 <item><ref id="stricmp" name="stricmp">
607 <item><ref id="strlen" name="strlen">
608 <item><ref id="strlower" name="strlower">
609 <item><ref id="strlwr" name="strlwr">
610 <item><ref id="strncat" name="strncat">
611 <item><ref id="strncmp" name="strncmp">
612 <item><ref id="strncpy" name="strncpy">
613 <item><ref id="strrchr" name="strrchr">
614 <item><ref id="strspn" name="strspn">
615 <item><ref id="strstr" name="strstr">
616 <item><ref id="strtok" name="strtok">
617 <item><ref id="strxfrm" name="strxfrm">
618 <item><ref id="strupper" name="strupper">
619 <item><ref id="strupr" name="strupr">
625 <sect1><tt/tgi.h/<label id="tgi.h"><p>
628 <item><ref id="tgi_arc" name="tgi_arc">
629 <item><ref id="tgi_bar" name="tgi_bar">
630 <item><ref id="tgi_circle" name="tgi_circle">
631 <item><ref id="tgi_clear" name="tgi_clear">
632 <item><ref id="tgi_done" name="tgi_done">
633 <item><ref id="tgi_ellipse" name="tgi_ellipse">
634 <item><ref id="tgi_getaspectratio" name="tgi_getaspectratio">
635 <item><ref id="tgi_getcolor" name="tgi_getcolor">
636 <item><ref id="tgi_getcolorcount" name="tgi_getcolorcount">
637 <item><ref id="tgi_getdefpalette" name="tgi_getdefpalette">
638 <item><ref id="tgi_geterror" name="tgi_geterror">
639 <item><ref id="tgi_geterrormsg" name="tgi_geterrormsg">
640 <item><ref id="tgi_getmaxcolor" name="tgi_getmaxcolor">
641 <item><ref id="tgi_getmaxx" name="tgi_getmaxx">
642 <item><ref id="tgi_getmaxy" name="tgi_getmaxy">
643 <item><ref id="tgi_getpagecount" name="tgi_getpagecount">
644 <item><ref id="tgi_getpalette" name="tgi_getpalette">
645 <item><ref id="tgi_getpixel" name="tgi_getpixel">
646 <item><ref id="tgi_getxres" name="tgi_getxres">
647 <item><ref id="tgi_getyres" name="tgi_getyres">
648 <item><ref id="tgi_gotoxy" name="tgi_gotoxy">
649 <item><ref id="tgi_init" name="tgi_init">
650 <item><ref id="tgi_install" name="tgi_install">
651 <item><ref id="tgi_ioctl" name="tgi_ioctl">
652 <item><ref id="tgi_line" name="tgi_line">
653 <item><ref id="tgi_lineto" name="tgi_lineto">
654 <item><ref id="tgi_load_driver" name="tgi_load_driver">
655 <item><ref id="tgi_outtext" name="tgi_outtext">
656 <item><ref id="tgi_outtextxy" name="tgi_outtextxy">
657 <item><ref id="tgi_setaspectratio" name="tgi_setaspectratio">
658 <item><ref id="tgi_setcolor" name="tgi_setcolor">
659 <item><ref id="tgi_setdrawpage" name="tgi_setdrawpage">
660 <item><ref id="tgi_setpalette" name="tgi_setpalette">
661 <item><ref id="tgi_setpixel" name="tgi_setpixel">
662 <item><ref id="tgi_setviewpage" name="tgi_setviewpage">
663 <item><ref id="tgi_gettextheight" name="tgi_gettextheight">
664 <item><ref id="tgi_settextstyle" name="tgi_settextstyle">
665 <item><ref id="tgi_gettextwidth" name="tgi_gettextwidth">
666 <item><ref id="tgi_uninstall" name="tgi_uninstall">
667 <item><ref id="tgi_unload" name="tgi_unload">
670 <sect1><tt/time.h/<label id="time.h"><p>
673 <!-- <item><ref id="_systime" name="_systime"> -->
674 <!-- <item><ref id="asctime" name="asctime"> -->
675 <item><ref id="clock" name="clock">
676 <!-- <item><ref id="ctime" name="ctime"> -->
677 <!-- <item><ref id="gmtime" name="gmtime"> -->
678 <!-- <item><ref id="localtime" name="localtime"> -->
679 <!-- <item><ref id="mktime" name="mktime"> -->
680 <!-- <item><ref id="strftime" name="strftime"> -->
681 <item><ref id="time" name="time">
687 <sect1><tt/unistd.h/<label id="unistd.h"><p>
690 <!-- <item><ref id="chdir" name="chdir"> -->
691 <item><ref id="exec" name="exec">
692 <!-- <item><ref id="getcwd" name="getcwd"> -->
693 <item><ref id="getopt" name="getopt">
694 <!-- <item><ref id="lseek" name="lseek"> -->
695 <!-- <item><ref id="mkdir" name="mkdir"> -->
696 <!-- <item><ref id="read" name="read"> -->
697 <!-- <item><ref id="rmdir" name="rmdir"> -->
698 <item><ref id="sleep" name="sleep">
699 <item><ref id="unlink" name="unlink">
700 <!-- <item><ref id="write" name="write"> -->
706 <sect1><tt/vic20.h/<label id="vic20.h"><p>
711 <sect1><tt/zlib.h/<label id="zlib.h"><p>
714 <!-- <item><ref id="adler32" name="adler32"> -->
715 <!-- <item><ref id="crc32" name="crc32"> -->
716 <!-- <item><ref id="inflatemem" name="inflatemem"> -->
717 <!-- <item><ref id="uncompress" name="uncompress"> -->
723 <sect>Alphabetical function reference<p>
725 <sect1>_DE_ISDIR<label id="_DE_ISDIR"><p>
729 <tag/Function/Determine if a directory entry specifies a directory.
730 <tag/Header/<tt/<ref id="dirent.h" name="dirent.h">/
731 <tag/Declaration/<tt/int _DE_ISDIR(unsigned char type);/
732 <tag/Description/The function is called with the type of a directory entry
733 taken from a <tt/struct dirent/ and returns true if the entry designates
737 <item>The function is actually a macro.
739 <tag/Availability/cc65
741 <ref id="_DE_ISLBL" name="_DE_ISLBL">,
742 <ref id="_DE_ISLNK" name="_DE_ISLNK">,
743 <ref id="_DE_ISREG" name="_DE_ISREG">
749 <sect1>_DE_ISLBL<label id="_DE_ISLBL"><p>
753 <tag/Function/Determine if a directory entry specifies a disk label.
754 <tag/Header/<tt/<ref id="dirent.h" name="dirent.h">/
755 <tag/Declaration/<tt/int _DE_ISLBL(unsigned char type);/
756 <tag/Description/The function is called with the type of a directory entry
757 taken from a <tt/struct dirent/ and returns true if the entry designates
761 <item>The function is actually a macro.
763 <tag/Availability/cc65
765 <ref id="_DE_ISDIR" name="_DE_ISDIR">,
766 <ref id="_DE_ISLNK" name="_DE_ISLNK">,
767 <ref id="_DE_ISREG" name="_DE_ISREG">
773 <sect1>_DE_ISLNK<label id="_DE_ISLNK"><p>
777 <tag/Function/Determine if a directory entry specifies a link.
778 <tag/Header/<tt/<ref id="dirent.h" name="dirent.h">/
779 <tag/Declaration/<tt/int _DE_ISLNK(unsigned char type);/
780 <tag/Description/The function is called with the type of a directory entry
781 taken from a <tt/struct dirent/ and returns true if the entry designates
785 <item>The function is actually a macro.
787 <tag/Availability/cc65
789 <ref id="_DE_ISDIR" name="_DE_ISDIR">,
790 <ref id="_DE_ISLBL" name="_DE_ISLBL">,
791 <ref id="_DE_ISREG" name="_DE_ISREG">
797 <sect1>_DE_ISREG<label id="_DE_ISREG"><p>
801 <tag/Function/Determine if a directory entry specifies a regular file.
802 <tag/Header/<tt/<ref id="dirent.h" name="dirent.h">/
803 <tag/Declaration/<tt/int _DE_ISREG(unsigned char type);/
804 <tag/Description/The function is called with the type of a directory entry
805 taken from a <tt/struct dirent/ and returns true if the entry designates
809 <item>The function is actually a macro.
810 <item>A "regular file" means anything with data in it. This might still mean
811 that special processing is needed, when accessing the file. Relative files of
812 the CBM systems are classified as being "regular" files, for example.
814 <tag/Availability/cc65
816 <ref id="_DE_ISDIR" name="_DE_ISDIR">,
817 <ref id="_DE_ISLBL" name="_DE_ISLBL">,
818 <ref id="_DE_ISLNK" name="_DE_ISLNK">
824 <sect1>_heapadd<label id="_heapadd"><p>
828 <tag/Function/Add a block to the heap.
829 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
830 <tag/Declaration/<tt/void __fastcall__ _heapadd (void* mem, size_t size);/
831 <tag/Description/The function adds a block of raw memory to the heap.
834 <item>The minimum blocksize that can be added is 6 bytes; the function will
835 ignore smaller blocks.
837 <tag/Availability/cc65
839 <ref id="_heapblocksize" name="_heapblocksize">,
840 <ref id="_heapmaxavail" name="_heapmaxavail">,
841 <ref id="_heapmemavail" name="_heapmemavail">,
842 <ref id="calloc" name="calloc">,
843 <ref id="free" name="free">,
844 <ref id="malloc" name="malloc">,
845 <ref id="realloc" name="realloc">
851 <sect1>_heapblocksize<label id="_heapblocksize"><p>
855 <tag/Function/Return the size of an allocated block.
856 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
857 <tag/Declaration/<tt/size_t __fastcall__ _heapblocksize (const void* block);/
858 <tag/Description/The function returns the size of a block that must have
859 previously been allocated by <tt/<ref id="malloc" name="malloc">/, <tt/<ref
860 id="calloc" name="calloc">/ or <tt/<ref id="realloc" name="realloc">/.
863 <item>Passing a pointer to a block that was is not the result of one of the
864 allocation functions, or that has been free'd will give unpredicable results.
866 <tag/Availability/cc65
868 <ref id="_heapadd" name="_heapadd">,
869 <ref id="_heapmaxavail" name="_heapmaxavail">,
870 <ref id="_heapmemavail" name="_heapmemavail">,
871 <ref id="calloc" name="calloc">,
872 <ref id="free" name="free">,
873 <ref id="malloc" name="malloc">,
874 <ref id="realloc" name="realloc">
880 <sect1>_heapmaxavail<label id="_heapmaxavail"><p>
884 <tag/Function/Return the largest block that is available on the heap.
885 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
886 <tag/Declaration/<tt/size_t _heapmaxavail (void);/
887 <tag/Description/The function returns the size of the largest block that may
888 be allocated from the heap using <tt/<ref id="malloc" name="malloc">/.
889 <tag/Availability/cc65
891 <ref id="_heapadd" name="_heapadd">,
892 <ref id="_heapblocksize" name="_heapblocksize">,
893 <ref id="_heapmemavail" name="_heapmemavail">,
894 <ref id="calloc" name="calloc">,
895 <ref id="free" name="free">,
896 <ref id="malloc" name="malloc">,
897 <ref id="realloc" name="realloc">
903 <sect1>_heapmemavail<label id="_heapmemavail"><p>
907 <tag/Function/Return the total available space on the heap.
908 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
909 <tag/Declaration/<tt/size_t __fastcall__ _heapmemavail (void);/
910 <tag/Description/The function returns the total number of bytes available on
914 <item>This function is of less use than usually assumed, since the returned
915 heap space may be available but not in one block. So even if this function
916 says that several times more heap space is available than needed, <ref
917 id="malloc" name="malloc"> may still return <tt/NULL/.
919 <tag/Availability/cc65
921 <ref id="_heapadd" name="_heapadd">,
922 <ref id="_heapblocksize" name="_heapblocksize">,
923 <ref id="_heapmaxavail" name="_heapmaxavail">,
924 <ref id="calloc" name="calloc">,
925 <ref id="free" name="free">,
926 <ref id="malloc" name="malloc">,
927 <ref id="realloc" name="realloc">
933 <sect1>_poserror<label id="_poserror"><p>
937 <tag/Function/Print an error message for the error in <tt/_oserror/.
938 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
939 <tag/Declaration/<tt/void __fastcall__ _poserror (const char* msg);/
940 <tag/Description/<tt/_poserror/ prints an error message to <tt/stderr/. If
941 <tt/msg/ is not <tt/NULL/ and not an empty string, it is printed followed by
942 a colon and a blank. Then the error message for the current contents of
943 <tt/_oserror/ are printed followed by a newline. The message output is the
944 same as returned by <tt/<ref id="_stroserror" name="_stroserror">/ with an
945 argument of <tt/_oserror/.
948 <item>Since operating system specific error code are - you guessed it -
949 operating system specific, the value in <tt/_oserror/ and the message that is
950 printed depends on the cc65 target.
951 <item>The function is only available as fastcall function, so it may only
952 be used in presence of a prototype.
954 <tag/Availability/cc65
956 <ref id="_stroserror" name="_stroserror">,
957 <ref id="perror" name="perror">
963 <sect1>_randomize<label id="_randomize"><p>
967 <tag/Function/Initialize the pseudo random number generator.
968 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
969 <tag/Declaration/<tt/void _randomize (void);/
970 <tag/Description/The function initializes the random number generator with
971 a seed derived from fast changing hardware events, so the seed itself can be
972 considered random to a certain degree.
973 <tag/Limits/<itemize>
974 <item>The randomness of the seed depends on the machine hardware.
976 <tag/Availability/cc65
978 <ref id="rand" name="rand">,
979 <ref id="srand" name="srand">
985 <sect1>_stroserror<label id="_stroserror"><p>
989 <tag/Function/Return a string describing an OS specific error code.
990 <tag/Header/<tt/<ref id="string.h" name="string.h">/
991 <tag/Declaration/<tt/const char* __fastcall__ _stroserror (unsigned char errcode);/
992 <tag/Description/<tt/_stroserror/ will return a string describing the given
993 operating system specific error code.
994 <tag/Limits/<itemize>
995 <item>Since operating system specific error code are - you guessed it -
996 operating system specific, the parameter and the string returned depend on the
998 <item>The function is only available as fastcall function, so it may only be
999 used in presence of a prototype.
1001 <tag/Availability/cc65
1003 <ref id="strerror" name="strerror">
1009 <sect1>_swap<label id="_swap"><p>
1013 <tag/Function/Swap the contents of memory areas.
1014 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1015 <tag/Declaration/<tt/void __fastcall__ _swap (void* p, void* q, size_t size);/
1016 <tag/Description/<tt/_swap/ will swap (exchange) the contents of the two memory
1017 areas pointed to by <tt/p/ and <tt/q/. Both memory areas are assumed to be
1018 <tt/size/ bytes in size.
1019 <tag/Limits/<itemize>
1020 <item>The memory areas may not overlap, otherwise the results are undefined.
1021 <item>The function is only available as fastcall function, so it may only be
1022 used in presence of a prototype.
1024 <tag/Availability/cc65
1026 <ref id="memcpy" name="memcpy">,
1027 <ref id="memmove" name="memmove">
1033 <sect1>_sys<label id="_sys"><p>
1037 <tag/Function/Call a subroutine passing register values.
1038 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
1039 <tag/Declaration/<tt/void __fastcall__ _sys (struct regs* r);/
1040 <tag/Description/The function will call the subroutine at the address
1041 specified in the <tt/pc/ member of the passed <tt/regs/ structure. All
1042 registers and the CPU flags are set to the values given in the <tt/regs/
1043 structure. On return from the subroutine, the new values of the registers and
1044 flags are stored back overwriting the old values.
1045 <tag/Limits/<itemize>
1046 <item>Bits 4 and 5 of the flags value in the <tt/regs/ structure are ignored
1047 when calling the subroutine (they are unchanged from their current values).
1048 <item>The function is only available as fastcall function, so it may only be
1049 used in presence of a prototype.
1051 <tag/Availability/cc65
1057 <sect1>BRK<label id="BRK"><p>
1061 <tag/Function/Insert a 6502 BRK instrunction into the code.
1062 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
1063 <tag/Declaration/<tt/void BRK (void);/
1064 <tag/Description/The function will insert a 6502 BRK instruction into the code
1065 which may be used to trigger a debugger.
1066 <tag/Limits/<itemize>
1067 <item>The function is actually a macro.
1068 <item>The inserted instruction may lead to unexpected results if no debugger
1071 <tag/Availability/cc65
1073 <ref id="CLI" name="CLI">,
1074 <ref id="SEI" name="SEI">
1080 <sect1>CLI<label id="CLI"><p>
1084 <tag/Function/Insert a 6502 CLI instrunction into the code.
1085 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
1086 <tag/Declaration/<tt/void CLI (void);/
1087 <tag/Description/The function will insert a 6502 CLI instruction into the code,
1088 so interrupts are enabled. Enabling interrupts has no effects if they are
1089 already enabled (the default).
1090 <tag/Limits/<itemize>
1091 <item>The function is actually a macro.
1092 <item>Disabling interrupts may lead to unexpected results.
1094 <tag/Availability/cc65
1096 <ref id="BRK" name="BRK">,
1097 <ref id="SEI" name="SEI">
1103 <sect1>PEEK<label id="PEEK"><p>
1107 <tag/Function/Read a byte from memory.
1108 <tag/Header/<tt/<ref id="peekpoke.h" name="peekpoke.h">/
1109 <tag/Declaration/<tt/unsigned char PEEK (unsigned addr);/
1110 <tag/Description/The function will read the absolute memory given by <tt/addr/
1111 and return the value read.
1112 <tag/Limits/<itemize>
1113 <item>The function is actually a macro.
1114 <item>This function depends highly on the platform and environment.
1116 <tag/Availability/cc65
1118 <ref id="PEEKW" name="PEEKW">,
1119 <ref id="POKE" name="POKE">
1125 <sect1>PEEKW<label id="PEEKW"><p>
1129 <tag/Function/Read a word (two bytes) from memory.
1130 <tag/Header/<tt/<ref id="peekpoke.h" name="peekpoke.h">/
1131 <tag/Declaration/<tt/unsigned PEEKW (unsigned addr);/
1132 <tag/Description/The function will read the absolute memory given by <tt/addr/
1133 and return the value read. The byte read from the higher address is the high
1134 byte of the return value.
1135 <tag/Limits/<itemize>
1136 <item>The function is actually a macro.
1137 <item>This function depends highly on the platform and environment.
1138 <item>The order in which the two bytes are read is unspecified and may
1139 depend of the address expression used.
1141 <tag/Availability/cc65
1143 <ref id="PEEK" name="PEEK">,
1144 <ref id="POKE" name="POKE">
1150 <sect1>POKE<label id="POKE"><p>
1154 <tag/Function/Write a byte to memory.
1155 <tag/Header/<tt/<ref id="peekpoke.h" name="peekpoke.h">/
1156 <tag/Declaration/<tt/void POKE (unsigned addr, unsigned char val);/
1157 <tag/Description/The function writes the value <tt/val/ to the absolute
1158 memory address given by <tt/addr/.
1159 <tag/Limits/<itemize>
1160 <item>The function is actually a macro.
1161 <item>This function depends highly on the platform and environment.
1162 <item>Careless use will cause the program to act strange or may crash the
1165 <tag/Availability/cc65
1167 <ref id="PEEK" name="PEEK">,
1168 <ref id="POKEW" name="POKEW">
1174 <sect1>POKEW<label id="POKEW"><p>
1178 <tag/Function/Write a word (two bytes) to memory.
1179 <tag/Header/<tt/<ref id="peekpoke.h" name="peekpoke.h">/
1180 <tag/Declaration/<tt/void POKEW (unsigned addr, unsigned val);/
1181 <tag/Description/The function writes the value <tt/val/ to the absolute
1182 memory address given by <tt/addr/. The low byte of <tt/val/ is written to
1183 the <tt/addr/, the high byte is written to <tt/addr+1/.
1184 <tag/Limits/<itemize>
1185 <item>The function is actually a macro.
1186 <item>This function depends highly on the platform and environment.
1187 <item>Careless use will cause the program to act strange or may crash the
1189 <item>The order in which the two bytes are written is unspecified and may
1190 depend of the address expression used.
1192 <tag/Availability/cc65
1194 <ref id="PEEK" name="PEEK">,
1195 <ref id="POKE" name="POKE">
1201 <sect1>SEI<label id="SEI"><p>
1205 <tag/Function/Insert a 6502 SEI instrunction into the code.
1206 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
1207 <tag/Declaration/<tt/void SEI (void);/
1208 <tag/Description/The function will insert a 6502 SEI instruction into the code,
1209 so interrupts are disabled. Note that non maskable interrupts cannot be
1211 <tag/Limits/<itemize>
1212 <item>The function is actually a macro.
1213 <item>Disabling interrupts may lead to unexpected results.
1215 <tag/Availability/cc65
1217 <ref id="BRK" name="BRK">,
1218 <ref id="CLI" name="CLI">
1224 <sect1>abort<label id="abort"><p>
1228 <tag/Function/Terminates a program abnormally.
1229 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1230 <tag/Declaration/<tt/void abort (void);/
1231 <tag/Description/<tt/abort/ raises <tt/SIGABRT/, writes a termination message
1232 on stderr, then terminates the program with an exit code of 3.
1233 <tag/Availability/ISO 9899
1235 <ref id="assert" name="assert">,
1236 <ref id="exit" name="exit">,
1237 <ref id="raise" name="raise">
1243 <sect1>abs<label id="abs"><p>
1247 <tag/Function/Returns the absolute value of an integer.
1248 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1249 <tag/Declaration/<tt/int __fastcall__ abs (int v);/
1250 <tag/Description/<tt/abs/ returns the absolute value of the argument passed to
1252 <tag/Limits/<itemize>
1253 <item>The return value is undefined if <tt/INT_MIN/ is passed to the function.
1254 <item>The function is only available as fastcall function, so it may only be
1255 used in presence of a prototype.
1257 <tag/Availability/ISO 9899
1259 <ref id="labs" name="labs">
1265 <sect1>assert<label id="assert"><p>
1269 <tag/Function/Test a condition and possibly abort.
1270 <tag/Header/<tt/<ref id="assert.h" name="assert.h">/
1271 <tag/Declaration/<tt/void assert (int cond);/
1272 <tag/Description/<tt/assert/ is a macro that expands to a <tt/id/
1273 statement. If the condition evaluates t zero (false), assert prints a message
1274 on stderr and aborts the program.
1275 <tag/Limits/<itemize>
1276 <item>The function is actually a macro.
1278 <tag/Availability/ISO 9899
1280 <ref id="abort" name="abort">,
1281 <ref id="exit" name="exit">
1287 <sect1>atexit<label id="atexit"><p>
1291 <tag/Function/Register an exit function.
1292 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1293 <tag/Declaration/<tt/int __fastcall__ atexit (void (*exitfunc) (void));/
1294 <tag/Description/<tt/atexit/ registers the function pointed to by
1295 <tt/exitfunc/ as an exit function. Exit functions are called when the program
1296 terminates, they are called in LIFO order (the last function registered is
1297 called first). <tt/atexit/ returns zero on success and a nonzero value on
1299 <tag/Limits/<itemize>
1300 <item>A maximum of 5 exit functions can be registered.
1301 <item>There is no way to unregister an exit function.
1302 <item>The function is only available as fastcall function, so it may only be
1303 used in presence of a prototype.
1305 <tag/Availability/ISO 9899
1307 <ref id="abort" name="abort">,
1308 <ref id="exit" name="exit">
1314 <sect1>atmos_load<label id="atmos_load"><p>
1318 <tag/Function/Load Atmos tape.
1319 <tag/Header/<tt/<ref id="atmos.h" name="atmos.h">/
1320 <tag/Declaration/<tt/void __fastcall__ atmos_load(const char* name);/
1321 <tag/Description/<tt/atmos_load/ reads a memory block from tape.
1322 <tag/Availability/cc65
1324 <ref id="atmos_save" name="atmos_save">
1330 <sect1>atmos_save<label id="atmos_save"><p>
1334 <tag/Function/Save Atmos tape.
1335 <tag/Header/<tt/<ref id="atmos.h" name="atmos.h">/
1336 <tag/Declaration/<tt/void __fastcall__ atmos_save(const char* name, const void* start, const void* end);/
1337 <tag/Description/<tt/atmos_save/ writes a memory block to tape.
1338 <tag/Availability/cc65
1340 <ref id="atmos_load" name="atmos_load">
1342 atmos_save("hires", 0xa000, 0xc000);
1348 <sect1>atoi<label id="atoi"><p>
1352 <tag/Function/Convert a string to an integer.
1353 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1354 <tag/Declaration/<tt/int __fastcall__ atoi (const char* s);/
1355 <tag/Description/<tt/atoi/ converts the given string into an integer.
1356 Conversion stops as soon as any invalid character is encountered.
1357 <tag/Limits/<itemize>
1358 <item>There is no way to detect any conversion errors.
1359 <item>The function does not check for an numerical overflow when converting.
1360 <item>The function is only available as fastcall function, so it may only be
1361 used in presence of a prototype.
1363 <tag/Availability/ISO 9899
1365 <ref id="atol" name="atol">,
1366 <ref id="itoa" name="itoa">,
1367 <ref id="ltoa" name="ltoa">,
1368 <ref id="ultoa" name="ultoa">,
1369 <ref id="utoa" name="utoa">
1375 <sect1>atol<label id="atol"><p>
1379 <tag/Function/Convert a string to a long integer.
1380 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1381 <tag/Declaration/<tt/long __fastcall__ atol (const char* s);/
1382 <tag/Description/<tt/atol/ converts the given string into a long integer.
1383 Conversion stops as soon as any invalid character is encountered.
1384 <tag/Limits/<itemize>
1385 <item>There is no way to detect any conversion errors.
1386 <item>The function does not check for an numerical overflow when converting.
1387 <item>The function is only available as fastcall function, so it may only be
1388 used in presence of a prototype.
1390 <tag/Availability/ISO 9899
1392 <ref id="atoi" name="atoi">,
1393 <ref id="itoa" name="itoa">,
1394 <ref id="ltoa" name="ltoa">,
1395 <ref id="ultoa" name="ultoa">,
1396 <ref id="utoa" name="utoa">
1402 <sect1>bgcolor<label id="bgcolor"><p>
1406 <tag/Function/Set the background text color.
1407 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1408 <tag/Declaration/<tt/unsigned char __fastcall__ bgcolor (unsigned char color);/
1409 <tag/Description/The function will set a new background color and return the
1410 old (current) one. The background color is valid for the whole text output
1411 area of the screen, not just for new text.
1412 <tag/Limits/<itemize>
1413 <item>Background colors are system dependent. The function may have no effect
1414 on systems where the background color cannot be changed.
1415 <item>The function is only available as fastcall function, so it may only be
1416 used in presence of a prototype.
1418 <tag/Availability/cc65
1420 <ref id="bordercolor" name="bordercolor">,
1421 <ref id="textcolor" name="textcolor">
1427 <sect1>bordercolor<label id="bordercolor"><p>
1431 <tag/Function/Set the border (frame) color.
1432 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1433 <tag/Declaration/<tt/unsigned char __fastcall__ bordercolor (unsigned char color);/
1434 <tag/Description/The function will set a new border color. It returns the old
1435 (current) border color.
1436 <tag/Limits/<itemize>
1437 <item>Border colors are system dependent. The function may have no effect
1438 on systems where the border color cannot be changed.
1439 <item>The function is only available as fastcall function, so it may only
1440 be used in presence of a prototype.
1442 <tag/Availability/cc65
1444 <ref id="bgcolor" name="bgcolor">,
1445 <ref id="textcolor" name="textcolor">
1451 <sect1>bsearch<label id="bsearch"><p>
1455 <tag/Function/Do a binary search in a sorted array.
1456 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1457 <tag/Declaration/<tt/void* __fastcall__ bsearch (const void* key,
1458 const void* base, size_t n, size_t size,
1459 int (*cmp) (const void*, const void*));/
1460 <tag/Description/<tt/bsearch/ searches a sorted array for a member that
1461 matches the one pointed to by <tt/key/. <tt/base/ is the address of the array,
1462 <tt/n/ is the number of elements, <tt/size/ the size of an element and <tt/cmp/
1463 the function used to compare the members against the key. The function returns
1464 a pointer to the member found, or <tt/NULL/ if there was no match.
1467 <item>The contents of the array must be sorted in ascending order according to
1468 the compare function given.
1469 <item>If there are multiple members that match the key, the function will
1470 return one of the members.
1471 <item>The function is only available as fastcall function, so it may only
1472 be used in presence of a prototype.
1474 <tag/Availability/ISO 9899
1476 <ref id="qsort" name="qsort">
1482 <sect1>bzero<label id="bzero"><p>
1486 <tag/Function/Fill a memory area with zeroes.
1487 <tag/Header/<tt/<ref id="string.h" name="string.h">/
1488 <tag/Declaration/<tt/void __fastcall__ bzero (void* p, size_t count);/
1489 <tag/Description/<tt/bzero/ fills the memory area pointed to by <tt/p/ with
1493 <item>The function is non standard and therefore only available in non ANSI
1494 mode. You should use <tt/<ref id="memset" name="memset">/ instead.
1495 <item>The function is only available as fastcall function, so it may only
1496 be used in presence of a prototype.
1498 <tag/Availability/cc65
1500 <ref id="_swap" name="_swap">,
1501 <ref id="memcpy" name="memcpy">,
1502 <ref id="memmove" name="memmove">,
1503 <ref id="memset" name="memset">,
1509 <sect1>c64mode<label id="c64mode"><p>
1513 <tag/Function/Switch the C128 into C64 compatible mode.
1514 <tag/Header/<tt/<ref id="c128.h" name="c128.h">/
1515 <tag/Declaration/<tt/void c64mode (void);/
1516 <tag/Description/The function will cause the machine to reboot into C64 mode.
1517 <tag/Limits/<itemize>
1518 <item>The function is specific to the C128.
1519 <item>The function will not return to the caller.
1521 <tag/Availability/C128
1527 <sect1>calloc<label id="calloc"><p>
1531 <tag/Function/Allocate and clear memory.
1532 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1533 <tag/Declaration/<tt/void* __fastcall__ calloc (size_t n, size_t size);/
1534 <tag/Description/<tt/calloc/ allocates memory for an array of <tt/n/ elements
1535 of size <tt/size/, clears the whole block with binary zeroes and returns a
1536 pointer to it. On error (not enough memory available), <tt/calloc/ returns
1540 <item>Clearing the memory may not have the expected effect on all platforms:
1541 pointers in the block may not be <tt/NULL/ and floating point variables may
1542 not be zero (0.0). In other words: The "clearing" effect of this function
1543 should be used with care for portable programs.
1544 <item>The function is only available as fastcall function, so it may only
1545 be used in presence of a prototype.
1547 <tag/Availability/ISO 9899
1549 <ref id="_heapadd" name="_heapadd">,
1550 <ref id="_heapblocksize" name="_heapblocksize">,
1551 <ref id="_heapmaxavail" name="_heapmaxavail">,
1552 <ref id="_heapmemavail" name="_heapmemavail">,
1553 <ref id="free" name="free">,
1554 <ref id="malloc" name="malloc">,
1555 <ref id="realloc" name="realloc">
1561 <sect1>cclear<label id="cclear"><p>
1565 <tag/Function/Clear part of a line (write a given number of spaces).
1566 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1567 <tag/Declaration/<tt/void __fastcall__ cclear (unsigned char length);/
1568 <tag/Description/The function clears part of a line by writing <tt/length/
1569 spaces in the current text color.
1570 <tag/Limits/<itemize>
1571 <item>The function is only available as fastcall function, so it may
1572 only be used in presence of a prototype.
1574 <tag/Availability/cc65
1576 <ref id="cclearxy" name="cclearxy">,
1577 <ref id="clrscr" name="clrscr">
1583 <sect1>cclearxy<label id="cclearxy"><p>
1587 <tag/Function/Clear part of a line (write a given number of spaces) starting
1588 at a specific screen position.
1589 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1590 <tag/Declaration/<tt/void __fastcall__ cclearxy (unsigned char x, unsigned char y, unsigned char length);/
1591 <tag/Description/The function moves the cursor to a specific position, and
1592 will then clear part of the line by writing <tt/length/ spaces in the current
1594 <tag/Limits/<itemize>
1595 <item>The function is only available as fastcall function, so it may
1596 only be used in presence of a prototype.
1598 <tag/Availability/cc65
1600 <ref id="cclear" name="cclear">,
1601 <ref id="clrscr" name="clrscr">
1607 <sect1>cgetc<label id="cgetc"><p>
1611 <tag/Function/Read a character from the keyboard.
1612 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1613 <tag/Declaration/<tt/char cgetc (void);/
1614 <tag/Description/The function reads a character from the keyboard. If there is
1615 no character available, <tt/cgetc/ waits until the user presses a key. If the
1616 cursor is enabled by use of the <tt/cursor/ function, a blinking cursor is
1617 displayed while waiting.
1618 <tag/Limits/<itemize>
1619 <item>If the system supports a keyboard buffer, <tt/cgetc/ will fetch a key
1620 from this buffer and wait only if the buffer is empty.
1622 <tag/Availability/cc65
1624 <ref id="cursor" name="cursor">,
1625 <ref id="kbhit" name="kbhit">
1631 <sect1>chline<label id="chline"><p>
1635 <tag/Function/Output a horizontal line in text mode.
1636 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1637 <tag/Declaration/<tt/void __fastcall__ chline (unsigned char length);/
1638 <tag/Description/The function outputs a horizontal line with the given length
1639 starting at the current cursor position.
1640 <tag/Limits/<itemize>
1641 <item>The character used to draw the horizontal line is system dependent.
1642 If available, a line drawing character is used. Drawing a line that is partially
1643 off screen leads to undefined behaviour.
1644 <item>The function is only available as fastcall function, so it may only be
1645 used in presence of a prototype.
1647 <tag/Availability/cc65
1649 <ref id="chlinexy" name="chlinexy">,
1650 <ref id="cvline" name="cvline">,
1651 <ref id="cvlinexy" name="cvlinexy">
1657 <sect1>chlinexy<label id="chlinexy"><p>
1661 <tag/Function/Output a horizontal line at a given position in text mode.
1662 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1663 <tag/Declaration/<tt/void __fastcall__ chlinexy (unsigned char x, unsigned char y, unsigned char length);/
1664 <tag/Description/The function outputs a horizontal line with the given length
1665 starting at a given position.
1666 <tag/Limits/<itemize>
1667 <item>The character used to draw the horizontal line is system dependent.
1668 If available, a line drawing character is used. Drawing a line that is partially
1669 off screen leads to undefined behaviour.
1670 <item>The function is only available as fastcall function, so it may only be
1671 used in presence of a prototype.
1673 <tag/Availability/cc65
1675 <ref id="chline" name="chline">,
1676 <ref id="cvline" name="cvline">,
1677 <ref id="cvlinexy" name="cvlinexy">
1683 <sect1>clearerr<label id="clearerr"><p>
1687 <tag/Function/Clear error and end-of-file status of a stream.
1688 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
1689 <tag/Declaration/<tt/void __fastcall__ clearerr (FILE* f);/
1690 <tag/Description/<tt/clearerr/ clears the error and end-of-file status
1691 indicators for the stream <tt/f/.
1692 <tag/Limits/<itemize>
1693 <item>The function is only available as fastcall function, so it may only be
1694 used in presence of a prototype.
1696 <tag/Availability/ISO 9899
1698 <ref id="feof" name="feof">,
1699 <ref id="ferror" name="ferror">
1705 <sect1>clock<label id="clock"><p>
1709 <tag/Function/Determine the processor time used.
1710 <tag/Header/<tt/<ref id="time.h" name="time.h">/
1711 <tag/Declaration/<tt/clock_t clock (void);/
1712 <tag/Description/The <tt/clock/ function returns an approximaton of processor
1713 time used by the program. The time is returned in implementation defined
1714 units. It can be converted to seconds by dividing by the value of the macro
1715 <tt/CLOCKS_PER_SEC/.
1716 <tag/Limits/<itemize>
1717 <item>Since the machines, cc65 generated programs run on, cannot run multiple
1718 processes, the function will actually return the time since some
1719 implementation defined point in the past.
1721 <tag/Availability/ISO 9899
1723 <ref id="time" name="time">
1729 <sect1>clrscr<label id="clrscr"><p>
1733 <tag/Function/Clear the text screen.
1734 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1735 <tag/Declaration/<tt/void clrscr (void);/
1736 <tag/Description/The function clears the text screen and moves the cursor to
1737 the upper left corner.
1738 <tag/Availability/cc65
1740 <ref id="cclear" name="cclear">,
1741 <ref id="cclearxy" name="cclearxy">
1747 <sect1>close<label id="close"><p>
1751 <tag/Function/Close a file descriptor.
1752 <tag/Header/<tt/<ref id="fcntl.h" name="fcntl.h">/
1753 <tag/Declaration/<tt/int __fastcall__ close (int fd);/
1754 <tag/Description/The function closes the given file descriptor. It returns zero
1755 on success and -1 on error. If an error occurs, the cause can be determined by
1756 reading the <tt/errno/ variable.
1757 <tag/Limits/<itemize>
1758 <item>The function is only available as fastcall function, so it may only
1759 be used in presence of a prototype.
1761 <tag/Availability/POSIX 1003.1
1763 <ref id="creat" name="creat">,
1764 <ref id="open" name="open">
1770 <sect1>closedir<label id="closedir"><p>
1774 <tag/Function/Close a directory.
1775 <tag/Header/<tt/<ref id="dirent.h" name="dirent.h">/
1776 <tag/Declaration/<tt/int __fastcall__ closedir (DIR* dir);/
1777 <tag/Description/The function closes the given directory descriptor. It returns
1778 zero on success and -1 on error. If an error occurs, the cause can be determined
1779 by reading the <tt/errno/ variable.
1780 <tag/Limits/<itemize>
1781 <item>The function is only available as fastcall function, so it may only
1782 be used in presence of a prototype.
1784 <tag/Availability/POSIX 1003.1
1786 <ref id="opendir" name="opendir">,
1787 <ref id="readdir" name="readdir">
1793 <sect1>creat<label id="creat"><p>
1797 <tag/Function/Create a file.
1798 <tag/Header/<tt/<ref id="fcntl.h" name="fcntl.h">/
1799 <tag/Declaration/<tt/int __fastcall__ creat (const char* name, unsigned mode);/
1800 <tag/Description/<tt/creat/ creates a new file and returns the file descriptor
1801 associated with it. On error, -1 is returned and an error code is stored in
1803 <tag/Limits/<itemize>
1804 <item><tt/creat/ is identical to calling <tt/<ref id="open" name="open">/ with
1805 <tt/flags/ equal to <tt/O_WRONLY | O_CREAT | O_TRUNC/.
1806 <item>The function is only available as fastcall function, so it may only
1807 be used in presence of a prototype.
1809 <tag/Availability/POSIX 1003.1
1811 <ref id="close" name="close">,
1812 <ref id="open" name="open">
1818 <sect1>cprintf<label id="cprintf"><p>
1822 <tag/Function/Formatted output to the console.
1823 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1824 <tag/Declaration/<tt/int cprintf (const char* format, ...);/
1825 <tag/Description/The arguments are converted to text where necessary and
1826 formatted according to the format string given. The resulting string is output
1827 to the console. <tt/cprintf/ supports the same format specifiers as
1828 <tt/printf/. <!-- <tt/<ref id="printf" name="printf">/. -->
1829 <tag/Limits/<itemize>
1830 <item>Like all other <tt/conio/ output functions, <tt/cprintf/ distinguishes
1831 between <tt/\r/ and <tt/\n/.
1833 <tag/Availability/cc65
1835 <ref id="cputc" name="cputc">,
1836 <ref id="cputcxy" name="cputcxy">,
1837 <ref id="cputs" name="cputs">,
1838 <ref id="cputsxy" name="cputsxy">,
1839 <ref id="vcprintf" name="vcprintf">
1845 <sect1>cputc<label id="cputc"><p>
1849 <tag/Function/Output a character directly to the console.
1850 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1851 <tag/Declaration/<tt/void __fastcall__ cputc (char c);/
1852 <tag/Description/Output one character to the console at the current cursor
1854 <tag/Limits/<itemize>
1855 <item>Like all other <tt/conio/ output functions, <tt/cputc/ distinguishes
1856 between <tt/\r/ and <tt/\n/.
1857 <item>The function is only available as fastcall function, so it may only
1858 be used in presence of a prototype.
1860 <tag/Availability/cc65
1862 <ref id="cprintf" name="cprintf">,
1863 <ref id="cputcxy" name="cputcxy">,
1864 <ref id="cputs" name="cputs">,
1865 <ref id="cputsxy" name="cputsxy">,
1866 <ref id="vcprintf" name="vcprintf">
1872 <sect1>cputcxy<label id="cputcxy"><p>
1876 <tag/Function/Output a character at a specific screen position.
1877 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1878 <tag/Declaration/<tt/void __fastcall__ cputcxy (unsigned char x, unsigned char y, char c);/
1879 <tag/Description/<tt/cputcxy/ moves the cursor to the given x/y position on
1880 the screen and outputs one character.
1881 <tag/Limits/<itemize>
1882 <item>Like all other <tt/conio/ output functions, <tt/cputcxy/ distinguishes
1883 between <tt/\r/ and <tt/\n/.
1884 <item>The function is only available as fastcall function, so it may only
1885 be used in presence of a prototype.
1887 <tag/Availability/cc65
1889 <ref id="cprintf" name="cprintf">,
1890 <ref id="cputc" name="cputc">,
1891 <ref id="cputs" name="cputs">,
1892 <ref id="cputsxy" name="cputsxy">,
1893 <ref id="vcprintf" name="vcprintf">
1899 <sect1>cputs<label id="cputs"><p>
1903 <tag/Function/Output a string directly to the console.
1904 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1905 <tag/Declaration/<tt/void __fastcall__ cputs (const char* s);/
1906 <tag/Description/The function outputs the given string on the console at the
1907 current cursor position.
1908 <tag/Limits/<itemize>
1909 <item>Like all other <tt/conio/ output functions, <tt/cputs/ distinguishes
1910 between <tt/\r/ and <tt/\n/.
1911 <item>The function is only available as fastcall function, so it may only
1912 be used in presence of a prototype.
1914 <tag/Availability/cc65
1916 <ref id="cprintf" name="cprintf">,
1917 <ref id="cputc" name="cputc">,
1918 <ref id="cputcxy" name="cputcxy">,
1919 <ref id="cputsxy" name="cputsxy">,
1920 <ref id="vcprintf" name="vcprintf">
1926 <sect1>cputsxy<label id="cputsxy"><p>
1930 <tag/Function/Output a string to the console at a given position.
1931 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1932 <tag/Declaration/<tt/void __fastcall__ cputsxy (unsigned char x, unsigned char y, const char* s);/
1933 <tag/Description/<tt/cputsxy/ moves the cursor to the given x/y position,
1934 and outputs the string <tt/s/.
1935 <tag/Limits/<itemize>
1936 <item>Like all other <tt/conio/ output functions, <tt/cputsxy/ distinguishes
1937 between <tt/\r/ and <tt/\n/.
1938 <item>The function is only available as fastcall function, so it may only
1939 be used in presence of a prototype.
1941 <tag/Availability/cc65
1943 <ref id="cprintf" name="cprintf">,
1944 <ref id="cputc" name="cputc">,
1945 <ref id="cputcxy" name="cputcxy">,
1946 <ref id="cputs" name="cputs">,
1947 <ref id="vcprintf" name="vcprintf">
1953 <sect1>cursor<label id="cursor"><p>
1957 <tag/Function/Enable/disable a blinking cursor when waiting for keyboard input.
1958 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1959 <tag/Declaration/<tt/unsigned char __fastcall__ cursor (unsigned char onoff);/
1960 <tag/Description/If the argument to the function is non zero, a blinking cursor
1961 will be enabled when the <tt/cgetc/ function waits for input from the keyboard.
1962 If the argument is zero, <tt/cgetc/ will wait without a blinking cursor.
1963 <tag/Limits/<itemize>
1964 <item>The function is only available as fastcall function, so it may only
1965 be used in presence of a prototype.
1967 <tag/Availability/cc65
1969 <ref id="cgetc" name="cgetc">,
1970 <ref id="kbhit" name="kbhit">
1976 <sect1>cvline<label id="cvline"><p>
1980 <tag/Function/Output a vertical line in text mode.
1981 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1982 <tag/Declaration/<tt/void __fastcall__ cvline (unsigned char length);/
1983 <tag/Description/The function outputs a vertical line with the given length
1984 starting at the current cursor position.
1985 <tag/Limits/<itemize>
1986 <item>The character used to draw the vertical line is system dependent.
1987 If available, a line drawing character is used. Drawing a line that is partially
1988 off screen leads to undefined behaviour.
1989 <item>The function is only available as fastcall function, so it may only be
1990 used in presence of a prototype.
1992 <tag/Availability/cc65
1994 <ref id="chline" name="chline">,
1995 <ref id="chlinexy" name="chlinexy">,
1996 <ref id="cvlinexy" name="cvlinexy">
2002 <sect1>cvlinexy<label id="cvlinexy"><p>
2006 <tag/Function/Output a vertical line at a given position in text mode.
2007 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2008 <tag/Declaration/<tt/void __fastcall__ cvlinexy (unsigned char x, unsigned char y, unsigned char length);/
2009 <tag/Description/The function outputs a vertical line with the given length
2010 starting at a given position.
2011 <tag/Limits/<itemize>
2012 <item>The character used to draw the vertical line is system dependent.
2013 If available, a line drawing character is used. Drawing a line that is partially
2014 off screen leads to undefined behaviour.
2015 <item>The function is only available as fastcall function, so it may only be
2016 used in presence of a prototype.
2018 <tag/Availability/cc65
2020 <ref id="chline" name="chline">,
2021 <ref id="chlinexy" name="chlinexy">,
2022 <ref id="cvline" name="cvline">
2028 <sect1>div<label id="div"><p>
2032 <tag/Function/Divide two ints and return quotient and remainder.
2033 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
2034 <tag/Declaration/<tt/div_t __fastcall__ div (int numer, int denom);/
2035 <tag/Description/<tt/div/ divides <tt/numer/ by <tt/denom/ and returns the
2036 quotient and remainder in a <tt/div_t/ structure.
2039 <item>The function is only available as fastcall function, so it may only
2040 be used in presence of a prototype.
2042 <tag/Availability/ISO 9899
2050 <sect1>em_commit<label id="em_commit"><p>
2054 <tag/Function/Commit changes into extended memory.
2055 <tag/Header/<tt/<ref id="em.h" name="em.h">/
2056 <tag/Declaration/<tt/void em_commit (void);/
2057 <tag/Description/Commit changes in the memory window to extended storage. If
2058 the contents of the memory window have been changed, these changes may be lost
2059 if <tt/<ref id="em_map" name="em_map">/, <tt/<ref id="em_use" name="em_use">/,
2060 <tt/<ref id="em_copyfrom" name="em_copyfrom">/ or <tt/<ref id="em_copyto"
2061 name="em_copyto">/ are called without calling <tt/em_commit/ first.
2062 <tag/Limits/<itemize>
2063 <item>Calling <tt/em_commit/ does not necessarily mean that changes to the
2064 memory window are discarded, it does just mean that the drivers is allowed
2066 <item>The function is only available as fastcall function, so it may only be
2067 used in presence of a prototype.
2068 <item>The function produces undefined results if no extended memory driver is
2071 <tag/Availability/cc65
2073 <ref id="em_load_driver" name="em_load_driver">,
2074 <ref id="em_map" name="em_map">,
2075 <ref id="em_use" name="em_use">
2081 <sect1>em_copyfrom<label id="em_copyfrom"><p>
2085 <tag/Function/Copy from extended into normal memory.
2086 <tag/Header/<tt/<ref id="em.h" name="em.h">/
2087 <tag/Declaration/<tt/void __fastcall__ em_copyfrom (const struct em_copy* copy_data);/
2088 <tag/Description/Copy data from extended memory into linear memory. Source and
2089 target addresses as well as the number of bytes to transfer are specified in
2090 the <tt/em_copy/ structure that is passed as a parameter.
2091 <tag/Limits/<itemize>
2092 <item>Calling <tt/em_copyfrom/ will invalidate the memory window, so if you
2093 made any changes to the data in the window, call <tt/<ref id="em_commit"
2094 name="em_commit">/ first, or the changes are lost.
2095 <item>The function is only available as fastcall function, so it may only be
2096 used in presence of a prototype.
2097 <item>The function produces undefined results if no extended memory driver is
2100 <tag/Availability/cc65
2102 <ref id="em_commit" name="em_commit">,
2103 <ref id="em_copyto" name="em_copyto">,
2104 <ref id="em_load_driver" name="em_load_driver">
2110 <sect1>em_copyto<label id="em_copyto"><p>
2114 <tag/Function/Copy from normal into extended memory.
2115 <tag/Header/<tt/<ref id="em.h" name="em.h">/
2116 <tag/Declaration/<tt/void __fastcall__ em_copyto (const struct em_copy* copy_data);/
2117 <tag/Description/Copy data from linear into extended memory. Source and
2118 target addresses as well as the number of bytes to transfer are specified in
2119 the <tt/em_copy/ structure that is passed as a parameter.
2120 <tag/Limits/<itemize>
2121 <item>Calling <tt/em_copyto/ will invalidate the memory window, so if you
2122 made any changes to the data in the window, call <tt/<ref id="em_commit"
2123 name="em_commit">/ first, or the changes are lost.
2124 <item>The function is only available as fastcall function, so it may only be
2125 used in presence of a prototype.
2126 <item>The function produces undefined results if no extended memory driver is
2129 <tag/Availability/cc65
2131 <ref id="em_commit" name="em_commit">,
2132 <ref id="em_copyfrom" name="em_copyfrom">,
2133 <ref id="em_load_driver" name="em_load_driver">
2139 <sect1>em_install<label id="em_install"><p>
2143 <tag/Function/Install an already loaded extended memory driver.
2144 <tag/Header/<tt/<ref id="em.h" name="em.h">/
2145 <tag/Declaration/<tt/unsigned char _fastcall__ em_install (void* driver);/
2146 <tag/Description/The function installs an already loaded extended memory driver
2147 and returns an error code. The function may be used to install a driver linked
2148 statically to the program.
2149 <tag/Limits/<itemize>
2150 <item>Not all drivers are able to detect if the supported hardware is really
2152 <item>The function is only available as fastcall function, so it may only be
2153 used in presence of a prototype.
2155 <tag/Availability/cc65
2157 <ref id="em_load_driver" name="em_load_driver">,
2158 <ref id="em_uninstall" name="em_uninstall">,
2159 <ref id="em_unload" name="em_unload">
2165 <sect1>em_load_driver<label id="em_load_driver"><p>
2169 <tag/Function/Load and initialize an extended memory driver.
2170 <tag/Header/<tt/<ref id="em.h" name="em.h">/
2171 <tag/Declaration/<tt/void __fastcall__ em_load_driver (const char* name);/
2172 <tag/Description/Load an extended memory driver into memory and initialize
2173 it. The function returns an error code that tells if all this has been
2175 <tag/Limits/<itemize>
2176 <item>Not all drivers are able to detect if the supported hardware is really
2178 <item>The function is only available as fastcall function, so it may only be
2179 used in presence of a prototype.
2180 <item>The driver is loaded by name, so currently you must know the type of
2181 extended memory that should be supported. There is no autodetect capability.
2183 <tag/Availability/cc65
2185 <ref id="em_unload" name="em_unload">
2191 <sect1>em_map<label id="em_map"><p>
2195 <tag/Function/Make a page of extended memory accessible.
2196 <tag/Header/<tt/<ref id="em.h" name="em.h">/
2197 <tag/Declaration/<tt/void* __fastcall__ em_map (unsigned page);/
2198 <tag/Description/The function maps one page of extended memory into linear
2199 memory and returns a pointer to the page frame. Depending on the hardware
2200 and driver, the data is either mapped into the address space or transfered
2201 into a buffer. If you don't need the actual contents of the page (for example
2202 because you're going to overwrite it completely), it is better to call
2203 <tt/<ref id="em_use" name="em_use">/ instead. <tt/em_use/ will not transfer the
2204 data if it is possible to avoid that.
2205 <tag/Limits/<itemize>
2206 <item>Calling <tt/em_map/ will invalidate the memory window, so if you
2207 made any changes to the data in the window, call <tt/<ref id="em_commit"
2208 name="em_commit">/ first, or the changes are lost.
2209 <item>The function is only available as fastcall function, so it may only be
2210 used in presence of a prototype.
2211 <item>The function produces undefined results if no extended memory driver is
2214 <tag/Availability/cc65
2216 <ref id="em_commit" name="em_commit">,
2217 <ref id="em_load_driver" name="em_load_driver">,
2218 <ref id="em_use" name="em_use">
2224 <sect1>em_pagecount<label id="em_pagecount"><p>
2228 <tag/Function/Return the number of available extended memory pages.
2229 <tag/Header/<tt/<ref id="em.h" name="em.h">/
2230 <tag/Declaration/<tt/unsigned em_pagecount (void);/
2231 <tag/Description/The function returns the size of the extended memory supported
2232 by the driver in 256 byte pages.
2233 <tag/Limits/<itemize>
2234 <item>The function returns zero if no extended memory driver is loaded.
2235 <item>The function may return zero if the supported hardware was not detected.
2237 <tag/Availability/cc65
2239 <ref id="em_load_driver" name="em_load_driver">
2245 <sect1>em_uninstall<label id="em_uninstall"><p>
2249 <tag/Function/Uninstall an already loaded extended memory driver.
2250 <tag/Header/<tt/<ref id="em.h" name="em.h">/
2251 <tag/Declaration/<tt/unsigned char em_uninstall (void);/
2252 <tag/Description/The function uninstalls an already loaded extended memory
2253 driver but doesn't remove it from memory.
2254 <tag/Limits/<itemize>
2255 <item>If the driver has been loaded using <tt/<ref id="em_load_driver"
2256 name="em_load_driver">/, <tt/<ref id="em_unload" name="em_unload">/
2257 should be used instead of <tt/em_uninstall/ so the driver is also removed
2260 <tag/Availability/cc65
2262 <ref id="em_install" name="em_install">,
2263 <ref id="em_load_driver" name="em_load_driver">,
2264 <ref id="em_unload" name="em_unload">
2270 <sect1>em_unload<label id="em_unload"><p>
2274 <tag/Function/Unload an extended memory driver.
2275 <tag/Header/<tt/<ref id="em.h" name="em.h">/
2276 <tag/Declaration/<tt/unsigned char em_unload (void);/
2277 <tag/Description/The function unloads a loaded extended memory driver and
2278 frees all memory allocated for the driver.
2279 <tag/Limits/<itemize>
2280 <item>The function does nothing if no driver is loaded.
2282 <tag/Availability/cc65
2284 <ref id="em_load_driver" name="em_load_driver">
2290 <sect1>em_use<label id="em_use"><p>
2294 <tag/Function/Prepare an extended memory page for use.
2295 <tag/Header/<tt/<ref id="em.h" name="em.h">/
2296 <tag/Declaration/<tt/void* __fastcall__ em_use (unsigned page);/
2297 <tag/Description/The function maps one page of extended memory into linear
2298 memory and returns a pointer to the page frame. This function is similar to
2299 <tt/<ref id="em_map" name="em_map">/, but will not transfer data into the
2300 actual memory window in the assumption that the existing data is wrong or
2301 will get overwritten.
2302 <tag/Limits/<itemize>
2303 <item>Calling <tt/em_use/ will invalidate the memory window, so if you
2304 made any changes to the data in the window, call <tt/<ref id="em_commit"
2305 name="em_commit">/ first, or the changes are lost.
2306 <item>The function is only available as fastcall function, so it may only be
2307 used in presence of a prototype.
2308 <item>The function produces undefined results if no extended memory driver is
2311 <tag/Availability/cc65
2313 <ref id="em_commit" name="em_commit">,
2314 <ref id="em_load_driver" name="em_load_driver">,
2315 <ref id="em_map" name="em_map">
2321 <sect1>exit<label id="exit"><p>
2325 <tag/Function/Terminate the program.
2326 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
2327 <tag/Declaration/<tt/void __fastcall__ exit (int status);/
2328 <tag/Description/<tt/exit/ terminates the program. The argument specifies the
2329 return code of the program. Before termination, all files are closed, buffered
2330 output is written and any functions registered with <tt/<ref id="atexit"
2331 name="atexit">/ are called. Common values for status are <tt/EXIT_SUCCESS/ and
2332 <tt/EXIT_FAILURE/ which are also defined in <tt/<ref id="stdlib.h"
2334 <tag/Limits/<itemize>
2335 <item>The function is only available as fastcall function, so it may only
2336 be used in presence of a prototype.
2337 <item>It depends on the host machine if the program return code can be
2338 evaluated or is ignored.
2340 <tag/Availability/ISO 9899
2342 <ref id="abort" name="abort">,
2343 <ref id="exit" name="exit">
2349 <sect1>exec<label id="exec"><p>
2353 <tag/Function/Execute a program file.
2354 <tag/Header/<tt/<ref id="unistd.h" name="unistd.h">/
2355 <tag/Declaration/<tt/int __fastcall__ exec (const char* progname, const char* cmdline);/
2356 <tag/Description/<tt/exec/ replaces the currently running program by a new one.
2357 Calling <tt/exec()/ is identical to calling <tt/<ref id="exit" name="exit()">/,
2358 then loading and starting the program named in the first argument, passing
2359 the command line specified as second argument. Instead of an empty string,
2360 a <tt/NULL/ pointer may be passed as second parameter.
2361 On success, the function does not return. On failure, -1 is returned and
2362 <tt/errno/ contains an error code.
2363 <tag/Limits/<itemize>
2364 <item>The function is only available as fastcall function, so it may only
2365 be used in presence of a prototype.
2366 <item>On most platforms, the function needs to copy a small stub loader to
2367 some memory area outside the program space. This may collide with other
2368 programs. See the platform specific docs on this.
2369 <item>Because it is necessary to terminate the running program before the
2370 memory can be reused to load the new one, there is a high chance that the
2371 function may not be able to return on errors.
2372 <item>The command line is passed to the new program in the same way as cc65
2373 programs expect the command line. If the new program is not a cc65 generated
2374 program, it may not be able to read it.
2376 <tag/Availability/cc65
2378 <ref id="exit" name="exit">
2384 <sect1>fast<label id="fast"><p>
2388 <tag/Function/Switch the C128 into 2MHz mode.
2389 <tag/Header/<tt/<ref id="c128.h" name="c128.h">/
2390 <tag/Declaration/<tt/void fast (void);/
2391 <tag/Description/The function will switch the clock of the C128 to 2MHz. This
2392 will nearly double the speed compared to slow mode.
2393 <tag/Limits/<itemize>
2394 <item>The function is specific to the C128.
2395 <item>2MHz clock will not work in 40 column mode.
2397 <tag/Availability/C128
2399 <ref id="slow" name="slow">,
2400 <ref id="toggle_videomode" name="toggle_videomode">,
2401 <ref id="videomode" name="videomode">
2407 <sect1>feof<label id="feof"><p>
2411 <tag/Function/Return the end-of-file indicator of a stream.
2412 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
2413 <tag/Declaration/<tt/int __fastcall__ feof (FILE* f);/
2414 <tag/Description/<tt/feof/ tests the end-of-file indicator ofthe stream
2415 <tt/f/, and returns a non zero value if it is set.
2416 <tag/Limits/<itemize>
2417 <item>The indicator is set only after a read past the end of a file is
2419 <item>The function is only available as fastcall function, so it may only be
2420 used in presence of a prototype.
2422 <tag/Availability/ISO 9899
2424 <ref id="feof" name="clearerr">,
2425 <ref id="ferror" name="ferror">
2431 <sect1>ferror<label id="ferror"><p>
2435 <tag/Function/Return the error indicator of a stream.
2436 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
2437 <tag/Declaration/<tt/int __fastcall__ ferror (FILE* f);/
2438 <tag/Description/<tt/ferror/ tests the error indicator of the stream
2439 <tt/f/, and returns a non zero value if it is set.
2440 <tag/Limits/<itemize>
2441 <item>The function is only available as fastcall function, so it may only be
2442 used in presence of a prototype.
2444 <tag/Availability/ISO 9899
2446 <ref id="feof" name="clearerr">,
2447 <ref id="ferror" name="feof">
2453 <sect1>fileno<label id="fileno"><p>
2457 <tag/Function/Return the file handle used by a stream.
2458 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
2459 <tag/Declaration/<tt/int __fastcall__ fileno (FILE* f);/
2460 <tag/Description/The <tt/fileno/ function returns the file handle used
2461 internally by a C stream. This file handle (an integer) can be used as a
2462 handle for the POSIX input/output functions.
2463 <tag/Limits/<itemize>
2464 <item>The function is only available as fastcall function, so it may only be
2465 used in presence of a prototype.
2466 <item>Mixing C file I/O functions and POSIX file I/O functions for the same
2467 file may have unpredictable results.
2469 <tag/Availability/POSIX 1003.1
2471 <ref id="creat" name="creat">,
2472 <ref id="open" name="open"> <!-- , -->
2473 <!-- <ref id="read" name="read">, -->
2474 <!-- <ref id="write" name="write"> -->
2480 <sect1>free<label id="free"><p>
2484 <tag/Function/Free a block of dynamic memory.
2485 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
2486 <tag/Declaration/<tt/void __fastcall__ free (void* block);/
2487 <tag/Description/Free a block of dynamic memory previously allocated with
2488 <tt/<ref id="malloc" name="malloc">/, <tt/<ref id="calloc" name="calloc">/
2489 or <tt/<ref id="realloc" name="realloc">/. As an exception, if the passed
2490 pointer is <tt/NULL/, no action is performed.
2493 <item>Passing an already free'd block to <tt/free/ again will cause undefined
2494 behaviour and may crash your program.
2495 <item>The function is only available as fastcall function, so it may only
2496 be used in presence of a prototype.
2498 <tag/Availability/ISO 9899
2500 <ref id="_heapadd" name="_heapadd">,
2501 <ref id="_heapblocksize" name="_heapblocksize">,
2502 <ref id="_heapmaxavail" name="_heapmaxavail">,
2503 <ref id="_heapmemavail" name="_heapmemavail">,
2504 <ref id="calloc" name="calloc">,
2505 <ref id="malloc" name="malloc">,
2506 <ref id="realloc" name="realloc">
2512 <sect1>get_ostype<label id="get_ostype"><p>
2516 <tag/Function/The function returns the operating system, the program runs on.
2517 <tag/Header/<tt/<ref id="apple2.h" name="apple2.h">,
2518 <ref id="atari.h" name="atari.h">, <ref id="c64.h" name="c64.h">/
2519 <tag/Declaration/<tt/unsigned char get_ostype (void);/
2520 <tag/Description/<tt/get_ostype/ is machine dependent and does not exist for
2521 all supported targets. If it exists, it returns a number that identifies the
2522 operating system or machine type, the program runs on. The machine dependent
2523 header files define constants that can be used to check the return code.
2524 <tag/Limits/<itemize>
2525 <item>The function does not exist on all platforms.
2526 <item>The return codes are platform dependent.
2528 <tag/Availability/cc65 (not all platforms)
2534 <sect1>getcpu<label id="getcpu"><p>
2538 <tag/Function/Determine on which CPU the program is running.
2539 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
2540 <tag/Declaration/<tt/unsigned char getcpu (void);/
2541 <tag/Description/The function checks on which CPU the code is running. It
2542 returns one of the constants<itemize>
2544 <item><tt/CPU_65C02/
2545 <item><tt/CPU_65816/
2547 <tag/Limits/<itemize>
2548 <item>Other, more exotic CPU types are not disinguished.
2550 <tag/Availability/cc65
2556 <sect1>getenv<label id="getenv"><p>
2560 <tag/Function/Return a value from the environment.
2561 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
2562 <tag/Declaration/<tt/char* __fastcall__ getenv (const char* name);/
2563 <tag/Description/The function searches the environment for an entry that
2564 matches <tt/name/ and returns its value. The environment consists of a list
2565 of strings in the form <tt/name=value/. If there is no match, <tt/getenv/
2567 <tag/Limits/<itemize>
2568 <item>What exactly is stored in the environment depends on the machine the
2569 program is running on.
2570 <item>The function is only available as fastcall function, so it may only
2571 be used in presence of a prototype.
2573 <tag/Availability/ISO 9899
2579 <sect1>getopt<label id="getopt"><p>
2583 <tag/Function/Parse command line options.
2584 <tag/Header/<tt/<ref id="unistd.h" name="unistd.h">/
2585 <tag/Declaration/<tt/int __fastcall__ getopt (int argc, char* const* argv,
2586 const char* optstring);/
2587 <tag/Description/The function parses command line arguments, <tt/argc/ and
2588 <tt/argv/ are the argument count and array passed to <tt/main/. <tt/optstring/
2589 is a string that contains command line option characters. If a character in
2590 <tt/optstring/ is followed by a colon, the option requires an argument. An
2591 option on the command line is recognized if it is one of the option characters
2593 <tt/getopt/ must be called repeatedly. It will return each option character
2594 found on the command line and <tt/EOF/ (-1) if there is no other option. An
2595 option argument is placed in <tt/optarg/, the index of the next element on the
2596 command line to be processed is placed in <tt/optind/.
2597 <tag/Limits/<itemize>
2598 <item>The implementation will not reorder options. A non option on the command
2599 line will terminate option processing. All remaining arguments are not
2600 recognized as options, even if the start with a '-' character.
2601 <item>The function is only available as fastcall function, so it may only
2602 be used in presence of a prototype.
2604 <tag/Availability/POSIX.2
2610 <sect1>gotox<label id="gotox"><p>
2614 <tag/Function/Move the text mode cursor to a new X position.
2615 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2616 <tag/Declaration/<tt/void __fastcall__ gotox (unsigned char x);/
2617 <tag/Description/The function moves the text mode cursor to the specified X
2618 position while leaving the Y position untouched. The leftmost position on the
2619 screen has the coordinate 0.
2620 <tag/Limits/<itemize>
2621 <item>The function is only available as fastcall function, so it may
2622 only be used in presence of a prototype.
2623 <item>Invalid values for the X position (out of screen coordinates) may
2624 lead to undefined behaviour.
2626 <tag/Availability/cc65
2628 <ref id="gotoy" name="gotoy">,
2629 <ref id="gotoxy" name="gotoxy">,
2630 <ref id="wherex" name="wherex">,
2631 <ref id="wherey" name="wherey">
2637 <sect1>gotoxy<label id="gotoxy"><p>
2641 <tag/Function/Move the text mode cursor to a new position.
2642 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2643 <tag/Declaration/<tt/void __fastcall__ gotoxy (unsigned char x, unsigned char y);/
2644 <tag/Description/The function moves the text mode cursor to the specified
2645 position. The leftmost position on the screen has the X coordinate 0, the
2646 topmost line has the Y coordinate 0.
2647 <tag/Limits/<itemize>
2648 <item>The function is only available as fastcall function, so it may only be
2649 used in presence of a prototype.
2650 <item>Invalid values for any of both coordinates (out of screen positions) may
2651 lead to undefined behaviour.
2653 <tag/Availability/cc65
2655 <ref id="gotox" name="gotox">,
2656 <ref id="gotoy" name="gotoy">,
2657 <ref id="wherex" name="wherex">,
2658 <ref id="wherey" name="wherey">
2664 <sect1>gotoy<label id="gotoy"><p>
2668 <tag/Function/Move the text mode cursor to a new Y position.
2669 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2670 <tag/Declaration/<tt/void __fastcall__ gotoy (unsigned char x);/
2671 <tag/Description/The function moves the text mode cursor to the specified Y
2672 position while leaving the X position untouched. The uppermost position on the
2673 screen has the coordinate 0.
2674 <tag/Limits/<itemize>
2675 <item>The function is only available as fastcall function, so it may
2676 only be used in presence of a prototype.
2677 <item>Invalid values for the Y position (out of screen coordinates) may lead
2678 to undefined behaviour.
2680 <tag/Availability/cc65
2682 <ref id="gotox" name="gotox">,
2683 <ref id="gotoxy" name="gotoxy">,
2684 <ref id="wherex" name="wherex">,
2685 <ref id="wherey" name="wherey">
2691 <sect1>isalnum<label id="isalnum"><p>
2695 <tag/Function/Check if a given character is a letter or digit.
2696 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2697 <tag/Declaration/<tt/int __fastcall__ isalnum (int c);/
2698 <tag/Description/The function returns a non zero value if the given argument
2699 is a letter or digit. The return value is zero if the character is anything
2701 <tag/Limits/<itemize>
2702 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2703 inline sequence generated by the macro will not work correctly for values
2704 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2705 this range. The non inline function may be accessed by <tt/#undef/'ing
2707 <item>When compiling without <tt/-Os/, the function is only available as
2708 fastcall function, so it may only be used in presence of a prototype.
2710 <tag/Availability/ISO 9899
2712 <ref id="isalpha" name="isalpha">,
2713 <ref id="isascii" name="isascii">,
2714 <ref id="isblank" name="isblank">,
2715 <ref id="iscntrl" name="iscntrl">,
2716 <ref id="isdigit" name="isdigit">,
2717 <ref id="isgraph" name="isgraph">,
2718 <ref id="islower" name="islower">,
2719 <ref id="isprint" name="isprint">,
2720 <ref id="ispunct" name="ispunct">,
2721 <ref id="isspace" name="isspace">,
2722 <ref id="isupper" name="isupper">,
2723 <ref id="isxdigit" name="isxdigit">
2729 <sect1>isalpha<label id="isalpha"><p>
2733 <tag/Function/Check if a given character is a letter.
2734 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2735 <tag/Declaration/<tt/int __fastcall__ isalpha (int c);/
2736 <tag/Description/The function returns a non zero value if the given argument
2737 is a letter. The return value is zero if the character is anything else.
2738 <tag/Limits/<itemize>
2739 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2740 inline sequence generated by the macro will not work correctly for values
2741 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2742 this range. The non inline function may be accessed by <tt/#undef/'ing the
2744 <item>When compiling without <tt/-Os/, the function is only available as
2745 fastcall function, so it may only be used in presence of a prototype.
2747 <tag/Availability/ISO 9899
2749 <ref id="isalnum" name="isalnum">,
2750 <ref id="isascii" name="isascii">,
2751 <ref id="isblank" name="isblank">,
2752 <ref id="iscntrl" name="iscntrl">,
2753 <ref id="isdigit" name="isdigit">,
2754 <ref id="isgraph" name="isgraph">,
2755 <ref id="islower" name="islower">,
2756 <ref id="isprint" name="isprint">,
2757 <ref id="ispunct" name="ispunct">,
2758 <ref id="isspace" name="isspace">,
2759 <ref id="isupper" name="isupper">,
2760 <ref id="isxdigit" name="isxdigit">
2766 <sect1>isascii<label id="isascii"><p>
2770 <tag/Function/Check if a given character is in the ASCII (0..127) range.
2771 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2772 <tag/Declaration/<tt/int __fastcall__ isascii (int c);/
2773 <tag/Description/The function returns a non zero value if the given argument
2774 is in the range 0..127 (the range of valid ASCII characters) and zero if not.
2775 <tag/Limits/<itemize>
2776 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2777 inline sequence generated by the macro will not work correctly for values
2778 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2779 this range. The non inline function may be accessed by <tt/#undef/'ing the
2781 <item>When compiling without <tt/-Os/, the function is only available as
2782 fastcall function, so it may only be used in presence of a prototype.
2784 <tag/Availability/ISO 9899
2786 <ref id="isalnum" name="isalnum">,
2787 <ref id="isalpha" name="isalpha">,
2788 <ref id="isblank" name="isblank">,
2789 <ref id="iscntrl" name="iscntrl">,
2790 <ref id="isdigit" name="isdigit">,
2791 <ref id="isgraph" name="isgraph">,
2792 <ref id="islower" name="islower">,
2793 <ref id="isprint" name="isprint">,
2794 <ref id="ispunct" name="ispunct">,
2795 <ref id="isspace" name="isspace">,
2796 <ref id="isupper" name="isupper">,
2797 <ref id="isxdigit" name="isxdigit">
2803 <sect1>isblank<label id="isblank"><p>
2807 <tag/Function/Check if a given character is a space or tab.
2808 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2809 <tag/Declaration/<tt/int __fastcall__ isblank (int c);/
2810 <tag/Description/The function returns a non zero value if the given argument
2811 is a space or tab character. The return value is zero if the character is
2813 <tag/Limits/<itemize>
2814 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2815 inline sequence generated by the macro will not work correctly for values
2816 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2817 this range. The non inline function may be accessed by <tt/#undef/'ing the
2819 <item>When compiling without <tt/-Os/, the function is only available as
2820 fastcall function, so it may only be used in presence of a prototype.
2822 <tag/Availability/cc65
2824 <ref id="isalnum" name="isalnum">,
2825 <ref id="isalpha" name="isalpha">,
2826 <ref id="isascii" name="isascii">,
2827 <ref id="iscntrl" name="iscntrl">,
2828 <ref id="isdigit" name="isdigit">,
2829 <ref id="isgraph" name="isgraph">,
2830 <ref id="islower" name="islower">,
2831 <ref id="isprint" name="isprint">,
2832 <ref id="ispunct" name="ispunct">,
2833 <ref id="isspace" name="isspace">,
2834 <ref id="isupper" name="isupper">,
2835 <ref id="isxdigit" name="isxdigit">
2841 <sect1>iscntrl<label id="iscntrl"><p>
2845 <tag/Function/Check if a given character is a control character.
2846 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2847 <tag/Declaration/<tt/int __fastcall__ iscntrl (int c);/
2848 <tag/Description/The function returns a non zero value if the given argument
2849 is a control character. The return value is zero if the character is anything
2851 <tag/Limits/<itemize>
2852 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2853 inline sequence generated by the macro will not work correctly for values
2854 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2855 this range. The non inline function may be accessed by <tt/#undef/'ing the
2857 <item>When compiling without <tt/-Os/, the function is only available as
2858 fastcall function, so it may only be used in presence of a prototype.
2860 <tag/Availability/ISO 9899
2862 <ref id="isalnum" name="isalnum">,
2863 <ref id="isalpha" name="isalpha">,
2864 <ref id="isascii" name="isascii">,
2865 <ref id="isblank" name="isblank">,
2866 <ref id="isdigit" name="isdigit">,
2867 <ref id="isgraph" name="isgraph">,
2868 <ref id="islower" name="islower">,
2869 <ref id="isprint" name="isprint">,
2870 <ref id="ispunct" name="ispunct">,
2871 <ref id="isspace" name="isspace">,
2872 <ref id="isupper" name="isupper">,
2873 <ref id="isxdigit" name="isxdigit">
2879 <sect1>isdigit<label id="isdigit"><p>
2883 <tag/Function/Check if a given character is a digit.
2884 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2885 <tag/Declaration/<tt/int __fastcall__ isdigit (int c);/
2886 <tag/Description/The function returns a non zero value if the given argument
2887 is a digit. The return value is zero if the character is anything else.
2888 <tag/Limits/<itemize>
2889 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2890 inline sequence generated by the macro will not work correctly for values
2891 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2892 this range. The non inline function may be accessed by <tt/#undef/'ing the
2894 <item>When compiling without <tt/-Os/, the function is only available as
2895 fastcall function, so it may only be used in presence of a prototype.
2897 <tag/Availability/ISO 9899
2899 <ref id="isalnum" name="isalnum">,
2900 <ref id="isalpha" name="isalpha">,
2901 <ref id="isascii" name="isascii">,
2902 <ref id="isblank" name="isblank">,
2903 <ref id="iscntrl" name="iscntrl">,
2904 <ref id="isgraph" name="isgraph">,
2905 <ref id="islower" name="islower">,
2906 <ref id="isprint" name="isprint">,
2907 <ref id="ispunct" name="ispunct">,
2908 <ref id="isspace" name="isspace">,
2909 <ref id="isupper" name="isupper">,
2910 <ref id="isxdigit" name="isxdigit">
2916 <sect1>isgraph<label id="isgraph"><p>
2920 <tag/Function/Check if a given character is a printable character (except
2922 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2923 <tag/Declaration/<tt/int __fastcall__ isgraph (int c);/
2924 <tag/Description/The function returns a non zero value if the given argument
2925 is a printable character with the exception of space. The return value is zero
2926 if the character is anything else.
2927 <tag/Limits/<itemize>
2928 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2929 inline sequence generated by the macro will not work correctly for values
2930 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2931 this range. The non inline function may be accessed by <tt/#undef/'ing the
2933 <item>When compiling without <tt/-Os/, the function is only available as
2934 fastcall function, so it may only be used in presence of a prototype.
2936 <tag/Availability/ISO 9899
2938 <ref id="isalnum" name="isalnum">,
2939 <ref id="isalpha" name="isalpha">,
2940 <ref id="isascii" name="isascii">,
2941 <ref id="isblank" name="isblank">,
2942 <ref id="iscntrl" name="iscntrl">,
2943 <ref id="isdigit" name="isdigit">,
2944 <ref id="islower" name="islower">,
2945 <ref id="isprint" name="isprint">,
2946 <ref id="ispunct" name="ispunct">,
2947 <ref id="isspace" name="isspace">,
2948 <ref id="isupper" name="isupper">,
2949 <ref id="isxdigit" name="isxdigit">
2955 <sect1>islower<label id="islower"><p>
2959 <tag/Function/Check if a given character is a lower case letter.
2960 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2961 <tag/Declaration/<tt/int __fastcall__ islower (int c);/
2962 <tag/Description/The function returns a non zero value if the given argument
2963 is a lower case letter. The return value is zero if the character is anything
2965 <tag/Limits/<itemize>
2966 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2967 inline sequence generated by the macro will not work correctly for values
2968 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2969 this range. The non inline function may be accessed by <tt/#undef/'ing the
2971 <item>When compiling without <tt/-Os/, the function is only available as
2972 fastcall function, so it may only be used in presence of a prototype.
2974 <tag/Availability/ISO 9899
2976 <ref id="isalnum" name="isalnum">,
2977 <ref id="isalpha" name="isalpha">,
2978 <ref id="isascii" name="isascii">,
2979 <ref id="isblank" name="isblank">,
2980 <ref id="iscntrl" name="iscntrl">,
2981 <ref id="isdigit" name="isdigit">,
2982 <ref id="isgraph" name="isgraph">,
2983 <ref id="isprint" name="isprint">,
2984 <ref id="ispunct" name="ispunct">,
2985 <ref id="isspace" name="isspace">,
2986 <ref id="isupper" name="isupper">,
2987 <ref id="isxdigit" name="isxdigit">
2993 <sect1>isprint<label id="isprint"><p>
2997 <tag/Function/Check if a given character is a printable character.
2998 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2999 <tag/Declaration/<tt/int __fastcall__ isprint (int c);/
3000 <tag/Description/The function returns a non zero value if the given argument
3001 is a printable character (this includes the space character). The return value
3002 is zero if the character is anything else.
3003 <tag/Limits/<itemize>
3004 <item>When compiling with <tt/-Os/ the function is actually a macro. The
3005 inline sequence generated by the macro will not work correctly for values
3006 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
3007 this range. The non inline function may be accessed by <tt/#undef/'ing the
3009 <item>When compiling without <tt/-Os/, the function is only available as
3010 fastcall function, so it may only be used in presence of a prototype.
3012 <tag/Availability/ISO 9899
3014 <ref id="isalnum" name="isalnum">,
3015 <ref id="isalpha" name="isalpha">,
3016 <ref id="isascii" name="isascii">,
3017 <ref id="isblank" name="isblank">,
3018 <ref id="iscntrl" name="iscntrl">,
3019 <ref id="isdigit" name="isdigit">,
3020 <ref id="isgraph" name="isgraph">,
3021 <ref id="islower" name="islower">,
3022 <ref id="ispunct" name="ispunct">,
3023 <ref id="isspace" name="isspace">,
3024 <ref id="isupper" name="isupper">,
3025 <ref id="isxdigit" name="isxdigit">
3031 <sect1>ispunct<label id="ispunct"><p>
3035 <tag/Function/Check if a given character is a printable character but not a
3036 space or an alphanumeric character.
3037 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
3038 <tag/Declaration/<tt/int __fastcall__ ispunct (int c);/
3039 <tag/Description/The function returns a non zero value if the given argument
3040 is a printable character, but not a space or anything alphanumeric. The return
3041 value is zero if the character is anything else.
3042 <tag/Limits/<itemize>
3043 <item>When compiling with <tt/-Os/ the function is actually a macro. The
3044 inline sequence generated by the macro will not work correctly for values
3045 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
3046 this range. The non inline function may be accessed by <tt/#undef/'ing the
3048 <item>When compiling without <tt/-Os/, the function is only available as
3049 fastcall function, so it may only be used in presence of a prototype.
3051 <tag/Availability/ISO 9899
3053 <ref id="isalnum" name="isalnum">,
3054 <ref id="isalpha" name="isalpha">,
3055 <ref id="isascii" name="isascii">,
3056 <ref id="isblank" name="isblank">,
3057 <ref id="iscntrl" name="iscntrl">,
3058 <ref id="isdigit" name="isdigit">,
3059 <ref id="isgraph" name="isgraph">,
3060 <ref id="islower" name="islower">,
3061 <ref id="isprint" name="isprint">,
3062 <ref id="isspace" name="isspace">,
3063 <ref id="isupper" name="isupper">,
3064 <ref id="isxdigit" name="isxdigit">
3070 <sect1>isspace<label id="isspace"><p>
3074 <tag/Function/Check if a given character is a a white-space character.
3075 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
3076 <tag/Declaration/<tt/int __fastcall__ isspace (int c);/
3077 <tag/Description/The function returns a non zero value if the given argument
3078 is a white space character. The return value is zero if the character is
3079 anything else. The standard white space characters are: space, formfeed ('\f'),
3080 newline ('\n'), carriage return ('\r'), horizontal tab ('\t'), and vertical tab
3082 <tag/Limits/<itemize>
3083 <item>When compiling with <tt/-Os/ the function is actually a macro. The
3084 inline sequence generated by the macro will not work correctly for values
3085 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
3086 this range. The non inline function may be accessed by <tt/#undef/'ing the
3088 <item>When compiling without <tt/-Os/, the function is only available as
3089 fastcall function, so it may only be used in presence of a prototype.
3091 <tag/Availability/ISO 9899
3093 <ref id="isalnum" name="isalnum">,
3094 <ref id="isalpha" name="isalpha">,
3095 <ref id="isascii" name="isascii">,
3096 <ref id="isblank" name="isblank">,
3097 <ref id="iscntrl" name="iscntrl">,
3098 <ref id="isdigit" name="isdigit">,
3099 <ref id="isgraph" name="isgraph">,
3100 <ref id="islower" name="islower">,
3101 <ref id="isprint" name="isprint">,
3102 <ref id="ispunct" name="ispunct">,
3103 <ref id="isupper" name="isupper">,
3104 <ref id="isxdigit" name="isxdigit">
3110 <sect1>isupper<label id="isupper"><p>
3114 <tag/Function/Check if a given character is an upper case letter.
3115 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
3116 <tag/Declaration/<tt/int __fastcall__ isupper (int c);/
3117 <tag/Description/The function returns a non zero value if the given argument
3118 is an upper case letter. The return value is zero if the character is anything
3120 <tag/Limits/<itemize>
3121 <item>When compiling with <tt/-Os/ the function is actually a macro. The
3122 inline sequence generated by the macro will not work correctly for values
3123 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
3124 this range. The non inline function may be accessed by <tt/#undef/'ing the
3126 <item>When compiling without <tt/-Os/, the function is only available as
3127 fastcall function, so it may only be used in presence of a prototype.
3129 <tag/Availability/ISO 9899
3131 <ref id="isalnum" name="isalnum">,
3132 <ref id="isalpha" name="isalpha">,
3133 <ref id="isascii" name="isascii">,
3134 <ref id="isblank" name="isblank">,
3135 <ref id="iscntrl" name="iscntrl">,
3136 <ref id="isdigit" name="isdigit">,
3137 <ref id="isgraph" name="isgraph">,
3138 <ref id="islower" name="islower">,
3139 <ref id="isprint" name="isprint">,
3140 <ref id="ispunct" name="ispunct">,
3141 <ref id="isspace" name="isspace">,
3142 <ref id="isxdigit" name="isxdigit">
3148 <sect1>isxdigit<label id="isxdigit"><p>
3152 <tag/Function/Check if a given character is a hexadecimal digit.
3153 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
3154 <tag/Declaration/<tt/int __fastcall__ isxdigit (int c);/
3155 <tag/Description/The function returns a non zero value if the given argument
3156 is a hexadecimal digit (0..9, a..f and A..F). The return value is zero if the
3157 character is anything else.
3158 <tag/Limits/<itemize>
3159 <item>When compiling with <tt/-Os/ the function is actually a macro. The
3160 inline sequence generated by the macro will not work correctly for values
3161 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
3162 this range. The non inline function may be accessed by <tt/#undef/'ing the
3164 <item>When compiling without <tt/-Os/, the function is only available as
3165 fastcall function, so it may only be used in presence of a prototype.
3167 <tag/Availability/ISO 9899
3169 <ref id="isalnum" name="isalnum">,
3170 <ref id="isalpha" name="isalpha">,
3171 <ref id="isascii" name="isascii">,
3172 <ref id="isblank" name="isblank">,
3173 <ref id="iscntrl" name="iscntrl">,
3174 <ref id="isdigit" name="isdigit">,
3175 <ref id="isgraph" name="isgraph">,
3176 <ref id="islower" name="islower">,
3177 <ref id="isprint" name="isprint">,
3178 <ref id="ispunct" name="ispunct">,
3179 <ref id="isspace" name="isspace">,
3180 <ref id="isupper" name="isupper">
3186 <sect1>itoa<label id="itoa"><p>
3190 <tag/Function/Convert an integer into a string.
3191 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
3192 <tag/Declaration/<tt/char* __fastcall__ itoa (int val, char* buf, int radix);/
3193 <tag/Description/<tt/itoa/ converts the integer <tt/val/ into a string using
3194 <tt/radix/ as the base.
3195 <tag/Limits/<itemize>
3196 <item>There are no provisions to prevent a buffer overflow.
3197 <item>If <tt/val/ contains <tt/INT_MIN/, the behaviour is undefined.
3198 <item>The function is non standard, so it is not available in strict ANSI mode.
3199 You should probably use <tt/sprintf/ instead.
3200 <item>The function is only available as fastcall function, so it may only be
3201 used in presence of a prototype.
3203 <tag/Availability/cc65
3205 <ref id="atoi" name="atoi">,
3206 <ref id="atol" name="atol">,
3207 <ref id="ltoa" name="ltoa">,
3208 <ref id="ultoa" name="ultoa">,
3209 <ref id="utoa" name="utoa">
3215 <sect1>joy_count<label id="joy_count"><p>
3219 <tag/Function/Return the number of joysticks supported by the current driver.
3220 <tag/Header/<tt/<ref id="joystick.h" name="joystick.h">/
3221 <tag/Declaration/<tt/unsigned char joy_count (void);/
3222 <tag/Description/The function returns a the number of joysticks supported
3223 by the current joystick driver.
3224 <tag/Limits/<itemize>
3225 <item>A joystick driver must be loaded using <ref id="joy_load_driver"
3226 name="joy_load_driver"> before calling this function.
3227 <item>The function returns the number of joysticks supported by the driver.
3228 There's no way to check for the number of actually connected joysticks.
3230 <tag/Availability/cc65
3232 <ref id="joy_load_driver" name="joy_load_driver">,
3233 <ref id="joy_read" name="joy_read">
3239 <sect1>joy_install<label id="joy_install"><p>
3243 <tag/Function/Install an already loaded driver and return an error code.
3244 <tag/Header/<tt/<ref id="joystick.h" name="joystick.h">/
3245 <tag/Declaration/<tt/unsigned char __fastcall__ joy_install (void* driver);/
3246 <tag/Description/The function installs a driver that was already loaded into
3247 memory (or linked statically to the program). It returns an error code
3248 (<tt/JOY_ERR_OK/ in case of success).
3249 <tag/Limits/<itemize>
3250 <item>The function is only available as fastcall function, so it may only be
3251 used in presence of a prototype.
3253 <tag/Availability/cc65
3255 <ref id="joy_load_driver" name="joy_load_driver">,
3256 <ref id="joy_uninstall" name="joy_uninstall">,
3257 <ref id="joy_unload" name="joy_unload">
3263 <sect1>joy_load_driver<label id="joy_load_driver"><p>
3267 <tag/Function/Load a driver from disk and install it.
3268 <tag/Header/<tt/<ref id="joystick.h" name="joystick.h">/
3269 <tag/Declaration/<tt/unsigned char __fastcall__ joy_load_driver (const char* driver);/
3270 <tag/Description/The function loads a driver with the given name from disk
3271 and installs it. An error code is returned, which is <tt/JOY_ERR_OK/ if the
3272 driver was successfully loaded and installed.
3273 <tag/Limits/<itemize>
3274 <item>The function is only available as fastcall function, so it may only be
3275 used in presence of a prototype.
3277 <tag/Availability/cc65
3279 <ref id="joy_install" name="joy_install">,
3280 <ref id="joy_uninstall" name="joy_uninstall">,
3281 <ref id="joy_unload" name="joy_unload">
3287 <sect1>joy_read<label id="joy_read"><p>
3291 <tag/Function/Read the status of a joystick.
3292 <tag/Header/<tt/<ref id="joystick.h" name="joystick.h">/
3293 <tag/Declaration/<tt/unsigned char __fastcall__ joy_read (unsigned char joystick);/
3294 <tag/Description/The function reads the status bits for a joystick. The number
3295 of the joystick is passed as parameter. The result may be examined by using one
3296 of the <tt/JOY_xxx/ macros from <ref id="joystick.h" name="joystick.h">.
3297 <tag/Limits/<itemize>
3298 <item>A joystick driver must be loaded using <ref id="joy_load_driver"
3299 name="joy_load_driver"> before calling this function.
3300 <item>The function is only available as fastcall function, so it may only be
3301 used in presence of a prototype.
3303 <tag/Availability/cc65
3305 <ref id="joy_count" name="joy_count">,
3306 <ref id="joy_load_driver" name="joy_load_driver">,
3307 <ref id="joy_unload" name="joy_unload">
3313 <sect1>joy_uninstall<label id="joy_uninstall"><p>
3317 <tag/Function/Uninstall the current joystick driver.
3318 <tag/Header/<tt/<ref id="joystick.h" name="joystick.h">/
3319 <tag/Declaration/<tt/unsigned char joy_uninstall (void);/
3320 <tag/Description/The function uninstalls the currently installed joystick
3321 driver. It does not remove the driver from memory. The function returns an
3322 error code, which is <tt/JOY_ERR_OK/ if the driver was successfully uninstalled.
3323 <tag/Limits/<itemize>
3324 <item>A joystick driver must be installed using <ref id="joy_install"
3325 name="joy_install"> before calling this function.
3327 <tag/Availability/cc65
3329 <ref id="joy_install" name="joy_install">,
3330 <ref id="joy_load_driver" name="joy_load_driver">,
3331 <ref id="joy_unload" name="joy_unload">
3337 <sect1>joy_unload<label id="joy_unload"><p>
3341 <tag/Function/Uninstall, then unload the current joystick driver.
3342 <tag/Header/<tt/<ref id="joystick.h" name="joystick.h">/
3343 <tag/Declaration/<tt/unsigned char joy_unload (void);/
3344 <tag/Description/The function uninstalls the currently installed joystick
3345 driver and removes it from memory. An error code is returned, which is
3346 <tt/JOY_ERR_OK/ if the driver was successfully uninstalled.
3347 <tag/Limits/<itemize>
3348 <item>A joystick driver must be loaded using <ref id="joy_load_driver"
3349 name="joy_load_driver"> before calling this function.
3351 <tag/Availability/cc65
3353 <ref id="joy_load_driver" name="joy_load_driver">
3359 <sect1>kbhit<label id="kbhit"><p>
3363 <tag/Function/Check if there's a key waiting in the keyboard buffer.
3364 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
3365 <tag/Declaration/<tt/unsigned char kbhit (void);/
3366 <tag/Description/The function returns a value of zero if there is no character
3367 waiting to be read from the keyboard. It returns non zero otherwise.
3368 <tag/Limits/<itemize>
3369 <item>If the system does not support a keyboard buffer (most systems
3370 do), the function is rather useless.
3372 <tag/Availability/cc65
3374 <ref id="cgetc" name="cgetc">,
3375 <ref id="cursor" name="cursor">
3381 <sect1>labs<label id="labs"><p>
3385 <tag/Function/Returns the absolute value of a long integer.
3386 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
3387 <tag/Declaration/<tt/long __fastcall__ labs (long v);/
3388 <tag/Description/<tt/labs/ returns the absolute value of the argument passed to
3390 <tag/Limits/<itemize>
3391 <item>The return value is undefined if <tt/LONG_MIN/ is passed to the function.
3392 <item>The function is only available as fastcall function, so it may only be
3393 used in presence of a prototype.
3395 <tag/Availability/ISO 9899
3397 <ref id="abs" name="abs">
3403 <sect1>ltoa<label id="ltoa"><p>
3407 <tag/Function/Convert a long integer into a string.
3408 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
3409 <tag/Declaration/<tt/char* __fastcall__ ltoa (long val, char* buf, int radix);/
3410 <tag/Description/<tt/itoa/ converts the long integer <tt/val/ into a string
3411 using <tt/radix/ as the base.
3412 <tag/Limits/<itemize>
3413 <item>There are no provisions to prevent a buffer overflow.
3414 <item>If <tt/val/ contains <tt/LONG_MIN/, the behaviour is undefined.
3415 <item>The function is non standard, so it is not available in strict ANSI mode.
3416 You should probably use <tt/sprintf/ instead.
3417 <item>The function is only available as fastcall function, so it may only be
3418 used in presence of a prototype.
3420 <tag/Availability/cc65
3422 <ref id="atoi" name="atoi">,
3423 <ref id="atol" name="atol">,
3424 <ref id="itoa" name="itoa">,
3425 <ref id="ultoa" name="ultoa">,
3426 <ref id="utoa" name="utoa">
3432 <sect1>localeconv<label id="localeconv"><p>
3436 <tag/Function/Returns a pointer to the current locale structure.
3437 <tag/Header/<tt/<ref id="locale.h" name="locale.h">/
3438 <tag/Declaration/<tt/struct lconv* localeconv (void);/
3439 <tag/Description/<tt/localeconv/ returns a pointer to the current locale
3441 <tag/Limits/<itemize>
3442 <item>cc65 supports only the "C" locale, so even after setting a new locale
3443 using <tt/<ref id="setlocale" name="setlocale">/, the structure returned will
3446 <tag/Availability/ISO 9899
3448 <ref id="setlocale" name="setlocale">
3454 <sect1>longjmp<label id="longjmp"><p>
3458 <tag/Function/Non local goto.
3459 <tag/Header/<tt/<ref id="setjmp.h" name="setjmp.h">/
3460 <tag/Declaration/<tt/void __fastcall__ longjmp (jmp_buf buf, int retval);/
3461 <tag/Description/The <tt/longjmp/ function restores a program context from the
3462 data in <tt/buf/, which must have been set by a preceeding call to
3463 <tt/<ref id="setjmp" name="setjmp">/. Program execution continues as if the
3464 call to <tt/<ref id="setjmp" name="setjmp">/ has just returned the value
3468 <item>If the parameter <tt/retval/ is zero, the function will behave as if it
3469 was called with a value of one.
3470 <item>The function is only available as fastcall function, so it may only
3471 be used in presence of a prototype.
3473 <tag/Availability/ISO 9899
3475 <ref id="setjmp" name="setjmp">
3481 <sect1>malloc<label id="malloc"><p>
3485 <tag/Function/Allocate dynamic memory.
3486 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
3487 <tag/Declaration/<tt/void* __fastcall__ malloc (size_t size);/
3488 <tag/Description/<tt/malloc/ allocates size bytes on the heap and returns a
3489 pointer to the allocated memory block. On error (not enough memory available),
3490 <tt/malloc/ returns <tt/NULL/.
3493 <item>The function is only available as fastcall function, so it may only
3494 be used in presence of a prototype.
3496 <tag/Availability/ISO 9899
3498 <ref id="_heapadd" name="_heapadd">,
3499 <ref id="_heapblocksize" name="_heapblocksize">,
3500 <ref id="_heapmaxavail" name="_heapmaxavail">,
3501 <ref id="_heapmemavail" name="_heapmemavail">,
3502 <ref id="calloc" name="calloc">,
3503 <ref id="free" name="free">,
3504 <ref id="realloc" name="realloc">,
3505 <ref id="strdup" name="strdup">
3511 <sect1>memchr<label id="memchr"><p>
3515 <tag/Function/Search for a character in a block of raw memory.
3516 <tag/Header/<tt/<ref id="string.h" name="string.h">/
3517 <tag/Declaration/<tt/void* __fastcall__ strchr (const void* mem, int c, size_t count);/
3518 <tag/Description/The <tt/memchr/ function locates the first occurrence of <tt/c/
3519 (converted to a char) in the block of raw memory string pointed to by <tt/mem/
3520 that is of size <tt/count/. Upon completion, the function returns a pointer to
3521 the character found, or a null pointer if the character was not found.
3522 <tag/Limits/<itemize>
3523 <item>The function is only available as fastcall function, so it may only
3524 be used in presence of a prototype.
3526 <tag/Availability/ISO 9899
3528 <ref id="strchr" name="strchr">
3534 <sect1>memcmp<label id="memcmp"><p>
3538 <tag/Function/Compare two memory areas.
3539 <tag/Header/<tt/<ref id="string.h" name="string.h">/
3540 <tag/Declaration/<tt/int __fastcall__ memcmp (const void* p1, const void* p2, size_t count);/
3541 <tag/Description/<tt/memcmp/ compares <tt/count/ bytes from the memory area
3542 pointed to by <tt/p1/ into the memory area pointed to by <tt/p2/. It returns a value that is less than
3543 zero if <tt/p1/ is less than <tt/p2/, zero if <tt/p1/ is the same as <tt/p2/,
3544 and a value greater than zero if <tt/p1/ is greater than <tt/p2/.
3547 <item>The function is only available as fastcall function, so it may only
3548 be used in presence of a prototype.
3550 <tag/Availability/ISO 9899
3552 <ref id="strcmp" name="strcmp">,
3553 <ref id="memmove" name="memmove">,
3554 <ref id="memset" name="memset">
3560 <sect1>memcpy<label id="memcpy"><p>
3564 <tag/Function/Copy a memory area.
3565 <tag/Header/<tt/<ref id="string.h" name="string.h">/
3566 <tag/Declaration/<tt/void* __fastcall__ memcpy (void* dest, const void* src, size_t count);/
3567 <tag/Description/<tt/memcpy/ copies <tt/count/ bytes from the memory area
3568 pointed to by <tt/src/ into the memory area pointed to by <tt/dest/. It returns
3572 <item>The result is undefined if the memory areas do overlap. Use
3573 <tt/<ref id="memmove" name="memmove">/ to copy overlapping memory areas.
3574 <item>The function is only available as fastcall function, so it may only
3575 be used in presence of a prototype.
3577 <tag/Availability/ISO 9899
3579 <ref id="_swap" name="_swap">,
3580 <ref id="memmove" name="memmove">,
3581 <ref id="memset" name="memset">
3587 <sect1>memmove<label id="memmove"><p>
3591 <tag/Function/Copy a memory area.
3592 <tag/Header/<tt/<ref id="string.h" name="string.h">/
3593 <tag/Declaration/<tt/void* __fastcall__ memmove (void* dest, const void* src, size_t count);/
3594 <tag/Description/<tt/memmove/ copies <tt/count/ bytes from the memory area
3595 pointed to by <tt/src/ into the memory area pointed to by <tt/dest/. It returns
3599 <item>While <tt/memmove/ allows the memory areas to overlap, it has some
3600 additional overhead compared to <tt/<ref id="memcpy" name="memcpy">/.
3601 <item>The function is only available as fastcall function, so it may only
3602 be used in presence of a prototype.
3604 <tag/Availability/ISO 9899
3606 <ref id="_swap" name="_swap">,
3607 <ref id="memcpy" name="memcpy">,
3608 <ref id="memset" name="memset">
3614 <sect1>memset<label id="memset"><p>
3618 <tag/Function/Fill a memory area.
3619 <tag/Header/<tt/<ref id="string.h" name="string.h">/
3620 <tag/Declaration/<tt/void* __fastcall__ memset (void* p, int val, size_t count);/
3621 <tag/Description/<tt/memset/ fills the memory area pointed to by <tt/p/ with
3622 the value <tt/val/. The function returns <tt/p/.
3625 <item>The function is only available as fastcall function, so it may only
3626 be used in presence of a prototype.
3628 <tag/Availability/ISO 9899
3630 <ref id="_swap" name="_swap">,
3631 <ref id="bzero" name="bzero">,
3632 <ref id="memcpy" name="memcpy">,
3633 <ref id="memmove" name="memmove">
3639 <sect1>mod_free<label id="mod_free"><p>
3643 <tag/Function/Free a relocatable module.
3644 <tag/Header/<tt/<ref id="modload.h" name="modload.h">/
3645 <tag/Declaration/<tt/void __fastcall__ mod_free (void* module);/
3646 <tag/Description/The function will free a module loaded into memory by use of
3647 the <tt/<ref id="mod_load" name="mod_load">/ function.
3648 <tag/Limits/<itemize>
3649 <item>The pointer passed as parameter is the pointer to the module memory,
3650 not the pointer to the control structure.
3652 <tag/Availability/cc65
3654 <ref id="mod_load" name="mod_load">
3660 <sect1>mod_load<label id="mod_load"><p>
3664 <tag/Function/Load a relocatable module.
3665 <tag/Header/<tt/<ref id="modload.h" name="modload.h">/
3666 <tag/Declaration/<tt/unsigned char mod_load (struct mod_ctrl* ctrl);/
3667 <tag/Description/The function will load a code module into memory and relocate
3668 it. The function will return an error code. If <tt/MLOAD_OK/ is returned, the
3669 outgoing fields in the passed <tt/mod_ctrl/ struct contain information about
3670 the module just loaded. Possible error codes are:
3672 <item><tt/MLOAD_OK/ - Module load successful
3673 <item><tt/MLOAD_ERR_READ/ - Read error
3674 <item><tt/MLOAD_ERR_HDR/ - Header error
3675 <item><tt/MLOAD_ERR_OS/ - Wrong operating system
3676 <item><tt/MLOAD_ERR_FMT/ - Data format error
3677 <item><tt/MLOAD_ERR_MEM/ - Not enough memory
3679 <tag/Limits/<itemize>
3680 <item>The <htmlurl url="ld65.html" name="ld65"> linker is needed to create
3681 relocatable o65 modules for use with this function.
3683 <tag/Availability/cc65
3685 <ref id="mod_free" name="mod_free">
3691 <sect1>mouse_setbox<label id="mouse_setbox"><p>
3695 <tag/Function/Specify a bounding box for the mouse cursor.
3696 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3697 <tag/Declaration/<tt/void __fastcall__ mouse_setbox (const struct mouse_box* box);/
3698 <tag/Description/The function allows to set a bounding box for mouse movement.
3699 <tag/Limits/<itemize>
3700 <item>The function does not check if the mouse cursor is currently within the
3701 given rectangle. Placing the mouse cursor within the bounding box is the
3702 responsibility of the programmer.
3703 <item>While the bounding box may be larger than the actual screen size, the
3704 standard mouse cursor draw routines may fail to set the cursor to coordinates
3705 outside of the screen area. Depending on the platform, you may have to supply
3706 your own mouse cursor routines.
3707 <item>The function is only available as fastcall function, so it may only be
3708 used in presence of a prototype.
3710 <tag/Availability/cc65
3712 <ref id="mouse_getbox" name="mouse_getbox">,
3713 <ref id="mouse_move" name="mouse_move">
3719 <sect1>mouse_getbox<label id="mouse_getbox"><p>
3723 <tag/Function/Return the current bounding box for the mouse cursor.
3724 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3725 <tag/Declaration/<tt/void __fastcall__ mouse_getbox (struct mouse_box* box);/
3726 <tag/Description/The function queries the current bounding box for mouse
3728 <tag/Limits/<itemize>
3729 <item>The function is only available as fastcall function, so it may only be
3730 used in presence of a prototype.
3732 <tag/Availability/cc65
3734 <ref id="mouse_move" name="mouse_move">,
3735 <ref id="mouse_setbox" name="mouse_setbox">
3741 <sect1>mouse_buttons<label id="mouse_buttons"><p>
3745 <tag/Function/Return a bit mask encoding the state of the mouse buttons.
3746 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3747 <tag/Declaration/<tt/unsigned char mouse_buttons (void);/
3748 <tag/Description/The function returns a bit mask that encodes the state of the
3749 mouse buttons. You may use the <tt/MOUSE_BTN_XXX/ flags to decode the function
3751 <tag/Availability/cc65
3753 <ref id="mouse_info" name="mouse_info">,
3754 <ref id="mouse_pos" name="mouse_pos">
3760 <sect1>mouse_geterrormsg<label id="mouse_geterrormsg"><p>
3764 <tag/Function/Return a readable error message for an error code.
3765 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3766 <tag/Declaration/<tt/const char* __fastcall__ mouse_geterrormsg (unsigned char
3768 <tag/Description/The function returns an error message (in english) for the
3769 error code passed parameter.
3770 <tag/Limits/<itemize>
3771 <item>The function will return "Unknown error" for invalid error codes.
3772 <item>The function is only available as fastcall function, so it may only be
3773 used in presence of a prototype.
3775 <tag/Availability/cc65
3777 <ref id="mouse_load_driver" name="mouse_load_driver">,
3778 <ref id="mouse_uninstall" name="mouse_uninstall">,
3779 <ref id="mouse_unload" name="mouse_unload">
3785 <sect1>mouse_hide<label id="mouse_hide"><p>
3789 <tag/Function/Hide the mouse pointer.
3790 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3791 <tag/Declaration/<tt/void mouse_hide (void);/
3792 <tag/Description/The function hides the mouse pointer. It manages a counter
3793 that is shared between <tt/<ref id="mouse_show" name="mouse_show">/ and
3794 <tt/mouse_hide/ so that every call call to <tt/mouse_hide/ must be followed by
3795 a call to <tt/<ref id="mouse_show" name="mouse_show">/ to make the mouse cursor
3797 <tag/Availability/cc65
3799 <ref id="mouse_show" name="mouse_show">
3805 <sect1>mouse_info<label id="mouse_info"><p>
3809 <tag/Function/Return the state of the mouse buttons and the position of the
3811 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3812 <tag/Declaration/<tt/void __fastcall__ mouse_info (struct mouse_info* info);/
3813 <tag/Description/The function returns the state of the mouse buttons and the
3814 position of the mouse in the <tt/mouse_info/ structure passed as parameter.
3815 <tag/Limits/<itemize>
3816 <item>The <tt/mouse_info/ struct is a superset of the <tt/mouse_pos/ struct,
3817 so if you just need the mouse position, call <tt/<ref id="mouse_pos"
3818 name="mouse_pos">/ instead.
3819 <item>The function is only available as fastcall function, so it may only be
3820 used in presence of a prototype.
3822 <tag/Availability/cc65
3824 <ref id="mouse_buttons" name="mouse_buttons">,
3825 <ref id="mouse_pos" name="mouse_pos">
3831 <sect1>mouse_install<label id="mouse_install"><p>
3835 <tag/Function/Install an already loaded mouse driver.
3836 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3837 <tag/Declaration/<tt/unsigned char __fastcall__ mouse_install (const struct
3838 mouse_callbacks* c, void* driver);/
3839 <tag/Description/The function installs an already loaded mouse driver and
3840 returns an error code. The <tt/mouse_callbacks/ structure passed as first
3841 parameter contains pointers to routines needed to move or hide/show the mouse
3842 pointer. Defaults for these routines are supplied by the library, so if you
3843 can live with these defaults (which are platform specific), just pass a
3844 pointer to <tt/mouse_def_callbacks/. The function may be used to install a
3845 driver linked statically to the program.
3846 <tag/Limits/<itemize>
3847 <item>Not all drivers are able to detect if the supported hardware is really
3849 <item>After installing a driver, the mouse cursor is hidden.
3850 <item>The function is only available as fastcall function, so it may only be
3851 used in presence of a prototype.
3853 <tag/Availability/cc65
3855 <ref id="mouse_load_driver" name="mouse_load_driver">,
3856 <ref id="mouse_uninstall" name="mouse_uninstall">,
3857 <ref id="mouse_unload" name="mouse_unload">
3863 <sect1>mouse_ioctl<label id="mouse_ioctl"><p>
3867 <tag/Function/Call the driver specific ioctl function.
3868 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3869 <tag/Declaration/<tt/unsigned char __fastcall__ mouse_ioctl (unsigned char code, void* data);/
3870 <tag/Description/The function calls the IOCTL entry in the mouse driver,
3871 which is driver specific. The <tt/code/ parameter will choose between
3872 different IOCTL functions, and the <tt/data/ depends on code. The
3873 function returns an error code. The purpose of this function is to allow
3874 for driver specific extensions. See the documentation for a specific mouse
3875 driver for supported ioctl calls.
3876 <tag/Limits/<itemize>
3877 <item>Calling this function is non portable, because each driver may
3878 implement different ioctl calls (or none at all).
3879 <item>The function is only available as fastcall function, so it may only be
3880 used in presence of a prototype.
3882 <tag/Availability/cc65
3888 <sect1>mouse_load_driver<label id="mouse_load_driver"><p>
3892 <tag/Function/Load and initialize a mouse driver.
3893 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3894 <tag/Declaration/<tt/unsigned char __fastcall__ mouse_load_driver (const struct
3895 mouse_callbacks* c, const char* driver);/
3896 <tag/Description/Load a mouse driver into memory and initialize it. The
3897 function returns an error code that tells if the call has been successful. The
3898 <tt/mouse_callbacks/ structure passed as first parameter contains pointers to
3899 routines needed to move or hide/show the mouse pointer. Defaults for these
3900 routines are supplied by the library, so if you can live with these defaults
3901 (which are platform specific), just pass a pointer to <tt/mouse_def_callbacks/.
3902 <tag/Limits/<itemize>
3903 <item>The driver is loaded by name, so currently you must know the type of
3904 mouse that should be supported. There is no autodetect capability.
3905 <item>Not all drivers are able to detect if the supported hardware is really
3907 <item>After installing a driver, the mouse cursor is hidden.
3908 <item>The function is only available as fastcall function, so it may only be
3909 used in presence of a prototype.
3911 <tag/Availability/cc65
3913 <ref id="mouse_install" name="mouse_install">,
3914 <ref id="mouse_uninstall" name="mouse_uninstall">,
3915 <ref id="mouse_unload" name="mouse_unload">
3921 <sect1>mouse_move<label id="mouse_move"><p>
3925 <tag/Function/Move the mouse cursor to a specific position.
3926 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3927 <tag/Declaration/<tt/void __fastcall__ mouse_move (int x, int y);/
3928 <tag/Description/The function updates the mouse position. If the mouse cursor
3929 is visible, it is shown at the new position.
3930 <tag/Limits/<itemize>
3931 <item>The function does not check if the new position is within the bounding
3932 box specified with <tt/<ref id="mouse_setbox" name="mouse_setbox">/.
3933 <item>The function is only available as fastcall function, so it may only be
3934 used in presence of a prototype.
3936 <tag/Availability/cc65
3938 <ref id="mouse_getbox" name="mouse_getbox">,
3939 <ref id="mouse_setbox" name="mouse_setbox">
3945 <sect1>mouse_pos<label id="mouse_pos"><p>
3949 <tag/Function/Return the position of the mouse.
3950 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3951 <tag/Declaration/<tt/void __fastcall__ mouse_pos (struct mouse_pos* pos);/
3952 <tag/Description/The function returns the position of the mouse in the
3953 <tt/mouse_pos/ structure passed as parameter.
3954 <tag/Limits/<itemize>
3955 <item>The <tt/mouse_pos/ struct is a subset of the <tt/mouse_info/ struct,
3956 so if you do also need the mouse buttons, call <tt/<ref id="mouse_info"
3957 name="mouse_info">/ instead.
3958 <item>The function is only available as fastcall function, so it may only be
3959 used in presence of a prototype.
3961 <tag/Availability/cc65
3963 <ref id="mouse_buttons" name="mouse_buttons">,
3964 <ref id="mouse_info" name="mouse_info">
3970 <sect1>mouse_show<label id="mouse_show"><p>
3974 <tag/Function/Show the mouse pointer.
3975 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3976 <tag/Declaration/<tt/void mouse_show (void);/
3977 <tag/Description/The function shows the mouse pointer. It manages a counter
3978 that is shared between <tt/<ref id="mouse_hide" name="mouse_hide">/ and
3979 <tt/mouse_show/. The mouse cursor is visible if there was one more call to
3980 <tt/mouse_show/ than to <tt/<ref id="mouse_hide" name="mouse_hide">/.
3981 <tag/Availability/cc65
3983 <ref id="mouse_hide" name="mouse_hide">
3989 <sect1>mouse_uninstall<label id="mouse_uninstall"><p>
3993 <tag/Function/Uninstall an already loaded mouse driver.
3994 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
3995 <tag/Declaration/<tt/unsigned char mouse_uninstall (void);/
3996 <tag/Description/The function uninstalls an already loaded mouse driver but
3997 don't removes it from memory.
3998 <tag/Limits/<itemize>
3999 <item>If the driver has been loaded using <tt/<ref id="mouse_load_driver"
4000 name="mouse_load_driver">/, <tt/<ref id="mouse_unload" name="mouse_unload">/
4001 should be used instead of <tt/mouse_uninstall/ so the driver is also removed
4004 <tag/Availability/cc65
4006 <ref id="mouse_install" name="mouse_install">,
4007 <ref id="mouse_load_driver" name="mouse_load_driver">,
4008 <ref id="mouse_unload" name="mouse_unload">
4014 <sect1>mouse_unload<label id="mouse_unload"><p>
4018 <tag/Function/Unload a mouse driver.
4019 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
4020 <tag/Declaration/<tt/unsigned char __fastcall__ mouse_unload (void);/
4021 <tag/Description/The function unloads a loaded mouse driver and frees all
4022 memory allocated for the driver.
4023 <tag/Limits/<itemize>
4024 <item>The function does nothing if no driver is loaded.
4026 <tag/Availability/cc65
4028 <ref id="mouse_install" name="mouse_install">,
4029 <ref id="mouse_load_driver" name="mouse_load_driver">,
4030 <ref id="mouse_uninstall" name="mouse_uninstall">
4036 <sect1>offsetof<label id="offsetof"><p>
4040 <tag/Function/Calculate the offset of a struct or union member.
4041 <tag/Header/<tt/<ref id="stddef.h" name="stddef.h">/
4042 <tag/Declaration/<tt/size_t offsetof (type, member);/
4043 <tag/Description/<tt/offsetof/ calculates the address offset of a <tt/struct/
4044 or <tt/union/ member.
4045 <tag/Limits/<itemize>
4046 <item>The function is actually a macro.
4048 <tag/Availability/ISO 9899
4054 <sect1>open<label id="open"><p>
4058 <tag/Function/Open and possibly create a file.
4059 <tag/Header/<tt/<ref id="fcntl.h" name="fcntl.h">/
4060 <tag/Declaration/<tt/int open (const char* name, int flags, ...);/
4061 <tag/Description/<tt/open/ opens a file and returns the file descriptor
4062 associated with it. On error, -1 is returned and an error code is stored in
4063 <tt/errno/. Several flags may be passed to <tt/open/ that change the behaviour.
4064 <tag/Limits/<itemize>
4065 <item>POSIX specifies an additional <tt/mode/ argument that may be passed to
4066 open, which is used as the permission mask when a new file is created. While
4067 cc65 allows to pass this argument, it is ignored.
4069 <tag/Availability/POSIX 1003.1
4071 <ref id="close" name="close">,
4072 <ref id="creat" name="creat">
4078 <sect1>opendir<label id="opendir"><p>
4082 <tag/Function/Open a directory.
4083 <tag/Header/<tt/<ref id="dirent.h" name="dirent.h">/
4084 <tag/Declaration/<tt/DIR* __fastcall__ opendir (const char* name);/
4085 <tag/Description/<tt/opendir/ opens a directory and returns the direcory
4086 descriptor associated with it. On error, NULL is returned and an error code is
4087 stored in <tt/errno/.
4088 <tag/Limits/<itemize>
4089 <item>The function is only available as fastcall function, so it may only
4090 be used in presence of a prototype.
4092 <tag/Availability/POSIX 1003.1
4094 <ref id="closedir" name="closedir">,
4095 <ref id="readdir" name="readdir">
4101 <sect1>peekbsys<label id="peekbsys"><p>
4105 <tag/Function/Read one byte from a location in the system bank.
4106 <tag/Header/<tt/<ref id="cbm610.h" name="cbm610.h">/,
4107 <tt/<ref id="cbm510.h" name="cbm510.h">/
4108 <tag/Declaration/<tt/unsigned char __fastcall__ peekbsys (unsigned addr);/
4109 <tag/Description/<tt/peekbsys/ reads one byte from the given address in the
4110 system bank (bank 15) of the CBM PET-II machines and returns it.
4113 <item>The function is only available as fastcall function, so it may only
4114 be used in presence of a prototype.
4115 <item>This function may be a macro depending on the compiler options. The
4116 actual function is accessible by #undef'ing the macro.
4118 <tag/Availability/cc65
4120 <ref id="PEEK" name="PEEK">,
4121 <ref id="PEEKW" name="PEEKW">,
4122 <ref id="peekwsys" name="peekwsys">,
4123 <ref id="pokebsys" name="pokebsys">,
4124 <ref id="pokewsys" name="pokewsys">
4130 <sect1>peekwsys<label id="peekwsys"><p>
4134 <tag/Function/Read one word from a location in the system bank.
4135 <tag/Header/<tt/<ref id="cbm610.h" name="cbm610.h">/,
4136 <tt/<ref id="cbm510.h" name="cbm510.h">/
4137 <tag/Declaration/<tt/unsigned __fastcall__ peekwsys (unsigned addr);/
4138 <tag/Description/<tt/peekwsys/ reads one word from the given address in the
4139 system bank (bank 15) of the CBM PET-II machines and returns it. Following
4140 the usual 6502 conventions, the low byte is read from <tt/addr/, and the
4141 high byte is read from <tt/addr+1/.
4144 <item>The function is only available as fastcall function, so it may only
4145 be used in presence of a prototype.
4146 <item>The order in which the two bytes are read is undefined.
4148 <tag/Availability/cc65
4150 <ref id="PEEK" name="PEEK">,
4151 <ref id="PEEKW" name="PEEKW">,
4152 <ref id="peekbsys" name="peekbsys">,
4153 <ref id="pokebsys" name="pokebsys">,
4154 <ref id="pokewsys" name="pokewsys">
4160 <sect1>perror<label id="perror"><p>
4164 <tag/Function/Print an error message for the error in <tt/errno/.
4165 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
4166 <tag/Declaration/<tt/void __fastcall__ perror (const char* s);/
4167 <tag/Description/<tt/perror/ prints an error message to <tt/stderr/. If <tt/s/
4168 is not <tt/NULL/ and not an empty string, it is printed followed by a colon and
4169 a blank. Then the error message for the current contents of <tt/errno/ is
4170 printed followed by a newline. The message output is the same as returned by
4171 <tt/<ref id="strerror" name="strerror">/ with an argument of <tt/errno/.
4174 <item>The function is only available as fastcall function, so it may only
4175 be used in presence of a prototype.
4177 <tag/Availability/ISO 9899
4179 <ref id="_poserror" name="_poserror">,
4180 <ref id="strerror" name="strerror">
4186 <sect1>pokebsys<label id="pokebsys"><p>
4190 <tag/Function/Write one byte to a location in the system bank.
4191 <tag/Header/<tt/<ref id="cbm610.h" name="cbm610.h">/,
4192 <tt/<ref id="cbm510.h" name="cbm510.h">/
4193 <tag/Declaration/<tt/void __fastcall__ pokebsys (unsigned addr, unsigned char val);/
4194 <tag/Description/<tt/pokebsys/ writes one byte to the given address in the
4195 system bank (bank 15) of the CBM PET-II machines.
4198 <item>The function is only available as fastcall function, so it may only
4199 be used in presence of a prototype.
4201 <tag/Availability/cc65
4203 <ref id="POKE" name="POKE">,
4204 <ref id="POKEW" name="POKEW">,
4205 <ref id="peekbsys" name="peekbsys">,
4206 <ref id="peekwsys" name="peekwsys">,
4207 <ref id="pokewsys" name="pokewsys">
4213 <sect1>pokewsys<label id="pokewsys"><p>
4217 <tag/Function/Write one word to a location in the system bank.
4218 <tag/Header/<tt/<ref id="cbm610.h" name="cbm610.h">/,
4219 <tt/<ref id="cbm510.h" name="cbm510.h">/
4220 <tag/Declaration/<tt/void __fastcall__ pokewsys (unsigned addr, unsigned val);/
4221 <tag/Description/<tt/pokewsys/ writes one word to the given address in the
4222 system bank (bank 15) of the CBM PET-II machines. Following the usual 6502
4223 conventions, the low byte of <tt/val/ is written to <tt/addr/, and the
4224 high byte is written to <tt/addr+1/.
4227 <item>The function is only available as fastcall function, so it may only
4228 be used in presence of a prototype.
4229 <item>The order in which the two bytes are written is undefined.
4231 <tag/Availability/cc65
4233 <ref id="POKE" name="POKE">,
4234 <ref id="POKEW" name="POKEW">,
4235 <ref id="peekbsys" name="peekbsys">,
4236 <ref id="peekwsys" name="peekwsys">,
4237 <ref id="pokebsys" name="pokebsys">
4243 <sect1>qsort<label id="qsort"><p>
4247 <tag/Function/Sort an array.
4248 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
4249 <tag/Declaration/<tt/void __fastcall__ qsort (void* base, size_t count,
4250 size_t size, int (*compare) (const void*, const void*));/
4251 <tag/Description/<tt/qsort/ sorts an array according to a given compare
4252 function <tt/compare/. <tt/base/ is the address of the array, <tt/count/
4253 is the number of elements, <tt/size/ the size of an element and <tt/compare/
4254 the function used to compare the members.
4257 <item>If there are multiple members with the same key, the order after calling
4258 the function is undefined.
4259 <item>The function is only available as fastcall function, so it may only
4260 be used in presence of a prototype.
4262 <tag/Availability/ISO 9899
4264 <ref id="bsearch" name="bsearch">
4270 <sect1>raise<label id="raise"><p>
4274 <tag/Function/Send a signal to the executing program.
4275 <tag/Header/<tt/<ref id="signal.h" name="signal.h">/
4276 <tag/Declaration/<tt/int __fastcall__ raise (int sig);/
4277 <tag/Description/<tt/raise/ sends the given signal to the program. If the
4278 program has installed a signal handler for the signal, this signal handler
4279 will be executed. If no handler has been installed, the default action for
4280 the raised signal will be taken. The function returns zero on success,
4282 <tag/Limits/<itemize>
4283 <item>The function is only available as fastcall function, so it may only
4284 be used in presence of a prototype.
4286 <tag/Availability/ISO 9899
4288 <ref id="abort" name="abort">,
4289 <ref id="signal" name="signal">
4295 <sect1>rand<label id="rand"><p>
4299 <tag/Function/Return a pseudo random number.
4300 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
4301 <tag/Declaration/<tt/int rand (void);/
4302 <tag/Description/The function returns a pseudo random number
4303 between 0 and <tt/RAND_MAX/ (exclusive).
4304 <tag/Limits/<itemize>
4305 <item>Without using <tt><ref id="srand" name="srand"></tt>, always the same
4306 flow of numbers is generated.
4307 <item>On startup, the function behaves as if <ref id="srand" name="srand">
4308 had been used with an argument of 1.
4310 <tag/Availability/ISO 9899
4312 <ref id="_randomize" name="_randomize">,
4313 <ref id="srand" name="srand">
4319 <sect1>readdir<label id="readdir"><p>
4323 <tag/Function/Read a directory.
4324 <tag/Header/<tt/<ref id="dirent.h" name="dirent.h">/
4325 <tag/Declaration/<tt/struct dirent* __fastcall__ readdir (DIR* dir);/
4326 <tag/Description/<tt/readdir/ reads the next directory entry from the directory
4327 stream pointed to by <tt/dir/. It stores the data in a <tt/dirent/ structure
4328 and returns a pointer to it. If the end of directory is reached, or an error
4329 occurs, NULL is returned. In case of errors, an error code is stored into
4331 <tag/Limits/<itemize>
4332 <item>The function is only available as fastcall function, so it may only
4333 be used in presence of a prototype.
4334 <item>The returned pointer may point to a statically allocated instance of
4335 <tt/struct dirent/, so it may get overwritten by subsequent calls to
4338 <tag/Availability/POSIX 1003.1
4340 <ref id="closedir" name="closedir">,
4341 <ref id="opendir" name="opendir">
4347 <sect1>realloc<label id="realloc"><p>
4351 <tag/Function/Change the size of an allocated memory block.
4352 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
4353 <tag/Declaration/<tt/void* __fastcall__ realloc (void* block, size_t size);/
4354 <tag/Description/<tt/realloc/ changes the size of the memory block pointed to
4355 by <tt/block/ to <tt/size/ bytes. If <tt/block/ is <tt/NULL/, <tt/realloc/
4356 behaves as if <tt/malloc/ had been called. If <tt/size/ is zero, <tt/realloc/
4357 behaves as if <tt/free/ had been called. On error (not enough memory
4358 available), <tt/realloc/ returns <tt/NULL/.
4361 <item>The part of the memory block that is returned will have its contents
4363 <item>This function is somewhat dangerous to use. Be careful to save the
4364 pointer you're passing somewhere else, otherwise
4366 ptr = realloc (ptr, size);
4368 will loose your only copy of <tt/ptr/ if <tt/realloc/ returns <tt/NULL/.
4369 <item>The function is only available as fastcall function, so it may only
4370 be used in presence of a prototype.
4372 <tag/Availability/ISO 9899
4374 <ref id="_heapadd" name="_heapadd">,
4375 <ref id="_heapblocksize" name="_heapblocksize">,
4376 <ref id="_heapmaxavail" name="_heapmaxavail">,
4377 <ref id="_heapmemavail" name="_heapmemavail">,
4378 <ref id="calloc" name="calloc">,
4379 <ref id="free" name="free">,
4380 <ref id="realloc" name="realloc">
4386 <sect1>remove<label id="remove"><p>
4390 <tag/Function/Delete a file.
4391 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
4392 <tag/Declaration/<tt/int __fastcall__ remove (const char* name);/
4393 <tag/Description/<tt/remove/ deletes the file with the given name. On success,
4394 zero is returned. On error, -1 is returned and <tt/errno/ is set to an error
4395 code describing the reason for the failure.
4398 <item>This function is not available on all cc65 targets (depends on the
4399 availability of file I/O).
4400 <item>The function is only available as fastcall function, so it may only
4401 be used in presence of a prototype.
4403 <tag/Availability/ISO 9899
4405 <ref id="rename" name="rename">,
4406 <ref id="unlink" name="unlink">
4409 #include <stdio.h>
4411 #define FILENAME "helloworld"
4413 if (remove (FILENAME) == 0) {
4414 printf ("We deleted %s successfully\n", FILENAME);
4416 printf ("There was a problem deleting %s\n", FILENAME);
4423 <sect1>rename<label id="rename"><p>
4427 <tag/Function/Rename a file.
4428 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
4429 <tag/Declaration/<tt/int __fastcall__ rename (const char* oldname, const char* newname);/
4430 <tag/Description/<tt/rename/ renames a file (gives it a new name). On success,
4431 zero is returned. On error, -1 is returned and <tt/errno/ is set to an error
4432 code describing the reason for the failure.
4435 <item>This function is not available on all cc65 targets (depends on the
4436 capabilities of the storage devices).
4437 <item>The function is only available as fastcall function, so it may only
4438 be used in presence of a prototype.
4440 <tag/Availability/ISO 9899
4442 <ref id="remove" name="remove">
4445 #include <stdio.h>
4447 #define OLDNAME "textfile.txt"
4448 #define NEWNAME "textfile.bak"
4450 if (rename (OLDNAME, NEWNAME) == 0) {
4451 printf ("Renamed %s to %s\n", OLDNAME, NEWNAME);
4453 printf ("Error renaming %s to %s\n", OLDNAME, NEWNAME);
4460 <sect1>reset_brk<label id="reset_brk"><p>
4464 <tag/Function/Resets the break vector to its original value.
4465 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
4466 <tag/Declaration/<tt/void reset_brk (void);/
4467 <tag/Description/<tt/reset_brk/ resets the break vector to the value it had
4468 before a call to <tt/set_brk/.
4471 <item>Since <tt/<ref id="set_brk" name="set_brk">/ installs an exit handler,
4472 it is not strictly necessary to call this function as part of the cleanup when
4475 <tag/Availability/cc65
4477 <ref id="reset_irq" name="reset_irq">,
4478 <ref id="set_brk" name="set_brk">,
4479 <ref id="set_irq" name="set_irq">
4485 <sect1>reset_irq<label id="reset_irq"><p>
4489 <tag/Function/Resets the C level interrupt request vector.
4490 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
4491 <tag/Declaration/<tt/void reset_irq (void);/
4492 <tag/Description/<tt/reset_irq/ resets the C level interrupt request vector.
4495 <item>The original IRQ vector is restored on program termination even without
4496 calling this function.
4498 <tag/Availability/cc65
4500 <ref id="reset_brk" name="reset_brk">,
4501 <ref id="set_brk" name="set_brk">,
4502 <ref id="set_irq" name="set_irq">
4508 <sect1>revers<label id="revers"><p>
4512 <tag/Function/Control revers character display.
4513 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
4514 <tag/Declaration/<tt/unsigned char __fastcall__ revers (unsigned char onoff);/
4515 <tag/Description/If the argument is non zero, the function enables reverse
4516 character display. If the argument is zero, reverse character display is
4517 switched off. The old value of the setting is returned.
4518 <tag/Limits/<itemize>
4519 <item>The function may not be supported by the hardware, in which case
4520 the call is ignored.
4521 <item>The function is only available as fastcall function, so it may only
4522 be used in presence of a prototype.
4524 <tag/Availability/cc65
4526 <ref id="textcolor" name="textcolor">
4532 <sect1>rewinddir<label id="rewinddir"><p>
4536 <tag/Function/Reset a directory stream.
4537 <tag/Header/<tt/<ref id="dirent.h" name="dirent.h">/
4538 <tag/Declaration/<tt/void __fastcall__ rewinddir (DIR* dir);/
4539 <tag/Description/<tt/rewinddir/ sets the position of the directory stream
4540 pointed to by <tt/dir/ to the start of the directory.
4541 <tag/Limits/<itemize>
4542 <item>The function is only available as fastcall function, so it may only
4543 be used in presence of a prototype.
4545 <tag/Availability/POSIX 1003.1
4547 <ref id="seekdir" name="seekdir">,
4548 <ref id="telldir" name="telldir">
4554 <sect1>screensize<label id="screensize"><p>
4558 <tag/Function/Return the dimensions of the text mode screen.
4559 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
4560 <tag/Declaration/<tt/void __fastcall__ screensize (unsigned char* x, unsigned char* y);/
4561 <tag/Description/The function returns the dimensions of the text mode screen.
4562 <tag/Limits/<itemize>
4563 <item>The function is only available as fastcall function, so it may only
4564 be used in presence of a prototype.
4566 <tag/Availability/cc65
4568 <ref id="gotox" name="gotox">,
4569 <ref id="gotoxy" name="gotoxy">,
4570 <ref id="gotoy" name="gotoy">,
4571 <ref id="wherex" name="wherex">,
4572 <ref id="wherey" name="wherey">
4578 <sect1>seekdir<label id="seekdir"><p>
4582 <tag/Function/Set the position of a directory stream.
4583 <tag/Header/<tt/<ref id="dirent.h" name="dirent.h">/
4584 <tag/Declaration/<tt/void __fastcall__ seekdir (DIR* dir, long offset);/
4585 <tag/Description/<tt/seekdir/ sets the position of the directory stream
4586 pointed to by <tt/dir/ to the value given in <tt/offset/, which should be a
4587 value returned by <tt/<ref id="telldir" name="telldir">/.
4588 <tag/Limits/<itemize>
4589 <item>The function is only available as fastcall function, so it may only
4590 be used in presence of a prototype.
4592 <tag/Availability/POSIX 1003.1
4594 <ref id="rewinddir" name="rewinddir">,
4595 <ref id="telldir" name="telldir">
4601 <sect1>ser_close<label id="ser_close"><p>
4605 <tag/Function/Close the port and disable interrupts
4606 <tag/Header/<tt/<ref id="serial.h" name="serial.h">/
4607 <tag/Declaration/<tt/unsigned char ser_close (void);/
4608 <tag/Description/Close the port by clearing buffers and disable interrupts.
4609 <tag/Availability/cc65
4610 <tag/See also/Other serial functions.
4615 extern char comlynx[];
4617 static void initialize(){
4618 struct ser_params params = {
4625 ser_install(&comlynx); // This will activate the ComLynx
4627 ser_open(&params);
4634 <sect1>ser_get<label id="ser_get"><p>
4638 <tag/Function/Read a character from serial port.
4639 <tag/Header/<tt/<ref id="serial.h" name="serial.h">/
4640 <tag/Declaration/<tt/unsigned char __fastcall__ ser_get (char* b);/
4641 <tag/Description/Get a character from the serial port. If no characters are
4642 available, the function will return SER_ERR_NO_DATA, so this is not a fatal
4644 <tag/Limits/<itemize>
4645 <item>The function is only available as fastcall function, so it may only
4646 be used in presence of a prototype.
4648 <tag/Availability/cc65
4649 <tag/See also/Other serial functions.
4651 Wait for a character to be available from a serial port.
4654 while (ser_get(&ch) == SER_ERR_NO_DATA)
4661 <sect1>ser_install<label id="ser_install"><p>
4665 <tag/Function/Install an already loaded driver and return an error code.
4666 <tag/Header/<tt/<ref id="serial.h" name="serial.h">/
4667 <tag/Declaration/<tt/unsigned char __fastcall__ ser_install (void* driver);/
4668 <tag/Description/The function installs a driver that was already loaded into
4669 memory (or linked statically to the program). It returns an error code
4670 (<tt/SER_ERR_OK/ in case of success).
4671 <tag/Limits/<itemize>
4672 <item>The function is only available as fastcall function, so it may only be
4673 used in presence of a prototype.
4675 <tag/Availability/cc65
4677 <ref id="ser_load_driver" name="ser_load_driver">,
4678 <ref id="ser_uninstall" name="ser_uninstall">,
4679 <ref id="ser_unload" name="ser_unload">
4681 extern char lynxser[]; //Include the driver statically instead of loading it.
4683 ser_install(&lynxser);
4689 <sect1>ser_ioctl<label id="ser_ioctl"><p>
4693 <tag/Function/Platform dependent code extensions.
4694 <tag/Header/<tt/<ref id="serial.h" name="serial.h">/
4695 <tag/Declaration/<tt/unsigned __fastcall__ ser_ioctl (unsigned char code, void* data);/
4696 <tag/Description/Some platforms have extra serial functions that are not
4697 supported by standard serial driver functions. You can extend the driver to support
4698 this extra functionality bt using ser_ioctl functions.
4699 <tag/Limits/<itemize>
4700 <item>The function is only available as fastcall function, so it may only
4701 be used in presence of a prototype.
4702 <item>These functions are not easily portable to other cc65 platforms.
4704 <tag/Availability/cc65
4705 <tag/See also/Other serial functions.
4710 <sect1>ser_load_driver<label id="ser_load_driver"><p>
4714 <tag/Function/Load and install a serial driver.
4715 <tag/Header/<tt/<ref id="serial.h" name="serial.h">/
4716 <tag/Declaration/<tt/unsigned char __fastcall__ ser_load_driver (const char *name);/
4717 <tag/Description/Load and install the driver by name.
4718 Will just load the driver and check if loading was successful.
4719 <tag/Limits/<itemize>
4720 <item>The function is only available as fastcall function, so it may only
4721 be used in presence of a prototype.
4723 <tag/Availability/cc65
4724 <tag/See also/Other serial functions.
4730 <sect1>ser_open<label id="ser_open"><p>
4734 <tag/Function/Open the port by setting the port parameters and enable interrupts
4735 <tag/Header/<tt/<ref id="serial.h" name="serial.h">/
4736 <tag/Declaration/<tt/unsigned char __fastcall__ ser_open (const struct ser_params* params);/
4737 <tag/Description/Open the port by setting the port parameters and enable interrupts.
4738 <tag/Limits/<itemize>
4739 <item>The function is only available as fastcall function, so it may only
4740 be used in presence of a prototype.
4742 <tag/Availability/cc65
4743 <tag/See also/Other serial functions.
4748 extern char comlynx[];
4750 static void initialize(){
4751 struct ser_params params = {
4758 ser_install(&comlynx); // This will activate the ComLynx
4760 ser_open(&params);
4767 <sect1>ser_put<label id="ser_put"><p>
4771 <tag/Function/Write a character to a serial port.
4772 <tag/Header/<tt/<ref id="serial.h" name="serial.h">/
4773 <tag/Declaration/<tt/unsigned char __fastcall__ ser_put (char b);/
4774 <tag/Description/Send a character via the serial port. There is a transmit
4775 buffer, but transmitting is not done via interrupt. The function returns
4776 SER_ERR_OVERFLOW if there is no space left in the transmit buffer.
4777 <tag/Limits/<itemize>
4778 <item>The function is only available as fastcall function, so it may only
4779 be used in presence of a prototype.
4781 <tag/Availability/cc65
4782 <tag/See also/Other serial functions.
4791 <sect1>ser_status<label id="ser_status"><p>
4795 <tag/Function/Return the serial port status.
4796 <tag/Header/<tt/<ref id="serial.h" name="serial.h">/
4797 <tag/Declaration/<tt/unsigned char __fastcall__ ser_status (unsigned char* status);/
4798 <tag/Description/Return the serial port status.
4799 <tag/Limits/<itemize>
4800 <item>The function is only available as fastcall function, so it may only
4801 be used in presence of a prototype.
4803 <tag/Availability/cc65
4804 <tag/See also/Other serial functions.
4810 <sect1>ser_uninstall<label id="ser_uninstall"><p>
4814 <tag/Function/Uninstall the currently loaded driver but do not unload it.
4815 <tag/Header/<tt/<ref id="serial.h" name="serial.h">/
4816 <tag/Declaration/<tt/unsigned char ser_uninstall (void);/
4817 <tag/Description/Uninstall the currently loaded driver but do not unload it.
4818 <tag/Availability/cc65
4819 <tag/See also/Other serial functions.
4824 <sect1>ser_unload<label id="ser_unload"><p>
4828 <tag/Function/Uninstall, then unload the currently loaded driver.
4829 <tag/Header/<tt/<ref id="serial.h" name="serial.h">/
4830 <tag/Declaration/<tt/unsigned char ser_unload (void);/
4831 <tag/Description/Uninstall, then unload the currently loaded driver.
4832 <tag/Availability/cc65
4833 <tag/See also/Other serial functions.
4839 <sect1>set_brk<label id="set_brk"><p>
4843 <tag/Function/Set the break vector to a user function.
4844 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
4845 <tag/Declaration/<tt/void __fastcall__ set_brk (brk_handler func);/
4846 <tag/Description/<tt/set_brk/ allows a user program to handle breaks within the
4847 program code by letting the vector point to a user written C function. The
4848 runtime library installs a small stub that saves the registers into global
4849 variables that may be accessed (and changed) by the break handler.
4852 <item>The function is only available as fastcall function, so it may only
4853 be used in presence of a prototype.
4854 <item>The stub saves the zero page registers used by the C runtime and switches
4855 to a small break handler stack. This means that it is safe to execute C code,
4856 even if C code was interrupted. Be careful however not to use too many local
4857 variables, and do not enable stack checks for the handler function or any other
4858 function called from it.
4859 <item>The <tt/brk_pc/ variable points to the <tt/BRK/ instruction. If you want
4860 the continue with the interrupted code, you have to adjust <tt/brk_pc/,
4861 otherwise the <tt/BRK/ instruction will get executed over and over again.
4862 <item>Since <tt/set_brk/ installs an exit handler, it is not strictly necessary
4863 to call <tt/<ref id="reset_brk" name="reset_brk">/ as part of the cleanup when
4864 the program terminates.
4866 <tag/Availability/cc65
4868 <ref id="reset_brk" name="reset_brk">
4874 <sect1>set_irq<label id="set_irq"><p>
4878 <tag/Function/Set the C level interrupt request vector to the given address.
4879 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
4880 <tag/Declaration/<tt/void __fastcall__ set_irq (irq_handler f, void *stack_addr, size_t stack_size);/
4881 <tag/Description/<tt/set_irq/ allows a user program to handle interrupt requests
4882 (IRQs) within the program code by letting the vector point to a user written C
4883 function. The runtime library installs a small stub that saves the zero page
4884 registers used by the C runtime before calling the handler function and restores
4885 them after the handler function returns. Additionally the stub temporarily switches
4886 the C runtime stack to the stack area provided as parameter. If the handler function
4887 was set up to handle a "private", "exclusive" interrupt request source it must
4888 return the value <tt/IRQ_HANDLED/ if and only if it has verified that the current
4889 interrupt request actually stems from that source. In all other cases it must return
4890 the value <tt/IRQ_NOT_HANDLED/.
4893 <item>The function is only available as fastcall function, so it may only
4894 be used in presence of a prototype.
4895 <item>The stub saves the registers and zero page locations used by the C runtime
4896 and switches to the provided stack area. As a consequence, there is some
4897 runtime overhead, but it it is safe to execute C code, even if other C code
4898 was interrupted. Be careful however not to call C library functions, and do not
4899 enable stack checks for the handler function or any other function called from
4901 <item>The interrupt vector is reset on function termination, so it's not
4902 strictly necessary to call <tt/<ref id="reset_irq" name="reset_irq">/ as part
4903 of the cleanup when the program terminates.
4905 <tag/Availability/cc65
4907 <ref id="reset_brk" name="reset_brk">,
4908 <ref id="reset_irq" name="reset_irq">,
4909 <ref id="set_brk" name="set_brk">
4915 <sect1>setjmp<label id="setjmp"><p>
4919 <tag/Function/Save the context for use with <tt/longjmp/.
4920 <tag/Header/<tt/<ref id="setjmp.h" name="setjmp.h">/
4921 <tag/Declaration/<tt/int __fastcall__ setjmp (jmp_buf buf);/
4922 <tag/Description/The <tt/setjmp/ function saves the current context in <tt/buf/
4923 for subsequent use by the <tt/<ref id="longjmp" name="longjmp">/ function and
4927 <item>The function is only available as fastcall function, so it may only
4928 be used in presence of a prototype.
4929 <item><tt/setjmp/ is actually a macro as required by the ISO standard.
4930 <item><tt/setjmp/ will not save the signal context.
4932 <tag/Availability/ISO 9899
4934 <ref id="longjmp" name="longjmp">
4940 <sect1>setlocale<label id="setlocale"><p>
4944 <tag/Function/Selects a locale.
4945 <tag/Header/<tt/<ref id="locale.h" name="locale.h">/
4946 <tag/Declaration/<tt/char* __fastcall__ setlocale (int category, const char* locale);/
4947 <tag/Description/<tt/setlocale/ sets or queries the program's locale.
4950 <item>The function is only available as fastcall function, so it may only
4951 be used in presence of a prototype.
4952 <item>cc65 supports only the "C" locale, so calling this function to set a
4953 different locale has no effect.
4955 <tag/Availability/ISO 9899
4957 <ref id="localeconv" name="localeconv">,
4958 <ref id="strcoll" name="strcoll">
4959 <ref id="strxfrm" name="strxfrm">
4965 <sect1>signal<label id="signal"><p>
4969 <tag/Function/Install a signal handler.
4970 <tag/Header/<tt/<ref id="signal.h" name="signal.h">/
4971 <tag/Declaration/<tt/__sigfunc __fastcall__ signal (int sig, __sigfunc func);/
4972 <tag/Description/<tt/signal/ installs a handler for the given signal. The
4973 handler may either be a user supplied function, or one of the predefined
4974 signal handlers <tt/SIG_IGN/ or <tt/SIG_DFL/. The function returns the
4975 previous value if the signal , or the special function vector SIG_ERR in
4977 <tag/Limits/<itemize>
4978 <item>The function is only available as fastcall function, so it may only
4979 be used in presence of a prototype.
4981 <tag/Availability/ISO 9899
4983 <ref id="abort" name="abort">,
4984 <ref id="raise" name="raise">
4990 <sect1>sleep<label id="sleep"><p>
4994 <tag/Function/Sleep for a specified amount of time.
4995 <tag/Header/<tt/<ref id="unistd.h" name="unistd.h">/
4996 <tag/Declaration/<tt/void __fastcall__ sleep (unsigned seconds);/
4997 <tag/Description/The function will return after the specified number of
4998 seconds have elapsed.
4999 <tag/Limits/<itemize>
5000 <item>The function is only available as fastcall function, so it may only
5001 be used in presence of a prototype.
5003 <tag/Availability/POSIX 1003.1
5009 <sect1>slow<label id="slow"><p>
5013 <tag/Function/Switch the C128 into 1MHz mode.
5014 <tag/Header/<tt/<ref id="c128.h" name="c128.h">/
5015 <tag/Declaration/<tt/void slow (void);/
5016 <tag/Description/The function will switch the clock of the C128 to 1MHz. This
5017 will halve the speed compared to fast mode.
5018 <tag/Limits/<itemize>
5019 <item>The function is specific to the C128.
5021 <tag/Availability/C128
5023 <ref id="fast" name="fast">,
5024 <ref id="toggle_videomode" name="toggle_videomode">,
5025 <ref id="videomode" name="videomode">
5031 <sect1>srand<label id="srand"><p>
5035 <tag/Function/Initialize the pseudo random number generator.
5036 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
5037 <tag/Declaration/<tt/void __fastcall__ srand (unsigned seed);/
5038 <tag/Description/The function initializes the random number generator using
5039 the given seed. On program startup, the generator behaves as if <tt/srand/ has
5040 been called with an argument of 1.
5041 <tag/Limits/<itemize>
5042 <item>The function is only available as fastcall function, so it may only
5043 be used in presence of a prototype.
5045 <tag/Availability/ISO 9899
5047 <ref id="_randomize" name="_randomize">,
5048 <ref id="rand" name="rand">
5054 <sect1>strcasecmp<label id="strcasecmp"><p>
5058 <tag/Function/Compare two strings case insensitive.
5059 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5060 <tag/Declaration/<tt/int __fastcall__ strcasecmp (const char* s1, const char* s2);/
5061 <tag/Description/The <tt/strcasecmp/ function compares the two strings passed
5062 as parameters without case sensitivity. It returns a value that is less than
5063 zero if <tt/s1/ is less than <tt/s2/, zero if <tt/s1/ is the same as <tt/s2/,
5064 and a value greater than zero if <tt/s1/ is greater than <tt/s2/.
5065 <tag/Limits/<itemize>
5066 <item>The function is only available as fastcall function, so it may only
5067 be used in presence of a prototype.
5068 <item>The function is not available in strict ANSI mode.
5070 <tag/Availability/cc65
5072 <ref id="strcmp" name="strcmp">,
5073 <ref id="strcoll" name="strcoll">,
5074 <ref id="stricmp" name="stricmp">,
5075 <ref id="strncmp" name="strncmp">,
5076 <ref id="strxfrm" name="strxfrm">
5082 <sect1>strcat<label id="strcat"><p>
5086 <tag/Function/Concatentate two strings.
5087 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5088 <tag/Declaration/<tt/char* __fastcall__ strcat (char* s1, const char* s2);/
5089 <tag/Description/The <tt/strcat/ function appends a copy of the string
5090 pointed to by s2 (including the terminating null byte) to the end of the
5091 string pointed to by s1. The initial byte of s2 overwrites the null byte at
5093 <tag/Limits/<itemize>
5094 <item>The function is only available as fastcall function, so it may only
5095 be used in presence of a prototype.
5096 <item>If copying takes place between objects that overlap, the behaviour
5099 <tag/Availability/ISO 9899
5101 <ref id="strcpy" name="strcpy">,
5102 <ref id="strncat" name="strncat">,
5103 <ref id="strncpy" name="strncpy">
5109 <sect1>strchr<label id="strchr"><p>
5113 <tag/Function/Search for a character in a string.
5114 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5115 <tag/Declaration/<tt/char* __fastcall__ strchr (const char* s, int c);/
5116 <tag/Description/The <tt/strchr/ function locates the first occurrence of <tt/c/
5117 (converted to a char) in the string pointed to by <tt/s/. The terminating null
5118 byte is considered to be part of the string. Upon completion, the function
5119 returns a pointer to the byte, or a null pointer if the byte was not found.
5120 <tag/Limits/<itemize>
5121 <item>The function is only available as fastcall function, so it may only
5122 be used in presence of a prototype.
5124 <tag/Availability/ISO 9899
5126 <ref id="memchr" name="memchr">,
5127 <ref id="strrchr" name="strrchr">
5133 <sect1>strcmp<label id="strcmp"><p>
5137 <tag/Function/Compare two strings.
5138 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5139 <tag/Declaration/<tt/int __fastcall__ strcmp (const char* s1, const char* s2);/
5140 <tag/Description/The <tt/strcmp/ function compares the two strings passed as
5141 parameters. It returns a value that is less than zero if <tt/s1/ is less than
5142 <tt/s2/, zero if <tt/s1/ is the same as <tt/s2/, and a value greater than zero
5143 if <tt/s1/ is greater than <tt/s2/.
5144 <tag/Limits/<itemize>
5145 <item>The function is only available as fastcall function, so it may only
5146 be used in presence of a prototype.
5148 <tag/Availability/ISO 9899
5150 <ref id="strcasecmp" name="strcasecmp">,
5151 <ref id="strcoll" name="strcoll">,
5152 <ref id="stricmp" name="stricmp">,
5153 <ref id="strncmp" name="strncmp">
5154 <ref id="strxfrm" name="strxfrm">
5160 <sect1>strcoll<label id="strcoll"><p>
5164 <tag/Function/Compare two strings.
5165 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5166 <tag/Declaration/<tt/int __fastcall__ strcoll (const char* s1, const char* s2);/
5167 <tag/Description/The <tt/strcoll/ function compares the two strings passed as
5168 parameters, according to the collating sequence set by <tt/<ref id="setlocale"
5169 name="setlocale">/. It returns a value that is less than zero if <tt/s1/ is
5170 less than <tt/s2/, zero if <tt/s1/ is the same as <tt/s2/, and a value greater
5171 than zero if <tt/s1/ is greater than <tt/s2/.
5172 <tag/Limits/<itemize>
5173 <item>The function is only available as fastcall function, so it may only
5174 be used in presence of a prototype.
5176 <tag/Availability/ISO 9899
5178 <ref id="setlocale" name="setlocale">,
5179 <ref id="strcasecmp" name="strcasecmp">,
5180 <ref id="strcmp" name="strcmp">,
5181 <ref id="stricmp" name="stricmp">,
5182 <ref id="strncmp" name="strncmp">,
5183 <ref id="strxfrm" name="strxfrm">
5189 <sect1>strcpy<label id="strcpy"><p>
5193 <tag/Function/Copy a string.
5194 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5195 <tag/Declaration/<tt/char* __fastcall__ strcpy (char* s1, const char* s2);/
5196 <tag/Description/The <tt/strcpy/ function copies the string pointed to by
5197 <tt/s2/ (including the terminating null byte) into the array pointed to by
5198 <tt/s1/. The function will always return <tt/s1/.
5199 <tag/Limits/<itemize>
5200 <item>The function is only available as fastcall function, so it may only
5201 be used in presence of a prototype.
5202 <item>If copying takes place between objects that overlap, the behaviour
5205 <tag/Availability/ISO 9899
5207 <ref id="strcat" name="strcat">,
5208 <ref id="strncat" name="strncat">,
5209 <ref id="strncpy" name="strncpy">
5212 #include <string.h>
5214 static char hello[14];
5216 strcpy (hello, "Hello world!\n");
5222 <sect1>strcspn<label id="strcspn"><p>
5226 <tag/Function/Compute the length of a substring.
5227 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5228 <tag/Declaration/<tt/size_t __fastcall__ strcspn (const char* s, const char* set);/
5229 <tag/Description/The <tt/strcspn/ function computes and returns the length of
5230 the substring pointed to by <tt/s/ which does <em>not</em> consist of
5231 characters contained in the string <tt/set/.
5232 <tag/Limits/<itemize>
5233 <item>The function is only available as fastcall function, so it may only
5234 be used in presence of a prototype.
5236 <tag/Availability/ISO 9899
5238 <ref id="strspn" name="strspn">,
5239 <ref id="strstr" name="strstr">,
5240 <ref id="strtok" name="strtok">
5246 <sect1>strdup<label id="strdup"><p>
5250 <tag/Function/Allocate a copy of a string on the heap.
5251 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5252 <tag/Declaration/<tt/char* __fastcall__ strdup (const char* s);/
5253 <tag/Description/<tt/strdup/ allocates a memory block on the heap, big enough
5254 to hold a copy of <tt/s/ including the terminating zero. If the allocation
5255 fails, <tt/NULL/ is returned, otherwise <tt/s/ is copied into the allocated
5256 memory block, and a pointer to the block is returned.
5257 <tag/Limits/<itemize>
5258 <item>The function is only available as fastcall function, so it may only
5259 be used in presence of a prototype.
5260 <item>It is up to the caller to free the allocated memory block.
5262 <tag/Availability/ISO 9899
5264 <ref id="free" name="free">,
5265 <ref id="malloc" name="malloc">
5271 <sect1>strerror<label id="strerror"><p>
5275 <tag/Function/Return a string describing an error code.
5276 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5277 <tag/Declaration/<tt/char* __fastcall__ strerror (int errcode);/
5278 <tag/Description/The <tt/strerror/ function returns a string describing the
5279 given error code. If an invalid error code is passed, the string "Unknown
5280 error" is returned, and <tt/errno/ is set to <tt/EINVAL/. In all other cases,
5281 <tt/errno/ is left untouched.
5282 <tag/Limits/<itemize>
5283 <item>The function is only available as fastcall function, so it may only
5284 be used in presence of a prototype.
5285 <item>While the return type of the function is a <tt/char*/, the returned
5286 string must not be modified by the caller!
5288 <tag/Availability/ISO 9899
5290 <ref id="_stroserror" name="_stroserror">
5296 <sect1>stricmp<label id="stricmp"><p>
5300 <tag/Function/Compare two strings case insensitive.
5301 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5302 <tag/Declaration/<tt/int __fastcall__ stricmp (const char* s1, const char* s2);/
5303 <tag/Description/The <tt/stricmp/ function compares the two strings passed as
5304 parameters without case sensitivity. It returns a value that is less than zero
5305 if <tt/s1/ is less than <tt/s2/, zero if <tt/s1/ is the same as <tt/s2/, and a
5306 value greater than zero if <tt/s1/ is greater than <tt/s2/.
5307 <tag/Limits/<itemize>
5308 <item>The function is only available as fastcall function, so it may only
5309 be used in presence of a prototype.
5310 <item>The function is not available in strict ANSI mode.
5312 <tag/Availability/cc65
5314 <ref id="strcasecmp" name="strcasecmp">,
5315 <ref id="strcmp" name="strcmp">,
5316 <ref id="strcoll" name="strcoll">,
5317 <ref id="strncmp" name="strncmp">,
5318 <ref id="strxfrm" name="strxfrm">
5324 <sect1>strlen<label id="strlen"><p>
5328 <tag/Function/Return the length of a string.
5329 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5330 <tag/Declaration/<tt/size_t __fastcall__ strlen (const char* s);/
5331 <tag/Description/The <tt/strlen/ function computes the number of bytes in the
5332 string to which s points, not including the terminating null byte.
5333 <tag/Limits/<itemize>
5334 <item>The function is only available as fastcall function, so it may only
5335 be used in presence of a prototype.
5336 <item>When compiling with <tt/-Os/ (inline known standard functions), the
5337 function does not work correctly for strings with more than 255 characters.
5339 <tag/Availability/ISO 9899
5341 <ref id="strcpy" name="strcpy">
5347 <sect1>strlower<label id="strlower"><p>
5351 <tag/Function/Make a string lower case.
5352 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5353 <tag/Declaration/<tt/char* __fastcall__ strlower (char* s);/
5354 <tag/Description/The <tt/strlower/ function will apply the <tt/tolower/
5355 function to each character of a string. The function will always return <tt/s/.
5356 <tag/Limits/<itemize>
5357 <item>The function is only available as fastcall function, so it may only
5358 be used in presence of a prototype.
5359 <item>The function prototype is unavailable when compiling in strict ANSI mode.
5360 <item>An alias name for this function is <tt/strlwr/.
5362 <tag/Availability/cc65
5364 <ref id="strupper" name="strupper">,
5365 <ref id="tolower" name="tolower">
5371 <sect1>strlwr<label id="strlwr"><p>
5378 <sect1>strncat<label id="strncat"><p>
5382 <tag/Function/Concatentate two strings.
5383 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5384 <tag/Declaration/<tt/char* __fastcall__ strncat (char* s1, const char* s2, size_t n);/
5385 <tag/Description/The <tt/strncat/ function appends not more than n characters
5386 of the string pointed to by s2 to the end of the string pointed to by s1. The
5387 terminating null character at the end of s1 is overwritten. A terminating null
5388 character is appended to the result, even if not all of s2 is appended to s1.
5389 <tag/Limits/<itemize>
5390 <item>The function is only available as fastcall function, so it may only
5391 be used in presence of a prototype.
5392 <item>If copying takes place between objects that overlap, the behaviour
5395 <tag/Availability/ISO 9899
5397 <ref id="strcpy" name="strcpy">,
5398 <ref id="strncat" name="strncat">,
5399 <ref id="strncpy" name="strncpy">
5405 <sect1>strncmp<label id="strncmp"><p>
5409 <tag/Function/Compare two strings.
5410 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5411 <tag/Declaration/<tt/int __fastcall__ strncmp (const char* s1, const char* s2, size_t count);/
5412 <tag/Description/The <tt/strncmp/ function compares not more than <tt/count/
5413 characters of the two strings passed as parameters. It returns a value that is
5414 less than zero if the first <tt/count/ characters of <tt/s1/ are less than
5415 <tt/s2/, zero if they are identical, and a value greater than zero they are
5417 <tag/Limits/<itemize>
5418 <item>The function is only available as fastcall function, so it may only
5419 be used in presence of a prototype.
5421 <tag/Availability/ISO 9899
5423 <ref id="strcasecmp" name="strcasecmp">,
5424 <ref id="strcmp" name="strcmp">,
5425 <ref id="strcoll" name="strcoll">,
5426 <ref id="stricmp" name="stricmp">,
5427 <ref id="strxfrm" name="strxfrm">
5433 <sect1>strncpy<label id="strncpy"><p>
5437 <tag/Function/Copy part of a string.
5438 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5439 <tag/Declaration/<tt/char* __fastcall__ strcpy (char* s1, const char* s2, size_t n);/
5440 <tag/Description/The <tt/strncpy/ function copies not more than n bytes from
5441 the array pointed to by <tt/s2/ to the array pointed to by <tt/s1/. If the array
5442 pointed to by <tt/s2/ is a string that is shorter than n bytes, null bytes are
5443 appended to the copy in the array pointed to by <tt/s1/, until <tt/n/ bytes are
5444 written. The function will always return <tt/s1/.
5445 <tag/Limits/<itemize>
5446 <item>The function is only available as fastcall function, so it may only
5447 be used in presence of a prototype. If there is no null byte in the first <tt/n/
5448 bytes of the array pointed to by <tt/s2/, the result is not null-terminated.
5449 <item>If copying takes place between objects that overlap, the behaviour is
5452 <tag/Availability/ISO 9899
5454 <ref id="strcat" name="strcat">,
5455 <ref id="strcpy" name="strcpy">,
5456 <ref id="strncat" name="strncat">
5461 static char hello[6];
5463 strcpy (hello, "Hello world!\n", sizeof (hello) - 1);
5470 <sect1>strrchr<label id="strrchr"><p>
5474 <tag/Function/Search for a character in a string.
5475 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5476 <tag/Declaration/<tt/char* __fastcall__ strrchr (const char* s, int c);/
5477 <tag/Description/The <tt/strrchr/ function locates the last occurrence of <tt/c/
5478 (converted to a char) in the string pointed to by <tt/s/. The terminating null
5479 byte is considered to be part of the string. Upon completion, the function
5480 returns a pointer to the byte, or a null pointer if the byte was not found.
5481 <tag/Limits/<itemize>
5482 <item>The function is only available as fastcall function, so it may only
5483 be used in presence of a prototype.
5485 <tag/Availability/ISO 9899
5487 <ref id="strchr" name="strchr">
5493 <sect1>strspn<label id="strspn"><p>
5497 <tag/Function/Compute the length of a substring.
5498 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5499 <tag/Declaration/<tt/size_t __fastcall__ strspn (const char* s, const char* set);/
5500 <tag/Description/The <tt/strspn/ function computes and returns the length of
5501 the substring pointed to by <tt/s/ which does consist only of characters
5502 contained in the string <tt/set/.
5503 <tag/Limits/<itemize>
5504 <item>The function is only available as fastcall function, so it may only
5505 be used in presence of a prototype.
5507 <tag/Availability/ISO 9899
5509 <ref id="strcspn" name="strcspn">,
5510 <ref id="strstr" name="strstr">
5516 <sect1>strstr<label id="strstr"><p>
5520 <tag/Function/Find a substring.
5521 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5522 <tag/Declaration/<tt/char* __fastcall__ strstr (const char* str, const char* substr);/
5523 <tag/Description/<tt/strstr/ searches for the first occurance of the string
5524 <tt/substr/ within <tt/str/. If found, it returns a pointer to the copy,
5525 otherwise it returns <tt/NULL/.
5526 <tag/Limits/<itemize>
5527 <item>The function is only available as fastcall function, so it may only
5528 be used in presence of a prototype.
5530 <tag/Availability/ISO 9899
5532 <ref id="strcspn" name="strcspn">,
5533 <ref id="strspn" name="strspn">
5539 <sect1>strtok<label id="strtok"><p>
5543 <tag/Function/Break a string into tokens.
5544 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5545 <tag/Declaration/<tt/char* __fastcall__ strtok (char* s1, const char* s2);/
5546 <tag/Description/<tt/strtok/ will break the string s1 into a sequence of
5547 tokens, which are delimited by characters from the string s2. The first call
5548 to <tt/strtok/ will return a pointer to the first token in the string s1.
5549 Following calls must pass a <tt/NULL/ pointer as s1 in order to get the next
5550 token in the string. Different sets of delimiters may be used for the
5551 subsequent calls to <tt/strtok/.
5552 <tag/Limits/<itemize>
5553 <item>The function is only available as fastcall function, so it may only
5554 be used in presence of a prototype.
5555 <item><tt/strtok/ will modify the string s1.
5557 <tag/Availability/ISO 9899
5559 <ref id="strcspn" name="strcspn">,
5560 <!-- <ref id="strpbrk" name="strpbrk"> -->
5566 <sect1>strxfrm<label id="strxfrm"><p>
5570 <tag/Function/Transform a string.
5571 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5572 <tag/Declaration/<tt/size_t __fastcall__ strxfrm (char* s1, const char* s2, size_t n);/
5573 <tag/Description/The <tt/strxfrm/ function transforms the string pointed to by
5574 s2 and places the resulting string into the string pointed to by s1. The
5575 transformation is such that if the <tt/strcmp/ function is applied to two
5576 transformed strings, it returns a value greater than, equal to, or less than
5577 zero, corresponding to the result of the <tt/strcoll/ function applied to the
5578 same two original strings. No more than n characters are placed into the
5579 resulting array pointed to by s1, including the terminating null character.
5580 <tag/Limits/<itemize>
5581 <item><tt/s1/ and <tt/s2/ must not point to the same memory area, otherwise
5582 the behaviour is undefined.
5583 <item>If <tt/n/ is zero, <tt/s1/ may be a NULL pointer.
5584 <item>The function is only available as fastcall function, so it may only
5585 be used in presence of a prototype.
5586 <item>Since cc65 doesn't support different charcter sets, <tt/strxfrm/ will
5587 just copy s2 to s1 using <tt><ref id="strncpy" name="strncpy"></tt>.
5589 <tag/Availability/ISO 9899
5591 <ref id="strcmp" name="strcmp">,
5592 <ref id="strcoll" name="strcoll">,
5593 <ref id="strncpy" name="strncpy">
5599 <sect1>strupper<label id="strupper"><p>
5603 <tag/Function/Make a string upper case.
5604 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5605 <tag/Declaration/<tt/char* __fastcall__ strupper (char* s);/
5606 <tag/Description/The <tt/strupper/ function will apply the <tt/toupper/
5607 function to each character of a string. The function will always return <tt/s/.
5608 <tag/Limits/<itemize>
5609 <item>The function is only available as fastcall function, so it may only
5610 be used in presence of a prototype.
5611 <item>The function prototype is unavailable when compiling in strict ANSI mode.
5612 <item>An alias name for this function is <tt/strupr/.
5614 <tag/Availability/cc65
5616 <ref id="strlower" name="strlower">
5617 <ref id="toupper" name="toupper">
5623 <sect1>strupr<label id="strupr"><p>
5630 <sect1>telldir<label id="telldir"><p>
5634 <tag/Function/Return the current position of a directory stream.
5635 <tag/Header/<tt/<ref id="dirent.h" name="dirent.h">/
5636 <tag/Declaration/<tt/long __fastcall__ telldir (DIR* dir);/
5637 <tag/Description/<tt/telldir/ returns the current position of a directory
5638 stream. The return value may be used in subsequent calls to
5639 <tt/<ref id="seekdir" name="seekdir">/.
5640 <tag/Limits/<itemize>
5641 <item>The function is only available as fastcall function, so it may only
5642 be used in presence of a prototype.
5644 <tag/Availability/POSIX 1003.1
5646 <ref id="seekdir" name="seekdir">,
5647 <ref id="telldir" name="telldir">
5653 <sect1>textcolor<label id="textcolor"><p>
5657 <tag/Function/Set the text color.
5658 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
5659 <tag/Declaration/<tt/unsigned char __fastcall__ textcolor (unsigned char color);/
5660 <tag/Description/The function will set a new text color. It returns the old
5661 (current) text color. Text output using any <tt/conio.h/ function will use
5662 the color set by this function.
5663 <tag/Limits/<itemize>
5664 <item>Text colors are system dependent. The function may have no effect
5665 on systems where the text color cannot be changed.
5666 <item>The function is only available as fastcall function, so it may only
5667 be used in presence of a prototype.
5669 <tag/Availability/cc65
5671 <ref id="bgcolor" name="bgcolor">,
5672 <ref id="bordercolor" name="bordercolor">
5678 <sect1>tgi_arc<label id="tgi_arc"><p>
5682 <tag/Function/Draw an elliptic arc in the current color.
5683 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5684 <tag/Declaration/<tt/void __fastcall__ tgi_arc (int x, int y,
5685 unsigned char rx, unsigned char ry, unsigned sa, unsigned ea);/
5686 <tag/Description/The function draws an elliptic arc with center at x/y and
5687 radii rx/ry using the current drawing color. The arc covers the angle
5688 between sa and ea (startangle and endangle), which must be in the range
5690 <tag/Limits/<itemize>
5691 <item>The function is only available as fastcall function, so it may only
5692 be used in presence of a prototype.
5693 <item>The function behaves unexpectedly or may crash if the angles are out
5696 <tag/Availability/cc65
5698 <ref id="tgi_bar" name="tgi_bar">,
5699 <ref id="tgi_circle" name="tgi_circle">,
5700 <ref id="tgi_ellipse" name="tgi_ellipse">,
5701 <ref id="tgi_pieslice" name="tgi_pieslice">,
5702 <ref id="tgi_setcolor" name="tgi_setcolor">
5704 /* Draw the upper half of an ellipse */
5705 tgi_setcolor(TGI_COLOR_BLUE);
5706 tgi_arc (50, 50, 40, 20, 0, 180);
5712 <sect1>tgi_bar<label id="tgi_bar"><p>
5716 <tag/Function/The function fills a rectangle on the drawpage with the current
5718 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5719 <tag/Declaration/<tt/void __fastcall__ tgi_bar (int x1, int y1, int x2, int y2);/
5720 <tag/Description/The function fills a rectangle on the drawpage with the current
5722 <tag/Limits/<itemize>
5723 <item>The function is only available as fastcall function, so it may only
5724 be used in presence of a prototype.
5726 <tag/Availability/cc65
5727 <tag/See also/Other tgi function
5729 tgi_setcolor(TGI_COLOR_GREEN);
5730 tgi_bar(10, 10, 100, 60);
5736 <sect1>tgi_circle<label id="tgi_circle"><p>
5740 <tag/Function/The function draws a circle in the current color.
5741 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5742 <tag/Declaration/<tt/void __fastcall__ tgi_circle (int x, int y, unsigned char radius);/
5743 <tag/Description/The function draws a circle in the current color.
5744 <tag/Limits/<itemize>
5745 <item>The function is only available as fastcall function, so it may only
5746 be used in presence of a prototype.
5748 <tag/Availability/cc65
5750 <ref id="tgi_arc" name="tgi_arc">,
5751 <ref id="tgi_bar" name="tgi_bar">,
5752 <ref id="tgi_ellipse" name="tgi_ellipse">,
5753 <ref id="tgi_pieslice" name="tgi_pieslice">,
5754 <ref id="tgi_setcolor" name="tgi_setcolor">
5756 tgi_setcolor(TGI_COLOR_BLACK);
5757 tgi_circle(50, 40, 40);
5763 <sect1>tgi_clear<label id="tgi_clear"><p>
5767 <tag/Function/Clear the drawpage
5768 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5769 <tag/Declaration/<tt/void tgi_clear (void);/
5770 <tag/Description/Clear the drawpage
5771 <tag/Availability/cc65
5772 <tag/See also/Other tgi functions
5778 <sect1>tgi_done<label id="tgi_done"><p>
5782 <tag/Function/End graphics mode, switch back to text mode.
5783 Will NOT uninstall or unload the driver!
5784 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5785 <tag/Declaration/<tt/void tgi_done (void);/
5786 <tag/Description/End graphics mode, switch back to text mode.
5787 Will NOT uninstall or unload the driver!
5788 <tag/Availability/cc65
5789 <tag/See also/Other tgi functions
5795 <sect1>tgi_ellipse<label id="tgi_ellipse"><p>
5799 <tag/Function/The function draws an ellipse in the current color.
5800 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5801 <tag/Declaration/<tt/void __fastcall__ tgi_ellipse (int x, int y, unsigned char rx, unsigned char ry);/
5802 <tag/Description/The function draws an ellipse at position x/y with radii
5803 rx and ry, using the current drawing color.
5804 <tag/Limits/<itemize>
5805 <item>The function is only available as fastcall function, so it may only
5806 be used in presence of a prototype.
5808 <tag/Availability/cc65
5810 <ref id="tgi_arc" name="tgi_arc">,
5811 <ref id="tgi_bar" name="tgi_bar">,
5812 <ref id="tgi_circle" name="tgi_circle">,
5813 <ref id="tgi_pieslice" name="tgi_pieslice">,
5814 <ref id="tgi_setcolor" name="tgi_setcolor">
5816 tgi_setcolor(TGI_COLOR_RED);
5817 tgi_ellipse (50, 40, 40, 20);
5823 <sect1>tgi_getaspectratio<label id="tgi_getaspectratio"><p>
5825 <quote> <descrip> <tag/Function/Return the pixel aspect ratio.
5826 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5827 <tag/Declaration/<tt/unsigned tgi_getaspectratio (void);/
5828 <tag/Description/The function returns the pixel aspect ratio for the current
5829 driver and display as an 8.8 fixed point value. It may be used to correct
5830 geometric shapes so they look correct on the display. As an example, a circle
5831 with a radius of 100 pixels may look elliptic on some driver/display
5832 combinations if the aspect ratio is not 1.00.
5833 <tag/Limits/<itemize>
5834 <item>The aspect ratio is encoded in the TGI driver which assumes a "standard"
5835 monitor for the given platform. The aspect ratio may be wrong if another
5837 <item>No TGI function will use the aspect ratio. It is up to the programmer to
5839 <item>The <ref id="tgi_setaspectratio" name="tgi_setaspectratio"> function can
5840 be used to change the aspect ratio for a loaded driver. The value is not reset
5841 by <ref id="tgi_init" name="tgi_init">, so if a driver is linked statically to
5842 an application, switching into and out of graphics mode will not restore the
5843 original aspect ratio.
5845 <tag/Availability/cc65
5847 <ref id="tgi_setaspectratio" name="tgi_setaspectratio">
5853 <sect1>tgi_getcolor<label id="tgi_getcolor"><p>
5857 <tag/Function/Return the current drawing color.
5858 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5859 <tag/Declaration/<tt/unsigned char tgi_getcolor (void);/
5860 <tag/Description/The actual color is an index to a palette. During tgi_init
5861 you will get a default palette. The number of colors depend on the platform.
5862 All platforms recognize at least TGI_COLOR_BLACK and TGI_COLOR_WHITE. But some
5863 platforms have many more predefined colors. If you paint using TGI_COLOR_GREEN
5864 and then you change the green of the palette to blue using tgi_setpalette then
5865 after this painting in TGI_COLOR_GREEN will actually be blue.
5866 <tag/Availability/cc65
5867 <tag/See also/Other tgi functions
5869 color = tgi_getcolor();
5875 <sect1>tgi_getcolorcount<label id="tgi_getcolorcount"><p>
5879 <tag/Function/Get the number of available colors.
5880 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5881 <tag/Declaration/<tt/unsigned char tgi_getcolorcount (void);/
5882 <tag/Description/Tgi platforms use indexed color palettes. This function
5883 returns the number of entries we can use in the palette.
5884 <tag/Availability/cc65
5885 <tag/See also/Other tgi functions
5887 if (tgi_getcolorcount() == 2) {
5888 printf("Only monochrome graphics is supported\n");
5895 <sect1>tgi_getdefpalette<label id="tgi_getdefpalette"><p>
5899 <tag/Function/Get the palette installed by default.
5900 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5901 <tag/Declaration/<tt/const unsigned char* tgi_getdefpalette (void);/
5902 <tag/Description/The tgi driver has a default palette that is active at startup.
5903 The named colors TGI_COLOR_BLACK, TGI_COLOR_WHITE, TGI_COLOR_RED... need this
5904 palette to work correctly.
5905 <tag/Availability/cc65
5906 <tag/See also/Other tgi functions
5912 <sect1>tgi_geterror<label id="tgi_geterror"><p>
5916 <tag/Function/Return the error code for the last operation.
5917 This will also clear the error.
5918 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5919 <tag/Declaration/<tt/unsigned char tgi_geterror (void);/
5920 <tag/Description/Return the error code for the last operation.
5921 This will also clear the error.
5922 <tag/Availability/cc65
5923 <tag/See also/Other tgi functions
5929 <sect1>tgi_geterrormsg<label id="tgi_geterrormsg"><p>
5933 <tag/Function/Get an error message describing the error.
5934 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5935 <tag/Declaration/<tt/const char* __fastcall__ tgi_geterrormsg (unsigned char code);/
5936 <tag/Description/Get an error message describing the error.
5937 <tag/Limits/<itemize>
5938 <item>The function is only available as fastcall function, so it may only
5939 be used in presence of a prototype.
5941 <tag/Availability/cc65
5942 <tag/See also/Other tgi functions
5948 <sect1>tgi_getmaxcolor<label id="tgi_getmaxcolor"><p>
5952 <tag/Function/Get the highest index of the palette.
5953 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5954 <tag/Declaration/<tt/unsigned char tgi_getmaxcolor (void);/
5955 <tag/Description/Get the highest index of the palette.
5956 <tag/Availability/cc65
5957 <tag/See also/Other tgi functions
5963 <sect1>tgi_getmaxx<label id="tgi_getmaxx"><p>
5967 <tag/Function/Get the maximum x coordinate that can be used on this screen.
5968 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5969 <tag/Declaration/<tt/unsigned tgi_getmaxx (void);/
5970 <tag/Description/Get the maximum x coordinate that can be used on this screen.
5971 <tag/Availability/cc65
5972 <tag/See also/Other tgi functions
5978 <sect1>tgi_getmaxy<label id="tgi_getmaxy"><p>
5982 <tag/Function/Get the maximum y coordinate that can be used on this screen.
5983 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5984 <tag/Declaration/<tt/unsigned tgi_getmaxy (void);/
5985 <tag/Description/Get the maximum y coordinate that can be used on this screen.
5986 <tag/Availability/cc65
5987 <tag/See also/Other tgi functions
5993 <sect1>tgi_getpagecount<label id="tgi_getpagecount"><p>
5997 <tag/Function/Return the number of screen pages available.
5998 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
5999 <tag/Declaration/<tt/unsigned tgi_getpagecount (void);/
6000 <tag/Description/Return the number of screen pages available.
6001 <tag/Availability/cc65
6003 <ref id="tgi_setdrawpage" name="tgi_setdrawpage">,
6004 <ref id="tgi_setviewpage" name="tgi_setviewpage">
6010 <sect1>tgi_getpalette<label id="tgi_getpalette"><p>
6014 <tag/Function/Get the palette installed.
6015 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6016 <tag/Declaration/<tt/const unsigned char* tgi_getpalette (void);/
6017 <tag/Description/Get the palette installed.
6018 <tag/Availability/cc65
6019 <tag/See also/Other tgi functions
6025 <sect1>tgi_getpixel<label id="tgi_getpixel"><p>
6029 <tag/Function/Get the color of a pixel from the viewpage.
6030 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6031 <tag/Declaration/<tt/unsigned char __fastcall__ tgi_getpixel (int x, int y);/
6032 <tag/Description/Get the color of a pixel from the viewpage.
6033 <tag/Limits/<itemize>
6034 <item>The function is only available as fastcall function, so it may only
6035 be used in presence of a prototype.
6037 <tag/Availability/cc65
6038 <tag/See also/Other tgi functions.
6044 <sect1>tgi_getxres<label id="tgi_getxres"><p>
6048 <tag/Function/Get number of horisontal pixels on the screen.
6049 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6050 <tag/Declaration/<tt/unsigned tgi_getxres (void);/
6051 <tag/Description/Get number of horisontal pixels on the screen.
6052 This is same as tgi_maxx()+1.
6053 <tag/Availability/cc65
6054 <tag/See also/Other tgi functions.
6060 <sect1>tgi_getyres<label id="tgi_getyres"><p>
6064 <tag/Function/Get number of vertical pixels on the screen.
6065 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6066 <tag/Declaration/<tt/unsigned tgi_getyres (void);/
6067 <tag/Description/Get number of vertical pixels on the screen.
6068 This is same as tgi_maxy()+1.
6069 <tag/Availability/cc65
6070 <tag/See also/Other tgi functions.
6076 <sect1>tgi_gotoxy<label id="tgi_gotoxy"><p>
6080 <tag/Function/Set graphics cursor at x, y.
6081 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6082 <tag/Declaration/<tt/void __fastcall__ tgi_gotoxy (int x, int y);/
6083 <tag/Description/Set graphics cursor at x, y.
6084 <tag/Limits/<itemize>
6085 <item>The function is only available as fastcall function, so it may only
6086 be used in presence of a prototype.
6088 <tag/Availability/cc65
6089 <tag/See also/Other tgi functions.
6095 <sect1>tgi_init<label id="tgi_init"><p>
6099 <tag/Function/Initialize the already loaded graphics driver.
6100 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6101 <tag/Declaration/<tt/void tgi_init (void);/
6102 <tag/Description/The tgi_init function will set the default palette to the
6104 <tag/Limits/<itemize>
6105 <item><tt/tgi_init/ will not clear the screen. This allows switching between
6106 text and graphics mode on platforms that have separate memory areas for the
6107 screens. If you want the screen cleared, call <tt/<ref id="tgi_clear"
6108 name="tgi_clear">/ after <tt/tgi_init/.
6110 <tag/Availability/cc65
6111 <tag/See also/Other tgi functions.
6113 extern char lynxtgi[]; //Include the driver statically instead of loading it.
6114 tgi_install(&lynxtgi);
6115 tgi_init(); //Set up the default palette and clear the screen.
6121 <sect1>tgi_install<label id="tgi_install"><p>
6125 <tag/Function/Install an already loaded driver and return an error code.
6126 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6127 <tag/Declaration/<tt/unsigned char __fastcall__ tgi_install (void* driver);/
6128 <tag/Description/The function installs a driver that was already loaded into
6129 memory (or linked statically to the program). It returns an error code
6130 (<tt/TGI_ERR_OK/ in case of success).
6131 <tag/Limits/<itemize>
6132 <item>The function is only available as fastcall function, so it may only be
6133 used in presence of a prototype.
6135 <tag/Availability/cc65
6137 <ref id="tgi_load_driver" name="tgi_load_driver">,
6138 <ref id="tgi_uninstall" name="tgi_uninstall">,
6139 <ref id="tgi_unload" name="tgi_unload">
6141 extern char lynxtgi[]; //Include the driver statically instead of loading it.
6143 tgi_install(&lynxtgi);
6144 tgi_init(); //Set up the default palette and clear the screen.
6150 <sect1>tgi_ioctl<label id="tgi_ioctl"><p>
6154 <tag/Function/Platform dependent code extensions.
6155 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6156 <tag/Declaration/<tt/unsigned __fastcall__ tgi_ioctl (unsigned char code, void* data);/
6157 <tag/Description/Some platforms have extra display hardware that is not
6158 supported by standard tgi functions. You can extend the driver to support
6159 this extra hardware using tgi_ioctl functions.
6160 <tag/Limits/<itemize>
6161 <item>The function is only available as fastcall function, so it may only
6162 be used in presence of a prototype.
6163 <item>These functions are not easily portable to other cc65 platforms.
6165 <tag/Availability/cc65
6166 <tag/See also/Other tgi functions.
6168 #define tgi_sprite(spr) tgi_ioctl(0, (void*)(spr))
6169 #define tgi_flip() tgi_ioctl(1, (void*)0)
6170 #define tgi_setbgcolor(bgcol) tgi_ioctl(2, (void*)(bgcol))
6171 #define tgi_setframerate(rate) tgi_ioctl(3, (void*)(rate))
6172 #define tgi_busy() tgi_ioctl(4, (void*)0)
6173 #define tgi_updatedisplay() tgi_ioctl(4, (void*)1)
6175 tgi_sprite(&background);
6176 tgi_setcolor(TGI_COLOR_BLUE);
6177 tgi_outttextxy(20,40,"Hello World");
6178 tgi_updatedisplay();
6185 <sect1>tgi_line<label id="tgi_line"><p>
6189 <tag/Function/Draw a line in the current drawing color.
6190 The graphics cursor will be set to x2/y2 by this call.
6191 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6192 <tag/Declaration/<tt/void __fastcall__ tgi_line (int x1, int y1, int x2, int y2);/
6193 <tag/Description/Draw a line in the current drawing color.
6194 The graphics cursor will be set to x2/y2 by this call.
6195 <tag/Limits/<itemize>
6196 <item>The function is only available as fastcall function, so it may only
6197 be used in presence of a prototype.
6199 <tag/Availability/cc65
6200 <tag/See also/Other tgi functions.
6206 <sect1>tgi_lineto<label id="tgi_lineto"><p>
6210 <tag/Function/Draw a line in the current drawing color from the graphics
6211 cursor to the new end point. The graphics cursor will be updated to x2/y2.
6212 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6213 <tag/Declaration/<tt/void __fastcall__ tgi_lineto (int x2, int y2);/
6214 <tag/Description/Draw a line in the current drawing color from the graphics
6215 cursor to the new end point. The graphics cursor will be updated to x2/y2.
6216 <tag/Limits/<itemize>
6217 <item>The function is only available as fastcall function, so it may only
6218 be used in presence of a prototype.
6220 <tag/Availability/cc65
6221 <tag/See also/Other tgi functions.
6227 <sect1>tgi_load_driver<label id="tgi_load_driver"><p>
6231 <tag/Function/Load and install the given driver.
6232 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6233 <tag/Declaration/<tt/void __fastcall__ tgi_load_driver (const char *name);/
6234 <tag/Description/Load and install the driver by name.
6235 Will just load the driver and check if loading was successful.
6236 Will not switch to graphics mode.
6237 <tag/Limits/<itemize>
6238 <item>The function is only available as fastcall function, so it may only
6239 be used in presence of a prototype.
6241 <tag/Availability/cc65
6242 <tag/See also/Other tgi functions.
6248 <sect1>tgi_outtext<label id="tgi_outtext"><p>
6252 <tag/Function/Output text at the current graphics cursor position.
6253 The graphics cursor is moved to the end of the text.
6254 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6255 <tag/Declaration/<tt/void __fastcall__ tgi_outtext (const char* s);/
6256 <tag/Description/Output text at the current graphics cursor position.
6257 The graphics cursor is moved to the end of the text.
6258 <tag/Limits/<itemize>
6259 <item>The function is only available as fastcall function, so it may only
6260 be used in presence of a prototype.
6262 <tag/Availability/cc65
6263 <tag/See also/Other tgi functions.
6269 <sect1>tgi_outtextxy<label id="tgi_outtextxy"><p>
6273 <tag/Function/Output text at the given cursor position.
6274 The graphics cursor is moved to the end of the text.
6275 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6276 <tag/Declaration/<tt/void __fastcall__ tgi_outtextxy (int x, int y, const char* s);/
6277 <tag/Description/Output text at the given cursor position.
6278 The graphics cursor is moved to the end of the text.
6279 <tag/Limits/<itemize>
6280 <item>The function is only available as fastcall function, so it may only
6281 be used in presence of a prototype.
6283 <tag/Availability/cc65
6284 <tag/See also/Other tgi functions.
6290 <sect1>tgi_pieslice<label id="tgi_pieslice"><p>
6294 <tag/Function/Draw an elliptic pie slice in the current color.
6295 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6296 <tag/Declaration/<tt/void __fastcall__ tgi_pie slice (int x, int y,
6297 unsigned char rx, unsigned char ry, unsigned sa, unsigned ea);/
6298 <tag/Description/The function draws an elliptic pie slice with center at x/y
6299 and radii rx/ry using the current drawing color. The pie slice covers the angle
6300 between sa and ea (startangle and endangle), which must be in the range
6302 <tag/Limits/<itemize>
6303 <item>The function is only available as fastcall function, so it may only
6304 be used in presence of a prototype.
6305 <item>The function behaves unexpectedly or may crash if the angles are out
6308 <tag/Availability/cc65
6310 <ref id="tgi_bar" name="tgi_arc">,
6311 <ref id="tgi_bar" name="tgi_bar">,
6312 <ref id="tgi_circle" name="tgi_circle">,
6313 <ref id="tgi_ellipse" name="tgi_ellipse">,
6314 <ref id="tgi_setcolor" name="tgi_setcolor">
6316 /* Draw the closed upper half of an ellipse */
6317 tgi_setcolor(TGI_COLOR_BLUE);
6318 tgi_pieslice (50, 50, 40, 20, 0, 180);
6324 <sect1>tgi_setaspectratio<label id="tgi_setaspectratio"><p>
6326 <quote> <descrip> <tag/Function/Set the pixel aspect ratio.
6327 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6328 <tag/Declaration/<tt/void __fastcall__ tgi_setaspectratio (unsigned ratio);/
6329 <tag/Description/The function sets the pixel aspect ratio for the current
6330 driver and display. The argument is an 8.8 fixed point value. The aspect ratio
6331 may be used to correct geometric shapes so they look correct on a given
6332 display. As an example, a circle with a radius of 100 pixels may look elliptic
6333 on some driver/display combinations if the aspect ratio is not 1.00.
6334 <tag/Limits/<itemize>
6335 <item>The aspect ratio is encoded in the TGI driver which assumes a "standard"
6336 monitor for the given platform. The aspect ratio may be wrong if another
6338 <item>No TGI function will use the aspect ratio. It is up to the programmer to
6340 <item>The <tt/tgi_setaspectratio/ function can be used to change the aspect
6341 ratio for a loaded driver. The value is not reset by <ref id="tgi_init"
6342 name="tgi_init">, so if a driver is linked statically to an application,
6343 switching into and out of graphics mode will not restore the original aspect
6346 <tag/Availability/cc65
6348 <ref id="tgi_getaspectratio" name="tgi_getaspectratio">
6354 <sect1>tgi_setcolor<label id="tgi_setcolor"><p>
6358 <tag/Function/Set color to be used in future draw operations.
6359 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6360 <tag/Declaration/<tt/void __fastcall__ tgi_setcolor (unsigned char color);/
6361 <tag/Description/Set color to be used in future draw operations.
6362 <tag/Limits/<itemize>
6363 <item>The function is only available as fastcall function, so it may only
6364 be used in presence of a prototype.
6366 <tag/Availability/cc65
6367 <tag/See also/Other tgi functions.
6369 tgi_setcolor(TGI_COLOR_BLACK);
6371 tgi_setcolor(TGI_COLOR_WHITE);
6372 tgi_bar(10,10,20,20);
6377 <sect1>tgi_setdrawpage<label id="tgi_setdrawpage"><p>
6381 <tag/Function/Set the page for drawing.
6382 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6383 <tag/Declaration/<tt/void __fastcall__ tgi_setdrawpage (unsigned char page);/
6384 <tag/Description/If the drawpage and the viewpage are the same then all drawing
6385 is seen immediately as it is drawn. For double buffered games you can set the
6386 drawpage to a different page than the viewpage. This lets you draw the next
6387 screen in the background and when the screen is ready you display it.
6388 <tag/Limits/<itemize>
6389 <item>The function is only available as fastcall function, so it may only
6390 be used in presence of a prototype.
6392 <tag/Availability/cc65
6393 <tag/See also/Other tgi functions.
6396 tgi_outtextxy(10, 10, "Hello World");
6397 tgi_setviewpage(1); // Show page 1
6399 tgi_outtextxy(10, 10, "Creating next frame");
6401 tgi_setviewpage(0); // Show page 0
6406 <sect1>tgi_setpalette<label id="tgi_setpalette"><p>
6410 <tag/Function/Set the palette (not available with all drivers/hardware).
6411 Palette is a pointer to as many entries as there are colors.
6412 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6413 <tag/Declaration/<tt/void __fastcall__ tgi_setpalette (const unsigned char* palette);/
6414 <tag/Description/Set the palette (not available with all drivers/hardware).
6415 Palette is a pointer to as many entries as there are colors.
6416 <tag/Limits/<itemize>
6417 <item>The function is only available as fastcall function, so it may only
6418 be used in presence of a prototype.
6420 <tag/Availability/cc65
6421 <tag/See also/Other tgi functions.
6426 <sect1>tgi_setpixel<label id="tgi_setpixel"><p>
6430 <tag/Function/Plot a pixel on the drawpage with the current color.
6431 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6432 <tag/Declaration/<tt/void __fastcall__ tgi_setpixel (int x, int y);/
6433 <tag/Description/Plot a pixel on the drawpage with the current color.
6434 <tag/Limits/<itemize>
6435 <item>The function is only available as fastcall function, so it may only
6436 be used in presence of a prototype.
6438 <tag/Availability/cc65
6439 <tag/See also/Other tgi functions.
6444 <sect1>tgi_setviewpage<label id="tgi_setviewpage"><p>
6448 <tag/Function/Set page to be visible on screen.
6449 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6450 <tag/Declaration/<tt/void __fastcall__ tgi_setviewpage (unsigned char page);/
6451 <tag/Description/If the drawpage and the viewpage are the same then all drawing
6452 is seen immediately as it is drawn. For double buffered games you can set the
6453 drawpage to a different page than the viewpage. This lets you draw the next
6454 screen in the background and when the screen is ready you display it.
6455 <tag/Limits/<itemize>
6456 <item>The function is only available as fastcall function, so it may only
6457 be used in presence of a prototype.
6459 <tag/Availability/cc65
6460 <tag/See also/Other tgi functions.
6463 tgi_outtextxy(10, 10, "Hello World");
6464 tgi_setviewpage(1); // Show page 1
6466 tgi_outtextxy(10, 10, "Creating next frame");
6468 tgi_setviewpage(0); // Show page 0
6473 <sect1>tgi_gettextheight<label id="tgi_gettextheight"><p>
6477 <tag/Function/Calculate the height of the text in pixels according to
6478 the current text style.
6479 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6480 <tag/Declaration/<tt/unsigned __fastcall__ tgi_gettextheight (const char* s);/
6481 <tag/Description/Calculate the height of the text in pixels according to
6482 the current text style.
6483 <tag/Limits/<itemize>
6484 <item>The function is only available as fastcall function, so it may only
6485 be used in presence of a prototype.
6487 <tag/Availability/cc65
6488 <tag/See also/Other tgi functions.
6493 <sect1>tgi_settextstyle<label id="tgi_settextstyle"><p>
6497 <tag/Function/Set the style for text output.
6498 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6499 <tag/Declaration/<tt/void __fastcall__ tgi_settextstyle (unsigned char magx, unsigned char magy, unsigned char dir);/
6500 <tag/Description/Set the style for text output.
6501 <tag/Limits/<itemize>
6502 <item>The function is only available as fastcall function, so it may only
6503 be used in presence of a prototype.
6505 <tag/Availability/cc65
6506 <tag/See also/Other tgi functions.
6511 <sect1>tgi_gettextwidth<label id="tgi_gettextwidth"><p>
6515 <tag/Function/Calculate the width of the text in pixels according to the current text style.
6516 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6517 <tag/Declaration/<tt/unsigned __fastcall__ tgi_gettextwidth (const char* s);/
6518 <tag/Function/Calculate the width of the text in pixels according to the current text style.
6519 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6520 <tag/Description/Calculate the width of the text in pixels according to the current text style.
6521 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6522 <tag/Limits/<itemize>
6523 <item>The function is only available as fastcall function, so it may only
6524 be used in presence of a prototype.
6526 <tag/Availability/cc65
6527 <tag/See also/Other tgi functions.
6532 <sect1>tgi_uninstall<label id="tgi_uninstall"><p>
6536 <tag/Function/Uninstall the currently loaded driver but do not unload it.
6537 Will call tgi_done if necessary.
6538 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6539 <tag/Declaration/<tt/void tgi_uninstall (void);/
6540 <tag/Description/Uninstall the currently loaded driver but do not unload it.
6541 Will call tgi_done if necessary.
6542 <tag/Availability/cc65
6543 <tag/See also/Other tgi functions.
6548 <sect1>tgi_unload<label id="tgi_unload"><p>
6552 <tag/Function/Uninstall, then unload the currently loaded driver.
6553 Will call tgi_done if necessary.
6554 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6555 <tag/Declaration/<tt/void tgi_unload (void);/
6556 <tag/Description/Uninstall, then unload the currently loaded driver.
6557 Will call tgi_done if necessary.
6558 <tag/Availability/cc65
6559 <tag/See also/Other tgi functions.
6564 <sect1>time<label id="time"><p>
6568 <tag/Function/Get the time.
6569 <tag/Header/<tt/<ref id="time.h" name="time.h">/
6570 <tag/Declaration/<tt/time_t __fastcall__ time (time_t* t);/
6571 <tag/Description/The function returns the time since the 1970-01-01 00:00:00
6572 measured in seconds. If the pointer <tt/t/ is not <tt/NULL/, the function
6573 result will also be stored there. If no time is available, <tt/(time_t)-1/ is
6574 returned and <tt/errno/ is set to <tt/ENOSYS/.
6575 <tag/Limits/<itemize>
6576 <item>The function is only available as fastcall function, so it may
6577 only be used in presence of a prototype.
6578 <item>Many platforms supported by cc65 do not have a realtime clock, so the
6579 returned value may not be valid.
6581 <tag/Availability/ISO 9899
6583 <ref id="clock" name="clock">
6589 <sect1>toggle_videomode<label id="toggle_videomode"><p>
6593 <tag/Function/Toggle between 40 and 80 column mode.
6594 <tag/Header/<tt/<ref id="c128.h" name="c128.h">/
6595 <tag/Declaration/<tt/void toggle_videomode (void);/
6596 <tag/Description/Toggle between 40 and 80 column mode. The settings for the
6597 old mode (cursor position, color and so on) are saved and restored together
6599 <tag/Limits/<itemize>
6600 <item>The function is specific to the C128.
6601 <item>This function is deprecated. Please use <ref id="videomode"
6602 name="videomode"> instead!
6604 <tag/Availability/C128
6606 <ref id="fast" name="fast">,
6607 <ref id="slow" name="slow">,
6608 <ref id="videomode" name="videomode">
6614 <sect1>tolower<label id="tolower"><p>
6618 <tag/Function/Convert a character into its lower case representation.
6619 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
6620 <tag/Declaration/<tt/int __fastcall__ tolower (int c);/
6621 <tag/Description/The function returns the given character converted to lower
6622 case. If the given character is not a letter, it is returned unchanged.
6623 <tag/Limits/<itemize>
6624 <item>The function is only available as fastcall function, so it may
6625 only be used in presence of a prototype.
6627 <tag/Availability/ISO 9899
6629 <ref id="islower" name="islower">,
6630 <ref id="isupper" name="isupper">,
6631 <ref id="toupper" name="toupper">
6637 <sect1>toupper<label id="toupper"><p>
6641 <tag/Function/Convert a character into its upper case representation.
6642 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
6643 <tag/Declaration/<tt/int __fastcall__ toupper (int c);/
6644 <tag/Description/The function returns the given character converted to upper
6645 case. If the given character is not a letter, it is returned unchanged.
6646 <tag/Limits/<itemize>
6647 <item>The function is only available as fastcall function, so it may
6648 only be used in presence of a prototype.
6650 <tag/Availability/ISO 9899
6652 <ref id="islower" name="islower">,
6653 <ref id="isupper" name="isupper">,
6654 <ref id="tolower" name="tolower">
6660 <sect1>ultoa<label id="ultoa"><p>
6664 <tag/Function/Convert an unsigned long integer into a string.
6665 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
6666 <tag/Declaration/<tt/char* __fastcall__ ultoa (unsigned long val, char* buf, int radix);/
6667 <tag/Description/<tt/itoa/ converts the unsigned long integer <tt/val/ into a
6668 string using <tt/radix/ as the base.
6669 <tag/Limits/<itemize>
6670 <item>There are no provisions to prevent a buffer overflow.
6671 <item>The function is non standard, so it is not available in strict ANSI mode.
6672 You should probably use <tt/sprintf/ instead.
6673 <item>The function is only available as fastcall function, so it may only be
6674 used in presence of a prototype.
6676 <tag/Availability/cc65
6678 <ref id="atoi" name="atoi">,
6679 <ref id="atol" name="atol">,
6680 <ref id="itoa" name="itoa">,
6681 <ref id="ltoa" name="ltoa">,
6682 <ref id="utoa" name="utoa">
6688 <sect1>unlink<label id="unlink"><p>
6692 <tag/Function/Delete a file.
6693 <tag/Header/<tt/<ref id="unistd.h" name="unistd.h">/
6694 <tag/Declaration/<tt/int __fastcall__ unlink (const char* name);/
6695 <tag/Description/<tt/unlink/ deletes the file with the given name. On success,
6696 zero is returned. On error, -1 is returned and <tt/errno/ is set to an error
6697 code describing the reason for the failure.
6700 <item>The use of this function is discouraged. Please use <tt/<ref id="remove"
6701 name="remove">/ instead, which is a native ANSI C function and does the same.
6702 <item>This function is not available on all cc65 targets (depends on the
6703 availability of file I/O).
6704 <item>The function is only available as fastcall function, so it may only
6705 be used in presence of a prototype.
6706 <item>Instead of <tt/unlink/, <tt/<ref id="remove" name="remove">/ should be
6707 used, which has the same semantics, but is more portable, because it conforms
6708 to the ISO C standard.
6710 <tag/Availability/POSIX 1003.1
6712 <ref id="remove" name="remove">
6715 #include <stdio.h>
6716 #include <unistd.h>
6718 #define FILENAME "helloworld"
6720 if (unlink (FILENAME) == 0) {
6721 printf ("We deleted %s successfully\n", FILENAME);
6723 printf ("There was a problem deleting %s\n", FILENAME);
6730 <sect1>utoa<label id="utoa"><p>
6734 <tag/Function/Convert an unsigned integer into a string.
6735 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
6736 <tag/Declaration/<tt/char* __fastcall__ utoa (unsigned val, char* buf, int radix);/
6737 <tag/Description/<tt/itoa/ converts the unsigned integer <tt/val/ into a string
6738 using <tt/radix/ as the base.
6739 <tag/Limits/<itemize>
6740 <item>There are no provisions to prevent a buffer overflow.
6741 <item>The function is non standard, so it is not available in strict ANSI mode.
6742 You should probably use <tt/sprintf/ instead.
6743 <item>The function is only available as fastcall function, so it may only be
6744 used in presence of a prototype.
6746 <tag/Availability/cc65
6748 <ref id="atoi" name="atoi">,
6749 <ref id="atol" name="atol">,
6750 <ref id="itoa" name="itoa">,
6751 <ref id="ltoa" name="ltoa">,
6752 <ref id="ultoa" name="ultoa">
6758 <sect1>vcprintf<label id="vcprintf"><p>
6762 <tag/Function/Formatted output to the console.
6763 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
6764 <tag/Declaration/<tt/int __fastcall__ vcprintf (const char* format, va_list ap);/
6765 <tag/Description/The arguments specified as a <tt/va_list/ are converted to
6766 text where necessary and formatted according to the format string given. The
6767 resulting string is output to the console. <tt/vcprintf/ supports the same
6768 format specifiers as <tt/vprintf/. <!-- <tt/<ref id="vprintf" name="vprintf">/. -->
6769 <tag/Limits/<itemize>
6770 <item>Like all other <tt/conio/ output functions, <tt/vcprintf/ distinguishes
6771 between <tt/\r/ and <tt/\n/.
6772 <item>The function is only available as fastcall function, so it may only be
6773 used in presence of a prototype.
6775 <tag/Availability/cc65
6777 <ref id="cprintf" name="cprintf">,
6778 <ref id="cputc" name="cputc">,
6779 <ref id="cputcxy" name="cputcxy">,
6780 <ref id="cputs" name="cputs">,
6781 <ref id="cputsxy" name="cputsxy">
6787 <sect1>videomode<label id="videomode"><p>
6791 <tag/Function/Switch to either 40 or 80 column mode.
6792 <tag/Header/<tt/<ref id="apple2enh.h" name="apple2enh.h">,
6793 <ref id="c128.h" name="c128.h">/
6794 <tag/Declaration/<tt/unsigned __fastcall__ videomode (unsigned Mode);/
6795 <tag/Description/Switch to 40 or 80 column mode depending on the argument. If
6796 the requested mode is already active, nothing happens. The old mode is returned
6798 <tag/Limits/<itemize>
6799 <item>The function is specific to the C128 and enhanced Apple //e.
6800 <item>This function replaces <ref id="toggle_videomode"
6801 name="toggle_videomode">.
6802 <item>The function is only available as fastcall function, so it may only be
6803 used in presence of a prototype.
6805 <tag/Availability/C128 and enhanced Apple //e
6807 <ref id="fast" name="fast">,
6808 <ref id="slow" name="slow">,
6809 <ref id="toggle_videomode" name="toggle_videomode">
6815 <sect1>wherex<label id="wherex"><p>
6819 <tag/Function/Return the current X position of the text mode cursor.
6820 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
6821 <tag/Declaration/<tt/unsigned char wherex (void);/
6822 <tag/Description/The function returns the current X position of the text mode
6823 cursor. Zero is returned for the leftmost screen position.
6824 <tag/Availability/cc65
6826 <ref id="gotox" name="gotox">,
6827 <ref id="gotoy" name="gotoy">,
6828 <ref id="gotoxy" name="gotoxy">,
6829 <ref id="wherey" name="wherey">
6835 <sect1>wherey<label id="wherey"><p>
6839 <tag/Function/Return the current Y position of the text mode cursor.
6840 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
6841 <tag/Declaration/<tt/unsigned char wherey (void);/
6842 <tag/Description/The function returns the current Y position of the text mode
6843 cursor. Zero is returned for the uppermost screen position.
6844 <tag/Availability/cc65
6846 <ref id="gotox" name="gotox">,
6847 <ref id="gotoy" name="gotoy">,
6848 <ref id="gotoxy" name="gotoxy">,
6849 <ref id="wherex" name="wherex">