1 <!doctype linuxdoc system> <!-- -*- text-mode -*- -->
4 <title>cc65 function reference
5 <author><url url="mailto:uz@cc65.org" name="Ullrich von Bassewitz">
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 <url
27 url="library.html" name="cc65 Library Overview">.
29 <em/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.
42 <tag/Notes/Notes on 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="_is_cmdline_dos" name="_is_cmdline_dos">
102 <!-- <item><ref id="_rest_vecs" name="_rest_vecs"> -->
103 <!-- <item><ref id="_save_vecs" name="_save_vecs"> -->
104 <!-- <item><ref id="_scroll" name="_scroll"> -->
105 <!-- <item><ref id="_setcolor" name="_setcolor"> -->
106 <!-- <item><ref id="_setcolor_low" name="_setcolor_low"> -->
107 <item><ref id="get_ostype" name="get_ostype">
108 <!-- <item><ref id="get_tv" name="get_tv"> -->
114 <sect1><tt/atmos.h/<label id="atmos.h"><p>
117 <item><ref id="atmos_load" name="atmos_load">
118 <item><ref id="atmos_save" name="atmos_save">
119 <!-- <item><ref id="atmos_explode" name="atmos_explode"> -->
120 <!-- <item><ref id="atmos_ping" name="atmos_ping"> -->
121 <!-- <item><ref id="atmos_shoot" name="atmos_shoot"> -->
122 <!-- <item><ref id="atmos_tick" name="atmos_tick"> -->
123 <!-- <item><ref id="atmos_tock" name="atmos_tock"> -->
124 <!-- <item><ref id="atmos_zap" name="atmos_zap"> -->
130 <sect1><tt/c128.h/<label id="c128.h"><p>
133 <item><ref id="c64mode" name="c64mode">
134 <item><ref id="fast" name="fast">
135 <item><ref id="slow" name="slow">
136 <item><ref id="toggle_videomode" name="toggle_videomode">
137 <item><ref id="videomode" name="videomode">
141 <sect1><tt/c16.h/<label id="c16.h"><p>
146 <sect1><tt/c64.h/<label id="c64.h"><p>
149 <item><ref id="get_ostype" name="get_ostype">
153 <sect1><tt/cbm.h/<label id="cbm.h"><p>
156 <item><ref id="cbm_k_acptr" name="cbm_k_acptr">
157 <item><ref id="cbm_k_basin" name="cbm_k_basin">
158 <item><ref id="cbm_k_bsout" name="cbm_k_bsout">
159 <item><ref id="cbm_k_chkin" name="cbm_k_chkin">
160 <item><ref id="cbm_k_ciout" name="cbm_k_ciout">
161 <item><ref id="cbm_k_ckout" name="cbm_k_ckout">
162 <item><ref id="cbm_k_clall" name="cbm_k_clall">
163 <item><ref id="cbm_k_close" name="cbm_k_close">
164 <item><ref id="cbm_k_clrch" name="cbm_k_clrch">
165 <item><ref id="cbm_k_getin" name="cbm_k_getin">
166 <item><ref id="cbm_k_iobase" name="cbm_k_iobase">
167 <item><ref id="cbm_k_listen" name="cbm_k_listen">
168 <item><ref id="cbm_k_load" name="cbm_k_load">
169 <item><ref id="cbm_k_open" name="cbm_k_open">
170 <item><ref id="cbm_k_readst" name="cbm_k_readst">
171 <item><ref id="cbm_k_save" name="cbm_k_save">
172 <item><ref id="cbm_k_setlfs" name="cbm_k_setlfs">
173 <item><ref id="cbm_k_setnam" name="cbm_k_setnam">
174 <item><ref id="cbm_k_unlsn" name="cbm_k_unlsn">
175 <!-- <item><ref id="cbm_load" name="cbm_load"> -->
176 <!-- <item><ref id="cbm_open" name="cbm_open"> -->
177 <!-- <item><ref id="cbm_opendir" name="cbm_opendir"> -->
178 <!-- <item><ref id="cbm_read" name="cbm_read"> -->
179 <!-- <item><ref id="cbm_readdir" name="cbm_readdir"> -->
180 <!-- <item><ref id="cbm_save" name="cbm_save"> -->
181 <!-- <item><ref id="cbm_write" name="cbm_write"> -->
182 <!-- <item><ref id="get_tv" name="get_tv"> -->
188 <sect1><tt/cbm510.h/<label id="cbm510.h"><p>
191 <item><ref id="peekbsys" name="peekbsys">
192 <item><ref id="peekwsys" name="peekwsys">
193 <item><ref id="pokebsys" name="pokebsys">
194 <item><ref id="pokewsys" name="pokewsys">
198 <sect1><tt/cbm610.h/<label id="cbm610.h"><p>
201 <item><ref id="peekbsys" name="peekbsys">
202 <item><ref id="peekwsys" name="peekwsys">
203 <item><ref id="pokebsys" name="pokebsys">
204 <item><ref id="pokewsys" name="pokewsys">
208 <sect1><tt/cc65.h/<label id="cc65.h"><p>
211 <!-- <item><ref id="cc65_cos" name="cc65_cos"> -->
212 <!-- <item><ref id="cc65_idiv32by16r16" name="cc65_idiv32by16r16"> -->
213 <!-- <item><ref id="cc65_imul16x16r32" name="cc65_imul16x16r32"> -->
214 <!-- <item><ref id="cc65_imul8x8r16" name="cc65_imul8x8r16"> -->
215 <!-- <item><ref id="cc65_sin" name="cc65_sin"> -->
216 <!-- <item><ref id="cc65_udiv32by16r16" name="cc65_udiv32by16r16"> -->
217 <!-- <item><ref id="cc65_umul16x16r32" name="cc65_umul16x16r32"> -->
218 <!-- <item><ref id="cc65_umul16x8r32" name="cc65_umul16x8r32"> -->
219 <!-- <item><ref id="cc65_umul8x8r16" name="cc65_umul8x8r16"> -->
225 <sect1><tt/conio.h/<label id="conio.h"><p>
228 <item><ref id="bgcolor" name="bgcolor">
229 <item><ref id="bordercolor" name="bordercolor">
230 <item><ref id="cclear" name="cclear">
231 <item><ref id="cclearxy" name="cclearxy">
232 <item><ref id="cgetc" name="cgetc">
233 <item><ref id="chline" name="chline">
234 <item><ref id="chlinexy" name="chlinexy">
235 <item><ref id="clrscr" name="clrscr">
236 <item><ref id="cprintf" name="cprintf">
237 <item><ref id="cputc" name="cputc">
238 <item><ref id="cputcxy" name="cputcxy">
239 <item><ref id="cputs" name="cputs">
240 <item><ref id="cputsxy" name="cputsxy">
241 <item><ref id="cursor" name="cursor">
242 <item><ref id="cvline" name="cvline">
243 <item><ref id="cvlinexy" name="cvlinexy">
244 <item><ref id="gotox" name="gotox">
245 <item><ref id="gotoxy" name="gotoxy">
246 <item><ref id="gotoy" name="gotoy">
247 <item><ref id="kbhit" name="kbhit">
248 <item><ref id="revers" name="revers">
249 <item><ref id="screensize" name="screensize">
250 <item><ref id="textcolor" name="textcolor">
251 <item><ref id="vcprintf" name="vcprintf">
252 <item><ref id="wherex" name="wherex">
253 <item><ref id="wherey" name="wherey">
257 <sect1><tt/ctype.h/<label id="ctype.h"><p>
260 <item><ref id="isalnum" name="isalnum">
261 <item><ref id="isalpha" name="isalpha">
262 <item><ref id="isascii" name="isascii">
263 <item><ref id="isblank" name="isblank">
264 <item><ref id="iscntrl" name="iscntrl">
265 <item><ref id="isdigit" name="isdigit">
266 <item><ref id="isgraph" name="isgraph">
267 <item><ref id="islower" name="islower">
268 <item><ref id="isprint" name="isprint">
269 <item><ref id="ispunct" name="ispunct">
270 <item><ref id="isspace" name="isspace">
271 <item><ref id="isupper" name="isupper">
272 <item><ref id="isxdigit" name="isxdigit">
273 <item><ref id="tolower" name="tolower">
274 <item><ref id="toupper" name="toupper">
278 <sect1><tt/dbg.h/<label id="dbg.h"><p>
281 <!-- <item><ref id="DbgInit" name="DbgInit"> -->
287 <sect1><tt/dio.h/<label id="dio.h"><p>
289 <url url="dio.html" name="Low-level disk I/O API">.
292 <sect1><tt/dirent.h/<label id="dirent.h"><p>
295 <item><ref id="_DE_ISDIR" name="_DE_ISDIR">
296 <item><ref id="_DE_ISLBL" name="_DE_ISLBL">
297 <item><ref id="_DE_ISLNK" name="_DE_ISLNK">
298 <item><ref id="_DE_ISREG" name="_DE_ISREG">
299 <item><ref id="closedir" name="closedir">
300 <item><ref id="opendir" name="opendir">
301 <item><ref id="readdir" name="readdir">
302 <item><ref id="rewinddir" name="rewinddir">
303 <item><ref id="seekdir" name="seekdir">
304 <item><ref id="telldir" name="telldir">
310 <sect1><tt/em.h/<label id="em.h"><p>
313 <item><ref id="em_commit" name="em_commit">
314 <item><ref id="em_copyfrom" name="em_copyfrom">
315 <item><ref id="em_copyto" name="em_copyto">
316 <item><ref id="em_install" name="em_install">
317 <item><ref id="em_load_driver" name="em_load_driver">
318 <item><ref id="em_map" name="em_map">
319 <item><ref id="em_pagecount" name="em_pagecount">
320 <item><ref id="em_uninstall" name="em_uninstall">
321 <item><ref id="em_unload" name="em_unload">
322 <item><ref id="em_use" name="em_use">
326 <sect1><tt/errno.h/<label id="errno.h"><p>
329 <!-- <item><ref id="_directerrno" name="_directerrno"> -->
330 <!-- <item><ref id="_mappederrno" name="_mappederrno"> -->
331 <!-- <item><ref id="_osmaperrno" name="_osmaperrno"> -->
332 <!-- <item><ref id="_seterrno" name="_seterrno"> -->
338 <sect1><tt/fcntl.h/<label id="fcntl.h"><p>
341 <item><ref id="close" name="close">
342 <item><ref id="creat" name="creat">
343 <item><ref id="open" name="open">
347 <sect1><tt/geos.h/<label id="geos.h"><p>
352 <sect1><tt/joystick.h/<label id="joystick.h"><p>
355 <item><ref id="joy_count" name="joy_count">
356 <item><ref id="joy_install" name="joy_install">
357 <item><ref id="joy_load_driver" name="joy_load_driver">
358 <item><ref id="joy_read" name="joy_read">
359 <item><ref id="joy_uninstall" name="joy_uninstall">
360 <item><ref id="joy_unload" name="joy_unload">
364 <sect1><tt/locale.h/<label id="locale.h"><p>
367 <item><ref id="localeconv" name="localeconv">
368 <item><ref id="setlocale" name="setlocale">
372 <sect1><tt/lynx.h/<label id="lynx.h"><p>
375 <!-- <item><ref id="lynx_eeprom_erase" name="lynx_eeprom_erase"> -->
376 <!-- <item><ref id="lynx_eeprom_read" name="lynx_eeprom_read"> -->
377 <!-- <item><ref id="lynx_eeprom_write" name="lynx_eeprom_write"> -->
378 <!-- <item><ref id="lynx_eeread" name="lynx_eeread"> -->
379 <!-- <item><ref id="lynx_eewrite" name="lynx_eewrite"> -->
380 <!-- <item><ref id="lynx_exec" name="lynx_exec"> -->
381 <!-- <item><ref id="lynx_load" name="lynx_load"> -->
387 <sect1><tt/modload.h/<label id="modload.h"><p>
390 <item><ref id="mod_load" name="mod_load">
391 <item><ref id="mod_free" name="mod_free">
395 <sect1><tt/mouse.h/<label id="mouse.h"><p>
398 <item><ref id="mouse_buttons" name="mouse_buttons">
399 <item><ref id="mouse_getbox" name="mouse_getbox">
400 <item><ref id="mouse_geterrormsg" name="mouse_geterrormsg">
401 <item><ref id="mouse_hide" name="mouse_hide">
402 <item><ref id="mouse_info" name="mouse_info">
403 <item><ref id="mouse_install" name="mouse_install">
404 <item><ref id="mouse_ioctl" name="mouse_ioctl">
405 <item><ref id="mouse_load_driver" name="mouse_load_driver">
406 <item><ref id="mouse_move" name="mouse_move">
407 <item><ref id="mouse_pos" name="mouse_pos">
408 <item><ref id="mouse_setbox" name="mouse_setbox">
409 <item><ref id="mouse_show" name="mouse_show">
410 <item><ref id="mouse_uninstall" name="mouse_uninstall">
411 <item><ref id="mouse_unload" name="mouse_unload">
415 <sect1><tt/nes.h/<label id="nes.h"><p>
418 <!-- <item><ref id="get_tv" name="get_tv"> -->
419 <!-- <item><ref id="waitvblank" name="waitvblank"> -->
425 <sect1><tt/o65.h/<label id="o65.h"><p>
427 The <tt/o65.h/ header file contains structure and constant definitions that
428 may be used when dealing with files in <url
429 url="http://www.6502.org/users/andre/o65/fileformat.html" name="the o65 format">.
430 It does not declare any functions.
433 <sect1><tt/peekpoke.h/<label id="peekpoke.h"><p>
436 <item><ref id="PEEK" name="PEEK">
437 <item><ref id="PEEKW" name="PEEKW">
438 <item><ref id="POKE" name="POKE">
439 <item><ref id="POKEW" name="POKEW">
443 <sect1><tt/pet.h/<label id="pet.h"><p>
448 <sect1><tt/plus4.h/<label id="plus4.h"><p>
453 <sect1><tt/serial.h/<label id="serial.h"><p>
455 The <tt/serial.h/ header file contains definitions for initializing serial
459 <item><ref id="ser_close" name="ser_close">
460 <item><ref id="ser_get" name="ser_get">
461 <item><ref id="ser_install" name="ser_install">
462 <item><ref id="ser_ioctl" name="ser_ioctl">
463 <item><ref id="ser_load_driver" name="ser_load_driver">
464 <item><ref id="ser_open" name="ser_open">
465 <item><ref id="ser_put" name="ser_put">
466 <item><ref id="ser_status" name="ser_status">
467 <item><ref id="ser_uninstall" name="ser_uninstall">
468 <item><ref id="ser_unload" name="ser_unload">
472 <sect1><tt/setjmp.h/<label id="setjmp.h"><p>
475 <item><ref id="setjmp" name="setjmp">
476 <item><ref id="longjmp" name="longjmp">
480 <sect1><tt/signal.h/<label id="signal.h"><p>
483 <item><ref id="raise" name="raise">
484 <item><ref id="signal" name="signal">
488 <sect1><tt/stdarg.h/<label id="stdarg.h"><p>
493 <sect1><tt/stdbool.h/<label id="stdbool.h"><p>
498 <sect1><tt/stddef.h/<label id="stddef.h"><p>
501 <item><ref id="offsetof" name="offsetof">
505 <sect1><tt/stdio.h/<label id="stdio.h"><p>
508 <item><ref id="_poserror" name="_poserror">
509 <item><ref id="clearerr" name="clearerr">
510 <!-- <item><ref id="fclose" name="fclose"> -->
511 <!-- <item><ref id="fdopen" name="fdopen"> -->
512 <item><ref id="feof" name="feof">
513 <item><ref id="ferror" name="ferror">
514 <!-- <item><ref id="fflush" name="fflush"> -->
515 <!-- <item><ref id="fgetc" name="fgetc"> -->
516 <!-- <item><ref id="fgetpos" name="fgetpos"> -->
517 <!-- <item><ref id="fgets" name="fgets"> -->
518 <item><ref id="fileno" name="fileno">
519 <!-- <item><ref id="fopen" name="fopen"> -->
520 <!-- <item><ref id="fprintf" name="fprintf"> -->
521 <!-- <item><ref id="fputc" name="fputc"> -->
522 <!-- <item><ref id="fputs" name="fputs"> -->
523 <!-- <item><ref id="fread" name="fread"> -->
524 <!-- <item><ref id="freopen" name="freopen"> -->
525 <!-- <item><ref id="fscanf" name="fscanf"> -->
526 <!-- <item><ref id="fseek" name="fseek"> -->
527 <!-- <item><ref id="fsetpos" name="fsetpos"> -->
528 <!-- <item><ref id="ftell" name="ftell"> -->
529 <!-- <item><ref id="fwrite" name="fwrite"> -->
530 <!-- <item><ref id="getc" name="getc"> -->
531 <!-- <item><ref id="getchar" name="getchar"> -->
532 <!-- <item><ref id="gets" name="gets"> -->
533 <!-- <item><ref id="printf" name="printf"> -->
534 <!-- <item><ref id="putc" name="putc"> -->
535 <!-- <item><ref id="putchar" name="putchar"> -->
536 <!-- <item><ref id="puts" name="puts"> -->
537 <item><ref id="rename" name="rename">
538 <item><ref id="remove" name="remove">
539 <!-- <item><ref id="rewind" name="rewind"> -->
540 <!-- <item><ref id="scanf" name="scanf"> -->
541 <!-- <item><ref id="snprintf" name="snprintf"> -->
542 <!-- <item><ref id="sprintf" name="sprintf"> -->
543 <!-- <item><ref id="sscanf" name="sscanf"> -->
544 <!-- <item><ref id="vfprintf" name="vfprintf"> -->
545 <!-- <item><ref id="vfscanf" name="vfscanf"> -->
546 <!-- <item><ref id="vprintf" name="vprintf"> -->
547 <!-- <item><ref id="vscanf" name="vscanf"> -->
548 <!-- <item><ref id="vsnprintf" name="vsnprintf"> -->
549 <!-- <item><ref id="vsprintf" name="vsprintf"> -->
550 <!-- <item><ref id="vsscanf" name="vsscanf"> -->
556 <sect1><tt/stdlib.h/<label id="stdlib.h"><p>
559 <item><ref id="_heapadd" name="_heapadd">
560 <item><ref id="_heapblocksize" name="_heapblocksize">
561 <item><ref id="_heapmaxavail" name="_heapmaxavail">
562 <item><ref id="_heapmemavail" name="_heapmemavail">
563 <item><ref id="_randomize" name="_randomize">
564 <item><ref id="_swap" name="_swap">
565 <item><ref id="abort" name="abort">
566 <item><ref id="abs" name="abs">
567 <item><ref id="atexit" name="atexit">
568 <item><ref id="atoi" name="atoi">
569 <item><ref id="atol" name="atol">
570 <item><ref id="bsearch" name="bsearch">
571 <item><ref id="calloc" name="calloc">
572 <item><ref id="div" name="div">
573 <item><ref id="exit" name="exit">
574 <item><ref id="free" name="free">
575 <item><ref id="getenv" name="getenv">
576 <item><ref id="itoa" name="itoa">
577 <item><ref id="labs" name="labs">
578 <item><ref id="ltoa" name="ltoa">
579 <item><ref id="malloc" name="malloc">
580 <item><ref id="perror" name="perror">
581 <!-- <item><ref id="posix_memalign" name="posix_memalign"> -->
582 <!-- <item><ref id="putenv" name="putenv"> -->
583 <item><ref id="qsort" name="qsort">
584 <item><ref id="rand" name="rand">
585 <item><ref id="realloc" name="realloc">
586 <item><ref id="srand" name="srand">
587 <!-- <item><ref id="system" name="system"> -->
588 <item><ref id="ultoa" name="ultoa">
589 <item><ref id="utoa" name="utoa">
595 <sect1><tt/string.h/<label id="string.h"><p>
598 <item><ref id="_stroserror" name="_stroserror">
599 <item><ref id="bzero" name="bzero">
600 <item><ref id="memchr" name="memchr">
601 <item><ref id="memcmp" name="memcmp">
602 <item><ref id="memcpy" name="memcpy">
603 <item><ref id="memmove" name="memmove">
604 <item><ref id="memset" name="memset">
605 <item><ref id="strcasecmp" name="strcasecmp">
606 <item><ref id="strcat" name="strcat">
607 <item><ref id="strchr" name="strchr">
608 <item><ref id="strcmp" name="strcmp">
609 <item><ref id="strcoll" name="strcoll">
610 <item><ref id="strcpy" name="strcpy">
611 <item><ref id="strcspn" name="strcspn">
612 <item><ref id="strdup" name="strdup">
613 <item><ref id="strerror" name="strerror">
614 <item><ref id="stricmp" name="stricmp">
615 <item><ref id="strlen" name="strlen">
616 <item><ref id="strlower" name="strlower">
617 <item><ref id="strlwr" name="strlwr">
618 <item><ref id="strncat" name="strncat">
619 <item><ref id="strncmp" name="strncmp">
620 <item><ref id="strncpy" name="strncpy">
621 <item><ref id="strqtok" name="strqtok">
622 <item><ref id="strrchr" name="strrchr">
623 <item><ref id="strspn" name="strspn">
624 <item><ref id="strstr" name="strstr">
625 <item><ref id="strtok" name="strtok">
626 <item><ref id="strxfrm" name="strxfrm">
627 <item><ref id="strupper" name="strupper">
628 <item><ref id="strupr" name="strupr">
634 <sect1><tt/tgi.h/<label id="tgi.h"><p>
637 <item><ref id="tgi_arc" name="tgi_arc">
638 <item><ref id="tgi_bar" name="tgi_bar">
639 <item><ref id="tgi_circle" name="tgi_circle">
640 <item><ref id="tgi_clear" name="tgi_clear">
641 <item><ref id="tgi_done" name="tgi_done">
642 <item><ref id="tgi_ellipse" name="tgi_ellipse">
643 <item><ref id="tgi_free_vectorfont" name="tgi_free_vectorfont">
644 <item><ref id="tgi_getaspectratio" name="tgi_getaspectratio">
645 <item><ref id="tgi_getcolor" name="tgi_getcolor">
646 <item><ref id="tgi_getcolorcount" name="tgi_getcolorcount">
647 <item><ref id="tgi_getdefpalette" name="tgi_getdefpalette">
648 <item><ref id="tgi_geterror" name="tgi_geterror">
649 <item><ref id="tgi_geterrormsg" name="tgi_geterrormsg">
650 <item><ref id="tgi_getmaxcolor" name="tgi_getmaxcolor">
651 <item><ref id="tgi_getmaxx" name="tgi_getmaxx">
652 <item><ref id="tgi_getmaxy" name="tgi_getmaxy">
653 <item><ref id="tgi_getpagecount" name="tgi_getpagecount">
654 <item><ref id="tgi_getpalette" name="tgi_getpalette">
655 <item><ref id="tgi_getpixel" name="tgi_getpixel">
656 <item><ref id="tgi_gettextheight" name="tgi_gettextheight">
657 <item><ref id="tgi_gettextwidth" name="tgi_gettextwidth">
658 <item><ref id="tgi_getxres" name="tgi_getxres">
659 <item><ref id="tgi_getyres" name="tgi_getyres">
660 <item><ref id="tgi_gotoxy" name="tgi_gotoxy">
661 <item><ref id="tgi_init" name="tgi_init">
662 <item><ref id="tgi_install" name="tgi_install">
663 <item><ref id="tgi_install_vectorfont" name="tgi_install_vectorfont">
664 <item><ref id="tgi_ioctl" name="tgi_ioctl">
665 <item><ref id="tgi_line" name="tgi_line">
666 <item><ref id="tgi_lineto" name="tgi_lineto">
667 <item><ref id="tgi_load_driver" name="tgi_load_driver">
668 <item><ref id="tgi_load_vectorfont" name="tgi_load_vectorfont">
669 <item><ref id="tgi_outtext" name="tgi_outtext">
670 <item><ref id="tgi_outtextxy" name="tgi_outtextxy">
671 <item><ref id="tgi_setaspectratio" name="tgi_setaspectratio">
672 <item><ref id="tgi_setcolor" name="tgi_setcolor">
673 <item><ref id="tgi_setdrawpage" name="tgi_setdrawpage">
674 <item><ref id="tgi_setpalette" name="tgi_setpalette">
675 <item><ref id="tgi_setpixel" name="tgi_setpixel">
676 <item><ref id="tgi_setviewpage" name="tgi_setviewpage">
677 <item><ref id="tgi_settextscale" name="tgi_settextscale">
678 <item><ref id="tgi_settextstyle" name="tgi_settextstyle">
679 <item><ref id="tgi_uninstall" name="tgi_uninstall">
680 <item><ref id="tgi_unload" name="tgi_unload">
683 <sect1><tt/time.h/<label id="time.h"><p>
686 <!-- <item><ref id="_systime" name="_systime"> -->
687 <!-- <item><ref id="asctime" name="asctime"> -->
688 <item><ref id="clock" name="clock">
689 <!-- <item><ref id="ctime" name="ctime"> -->
690 <!-- <item><ref id="gmtime" name="gmtime"> -->
691 <!-- <item><ref id="localtime" name="localtime"> -->
692 <!-- <item><ref id="mktime" name="mktime"> -->
693 <!-- <item><ref id="strftime" name="strftime"> -->
694 <item><ref id="time" name="time">
700 <sect1><tt/unistd.h/<label id="unistd.h"><p>
703 <!-- <item><ref id="chdir" name="chdir"> -->
704 <item><ref id="exec" name="exec">
705 <!-- <item><ref id="getcwd" name="getcwd"> -->
706 <item><ref id="getopt" name="getopt">
707 <!-- <item><ref id="lseek" name="lseek"> -->
708 <!-- <item><ref id="mkdir" name="mkdir"> -->
709 <!-- <item><ref id="read" name="read"> -->
710 <!-- <item><ref id="rmdir" name="rmdir"> -->
711 <item><ref id="sleep" name="sleep">
712 <item><ref id="unlink" name="unlink">
713 <!-- <item><ref id="write" name="write"> -->
719 <sect1><tt/vic20.h/<label id="vic20.h"><p>
724 <sect1><tt/zlib.h/<label id="zlib.h"><p>
727 <!-- <item><ref id="adler32" name="adler32"> -->
728 <!-- <item><ref id="crc32" name="crc32"> -->
729 <!-- <item><ref id="inflatemem" name="inflatemem"> -->
730 <!-- <item><ref id="uncompress" name="uncompress"> -->
736 <sect>Alphabetical function reference<p>
738 <sect1>_DE_ISDIR<label id="_DE_ISDIR"><p>
742 <tag/Function/Determine if a directory entry specifies a directory.
743 <tag/Header/<tt/<ref id="dirent.h" name="dirent.h">/
744 <tag/Declaration/<tt/int _DE_ISDIR(unsigned char type);/
745 <tag/Description/The function is called with the type of a directory entry
746 taken from a <tt/struct dirent/ and returns true if the entry designates
749 <item>The function is actually a macro.
751 <tag/Availability/cc65
753 <ref id="_DE_ISLBL" name="_DE_ISLBL">,
754 <ref id="_DE_ISLNK" name="_DE_ISLNK">,
755 <ref id="_DE_ISREG" name="_DE_ISREG">
761 <sect1>_DE_ISLBL<label id="_DE_ISLBL"><p>
765 <tag/Function/Determine if a directory entry specifies a disk label.
766 <tag/Header/<tt/<ref id="dirent.h" name="dirent.h">/
767 <tag/Declaration/<tt/int _DE_ISLBL(unsigned char type);/
768 <tag/Description/The function is called with the type of a directory entry
769 taken from a <tt/struct dirent/ and returns true if the entry designates
772 <item>The function is actually a macro.
774 <tag/Availability/cc65
776 <ref id="_DE_ISDIR" name="_DE_ISDIR">,
777 <ref id="_DE_ISLNK" name="_DE_ISLNK">,
778 <ref id="_DE_ISREG" name="_DE_ISREG">
784 <sect1>_DE_ISLNK<label id="_DE_ISLNK"><p>
788 <tag/Function/Determine if a directory entry specifies a link.
789 <tag/Header/<tt/<ref id="dirent.h" name="dirent.h">/
790 <tag/Declaration/<tt/int _DE_ISLNK(unsigned char type);/
791 <tag/Description/The function is called with the type of a directory entry
792 taken from a <tt/struct dirent/ and returns true if the entry designates
795 <item>The function is actually a macro.
797 <tag/Availability/cc65
799 <ref id="_DE_ISDIR" name="_DE_ISDIR">,
800 <ref id="_DE_ISLBL" name="_DE_ISLBL">,
801 <ref id="_DE_ISREG" name="_DE_ISREG">
807 <sect1>_DE_ISREG<label id="_DE_ISREG"><p>
811 <tag/Function/Determine if a directory entry specifies a regular file.
812 <tag/Header/<tt/<ref id="dirent.h" name="dirent.h">/
813 <tag/Declaration/<tt/int _DE_ISREG(unsigned char type);/
814 <tag/Description/The function is called with the type of a directory entry
815 taken from a <tt/struct dirent/ and returns true if the entry designates
818 <item>The function is actually a macro.
819 <item>A "regular file" means anything with data in it. This might still mean
820 that special processing is needed, when accessing the file. Relative files of
821 the CBM systems are classified as being "regular" files, for example.
823 <tag/Availability/cc65
825 <ref id="_DE_ISDIR" name="_DE_ISDIR">,
826 <ref id="_DE_ISLBL" name="_DE_ISLBL">,
827 <ref id="_DE_ISLNK" name="_DE_ISLNK">
833 <sect1>_heapadd<label id="_heapadd"><p>
837 <tag/Function/Add a block to the heap.
838 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
839 <tag/Declaration/<tt/void __fastcall__ _heapadd (void* mem, size_t size);/
840 <tag/Description/The function adds a block of raw memory to the heap.
842 <item>The minimum blocksize that can be added is 6 bytes; the function will
843 ignore smaller blocks.
844 <item>The function is available only as a fastcall function; so, it may be used
845 only in the presence of a prototype.
847 <tag/Availability/cc65
849 <ref id="_heapblocksize" name="_heapblocksize">,
850 <ref id="_heapmaxavail" name="_heapmaxavail">,
851 <ref id="_heapmemavail" name="_heapmemavail">,
852 <ref id="calloc" name="calloc">,
853 <ref id="free" name="free">,
854 <ref id="malloc" name="malloc">,
855 <ref id="realloc" name="realloc">
861 <sect1>_heapblocksize<label id="_heapblocksize"><p>
865 <tag/Function/Return the size of an allocated block.
866 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
867 <tag/Declaration/<tt/size_t __fastcall__ _heapblocksize (const void* block);/
868 <tag/Description/The function returns the size of a block that must have
869 previously been allocated by <tt/<ref id="malloc" name="malloc">/, <tt/<ref
870 id="calloc" name="calloc">/ or <tt/<ref id="realloc" name="realloc">/.
872 <item>Passing a pointer to a block that was is not the result of one of the
873 allocation functions, or that has been free'd will give unpredicable results.
874 <item>The function is available only as a fastcall function; so, it may be used
875 only in the presence of a prototype.
877 <tag/Availability/cc65
879 <ref id="_heapadd" name="_heapadd">,
880 <ref id="_heapmaxavail" name="_heapmaxavail">,
881 <ref id="_heapmemavail" name="_heapmemavail">,
882 <ref id="calloc" name="calloc">,
883 <ref id="free" name="free">,
884 <ref id="malloc" name="malloc">,
885 <ref id="realloc" name="realloc">
891 <sect1>_heapmaxavail<label id="_heapmaxavail"><p>
895 <tag/Function/Return the largest block that is available on the heap.
896 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
897 <tag/Declaration/<tt/size_t _heapmaxavail (void);/
898 <tag/Description/The function returns the size of the largest block that may
899 be allocated from the heap using <tt/<ref id="malloc" name="malloc">/.
900 <tag/Availability/cc65
902 <ref id="_heapadd" name="_heapadd">,
903 <ref id="_heapblocksize" name="_heapblocksize">,
904 <ref id="_heapmemavail" name="_heapmemavail">,
905 <ref id="calloc" name="calloc">,
906 <ref id="free" name="free">,
907 <ref id="malloc" name="malloc">,
908 <ref id="realloc" name="realloc">
914 <sect1>_heapmemavail<label id="_heapmemavail"><p>
918 <tag/Function/Return the total available space on the heap.
919 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
920 <tag/Declaration/<tt/size_t _heapmemavail (void);/
921 <tag/Description/The function returns the total number of bytes available on
924 <item>This function is of less use than usually assumed, since the returned
925 heap space may be available but not in one block. So even if this function
926 says that several times more heap space is available than needed, <ref
927 id="malloc" name="malloc"> may still return <tt/NULL/.
929 <tag/Availability/cc65
931 <ref id="_heapadd" name="_heapadd">,
932 <ref id="_heapblocksize" name="_heapblocksize">,
933 <ref id="_heapmaxavail" name="_heapmaxavail">,
934 <ref id="calloc" name="calloc">,
935 <ref id="free" name="free">,
936 <ref id="malloc" name="malloc">,
937 <ref id="realloc" name="realloc">
943 <sect1>_is_cmdline_dos<label id="_is_cmdline_dos"><p>
947 <tag/Function/Determines whether the underlying DOS supports command line arguments.
948 <tag/Header/<tt/<ref id="atari.h" name="atari.h">/
949 <tag/Declaration/<tt/unsigned char _is_cmdline_dos (void);/
950 <tag/Description/The function returns 0 if the DOS doesn't support command line arguments.
951 It returns 1 if it does.
953 <item>Many Atari DOSes which don't support command line arguments immediately clear the screen
954 and display their menu after a program exits. Therefore it might be difficult to read
955 the last messages printed by the program prior to its exit. This function can be used
956 to decide if a delay or wait for a key press should be executed when then program
959 <tag/Availability/cc65 (<tt/atari/ and <tt/atarixl/ platforms)
961 /* Hello World for Atari */
967 printf("Hello World\n");
968 if (! _is_cmdline_dos())
977 <sect1>_poserror<label id="_poserror"><p>
981 <tag/Function/Print an error message for the error in <tt/_oserror/.
982 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
983 <tag/Declaration/<tt/void __fastcall__ _poserror (const char* msg);/
984 <tag/Description/<tt/_poserror/ prints an error message to <tt/stderr/. If
985 <tt/msg/ is not <tt/NULL/ and not an empty string, it is printed followed by
986 a colon and a blank. Then the error message for the current contents of
987 <tt/_oserror/ are printed followed by a newline. The message output is the
988 same as returned by <tt/<ref id="_stroserror" name="_stroserror">/ with an
989 argument of <tt/_oserror/.
991 <item>Since operating system specific error code are - you guessed it -
992 operating system specific, the value in <tt/_oserror/ and the message that is
993 printed depends on the cc65 target.
994 <item>The function is only available as fastcall function, so it may only
995 be used in presence of a prototype.
997 <tag/Availability/cc65
999 <ref id="_stroserror" name="_stroserror">,
1000 <ref id="perror" name="perror">
1006 <sect1>_randomize<label id="_randomize"><p>
1010 <tag/Function/Initialize the pseudo random number generator.
1011 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1012 <tag/Declaration/<tt/void _randomize (void);/
1013 <tag/Description/The function initializes the random number generator with
1014 a seed derived from fast changing hardware events, so the seed itself can be
1015 considered random to a certain degree.
1016 <tag/Notes/<itemize>
1017 <item>The randomness of the seed depends on the machine hardware.
1019 <tag/Availability/cc65
1021 <ref id="rand" name="rand">,
1022 <ref id="srand" name="srand">
1028 <sect1>_stroserror<label id="_stroserror"><p>
1032 <tag/Function/Return a string describing an OS specific error code.
1033 <tag/Header/<tt/<ref id="string.h" name="string.h">/
1034 <tag/Declaration/<tt/const char* __fastcall__ _stroserror (unsigned char errcode);/
1035 <tag/Description/<tt/_stroserror/ will return a string describing the given
1036 operating system specific error code.
1037 <tag/Notes/<itemize>
1038 <item>Since operating system specific error code are - you guessed it -
1039 operating system specific, the parameter and the string returned depend on the
1041 <item>The function is only available as fastcall function, so it may only be
1042 used in presence of a prototype.
1044 <tag/Availability/cc65
1046 <ref id="strerror" name="strerror">
1052 <sect1>_swap<label id="_swap"><p>
1056 <tag/Function/Swap the contents of memory areas.
1057 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1058 <tag/Declaration/<tt/void __fastcall__ _swap (void* p, void* q, size_t size);/
1059 <tag/Description/<tt/_swap/ will swap (exchange) the contents of the two memory
1060 areas pointed to by <tt/p/ and <tt/q/. Both memory areas are assumed to be
1061 <tt/size/ bytes in size.
1062 <tag/Notes/<itemize>
1063 <item>The memory areas may not overlap, otherwise the results are undefined.
1064 <item>The function is only available as fastcall function, so it may only be
1065 used in presence of a prototype.
1067 <tag/Availability/cc65
1069 <ref id="memcpy" name="memcpy">,
1070 <ref id="memmove" name="memmove">
1076 <sect1>_sys<label id="_sys"><p>
1080 <tag/Function/Call a subroutine passing register values.
1081 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
1082 <tag/Declaration/<tt/void __fastcall__ _sys (struct regs* r);/
1083 <tag/Description/The function will call the subroutine at the address
1084 specified in the <tt/pc/ member of the passed <tt/regs/ structure. All
1085 registers and the CPU flags are set to the values given in the <tt/regs/
1086 structure. On return from the subroutine, the new values of the registers and
1087 flags are stored back overwriting the old values.
1088 <tag/Notes/<itemize>
1089 <item>Bits 4 and 5 of the flags value in the <tt/regs/ structure are ignored
1090 when calling the subroutine (they are unchanged from their current values).
1091 <item>The function is only available as fastcall function, so it may only be
1092 used in presence of a prototype.
1094 <tag/Availability/cc65
1100 <sect1>BRK<label id="BRK"><p>
1104 <tag/Function/Insert a 6502 BRK instrunction into the code.
1105 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
1106 <tag/Declaration/<tt/void BRK (void);/
1107 <tag/Description/The function will insert a 6502 BRK instruction into the code
1108 which may be used to trigger a debugger.
1109 <tag/Notes/<itemize>
1110 <item>The function is actually a macro.
1111 <item>The inserted instruction may lead to unexpected results if no debugger
1114 <tag/Availability/cc65
1116 <ref id="CLI" name="CLI">,
1117 <ref id="SEI" name="SEI">
1123 <sect1>CLI<label id="CLI"><p>
1127 <tag/Function/Insert a 6502 CLI instrunction into the code.
1128 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
1129 <tag/Declaration/<tt/void CLI (void);/
1130 <tag/Description/The function will insert a 6502 CLI instruction into the code,
1131 so interrupts are enabled. Enabling interrupts has no effects if they are
1132 already enabled (the default).
1133 <tag/Notes/<itemize>
1134 <item>The function is actually a macro.
1135 <item>Disabling interrupts may lead to unexpected results.
1137 <tag/Availability/cc65
1139 <ref id="BRK" name="BRK">,
1140 <ref id="SEI" name="SEI">
1146 <sect1>PEEK<label id="PEEK"><p>
1150 <tag/Function/Read a byte from memory.
1151 <tag/Header/<tt/<ref id="peekpoke.h" name="peekpoke.h">/
1152 <tag/Declaration/<tt/unsigned char PEEK (unsigned addr);/
1153 <tag/Description/The function will read the absolute memory given by <tt/addr/
1154 and return the value read.
1155 <tag/Notes/<itemize>
1156 <item>The function is actually a macro.
1157 <item>This function depends highly on the platform and environment.
1159 <tag/Availability/cc65
1161 <ref id="PEEKW" name="PEEKW">,
1162 <ref id="POKE" name="POKE">
1168 <sect1>PEEKW<label id="PEEKW"><p>
1172 <tag/Function/Read a word (two bytes) from memory.
1173 <tag/Header/<tt/<ref id="peekpoke.h" name="peekpoke.h">/
1174 <tag/Declaration/<tt/unsigned PEEKW (unsigned addr);/
1175 <tag/Description/The function will read the absolute memory given by <tt/addr/
1176 and return the value read. The byte read from the higher address is the high
1177 byte of the return value.
1178 <tag/Notes/<itemize>
1179 <item>The function is actually a macro.
1180 <item>This function depends highly on the platform and environment.
1181 <item>The order in which the two bytes are read is unspecified and may
1182 depend of the address expression used.
1184 <tag/Availability/cc65
1186 <ref id="PEEK" name="PEEK">,
1187 <ref id="POKE" name="POKE">
1193 <sect1>POKE<label id="POKE"><p>
1197 <tag/Function/Write a byte to memory.
1198 <tag/Header/<tt/<ref id="peekpoke.h" name="peekpoke.h">/
1199 <tag/Declaration/<tt/void POKE (unsigned addr, unsigned char val);/
1200 <tag/Description/The function writes the value <tt/val/ to the absolute
1201 memory address given by <tt/addr/.
1202 <tag/Notes/<itemize>
1203 <item>The function is actually a macro.
1204 <item>This function depends highly on the platform and environment.
1205 <item>Careless use will cause the program to act strange or may crash the
1208 <tag/Availability/cc65
1210 <ref id="PEEK" name="PEEK">,
1211 <ref id="POKEW" name="POKEW">
1217 <sect1>POKEW<label id="POKEW"><p>
1221 <tag/Function/Write a word (two bytes) to memory.
1222 <tag/Header/<tt/<ref id="peekpoke.h" name="peekpoke.h">/
1223 <tag/Declaration/<tt/void POKEW (unsigned addr, unsigned val);/
1224 <tag/Description/The function writes the value <tt/val/ to the absolute
1225 memory address given by <tt/addr/. The low byte of <tt/val/ is written to
1226 the <tt/addr/, the high byte is written to <tt/addr+1/.
1227 <tag/Notes/<itemize>
1228 <item>The function is actually a macro.
1229 <item>This function depends highly on the platform and environment.
1230 <item>Careless use will cause the program to act strange or may crash the
1232 <item>The order in which the two bytes are written is unspecified and may
1233 depend of the address expression used.
1235 <tag/Availability/cc65
1237 <ref id="PEEK" name="PEEK">,
1238 <ref id="POKE" name="POKE">
1244 <sect1>SEI<label id="SEI"><p>
1248 <tag/Function/Insert a 6502 SEI instrunction into the code.
1249 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
1250 <tag/Declaration/<tt/void SEI (void);/
1251 <tag/Description/The function will insert a 6502 SEI instruction into the code,
1252 so interrupts are disabled. Note that non maskable interrupts cannot be
1254 <tag/Notes/<itemize>
1255 <item>The function is actually a macro.
1256 <item>Disabling interrupts may lead to unexpected results.
1258 <tag/Availability/cc65
1260 <ref id="BRK" name="BRK">,
1261 <ref id="CLI" name="CLI">
1267 <sect1>abort<label id="abort"><p>
1271 <tag/Function/Terminates a program abnormally.
1272 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1273 <tag/Declaration/<tt/void abort (void);/
1274 <tag/Description/<tt/abort/ raises <tt/SIGABRT/, writes a termination message
1275 on stderr, then terminates the program with an exit code of 3.
1276 <tag/Availability/ISO 9899
1278 <ref id="assert" name="assert">,
1279 <ref id="exit" name="exit">,
1280 <ref id="raise" name="raise">
1286 <sect1>abs<label id="abs"><p>
1290 <tag/Function/Returns the absolute value of an integer.
1291 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1292 <tag/Declaration/<tt/int __fastcall__ abs (int v);/
1293 <tag/Description/<tt/abs/ returns the absolute value of the argument passed to
1295 <tag/Notes/<itemize>
1296 <item>The return value is undefined if <tt/INT_MIN/ is passed to the function.
1297 <item>The function is only available as fastcall function, so it may only be
1298 used in presence of a prototype.
1300 <tag/Availability/ISO 9899
1302 <ref id="labs" name="labs">
1308 <sect1>assert<label id="assert"><p>
1312 <tag/Function/Test a condition and possibly abort.
1313 <tag/Header/<tt/<ref id="assert.h" name="assert.h">/
1314 <tag/Declaration/<tt/void assert (int cond);/
1315 <tag/Description/<tt/assert/ is a macro that expands to a <tt/id/
1316 statement. If the condition evaluates t zero (false), assert prints a message
1317 on stderr and aborts the program.
1318 <tag/Notes/<itemize>
1319 <item>The function is actually a macro.
1321 <tag/Availability/ISO 9899
1323 <ref id="abort" name="abort">,
1324 <ref id="exit" name="exit">
1330 <sect1>atexit<label id="atexit"><p>
1334 <tag/Function/Register an exit function.
1335 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1336 <tag/Declaration/<tt/int __fastcall__ atexit (void (*exitfunc) (void));/
1337 <tag/Description/<tt/atexit/ registers the function pointed to by
1338 <tt/exitfunc/ as an exit function. Exit functions are called when the program
1339 terminates, they are called in LIFO order (the last function registered is
1340 called first). <tt/atexit/ returns zero on success and a nonzero value on
1342 <tag/Notes/<itemize>
1343 <item>A maximum of 5 exit functions can be registered.
1344 <item>There is no way to unregister an exit function.
1345 <item>The function is only available as fastcall function, so it may only be
1346 used in presence of a prototype.
1348 <tag/Availability/ISO 9899
1350 <ref id="abort" name="abort">,
1351 <ref id="exit" name="exit">
1357 <sect1>atmos_load<label id="atmos_load"><p>
1361 <tag/Function/Load Atmos tape.
1362 <tag/Header/<tt/<ref id="atmos.h" name="atmos.h">/
1363 <tag/Declaration/<tt/void __fastcall__ atmos_load(const char* name);/
1364 <tag/Description/<tt/atmos_load/ reads a memory block from tape.
1365 <tag/Notes/<itemize>
1366 <item>The function is available only as a fastcall function; so, it may be used
1367 only in the presence of a prototype.
1369 <tag/Availability/cc65
1371 <ref id="atmos_save" name="atmos_save">
1377 <sect1>atmos_save<label id="atmos_save"><p>
1381 <tag/Function/Save Atmos tape.
1382 <tag/Header/<tt/<ref id="atmos.h" name="atmos.h">/
1383 <tag/Declaration/<tt/void __fastcall__ atmos_save(const char* name, const void* start, const void* end);/
1384 <tag/Description/<tt/atmos_save/ writes a memory block to tape.
1385 <tag/Notes/<itemize>
1386 <item>The function is available only as a fastcall function; so, it may be used
1387 only in the presence of a prototype.
1389 <tag/Availability/cc65
1391 <ref id="atmos_load" name="atmos_load">
1393 atmos_save("hires", 0xa000, 0xc000);
1399 <sect1>atoi<label id="atoi"><p>
1403 <tag/Function/Convert a string to an integer.
1404 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1405 <tag/Declaration/<tt/int __fastcall__ atoi (const char* s);/
1406 <tag/Description/<tt/atoi/ converts the given string into an integer.
1407 Conversion stops as soon as any invalid character is encountered.
1408 <tag/Notes/<itemize>
1409 <item>There is no way to detect any conversion errors.
1410 <item>The function does not check for an numerical overflow when converting.
1411 <item>The function is only available as fastcall function, so it may only be
1412 used in presence of a prototype.
1414 <tag/Availability/ISO 9899
1416 <ref id="atol" name="atol">,
1417 <ref id="itoa" name="itoa">,
1418 <ref id="ltoa" name="ltoa">,
1419 <ref id="ultoa" name="ultoa">,
1420 <ref id="utoa" name="utoa">
1426 <sect1>atol<label id="atol"><p>
1430 <tag/Function/Convert a string to a long integer.
1431 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1432 <tag/Declaration/<tt/long __fastcall__ atol (const char* s);/
1433 <tag/Description/<tt/atol/ converts the given string into a long integer.
1434 Conversion stops as soon as any invalid character is encountered.
1435 <tag/Notes/<itemize>
1436 <item>There is no way to detect any conversion errors.
1437 <item>The function does not check for an numerical overflow when converting.
1438 <item>The function is only available as fastcall function, so it may only be
1439 used in presence of a prototype.
1441 <tag/Availability/ISO 9899
1443 <ref id="atoi" name="atoi">,
1444 <ref id="itoa" name="itoa">,
1445 <ref id="ltoa" name="ltoa">,
1446 <ref id="ultoa" name="ultoa">,
1447 <ref id="utoa" name="utoa">
1453 <sect1>bgcolor<label id="bgcolor"><p>
1457 <tag/Function/Set the background text color.
1458 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1459 <tag/Declaration/<tt/unsigned char __fastcall__ bgcolor (unsigned char color);/
1460 <tag/Description/The function will set a new background color and return the
1461 old (current) one. The background color is valid for the whole text output
1462 area of the screen, not just for new text.
1463 <tag/Notes/<itemize>
1464 <item>Background colors are system dependent. The function may have no effect
1465 on systems where the background color cannot be changed.
1466 <item>The function is only available as fastcall function, so it may only be
1467 used in presence of a prototype.
1469 <tag/Availability/cc65
1471 <ref id="bordercolor" name="bordercolor">,
1472 <ref id="textcolor" name="textcolor">
1478 <sect1>bordercolor<label id="bordercolor"><p>
1482 <tag/Function/Set the border (frame) color.
1483 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1484 <tag/Declaration/<tt/unsigned char __fastcall__ bordercolor (unsigned char color);/
1485 <tag/Description/The function will set a new border color. It returns the old
1486 (current) border color.
1487 <tag/Notes/<itemize>
1488 <item>Border colors are system dependent. The function may have no effect
1489 on systems where the border color cannot be changed.
1490 <item>The function is only available as fastcall function, so it may only
1491 be used in presence of a prototype.
1493 <tag/Availability/cc65
1495 <ref id="bgcolor" name="bgcolor">,
1496 <ref id="textcolor" name="textcolor">
1502 <sect1>bsearch<label id="bsearch"><p>
1506 <tag/Function/Do a binary search in a sorted array.
1507 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1508 <tag/Declaration/<tt/void* __fastcall__ bsearch (const void* key,
1509 const void* base, size_t n, size_t size,
1510 int __fastcall__ (* cmp) (const void*, const void*));/
1511 <tag/Description/<tt/bsearch/ searches a sorted array for a member that
1512 matches the one pointed to by <tt/key/. <tt/base/ is the address of the array,
1513 <tt/n/ is the number of elements, <tt/size/ the size of an element and <tt/cmp/
1514 the function used to compare the members against the key. The function returns
1515 a pointer to the member found, or <tt/NULL/ if there was no match.
1516 <tag/Notes/<itemize>
1517 <item>The contents of the array must be sorted in ascending order according to
1518 the compare function given.
1519 <item>If there are multiple members that match the key, the function will
1520 return one of the members.
1521 <item>The function is only available as fastcall function, so it may only
1522 be used in presence of a prototype.
1523 <item>The function to which <tt/cmp/ points must have the <tt/fastcall/ calling
1526 <tag/Availability/ISO 9899
1528 <ref id="qsort" name="qsort">
1534 <sect1>bzero<label id="bzero"><p>
1538 <tag/Function/Fill a memory area with zeroes.
1539 <tag/Header/<tt/<ref id="string.h" name="string.h">/
1540 <tag/Declaration/<tt/void __fastcall__ bzero (void* p, size_t count);/
1541 <tag/Description/<tt/bzero/ fills the memory area pointed to by <tt/p/ with
1543 <tag/Notes/<itemize>
1544 <item>The function is non standard and therefore only available in non ANSI
1545 mode. You should use <tt/<ref id="memset" name="memset">/ instead.
1546 <item>The function is only available as fastcall function, so it may only
1547 be used in presence of a prototype.
1549 <tag/Availability/cc65
1551 <ref id="_swap" name="_swap">,
1552 <ref id="memcpy" name="memcpy">,
1553 <ref id="memmove" name="memmove">,
1554 <ref id="memset" name="memset">,
1560 <sect1>c64mode<label id="c64mode"><p>
1564 <tag/Function/Switch the C128 into C64 compatible mode.
1565 <tag/Header/<tt/<ref id="c128.h" name="c128.h">/
1566 <tag/Declaration/<tt/void c64mode (void);/
1567 <tag/Description/The function will cause the machine to reboot into C64 mode.
1568 <tag/Notes/<itemize>
1569 <item>The function is specific to the C128.
1570 <item>The function will not return to the caller.
1572 <tag/Availability/C128
1578 <sect1>calloc<label id="calloc"><p>
1582 <tag/Function/Allocate and clear memory.
1583 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1584 <tag/Declaration/<tt/void* __fastcall__ calloc (size_t n, size_t size);/
1585 <tag/Description/<tt/calloc/ allocates memory for an array of <tt/n/ elements
1586 of size <tt/size/, clears the whole block with binary zeroes and returns a
1587 pointer to it. On error (not enough memory available), <tt/calloc/ returns
1589 <tag/Notes/<itemize>
1590 <item>Clearing the memory may not have the expected effect on all platforms:
1591 pointers in the block may not be <tt/NULL/ and floating point variables may
1592 not be zero (0.0). In other words: The "clearing" effect of this function
1593 should be used with care for portable programs.
1594 <item>The function is only available as fastcall function, so it may only
1595 be used in presence of a prototype.
1597 <tag/Availability/ISO 9899
1599 <ref id="_heapadd" name="_heapadd">,
1600 <ref id="_heapblocksize" name="_heapblocksize">,
1601 <ref id="_heapmaxavail" name="_heapmaxavail">,
1602 <ref id="_heapmemavail" name="_heapmemavail">,
1603 <ref id="free" name="free">,
1604 <ref id="malloc" name="malloc">,
1605 <ref id="realloc" name="realloc">
1611 <sect1>cbm_k_acptr<label id="cbm_k_acptr"><p>
1615 <tag/Function/Input byte from serial bus
1616 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
1617 <tag/Declaration/<tt/unsigned char cbm_k_acptr (void);/
1618 <tag/Description/The function returns a byte of data, which it
1619 gets from the current TALKer on the serial bus.
1620 In order to receive the data, the device must have previously been
1621 sent a command to TALK and a secondary address if it needs one.
1622 <tag/Notes/<itemize>
1625 <tag/Availability/cc65
1627 <ref id="cbm_k_talk" name="cbm_k_talk">,
1633 <sect1>cbm_k_basin<label id="cbm_k_basin"><p>
1637 <tag/Function/Input a Character from the Current Device
1638 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
1639 <tag/Declaration/<tt/unsigned char cbm_k_basin (void);/
1640 <tag/Description/The function returns a character from the current input device.
1641 Device must first have been OPENed and then designated as the input channel by the CHKIN routine.
1642 When this function is called, the next byte of data available from the device is returned.
1643 Exception is the routine for the keyboard device (which is the default input device).
1644 <tag/Notes/<itemize>
1647 <tag/Availability/cc65
1649 <ref id="cbm_k_open" name="cbm_k_open">,
1650 <ref id="cbm_k_chkin" name="cbm_k_chkin">
1656 <sect1>cbm_k_bsout<label id="cbm_k_bsout"><p>
1660 <tag/Function/Output a byte
1661 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
1662 <tag/Declaration/<tt/void __fastcall__ cbm_k_bsout (unsigned char C);/
1663 <tag/Description/Function sends the character to the current output device.
1664 Unless a device has been OPENed and designated as the
1665 current output channel using the CHKOUT routine, the character is
1666 printed to the screen, which is the default output device. If the
1667 cassette is the current device, outputting a byte will only add it to
1668 the buffer. No actual transmission of data will occur until the
1669 192-byte buffer is full.
1670 <tag/Notes/<itemize>
1671 <item>The function is only available as fastcall function, so it may
1672 only be used in presence of a prototype.
1674 <tag/Availability/cc65
1676 <ref id="cbm_k_open" name="cbm_k_open">,
1677 <ref id="cbm_k_chkin" name="cbm_k_chkout">
1683 <sect1>cbm_k_chkin<label id="cbm_k_chkin"><p>
1687 <tag/Function/Designate a Logical File As the Current Input Channel
1688 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
1689 <tag/Declaration/<tt/unsigned char __fastcall__ cbm_k_chkin (unsigned char FN);/
1690 <tag/Description/If you wish to
1691 get data from any device other than the keyboard, this function must be
1692 called after OPENing the device, before you can get a data byte with
1693 the cbm_k_basin or cbm_k_getin routine. When called, the routine will designate
1694 the logical file whose file number was supplied as the
1695 current file, its device as the current device, and its secondary
1696 address as the current secondary address. If the device on the
1697 channel is a serial device, which requires a TALK command and
1698 sometimes a secondary address, function will send them over the
1700 <tag/Notes/<itemize>
1701 <item>The function is only available as fastcall function, so it may
1702 only be used in presence of a prototype.
1704 <tag/Availability/cc65
1706 <ref id="cbm_k_open" name="cbm_k_open">,
1707 <ref id="cbm_k_basin" name="cbm_k_basin">,
1708 <ref id="cbm_k_getin" name="cbm_k_getin">
1714 <sect1>cbm_k_ciout<label id="cbm_k_ciout"><p>
1718 <tag/Function/Transmit a byte over the serial bus
1719 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
1720 <tag/Declaration/<tt/void __fastcall__ cbm_k_ciout (unsigned char C);/
1721 <tag/Description/Purpose of this function is to send a byte of data over
1722 the serial bus. In order for the data to be received, the serial
1723 device must have first been commanded to LISTEN and been given a
1724 secondary address if necessary. This routine always buffers the
1725 current character, and defers sending it until the next byte is
1726 buffered. When the UNLISTEN command is sent, the last byte will be
1727 sent with an End or Identify (EOI).
1728 <tag/Notes/<itemize>
1729 <item>The function is only available as fastcall function, so it may
1730 only be used in presence of a prototype.
1732 <tag/Availability/cc65
1734 <ref id="cbm_k_listen" name="cbm_k_listen">,
1735 <ref id="cbm_k_unlsn" name="cbm_k_unlsn">
1741 <sect1>cbm_k_ckout<label id="cbm_k_ckout"><p>
1745 <tag/Function/Designate a Logical File As the Current Output Channel
1746 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
1747 <tag/Declaration/<tt/unsigned char __fastcall__ cbm_k_ckout (unsigned char FN);/
1748 <tag/Description/If you wish to
1749 output data to any device other than the screen, this routine must be
1750 called after OPENing the device, and before you output a data byte
1751 with the cbm_k_bsout() function. When called, the function will designate the
1752 logical file whose file number was supplied as the current
1753 file, its device as the current device, and its secondary address as
1754 the current secondary address. If the device on the channel uses the
1755 serial bus, and therefore requires a LISTEN command and possibly a
1756 secondary address, this information will be sent on the bus.
1757 <tag/Notes/<itemize>
1758 <item>The function is only available as fastcall function, so it may
1759 only be used in presence of a prototype.
1761 <tag/Availability/cc65
1763 <ref id="cbm_k_bsout" name="cbm_k_bsout">,
1764 <ref id="cbm_k_listen" name="cbm_k_listen">
1770 <sect1>cbm_k_clall<label id="cbm_k_clall"><p>
1774 <tag/Function/Close All Logical I/O Files
1775 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
1776 <tag/Declaration/<tt/void cbm_k_clall (void);/
1777 <tag/Description/It closes all
1778 open files, by resetting the index into open files to
1779 zero and restores the default I/O devices.
1780 <tag/Notes/<itemize>
1783 <tag/Availability/cc65
1785 <ref id="cbm_k_open" name="cbm_k_open">,
1786 <ref id="cbm_k_close" name="cbm_k_close">
1792 <sect1>cbm_k_close<label id="cbm_k_close"><p>
1796 <tag/Function/Close a Logical I/O File
1797 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
1798 <tag/Declaration/<tt/void __fastcall__ cbm_k_close (unsigned char FN);/
1799 <tag/Description/It is used to
1800 close a logical file after all I/O operations involving that file have
1802 <tag/Notes/<itemize>
1803 <item>The function is only available as fastcall function, so it may
1804 only be used in presence of a prototype.
1806 <tag/Availability/cc65
1808 <ref id="cbm_k_open" name="cbm_k_open">,
1809 <ref id="cbm_k_clall" name="cbm_k_clall">
1815 <sect1>cbm_k_clrch<label id="cbm_k_clrch"><p>
1819 <tag/Function/Restore Current Input and Output Devices to the Default Devices
1820 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
1821 <tag/Declaration/<tt/void cbm_k_clrch (void);/
1822 <tag/Description/It sets the
1823 current input device to the keyboard, and the current output device to
1824 the screen. Also, if the current input device was formerly a serial
1825 device, the routine sends it an UNTALK command on the serial bus, and
1826 if a serial device was formerly the current output device, the routine
1827 sends it an UNLISTEN command.
1828 <tag/Notes/<itemize>
1831 <tag/Availability/cc65
1833 <ref id="cbm_k_chkin" name="cbm_k_chkin">,
1834 <ref id="cbm_k_ckout" name="cbm_k_ckout">
1840 <sect1>cbm_k_getin<label id="cbm_k_getin"><p>
1844 <tag/Function/Get One Byte from the Input Device
1845 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
1846 <tag/Declaration/<tt/unsigned char cbm_k_getin (void);/
1847 <tag/Description/Function gets a character from the current input device.
1848 <tag/Notes/<itemize>
1851 <tag/Availability/cc65
1853 <ref id="cbm_k_basin" name="cbm_k_basin">
1859 <sect1>cbm_k_iobase<label id="cbm_k_iobase"><p>
1863 <tag/Function/Return Base Address of Memory-Mapped I/O Devices
1864 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
1865 <tag/Declaration/<tt/unsigned cbm_k_iobase (void);/
1866 <tag/Description/This function returns the address of
1867 the memory section where the memory mapped I/O devices are located. This
1868 address can then be used with an offset to access the memory mapped I/O
1869 devices in the Commodore 64. The offset is the number of locations from
1870 the beginning of the page on which the I/O register you want is located.
1871 This function exists to provide compatibility between the Commodore 64,
1872 VIC-20, and future models of the Commodore 64. If the I/O locations for
1873 a program are set by a call to this function, they should
1874 still remain compatible with future versions of the Commodore 64, the
1876 <tag/Notes/<itemize>
1879 <tag/Availability/cc65
1887 <sect1>cbm_k_listen<label id="cbm_k_listen"><p>
1891 <tag/Function/Command a device on the serial bus to LISTEN
1892 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
1893 <tag/Declaration/<tt/void __fastcall__ cbm_k_listen (unsigned char dev);/
1894 <tag/Description/This function will command a device on the serial bus to
1895 receive data. The KERNAL routine will OR the supplied device number bit by bit
1896 to convert it to a listen address, then transmits this data as a command on
1897 the serial bus. The specified device will then go into listen mode, and
1898 be ready to accept information.
1899 <tag/Notes/<itemize>
1900 <item>The function is only available as fastcall function, so it may
1901 only be used in presence of a prototype.
1903 <tag/Availability/cc65
1905 <ref id="cbm_k_unlsn" name="cbm_k_unlsn">,
1911 <sect1>cbm_k_load<label id="cbm_k_load"><p>
1915 <tag/Function/Load RAM from a Device
1916 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
1917 <tag/Declaration/<tt/unsigned int __fastcall__ cbm_k_load(unsigned char flag, unsigned addr);/
1918 <tag/Description/This function LOADs data bytes from any input device directly into the memory.
1919 It can also be used for a verify operation, comparing data from a device with the data already in
1920 memory, while leaving the data stored in RAM unchanged.
1921 The flag must be set to 0 for a LOAD operation, or 1 for a
1922 verify, If the input device is OPENed with a secondary address (SA) of 0
1923 the header information from the device is ignored. In this case, the starting address for the load must be supplied.
1924 If the device is addressed with a secondary address of 1, then the data is
1925 loaded into memory starting at the location specified by the header.
1926 Function returns the address of the highest RAM location loaded.
1927 Before this function can be called, the KERNAL SETLFS, and SETNAM
1928 routines must be called.
1929 <tag/Notes/<itemize>
1930 <item>The function is only available as fastcall function, so it may
1931 only be used in presence of a prototype.
1933 <tag/Availability/cc65
1935 <ref id="cbm_k_save" name="cbm_k_save">,
1936 <ref id="cbm_k_setlfs" name="cbm_k_setlfs">,
1937 <ref id="cbm_k_setnam" name="cbm_k_setnam">
1943 <sect1>cbm_k_open<label id="cbm_k_open"><p>
1947 <tag/Function/Open a Logical I/O File
1948 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
1949 <tag/Declaration/<tt/unsigned char cbm_k_open (void);/
1950 <tag/Description/This function assigns a logical file to a device, so that it can be used for
1951 Input/Output operations. In order to specify the logical file number,
1952 the device number, and the secondary address if any, the cbm_k_setlfs() function must first be called.
1953 Likewise, in order to designate the filename, the cbm_k_setnam() function must be used first. After these two
1954 functions are called, cbm_k_open() is then called.
1955 <tag/Notes/<itemize>
1958 <tag/Availability/cc65
1960 <ref id="cbm_k_close" name="cbm_k_close">,
1961 <ref id="cbm_k_setlfs" name="cbm_k_setlfs">,
1962 <ref id="cbm_k_setnam" name="cbm_k_setnam">
1968 <sect1>cbm_k_readst<label id="cbm_k_readst"><p>
1972 <tag/Function/Read status word
1973 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
1974 <tag/Declaration/<tt/unsigned char cbm_k_readst (void);/
1975 <tag/Description/This function returns the current status of the I/O devices. It is usually called after new communication to an I/O device and gives information about device status, or errors that have occurred during the I/O operation.
1976 <tag/Notes/<itemize>
1979 <tag/Availability/cc65
1987 <sect1>cbm_k_save<label id="cbm_k_save"><p>
1991 <tag/Function/Save RAM to a Device
1992 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
1993 <tag/Declaration/<tt/unsigned char __fastcall__ cbm_k_save(unsigned int start, unsigned int end)/
1994 <tag/Description/This function saves a section of memory. The cbm_k_setlfs() and cbm_k_setnam() functions must be
1995 used before calling this function. However, a file name is not required to
1996 SAVE to device 1 (the Datassette(TM) recorder). Any attempt to save to
1997 other devices without using a file name results in an error. NOTE: Device 0 (the keyboard), device 2 (RS-232), and device 3 (the screen) cannot be SAVEd to. If the attempt is made, an error occurs, and the SAVE is stopped.
1998 <tag/Notes/<itemize>
1999 <item>The function is only available as fastcall function, so it may
2000 only be used in presence of a prototype.
2002 <tag/Availability/cc65
2004 <ref id="cbm_k_load" name="cbm_k_load">,
2005 <ref id="cbm_k_setlfs" name="cbm_k_setlfs">,
2006 <ref id="cbm_k_setnam" name="cbm_k_setnam">
2012 <sect1>cbm_k_setlfs<label id="cbm_k_setlfs"><p>
2016 <tag/Function/Set up a logical file
2017 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
2018 <tag/Declaration/<tt/void __fastcall__ cbm_k_setlfs (unsigned char LFN, unsigned char DEV, unsigned char SA);/
2019 <tag/Description/This functions sets up the logical file by setting its number, device address,
2020 and secondary address.
2021 <tag/Notes/<itemize>
2022 <item>The function is only available as fastcall function, so it may
2023 only be used in presence of a prototype.
2025 <tag/Availability/cc65
2027 <ref id="cbm_k_setnam" name="cbm_k_setnam">
2033 <sect1>cbm_k_setnam<label id="cbm_k_setnam"><p>
2037 <tag/Function/Set Filename Parameters
2038 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
2039 <tag/Declaration/<tt/void __fastcall__ cbm_k_setnam (const char* Name);/
2040 <tag/Description/This function is used to set up the file name for the OPEN,
2041 SAVE, or LOAD operations.
2042 <tag/Notes/<itemize>
2043 <item>The function is only available as fastcall function, so it may
2044 only be used in presence of a prototype.
2046 <tag/Availability/cc65
2048 <ref id="cbm_k_open" name="cbm_k_open">,
2049 <ref id="cbm_k_load" name="cbm_k_load">,
2050 <ref id="cbm_k_save" name="cbm_k_save">
2056 <sect1>cbm_k_talk<label id="cbm_k_talk"><p>
2060 <tag/Function/Commands device to TALK
2061 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
2062 <tag/Declaration/<tt/void __fastcall__ cbm_k_talk (unsigned char dev);/
2063 <tag/Description/When called, it ORs the device number with the TALK code (64, $40) and sends it on the serial
2064 bus. This commands the device to TALK.
2065 <tag/Notes/<itemize>
2066 <item>The function is only available as fastcall function, so it may
2067 only be used in presence of a prototype.
2069 <tag/Availability/cc65
2071 <ref id="cbm_k_acptr" name="cbm_k_acptr">
2077 <sect1>cbm_k_unlsn<label id="cbm_k_unlsn"><p>
2081 <tag/Function/Send an UNLISTEN command
2082 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
2083 <tag/Declaration/<tt/void cbm_k_unlsn (void);/
2084 <tag/Description/This function commands all devices on the serial bus to
2085 stop receiving data from the host computer (i.e., UNLISTEN). Calling this
2086 function results in an UNLISTEN command being transmitted on the serial
2087 bus. Only devices previously commanded to LISTEN are affected. This
2088 function is normally used after the host computer is finished sending data
2089 to external devices. Sending the UNLISTEN commands the listening devices
2090 to get off the serial bus so it can be used for other purposes.
2091 <tag/Notes/<itemize>
2094 <tag/Availability/cc65
2096 <ref id="cbm_k_listen" name="cbm_k_listen">
2102 <sect1>cclear<label id="cclear"><p>
2106 <tag/Function/Clear part of a line (write a given number of spaces).
2107 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2108 <tag/Declaration/<tt/void __fastcall__ cclear (unsigned char length);/
2109 <tag/Description/The function clears part of a line by writing <tt/length/
2110 spaces in the current text color.
2111 <tag/Notes/<itemize>
2112 <item>The function is only available as fastcall function, so it may
2113 only be used in presence of a prototype.
2115 <tag/Availability/cc65
2117 <ref id="cclearxy" name="cclearxy">,
2118 <ref id="clrscr" name="clrscr">
2124 <sect1>cclearxy<label id="cclearxy"><p>
2128 <tag/Function/Clear part of a line (write a given number of spaces) starting
2129 at a specific screen position.
2130 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2131 <tag/Declaration/<tt/void __fastcall__ cclearxy (unsigned char x, unsigned char y, unsigned char length);/
2132 <tag/Description/The function moves the cursor to a specific position, and
2133 will then clear part of the line by writing <tt/length/ spaces in the current
2135 <tag/Notes/<itemize>
2136 <item>The function is only available as fastcall function, so it may
2137 only be used in presence of a prototype.
2139 <tag/Availability/cc65
2141 <ref id="cclear" name="cclear">,
2142 <ref id="clrscr" name="clrscr">
2148 <sect1>cgetc<label id="cgetc"><p>
2152 <tag/Function/Read a character from the keyboard.
2153 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2154 <tag/Declaration/<tt/char cgetc (void);/
2155 <tag/Description/The function reads a character from the keyboard. If there is
2156 no character available, <tt/cgetc/ waits until the user presses a key. If the
2157 cursor is enabled by use of the <tt/cursor/ function, a blinking cursor is
2158 displayed while waiting.
2159 <tag/Notes/<itemize>
2160 <item>If the system supports a keyboard buffer, <tt/cgetc/ will fetch a key
2161 from this buffer and wait only if the buffer is empty.
2163 <tag/Availability/cc65
2165 <ref id="cursor" name="cursor">,
2166 <ref id="kbhit" name="kbhit">
2172 <sect1>chline<label id="chline"><p>
2176 <tag/Function/Output a horizontal line in text mode.
2177 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2178 <tag/Declaration/<tt/void __fastcall__ chline (unsigned char length);/
2179 <tag/Description/The function outputs a horizontal line with the given length
2180 starting at the current cursor position.
2181 <tag/Notes/<itemize>
2182 <item>The character used to draw the horizontal line is system dependent.
2183 If available, a line drawing character is used. Drawing a line that is partially
2184 off screen leads to undefined behaviour.
2185 <item>The function is only available as fastcall function, so it may only be
2186 used in presence of a prototype.
2188 <tag/Availability/cc65
2190 <ref id="chlinexy" name="chlinexy">,
2191 <ref id="cvline" name="cvline">,
2192 <ref id="cvlinexy" name="cvlinexy">
2198 <sect1>chlinexy<label id="chlinexy"><p>
2202 <tag/Function/Output a horizontal line at a given position in text mode.
2203 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2204 <tag/Declaration/<tt/void __fastcall__ chlinexy (unsigned char x, unsigned char y, unsigned char length);/
2205 <tag/Description/The function outputs a horizontal line with the given length
2206 starting at a given position.
2207 <tag/Notes/<itemize>
2208 <item>The character used to draw the horizontal line is system dependent.
2209 If available, a line drawing character is used. Drawing a line that is partially
2210 off screen leads to undefined behaviour.
2211 <item>The function is only available as fastcall function, so it may only be
2212 used in presence of a prototype.
2214 <tag/Availability/cc65
2216 <ref id="chline" name="chline">,
2217 <ref id="cvline" name="cvline">,
2218 <ref id="cvlinexy" name="cvlinexy">
2224 <sect1>clearerr<label id="clearerr"><p>
2228 <tag/Function/Clear error and end-of-file status of a stream.
2229 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
2230 <tag/Declaration/<tt/void __fastcall__ clearerr (FILE* f);/
2231 <tag/Description/<tt/clearerr/ clears the error and end-of-file status
2232 indicators for the stream <tt/f/.
2233 <tag/Notes/<itemize>
2234 <item>The function is only available as fastcall function, so it may only be
2235 used in presence of a prototype.
2237 <tag/Availability/ISO 9899
2239 <ref id="feof" name="feof">,
2240 <ref id="ferror" name="ferror">
2246 <sect1>clock<label id="clock"><p>
2250 <tag/Function/Determine the processor time used.
2251 <tag/Header/<tt/<ref id="time.h" name="time.h">/
2252 <tag/Declaration/<tt/clock_t clock (void);/
2253 <tag/Description/The <tt/clock/ function returns an approximaton of processor
2254 time used by the program. The time is returned in implementation defined
2255 units. It can be converted to seconds by dividing by the value of the macro
2256 <tt/CLOCKS_PER_SEC/.
2257 <tag/Notes/<itemize>
2258 <item>Since the machines, cc65 generated programs run on, cannot run multiple
2259 processes, the function will actually return the time since some
2260 implementation defined point in the past.
2262 <tag/Availability/ISO 9899
2264 <ref id="time" name="time">
2270 <sect1>clrscr<label id="clrscr"><p>
2274 <tag/Function/Clear the text screen.
2275 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2276 <tag/Declaration/<tt/void clrscr (void);/
2277 <tag/Description/The function clears the text screen and moves the cursor to
2278 the upper left corner.
2279 <tag/Availability/cc65
2281 <ref id="cclear" name="cclear">,
2282 <ref id="cclearxy" name="cclearxy">
2288 <sect1>close<label id="close"><p>
2292 <tag/Function/Close a file descriptor.
2293 <tag/Header/<tt/<ref id="fcntl.h" name="fcntl.h">/
2294 <tag/Declaration/<tt/int __fastcall__ close (int fd);/
2295 <tag/Description/The function closes the given file descriptor. It returns zero
2296 on success and -1 on error. If an error occurs, the cause can be determined by
2297 reading the <tt/errno/ variable.
2298 <tag/Notes/<itemize>
2299 <item>The function is only available as fastcall function, so it may only
2300 be used in presence of a prototype.
2302 <tag/Availability/POSIX 1003.1
2304 <ref id="creat" name="creat">,
2305 <ref id="open" name="open">
2311 <sect1>closedir<label id="closedir"><p>
2315 <tag/Function/Close a directory.
2316 <tag/Header/<tt/<ref id="dirent.h" name="dirent.h">/
2317 <tag/Declaration/<tt/int __fastcall__ closedir (DIR* dir);/
2318 <tag/Description/The function closes the given directory descriptor. It returns
2319 zero on success and -1 on error. If an error occurs, the cause can be determined
2320 by reading the <tt/errno/ variable.
2321 <tag/Notes/<itemize>
2322 <item>The function is only available as fastcall function, so it may only
2323 be used in presence of a prototype.
2325 <tag/Availability/POSIX 1003.1
2327 <ref id="opendir" name="opendir">,
2328 <ref id="readdir" name="readdir">
2334 <sect1>creat<label id="creat"><p>
2338 <tag/Function/Create a file.
2339 <tag/Header/<tt/<ref id="fcntl.h" name="fcntl.h">/
2340 <tag/Declaration/<tt/int __fastcall__ creat (const char* name, unsigned mode);/
2341 <tag/Description/<tt/creat/ creates a new file and returns the file descriptor
2342 associated with it. On error, -1 is returned and an error code is stored in
2344 <tag/Notes/<itemize>
2345 <item><tt/creat/ is identical to calling <tt/<ref id="open" name="open">/ with
2346 <tt/flags/ equal to <tt/O_WRONLY | O_CREAT | O_TRUNC/.
2347 <item>The function is only available as fastcall function, so it may only
2348 be used in presence of a prototype.
2350 <tag/Availability/POSIX 1003.1
2352 <ref id="close" name="close">,
2353 <ref id="open" name="open">
2359 <sect1>cprintf<label id="cprintf"><p>
2363 <tag/Function/Formatted output to the console.
2364 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2365 <tag/Declaration/<tt/int cprintf (const char* format, ...);/
2366 <tag/Description/The arguments are converted to text where necessary and
2367 formatted according to the format string given. The resulting string is output
2368 to the console. <tt/cprintf/ supports the same format specifiers as
2369 <tt/printf/. <!-- <tt/<ref id="printf" name="printf">/. -->
2370 <tag/Notes/<itemize>
2371 <item>Like all other <tt/conio/ output functions, <tt/cprintf/ distinguishes
2372 between <tt/\r/ and <tt/\n/.
2374 <tag/Availability/cc65
2376 <ref id="cputc" name="cputc">,
2377 <ref id="cputcxy" name="cputcxy">,
2378 <ref id="cputs" name="cputs">,
2379 <ref id="cputsxy" name="cputsxy">,
2380 <ref id="vcprintf" name="vcprintf">
2386 <sect1>cputc<label id="cputc"><p>
2390 <tag/Function/Output a character directly to the console.
2391 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2392 <tag/Declaration/<tt/void __fastcall__ cputc (char c);/
2393 <tag/Description/Output one character to the console at the current cursor
2395 <tag/Notes/<itemize>
2396 <item>Like all other <tt/conio/ output functions, <tt/cputc/ distinguishes
2397 between <tt/\r/ and <tt/\n/.
2398 <item>The function is only available as fastcall function, so it may only
2399 be used in presence of a prototype.
2401 <tag/Availability/cc65
2403 <ref id="cprintf" name="cprintf">,
2404 <ref id="cputcxy" name="cputcxy">,
2405 <ref id="cputs" name="cputs">,
2406 <ref id="cputsxy" name="cputsxy">,
2407 <ref id="vcprintf" name="vcprintf">
2413 <sect1>cputcxy<label id="cputcxy"><p>
2417 <tag/Function/Output a character at a specific screen position.
2418 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2419 <tag/Declaration/<tt/void __fastcall__ cputcxy (unsigned char x, unsigned char y, char c);/
2420 <tag/Description/<tt/cputcxy/ moves the cursor to the given x/y position on
2421 the screen and outputs one character.
2422 <tag/Notes/<itemize>
2423 <item>Like all other <tt/conio/ output functions, <tt/cputcxy/ distinguishes
2424 between <tt/\r/ and <tt/\n/.
2425 <item>The function is only available as fastcall function, so it may only
2426 be used in presence of a prototype.
2428 <tag/Availability/cc65
2430 <ref id="cprintf" name="cprintf">,
2431 <ref id="cputc" name="cputc">,
2432 <ref id="cputs" name="cputs">,
2433 <ref id="cputsxy" name="cputsxy">,
2434 <ref id="vcprintf" name="vcprintf">
2440 <sect1>cputs<label id="cputs"><p>
2444 <tag/Function/Output a string directly to the console.
2445 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2446 <tag/Declaration/<tt/void __fastcall__ cputs (const char* s);/
2447 <tag/Description/The function outputs the given string on the console at the
2448 current cursor position.
2449 <tag/Notes/<itemize>
2450 <item>Like all other <tt/conio/ output functions, <tt/cputs/ distinguishes
2451 between <tt/\r/ and <tt/\n/.
2452 <item>The function is only available as fastcall function, so it may only
2453 be used in presence of a prototype.
2455 <tag/Availability/cc65
2457 <ref id="cprintf" name="cprintf">,
2458 <ref id="cputc" name="cputc">,
2459 <ref id="cputcxy" name="cputcxy">,
2460 <ref id="cputsxy" name="cputsxy">,
2461 <ref id="vcprintf" name="vcprintf">
2467 <sect1>cputsxy<label id="cputsxy"><p>
2471 <tag/Function/Output a string to the console at a given position.
2472 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2473 <tag/Declaration/<tt/void __fastcall__ cputsxy (unsigned char x, unsigned char y, const char* s);/
2474 <tag/Description/<tt/cputsxy/ moves the cursor to the given x/y position,
2475 and outputs the string <tt/s/.
2476 <tag/Notes/<itemize>
2477 <item>Like all other <tt/conio/ output functions, <tt/cputsxy/ distinguishes
2478 between <tt/\r/ and <tt/\n/.
2479 <item>The function is only available as fastcall function, so it may only
2480 be used in presence of a prototype.
2482 <tag/Availability/cc65
2484 <ref id="cprintf" name="cprintf">,
2485 <ref id="cputc" name="cputc">,
2486 <ref id="cputcxy" name="cputcxy">,
2487 <ref id="cputs" name="cputs">,
2488 <ref id="vcprintf" name="vcprintf">
2494 <sect1>cursor<label id="cursor"><p>
2498 <tag/Function/Enable/disable a blinking cursor when waiting for keyboard input.
2499 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2500 <tag/Declaration/<tt/unsigned char __fastcall__ cursor (unsigned char onoff);/
2501 <tag/Description/If the argument to the function is non zero, a blinking cursor
2502 will be enabled when the <tt/cgetc/ function waits for input from the keyboard.
2503 If the argument is zero, <tt/cgetc/ will wait without a blinking cursor.
2504 <tag/Notes/<itemize>
2505 <item>The function is only available as fastcall function, so it may only
2506 be used in presence of a prototype.
2508 <tag/Availability/cc65
2510 <ref id="cgetc" name="cgetc">,
2511 <ref id="kbhit" name="kbhit">
2517 <sect1>cvline<label id="cvline"><p>
2521 <tag/Function/Output a vertical line in text mode.
2522 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2523 <tag/Declaration/<tt/void __fastcall__ cvline (unsigned char length);/
2524 <tag/Description/The function outputs a vertical line with the given length
2525 starting at the current cursor position.
2526 <tag/Notes/<itemize>
2527 <item>The character used to draw the vertical line is system dependent.
2528 If available, a line drawing character is used. Drawing a line that is partially
2529 off screen leads to undefined behaviour.
2530 <item>The function is only available as fastcall function, so it may only be
2531 used in presence of a prototype.
2533 <tag/Availability/cc65
2535 <ref id="chline" name="chline">,
2536 <ref id="chlinexy" name="chlinexy">,
2537 <ref id="cvlinexy" name="cvlinexy">
2543 <sect1>cvlinexy<label id="cvlinexy"><p>
2547 <tag/Function/Output a vertical line at a given position in text mode.
2548 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2549 <tag/Declaration/<tt/void __fastcall__ cvlinexy (unsigned char x, unsigned char y, unsigned char length);/
2550 <tag/Description/The function outputs a vertical line with the given length
2551 starting at a given position.
2552 <tag/Notes/<itemize>
2553 <item>The character used to draw the vertical line is system dependent.
2554 If available, a line drawing character is used. Drawing a line that is partially
2555 off screen leads to undefined behaviour.
2556 <item>The function is only available as fastcall function, so it may only be
2557 used in presence of a prototype.
2559 <tag/Availability/cc65
2561 <ref id="chline" name="chline">,
2562 <ref id="chlinexy" name="chlinexy">,
2563 <ref id="cvline" name="cvline">
2569 <sect1>div<label id="div"><p>
2573 <tag/Function/Divide two ints and return quotient and remainder.
2574 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
2575 <tag/Declaration/<tt/div_t __fastcall__ div (int numer, int denom);/
2576 <tag/Description/<tt/div/ divides <tt/numer/ by <tt/denom/ and returns the
2577 quotient and remainder in a <tt/div_t/ structure.
2578 <tag/Notes/<itemize>
2579 <item>The function is only available as fastcall function, so it may only
2580 be used in presence of a prototype.
2582 <tag/Availability/ISO 9899
2590 <sect1>em_commit<label id="em_commit"><p>
2594 <tag/Function/Commit changes into extended memory.
2595 <tag/Header/<tt/<ref id="em.h" name="em.h">/
2596 <tag/Declaration/<tt/void em_commit (void);/
2597 <tag/Description/Commit changes in the memory window to extended storage. If
2598 the contents of the memory window have been changed, these changes may be lost
2599 if <tt/<ref id="em_map" name="em_map">/, <tt/<ref id="em_use" name="em_use">/,
2600 <tt/<ref id="em_copyfrom" name="em_copyfrom">/ or <tt/<ref id="em_copyto"
2601 name="em_copyto">/ are called without calling <tt/em_commit/ first.
2602 <tag/Notes/<itemize>
2603 <item>Calling <tt/em_commit/ does not necessarily mean that changes to the
2604 memory window are discarded, it does just mean that the drivers is allowed
2606 <item>The function is only available as fastcall function, so it may only be
2607 used in presence of a prototype.
2608 <item>The function produces undefined results if no extended memory driver is
2611 <tag/Availability/cc65
2613 <ref id="em_load_driver" name="em_load_driver">,
2614 <ref id="em_map" name="em_map">,
2615 <ref id="em_use" name="em_use">
2621 <sect1>em_copyfrom<label id="em_copyfrom"><p>
2625 <tag/Function/Copy from extended into normal memory.
2626 <tag/Header/<tt/<ref id="em.h" name="em.h">/
2627 <tag/Declaration/<tt/void __fastcall__ em_copyfrom (const struct em_copy* copy_data);/
2628 <tag/Description/Copy data from extended memory into linear memory. Source and
2629 target addresses as well as the number of bytes to transfer are specified in
2630 the <tt/em_copy/ structure that is passed as a parameter.
2631 <tag/Notes/<itemize>
2632 <item>Calling <tt/em_copyfrom/ will invalidate the memory window, so if you
2633 made any changes to the data in the window, call <tt/<ref id="em_commit"
2634 name="em_commit">/ first, or the changes are lost.
2635 <item>The function is only available as fastcall function, so it may only be
2636 used in presence of a prototype.
2637 <item>The function produces undefined results if no extended memory driver is
2640 <tag/Availability/cc65
2642 <ref id="em_commit" name="em_commit">,
2643 <ref id="em_copyto" name="em_copyto">,
2644 <ref id="em_load_driver" name="em_load_driver">
2650 <sect1>em_copyto<label id="em_copyto"><p>
2654 <tag/Function/Copy from normal into extended memory.
2655 <tag/Header/<tt/<ref id="em.h" name="em.h">/
2656 <tag/Declaration/<tt/void __fastcall__ em_copyto (const struct em_copy* copy_data);/
2657 <tag/Description/Copy data from linear into extended memory. Source and
2658 target addresses as well as the number of bytes to transfer are specified in
2659 the <tt/em_copy/ structure that is passed as a parameter.
2660 <tag/Notes/<itemize>
2661 <item>Calling <tt/em_copyto/ will invalidate the memory window, so if you
2662 made any changes to the data in the window, call <tt/<ref id="em_commit"
2663 name="em_commit">/ first, or the changes are lost.
2664 <item>The function is only available as fastcall function, so it may only be
2665 used in presence of a prototype.
2666 <item>The function produces undefined results if no extended memory driver is
2669 <tag/Availability/cc65
2671 <ref id="em_commit" name="em_commit">,
2672 <ref id="em_copyfrom" name="em_copyfrom">,
2673 <ref id="em_load_driver" name="em_load_driver">
2679 <sect1>em_install<label id="em_install"><p>
2683 <tag/Function/Install an already loaded extended memory driver.
2684 <tag/Header/<tt/<ref id="em.h" name="em.h">/
2685 <tag/Declaration/<tt/unsigned char _fastcall__ em_install (void* driver);/
2686 <tag/Description/The function installs an already loaded extended memory driver
2687 and returns an error code. The function may be used to install a driver linked
2688 statically to the program.
2689 <tag/Notes/<itemize>
2690 <item>Not all drivers are able to detect if the supported hardware is really
2692 <item>The function is only available as fastcall function, so it may only be
2693 used in presence of a prototype.
2695 <tag/Availability/cc65
2697 <ref id="em_load_driver" name="em_load_driver">,
2698 <ref id="em_uninstall" name="em_uninstall">,
2699 <ref id="em_unload" name="em_unload">
2705 <sect1>em_load_driver<label id="em_load_driver"><p>
2709 <tag/Function/Load and initialize an extended memory driver.
2710 <tag/Header/<tt/<ref id="em.h" name="em.h">/
2711 <tag/Declaration/<tt/void __fastcall__ em_load_driver (const char* name);/
2712 <tag/Description/Load an extended memory driver into memory and initialize
2713 it. The function returns an error code that tells if all this has been
2715 <tag/Notes/<itemize>
2716 <item>Not all drivers are able to detect if the supported hardware is really
2718 <item>The function is only available as fastcall function, so it may only be
2719 used in presence of a prototype.
2720 <item>The driver is loaded by name, so currently you must know the type of
2721 extended memory that should be supported. There is no autodetect capability.
2723 <tag/Availability/cc65
2725 <ref id="em_unload" name="em_unload">
2731 <sect1>em_map<label id="em_map"><p>
2735 <tag/Function/Make a page of extended memory accessible.
2736 <tag/Header/<tt/<ref id="em.h" name="em.h">/
2737 <tag/Declaration/<tt/void* __fastcall__ em_map (unsigned page);/
2738 <tag/Description/The function maps one page of extended memory into linear
2739 memory and returns a pointer to the page frame. Depending on the hardware
2740 and driver, the data is either mapped into the address space or transfered
2741 into a buffer. If you don't need the actual contents of the page (for example
2742 because you're going to overwrite it completely), it is better to call
2743 <tt/<ref id="em_use" name="em_use">/ instead. <tt/em_use/ will not transfer the
2744 data if it is possible to avoid that.
2745 <tag/Notes/<itemize>
2746 <item>Calling <tt/em_map/ will invalidate the memory window, so if you
2747 made any changes to the data in the window, call <tt/<ref id="em_commit"
2748 name="em_commit">/ first, or the changes are lost.
2749 <item>The function is only available as fastcall function, so it may only be
2750 used in presence of a prototype.
2751 <item>The function produces undefined results if no extended memory driver is
2754 <tag/Availability/cc65
2756 <ref id="em_commit" name="em_commit">,
2757 <ref id="em_load_driver" name="em_load_driver">,
2758 <ref id="em_use" name="em_use">
2764 <sect1>em_pagecount<label id="em_pagecount"><p>
2768 <tag/Function/Return the number of available extended memory pages.
2769 <tag/Header/<tt/<ref id="em.h" name="em.h">/
2770 <tag/Declaration/<tt/unsigned em_pagecount (void);/
2771 <tag/Description/The function returns the size of the extended memory supported
2772 by the driver in 256 byte pages.
2773 <tag/Notes/<itemize>
2774 <item>The function returns zero if no extended memory driver is loaded.
2775 <item>The function may return zero if the supported hardware was not detected.
2777 <tag/Availability/cc65
2779 <ref id="em_load_driver" name="em_load_driver">
2785 <sect1>em_uninstall<label id="em_uninstall"><p>
2789 <tag/Function/Uninstall an already loaded extended memory driver.
2790 <tag/Header/<tt/<ref id="em.h" name="em.h">/
2791 <tag/Declaration/<tt/unsigned char em_uninstall (void);/
2792 <tag/Description/The function uninstalls an already loaded extended memory
2793 driver but doesn't remove it from memory.
2794 <tag/Notes/<itemize>
2795 <item>If the driver has been loaded using <tt/<ref id="em_load_driver"
2796 name="em_load_driver">/, <tt/<ref id="em_unload" name="em_unload">/
2797 should be used instead of <tt/em_uninstall/ so the driver is also removed
2800 <tag/Availability/cc65
2802 <ref id="em_install" name="em_install">,
2803 <ref id="em_load_driver" name="em_load_driver">,
2804 <ref id="em_unload" name="em_unload">
2810 <sect1>em_unload<label id="em_unload"><p>
2814 <tag/Function/Unload an extended memory driver.
2815 <tag/Header/<tt/<ref id="em.h" name="em.h">/
2816 <tag/Declaration/<tt/unsigned char em_unload (void);/
2817 <tag/Description/The function unloads a loaded extended memory driver and
2818 frees all memory allocated for the driver.
2819 <tag/Notes/<itemize>
2820 <item>The function does nothing if no driver is loaded.
2822 <tag/Availability/cc65
2824 <ref id="em_load_driver" name="em_load_driver">
2830 <sect1>em_use<label id="em_use"><p>
2834 <tag/Function/Prepare an extended memory page for use.
2835 <tag/Header/<tt/<ref id="em.h" name="em.h">/
2836 <tag/Declaration/<tt/void* __fastcall__ em_use (unsigned page);/
2837 <tag/Description/The function maps one page of extended memory into linear
2838 memory and returns a pointer to the page frame. This function is similar to
2839 <tt/<ref id="em_map" name="em_map">/, but will not transfer data into the
2840 actual memory window in the assumption that the existing data is wrong or
2841 will get overwritten.
2842 <tag/Notes/<itemize>
2843 <item>Calling <tt/em_use/ will invalidate the memory window, so if you
2844 made any changes to the data in the window, call <tt/<ref id="em_commit"
2845 name="em_commit">/ first, or the changes are lost.
2846 <item>The function is only available as fastcall function, so it may only be
2847 used in presence of a prototype.
2848 <item>The function produces undefined results if no extended memory driver is
2851 <tag/Availability/cc65
2853 <ref id="em_commit" name="em_commit">,
2854 <ref id="em_load_driver" name="em_load_driver">,
2855 <ref id="em_map" name="em_map">
2861 <sect1>exit<label id="exit"><p>
2865 <tag/Function/Terminate the program.
2866 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
2867 <tag/Declaration/<tt/void __fastcall__ exit (int status);/
2868 <tag/Description/<tt/exit/ terminates the program. The argument specifies the
2869 return code of the program. Before termination, all files are closed, buffered
2870 output is written and any functions registered with <tt/<ref id="atexit"
2871 name="atexit">/ are called. Common values for status are <tt/EXIT_SUCCESS/ and
2872 <tt/EXIT_FAILURE/ which are also defined in <tt/<ref id="stdlib.h"
2874 <tag/Notes/<itemize>
2875 <item>The function is only available as fastcall function, so it may only
2876 be used in presence of a prototype.
2877 <item>It depends on the host machine if the program return code can be
2878 evaluated or is ignored.
2880 <tag/Availability/ISO 9899
2882 <ref id="abort" name="abort">,
2883 <ref id="exit" name="exit">
2889 <sect1>exec<label id="exec"><p>
2893 <tag/Function/Execute a program file.
2894 <tag/Header/<tt/<ref id="unistd.h" name="unistd.h">/
2895 <tag/Declaration/<tt/int __fastcall__ exec (const char* progname, const char* cmdline);/
2896 <tag/Description/<tt/exec/ replaces the currently running program by a new one.
2897 Calling <tt/exec()/ is identical to calling <tt/<ref id="exit" name="exit()">/,
2898 then loading and starting the program named in the first argument, passing
2899 the command line specified as second argument. Instead of an empty string,
2900 a <tt/NULL/ pointer may be passed as second parameter.
2901 On success, the function does not return. On failure, -1 is returned and
2902 <tt/errno/ contains an error code.
2903 <tag/Notes/<itemize>
2904 <item>The function is only available as fastcall function, so it may only
2905 be used in presence of a prototype.
2906 <item>On most platforms, the function needs to copy a small stub loader to
2907 some memory area outside the program space. This may collide with other
2908 programs. See the platform specific docs on this.
2909 <item>Because it is necessary to terminate the running program before the
2910 memory can be reused to load the new one, there is a high chance that the
2911 function may not be able to return on errors.
2912 <item>The command line is passed to the new program in the same way as cc65
2913 programs expect the command line. If the new program is not a cc65 generated
2914 program, it may not be able to read it.
2916 <tag/Availability/cc65
2918 <ref id="exit" name="exit">
2924 <sect1>fast<label id="fast"><p>
2928 <tag/Function/Switch the C128 into 2MHz mode.
2929 <tag/Header/<tt/<ref id="c128.h" name="c128.h">/
2930 <tag/Declaration/<tt/void fast (void);/
2931 <tag/Description/The function will switch the clock of the C128 to 2MHz. This
2932 will nearly double the speed compared to slow mode.
2933 <tag/Notes/<itemize>
2934 <item>The function is specific to the C128.
2935 <item>2MHz clock will not work in 40 column mode.
2937 <tag/Availability/C128
2939 <ref id="slow" name="slow">,
2940 <ref id="toggle_videomode" name="toggle_videomode">,
2941 <ref id="videomode" name="videomode">
2947 <sect1>feof<label id="feof"><p>
2951 <tag/Function/Return the end-of-file indicator of a stream.
2952 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
2953 <tag/Declaration/<tt/int __fastcall__ feof (FILE* f);/
2954 <tag/Description/<tt/feof/ tests the end-of-file indicator ofthe stream
2955 <tt/f/, and returns a non zero value if it is set.
2956 <tag/Notes/<itemize>
2957 <item>The indicator is set only after a read past the end of a file is
2959 <item>The function is only available as fastcall function, so it may only be
2960 used in presence of a prototype.
2962 <tag/Availability/ISO 9899
2964 <ref id="feof" name="clearerr">,
2965 <ref id="ferror" name="ferror">
2971 <sect1>ferror<label id="ferror"><p>
2975 <tag/Function/Return the error indicator of a stream.
2976 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
2977 <tag/Declaration/<tt/int __fastcall__ ferror (FILE* f);/
2978 <tag/Description/<tt/ferror/ tests the error indicator of the stream
2979 <tt/f/, and returns a non zero value if it is set.
2980 <tag/Notes/<itemize>
2981 <item>The function is only available as fastcall function, so it may only be
2982 used in presence of a prototype.
2984 <tag/Availability/ISO 9899
2986 <ref id="feof" name="clearerr">,
2987 <ref id="ferror" name="feof">
2993 <sect1>fileno<label id="fileno"><p>
2997 <tag/Function/Return the file handle used by a stream.
2998 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
2999 <tag/Declaration/<tt/int __fastcall__ fileno (FILE* f);/
3000 <tag/Description/The <tt/fileno/ function returns the file handle used
3001 internally by a C stream. This file handle (an integer) can be used as a
3002 handle for the POSIX input/output functions.
3003 <tag/Notes/<itemize>
3004 <item>The function is only available as fastcall function, so it may only be
3005 used in presence of a prototype.
3006 <item>Mixing C file I/O functions and POSIX file I/O functions for the same
3007 file may have unpredictable results.
3009 <tag/Availability/POSIX 1003.1
3011 <ref id="creat" name="creat">,
3012 <ref id="open" name="open"> <!-- , -->
3013 <!-- <ref id="read" name="read">, -->
3014 <!-- <ref id="write" name="write"> -->
3020 <sect1>free<label id="free"><p>
3024 <tag/Function/Free a block of dynamic memory.
3025 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
3026 <tag/Declaration/<tt/void __fastcall__ free (void* block);/
3027 <tag/Description/Free a block of dynamic memory previously allocated with
3028 <tt/<ref id="malloc" name="malloc">/, <tt/<ref id="calloc" name="calloc">/
3029 or <tt/<ref id="realloc" name="realloc">/. As an exception, if the passed
3030 pointer is <tt/NULL/, no action is performed.
3031 <tag/Notes/<itemize>
3032 <item>Passing an already free'd block to <tt/free/ again will cause undefined
3033 behaviour and may crash your program.
3034 <item>The function is only available as fastcall function, so it may only
3035 be used in presence of a prototype.
3037 <tag/Availability/ISO 9899
3039 <ref id="_heapadd" name="_heapadd">,
3040 <ref id="_heapblocksize" name="_heapblocksize">,
3041 <ref id="_heapmaxavail" name="_heapmaxavail">,
3042 <ref id="_heapmemavail" name="_heapmemavail">,
3043 <ref id="calloc" name="calloc">,
3044 <ref id="malloc" name="malloc">,
3045 <ref id="realloc" name="realloc">
3051 <sect1>get_ostype<label id="get_ostype"><p>
3055 <tag/Function/The function returns the operating system, the program runs on.
3056 <tag/Header/<tt/<ref id="apple2.h" name="apple2.h">,
3057 <ref id="atari.h" name="atari.h">, <ref id="c64.h" name="c64.h">/
3058 <tag/Declaration/<tt/unsigned char get_ostype (void);/
3059 <tag/Description/<tt/get_ostype/ is machine dependent and does not exist for
3060 all supported targets. If it exists, it returns a number that identifies the
3061 operating system or machine type, the program runs on. The machine dependent
3062 header files define constants that can be used to check the return code.
3063 <tag/Notes/<itemize>
3064 <item>The function does not exist on all platforms.
3065 <item>The return codes are platform dependent.
3067 <tag/Availability/cc65 (not all platforms)
3073 <sect1>getcpu<label id="getcpu"><p>
3077 <tag/Function/Determine on which CPU the program is running.
3078 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
3079 <tag/Declaration/<tt/unsigned char getcpu (void);/
3080 <tag/Description/The function checks on which CPU the code is running. It
3081 returns one of the constants<itemize>
3083 <item><tt/CPU_65C02/
3084 <item><tt/CPU_65816/
3086 <tag/Notes/<itemize>
3087 <item>Other, more exotic CPU types are not disinguished.
3089 <tag/Availability/cc65
3095 <sect1>getenv<label id="getenv"><p>
3099 <tag/Function/Return a value from the environment.
3100 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
3101 <tag/Declaration/<tt/char* __fastcall__ getenv (const char* name);/
3102 <tag/Description/The function searches the environment for an entry that
3103 matches <tt/name/ and returns its value. The environment consists of a list
3104 of strings in the form <tt/name=value/. If there is no match, <tt/getenv/
3106 <tag/Notes/<itemize>
3107 <item>What exactly is stored in the environment depends on the machine the
3108 program is running on.
3109 <item>The function is only available as fastcall function, so it may only
3110 be used in presence of a prototype.
3112 <tag/Availability/ISO 9899
3118 <sect1>getopt<label id="getopt"><p>
3122 <tag/Function/Parse command line options.
3123 <tag/Header/<tt/<ref id="unistd.h" name="unistd.h">/
3124 <tag/Declaration/<tt/int __fastcall__ getopt (int argc, char* const* argv,
3125 const char* optstring);/
3126 <tag/Description/The function parses command line arguments, <tt/argc/ and
3127 <tt/argv/ are the argument count and array passed to <tt/main/. <tt/optstring/
3128 is a string that contains command line option characters. If a character in
3129 <tt/optstring/ is followed by a colon, the option requires an argument. An
3130 option on the command line is recognized if it is one of the option characters
3132 <tt/getopt/ must be called repeatedly. It will return each option character
3133 found on the command line and <tt/EOF/ (-1) if there is no other option. An
3134 option argument is placed in <tt/optarg/, the index of the next element on the
3135 command line to be processed is placed in <tt/optind/.
3136 <tag/Notes/<itemize>
3137 <item>The implementation will not reorder options. A non option on the command
3138 line will terminate option processing. All remaining arguments are not
3139 recognized as options, even if the start with a '-' character.
3140 <item>The function is only available as fastcall function, so it may only
3141 be used in presence of a prototype.
3143 <tag/Availability/POSIX.2
3149 <sect1>gotox<label id="gotox"><p>
3153 <tag/Function/Move the text mode cursor to a new X position.
3154 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
3155 <tag/Declaration/<tt/void __fastcall__ gotox (unsigned char x);/
3156 <tag/Description/The function moves the text mode cursor to the specified X
3157 position while leaving the Y position untouched. The leftmost position on the
3158 screen has the coordinate 0.
3159 <tag/Notes/<itemize>
3160 <item>The function is only available as fastcall function, so it may
3161 only be used in presence of a prototype.
3162 <item>Invalid values for the X position (out of screen coordinates) may
3163 lead to undefined behaviour.
3165 <tag/Availability/cc65
3167 <ref id="gotoy" name="gotoy">,
3168 <ref id="gotoxy" name="gotoxy">,
3169 <ref id="wherex" name="wherex">,
3170 <ref id="wherey" name="wherey">
3176 <sect1>gotoxy<label id="gotoxy"><p>
3180 <tag/Function/Move the text mode cursor to a new position.
3181 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
3182 <tag/Declaration/<tt/void __fastcall__ gotoxy (unsigned char x, unsigned char y);/
3183 <tag/Description/The function moves the text mode cursor to the specified
3184 position. The leftmost position on the screen has the X coordinate 0, the
3185 topmost line has the Y coordinate 0.
3186 <tag/Notes/<itemize>
3187 <item>The function is only available as fastcall function, so it may only be
3188 used in presence of a prototype.
3189 <item>Invalid values for any of both coordinates (out of screen positions) may
3190 lead to undefined behaviour.
3192 <tag/Availability/cc65
3194 <ref id="gotox" name="gotox">,
3195 <ref id="gotoy" name="gotoy">,
3196 <ref id="wherex" name="wherex">,
3197 <ref id="wherey" name="wherey">
3203 <sect1>gotoy<label id="gotoy"><p>
3207 <tag/Function/Move the text mode cursor to a new Y position.
3208 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
3209 <tag/Declaration/<tt/void __fastcall__ gotoy (unsigned char x);/
3210 <tag/Description/The function moves the text mode cursor to the specified Y
3211 position while leaving the X position untouched. The uppermost position on the
3212 screen has the coordinate 0.
3213 <tag/Notes/<itemize>
3214 <item>The function is only available as fastcall function, so it may
3215 only be used in presence of a prototype.
3216 <item>Invalid values for the Y position (out of screen coordinates) may lead
3217 to undefined behaviour.
3219 <tag/Availability/cc65
3221 <ref id="gotox" name="gotox">,
3222 <ref id="gotoxy" name="gotoxy">,
3223 <ref id="wherex" name="wherex">,
3224 <ref id="wherey" name="wherey">
3230 <sect1>isalnum<label id="isalnum"><p>
3234 <tag/Function/Check if a given character is a letter or digit.
3235 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
3236 <tag/Declaration/<tt/int __fastcall__ isalnum (int c);/
3237 <tag/Description/The function returns a non zero value if the given argument
3238 is a letter or digit. The return value is zero if the character is anything
3240 <tag/Notes/<itemize>
3241 <item>When compiling with <tt/-Os/ the function is actually a macro. The
3242 inline sequence generated by the macro will not work correctly for values
3243 outside the range 0..255. <em/Note:/ The constant <tt/EOF/ is not part of
3244 this range. The non inline function may be accessed by <tt/#undef/'ing
3246 <item>When compiling without <tt/-Os/, the function is only available as
3247 fastcall function, so it may only be used in presence of a prototype.
3249 <tag/Availability/ISO 9899
3251 <ref id="isalpha" name="isalpha">,
3252 <ref id="isascii" name="isascii">,
3253 <ref id="isblank" name="isblank">,
3254 <ref id="iscntrl" name="iscntrl">,
3255 <ref id="isdigit" name="isdigit">,
3256 <ref id="isgraph" name="isgraph">,
3257 <ref id="islower" name="islower">,
3258 <ref id="isprint" name="isprint">,
3259 <ref id="ispunct" name="ispunct">,
3260 <ref id="isspace" name="isspace">,
3261 <ref id="isupper" name="isupper">,
3262 <ref id="isxdigit" name="isxdigit">
3268 <sect1>isalpha<label id="isalpha"><p>
3272 <tag/Function/Check if a given character is a letter.
3273 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
3274 <tag/Declaration/<tt/int __fastcall__ isalpha (int c);/
3275 <tag/Description/The function returns a non zero value if the given argument
3276 is a letter. The return value is zero if the character is anything else.
3277 <tag/Notes/<itemize>
3278 <item>When compiling with <tt/-Os/ the function is actually a macro. The
3279 inline sequence generated by the macro will not work correctly for values
3280 outside the range 0..255. <em/Note:/ The constant <tt/EOF/ is not part of
3281 this range. The non inline function may be accessed by <tt/#undef/'ing the
3283 <item>When compiling without <tt/-Os/, the function is only available as
3284 fastcall function, so it may only be used in presence of a prototype.
3286 <tag/Availability/ISO 9899
3288 <ref id="isalnum" name="isalnum">,
3289 <ref id="isascii" name="isascii">,
3290 <ref id="isblank" name="isblank">,
3291 <ref id="iscntrl" name="iscntrl">,
3292 <ref id="isdigit" name="isdigit">,
3293 <ref id="isgraph" name="isgraph">,
3294 <ref id="islower" name="islower">,
3295 <ref id="isprint" name="isprint">,
3296 <ref id="ispunct" name="ispunct">,
3297 <ref id="isspace" name="isspace">,
3298 <ref id="isupper" name="isupper">,
3299 <ref id="isxdigit" name="isxdigit">
3305 <sect1>isascii<label id="isascii"><p>
3309 <tag/Function/Check if a given character is in the ASCII (0..127) range.
3310 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
3311 <tag/Declaration/<tt/int __fastcall__ isascii (int c);/
3312 <tag/Description/The function returns a non zero value if the given argument
3313 is in the range 0..127 (the range of valid ASCII characters) and zero if not.
3314 <tag/Notes/<itemize>
3315 <item>When compiling with <tt/-Os/ the function is actually a macro. The
3316 inline sequence generated by the macro will not work correctly for values
3317 outside the range 0..255. <em/Note:/ The constant <tt/EOF/ is not part of
3318 this range. The non inline function may be accessed by <tt/#undef/'ing the
3320 <item>When compiling without <tt/-Os/, the function is only available as
3321 fastcall function, so it may only be used in presence of a prototype.
3323 <tag/Availability/ISO 9899
3325 <ref id="isalnum" name="isalnum">,
3326 <ref id="isalpha" name="isalpha">,
3327 <ref id="isblank" name="isblank">,
3328 <ref id="iscntrl" name="iscntrl">,
3329 <ref id="isdigit" name="isdigit">,
3330 <ref id="isgraph" name="isgraph">,
3331 <ref id="islower" name="islower">,
3332 <ref id="isprint" name="isprint">,
3333 <ref id="ispunct" name="ispunct">,
3334 <ref id="isspace" name="isspace">,
3335 <ref id="isupper" name="isupper">,
3336 <ref id="isxdigit" name="isxdigit">
3342 <sect1>isblank<label id="isblank"><p>
3346 <tag/Function/Check if a given character is a space or tab.
3347 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
3348 <tag/Declaration/<tt/int __fastcall__ isblank (int c);/
3349 <tag/Description/The function returns a non zero value if the given argument
3350 is a space or tab character. The return value is zero if the character is
3352 <tag/Notes/<itemize>
3353 <item>When compiling with <tt/-Os/ the function is actually a macro. The
3354 inline sequence generated by the macro will not work correctly for values
3355 outside the range 0..255. <em/Note:/ The constant <tt/EOF/ is not part of
3356 this range. The non inline function may be accessed by <tt/#undef/'ing the
3358 <item>When compiling without <tt/-Os/, the function is only available as
3359 fastcall function, so it may only be used in presence of a prototype.
3361 <tag/Availability/ISO 9899
3363 <ref id="isalnum" name="isalnum">,
3364 <ref id="isalpha" name="isalpha">,
3365 <ref id="isascii" name="isascii">,
3366 <ref id="iscntrl" name="iscntrl">,
3367 <ref id="isdigit" name="isdigit">,
3368 <ref id="isgraph" name="isgraph">,
3369 <ref id="islower" name="islower">,
3370 <ref id="isprint" name="isprint">,
3371 <ref id="ispunct" name="ispunct">,
3372 <ref id="isspace" name="isspace">,
3373 <ref id="isupper" name="isupper">,
3374 <ref id="isxdigit" name="isxdigit">
3380 <sect1>iscntrl<label id="iscntrl"><p>
3384 <tag/Function/Check if a given character is a control character.
3385 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
3386 <tag/Declaration/<tt/int __fastcall__ iscntrl (int c);/
3387 <tag/Description/The function returns a non zero value if the given argument
3388 is a control character. The return value is zero if the character is anything
3390 <tag/Notes/<itemize>
3391 <item>When compiling with <tt/-Os/ the function is actually a macro. The
3392 inline sequence generated by the macro will not work correctly for values
3393 outside the range 0..255. <em/Note:/ The constant <tt/EOF/ is not part of
3394 this range. The non inline function may be accessed by <tt/#undef/'ing the
3396 <item>When compiling without <tt/-Os/, the function is only available as
3397 fastcall function, so it may only be used in presence of a prototype.
3399 <tag/Availability/ISO 9899
3401 <ref id="isalnum" name="isalnum">,
3402 <ref id="isalpha" name="isalpha">,
3403 <ref id="isascii" name="isascii">,
3404 <ref id="isblank" name="isblank">,
3405 <ref id="isdigit" name="isdigit">,
3406 <ref id="isgraph" name="isgraph">,
3407 <ref id="islower" name="islower">,
3408 <ref id="isprint" name="isprint">,
3409 <ref id="ispunct" name="ispunct">,
3410 <ref id="isspace" name="isspace">,
3411 <ref id="isupper" name="isupper">,
3412 <ref id="isxdigit" name="isxdigit">
3418 <sect1>isdigit<label id="isdigit"><p>
3422 <tag/Function/Check if a given character is a digit.
3423 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
3424 <tag/Declaration/<tt/int __fastcall__ isdigit (int c);/
3425 <tag/Description/The function returns a non zero value if the given argument
3426 is a digit. The return value is zero if the character is anything else.
3427 <tag/Notes/<itemize>
3428 <item>When compiling with <tt/-Os/ the function is actually a macro. The
3429 inline sequence generated by the macro will not work correctly for values
3430 outside the range 0..255. <em/Note:/ The constant <tt/EOF/ is not part of
3431 this range. The non inline function may be accessed by <tt/#undef/'ing the
3433 <item>When compiling without <tt/-Os/, the function is only available as
3434 fastcall function, so it may only be used in presence of a prototype.
3436 <tag/Availability/ISO 9899
3438 <ref id="isalnum" name="isalnum">,
3439 <ref id="isalpha" name="isalpha">,
3440 <ref id="isascii" name="isascii">,
3441 <ref id="isblank" name="isblank">,
3442 <ref id="iscntrl" name="iscntrl">,
3443 <ref id="isgraph" name="isgraph">,
3444 <ref id="islower" name="islower">,
3445 <ref id="isprint" name="isprint">,
3446 <ref id="ispunct" name="ispunct">,
3447 <ref id="isspace" name="isspace">,
3448 <ref id="isupper" name="isupper">,
3449 <ref id="isxdigit" name="isxdigit">
3455 <sect1>isgraph<label id="isgraph"><p>
3459 <tag/Function/Check if a given character is a printable character (except
3461 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
3462 <tag/Declaration/<tt/int __fastcall__ isgraph (int c);/
3463 <tag/Description/The function returns a non zero value if the given argument
3464 is a printable character with the exception of space. The return value is zero
3465 if the character is anything else.
3466 <tag/Notes/<itemize>
3467 <item>When compiling with <tt/-Os/ the function is actually a macro. The
3468 inline sequence generated by the macro will not work correctly for values
3469 outside the range 0..255. <em/Note:/ The constant <tt/EOF/ is not part of
3470 this range. The non inline function may be accessed by <tt/#undef/'ing the
3472 <item>When compiling without <tt/-Os/, the function is only available as
3473 fastcall function, so it may only be used in presence of a prototype.
3475 <tag/Availability/ISO 9899
3477 <ref id="isalnum" name="isalnum">,
3478 <ref id="isalpha" name="isalpha">,
3479 <ref id="isascii" name="isascii">,
3480 <ref id="isblank" name="isblank">,
3481 <ref id="iscntrl" name="iscntrl">,
3482 <ref id="isdigit" name="isdigit">,
3483 <ref id="islower" name="islower">,
3484 <ref id="isprint" name="isprint">,
3485 <ref id="ispunct" name="ispunct">,
3486 <ref id="isspace" name="isspace">,
3487 <ref id="isupper" name="isupper">,
3488 <ref id="isxdigit" name="isxdigit">
3494 <sect1>islower<label id="islower"><p>
3498 <tag/Function/Check if a given character is a lower case letter.
3499 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
3500 <tag/Declaration/<tt/int __fastcall__ islower (int c);/
3501 <tag/Description/The function returns a non zero value if the given argument
3502 is a lower case letter. The return value is zero if the character is anything
3504 <tag/Notes/<itemize>
3505 <item>When compiling with <tt/-Os/ the function is actually a macro. The
3506 inline sequence generated by the macro will not work correctly for values
3507 outside the range 0..255. <em/Note:/ The constant <tt/EOF/ is not part of
3508 this range. The non inline function may be accessed by <tt/#undef/'ing the
3510 <item>When compiling without <tt/-Os/, the function is only available as
3511 fastcall function, so it may only be used in presence of a prototype.
3513 <tag/Availability/ISO 9899
3515 <ref id="isalnum" name="isalnum">,
3516 <ref id="isalpha" name="isalpha">,
3517 <ref id="isascii" name="isascii">,
3518 <ref id="isblank" name="isblank">,
3519 <ref id="iscntrl" name="iscntrl">,
3520 <ref id="isdigit" name="isdigit">,
3521 <ref id="isgraph" name="isgraph">,
3522 <ref id="isprint" name="isprint">,
3523 <ref id="ispunct" name="ispunct">,
3524 <ref id="isspace" name="isspace">,
3525 <ref id="isupper" name="isupper">,
3526 <ref id="isxdigit" name="isxdigit">
3532 <sect1>isprint<label id="isprint"><p>
3536 <tag/Function/Check if a given character is a printable character.
3537 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
3538 <tag/Declaration/<tt/int __fastcall__ isprint (int c);/
3539 <tag/Description/The function returns a non zero value if the given argument
3540 is a printable character (this includes the space character). The return value
3541 is zero if the character is anything else.
3542 <tag/Notes/<itemize>
3543 <item>When compiling with <tt/-Os/ the function is actually a macro. The
3544 inline sequence generated by the macro will not work correctly for values
3545 outside the range 0..255. <em/Note:/ The constant <tt/EOF/ is not part of
3546 this range. The non inline function may be accessed by <tt/#undef/'ing the
3548 <item>When compiling without <tt/-Os/, the function is only available as
3549 fastcall function, so it may only be used in presence of a prototype.
3551 <tag/Availability/ISO 9899
3553 <ref id="isalnum" name="isalnum">,
3554 <ref id="isalpha" name="isalpha">,
3555 <ref id="isascii" name="isascii">,
3556 <ref id="isblank" name="isblank">,
3557 <ref id="iscntrl" name="iscntrl">,
3558 <ref id="isdigit" name="isdigit">,
3559 <ref id="isgraph" name="isgraph">,
3560 <ref id="islower" name="islower">,
3561 <ref id="ispunct" name="ispunct">,
3562 <ref id="isspace" name="isspace">,
3563 <ref id="isupper" name="isupper">,
3564 <ref id="isxdigit" name="isxdigit">
3570 <sect1>ispunct<label id="ispunct"><p>
3574 <tag/Function/Check if a given character is a printable character but not a
3575 space or an alphanumeric character.
3576 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
3577 <tag/Declaration/<tt/int __fastcall__ ispunct (int c);/
3578 <tag/Description/The function returns a non zero value if the given argument
3579 is a printable character, but not a space or anything alphanumeric. The return
3580 value is zero if the character is anything else.
3581 <tag/Notes/<itemize>
3582 <item>When compiling with <tt/-Os/ the function is actually a macro. The
3583 inline sequence generated by the macro will not work correctly for values
3584 outside the range 0..255. <em/Note:/ The constant <tt/EOF/ is not part of
3585 this range. The non inline function may be accessed by <tt/#undef/'ing the
3587 <item>When compiling without <tt/-Os/, the function is only available as
3588 fastcall function, so it may only be used in presence of a prototype.
3590 <tag/Availability/ISO 9899
3592 <ref id="isalnum" name="isalnum">,
3593 <ref id="isalpha" name="isalpha">,
3594 <ref id="isascii" name="isascii">,
3595 <ref id="isblank" name="isblank">,
3596 <ref id="iscntrl" name="iscntrl">,
3597 <ref id="isdigit" name="isdigit">,
3598 <ref id="isgraph" name="isgraph">,
3599 <ref id="islower" name="islower">,
3600 <ref id="isprint" name="isprint">,
3601 <ref id="isspace" name="isspace">,
3602 <ref id="isupper" name="isupper">,
3603 <ref id="isxdigit" name="isxdigit">
3609 <sect1>isspace<label id="isspace"><p>
3613 <tag/Function/Check if a given character is a a white-space character.
3614 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
3615 <tag/Declaration/<tt/int __fastcall__ isspace (int c);/
3616 <tag/Description/The function returns a non zero value if the given argument
3617 is a white space character. The return value is zero if the character is
3618 anything else. The standard white space characters are: space, formfeed ('\f'),
3619 newline ('\n'), carriage return ('\r'), horizontal tab ('\t'), and vertical tab
3621 <tag/Notes/<itemize>
3622 <item>When compiling with <tt/-Os/ the function is actually a macro. The
3623 inline sequence generated by the macro will not work correctly for values
3624 outside the range 0..255. <em/Note:/ The constant <tt/EOF/ is not part of
3625 this range. The non inline function may be accessed by <tt/#undef/'ing the
3627 <item>When compiling without <tt/-Os/, the function is only available as
3628 fastcall function, so it may only be used in presence of a prototype.
3630 <tag/Availability/ISO 9899
3632 <ref id="isalnum" name="isalnum">,
3633 <ref id="isalpha" name="isalpha">,
3634 <ref id="isascii" name="isascii">,
3635 <ref id="isblank" name="isblank">,
3636 <ref id="iscntrl" name="iscntrl">,
3637 <ref id="isdigit" name="isdigit">,
3638 <ref id="isgraph" name="isgraph">,
3639 <ref id="islower" name="islower">,
3640 <ref id="isprint" name="isprint">,
3641 <ref id="ispunct" name="ispunct">,
3642 <ref id="isupper" name="isupper">,
3643 <ref id="isxdigit" name="isxdigit">
3649 <sect1>isupper<label id="isupper"><p>
3653 <tag/Function/Check if a given character is an upper case letter.
3654 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
3655 <tag/Declaration/<tt/int __fastcall__ isupper (int c);/
3656 <tag/Description/The function returns a non zero value if the given argument
3657 is an upper case letter. The return value is zero if the character is anything
3659 <tag/Notes/<itemize>
3660 <item>When compiling with <tt/-Os/ the function is actually a macro. The
3661 inline sequence generated by the macro will not work correctly for values
3662 outside the range 0..255. <em/Note:/ The constant <tt/EOF/ is not part of
3663 this range. The non inline function may be accessed by <tt/#undef/'ing the
3665 <item>When compiling without <tt/-Os/, the function is only available as
3666 fastcall function, so it may only be used in presence of a prototype.
3668 <tag/Availability/ISO 9899
3670 <ref id="isalnum" name="isalnum">,
3671 <ref id="isalpha" name="isalpha">,
3672 <ref id="isascii" name="isascii">,
3673 <ref id="isblank" name="isblank">,
3674 <ref id="iscntrl" name="iscntrl">,
3675 <ref id="isdigit" name="isdigit">,
3676 <ref id="isgraph" name="isgraph">,
3677 <ref id="islower" name="islower">,
3678 <ref id="isprint" name="isprint">,
3679 <ref id="ispunct" name="ispunct">,
3680 <ref id="isspace" name="isspace">,
3681 <ref id="isxdigit" name="isxdigit">
3687 <sect1>isxdigit<label id="isxdigit"><p>
3691 <tag/Function/Check if a given character is a hexadecimal digit.
3692 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
3693 <tag/Declaration/<tt/int __fastcall__ isxdigit (int c);/
3694 <tag/Description/The function returns a non zero value if the given argument
3695 is a hexadecimal digit (0..9, a..f and A..F). The return value is zero if the
3696 character is anything else.
3697 <tag/Notes/<itemize>
3698 <item>When compiling with <tt/-Os/ the function is actually a macro. The
3699 inline sequence generated by the macro will not work correctly for values
3700 outside the range 0..255. <em/Note:/ The constant <tt/EOF/ is not part of
3701 this range. The non inline function may be accessed by <tt/#undef/'ing the
3703 <item>When compiling without <tt/-Os/, the function is only available as
3704 fastcall function, so it may only be used in presence of a prototype.
3706 <tag/Availability/ISO 9899
3708 <ref id="isalnum" name="isalnum">,
3709 <ref id="isalpha" name="isalpha">,
3710 <ref id="isascii" name="isascii">,
3711 <ref id="isblank" name="isblank">,
3712 <ref id="iscntrl" name="iscntrl">,
3713 <ref id="isdigit" name="isdigit">,
3714 <ref id="isgraph" name="isgraph">,
3715 <ref id="islower" name="islower">,
3716 <ref id="isprint" name="isprint">,
3717 <ref id="ispunct" name="ispunct">,
3718 <ref id="isspace" name="isspace">,
3719 <ref id="isupper" name="isupper">
3725 <sect1>itoa<label id="itoa"><p>
3729 <tag/Function/Convert an integer into a string.
3730 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
3731 <tag/Declaration/<tt/char* __fastcall__ itoa (int val, char* buf, int radix);/
3732 <tag/Description/<tt/itoa/ converts the integer <tt/val/ into a string using
3733 <tt/radix/ as the base.
3734 <tag/Notes/<itemize>
3735 <item>There are no provisions to prevent a buffer overflow.
3736 <item>If <tt/val/ contains <tt/INT_MIN/, the behaviour is undefined.
3737 <item>The function is non standard, so it is not available in strict ANSI mode.
3738 You should probably use <tt/sprintf/ instead.
3739 <item>The function is only available as fastcall function, so it may only be
3740 used in presence of a prototype.
3742 <tag/Availability/cc65
3744 <ref id="atoi" name="atoi">,
3745 <ref id="atol" name="atol">,
3746 <ref id="ltoa" name="ltoa">,
3747 <ref id="ultoa" name="ultoa">,
3748 <ref id="utoa" name="utoa">
3754 <sect1>joy_count<label id="joy_count"><p>
3758 <tag/Function/Return the number of joysticks supported by the current driver.
3759 <tag/Header/<tt/<ref id="joystick.h" name="joystick.h">/
3760 <tag/Declaration/<tt/unsigned char joy_count (void);/
3761 <tag/Description/The function returns a the number of joysticks supported
3762 by the current joystick driver.
3763 <tag/Notes/<itemize>
3764 <item>A joystick driver must be loaded using <ref id="joy_load_driver"
3765 name="joy_load_driver"> before calling this function.
3766 <item>The function returns the number of joysticks supported by the driver.
3767 There's no way to check for the number of actually connected joysticks.
3769 <tag/Availability/cc65
3771 <ref id="joy_load_driver" name="joy_load_driver">,
3772 <ref id="joy_read" name="joy_read">
3778 <sect1>joy_install<label id="joy_install"><p>
3782 <tag/Function/Install an already loaded driver and return an error code.
3783 <tag/Header/<tt/<ref id="joystick.h" name="joystick.h">/
3784 <tag/Declaration/<tt/unsigned char __fastcall__ joy_install (void* driver);/
3785 <tag/Description/The function installs a driver that was already loaded into
3786 memory (or linked statically to the program). It returns an error code
3787 (<tt/JOY_ERR_OK/ in case of success).
3788 <tag/Notes/<itemize>
3789 <item>The function is only available as fastcall function, so it may only be
3790 used in presence of a prototype.
3792 <tag/Availability/cc65
3794 <ref id="joy_load_driver" name="joy_load_driver">,
3795 <ref id="joy_uninstall" name="joy_uninstall">,
3796 <ref id="joy_unload" name="joy_unload">
3802 <sect1>joy_load_driver<label id="joy_load_driver"><p>
3806 <tag/Function/Load a driver from disk and install it.
3807 <tag/Header/<tt/<ref id="joystick.h" name="joystick.h">/
3808 <tag/Declaration/<tt/unsigned char __fastcall__ joy_load_driver (const char* driver);/
3809 <tag/Description/The function loads a driver with the given name from disk
3810 and installs it. An error code is returned, which is <tt/JOY_ERR_OK/ if the
3811 driver was successfully loaded and installed.
3812 <tag/Notes/<itemize>
3813 <item>The function is only available as fastcall function, so it may only be
3814 used in presence of a prototype.
3816 <tag/Availability/cc65
3818 <ref id="joy_install" name="joy_install">,
3819 <ref id="joy_uninstall" name="joy_uninstall">,
3820 <ref id="joy_unload" name="joy_unload">
3826 <sect1>joy_read<label id="joy_read"><p>
3830 <tag/Function/Read the status of a joystick.
3831 <tag/Header/<tt/<ref id="joystick.h" name="joystick.h">/
3832 <tag/Declaration/<tt/unsigned char __fastcall__ joy_read (unsigned char joystick);/
3833 <tag/Description/The function reads the status bits for a joystick. The number
3834 of the joystick is passed as parameter. The result may be examined by using one
3835 of the <tt/JOY_xxx/ macros from <ref id="joystick.h" name="joystick.h">.
3836 <tag/Notes/<itemize>
3837 <item>A joystick driver must be loaded using <ref id="joy_load_driver"
3838 name="joy_load_driver"> before calling this function.
3839 <item>The function is only available as fastcall function, so it may only be
3840 used in presence of a prototype.
3842 <tag/Availability/cc65
3844 <ref id="joy_count" name="joy_count">,
3845 <ref id="joy_load_driver" name="joy_load_driver">,
3846 <ref id="joy_unload" name="joy_unload">
3852 <sect1>joy_uninstall<label id="joy_uninstall"><p>
3856 <tag/Function/Uninstall the current joystick driver.
3857 <tag/Header/<tt/<ref id="joystick.h" name="joystick.h">/
3858 <tag/Declaration/<tt/unsigned char joy_uninstall (void);/
3859 <tag/Description/The function uninstalls the currently installed joystick
3860 driver. It does not remove the driver from memory. The function returns an
3861 error code, which is <tt/JOY_ERR_OK/ if the driver was successfully uninstalled.
3862 <tag/Notes/<itemize>
3863 <item>A joystick driver must be installed using <ref id="joy_install"
3864 name="joy_install"> before calling this function.
3866 <tag/Availability/cc65
3868 <ref id="joy_install" name="joy_install">,
3869 <ref id="joy_load_driver" name="joy_load_driver">,
3870 <ref id="joy_unload" name="joy_unload">
3876 <sect1>joy_unload<label id="joy_unload"><p>
3880 <tag/Function/Uninstall, then unload the current joystick driver.
3881 <tag/Header/<tt/<ref id="joystick.h" name="joystick.h">/
3882 <tag/Declaration/<tt/unsigned char joy_unload (void);/
3883 <tag/Description/The function uninstalls the currently installed joystick
3884 driver and removes it from memory. An error code is returned, which is
3885 <tt/JOY_ERR_OK/ if the driver was successfully uninstalled.
3886 <tag/Notes/<itemize>
3887 <item>A joystick driver must be loaded using <ref id="joy_load_driver"
3888 name="joy_load_driver"> before calling this function.
3890 <tag/Availability/cc65
3892 <ref id="joy_load_driver" name="joy_load_driver">
3898 <sect1>kbhit<label id="kbhit"><p>
3902 <tag/Function/Check if there's a key waiting in the keyboard buffer.
3903 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
3904 <tag/Declaration/<tt/unsigned char kbhit (void);/
3905 <tag/Description/The function returns a value of zero if there is no character
3906 waiting to be read from the keyboard. It returns non zero otherwise.
3907 <tag/Notes/<itemize>
3908 <item>If the system does not support a keyboard buffer (most systems
3909 do), the function is rather useless.
3911 <tag/Availability/cc65
3913 <ref id="cgetc" name="cgetc">,
3914 <ref id="cursor" name="cursor">
3920 <sect1>labs<label id="labs"><p>
3924 <tag/Function/Returns the absolute value of a long integer.
3925 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
3926 <tag/Declaration/<tt/long __fastcall__ labs (long v);/
3927 <tag/Description/<tt/labs/ returns the absolute value of the argument passed to
3929 <tag/Notes/<itemize>
3930 <item>The return value is undefined if <tt/LONG_MIN/ is passed to the function.
3931 <item>The function is only available as fastcall function, so it may only be
3932 used in presence of a prototype.
3934 <tag/Availability/ISO 9899
3936 <ref id="abs" name="abs">
3942 <sect1>ltoa<label id="ltoa"><p>
3946 <tag/Function/Convert a long integer into a string.
3947 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
3948 <tag/Declaration/<tt/char* __fastcall__ ltoa (long val, char* buf, int radix);/
3949 <tag/Description/<tt/itoa/ converts the long integer <tt/val/ into a string
3950 using <tt/radix/ as the base.
3951 <tag/Notes/<itemize>
3952 <item>There are no provisions to prevent a buffer overflow.
3953 <item>If <tt/val/ contains <tt/LONG_MIN/, the behaviour is undefined.
3954 <item>The function is non standard, so it is not available in strict ANSI mode.
3955 You should probably use <tt/sprintf/ instead.
3956 <item>The function is only available as fastcall function, so it may only be
3957 used in presence of a prototype.
3959 <tag/Availability/cc65
3961 <ref id="atoi" name="atoi">,
3962 <ref id="atol" name="atol">,
3963 <ref id="itoa" name="itoa">,
3964 <ref id="ultoa" name="ultoa">,
3965 <ref id="utoa" name="utoa">
3971 <sect1>localeconv<label id="localeconv"><p>
3975 <tag/Function/Returns a pointer to the current locale structure.
3976 <tag/Header/<tt/<ref id="locale.h" name="locale.h">/
3977 <tag/Declaration/<tt/struct lconv* localeconv (void);/
3978 <tag/Description/<tt/localeconv/ returns a pointer to the current locale
3980 <tag/Notes/<itemize>
3981 <item>cc65 supports only the "C" locale, so even after setting a new locale
3982 using <tt/<ref id="setlocale" name="setlocale">/, the structure returned will
3985 <tag/Availability/ISO 9899
3987 <ref id="setlocale" name="setlocale">
3993 <sect1>longjmp<label id="longjmp"><p>
3997 <tag/Function/Non local goto.
3998 <tag/Header/<tt/<ref id="setjmp.h" name="setjmp.h">/
3999 <tag/Declaration/<tt/void __fastcall__ longjmp (jmp_buf buf, int retval);/
4000 <tag/Description/The <tt/longjmp/ function restores a program context from the
4001 data in <tt/buf/, which must have been set by a preceeding call to
4002 <tt/<ref id="setjmp" name="setjmp">/. Program execution continues as if the
4003 call to <tt/<ref id="setjmp" name="setjmp">/ has just returned the value
4005 <tag/Notes/<itemize>
4006 <item>If the parameter <tt/retval/ is zero, the function will behave as if it
4007 was called with a value of one.
4008 <item>The function is only available as fastcall function, so it may only
4009 be used in presence of a prototype.
4011 <tag/Availability/ISO 9899
4013 <ref id="setjmp" name="setjmp">
4019 <sect1>malloc<label id="malloc"><p>
4023 <tag/Function/Allocate dynamic memory.
4024 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
4025 <tag/Declaration/<tt/void* __fastcall__ malloc (size_t size);/
4026 <tag/Description/<tt/malloc/ allocates size bytes on the heap and returns a
4027 pointer to the allocated memory block. On error (not enough memory available),
4028 <tt/malloc/ returns <tt/NULL/.
4029 <tag/Notes/<itemize>
4030 <item>The function is only available as fastcall function, so it may only
4031 be used in presence of a prototype.
4033 <tag/Availability/ISO 9899
4035 <ref id="_heapadd" name="_heapadd">,
4036 <ref id="_heapblocksize" name="_heapblocksize">,
4037 <ref id="_heapmaxavail" name="_heapmaxavail">,
4038 <ref id="_heapmemavail" name="_heapmemavail">,
4039 <ref id="calloc" name="calloc">,
4040 <ref id="free" name="free">,
4041 <ref id="realloc" name="realloc">,
4042 <ref id="strdup" name="strdup">
4048 <sect1>memchr<label id="memchr"><p>
4052 <tag/Function/Search for a character in a block of raw memory.
4053 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4054 <tag/Declaration/<tt/void* __fastcall__ strchr (const void* mem, int c, size_t count);/
4055 <tag/Description/The <tt/memchr/ function locates the first occurrence of <tt/c/
4056 (converted to a char) in the block of raw memory string pointed to by <tt/mem/
4057 that is of size <tt/count/. Upon completion, the function returns a pointer to
4058 the character found, or a null pointer if the character was not found.
4059 <tag/Notes/<itemize>
4060 <item>The function is only available as fastcall function, so it may only
4061 be used in presence of a prototype.
4063 <tag/Availability/ISO 9899
4065 <ref id="strchr" name="strchr">
4071 <sect1>memcmp<label id="memcmp"><p>
4075 <tag/Function/Compare two memory areas.
4076 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4077 <tag/Declaration/<tt/int __fastcall__ memcmp (const void* p1, const void* p2, size_t count);/
4078 <tag/Description/<tt/memcmp/ compares <tt/count/ bytes from the memory area
4079 pointed to by <tt/p1/ into the memory area pointed to by <tt/p2/. It returns a value that is less than
4080 zero if <tt/p1/ is less than <tt/p2/, zero if <tt/p1/ is the same as <tt/p2/,
4081 and a value greater than zero if <tt/p1/ is greater than <tt/p2/.
4082 <tag/Notes/<itemize>
4083 <item>The function is only available as fastcall function, so it may only
4084 be used in presence of a prototype.
4086 <tag/Availability/ISO 9899
4088 <ref id="strcmp" name="strcmp">,
4089 <ref id="memmove" name="memmove">,
4090 <ref id="memset" name="memset">
4096 <sect1>memcpy<label id="memcpy"><p>
4100 <tag/Function/Copy a memory area.
4101 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4102 <tag/Declaration/<tt/void* __fastcall__ memcpy (void* dest, const void* src, size_t count);/
4103 <tag/Description/<tt/memcpy/ copies <tt/count/ bytes from the memory area
4104 pointed to by <tt/src/ into the memory area pointed to by <tt/dest/. It returns
4106 <tag/Notes/<itemize>
4107 <item>The result is undefined if the memory areas do overlap. Use
4108 <tt/<ref id="memmove" name="memmove">/ to copy overlapping memory areas.
4109 <item>The function is only available as fastcall function, so it may only
4110 be used in presence of a prototype.
4112 <tag/Availability/ISO 9899
4114 <ref id="_swap" name="_swap">,
4115 <ref id="memmove" name="memmove">,
4116 <ref id="memset" name="memset">
4122 <sect1>memmove<label id="memmove"><p>
4126 <tag/Function/Copy a memory area.
4127 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4128 <tag/Declaration/<tt/void* __fastcall__ memmove (void* dest, const void* src, size_t count);/
4129 <tag/Description/<tt/memmove/ copies <tt/count/ bytes from the memory area
4130 pointed to by <tt/src/ into the memory area pointed to by <tt/dest/. It returns
4132 <tag/Notes/<itemize>
4133 <item>While <tt/memmove/ allows the memory areas to overlap, it has some
4134 additional overhead compared to <tt/<ref id="memcpy" name="memcpy">/.
4135 <item>The function is only available as fastcall function, so it may only
4136 be used in presence of a prototype.
4138 <tag/Availability/ISO 9899
4140 <ref id="_swap" name="_swap">,
4141 <ref id="memcpy" name="memcpy">,
4142 <ref id="memset" name="memset">
4148 <sect1>memset<label id="memset"><p>
4152 <tag/Function/Fill a memory area.
4153 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4154 <tag/Declaration/<tt/void* __fastcall__ memset (void* p, int val, size_t count);/
4155 <tag/Description/<tt/memset/ fills the memory area pointed to by <tt/p/ with
4156 the value <tt/val/. The function returns <tt/p/.
4157 <tag/Notes/<itemize>
4158 <item>The function is only available as fastcall function, so it may only
4159 be used in presence of a prototype.
4161 <tag/Availability/ISO 9899
4163 <ref id="_swap" name="_swap">,
4164 <ref id="bzero" name="bzero">,
4165 <ref id="memcpy" name="memcpy">,
4166 <ref id="memmove" name="memmove">
4172 <sect1>mod_free<label id="mod_free"><p>
4176 <tag/Function/Free a relocatable module.
4177 <tag/Header/<tt/<ref id="modload.h" name="modload.h">/
4178 <tag/Declaration/<tt/void __fastcall__ mod_free (void* module);/
4179 <tag/Description/The function will free a module loaded into memory by use of
4180 the <tt/<ref id="mod_load" name="mod_load">/ function.
4181 <tag/Notes/<itemize>
4182 <item>The pointer passed as parameter is the pointer to the module memory,
4183 not the pointer to the control structure.
4184 <item>The function is available only as a fastcall function; so, it may be used
4185 only in the presence of a prototype.
4187 <tag/Availability/cc65
4189 <ref id="mod_load" name="mod_load">
4195 <sect1>mod_load<label id="mod_load"><p>
4199 <tag/Function/Load a relocatable module.
4200 <tag/Header/<tt/<ref id="modload.h" name="modload.h">/
4201 <tag/Declaration/<tt/unsigned char __fastcall__ mod_load (struct mod_ctrl* ctrl);/
4202 <tag/Description/The function will load a code module into memory and relocate
4203 it. The function will return an error code. If <tt/MLOAD_OK/ is returned, the
4204 outgoing fields in the passed <tt/mod_ctrl/ struct contain information about
4205 the module just loaded. Possible error codes are:
4207 <item><tt/MLOAD_OK/ - Module load successful
4208 <item><tt/MLOAD_ERR_READ/ - Read error
4209 <item><tt/MLOAD_ERR_HDR/ - Header error
4210 <item><tt/MLOAD_ERR_OS/ - Wrong operating system
4211 <item><tt/MLOAD_ERR_FMT/ - Data format error
4212 <item><tt/MLOAD_ERR_MEM/ - Not enough memory
4214 <tag/Notes/<itemize>
4215 <item>The <htmlurl url="ld65.html" name="ld65"> linker is needed to create
4216 relocatable o65 modules for use with this function.
4217 <item>The function is available only as a fastcall function; so, it may be used
4218 only in the presence of a prototype.
4220 <tag/Availability/cc65
4222 <ref id="mod_free" name="mod_free">
4228 <sect1>mouse_setbox<label id="mouse_setbox"><p>
4232 <tag/Function/Specify a bounding box for the mouse cursor.
4233 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
4234 <tag/Declaration/<tt/void __fastcall__ mouse_setbox (const struct mouse_box* box);/
4235 <tag/Description/The function allows to set a bounding box for mouse movement.
4236 <tag/Notes/<itemize>
4237 <item>The function does not check if the mouse cursor is currently within the
4238 given rectangle. Placing the mouse cursor within the bounding box is the
4239 responsibility of the programmer.
4240 <item>While the bounding box may be larger than the actual screen size, the
4241 standard mouse cursor draw routines may fail to set the cursor to coordinates
4242 outside of the screen area. Depending on the platform, you may have to supply
4243 your own mouse cursor routines.
4244 <item>The function is only available as fastcall function, so it may only be
4245 used in presence of a prototype.
4247 <tag/Availability/cc65
4249 <ref id="mouse_getbox" name="mouse_getbox">,
4250 <ref id="mouse_move" name="mouse_move">
4256 <sect1>mouse_getbox<label id="mouse_getbox"><p>
4260 <tag/Function/Return the current bounding box for the mouse cursor.
4261 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
4262 <tag/Declaration/<tt/void __fastcall__ mouse_getbox (struct mouse_box* box);/
4263 <tag/Description/The function queries the current bounding box for mouse
4265 <tag/Notes/<itemize>
4266 <item>The function is only available as fastcall function, so it may only be
4267 used in presence of a prototype.
4269 <tag/Availability/cc65
4271 <ref id="mouse_move" name="mouse_move">,
4272 <ref id="mouse_setbox" name="mouse_setbox">
4278 <sect1>mouse_buttons<label id="mouse_buttons"><p>
4282 <tag/Function/Return a bit mask encoding the state of the mouse buttons.
4283 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
4284 <tag/Declaration/<tt/unsigned char mouse_buttons (void);/
4285 <tag/Description/The function returns a bit mask that encodes the state of the
4286 mouse buttons. You may use the <tt/MOUSE_BTN_XXX/ flags to decode the function
4288 <tag/Availability/cc65
4290 <ref id="mouse_info" name="mouse_info">,
4291 <ref id="mouse_pos" name="mouse_pos">
4297 <sect1>mouse_geterrormsg<label id="mouse_geterrormsg"><p>
4301 <tag/Function/Return a readable error message for an error code.
4302 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
4303 <tag/Declaration/<tt/const char* __fastcall__ mouse_geterrormsg (unsigned char
4305 <tag/Description/The function returns an error message (in english) for the
4306 error code passed parameter.
4307 <tag/Notes/<itemize>
4308 <item>The function will return "Unknown error" for invalid error codes.
4309 <item>The function is only available as fastcall function, so it may only be
4310 used in presence of a prototype.
4312 <tag/Availability/cc65
4314 <ref id="mouse_load_driver" name="mouse_load_driver">,
4315 <ref id="mouse_uninstall" name="mouse_uninstall">,
4316 <ref id="mouse_unload" name="mouse_unload">
4322 <sect1>mouse_hide<label id="mouse_hide"><p>
4326 <tag/Function/Hide the mouse pointer.
4327 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
4328 <tag/Declaration/<tt/void mouse_hide (void);/
4329 <tag/Description/The function hides the mouse pointer. It manages a counter
4330 that is shared between <tt/<ref id="mouse_show" name="mouse_show">/ and
4331 <tt/mouse_hide/ so that every call call to <tt/mouse_hide/ must be followed by
4332 a call to <tt/<ref id="mouse_show" name="mouse_show">/ to make the mouse cursor
4334 <tag/Availability/cc65
4336 <ref id="mouse_show" name="mouse_show">
4342 <sect1>mouse_info<label id="mouse_info"><p>
4346 <tag/Function/Return the state of the mouse buttons and the position of the
4348 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
4349 <tag/Declaration/<tt/void __fastcall__ mouse_info (struct mouse_info* info);/
4350 <tag/Description/The function returns the state of the mouse buttons and the
4351 position of the mouse in the <tt/mouse_info/ structure passed as parameter.
4352 <tag/Notes/<itemize>
4353 <item>The <tt/mouse_info/ struct is a superset of the <tt/mouse_pos/ struct,
4354 so if you just need the mouse position, call <tt/<ref id="mouse_pos"
4355 name="mouse_pos">/ instead.
4356 <item>The function is only available as fastcall function, so it may only be
4357 used in presence of a prototype.
4359 <tag/Availability/cc65
4361 <ref id="mouse_buttons" name="mouse_buttons">,
4362 <ref id="mouse_pos" name="mouse_pos">
4368 <sect1>mouse_install<label id="mouse_install"><p>
4372 <tag/Function/Install an already loaded mouse driver.
4373 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
4374 <tag/Declaration/<tt/unsigned char __fastcall__ mouse_install (const struct
4375 mouse_callbacks* c, void* driver);/
4376 <tag/Description/The function installs an already loaded mouse driver and
4377 returns an error code. The <tt/mouse_callbacks/ structure passed as first
4378 parameter contains pointers to routines needed to move or hide/show the mouse
4379 pointer. Defaults for these routines are supplied by the library, so if you
4380 can live with these defaults (which are platform specific), just pass a
4381 pointer to <tt/mouse_def_callbacks/. The function may be used to install a
4382 driver linked statically to the program.
4383 <tag/Notes/<itemize>
4384 <item>Not all drivers are able to detect if the supported hardware is really
4386 <item>After installing a driver, the mouse cursor is hidden.
4387 <item>The function is only available as fastcall function, so it may only be
4388 used in presence of a prototype.
4390 <tag/Availability/cc65
4392 <ref id="mouse_load_driver" name="mouse_load_driver">,
4393 <ref id="mouse_uninstall" name="mouse_uninstall">,
4394 <ref id="mouse_unload" name="mouse_unload">
4400 <sect1>mouse_ioctl<label id="mouse_ioctl"><p>
4404 <tag/Function/Call the driver specific ioctl function.
4405 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
4406 <tag/Declaration/<tt/unsigned char __fastcall__ mouse_ioctl (unsigned char code, void* data);/
4407 <tag/Description/The function calls the IOCTL entry in the mouse driver,
4408 which is driver specific. The <tt/code/ parameter will choose between
4409 different IOCTL functions, and the <tt/data/ depends on code. The
4410 function returns an error code. The purpose of this function is to allow
4411 for driver specific extensions. See the documentation for a specific mouse
4412 driver for supported ioctl calls.
4413 <tag/Notes/<itemize>
4414 <item>Calling this function is non portable, because each driver may
4415 implement different ioctl calls (or none at all).
4416 <item>The function is only available as fastcall function, so it may only be
4417 used in presence of a prototype.
4419 <tag/Availability/cc65
4425 <sect1>mouse_load_driver<label id="mouse_load_driver"><p>
4429 <tag/Function/Load and initialize a mouse driver.
4430 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
4431 <tag/Declaration/<tt/unsigned char __fastcall__ mouse_load_driver (const struct
4432 mouse_callbacks* c, const char* driver);/
4433 <tag/Description/Load a mouse driver into memory and initialize it. The
4434 function returns an error code that tells if the call has been successful. The
4435 <tt/mouse_callbacks/ structure passed as first parameter contains pointers to
4436 routines needed to move or hide/show the mouse pointer. Defaults for these
4437 routines are supplied by the library, so if you can live with these defaults
4438 (which are platform specific), just pass a pointer to <tt/mouse_def_callbacks/.
4439 <tag/Notes/<itemize>
4440 <item>The driver is loaded by name, so currently you must know the type of
4441 mouse that should be supported. There is no autodetect capability.
4442 <item>Not all drivers are able to detect if the supported hardware is really
4444 <item>After installing a driver, the mouse cursor is hidden.
4445 <item>The function is only available as fastcall function, so it may only be
4446 used in presence of a prototype.
4448 <tag/Availability/cc65
4450 <ref id="mouse_install" name="mouse_install">,
4451 <ref id="mouse_uninstall" name="mouse_uninstall">,
4452 <ref id="mouse_unload" name="mouse_unload">
4458 <sect1>mouse_move<label id="mouse_move"><p>
4462 <tag/Function/Move the mouse cursor to a specific position.
4463 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
4464 <tag/Declaration/<tt/void __fastcall__ mouse_move (int x, int y);/
4465 <tag/Description/The function updates the mouse position. If the mouse cursor
4466 is visible, it is shown at the new position.
4467 <tag/Notes/<itemize>
4468 <item>The function does not check if the new position is within the bounding
4469 box specified with <tt/<ref id="mouse_setbox" name="mouse_setbox">/.
4470 <item>The function is only available as fastcall function, so it may only be
4471 used in presence of a prototype.
4473 <tag/Availability/cc65
4475 <ref id="mouse_getbox" name="mouse_getbox">,
4476 <ref id="mouse_setbox" name="mouse_setbox">
4482 <sect1>mouse_pos<label id="mouse_pos"><p>
4486 <tag/Function/Return the position of the mouse.
4487 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
4488 <tag/Declaration/<tt/void __fastcall__ mouse_pos (struct mouse_pos* pos);/
4489 <tag/Description/The function returns the position of the mouse in the
4490 <tt/mouse_pos/ structure passed as parameter.
4491 <tag/Notes/<itemize>
4492 <item>The <tt/mouse_pos/ struct is a subset of the <tt/mouse_info/ struct,
4493 so if you do also need the mouse buttons, call <tt/<ref id="mouse_info"
4494 name="mouse_info">/ instead.
4495 <item>The function is only available as fastcall function, so it may only be
4496 used in presence of a prototype.
4498 <tag/Availability/cc65
4500 <ref id="mouse_buttons" name="mouse_buttons">,
4501 <ref id="mouse_info" name="mouse_info">
4507 <sect1>mouse_show<label id="mouse_show"><p>
4511 <tag/Function/Show the mouse pointer.
4512 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
4513 <tag/Declaration/<tt/void mouse_show (void);/
4514 <tag/Description/The function shows the mouse pointer. It manages a counter
4515 that is shared between <tt/<ref id="mouse_hide" name="mouse_hide">/ and
4516 <tt/mouse_show/. The mouse cursor is visible if there was one more call to
4517 <tt/mouse_show/ than to <tt/<ref id="mouse_hide" name="mouse_hide">/.
4518 <tag/Availability/cc65
4520 <ref id="mouse_hide" name="mouse_hide">
4526 <sect1>mouse_uninstall<label id="mouse_uninstall"><p>
4530 <tag/Function/Uninstall an already loaded mouse driver.
4531 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
4532 <tag/Declaration/<tt/unsigned char mouse_uninstall (void);/
4533 <tag/Description/The function uninstalls an already loaded mouse driver but
4534 don't removes it from memory.
4535 <tag/Notes/<itemize>
4536 <item>If the driver has been loaded using <tt/<ref id="mouse_load_driver"
4537 name="mouse_load_driver">/, <tt/<ref id="mouse_unload" name="mouse_unload">/
4538 should be used instead of <tt/mouse_uninstall/ so the driver is also removed
4541 <tag/Availability/cc65
4543 <ref id="mouse_install" name="mouse_install">,
4544 <ref id="mouse_load_driver" name="mouse_load_driver">,
4545 <ref id="mouse_unload" name="mouse_unload">
4551 <sect1>mouse_unload<label id="mouse_unload"><p>
4555 <tag/Function/Unload a mouse driver.
4556 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
4557 <tag/Declaration/<tt/unsigned char mouse_unload (void);/
4558 <tag/Description/The function unloads a loaded mouse driver and frees all
4559 memory allocated for the driver.
4560 <tag/Notes/<itemize>
4561 <item>The function does nothing if no driver is loaded.
4563 <tag/Availability/cc65
4565 <ref id="mouse_install" name="mouse_install">,
4566 <ref id="mouse_load_driver" name="mouse_load_driver">,
4567 <ref id="mouse_uninstall" name="mouse_uninstall">
4573 <sect1>offsetof<label id="offsetof"><p>
4577 <tag/Function/Calculate the offset of a struct or union member.
4578 <tag/Header/<tt/<ref id="stddef.h" name="stddef.h">/
4579 <tag/Declaration/<tt/size_t offsetof (type, member);/
4580 <tag/Description/<tt/offsetof/ calculates the address offset of a <tt/struct/
4581 or <tt/union/ member.
4582 <tag/Notes/<itemize>
4583 <item>The function is actually a macro.
4585 <tag/Availability/ISO 9899
4591 <sect1>open<label id="open"><p>
4595 <tag/Function/Open and possibly create a file.
4596 <tag/Header/<tt/<ref id="fcntl.h" name="fcntl.h">/
4597 <tag/Declaration/<tt/int open (const char* name, int flags, ...);/
4598 <tag/Description/<tt/open/ opens a file and returns the file descriptor
4599 associated with it. On error, -1 is returned and an error code is stored in
4600 <tt/errno/. Several flags may be passed to <tt/open/ that change the behaviour.
4601 <tag/Notes/<itemize>
4602 <item>POSIX specifies an additional <tt/mode/ argument that may be passed to
4603 open, which is used as the permission mask when a new file is created. While
4604 cc65 allows to pass this argument, it is ignored.
4606 <tag/Availability/POSIX 1003.1
4608 <ref id="close" name="close">,
4609 <ref id="creat" name="creat">
4615 <sect1>opendir<label id="opendir"><p>
4619 <tag/Function/Open a directory.
4620 <tag/Header/<tt/<ref id="dirent.h" name="dirent.h">/
4621 <tag/Declaration/<tt/DIR* __fastcall__ opendir (const char* name);/
4622 <tag/Description/<tt/opendir/ opens a directory and returns the direcory
4623 descriptor associated with it. On error, NULL is returned and an error code is
4624 stored in <tt/errno/.
4625 <tag/Notes/<itemize>
4626 <item>The function is only available as fastcall function, so it may only
4627 be used in presence of a prototype.
4629 <tag/Availability/POSIX 1003.1
4631 <ref id="closedir" name="closedir">,
4632 <ref id="readdir" name="readdir">
4638 <sect1>peekbsys<label id="peekbsys"><p>
4642 <tag/Function/Read one byte from a location in the system bank.
4643 <tag/Header/<tt/<ref id="cbm610.h" name="cbm610.h">/,
4644 <tt/<ref id="cbm510.h" name="cbm510.h">/
4645 <tag/Declaration/<tt/unsigned char __fastcall__ peekbsys (unsigned addr);/
4646 <tag/Description/<tt/peekbsys/ reads one byte from the given address in the
4647 system bank (bank 15) of the CBM PET-II machines and returns it.
4648 <tag/Notes/<itemize>
4649 <item>The function is only available as fastcall function, so it may only
4650 be used in presence of a prototype.
4651 <item>This function may be a macro depending on the compiler options. The
4652 actual function is accessible by #undef'ing the macro.
4654 <tag/Availability/cc65
4656 <ref id="PEEK" name="PEEK">,
4657 <ref id="PEEKW" name="PEEKW">,
4658 <ref id="peekwsys" name="peekwsys">,
4659 <ref id="pokebsys" name="pokebsys">,
4660 <ref id="pokewsys" name="pokewsys">
4666 <sect1>peekwsys<label id="peekwsys"><p>
4670 <tag/Function/Read one word from a location in the system bank.
4671 <tag/Header/<tt/<ref id="cbm610.h" name="cbm610.h">/,
4672 <tt/<ref id="cbm510.h" name="cbm510.h">/
4673 <tag/Declaration/<tt/unsigned __fastcall__ peekwsys (unsigned addr);/
4674 <tag/Description/<tt/peekwsys/ reads one word from the given address in the
4675 system bank (bank 15) of the CBM PET-II machines and returns it. Following
4676 the usual 6502 conventions, the low byte is read from <tt/addr/, and the
4677 high byte is read from <tt/addr+1/.
4678 <tag/Notes/<itemize>
4679 <item>The function is only available as fastcall function, so it may only
4680 be used in presence of a prototype.
4681 <item>The order in which the two bytes are read is undefined.
4683 <tag/Availability/cc65
4685 <ref id="PEEK" name="PEEK">,
4686 <ref id="PEEKW" name="PEEKW">,
4687 <ref id="peekbsys" name="peekbsys">,
4688 <ref id="pokebsys" name="pokebsys">,
4689 <ref id="pokewsys" name="pokewsys">
4695 <sect1>perror<label id="perror"><p>
4699 <tag/Function/Print an error message for the error in <tt/errno/.
4700 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
4701 <tag/Declaration/<tt/void __fastcall__ perror (const char* s);/
4702 <tag/Description/<tt/perror/ prints an error message to <tt/stderr/. If <tt/s/
4703 is not <tt/NULL/ and not an empty string, it is printed followed by a colon and
4704 a blank. Then the error message for the current contents of <tt/errno/ is
4705 printed followed by a newline. The message output is the same as returned by
4706 <tt/<ref id="strerror" name="strerror">/ with an argument of <tt/errno/.
4707 <tag/Notes/<itemize>
4708 <item>The function is only available as fastcall function, so it may only
4709 be used in presence of a prototype.
4711 <tag/Availability/ISO 9899
4713 <ref id="_poserror" name="_poserror">,
4714 <ref id="strerror" name="strerror">
4720 <sect1>pokebsys<label id="pokebsys"><p>
4724 <tag/Function/Write one byte to a location in the system bank.
4725 <tag/Header/<tt/<ref id="cbm610.h" name="cbm610.h">/,
4726 <tt/<ref id="cbm510.h" name="cbm510.h">/
4727 <tag/Declaration/<tt/void __fastcall__ pokebsys (unsigned addr, unsigned char val);/
4728 <tag/Description/<tt/pokebsys/ writes one byte to the given address in the
4729 system bank (bank 15) of the CBM PET-II machines.
4730 <tag/Notes/<itemize>
4731 <item>The function is only available as fastcall function, so it may only
4732 be used in presence of a prototype.
4734 <tag/Availability/cc65
4736 <ref id="POKE" name="POKE">,
4737 <ref id="POKEW" name="POKEW">,
4738 <ref id="peekbsys" name="peekbsys">,
4739 <ref id="peekwsys" name="peekwsys">,
4740 <ref id="pokewsys" name="pokewsys">
4746 <sect1>pokewsys<label id="pokewsys"><p>
4750 <tag/Function/Write one word to a location in the system bank.
4751 <tag/Header/<tt/<ref id="cbm610.h" name="cbm610.h">/,
4752 <tt/<ref id="cbm510.h" name="cbm510.h">/
4753 <tag/Declaration/<tt/void __fastcall__ pokewsys (unsigned addr, unsigned val);/
4754 <tag/Description/<tt/pokewsys/ writes one word to the given address in the
4755 system bank (bank 15) of the CBM PET-II machines. Following the usual 6502
4756 conventions, the low byte of <tt/val/ is written to <tt/addr/, and the
4757 high byte is written to <tt/addr+1/.
4758 <tag/Notes/<itemize>
4759 <item>The function is only available as fastcall function, so it may only
4760 be used in presence of a prototype.
4761 <item>The order in which the two bytes are written is undefined.
4763 <tag/Availability/cc65
4765 <ref id="POKE" name="POKE">,
4766 <ref id="POKEW" name="POKEW">,
4767 <ref id="peekbsys" name="peekbsys">,
4768 <ref id="peekwsys" name="peekwsys">,
4769 <ref id="pokebsys" name="pokebsys">
4775 <sect1>qsort<label id="qsort"><p>
4779 <tag/Function/Sort an array.
4780 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
4781 <tag/Declaration/<tt/void __fastcall__ qsort (void* base, size_t count,
4782 size_t size, int __fastcall__ (* compare) (const void*, const void*));/
4783 <tag/Description/<tt/qsort/ sorts an array according to a given compare
4784 function <tt/compare/. <tt/base/ is the address of the array, <tt/count/
4785 is the number of elements, <tt/size/ the size of an element and <tt/compare/
4786 the function used to compare the members.
4787 <tag/Notes/<itemize>
4788 <item>If there are multiple members with the same key, the order after calling
4789 the function is undefined.
4790 <item>The function is only available as fastcall function, so it may only
4791 be used in presence of a prototype.
4792 <item>The function to which <tt/compare/ points must have the <tt/fastcall/
4795 <tag/Availability/ISO 9899
4797 <ref id="bsearch" name="bsearch">
4803 <sect1>raise<label id="raise"><p>
4807 <tag/Function/Send a signal to the executing program.
4808 <tag/Header/<tt/<ref id="signal.h" name="signal.h">/
4809 <tag/Declaration/<tt/int __fastcall__ raise (int sig);/
4810 <tag/Description/<tt/raise/ sends the given signal to the program. If the
4811 program has installed a signal handler for the signal, this signal handler
4812 will be executed. If no handler has been installed, the default action for
4813 the raised signal will be taken. The function returns zero on success,
4815 <tag/Notes/<itemize>
4816 <item>The function is only available as fastcall function, so it may only
4817 be used in presence of a prototype.
4819 <tag/Availability/ISO 9899
4821 <ref id="abort" name="abort">,
4822 <ref id="signal" name="signal">
4828 <sect1>rand<label id="rand"><p>
4832 <tag/Function/Return a pseudo random number.
4833 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
4834 <tag/Declaration/<tt/int rand (void);/
4835 <tag/Description/The function returns a pseudo random number
4836 between 0 and <tt/RAND_MAX/ (exclusive).
4837 <tag/Notes/<itemize>
4838 <item>Without using <tt><ref id="srand" name="srand"></tt>, always the same
4839 flow of numbers is generated.
4840 <item>On startup, the function behaves as if <ref id="srand" name="srand">
4841 had been used with an argument of 1.
4843 <tag/Availability/ISO 9899
4845 <ref id="_randomize" name="_randomize">,
4846 <ref id="srand" name="srand">
4852 <sect1>readdir<label id="readdir"><p>
4856 <tag/Function/Read a directory.
4857 <tag/Header/<tt/<ref id="dirent.h" name="dirent.h">/
4858 <tag/Declaration/<tt/struct dirent* __fastcall__ readdir (DIR* dir);/
4859 <tag/Description/<tt/readdir/ reads the next directory entry from the directory
4860 stream pointed to by <tt/dir/. It stores the data in a <tt/dirent/ structure
4861 and returns a pointer to it. If the end of directory is reached, or an error
4862 occurs, NULL is returned. In case of errors, an error code is stored into
4864 <tag/Notes/<itemize>
4865 <item>The function is only available as fastcall function, so it may only
4866 be used in presence of a prototype.
4867 <item>The returned pointer may point to a statically allocated instance of
4868 <tt/struct dirent/, so it may get overwritten by subsequent calls to
4870 <item>On several platforms, namely the CBMs and the Atari, the disk drives get
4871 confused when opening/closing files between directory reads. So for example a
4872 program that reads the list of files on a disk, and after each call to
4873 <tt/readdir/, opens the file to process it, will fail.<newline>
4874 Possible solutions are reading the directory into memory before processing the
4875 file list, or to reset the directory by seeking to the correct position after
4876 opening/closing a file:
4878 seekdir (DIR, telldir (DIR));
4880 Platforms known to work without problems are: Apple.
4882 <tag/Availability/POSIX 1003.1
4884 <ref id="closedir" name="closedir">,
4885 <ref id="opendir" name="opendir">
4891 <sect1>realloc<label id="realloc"><p>
4895 <tag/Function/Change the size of an allocated memory block.
4896 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
4897 <tag/Declaration/<tt/void* __fastcall__ realloc (void* block, size_t size);/
4898 <tag/Description/<tt/realloc/ changes the size of the memory block pointed to
4899 by <tt/block/ to <tt/size/ bytes. If <tt/block/ is <tt/NULL/, <tt/realloc/
4900 behaves as if <tt/malloc/ had been called. If <tt/size/ is zero, <tt/realloc/
4901 behaves as if <tt/free/ had been called. On error (not enough memory
4902 available), <tt/realloc/ returns <tt/NULL/.
4903 <tag/Notes/<itemize>
4904 <item>The part of the memory block that is returned will have its contents
4906 <item>This function is somewhat dangerous to use. Be careful to save the
4907 pointer you're passing somewhere else, otherwise
4909 ptr = realloc (ptr, size);
4911 will loose your only copy of <tt/ptr/ if <tt/realloc/ returns <tt/NULL/.
4912 <item>The function is only available as fastcall function, so it may only
4913 be used in presence of a prototype.
4915 <tag/Availability/ISO 9899
4917 <ref id="_heapadd" name="_heapadd">,
4918 <ref id="_heapblocksize" name="_heapblocksize">,
4919 <ref id="_heapmaxavail" name="_heapmaxavail">,
4920 <ref id="_heapmemavail" name="_heapmemavail">,
4921 <ref id="calloc" name="calloc">,
4922 <ref id="free" name="free">,
4923 <ref id="realloc" name="realloc">
4929 <sect1>remove<label id="remove"><p>
4933 <tag/Function/Delete a file.
4934 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
4935 <tag/Declaration/<tt/int __fastcall__ remove (const char* name);/
4936 <tag/Description/<tt/remove/ deletes the file with the given name. On success,
4937 zero is returned. On error, -1 is returned and <tt/errno/ is set to an error
4938 code describing the reason for the failure.
4939 <tag/Notes/<itemize>
4940 <item>This function is not available on all cc65 targets (depends on the
4941 availability of file I/O).
4942 <item>The function is only available as fastcall function, so it may only
4943 be used in presence of a prototype.
4945 <tag/Availability/ISO 9899
4947 <ref id="rename" name="rename">,
4948 <ref id="unlink" name="unlink">
4951 #include <stdio.h>
4953 #define FILENAME "helloworld"
4955 if (remove (FILENAME) == 0) {
4956 printf ("We deleted %s successfully\n", FILENAME);
4958 printf ("There was a problem deleting %s\n", FILENAME);
4965 <sect1>rename<label id="rename"><p>
4969 <tag/Function/Rename a file.
4970 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
4971 <tag/Declaration/<tt/int __fastcall__ rename (const char* oldname, const char* newname);/
4972 <tag/Description/<tt/rename/ renames a file (gives it a new name). On success,
4973 zero is returned. On error, -1 is returned and <tt/errno/ is set to an error
4974 code describing the reason for the failure.
4975 <tag/Notes/<itemize>
4976 <item>This function is not available on all cc65 targets (depends on the
4977 capabilities of the storage devices).
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="remove" name="remove">
4986 #include <stdio.h>
4988 #define OLDNAME "textfile.txt"
4989 #define NEWNAME "textfile.bak"
4991 if (rename (OLDNAME, NEWNAME) == 0) {
4992 printf ("Renamed %s to %s\n", OLDNAME, NEWNAME);
4994 printf ("Error renaming %s to %s\n", OLDNAME, NEWNAME);
5001 <sect1>reset_brk<label id="reset_brk"><p>
5005 <tag/Function/Resets the break vector to its original value.
5006 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
5007 <tag/Declaration/<tt/void reset_brk (void);/
5008 <tag/Description/<tt/reset_brk/ resets the break vector to the value it had
5009 before a call to <tt/set_brk/.
5010 <tag/Notes/<itemize>
5011 <item>The break vector is reset on program termination, so it's not strictly
5012 necessary to call this function as a part of your clean-up when exitting the program.
5014 <tag/Availability/cc65
5016 <ref id="reset_irq" name="reset_irq">,
5017 <ref id="set_brk" name="set_brk">,
5018 <ref id="set_irq" name="set_irq">
5024 <sect1>reset_irq<label id="reset_irq"><p>
5028 <tag/Function/Resets the C level interrupt request vector.
5029 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
5030 <tag/Declaration/<tt/void reset_irq (void);/
5031 <tag/Description/<tt/reset_irq/ resets the C level interrupt request vector.
5032 <tag/Notes/<itemize>
5033 <item>The interrupt vector is reset on program termination, so it's not strictly
5034 necessary to call this function as a part of your clean-up when exitting the program.
5036 <tag/Availability/cc65
5038 <ref id="reset_brk" name="reset_brk">,
5039 <ref id="set_brk" name="set_brk">,
5040 <ref id="set_irq" name="set_irq">
5046 <sect1>revers<label id="revers"><p>
5050 <tag/Function/Control revers character display.
5051 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
5052 <tag/Declaration/<tt/unsigned char __fastcall__ revers (unsigned char onoff);/
5053 <tag/Description/If the argument is non zero, the function enables reverse
5054 character display. If the argument is zero, reverse character display is
5055 switched off. The old value of the setting is returned.
5056 <tag/Notes/<itemize>
5057 <item>The function may not be supported by the hardware, in which case
5058 the call is ignored.
5059 <item>The function is only available as fastcall function, so it may only
5060 be used in presence of a prototype.
5062 <tag/Availability/cc65
5064 <ref id="textcolor" name="textcolor">
5070 <sect1>rewinddir<label id="rewinddir"><p>
5074 <tag/Function/Reset a directory stream.
5075 <tag/Header/<tt/<ref id="dirent.h" name="dirent.h">/
5076 <tag/Declaration/<tt/void __fastcall__ rewinddir (DIR* dir);/
5077 <tag/Description/<tt/rewinddir/ sets the position of the directory stream
5078 pointed to by <tt/dir/ to the start of the directory.
5079 <tag/Notes/<itemize>
5080 <item>The function is only available as fastcall function, so it may only
5081 be used in presence of a prototype.
5083 <tag/Availability/POSIX 1003.1
5085 <ref id="seekdir" name="seekdir">,
5086 <ref id="telldir" name="telldir">
5092 <sect1>screensize<label id="screensize"><p>
5096 <tag/Function/Return the dimensions of the text mode screen.
5097 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
5098 <tag/Declaration/<tt/void __fastcall__ screensize (unsigned char* x, unsigned char* y);/
5099 <tag/Description/The function returns the dimensions of the text mode screen.
5100 <tag/Notes/<itemize>
5101 <item>The function is only available as fastcall function, so it may only
5102 be used in presence of a prototype.
5104 <tag/Availability/cc65
5106 <ref id="gotox" name="gotox">,
5107 <ref id="gotoxy" name="gotoxy">,
5108 <ref id="gotoy" name="gotoy">,
5109 <ref id="wherex" name="wherex">,
5110 <ref id="wherey" name="wherey">
5116 <sect1>seekdir<label id="seekdir"><p>
5120 <tag/Function/Set the position of a directory stream.
5121 <tag/Header/<tt/<ref id="dirent.h" name="dirent.h">/
5122 <tag/Declaration/<tt/void __fastcall__ seekdir (DIR* dir, long offset);/
5123 <tag/Description/<tt/seekdir/ sets the position of the directory stream
5124 pointed to by <tt/dir/ to the value given in <tt/offset/, which should be a
5125 value returned by <tt/<ref id="telldir" name="telldir">/.
5126 <tag/Notes/<itemize>
5127 <item>The function is only available as fastcall function, so it may only
5128 be used in presence of a prototype.
5130 <tag/Availability/POSIX 1003.1
5132 <ref id="rewinddir" name="rewinddir">,
5133 <ref id="telldir" name="telldir">
5139 <sect1>ser_close<label id="ser_close"><p>
5143 <tag/Function/Close the port and disable interrupts
5144 <tag/Header/<tt/<ref id="serial.h" name="serial.h">/
5145 <tag/Declaration/<tt/unsigned char ser_close (void);/
5146 <tag/Description/Close the port by clearing buffers and disable interrupts.
5147 <tag/Availability/cc65
5148 <tag/See also/Other serial functions.
5153 static void initialize(){
5154 struct ser_params params = {
5161 ser_install(lynx_comlynx); // This will activate the ComLynx
5163 ser_open(&params);
5170 <sect1>ser_get<label id="ser_get"><p>
5174 <tag/Function/Read a character from serial port.
5175 <tag/Header/<tt/<ref id="serial.h" name="serial.h">/
5176 <tag/Declaration/<tt/unsigned char __fastcall__ ser_get (char* b);/
5177 <tag/Description/Get a character from the serial port. If no characters are
5178 available, the function will return SER_ERR_NO_DATA, so this is not a fatal
5180 <tag/Notes/<itemize>
5181 <item>The function is only available as fastcall function, so it may only
5182 be used in presence of a prototype.
5184 <tag/Availability/cc65
5185 <tag/See also/Other serial functions.
5187 Wait for a character to be available from a serial port.
5190 while (ser_get(&ch) == SER_ERR_NO_DATA)
5197 <sect1>ser_install<label id="ser_install"><p>
5201 <tag/Function/Install an already loaded driver and return an error code.
5202 <tag/Header/<tt/<ref id="serial.h" name="serial.h">/
5203 <tag/Declaration/<tt/unsigned char __fastcall__ ser_install (void* driver);/
5204 <tag/Description/The function installs a driver that was already loaded into
5205 memory (or linked statically to the program). It returns an error code
5206 (<tt/SER_ERR_OK/ in case of success).
5207 <tag/Notes/<itemize>
5208 <item>The function is only available as fastcall function, so it may only be
5209 used in presence of a prototype.
5211 <tag/Availability/cc65
5213 <ref id="ser_load_driver" name="ser_load_driver">,
5214 <ref id="ser_uninstall" name="ser_uninstall">,
5215 <ref id="ser_unload" name="ser_unload">
5217 ser_install(lynx_comlynx); //Include the driver statically instead of loading it.
5223 <sect1>ser_ioctl<label id="ser_ioctl"><p>
5227 <tag/Function/Platform dependent code extensions.
5228 <tag/Header/<tt/<ref id="serial.h" name="serial.h">/
5229 <tag/Declaration/<tt/unsigned __fastcall__ ser_ioctl (unsigned char code, void* data);/
5230 <tag/Description/Some platforms have extra serial functions that are not
5231 supported by standard serial driver functions. You can extend the driver to support
5232 this extra functionality bt using ser_ioctl functions.
5233 <tag/Notes/<itemize>
5234 <item>The function is only available as fastcall function, so it may only
5235 be used in presence of a prototype.
5236 <item>These functions are not easily portable to other cc65 platforms.
5238 <tag/Availability/cc65
5239 <tag/See also/Other serial functions.
5244 <sect1>ser_load_driver<label id="ser_load_driver"><p>
5248 <tag/Function/Load and install a serial driver.
5249 <tag/Header/<tt/<ref id="serial.h" name="serial.h">/
5250 <tag/Declaration/<tt/unsigned char __fastcall__ ser_load_driver (const char *name);/
5251 <tag/Description/Load and install the driver by name.
5252 Will just load the driver and check if loading was successful.
5253 <tag/Notes/<itemize>
5254 <item>The function is only available as fastcall function, so it may only
5255 be used in presence of a prototype.
5257 <tag/Availability/cc65
5258 <tag/See also/Other serial functions.
5264 <sect1>ser_open<label id="ser_open"><p>
5268 <tag/Function/Open the port by setting the port parameters and enable interrupts
5269 <tag/Header/<tt/<ref id="serial.h" name="serial.h">/
5270 <tag/Declaration/<tt/unsigned char __fastcall__ ser_open (const struct ser_params* params);/
5271 <tag/Description/Open the port by setting the port parameters and enable interrupts.
5272 <tag/Notes/<itemize>
5273 <item>The function is only available as fastcall function, so it may only
5274 be used in presence of a prototype.
5276 <tag/Availability/cc65
5277 <tag/See also/Other serial functions.
5282 static void initialize(){
5283 struct ser_params params = {
5290 ser_install(lynx_comlynx); // This will activate the ComLynx
5292 ser_open(&params);
5299 <sect1>ser_put<label id="ser_put"><p>
5303 <tag/Function/Write a character to a serial port.
5304 <tag/Header/<tt/<ref id="serial.h" name="serial.h">/
5305 <tag/Declaration/<tt/unsigned char __fastcall__ ser_put (char b);/
5306 <tag/Description/Send a character via the serial port. There is a transmit
5307 buffer, but transmitting is not done via interrupt. The function returns
5308 SER_ERR_OVERFLOW if there is no space left in the transmit buffer.
5309 <tag/Notes/<itemize>
5310 <item>The function is only available as fastcall function, so it may only
5311 be used in presence of a prototype.
5313 <tag/Availability/cc65
5314 <tag/See also/Other serial functions.
5323 <sect1>ser_status<label id="ser_status"><p>
5327 <tag/Function/Return the serial port status.
5328 <tag/Header/<tt/<ref id="serial.h" name="serial.h">/
5329 <tag/Declaration/<tt/unsigned char __fastcall__ ser_status (unsigned char* status);/
5330 <tag/Description/Return the serial port status.
5331 <tag/Notes/<itemize>
5332 <item>The function is only available as fastcall function, so it may only
5333 be used in presence of a prototype.
5335 <tag/Availability/cc65
5336 <tag/See also/Other serial functions.
5342 <sect1>ser_uninstall<label id="ser_uninstall"><p>
5346 <tag/Function/Uninstall the currently loaded driver but do not unload it.
5347 <tag/Header/<tt/<ref id="serial.h" name="serial.h">/
5348 <tag/Declaration/<tt/unsigned char ser_uninstall (void);/
5349 <tag/Description/Uninstall the currently loaded driver but do not unload it.
5350 <tag/Availability/cc65
5351 <tag/See also/Other serial functions.
5356 <sect1>ser_unload<label id="ser_unload"><p>
5360 <tag/Function/Uninstall, then unload the currently loaded driver.
5361 <tag/Header/<tt/<ref id="serial.h" name="serial.h">/
5362 <tag/Declaration/<tt/unsigned char ser_unload (void);/
5363 <tag/Description/Uninstall, then unload the currently loaded driver.
5364 <tag/Availability/cc65
5365 <tag/See also/Other serial functions.
5371 <sect1>set_brk<label id="set_brk"><p>
5375 <tag/Function/Set the break vector to a user function.
5376 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
5377 <tag/Declaration/<tt/void __fastcall__ set_brk (brk_handler func);/
5378 <tag/Description/<tt/set_brk/ allows a user program to handle breaks within the
5379 program code by letting the vector point to a user written C function. The
5380 runtime library installs a small stub that saves the registers into global
5381 variables that may be accessed (and changed) by the break handler.
5382 <tag/Notes/<itemize>
5383 <item>The function is only available as fastcall function, so it may only
5384 be used in presence of a prototype.
5385 <item>The stub saves the zero page registers used by the C runtime and switches
5386 to a small break handler stack. This means that it is safe to execute C code,
5387 even if C code was interrupted. Be careful however not to use too many local
5388 variables, and do not enable stack checks for the handler function or any other
5389 function called from it.
5390 <item>The <tt/brk_pc/ variable points to the <tt/BRK/ instruction. If you want
5391 the continue with the interrupted code, you have to adjust <tt/brk_pc/,
5392 otherwise the <tt/BRK/ instruction will get executed over and over again.
5393 <item>The break vector is reset on program termination, so it's not strictly
5394 necessary to call <tt/<ref id="reset_brk" name="reset_brk">/ as a part of your
5395 clean-up when exitting the program.
5397 <tag/Availability/cc65
5399 <ref id="reset_brk" name="reset_brk">
5405 <sect1>set_irq<label id="set_irq"><p>
5409 <tag/Function/Set the C level interrupt request vector to the given address.
5410 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
5411 <tag/Declaration/<tt/void __fastcall__ set_irq (irq_handler f, void *stack_addr, size_t stack_size);/
5412 <tag/Description/<tt/set_irq/ allows a user program to handle interrupt requests
5413 (IRQs) within the program code by letting the vector point to a user written C
5414 function. The runtime library installs a small stub that saves the zero page
5415 registers used by the C runtime before calling the handler function and restores
5416 them after the handler function returns. Additionally the stub temporarily switches
5417 the C runtime stack to the stack area provided as parameter. If the handler function
5418 was set up to handle a "private", "exclusive" interrupt request source it must
5419 return the value <tt/IRQ_HANDLED/ if and only if it has verified that the current
5420 interrupt request actually stems from that source. In all other cases it must return
5421 the value <tt/IRQ_NOT_HANDLED/.
5422 <tag/Notes/<itemize>
5423 <item>The function is only available as fastcall function, so it may only
5424 be used in presence of a prototype.
5425 <item>The stub saves the registers and zero page locations used by the C runtime
5426 and switches to the provided stack area. As a consequence, there is some
5427 runtime overhead, but it it is safe to execute C code, even if other C code
5428 was interrupted. Be careful however not to call C library functions, and do not
5429 enable stack checks for the handler function or any other function called from
5431 <item>The interrupt vector is reset on program termination, so it's not strictly
5432 necessary to call <tt/<ref id="reset_irq" name="reset_irq">/ as a part of your
5433 clean-up when exitting the program.
5435 <tag/Availability/cc65
5437 <ref id="reset_brk" name="reset_brk">,
5438 <ref id="reset_irq" name="reset_irq">,
5439 <ref id="set_brk" name="set_brk">
5445 <sect1>setjmp<label id="setjmp"><p>
5449 <tag/Function/Save the context for use with <tt/longjmp/.
5450 <tag/Header/<tt/<ref id="setjmp.h" name="setjmp.h">/
5451 <tag/Declaration/<tt/int __fastcall__ setjmp (jmp_buf buf);/
5452 <tag/Description/The <tt/setjmp/ function saves the current context in <tt/buf/
5453 for subsequent use by the <tt/<ref id="longjmp" name="longjmp">/ function and
5455 <tag/Notes/<itemize>
5456 <item>The function is only available as fastcall function, so it may only
5457 be used in presence of a prototype.
5458 <item><tt/setjmp/ is actually a macro as required by the ISO standard.
5459 <item><tt/setjmp/ will not save the signal context.
5461 <tag/Availability/ISO 9899
5463 <ref id="longjmp" name="longjmp">
5469 <sect1>setlocale<label id="setlocale"><p>
5473 <tag/Function/Selects a locale.
5474 <tag/Header/<tt/<ref id="locale.h" name="locale.h">/
5475 <tag/Declaration/<tt/char* __fastcall__ setlocale (int category, const char* locale);/
5476 <tag/Description/<tt/setlocale/ sets or queries the program's locale.
5477 <tag/Notes/<itemize>
5478 <item>The function is only available as fastcall function, so it may only
5479 be used in presence of a prototype.
5480 <item>cc65 supports only the "C" locale, so calling this function to set a
5481 different locale has no effect.
5483 <tag/Availability/ISO 9899
5485 <ref id="localeconv" name="localeconv">,
5486 <ref id="strcoll" name="strcoll">
5487 <ref id="strxfrm" name="strxfrm">
5493 <sect1>signal<label id="signal"><p>
5497 <tag/Function/Install a signal handler.
5498 <tag/Header/<tt/<ref id="signal.h" name="signal.h">/
5499 <tag/Declaration/<tt/__sigfunc __fastcall__ signal (int sig, __sigfunc func);/
5500 <tag/Description/<tt/signal/ installs a handler for the given signal. The
5501 handler may either be a user supplied function, or one of the predefined
5502 signal handlers <tt/SIG_IGN/ or <tt/SIG_DFL/. The function returns the
5503 previous value if the signal , or the special function vector SIG_ERR in
5505 <tag/Notes/<itemize>
5506 <item>The function is only available as fastcall function, so it may only
5507 be used in presence of a prototype.
5509 <tag/Availability/ISO 9899
5511 <ref id="abort" name="abort">,
5512 <ref id="raise" name="raise">
5518 <sect1>sleep<label id="sleep"><p>
5522 <tag/Function/Sleep for a specified amount of time.
5523 <tag/Header/<tt/<ref id="unistd.h" name="unistd.h">/
5524 <tag/Declaration/<tt/void __fastcall__ sleep (unsigned seconds);/
5525 <tag/Description/The function will return after the specified number of
5526 seconds have elapsed.
5527 <tag/Notes/<itemize>
5528 <item>The function is only available as fastcall function, so it may only
5529 be used in presence of a prototype.
5531 <tag/Availability/POSIX 1003.1
5537 <sect1>slow<label id="slow"><p>
5541 <tag/Function/Switch the C128 into 1MHz mode.
5542 <tag/Header/<tt/<ref id="c128.h" name="c128.h">/
5543 <tag/Declaration/<tt/void slow (void);/
5544 <tag/Description/The function will switch the clock of the C128 to 1MHz. This
5545 will halve the speed compared to fast mode.
5546 <tag/Notes/<itemize>
5547 <item>The function is specific to the C128.
5549 <tag/Availability/C128
5551 <ref id="fast" name="fast">,
5552 <ref id="toggle_videomode" name="toggle_videomode">,
5553 <ref id="videomode" name="videomode">
5559 <sect1>srand<label id="srand"><p>
5563 <tag/Function/Initialize the pseudo random number generator.
5564 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
5565 <tag/Declaration/<tt/void __fastcall__ srand (unsigned seed);/
5566 <tag/Description/The function initializes the random number generator using
5567 the given seed. On program startup, the generator behaves as if <tt/srand/ has
5568 been called with an argument of 1.
5569 <tag/Notes/<itemize>
5570 <item>The function is only available as fastcall function, so it may only
5571 be used in presence of a prototype.
5573 <tag/Availability/ISO 9899
5575 <ref id="_randomize" name="_randomize">,
5576 <ref id="rand" name="rand">
5582 <sect1>strcasecmp<label id="strcasecmp"><p>
5586 <tag/Function/Compare two strings case insensitive.
5587 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5588 <tag/Declaration/<tt/int __fastcall__ strcasecmp (const char* s1, const char* s2);/
5589 <tag/Description/The <tt/strcasecmp/ function compares the two strings passed
5590 as parameters without case sensitivity. It returns a value that is less than
5591 zero if <tt/s1/ is less than <tt/s2/, zero if <tt/s1/ is the same as <tt/s2/,
5592 and a value greater than zero if <tt/s1/ is greater than <tt/s2/.
5593 <tag/Notes/<itemize>
5594 <item>The function is only available as fastcall function, so it may only
5595 be used in presence of a prototype.
5596 <item>The function is not available in strict ANSI mode.
5598 <tag/Availability/cc65
5600 <ref id="strcmp" name="strcmp">,
5601 <ref id="strcoll" name="strcoll">,
5602 <ref id="stricmp" name="stricmp">,
5603 <ref id="strncmp" name="strncmp">,
5604 <ref id="strxfrm" name="strxfrm">
5610 <sect1>strcat<label id="strcat"><p>
5614 <tag/Function/Concatentate two strings.
5615 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5616 <tag/Declaration/<tt/char* __fastcall__ strcat (char* s1, const char* s2);/
5617 <tag/Description/The <tt/strcat/ function appends a copy of the string
5618 pointed to by s2 (including the terminating null byte) to the end of the
5619 string pointed to by s1. The initial byte of s2 overwrites the null byte at
5621 <tag/Notes/<itemize>
5622 <item>The function is only available as fastcall function, so it may only
5623 be used in presence of a prototype.
5624 <item>If copying takes place between objects that overlap, the behaviour
5627 <tag/Availability/ISO 9899
5629 <ref id="strcpy" name="strcpy">,
5630 <ref id="strncat" name="strncat">,
5631 <ref id="strncpy" name="strncpy">
5637 <sect1>strchr<label id="strchr"><p>
5641 <tag/Function/Search for a character in a string.
5642 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5643 <tag/Declaration/<tt/char* __fastcall__ strchr (const char* s, int c);/
5644 <tag/Description/The <tt/strchr/ function locates the first occurrence of <tt/c/
5645 (converted to a char) in the string pointed to by <tt/s/. The terminating null
5646 byte is considered to be part of the string. Upon completion, the function
5647 returns a pointer to the byte, or a null pointer if the byte was not found.
5648 <tag/Notes/<itemize>
5649 <item>The function is only available as fastcall function, so it may only
5650 be used in presence of a prototype.
5652 <tag/Availability/ISO 9899
5654 <ref id="memchr" name="memchr">,
5655 <ref id="strrchr" name="strrchr">
5661 <sect1>strcmp<label id="strcmp"><p>
5665 <tag/Function/Compare two strings.
5666 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5667 <tag/Declaration/<tt/int __fastcall__ strcmp (const char* s1, const char* s2);/
5668 <tag/Description/The <tt/strcmp/ function compares the two strings passed as
5669 parameters. It returns a value that is less than zero if <tt/s1/ is less than
5670 <tt/s2/, zero if <tt/s1/ is the same as <tt/s2/, and a value greater than zero
5671 if <tt/s1/ is greater than <tt/s2/.
5672 <tag/Notes/<itemize>
5673 <item>The function is only available as fastcall function, so it may only
5674 be used in presence of a prototype.
5676 <tag/Availability/ISO 9899
5678 <ref id="strcasecmp" name="strcasecmp">,
5679 <ref id="strcoll" name="strcoll">,
5680 <ref id="stricmp" name="stricmp">,
5681 <ref id="strncmp" name="strncmp">
5682 <ref id="strxfrm" name="strxfrm">
5688 <sect1>strcoll<label id="strcoll"><p>
5692 <tag/Function/Compare two strings.
5693 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5694 <tag/Declaration/<tt/int __fastcall__ strcoll (const char* s1, const char* s2);/
5695 <tag/Description/The <tt/strcoll/ function compares the two strings passed as
5696 parameters, according to the collating sequence set by <tt/<ref id="setlocale"
5697 name="setlocale">/. It returns a value that is less than zero if <tt/s1/ is
5698 less than <tt/s2/, zero if <tt/s1/ is the same as <tt/s2/, and a value greater
5699 than zero if <tt/s1/ is greater than <tt/s2/.
5700 <tag/Notes/<itemize>
5701 <item>The function is only available as fastcall function, so it may only
5702 be used in presence of a prototype.
5704 <tag/Availability/ISO 9899
5706 <ref id="setlocale" name="setlocale">,
5707 <ref id="strcasecmp" name="strcasecmp">,
5708 <ref id="strcmp" name="strcmp">,
5709 <ref id="stricmp" name="stricmp">,
5710 <ref id="strncmp" name="strncmp">,
5711 <ref id="strxfrm" name="strxfrm">
5717 <sect1>strcpy<label id="strcpy"><p>
5721 <tag/Function/Copy a string.
5722 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5723 <tag/Declaration/<tt/char* __fastcall__ strcpy (char* s1, const char* s2);/
5724 <tag/Description/The <tt/strcpy/ function copies the string pointed to by
5725 <tt/s2/ (including the terminating null byte) into the array pointed to by
5726 <tt/s1/. The function will always return <tt/s1/.
5727 <tag/Notes/<itemize>
5728 <item>The function is only available as fastcall function, so it may only
5729 be used in presence of a prototype.
5730 <item>If copying takes place between objects that overlap, the behaviour
5733 <tag/Availability/ISO 9899
5735 <ref id="strcat" name="strcat">,
5736 <ref id="strncat" name="strncat">,
5737 <ref id="strncpy" name="strncpy">
5740 #include <string.h>
5742 static char hello[14];
5744 strcpy (hello, "Hello world!\n");
5750 <sect1>strcspn<label id="strcspn"><p>
5754 <tag/Function/Compute the length of a substring.
5755 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5756 <tag/Declaration/<tt/size_t __fastcall__ strcspn (const char* s, const char* set);/
5757 <tag/Description/The <tt/strcspn/ function computes and returns the length of
5758 the substring pointed to by <tt/s/ which does <em>not</em> consist of
5759 characters contained in the string <tt/set/.
5760 <tag/Notes/<itemize>
5761 <item>The function is only available as fastcall function, so it may only
5762 be used in presence of a prototype.
5764 <tag/Availability/ISO 9899
5766 <ref id="strqtok" name="strqtok">,
5767 <ref id="strspn" name="strspn">,
5768 <ref id="strstr" name="strstr">,
5769 <ref id="strtok" name="strtok">
5775 <sect1>strdup<label id="strdup"><p>
5779 <tag/Function/Allocate a copy of a string on the heap.
5780 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5781 <tag/Declaration/<tt/char* __fastcall__ strdup (const char* s);/
5782 <tag/Description/<tt/strdup/ allocates a memory block on the heap, big enough
5783 to hold a copy of <tt/s/ including the terminating zero. If the allocation
5784 fails, <tt/NULL/ is returned, otherwise <tt/s/ is copied into the allocated
5785 memory block, and a pointer to the block is returned.
5786 <tag/Notes/<itemize>
5787 <item>The function is only available as fastcall function, so it may only
5788 be used in presence of a prototype.
5789 <item>It is up to the caller to free the allocated memory block.
5791 <tag/Availability/ISO 9899
5793 <ref id="free" name="free">,
5794 <ref id="malloc" name="malloc">
5800 <sect1>strerror<label id="strerror"><p>
5804 <tag/Function/Return a string describing an error code.
5805 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5806 <tag/Declaration/<tt/char* __fastcall__ strerror (int errcode);/
5807 <tag/Description/The <tt/strerror/ function returns a string describing the
5808 given error code. If an invalid error code is passed, the string "Unknown
5809 error" is returned, and <tt/errno/ is set to <tt/EINVAL/. In all other cases,
5810 <tt/errno/ is left untouched.
5811 <tag/Notes/<itemize>
5812 <item>The function is only available as fastcall function, so it may only
5813 be used in presence of a prototype.
5814 <item>While the return type of the function is a <tt/char*/, the returned
5815 string must not be modified by the caller!
5817 <tag/Availability/ISO 9899
5819 <ref id="_stroserror" name="_stroserror">
5825 <sect1>stricmp<label id="stricmp"><p>
5829 <tag/Function/Compare two strings case insensitive.
5830 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5831 <tag/Declaration/<tt/int __fastcall__ stricmp (const char* s1, const char* s2);/
5832 <tag/Description/The <tt/stricmp/ function compares the two strings passed as
5833 parameters without case sensitivity. It returns a value that is less than zero
5834 if <tt/s1/ is less than <tt/s2/, zero if <tt/s1/ is the same as <tt/s2/, and a
5835 value greater than zero if <tt/s1/ is greater than <tt/s2/.
5836 <tag/Notes/<itemize>
5837 <item>The function is only available as fastcall function, so it may only
5838 be used in presence of a prototype.
5839 <item>The function is not available in strict ANSI mode.
5841 <tag/Availability/cc65
5843 <ref id="strcasecmp" name="strcasecmp">,
5844 <ref id="strcmp" name="strcmp">,
5845 <ref id="strcoll" name="strcoll">,
5846 <ref id="strncmp" name="strncmp">,
5847 <ref id="strxfrm" name="strxfrm">
5853 <sect1>strlen<label id="strlen"><p>
5857 <tag/Function/Return the length of a string.
5858 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5859 <tag/Declaration/<tt/size_t __fastcall__ strlen (const char* s);/
5860 <tag/Description/The <tt/strlen/ function computes the number of bytes in the
5861 string to which s points, not including the terminating null byte.
5862 <tag/Notes/<itemize>
5863 <item>The function is only available as fastcall function, so it may only
5864 be used in presence of a prototype.
5865 <item>When compiling with <tt/-Os/ (inline known standard functions), the
5866 function does not work correctly for strings with more than 255 characters.
5868 <tag/Availability/ISO 9899
5870 <ref id="strcpy" name="strcpy">
5876 <sect1>strlower<label id="strlower"><p>
5880 <tag/Function/Make a string lower case.
5881 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5882 <tag/Declaration/<tt/char* __fastcall__ strlower (char* s);/
5883 <tag/Description/The <tt/strlower/ function will apply the <tt/tolower/
5884 function to each character of a string. The function will always return <tt/s/.
5885 <tag/Notes/<itemize>
5886 <item>The function is only available as fastcall function, so it may only
5887 be used in presence of a prototype.
5888 <item>The function prototype is unavailable when compiling in strict ANSI mode.
5889 <item>An alias name for this function is <tt/strlwr/.
5891 <tag/Availability/cc65
5893 <ref id="strupper" name="strupper">,
5894 <ref id="tolower" name="tolower">
5900 <sect1>strlwr<label id="strlwr"><p>
5907 <sect1>strncat<label id="strncat"><p>
5911 <tag/Function/Concatentate two strings.
5912 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5913 <tag/Declaration/<tt/char* __fastcall__ strncat (char* s1, const char* s2, size_t n);/
5914 <tag/Description/The <tt/strncat/ function appends not more than n characters
5915 of the string pointed to by s2 to the end of the string pointed to by s1. The
5916 terminating null character at the end of s1 is overwritten. A terminating null
5917 character is appended to the result, even if not all of s2 is appended to s1.
5918 <tag/Notes/<itemize>
5919 <item>The function is only available as fastcall function, so it may only
5920 be used in presence of a prototype.
5921 <item>If copying takes place between objects that overlap, the behaviour
5924 <tag/Availability/ISO 9899
5926 <ref id="strcpy" name="strcpy">,
5927 <ref id="strncat" name="strncat">,
5928 <ref id="strncpy" name="strncpy">
5934 <sect1>strncmp<label id="strncmp"><p>
5938 <tag/Function/Compare two strings.
5939 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5940 <tag/Declaration/<tt/int __fastcall__ strncmp (const char* s1, const char* s2, size_t count);/
5941 <tag/Description/The <tt/strncmp/ function compares not more than <tt/count/
5942 characters of the two strings passed as parameters. It returns a value that is
5943 less than zero if the first <tt/count/ characters of <tt/s1/ are less than
5944 <tt/s2/, zero if they are identical, and a value greater than zero they are
5946 <tag/Notes/<itemize>
5947 <item>The function is only available as fastcall function, so it may only
5948 be used in presence of a prototype.
5950 <tag/Availability/ISO 9899
5952 <ref id="strcasecmp" name="strcasecmp">,
5953 <ref id="strcmp" name="strcmp">,
5954 <ref id="strcoll" name="strcoll">,
5955 <ref id="stricmp" name="stricmp">,
5956 <ref id="strxfrm" name="strxfrm">
5962 <sect1>strncpy<label id="strncpy"><p>
5966 <tag/Function/Copy part of a string.
5967 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5968 <tag/Declaration/<tt/char* __fastcall__ strncpy (char* s1, const char* s2, size_t n);/
5969 <tag/Description/The <tt/strncpy/ function copies not more than <tt/n/ bytes from
5970 the array pointed to by <tt/s2/ to the array pointed to by <tt/s1/. If the array
5971 pointed to by <tt/s2/ is a string that is shorter than <tt/n/ bytes, null bytes are
5972 appended to the copy in the array pointed to by <tt/s1/, until <tt/n/ bytes are
5973 written. The function always will return <tt/s1/.
5974 <tag/Notes/<itemize>
5975 <item>The function is available only as a fastcall function; so, it may be used
5976 only in the presence of a prototype.
5977 <item>If there is no null byte in the first <tt/n/ bytes of the array pointed
5978 to by <tt/s2/, the result is <em/not/ null-terminated!
5979 <item>If copying takes place between objects that overlap, the behaviour is
5982 <tag/Availability/ISO 9899
5984 <ref id="memcpy" name="memcpy">,
5985 <ref id="strcat" name="strcat">,
5986 <ref id="strcpy" name="strcpy">,
5987 <ref id="strncat" name="strncat">
5992 static char hello[6];
5994 strncpy (hello, "Hello world!\n", sizeof hello - 1)[5] = '\0';
6000 <sect1>strqtok<label id="strqtok"><p>
6004 <tag/Function/Break a string into tokens.
6005 <tag/Header/<tt/<ref id="string.h" name="string.h">/
6006 <tag/Declaration/<tt/char* __fastcall__ strqtok (char* s1, const char* s2);/
6007 <tag/Description/<tt/strqtok()/ will break the string <tt/s1/ into a sequence of
6008 tokens, which are delimited by either quotation marks or characters from the
6009 string <tt/s2/. Tokens inside quotation marks may contain characters from <tt/s2/
6010 (they aren't delimiters there). The first call to <tt/strqtok()/ will return a
6011 pointer to the first token in the string <tt/s1/. The following calls must pass
6012 a <tt/NULL/ pointer as <tt/s1/, in order to get the next token in the string.
6013 Different sets of delimiters may be used for the subsequent calls to <tt/strqtok()/.
6014 <tag/Notes/<itemize>
6015 <item>The function is available only as a fastcall function; so, it may be used
6016 only in the presence of a prototype.
6017 <item><tt/strqtok()/ will modify the string <tt/s1/.
6018 <item>The function will forget where it is in the <tt/s1/ string if it is given
6019 a second <tt/s1/ string before it finishes the first one.
6021 <tag/Availability/cc65
6023 <ref id="strcspn" name="strcspn">,
6024 <!-- <ref id="strpbrk" name="strpbrk">, -->
6025 <ref id="strspn" name="strspn">,
6026 <ref id="strtok" name="strtok">
6032 <sect1>strrchr<label id="strrchr"><p>
6036 <tag/Function/Search for a character in a string.
6037 <tag/Header/<tt/<ref id="string.h" name="string.h">/
6038 <tag/Declaration/<tt/char* __fastcall__ strrchr (const char* s, int c);/
6039 <tag/Description/The <tt/strrchr/ function locates the last occurrence of <tt/c/
6040 (converted to a char) in the string pointed to by <tt/s/. The terminating null
6041 byte is considered to be part of the string. Upon completion, the function
6042 returns a pointer to the byte, or a null pointer if the byte was not found.
6043 <tag/Notes/<itemize>
6044 <item>The function is only available as fastcall function, so it may only
6045 be used in presence of a prototype.
6047 <tag/Availability/ISO 9899
6049 <ref id="strchr" name="strchr">
6055 <sect1>strspn<label id="strspn"><p>
6059 <tag/Function/Compute the length of a substring.
6060 <tag/Header/<tt/<ref id="string.h" name="string.h">/
6061 <tag/Declaration/<tt/size_t __fastcall__ strspn (const char* s, const char* set);/
6062 <tag/Description/The <tt/strspn/ function computes and returns the length of
6063 the substring pointed to by <tt/s/ which does consist only of characters
6064 contained in the string <tt/set/.
6065 <tag/Notes/<itemize>
6066 <item>The function is only available as fastcall function, so it may only
6067 be used in presence of a prototype.
6069 <tag/Availability/ISO 9899
6071 <ref id="strcspn" name="strcspn">,
6072 <ref id="strstr" name="strstr">
6078 <sect1>strstr<label id="strstr"><p>
6082 <tag/Function/Find a substring.
6083 <tag/Header/<tt/<ref id="string.h" name="string.h">/
6084 <tag/Declaration/<tt/char* __fastcall__ strstr (const char* str, const char* substr);/
6085 <tag/Description/<tt/strstr/ searches for the first occurance of the string
6086 <tt/substr/ within <tt/str/. If found, it returns a pointer to the copy,
6087 otherwise it returns <tt/NULL/.
6088 <tag/Notes/<itemize>
6089 <item>The function is only available as fastcall function, so it may only
6090 be used in presence of a prototype.
6092 <tag/Availability/ISO 9899
6094 <ref id="strcspn" name="strcspn">,
6095 <ref id="strspn" name="strspn">
6101 <sect1>strtok<label id="strtok"><p>
6105 <tag/Function/Break a string into tokens.
6106 <tag/Header/<tt/<ref id="string.h" name="string.h">/
6107 <tag/Declaration/<tt/char* __fastcall__ strtok (char* s1, const char* s2);/
6108 <tag/Description/<tt/strtok()/ will break the string <tt/s1/ into a sequence of
6109 tokens, which are delimited by characters from the string <tt/s2/. The first call
6110 to <tt/strtok()/ will return a pointer to the first token in the string <tt/s1/.
6111 The following calls must pass a <tt/NULL/ pointer as <tt/s1/, in order to get
6112 the next token in the string. Different sets of delimiters may be used for the
6113 subsequent calls to <tt/strtok()/.
6114 <tag/Notes/<itemize>
6115 <item>The function is only available as fastcall function, so it may only
6116 be used in presence of a prototype.
6117 <item><tt/strtok()/ will modify the string <tt/s1/.
6118 <item>The function will forget where it is in the <tt/s1/ string if it is given
6119 a second <tt/s1/ string before it finishes the first one.
6121 <tag/Availability/ISO 9899
6123 <ref id="strcspn" name="strcspn">,
6124 <!-- <ref id="strpbrk" name="strpbrk">, -->
6125 <ref id="strqtok" name="strqtok">,
6126 <ref id="strspn" name="strspn">
6132 <sect1>strxfrm<label id="strxfrm"><p>
6136 <tag/Function/Transform a string.
6137 <tag/Header/<tt/<ref id="string.h" name="string.h">/
6138 <tag/Declaration/<tt/size_t __fastcall__ strxfrm (char* s1, const char* s2, size_t n);/
6139 <tag/Description/The <tt/strxfrm/ function transforms the string pointed to by
6140 s2 and places the resulting string into the string pointed to by s1. The
6141 transformation is such that if the <tt/strcmp/ function is applied to two
6142 transformed strings, it returns a value greater than, equal to, or less than
6143 zero, corresponding to the result of the <tt/strcoll/ function applied to the
6144 same two original strings. No more than n characters are placed into the
6145 resulting array pointed to by s1, including the terminating null character.
6146 <tag/Notes/<itemize>
6147 <item><tt/s1/ and <tt/s2/ must not point to the same memory area, otherwise
6148 the behaviour is undefined.
6149 <item>If <tt/n/ is zero, <tt/s1/ may be a NULL pointer.
6150 <item>The function is only available as fastcall function, so it may only
6151 be used in presence of a prototype.
6152 <item>Since cc65 doesn't support different charcter sets, <tt/strxfrm/ will
6153 just copy s2 to s1 using <tt><ref id="strncpy" name="strncpy"></tt>.
6155 <tag/Availability/ISO 9899
6157 <ref id="strcmp" name="strcmp">,
6158 <ref id="strcoll" name="strcoll">,
6159 <ref id="strncpy" name="strncpy">
6165 <sect1>strupper<label id="strupper"><p>
6169 <tag/Function/Make a string upper case.
6170 <tag/Header/<tt/<ref id="string.h" name="string.h">/
6171 <tag/Declaration/<tt/char* __fastcall__ strupper (char* s);/
6172 <tag/Description/The <tt/strupper/ function will apply the <tt/toupper/
6173 function to each character of a string. The function will always return <tt/s/.
6174 <tag/Notes/<itemize>
6175 <item>The function is only available as fastcall function, so it may only
6176 be used in presence of a prototype.
6177 <item>The function prototype is unavailable when compiling in strict ANSI mode.
6178 <item>An alias name for this function is <tt/strupr/.
6180 <tag/Availability/cc65
6182 <ref id="strlower" name="strlower">
6183 <ref id="toupper" name="toupper">
6189 <sect1>strupr<label id="strupr"><p>
6196 <sect1>telldir<label id="telldir"><p>
6200 <tag/Function/Return the current position of a directory stream.
6201 <tag/Header/<tt/<ref id="dirent.h" name="dirent.h">/
6202 <tag/Declaration/<tt/long __fastcall__ telldir (DIR* dir);/
6203 <tag/Description/<tt/telldir/ returns the current position of a directory
6204 stream. The return value may be used in subsequent calls to
6205 <tt/<ref id="seekdir" name="seekdir">/.
6206 <tag/Notes/<itemize>
6207 <item>The function is only available as fastcall function, so it may only
6208 be used in presence of a prototype.
6210 <tag/Availability/POSIX 1003.1
6212 <ref id="seekdir" name="seekdir">,
6213 <ref id="telldir" name="telldir">
6219 <sect1>textcolor<label id="textcolor"><p>
6223 <tag/Function/Set the text color.
6224 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
6225 <tag/Declaration/<tt/unsigned char __fastcall__ textcolor (unsigned char color);/
6226 <tag/Description/The function will set a new text color. It returns the old
6227 (current) text color. Text output using any <tt/conio.h/ function will use
6228 the color set by this function.
6229 <tag/Notes/<itemize>
6230 <item>Text colors are system dependent. The function may have no effect
6231 on systems where the text color cannot be changed.
6232 <item>The function is only available as fastcall function, so it may only
6233 be used in presence of a prototype.
6235 <tag/Availability/cc65
6237 <ref id="bgcolor" name="bgcolor">,
6238 <ref id="bordercolor" name="bordercolor">
6244 <sect1>tgi_arc<label id="tgi_arc"><p>
6248 <tag/Function/Draw an elliptic arc in the current color.
6249 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6250 <tag/Declaration/<tt/void __fastcall__ tgi_arc (int x, int y,
6251 unsigned char rx, unsigned char ry, unsigned sa, unsigned ea);/
6252 <tag/Description/The function draws an elliptic arc with center at x/y and
6253 radii rx/ry using the current drawing color. The arc covers the angle
6254 between sa and ea (startangle and endangle), which must be in the range
6256 <tag/Notes/<itemize>
6257 <item>The function is only available as fastcall function, so it may only
6258 be used in presence of a prototype.
6259 <item>The function behaves unexpectedly or may crash if the angles are out
6262 <tag/Availability/cc65
6264 <ref id="tgi_bar" name="tgi_bar">,
6265 <ref id="tgi_circle" name="tgi_circle">,
6266 <ref id="tgi_ellipse" name="tgi_ellipse">,
6267 <ref id="tgi_pieslice" name="tgi_pieslice">,
6268 <ref id="tgi_setcolor" name="tgi_setcolor">
6270 /* Draw the upper half of an ellipse */
6271 tgi_setcolor(TGI_COLOR_BLUE);
6272 tgi_arc (50, 50, 40, 20, 0, 180);
6278 <sect1>tgi_bar<label id="tgi_bar"><p>
6282 <tag/Function/The function fills a rectangle on the drawpage with the current
6284 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6285 <tag/Declaration/<tt/void __fastcall__ tgi_bar (int x1, int y1, int x2, int y2);/
6286 <tag/Description/The function fills a rectangle on the drawpage with the current
6288 <tag/Notes/<itemize>
6289 <item>The function is only available as fastcall function, so it may only
6290 be used in presence of a prototype.
6292 <tag/Availability/cc65
6293 <tag/See also/Other tgi function
6295 tgi_setcolor(TGI_COLOR_GREEN);
6296 tgi_bar(10, 10, 100, 60);
6302 <sect1>tgi_circle<label id="tgi_circle"><p>
6306 <tag/Function/The function draws a circle in the current color.
6307 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6308 <tag/Declaration/<tt/void __fastcall__ tgi_circle (int x, int y, unsigned char radius);/
6309 <tag/Description/The function draws a circle in the current color.
6310 <tag/Notes/<itemize>
6311 <item>The function is only available as fastcall function, so it may only
6312 be used in presence of a prototype.
6314 <tag/Availability/cc65
6316 <ref id="tgi_arc" name="tgi_arc">,
6317 <ref id="tgi_bar" name="tgi_bar">,
6318 <ref id="tgi_ellipse" name="tgi_ellipse">,
6319 <ref id="tgi_pieslice" name="tgi_pieslice">,
6320 <ref id="tgi_setcolor" name="tgi_setcolor">
6322 tgi_setcolor(TGI_COLOR_BLACK);
6323 tgi_circle(50, 40, 40);
6329 <sect1>tgi_clear<label id="tgi_clear"><p>
6333 <tag/Function/Clear the drawpage
6334 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6335 <tag/Declaration/<tt/void tgi_clear (void);/
6336 <tag/Description/Clear the drawpage
6337 <tag/Availability/cc65
6338 <tag/See also/Other tgi functions
6344 <sect1>tgi_done<label id="tgi_done"><p>
6348 <tag/Function/End graphics mode, switch back to text mode.
6349 Will NOT uninstall or unload the driver!
6350 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6351 <tag/Declaration/<tt/void tgi_done (void);/
6352 <tag/Description/End graphics mode, switch back to text mode.
6353 Will NOT uninstall or unload the driver!
6354 <tag/Availability/cc65
6355 <tag/See also/Other tgi functions
6361 <sect1>tgi_ellipse<label id="tgi_ellipse"><p>
6365 <tag/Function/The function draws an ellipse in the current color.
6366 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6367 <tag/Declaration/<tt/void __fastcall__ tgi_ellipse (int x, int y, unsigned char rx, unsigned char ry);/
6368 <tag/Description/The function draws an ellipse at position x/y with radii
6369 rx and ry, using the current drawing color.
6370 <tag/Notes/<itemize>
6371 <item>The function is only available as fastcall function, so it may only
6372 be used in presence of a prototype.
6374 <tag/Availability/cc65
6376 <ref id="tgi_arc" name="tgi_arc">,
6377 <ref id="tgi_bar" name="tgi_bar">,
6378 <ref id="tgi_circle" name="tgi_circle">,
6379 <ref id="tgi_pieslice" name="tgi_pieslice">,
6380 <ref id="tgi_setcolor" name="tgi_setcolor">
6382 tgi_setcolor(TGI_COLOR_RED);
6383 tgi_ellipse (50, 40, 40, 20);
6389 <sect1>tgi_free_vectorfont<label id="tgi_free_vectorfont"><p>
6393 <tag/Function/Free a vector font that was previously loaded into memory.
6394 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6395 <tag/Declaration/<tt/void __fastcall__ tgi_free_vectorfont (const tgi_vectorfont* font);/
6396 <tag/Description/Free a vector font that was previously loaded into memory.
6397 <tag/Notes/<itemize>
6398 <item>The function is only available as fastcall function, so it may only
6399 be used in presence of a prototype.
6401 <tag/Availability/cc65
6403 <ref id="tgi_load_vectorfont" name="tgi_load_vectorfont">,
6404 <ref id="tgi_install_vectorfont" name="tgi_install_vectorfont">
6410 <sect1>tgi_getaspectratio<label id="tgi_getaspectratio"><p>
6412 <quote> <descrip> <tag/Function/Return the pixel aspect ratio.
6413 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6414 <tag/Declaration/<tt/unsigned tgi_getaspectratio (void);/
6415 <tag/Description/The function returns the pixel aspect ratio for the current
6416 driver and display as an 8.8 fixed point value. It may be used to correct
6417 geometric shapes so they look correct on the display. As an example, a circle
6418 with a radius of 100 pixels may look elliptic on some driver/display
6419 combinations if the aspect ratio is not 1.00.
6420 <tag/Notes/<itemize>
6421 <item>The aspect ratio is encoded in the TGI driver which assumes a "standard"
6422 monitor for the given platform. The aspect ratio may be wrong if another
6424 <item>No TGI function will use the aspect ratio. It is up to the programmer to
6426 <item>The <ref id="tgi_setaspectratio" name="tgi_setaspectratio"> function can
6427 be used to change the aspect ratio for a loaded driver. The value is not reset
6428 by <ref id="tgi_init" name="tgi_init">, so if a driver is linked statically to
6429 an application, switching into and out of graphics mode will not restore the
6430 original aspect ratio.
6432 <tag/Availability/cc65
6434 <ref id="tgi_setaspectratio" name="tgi_setaspectratio">
6440 <sect1>tgi_getcolor<label id="tgi_getcolor"><p>
6444 <tag/Function/Return the current drawing color.
6445 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6446 <tag/Declaration/<tt/unsigned char tgi_getcolor (void);/
6447 <tag/Description/The actual color is an index to a palette. During tgi_init
6448 you will get a default palette. The number of colors depend on the platform.
6449 All platforms recognize at least TGI_COLOR_BLACK and TGI_COLOR_WHITE. But some
6450 platforms have many more predefined colors. If you paint using TGI_COLOR_GREEN
6451 and then you change the green of the palette to blue using tgi_setpalette then
6452 after this painting in TGI_COLOR_GREEN will actually be blue.
6453 <tag/Availability/cc65
6454 <tag/See also/Other tgi functions
6456 color = tgi_getcolor();
6462 <sect1>tgi_getcolorcount<label id="tgi_getcolorcount"><p>
6466 <tag/Function/Get the number of available colors.
6467 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6468 <tag/Declaration/<tt/unsigned char tgi_getcolorcount (void);/
6469 <tag/Description/Tgi platforms use indexed color palettes. This function
6470 returns the number of entries we can use in the palette.
6471 <tag/Availability/cc65
6472 <tag/See also/Other tgi functions
6474 if (tgi_getcolorcount() == 2) {
6475 printf("Only monochrome graphics is supported\n");
6482 <sect1>tgi_getdefpalette<label id="tgi_getdefpalette"><p>
6486 <tag/Function/Get the palette installed by default.
6487 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6488 <tag/Declaration/<tt/const unsigned char* tgi_getdefpalette (void);/
6489 <tag/Description/The tgi driver has a default palette that is active at startup.
6490 The named colors TGI_COLOR_BLACK, TGI_COLOR_WHITE, TGI_COLOR_RED... need this
6491 palette to work correctly.
6492 <tag/Availability/cc65
6493 <tag/See also/Other tgi functions
6499 <sect1>tgi_geterror<label id="tgi_geterror"><p>
6503 <tag/Function/Return the error code for the last operation.
6504 This will also clear the error.
6505 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6506 <tag/Declaration/<tt/unsigned char tgi_geterror (void);/
6507 <tag/Description/Return the error code for the last operation.
6508 This will also clear the error.
6509 <tag/Availability/cc65
6510 <tag/See also/Other tgi functions
6516 <sect1>tgi_geterrormsg<label id="tgi_geterrormsg"><p>
6520 <tag/Function/Get an error message describing the error.
6521 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6522 <tag/Declaration/<tt/const char* __fastcall__ tgi_geterrormsg (unsigned char code);/
6523 <tag/Description/Get an error message describing the error.
6524 <tag/Notes/<itemize>
6525 <item>The function is only available as fastcall function, so it may only
6526 be used in presence of a prototype.
6528 <tag/Availability/cc65
6529 <tag/See also/Other tgi functions
6535 <sect1>tgi_getmaxcolor<label id="tgi_getmaxcolor"><p>
6539 <tag/Function/Get the highest index of the palette.
6540 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6541 <tag/Declaration/<tt/unsigned char tgi_getmaxcolor (void);/
6542 <tag/Description/Get the highest index of the palette.
6543 <tag/Availability/cc65
6544 <tag/See also/Other tgi functions
6550 <sect1>tgi_getmaxx<label id="tgi_getmaxx"><p>
6554 <tag/Function/Get the maximum x coordinate that can be used on this screen.
6555 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6556 <tag/Declaration/<tt/unsigned tgi_getmaxx (void);/
6557 <tag/Description/Get the maximum x coordinate that can be used on this screen.
6558 <tag/Availability/cc65
6559 <tag/See also/Other tgi functions
6565 <sect1>tgi_getmaxy<label id="tgi_getmaxy"><p>
6569 <tag/Function/Get the maximum y coordinate that can be used on this screen.
6570 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6571 <tag/Declaration/<tt/unsigned tgi_getmaxy (void);/
6572 <tag/Description/Get the maximum y coordinate that can be used on this screen.
6573 <tag/Availability/cc65
6574 <tag/See also/Other tgi functions
6580 <sect1>tgi_getpagecount<label id="tgi_getpagecount"><p>
6584 <tag/Function/Return the number of screen pages available.
6585 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6586 <tag/Declaration/<tt/unsigned tgi_getpagecount (void);/
6587 <tag/Description/Return the number of screen pages available.
6588 <tag/Availability/cc65
6590 <ref id="tgi_setdrawpage" name="tgi_setdrawpage">,
6591 <ref id="tgi_setviewpage" name="tgi_setviewpage">
6597 <sect1>tgi_getpalette<label id="tgi_getpalette"><p>
6601 <tag/Function/Get the palette installed.
6602 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6603 <tag/Declaration/<tt/const unsigned char* tgi_getpalette (void);/
6604 <tag/Description/Get the palette installed.
6605 <tag/Availability/cc65
6606 <tag/See also/Other tgi functions
6612 <sect1>tgi_getpixel<label id="tgi_getpixel"><p>
6616 <tag/Function/Get the color of a pixel from the viewpage.
6617 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6618 <tag/Declaration/<tt/unsigned char __fastcall__ tgi_getpixel (int x, int y);/
6619 <tag/Description/Get the color of a pixel from the viewpage.
6620 <tag/Notes/<itemize>
6621 <item>The function is only available as fastcall function, so it may only
6622 be used in presence of a prototype.
6624 <tag/Availability/cc65
6625 <tag/See also/Other tgi functions.
6631 <sect1>tgi_getxres<label id="tgi_getxres"><p>
6635 <tag/Function/Get number of horisontal pixels on the screen.
6636 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6637 <tag/Declaration/<tt/unsigned tgi_getxres (void);/
6638 <tag/Description/Get number of horisontal pixels on the screen.
6639 This is same as tgi_maxx()+1.
6640 <tag/Availability/cc65
6641 <tag/See also/Other tgi functions.
6647 <sect1>tgi_getyres<label id="tgi_getyres"><p>
6651 <tag/Function/Get number of vertical pixels on the screen.
6652 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6653 <tag/Declaration/<tt/unsigned tgi_getyres (void);/
6654 <tag/Description/Get number of vertical pixels on the screen.
6655 This is same as tgi_maxy()+1.
6656 <tag/Availability/cc65
6657 <tag/See also/Other tgi functions.
6663 <sect1>tgi_gotoxy<label id="tgi_gotoxy"><p>
6667 <tag/Function/Set graphics cursor at x, y.
6668 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6669 <tag/Declaration/<tt/void __fastcall__ tgi_gotoxy (int x, int y);/
6670 <tag/Description/Set graphics cursor at x, y.
6671 <tag/Notes/<itemize>
6672 <item>The function is only available as fastcall function, so it may only
6673 be used in presence of a prototype.
6675 <tag/Availability/cc65
6676 <tag/See also/Other tgi functions.
6682 <sect1>tgi_init<label id="tgi_init"><p>
6686 <tag/Function/Initialize the already loaded graphics driver.
6687 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6688 <tag/Declaration/<tt/void tgi_init (void);/
6689 <tag/Description/The tgi_init function will set the default palette to the
6691 <tag/Notes/<itemize>
6692 <item><tt/tgi_init/ will not clear the screen. This allows switching between
6693 text and graphics mode on platforms that have separate memory areas for the
6694 screens. If you want the screen cleared, call <tt/<ref id="tgi_clear"
6695 name="tgi_clear">/ after <tt/tgi_init/.
6697 <tag/Availability/cc65
6698 <tag/See also/Other tgi functions.
6700 tgi_install(tgi_static_stddrv); //Include the driver statically instead of loading it.
6701 tgi_init(); //Set up the default palette and clear the screen.
6707 <sect1>tgi_install<label id="tgi_install"><p>
6711 <tag/Function/Install an already loaded driver and return an error code.
6712 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6713 <tag/Declaration/<tt/unsigned char __fastcall__ tgi_install (void* driver);/
6714 <tag/Description/The function installs a driver that was already loaded into
6715 memory (or linked statically to the program). It returns an error code
6716 (<tt/TGI_ERR_OK/ in case of success).
6717 <tag/Notes/<itemize>
6718 <item>The function is only available as fastcall function, so it may only be
6719 used in presence of a prototype.
6721 <tag/Availability/cc65
6723 <ref id="tgi_load_driver" name="tgi_load_driver">,
6724 <ref id="tgi_uninstall" name="tgi_uninstall">,
6725 <ref id="tgi_unload" name="tgi_unload">
6727 tgi_install(tgi_static_stddrv); //Include the driver statically instead of loading it.
6728 tgi_init(); //Set up the default palette and clear the screen.
6734 <sect1>tgi_install_vectorfont<label id="tgi_install_vectorfont"><p>
6738 <tag/Function/Install an already loaded driver and return an error code.
6739 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6740 <tag/Declaration/<tt/void __fastcall__ tgi_install_vectorfont (const tgi_vectorfont* font);/
6742 Install a vector font for use. More than one vector font can be loaded,
6743 but only one can be active. This function is used to tell which one. Call
6744 with a NULL pointer to uninstall the currently installed font.
6745 <tag/Notes/<itemize>
6746 <item>The function is only available as fastcall function, so it may only be
6747 used in presence of a prototype.
6749 <tag/Availability/cc65
6751 <ref id="tgi_load_vectorfont" name="tgi_load_vectorfont">,
6752 <ref id="tgi_free_vectorfont" name="tgi_free_vectorfont">
6758 <sect1>tgi_ioctl<label id="tgi_ioctl"><p>
6762 <tag/Function/Platform dependent code extensions.
6763 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6764 <tag/Declaration/<tt/unsigned __fastcall__ tgi_ioctl (unsigned char code, void* data);/
6765 <tag/Description/Some platforms have extra display hardware that is not
6766 supported by standard tgi functions. You can extend the driver to support
6767 this extra hardware using tgi_ioctl functions.
6768 <tag/Notes/<itemize>
6769 <item>The function is only available as fastcall function, so it may only
6770 be used in presence of a prototype.
6771 <item>These functions are not easily portable to other cc65 platforms.
6773 <tag/Availability/cc65
6774 <tag/See also/Other tgi functions.
6776 #define tgi_sprite(spr) tgi_ioctl(0, (void*)(spr))
6777 #define tgi_flip() tgi_ioctl(1, (void*)0)
6778 #define tgi_setbgcolor(bgcol) tgi_ioctl(2, (void*)(bgcol))
6779 #define tgi_setframerate(rate) tgi_ioctl(3, (void*)(rate))
6780 #define tgi_busy() tgi_ioctl(4, (void*)0)
6781 #define tgi_updatedisplay() tgi_ioctl(4, (void*)1)
6783 tgi_sprite(&background);
6784 tgi_setcolor(TGI_COLOR_BLUE);
6785 tgi_outttextxy(20,40,"Hello World");
6786 tgi_updatedisplay();
6793 <sect1>tgi_line<label id="tgi_line"><p>
6797 <tag/Function/Draw a line in the current drawing color.
6798 The graphics cursor will be set to x2/y2 by this call.
6799 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6800 <tag/Declaration/<tt/void __fastcall__ tgi_line (int x1, int y1, int x2, int y2);/
6801 <tag/Description/Draw a line in the current drawing color.
6802 The graphics cursor will be set to x2/y2 by this call.
6803 <tag/Notes/<itemize>
6804 <item>The function is only available as fastcall function, so it may only
6805 be used in presence of a prototype.
6807 <tag/Availability/cc65
6808 <tag/See also/Other tgi functions.
6814 <sect1>tgi_lineto<label id="tgi_lineto"><p>
6818 <tag/Function/Draw a line in the current drawing color from the graphics
6819 cursor to the new end point. The graphics cursor will be updated to x2/y2.
6820 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6821 <tag/Declaration/<tt/void __fastcall__ tgi_lineto (int x2, int y2);/
6822 <tag/Description/Draw a line in the current drawing color from the graphics
6823 cursor to the new end point. The graphics cursor will be updated to x2/y2.
6824 <tag/Notes/<itemize>
6825 <item>The function is only available as fastcall function, so it may only
6826 be used in presence of a prototype.
6828 <tag/Availability/cc65
6829 <tag/See also/Other tgi functions.
6835 <sect1>tgi_load_driver<label id="tgi_load_driver"><p>
6839 <tag/Function/Load and install the given driver.
6840 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6841 <tag/Declaration/<tt/void __fastcall__ tgi_load_driver (const char *name);/
6842 <tag/Description/Load and install the driver by name.
6843 Will just load the driver and check if loading was successful.
6844 Will not switch to graphics mode.
6845 <tag/Notes/<itemize>
6846 <item>The function is only available as fastcall function, so it may only
6847 be used in presence of a prototype.
6849 <tag/Availability/cc65
6850 <tag/See also/Other tgi functions.
6856 <sect1>tgi_load_vectorfont<label id="tgi_load_vectorfont"><p>
6860 <tag/Function/Load the given vector font.
6861 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6862 <tag/Declaration/<tt/const tgi_vectorfont* __fastcall__ tgi_load_vectorfont (const char* name);/
6864 Load a vector font into memory and return it. In case of errors, NULL is
6865 returned and an error is set, which can be retrieved using tgi_geterror.
6866 To use the font, it has to be installed using tgi_install_vectorfont.
6867 <tag/Notes/<itemize>
6868 <item>The function is only available as fastcall function, so it may only
6869 be used in presence of a prototype.
6871 <tag/Availability/cc65
6873 <ref id="tgi_install_vectorfont" name="tgi_install_vectorfont">,
6874 <ref id="tgi_free_vectorfont" name="tgi_free_vectorfont">
6880 <sect1>tgi_outtext<label id="tgi_outtext"><p>
6884 <tag/Function/Output text at the current graphics cursor position.
6885 The graphics cursor is moved to the end of the text.
6886 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6887 <tag/Declaration/<tt/void __fastcall__ tgi_outtext (const char* s);/
6888 <tag/Description/Output text at the current graphics cursor position.
6889 The graphics cursor is moved to the end of the text.
6890 <tag/Notes/<itemize>
6891 <item>The function is only available as fastcall function, so it may only
6892 be used in presence of a prototype.
6894 <tag/Availability/cc65
6895 <tag/See also/Other tgi functions.
6901 <sect1>tgi_outtextxy<label id="tgi_outtextxy"><p>
6905 <tag/Function/Output text at the given cursor position.
6906 The graphics cursor is moved to the end of the text.
6907 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6908 <tag/Declaration/<tt/void __fastcall__ tgi_outtextxy (int x, int y, const char* s);/
6909 <tag/Description/Output text at the given cursor position.
6910 The graphics cursor is moved to the end of the text.
6911 <tag/Notes/<itemize>
6912 <item>The function is only available as fastcall function, so it may only
6913 be used in presence of a prototype.
6915 <tag/Availability/cc65
6916 <tag/See also/Other tgi functions.
6922 <sect1>tgi_pieslice<label id="tgi_pieslice"><p>
6926 <tag/Function/Draw an elliptic pie slice in the current color.
6927 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6928 <tag/Declaration/<tt/void __fastcall__ tgi_pie slice (int x, int y,
6929 unsigned char rx, unsigned char ry, unsigned sa, unsigned ea);/
6930 <tag/Description/The function draws an elliptic pie slice with center at x/y
6931 and radii rx/ry using the current drawing color. The pie slice covers the angle
6932 between sa and ea (startangle and endangle), which must be in the range
6934 <tag/Notes/<itemize>
6935 <item>The function is only available as fastcall function, so it may only
6936 be used in presence of a prototype.
6937 <item>The function behaves unexpectedly or may crash if the angles are out
6940 <tag/Availability/cc65
6942 <ref id="tgi_bar" name="tgi_arc">,
6943 <ref id="tgi_bar" name="tgi_bar">,
6944 <ref id="tgi_circle" name="tgi_circle">,
6945 <ref id="tgi_ellipse" name="tgi_ellipse">,
6946 <ref id="tgi_setcolor" name="tgi_setcolor">
6948 /* Draw the closed upper half of an ellipse */
6949 tgi_setcolor(TGI_COLOR_BLUE);
6950 tgi_pieslice (50, 50, 40, 20, 0, 180);
6956 <sect1>tgi_setaspectratio<label id="tgi_setaspectratio"><p>
6958 <quote> <descrip> <tag/Function/Set the pixel aspect ratio.
6959 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6960 <tag/Declaration/<tt/void __fastcall__ tgi_setaspectratio (unsigned ratio);/
6961 <tag/Description/The function sets the pixel aspect ratio for the current
6962 driver and display. The argument is an 8.8 fixed point value. The aspect ratio
6963 may be used to correct geometric shapes so they look correct on a given
6964 display. As an example, a circle with a radius of 100 pixels may look elliptic
6965 on some driver/display combinations if the aspect ratio is not 1.00.
6966 <tag/Notes/<itemize>
6967 <item>The aspect ratio is encoded in the TGI driver which assumes a "standard"
6968 monitor for the given platform. The aspect ratio may be wrong if another
6970 <item>No TGI function will use the aspect ratio. It is up to the programmer to
6972 <item>The <tt/tgi_setaspectratio/ function can be used to change the aspect
6973 ratio for a loaded driver. The value is not reset by <ref id="tgi_init"
6974 name="tgi_init">, so if a driver is linked statically to an application,
6975 switching into and out of graphics mode will not restore the original aspect
6977 <item>The function is available only as a fastcall function; so, it may be used
6978 only in the presence of a prototype.
6980 <tag/Availability/cc65
6982 <ref id="tgi_getaspectratio" name="tgi_getaspectratio">
6988 <sect1>tgi_setcolor<label id="tgi_setcolor"><p>
6992 <tag/Function/Set color to be used in future draw operations.
6993 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6994 <tag/Declaration/<tt/void __fastcall__ tgi_setcolor (unsigned char color);/
6995 <tag/Description/Set color to be used in future draw operations.
6996 <tag/Notes/<itemize>
6997 <item>The function is only available as fastcall function, so it may only
6998 be used in presence of a prototype.
7000 <tag/Availability/cc65
7001 <tag/See also/Other tgi functions.
7003 tgi_setcolor(TGI_COLOR_BLACK);
7005 tgi_setcolor(TGI_COLOR_WHITE);
7006 tgi_bar(10,10,20,20);
7011 <sect1>tgi_setdrawpage<label id="tgi_setdrawpage"><p>
7015 <tag/Function/Set the page for drawing.
7016 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
7017 <tag/Declaration/<tt/void __fastcall__ tgi_setdrawpage (unsigned char page);/
7018 <tag/Description/If the drawpage and the viewpage are the same then all drawing
7019 is seen immediately as it is drawn. For double buffered games you can set the
7020 drawpage to a different page than the viewpage. This lets you draw the next
7021 screen in the background and when the screen is ready you display it.
7022 <tag/Notes/<itemize>
7023 <item>The function is only available as fastcall function, so it may only
7024 be used in presence of a prototype.
7026 <tag/Availability/cc65
7027 <tag/See also/Other tgi functions.
7030 tgi_outtextxy(10, 10, "Hello World");
7031 tgi_setviewpage(1); // Show page 1
7033 tgi_outtextxy(10, 10, "Creating next frame");
7035 tgi_setviewpage(0); // Show page 0
7040 <sect1>tgi_setpalette<label id="tgi_setpalette"><p>
7044 <tag/Function/Set the palette (not available with all drivers/hardware).
7045 Palette is a pointer to as many entries as there are colors.
7046 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
7047 <tag/Declaration/<tt/void __fastcall__ tgi_setpalette (const unsigned char* palette);/
7048 <tag/Description/Set the palette (not available with all drivers/hardware).
7049 Palette is a pointer to as many entries as there are colors.
7050 <tag/Notes/<itemize>
7051 <item>The function is only available as fastcall function, so it may only
7052 be used in presence of a prototype.
7054 <tag/Availability/cc65
7055 <tag/See also/Other tgi functions.
7060 <sect1>tgi_setpixel<label id="tgi_setpixel"><p>
7064 <tag/Function/Plot a pixel on the drawpage with the current color.
7065 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
7066 <tag/Declaration/<tt/void __fastcall__ tgi_setpixel (int x, int y);/
7067 <tag/Description/Plot a pixel on the drawpage with the current color.
7068 <tag/Notes/<itemize>
7069 <item>The function is only available as fastcall function, so it may only
7070 be used in presence of a prototype.
7072 <tag/Availability/cc65
7073 <tag/See also/Other tgi functions.
7078 <sect1>tgi_setviewpage<label id="tgi_setviewpage"><p>
7082 <tag/Function/Set page to be visible on screen.
7083 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
7084 <tag/Declaration/<tt/void __fastcall__ tgi_setviewpage (unsigned char page);/
7085 <tag/Description/If the drawpage and the viewpage are the same then all drawing
7086 is seen immediately as it is drawn. For double buffered games you can set the
7087 drawpage to a different page than the viewpage. This lets you draw the next
7088 screen in the background and when the screen is ready you display it.
7089 <tag/Notes/<itemize>
7090 <item>The function is only available as fastcall function, so it may only
7091 be used in presence of a prototype.
7093 <tag/Availability/cc65
7094 <tag/See also/Other tgi functions.
7097 tgi_outtextxy(10, 10, "Hello World");
7098 tgi_setviewpage(1); // Show page 1
7100 tgi_outtextxy(10, 10, "Creating next frame");
7102 tgi_setviewpage(0); // Show page 0
7107 <sect1>tgi_gettextheight<label id="tgi_gettextheight"><p>
7111 <tag/Function/Calculate the height of the text in pixels according to
7112 the current text style.
7113 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
7114 <tag/Declaration/<tt/unsigned __fastcall__ tgi_gettextheight (const char* s);/
7115 <tag/Description/Calculate the height of the text in pixels according to
7116 the current text style.
7117 <tag/Notes/<itemize>
7118 <item>The function is only available as fastcall function, so it may only
7119 be used in presence of a prototype.
7121 <tag/Availability/cc65
7122 <tag/See also/Other tgi functions.
7127 <sect1>tgi_settextscale<label id="tgi_settextscale"><p>
7131 <tag/Function/Set the scaling for text output.
7132 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
7133 <tag/Declaration/<tt/void __fastcall__ tgi_settextscale (unsigned width, unsigned height);/
7135 Set the scaling for text output. The scaling factors for width and height
7136 are 8.8 fixed point values. This means that $100 = 1 $200 = 2 etc.
7137 <tag/Notes/<itemize>
7138 <item>The function is only available as fastcall function, so it may only
7139 be used in presence of a prototype.
7141 <tag/Availability/cc65
7143 <ref id="tgi_settextstyle" name="tgi_settextstyle">
7148 <sect1>tgi_settextstyle<label id="tgi_settextstyle"><p>
7152 <tag/Function/Set the style for text output.
7153 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
7154 <tag/Declaration/<tt/void __fastcall__ tgi_settextstyle (unsigned char magx, unsigned char magy, unsigned char dir, unsigned char font);/
7155 <tag/Description/Set the style for text output.
7156 <tag/Notes/<itemize>
7157 <item>The function is only available as fastcall function, so it may only
7158 be used in presence of a prototype.
7160 <tag/Availability/cc65
7162 <ref id="tgi_settextscale" name="tgi_settextscale">
7167 <sect1>tgi_gettextwidth<label id="tgi_gettextwidth"><p>
7171 <tag/Function/Calculate the width of the text in pixels according to the current text style.
7172 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
7173 <tag/Declaration/<tt/unsigned __fastcall__ tgi_gettextwidth (const char* s);/
7174 <tag/Description/Calculate the width of the text in pixels according to the current text style.
7175 <tag/Notes/<itemize>
7176 <item>The function is only available as fastcall function, so it may only
7177 be used in presence of a prototype.
7179 <tag/Availability/cc65
7180 <tag/See also/Other tgi functions.
7185 <sect1>tgi_uninstall<label id="tgi_uninstall"><p>
7189 <tag/Function/Uninstall the currently loaded driver but do not unload it.
7190 Will call tgi_done if necessary.
7191 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
7192 <tag/Declaration/<tt/void tgi_uninstall (void);/
7193 <tag/Description/Uninstall the currently loaded driver but do not unload it.
7194 Will call tgi_done if necessary.
7195 <tag/Availability/cc65
7196 <tag/See also/Other tgi functions.
7201 <sect1>tgi_unload<label id="tgi_unload"><p>
7205 <tag/Function/Uninstall, then unload the currently loaded driver.
7206 Will call tgi_done if necessary.
7207 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
7208 <tag/Declaration/<tt/void tgi_unload (void);/
7209 <tag/Description/Uninstall, then unload the currently loaded driver.
7210 Will call tgi_done if necessary.
7211 <tag/Availability/cc65
7212 <tag/See also/Other tgi functions.
7217 <sect1>time<label id="time"><p>
7221 <tag/Function/Get the time.
7222 <tag/Header/<tt/<ref id="time.h" name="time.h">/
7223 <tag/Declaration/<tt/time_t __fastcall__ time (time_t* t);/
7224 <tag/Description/The function returns the time since the 1970-01-01 00:00:00
7225 measured in seconds. If the pointer <tt/t/ is not <tt/NULL/, the function
7226 result will also be stored there. If no time is available, <tt/(time_t)-1/ is
7227 returned and <tt/errno/ is set to <tt/ENOSYS/.
7228 <tag/Notes/<itemize>
7229 <item>The function is only available as fastcall function, so it may
7230 only be used in presence of a prototype.
7231 <item>Many platforms supported by cc65 do not have a realtime clock, so the
7232 returned value may not be valid.
7234 <tag/Availability/ISO 9899
7236 <ref id="clock" name="clock">
7242 <sect1>toggle_videomode<label id="toggle_videomode"><p>
7246 <tag/Function/Toggle between 40 and 80 column mode.
7247 <tag/Header/<tt/<ref id="c128.h" name="c128.h">/
7248 <tag/Declaration/<tt/void toggle_videomode (void);/
7249 <tag/Description/Toggle between 40 and 80 column mode. The settings for the
7250 old mode (cursor position, color and so on) are saved and restored together
7252 <tag/Notes/<itemize>
7253 <item>The function is specific to the C128.
7254 <item>This function is deprecated. Please use <ref id="videomode"
7255 name="videomode"> instead!
7257 <tag/Availability/C128
7259 <ref id="fast" name="fast">,
7260 <ref id="slow" name="slow">,
7261 <ref id="videomode" name="videomode">
7267 <sect1>tolower<label id="tolower"><p>
7271 <tag/Function/Convert a character into its lower case representation.
7272 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
7273 <tag/Declaration/<tt/int __fastcall__ tolower (int c);/
7274 <tag/Description/The function returns the given character converted to lower
7275 case. If the given character is not a letter, it is returned unchanged.
7276 <tag/Notes/<itemize>
7277 <item>The function is only available as fastcall function, so it may
7278 only be used in presence of a prototype.
7280 <tag/Availability/ISO 9899
7282 <ref id="islower" name="islower">,
7283 <ref id="isupper" name="isupper">,
7284 <ref id="toupper" name="toupper">
7290 <sect1>toupper<label id="toupper"><p>
7294 <tag/Function/Convert a character into its upper case representation.
7295 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
7296 <tag/Declaration/<tt/int __fastcall__ toupper (int c);/
7297 <tag/Description/The function returns the given character converted to upper
7298 case. If the given character is not a letter, it is returned unchanged.
7299 <tag/Notes/<itemize>
7300 <item>The function is only available as fastcall function, so it may
7301 only be used in presence of a prototype.
7303 <tag/Availability/ISO 9899
7305 <ref id="islower" name="islower">,
7306 <ref id="isupper" name="isupper">,
7307 <ref id="tolower" name="tolower">
7313 <sect1>ultoa<label id="ultoa"><p>
7317 <tag/Function/Convert an unsigned long integer into a string.
7318 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
7319 <tag/Declaration/<tt/char* __fastcall__ ultoa (unsigned long val, char* buf, int radix);/
7320 <tag/Description/<tt/itoa/ converts the unsigned long integer <tt/val/ into a
7321 string using <tt/radix/ as the base.
7322 <tag/Notes/<itemize>
7323 <item>There are no provisions to prevent a buffer overflow.
7324 <item>The function is non standard, so it is not available in strict ANSI mode.
7325 You should probably use <tt/sprintf/ instead.
7326 <item>The function is only available as fastcall function, so it may only be
7327 used in presence of a prototype.
7329 <tag/Availability/cc65
7331 <ref id="atoi" name="atoi">,
7332 <ref id="atol" name="atol">,
7333 <ref id="itoa" name="itoa">,
7334 <ref id="ltoa" name="ltoa">,
7335 <ref id="utoa" name="utoa">
7341 <sect1>unlink<label id="unlink"><p>
7345 <tag/Function/Delete a file.
7346 <tag/Header/<tt/<ref id="unistd.h" name="unistd.h">/
7347 <tag/Declaration/<tt/int __fastcall__ unlink (const char* name);/
7348 <tag/Description/<tt/unlink/ deletes the file with the given name. On success,
7349 zero is returned. On error, -1 is returned and <tt/errno/ is set to an error
7350 code describing the reason for the failure.
7351 <tag/Notes/<itemize>
7352 <item>The use of this function is discouraged. Please use <tt/<ref id="remove"
7353 name="remove">/ instead, which is a native ANSI C function and does the same.
7354 <item>This function is not available on all cc65 targets (depends on the
7355 availability of file I/O).
7356 <item>The function is only available as fastcall function, so it may only
7357 be used in presence of a prototype.
7358 <item>Instead of <tt/unlink/, <tt/<ref id="remove" name="remove">/ should be
7359 used, which has the same semantics, but is more portable, because it conforms
7360 to the ISO C standard.
7362 <tag/Availability/POSIX 1003.1
7364 <ref id="remove" name="remove">
7367 #include <stdio.h>
7368 #include <unistd.h>
7370 #define FILENAME "helloworld"
7372 if (unlink (FILENAME) == 0) {
7373 printf ("We deleted %s successfully\n", FILENAME);
7375 printf ("There was a problem deleting %s\n", FILENAME);
7382 <sect1>utoa<label id="utoa"><p>
7386 <tag/Function/Convert an unsigned integer into a string.
7387 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
7388 <tag/Declaration/<tt/char* __fastcall__ utoa (unsigned val, char* buf, int radix);/
7389 <tag/Description/<tt/itoa/ converts the unsigned integer <tt/val/ into a string
7390 using <tt/radix/ as the base.
7391 <tag/Notes/<itemize>
7392 <item>There are no provisions to prevent a buffer overflow.
7393 <item>The function is non standard, so it is not available in strict ANSI mode.
7394 You should probably use <tt/sprintf/ instead.
7395 <item>The function is only available as fastcall function, so it may only be
7396 used in presence of a prototype.
7398 <tag/Availability/cc65
7400 <ref id="atoi" name="atoi">,
7401 <ref id="atol" name="atol">,
7402 <ref id="itoa" name="itoa">,
7403 <ref id="ltoa" name="ltoa">,
7404 <ref id="ultoa" name="ultoa">
7410 <sect1>vcprintf<label id="vcprintf"><p>
7414 <tag/Function/Formatted output to the console.
7415 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
7416 <tag/Declaration/<tt/int __fastcall__ vcprintf (const char* format, va_list ap);/
7417 <tag/Description/The arguments specified as a <tt/va_list/ are converted to
7418 text where necessary and formatted according to the format string given. The
7419 resulting string is output to the console. <tt/vcprintf/ supports the same
7420 format specifiers as <tt/vprintf/. <!-- <tt/<ref id="vprintf" name="vprintf">/. -->
7421 <tag/Notes/<itemize>
7422 <item>Like all other <tt/conio/ output functions, <tt/vcprintf/ distinguishes
7423 between <tt/\r/ and <tt/\n/.
7424 <item>The function is only available as fastcall function, so it may only be
7425 used in presence of a prototype.
7427 <tag/Availability/cc65
7429 <ref id="cprintf" name="cprintf">,
7430 <ref id="cputc" name="cputc">,
7431 <ref id="cputcxy" name="cputcxy">,
7432 <ref id="cputs" name="cputs">,
7433 <ref id="cputsxy" name="cputsxy">
7439 <sect1>videomode<label id="videomode"><p>
7443 <tag/Function/Switch to either 40 or 80 column mode.
7444 <tag/Header/<tt/<ref id="apple2enh.h" name="apple2enh.h">,
7445 <ref id="c128.h" name="c128.h">/
7446 <tag/Declaration/<tt/unsigned __fastcall__ videomode (unsigned Mode);/
7447 <tag/Description/Switch to 40 or 80 column mode depending on the argument. If
7448 the requested mode is already active, nothing happens. The old mode is returned
7450 <tag/Notes/<itemize>
7451 <item>The function is specific to the C128 and enhanced Apple //e.
7452 <item>This function replaces <ref id="toggle_videomode"
7453 name="toggle_videomode">.
7454 <item>The function is only available as fastcall function, so it may only be
7455 used in presence of a prototype.
7457 <tag/Availability/C128 and enhanced Apple //e
7459 <ref id="fast" name="fast">,
7460 <ref id="slow" name="slow">,
7461 <ref id="toggle_videomode" name="toggle_videomode">
7467 <sect1>wherex<label id="wherex"><p>
7471 <tag/Function/Return the current X position of the text mode cursor.
7472 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
7473 <tag/Declaration/<tt/unsigned char wherex (void);/
7474 <tag/Description/The function returns the current X position of the text mode
7475 cursor. Zero is returned for the leftmost screen position.
7476 <tag/Availability/cc65
7478 <ref id="gotox" name="gotox">,
7479 <ref id="gotoy" name="gotoy">,
7480 <ref id="gotoxy" name="gotoxy">,
7481 <ref id="wherey" name="wherey">
7487 <sect1>wherey<label id="wherey"><p>
7491 <tag/Function/Return the current Y position of the text mode cursor.
7492 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
7493 <tag/Declaration/<tt/unsigned char wherey (void);/
7494 <tag/Description/The function returns the current Y position of the text mode
7495 cursor. Zero is returned for the uppermost screen position.
7496 <tag/Availability/cc65
7498 <ref id="gotox" name="gotox">,
7499 <ref id="gotoy" name="gotoy">,
7500 <ref id="gotoxy" name="gotoxy">,
7501 <ref id="wherex" name="wherex">