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="_rest_vecs" name="_rest_vecs"> -->
102 <!-- <item><ref id="_save_vecs" name="_save_vecs"> -->
103 <!-- <item><ref id="_scroll" name="_scroll"> -->
104 <!-- <item><ref id="_setcolor" name="_setcolor"> -->
105 <!-- <item><ref id="_setcolor_low" name="_setcolor_low"> -->
106 <item><ref id="get_ostype" name="get_ostype">
107 <!-- <item><ref id="get_tv" name="get_tv"> -->
113 <sect1><tt/atmos.h/<label id="atmos.h"><p>
116 <item><ref id="atmos_load" name="atmos_load">
117 <item><ref id="atmos_save" name="atmos_save">
118 <!-- <item><ref id="atmos_explode" name="atmos_explode"> -->
119 <!-- <item><ref id="atmos_ping" name="atmos_ping"> -->
120 <!-- <item><ref id="atmos_shoot" name="atmos_shoot"> -->
121 <!-- <item><ref id="atmos_tick" name="atmos_tick"> -->
122 <!-- <item><ref id="atmos_tock" name="atmos_tock"> -->
123 <!-- <item><ref id="atmos_zap" name="atmos_zap"> -->
129 <sect1><tt/c128.h/<label id="c128.h"><p>
132 <item><ref id="c64mode" name="c64mode">
133 <item><ref id="fast" name="fast">
134 <item><ref id="slow" name="slow">
135 <item><ref id="toggle_videomode" name="toggle_videomode">
136 <item><ref id="videomode" name="videomode">
140 <sect1><tt/c16.h/<label id="c16.h"><p>
145 <sect1><tt/c64.h/<label id="c64.h"><p>
148 <item><ref id="get_ostype" name="get_ostype">
152 <sect1><tt/cbm.h/<label id="cbm.h"><p>
155 <item><ref id="cbm_k_acptr" name="cbm_k_acptr">
156 <item><ref id="cbm_k_basin" name="cbm_k_basin">
157 <item><ref id="cbm_k_bsout" name="cbm_k_bsout">
158 <item><ref id="cbm_k_chkin" name="cbm_k_chkin">
159 <item><ref id="cbm_k_ciout" name="cbm_k_ciout">
160 <item><ref id="cbm_k_ckout" name="cbm_k_ckout">
161 <item><ref id="cbm_k_clall" name="cbm_k_clall">
162 <item><ref id="cbm_k_close" name="cbm_k_close">
163 <item><ref id="cbm_k_clrch" name="cbm_k_clrch">
164 <item><ref id="cbm_k_getin" name="cbm_k_getin">
165 <item><ref id="cbm_k_iobase" name="cbm_k_iobase">
166 <item><ref id="cbm_k_listen" name="cbm_k_listen">
167 <item><ref id="cbm_k_load" name="cbm_k_load">
168 <item><ref id="cbm_k_open" name="cbm_k_open">
169 <item><ref id="cbm_k_readst" name="cbm_k_readst">
170 <item><ref id="cbm_k_save" name="cbm_k_save">
171 <item><ref id="cbm_k_setlfs" name="cbm_k_setlfs">
172 <item><ref id="cbm_k_setnam" name="cbm_k_setnam">
173 <item><ref id="cbm_k_unlsn" name="cbm_k_unlsn">
174 <!-- <item><ref id="cbm_load" name="cbm_load"> -->
175 <!-- <item><ref id="cbm_open" name="cbm_open"> -->
176 <!-- <item><ref id="cbm_opendir" name="cbm_opendir"> -->
177 <!-- <item><ref id="cbm_read" name="cbm_read"> -->
178 <!-- <item><ref id="cbm_readdir" name="cbm_readdir"> -->
179 <!-- <item><ref id="cbm_save" name="cbm_save"> -->
180 <!-- <item><ref id="cbm_write" name="cbm_write"> -->
181 <!-- <item><ref id="get_tv" name="get_tv"> -->
187 <sect1><tt/cbm510.h/<label id="cbm510.h"><p>
190 <item><ref id="peekbsys" name="peekbsys">
191 <item><ref id="peekwsys" name="peekwsys">
192 <item><ref id="pokebsys" name="pokebsys">
193 <item><ref id="pokewsys" name="pokewsys">
197 <sect1><tt/cbm610.h/<label id="cbm610.h"><p>
200 <item><ref id="peekbsys" name="peekbsys">
201 <item><ref id="peekwsys" name="peekwsys">
202 <item><ref id="pokebsys" name="pokebsys">
203 <item><ref id="pokewsys" name="pokewsys">
207 <sect1><tt/cc65.h/<label id="cc65.h"><p>
210 <!-- <item><ref id="cc65_cos" name="cc65_cos"> -->
211 <!-- <item><ref id="cc65_idiv32by16r16" name="cc65_idiv32by16r16"> -->
212 <!-- <item><ref id="cc65_imul16x16r32" name="cc65_imul16x16r32"> -->
213 <!-- <item><ref id="cc65_imul8x8r16" name="cc65_imul8x8r16"> -->
214 <!-- <item><ref id="cc65_sin" name="cc65_sin"> -->
215 <!-- <item><ref id="cc65_udiv32by16r16" name="cc65_udiv32by16r16"> -->
216 <!-- <item><ref id="cc65_umul16x16r32" name="cc65_umul16x16r32"> -->
217 <!-- <item><ref id="cc65_umul16x8r32" name="cc65_umul16x8r32"> -->
218 <!-- <item><ref id="cc65_umul8x8r16" name="cc65_umul8x8r16"> -->
224 <sect1><tt/conio.h/<label id="conio.h"><p>
227 <item><ref id="bgcolor" name="bgcolor">
228 <item><ref id="bordercolor" name="bordercolor">
229 <item><ref id="cclear" name="cclear">
230 <item><ref id="cclearxy" name="cclearxy">
231 <item><ref id="cgetc" name="cgetc">
232 <item><ref id="chline" name="chline">
233 <item><ref id="chlinexy" name="chlinexy">
234 <item><ref id="clrscr" name="clrscr">
235 <item><ref id="cprintf" name="cprintf">
236 <item><ref id="cputc" name="cputc">
237 <item><ref id="cputcxy" name="cputcxy">
238 <item><ref id="cputs" name="cputs">
239 <item><ref id="cputsxy" name="cputsxy">
240 <item><ref id="cursor" name="cursor">
241 <item><ref id="cvline" name="cvline">
242 <item><ref id="cvlinexy" name="cvlinexy">
243 <item><ref id="gotox" name="gotox">
244 <item><ref id="gotoxy" name="gotoxy">
245 <item><ref id="gotoy" name="gotoy">
246 <item><ref id="kbhit" name="kbhit">
247 <item><ref id="revers" name="revers">
248 <item><ref id="screensize" name="screensize">
249 <item><ref id="textcolor" name="textcolor">
250 <item><ref id="vcprintf" name="vcprintf">
251 <item><ref id="wherex" name="wherex">
252 <item><ref id="wherey" name="wherey">
256 <sect1><tt/ctype.h/<label id="ctype.h"><p>
259 <item><ref id="isalnum" name="isalnum">
260 <item><ref id="isalpha" name="isalpha">
261 <item><ref id="isascii" name="isascii">
262 <item><ref id="isblank" name="isblank">
263 <item><ref id="iscntrl" name="iscntrl">
264 <item><ref id="isdigit" name="isdigit">
265 <item><ref id="isgraph" name="isgraph">
266 <item><ref id="islower" name="islower">
267 <item><ref id="isprint" name="isprint">
268 <item><ref id="ispunct" name="ispunct">
269 <item><ref id="isspace" name="isspace">
270 <item><ref id="isupper" name="isupper">
271 <item><ref id="isxdigit" name="isxdigit">
272 <item><ref id="tolower" name="tolower">
273 <item><ref id="toupper" name="toupper">
277 <sect1><tt/dbg.h/<label id="dbg.h"><p>
280 <!-- <item><ref id="DbgInit" name="DbgInit"> -->
286 <sect1><tt/dio.h/<label id="dio.h"><p>
288 <url url="dio.html" name="Low-level disk I/O API">.
291 <sect1><tt/dirent.h/<label id="dirent.h"><p>
294 <item><ref id="_DE_ISDIR" name="_DE_ISDIR">
295 <item><ref id="_DE_ISLBL" name="_DE_ISLBL">
296 <item><ref id="_DE_ISLNK" name="_DE_ISLNK">
297 <item><ref id="_DE_ISREG" name="_DE_ISREG">
298 <item><ref id="closedir" name="closedir">
299 <item><ref id="opendir" name="opendir">
300 <item><ref id="readdir" name="readdir">
301 <item><ref id="rewinddir" name="rewinddir">
302 <item><ref id="seekdir" name="seekdir">
303 <item><ref id="telldir" name="telldir">
309 <sect1><tt/em.h/<label id="em.h"><p>
312 <item><ref id="em_commit" name="em_commit">
313 <item><ref id="em_copyfrom" name="em_copyfrom">
314 <item><ref id="em_copyto" name="em_copyto">
315 <item><ref id="em_install" name="em_install">
316 <item><ref id="em_load_driver" name="em_load_driver">
317 <item><ref id="em_map" name="em_map">
318 <item><ref id="em_pagecount" name="em_pagecount">
319 <item><ref id="em_uninstall" name="em_uninstall">
320 <item><ref id="em_unload" name="em_unload">
321 <item><ref id="em_use" name="em_use">
325 <sect1><tt/errno.h/<label id="errno.h"><p>
328 <!-- <item><ref id="_directerrno" name="_directerrno"> -->
329 <!-- <item><ref id="_mappederrno" name="_mappederrno"> -->
330 <!-- <item><ref id="_osmaperrno" name="_osmaperrno"> -->
331 <!-- <item><ref id="_seterrno" name="_seterrno"> -->
337 <sect1><tt/fcntl.h/<label id="fcntl.h"><p>
340 <item><ref id="close" name="close">
341 <item><ref id="creat" name="creat">
342 <item><ref id="open" name="open">
346 <sect1><tt/geos.h/<label id="geos.h"><p>
351 <sect1><tt/joystick.h/<label id="joystick.h"><p>
354 <item><ref id="joy_count" name="joy_count">
355 <item><ref id="joy_install" name="joy_install">
356 <item><ref id="joy_load_driver" name="joy_load_driver">
357 <item><ref id="joy_read" name="joy_read">
358 <item><ref id="joy_uninstall" name="joy_uninstall">
359 <item><ref id="joy_unload" name="joy_unload">
363 <sect1><tt/locale.h/<label id="locale.h"><p>
366 <item><ref id="localeconv" name="localeconv">
367 <item><ref id="setlocale" name="setlocale">
371 <sect1><tt/lynx.h/<label id="lynx.h"><p>
374 <!-- <item><ref id="lynx_eeprom_erase" name="lynx_eeprom_erase"> -->
375 <!-- <item><ref id="lynx_eeprom_read" name="lynx_eeprom_read"> -->
376 <!-- <item><ref id="lynx_eeprom_write" name="lynx_eeprom_write"> -->
377 <!-- <item><ref id="lynx_eeread" name="lynx_eeread"> -->
378 <!-- <item><ref id="lynx_eewrite" name="lynx_eewrite"> -->
379 <!-- <item><ref id="lynx_exec" name="lynx_exec"> -->
380 <!-- <item><ref id="lynx_load" name="lynx_load"> -->
386 <sect1><tt/modload.h/<label id="modload.h"><p>
389 <item><ref id="mod_load" name="mod_load">
390 <item><ref id="mod_free" name="mod_free">
394 <sect1><tt/mouse.h/<label id="mouse.h"><p>
397 <item><ref id="mouse_buttons" name="mouse_buttons">
398 <item><ref id="mouse_getbox" name="mouse_getbox">
399 <item><ref id="mouse_geterrormsg" name="mouse_geterrormsg">
400 <item><ref id="mouse_hide" name="mouse_hide">
401 <item><ref id="mouse_info" name="mouse_info">
402 <item><ref id="mouse_install" name="mouse_install">
403 <item><ref id="mouse_ioctl" name="mouse_ioctl">
404 <item><ref id="mouse_load_driver" name="mouse_load_driver">
405 <item><ref id="mouse_move" name="mouse_move">
406 <item><ref id="mouse_pos" name="mouse_pos">
407 <item><ref id="mouse_setbox" name="mouse_setbox">
408 <item><ref id="mouse_show" name="mouse_show">
409 <item><ref id="mouse_uninstall" name="mouse_uninstall">
410 <item><ref id="mouse_unload" name="mouse_unload">
414 <sect1><tt/nes.h/<label id="nes.h"><p>
417 <!-- <item><ref id="get_tv" name="get_tv"> -->
418 <!-- <item><ref id="waitvblank" name="waitvblank"> -->
424 <sect1><tt/o65.h/<label id="o65.h"><p>
426 The <tt/o65.h/ header file contains structure and constant definitions that
427 may be used when dealing with files in <url
428 url="http://www.6502.org/users/andre/o65/fileformat.html" name="the o65 format">.
429 It does not declare any functions.
432 <sect1><tt/peekpoke.h/<label id="peekpoke.h"><p>
435 <item><ref id="PEEK" name="PEEK">
436 <item><ref id="PEEKW" name="PEEKW">
437 <item><ref id="POKE" name="POKE">
438 <item><ref id="POKEW" name="POKEW">
442 <sect1><tt/pet.h/<label id="pet.h"><p>
447 <sect1><tt/plus4.h/<label id="plus4.h"><p>
452 <sect1><tt/serial.h/<label id="serial.h"><p>
454 The <tt/serial.h/ header file contains definitions for initializing serial
458 <item><ref id="ser_close" name="ser_close">
459 <item><ref id="ser_get" name="ser_get">
460 <item><ref id="ser_install" name="ser_install">
461 <item><ref id="ser_ioctl" name="ser_ioctl">
462 <item><ref id="ser_load_driver" name="ser_load_driver">
463 <item><ref id="ser_open" name="ser_open">
464 <item><ref id="ser_put" name="ser_put">
465 <item><ref id="ser_status" name="ser_status">
466 <item><ref id="ser_uninstall" name="ser_uninstall">
467 <item><ref id="ser_unload" name="ser_unload">
471 <sect1><tt/setjmp.h/<label id="setjmp.h"><p>
474 <item><ref id="setjmp" name="setjmp">
475 <item><ref id="longjmp" name="longjmp">
479 <sect1><tt/signal.h/<label id="signal.h"><p>
482 <item><ref id="raise" name="raise">
483 <item><ref id="signal" name="signal">
487 <sect1><tt/stdarg.h/<label id="stdarg.h"><p>
492 <sect1><tt/stdbool.h/<label id="stdbool.h"><p>
497 <sect1><tt/stddef.h/<label id="stddef.h"><p>
500 <item><ref id="offsetof" name="offsetof">
504 <sect1><tt/stdio.h/<label id="stdio.h"><p>
507 <item><ref id="_poserror" name="_poserror">
508 <item><ref id="clearerr" name="clearerr">
509 <!-- <item><ref id="fclose" name="fclose"> -->
510 <!-- <item><ref id="fdopen" name="fdopen"> -->
511 <item><ref id="feof" name="feof">
512 <item><ref id="ferror" name="ferror">
513 <!-- <item><ref id="fflush" name="fflush"> -->
514 <!-- <item><ref id="fgetc" name="fgetc"> -->
515 <!-- <item><ref id="fgetpos" name="fgetpos"> -->
516 <!-- <item><ref id="fgets" name="fgets"> -->
517 <item><ref id="fileno" name="fileno">
518 <!-- <item><ref id="fopen" name="fopen"> -->
519 <!-- <item><ref id="fprintf" name="fprintf"> -->
520 <!-- <item><ref id="fputc" name="fputc"> -->
521 <!-- <item><ref id="fputs" name="fputs"> -->
522 <!-- <item><ref id="fread" name="fread"> -->
523 <!-- <item><ref id="freopen" name="freopen"> -->
524 <!-- <item><ref id="fscanf" name="fscanf"> -->
525 <!-- <item><ref id="fseek" name="fseek"> -->
526 <!-- <item><ref id="fsetpos" name="fsetpos"> -->
527 <!-- <item><ref id="ftell" name="ftell"> -->
528 <!-- <item><ref id="fwrite" name="fwrite"> -->
529 <!-- <item><ref id="getc" name="getc"> -->
530 <!-- <item><ref id="getchar" name="getchar"> -->
531 <!-- <item><ref id="gets" name="gets"> -->
532 <!-- <item><ref id="printf" name="printf"> -->
533 <!-- <item><ref id="putc" name="putc"> -->
534 <!-- <item><ref id="putchar" name="putchar"> -->
535 <!-- <item><ref id="puts" name="puts"> -->
536 <item><ref id="rename" name="rename">
537 <item><ref id="remove" name="remove">
538 <!-- <item><ref id="rewind" name="rewind"> -->
539 <!-- <item><ref id="scanf" name="scanf"> -->
540 <!-- <item><ref id="snprintf" name="snprintf"> -->
541 <!-- <item><ref id="sprintf" name="sprintf"> -->
542 <!-- <item><ref id="sscanf" name="sscanf"> -->
543 <!-- <item><ref id="vfprintf" name="vfprintf"> -->
544 <!-- <item><ref id="vfscanf" name="vfscanf"> -->
545 <!-- <item><ref id="vprintf" name="vprintf"> -->
546 <!-- <item><ref id="vscanf" name="vscanf"> -->
547 <!-- <item><ref id="vsnprintf" name="vsnprintf"> -->
548 <!-- <item><ref id="vsprintf" name="vsprintf"> -->
549 <!-- <item><ref id="vsscanf" name="vsscanf"> -->
555 <sect1><tt/stdlib.h/<label id="stdlib.h"><p>
558 <item><ref id="_heapadd" name="_heapadd">
559 <item><ref id="_heapblocksize" name="_heapblocksize">
560 <item><ref id="_heapmaxavail" name="_heapmaxavail">
561 <item><ref id="_heapmemavail" name="_heapmemavail">
562 <item><ref id="_randomize" name="_randomize">
563 <item><ref id="_swap" name="_swap">
564 <item><ref id="abort" name="abort">
565 <item><ref id="abs" name="abs">
566 <item><ref id="atexit" name="atexit">
567 <item><ref id="atoi" name="atoi">
568 <item><ref id="atol" name="atol">
569 <item><ref id="bsearch" name="bsearch">
570 <item><ref id="calloc" name="calloc">
571 <item><ref id="div" name="div">
572 <item><ref id="exit" name="exit">
573 <item><ref id="free" name="free">
574 <item><ref id="getenv" name="getenv">
575 <item><ref id="itoa" name="itoa">
576 <item><ref id="labs" name="labs">
577 <item><ref id="ltoa" name="ltoa">
578 <item><ref id="malloc" name="malloc">
579 <item><ref id="perror" name="perror">
580 <!-- <item><ref id="posix_memalign" name="posix_memalign"> -->
581 <!-- <item><ref id="putenv" name="putenv"> -->
582 <item><ref id="qsort" name="qsort">
583 <item><ref id="rand" name="rand">
584 <item><ref id="realloc" name="realloc">
585 <item><ref id="srand" name="srand">
586 <!-- <item><ref id="system" name="system"> -->
587 <item><ref id="ultoa" name="ultoa">
588 <item><ref id="utoa" name="utoa">
594 <sect1><tt/string.h/<label id="string.h"><p>
597 <item><ref id="_stroserror" name="_stroserror">
598 <item><ref id="bzero" name="bzero">
599 <item><ref id="memchr" name="memchr">
600 <item><ref id="memcmp" name="memcmp">
601 <item><ref id="memcpy" name="memcpy">
602 <item><ref id="memmove" name="memmove">
603 <item><ref id="memset" name="memset">
604 <item><ref id="strcasecmp" name="strcasecmp">
605 <item><ref id="strcat" name="strcat">
606 <item><ref id="strchr" name="strchr">
607 <item><ref id="strcmp" name="strcmp">
608 <item><ref id="strcoll" name="strcoll">
609 <item><ref id="strcpy" name="strcpy">
610 <item><ref id="strcspn" name="strcspn">
611 <item><ref id="strdup" name="strdup">
612 <item><ref id="strerror" name="strerror">
613 <item><ref id="stricmp" name="stricmp">
614 <item><ref id="strlen" name="strlen">
615 <item><ref id="strlower" name="strlower">
616 <item><ref id="strlwr" name="strlwr">
617 <item><ref id="strncat" name="strncat">
618 <item><ref id="strncmp" name="strncmp">
619 <item><ref id="strncpy" name="strncpy">
620 <item><ref id="strqtok" name="strqtok">
621 <item><ref id="strrchr" name="strrchr">
622 <item><ref id="strspn" name="strspn">
623 <item><ref id="strstr" name="strstr">
624 <item><ref id="strtok" name="strtok">
625 <item><ref id="strxfrm" name="strxfrm">
626 <item><ref id="strupper" name="strupper">
627 <item><ref id="strupr" name="strupr">
633 <sect1><tt/tgi.h/<label id="tgi.h"><p>
636 <item><ref id="tgi_arc" name="tgi_arc">
637 <item><ref id="tgi_bar" name="tgi_bar">
638 <item><ref id="tgi_circle" name="tgi_circle">
639 <item><ref id="tgi_clear" name="tgi_clear">
640 <item><ref id="tgi_done" name="tgi_done">
641 <item><ref id="tgi_ellipse" name="tgi_ellipse">
642 <item><ref id="tgi_free_vectorfont" name="tgi_free_vectorfont">
643 <item><ref id="tgi_getaspectratio" name="tgi_getaspectratio">
644 <item><ref id="tgi_getcolor" name="tgi_getcolor">
645 <item><ref id="tgi_getcolorcount" name="tgi_getcolorcount">
646 <item><ref id="tgi_getdefpalette" name="tgi_getdefpalette">
647 <item><ref id="tgi_geterror" name="tgi_geterror">
648 <item><ref id="tgi_geterrormsg" name="tgi_geterrormsg">
649 <item><ref id="tgi_getmaxcolor" name="tgi_getmaxcolor">
650 <item><ref id="tgi_getmaxx" name="tgi_getmaxx">
651 <item><ref id="tgi_getmaxy" name="tgi_getmaxy">
652 <item><ref id="tgi_getpagecount" name="tgi_getpagecount">
653 <item><ref id="tgi_getpalette" name="tgi_getpalette">
654 <item><ref id="tgi_getpixel" name="tgi_getpixel">
655 <item><ref id="tgi_gettextheight" name="tgi_gettextheight">
656 <item><ref id="tgi_gettextwidth" name="tgi_gettextwidth">
657 <item><ref id="tgi_getxres" name="tgi_getxres">
658 <item><ref id="tgi_getyres" name="tgi_getyres">
659 <item><ref id="tgi_gotoxy" name="tgi_gotoxy">
660 <item><ref id="tgi_init" name="tgi_init">
661 <item><ref id="tgi_install" name="tgi_install">
662 <item><ref id="tgi_install_vectorfont" name="tgi_install_vectorfont">
663 <item><ref id="tgi_ioctl" name="tgi_ioctl">
664 <item><ref id="tgi_line" name="tgi_line">
665 <item><ref id="tgi_lineto" name="tgi_lineto">
666 <item><ref id="tgi_load_driver" name="tgi_load_driver">
667 <item><ref id="tgi_load_vectorfont" name="tgi_load_vectorfont">
668 <item><ref id="tgi_outtext" name="tgi_outtext">
669 <item><ref id="tgi_outtextxy" name="tgi_outtextxy">
670 <item><ref id="tgi_setaspectratio" name="tgi_setaspectratio">
671 <item><ref id="tgi_setcolor" name="tgi_setcolor">
672 <item><ref id="tgi_setdrawpage" name="tgi_setdrawpage">
673 <item><ref id="tgi_setpalette" name="tgi_setpalette">
674 <item><ref id="tgi_setpixel" name="tgi_setpixel">
675 <item><ref id="tgi_setviewpage" name="tgi_setviewpage">
676 <item><ref id="tgi_settextscale" name="tgi_settextscale">
677 <item><ref id="tgi_settextstyle" name="tgi_settextstyle">
678 <item><ref id="tgi_uninstall" name="tgi_uninstall">
679 <item><ref id="tgi_unload" name="tgi_unload">
682 <sect1><tt/time.h/<label id="time.h"><p>
685 <!-- <item><ref id="_systime" name="_systime"> -->
686 <!-- <item><ref id="asctime" name="asctime"> -->
687 <item><ref id="clock" name="clock">
688 <!-- <item><ref id="ctime" name="ctime"> -->
689 <!-- <item><ref id="gmtime" name="gmtime"> -->
690 <!-- <item><ref id="localtime" name="localtime"> -->
691 <!-- <item><ref id="mktime" name="mktime"> -->
692 <!-- <item><ref id="strftime" name="strftime"> -->
693 <item><ref id="time" name="time">
699 <sect1><tt/unistd.h/<label id="unistd.h"><p>
702 <!-- <item><ref id="chdir" name="chdir"> -->
703 <item><ref id="exec" name="exec">
704 <!-- <item><ref id="getcwd" name="getcwd"> -->
705 <item><ref id="getopt" name="getopt">
706 <!-- <item><ref id="lseek" name="lseek"> -->
707 <!-- <item><ref id="mkdir" name="mkdir"> -->
708 <!-- <item><ref id="read" name="read"> -->
709 <!-- <item><ref id="rmdir" name="rmdir"> -->
710 <item><ref id="sleep" name="sleep">
711 <item><ref id="unlink" name="unlink">
712 <!-- <item><ref id="write" name="write"> -->
718 <sect1><tt/vic20.h/<label id="vic20.h"><p>
723 <sect1><tt/zlib.h/<label id="zlib.h"><p>
726 <!-- <item><ref id="adler32" name="adler32"> -->
727 <!-- <item><ref id="crc32" name="crc32"> -->
728 <!-- <item><ref id="inflatemem" name="inflatemem"> -->
729 <!-- <item><ref id="uncompress" name="uncompress"> -->
735 <sect>Alphabetical function reference<p>
737 <sect1>_DE_ISDIR<label id="_DE_ISDIR"><p>
741 <tag/Function/Determine if a directory entry specifies a directory.
742 <tag/Header/<tt/<ref id="dirent.h" name="dirent.h">/
743 <tag/Declaration/<tt/int _DE_ISDIR(unsigned char type);/
744 <tag/Description/The function is called with the type of a directory entry
745 taken from a <tt/struct dirent/ and returns true if the entry designates
748 <item>The function is actually a macro.
750 <tag/Availability/cc65
752 <ref id="_DE_ISLBL" name="_DE_ISLBL">,
753 <ref id="_DE_ISLNK" name="_DE_ISLNK">,
754 <ref id="_DE_ISREG" name="_DE_ISREG">
760 <sect1>_DE_ISLBL<label id="_DE_ISLBL"><p>
764 <tag/Function/Determine if a directory entry specifies a disk label.
765 <tag/Header/<tt/<ref id="dirent.h" name="dirent.h">/
766 <tag/Declaration/<tt/int _DE_ISLBL(unsigned char type);/
767 <tag/Description/The function is called with the type of a directory entry
768 taken from a <tt/struct dirent/ and returns true if the entry designates
771 <item>The function is actually a macro.
773 <tag/Availability/cc65
775 <ref id="_DE_ISDIR" name="_DE_ISDIR">,
776 <ref id="_DE_ISLNK" name="_DE_ISLNK">,
777 <ref id="_DE_ISREG" name="_DE_ISREG">
783 <sect1>_DE_ISLNK<label id="_DE_ISLNK"><p>
787 <tag/Function/Determine if a directory entry specifies a link.
788 <tag/Header/<tt/<ref id="dirent.h" name="dirent.h">/
789 <tag/Declaration/<tt/int _DE_ISLNK(unsigned char type);/
790 <tag/Description/The function is called with the type of a directory entry
791 taken from a <tt/struct dirent/ and returns true if the entry designates
794 <item>The function is actually a macro.
796 <tag/Availability/cc65
798 <ref id="_DE_ISDIR" name="_DE_ISDIR">,
799 <ref id="_DE_ISLBL" name="_DE_ISLBL">,
800 <ref id="_DE_ISREG" name="_DE_ISREG">
806 <sect1>_DE_ISREG<label id="_DE_ISREG"><p>
810 <tag/Function/Determine if a directory entry specifies a regular file.
811 <tag/Header/<tt/<ref id="dirent.h" name="dirent.h">/
812 <tag/Declaration/<tt/int _DE_ISREG(unsigned char type);/
813 <tag/Description/The function is called with the type of a directory entry
814 taken from a <tt/struct dirent/ and returns true if the entry designates
817 <item>The function is actually a macro.
818 <item>A "regular file" means anything with data in it. This might still mean
819 that special processing is needed, when accessing the file. Relative files of
820 the CBM systems are classified as being "regular" files, for example.
822 <tag/Availability/cc65
824 <ref id="_DE_ISDIR" name="_DE_ISDIR">,
825 <ref id="_DE_ISLBL" name="_DE_ISLBL">,
826 <ref id="_DE_ISLNK" name="_DE_ISLNK">
832 <sect1>_heapadd<label id="_heapadd"><p>
836 <tag/Function/Add a block to the heap.
837 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
838 <tag/Declaration/<tt/void __fastcall__ _heapadd (void* mem, size_t size);/
839 <tag/Description/The function adds a block of raw memory to the heap.
841 <item>The minimum blocksize that can be added is 6 bytes; the function will
842 ignore smaller blocks.
843 <item>The function is available only as a fastcall function; so, it may be used
844 only in the presence of a prototype.
846 <tag/Availability/cc65
848 <ref id="_heapblocksize" name="_heapblocksize">,
849 <ref id="_heapmaxavail" name="_heapmaxavail">,
850 <ref id="_heapmemavail" name="_heapmemavail">,
851 <ref id="calloc" name="calloc">,
852 <ref id="free" name="free">,
853 <ref id="malloc" name="malloc">,
854 <ref id="realloc" name="realloc">
860 <sect1>_heapblocksize<label id="_heapblocksize"><p>
864 <tag/Function/Return the size of an allocated block.
865 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
866 <tag/Declaration/<tt/size_t __fastcall__ _heapblocksize (const void* block);/
867 <tag/Description/The function returns the size of a block that must have
868 previously been allocated by <tt/<ref id="malloc" name="malloc">/, <tt/<ref
869 id="calloc" name="calloc">/ or <tt/<ref id="realloc" name="realloc">/.
871 <item>Passing a pointer to a block that was is not the result of one of the
872 allocation functions, or that has been free'd will give unpredicable results.
873 <item>The function is available only as a fastcall function; so, it may be used
874 only in the presence of a prototype.
876 <tag/Availability/cc65
878 <ref id="_heapadd" name="_heapadd">,
879 <ref id="_heapmaxavail" name="_heapmaxavail">,
880 <ref id="_heapmemavail" name="_heapmemavail">,
881 <ref id="calloc" name="calloc">,
882 <ref id="free" name="free">,
883 <ref id="malloc" name="malloc">,
884 <ref id="realloc" name="realloc">
890 <sect1>_heapmaxavail<label id="_heapmaxavail"><p>
894 <tag/Function/Return the largest block that is available on the heap.
895 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
896 <tag/Declaration/<tt/size_t _heapmaxavail (void);/
897 <tag/Description/The function returns the size of the largest block that may
898 be allocated from the heap using <tt/<ref id="malloc" name="malloc">/.
899 <tag/Availability/cc65
901 <ref id="_heapadd" name="_heapadd">,
902 <ref id="_heapblocksize" name="_heapblocksize">,
903 <ref id="_heapmemavail" name="_heapmemavail">,
904 <ref id="calloc" name="calloc">,
905 <ref id="free" name="free">,
906 <ref id="malloc" name="malloc">,
907 <ref id="realloc" name="realloc">
913 <sect1>_heapmemavail<label id="_heapmemavail"><p>
917 <tag/Function/Return the total available space on the heap.
918 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
919 <tag/Declaration/<tt/size_t _heapmemavail (void);/
920 <tag/Description/The function returns the total number of bytes available on
923 <item>This function is of less use than usually assumed, since the returned
924 heap space may be available but not in one block. So even if this function
925 says that several times more heap space is available than needed, <ref
926 id="malloc" name="malloc"> may still return <tt/NULL/.
928 <tag/Availability/cc65
930 <ref id="_heapadd" name="_heapadd">,
931 <ref id="_heapblocksize" name="_heapblocksize">,
932 <ref id="_heapmaxavail" name="_heapmaxavail">,
933 <ref id="calloc" name="calloc">,
934 <ref id="free" name="free">,
935 <ref id="malloc" name="malloc">,
936 <ref id="realloc" name="realloc">
942 <sect1>_poserror<label id="_poserror"><p>
946 <tag/Function/Print an error message for the error in <tt/_oserror/.
947 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
948 <tag/Declaration/<tt/void __fastcall__ _poserror (const char* msg);/
949 <tag/Description/<tt/_poserror/ prints an error message to <tt/stderr/. If
950 <tt/msg/ is not <tt/NULL/ and not an empty string, it is printed followed by
951 a colon and a blank. Then the error message for the current contents of
952 <tt/_oserror/ are printed followed by a newline. The message output is the
953 same as returned by <tt/<ref id="_stroserror" name="_stroserror">/ with an
954 argument of <tt/_oserror/.
956 <item>Since operating system specific error code are - you guessed it -
957 operating system specific, the value in <tt/_oserror/ and the message that is
958 printed depends on the cc65 target.
959 <item>The function is only available as fastcall function, so it may only
960 be used in presence of a prototype.
962 <tag/Availability/cc65
964 <ref id="_stroserror" name="_stroserror">,
965 <ref id="perror" name="perror">
971 <sect1>_randomize<label id="_randomize"><p>
975 <tag/Function/Initialize the pseudo random number generator.
976 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
977 <tag/Declaration/<tt/void _randomize (void);/
978 <tag/Description/The function initializes the random number generator with
979 a seed derived from fast changing hardware events, so the seed itself can be
980 considered random to a certain degree.
982 <item>The randomness of the seed depends on the machine hardware.
984 <tag/Availability/cc65
986 <ref id="rand" name="rand">,
987 <ref id="srand" name="srand">
993 <sect1>_stroserror<label id="_stroserror"><p>
997 <tag/Function/Return a string describing an OS specific error code.
998 <tag/Header/<tt/<ref id="string.h" name="string.h">/
999 <tag/Declaration/<tt/const char* __fastcall__ _stroserror (unsigned char errcode);/
1000 <tag/Description/<tt/_stroserror/ will return a string describing the given
1001 operating system specific error code.
1002 <tag/Notes/<itemize>
1003 <item>Since operating system specific error code are - you guessed it -
1004 operating system specific, the parameter and the string returned depend on the
1006 <item>The function is only available as fastcall function, so it may only be
1007 used in presence of a prototype.
1009 <tag/Availability/cc65
1011 <ref id="strerror" name="strerror">
1017 <sect1>_swap<label id="_swap"><p>
1021 <tag/Function/Swap the contents of memory areas.
1022 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1023 <tag/Declaration/<tt/void __fastcall__ _swap (void* p, void* q, size_t size);/
1024 <tag/Description/<tt/_swap/ will swap (exchange) the contents of the two memory
1025 areas pointed to by <tt/p/ and <tt/q/. Both memory areas are assumed to be
1026 <tt/size/ bytes in size.
1027 <tag/Notes/<itemize>
1028 <item>The memory areas may not overlap, otherwise the results are undefined.
1029 <item>The function is only available as fastcall function, so it may only be
1030 used in presence of a prototype.
1032 <tag/Availability/cc65
1034 <ref id="memcpy" name="memcpy">,
1035 <ref id="memmove" name="memmove">
1041 <sect1>_sys<label id="_sys"><p>
1045 <tag/Function/Call a subroutine passing register values.
1046 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
1047 <tag/Declaration/<tt/void __fastcall__ _sys (struct regs* r);/
1048 <tag/Description/The function will call the subroutine at the address
1049 specified in the <tt/pc/ member of the passed <tt/regs/ structure. All
1050 registers and the CPU flags are set to the values given in the <tt/regs/
1051 structure. On return from the subroutine, the new values of the registers and
1052 flags are stored back overwriting the old values.
1053 <tag/Notes/<itemize>
1054 <item>Bits 4 and 5 of the flags value in the <tt/regs/ structure are ignored
1055 when calling the subroutine (they are unchanged from their current values).
1056 <item>The function is only available as fastcall function, so it may only be
1057 used in presence of a prototype.
1059 <tag/Availability/cc65
1065 <sect1>BRK<label id="BRK"><p>
1069 <tag/Function/Insert a 6502 BRK instrunction into the code.
1070 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
1071 <tag/Declaration/<tt/void BRK (void);/
1072 <tag/Description/The function will insert a 6502 BRK instruction into the code
1073 which may be used to trigger a debugger.
1074 <tag/Notes/<itemize>
1075 <item>The function is actually a macro.
1076 <item>The inserted instruction may lead to unexpected results if no debugger
1079 <tag/Availability/cc65
1081 <ref id="CLI" name="CLI">,
1082 <ref id="SEI" name="SEI">
1088 <sect1>CLI<label id="CLI"><p>
1092 <tag/Function/Insert a 6502 CLI instrunction into the code.
1093 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
1094 <tag/Declaration/<tt/void CLI (void);/
1095 <tag/Description/The function will insert a 6502 CLI instruction into the code,
1096 so interrupts are enabled. Enabling interrupts has no effects if they are
1097 already enabled (the default).
1098 <tag/Notes/<itemize>
1099 <item>The function is actually a macro.
1100 <item>Disabling interrupts may lead to unexpected results.
1102 <tag/Availability/cc65
1104 <ref id="BRK" name="BRK">,
1105 <ref id="SEI" name="SEI">
1111 <sect1>PEEK<label id="PEEK"><p>
1115 <tag/Function/Read a byte from memory.
1116 <tag/Header/<tt/<ref id="peekpoke.h" name="peekpoke.h">/
1117 <tag/Declaration/<tt/unsigned char PEEK (unsigned addr);/
1118 <tag/Description/The function will read the absolute memory given by <tt/addr/
1119 and return the value read.
1120 <tag/Notes/<itemize>
1121 <item>The function is actually a macro.
1122 <item>This function depends highly on the platform and environment.
1124 <tag/Availability/cc65
1126 <ref id="PEEKW" name="PEEKW">,
1127 <ref id="POKE" name="POKE">
1133 <sect1>PEEKW<label id="PEEKW"><p>
1137 <tag/Function/Read a word (two bytes) from memory.
1138 <tag/Header/<tt/<ref id="peekpoke.h" name="peekpoke.h">/
1139 <tag/Declaration/<tt/unsigned PEEKW (unsigned addr);/
1140 <tag/Description/The function will read the absolute memory given by <tt/addr/
1141 and return the value read. The byte read from the higher address is the high
1142 byte of the return value.
1143 <tag/Notes/<itemize>
1144 <item>The function is actually a macro.
1145 <item>This function depends highly on the platform and environment.
1146 <item>The order in which the two bytes are read is unspecified and may
1147 depend of the address expression used.
1149 <tag/Availability/cc65
1151 <ref id="PEEK" name="PEEK">,
1152 <ref id="POKE" name="POKE">
1158 <sect1>POKE<label id="POKE"><p>
1162 <tag/Function/Write a byte to memory.
1163 <tag/Header/<tt/<ref id="peekpoke.h" name="peekpoke.h">/
1164 <tag/Declaration/<tt/void POKE (unsigned addr, unsigned char val);/
1165 <tag/Description/The function writes the value <tt/val/ to the absolute
1166 memory address given by <tt/addr/.
1167 <tag/Notes/<itemize>
1168 <item>The function is actually a macro.
1169 <item>This function depends highly on the platform and environment.
1170 <item>Careless use will cause the program to act strange or may crash the
1173 <tag/Availability/cc65
1175 <ref id="PEEK" name="PEEK">,
1176 <ref id="POKEW" name="POKEW">
1182 <sect1>POKEW<label id="POKEW"><p>
1186 <tag/Function/Write a word (two bytes) to memory.
1187 <tag/Header/<tt/<ref id="peekpoke.h" name="peekpoke.h">/
1188 <tag/Declaration/<tt/void POKEW (unsigned addr, unsigned val);/
1189 <tag/Description/The function writes the value <tt/val/ to the absolute
1190 memory address given by <tt/addr/. The low byte of <tt/val/ is written to
1191 the <tt/addr/, the high byte is written to <tt/addr+1/.
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>Careless use will cause the program to act strange or may crash the
1197 <item>The order in which the two bytes are written is unspecified and may
1198 depend of the address expression used.
1200 <tag/Availability/cc65
1202 <ref id="PEEK" name="PEEK">,
1203 <ref id="POKE" name="POKE">
1209 <sect1>SEI<label id="SEI"><p>
1213 <tag/Function/Insert a 6502 SEI instrunction into the code.
1214 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
1215 <tag/Declaration/<tt/void SEI (void);/
1216 <tag/Description/The function will insert a 6502 SEI instruction into the code,
1217 so interrupts are disabled. Note that non maskable interrupts cannot be
1219 <tag/Notes/<itemize>
1220 <item>The function is actually a macro.
1221 <item>Disabling interrupts may lead to unexpected results.
1223 <tag/Availability/cc65
1225 <ref id="BRK" name="BRK">,
1226 <ref id="CLI" name="CLI">
1232 <sect1>abort<label id="abort"><p>
1236 <tag/Function/Terminates a program abnormally.
1237 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1238 <tag/Declaration/<tt/void abort (void);/
1239 <tag/Description/<tt/abort/ raises <tt/SIGABRT/, writes a termination message
1240 on stderr, then terminates the program with an exit code of 3.
1241 <tag/Availability/ISO 9899
1243 <ref id="assert" name="assert">,
1244 <ref id="exit" name="exit">,
1245 <ref id="raise" name="raise">
1251 <sect1>abs<label id="abs"><p>
1255 <tag/Function/Returns the absolute value of an integer.
1256 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1257 <tag/Declaration/<tt/int __fastcall__ abs (int v);/
1258 <tag/Description/<tt/abs/ returns the absolute value of the argument passed to
1260 <tag/Notes/<itemize>
1261 <item>The return value is undefined if <tt/INT_MIN/ is passed to the function.
1262 <item>The function is only available as fastcall function, so it may only be
1263 used in presence of a prototype.
1265 <tag/Availability/ISO 9899
1267 <ref id="labs" name="labs">
1273 <sect1>assert<label id="assert"><p>
1277 <tag/Function/Test a condition and possibly abort.
1278 <tag/Header/<tt/<ref id="assert.h" name="assert.h">/
1279 <tag/Declaration/<tt/void assert (int cond);/
1280 <tag/Description/<tt/assert/ is a macro that expands to a <tt/id/
1281 statement. If the condition evaluates t zero (false), assert prints a message
1282 on stderr and aborts the program.
1283 <tag/Notes/<itemize>
1284 <item>The function is actually a macro.
1286 <tag/Availability/ISO 9899
1288 <ref id="abort" name="abort">,
1289 <ref id="exit" name="exit">
1295 <sect1>atexit<label id="atexit"><p>
1299 <tag/Function/Register an exit function.
1300 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1301 <tag/Declaration/<tt/int __fastcall__ atexit (void (*exitfunc) (void));/
1302 <tag/Description/<tt/atexit/ registers the function pointed to by
1303 <tt/exitfunc/ as an exit function. Exit functions are called when the program
1304 terminates, they are called in LIFO order (the last function registered is
1305 called first). <tt/atexit/ returns zero on success and a nonzero value on
1307 <tag/Notes/<itemize>
1308 <item>A maximum of 5 exit functions can be registered.
1309 <item>There is no way to unregister an exit function.
1310 <item>The function is only available as fastcall function, so it may only be
1311 used in presence of a prototype.
1313 <tag/Availability/ISO 9899
1315 <ref id="abort" name="abort">,
1316 <ref id="exit" name="exit">
1322 <sect1>atmos_load<label id="atmos_load"><p>
1326 <tag/Function/Load Atmos tape.
1327 <tag/Header/<tt/<ref id="atmos.h" name="atmos.h">/
1328 <tag/Declaration/<tt/void __fastcall__ atmos_load(const char* name);/
1329 <tag/Description/<tt/atmos_load/ reads a memory block from tape.
1330 <tag/Notes/<itemize>
1331 <item>The function is available only as a fastcall function; so, it may be used
1332 only in the presence of a prototype.
1334 <tag/Availability/cc65
1336 <ref id="atmos_save" name="atmos_save">
1342 <sect1>atmos_save<label id="atmos_save"><p>
1346 <tag/Function/Save Atmos tape.
1347 <tag/Header/<tt/<ref id="atmos.h" name="atmos.h">/
1348 <tag/Declaration/<tt/void __fastcall__ atmos_save(const char* name, const void* start, const void* end);/
1349 <tag/Description/<tt/atmos_save/ writes a memory block to tape.
1350 <tag/Notes/<itemize>
1351 <item>The function is available only as a fastcall function; so, it may be used
1352 only in the presence of a prototype.
1354 <tag/Availability/cc65
1356 <ref id="atmos_load" name="atmos_load">
1358 atmos_save("hires", 0xa000, 0xc000);
1364 <sect1>atoi<label id="atoi"><p>
1368 <tag/Function/Convert a string to an integer.
1369 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1370 <tag/Declaration/<tt/int __fastcall__ atoi (const char* s);/
1371 <tag/Description/<tt/atoi/ converts the given string into an integer.
1372 Conversion stops as soon as any invalid character is encountered.
1373 <tag/Notes/<itemize>
1374 <item>There is no way to detect any conversion errors.
1375 <item>The function does not check for an numerical overflow when converting.
1376 <item>The function is only available as fastcall function, so it may only be
1377 used in presence of a prototype.
1379 <tag/Availability/ISO 9899
1381 <ref id="atol" name="atol">,
1382 <ref id="itoa" name="itoa">,
1383 <ref id="ltoa" name="ltoa">,
1384 <ref id="ultoa" name="ultoa">,
1385 <ref id="utoa" name="utoa">
1391 <sect1>atol<label id="atol"><p>
1395 <tag/Function/Convert a string to a long integer.
1396 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1397 <tag/Declaration/<tt/long __fastcall__ atol (const char* s);/
1398 <tag/Description/<tt/atol/ converts the given string into a long integer.
1399 Conversion stops as soon as any invalid character is encountered.
1400 <tag/Notes/<itemize>
1401 <item>There is no way to detect any conversion errors.
1402 <item>The function does not check for an numerical overflow when converting.
1403 <item>The function is only available as fastcall function, so it may only be
1404 used in presence of a prototype.
1406 <tag/Availability/ISO 9899
1408 <ref id="atoi" name="atoi">,
1409 <ref id="itoa" name="itoa">,
1410 <ref id="ltoa" name="ltoa">,
1411 <ref id="ultoa" name="ultoa">,
1412 <ref id="utoa" name="utoa">
1418 <sect1>bgcolor<label id="bgcolor"><p>
1422 <tag/Function/Set the background text color.
1423 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1424 <tag/Declaration/<tt/unsigned char __fastcall__ bgcolor (unsigned char color);/
1425 <tag/Description/The function will set a new background color and return the
1426 old (current) one. The background color is valid for the whole text output
1427 area of the screen, not just for new text.
1428 <tag/Notes/<itemize>
1429 <item>Background colors are system dependent. The function may have no effect
1430 on systems where the background color cannot be changed.
1431 <item>The function is only available as fastcall function, so it may only be
1432 used in presence of a prototype.
1434 <tag/Availability/cc65
1436 <ref id="bordercolor" name="bordercolor">,
1437 <ref id="textcolor" name="textcolor">
1443 <sect1>bordercolor<label id="bordercolor"><p>
1447 <tag/Function/Set the border (frame) color.
1448 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1449 <tag/Declaration/<tt/unsigned char __fastcall__ bordercolor (unsigned char color);/
1450 <tag/Description/The function will set a new border color. It returns the old
1451 (current) border color.
1452 <tag/Notes/<itemize>
1453 <item>Border colors are system dependent. The function may have no effect
1454 on systems where the border color cannot be changed.
1455 <item>The function is only available as fastcall function, so it may only
1456 be used in presence of a prototype.
1458 <tag/Availability/cc65
1460 <ref id="bgcolor" name="bgcolor">,
1461 <ref id="textcolor" name="textcolor">
1467 <sect1>bsearch<label id="bsearch"><p>
1471 <tag/Function/Do a binary search in a sorted array.
1472 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1473 <tag/Declaration/<tt/void* __fastcall__ bsearch (const void* key,
1474 const void* base, size_t n, size_t size,
1475 int __fastcall__ (* cmp) (const void*, const void*));/
1476 <tag/Description/<tt/bsearch/ searches a sorted array for a member that
1477 matches the one pointed to by <tt/key/. <tt/base/ is the address of the array,
1478 <tt/n/ is the number of elements, <tt/size/ the size of an element and <tt/cmp/
1479 the function used to compare the members against the key. The function returns
1480 a pointer to the member found, or <tt/NULL/ if there was no match.
1481 <tag/Notes/<itemize>
1482 <item>The contents of the array must be sorted in ascending order according to
1483 the compare function given.
1484 <item>If there are multiple members that match the key, the function will
1485 return one of the members.
1486 <item>The function is only available as fastcall function, so it may only
1487 be used in presence of a prototype.
1488 <item>The function to which <tt/cmp/ points must have the <tt/fastcall/ calling
1491 <tag/Availability/ISO 9899
1493 <ref id="qsort" name="qsort">
1499 <sect1>bzero<label id="bzero"><p>
1503 <tag/Function/Fill a memory area with zeroes.
1504 <tag/Header/<tt/<ref id="string.h" name="string.h">/
1505 <tag/Declaration/<tt/void __fastcall__ bzero (void* p, size_t count);/
1506 <tag/Description/<tt/bzero/ fills the memory area pointed to by <tt/p/ with
1508 <tag/Notes/<itemize>
1509 <item>The function is non standard and therefore only available in non ANSI
1510 mode. You should use <tt/<ref id="memset" name="memset">/ instead.
1511 <item>The function is only available as fastcall function, so it may only
1512 be used in presence of a prototype.
1514 <tag/Availability/cc65
1516 <ref id="_swap" name="_swap">,
1517 <ref id="memcpy" name="memcpy">,
1518 <ref id="memmove" name="memmove">,
1519 <ref id="memset" name="memset">,
1525 <sect1>c64mode<label id="c64mode"><p>
1529 <tag/Function/Switch the C128 into C64 compatible mode.
1530 <tag/Header/<tt/<ref id="c128.h" name="c128.h">/
1531 <tag/Declaration/<tt/void c64mode (void);/
1532 <tag/Description/The function will cause the machine to reboot into C64 mode.
1533 <tag/Notes/<itemize>
1534 <item>The function is specific to the C128.
1535 <item>The function will not return to the caller.
1537 <tag/Availability/C128
1543 <sect1>calloc<label id="calloc"><p>
1547 <tag/Function/Allocate and clear memory.
1548 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1549 <tag/Declaration/<tt/void* __fastcall__ calloc (size_t n, size_t size);/
1550 <tag/Description/<tt/calloc/ allocates memory for an array of <tt/n/ elements
1551 of size <tt/size/, clears the whole block with binary zeroes and returns a
1552 pointer to it. On error (not enough memory available), <tt/calloc/ returns
1554 <tag/Notes/<itemize>
1555 <item>Clearing the memory may not have the expected effect on all platforms:
1556 pointers in the block may not be <tt/NULL/ and floating point variables may
1557 not be zero (0.0). In other words: The "clearing" effect of this function
1558 should be used with care for portable programs.
1559 <item>The function is only available as fastcall function, so it may only
1560 be used in presence of a prototype.
1562 <tag/Availability/ISO 9899
1564 <ref id="_heapadd" name="_heapadd">,
1565 <ref id="_heapblocksize" name="_heapblocksize">,
1566 <ref id="_heapmaxavail" name="_heapmaxavail">,
1567 <ref id="_heapmemavail" name="_heapmemavail">,
1568 <ref id="free" name="free">,
1569 <ref id="malloc" name="malloc">,
1570 <ref id="realloc" name="realloc">
1576 <sect1>cbm_k_acptr<label id="cbm_k_acptr"><p>
1580 <tag/Function/Input byte from serial bus
1581 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
1582 <tag/Declaration/<tt/unsigned char cbm_k_acptr (void);/
1583 <tag/Description/The function returns a byte of data, which it
1584 gets from the current TALKer on the serial bus.
1585 In order to receive the data, the device must have previously been
1586 sent a command to TALK and a secondary address if it needs one.
1587 <tag/Notes/<itemize>
1590 <tag/Availability/cc65
1592 <ref id="cbm_k_talk" name="cbm_k_talk">,
1598 <sect1>cbm_k_basin<label id="cbm_k_basin"><p>
1602 <tag/Function/Input a Character from the Current Device
1603 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
1604 <tag/Declaration/<tt/unsigned char cbm_k_basin (void);/
1605 <tag/Description/The function returns a character from the current input device.
1606 Device must first have been OPENed and then designated as the input channel by the CHKIN routine.
1607 When this function is called, the next byte of data available from the device is returned.
1608 Exception is the routine for the keyboard device (which is the default input device).
1609 <tag/Notes/<itemize>
1612 <tag/Availability/cc65
1614 <ref id="cbm_k_open" name="cbm_k_open">,
1615 <ref id="cbm_k_chkin" name="cbm_k_chkin">
1621 <sect1>cbm_k_bsout<label id="cbm_k_bsout"><p>
1625 <tag/Function/Output a byte
1626 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
1627 <tag/Declaration/<tt/void __fastcall__ cbm_k_bsout (unsigned char C);/
1628 <tag/Description/Function sends the character to the current output device.
1629 Unless a device has been OPENed and designated as the
1630 current output channel using the CHKOUT routine, the character is
1631 printed to the screen, which is the default output device. If the
1632 cassette is the current device, outputting a byte will only add it to
1633 the buffer. No actual transmission of data will occur until the
1634 192-byte buffer is full.
1635 <tag/Notes/<itemize>
1636 <item>The function is only available as fastcall function, so it may
1637 only be used in presence of a prototype.
1639 <tag/Availability/cc65
1641 <ref id="cbm_k_open" name="cbm_k_open">,
1642 <ref id="cbm_k_chkin" name="cbm_k_chkout">
1648 <sect1>cbm_k_chkin<label id="cbm_k_chkin"><p>
1652 <tag/Function/Designate a Logical File As the Current Input Channel
1653 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
1654 <tag/Declaration/<tt/unsigned char __fastcall__ cbm_k_chkin (unsigned char FN);/
1655 <tag/Description/If you wish to
1656 get data from any device other than the keyboard, this function must be
1657 called after OPENing the device, before you can get a data byte with
1658 the cbm_k_basin or cbm_k_getin routine. When called, the routine will designate
1659 the logical file whose file number was supplied as the
1660 current file, its device as the current device, and its secondary
1661 address as the current secondary address. If the device on the
1662 channel is a serial device, which requires a TALK command and
1663 sometimes a secondary address, function will send them over the
1665 <tag/Notes/<itemize>
1666 <item>The function is only available as fastcall function, so it may
1667 only be used in presence of a prototype.
1669 <tag/Availability/cc65
1671 <ref id="cbm_k_open" name="cbm_k_open">,
1672 <ref id="cbm_k_basin" name="cbm_k_basin">,
1673 <ref id="cbm_k_getin" name="cbm_k_getin">
1679 <sect1>cbm_k_ciout<label id="cbm_k_ciout"><p>
1683 <tag/Function/Transmit a byte over the serial bus
1684 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
1685 <tag/Declaration/<tt/void __fastcall__ cbm_k_ciout (unsigned char C);/
1686 <tag/Description/Purpose of this function is to send a byte of data over
1687 the serial bus. In order for the data to be received, the serial
1688 device must have first been commanded to LISTEN and been given a
1689 secondary address if necessary. This routine always buffers the
1690 current character, and defers sending it until the next byte is
1691 buffered. When the UNLISTEN command is sent, the last byte will be
1692 sent with an End or Identify (EOI).
1693 <tag/Notes/<itemize>
1694 <item>The function is only available as fastcall function, so it may
1695 only be used in presence of a prototype.
1697 <tag/Availability/cc65
1699 <ref id="cbm_k_listen" name="cbm_k_listen">,
1700 <ref id="cbm_k_unlsn" name="cbm_k_unlsn">
1706 <sect1>cbm_k_ckout<label id="cbm_k_ckout"><p>
1710 <tag/Function/Designate a Logical File As the Current Output Channel
1711 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
1712 <tag/Declaration/<tt/unsigned char __fastcall__ cbm_k_ckout (unsigned char FN);/
1713 <tag/Description/If you wish to
1714 output data to any device other than the screen, this routine must be
1715 called after OPENing the device, and before you output a data byte
1716 with the cbm_k_bsout() function. When called, the function will designate the
1717 logical file whose file number was supplied as the current
1718 file, its device as the current device, and its secondary address as
1719 the current secondary address. If the device on the channel uses the
1720 serial bus, and therefore requires a LISTEN command and possibly a
1721 secondary address, this information will be sent on the bus.
1722 <tag/Notes/<itemize>
1723 <item>The function is only available as fastcall function, so it may
1724 only be used in presence of a prototype.
1726 <tag/Availability/cc65
1728 <ref id="cbm_k_bsout" name="cbm_k_bsout">,
1729 <ref id="cbm_k_listen" name="cbm_k_listen">
1735 <sect1>cbm_k_clall<label id="cbm_k_clall"><p>
1739 <tag/Function/Close All Logical I/O Files
1740 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
1741 <tag/Declaration/<tt/void cbm_k_clall (void);/
1742 <tag/Description/It closes all
1743 open files, by resetting the index into open files to
1744 zero and restores the default I/O devices.
1745 <tag/Notes/<itemize>
1748 <tag/Availability/cc65
1750 <ref id="cbm_k_open" name="cbm_k_open">,
1751 <ref id="cbm_k_close" name="cbm_k_close">
1757 <sect1>cbm_k_close<label id="cbm_k_close"><p>
1761 <tag/Function/Close a Logical I/O File
1762 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
1763 <tag/Declaration/<tt/void __fastcall__ cbm_k_close (unsigned char FN);/
1764 <tag/Description/It is used to
1765 close a logical file after all I/O operations involving that file have
1767 <tag/Notes/<itemize>
1768 <item>The function is only available as fastcall function, so it may
1769 only be used in presence of a prototype.
1771 <tag/Availability/cc65
1773 <ref id="cbm_k_open" name="cbm_k_open">,
1774 <ref id="cbm_k_clall" name="cbm_k_clall">
1780 <sect1>cbm_k_clrch<label id="cbm_k_clrch"><p>
1784 <tag/Function/Restore Current Input and Output Devices to the Default Devices
1785 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
1786 <tag/Declaration/<tt/void cbm_k_clrch (void);/
1787 <tag/Description/It sets the
1788 current input device to the keyboard, and the current output device to
1789 the screen. Also, if the current input device was formerly a serial
1790 device, the routine sends it an UNTALK command on the serial bus, and
1791 if a serial device was formerly the current output device, the routine
1792 sends it an UNLISTEN command.
1793 <tag/Notes/<itemize>
1796 <tag/Availability/cc65
1798 <ref id="cbm_k_chkin" name="cbm_k_chkin">,
1799 <ref id="cbm_k_ckout" name="cbm_k_ckout">
1805 <sect1>cbm_k_getin<label id="cbm_k_getin"><p>
1809 <tag/Function/Get One Byte from the Input Device
1810 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
1811 <tag/Declaration/<tt/unsigned char cbm_k_getin (void);/
1812 <tag/Description/Function gets a character from the current input device.
1813 <tag/Notes/<itemize>
1816 <tag/Availability/cc65
1818 <ref id="cbm_k_basin" name="cbm_k_basin">
1824 <sect1>cbm_k_iobase<label id="cbm_k_iobase"><p>
1828 <tag/Function/Return Base Address of Memory-Mapped I/O Devices
1829 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
1830 <tag/Declaration/<tt/unsigned cbm_k_iobase (void);/
1831 <tag/Description/This function returns the address of
1832 the memory section where the memory mapped I/O devices are located. This
1833 address can then be used with an offset to access the memory mapped I/O
1834 devices in the Commodore 64. The offset is the number of locations from
1835 the beginning of the page on which the I/O register you want is located.
1836 This function exists to provide compatibility between the Commodore 64,
1837 VIC-20, and future models of the Commodore 64. If the I/O locations for
1838 a program are set by a call to this function, they should
1839 still remain compatible with future versions of the Commodore 64, the
1841 <tag/Notes/<itemize>
1844 <tag/Availability/cc65
1852 <sect1>cbm_k_listen<label id="cbm_k_listen"><p>
1856 <tag/Function/Command a device on the serial bus to LISTEN
1857 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
1858 <tag/Declaration/<tt/void __fastcall__ cbm_k_listen (unsigned char dev);/
1859 <tag/Description/This function will command a device on the serial bus to
1860 receive data. The KERNAL routine will OR the supplied device number bit by bit
1861 to convert it to a listen address, then transmits this data as a command on
1862 the serial bus. The specified device will then go into listen mode, and
1863 be ready to accept information.
1864 <tag/Notes/<itemize>
1865 <item>The function is only available as fastcall function, so it may
1866 only be used in presence of a prototype.
1868 <tag/Availability/cc65
1870 <ref id="cbm_k_unlsn" name="cbm_k_unlsn">,
1876 <sect1>cbm_k_load<label id="cbm_k_load"><p>
1880 <tag/Function/Load RAM from a Device
1881 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
1882 <tag/Declaration/<tt/unsigned int __fastcall__ cbm_k_load(unsigned char flag, unsigned addr);/
1883 <tag/Description/This function LOADs data bytes from any input device directly into the memory.
1884 It can also be used for a verify operation, comparing data from a device with the data already in
1885 memory, while leaving the data stored in RAM unchanged.
1886 The flag must be set to 0 for a LOAD operation, or 1 for a
1887 verify, If the input device is OPENed with a secondary address (SA) of 0
1888 the header information from the device is ignored. In this case, the starting address for the load must be supplied.
1889 If the device is addressed with a secondary address of 1, then the data is
1890 loaded into memory starting at the location specified by the header.
1891 Function returns the address of the highest RAM location loaded.
1892 Before this function can be called, the KERNAL SETLFS, and SETNAM
1893 routines must be called.
1894 <tag/Notes/<itemize>
1895 <item>The function is only available as fastcall function, so it may
1896 only be used in presence of a prototype.
1898 <tag/Availability/cc65
1900 <ref id="cbm_k_save" name="cbm_k_save">,
1901 <ref id="cbm_k_setlfs" name="cbm_k_setlfs">,
1902 <ref id="cbm_k_setnam" name="cbm_k_setnam">
1908 <sect1>cbm_k_open<label id="cbm_k_open"><p>
1912 <tag/Function/Open a Logical I/O File
1913 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
1914 <tag/Declaration/<tt/unsigned char cbm_k_open (void);/
1915 <tag/Description/This function assigns a logical file to a device, so that it can be used for
1916 Input/Output operations. In order to specify the logical file number,
1917 the device number, and the secondary address if any, the cbm_k_setlfs() function must first be called.
1918 Likewise, in order to designate the filename, the cbm_k_setnam() function must be used first. After these two
1919 functions are called, cbm_k_open() is then called.
1920 <tag/Notes/<itemize>
1923 <tag/Availability/cc65
1925 <ref id="cbm_k_close" name="cbm_k_close">,
1926 <ref id="cbm_k_setlfs" name="cbm_k_setlfs">,
1927 <ref id="cbm_k_setnam" name="cbm_k_setnam">
1933 <sect1>cbm_k_readst<label id="cbm_k_readst"><p>
1937 <tag/Function/Read status word
1938 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
1939 <tag/Declaration/<tt/unsigned char cbm_k_readst (void);/
1940 <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.
1941 <tag/Notes/<itemize>
1944 <tag/Availability/cc65
1952 <sect1>cbm_k_save<label id="cbm_k_save"><p>
1956 <tag/Function/Save RAM to a Device
1957 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
1958 <tag/Declaration/<tt/unsigned char __fastcall__ cbm_k_save(unsigned int start, unsigned int end)/
1959 <tag/Description/This function saves a section of memory. The cbm_k_setlfs() and cbm_k_setnam() functions must be
1960 used before calling this function. However, a file name is not required to
1961 SAVE to device 1 (the Datassette(TM) recorder). Any attempt to save to
1962 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.
1963 <tag/Notes/<itemize>
1964 <item>The function is only available as fastcall function, so it may
1965 only be used in presence of a prototype.
1967 <tag/Availability/cc65
1969 <ref id="cbm_k_load" name="cbm_k_load">,
1970 <ref id="cbm_k_setlfs" name="cbm_k_setlfs">,
1971 <ref id="cbm_k_setnam" name="cbm_k_setnam">
1977 <sect1>cbm_k_setlfs<label id="cbm_k_setlfs"><p>
1981 <tag/Function/Set up a logical file
1982 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
1983 <tag/Declaration/<tt/void __fastcall__ cbm_k_setlfs (unsigned char LFN, unsigned char DEV, unsigned char SA);/
1984 <tag/Description/This functions sets up the logical file by setting its number, device address,
1985 and secondary address.
1986 <tag/Notes/<itemize>
1987 <item>The function is only available as fastcall function, so it may
1988 only be used in presence of a prototype.
1990 <tag/Availability/cc65
1992 <ref id="cbm_k_setnam" name="cbm_k_setnam">
1998 <sect1>cbm_k_setnam<label id="cbm_k_setnam"><p>
2002 <tag/Function/Set Filename Parameters
2003 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
2004 <tag/Declaration/<tt/void __fastcall__ cbm_k_setnam (const char* Name);/
2005 <tag/Description/This function is used to set up the file name for the OPEN,
2006 SAVE, or LOAD operations.
2007 <tag/Notes/<itemize>
2008 <item>The function is only available as fastcall function, so it may
2009 only be used in presence of a prototype.
2011 <tag/Availability/cc65
2013 <ref id="cbm_k_open" name="cbm_k_open">,
2014 <ref id="cbm_k_load" name="cbm_k_load">,
2015 <ref id="cbm_k_save" name="cbm_k_save">
2021 <sect1>cbm_k_talk<label id="cbm_k_talk"><p>
2025 <tag/Function/Commands device to TALK
2026 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
2027 <tag/Declaration/<tt/void __fastcall__ cbm_k_talk (unsigned char dev);/
2028 <tag/Description/When called, it ORs the device number with the TALK code (64, $40) and sends it on the serial
2029 bus. This commands the device to TALK.
2030 <tag/Notes/<itemize>
2031 <item>The function is only available as fastcall function, so it may
2032 only be used in presence of a prototype.
2034 <tag/Availability/cc65
2036 <ref id="cbm_k_acptr" name="cbm_k_acptr">
2042 <sect1>cbm_k_unlsn<label id="cbm_k_unlsn"><p>
2046 <tag/Function/Send an UNLISTEN command
2047 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
2048 <tag/Declaration/<tt/void cbm_k_unlsn (void);/
2049 <tag/Description/This function commands all devices on the serial bus to
2050 stop receiving data from the host computer (i.e., UNLISTEN). Calling this
2051 function results in an UNLISTEN command being transmitted on the serial
2052 bus. Only devices previously commanded to LISTEN are affected. This
2053 function is normally used after the host computer is finished sending data
2054 to external devices. Sending the UNLISTEN commands the listening devices
2055 to get off the serial bus so it can be used for other purposes.
2056 <tag/Notes/<itemize>
2059 <tag/Availability/cc65
2061 <ref id="cbm_k_listen" name="cbm_k_listen">
2067 <sect1>cclear<label id="cclear"><p>
2071 <tag/Function/Clear part of a line (write a given number of spaces).
2072 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2073 <tag/Declaration/<tt/void __fastcall__ cclear (unsigned char length);/
2074 <tag/Description/The function clears part of a line by writing <tt/length/
2075 spaces in the current text color.
2076 <tag/Notes/<itemize>
2077 <item>The function is only available as fastcall function, so it may
2078 only be used in presence of a prototype.
2080 <tag/Availability/cc65
2082 <ref id="cclearxy" name="cclearxy">,
2083 <ref id="clrscr" name="clrscr">
2089 <sect1>cclearxy<label id="cclearxy"><p>
2093 <tag/Function/Clear part of a line (write a given number of spaces) starting
2094 at a specific screen position.
2095 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2096 <tag/Declaration/<tt/void __fastcall__ cclearxy (unsigned char x, unsigned char y, unsigned char length);/
2097 <tag/Description/The function moves the cursor to a specific position, and
2098 will then clear part of the line by writing <tt/length/ spaces in the current
2100 <tag/Notes/<itemize>
2101 <item>The function is only available as fastcall function, so it may
2102 only be used in presence of a prototype.
2104 <tag/Availability/cc65
2106 <ref id="cclear" name="cclear">,
2107 <ref id="clrscr" name="clrscr">
2113 <sect1>cgetc<label id="cgetc"><p>
2117 <tag/Function/Read a character from the keyboard.
2118 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2119 <tag/Declaration/<tt/char cgetc (void);/
2120 <tag/Description/The function reads a character from the keyboard. If there is
2121 no character available, <tt/cgetc/ waits until the user presses a key. If the
2122 cursor is enabled by use of the <tt/cursor/ function, a blinking cursor is
2123 displayed while waiting.
2124 <tag/Notes/<itemize>
2125 <item>If the system supports a keyboard buffer, <tt/cgetc/ will fetch a key
2126 from this buffer and wait only if the buffer is empty.
2128 <tag/Availability/cc65
2130 <ref id="cursor" name="cursor">,
2131 <ref id="kbhit" name="kbhit">
2137 <sect1>chline<label id="chline"><p>
2141 <tag/Function/Output a horizontal line in text mode.
2142 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2143 <tag/Declaration/<tt/void __fastcall__ chline (unsigned char length);/
2144 <tag/Description/The function outputs a horizontal line with the given length
2145 starting at the current cursor position.
2146 <tag/Notes/<itemize>
2147 <item>The character used to draw the horizontal line is system dependent.
2148 If available, a line drawing character is used. Drawing a line that is partially
2149 off screen leads to undefined behaviour.
2150 <item>The function is only available as fastcall function, so it may only be
2151 used in presence of a prototype.
2153 <tag/Availability/cc65
2155 <ref id="chlinexy" name="chlinexy">,
2156 <ref id="cvline" name="cvline">,
2157 <ref id="cvlinexy" name="cvlinexy">
2163 <sect1>chlinexy<label id="chlinexy"><p>
2167 <tag/Function/Output a horizontal line at a given position in text mode.
2168 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2169 <tag/Declaration/<tt/void __fastcall__ chlinexy (unsigned char x, unsigned char y, unsigned char length);/
2170 <tag/Description/The function outputs a horizontal line with the given length
2171 starting at a given position.
2172 <tag/Notes/<itemize>
2173 <item>The character used to draw the horizontal line is system dependent.
2174 If available, a line drawing character is used. Drawing a line that is partially
2175 off screen leads to undefined behaviour.
2176 <item>The function is only available as fastcall function, so it may only be
2177 used in presence of a prototype.
2179 <tag/Availability/cc65
2181 <ref id="chline" name="chline">,
2182 <ref id="cvline" name="cvline">,
2183 <ref id="cvlinexy" name="cvlinexy">
2189 <sect1>clearerr<label id="clearerr"><p>
2193 <tag/Function/Clear error and end-of-file status of a stream.
2194 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
2195 <tag/Declaration/<tt/void __fastcall__ clearerr (FILE* f);/
2196 <tag/Description/<tt/clearerr/ clears the error and end-of-file status
2197 indicators for the stream <tt/f/.
2198 <tag/Notes/<itemize>
2199 <item>The function is only available as fastcall function, so it may only be
2200 used in presence of a prototype.
2202 <tag/Availability/ISO 9899
2204 <ref id="feof" name="feof">,
2205 <ref id="ferror" name="ferror">
2211 <sect1>clock<label id="clock"><p>
2215 <tag/Function/Determine the processor time used.
2216 <tag/Header/<tt/<ref id="time.h" name="time.h">/
2217 <tag/Declaration/<tt/clock_t clock (void);/
2218 <tag/Description/The <tt/clock/ function returns an approximaton of processor
2219 time used by the program. The time is returned in implementation defined
2220 units. It can be converted to seconds by dividing by the value of the macro
2221 <tt/CLOCKS_PER_SEC/.
2222 <tag/Notes/<itemize>
2223 <item>Since the machines, cc65 generated programs run on, cannot run multiple
2224 processes, the function will actually return the time since some
2225 implementation defined point in the past.
2227 <tag/Availability/ISO 9899
2229 <ref id="time" name="time">
2235 <sect1>clrscr<label id="clrscr"><p>
2239 <tag/Function/Clear the text screen.
2240 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2241 <tag/Declaration/<tt/void clrscr (void);/
2242 <tag/Description/The function clears the text screen and moves the cursor to
2243 the upper left corner.
2244 <tag/Availability/cc65
2246 <ref id="cclear" name="cclear">,
2247 <ref id="cclearxy" name="cclearxy">
2253 <sect1>close<label id="close"><p>
2257 <tag/Function/Close a file descriptor.
2258 <tag/Header/<tt/<ref id="fcntl.h" name="fcntl.h">/
2259 <tag/Declaration/<tt/int __fastcall__ close (int fd);/
2260 <tag/Description/The function closes the given file descriptor. It returns zero
2261 on success and -1 on error. If an error occurs, the cause can be determined by
2262 reading the <tt/errno/ variable.
2263 <tag/Notes/<itemize>
2264 <item>The function is only available as fastcall function, so it may only
2265 be used in presence of a prototype.
2267 <tag/Availability/POSIX 1003.1
2269 <ref id="creat" name="creat">,
2270 <ref id="open" name="open">
2276 <sect1>closedir<label id="closedir"><p>
2280 <tag/Function/Close a directory.
2281 <tag/Header/<tt/<ref id="dirent.h" name="dirent.h">/
2282 <tag/Declaration/<tt/int __fastcall__ closedir (DIR* dir);/
2283 <tag/Description/The function closes the given directory descriptor. It returns
2284 zero on success and -1 on error. If an error occurs, the cause can be determined
2285 by reading the <tt/errno/ variable.
2286 <tag/Notes/<itemize>
2287 <item>The function is only available as fastcall function, so it may only
2288 be used in presence of a prototype.
2290 <tag/Availability/POSIX 1003.1
2292 <ref id="opendir" name="opendir">,
2293 <ref id="readdir" name="readdir">
2299 <sect1>creat<label id="creat"><p>
2303 <tag/Function/Create a file.
2304 <tag/Header/<tt/<ref id="fcntl.h" name="fcntl.h">/
2305 <tag/Declaration/<tt/int __fastcall__ creat (const char* name, unsigned mode);/
2306 <tag/Description/<tt/creat/ creates a new file and returns the file descriptor
2307 associated with it. On error, -1 is returned and an error code is stored in
2309 <tag/Notes/<itemize>
2310 <item><tt/creat/ is identical to calling <tt/<ref id="open" name="open">/ with
2311 <tt/flags/ equal to <tt/O_WRONLY | O_CREAT | O_TRUNC/.
2312 <item>The function is only available as fastcall function, so it may only
2313 be used in presence of a prototype.
2315 <tag/Availability/POSIX 1003.1
2317 <ref id="close" name="close">,
2318 <ref id="open" name="open">
2324 <sect1>cprintf<label id="cprintf"><p>
2328 <tag/Function/Formatted output to the console.
2329 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2330 <tag/Declaration/<tt/int cprintf (const char* format, ...);/
2331 <tag/Description/The arguments are converted to text where necessary and
2332 formatted according to the format string given. The resulting string is output
2333 to the console. <tt/cprintf/ supports the same format specifiers as
2334 <tt/printf/. <!-- <tt/<ref id="printf" name="printf">/. -->
2335 <tag/Notes/<itemize>
2336 <item>Like all other <tt/conio/ output functions, <tt/cprintf/ distinguishes
2337 between <tt/\r/ and <tt/\n/.
2339 <tag/Availability/cc65
2341 <ref id="cputc" name="cputc">,
2342 <ref id="cputcxy" name="cputcxy">,
2343 <ref id="cputs" name="cputs">,
2344 <ref id="cputsxy" name="cputsxy">,
2345 <ref id="vcprintf" name="vcprintf">
2351 <sect1>cputc<label id="cputc"><p>
2355 <tag/Function/Output a character directly to the console.
2356 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2357 <tag/Declaration/<tt/void __fastcall__ cputc (char c);/
2358 <tag/Description/Output one character to the console at the current cursor
2360 <tag/Notes/<itemize>
2361 <item>Like all other <tt/conio/ output functions, <tt/cputc/ distinguishes
2362 between <tt/\r/ and <tt/\n/.
2363 <item>The function is only available as fastcall function, so it may only
2364 be used in presence of a prototype.
2366 <tag/Availability/cc65
2368 <ref id="cprintf" name="cprintf">,
2369 <ref id="cputcxy" name="cputcxy">,
2370 <ref id="cputs" name="cputs">,
2371 <ref id="cputsxy" name="cputsxy">,
2372 <ref id="vcprintf" name="vcprintf">
2378 <sect1>cputcxy<label id="cputcxy"><p>
2382 <tag/Function/Output a character at a specific screen position.
2383 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2384 <tag/Declaration/<tt/void __fastcall__ cputcxy (unsigned char x, unsigned char y, char c);/
2385 <tag/Description/<tt/cputcxy/ moves the cursor to the given x/y position on
2386 the screen and outputs one character.
2387 <tag/Notes/<itemize>
2388 <item>Like all other <tt/conio/ output functions, <tt/cputcxy/ distinguishes
2389 between <tt/\r/ and <tt/\n/.
2390 <item>The function is only available as fastcall function, so it may only
2391 be used in presence of a prototype.
2393 <tag/Availability/cc65
2395 <ref id="cprintf" name="cprintf">,
2396 <ref id="cputc" name="cputc">,
2397 <ref id="cputs" name="cputs">,
2398 <ref id="cputsxy" name="cputsxy">,
2399 <ref id="vcprintf" name="vcprintf">
2405 <sect1>cputs<label id="cputs"><p>
2409 <tag/Function/Output a string directly to the console.
2410 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2411 <tag/Declaration/<tt/void __fastcall__ cputs (const char* s);/
2412 <tag/Description/The function outputs the given string on the console at the
2413 current cursor position.
2414 <tag/Notes/<itemize>
2415 <item>Like all other <tt/conio/ output functions, <tt/cputs/ distinguishes
2416 between <tt/\r/ and <tt/\n/.
2417 <item>The function is only available as fastcall function, so it may only
2418 be used in presence of a prototype.
2420 <tag/Availability/cc65
2422 <ref id="cprintf" name="cprintf">,
2423 <ref id="cputc" name="cputc">,
2424 <ref id="cputcxy" name="cputcxy">,
2425 <ref id="cputsxy" name="cputsxy">,
2426 <ref id="vcprintf" name="vcprintf">
2432 <sect1>cputsxy<label id="cputsxy"><p>
2436 <tag/Function/Output a string to the console at a given position.
2437 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2438 <tag/Declaration/<tt/void __fastcall__ cputsxy (unsigned char x, unsigned char y, const char* s);/
2439 <tag/Description/<tt/cputsxy/ moves the cursor to the given x/y position,
2440 and outputs the string <tt/s/.
2441 <tag/Notes/<itemize>
2442 <item>Like all other <tt/conio/ output functions, <tt/cputsxy/ distinguishes
2443 between <tt/\r/ and <tt/\n/.
2444 <item>The function is only available as fastcall function, so it may only
2445 be used in presence of a prototype.
2447 <tag/Availability/cc65
2449 <ref id="cprintf" name="cprintf">,
2450 <ref id="cputc" name="cputc">,
2451 <ref id="cputcxy" name="cputcxy">,
2452 <ref id="cputs" name="cputs">,
2453 <ref id="vcprintf" name="vcprintf">
2459 <sect1>cursor<label id="cursor"><p>
2463 <tag/Function/Enable/disable a blinking cursor when waiting for keyboard input.
2464 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2465 <tag/Declaration/<tt/unsigned char __fastcall__ cursor (unsigned char onoff);/
2466 <tag/Description/If the argument to the function is non zero, a blinking cursor
2467 will be enabled when the <tt/cgetc/ function waits for input from the keyboard.
2468 If the argument is zero, <tt/cgetc/ will wait without a blinking cursor.
2469 <tag/Notes/<itemize>
2470 <item>The function is only available as fastcall function, so it may only
2471 be used in presence of a prototype.
2473 <tag/Availability/cc65
2475 <ref id="cgetc" name="cgetc">,
2476 <ref id="kbhit" name="kbhit">
2482 <sect1>cvline<label id="cvline"><p>
2486 <tag/Function/Output a vertical line in text mode.
2487 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2488 <tag/Declaration/<tt/void __fastcall__ cvline (unsigned char length);/
2489 <tag/Description/The function outputs a vertical line with the given length
2490 starting at the current cursor position.
2491 <tag/Notes/<itemize>
2492 <item>The character used to draw the vertical line is system dependent.
2493 If available, a line drawing character is used. Drawing a line that is partially
2494 off screen leads to undefined behaviour.
2495 <item>The function is only available as fastcall function, so it may only be
2496 used in presence of a prototype.
2498 <tag/Availability/cc65
2500 <ref id="chline" name="chline">,
2501 <ref id="chlinexy" name="chlinexy">,
2502 <ref id="cvlinexy" name="cvlinexy">
2508 <sect1>cvlinexy<label id="cvlinexy"><p>
2512 <tag/Function/Output a vertical line at a given position in text mode.
2513 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2514 <tag/Declaration/<tt/void __fastcall__ cvlinexy (unsigned char x, unsigned char y, unsigned char length);/
2515 <tag/Description/The function outputs a vertical line with the given length
2516 starting at a given position.
2517 <tag/Notes/<itemize>
2518 <item>The character used to draw the vertical line is system dependent.
2519 If available, a line drawing character is used. Drawing a line that is partially
2520 off screen leads to undefined behaviour.
2521 <item>The function is only available as fastcall function, so it may only be
2522 used in presence of a prototype.
2524 <tag/Availability/cc65
2526 <ref id="chline" name="chline">,
2527 <ref id="chlinexy" name="chlinexy">,
2528 <ref id="cvline" name="cvline">
2534 <sect1>div<label id="div"><p>
2538 <tag/Function/Divide two ints and return quotient and remainder.
2539 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
2540 <tag/Declaration/<tt/div_t __fastcall__ div (int numer, int denom);/
2541 <tag/Description/<tt/div/ divides <tt/numer/ by <tt/denom/ and returns the
2542 quotient and remainder in a <tt/div_t/ structure.
2543 <tag/Notes/<itemize>
2544 <item>The function is only available as fastcall function, so it may only
2545 be used in presence of a prototype.
2547 <tag/Availability/ISO 9899
2555 <sect1>em_commit<label id="em_commit"><p>
2559 <tag/Function/Commit changes into extended memory.
2560 <tag/Header/<tt/<ref id="em.h" name="em.h">/
2561 <tag/Declaration/<tt/void em_commit (void);/
2562 <tag/Description/Commit changes in the memory window to extended storage. If
2563 the contents of the memory window have been changed, these changes may be lost
2564 if <tt/<ref id="em_map" name="em_map">/, <tt/<ref id="em_use" name="em_use">/,
2565 <tt/<ref id="em_copyfrom" name="em_copyfrom">/ or <tt/<ref id="em_copyto"
2566 name="em_copyto">/ are called without calling <tt/em_commit/ first.
2567 <tag/Notes/<itemize>
2568 <item>Calling <tt/em_commit/ does not necessarily mean that changes to the
2569 memory window are discarded, it does just mean that the drivers is allowed
2571 <item>The function is only available as fastcall function, so it may only be
2572 used in presence of a prototype.
2573 <item>The function produces undefined results if no extended memory driver is
2576 <tag/Availability/cc65
2578 <ref id="em_load_driver" name="em_load_driver">,
2579 <ref id="em_map" name="em_map">,
2580 <ref id="em_use" name="em_use">
2586 <sect1>em_copyfrom<label id="em_copyfrom"><p>
2590 <tag/Function/Copy from extended into normal memory.
2591 <tag/Header/<tt/<ref id="em.h" name="em.h">/
2592 <tag/Declaration/<tt/void __fastcall__ em_copyfrom (const struct em_copy* copy_data);/
2593 <tag/Description/Copy data from extended memory into linear memory. Source and
2594 target addresses as well as the number of bytes to transfer are specified in
2595 the <tt/em_copy/ structure that is passed as a parameter.
2596 <tag/Notes/<itemize>
2597 <item>Calling <tt/em_copyfrom/ will invalidate the memory window, so if you
2598 made any changes to the data in the window, call <tt/<ref id="em_commit"
2599 name="em_commit">/ first, or the changes are lost.
2600 <item>The function is only available as fastcall function, so it may only be
2601 used in presence of a prototype.
2602 <item>The function produces undefined results if no extended memory driver is
2605 <tag/Availability/cc65
2607 <ref id="em_commit" name="em_commit">,
2608 <ref id="em_copyto" name="em_copyto">,
2609 <ref id="em_load_driver" name="em_load_driver">
2615 <sect1>em_copyto<label id="em_copyto"><p>
2619 <tag/Function/Copy from normal into extended memory.
2620 <tag/Header/<tt/<ref id="em.h" name="em.h">/
2621 <tag/Declaration/<tt/void __fastcall__ em_copyto (const struct em_copy* copy_data);/
2622 <tag/Description/Copy data from linear into extended memory. Source and
2623 target addresses as well as the number of bytes to transfer are specified in
2624 the <tt/em_copy/ structure that is passed as a parameter.
2625 <tag/Notes/<itemize>
2626 <item>Calling <tt/em_copyto/ will invalidate the memory window, so if you
2627 made any changes to the data in the window, call <tt/<ref id="em_commit"
2628 name="em_commit">/ first, or the changes are lost.
2629 <item>The function is only available as fastcall function, so it may only be
2630 used in presence of a prototype.
2631 <item>The function produces undefined results if no extended memory driver is
2634 <tag/Availability/cc65
2636 <ref id="em_commit" name="em_commit">,
2637 <ref id="em_copyfrom" name="em_copyfrom">,
2638 <ref id="em_load_driver" name="em_load_driver">
2644 <sect1>em_install<label id="em_install"><p>
2648 <tag/Function/Install an already loaded extended memory driver.
2649 <tag/Header/<tt/<ref id="em.h" name="em.h">/
2650 <tag/Declaration/<tt/unsigned char _fastcall__ em_install (void* driver);/
2651 <tag/Description/The function installs an already loaded extended memory driver
2652 and returns an error code. The function may be used to install a driver linked
2653 statically to the program.
2654 <tag/Notes/<itemize>
2655 <item>Not all drivers are able to detect if the supported hardware is really
2657 <item>The function is only available as fastcall function, so it may only be
2658 used in presence of a prototype.
2660 <tag/Availability/cc65
2662 <ref id="em_load_driver" name="em_load_driver">,
2663 <ref id="em_uninstall" name="em_uninstall">,
2664 <ref id="em_unload" name="em_unload">
2670 <sect1>em_load_driver<label id="em_load_driver"><p>
2674 <tag/Function/Load and initialize an extended memory driver.
2675 <tag/Header/<tt/<ref id="em.h" name="em.h">/
2676 <tag/Declaration/<tt/void __fastcall__ em_load_driver (const char* name);/
2677 <tag/Description/Load an extended memory driver into memory and initialize
2678 it. The function returns an error code that tells if all this has been
2680 <tag/Notes/<itemize>
2681 <item>Not all drivers are able to detect if the supported hardware is really
2683 <item>The function is only available as fastcall function, so it may only be
2684 used in presence of a prototype.
2685 <item>The driver is loaded by name, so currently you must know the type of
2686 extended memory that should be supported. There is no autodetect capability.
2688 <tag/Availability/cc65
2690 <ref id="em_unload" name="em_unload">
2696 <sect1>em_map<label id="em_map"><p>
2700 <tag/Function/Make a page of extended memory accessible.
2701 <tag/Header/<tt/<ref id="em.h" name="em.h">/
2702 <tag/Declaration/<tt/void* __fastcall__ em_map (unsigned page);/
2703 <tag/Description/The function maps one page of extended memory into linear
2704 memory and returns a pointer to the page frame. Depending on the hardware
2705 and driver, the data is either mapped into the address space or transfered
2706 into a buffer. If you don't need the actual contents of the page (for example
2707 because you're going to overwrite it completely), it is better to call
2708 <tt/<ref id="em_use" name="em_use">/ instead. <tt/em_use/ will not transfer the
2709 data if it is possible to avoid that.
2710 <tag/Notes/<itemize>
2711 <item>Calling <tt/em_map/ will invalidate the memory window, so if you
2712 made any changes to the data in the window, call <tt/<ref id="em_commit"
2713 name="em_commit">/ first, or the changes are lost.
2714 <item>The function is only available as fastcall function, so it may only be
2715 used in presence of a prototype.
2716 <item>The function produces undefined results if no extended memory driver is
2719 <tag/Availability/cc65
2721 <ref id="em_commit" name="em_commit">,
2722 <ref id="em_load_driver" name="em_load_driver">,
2723 <ref id="em_use" name="em_use">
2729 <sect1>em_pagecount<label id="em_pagecount"><p>
2733 <tag/Function/Return the number of available extended memory pages.
2734 <tag/Header/<tt/<ref id="em.h" name="em.h">/
2735 <tag/Declaration/<tt/unsigned em_pagecount (void);/
2736 <tag/Description/The function returns the size of the extended memory supported
2737 by the driver in 256 byte pages.
2738 <tag/Notes/<itemize>
2739 <item>The function returns zero if no extended memory driver is loaded.
2740 <item>The function may return zero if the supported hardware was not detected.
2742 <tag/Availability/cc65
2744 <ref id="em_load_driver" name="em_load_driver">
2750 <sect1>em_uninstall<label id="em_uninstall"><p>
2754 <tag/Function/Uninstall an already loaded extended memory driver.
2755 <tag/Header/<tt/<ref id="em.h" name="em.h">/
2756 <tag/Declaration/<tt/unsigned char em_uninstall (void);/
2757 <tag/Description/The function uninstalls an already loaded extended memory
2758 driver but doesn't remove it from memory.
2759 <tag/Notes/<itemize>
2760 <item>If the driver has been loaded using <tt/<ref id="em_load_driver"
2761 name="em_load_driver">/, <tt/<ref id="em_unload" name="em_unload">/
2762 should be used instead of <tt/em_uninstall/ so the driver is also removed
2765 <tag/Availability/cc65
2767 <ref id="em_install" name="em_install">,
2768 <ref id="em_load_driver" name="em_load_driver">,
2769 <ref id="em_unload" name="em_unload">
2775 <sect1>em_unload<label id="em_unload"><p>
2779 <tag/Function/Unload an extended memory driver.
2780 <tag/Header/<tt/<ref id="em.h" name="em.h">/
2781 <tag/Declaration/<tt/unsigned char em_unload (void);/
2782 <tag/Description/The function unloads a loaded extended memory driver and
2783 frees all memory allocated for the driver.
2784 <tag/Notes/<itemize>
2785 <item>The function does nothing if no driver is loaded.
2787 <tag/Availability/cc65
2789 <ref id="em_load_driver" name="em_load_driver">
2795 <sect1>em_use<label id="em_use"><p>
2799 <tag/Function/Prepare an extended memory page for use.
2800 <tag/Header/<tt/<ref id="em.h" name="em.h">/
2801 <tag/Declaration/<tt/void* __fastcall__ em_use (unsigned page);/
2802 <tag/Description/The function maps one page of extended memory into linear
2803 memory and returns a pointer to the page frame. This function is similar to
2804 <tt/<ref id="em_map" name="em_map">/, but will not transfer data into the
2805 actual memory window in the assumption that the existing data is wrong or
2806 will get overwritten.
2807 <tag/Notes/<itemize>
2808 <item>Calling <tt/em_use/ will invalidate the memory window, so if you
2809 made any changes to the data in the window, call <tt/<ref id="em_commit"
2810 name="em_commit">/ first, or the changes are lost.
2811 <item>The function is only available as fastcall function, so it may only be
2812 used in presence of a prototype.
2813 <item>The function produces undefined results if no extended memory driver is
2816 <tag/Availability/cc65
2818 <ref id="em_commit" name="em_commit">,
2819 <ref id="em_load_driver" name="em_load_driver">,
2820 <ref id="em_map" name="em_map">
2826 <sect1>exit<label id="exit"><p>
2830 <tag/Function/Terminate the program.
2831 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
2832 <tag/Declaration/<tt/void __fastcall__ exit (int status);/
2833 <tag/Description/<tt/exit/ terminates the program. The argument specifies the
2834 return code of the program. Before termination, all files are closed, buffered
2835 output is written and any functions registered with <tt/<ref id="atexit"
2836 name="atexit">/ are called. Common values for status are <tt/EXIT_SUCCESS/ and
2837 <tt/EXIT_FAILURE/ which are also defined in <tt/<ref id="stdlib.h"
2839 <tag/Notes/<itemize>
2840 <item>The function is only available as fastcall function, so it may only
2841 be used in presence of a prototype.
2842 <item>It depends on the host machine if the program return code can be
2843 evaluated or is ignored.
2845 <tag/Availability/ISO 9899
2847 <ref id="abort" name="abort">,
2848 <ref id="exit" name="exit">
2854 <sect1>exec<label id="exec"><p>
2858 <tag/Function/Execute a program file.
2859 <tag/Header/<tt/<ref id="unistd.h" name="unistd.h">/
2860 <tag/Declaration/<tt/int __fastcall__ exec (const char* progname, const char* cmdline);/
2861 <tag/Description/<tt/exec/ replaces the currently running program by a new one.
2862 Calling <tt/exec()/ is identical to calling <tt/<ref id="exit" name="exit()">/,
2863 then loading and starting the program named in the first argument, passing
2864 the command line specified as second argument. Instead of an empty string,
2865 a <tt/NULL/ pointer may be passed as second parameter.
2866 On success, the function does not return. On failure, -1 is returned and
2867 <tt/errno/ contains an error code.
2868 <tag/Notes/<itemize>
2869 <item>The function is only available as fastcall function, so it may only
2870 be used in presence of a prototype.
2871 <item>On most platforms, the function needs to copy a small stub loader to
2872 some memory area outside the program space. This may collide with other
2873 programs. See the platform specific docs on this.
2874 <item>Because it is necessary to terminate the running program before the
2875 memory can be reused to load the new one, there is a high chance that the
2876 function may not be able to return on errors.
2877 <item>The command line is passed to the new program in the same way as cc65
2878 programs expect the command line. If the new program is not a cc65 generated
2879 program, it may not be able to read it.
2881 <tag/Availability/cc65
2883 <ref id="exit" name="exit">
2889 <sect1>fast<label id="fast"><p>
2893 <tag/Function/Switch the C128 into 2MHz mode.
2894 <tag/Header/<tt/<ref id="c128.h" name="c128.h">/
2895 <tag/Declaration/<tt/void fast (void);/
2896 <tag/Description/The function will switch the clock of the C128 to 2MHz. This
2897 will nearly double the speed compared to slow mode.
2898 <tag/Notes/<itemize>
2899 <item>The function is specific to the C128.
2900 <item>2MHz clock will not work in 40 column mode.
2902 <tag/Availability/C128
2904 <ref id="slow" name="slow">,
2905 <ref id="toggle_videomode" name="toggle_videomode">,
2906 <ref id="videomode" name="videomode">
2912 <sect1>feof<label id="feof"><p>
2916 <tag/Function/Return the end-of-file indicator of a stream.
2917 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
2918 <tag/Declaration/<tt/int __fastcall__ feof (FILE* f);/
2919 <tag/Description/<tt/feof/ tests the end-of-file indicator ofthe stream
2920 <tt/f/, and returns a non zero value if it is set.
2921 <tag/Notes/<itemize>
2922 <item>The indicator is set only after a read past the end of a file is
2924 <item>The function is only available as fastcall function, so it may only be
2925 used in presence of a prototype.
2927 <tag/Availability/ISO 9899
2929 <ref id="feof" name="clearerr">,
2930 <ref id="ferror" name="ferror">
2936 <sect1>ferror<label id="ferror"><p>
2940 <tag/Function/Return the error indicator of a stream.
2941 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
2942 <tag/Declaration/<tt/int __fastcall__ ferror (FILE* f);/
2943 <tag/Description/<tt/ferror/ tests the error indicator of the stream
2944 <tt/f/, and returns a non zero value if it is set.
2945 <tag/Notes/<itemize>
2946 <item>The function is only available as fastcall function, so it may only be
2947 used in presence of a prototype.
2949 <tag/Availability/ISO 9899
2951 <ref id="feof" name="clearerr">,
2952 <ref id="ferror" name="feof">
2958 <sect1>fileno<label id="fileno"><p>
2962 <tag/Function/Return the file handle used by a stream.
2963 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
2964 <tag/Declaration/<tt/int __fastcall__ fileno (FILE* f);/
2965 <tag/Description/The <tt/fileno/ function returns the file handle used
2966 internally by a C stream. This file handle (an integer) can be used as a
2967 handle for the POSIX input/output functions.
2968 <tag/Notes/<itemize>
2969 <item>The function is only available as fastcall function, so it may only be
2970 used in presence of a prototype.
2971 <item>Mixing C file I/O functions and POSIX file I/O functions for the same
2972 file may have unpredictable results.
2974 <tag/Availability/POSIX 1003.1
2976 <ref id="creat" name="creat">,
2977 <ref id="open" name="open"> <!-- , -->
2978 <!-- <ref id="read" name="read">, -->
2979 <!-- <ref id="write" name="write"> -->
2985 <sect1>free<label id="free"><p>
2989 <tag/Function/Free a block of dynamic memory.
2990 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
2991 <tag/Declaration/<tt/void __fastcall__ free (void* block);/
2992 <tag/Description/Free a block of dynamic memory previously allocated with
2993 <tt/<ref id="malloc" name="malloc">/, <tt/<ref id="calloc" name="calloc">/
2994 or <tt/<ref id="realloc" name="realloc">/. As an exception, if the passed
2995 pointer is <tt/NULL/, no action is performed.
2996 <tag/Notes/<itemize>
2997 <item>Passing an already free'd block to <tt/free/ again will cause undefined
2998 behaviour and may crash your program.
2999 <item>The function is only available as fastcall function, so it may only
3000 be used in presence of a prototype.
3002 <tag/Availability/ISO 9899
3004 <ref id="_heapadd" name="_heapadd">,
3005 <ref id="_heapblocksize" name="_heapblocksize">,
3006 <ref id="_heapmaxavail" name="_heapmaxavail">,
3007 <ref id="_heapmemavail" name="_heapmemavail">,
3008 <ref id="calloc" name="calloc">,
3009 <ref id="malloc" name="malloc">,
3010 <ref id="realloc" name="realloc">
3016 <sect1>get_ostype<label id="get_ostype"><p>
3020 <tag/Function/The function returns the operating system, the program runs on.
3021 <tag/Header/<tt/<ref id="apple2.h" name="apple2.h">,
3022 <ref id="atari.h" name="atari.h">, <ref id="c64.h" name="c64.h">/
3023 <tag/Declaration/<tt/unsigned char get_ostype (void);/
3024 <tag/Description/<tt/get_ostype/ is machine dependent and does not exist for
3025 all supported targets. If it exists, it returns a number that identifies the
3026 operating system or machine type, the program runs on. The machine dependent
3027 header files define constants that can be used to check the return code.
3028 <tag/Notes/<itemize>
3029 <item>The function does not exist on all platforms.
3030 <item>The return codes are platform dependent.
3032 <tag/Availability/cc65 (not all platforms)
3038 <sect1>getcpu<label id="getcpu"><p>
3042 <tag/Function/Determine on which CPU the program is running.
3043 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
3044 <tag/Declaration/<tt/unsigned char getcpu (void);/
3045 <tag/Description/The function checks on which CPU the code is running. It
3046 returns one of the constants<itemize>
3048 <item><tt/CPU_65C02/
3049 <item><tt/CPU_65816/
3051 <tag/Notes/<itemize>
3052 <item>Other, more exotic CPU types are not disinguished.
3054 <tag/Availability/cc65
3060 <sect1>getenv<label id="getenv"><p>
3064 <tag/Function/Return a value from the environment.
3065 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
3066 <tag/Declaration/<tt/char* __fastcall__ getenv (const char* name);/
3067 <tag/Description/The function searches the environment for an entry that
3068 matches <tt/name/ and returns its value. The environment consists of a list
3069 of strings in the form <tt/name=value/. If there is no match, <tt/getenv/
3071 <tag/Notes/<itemize>
3072 <item>What exactly is stored in the environment depends on the machine the
3073 program is running on.
3074 <item>The function is only available as fastcall function, so it may only
3075 be used in presence of a prototype.
3077 <tag/Availability/ISO 9899
3083 <sect1>getopt<label id="getopt"><p>
3087 <tag/Function/Parse command line options.
3088 <tag/Header/<tt/<ref id="unistd.h" name="unistd.h">/
3089 <tag/Declaration/<tt/int __fastcall__ getopt (int argc, char* const* argv,
3090 const char* optstring);/
3091 <tag/Description/The function parses command line arguments, <tt/argc/ and
3092 <tt/argv/ are the argument count and array passed to <tt/main/. <tt/optstring/
3093 is a string that contains command line option characters. If a character in
3094 <tt/optstring/ is followed by a colon, the option requires an argument. An
3095 option on the command line is recognized if it is one of the option characters
3097 <tt/getopt/ must be called repeatedly. It will return each option character
3098 found on the command line and <tt/EOF/ (-1) if there is no other option. An
3099 option argument is placed in <tt/optarg/, the index of the next element on the
3100 command line to be processed is placed in <tt/optind/.
3101 <tag/Notes/<itemize>
3102 <item>The implementation will not reorder options. A non option on the command
3103 line will terminate option processing. All remaining arguments are not
3104 recognized as options, even if the start with a '-' character.
3105 <item>The function is only available as fastcall function, so it may only
3106 be used in presence of a prototype.
3108 <tag/Availability/POSIX.2
3114 <sect1>gotox<label id="gotox"><p>
3118 <tag/Function/Move the text mode cursor to a new X position.
3119 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
3120 <tag/Declaration/<tt/void __fastcall__ gotox (unsigned char x);/
3121 <tag/Description/The function moves the text mode cursor to the specified X
3122 position while leaving the Y position untouched. The leftmost position on the
3123 screen has the coordinate 0.
3124 <tag/Notes/<itemize>
3125 <item>The function is only available as fastcall function, so it may
3126 only be used in presence of a prototype.
3127 <item>Invalid values for the X position (out of screen coordinates) may
3128 lead to undefined behaviour.
3130 <tag/Availability/cc65
3132 <ref id="gotoy" name="gotoy">,
3133 <ref id="gotoxy" name="gotoxy">,
3134 <ref id="wherex" name="wherex">,
3135 <ref id="wherey" name="wherey">
3141 <sect1>gotoxy<label id="gotoxy"><p>
3145 <tag/Function/Move the text mode cursor to a new position.
3146 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
3147 <tag/Declaration/<tt/void __fastcall__ gotoxy (unsigned char x, unsigned char y);/
3148 <tag/Description/The function moves the text mode cursor to the specified
3149 position. The leftmost position on the screen has the X coordinate 0, the
3150 topmost line has the Y coordinate 0.
3151 <tag/Notes/<itemize>
3152 <item>The function is only available as fastcall function, so it may only be
3153 used in presence of a prototype.
3154 <item>Invalid values for any of both coordinates (out of screen positions) may
3155 lead to undefined behaviour.
3157 <tag/Availability/cc65
3159 <ref id="gotox" name="gotox">,
3160 <ref id="gotoy" name="gotoy">,
3161 <ref id="wherex" name="wherex">,
3162 <ref id="wherey" name="wherey">
3168 <sect1>gotoy<label id="gotoy"><p>
3172 <tag/Function/Move the text mode cursor to a new Y position.
3173 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
3174 <tag/Declaration/<tt/void __fastcall__ gotoy (unsigned char x);/
3175 <tag/Description/The function moves the text mode cursor to the specified Y
3176 position while leaving the X position untouched. The uppermost position on the
3177 screen has the coordinate 0.
3178 <tag/Notes/<itemize>
3179 <item>The function is only available as fastcall function, so it may
3180 only be used in presence of a prototype.
3181 <item>Invalid values for the Y position (out of screen coordinates) may lead
3182 to undefined behaviour.
3184 <tag/Availability/cc65
3186 <ref id="gotox" name="gotox">,
3187 <ref id="gotoxy" name="gotoxy">,
3188 <ref id="wherex" name="wherex">,
3189 <ref id="wherey" name="wherey">
3195 <sect1>isalnum<label id="isalnum"><p>
3199 <tag/Function/Check if a given character is a letter or digit.
3200 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
3201 <tag/Declaration/<tt/int __fastcall__ isalnum (int c);/
3202 <tag/Description/The function returns a non zero value if the given argument
3203 is a letter or digit. The return value is zero if the character is anything
3205 <tag/Notes/<itemize>
3206 <item>When compiling with <tt/-Os/ the function is actually a macro. The
3207 inline sequence generated by the macro will not work correctly for values
3208 outside the range 0..255. <em/Note:/ The constant <tt/EOF/ is not part of
3209 this range. The non inline function may be accessed by <tt/#undef/'ing
3211 <item>When compiling without <tt/-Os/, the function is only available as
3212 fastcall function, so it may only be used in presence of a prototype.
3214 <tag/Availability/ISO 9899
3216 <ref id="isalpha" name="isalpha">,
3217 <ref id="isascii" name="isascii">,
3218 <ref id="isblank" name="isblank">,
3219 <ref id="iscntrl" name="iscntrl">,
3220 <ref id="isdigit" name="isdigit">,
3221 <ref id="isgraph" name="isgraph">,
3222 <ref id="islower" name="islower">,
3223 <ref id="isprint" name="isprint">,
3224 <ref id="ispunct" name="ispunct">,
3225 <ref id="isspace" name="isspace">,
3226 <ref id="isupper" name="isupper">,
3227 <ref id="isxdigit" name="isxdigit">
3233 <sect1>isalpha<label id="isalpha"><p>
3237 <tag/Function/Check if a given character is a letter.
3238 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
3239 <tag/Declaration/<tt/int __fastcall__ isalpha (int c);/
3240 <tag/Description/The function returns a non zero value if the given argument
3241 is a letter. The return value is zero if the character is anything else.
3242 <tag/Notes/<itemize>
3243 <item>When compiling with <tt/-Os/ the function is actually a macro. The
3244 inline sequence generated by the macro will not work correctly for values
3245 outside the range 0..255. <em/Note:/ The constant <tt/EOF/ is not part of
3246 this range. The non inline function may be accessed by <tt/#undef/'ing the
3248 <item>When compiling without <tt/-Os/, the function is only available as
3249 fastcall function, so it may only be used in presence of a prototype.
3251 <tag/Availability/ISO 9899
3253 <ref id="isalnum" name="isalnum">,
3254 <ref id="isascii" name="isascii">,
3255 <ref id="isblank" name="isblank">,
3256 <ref id="iscntrl" name="iscntrl">,
3257 <ref id="isdigit" name="isdigit">,
3258 <ref id="isgraph" name="isgraph">,
3259 <ref id="islower" name="islower">,
3260 <ref id="isprint" name="isprint">,
3261 <ref id="ispunct" name="ispunct">,
3262 <ref id="isspace" name="isspace">,
3263 <ref id="isupper" name="isupper">,
3264 <ref id="isxdigit" name="isxdigit">
3270 <sect1>isascii<label id="isascii"><p>
3274 <tag/Function/Check if a given character is in the ASCII (0..127) range.
3275 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
3276 <tag/Declaration/<tt/int __fastcall__ isascii (int c);/
3277 <tag/Description/The function returns a non zero value if the given argument
3278 is in the range 0..127 (the range of valid ASCII characters) and zero if not.
3279 <tag/Notes/<itemize>
3280 <item>When compiling with <tt/-Os/ the function is actually a macro. The
3281 inline sequence generated by the macro will not work correctly for values
3282 outside the range 0..255. <em/Note:/ The constant <tt/EOF/ is not part of
3283 this range. The non inline function may be accessed by <tt/#undef/'ing the
3285 <item>When compiling without <tt/-Os/, the function is only available as
3286 fastcall function, so it may only be used in presence of a prototype.
3288 <tag/Availability/ISO 9899
3290 <ref id="isalnum" name="isalnum">,
3291 <ref id="isalpha" name="isalpha">,
3292 <ref id="isblank" name="isblank">,
3293 <ref id="iscntrl" name="iscntrl">,
3294 <ref id="isdigit" name="isdigit">,
3295 <ref id="isgraph" name="isgraph">,
3296 <ref id="islower" name="islower">,
3297 <ref id="isprint" name="isprint">,
3298 <ref id="ispunct" name="ispunct">,
3299 <ref id="isspace" name="isspace">,
3300 <ref id="isupper" name="isupper">,
3301 <ref id="isxdigit" name="isxdigit">
3307 <sect1>isblank<label id="isblank"><p>
3311 <tag/Function/Check if a given character is a space or tab.
3312 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
3313 <tag/Declaration/<tt/int __fastcall__ isblank (int c);/
3314 <tag/Description/The function returns a non zero value if the given argument
3315 is a space or tab character. The return value is zero if the character is
3317 <tag/Notes/<itemize>
3318 <item>When compiling with <tt/-Os/ the function is actually a macro. The
3319 inline sequence generated by the macro will not work correctly for values
3320 outside the range 0..255. <em/Note:/ The constant <tt/EOF/ is not part of
3321 this range. The non inline function may be accessed by <tt/#undef/'ing the
3323 <item>When compiling without <tt/-Os/, the function is only available as
3324 fastcall function, so it may only be used in presence of a prototype.
3326 <tag/Availability/ISO 9899
3328 <ref id="isalnum" name="isalnum">,
3329 <ref id="isalpha" name="isalpha">,
3330 <ref id="isascii" name="isascii">,
3331 <ref id="iscntrl" name="iscntrl">,
3332 <ref id="isdigit" name="isdigit">,
3333 <ref id="isgraph" name="isgraph">,
3334 <ref id="islower" name="islower">,
3335 <ref id="isprint" name="isprint">,
3336 <ref id="ispunct" name="ispunct">,
3337 <ref id="isspace" name="isspace">,
3338 <ref id="isupper" name="isupper">,
3339 <ref id="isxdigit" name="isxdigit">
3345 <sect1>iscntrl<label id="iscntrl"><p>
3349 <tag/Function/Check if a given character is a control character.
3350 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
3351 <tag/Declaration/<tt/int __fastcall__ iscntrl (int c);/
3352 <tag/Description/The function returns a non zero value if the given argument
3353 is a control character. The return value is zero if the character is anything
3355 <tag/Notes/<itemize>
3356 <item>When compiling with <tt/-Os/ the function is actually a macro. The
3357 inline sequence generated by the macro will not work correctly for values
3358 outside the range 0..255. <em/Note:/ The constant <tt/EOF/ is not part of
3359 this range. The non inline function may be accessed by <tt/#undef/'ing the
3361 <item>When compiling without <tt/-Os/, the function is only available as
3362 fastcall function, so it may only be used in presence of a prototype.
3364 <tag/Availability/ISO 9899
3366 <ref id="isalnum" name="isalnum">,
3367 <ref id="isalpha" name="isalpha">,
3368 <ref id="isascii" name="isascii">,
3369 <ref id="isblank" name="isblank">,
3370 <ref id="isdigit" name="isdigit">,
3371 <ref id="isgraph" name="isgraph">,
3372 <ref id="islower" name="islower">,
3373 <ref id="isprint" name="isprint">,
3374 <ref id="ispunct" name="ispunct">,
3375 <ref id="isspace" name="isspace">,
3376 <ref id="isupper" name="isupper">,
3377 <ref id="isxdigit" name="isxdigit">
3383 <sect1>isdigit<label id="isdigit"><p>
3387 <tag/Function/Check if a given character is a digit.
3388 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
3389 <tag/Declaration/<tt/int __fastcall__ isdigit (int c);/
3390 <tag/Description/The function returns a non zero value if the given argument
3391 is a digit. The return value is zero if the character is anything else.
3392 <tag/Notes/<itemize>
3393 <item>When compiling with <tt/-Os/ the function is actually a macro. The
3394 inline sequence generated by the macro will not work correctly for values
3395 outside the range 0..255. <em/Note:/ The constant <tt/EOF/ is not part of
3396 this range. The non inline function may be accessed by <tt/#undef/'ing the
3398 <item>When compiling without <tt/-Os/, the function is only available as
3399 fastcall function, so it may only be used in presence of a prototype.
3401 <tag/Availability/ISO 9899
3403 <ref id="isalnum" name="isalnum">,
3404 <ref id="isalpha" name="isalpha">,
3405 <ref id="isascii" name="isascii">,
3406 <ref id="isblank" name="isblank">,
3407 <ref id="iscntrl" name="iscntrl">,
3408 <ref id="isgraph" name="isgraph">,
3409 <ref id="islower" name="islower">,
3410 <ref id="isprint" name="isprint">,
3411 <ref id="ispunct" name="ispunct">,
3412 <ref id="isspace" name="isspace">,
3413 <ref id="isupper" name="isupper">,
3414 <ref id="isxdigit" name="isxdigit">
3420 <sect1>isgraph<label id="isgraph"><p>
3424 <tag/Function/Check if a given character is a printable character (except
3426 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
3427 <tag/Declaration/<tt/int __fastcall__ isgraph (int c);/
3428 <tag/Description/The function returns a non zero value if the given argument
3429 is a printable character with the exception of space. The return value is zero
3430 if the character is anything else.
3431 <tag/Notes/<itemize>
3432 <item>When compiling with <tt/-Os/ the function is actually a macro. The
3433 inline sequence generated by the macro will not work correctly for values
3434 outside the range 0..255. <em/Note:/ The constant <tt/EOF/ is not part of
3435 this range. The non inline function may be accessed by <tt/#undef/'ing the
3437 <item>When compiling without <tt/-Os/, the function is only available as
3438 fastcall function, so it may only be used in presence of a prototype.
3440 <tag/Availability/ISO 9899
3442 <ref id="isalnum" name="isalnum">,
3443 <ref id="isalpha" name="isalpha">,
3444 <ref id="isascii" name="isascii">,
3445 <ref id="isblank" name="isblank">,
3446 <ref id="iscntrl" name="iscntrl">,
3447 <ref id="isdigit" name="isdigit">,
3448 <ref id="islower" name="islower">,
3449 <ref id="isprint" name="isprint">,
3450 <ref id="ispunct" name="ispunct">,
3451 <ref id="isspace" name="isspace">,
3452 <ref id="isupper" name="isupper">,
3453 <ref id="isxdigit" name="isxdigit">
3459 <sect1>islower<label id="islower"><p>
3463 <tag/Function/Check if a given character is a lower case letter.
3464 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
3465 <tag/Declaration/<tt/int __fastcall__ islower (int c);/
3466 <tag/Description/The function returns a non zero value if the given argument
3467 is a lower case letter. The return value is zero if the character is anything
3469 <tag/Notes/<itemize>
3470 <item>When compiling with <tt/-Os/ the function is actually a macro. The
3471 inline sequence generated by the macro will not work correctly for values
3472 outside the range 0..255. <em/Note:/ The constant <tt/EOF/ is not part of
3473 this range. The non inline function may be accessed by <tt/#undef/'ing the
3475 <item>When compiling without <tt/-Os/, the function is only available as
3476 fastcall function, so it may only be used in presence of a prototype.
3478 <tag/Availability/ISO 9899
3480 <ref id="isalnum" name="isalnum">,
3481 <ref id="isalpha" name="isalpha">,
3482 <ref id="isascii" name="isascii">,
3483 <ref id="isblank" name="isblank">,
3484 <ref id="iscntrl" name="iscntrl">,
3485 <ref id="isdigit" name="isdigit">,
3486 <ref id="isgraph" name="isgraph">,
3487 <ref id="isprint" name="isprint">,
3488 <ref id="ispunct" name="ispunct">,
3489 <ref id="isspace" name="isspace">,
3490 <ref id="isupper" name="isupper">,
3491 <ref id="isxdigit" name="isxdigit">
3497 <sect1>isprint<label id="isprint"><p>
3501 <tag/Function/Check if a given character is a printable character.
3502 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
3503 <tag/Declaration/<tt/int __fastcall__ isprint (int c);/
3504 <tag/Description/The function returns a non zero value if the given argument
3505 is a printable character (this includes the space character). The return value
3506 is zero if the character is anything else.
3507 <tag/Notes/<itemize>
3508 <item>When compiling with <tt/-Os/ the function is actually a macro. The
3509 inline sequence generated by the macro will not work correctly for values
3510 outside the range 0..255. <em/Note:/ The constant <tt/EOF/ is not part of
3511 this range. The non inline function may be accessed by <tt/#undef/'ing the
3513 <item>When compiling without <tt/-Os/, the function is only available as
3514 fastcall function, so it may only be used in presence of a prototype.
3516 <tag/Availability/ISO 9899
3518 <ref id="isalnum" name="isalnum">,
3519 <ref id="isalpha" name="isalpha">,
3520 <ref id="isascii" name="isascii">,
3521 <ref id="isblank" name="isblank">,
3522 <ref id="iscntrl" name="iscntrl">,
3523 <ref id="isdigit" name="isdigit">,
3524 <ref id="isgraph" name="isgraph">,
3525 <ref id="islower" name="islower">,
3526 <ref id="ispunct" name="ispunct">,
3527 <ref id="isspace" name="isspace">,
3528 <ref id="isupper" name="isupper">,
3529 <ref id="isxdigit" name="isxdigit">
3535 <sect1>ispunct<label id="ispunct"><p>
3539 <tag/Function/Check if a given character is a printable character but not a
3540 space or an alphanumeric character.
3541 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
3542 <tag/Declaration/<tt/int __fastcall__ ispunct (int c);/
3543 <tag/Description/The function returns a non zero value if the given argument
3544 is a printable character, but not a space or anything alphanumeric. The return
3545 value is zero if the character is anything else.
3546 <tag/Notes/<itemize>
3547 <item>When compiling with <tt/-Os/ the function is actually a macro. The
3548 inline sequence generated by the macro will not work correctly for values
3549 outside the range 0..255. <em/Note:/ The constant <tt/EOF/ is not part of
3550 this range. The non inline function may be accessed by <tt/#undef/'ing the
3552 <item>When compiling without <tt/-Os/, the function is only available as
3553 fastcall function, so it may only be used in presence of a prototype.
3555 <tag/Availability/ISO 9899
3557 <ref id="isalnum" name="isalnum">,
3558 <ref id="isalpha" name="isalpha">,
3559 <ref id="isascii" name="isascii">,
3560 <ref id="isblank" name="isblank">,
3561 <ref id="iscntrl" name="iscntrl">,
3562 <ref id="isdigit" name="isdigit">,
3563 <ref id="isgraph" name="isgraph">,
3564 <ref id="islower" name="islower">,
3565 <ref id="isprint" name="isprint">,
3566 <ref id="isspace" name="isspace">,
3567 <ref id="isupper" name="isupper">,
3568 <ref id="isxdigit" name="isxdigit">
3574 <sect1>isspace<label id="isspace"><p>
3578 <tag/Function/Check if a given character is a a white-space character.
3579 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
3580 <tag/Declaration/<tt/int __fastcall__ isspace (int c);/
3581 <tag/Description/The function returns a non zero value if the given argument
3582 is a white space character. The return value is zero if the character is
3583 anything else. The standard white space characters are: space, formfeed ('\f'),
3584 newline ('\n'), carriage return ('\r'), horizontal tab ('\t'), and vertical tab
3586 <tag/Notes/<itemize>
3587 <item>When compiling with <tt/-Os/ the function is actually a macro. The
3588 inline sequence generated by the macro will not work correctly for values
3589 outside the range 0..255. <em/Note:/ The constant <tt/EOF/ is not part of
3590 this range. The non inline function may be accessed by <tt/#undef/'ing the
3592 <item>When compiling without <tt/-Os/, the function is only available as
3593 fastcall function, so it may only be used in presence of a prototype.
3595 <tag/Availability/ISO 9899
3597 <ref id="isalnum" name="isalnum">,
3598 <ref id="isalpha" name="isalpha">,
3599 <ref id="isascii" name="isascii">,
3600 <ref id="isblank" name="isblank">,
3601 <ref id="iscntrl" name="iscntrl">,
3602 <ref id="isdigit" name="isdigit">,
3603 <ref id="isgraph" name="isgraph">,
3604 <ref id="islower" name="islower">,
3605 <ref id="isprint" name="isprint">,
3606 <ref id="ispunct" name="ispunct">,
3607 <ref id="isupper" name="isupper">,
3608 <ref id="isxdigit" name="isxdigit">
3614 <sect1>isupper<label id="isupper"><p>
3618 <tag/Function/Check if a given character is an upper case letter.
3619 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
3620 <tag/Declaration/<tt/int __fastcall__ isupper (int c);/
3621 <tag/Description/The function returns a non zero value if the given argument
3622 is an upper case letter. The return value is zero if the character is anything
3624 <tag/Notes/<itemize>
3625 <item>When compiling with <tt/-Os/ the function is actually a macro. The
3626 inline sequence generated by the macro will not work correctly for values
3627 outside the range 0..255. <em/Note:/ The constant <tt/EOF/ is not part of
3628 this range. The non inline function may be accessed by <tt/#undef/'ing the
3630 <item>When compiling without <tt/-Os/, the function is only available as
3631 fastcall function, so it may only be used in presence of a prototype.
3633 <tag/Availability/ISO 9899
3635 <ref id="isalnum" name="isalnum">,
3636 <ref id="isalpha" name="isalpha">,
3637 <ref id="isascii" name="isascii">,
3638 <ref id="isblank" name="isblank">,
3639 <ref id="iscntrl" name="iscntrl">,
3640 <ref id="isdigit" name="isdigit">,
3641 <ref id="isgraph" name="isgraph">,
3642 <ref id="islower" name="islower">,
3643 <ref id="isprint" name="isprint">,
3644 <ref id="ispunct" name="ispunct">,
3645 <ref id="isspace" name="isspace">,
3646 <ref id="isxdigit" name="isxdigit">
3652 <sect1>isxdigit<label id="isxdigit"><p>
3656 <tag/Function/Check if a given character is a hexadecimal digit.
3657 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
3658 <tag/Declaration/<tt/int __fastcall__ isxdigit (int c);/
3659 <tag/Description/The function returns a non zero value if the given argument
3660 is a hexadecimal digit (0..9, a..f and A..F). The return value is zero if the
3661 character is anything else.
3662 <tag/Notes/<itemize>
3663 <item>When compiling with <tt/-Os/ the function is actually a macro. The
3664 inline sequence generated by the macro will not work correctly for values
3665 outside the range 0..255. <em/Note:/ The constant <tt/EOF/ is not part of
3666 this range. The non inline function may be accessed by <tt/#undef/'ing the
3668 <item>When compiling without <tt/-Os/, the function is only available as
3669 fastcall function, so it may only be used in presence of a prototype.
3671 <tag/Availability/ISO 9899
3673 <ref id="isalnum" name="isalnum">,
3674 <ref id="isalpha" name="isalpha">,
3675 <ref id="isascii" name="isascii">,
3676 <ref id="isblank" name="isblank">,
3677 <ref id="iscntrl" name="iscntrl">,
3678 <ref id="isdigit" name="isdigit">,
3679 <ref id="isgraph" name="isgraph">,
3680 <ref id="islower" name="islower">,
3681 <ref id="isprint" name="isprint">,
3682 <ref id="ispunct" name="ispunct">,
3683 <ref id="isspace" name="isspace">,
3684 <ref id="isupper" name="isupper">
3690 <sect1>itoa<label id="itoa"><p>
3694 <tag/Function/Convert an integer into a string.
3695 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
3696 <tag/Declaration/<tt/char* __fastcall__ itoa (int val, char* buf, int radix);/
3697 <tag/Description/<tt/itoa/ converts the integer <tt/val/ into a string using
3698 <tt/radix/ as the base.
3699 <tag/Notes/<itemize>
3700 <item>There are no provisions to prevent a buffer overflow.
3701 <item>If <tt/val/ contains <tt/INT_MIN/, the behaviour is undefined.
3702 <item>The function is non standard, so it is not available in strict ANSI mode.
3703 You should probably use <tt/sprintf/ instead.
3704 <item>The function is only available as fastcall function, so it may only be
3705 used in presence of a prototype.
3707 <tag/Availability/cc65
3709 <ref id="atoi" name="atoi">,
3710 <ref id="atol" name="atol">,
3711 <ref id="ltoa" name="ltoa">,
3712 <ref id="ultoa" name="ultoa">,
3713 <ref id="utoa" name="utoa">
3719 <sect1>joy_count<label id="joy_count"><p>
3723 <tag/Function/Return the number of joysticks supported by the current driver.
3724 <tag/Header/<tt/<ref id="joystick.h" name="joystick.h">/
3725 <tag/Declaration/<tt/unsigned char joy_count (void);/
3726 <tag/Description/The function returns a the number of joysticks supported
3727 by the current joystick driver.
3728 <tag/Notes/<itemize>
3729 <item>A joystick driver must be loaded using <ref id="joy_load_driver"
3730 name="joy_load_driver"> before calling this function.
3731 <item>The function returns the number of joysticks supported by the driver.
3732 There's no way to check for the number of actually connected joysticks.
3734 <tag/Availability/cc65
3736 <ref id="joy_load_driver" name="joy_load_driver">,
3737 <ref id="joy_read" name="joy_read">
3743 <sect1>joy_install<label id="joy_install"><p>
3747 <tag/Function/Install an already loaded driver and return an error code.
3748 <tag/Header/<tt/<ref id="joystick.h" name="joystick.h">/
3749 <tag/Declaration/<tt/unsigned char __fastcall__ joy_install (void* driver);/
3750 <tag/Description/The function installs a driver that was already loaded into
3751 memory (or linked statically to the program). It returns an error code
3752 (<tt/JOY_ERR_OK/ in case of success).
3753 <tag/Notes/<itemize>
3754 <item>The function is only available as fastcall function, so it may only be
3755 used in presence of a prototype.
3757 <tag/Availability/cc65
3759 <ref id="joy_load_driver" name="joy_load_driver">,
3760 <ref id="joy_uninstall" name="joy_uninstall">,
3761 <ref id="joy_unload" name="joy_unload">
3767 <sect1>joy_load_driver<label id="joy_load_driver"><p>
3771 <tag/Function/Load a driver from disk and install it.
3772 <tag/Header/<tt/<ref id="joystick.h" name="joystick.h">/
3773 <tag/Declaration/<tt/unsigned char __fastcall__ joy_load_driver (const char* driver);/
3774 <tag/Description/The function loads a driver with the given name from disk
3775 and installs it. An error code is returned, which is <tt/JOY_ERR_OK/ if the
3776 driver was successfully loaded and installed.
3777 <tag/Notes/<itemize>
3778 <item>The function is only available as fastcall function, so it may only be
3779 used in presence of a prototype.
3781 <tag/Availability/cc65
3783 <ref id="joy_install" name="joy_install">,
3784 <ref id="joy_uninstall" name="joy_uninstall">,
3785 <ref id="joy_unload" name="joy_unload">
3791 <sect1>joy_read<label id="joy_read"><p>
3795 <tag/Function/Read the status of a joystick.
3796 <tag/Header/<tt/<ref id="joystick.h" name="joystick.h">/
3797 <tag/Declaration/<tt/unsigned char __fastcall__ joy_read (unsigned char joystick);/
3798 <tag/Description/The function reads the status bits for a joystick. The number
3799 of the joystick is passed as parameter. The result may be examined by using one
3800 of the <tt/JOY_xxx/ macros from <ref id="joystick.h" name="joystick.h">.
3801 <tag/Notes/<itemize>
3802 <item>A joystick driver must be loaded using <ref id="joy_load_driver"
3803 name="joy_load_driver"> before calling this function.
3804 <item>The function is only available as fastcall function, so it may only be
3805 used in presence of a prototype.
3807 <tag/Availability/cc65
3809 <ref id="joy_count" name="joy_count">,
3810 <ref id="joy_load_driver" name="joy_load_driver">,
3811 <ref id="joy_unload" name="joy_unload">
3817 <sect1>joy_uninstall<label id="joy_uninstall"><p>
3821 <tag/Function/Uninstall the current joystick driver.
3822 <tag/Header/<tt/<ref id="joystick.h" name="joystick.h">/
3823 <tag/Declaration/<tt/unsigned char joy_uninstall (void);/
3824 <tag/Description/The function uninstalls the currently installed joystick
3825 driver. It does not remove the driver from memory. The function returns an
3826 error code, which is <tt/JOY_ERR_OK/ if the driver was successfully uninstalled.
3827 <tag/Notes/<itemize>
3828 <item>A joystick driver must be installed using <ref id="joy_install"
3829 name="joy_install"> before calling this function.
3831 <tag/Availability/cc65
3833 <ref id="joy_install" name="joy_install">,
3834 <ref id="joy_load_driver" name="joy_load_driver">,
3835 <ref id="joy_unload" name="joy_unload">
3841 <sect1>joy_unload<label id="joy_unload"><p>
3845 <tag/Function/Uninstall, then unload the current joystick driver.
3846 <tag/Header/<tt/<ref id="joystick.h" name="joystick.h">/
3847 <tag/Declaration/<tt/unsigned char joy_unload (void);/
3848 <tag/Description/The function uninstalls the currently installed joystick
3849 driver and removes it from memory. An error code is returned, which is
3850 <tt/JOY_ERR_OK/ if the driver was successfully uninstalled.
3851 <tag/Notes/<itemize>
3852 <item>A joystick driver must be loaded using <ref id="joy_load_driver"
3853 name="joy_load_driver"> before calling this function.
3855 <tag/Availability/cc65
3857 <ref id="joy_load_driver" name="joy_load_driver">
3863 <sect1>kbhit<label id="kbhit"><p>
3867 <tag/Function/Check if there's a key waiting in the keyboard buffer.
3868 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
3869 <tag/Declaration/<tt/unsigned char kbhit (void);/
3870 <tag/Description/The function returns a value of zero if there is no character
3871 waiting to be read from the keyboard. It returns non zero otherwise.
3872 <tag/Notes/<itemize>
3873 <item>If the system does not support a keyboard buffer (most systems
3874 do), the function is rather useless.
3876 <tag/Availability/cc65
3878 <ref id="cgetc" name="cgetc">,
3879 <ref id="cursor" name="cursor">
3885 <sect1>labs<label id="labs"><p>
3889 <tag/Function/Returns the absolute value of a long integer.
3890 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
3891 <tag/Declaration/<tt/long __fastcall__ labs (long v);/
3892 <tag/Description/<tt/labs/ returns the absolute value of the argument passed to
3894 <tag/Notes/<itemize>
3895 <item>The return value is undefined if <tt/LONG_MIN/ is passed to the function.
3896 <item>The function is only available as fastcall function, so it may only be
3897 used in presence of a prototype.
3899 <tag/Availability/ISO 9899
3901 <ref id="abs" name="abs">
3907 <sect1>ltoa<label id="ltoa"><p>
3911 <tag/Function/Convert a long integer into a string.
3912 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
3913 <tag/Declaration/<tt/char* __fastcall__ ltoa (long val, char* buf, int radix);/
3914 <tag/Description/<tt/itoa/ converts the long integer <tt/val/ into a string
3915 using <tt/radix/ as the base.
3916 <tag/Notes/<itemize>
3917 <item>There are no provisions to prevent a buffer overflow.
3918 <item>If <tt/val/ contains <tt/LONG_MIN/, the behaviour is undefined.
3919 <item>The function is non standard, so it is not available in strict ANSI mode.
3920 You should probably use <tt/sprintf/ instead.
3921 <item>The function is only available as fastcall function, so it may only be
3922 used in presence of a prototype.
3924 <tag/Availability/cc65
3926 <ref id="atoi" name="atoi">,
3927 <ref id="atol" name="atol">,
3928 <ref id="itoa" name="itoa">,
3929 <ref id="ultoa" name="ultoa">,
3930 <ref id="utoa" name="utoa">
3936 <sect1>localeconv<label id="localeconv"><p>
3940 <tag/Function/Returns a pointer to the current locale structure.
3941 <tag/Header/<tt/<ref id="locale.h" name="locale.h">/
3942 <tag/Declaration/<tt/struct lconv* localeconv (void);/
3943 <tag/Description/<tt/localeconv/ returns a pointer to the current locale
3945 <tag/Notes/<itemize>
3946 <item>cc65 supports only the "C" locale, so even after setting a new locale
3947 using <tt/<ref id="setlocale" name="setlocale">/, the structure returned will
3950 <tag/Availability/ISO 9899
3952 <ref id="setlocale" name="setlocale">
3958 <sect1>longjmp<label id="longjmp"><p>
3962 <tag/Function/Non local goto.
3963 <tag/Header/<tt/<ref id="setjmp.h" name="setjmp.h">/
3964 <tag/Declaration/<tt/void __fastcall__ longjmp (jmp_buf buf, int retval);/
3965 <tag/Description/The <tt/longjmp/ function restores a program context from the
3966 data in <tt/buf/, which must have been set by a preceeding call to
3967 <tt/<ref id="setjmp" name="setjmp">/. Program execution continues as if the
3968 call to <tt/<ref id="setjmp" name="setjmp">/ has just returned the value
3970 <tag/Notes/<itemize>
3971 <item>If the parameter <tt/retval/ is zero, the function will behave as if it
3972 was called with a value of one.
3973 <item>The function is only available as fastcall function, so it may only
3974 be used in presence of a prototype.
3976 <tag/Availability/ISO 9899
3978 <ref id="setjmp" name="setjmp">
3984 <sect1>malloc<label id="malloc"><p>
3988 <tag/Function/Allocate dynamic memory.
3989 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
3990 <tag/Declaration/<tt/void* __fastcall__ malloc (size_t size);/
3991 <tag/Description/<tt/malloc/ allocates size bytes on the heap and returns a
3992 pointer to the allocated memory block. On error (not enough memory available),
3993 <tt/malloc/ returns <tt/NULL/.
3994 <tag/Notes/<itemize>
3995 <item>The function is only available as fastcall function, so it may only
3996 be used in presence of a prototype.
3998 <tag/Availability/ISO 9899
4000 <ref id="_heapadd" name="_heapadd">,
4001 <ref id="_heapblocksize" name="_heapblocksize">,
4002 <ref id="_heapmaxavail" name="_heapmaxavail">,
4003 <ref id="_heapmemavail" name="_heapmemavail">,
4004 <ref id="calloc" name="calloc">,
4005 <ref id="free" name="free">,
4006 <ref id="realloc" name="realloc">,
4007 <ref id="strdup" name="strdup">
4013 <sect1>memchr<label id="memchr"><p>
4017 <tag/Function/Search for a character in a block of raw memory.
4018 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4019 <tag/Declaration/<tt/void* __fastcall__ strchr (const void* mem, int c, size_t count);/
4020 <tag/Description/The <tt/memchr/ function locates the first occurrence of <tt/c/
4021 (converted to a char) in the block of raw memory string pointed to by <tt/mem/
4022 that is of size <tt/count/. Upon completion, the function returns a pointer to
4023 the character found, or a null pointer if the character was not found.
4024 <tag/Notes/<itemize>
4025 <item>The function is only available as fastcall function, so it may only
4026 be used in presence of a prototype.
4028 <tag/Availability/ISO 9899
4030 <ref id="strchr" name="strchr">
4036 <sect1>memcmp<label id="memcmp"><p>
4040 <tag/Function/Compare two memory areas.
4041 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4042 <tag/Declaration/<tt/int __fastcall__ memcmp (const void* p1, const void* p2, size_t count);/
4043 <tag/Description/<tt/memcmp/ compares <tt/count/ bytes from the memory area
4044 pointed to by <tt/p1/ into the memory area pointed to by <tt/p2/. It returns a value that is less than
4045 zero if <tt/p1/ is less than <tt/p2/, zero if <tt/p1/ is the same as <tt/p2/,
4046 and a value greater than zero if <tt/p1/ is greater than <tt/p2/.
4047 <tag/Notes/<itemize>
4048 <item>The function is only available as fastcall function, so it may only
4049 be used in presence of a prototype.
4051 <tag/Availability/ISO 9899
4053 <ref id="strcmp" name="strcmp">,
4054 <ref id="memmove" name="memmove">,
4055 <ref id="memset" name="memset">
4061 <sect1>memcpy<label id="memcpy"><p>
4065 <tag/Function/Copy a memory area.
4066 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4067 <tag/Declaration/<tt/void* __fastcall__ memcpy (void* dest, const void* src, size_t count);/
4068 <tag/Description/<tt/memcpy/ copies <tt/count/ bytes from the memory area
4069 pointed to by <tt/src/ into the memory area pointed to by <tt/dest/. It returns
4071 <tag/Notes/<itemize>
4072 <item>The result is undefined if the memory areas do overlap. Use
4073 <tt/<ref id="memmove" name="memmove">/ to copy overlapping memory areas.
4074 <item>The function is only available as fastcall function, so it may only
4075 be used in presence of a prototype.
4077 <tag/Availability/ISO 9899
4079 <ref id="_swap" name="_swap">,
4080 <ref id="memmove" name="memmove">,
4081 <ref id="memset" name="memset">
4087 <sect1>memmove<label id="memmove"><p>
4091 <tag/Function/Copy a memory area.
4092 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4093 <tag/Declaration/<tt/void* __fastcall__ memmove (void* dest, const void* src, size_t count);/
4094 <tag/Description/<tt/memmove/ copies <tt/count/ bytes from the memory area
4095 pointed to by <tt/src/ into the memory area pointed to by <tt/dest/. It returns
4097 <tag/Notes/<itemize>
4098 <item>While <tt/memmove/ allows the memory areas to overlap, it has some
4099 additional overhead compared to <tt/<ref id="memcpy" name="memcpy">/.
4100 <item>The function is only available as fastcall function, so it may only
4101 be used in presence of a prototype.
4103 <tag/Availability/ISO 9899
4105 <ref id="_swap" name="_swap">,
4106 <ref id="memcpy" name="memcpy">,
4107 <ref id="memset" name="memset">
4113 <sect1>memset<label id="memset"><p>
4117 <tag/Function/Fill a memory area.
4118 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4119 <tag/Declaration/<tt/void* __fastcall__ memset (void* p, int val, size_t count);/
4120 <tag/Description/<tt/memset/ fills the memory area pointed to by <tt/p/ with
4121 the value <tt/val/. The function returns <tt/p/.
4122 <tag/Notes/<itemize>
4123 <item>The function is only available as fastcall function, so it may only
4124 be used in presence of a prototype.
4126 <tag/Availability/ISO 9899
4128 <ref id="_swap" name="_swap">,
4129 <ref id="bzero" name="bzero">,
4130 <ref id="memcpy" name="memcpy">,
4131 <ref id="memmove" name="memmove">
4137 <sect1>mod_free<label id="mod_free"><p>
4141 <tag/Function/Free a relocatable module.
4142 <tag/Header/<tt/<ref id="modload.h" name="modload.h">/
4143 <tag/Declaration/<tt/void __fastcall__ mod_free (void* module);/
4144 <tag/Description/The function will free a module loaded into memory by use of
4145 the <tt/<ref id="mod_load" name="mod_load">/ function.
4146 <tag/Notes/<itemize>
4147 <item>The pointer passed as parameter is the pointer to the module memory,
4148 not the pointer to the control structure.
4149 <item>The function is available only as a fastcall function; so, it may be used
4150 only in the presence of a prototype.
4152 <tag/Availability/cc65
4154 <ref id="mod_load" name="mod_load">
4160 <sect1>mod_load<label id="mod_load"><p>
4164 <tag/Function/Load a relocatable module.
4165 <tag/Header/<tt/<ref id="modload.h" name="modload.h">/
4166 <tag/Declaration/<tt/unsigned char __fastcall__ mod_load (struct mod_ctrl* ctrl);/
4167 <tag/Description/The function will load a code module into memory and relocate
4168 it. The function will return an error code. If <tt/MLOAD_OK/ is returned, the
4169 outgoing fields in the passed <tt/mod_ctrl/ struct contain information about
4170 the module just loaded. Possible error codes are:
4172 <item><tt/MLOAD_OK/ - Module load successful
4173 <item><tt/MLOAD_ERR_READ/ - Read error
4174 <item><tt/MLOAD_ERR_HDR/ - Header error
4175 <item><tt/MLOAD_ERR_OS/ - Wrong operating system
4176 <item><tt/MLOAD_ERR_FMT/ - Data format error
4177 <item><tt/MLOAD_ERR_MEM/ - Not enough memory
4179 <tag/Notes/<itemize>
4180 <item>The <htmlurl url="ld65.html" name="ld65"> linker is needed to create
4181 relocatable o65 modules for use with this function.
4182 <item>The function is available only as a fastcall function; so, it may be used
4183 only in the presence of a prototype.
4185 <tag/Availability/cc65
4187 <ref id="mod_free" name="mod_free">
4193 <sect1>mouse_setbox<label id="mouse_setbox"><p>
4197 <tag/Function/Specify a bounding box for the mouse cursor.
4198 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
4199 <tag/Declaration/<tt/void __fastcall__ mouse_setbox (const struct mouse_box* box);/
4200 <tag/Description/The function allows to set a bounding box for mouse movement.
4201 <tag/Notes/<itemize>
4202 <item>The function does not check if the mouse cursor is currently within the
4203 given rectangle. Placing the mouse cursor within the bounding box is the
4204 responsibility of the programmer.
4205 <item>While the bounding box may be larger than the actual screen size, the
4206 standard mouse cursor draw routines may fail to set the cursor to coordinates
4207 outside of the screen area. Depending on the platform, you may have to supply
4208 your own mouse cursor routines.
4209 <item>The function is only available as fastcall function, so it may only be
4210 used in presence of a prototype.
4212 <tag/Availability/cc65
4214 <ref id="mouse_getbox" name="mouse_getbox">,
4215 <ref id="mouse_move" name="mouse_move">
4221 <sect1>mouse_getbox<label id="mouse_getbox"><p>
4225 <tag/Function/Return the current bounding box for the mouse cursor.
4226 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
4227 <tag/Declaration/<tt/void __fastcall__ mouse_getbox (struct mouse_box* box);/
4228 <tag/Description/The function queries the current bounding box for mouse
4230 <tag/Notes/<itemize>
4231 <item>The function is only available as fastcall function, so it may only be
4232 used in presence of a prototype.
4234 <tag/Availability/cc65
4236 <ref id="mouse_move" name="mouse_move">,
4237 <ref id="mouse_setbox" name="mouse_setbox">
4243 <sect1>mouse_buttons<label id="mouse_buttons"><p>
4247 <tag/Function/Return a bit mask encoding the state of the mouse buttons.
4248 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
4249 <tag/Declaration/<tt/unsigned char mouse_buttons (void);/
4250 <tag/Description/The function returns a bit mask that encodes the state of the
4251 mouse buttons. You may use the <tt/MOUSE_BTN_XXX/ flags to decode the function
4253 <tag/Availability/cc65
4255 <ref id="mouse_info" name="mouse_info">,
4256 <ref id="mouse_pos" name="mouse_pos">
4262 <sect1>mouse_geterrormsg<label id="mouse_geterrormsg"><p>
4266 <tag/Function/Return a readable error message for an error code.
4267 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
4268 <tag/Declaration/<tt/const char* __fastcall__ mouse_geterrormsg (unsigned char
4270 <tag/Description/The function returns an error message (in english) for the
4271 error code passed parameter.
4272 <tag/Notes/<itemize>
4273 <item>The function will return "Unknown error" for invalid error codes.
4274 <item>The function is only available as fastcall function, so it may only be
4275 used in presence of a prototype.
4277 <tag/Availability/cc65
4279 <ref id="mouse_load_driver" name="mouse_load_driver">,
4280 <ref id="mouse_uninstall" name="mouse_uninstall">,
4281 <ref id="mouse_unload" name="mouse_unload">
4287 <sect1>mouse_hide<label id="mouse_hide"><p>
4291 <tag/Function/Hide the mouse pointer.
4292 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
4293 <tag/Declaration/<tt/void mouse_hide (void);/
4294 <tag/Description/The function hides the mouse pointer. It manages a counter
4295 that is shared between <tt/<ref id="mouse_show" name="mouse_show">/ and
4296 <tt/mouse_hide/ so that every call call to <tt/mouse_hide/ must be followed by
4297 a call to <tt/<ref id="mouse_show" name="mouse_show">/ to make the mouse cursor
4299 <tag/Availability/cc65
4301 <ref id="mouse_show" name="mouse_show">
4307 <sect1>mouse_info<label id="mouse_info"><p>
4311 <tag/Function/Return the state of the mouse buttons and the position of the
4313 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
4314 <tag/Declaration/<tt/void __fastcall__ mouse_info (struct mouse_info* info);/
4315 <tag/Description/The function returns the state of the mouse buttons and the
4316 position of the mouse in the <tt/mouse_info/ structure passed as parameter.
4317 <tag/Notes/<itemize>
4318 <item>The <tt/mouse_info/ struct is a superset of the <tt/mouse_pos/ struct,
4319 so if you just need the mouse position, call <tt/<ref id="mouse_pos"
4320 name="mouse_pos">/ instead.
4321 <item>The function is only available as fastcall function, so it may only be
4322 used in presence of a prototype.
4324 <tag/Availability/cc65
4326 <ref id="mouse_buttons" name="mouse_buttons">,
4327 <ref id="mouse_pos" name="mouse_pos">
4333 <sect1>mouse_install<label id="mouse_install"><p>
4337 <tag/Function/Install an already loaded mouse driver.
4338 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
4339 <tag/Declaration/<tt/unsigned char __fastcall__ mouse_install (const struct
4340 mouse_callbacks* c, void* driver);/
4341 <tag/Description/The function installs an already loaded mouse driver and
4342 returns an error code. The <tt/mouse_callbacks/ structure passed as first
4343 parameter contains pointers to routines needed to move or hide/show the mouse
4344 pointer. Defaults for these routines are supplied by the library, so if you
4345 can live with these defaults (which are platform specific), just pass a
4346 pointer to <tt/mouse_def_callbacks/. The function may be used to install a
4347 driver linked statically to the program.
4348 <tag/Notes/<itemize>
4349 <item>Not all drivers are able to detect if the supported hardware is really
4351 <item>After installing a driver, the mouse cursor is hidden.
4352 <item>The function is only available as fastcall function, so it may only be
4353 used in presence of a prototype.
4355 <tag/Availability/cc65
4357 <ref id="mouse_load_driver" name="mouse_load_driver">,
4358 <ref id="mouse_uninstall" name="mouse_uninstall">,
4359 <ref id="mouse_unload" name="mouse_unload">
4365 <sect1>mouse_ioctl<label id="mouse_ioctl"><p>
4369 <tag/Function/Call the driver specific ioctl function.
4370 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
4371 <tag/Declaration/<tt/unsigned char __fastcall__ mouse_ioctl (unsigned char code, void* data);/
4372 <tag/Description/The function calls the IOCTL entry in the mouse driver,
4373 which is driver specific. The <tt/code/ parameter will choose between
4374 different IOCTL functions, and the <tt/data/ depends on code. The
4375 function returns an error code. The purpose of this function is to allow
4376 for driver specific extensions. See the documentation for a specific mouse
4377 driver for supported ioctl calls.
4378 <tag/Notes/<itemize>
4379 <item>Calling this function is non portable, because each driver may
4380 implement different ioctl calls (or none at all).
4381 <item>The function is only available as fastcall function, so it may only be
4382 used in presence of a prototype.
4384 <tag/Availability/cc65
4390 <sect1>mouse_load_driver<label id="mouse_load_driver"><p>
4394 <tag/Function/Load and initialize a mouse driver.
4395 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
4396 <tag/Declaration/<tt/unsigned char __fastcall__ mouse_load_driver (const struct
4397 mouse_callbacks* c, const char* driver);/
4398 <tag/Description/Load a mouse driver into memory and initialize it. The
4399 function returns an error code that tells if the call has been successful. The
4400 <tt/mouse_callbacks/ structure passed as first parameter contains pointers to
4401 routines needed to move or hide/show the mouse pointer. Defaults for these
4402 routines are supplied by the library, so if you can live with these defaults
4403 (which are platform specific), just pass a pointer to <tt/mouse_def_callbacks/.
4404 <tag/Notes/<itemize>
4405 <item>The driver is loaded by name, so currently you must know the type of
4406 mouse that should be supported. There is no autodetect capability.
4407 <item>Not all drivers are able to detect if the supported hardware is really
4409 <item>After installing a driver, the mouse cursor is hidden.
4410 <item>The function is only available as fastcall function, so it may only be
4411 used in presence of a prototype.
4413 <tag/Availability/cc65
4415 <ref id="mouse_install" name="mouse_install">,
4416 <ref id="mouse_uninstall" name="mouse_uninstall">,
4417 <ref id="mouse_unload" name="mouse_unload">
4423 <sect1>mouse_move<label id="mouse_move"><p>
4427 <tag/Function/Move the mouse cursor to a specific position.
4428 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
4429 <tag/Declaration/<tt/void __fastcall__ mouse_move (int x, int y);/
4430 <tag/Description/The function updates the mouse position. If the mouse cursor
4431 is visible, it is shown at the new position.
4432 <tag/Notes/<itemize>
4433 <item>The function does not check if the new position is within the bounding
4434 box specified with <tt/<ref id="mouse_setbox" name="mouse_setbox">/.
4435 <item>The function is only available as fastcall function, so it may only be
4436 used in presence of a prototype.
4438 <tag/Availability/cc65
4440 <ref id="mouse_getbox" name="mouse_getbox">,
4441 <ref id="mouse_setbox" name="mouse_setbox">
4447 <sect1>mouse_pos<label id="mouse_pos"><p>
4451 <tag/Function/Return the position of the mouse.
4452 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
4453 <tag/Declaration/<tt/void __fastcall__ mouse_pos (struct mouse_pos* pos);/
4454 <tag/Description/The function returns the position of the mouse in the
4455 <tt/mouse_pos/ structure passed as parameter.
4456 <tag/Notes/<itemize>
4457 <item>The <tt/mouse_pos/ struct is a subset of the <tt/mouse_info/ struct,
4458 so if you do also need the mouse buttons, call <tt/<ref id="mouse_info"
4459 name="mouse_info">/ instead.
4460 <item>The function is only available as fastcall function, so it may only be
4461 used in presence of a prototype.
4463 <tag/Availability/cc65
4465 <ref id="mouse_buttons" name="mouse_buttons">,
4466 <ref id="mouse_info" name="mouse_info">
4472 <sect1>mouse_show<label id="mouse_show"><p>
4476 <tag/Function/Show the mouse pointer.
4477 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
4478 <tag/Declaration/<tt/void mouse_show (void);/
4479 <tag/Description/The function shows the mouse pointer. It manages a counter
4480 that is shared between <tt/<ref id="mouse_hide" name="mouse_hide">/ and
4481 <tt/mouse_show/. The mouse cursor is visible if there was one more call to
4482 <tt/mouse_show/ than to <tt/<ref id="mouse_hide" name="mouse_hide">/.
4483 <tag/Availability/cc65
4485 <ref id="mouse_hide" name="mouse_hide">
4491 <sect1>mouse_uninstall<label id="mouse_uninstall"><p>
4495 <tag/Function/Uninstall an already loaded mouse driver.
4496 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
4497 <tag/Declaration/<tt/unsigned char mouse_uninstall (void);/
4498 <tag/Description/The function uninstalls an already loaded mouse driver but
4499 don't removes it from memory.
4500 <tag/Notes/<itemize>
4501 <item>If the driver has been loaded using <tt/<ref id="mouse_load_driver"
4502 name="mouse_load_driver">/, <tt/<ref id="mouse_unload" name="mouse_unload">/
4503 should be used instead of <tt/mouse_uninstall/ so the driver is also removed
4506 <tag/Availability/cc65
4508 <ref id="mouse_install" name="mouse_install">,
4509 <ref id="mouse_load_driver" name="mouse_load_driver">,
4510 <ref id="mouse_unload" name="mouse_unload">
4516 <sect1>mouse_unload<label id="mouse_unload"><p>
4520 <tag/Function/Unload a mouse driver.
4521 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
4522 <tag/Declaration/<tt/unsigned char mouse_unload (void);/
4523 <tag/Description/The function unloads a loaded mouse driver and frees all
4524 memory allocated for the driver.
4525 <tag/Notes/<itemize>
4526 <item>The function does nothing if no driver is loaded.
4528 <tag/Availability/cc65
4530 <ref id="mouse_install" name="mouse_install">,
4531 <ref id="mouse_load_driver" name="mouse_load_driver">,
4532 <ref id="mouse_uninstall" name="mouse_uninstall">
4538 <sect1>offsetof<label id="offsetof"><p>
4542 <tag/Function/Calculate the offset of a struct or union member.
4543 <tag/Header/<tt/<ref id="stddef.h" name="stddef.h">/
4544 <tag/Declaration/<tt/size_t offsetof (type, member);/
4545 <tag/Description/<tt/offsetof/ calculates the address offset of a <tt/struct/
4546 or <tt/union/ member.
4547 <tag/Notes/<itemize>
4548 <item>The function is actually a macro.
4550 <tag/Availability/ISO 9899
4556 <sect1>open<label id="open"><p>
4560 <tag/Function/Open and possibly create a file.
4561 <tag/Header/<tt/<ref id="fcntl.h" name="fcntl.h">/
4562 <tag/Declaration/<tt/int open (const char* name, int flags, ...);/
4563 <tag/Description/<tt/open/ opens a file and returns the file descriptor
4564 associated with it. On error, -1 is returned and an error code is stored in
4565 <tt/errno/. Several flags may be passed to <tt/open/ that change the behaviour.
4566 <tag/Notes/<itemize>
4567 <item>POSIX specifies an additional <tt/mode/ argument that may be passed to
4568 open, which is used as the permission mask when a new file is created. While
4569 cc65 allows to pass this argument, it is ignored.
4571 <tag/Availability/POSIX 1003.1
4573 <ref id="close" name="close">,
4574 <ref id="creat" name="creat">
4580 <sect1>opendir<label id="opendir"><p>
4584 <tag/Function/Open a directory.
4585 <tag/Header/<tt/<ref id="dirent.h" name="dirent.h">/
4586 <tag/Declaration/<tt/DIR* __fastcall__ opendir (const char* name);/
4587 <tag/Description/<tt/opendir/ opens a directory and returns the direcory
4588 descriptor associated with it. On error, NULL is returned and an error code is
4589 stored in <tt/errno/.
4590 <tag/Notes/<itemize>
4591 <item>The function is only available as fastcall function, so it may only
4592 be used in presence of a prototype.
4594 <tag/Availability/POSIX 1003.1
4596 <ref id="closedir" name="closedir">,
4597 <ref id="readdir" name="readdir">
4603 <sect1>peekbsys<label id="peekbsys"><p>
4607 <tag/Function/Read one byte from a location in the system bank.
4608 <tag/Header/<tt/<ref id="cbm610.h" name="cbm610.h">/,
4609 <tt/<ref id="cbm510.h" name="cbm510.h">/
4610 <tag/Declaration/<tt/unsigned char __fastcall__ peekbsys (unsigned addr);/
4611 <tag/Description/<tt/peekbsys/ reads one byte from the given address in the
4612 system bank (bank 15) of the CBM PET-II machines and returns it.
4613 <tag/Notes/<itemize>
4614 <item>The function is only available as fastcall function, so it may only
4615 be used in presence of a prototype.
4616 <item>This function may be a macro depending on the compiler options. The
4617 actual function is accessible by #undef'ing the macro.
4619 <tag/Availability/cc65
4621 <ref id="PEEK" name="PEEK">,
4622 <ref id="PEEKW" name="PEEKW">,
4623 <ref id="peekwsys" name="peekwsys">,
4624 <ref id="pokebsys" name="pokebsys">,
4625 <ref id="pokewsys" name="pokewsys">
4631 <sect1>peekwsys<label id="peekwsys"><p>
4635 <tag/Function/Read one word from a location in the system bank.
4636 <tag/Header/<tt/<ref id="cbm610.h" name="cbm610.h">/,
4637 <tt/<ref id="cbm510.h" name="cbm510.h">/
4638 <tag/Declaration/<tt/unsigned __fastcall__ peekwsys (unsigned addr);/
4639 <tag/Description/<tt/peekwsys/ reads one word from the given address in the
4640 system bank (bank 15) of the CBM PET-II machines and returns it. Following
4641 the usual 6502 conventions, the low byte is read from <tt/addr/, and the
4642 high byte is read from <tt/addr+1/.
4643 <tag/Notes/<itemize>
4644 <item>The function is only available as fastcall function, so it may only
4645 be used in presence of a prototype.
4646 <item>The order in which the two bytes are read is undefined.
4648 <tag/Availability/cc65
4650 <ref id="PEEK" name="PEEK">,
4651 <ref id="PEEKW" name="PEEKW">,
4652 <ref id="peekbsys" name="peekbsys">,
4653 <ref id="pokebsys" name="pokebsys">,
4654 <ref id="pokewsys" name="pokewsys">
4660 <sect1>perror<label id="perror"><p>
4664 <tag/Function/Print an error message for the error in <tt/errno/.
4665 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
4666 <tag/Declaration/<tt/void __fastcall__ perror (const char* s);/
4667 <tag/Description/<tt/perror/ prints an error message to <tt/stderr/. If <tt/s/
4668 is not <tt/NULL/ and not an empty string, it is printed followed by a colon and
4669 a blank. Then the error message for the current contents of <tt/errno/ is
4670 printed followed by a newline. The message output is the same as returned by
4671 <tt/<ref id="strerror" name="strerror">/ with an argument of <tt/errno/.
4672 <tag/Notes/<itemize>
4673 <item>The function is only available as fastcall function, so it may only
4674 be used in presence of a prototype.
4676 <tag/Availability/ISO 9899
4678 <ref id="_poserror" name="_poserror">,
4679 <ref id="strerror" name="strerror">
4685 <sect1>pokebsys<label id="pokebsys"><p>
4689 <tag/Function/Write one byte to a location in the system bank.
4690 <tag/Header/<tt/<ref id="cbm610.h" name="cbm610.h">/,
4691 <tt/<ref id="cbm510.h" name="cbm510.h">/
4692 <tag/Declaration/<tt/void __fastcall__ pokebsys (unsigned addr, unsigned char val);/
4693 <tag/Description/<tt/pokebsys/ writes one byte to the given address in the
4694 system bank (bank 15) of the CBM PET-II machines.
4695 <tag/Notes/<itemize>
4696 <item>The function is only available as fastcall function, so it may only
4697 be used in presence of a prototype.
4699 <tag/Availability/cc65
4701 <ref id="POKE" name="POKE">,
4702 <ref id="POKEW" name="POKEW">,
4703 <ref id="peekbsys" name="peekbsys">,
4704 <ref id="peekwsys" name="peekwsys">,
4705 <ref id="pokewsys" name="pokewsys">
4711 <sect1>pokewsys<label id="pokewsys"><p>
4715 <tag/Function/Write one word to a location in the system bank.
4716 <tag/Header/<tt/<ref id="cbm610.h" name="cbm610.h">/,
4717 <tt/<ref id="cbm510.h" name="cbm510.h">/
4718 <tag/Declaration/<tt/void __fastcall__ pokewsys (unsigned addr, unsigned val);/
4719 <tag/Description/<tt/pokewsys/ writes one word to the given address in the
4720 system bank (bank 15) of the CBM PET-II machines. Following the usual 6502
4721 conventions, the low byte of <tt/val/ is written to <tt/addr/, and the
4722 high byte is written to <tt/addr+1/.
4723 <tag/Notes/<itemize>
4724 <item>The function is only available as fastcall function, so it may only
4725 be used in presence of a prototype.
4726 <item>The order in which the two bytes are written is undefined.
4728 <tag/Availability/cc65
4730 <ref id="POKE" name="POKE">,
4731 <ref id="POKEW" name="POKEW">,
4732 <ref id="peekbsys" name="peekbsys">,
4733 <ref id="peekwsys" name="peekwsys">,
4734 <ref id="pokebsys" name="pokebsys">
4740 <sect1>qsort<label id="qsort"><p>
4744 <tag/Function/Sort an array.
4745 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
4746 <tag/Declaration/<tt/void __fastcall__ qsort (void* base, size_t count,
4747 size_t size, int __fastcall__ (* compare) (const void*, const void*));/
4748 <tag/Description/<tt/qsort/ sorts an array according to a given compare
4749 function <tt/compare/. <tt/base/ is the address of the array, <tt/count/
4750 is the number of elements, <tt/size/ the size of an element and <tt/compare/
4751 the function used to compare the members.
4752 <tag/Notes/<itemize>
4753 <item>If there are multiple members with the same key, the order after calling
4754 the function is undefined.
4755 <item>The function is only available as fastcall function, so it may only
4756 be used in presence of a prototype.
4757 <item>The function to which <tt/compare/ points must have the <tt/fastcall/
4760 <tag/Availability/ISO 9899
4762 <ref id="bsearch" name="bsearch">
4768 <sect1>raise<label id="raise"><p>
4772 <tag/Function/Send a signal to the executing program.
4773 <tag/Header/<tt/<ref id="signal.h" name="signal.h">/
4774 <tag/Declaration/<tt/int __fastcall__ raise (int sig);/
4775 <tag/Description/<tt/raise/ sends the given signal to the program. If the
4776 program has installed a signal handler for the signal, this signal handler
4777 will be executed. If no handler has been installed, the default action for
4778 the raised signal will be taken. The function returns zero on success,
4780 <tag/Notes/<itemize>
4781 <item>The function is only available as fastcall function, so it may only
4782 be used in presence of a prototype.
4784 <tag/Availability/ISO 9899
4786 <ref id="abort" name="abort">,
4787 <ref id="signal" name="signal">
4793 <sect1>rand<label id="rand"><p>
4797 <tag/Function/Return a pseudo random number.
4798 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
4799 <tag/Declaration/<tt/int rand (void);/
4800 <tag/Description/The function returns a pseudo random number
4801 between 0 and <tt/RAND_MAX/ (exclusive).
4802 <tag/Notes/<itemize>
4803 <item>Without using <tt><ref id="srand" name="srand"></tt>, always the same
4804 flow of numbers is generated.
4805 <item>On startup, the function behaves as if <ref id="srand" name="srand">
4806 had been used with an argument of 1.
4808 <tag/Availability/ISO 9899
4810 <ref id="_randomize" name="_randomize">,
4811 <ref id="srand" name="srand">
4817 <sect1>readdir<label id="readdir"><p>
4821 <tag/Function/Read a directory.
4822 <tag/Header/<tt/<ref id="dirent.h" name="dirent.h">/
4823 <tag/Declaration/<tt/struct dirent* __fastcall__ readdir (DIR* dir);/
4824 <tag/Description/<tt/readdir/ reads the next directory entry from the directory
4825 stream pointed to by <tt/dir/. It stores the data in a <tt/dirent/ structure
4826 and returns a pointer to it. If the end of directory is reached, or an error
4827 occurs, NULL is returned. In case of errors, an error code is stored into
4829 <tag/Notes/<itemize>
4830 <item>The function is only available as fastcall function, so it may only
4831 be used in presence of a prototype.
4832 <item>The returned pointer may point to a statically allocated instance of
4833 <tt/struct dirent/, so it may get overwritten by subsequent calls to
4835 <item>On several platforms, namely the CBMs and the Atari, the disk drives get
4836 confused when opening/closing files between directory reads. So for example a
4837 program that reads the list of files on a disk, and after each call to
4838 <tt/readdir/, opens the file to process it, will fail.<newline>
4839 Possible solutions are reading the directory into memory before processing the
4840 file list, or to reset the directory by seeking to the correct position after
4841 opening/closing a file:
4843 seekdir (DIR, telldir (DIR));
4845 Platforms known to work without problems are: Apple.
4847 <tag/Availability/POSIX 1003.1
4849 <ref id="closedir" name="closedir">,
4850 <ref id="opendir" name="opendir">
4856 <sect1>realloc<label id="realloc"><p>
4860 <tag/Function/Change the size of an allocated memory block.
4861 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
4862 <tag/Declaration/<tt/void* __fastcall__ realloc (void* block, size_t size);/
4863 <tag/Description/<tt/realloc/ changes the size of the memory block pointed to
4864 by <tt/block/ to <tt/size/ bytes. If <tt/block/ is <tt/NULL/, <tt/realloc/
4865 behaves as if <tt/malloc/ had been called. If <tt/size/ is zero, <tt/realloc/
4866 behaves as if <tt/free/ had been called. On error (not enough memory
4867 available), <tt/realloc/ returns <tt/NULL/.
4868 <tag/Notes/<itemize>
4869 <item>The part of the memory block that is returned will have its contents
4871 <item>This function is somewhat dangerous to use. Be careful to save the
4872 pointer you're passing somewhere else, otherwise
4874 ptr = realloc (ptr, size);
4876 will loose your only copy of <tt/ptr/ if <tt/realloc/ returns <tt/NULL/.
4877 <item>The function is only available as fastcall function, so it may only
4878 be used in presence of a prototype.
4880 <tag/Availability/ISO 9899
4882 <ref id="_heapadd" name="_heapadd">,
4883 <ref id="_heapblocksize" name="_heapblocksize">,
4884 <ref id="_heapmaxavail" name="_heapmaxavail">,
4885 <ref id="_heapmemavail" name="_heapmemavail">,
4886 <ref id="calloc" name="calloc">,
4887 <ref id="free" name="free">,
4888 <ref id="realloc" name="realloc">
4894 <sect1>remove<label id="remove"><p>
4898 <tag/Function/Delete a file.
4899 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
4900 <tag/Declaration/<tt/int __fastcall__ remove (const char* name);/
4901 <tag/Description/<tt/remove/ deletes the file with the given name. On success,
4902 zero is returned. On error, -1 is returned and <tt/errno/ is set to an error
4903 code describing the reason for the failure.
4904 <tag/Notes/<itemize>
4905 <item>This function is not available on all cc65 targets (depends on the
4906 availability of file I/O).
4907 <item>The function is only available as fastcall function, so it may only
4908 be used in presence of a prototype.
4910 <tag/Availability/ISO 9899
4912 <ref id="rename" name="rename">,
4913 <ref id="unlink" name="unlink">
4916 #include <stdio.h>
4918 #define FILENAME "helloworld"
4920 if (remove (FILENAME) == 0) {
4921 printf ("We deleted %s successfully\n", FILENAME);
4923 printf ("There was a problem deleting %s\n", FILENAME);
4930 <sect1>rename<label id="rename"><p>
4934 <tag/Function/Rename a file.
4935 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
4936 <tag/Declaration/<tt/int __fastcall__ rename (const char* oldname, const char* newname);/
4937 <tag/Description/<tt/rename/ renames a file (gives it a new name). On success,
4938 zero is returned. On error, -1 is returned and <tt/errno/ is set to an error
4939 code describing the reason for the failure.
4940 <tag/Notes/<itemize>
4941 <item>This function is not available on all cc65 targets (depends on the
4942 capabilities of the storage devices).
4943 <item>The function is only available as fastcall function, so it may only
4944 be used in presence of a prototype.
4946 <tag/Availability/ISO 9899
4948 <ref id="remove" name="remove">
4951 #include <stdio.h>
4953 #define OLDNAME "textfile.txt"
4954 #define NEWNAME "textfile.bak"
4956 if (rename (OLDNAME, NEWNAME) == 0) {
4957 printf ("Renamed %s to %s\n", OLDNAME, NEWNAME);
4959 printf ("Error renaming %s to %s\n", OLDNAME, NEWNAME);
4966 <sect1>reset_brk<label id="reset_brk"><p>
4970 <tag/Function/Resets the break vector to its original value.
4971 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
4972 <tag/Declaration/<tt/void reset_brk (void);/
4973 <tag/Description/<tt/reset_brk/ resets the break vector to the value it had
4974 before a call to <tt/set_brk/.
4975 <tag/Notes/<itemize>
4976 <item>The break vector is reset on program termination, so it's not strictly
4977 necessary to call this function as a part of your clean-up when exitting the program.
4979 <tag/Availability/cc65
4981 <ref id="reset_irq" name="reset_irq">,
4982 <ref id="set_brk" name="set_brk">,
4983 <ref id="set_irq" name="set_irq">
4989 <sect1>reset_irq<label id="reset_irq"><p>
4993 <tag/Function/Resets the C level interrupt request vector.
4994 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
4995 <tag/Declaration/<tt/void reset_irq (void);/
4996 <tag/Description/<tt/reset_irq/ resets the C level interrupt request vector.
4997 <tag/Notes/<itemize>
4998 <item>The interrupt vector is reset on program termination, so it's not strictly
4999 necessary to call this function as a part of your clean-up when exitting the program.
5001 <tag/Availability/cc65
5003 <ref id="reset_brk" name="reset_brk">,
5004 <ref id="set_brk" name="set_brk">,
5005 <ref id="set_irq" name="set_irq">
5011 <sect1>revers<label id="revers"><p>
5015 <tag/Function/Control revers character display.
5016 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
5017 <tag/Declaration/<tt/unsigned char __fastcall__ revers (unsigned char onoff);/
5018 <tag/Description/If the argument is non zero, the function enables reverse
5019 character display. If the argument is zero, reverse character display is
5020 switched off. The old value of the setting is returned.
5021 <tag/Notes/<itemize>
5022 <item>The function may not be supported by the hardware, in which case
5023 the call is ignored.
5024 <item>The function is only available as fastcall function, so it may only
5025 be used in presence of a prototype.
5027 <tag/Availability/cc65
5029 <ref id="textcolor" name="textcolor">
5035 <sect1>rewinddir<label id="rewinddir"><p>
5039 <tag/Function/Reset a directory stream.
5040 <tag/Header/<tt/<ref id="dirent.h" name="dirent.h">/
5041 <tag/Declaration/<tt/void __fastcall__ rewinddir (DIR* dir);/
5042 <tag/Description/<tt/rewinddir/ sets the position of the directory stream
5043 pointed to by <tt/dir/ to the start of the directory.
5044 <tag/Notes/<itemize>
5045 <item>The function is only available as fastcall function, so it may only
5046 be used in presence of a prototype.
5048 <tag/Availability/POSIX 1003.1
5050 <ref id="seekdir" name="seekdir">,
5051 <ref id="telldir" name="telldir">
5057 <sect1>screensize<label id="screensize"><p>
5061 <tag/Function/Return the dimensions of the text mode screen.
5062 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
5063 <tag/Declaration/<tt/void __fastcall__ screensize (unsigned char* x, unsigned char* y);/
5064 <tag/Description/The function returns the dimensions of the text mode screen.
5065 <tag/Notes/<itemize>
5066 <item>The function is only available as fastcall function, so it may only
5067 be used in presence of a prototype.
5069 <tag/Availability/cc65
5071 <ref id="gotox" name="gotox">,
5072 <ref id="gotoxy" name="gotoxy">,
5073 <ref id="gotoy" name="gotoy">,
5074 <ref id="wherex" name="wherex">,
5075 <ref id="wherey" name="wherey">
5081 <sect1>seekdir<label id="seekdir"><p>
5085 <tag/Function/Set the position of a directory stream.
5086 <tag/Header/<tt/<ref id="dirent.h" name="dirent.h">/
5087 <tag/Declaration/<tt/void __fastcall__ seekdir (DIR* dir, long offset);/
5088 <tag/Description/<tt/seekdir/ sets the position of the directory stream
5089 pointed to by <tt/dir/ to the value given in <tt/offset/, which should be a
5090 value returned by <tt/<ref id="telldir" name="telldir">/.
5091 <tag/Notes/<itemize>
5092 <item>The function is only available as fastcall function, so it may only
5093 be used in presence of a prototype.
5095 <tag/Availability/POSIX 1003.1
5097 <ref id="rewinddir" name="rewinddir">,
5098 <ref id="telldir" name="telldir">
5104 <sect1>ser_close<label id="ser_close"><p>
5108 <tag/Function/Close the port and disable interrupts
5109 <tag/Header/<tt/<ref id="serial.h" name="serial.h">/
5110 <tag/Declaration/<tt/unsigned char ser_close (void);/
5111 <tag/Description/Close the port by clearing buffers and disable interrupts.
5112 <tag/Availability/cc65
5113 <tag/See also/Other serial functions.
5118 static void initialize(){
5119 struct ser_params params = {
5126 ser_install(lynx_comlynx); // This will activate the ComLynx
5128 ser_open(&params);
5135 <sect1>ser_get<label id="ser_get"><p>
5139 <tag/Function/Read a character from serial port.
5140 <tag/Header/<tt/<ref id="serial.h" name="serial.h">/
5141 <tag/Declaration/<tt/unsigned char __fastcall__ ser_get (char* b);/
5142 <tag/Description/Get a character from the serial port. If no characters are
5143 available, the function will return SER_ERR_NO_DATA, so this is not a fatal
5145 <tag/Notes/<itemize>
5146 <item>The function is only available as fastcall function, so it may only
5147 be used in presence of a prototype.
5149 <tag/Availability/cc65
5150 <tag/See also/Other serial functions.
5152 Wait for a character to be available from a serial port.
5155 while (ser_get(&ch) == SER_ERR_NO_DATA)
5162 <sect1>ser_install<label id="ser_install"><p>
5166 <tag/Function/Install an already loaded driver and return an error code.
5167 <tag/Header/<tt/<ref id="serial.h" name="serial.h">/
5168 <tag/Declaration/<tt/unsigned char __fastcall__ ser_install (void* driver);/
5169 <tag/Description/The function installs a driver that was already loaded into
5170 memory (or linked statically to the program). It returns an error code
5171 (<tt/SER_ERR_OK/ in case of success).
5172 <tag/Notes/<itemize>
5173 <item>The function is only available as fastcall function, so it may only be
5174 used in presence of a prototype.
5176 <tag/Availability/cc65
5178 <ref id="ser_load_driver" name="ser_load_driver">,
5179 <ref id="ser_uninstall" name="ser_uninstall">,
5180 <ref id="ser_unload" name="ser_unload">
5182 ser_install(lynx_comlynx); //Include the driver statically instead of loading it.
5188 <sect1>ser_ioctl<label id="ser_ioctl"><p>
5192 <tag/Function/Platform dependent code extensions.
5193 <tag/Header/<tt/<ref id="serial.h" name="serial.h">/
5194 <tag/Declaration/<tt/unsigned __fastcall__ ser_ioctl (unsigned char code, void* data);/
5195 <tag/Description/Some platforms have extra serial functions that are not
5196 supported by standard serial driver functions. You can extend the driver to support
5197 this extra functionality bt using ser_ioctl functions.
5198 <tag/Notes/<itemize>
5199 <item>The function is only available as fastcall function, so it may only
5200 be used in presence of a prototype.
5201 <item>These functions are not easily portable to other cc65 platforms.
5203 <tag/Availability/cc65
5204 <tag/See also/Other serial functions.
5209 <sect1>ser_load_driver<label id="ser_load_driver"><p>
5213 <tag/Function/Load and install a serial driver.
5214 <tag/Header/<tt/<ref id="serial.h" name="serial.h">/
5215 <tag/Declaration/<tt/unsigned char __fastcall__ ser_load_driver (const char *name);/
5216 <tag/Description/Load and install the driver by name.
5217 Will just load the driver and check if loading was successful.
5218 <tag/Notes/<itemize>
5219 <item>The function is only available as fastcall function, so it may only
5220 be used in presence of a prototype.
5222 <tag/Availability/cc65
5223 <tag/See also/Other serial functions.
5229 <sect1>ser_open<label id="ser_open"><p>
5233 <tag/Function/Open the port by setting the port parameters and enable interrupts
5234 <tag/Header/<tt/<ref id="serial.h" name="serial.h">/
5235 <tag/Declaration/<tt/unsigned char __fastcall__ ser_open (const struct ser_params* params);/
5236 <tag/Description/Open the port by setting the port parameters and enable interrupts.
5237 <tag/Notes/<itemize>
5238 <item>The function is only available as fastcall function, so it may only
5239 be used in presence of a prototype.
5241 <tag/Availability/cc65
5242 <tag/See also/Other serial functions.
5247 static void initialize(){
5248 struct ser_params params = {
5255 ser_install(lynx_comlynx); // This will activate the ComLynx
5257 ser_open(&params);
5264 <sect1>ser_put<label id="ser_put"><p>
5268 <tag/Function/Write a character to a serial port.
5269 <tag/Header/<tt/<ref id="serial.h" name="serial.h">/
5270 <tag/Declaration/<tt/unsigned char __fastcall__ ser_put (char b);/
5271 <tag/Description/Send a character via the serial port. There is a transmit
5272 buffer, but transmitting is not done via interrupt. The function returns
5273 SER_ERR_OVERFLOW if there is no space left in the transmit buffer.
5274 <tag/Notes/<itemize>
5275 <item>The function is only available as fastcall function, so it may only
5276 be used in presence of a prototype.
5278 <tag/Availability/cc65
5279 <tag/See also/Other serial functions.
5288 <sect1>ser_status<label id="ser_status"><p>
5292 <tag/Function/Return the serial port status.
5293 <tag/Header/<tt/<ref id="serial.h" name="serial.h">/
5294 <tag/Declaration/<tt/unsigned char __fastcall__ ser_status (unsigned char* status);/
5295 <tag/Description/Return the serial port status.
5296 <tag/Notes/<itemize>
5297 <item>The function is only available as fastcall function, so it may only
5298 be used in presence of a prototype.
5300 <tag/Availability/cc65
5301 <tag/See also/Other serial functions.
5307 <sect1>ser_uninstall<label id="ser_uninstall"><p>
5311 <tag/Function/Uninstall the currently loaded driver but do not unload it.
5312 <tag/Header/<tt/<ref id="serial.h" name="serial.h">/
5313 <tag/Declaration/<tt/unsigned char ser_uninstall (void);/
5314 <tag/Description/Uninstall the currently loaded driver but do not unload it.
5315 <tag/Availability/cc65
5316 <tag/See also/Other serial functions.
5321 <sect1>ser_unload<label id="ser_unload"><p>
5325 <tag/Function/Uninstall, then unload the currently loaded driver.
5326 <tag/Header/<tt/<ref id="serial.h" name="serial.h">/
5327 <tag/Declaration/<tt/unsigned char ser_unload (void);/
5328 <tag/Description/Uninstall, then unload the currently loaded driver.
5329 <tag/Availability/cc65
5330 <tag/See also/Other serial functions.
5336 <sect1>set_brk<label id="set_brk"><p>
5340 <tag/Function/Set the break vector to a user function.
5341 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
5342 <tag/Declaration/<tt/void __fastcall__ set_brk (brk_handler func);/
5343 <tag/Description/<tt/set_brk/ allows a user program to handle breaks within the
5344 program code by letting the vector point to a user written C function. The
5345 runtime library installs a small stub that saves the registers into global
5346 variables that may be accessed (and changed) by the break handler.
5347 <tag/Notes/<itemize>
5348 <item>The function is only available as fastcall function, so it may only
5349 be used in presence of a prototype.
5350 <item>The stub saves the zero page registers used by the C runtime and switches
5351 to a small break handler stack. This means that it is safe to execute C code,
5352 even if C code was interrupted. Be careful however not to use too many local
5353 variables, and do not enable stack checks for the handler function or any other
5354 function called from it.
5355 <item>The <tt/brk_pc/ variable points to the <tt/BRK/ instruction. If you want
5356 the continue with the interrupted code, you have to adjust <tt/brk_pc/,
5357 otherwise the <tt/BRK/ instruction will get executed over and over again.
5358 <item>The break vector is reset on program termination, so it's not strictly
5359 necessary to call <tt/<ref id="reset_brk" name="reset_brk">/ as a part of your
5360 clean-up when exitting the program.
5362 <tag/Availability/cc65
5364 <ref id="reset_brk" name="reset_brk">
5370 <sect1>set_irq<label id="set_irq"><p>
5374 <tag/Function/Set the C level interrupt request vector to the given address.
5375 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
5376 <tag/Declaration/<tt/void __fastcall__ set_irq (irq_handler f, void *stack_addr, size_t stack_size);/
5377 <tag/Description/<tt/set_irq/ allows a user program to handle interrupt requests
5378 (IRQs) within the program code by letting the vector point to a user written C
5379 function. The runtime library installs a small stub that saves the zero page
5380 registers used by the C runtime before calling the handler function and restores
5381 them after the handler function returns. Additionally the stub temporarily switches
5382 the C runtime stack to the stack area provided as parameter. If the handler function
5383 was set up to handle a "private", "exclusive" interrupt request source it must
5384 return the value <tt/IRQ_HANDLED/ if and only if it has verified that the current
5385 interrupt request actually stems from that source. In all other cases it must return
5386 the value <tt/IRQ_NOT_HANDLED/.
5387 <tag/Notes/<itemize>
5388 <item>The function is only available as fastcall function, so it may only
5389 be used in presence of a prototype.
5390 <item>The stub saves the registers and zero page locations used by the C runtime
5391 and switches to the provided stack area. As a consequence, there is some
5392 runtime overhead, but it it is safe to execute C code, even if other C code
5393 was interrupted. Be careful however not to call C library functions, and do not
5394 enable stack checks for the handler function or any other function called from
5396 <item>The interrupt vector is reset on program termination, so it's not strictly
5397 necessary to call <tt/<ref id="reset_irq" name="reset_irq">/ as a part of your
5398 clean-up when exitting the program.
5400 <tag/Availability/cc65
5402 <ref id="reset_brk" name="reset_brk">,
5403 <ref id="reset_irq" name="reset_irq">,
5404 <ref id="set_brk" name="set_brk">
5410 <sect1>setjmp<label id="setjmp"><p>
5414 <tag/Function/Save the context for use with <tt/longjmp/.
5415 <tag/Header/<tt/<ref id="setjmp.h" name="setjmp.h">/
5416 <tag/Declaration/<tt/int __fastcall__ setjmp (jmp_buf buf);/
5417 <tag/Description/The <tt/setjmp/ function saves the current context in <tt/buf/
5418 for subsequent use by the <tt/<ref id="longjmp" name="longjmp">/ function and
5420 <tag/Notes/<itemize>
5421 <item>The function is only available as fastcall function, so it may only
5422 be used in presence of a prototype.
5423 <item><tt/setjmp/ is actually a macro as required by the ISO standard.
5424 <item><tt/setjmp/ will not save the signal context.
5426 <tag/Availability/ISO 9899
5428 <ref id="longjmp" name="longjmp">
5434 <sect1>setlocale<label id="setlocale"><p>
5438 <tag/Function/Selects a locale.
5439 <tag/Header/<tt/<ref id="locale.h" name="locale.h">/
5440 <tag/Declaration/<tt/char* __fastcall__ setlocale (int category, const char* locale);/
5441 <tag/Description/<tt/setlocale/ sets or queries the program's locale.
5442 <tag/Notes/<itemize>
5443 <item>The function is only available as fastcall function, so it may only
5444 be used in presence of a prototype.
5445 <item>cc65 supports only the "C" locale, so calling this function to set a
5446 different locale has no effect.
5448 <tag/Availability/ISO 9899
5450 <ref id="localeconv" name="localeconv">,
5451 <ref id="strcoll" name="strcoll">
5452 <ref id="strxfrm" name="strxfrm">
5458 <sect1>signal<label id="signal"><p>
5462 <tag/Function/Install a signal handler.
5463 <tag/Header/<tt/<ref id="signal.h" name="signal.h">/
5464 <tag/Declaration/<tt/__sigfunc __fastcall__ signal (int sig, __sigfunc func);/
5465 <tag/Description/<tt/signal/ installs a handler for the given signal. The
5466 handler may either be a user supplied function, or one of the predefined
5467 signal handlers <tt/SIG_IGN/ or <tt/SIG_DFL/. The function returns the
5468 previous value if the signal , or the special function vector SIG_ERR in
5470 <tag/Notes/<itemize>
5471 <item>The function is only available as fastcall function, so it may only
5472 be used in presence of a prototype.
5474 <tag/Availability/ISO 9899
5476 <ref id="abort" name="abort">,
5477 <ref id="raise" name="raise">
5483 <sect1>sleep<label id="sleep"><p>
5487 <tag/Function/Sleep for a specified amount of time.
5488 <tag/Header/<tt/<ref id="unistd.h" name="unistd.h">/
5489 <tag/Declaration/<tt/void __fastcall__ sleep (unsigned seconds);/
5490 <tag/Description/The function will return after the specified number of
5491 seconds have elapsed.
5492 <tag/Notes/<itemize>
5493 <item>The function is only available as fastcall function, so it may only
5494 be used in presence of a prototype.
5496 <tag/Availability/POSIX 1003.1
5502 <sect1>slow<label id="slow"><p>
5506 <tag/Function/Switch the C128 into 1MHz mode.
5507 <tag/Header/<tt/<ref id="c128.h" name="c128.h">/
5508 <tag/Declaration/<tt/void slow (void);/
5509 <tag/Description/The function will switch the clock of the C128 to 1MHz. This
5510 will halve the speed compared to fast mode.
5511 <tag/Notes/<itemize>
5512 <item>The function is specific to the C128.
5514 <tag/Availability/C128
5516 <ref id="fast" name="fast">,
5517 <ref id="toggle_videomode" name="toggle_videomode">,
5518 <ref id="videomode" name="videomode">
5524 <sect1>srand<label id="srand"><p>
5528 <tag/Function/Initialize the pseudo random number generator.
5529 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
5530 <tag/Declaration/<tt/void __fastcall__ srand (unsigned seed);/
5531 <tag/Description/The function initializes the random number generator using
5532 the given seed. On program startup, the generator behaves as if <tt/srand/ has
5533 been called with an argument of 1.
5534 <tag/Notes/<itemize>
5535 <item>The function is only available as fastcall function, so it may only
5536 be used in presence of a prototype.
5538 <tag/Availability/ISO 9899
5540 <ref id="_randomize" name="_randomize">,
5541 <ref id="rand" name="rand">
5547 <sect1>strcasecmp<label id="strcasecmp"><p>
5551 <tag/Function/Compare two strings case insensitive.
5552 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5553 <tag/Declaration/<tt/int __fastcall__ strcasecmp (const char* s1, const char* s2);/
5554 <tag/Description/The <tt/strcasecmp/ function compares the two strings passed
5555 as parameters without case sensitivity. It returns a value that is less than
5556 zero if <tt/s1/ is less than <tt/s2/, zero if <tt/s1/ is the same as <tt/s2/,
5557 and a value greater than zero if <tt/s1/ is greater than <tt/s2/.
5558 <tag/Notes/<itemize>
5559 <item>The function is only available as fastcall function, so it may only
5560 be used in presence of a prototype.
5561 <item>The function is not available in strict ANSI mode.
5563 <tag/Availability/cc65
5565 <ref id="strcmp" name="strcmp">,
5566 <ref id="strcoll" name="strcoll">,
5567 <ref id="stricmp" name="stricmp">,
5568 <ref id="strncmp" name="strncmp">,
5569 <ref id="strxfrm" name="strxfrm">
5575 <sect1>strcat<label id="strcat"><p>
5579 <tag/Function/Concatentate two strings.
5580 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5581 <tag/Declaration/<tt/char* __fastcall__ strcat (char* s1, const char* s2);/
5582 <tag/Description/The <tt/strcat/ function appends a copy of the string
5583 pointed to by s2 (including the terminating null byte) to the end of the
5584 string pointed to by s1. The initial byte of s2 overwrites the null byte at
5586 <tag/Notes/<itemize>
5587 <item>The function is only available as fastcall function, so it may only
5588 be used in presence of a prototype.
5589 <item>If copying takes place between objects that overlap, the behaviour
5592 <tag/Availability/ISO 9899
5594 <ref id="strcpy" name="strcpy">,
5595 <ref id="strncat" name="strncat">,
5596 <ref id="strncpy" name="strncpy">
5602 <sect1>strchr<label id="strchr"><p>
5606 <tag/Function/Search for a character in a string.
5607 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5608 <tag/Declaration/<tt/char* __fastcall__ strchr (const char* s, int c);/
5609 <tag/Description/The <tt/strchr/ function locates the first occurrence of <tt/c/
5610 (converted to a char) in the string pointed to by <tt/s/. The terminating null
5611 byte is considered to be part of the string. Upon completion, the function
5612 returns a pointer to the byte, or a null pointer if the byte was not found.
5613 <tag/Notes/<itemize>
5614 <item>The function is only available as fastcall function, so it may only
5615 be used in presence of a prototype.
5617 <tag/Availability/ISO 9899
5619 <ref id="memchr" name="memchr">,
5620 <ref id="strrchr" name="strrchr">
5626 <sect1>strcmp<label id="strcmp"><p>
5630 <tag/Function/Compare two strings.
5631 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5632 <tag/Declaration/<tt/int __fastcall__ strcmp (const char* s1, const char* s2);/
5633 <tag/Description/The <tt/strcmp/ function compares the two strings passed as
5634 parameters. It returns a value that is less than zero if <tt/s1/ is less than
5635 <tt/s2/, zero if <tt/s1/ is the same as <tt/s2/, and a value greater than zero
5636 if <tt/s1/ is greater than <tt/s2/.
5637 <tag/Notes/<itemize>
5638 <item>The function is only available as fastcall function, so it may only
5639 be used in presence of a prototype.
5641 <tag/Availability/ISO 9899
5643 <ref id="strcasecmp" name="strcasecmp">,
5644 <ref id="strcoll" name="strcoll">,
5645 <ref id="stricmp" name="stricmp">,
5646 <ref id="strncmp" name="strncmp">
5647 <ref id="strxfrm" name="strxfrm">
5653 <sect1>strcoll<label id="strcoll"><p>
5657 <tag/Function/Compare two strings.
5658 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5659 <tag/Declaration/<tt/int __fastcall__ strcoll (const char* s1, const char* s2);/
5660 <tag/Description/The <tt/strcoll/ function compares the two strings passed as
5661 parameters, according to the collating sequence set by <tt/<ref id="setlocale"
5662 name="setlocale">/. It returns a value that is less than zero if <tt/s1/ is
5663 less than <tt/s2/, zero if <tt/s1/ is the same as <tt/s2/, and a value greater
5664 than zero if <tt/s1/ is greater than <tt/s2/.
5665 <tag/Notes/<itemize>
5666 <item>The function is only available as fastcall function, so it may only
5667 be used in presence of a prototype.
5669 <tag/Availability/ISO 9899
5671 <ref id="setlocale" name="setlocale">,
5672 <ref id="strcasecmp" name="strcasecmp">,
5673 <ref id="strcmp" name="strcmp">,
5674 <ref id="stricmp" name="stricmp">,
5675 <ref id="strncmp" name="strncmp">,
5676 <ref id="strxfrm" name="strxfrm">
5682 <sect1>strcpy<label id="strcpy"><p>
5686 <tag/Function/Copy a string.
5687 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5688 <tag/Declaration/<tt/char* __fastcall__ strcpy (char* s1, const char* s2);/
5689 <tag/Description/The <tt/strcpy/ function copies the string pointed to by
5690 <tt/s2/ (including the terminating null byte) into the array pointed to by
5691 <tt/s1/. The function will always return <tt/s1/.
5692 <tag/Notes/<itemize>
5693 <item>The function is only available as fastcall function, so it may only
5694 be used in presence of a prototype.
5695 <item>If copying takes place between objects that overlap, the behaviour
5698 <tag/Availability/ISO 9899
5700 <ref id="strcat" name="strcat">,
5701 <ref id="strncat" name="strncat">,
5702 <ref id="strncpy" name="strncpy">
5705 #include <string.h>
5707 static char hello[14];
5709 strcpy (hello, "Hello world!\n");
5715 <sect1>strcspn<label id="strcspn"><p>
5719 <tag/Function/Compute the length of a substring.
5720 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5721 <tag/Declaration/<tt/size_t __fastcall__ strcspn (const char* s, const char* set);/
5722 <tag/Description/The <tt/strcspn/ function computes and returns the length of
5723 the substring pointed to by <tt/s/ which does <em>not</em> consist of
5724 characters contained in the string <tt/set/.
5725 <tag/Notes/<itemize>
5726 <item>The function is only available as fastcall function, so it may only
5727 be used in presence of a prototype.
5729 <tag/Availability/ISO 9899
5731 <ref id="strqtok" name="strqtok">,
5732 <ref id="strspn" name="strspn">,
5733 <ref id="strstr" name="strstr">,
5734 <ref id="strtok" name="strtok">
5740 <sect1>strdup<label id="strdup"><p>
5744 <tag/Function/Allocate a copy of a string on the heap.
5745 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5746 <tag/Declaration/<tt/char* __fastcall__ strdup (const char* s);/
5747 <tag/Description/<tt/strdup/ allocates a memory block on the heap, big enough
5748 to hold a copy of <tt/s/ including the terminating zero. If the allocation
5749 fails, <tt/NULL/ is returned, otherwise <tt/s/ is copied into the allocated
5750 memory block, and a pointer to the block is returned.
5751 <tag/Notes/<itemize>
5752 <item>The function is only available as fastcall function, so it may only
5753 be used in presence of a prototype.
5754 <item>It is up to the caller to free the allocated memory block.
5756 <tag/Availability/ISO 9899
5758 <ref id="free" name="free">,
5759 <ref id="malloc" name="malloc">
5765 <sect1>strerror<label id="strerror"><p>
5769 <tag/Function/Return a string describing an error code.
5770 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5771 <tag/Declaration/<tt/char* __fastcall__ strerror (int errcode);/
5772 <tag/Description/The <tt/strerror/ function returns a string describing the
5773 given error code. If an invalid error code is passed, the string "Unknown
5774 error" is returned, and <tt/errno/ is set to <tt/EINVAL/. In all other cases,
5775 <tt/errno/ is left untouched.
5776 <tag/Notes/<itemize>
5777 <item>The function is only available as fastcall function, so it may only
5778 be used in presence of a prototype.
5779 <item>While the return type of the function is a <tt/char*/, the returned
5780 string must not be modified by the caller!
5782 <tag/Availability/ISO 9899
5784 <ref id="_stroserror" name="_stroserror">
5790 <sect1>stricmp<label id="stricmp"><p>
5794 <tag/Function/Compare two strings case insensitive.
5795 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5796 <tag/Declaration/<tt/int __fastcall__ stricmp (const char* s1, const char* s2);/
5797 <tag/Description/The <tt/stricmp/ function compares the two strings passed as
5798 parameters without case sensitivity. It returns a value that is less than zero
5799 if <tt/s1/ is less than <tt/s2/, zero if <tt/s1/ is the same as <tt/s2/, and a
5800 value greater than zero if <tt/s1/ is greater than <tt/s2/.
5801 <tag/Notes/<itemize>
5802 <item>The function is only available as fastcall function, so it may only
5803 be used in presence of a prototype.
5804 <item>The function is not available in strict ANSI mode.
5806 <tag/Availability/cc65
5808 <ref id="strcasecmp" name="strcasecmp">,
5809 <ref id="strcmp" name="strcmp">,
5810 <ref id="strcoll" name="strcoll">,
5811 <ref id="strncmp" name="strncmp">,
5812 <ref id="strxfrm" name="strxfrm">
5818 <sect1>strlen<label id="strlen"><p>
5822 <tag/Function/Return the length of a string.
5823 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5824 <tag/Declaration/<tt/size_t __fastcall__ strlen (const char* s);/
5825 <tag/Description/The <tt/strlen/ function computes the number of bytes in the
5826 string to which s points, not including the terminating null byte.
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>When compiling with <tt/-Os/ (inline known standard functions), the
5831 function does not work correctly for strings with more than 255 characters.
5833 <tag/Availability/ISO 9899
5835 <ref id="strcpy" name="strcpy">
5841 <sect1>strlower<label id="strlower"><p>
5845 <tag/Function/Make a string lower case.
5846 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5847 <tag/Declaration/<tt/char* __fastcall__ strlower (char* s);/
5848 <tag/Description/The <tt/strlower/ function will apply the <tt/tolower/
5849 function to each character of a string. The function will always return <tt/s/.
5850 <tag/Notes/<itemize>
5851 <item>The function is only available as fastcall function, so it may only
5852 be used in presence of a prototype.
5853 <item>The function prototype is unavailable when compiling in strict ANSI mode.
5854 <item>An alias name for this function is <tt/strlwr/.
5856 <tag/Availability/cc65
5858 <ref id="strupper" name="strupper">,
5859 <ref id="tolower" name="tolower">
5865 <sect1>strlwr<label id="strlwr"><p>
5872 <sect1>strncat<label id="strncat"><p>
5876 <tag/Function/Concatentate two strings.
5877 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5878 <tag/Declaration/<tt/char* __fastcall__ strncat (char* s1, const char* s2, size_t n);/
5879 <tag/Description/The <tt/strncat/ function appends not more than n characters
5880 of the string pointed to by s2 to the end of the string pointed to by s1. The
5881 terminating null character at the end of s1 is overwritten. A terminating null
5882 character is appended to the result, even if not all of s2 is appended to s1.
5883 <tag/Notes/<itemize>
5884 <item>The function is only available as fastcall function, so it may only
5885 be used in presence of a prototype.
5886 <item>If copying takes place between objects that overlap, the behaviour
5889 <tag/Availability/ISO 9899
5891 <ref id="strcpy" name="strcpy">,
5892 <ref id="strncat" name="strncat">,
5893 <ref id="strncpy" name="strncpy">
5899 <sect1>strncmp<label id="strncmp"><p>
5903 <tag/Function/Compare two strings.
5904 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5905 <tag/Declaration/<tt/int __fastcall__ strncmp (const char* s1, const char* s2, size_t count);/
5906 <tag/Description/The <tt/strncmp/ function compares not more than <tt/count/
5907 characters of the two strings passed as parameters. It returns a value that is
5908 less than zero if the first <tt/count/ characters of <tt/s1/ are less than
5909 <tt/s2/, zero if they are identical, and a value greater than zero they are
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.
5915 <tag/Availability/ISO 9899
5917 <ref id="strcasecmp" name="strcasecmp">,
5918 <ref id="strcmp" name="strcmp">,
5919 <ref id="strcoll" name="strcoll">,
5920 <ref id="stricmp" name="stricmp">,
5921 <ref id="strxfrm" name="strxfrm">
5927 <sect1>strncpy<label id="strncpy"><p>
5931 <tag/Function/Copy part of a string.
5932 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5933 <tag/Declaration/<tt/char* __fastcall__ strncpy (char* s1, const char* s2, size_t n);/
5934 <tag/Description/The <tt/strncpy/ function copies not more than <tt/n/ bytes from
5935 the array pointed to by <tt/s2/ to the array pointed to by <tt/s1/. If the array
5936 pointed to by <tt/s2/ is a string that is shorter than <tt/n/ bytes, null bytes are
5937 appended to the copy in the array pointed to by <tt/s1/, until <tt/n/ bytes are
5938 written. The function always will return <tt/s1/.
5939 <tag/Notes/<itemize>
5940 <item>The function is available only as a fastcall function; so, it may be used
5941 only in the presence of a prototype.
5942 <item>If there is no null byte in the first <tt/n/ bytes of the array pointed
5943 to by <tt/s2/, the result is <em/not/ null-terminated!
5944 <item>If copying takes place between objects that overlap, the behaviour is
5947 <tag/Availability/ISO 9899
5949 <ref id="memcpy" name="memcpy">,
5950 <ref id="strcat" name="strcat">,
5951 <ref id="strcpy" name="strcpy">,
5952 <ref id="strncat" name="strncat">
5957 static char hello[6];
5959 strncpy (hello, "Hello world!\n", sizeof hello - 1)[5] = '\0';
5965 <sect1>strqtok<label id="strqtok"><p>
5969 <tag/Function/Break a string into tokens.
5970 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5971 <tag/Declaration/<tt/char* __fastcall__ strqtok (char* s1, const char* s2);/
5972 <tag/Description/<tt/strqtok()/ will break the string <tt/s1/ into a sequence of
5973 tokens, which are delimited by either quotation marks or characters from the
5974 string <tt/s2/. Tokens inside quotation marks may contain characters from <tt/s2/
5975 (they aren't delimiters there). The first call to <tt/strqtok()/ will return a
5976 pointer to the first token in the string <tt/s1/. The following calls must pass
5977 a <tt/NULL/ pointer as <tt/s1/, in order to get the next token in the string.
5978 Different sets of delimiters may be used for the subsequent calls to <tt/strqtok()/.
5979 <tag/Notes/<itemize>
5980 <item>The function is available only as a fastcall function; so, it may be used
5981 only in the presence of a prototype.
5982 <item><tt/strqtok()/ will modify the string <tt/s1/.
5983 <item>The function will forget where it is in the <tt/s1/ string if it is given
5984 a second <tt/s1/ string before it finishes the first one.
5986 <tag/Availability/cc65
5988 <ref id="strcspn" name="strcspn">,
5989 <!-- <ref id="strpbrk" name="strpbrk">, -->
5990 <ref id="strspn" name="strspn">,
5991 <ref id="strtok" name="strtok">
5997 <sect1>strrchr<label id="strrchr"><p>
6001 <tag/Function/Search for a character in a string.
6002 <tag/Header/<tt/<ref id="string.h" name="string.h">/
6003 <tag/Declaration/<tt/char* __fastcall__ strrchr (const char* s, int c);/
6004 <tag/Description/The <tt/strrchr/ function locates the last occurrence of <tt/c/
6005 (converted to a char) in the string pointed to by <tt/s/. The terminating null
6006 byte is considered to be part of the string. Upon completion, the function
6007 returns a pointer to the byte, or a null pointer if the byte was not found.
6008 <tag/Notes/<itemize>
6009 <item>The function is only available as fastcall function, so it may only
6010 be used in presence of a prototype.
6012 <tag/Availability/ISO 9899
6014 <ref id="strchr" name="strchr">
6020 <sect1>strspn<label id="strspn"><p>
6024 <tag/Function/Compute the length of a substring.
6025 <tag/Header/<tt/<ref id="string.h" name="string.h">/
6026 <tag/Declaration/<tt/size_t __fastcall__ strspn (const char* s, const char* set);/
6027 <tag/Description/The <tt/strspn/ function computes and returns the length of
6028 the substring pointed to by <tt/s/ which does consist only of characters
6029 contained in the string <tt/set/.
6030 <tag/Notes/<itemize>
6031 <item>The function is only available as fastcall function, so it may only
6032 be used in presence of a prototype.
6034 <tag/Availability/ISO 9899
6036 <ref id="strcspn" name="strcspn">,
6037 <ref id="strstr" name="strstr">
6043 <sect1>strstr<label id="strstr"><p>
6047 <tag/Function/Find a substring.
6048 <tag/Header/<tt/<ref id="string.h" name="string.h">/
6049 <tag/Declaration/<tt/char* __fastcall__ strstr (const char* str, const char* substr);/
6050 <tag/Description/<tt/strstr/ searches for the first occurance of the string
6051 <tt/substr/ within <tt/str/. If found, it returns a pointer to the copy,
6052 otherwise it returns <tt/NULL/.
6053 <tag/Notes/<itemize>
6054 <item>The function is only available as fastcall function, so it may only
6055 be used in presence of a prototype.
6057 <tag/Availability/ISO 9899
6059 <ref id="strcspn" name="strcspn">,
6060 <ref id="strspn" name="strspn">
6066 <sect1>strtok<label id="strtok"><p>
6070 <tag/Function/Break a string into tokens.
6071 <tag/Header/<tt/<ref id="string.h" name="string.h">/
6072 <tag/Declaration/<tt/char* __fastcall__ strtok (char* s1, const char* s2);/
6073 <tag/Description/<tt/strtok()/ will break the string <tt/s1/ into a sequence of
6074 tokens, which are delimited by characters from the string <tt/s2/. The first call
6075 to <tt/strtok()/ will return a pointer to the first token in the string <tt/s1/.
6076 The following calls must pass a <tt/NULL/ pointer as <tt/s1/, in order to get
6077 the next token in the string. Different sets of delimiters may be used for the
6078 subsequent calls to <tt/strtok()/.
6079 <tag/Notes/<itemize>
6080 <item>The function is only available as fastcall function, so it may only
6081 be used in presence of a prototype.
6082 <item><tt/strtok()/ will modify the string <tt/s1/.
6083 <item>The function will forget where it is in the <tt/s1/ string if it is given
6084 a second <tt/s1/ string before it finishes the first one.
6086 <tag/Availability/ISO 9899
6088 <ref id="strcspn" name="strcspn">,
6089 <!-- <ref id="strpbrk" name="strpbrk">, -->
6090 <ref id="strqtok" name="strqtok">,
6091 <ref id="strspn" name="strspn">
6097 <sect1>strxfrm<label id="strxfrm"><p>
6101 <tag/Function/Transform a string.
6102 <tag/Header/<tt/<ref id="string.h" name="string.h">/
6103 <tag/Declaration/<tt/size_t __fastcall__ strxfrm (char* s1, const char* s2, size_t n);/
6104 <tag/Description/The <tt/strxfrm/ function transforms the string pointed to by
6105 s2 and places the resulting string into the string pointed to by s1. The
6106 transformation is such that if the <tt/strcmp/ function is applied to two
6107 transformed strings, it returns a value greater than, equal to, or less than
6108 zero, corresponding to the result of the <tt/strcoll/ function applied to the
6109 same two original strings. No more than n characters are placed into the
6110 resulting array pointed to by s1, including the terminating null character.
6111 <tag/Notes/<itemize>
6112 <item><tt/s1/ and <tt/s2/ must not point to the same memory area, otherwise
6113 the behaviour is undefined.
6114 <item>If <tt/n/ is zero, <tt/s1/ may be a NULL pointer.
6115 <item>The function is only available as fastcall function, so it may only
6116 be used in presence of a prototype.
6117 <item>Since cc65 doesn't support different charcter sets, <tt/strxfrm/ will
6118 just copy s2 to s1 using <tt><ref id="strncpy" name="strncpy"></tt>.
6120 <tag/Availability/ISO 9899
6122 <ref id="strcmp" name="strcmp">,
6123 <ref id="strcoll" name="strcoll">,
6124 <ref id="strncpy" name="strncpy">
6130 <sect1>strupper<label id="strupper"><p>
6134 <tag/Function/Make a string upper case.
6135 <tag/Header/<tt/<ref id="string.h" name="string.h">/
6136 <tag/Declaration/<tt/char* __fastcall__ strupper (char* s);/
6137 <tag/Description/The <tt/strupper/ function will apply the <tt/toupper/
6138 function to each character of a string. The function will always return <tt/s/.
6139 <tag/Notes/<itemize>
6140 <item>The function is only available as fastcall function, so it may only
6141 be used in presence of a prototype.
6142 <item>The function prototype is unavailable when compiling in strict ANSI mode.
6143 <item>An alias name for this function is <tt/strupr/.
6145 <tag/Availability/cc65
6147 <ref id="strlower" name="strlower">
6148 <ref id="toupper" name="toupper">
6154 <sect1>strupr<label id="strupr"><p>
6161 <sect1>telldir<label id="telldir"><p>
6165 <tag/Function/Return the current position of a directory stream.
6166 <tag/Header/<tt/<ref id="dirent.h" name="dirent.h">/
6167 <tag/Declaration/<tt/long __fastcall__ telldir (DIR* dir);/
6168 <tag/Description/<tt/telldir/ returns the current position of a directory
6169 stream. The return value may be used in subsequent calls to
6170 <tt/<ref id="seekdir" name="seekdir">/.
6171 <tag/Notes/<itemize>
6172 <item>The function is only available as fastcall function, so it may only
6173 be used in presence of a prototype.
6175 <tag/Availability/POSIX 1003.1
6177 <ref id="seekdir" name="seekdir">,
6178 <ref id="telldir" name="telldir">
6184 <sect1>textcolor<label id="textcolor"><p>
6188 <tag/Function/Set the text color.
6189 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
6190 <tag/Declaration/<tt/unsigned char __fastcall__ textcolor (unsigned char color);/
6191 <tag/Description/The function will set a new text color. It returns the old
6192 (current) text color. Text output using any <tt/conio.h/ function will use
6193 the color set by this function.
6194 <tag/Notes/<itemize>
6195 <item>Text colors are system dependent. The function may have no effect
6196 on systems where the text color cannot be changed.
6197 <item>The function is only available as fastcall function, so it may only
6198 be used in presence of a prototype.
6200 <tag/Availability/cc65
6202 <ref id="bgcolor" name="bgcolor">,
6203 <ref id="bordercolor" name="bordercolor">
6209 <sect1>tgi_arc<label id="tgi_arc"><p>
6213 <tag/Function/Draw an elliptic arc in the current color.
6214 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6215 <tag/Declaration/<tt/void __fastcall__ tgi_arc (int x, int y,
6216 unsigned char rx, unsigned char ry, unsigned sa, unsigned ea);/
6217 <tag/Description/The function draws an elliptic arc with center at x/y and
6218 radii rx/ry using the current drawing color. The arc covers the angle
6219 between sa and ea (startangle and endangle), which must be in the range
6221 <tag/Notes/<itemize>
6222 <item>The function is only available as fastcall function, so it may only
6223 be used in presence of a prototype.
6224 <item>The function behaves unexpectedly or may crash if the angles are out
6227 <tag/Availability/cc65
6229 <ref id="tgi_bar" name="tgi_bar">,
6230 <ref id="tgi_circle" name="tgi_circle">,
6231 <ref id="tgi_ellipse" name="tgi_ellipse">,
6232 <ref id="tgi_pieslice" name="tgi_pieslice">,
6233 <ref id="tgi_setcolor" name="tgi_setcolor">
6235 /* Draw the upper half of an ellipse */
6236 tgi_setcolor(TGI_COLOR_BLUE);
6237 tgi_arc (50, 50, 40, 20, 0, 180);
6243 <sect1>tgi_bar<label id="tgi_bar"><p>
6247 <tag/Function/The function fills a rectangle on the drawpage with the current
6249 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6250 <tag/Declaration/<tt/void __fastcall__ tgi_bar (int x1, int y1, int x2, int y2);/
6251 <tag/Description/The function fills a rectangle on the drawpage with the current
6253 <tag/Notes/<itemize>
6254 <item>The function is only available as fastcall function, so it may only
6255 be used in presence of a prototype.
6257 <tag/Availability/cc65
6258 <tag/See also/Other tgi function
6260 tgi_setcolor(TGI_COLOR_GREEN);
6261 tgi_bar(10, 10, 100, 60);
6267 <sect1>tgi_circle<label id="tgi_circle"><p>
6271 <tag/Function/The function draws a circle in the current color.
6272 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6273 <tag/Declaration/<tt/void __fastcall__ tgi_circle (int x, int y, unsigned char radius);/
6274 <tag/Description/The function draws a circle in the current color.
6275 <tag/Notes/<itemize>
6276 <item>The function is only available as fastcall function, so it may only
6277 be used in presence of a prototype.
6279 <tag/Availability/cc65
6281 <ref id="tgi_arc" name="tgi_arc">,
6282 <ref id="tgi_bar" name="tgi_bar">,
6283 <ref id="tgi_ellipse" name="tgi_ellipse">,
6284 <ref id="tgi_pieslice" name="tgi_pieslice">,
6285 <ref id="tgi_setcolor" name="tgi_setcolor">
6287 tgi_setcolor(TGI_COLOR_BLACK);
6288 tgi_circle(50, 40, 40);
6294 <sect1>tgi_clear<label id="tgi_clear"><p>
6298 <tag/Function/Clear the drawpage
6299 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6300 <tag/Declaration/<tt/void tgi_clear (void);/
6301 <tag/Description/Clear the drawpage
6302 <tag/Availability/cc65
6303 <tag/See also/Other tgi functions
6309 <sect1>tgi_done<label id="tgi_done"><p>
6313 <tag/Function/End graphics mode, switch back to text mode.
6314 Will NOT uninstall or unload the driver!
6315 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6316 <tag/Declaration/<tt/void tgi_done (void);/
6317 <tag/Description/End graphics mode, switch back to text mode.
6318 Will NOT uninstall or unload the driver!
6319 <tag/Availability/cc65
6320 <tag/See also/Other tgi functions
6326 <sect1>tgi_ellipse<label id="tgi_ellipse"><p>
6330 <tag/Function/The function draws an ellipse in the current color.
6331 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6332 <tag/Declaration/<tt/void __fastcall__ tgi_ellipse (int x, int y, unsigned char rx, unsigned char ry);/
6333 <tag/Description/The function draws an ellipse at position x/y with radii
6334 rx and ry, using the current drawing color.
6335 <tag/Notes/<itemize>
6336 <item>The function is only available as fastcall function, so it may only
6337 be used in presence of a prototype.
6339 <tag/Availability/cc65
6341 <ref id="tgi_arc" name="tgi_arc">,
6342 <ref id="tgi_bar" name="tgi_bar">,
6343 <ref id="tgi_circle" name="tgi_circle">,
6344 <ref id="tgi_pieslice" name="tgi_pieslice">,
6345 <ref id="tgi_setcolor" name="tgi_setcolor">
6347 tgi_setcolor(TGI_COLOR_RED);
6348 tgi_ellipse (50, 40, 40, 20);
6354 <sect1>tgi_free_vectorfont<label id="tgi_free_vectorfont"><p>
6358 <tag/Function/Free a vector font that was previously loaded into memory.
6359 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6360 <tag/Declaration/<tt/void __fastcall__ tgi_free_vectorfont (const tgi_vectorfont* font);/
6361 <tag/Description/Free a vector font that was previously loaded into memory.
6362 <tag/Notes/<itemize>
6363 <item>The function is only available as fastcall function, so it may only
6364 be used in presence of a prototype.
6366 <tag/Availability/cc65
6368 <ref id="tgi_load_vectorfont" name="tgi_load_vectorfont">,
6369 <ref id="tgi_install_vectorfont" name="tgi_install_vectorfont">
6375 <sect1>tgi_getaspectratio<label id="tgi_getaspectratio"><p>
6377 <quote> <descrip> <tag/Function/Return the pixel aspect ratio.
6378 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6379 <tag/Declaration/<tt/unsigned tgi_getaspectratio (void);/
6380 <tag/Description/The function returns the pixel aspect ratio for the current
6381 driver and display as an 8.8 fixed point value. It may be used to correct
6382 geometric shapes so they look correct on the display. As an example, a circle
6383 with a radius of 100 pixels may look elliptic on some driver/display
6384 combinations if the aspect ratio is not 1.00.
6385 <tag/Notes/<itemize>
6386 <item>The aspect ratio is encoded in the TGI driver which assumes a "standard"
6387 monitor for the given platform. The aspect ratio may be wrong if another
6389 <item>No TGI function will use the aspect ratio. It is up to the programmer to
6391 <item>The <ref id="tgi_setaspectratio" name="tgi_setaspectratio"> function can
6392 be used to change the aspect ratio for a loaded driver. The value is not reset
6393 by <ref id="tgi_init" name="tgi_init">, so if a driver is linked statically to
6394 an application, switching into and out of graphics mode will not restore the
6395 original aspect ratio.
6397 <tag/Availability/cc65
6399 <ref id="tgi_setaspectratio" name="tgi_setaspectratio">
6405 <sect1>tgi_getcolor<label id="tgi_getcolor"><p>
6409 <tag/Function/Return the current drawing color.
6410 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6411 <tag/Declaration/<tt/unsigned char tgi_getcolor (void);/
6412 <tag/Description/The actual color is an index to a palette. During tgi_init
6413 you will get a default palette. The number of colors depend on the platform.
6414 All platforms recognize at least TGI_COLOR_BLACK and TGI_COLOR_WHITE. But some
6415 platforms have many more predefined colors. If you paint using TGI_COLOR_GREEN
6416 and then you change the green of the palette to blue using tgi_setpalette then
6417 after this painting in TGI_COLOR_GREEN will actually be blue.
6418 <tag/Availability/cc65
6419 <tag/See also/Other tgi functions
6421 color = tgi_getcolor();
6427 <sect1>tgi_getcolorcount<label id="tgi_getcolorcount"><p>
6431 <tag/Function/Get the number of available colors.
6432 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6433 <tag/Declaration/<tt/unsigned char tgi_getcolorcount (void);/
6434 <tag/Description/Tgi platforms use indexed color palettes. This function
6435 returns the number of entries we can use in the palette.
6436 <tag/Availability/cc65
6437 <tag/See also/Other tgi functions
6439 if (tgi_getcolorcount() == 2) {
6440 printf("Only monochrome graphics is supported\n");
6447 <sect1>tgi_getdefpalette<label id="tgi_getdefpalette"><p>
6451 <tag/Function/Get the palette installed by default.
6452 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6453 <tag/Declaration/<tt/const unsigned char* tgi_getdefpalette (void);/
6454 <tag/Description/The tgi driver has a default palette that is active at startup.
6455 The named colors TGI_COLOR_BLACK, TGI_COLOR_WHITE, TGI_COLOR_RED... need this
6456 palette to work correctly.
6457 <tag/Availability/cc65
6458 <tag/See also/Other tgi functions
6464 <sect1>tgi_geterror<label id="tgi_geterror"><p>
6468 <tag/Function/Return the error code for the last operation.
6469 This will also clear the error.
6470 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6471 <tag/Declaration/<tt/unsigned char tgi_geterror (void);/
6472 <tag/Description/Return the error code for the last operation.
6473 This will also clear the error.
6474 <tag/Availability/cc65
6475 <tag/See also/Other tgi functions
6481 <sect1>tgi_geterrormsg<label id="tgi_geterrormsg"><p>
6485 <tag/Function/Get an error message describing the error.
6486 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6487 <tag/Declaration/<tt/const char* __fastcall__ tgi_geterrormsg (unsigned char code);/
6488 <tag/Description/Get an error message describing the error.
6489 <tag/Notes/<itemize>
6490 <item>The function is only available as fastcall function, so it may only
6491 be used in presence of a prototype.
6493 <tag/Availability/cc65
6494 <tag/See also/Other tgi functions
6500 <sect1>tgi_getmaxcolor<label id="tgi_getmaxcolor"><p>
6504 <tag/Function/Get the highest index of the palette.
6505 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6506 <tag/Declaration/<tt/unsigned char tgi_getmaxcolor (void);/
6507 <tag/Description/Get the highest index of the palette.
6508 <tag/Availability/cc65
6509 <tag/See also/Other tgi functions
6515 <sect1>tgi_getmaxx<label id="tgi_getmaxx"><p>
6519 <tag/Function/Get the maximum x coordinate that can be used on this screen.
6520 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6521 <tag/Declaration/<tt/unsigned tgi_getmaxx (void);/
6522 <tag/Description/Get the maximum x coordinate that can be used on this screen.
6523 <tag/Availability/cc65
6524 <tag/See also/Other tgi functions
6530 <sect1>tgi_getmaxy<label id="tgi_getmaxy"><p>
6534 <tag/Function/Get the maximum y coordinate that can be used on this screen.
6535 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6536 <tag/Declaration/<tt/unsigned tgi_getmaxy (void);/
6537 <tag/Description/Get the maximum y coordinate that can be used on this screen.
6538 <tag/Availability/cc65
6539 <tag/See also/Other tgi functions
6545 <sect1>tgi_getpagecount<label id="tgi_getpagecount"><p>
6549 <tag/Function/Return the number of screen pages available.
6550 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6551 <tag/Declaration/<tt/unsigned tgi_getpagecount (void);/
6552 <tag/Description/Return the number of screen pages available.
6553 <tag/Availability/cc65
6555 <ref id="tgi_setdrawpage" name="tgi_setdrawpage">,
6556 <ref id="tgi_setviewpage" name="tgi_setviewpage">
6562 <sect1>tgi_getpalette<label id="tgi_getpalette"><p>
6566 <tag/Function/Get the palette installed.
6567 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6568 <tag/Declaration/<tt/const unsigned char* tgi_getpalette (void);/
6569 <tag/Description/Get the palette installed.
6570 <tag/Availability/cc65
6571 <tag/See also/Other tgi functions
6577 <sect1>tgi_getpixel<label id="tgi_getpixel"><p>
6581 <tag/Function/Get the color of a pixel from the viewpage.
6582 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6583 <tag/Declaration/<tt/unsigned char __fastcall__ tgi_getpixel (int x, int y);/
6584 <tag/Description/Get the color of a pixel from the viewpage.
6585 <tag/Notes/<itemize>
6586 <item>The function is only available as fastcall function, so it may only
6587 be used in presence of a prototype.
6589 <tag/Availability/cc65
6590 <tag/See also/Other tgi functions.
6596 <sect1>tgi_getxres<label id="tgi_getxres"><p>
6600 <tag/Function/Get number of horisontal pixels on the screen.
6601 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6602 <tag/Declaration/<tt/unsigned tgi_getxres (void);/
6603 <tag/Description/Get number of horisontal pixels on the screen.
6604 This is same as tgi_maxx()+1.
6605 <tag/Availability/cc65
6606 <tag/See also/Other tgi functions.
6612 <sect1>tgi_getyres<label id="tgi_getyres"><p>
6616 <tag/Function/Get number of vertical pixels on the screen.
6617 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6618 <tag/Declaration/<tt/unsigned tgi_getyres (void);/
6619 <tag/Description/Get number of vertical pixels on the screen.
6620 This is same as tgi_maxy()+1.
6621 <tag/Availability/cc65
6622 <tag/See also/Other tgi functions.
6628 <sect1>tgi_gotoxy<label id="tgi_gotoxy"><p>
6632 <tag/Function/Set graphics cursor at x, y.
6633 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6634 <tag/Declaration/<tt/void __fastcall__ tgi_gotoxy (int x, int y);/
6635 <tag/Description/Set graphics cursor at x, y.
6636 <tag/Notes/<itemize>
6637 <item>The function is only available as fastcall function, so it may only
6638 be used in presence of a prototype.
6640 <tag/Availability/cc65
6641 <tag/See also/Other tgi functions.
6647 <sect1>tgi_init<label id="tgi_init"><p>
6651 <tag/Function/Initialize the already loaded graphics driver.
6652 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6653 <tag/Declaration/<tt/void tgi_init (void);/
6654 <tag/Description/The tgi_init function will set the default palette to the
6656 <tag/Notes/<itemize>
6657 <item><tt/tgi_init/ will not clear the screen. This allows switching between
6658 text and graphics mode on platforms that have separate memory areas for the
6659 screens. If you want the screen cleared, call <tt/<ref id="tgi_clear"
6660 name="tgi_clear">/ after <tt/tgi_init/.
6662 <tag/Availability/cc65
6663 <tag/See also/Other tgi functions.
6665 tgi_install(tgi_static_stddrv); //Include the driver statically instead of loading it.
6666 tgi_init(); //Set up the default palette and clear the screen.
6672 <sect1>tgi_install<label id="tgi_install"><p>
6676 <tag/Function/Install an already loaded driver and return an error code.
6677 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6678 <tag/Declaration/<tt/unsigned char __fastcall__ tgi_install (void* driver);/
6679 <tag/Description/The function installs a driver that was already loaded into
6680 memory (or linked statically to the program). It returns an error code
6681 (<tt/TGI_ERR_OK/ in case of success).
6682 <tag/Notes/<itemize>
6683 <item>The function is only available as fastcall function, so it may only be
6684 used in presence of a prototype.
6686 <tag/Availability/cc65
6688 <ref id="tgi_load_driver" name="tgi_load_driver">,
6689 <ref id="tgi_uninstall" name="tgi_uninstall">,
6690 <ref id="tgi_unload" name="tgi_unload">
6692 tgi_install(tgi_static_stddrv); //Include the driver statically instead of loading it.
6693 tgi_init(); //Set up the default palette and clear the screen.
6699 <sect1>tgi_install_vectorfont<label id="tgi_install_vectorfont"><p>
6703 <tag/Function/Install an already loaded driver and return an error code.
6704 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6705 <tag/Declaration/<tt/void __fastcall__ tgi_install_vectorfont (const tgi_vectorfont* font);/
6707 Install a vector font for use. More than one vector font can be loaded,
6708 but only one can be active. This function is used to tell which one. Call
6709 with a NULL pointer to uninstall the currently installed font.
6710 <tag/Notes/<itemize>
6711 <item>The function is only available as fastcall function, so it may only be
6712 used in presence of a prototype.
6714 <tag/Availability/cc65
6716 <ref id="tgi_load_vectorfont" name="tgi_load_vectorfont">,
6717 <ref id="tgi_free_vectorfont" name="tgi_free_vectorfont">
6723 <sect1>tgi_ioctl<label id="tgi_ioctl"><p>
6727 <tag/Function/Platform dependent code extensions.
6728 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6729 <tag/Declaration/<tt/unsigned __fastcall__ tgi_ioctl (unsigned char code, void* data);/
6730 <tag/Description/Some platforms have extra display hardware that is not
6731 supported by standard tgi functions. You can extend the driver to support
6732 this extra hardware using tgi_ioctl functions.
6733 <tag/Notes/<itemize>
6734 <item>The function is only available as fastcall function, so it may only
6735 be used in presence of a prototype.
6736 <item>These functions are not easily portable to other cc65 platforms.
6738 <tag/Availability/cc65
6739 <tag/See also/Other tgi functions.
6741 #define tgi_sprite(spr) tgi_ioctl(0, (void*)(spr))
6742 #define tgi_flip() tgi_ioctl(1, (void*)0)
6743 #define tgi_setbgcolor(bgcol) tgi_ioctl(2, (void*)(bgcol))
6744 #define tgi_setframerate(rate) tgi_ioctl(3, (void*)(rate))
6745 #define tgi_busy() tgi_ioctl(4, (void*)0)
6746 #define tgi_updatedisplay() tgi_ioctl(4, (void*)1)
6748 tgi_sprite(&background);
6749 tgi_setcolor(TGI_COLOR_BLUE);
6750 tgi_outttextxy(20,40,"Hello World");
6751 tgi_updatedisplay();
6758 <sect1>tgi_line<label id="tgi_line"><p>
6762 <tag/Function/Draw a line in the current drawing color.
6763 The graphics cursor will be set to x2/y2 by this call.
6764 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6765 <tag/Declaration/<tt/void __fastcall__ tgi_line (int x1, int y1, int x2, int y2);/
6766 <tag/Description/Draw a line in the current drawing color.
6767 The graphics cursor will be set to x2/y2 by this call.
6768 <tag/Notes/<itemize>
6769 <item>The function is only available as fastcall function, so it may only
6770 be used in presence of a prototype.
6772 <tag/Availability/cc65
6773 <tag/See also/Other tgi functions.
6779 <sect1>tgi_lineto<label id="tgi_lineto"><p>
6783 <tag/Function/Draw a line in the current drawing color from the graphics
6784 cursor to the new end point. The graphics cursor will be updated to x2/y2.
6785 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6786 <tag/Declaration/<tt/void __fastcall__ tgi_lineto (int x2, int y2);/
6787 <tag/Description/Draw a line in the current drawing color from the graphics
6788 cursor to the new end point. The graphics cursor will be updated to x2/y2.
6789 <tag/Notes/<itemize>
6790 <item>The function is only available as fastcall function, so it may only
6791 be used in presence of a prototype.
6793 <tag/Availability/cc65
6794 <tag/See also/Other tgi functions.
6800 <sect1>tgi_load_driver<label id="tgi_load_driver"><p>
6804 <tag/Function/Load and install the given driver.
6805 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6806 <tag/Declaration/<tt/void __fastcall__ tgi_load_driver (const char *name);/
6807 <tag/Description/Load and install the driver by name.
6808 Will just load the driver and check if loading was successful.
6809 Will not switch to graphics mode.
6810 <tag/Notes/<itemize>
6811 <item>The function is only available as fastcall function, so it may only
6812 be used in presence of a prototype.
6814 <tag/Availability/cc65
6815 <tag/See also/Other tgi functions.
6821 <sect1>tgi_load_vectorfont<label id="tgi_load_vectorfont"><p>
6825 <tag/Function/Load the given vector font.
6826 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6827 <tag/Declaration/<tt/const tgi_vectorfont* __fastcall__ tgi_load_vectorfont (const char* name);/
6829 Load a vector font into memory and return it. In case of errors, NULL is
6830 returned and an error is set, which can be retrieved using tgi_geterror.
6831 To use the font, it has to be installed using tgi_install_vectorfont.
6832 <tag/Notes/<itemize>
6833 <item>The function is only available as fastcall function, so it may only
6834 be used in presence of a prototype.
6836 <tag/Availability/cc65
6838 <ref id="tgi_install_vectorfont" name="tgi_install_vectorfont">,
6839 <ref id="tgi_free_vectorfont" name="tgi_free_vectorfont">
6845 <sect1>tgi_outtext<label id="tgi_outtext"><p>
6849 <tag/Function/Output text at the current graphics cursor position.
6850 The graphics cursor is moved to the end of the text.
6851 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6852 <tag/Declaration/<tt/void __fastcall__ tgi_outtext (const char* s);/
6853 <tag/Description/Output text at the current graphics cursor position.
6854 The graphics cursor is moved to the end of the text.
6855 <tag/Notes/<itemize>
6856 <item>The function is only available as fastcall function, so it may only
6857 be used in presence of a prototype.
6859 <tag/Availability/cc65
6860 <tag/See also/Other tgi functions.
6866 <sect1>tgi_outtextxy<label id="tgi_outtextxy"><p>
6870 <tag/Function/Output text at the given cursor position.
6871 The graphics cursor is moved to the end of the text.
6872 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6873 <tag/Declaration/<tt/void __fastcall__ tgi_outtextxy (int x, int y, const char* s);/
6874 <tag/Description/Output text at the given cursor position.
6875 The graphics cursor is moved to the end of the text.
6876 <tag/Notes/<itemize>
6877 <item>The function is only available as fastcall function, so it may only
6878 be used in presence of a prototype.
6880 <tag/Availability/cc65
6881 <tag/See also/Other tgi functions.
6887 <sect1>tgi_pieslice<label id="tgi_pieslice"><p>
6891 <tag/Function/Draw an elliptic pie slice in the current color.
6892 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6893 <tag/Declaration/<tt/void __fastcall__ tgi_pie slice (int x, int y,
6894 unsigned char rx, unsigned char ry, unsigned sa, unsigned ea);/
6895 <tag/Description/The function draws an elliptic pie slice with center at x/y
6896 and radii rx/ry using the current drawing color. The pie slice covers the angle
6897 between sa and ea (startangle and endangle), which must be in the range
6899 <tag/Notes/<itemize>
6900 <item>The function is only available as fastcall function, so it may only
6901 be used in presence of a prototype.
6902 <item>The function behaves unexpectedly or may crash if the angles are out
6905 <tag/Availability/cc65
6907 <ref id="tgi_bar" name="tgi_arc">,
6908 <ref id="tgi_bar" name="tgi_bar">,
6909 <ref id="tgi_circle" name="tgi_circle">,
6910 <ref id="tgi_ellipse" name="tgi_ellipse">,
6911 <ref id="tgi_setcolor" name="tgi_setcolor">
6913 /* Draw the closed upper half of an ellipse */
6914 tgi_setcolor(TGI_COLOR_BLUE);
6915 tgi_pieslice (50, 50, 40, 20, 0, 180);
6921 <sect1>tgi_setaspectratio<label id="tgi_setaspectratio"><p>
6923 <quote> <descrip> <tag/Function/Set the pixel aspect ratio.
6924 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6925 <tag/Declaration/<tt/void __fastcall__ tgi_setaspectratio (unsigned ratio);/
6926 <tag/Description/The function sets the pixel aspect ratio for the current
6927 driver and display. The argument is an 8.8 fixed point value. The aspect ratio
6928 may be used to correct geometric shapes so they look correct on a given
6929 display. As an example, a circle with a radius of 100 pixels may look elliptic
6930 on some driver/display combinations if the aspect ratio is not 1.00.
6931 <tag/Notes/<itemize>
6932 <item>The aspect ratio is encoded in the TGI driver which assumes a "standard"
6933 monitor for the given platform. The aspect ratio may be wrong if another
6935 <item>No TGI function will use the aspect ratio. It is up to the programmer to
6937 <item>The <tt/tgi_setaspectratio/ function can be used to change the aspect
6938 ratio for a loaded driver. The value is not reset by <ref id="tgi_init"
6939 name="tgi_init">, so if a driver is linked statically to an application,
6940 switching into and out of graphics mode will not restore the original aspect
6942 <item>The function is available only as a fastcall function; so, it may be used
6943 only in the presence of a prototype.
6945 <tag/Availability/cc65
6947 <ref id="tgi_getaspectratio" name="tgi_getaspectratio">
6953 <sect1>tgi_setcolor<label id="tgi_setcolor"><p>
6957 <tag/Function/Set color to be used in future draw operations.
6958 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6959 <tag/Declaration/<tt/void __fastcall__ tgi_setcolor (unsigned char color);/
6960 <tag/Description/Set color to be used in future draw operations.
6961 <tag/Notes/<itemize>
6962 <item>The function is only available as fastcall function, so it may only
6963 be used in presence of a prototype.
6965 <tag/Availability/cc65
6966 <tag/See also/Other tgi functions.
6968 tgi_setcolor(TGI_COLOR_BLACK);
6970 tgi_setcolor(TGI_COLOR_WHITE);
6971 tgi_bar(10,10,20,20);
6976 <sect1>tgi_setdrawpage<label id="tgi_setdrawpage"><p>
6980 <tag/Function/Set the page for drawing.
6981 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6982 <tag/Declaration/<tt/void __fastcall__ tgi_setdrawpage (unsigned char page);/
6983 <tag/Description/If the drawpage and the viewpage are the same then all drawing
6984 is seen immediately as it is drawn. For double buffered games you can set the
6985 drawpage to a different page than the viewpage. This lets you draw the next
6986 screen in the background and when the screen is ready you display it.
6987 <tag/Notes/<itemize>
6988 <item>The function is only available as fastcall function, so it may only
6989 be used in presence of a prototype.
6991 <tag/Availability/cc65
6992 <tag/See also/Other tgi functions.
6995 tgi_outtextxy(10, 10, "Hello World");
6996 tgi_setviewpage(1); // Show page 1
6998 tgi_outtextxy(10, 10, "Creating next frame");
7000 tgi_setviewpage(0); // Show page 0
7005 <sect1>tgi_setpalette<label id="tgi_setpalette"><p>
7009 <tag/Function/Set the palette (not available with all drivers/hardware).
7010 Palette is a pointer to as many entries as there are colors.
7011 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
7012 <tag/Declaration/<tt/void __fastcall__ tgi_setpalette (const unsigned char* palette);/
7013 <tag/Description/Set the palette (not available with all drivers/hardware).
7014 Palette is a pointer to as many entries as there are colors.
7015 <tag/Notes/<itemize>
7016 <item>The function is only available as fastcall function, so it may only
7017 be used in presence of a prototype.
7019 <tag/Availability/cc65
7020 <tag/See also/Other tgi functions.
7025 <sect1>tgi_setpixel<label id="tgi_setpixel"><p>
7029 <tag/Function/Plot a pixel on the drawpage with the current color.
7030 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
7031 <tag/Declaration/<tt/void __fastcall__ tgi_setpixel (int x, int y);/
7032 <tag/Description/Plot a pixel on the drawpage with the current color.
7033 <tag/Notes/<itemize>
7034 <item>The function is only available as fastcall function, so it may only
7035 be used in presence of a prototype.
7037 <tag/Availability/cc65
7038 <tag/See also/Other tgi functions.
7043 <sect1>tgi_setviewpage<label id="tgi_setviewpage"><p>
7047 <tag/Function/Set page to be visible on screen.
7048 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
7049 <tag/Declaration/<tt/void __fastcall__ tgi_setviewpage (unsigned char page);/
7050 <tag/Description/If the drawpage and the viewpage are the same then all drawing
7051 is seen immediately as it is drawn. For double buffered games you can set the
7052 drawpage to a different page than the viewpage. This lets you draw the next
7053 screen in the background and when the screen is ready you display it.
7054 <tag/Notes/<itemize>
7055 <item>The function is only available as fastcall function, so it may only
7056 be used in presence of a prototype.
7058 <tag/Availability/cc65
7059 <tag/See also/Other tgi functions.
7062 tgi_outtextxy(10, 10, "Hello World");
7063 tgi_setviewpage(1); // Show page 1
7065 tgi_outtextxy(10, 10, "Creating next frame");
7067 tgi_setviewpage(0); // Show page 0
7072 <sect1>tgi_gettextheight<label id="tgi_gettextheight"><p>
7076 <tag/Function/Calculate the height of the text in pixels according to
7077 the current text style.
7078 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
7079 <tag/Declaration/<tt/unsigned __fastcall__ tgi_gettextheight (const char* s);/
7080 <tag/Description/Calculate the height of the text in pixels according to
7081 the current text style.
7082 <tag/Notes/<itemize>
7083 <item>The function is only available as fastcall function, so it may only
7084 be used in presence of a prototype.
7086 <tag/Availability/cc65
7087 <tag/See also/Other tgi functions.
7092 <sect1>tgi_settextscale<label id="tgi_settextscale"><p>
7096 <tag/Function/Set the scaling for text output.
7097 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
7098 <tag/Declaration/<tt/void __fastcall__ tgi_settextscale (unsigned width, unsigned height);/
7100 Set the scaling for text output. The scaling factors for width and height
7101 are 8.8 fixed point values. This means that $100 = 1 $200 = 2 etc.
7102 <tag/Notes/<itemize>
7103 <item>The function is only available as fastcall function, so it may only
7104 be used in presence of a prototype.
7106 <tag/Availability/cc65
7108 <ref id="tgi_settextstyle" name="tgi_settextstyle">
7113 <sect1>tgi_settextstyle<label id="tgi_settextstyle"><p>
7117 <tag/Function/Set the style for text output.
7118 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
7119 <tag/Declaration/<tt/void __fastcall__ tgi_settextstyle (unsigned char magx, unsigned char magy, unsigned char dir, unsigned char font);/
7120 <tag/Description/Set the style for text output.
7121 <tag/Notes/<itemize>
7122 <item>The function is only available as fastcall function, so it may only
7123 be used in presence of a prototype.
7125 <tag/Availability/cc65
7127 <ref id="tgi_settextscale" name="tgi_settextscale">
7132 <sect1>tgi_gettextwidth<label id="tgi_gettextwidth"><p>
7136 <tag/Function/Calculate the width of the text in pixels according to the current text style.
7137 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
7138 <tag/Declaration/<tt/unsigned __fastcall__ tgi_gettextwidth (const char* s);/
7139 <tag/Description/Calculate the width of the text in pixels according to the current text style.
7140 <tag/Notes/<itemize>
7141 <item>The function is only available as fastcall function, so it may only
7142 be used in presence of a prototype.
7144 <tag/Availability/cc65
7145 <tag/See also/Other tgi functions.
7150 <sect1>tgi_uninstall<label id="tgi_uninstall"><p>
7154 <tag/Function/Uninstall the currently loaded driver but do not unload it.
7155 Will call tgi_done if necessary.
7156 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
7157 <tag/Declaration/<tt/void tgi_uninstall (void);/
7158 <tag/Description/Uninstall the currently loaded driver but do not unload it.
7159 Will call tgi_done if necessary.
7160 <tag/Availability/cc65
7161 <tag/See also/Other tgi functions.
7166 <sect1>tgi_unload<label id="tgi_unload"><p>
7170 <tag/Function/Uninstall, then unload the currently loaded driver.
7171 Will call tgi_done if necessary.
7172 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
7173 <tag/Declaration/<tt/void tgi_unload (void);/
7174 <tag/Description/Uninstall, then unload the currently loaded driver.
7175 Will call tgi_done if necessary.
7176 <tag/Availability/cc65
7177 <tag/See also/Other tgi functions.
7182 <sect1>time<label id="time"><p>
7186 <tag/Function/Get the time.
7187 <tag/Header/<tt/<ref id="time.h" name="time.h">/
7188 <tag/Declaration/<tt/time_t __fastcall__ time (time_t* t);/
7189 <tag/Description/The function returns the time since the 1970-01-01 00:00:00
7190 measured in seconds. If the pointer <tt/t/ is not <tt/NULL/, the function
7191 result will also be stored there. If no time is available, <tt/(time_t)-1/ is
7192 returned and <tt/errno/ is set to <tt/ENOSYS/.
7193 <tag/Notes/<itemize>
7194 <item>The function is only available as fastcall function, so it may
7195 only be used in presence of a prototype.
7196 <item>Many platforms supported by cc65 do not have a realtime clock, so the
7197 returned value may not be valid.
7199 <tag/Availability/ISO 9899
7201 <ref id="clock" name="clock">
7207 <sect1>toggle_videomode<label id="toggle_videomode"><p>
7211 <tag/Function/Toggle between 40 and 80 column mode.
7212 <tag/Header/<tt/<ref id="c128.h" name="c128.h">/
7213 <tag/Declaration/<tt/void toggle_videomode (void);/
7214 <tag/Description/Toggle between 40 and 80 column mode. The settings for the
7215 old mode (cursor position, color and so on) are saved and restored together
7217 <tag/Notes/<itemize>
7218 <item>The function is specific to the C128.
7219 <item>This function is deprecated. Please use <ref id="videomode"
7220 name="videomode"> instead!
7222 <tag/Availability/C128
7224 <ref id="fast" name="fast">,
7225 <ref id="slow" name="slow">,
7226 <ref id="videomode" name="videomode">
7232 <sect1>tolower<label id="tolower"><p>
7236 <tag/Function/Convert a character into its lower case representation.
7237 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
7238 <tag/Declaration/<tt/int __fastcall__ tolower (int c);/
7239 <tag/Description/The function returns the given character converted to lower
7240 case. If the given character is not a letter, it is returned unchanged.
7241 <tag/Notes/<itemize>
7242 <item>The function is only available as fastcall function, so it may
7243 only be used in presence of a prototype.
7245 <tag/Availability/ISO 9899
7247 <ref id="islower" name="islower">,
7248 <ref id="isupper" name="isupper">,
7249 <ref id="toupper" name="toupper">
7255 <sect1>toupper<label id="toupper"><p>
7259 <tag/Function/Convert a character into its upper case representation.
7260 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
7261 <tag/Declaration/<tt/int __fastcall__ toupper (int c);/
7262 <tag/Description/The function returns the given character converted to upper
7263 case. If the given character is not a letter, it is returned unchanged.
7264 <tag/Notes/<itemize>
7265 <item>The function is only available as fastcall function, so it may
7266 only be used in presence of a prototype.
7268 <tag/Availability/ISO 9899
7270 <ref id="islower" name="islower">,
7271 <ref id="isupper" name="isupper">,
7272 <ref id="tolower" name="tolower">
7278 <sect1>ultoa<label id="ultoa"><p>
7282 <tag/Function/Convert an unsigned long integer into a string.
7283 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
7284 <tag/Declaration/<tt/char* __fastcall__ ultoa (unsigned long val, char* buf, int radix);/
7285 <tag/Description/<tt/itoa/ converts the unsigned long integer <tt/val/ into a
7286 string using <tt/radix/ as the base.
7287 <tag/Notes/<itemize>
7288 <item>There are no provisions to prevent a buffer overflow.
7289 <item>The function is non standard, so it is not available in strict ANSI mode.
7290 You should probably use <tt/sprintf/ instead.
7291 <item>The function is only available as fastcall function, so it may only be
7292 used in presence of a prototype.
7294 <tag/Availability/cc65
7296 <ref id="atoi" name="atoi">,
7297 <ref id="atol" name="atol">,
7298 <ref id="itoa" name="itoa">,
7299 <ref id="ltoa" name="ltoa">,
7300 <ref id="utoa" name="utoa">
7306 <sect1>unlink<label id="unlink"><p>
7310 <tag/Function/Delete a file.
7311 <tag/Header/<tt/<ref id="unistd.h" name="unistd.h">/
7312 <tag/Declaration/<tt/int __fastcall__ unlink (const char* name);/
7313 <tag/Description/<tt/unlink/ deletes the file with the given name. On success,
7314 zero is returned. On error, -1 is returned and <tt/errno/ is set to an error
7315 code describing the reason for the failure.
7316 <tag/Notes/<itemize>
7317 <item>The use of this function is discouraged. Please use <tt/<ref id="remove"
7318 name="remove">/ instead, which is a native ANSI C function and does the same.
7319 <item>This function is not available on all cc65 targets (depends on the
7320 availability of file I/O).
7321 <item>The function is only available as fastcall function, so it may only
7322 be used in presence of a prototype.
7323 <item>Instead of <tt/unlink/, <tt/<ref id="remove" name="remove">/ should be
7324 used, which has the same semantics, but is more portable, because it conforms
7325 to the ISO C standard.
7327 <tag/Availability/POSIX 1003.1
7329 <ref id="remove" name="remove">
7332 #include <stdio.h>
7333 #include <unistd.h>
7335 #define FILENAME "helloworld"
7337 if (unlink (FILENAME) == 0) {
7338 printf ("We deleted %s successfully\n", FILENAME);
7340 printf ("There was a problem deleting %s\n", FILENAME);
7347 <sect1>utoa<label id="utoa"><p>
7351 <tag/Function/Convert an unsigned integer into a string.
7352 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
7353 <tag/Declaration/<tt/char* __fastcall__ utoa (unsigned val, char* buf, int radix);/
7354 <tag/Description/<tt/itoa/ converts the unsigned integer <tt/val/ into a string
7355 using <tt/radix/ as the base.
7356 <tag/Notes/<itemize>
7357 <item>There are no provisions to prevent a buffer overflow.
7358 <item>The function is non standard, so it is not available in strict ANSI mode.
7359 You should probably use <tt/sprintf/ instead.
7360 <item>The function is only available as fastcall function, so it may only be
7361 used in presence of a prototype.
7363 <tag/Availability/cc65
7365 <ref id="atoi" name="atoi">,
7366 <ref id="atol" name="atol">,
7367 <ref id="itoa" name="itoa">,
7368 <ref id="ltoa" name="ltoa">,
7369 <ref id="ultoa" name="ultoa">
7375 <sect1>vcprintf<label id="vcprintf"><p>
7379 <tag/Function/Formatted output to the console.
7380 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
7381 <tag/Declaration/<tt/int __fastcall__ vcprintf (const char* format, va_list ap);/
7382 <tag/Description/The arguments specified as a <tt/va_list/ are converted to
7383 text where necessary and formatted according to the format string given. The
7384 resulting string is output to the console. <tt/vcprintf/ supports the same
7385 format specifiers as <tt/vprintf/. <!-- <tt/<ref id="vprintf" name="vprintf">/. -->
7386 <tag/Notes/<itemize>
7387 <item>Like all other <tt/conio/ output functions, <tt/vcprintf/ distinguishes
7388 between <tt/\r/ and <tt/\n/.
7389 <item>The function is only available as fastcall function, so it may only be
7390 used in presence of a prototype.
7392 <tag/Availability/cc65
7394 <ref id="cprintf" name="cprintf">,
7395 <ref id="cputc" name="cputc">,
7396 <ref id="cputcxy" name="cputcxy">,
7397 <ref id="cputs" name="cputs">,
7398 <ref id="cputsxy" name="cputsxy">
7404 <sect1>videomode<label id="videomode"><p>
7408 <tag/Function/Switch to either 40 or 80 column mode.
7409 <tag/Header/<tt/<ref id="apple2enh.h" name="apple2enh.h">,
7410 <ref id="c128.h" name="c128.h">/
7411 <tag/Declaration/<tt/unsigned __fastcall__ videomode (unsigned Mode);/
7412 <tag/Description/Switch to 40 or 80 column mode depending on the argument. If
7413 the requested mode is already active, nothing happens. The old mode is returned
7415 <tag/Notes/<itemize>
7416 <item>The function is specific to the C128 and enhanced Apple //e.
7417 <item>This function replaces <ref id="toggle_videomode"
7418 name="toggle_videomode">.
7419 <item>The function is only available as fastcall function, so it may only be
7420 used in presence of a prototype.
7422 <tag/Availability/C128 and enhanced Apple //e
7424 <ref id="fast" name="fast">,
7425 <ref id="slow" name="slow">,
7426 <ref id="toggle_videomode" name="toggle_videomode">
7432 <sect1>wherex<label id="wherex"><p>
7436 <tag/Function/Return the current X position of the text mode cursor.
7437 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
7438 <tag/Declaration/<tt/unsigned char wherex (void);/
7439 <tag/Description/The function returns the current X position of the text mode
7440 cursor. Zero is returned for the leftmost screen position.
7441 <tag/Availability/cc65
7443 <ref id="gotox" name="gotox">,
7444 <ref id="gotoy" name="gotoy">,
7445 <ref id="gotoxy" name="gotoxy">,
7446 <ref id="wherey" name="wherey">
7452 <sect1>wherey<label id="wherey"><p>
7456 <tag/Function/Return the current Y position of the text mode cursor.
7457 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
7458 <tag/Declaration/<tt/unsigned char wherey (void);/
7459 <tag/Description/The function returns the current Y position of the text mode
7460 cursor. Zero is returned for the uppermost screen position.
7461 <tag/Availability/cc65
7463 <ref id="gotox" name="gotox">,
7464 <ref id="gotoy" name="gotoy">,
7465 <ref id="gotoxy" name="gotoxy">,
7466 <ref id="wherex" name="wherex">