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.
952 <tag/Availability/cc65 (<tt/atari/ and <tt/atarixl/ platforms)
957 <sect1>_poserror<label id="_poserror"><p>
961 <tag/Function/Print an error message for the error in <tt/_oserror/.
962 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
963 <tag/Declaration/<tt/void __fastcall__ _poserror (const char* msg);/
964 <tag/Description/<tt/_poserror/ prints an error message to <tt/stderr/. If
965 <tt/msg/ is not <tt/NULL/ and not an empty string, it is printed followed by
966 a colon and a blank. Then the error message for the current contents of
967 <tt/_oserror/ are printed followed by a newline. The message output is the
968 same as returned by <tt/<ref id="_stroserror" name="_stroserror">/ with an
969 argument of <tt/_oserror/.
971 <item>Since operating system specific error code are - you guessed it -
972 operating system specific, the value in <tt/_oserror/ and the message that is
973 printed depends on the cc65 target.
974 <item>The function is only available as fastcall function, so it may only
975 be used in presence of a prototype.
977 <tag/Availability/cc65
979 <ref id="_stroserror" name="_stroserror">,
980 <ref id="perror" name="perror">
986 <sect1>_randomize<label id="_randomize"><p>
990 <tag/Function/Initialize the pseudo random number generator.
991 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
992 <tag/Declaration/<tt/void _randomize (void);/
993 <tag/Description/The function initializes the random number generator with
994 a seed derived from fast changing hardware events, so the seed itself can be
995 considered random to a certain degree.
997 <item>The randomness of the seed depends on the machine hardware.
999 <tag/Availability/cc65
1001 <ref id="rand" name="rand">,
1002 <ref id="srand" name="srand">
1008 <sect1>_stroserror<label id="_stroserror"><p>
1012 <tag/Function/Return a string describing an OS specific error code.
1013 <tag/Header/<tt/<ref id="string.h" name="string.h">/
1014 <tag/Declaration/<tt/const char* __fastcall__ _stroserror (unsigned char errcode);/
1015 <tag/Description/<tt/_stroserror/ will return a string describing the given
1016 operating system specific error code.
1017 <tag/Notes/<itemize>
1018 <item>Since operating system specific error code are - you guessed it -
1019 operating system specific, the parameter and the string returned depend on the
1021 <item>The function is only available as fastcall function, so it may only be
1022 used in presence of a prototype.
1024 <tag/Availability/cc65
1026 <ref id="strerror" name="strerror">
1032 <sect1>_swap<label id="_swap"><p>
1036 <tag/Function/Swap the contents of memory areas.
1037 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1038 <tag/Declaration/<tt/void __fastcall__ _swap (void* p, void* q, size_t size);/
1039 <tag/Description/<tt/_swap/ will swap (exchange) the contents of the two memory
1040 areas pointed to by <tt/p/ and <tt/q/. Both memory areas are assumed to be
1041 <tt/size/ bytes in size.
1042 <tag/Notes/<itemize>
1043 <item>The memory areas may not overlap, otherwise the results are undefined.
1044 <item>The function is only available as fastcall function, so it may only be
1045 used in presence of a prototype.
1047 <tag/Availability/cc65
1049 <ref id="memcpy" name="memcpy">,
1050 <ref id="memmove" name="memmove">
1056 <sect1>_sys<label id="_sys"><p>
1060 <tag/Function/Call a subroutine passing register values.
1061 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
1062 <tag/Declaration/<tt/void __fastcall__ _sys (struct regs* r);/
1063 <tag/Description/The function will call the subroutine at the address
1064 specified in the <tt/pc/ member of the passed <tt/regs/ structure. All
1065 registers and the CPU flags are set to the values given in the <tt/regs/
1066 structure. On return from the subroutine, the new values of the registers and
1067 flags are stored back overwriting the old values.
1068 <tag/Notes/<itemize>
1069 <item>Bits 4 and 5 of the flags value in the <tt/regs/ structure are ignored
1070 when calling the subroutine (they are unchanged from their current values).
1071 <item>The function is only available as fastcall function, so it may only be
1072 used in presence of a prototype.
1074 <tag/Availability/cc65
1080 <sect1>BRK<label id="BRK"><p>
1084 <tag/Function/Insert a 6502 BRK instrunction into the code.
1085 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
1086 <tag/Declaration/<tt/void BRK (void);/
1087 <tag/Description/The function will insert a 6502 BRK instruction into the code
1088 which may be used to trigger a debugger.
1089 <tag/Notes/<itemize>
1090 <item>The function is actually a macro.
1091 <item>The inserted instruction may lead to unexpected results if no debugger
1094 <tag/Availability/cc65
1096 <ref id="CLI" name="CLI">,
1097 <ref id="SEI" name="SEI">
1103 <sect1>CLI<label id="CLI"><p>
1107 <tag/Function/Insert a 6502 CLI instrunction into the code.
1108 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
1109 <tag/Declaration/<tt/void CLI (void);/
1110 <tag/Description/The function will insert a 6502 CLI instruction into the code,
1111 so interrupts are enabled. Enabling interrupts has no effects if they are
1112 already enabled (the default).
1113 <tag/Notes/<itemize>
1114 <item>The function is actually a macro.
1115 <item>Disabling interrupts may lead to unexpected results.
1117 <tag/Availability/cc65
1119 <ref id="BRK" name="BRK">,
1120 <ref id="SEI" name="SEI">
1126 <sect1>PEEK<label id="PEEK"><p>
1130 <tag/Function/Read a byte from memory.
1131 <tag/Header/<tt/<ref id="peekpoke.h" name="peekpoke.h">/
1132 <tag/Declaration/<tt/unsigned char PEEK (unsigned addr);/
1133 <tag/Description/The function will read the absolute memory given by <tt/addr/
1134 and return the value read.
1135 <tag/Notes/<itemize>
1136 <item>The function is actually a macro.
1137 <item>This function depends highly on the platform and environment.
1139 <tag/Availability/cc65
1141 <ref id="PEEKW" name="PEEKW">,
1142 <ref id="POKE" name="POKE">
1148 <sect1>PEEKW<label id="PEEKW"><p>
1152 <tag/Function/Read a word (two bytes) from memory.
1153 <tag/Header/<tt/<ref id="peekpoke.h" name="peekpoke.h">/
1154 <tag/Declaration/<tt/unsigned PEEKW (unsigned addr);/
1155 <tag/Description/The function will read the absolute memory given by <tt/addr/
1156 and return the value read. The byte read from the higher address is the high
1157 byte of the return value.
1158 <tag/Notes/<itemize>
1159 <item>The function is actually a macro.
1160 <item>This function depends highly on the platform and environment.
1161 <item>The order in which the two bytes are read is unspecified and may
1162 depend of the address expression used.
1164 <tag/Availability/cc65
1166 <ref id="PEEK" name="PEEK">,
1167 <ref id="POKE" name="POKE">
1173 <sect1>POKE<label id="POKE"><p>
1177 <tag/Function/Write a byte to memory.
1178 <tag/Header/<tt/<ref id="peekpoke.h" name="peekpoke.h">/
1179 <tag/Declaration/<tt/void POKE (unsigned addr, unsigned char val);/
1180 <tag/Description/The function writes the value <tt/val/ to the absolute
1181 memory address given by <tt/addr/.
1182 <tag/Notes/<itemize>
1183 <item>The function is actually a macro.
1184 <item>This function depends highly on the platform and environment.
1185 <item>Careless use will cause the program to act strange or may crash the
1188 <tag/Availability/cc65
1190 <ref id="PEEK" name="PEEK">,
1191 <ref id="POKEW" name="POKEW">
1197 <sect1>POKEW<label id="POKEW"><p>
1201 <tag/Function/Write a word (two bytes) to memory.
1202 <tag/Header/<tt/<ref id="peekpoke.h" name="peekpoke.h">/
1203 <tag/Declaration/<tt/void POKEW (unsigned addr, unsigned val);/
1204 <tag/Description/The function writes the value <tt/val/ to the absolute
1205 memory address given by <tt/addr/. The low byte of <tt/val/ is written to
1206 the <tt/addr/, the high byte is written to <tt/addr+1/.
1207 <tag/Notes/<itemize>
1208 <item>The function is actually a macro.
1209 <item>This function depends highly on the platform and environment.
1210 <item>Careless use will cause the program to act strange or may crash the
1212 <item>The order in which the two bytes are written is unspecified and may
1213 depend of the address expression used.
1215 <tag/Availability/cc65
1217 <ref id="PEEK" name="PEEK">,
1218 <ref id="POKE" name="POKE">
1224 <sect1>SEI<label id="SEI"><p>
1228 <tag/Function/Insert a 6502 SEI instrunction into the code.
1229 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
1230 <tag/Declaration/<tt/void SEI (void);/
1231 <tag/Description/The function will insert a 6502 SEI instruction into the code,
1232 so interrupts are disabled. Note that non maskable interrupts cannot be
1234 <tag/Notes/<itemize>
1235 <item>The function is actually a macro.
1236 <item>Disabling interrupts may lead to unexpected results.
1238 <tag/Availability/cc65
1240 <ref id="BRK" name="BRK">,
1241 <ref id="CLI" name="CLI">
1247 <sect1>abort<label id="abort"><p>
1251 <tag/Function/Terminates a program abnormally.
1252 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1253 <tag/Declaration/<tt/void abort (void);/
1254 <tag/Description/<tt/abort/ raises <tt/SIGABRT/, writes a termination message
1255 on stderr, then terminates the program with an exit code of 3.
1256 <tag/Availability/ISO 9899
1258 <ref id="assert" name="assert">,
1259 <ref id="exit" name="exit">,
1260 <ref id="raise" name="raise">
1266 <sect1>abs<label id="abs"><p>
1270 <tag/Function/Returns the absolute value of an integer.
1271 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1272 <tag/Declaration/<tt/int __fastcall__ abs (int v);/
1273 <tag/Description/<tt/abs/ returns the absolute value of the argument passed to
1275 <tag/Notes/<itemize>
1276 <item>The return value is undefined if <tt/INT_MIN/ is passed to the function.
1277 <item>The function is only available as fastcall function, so it may only be
1278 used in presence of a prototype.
1280 <tag/Availability/ISO 9899
1282 <ref id="labs" name="labs">
1288 <sect1>assert<label id="assert"><p>
1292 <tag/Function/Test a condition and possibly abort.
1293 <tag/Header/<tt/<ref id="assert.h" name="assert.h">/
1294 <tag/Declaration/<tt/void assert (int cond);/
1295 <tag/Description/<tt/assert/ is a macro that expands to a <tt/id/
1296 statement. If the condition evaluates t zero (false), assert prints a message
1297 on stderr and aborts the program.
1298 <tag/Notes/<itemize>
1299 <item>The function is actually a macro.
1301 <tag/Availability/ISO 9899
1303 <ref id="abort" name="abort">,
1304 <ref id="exit" name="exit">
1310 <sect1>atexit<label id="atexit"><p>
1314 <tag/Function/Register an exit function.
1315 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1316 <tag/Declaration/<tt/int __fastcall__ atexit (void (*exitfunc) (void));/
1317 <tag/Description/<tt/atexit/ registers the function pointed to by
1318 <tt/exitfunc/ as an exit function. Exit functions are called when the program
1319 terminates, they are called in LIFO order (the last function registered is
1320 called first). <tt/atexit/ returns zero on success and a nonzero value on
1322 <tag/Notes/<itemize>
1323 <item>A maximum of 5 exit functions can be registered.
1324 <item>There is no way to unregister an exit function.
1325 <item>The function is only available as fastcall function, so it may only be
1326 used in presence of a prototype.
1328 <tag/Availability/ISO 9899
1330 <ref id="abort" name="abort">,
1331 <ref id="exit" name="exit">
1337 <sect1>atmos_load<label id="atmos_load"><p>
1341 <tag/Function/Load Atmos tape.
1342 <tag/Header/<tt/<ref id="atmos.h" name="atmos.h">/
1343 <tag/Declaration/<tt/void __fastcall__ atmos_load(const char* name);/
1344 <tag/Description/<tt/atmos_load/ reads a memory block from tape.
1345 <tag/Notes/<itemize>
1346 <item>The function is available only as a fastcall function; so, it may be used
1347 only in the presence of a prototype.
1349 <tag/Availability/cc65
1351 <ref id="atmos_save" name="atmos_save">
1357 <sect1>atmos_save<label id="atmos_save"><p>
1361 <tag/Function/Save Atmos tape.
1362 <tag/Header/<tt/<ref id="atmos.h" name="atmos.h">/
1363 <tag/Declaration/<tt/void __fastcall__ atmos_save(const char* name, const void* start, const void* end);/
1364 <tag/Description/<tt/atmos_save/ writes a memory block to 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_load" name="atmos_load">
1373 atmos_save("hires", 0xa000, 0xc000);
1379 <sect1>atoi<label id="atoi"><p>
1383 <tag/Function/Convert a string to an integer.
1384 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1385 <tag/Declaration/<tt/int __fastcall__ atoi (const char* s);/
1386 <tag/Description/<tt/atoi/ converts the given string into an integer.
1387 Conversion stops as soon as any invalid character is encountered.
1388 <tag/Notes/<itemize>
1389 <item>There is no way to detect any conversion errors.
1390 <item>The function does not check for an numerical overflow when converting.
1391 <item>The function is only available as fastcall function, so it may only be
1392 used in presence of a prototype.
1394 <tag/Availability/ISO 9899
1396 <ref id="atol" name="atol">,
1397 <ref id="itoa" name="itoa">,
1398 <ref id="ltoa" name="ltoa">,
1399 <ref id="ultoa" name="ultoa">,
1400 <ref id="utoa" name="utoa">
1406 <sect1>atol<label id="atol"><p>
1410 <tag/Function/Convert a string to a long integer.
1411 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1412 <tag/Declaration/<tt/long __fastcall__ atol (const char* s);/
1413 <tag/Description/<tt/atol/ converts the given string into a long integer.
1414 Conversion stops as soon as any invalid character is encountered.
1415 <tag/Notes/<itemize>
1416 <item>There is no way to detect any conversion errors.
1417 <item>The function does not check for an numerical overflow when converting.
1418 <item>The function is only available as fastcall function, so it may only be
1419 used in presence of a prototype.
1421 <tag/Availability/ISO 9899
1423 <ref id="atoi" name="atoi">,
1424 <ref id="itoa" name="itoa">,
1425 <ref id="ltoa" name="ltoa">,
1426 <ref id="ultoa" name="ultoa">,
1427 <ref id="utoa" name="utoa">
1433 <sect1>bgcolor<label id="bgcolor"><p>
1437 <tag/Function/Set the background text color.
1438 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1439 <tag/Declaration/<tt/unsigned char __fastcall__ bgcolor (unsigned char color);/
1440 <tag/Description/The function will set a new background color and return the
1441 old (current) one. The background color is valid for the whole text output
1442 area of the screen, not just for new text.
1443 <tag/Notes/<itemize>
1444 <item>Background colors are system dependent. The function may have no effect
1445 on systems where the background color cannot be changed.
1446 <item>The function is only available as fastcall function, so it may only be
1447 used in presence of a prototype.
1449 <tag/Availability/cc65
1451 <ref id="bordercolor" name="bordercolor">,
1452 <ref id="textcolor" name="textcolor">
1458 <sect1>bordercolor<label id="bordercolor"><p>
1462 <tag/Function/Set the border (frame) color.
1463 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1464 <tag/Declaration/<tt/unsigned char __fastcall__ bordercolor (unsigned char color);/
1465 <tag/Description/The function will set a new border color. It returns the old
1466 (current) border color.
1467 <tag/Notes/<itemize>
1468 <item>Border colors are system dependent. The function may have no effect
1469 on systems where the border color cannot be changed.
1470 <item>The function is only available as fastcall function, so it may only
1471 be used in presence of a prototype.
1473 <tag/Availability/cc65
1475 <ref id="bgcolor" name="bgcolor">,
1476 <ref id="textcolor" name="textcolor">
1482 <sect1>bsearch<label id="bsearch"><p>
1486 <tag/Function/Do a binary search in a sorted array.
1487 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1488 <tag/Declaration/<tt/void* __fastcall__ bsearch (const void* key,
1489 const void* base, size_t n, size_t size,
1490 int __fastcall__ (* cmp) (const void*, const void*));/
1491 <tag/Description/<tt/bsearch/ searches a sorted array for a member that
1492 matches the one pointed to by <tt/key/. <tt/base/ is the address of the array,
1493 <tt/n/ is the number of elements, <tt/size/ the size of an element and <tt/cmp/
1494 the function used to compare the members against the key. The function returns
1495 a pointer to the member found, or <tt/NULL/ if there was no match.
1496 <tag/Notes/<itemize>
1497 <item>The contents of the array must be sorted in ascending order according to
1498 the compare function given.
1499 <item>If there are multiple members that match the key, the function will
1500 return one of the members.
1501 <item>The function is only available as fastcall function, so it may only
1502 be used in presence of a prototype.
1503 <item>The function to which <tt/cmp/ points must have the <tt/fastcall/ calling
1506 <tag/Availability/ISO 9899
1508 <ref id="qsort" name="qsort">
1514 <sect1>bzero<label id="bzero"><p>
1518 <tag/Function/Fill a memory area with zeroes.
1519 <tag/Header/<tt/<ref id="string.h" name="string.h">/
1520 <tag/Declaration/<tt/void __fastcall__ bzero (void* p, size_t count);/
1521 <tag/Description/<tt/bzero/ fills the memory area pointed to by <tt/p/ with
1523 <tag/Notes/<itemize>
1524 <item>The function is non standard and therefore only available in non ANSI
1525 mode. You should use <tt/<ref id="memset" name="memset">/ instead.
1526 <item>The function is only available as fastcall function, so it may only
1527 be used in presence of a prototype.
1529 <tag/Availability/cc65
1531 <ref id="_swap" name="_swap">,
1532 <ref id="memcpy" name="memcpy">,
1533 <ref id="memmove" name="memmove">,
1534 <ref id="memset" name="memset">,
1540 <sect1>c64mode<label id="c64mode"><p>
1544 <tag/Function/Switch the C128 into C64 compatible mode.
1545 <tag/Header/<tt/<ref id="c128.h" name="c128.h">/
1546 <tag/Declaration/<tt/void c64mode (void);/
1547 <tag/Description/The function will cause the machine to reboot into C64 mode.
1548 <tag/Notes/<itemize>
1549 <item>The function is specific to the C128.
1550 <item>The function will not return to the caller.
1552 <tag/Availability/C128
1558 <sect1>calloc<label id="calloc"><p>
1562 <tag/Function/Allocate and clear memory.
1563 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1564 <tag/Declaration/<tt/void* __fastcall__ calloc (size_t n, size_t size);/
1565 <tag/Description/<tt/calloc/ allocates memory for an array of <tt/n/ elements
1566 of size <tt/size/, clears the whole block with binary zeroes and returns a
1567 pointer to it. On error (not enough memory available), <tt/calloc/ returns
1569 <tag/Notes/<itemize>
1570 <item>Clearing the memory may not have the expected effect on all platforms:
1571 pointers in the block may not be <tt/NULL/ and floating point variables may
1572 not be zero (0.0). In other words: The "clearing" effect of this function
1573 should be used with care for portable programs.
1574 <item>The function is only available as fastcall function, so it may only
1575 be used in presence of a prototype.
1577 <tag/Availability/ISO 9899
1579 <ref id="_heapadd" name="_heapadd">,
1580 <ref id="_heapblocksize" name="_heapblocksize">,
1581 <ref id="_heapmaxavail" name="_heapmaxavail">,
1582 <ref id="_heapmemavail" name="_heapmemavail">,
1583 <ref id="free" name="free">,
1584 <ref id="malloc" name="malloc">,
1585 <ref id="realloc" name="realloc">
1591 <sect1>cbm_k_acptr<label id="cbm_k_acptr"><p>
1595 <tag/Function/Input byte from serial bus
1596 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
1597 <tag/Declaration/<tt/unsigned char cbm_k_acptr (void);/
1598 <tag/Description/The function returns a byte of data, which it
1599 gets from the current TALKer on the serial bus.
1600 In order to receive the data, the device must have previously been
1601 sent a command to TALK and a secondary address if it needs one.
1602 <tag/Notes/<itemize>
1605 <tag/Availability/cc65
1607 <ref id="cbm_k_talk" name="cbm_k_talk">,
1613 <sect1>cbm_k_basin<label id="cbm_k_basin"><p>
1617 <tag/Function/Input a Character from the Current Device
1618 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
1619 <tag/Declaration/<tt/unsigned char cbm_k_basin (void);/
1620 <tag/Description/The function returns a character from the current input device.
1621 Device must first have been OPENed and then designated as the input channel by the CHKIN routine.
1622 When this function is called, the next byte of data available from the device is returned.
1623 Exception is the routine for the keyboard device (which is the default input device).
1624 <tag/Notes/<itemize>
1627 <tag/Availability/cc65
1629 <ref id="cbm_k_open" name="cbm_k_open">,
1630 <ref id="cbm_k_chkin" name="cbm_k_chkin">
1636 <sect1>cbm_k_bsout<label id="cbm_k_bsout"><p>
1640 <tag/Function/Output a byte
1641 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
1642 <tag/Declaration/<tt/void __fastcall__ cbm_k_bsout (unsigned char C);/
1643 <tag/Description/Function sends the character to the current output device.
1644 Unless a device has been OPENed and designated as the
1645 current output channel using the CHKOUT routine, the character is
1646 printed to the screen, which is the default output device. If the
1647 cassette is the current device, outputting a byte will only add it to
1648 the buffer. No actual transmission of data will occur until the
1649 192-byte buffer is full.
1650 <tag/Notes/<itemize>
1651 <item>The function is only available as fastcall function, so it may
1652 only be used in presence of a prototype.
1654 <tag/Availability/cc65
1656 <ref id="cbm_k_open" name="cbm_k_open">,
1657 <ref id="cbm_k_chkin" name="cbm_k_chkout">
1663 <sect1>cbm_k_chkin<label id="cbm_k_chkin"><p>
1667 <tag/Function/Designate a Logical File As the Current Input Channel
1668 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
1669 <tag/Declaration/<tt/unsigned char __fastcall__ cbm_k_chkin (unsigned char FN);/
1670 <tag/Description/If you wish to
1671 get data from any device other than the keyboard, this function must be
1672 called after OPENing the device, before you can get a data byte with
1673 the cbm_k_basin or cbm_k_getin routine. When called, the routine will designate
1674 the logical file whose file number was supplied as the
1675 current file, its device as the current device, and its secondary
1676 address as the current secondary address. If the device on the
1677 channel is a serial device, which requires a TALK command and
1678 sometimes a secondary address, function will send them over the
1680 <tag/Notes/<itemize>
1681 <item>The function is only available as fastcall function, so it may
1682 only be used in presence of a prototype.
1684 <tag/Availability/cc65
1686 <ref id="cbm_k_open" name="cbm_k_open">,
1687 <ref id="cbm_k_basin" name="cbm_k_basin">,
1688 <ref id="cbm_k_getin" name="cbm_k_getin">
1694 <sect1>cbm_k_ciout<label id="cbm_k_ciout"><p>
1698 <tag/Function/Transmit a byte over the serial bus
1699 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
1700 <tag/Declaration/<tt/void __fastcall__ cbm_k_ciout (unsigned char C);/
1701 <tag/Description/Purpose of this function is to send a byte of data over
1702 the serial bus. In order for the data to be received, the serial
1703 device must have first been commanded to LISTEN and been given a
1704 secondary address if necessary. This routine always buffers the
1705 current character, and defers sending it until the next byte is
1706 buffered. When the UNLISTEN command is sent, the last byte will be
1707 sent with an End or Identify (EOI).
1708 <tag/Notes/<itemize>
1709 <item>The function is only available as fastcall function, so it may
1710 only be used in presence of a prototype.
1712 <tag/Availability/cc65
1714 <ref id="cbm_k_listen" name="cbm_k_listen">,
1715 <ref id="cbm_k_unlsn" name="cbm_k_unlsn">
1721 <sect1>cbm_k_ckout<label id="cbm_k_ckout"><p>
1725 <tag/Function/Designate a Logical File As the Current Output Channel
1726 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
1727 <tag/Declaration/<tt/unsigned char __fastcall__ cbm_k_ckout (unsigned char FN);/
1728 <tag/Description/If you wish to
1729 output data to any device other than the screen, this routine must be
1730 called after OPENing the device, and before you output a data byte
1731 with the cbm_k_bsout() function. When called, the function will designate the
1732 logical file whose file number was supplied as the current
1733 file, its device as the current device, and its secondary address as
1734 the current secondary address. If the device on the channel uses the
1735 serial bus, and therefore requires a LISTEN command and possibly a
1736 secondary address, this information will be sent on the bus.
1737 <tag/Notes/<itemize>
1738 <item>The function is only available as fastcall function, so it may
1739 only be used in presence of a prototype.
1741 <tag/Availability/cc65
1743 <ref id="cbm_k_bsout" name="cbm_k_bsout">,
1744 <ref id="cbm_k_listen" name="cbm_k_listen">
1750 <sect1>cbm_k_clall<label id="cbm_k_clall"><p>
1754 <tag/Function/Close All Logical I/O Files
1755 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
1756 <tag/Declaration/<tt/void cbm_k_clall (void);/
1757 <tag/Description/It closes all
1758 open files, by resetting the index into open files to
1759 zero and restores the default I/O devices.
1760 <tag/Notes/<itemize>
1763 <tag/Availability/cc65
1765 <ref id="cbm_k_open" name="cbm_k_open">,
1766 <ref id="cbm_k_close" name="cbm_k_close">
1772 <sect1>cbm_k_close<label id="cbm_k_close"><p>
1776 <tag/Function/Close a Logical I/O File
1777 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
1778 <tag/Declaration/<tt/void __fastcall__ cbm_k_close (unsigned char FN);/
1779 <tag/Description/It is used to
1780 close a logical file after all I/O operations involving that file have
1782 <tag/Notes/<itemize>
1783 <item>The function is only available as fastcall function, so it may
1784 only be used in presence of a prototype.
1786 <tag/Availability/cc65
1788 <ref id="cbm_k_open" name="cbm_k_open">,
1789 <ref id="cbm_k_clall" name="cbm_k_clall">
1795 <sect1>cbm_k_clrch<label id="cbm_k_clrch"><p>
1799 <tag/Function/Restore Current Input and Output Devices to the Default Devices
1800 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
1801 <tag/Declaration/<tt/void cbm_k_clrch (void);/
1802 <tag/Description/It sets the
1803 current input device to the keyboard, and the current output device to
1804 the screen. Also, if the current input device was formerly a serial
1805 device, the routine sends it an UNTALK command on the serial bus, and
1806 if a serial device was formerly the current output device, the routine
1807 sends it an UNLISTEN command.
1808 <tag/Notes/<itemize>
1811 <tag/Availability/cc65
1813 <ref id="cbm_k_chkin" name="cbm_k_chkin">,
1814 <ref id="cbm_k_ckout" name="cbm_k_ckout">
1820 <sect1>cbm_k_getin<label id="cbm_k_getin"><p>
1824 <tag/Function/Get One Byte from the Input Device
1825 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
1826 <tag/Declaration/<tt/unsigned char cbm_k_getin (void);/
1827 <tag/Description/Function gets a character from the current input device.
1828 <tag/Notes/<itemize>
1831 <tag/Availability/cc65
1833 <ref id="cbm_k_basin" name="cbm_k_basin">
1839 <sect1>cbm_k_iobase<label id="cbm_k_iobase"><p>
1843 <tag/Function/Return Base Address of Memory-Mapped I/O Devices
1844 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
1845 <tag/Declaration/<tt/unsigned cbm_k_iobase (void);/
1846 <tag/Description/This function returns the address of
1847 the memory section where the memory mapped I/O devices are located. This
1848 address can then be used with an offset to access the memory mapped I/O
1849 devices in the Commodore 64. The offset is the number of locations from
1850 the beginning of the page on which the I/O register you want is located.
1851 This function exists to provide compatibility between the Commodore 64,
1852 VIC-20, and future models of the Commodore 64. If the I/O locations for
1853 a program are set by a call to this function, they should
1854 still remain compatible with future versions of the Commodore 64, the
1856 <tag/Notes/<itemize>
1859 <tag/Availability/cc65
1867 <sect1>cbm_k_listen<label id="cbm_k_listen"><p>
1871 <tag/Function/Command a device on the serial bus to LISTEN
1872 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
1873 <tag/Declaration/<tt/void __fastcall__ cbm_k_listen (unsigned char dev);/
1874 <tag/Description/This function will command a device on the serial bus to
1875 receive data. The KERNAL routine will OR the supplied device number bit by bit
1876 to convert it to a listen address, then transmits this data as a command on
1877 the serial bus. The specified device will then go into listen mode, and
1878 be ready to accept information.
1879 <tag/Notes/<itemize>
1880 <item>The function is only available as fastcall function, so it may
1881 only be used in presence of a prototype.
1883 <tag/Availability/cc65
1885 <ref id="cbm_k_unlsn" name="cbm_k_unlsn">,
1891 <sect1>cbm_k_load<label id="cbm_k_load"><p>
1895 <tag/Function/Load RAM from a Device
1896 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
1897 <tag/Declaration/<tt/unsigned int __fastcall__ cbm_k_load(unsigned char flag, unsigned addr);/
1898 <tag/Description/This function LOADs data bytes from any input device directly into the memory.
1899 It can also be used for a verify operation, comparing data from a device with the data already in
1900 memory, while leaving the data stored in RAM unchanged.
1901 The flag must be set to 0 for a LOAD operation, or 1 for a
1902 verify, If the input device is OPENed with a secondary address (SA) of 0
1903 the header information from the device is ignored. In this case, the starting address for the load must be supplied.
1904 If the device is addressed with a secondary address of 1, then the data is
1905 loaded into memory starting at the location specified by the header.
1906 Function returns the address of the highest RAM location loaded.
1907 Before this function can be called, the KERNAL SETLFS, and SETNAM
1908 routines must be called.
1909 <tag/Notes/<itemize>
1910 <item>The function is only available as fastcall function, so it may
1911 only be used in presence of a prototype.
1913 <tag/Availability/cc65
1915 <ref id="cbm_k_save" name="cbm_k_save">,
1916 <ref id="cbm_k_setlfs" name="cbm_k_setlfs">,
1917 <ref id="cbm_k_setnam" name="cbm_k_setnam">
1923 <sect1>cbm_k_open<label id="cbm_k_open"><p>
1927 <tag/Function/Open a Logical I/O File
1928 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
1929 <tag/Declaration/<tt/unsigned char cbm_k_open (void);/
1930 <tag/Description/This function assigns a logical file to a device, so that it can be used for
1931 Input/Output operations. In order to specify the logical file number,
1932 the device number, and the secondary address if any, the cbm_k_setlfs() function must first be called.
1933 Likewise, in order to designate the filename, the cbm_k_setnam() function must be used first. After these two
1934 functions are called, cbm_k_open() is then called.
1935 <tag/Notes/<itemize>
1938 <tag/Availability/cc65
1940 <ref id="cbm_k_close" name="cbm_k_close">,
1941 <ref id="cbm_k_setlfs" name="cbm_k_setlfs">,
1942 <ref id="cbm_k_setnam" name="cbm_k_setnam">
1948 <sect1>cbm_k_readst<label id="cbm_k_readst"><p>
1952 <tag/Function/Read status word
1953 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
1954 <tag/Declaration/<tt/unsigned char cbm_k_readst (void);/
1955 <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.
1956 <tag/Notes/<itemize>
1959 <tag/Availability/cc65
1967 <sect1>cbm_k_save<label id="cbm_k_save"><p>
1971 <tag/Function/Save RAM to a Device
1972 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
1973 <tag/Declaration/<tt/unsigned char __fastcall__ cbm_k_save(unsigned int start, unsigned int end)/
1974 <tag/Description/This function saves a section of memory. The cbm_k_setlfs() and cbm_k_setnam() functions must be
1975 used before calling this function. However, a file name is not required to
1976 SAVE to device 1 (the Datassette(TM) recorder). Any attempt to save to
1977 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.
1978 <tag/Notes/<itemize>
1979 <item>The function is only available as fastcall function, so it may
1980 only be used in presence of a prototype.
1982 <tag/Availability/cc65
1984 <ref id="cbm_k_load" name="cbm_k_load">,
1985 <ref id="cbm_k_setlfs" name="cbm_k_setlfs">,
1986 <ref id="cbm_k_setnam" name="cbm_k_setnam">
1992 <sect1>cbm_k_setlfs<label id="cbm_k_setlfs"><p>
1996 <tag/Function/Set up a logical file
1997 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
1998 <tag/Declaration/<tt/void __fastcall__ cbm_k_setlfs (unsigned char LFN, unsigned char DEV, unsigned char SA);/
1999 <tag/Description/This functions sets up the logical file by setting its number, device address,
2000 and secondary address.
2001 <tag/Notes/<itemize>
2002 <item>The function is only available as fastcall function, so it may
2003 only be used in presence of a prototype.
2005 <tag/Availability/cc65
2007 <ref id="cbm_k_setnam" name="cbm_k_setnam">
2013 <sect1>cbm_k_setnam<label id="cbm_k_setnam"><p>
2017 <tag/Function/Set Filename Parameters
2018 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
2019 <tag/Declaration/<tt/void __fastcall__ cbm_k_setnam (const char* Name);/
2020 <tag/Description/This function is used to set up the file name for the OPEN,
2021 SAVE, or LOAD operations.
2022 <tag/Notes/<itemize>
2023 <item>The function is only available as fastcall function, so it may
2024 only be used in presence of a prototype.
2026 <tag/Availability/cc65
2028 <ref id="cbm_k_open" name="cbm_k_open">,
2029 <ref id="cbm_k_load" name="cbm_k_load">,
2030 <ref id="cbm_k_save" name="cbm_k_save">
2036 <sect1>cbm_k_talk<label id="cbm_k_talk"><p>
2040 <tag/Function/Commands device to TALK
2041 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
2042 <tag/Declaration/<tt/void __fastcall__ cbm_k_talk (unsigned char dev);/
2043 <tag/Description/When called, it ORs the device number with the TALK code (64, $40) and sends it on the serial
2044 bus. This commands the device to TALK.
2045 <tag/Notes/<itemize>
2046 <item>The function is only available as fastcall function, so it may
2047 only be used in presence of a prototype.
2049 <tag/Availability/cc65
2051 <ref id="cbm_k_acptr" name="cbm_k_acptr">
2057 <sect1>cbm_k_unlsn<label id="cbm_k_unlsn"><p>
2061 <tag/Function/Send an UNLISTEN command
2062 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
2063 <tag/Declaration/<tt/void cbm_k_unlsn (void);/
2064 <tag/Description/This function commands all devices on the serial bus to
2065 stop receiving data from the host computer (i.e., UNLISTEN). Calling this
2066 function results in an UNLISTEN command being transmitted on the serial
2067 bus. Only devices previously commanded to LISTEN are affected. This
2068 function is normally used after the host computer is finished sending data
2069 to external devices. Sending the UNLISTEN commands the listening devices
2070 to get off the serial bus so it can be used for other purposes.
2071 <tag/Notes/<itemize>
2074 <tag/Availability/cc65
2076 <ref id="cbm_k_listen" name="cbm_k_listen">
2082 <sect1>cclear<label id="cclear"><p>
2086 <tag/Function/Clear part of a line (write a given number of spaces).
2087 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2088 <tag/Declaration/<tt/void __fastcall__ cclear (unsigned char length);/
2089 <tag/Description/The function clears part of a line by writing <tt/length/
2090 spaces in the current text color.
2091 <tag/Notes/<itemize>
2092 <item>The function is only available as fastcall function, so it may
2093 only be used in presence of a prototype.
2095 <tag/Availability/cc65
2097 <ref id="cclearxy" name="cclearxy">,
2098 <ref id="clrscr" name="clrscr">
2104 <sect1>cclearxy<label id="cclearxy"><p>
2108 <tag/Function/Clear part of a line (write a given number of spaces) starting
2109 at a specific screen position.
2110 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2111 <tag/Declaration/<tt/void __fastcall__ cclearxy (unsigned char x, unsigned char y, unsigned char length);/
2112 <tag/Description/The function moves the cursor to a specific position, and
2113 will then clear part of the line by writing <tt/length/ spaces in the current
2115 <tag/Notes/<itemize>
2116 <item>The function is only available as fastcall function, so it may
2117 only be used in presence of a prototype.
2119 <tag/Availability/cc65
2121 <ref id="cclear" name="cclear">,
2122 <ref id="clrscr" name="clrscr">
2128 <sect1>cgetc<label id="cgetc"><p>
2132 <tag/Function/Read a character from the keyboard.
2133 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2134 <tag/Declaration/<tt/char cgetc (void);/
2135 <tag/Description/The function reads a character from the keyboard. If there is
2136 no character available, <tt/cgetc/ waits until the user presses a key. If the
2137 cursor is enabled by use of the <tt/cursor/ function, a blinking cursor is
2138 displayed while waiting.
2139 <tag/Notes/<itemize>
2140 <item>If the system supports a keyboard buffer, <tt/cgetc/ will fetch a key
2141 from this buffer and wait only if the buffer is empty.
2143 <tag/Availability/cc65
2145 <ref id="cursor" name="cursor">,
2146 <ref id="kbhit" name="kbhit">
2152 <sect1>chline<label id="chline"><p>
2156 <tag/Function/Output a horizontal line in text mode.
2157 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2158 <tag/Declaration/<tt/void __fastcall__ chline (unsigned char length);/
2159 <tag/Description/The function outputs a horizontal line with the given length
2160 starting at the current cursor position.
2161 <tag/Notes/<itemize>
2162 <item>The character used to draw the horizontal line is system dependent.
2163 If available, a line drawing character is used. Drawing a line that is partially
2164 off screen leads to undefined behaviour.
2165 <item>The function is only available as fastcall function, so it may only be
2166 used in presence of a prototype.
2168 <tag/Availability/cc65
2170 <ref id="chlinexy" name="chlinexy">,
2171 <ref id="cvline" name="cvline">,
2172 <ref id="cvlinexy" name="cvlinexy">
2178 <sect1>chlinexy<label id="chlinexy"><p>
2182 <tag/Function/Output a horizontal line at a given position in text mode.
2183 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2184 <tag/Declaration/<tt/void __fastcall__ chlinexy (unsigned char x, unsigned char y, unsigned char length);/
2185 <tag/Description/The function outputs a horizontal line with the given length
2186 starting at a given position.
2187 <tag/Notes/<itemize>
2188 <item>The character used to draw the horizontal line is system dependent.
2189 If available, a line drawing character is used. Drawing a line that is partially
2190 off screen leads to undefined behaviour.
2191 <item>The function is only available as fastcall function, so it may only be
2192 used in presence of a prototype.
2194 <tag/Availability/cc65
2196 <ref id="chline" name="chline">,
2197 <ref id="cvline" name="cvline">,
2198 <ref id="cvlinexy" name="cvlinexy">
2204 <sect1>clearerr<label id="clearerr"><p>
2208 <tag/Function/Clear error and end-of-file status of a stream.
2209 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
2210 <tag/Declaration/<tt/void __fastcall__ clearerr (FILE* f);/
2211 <tag/Description/<tt/clearerr/ clears the error and end-of-file status
2212 indicators for the stream <tt/f/.
2213 <tag/Notes/<itemize>
2214 <item>The function is only available as fastcall function, so it may only be
2215 used in presence of a prototype.
2217 <tag/Availability/ISO 9899
2219 <ref id="feof" name="feof">,
2220 <ref id="ferror" name="ferror">
2226 <sect1>clock<label id="clock"><p>
2230 <tag/Function/Determine the processor time used.
2231 <tag/Header/<tt/<ref id="time.h" name="time.h">/
2232 <tag/Declaration/<tt/clock_t clock (void);/
2233 <tag/Description/The <tt/clock/ function returns an approximaton of processor
2234 time used by the program. The time is returned in implementation defined
2235 units. It can be converted to seconds by dividing by the value of the macro
2236 <tt/CLOCKS_PER_SEC/.
2237 <tag/Notes/<itemize>
2238 <item>Since the machines, cc65 generated programs run on, cannot run multiple
2239 processes, the function will actually return the time since some
2240 implementation defined point in the past.
2242 <tag/Availability/ISO 9899
2244 <ref id="time" name="time">
2250 <sect1>clrscr<label id="clrscr"><p>
2254 <tag/Function/Clear the text screen.
2255 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2256 <tag/Declaration/<tt/void clrscr (void);/
2257 <tag/Description/The function clears the text screen and moves the cursor to
2258 the upper left corner.
2259 <tag/Availability/cc65
2261 <ref id="cclear" name="cclear">,
2262 <ref id="cclearxy" name="cclearxy">
2268 <sect1>close<label id="close"><p>
2272 <tag/Function/Close a file descriptor.
2273 <tag/Header/<tt/<ref id="fcntl.h" name="fcntl.h">/
2274 <tag/Declaration/<tt/int __fastcall__ close (int fd);/
2275 <tag/Description/The function closes the given file descriptor. It returns zero
2276 on success and -1 on error. If an error occurs, the cause can be determined by
2277 reading the <tt/errno/ variable.
2278 <tag/Notes/<itemize>
2279 <item>The function is only available as fastcall function, so it may only
2280 be used in presence of a prototype.
2282 <tag/Availability/POSIX 1003.1
2284 <ref id="creat" name="creat">,
2285 <ref id="open" name="open">
2291 <sect1>closedir<label id="closedir"><p>
2295 <tag/Function/Close a directory.
2296 <tag/Header/<tt/<ref id="dirent.h" name="dirent.h">/
2297 <tag/Declaration/<tt/int __fastcall__ closedir (DIR* dir);/
2298 <tag/Description/The function closes the given directory descriptor. It returns
2299 zero on success and -1 on error. If an error occurs, the cause can be determined
2300 by reading the <tt/errno/ variable.
2301 <tag/Notes/<itemize>
2302 <item>The function is only available as fastcall function, so it may only
2303 be used in presence of a prototype.
2305 <tag/Availability/POSIX 1003.1
2307 <ref id="opendir" name="opendir">,
2308 <ref id="readdir" name="readdir">
2314 <sect1>creat<label id="creat"><p>
2318 <tag/Function/Create a file.
2319 <tag/Header/<tt/<ref id="fcntl.h" name="fcntl.h">/
2320 <tag/Declaration/<tt/int __fastcall__ creat (const char* name, unsigned mode);/
2321 <tag/Description/<tt/creat/ creates a new file and returns the file descriptor
2322 associated with it. On error, -1 is returned and an error code is stored in
2324 <tag/Notes/<itemize>
2325 <item><tt/creat/ is identical to calling <tt/<ref id="open" name="open">/ with
2326 <tt/flags/ equal to <tt/O_WRONLY | O_CREAT | O_TRUNC/.
2327 <item>The function is only available as fastcall function, so it may only
2328 be used in presence of a prototype.
2330 <tag/Availability/POSIX 1003.1
2332 <ref id="close" name="close">,
2333 <ref id="open" name="open">
2339 <sect1>cprintf<label id="cprintf"><p>
2343 <tag/Function/Formatted output to the console.
2344 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2345 <tag/Declaration/<tt/int cprintf (const char* format, ...);/
2346 <tag/Description/The arguments are converted to text where necessary and
2347 formatted according to the format string given. The resulting string is output
2348 to the console. <tt/cprintf/ supports the same format specifiers as
2349 <tt/printf/. <!-- <tt/<ref id="printf" name="printf">/. -->
2350 <tag/Notes/<itemize>
2351 <item>Like all other <tt/conio/ output functions, <tt/cprintf/ distinguishes
2352 between <tt/\r/ and <tt/\n/.
2354 <tag/Availability/cc65
2356 <ref id="cputc" name="cputc">,
2357 <ref id="cputcxy" name="cputcxy">,
2358 <ref id="cputs" name="cputs">,
2359 <ref id="cputsxy" name="cputsxy">,
2360 <ref id="vcprintf" name="vcprintf">
2366 <sect1>cputc<label id="cputc"><p>
2370 <tag/Function/Output a character directly to the console.
2371 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2372 <tag/Declaration/<tt/void __fastcall__ cputc (char c);/
2373 <tag/Description/Output one character to the console at the current cursor
2375 <tag/Notes/<itemize>
2376 <item>Like all other <tt/conio/ output functions, <tt/cputc/ distinguishes
2377 between <tt/\r/ and <tt/\n/.
2378 <item>The function is only available as fastcall function, so it may only
2379 be used in presence of a prototype.
2381 <tag/Availability/cc65
2383 <ref id="cprintf" name="cprintf">,
2384 <ref id="cputcxy" name="cputcxy">,
2385 <ref id="cputs" name="cputs">,
2386 <ref id="cputsxy" name="cputsxy">,
2387 <ref id="vcprintf" name="vcprintf">
2393 <sect1>cputcxy<label id="cputcxy"><p>
2397 <tag/Function/Output a character at a specific screen position.
2398 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2399 <tag/Declaration/<tt/void __fastcall__ cputcxy (unsigned char x, unsigned char y, char c);/
2400 <tag/Description/<tt/cputcxy/ moves the cursor to the given x/y position on
2401 the screen and outputs one character.
2402 <tag/Notes/<itemize>
2403 <item>Like all other <tt/conio/ output functions, <tt/cputcxy/ distinguishes
2404 between <tt/\r/ and <tt/\n/.
2405 <item>The function is only available as fastcall function, so it may only
2406 be used in presence of a prototype.
2408 <tag/Availability/cc65
2410 <ref id="cprintf" name="cprintf">,
2411 <ref id="cputc" name="cputc">,
2412 <ref id="cputs" name="cputs">,
2413 <ref id="cputsxy" name="cputsxy">,
2414 <ref id="vcprintf" name="vcprintf">
2420 <sect1>cputs<label id="cputs"><p>
2424 <tag/Function/Output a string directly to the console.
2425 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2426 <tag/Declaration/<tt/void __fastcall__ cputs (const char* s);/
2427 <tag/Description/The function outputs the given string on the console at the
2428 current cursor position.
2429 <tag/Notes/<itemize>
2430 <item>Like all other <tt/conio/ output functions, <tt/cputs/ distinguishes
2431 between <tt/\r/ and <tt/\n/.
2432 <item>The function is only available as fastcall function, so it may only
2433 be used in presence of a prototype.
2435 <tag/Availability/cc65
2437 <ref id="cprintf" name="cprintf">,
2438 <ref id="cputc" name="cputc">,
2439 <ref id="cputcxy" name="cputcxy">,
2440 <ref id="cputsxy" name="cputsxy">,
2441 <ref id="vcprintf" name="vcprintf">
2447 <sect1>cputsxy<label id="cputsxy"><p>
2451 <tag/Function/Output a string to the console at a given position.
2452 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2453 <tag/Declaration/<tt/void __fastcall__ cputsxy (unsigned char x, unsigned char y, const char* s);/
2454 <tag/Description/<tt/cputsxy/ moves the cursor to the given x/y position,
2455 and outputs the string <tt/s/.
2456 <tag/Notes/<itemize>
2457 <item>Like all other <tt/conio/ output functions, <tt/cputsxy/ distinguishes
2458 between <tt/\r/ and <tt/\n/.
2459 <item>The function is only available as fastcall function, so it may only
2460 be used in presence of a prototype.
2462 <tag/Availability/cc65
2464 <ref id="cprintf" name="cprintf">,
2465 <ref id="cputc" name="cputc">,
2466 <ref id="cputcxy" name="cputcxy">,
2467 <ref id="cputs" name="cputs">,
2468 <ref id="vcprintf" name="vcprintf">
2474 <sect1>cursor<label id="cursor"><p>
2478 <tag/Function/Enable/disable a blinking cursor when waiting for keyboard input.
2479 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2480 <tag/Declaration/<tt/unsigned char __fastcall__ cursor (unsigned char onoff);/
2481 <tag/Description/If the argument to the function is non zero, a blinking cursor
2482 will be enabled when the <tt/cgetc/ function waits for input from the keyboard.
2483 If the argument is zero, <tt/cgetc/ will wait without a blinking cursor.
2484 <tag/Notes/<itemize>
2485 <item>The function is only available as fastcall function, so it may only
2486 be used in presence of a prototype.
2488 <tag/Availability/cc65
2490 <ref id="cgetc" name="cgetc">,
2491 <ref id="kbhit" name="kbhit">
2497 <sect1>cvline<label id="cvline"><p>
2501 <tag/Function/Output a vertical line in text mode.
2502 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2503 <tag/Declaration/<tt/void __fastcall__ cvline (unsigned char length);/
2504 <tag/Description/The function outputs a vertical line with the given length
2505 starting at the current cursor position.
2506 <tag/Notes/<itemize>
2507 <item>The character used to draw the vertical line is system dependent.
2508 If available, a line drawing character is used. Drawing a line that is partially
2509 off screen leads to undefined behaviour.
2510 <item>The function is only available as fastcall function, so it may only be
2511 used in presence of a prototype.
2513 <tag/Availability/cc65
2515 <ref id="chline" name="chline">,
2516 <ref id="chlinexy" name="chlinexy">,
2517 <ref id="cvlinexy" name="cvlinexy">
2523 <sect1>cvlinexy<label id="cvlinexy"><p>
2527 <tag/Function/Output a vertical line at a given position in text mode.
2528 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2529 <tag/Declaration/<tt/void __fastcall__ cvlinexy (unsigned char x, unsigned char y, unsigned char length);/
2530 <tag/Description/The function outputs a vertical line with the given length
2531 starting at a given position.
2532 <tag/Notes/<itemize>
2533 <item>The character used to draw the vertical line is system dependent.
2534 If available, a line drawing character is used. Drawing a line that is partially
2535 off screen leads to undefined behaviour.
2536 <item>The function is only available as fastcall function, so it may only be
2537 used in presence of a prototype.
2539 <tag/Availability/cc65
2541 <ref id="chline" name="chline">,
2542 <ref id="chlinexy" name="chlinexy">,
2543 <ref id="cvline" name="cvline">
2549 <sect1>div<label id="div"><p>
2553 <tag/Function/Divide two ints and return quotient and remainder.
2554 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
2555 <tag/Declaration/<tt/div_t __fastcall__ div (int numer, int denom);/
2556 <tag/Description/<tt/div/ divides <tt/numer/ by <tt/denom/ and returns the
2557 quotient and remainder in a <tt/div_t/ structure.
2558 <tag/Notes/<itemize>
2559 <item>The function is only available as fastcall function, so it may only
2560 be used in presence of a prototype.
2562 <tag/Availability/ISO 9899
2570 <sect1>doesclrscrafterexit<label id="doesclrscrafterexit"><p>
2574 <tag/Function/Determines whether the screen is going to be cleared after program exit.
2575 <tag/Header/<tt/<ref id="cc65.h" name="cc65.h">/
2576 <tag/Declaration/<tt/unsigned char doesclrscrafterexit (void);/
2577 <tag/Description/The function returns zero if the screen won't be cleared immediately after
2578 program termination. It returns a non-zero value if it will.
2579 <tag/Notes/<itemize>
2580 <item>Some systems, maybe depending on configuration, immediately clear the screen
2581 after a program exits. Therefore it might be difficult to read
2582 the last messages printed by the program prior to its exit. This function can be used
2583 to decide if a delay or wait for a key press should be executed when then program
2586 <tag/Availability/cc65
2594 printf("Hello World\n");
2595 if (doesclrscrafterexit())
2604 <sect1>em_commit<label id="em_commit"><p>
2608 <tag/Function/Commit changes into extended memory.
2609 <tag/Header/<tt/<ref id="em.h" name="em.h">/
2610 <tag/Declaration/<tt/void em_commit (void);/
2611 <tag/Description/Commit changes in the memory window to extended storage. If
2612 the contents of the memory window have been changed, these changes may be lost
2613 if <tt/<ref id="em_map" name="em_map">/, <tt/<ref id="em_use" name="em_use">/,
2614 <tt/<ref id="em_copyfrom" name="em_copyfrom">/ or <tt/<ref id="em_copyto"
2615 name="em_copyto">/ are called without calling <tt/em_commit/ first.
2616 <tag/Notes/<itemize>
2617 <item>Calling <tt/em_commit/ does not necessarily mean that changes to the
2618 memory window are discarded, it does just mean that the drivers is allowed
2620 <item>The function is only available as fastcall function, so it may only be
2621 used in presence of a prototype.
2622 <item>The function produces undefined results if no extended memory driver is
2625 <tag/Availability/cc65
2627 <ref id="em_load_driver" name="em_load_driver">,
2628 <ref id="em_map" name="em_map">,
2629 <ref id="em_use" name="em_use">
2635 <sect1>em_copyfrom<label id="em_copyfrom"><p>
2639 <tag/Function/Copy from extended into normal memory.
2640 <tag/Header/<tt/<ref id="em.h" name="em.h">/
2641 <tag/Declaration/<tt/void __fastcall__ em_copyfrom (const struct em_copy* copy_data);/
2642 <tag/Description/Copy data from extended memory into linear memory. Source and
2643 target addresses as well as the number of bytes to transfer are specified in
2644 the <tt/em_copy/ structure that is passed as a parameter.
2645 <tag/Notes/<itemize>
2646 <item>Calling <tt/em_copyfrom/ will invalidate the memory window, so if you
2647 made any changes to the data in the window, call <tt/<ref id="em_commit"
2648 name="em_commit">/ first, or the changes are lost.
2649 <item>The function is only available as fastcall function, so it may only be
2650 used in presence of a prototype.
2651 <item>The function produces undefined results if no extended memory driver is
2654 <tag/Availability/cc65
2656 <ref id="em_commit" name="em_commit">,
2657 <ref id="em_copyto" name="em_copyto">,
2658 <ref id="em_load_driver" name="em_load_driver">
2664 <sect1>em_copyto<label id="em_copyto"><p>
2668 <tag/Function/Copy from normal into extended memory.
2669 <tag/Header/<tt/<ref id="em.h" name="em.h">/
2670 <tag/Declaration/<tt/void __fastcall__ em_copyto (const struct em_copy* copy_data);/
2671 <tag/Description/Copy data from linear into extended memory. Source and
2672 target addresses as well as the number of bytes to transfer are specified in
2673 the <tt/em_copy/ structure that is passed as a parameter.
2674 <tag/Notes/<itemize>
2675 <item>Calling <tt/em_copyto/ will invalidate the memory window, so if you
2676 made any changes to the data in the window, call <tt/<ref id="em_commit"
2677 name="em_commit">/ first, or the changes are lost.
2678 <item>The function is only available as fastcall function, so it may only be
2679 used in presence of a prototype.
2680 <item>The function produces undefined results if no extended memory driver is
2683 <tag/Availability/cc65
2685 <ref id="em_commit" name="em_commit">,
2686 <ref id="em_copyfrom" name="em_copyfrom">,
2687 <ref id="em_load_driver" name="em_load_driver">
2693 <sect1>em_install<label id="em_install"><p>
2697 <tag/Function/Install an already loaded extended memory driver.
2698 <tag/Header/<tt/<ref id="em.h" name="em.h">/
2699 <tag/Declaration/<tt/unsigned char _fastcall__ em_install (void* driver);/
2700 <tag/Description/The function installs an already loaded extended memory driver
2701 and returns an error code. The function may be used to install a driver linked
2702 statically to the program.
2703 <tag/Notes/<itemize>
2704 <item>Not all drivers are able to detect if the supported hardware is really
2706 <item>The function is only available as fastcall function, so it may only be
2707 used in presence of a prototype.
2709 <tag/Availability/cc65
2711 <ref id="em_load_driver" name="em_load_driver">,
2712 <ref id="em_uninstall" name="em_uninstall">,
2713 <ref id="em_unload" name="em_unload">
2719 <sect1>em_load_driver<label id="em_load_driver"><p>
2723 <tag/Function/Load and initialize an extended memory driver.
2724 <tag/Header/<tt/<ref id="em.h" name="em.h">/
2725 <tag/Declaration/<tt/void __fastcall__ em_load_driver (const char* name);/
2726 <tag/Description/Load an extended memory driver into memory and initialize
2727 it. The function returns an error code that tells if all this has been
2729 <tag/Notes/<itemize>
2730 <item>Not all drivers are able to detect if the supported hardware is really
2732 <item>The function is only available as fastcall function, so it may only be
2733 used in presence of a prototype.
2734 <item>The driver is loaded by name, so currently you must know the type of
2735 extended memory that should be supported. There is no autodetect capability.
2737 <tag/Availability/cc65
2739 <ref id="em_unload" name="em_unload">
2745 <sect1>em_map<label id="em_map"><p>
2749 <tag/Function/Make a page of extended memory accessible.
2750 <tag/Header/<tt/<ref id="em.h" name="em.h">/
2751 <tag/Declaration/<tt/void* __fastcall__ em_map (unsigned page);/
2752 <tag/Description/The function maps one page of extended memory into linear
2753 memory and returns a pointer to the page frame. Depending on the hardware
2754 and driver, the data is either mapped into the address space or transfered
2755 into a buffer. If you don't need the actual contents of the page (for example
2756 because you're going to overwrite it completely), it is better to call
2757 <tt/<ref id="em_use" name="em_use">/ instead. <tt/em_use/ will not transfer the
2758 data if it is possible to avoid that.
2759 <tag/Notes/<itemize>
2760 <item>Calling <tt/em_map/ will invalidate the memory window, so if you
2761 made any changes to the data in the window, call <tt/<ref id="em_commit"
2762 name="em_commit">/ first, or the changes are lost.
2763 <item>The function is only available as fastcall function, so it may only be
2764 used in presence of a prototype.
2765 <item>The function produces undefined results if no extended memory driver is
2768 <tag/Availability/cc65
2770 <ref id="em_commit" name="em_commit">,
2771 <ref id="em_load_driver" name="em_load_driver">,
2772 <ref id="em_use" name="em_use">
2778 <sect1>em_pagecount<label id="em_pagecount"><p>
2782 <tag/Function/Return the number of available extended memory pages.
2783 <tag/Header/<tt/<ref id="em.h" name="em.h">/
2784 <tag/Declaration/<tt/unsigned em_pagecount (void);/
2785 <tag/Description/The function returns the size of the extended memory supported
2786 by the driver in 256 byte pages.
2787 <tag/Notes/<itemize>
2788 <item>The function returns zero if no extended memory driver is loaded.
2789 <item>The function may return zero if the supported hardware was not detected.
2791 <tag/Availability/cc65
2793 <ref id="em_load_driver" name="em_load_driver">
2799 <sect1>em_uninstall<label id="em_uninstall"><p>
2803 <tag/Function/Uninstall an already loaded extended memory driver.
2804 <tag/Header/<tt/<ref id="em.h" name="em.h">/
2805 <tag/Declaration/<tt/unsigned char em_uninstall (void);/
2806 <tag/Description/The function uninstalls an already loaded extended memory
2807 driver but doesn't remove it from memory.
2808 <tag/Notes/<itemize>
2809 <item>If the driver has been loaded using <tt/<ref id="em_load_driver"
2810 name="em_load_driver">/, <tt/<ref id="em_unload" name="em_unload">/
2811 should be used instead of <tt/em_uninstall/ so the driver is also removed
2814 <tag/Availability/cc65
2816 <ref id="em_install" name="em_install">,
2817 <ref id="em_load_driver" name="em_load_driver">,
2818 <ref id="em_unload" name="em_unload">
2824 <sect1>em_unload<label id="em_unload"><p>
2828 <tag/Function/Unload an extended memory driver.
2829 <tag/Header/<tt/<ref id="em.h" name="em.h">/
2830 <tag/Declaration/<tt/unsigned char em_unload (void);/
2831 <tag/Description/The function unloads a loaded extended memory driver and
2832 frees all memory allocated for the driver.
2833 <tag/Notes/<itemize>
2834 <item>The function does nothing if no driver is loaded.
2836 <tag/Availability/cc65
2838 <ref id="em_load_driver" name="em_load_driver">
2844 <sect1>em_use<label id="em_use"><p>
2848 <tag/Function/Prepare an extended memory page for use.
2849 <tag/Header/<tt/<ref id="em.h" name="em.h">/
2850 <tag/Declaration/<tt/void* __fastcall__ em_use (unsigned page);/
2851 <tag/Description/The function maps one page of extended memory into linear
2852 memory and returns a pointer to the page frame. This function is similar to
2853 <tt/<ref id="em_map" name="em_map">/, but will not transfer data into the
2854 actual memory window in the assumption that the existing data is wrong or
2855 will get overwritten.
2856 <tag/Notes/<itemize>
2857 <item>Calling <tt/em_use/ will invalidate the memory window, so if you
2858 made any changes to the data in the window, call <tt/<ref id="em_commit"
2859 name="em_commit">/ first, or the changes are lost.
2860 <item>The function is only available as fastcall function, so it may only be
2861 used in presence of a prototype.
2862 <item>The function produces undefined results if no extended memory driver is
2865 <tag/Availability/cc65
2867 <ref id="em_commit" name="em_commit">,
2868 <ref id="em_load_driver" name="em_load_driver">,
2869 <ref id="em_map" name="em_map">
2875 <sect1>exit<label id="exit"><p>
2879 <tag/Function/Terminate the program.
2880 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
2881 <tag/Declaration/<tt/void __fastcall__ exit (int status);/
2882 <tag/Description/<tt/exit/ terminates the program. The argument specifies the
2883 return code of the program. Before termination, all files are closed, buffered
2884 output is written and any functions registered with <tt/<ref id="atexit"
2885 name="atexit">/ are called. Common values for status are <tt/EXIT_SUCCESS/ and
2886 <tt/EXIT_FAILURE/ which are also defined in <tt/<ref id="stdlib.h"
2888 <tag/Notes/<itemize>
2889 <item>The function is only available as fastcall function, so it may only
2890 be used in presence of a prototype.
2891 <item>It depends on the host machine if the program return code can be
2892 evaluated or is ignored.
2894 <tag/Availability/ISO 9899
2896 <ref id="abort" name="abort">,
2897 <ref id="exit" name="exit">
2903 <sect1>exec<label id="exec"><p>
2907 <tag/Function/Execute a program file.
2908 <tag/Header/<tt/<ref id="unistd.h" name="unistd.h">/
2909 <tag/Declaration/<tt/int __fastcall__ exec (const char* progname, const char* cmdline);/
2910 <tag/Description/<tt/exec/ replaces the currently running program by a new one.
2911 Calling <tt/exec()/ is identical to calling <tt/<ref id="exit" name="exit()">/,
2912 then loading and starting the program named in the first argument, passing
2913 the command line specified as second argument. Instead of an empty string,
2914 a <tt/NULL/ pointer may be passed as second parameter.
2915 On success, the function does not return. On failure, -1 is returned and
2916 <tt/errno/ contains an error code.
2917 <tag/Notes/<itemize>
2918 <item>The function is only available as fastcall function, so it may only
2919 be used in presence of a prototype.
2920 <item>On most platforms, the function needs to copy a small stub loader to
2921 some memory area outside the program space. This may collide with other
2922 programs. See the platform specific docs on this.
2923 <item>Because it is necessary to terminate the running program before the
2924 memory can be reused to load the new one, there is a high chance that the
2925 function may not be able to return on errors.
2926 <item>The command line is passed to the new program in the same way as cc65
2927 programs expect the command line. If the new program is not a cc65 generated
2928 program, it may not be able to read it.
2930 <tag/Availability/cc65
2932 <ref id="exit" name="exit">
2938 <sect1>fast<label id="fast"><p>
2942 <tag/Function/Switch the C128 into 2MHz mode.
2943 <tag/Header/<tt/<ref id="c128.h" name="c128.h">/
2944 <tag/Declaration/<tt/void fast (void);/
2945 <tag/Description/The function will switch the clock of the C128 to 2MHz. This
2946 will nearly double the speed compared to slow mode.
2947 <tag/Notes/<itemize>
2948 <item>The function is specific to the C128.
2949 <item>2MHz clock will not work in 40 column mode.
2951 <tag/Availability/C128
2953 <ref id="slow" name="slow">,
2954 <ref id="toggle_videomode" name="toggle_videomode">,
2955 <ref id="videomode" name="videomode">
2961 <sect1>feof<label id="feof"><p>
2965 <tag/Function/Return the end-of-file indicator of a stream.
2966 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
2967 <tag/Declaration/<tt/int __fastcall__ feof (FILE* f);/
2968 <tag/Description/<tt/feof/ tests the end-of-file indicator ofthe stream
2969 <tt/f/, and returns a non zero value if it is set.
2970 <tag/Notes/<itemize>
2971 <item>The indicator is set only after a read past the end of a file is
2973 <item>The function is only available as fastcall function, so it may only be
2974 used in presence of a prototype.
2976 <tag/Availability/ISO 9899
2978 <ref id="feof" name="clearerr">,
2979 <ref id="ferror" name="ferror">
2985 <sect1>ferror<label id="ferror"><p>
2989 <tag/Function/Return the error indicator of a stream.
2990 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
2991 <tag/Declaration/<tt/int __fastcall__ ferror (FILE* f);/
2992 <tag/Description/<tt/ferror/ tests the error indicator of the stream
2993 <tt/f/, and returns a non zero value if it is set.
2994 <tag/Notes/<itemize>
2995 <item>The function is only available as fastcall function, so it may only be
2996 used in presence of a prototype.
2998 <tag/Availability/ISO 9899
3000 <ref id="feof" name="clearerr">,
3001 <ref id="ferror" name="feof">
3007 <sect1>fileno<label id="fileno"><p>
3011 <tag/Function/Return the file handle used by a stream.
3012 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
3013 <tag/Declaration/<tt/int __fastcall__ fileno (FILE* f);/
3014 <tag/Description/The <tt/fileno/ function returns the file handle used
3015 internally by a C stream. This file handle (an integer) can be used as a
3016 handle for the POSIX input/output functions.
3017 <tag/Notes/<itemize>
3018 <item>The function is only available as fastcall function, so it may only be
3019 used in presence of a prototype.
3020 <item>Mixing C file I/O functions and POSIX file I/O functions for the same
3021 file may have unpredictable results.
3023 <tag/Availability/POSIX 1003.1
3025 <ref id="creat" name="creat">,
3026 <ref id="open" name="open"> <!-- , -->
3027 <!-- <ref id="read" name="read">, -->
3028 <!-- <ref id="write" name="write"> -->
3034 <sect1>free<label id="free"><p>
3038 <tag/Function/Free a block of dynamic memory.
3039 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
3040 <tag/Declaration/<tt/void __fastcall__ free (void* block);/
3041 <tag/Description/Free a block of dynamic memory previously allocated with
3042 <tt/<ref id="malloc" name="malloc">/, <tt/<ref id="calloc" name="calloc">/
3043 or <tt/<ref id="realloc" name="realloc">/. As an exception, if the passed
3044 pointer is <tt/NULL/, no action is performed.
3045 <tag/Notes/<itemize>
3046 <item>Passing an already free'd block to <tt/free/ again will cause undefined
3047 behaviour and may crash your program.
3048 <item>The function is only available as fastcall function, so it may only
3049 be used in presence of a prototype.
3051 <tag/Availability/ISO 9899
3053 <ref id="_heapadd" name="_heapadd">,
3054 <ref id="_heapblocksize" name="_heapblocksize">,
3055 <ref id="_heapmaxavail" name="_heapmaxavail">,
3056 <ref id="_heapmemavail" name="_heapmemavail">,
3057 <ref id="calloc" name="calloc">,
3058 <ref id="malloc" name="malloc">,
3059 <ref id="realloc" name="realloc">
3065 <sect1>get_ostype<label id="get_ostype"><p>
3069 <tag/Function/The function returns the operating system, the program runs on.
3070 <tag/Header/<tt/<ref id="apple2.h" name="apple2.h">,
3071 <ref id="atari.h" name="atari.h">, <ref id="c64.h" name="c64.h">/
3072 <tag/Declaration/<tt/unsigned char get_ostype (void);/
3073 <tag/Description/<tt/get_ostype/ is machine dependent and does not exist for
3074 all supported targets. If it exists, it returns a number that identifies the
3075 operating system or machine type, the program runs on. The machine dependent
3076 header files define constants that can be used to check the return code.
3077 <tag/Notes/<itemize>
3078 <item>The function does not exist on all platforms.
3079 <item>The return codes are platform dependent.
3081 <tag/Availability/cc65 (not all platforms)
3087 <sect1>getcpu<label id="getcpu"><p>
3091 <tag/Function/Determine on which CPU the program is running.
3092 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
3093 <tag/Declaration/<tt/unsigned char getcpu (void);/
3094 <tag/Description/The function checks on which CPU the code is running. It
3095 returns one of the constants<itemize>
3097 <item><tt/CPU_65C02/
3098 <item><tt/CPU_65816/
3100 <tag/Notes/<itemize>
3101 <item>Other, more exotic CPU types are not disinguished.
3103 <tag/Availability/cc65
3109 <sect1>getenv<label id="getenv"><p>
3113 <tag/Function/Return a value from the environment.
3114 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
3115 <tag/Declaration/<tt/char* __fastcall__ getenv (const char* name);/
3116 <tag/Description/The function searches the environment for an entry that
3117 matches <tt/name/ and returns its value. The environment consists of a list
3118 of strings in the form <tt/name=value/. If there is no match, <tt/getenv/
3120 <tag/Notes/<itemize>
3121 <item>What exactly is stored in the environment depends on the machine the
3122 program is running on.
3123 <item>The function is only available as fastcall function, so it may only
3124 be used in presence of a prototype.
3126 <tag/Availability/ISO 9899
3132 <sect1>getopt<label id="getopt"><p>
3136 <tag/Function/Parse command line options.
3137 <tag/Header/<tt/<ref id="unistd.h" name="unistd.h">/
3138 <tag/Declaration/<tt/int __fastcall__ getopt (int argc, char* const* argv,
3139 const char* optstring);/
3140 <tag/Description/The function parses command line arguments, <tt/argc/ and
3141 <tt/argv/ are the argument count and array passed to <tt/main/. <tt/optstring/
3142 is a string that contains command line option characters. If a character in
3143 <tt/optstring/ is followed by a colon, the option requires an argument. An
3144 option on the command line is recognized if it is one of the option characters
3146 <tt/getopt/ must be called repeatedly. It will return each option character
3147 found on the command line and <tt/EOF/ (-1) if there is no other option. An
3148 option argument is placed in <tt/optarg/, the index of the next element on the
3149 command line to be processed is placed in <tt/optind/.
3150 <tag/Notes/<itemize>
3151 <item>The implementation will not reorder options. A non option on the command
3152 line will terminate option processing. All remaining arguments are not
3153 recognized as options, even if the start with a '-' character.
3154 <item>The function is only available as fastcall function, so it may only
3155 be used in presence of a prototype.
3157 <tag/Availability/POSIX.2
3163 <sect1>gotox<label id="gotox"><p>
3167 <tag/Function/Move the text mode cursor to a new X position.
3168 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
3169 <tag/Declaration/<tt/void __fastcall__ gotox (unsigned char x);/
3170 <tag/Description/The function moves the text mode cursor to the specified X
3171 position while leaving the Y position untouched. The leftmost position on the
3172 screen has the coordinate 0.
3173 <tag/Notes/<itemize>
3174 <item>The function is only available as fastcall function, so it may
3175 only be used in presence of a prototype.
3176 <item>Invalid values for the X position (out of screen coordinates) may
3177 lead to undefined behaviour.
3179 <tag/Availability/cc65
3181 <ref id="gotoy" name="gotoy">,
3182 <ref id="gotoxy" name="gotoxy">,
3183 <ref id="wherex" name="wherex">,
3184 <ref id="wherey" name="wherey">
3190 <sect1>gotoxy<label id="gotoxy"><p>
3194 <tag/Function/Move the text mode cursor to a new position.
3195 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
3196 <tag/Declaration/<tt/void __fastcall__ gotoxy (unsigned char x, unsigned char y);/
3197 <tag/Description/The function moves the text mode cursor to the specified
3198 position. The leftmost position on the screen has the X coordinate 0, the
3199 topmost line has the Y coordinate 0.
3200 <tag/Notes/<itemize>
3201 <item>The function is only available as fastcall function, so it may only be
3202 used in presence of a prototype.
3203 <item>Invalid values for any of both coordinates (out of screen positions) may
3204 lead to undefined behaviour.
3206 <tag/Availability/cc65
3208 <ref id="gotox" name="gotox">,
3209 <ref id="gotoy" name="gotoy">,
3210 <ref id="wherex" name="wherex">,
3211 <ref id="wherey" name="wherey">
3217 <sect1>gotoy<label id="gotoy"><p>
3221 <tag/Function/Move the text mode cursor to a new Y position.
3222 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
3223 <tag/Declaration/<tt/void __fastcall__ gotoy (unsigned char x);/
3224 <tag/Description/The function moves the text mode cursor to the specified Y
3225 position while leaving the X position untouched. The uppermost position on the
3226 screen has the coordinate 0.
3227 <tag/Notes/<itemize>
3228 <item>The function is only available as fastcall function, so it may
3229 only be used in presence of a prototype.
3230 <item>Invalid values for the Y position (out of screen coordinates) may lead
3231 to undefined behaviour.
3233 <tag/Availability/cc65
3235 <ref id="gotox" name="gotox">,
3236 <ref id="gotoxy" name="gotoxy">,
3237 <ref id="wherex" name="wherex">,
3238 <ref id="wherey" name="wherey">
3244 <sect1>isalnum<label id="isalnum"><p>
3248 <tag/Function/Check if a given character is a letter or digit.
3249 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
3250 <tag/Declaration/<tt/int __fastcall__ isalnum (int c);/
3251 <tag/Description/The function returns a non zero value if the given argument
3252 is a letter or digit. The return value is zero if the character is anything
3254 <tag/Notes/<itemize>
3255 <item>When compiling with <tt/-Os/ the function is actually a macro. The
3256 inline sequence generated by the macro will not work correctly for values
3257 outside the range 0..255. <em/Note:/ The constant <tt/EOF/ is not part of
3258 this range. The non inline function may be accessed by <tt/#undef/'ing
3260 <item>When compiling without <tt/-Os/, the function is only available as
3261 fastcall function, so it may only be used in presence of a prototype.
3263 <tag/Availability/ISO 9899
3265 <ref id="isalpha" name="isalpha">,
3266 <ref id="isascii" name="isascii">,
3267 <ref id="isblank" name="isblank">,
3268 <ref id="iscntrl" name="iscntrl">,
3269 <ref id="isdigit" name="isdigit">,
3270 <ref id="isgraph" name="isgraph">,
3271 <ref id="islower" name="islower">,
3272 <ref id="isprint" name="isprint">,
3273 <ref id="ispunct" name="ispunct">,
3274 <ref id="isspace" name="isspace">,
3275 <ref id="isupper" name="isupper">,
3276 <ref id="isxdigit" name="isxdigit">
3282 <sect1>isalpha<label id="isalpha"><p>
3286 <tag/Function/Check if a given character is a letter.
3287 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
3288 <tag/Declaration/<tt/int __fastcall__ isalpha (int c);/
3289 <tag/Description/The function returns a non zero value if the given argument
3290 is a letter. The return value is zero if the character is anything else.
3291 <tag/Notes/<itemize>
3292 <item>When compiling with <tt/-Os/ the function is actually a macro. The
3293 inline sequence generated by the macro will not work correctly for values
3294 outside the range 0..255. <em/Note:/ The constant <tt/EOF/ is not part of
3295 this range. The non inline function may be accessed by <tt/#undef/'ing the
3297 <item>When compiling without <tt/-Os/, the function is only available as
3298 fastcall function, so it may only be used in presence of a prototype.
3300 <tag/Availability/ISO 9899
3302 <ref id="isalnum" name="isalnum">,
3303 <ref id="isascii" name="isascii">,
3304 <ref id="isblank" name="isblank">,
3305 <ref id="iscntrl" name="iscntrl">,
3306 <ref id="isdigit" name="isdigit">,
3307 <ref id="isgraph" name="isgraph">,
3308 <ref id="islower" name="islower">,
3309 <ref id="isprint" name="isprint">,
3310 <ref id="ispunct" name="ispunct">,
3311 <ref id="isspace" name="isspace">,
3312 <ref id="isupper" name="isupper">,
3313 <ref id="isxdigit" name="isxdigit">
3319 <sect1>isascii<label id="isascii"><p>
3323 <tag/Function/Check if a given character is in the ASCII (0..127) range.
3324 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
3325 <tag/Declaration/<tt/int __fastcall__ isascii (int c);/
3326 <tag/Description/The function returns a non zero value if the given argument
3327 is in the range 0..127 (the range of valid ASCII characters) and zero if not.
3328 <tag/Notes/<itemize>
3329 <item>When compiling with <tt/-Os/ the function is actually a macro. The
3330 inline sequence generated by the macro will not work correctly for values
3331 outside the range 0..255. <em/Note:/ The constant <tt/EOF/ is not part of
3332 this range. The non inline function may be accessed by <tt/#undef/'ing the
3334 <item>When compiling without <tt/-Os/, the function is only available as
3335 fastcall function, so it may only be used in presence of a prototype.
3337 <tag/Availability/ISO 9899
3339 <ref id="isalnum" name="isalnum">,
3340 <ref id="isalpha" name="isalpha">,
3341 <ref id="isblank" name="isblank">,
3342 <ref id="iscntrl" name="iscntrl">,
3343 <ref id="isdigit" name="isdigit">,
3344 <ref id="isgraph" name="isgraph">,
3345 <ref id="islower" name="islower">,
3346 <ref id="isprint" name="isprint">,
3347 <ref id="ispunct" name="ispunct">,
3348 <ref id="isspace" name="isspace">,
3349 <ref id="isupper" name="isupper">,
3350 <ref id="isxdigit" name="isxdigit">
3356 <sect1>isblank<label id="isblank"><p>
3360 <tag/Function/Check if a given character is a space or tab.
3361 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
3362 <tag/Declaration/<tt/int __fastcall__ isblank (int c);/
3363 <tag/Description/The function returns a non zero value if the given argument
3364 is a space or tab character. The return value is zero if the character is
3366 <tag/Notes/<itemize>
3367 <item>When compiling with <tt/-Os/ the function is actually a macro. The
3368 inline sequence generated by the macro will not work correctly for values
3369 outside the range 0..255. <em/Note:/ The constant <tt/EOF/ is not part of
3370 this range. The non inline function may be accessed by <tt/#undef/'ing the
3372 <item>When compiling without <tt/-Os/, the function is only available as
3373 fastcall function, so it may only be used in presence of a prototype.
3375 <tag/Availability/ISO 9899
3377 <ref id="isalnum" name="isalnum">,
3378 <ref id="isalpha" name="isalpha">,
3379 <ref id="isascii" name="isascii">,
3380 <ref id="iscntrl" name="iscntrl">,
3381 <ref id="isdigit" name="isdigit">,
3382 <ref id="isgraph" name="isgraph">,
3383 <ref id="islower" name="islower">,
3384 <ref id="isprint" name="isprint">,
3385 <ref id="ispunct" name="ispunct">,
3386 <ref id="isspace" name="isspace">,
3387 <ref id="isupper" name="isupper">,
3388 <ref id="isxdigit" name="isxdigit">
3394 <sect1>iscntrl<label id="iscntrl"><p>
3398 <tag/Function/Check if a given character is a control character.
3399 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
3400 <tag/Declaration/<tt/int __fastcall__ iscntrl (int c);/
3401 <tag/Description/The function returns a non zero value if the given argument
3402 is a control character. The return value is zero if the character is anything
3404 <tag/Notes/<itemize>
3405 <item>When compiling with <tt/-Os/ the function is actually a macro. The
3406 inline sequence generated by the macro will not work correctly for values
3407 outside the range 0..255. <em/Note:/ The constant <tt/EOF/ is not part of
3408 this range. The non inline function may be accessed by <tt/#undef/'ing the
3410 <item>When compiling without <tt/-Os/, the function is only available as
3411 fastcall function, so it may only be used in presence of a prototype.
3413 <tag/Availability/ISO 9899
3415 <ref id="isalnum" name="isalnum">,
3416 <ref id="isalpha" name="isalpha">,
3417 <ref id="isascii" name="isascii">,
3418 <ref id="isblank" name="isblank">,
3419 <ref id="isdigit" name="isdigit">,
3420 <ref id="isgraph" name="isgraph">,
3421 <ref id="islower" name="islower">,
3422 <ref id="isprint" name="isprint">,
3423 <ref id="ispunct" name="ispunct">,
3424 <ref id="isspace" name="isspace">,
3425 <ref id="isupper" name="isupper">,
3426 <ref id="isxdigit" name="isxdigit">
3432 <sect1>isdigit<label id="isdigit"><p>
3436 <tag/Function/Check if a given character is a digit.
3437 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
3438 <tag/Declaration/<tt/int __fastcall__ isdigit (int c);/
3439 <tag/Description/The function returns a non zero value if the given argument
3440 is a digit. The return value is zero if the character is anything else.
3441 <tag/Notes/<itemize>
3442 <item>When compiling with <tt/-Os/ the function is actually a macro. The
3443 inline sequence generated by the macro will not work correctly for values
3444 outside the range 0..255. <em/Note:/ The constant <tt/EOF/ is not part of
3445 this range. The non inline function may be accessed by <tt/#undef/'ing the
3447 <item>When compiling without <tt/-Os/, the function is only available as
3448 fastcall function, so it may only be used in presence of a prototype.
3450 <tag/Availability/ISO 9899
3452 <ref id="isalnum" name="isalnum">,
3453 <ref id="isalpha" name="isalpha">,
3454 <ref id="isascii" name="isascii">,
3455 <ref id="isblank" name="isblank">,
3456 <ref id="iscntrl" name="iscntrl">,
3457 <ref id="isgraph" name="isgraph">,
3458 <ref id="islower" name="islower">,
3459 <ref id="isprint" name="isprint">,
3460 <ref id="ispunct" name="ispunct">,
3461 <ref id="isspace" name="isspace">,
3462 <ref id="isupper" name="isupper">,
3463 <ref id="isxdigit" name="isxdigit">
3469 <sect1>isgraph<label id="isgraph"><p>
3473 <tag/Function/Check if a given character is a printable character (except
3475 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
3476 <tag/Declaration/<tt/int __fastcall__ isgraph (int c);/
3477 <tag/Description/The function returns a non zero value if the given argument
3478 is a printable character with the exception of space. The return value is zero
3479 if the character is anything else.
3480 <tag/Notes/<itemize>
3481 <item>When compiling with <tt/-Os/ the function is actually a macro. The
3482 inline sequence generated by the macro will not work correctly for values
3483 outside the range 0..255. <em/Note:/ The constant <tt/EOF/ is not part of
3484 this range. The non inline function may be accessed by <tt/#undef/'ing the
3486 <item>When compiling without <tt/-Os/, the function is only available as
3487 fastcall function, so it may only be used in presence of a prototype.
3489 <tag/Availability/ISO 9899
3491 <ref id="isalnum" name="isalnum">,
3492 <ref id="isalpha" name="isalpha">,
3493 <ref id="isascii" name="isascii">,
3494 <ref id="isblank" name="isblank">,
3495 <ref id="iscntrl" name="iscntrl">,
3496 <ref id="isdigit" name="isdigit">,
3497 <ref id="islower" name="islower">,
3498 <ref id="isprint" name="isprint">,
3499 <ref id="ispunct" name="ispunct">,
3500 <ref id="isspace" name="isspace">,
3501 <ref id="isupper" name="isupper">,
3502 <ref id="isxdigit" name="isxdigit">
3508 <sect1>islower<label id="islower"><p>
3512 <tag/Function/Check if a given character is a lower case letter.
3513 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
3514 <tag/Declaration/<tt/int __fastcall__ islower (int c);/
3515 <tag/Description/The function returns a non zero value if the given argument
3516 is a lower case letter. The return value is zero if the character is anything
3518 <tag/Notes/<itemize>
3519 <item>When compiling with <tt/-Os/ the function is actually a macro. The
3520 inline sequence generated by the macro will not work correctly for values
3521 outside the range 0..255. <em/Note:/ The constant <tt/EOF/ is not part of
3522 this range. The non inline function may be accessed by <tt/#undef/'ing the
3524 <item>When compiling without <tt/-Os/, the function is only available as
3525 fastcall function, so it may only be used in presence of a prototype.
3527 <tag/Availability/ISO 9899
3529 <ref id="isalnum" name="isalnum">,
3530 <ref id="isalpha" name="isalpha">,
3531 <ref id="isascii" name="isascii">,
3532 <ref id="isblank" name="isblank">,
3533 <ref id="iscntrl" name="iscntrl">,
3534 <ref id="isdigit" name="isdigit">,
3535 <ref id="isgraph" name="isgraph">,
3536 <ref id="isprint" name="isprint">,
3537 <ref id="ispunct" name="ispunct">,
3538 <ref id="isspace" name="isspace">,
3539 <ref id="isupper" name="isupper">,
3540 <ref id="isxdigit" name="isxdigit">
3546 <sect1>isprint<label id="isprint"><p>
3550 <tag/Function/Check if a given character is a printable character.
3551 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
3552 <tag/Declaration/<tt/int __fastcall__ isprint (int c);/
3553 <tag/Description/The function returns a non zero value if the given argument
3554 is a printable character (this includes the space character). The return value
3555 is zero if the character is anything else.
3556 <tag/Notes/<itemize>
3557 <item>When compiling with <tt/-Os/ the function is actually a macro. The
3558 inline sequence generated by the macro will not work correctly for values
3559 outside the range 0..255. <em/Note:/ The constant <tt/EOF/ is not part of
3560 this range. The non inline function may be accessed by <tt/#undef/'ing the
3562 <item>When compiling without <tt/-Os/, the function is only available as
3563 fastcall function, so it may only be used in presence of a prototype.
3565 <tag/Availability/ISO 9899
3567 <ref id="isalnum" name="isalnum">,
3568 <ref id="isalpha" name="isalpha">,
3569 <ref id="isascii" name="isascii">,
3570 <ref id="isblank" name="isblank">,
3571 <ref id="iscntrl" name="iscntrl">,
3572 <ref id="isdigit" name="isdigit">,
3573 <ref id="isgraph" name="isgraph">,
3574 <ref id="islower" name="islower">,
3575 <ref id="ispunct" name="ispunct">,
3576 <ref id="isspace" name="isspace">,
3577 <ref id="isupper" name="isupper">,
3578 <ref id="isxdigit" name="isxdigit">
3584 <sect1>ispunct<label id="ispunct"><p>
3588 <tag/Function/Check if a given character is a printable character but not a
3589 space or an alphanumeric character.
3590 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
3591 <tag/Declaration/<tt/int __fastcall__ ispunct (int c);/
3592 <tag/Description/The function returns a non zero value if the given argument
3593 is a printable character, but not a space or anything alphanumeric. The return
3594 value is zero if the character is anything else.
3595 <tag/Notes/<itemize>
3596 <item>When compiling with <tt/-Os/ the function is actually a macro. The
3597 inline sequence generated by the macro will not work correctly for values
3598 outside the range 0..255. <em/Note:/ The constant <tt/EOF/ is not part of
3599 this range. The non inline function may be accessed by <tt/#undef/'ing the
3601 <item>When compiling without <tt/-Os/, the function is only available as
3602 fastcall function, so it may only be used in presence of a prototype.
3604 <tag/Availability/ISO 9899
3606 <ref id="isalnum" name="isalnum">,
3607 <ref id="isalpha" name="isalpha">,
3608 <ref id="isascii" name="isascii">,
3609 <ref id="isblank" name="isblank">,
3610 <ref id="iscntrl" name="iscntrl">,
3611 <ref id="isdigit" name="isdigit">,
3612 <ref id="isgraph" name="isgraph">,
3613 <ref id="islower" name="islower">,
3614 <ref id="isprint" name="isprint">,
3615 <ref id="isspace" name="isspace">,
3616 <ref id="isupper" name="isupper">,
3617 <ref id="isxdigit" name="isxdigit">
3623 <sect1>isspace<label id="isspace"><p>
3627 <tag/Function/Check if a given character is a a white-space character.
3628 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
3629 <tag/Declaration/<tt/int __fastcall__ isspace (int c);/
3630 <tag/Description/The function returns a non zero value if the given argument
3631 is a white space character. The return value is zero if the character is
3632 anything else. The standard white space characters are: space, formfeed ('\f'),
3633 newline ('\n'), carriage return ('\r'), horizontal tab ('\t'), and vertical tab
3635 <tag/Notes/<itemize>
3636 <item>When compiling with <tt/-Os/ the function is actually a macro. The
3637 inline sequence generated by the macro will not work correctly for values
3638 outside the range 0..255. <em/Note:/ The constant <tt/EOF/ is not part of
3639 this range. The non inline function may be accessed by <tt/#undef/'ing the
3641 <item>When compiling without <tt/-Os/, the function is only available as
3642 fastcall function, so it may only be used in presence of a prototype.
3644 <tag/Availability/ISO 9899
3646 <ref id="isalnum" name="isalnum">,
3647 <ref id="isalpha" name="isalpha">,
3648 <ref id="isascii" name="isascii">,
3649 <ref id="isblank" name="isblank">,
3650 <ref id="iscntrl" name="iscntrl">,
3651 <ref id="isdigit" name="isdigit">,
3652 <ref id="isgraph" name="isgraph">,
3653 <ref id="islower" name="islower">,
3654 <ref id="isprint" name="isprint">,
3655 <ref id="ispunct" name="ispunct">,
3656 <ref id="isupper" name="isupper">,
3657 <ref id="isxdigit" name="isxdigit">
3663 <sect1>isupper<label id="isupper"><p>
3667 <tag/Function/Check if a given character is an upper case letter.
3668 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
3669 <tag/Declaration/<tt/int __fastcall__ isupper (int c);/
3670 <tag/Description/The function returns a non zero value if the given argument
3671 is an upper case letter. The return value is zero if the character is anything
3673 <tag/Notes/<itemize>
3674 <item>When compiling with <tt/-Os/ the function is actually a macro. The
3675 inline sequence generated by the macro will not work correctly for values
3676 outside the range 0..255. <em/Note:/ The constant <tt/EOF/ is not part of
3677 this range. The non inline function may be accessed by <tt/#undef/'ing the
3679 <item>When compiling without <tt/-Os/, the function is only available as
3680 fastcall function, so it may only be used in presence of a prototype.
3682 <tag/Availability/ISO 9899
3684 <ref id="isalnum" name="isalnum">,
3685 <ref id="isalpha" name="isalpha">,
3686 <ref id="isascii" name="isascii">,
3687 <ref id="isblank" name="isblank">,
3688 <ref id="iscntrl" name="iscntrl">,
3689 <ref id="isdigit" name="isdigit">,
3690 <ref id="isgraph" name="isgraph">,
3691 <ref id="islower" name="islower">,
3692 <ref id="isprint" name="isprint">,
3693 <ref id="ispunct" name="ispunct">,
3694 <ref id="isspace" name="isspace">,
3695 <ref id="isxdigit" name="isxdigit">
3701 <sect1>isxdigit<label id="isxdigit"><p>
3705 <tag/Function/Check if a given character is a hexadecimal digit.
3706 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
3707 <tag/Declaration/<tt/int __fastcall__ isxdigit (int c);/
3708 <tag/Description/The function returns a non zero value if the given argument
3709 is a hexadecimal digit (0..9, a..f and A..F). The return value is zero if the
3710 character is anything else.
3711 <tag/Notes/<itemize>
3712 <item>When compiling with <tt/-Os/ the function is actually a macro. The
3713 inline sequence generated by the macro will not work correctly for values
3714 outside the range 0..255. <em/Note:/ The constant <tt/EOF/ is not part of
3715 this range. The non inline function may be accessed by <tt/#undef/'ing the
3717 <item>When compiling without <tt/-Os/, the function is only available as
3718 fastcall function, so it may only be used in presence of a prototype.
3720 <tag/Availability/ISO 9899
3722 <ref id="isalnum" name="isalnum">,
3723 <ref id="isalpha" name="isalpha">,
3724 <ref id="isascii" name="isascii">,
3725 <ref id="isblank" name="isblank">,
3726 <ref id="iscntrl" name="iscntrl">,
3727 <ref id="isdigit" name="isdigit">,
3728 <ref id="isgraph" name="isgraph">,
3729 <ref id="islower" name="islower">,
3730 <ref id="isprint" name="isprint">,
3731 <ref id="ispunct" name="ispunct">,
3732 <ref id="isspace" name="isspace">,
3733 <ref id="isupper" name="isupper">
3739 <sect1>itoa<label id="itoa"><p>
3743 <tag/Function/Convert an integer into a string.
3744 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
3745 <tag/Declaration/<tt/char* __fastcall__ itoa (int val, char* buf, int radix);/
3746 <tag/Description/<tt/itoa/ converts the integer <tt/val/ into a string using
3747 <tt/radix/ as the base.
3748 <tag/Notes/<itemize>
3749 <item>There are no provisions to prevent a buffer overflow.
3750 <item>If <tt/val/ contains <tt/INT_MIN/, the behaviour is undefined.
3751 <item>The function is non standard, so it is not available in strict ANSI mode.
3752 You should probably use <tt/sprintf/ instead.
3753 <item>The function is only available as fastcall function, so it may only be
3754 used in presence of a prototype.
3756 <tag/Availability/cc65
3758 <ref id="atoi" name="atoi">,
3759 <ref id="atol" name="atol">,
3760 <ref id="ltoa" name="ltoa">,
3761 <ref id="ultoa" name="ultoa">,
3762 <ref id="utoa" name="utoa">
3768 <sect1>joy_count<label id="joy_count"><p>
3772 <tag/Function/Return the number of joysticks supported by the current driver.
3773 <tag/Header/<tt/<ref id="joystick.h" name="joystick.h">/
3774 <tag/Declaration/<tt/unsigned char joy_count (void);/
3775 <tag/Description/The function returns a the number of joysticks supported
3776 by the current joystick driver.
3777 <tag/Notes/<itemize>
3778 <item>A joystick driver must be loaded using <ref id="joy_load_driver"
3779 name="joy_load_driver"> before calling this function.
3780 <item>The function returns the number of joysticks supported by the driver.
3781 There's no way to check for the number of actually connected joysticks.
3783 <tag/Availability/cc65
3785 <ref id="joy_load_driver" name="joy_load_driver">,
3786 <ref id="joy_read" name="joy_read">
3792 <sect1>joy_install<label id="joy_install"><p>
3796 <tag/Function/Install an already loaded driver and return an error code.
3797 <tag/Header/<tt/<ref id="joystick.h" name="joystick.h">/
3798 <tag/Declaration/<tt/unsigned char __fastcall__ joy_install (void* driver);/
3799 <tag/Description/The function installs a driver that was already loaded into
3800 memory (or linked statically to the program). It returns an error code
3801 (<tt/JOY_ERR_OK/ in case of success).
3802 <tag/Notes/<itemize>
3803 <item>The function is only available as fastcall function, so it may only be
3804 used in presence of a prototype.
3806 <tag/Availability/cc65
3808 <ref id="joy_load_driver" name="joy_load_driver">,
3809 <ref id="joy_uninstall" name="joy_uninstall">,
3810 <ref id="joy_unload" name="joy_unload">
3816 <sect1>joy_load_driver<label id="joy_load_driver"><p>
3820 <tag/Function/Load a driver from disk and install it.
3821 <tag/Header/<tt/<ref id="joystick.h" name="joystick.h">/
3822 <tag/Declaration/<tt/unsigned char __fastcall__ joy_load_driver (const char* driver);/
3823 <tag/Description/The function loads a driver with the given name from disk
3824 and installs it. An error code is returned, which is <tt/JOY_ERR_OK/ if the
3825 driver was successfully loaded and installed.
3826 <tag/Notes/<itemize>
3827 <item>The function is only available as fastcall function, so it may only be
3828 used in presence of a prototype.
3830 <tag/Availability/cc65
3832 <ref id="joy_install" name="joy_install">,
3833 <ref id="joy_uninstall" name="joy_uninstall">,
3834 <ref id="joy_unload" name="joy_unload">
3840 <sect1>joy_read<label id="joy_read"><p>
3844 <tag/Function/Read the status of a joystick.
3845 <tag/Header/<tt/<ref id="joystick.h" name="joystick.h">/
3846 <tag/Declaration/<tt/unsigned char __fastcall__ joy_read (unsigned char joystick);/
3847 <tag/Description/The function reads the status bits for a joystick. The number
3848 of the joystick is passed as parameter. The result may be examined by using one
3849 of the <tt/JOY_xxx/ macros from <ref id="joystick.h" name="joystick.h">.
3850 <tag/Notes/<itemize>
3851 <item>A joystick driver must be loaded using <ref id="joy_load_driver"
3852 name="joy_load_driver"> before calling this function.
3853 <item>The function is only available as fastcall function, so it may only be
3854 used in presence of a prototype.
3856 <tag/Availability/cc65
3858 <ref id="joy_count" name="joy_count">,
3859 <ref id="joy_load_driver" name="joy_load_driver">,
3860 <ref id="joy_unload" name="joy_unload">
3866 <sect1>joy_uninstall<label id="joy_uninstall"><p>
3870 <tag/Function/Uninstall the current joystick driver.
3871 <tag/Header/<tt/<ref id="joystick.h" name="joystick.h">/
3872 <tag/Declaration/<tt/unsigned char joy_uninstall (void);/
3873 <tag/Description/The function uninstalls the currently installed joystick
3874 driver. It does not remove the driver from memory. The function returns an
3875 error code, which is <tt/JOY_ERR_OK/ if the driver was successfully uninstalled.
3876 <tag/Notes/<itemize>
3877 <item>A joystick driver must be installed using <ref id="joy_install"
3878 name="joy_install"> before calling this function.
3880 <tag/Availability/cc65
3882 <ref id="joy_install" name="joy_install">,
3883 <ref id="joy_load_driver" name="joy_load_driver">,
3884 <ref id="joy_unload" name="joy_unload">
3890 <sect1>joy_unload<label id="joy_unload"><p>
3894 <tag/Function/Uninstall, then unload the current joystick driver.
3895 <tag/Header/<tt/<ref id="joystick.h" name="joystick.h">/
3896 <tag/Declaration/<tt/unsigned char joy_unload (void);/
3897 <tag/Description/The function uninstalls the currently installed joystick
3898 driver and removes it from memory. An error code is returned, which is
3899 <tt/JOY_ERR_OK/ if the driver was successfully uninstalled.
3900 <tag/Notes/<itemize>
3901 <item>A joystick driver must be loaded using <ref id="joy_load_driver"
3902 name="joy_load_driver"> before calling this function.
3904 <tag/Availability/cc65
3906 <ref id="joy_load_driver" name="joy_load_driver">
3912 <sect1>kbhit<label id="kbhit"><p>
3916 <tag/Function/Check if there's a key waiting in the keyboard buffer.
3917 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
3918 <tag/Declaration/<tt/unsigned char kbhit (void);/
3919 <tag/Description/The function returns a value of zero if there is no character
3920 waiting to be read from the keyboard. It returns non zero otherwise.
3921 <tag/Notes/<itemize>
3922 <item>If the system does not support a keyboard buffer (most systems
3923 do), the function is rather useless.
3925 <tag/Availability/cc65
3927 <ref id="cgetc" name="cgetc">,
3928 <ref id="cursor" name="cursor">
3934 <sect1>labs<label id="labs"><p>
3938 <tag/Function/Returns the absolute value of a long integer.
3939 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
3940 <tag/Declaration/<tt/long __fastcall__ labs (long v);/
3941 <tag/Description/<tt/labs/ returns the absolute value of the argument passed to
3943 <tag/Notes/<itemize>
3944 <item>The return value is undefined if <tt/LONG_MIN/ is passed to the function.
3945 <item>The function is only available as fastcall function, so it may only be
3946 used in presence of a prototype.
3948 <tag/Availability/ISO 9899
3950 <ref id="abs" name="abs">
3956 <sect1>ltoa<label id="ltoa"><p>
3960 <tag/Function/Convert a long integer into a string.
3961 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
3962 <tag/Declaration/<tt/char* __fastcall__ ltoa (long val, char* buf, int radix);/
3963 <tag/Description/<tt/itoa/ converts the long integer <tt/val/ into a string
3964 using <tt/radix/ as the base.
3965 <tag/Notes/<itemize>
3966 <item>There are no provisions to prevent a buffer overflow.
3967 <item>If <tt/val/ contains <tt/LONG_MIN/, the behaviour is undefined.
3968 <item>The function is non standard, so it is not available in strict ANSI mode.
3969 You should probably use <tt/sprintf/ instead.
3970 <item>The function is only available as fastcall function, so it may only be
3971 used in presence of a prototype.
3973 <tag/Availability/cc65
3975 <ref id="atoi" name="atoi">,
3976 <ref id="atol" name="atol">,
3977 <ref id="itoa" name="itoa">,
3978 <ref id="ultoa" name="ultoa">,
3979 <ref id="utoa" name="utoa">
3985 <sect1>localeconv<label id="localeconv"><p>
3989 <tag/Function/Returns a pointer to the current locale structure.
3990 <tag/Header/<tt/<ref id="locale.h" name="locale.h">/
3991 <tag/Declaration/<tt/struct lconv* localeconv (void);/
3992 <tag/Description/<tt/localeconv/ returns a pointer to the current locale
3994 <tag/Notes/<itemize>
3995 <item>cc65 supports only the "C" locale, so even after setting a new locale
3996 using <tt/<ref id="setlocale" name="setlocale">/, the structure returned will
3999 <tag/Availability/ISO 9899
4001 <ref id="setlocale" name="setlocale">
4007 <sect1>longjmp<label id="longjmp"><p>
4011 <tag/Function/Non local goto.
4012 <tag/Header/<tt/<ref id="setjmp.h" name="setjmp.h">/
4013 <tag/Declaration/<tt/void __fastcall__ longjmp (jmp_buf buf, int retval);/
4014 <tag/Description/The <tt/longjmp/ function restores a program context from the
4015 data in <tt/buf/, which must have been set by a preceeding call to
4016 <tt/<ref id="setjmp" name="setjmp">/. Program execution continues as if the
4017 call to <tt/<ref id="setjmp" name="setjmp">/ has just returned the value
4019 <tag/Notes/<itemize>
4020 <item>If the parameter <tt/retval/ is zero, the function will behave as if it
4021 was called with a value of one.
4022 <item>The function is only available as fastcall function, so it may only
4023 be used in presence of a prototype.
4025 <tag/Availability/ISO 9899
4027 <ref id="setjmp" name="setjmp">
4033 <sect1>malloc<label id="malloc"><p>
4037 <tag/Function/Allocate dynamic memory.
4038 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
4039 <tag/Declaration/<tt/void* __fastcall__ malloc (size_t size);/
4040 <tag/Description/<tt/malloc/ allocates size bytes on the heap and returns a
4041 pointer to the allocated memory block. On error (not enough memory available),
4042 <tt/malloc/ returns <tt/NULL/.
4043 <tag/Notes/<itemize>
4044 <item>The function is only available as fastcall function, so it may only
4045 be used in presence of a prototype.
4047 <tag/Availability/ISO 9899
4049 <ref id="_heapadd" name="_heapadd">,
4050 <ref id="_heapblocksize" name="_heapblocksize">,
4051 <ref id="_heapmaxavail" name="_heapmaxavail">,
4052 <ref id="_heapmemavail" name="_heapmemavail">,
4053 <ref id="calloc" name="calloc">,
4054 <ref id="free" name="free">,
4055 <ref id="realloc" name="realloc">,
4056 <ref id="strdup" name="strdup">
4062 <sect1>memchr<label id="memchr"><p>
4066 <tag/Function/Search for a character in a block of raw memory.
4067 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4068 <tag/Declaration/<tt/void* __fastcall__ strchr (const void* mem, int c, size_t count);/
4069 <tag/Description/The <tt/memchr/ function locates the first occurrence of <tt/c/
4070 (converted to a char) in the block of raw memory string pointed to by <tt/mem/
4071 that is of size <tt/count/. Upon completion, the function returns a pointer to
4072 the character found, or a null pointer if the character was not found.
4073 <tag/Notes/<itemize>
4074 <item>The function is only available as fastcall function, so it may only
4075 be used in presence of a prototype.
4077 <tag/Availability/ISO 9899
4079 <ref id="strchr" name="strchr">
4085 <sect1>memcmp<label id="memcmp"><p>
4089 <tag/Function/Compare two memory areas.
4090 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4091 <tag/Declaration/<tt/int __fastcall__ memcmp (const void* p1, const void* p2, size_t count);/
4092 <tag/Description/<tt/memcmp/ compares <tt/count/ bytes from the memory area
4093 pointed to by <tt/p1/ into the memory area pointed to by <tt/p2/. It returns a value that is less than
4094 zero if <tt/p1/ is less than <tt/p2/, zero if <tt/p1/ is the same as <tt/p2/,
4095 and a value greater than zero if <tt/p1/ is greater than <tt/p2/.
4096 <tag/Notes/<itemize>
4097 <item>The function is only available as fastcall function, so it may only
4098 be used in presence of a prototype.
4100 <tag/Availability/ISO 9899
4102 <ref id="strcmp" name="strcmp">,
4103 <ref id="memmove" name="memmove">,
4104 <ref id="memset" name="memset">
4110 <sect1>memcpy<label id="memcpy"><p>
4114 <tag/Function/Copy a memory area.
4115 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4116 <tag/Declaration/<tt/void* __fastcall__ memcpy (void* dest, const void* src, size_t count);/
4117 <tag/Description/<tt/memcpy/ copies <tt/count/ bytes from the memory area
4118 pointed to by <tt/src/ into the memory area pointed to by <tt/dest/. It returns
4120 <tag/Notes/<itemize>
4121 <item>The result is undefined if the memory areas do overlap. Use
4122 <tt/<ref id="memmove" name="memmove">/ to copy overlapping memory areas.
4123 <item>The function is only available as fastcall function, so it may only
4124 be used in presence of a prototype.
4126 <tag/Availability/ISO 9899
4128 <ref id="_swap" name="_swap">,
4129 <ref id="memmove" name="memmove">,
4130 <ref id="memset" name="memset">
4136 <sect1>memmove<label id="memmove"><p>
4140 <tag/Function/Copy a memory area.
4141 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4142 <tag/Declaration/<tt/void* __fastcall__ memmove (void* dest, const void* src, size_t count);/
4143 <tag/Description/<tt/memmove/ copies <tt/count/ bytes from the memory area
4144 pointed to by <tt/src/ into the memory area pointed to by <tt/dest/. It returns
4146 <tag/Notes/<itemize>
4147 <item>While <tt/memmove/ allows the memory areas to overlap, it has some
4148 additional overhead compared to <tt/<ref id="memcpy" name="memcpy">/.
4149 <item>The function is only available as fastcall function, so it may only
4150 be used in presence of a prototype.
4152 <tag/Availability/ISO 9899
4154 <ref id="_swap" name="_swap">,
4155 <ref id="memcpy" name="memcpy">,
4156 <ref id="memset" name="memset">
4162 <sect1>memset<label id="memset"><p>
4166 <tag/Function/Fill a memory area.
4167 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4168 <tag/Declaration/<tt/void* __fastcall__ memset (void* p, int val, size_t count);/
4169 <tag/Description/<tt/memset/ fills the memory area pointed to by <tt/p/ with
4170 the value <tt/val/. The function returns <tt/p/.
4171 <tag/Notes/<itemize>
4172 <item>The function is only available as fastcall function, so it may only
4173 be used in presence of a prototype.
4175 <tag/Availability/ISO 9899
4177 <ref id="_swap" name="_swap">,
4178 <ref id="bzero" name="bzero">,
4179 <ref id="memcpy" name="memcpy">,
4180 <ref id="memmove" name="memmove">
4186 <sect1>mod_free<label id="mod_free"><p>
4190 <tag/Function/Free a relocatable module.
4191 <tag/Header/<tt/<ref id="modload.h" name="modload.h">/
4192 <tag/Declaration/<tt/void __fastcall__ mod_free (void* module);/
4193 <tag/Description/The function will free a module loaded into memory by use of
4194 the <tt/<ref id="mod_load" name="mod_load">/ function.
4195 <tag/Notes/<itemize>
4196 <item>The pointer passed as parameter is the pointer to the module memory,
4197 not the pointer to the control structure.
4198 <item>The function is available only as a fastcall function; so, it may be used
4199 only in the presence of a prototype.
4201 <tag/Availability/cc65
4203 <ref id="mod_load" name="mod_load">
4209 <sect1>mod_load<label id="mod_load"><p>
4213 <tag/Function/Load a relocatable module.
4214 <tag/Header/<tt/<ref id="modload.h" name="modload.h">/
4215 <tag/Declaration/<tt/unsigned char __fastcall__ mod_load (struct mod_ctrl* ctrl);/
4216 <tag/Description/The function will load a code module into memory and relocate
4217 it. The function will return an error code. If <tt/MLOAD_OK/ is returned, the
4218 outgoing fields in the passed <tt/mod_ctrl/ struct contain information about
4219 the module just loaded. Possible error codes are:
4221 <item><tt/MLOAD_OK/ - Module load successful
4222 <item><tt/MLOAD_ERR_READ/ - Read error
4223 <item><tt/MLOAD_ERR_HDR/ - Header error
4224 <item><tt/MLOAD_ERR_OS/ - Wrong operating system
4225 <item><tt/MLOAD_ERR_FMT/ - Data format error
4226 <item><tt/MLOAD_ERR_MEM/ - Not enough memory
4228 <tag/Notes/<itemize>
4229 <item>The <htmlurl url="ld65.html" name="ld65"> linker is needed to create
4230 relocatable o65 modules for use with this function.
4231 <item>The function is available only as a fastcall function; so, it may be used
4232 only in the presence of a prototype.
4234 <tag/Availability/cc65
4236 <ref id="mod_free" name="mod_free">
4242 <sect1>mouse_setbox<label id="mouse_setbox"><p>
4246 <tag/Function/Specify a bounding box for the mouse cursor.
4247 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
4248 <tag/Declaration/<tt/void __fastcall__ mouse_setbox (const struct mouse_box* box);/
4249 <tag/Description/The function allows to set a bounding box for mouse movement.
4250 <tag/Notes/<itemize>
4251 <item>The function does not check if the mouse cursor is currently within the
4252 given rectangle. Placing the mouse cursor within the bounding box is the
4253 responsibility of the programmer.
4254 <item>While the bounding box may be larger than the actual screen size, the
4255 standard mouse cursor draw routines may fail to set the cursor to coordinates
4256 outside of the screen area. Depending on the platform, you may have to supply
4257 your own mouse cursor routines.
4258 <item>The function is only available as fastcall function, so it may only be
4259 used in presence of a prototype.
4261 <tag/Availability/cc65
4263 <ref id="mouse_getbox" name="mouse_getbox">,
4264 <ref id="mouse_move" name="mouse_move">
4270 <sect1>mouse_getbox<label id="mouse_getbox"><p>
4274 <tag/Function/Return the current bounding box for the mouse cursor.
4275 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
4276 <tag/Declaration/<tt/void __fastcall__ mouse_getbox (struct mouse_box* box);/
4277 <tag/Description/The function queries the current bounding box for mouse
4279 <tag/Notes/<itemize>
4280 <item>The function is only available as fastcall function, so it may only be
4281 used in presence of a prototype.
4283 <tag/Availability/cc65
4285 <ref id="mouse_move" name="mouse_move">,
4286 <ref id="mouse_setbox" name="mouse_setbox">
4292 <sect1>mouse_buttons<label id="mouse_buttons"><p>
4296 <tag/Function/Return a bit mask encoding the state of the mouse buttons.
4297 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
4298 <tag/Declaration/<tt/unsigned char mouse_buttons (void);/
4299 <tag/Description/The function returns a bit mask that encodes the state of the
4300 mouse buttons. You may use the <tt/MOUSE_BTN_XXX/ flags to decode the function
4302 <tag/Availability/cc65
4304 <ref id="mouse_info" name="mouse_info">,
4305 <ref id="mouse_pos" name="mouse_pos">
4311 <sect1>mouse_geterrormsg<label id="mouse_geterrormsg"><p>
4315 <tag/Function/Return a readable error message for an error code.
4316 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
4317 <tag/Declaration/<tt/const char* __fastcall__ mouse_geterrormsg (unsigned char
4319 <tag/Description/The function returns an error message (in english) for the
4320 error code passed parameter.
4321 <tag/Notes/<itemize>
4322 <item>The function will return "Unknown error" for invalid error codes.
4323 <item>The function is only available as fastcall function, so it may only be
4324 used in presence of a prototype.
4326 <tag/Availability/cc65
4328 <ref id="mouse_load_driver" name="mouse_load_driver">,
4329 <ref id="mouse_uninstall" name="mouse_uninstall">,
4330 <ref id="mouse_unload" name="mouse_unload">
4336 <sect1>mouse_hide<label id="mouse_hide"><p>
4340 <tag/Function/Hide the mouse pointer.
4341 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
4342 <tag/Declaration/<tt/void mouse_hide (void);/
4343 <tag/Description/The function hides the mouse pointer. It manages a counter
4344 that is shared between <tt/<ref id="mouse_show" name="mouse_show">/ and
4345 <tt/mouse_hide/ so that every call call to <tt/mouse_hide/ must be followed by
4346 a call to <tt/<ref id="mouse_show" name="mouse_show">/ to make the mouse cursor
4348 <tag/Availability/cc65
4350 <ref id="mouse_show" name="mouse_show">
4356 <sect1>mouse_info<label id="mouse_info"><p>
4360 <tag/Function/Return the state of the mouse buttons and the position of the
4362 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
4363 <tag/Declaration/<tt/void __fastcall__ mouse_info (struct mouse_info* info);/
4364 <tag/Description/The function returns the state of the mouse buttons and the
4365 position of the mouse in the <tt/mouse_info/ structure passed as parameter.
4366 <tag/Notes/<itemize>
4367 <item>The <tt/mouse_info/ struct is a superset of the <tt/mouse_pos/ struct,
4368 so if you just need the mouse position, call <tt/<ref id="mouse_pos"
4369 name="mouse_pos">/ instead.
4370 <item>The function is only available as fastcall function, so it may only be
4371 used in presence of a prototype.
4373 <tag/Availability/cc65
4375 <ref id="mouse_buttons" name="mouse_buttons">,
4376 <ref id="mouse_pos" name="mouse_pos">
4382 <sect1>mouse_install<label id="mouse_install"><p>
4386 <tag/Function/Install an already loaded mouse driver.
4387 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
4388 <tag/Declaration/<tt/unsigned char __fastcall__ mouse_install (const struct
4389 mouse_callbacks* c, void* driver);/
4390 <tag/Description/The function installs an already loaded mouse driver and
4391 returns an error code. The <tt/mouse_callbacks/ structure passed as first
4392 parameter contains pointers to routines needed to move or hide/show the mouse
4393 pointer. Defaults for these routines are supplied by the library, so if you
4394 can live with these defaults (which are platform specific), just pass a
4395 pointer to <tt/mouse_def_callbacks/. The function may be used to install a
4396 driver linked statically to the program.
4397 <tag/Notes/<itemize>
4398 <item>Not all drivers are able to detect if the supported hardware is really
4400 <item>After installing a driver, the mouse cursor is hidden.
4401 <item>The function is only available as fastcall function, so it may only be
4402 used in presence of a prototype.
4404 <tag/Availability/cc65
4406 <ref id="mouse_load_driver" name="mouse_load_driver">,
4407 <ref id="mouse_uninstall" name="mouse_uninstall">,
4408 <ref id="mouse_unload" name="mouse_unload">
4414 <sect1>mouse_ioctl<label id="mouse_ioctl"><p>
4418 <tag/Function/Call the driver specific ioctl function.
4419 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
4420 <tag/Declaration/<tt/unsigned char __fastcall__ mouse_ioctl (unsigned char code, void* data);/
4421 <tag/Description/The function calls the IOCTL entry in the mouse driver,
4422 which is driver specific. The <tt/code/ parameter will choose between
4423 different IOCTL functions, and the <tt/data/ depends on code. The
4424 function returns an error code. The purpose of this function is to allow
4425 for driver specific extensions. See the documentation for a specific mouse
4426 driver for supported ioctl calls.
4427 <tag/Notes/<itemize>
4428 <item>Calling this function is non portable, because each driver may
4429 implement different ioctl calls (or none at all).
4430 <item>The function is only available as fastcall function, so it may only be
4431 used in presence of a prototype.
4433 <tag/Availability/cc65
4439 <sect1>mouse_load_driver<label id="mouse_load_driver"><p>
4443 <tag/Function/Load and initialize a mouse driver.
4444 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
4445 <tag/Declaration/<tt/unsigned char __fastcall__ mouse_load_driver (const struct
4446 mouse_callbacks* c, const char* driver);/
4447 <tag/Description/Load a mouse driver into memory and initialize it. The
4448 function returns an error code that tells if the call has been successful. The
4449 <tt/mouse_callbacks/ structure passed as first parameter contains pointers to
4450 routines needed to move or hide/show the mouse pointer. Defaults for these
4451 routines are supplied by the library, so if you can live with these defaults
4452 (which are platform specific), just pass a pointer to <tt/mouse_def_callbacks/.
4453 <tag/Notes/<itemize>
4454 <item>The driver is loaded by name, so currently you must know the type of
4455 mouse that should be supported. There is no autodetect capability.
4456 <item>Not all drivers are able to detect if the supported hardware is really
4458 <item>After installing a driver, the mouse cursor is hidden.
4459 <item>The function is only available as fastcall function, so it may only be
4460 used in presence of a prototype.
4462 <tag/Availability/cc65
4464 <ref id="mouse_install" name="mouse_install">,
4465 <ref id="mouse_uninstall" name="mouse_uninstall">,
4466 <ref id="mouse_unload" name="mouse_unload">
4472 <sect1>mouse_move<label id="mouse_move"><p>
4476 <tag/Function/Move the mouse cursor to a specific position.
4477 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
4478 <tag/Declaration/<tt/void __fastcall__ mouse_move (int x, int y);/
4479 <tag/Description/The function updates the mouse position. If the mouse cursor
4480 is visible, it is shown at the new position.
4481 <tag/Notes/<itemize>
4482 <item>The function does not check if the new position is within the bounding
4483 box specified with <tt/<ref id="mouse_setbox" name="mouse_setbox">/.
4484 <item>The function is only available as fastcall function, so it may only be
4485 used in presence of a prototype.
4487 <tag/Availability/cc65
4489 <ref id="mouse_getbox" name="mouse_getbox">,
4490 <ref id="mouse_setbox" name="mouse_setbox">
4496 <sect1>mouse_pos<label id="mouse_pos"><p>
4500 <tag/Function/Return the position of the mouse.
4501 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
4502 <tag/Declaration/<tt/void __fastcall__ mouse_pos (struct mouse_pos* pos);/
4503 <tag/Description/The function returns the position of the mouse in the
4504 <tt/mouse_pos/ structure passed as parameter.
4505 <tag/Notes/<itemize>
4506 <item>The <tt/mouse_pos/ struct is a subset of the <tt/mouse_info/ struct,
4507 so if you do also need the mouse buttons, call <tt/<ref id="mouse_info"
4508 name="mouse_info">/ instead.
4509 <item>The function is only available as fastcall function, so it may only be
4510 used in presence of a prototype.
4512 <tag/Availability/cc65
4514 <ref id="mouse_buttons" name="mouse_buttons">,
4515 <ref id="mouse_info" name="mouse_info">
4521 <sect1>mouse_show<label id="mouse_show"><p>
4525 <tag/Function/Show the mouse pointer.
4526 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
4527 <tag/Declaration/<tt/void mouse_show (void);/
4528 <tag/Description/The function shows the mouse pointer. It manages a counter
4529 that is shared between <tt/<ref id="mouse_hide" name="mouse_hide">/ and
4530 <tt/mouse_show/. The mouse cursor is visible if there was one more call to
4531 <tt/mouse_show/ than to <tt/<ref id="mouse_hide" name="mouse_hide">/.
4532 <tag/Availability/cc65
4534 <ref id="mouse_hide" name="mouse_hide">
4540 <sect1>mouse_uninstall<label id="mouse_uninstall"><p>
4544 <tag/Function/Uninstall an already loaded mouse driver.
4545 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
4546 <tag/Declaration/<tt/unsigned char mouse_uninstall (void);/
4547 <tag/Description/The function uninstalls an already loaded mouse driver but
4548 don't removes it from memory.
4549 <tag/Notes/<itemize>
4550 <item>If the driver has been loaded using <tt/<ref id="mouse_load_driver"
4551 name="mouse_load_driver">/, <tt/<ref id="mouse_unload" name="mouse_unload">/
4552 should be used instead of <tt/mouse_uninstall/ so the driver is also removed
4555 <tag/Availability/cc65
4557 <ref id="mouse_install" name="mouse_install">,
4558 <ref id="mouse_load_driver" name="mouse_load_driver">,
4559 <ref id="mouse_unload" name="mouse_unload">
4565 <sect1>mouse_unload<label id="mouse_unload"><p>
4569 <tag/Function/Unload a mouse driver.
4570 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
4571 <tag/Declaration/<tt/unsigned char mouse_unload (void);/
4572 <tag/Description/The function unloads a loaded mouse driver and frees all
4573 memory allocated for the driver.
4574 <tag/Notes/<itemize>
4575 <item>The function does nothing if no driver is loaded.
4577 <tag/Availability/cc65
4579 <ref id="mouse_install" name="mouse_install">,
4580 <ref id="mouse_load_driver" name="mouse_load_driver">,
4581 <ref id="mouse_uninstall" name="mouse_uninstall">
4587 <sect1>offsetof<label id="offsetof"><p>
4591 <tag/Function/Calculate the offset of a struct or union member.
4592 <tag/Header/<tt/<ref id="stddef.h" name="stddef.h">/
4593 <tag/Declaration/<tt/size_t offsetof (type, member);/
4594 <tag/Description/<tt/offsetof/ calculates the address offset of a <tt/struct/
4595 or <tt/union/ member.
4596 <tag/Notes/<itemize>
4597 <item>The function is actually a macro.
4599 <tag/Availability/ISO 9899
4605 <sect1>open<label id="open"><p>
4609 <tag/Function/Open and possibly create a file.
4610 <tag/Header/<tt/<ref id="fcntl.h" name="fcntl.h">/
4611 <tag/Declaration/<tt/int open (const char* name, int flags, ...);/
4612 <tag/Description/<tt/open/ opens a file and returns the file descriptor
4613 associated with it. On error, -1 is returned and an error code is stored in
4614 <tt/errno/. Several flags may be passed to <tt/open/ that change the behaviour.
4615 <tag/Notes/<itemize>
4616 <item>POSIX specifies an additional <tt/mode/ argument that may be passed to
4617 open, which is used as the permission mask when a new file is created. While
4618 cc65 allows to pass this argument, it is ignored.
4620 <tag/Availability/POSIX 1003.1
4622 <ref id="close" name="close">,
4623 <ref id="creat" name="creat">
4629 <sect1>opendir<label id="opendir"><p>
4633 <tag/Function/Open a directory.
4634 <tag/Header/<tt/<ref id="dirent.h" name="dirent.h">/
4635 <tag/Declaration/<tt/DIR* __fastcall__ opendir (const char* name);/
4636 <tag/Description/<tt/opendir/ opens a directory and returns the direcory
4637 descriptor associated with it. On error, NULL is returned and an error code is
4638 stored in <tt/errno/.
4639 <tag/Notes/<itemize>
4640 <item>The function is only available as fastcall function, so it may only
4641 be used in presence of a prototype.
4643 <tag/Availability/POSIX 1003.1
4645 <ref id="closedir" name="closedir">,
4646 <ref id="readdir" name="readdir">
4652 <sect1>peekbsys<label id="peekbsys"><p>
4656 <tag/Function/Read one byte from a location in the system bank.
4657 <tag/Header/<tt/<ref id="cbm610.h" name="cbm610.h">/,
4658 <tt/<ref id="cbm510.h" name="cbm510.h">/
4659 <tag/Declaration/<tt/unsigned char __fastcall__ peekbsys (unsigned addr);/
4660 <tag/Description/<tt/peekbsys/ reads one byte from the given address in the
4661 system bank (bank 15) of the CBM PET-II machines and returns it.
4662 <tag/Notes/<itemize>
4663 <item>The function is only available as fastcall function, so it may only
4664 be used in presence of a prototype.
4665 <item>This function may be a macro depending on the compiler options. The
4666 actual function is accessible by #undef'ing the macro.
4668 <tag/Availability/cc65
4670 <ref id="PEEK" name="PEEK">,
4671 <ref id="PEEKW" name="PEEKW">,
4672 <ref id="peekwsys" name="peekwsys">,
4673 <ref id="pokebsys" name="pokebsys">,
4674 <ref id="pokewsys" name="pokewsys">
4680 <sect1>peekwsys<label id="peekwsys"><p>
4684 <tag/Function/Read one word from a location in the system bank.
4685 <tag/Header/<tt/<ref id="cbm610.h" name="cbm610.h">/,
4686 <tt/<ref id="cbm510.h" name="cbm510.h">/
4687 <tag/Declaration/<tt/unsigned __fastcall__ peekwsys (unsigned addr);/
4688 <tag/Description/<tt/peekwsys/ reads one word from the given address in the
4689 system bank (bank 15) of the CBM PET-II machines and returns it. Following
4690 the usual 6502 conventions, the low byte is read from <tt/addr/, and the
4691 high byte is read from <tt/addr+1/.
4692 <tag/Notes/<itemize>
4693 <item>The function is only available as fastcall function, so it may only
4694 be used in presence of a prototype.
4695 <item>The order in which the two bytes are read is undefined.
4697 <tag/Availability/cc65
4699 <ref id="PEEK" name="PEEK">,
4700 <ref id="PEEKW" name="PEEKW">,
4701 <ref id="peekbsys" name="peekbsys">,
4702 <ref id="pokebsys" name="pokebsys">,
4703 <ref id="pokewsys" name="pokewsys">
4709 <sect1>perror<label id="perror"><p>
4713 <tag/Function/Print an error message for the error in <tt/errno/.
4714 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
4715 <tag/Declaration/<tt/void __fastcall__ perror (const char* s);/
4716 <tag/Description/<tt/perror/ prints an error message to <tt/stderr/. If <tt/s/
4717 is not <tt/NULL/ and not an empty string, it is printed followed by a colon and
4718 a blank. Then the error message for the current contents of <tt/errno/ is
4719 printed followed by a newline. The message output is the same as returned by
4720 <tt/<ref id="strerror" name="strerror">/ with an argument of <tt/errno/.
4721 <tag/Notes/<itemize>
4722 <item>The function is only available as fastcall function, so it may only
4723 be used in presence of a prototype.
4725 <tag/Availability/ISO 9899
4727 <ref id="_poserror" name="_poserror">,
4728 <ref id="strerror" name="strerror">
4734 <sect1>pokebsys<label id="pokebsys"><p>
4738 <tag/Function/Write one byte to a location in the system bank.
4739 <tag/Header/<tt/<ref id="cbm610.h" name="cbm610.h">/,
4740 <tt/<ref id="cbm510.h" name="cbm510.h">/
4741 <tag/Declaration/<tt/void __fastcall__ pokebsys (unsigned addr, unsigned char val);/
4742 <tag/Description/<tt/pokebsys/ writes one byte to the given address in the
4743 system bank (bank 15) of the CBM PET-II machines.
4744 <tag/Notes/<itemize>
4745 <item>The function is only available as fastcall function, so it may only
4746 be used in presence of a prototype.
4748 <tag/Availability/cc65
4750 <ref id="POKE" name="POKE">,
4751 <ref id="POKEW" name="POKEW">,
4752 <ref id="peekbsys" name="peekbsys">,
4753 <ref id="peekwsys" name="peekwsys">,
4754 <ref id="pokewsys" name="pokewsys">
4760 <sect1>pokewsys<label id="pokewsys"><p>
4764 <tag/Function/Write one word to a location in the system bank.
4765 <tag/Header/<tt/<ref id="cbm610.h" name="cbm610.h">/,
4766 <tt/<ref id="cbm510.h" name="cbm510.h">/
4767 <tag/Declaration/<tt/void __fastcall__ pokewsys (unsigned addr, unsigned val);/
4768 <tag/Description/<tt/pokewsys/ writes one word to the given address in the
4769 system bank (bank 15) of the CBM PET-II machines. Following the usual 6502
4770 conventions, the low byte of <tt/val/ is written to <tt/addr/, and the
4771 high byte is written to <tt/addr+1/.
4772 <tag/Notes/<itemize>
4773 <item>The function is only available as fastcall function, so it may only
4774 be used in presence of a prototype.
4775 <item>The order in which the two bytes are written is undefined.
4777 <tag/Availability/cc65
4779 <ref id="POKE" name="POKE">,
4780 <ref id="POKEW" name="POKEW">,
4781 <ref id="peekbsys" name="peekbsys">,
4782 <ref id="peekwsys" name="peekwsys">,
4783 <ref id="pokebsys" name="pokebsys">
4789 <sect1>qsort<label id="qsort"><p>
4793 <tag/Function/Sort an array.
4794 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
4795 <tag/Declaration/<tt/void __fastcall__ qsort (void* base, size_t count,
4796 size_t size, int __fastcall__ (* compare) (const void*, const void*));/
4797 <tag/Description/<tt/qsort/ sorts an array according to a given compare
4798 function <tt/compare/. <tt/base/ is the address of the array, <tt/count/
4799 is the number of elements, <tt/size/ the size of an element and <tt/compare/
4800 the function used to compare the members.
4801 <tag/Notes/<itemize>
4802 <item>If there are multiple members with the same key, the order after calling
4803 the function is undefined.
4804 <item>The function is only available as fastcall function, so it may only
4805 be used in presence of a prototype.
4806 <item>The function to which <tt/compare/ points must have the <tt/fastcall/
4809 <tag/Availability/ISO 9899
4811 <ref id="bsearch" name="bsearch">
4817 <sect1>raise<label id="raise"><p>
4821 <tag/Function/Send a signal to the executing program.
4822 <tag/Header/<tt/<ref id="signal.h" name="signal.h">/
4823 <tag/Declaration/<tt/int __fastcall__ raise (int sig);/
4824 <tag/Description/<tt/raise/ sends the given signal to the program. If the
4825 program has installed a signal handler for the signal, this signal handler
4826 will be executed. If no handler has been installed, the default action for
4827 the raised signal will be taken. The function returns zero on success,
4829 <tag/Notes/<itemize>
4830 <item>The function is only available as fastcall function, so it may only
4831 be used in presence of a prototype.
4833 <tag/Availability/ISO 9899
4835 <ref id="abort" name="abort">,
4836 <ref id="signal" name="signal">
4842 <sect1>rand<label id="rand"><p>
4846 <tag/Function/Return a pseudo random number.
4847 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
4848 <tag/Declaration/<tt/int rand (void);/
4849 <tag/Description/The function returns a pseudo random number
4850 between 0 and <tt/RAND_MAX/ (exclusive).
4851 <tag/Notes/<itemize>
4852 <item>Without using <tt><ref id="srand" name="srand"></tt>, always the same
4853 flow of numbers is generated.
4854 <item>On startup, the function behaves as if <ref id="srand" name="srand">
4855 had been used with an argument of 1.
4857 <tag/Availability/ISO 9899
4859 <ref id="_randomize" name="_randomize">,
4860 <ref id="srand" name="srand">
4866 <sect1>readdir<label id="readdir"><p>
4870 <tag/Function/Read a directory.
4871 <tag/Header/<tt/<ref id="dirent.h" name="dirent.h">/
4872 <tag/Declaration/<tt/struct dirent* __fastcall__ readdir (DIR* dir);/
4873 <tag/Description/<tt/readdir/ reads the next directory entry from the directory
4874 stream pointed to by <tt/dir/. It stores the data in a <tt/dirent/ structure
4875 and returns a pointer to it. If the end of directory is reached, or an error
4876 occurs, NULL is returned. In case of errors, an error code is stored into
4878 <tag/Notes/<itemize>
4879 <item>The function is only available as fastcall function, so it may only
4880 be used in presence of a prototype.
4881 <item>The returned pointer may point to a statically allocated instance of
4882 <tt/struct dirent/, so it may get overwritten by subsequent calls to
4884 <item>On several platforms, namely the CBMs and the Atari, the disk drives get
4885 confused when opening/closing files between directory reads. So for example a
4886 program that reads the list of files on a disk, and after each call to
4887 <tt/readdir/, opens the file to process it, will fail.<newline>
4888 Possible solutions are reading the directory into memory before processing the
4889 file list, or to reset the directory by seeking to the correct position after
4890 opening/closing a file:
4892 seekdir (DIR, telldir (DIR));
4894 Platforms known to work without problems are: Apple.
4896 <tag/Availability/POSIX 1003.1
4898 <ref id="closedir" name="closedir">,
4899 <ref id="opendir" name="opendir">
4905 <sect1>realloc<label id="realloc"><p>
4909 <tag/Function/Change the size of an allocated memory block.
4910 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
4911 <tag/Declaration/<tt/void* __fastcall__ realloc (void* block, size_t size);/
4912 <tag/Description/<tt/realloc/ changes the size of the memory block pointed to
4913 by <tt/block/ to <tt/size/ bytes. If <tt/block/ is <tt/NULL/, <tt/realloc/
4914 behaves as if <tt/malloc/ had been called. If <tt/size/ is zero, <tt/realloc/
4915 behaves as if <tt/free/ had been called. On error (not enough memory
4916 available), <tt/realloc/ returns <tt/NULL/.
4917 <tag/Notes/<itemize>
4918 <item>The part of the memory block that is returned will have its contents
4920 <item>This function is somewhat dangerous to use. Be careful to save the
4921 pointer you're passing somewhere else, otherwise
4923 ptr = realloc (ptr, size);
4925 will loose your only copy of <tt/ptr/ if <tt/realloc/ returns <tt/NULL/.
4926 <item>The function is only available as fastcall function, so it may only
4927 be used in presence of a prototype.
4929 <tag/Availability/ISO 9899
4931 <ref id="_heapadd" name="_heapadd">,
4932 <ref id="_heapblocksize" name="_heapblocksize">,
4933 <ref id="_heapmaxavail" name="_heapmaxavail">,
4934 <ref id="_heapmemavail" name="_heapmemavail">,
4935 <ref id="calloc" name="calloc">,
4936 <ref id="free" name="free">,
4937 <ref id="realloc" name="realloc">
4943 <sect1>remove<label id="remove"><p>
4947 <tag/Function/Delete a file.
4948 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
4949 <tag/Declaration/<tt/int __fastcall__ remove (const char* name);/
4950 <tag/Description/<tt/remove/ deletes the file with the given name. On success,
4951 zero is returned. On error, -1 is returned and <tt/errno/ is set to an error
4952 code describing the reason for the failure.
4953 <tag/Notes/<itemize>
4954 <item>This function is not available on all cc65 targets (depends on the
4955 availability of file I/O).
4956 <item>The function is only available as fastcall function, so it may only
4957 be used in presence of a prototype.
4959 <tag/Availability/ISO 9899
4961 <ref id="rename" name="rename">,
4962 <ref id="unlink" name="unlink">
4965 #include <stdio.h>
4967 #define FILENAME "helloworld"
4969 if (remove (FILENAME) == 0) {
4970 printf ("We deleted %s successfully\n", FILENAME);
4972 printf ("There was a problem deleting %s\n", FILENAME);
4979 <sect1>rename<label id="rename"><p>
4983 <tag/Function/Rename a file.
4984 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
4985 <tag/Declaration/<tt/int __fastcall__ rename (const char* oldname, const char* newname);/
4986 <tag/Description/<tt/rename/ renames a file (gives it a new name). On success,
4987 zero is returned. On error, -1 is returned and <tt/errno/ is set to an error
4988 code describing the reason for the failure.
4989 <tag/Notes/<itemize>
4990 <item>This function is not available on all cc65 targets (depends on the
4991 capabilities of the storage devices).
4992 <item>The function is only available as fastcall function, so it may only
4993 be used in presence of a prototype.
4995 <tag/Availability/ISO 9899
4997 <ref id="remove" name="remove">
5000 #include <stdio.h>
5002 #define OLDNAME "textfile.txt"
5003 #define NEWNAME "textfile.bak"
5005 if (rename (OLDNAME, NEWNAME) == 0) {
5006 printf ("Renamed %s to %s\n", OLDNAME, NEWNAME);
5008 printf ("Error renaming %s to %s\n", OLDNAME, NEWNAME);
5015 <sect1>reset_brk<label id="reset_brk"><p>
5019 <tag/Function/Resets the break vector to its original value.
5020 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
5021 <tag/Declaration/<tt/void reset_brk (void);/
5022 <tag/Description/<tt/reset_brk/ resets the break vector to the value it had
5023 before a call to <tt/set_brk/.
5024 <tag/Notes/<itemize>
5025 <item>The break vector is reset on program termination, so it's not strictly
5026 necessary to call this function as a part of your clean-up when exitting the program.
5028 <tag/Availability/cc65
5030 <ref id="reset_irq" name="reset_irq">,
5031 <ref id="set_brk" name="set_brk">,
5032 <ref id="set_irq" name="set_irq">
5038 <sect1>reset_irq<label id="reset_irq"><p>
5042 <tag/Function/Resets the C level interrupt request vector.
5043 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
5044 <tag/Declaration/<tt/void reset_irq (void);/
5045 <tag/Description/<tt/reset_irq/ resets the C level interrupt request vector.
5046 <tag/Notes/<itemize>
5047 <item>The interrupt vector is reset on program termination, so it's not strictly
5048 necessary to call this function as a part of your clean-up when exitting the program.
5050 <tag/Availability/cc65
5052 <ref id="reset_brk" name="reset_brk">,
5053 <ref id="set_brk" name="set_brk">,
5054 <ref id="set_irq" name="set_irq">
5060 <sect1>revers<label id="revers"><p>
5064 <tag/Function/Control revers character display.
5065 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
5066 <tag/Declaration/<tt/unsigned char __fastcall__ revers (unsigned char onoff);/
5067 <tag/Description/If the argument is non zero, the function enables reverse
5068 character display. If the argument is zero, reverse character display is
5069 switched off. The old value of the setting is returned.
5070 <tag/Notes/<itemize>
5071 <item>The function may not be supported by the hardware, in which case
5072 the call is ignored.
5073 <item>The function is only available as fastcall function, so it may only
5074 be used in presence of a prototype.
5076 <tag/Availability/cc65
5078 <ref id="textcolor" name="textcolor">
5084 <sect1>rewinddir<label id="rewinddir"><p>
5088 <tag/Function/Reset a directory stream.
5089 <tag/Header/<tt/<ref id="dirent.h" name="dirent.h">/
5090 <tag/Declaration/<tt/void __fastcall__ rewinddir (DIR* dir);/
5091 <tag/Description/<tt/rewinddir/ sets the position of the directory stream
5092 pointed to by <tt/dir/ to the start of the directory.
5093 <tag/Notes/<itemize>
5094 <item>The function is only available as fastcall function, so it may only
5095 be used in presence of a prototype.
5097 <tag/Availability/POSIX 1003.1
5099 <ref id="seekdir" name="seekdir">,
5100 <ref id="telldir" name="telldir">
5106 <sect1>screensize<label id="screensize"><p>
5110 <tag/Function/Return the dimensions of the text mode screen.
5111 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
5112 <tag/Declaration/<tt/void __fastcall__ screensize (unsigned char* x, unsigned char* y);/
5113 <tag/Description/The function returns the dimensions of the text mode screen.
5114 <tag/Notes/<itemize>
5115 <item>The function is only available as fastcall function, so it may only
5116 be used in presence of a prototype.
5118 <tag/Availability/cc65
5120 <ref id="gotox" name="gotox">,
5121 <ref id="gotoxy" name="gotoxy">,
5122 <ref id="gotoy" name="gotoy">,
5123 <ref id="wherex" name="wherex">,
5124 <ref id="wherey" name="wherey">
5130 <sect1>seekdir<label id="seekdir"><p>
5134 <tag/Function/Set the position of a directory stream.
5135 <tag/Header/<tt/<ref id="dirent.h" name="dirent.h">/
5136 <tag/Declaration/<tt/void __fastcall__ seekdir (DIR* dir, long offset);/
5137 <tag/Description/<tt/seekdir/ sets the position of the directory stream
5138 pointed to by <tt/dir/ to the value given in <tt/offset/, which should be a
5139 value returned by <tt/<ref id="telldir" name="telldir">/.
5140 <tag/Notes/<itemize>
5141 <item>The function is only available as fastcall function, so it may only
5142 be used in presence of a prototype.
5144 <tag/Availability/POSIX 1003.1
5146 <ref id="rewinddir" name="rewinddir">,
5147 <ref id="telldir" name="telldir">
5153 <sect1>ser_close<label id="ser_close"><p>
5157 <tag/Function/Close the port and disable interrupts
5158 <tag/Header/<tt/<ref id="serial.h" name="serial.h">/
5159 <tag/Declaration/<tt/unsigned char ser_close (void);/
5160 <tag/Description/Close the port by clearing buffers and disable interrupts.
5161 <tag/Availability/cc65
5162 <tag/See also/Other serial functions.
5167 static void initialize(){
5168 struct ser_params params = {
5175 ser_install(lynx_comlynx); // This will activate the ComLynx
5177 ser_open(&params);
5184 <sect1>ser_get<label id="ser_get"><p>
5188 <tag/Function/Read a character from serial port.
5189 <tag/Header/<tt/<ref id="serial.h" name="serial.h">/
5190 <tag/Declaration/<tt/unsigned char __fastcall__ ser_get (char* b);/
5191 <tag/Description/Get a character from the serial port. If no characters are
5192 available, the function will return SER_ERR_NO_DATA, so this is not a fatal
5194 <tag/Notes/<itemize>
5195 <item>The function is only available as fastcall function, so it may only
5196 be used in presence of a prototype.
5198 <tag/Availability/cc65
5199 <tag/See also/Other serial functions.
5201 Wait for a character to be available from a serial port.
5204 while (ser_get(&ch) == SER_ERR_NO_DATA)
5211 <sect1>ser_install<label id="ser_install"><p>
5215 <tag/Function/Install an already loaded driver and return an error code.
5216 <tag/Header/<tt/<ref id="serial.h" name="serial.h">/
5217 <tag/Declaration/<tt/unsigned char __fastcall__ ser_install (void* driver);/
5218 <tag/Description/The function installs a driver that was already loaded into
5219 memory (or linked statically to the program). It returns an error code
5220 (<tt/SER_ERR_OK/ in case of success).
5221 <tag/Notes/<itemize>
5222 <item>The function is only available as fastcall function, so it may only be
5223 used in presence of a prototype.
5225 <tag/Availability/cc65
5227 <ref id="ser_load_driver" name="ser_load_driver">,
5228 <ref id="ser_uninstall" name="ser_uninstall">,
5229 <ref id="ser_unload" name="ser_unload">
5231 ser_install(lynx_comlynx); //Include the driver statically instead of loading it.
5237 <sect1>ser_ioctl<label id="ser_ioctl"><p>
5241 <tag/Function/Platform dependent code extensions.
5242 <tag/Header/<tt/<ref id="serial.h" name="serial.h">/
5243 <tag/Declaration/<tt/unsigned __fastcall__ ser_ioctl (unsigned char code, void* data);/
5244 <tag/Description/Some platforms have extra serial functions that are not
5245 supported by standard serial driver functions. You can extend the driver to support
5246 this extra functionality bt using ser_ioctl functions.
5247 <tag/Notes/<itemize>
5248 <item>The function is only available as fastcall function, so it may only
5249 be used in presence of a prototype.
5250 <item>These functions are not easily portable to other cc65 platforms.
5252 <tag/Availability/cc65
5253 <tag/See also/Other serial functions.
5258 <sect1>ser_load_driver<label id="ser_load_driver"><p>
5262 <tag/Function/Load and install a serial driver.
5263 <tag/Header/<tt/<ref id="serial.h" name="serial.h">/
5264 <tag/Declaration/<tt/unsigned char __fastcall__ ser_load_driver (const char *name);/
5265 <tag/Description/Load and install the driver by name.
5266 Will just load the driver and check if loading was successful.
5267 <tag/Notes/<itemize>
5268 <item>The function is only available as fastcall function, so it may only
5269 be used in presence of a prototype.
5271 <tag/Availability/cc65
5272 <tag/See also/Other serial functions.
5278 <sect1>ser_open<label id="ser_open"><p>
5282 <tag/Function/Open the port by setting the port parameters and enable interrupts
5283 <tag/Header/<tt/<ref id="serial.h" name="serial.h">/
5284 <tag/Declaration/<tt/unsigned char __fastcall__ ser_open (const struct ser_params* params);/
5285 <tag/Description/Open the port by setting the port parameters and enable interrupts.
5286 <tag/Notes/<itemize>
5287 <item>The function is only available as fastcall function, so it may only
5288 be used in presence of a prototype.
5290 <tag/Availability/cc65
5291 <tag/See also/Other serial functions.
5296 static void initialize(){
5297 struct ser_params params = {
5304 ser_install(lynx_comlynx); // This will activate the ComLynx
5306 ser_open(&params);
5313 <sect1>ser_put<label id="ser_put"><p>
5317 <tag/Function/Write a character to a serial port.
5318 <tag/Header/<tt/<ref id="serial.h" name="serial.h">/
5319 <tag/Declaration/<tt/unsigned char __fastcall__ ser_put (char b);/
5320 <tag/Description/Send a character via the serial port. There is a transmit
5321 buffer, but transmitting is not done via interrupt. The function returns
5322 SER_ERR_OVERFLOW if there is no space left in the transmit buffer.
5323 <tag/Notes/<itemize>
5324 <item>The function is only available as fastcall function, so it may only
5325 be used in presence of a prototype.
5327 <tag/Availability/cc65
5328 <tag/See also/Other serial functions.
5337 <sect1>ser_status<label id="ser_status"><p>
5341 <tag/Function/Return the serial port status.
5342 <tag/Header/<tt/<ref id="serial.h" name="serial.h">/
5343 <tag/Declaration/<tt/unsigned char __fastcall__ ser_status (unsigned char* status);/
5344 <tag/Description/Return the serial port status.
5345 <tag/Notes/<itemize>
5346 <item>The function is only available as fastcall function, so it may only
5347 be used in presence of a prototype.
5349 <tag/Availability/cc65
5350 <tag/See also/Other serial functions.
5356 <sect1>ser_uninstall<label id="ser_uninstall"><p>
5360 <tag/Function/Uninstall the currently loaded driver but do not unload it.
5361 <tag/Header/<tt/<ref id="serial.h" name="serial.h">/
5362 <tag/Declaration/<tt/unsigned char ser_uninstall (void);/
5363 <tag/Description/Uninstall the currently loaded driver but do not unload it.
5364 <tag/Availability/cc65
5365 <tag/See also/Other serial functions.
5370 <sect1>ser_unload<label id="ser_unload"><p>
5374 <tag/Function/Uninstall, then unload the currently loaded driver.
5375 <tag/Header/<tt/<ref id="serial.h" name="serial.h">/
5376 <tag/Declaration/<tt/unsigned char ser_unload (void);/
5377 <tag/Description/Uninstall, then unload the currently loaded driver.
5378 <tag/Availability/cc65
5379 <tag/See also/Other serial functions.
5385 <sect1>set_brk<label id="set_brk"><p>
5389 <tag/Function/Set the break vector to a user function.
5390 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
5391 <tag/Declaration/<tt/void __fastcall__ set_brk (brk_handler func);/
5392 <tag/Description/<tt/set_brk/ allows a user program to handle breaks within the
5393 program code by letting the vector point to a user written C function. The
5394 runtime library installs a small stub that saves the registers into global
5395 variables that may be accessed (and changed) by the break handler.
5396 <tag/Notes/<itemize>
5397 <item>The function is only available as fastcall function, so it may only
5398 be used in presence of a prototype.
5399 <item>The stub saves the zero page registers used by the C runtime and switches
5400 to a small break handler stack. This means that it is safe to execute C code,
5401 even if C code was interrupted. Be careful however not to use too many local
5402 variables, and do not enable stack checks for the handler function or any other
5403 function called from it.
5404 <item>The <tt/brk_pc/ variable points to the <tt/BRK/ instruction. If you want
5405 the continue with the interrupted code, you have to adjust <tt/brk_pc/,
5406 otherwise the <tt/BRK/ instruction will get executed over and over again.
5407 <item>The break vector is reset on program termination, so it's not strictly
5408 necessary to call <tt/<ref id="reset_brk" name="reset_brk">/ as a part of your
5409 clean-up when exitting the program.
5411 <tag/Availability/cc65
5413 <ref id="reset_brk" name="reset_brk">
5419 <sect1>set_irq<label id="set_irq"><p>
5423 <tag/Function/Set the C level interrupt request vector to the given address.
5424 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
5425 <tag/Declaration/<tt/void __fastcall__ set_irq (irq_handler f, void *stack_addr, size_t stack_size);/
5426 <tag/Description/<tt/set_irq/ allows a user program to handle interrupt requests
5427 (IRQs) within the program code by letting the vector point to a user written C
5428 function. The runtime library installs a small stub that saves the zero page
5429 registers used by the C runtime before calling the handler function and restores
5430 them after the handler function returns. Additionally the stub temporarily switches
5431 the C runtime stack to the stack area provided as parameter. If the handler function
5432 was set up to handle a "private", "exclusive" interrupt request source it must
5433 return the value <tt/IRQ_HANDLED/ if and only if it has verified that the current
5434 interrupt request actually stems from that source. In all other cases it must return
5435 the value <tt/IRQ_NOT_HANDLED/.
5436 <tag/Notes/<itemize>
5437 <item>The function is only available as fastcall function, so it may only
5438 be used in presence of a prototype.
5439 <item>The stub saves the registers and zero page locations used by the C runtime
5440 and switches to the provided stack area. As a consequence, there is some
5441 runtime overhead, but it it is safe to execute C code, even if other C code
5442 was interrupted. Be careful however not to call C library functions, and do not
5443 enable stack checks for the handler function or any other function called from
5445 <item>The interrupt vector is reset on program termination, so it's not strictly
5446 necessary to call <tt/<ref id="reset_irq" name="reset_irq">/ as a part of your
5447 clean-up when exitting the program.
5449 <tag/Availability/cc65
5451 <ref id="reset_brk" name="reset_brk">,
5452 <ref id="reset_irq" name="reset_irq">,
5453 <ref id="set_brk" name="set_brk">
5459 <sect1>setjmp<label id="setjmp"><p>
5463 <tag/Function/Save the context for use with <tt/longjmp/.
5464 <tag/Header/<tt/<ref id="setjmp.h" name="setjmp.h">/
5465 <tag/Declaration/<tt/int __fastcall__ setjmp (jmp_buf buf);/
5466 <tag/Description/The <tt/setjmp/ function saves the current context in <tt/buf/
5467 for subsequent use by the <tt/<ref id="longjmp" name="longjmp">/ function and
5469 <tag/Notes/<itemize>
5470 <item>The function is only available as fastcall function, so it may only
5471 be used in presence of a prototype.
5472 <item><tt/setjmp/ is actually a macro as required by the ISO standard.
5473 <item><tt/setjmp/ will not save the signal context.
5475 <tag/Availability/ISO 9899
5477 <ref id="longjmp" name="longjmp">
5483 <sect1>setlocale<label id="setlocale"><p>
5487 <tag/Function/Selects a locale.
5488 <tag/Header/<tt/<ref id="locale.h" name="locale.h">/
5489 <tag/Declaration/<tt/char* __fastcall__ setlocale (int category, const char* locale);/
5490 <tag/Description/<tt/setlocale/ sets or queries the program's locale.
5491 <tag/Notes/<itemize>
5492 <item>The function is only available as fastcall function, so it may only
5493 be used in presence of a prototype.
5494 <item>cc65 supports only the "C" locale, so calling this function to set a
5495 different locale has no effect.
5497 <tag/Availability/ISO 9899
5499 <ref id="localeconv" name="localeconv">,
5500 <ref id="strcoll" name="strcoll">
5501 <ref id="strxfrm" name="strxfrm">
5507 <sect1>signal<label id="signal"><p>
5511 <tag/Function/Install a signal handler.
5512 <tag/Header/<tt/<ref id="signal.h" name="signal.h">/
5513 <tag/Declaration/<tt/__sigfunc __fastcall__ signal (int sig, __sigfunc func);/
5514 <tag/Description/<tt/signal/ installs a handler for the given signal. The
5515 handler may either be a user supplied function, or one of the predefined
5516 signal handlers <tt/SIG_IGN/ or <tt/SIG_DFL/. The function returns the
5517 previous value if the signal , or the special function vector SIG_ERR in
5519 <tag/Notes/<itemize>
5520 <item>The function is only available as fastcall function, so it may only
5521 be used in presence of a prototype.
5523 <tag/Availability/ISO 9899
5525 <ref id="abort" name="abort">,
5526 <ref id="raise" name="raise">
5532 <sect1>sleep<label id="sleep"><p>
5536 <tag/Function/Sleep for a specified amount of time.
5537 <tag/Header/<tt/<ref id="unistd.h" name="unistd.h">/
5538 <tag/Declaration/<tt/void __fastcall__ sleep (unsigned seconds);/
5539 <tag/Description/The function will return after the specified number of
5540 seconds have elapsed.
5541 <tag/Notes/<itemize>
5542 <item>The function is only available as fastcall function, so it may only
5543 be used in presence of a prototype.
5545 <tag/Availability/POSIX 1003.1
5551 <sect1>slow<label id="slow"><p>
5555 <tag/Function/Switch the C128 into 1MHz mode.
5556 <tag/Header/<tt/<ref id="c128.h" name="c128.h">/
5557 <tag/Declaration/<tt/void slow (void);/
5558 <tag/Description/The function will switch the clock of the C128 to 1MHz. This
5559 will halve the speed compared to fast mode.
5560 <tag/Notes/<itemize>
5561 <item>The function is specific to the C128.
5563 <tag/Availability/C128
5565 <ref id="fast" name="fast">,
5566 <ref id="toggle_videomode" name="toggle_videomode">,
5567 <ref id="videomode" name="videomode">
5573 <sect1>srand<label id="srand"><p>
5577 <tag/Function/Initialize the pseudo random number generator.
5578 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
5579 <tag/Declaration/<tt/void __fastcall__ srand (unsigned seed);/
5580 <tag/Description/The function initializes the random number generator using
5581 the given seed. On program startup, the generator behaves as if <tt/srand/ has
5582 been called with an argument of 1.
5583 <tag/Notes/<itemize>
5584 <item>The function is only available as fastcall function, so it may only
5585 be used in presence of a prototype.
5587 <tag/Availability/ISO 9899
5589 <ref id="_randomize" name="_randomize">,
5590 <ref id="rand" name="rand">
5596 <sect1>strcasecmp<label id="strcasecmp"><p>
5600 <tag/Function/Compare two strings case insensitive.
5601 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5602 <tag/Declaration/<tt/int __fastcall__ strcasecmp (const char* s1, const char* s2);/
5603 <tag/Description/The <tt/strcasecmp/ function compares the two strings passed
5604 as parameters without case sensitivity. It returns a value that is less than
5605 zero if <tt/s1/ is less than <tt/s2/, zero if <tt/s1/ is the same as <tt/s2/,
5606 and a value greater than zero if <tt/s1/ is greater than <tt/s2/.
5607 <tag/Notes/<itemize>
5608 <item>The function is only available as fastcall function, so it may only
5609 be used in presence of a prototype.
5610 <item>The function is not available in strict ANSI mode.
5612 <tag/Availability/cc65
5614 <ref id="strcmp" name="strcmp">,
5615 <ref id="strcoll" name="strcoll">,
5616 <ref id="stricmp" name="stricmp">,
5617 <ref id="strncmp" name="strncmp">,
5618 <ref id="strxfrm" name="strxfrm">
5624 <sect1>strcat<label id="strcat"><p>
5628 <tag/Function/Concatentate two strings.
5629 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5630 <tag/Declaration/<tt/char* __fastcall__ strcat (char* s1, const char* s2);/
5631 <tag/Description/The <tt/strcat/ function appends a copy of the string
5632 pointed to by s2 (including the terminating null byte) to the end of the
5633 string pointed to by s1. The initial byte of s2 overwrites the null byte at
5635 <tag/Notes/<itemize>
5636 <item>The function is only available as fastcall function, so it may only
5637 be used in presence of a prototype.
5638 <item>If copying takes place between objects that overlap, the behaviour
5641 <tag/Availability/ISO 9899
5643 <ref id="strcpy" name="strcpy">,
5644 <ref id="strncat" name="strncat">,
5645 <ref id="strncpy" name="strncpy">
5651 <sect1>strchr<label id="strchr"><p>
5655 <tag/Function/Search for a character in a string.
5656 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5657 <tag/Declaration/<tt/char* __fastcall__ strchr (const char* s, int c);/
5658 <tag/Description/The <tt/strchr/ function locates the first occurrence of <tt/c/
5659 (converted to a char) in the string pointed to by <tt/s/. The terminating null
5660 byte is considered to be part of the string. Upon completion, the function
5661 returns a pointer to the byte, or a null pointer if the byte was not found.
5662 <tag/Notes/<itemize>
5663 <item>The function is only available as fastcall function, so it may only
5664 be used in presence of a prototype.
5666 <tag/Availability/ISO 9899
5668 <ref id="memchr" name="memchr">,
5669 <ref id="strrchr" name="strrchr">
5675 <sect1>strcmp<label id="strcmp"><p>
5679 <tag/Function/Compare two strings.
5680 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5681 <tag/Declaration/<tt/int __fastcall__ strcmp (const char* s1, const char* s2);/
5682 <tag/Description/The <tt/strcmp/ function compares the two strings passed as
5683 parameters. It returns a value that is less than zero if <tt/s1/ is less than
5684 <tt/s2/, zero if <tt/s1/ is the same as <tt/s2/, and a value greater than zero
5685 if <tt/s1/ is greater than <tt/s2/.
5686 <tag/Notes/<itemize>
5687 <item>The function is only available as fastcall function, so it may only
5688 be used in presence of a prototype.
5690 <tag/Availability/ISO 9899
5692 <ref id="strcasecmp" name="strcasecmp">,
5693 <ref id="strcoll" name="strcoll">,
5694 <ref id="stricmp" name="stricmp">,
5695 <ref id="strncmp" name="strncmp">
5696 <ref id="strxfrm" name="strxfrm">
5702 <sect1>strcoll<label id="strcoll"><p>
5706 <tag/Function/Compare two strings.
5707 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5708 <tag/Declaration/<tt/int __fastcall__ strcoll (const char* s1, const char* s2);/
5709 <tag/Description/The <tt/strcoll/ function compares the two strings passed as
5710 parameters, according to the collating sequence set by <tt/<ref id="setlocale"
5711 name="setlocale">/. It returns a value that is less than zero if <tt/s1/ is
5712 less than <tt/s2/, zero if <tt/s1/ is the same as <tt/s2/, and a value greater
5713 than zero if <tt/s1/ is greater than <tt/s2/.
5714 <tag/Notes/<itemize>
5715 <item>The function is only available as fastcall function, so it may only
5716 be used in presence of a prototype.
5718 <tag/Availability/ISO 9899
5720 <ref id="setlocale" name="setlocale">,
5721 <ref id="strcasecmp" name="strcasecmp">,
5722 <ref id="strcmp" name="strcmp">,
5723 <ref id="stricmp" name="stricmp">,
5724 <ref id="strncmp" name="strncmp">,
5725 <ref id="strxfrm" name="strxfrm">
5731 <sect1>strcpy<label id="strcpy"><p>
5735 <tag/Function/Copy a string.
5736 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5737 <tag/Declaration/<tt/char* __fastcall__ strcpy (char* s1, const char* s2);/
5738 <tag/Description/The <tt/strcpy/ function copies the string pointed to by
5739 <tt/s2/ (including the terminating null byte) into the array pointed to by
5740 <tt/s1/. The function will always return <tt/s1/.
5741 <tag/Notes/<itemize>
5742 <item>The function is only available as fastcall function, so it may only
5743 be used in presence of a prototype.
5744 <item>If copying takes place between objects that overlap, the behaviour
5747 <tag/Availability/ISO 9899
5749 <ref id="strcat" name="strcat">,
5750 <ref id="strncat" name="strncat">,
5751 <ref id="strncpy" name="strncpy">
5754 #include <string.h>
5756 static char hello[14];
5758 strcpy (hello, "Hello world!\n");
5764 <sect1>strcspn<label id="strcspn"><p>
5768 <tag/Function/Compute the length of a substring.
5769 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5770 <tag/Declaration/<tt/size_t __fastcall__ strcspn (const char* s, const char* set);/
5771 <tag/Description/The <tt/strcspn/ function computes and returns the length of
5772 the substring pointed to by <tt/s/ which does <em>not</em> consist of
5773 characters contained in the string <tt/set/.
5774 <tag/Notes/<itemize>
5775 <item>The function is only available as fastcall function, so it may only
5776 be used in presence of a prototype.
5778 <tag/Availability/ISO 9899
5780 <ref id="strqtok" name="strqtok">,
5781 <ref id="strspn" name="strspn">,
5782 <ref id="strstr" name="strstr">,
5783 <ref id="strtok" name="strtok">
5789 <sect1>strdup<label id="strdup"><p>
5793 <tag/Function/Allocate a copy of a string on the heap.
5794 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5795 <tag/Declaration/<tt/char* __fastcall__ strdup (const char* s);/
5796 <tag/Description/<tt/strdup/ allocates a memory block on the heap, big enough
5797 to hold a copy of <tt/s/ including the terminating zero. If the allocation
5798 fails, <tt/NULL/ is returned, otherwise <tt/s/ is copied into the allocated
5799 memory block, and a pointer to the block is returned.
5800 <tag/Notes/<itemize>
5801 <item>The function is only available as fastcall function, so it may only
5802 be used in presence of a prototype.
5803 <item>It is up to the caller to free the allocated memory block.
5805 <tag/Availability/ISO 9899
5807 <ref id="free" name="free">,
5808 <ref id="malloc" name="malloc">
5814 <sect1>strerror<label id="strerror"><p>
5818 <tag/Function/Return a string describing an error code.
5819 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5820 <tag/Declaration/<tt/char* __fastcall__ strerror (int errcode);/
5821 <tag/Description/The <tt/strerror/ function returns a string describing the
5822 given error code. If an invalid error code is passed, the string "Unknown
5823 error" is returned, and <tt/errno/ is set to <tt/EINVAL/. In all other cases,
5824 <tt/errno/ is left untouched.
5825 <tag/Notes/<itemize>
5826 <item>The function is only available as fastcall function, so it may only
5827 be used in presence of a prototype.
5828 <item>While the return type of the function is a <tt/char*/, the returned
5829 string must not be modified by the caller!
5831 <tag/Availability/ISO 9899
5833 <ref id="_stroserror" name="_stroserror">
5839 <sect1>stricmp<label id="stricmp"><p>
5843 <tag/Function/Compare two strings case insensitive.
5844 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5845 <tag/Declaration/<tt/int __fastcall__ stricmp (const char* s1, const char* s2);/
5846 <tag/Description/The <tt/stricmp/ function compares the two strings passed as
5847 parameters without case sensitivity. It returns a value that is less than zero
5848 if <tt/s1/ is less than <tt/s2/, zero if <tt/s1/ is the same as <tt/s2/, and a
5849 value greater than zero if <tt/s1/ is greater than <tt/s2/.
5850 <tag/Notes/<itemize>
5851 <item>The function is only available as fastcall function, so it may only
5852 be used in presence of a prototype.
5853 <item>The function is not available in strict ANSI mode.
5855 <tag/Availability/cc65
5857 <ref id="strcasecmp" name="strcasecmp">,
5858 <ref id="strcmp" name="strcmp">,
5859 <ref id="strcoll" name="strcoll">,
5860 <ref id="strncmp" name="strncmp">,
5861 <ref id="strxfrm" name="strxfrm">
5867 <sect1>strlen<label id="strlen"><p>
5871 <tag/Function/Return the length of a string.
5872 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5873 <tag/Declaration/<tt/size_t __fastcall__ strlen (const char* s);/
5874 <tag/Description/The <tt/strlen/ function computes the number of bytes in the
5875 string to which s points, not including the terminating null byte.
5876 <tag/Notes/<itemize>
5877 <item>The function is only available as fastcall function, so it may only
5878 be used in presence of a prototype.
5879 <item>When compiling with <tt/-Os/ (inline known standard functions), the
5880 function does not work correctly for strings with more than 255 characters.
5882 <tag/Availability/ISO 9899
5884 <ref id="strcpy" name="strcpy">
5890 <sect1>strlower<label id="strlower"><p>
5894 <tag/Function/Make a string lower case.
5895 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5896 <tag/Declaration/<tt/char* __fastcall__ strlower (char* s);/
5897 <tag/Description/The <tt/strlower/ function will apply the <tt/tolower/
5898 function to each character of a string. The function will always return <tt/s/.
5899 <tag/Notes/<itemize>
5900 <item>The function is only available as fastcall function, so it may only
5901 be used in presence of a prototype.
5902 <item>The function prototype is unavailable when compiling in strict ANSI mode.
5903 <item>An alias name for this function is <tt/strlwr/.
5905 <tag/Availability/cc65
5907 <ref id="strupper" name="strupper">,
5908 <ref id="tolower" name="tolower">
5914 <sect1>strlwr<label id="strlwr"><p>
5921 <sect1>strncat<label id="strncat"><p>
5925 <tag/Function/Concatentate two strings.
5926 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5927 <tag/Declaration/<tt/char* __fastcall__ strncat (char* s1, const char* s2, size_t n);/
5928 <tag/Description/The <tt/strncat/ function appends not more than n characters
5929 of the string pointed to by s2 to the end of the string pointed to by s1. The
5930 terminating null character at the end of s1 is overwritten. A terminating null
5931 character is appended to the result, even if not all of s2 is appended to s1.
5932 <tag/Notes/<itemize>
5933 <item>The function is only available as fastcall function, so it may only
5934 be used in presence of a prototype.
5935 <item>If copying takes place between objects that overlap, the behaviour
5938 <tag/Availability/ISO 9899
5940 <ref id="strcpy" name="strcpy">,
5941 <ref id="strncat" name="strncat">,
5942 <ref id="strncpy" name="strncpy">
5948 <sect1>strncmp<label id="strncmp"><p>
5952 <tag/Function/Compare two strings.
5953 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5954 <tag/Declaration/<tt/int __fastcall__ strncmp (const char* s1, const char* s2, size_t count);/
5955 <tag/Description/The <tt/strncmp/ function compares not more than <tt/count/
5956 characters of the two strings passed as parameters. It returns a value that is
5957 less than zero if the first <tt/count/ characters of <tt/s1/ are less than
5958 <tt/s2/, zero if they are identical, and a value greater than zero they are
5960 <tag/Notes/<itemize>
5961 <item>The function is only available as fastcall function, so it may only
5962 be used in presence of a prototype.
5964 <tag/Availability/ISO 9899
5966 <ref id="strcasecmp" name="strcasecmp">,
5967 <ref id="strcmp" name="strcmp">,
5968 <ref id="strcoll" name="strcoll">,
5969 <ref id="stricmp" name="stricmp">,
5970 <ref id="strxfrm" name="strxfrm">
5976 <sect1>strncpy<label id="strncpy"><p>
5980 <tag/Function/Copy part of a string.
5981 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5982 <tag/Declaration/<tt/char* __fastcall__ strncpy (char* s1, const char* s2, size_t n);/
5983 <tag/Description/The <tt/strncpy/ function copies not more than <tt/n/ bytes from
5984 the array pointed to by <tt/s2/ to the array pointed to by <tt/s1/. If the array
5985 pointed to by <tt/s2/ is a string that is shorter than <tt/n/ bytes, null bytes are
5986 appended to the copy in the array pointed to by <tt/s1/, until <tt/n/ bytes are
5987 written. The function always will return <tt/s1/.
5988 <tag/Notes/<itemize>
5989 <item>The function is available only as a fastcall function; so, it may be used
5990 only in the presence of a prototype.
5991 <item>If there is no null byte in the first <tt/n/ bytes of the array pointed
5992 to by <tt/s2/, the result is <em/not/ null-terminated!
5993 <item>If copying takes place between objects that overlap, the behaviour is
5996 <tag/Availability/ISO 9899
5998 <ref id="memcpy" name="memcpy">,
5999 <ref id="strcat" name="strcat">,
6000 <ref id="strcpy" name="strcpy">,
6001 <ref id="strncat" name="strncat">
6006 static char hello[6];
6008 strncpy (hello, "Hello world!\n", sizeof hello - 1)[5] = '\0';
6014 <sect1>strqtok<label id="strqtok"><p>
6018 <tag/Function/Break a string into tokens.
6019 <tag/Header/<tt/<ref id="string.h" name="string.h">/
6020 <tag/Declaration/<tt/char* __fastcall__ strqtok (char* s1, const char* s2);/
6021 <tag/Description/<tt/strqtok()/ will break the string <tt/s1/ into a sequence of
6022 tokens, which are delimited by either quotation marks or characters from the
6023 string <tt/s2/. Tokens inside quotation marks may contain characters from <tt/s2/
6024 (they aren't delimiters there). The first call to <tt/strqtok()/ will return a
6025 pointer to the first token in the string <tt/s1/. The following calls must pass
6026 a <tt/NULL/ pointer as <tt/s1/, in order to get the next token in the string.
6027 Different sets of delimiters may be used for the subsequent calls to <tt/strqtok()/.
6028 <tag/Notes/<itemize>
6029 <item>The function is available only as a fastcall function; so, it may be used
6030 only in the presence of a prototype.
6031 <item><tt/strqtok()/ will modify the string <tt/s1/.
6032 <item>The function will forget where it is in the <tt/s1/ string if it is given
6033 a second <tt/s1/ string before it finishes the first one.
6035 <tag/Availability/cc65
6037 <ref id="strcspn" name="strcspn">,
6038 <!-- <ref id="strpbrk" name="strpbrk">, -->
6039 <ref id="strspn" name="strspn">,
6040 <ref id="strtok" name="strtok">
6046 <sect1>strrchr<label id="strrchr"><p>
6050 <tag/Function/Search for a character in a string.
6051 <tag/Header/<tt/<ref id="string.h" name="string.h">/
6052 <tag/Declaration/<tt/char* __fastcall__ strrchr (const char* s, int c);/
6053 <tag/Description/The <tt/strrchr/ function locates the last occurrence of <tt/c/
6054 (converted to a char) in the string pointed to by <tt/s/. The terminating null
6055 byte is considered to be part of the string. Upon completion, the function
6056 returns a pointer to the byte, or a null pointer if the byte was not found.
6057 <tag/Notes/<itemize>
6058 <item>The function is only available as fastcall function, so it may only
6059 be used in presence of a prototype.
6061 <tag/Availability/ISO 9899
6063 <ref id="strchr" name="strchr">
6069 <sect1>strspn<label id="strspn"><p>
6073 <tag/Function/Compute the length of a substring.
6074 <tag/Header/<tt/<ref id="string.h" name="string.h">/
6075 <tag/Declaration/<tt/size_t __fastcall__ strspn (const char* s, const char* set);/
6076 <tag/Description/The <tt/strspn/ function computes and returns the length of
6077 the substring pointed to by <tt/s/ which does consist only of characters
6078 contained in the string <tt/set/.
6079 <tag/Notes/<itemize>
6080 <item>The function is only available as fastcall function, so it may only
6081 be used in presence of a prototype.
6083 <tag/Availability/ISO 9899
6085 <ref id="strcspn" name="strcspn">,
6086 <ref id="strstr" name="strstr">
6092 <sect1>strstr<label id="strstr"><p>
6096 <tag/Function/Find a substring.
6097 <tag/Header/<tt/<ref id="string.h" name="string.h">/
6098 <tag/Declaration/<tt/char* __fastcall__ strstr (const char* str, const char* substr);/
6099 <tag/Description/<tt/strstr/ searches for the first occurance of the string
6100 <tt/substr/ within <tt/str/. If found, it returns a pointer to the copy,
6101 otherwise it returns <tt/NULL/.
6102 <tag/Notes/<itemize>
6103 <item>The function is only available as fastcall function, so it may only
6104 be used in presence of a prototype.
6106 <tag/Availability/ISO 9899
6108 <ref id="strcspn" name="strcspn">,
6109 <ref id="strspn" name="strspn">
6115 <sect1>strtok<label id="strtok"><p>
6119 <tag/Function/Break a string into tokens.
6120 <tag/Header/<tt/<ref id="string.h" name="string.h">/
6121 <tag/Declaration/<tt/char* __fastcall__ strtok (char* s1, const char* s2);/
6122 <tag/Description/<tt/strtok()/ will break the string <tt/s1/ into a sequence of
6123 tokens, which are delimited by characters from the string <tt/s2/. The first call
6124 to <tt/strtok()/ will return a pointer to the first token in the string <tt/s1/.
6125 The following calls must pass a <tt/NULL/ pointer as <tt/s1/, in order to get
6126 the next token in the string. Different sets of delimiters may be used for the
6127 subsequent calls to <tt/strtok()/.
6128 <tag/Notes/<itemize>
6129 <item>The function is only available as fastcall function, so it may only
6130 be used in presence of a prototype.
6131 <item><tt/strtok()/ will modify the string <tt/s1/.
6132 <item>The function will forget where it is in the <tt/s1/ string if it is given
6133 a second <tt/s1/ string before it finishes the first one.
6135 <tag/Availability/ISO 9899
6137 <ref id="strcspn" name="strcspn">,
6138 <!-- <ref id="strpbrk" name="strpbrk">, -->
6139 <ref id="strqtok" name="strqtok">,
6140 <ref id="strspn" name="strspn">
6146 <sect1>strxfrm<label id="strxfrm"><p>
6150 <tag/Function/Transform a string.
6151 <tag/Header/<tt/<ref id="string.h" name="string.h">/
6152 <tag/Declaration/<tt/size_t __fastcall__ strxfrm (char* s1, const char* s2, size_t n);/
6153 <tag/Description/The <tt/strxfrm/ function transforms the string pointed to by
6154 s2 and places the resulting string into the string pointed to by s1. The
6155 transformation is such that if the <tt/strcmp/ function is applied to two
6156 transformed strings, it returns a value greater than, equal to, or less than
6157 zero, corresponding to the result of the <tt/strcoll/ function applied to the
6158 same two original strings. No more than n characters are placed into the
6159 resulting array pointed to by s1, including the terminating null character.
6160 <tag/Notes/<itemize>
6161 <item><tt/s1/ and <tt/s2/ must not point to the same memory area, otherwise
6162 the behaviour is undefined.
6163 <item>If <tt/n/ is zero, <tt/s1/ may be a NULL pointer.
6164 <item>The function is only available as fastcall function, so it may only
6165 be used in presence of a prototype.
6166 <item>Since cc65 doesn't support different charcter sets, <tt/strxfrm/ will
6167 just copy s2 to s1 using <tt><ref id="strncpy" name="strncpy"></tt>.
6169 <tag/Availability/ISO 9899
6171 <ref id="strcmp" name="strcmp">,
6172 <ref id="strcoll" name="strcoll">,
6173 <ref id="strncpy" name="strncpy">
6179 <sect1>strupper<label id="strupper"><p>
6183 <tag/Function/Make a string upper case.
6184 <tag/Header/<tt/<ref id="string.h" name="string.h">/
6185 <tag/Declaration/<tt/char* __fastcall__ strupper (char* s);/
6186 <tag/Description/The <tt/strupper/ function will apply the <tt/toupper/
6187 function to each character of a string. The function will always return <tt/s/.
6188 <tag/Notes/<itemize>
6189 <item>The function is only available as fastcall function, so it may only
6190 be used in presence of a prototype.
6191 <item>The function prototype is unavailable when compiling in strict ANSI mode.
6192 <item>An alias name for this function is <tt/strupr/.
6194 <tag/Availability/cc65
6196 <ref id="strlower" name="strlower">
6197 <ref id="toupper" name="toupper">
6203 <sect1>strupr<label id="strupr"><p>
6210 <sect1>telldir<label id="telldir"><p>
6214 <tag/Function/Return the current position of a directory stream.
6215 <tag/Header/<tt/<ref id="dirent.h" name="dirent.h">/
6216 <tag/Declaration/<tt/long __fastcall__ telldir (DIR* dir);/
6217 <tag/Description/<tt/telldir/ returns the current position of a directory
6218 stream. The return value may be used in subsequent calls to
6219 <tt/<ref id="seekdir" name="seekdir">/.
6220 <tag/Notes/<itemize>
6221 <item>The function is only available as fastcall function, so it may only
6222 be used in presence of a prototype.
6224 <tag/Availability/POSIX 1003.1
6226 <ref id="seekdir" name="seekdir">,
6227 <ref id="telldir" name="telldir">
6233 <sect1>textcolor<label id="textcolor"><p>
6237 <tag/Function/Set the text color.
6238 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
6239 <tag/Declaration/<tt/unsigned char __fastcall__ textcolor (unsigned char color);/
6240 <tag/Description/The function will set a new text color. It returns the old
6241 (current) text color. Text output using any <tt/conio.h/ function will use
6242 the color set by this function.
6243 <tag/Notes/<itemize>
6244 <item>Text colors are system dependent. The function may have no effect
6245 on systems where the text color cannot be changed.
6246 <item>The function is only available as fastcall function, so it may only
6247 be used in presence of a prototype.
6249 <tag/Availability/cc65
6251 <ref id="bgcolor" name="bgcolor">,
6252 <ref id="bordercolor" name="bordercolor">
6258 <sect1>tgi_arc<label id="tgi_arc"><p>
6262 <tag/Function/Draw an elliptic arc in the current color.
6263 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6264 <tag/Declaration/<tt/void __fastcall__ tgi_arc (int x, int y,
6265 unsigned char rx, unsigned char ry, unsigned sa, unsigned ea);/
6266 <tag/Description/The function draws an elliptic arc with center at x/y and
6267 radii rx/ry using the current drawing color. The arc covers the angle
6268 between sa and ea (startangle and endangle), which must be in the range
6270 <tag/Notes/<itemize>
6271 <item>The function is only available as fastcall function, so it may only
6272 be used in presence of a prototype.
6273 <item>The function behaves unexpectedly or may crash if the angles are out
6276 <tag/Availability/cc65
6278 <ref id="tgi_bar" name="tgi_bar">,
6279 <ref id="tgi_circle" name="tgi_circle">,
6280 <ref id="tgi_ellipse" name="tgi_ellipse">,
6281 <ref id="tgi_pieslice" name="tgi_pieslice">,
6282 <ref id="tgi_setcolor" name="tgi_setcolor">
6284 /* Draw the upper half of an ellipse */
6285 tgi_setcolor(TGI_COLOR_BLUE);
6286 tgi_arc (50, 50, 40, 20, 0, 180);
6292 <sect1>tgi_bar<label id="tgi_bar"><p>
6296 <tag/Function/The function fills a rectangle on the drawpage with the current
6298 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6299 <tag/Declaration/<tt/void __fastcall__ tgi_bar (int x1, int y1, int x2, int y2);/
6300 <tag/Description/The function fills a rectangle on the drawpage with the current
6302 <tag/Notes/<itemize>
6303 <item>The function is only available as fastcall function, so it may only
6304 be used in presence of a prototype.
6306 <tag/Availability/cc65
6307 <tag/See also/Other tgi function
6309 tgi_setcolor(TGI_COLOR_GREEN);
6310 tgi_bar(10, 10, 100, 60);
6316 <sect1>tgi_circle<label id="tgi_circle"><p>
6320 <tag/Function/The function draws a circle in the current color.
6321 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6322 <tag/Declaration/<tt/void __fastcall__ tgi_circle (int x, int y, unsigned char radius);/
6323 <tag/Description/The function draws a circle in the current color.
6324 <tag/Notes/<itemize>
6325 <item>The function is only available as fastcall function, so it may only
6326 be used in presence of a prototype.
6328 <tag/Availability/cc65
6330 <ref id="tgi_arc" name="tgi_arc">,
6331 <ref id="tgi_bar" name="tgi_bar">,
6332 <ref id="tgi_ellipse" name="tgi_ellipse">,
6333 <ref id="tgi_pieslice" name="tgi_pieslice">,
6334 <ref id="tgi_setcolor" name="tgi_setcolor">
6336 tgi_setcolor(TGI_COLOR_BLACK);
6337 tgi_circle(50, 40, 40);
6343 <sect1>tgi_clear<label id="tgi_clear"><p>
6347 <tag/Function/Clear the drawpage
6348 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6349 <tag/Declaration/<tt/void tgi_clear (void);/
6350 <tag/Description/Clear the drawpage
6351 <tag/Availability/cc65
6352 <tag/See also/Other tgi functions
6358 <sect1>tgi_done<label id="tgi_done"><p>
6362 <tag/Function/End graphics mode, switch back to text mode.
6363 Will NOT uninstall or unload the driver!
6364 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6365 <tag/Declaration/<tt/void tgi_done (void);/
6366 <tag/Description/End graphics mode, switch back to text mode.
6367 Will NOT uninstall or unload the driver!
6368 <tag/Availability/cc65
6369 <tag/See also/Other tgi functions
6375 <sect1>tgi_ellipse<label id="tgi_ellipse"><p>
6379 <tag/Function/The function draws an ellipse in the current color.
6380 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6381 <tag/Declaration/<tt/void __fastcall__ tgi_ellipse (int x, int y, unsigned char rx, unsigned char ry);/
6382 <tag/Description/The function draws an ellipse at position x/y with radii
6383 rx and ry, using the current drawing color.
6384 <tag/Notes/<itemize>
6385 <item>The function is only available as fastcall function, so it may only
6386 be used in presence of a prototype.
6388 <tag/Availability/cc65
6390 <ref id="tgi_arc" name="tgi_arc">,
6391 <ref id="tgi_bar" name="tgi_bar">,
6392 <ref id="tgi_circle" name="tgi_circle">,
6393 <ref id="tgi_pieslice" name="tgi_pieslice">,
6394 <ref id="tgi_setcolor" name="tgi_setcolor">
6396 tgi_setcolor(TGI_COLOR_RED);
6397 tgi_ellipse (50, 40, 40, 20);
6403 <sect1>tgi_free_vectorfont<label id="tgi_free_vectorfont"><p>
6407 <tag/Function/Free a vector font that was previously loaded into memory.
6408 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6409 <tag/Declaration/<tt/void __fastcall__ tgi_free_vectorfont (const tgi_vectorfont* font);/
6410 <tag/Description/Free a vector font that was previously loaded into memory.
6411 <tag/Notes/<itemize>
6412 <item>The function is only available as fastcall function, so it may only
6413 be used in presence of a prototype.
6415 <tag/Availability/cc65
6417 <ref id="tgi_load_vectorfont" name="tgi_load_vectorfont">,
6418 <ref id="tgi_install_vectorfont" name="tgi_install_vectorfont">
6424 <sect1>tgi_getaspectratio<label id="tgi_getaspectratio"><p>
6426 <quote> <descrip> <tag/Function/Return the pixel aspect ratio.
6427 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6428 <tag/Declaration/<tt/unsigned tgi_getaspectratio (void);/
6429 <tag/Description/The function returns the pixel aspect ratio for the current
6430 driver and display as an 8.8 fixed point value. It may be used to correct
6431 geometric shapes so they look correct on the display. As an example, a circle
6432 with a radius of 100 pixels may look elliptic on some driver/display
6433 combinations if the aspect ratio is not 1.00.
6434 <tag/Notes/<itemize>
6435 <item>The aspect ratio is encoded in the TGI driver which assumes a "standard"
6436 monitor for the given platform. The aspect ratio may be wrong if another
6438 <item>No TGI function will use the aspect ratio. It is up to the programmer to
6440 <item>The <ref id="tgi_setaspectratio" name="tgi_setaspectratio"> function can
6441 be used to change the aspect ratio for a loaded driver. The value is not reset
6442 by <ref id="tgi_init" name="tgi_init">, so if a driver is linked statically to
6443 an application, switching into and out of graphics mode will not restore the
6444 original aspect ratio.
6446 <tag/Availability/cc65
6448 <ref id="tgi_setaspectratio" name="tgi_setaspectratio">
6454 <sect1>tgi_getcolor<label id="tgi_getcolor"><p>
6458 <tag/Function/Return the current drawing color.
6459 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6460 <tag/Declaration/<tt/unsigned char tgi_getcolor (void);/
6461 <tag/Description/The actual color is an index to a palette. During tgi_init
6462 you will get a default palette. The number of colors depend on the platform.
6463 All platforms recognize at least TGI_COLOR_BLACK and TGI_COLOR_WHITE. But some
6464 platforms have many more predefined colors. If you paint using TGI_COLOR_GREEN
6465 and then you change the green of the palette to blue using tgi_setpalette then
6466 after this painting in TGI_COLOR_GREEN will actually be blue.
6467 <tag/Availability/cc65
6468 <tag/See also/Other tgi functions
6470 color = tgi_getcolor();
6476 <sect1>tgi_getcolorcount<label id="tgi_getcolorcount"><p>
6480 <tag/Function/Get the number of available colors.
6481 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6482 <tag/Declaration/<tt/unsigned char tgi_getcolorcount (void);/
6483 <tag/Description/Tgi platforms use indexed color palettes. This function
6484 returns the number of entries we can use in the palette.
6485 <tag/Availability/cc65
6486 <tag/See also/Other tgi functions
6488 if (tgi_getcolorcount() == 2) {
6489 printf("Only monochrome graphics is supported\n");
6496 <sect1>tgi_getdefpalette<label id="tgi_getdefpalette"><p>
6500 <tag/Function/Get the palette installed by default.
6501 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6502 <tag/Declaration/<tt/const unsigned char* tgi_getdefpalette (void);/
6503 <tag/Description/The tgi driver has a default palette that is active at startup.
6504 The named colors TGI_COLOR_BLACK, TGI_COLOR_WHITE, TGI_COLOR_RED... need this
6505 palette to work correctly.
6506 <tag/Availability/cc65
6507 <tag/See also/Other tgi functions
6513 <sect1>tgi_geterror<label id="tgi_geterror"><p>
6517 <tag/Function/Return the error code for the last operation.
6518 This will also clear the error.
6519 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6520 <tag/Declaration/<tt/unsigned char tgi_geterror (void);/
6521 <tag/Description/Return the error code for the last operation.
6522 This will also clear the error.
6523 <tag/Availability/cc65
6524 <tag/See also/Other tgi functions
6530 <sect1>tgi_geterrormsg<label id="tgi_geterrormsg"><p>
6534 <tag/Function/Get an error message describing the error.
6535 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6536 <tag/Declaration/<tt/const char* __fastcall__ tgi_geterrormsg (unsigned char code);/
6537 <tag/Description/Get an error message describing the error.
6538 <tag/Notes/<itemize>
6539 <item>The function is only available as fastcall function, so it may only
6540 be used in presence of a prototype.
6542 <tag/Availability/cc65
6543 <tag/See also/Other tgi functions
6549 <sect1>tgi_getmaxcolor<label id="tgi_getmaxcolor"><p>
6553 <tag/Function/Get the highest index of the palette.
6554 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6555 <tag/Declaration/<tt/unsigned char tgi_getmaxcolor (void);/
6556 <tag/Description/Get the highest index of the palette.
6557 <tag/Availability/cc65
6558 <tag/See also/Other tgi functions
6564 <sect1>tgi_getmaxx<label id="tgi_getmaxx"><p>
6568 <tag/Function/Get the maximum x coordinate that can be used on this screen.
6569 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6570 <tag/Declaration/<tt/unsigned tgi_getmaxx (void);/
6571 <tag/Description/Get the maximum x coordinate that can be used on this screen.
6572 <tag/Availability/cc65
6573 <tag/See also/Other tgi functions
6579 <sect1>tgi_getmaxy<label id="tgi_getmaxy"><p>
6583 <tag/Function/Get the maximum y coordinate that can be used on this screen.
6584 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6585 <tag/Declaration/<tt/unsigned tgi_getmaxy (void);/
6586 <tag/Description/Get the maximum y coordinate that can be used on this screen.
6587 <tag/Availability/cc65
6588 <tag/See also/Other tgi functions
6594 <sect1>tgi_getpagecount<label id="tgi_getpagecount"><p>
6598 <tag/Function/Return the number of screen pages available.
6599 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6600 <tag/Declaration/<tt/unsigned tgi_getpagecount (void);/
6601 <tag/Description/Return the number of screen pages available.
6602 <tag/Availability/cc65
6604 <ref id="tgi_setdrawpage" name="tgi_setdrawpage">,
6605 <ref id="tgi_setviewpage" name="tgi_setviewpage">
6611 <sect1>tgi_getpalette<label id="tgi_getpalette"><p>
6615 <tag/Function/Get the palette installed.
6616 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6617 <tag/Declaration/<tt/const unsigned char* tgi_getpalette (void);/
6618 <tag/Description/Get the palette installed.
6619 <tag/Availability/cc65
6620 <tag/See also/Other tgi functions
6626 <sect1>tgi_getpixel<label id="tgi_getpixel"><p>
6630 <tag/Function/Get the color of a pixel from the viewpage.
6631 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6632 <tag/Declaration/<tt/unsigned char __fastcall__ tgi_getpixel (int x, int y);/
6633 <tag/Description/Get the color of a pixel from the viewpage.
6634 <tag/Notes/<itemize>
6635 <item>The function is only available as fastcall function, so it may only
6636 be used in presence of a prototype.
6638 <tag/Availability/cc65
6639 <tag/See also/Other tgi functions.
6645 <sect1>tgi_getxres<label id="tgi_getxres"><p>
6649 <tag/Function/Get number of horisontal pixels on the screen.
6650 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6651 <tag/Declaration/<tt/unsigned tgi_getxres (void);/
6652 <tag/Description/Get number of horisontal pixels on the screen.
6653 This is same as tgi_maxx()+1.
6654 <tag/Availability/cc65
6655 <tag/See also/Other tgi functions.
6661 <sect1>tgi_getyres<label id="tgi_getyres"><p>
6665 <tag/Function/Get number of vertical pixels on the screen.
6666 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6667 <tag/Declaration/<tt/unsigned tgi_getyres (void);/
6668 <tag/Description/Get number of vertical pixels on the screen.
6669 This is same as tgi_maxy()+1.
6670 <tag/Availability/cc65
6671 <tag/See also/Other tgi functions.
6677 <sect1>tgi_gotoxy<label id="tgi_gotoxy"><p>
6681 <tag/Function/Set graphics cursor at x, y.
6682 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6683 <tag/Declaration/<tt/void __fastcall__ tgi_gotoxy (int x, int y);/
6684 <tag/Description/Set graphics cursor at x, y.
6685 <tag/Notes/<itemize>
6686 <item>The function is only available as fastcall function, so it may only
6687 be used in presence of a prototype.
6689 <tag/Availability/cc65
6690 <tag/See also/Other tgi functions.
6696 <sect1>tgi_init<label id="tgi_init"><p>
6700 <tag/Function/Initialize the already loaded graphics driver.
6701 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6702 <tag/Declaration/<tt/void tgi_init (void);/
6703 <tag/Description/The tgi_init function will set the default palette to the
6705 <tag/Notes/<itemize>
6706 <item><tt/tgi_init/ will not clear the screen. This allows switching between
6707 text and graphics mode on platforms that have separate memory areas for the
6708 screens. If you want the screen cleared, call <tt/<ref id="tgi_clear"
6709 name="tgi_clear">/ after <tt/tgi_init/.
6711 <tag/Availability/cc65
6712 <tag/See also/Other tgi functions.
6714 tgi_install(tgi_static_stddrv); //Include the driver statically instead of loading it.
6715 tgi_init(); //Set up the default palette and clear the screen.
6721 <sect1>tgi_install<label id="tgi_install"><p>
6725 <tag/Function/Install an already loaded driver and return an error code.
6726 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6727 <tag/Declaration/<tt/unsigned char __fastcall__ tgi_install (void* driver);/
6728 <tag/Description/The function installs a driver that was already loaded into
6729 memory (or linked statically to the program). It returns an error code
6730 (<tt/TGI_ERR_OK/ in case of success).
6731 <tag/Notes/<itemize>
6732 <item>The function is only available as fastcall function, so it may only be
6733 used in presence of a prototype.
6735 <tag/Availability/cc65
6737 <ref id="tgi_load_driver" name="tgi_load_driver">,
6738 <ref id="tgi_uninstall" name="tgi_uninstall">,
6739 <ref id="tgi_unload" name="tgi_unload">
6741 tgi_install(tgi_static_stddrv); //Include the driver statically instead of loading it.
6742 tgi_init(); //Set up the default palette and clear the screen.
6748 <sect1>tgi_install_vectorfont<label id="tgi_install_vectorfont"><p>
6752 <tag/Function/Install an already loaded driver and return an error code.
6753 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6754 <tag/Declaration/<tt/void __fastcall__ tgi_install_vectorfont (const tgi_vectorfont* font);/
6756 Install a vector font for use. More than one vector font can be loaded,
6757 but only one can be active. This function is used to tell which one. Call
6758 with a NULL pointer to uninstall the currently installed font.
6759 <tag/Notes/<itemize>
6760 <item>The function is only available as fastcall function, so it may only be
6761 used in presence of a prototype.
6763 <tag/Availability/cc65
6765 <ref id="tgi_load_vectorfont" name="tgi_load_vectorfont">,
6766 <ref id="tgi_free_vectorfont" name="tgi_free_vectorfont">
6772 <sect1>tgi_ioctl<label id="tgi_ioctl"><p>
6776 <tag/Function/Platform dependent code extensions.
6777 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6778 <tag/Declaration/<tt/unsigned __fastcall__ tgi_ioctl (unsigned char code, void* data);/
6779 <tag/Description/Some platforms have extra display hardware that is not
6780 supported by standard tgi functions. You can extend the driver to support
6781 this extra hardware using tgi_ioctl functions.
6782 <tag/Notes/<itemize>
6783 <item>The function is only available as fastcall function, so it may only
6784 be used in presence of a prototype.
6785 <item>These functions are not easily portable to other cc65 platforms.
6787 <tag/Availability/cc65
6788 <tag/See also/Other tgi functions.
6790 #define tgi_sprite(spr) tgi_ioctl(0, (void*)(spr))
6791 #define tgi_flip() tgi_ioctl(1, (void*)0)
6792 #define tgi_setbgcolor(bgcol) tgi_ioctl(2, (void*)(bgcol))
6793 #define tgi_setframerate(rate) tgi_ioctl(3, (void*)(rate))
6794 #define tgi_busy() tgi_ioctl(4, (void*)0)
6795 #define tgi_updatedisplay() tgi_ioctl(4, (void*)1)
6797 tgi_sprite(&background);
6798 tgi_setcolor(TGI_COLOR_BLUE);
6799 tgi_outttextxy(20,40,"Hello World");
6800 tgi_updatedisplay();
6807 <sect1>tgi_line<label id="tgi_line"><p>
6811 <tag/Function/Draw a line in the current drawing color.
6812 The graphics cursor will be set to x2/y2 by this call.
6813 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6814 <tag/Declaration/<tt/void __fastcall__ tgi_line (int x1, int y1, int x2, int y2);/
6815 <tag/Description/Draw a line in the current drawing color.
6816 The graphics cursor will be set to x2/y2 by this call.
6817 <tag/Notes/<itemize>
6818 <item>The function is only available as fastcall function, so it may only
6819 be used in presence of a prototype.
6821 <tag/Availability/cc65
6822 <tag/See also/Other tgi functions.
6828 <sect1>tgi_lineto<label id="tgi_lineto"><p>
6832 <tag/Function/Draw a line in the current drawing color from the graphics
6833 cursor to the new end point. The graphics cursor will be updated to x2/y2.
6834 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6835 <tag/Declaration/<tt/void __fastcall__ tgi_lineto (int x2, int y2);/
6836 <tag/Description/Draw a line in the current drawing color from the graphics
6837 cursor to the new end point. The graphics cursor will be updated to x2/y2.
6838 <tag/Notes/<itemize>
6839 <item>The function is only available as fastcall function, so it may only
6840 be used in presence of a prototype.
6842 <tag/Availability/cc65
6843 <tag/See also/Other tgi functions.
6849 <sect1>tgi_load_driver<label id="tgi_load_driver"><p>
6853 <tag/Function/Load and install the given driver.
6854 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6855 <tag/Declaration/<tt/void __fastcall__ tgi_load_driver (const char *name);/
6856 <tag/Description/Load and install the driver by name.
6857 Will just load the driver and check if loading was successful.
6858 Will not switch to graphics mode.
6859 <tag/Notes/<itemize>
6860 <item>The function is only available as fastcall function, so it may only
6861 be used in presence of a prototype.
6863 <tag/Availability/cc65
6864 <tag/See also/Other tgi functions.
6870 <sect1>tgi_load_vectorfont<label id="tgi_load_vectorfont"><p>
6874 <tag/Function/Load the given vector font.
6875 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6876 <tag/Declaration/<tt/const tgi_vectorfont* __fastcall__ tgi_load_vectorfont (const char* name);/
6878 Load a vector font into memory and return it. In case of errors, NULL is
6879 returned and an error is set, which can be retrieved using tgi_geterror.
6880 To use the font, it has to be installed using tgi_install_vectorfont.
6881 <tag/Notes/<itemize>
6882 <item>The function is only available as fastcall function, so it may only
6883 be used in presence of a prototype.
6885 <tag/Availability/cc65
6887 <ref id="tgi_install_vectorfont" name="tgi_install_vectorfont">,
6888 <ref id="tgi_free_vectorfont" name="tgi_free_vectorfont">
6894 <sect1>tgi_outtext<label id="tgi_outtext"><p>
6898 <tag/Function/Output text at the current graphics cursor position.
6899 The graphics cursor is moved to the end of the text.
6900 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6901 <tag/Declaration/<tt/void __fastcall__ tgi_outtext (const char* s);/
6902 <tag/Description/Output text at the current graphics cursor position.
6903 The graphics cursor is moved to the end of the text.
6904 <tag/Notes/<itemize>
6905 <item>The function is only available as fastcall function, so it may only
6906 be used in presence of a prototype.
6908 <tag/Availability/cc65
6909 <tag/See also/Other tgi functions.
6915 <sect1>tgi_outtextxy<label id="tgi_outtextxy"><p>
6919 <tag/Function/Output text at the given cursor position.
6920 The graphics cursor is moved to the end of the text.
6921 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6922 <tag/Declaration/<tt/void __fastcall__ tgi_outtextxy (int x, int y, const char* s);/
6923 <tag/Description/Output text at the given cursor position.
6924 The graphics cursor is moved to the end of the text.
6925 <tag/Notes/<itemize>
6926 <item>The function is only available as fastcall function, so it may only
6927 be used in presence of a prototype.
6929 <tag/Availability/cc65
6930 <tag/See also/Other tgi functions.
6936 <sect1>tgi_pieslice<label id="tgi_pieslice"><p>
6940 <tag/Function/Draw an elliptic pie slice in the current color.
6941 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6942 <tag/Declaration/<tt/void __fastcall__ tgi_pie slice (int x, int y,
6943 unsigned char rx, unsigned char ry, unsigned sa, unsigned ea);/
6944 <tag/Description/The function draws an elliptic pie slice with center at x/y
6945 and radii rx/ry using the current drawing color. The pie slice covers the angle
6946 between sa and ea (startangle and endangle), which must be in the range
6948 <tag/Notes/<itemize>
6949 <item>The function is only available as fastcall function, so it may only
6950 be used in presence of a prototype.
6951 <item>The function behaves unexpectedly or may crash if the angles are out
6954 <tag/Availability/cc65
6956 <ref id="tgi_bar" name="tgi_arc">,
6957 <ref id="tgi_bar" name="tgi_bar">,
6958 <ref id="tgi_circle" name="tgi_circle">,
6959 <ref id="tgi_ellipse" name="tgi_ellipse">,
6960 <ref id="tgi_setcolor" name="tgi_setcolor">
6962 /* Draw the closed upper half of an ellipse */
6963 tgi_setcolor(TGI_COLOR_BLUE);
6964 tgi_pieslice (50, 50, 40, 20, 0, 180);
6970 <sect1>tgi_setaspectratio<label id="tgi_setaspectratio"><p>
6972 <quote> <descrip> <tag/Function/Set the pixel aspect ratio.
6973 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6974 <tag/Declaration/<tt/void __fastcall__ tgi_setaspectratio (unsigned ratio);/
6975 <tag/Description/The function sets the pixel aspect ratio for the current
6976 driver and display. The argument is an 8.8 fixed point value. The aspect ratio
6977 may be used to correct geometric shapes so they look correct on a given
6978 display. As an example, a circle with a radius of 100 pixels may look elliptic
6979 on some driver/display combinations if the aspect ratio is not 1.00.
6980 <tag/Notes/<itemize>
6981 <item>The aspect ratio is encoded in the TGI driver which assumes a "standard"
6982 monitor for the given platform. The aspect ratio may be wrong if another
6984 <item>No TGI function will use the aspect ratio. It is up to the programmer to
6986 <item>The <tt/tgi_setaspectratio/ function can be used to change the aspect
6987 ratio for a loaded driver. The value is not reset by <ref id="tgi_init"
6988 name="tgi_init">, so if a driver is linked statically to an application,
6989 switching into and out of graphics mode will not restore the original aspect
6991 <item>The function is available only as a fastcall function; so, it may be used
6992 only in the presence of a prototype.
6994 <tag/Availability/cc65
6996 <ref id="tgi_getaspectratio" name="tgi_getaspectratio">
7002 <sect1>tgi_setcolor<label id="tgi_setcolor"><p>
7006 <tag/Function/Set color to be used in future draw operations.
7007 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
7008 <tag/Declaration/<tt/void __fastcall__ tgi_setcolor (unsigned char color);/
7009 <tag/Description/Set color to be used in future draw operations.
7010 <tag/Notes/<itemize>
7011 <item>The function is only available as fastcall function, so it may only
7012 be used in presence of a prototype.
7014 <tag/Availability/cc65
7015 <tag/See also/Other tgi functions.
7017 tgi_setcolor(TGI_COLOR_BLACK);
7019 tgi_setcolor(TGI_COLOR_WHITE);
7020 tgi_bar(10,10,20,20);
7025 <sect1>tgi_setdrawpage<label id="tgi_setdrawpage"><p>
7029 <tag/Function/Set the page for drawing.
7030 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
7031 <tag/Declaration/<tt/void __fastcall__ tgi_setdrawpage (unsigned char page);/
7032 <tag/Description/If the drawpage and the viewpage are the same then all drawing
7033 is seen immediately as it is drawn. For double buffered games you can set the
7034 drawpage to a different page than the viewpage. This lets you draw the next
7035 screen in the background and when the screen is ready you display it.
7036 <tag/Notes/<itemize>
7037 <item>The function is only available as fastcall function, so it may only
7038 be used in presence of a prototype.
7040 <tag/Availability/cc65
7041 <tag/See also/Other tgi functions.
7044 tgi_outtextxy(10, 10, "Hello World");
7045 tgi_setviewpage(1); // Show page 1
7047 tgi_outtextxy(10, 10, "Creating next frame");
7049 tgi_setviewpage(0); // Show page 0
7054 <sect1>tgi_setpalette<label id="tgi_setpalette"><p>
7058 <tag/Function/Set the palette (not available with all drivers/hardware).
7059 Palette is a pointer to as many entries as there are colors.
7060 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
7061 <tag/Declaration/<tt/void __fastcall__ tgi_setpalette (const unsigned char* palette);/
7062 <tag/Description/Set the palette (not available with all drivers/hardware).
7063 Palette is a pointer to as many entries as there are colors.
7064 <tag/Notes/<itemize>
7065 <item>The function is only available as fastcall function, so it may only
7066 be used in presence of a prototype.
7068 <tag/Availability/cc65
7069 <tag/See also/Other tgi functions.
7074 <sect1>tgi_setpixel<label id="tgi_setpixel"><p>
7078 <tag/Function/Plot a pixel on the drawpage with the current color.
7079 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
7080 <tag/Declaration/<tt/void __fastcall__ tgi_setpixel (int x, int y);/
7081 <tag/Description/Plot a pixel on the drawpage with the current color.
7082 <tag/Notes/<itemize>
7083 <item>The function is only available as fastcall function, so it may only
7084 be used in presence of a prototype.
7086 <tag/Availability/cc65
7087 <tag/See also/Other tgi functions.
7092 <sect1>tgi_setviewpage<label id="tgi_setviewpage"><p>
7096 <tag/Function/Set page to be visible on screen.
7097 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
7098 <tag/Declaration/<tt/void __fastcall__ tgi_setviewpage (unsigned char page);/
7099 <tag/Description/If the drawpage and the viewpage are the same then all drawing
7100 is seen immediately as it is drawn. For double buffered games you can set the
7101 drawpage to a different page than the viewpage. This lets you draw the next
7102 screen in the background and when the screen is ready you display it.
7103 <tag/Notes/<itemize>
7104 <item>The function is only available as fastcall function, so it may only
7105 be used in presence of a prototype.
7107 <tag/Availability/cc65
7108 <tag/See also/Other tgi functions.
7111 tgi_outtextxy(10, 10, "Hello World");
7112 tgi_setviewpage(1); // Show page 1
7114 tgi_outtextxy(10, 10, "Creating next frame");
7116 tgi_setviewpage(0); // Show page 0
7121 <sect1>tgi_gettextheight<label id="tgi_gettextheight"><p>
7125 <tag/Function/Calculate the height of the text in pixels according to
7126 the current text style.
7127 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
7128 <tag/Declaration/<tt/unsigned __fastcall__ tgi_gettextheight (const char* s);/
7129 <tag/Description/Calculate the height of the text in pixels according to
7130 the current text style.
7131 <tag/Notes/<itemize>
7132 <item>The function is only available as fastcall function, so it may only
7133 be used in presence of a prototype.
7135 <tag/Availability/cc65
7136 <tag/See also/Other tgi functions.
7141 <sect1>tgi_settextscale<label id="tgi_settextscale"><p>
7145 <tag/Function/Set the scaling for text output.
7146 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
7147 <tag/Declaration/<tt/void __fastcall__ tgi_settextscale (unsigned width, unsigned height);/
7149 Set the scaling for text output. The scaling factors for width and height
7150 are 8.8 fixed point values. This means that $100 = 1 $200 = 2 etc.
7151 <tag/Notes/<itemize>
7152 <item>The function is only available as fastcall function, so it may only
7153 be used in presence of a prototype.
7155 <tag/Availability/cc65
7157 <ref id="tgi_settextstyle" name="tgi_settextstyle">
7162 <sect1>tgi_settextstyle<label id="tgi_settextstyle"><p>
7166 <tag/Function/Set the style for text output.
7167 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
7168 <tag/Declaration/<tt/void __fastcall__ tgi_settextstyle (unsigned char magx, unsigned char magy, unsigned char dir, unsigned char font);/
7169 <tag/Description/Set the style for text output.
7170 <tag/Notes/<itemize>
7171 <item>The function is only available as fastcall function, so it may only
7172 be used in presence of a prototype.
7174 <tag/Availability/cc65
7176 <ref id="tgi_settextscale" name="tgi_settextscale">
7181 <sect1>tgi_gettextwidth<label id="tgi_gettextwidth"><p>
7185 <tag/Function/Calculate the width of the text in pixels according to the current text style.
7186 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
7187 <tag/Declaration/<tt/unsigned __fastcall__ tgi_gettextwidth (const char* s);/
7188 <tag/Description/Calculate the width of the text in pixels according to the current text style.
7189 <tag/Notes/<itemize>
7190 <item>The function is only available as fastcall function, so it may only
7191 be used in presence of a prototype.
7193 <tag/Availability/cc65
7194 <tag/See also/Other tgi functions.
7199 <sect1>tgi_uninstall<label id="tgi_uninstall"><p>
7203 <tag/Function/Uninstall the currently loaded driver but do not unload it.
7204 Will call tgi_done if necessary.
7205 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
7206 <tag/Declaration/<tt/void tgi_uninstall (void);/
7207 <tag/Description/Uninstall the currently loaded driver but do not unload it.
7208 Will call tgi_done if necessary.
7209 <tag/Availability/cc65
7210 <tag/See also/Other tgi functions.
7215 <sect1>tgi_unload<label id="tgi_unload"><p>
7219 <tag/Function/Uninstall, then unload the currently loaded driver.
7220 Will call tgi_done if necessary.
7221 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
7222 <tag/Declaration/<tt/void tgi_unload (void);/
7223 <tag/Description/Uninstall, then unload the currently loaded driver.
7224 Will call tgi_done if necessary.
7225 <tag/Availability/cc65
7226 <tag/See also/Other tgi functions.
7231 <sect1>time<label id="time"><p>
7235 <tag/Function/Get the time.
7236 <tag/Header/<tt/<ref id="time.h" name="time.h">/
7237 <tag/Declaration/<tt/time_t __fastcall__ time (time_t* t);/
7238 <tag/Description/The function returns the time since the 1970-01-01 00:00:00
7239 measured in seconds. If the pointer <tt/t/ is not <tt/NULL/, the function
7240 result will also be stored there. If no time is available, <tt/(time_t)-1/ is
7241 returned and <tt/errno/ is set to <tt/ENOSYS/.
7242 <tag/Notes/<itemize>
7243 <item>The function is only available as fastcall function, so it may
7244 only be used in presence of a prototype.
7245 <item>Many platforms supported by cc65 do not have a realtime clock, so the
7246 returned value may not be valid.
7248 <tag/Availability/ISO 9899
7250 <ref id="clock" name="clock">
7256 <sect1>toggle_videomode<label id="toggle_videomode"><p>
7260 <tag/Function/Toggle between 40 and 80 column mode.
7261 <tag/Header/<tt/<ref id="c128.h" name="c128.h">/
7262 <tag/Declaration/<tt/void toggle_videomode (void);/
7263 <tag/Description/Toggle between 40 and 80 column mode. The settings for the
7264 old mode (cursor position, color and so on) are saved and restored together
7266 <tag/Notes/<itemize>
7267 <item>The function is specific to the C128.
7268 <item>This function is deprecated. Please use <ref id="videomode"
7269 name="videomode"> instead!
7271 <tag/Availability/C128
7273 <ref id="fast" name="fast">,
7274 <ref id="slow" name="slow">,
7275 <ref id="videomode" name="videomode">
7281 <sect1>tolower<label id="tolower"><p>
7285 <tag/Function/Convert a character into its lower case representation.
7286 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
7287 <tag/Declaration/<tt/int __fastcall__ tolower (int c);/
7288 <tag/Description/The function returns the given character converted to lower
7289 case. If the given character is not a letter, it is returned unchanged.
7290 <tag/Notes/<itemize>
7291 <item>The function is only available as fastcall function, so it may
7292 only be used in presence of a prototype.
7294 <tag/Availability/ISO 9899
7296 <ref id="islower" name="islower">,
7297 <ref id="isupper" name="isupper">,
7298 <ref id="toupper" name="toupper">
7304 <sect1>toupper<label id="toupper"><p>
7308 <tag/Function/Convert a character into its upper case representation.
7309 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
7310 <tag/Declaration/<tt/int __fastcall__ toupper (int c);/
7311 <tag/Description/The function returns the given character converted to upper
7312 case. If the given character is not a letter, it is returned unchanged.
7313 <tag/Notes/<itemize>
7314 <item>The function is only available as fastcall function, so it may
7315 only be used in presence of a prototype.
7317 <tag/Availability/ISO 9899
7319 <ref id="islower" name="islower">,
7320 <ref id="isupper" name="isupper">,
7321 <ref id="tolower" name="tolower">
7327 <sect1>ultoa<label id="ultoa"><p>
7331 <tag/Function/Convert an unsigned long integer into a string.
7332 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
7333 <tag/Declaration/<tt/char* __fastcall__ ultoa (unsigned long val, char* buf, int radix);/
7334 <tag/Description/<tt/itoa/ converts the unsigned long integer <tt/val/ into a
7335 string using <tt/radix/ as the base.
7336 <tag/Notes/<itemize>
7337 <item>There are no provisions to prevent a buffer overflow.
7338 <item>The function is non standard, so it is not available in strict ANSI mode.
7339 You should probably use <tt/sprintf/ instead.
7340 <item>The function is only available as fastcall function, so it may only be
7341 used in presence of a prototype.
7343 <tag/Availability/cc65
7345 <ref id="atoi" name="atoi">,
7346 <ref id="atol" name="atol">,
7347 <ref id="itoa" name="itoa">,
7348 <ref id="ltoa" name="ltoa">,
7349 <ref id="utoa" name="utoa">
7355 <sect1>unlink<label id="unlink"><p>
7359 <tag/Function/Delete a file.
7360 <tag/Header/<tt/<ref id="unistd.h" name="unistd.h">/
7361 <tag/Declaration/<tt/int __fastcall__ unlink (const char* name);/
7362 <tag/Description/<tt/unlink/ deletes the file with the given name. On success,
7363 zero is returned. On error, -1 is returned and <tt/errno/ is set to an error
7364 code describing the reason for the failure.
7365 <tag/Notes/<itemize>
7366 <item>The use of this function is discouraged. Please use <tt/<ref id="remove"
7367 name="remove">/ instead, which is a native ANSI C function and does the same.
7368 <item>This function is not available on all cc65 targets (depends on the
7369 availability of file I/O).
7370 <item>The function is only available as fastcall function, so it may only
7371 be used in presence of a prototype.
7372 <item>Instead of <tt/unlink/, <tt/<ref id="remove" name="remove">/ should be
7373 used, which has the same semantics, but is more portable, because it conforms
7374 to the ISO C standard.
7376 <tag/Availability/POSIX 1003.1
7378 <ref id="remove" name="remove">
7381 #include <stdio.h>
7382 #include <unistd.h>
7384 #define FILENAME "helloworld"
7386 if (unlink (FILENAME) == 0) {
7387 printf ("We deleted %s successfully\n", FILENAME);
7389 printf ("There was a problem deleting %s\n", FILENAME);
7396 <sect1>utoa<label id="utoa"><p>
7400 <tag/Function/Convert an unsigned integer into a string.
7401 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
7402 <tag/Declaration/<tt/char* __fastcall__ utoa (unsigned val, char* buf, int radix);/
7403 <tag/Description/<tt/itoa/ converts the unsigned integer <tt/val/ into a string
7404 using <tt/radix/ as the base.
7405 <tag/Notes/<itemize>
7406 <item>There are no provisions to prevent a buffer overflow.
7407 <item>The function is non standard, so it is not available in strict ANSI mode.
7408 You should probably use <tt/sprintf/ instead.
7409 <item>The function is only available as fastcall function, so it may only be
7410 used in presence of a prototype.
7412 <tag/Availability/cc65
7414 <ref id="atoi" name="atoi">,
7415 <ref id="atol" name="atol">,
7416 <ref id="itoa" name="itoa">,
7417 <ref id="ltoa" name="ltoa">,
7418 <ref id="ultoa" name="ultoa">
7424 <sect1>vcprintf<label id="vcprintf"><p>
7428 <tag/Function/Formatted output to the console.
7429 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
7430 <tag/Declaration/<tt/int __fastcall__ vcprintf (const char* format, va_list ap);/
7431 <tag/Description/The arguments specified as a <tt/va_list/ are converted to
7432 text where necessary and formatted according to the format string given. The
7433 resulting string is output to the console. <tt/vcprintf/ supports the same
7434 format specifiers as <tt/vprintf/. <!-- <tt/<ref id="vprintf" name="vprintf">/. -->
7435 <tag/Notes/<itemize>
7436 <item>Like all other <tt/conio/ output functions, <tt/vcprintf/ distinguishes
7437 between <tt/\r/ and <tt/\n/.
7438 <item>The function is only available as fastcall function, so it may only be
7439 used in presence of a prototype.
7441 <tag/Availability/cc65
7443 <ref id="cprintf" name="cprintf">,
7444 <ref id="cputc" name="cputc">,
7445 <ref id="cputcxy" name="cputcxy">,
7446 <ref id="cputs" name="cputs">,
7447 <ref id="cputsxy" name="cputsxy">
7453 <sect1>videomode<label id="videomode"><p>
7457 <tag/Function/Switch to either 40 or 80 column mode.
7458 <tag/Header/<tt/<ref id="apple2enh.h" name="apple2enh.h">,
7459 <ref id="c128.h" name="c128.h">/
7460 <tag/Declaration/<tt/unsigned __fastcall__ videomode (unsigned Mode);/
7461 <tag/Description/Switch to 40 or 80 column mode depending on the argument. If
7462 the requested mode is already active, nothing happens. The old mode is returned
7464 <tag/Notes/<itemize>
7465 <item>The function is specific to the C128 and enhanced Apple //e.
7466 <item>This function replaces <ref id="toggle_videomode"
7467 name="toggle_videomode">.
7468 <item>The function is only available as fastcall function, so it may only be
7469 used in presence of a prototype.
7471 <tag/Availability/C128 and enhanced Apple //e
7473 <ref id="fast" name="fast">,
7474 <ref id="slow" name="slow">,
7475 <ref id="toggle_videomode" name="toggle_videomode">
7481 <sect1>wherex<label id="wherex"><p>
7485 <tag/Function/Return the current X position of the text mode cursor.
7486 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
7487 <tag/Declaration/<tt/unsigned char wherex (void);/
7488 <tag/Description/The function returns the current X position of the text mode
7489 cursor. Zero is returned for the leftmost screen position.
7490 <tag/Availability/cc65
7492 <ref id="gotox" name="gotox">,
7493 <ref id="gotoy" name="gotoy">,
7494 <ref id="gotoxy" name="gotoxy">,
7495 <ref id="wherey" name="wherey">
7501 <sect1>wherey<label id="wherey"><p>
7505 <tag/Function/Return the current Y position of the text mode cursor.
7506 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
7507 <tag/Declaration/<tt/unsigned char wherey (void);/
7508 <tag/Description/The function returns the current Y position of the text mode
7509 cursor. Zero is returned for the uppermost screen position.
7510 <tag/Availability/cc65
7512 <ref id="gotox" name="gotox">,
7513 <ref id="gotoy" name="gotoy">,
7514 <ref id="gotoxy" name="gotoxy">,
7515 <ref id="wherex" name="wherex">