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.
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
749 <item>The function is actually a macro.
751 <tag/Availability/cc65
753 <ref id="_DE_ISLBL" name="_DE_ISLBL">,
754 <ref id="_DE_ISLNK" name="_DE_ISLNK">,
755 <ref id="_DE_ISREG" name="_DE_ISREG">
761 <sect1>_DE_ISLBL<label id="_DE_ISLBL"><p>
765 <tag/Function/Determine if a directory entry specifies a disk label.
766 <tag/Header/<tt/<ref id="dirent.h" name="dirent.h">/
767 <tag/Declaration/<tt/int _DE_ISLBL(unsigned char type);/
768 <tag/Description/The function is called with the type of a directory entry
769 taken from a <tt/struct dirent/ and returns true if the entry designates
773 <item>The function is actually a macro.
775 <tag/Availability/cc65
777 <ref id="_DE_ISDIR" name="_DE_ISDIR">,
778 <ref id="_DE_ISLNK" name="_DE_ISLNK">,
779 <ref id="_DE_ISREG" name="_DE_ISREG">
785 <sect1>_DE_ISLNK<label id="_DE_ISLNK"><p>
789 <tag/Function/Determine if a directory entry specifies a link.
790 <tag/Header/<tt/<ref id="dirent.h" name="dirent.h">/
791 <tag/Declaration/<tt/int _DE_ISLNK(unsigned char type);/
792 <tag/Description/The function is called with the type of a directory entry
793 taken from a <tt/struct dirent/ and returns true if the entry designates
797 <item>The function is actually a macro.
799 <tag/Availability/cc65
801 <ref id="_DE_ISDIR" name="_DE_ISDIR">,
802 <ref id="_DE_ISLBL" name="_DE_ISLBL">,
803 <ref id="_DE_ISREG" name="_DE_ISREG">
809 <sect1>_DE_ISREG<label id="_DE_ISREG"><p>
813 <tag/Function/Determine if a directory entry specifies a regular file.
814 <tag/Header/<tt/<ref id="dirent.h" name="dirent.h">/
815 <tag/Declaration/<tt/int _DE_ISREG(unsigned char type);/
816 <tag/Description/The function is called with the type of a directory entry
817 taken from a <tt/struct dirent/ and returns true if the entry designates
821 <item>The function is actually a macro.
822 <item>A "regular file" means anything with data in it. This might still mean
823 that special processing is needed, when accessing the file. Relative files of
824 the CBM systems are classified as being "regular" files, for example.
826 <tag/Availability/cc65
828 <ref id="_DE_ISDIR" name="_DE_ISDIR">,
829 <ref id="_DE_ISLBL" name="_DE_ISLBL">,
830 <ref id="_DE_ISLNK" name="_DE_ISLNK">
836 <sect1>_heapadd<label id="_heapadd"><p>
840 <tag/Function/Add a block to the heap.
841 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
842 <tag/Declaration/<tt/void __fastcall__ _heapadd (void* mem, size_t size);/
843 <tag/Description/The function adds a block of raw memory to the heap.
846 <item>The minimum blocksize that can be added is 6 bytes; the function will
847 ignore smaller blocks.
849 <tag/Availability/cc65
851 <ref id="_heapblocksize" name="_heapblocksize">,
852 <ref id="_heapmaxavail" name="_heapmaxavail">,
853 <ref id="_heapmemavail" name="_heapmemavail">,
854 <ref id="calloc" name="calloc">,
855 <ref id="free" name="free">,
856 <ref id="malloc" name="malloc">,
857 <ref id="realloc" name="realloc">
863 <sect1>_heapblocksize<label id="_heapblocksize"><p>
867 <tag/Function/Return the size of an allocated block.
868 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
869 <tag/Declaration/<tt/size_t __fastcall__ _heapblocksize (const void* block);/
870 <tag/Description/The function returns the size of a block that must have
871 previously been allocated by <tt/<ref id="malloc" name="malloc">/, <tt/<ref
872 id="calloc" name="calloc">/ or <tt/<ref id="realloc" name="realloc">/.
875 <item>Passing a pointer to a block that was is not the result of one of the
876 allocation functions, or that has been free'd will give unpredicable results.
878 <tag/Availability/cc65
880 <ref id="_heapadd" name="_heapadd">,
881 <ref id="_heapmaxavail" name="_heapmaxavail">,
882 <ref id="_heapmemavail" name="_heapmemavail">,
883 <ref id="calloc" name="calloc">,
884 <ref id="free" name="free">,
885 <ref id="malloc" name="malloc">,
886 <ref id="realloc" name="realloc">
892 <sect1>_heapmaxavail<label id="_heapmaxavail"><p>
896 <tag/Function/Return the largest block that is available on the heap.
897 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
898 <tag/Declaration/<tt/size_t _heapmaxavail (void);/
899 <tag/Description/The function returns the size of the largest block that may
900 be allocated from the heap using <tt/<ref id="malloc" name="malloc">/.
901 <tag/Availability/cc65
903 <ref id="_heapadd" name="_heapadd">,
904 <ref id="_heapblocksize" name="_heapblocksize">,
905 <ref id="_heapmemavail" name="_heapmemavail">,
906 <ref id="calloc" name="calloc">,
907 <ref id="free" name="free">,
908 <ref id="malloc" name="malloc">,
909 <ref id="realloc" name="realloc">
915 <sect1>_heapmemavail<label id="_heapmemavail"><p>
919 <tag/Function/Return the total available space on the heap.
920 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
921 <tag/Declaration/<tt/size_t __fastcall__ _heapmemavail (void);/
922 <tag/Description/The function returns the total number of bytes available on
926 <item>This function is of less use than usually assumed, since the returned
927 heap space may be available but not in one block. So even if this function
928 says that several times more heap space is available than needed, <ref
929 id="malloc" name="malloc"> may still return <tt/NULL/.
931 <tag/Availability/cc65
933 <ref id="_heapadd" name="_heapadd">,
934 <ref id="_heapblocksize" name="_heapblocksize">,
935 <ref id="_heapmaxavail" name="_heapmaxavail">,
936 <ref id="calloc" name="calloc">,
937 <ref id="free" name="free">,
938 <ref id="malloc" name="malloc">,
939 <ref id="realloc" name="realloc">
945 <sect1>_poserror<label id="_poserror"><p>
949 <tag/Function/Print an error message for the error in <tt/_oserror/.
950 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
951 <tag/Declaration/<tt/void __fastcall__ _poserror (const char* msg);/
952 <tag/Description/<tt/_poserror/ prints an error message to <tt/stderr/. If
953 <tt/msg/ is not <tt/NULL/ and not an empty string, it is printed followed by
954 a colon and a blank. Then the error message for the current contents of
955 <tt/_oserror/ are printed followed by a newline. The message output is the
956 same as returned by <tt/<ref id="_stroserror" name="_stroserror">/ with an
957 argument of <tt/_oserror/.
960 <item>Since operating system specific error code are - you guessed it -
961 operating system specific, the value in <tt/_oserror/ and the message that is
962 printed depends on the cc65 target.
963 <item>The function is only available as fastcall function, so it may only
964 be used in presence of a prototype.
966 <tag/Availability/cc65
968 <ref id="_stroserror" name="_stroserror">,
969 <ref id="perror" name="perror">
975 <sect1>_randomize<label id="_randomize"><p>
979 <tag/Function/Initialize the pseudo random number generator.
980 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
981 <tag/Declaration/<tt/void _randomize (void);/
982 <tag/Description/The function initializes the random number generator with
983 a seed derived from fast changing hardware events, so the seed itself can be
984 considered random to a certain degree.
985 <tag/Limits/<itemize>
986 <item>The randomness of the seed depends on the machine hardware.
988 <tag/Availability/cc65
990 <ref id="rand" name="rand">,
991 <ref id="srand" name="srand">
997 <sect1>_stroserror<label id="_stroserror"><p>
1001 <tag/Function/Return a string describing an OS specific error code.
1002 <tag/Header/<tt/<ref id="string.h" name="string.h">/
1003 <tag/Declaration/<tt/const char* __fastcall__ _stroserror (unsigned char errcode);/
1004 <tag/Description/<tt/_stroserror/ will return a string describing the given
1005 operating system specific error code.
1006 <tag/Limits/<itemize>
1007 <item>Since operating system specific error code are - you guessed it -
1008 operating system specific, the parameter and the string returned depend on the
1010 <item>The function is only available as fastcall function, so it may only be
1011 used in presence of a prototype.
1013 <tag/Availability/cc65
1015 <ref id="strerror" name="strerror">
1021 <sect1>_swap<label id="_swap"><p>
1025 <tag/Function/Swap the contents of memory areas.
1026 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1027 <tag/Declaration/<tt/void __fastcall__ _swap (void* p, void* q, size_t size);/
1028 <tag/Description/<tt/_swap/ will swap (exchange) the contents of the two memory
1029 areas pointed to by <tt/p/ and <tt/q/. Both memory areas are assumed to be
1030 <tt/size/ bytes in size.
1031 <tag/Limits/<itemize>
1032 <item>The memory areas may not overlap, otherwise the results are undefined.
1033 <item>The function is only available as fastcall function, so it may only be
1034 used in presence of a prototype.
1036 <tag/Availability/cc65
1038 <ref id="memcpy" name="memcpy">,
1039 <ref id="memmove" name="memmove">
1045 <sect1>_sys<label id="_sys"><p>
1049 <tag/Function/Call a subroutine passing register values.
1050 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
1051 <tag/Declaration/<tt/void __fastcall__ _sys (struct regs* r);/
1052 <tag/Description/The function will call the subroutine at the address
1053 specified in the <tt/pc/ member of the passed <tt/regs/ structure. All
1054 registers and the CPU flags are set to the values given in the <tt/regs/
1055 structure. On return from the subroutine, the new values of the registers and
1056 flags are stored back overwriting the old values.
1057 <tag/Limits/<itemize>
1058 <item>Bits 4 and 5 of the flags value in the <tt/regs/ structure are ignored
1059 when calling the subroutine (they are unchanged from their current values).
1060 <item>The function is only available as fastcall function, so it may only be
1061 used in presence of a prototype.
1063 <tag/Availability/cc65
1069 <sect1>BRK<label id="BRK"><p>
1073 <tag/Function/Insert a 6502 BRK instrunction into the code.
1074 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
1075 <tag/Declaration/<tt/void BRK (void);/
1076 <tag/Description/The function will insert a 6502 BRK instruction into the code
1077 which may be used to trigger a debugger.
1078 <tag/Limits/<itemize>
1079 <item>The function is actually a macro.
1080 <item>The inserted instruction may lead to unexpected results if no debugger
1083 <tag/Availability/cc65
1085 <ref id="CLI" name="CLI">,
1086 <ref id="SEI" name="SEI">
1092 <sect1>CLI<label id="CLI"><p>
1096 <tag/Function/Insert a 6502 CLI instrunction into the code.
1097 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
1098 <tag/Declaration/<tt/void CLI (void);/
1099 <tag/Description/The function will insert a 6502 CLI instruction into the code,
1100 so interrupts are enabled. Enabling interrupts has no effects if they are
1101 already enabled (the default).
1102 <tag/Limits/<itemize>
1103 <item>The function is actually a macro.
1104 <item>Disabling interrupts may lead to unexpected results.
1106 <tag/Availability/cc65
1108 <ref id="BRK" name="BRK">,
1109 <ref id="SEI" name="SEI">
1115 <sect1>PEEK<label id="PEEK"><p>
1119 <tag/Function/Read a byte from memory.
1120 <tag/Header/<tt/<ref id="peekpoke.h" name="peekpoke.h">/
1121 <tag/Declaration/<tt/unsigned char PEEK (unsigned addr);/
1122 <tag/Description/The function will read the absolute memory given by <tt/addr/
1123 and return the value read.
1124 <tag/Limits/<itemize>
1125 <item>The function is actually a macro.
1126 <item>This function depends highly on the platform and environment.
1128 <tag/Availability/cc65
1130 <ref id="PEEKW" name="PEEKW">,
1131 <ref id="POKE" name="POKE">
1137 <sect1>PEEKW<label id="PEEKW"><p>
1141 <tag/Function/Read a word (two bytes) from memory.
1142 <tag/Header/<tt/<ref id="peekpoke.h" name="peekpoke.h">/
1143 <tag/Declaration/<tt/unsigned PEEKW (unsigned addr);/
1144 <tag/Description/The function will read the absolute memory given by <tt/addr/
1145 and return the value read. The byte read from the higher address is the high
1146 byte of the return value.
1147 <tag/Limits/<itemize>
1148 <item>The function is actually a macro.
1149 <item>This function depends highly on the platform and environment.
1150 <item>The order in which the two bytes are read is unspecified and may
1151 depend of the address expression used.
1153 <tag/Availability/cc65
1155 <ref id="PEEK" name="PEEK">,
1156 <ref id="POKE" name="POKE">
1162 <sect1>POKE<label id="POKE"><p>
1166 <tag/Function/Write a byte to memory.
1167 <tag/Header/<tt/<ref id="peekpoke.h" name="peekpoke.h">/
1168 <tag/Declaration/<tt/void POKE (unsigned addr, unsigned char val);/
1169 <tag/Description/The function writes the value <tt/val/ to the absolute
1170 memory address given by <tt/addr/.
1171 <tag/Limits/<itemize>
1172 <item>The function is actually a macro.
1173 <item>This function depends highly on the platform and environment.
1174 <item>Careless use will cause the program to act strange or may crash the
1177 <tag/Availability/cc65
1179 <ref id="PEEK" name="PEEK">,
1180 <ref id="POKEW" name="POKEW">
1186 <sect1>POKEW<label id="POKEW"><p>
1190 <tag/Function/Write a word (two bytes) to memory.
1191 <tag/Header/<tt/<ref id="peekpoke.h" name="peekpoke.h">/
1192 <tag/Declaration/<tt/void POKEW (unsigned addr, unsigned val);/
1193 <tag/Description/The function writes the value <tt/val/ to the absolute
1194 memory address given by <tt/addr/. The low byte of <tt/val/ is written to
1195 the <tt/addr/, the high byte is written to <tt/addr+1/.
1196 <tag/Limits/<itemize>
1197 <item>The function is actually a macro.
1198 <item>This function depends highly on the platform and environment.
1199 <item>Careless use will cause the program to act strange or may crash the
1201 <item>The order in which the two bytes are written is unspecified and may
1202 depend of the address expression used.
1204 <tag/Availability/cc65
1206 <ref id="PEEK" name="PEEK">,
1207 <ref id="POKE" name="POKE">
1213 <sect1>SEI<label id="SEI"><p>
1217 <tag/Function/Insert a 6502 SEI instrunction into the code.
1218 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
1219 <tag/Declaration/<tt/void SEI (void);/
1220 <tag/Description/The function will insert a 6502 SEI instruction into the code,
1221 so interrupts are disabled. Note that non maskable interrupts cannot be
1223 <tag/Limits/<itemize>
1224 <item>The function is actually a macro.
1225 <item>Disabling interrupts may lead to unexpected results.
1227 <tag/Availability/cc65
1229 <ref id="BRK" name="BRK">,
1230 <ref id="CLI" name="CLI">
1236 <sect1>abort<label id="abort"><p>
1240 <tag/Function/Terminates a program abnormally.
1241 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1242 <tag/Declaration/<tt/void abort (void);/
1243 <tag/Description/<tt/abort/ raises <tt/SIGABRT/, writes a termination message
1244 on stderr, then terminates the program with an exit code of 3.
1245 <tag/Availability/ISO 9899
1247 <ref id="assert" name="assert">,
1248 <ref id="exit" name="exit">,
1249 <ref id="raise" name="raise">
1255 <sect1>abs<label id="abs"><p>
1259 <tag/Function/Returns the absolute value of an integer.
1260 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1261 <tag/Declaration/<tt/int __fastcall__ abs (int v);/
1262 <tag/Description/<tt/abs/ returns the absolute value of the argument passed to
1264 <tag/Limits/<itemize>
1265 <item>The return value is undefined if <tt/INT_MIN/ is passed to the function.
1266 <item>The function is only available as fastcall function, so it may only be
1267 used in presence of a prototype.
1269 <tag/Availability/ISO 9899
1271 <ref id="labs" name="labs">
1277 <sect1>assert<label id="assert"><p>
1281 <tag/Function/Test a condition and possibly abort.
1282 <tag/Header/<tt/<ref id="assert.h" name="assert.h">/
1283 <tag/Declaration/<tt/void assert (int cond);/
1284 <tag/Description/<tt/assert/ is a macro that expands to a <tt/id/
1285 statement. If the condition evaluates t zero (false), assert prints a message
1286 on stderr and aborts the program.
1287 <tag/Limits/<itemize>
1288 <item>The function is actually a macro.
1290 <tag/Availability/ISO 9899
1292 <ref id="abort" name="abort">,
1293 <ref id="exit" name="exit">
1299 <sect1>atexit<label id="atexit"><p>
1303 <tag/Function/Register an exit function.
1304 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1305 <tag/Declaration/<tt/int __fastcall__ atexit (void (*exitfunc) (void));/
1306 <tag/Description/<tt/atexit/ registers the function pointed to by
1307 <tt/exitfunc/ as an exit function. Exit functions are called when the program
1308 terminates, they are called in LIFO order (the last function registered is
1309 called first). <tt/atexit/ returns zero on success and a nonzero value on
1311 <tag/Limits/<itemize>
1312 <item>A maximum of 5 exit functions can be registered.
1313 <item>There is no way to unregister an exit function.
1314 <item>The function is only available as fastcall function, so it may only be
1315 used in presence of a prototype.
1317 <tag/Availability/ISO 9899
1319 <ref id="abort" name="abort">,
1320 <ref id="exit" name="exit">
1326 <sect1>atmos_load<label id="atmos_load"><p>
1330 <tag/Function/Load Atmos tape.
1331 <tag/Header/<tt/<ref id="atmos.h" name="atmos.h">/
1332 <tag/Declaration/<tt/void __fastcall__ atmos_load(const char* name);/
1333 <tag/Description/<tt/atmos_load/ reads a memory block from tape.
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/Availability/cc65
1352 <ref id="atmos_load" name="atmos_load">
1354 atmos_save("hires", 0xa000, 0xc000);
1360 <sect1>atoi<label id="atoi"><p>
1364 <tag/Function/Convert a string to an integer.
1365 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1366 <tag/Declaration/<tt/int __fastcall__ atoi (const char* s);/
1367 <tag/Description/<tt/atoi/ converts the given string into an integer.
1368 Conversion stops as soon as any invalid character is encountered.
1369 <tag/Limits/<itemize>
1370 <item>There is no way to detect any conversion errors.
1371 <item>The function does not check for an numerical overflow when converting.
1372 <item>The function is only available as fastcall function, so it may only be
1373 used in presence of a prototype.
1375 <tag/Availability/ISO 9899
1377 <ref id="atol" name="atol">,
1378 <ref id="itoa" name="itoa">,
1379 <ref id="ltoa" name="ltoa">,
1380 <ref id="ultoa" name="ultoa">,
1381 <ref id="utoa" name="utoa">
1387 <sect1>atol<label id="atol"><p>
1391 <tag/Function/Convert a string to a long integer.
1392 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1393 <tag/Declaration/<tt/long __fastcall__ atol (const char* s);/
1394 <tag/Description/<tt/atol/ converts the given string into a long integer.
1395 Conversion stops as soon as any invalid character is encountered.
1396 <tag/Limits/<itemize>
1397 <item>There is no way to detect any conversion errors.
1398 <item>The function does not check for an numerical overflow when converting.
1399 <item>The function is only available as fastcall function, so it may only be
1400 used in presence of a prototype.
1402 <tag/Availability/ISO 9899
1404 <ref id="atoi" name="atoi">,
1405 <ref id="itoa" name="itoa">,
1406 <ref id="ltoa" name="ltoa">,
1407 <ref id="ultoa" name="ultoa">,
1408 <ref id="utoa" name="utoa">
1414 <sect1>bgcolor<label id="bgcolor"><p>
1418 <tag/Function/Set the background text color.
1419 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1420 <tag/Declaration/<tt/unsigned char __fastcall__ bgcolor (unsigned char color);/
1421 <tag/Description/The function will set a new background color and return the
1422 old (current) one. The background color is valid for the whole text output
1423 area of the screen, not just for new text.
1424 <tag/Limits/<itemize>
1425 <item>Background colors are system dependent. The function may have no effect
1426 on systems where the background color cannot be changed.
1427 <item>The function is only available as fastcall function, so it may only be
1428 used in presence of a prototype.
1430 <tag/Availability/cc65
1432 <ref id="bordercolor" name="bordercolor">,
1433 <ref id="textcolor" name="textcolor">
1439 <sect1>bordercolor<label id="bordercolor"><p>
1443 <tag/Function/Set the border (frame) color.
1444 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1445 <tag/Declaration/<tt/unsigned char __fastcall__ bordercolor (unsigned char color);/
1446 <tag/Description/The function will set a new border color. It returns the old
1447 (current) border color.
1448 <tag/Limits/<itemize>
1449 <item>Border colors are system dependent. The function may have no effect
1450 on systems where the border color cannot be changed.
1451 <item>The function is only available as fastcall function, so it may only
1452 be used in presence of a prototype.
1454 <tag/Availability/cc65
1456 <ref id="bgcolor" name="bgcolor">,
1457 <ref id="textcolor" name="textcolor">
1463 <sect1>bsearch<label id="bsearch"><p>
1467 <tag/Function/Do a binary search in a sorted array.
1468 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1469 <tag/Declaration/<tt/void* __fastcall__ bsearch (const void* key,
1470 const void* base, size_t n, size_t size,
1471 int (*cmp) (const void*, const void*));/
1472 <tag/Description/<tt/bsearch/ searches a sorted array for a member that
1473 matches the one pointed to by <tt/key/. <tt/base/ is the address of the array,
1474 <tt/n/ is the number of elements, <tt/size/ the size of an element and <tt/cmp/
1475 the function used to compare the members against the key. The function returns
1476 a pointer to the member found, or <tt/NULL/ if there was no match.
1479 <item>The contents of the array must be sorted in ascending order according to
1480 the compare function given.
1481 <item>If there are multiple members that match the key, the function will
1482 return one of the members.
1483 <item>The function is only available as fastcall function, so it may only
1484 be used in presence of a prototype.
1486 <tag/Availability/ISO 9899
1488 <ref id="qsort" name="qsort">
1494 <sect1>bzero<label id="bzero"><p>
1498 <tag/Function/Fill a memory area with zeroes.
1499 <tag/Header/<tt/<ref id="string.h" name="string.h">/
1500 <tag/Declaration/<tt/void __fastcall__ bzero (void* p, size_t count);/
1501 <tag/Description/<tt/bzero/ fills the memory area pointed to by <tt/p/ with
1505 <item>The function is non standard and therefore only available in non ANSI
1506 mode. You should use <tt/<ref id="memset" name="memset">/ instead.
1507 <item>The function is only available as fastcall function, so it may only
1508 be used in presence of a prototype.
1510 <tag/Availability/cc65
1512 <ref id="_swap" name="_swap">,
1513 <ref id="memcpy" name="memcpy">,
1514 <ref id="memmove" name="memmove">,
1515 <ref id="memset" name="memset">,
1521 <sect1>c64mode<label id="c64mode"><p>
1525 <tag/Function/Switch the C128 into C64 compatible mode.
1526 <tag/Header/<tt/<ref id="c128.h" name="c128.h">/
1527 <tag/Declaration/<tt/void c64mode (void);/
1528 <tag/Description/The function will cause the machine to reboot into C64 mode.
1529 <tag/Limits/<itemize>
1530 <item>The function is specific to the C128.
1531 <item>The function will not return to the caller.
1533 <tag/Availability/C128
1539 <sect1>calloc<label id="calloc"><p>
1543 <tag/Function/Allocate and clear memory.
1544 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1545 <tag/Declaration/<tt/void* __fastcall__ calloc (size_t n, size_t size);/
1546 <tag/Description/<tt/calloc/ allocates memory for an array of <tt/n/ elements
1547 of size <tt/size/, clears the whole block with binary zeroes and returns a
1548 pointer to it. On error (not enough memory available), <tt/calloc/ returns
1552 <item>Clearing the memory may not have the expected effect on all platforms:
1553 pointers in the block may not be <tt/NULL/ and floating point variables may
1554 not be zero (0.0). In other words: The "clearing" effect of this function
1555 should be used with care for portable programs.
1556 <item>The function is only available as fastcall function, so it may only
1557 be used in presence of a prototype.
1559 <tag/Availability/ISO 9899
1561 <ref id="_heapadd" name="_heapadd">,
1562 <ref id="_heapblocksize" name="_heapblocksize">,
1563 <ref id="_heapmaxavail" name="_heapmaxavail">,
1564 <ref id="_heapmemavail" name="_heapmemavail">,
1565 <ref id="free" name="free">,
1566 <ref id="malloc" name="malloc">,
1567 <ref id="realloc" name="realloc">
1573 <sect1>cbm_k_acptr<label id="cbm_k_acptr"><p>
1577 <tag/Function/Input byte from serial bus
1578 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
1579 <tag/Declaration/<tt/unsigned char cbm_k_acptr (void);/
1580 <tag/Description/The function returns a byte of data, which it
1581 gets from the current TALKer on the serial bus.
1582 In order to receive the data, the device must have previously been
1583 sent a command to TALK and a secondary address if it needs one.
1584 <tag/Limits/<itemize>
1587 <tag/Availability/cc65
1589 <ref id="cbm_k_talk" name="cbm_k_talk">,
1595 <sect1>cbm_k_basin<label id="cbm_k_basin"><p>
1599 <tag/Function/Input a Character from the Current Device
1600 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
1601 <tag/Declaration/<tt/unsigned char cbm_k_basin (void);/
1602 <tag/Description/The function returns a character from the current input device.
1603 Device must first have been OPENed and then designated as the input channel by the CHKIN routine.
1604 When this function is called, the next byte of data available from the device is returned.
1605 Exception is the routine for the keyboard device (which is the default input device).
1606 <tag/Limits/<itemize>
1609 <tag/Availability/cc65
1611 <ref id="cbm_k_open" name="cbm_k_open">,
1612 <ref id="cbm_k_chkin" name="cbm_k_chkin">
1618 <sect1>cbm_k_bsout<label id="cbm_k_bsout"><p>
1622 <tag/Function/Output a byte
1623 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
1624 <tag/Declaration/<tt/void __fastcall__ cbm_k_bsout (unsigned char C);/
1625 <tag/Description/Function sends the character to the current output device.
1626 Unless a device has been OPENed and designated as the
1627 current output channel using the CHKOUT routine, the character is
1628 printed to the screen, which is the default output device. If the
1629 cassette is the current device, outputting a byte will only add it to
1630 the buffer. No actual transmission of data will occur until the
1631 192-byte buffer is full.
1632 <tag/Limits/<itemize>
1633 <item>The function is only available as fastcall function, so it may
1634 only be used in presence of a prototype.
1636 <tag/Availability/cc65
1638 <ref id="cbm_k_open" name="cbm_k_open">,
1639 <ref id="cbm_k_chkin" name="cbm_k_chkout">
1645 <sect1>cbm_k_chkin<label id="cbm_k_chkin"><p>
1649 <tag/Function/Designate a Logical File As the Current Input Channel
1650 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
1651 <tag/Declaration/<tt/unsigned char __fastcall__ cbm_k_chkin (unsigned char FN);/
1652 <tag/Description/If you wish to
1653 get data from any device other than the keyboard, this function must be
1654 called after OPENing the device, before you can get a data byte with
1655 the cbm_k_basin or cbm_k_getin routine. When called, the routine will designate
1656 the logical file whose file number was supplied as the
1657 current file, its device as the current device, and its secondary
1658 address as the current secondary address. If the device on the
1659 channel is a serial device, which requires a TALK command and
1660 sometimes a secondary address, function will send them over the
1662 <tag/Limits/<itemize>
1663 <item>The function is only available as fastcall function, so it may
1664 only be used in presence of a prototype.
1666 <tag/Availability/cc65
1668 <ref id="cbm_k_open" name="cbm_k_open">,
1669 <ref id="cbm_k_basin" name="cbm_k_basin">,
1670 <ref id="cbm_k_getin" name="cbm_k_getin">
1676 <sect1>cbm_k_ciout<label id="cbm_k_ciout"><p>
1680 <tag/Function/Transmit a byte over the serial bus
1681 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
1682 <tag/Declaration/<tt/void __fastcall__ cbm_k_ciout (unsigned char C);/
1683 <tag/Description/Purpose of this function is to send a byte of data over
1684 the serial bus. In order for the data to be received, the serial
1685 device must have first been commanded to LISTEN and been given a
1686 secondary address if necessary. This routine always buffers the
1687 current character, and defers sending it until the next byte is
1688 buffered. When the UNLISTEN command is sent, the last byte will be
1689 sent with an End or Identify (EOI).
1690 <tag/Limits/<itemize>
1691 <item>The function is only available as fastcall function, so it may
1692 only be used in presence of a prototype.
1694 <tag/Availability/cc65
1696 <ref id="cbm_k_listen" name="cbm_k_listen">,
1697 <ref id="cbm_k_unlsn" name="cbm_k_unlsn">
1703 <sect1>cbm_k_ckout<label id="cbm_k_ckout"><p>
1707 <tag/Function/Designate a Logical File As the Current Output Channel
1708 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
1709 <tag/Declaration/<tt/unsigned char __fastcall__ cbm_k_ckout (unsigned char FN);/
1710 <tag/Description/If you wish to
1711 output data to any device other than the screen, this routine must be
1712 called after OPENing the device, and before you output a data byte
1713 with the cbm_k_bsout() function. When called, the function will designate the
1714 logical file whose file number was supplied as the current
1715 file, its device as the current device, and its secondary address as
1716 the current secondary address. If the device on the channel uses the
1717 serial bus, and therefore requires a LISTEN command and possibly a
1718 secondary address, this information will be sent on the bus.
1719 <tag/Limits/<itemize>
1720 <item>The function is only available as fastcall function, so it may
1721 only be used in presence of a prototype.
1723 <tag/Availability/cc65
1725 <ref id="cbm_k_bsout" name="cbm_k_bsout">,
1726 <ref id="cbm_k_listen" name="cbm_k_listen">
1732 <sect1>cbm_k_clall<label id="cbm_k_clall"><p>
1736 <tag/Function/Close All Logical I/O Files
1737 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
1738 <tag/Declaration/<tt/void cbm_k_clall (void);/
1739 <tag/Description/It closes all
1740 open files, by resetting the index into open files to
1741 zero and restores the default I/O devices.
1742 <tag/Limits/<itemize>
1745 <tag/Availability/cc65
1747 <ref id="cbm_k_open" name="cbm_k_open">,
1748 <ref id="cbm_k_close" name="cbm_k_close">
1754 <sect1>cbm_k_close<label id="cbm_k_close"><p>
1758 <tag/Function/Close a Logical I/O File
1759 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
1760 <tag/Declaration/<tt/void __fastcall__ cbm_k_close (unsigned char FN);/
1761 <tag/Description/It is used to
1762 close a logical file after all I/O operations involving that file have
1764 <tag/Limits/<itemize>
1765 <item>The function is only available as fastcall function, so it may
1766 only be used in presence of a prototype.
1768 <tag/Availability/cc65
1770 <ref id="cbm_k_open" name="cbm_k_open">,
1771 <ref id="cbm_k_clall" name="cbm_k_clall">
1777 <sect1>cbm_k_clrch<label id="cbm_k_clrch"><p>
1781 <tag/Function/Restore Current Input and Output Devices to the Default Devices
1782 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
1783 <tag/Declaration/<tt/void cbm_k_clrch (void);/
1784 <tag/Description/It sets the
1785 current input device to the keyboard, and the current output device to
1786 the screen. Also, if the current input device was formerly a serial
1787 device, the routine sends it an UNTALK command on the serial bus, and
1788 if a serial device was formerly the current output device, the routine
1789 sends it an UNLISTEN command.
1790 <tag/Limits/<itemize>
1793 <tag/Availability/cc65
1795 <ref id="cbm_k_chkin" name="cbm_k_chkin">,
1796 <ref id="cbm_k_ckout" name="cbm_k_ckout">
1802 <sect1>cbm_k_getin<label id="cbm_k_getin"><p>
1806 <tag/Function/Get One Byte from the Input Device
1807 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
1808 <tag/Declaration/<tt/unsigned char cbm_k_getin (void);/
1809 <tag/Description/Function gets a character from the current input device.
1810 <tag/Limits/<itemize>
1813 <tag/Availability/cc65
1815 <ref id="cbm_k_basin" name="cbm_k_basin">
1821 <sect1>cbm_k_iobase<label id="cbm_k_iobase"><p>
1825 <tag/Function/Return Base Address of Memory-Mapped I/O Devices
1826 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
1827 <tag/Declaration/<tt/unsigned cbm_k_iobase (void);/
1828 <tag/Description/This function returns the address of
1829 the memory section where the memory mapped I/O devices are located. This
1830 address can then be used with an offset to access the memory mapped I/O
1831 devices in the Commodore 64. The offset is the number of locations from
1832 the beginning of the page on which the I/O register you want is located.
1833 This function exists to provide compatibility between the Commodore 64,
1834 VIC-20, and future models of the Commodore 64. If the I/O locations for
1835 a program are set by a call to this function, they should
1836 still remain compatible with future versions of the Commodore 64, the
1838 <tag/Limits/<itemize>
1841 <tag/Availability/cc65
1849 <sect1>cbm_k_listen<label id="cbm_k_listen"><p>
1853 <tag/Function/Command a device on the serial bus to LISTEN
1854 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
1855 <tag/Declaration/<tt/void __fastcall__ cbm_k_listen (unsigned char dev);/
1856 <tag/Description/This function will command a device on the serial bus to
1857 receive data. The KERNAL routine will OR the supplied device number bit by bit
1858 to convert it to a listen address, then transmits this data as a command on
1859 the serial bus. The specified device will then go into listen mode, and
1860 be ready to accept information.
1861 <tag/Limits/<itemize>
1862 <item>The function is only available as fastcall function, so it may
1863 only be used in presence of a prototype.
1865 <tag/Availability/cc65
1867 <ref id="cbm_k_unlsn" name="cbm_k_unlsn">,
1873 <sect1>cbm_k_load<label id="cbm_k_load"><p>
1877 <tag/Function/Load RAM from a Device
1878 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
1879 <tag/Declaration/<tt/unsigned int __fastcall__ cbm_k_load(unsigned char flag, unsigned addr);/
1880 <tag/Description/This function LOADs data bytes from any input device directly into the memory.
1881 It can also be used for a verify operation, comparing data from a device with the data already in
1882 memory, while leaving the data stored in RAM unchanged.
1883 The flag must be set to 0 for a LOAD operation, or 1 for a
1884 verify, If the input device is OPENed with a secondary address (SA) of 0
1885 the header information from the device is ignored. In this case, the starting address for the load must be supplied.
1886 If the device is addressed with a secondary address of 1, then the data is
1887 loaded into memory starting at the location specified by the header.
1888 Function returns the address of the highest RAM location loaded.
1889 Before this function can be called, the KERNAL SETLFS, and SETNAM
1890 routines must be called.
1891 <tag/Limits/<itemize>
1892 <item>The function is only available as fastcall function, so it may
1893 only be used in presence of a prototype.
1895 <tag/Availability/cc65
1897 <ref id="cbm_k_save" name="cbm_k_save">,
1898 <ref id="cbm_k_setlfs" name="cbm_k_setlfs">,
1899 <ref id="cbm_k_setnam" name="cbm_k_setnam">
1905 <sect1>cbm_k_open<label id="cbm_k_open"><p>
1909 <tag/Function/Open a Logical I/O File
1910 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
1911 <tag/Declaration/<tt/unsigned char cbm_k_open (void);/
1912 <tag/Description/This function assigns a logical file to a device, so that it can be used for
1913 Input/Output operations. In order to specify the logical file number,
1914 the device number, and the secondary address if any, the cbm_k_setlfs() function must first be called.
1915 Likewise, in order to designate the filename, the cbm_k_setnam() function must be used first. After these two
1916 functions are called, cbm_k_open() is then called.
1917 <tag/Limits/<itemize>
1920 <tag/Availability/cc65
1922 <ref id="cbm_k_close" name="cbm_k_close">,
1923 <ref id="cbm_k_setlfs" name="cbm_k_setlfs">,
1924 <ref id="cbm_k_setnam" name="cbm_k_setnam">
1930 <sect1>cbm_k_readst<label id="cbm_k_readst"><p>
1934 <tag/Function/Read status word
1935 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
1936 <tag/Declaration/<tt/unsigned char cbm_k_readst (void);/
1937 <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.
1938 <tag/Limits/<itemize>
1941 <tag/Availability/cc65
1949 <sect1>cbm_k_save<label id="cbm_k_save"><p>
1953 <tag/Function/Save RAM to a Device
1954 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
1955 <tag/Declaration/<tt/unsigned char __fastcall__ cbm_k_save(unsigned int start, unsigned int end)/
1956 <tag/Description/This function saves a section of memory. The cbm_k_setlfs() and cbm_k_setnam() functions must be
1957 used before calling this function. However, a file name is not required to
1958 SAVE to device 1 (the Datassette(TM) recorder). Any attempt to save to
1959 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.
1960 <tag/Limits/<itemize>
1961 <item>The function is only available as fastcall function, so it may
1962 only be used in presence of a prototype.
1964 <tag/Availability/cc65
1966 <ref id="cbm_k_load" name="cbm_k_load">,
1967 <ref id="cbm_k_setlfs" name="cbm_k_setlfs">,
1968 <ref id="cbm_k_setnam" name="cbm_k_setnam">
1974 <sect1>cbm_k_setlfs<label id="cbm_k_setlfs"><p>
1978 <tag/Function/Set up a logical file
1979 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
1980 <tag/Declaration/<tt/void __fastcall__ cbm_k_setlfs (unsigned char LFN, unsigned char DEV, unsigned char SA);/
1981 <tag/Description/This functions sets up the logical file by setting its number, device address,
1982 and secondary address.
1983 <tag/Limits/<itemize>
1984 <item>The function is only available as fastcall function, so it may
1985 only be used in presence of a prototype.
1987 <tag/Availability/cc65
1989 <ref id="cbm_k_setnam" name="cbm_k_setnam">
1995 <sect1>cbm_k_setnam<label id="cbm_k_setnam"><p>
1999 <tag/Function/Set Filename Parameters
2000 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
2001 <tag/Declaration/<tt/void __fastcall__ cbm_k_setnam (const char* Name);/
2002 <tag/Description/This function is used to set up the file name for the OPEN,
2003 SAVE, or LOAD operations.
2004 <tag/Limits/<itemize>
2005 <item>The function is only available as fastcall function, so it may
2006 only be used in presence of a prototype.
2008 <tag/Availability/cc65
2010 <ref id="cbm_k_open" name="cbm_k_open">,
2011 <ref id="cbm_k_load" name="cbm_k_load">,
2012 <ref id="cbm_k_save" name="cbm_k_save">
2018 <sect1>cbm_k_talk<label id="cbm_k_talk"><p>
2022 <tag/Function/Commands device to TALK
2023 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
2024 <tag/Declaration/<tt/void __fastcall__ cbm_k_talk (unsigned char dev);/
2025 <tag/Description/When called, it ORs the device number with the TALK code (64, $40) and sends it on the serial
2026 bus. This commands the device to TALK.
2027 <tag/Limits/<itemize>
2028 <item>The function is only available as fastcall function, so it may
2029 only be used in presence of a prototype.
2031 <tag/Availability/cc65
2033 <ref id="cbm_k_acptr" name="cbm_k_acptr">
2039 <sect1>cbm_k_unlsn<label id="cbm_k_unlsn"><p>
2043 <tag/Function/Send an UNLISTEN command
2044 <tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
2045 <tag/Declaration/<tt/void cbm_k_unlsn (void);/
2046 <tag/Description/This function commands all devices on the serial bus to
2047 stop receiving data from the host computer (i.e., UNLISTEN). Calling this
2048 function results in an UNLISTEN command being transmitted on the serial
2049 bus. Only devices previously commanded to LISTEN are affected. This
2050 function is normally used after the host computer is finished sending data
2051 to external devices. Sending the UNLISTEN commands the listening devices
2052 to get off the serial bus so it can be used for other purposes.
2053 <tag/Limits/<itemize>
2056 <tag/Availability/cc65
2058 <ref id="cbm_k_listen" name="cbm_k_listen">
2064 <sect1>cclear<label id="cclear"><p>
2068 <tag/Function/Clear part of a line (write a given number of spaces).
2069 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2070 <tag/Declaration/<tt/void __fastcall__ cclear (unsigned char length);/
2071 <tag/Description/The function clears part of a line by writing <tt/length/
2072 spaces in the current text color.
2073 <tag/Limits/<itemize>
2074 <item>The function is only available as fastcall function, so it may
2075 only be used in presence of a prototype.
2077 <tag/Availability/cc65
2079 <ref id="cclearxy" name="cclearxy">,
2080 <ref id="clrscr" name="clrscr">
2086 <sect1>cclearxy<label id="cclearxy"><p>
2090 <tag/Function/Clear part of a line (write a given number of spaces) starting
2091 at a specific screen position.
2092 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2093 <tag/Declaration/<tt/void __fastcall__ cclearxy (unsigned char x, unsigned char y, unsigned char length);/
2094 <tag/Description/The function moves the cursor to a specific position, and
2095 will then clear part of the line by writing <tt/length/ spaces in the current
2097 <tag/Limits/<itemize>
2098 <item>The function is only available as fastcall function, so it may
2099 only be used in presence of a prototype.
2101 <tag/Availability/cc65
2103 <ref id="cclear" name="cclear">,
2104 <ref id="clrscr" name="clrscr">
2110 <sect1>cgetc<label id="cgetc"><p>
2114 <tag/Function/Read a character from the keyboard.
2115 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2116 <tag/Declaration/<tt/char cgetc (void);/
2117 <tag/Description/The function reads a character from the keyboard. If there is
2118 no character available, <tt/cgetc/ waits until the user presses a key. If the
2119 cursor is enabled by use of the <tt/cursor/ function, a blinking cursor is
2120 displayed while waiting.
2121 <tag/Limits/<itemize>
2122 <item>If the system supports a keyboard buffer, <tt/cgetc/ will fetch a key
2123 from this buffer and wait only if the buffer is empty.
2125 <tag/Availability/cc65
2127 <ref id="cursor" name="cursor">,
2128 <ref id="kbhit" name="kbhit">
2134 <sect1>chline<label id="chline"><p>
2138 <tag/Function/Output a horizontal line in text mode.
2139 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2140 <tag/Declaration/<tt/void __fastcall__ chline (unsigned char length);/
2141 <tag/Description/The function outputs a horizontal line with the given length
2142 starting at the current cursor position.
2143 <tag/Limits/<itemize>
2144 <item>The character used to draw the horizontal line is system dependent.
2145 If available, a line drawing character is used. Drawing a line that is partially
2146 off screen leads to undefined behaviour.
2147 <item>The function is only available as fastcall function, so it may only be
2148 used in presence of a prototype.
2150 <tag/Availability/cc65
2152 <ref id="chlinexy" name="chlinexy">,
2153 <ref id="cvline" name="cvline">,
2154 <ref id="cvlinexy" name="cvlinexy">
2160 <sect1>chlinexy<label id="chlinexy"><p>
2164 <tag/Function/Output a horizontal line at a given position in text mode.
2165 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2166 <tag/Declaration/<tt/void __fastcall__ chlinexy (unsigned char x, unsigned char y, unsigned char length);/
2167 <tag/Description/The function outputs a horizontal line with the given length
2168 starting at a given position.
2169 <tag/Limits/<itemize>
2170 <item>The character used to draw the horizontal line is system dependent.
2171 If available, a line drawing character is used. Drawing a line that is partially
2172 off screen leads to undefined behaviour.
2173 <item>The function is only available as fastcall function, so it may only be
2174 used in presence of a prototype.
2176 <tag/Availability/cc65
2178 <ref id="chline" name="chline">,
2179 <ref id="cvline" name="cvline">,
2180 <ref id="cvlinexy" name="cvlinexy">
2186 <sect1>clearerr<label id="clearerr"><p>
2190 <tag/Function/Clear error and end-of-file status of a stream.
2191 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
2192 <tag/Declaration/<tt/void __fastcall__ clearerr (FILE* f);/
2193 <tag/Description/<tt/clearerr/ clears the error and end-of-file status
2194 indicators for the stream <tt/f/.
2195 <tag/Limits/<itemize>
2196 <item>The function is only available as fastcall function, so it may only be
2197 used in presence of a prototype.
2199 <tag/Availability/ISO 9899
2201 <ref id="feof" name="feof">,
2202 <ref id="ferror" name="ferror">
2208 <sect1>clock<label id="clock"><p>
2212 <tag/Function/Determine the processor time used.
2213 <tag/Header/<tt/<ref id="time.h" name="time.h">/
2214 <tag/Declaration/<tt/clock_t clock (void);/
2215 <tag/Description/The <tt/clock/ function returns an approximaton of processor
2216 time used by the program. The time is returned in implementation defined
2217 units. It can be converted to seconds by dividing by the value of the macro
2218 <tt/CLOCKS_PER_SEC/.
2219 <tag/Limits/<itemize>
2220 <item>Since the machines, cc65 generated programs run on, cannot run multiple
2221 processes, the function will actually return the time since some
2222 implementation defined point in the past.
2224 <tag/Availability/ISO 9899
2226 <ref id="time" name="time">
2232 <sect1>clrscr<label id="clrscr"><p>
2236 <tag/Function/Clear the text screen.
2237 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2238 <tag/Declaration/<tt/void clrscr (void);/
2239 <tag/Description/The function clears the text screen and moves the cursor to
2240 the upper left corner.
2241 <tag/Availability/cc65
2243 <ref id="cclear" name="cclear">,
2244 <ref id="cclearxy" name="cclearxy">
2250 <sect1>close<label id="close"><p>
2254 <tag/Function/Close a file descriptor.
2255 <tag/Header/<tt/<ref id="fcntl.h" name="fcntl.h">/
2256 <tag/Declaration/<tt/int __fastcall__ close (int fd);/
2257 <tag/Description/The function closes the given file descriptor. It returns zero
2258 on success and -1 on error. If an error occurs, the cause can be determined by
2259 reading the <tt/errno/ variable.
2260 <tag/Limits/<itemize>
2261 <item>The function is only available as fastcall function, so it may only
2262 be used in presence of a prototype.
2264 <tag/Availability/POSIX 1003.1
2266 <ref id="creat" name="creat">,
2267 <ref id="open" name="open">
2273 <sect1>closedir<label id="closedir"><p>
2277 <tag/Function/Close a directory.
2278 <tag/Header/<tt/<ref id="dirent.h" name="dirent.h">/
2279 <tag/Declaration/<tt/int __fastcall__ closedir (DIR* dir);/
2280 <tag/Description/The function closes the given directory descriptor. It returns
2281 zero on success and -1 on error. If an error occurs, the cause can be determined
2282 by reading the <tt/errno/ variable.
2283 <tag/Limits/<itemize>
2284 <item>The function is only available as fastcall function, so it may only
2285 be used in presence of a prototype.
2287 <tag/Availability/POSIX 1003.1
2289 <ref id="opendir" name="opendir">,
2290 <ref id="readdir" name="readdir">
2296 <sect1>creat<label id="creat"><p>
2300 <tag/Function/Create a file.
2301 <tag/Header/<tt/<ref id="fcntl.h" name="fcntl.h">/
2302 <tag/Declaration/<tt/int __fastcall__ creat (const char* name, unsigned mode);/
2303 <tag/Description/<tt/creat/ creates a new file and returns the file descriptor
2304 associated with it. On error, -1 is returned and an error code is stored in
2306 <tag/Limits/<itemize>
2307 <item><tt/creat/ is identical to calling <tt/<ref id="open" name="open">/ with
2308 <tt/flags/ equal to <tt/O_WRONLY | O_CREAT | O_TRUNC/.
2309 <item>The function is only available as fastcall function, so it may only
2310 be used in presence of a prototype.
2312 <tag/Availability/POSIX 1003.1
2314 <ref id="close" name="close">,
2315 <ref id="open" name="open">
2321 <sect1>cprintf<label id="cprintf"><p>
2325 <tag/Function/Formatted output to the console.
2326 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2327 <tag/Declaration/<tt/int cprintf (const char* format, ...);/
2328 <tag/Description/The arguments are converted to text where necessary and
2329 formatted according to the format string given. The resulting string is output
2330 to the console. <tt/cprintf/ supports the same format specifiers as
2331 <tt/printf/. <!-- <tt/<ref id="printf" name="printf">/. -->
2332 <tag/Limits/<itemize>
2333 <item>Like all other <tt/conio/ output functions, <tt/cprintf/ distinguishes
2334 between <tt/\r/ and <tt/\n/.
2336 <tag/Availability/cc65
2338 <ref id="cputc" name="cputc">,
2339 <ref id="cputcxy" name="cputcxy">,
2340 <ref id="cputs" name="cputs">,
2341 <ref id="cputsxy" name="cputsxy">,
2342 <ref id="vcprintf" name="vcprintf">
2348 <sect1>cputc<label id="cputc"><p>
2352 <tag/Function/Output a character directly to the console.
2353 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2354 <tag/Declaration/<tt/void __fastcall__ cputc (char c);/
2355 <tag/Description/Output one character to the console at the current cursor
2357 <tag/Limits/<itemize>
2358 <item>Like all other <tt/conio/ output functions, <tt/cputc/ distinguishes
2359 between <tt/\r/ and <tt/\n/.
2360 <item>The function is only available as fastcall function, so it may only
2361 be used in presence of a prototype.
2363 <tag/Availability/cc65
2365 <ref id="cprintf" name="cprintf">,
2366 <ref id="cputcxy" name="cputcxy">,
2367 <ref id="cputs" name="cputs">,
2368 <ref id="cputsxy" name="cputsxy">,
2369 <ref id="vcprintf" name="vcprintf">
2375 <sect1>cputcxy<label id="cputcxy"><p>
2379 <tag/Function/Output a character at a specific screen position.
2380 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2381 <tag/Declaration/<tt/void __fastcall__ cputcxy (unsigned char x, unsigned char y, char c);/
2382 <tag/Description/<tt/cputcxy/ moves the cursor to the given x/y position on
2383 the screen and outputs one character.
2384 <tag/Limits/<itemize>
2385 <item>Like all other <tt/conio/ output functions, <tt/cputcxy/ distinguishes
2386 between <tt/\r/ and <tt/\n/.
2387 <item>The function is only available as fastcall function, so it may only
2388 be used in presence of a prototype.
2390 <tag/Availability/cc65
2392 <ref id="cprintf" name="cprintf">,
2393 <ref id="cputc" name="cputc">,
2394 <ref id="cputs" name="cputs">,
2395 <ref id="cputsxy" name="cputsxy">,
2396 <ref id="vcprintf" name="vcprintf">
2402 <sect1>cputs<label id="cputs"><p>
2406 <tag/Function/Output a string directly to the console.
2407 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2408 <tag/Declaration/<tt/void __fastcall__ cputs (const char* s);/
2409 <tag/Description/The function outputs the given string on the console at the
2410 current cursor position.
2411 <tag/Limits/<itemize>
2412 <item>Like all other <tt/conio/ output functions, <tt/cputs/ distinguishes
2413 between <tt/\r/ and <tt/\n/.
2414 <item>The function is only available as fastcall function, so it may only
2415 be used in presence of a prototype.
2417 <tag/Availability/cc65
2419 <ref id="cprintf" name="cprintf">,
2420 <ref id="cputc" name="cputc">,
2421 <ref id="cputcxy" name="cputcxy">,
2422 <ref id="cputsxy" name="cputsxy">,
2423 <ref id="vcprintf" name="vcprintf">
2429 <sect1>cputsxy<label id="cputsxy"><p>
2433 <tag/Function/Output a string to the console at a given position.
2434 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2435 <tag/Declaration/<tt/void __fastcall__ cputsxy (unsigned char x, unsigned char y, const char* s);/
2436 <tag/Description/<tt/cputsxy/ moves the cursor to the given x/y position,
2437 and outputs the string <tt/s/.
2438 <tag/Limits/<itemize>
2439 <item>Like all other <tt/conio/ output functions, <tt/cputsxy/ distinguishes
2440 between <tt/\r/ and <tt/\n/.
2441 <item>The function is only available as fastcall function, so it may only
2442 be used in presence of a prototype.
2444 <tag/Availability/cc65
2446 <ref id="cprintf" name="cprintf">,
2447 <ref id="cputc" name="cputc">,
2448 <ref id="cputcxy" name="cputcxy">,
2449 <ref id="cputs" name="cputs">,
2450 <ref id="vcprintf" name="vcprintf">
2456 <sect1>cursor<label id="cursor"><p>
2460 <tag/Function/Enable/disable a blinking cursor when waiting for keyboard input.
2461 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2462 <tag/Declaration/<tt/unsigned char __fastcall__ cursor (unsigned char onoff);/
2463 <tag/Description/If the argument to the function is non zero, a blinking cursor
2464 will be enabled when the <tt/cgetc/ function waits for input from the keyboard.
2465 If the argument is zero, <tt/cgetc/ will wait without a blinking cursor.
2466 <tag/Limits/<itemize>
2467 <item>The function is only available as fastcall function, so it may only
2468 be used in presence of a prototype.
2470 <tag/Availability/cc65
2472 <ref id="cgetc" name="cgetc">,
2473 <ref id="kbhit" name="kbhit">
2479 <sect1>cvline<label id="cvline"><p>
2483 <tag/Function/Output a vertical line in text mode.
2484 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2485 <tag/Declaration/<tt/void __fastcall__ cvline (unsigned char length);/
2486 <tag/Description/The function outputs a vertical line with the given length
2487 starting at the current cursor position.
2488 <tag/Limits/<itemize>
2489 <item>The character used to draw the vertical line is system dependent.
2490 If available, a line drawing character is used. Drawing a line that is partially
2491 off screen leads to undefined behaviour.
2492 <item>The function is only available as fastcall function, so it may only be
2493 used in presence of a prototype.
2495 <tag/Availability/cc65
2497 <ref id="chline" name="chline">,
2498 <ref id="chlinexy" name="chlinexy">,
2499 <ref id="cvlinexy" name="cvlinexy">
2505 <sect1>cvlinexy<label id="cvlinexy"><p>
2509 <tag/Function/Output a vertical line at a given position in text mode.
2510 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2511 <tag/Declaration/<tt/void __fastcall__ cvlinexy (unsigned char x, unsigned char y, unsigned char length);/
2512 <tag/Description/The function outputs a vertical line with the given length
2513 starting at a given position.
2514 <tag/Limits/<itemize>
2515 <item>The character used to draw the vertical line is system dependent.
2516 If available, a line drawing character is used. Drawing a line that is partially
2517 off screen leads to undefined behaviour.
2518 <item>The function is only available as fastcall function, so it may only be
2519 used in presence of a prototype.
2521 <tag/Availability/cc65
2523 <ref id="chline" name="chline">,
2524 <ref id="chlinexy" name="chlinexy">,
2525 <ref id="cvline" name="cvline">
2531 <sect1>div<label id="div"><p>
2535 <tag/Function/Divide two ints and return quotient and remainder.
2536 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
2537 <tag/Declaration/<tt/div_t __fastcall__ div (int numer, int denom);/
2538 <tag/Description/<tt/div/ divides <tt/numer/ by <tt/denom/ and returns the
2539 quotient and remainder in a <tt/div_t/ structure.
2542 <item>The function is only available as fastcall function, so it may only
2543 be used in presence of a prototype.
2545 <tag/Availability/ISO 9899
2553 <sect1>em_commit<label id="em_commit"><p>
2557 <tag/Function/Commit changes into extended memory.
2558 <tag/Header/<tt/<ref id="em.h" name="em.h">/
2559 <tag/Declaration/<tt/void em_commit (void);/
2560 <tag/Description/Commit changes in the memory window to extended storage. If
2561 the contents of the memory window have been changed, these changes may be lost
2562 if <tt/<ref id="em_map" name="em_map">/, <tt/<ref id="em_use" name="em_use">/,
2563 <tt/<ref id="em_copyfrom" name="em_copyfrom">/ or <tt/<ref id="em_copyto"
2564 name="em_copyto">/ are called without calling <tt/em_commit/ first.
2565 <tag/Limits/<itemize>
2566 <item>Calling <tt/em_commit/ does not necessarily mean that changes to the
2567 memory window are discarded, it does just mean that the drivers is allowed
2569 <item>The function is only available as fastcall function, so it may only be
2570 used in presence of a prototype.
2571 <item>The function produces undefined results if no extended memory driver is
2574 <tag/Availability/cc65
2576 <ref id="em_load_driver" name="em_load_driver">,
2577 <ref id="em_map" name="em_map">,
2578 <ref id="em_use" name="em_use">
2584 <sect1>em_copyfrom<label id="em_copyfrom"><p>
2588 <tag/Function/Copy from extended into normal memory.
2589 <tag/Header/<tt/<ref id="em.h" name="em.h">/
2590 <tag/Declaration/<tt/void __fastcall__ em_copyfrom (const struct em_copy* copy_data);/
2591 <tag/Description/Copy data from extended memory into linear memory. Source and
2592 target addresses as well as the number of bytes to transfer are specified in
2593 the <tt/em_copy/ structure that is passed as a parameter.
2594 <tag/Limits/<itemize>
2595 <item>Calling <tt/em_copyfrom/ will invalidate the memory window, so if you
2596 made any changes to the data in the window, call <tt/<ref id="em_commit"
2597 name="em_commit">/ first, or the changes are lost.
2598 <item>The function is only available as fastcall function, so it may only be
2599 used in presence of a prototype.
2600 <item>The function produces undefined results if no extended memory driver is
2603 <tag/Availability/cc65
2605 <ref id="em_commit" name="em_commit">,
2606 <ref id="em_copyto" name="em_copyto">,
2607 <ref id="em_load_driver" name="em_load_driver">
2613 <sect1>em_copyto<label id="em_copyto"><p>
2617 <tag/Function/Copy from normal into extended memory.
2618 <tag/Header/<tt/<ref id="em.h" name="em.h">/
2619 <tag/Declaration/<tt/void __fastcall__ em_copyto (const struct em_copy* copy_data);/
2620 <tag/Description/Copy data from linear into extended memory. Source and
2621 target addresses as well as the number of bytes to transfer are specified in
2622 the <tt/em_copy/ structure that is passed as a parameter.
2623 <tag/Limits/<itemize>
2624 <item>Calling <tt/em_copyto/ will invalidate the memory window, so if you
2625 made any changes to the data in the window, call <tt/<ref id="em_commit"
2626 name="em_commit">/ first, or the changes are lost.
2627 <item>The function is only available as fastcall function, so it may only be
2628 used in presence of a prototype.
2629 <item>The function produces undefined results if no extended memory driver is
2632 <tag/Availability/cc65
2634 <ref id="em_commit" name="em_commit">,
2635 <ref id="em_copyfrom" name="em_copyfrom">,
2636 <ref id="em_load_driver" name="em_load_driver">
2642 <sect1>em_install<label id="em_install"><p>
2646 <tag/Function/Install an already loaded extended memory driver.
2647 <tag/Header/<tt/<ref id="em.h" name="em.h">/
2648 <tag/Declaration/<tt/unsigned char _fastcall__ em_install (void* driver);/
2649 <tag/Description/The function installs an already loaded extended memory driver
2650 and returns an error code. The function may be used to install a driver linked
2651 statically to the program.
2652 <tag/Limits/<itemize>
2653 <item>Not all drivers are able to detect if the supported hardware is really
2655 <item>The function is only available as fastcall function, so it may only be
2656 used in presence of a prototype.
2658 <tag/Availability/cc65
2660 <ref id="em_load_driver" name="em_load_driver">,
2661 <ref id="em_uninstall" name="em_uninstall">,
2662 <ref id="em_unload" name="em_unload">
2668 <sect1>em_load_driver<label id="em_load_driver"><p>
2672 <tag/Function/Load and initialize an extended memory driver.
2673 <tag/Header/<tt/<ref id="em.h" name="em.h">/
2674 <tag/Declaration/<tt/void __fastcall__ em_load_driver (const char* name);/
2675 <tag/Description/Load an extended memory driver into memory and initialize
2676 it. The function returns an error code that tells if all this has been
2678 <tag/Limits/<itemize>
2679 <item>Not all drivers are able to detect if the supported hardware is really
2681 <item>The function is only available as fastcall function, so it may only be
2682 used in presence of a prototype.
2683 <item>The driver is loaded by name, so currently you must know the type of
2684 extended memory that should be supported. There is no autodetect capability.
2686 <tag/Availability/cc65
2688 <ref id="em_unload" name="em_unload">
2694 <sect1>em_map<label id="em_map"><p>
2698 <tag/Function/Make a page of extended memory accessible.
2699 <tag/Header/<tt/<ref id="em.h" name="em.h">/
2700 <tag/Declaration/<tt/void* __fastcall__ em_map (unsigned page);/
2701 <tag/Description/The function maps one page of extended memory into linear
2702 memory and returns a pointer to the page frame. Depending on the hardware
2703 and driver, the data is either mapped into the address space or transfered
2704 into a buffer. If you don't need the actual contents of the page (for example
2705 because you're going to overwrite it completely), it is better to call
2706 <tt/<ref id="em_use" name="em_use">/ instead. <tt/em_use/ will not transfer the
2707 data if it is possible to avoid that.
2708 <tag/Limits/<itemize>
2709 <item>Calling <tt/em_map/ will invalidate the memory window, so if you
2710 made any changes to the data in the window, call <tt/<ref id="em_commit"
2711 name="em_commit">/ first, or the changes are lost.
2712 <item>The function is only available as fastcall function, so it may only be
2713 used in presence of a prototype.
2714 <item>The function produces undefined results if no extended memory driver is
2717 <tag/Availability/cc65
2719 <ref id="em_commit" name="em_commit">,
2720 <ref id="em_load_driver" name="em_load_driver">,
2721 <ref id="em_use" name="em_use">
2727 <sect1>em_pagecount<label id="em_pagecount"><p>
2731 <tag/Function/Return the number of available extended memory pages.
2732 <tag/Header/<tt/<ref id="em.h" name="em.h">/
2733 <tag/Declaration/<tt/unsigned em_pagecount (void);/
2734 <tag/Description/The function returns the size of the extended memory supported
2735 by the driver in 256 byte pages.
2736 <tag/Limits/<itemize>
2737 <item>The function returns zero if no extended memory driver is loaded.
2738 <item>The function may return zero if the supported hardware was not detected.
2740 <tag/Availability/cc65
2742 <ref id="em_load_driver" name="em_load_driver">
2748 <sect1>em_uninstall<label id="em_uninstall"><p>
2752 <tag/Function/Uninstall an already loaded extended memory driver.
2753 <tag/Header/<tt/<ref id="em.h" name="em.h">/
2754 <tag/Declaration/<tt/unsigned char em_uninstall (void);/
2755 <tag/Description/The function uninstalls an already loaded extended memory
2756 driver but doesn't remove it from memory.
2757 <tag/Limits/<itemize>
2758 <item>If the driver has been loaded using <tt/<ref id="em_load_driver"
2759 name="em_load_driver">/, <tt/<ref id="em_unload" name="em_unload">/
2760 should be used instead of <tt/em_uninstall/ so the driver is also removed
2763 <tag/Availability/cc65
2765 <ref id="em_install" name="em_install">,
2766 <ref id="em_load_driver" name="em_load_driver">,
2767 <ref id="em_unload" name="em_unload">
2773 <sect1>em_unload<label id="em_unload"><p>
2777 <tag/Function/Unload an extended memory driver.
2778 <tag/Header/<tt/<ref id="em.h" name="em.h">/
2779 <tag/Declaration/<tt/unsigned char em_unload (void);/
2780 <tag/Description/The function unloads a loaded extended memory driver and
2781 frees all memory allocated for the driver.
2782 <tag/Limits/<itemize>
2783 <item>The function does nothing if no driver is loaded.
2785 <tag/Availability/cc65
2787 <ref id="em_load_driver" name="em_load_driver">
2793 <sect1>em_use<label id="em_use"><p>
2797 <tag/Function/Prepare an extended memory page for use.
2798 <tag/Header/<tt/<ref id="em.h" name="em.h">/
2799 <tag/Declaration/<tt/void* __fastcall__ em_use (unsigned page);/
2800 <tag/Description/The function maps one page of extended memory into linear
2801 memory and returns a pointer to the page frame. This function is similar to
2802 <tt/<ref id="em_map" name="em_map">/, but will not transfer data into the
2803 actual memory window in the assumption that the existing data is wrong or
2804 will get overwritten.
2805 <tag/Limits/<itemize>
2806 <item>Calling <tt/em_use/ will invalidate the memory window, so if you
2807 made any changes to the data in the window, call <tt/<ref id="em_commit"
2808 name="em_commit">/ first, or the changes are lost.
2809 <item>The function is only available as fastcall function, so it may only be
2810 used in presence of a prototype.
2811 <item>The function produces undefined results if no extended memory driver is
2814 <tag/Availability/cc65
2816 <ref id="em_commit" name="em_commit">,
2817 <ref id="em_load_driver" name="em_load_driver">,
2818 <ref id="em_map" name="em_map">
2824 <sect1>exit<label id="exit"><p>
2828 <tag/Function/Terminate the program.
2829 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
2830 <tag/Declaration/<tt/void __fastcall__ exit (int status);/
2831 <tag/Description/<tt/exit/ terminates the program. The argument specifies the
2832 return code of the program. Before termination, all files are closed, buffered
2833 output is written and any functions registered with <tt/<ref id="atexit"
2834 name="atexit">/ are called. Common values for status are <tt/EXIT_SUCCESS/ and
2835 <tt/EXIT_FAILURE/ which are also defined in <tt/<ref id="stdlib.h"
2837 <tag/Limits/<itemize>
2838 <item>The function is only available as fastcall function, so it may only
2839 be used in presence of a prototype.
2840 <item>It depends on the host machine if the program return code can be
2841 evaluated or is ignored.
2843 <tag/Availability/ISO 9899
2845 <ref id="abort" name="abort">,
2846 <ref id="exit" name="exit">
2852 <sect1>exec<label id="exec"><p>
2856 <tag/Function/Execute a program file.
2857 <tag/Header/<tt/<ref id="unistd.h" name="unistd.h">/
2858 <tag/Declaration/<tt/int __fastcall__ exec (const char* progname, const char* cmdline);/
2859 <tag/Description/<tt/exec/ replaces the currently running program by a new one.
2860 Calling <tt/exec()/ is identical to calling <tt/<ref id="exit" name="exit()">/,
2861 then loading and starting the program named in the first argument, passing
2862 the command line specified as second argument. Instead of an empty string,
2863 a <tt/NULL/ pointer may be passed as second parameter.
2864 On success, the function does not return. On failure, -1 is returned and
2865 <tt/errno/ contains an error code.
2866 <tag/Limits/<itemize>
2867 <item>The function is only available as fastcall function, so it may only
2868 be used in presence of a prototype.
2869 <item>On most platforms, the function needs to copy a small stub loader to
2870 some memory area outside the program space. This may collide with other
2871 programs. See the platform specific docs on this.
2872 <item>Because it is necessary to terminate the running program before the
2873 memory can be reused to load the new one, there is a high chance that the
2874 function may not be able to return on errors.
2875 <item>The command line is passed to the new program in the same way as cc65
2876 programs expect the command line. If the new program is not a cc65 generated
2877 program, it may not be able to read it.
2879 <tag/Availability/cc65
2881 <ref id="exit" name="exit">
2887 <sect1>fast<label id="fast"><p>
2891 <tag/Function/Switch the C128 into 2MHz mode.
2892 <tag/Header/<tt/<ref id="c128.h" name="c128.h">/
2893 <tag/Declaration/<tt/void fast (void);/
2894 <tag/Description/The function will switch the clock of the C128 to 2MHz. This
2895 will nearly double the speed compared to slow mode.
2896 <tag/Limits/<itemize>
2897 <item>The function is specific to the C128.
2898 <item>2MHz clock will not work in 40 column mode.
2900 <tag/Availability/C128
2902 <ref id="slow" name="slow">,
2903 <ref id="toggle_videomode" name="toggle_videomode">,
2904 <ref id="videomode" name="videomode">
2910 <sect1>feof<label id="feof"><p>
2914 <tag/Function/Return the end-of-file indicator of a stream.
2915 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
2916 <tag/Declaration/<tt/int __fastcall__ feof (FILE* f);/
2917 <tag/Description/<tt/feof/ tests the end-of-file indicator ofthe stream
2918 <tt/f/, and returns a non zero value if it is set.
2919 <tag/Limits/<itemize>
2920 <item>The indicator is set only after a read past the end of a file is
2922 <item>The function is only available as fastcall function, so it may only be
2923 used in presence of a prototype.
2925 <tag/Availability/ISO 9899
2927 <ref id="feof" name="clearerr">,
2928 <ref id="ferror" name="ferror">
2934 <sect1>ferror<label id="ferror"><p>
2938 <tag/Function/Return the error indicator of a stream.
2939 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
2940 <tag/Declaration/<tt/int __fastcall__ ferror (FILE* f);/
2941 <tag/Description/<tt/ferror/ tests the error indicator of the stream
2942 <tt/f/, and returns a non zero value if it is set.
2943 <tag/Limits/<itemize>
2944 <item>The function is only available as fastcall function, so it may only be
2945 used in presence of a prototype.
2947 <tag/Availability/ISO 9899
2949 <ref id="feof" name="clearerr">,
2950 <ref id="ferror" name="feof">
2956 <sect1>fileno<label id="fileno"><p>
2960 <tag/Function/Return the file handle used by a stream.
2961 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
2962 <tag/Declaration/<tt/int __fastcall__ fileno (FILE* f);/
2963 <tag/Description/The <tt/fileno/ function returns the file handle used
2964 internally by a C stream. This file handle (an integer) can be used as a
2965 handle for the POSIX input/output functions.
2966 <tag/Limits/<itemize>
2967 <item>The function is only available as fastcall function, so it may only be
2968 used in presence of a prototype.
2969 <item>Mixing C file I/O functions and POSIX file I/O functions for the same
2970 file may have unpredictable results.
2972 <tag/Availability/POSIX 1003.1
2974 <ref id="creat" name="creat">,
2975 <ref id="open" name="open"> <!-- , -->
2976 <!-- <ref id="read" name="read">, -->
2977 <!-- <ref id="write" name="write"> -->
2983 <sect1>free<label id="free"><p>
2987 <tag/Function/Free a block of dynamic memory.
2988 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
2989 <tag/Declaration/<tt/void __fastcall__ free (void* block);/
2990 <tag/Description/Free a block of dynamic memory previously allocated with
2991 <tt/<ref id="malloc" name="malloc">/, <tt/<ref id="calloc" name="calloc">/
2992 or <tt/<ref id="realloc" name="realloc">/. As an exception, if the passed
2993 pointer is <tt/NULL/, no action is performed.
2996 <item>Passing an already free'd block to <tt/free/ again will cause undefined
2997 behaviour and may crash your program.
2998 <item>The function is only available as fastcall function, so it may only
2999 be used in presence of a prototype.
3001 <tag/Availability/ISO 9899
3003 <ref id="_heapadd" name="_heapadd">,
3004 <ref id="_heapblocksize" name="_heapblocksize">,
3005 <ref id="_heapmaxavail" name="_heapmaxavail">,
3006 <ref id="_heapmemavail" name="_heapmemavail">,
3007 <ref id="calloc" name="calloc">,
3008 <ref id="malloc" name="malloc">,
3009 <ref id="realloc" name="realloc">
3015 <sect1>get_ostype<label id="get_ostype"><p>
3019 <tag/Function/The function returns the operating system, the program runs on.
3020 <tag/Header/<tt/<ref id="apple2.h" name="apple2.h">,
3021 <ref id="atari.h" name="atari.h">, <ref id="c64.h" name="c64.h">/
3022 <tag/Declaration/<tt/unsigned char get_ostype (void);/
3023 <tag/Description/<tt/get_ostype/ is machine dependent and does not exist for
3024 all supported targets. If it exists, it returns a number that identifies the
3025 operating system or machine type, the program runs on. The machine dependent
3026 header files define constants that can be used to check the return code.
3027 <tag/Limits/<itemize>
3028 <item>The function does not exist on all platforms.
3029 <item>The return codes are platform dependent.
3031 <tag/Availability/cc65 (not all platforms)
3037 <sect1>getcpu<label id="getcpu"><p>
3041 <tag/Function/Determine on which CPU the program is running.
3042 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
3043 <tag/Declaration/<tt/unsigned char getcpu (void);/
3044 <tag/Description/The function checks on which CPU the code is running. It
3045 returns one of the constants<itemize>
3047 <item><tt/CPU_65C02/
3048 <item><tt/CPU_65816/
3050 <tag/Limits/<itemize>
3051 <item>Other, more exotic CPU types are not disinguished.
3053 <tag/Availability/cc65
3059 <sect1>getenv<label id="getenv"><p>
3063 <tag/Function/Return a value from the environment.
3064 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
3065 <tag/Declaration/<tt/char* __fastcall__ getenv (const char* name);/
3066 <tag/Description/The function searches the environment for an entry that
3067 matches <tt/name/ and returns its value. The environment consists of a list
3068 of strings in the form <tt/name=value/. If there is no match, <tt/getenv/
3070 <tag/Limits/<itemize>
3071 <item>What exactly is stored in the environment depends on the machine the
3072 program is running on.
3073 <item>The function is only available as fastcall function, so it may only
3074 be used in presence of a prototype.
3076 <tag/Availability/ISO 9899
3082 <sect1>getopt<label id="getopt"><p>
3086 <tag/Function/Parse command line options.
3087 <tag/Header/<tt/<ref id="unistd.h" name="unistd.h">/
3088 <tag/Declaration/<tt/int __fastcall__ getopt (int argc, char* const* argv,
3089 const char* optstring);/
3090 <tag/Description/The function parses command line arguments, <tt/argc/ and
3091 <tt/argv/ are the argument count and array passed to <tt/main/. <tt/optstring/
3092 is a string that contains command line option characters. If a character in
3093 <tt/optstring/ is followed by a colon, the option requires an argument. An
3094 option on the command line is recognized if it is one of the option characters
3096 <tt/getopt/ must be called repeatedly. It will return each option character
3097 found on the command line and <tt/EOF/ (-1) if there is no other option. An
3098 option argument is placed in <tt/optarg/, the index of the next element on the
3099 command line to be processed is placed in <tt/optind/.
3100 <tag/Limits/<itemize>
3101 <item>The implementation will not reorder options. A non option on the command
3102 line will terminate option processing. All remaining arguments are not
3103 recognized as options, even if the start with a '-' character.
3104 <item>The function is only available as fastcall function, so it may only
3105 be used in presence of a prototype.
3107 <tag/Availability/POSIX.2
3113 <sect1>gotox<label id="gotox"><p>
3117 <tag/Function/Move the text mode cursor to a new X position.
3118 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
3119 <tag/Declaration/<tt/void __fastcall__ gotox (unsigned char x);/
3120 <tag/Description/The function moves the text mode cursor to the specified X
3121 position while leaving the Y position untouched. The leftmost position on the
3122 screen has the coordinate 0.
3123 <tag/Limits/<itemize>
3124 <item>The function is only available as fastcall function, so it may
3125 only be used in presence of a prototype.
3126 <item>Invalid values for the X position (out of screen coordinates) may
3127 lead to undefined behaviour.
3129 <tag/Availability/cc65
3131 <ref id="gotoy" name="gotoy">,
3132 <ref id="gotoxy" name="gotoxy">,
3133 <ref id="wherex" name="wherex">,
3134 <ref id="wherey" name="wherey">
3140 <sect1>gotoxy<label id="gotoxy"><p>
3144 <tag/Function/Move the text mode cursor to a new position.
3145 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
3146 <tag/Declaration/<tt/void __fastcall__ gotoxy (unsigned char x, unsigned char y);/
3147 <tag/Description/The function moves the text mode cursor to the specified
3148 position. The leftmost position on the screen has the X coordinate 0, the
3149 topmost line has the Y coordinate 0.
3150 <tag/Limits/<itemize>
3151 <item>The function is only available as fastcall function, so it may only be
3152 used in presence of a prototype.
3153 <item>Invalid values for any of both coordinates (out of screen positions) may
3154 lead to undefined behaviour.
3156 <tag/Availability/cc65
3158 <ref id="gotox" name="gotox">,
3159 <ref id="gotoy" name="gotoy">,
3160 <ref id="wherex" name="wherex">,
3161 <ref id="wherey" name="wherey">
3167 <sect1>gotoy<label id="gotoy"><p>
3171 <tag/Function/Move the text mode cursor to a new Y position.
3172 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
3173 <tag/Declaration/<tt/void __fastcall__ gotoy (unsigned char x);/
3174 <tag/Description/The function moves the text mode cursor to the specified Y
3175 position while leaving the X position untouched. The uppermost position on the
3176 screen has the coordinate 0.
3177 <tag/Limits/<itemize>
3178 <item>The function is only available as fastcall function, so it may
3179 only be used in presence of a prototype.
3180 <item>Invalid values for the Y position (out of screen coordinates) may lead
3181 to undefined behaviour.
3183 <tag/Availability/cc65
3185 <ref id="gotox" name="gotox">,
3186 <ref id="gotoxy" name="gotoxy">,
3187 <ref id="wherex" name="wherex">,
3188 <ref id="wherey" name="wherey">
3194 <sect1>isalnum<label id="isalnum"><p>
3198 <tag/Function/Check if a given character is a letter or digit.
3199 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
3200 <tag/Declaration/<tt/int __fastcall__ isalnum (int c);/
3201 <tag/Description/The function returns a non zero value if the given argument
3202 is a letter or digit. The return value is zero if the character is anything
3204 <tag/Limits/<itemize>
3205 <item>When compiling with <tt/-Os/ the function is actually a macro. The
3206 inline sequence generated by the macro will not work correctly for values
3207 outside the range 0..255. <em/Note:/ The constant <tt/EOF/ is not part of
3208 this range. The non inline function may be accessed by <tt/#undef/'ing
3210 <item>When compiling without <tt/-Os/, the function is only available as
3211 fastcall function, so it may only be used in presence of a prototype.
3213 <tag/Availability/ISO 9899
3215 <ref id="isalpha" name="isalpha">,
3216 <ref id="isascii" name="isascii">,
3217 <ref id="isblank" name="isblank">,
3218 <ref id="iscntrl" name="iscntrl">,
3219 <ref id="isdigit" name="isdigit">,
3220 <ref id="isgraph" name="isgraph">,
3221 <ref id="islower" name="islower">,
3222 <ref id="isprint" name="isprint">,
3223 <ref id="ispunct" name="ispunct">,
3224 <ref id="isspace" name="isspace">,
3225 <ref id="isupper" name="isupper">,
3226 <ref id="isxdigit" name="isxdigit">
3232 <sect1>isalpha<label id="isalpha"><p>
3236 <tag/Function/Check if a given character is a letter.
3237 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
3238 <tag/Declaration/<tt/int __fastcall__ isalpha (int c);/
3239 <tag/Description/The function returns a non zero value if the given argument
3240 is a letter. The return value is zero if the character is anything else.
3241 <tag/Limits/<itemize>
3242 <item>When compiling with <tt/-Os/ the function is actually a macro. The
3243 inline sequence generated by the macro will not work correctly for values
3244 outside the range 0..255. <em/Note:/ The constant <tt/EOF/ is not part of
3245 this range. The non inline function may be accessed by <tt/#undef/'ing the
3247 <item>When compiling without <tt/-Os/, the function is only available as
3248 fastcall function, so it may only be used in presence of a prototype.
3250 <tag/Availability/ISO 9899
3252 <ref id="isalnum" name="isalnum">,
3253 <ref id="isascii" name="isascii">,
3254 <ref id="isblank" name="isblank">,
3255 <ref id="iscntrl" name="iscntrl">,
3256 <ref id="isdigit" name="isdigit">,
3257 <ref id="isgraph" name="isgraph">,
3258 <ref id="islower" name="islower">,
3259 <ref id="isprint" name="isprint">,
3260 <ref id="ispunct" name="ispunct">,
3261 <ref id="isspace" name="isspace">,
3262 <ref id="isupper" name="isupper">,
3263 <ref id="isxdigit" name="isxdigit">
3269 <sect1>isascii<label id="isascii"><p>
3273 <tag/Function/Check if a given character is in the ASCII (0..127) range.
3274 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
3275 <tag/Declaration/<tt/int __fastcall__ isascii (int c);/
3276 <tag/Description/The function returns a non zero value if the given argument
3277 is in the range 0..127 (the range of valid ASCII characters) and zero if not.
3278 <tag/Limits/<itemize>
3279 <item>When compiling with <tt/-Os/ the function is actually a macro. The
3280 inline sequence generated by the macro will not work correctly for values
3281 outside the range 0..255. <em/Note:/ The constant <tt/EOF/ is not part of
3282 this range. The non inline function may be accessed by <tt/#undef/'ing the
3284 <item>When compiling without <tt/-Os/, the function is only available as
3285 fastcall function, so it may only be used in presence of a prototype.
3287 <tag/Availability/ISO 9899
3289 <ref id="isalnum" name="isalnum">,
3290 <ref id="isalpha" name="isalpha">,
3291 <ref id="isblank" name="isblank">,
3292 <ref id="iscntrl" name="iscntrl">,
3293 <ref id="isdigit" name="isdigit">,
3294 <ref id="isgraph" name="isgraph">,
3295 <ref id="islower" name="islower">,
3296 <ref id="isprint" name="isprint">,
3297 <ref id="ispunct" name="ispunct">,
3298 <ref id="isspace" name="isspace">,
3299 <ref id="isupper" name="isupper">,
3300 <ref id="isxdigit" name="isxdigit">
3306 <sect1>isblank<label id="isblank"><p>
3310 <tag/Function/Check if a given character is a space or tab.
3311 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
3312 <tag/Declaration/<tt/int __fastcall__ isblank (int c);/
3313 <tag/Description/The function returns a non zero value if the given argument
3314 is a space or tab character. The return value is zero if the character is
3316 <tag/Limits/<itemize>
3317 <item>When compiling with <tt/-Os/ the function is actually a macro. The
3318 inline sequence generated by the macro will not work correctly for values
3319 outside the range 0..255. <em/Note:/ The constant <tt/EOF/ is not part of
3320 this range. The non inline function may be accessed by <tt/#undef/'ing the
3322 <item>When compiling without <tt/-Os/, the function is only available as
3323 fastcall function, so it may only be used in presence of a prototype.
3325 <tag/Availability/cc65
3327 <ref id="isalnum" name="isalnum">,
3328 <ref id="isalpha" name="isalpha">,
3329 <ref id="isascii" name="isascii">,
3330 <ref id="iscntrl" name="iscntrl">,
3331 <ref id="isdigit" name="isdigit">,
3332 <ref id="isgraph" name="isgraph">,
3333 <ref id="islower" name="islower">,
3334 <ref id="isprint" name="isprint">,
3335 <ref id="ispunct" name="ispunct">,
3336 <ref id="isspace" name="isspace">,
3337 <ref id="isupper" name="isupper">,
3338 <ref id="isxdigit" name="isxdigit">
3344 <sect1>iscntrl<label id="iscntrl"><p>
3348 <tag/Function/Check if a given character is a control character.
3349 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
3350 <tag/Declaration/<tt/int __fastcall__ iscntrl (int c);/
3351 <tag/Description/The function returns a non zero value if the given argument
3352 is a control character. The return value is zero if the character is anything
3354 <tag/Limits/<itemize>
3355 <item>When compiling with <tt/-Os/ the function is actually a macro. The
3356 inline sequence generated by the macro will not work correctly for values
3357 outside the range 0..255. <em/Note:/ The constant <tt/EOF/ is not part of
3358 this range. The non inline function may be accessed by <tt/#undef/'ing the
3360 <item>When compiling without <tt/-Os/, the function is only available as
3361 fastcall function, so it may only be used in presence of a prototype.
3363 <tag/Availability/ISO 9899
3365 <ref id="isalnum" name="isalnum">,
3366 <ref id="isalpha" name="isalpha">,
3367 <ref id="isascii" name="isascii">,
3368 <ref id="isblank" name="isblank">,
3369 <ref id="isdigit" name="isdigit">,
3370 <ref id="isgraph" name="isgraph">,
3371 <ref id="islower" name="islower">,
3372 <ref id="isprint" name="isprint">,
3373 <ref id="ispunct" name="ispunct">,
3374 <ref id="isspace" name="isspace">,
3375 <ref id="isupper" name="isupper">,
3376 <ref id="isxdigit" name="isxdigit">
3382 <sect1>isdigit<label id="isdigit"><p>
3386 <tag/Function/Check if a given character is a digit.
3387 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
3388 <tag/Declaration/<tt/int __fastcall__ isdigit (int c);/
3389 <tag/Description/The function returns a non zero value if the given argument
3390 is a digit. The return value is zero if the character is anything else.
3391 <tag/Limits/<itemize>
3392 <item>When compiling with <tt/-Os/ the function is actually a macro. The
3393 inline sequence generated by the macro will not work correctly for values
3394 outside the range 0..255. <em/Note:/ The constant <tt/EOF/ is not part of
3395 this range. The non inline function may be accessed by <tt/#undef/'ing the
3397 <item>When compiling without <tt/-Os/, the function is only available as
3398 fastcall function, so it may only be used in presence of a prototype.
3400 <tag/Availability/ISO 9899
3402 <ref id="isalnum" name="isalnum">,
3403 <ref id="isalpha" name="isalpha">,
3404 <ref id="isascii" name="isascii">,
3405 <ref id="isblank" name="isblank">,
3406 <ref id="iscntrl" name="iscntrl">,
3407 <ref id="isgraph" name="isgraph">,
3408 <ref id="islower" name="islower">,
3409 <ref id="isprint" name="isprint">,
3410 <ref id="ispunct" name="ispunct">,
3411 <ref id="isspace" name="isspace">,
3412 <ref id="isupper" name="isupper">,
3413 <ref id="isxdigit" name="isxdigit">
3419 <sect1>isgraph<label id="isgraph"><p>
3423 <tag/Function/Check if a given character is a printable character (except
3425 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
3426 <tag/Declaration/<tt/int __fastcall__ isgraph (int c);/
3427 <tag/Description/The function returns a non zero value if the given argument
3428 is a printable character with the exception of space. The return value is zero
3429 if the character is anything else.
3430 <tag/Limits/<itemize>
3431 <item>When compiling with <tt/-Os/ the function is actually a macro. The
3432 inline sequence generated by the macro will not work correctly for values
3433 outside the range 0..255. <em/Note:/ The constant <tt/EOF/ is not part of
3434 this range. The non inline function may be accessed by <tt/#undef/'ing the
3436 <item>When compiling without <tt/-Os/, the function is only available as
3437 fastcall function, so it may only be used in presence of a prototype.
3439 <tag/Availability/ISO 9899
3441 <ref id="isalnum" name="isalnum">,
3442 <ref id="isalpha" name="isalpha">,
3443 <ref id="isascii" name="isascii">,
3444 <ref id="isblank" name="isblank">,
3445 <ref id="iscntrl" name="iscntrl">,
3446 <ref id="isdigit" name="isdigit">,
3447 <ref id="islower" name="islower">,
3448 <ref id="isprint" name="isprint">,
3449 <ref id="ispunct" name="ispunct">,
3450 <ref id="isspace" name="isspace">,
3451 <ref id="isupper" name="isupper">,
3452 <ref id="isxdigit" name="isxdigit">
3458 <sect1>islower<label id="islower"><p>
3462 <tag/Function/Check if a given character is a lower case letter.
3463 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
3464 <tag/Declaration/<tt/int __fastcall__ islower (int c);/
3465 <tag/Description/The function returns a non zero value if the given argument
3466 is a lower case letter. The return value is zero if the character is anything
3468 <tag/Limits/<itemize>
3469 <item>When compiling with <tt/-Os/ the function is actually a macro. The
3470 inline sequence generated by the macro will not work correctly for values
3471 outside the range 0..255. <em/Note:/ The constant <tt/EOF/ is not part of
3472 this range. The non inline function may be accessed by <tt/#undef/'ing the
3474 <item>When compiling without <tt/-Os/, the function is only available as
3475 fastcall function, so it may only be used in presence of a prototype.
3477 <tag/Availability/ISO 9899
3479 <ref id="isalnum" name="isalnum">,
3480 <ref id="isalpha" name="isalpha">,
3481 <ref id="isascii" name="isascii">,
3482 <ref id="isblank" name="isblank">,
3483 <ref id="iscntrl" name="iscntrl">,
3484 <ref id="isdigit" name="isdigit">,
3485 <ref id="isgraph" name="isgraph">,
3486 <ref id="isprint" name="isprint">,
3487 <ref id="ispunct" name="ispunct">,
3488 <ref id="isspace" name="isspace">,
3489 <ref id="isupper" name="isupper">,
3490 <ref id="isxdigit" name="isxdigit">
3496 <sect1>isprint<label id="isprint"><p>
3500 <tag/Function/Check if a given character is a printable character.
3501 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
3502 <tag/Declaration/<tt/int __fastcall__ isprint (int c);/
3503 <tag/Description/The function returns a non zero value if the given argument
3504 is a printable character (this includes the space character). The return value
3505 is zero if the character is anything else.
3506 <tag/Limits/<itemize>
3507 <item>When compiling with <tt/-Os/ the function is actually a macro. The
3508 inline sequence generated by the macro will not work correctly for values
3509 outside the range 0..255. <em/Note:/ The constant <tt/EOF/ is not part of
3510 this range. The non inline function may be accessed by <tt/#undef/'ing the
3512 <item>When compiling without <tt/-Os/, the function is only available as
3513 fastcall function, so it may only be used in presence of a prototype.
3515 <tag/Availability/ISO 9899
3517 <ref id="isalnum" name="isalnum">,
3518 <ref id="isalpha" name="isalpha">,
3519 <ref id="isascii" name="isascii">,
3520 <ref id="isblank" name="isblank">,
3521 <ref id="iscntrl" name="iscntrl">,
3522 <ref id="isdigit" name="isdigit">,
3523 <ref id="isgraph" name="isgraph">,
3524 <ref id="islower" name="islower">,
3525 <ref id="ispunct" name="ispunct">,
3526 <ref id="isspace" name="isspace">,
3527 <ref id="isupper" name="isupper">,
3528 <ref id="isxdigit" name="isxdigit">
3534 <sect1>ispunct<label id="ispunct"><p>
3538 <tag/Function/Check if a given character is a printable character but not a
3539 space or an alphanumeric character.
3540 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
3541 <tag/Declaration/<tt/int __fastcall__ ispunct (int c);/
3542 <tag/Description/The function returns a non zero value if the given argument
3543 is a printable character, but not a space or anything alphanumeric. The return
3544 value is zero if the character is anything else.
3545 <tag/Limits/<itemize>
3546 <item>When compiling with <tt/-Os/ the function is actually a macro. The
3547 inline sequence generated by the macro will not work correctly for values
3548 outside the range 0..255. <em/Note:/ The constant <tt/EOF/ is not part of
3549 this range. The non inline function may be accessed by <tt/#undef/'ing the
3551 <item>When compiling without <tt/-Os/, the function is only available as
3552 fastcall function, so it may only be used in presence of a prototype.
3554 <tag/Availability/ISO 9899
3556 <ref id="isalnum" name="isalnum">,
3557 <ref id="isalpha" name="isalpha">,
3558 <ref id="isascii" name="isascii">,
3559 <ref id="isblank" name="isblank">,
3560 <ref id="iscntrl" name="iscntrl">,
3561 <ref id="isdigit" name="isdigit">,
3562 <ref id="isgraph" name="isgraph">,
3563 <ref id="islower" name="islower">,
3564 <ref id="isprint" name="isprint">,
3565 <ref id="isspace" name="isspace">,
3566 <ref id="isupper" name="isupper">,
3567 <ref id="isxdigit" name="isxdigit">
3573 <sect1>isspace<label id="isspace"><p>
3577 <tag/Function/Check if a given character is a a white-space character.
3578 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
3579 <tag/Declaration/<tt/int __fastcall__ isspace (int c);/
3580 <tag/Description/The function returns a non zero value if the given argument
3581 is a white space character. The return value is zero if the character is
3582 anything else. The standard white space characters are: space, formfeed ('\f'),
3583 newline ('\n'), carriage return ('\r'), horizontal tab ('\t'), and vertical tab
3585 <tag/Limits/<itemize>
3586 <item>When compiling with <tt/-Os/ the function is actually a macro. The
3587 inline sequence generated by the macro will not work correctly for values
3588 outside the range 0..255. <em/Note:/ The constant <tt/EOF/ is not part of
3589 this range. The non inline function may be accessed by <tt/#undef/'ing the
3591 <item>When compiling without <tt/-Os/, the function is only available as
3592 fastcall function, so it may only be used in presence of a prototype.
3594 <tag/Availability/ISO 9899
3596 <ref id="isalnum" name="isalnum">,
3597 <ref id="isalpha" name="isalpha">,
3598 <ref id="isascii" name="isascii">,
3599 <ref id="isblank" name="isblank">,
3600 <ref id="iscntrl" name="iscntrl">,
3601 <ref id="isdigit" name="isdigit">,
3602 <ref id="isgraph" name="isgraph">,
3603 <ref id="islower" name="islower">,
3604 <ref id="isprint" name="isprint">,
3605 <ref id="ispunct" name="ispunct">,
3606 <ref id="isupper" name="isupper">,
3607 <ref id="isxdigit" name="isxdigit">
3613 <sect1>isupper<label id="isupper"><p>
3617 <tag/Function/Check if a given character is an upper case letter.
3618 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
3619 <tag/Declaration/<tt/int __fastcall__ isupper (int c);/
3620 <tag/Description/The function returns a non zero value if the given argument
3621 is an upper case letter. The return value is zero if the character is anything
3623 <tag/Limits/<itemize>
3624 <item>When compiling with <tt/-Os/ the function is actually a macro. The
3625 inline sequence generated by the macro will not work correctly for values
3626 outside the range 0..255. <em/Note:/ The constant <tt/EOF/ is not part of
3627 this range. The non inline function may be accessed by <tt/#undef/'ing the
3629 <item>When compiling without <tt/-Os/, the function is only available as
3630 fastcall function, so it may only be used in presence of a prototype.
3632 <tag/Availability/ISO 9899
3634 <ref id="isalnum" name="isalnum">,
3635 <ref id="isalpha" name="isalpha">,
3636 <ref id="isascii" name="isascii">,
3637 <ref id="isblank" name="isblank">,
3638 <ref id="iscntrl" name="iscntrl">,
3639 <ref id="isdigit" name="isdigit">,
3640 <ref id="isgraph" name="isgraph">,
3641 <ref id="islower" name="islower">,
3642 <ref id="isprint" name="isprint">,
3643 <ref id="ispunct" name="ispunct">,
3644 <ref id="isspace" name="isspace">,
3645 <ref id="isxdigit" name="isxdigit">
3651 <sect1>isxdigit<label id="isxdigit"><p>
3655 <tag/Function/Check if a given character is a hexadecimal digit.
3656 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
3657 <tag/Declaration/<tt/int __fastcall__ isxdigit (int c);/
3658 <tag/Description/The function returns a non zero value if the given argument
3659 is a hexadecimal digit (0..9, a..f and A..F). The return value is zero if the
3660 character is anything else.
3661 <tag/Limits/<itemize>
3662 <item>When compiling with <tt/-Os/ the function is actually a macro. The
3663 inline sequence generated by the macro will not work correctly for values
3664 outside the range 0..255. <em/Note:/ The constant <tt/EOF/ is not part of
3665 this range. The non inline function may be accessed by <tt/#undef/'ing the
3667 <item>When compiling without <tt/-Os/, the function is only available as
3668 fastcall function, so it may only be used in presence of a prototype.
3670 <tag/Availability/ISO 9899
3672 <ref id="isalnum" name="isalnum">,
3673 <ref id="isalpha" name="isalpha">,
3674 <ref id="isascii" name="isascii">,
3675 <ref id="isblank" name="isblank">,
3676 <ref id="iscntrl" name="iscntrl">,
3677 <ref id="isdigit" name="isdigit">,
3678 <ref id="isgraph" name="isgraph">,
3679 <ref id="islower" name="islower">,
3680 <ref id="isprint" name="isprint">,
3681 <ref id="ispunct" name="ispunct">,
3682 <ref id="isspace" name="isspace">,
3683 <ref id="isupper" name="isupper">
3689 <sect1>itoa<label id="itoa"><p>
3693 <tag/Function/Convert an integer into a string.
3694 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
3695 <tag/Declaration/<tt/char* __fastcall__ itoa (int val, char* buf, int radix);/
3696 <tag/Description/<tt/itoa/ converts the integer <tt/val/ into a string using
3697 <tt/radix/ as the base.
3698 <tag/Limits/<itemize>
3699 <item>There are no provisions to prevent a buffer overflow.
3700 <item>If <tt/val/ contains <tt/INT_MIN/, the behaviour is undefined.
3701 <item>The function is non standard, so it is not available in strict ANSI mode.
3702 You should probably use <tt/sprintf/ instead.
3703 <item>The function is only available as fastcall function, so it may only be
3704 used in presence of a prototype.
3706 <tag/Availability/cc65
3708 <ref id="atoi" name="atoi">,
3709 <ref id="atol" name="atol">,
3710 <ref id="ltoa" name="ltoa">,
3711 <ref id="ultoa" name="ultoa">,
3712 <ref id="utoa" name="utoa">
3718 <sect1>joy_count<label id="joy_count"><p>
3722 <tag/Function/Return the number of joysticks supported by the current driver.
3723 <tag/Header/<tt/<ref id="joystick.h" name="joystick.h">/
3724 <tag/Declaration/<tt/unsigned char joy_count (void);/
3725 <tag/Description/The function returns a the number of joysticks supported
3726 by the current joystick driver.
3727 <tag/Limits/<itemize>
3728 <item>A joystick driver must be loaded using <ref id="joy_load_driver"
3729 name="joy_load_driver"> before calling this function.
3730 <item>The function returns the number of joysticks supported by the driver.
3731 There's no way to check for the number of actually connected joysticks.
3733 <tag/Availability/cc65
3735 <ref id="joy_load_driver" name="joy_load_driver">,
3736 <ref id="joy_read" name="joy_read">
3742 <sect1>joy_install<label id="joy_install"><p>
3746 <tag/Function/Install an already loaded driver and return an error code.
3747 <tag/Header/<tt/<ref id="joystick.h" name="joystick.h">/
3748 <tag/Declaration/<tt/unsigned char __fastcall__ joy_install (void* driver);/
3749 <tag/Description/The function installs a driver that was already loaded into
3750 memory (or linked statically to the program). It returns an error code
3751 (<tt/JOY_ERR_OK/ in case of success).
3752 <tag/Limits/<itemize>
3753 <item>The function is only available as fastcall function, so it may only be
3754 used in presence of a prototype.
3756 <tag/Availability/cc65
3758 <ref id="joy_load_driver" name="joy_load_driver">,
3759 <ref id="joy_uninstall" name="joy_uninstall">,
3760 <ref id="joy_unload" name="joy_unload">
3766 <sect1>joy_load_driver<label id="joy_load_driver"><p>
3770 <tag/Function/Load a driver from disk and install it.
3771 <tag/Header/<tt/<ref id="joystick.h" name="joystick.h">/
3772 <tag/Declaration/<tt/unsigned char __fastcall__ joy_load_driver (const char* driver);/
3773 <tag/Description/The function loads a driver with the given name from disk
3774 and installs it. An error code is returned, which is <tt/JOY_ERR_OK/ if the
3775 driver was successfully loaded and installed.
3776 <tag/Limits/<itemize>
3777 <item>The function is only available as fastcall function, so it may only be
3778 used in presence of a prototype.
3780 <tag/Availability/cc65
3782 <ref id="joy_install" name="joy_install">,
3783 <ref id="joy_uninstall" name="joy_uninstall">,
3784 <ref id="joy_unload" name="joy_unload">
3790 <sect1>joy_read<label id="joy_read"><p>
3794 <tag/Function/Read the status of a joystick.
3795 <tag/Header/<tt/<ref id="joystick.h" name="joystick.h">/
3796 <tag/Declaration/<tt/unsigned char __fastcall__ joy_read (unsigned char joystick);/
3797 <tag/Description/The function reads the status bits for a joystick. The number
3798 of the joystick is passed as parameter. The result may be examined by using one
3799 of the <tt/JOY_xxx/ macros from <ref id="joystick.h" name="joystick.h">.
3800 <tag/Limits/<itemize>
3801 <item>A joystick driver must be loaded using <ref id="joy_load_driver"
3802 name="joy_load_driver"> before calling this function.
3803 <item>The function is only available as fastcall function, so it may only be
3804 used in presence of a prototype.
3806 <tag/Availability/cc65
3808 <ref id="joy_count" name="joy_count">,
3809 <ref id="joy_load_driver" name="joy_load_driver">,
3810 <ref id="joy_unload" name="joy_unload">
3816 <sect1>joy_uninstall<label id="joy_uninstall"><p>
3820 <tag/Function/Uninstall the current joystick driver.
3821 <tag/Header/<tt/<ref id="joystick.h" name="joystick.h">/
3822 <tag/Declaration/<tt/unsigned char joy_uninstall (void);/
3823 <tag/Description/The function uninstalls the currently installed joystick
3824 driver. It does not remove the driver from memory. The function returns an
3825 error code, which is <tt/JOY_ERR_OK/ if the driver was successfully uninstalled.
3826 <tag/Limits/<itemize>
3827 <item>A joystick driver must be installed using <ref id="joy_install"
3828 name="joy_install"> before calling this function.
3830 <tag/Availability/cc65
3832 <ref id="joy_install" name="joy_install">,
3833 <ref id="joy_load_driver" name="joy_load_driver">,
3834 <ref id="joy_unload" name="joy_unload">
3840 <sect1>joy_unload<label id="joy_unload"><p>
3844 <tag/Function/Uninstall, then unload the current joystick driver.
3845 <tag/Header/<tt/<ref id="joystick.h" name="joystick.h">/
3846 <tag/Declaration/<tt/unsigned char joy_unload (void);/
3847 <tag/Description/The function uninstalls the currently installed joystick
3848 driver and removes it from memory. An error code is returned, which is
3849 <tt/JOY_ERR_OK/ if the driver was successfully uninstalled.
3850 <tag/Limits/<itemize>
3851 <item>A joystick driver must be loaded using <ref id="joy_load_driver"
3852 name="joy_load_driver"> before calling this function.
3854 <tag/Availability/cc65
3856 <ref id="joy_load_driver" name="joy_load_driver">
3862 <sect1>kbhit<label id="kbhit"><p>
3866 <tag/Function/Check if there's a key waiting in the keyboard buffer.
3867 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
3868 <tag/Declaration/<tt/unsigned char kbhit (void);/
3869 <tag/Description/The function returns a value of zero if there is no character
3870 waiting to be read from the keyboard. It returns non zero otherwise.
3871 <tag/Limits/<itemize>
3872 <item>If the system does not support a keyboard buffer (most systems
3873 do), the function is rather useless.
3875 <tag/Availability/cc65
3877 <ref id="cgetc" name="cgetc">,
3878 <ref id="cursor" name="cursor">
3884 <sect1>labs<label id="labs"><p>
3888 <tag/Function/Returns the absolute value of a long integer.
3889 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
3890 <tag/Declaration/<tt/long __fastcall__ labs (long v);/
3891 <tag/Description/<tt/labs/ returns the absolute value of the argument passed to
3893 <tag/Limits/<itemize>
3894 <item>The return value is undefined if <tt/LONG_MIN/ is passed to the function.
3895 <item>The function is only available as fastcall function, so it may only be
3896 used in presence of a prototype.
3898 <tag/Availability/ISO 9899
3900 <ref id="abs" name="abs">
3906 <sect1>ltoa<label id="ltoa"><p>
3910 <tag/Function/Convert a long integer into a string.
3911 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
3912 <tag/Declaration/<tt/char* __fastcall__ ltoa (long val, char* buf, int radix);/
3913 <tag/Description/<tt/itoa/ converts the long integer <tt/val/ into a string
3914 using <tt/radix/ as the base.
3915 <tag/Limits/<itemize>
3916 <item>There are no provisions to prevent a buffer overflow.
3917 <item>If <tt/val/ contains <tt/LONG_MIN/, the behaviour is undefined.
3918 <item>The function is non standard, so it is not available in strict ANSI mode.
3919 You should probably use <tt/sprintf/ instead.
3920 <item>The function is only available as fastcall function, so it may only be
3921 used in presence of a prototype.
3923 <tag/Availability/cc65
3925 <ref id="atoi" name="atoi">,
3926 <ref id="atol" name="atol">,
3927 <ref id="itoa" name="itoa">,
3928 <ref id="ultoa" name="ultoa">,
3929 <ref id="utoa" name="utoa">
3935 <sect1>localeconv<label id="localeconv"><p>
3939 <tag/Function/Returns a pointer to the current locale structure.
3940 <tag/Header/<tt/<ref id="locale.h" name="locale.h">/
3941 <tag/Declaration/<tt/struct lconv* localeconv (void);/
3942 <tag/Description/<tt/localeconv/ returns a pointer to the current locale
3944 <tag/Limits/<itemize>
3945 <item>cc65 supports only the "C" locale, so even after setting a new locale
3946 using <tt/<ref id="setlocale" name="setlocale">/, the structure returned will
3949 <tag/Availability/ISO 9899
3951 <ref id="setlocale" name="setlocale">
3957 <sect1>longjmp<label id="longjmp"><p>
3961 <tag/Function/Non local goto.
3962 <tag/Header/<tt/<ref id="setjmp.h" name="setjmp.h">/
3963 <tag/Declaration/<tt/void __fastcall__ longjmp (jmp_buf buf, int retval);/
3964 <tag/Description/The <tt/longjmp/ function restores a program context from the
3965 data in <tt/buf/, which must have been set by a preceeding call to
3966 <tt/<ref id="setjmp" name="setjmp">/. Program execution continues as if the
3967 call to <tt/<ref id="setjmp" name="setjmp">/ has just returned the value
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/.
3996 <item>The function is only available as fastcall function, so it may only
3997 be used in presence of a prototype.
3999 <tag/Availability/ISO 9899
4001 <ref id="_heapadd" name="_heapadd">,
4002 <ref id="_heapblocksize" name="_heapblocksize">,
4003 <ref id="_heapmaxavail" name="_heapmaxavail">,
4004 <ref id="_heapmemavail" name="_heapmemavail">,
4005 <ref id="calloc" name="calloc">,
4006 <ref id="free" name="free">,
4007 <ref id="realloc" name="realloc">,
4008 <ref id="strdup" name="strdup">
4014 <sect1>memchr<label id="memchr"><p>
4018 <tag/Function/Search for a character in a block of raw memory.
4019 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4020 <tag/Declaration/<tt/void* __fastcall__ strchr (const void* mem, int c, size_t count);/
4021 <tag/Description/The <tt/memchr/ function locates the first occurrence of <tt/c/
4022 (converted to a char) in the block of raw memory string pointed to by <tt/mem/
4023 that is of size <tt/count/. Upon completion, the function returns a pointer to
4024 the character found, or a null pointer if the character was not found.
4025 <tag/Limits/<itemize>
4026 <item>The function is only available as fastcall function, so it may only
4027 be used in presence of a prototype.
4029 <tag/Availability/ISO 9899
4031 <ref id="strchr" name="strchr">
4037 <sect1>memcmp<label id="memcmp"><p>
4041 <tag/Function/Compare two memory areas.
4042 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4043 <tag/Declaration/<tt/int __fastcall__ memcmp (const void* p1, const void* p2, size_t count);/
4044 <tag/Description/<tt/memcmp/ compares <tt/count/ bytes from the memory area
4045 pointed to by <tt/p1/ into the memory area pointed to by <tt/p2/. It returns a value that is less than
4046 zero if <tt/p1/ is less than <tt/p2/, zero if <tt/p1/ is the same as <tt/p2/,
4047 and a value greater than zero if <tt/p1/ is greater than <tt/p2/.
4050 <item>The function is only available as fastcall function, so it may only
4051 be used in presence of a prototype.
4053 <tag/Availability/ISO 9899
4055 <ref id="strcmp" name="strcmp">,
4056 <ref id="memmove" name="memmove">,
4057 <ref id="memset" name="memset">
4063 <sect1>memcpy<label id="memcpy"><p>
4067 <tag/Function/Copy a memory area.
4068 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4069 <tag/Declaration/<tt/void* __fastcall__ memcpy (void* dest, const void* src, size_t count);/
4070 <tag/Description/<tt/memcpy/ copies <tt/count/ bytes from the memory area
4071 pointed to by <tt/src/ into the memory area pointed to by <tt/dest/. It returns
4075 <item>The result is undefined if the memory areas do overlap. Use
4076 <tt/<ref id="memmove" name="memmove">/ to copy overlapping memory areas.
4077 <item>The function is only available as fastcall function, so it may only
4078 be used in presence of a prototype.
4080 <tag/Availability/ISO 9899
4082 <ref id="_swap" name="_swap">,
4083 <ref id="memmove" name="memmove">,
4084 <ref id="memset" name="memset">
4090 <sect1>memmove<label id="memmove"><p>
4094 <tag/Function/Copy a memory area.
4095 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4096 <tag/Declaration/<tt/void* __fastcall__ memmove (void* dest, const void* src, size_t count);/
4097 <tag/Description/<tt/memmove/ copies <tt/count/ bytes from the memory area
4098 pointed to by <tt/src/ into the memory area pointed to by <tt/dest/. It returns
4102 <item>While <tt/memmove/ allows the memory areas to overlap, it has some
4103 additional overhead compared to <tt/<ref id="memcpy" name="memcpy">/.
4104 <item>The function is only available as fastcall function, so it may only
4105 be used in presence of a prototype.
4107 <tag/Availability/ISO 9899
4109 <ref id="_swap" name="_swap">,
4110 <ref id="memcpy" name="memcpy">,
4111 <ref id="memset" name="memset">
4117 <sect1>memset<label id="memset"><p>
4121 <tag/Function/Fill a memory area.
4122 <tag/Header/<tt/<ref id="string.h" name="string.h">/
4123 <tag/Declaration/<tt/void* __fastcall__ memset (void* p, int val, size_t count);/
4124 <tag/Description/<tt/memset/ fills the memory area pointed to by <tt/p/ with
4125 the value <tt/val/. The function returns <tt/p/.
4128 <item>The function is only available as fastcall function, so it may only
4129 be used in presence of a prototype.
4131 <tag/Availability/ISO 9899
4133 <ref id="_swap" name="_swap">,
4134 <ref id="bzero" name="bzero">,
4135 <ref id="memcpy" name="memcpy">,
4136 <ref id="memmove" name="memmove">
4142 <sect1>mod_free<label id="mod_free"><p>
4146 <tag/Function/Free a relocatable module.
4147 <tag/Header/<tt/<ref id="modload.h" name="modload.h">/
4148 <tag/Declaration/<tt/void __fastcall__ mod_free (void* module);/
4149 <tag/Description/The function will free a module loaded into memory by use of
4150 the <tt/<ref id="mod_load" name="mod_load">/ function.
4151 <tag/Limits/<itemize>
4152 <item>The pointer passed as parameter is the pointer to the module memory,
4153 not the pointer to the control structure.
4155 <tag/Availability/cc65
4157 <ref id="mod_load" name="mod_load">
4163 <sect1>mod_load<label id="mod_load"><p>
4167 <tag/Function/Load a relocatable module.
4168 <tag/Header/<tt/<ref id="modload.h" name="modload.h">/
4169 <tag/Declaration/<tt/unsigned char mod_load (struct mod_ctrl* ctrl);/
4170 <tag/Description/The function will load a code module into memory and relocate
4171 it. The function will return an error code. If <tt/MLOAD_OK/ is returned, the
4172 outgoing fields in the passed <tt/mod_ctrl/ struct contain information about
4173 the module just loaded. Possible error codes are:
4175 <item><tt/MLOAD_OK/ - Module load successful
4176 <item><tt/MLOAD_ERR_READ/ - Read error
4177 <item><tt/MLOAD_ERR_HDR/ - Header error
4178 <item><tt/MLOAD_ERR_OS/ - Wrong operating system
4179 <item><tt/MLOAD_ERR_FMT/ - Data format error
4180 <item><tt/MLOAD_ERR_MEM/ - Not enough memory
4182 <tag/Limits/<itemize>
4183 <item>The <htmlurl url="ld65.html" name="ld65"> linker is needed to create
4184 relocatable o65 modules for use with this function.
4186 <tag/Availability/cc65
4188 <ref id="mod_free" name="mod_free">
4194 <sect1>mouse_setbox<label id="mouse_setbox"><p>
4198 <tag/Function/Specify a bounding box for the mouse cursor.
4199 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
4200 <tag/Declaration/<tt/void __fastcall__ mouse_setbox (const struct mouse_box* box);/
4201 <tag/Description/The function allows to set a bounding box for mouse movement.
4202 <tag/Limits/<itemize>
4203 <item>The function does not check if the mouse cursor is currently within the
4204 given rectangle. Placing the mouse cursor within the bounding box is the
4205 responsibility of the programmer.
4206 <item>While the bounding box may be larger than the actual screen size, the
4207 standard mouse cursor draw routines may fail to set the cursor to coordinates
4208 outside of the screen area. Depending on the platform, you may have to supply
4209 your own mouse cursor routines.
4210 <item>The function is only available as fastcall function, so it may only be
4211 used in presence of a prototype.
4213 <tag/Availability/cc65
4215 <ref id="mouse_getbox" name="mouse_getbox">,
4216 <ref id="mouse_move" name="mouse_move">
4222 <sect1>mouse_getbox<label id="mouse_getbox"><p>
4226 <tag/Function/Return the current bounding box for the mouse cursor.
4227 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
4228 <tag/Declaration/<tt/void __fastcall__ mouse_getbox (struct mouse_box* box);/
4229 <tag/Description/The function queries the current bounding box for mouse
4231 <tag/Limits/<itemize>
4232 <item>The function is only available as fastcall function, so it may only be
4233 used in presence of a prototype.
4235 <tag/Availability/cc65
4237 <ref id="mouse_move" name="mouse_move">,
4238 <ref id="mouse_setbox" name="mouse_setbox">
4244 <sect1>mouse_buttons<label id="mouse_buttons"><p>
4248 <tag/Function/Return a bit mask encoding the state of the mouse buttons.
4249 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
4250 <tag/Declaration/<tt/unsigned char mouse_buttons (void);/
4251 <tag/Description/The function returns a bit mask that encodes the state of the
4252 mouse buttons. You may use the <tt/MOUSE_BTN_XXX/ flags to decode the function
4254 <tag/Availability/cc65
4256 <ref id="mouse_info" name="mouse_info">,
4257 <ref id="mouse_pos" name="mouse_pos">
4263 <sect1>mouse_geterrormsg<label id="mouse_geterrormsg"><p>
4267 <tag/Function/Return a readable error message for an error code.
4268 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
4269 <tag/Declaration/<tt/const char* __fastcall__ mouse_geterrormsg (unsigned char
4271 <tag/Description/The function returns an error message (in english) for the
4272 error code passed parameter.
4273 <tag/Limits/<itemize>
4274 <item>The function will return "Unknown error" for invalid error codes.
4275 <item>The function is only available as fastcall function, so it may only be
4276 used in presence of a prototype.
4278 <tag/Availability/cc65
4280 <ref id="mouse_load_driver" name="mouse_load_driver">,
4281 <ref id="mouse_uninstall" name="mouse_uninstall">,
4282 <ref id="mouse_unload" name="mouse_unload">
4288 <sect1>mouse_hide<label id="mouse_hide"><p>
4292 <tag/Function/Hide the mouse pointer.
4293 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
4294 <tag/Declaration/<tt/void mouse_hide (void);/
4295 <tag/Description/The function hides the mouse pointer. It manages a counter
4296 that is shared between <tt/<ref id="mouse_show" name="mouse_show">/ and
4297 <tt/mouse_hide/ so that every call call to <tt/mouse_hide/ must be followed by
4298 a call to <tt/<ref id="mouse_show" name="mouse_show">/ to make the mouse cursor
4300 <tag/Availability/cc65
4302 <ref id="mouse_show" name="mouse_show">
4308 <sect1>mouse_info<label id="mouse_info"><p>
4312 <tag/Function/Return the state of the mouse buttons and the position of the
4314 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
4315 <tag/Declaration/<tt/void __fastcall__ mouse_info (struct mouse_info* info);/
4316 <tag/Description/The function returns the state of the mouse buttons and the
4317 position of the mouse in the <tt/mouse_info/ structure passed as parameter.
4318 <tag/Limits/<itemize>
4319 <item>The <tt/mouse_info/ struct is a superset of the <tt/mouse_pos/ struct,
4320 so if you just need the mouse position, call <tt/<ref id="mouse_pos"
4321 name="mouse_pos">/ instead.
4322 <item>The function is only available as fastcall function, so it may only be
4323 used in presence of a prototype.
4325 <tag/Availability/cc65
4327 <ref id="mouse_buttons" name="mouse_buttons">,
4328 <ref id="mouse_pos" name="mouse_pos">
4334 <sect1>mouse_install<label id="mouse_install"><p>
4338 <tag/Function/Install an already loaded mouse driver.
4339 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
4340 <tag/Declaration/<tt/unsigned char __fastcall__ mouse_install (const struct
4341 mouse_callbacks* c, void* driver);/
4342 <tag/Description/The function installs an already loaded mouse driver and
4343 returns an error code. The <tt/mouse_callbacks/ structure passed as first
4344 parameter contains pointers to routines needed to move or hide/show the mouse
4345 pointer. Defaults for these routines are supplied by the library, so if you
4346 can live with these defaults (which are platform specific), just pass a
4347 pointer to <tt/mouse_def_callbacks/. The function may be used to install a
4348 driver linked statically to the program.
4349 <tag/Limits/<itemize>
4350 <item>Not all drivers are able to detect if the supported hardware is really
4352 <item>After installing a driver, the mouse cursor is hidden.
4353 <item>The function is only available as fastcall function, so it may only be
4354 used in presence of a prototype.
4356 <tag/Availability/cc65
4358 <ref id="mouse_load_driver" name="mouse_load_driver">,
4359 <ref id="mouse_uninstall" name="mouse_uninstall">,
4360 <ref id="mouse_unload" name="mouse_unload">
4366 <sect1>mouse_ioctl<label id="mouse_ioctl"><p>
4370 <tag/Function/Call the driver specific ioctl function.
4371 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
4372 <tag/Declaration/<tt/unsigned char __fastcall__ mouse_ioctl (unsigned char code, void* data);/
4373 <tag/Description/The function calls the IOCTL entry in the mouse driver,
4374 which is driver specific. The <tt/code/ parameter will choose between
4375 different IOCTL functions, and the <tt/data/ depends on code. The
4376 function returns an error code. The purpose of this function is to allow
4377 for driver specific extensions. See the documentation for a specific mouse
4378 driver for supported ioctl calls.
4379 <tag/Limits/<itemize>
4380 <item>Calling this function is non portable, because each driver may
4381 implement different ioctl calls (or none at all).
4382 <item>The function is only available as fastcall function, so it may only be
4383 used in presence of a prototype.
4385 <tag/Availability/cc65
4391 <sect1>mouse_load_driver<label id="mouse_load_driver"><p>
4395 <tag/Function/Load and initialize a mouse driver.
4396 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
4397 <tag/Declaration/<tt/unsigned char __fastcall__ mouse_load_driver (const struct
4398 mouse_callbacks* c, const char* driver);/
4399 <tag/Description/Load a mouse driver into memory and initialize it. The
4400 function returns an error code that tells if the call has been successful. The
4401 <tt/mouse_callbacks/ structure passed as first parameter contains pointers to
4402 routines needed to move or hide/show the mouse pointer. Defaults for these
4403 routines are supplied by the library, so if you can live with these defaults
4404 (which are platform specific), just pass a pointer to <tt/mouse_def_callbacks/.
4405 <tag/Limits/<itemize>
4406 <item>The driver is loaded by name, so currently you must know the type of
4407 mouse that should be supported. There is no autodetect capability.
4408 <item>Not all drivers are able to detect if the supported hardware is really
4410 <item>After installing a driver, the mouse cursor is hidden.
4411 <item>The function is only available as fastcall function, so it may only be
4412 used in presence of a prototype.
4414 <tag/Availability/cc65
4416 <ref id="mouse_install" name="mouse_install">,
4417 <ref id="mouse_uninstall" name="mouse_uninstall">,
4418 <ref id="mouse_unload" name="mouse_unload">
4424 <sect1>mouse_move<label id="mouse_move"><p>
4428 <tag/Function/Move the mouse cursor to a specific position.
4429 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
4430 <tag/Declaration/<tt/void __fastcall__ mouse_move (int x, int y);/
4431 <tag/Description/The function updates the mouse position. If the mouse cursor
4432 is visible, it is shown at the new position.
4433 <tag/Limits/<itemize>
4434 <item>The function does not check if the new position is within the bounding
4435 box specified with <tt/<ref id="mouse_setbox" name="mouse_setbox">/.
4436 <item>The function is only available as fastcall function, so it may only be
4437 used in presence of a prototype.
4439 <tag/Availability/cc65
4441 <ref id="mouse_getbox" name="mouse_getbox">,
4442 <ref id="mouse_setbox" name="mouse_setbox">
4448 <sect1>mouse_pos<label id="mouse_pos"><p>
4452 <tag/Function/Return the position of the mouse.
4453 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
4454 <tag/Declaration/<tt/void __fastcall__ mouse_pos (struct mouse_pos* pos);/
4455 <tag/Description/The function returns the position of the mouse in the
4456 <tt/mouse_pos/ structure passed as parameter.
4457 <tag/Limits/<itemize>
4458 <item>The <tt/mouse_pos/ struct is a subset of the <tt/mouse_info/ struct,
4459 so if you do also need the mouse buttons, call <tt/<ref id="mouse_info"
4460 name="mouse_info">/ instead.
4461 <item>The function is only available as fastcall function, so it may only be
4462 used in presence of a prototype.
4464 <tag/Availability/cc65
4466 <ref id="mouse_buttons" name="mouse_buttons">,
4467 <ref id="mouse_info" name="mouse_info">
4473 <sect1>mouse_show<label id="mouse_show"><p>
4477 <tag/Function/Show the mouse pointer.
4478 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
4479 <tag/Declaration/<tt/void mouse_show (void);/
4480 <tag/Description/The function shows the mouse pointer. It manages a counter
4481 that is shared between <tt/<ref id="mouse_hide" name="mouse_hide">/ and
4482 <tt/mouse_show/. The mouse cursor is visible if there was one more call to
4483 <tt/mouse_show/ than to <tt/<ref id="mouse_hide" name="mouse_hide">/.
4484 <tag/Availability/cc65
4486 <ref id="mouse_hide" name="mouse_hide">
4492 <sect1>mouse_uninstall<label id="mouse_uninstall"><p>
4496 <tag/Function/Uninstall an already loaded mouse driver.
4497 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
4498 <tag/Declaration/<tt/unsigned char mouse_uninstall (void);/
4499 <tag/Description/The function uninstalls an already loaded mouse driver but
4500 don't removes it from memory.
4501 <tag/Limits/<itemize>
4502 <item>If the driver has been loaded using <tt/<ref id="mouse_load_driver"
4503 name="mouse_load_driver">/, <tt/<ref id="mouse_unload" name="mouse_unload">/
4504 should be used instead of <tt/mouse_uninstall/ so the driver is also removed
4507 <tag/Availability/cc65
4509 <ref id="mouse_install" name="mouse_install">,
4510 <ref id="mouse_load_driver" name="mouse_load_driver">,
4511 <ref id="mouse_unload" name="mouse_unload">
4517 <sect1>mouse_unload<label id="mouse_unload"><p>
4521 <tag/Function/Unload a mouse driver.
4522 <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/
4523 <tag/Declaration/<tt/unsigned char __fastcall__ mouse_unload (void);/
4524 <tag/Description/The function unloads a loaded mouse driver and frees all
4525 memory allocated for the driver.
4526 <tag/Limits/<itemize>
4527 <item>The function does nothing if no driver is loaded.
4529 <tag/Availability/cc65
4531 <ref id="mouse_install" name="mouse_install">,
4532 <ref id="mouse_load_driver" name="mouse_load_driver">,
4533 <ref id="mouse_uninstall" name="mouse_uninstall">
4539 <sect1>offsetof<label id="offsetof"><p>
4543 <tag/Function/Calculate the offset of a struct or union member.
4544 <tag/Header/<tt/<ref id="stddef.h" name="stddef.h">/
4545 <tag/Declaration/<tt/size_t offsetof (type, member);/
4546 <tag/Description/<tt/offsetof/ calculates the address offset of a <tt/struct/
4547 or <tt/union/ member.
4548 <tag/Limits/<itemize>
4549 <item>The function is actually a macro.
4551 <tag/Availability/ISO 9899
4557 <sect1>open<label id="open"><p>
4561 <tag/Function/Open and possibly create a file.
4562 <tag/Header/<tt/<ref id="fcntl.h" name="fcntl.h">/
4563 <tag/Declaration/<tt/int open (const char* name, int flags, ...);/
4564 <tag/Description/<tt/open/ opens a file and returns the file descriptor
4565 associated with it. On error, -1 is returned and an error code is stored in
4566 <tt/errno/. Several flags may be passed to <tt/open/ that change the behaviour.
4567 <tag/Limits/<itemize>
4568 <item>POSIX specifies an additional <tt/mode/ argument that may be passed to
4569 open, which is used as the permission mask when a new file is created. While
4570 cc65 allows to pass this argument, it is ignored.
4572 <tag/Availability/POSIX 1003.1
4574 <ref id="close" name="close">,
4575 <ref id="creat" name="creat">
4581 <sect1>opendir<label id="opendir"><p>
4585 <tag/Function/Open a directory.
4586 <tag/Header/<tt/<ref id="dirent.h" name="dirent.h">/
4587 <tag/Declaration/<tt/DIR* __fastcall__ opendir (const char* name);/
4588 <tag/Description/<tt/opendir/ opens a directory and returns the direcory
4589 descriptor associated with it. On error, NULL is returned and an error code is
4590 stored in <tt/errno/.
4591 <tag/Limits/<itemize>
4592 <item>The function is only available as fastcall function, so it may only
4593 be used in presence of a prototype.
4595 <tag/Availability/POSIX 1003.1
4597 <ref id="closedir" name="closedir">,
4598 <ref id="readdir" name="readdir">
4604 <sect1>peekbsys<label id="peekbsys"><p>
4608 <tag/Function/Read one byte from a location in the system bank.
4609 <tag/Header/<tt/<ref id="cbm610.h" name="cbm610.h">/,
4610 <tt/<ref id="cbm510.h" name="cbm510.h">/
4611 <tag/Declaration/<tt/unsigned char __fastcall__ peekbsys (unsigned addr);/
4612 <tag/Description/<tt/peekbsys/ reads one byte from the given address in the
4613 system bank (bank 15) of the CBM PET-II machines and returns it.
4616 <item>The function is only available as fastcall function, so it may only
4617 be used in presence of a prototype.
4618 <item>This function may be a macro depending on the compiler options. The
4619 actual function is accessible by #undef'ing the macro.
4621 <tag/Availability/cc65
4623 <ref id="PEEK" name="PEEK">,
4624 <ref id="PEEKW" name="PEEKW">,
4625 <ref id="peekwsys" name="peekwsys">,
4626 <ref id="pokebsys" name="pokebsys">,
4627 <ref id="pokewsys" name="pokewsys">
4633 <sect1>peekwsys<label id="peekwsys"><p>
4637 <tag/Function/Read one word from a location in the system bank.
4638 <tag/Header/<tt/<ref id="cbm610.h" name="cbm610.h">/,
4639 <tt/<ref id="cbm510.h" name="cbm510.h">/
4640 <tag/Declaration/<tt/unsigned __fastcall__ peekwsys (unsigned addr);/
4641 <tag/Description/<tt/peekwsys/ reads one word from the given address in the
4642 system bank (bank 15) of the CBM PET-II machines and returns it. Following
4643 the usual 6502 conventions, the low byte is read from <tt/addr/, and the
4644 high byte is read from <tt/addr+1/.
4647 <item>The function is only available as fastcall function, so it may only
4648 be used in presence of a prototype.
4649 <item>The order in which the two bytes are read is undefined.
4651 <tag/Availability/cc65
4653 <ref id="PEEK" name="PEEK">,
4654 <ref id="PEEKW" name="PEEKW">,
4655 <ref id="peekbsys" name="peekbsys">,
4656 <ref id="pokebsys" name="pokebsys">,
4657 <ref id="pokewsys" name="pokewsys">
4663 <sect1>perror<label id="perror"><p>
4667 <tag/Function/Print an error message for the error in <tt/errno/.
4668 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
4669 <tag/Declaration/<tt/void __fastcall__ perror (const char* s);/
4670 <tag/Description/<tt/perror/ prints an error message to <tt/stderr/. If <tt/s/
4671 is not <tt/NULL/ and not an empty string, it is printed followed by a colon and
4672 a blank. Then the error message for the current contents of <tt/errno/ is
4673 printed followed by a newline. The message output is the same as returned by
4674 <tt/<ref id="strerror" name="strerror">/ with an argument of <tt/errno/.
4677 <item>The function is only available as fastcall function, so it may only
4678 be used in presence of a prototype.
4680 <tag/Availability/ISO 9899
4682 <ref id="_poserror" name="_poserror">,
4683 <ref id="strerror" name="strerror">
4689 <sect1>pokebsys<label id="pokebsys"><p>
4693 <tag/Function/Write one byte to a location in the system bank.
4694 <tag/Header/<tt/<ref id="cbm610.h" name="cbm610.h">/,
4695 <tt/<ref id="cbm510.h" name="cbm510.h">/
4696 <tag/Declaration/<tt/void __fastcall__ pokebsys (unsigned addr, unsigned char val);/
4697 <tag/Description/<tt/pokebsys/ writes one byte to the given address in the
4698 system bank (bank 15) of the CBM PET-II machines.
4701 <item>The function is only available as fastcall function, so it may only
4702 be used in presence of a prototype.
4704 <tag/Availability/cc65
4706 <ref id="POKE" name="POKE">,
4707 <ref id="POKEW" name="POKEW">,
4708 <ref id="peekbsys" name="peekbsys">,
4709 <ref id="peekwsys" name="peekwsys">,
4710 <ref id="pokewsys" name="pokewsys">
4716 <sect1>pokewsys<label id="pokewsys"><p>
4720 <tag/Function/Write one word to a location in the system bank.
4721 <tag/Header/<tt/<ref id="cbm610.h" name="cbm610.h">/,
4722 <tt/<ref id="cbm510.h" name="cbm510.h">/
4723 <tag/Declaration/<tt/void __fastcall__ pokewsys (unsigned addr, unsigned val);/
4724 <tag/Description/<tt/pokewsys/ writes one word to the given address in the
4725 system bank (bank 15) of the CBM PET-II machines. Following the usual 6502
4726 conventions, the low byte of <tt/val/ is written to <tt/addr/, and the
4727 high byte is written to <tt/addr+1/.
4730 <item>The function is only available as fastcall function, so it may only
4731 be used in presence of a prototype.
4732 <item>The order in which the two bytes are written is undefined.
4734 <tag/Availability/cc65
4736 <ref id="POKE" name="POKE">,
4737 <ref id="POKEW" name="POKEW">,
4738 <ref id="peekbsys" name="peekbsys">,
4739 <ref id="peekwsys" name="peekwsys">,
4740 <ref id="pokebsys" name="pokebsys">
4746 <sect1>qsort<label id="qsort"><p>
4750 <tag/Function/Sort an array.
4751 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
4752 <tag/Declaration/<tt/void __fastcall__ qsort (void* base, size_t count,
4753 size_t size, int (*compare) (const void*, const void*));/
4754 <tag/Description/<tt/qsort/ sorts an array according to a given compare
4755 function <tt/compare/. <tt/base/ is the address of the array, <tt/count/
4756 is the number of elements, <tt/size/ the size of an element and <tt/compare/
4757 the function used to compare the members.
4760 <item>If there are multiple members with the same key, the order after calling
4761 the function is undefined.
4762 <item>The function is only available as fastcall function, so it may only
4763 be used in presence of a prototype.
4765 <tag/Availability/ISO 9899
4767 <ref id="bsearch" name="bsearch">
4773 <sect1>raise<label id="raise"><p>
4777 <tag/Function/Send a signal to the executing program.
4778 <tag/Header/<tt/<ref id="signal.h" name="signal.h">/
4779 <tag/Declaration/<tt/int __fastcall__ raise (int sig);/
4780 <tag/Description/<tt/raise/ sends the given signal to the program. If the
4781 program has installed a signal handler for the signal, this signal handler
4782 will be executed. If no handler has been installed, the default action for
4783 the raised signal will be taken. The function returns zero on success,
4785 <tag/Limits/<itemize>
4786 <item>The function is only available as fastcall function, so it may only
4787 be used in presence of a prototype.
4789 <tag/Availability/ISO 9899
4791 <ref id="abort" name="abort">,
4792 <ref id="signal" name="signal">
4798 <sect1>rand<label id="rand"><p>
4802 <tag/Function/Return a pseudo random number.
4803 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
4804 <tag/Declaration/<tt/int rand (void);/
4805 <tag/Description/The function returns a pseudo random number
4806 between 0 and <tt/RAND_MAX/ (exclusive).
4807 <tag/Limits/<itemize>
4808 <item>Without using <tt><ref id="srand" name="srand"></tt>, always the same
4809 flow of numbers is generated.
4810 <item>On startup, the function behaves as if <ref id="srand" name="srand">
4811 had been used with an argument of 1.
4813 <tag/Availability/ISO 9899
4815 <ref id="_randomize" name="_randomize">,
4816 <ref id="srand" name="srand">
4822 <sect1>readdir<label id="readdir"><p>
4826 <tag/Function/Read a directory.
4827 <tag/Header/<tt/<ref id="dirent.h" name="dirent.h">/
4828 <tag/Declaration/<tt/struct dirent* __fastcall__ readdir (DIR* dir);/
4829 <tag/Description/<tt/readdir/ reads the next directory entry from the directory
4830 stream pointed to by <tt/dir/. It stores the data in a <tt/dirent/ structure
4831 and returns a pointer to it. If the end of directory is reached, or an error
4832 occurs, NULL is returned. In case of errors, an error code is stored into
4834 <tag/Limits/<itemize>
4835 <item>The function is only available as fastcall function, so it may only
4836 be used in presence of a prototype.
4837 <item>The returned pointer may point to a statically allocated instance of
4838 <tt/struct dirent/, so it may get overwritten by subsequent calls to
4840 <item>On several platforms, namely the CBMs and the Atari, the disk drives get
4841 confused when opening/closing files between directory reads. So for example a
4842 program that reads the list of files on a disk, and after each call to
4843 <tt/readdir/, opens the file to process it, will fail.<newline>
4844 Possible solutions are reading the directory into memory before processing the
4845 file list, or to reset the directory by seeking to the correct position after
4846 opening/closing a file:
4848 seekdir (DIR, telldir (DIR));
4850 Platforms known to work without problems are: Apple.
4852 <tag/Availability/POSIX 1003.1
4854 <ref id="closedir" name="closedir">,
4855 <ref id="opendir" name="opendir">
4861 <sect1>realloc<label id="realloc"><p>
4865 <tag/Function/Change the size of an allocated memory block.
4866 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
4867 <tag/Declaration/<tt/void* __fastcall__ realloc (void* block, size_t size);/
4868 <tag/Description/<tt/realloc/ changes the size of the memory block pointed to
4869 by <tt/block/ to <tt/size/ bytes. If <tt/block/ is <tt/NULL/, <tt/realloc/
4870 behaves as if <tt/malloc/ had been called. If <tt/size/ is zero, <tt/realloc/
4871 behaves as if <tt/free/ had been called. On error (not enough memory
4872 available), <tt/realloc/ returns <tt/NULL/.
4875 <item>The part of the memory block that is returned will have its contents
4877 <item>This function is somewhat dangerous to use. Be careful to save the
4878 pointer you're passing somewhere else, otherwise
4880 ptr = realloc (ptr, size);
4882 will loose your only copy of <tt/ptr/ if <tt/realloc/ returns <tt/NULL/.
4883 <item>The function is only available as fastcall function, so it may only
4884 be used in presence of a prototype.
4886 <tag/Availability/ISO 9899
4888 <ref id="_heapadd" name="_heapadd">,
4889 <ref id="_heapblocksize" name="_heapblocksize">,
4890 <ref id="_heapmaxavail" name="_heapmaxavail">,
4891 <ref id="_heapmemavail" name="_heapmemavail">,
4892 <ref id="calloc" name="calloc">,
4893 <ref id="free" name="free">,
4894 <ref id="realloc" name="realloc">
4900 <sect1>remove<label id="remove"><p>
4904 <tag/Function/Delete a file.
4905 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
4906 <tag/Declaration/<tt/int __fastcall__ remove (const char* name);/
4907 <tag/Description/<tt/remove/ deletes the file with the given name. On success,
4908 zero is returned. On error, -1 is returned and <tt/errno/ is set to an error
4909 code describing the reason for the failure.
4912 <item>This function is not available on all cc65 targets (depends on the
4913 availability of file I/O).
4914 <item>The function is only available as fastcall function, so it may only
4915 be used in presence of a prototype.
4917 <tag/Availability/ISO 9899
4919 <ref id="rename" name="rename">,
4920 <ref id="unlink" name="unlink">
4923 #include <stdio.h>
4925 #define FILENAME "helloworld"
4927 if (remove (FILENAME) == 0) {
4928 printf ("We deleted %s successfully\n", FILENAME);
4930 printf ("There was a problem deleting %s\n", FILENAME);
4937 <sect1>rename<label id="rename"><p>
4941 <tag/Function/Rename a file.
4942 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
4943 <tag/Declaration/<tt/int __fastcall__ rename (const char* oldname, const char* newname);/
4944 <tag/Description/<tt/rename/ renames a file (gives it a new name). On success,
4945 zero is returned. On error, -1 is returned and <tt/errno/ is set to an error
4946 code describing the reason for the failure.
4949 <item>This function is not available on all cc65 targets (depends on the
4950 capabilities of the storage devices).
4951 <item>The function is only available as fastcall function, so it may only
4952 be used in presence of a prototype.
4954 <tag/Availability/ISO 9899
4956 <ref id="remove" name="remove">
4959 #include <stdio.h>
4961 #define OLDNAME "textfile.txt"
4962 #define NEWNAME "textfile.bak"
4964 if (rename (OLDNAME, NEWNAME) == 0) {
4965 printf ("Renamed %s to %s\n", OLDNAME, NEWNAME);
4967 printf ("Error renaming %s to %s\n", OLDNAME, NEWNAME);
4974 <sect1>reset_brk<label id="reset_brk"><p>
4978 <tag/Function/Resets the break vector to its original value.
4979 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
4980 <tag/Declaration/<tt/void reset_brk (void);/
4981 <tag/Description/<tt/reset_brk/ resets the break vector to the value it had
4982 before a call to <tt/set_brk/.
4985 <item>Since <tt/<ref id="set_brk" name="set_brk">/ installs an exit handler,
4986 it is not strictly necessary to call this function as part of the cleanup when
4989 <tag/Availability/cc65
4991 <ref id="reset_irq" name="reset_irq">,
4992 <ref id="set_brk" name="set_brk">,
4993 <ref id="set_irq" name="set_irq">
4999 <sect1>reset_irq<label id="reset_irq"><p>
5003 <tag/Function/Resets the C level interrupt request vector.
5004 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
5005 <tag/Declaration/<tt/void reset_irq (void);/
5006 <tag/Description/<tt/reset_irq/ resets the C level interrupt request vector.
5009 <item>The original IRQ vector is restored on program termination even without
5010 calling this function.
5012 <tag/Availability/cc65
5014 <ref id="reset_brk" name="reset_brk">,
5015 <ref id="set_brk" name="set_brk">,
5016 <ref id="set_irq" name="set_irq">
5022 <sect1>revers<label id="revers"><p>
5026 <tag/Function/Control revers character display.
5027 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
5028 <tag/Declaration/<tt/unsigned char __fastcall__ revers (unsigned char onoff);/
5029 <tag/Description/If the argument is non zero, the function enables reverse
5030 character display. If the argument is zero, reverse character display is
5031 switched off. The old value of the setting is returned.
5032 <tag/Limits/<itemize>
5033 <item>The function may not be supported by the hardware, in which case
5034 the call is ignored.
5035 <item>The function is only available as fastcall function, so it may only
5036 be used in presence of a prototype.
5038 <tag/Availability/cc65
5040 <ref id="textcolor" name="textcolor">
5046 <sect1>rewinddir<label id="rewinddir"><p>
5050 <tag/Function/Reset a directory stream.
5051 <tag/Header/<tt/<ref id="dirent.h" name="dirent.h">/
5052 <tag/Declaration/<tt/void __fastcall__ rewinddir (DIR* dir);/
5053 <tag/Description/<tt/rewinddir/ sets the position of the directory stream
5054 pointed to by <tt/dir/ to the start of the directory.
5055 <tag/Limits/<itemize>
5056 <item>The function is only available as fastcall function, so it may only
5057 be used in presence of a prototype.
5059 <tag/Availability/POSIX 1003.1
5061 <ref id="seekdir" name="seekdir">,
5062 <ref id="telldir" name="telldir">
5068 <sect1>screensize<label id="screensize"><p>
5072 <tag/Function/Return the dimensions of the text mode screen.
5073 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
5074 <tag/Declaration/<tt/void __fastcall__ screensize (unsigned char* x, unsigned char* y);/
5075 <tag/Description/The function returns the dimensions of the text mode screen.
5076 <tag/Limits/<itemize>
5077 <item>The function is only available as fastcall function, so it may only
5078 be used in presence of a prototype.
5080 <tag/Availability/cc65
5082 <ref id="gotox" name="gotox">,
5083 <ref id="gotoxy" name="gotoxy">,
5084 <ref id="gotoy" name="gotoy">,
5085 <ref id="wherex" name="wherex">,
5086 <ref id="wherey" name="wherey">
5092 <sect1>seekdir<label id="seekdir"><p>
5096 <tag/Function/Set the position of a directory stream.
5097 <tag/Header/<tt/<ref id="dirent.h" name="dirent.h">/
5098 <tag/Declaration/<tt/void __fastcall__ seekdir (DIR* dir, long offset);/
5099 <tag/Description/<tt/seekdir/ sets the position of the directory stream
5100 pointed to by <tt/dir/ to the value given in <tt/offset/, which should be a
5101 value returned by <tt/<ref id="telldir" name="telldir">/.
5102 <tag/Limits/<itemize>
5103 <item>The function is only available as fastcall function, so it may only
5104 be used in presence of a prototype.
5106 <tag/Availability/POSIX 1003.1
5108 <ref id="rewinddir" name="rewinddir">,
5109 <ref id="telldir" name="telldir">
5115 <sect1>ser_close<label id="ser_close"><p>
5119 <tag/Function/Close the port and disable interrupts
5120 <tag/Header/<tt/<ref id="serial.h" name="serial.h">/
5121 <tag/Declaration/<tt/unsigned char ser_close (void);/
5122 <tag/Description/Close the port by clearing buffers and disable interrupts.
5123 <tag/Availability/cc65
5124 <tag/See also/Other serial functions.
5129 static void initialize(){
5130 struct ser_params params = {
5137 ser_install(lynx_comlynx); // This will activate the ComLynx
5139 ser_open(&params);
5146 <sect1>ser_get<label id="ser_get"><p>
5150 <tag/Function/Read a character from serial port.
5151 <tag/Header/<tt/<ref id="serial.h" name="serial.h">/
5152 <tag/Declaration/<tt/unsigned char __fastcall__ ser_get (char* b);/
5153 <tag/Description/Get a character from the serial port. If no characters are
5154 available, the function will return SER_ERR_NO_DATA, so this is not a fatal
5156 <tag/Limits/<itemize>
5157 <item>The function is only available as fastcall function, so it may only
5158 be used in presence of a prototype.
5160 <tag/Availability/cc65
5161 <tag/See also/Other serial functions.
5163 Wait for a character to be available from a serial port.
5166 while (ser_get(&ch) == SER_ERR_NO_DATA)
5173 <sect1>ser_install<label id="ser_install"><p>
5177 <tag/Function/Install an already loaded driver and return an error code.
5178 <tag/Header/<tt/<ref id="serial.h" name="serial.h">/
5179 <tag/Declaration/<tt/unsigned char __fastcall__ ser_install (void* driver);/
5180 <tag/Description/The function installs a driver that was already loaded into
5181 memory (or linked statically to the program). It returns an error code
5182 (<tt/SER_ERR_OK/ in case of success).
5183 <tag/Limits/<itemize>
5184 <item>The function is only available as fastcall function, so it may only be
5185 used in presence of a prototype.
5187 <tag/Availability/cc65
5189 <ref id="ser_load_driver" name="ser_load_driver">,
5190 <ref id="ser_uninstall" name="ser_uninstall">,
5191 <ref id="ser_unload" name="ser_unload">
5193 ser_install(lynx_comlynx); //Include the driver statically instead of loading it.
5199 <sect1>ser_ioctl<label id="ser_ioctl"><p>
5203 <tag/Function/Platform dependent code extensions.
5204 <tag/Header/<tt/<ref id="serial.h" name="serial.h">/
5205 <tag/Declaration/<tt/unsigned __fastcall__ ser_ioctl (unsigned char code, void* data);/
5206 <tag/Description/Some platforms have extra serial functions that are not
5207 supported by standard serial driver functions. You can extend the driver to support
5208 this extra functionality bt using ser_ioctl functions.
5209 <tag/Limits/<itemize>
5210 <item>The function is only available as fastcall function, so it may only
5211 be used in presence of a prototype.
5212 <item>These functions are not easily portable to other cc65 platforms.
5214 <tag/Availability/cc65
5215 <tag/See also/Other serial functions.
5220 <sect1>ser_load_driver<label id="ser_load_driver"><p>
5224 <tag/Function/Load and install a serial driver.
5225 <tag/Header/<tt/<ref id="serial.h" name="serial.h">/
5226 <tag/Declaration/<tt/unsigned char __fastcall__ ser_load_driver (const char *name);/
5227 <tag/Description/Load and install the driver by name.
5228 Will just load the driver and check if loading was successful.
5229 <tag/Limits/<itemize>
5230 <item>The function is only available as fastcall function, so it may only
5231 be used in presence of a prototype.
5233 <tag/Availability/cc65
5234 <tag/See also/Other serial functions.
5240 <sect1>ser_open<label id="ser_open"><p>
5244 <tag/Function/Open the port by setting the port parameters and enable interrupts
5245 <tag/Header/<tt/<ref id="serial.h" name="serial.h">/
5246 <tag/Declaration/<tt/unsigned char __fastcall__ ser_open (const struct ser_params* params);/
5247 <tag/Description/Open the port by setting the port parameters and enable interrupts.
5248 <tag/Limits/<itemize>
5249 <item>The function is only available as fastcall function, so it may only
5250 be used in presence of a prototype.
5252 <tag/Availability/cc65
5253 <tag/See also/Other serial functions.
5258 static void initialize(){
5259 struct ser_params params = {
5266 ser_install(lynx_comlynx); // This will activate the ComLynx
5268 ser_open(&params);
5275 <sect1>ser_put<label id="ser_put"><p>
5279 <tag/Function/Write a character to a serial port.
5280 <tag/Header/<tt/<ref id="serial.h" name="serial.h">/
5281 <tag/Declaration/<tt/unsigned char __fastcall__ ser_put (char b);/
5282 <tag/Description/Send a character via the serial port. There is a transmit
5283 buffer, but transmitting is not done via interrupt. The function returns
5284 SER_ERR_OVERFLOW if there is no space left in the transmit buffer.
5285 <tag/Limits/<itemize>
5286 <item>The function is only available as fastcall function, so it may only
5287 be used in presence of a prototype.
5289 <tag/Availability/cc65
5290 <tag/See also/Other serial functions.
5299 <sect1>ser_status<label id="ser_status"><p>
5303 <tag/Function/Return the serial port status.
5304 <tag/Header/<tt/<ref id="serial.h" name="serial.h">/
5305 <tag/Declaration/<tt/unsigned char __fastcall__ ser_status (unsigned char* status);/
5306 <tag/Description/Return the serial port status.
5307 <tag/Limits/<itemize>
5308 <item>The function is only available as fastcall function, so it may only
5309 be used in presence of a prototype.
5311 <tag/Availability/cc65
5312 <tag/See also/Other serial functions.
5318 <sect1>ser_uninstall<label id="ser_uninstall"><p>
5322 <tag/Function/Uninstall the currently loaded driver but do not unload it.
5323 <tag/Header/<tt/<ref id="serial.h" name="serial.h">/
5324 <tag/Declaration/<tt/unsigned char ser_uninstall (void);/
5325 <tag/Description/Uninstall the currently loaded driver but do not unload it.
5326 <tag/Availability/cc65
5327 <tag/See also/Other serial functions.
5332 <sect1>ser_unload<label id="ser_unload"><p>
5336 <tag/Function/Uninstall, then unload the currently loaded driver.
5337 <tag/Header/<tt/<ref id="serial.h" name="serial.h">/
5338 <tag/Declaration/<tt/unsigned char ser_unload (void);/
5339 <tag/Description/Uninstall, then unload the currently loaded driver.
5340 <tag/Availability/cc65
5341 <tag/See also/Other serial functions.
5347 <sect1>set_brk<label id="set_brk"><p>
5351 <tag/Function/Set the break vector to a user function.
5352 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
5353 <tag/Declaration/<tt/void __fastcall__ set_brk (brk_handler func);/
5354 <tag/Description/<tt/set_brk/ allows a user program to handle breaks within the
5355 program code by letting the vector point to a user written C function. The
5356 runtime library installs a small stub that saves the registers into global
5357 variables that may be accessed (and changed) by the break handler.
5360 <item>The function is only available as fastcall function, so it may only
5361 be used in presence of a prototype.
5362 <item>The stub saves the zero page registers used by the C runtime and switches
5363 to a small break handler stack. This means that it is safe to execute C code,
5364 even if C code was interrupted. Be careful however not to use too many local
5365 variables, and do not enable stack checks for the handler function or any other
5366 function called from it.
5367 <item>The <tt/brk_pc/ variable points to the <tt/BRK/ instruction. If you want
5368 the continue with the interrupted code, you have to adjust <tt/brk_pc/,
5369 otherwise the <tt/BRK/ instruction will get executed over and over again.
5370 <item>Since <tt/set_brk/ installs an exit handler, it is not strictly necessary
5371 to call <tt/<ref id="reset_brk" name="reset_brk">/ as part of the cleanup when
5372 the program terminates.
5374 <tag/Availability/cc65
5376 <ref id="reset_brk" name="reset_brk">
5382 <sect1>set_irq<label id="set_irq"><p>
5386 <tag/Function/Set the C level interrupt request vector to the given address.
5387 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
5388 <tag/Declaration/<tt/void __fastcall__ set_irq (irq_handler f, void *stack_addr, size_t stack_size);/
5389 <tag/Description/<tt/set_irq/ allows a user program to handle interrupt requests
5390 (IRQs) within the program code by letting the vector point to a user written C
5391 function. The runtime library installs a small stub that saves the zero page
5392 registers used by the C runtime before calling the handler function and restores
5393 them after the handler function returns. Additionally the stub temporarily switches
5394 the C runtime stack to the stack area provided as parameter. If the handler function
5395 was set up to handle a "private", "exclusive" interrupt request source it must
5396 return the value <tt/IRQ_HANDLED/ if and only if it has verified that the current
5397 interrupt request actually stems from that source. In all other cases it must return
5398 the value <tt/IRQ_NOT_HANDLED/.
5401 <item>The function is only available as fastcall function, so it may only
5402 be used in presence of a prototype.
5403 <item>The stub saves the registers and zero page locations used by the C runtime
5404 and switches to the provided stack area. As a consequence, there is some
5405 runtime overhead, but it it is safe to execute C code, even if other C code
5406 was interrupted. Be careful however not to call C library functions, and do not
5407 enable stack checks for the handler function or any other function called from
5409 <item>The interrupt vector is reset on function termination, so it's not
5410 strictly necessary to call <tt/<ref id="reset_irq" name="reset_irq">/ as part
5411 of the cleanup when the program terminates.
5413 <tag/Availability/cc65
5415 <ref id="reset_brk" name="reset_brk">,
5416 <ref id="reset_irq" name="reset_irq">,
5417 <ref id="set_brk" name="set_brk">
5423 <sect1>setjmp<label id="setjmp"><p>
5427 <tag/Function/Save the context for use with <tt/longjmp/.
5428 <tag/Header/<tt/<ref id="setjmp.h" name="setjmp.h">/
5429 <tag/Declaration/<tt/int __fastcall__ setjmp (jmp_buf buf);/
5430 <tag/Description/The <tt/setjmp/ function saves the current context in <tt/buf/
5431 for subsequent use by the <tt/<ref id="longjmp" name="longjmp">/ function and
5435 <item>The function is only available as fastcall function, so it may only
5436 be used in presence of a prototype.
5437 <item><tt/setjmp/ is actually a macro as required by the ISO standard.
5438 <item><tt/setjmp/ will not save the signal context.
5440 <tag/Availability/ISO 9899
5442 <ref id="longjmp" name="longjmp">
5448 <sect1>setlocale<label id="setlocale"><p>
5452 <tag/Function/Selects a locale.
5453 <tag/Header/<tt/<ref id="locale.h" name="locale.h">/
5454 <tag/Declaration/<tt/char* __fastcall__ setlocale (int category, const char* locale);/
5455 <tag/Description/<tt/setlocale/ sets or queries the program's locale.
5458 <item>The function is only available as fastcall function, so it may only
5459 be used in presence of a prototype.
5460 <item>cc65 supports only the "C" locale, so calling this function to set a
5461 different locale has no effect.
5463 <tag/Availability/ISO 9899
5465 <ref id="localeconv" name="localeconv">,
5466 <ref id="strcoll" name="strcoll">
5467 <ref id="strxfrm" name="strxfrm">
5473 <sect1>signal<label id="signal"><p>
5477 <tag/Function/Install a signal handler.
5478 <tag/Header/<tt/<ref id="signal.h" name="signal.h">/
5479 <tag/Declaration/<tt/__sigfunc __fastcall__ signal (int sig, __sigfunc func);/
5480 <tag/Description/<tt/signal/ installs a handler for the given signal. The
5481 handler may either be a user supplied function, or one of the predefined
5482 signal handlers <tt/SIG_IGN/ or <tt/SIG_DFL/. The function returns the
5483 previous value if the signal , or the special function vector SIG_ERR in
5485 <tag/Limits/<itemize>
5486 <item>The function is only available as fastcall function, so it may only
5487 be used in presence of a prototype.
5489 <tag/Availability/ISO 9899
5491 <ref id="abort" name="abort">,
5492 <ref id="raise" name="raise">
5498 <sect1>sleep<label id="sleep"><p>
5502 <tag/Function/Sleep for a specified amount of time.
5503 <tag/Header/<tt/<ref id="unistd.h" name="unistd.h">/
5504 <tag/Declaration/<tt/void __fastcall__ sleep (unsigned seconds);/
5505 <tag/Description/The function will return after the specified number of
5506 seconds have elapsed.
5507 <tag/Limits/<itemize>
5508 <item>The function is only available as fastcall function, so it may only
5509 be used in presence of a prototype.
5511 <tag/Availability/POSIX 1003.1
5517 <sect1>slow<label id="slow"><p>
5521 <tag/Function/Switch the C128 into 1MHz mode.
5522 <tag/Header/<tt/<ref id="c128.h" name="c128.h">/
5523 <tag/Declaration/<tt/void slow (void);/
5524 <tag/Description/The function will switch the clock of the C128 to 1MHz. This
5525 will halve the speed compared to fast mode.
5526 <tag/Limits/<itemize>
5527 <item>The function is specific to the C128.
5529 <tag/Availability/C128
5531 <ref id="fast" name="fast">,
5532 <ref id="toggle_videomode" name="toggle_videomode">,
5533 <ref id="videomode" name="videomode">
5539 <sect1>srand<label id="srand"><p>
5543 <tag/Function/Initialize the pseudo random number generator.
5544 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
5545 <tag/Declaration/<tt/void __fastcall__ srand (unsigned seed);/
5546 <tag/Description/The function initializes the random number generator using
5547 the given seed. On program startup, the generator behaves as if <tt/srand/ has
5548 been called with an argument of 1.
5549 <tag/Limits/<itemize>
5550 <item>The function is only available as fastcall function, so it may only
5551 be used in presence of a prototype.
5553 <tag/Availability/ISO 9899
5555 <ref id="_randomize" name="_randomize">,
5556 <ref id="rand" name="rand">
5562 <sect1>strcasecmp<label id="strcasecmp"><p>
5566 <tag/Function/Compare two strings case insensitive.
5567 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5568 <tag/Declaration/<tt/int __fastcall__ strcasecmp (const char* s1, const char* s2);/
5569 <tag/Description/The <tt/strcasecmp/ function compares the two strings passed
5570 as parameters without case sensitivity. It returns a value that is less than
5571 zero if <tt/s1/ is less than <tt/s2/, zero if <tt/s1/ is the same as <tt/s2/,
5572 and a value greater than zero if <tt/s1/ is greater than <tt/s2/.
5573 <tag/Limits/<itemize>
5574 <item>The function is only available as fastcall function, so it may only
5575 be used in presence of a prototype.
5576 <item>The function is not available in strict ANSI mode.
5578 <tag/Availability/cc65
5580 <ref id="strcmp" name="strcmp">,
5581 <ref id="strcoll" name="strcoll">,
5582 <ref id="stricmp" name="stricmp">,
5583 <ref id="strncmp" name="strncmp">,
5584 <ref id="strxfrm" name="strxfrm">
5590 <sect1>strcat<label id="strcat"><p>
5594 <tag/Function/Concatentate two strings.
5595 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5596 <tag/Declaration/<tt/char* __fastcall__ strcat (char* s1, const char* s2);/
5597 <tag/Description/The <tt/strcat/ function appends a copy of the string
5598 pointed to by s2 (including the terminating null byte) to the end of the
5599 string pointed to by s1. The initial byte of s2 overwrites the null byte at
5601 <tag/Limits/<itemize>
5602 <item>The function is only available as fastcall function, so it may only
5603 be used in presence of a prototype.
5604 <item>If copying takes place between objects that overlap, the behaviour
5607 <tag/Availability/ISO 9899
5609 <ref id="strcpy" name="strcpy">,
5610 <ref id="strncat" name="strncat">,
5611 <ref id="strncpy" name="strncpy">
5617 <sect1>strchr<label id="strchr"><p>
5621 <tag/Function/Search for a character in a string.
5622 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5623 <tag/Declaration/<tt/char* __fastcall__ strchr (const char* s, int c);/
5624 <tag/Description/The <tt/strchr/ function locates the first occurrence of <tt/c/
5625 (converted to a char) in the string pointed to by <tt/s/. The terminating null
5626 byte is considered to be part of the string. Upon completion, the function
5627 returns a pointer to the byte, or a null pointer if the byte was not found.
5628 <tag/Limits/<itemize>
5629 <item>The function is only available as fastcall function, so it may only
5630 be used in presence of a prototype.
5632 <tag/Availability/ISO 9899
5634 <ref id="memchr" name="memchr">,
5635 <ref id="strrchr" name="strrchr">
5641 <sect1>strcmp<label id="strcmp"><p>
5645 <tag/Function/Compare two strings.
5646 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5647 <tag/Declaration/<tt/int __fastcall__ strcmp (const char* s1, const char* s2);/
5648 <tag/Description/The <tt/strcmp/ function compares the two strings passed as
5649 parameters. It returns a value that is less than zero if <tt/s1/ is less than
5650 <tt/s2/, zero if <tt/s1/ is the same as <tt/s2/, and a value greater than zero
5651 if <tt/s1/ is greater than <tt/s2/.
5652 <tag/Limits/<itemize>
5653 <item>The function is only available as fastcall function, so it may only
5654 be used in presence of a prototype.
5656 <tag/Availability/ISO 9899
5658 <ref id="strcasecmp" name="strcasecmp">,
5659 <ref id="strcoll" name="strcoll">,
5660 <ref id="stricmp" name="stricmp">,
5661 <ref id="strncmp" name="strncmp">
5662 <ref id="strxfrm" name="strxfrm">
5668 <sect1>strcoll<label id="strcoll"><p>
5672 <tag/Function/Compare two strings.
5673 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5674 <tag/Declaration/<tt/int __fastcall__ strcoll (const char* s1, const char* s2);/
5675 <tag/Description/The <tt/strcoll/ function compares the two strings passed as
5676 parameters, according to the collating sequence set by <tt/<ref id="setlocale"
5677 name="setlocale">/. It returns a value that is less than zero if <tt/s1/ is
5678 less than <tt/s2/, zero if <tt/s1/ is the same as <tt/s2/, and a value greater
5679 than zero if <tt/s1/ is greater than <tt/s2/.
5680 <tag/Limits/<itemize>
5681 <item>The function is only available as fastcall function, so it may only
5682 be used in presence of a prototype.
5684 <tag/Availability/ISO 9899
5686 <ref id="setlocale" name="setlocale">,
5687 <ref id="strcasecmp" name="strcasecmp">,
5688 <ref id="strcmp" name="strcmp">,
5689 <ref id="stricmp" name="stricmp">,
5690 <ref id="strncmp" name="strncmp">,
5691 <ref id="strxfrm" name="strxfrm">
5697 <sect1>strcpy<label id="strcpy"><p>
5701 <tag/Function/Copy a string.
5702 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5703 <tag/Declaration/<tt/char* __fastcall__ strcpy (char* s1, const char* s2);/
5704 <tag/Description/The <tt/strcpy/ function copies the string pointed to by
5705 <tt/s2/ (including the terminating null byte) into the array pointed to by
5706 <tt/s1/. The function will always return <tt/s1/.
5707 <tag/Limits/<itemize>
5708 <item>The function is only available as fastcall function, so it may only
5709 be used in presence of a prototype.
5710 <item>If copying takes place between objects that overlap, the behaviour
5713 <tag/Availability/ISO 9899
5715 <ref id="strcat" name="strcat">,
5716 <ref id="strncat" name="strncat">,
5717 <ref id="strncpy" name="strncpy">
5720 #include <string.h>
5722 static char hello[14];
5724 strcpy (hello, "Hello world!\n");
5730 <sect1>strcspn<label id="strcspn"><p>
5734 <tag/Function/Compute the length of a substring.
5735 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5736 <tag/Declaration/<tt/size_t __fastcall__ strcspn (const char* s, const char* set);/
5737 <tag/Description/The <tt/strcspn/ function computes and returns the length of
5738 the substring pointed to by <tt/s/ which does <em>not</em> consist of
5739 characters contained in the string <tt/set/.
5740 <tag/Limits/<itemize>
5741 <item>The function is only available as fastcall function, so it may only
5742 be used in presence of a prototype.
5744 <tag/Availability/ISO 9899
5746 <ref id="strqtok" name="strqtok">,
5747 <ref id="strspn" name="strspn">,
5748 <ref id="strstr" name="strstr">,
5749 <ref id="strtok" name="strtok">
5755 <sect1>strdup<label id="strdup"><p>
5759 <tag/Function/Allocate a copy of a string on the heap.
5760 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5761 <tag/Declaration/<tt/char* __fastcall__ strdup (const char* s);/
5762 <tag/Description/<tt/strdup/ allocates a memory block on the heap, big enough
5763 to hold a copy of <tt/s/ including the terminating zero. If the allocation
5764 fails, <tt/NULL/ is returned, otherwise <tt/s/ is copied into the allocated
5765 memory block, and a pointer to the block is returned.
5766 <tag/Limits/<itemize>
5767 <item>The function is only available as fastcall function, so it may only
5768 be used in presence of a prototype.
5769 <item>It is up to the caller to free the allocated memory block.
5771 <tag/Availability/ISO 9899
5773 <ref id="free" name="free">,
5774 <ref id="malloc" name="malloc">
5780 <sect1>strerror<label id="strerror"><p>
5784 <tag/Function/Return a string describing an error code.
5785 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5786 <tag/Declaration/<tt/char* __fastcall__ strerror (int errcode);/
5787 <tag/Description/The <tt/strerror/ function returns a string describing the
5788 given error code. If an invalid error code is passed, the string "Unknown
5789 error" is returned, and <tt/errno/ is set to <tt/EINVAL/. In all other cases,
5790 <tt/errno/ is left untouched.
5791 <tag/Limits/<itemize>
5792 <item>The function is only available as fastcall function, so it may only
5793 be used in presence of a prototype.
5794 <item>While the return type of the function is a <tt/char*/, the returned
5795 string must not be modified by the caller!
5797 <tag/Availability/ISO 9899
5799 <ref id="_stroserror" name="_stroserror">
5805 <sect1>stricmp<label id="stricmp"><p>
5809 <tag/Function/Compare two strings case insensitive.
5810 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5811 <tag/Declaration/<tt/int __fastcall__ stricmp (const char* s1, const char* s2);/
5812 <tag/Description/The <tt/stricmp/ function compares the two strings passed as
5813 parameters without case sensitivity. It returns a value that is less than zero
5814 if <tt/s1/ is less than <tt/s2/, zero if <tt/s1/ is the same as <tt/s2/, and a
5815 value greater than zero if <tt/s1/ is greater than <tt/s2/.
5816 <tag/Limits/<itemize>
5817 <item>The function is only available as fastcall function, so it may only
5818 be used in presence of a prototype.
5819 <item>The function is not available in strict ANSI mode.
5821 <tag/Availability/cc65
5823 <ref id="strcasecmp" name="strcasecmp">,
5824 <ref id="strcmp" name="strcmp">,
5825 <ref id="strcoll" name="strcoll">,
5826 <ref id="strncmp" name="strncmp">,
5827 <ref id="strxfrm" name="strxfrm">
5833 <sect1>strlen<label id="strlen"><p>
5837 <tag/Function/Return the length of a string.
5838 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5839 <tag/Declaration/<tt/size_t __fastcall__ strlen (const char* s);/
5840 <tag/Description/The <tt/strlen/ function computes the number of bytes in the
5841 string to which s points, not including the terminating null byte.
5842 <tag/Limits/<itemize>
5843 <item>The function is only available as fastcall function, so it may only
5844 be used in presence of a prototype.
5845 <item>When compiling with <tt/-Os/ (inline known standard functions), the
5846 function does not work correctly for strings with more than 255 characters.
5848 <tag/Availability/ISO 9899
5850 <ref id="strcpy" name="strcpy">
5856 <sect1>strlower<label id="strlower"><p>
5860 <tag/Function/Make a string lower case.
5861 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5862 <tag/Declaration/<tt/char* __fastcall__ strlower (char* s);/
5863 <tag/Description/The <tt/strlower/ function will apply the <tt/tolower/
5864 function to each character of a string. The function will always return <tt/s/.
5865 <tag/Limits/<itemize>
5866 <item>The function is only available as fastcall function, so it may only
5867 be used in presence of a prototype.
5868 <item>The function prototype is unavailable when compiling in strict ANSI mode.
5869 <item>An alias name for this function is <tt/strlwr/.
5871 <tag/Availability/cc65
5873 <ref id="strupper" name="strupper">,
5874 <ref id="tolower" name="tolower">
5880 <sect1>strlwr<label id="strlwr"><p>
5887 <sect1>strncat<label id="strncat"><p>
5891 <tag/Function/Concatentate two strings.
5892 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5893 <tag/Declaration/<tt/char* __fastcall__ strncat (char* s1, const char* s2, size_t n);/
5894 <tag/Description/The <tt/strncat/ function appends not more than n characters
5895 of the string pointed to by s2 to the end of the string pointed to by s1. The
5896 terminating null character at the end of s1 is overwritten. A terminating null
5897 character is appended to the result, even if not all of s2 is appended to s1.
5898 <tag/Limits/<itemize>
5899 <item>The function is only available as fastcall function, so it may only
5900 be used in presence of a prototype.
5901 <item>If copying takes place between objects that overlap, the behaviour
5904 <tag/Availability/ISO 9899
5906 <ref id="strcpy" name="strcpy">,
5907 <ref id="strncat" name="strncat">,
5908 <ref id="strncpy" name="strncpy">
5914 <sect1>strncmp<label id="strncmp"><p>
5918 <tag/Function/Compare two strings.
5919 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5920 <tag/Declaration/<tt/int __fastcall__ strncmp (const char* s1, const char* s2, size_t count);/
5921 <tag/Description/The <tt/strncmp/ function compares not more than <tt/count/
5922 characters of the two strings passed as parameters. It returns a value that is
5923 less than zero if the first <tt/count/ characters of <tt/s1/ are less than
5924 <tt/s2/, zero if they are identical, and a value greater than zero they are
5926 <tag/Limits/<itemize>
5927 <item>The function is only available as fastcall function, so it may only
5928 be used in presence of a prototype.
5930 <tag/Availability/ISO 9899
5932 <ref id="strcasecmp" name="strcasecmp">,
5933 <ref id="strcmp" name="strcmp">,
5934 <ref id="strcoll" name="strcoll">,
5935 <ref id="stricmp" name="stricmp">,
5936 <ref id="strxfrm" name="strxfrm">
5942 <sect1>strncpy<label id="strncpy"><p>
5946 <tag/Function/Copy part of a string.
5947 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5948 <tag/Declaration/<tt/char* __fastcall__ strncpy (char* s1, const char* s2, size_t n);/
5949 <tag/Description/The <tt/strncpy/ function copies not more than <tt/n/ bytes from
5950 the array pointed to by <tt/s2/ to the array pointed to by <tt/s1/. If the array
5951 pointed to by <tt/s2/ is a string that is shorter than <tt/n/ bytes, null bytes are
5952 appended to the copy in the array pointed to by <tt/s1/, until <tt/n/ bytes are
5953 written. The function always will return <tt/s1/.
5954 <tag/Limits/<itemize>
5955 <item>The function is available only as a fastcall function; so, it may be used
5956 only in the presence of a prototype.
5957 <item>If there is no null byte in the first <tt/n/ bytes of the array pointed
5958 to by <tt/s2/, the result is <em/not/ null-terminated!
5959 <item>If copying takes place between objects that overlap, the behaviour is
5962 <tag/Availability/ISO 9899
5964 <ref id="memcpy" name="memcpy">,
5965 <ref id="strcat" name="strcat">,
5966 <ref id="strcpy" name="strcpy">,
5967 <ref id="strncat" name="strncat">
5972 static char hello[6];
5974 strncpy (hello, "Hello world!\n", sizeof hello - 1)[5] = '\0';
5980 <sect1>strqtok<label id="strqtok"><p>
5984 <tag/Function/Break a string into tokens.
5985 <tag/Header/<tt/<ref id="string.h" name="string.h">/
5986 <tag/Declaration/<tt/char* __fastcall__ strqtok (char* s1, const char* s2);/
5987 <tag/Description/<tt/strqtok()/ will break the string <tt/s1/ into a sequence of
5988 tokens, which are delimited by either quotation marks or characters from the
5989 string <tt/s2/. Tokens inside quotation marks may contain characters from <tt/s2/
5990 (they aren't delimiters there). The first call to <tt/strqtok()/ will return a
5991 pointer to the first token in the string <tt/s1/. The following calls must pass
5992 a <tt/NULL/ pointer as <tt/s1/, in order to get the next token in the string.
5993 Different sets of delimiters may be used for the subsequent calls to <tt/strqtok()/.
5994 <tag/Limits/<itemize>
5995 <item>The function is available only as a fastcall function; so, it may be used
5996 only in the presence of a prototype.
5997 <item><tt/strqtok()/ will modify the string <tt/s1/.
5998 <item>The function will forget where it is in the <tt/s1/ string if it is given
5999 a second <tt/s1/ string before it finishes the first one.
6001 <tag/Availability/cc65
6003 <ref id="strcspn" name="strcspn">,
6004 <!-- <ref id="strpbrk" name="strpbrk">, -->
6005 <ref id="strspn" name="strspn">,
6006 <ref id="strtok" name="strtok">
6012 <sect1>strrchr<label id="strrchr"><p>
6016 <tag/Function/Search for a character in a string.
6017 <tag/Header/<tt/<ref id="string.h" name="string.h">/
6018 <tag/Declaration/<tt/char* __fastcall__ strrchr (const char* s, int c);/
6019 <tag/Description/The <tt/strrchr/ function locates the last occurrence of <tt/c/
6020 (converted to a char) in the string pointed to by <tt/s/. The terminating null
6021 byte is considered to be part of the string. Upon completion, the function
6022 returns a pointer to the byte, or a null pointer if the byte was not found.
6023 <tag/Limits/<itemize>
6024 <item>The function is only available as fastcall function, so it may only
6025 be used in presence of a prototype.
6027 <tag/Availability/ISO 9899
6029 <ref id="strchr" name="strchr">
6035 <sect1>strspn<label id="strspn"><p>
6039 <tag/Function/Compute the length of a substring.
6040 <tag/Header/<tt/<ref id="string.h" name="string.h">/
6041 <tag/Declaration/<tt/size_t __fastcall__ strspn (const char* s, const char* set);/
6042 <tag/Description/The <tt/strspn/ function computes and returns the length of
6043 the substring pointed to by <tt/s/ which does consist only of characters
6044 contained in the string <tt/set/.
6045 <tag/Limits/<itemize>
6046 <item>The function is only available as fastcall function, so it may only
6047 be used in presence of a prototype.
6049 <tag/Availability/ISO 9899
6051 <ref id="strcspn" name="strcspn">,
6052 <ref id="strstr" name="strstr">
6058 <sect1>strstr<label id="strstr"><p>
6062 <tag/Function/Find a substring.
6063 <tag/Header/<tt/<ref id="string.h" name="string.h">/
6064 <tag/Declaration/<tt/char* __fastcall__ strstr (const char* str, const char* substr);/
6065 <tag/Description/<tt/strstr/ searches for the first occurance of the string
6066 <tt/substr/ within <tt/str/. If found, it returns a pointer to the copy,
6067 otherwise it returns <tt/NULL/.
6068 <tag/Limits/<itemize>
6069 <item>The function is only available as fastcall function, so it may only
6070 be used in presence of a prototype.
6072 <tag/Availability/ISO 9899
6074 <ref id="strcspn" name="strcspn">,
6075 <ref id="strspn" name="strspn">
6081 <sect1>strtok<label id="strtok"><p>
6085 <tag/Function/Break a string into tokens.
6086 <tag/Header/<tt/<ref id="string.h" name="string.h">/
6087 <tag/Declaration/<tt/char* __fastcall__ strtok (char* s1, const char* s2);/
6088 <tag/Description/<tt/strtok()/ will break the string <tt/s1/ into a sequence of
6089 tokens, which are delimited by characters from the string <tt/s2/. The first call
6090 to <tt/strtok()/ will return a pointer to the first token in the string <tt/s1/.
6091 The following calls must pass a <tt/NULL/ pointer as <tt/s1/, in order to get
6092 the next token in the string. Different sets of delimiters may be used for the
6093 subsequent calls to <tt/strtok()/.
6094 <tag/Limits/<itemize>
6095 <item>The function is only available as fastcall function, so it may only
6096 be used in presence of a prototype.
6097 <item><tt/strtok()/ will modify the string <tt/s1/.
6098 <item>The function will forget where it is in the <tt/s1/ string if it is given
6099 a second <tt/s1/ string before it finishes the first one.
6101 <tag/Availability/ISO 9899
6103 <ref id="strcspn" name="strcspn">,
6104 <!-- <ref id="strpbrk" name="strpbrk">, -->
6105 <ref id="strqtok" name="strqtok">,
6106 <ref id="strspn" name="strspn">
6112 <sect1>strxfrm<label id="strxfrm"><p>
6116 <tag/Function/Transform a string.
6117 <tag/Header/<tt/<ref id="string.h" name="string.h">/
6118 <tag/Declaration/<tt/size_t __fastcall__ strxfrm (char* s1, const char* s2, size_t n);/
6119 <tag/Description/The <tt/strxfrm/ function transforms the string pointed to by
6120 s2 and places the resulting string into the string pointed to by s1. The
6121 transformation is such that if the <tt/strcmp/ function is applied to two
6122 transformed strings, it returns a value greater than, equal to, or less than
6123 zero, corresponding to the result of the <tt/strcoll/ function applied to the
6124 same two original strings. No more than n characters are placed into the
6125 resulting array pointed to by s1, including the terminating null character.
6126 <tag/Limits/<itemize>
6127 <item><tt/s1/ and <tt/s2/ must not point to the same memory area, otherwise
6128 the behaviour is undefined.
6129 <item>If <tt/n/ is zero, <tt/s1/ may be a NULL pointer.
6130 <item>The function is only available as fastcall function, so it may only
6131 be used in presence of a prototype.
6132 <item>Since cc65 doesn't support different charcter sets, <tt/strxfrm/ will
6133 just copy s2 to s1 using <tt><ref id="strncpy" name="strncpy"></tt>.
6135 <tag/Availability/ISO 9899
6137 <ref id="strcmp" name="strcmp">,
6138 <ref id="strcoll" name="strcoll">,
6139 <ref id="strncpy" name="strncpy">
6145 <sect1>strupper<label id="strupper"><p>
6149 <tag/Function/Make a string upper case.
6150 <tag/Header/<tt/<ref id="string.h" name="string.h">/
6151 <tag/Declaration/<tt/char* __fastcall__ strupper (char* s);/
6152 <tag/Description/The <tt/strupper/ function will apply the <tt/toupper/
6153 function to each character of a string. The function will always return <tt/s/.
6154 <tag/Limits/<itemize>
6155 <item>The function is only available as fastcall function, so it may only
6156 be used in presence of a prototype.
6157 <item>The function prototype is unavailable when compiling in strict ANSI mode.
6158 <item>An alias name for this function is <tt/strupr/.
6160 <tag/Availability/cc65
6162 <ref id="strlower" name="strlower">
6163 <ref id="toupper" name="toupper">
6169 <sect1>strupr<label id="strupr"><p>
6176 <sect1>telldir<label id="telldir"><p>
6180 <tag/Function/Return the current position of a directory stream.
6181 <tag/Header/<tt/<ref id="dirent.h" name="dirent.h">/
6182 <tag/Declaration/<tt/long __fastcall__ telldir (DIR* dir);/
6183 <tag/Description/<tt/telldir/ returns the current position of a directory
6184 stream. The return value may be used in subsequent calls to
6185 <tt/<ref id="seekdir" name="seekdir">/.
6186 <tag/Limits/<itemize>
6187 <item>The function is only available as fastcall function, so it may only
6188 be used in presence of a prototype.
6190 <tag/Availability/POSIX 1003.1
6192 <ref id="seekdir" name="seekdir">,
6193 <ref id="telldir" name="telldir">
6199 <sect1>textcolor<label id="textcolor"><p>
6203 <tag/Function/Set the text color.
6204 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
6205 <tag/Declaration/<tt/unsigned char __fastcall__ textcolor (unsigned char color);/
6206 <tag/Description/The function will set a new text color. It returns the old
6207 (current) text color. Text output using any <tt/conio.h/ function will use
6208 the color set by this function.
6209 <tag/Limits/<itemize>
6210 <item>Text colors are system dependent. The function may have no effect
6211 on systems where the text color cannot be changed.
6212 <item>The function is only available as fastcall function, so it may only
6213 be used in presence of a prototype.
6215 <tag/Availability/cc65
6217 <ref id="bgcolor" name="bgcolor">,
6218 <ref id="bordercolor" name="bordercolor">
6224 <sect1>tgi_arc<label id="tgi_arc"><p>
6228 <tag/Function/Draw an elliptic arc in the current color.
6229 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6230 <tag/Declaration/<tt/void __fastcall__ tgi_arc (int x, int y,
6231 unsigned char rx, unsigned char ry, unsigned sa, unsigned ea);/
6232 <tag/Description/The function draws an elliptic arc with center at x/y and
6233 radii rx/ry using the current drawing color. The arc covers the angle
6234 between sa and ea (startangle and endangle), which must be in the range
6236 <tag/Limits/<itemize>
6237 <item>The function is only available as fastcall function, so it may only
6238 be used in presence of a prototype.
6239 <item>The function behaves unexpectedly or may crash if the angles are out
6242 <tag/Availability/cc65
6244 <ref id="tgi_bar" name="tgi_bar">,
6245 <ref id="tgi_circle" name="tgi_circle">,
6246 <ref id="tgi_ellipse" name="tgi_ellipse">,
6247 <ref id="tgi_pieslice" name="tgi_pieslice">,
6248 <ref id="tgi_setcolor" name="tgi_setcolor">
6250 /* Draw the upper half of an ellipse */
6251 tgi_setcolor(TGI_COLOR_BLUE);
6252 tgi_arc (50, 50, 40, 20, 0, 180);
6258 <sect1>tgi_bar<label id="tgi_bar"><p>
6262 <tag/Function/The function fills a rectangle on the drawpage with the current
6264 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6265 <tag/Declaration/<tt/void __fastcall__ tgi_bar (int x1, int y1, int x2, int y2);/
6266 <tag/Description/The function fills a rectangle on the drawpage with the current
6268 <tag/Limits/<itemize>
6269 <item>The function is only available as fastcall function, so it may only
6270 be used in presence of a prototype.
6272 <tag/Availability/cc65
6273 <tag/See also/Other tgi function
6275 tgi_setcolor(TGI_COLOR_GREEN);
6276 tgi_bar(10, 10, 100, 60);
6282 <sect1>tgi_circle<label id="tgi_circle"><p>
6286 <tag/Function/The function draws a circle in the current color.
6287 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6288 <tag/Declaration/<tt/void __fastcall__ tgi_circle (int x, int y, unsigned char radius);/
6289 <tag/Description/The function draws a circle in the current color.
6290 <tag/Limits/<itemize>
6291 <item>The function is only available as fastcall function, so it may only
6292 be used in presence of a prototype.
6294 <tag/Availability/cc65
6296 <ref id="tgi_arc" name="tgi_arc">,
6297 <ref id="tgi_bar" name="tgi_bar">,
6298 <ref id="tgi_ellipse" name="tgi_ellipse">,
6299 <ref id="tgi_pieslice" name="tgi_pieslice">,
6300 <ref id="tgi_setcolor" name="tgi_setcolor">
6302 tgi_setcolor(TGI_COLOR_BLACK);
6303 tgi_circle(50, 40, 40);
6309 <sect1>tgi_clear<label id="tgi_clear"><p>
6313 <tag/Function/Clear the drawpage
6314 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6315 <tag/Declaration/<tt/void tgi_clear (void);/
6316 <tag/Description/Clear the drawpage
6317 <tag/Availability/cc65
6318 <tag/See also/Other tgi functions
6324 <sect1>tgi_done<label id="tgi_done"><p>
6328 <tag/Function/End graphics mode, switch back to text mode.
6329 Will NOT uninstall or unload the driver!
6330 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6331 <tag/Declaration/<tt/void tgi_done (void);/
6332 <tag/Description/End graphics mode, switch back to text mode.
6333 Will NOT uninstall or unload the driver!
6334 <tag/Availability/cc65
6335 <tag/See also/Other tgi functions
6341 <sect1>tgi_ellipse<label id="tgi_ellipse"><p>
6345 <tag/Function/The function draws an ellipse in the current color.
6346 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6347 <tag/Declaration/<tt/void __fastcall__ tgi_ellipse (int x, int y, unsigned char rx, unsigned char ry);/
6348 <tag/Description/The function draws an ellipse at position x/y with radii
6349 rx and ry, using the current drawing color.
6350 <tag/Limits/<itemize>
6351 <item>The function is only available as fastcall function, so it may only
6352 be used in presence of a prototype.
6354 <tag/Availability/cc65
6356 <ref id="tgi_arc" name="tgi_arc">,
6357 <ref id="tgi_bar" name="tgi_bar">,
6358 <ref id="tgi_circle" name="tgi_circle">,
6359 <ref id="tgi_pieslice" name="tgi_pieslice">,
6360 <ref id="tgi_setcolor" name="tgi_setcolor">
6362 tgi_setcolor(TGI_COLOR_RED);
6363 tgi_ellipse (50, 40, 40, 20);
6369 <sect1>tgi_free_vectorfont<label id="tgi_free_vectorfont"><p>
6373 <tag/Function/Free a vector font that was previously loaded into memory.
6374 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6375 <tag/Declaration/<tt/void __fastcall__ tgi_free_vectorfont (const tgi_vectorfont* font);/
6376 <tag/Description/Free a vector font that was previously loaded into memory.
6377 <tag/Limits/<itemize>
6378 <item>The function is only available as fastcall function, so it may only
6379 be used in presence of a prototype.
6381 <tag/Availability/cc65
6383 <ref id="tgi_load_vectorfont" name="tgi_load_vectorfont">,
6384 <ref id="tgi_install_vectorfont" name="tgi_install_vectorfont">
6390 <sect1>tgi_getaspectratio<label id="tgi_getaspectratio"><p>
6392 <quote> <descrip> <tag/Function/Return the pixel aspect ratio.
6393 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6394 <tag/Declaration/<tt/unsigned tgi_getaspectratio (void);/
6395 <tag/Description/The function returns the pixel aspect ratio for the current
6396 driver and display as an 8.8 fixed point value. It may be used to correct
6397 geometric shapes so they look correct on the display. As an example, a circle
6398 with a radius of 100 pixels may look elliptic on some driver/display
6399 combinations if the aspect ratio is not 1.00.
6400 <tag/Limits/<itemize>
6401 <item>The aspect ratio is encoded in the TGI driver which assumes a "standard"
6402 monitor for the given platform. The aspect ratio may be wrong if another
6404 <item>No TGI function will use the aspect ratio. It is up to the programmer to
6406 <item>The <ref id="tgi_setaspectratio" name="tgi_setaspectratio"> function can
6407 be used to change the aspect ratio for a loaded driver. The value is not reset
6408 by <ref id="tgi_init" name="tgi_init">, so if a driver is linked statically to
6409 an application, switching into and out of graphics mode will not restore the
6410 original aspect ratio.
6412 <tag/Availability/cc65
6414 <ref id="tgi_setaspectratio" name="tgi_setaspectratio">
6420 <sect1>tgi_getcolor<label id="tgi_getcolor"><p>
6424 <tag/Function/Return the current drawing color.
6425 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6426 <tag/Declaration/<tt/unsigned char tgi_getcolor (void);/
6427 <tag/Description/The actual color is an index to a palette. During tgi_init
6428 you will get a default palette. The number of colors depend on the platform.
6429 All platforms recognize at least TGI_COLOR_BLACK and TGI_COLOR_WHITE. But some
6430 platforms have many more predefined colors. If you paint using TGI_COLOR_GREEN
6431 and then you change the green of the palette to blue using tgi_setpalette then
6432 after this painting in TGI_COLOR_GREEN will actually be blue.
6433 <tag/Availability/cc65
6434 <tag/See also/Other tgi functions
6436 color = tgi_getcolor();
6442 <sect1>tgi_getcolorcount<label id="tgi_getcolorcount"><p>
6446 <tag/Function/Get the number of available colors.
6447 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6448 <tag/Declaration/<tt/unsigned char tgi_getcolorcount (void);/
6449 <tag/Description/Tgi platforms use indexed color palettes. This function
6450 returns the number of entries we can use in the palette.
6451 <tag/Availability/cc65
6452 <tag/See also/Other tgi functions
6454 if (tgi_getcolorcount() == 2) {
6455 printf("Only monochrome graphics is supported\n");
6462 <sect1>tgi_getdefpalette<label id="tgi_getdefpalette"><p>
6466 <tag/Function/Get the palette installed by default.
6467 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6468 <tag/Declaration/<tt/const unsigned char* tgi_getdefpalette (void);/
6469 <tag/Description/The tgi driver has a default palette that is active at startup.
6470 The named colors TGI_COLOR_BLACK, TGI_COLOR_WHITE, TGI_COLOR_RED... need this
6471 palette to work correctly.
6472 <tag/Availability/cc65
6473 <tag/See also/Other tgi functions
6479 <sect1>tgi_geterror<label id="tgi_geterror"><p>
6483 <tag/Function/Return the error code for the last operation.
6484 This will also clear the error.
6485 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6486 <tag/Declaration/<tt/unsigned char tgi_geterror (void);/
6487 <tag/Description/Return the error code for the last operation.
6488 This will also clear the error.
6489 <tag/Availability/cc65
6490 <tag/See also/Other tgi functions
6496 <sect1>tgi_geterrormsg<label id="tgi_geterrormsg"><p>
6500 <tag/Function/Get an error message describing the error.
6501 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6502 <tag/Declaration/<tt/const char* __fastcall__ tgi_geterrormsg (unsigned char code);/
6503 <tag/Description/Get an error message describing the error.
6504 <tag/Limits/<itemize>
6505 <item>The function is only available as fastcall function, so it may only
6506 be used in presence of a prototype.
6508 <tag/Availability/cc65
6509 <tag/See also/Other tgi functions
6515 <sect1>tgi_getmaxcolor<label id="tgi_getmaxcolor"><p>
6519 <tag/Function/Get the highest index of the palette.
6520 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6521 <tag/Declaration/<tt/unsigned char tgi_getmaxcolor (void);/
6522 <tag/Description/Get the highest index of the palette.
6523 <tag/Availability/cc65
6524 <tag/See also/Other tgi functions
6530 <sect1>tgi_getmaxx<label id="tgi_getmaxx"><p>
6534 <tag/Function/Get the maximum x 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_getmaxx (void);/
6537 <tag/Description/Get the maximum x coordinate that can be used on this screen.
6538 <tag/Availability/cc65
6539 <tag/See also/Other tgi functions
6545 <sect1>tgi_getmaxy<label id="tgi_getmaxy"><p>
6549 <tag/Function/Get the maximum y coordinate that can be used on this screen.
6550 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6551 <tag/Declaration/<tt/unsigned tgi_getmaxy (void);/
6552 <tag/Description/Get the maximum y coordinate that can be used on this screen.
6553 <tag/Availability/cc65
6554 <tag/See also/Other tgi functions
6560 <sect1>tgi_getpagecount<label id="tgi_getpagecount"><p>
6564 <tag/Function/Return the number of screen pages available.
6565 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6566 <tag/Declaration/<tt/unsigned tgi_getpagecount (void);/
6567 <tag/Description/Return the number of screen pages available.
6568 <tag/Availability/cc65
6570 <ref id="tgi_setdrawpage" name="tgi_setdrawpage">,
6571 <ref id="tgi_setviewpage" name="tgi_setviewpage">
6577 <sect1>tgi_getpalette<label id="tgi_getpalette"><p>
6581 <tag/Function/Get the palette installed.
6582 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6583 <tag/Declaration/<tt/const unsigned char* tgi_getpalette (void);/
6584 <tag/Description/Get the palette installed.
6585 <tag/Availability/cc65
6586 <tag/See also/Other tgi functions
6592 <sect1>tgi_getpixel<label id="tgi_getpixel"><p>
6596 <tag/Function/Get the color of a pixel from the viewpage.
6597 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6598 <tag/Declaration/<tt/unsigned char __fastcall__ tgi_getpixel (int x, int y);/
6599 <tag/Description/Get the color of a pixel from the viewpage.
6600 <tag/Limits/<itemize>
6601 <item>The function is only available as fastcall function, so it may only
6602 be used in presence of a prototype.
6604 <tag/Availability/cc65
6605 <tag/See also/Other tgi functions.
6611 <sect1>tgi_getxres<label id="tgi_getxres"><p>
6615 <tag/Function/Get number of horisontal pixels on the screen.
6616 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6617 <tag/Declaration/<tt/unsigned tgi_getxres (void);/
6618 <tag/Description/Get number of horisontal pixels on the screen.
6619 This is same as tgi_maxx()+1.
6620 <tag/Availability/cc65
6621 <tag/See also/Other tgi functions.
6627 <sect1>tgi_getyres<label id="tgi_getyres"><p>
6631 <tag/Function/Get number of vertical pixels on the screen.
6632 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6633 <tag/Declaration/<tt/unsigned tgi_getyres (void);/
6634 <tag/Description/Get number of vertical pixels on the screen.
6635 This is same as tgi_maxy()+1.
6636 <tag/Availability/cc65
6637 <tag/See also/Other tgi functions.
6643 <sect1>tgi_gotoxy<label id="tgi_gotoxy"><p>
6647 <tag/Function/Set graphics cursor at x, y.
6648 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6649 <tag/Declaration/<tt/void __fastcall__ tgi_gotoxy (int x, int y);/
6650 <tag/Description/Set graphics cursor at x, y.
6651 <tag/Limits/<itemize>
6652 <item>The function is only available as fastcall function, so it may only
6653 be used in presence of a prototype.
6655 <tag/Availability/cc65
6656 <tag/See also/Other tgi functions.
6662 <sect1>tgi_init<label id="tgi_init"><p>
6666 <tag/Function/Initialize the already loaded graphics driver.
6667 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6668 <tag/Declaration/<tt/void tgi_init (void);/
6669 <tag/Description/The tgi_init function will set the default palette to the
6671 <tag/Limits/<itemize>
6672 <item><tt/tgi_init/ will not clear the screen. This allows switching between
6673 text and graphics mode on platforms that have separate memory areas for the
6674 screens. If you want the screen cleared, call <tt/<ref id="tgi_clear"
6675 name="tgi_clear">/ after <tt/tgi_init/.
6677 <tag/Availability/cc65
6678 <tag/See also/Other tgi functions.
6680 tgi_install(tgi_static_stddrv); //Include the driver statically instead of loading it.
6681 tgi_init(); //Set up the default palette and clear the screen.
6687 <sect1>tgi_install<label id="tgi_install"><p>
6691 <tag/Function/Install an already loaded driver and return an error code.
6692 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6693 <tag/Declaration/<tt/unsigned char __fastcall__ tgi_install (void* driver);/
6694 <tag/Description/The function installs a driver that was already loaded into
6695 memory (or linked statically to the program). It returns an error code
6696 (<tt/TGI_ERR_OK/ in case of success).
6697 <tag/Limits/<itemize>
6698 <item>The function is only available as fastcall function, so it may only be
6699 used in presence of a prototype.
6701 <tag/Availability/cc65
6703 <ref id="tgi_load_driver" name="tgi_load_driver">,
6704 <ref id="tgi_uninstall" name="tgi_uninstall">,
6705 <ref id="tgi_unload" name="tgi_unload">
6707 tgi_install(tgi_static_stddrv); //Include the driver statically instead of loading it.
6708 tgi_init(); //Set up the default palette and clear the screen.
6714 <sect1>tgi_install_vectorfont<label id="tgi_install_vectorfont"><p>
6718 <tag/Function/Install an already loaded driver and return an error code.
6719 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6720 <tag/Declaration/<tt/void __fastcall__ tgi_install_vectorfont (const tgi_vectorfont* font);/
6722 Install a vector font for use. More than one vector font can be loaded,
6723 but only one can be active. This function is used to tell which one. Call
6724 with a NULL pointer to uninstall the currently installed font.
6725 <tag/Limits/<itemize>
6726 <item>The function is only available as fastcall function, so it may only be
6727 used in presence of a prototype.
6729 <tag/Availability/cc65
6731 <ref id="tgi_load_vectorfont" name="tgi_load_vectorfont">,
6732 <ref id="tgi_free_vectorfont" name="tgi_free_vectorfont">
6738 <sect1>tgi_ioctl<label id="tgi_ioctl"><p>
6742 <tag/Function/Platform dependent code extensions.
6743 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6744 <tag/Declaration/<tt/unsigned __fastcall__ tgi_ioctl (unsigned char code, void* data);/
6745 <tag/Description/Some platforms have extra display hardware that is not
6746 supported by standard tgi functions. You can extend the driver to support
6747 this extra hardware using tgi_ioctl functions.
6748 <tag/Limits/<itemize>
6749 <item>The function is only available as fastcall function, so it may only
6750 be used in presence of a prototype.
6751 <item>These functions are not easily portable to other cc65 platforms.
6753 <tag/Availability/cc65
6754 <tag/See also/Other tgi functions.
6756 #define tgi_sprite(spr) tgi_ioctl(0, (void*)(spr))
6757 #define tgi_flip() tgi_ioctl(1, (void*)0)
6758 #define tgi_setbgcolor(bgcol) tgi_ioctl(2, (void*)(bgcol))
6759 #define tgi_setframerate(rate) tgi_ioctl(3, (void*)(rate))
6760 #define tgi_busy() tgi_ioctl(4, (void*)0)
6761 #define tgi_updatedisplay() tgi_ioctl(4, (void*)1)
6763 tgi_sprite(&background);
6764 tgi_setcolor(TGI_COLOR_BLUE);
6765 tgi_outttextxy(20,40,"Hello World");
6766 tgi_updatedisplay();
6773 <sect1>tgi_line<label id="tgi_line"><p>
6777 <tag/Function/Draw a line in the current drawing color.
6778 The graphics cursor will be set to x2/y2 by this call.
6779 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6780 <tag/Declaration/<tt/void __fastcall__ tgi_line (int x1, int y1, int x2, int y2);/
6781 <tag/Description/Draw a line in the current drawing color.
6782 The graphics cursor will be set to x2/y2 by this call.
6783 <tag/Limits/<itemize>
6784 <item>The function is only available as fastcall function, so it may only
6785 be used in presence of a prototype.
6787 <tag/Availability/cc65
6788 <tag/See also/Other tgi functions.
6794 <sect1>tgi_lineto<label id="tgi_lineto"><p>
6798 <tag/Function/Draw a line in the current drawing color from the graphics
6799 cursor to the new end point. The graphics cursor will be updated to x2/y2.
6800 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6801 <tag/Declaration/<tt/void __fastcall__ tgi_lineto (int x2, int y2);/
6802 <tag/Description/Draw a line in the current drawing color from the graphics
6803 cursor to the new end point. The graphics cursor will be updated to x2/y2.
6804 <tag/Limits/<itemize>
6805 <item>The function is only available as fastcall function, so it may only
6806 be used in presence of a prototype.
6808 <tag/Availability/cc65
6809 <tag/See also/Other tgi functions.
6815 <sect1>tgi_load_driver<label id="tgi_load_driver"><p>
6819 <tag/Function/Load and install the given driver.
6820 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6821 <tag/Declaration/<tt/void __fastcall__ tgi_load_driver (const char *name);/
6822 <tag/Description/Load and install the driver by name.
6823 Will just load the driver and check if loading was successful.
6824 Will not switch to graphics mode.
6825 <tag/Limits/<itemize>
6826 <item>The function is only available as fastcall function, so it may only
6827 be used in presence of a prototype.
6829 <tag/Availability/cc65
6830 <tag/See also/Other tgi functions.
6836 <sect1>tgi_load_vectorfont<label id="tgi_load_vectorfont"><p>
6840 <tag/Function/Load the given vector font.
6841 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6842 <tag/Declaration/<tt/const tgi_vectorfont* __fastcall__ tgi_load_vectorfont (const char* name);/
6844 Load a vector font into memory and return it. In case of errors, NULL is
6845 returned and an error is set, which can be retrieved using tgi_geterror.
6846 To use the font, it has to be installed using tgi_install_vectorfont.
6847 <tag/Limits/<itemize>
6848 <item>The function is only available as fastcall function, so it may only
6849 be used in presence of a prototype.
6851 <tag/Availability/cc65
6853 <ref id="tgi_install_vectorfont" name="tgi_install_vectorfont">,
6854 <ref id="tgi_free_vectorfont" name="tgi_free_vectorfont">
6860 <sect1>tgi_outtext<label id="tgi_outtext"><p>
6864 <tag/Function/Output text at the current graphics cursor position.
6865 The graphics cursor is moved to the end of the text.
6866 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6867 <tag/Declaration/<tt/void __fastcall__ tgi_outtext (const char* s);/
6868 <tag/Description/Output text at the current graphics cursor position.
6869 The graphics cursor is moved to the end of the text.
6870 <tag/Limits/<itemize>
6871 <item>The function is only available as fastcall function, so it may only
6872 be used in presence of a prototype.
6874 <tag/Availability/cc65
6875 <tag/See also/Other tgi functions.
6881 <sect1>tgi_outtextxy<label id="tgi_outtextxy"><p>
6885 <tag/Function/Output text at the given cursor position.
6886 The graphics cursor is moved to the end of the text.
6887 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6888 <tag/Declaration/<tt/void __fastcall__ tgi_outtextxy (int x, int y, const char* s);/
6889 <tag/Description/Output text at the given cursor position.
6890 The graphics cursor is moved to the end of the text.
6891 <tag/Limits/<itemize>
6892 <item>The function is only available as fastcall function, so it may only
6893 be used in presence of a prototype.
6895 <tag/Availability/cc65
6896 <tag/See also/Other tgi functions.
6902 <sect1>tgi_pieslice<label id="tgi_pieslice"><p>
6906 <tag/Function/Draw an elliptic pie slice in the current color.
6907 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6908 <tag/Declaration/<tt/void __fastcall__ tgi_pie slice (int x, int y,
6909 unsigned char rx, unsigned char ry, unsigned sa, unsigned ea);/
6910 <tag/Description/The function draws an elliptic pie slice with center at x/y
6911 and radii rx/ry using the current drawing color. The pie slice covers the angle
6912 between sa and ea (startangle and endangle), which must be in the range
6914 <tag/Limits/<itemize>
6915 <item>The function is only available as fastcall function, so it may only
6916 be used in presence of a prototype.
6917 <item>The function behaves unexpectedly or may crash if the angles are out
6920 <tag/Availability/cc65
6922 <ref id="tgi_bar" name="tgi_arc">,
6923 <ref id="tgi_bar" name="tgi_bar">,
6924 <ref id="tgi_circle" name="tgi_circle">,
6925 <ref id="tgi_ellipse" name="tgi_ellipse">,
6926 <ref id="tgi_setcolor" name="tgi_setcolor">
6928 /* Draw the closed upper half of an ellipse */
6929 tgi_setcolor(TGI_COLOR_BLUE);
6930 tgi_pieslice (50, 50, 40, 20, 0, 180);
6936 <sect1>tgi_setaspectratio<label id="tgi_setaspectratio"><p>
6938 <quote> <descrip> <tag/Function/Set the pixel aspect ratio.
6939 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6940 <tag/Declaration/<tt/void __fastcall__ tgi_setaspectratio (unsigned ratio);/
6941 <tag/Description/The function sets the pixel aspect ratio for the current
6942 driver and display. The argument is an 8.8 fixed point value. The aspect ratio
6943 may be used to correct geometric shapes so they look correct on a given
6944 display. As an example, a circle with a radius of 100 pixels may look elliptic
6945 on some driver/display combinations if the aspect ratio is not 1.00.
6946 <tag/Limits/<itemize>
6947 <item>The aspect ratio is encoded in the TGI driver which assumes a "standard"
6948 monitor for the given platform. The aspect ratio may be wrong if another
6950 <item>No TGI function will use the aspect ratio. It is up to the programmer to
6952 <item>The <tt/tgi_setaspectratio/ function can be used to change the aspect
6953 ratio for a loaded driver. The value is not reset by <ref id="tgi_init"
6954 name="tgi_init">, so if a driver is linked statically to an application,
6955 switching into and out of graphics mode will not restore the original aspect
6958 <tag/Availability/cc65
6960 <ref id="tgi_getaspectratio" name="tgi_getaspectratio">
6966 <sect1>tgi_setcolor<label id="tgi_setcolor"><p>
6970 <tag/Function/Set color to be used in future draw operations.
6971 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6972 <tag/Declaration/<tt/void __fastcall__ tgi_setcolor (unsigned char color);/
6973 <tag/Description/Set color to be used in future draw operations.
6974 <tag/Limits/<itemize>
6975 <item>The function is only available as fastcall function, so it may only
6976 be used in presence of a prototype.
6978 <tag/Availability/cc65
6979 <tag/See also/Other tgi functions.
6981 tgi_setcolor(TGI_COLOR_BLACK);
6983 tgi_setcolor(TGI_COLOR_WHITE);
6984 tgi_bar(10,10,20,20);
6989 <sect1>tgi_setdrawpage<label id="tgi_setdrawpage"><p>
6993 <tag/Function/Set the page for drawing.
6994 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
6995 <tag/Declaration/<tt/void __fastcall__ tgi_setdrawpage (unsigned char page);/
6996 <tag/Description/If the drawpage and the viewpage are the same then all drawing
6997 is seen immediately as it is drawn. For double buffered games you can set the
6998 drawpage to a different page than the viewpage. This lets you draw the next
6999 screen in the background and when the screen is ready you display it.
7000 <tag/Limits/<itemize>
7001 <item>The function is only available as fastcall function, so it may only
7002 be used in presence of a prototype.
7004 <tag/Availability/cc65
7005 <tag/See also/Other tgi functions.
7008 tgi_outtextxy(10, 10, "Hello World");
7009 tgi_setviewpage(1); // Show page 1
7011 tgi_outtextxy(10, 10, "Creating next frame");
7013 tgi_setviewpage(0); // Show page 0
7018 <sect1>tgi_setpalette<label id="tgi_setpalette"><p>
7022 <tag/Function/Set the palette (not available with all drivers/hardware).
7023 Palette is a pointer to as many entries as there are colors.
7024 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
7025 <tag/Declaration/<tt/void __fastcall__ tgi_setpalette (const unsigned char* palette);/
7026 <tag/Description/Set the palette (not available with all drivers/hardware).
7027 Palette is a pointer to as many entries as there are colors.
7028 <tag/Limits/<itemize>
7029 <item>The function is only available as fastcall function, so it may only
7030 be used in presence of a prototype.
7032 <tag/Availability/cc65
7033 <tag/See also/Other tgi functions.
7038 <sect1>tgi_setpixel<label id="tgi_setpixel"><p>
7042 <tag/Function/Plot a pixel on the drawpage with the current color.
7043 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
7044 <tag/Declaration/<tt/void __fastcall__ tgi_setpixel (int x, int y);/
7045 <tag/Description/Plot a pixel on the drawpage with the current color.
7046 <tag/Limits/<itemize>
7047 <item>The function is only available as fastcall function, so it may only
7048 be used in presence of a prototype.
7050 <tag/Availability/cc65
7051 <tag/See also/Other tgi functions.
7056 <sect1>tgi_setviewpage<label id="tgi_setviewpage"><p>
7060 <tag/Function/Set page to be visible on screen.
7061 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
7062 <tag/Declaration/<tt/void __fastcall__ tgi_setviewpage (unsigned char page);/
7063 <tag/Description/If the drawpage and the viewpage are the same then all drawing
7064 is seen immediately as it is drawn. For double buffered games you can set the
7065 drawpage to a different page than the viewpage. This lets you draw the next
7066 screen in the background and when the screen is ready you display it.
7067 <tag/Limits/<itemize>
7068 <item>The function is only available as fastcall function, so it may only
7069 be used in presence of a prototype.
7071 <tag/Availability/cc65
7072 <tag/See also/Other tgi functions.
7075 tgi_outtextxy(10, 10, "Hello World");
7076 tgi_setviewpage(1); // Show page 1
7078 tgi_outtextxy(10, 10, "Creating next frame");
7080 tgi_setviewpage(0); // Show page 0
7085 <sect1>tgi_gettextheight<label id="tgi_gettextheight"><p>
7089 <tag/Function/Calculate the height of the text in pixels according to
7090 the current text style.
7091 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
7092 <tag/Declaration/<tt/unsigned __fastcall__ tgi_gettextheight (const char* s);/
7093 <tag/Description/Calculate the height of the text in pixels according to
7094 the current text style.
7095 <tag/Limits/<itemize>
7096 <item>The function is only available as fastcall function, so it may only
7097 be used in presence of a prototype.
7099 <tag/Availability/cc65
7100 <tag/See also/Other tgi functions.
7105 <sect1>tgi_settextscale<label id="tgi_settextscale"><p>
7109 <tag/Function/Set the scaling for text output.
7110 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
7111 <tag/Declaration/<tt/void __fastcall__ tgi_settextscale (unsigned width, unsigned height);/
7113 Set the scaling for text output. The scaling factors for width and height
7114 are 8.8 fixed point values. This means that $100 = 1 $200 = 2 etc.
7115 <tag/Limits/<itemize>
7116 <item>The function is only available as fastcall function, so it may only
7117 be used in presence of a prototype.
7119 <tag/Availability/cc65
7121 <ref id="tgi_settextstyle" name="tgi_settextstyle">
7126 <sect1>tgi_settextstyle<label id="tgi_settextstyle"><p>
7130 <tag/Function/Set the style for text output.
7131 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
7132 <tag/Declaration/<tt/void __fastcall__ tgi_settextstyle (unsigned char magx, unsigned char magy, unsigned char dir, unsigned char font);/
7133 <tag/Description/Set the style for text output.
7134 <tag/Limits/<itemize>
7135 <item>The function is only available as fastcall function, so it may only
7136 be used in presence of a prototype.
7138 <tag/Availability/cc65
7140 <ref id="tgi_settextscale" name="tgi_settextscale">
7145 <sect1>tgi_gettextwidth<label id="tgi_gettextwidth"><p>
7149 <tag/Function/Calculate the width of the text in pixels according to the current text style.
7150 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
7151 <tag/Declaration/<tt/unsigned __fastcall__ tgi_gettextwidth (const char* s);/
7152 <tag/Description/Calculate the width of the text in pixels according to the current text style.
7153 <tag/Limits/<itemize>
7154 <item>The function is only available as fastcall function, so it may only
7155 be used in presence of a prototype.
7157 <tag/Availability/cc65
7158 <tag/See also/Other tgi functions.
7163 <sect1>tgi_uninstall<label id="tgi_uninstall"><p>
7167 <tag/Function/Uninstall the currently loaded driver but do not unload it.
7168 Will call tgi_done if necessary.
7169 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
7170 <tag/Declaration/<tt/void tgi_uninstall (void);/
7171 <tag/Description/Uninstall the currently loaded driver but do not unload it.
7172 Will call tgi_done if necessary.
7173 <tag/Availability/cc65
7174 <tag/See also/Other tgi functions.
7179 <sect1>tgi_unload<label id="tgi_unload"><p>
7183 <tag/Function/Uninstall, then unload the currently loaded driver.
7184 Will call tgi_done if necessary.
7185 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
7186 <tag/Declaration/<tt/void tgi_unload (void);/
7187 <tag/Description/Uninstall, then unload the currently loaded driver.
7188 Will call tgi_done if necessary.
7189 <tag/Availability/cc65
7190 <tag/See also/Other tgi functions.
7195 <sect1>time<label id="time"><p>
7199 <tag/Function/Get the time.
7200 <tag/Header/<tt/<ref id="time.h" name="time.h">/
7201 <tag/Declaration/<tt/time_t __fastcall__ time (time_t* t);/
7202 <tag/Description/The function returns the time since the 1970-01-01 00:00:00
7203 measured in seconds. If the pointer <tt/t/ is not <tt/NULL/, the function
7204 result will also be stored there. If no time is available, <tt/(time_t)-1/ is
7205 returned and <tt/errno/ is set to <tt/ENOSYS/.
7206 <tag/Limits/<itemize>
7207 <item>The function is only available as fastcall function, so it may
7208 only be used in presence of a prototype.
7209 <item>Many platforms supported by cc65 do not have a realtime clock, so the
7210 returned value may not be valid.
7212 <tag/Availability/ISO 9899
7214 <ref id="clock" name="clock">
7220 <sect1>toggle_videomode<label id="toggle_videomode"><p>
7224 <tag/Function/Toggle between 40 and 80 column mode.
7225 <tag/Header/<tt/<ref id="c128.h" name="c128.h">/
7226 <tag/Declaration/<tt/void toggle_videomode (void);/
7227 <tag/Description/Toggle between 40 and 80 column mode. The settings for the
7228 old mode (cursor position, color and so on) are saved and restored together
7230 <tag/Limits/<itemize>
7231 <item>The function is specific to the C128.
7232 <item>This function is deprecated. Please use <ref id="videomode"
7233 name="videomode"> instead!
7235 <tag/Availability/C128
7237 <ref id="fast" name="fast">,
7238 <ref id="slow" name="slow">,
7239 <ref id="videomode" name="videomode">
7245 <sect1>tolower<label id="tolower"><p>
7249 <tag/Function/Convert a character into its lower case representation.
7250 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
7251 <tag/Declaration/<tt/int __fastcall__ tolower (int c);/
7252 <tag/Description/The function returns the given character converted to lower
7253 case. If the given character is not a letter, it is returned unchanged.
7254 <tag/Limits/<itemize>
7255 <item>The function is only available as fastcall function, so it may
7256 only be used in presence of a prototype.
7258 <tag/Availability/ISO 9899
7260 <ref id="islower" name="islower">,
7261 <ref id="isupper" name="isupper">,
7262 <ref id="toupper" name="toupper">
7268 <sect1>toupper<label id="toupper"><p>
7272 <tag/Function/Convert a character into its upper case representation.
7273 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
7274 <tag/Declaration/<tt/int __fastcall__ toupper (int c);/
7275 <tag/Description/The function returns the given character converted to upper
7276 case. If the given character is not a letter, it is returned unchanged.
7277 <tag/Limits/<itemize>
7278 <item>The function is only available as fastcall function, so it may
7279 only be used in presence of a prototype.
7281 <tag/Availability/ISO 9899
7283 <ref id="islower" name="islower">,
7284 <ref id="isupper" name="isupper">,
7285 <ref id="tolower" name="tolower">
7291 <sect1>ultoa<label id="ultoa"><p>
7295 <tag/Function/Convert an unsigned long integer into a string.
7296 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
7297 <tag/Declaration/<tt/char* __fastcall__ ultoa (unsigned long val, char* buf, int radix);/
7298 <tag/Description/<tt/itoa/ converts the unsigned long integer <tt/val/ into a
7299 string using <tt/radix/ as the base.
7300 <tag/Limits/<itemize>
7301 <item>There are no provisions to prevent a buffer overflow.
7302 <item>The function is non standard, so it is not available in strict ANSI mode.
7303 You should probably use <tt/sprintf/ instead.
7304 <item>The function is only available as fastcall function, so it may only be
7305 used in presence of a prototype.
7307 <tag/Availability/cc65
7309 <ref id="atoi" name="atoi">,
7310 <ref id="atol" name="atol">,
7311 <ref id="itoa" name="itoa">,
7312 <ref id="ltoa" name="ltoa">,
7313 <ref id="utoa" name="utoa">
7319 <sect1>unlink<label id="unlink"><p>
7323 <tag/Function/Delete a file.
7324 <tag/Header/<tt/<ref id="unistd.h" name="unistd.h">/
7325 <tag/Declaration/<tt/int __fastcall__ unlink (const char* name);/
7326 <tag/Description/<tt/unlink/ deletes the file with the given name. On success,
7327 zero is returned. On error, -1 is returned and <tt/errno/ is set to an error
7328 code describing the reason for the failure.
7331 <item>The use of this function is discouraged. Please use <tt/<ref id="remove"
7332 name="remove">/ instead, which is a native ANSI C function and does the same.
7333 <item>This function is not available on all cc65 targets (depends on the
7334 availability of file I/O).
7335 <item>The function is only available as fastcall function, so it may only
7336 be used in presence of a prototype.
7337 <item>Instead of <tt/unlink/, <tt/<ref id="remove" name="remove">/ should be
7338 used, which has the same semantics, but is more portable, because it conforms
7339 to the ISO C standard.
7341 <tag/Availability/POSIX 1003.1
7343 <ref id="remove" name="remove">
7346 #include <stdio.h>
7347 #include <unistd.h>
7349 #define FILENAME "helloworld"
7351 if (unlink (FILENAME) == 0) {
7352 printf ("We deleted %s successfully\n", FILENAME);
7354 printf ("There was a problem deleting %s\n", FILENAME);
7361 <sect1>utoa<label id="utoa"><p>
7365 <tag/Function/Convert an unsigned integer into a string.
7366 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
7367 <tag/Declaration/<tt/char* __fastcall__ utoa (unsigned val, char* buf, int radix);/
7368 <tag/Description/<tt/itoa/ converts the unsigned integer <tt/val/ into a string
7369 using <tt/radix/ as the base.
7370 <tag/Limits/<itemize>
7371 <item>There are no provisions to prevent a buffer overflow.
7372 <item>The function is non standard, so it is not available in strict ANSI mode.
7373 You should probably use <tt/sprintf/ instead.
7374 <item>The function is only available as fastcall function, so it may only be
7375 used in presence of a prototype.
7377 <tag/Availability/cc65
7379 <ref id="atoi" name="atoi">,
7380 <ref id="atol" name="atol">,
7381 <ref id="itoa" name="itoa">,
7382 <ref id="ltoa" name="ltoa">,
7383 <ref id="ultoa" name="ultoa">
7389 <sect1>vcprintf<label id="vcprintf"><p>
7393 <tag/Function/Formatted output to the console.
7394 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
7395 <tag/Declaration/<tt/int __fastcall__ vcprintf (const char* format, va_list ap);/
7396 <tag/Description/The arguments specified as a <tt/va_list/ are converted to
7397 text where necessary and formatted according to the format string given. The
7398 resulting string is output to the console. <tt/vcprintf/ supports the same
7399 format specifiers as <tt/vprintf/. <!-- <tt/<ref id="vprintf" name="vprintf">/. -->
7400 <tag/Limits/<itemize>
7401 <item>Like all other <tt/conio/ output functions, <tt/vcprintf/ distinguishes
7402 between <tt/\r/ and <tt/\n/.
7403 <item>The function is only available as fastcall function, so it may only be
7404 used in presence of a prototype.
7406 <tag/Availability/cc65
7408 <ref id="cprintf" name="cprintf">,
7409 <ref id="cputc" name="cputc">,
7410 <ref id="cputcxy" name="cputcxy">,
7411 <ref id="cputs" name="cputs">,
7412 <ref id="cputsxy" name="cputsxy">
7418 <sect1>videomode<label id="videomode"><p>
7422 <tag/Function/Switch to either 40 or 80 column mode.
7423 <tag/Header/<tt/<ref id="apple2enh.h" name="apple2enh.h">,
7424 <ref id="c128.h" name="c128.h">/
7425 <tag/Declaration/<tt/unsigned __fastcall__ videomode (unsigned Mode);/
7426 <tag/Description/Switch to 40 or 80 column mode depending on the argument. If
7427 the requested mode is already active, nothing happens. The old mode is returned
7429 <tag/Limits/<itemize>
7430 <item>The function is specific to the C128 and enhanced Apple //e.
7431 <item>This function replaces <ref id="toggle_videomode"
7432 name="toggle_videomode">.
7433 <item>The function is only available as fastcall function, so it may only be
7434 used in presence of a prototype.
7436 <tag/Availability/C128 and enhanced Apple //e
7438 <ref id="fast" name="fast">,
7439 <ref id="slow" name="slow">,
7440 <ref id="toggle_videomode" name="toggle_videomode">
7446 <sect1>wherex<label id="wherex"><p>
7450 <tag/Function/Return the current X position of the text mode cursor.
7451 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
7452 <tag/Declaration/<tt/unsigned char wherex (void);/
7453 <tag/Description/The function returns the current X position of the text mode
7454 cursor. Zero is returned for the leftmost screen position.
7455 <tag/Availability/cc65
7457 <ref id="gotox" name="gotox">,
7458 <ref id="gotoy" name="gotoy">,
7459 <ref id="gotoxy" name="gotoxy">,
7460 <ref id="wherey" name="wherey">
7466 <sect1>wherey<label id="wherey"><p>
7470 <tag/Function/Return the current Y position of the text mode cursor.
7471 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
7472 <tag/Declaration/<tt/unsigned char wherey (void);/
7473 <tag/Description/The function returns the current Y position of the text mode
7474 cursor. Zero is returned for the uppermost screen position.
7475 <tag/Availability/cc65
7477 <ref id="gotox" name="gotox">,
7478 <ref id="gotoy" name="gotoy">,
7479 <ref id="gotoxy" name="gotoxy">,
7480 <ref id="wherex" name="wherex">