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_scnkey" name="cbm_k_scnkey">
173 <item><ref id="cbm_k_setlfs" name="cbm_k_setlfs">
174 <item><ref id="cbm_k_setnam" name="cbm_k_setnam">
175 <item><ref id="cbm_k_talk" name="cbm_k_talk">
176 <item><ref id="cbm_k_udtim" name="cbm_k_udtim">
177 <item><ref id="cbm_k_unlsn" name="cbm_k_unlsn">
178 <!-- <item><ref id="cbm_load" name="cbm_load"> -->
179 <!-- <item><ref id="cbm_open" name="cbm_open"> -->
180 <!-- <item><ref id="cbm_opendir" name="cbm_opendir"> -->
181 <!-- <item><ref id="cbm_read" name="cbm_read"> -->
182 <!-- <item><ref id="cbm_readdir" name="cbm_readdir"> -->
183 <!-- <item><ref id="cbm_save" name="cbm_save"> -->
184 <!-- <item><ref id="cbm_write" name="cbm_write"> -->
185 <!-- <item><ref id="get_tv" name="get_tv"> -->
191 <sect1><tt/cbm510.h/<label id="cbm510.h"><p>
194 <item><ref id="peekbsys" name="peekbsys">
195 <item><ref id="peekwsys" name="peekwsys">
196 <item><ref id="pokebsys" name="pokebsys">
197 <item><ref id="pokewsys" name="pokewsys">
201 <sect1><tt/cbm610.h/<label id="cbm610.h"><p>
204 <item><ref id="peekbsys" name="peekbsys">
205 <item><ref id="peekwsys" name="peekwsys">
206 <item><ref id="pokebsys" name="pokebsys">
207 <item><ref id="pokewsys" name="pokewsys">
211 <sect1><tt/cc65.h/<label id="cc65.h"><p>
214 <!-- <item><ref id="cc65_cos" name="cc65_cos"> -->
215 <!-- <item><ref id="cc65_idiv32by16r16" name="cc65_idiv32by16r16"> -->
216 <!-- <item><ref id="cc65_imul16x16r32" name="cc65_imul16x16r32"> -->
217 <!-- <item><ref id="cc65_imul8x8r16" name="cc65_imul8x8r16"> -->
218 <!-- <item><ref id="cc65_sin" name="cc65_sin"> -->
219 <!-- <item><ref id="cc65_udiv32by16r16" name="cc65_udiv32by16r16"> -->
220 <!-- <item><ref id="cc65_umul16x16r32" name="cc65_umul16x16r32"> -->
221 <!-- <item><ref id="cc65_umul16x8r32" name="cc65_umul16x8r32"> -->
222 <!-- <item><ref id="cc65_umul8x8r16" name="cc65_umul8x8r16"> -->
223 <item><ref id="doesclrscrafterexit" name="doesclrscrafterexit">
229 <sect1><tt/conio.h/<label id="conio.h"><p>
232 <item><ref id="bgcolor" name="bgcolor">
233 <item><ref id="bordercolor" name="bordercolor">
234 <item><ref id="cclear" name="cclear">
235 <item><ref id="cclearxy" name="cclearxy">
236 <item><ref id="cgetc" name="cgetc">
237 <item><ref id="chline" name="chline">
238 <item><ref id="chlinexy" name="chlinexy">
239 <item><ref id="clrscr" name="clrscr">
240 <item><ref id="cprintf" name="cprintf">
241 <item><ref id="cputc" name="cputc">
242 <item><ref id="cputcxy" name="cputcxy">
243 <item><ref id="cputs" name="cputs">
244 <item><ref id="cputsxy" name="cputsxy">
245 <item><ref id="cursor" name="cursor">
246 <item><ref id="cvline" name="cvline">
247 <item><ref id="cvlinexy" name="cvlinexy">
248 <item><ref id="gotox" name="gotox">
249 <item><ref id="gotoxy" name="gotoxy">
250 <item><ref id="gotoy" name="gotoy">
251 <item><ref id="kbhit" name="kbhit">
252 <item><ref id="revers" name="revers">
253 <item><ref id="screensize" name="screensize">
254 <item><ref id="textcolor" name="textcolor">
255 <item><ref id="vcprintf" name="vcprintf">
256 <item><ref id="wherex" name="wherex">
257 <item><ref id="wherey" name="wherey">
261 <sect1><tt/ctype.h/<label id="ctype.h"><p>
264 <item><ref id="isalnum" name="isalnum">
265 <item><ref id="isalpha" name="isalpha">
266 <item><ref id="isascii" name="isascii">
267 <item><ref id="isblank" name="isblank">
268 <item><ref id="iscntrl" name="iscntrl">
269 <item><ref id="isdigit" name="isdigit">
270 <item><ref id="isgraph" name="isgraph">
271 <item><ref id="islower" name="islower">
272 <item><ref id="isprint" name="isprint">
273 <item><ref id="ispunct" name="ispunct">
274 <item><ref id="isspace" name="isspace">
275 <item><ref id="isupper" name="isupper">
276 <item><ref id="isxdigit" name="isxdigit">
277 <item><ref id="tolower" name="tolower">
278 <item><ref id="toupper" name="toupper">
282 <sect1><tt/dbg.h/<label id="dbg.h"><p>
285 <!-- <item><ref id="DbgInit" name="DbgInit"> -->
291 <sect1><tt/dio.h/<label id="dio.h"><p>
293 <url url="dio.html" name="Low-level disk I/O API">.
296 <sect1><tt/dirent.h/<label id="dirent.h"><p>
299 <item><ref id="_DE_ISDIR" name="_DE_ISDIR">
300 <item><ref id="_DE_ISLBL" name="_DE_ISLBL">
301 <item><ref id="_DE_ISLNK" name="_DE_ISLNK">
302 <item><ref id="_DE_ISREG" name="_DE_ISREG">
303 <item><ref id="closedir" name="closedir">
304 <item><ref id="opendir" name="opendir">
305 <item><ref id="readdir" name="readdir">
306 <item><ref id="rewinddir" name="rewinddir">
307 <item><ref id="seekdir" name="seekdir">
308 <item><ref id="telldir" name="telldir">
314 <sect1><tt/em.h/<label id="em.h"><p>
317 <item><ref id="em_commit" name="em_commit">
318 <item><ref id="em_copyfrom" name="em_copyfrom">
319 <item><ref id="em_copyto" name="em_copyto">
320 <item><ref id="em_install" name="em_install">
321 <item><ref id="em_load_driver" name="em_load_driver">
322 <item><ref id="em_map" name="em_map">
323 <item><ref id="em_pagecount" name="em_pagecount">
324 <item><ref id="em_uninstall" name="em_uninstall">
325 <item><ref id="em_unload" name="em_unload">
326 <item><ref id="em_use" name="em_use">
330 <sect1><tt/errno.h/<label id="errno.h"><p>
333 <!-- <item><ref id="_directerrno" name="_directerrno"> -->
334 <!-- <item><ref id="_mappederrno" name="_mappederrno"> -->
335 <!-- <item><ref id="_osmaperrno" name="_osmaperrno"> -->
336 <!-- <item><ref id="_seterrno" name="_seterrno"> -->
342 <sect1><tt/fcntl.h/<label id="fcntl.h"><p>
345 <item><ref id="close" name="close">
346 <item><ref id="creat" name="creat">
347 <item><ref id="open" name="open">
351 <sect1><tt/gamate.h/<label id="gamate.h"><p>
354 <!-- <item><ref id="get_tv" name="get_tv"> -->
355 <!-- <item><ref id="waitvblank" name="waitvblank"> -->
361 <sect1><tt/geos.h/<label id="geos.h"><p>
366 <sect1><tt/joystick.h/<label id="joystick.h"><p>
369 <item><ref id="joy_count" name="joy_count">
370 <item><ref id="joy_install" name="joy_install">
371 <item><ref id="joy_load_driver" name="joy_load_driver">
372 <item><ref id="joy_read" name="joy_read">
373 <item><ref id="joy_uninstall" name="joy_uninstall">
374 <item><ref id="joy_unload" name="joy_unload">
378 <sect1><tt/locale.h/<label id="locale.h"><p>
381 <item><ref id="localeconv" name="localeconv">
382 <item><ref id="setlocale" name="setlocale">
386 <sect1><tt/lynx.h/<label id="lynx.h"><p>
389 <!-- <item><ref id="lynx_eeprom_erase" name="lynx_eeprom_erase"> -->
390 <!-- <item><ref id="lynx_eeprom_read" name="lynx_eeprom_read"> -->
391 <!-- <item><ref id="lynx_eeprom_write" name="lynx_eeprom_write"> -->
392 <!-- <item><ref id="lynx_eeread" name="lynx_eeread"> -->
393 <!-- <item><ref id="lynx_eewrite" name="lynx_eewrite"> -->
394 <!-- <item><ref id="lynx_exec" name="lynx_exec"> -->
395 <!-- <item><ref id="lynx_load" name="lynx_load"> -->
401 <sect1><tt/modload.h/<label id="modload.h"><p>
404 <item><ref id="mod_load" name="mod_load">
405 <item><ref id="mod_free" name="mod_free">
409 <sect1><tt/mouse.h/<label id="mouse.h"><p>
412 <item><ref id="mouse_buttons" name="mouse_buttons">
413 <item><ref id="mouse_getbox" name="mouse_getbox">
414 <item><ref id="mouse_geterrormsg" name="mouse_geterrormsg">
415 <item><ref id="mouse_hide" name="mouse_hide">
416 <item><ref id="mouse_info" name="mouse_info">
417 <item><ref id="mouse_install" name="mouse_install">
418 <item><ref id="mouse_ioctl" name="mouse_ioctl">
419 <item><ref id="mouse_load_driver" name="mouse_load_driver">
420 <item><ref id="mouse_move" name="mouse_move">
421 <item><ref id="mouse_pos" name="mouse_pos">
422 <item><ref id="mouse_setbox" name="mouse_setbox">
423 <item><ref id="mouse_show" name="mouse_show">
424 <item><ref id="mouse_uninstall" name="mouse_uninstall">
425 <item><ref id="mouse_unload" name="mouse_unload">
429 <sect1><tt/nes.h/<label id="nes.h"><p>
432 <!-- <item><ref id="get_tv" name="get_tv"> -->
433 <!-- <item><ref id="waitvblank" name="waitvblank"> -->
439 <sect1><tt/o65.h/<label id="o65.h"><p>
441 The <tt/o65.h/ header file contains structure and constant definitions that
442 may be used when dealing with files in <url
443 url="http://www.6502.org/users/andre/o65/fileformat.html" name="the o65 format">.
444 It does not declare any functions.
447 <sect1><tt/pce.h/<label id="pce.h"><p>
450 <!-- <item><ref id="get_tv" name="get_tv"> -->
451 <!-- <item><ref id="waitvblank" name="waitvblank"> -->
457 <sect1><tt/peekpoke.h/<label id="peekpoke.h"><p>
460 <item><ref id="PEEK" name="PEEK">
461 <item><ref id="PEEKW" name="PEEKW">
462 <item><ref id="POKE" name="POKE">
463 <item><ref id="POKEW" name="POKEW">
467 <sect1><tt/pen.h/<label id="pen.h"><p>
470 <!-- <item><ref id="pen_adjust" name="pen_adjust"> -->
471 <!-- <item><ref id="pen_calibrate" name="pen_calibrate"> -->
477 <sect1><tt/pet.h/<label id="pet.h"><p>
482 <sect1><tt/plus4.h/<label id="plus4.h"><p>
487 <sect1><tt/serial.h/<label id="serial.h"><p>
489 The <tt/serial.h/ header file contains definitions for initializing serial
493 <item><ref id="ser_close" name="ser_close">
494 <item><ref id="ser_get" name="ser_get">
495 <item><ref id="ser_install" name="ser_install">
496 <item><ref id="ser_ioctl" name="ser_ioctl">
497 <item><ref id="ser_load_driver" name="ser_load_driver">
498 <item><ref id="ser_open" name="ser_open">
499 <item><ref id="ser_put" name="ser_put">
500 <item><ref id="ser_status" name="ser_status">
501 <item><ref id="ser_uninstall" name="ser_uninstall">
502 <item><ref id="ser_unload" name="ser_unload">
506 <sect1><tt/setjmp.h/<label id="setjmp.h"><p>
509 <item><ref id="setjmp" name="setjmp">
510 <item><ref id="longjmp" name="longjmp">
514 <sect1><tt/signal.h/<label id="signal.h"><p>
517 <item><ref id="raise" name="raise">
518 <item><ref id="signal" name="signal">
522 <sect1><tt/stdarg.h/<label id="stdarg.h"><p>
527 <sect1><tt/stdbool.h/<label id="stdbool.h"><p>
532 <sect1><tt/stddef.h/<label id="stddef.h"><p>
535 <item><ref id="offsetof" name="offsetof">
539 <sect1><tt/stdio.h/<label id="stdio.h"><p>
542 <item><ref id="_poserror" name="_poserror">
543 <item><ref id="clearerr" name="clearerr">
544 <!-- <item><ref id="fclose" name="fclose"> -->
545 <!-- <item><ref id="fdopen" name="fdopen"> -->
546 <item><ref id="feof" name="feof">
547 <item><ref id="ferror" name="ferror">
548 <!-- <item><ref id="fflush" name="fflush"> -->
549 <!-- <item><ref id="fgetc" name="fgetc"> -->
550 <!-- <item><ref id="fgetpos" name="fgetpos"> -->
551 <!-- <item><ref id="fgets" name="fgets"> -->
552 <item><ref id="fileno" name="fileno">
553 <!-- <item><ref id="fopen" name="fopen"> -->
554 <!-- <item><ref id="fprintf" name="fprintf"> -->
555 <!-- <item><ref id="fputc" name="fputc"> -->
556 <!-- <item><ref id="fputs" name="fputs"> -->
557 <!-- <item><ref id="fread" name="fread"> -->
558 <!-- <item><ref id="freopen" name="freopen"> -->
559 <!-- <item><ref id="fscanf" name="fscanf"> -->
560 <!-- <item><ref id="fseek" name="fseek"> -->
561 <!-- <item><ref id="fsetpos" name="fsetpos"> -->
562 <!-- <item><ref id="ftell" name="ftell"> -->
563 <!-- <item><ref id="fwrite" name="fwrite"> -->
564 <!-- <item><ref id="getc" name="getc"> -->
565 <!-- <item><ref id="getchar" name="getchar"> -->
566 <!-- <item><ref id="gets" name="gets"> -->
567 <!-- <item><ref id="printf" name="printf"> -->
568 <!-- <item><ref id="putc" name="putc"> -->
569 <!-- <item><ref id="putchar" name="putchar"> -->
570 <!-- <item><ref id="puts" name="puts"> -->
571 <item><ref id="rename" name="rename">
572 <item><ref id="remove" name="remove">
573 <!-- <item><ref id="rewind" name="rewind"> -->
574 <!-- <item><ref id="scanf" name="scanf"> -->
575 <!-- <item><ref id="snprintf" name="snprintf"> -->
576 <!-- <item><ref id="sprintf" name="sprintf"> -->
577 <!-- <item><ref id="sscanf" name="sscanf"> -->
578 <!-- <item><ref id="vfprintf" name="vfprintf"> -->
579 <!-- <item><ref id="vfscanf" name="vfscanf"> -->
580 <!-- <item><ref id="vprintf" name="vprintf"> -->
581 <!-- <item><ref id="vscanf" name="vscanf"> -->
582 <!-- <item><ref id="vsnprintf" name="vsnprintf"> -->
583 <!-- <item><ref id="vsprintf" name="vsprintf"> -->
584 <!-- <item><ref id="vsscanf" name="vsscanf"> -->
590 <sect1><tt/stdlib.h/<label id="stdlib.h"><p>
593 <item><ref id="_heapadd" name="_heapadd">
594 <item><ref id="_heapblocksize" name="_heapblocksize">
595 <item><ref id="_heapmaxavail" name="_heapmaxavail">
596 <item><ref id="_heapmemavail" name="_heapmemavail">
597 <item><ref id="_randomize" name="_randomize">
598 <item><ref id="_swap" name="_swap">
599 <item><ref id="abort" name="abort">
600 <item><ref id="abs" name="abs">
601 <item><ref id="atexit" name="atexit">
602 <item><ref id="atoi" name="atoi">
603 <item><ref id="atol" name="atol">
604 <item><ref id="bsearch" name="bsearch">
605 <item><ref id="calloc" name="calloc">
606 <item><ref id="div" name="div">
607 <item><ref id="exit" name="exit">
608 <item><ref id="free" name="free">
609 <item><ref id="getenv" name="getenv">
610 <item><ref id="itoa" name="itoa">
611 <item><ref id="labs" name="labs">
612 <item><ref id="ltoa" name="ltoa">
613 <item><ref id="malloc" name="malloc">
614 <item><ref id="perror" name="perror">
615 <!-- <item><ref id="posix_memalign" name="posix_memalign"> -->
616 <!-- <item><ref id="putenv" name="putenv"> -->
617 <item><ref id="qsort" name="qsort">
618 <item><ref id="rand" name="rand">
619 <item><ref id="realloc" name="realloc">
620 <item><ref id="srand" name="srand">
621 <!-- <item><ref id="system" name="system"> -->
622 <item><ref id="ultoa" name="ultoa">
623 <item><ref id="utoa" name="utoa">
629 <sect1><tt/string.h/<label id="string.h"><p>
632 <item><ref id="_stroserror" name="_stroserror">
633 <item><ref id="bzero" name="bzero">
634 <item><ref id="memchr" name="memchr">
635 <item><ref id="memcmp" name="memcmp">
636 <item><ref id="memcpy" name="memcpy">
637 <item><ref id="memmove" name="memmove">
638 <item><ref id="memset" name="memset">
639 <item><ref id="strcasecmp" name="strcasecmp">
640 <item><ref id="strcat" name="strcat">
641 <item><ref id="strchr" name="strchr">
642 <item><ref id="strcmp" name="strcmp">
643 <item><ref id="strcoll" name="strcoll">
644 <item><ref id="strcpy" name="strcpy">
645 <item><ref id="strcspn" name="strcspn">
646 <item><ref id="strdup" name="strdup">
647 <item><ref id="strerror" name="strerror">
648 <item><ref id="stricmp" name="stricmp">
649 <item><ref id="strlen" name="strlen">
650 <item><ref id="strlower" name="strlower">
651 <item><ref id="strlwr" name="strlwr">
652 <item><ref id="strncat" name="strncat">
653 <item><ref id="strncmp" name="strncmp">
654 <item><ref id="strncpy" name="strncpy">
655 <item><ref id="strqtok" name="strqtok">
656 <item><ref id="strrchr" name="strrchr">
657 <item><ref id="strspn" name="strspn">
658 <item><ref id="strstr" name="strstr">
659 <item><ref id="strtok" name="strtok">
660 <item><ref id="strxfrm" name="strxfrm">
661 <item><ref id="strupper" name="strupper">
662 <item><ref id="strupr" name="strupr">
668 <sect1><tt/tgi.h/<label id="tgi.h"><p>
671 <item><ref id="tgi_arc" name="tgi_arc">
672 <item><ref id="tgi_bar" name="tgi_bar">
673 <item><ref id="tgi_circle" name="tgi_circle">
674 <item><ref id="tgi_clear" name="tgi_clear">
675 <item><ref id="tgi_done" name="tgi_done">
676 <item><ref id="tgi_ellipse" name="tgi_ellipse">
677 <item><ref id="tgi_free_vectorfont" name="tgi_free_vectorfont">
678 <item><ref id="tgi_getaspectratio" name="tgi_getaspectratio">
679 <item><ref id="tgi_getcolor" name="tgi_getcolor">
680 <item><ref id="tgi_getcolorcount" name="tgi_getcolorcount">
681 <item><ref id="tgi_getdefpalette" name="tgi_getdefpalette">
682 <item><ref id="tgi_geterror" name="tgi_geterror">
683 <item><ref id="tgi_geterrormsg" name="tgi_geterrormsg">
684 <item><ref id="tgi_getmaxcolor" name="tgi_getmaxcolor">
685 <item><ref id="tgi_getmaxx" name="tgi_getmaxx">
686 <item><ref id="tgi_getmaxy" name="tgi_getmaxy">
687 <item><ref id="tgi_getpagecount" name="tgi_getpagecount">
688 <item><ref id="tgi_getpalette" name="tgi_getpalette">
689 <item><ref id="tgi_getpixel" name="tgi_getpixel">
690 <item><ref id="tgi_gettextheight" name="tgi_gettextheight">
691 <item><ref id="tgi_gettextwidth" name="tgi_gettextwidth">
692 <item><ref id="tgi_getxres" name="tgi_getxres">
693 <item><ref id="tgi_getyres" name="tgi_getyres">
694 <item><ref id="tgi_gotoxy" name="tgi_gotoxy">
695 <item><ref id="tgi_init" name="tgi_init">
696 <item><ref id="tgi_install" name="tgi_install">
697 <item><ref id="tgi_install_vectorfont" name="tgi_install_vectorfont">
698 <item><ref id="tgi_ioctl" name="tgi_ioctl">
699 <item><ref id="tgi_line" name="tgi_line">
700 <item><ref id="tgi_lineto" name="tgi_lineto">
701 <item><ref id="tgi_load_driver" name="tgi_load_driver">
702 <item><ref id="tgi_load_vectorfont" name="tgi_load_vectorfont">
703 <item><ref id="tgi_outtext" name="tgi_outtext">
704 <item><ref id="tgi_outtextxy" name="tgi_outtextxy">
705 <item><ref id="tgi_setaspectratio" name="tgi_setaspectratio">
706 <item><ref id="tgi_setcolor" name="tgi_setcolor">
707 <item><ref id="tgi_setdrawpage" name="tgi_setdrawpage">
708 <item><ref id="tgi_setpalette" name="tgi_setpalette">
709 <item><ref id="tgi_setpixel" name="tgi_setpixel">
710 <item><ref id="tgi_setviewpage" name="tgi_setviewpage">
711 <item><ref id="tgi_settextscale" name="tgi_settextscale">
712 <item><ref id="tgi_settextstyle" name="tgi_settextstyle">
713 <item><ref id="tgi_uninstall" name="tgi_uninstall">
714 <item><ref id="tgi_unload" name="tgi_unload">
717 <sect1><tt/time.h/<label id="time.h"><p>
720 <!-- <item><ref id="_systime" name="_systime"> -->
721 <!-- <item><ref id="asctime" name="asctime"> -->
722 <item><ref id="clock" name="clock">
723 <!-- <item><ref id="ctime" name="ctime"> -->
724 <!-- <item><ref id="gmtime" name="gmtime"> -->
725 <!-- <item><ref id="localtime" name="localtime"> -->
726 <!-- <item><ref id="mktime" name="mktime"> -->
727 <!-- <item><ref id="strftime" name="strftime"> -->
728 <item><ref id="time" name="time">
734 <sect1><tt/unistd.h/<label id="unistd.h"><p>
737 <!-- <item><ref id="chdir" name="chdir"> -->
738 <item><ref id="exec" name="exec">
739 <!-- <item><ref id="getcwd" name="getcwd"> -->
740 <item><ref id="getopt" name="getopt">
741 <!-- <item><ref id="lseek" name="lseek"> -->
742 <!-- <item><ref id="mkdir" name="mkdir"> -->
743 <!-- <item><ref id="read" name="read"> -->
744 <!-- <item><ref id="rmdir" name="rmdir"> -->
745 <item><ref id="sleep" name="sleep">
746 <item><ref id="unlink" name="unlink">
747 <!-- <item><ref id="write" name="write"> -->
753 <sect1><tt/vic20.h/<label id="vic20.h"><p>
758 <sect1><tt/zlib.h/<label id="zlib.h"><p>
761 <!-- <item><ref id="adler32" name="adler32"> -->
762 <!-- <item><ref id="crc32" name="crc32"> -->
763 <!-- <item><ref id="inflatemem" name="inflatemem"> -->
764 <!-- <item><ref id="uncompress" name="uncompress"> -->
770 <sect>Alphabetical function reference<p>
772 <sect1>_DE_ISDIR<label id="_DE_ISDIR"><p>
776 <tag/Function/Determine if a directory entry specifies a directory.
777 <tag/Header/<tt/<ref id="dirent.h" name="dirent.h">/
778 <tag/Declaration/<tt/int _DE_ISDIR(unsigned char type);/
779 <tag/Description/The function is called with the type of a directory entry
780 taken from a <tt/struct dirent/ and returns true if the entry designates
783 <item>The function is actually a macro.
785 <tag/Availability/cc65
787 <ref id="_DE_ISLBL" name="_DE_ISLBL">,
788 <ref id="_DE_ISLNK" name="_DE_ISLNK">,
789 <ref id="_DE_ISREG" name="_DE_ISREG">
795 <sect1>_DE_ISLBL<label id="_DE_ISLBL"><p>
799 <tag/Function/Determine if a directory entry specifies a disk label.
800 <tag/Header/<tt/<ref id="dirent.h" name="dirent.h">/
801 <tag/Declaration/<tt/int _DE_ISLBL(unsigned char type);/
802 <tag/Description/The function is called with the type of a directory entry
803 taken from a <tt/struct dirent/ and returns true if the entry designates
806 <item>The function is actually a macro.
808 <tag/Availability/cc65
810 <ref id="_DE_ISDIR" name="_DE_ISDIR">,
811 <ref id="_DE_ISLNK" name="_DE_ISLNK">,
812 <ref id="_DE_ISREG" name="_DE_ISREG">
818 <sect1>_DE_ISLNK<label id="_DE_ISLNK"><p>
822 <tag/Function/Determine if a directory entry specifies a link.
823 <tag/Header/<tt/<ref id="dirent.h" name="dirent.h">/
824 <tag/Declaration/<tt/int _DE_ISLNK(unsigned char type);/
825 <tag/Description/The function is called with the type of a directory entry
826 taken from a <tt/struct dirent/ and returns true if the entry designates
829 <item>The function is actually a macro.
831 <tag/Availability/cc65
833 <ref id="_DE_ISDIR" name="_DE_ISDIR">,
834 <ref id="_DE_ISLBL" name="_DE_ISLBL">,
835 <ref id="_DE_ISREG" name="_DE_ISREG">
841 <sect1>_DE_ISREG<label id="_DE_ISREG"><p>
845 <tag/Function/Determine if a directory entry specifies a regular file.
846 <tag/Header/<tt/<ref id="dirent.h" name="dirent.h">/
847 <tag/Declaration/<tt/int _DE_ISREG(unsigned char type);/
848 <tag/Description/The function is called with the type of a directory entry
849 taken from a <tt/struct dirent/ and returns true if the entry designates
852 <item>The function is actually a macro.
853 <item>A "regular file" means anything with data in it. This might still mean
854 that special processing is needed, when accessing the file. Relative files of
855 the CBM systems are classified as being "regular" files, for example.
857 <tag/Availability/cc65
859 <ref id="_DE_ISDIR" name="_DE_ISDIR">,
860 <ref id="_DE_ISLBL" name="_DE_ISLBL">,
861 <ref id="_DE_ISLNK" name="_DE_ISLNK">
867 <sect1>_heapadd<label id="_heapadd"><p>
871 <tag/Function/Add a block to the heap.
872 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
873 <tag/Declaration/<tt/void __fastcall__ _heapadd (void* mem, size_t size);/
874 <tag/Description/The function adds a block of raw memory to the heap.
876 <item>The minimum blocksize that can be added is 6 bytes; the function will
877 ignore smaller blocks.
878 <item>The function is available only as a fastcall function; so, it may be used
879 only in the presence of a prototype.
881 <tag/Availability/cc65
883 <ref id="_heapblocksize" name="_heapblocksize">,
884 <ref id="_heapmaxavail" name="_heapmaxavail">,
885 <ref id="_heapmemavail" name="_heapmemavail">,
886 <ref id="calloc" name="calloc">,
887 <ref id="free" name="free">,
888 <ref id="malloc" name="malloc">,
889 <ref id="realloc" name="realloc">
895 <sect1>_heapblocksize<label id="_heapblocksize"><p>
899 <tag/Function/Return the size of an allocated block.
900 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
901 <tag/Declaration/<tt/size_t __fastcall__ _heapblocksize (const void* block);/
902 <tag/Description/The function returns the size of a block that must have
903 previously been allocated by <tt/<ref id="malloc" name="malloc">/, <tt/<ref
904 id="calloc" name="calloc">/ or <tt/<ref id="realloc" name="realloc">/.
906 <item>Passing a pointer to a block that was is not the result of one of the
907 allocation functions, or that has been free'd will give unpredicable results.
908 <item>The function is available only as a fastcall function; so, it may be used
909 only in the presence of a prototype.
911 <tag/Availability/cc65
913 <ref id="_heapadd" name="_heapadd">,
914 <ref id="_heapmaxavail" name="_heapmaxavail">,
915 <ref id="_heapmemavail" name="_heapmemavail">,
916 <ref id="calloc" name="calloc">,
917 <ref id="free" name="free">,
918 <ref id="malloc" name="malloc">,
919 <ref id="realloc" name="realloc">
925 <sect1>_heapmaxavail<label id="_heapmaxavail"><p>
929 <tag/Function/Return the largest block that is available on the heap.
930 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
931 <tag/Declaration/<tt/size_t _heapmaxavail (void);/
932 <tag/Description/The function returns the size of the largest block that may
933 be allocated from the heap using <tt/<ref id="malloc" name="malloc">/.
934 <tag/Availability/cc65
936 <ref id="_heapadd" name="_heapadd">,
937 <ref id="_heapblocksize" name="_heapblocksize">,
938 <ref id="_heapmemavail" name="_heapmemavail">,
939 <ref id="calloc" name="calloc">,
940 <ref id="free" name="free">,
941 <ref id="malloc" name="malloc">,
942 <ref id="realloc" name="realloc">
948 <sect1>_heapmemavail<label id="_heapmemavail"><p>
952 <tag/Function/Return the total available space on the heap.
953 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
954 <tag/Declaration/<tt/size_t _heapmemavail (void);/
955 <tag/Description/The function returns the total number of bytes available on
958 <item>This function is of less use than usually assumed, since the returned
959 heap space may be available but not in one block. So even if this function
960 says that several times more heap space is available than needed, <ref
961 id="malloc" name="malloc"> may still return <tt/NULL/.
963 <tag/Availability/cc65
965 <ref id="_heapadd" name="_heapadd">,
966 <ref id="_heapblocksize" name="_heapblocksize">,
967 <ref id="_heapmaxavail" name="_heapmaxavail">,
968 <ref id="calloc" name="calloc">,
969 <ref id="free" name="free">,
970 <ref id="malloc" name="malloc">,
971 <ref id="realloc" name="realloc">
977 <sect1>_is_cmdline_dos<label id="_is_cmdline_dos"><p>
981 <tag/Function/Determines whether the underlying DOS supports command line arguments.
982 <tag/Header/<tt/<ref id="atari.h" name="atari.h">/
983 <tag/Declaration/<tt/unsigned char _is_cmdline_dos (void);/
984 <tag/Description/The function returns 0 if the DOS doesn't support command line arguments.
985 It returns 1 if it does.
986 <tag/Availability/cc65 (<tt/atari/ and <tt/atarixl/ platforms)
991 <sect1>_poserror<label id="_poserror"><p>
995 <tag/Function/Print an error message for the error in <tt/_oserror/.
996 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
997 <tag/Declaration/<tt/void __fastcall__ _poserror (const char* msg);/
998 <tag/Description/<tt/_poserror/ prints an error message to <tt/stderr/. If
999 <tt/msg/ is not <tt/NULL/ and not an empty string, it is printed followed by
1000 a colon and a blank. Then the error message for the current contents of
1001 <tt/_oserror/ are printed followed by a newline. The message output is the
1002 same as returned by <tt/<ref id="_stroserror" name="_stroserror">/ with an
1003 argument of <tt/_oserror/.
1004 <tag/Notes/<itemize>
1005 <item>Since operating system specific error code are - you guessed it -
1006 operating system specific, the value in <tt/_oserror/ and the message that is
1007 printed depends on the cc65 target.
1008 <item>The function is only available as fastcall function, so it may only
1009 be used in presence of a prototype.
1011 <tag/Availability/cc65
1013 <ref id="_stroserror" name="_stroserror">,
1014 <ref id="perror" name="perror">
1020 <sect1>_randomize<label id="_randomize"><p>
1024 <tag/Function/Initialize the pseudo random number generator.
1025 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1026 <tag/Declaration/<tt/void _randomize (void);/
1027 <tag/Description/The function initializes the random number generator with
1028 a seed derived from fast changing hardware events, so the seed itself can be
1029 considered random to a certain degree.
1030 <tag/Notes/<itemize>
1031 <item>The randomness of the seed depends on the machine hardware.
1033 <tag/Availability/cc65
1035 <ref id="rand" name="rand">,
1036 <ref id="srand" name="srand">
1042 <sect1>_stroserror<label id="_stroserror"><p>
1046 <tag/Function/Return a string describing an OS specific error code.
1047 <tag/Header/<tt/<ref id="string.h" name="string.h">/
1048 <tag/Declaration/<tt/const char* __fastcall__ _stroserror (unsigned char errcode);/
1049 <tag/Description/<tt/_stroserror/ will return a string describing the given
1050 operating system specific error code.
1051 <tag/Notes/<itemize>
1052 <item>Since operating system specific error code are - you guessed it -
1053 operating system specific, the parameter and the string returned depend on the
1055 <item>The function is only available as fastcall function, so it may only be
1056 used in presence of a prototype.
1058 <tag/Availability/cc65
1060 <ref id="strerror" name="strerror">
1066 <sect1>_swap<label id="_swap"><p>
1070 <tag/Function/Swap the contents of memory areas.
1071 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1072 <tag/Declaration/<tt/void __fastcall__ _swap (void* p, void* q, size_t size);/
1073 <tag/Description/<tt/_swap/ will swap (exchange) the contents of the two memory
1074 areas pointed to by <tt/p/ and <tt/q/. Both memory areas are assumed to be
1075 <tt/size/ bytes in size.
1076 <tag/Notes/<itemize>
1077 <item>The memory areas may not overlap, otherwise the results are undefined.
1078 <item>The function is only available as fastcall function, so it may only be
1079 used in presence of a prototype.
1081 <tag/Availability/cc65
1083 <ref id="memcpy" name="memcpy">,
1084 <ref id="memmove" name="memmove">
1090 <sect1>_sys<label id="_sys"><p>
1094 <tag/Function/Call a subroutine passing register values.
1095 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
1096 <tag/Declaration/<tt/void __fastcall__ _sys (struct regs* r);/
1097 <tag/Description/The function will call the subroutine at the address
1098 specified in the <tt/pc/ member of the passed <tt/regs/ structure. All
1099 registers and the CPU flags are set to the values given in the <tt/regs/
1100 structure. On return from the subroutine, the new values of the registers and
1101 flags are stored back overwriting the old values.
1102 <tag/Notes/<itemize>
1103 <item>Bits 4 and 5 of the flags value in the <tt/regs/ structure are ignored
1104 when calling the subroutine (they are unchanged from their current values).
1105 <item>The function is only available as fastcall function, so it may only be
1106 used in presence of a prototype.
1108 <tag/Availability/cc65
1114 <sect1>BRK<label id="BRK"><p>
1118 <tag/Function/Insert a 6502 BRK instrunction into the code.
1119 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
1120 <tag/Declaration/<tt/void BRK (void);/
1121 <tag/Description/The function will insert a 6502 BRK instruction into the code
1122 which may be used to trigger a debugger.
1123 <tag/Notes/<itemize>
1124 <item>The function is actually a macro.
1125 <item>The inserted instruction may lead to unexpected results if no debugger
1128 <tag/Availability/cc65
1130 <ref id="CLI" name="CLI">,
1131 <ref id="SEI" name="SEI">
1137 <sect1>CLI<label id="CLI"><p>
1141 <tag/Function/Insert a 6502 CLI instrunction into the code.
1142 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
1143 <tag/Declaration/<tt/void CLI (void);/
1144 <tag/Description/The function will insert a 6502 CLI instruction into the code,
1145 so interrupts are enabled. Enabling interrupts has no effects if they are
1146 already enabled (the default).
1147 <tag/Notes/<itemize>
1148 <item>The function is actually a macro.
1149 <item>Disabling interrupts may lead to unexpected results.
1151 <tag/Availability/cc65
1153 <ref id="BRK" name="BRK">,
1154 <ref id="SEI" name="SEI">
1160 <sect1>PEEK<label id="PEEK"><p>
1164 <tag/Function/Read a byte from memory.
1165 <tag/Header/<tt/<ref id="peekpoke.h" name="peekpoke.h">/
1166 <tag/Declaration/<tt/unsigned char PEEK (unsigned addr);/
1167 <tag/Description/The function will read the absolute memory given by <tt/addr/
1168 and return the value read.
1169 <tag/Notes/<itemize>
1170 <item>The function is actually a macro.
1171 <item>This function depends highly on the platform and environment.
1173 <tag/Availability/cc65
1175 <ref id="PEEKW" name="PEEKW">,
1176 <ref id="POKE" name="POKE">
1182 <sect1>PEEKW<label id="PEEKW"><p>
1186 <tag/Function/Read a word (two bytes) from memory.
1187 <tag/Header/<tt/<ref id="peekpoke.h" name="peekpoke.h">/
1188 <tag/Declaration/<tt/unsigned PEEKW (unsigned addr);/
1189 <tag/Description/The function will read the absolute memory given by <tt/addr/
1190 and return the value read. The byte read from the higher address is the high
1191 byte of the return value.
1192 <tag/Notes/<itemize>
1193 <item>The function is actually a macro.
1194 <item>This function depends highly on the platform and environment.
1195 <item>The order in which the two bytes are read is unspecified and may
1196 depend of the address expression used.
1198 <tag/Availability/cc65
1200 <ref id="PEEK" name="PEEK">,
1201 <ref id="POKE" name="POKE">
1207 <sect1>POKE<label id="POKE"><p>
1211 <tag/Function/Write a byte to memory.
1212 <tag/Header/<tt/<ref id="peekpoke.h" name="peekpoke.h">/
1213 <tag/Declaration/<tt/void POKE (unsigned addr, unsigned char val);/
1214 <tag/Description/The function writes the value <tt/val/ to the absolute
1215 memory address given by <tt/addr/.
1216 <tag/Notes/<itemize>
1217 <item>The function is actually a macro.
1218 <item>This function depends highly on the platform and environment.
1219 <item>Careless use will cause the program to act strange or may crash the
1222 <tag/Availability/cc65
1224 <ref id="PEEK" name="PEEK">,
1225 <ref id="POKEW" name="POKEW">
1231 <sect1>POKEW<label id="POKEW"><p>
1235 <tag/Function/Write a word (two bytes) to memory.
1236 <tag/Header/<tt/<ref id="peekpoke.h" name="peekpoke.h">/
1237 <tag/Declaration/<tt/void POKEW (unsigned addr, unsigned val);/
1238 <tag/Description/The function writes the value <tt/val/ to the absolute
1239 memory address given by <tt/addr/. The low byte of <tt/val/ is written to
1240 the <tt/addr/, the high byte is written to <tt/addr+1/.
1241 <tag/Notes/<itemize>
1242 <item>The function is actually a macro.
1243 <item>This function depends highly on the platform and environment.
1244 <item>Careless use will cause the program to act strange or may crash the
1246 <item>The order in which the two bytes are written is unspecified and may
1247 depend of the address expression used.
1249 <tag/Availability/cc65
1251 <ref id="PEEK" name="PEEK">,
1252 <ref id="POKE" name="POKE">
1258 <sect1>SEI<label id="SEI"><p>
1262 <tag/Function/Insert a 6502 SEI instrunction into the code.
1263 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
1264 <tag/Declaration/<tt/void SEI (void);/
1265 <tag/Description/The function will insert a 6502 SEI instruction into the code,
1266 so interrupts are disabled. Note that non maskable interrupts cannot be
1268 <tag/Notes/<itemize>
1269 <item>The function is actually a macro.
1270 <item>Disabling interrupts may lead to unexpected results.
1272 <tag/Availability/cc65
1274 <ref id="BRK" name="BRK">,
1275 <ref id="CLI" name="CLI">
1281 <sect1>abort<label id="abort"><p>
1285 <tag/Function/Terminates a program abnormally.
1286 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1287 <tag/Declaration/<tt/void abort (void);/
1288 <tag/Description/<tt/abort/ raises <tt/SIGABRT/, writes a termination message
1289 on stderr, then terminates the program with an exit code of 3.
1290 <tag/Availability/ISO 9899
1292 <ref id="assert" name="assert">,
1293 <ref id="exit" name="exit">,
1294 <ref id="raise" name="raise">
1300 <sect1>abs<label id="abs"><p>
1304 <tag/Function/Returns the absolute value of an integer.
1305 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1306 <tag/Declaration/<tt/int __fastcall__ abs (int v);/
1307 <tag/Description/<tt/abs/ returns the absolute value of the argument passed to
1309 <tag/Notes/<itemize>
1310 <item>The return value is undefined if <tt/INT_MIN/ is passed to the function.
1311 <item>The function is only available as fastcall function, so it may only be
1312 used in presence of a prototype.
1314 <tag/Availability/ISO 9899
1316 <ref id="labs" name="labs">
1322 <sect1>assert<label id="assert"><p>
1326 <tag/Function/Test a condition and possibly abort.
1327 <tag/Header/<tt/<ref id="assert.h" name="assert.h">/
1328 <tag/Declaration/<tt/void assert (int cond);/
1329 <tag/Description/<tt/assert/ is a macro that expands to a <tt/id/
1330 statement. If the condition evaluates t zero (false), assert prints a message
1331 on stderr and aborts the program.
1332 <tag/Notes/<itemize>
1333 <item>The function is actually a macro.
1335 <tag/Availability/ISO 9899
1337 <ref id="abort" name="abort">,
1338 <ref id="exit" name="exit">
1344 <sect1>atexit<label id="atexit"><p>
1348 <tag/Function/Register an exit function.
1349 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1350 <tag/Declaration/<tt/int __fastcall__ atexit (void (*exitfunc) (void));/
1351 <tag/Description/<tt/atexit/ registers the function pointed to by
1352 <tt/exitfunc/ as an exit function. Exit functions are called when the program
1353 terminates, they are called in LIFO order (the last function registered is
1354 called first). <tt/atexit/ returns zero on success and a nonzero value on
1356 <tag/Notes/<itemize>
1357 <item>A maximum of 5 exit functions can be registered.
1358 <item>There is no way to unregister an exit function.
1359 <item>The function is only available as fastcall function, so it may only be
1360 used in presence of a prototype.
1362 <tag/Availability/ISO 9899
1364 <ref id="abort" name="abort">,
1365 <ref id="exit" name="exit">
1371 <sect1>atmos_load<label id="atmos_load"><p>
1375 <tag/Function/Load Atmos tape.
1376 <tag/Header/<tt/<ref id="atmos.h" name="atmos.h">/
1377 <tag/Declaration/<tt/void __fastcall__ atmos_load(const char* name);/
1378 <tag/Description/<tt/atmos_load/ reads a memory block from tape.
1379 <tag/Notes/<itemize>
1380 <item>The function is available only as a fastcall function; so, it may be used
1381 only in the presence of a prototype.
1383 <tag/Availability/cc65
1385 <ref id="atmos_save" name="atmos_save">
1391 <sect1>atmos_save<label id="atmos_save"><p>
1395 <tag/Function/Save Atmos tape.
1396 <tag/Header/<tt/<ref id="atmos.h" name="atmos.h">/
1397 <tag/Declaration/<tt/void __fastcall__ atmos_save(const char* name, const void* start, const void* end);/
1398 <tag/Description/<tt/atmos_save/ writes a memory block to tape.
1399 <tag/Notes/<itemize>
1400 <item>The function is available only as a fastcall function; so, it may be used
1401 only in the presence of a prototype.
1403 <tag/Availability/cc65
1405 <ref id="atmos_load" name="atmos_load">
1407 atmos_save("hires", 0xa000, 0xc000);
1413 <sect1>atoi<label id="atoi"><p>
1417 <tag/Function/Convert a string to an integer.
1418 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1419 <tag/Declaration/<tt/int __fastcall__ atoi (const char* s);/
1420 <tag/Description/<tt/atoi/ converts the given string into an integer.
1421 Conversion stops as soon as any invalid character is encountered.
1422 <tag/Notes/<itemize>
1423 <item>There is no way to detect any conversion errors.
1424 <item>The function does not check for an numerical overflow when converting.
1425 <item>The function is only available as fastcall function, so it may only be
1426 used in presence of a prototype.
1428 <tag/Availability/ISO 9899
1430 <ref id="atol" name="atol">,
1431 <ref id="itoa" name="itoa">,
1432 <ref id="ltoa" name="ltoa">,
1433 <ref id="ultoa" name="ultoa">,
1434 <ref id="utoa" name="utoa">
1440 <sect1>atol<label id="atol"><p>
1444 <tag/Function/Convert a string to a long integer.
1445 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1446 <tag/Declaration/<tt/long __fastcall__ atol (const char* s);/
1447 <tag/Description/<tt/atol/ converts the given string into a long integer.
1448 Conversion stops as soon as any invalid character is encountered.
1449 <tag/Notes/<itemize>
1450 <item>There is no way to detect any conversion errors.
1451 <item>The function does not check for an numerical overflow when converting.
1452 <item>The function is only available as fastcall function, so it may only be
1453 used in presence of a prototype.
1455 <tag/Availability/ISO 9899
1457 <ref id="atoi" name="atoi">,
1458 <ref id="itoa" name="itoa">,
1459 <ref id="ltoa" name="ltoa">,
1460 <ref id="ultoa" name="ultoa">,
1461 <ref id="utoa" name="utoa">
1467 <sect1>bgcolor<label id="bgcolor"><p>
1471 <tag/Function/Set the background text color.
1472 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1473 <tag/Declaration/<tt/unsigned char __fastcall__ bgcolor (unsigned char color);/
1474 <tag/Description/The function will set a new background color and return the
1475 old (current) one. The background color is valid for the whole text output
1476 area of the screen, not just for new text.
1477 <tag/Notes/<itemize>
1478 <item>Background colors are system dependent. The function may have no effect
1479 on systems where the background color cannot be changed.
1480 <item>The function is only available as fastcall function, so it may only be
1481 used in presence of a prototype.
1483 <tag/Availability/cc65
1485 <ref id="bordercolor" name="bordercolor">,
1486 <ref id="textcolor" name="textcolor">
1492 <sect1>bordercolor<label id="bordercolor"><p>
1496 <tag/Function/Set the border (frame) color.
1497 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1498 <tag/Declaration/<tt/unsigned char __fastcall__ bordercolor (unsigned char color);/
1499 <tag/Description/The function will set a new border color. It returns the old
1500 (current) border color.
1501 <tag/Notes/<itemize>
1502 <item>Border colors are system dependent. The function may have no effect
1503 on systems where the border color cannot be changed.
1504 <item>The function is only available as fastcall function, so it may only
1505 be used in presence of a prototype.
1507 <tag/Availability/cc65
1509 <ref id="bgcolor" name="bgcolor">,
1510 <ref id="textcolor" name="textcolor">
1516 <sect1>bsearch<label id="bsearch"><p>
1520 <tag/Function/Do a binary search in a sorted array.
1521 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1522 <tag/Declaration/<tt/void* __fastcall__ bsearch (const void* key,
1523 const void* base, size_t n, size_t size,
1524 int __fastcall__ (* cmp) (const void*, const void*));/
1525 <tag/Description/<tt/bsearch/ searches a sorted array for a member that
1526 matches the one pointed to by <tt/key/. <tt/base/ is the address of the array,
1527 <tt/n/ is the number of elements, <tt/size/ the size of an element and <tt/cmp/
1528 the function used to compare the members against the key. The function returns
1529 a pointer to the member found, or <tt/NULL/ if there was no match.
1530 <tag/Notes/<itemize>
1531 <item>The contents of the array must be sorted in ascending order according to
1532 the compare function given.
1533 <item>If there are multiple members that match the key, the function will
1534 return one of the members.
1535 <item>The function is only available as fastcall function, so it may only
1536 be used in presence of a prototype.
1537 <item>The function to which <tt/cmp/ points must have the <tt/fastcall/ calling
1540 <tag/Availability/ISO 9899
1542 <ref id="qsort" name="qsort">
1548 <sect1>bzero<label id="bzero"><p>
1552 <tag/Function/Fill a memory area with zeroes.
1553 <tag/Header/<tt/<ref id="string.h" name="string.h">/
1554 <tag/Declaration/<tt/void __fastcall__ bzero (void* p, size_t count);/
1555 <tag/Description/<tt/bzero/ fills the memory area pointed to by <tt/p/ with
1557 <tag/Notes/<itemize>
1558 <item>The function is non standard and therefore only available in non ANSI
1559 mode. You should use <tt/<ref id="memset" name="memset">/ instead.
1560 <item>The function is only available as fastcall function, so it may only
1561 be used in presence of a prototype.
1563 <tag/Availability/cc65
1565 <ref id="_swap" name="_swap">,
1566 <ref id="memcpy" name="memcpy">,
1567 <ref id="memmove" name="memmove">,
1568 <ref id="memset" name="memset">,
1574 <sect1>c64mode<label id="c64mode"><p>
1578 <tag/Function/Switch the C128 into C64 compatible mode.
1579 <tag/Header/<tt/<ref id="c128.h" name="c128.h">/
1580 <tag/Declaration/<tt/void c64mode (void);/
1581 <tag/Description/The function will cause the machine to reboot into C64 mode.
1582 <tag/Notes/<itemize>
1583 <item>The function is specific to the C128.
1584 <item>The function will not return to the caller.
1586 <tag/Availability/C128
1592 <sect1>calloc<label id="calloc"><p>
1596 <tag/Function/Allocate and clear memory.
1597 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1598 <tag/Declaration/<tt/void* __fastcall__ calloc (size_t n, size_t size);/
1599 <tag/Description/<tt/calloc/ allocates memory for an array of <tt/n/ elements
1600 of size <tt/size/, clears the whole block with binary zeroes and returns a
1601 pointer to it. On error (not enough memory available), <tt/calloc/ returns
1603 <tag/Notes/<itemize>
1604 <item>Clearing the memory may not have the expected effect on all platforms:
1605 pointers in the block may not be <tt/NULL/ and floating point variables may
1606 not be zero (0.0). In other words: The "clearing" effect of this function
1607 should be used with care for portable programs.
1608 <item>The function is only available as fastcall function, so it may only
1609 be used in presence of a prototype.
1611 <tag/Availability/ISO 9899
1613 <ref id="_heapadd" name="_heapadd">,
1614 <ref id="_heapblocksize" name="_heapblocksize">,
1615 <ref id="_heapmaxavail" name="_heapmaxavail">,
1616 <ref id="_heapmemavail" name="_heapmemavail">,
1617 <ref id="free" name="free">,
1618 <ref id="malloc" name="malloc">,
1619 <ref id="realloc" name="realloc">
1625 <sect1>cbm_k_acptr<label id="cbm_k_acptr"><p>
1629 <tag/Function/Input byte from serial bus
1630 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
1631 <tag/Declaration/<tt/unsigned char cbm_k_acptr (void);/
1632 <tag/Description/The function returns a byte of data, which it
1633 gets from the current TALKer on the serial bus.
1634 In order to receive the data, the device must have previously been
1635 sent a command to TALK and a secondary address if it needs one.
1636 <tag/Notes/<itemize>
1639 <tag/Availability/cc65
1641 <ref id="cbm_k_talk" name="cbm_k_talk">,
1647 <sect1>cbm_k_basin<label id="cbm_k_basin"><p>
1651 <tag/Function/Input a Character from the Current Device
1652 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
1653 <tag/Declaration/<tt/unsigned char cbm_k_basin (void);/
1654 <tag/Description/The function returns a character from the current input device.
1655 Device must first have been OPENed and then designated as the input channel by the CHKIN routine.
1656 When this function is called, the next byte of data available from the device is returned.
1657 Exception is the routine for the keyboard device (which is the default input device).
1658 <tag/Notes/<itemize>
1661 <tag/Availability/cc65
1663 <ref id="cbm_k_open" name="cbm_k_open">,
1664 <ref id="cbm_k_chkin" name="cbm_k_chkin">
1670 <sect1>cbm_k_bsout<label id="cbm_k_bsout"><p>
1674 <tag/Function/Output a byte
1675 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
1676 <tag/Declaration/<tt/void __fastcall__ cbm_k_bsout (unsigned char C);/
1677 <tag/Description/Function sends the character to the current output device.
1678 Unless a device has been OPENed and designated as the
1679 current output channel using the CHKOUT routine, the character is
1680 printed to the screen, which is the default output device. If the
1681 cassette is the current device, outputting a byte will only add it to
1682 the buffer. No actual transmission of data will occur until the
1683 192-byte buffer is full.
1684 <tag/Notes/<itemize>
1685 <item>The function is only available as fastcall function, so it may
1686 only be used in presence of a prototype.
1688 <tag/Availability/cc65
1690 <ref id="cbm_k_open" name="cbm_k_open">,
1691 <ref id="cbm_k_chkin" name="cbm_k_chkout">
1697 <sect1>cbm_k_chkin<label id="cbm_k_chkin"><p>
1701 <tag/Function/Designate a Logical File As the Current Input Channel
1702 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
1703 <tag/Declaration/<tt/unsigned char __fastcall__ cbm_k_chkin (unsigned char FN);/
1704 <tag/Description/If you wish to
1705 get data from any device other than the keyboard, this function must be
1706 called after OPENing the device, before you can get a data byte with
1707 the cbm_k_basin or cbm_k_getin routine. When called, the routine will designate
1708 the logical file whose file number was supplied as the
1709 current file, its device as the current device, and its secondary
1710 address as the current secondary address. If the device on the
1711 channel is a serial device, which requires a TALK command and
1712 sometimes a secondary address, function will send them over the
1714 <tag/Notes/<itemize>
1715 <item>The function is only available as fastcall function, so it may
1716 only be used in presence of a prototype.
1718 <tag/Availability/cc65
1720 <ref id="cbm_k_open" name="cbm_k_open">,
1721 <ref id="cbm_k_basin" name="cbm_k_basin">,
1722 <ref id="cbm_k_getin" name="cbm_k_getin">
1728 <sect1>cbm_k_ciout<label id="cbm_k_ciout"><p>
1732 <tag/Function/Transmit a byte over the serial bus
1733 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
1734 <tag/Declaration/<tt/void __fastcall__ cbm_k_ciout (unsigned char C);/
1735 <tag/Description/Purpose of this function is to send a byte of data over
1736 the serial bus. In order for the data to be received, the serial
1737 device must have first been commanded to LISTEN and been given a
1738 secondary address if necessary. This routine always buffers the
1739 current character, and defers sending it until the next byte is
1740 buffered. When the UNLISTEN command is sent, the last byte will be
1741 sent with an End or Identify (EOI).
1742 <tag/Notes/<itemize>
1743 <item>The function is only available as fastcall function, so it may
1744 only be used in presence of a prototype.
1746 <tag/Availability/cc65
1748 <ref id="cbm_k_listen" name="cbm_k_listen">,
1749 <ref id="cbm_k_unlsn" name="cbm_k_unlsn">
1755 <sect1>cbm_k_ckout<label id="cbm_k_ckout"><p>
1759 <tag/Function/Designate a Logical File As the Current Output Channel
1760 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
1761 <tag/Declaration/<tt/unsigned char __fastcall__ cbm_k_ckout (unsigned char FN);/
1762 <tag/Description/If you wish to
1763 output data to any device other than the screen, this routine must be
1764 called after OPENing the device, and before you output a data byte
1765 with the cbm_k_bsout() function. When called, the function will designate the
1766 logical file whose file number was supplied as the current
1767 file, its device as the current device, and its secondary address as
1768 the current secondary address. If the device on the channel uses the
1769 serial bus, and therefore requires a LISTEN command and possibly a
1770 secondary address, this information will be sent on the bus.
1771 <tag/Notes/<itemize>
1772 <item>The function is only available as fastcall function, so it may
1773 only be used in presence of a prototype.
1775 <tag/Availability/cc65
1777 <ref id="cbm_k_bsout" name="cbm_k_bsout">,
1778 <ref id="cbm_k_listen" name="cbm_k_listen">
1784 <sect1>cbm_k_clall<label id="cbm_k_clall"><p>
1788 <tag/Function/Close All Logical I/O Files
1789 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
1790 <tag/Declaration/<tt/void cbm_k_clall (void);/
1791 <tag/Description/It closes all
1792 open files, by resetting the index into open files to
1793 zero and restores the default I/O devices.
1794 <tag/Notes/<itemize>
1797 <tag/Availability/cc65
1799 <ref id="cbm_k_open" name="cbm_k_open">,
1800 <ref id="cbm_k_close" name="cbm_k_close">
1806 <sect1>cbm_k_close<label id="cbm_k_close"><p>
1810 <tag/Function/Close a Logical I/O File
1811 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
1812 <tag/Declaration/<tt/void __fastcall__ cbm_k_close (unsigned char FN);/
1813 <tag/Description/It is used to
1814 close a logical file after all I/O operations involving that file have
1816 <tag/Notes/<itemize>
1817 <item>The function is only available as fastcall function, so it may
1818 only be used in presence of a prototype.
1820 <tag/Availability/cc65
1822 <ref id="cbm_k_open" name="cbm_k_open">,
1823 <ref id="cbm_k_clall" name="cbm_k_clall">
1829 <sect1>cbm_k_clrch<label id="cbm_k_clrch"><p>
1833 <tag/Function/Restore Current Input and Output Devices to the Default Devices
1834 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
1835 <tag/Declaration/<tt/void cbm_k_clrch (void);/
1836 <tag/Description/It sets the
1837 current input device to the keyboard, and the current output device to
1838 the screen. Also, if the current input device was formerly a serial
1839 device, the routine sends it an UNTALK command on the serial bus, and
1840 if a serial device was formerly the current output device, the routine
1841 sends it an UNLISTEN command.
1842 <tag/Notes/<itemize>
1845 <tag/Availability/cc65
1847 <ref id="cbm_k_chkin" name="cbm_k_chkin">,
1848 <ref id="cbm_k_ckout" name="cbm_k_ckout">
1854 <sect1>cbm_k_getin<label id="cbm_k_getin"><p>
1858 <tag/Function/Get One Byte from the Input Device
1859 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
1860 <tag/Declaration/<tt/unsigned char cbm_k_getin (void);/
1861 <tag/Description/Function gets a character from the current input device.
1862 <tag/Notes/<itemize>
1865 <tag/Availability/cc65
1867 <ref id="cbm_k_basin" name="cbm_k_basin">
1873 <sect1>cbm_k_iobase<label id="cbm_k_iobase"><p>
1877 <tag/Function/Return Base Address of Memory-Mapped I/O Devices
1878 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
1879 <tag/Declaration/<tt/unsigned cbm_k_iobase (void);/
1880 <tag/Description/This function returns the address of
1881 the memory section where the memory mapped I/O devices are located. This
1882 address can then be used with an offset to access the memory mapped I/O
1883 devices in the Commodore 64. The offset is the number of locations from
1884 the beginning of the page on which the I/O register you want is located.
1885 This function exists to provide compatibility between the Commodore 64,
1886 VIC-20, and future models of the Commodore 64. If the I/O locations for
1887 a program are set by a call to this function, they should
1888 still remain compatible with future versions of the Commodore 64, the
1890 <tag/Notes/<itemize>
1893 <tag/Availability/cc65
1901 <sect1>cbm_k_listen<label id="cbm_k_listen"><p>
1905 <tag/Function/Command a device on the serial bus to LISTEN
1906 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
1907 <tag/Declaration/<tt/void __fastcall__ cbm_k_listen (unsigned char dev);/
1908 <tag/Description/This function will command a device on the serial bus to
1909 receive data. The KERNAL routine will OR the supplied device number bit by bit
1910 to convert it to a listen address, then transmits this data as a command on
1911 the serial bus. The specified device will then go into listen mode, and
1912 be ready to accept information.
1913 <tag/Notes/<itemize>
1914 <item>The function is only available as fastcall function, so it may
1915 only be used in presence of a prototype.
1917 <tag/Availability/cc65
1919 <ref id="cbm_k_unlsn" name="cbm_k_unlsn">,
1925 <sect1>cbm_k_load<label id="cbm_k_load"><p>
1929 <tag/Function/Load RAM from a Device
1930 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
1931 <tag/Declaration/<tt/unsigned int __fastcall__ cbm_k_load(unsigned char flag, unsigned addr);/
1932 <tag/Description/This function LOADs data bytes from any input device directly into the memory.
1933 It can also be used for a verify operation, comparing data from a device with the data already in
1934 memory, while leaving the data stored in RAM unchanged.
1935 The flag must be set to 0 for a LOAD operation, or 1 for a
1936 verify, If the input device is OPENed with a secondary address (SA) of 0
1937 the header information from the device is ignored. In this case, the starting address for the load must be supplied.
1938 If the device is addressed with a secondary address of 1, then the data is
1939 loaded into memory starting at the location specified by the header.
1940 Function returns the address of the highest RAM location loaded.
1941 Before this function can be called, the KERNAL SETLFS, and SETNAM
1942 routines must be called.
1943 <tag/Notes/<itemize>
1944 <item>The function is only available as fastcall function, so it may
1945 only be used in presence of a prototype.
1947 <tag/Availability/cc65
1949 <ref id="cbm_k_save" name="cbm_k_save">,
1950 <ref id="cbm_k_setlfs" name="cbm_k_setlfs">,
1951 <ref id="cbm_k_setnam" name="cbm_k_setnam">
1957 <sect1>cbm_k_open<label id="cbm_k_open"><p>
1961 <tag/Function/Open a Logical I/O File
1962 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
1963 <tag/Declaration/<tt/unsigned char cbm_k_open (void);/
1964 <tag/Description/This function assigns a logical file to a device, so that it can be used for
1965 Input/Output operations. In order to specify the logical file number,
1966 the device number, and the secondary address if any, the cbm_k_setlfs() function must first be called.
1967 Likewise, in order to designate the filename, the cbm_k_setnam() function must be used first. After these two
1968 functions are called, cbm_k_open() is then called.
1969 <tag/Notes/<itemize>
1972 <tag/Availability/cc65
1974 <ref id="cbm_k_close" name="cbm_k_close">,
1975 <ref id="cbm_k_setlfs" name="cbm_k_setlfs">,
1976 <ref id="cbm_k_setnam" name="cbm_k_setnam">
1982 <sect1>cbm_k_readst<label id="cbm_k_readst"><p>
1986 <tag/Function/Read status word
1987 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
1988 <tag/Declaration/<tt/unsigned char cbm_k_readst (void);/
1989 <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.
1990 <tag/Notes/<itemize>
1993 <tag/Availability/cc65
2001 <sect1>cbm_k_save<label id="cbm_k_save"><p>
2005 <tag/Function/Save RAM to a Device
2006 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
2007 <tag/Declaration/<tt/unsigned char __fastcall__ cbm_k_save(unsigned int start, unsigned int end)/
2008 <tag/Description/This function saves a section of memory. The cbm_k_setlfs() and cbm_k_setnam() functions must be
2009 used before calling this function. However, a file name is not required to
2010 SAVE to device 1 (the Datassette(TM) recorder). Any attempt to save to
2011 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.
2012 <tag/Notes/<itemize>
2013 <item>The function is only available as fastcall function, so it may
2014 only be used in presence of a prototype.
2016 <tag/Availability/cc65
2018 <ref id="cbm_k_load" name="cbm_k_load">,
2019 <ref id="cbm_k_setlfs" name="cbm_k_setlfs">,
2020 <ref id="cbm_k_setnam" name="cbm_k_setnam">
2026 <sect1>cbm_k_scnkey<label id="cbm_k_scnkey"><p>
2030 <tag/Function/Scan the keyboard matrix.
2031 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
2032 <tag/Declaration/<tt/void cbm_k_scnkey (void);/
2033 <tag/Description/This function looks at the switches in the keyboard, to see
2034 if any of them are being pressed. If they are, then code numbers for them are
2035 stored in RAM. Other functions use those numbers to input text. Normally,
2036 the keyboard is scanned by the Kernal's Interrupt Service Routine. But, if
2037 you divert the "Jiffy interrupt" to a C-code ISR, then that ISR must call this
2038 function, in order to provide input from the keyboard.
2039 <tag/Availability/cc65
2041 <ref id="cbm_k_getin" name="cbm_k_getin">,
2042 <ref id="cbm_k_udtim" name="cbm_k_udtim">,
2043 <ref id="cgetc" name="cgetc">,
2044 <!-- <ref id="getc" name="getc"> -->
2045 <!-- <ref id="getchar" name="getchar"> -->
2051 <sect1>cbm_k_setlfs<label id="cbm_k_setlfs"><p>
2055 <tag/Function/Set up a logical file
2056 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
2057 <tag/Declaration/<tt/void __fastcall__ cbm_k_setlfs (unsigned char LFN, unsigned char DEV, unsigned char SA);/
2058 <tag/Description/This functions sets up the logical file by setting its number, device address,
2059 and secondary address.
2060 <tag/Notes/<itemize>
2061 <item>The function is only available as fastcall function, so it may
2062 only be used in presence of a prototype.
2064 <tag/Availability/cc65
2066 <ref id="cbm_k_setnam" name="cbm_k_setnam">
2072 <sect1>cbm_k_setnam<label id="cbm_k_setnam"><p>
2076 <tag/Function/Set Filename Parameters
2077 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
2078 <tag/Declaration/<tt/void __fastcall__ cbm_k_setnam (const char* Name);/
2079 <tag/Description/This function is used to set up the file name for the OPEN,
2080 SAVE, or LOAD operations.
2081 <tag/Notes/<itemize>
2082 <item>The function is only available as fastcall function, so it may
2083 only be used in presence of a prototype.
2085 <tag/Availability/cc65
2087 <ref id="cbm_k_open" name="cbm_k_open">,
2088 <ref id="cbm_k_load" name="cbm_k_load">,
2089 <ref id="cbm_k_save" name="cbm_k_save">
2095 <sect1>cbm_k_talk<label id="cbm_k_talk"><p>
2099 <tag/Function/Commands device to TALK
2100 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
2101 <tag/Declaration/<tt/void __fastcall__ cbm_k_talk (unsigned char dev);/
2102 <tag/Description/When called, it ORs the device number with the TALK code (64, $40) and sends it on the serial
2103 bus. This commands the device to TALK.
2104 <tag/Notes/<itemize>
2105 <item>The function is only available as fastcall function, so it may
2106 only be used in presence of a prototype.
2108 <tag/Availability/cc65
2110 <ref id="cbm_k_acptr" name="cbm_k_acptr">
2116 <sect1>cbm_k_udtim<label id="cbm_k_udtim"><p>
2120 <tag/Function/Update the Jiffy clock.
2121 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
2122 <tag/Declaration/<tt/void cbm_k_udtim (void);/
2123 <tag/Description/This function adds one count to the Jiffy clock. That clock
2124 counts sixtieths of a second. It is used by the library's <tt/clock()/
2125 function. Normally, the Jiffy clock is updated by the Kernal's Interrupt
2126 Service Routine. But, if you divert the "Jiffy interrupt" to a C-code ISR,
2127 then that ISR must call this function, in order to keep the clock valid.
2128 <tag/Availability/cc65
2130 <ref id="cbm_k_scnkey" name="cbm_k_scnkey">,
2131 <ref id="clock" name="clock">
2137 <sect1>cbm_k_unlsn<label id="cbm_k_unlsn"><p>
2141 <tag/Function/Send an UNLISTEN command
2142 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
2143 <tag/Declaration/<tt/void cbm_k_unlsn (void);/
2144 <tag/Description/This function commands all devices on the serial bus to
2145 stop receiving data from the host computer (i.e., UNLISTEN). Calling this
2146 function results in an UNLISTEN command being transmitted on the serial
2147 bus. Only devices previously commanded to LISTEN are affected. This
2148 function is normally used after the host computer is finished sending data
2149 to external devices. Sending the UNLISTEN commands the listening devices
2150 to get off the serial bus so it can be used for other purposes.
2151 <tag/Notes/<itemize>
2154 <tag/Availability/cc65
2156 <ref id="cbm_k_listen" name="cbm_k_listen">
2162 <sect1>cclear<label id="cclear"><p>
2166 <tag/Function/Clear part of a line (write a given number of spaces).
2167 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2168 <tag/Declaration/<tt/void __fastcall__ cclear (unsigned char length);/
2169 <tag/Description/The function clears part of a line by writing <tt/length/
2170 spaces in the current text color.
2171 <tag/Notes/<itemize>
2172 <item>The function is only available as fastcall function, so it may
2173 only be used in presence of a prototype.
2175 <tag/Availability/cc65
2177 <ref id="cclearxy" name="cclearxy">,
2178 <ref id="clrscr" name="clrscr">
2184 <sect1>cclearxy<label id="cclearxy"><p>
2188 <tag/Function/Clear part of a line (write a given number of spaces) starting
2189 at a specific screen position.
2190 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2191 <tag/Declaration/<tt/void __fastcall__ cclearxy (unsigned char x, unsigned char y, unsigned char length);/
2192 <tag/Description/The function moves the cursor to a specific position, and
2193 will then clear part of the line by writing <tt/length/ spaces in the current
2195 <tag/Notes/<itemize>
2196 <item>The function is only available as fastcall function, so it may
2197 only be used in presence of a prototype.
2199 <tag/Availability/cc65
2201 <ref id="cclear" name="cclear">,
2202 <ref id="clrscr" name="clrscr">
2208 <sect1>cgetc<label id="cgetc"><p>
2212 <tag/Function/Read a character from the keyboard.
2213 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2214 <tag/Declaration/<tt/char cgetc (void);/
2215 <tag/Description/The function reads a character from the keyboard. If there is
2216 no character available, <tt/cgetc()/ waits until the user presses a key. If the
2217 cursor is enabled by use of the <tt/cursor/ function, a blinking cursor is
2218 displayed while waiting.
2219 <tag/Notes/<itemize>
2220 <item>If the system supports a keyboard buffer, <tt/cgetc()/ will fetch a key
2221 from that buffer; and, wait only if the buffer is empty.
2222 <item>The keyboard must be scanned periodically, in order for this function to
2223 see anything that you type. (See the description of <tt/cbm_k_scnkey()/.)
2225 <tag/Availability/cc65
2227 <ref id="cbm_k_scnkey" name="cbm_k_scnkey">,
2228 <ref id="cursor" name="cursor">,
2229 <ref id="kbhit" name="kbhit">
2235 <sect1>chline<label id="chline"><p>
2239 <tag/Function/Output a horizontal line in text mode.
2240 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2241 <tag/Declaration/<tt/void __fastcall__ chline (unsigned char length);/
2242 <tag/Description/The function outputs a horizontal line with the given length
2243 starting at the current cursor position.
2244 <tag/Notes/<itemize>
2245 <item>The character used to draw the horizontal line is system dependent.
2246 If available, a line drawing character is used. Drawing a line that is partially
2247 off screen leads to undefined behaviour.
2248 <item>The function is only available as fastcall function, so it may only be
2249 used in presence of a prototype.
2251 <tag/Availability/cc65
2253 <ref id="chlinexy" name="chlinexy">,
2254 <ref id="cvline" name="cvline">,
2255 <ref id="cvlinexy" name="cvlinexy">
2261 <sect1>chlinexy<label id="chlinexy"><p>
2265 <tag/Function/Output a horizontal line at a given position in text mode.
2266 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2267 <tag/Declaration/<tt/void __fastcall__ chlinexy (unsigned char x, unsigned char y, unsigned char length);/
2268 <tag/Description/The function outputs a horizontal line with the given length
2269 starting at a given position.
2270 <tag/Notes/<itemize>
2271 <item>The character used to draw the horizontal line is system dependent.
2272 If available, a line drawing character is used. Drawing a line that is partially
2273 off screen leads to undefined behaviour.
2274 <item>The function is only available as fastcall function, so it may only be
2275 used in presence of a prototype.
2277 <tag/Availability/cc65
2279 <ref id="chline" name="chline">,
2280 <ref id="cvline" name="cvline">,
2281 <ref id="cvlinexy" name="cvlinexy">
2287 <sect1>clearerr<label id="clearerr"><p>
2291 <tag/Function/Clear error and end-of-file status of a stream.
2292 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
2293 <tag/Declaration/<tt/void __fastcall__ clearerr (FILE* f);/
2294 <tag/Description/<tt/clearerr/ clears the error and end-of-file status
2295 indicators for the stream <tt/f/.
2296 <tag/Notes/<itemize>
2297 <item>The function is only available as fastcall function, so it may only be
2298 used in presence of a prototype.
2300 <tag/Availability/ISO 9899
2302 <ref id="feof" name="feof">,
2303 <ref id="ferror" name="ferror">
2309 <sect1>clock<label id="clock"><p>
2313 <tag/Function/Determine the processor time used.
2314 <tag/Header/<tt/<ref id="time.h" name="time.h">/
2315 <tag/Declaration/<tt/clock_t clock (void);/
2316 <tag/Description/The <tt/clock/ function returns an approximaton of processor
2317 time used by the program. The time is returned in implementation-defined
2318 units. It can be converted to seconds by dividing by the value of the macro
2319 <tt/CLOCKS_PER_SEC/.
2320 <tag/Notes/<itemize>
2321 <item>Since the machines that cc65-generated programs run on cannot run multiple
2322 processes, the function actually will return the time since some
2323 implementation-defined point in the past.
2324 <item>The Jiffy clock must be "running", in order for this function to return
2325 changing values. (See the description of <tt/cbm_k_udtim()/.)
2327 <tag/Availability/ISO 9899
2329 <ref id="cbm_k_udtim" name="cbm_k_udtim">,
2330 <ref id="time" name="time">
2336 <sect1>clrscr<label id="clrscr"><p>
2340 <tag/Function/Clear the text screen.
2341 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2342 <tag/Declaration/<tt/void clrscr (void);/
2343 <tag/Description/The function clears the text screen and moves the cursor to
2344 the upper left corner.
2345 <tag/Availability/cc65
2347 <ref id="cclear" name="cclear">,
2348 <ref id="cclearxy" name="cclearxy">
2354 <sect1>close<label id="close"><p>
2358 <tag/Function/Close a file descriptor.
2359 <tag/Header/<tt/<ref id="fcntl.h" name="fcntl.h">/
2360 <tag/Declaration/<tt/int __fastcall__ close (int fd);/
2361 <tag/Description/The function closes the given file descriptor. It returns zero
2362 on success and -1 on error. If an error occurs, the cause can be determined by
2363 reading the <tt/errno/ variable.
2364 <tag/Notes/<itemize>
2365 <item>The function is only available as fastcall function, so it may only
2366 be used in presence of a prototype.
2368 <tag/Availability/POSIX 1003.1
2370 <ref id="creat" name="creat">,
2371 <ref id="open" name="open">
2377 <sect1>closedir<label id="closedir"><p>
2381 <tag/Function/Close a directory.
2382 <tag/Header/<tt/<ref id="dirent.h" name="dirent.h">/
2383 <tag/Declaration/<tt/int __fastcall__ closedir (DIR* dir);/
2384 <tag/Description/The function closes the given directory descriptor. It returns
2385 zero on success and -1 on error. If an error occurs, the cause can be determined
2386 by reading the <tt/errno/ variable.
2387 <tag/Notes/<itemize>
2388 <item>The function is only available as fastcall function, so it may only
2389 be used in presence of a prototype.
2391 <tag/Availability/POSIX 1003.1
2393 <ref id="opendir" name="opendir">,
2394 <ref id="readdir" name="readdir">
2400 <sect1>creat<label id="creat"><p>
2404 <tag/Function/Create a file.
2405 <tag/Header/<tt/<ref id="fcntl.h" name="fcntl.h">/
2406 <tag/Declaration/<tt/int __fastcall__ creat (const char* name, unsigned mode);/
2407 <tag/Description/<tt/creat/ creates a new file and returns the file descriptor
2408 associated with it. On error, -1 is returned and an error code is stored in
2410 <tag/Notes/<itemize>
2411 <item><tt/creat/ is identical to calling <tt/<ref id="open" name="open">/ with
2412 <tt/flags/ equal to <tt/O_WRONLY | O_CREAT | O_TRUNC/.
2413 <item>The function is only available as fastcall function, so it may only
2414 be used in presence of a prototype.
2416 <tag/Availability/POSIX 1003.1
2418 <ref id="close" name="close">,
2419 <ref id="open" name="open">
2425 <sect1>cprintf<label id="cprintf"><p>
2429 <tag/Function/Formatted output to the console.
2430 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2431 <tag/Declaration/<tt/int cprintf (const char* format, ...);/
2432 <tag/Description/The arguments are converted to text where necessary and
2433 formatted according to the format string given. The resulting string is output
2434 to the console. <tt/cprintf/ supports the same format specifiers as
2435 <tt/printf/. <!-- <tt/<ref id="printf" name="printf">/. -->
2436 <tag/Notes/<itemize>
2437 <item>Like all other <tt/conio/ output functions, <tt/cprintf/ distinguishes
2438 between <tt/\r/ and <tt/\n/.
2440 <tag/Availability/cc65
2442 <ref id="cputc" name="cputc">,
2443 <ref id="cputcxy" name="cputcxy">,
2444 <ref id="cputs" name="cputs">,
2445 <ref id="cputsxy" name="cputsxy">,
2446 <ref id="vcprintf" name="vcprintf">
2452 <sect1>cputc<label id="cputc"><p>
2456 <tag/Function/Output a character directly to the console.
2457 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2458 <tag/Declaration/<tt/void __fastcall__ cputc (char c);/
2459 <tag/Description/Output one character to the console at the current cursor
2461 <tag/Notes/<itemize>
2462 <item>Like all other <tt/conio/ output functions, <tt/cputc/ distinguishes
2463 between <tt/\r/ and <tt/\n/.
2464 <item>The function is only available as fastcall function, so it may only
2465 be used in presence of a prototype.
2467 <tag/Availability/cc65
2469 <ref id="cprintf" name="cprintf">,
2470 <ref id="cputcxy" name="cputcxy">,
2471 <ref id="cputs" name="cputs">,
2472 <ref id="cputsxy" name="cputsxy">,
2473 <ref id="vcprintf" name="vcprintf">
2479 <sect1>cputcxy<label id="cputcxy"><p>
2483 <tag/Function/Output a character at a specific screen position.
2484 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2485 <tag/Declaration/<tt/void __fastcall__ cputcxy (unsigned char x, unsigned char y, char c);/
2486 <tag/Description/<tt/cputcxy/ moves the cursor to the given x/y position on
2487 the screen and outputs one character.
2488 <tag/Notes/<itemize>
2489 <item>Like all other <tt/conio/ output functions, <tt/cputcxy/ distinguishes
2490 between <tt/\r/ and <tt/\n/.
2491 <item>The function is only available as fastcall function, so it may only
2492 be used in presence of a prototype.
2494 <tag/Availability/cc65
2496 <ref id="cprintf" name="cprintf">,
2497 <ref id="cputc" name="cputc">,
2498 <ref id="cputs" name="cputs">,
2499 <ref id="cputsxy" name="cputsxy">,
2500 <ref id="vcprintf" name="vcprintf">
2506 <sect1>cputs<label id="cputs"><p>
2510 <tag/Function/Output a string directly to the console.
2511 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2512 <tag/Declaration/<tt/void __fastcall__ cputs (const char* s);/
2513 <tag/Description/The function outputs the given string on the console at the
2514 current cursor position.
2515 <tag/Notes/<itemize>
2516 <item>Like all other <tt/conio/ output functions, <tt/cputs/ distinguishes
2517 between <tt/\r/ and <tt/\n/.
2518 <item>The function is only available as fastcall function, so it may only
2519 be used in presence of a prototype.
2521 <tag/Availability/cc65
2523 <ref id="cprintf" name="cprintf">,
2524 <ref id="cputc" name="cputc">,
2525 <ref id="cputcxy" name="cputcxy">,
2526 <ref id="cputsxy" name="cputsxy">,
2527 <ref id="vcprintf" name="vcprintf">
2533 <sect1>cputsxy<label id="cputsxy"><p>
2537 <tag/Function/Output a string to the console at a given position.
2538 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2539 <tag/Declaration/<tt/void __fastcall__ cputsxy (unsigned char x, unsigned char y, const char* s);/
2540 <tag/Description/<tt/cputsxy/ moves the cursor to the given x/y position,
2541 and outputs the string <tt/s/.
2542 <tag/Notes/<itemize>
2543 <item>Like all other <tt/conio/ output functions, <tt/cputsxy/ distinguishes
2544 between <tt/\r/ and <tt/\n/.
2545 <item>The function is only available as fastcall function, so it may only
2546 be used in presence of a prototype.
2548 <tag/Availability/cc65
2550 <ref id="cprintf" name="cprintf">,
2551 <ref id="cputc" name="cputc">,
2552 <ref id="cputcxy" name="cputcxy">,
2553 <ref id="cputs" name="cputs">,
2554 <ref id="vcprintf" name="vcprintf">
2560 <sect1>cursor<label id="cursor"><p>
2564 <tag/Function/Enable/disable a blinking cursor when waiting for keyboard input.
2565 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2566 <tag/Declaration/<tt/unsigned char __fastcall__ cursor (unsigned char onoff);/
2567 <tag/Description/If the argument to the function is non zero, a blinking cursor
2568 will be enabled when the <tt/cgetc/ function waits for input from the keyboard.
2569 If the argument is zero, <tt/cgetc/ will wait without a blinking cursor.
2570 <tag/Notes/<itemize>
2571 <item>The function is only available as fastcall function, so it may only
2572 be used in presence of a prototype.
2574 <tag/Availability/cc65
2576 <ref id="cgetc" name="cgetc">,
2577 <ref id="kbhit" name="kbhit">
2583 <sect1>cvline<label id="cvline"><p>
2587 <tag/Function/Output a vertical line in text mode.
2588 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2589 <tag/Declaration/<tt/void __fastcall__ cvline (unsigned char length);/
2590 <tag/Description/The function outputs a vertical line with the given length
2591 starting at the current cursor position.
2592 <tag/Notes/<itemize>
2593 <item>The character used to draw the vertical line is system dependent.
2594 If available, a line drawing character is used. Drawing a line that is partially
2595 off screen leads to undefined behaviour.
2596 <item>The function is only available as fastcall function, so it may only be
2597 used in presence of a prototype.
2599 <tag/Availability/cc65
2601 <ref id="chline" name="chline">,
2602 <ref id="chlinexy" name="chlinexy">,
2603 <ref id="cvlinexy" name="cvlinexy">
2609 <sect1>cvlinexy<label id="cvlinexy"><p>
2613 <tag/Function/Output a vertical line at a given position in text mode.
2614 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2615 <tag/Declaration/<tt/void __fastcall__ cvlinexy (unsigned char x, unsigned char y, unsigned char length);/
2616 <tag/Description/The function outputs a vertical line with the given length
2617 starting at a given position.
2618 <tag/Notes/<itemize>
2619 <item>The character used to draw the vertical line is system dependent.
2620 If available, a line drawing character is used. Drawing a line that is partially
2621 off screen leads to undefined behaviour.
2622 <item>The function is only available as fastcall function, so it may only be
2623 used in presence of a prototype.
2625 <tag/Availability/cc65
2627 <ref id="chline" name="chline">,
2628 <ref id="chlinexy" name="chlinexy">,
2629 <ref id="cvline" name="cvline">
2635 <sect1>div<label id="div"><p>
2639 <tag/Function/Divide two ints and return quotient and remainder.
2640 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
2641 <tag/Declaration/<tt/div_t __fastcall__ div (int numer, int denom);/
2642 <tag/Description/<tt/div/ divides <tt/numer/ by <tt/denom/ and returns the
2643 quotient and remainder in a <tt/div_t/ structure.
2644 <tag/Notes/<itemize>
2645 <item>The function is only available as fastcall function, so it may only
2646 be used in presence of a prototype.
2648 <tag/Availability/ISO 9899
2656 <sect1>doesclrscrafterexit<label id="doesclrscrafterexit"><p>
2660 <tag/Function/Determines whether the screen is going to be cleared after program exit.
2661 <tag/Header/<tt/<ref id="cc65.h" name="cc65.h">/
2662 <tag/Declaration/<tt/unsigned char doesclrscrafterexit (void);/
2663 <tag/Description/The function returns zero if the screen won't be cleared immediately after
2664 program termination. It returns a non-zero value if it will.
2665 <tag/Notes/<itemize>
2666 <item>Some systems, maybe depending on configuration, immediately clear the screen
2667 after a program exits. Therefore it might be difficult to read
2668 the last messages printed by the program prior to its exit. This function can be used
2669 to decide if a delay or wait for a key press should be executed when then program
2672 <tag/Availability/cc65
2680 printf("Hello World\n");
2681 if (doesclrscrafterexit())
2690 <sect1>em_commit<label id="em_commit"><p>
2694 <tag/Function/Commit changes into extended memory.
2695 <tag/Header/<tt/<ref id="em.h" name="em.h">/
2696 <tag/Declaration/<tt/void em_commit (void);/
2697 <tag/Description/Commit changes in the memory window to extended storage. If
2698 the contents of the memory window have been changed, these changes may be lost
2699 if <tt/<ref id="em_map" name="em_map">/, <tt/<ref id="em_use" name="em_use">/,
2700 <tt/<ref id="em_copyfrom" name="em_copyfrom">/ or <tt/<ref id="em_copyto"
2701 name="em_copyto">/ are called without calling <tt/em_commit/ first.
2702 <tag/Notes/<itemize>
2703 <item>Calling <tt/em_commit/ does not necessarily mean that changes to the
2704 memory window are discarded, it does just mean that the drivers is allowed
2706 <item>The function is only available as fastcall function, so it may only be
2707 used in presence of a prototype.
2708 <item>The function produces undefined results if no extended memory driver is
2711 <tag/Availability/cc65
2713 <ref id="em_load_driver" name="em_load_driver">,
2714 <ref id="em_map" name="em_map">,
2715 <ref id="em_use" name="em_use">
2721 <sect1>em_copyfrom<label id="em_copyfrom"><p>
2725 <tag/Function/Copy from extended into normal memory.
2726 <tag/Header/<tt/<ref id="em.h" name="em.h">/
2727 <tag/Declaration/<tt/void __fastcall__ em_copyfrom (const struct em_copy* copy_data);/
2728 <tag/Description/Copy data from extended memory into linear memory. Source and
2729 target addresses as well as the number of bytes to transfer are specified in
2730 the <tt/em_copy/ structure that is passed as a parameter.
2731 <tag/Notes/<itemize>
2732 <item>Calling <tt/em_copyfrom/ will invalidate the memory window, so if you
2733 made any changes to the data in the window, call <tt/<ref id="em_commit"
2734 name="em_commit">/ first, or the changes are lost.
2735 <item>The function is only available as fastcall function, so it may only be
2736 used in presence of a prototype.
2737 <item>The function produces undefined results if no extended memory driver is
2740 <tag/Availability/cc65
2742 <ref id="em_commit" name="em_commit">,
2743 <ref id="em_copyto" name="em_copyto">,
2744 <ref id="em_load_driver" name="em_load_driver">
2750 <sect1>em_copyto<label id="em_copyto"><p>
2754 <tag/Function/Copy from normal into extended memory.
2755 <tag/Header/<tt/<ref id="em.h" name="em.h">/
2756 <tag/Declaration/<tt/void __fastcall__ em_copyto (const struct em_copy* copy_data);/
2757 <tag/Description/Copy data from linear into extended memory. Source and
2758 target addresses as well as the number of bytes to transfer are specified in
2759 the <tt/em_copy/ structure that is passed as a parameter.
2760 <tag/Notes/<itemize>
2761 <item>Calling <tt/em_copyto/ will invalidate the memory window, so if you
2762 made any changes to the data in the window, call <tt/<ref id="em_commit"
2763 name="em_commit">/ first, or the changes are lost.
2764 <item>The function is only available as fastcall function, so it may only be
2765 used in presence of a prototype.
2766 <item>The function produces undefined results if no extended memory driver is
2769 <tag/Availability/cc65
2771 <ref id="em_commit" name="em_commit">,
2772 <ref id="em_copyfrom" name="em_copyfrom">,
2773 <ref id="em_load_driver" name="em_load_driver">
2779 <sect1>em_install<label id="em_install"><p>
2783 <tag/Function/Install an already loaded extended memory driver.
2784 <tag/Header/<tt/<ref id="em.h" name="em.h">/
2785 <tag/Declaration/<tt/unsigned char _fastcall__ em_install (void* driver);/
2786 <tag/Description/The function installs an already loaded extended memory driver
2787 and returns an error code. The function may be used to install a driver linked
2788 statically to the program.
2789 <tag/Notes/<itemize>
2790 <item>Not all drivers are able to detect if the supported hardware is really
2792 <item>The function is only available as fastcall function, so it may only be
2793 used in presence of a prototype.
2795 <tag/Availability/cc65
2797 <ref id="em_load_driver" name="em_load_driver">,
2798 <ref id="em_uninstall" name="em_uninstall">,
2799 <ref id="em_unload" name="em_unload">
2805 <sect1>em_load_driver<label id="em_load_driver"><p>
2809 <tag/Function/Load and initialize an extended memory driver.
2810 <tag/Header/<tt/<ref id="em.h" name="em.h">/
2811 <tag/Declaration/<tt/void __fastcall__ em_load_driver (const char* name);/
2812 <tag/Description/Load an extended memory driver into memory and initialize
2813 it. The function returns an error code that tells if all this has been
2815 <tag/Notes/<itemize>
2816 <item>Not all drivers are able to detect if the supported hardware is really
2818 <item>The function is only available as fastcall function, so it may only be
2819 used in presence of a prototype.
2820 <item>The driver is loaded by name, so currently you must know the type of
2821 extended memory that should be supported. There is no autodetect capability.
2823 <tag/Availability/cc65
2825 <ref id="em_unload" name="em_unload">
2831 <sect1>em_map<label id="em_map"><p>
2835 <tag/Function/Make a page of extended memory accessible.
2836 <tag/Header/<tt/<ref id="em.h" name="em.h">/
2837 <tag/Declaration/<tt/void* __fastcall__ em_map (unsigned page);/
2838 <tag/Description/The function maps one page of extended memory into linear
2839 memory and returns a pointer to the page frame. Depending on the hardware
2840 and driver, the data is either mapped into the address space or transfered
2841 into a buffer. If you don't need the actual contents of the page (for example
2842 because you're going to overwrite it completely), it is better to call
2843 <tt/<ref id="em_use" name="em_use">/ instead. <tt/em_use/ will not transfer the
2844 data if it is possible to avoid that.
2845 <tag/Notes/<itemize>
2846 <item>Calling <tt/em_map/ will invalidate the memory window, so if you
2847 made any changes to the data in the window, call <tt/<ref id="em_commit"
2848 name="em_commit">/ first, or the changes are lost.
2849 <item>The function is only available as fastcall function, so it may only be
2850 used in presence of a prototype.
2851 <item>The function produces undefined results if no extended memory driver is
2854 <tag/Availability/cc65
2856 <ref id="em_commit" name="em_commit">,
2857 <ref id="em_load_driver" name="em_load_driver">,
2858 <ref id="em_use" name="em_use">
2864 <sect1>em_pagecount<label id="em_pagecount"><p>
2868 <tag/Function/Return the number of available extended memory pages.
2869 <tag/Header/<tt/<ref id="em.h" name="em.h">/
2870 <tag/Declaration/<tt/unsigned em_pagecount (void);/
2871 <tag/Description/The function returns the size of the extended memory supported
2872 by the driver in 256 byte pages.
2873 <tag/Notes/<itemize>
2874 <item>The function returns zero if no extended memory driver is loaded.
2875 <item>The function may return zero if the supported hardware was not detected.
2877 <tag/Availability/cc65
2879 <ref id="em_load_driver" name="em_load_driver">
2885 <sect1>em_uninstall<label id="em_uninstall"><p>
2889 <tag/Function/Uninstall an already loaded extended memory driver.
2890 <tag/Header/<tt/<ref id="em.h" name="em.h">/
2891 <tag/Declaration/<tt/unsigned char em_uninstall (void);/
2892 <tag/Description/The function uninstalls an already loaded extended memory
2893 driver but doesn't remove it from memory.
2894 <tag/Notes/<itemize>
2895 <item>If the driver has been loaded using <tt/<ref id="em_load_driver"
2896 name="em_load_driver">/, <tt/<ref id="em_unload" name="em_unload">/
2897 should be used instead of <tt/em_uninstall/ so the driver is also removed
2900 <tag/Availability/cc65
2902 <ref id="em_install" name="em_install">,
2903 <ref id="em_load_driver" name="em_load_driver">,
2904 <ref id="em_unload" name="em_unload">
2910 <sect1>em_unload<label id="em_unload"><p>
2914 <tag/Function/Unload an extended memory driver.
2915 <tag/Header/<tt/<ref id="em.h" name="em.h">/
2916 <tag/Declaration/<tt/unsigned char em_unload (void);/
2917 <tag/Description/The function unloads a loaded extended memory driver and
2918 frees all memory allocated for the driver.
2919 <tag/Notes/<itemize>
2920 <item>The function does nothing if no driver is loaded.
2922 <tag/Availability/cc65
2924 <ref id="em_load_driver" name="em_load_driver">
2930 <sect1>em_use<label id="em_use"><p>
2934 <tag/Function/Prepare an extended memory page for use.
2935 <tag/Header/<tt/<ref id="em.h" name="em.h">/
2936 <tag/Declaration/<tt/void* __fastcall__ em_use (unsigned page);/
2937 <tag/Description/The function maps one page of extended memory into linear
2938 memory and returns a pointer to the page frame. This function is similar to
2939 <tt/<ref id="em_map" name="em_map">/, but will not transfer data into the
2940 actual memory window in the assumption that the existing data is wrong or
2941 will get overwritten.
2942 <tag/Notes/<itemize>
2943 <item>Calling <tt/em_use/ will invalidate the memory window, so if you
2944 made any changes to the data in the window, call <tt/<ref id="em_commit"
2945 name="em_commit">/ first, or the changes are lost.
2946 <item>The function is only available as fastcall function, so it may only be
2947 used in presence of a prototype.
2948 <item>The function produces undefined results if no extended memory driver is
2951 <tag/Availability/cc65
2953 <ref id="em_commit" name="em_commit">,
2954 <ref id="em_load_driver" name="em_load_driver">,
2955 <ref id="em_map" name="em_map">
2961 <sect1>exit<label id="exit"><p>
2965 <tag/Function/Terminate the program.
2966 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
2967 <tag/Declaration/<tt/void __fastcall__ exit (int status);/
2968 <tag/Description/<tt/exit/ terminates the program. The argument specifies the
2969 return code of the program. Before termination, all files are closed, buffered
2970 output is written and any functions registered with <tt/<ref id="atexit"
2971 name="atexit">/ are called. Common values for status are <tt/EXIT_SUCCESS/ and
2972 <tt/EXIT_FAILURE/ which are also defined in <tt/<ref id="stdlib.h"
2974 <tag/Notes/<itemize>
2975 <item>The function is only available as fastcall function, so it may only
2976 be used in presence of a prototype.
2977 <item>It depends on the host machine if the program return code can be
2978 evaluated or is ignored.
2980 <tag/Availability/ISO 9899
2982 <ref id="abort" name="abort">,
2983 <ref id="exit" name="exit">
2989 <sect1>exec<label id="exec"><p>
2993 <tag/Function/Execute a program file.
2994 <tag/Header/<tt/<ref id="unistd.h" name="unistd.h">/
2995 <tag/Declaration/<tt/int __fastcall__ exec (const char* progname, const char* cmdline);/
2996 <tag/Description/<tt/exec/ replaces the currently running program by a new one.
2997 Calling <tt/exec()/ is identical to calling <tt/<ref id="exit" name="exit()">/,
2998 then loading and starting the program named in the first argument, passing
2999 the command line specified as second argument. Instead of an empty string,
3000 a <tt/NULL/ pointer may be passed as second parameter.
3001 On success, the function does not return. On failure, -1 is returned and
3002 <tt/errno/ contains an error code.
3003 <tag/Notes/<itemize>
3004 <item>The function is only available as fastcall function, so it may only
3005 be used in presence of a prototype.
3006 <item>On most platforms, the function needs to copy a small stub loader to
3007 some memory area outside the program space. This may collide with other
3008 programs. See the platform specific docs on this.
3009 <item>Because it is necessary to terminate the running program before the
3010 memory can be reused to load the new one, there is a high chance that the
3011 function may not be able to return on errors.
3012 <item>The command line is passed to the new program in the same way as cc65
3013 programs expect the command line. If the new program is not a cc65 generated
3014 program, it may not be able to read it.
3016 <tag/Availability/cc65
3018 <ref id="exit" name="exit">
3024 <sect1>fast<label id="fast"><p>
3028 <tag/Function/Switch the C128 into 2MHz mode.
3029 <tag/Header/<tt/<ref id="c128.h" name="c128.h">/
3030 <tag/Declaration/<tt/void fast (void);/
3031 <tag/Description/The function will switch the clock of the C128 to 2MHz. This
3032 will nearly double the speed compared to slow mode.
3033 <tag/Notes/<itemize>
3034 <item>The function is specific to the C128.
3035 <item>2MHz clock will not work in 40 column mode.
3037 <tag/Availability/C128
3039 <ref id="slow" name="slow">,
3040 <ref id="toggle_videomode" name="toggle_videomode">,
3041 <ref id="videomode" name="videomode">
3047 <sect1>feof<label id="feof"><p>
3051 <tag/Function/Return the end-of-file indicator of a stream.
3052 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
3053 <tag/Declaration/<tt/int __fastcall__ feof (FILE* f);/
3054 <tag/Description/<tt/feof/ tests the end-of-file indicator ofthe stream
3055 <tt/f/, and returns a non zero value if it is set.
3056 <tag/Notes/<itemize>
3057 <item>The indicator is set only after a read past the end of a file is
3059 <item>The function is only available as fastcall function, so it may only be
3060 used in presence of a prototype.
3062 <tag/Availability/ISO 9899
3064 <ref id="feof" name="clearerr">,
3065 <ref id="ferror" name="ferror">
3071 <sect1>ferror<label id="ferror"><p>
3075 <tag/Function/Return the error indicator of a stream.
3076 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
3077 <tag/Declaration/<tt/int __fastcall__ ferror (FILE* f);/
3078 <tag/Description/<tt/ferror/ tests the error indicator of the stream
3079 <tt/f/, and returns a non zero value if it is set.
3080 <tag/Notes/<itemize>
3081 <item>The function is only available as fastcall function, so it may only be
3082 used in presence of a prototype.
3084 <tag/Availability/ISO 9899
3086 <ref id="feof" name="clearerr">,
3087 <ref id="ferror" name="feof">
3093 <sect1>fileno<label id="fileno"><p>
3097 <tag/Function/Return the file handle used by a stream.
3098 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
3099 <tag/Declaration/<tt/int __fastcall__ fileno (FILE* f);/
3100 <tag/Description/The <tt/fileno/ function returns the file handle used
3101 internally by a C stream. This file handle (an integer) can be used as a
3102 handle for the POSIX input/output functions.
3103 <tag/Notes/<itemize>
3104 <item>The function is only available as fastcall function, so it may only be
3105 used in presence of a prototype.
3106 <item>Mixing C file I/O functions and POSIX file I/O functions for the same
3107 file may have unpredictable results.
3109 <tag/Availability/POSIX 1003.1
3111 <ref id="creat" name="creat">,
3112 <ref id="open" name="open"> <!-- , -->
3113 <!-- <ref id="read" name="read">, -->
3114 <!-- <ref id="write" name="write"> -->
3120 <sect1>free<label id="free"><p>
3124 <tag/Function/Free a block of dynamic memory.
3125 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
3126 <tag/Declaration/<tt/void __fastcall__ free (void* block);/
3127 <tag/Description/Free a block of dynamic memory previously allocated with
3128 <tt/<ref id="malloc" name="malloc">/, <tt/<ref id="calloc" name="calloc">/
3129 or <tt/<ref id="realloc" name="realloc">/. As an exception, if the passed
3130 pointer is <tt/NULL/, no action is performed.
3131 <tag/Notes/<itemize>
3132 <item>Passing an already free'd block to <tt/free/ again will cause undefined
3133 behaviour and may crash your program.
3134 <item>The function is only available as fastcall function, so it may only
3135 be used in presence of a prototype.
3137 <tag/Availability/ISO 9899
3139 <ref id="_heapadd" name="_heapadd">,
3140 <ref id="_heapblocksize" name="_heapblocksize">,
3141 <ref id="_heapmaxavail" name="_heapmaxavail">,
3142 <ref id="_heapmemavail" name="_heapmemavail">,
3143 <ref id="calloc" name="calloc">,
3144 <ref id="malloc" name="malloc">,
3145 <ref id="realloc" name="realloc">
3151 <sect1>get_ostype<label id="get_ostype"><p>
3155 <tag/Function/The function returns the operating system, the program runs on.
3156 <tag/Header/<tt/<ref id="apple2.h" name="apple2.h">,
3157 <ref id="atari.h" name="atari.h">, <ref id="c64.h" name="c64.h">/
3158 <tag/Declaration/<tt/unsigned char get_ostype (void);/
3159 <tag/Description/<tt/get_ostype/ is machine dependent and does not exist for
3160 all supported targets. If it exists, it returns a number that identifies the
3161 operating system or machine type, the program runs on. The machine dependent
3162 header files define constants that can be used to check the return code.
3163 <tag/Notes/<itemize>
3164 <item>The function does not exist on all platforms.
3165 <item>The return codes are platform dependent.
3167 <tag/Availability/cc65 (not all platforms)
3173 <sect1>getcpu<label id="getcpu"><p>
3177 <tag/Function/Determine on which CPU the program is running.
3178 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
3179 <tag/Declaration/<tt/unsigned char getcpu (void);/
3180 <tag/Description/The function checks on which CPU the code is running. It
3181 returns one of the constants<itemize>
3183 <item><tt/CPU_65C02/
3184 <item><tt/CPU_65816/
3186 <tag/Notes/<itemize>
3187 <item>Other, more exotic CPU types are not disinguished.
3189 <tag/Availability/cc65
3195 <sect1>getenv<label id="getenv"><p>
3199 <tag/Function/Return a value from the environment.
3200 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
3201 <tag/Declaration/<tt/char* __fastcall__ getenv (const char* name);/
3202 <tag/Description/The function searches the environment for an entry that
3203 matches <tt/name/ and returns its value. The environment consists of a list
3204 of strings in the form <tt/name=value/. If there is no match, <tt/getenv/
3206 <tag/Notes/<itemize>
3207 <item>What exactly is stored in the environment depends on the machine the
3208 program is running on.
3209 <item>The function is only available as fastcall function, so it may only
3210 be used in presence of a prototype.
3212 <tag/Availability/ISO 9899
3218 <sect1>getopt<label id="getopt"><p>
3222 <tag/Function/Parse command line options.
3223 <tag/Header/<tt/<ref id="unistd.h" name="unistd.h">/
3224 <tag/Declaration/<tt/int __fastcall__ getopt (int argc, char* const* argv,
3225 const char* optstring);/
3226 <tag/Description/The function parses command line arguments, <tt/argc/ and
3227 <tt/argv/ are the argument count and array passed to <tt/main/. <tt/optstring/
3228 is a string that contains command line option characters. If a character in
3229 <tt/optstring/ is followed by a colon, the option requires an argument. An
3230 option on the command line is recognized if it is one of the option characters
3232 <tt/getopt/ must be called repeatedly. It will return each option character
3233 found on the command line and <tt/EOF/ (-1) if there is no other option. An
3234 option argument is placed in <tt/optarg/, the index of the next element on the
3235 command line to be processed is placed in <tt/optind/.
3236 <tag/Notes/<itemize>
3237 <item>The implementation will not reorder options. A non option on the command
3238 line will terminate option processing. All remaining arguments are not
3239 recognized as options, even if the start with a '-' character.
3240 <item>The function is only available as fastcall function, so it may only
3241 be used in presence of a prototype.
3243 <tag/Availability/POSIX.2
3249 <sect1>gotox<label id="gotox"><p>
3253 <tag/Function/Move the text mode cursor to a new X position.
3254 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
3255 <tag/Declaration/<tt/void __fastcall__ gotox (unsigned char x);/
3256 <tag/Description/The function moves the text mode cursor to the specified X
3257 position while leaving the Y position untouched. The leftmost position on the
3258 screen has the coordinate 0.
3259 <tag/Notes/<itemize>
3260 <item>The function is only available as fastcall function, so it may
3261 only be used in presence of a prototype.
3262 <item>Invalid values for the X position (out of screen coordinates) may
3263 lead to undefined behaviour.
3265 <tag/Availability/cc65
3267 <ref id="gotoy" name="gotoy">,
3268 <ref id="gotoxy" name="gotoxy">,
3269 <ref id="wherex" name="wherex">,
3270 <ref id="wherey" name="wherey">
3276 <sect1>gotoxy<label id="gotoxy"><p>
3280 <tag/Function/Move the text mode cursor to a new position.
3281 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
3282 <tag/Declaration/<tt/void __fastcall__ gotoxy (unsigned char x, unsigned char y);/
3283 <tag/Description/The function moves the text mode cursor to the specified
3284 position. The leftmost position on the screen has the X coordinate 0, the
3285 topmost line has the Y coordinate 0.
3286 <tag/Notes/<itemize>
3287 <item>The function is only available as fastcall function, so it may only be
3288 used in presence of a prototype.
3289 <item>Invalid values for any of both coordinates (out of screen positions) may
3290 lead to undefined behaviour.
3292 <tag/Availability/cc65
3294 <ref id="gotox" name="gotox">,
3295 <ref id="gotoy" name="gotoy">,
3296 <ref id="wherex" name="wherex">,
3297 <ref id="wherey" name="wherey">
3303 <sect1>gotoy<label id="gotoy"><p>
3307 <tag/Function/Move the text mode cursor to a new Y position.
3308 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
3309 <tag/Declaration/<tt/void __fastcall__ gotoy (unsigned char x);/
3310 <tag/Description/The function moves the text mode cursor to the specified Y
3311 position while leaving the X position untouched. The uppermost position on the
3312 screen has the coordinate 0.
3313 <tag/Notes/<itemize>
3314 <item>The function is only available as fastcall function, so it may
3315 only be used in presence of a prototype.
3316 <item>Invalid values for the Y position (out of screen coordinates) may lead
3317 to undefined behaviour.
3319 <tag/Availability/cc65
3321 <ref id="gotox" name="gotox">,
3322 <ref id="gotoxy" name="gotoxy">,
3323 <ref id="wherex" name="wherex">,
3324 <ref id="wherey" name="wherey">
3330 <sect1>isalnum<label id="isalnum"><p>
3334 <tag/Function/Check if a given character is a letter or digit.
3335 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
3336 <tag/Declaration/<tt/int __fastcall__ isalnum (int c);/
3337 <tag/Description/The function returns a non zero value if the given argument
3338 is a letter or digit. The return value is zero if the character is anything
3340 <tag/Notes/<itemize>
3341 <item>When compiling with <tt/-Os/ the function is actually a macro. The
3342 inline sequence generated by the macro will not work correctly for values
3343 outside the range 0..255. <em/Note:/ The constant <tt/EOF/ is not part of
3344 this range. The non inline function may be accessed by <tt/#undef/'ing
3346 <item>When compiling without <tt/-Os/, the function is only available as
3347 fastcall function, so it may only be used in presence of a prototype.
3349 <tag/Availability/ISO 9899
3351 <ref id="isalpha" name="isalpha">,
3352 <ref id="isascii" name="isascii">,
3353 <ref id="isblank" name="isblank">,
3354 <ref id="iscntrl" name="iscntrl">,
3355 <ref id="isdigit" name="isdigit">,
3356 <ref id="isgraph" name="isgraph">,
3357 <ref id="islower" name="islower">,
3358 <ref id="isprint" name="isprint">,
3359 <ref id="ispunct" name="ispunct">,
3360 <ref id="isspace" name="isspace">,
3361 <ref id="isupper" name="isupper">,
3362 <ref id="isxdigit" name="isxdigit">
3368 <sect1>isalpha<label id="isalpha"><p>
3372 <tag/Function/Check if a given character is a letter.
3373 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
3374 <tag/Declaration/<tt/int __fastcall__ isalpha (int c);/
3375 <tag/Description/The function returns a non zero value if the given argument
3376 is a letter. The return value is zero if the character is anything else.
3377 <tag/Notes/<itemize>
3378 <item>When compiling with <tt/-Os/ the function is actually a macro. The
3379 inline sequence generated by the macro will not work correctly for values
3380 outside the range 0..255. <em/Note:/ The constant <tt/EOF/ is not part of
3381 this range. The non inline function may be accessed by <tt/#undef/'ing the
3383 <item>When compiling without <tt/-Os/, the function is only available as
3384 fastcall function, so it may only be used in presence of a prototype.
3386 <tag/Availability/ISO 9899
3388 <ref id="isalnum" name="isalnum">,
3389 <ref id="isascii" name="isascii">,
3390 <ref id="isblank" name="isblank">,
3391 <ref id="iscntrl" name="iscntrl">,
3392 <ref id="isdigit" name="isdigit">,
3393 <ref id="isgraph" name="isgraph">,
3394 <ref id="islower" name="islower">,
3395 <ref id="isprint" name="isprint">,
3396 <ref id="ispunct" name="ispunct">,
3397 <ref id="isspace" name="isspace">,
3398 <ref id="isupper" name="isupper">,
3399 <ref id="isxdigit" name="isxdigit">
3405 <sect1>isascii<label id="isascii"><p>
3409 <tag/Function/Check if a given character is in the ASCII (0..127) range.
3410 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
3411 <tag/Declaration/<tt/int __fastcall__ isascii (int c);/
3412 <tag/Description/The function returns a non zero value if the given argument
3413 is in the range 0..127 (the range of valid ASCII characters) and zero if not.
3414 <tag/Notes/<itemize>
3415 <item>When compiling with <tt/-Os/ the function is actually a macro. The
3416 inline sequence generated by the macro will not work correctly for values
3417 outside the range 0..255. <em/Note:/ The constant <tt/EOF/ is not part of
3418 this range. The non inline function may be accessed by <tt/#undef/'ing the
3420 <item>When compiling without <tt/-Os/, the function is only available as
3421 fastcall function, so it may only be used in presence of a prototype.
3423 <tag/Availability/ISO 9899
3425 <ref id="isalnum" name="isalnum">,
3426 <ref id="isalpha" name="isalpha">,
3427 <ref id="isblank" name="isblank">,
3428 <ref id="iscntrl" name="iscntrl">,
3429 <ref id="isdigit" name="isdigit">,
3430 <ref id="isgraph" name="isgraph">,
3431 <ref id="islower" name="islower">,
3432 <ref id="isprint" name="isprint">,
3433 <ref id="ispunct" name="ispunct">,
3434 <ref id="isspace" name="isspace">,
3435 <ref id="isupper" name="isupper">,
3436 <ref id="isxdigit" name="isxdigit">
3442 <sect1>isblank<label id="isblank"><p>
3446 <tag/Function/Check if a given character is a space or tab.
3447 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
3448 <tag/Declaration/<tt/int __fastcall__ isblank (int c);/
3449 <tag/Description/The function returns a non zero value if the given argument
3450 is a space or tab character. The return value is zero if the character is
3452 <tag/Notes/<itemize>
3453 <item>When compiling with <tt/-Os/ the function is actually a macro. The
3454 inline sequence generated by the macro will not work correctly for values
3455 outside the range 0..255. <em/Note:/ The constant <tt/EOF/ is not part of
3456 this range. The non inline function may be accessed by <tt/#undef/'ing the
3458 <item>When compiling without <tt/-Os/, the function is only available as
3459 fastcall function, so it may only be used in presence of a prototype.
3461 <tag/Availability/ISO 9899
3463 <ref id="isalnum" name="isalnum">,
3464 <ref id="isalpha" name="isalpha">,
3465 <ref id="isascii" name="isascii">,
3466 <ref id="iscntrl" name="iscntrl">,
3467 <ref id="isdigit" name="isdigit">,
3468 <ref id="isgraph" name="isgraph">,
3469 <ref id="islower" name="islower">,
3470 <ref id="isprint" name="isprint">,
3471 <ref id="ispunct" name="ispunct">,
3472 <ref id="isspace" name="isspace">,
3473 <ref id="isupper" name="isupper">,
3474 <ref id="isxdigit" name="isxdigit">
3480 <sect1>iscntrl<label id="iscntrl"><p>
3484 <tag/Function/Check if a given character is a control character.
3485 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
3486 <tag/Declaration/<tt/int __fastcall__ iscntrl (int c);/
3487 <tag/Description/The function returns a non zero value if the given argument
3488 is a control character. The return value is zero if the character is anything
3490 <tag/Notes/<itemize>
3491 <item>When compiling with <tt/-Os/ the function is actually a macro. The
3492 inline sequence generated by the macro will not work correctly for values
3493 outside the range 0..255. <em/Note:/ The constant <tt/EOF/ is not part of
3494 this range. The non inline function may be accessed by <tt/#undef/'ing the
3496 <item>When compiling without <tt/-Os/, the function is only available as
3497 fastcall function, so it may only be used in presence of a prototype.
3499 <tag/Availability/ISO 9899
3501 <ref id="isalnum" name="isalnum">,
3502 <ref id="isalpha" name="isalpha">,
3503 <ref id="isascii" name="isascii">,
3504 <ref id="isblank" name="isblank">,
3505 <ref id="isdigit" name="isdigit">,
3506 <ref id="isgraph" name="isgraph">,
3507 <ref id="islower" name="islower">,
3508 <ref id="isprint" name="isprint">,
3509 <ref id="ispunct" name="ispunct">,
3510 <ref id="isspace" name="isspace">,
3511 <ref id="isupper" name="isupper">,
3512 <ref id="isxdigit" name="isxdigit">
3518 <sect1>isdigit<label id="isdigit"><p>
3522 <tag/Function/Check if a given character is a digit.
3523 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
3524 <tag/Declaration/<tt/int __fastcall__ isdigit (int c);/
3525 <tag/Description/The function returns a non zero value if the given argument
3526 is a digit. The return value is zero if the character is anything else.
3527 <tag/Notes/<itemize>
3528 <item>When compiling with <tt/-Os/ the function is actually a macro. The
3529 inline sequence generated by the macro will not work correctly for values
3530 outside the range 0..255. <em/Note:/ The constant <tt/EOF/ is not part of
3531 this range. The non inline function may be accessed by <tt/#undef/'ing the
3533 <item>When compiling without <tt/-Os/, the function is only available as
3534 fastcall function, so it may only be used in presence of a prototype.
3536 <tag/Availability/ISO 9899
3538 <ref id="isalnum" name="isalnum">,
3539 <ref id="isalpha" name="isalpha">,
3540 <ref id="isascii" name="isascii">,
3541 <ref id="isblank" name="isblank">,
3542 <ref id="iscntrl" name="iscntrl">,
3543 <ref id="isgraph" name="isgraph">,
3544 <ref id="islower" name="islower">,
3545 <ref id="isprint" name="isprint">,
3546 <ref id="ispunct" name="ispunct">,
3547 <ref id="isspace" name="isspace">,
3548 <ref id="isupper" name="isupper">,
3549 <ref id="isxdigit" name="isxdigit">
3555 <sect1>isgraph<label id="isgraph"><p>
3559 <tag/Function/Check if a given character is a printable character (except
3561 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
3562 <tag/Declaration/<tt/int __fastcall__ isgraph (int c);/
3563 <tag/Description/The function returns a non zero value if the given argument
3564 is a printable character with the exception of space. The return value is zero
3565 if the character is anything else.
3566 <tag/Notes/<itemize>
3567 <item>When compiling with <tt/-Os/ the function is actually a macro. The
3568 inline sequence generated by the macro will not work correctly for values
3569 outside the range 0..255. <em/Note:/ The constant <tt/EOF/ is not part of
3570 this range. The non inline function may be accessed by <tt/#undef/'ing the
3572 <item>When compiling without <tt/-Os/, the function is only available as
3573 fastcall function, so it may only be used in presence of a prototype.
3575 <tag/Availability/ISO 9899
3577 <ref id="isalnum" name="isalnum">,
3578 <ref id="isalpha" name="isalpha">,
3579 <ref id="isascii" name="isascii">,
3580 <ref id="isblank" name="isblank">,
3581 <ref id="iscntrl" name="iscntrl">,
3582 <ref id="isdigit" name="isdigit">,
3583 <ref id="islower" name="islower">,
3584 <ref id="isprint" name="isprint">,
3585 <ref id="ispunct" name="ispunct">,
3586 <ref id="isspace" name="isspace">,
3587 <ref id="isupper" name="isupper">,
3588 <ref id="isxdigit" name="isxdigit">
3594 <sect1>islower<label id="islower"><p>
3598 <tag/Function/Check if a given character is a lower case letter.
3599 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
3600 <tag/Declaration/<tt/int __fastcall__ islower (int c);/
3601 <tag/Description/The function returns a non zero value if the given argument
3602 is a lower case letter. The return value is zero if the character is anything
3604 <tag/Notes/<itemize>
3605 <item>When compiling with <tt/-Os/ the function is actually a macro. The
3606 inline sequence generated by the macro will not work correctly for values
3607 outside the range 0..255. <em/Note:/ The constant <tt/EOF/ is not part of
3608 this range. The non inline function may be accessed by <tt/#undef/'ing the
3610 <item>When compiling without <tt/-Os/, the function is only available as
3611 fastcall function, so it may only be used in presence of a prototype.
3613 <tag/Availability/ISO 9899
3615 <ref id="isalnum" name="isalnum">,
3616 <ref id="isalpha" name="isalpha">,
3617 <ref id="isascii" name="isascii">,
3618 <ref id="isblank" name="isblank">,
3619 <ref id="iscntrl" name="iscntrl">,
3620 <ref id="isdigit" name="isdigit">,
3621 <ref id="isgraph" name="isgraph">,
3622 <ref id="isprint" name="isprint">,
3623 <ref id="ispunct" name="ispunct">,
3624 <ref id="isspace" name="isspace">,
3625 <ref id="isupper" name="isupper">,
3626 <ref id="isxdigit" name="isxdigit">
3632 <sect1>isprint<label id="isprint"><p>
3636 <tag/Function/Check if a given character is a printable character.
3637 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
3638 <tag/Declaration/<tt/int __fastcall__ isprint (int c);/
3639 <tag/Description/The function returns a non zero value if the given argument
3640 is a printable character (this includes the space character). The return value
3641 is zero if the character is anything else.
3642 <tag/Notes/<itemize>
3643 <item>When compiling with <tt/-Os/ the function is actually a macro. The
3644 inline sequence generated by the macro will not work correctly for values
3645 outside the range 0..255. <em/Note:/ The constant <tt/EOF/ is not part of
3646 this range. The non inline function may be accessed by <tt/#undef/'ing the
3648 <item>When compiling without <tt/-Os/, the function is only available as
3649 fastcall function, so it may only be used in presence of a prototype.
3651 <tag/Availability/ISO 9899
3653 <ref id="isalnum" name="isalnum">,
3654 <ref id="isalpha" name="isalpha">,
3655 <ref id="isascii" name="isascii">,
3656 <ref id="isblank" name="isblank">,
3657 <ref id="iscntrl" name="iscntrl">,
3658 <ref id="isdigit" name="isdigit">,
3659 <ref id="isgraph" name="isgraph">,
3660 <ref id="islower" name="islower">,
3661 <ref id="ispunct" name="ispunct">,
3662 <ref id="isspace" name="isspace">,
3663 <ref id="isupper" name="isupper">,
3664 <ref id="isxdigit" name="isxdigit">
3670 <sect1>ispunct<label id="ispunct"><p>
3674 <tag/Function/Check if a given character is a printable character but not a
3675 space or an alphanumeric character.
3676 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
3677 <tag/Declaration/<tt/int __fastcall__ ispunct (int c);/
3678 <tag/Description/The function returns a non zero value if the given argument
3679 is a printable character, but not a space or anything alphanumeric. The return
3680 value is zero if the character is anything else.
3681 <tag/Notes/<itemize>
3682 <item>When compiling with <tt/-Os/ the function is actually a macro. The
3683 inline sequence generated by the macro will not work correctly for values
3684 outside the range 0..255. <em/Note:/ The constant <tt/EOF/ is not part of
3685 this range. The non inline function may be accessed by <tt/#undef/'ing the
3687 <item>When compiling without <tt/-Os/, the function is only available as
3688 fastcall function, so it may only be used in presence of a prototype.
3690 <tag/Availability/ISO 9899
3692 <ref id="isalnum" name="isalnum">,
3693 <ref id="isalpha" name="isalpha">,
3694 <ref id="isascii" name="isascii">,
3695 <ref id="isblank" name="isblank">,
3696 <ref id="iscntrl" name="iscntrl">,
3697 <ref id="isdigit" name="isdigit">,
3698 <ref id="isgraph" name="isgraph">,
3699 <ref id="islower" name="islower">,
3700 <ref id="isprint" name="isprint">,
3701 <ref id="isspace" name="isspace">,
3702 <ref id="isupper" name="isupper">,
3703 <ref id="isxdigit" name="isxdigit">
3709 <sect1>isspace<label id="isspace"><p>
3713 <tag/Function/Check if a given character is a white-space character.
3714 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
3715 <tag/Declaration/<tt/int __fastcall__ isspace (int c);/
3716 <tag/Description/The function returns a non zero value if the given argument
3717 is a white space character. The return value is zero if the character is
3718 anything else. The standard white space characters are: space, formfeed ('\f'),
3719 newline ('\n'), carriage return ('\r'), horizontal tab ('\t'), and vertical tab
3721 <tag/Notes/<itemize>
3722 <item>When compiling with <tt/-Os/ the function is actually a macro. The
3723 inline sequence generated by the macro will not work correctly for values
3724 outside the range 0..255. <em/Note:/ The constant <tt/EOF/ is not part of
3725 this range. The non inline function may be accessed by <tt/#undef/'ing the
3727 <item>When compiling without <tt/-Os/, the function is only available as
3728 fastcall function, so it may only be used in presence of a prototype.
3730 <tag/Availability/ISO 9899
3732 <ref id="isalnum" name="isalnum">,
3733 <ref id="isalpha" name="isalpha">,
3734 <ref id="isascii" name="isascii">,
3735 <ref id="isblank" name="isblank">,
3736 <ref id="iscntrl" name="iscntrl">,
3737 <ref id="isdigit" name="isdigit">,
3738 <ref id="isgraph" name="isgraph">,
3739 <ref id="islower" name="islower">,
3740 <ref id="isprint" name="isprint">,
3741 <ref id="ispunct" name="ispunct">,
3742 <ref id="isupper" name="isupper">,
3743 <ref id="isxdigit" name="isxdigit">
3749 <sect1>isupper<label id="isupper"><p>
3753 <tag/Function/Check if a given character is an upper case letter.
3754 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
3755 <tag/Declaration/<tt/int __fastcall__ isupper (int c);/
3756 <tag/Description/The function returns a non zero value if the given argument
3757 is an upper case letter. The return value is zero if the character is anything
3759 <tag/Notes/<itemize>
3760 <item>When compiling with <tt/-Os/ the function is actually a macro. The
3761 inline sequence generated by the macro will not work correctly for values
3762 outside the range 0..255. <em/Note:/ The constant <tt/EOF/ is not part of
3763 this range. The non inline function may be accessed by <tt/#undef/'ing the
3765 <item>When compiling without <tt/-Os/, the function is only available as
3766 fastcall function, so it may only be used in presence of a prototype.
3768 <tag/Availability/ISO 9899
3770 <ref id="isalnum" name="isalnum">,
3771 <ref id="isalpha" name="isalpha">,
3772 <ref id="isascii" name="isascii">,
3773 <ref id="isblank" name="isblank">,
3774 <ref id="iscntrl" name="iscntrl">,
3775 <ref id="isdigit" name="isdigit">,
3776 <ref id="isgraph" name="isgraph">,
3777 <ref id="islower" name="islower">,
3778 <ref id="isprint" name="isprint">,
3779 <ref id="ispunct" name="ispunct">,
3780 <ref id="isspace" name="isspace">,
3781 <ref id="isxdigit" name="isxdigit">
3787 <sect1>isxdigit<label id="isxdigit"><p>
3791 <tag/Function/Check if a given character is a hexadecimal digit.
3792 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
3793 <tag/Declaration/<tt/int __fastcall__ isxdigit (int c);/
3794 <tag/Description/The function returns a non zero value if the given argument
3795 is a hexadecimal digit (0..9, a..f and A..F). The return value is zero if the
3796 character is anything else.
3797 <tag/Notes/<itemize>
3798 <item>When compiling with <tt/-Os/ the function is actually a macro. The
3799 inline sequence generated by the macro will not work correctly for values
3800 outside the range 0..255. <em/Note:/ The constant <tt/EOF/ is not part of
3801 this range. The non inline function may be accessed by <tt/#undef/'ing the
3803 <item>When compiling without <tt/-Os/, the function is only available as
3804 fastcall function, so it may only be used in presence of a prototype.
3806 <tag/Availability/ISO 9899
3808 <ref id="isalnum" name="isalnum">,
3809 <ref id="isalpha" name="isalpha">,
3810 <ref id="isascii" name="isascii">,
3811 <ref id="isblank" name="isblank">,
3812 <ref id="iscntrl" name="iscntrl">,
3813 <ref id="isdigit" name="isdigit">,
3814 <ref id="isgraph" name="isgraph">,
3815 <ref id="islower" name="islower">,
3816 <ref id="isprint" name="isprint">,
3817 <ref id="ispunct" name="ispunct">,
3818 <ref id="isspace" name="isspace">,
3819 <ref id="isupper" name="isupper">
3825 <sect1>itoa<label id="itoa"><p>
3829 <tag/Function/Convert an integer into a string.
3830 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
3831 <tag/Declaration/<tt/char* __fastcall__ itoa (int val, char* buf, int radix);/
3832 <tag/Description/<tt/itoa/ converts the integer <tt/val/ into a string using
3833 <tt/radix/ as the base.
3834 <tag/Notes/<itemize>
3835 <item>There are no provisions to prevent a buffer overflow.
3836 <item>If <tt/val/ contains <tt/INT_MIN/, the behaviour is undefined.
3837 <item>The function is non standard, so it is not available in strict ANSI mode.
3838 You should probably use <tt/sprintf/ instead.
3839 <item>The function is only available as fastcall function, so it may only be
3840 used in presence of a prototype.
3842 <tag/Availability/cc65
3844 <ref id="atoi" name="atoi">,
3845 <ref id="atol" name="atol">,
3846 <ref id="ltoa" name="ltoa">,
3847 <ref id="ultoa" name="ultoa">,
3848 <ref id="utoa" name="utoa">
3854 <sect1>joy_count<label id="joy_count"><p>
3858 <tag/Function/Return the number of joysticks supported by the current driver.
3859 <tag/Header/<tt/<ref id="joystick.h" name="joystick.h">/
3860 <tag/Declaration/<tt/unsigned char joy_count (void);/
3861 <tag/Description/The function returns a the number of joysticks supported
3862 by the current joystick driver.
3863 <tag/Notes/<itemize>
3864 <item>A joystick driver must be loaded using <ref id="joy_load_driver"
3865 name="joy_load_driver"> before calling this function.
3866 <item>The function returns the number of joysticks supported by the driver.
3867 There's no way to check for the number of actually connected joysticks.
3869 <tag/Availability/cc65
3871 <ref id="joy_load_driver" name="joy_load_driver">,
3872 <ref id="joy_read" name="joy_read">
3878 <sect1>joy_install<label id="joy_install"><p>
3882 <tag/Function/Install an already loaded driver and return an error code.
3883 <tag/Header/<tt/<ref id="joystick.h" name="joystick.h">/
3884 <tag/Declaration/<tt/unsigned char __fastcall__ joy_install (void* driver);/
3885 <tag/Description/The function installs a driver that was already loaded into
3886 memory (or linked statically to the program). It returns an error code
3887 (<tt/JOY_ERR_OK/ in case of success).
3888 <tag/Notes/<itemize>
3889 <item>The function is only available as fastcall function, so it may only be
3890 used in presence of a prototype.
3892 <tag/Availability/cc65
3894 <ref id="joy_load_driver" name="joy_load_driver">,
3895 <ref id="joy_uninstall" name="joy_uninstall">,
3896 <ref id="joy_unload" name="joy_unload">
3902 <sect1>joy_load_driver<label id="joy_load_driver"><p>
3906 <tag/Function/Load a driver from disk and install it.
3907 <tag/Header/<tt/<ref id="joystick.h" name="joystick.h">/
3908 <tag/Declaration/<tt/unsigned char __fastcall__ joy_load_driver (const char* driver);/
3909 <tag/Description/The function loads a driver with the given name from disk
3910 and installs it. An error code is returned, which is <tt/JOY_ERR_OK/ if the
3911 driver was successfully loaded and installed.
3912 <tag/Notes/<itemize>
3913 <item>The function is only available as fastcall function, so it may only be
3914 used in presence of a prototype.
3916 <tag/Availability/cc65
3918 <ref id="joy_install" name="joy_install">,
3919 <ref id="joy_uninstall" name="joy_uninstall">,
3920 <ref id="joy_unload" name="joy_unload">
3926 <sect1>joy_read<label id="joy_read"><p>
3930 <tag/Function/Read the status of a joystick.
3931 <tag/Header/<tt/<ref id="joystick.h" name="joystick.h">/
3932 <tag/Declaration/<tt/unsigned char __fastcall__ joy_read (unsigned char joystick);/
3933 <tag/Description/The function reads the status bits for a joystick. The number
3934 of the joystick is passed as parameter. The result may be examined by using one
3935 of the <tt/JOY_xxx/ macros from <ref id="joystick.h" name="joystick.h">.
3936 <tag/Notes/<itemize>
3937 <item>A joystick driver must be loaded using <ref id="joy_load_driver"
3938 name="joy_load_driver"> before calling this function.
3939 <item>The function is only available as fastcall function, so it may only be
3940 used in presence of a prototype.
3942 <tag/Availability/cc65
3944 <ref id="joy_count" name="joy_count">,
3945 <ref id="joy_load_driver" name="joy_load_driver">,
3946 <ref id="joy_unload" name="joy_unload">
3952 <sect1>joy_uninstall<label id="joy_uninstall"><p>
3956 <tag/Function/Uninstall the current joystick driver.
3957 <tag/Header/<tt/<ref id="joystick.h" name="joystick.h">/
3958 <tag/Declaration/<tt/unsigned char joy_uninstall (void);/
3959 <tag/Description/The function uninstalls the currently installed joystick
3960 driver. It does not remove the driver from memory. The function returns an
3961 error code, which is <tt/JOY_ERR_OK/ if the driver was successfully uninstalled.
3962 <tag/Notes/<itemize>
3963 <item>A joystick driver must be installed using <ref id="joy_install"
3964 name="joy_install"> before calling this function.
3966 <tag/Availability/cc65
3968 <ref id="joy_install" name="joy_install">,
3969 <ref id="joy_load_driver" name="joy_load_driver">,
3970 <ref id="joy_unload" name="joy_unload">
3976 <sect1>joy_unload<label id="joy_unload"><p>
3980 <tag/Function/Uninstall, then unload the current joystick driver.
3981 <tag/Header/<tt/<ref id="joystick.h" name="joystick.h">/
3982 <tag/Declaration/<tt/unsigned char joy_unload (void);/
3983 <tag/Description/The function uninstalls the currently installed joystick
3984 driver and removes it from memory. An error code is returned, which is
3985 <tt/JOY_ERR_OK/ if the driver was successfully uninstalled.
3986 <tag/Notes/<itemize>
3987 <item>A joystick driver must be loaded using <ref id="joy_load_driver"
3988 name="joy_load_driver"> before calling this function.
3990 <tag/Availability/cc65
3992 <ref id="joy_load_driver" name="joy_load_driver">
3998 <sect1>kbhit<label id="kbhit"><p>
4002 <tag/Function/Check if there's a key waiting in the keyboard buffer.
4003 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
4004 <tag/Declaration/<tt/unsigned char kbhit (void);/
4005 <tag/Description/The function returns a value of zero if there is no character
4006 waiting to be read from the keyboard. It returns non zero otherwise.
4007 <tag/Notes/<itemize>
4008 <item>If the system does not support a keyboard buffer (most systems
4009 do), the function is rather useless.
4011 <tag/Availability/cc65
4013 <ref id="cgetc" name="cgetc">,
4014 <ref id="cursor" name="cursor">
4020 <sect1>labs<label id="labs"><p>
4024 <tag/Function/Returns the absolute value of a long integer.
4025 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
4026 <tag/Declaration/<tt/long __fastcall__ labs (long v);/
4027 <tag/Description/<tt/labs/ returns the absolute value of the argument passed to
4029 <tag/Notes/<itemize>
4030 <item>The return value is undefined if <tt/LONG_MIN/ is passed to the function.
4031 <item>The function is only available as fastcall function, so it may only be
4032 used in presence of a prototype.
4034 <tag/Availability/ISO 9899
4036 <ref id="abs" name="abs">
4042 <sect1>ltoa<label id="ltoa"><p>
4046 <tag/Function/Convert a long integer into a string.
4047 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
4048 <tag/Declaration/<tt/char* __fastcall__ ltoa (long val, char* buf, int radix);/
4049 <tag/Description/<tt/itoa/ converts the long integer <tt/val/ into a string
4050 using <tt/radix/ as the base.
4051 <tag/Notes/<itemize>
4052 <item>There are no provisions to prevent a buffer overflow.
4053 <item>If <tt/val/ contains <tt/LONG_MIN/, the behaviour is undefined.
4054 <item>The function is non standard, so it is not available in strict ANSI mode.
4055 You should probably use <tt/sprintf/ instead.
4056 <item>The function is only available as fastcall function, so it may only be
4057 used in presence of a prototype.
4059 <tag/Availability/cc65
4061 <ref id="atoi" name="atoi">,
4062 <ref id="atol" name="atol">,
4063 <ref id="itoa" name="itoa">,
4064 <ref id="ultoa" name="ultoa">,
4065 <ref id="utoa" name="utoa">
4071 <sect1>localeconv<label id="localeconv"><p>
4075 <tag/Function/Returns a pointer to the current locale structure.
4076 <tag/Header/<tt/<ref id="locale.h" name="locale.h">/
4077 <tag/Declaration/<tt/struct lconv* localeconv (void);/
4078 <tag/Description/<tt/localeconv/ returns a pointer to the current locale
4080 <tag/Notes/<itemize>
4081 <item>cc65 supports only the "C" locale, so even after setting a new locale
4082 using <tt/<ref id="setlocale" name="setlocale">/, the structure returned will
4085 <tag/Availability/ISO 9899
4087 <ref id="setlocale" name="setlocale">
4093 <sect1>longjmp<label id="longjmp"><p>
4097 <tag/Function/Non local goto.
4098 <tag/Header/<tt/<ref id="setjmp.h" name="setjmp.h">/
4099 <tag/Declaration/<tt/void __fastcall__ longjmp (jmp_buf buf, int retval);/
4100 <tag/Description/The <tt/longjmp/ function restores a program context from the
4101 data in <tt/buf/, which must have been set by a preceeding call to
4102 <tt/<ref id="setjmp" name="setjmp">/. Program execution continues as if the
4103 call to <tt/<ref id="setjmp" name="setjmp">/ has just returned the value
4105 <tag/Notes/<itemize>
4106 <item>If the parameter <tt/retval/ is zero, the function will behave as if it
4107 was called with a value of one.
4108 <item>The function is only available as fastcall function, so it may only
4109 be used in presence of a prototype.
4111 <tag/Availability/ISO 9899
4113 <ref id="setjmp" name="setjmp">
4119 <sect1>malloc<label id="malloc"><p>
4123 <tag/Function/Allocate dynamic memory.
4124 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
4125 <tag/Declaration/<tt/void* __fastcall__ malloc (size_t size);/
4126 <tag/Description/<tt/malloc/ allocates size bytes on the heap and returns a
4127 pointer to the allocated memory block. On error (not enough memory available),
4128 <tt/malloc/ returns <tt/NULL/.
4129 <tag/Notes/<itemize>
4130 <item>The function is only available as fastcall function, so it may only
4131 be used in presence of a prototype.
4133 <tag/Availability/ISO 9899
4135 <ref id="_heapadd" name="_heapadd">,
4136 <ref id="_heapblocksize" name="_heapblocksize">,
4137 <ref id="_heapmaxavail" name="_heapmaxavail">,
4138 <ref id="_heapmemavail" name="_heapmemavail">,
4139 <ref id="calloc" name="calloc">,
4140 <ref id="free" name="free">,
4141 <ref id="realloc" name="realloc">,
4142 <ref id="strdup" name="strdup">
4148 <sect1>memchr<label id="memchr"><p>
4152 <tag/Function/Search for a character in a block of raw memory.
4153 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4154 <tag/Declaration/<tt/void* __fastcall__ strchr (const void* mem, int c, size_t count);/
4155 <tag/Description/The <tt/memchr/ function locates the first occurrence of <tt/c/
4156 (converted to a char) in the block of raw memory string pointed to by <tt/mem/
4157 that is of size <tt/count/. Upon completion, the function returns a pointer to
4158 the character found, or a null pointer if the character was not found.
4159 <tag/Notes/<itemize>
4160 <item>The function is only available as fastcall function, so it may only
4161 be used in presence of a prototype.
4163 <tag/Availability/ISO 9899
4165 <ref id="strchr" name="strchr">
4171 <sect1>memcmp<label id="memcmp"><p>
4175 <tag/Function/Compare two memory areas.
4176 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4177 <tag/Declaration/<tt/int __fastcall__ memcmp (const void* p1, const void* p2, size_t count);/
4178 <tag/Description/<tt/memcmp/ compares <tt/count/ bytes from the memory area
4179 pointed to by <tt/p1/ into the memory area pointed to by <tt/p2/. It returns a value that is less than
4180 zero if <tt/p1/ is less than <tt/p2/, zero if <tt/p1/ is the same as <tt/p2/,
4181 and a value greater than zero if <tt/p1/ is greater than <tt/p2/.
4182 <tag/Notes/<itemize>
4183 <item>The function is only available as fastcall function, so it may only
4184 be used in presence of a prototype.
4186 <tag/Availability/ISO 9899
4188 <ref id="strcmp" name="strcmp">,
4189 <ref id="memmove" name="memmove">,
4190 <ref id="memset" name="memset">
4196 <sect1>memcpy<label id="memcpy"><p>
4200 <tag/Function/Copy a memory area.
4201 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4202 <tag/Declaration/<tt/void* __fastcall__ memcpy (void* dest, const void* src, size_t count);/
4203 <tag/Description/<tt/memcpy/ copies <tt/count/ bytes from the memory area
4204 pointed to by <tt/src/ into the memory area pointed to by <tt/dest/. It returns
4206 <tag/Notes/<itemize>
4207 <item>The result is undefined if the memory areas do overlap. Use
4208 <tt/<ref id="memmove" name="memmove">/ to copy overlapping memory areas.
4209 <item>The function is only available as fastcall function, so it may only
4210 be used in presence of a prototype.
4212 <tag/Availability/ISO 9899
4214 <ref id="_swap" name="_swap">,
4215 <ref id="memmove" name="memmove">,
4216 <ref id="memset" name="memset">
4222 <sect1>memmove<label id="memmove"><p>
4226 <tag/Function/Copy a memory area.
4227 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4228 <tag/Declaration/<tt/void* __fastcall__ memmove (void* dest, const void* src, size_t count);/
4229 <tag/Description/<tt/memmove/ copies <tt/count/ bytes from the memory area
4230 pointed to by <tt/src/ into the memory area pointed to by <tt/dest/. It returns
4232 <tag/Notes/<itemize>
4233 <item>While <tt/memmove/ allows the memory areas to overlap, it has some
4234 additional overhead compared to <tt/<ref id="memcpy" name="memcpy">/.
4235 <item>The function is only available as fastcall function, so it may only
4236 be used in presence of a prototype.
4238 <tag/Availability/ISO 9899
4240 <ref id="_swap" name="_swap">,
4241 <ref id="memcpy" name="memcpy">,
4242 <ref id="memset" name="memset">
4248 <sect1>memset<label id="memset"><p>
4252 <tag/Function/Fill a memory area.
4253 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4254 <tag/Declaration/<tt/void* __fastcall__ memset (void* p, int val, size_t count);/
4255 <tag/Description/<tt/memset/ fills the memory area pointed to by <tt/p/ with
4256 the value <tt/val/. The function returns <tt/p/.
4257 <tag/Notes/<itemize>
4258 <item>The function is only available as fastcall function, so it may only
4259 be used in presence of a prototype.
4261 <tag/Availability/ISO 9899
4263 <ref id="_swap" name="_swap">,
4264 <ref id="bzero" name="bzero">,
4265 <ref id="memcpy" name="memcpy">,
4266 <ref id="memmove" name="memmove">
4272 <sect1>mod_free<label id="mod_free"><p>
4276 <tag/Function/Free a relocatable module.
4277 <tag/Header/<tt/<ref id="modload.h" name="modload.h">/
4278 <tag/Declaration/<tt/void __fastcall__ mod_free (void* module);/
4279 <tag/Description/The function will free a module loaded into memory by use of
4280 the <tt/<ref id="mod_load" name="mod_load">/ function.
4281 <tag/Notes/<itemize>
4282 <item>The pointer passed as parameter is the pointer to the module memory,
4283 not the pointer to the control structure.
4284 <item>The function is available only as a fastcall function; so, it may be used
4285 only in the presence of a prototype.
4287 <tag/Availability/cc65
4289 <ref id="mod_load" name="mod_load">
4295 <sect1>mod_load<label id="mod_load"><p>
4299 <tag/Function/Load a relocatable module.
4300 <tag/Header/<tt/<ref id="modload.h" name="modload.h">/
4301 <tag/Declaration/<tt/unsigned char __fastcall__ mod_load (struct mod_ctrl* ctrl);/
4302 <tag/Description/The function will load a code module into memory and relocate
4303 it. The function will return an error code. If <tt/MLOAD_OK/ is returned, the
4304 outgoing fields in the passed <tt/mod_ctrl/ struct contain information about
4305 the module just loaded. Possible error codes are:
4307 <item><tt/MLOAD_OK/ - Module load successful
4308 <item><tt/MLOAD_ERR_READ/ - Read error
4309 <item><tt/MLOAD_ERR_HDR/ - Header error
4310 <item><tt/MLOAD_ERR_OS/ - Wrong operating system
4311 <item><tt/MLOAD_ERR_FMT/ - Data format error
4312 <item><tt/MLOAD_ERR_MEM/ - Not enough memory
4314 <tag/Notes/<itemize>
4315 <item>The <htmlurl url="ld65.html" name="ld65"> linker is needed to create
4316 relocatable o65 modules for use with this function.
4317 <item>The function is available only as a fastcall function; so, it may be used
4318 only in the presence of a prototype.
4320 <tag/Availability/cc65
4322 <ref id="mod_free" name="mod_free">
4328 <sect1>mouse_setbox<label id="mouse_setbox"><p>
4332 <tag/Function/Specify a bounding box for the mouse cursor.
4333 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
4334 <tag/Declaration/<tt/void __fastcall__ mouse_setbox (const struct mouse_box* box);/
4335 <tag/Description/The function allows to set a bounding box for mouse movement.
4336 <tag/Notes/<itemize>
4337 <item>The function does not check if the mouse cursor is currently within the
4338 given rectangle. Placing the mouse cursor within the bounding box is the
4339 responsibility of the programmer.
4340 <item>While the bounding box may be larger than the actual screen size, the
4341 standard mouse cursor draw routines may fail to set the cursor to coordinates
4342 outside of the screen area. Depending on the platform, you may have to supply
4343 your own mouse cursor routines.
4344 <item>The function is only available as fastcall function, so it may only be
4345 used in presence of a prototype.
4347 <tag/Availability/cc65
4349 <ref id="mouse_getbox" name="mouse_getbox">,
4350 <ref id="mouse_move" name="mouse_move">
4356 <sect1>mouse_getbox<label id="mouse_getbox"><p>
4360 <tag/Function/Return the current bounding box for the mouse cursor.
4361 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
4362 <tag/Declaration/<tt/void __fastcall__ mouse_getbox (struct mouse_box* box);/
4363 <tag/Description/The function queries the current bounding box for mouse
4365 <tag/Notes/<itemize>
4366 <item>The function is only available as fastcall function, so it may only be
4367 used in presence of a prototype.
4369 <tag/Availability/cc65
4371 <ref id="mouse_move" name="mouse_move">,
4372 <ref id="mouse_setbox" name="mouse_setbox">
4378 <sect1>mouse_buttons<label id="mouse_buttons"><p>
4382 <tag/Function/Return a bit mask encoding the state of the mouse buttons.
4383 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
4384 <tag/Declaration/<tt/unsigned char mouse_buttons (void);/
4385 <tag/Description/The function returns a bit mask that encodes the state of the
4386 mouse buttons. You may use the <tt/MOUSE_BTN_XXX/ flags to decode the function
4388 <tag/Availability/cc65
4390 <ref id="mouse_info" name="mouse_info">,
4391 <ref id="mouse_pos" name="mouse_pos">
4397 <sect1>mouse_geterrormsg<label id="mouse_geterrormsg"><p>
4401 <tag/Function/Return a readable error message for an error code.
4402 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
4403 <tag/Declaration/<tt/const char* __fastcall__ mouse_geterrormsg (unsigned char
4405 <tag/Description/The function returns an error message (in english) for the
4406 error code passed parameter.
4407 <tag/Notes/<itemize>
4408 <item>The function will return "Unknown error" for invalid error codes.
4409 <item>The function is only available as fastcall function, so it may only be
4410 used in presence of a prototype.
4412 <tag/Availability/cc65
4414 <ref id="mouse_load_driver" name="mouse_load_driver">,
4415 <ref id="mouse_uninstall" name="mouse_uninstall">,
4416 <ref id="mouse_unload" name="mouse_unload">
4422 <sect1>mouse_hide<label id="mouse_hide"><p>
4426 <tag/Function/Hide the mouse pointer.
4427 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
4428 <tag/Declaration/<tt/void mouse_hide (void);/
4429 <tag/Description/The function hides the mouse pointer. It manages a counter
4430 that is shared between <tt/<ref id="mouse_show" name="mouse_show">/ and
4431 <tt/mouse_hide/ so that every call call to <tt/mouse_hide/ must be followed by
4432 a call to <tt/<ref id="mouse_show" name="mouse_show">/ to make the mouse cursor
4434 <tag/Availability/cc65
4436 <ref id="mouse_show" name="mouse_show">
4442 <sect1>mouse_info<label id="mouse_info"><p>
4446 <tag/Function/Return the state of the mouse buttons and the position of the
4448 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
4449 <tag/Declaration/<tt/void __fastcall__ mouse_info (struct mouse_info* info);/
4450 <tag/Description/The function returns the state of the mouse buttons and the
4451 position of the mouse in the <tt/mouse_info/ structure passed as parameter.
4452 <tag/Notes/<itemize>
4453 <item>The <tt/mouse_info/ struct is a superset of the <tt/mouse_pos/ struct,
4454 so if you just need the mouse position, call <tt/<ref id="mouse_pos"
4455 name="mouse_pos">/ instead.
4456 <item>The function is only available as fastcall function, so it may only be
4457 used in presence of a prototype.
4459 <tag/Availability/cc65
4461 <ref id="mouse_buttons" name="mouse_buttons">,
4462 <ref id="mouse_pos" name="mouse_pos">
4468 <sect1>mouse_install<label id="mouse_install"><p>
4472 <tag/Function/Install an already loaded mouse driver.
4473 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
4474 <tag/Declaration/<tt/unsigned char __fastcall__ mouse_install (const struct
4475 mouse_callbacks* c, void* driver);/
4476 <tag/Description/The function installs an already loaded mouse driver and
4477 returns an error code. The <tt/mouse_callbacks/ structure passed as first
4478 parameter contains pointers to routines needed to move or hide/show the mouse
4479 pointer. Defaults for these routines are supplied by the library, so if you
4480 can live with these defaults (which are platform specific), just pass a
4481 pointer to <tt/mouse_def_callbacks/. The function may be used to install a
4482 driver linked statically to the program.
4483 <tag/Notes/<itemize>
4484 <item>Not all drivers are able to detect if the supported hardware is really
4486 <item>After installing a driver, the mouse cursor is hidden.
4487 <item>The function is only available as fastcall function, so it may only be
4488 used in presence of a prototype.
4490 <tag/Availability/cc65
4492 <ref id="mouse_load_driver" name="mouse_load_driver">,
4493 <ref id="mouse_uninstall" name="mouse_uninstall">,
4494 <ref id="mouse_unload" name="mouse_unload">
4500 <sect1>mouse_ioctl<label id="mouse_ioctl"><p>
4504 <tag/Function/Call the driver specific ioctl function.
4505 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
4506 <tag/Declaration/<tt/unsigned char __fastcall__ mouse_ioctl (unsigned char code, void* data);/
4507 <tag/Description/The function calls the IOCTL entry in the mouse driver,
4508 which is driver specific. The <tt/code/ parameter will choose between
4509 different IOCTL functions, and the <tt/data/ depends on code. The
4510 function returns an error code. The purpose of this function is to allow
4511 for driver specific extensions. See the documentation for a specific mouse
4512 driver for supported ioctl calls.
4513 <tag/Notes/<itemize>
4514 <item>Calling this function is non portable, because each driver may
4515 implement different ioctl calls (or none at all).
4516 <item>The function is only available as fastcall function, so it may only be
4517 used in presence of a prototype.
4519 <tag/Availability/cc65
4525 <sect1>mouse_load_driver<label id="mouse_load_driver"><p>
4529 <tag/Function/Load and initialize a mouse driver.
4530 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
4531 <tag/Declaration/<tt/unsigned char __fastcall__ mouse_load_driver (const struct
4532 mouse_callbacks* c, const char* driver);/
4533 <tag/Description/Load a mouse driver into memory and initialize it. The
4534 function returns an error code that tells if the call has been successful. The
4535 <tt/mouse_callbacks/ structure passed as first parameter contains pointers to
4536 routines needed to move or hide/show the mouse pointer. Defaults for these
4537 routines are supplied by the library, so if you can live with these defaults
4538 (which are platform specific), just pass a pointer to <tt/mouse_def_callbacks/.
4539 <tag/Notes/<itemize>
4540 <item>The driver is loaded by name, so currently you must know the type of
4541 mouse that should be supported. There is no autodetect capability.
4542 <item>Not all drivers are able to detect if the supported hardware is really
4544 <item>After installing a driver, the mouse cursor is hidden.
4545 <item>The function is only available as fastcall function, so it may only be
4546 used in presence of a prototype.
4548 <tag/Availability/cc65
4550 <ref id="mouse_install" name="mouse_install">,
4551 <ref id="mouse_uninstall" name="mouse_uninstall">,
4552 <ref id="mouse_unload" name="mouse_unload">
4558 <sect1>mouse_move<label id="mouse_move"><p>
4562 <tag/Function/Move the mouse cursor to a specific position.
4563 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
4564 <tag/Declaration/<tt/void __fastcall__ mouse_move (int x, int y);/
4565 <tag/Description/The function updates the mouse position. If the mouse cursor
4566 is visible, it is shown at the new position.
4567 <tag/Notes/<itemize>
4568 <item>The function does not check if the new position is within the bounding
4569 box specified with <tt/<ref id="mouse_setbox" name="mouse_setbox">/.
4570 <item>The function is only available as fastcall function, so it may only be
4571 used in presence of a prototype.
4573 <tag/Availability/cc65
4575 <ref id="mouse_getbox" name="mouse_getbox">,
4576 <ref id="mouse_setbox" name="mouse_setbox">
4582 <sect1>mouse_pos<label id="mouse_pos"><p>
4586 <tag/Function/Return the position of the mouse.
4587 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
4588 <tag/Declaration/<tt/void __fastcall__ mouse_pos (struct mouse_pos* pos);/
4589 <tag/Description/The function returns the position of the mouse in the
4590 <tt/mouse_pos/ structure passed as parameter.
4591 <tag/Notes/<itemize>
4592 <item>The <tt/mouse_pos/ struct is a subset of the <tt/mouse_info/ struct,
4593 so if you do also need the mouse buttons, call <tt/<ref id="mouse_info"
4594 name="mouse_info">/ instead.
4595 <item>The function is only available as fastcall function, so it may only be
4596 used in presence of a prototype.
4598 <tag/Availability/cc65
4600 <ref id="mouse_buttons" name="mouse_buttons">,
4601 <ref id="mouse_info" name="mouse_info">
4607 <sect1>mouse_show<label id="mouse_show"><p>
4611 <tag/Function/Show the mouse pointer.
4612 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
4613 <tag/Declaration/<tt/void mouse_show (void);/
4614 <tag/Description/The function shows the mouse pointer. It manages a counter
4615 that is shared between <tt/<ref id="mouse_hide" name="mouse_hide">/ and
4616 <tt/mouse_show/. The mouse cursor is visible if there was one more call to
4617 <tt/mouse_show/ than to <tt/<ref id="mouse_hide" name="mouse_hide">/.
4618 <tag/Availability/cc65
4620 <ref id="mouse_hide" name="mouse_hide">
4626 <sect1>mouse_uninstall<label id="mouse_uninstall"><p>
4630 <tag/Function/Uninstall an already loaded mouse driver.
4631 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
4632 <tag/Declaration/<tt/unsigned char mouse_uninstall (void);/
4633 <tag/Description/The function uninstalls an already loaded mouse driver but
4634 don't removes it from memory.
4635 <tag/Notes/<itemize>
4636 <item>If the driver has been loaded using <tt/<ref id="mouse_load_driver"
4637 name="mouse_load_driver">/, <tt/<ref id="mouse_unload" name="mouse_unload">/
4638 should be used instead of <tt/mouse_uninstall/ so the driver is also removed
4641 <tag/Availability/cc65
4643 <ref id="mouse_install" name="mouse_install">,
4644 <ref id="mouse_load_driver" name="mouse_load_driver">,
4645 <ref id="mouse_unload" name="mouse_unload">
4651 <sect1>mouse_unload<label id="mouse_unload"><p>
4655 <tag/Function/Unload a mouse driver.
4656 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
4657 <tag/Declaration/<tt/unsigned char mouse_unload (void);/
4658 <tag/Description/The function unloads a loaded mouse driver and frees all
4659 memory allocated for the driver.
4660 <tag/Notes/<itemize>
4661 <item>The function does nothing if no driver is loaded.
4663 <tag/Availability/cc65
4665 <ref id="mouse_install" name="mouse_install">,
4666 <ref id="mouse_load_driver" name="mouse_load_driver">,
4667 <ref id="mouse_uninstall" name="mouse_uninstall">
4673 <sect1>offsetof<label id="offsetof"><p>
4677 <tag/Function/Calculate the offset of a struct or union member.
4678 <tag/Header/<tt/<ref id="stddef.h" name="stddef.h">/
4679 <tag/Declaration/<tt/size_t offsetof (type, member);/
4680 <tag/Description/<tt/offsetof/ calculates the address offset of a <tt/struct/
4681 or <tt/union/ member.
4682 <tag/Notes/<itemize>
4683 <item>The function is actually a macro.
4685 <tag/Availability/ISO 9899
4691 <sect1>open<label id="open"><p>
4695 <tag/Function/Open and possibly create a file.
4696 <tag/Header/<tt/<ref id="fcntl.h" name="fcntl.h">/
4697 <tag/Declaration/<tt/int open (const char* name, int flags, ...);/
4698 <tag/Description/<tt/open/ opens a file and returns the file descriptor
4699 associated with it. On error, -1 is returned and an error code is stored in
4700 <tt/errno/. Several flags may be passed to <tt/open/ that change the behaviour.
4701 <tag/Notes/<itemize>
4702 <item>POSIX specifies an additional <tt/mode/ argument that may be passed to
4703 open, which is used as the permission mask when a new file is created. While
4704 cc65 allows to pass this argument, it is ignored.
4706 <tag/Availability/POSIX 1003.1
4708 <ref id="close" name="close">,
4709 <ref id="creat" name="creat">
4715 <sect1>opendir<label id="opendir"><p>
4719 <tag/Function/Open a directory.
4720 <tag/Header/<tt/<ref id="dirent.h" name="dirent.h">/
4721 <tag/Declaration/<tt/DIR* __fastcall__ opendir (const char* name);/
4722 <tag/Description/<tt/opendir/ opens a directory and returns the direcory
4723 descriptor associated with it. On error, NULL is returned and an error code is
4724 stored in <tt/errno/.
4725 <tag/Notes/<itemize>
4726 <item>The function is only available as fastcall function, so it may only
4727 be used in presence of a prototype.
4729 <tag/Availability/POSIX 1003.1
4731 <ref id="closedir" name="closedir">,
4732 <ref id="readdir" name="readdir">
4738 <sect1>peekbsys<label id="peekbsys"><p>
4742 <tag/Function/Read one byte from a location in the system bank.
4743 <tag/Header/<tt/<ref id="cbm610.h" name="cbm610.h">/,
4744 <tt/<ref id="cbm510.h" name="cbm510.h">/
4745 <tag/Declaration/<tt/unsigned char __fastcall__ peekbsys (unsigned addr);/
4746 <tag/Description/<tt/peekbsys/ reads one byte from the given address in the
4747 system bank (bank 15) of the CBM PET-II machines and returns it.
4748 <tag/Notes/<itemize>
4749 <item>The function is only available as fastcall function, so it may only
4750 be used in presence of a prototype.
4751 <item>This function may be a macro depending on the compiler options. The
4752 actual function is accessible by #undef'ing the macro.
4754 <tag/Availability/cc65
4756 <ref id="PEEK" name="PEEK">,
4757 <ref id="PEEKW" name="PEEKW">,
4758 <ref id="peekwsys" name="peekwsys">,
4759 <ref id="pokebsys" name="pokebsys">,
4760 <ref id="pokewsys" name="pokewsys">
4766 <sect1>peekwsys<label id="peekwsys"><p>
4770 <tag/Function/Read one word from a location in the system bank.
4771 <tag/Header/<tt/<ref id="cbm610.h" name="cbm610.h">/,
4772 <tt/<ref id="cbm510.h" name="cbm510.h">/
4773 <tag/Declaration/<tt/unsigned __fastcall__ peekwsys (unsigned addr);/
4774 <tag/Description/<tt/peekwsys/ reads one word from the given address in the
4775 system bank (bank 15) of the CBM PET-II machines and returns it. Following
4776 the usual 6502 conventions, the low byte is read from <tt/addr/, and the
4777 high byte is read from <tt/addr+1/.
4778 <tag/Notes/<itemize>
4779 <item>The function is only available as fastcall function, so it may only
4780 be used in presence of a prototype.
4781 <item>The order in which the two bytes are read is undefined.
4783 <tag/Availability/cc65
4785 <ref id="PEEK" name="PEEK">,
4786 <ref id="PEEKW" name="PEEKW">,
4787 <ref id="peekbsys" name="peekbsys">,
4788 <ref id="pokebsys" name="pokebsys">,
4789 <ref id="pokewsys" name="pokewsys">
4795 <sect1>perror<label id="perror"><p>
4799 <tag/Function/Print an error message for the error in <tt/errno/.
4800 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
4801 <tag/Declaration/<tt/void __fastcall__ perror (const char* s);/
4802 <tag/Description/<tt/perror/ prints an error message to <tt/stderr/. If <tt/s/
4803 is not <tt/NULL/ and not an empty string, it is printed followed by a colon and
4804 a blank. Then the error message for the current contents of <tt/errno/ is
4805 printed followed by a newline. The message output is the same as returned by
4806 <tt/<ref id="strerror" name="strerror">/ with an argument of <tt/errno/.
4807 <tag/Notes/<itemize>
4808 <item>The function is only available as fastcall function, so it may only
4809 be used in presence of a prototype.
4811 <tag/Availability/ISO 9899
4813 <ref id="_poserror" name="_poserror">,
4814 <ref id="strerror" name="strerror">
4820 <sect1>pokebsys<label id="pokebsys"><p>
4824 <tag/Function/Write one byte to a location in the system bank.
4825 <tag/Header/<tt/<ref id="cbm610.h" name="cbm610.h">/,
4826 <tt/<ref id="cbm510.h" name="cbm510.h">/
4827 <tag/Declaration/<tt/void __fastcall__ pokebsys (unsigned addr, unsigned char val);/
4828 <tag/Description/<tt/pokebsys/ writes one byte to the given address in the
4829 system bank (bank 15) of the CBM PET-II machines.
4830 <tag/Notes/<itemize>
4831 <item>The function is only available as fastcall function, so it may only
4832 be used in presence of a prototype.
4834 <tag/Availability/cc65
4836 <ref id="POKE" name="POKE">,
4837 <ref id="POKEW" name="POKEW">,
4838 <ref id="peekbsys" name="peekbsys">,
4839 <ref id="peekwsys" name="peekwsys">,
4840 <ref id="pokewsys" name="pokewsys">
4846 <sect1>pokewsys<label id="pokewsys"><p>
4850 <tag/Function/Write one word to a location in the system bank.
4851 <tag/Header/<tt/<ref id="cbm610.h" name="cbm610.h">/,
4852 <tt/<ref id="cbm510.h" name="cbm510.h">/
4853 <tag/Declaration/<tt/void __fastcall__ pokewsys (unsigned addr, unsigned val);/
4854 <tag/Description/<tt/pokewsys/ writes one word to the given address in the
4855 system bank (bank 15) of the CBM PET-II machines. Following the usual 6502
4856 conventions, the low byte of <tt/val/ is written to <tt/addr/, and the
4857 high byte is written to <tt/addr+1/.
4858 <tag/Notes/<itemize>
4859 <item>The function is only available as fastcall function, so it may only
4860 be used in presence of a prototype.
4861 <item>The order in which the two bytes are written is undefined.
4863 <tag/Availability/cc65
4865 <ref id="POKE" name="POKE">,
4866 <ref id="POKEW" name="POKEW">,
4867 <ref id="peekbsys" name="peekbsys">,
4868 <ref id="peekwsys" name="peekwsys">,
4869 <ref id="pokebsys" name="pokebsys">
4875 <sect1>qsort<label id="qsort"><p>
4879 <tag/Function/Sort an array.
4880 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
4881 <tag/Declaration/<tt/void __fastcall__ qsort (void* base, size_t count,
4882 size_t size, int __fastcall__ (* compare) (const void*, const void*));/
4883 <tag/Description/<tt/qsort/ sorts an array according to a given compare
4884 function <tt/compare/. <tt/base/ is the address of the array, <tt/count/
4885 is the number of elements, <tt/size/ the size of an element and <tt/compare/
4886 the function used to compare the members.
4887 <tag/Notes/<itemize>
4888 <item>If there are multiple members with the same key, the order after calling
4889 the function is undefined.
4890 <item>The function is only available as fastcall function, so it may only
4891 be used in presence of a prototype.
4892 <item>The function to which <tt/compare/ points must have the <tt/fastcall/
4895 <tag/Availability/ISO 9899
4897 <ref id="bsearch" name="bsearch">
4903 <sect1>raise<label id="raise"><p>
4907 <tag/Function/Send a signal to the executing program.
4908 <tag/Header/<tt/<ref id="signal.h" name="signal.h">/
4909 <tag/Declaration/<tt/int __fastcall__ raise (int sig);/
4910 <tag/Description/<tt/raise/ sends the given signal to the program. If the
4911 program has installed a signal handler for the signal, this signal handler
4912 will be executed. If no handler has been installed, the default action for
4913 the raised signal will be taken. The function returns zero on success,
4915 <tag/Notes/<itemize>
4916 <item>The function is only available as fastcall function, so it may only
4917 be used in presence of a prototype.
4919 <tag/Availability/ISO 9899
4921 <ref id="abort" name="abort">,
4922 <ref id="signal" name="signal">
4928 <sect1>rand<label id="rand"><p>
4932 <tag/Function/Return a pseudo random number.
4933 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
4934 <tag/Declaration/<tt/int rand (void);/
4935 <tag/Description/The function returns a pseudo random number
4936 between 0 and <tt/RAND_MAX/ (exclusive).
4937 <tag/Notes/<itemize>
4938 <item>Without using <tt><ref id="srand" name="srand"></tt>, always the same
4939 flow of numbers is generated.
4940 <item>On startup, the function behaves as if <ref id="srand" name="srand">
4941 had been used with an argument of 1.
4943 <tag/Availability/ISO 9899
4945 <ref id="_randomize" name="_randomize">,
4946 <ref id="srand" name="srand">
4952 <sect1>readdir<label id="readdir"><p>
4956 <tag/Function/Read a directory.
4957 <tag/Header/<tt/<ref id="dirent.h" name="dirent.h">/
4958 <tag/Declaration/<tt/struct dirent* __fastcall__ readdir (DIR* dir);/
4959 <tag/Description/<tt/readdir/ reads the next directory entry from the directory
4960 stream pointed to by <tt/dir/. It stores the data in a <tt/dirent/ structure
4961 and returns a pointer to it. If the end of directory is reached, or an error
4962 occurs, NULL is returned. In case of errors, an error code is stored into
4964 <tag/Notes/<itemize>
4965 <item>The function is only available as fastcall function, so it may only
4966 be used in presence of a prototype.
4967 <item>The returned pointer may point to a statically allocated instance of
4968 <tt/struct dirent/, so it may get overwritten by subsequent calls to
4970 <item>On several platforms, namely the CBMs and the Atari, the disk drives get
4971 confused when opening/closing files between directory reads. So for example a
4972 program that reads the list of files on a disk, and after each call to
4973 <tt/readdir/, opens the file to process it, will fail.<newline>
4974 Possible solutions are reading the directory into memory before processing the
4975 file list, or to reset the directory by seeking to the correct position after
4976 opening/closing a file:
4978 seekdir (DIR, telldir (DIR));
4980 Platforms known to work without problems are: Apple.
4982 <tag/Availability/POSIX 1003.1
4984 <ref id="closedir" name="closedir">,
4985 <ref id="opendir" name="opendir">
4991 <sect1>realloc<label id="realloc"><p>
4995 <tag/Function/Change the size of an allocated memory block.
4996 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
4997 <tag/Declaration/<tt/void* __fastcall__ realloc (void* block, size_t size);/
4998 <tag/Description/<tt/realloc/ changes the size of the memory block pointed to
4999 by <tt/block/ to <tt/size/ bytes. If <tt/block/ is <tt/NULL/, <tt/realloc/
5000 behaves as if <tt/malloc/ had been called. If <tt/size/ is zero, <tt/realloc/
5001 behaves as if <tt/free/ had been called. On error (not enough memory
5002 available), <tt/realloc/ returns <tt/NULL/.
5003 <tag/Notes/<itemize>
5004 <item>The part of the memory block that is returned will have its contents
5006 <item>This function is somewhat dangerous to use. Be careful to save the
5007 pointer you're passing somewhere else, otherwise
5009 ptr = realloc (ptr, size);
5011 will loose your only copy of <tt/ptr/ if <tt/realloc/ returns <tt/NULL/.
5012 <item>The function is only available as fastcall function, so it may only
5013 be used in presence of a prototype.
5015 <tag/Availability/ISO 9899
5017 <ref id="_heapadd" name="_heapadd">,
5018 <ref id="_heapblocksize" name="_heapblocksize">,
5019 <ref id="_heapmaxavail" name="_heapmaxavail">,
5020 <ref id="_heapmemavail" name="_heapmemavail">,
5021 <ref id="calloc" name="calloc">,
5022 <ref id="free" name="free">,
5023 <ref id="realloc" name="realloc">
5029 <sect1>remove<label id="remove"><p>
5033 <tag/Function/Delete a file.
5034 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
5035 <tag/Declaration/<tt/int __fastcall__ remove (const char* name);/
5036 <tag/Description/<tt/remove/ deletes the file with the given name. On success,
5037 zero is returned. On error, -1 is returned and <tt/errno/ is set to an error
5038 code describing the reason for the failure.
5039 <tag/Notes/<itemize>
5040 <item>This function is not available on all cc65 targets (depends on the
5041 availability of file I/O).
5042 <item>The function is only available as fastcall function, so it may only
5043 be used in presence of a prototype.
5045 <tag/Availability/ISO 9899
5047 <ref id="rename" name="rename">,
5048 <ref id="unlink" name="unlink">
5051 #include <stdio.h>
5053 #define FILENAME "helloworld"
5055 if (remove (FILENAME) == 0) {
5056 printf ("We deleted %s successfully\n", FILENAME);
5058 printf ("There was a problem deleting %s\n", FILENAME);
5065 <sect1>rename<label id="rename"><p>
5069 <tag/Function/Rename a file.
5070 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
5071 <tag/Declaration/<tt/int __fastcall__ rename (const char* oldname, const char* newname);/
5072 <tag/Description/<tt/rename/ renames a file (gives it a new name). On success,
5073 zero is returned. On error, -1 is returned and <tt/errno/ is set to an error
5074 code describing the reason for the failure.
5075 <tag/Notes/<itemize>
5076 <item>This function is not available on all cc65 targets (depends on the
5077 capabilities of the storage devices).
5078 <item>The function is only available as fastcall function, so it may only
5079 be used in presence of a prototype.
5081 <tag/Availability/ISO 9899
5083 <ref id="remove" name="remove">
5086 #include <stdio.h>
5088 #define OLDNAME "textfile.txt"
5089 #define NEWNAME "textfile.bak"
5091 if (rename (OLDNAME, NEWNAME) == 0) {
5092 printf ("Renamed %s to %s\n", OLDNAME, NEWNAME);
5094 printf ("Error renaming %s to %s\n", OLDNAME, NEWNAME);
5101 <sect1>reset_brk<label id="reset_brk"><p>
5105 <tag/Function/Resets the break vector to its original value.
5106 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
5107 <tag/Declaration/<tt/void reset_brk (void);/
5108 <tag/Description/<tt/reset_brk/ resets the break vector to the value it had
5109 before a call to <tt/set_brk/.
5110 <tag/Notes/<itemize>
5111 <item>The break vector is reset on program termination, so it's not strictly
5112 necessary to call this function as a part of your clean-up when exitting the program.
5114 <tag/Availability/cc65
5116 <ref id="reset_irq" name="reset_irq">,
5117 <ref id="set_brk" name="set_brk">,
5118 <ref id="set_irq" name="set_irq">
5124 <sect1>reset_irq<label id="reset_irq"><p>
5128 <tag/Function/Resets the C level interrupt request vector.
5129 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
5130 <tag/Declaration/<tt/void reset_irq (void);/
5131 <tag/Description/<tt/reset_irq/ resets the C level interrupt request vector.
5132 <tag/Notes/<itemize>
5133 <item>The interrupt vector is reset on program termination, so it's not strictly
5134 necessary to call this function as a part of your clean-up when exitting the program.
5136 <tag/Availability/cc65
5138 <ref id="reset_brk" name="reset_brk">,
5139 <ref id="set_brk" name="set_brk">,
5140 <ref id="set_irq" name="set_irq">
5146 <sect1>revers<label id="revers"><p>
5150 <tag/Function/Control revers character display.
5151 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
5152 <tag/Declaration/<tt/unsigned char __fastcall__ revers (unsigned char onoff);/
5153 <tag/Description/If the argument is non zero, the function enables reverse
5154 character display. If the argument is zero, reverse character display is
5155 switched off. The old value of the setting is returned.
5156 <tag/Notes/<itemize>
5157 <item>The function may not be supported by the hardware, in which case
5158 the call is ignored.
5159 <item>The function is only available as fastcall function, so it may only
5160 be used in presence of a prototype.
5162 <tag/Availability/cc65
5164 <ref id="textcolor" name="textcolor">
5170 <sect1>rewinddir<label id="rewinddir"><p>
5174 <tag/Function/Reset a directory stream.
5175 <tag/Header/<tt/<ref id="dirent.h" name="dirent.h">/
5176 <tag/Declaration/<tt/void __fastcall__ rewinddir (DIR* dir);/
5177 <tag/Description/<tt/rewinddir/ sets the position of the directory stream
5178 pointed to by <tt/dir/ to the start of the directory.
5179 <tag/Notes/<itemize>
5180 <item>The function is only available as fastcall function, so it may only
5181 be used in presence of a prototype.
5183 <tag/Availability/POSIX 1003.1
5185 <ref id="seekdir" name="seekdir">,
5186 <ref id="telldir" name="telldir">
5192 <sect1>screensize<label id="screensize"><p>
5196 <tag/Function/Return the dimensions of the text mode screen.
5197 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
5198 <tag/Declaration/<tt/void __fastcall__ screensize (unsigned char* x, unsigned char* y);/
5199 <tag/Description/The function returns the dimensions of the text mode screen.
5200 <tag/Notes/<itemize>
5201 <item>The function is only available as fastcall function, so it may only
5202 be used in presence of a prototype.
5204 <tag/Availability/cc65
5206 <ref id="gotox" name="gotox">,
5207 <ref id="gotoxy" name="gotoxy">,
5208 <ref id="gotoy" name="gotoy">,
5209 <ref id="wherex" name="wherex">,
5210 <ref id="wherey" name="wherey">
5216 <sect1>seekdir<label id="seekdir"><p>
5220 <tag/Function/Set the position of a directory stream.
5221 <tag/Header/<tt/<ref id="dirent.h" name="dirent.h">/
5222 <tag/Declaration/<tt/void __fastcall__ seekdir (DIR* dir, long offset);/
5223 <tag/Description/<tt/seekdir/ sets the position of the directory stream
5224 pointed to by <tt/dir/ to the value given in <tt/offset/, which should be a
5225 value returned by <tt/<ref id="telldir" name="telldir">/.
5226 <tag/Notes/<itemize>
5227 <item>The function is only available as fastcall function, so it may only
5228 be used in presence of a prototype.
5230 <tag/Availability/POSIX 1003.1
5232 <ref id="rewinddir" name="rewinddir">,
5233 <ref id="telldir" name="telldir">
5239 <sect1>ser_close<label id="ser_close"><p>
5243 <tag/Function/Close the port and disable interrupts
5244 <tag/Header/<tt/<ref id="serial.h" name="serial.h">/
5245 <tag/Declaration/<tt/unsigned char ser_close (void);/
5246 <tag/Description/Close the port by clearing buffers and disable interrupts.
5247 <tag/Availability/cc65
5248 <tag/See also/Other serial functions.
5253 static void initialize(){
5254 struct ser_params params = {
5261 ser_install(lynx_comlynx); // This will activate the ComLynx
5263 ser_open(&params);
5270 <sect1>ser_get<label id="ser_get"><p>
5274 <tag/Function/Read a character from serial port.
5275 <tag/Header/<tt/<ref id="serial.h" name="serial.h">/
5276 <tag/Declaration/<tt/unsigned char __fastcall__ ser_get (char* b);/
5277 <tag/Description/Get a character from the serial port. If no characters are
5278 available, the function will return SER_ERR_NO_DATA, so this is not a fatal
5280 <tag/Notes/<itemize>
5281 <item>The function is only available as fastcall function, so it may only
5282 be used in presence of a prototype.
5284 <tag/Availability/cc65
5285 <tag/See also/Other serial functions.
5287 Wait for a character to be available from a serial port.
5290 while (ser_get(&ch) == SER_ERR_NO_DATA)
5297 <sect1>ser_install<label id="ser_install"><p>
5301 <tag/Function/Install an already loaded driver and return an error code.
5302 <tag/Header/<tt/<ref id="serial.h" name="serial.h">/
5303 <tag/Declaration/<tt/unsigned char __fastcall__ ser_install (void* driver);/
5304 <tag/Description/The function installs a driver that was already loaded into
5305 memory (or linked statically to the program). It returns an error code
5306 (<tt/SER_ERR_OK/ in case of success).
5307 <tag/Notes/<itemize>
5308 <item>The function is only available as fastcall function, so it may only be
5309 used in presence of a prototype.
5311 <tag/Availability/cc65
5313 <ref id="ser_load_driver" name="ser_load_driver">,
5314 <ref id="ser_uninstall" name="ser_uninstall">,
5315 <ref id="ser_unload" name="ser_unload">
5317 ser_install(lynx_comlynx); //Include the driver statically instead of loading it.
5323 <sect1>ser_ioctl<label id="ser_ioctl"><p>
5327 <tag/Function/Platform dependent code extensions.
5328 <tag/Header/<tt/<ref id="serial.h" name="serial.h">/
5329 <tag/Declaration/<tt/unsigned __fastcall__ ser_ioctl (unsigned char code, void* data);/
5330 <tag/Description/Some platforms have extra serial functions that are not
5331 supported by standard serial driver functions. You can extend the driver to support
5332 this extra functionality bt using ser_ioctl functions.
5333 <tag/Notes/<itemize>
5334 <item>The function is only available as fastcall function, so it may only
5335 be used in presence of a prototype.
5336 <item>These functions are not easily portable to other cc65 platforms.
5338 <tag/Availability/cc65
5339 <tag/See also/Other serial functions.
5344 <sect1>ser_load_driver<label id="ser_load_driver"><p>
5348 <tag/Function/Load and install a serial driver.
5349 <tag/Header/<tt/<ref id="serial.h" name="serial.h">/
5350 <tag/Declaration/<tt/unsigned char __fastcall__ ser_load_driver (const char *name);/
5351 <tag/Description/Load and install the driver by name.
5352 Will just load the driver and check if loading was successful.
5353 <tag/Notes/<itemize>
5354 <item>The function is only available as fastcall function, so it may only
5355 be used in presence of a prototype.
5357 <tag/Availability/cc65
5358 <tag/See also/Other serial functions.
5364 <sect1>ser_open<label id="ser_open"><p>
5368 <tag/Function/Open the port by setting the port parameters and enable interrupts
5369 <tag/Header/<tt/<ref id="serial.h" name="serial.h">/
5370 <tag/Declaration/<tt/unsigned char __fastcall__ ser_open (const struct ser_params* params);/
5371 <tag/Description/Open the port by setting the port parameters and enable interrupts.
5372 <tag/Notes/<itemize>
5373 <item>The function is only available as fastcall function, so it may only
5374 be used in presence of a prototype.
5376 <tag/Availability/cc65
5377 <tag/See also/Other serial functions.
5382 static void initialize(){
5383 struct ser_params params = {
5390 ser_install(lynx_comlynx); // This will activate the ComLynx
5392 ser_open(&params);
5399 <sect1>ser_put<label id="ser_put"><p>
5403 <tag/Function/Write a character to a serial port.
5404 <tag/Header/<tt/<ref id="serial.h" name="serial.h">/
5405 <tag/Declaration/<tt/unsigned char __fastcall__ ser_put (char b);/
5406 <tag/Description/Send a character via the serial port. There is a transmit
5407 buffer, but transmitting is not done via interrupt. The function returns
5408 SER_ERR_OVERFLOW if there is no space left in the transmit buffer.
5409 <tag/Notes/<itemize>
5410 <item>The function is only available as fastcall function, so it may only
5411 be used in presence of a prototype.
5413 <tag/Availability/cc65
5414 <tag/See also/Other serial functions.
5423 <sect1>ser_status<label id="ser_status"><p>
5427 <tag/Function/Return the serial port status.
5428 <tag/Header/<tt/<ref id="serial.h" name="serial.h">/
5429 <tag/Declaration/<tt/unsigned char __fastcall__ ser_status (unsigned char* status);/
5430 <tag/Description/Return the serial port status.
5431 <tag/Notes/<itemize>
5432 <item>The function is only available as fastcall function, so it may only
5433 be used in presence of a prototype.
5435 <tag/Availability/cc65
5436 <tag/See also/Other serial functions.
5442 <sect1>ser_uninstall<label id="ser_uninstall"><p>
5446 <tag/Function/Uninstall the currently loaded driver but do not unload it.
5447 <tag/Header/<tt/<ref id="serial.h" name="serial.h">/
5448 <tag/Declaration/<tt/unsigned char ser_uninstall (void);/
5449 <tag/Description/Uninstall the currently loaded driver but do not unload it.
5450 <tag/Availability/cc65
5451 <tag/See also/Other serial functions.
5456 <sect1>ser_unload<label id="ser_unload"><p>
5460 <tag/Function/Uninstall, then unload the currently loaded driver.
5461 <tag/Header/<tt/<ref id="serial.h" name="serial.h">/
5462 <tag/Declaration/<tt/unsigned char ser_unload (void);/
5463 <tag/Description/Uninstall, then unload the currently loaded driver.
5464 <tag/Availability/cc65
5465 <tag/See also/Other serial functions.
5471 <sect1>set_brk<label id="set_brk"><p>
5475 <tag/Function/Set the break vector to a user function.
5476 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
5477 <tag/Declaration/<tt/void __fastcall__ set_brk (brk_handler func);/
5478 <tag/Description/<tt/set_brk/ allows a user program to handle breaks within the
5479 program code by letting the vector point to a user written C function. The
5480 runtime library installs a small stub that saves the registers into global
5481 variables that may be accessed (and changed) by the break handler.
5482 <tag/Notes/<itemize>
5483 <item>The function is only available as fastcall function, so it may only
5484 be used in presence of a prototype.
5485 <item>The stub saves the zero page registers used by the C runtime and switches
5486 to a small break handler stack. This means that it is safe to execute C code,
5487 even if C code was interrupted. Be careful however not to use too many local
5488 variables, and do not enable stack checks for the handler function or any other
5489 function called from it.
5490 <item>The <tt/brk_pc/ variable points to the <tt/BRK/ instruction. If you want
5491 the continue with the interrupted code, you have to adjust <tt/brk_pc/,
5492 otherwise the <tt/BRK/ instruction will get executed over and over again.
5493 <item>The break vector is reset on program termination, so it's not strictly
5494 necessary to call <tt/<ref id="reset_brk" name="reset_brk">/ as a part of your
5495 clean-up when exitting the program.
5497 <tag/Availability/cc65
5499 <ref id="reset_brk" name="reset_brk">
5505 <sect1>set_irq<label id="set_irq"><p>
5509 <tag/Function/Set the C level interrupt request vector to the given address.
5510 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
5511 <tag/Declaration/<tt/void __fastcall__ set_irq (irq_handler f, void *stack_addr, size_t stack_size);/
5512 <tag/Description/<tt/set_irq/ allows a user program to handle interrupt requests
5513 (IRQs) within the program code by letting the vector point to a user written C
5514 function. The runtime library installs a small stub that saves the zero page
5515 registers used by the C runtime before calling the handler function and restores
5516 them after the handler function returns. Additionally the stub temporarily switches
5517 the C runtime stack to the stack area provided as parameter. If the handler function
5518 was set up to handle a "private", "exclusive" interrupt request source it must
5519 return the value <tt/IRQ_HANDLED/ if and only if it has verified that the current
5520 interrupt request actually stems from that source. In all other cases it must return
5521 the value <tt/IRQ_NOT_HANDLED/.
5522 <tag/Notes/<itemize>
5523 <item>The function is only available as fastcall function, so it may only
5524 be used in presence of a prototype.
5525 <item>The stub saves the registers and zero page locations used by the C runtime
5526 and switches to the provided stack area. As a consequence, there is some
5527 runtime overhead, but it it is safe to execute C code, even if other C code
5528 was interrupted. Be careful however not to call C library functions, and do not
5529 enable stack checks for the handler function or any other function called from
5531 <item>The interrupt vector is reset on program termination, so it's not strictly
5532 necessary to call <tt/<ref id="reset_irq" name="reset_irq">/ as a part of your
5533 clean-up when exitting the program.
5535 <tag/Availability/cc65
5537 <ref id="reset_brk" name="reset_brk">,
5538 <ref id="reset_irq" name="reset_irq">,
5539 <ref id="set_brk" name="set_brk">
5545 <sect1>setjmp<label id="setjmp"><p>
5549 <tag/Function/Save the context for use with <tt/longjmp/.
5550 <tag/Header/<tt/<ref id="setjmp.h" name="setjmp.h">/
5551 <tag/Declaration/<tt/int __fastcall__ setjmp (jmp_buf buf);/
5552 <tag/Description/The <tt/setjmp/ function saves the current context in <tt/buf/
5553 for subsequent use by the <tt/<ref id="longjmp" name="longjmp">/ function and
5555 <tag/Notes/<itemize>
5556 <item>The function is only available as fastcall function, so it may only
5557 be used in presence of a prototype.
5558 <item><tt/setjmp/ is actually a macro as required by the ISO standard.
5559 <item><tt/setjmp/ will not save the signal context.
5561 <tag/Availability/ISO 9899
5563 <ref id="longjmp" name="longjmp">
5569 <sect1>setlocale<label id="setlocale"><p>
5573 <tag/Function/Selects a locale.
5574 <tag/Header/<tt/<ref id="locale.h" name="locale.h">/
5575 <tag/Declaration/<tt/char* __fastcall__ setlocale (int category, const char* locale);/
5576 <tag/Description/<tt/setlocale/ sets or queries the program's locale.
5577 <tag/Notes/<itemize>
5578 <item>The function is only available as fastcall function, so it may only
5579 be used in presence of a prototype.
5580 <item>cc65 supports only the "C" locale, so calling this function to set a
5581 different locale has no effect.
5583 <tag/Availability/ISO 9899
5585 <ref id="localeconv" name="localeconv">,
5586 <ref id="strcoll" name="strcoll">
5587 <ref id="strxfrm" name="strxfrm">
5593 <sect1>signal<label id="signal"><p>
5597 <tag/Function/Install a signal handler.
5598 <tag/Header/<tt/<ref id="signal.h" name="signal.h">/
5599 <tag/Declaration/<tt/__sigfunc __fastcall__ signal (int sig, __sigfunc func);/
5600 <tag/Description/<tt/signal/ installs a handler for the given signal. The
5601 handler may either be a user supplied function, or one of the predefined
5602 signal handlers <tt/SIG_IGN/ or <tt/SIG_DFL/. The function returns the
5603 previous value if the signal , or the special function vector SIG_ERR in
5605 <tag/Notes/<itemize>
5606 <item>The function is only available as fastcall function, so it may only
5607 be used in presence of a prototype.
5609 <tag/Availability/ISO 9899
5611 <ref id="abort" name="abort">,
5612 <ref id="raise" name="raise">
5618 <sect1>sleep<label id="sleep"><p>
5622 <tag/Function/Sleep for a specified amount of time.
5623 <tag/Header/<tt/<ref id="unistd.h" name="unistd.h">/
5624 <tag/Declaration/<tt/void __fastcall__ sleep (unsigned seconds);/
5625 <tag/Description/The function will return after the specified number of
5626 seconds have elapsed.
5627 <tag/Notes/<itemize>
5628 <item>The function is only available as fastcall function, so it may only
5629 be used in presence of a prototype.
5631 <tag/Availability/POSIX 1003.1
5637 <sect1>slow<label id="slow"><p>
5641 <tag/Function/Switch the C128 into 1MHz mode.
5642 <tag/Header/<tt/<ref id="c128.h" name="c128.h">/
5643 <tag/Declaration/<tt/void slow (void);/
5644 <tag/Description/The function will switch the clock of the C128 to 1MHz. This
5645 will halve the speed compared to fast mode.
5646 <tag/Notes/<itemize>
5647 <item>The function is specific to the C128.
5649 <tag/Availability/C128
5651 <ref id="fast" name="fast">,
5652 <ref id="toggle_videomode" name="toggle_videomode">,
5653 <ref id="videomode" name="videomode">
5659 <sect1>srand<label id="srand"><p>
5663 <tag/Function/Initialize the pseudo random number generator.
5664 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
5665 <tag/Declaration/<tt/void __fastcall__ srand (unsigned seed);/
5666 <tag/Description/The function initializes the random number generator using
5667 the given seed. On program startup, the generator behaves as if <tt/srand/ has
5668 been called with an argument of 1.
5669 <tag/Notes/<itemize>
5670 <item>The function is only available as fastcall function, so it may only
5671 be used in presence of a prototype.
5673 <tag/Availability/ISO 9899
5675 <ref id="_randomize" name="_randomize">,
5676 <ref id="rand" name="rand">
5682 <sect1>strcasecmp<label id="strcasecmp"><p>
5686 <tag/Function/Compare two strings case insensitive.
5687 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5688 <tag/Declaration/<tt/int __fastcall__ strcasecmp (const char* s1, const char* s2);/
5689 <tag/Description/The <tt/strcasecmp/ function compares the two strings passed
5690 as parameters without case sensitivity. It returns a value that is less than
5691 zero if <tt/s1/ is less than <tt/s2/, zero if <tt/s1/ is the same as <tt/s2/,
5692 and a value greater than zero if <tt/s1/ is greater than <tt/s2/.
5693 <tag/Notes/<itemize>
5694 <item>The function is only available as fastcall function, so it may only
5695 be used in presence of a prototype.
5696 <item>The function is not available in strict ANSI mode.
5698 <tag/Availability/cc65
5700 <ref id="strcmp" name="strcmp">,
5701 <ref id="strcoll" name="strcoll">,
5702 <ref id="stricmp" name="stricmp">,
5703 <ref id="strncmp" name="strncmp">,
5704 <ref id="strxfrm" name="strxfrm">
5710 <sect1>strcat<label id="strcat"><p>
5714 <tag/Function/Concatentate two strings.
5715 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5716 <tag/Declaration/<tt/char* __fastcall__ strcat (char* s1, const char* s2);/
5717 <tag/Description/The <tt/strcat/ function appends a copy of the string
5718 pointed to by s2 (including the terminating null byte) to the end of the
5719 string pointed to by s1. The initial byte of s2 overwrites the null byte at
5721 <tag/Notes/<itemize>
5722 <item>The function is only available as fastcall function, so it may only
5723 be used in presence of a prototype.
5724 <item>If copying takes place between objects that overlap, the behaviour
5727 <tag/Availability/ISO 9899
5729 <ref id="strcpy" name="strcpy">,
5730 <ref id="strncat" name="strncat">,
5731 <ref id="strncpy" name="strncpy">
5737 <sect1>strchr<label id="strchr"><p>
5741 <tag/Function/Search for a character in a string.
5742 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5743 <tag/Declaration/<tt/char* __fastcall__ strchr (const char* s, int c);/
5744 <tag/Description/The <tt/strchr/ function locates the first occurrence of <tt/c/
5745 (converted to a char) in the string pointed to by <tt/s/. The terminating null
5746 byte is considered to be part of the string. Upon completion, the function
5747 returns a pointer to the byte, or a null pointer if the byte was not found.
5748 <tag/Notes/<itemize>
5749 <item>The function is only available as fastcall function, so it may only
5750 be used in presence of a prototype.
5752 <tag/Availability/ISO 9899
5754 <ref id="memchr" name="memchr">,
5755 <ref id="strrchr" name="strrchr">
5761 <sect1>strcmp<label id="strcmp"><p>
5765 <tag/Function/Compare two strings.
5766 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5767 <tag/Declaration/<tt/int __fastcall__ strcmp (const char* s1, const char* s2);/
5768 <tag/Description/The <tt/strcmp/ function compares the two strings passed as
5769 parameters. It returns a value that is less than zero if <tt/s1/ is less than
5770 <tt/s2/, zero if <tt/s1/ is the same as <tt/s2/, and a value greater than zero
5771 if <tt/s1/ is greater than <tt/s2/.
5772 <tag/Notes/<itemize>
5773 <item>The function is only available as fastcall function, so it may only
5774 be used in presence of a prototype.
5776 <tag/Availability/ISO 9899
5778 <ref id="strcasecmp" name="strcasecmp">,
5779 <ref id="strcoll" name="strcoll">,
5780 <ref id="stricmp" name="stricmp">,
5781 <ref id="strncmp" name="strncmp">
5782 <ref id="strxfrm" name="strxfrm">
5788 <sect1>strcoll<label id="strcoll"><p>
5792 <tag/Function/Compare two strings.
5793 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5794 <tag/Declaration/<tt/int __fastcall__ strcoll (const char* s1, const char* s2);/
5795 <tag/Description/The <tt/strcoll/ function compares the two strings passed as
5796 parameters, according to the collating sequence set by <tt/<ref id="setlocale"
5797 name="setlocale">/. It returns a value that is less than zero if <tt/s1/ is
5798 less than <tt/s2/, zero if <tt/s1/ is the same as <tt/s2/, and a value greater
5799 than zero if <tt/s1/ is greater than <tt/s2/.
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.
5804 <tag/Availability/ISO 9899
5806 <ref id="setlocale" name="setlocale">,
5807 <ref id="strcasecmp" name="strcasecmp">,
5808 <ref id="strcmp" name="strcmp">,
5809 <ref id="stricmp" name="stricmp">,
5810 <ref id="strncmp" name="strncmp">,
5811 <ref id="strxfrm" name="strxfrm">
5817 <sect1>strcpy<label id="strcpy"><p>
5821 <tag/Function/Copy a string.
5822 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5823 <tag/Declaration/<tt/char* __fastcall__ strcpy (char* s1, const char* s2);/
5824 <tag/Description/The <tt/strcpy/ function copies the string pointed to by
5825 <tt/s2/ (including the terminating null byte) into the array pointed to by
5826 <tt/s1/. The function will always return <tt/s1/.
5827 <tag/Notes/<itemize>
5828 <item>The function is only available as fastcall function, so it may only
5829 be used in presence of a prototype.
5830 <item>If copying takes place between objects that overlap, the behaviour
5833 <tag/Availability/ISO 9899
5835 <ref id="strcat" name="strcat">,
5836 <ref id="strncat" name="strncat">,
5837 <ref id="strncpy" name="strncpy">
5840 #include <string.h>
5842 static char hello[14];
5844 strcpy (hello, "Hello world!\n");
5850 <sect1>strcspn<label id="strcspn"><p>
5854 <tag/Function/Compute the length of a substring.
5855 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5856 <tag/Declaration/<tt/size_t __fastcall__ strcspn (const char* s, const char* set);/
5857 <tag/Description/The <tt/strcspn/ function computes and returns the length of
5858 the substring pointed to by <tt/s/ which does <em>not</em> consist of
5859 characters contained in the string <tt/set/.
5860 <tag/Notes/<itemize>
5861 <item>The function is only available as fastcall function, so it may only
5862 be used in presence of a prototype.
5864 <tag/Availability/ISO 9899
5866 <ref id="strqtok" name="strqtok">,
5867 <ref id="strspn" name="strspn">,
5868 <ref id="strstr" name="strstr">,
5869 <ref id="strtok" name="strtok">
5875 <sect1>strdup<label id="strdup"><p>
5879 <tag/Function/Allocate a copy of a string on the heap.
5880 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5881 <tag/Declaration/<tt/char* __fastcall__ strdup (const char* s);/
5882 <tag/Description/<tt/strdup/ allocates a memory block on the heap, big enough
5883 to hold a copy of <tt/s/ including the terminating zero. If the allocation
5884 fails, <tt/NULL/ is returned, otherwise <tt/s/ is copied into the allocated
5885 memory block, and a pointer to the block is returned.
5886 <tag/Notes/<itemize>
5887 <item>The function is only available as fastcall function, so it may only
5888 be used in presence of a prototype.
5889 <item>It is up to the caller to free the allocated memory block.
5891 <tag/Availability/ISO 9899
5893 <ref id="free" name="free">,
5894 <ref id="malloc" name="malloc">
5900 <sect1>strerror<label id="strerror"><p>
5904 <tag/Function/Return a string describing an error code.
5905 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5906 <tag/Declaration/<tt/char* __fastcall__ strerror (int errcode);/
5907 <tag/Description/The <tt/strerror/ function returns a string describing the
5908 given error code. If an invalid error code is passed, the string "Unknown
5909 error" is returned, and <tt/errno/ is set to <tt/EINVAL/. In all other cases,
5910 <tt/errno/ is left untouched.
5911 <tag/Notes/<itemize>
5912 <item>The function is only available as fastcall function, so it may only
5913 be used in presence of a prototype.
5914 <item>While the return type of the function is a <tt/char*/, the returned
5915 string must not be modified by the caller!
5917 <tag/Availability/ISO 9899
5919 <ref id="_stroserror" name="_stroserror">
5925 <sect1>stricmp<label id="stricmp"><p>
5929 <tag/Function/Compare two strings case insensitive.
5930 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5931 <tag/Declaration/<tt/int __fastcall__ stricmp (const char* s1, const char* s2);/
5932 <tag/Description/The <tt/stricmp/ function compares the two strings passed as
5933 parameters without case sensitivity. It returns a value that is less than zero
5934 if <tt/s1/ is less than <tt/s2/, zero if <tt/s1/ is the same as <tt/s2/, and a
5935 value greater than zero if <tt/s1/ is greater than <tt/s2/.
5936 <tag/Notes/<itemize>
5937 <item>The function is only available as fastcall function, so it may only
5938 be used in presence of a prototype.
5939 <item>The function is not available in strict ANSI mode.
5941 <tag/Availability/cc65
5943 <ref id="strcasecmp" name="strcasecmp">,
5944 <ref id="strcmp" name="strcmp">,
5945 <ref id="strcoll" name="strcoll">,
5946 <ref id="strncmp" name="strncmp">,
5947 <ref id="strxfrm" name="strxfrm">
5953 <sect1>strlen<label id="strlen"><p>
5957 <tag/Function/Return the length of a string.
5958 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5959 <tag/Declaration/<tt/size_t __fastcall__ strlen (const char* s);/
5960 <tag/Description/The <tt/strlen/ function computes the number of bytes in the
5961 string to which s points, not including the terminating null byte.
5962 <tag/Notes/<itemize>
5963 <item>The function is only available as fastcall function, so it may only
5964 be used in presence of a prototype.
5965 <item>When compiling with <tt/-Os/ (inline known standard functions), the
5966 function does not work correctly for strings with more than 255 characters.
5968 <tag/Availability/ISO 9899
5970 <ref id="strcpy" name="strcpy">
5976 <sect1>strlower<label id="strlower"><p>
5980 <tag/Function/Make a string lower case.
5981 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5982 <tag/Declaration/<tt/char* __fastcall__ strlower (char* s);/
5983 <tag/Description/The <tt/strlower/ function will apply the <tt/tolower/
5984 function to each character of a string. The function will always return <tt/s/.
5985 <tag/Notes/<itemize>
5986 <item>The function is only available as fastcall function, so it may only
5987 be used in presence of a prototype.
5988 <item>The function prototype is unavailable when compiling in strict ANSI mode.
5989 <item>An alias name for this function is <tt/strlwr/.
5991 <tag/Availability/cc65
5993 <ref id="strupper" name="strupper">,
5994 <ref id="tolower" name="tolower">
6000 <sect1>strlwr<label id="strlwr"><p>
6007 <sect1>strncat<label id="strncat"><p>
6011 <tag/Function/Concatentate two strings.
6012 <tag/Header/<tt/<ref id="string.h" name="string.h">/
6013 <tag/Declaration/<tt/char* __fastcall__ strncat (char* s1, const char* s2, size_t n);/
6014 <tag/Description/The <tt/strncat/ function appends not more than n characters
6015 of the string pointed to by s2 to the end of the string pointed to by s1. The
6016 terminating null character at the end of s1 is overwritten. A terminating null
6017 character is appended to the result, even if not all of s2 is appended to s1.
6018 <tag/Notes/<itemize>
6019 <item>The function is only available as fastcall function, so it may only
6020 be used in presence of a prototype.
6021 <item>If copying takes place between objects that overlap, the behaviour
6024 <tag/Availability/ISO 9899
6026 <ref id="strcpy" name="strcpy">,
6027 <ref id="strncat" name="strncat">,
6028 <ref id="strncpy" name="strncpy">
6034 <sect1>strncmp<label id="strncmp"><p>
6038 <tag/Function/Compare two strings.
6039 <tag/Header/<tt/<ref id="string.h" name="string.h">/
6040 <tag/Declaration/<tt/int __fastcall__ strncmp (const char* s1, const char* s2, size_t count);/
6041 <tag/Description/The <tt/strncmp/ function compares not more than <tt/count/
6042 characters of the two strings passed as parameters. It returns a value that is
6043 less than zero if the first <tt/count/ characters of <tt/s1/ are less than
6044 <tt/s2/, zero if they are identical, and a value greater than zero they are
6046 <tag/Notes/<itemize>
6047 <item>The function is only available as fastcall function, so it may only
6048 be used in presence of a prototype.
6050 <tag/Availability/ISO 9899
6052 <ref id="strcasecmp" name="strcasecmp">,
6053 <ref id="strcmp" name="strcmp">,
6054 <ref id="strcoll" name="strcoll">,
6055 <ref id="stricmp" name="stricmp">,
6056 <ref id="strxfrm" name="strxfrm">
6062 <sect1>strncpy<label id="strncpy"><p>
6066 <tag/Function/Copy part of a string.
6067 <tag/Header/<tt/<ref id="string.h" name="string.h">/
6068 <tag/Declaration/<tt/char* __fastcall__ strncpy (char* s1, const char* s2, size_t n);/
6069 <tag/Description/The <tt/strncpy/ function copies not more than <tt/n/ bytes from
6070 the array pointed to by <tt/s2/ to the array pointed to by <tt/s1/. If the array
6071 pointed to by <tt/s2/ is a string that is shorter than <tt/n/ bytes, null bytes are
6072 appended to the copy in the array pointed to by <tt/s1/, until <tt/n/ bytes are
6073 written. The function always will return <tt/s1/.
6074 <tag/Notes/<itemize>
6075 <item>The function is available only as a fastcall function; so, it may be used
6076 only in the presence of a prototype.
6077 <item>If there is no null byte in the first <tt/n/ bytes of the array pointed
6078 to by <tt/s2/, the result is <em/not/ null-terminated!
6079 <item>If copying takes place between objects that overlap, the behaviour is
6082 <tag/Availability/ISO 9899
6084 <ref id="memcpy" name="memcpy">,
6085 <ref id="strcat" name="strcat">,
6086 <ref id="strcpy" name="strcpy">,
6087 <ref id="strncat" name="strncat">
6092 static char hello[6];
6094 strncpy (hello, "Hello world!\n", sizeof hello - 1)[5] = '\0';
6100 <sect1>strqtok<label id="strqtok"><p>
6104 <tag/Function/Break a string into tokens.
6105 <tag/Header/<tt/<ref id="string.h" name="string.h">/
6106 <tag/Declaration/<tt/char* __fastcall__ strqtok (char* s1, const char* s2);/
6107 <tag/Description/<tt/strqtok()/ will break the string <tt/s1/ into a sequence of
6108 tokens, which are delimited by either quotation marks or characters from the
6109 string <tt/s2/. Tokens inside quotation marks may contain characters from <tt/s2/
6110 (they aren't delimiters there). The first call to <tt/strqtok()/ will return a
6111 pointer to the first token in the string <tt/s1/. The following calls must pass
6112 a <tt/NULL/ pointer as <tt/s1/, in order to get the next token in the string.
6113 Different sets of delimiters may be used for the subsequent calls to <tt/strqtok()/.
6114 <tag/Notes/<itemize>
6115 <item>The function is available only as a fastcall function; so, it may be used
6116 only in the presence of a prototype.
6117 <item><tt/strqtok()/ will modify the string <tt/s1/.
6118 <item>The function will forget where it is in the <tt/s1/ string if it is given
6119 a second <tt/s1/ string before it finishes the first one.
6121 <tag/Availability/cc65
6123 <ref id="strcspn" name="strcspn">,
6124 <!-- <ref id="strpbrk" name="strpbrk">, -->
6125 <ref id="strspn" name="strspn">,
6126 <ref id="strtok" name="strtok">
6132 <sect1>strrchr<label id="strrchr"><p>
6136 <tag/Function/Search for a character in a string.
6137 <tag/Header/<tt/<ref id="string.h" name="string.h">/
6138 <tag/Declaration/<tt/char* __fastcall__ strrchr (const char* s, int c);/
6139 <tag/Description/The <tt/strrchr/ function locates the last occurrence of <tt/c/
6140 (converted to a char) in the string pointed to by <tt/s/. The terminating null
6141 byte is considered to be part of the string. Upon completion, the function
6142 returns a pointer to the byte, or a null pointer if the byte was not found.
6143 <tag/Notes/<itemize>
6144 <item>The function is only available as fastcall function, so it may only
6145 be used in presence of a prototype.
6147 <tag/Availability/ISO 9899
6149 <ref id="strchr" name="strchr">
6155 <sect1>strspn<label id="strspn"><p>
6159 <tag/Function/Compute the length of a substring.
6160 <tag/Header/<tt/<ref id="string.h" name="string.h">/
6161 <tag/Declaration/<tt/size_t __fastcall__ strspn (const char* s, const char* set);/
6162 <tag/Description/The <tt/strspn/ function computes and returns the length of
6163 the substring pointed to by <tt/s/ which does consist only of characters
6164 contained in the string <tt/set/.
6165 <tag/Notes/<itemize>
6166 <item>The function is only available as fastcall function, so it may only
6167 be used in presence of a prototype.
6169 <tag/Availability/ISO 9899
6171 <ref id="strcspn" name="strcspn">,
6172 <ref id="strstr" name="strstr">
6178 <sect1>strstr<label id="strstr"><p>
6182 <tag/Function/Find a substring.
6183 <tag/Header/<tt/<ref id="string.h" name="string.h">/
6184 <tag/Declaration/<tt/char* __fastcall__ strstr (const char* str, const char* substr);/
6185 <tag/Description/<tt/strstr/ searches for the first occurance of the string
6186 <tt/substr/ within <tt/str/. If found, it returns a pointer to the copy,
6187 otherwise it returns <tt/NULL/.
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.
6192 <tag/Availability/ISO 9899
6194 <ref id="strcspn" name="strcspn">,
6195 <ref id="strspn" name="strspn">
6201 <sect1>strtok<label id="strtok"><p>
6205 <tag/Function/Break a string into tokens.
6206 <tag/Header/<tt/<ref id="string.h" name="string.h">/
6207 <tag/Declaration/<tt/char* __fastcall__ strtok (char* s1, const char* s2);/
6208 <tag/Description/<tt/strtok()/ will break the string <tt/s1/ into a sequence of
6209 tokens, which are delimited by characters from the string <tt/s2/. The first call
6210 to <tt/strtok()/ will return a pointer to the first token in the string <tt/s1/.
6211 The following calls must pass a <tt/NULL/ pointer as <tt/s1/, in order to get
6212 the next token in the string. Different sets of delimiters may be used for the
6213 subsequent calls to <tt/strtok()/.
6214 <tag/Notes/<itemize>
6215 <item>The function is only available as fastcall function, so it may only
6216 be used in presence of a prototype.
6217 <item><tt/strtok()/ will modify the string <tt/s1/.
6218 <item>The function will forget where it is in the <tt/s1/ string if it is given
6219 a second <tt/s1/ string before it finishes the first one.
6221 <tag/Availability/ISO 9899
6223 <ref id="strcspn" name="strcspn">,
6224 <!-- <ref id="strpbrk" name="strpbrk">, -->
6225 <ref id="strqtok" name="strqtok">,
6226 <ref id="strspn" name="strspn">
6232 <sect1>strxfrm<label id="strxfrm"><p>
6236 <tag/Function/Transform a string.
6237 <tag/Header/<tt/<ref id="string.h" name="string.h">/
6238 <tag/Declaration/<tt/size_t __fastcall__ strxfrm (char* s1, const char* s2, size_t n);/
6239 <tag/Description/The <tt/strxfrm/ function transforms the string pointed to by
6240 s2 and places the resulting string into the string pointed to by s1. The
6241 transformation is such that if the <tt/strcmp/ function is applied to two
6242 transformed strings, it returns a value greater than, equal to, or less than
6243 zero, corresponding to the result of the <tt/strcoll/ function applied to the
6244 same two original strings. No more than n characters are placed into the
6245 resulting array pointed to by s1, including the terminating null character.
6246 <tag/Notes/<itemize>
6247 <item><tt/s1/ and <tt/s2/ must not point to the same memory area, otherwise
6248 the behaviour is undefined.
6249 <item>If <tt/n/ is zero, <tt/s1/ may be a NULL pointer.
6250 <item>The function is only available as fastcall function, so it may only
6251 be used in presence of a prototype.
6252 <item>Since cc65 doesn't support different charcter sets, <tt/strxfrm/ will
6253 just copy s2 to s1 using <tt><ref id="strncpy" name="strncpy"></tt>.
6255 <tag/Availability/ISO 9899
6257 <ref id="strcmp" name="strcmp">,
6258 <ref id="strcoll" name="strcoll">,
6259 <ref id="strncpy" name="strncpy">
6265 <sect1>strupper<label id="strupper"><p>
6269 <tag/Function/Make a string upper case.
6270 <tag/Header/<tt/<ref id="string.h" name="string.h">/
6271 <tag/Declaration/<tt/char* __fastcall__ strupper (char* s);/
6272 <tag/Description/The <tt/strupper/ function will apply the <tt/toupper/
6273 function to each character of a string. The function will always return <tt/s/.
6274 <tag/Notes/<itemize>
6275 <item>The function is only available as fastcall function, so it may only
6276 be used in presence of a prototype.
6277 <item>The function prototype is unavailable when compiling in strict ANSI mode.
6278 <item>An alias name for this function is <tt/strupr/.
6280 <tag/Availability/cc65
6282 <ref id="strlower" name="strlower">
6283 <ref id="toupper" name="toupper">
6289 <sect1>strupr<label id="strupr"><p>
6296 <sect1>telldir<label id="telldir"><p>
6300 <tag/Function/Return the current position of a directory stream.
6301 <tag/Header/<tt/<ref id="dirent.h" name="dirent.h">/
6302 <tag/Declaration/<tt/long __fastcall__ telldir (DIR* dir);/
6303 <tag/Description/<tt/telldir/ returns the current position of a directory
6304 stream. The return value may be used in subsequent calls to
6305 <tt/<ref id="seekdir" name="seekdir">/.
6306 <tag/Notes/<itemize>
6307 <item>The function is only available as fastcall function, so it may only
6308 be used in presence of a prototype.
6310 <tag/Availability/POSIX 1003.1
6312 <ref id="seekdir" name="seekdir">,
6313 <ref id="telldir" name="telldir">
6319 <sect1>textcolor<label id="textcolor"><p>
6323 <tag/Function/Set the text color.
6324 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
6325 <tag/Declaration/<tt/unsigned char __fastcall__ textcolor (unsigned char color);/
6326 <tag/Description/The function will set a new text color. It returns the old
6327 (current) text color. Text output using any <tt/conio.h/ function will use
6328 the color set by this function.
6329 <tag/Notes/<itemize>
6330 <item>Text colors are system dependent. The function may have no effect
6331 on systems where the text color cannot be changed.
6332 <item>The function is only available as fastcall function, so it may only
6333 be used in presence of a prototype.
6335 <tag/Availability/cc65
6337 <ref id="bgcolor" name="bgcolor">,
6338 <ref id="bordercolor" name="bordercolor">
6344 <sect1>tgi_arc<label id="tgi_arc"><p>
6348 <tag/Function/Draw an elliptic arc in the current color.
6349 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6350 <tag/Declaration/<tt/void __fastcall__ tgi_arc (int x, int y,
6351 unsigned char rx, unsigned char ry, unsigned sa, unsigned ea);/
6352 <tag/Description/The function draws an elliptic arc with center at x/y and
6353 radii rx/ry using the current drawing color. The arc covers the angle
6354 between sa and ea (startangle and endangle), which must be in the range
6356 <tag/Notes/<itemize>
6357 <item>The function is only available as fastcall function, so it may only
6358 be used in presence of a prototype.
6359 <item>The function behaves unexpectedly or may crash if the angles are out
6362 <tag/Availability/cc65
6364 <ref id="tgi_bar" name="tgi_bar">,
6365 <ref id="tgi_circle" name="tgi_circle">,
6366 <ref id="tgi_ellipse" name="tgi_ellipse">,
6367 <ref id="tgi_pieslice" name="tgi_pieslice">,
6368 <ref id="tgi_setcolor" name="tgi_setcolor">
6370 /* Draw the upper half of an ellipse */
6371 tgi_setcolor(TGI_COLOR_BLUE);
6372 tgi_arc (50, 50, 40, 20, 0, 180);
6378 <sect1>tgi_bar<label id="tgi_bar"><p>
6382 <tag/Function/The function fills a rectangle on the drawpage with the current
6384 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6385 <tag/Declaration/<tt/void __fastcall__ tgi_bar (int x1, int y1, int x2, int y2);/
6386 <tag/Description/The function fills a rectangle on the drawpage with the current
6388 <tag/Notes/<itemize>
6389 <item>The function is only available as fastcall function, so it may only
6390 be used in presence of a prototype.
6392 <tag/Availability/cc65
6393 <tag/See also/Other tgi function
6395 tgi_setcolor(TGI_COLOR_GREEN);
6396 tgi_bar(10, 10, 100, 60);
6402 <sect1>tgi_circle<label id="tgi_circle"><p>
6406 <tag/Function/The function draws a circle in the current color.
6407 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6408 <tag/Declaration/<tt/void __fastcall__ tgi_circle (int x, int y, unsigned char radius);/
6409 <tag/Description/The function draws a circle in the current color.
6410 <tag/Notes/<itemize>
6411 <item>The function is only available as fastcall function, so it may only
6412 be used in presence of a prototype.
6414 <tag/Availability/cc65
6416 <ref id="tgi_arc" name="tgi_arc">,
6417 <ref id="tgi_bar" name="tgi_bar">,
6418 <ref id="tgi_ellipse" name="tgi_ellipse">,
6419 <ref id="tgi_pieslice" name="tgi_pieslice">,
6420 <ref id="tgi_setcolor" name="tgi_setcolor">
6422 tgi_setcolor(TGI_COLOR_BLACK);
6423 tgi_circle(50, 40, 40);
6429 <sect1>tgi_clear<label id="tgi_clear"><p>
6433 <tag/Function/Clear the drawpage
6434 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6435 <tag/Declaration/<tt/void tgi_clear (void);/
6436 <tag/Description/Clear the drawpage
6437 <tag/Availability/cc65
6438 <tag/See also/Other tgi functions
6444 <sect1>tgi_done<label id="tgi_done"><p>
6448 <tag/Function/End graphics mode, switch back to text mode.
6449 Will NOT uninstall or unload the driver!
6450 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6451 <tag/Declaration/<tt/void tgi_done (void);/
6452 <tag/Description/End graphics mode, switch back to text mode.
6453 Will NOT uninstall or unload the driver!
6454 <tag/Availability/cc65
6455 <tag/See also/Other tgi functions
6461 <sect1>tgi_ellipse<label id="tgi_ellipse"><p>
6465 <tag/Function/The function draws an ellipse in the current color.
6466 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6467 <tag/Declaration/<tt/void __fastcall__ tgi_ellipse (int x, int y, unsigned char rx, unsigned char ry);/
6468 <tag/Description/The function draws an ellipse at position x/y with radii
6469 rx and ry, using the current drawing color.
6470 <tag/Notes/<itemize>
6471 <item>The function is only available as fastcall function, so it may only
6472 be used in presence of a prototype.
6474 <tag/Availability/cc65
6476 <ref id="tgi_arc" name="tgi_arc">,
6477 <ref id="tgi_bar" name="tgi_bar">,
6478 <ref id="tgi_circle" name="tgi_circle">,
6479 <ref id="tgi_pieslice" name="tgi_pieslice">,
6480 <ref id="tgi_setcolor" name="tgi_setcolor">
6482 tgi_setcolor(TGI_COLOR_RED);
6483 tgi_ellipse (50, 40, 40, 20);
6489 <sect1>tgi_free_vectorfont<label id="tgi_free_vectorfont"><p>
6493 <tag/Function/Free a vector font that was previously loaded into memory.
6494 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6495 <tag/Declaration/<tt/void __fastcall__ tgi_free_vectorfont (const tgi_vectorfont* font);/
6496 <tag/Description/Free a vector font that was previously loaded into memory.
6497 <tag/Notes/<itemize>
6498 <item>The function is only available as fastcall function, so it may only
6499 be used in presence of a prototype.
6501 <tag/Availability/cc65
6503 <ref id="tgi_load_vectorfont" name="tgi_load_vectorfont">,
6504 <ref id="tgi_install_vectorfont" name="tgi_install_vectorfont">
6510 <sect1>tgi_getaspectratio<label id="tgi_getaspectratio"><p>
6512 <quote> <descrip> <tag/Function/Return the pixel aspect ratio.
6513 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6514 <tag/Declaration/<tt/unsigned tgi_getaspectratio (void);/
6515 <tag/Description/The function returns the pixel aspect ratio for the current
6516 driver and display as an 8.8 fixed point value. It may be used to correct
6517 geometric shapes so they look correct on the display. As an example, a circle
6518 with a radius of 100 pixels may look elliptic on some driver/display
6519 combinations if the aspect ratio is not 1.00.
6520 <tag/Notes/<itemize>
6521 <item>The aspect ratio is encoded in the TGI driver which assumes a "standard"
6522 monitor for the given platform. The aspect ratio may be wrong if another
6524 <item>No TGI function will use the aspect ratio. It is up to the programmer to
6526 <item>The <ref id="tgi_setaspectratio" name="tgi_setaspectratio"> function can
6527 be used to change the aspect ratio for a loaded driver. The value is not reset
6528 by <ref id="tgi_init" name="tgi_init">, so if a driver is linked statically to
6529 an application, switching into and out of graphics mode will not restore the
6530 original aspect ratio.
6532 <tag/Availability/cc65
6534 <ref id="tgi_setaspectratio" name="tgi_setaspectratio">
6540 <sect1>tgi_getcolor<label id="tgi_getcolor"><p>
6544 <tag/Function/Return the current drawing color.
6545 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6546 <tag/Declaration/<tt/unsigned char tgi_getcolor (void);/
6547 <tag/Description/The actual color is an index to a palette. During tgi_init
6548 you will get a default palette. The number of colors depend on the platform.
6549 All platforms recognize at least TGI_COLOR_BLACK and TGI_COLOR_WHITE. But some
6550 platforms have many more predefined colors. If you paint using TGI_COLOR_GREEN
6551 and then you change the green of the palette to blue using tgi_setpalette then
6552 after this painting in TGI_COLOR_GREEN will actually be blue.
6553 <tag/Availability/cc65
6554 <tag/See also/Other tgi functions
6556 color = tgi_getcolor();
6562 <sect1>tgi_getcolorcount<label id="tgi_getcolorcount"><p>
6566 <tag/Function/Get the number of available colors.
6567 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6568 <tag/Declaration/<tt/unsigned char tgi_getcolorcount (void);/
6569 <tag/Description/Tgi platforms use indexed color palettes. This function
6570 returns the number of entries we can use in the palette.
6571 <tag/Availability/cc65
6572 <tag/See also/Other tgi functions
6574 if (tgi_getcolorcount() == 2) {
6575 printf("Only monochrome graphics is supported\n");
6582 <sect1>tgi_getdefpalette<label id="tgi_getdefpalette"><p>
6586 <tag/Function/Get the palette installed by default.
6587 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6588 <tag/Declaration/<tt/const unsigned char* tgi_getdefpalette (void);/
6589 <tag/Description/The tgi driver has a default palette that is active at startup.
6590 The named colors TGI_COLOR_BLACK, TGI_COLOR_WHITE, TGI_COLOR_RED... need this
6591 palette to work correctly.
6592 <tag/Availability/cc65
6593 <tag/See also/Other tgi functions
6599 <sect1>tgi_geterror<label id="tgi_geterror"><p>
6603 <tag/Function/Return the error code for the last operation.
6604 This will also clear the error.
6605 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6606 <tag/Declaration/<tt/unsigned char tgi_geterror (void);/
6607 <tag/Description/Return the error code for the last operation.
6608 This will also clear the error.
6609 <tag/Availability/cc65
6610 <tag/See also/Other tgi functions
6616 <sect1>tgi_geterrormsg<label id="tgi_geterrormsg"><p>
6620 <tag/Function/Get an error message describing the error.
6621 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6622 <tag/Declaration/<tt/const char* __fastcall__ tgi_geterrormsg (unsigned char code);/
6623 <tag/Description/Get an error message describing the error.
6624 <tag/Notes/<itemize>
6625 <item>The function is only available as fastcall function, so it may only
6626 be used in presence of a prototype.
6628 <tag/Availability/cc65
6629 <tag/See also/Other tgi functions
6635 <sect1>tgi_getmaxcolor<label id="tgi_getmaxcolor"><p>
6639 <tag/Function/Get the highest index of the palette.
6640 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6641 <tag/Declaration/<tt/unsigned char tgi_getmaxcolor (void);/
6642 <tag/Description/Get the highest index of the palette.
6643 <tag/Availability/cc65
6644 <tag/See also/Other tgi functions
6650 <sect1>tgi_getmaxx<label id="tgi_getmaxx"><p>
6654 <tag/Function/Get the maximum x coordinate that can be used on this screen.
6655 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6656 <tag/Declaration/<tt/unsigned tgi_getmaxx (void);/
6657 <tag/Description/Get the maximum x coordinate that can be used on this screen.
6658 <tag/Availability/cc65
6659 <tag/See also/Other tgi functions
6665 <sect1>tgi_getmaxy<label id="tgi_getmaxy"><p>
6669 <tag/Function/Get the maximum y coordinate that can be used on this screen.
6670 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6671 <tag/Declaration/<tt/unsigned tgi_getmaxy (void);/
6672 <tag/Description/Get the maximum y coordinate that can be used on this screen.
6673 <tag/Availability/cc65
6674 <tag/See also/Other tgi functions
6680 <sect1>tgi_getpagecount<label id="tgi_getpagecount"><p>
6684 <tag/Function/Return the number of screen pages available.
6685 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6686 <tag/Declaration/<tt/unsigned tgi_getpagecount (void);/
6687 <tag/Description/Return the number of screen pages available.
6688 <tag/Availability/cc65
6690 <ref id="tgi_setdrawpage" name="tgi_setdrawpage">,
6691 <ref id="tgi_setviewpage" name="tgi_setviewpage">
6697 <sect1>tgi_getpalette<label id="tgi_getpalette"><p>
6701 <tag/Function/Get the palette installed.
6702 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6703 <tag/Declaration/<tt/const unsigned char* tgi_getpalette (void);/
6704 <tag/Description/Get the palette installed.
6705 <tag/Availability/cc65
6706 <tag/See also/Other tgi functions
6712 <sect1>tgi_getpixel<label id="tgi_getpixel"><p>
6716 <tag/Function/Get the color of a pixel from the viewpage.
6717 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6718 <tag/Declaration/<tt/unsigned char __fastcall__ tgi_getpixel (int x, int y);/
6719 <tag/Description/Get the color of a pixel from the viewpage.
6720 <tag/Notes/<itemize>
6721 <item>The function is only available as fastcall function, so it may only
6722 be used in presence of a prototype.
6724 <tag/Availability/cc65
6725 <tag/See also/Other tgi functions.
6731 <sect1>tgi_getxres<label id="tgi_getxres"><p>
6735 <tag/Function/Get number of horisontal pixels on the screen.
6736 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6737 <tag/Declaration/<tt/unsigned tgi_getxres (void);/
6738 <tag/Description/Get number of horisontal pixels on the screen.
6739 This is same as tgi_maxx()+1.
6740 <tag/Availability/cc65
6741 <tag/See also/Other tgi functions.
6747 <sect1>tgi_getyres<label id="tgi_getyres"><p>
6751 <tag/Function/Get number of vertical pixels on the screen.
6752 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6753 <tag/Declaration/<tt/unsigned tgi_getyres (void);/
6754 <tag/Description/Get number of vertical pixels on the screen.
6755 This is same as tgi_maxy()+1.
6756 <tag/Availability/cc65
6757 <tag/See also/Other tgi functions.
6763 <sect1>tgi_gotoxy<label id="tgi_gotoxy"><p>
6767 <tag/Function/Set graphics cursor at x, y.
6768 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6769 <tag/Declaration/<tt/void __fastcall__ tgi_gotoxy (int x, int y);/
6770 <tag/Description/Set graphics cursor at x, y.
6771 <tag/Notes/<itemize>
6772 <item>The function is only available as fastcall function, so it may only
6773 be used in presence of a prototype.
6775 <tag/Availability/cc65
6776 <tag/See also/Other tgi functions.
6782 <sect1>tgi_init<label id="tgi_init"><p>
6786 <tag/Function/Initialize the already loaded graphics driver.
6787 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6788 <tag/Declaration/<tt/void tgi_init (void);/
6789 <tag/Description/The tgi_init function will set the default palette to the
6791 <tag/Notes/<itemize>
6792 <item><tt/tgi_init/ will not clear the screen. This allows switching between
6793 text and graphics mode on platforms that have separate memory areas for the
6794 screens. If you want the screen cleared, call <tt/<ref id="tgi_clear"
6795 name="tgi_clear">/ after <tt/tgi_init/.
6797 <tag/Availability/cc65
6798 <tag/See also/Other tgi functions.
6800 tgi_install(tgi_static_stddrv); //Include the driver statically instead of loading it.
6801 tgi_init(); //Set up the default palette and clear the screen.
6807 <sect1>tgi_install<label id="tgi_install"><p>
6811 <tag/Function/Install an already loaded driver and return an error code.
6812 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6813 <tag/Declaration/<tt/unsigned char __fastcall__ tgi_install (void* driver);/
6814 <tag/Description/The function installs a driver that was already loaded into
6815 memory (or linked statically to the program). It returns an error code
6816 (<tt/TGI_ERR_OK/ in case of success).
6817 <tag/Notes/<itemize>
6818 <item>The function is only available as fastcall function, so it may only be
6819 used in presence of a prototype.
6821 <tag/Availability/cc65
6823 <ref id="tgi_load_driver" name="tgi_load_driver">,
6824 <ref id="tgi_uninstall" name="tgi_uninstall">,
6825 <ref id="tgi_unload" name="tgi_unload">
6827 tgi_install(tgi_static_stddrv); //Include the driver statically instead of loading it.
6828 tgi_init(); //Set up the default palette and clear the screen.
6834 <sect1>tgi_install_vectorfont<label id="tgi_install_vectorfont"><p>
6838 <tag/Function/Install an already loaded driver and return an error code.
6839 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6840 <tag/Declaration/<tt/void __fastcall__ tgi_install_vectorfont (const tgi_vectorfont* font);/
6842 Install a vector font for use. More than one vector font can be loaded,
6843 but only one can be active. This function is used to tell which one. Call
6844 with a NULL pointer to uninstall the currently installed font.
6845 <tag/Notes/<itemize>
6846 <item>The function is only available as fastcall function, so it may only be
6847 used in presence of a prototype.
6849 <tag/Availability/cc65
6851 <ref id="tgi_load_vectorfont" name="tgi_load_vectorfont">,
6852 <ref id="tgi_free_vectorfont" name="tgi_free_vectorfont">
6858 <sect1>tgi_ioctl<label id="tgi_ioctl"><p>
6862 <tag/Function/Platform dependent code extensions.
6863 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6864 <tag/Declaration/<tt/unsigned __fastcall__ tgi_ioctl (unsigned char code, void* data);/
6865 <tag/Description/Some platforms have extra display hardware that is not
6866 supported by standard tgi functions. You can extend the driver to support
6867 this extra hardware using tgi_ioctl functions.
6868 <tag/Notes/<itemize>
6869 <item>The function is only available as fastcall function, so it may only
6870 be used in presence of a prototype.
6871 <item>These functions are not easily portable to other cc65 platforms.
6873 <tag/Availability/cc65
6874 <tag/See also/Other tgi functions.
6876 #define tgi_sprite(spr) tgi_ioctl(0, (void*)(spr))
6877 #define tgi_flip() tgi_ioctl(1, (void*)0)
6878 #define tgi_setbgcolor(bgcol) tgi_ioctl(2, (void*)(bgcol))
6879 #define tgi_setframerate(rate) tgi_ioctl(3, (void*)(rate))
6880 #define tgi_busy() tgi_ioctl(4, (void*)0)
6881 #define tgi_updatedisplay() tgi_ioctl(4, (void*)1)
6883 tgi_sprite(&background);
6884 tgi_setcolor(TGI_COLOR_BLUE);
6885 tgi_outttextxy(20,40,"Hello World");
6886 tgi_updatedisplay();
6893 <sect1>tgi_line<label id="tgi_line"><p>
6897 <tag/Function/Draw a line in the current drawing color.
6898 The graphics cursor will be set to x2/y2 by this call.
6899 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6900 <tag/Declaration/<tt/void __fastcall__ tgi_line (int x1, int y1, int x2, int y2);/
6901 <tag/Description/Draw a line in the current drawing color.
6902 The graphics cursor will be set to x2/y2 by this call.
6903 <tag/Notes/<itemize>
6904 <item>The function is only available as fastcall function, so it may only
6905 be used in presence of a prototype.
6907 <tag/Availability/cc65
6908 <tag/See also/Other tgi functions.
6914 <sect1>tgi_lineto<label id="tgi_lineto"><p>
6918 <tag/Function/Draw a line in the current drawing color from the graphics
6919 cursor to the new end point. The graphics cursor will be updated to x2/y2.
6920 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6921 <tag/Declaration/<tt/void __fastcall__ tgi_lineto (int x2, int y2);/
6922 <tag/Description/Draw a line in the current drawing color from the graphics
6923 cursor to the new end point. The graphics cursor will be updated to x2/y2.
6924 <tag/Notes/<itemize>
6925 <item>The function is only available as fastcall function, so it may only
6926 be used in presence of a prototype.
6928 <tag/Availability/cc65
6929 <tag/See also/Other tgi functions.
6935 <sect1>tgi_load_driver<label id="tgi_load_driver"><p>
6939 <tag/Function/Load and install the given driver.
6940 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6941 <tag/Declaration/<tt/void __fastcall__ tgi_load_driver (const char *name);/
6942 <tag/Description/Load and install the driver by name.
6943 Will just load the driver and check if loading was successful.
6944 Will not switch to graphics mode.
6945 <tag/Notes/<itemize>
6946 <item>The function is only available as fastcall function, so it may only
6947 be used in presence of a prototype.
6949 <tag/Availability/cc65
6950 <tag/See also/Other tgi functions.
6956 <sect1>tgi_load_vectorfont<label id="tgi_load_vectorfont"><p>
6960 <tag/Function/Load the given vector font.
6961 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6962 <tag/Declaration/<tt/const tgi_vectorfont* __fastcall__ tgi_load_vectorfont (const char* name);/
6964 Load a vector font into memory and return it. In case of errors, NULL is
6965 returned and an error is set, which can be retrieved using tgi_geterror.
6966 To use the font, it has to be installed using tgi_install_vectorfont.
6967 <tag/Notes/<itemize>
6968 <item>The function is only available as fastcall function, so it may only
6969 be used in presence of a prototype.
6971 <tag/Availability/cc65
6973 <ref id="tgi_install_vectorfont" name="tgi_install_vectorfont">,
6974 <ref id="tgi_free_vectorfont" name="tgi_free_vectorfont">
6980 <sect1>tgi_outtext<label id="tgi_outtext"><p>
6984 <tag/Function/Output text at the current graphics cursor position.
6985 The graphics cursor is moved to the end of the text.
6986 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6987 <tag/Declaration/<tt/void __fastcall__ tgi_outtext (const char* s);/
6988 <tag/Description/Output text at the current graphics cursor position.
6989 The graphics cursor is moved to the end of the text.
6990 <tag/Notes/<itemize>
6991 <item>The function is only available as fastcall function, so it may only
6992 be used in presence of a prototype.
6994 <tag/Availability/cc65
6995 <tag/See also/Other tgi functions.
7001 <sect1>tgi_outtextxy<label id="tgi_outtextxy"><p>
7005 <tag/Function/Output text at the given cursor position.
7006 The graphics cursor is moved to the end of the text.
7007 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
7008 <tag/Declaration/<tt/void __fastcall__ tgi_outtextxy (int x, int y, const char* s);/
7009 <tag/Description/Output text at the given cursor position.
7010 The graphics cursor is moved to the end of the text.
7011 <tag/Notes/<itemize>
7012 <item>The function is only available as fastcall function, so it may only
7013 be used in presence of a prototype.
7015 <tag/Availability/cc65
7016 <tag/See also/Other tgi functions.
7022 <sect1>tgi_pieslice<label id="tgi_pieslice"><p>
7026 <tag/Function/Draw an elliptic pie slice in the current color.
7027 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
7028 <tag/Declaration/<tt/void __fastcall__ tgi_pie slice (int x, int y,
7029 unsigned char rx, unsigned char ry, unsigned sa, unsigned ea);/
7030 <tag/Description/The function draws an elliptic pie slice with center at x/y
7031 and radii rx/ry using the current drawing color. The pie slice covers the angle
7032 between sa and ea (startangle and endangle), which must be in the range
7034 <tag/Notes/<itemize>
7035 <item>The function is only available as fastcall function, so it may only
7036 be used in presence of a prototype.
7037 <item>The function behaves unexpectedly or may crash if the angles are out
7040 <tag/Availability/cc65
7042 <ref id="tgi_bar" name="tgi_arc">,
7043 <ref id="tgi_bar" name="tgi_bar">,
7044 <ref id="tgi_circle" name="tgi_circle">,
7045 <ref id="tgi_ellipse" name="tgi_ellipse">,
7046 <ref id="tgi_setcolor" name="tgi_setcolor">
7048 /* Draw the closed upper half of an ellipse */
7049 tgi_setcolor(TGI_COLOR_BLUE);
7050 tgi_pieslice (50, 50, 40, 20, 0, 180);
7056 <sect1>tgi_setaspectratio<label id="tgi_setaspectratio"><p>
7058 <quote> <descrip> <tag/Function/Set the pixel aspect ratio.
7059 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
7060 <tag/Declaration/<tt/void __fastcall__ tgi_setaspectratio (unsigned ratio);/
7061 <tag/Description/The function sets the pixel aspect ratio for the current
7062 driver and display. The argument is an 8.8 fixed point value. The aspect ratio
7063 may be used to correct geometric shapes so they look correct on a given
7064 display. As an example, a circle with a radius of 100 pixels may look elliptic
7065 on some driver/display combinations if the aspect ratio is not 1.00.
7066 <tag/Notes/<itemize>
7067 <item>The aspect ratio is encoded in the TGI driver which assumes a "standard"
7068 monitor for the given platform. The aspect ratio may be wrong if another
7070 <item>No TGI function will use the aspect ratio. It is up to the programmer to
7072 <item>The <tt/tgi_setaspectratio/ function can be used to change the aspect
7073 ratio for a loaded driver. The value is not reset by <ref id="tgi_init"
7074 name="tgi_init">, so if a driver is linked statically to an application,
7075 switching into and out of graphics mode will not restore the original aspect
7077 <item>The function is available only as a fastcall function; so, it may be used
7078 only in the presence of a prototype.
7080 <tag/Availability/cc65
7082 <ref id="tgi_getaspectratio" name="tgi_getaspectratio">
7088 <sect1>tgi_setcolor<label id="tgi_setcolor"><p>
7092 <tag/Function/Set color to be used in future draw operations.
7093 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
7094 <tag/Declaration/<tt/void __fastcall__ tgi_setcolor (unsigned char color);/
7095 <tag/Description/Set color to be used in future draw operations.
7096 <tag/Notes/<itemize>
7097 <item>The function is only available as fastcall function, so it may only
7098 be used in presence of a prototype.
7100 <tag/Availability/cc65
7101 <tag/See also/Other tgi functions.
7103 tgi_setcolor(TGI_COLOR_BLACK);
7105 tgi_setcolor(TGI_COLOR_WHITE);
7106 tgi_bar(10,10,20,20);
7111 <sect1>tgi_setdrawpage<label id="tgi_setdrawpage"><p>
7115 <tag/Function/Set the page for drawing.
7116 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
7117 <tag/Declaration/<tt/void __fastcall__ tgi_setdrawpage (unsigned char page);/
7118 <tag/Description/If the drawpage and the viewpage are the same then all drawing
7119 is seen immediately as it is drawn. For double buffered games you can set the
7120 drawpage to a different page than the viewpage. This lets you draw the next
7121 screen in the background and when the screen is ready you display it.
7122 <tag/Notes/<itemize>
7123 <item>The function is only available as fastcall function, so it may only
7124 be used in presence of a prototype.
7126 <tag/Availability/cc65
7127 <tag/See also/Other tgi functions.
7130 tgi_outtextxy(10, 10, "Hello World");
7131 tgi_setviewpage(1); // Show page 1
7133 tgi_outtextxy(10, 10, "Creating next frame");
7135 tgi_setviewpage(0); // Show page 0
7140 <sect1>tgi_setpalette<label id="tgi_setpalette"><p>
7144 <tag/Function/Set the palette (not available with all drivers/hardware).
7145 Palette is a pointer to as many entries as there are colors.
7146 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
7147 <tag/Declaration/<tt/void __fastcall__ tgi_setpalette (const unsigned char* palette);/
7148 <tag/Description/Set the palette (not available with all drivers/hardware).
7149 Palette is a pointer to as many entries as there are colors.
7150 <tag/Notes/<itemize>
7151 <item>The function is only available as fastcall function, so it may only
7152 be used in presence of a prototype.
7154 <tag/Availability/cc65
7155 <tag/See also/Other tgi functions.
7160 <sect1>tgi_setpixel<label id="tgi_setpixel"><p>
7164 <tag/Function/Plot a pixel on the drawpage with the current color.
7165 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
7166 <tag/Declaration/<tt/void __fastcall__ tgi_setpixel (int x, int y);/
7167 <tag/Description/Plot a pixel on the drawpage with the current color.
7168 <tag/Notes/<itemize>
7169 <item>The function is only available as fastcall function, so it may only
7170 be used in presence of a prototype.
7172 <tag/Availability/cc65
7173 <tag/See also/Other tgi functions.
7178 <sect1>tgi_setviewpage<label id="tgi_setviewpage"><p>
7182 <tag/Function/Set page to be visible on screen.
7183 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
7184 <tag/Declaration/<tt/void __fastcall__ tgi_setviewpage (unsigned char page);/
7185 <tag/Description/If the drawpage and the viewpage are the same then all drawing
7186 is seen immediately as it is drawn. For double buffered games you can set the
7187 drawpage to a different page than the viewpage. This lets you draw the next
7188 screen in the background and when the screen is ready you display it.
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.
7197 tgi_outtextxy(10, 10, "Hello World");
7198 tgi_setviewpage(1); // Show page 1
7200 tgi_outtextxy(10, 10, "Creating next frame");
7202 tgi_setviewpage(0); // Show page 0
7207 <sect1>tgi_gettextheight<label id="tgi_gettextheight"><p>
7211 <tag/Function/Calculate the height of the text in pixels according to
7212 the current text style.
7213 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
7214 <tag/Declaration/<tt/unsigned __fastcall__ tgi_gettextheight (const char* s);/
7215 <tag/Description/Calculate the height of the text in pixels according to
7216 the current text style.
7217 <tag/Notes/<itemize>
7218 <item>The function is only available as fastcall function, so it may only
7219 be used in presence of a prototype.
7221 <tag/Availability/cc65
7222 <tag/See also/Other tgi functions.
7227 <sect1>tgi_settextscale<label id="tgi_settextscale"><p>
7231 <tag/Function/Set the scaling for text output.
7232 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
7233 <tag/Declaration/<tt/void __fastcall__ tgi_settextscale (unsigned width, unsigned height);/
7235 Set the scaling for text output. The scaling factors for width and height
7236 are 8.8 fixed point values. This means that $100 = 1 $200 = 2 etc.
7237 <tag/Notes/<itemize>
7238 <item>The function is only available as fastcall function, so it may only
7239 be used in presence of a prototype.
7241 <tag/Availability/cc65
7243 <ref id="tgi_settextstyle" name="tgi_settextstyle">
7248 <sect1>tgi_settextstyle<label id="tgi_settextstyle"><p>
7252 <tag/Function/Set the style for text output.
7253 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
7254 <tag/Declaration/<tt/void __fastcall__ tgi_settextstyle (unsigned char magx, unsigned char magy, unsigned char dir, unsigned char font);/
7255 <tag/Description/Set the style for text output.
7256 <tag/Notes/<itemize>
7257 <item>The function is only available as fastcall function, so it may only
7258 be used in presence of a prototype.
7260 <tag/Availability/cc65
7262 <ref id="tgi_settextscale" name="tgi_settextscale">
7267 <sect1>tgi_gettextwidth<label id="tgi_gettextwidth"><p>
7271 <tag/Function/Calculate the width of the text in pixels according to the current text style.
7272 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
7273 <tag/Declaration/<tt/unsigned __fastcall__ tgi_gettextwidth (const char* s);/
7274 <tag/Description/Calculate the width of the text in pixels according to the current text style.
7275 <tag/Notes/<itemize>
7276 <item>The function is only available as fastcall function, so it may only
7277 be used in presence of a prototype.
7279 <tag/Availability/cc65
7280 <tag/See also/Other tgi functions.
7285 <sect1>tgi_uninstall<label id="tgi_uninstall"><p>
7289 <tag/Function/Uninstall the currently loaded driver but do not unload it.
7290 Will call tgi_done if necessary.
7291 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
7292 <tag/Declaration/<tt/void tgi_uninstall (void);/
7293 <tag/Description/Uninstall the currently loaded driver but do not unload it.
7294 Will call tgi_done if necessary.
7295 <tag/Availability/cc65
7296 <tag/See also/Other tgi functions.
7301 <sect1>tgi_unload<label id="tgi_unload"><p>
7305 <tag/Function/Uninstall, then unload the currently loaded driver.
7306 Will call tgi_done if necessary.
7307 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
7308 <tag/Declaration/<tt/void tgi_unload (void);/
7309 <tag/Description/Uninstall, then unload the currently loaded driver.
7310 Will call tgi_done if necessary.
7311 <tag/Availability/cc65
7312 <tag/See also/Other tgi functions.
7317 <sect1>time<label id="time"><p>
7321 <tag/Function/Get the time.
7322 <tag/Header/<tt/<ref id="time.h" name="time.h">/
7323 <tag/Declaration/<tt/time_t __fastcall__ time (time_t* t);/
7324 <tag/Description/The function returns the time since the 1970-01-01 00:00:00
7325 measured in seconds. If the pointer <tt/t/ is not <tt/NULL/, the function
7326 result will also be stored there. If no time is available, <tt/(time_t)-1/ is
7327 returned and <tt/errno/ is set to <tt/ENOSYS/.
7328 <tag/Notes/<itemize>
7329 <item>The function is only available as fastcall function, so it may
7330 only be used in presence of a prototype.
7331 <item>Many platforms supported by cc65 do not have a realtime clock, so the
7332 returned value may not be valid.
7334 <tag/Availability/ISO 9899
7336 <ref id="clock" name="clock">
7342 <sect1>toggle_videomode<label id="toggle_videomode"><p>
7346 <tag/Function/Toggle between 40 and 80 column mode.
7347 <tag/Header/<tt/<ref id="c128.h" name="c128.h">/
7348 <tag/Declaration/<tt/void toggle_videomode (void);/
7349 <tag/Description/Toggle between 40 and 80 column mode. The settings for the
7350 old mode (cursor position, color and so on) are saved and restored together
7352 <tag/Notes/<itemize>
7353 <item>The function is specific to the C128.
7354 <item>This function is deprecated. Please use <ref id="videomode"
7355 name="videomode"> instead!
7357 <tag/Availability/C128
7359 <ref id="fast" name="fast">,
7360 <ref id="slow" name="slow">,
7361 <ref id="videomode" name="videomode">
7367 <sect1>tolower<label id="tolower"><p>
7371 <tag/Function/Convert a character into its lower case representation.
7372 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
7373 <tag/Declaration/<tt/int __fastcall__ tolower (int c);/
7374 <tag/Description/The function returns the given character converted to lower
7375 case. If the given character is not a letter, it is returned unchanged.
7376 <tag/Notes/<itemize>
7377 <item>The function is only available as fastcall function, so it may
7378 only be used in presence of a prototype.
7380 <tag/Availability/ISO 9899
7382 <ref id="islower" name="islower">,
7383 <ref id="isupper" name="isupper">,
7384 <ref id="toupper" name="toupper">
7390 <sect1>toupper<label id="toupper"><p>
7394 <tag/Function/Convert a character into its upper case representation.
7395 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
7396 <tag/Declaration/<tt/int __fastcall__ toupper (int c);/
7397 <tag/Description/The function returns the given character converted to upper
7398 case. If the given character is not a letter, it is returned unchanged.
7399 <tag/Notes/<itemize>
7400 <item>The function is only available as fastcall function, so it may
7401 only be used in presence of a prototype.
7403 <tag/Availability/ISO 9899
7405 <ref id="islower" name="islower">,
7406 <ref id="isupper" name="isupper">,
7407 <ref id="tolower" name="tolower">
7413 <sect1>ultoa<label id="ultoa"><p>
7417 <tag/Function/Convert an unsigned long integer into a string.
7418 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
7419 <tag/Declaration/<tt/char* __fastcall__ ultoa (unsigned long val, char* buf, int radix);/
7420 <tag/Description/<tt/itoa/ converts the unsigned long integer <tt/val/ into a
7421 string using <tt/radix/ as the base.
7422 <tag/Notes/<itemize>
7423 <item>There are no provisions to prevent a buffer overflow.
7424 <item>The function is non standard, so it is not available in strict ANSI mode.
7425 You should probably use <tt/sprintf/ instead.
7426 <item>The function is only available as fastcall function, so it may only be
7427 used in presence of a prototype.
7429 <tag/Availability/cc65
7431 <ref id="atoi" name="atoi">,
7432 <ref id="atol" name="atol">,
7433 <ref id="itoa" name="itoa">,
7434 <ref id="ltoa" name="ltoa">,
7435 <ref id="utoa" name="utoa">
7441 <sect1>unlink<label id="unlink"><p>
7445 <tag/Function/Delete a file.
7446 <tag/Header/<tt/<ref id="unistd.h" name="unistd.h">/
7447 <tag/Declaration/<tt/int __fastcall__ unlink (const char* name);/
7448 <tag/Description/<tt/unlink/ deletes the file with the given name. On success,
7449 zero is returned. On error, -1 is returned and <tt/errno/ is set to an error
7450 code describing the reason for the failure.
7451 <tag/Notes/<itemize>
7452 <item>The use of this function is discouraged. Please use <tt/<ref id="remove"
7453 name="remove">/ instead, which is a native ANSI C function and does the same.
7454 <item>This function is not available on all cc65 targets (depends on the
7455 availability of file I/O).
7456 <item>The function is only available as fastcall function, so it may only
7457 be used in presence of a prototype.
7458 <item>Instead of <tt/unlink/, <tt/<ref id="remove" name="remove">/ should be
7459 used, which has the same semantics, but is more portable, because it conforms
7460 to the ISO C standard.
7462 <tag/Availability/POSIX 1003.1
7464 <ref id="remove" name="remove">
7467 #include <stdio.h>
7468 #include <unistd.h>
7470 #define FILENAME "helloworld"
7472 if (unlink (FILENAME) == 0) {
7473 printf ("We deleted %s successfully\n", FILENAME);
7475 printf ("There was a problem deleting %s\n", FILENAME);
7482 <sect1>utoa<label id="utoa"><p>
7486 <tag/Function/Convert an unsigned integer into a string.
7487 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
7488 <tag/Declaration/<tt/char* __fastcall__ utoa (unsigned val, char* buf, int radix);/
7489 <tag/Description/<tt/itoa/ converts the unsigned integer <tt/val/ into a string
7490 using <tt/radix/ as the base.
7491 <tag/Notes/<itemize>
7492 <item>There are no provisions to prevent a buffer overflow.
7493 <item>The function is non standard, so it is not available in strict ANSI mode.
7494 You should probably use <tt/sprintf/ instead.
7495 <item>The function is only available as fastcall function, so it may only be
7496 used in presence of a prototype.
7498 <tag/Availability/cc65
7500 <ref id="atoi" name="atoi">,
7501 <ref id="atol" name="atol">,
7502 <ref id="itoa" name="itoa">,
7503 <ref id="ltoa" name="ltoa">,
7504 <ref id="ultoa" name="ultoa">
7510 <sect1>vcprintf<label id="vcprintf"><p>
7514 <tag/Function/Formatted output to the console.
7515 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
7516 <tag/Declaration/<tt/int __fastcall__ vcprintf (const char* format, va_list ap);/
7517 <tag/Description/The arguments specified as a <tt/va_list/ are converted to
7518 text where necessary and formatted according to the format string given. The
7519 resulting string is output to the console. <tt/vcprintf/ supports the same
7520 format specifiers as <tt/vprintf/. <!-- <tt/<ref id="vprintf" name="vprintf">/. -->
7521 <tag/Notes/<itemize>
7522 <item>Like all other <tt/conio/ output functions, <tt/vcprintf/ distinguishes
7523 between <tt/\r/ and <tt/\n/.
7524 <item>The function is only available as fastcall function, so it may only be
7525 used in presence of a prototype.
7527 <tag/Availability/cc65
7529 <ref id="cprintf" name="cprintf">,
7530 <ref id="cputc" name="cputc">,
7531 <ref id="cputcxy" name="cputcxy">,
7532 <ref id="cputs" name="cputs">,
7533 <ref id="cputsxy" name="cputsxy">
7539 <sect1>videomode<label id="videomode"><p>
7543 <tag/Function/Switch to either 40 or 80 column mode.
7544 <tag/Header/<tt/<ref id="apple2enh.h" name="apple2enh.h">,
7545 <ref id="c128.h" name="c128.h">/
7546 <tag/Declaration/<tt/unsigned __fastcall__ videomode (unsigned Mode);/
7547 <tag/Description/Switch to 40 or 80 column mode depending on the argument. If
7548 the requested mode is already active, nothing happens. The old mode is returned
7550 <tag/Notes/<itemize>
7551 <item>The function is specific to the C128 and enhanced Apple //e.
7552 <item>This function replaces <ref id="toggle_videomode"
7553 name="toggle_videomode">.
7554 <item>The function is only available as fastcall function, so it may only be
7555 used in presence of a prototype.
7557 <tag/Availability/C128 and enhanced Apple //e
7559 <ref id="fast" name="fast">,
7560 <ref id="slow" name="slow">,
7561 <ref id="toggle_videomode" name="toggle_videomode">
7567 <sect1>wherex<label id="wherex"><p>
7571 <tag/Function/Return the current X position of the text mode cursor.
7572 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
7573 <tag/Declaration/<tt/unsigned char wherex (void);/
7574 <tag/Description/The function returns the current X position of the text mode
7575 cursor. Zero is returned for the leftmost screen position.
7576 <tag/Availability/cc65
7578 <ref id="gotox" name="gotox">,
7579 <ref id="gotoy" name="gotoy">,
7580 <ref id="gotoxy" name="gotoxy">,
7581 <ref id="wherey" name="wherey">
7587 <sect1>wherey<label id="wherey"><p>
7591 <tag/Function/Return the current Y position of the text mode cursor.
7592 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
7593 <tag/Declaration/<tt/unsigned char wherey (void);/
7594 <tag/Description/The function returns the current Y position of the text mode
7595 cursor. Zero is returned for the uppermost screen position.
7596 <tag/Availability/cc65
7598 <ref id="gotox" name="gotox">,
7599 <ref id="gotoy" name="gotoy">,
7600 <ref id="gotoxy" name="gotoxy">,
7601 <ref id="wherex" name="wherex">