1 <!doctype linuxdoc system>
4 <title>cc65 function reference
5 <author>Ullrich von Bassewitz, <htmlurl url="mailto:uz@cc65.org" name="uz@cc65.org">
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 <htmlurl
27 url="library.html" name="cc65 Library Overview">.
29 <bf/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="set_brk" name="set_brk">
65 <sect1><tt/apple2.h/<label id="apple2.h"><p>
68 <sect1><tt/atari.h/<label id="atari.h"><p>
71 <sect1><tt/atmos.h/<label id="atmos.h"><p>
74 <sect1><tt/assert.h/<label id="assert.h"><p>
77 <item><ref id="assert" name="assert">
81 <sect1><tt/c128.h/<label id="c128.h"><p>
84 <item><ref id="c64mode" name="c64mode">
85 <item><ref id="fast" name="fast">
86 <item><ref id="toggle_videomode" name="toggle_videomode">
87 <item><ref id="slow" name="slow">
91 <sect1><tt/c16.h/<label id="c16.h"><p>
94 <sect1><tt/c64.h/<label id="c64.h"><p>
97 <sect1><tt/conio.h/<label id="conio.h"><p>
100 <item><ref id="bgcolor" name="bgcolor">
101 <item><ref id="bordercolor" name="bordercolor">
102 <item><ref id="cclear" name="cclear">
103 <item><ref id="cclearxy" name="cclearxy">
104 <item><ref id="cgetc" name="cgetc">
105 <item><ref id="chline" name="chline">
106 <item><ref id="chlinexy" name="chlinexy">
107 <item><ref id="clrscr" name="clrscr">
108 <item><ref id="cprintf" name="cprintf">
109 <item><ref id="cputc" name="cputc">
110 <item><ref id="cputcxy" name="cputcxy">
111 <item><ref id="cputs" name="cputs">
112 <item><ref id="cputsxy" name="cputsxy">
113 <item><ref id="cursor" name="cursor">
114 <item><ref id="cvline" name="cvline">
115 <item><ref id="cvlinexy" name="cvlinexy">
116 <item><ref id="gotox" name="gotox">
117 <item><ref id="gotoxy" name="gotoxy">
118 <item><ref id="gotoy" name="gotoy">
119 <item><ref id="kbhit" name="kbhit">
120 <item><ref id="revers" name="revers">
121 <item><ref id="screensize" name="screensize">
122 <item><ref id="textcolor" name="textcolor">
123 <item><ref id="vcprintf" name="vcprintf">
124 <item><ref id="wherex" name="wherex">
125 <item><ref id="wherey" name="wherey">
129 <sect1><tt/ctype.h/<label id="ctype.h"><p>
132 <item><ref id="isalnum" name="isalnum">
133 <item><ref id="isalpha" name="isalpha">
134 <item><ref id="isascii" name="isascii">
135 <item><ref id="isblank" name="isblank">
136 <item><ref id="iscntrl" name="iscntrl">
137 <item><ref id="isdigit" name="isdigit">
138 <item><ref id="isgraph" name="isgraph">
139 <item><ref id="islower" name="islower">
140 <item><ref id="isprint" name="isprint">
141 <item><ref id="ispunct" name="ispunct">
142 <item><ref id="isspace" name="isspace">
143 <item><ref id="isupper" name="isupper">
144 <item><ref id="isxdigit" name="isxdigit">
145 <item><ref id="tolower" name="tolower">
146 <item><ref id="toupper" name="toupper">
150 <sect1><tt/dbg.h/<label id="dbg.h"><p>
153 <sect1><tt/dio.h/<label id="dio.h"><p>
156 <sect1><tt/em.h/<label id="em.h"><p>
159 <item><ref id="em_commit" name="em_commit">
160 <item><ref id="em_copyfrom" name="em_copyfrom">
161 <item><ref id="em_copyto" name="em_copyto">
162 <item><ref id="em_load_driver" name="em_load_driver">
163 <item><ref id="em_map" name="em_map">
164 <item><ref id="em_pagecount" name="em_pagecount">
165 <item><ref id="em_unload" name="em_unload">
166 <item><ref id="em_use" name="em_use">
170 <sect1><tt/errno.h/<label id="errno.h"><p>
173 <sect1><tt/fcntl.h/<label id="fcntl.h"><p>
176 <item><ref id="close" name="close">
177 <item><ref id="creat" name="creat">
178 <item><ref id="open" name="open">
182 <sect1><tt/geos.h/<label id="geos.h"><p>
185 <sect1><tt/joystick.h/<label id="joystick.h"><p>
188 <sect1><tt/locale.h/<label id="locale.h"><p>
191 <item><ref id="localeconv" name="localeconv">
192 <item><ref id="setlocale" name="setlocale">
196 <sect1><tt/modload.h/<label id="modload.h"><p>
199 <sect1><tt/nes.h/<label id="nes.h"><p>
202 <sect1><tt/o65.h/<label id="o65.h"><p>
205 <sect1><tt/peekpoke.h/<label id="peekpoke.h"><p>
208 <item><ref id="PEEK" name="PEEK">
209 <item><ref id="PEEKW" name="PEEKW">
210 <item><ref id="POKE" name="POKE">
211 <item><ref id="POKEW" name="POKEW">
215 <sect1><tt/pet.h/<label id="pet.h"><p>
218 <sect1><tt/plus4.h/<label id="plus4.h"><p>
221 <sect1><tt/serial.h/<label id="serial.h"><p>
224 <sect1><tt/setjmp.h/<label id="setjmp.h"><p>
227 <sect1><tt/signal.h/<label id="signal.h"><p>
230 <item><ref id="raise" name="raise">
231 <item><ref id="signal" name="signal">
235 <sect1><tt/stdarg.h/<label id="stdarg.h"><p>
238 <sect1><tt/stdbool.h/<label id="stdbool.h"><p>
241 <sect1><tt/stddef.h/<label id="stddef.h"><p>
244 <item><ref id="offsetof" name="offsetof">
248 <sect1><tt/stdio.h/<label id="stdio.h"><p>
251 <sect1><tt/stdlib.h/<label id="stdlib.h"><p>
254 <item><ref id="_heapadd" name="_heapadd">
255 <item><ref id="_heapmaxavail" name="_heapmaxavail">
256 <item><ref id="_heapmemavail" name="_heapmemavail">
257 <item><ref id="_poserror" name="_poserror">
258 <item><ref id="_randomize" name="_randomize">
259 <item><ref id="_swap" name="_swap">
260 <item><ref id="abort" name="abort">
261 <item><ref id="abs" name="abs">
262 <item><ref id="atexit" name="atexit">
263 <item><ref id="atoi" name="atoi">
264 <item><ref id="atol" name="atol">
265 <item><ref id="bsearch" name="bsearch">
266 <item><ref id="calloc" name="calloc">
267 <!-- <item><ref id="clearerr" name="clearerr"> -->
268 <item><ref id="div" name="div">
269 <item><ref id="exit" name="exit">
270 <!-- <item><ref id="fclose" name="fclose"> -->
271 <!-- <item><ref id="fdopen" name="fdopen"> -->
272 <!-- <item><ref id="feof" name="feof"> -->
273 <!-- <item><ref id="ferror" name="ferror"> -->
274 <!-- <item><ref id="fflush" name="fflush"> -->
275 <!-- <item><ref id="fgetc" name="fgetc"> -->
276 <!-- <item><ref id="fgetpos" name="fgetpos"> -->
277 <!-- <item><ref id="fgets" name="fgets"> -->
278 <!-- <item><ref id="fileno" name="fileno"> -->
279 <!-- <item><ref id="flushall" name="flushall"> -->
280 <!-- <item><ref id="fopen" name="fopen"> -->
281 <!-- <item><ref id="fprintf" name="fprintf"> -->
282 <!-- <item><ref id="fputc" name="fputc"> -->
283 <!-- <item><ref id="fputs" name="fputs"> -->
284 <!-- <item><ref id="fread" name="fread"> -->
285 <item><ref id="free" name="free">
286 <!-- <item><ref id="freopen" name="freopen"> -->
287 <!-- <item><ref id="fscanf" name="fscanf"> -->
288 <!-- <item><ref id="fseek" name="fseek"> -->
289 <!-- <item><ref id="fsetpos" name="fsetpos"> -->
290 <!-- <item><ref id="ftell" name="ftell"> -->
291 <!-- <item><ref id="fwrite" name="fwrite"> -->
292 <!-- <item><ref id="getc" name="getc"> -->
293 <!-- <item><ref id="getchar" name="getchar"> -->
294 <!-- <item><ref id="gets" name="gets"> -->
295 <item><ref id="getenv" name="getenv">
296 <item><ref id="itoa" name="itoa">
297 <item><ref id="labs" name="labs">
298 <item><ref id="ltoa" name="ltoa">
299 <item><ref id="malloc" name="malloc">
300 <item><ref id="perror" name="perror">
301 <!-- <item><ref id="printf" name="printf"> -->
302 <!-- <item><ref id="putc" name="putc"> -->
303 <!-- <item><ref id="putchar" name="putchar"> -->
304 <!-- <item><ref id="puts" name="puts"> -->
305 <item><ref id="qsort" name="qsort">
306 <item><ref id="rand" name="rand">
307 <item><ref id="realloc" name="realloc">
308 <item><ref id="remove" name="remove">
309 <!-- <item><ref id="rename" name="rename"> -->
310 <!-- <item><ref id="rewind" name="rewind"> -->
311 <!-- <item><ref id="scanf" name="scanf"> -->
312 <!-- <item><ref id="sprintf" name="sprintf"> -->
313 <item><ref id="srand" name="srand">
314 <!-- <item><ref id="sscanf" name="sscanf"> -->
315 <item><ref id="ultoa" name="ultoa">
316 <item><ref id="utoa" name="utoa">
317 <!-- <item><ref id="vfprintf" name="vfprintf"> -->
318 <!-- <item><ref id="vfscanf" name="vfscanf"> -->
319 <!-- <item><ref id="vprintf" name="vprintf"> -->
320 <!-- <item><ref id="vscanf" name="vscanf"> -->
321 <!-- <item><ref id="vsprintf" name="vsprintf"> -->
322 <!-- <item><ref id="vsscanf" name="vsscanf"> -->
326 <sect1><tt/string.h/<label id="string.h"><p>
329 <item><ref id="_stroserror" name="_stroserror">
330 <item><ref id="bzero" name="bzero">
331 <item><ref id="memchr" name="memchr">
332 <item><ref id="memcpy" name="memcpy">
333 <item><ref id="memmove" name="memmove">
334 <item><ref id="memset" name="memset">
335 <item><ref id="strcasecmp" name="strcasecmp">
336 <item><ref id="strcat" name="strcat">
337 <item><ref id="strchr" name="strchr">
338 <item><ref id="strcmp" name="strcmp">
339 <item><ref id="strcoll" name="strcoll">
340 <item><ref id="strcpy" name="strcpy">
341 <item><ref id="strcspn" name="strcspn">
342 <item><ref id="strdup" name="strdup">
343 <item><ref id="strerror" name="strerror">
344 <item><ref id="stricmp" name="stricmp">
345 <item><ref id="strlen" name="strlen">
346 <item><ref id="strlower" name="strlower">
347 <item><ref id="strlwr" name="strlwr">
348 <!-- <item><ref id="strncat" name="strncat"> -->
349 <!-- <item><ref id="strncmp" name="strncmp"> -->
350 <item><ref id="strncpy" name="strncpy">
351 <item><ref id="strrchr" name="strrchr">
352 <item><ref id="strspn" name="strspn">
353 <item><ref id="strstr" name="strstr">
354 <!-- <item><ref id="strtok" name="strtok"> -->
355 <!-- <item><ref id="strxfrm" name="strxfrm"> -->
356 <item><ref id="strupper" name="strupper">
357 <item><ref id="strupr" name="strupr">
361 <sect1><tt/tgi.h/<label id="tgi.h"><p>
364 <sect1><tt/time.h/<label id="time.h"><p>
368 <item><ref id="_systime" name="_systime">
369 <item><ref id="asctime" name="asctime">
370 <item><ref id="clock" name="clock">
371 <item><ref id="ctime" name="ctime">
372 <item><ref id="gmtime" name="gmtime">
373 <item><ref id="localtime" name="localtime">
374 <item><ref id="mktime" name="mktime">
375 <item><ref id="strftime" name="strftime">
376 <item><ref id="time" name="time">
381 <sect1><tt/unistd.h/<label id="unistd.h"><p>
384 <!-- <item><ref id="chdir" name="chdir"> -->
385 <!-- <item><ref id="getcwd" name="getcwd"> -->
386 <!-- <item><ref id="lseek" name="lseek"> -->
387 <!-- <item><ref id="mkdir" name="mkdir"> -->
388 <!-- <item><ref id="read" name="read"> -->
389 <!-- <item><ref id="rmdir" name="rmdir"> -->
390 <item><ref id="sleep" name="sleep">
391 <item><ref id="unlink" name="unlink">
392 <!-- <item><ref id="write" name="write"> -->
396 <sect1><tt/vic20.h/<label id="vic20.h"><p>
399 <sect1><tt/zlib.h/<label id="zlib.h"><p>
404 <sect>Alphabetical function reference<p>
406 <sect1>_heapadd<label id="_heapadd"><p>
410 <tag/Function/Add a block to the heap.
411 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
412 <tag/Declaration/<tt/void __fastcall__ _heapadd (void* mem, size_t size);/
413 <tag/Description/The function adds a block of raw memory to the heap.
416 <item>The minimum blocksize that can be added is 6 bytes; the function will
417 ignore blocks with smaller sizes.
419 <tag/Availability/cc65
421 <ref id="_heapmaxavail" name="_heapmaxavail">,
422 <ref id="_heapmemavail" name="_heapmemavail">,
423 <ref id="calloc" name="calloc">,
424 <ref id="free" name="free">,
425 <ref id="malloc" name="malloc">,
426 <ref id="realloc" name="realloc">
432 <sect1>_heapmaxavail<label id="_heapmaxavail"><p>
436 <tag/Function/Return the largest block that is available on the heap.
437 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
438 <tag/Declaration/<tt/size_t __fastcall__ _heapmaxavail (void);/
439 <tag/Description/The function returns the size of the largest block that may
440 be allocated from the heap using <tt/<ref id="malloc" name="malloc">/.
441 <tag/Availability/cc65
443 <ref id="_heapadd" name="_heapadd">,
444 <ref id="_heapmemavail" name="_heapmemavail">,
445 <ref id="calloc" name="calloc">,
446 <ref id="free" name="free">,
447 <ref id="malloc" name="malloc">,
448 <ref id="realloc" name="realloc">
454 <sect1>_heapmemavail<label id="_heapmemavail"><p>
458 <tag/Function/Return the total available space on the heap.
459 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
460 <tag/Declaration/<tt/size_t __fastcall__ _heapmemavail (void);/
461 <tag/Description/The function returns the total number of bytes available on
465 <item>This function is of less use than usually assumed, since the returned
466 heap space may be available but not in one block. So even if this function
467 says that several times more heap space is available than needed, <ref
468 id="malloc" name="malloc"> may still return <tt/NULL/.
470 <tag/Availability/cc65
472 <ref id="_heapadd" name="_heapadd">,
473 <ref id="_heapmaxavail" name="_heapmaxavail">,
474 <ref id="calloc" name="calloc">,
475 <ref id="free" name="free">,
476 <ref id="malloc" name="malloc">,
477 <ref id="realloc" name="realloc">
483 <sect1>_poserror<label id="_poserror"><p>
487 <tag/Function/Print an error message for the error in <tt/_oserrno/.
488 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
489 <tag/Declaration/<tt/void __fastcall__ _poserror (const char* msg);/
490 <tag/Description/<tt/_poserror/ prints an error message to <tt/stderr/. If
491 <tt/msg/ is not <tt/NULL/ and not an empty string, it is printed followed by
492 a colon and a blank. Then the error message for the current contents of
493 <tt/_oserrno/ are printed followed by a newline. The message output is the
494 same as returned by <tt/<ref id="_stroserror" name="_stroserror">/ with an
495 argument of <tt/_oserrno/.
498 <item>Since operating system specific error code are - you guessed it -
499 operating system specific, the value in <tt/_oserror/ and the message that is
500 printed depend on the cc65 target.
501 <item>The function is only available as fastcall function, so it may only
502 be used in presence of a prototype.
504 <tag/Availability/cc65
506 <ref id="_stroserror" name="_stroserror">,
507 <ref id="perror" name="perror">
513 <sect1>_randomize<label id="_randomize"><p>
517 <tag/Function/Initialize the pseudo random number generator.
518 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
519 <tag/Declaration/<tt/void _randomize (void);/
520 <tag/Description/The function initializes the random number generator with
521 a seed derived from fast changing hardware events, so the seed itself can be
522 considered random to a certain degree.
523 <tag/Limits/<itemize>
524 <item>The randomness of the seed depends on the machine hardware.
526 <tag/Availability/cc65
528 <ref id="rand" name="rand">,
529 <ref id="srand" name="srand">
535 <sect1>_stroserror<label id="_stroserror"><p>
539 <tag/Function/Return a string describing an OS specific error code.
540 <tag/Header/<tt/<ref id="string.h" name="string.h">/
541 <tag/Declaration/<tt/const char* __fastcall__ _stroserror (unsigned char errcode);/
542 <tag/Description/<tt/_stroserror/ will return a string describing the given
543 operating system specific error code.
544 <tag/Limits/<itemize>
545 <item>Since operating system specific error code are - you guessed it -
546 operating system specific, the parameter and the string returned depend on the
548 <item>The function is only available as fastcall function, so it may only be
549 used in presence of a prototype.
551 <tag/Availability/cc65
553 <ref id="strerror" name="strerror">
559 <sect1>_swap<label id="_swap"><p>
563 <tag/Function/Swap the contents of memory areas.
564 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
565 <tag/Declaration/<tt/void __fastcall__ _swap (void* p, void* q, size_t size);/
566 <tag/Description/<tt/_swap/ will swap (exchange) the contents of the two memory
567 areas pointed to by <tt/p/ and <tt/q/. Both memory areas are assumed to be
568 <tt/size/ bytes in size.
569 <tag/Limits/<itemize>
570 <item>The memory areas may not overlap, otherwise the results are undefined.
571 <item>The function is only available as fastcall function, so it may only be
572 used in presence of a prototype.
574 <tag/Availability/cc65
576 <ref id="memcpy" name="memcpy">,
577 <ref id="memmove" name="memmove">
583 <sect1>_sys<label id="_sys"><p>
587 <tag/Function/Call a subroutine passing register values.
588 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
589 <tag/Declaration/<tt/void __fastcall__ _sys (struct regs* r);/
590 <tag/Description/The function will call the subroutine at the address
591 specified in the <tt/pc/ member of the passed <tt/regs/ structure. All
592 registers and the CPU flags are set to the values given in the <tt/regs/
593 structure. On return from the subroutine, the new values of the registers and
594 flags are stored back overwriting the old values.
595 <tag/Limits/<itemize>
596 <item>Bits 4 and 5 of the flags value in the <tt/regs/ structure are ignored
597 when calling the subroutine (they are unchanged from their current values).
598 <item>The function is only available as fastcall function, so it may only be
599 used in presence of a prototype.
601 <tag/Availability/cc65
607 <sect1>BRK<label id="BRK"><p>
611 <tag/Function/Insert a 6502 BRK instrunction into the code.
612 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
613 <tag/Declaration/<tt/void BRK (void);/
614 <tag/Description/The function will insert a 6502 BRK instruction into the code
615 which may be used to trigger a debugger.
616 <tag/Limits/<itemize>
617 <item>The function is actually a macro.
618 <item>The inserted instruction may lead to unexpected results if no debugger
621 <tag/Availability/cc65
623 <ref id="CLI" name="CLI">,
624 <ref id="SEI" name="SEI">
630 <sect1>CLI<label id="CLI"><p>
634 <tag/Function/Insert a 6502 CLI instrunction into the code.
635 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
636 <tag/Declaration/<tt/void CLI (void);/
637 <tag/Description/The function will insert a 6502 CLI instruction into the code,
638 so interrupts are disabled. Note that non maskable interrupts cannot be
640 <tag/Limits/<itemize>
641 <item>The function is actually a macro.
642 <item>Disabling interrupts may lead to unexpected results.
644 <tag/Availability/cc65
646 <ref id="BRK" name="BRK">,
647 <ref id="SEI" name="SEI">
653 <sect1>PEEK<label id="PEEK"><p>
657 <tag/Function/Read a byte from memory.
658 <tag/Header/<tt/<ref id="peekpoke.h" name="peekpoke.h">/
659 <tag/Declaration/<tt/unsigned char PEEK (unsigned addr);/
660 <tag/Description/The function will read the absolute memory given by <tt/addr/
661 and return the value read.
662 <tag/Limits/<itemize>
663 <item>The function is actually a macro.
664 <item>This function depends highly on the platform and environment.
666 <tag/Availability/cc65
668 <ref id="PEEKW" name="PEEKW">,
669 <ref id="POKE" name="POKE">
675 <sect1>PEEKW<label id="PEEKW"><p>
679 <tag/Function/Read a word (two bytes) from memory.
680 <tag/Header/<tt/<ref id="peekpoke.h" name="peekpoke.h">/
681 <tag/Declaration/<tt/unsigned PEEKW (unsigned addr);/
682 <tag/Description/The function will read the absolute memory given by <tt/addr/
683 and return the value read. The byte read from the higher address is the high
684 byte of the return value.
685 <tag/Limits/<itemize>
686 <item>The function is actually a macro.
687 <item>This function depends highly on the platform and environment.
688 <item>The order in which the two bytes are read is unspecified and may
689 depend of the address expression used.
691 <tag/Availability/cc65
693 <ref id="PEEK" name="PEEK">,
694 <ref id="POKE" name="POKE">
700 <sect1>POKE<label id="POKE"><p>
704 <tag/Function/Write a byte to memory.
705 <tag/Header/<tt/<ref id="peekpoke.h" name="peekpoke.h">/
706 <tag/Declaration/<tt/void POKE (unsigned addr, unsigned char val);/
707 <tag/Description/The function writes the value <tt/val/ to the absolute
708 memory address given by <tt/addr/.
709 <tag/Limits/<itemize>
710 <item>The function is actually a macro.
711 <item>This function depends highly on the platform and environment.
712 <item>Careless use will cause the program to act strange or may crash the
715 <tag/Availability/cc65
717 <ref id="PEEK" name="PEEK">,
718 <ref id="POKEW" name="POKEW">
724 <sect1>POKEW<label id="POKEW"><p>
728 <tag/Function/Write a word (two bytes) to memory.
729 <tag/Header/<tt/<ref id="peekpoke.h" name="peekpoke.h">/
730 <tag/Declaration/<tt/void POKEW (unsigned addr, unsigned val);/
731 <tag/Description/The function writes the value <tt/val/ to the absolute
732 memory address given by <tt/addr/. The low byte of <tt/val/ is written to
733 the <tt/addr/, the high byte is written to <tt/addr+1/.
734 <tag/Limits/<itemize>
735 <item>The function is actually a macro.
736 <item>This function depends highly on the platform and environment.
737 <item>Careless use will cause the program to act strange or may crash the
739 <item>The order in which the two bytes are written is unspecified and may
740 depend of the address expression used.
742 <tag/Availability/cc65
744 <ref id="PEEK" name="PEEK">,
745 <ref id="POKE" name="POKE">
751 <sect1>SEI<label id="SEI"><p>
755 <tag/Function/Insert a 6502 SEI instrunction into the code.
756 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
757 <tag/Declaration/<tt/void SEI (void);/
758 <tag/Description/The function will insert a 6502 SEI instruction into the code,
759 so interrupts are enabled. Enabling interrupts has no effects if they are
760 already enabled (the default).
761 <tag/Limits/<itemize>
762 <item>The function is actually a macro.
764 <tag/Availability/cc65
766 <ref id="BRK" name="BRK">,
767 <ref id="CLI" name="CLI">
773 <sect1>abort<label id="abort"><p>
777 <tag/Function/Terminates a program abnormally.
778 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
779 <tag/Declaration/<tt/void abort (void);/
780 <tag/Description/<tt/abort/ raises <tt/SIGABRT/, writes a termination message
781 on stderr, then terminates the program with an exit code of 3.
782 <tag/Availability/ISO 9899
784 <ref id="assert" name="assert">,
785 <ref id="exit" name="exit">,
786 <ref id="raise" name="raise">
792 <sect1>abs<label id="abs"><p>
796 <tag/Function/Returns the absolute value of an integer.
797 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
798 <tag/Declaration/<tt/int __fastcall__ abs (int v);/
799 <tag/Description/<tt/abs/ returns the absolute value of the argument passed to
801 <tag/Limits/<itemize>
802 <item>The return value is undefined if <tt/INT_MIN/ is passed to the function.
803 <item>The function is only available as fastcall function, so it may only be
804 used in presence of a prototype.
806 <tag/Availability/ISO 9899
808 <ref id="labs" name="labs">
814 <sect1>assert<label id="assert"><p>
818 <tag/Function/Test a condition and possibly abort.
819 <tag/Header/<tt/<ref id="assert.h" name="assert.h">/
820 <tag/Declaration/<tt/void assert (int cond);/
821 <tag/Description/<tt/assert/ is a macro that expands to a <tt/id/
822 statement. If the condition evaluates t zero (false), assert prints a message
823 on stderr and aborts the program.
824 <tag/Limits/<itemize>
825 <item>The function is actually a macro.
827 <tag/Availability/ISO 9899
829 <ref id="abort" name="abort">,
830 <ref id="exit" name="exit">
836 <sect1>atexit<label id="atexit"><p>
840 <tag/Function/Register an exit function.
841 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
842 <tag/Declaration/<tt/int __fastcall__ atexit (void (*exitfunc) (void));/
843 <tag/Description/<tt/atexit/ registers the function pointed to by
844 <tt/exitfunc/ as an exit function. Exit functions are called when the program
845 terminates, they are called in LIFO order (the last function registered is
846 called first). <tt/atexit/ returns zero on success and a nonzero value on
848 <tag/Limits/<itemize>
849 <item>A maximum of 5 exit functions can be registered.
850 <item>There is no way to unregister an exit function.
851 <item>The function is only available as fastcall function, so it may only be
852 used in presence of a prototype.
854 <tag/Availability/ISO 9899
856 <ref id="abort" name="abort">,
857 <ref id="exit" name="exit">
863 <sect1>atoi<label id="atoi"><p>
867 <tag/Function/Convert a string to an integer.
868 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
869 <tag/Declaration/<tt/int __fastcall__ atoi (const char* s);/
870 <tag/Description/<tt/atoi/ converts the given string into an integer.
871 Conversion stops as soon as any invalid character is encountered.
872 <tag/Limits/<itemize>
873 <item>There is no way to detect any conversion errors.
874 <item>The function does not check for an numerical overflow when converting.
875 <item>The function is only available as fastcall function, so it may only be
876 used in presence of a prototype.
878 <tag/Availability/ISO 9899
880 <ref id="atol" name="atol">,
881 <ref id="itoa" name="itoa">,
882 <ref id="ltoa" name="ltoa">,
883 <ref id="ultoa" name="ultoa">,
884 <ref id="utoa" name="utoa">
890 <sect1>atol<label id="atol"><p>
894 <tag/Function/Convert a string to a long integer.
895 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
896 <tag/Declaration/<tt/long __fastcall__ atol (const char* s);/
897 <tag/Description/<tt/atol/ converts the given string into a long integer.
898 Conversion stops as soon as any invalid character is encountered.
899 <tag/Limits/<itemize>
900 <item>There is no way to detect any conversion errors.
901 <item>The function does not check for an numerical overflow when converting.
902 <item>The function is only available as fastcall function, so it may only be
903 used in presence of a prototype.
905 <tag/Availability/ISO 9899
907 <ref id="atoi" name="atoi">,
908 <ref id="itoa" name="itoa">,
909 <ref id="ltoa" name="ltoa">,
910 <ref id="ultoa" name="ultoa">,
911 <ref id="utoa" name="utoa">
917 <sect1>bgcolor<label id="bgcolor"><p>
921 <tag/Function/Set the background text color.
922 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
923 <tag/Declaration/<tt/unsigned char __fastcall__ bgcolor (unsigned char color);/
924 <tag/Description/The function will set a new background text color. It returns
925 the old (current) background color.
926 <tag/Limits/<itemize>
927 <item>Background colors are system dependent. The function may have no effect
928 on systems where the background color cannot be changed.
929 <item>The function is only available as fastcall function, so it may only be
930 used in presence of a prototype.
932 <tag/Availability/cc65
934 <ref id="bordercolor" name="bordercolor">,
935 <ref id="textcolor" name="textcolor">
941 <sect1>bordercolor<label id="bordercolor"><p>
945 <tag/Function/Set the border (frame) color.
946 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
947 <tag/Declaration/<tt/unsigned char __fastcall__ bordercolor (unsigned char color);/
948 <tag/Description/The function will set a new border color. It returns the old
949 (current) border color.
950 <tag/Limits/<itemize>
951 <item>Border colors are system dependent. The function may have no effect
952 on systems where the border color cannot be changed.
953 <item>The function is only available as fastcall function, so it may only
954 be used in presence of a prototype.
956 <tag/Availability/cc65
958 <ref id="bgcolor" name="bgcolor">,
959 <ref id="textcolor" name="textcolor">
965 <sect1>bsearch<label id="bsearch"><p>
969 <tag/Function/Do a binary search in a sorted array.
970 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
971 <tag/Declaration/<tt/void* __fastcall__ bsearch (const void* key,
972 const void* base, size_t n, size_t size,
973 int (*cmp) (const void*, const void*));/
974 <tag/Description/<tt/bsearch/ searches a sorted array for a member that
975 matches the one pointed to by <tt/key/. <tt/base/ is the address of the array,
976 <tt/n/ is the number of elements, <tt/size/ the size of an element and <tt/cmp/
977 the function used to compare the members against the key. The function returns
978 a pointer to the member found, or <tt/NULL/ if there was no match.
981 <item>The contents of the array must be sorted in ascending order according to
982 the compare function given.
983 <item>If there are multiple members that match the key, the function will
984 return one of the members.
985 <item>The function is only available as fastcall function, so it may only
986 be used in presence of a prototype.
988 <tag/Availability/ISO 9899
990 <ref id="qsort" name="qsort">
996 <sect1>bzero<label id="bzero"><p>
1000 <tag/Function/Fill a memory area with zeroes.
1001 <tag/Header/<tt/<ref id="string.h" name="string.h">/
1002 <tag/Declaration/<tt/void __fastcall__ bzero (void* p, size_t count);/
1003 <tag/Description/<tt/bzero/ fills the memory area pointed to by <tt/p/ with
1007 <item>The function is non standard and therefore only available in non ANSI
1008 mode. You should use <tt/<ref id="memset" name="memset">/ instead.
1009 <item>The function is only available as fastcall function, so it may only
1010 be used in presence of a prototype.
1012 <tag/Availability/cc65
1014 <ref id="_swap" name="_swap">,
1015 <ref id="memcpy" name="memcpy">,
1016 <ref id="memmove" name="memmove">,
1017 <ref id="memset" name="memset">,
1023 <sect1>c64mode<label id="c64mode"><p>
1027 <tag/Function/Switch the C128 into C64 compatible mode.
1028 <tag/Header/<tt/<ref id="c128.h" name="c128.h">/
1029 <tag/Declaration/<tt/void c64mode (void);/
1030 <tag/Description/The function will cause the machine to reboot into C64 mode.
1031 <tag/Limits/<itemize>
1032 <item>The function is specific to the C128.
1033 <item>The function will not return to the caller.
1035 <tag/Availability/C128
1041 <sect1>calloc<label id="calloc"><p>
1045 <tag/Function/Allocate and clear memory.
1046 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1047 <tag/Declaration/<tt/void* __fastcall__ calloc (size_t n, size_t size);/
1048 <tag/Description/<tt/calloc/ allocates memory for an array of <tt/n/ elements
1049 of size <tt/size/, clears the whole block with binary zeroes and returns a
1050 pointer to it. On error (not enough memory available), <tt/calloc/ returns
1054 <item>Clearing the memory may not have the expected effect on all platforms:
1055 pointers in the block may not be <tt/NULL/ and floating point variables may
1056 not be zero (0.0). In other words: The "clearing" effect of this function
1057 should be used with care for portable programs.
1058 <item>The function is only available as fastcall function, so it may only
1059 be used in presence of a prototype.
1061 <tag/Availability/ISO 9899
1063 <ref id="_heapadd" name="_heapadd">,
1064 <ref id="_heapmaxavail" name="_heapmaxavail">,
1065 <ref id="_heapmemavail" name="_heapmemavail">,
1066 <ref id="free" name="free">,
1067 <ref id="malloc" name="malloc">,
1068 <ref id="realloc" name="realloc">
1074 <sect1>cclear<label id="cclear"><p>
1078 <tag/Function/Clear part of a line (write a given number of spaces).
1079 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1080 <tag/Declaration/<tt/void __fastcall__ cclear (unsigned char length);/
1081 <tag/Description/The function clears part of a line by writing <tt/length/
1082 spaces in the current text color.
1083 <tag/Limits/<itemize>
1084 <item>The function is only available as fastcall function, so it may
1085 only be used in presence of a prototype.
1087 <tag/Availability/cc65
1089 <ref id="cclearxy" name="cclearxy">,
1090 <ref id="clrscr" name="clrscr">
1096 <sect1>cclearxy<label id="cclearxy"><p>
1100 <tag/Function/Clear part of a line (write a given number of spaces) starting
1101 at a specific screen position.
1102 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1103 <tag/Declaration/<tt/void __fastcall__ cclearxy (unsigned char x, unsigned char y, unsigned char length);/
1104 <tag/Description/The function moves the cursor to a specific position, and
1105 will then clear part of the line by writing <tt/length/ spaces in the current
1107 <tag/Limits/<itemize>
1108 <item>The function is only available as fastcall function, so it may
1109 only be used in presence of a prototype.
1111 <tag/Availability/cc65
1113 <ref id="cclear" name="cclear">,
1114 <ref id="clrscr" name="clrscr">
1120 <sect1>cgetc<label id="cgetc"><p>
1124 <tag/Function/Read a character from the keyboard.
1125 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1126 <tag/Declaration/<tt/char cgetc (void);/
1127 <tag/Description/The function reads a character from the keyboard. If there is
1128 no character available, <tt/cgetc/ waits until the user presses a key. If the
1129 cursor is enabled by use of the <tt/cursor/ function, a blinking cursor is
1130 displayed while waiting.
1131 <tag/Limits/<itemize>
1132 <item>If the system supports a keyboard buffer, <tt/cgetc/ will fetch a key
1133 from this buffer and wait only if the buffer is empty.
1135 <tag/Availability/cc65
1137 <ref id="cursor" name="cursor">,
1138 <ref id="kbhit" name="kbhit">
1144 <sect1>chline<label id="chline"><p>
1148 <tag/Function/Output a horizontal line in text mode.
1149 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1150 <tag/Declaration/<tt/void __fastcall__ chline (unsigned char length);/
1151 <tag/Description/The function outputs a horizontal line with the given length
1152 starting at the current cursor position.
1153 <tag/Limits/<itemize>
1154 <item>The character used to draw the horizontal line is system dependent.
1155 If available, a line drawing character is used. Drawing a line that is partially
1156 off screen leads to undefined behaviour.
1157 <item>The function is only available as fastcall function, so it may only be
1158 used in presence of a prototype.
1160 <tag/Availability/cc65
1162 <ref id="chlinexy" name="chlinexy">,
1163 <ref id="cvline" name="cvline">,
1164 <ref id="cvlinexy" name="cvlinexy">
1170 <sect1>chlinexy<label id="chlinexy"><p>
1174 <tag/Function/Output a horizontal line at a given position in text mode.
1175 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1176 <tag/Declaration/<tt/void __fastcall__ chlinexy (unsigned char x, unsigned char y, unsigned char length);/
1177 <tag/Description/The function outputs a horizontal line with the given length
1178 starting at a given position.
1179 <tag/Limits/<itemize>
1180 <item>The character used to draw the horizontal line is system dependent.
1181 If available, a line drawing character is used. Drawing a line that is partially
1182 off screen leads to undefined behaviour.
1183 <item>The function is only available as fastcall function, so it may only be
1184 used in presence of a prototype.
1186 <tag/Availability/cc65
1188 <ref id="chline" name="chline">,
1189 <ref id="cvline" name="cvline">,
1190 <ref id="cvlinexy" name="cvlinexy">
1196 <sect1>clrscr<label id="clrscr"><p>
1200 <tag/Function/Clear the text screen.
1201 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1202 <tag/Declaration/<tt/void clrscr (void);/
1203 <tag/Description/The function clears the text screen and moves the cursor to
1204 the upper left corner.
1205 <tag/Availability/cc65
1207 <ref id="cclear" name="cclear">,
1208 <ref id="cclearxy" name="cclearxy">
1214 <sect1>close<label id="close"><p>
1218 <tag/Function/Close a file descriptor.
1219 <tag/Header/<tt/<ref id="fcntl.h" name="fcntl.h">/
1220 <tag/Declaration/<tt/int __fastcall__ close (int fd);/
1221 <tag/Description/The function closes the given file descriptor. It returns zero
1222 on success and -1 on error. If an error occurs, the cause can be determined by
1223 reading the <tt/errno/ variable.
1224 <tag/Limits/<itemize>
1225 <item>The function is only available as fastcall function, so it may only
1226 be used in presence of a prototype.
1228 <tag/Availability/POSIX
1230 <ref id="creat" name="creat">,
1231 <ref id="open" name="open">
1237 <sect1>creat<label id="creat"><p>
1241 <tag/Function/Create a file.
1242 <tag/Header/<tt/<ref id="fcntl.h" name="fcntl.h">/
1243 <tag/Declaration/<tt/int __fastcall__ creat (const char* name, unsigned mode);/
1244 <tag/Description/<tt/creat/ creates a new file and returns the file descriptor
1245 associated with it. On error, -1 is returned and an error code is stored in
1247 <tag/Limits/<itemize>
1248 <item><tt/creat/ is identical to calling <tt/<ref id="open" name="open">/ with
1249 <tt/flags/ equal to <tt/O_WRONLY | O_CREAT | O_TRUNC/.
1250 <item>The function is only available as fastcall function, so it may only
1251 be used in presence of a prototype.
1253 <tag/Availability/POSIX
1255 <ref id="close" name="close">,
1256 <ref id="open" name="open">
1262 <sect1>cprintf<label id="cprintf"><p>
1266 <tag/Function/Formatted output to the console.
1267 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1268 <tag/Declaration/<tt/int cprintf (const char* format, ...);/
1269 <tag/Description/The arguments are converted to text where necessary and
1270 formatted according to the format string given. The resulting string is output
1271 to the console. <tt/cprintf/ supports the same format specifiers as
1272 <tt/printf/. <!-- <tt/<ref id="printf" name="printf">/. -->
1273 <tag/Limits/<itemize>
1274 <item>Like all other <tt/conio/ output functions, <tt/cprintf/ distinguishes
1275 between <tt/\r/ and <tt/\n/.
1277 <tag/Availability/cc65
1279 <ref id="cputc" name="cputc">,
1280 <ref id="cputcxy" name="cputcxy">,
1281 <ref id="cputs" name="cputs">,
1282 <ref id="cputsxy" name="cputsxy">,
1283 <ref id="vcprintf" name="vcprintf">
1289 <sect1>cputc<label id="cputc"><p>
1293 <tag/Function/Output a character directly to the console.
1294 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1295 <tag/Declaration/<tt/void __fastcall__ cputc (char c);/
1296 <tag/Description/Output one character to the console at the current cursor
1298 <tag/Limits/<itemize>
1299 <item>Like all other <tt/conio/ output functions, <tt/cputc/ distinguishes
1300 between <tt/\r/ and <tt/\n/.
1301 <item>The function is only available as fastcall function, so it may only
1302 be used in presence of a prototype.
1304 <tag/Availability/cc65
1306 <ref id="cprintf" name="cprintf">,
1307 <ref id="cputcxy" name="cputcxy">,
1308 <ref id="cputs" name="cputs">,
1309 <ref id="cputsxy" name="cputsxy">,
1310 <ref id="vcprintf" name="vcprintf">
1316 <sect1>cputcxy<label id="cputcxy"><p>
1320 <tag/Function/Output a character at a specific screen position.
1321 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1322 <tag/Declaration/<tt/void __fastcall__ cputcxy (unsigned char x, unsigned char y, char c);/
1323 <tag/Description/<tt/cputcxy/ moves the cursor to the given x/y position on
1324 the screen and outputs one character.
1325 <tag/Limits/<itemize>
1326 <item>Like all other <tt/conio/ output functions, <tt/cputcxy/ distinguishes
1327 between <tt/\r/ and <tt/\n/.
1328 <item>The function is only available as fastcall function, so it may only
1329 be used in presence of a prototype.
1331 <tag/Availability/cc65
1333 <ref id="cprintf" name="cprintf">,
1334 <ref id="cputc" name="cputc">,
1335 <ref id="cputs" name="cputs">,
1336 <ref id="cputsxy" name="cputsxy">,
1337 <ref id="vcprintf" name="vcprintf">
1343 <sect1>cputs<label id="cputs"><p>
1347 <tag/Function/Output a string directly to the console.
1348 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1349 <tag/Declaration/<tt/void __fastcall__ cputs (const char* s);/
1350 <tag/Description/The function outputs the given string on the console at the
1351 current cursor position.
1352 <tag/Limits/<itemize>
1353 <item>Like all other <tt/conio/ output functions, <tt/cputs/ distinguishes
1354 between <tt/\r/ and <tt/\n/.
1355 <item>The function is only available as fastcall function, so it may only
1356 be used in presence of a prototype.
1358 <tag/Availability/cc65
1360 <ref id="cprintf" name="cprintf">,
1361 <ref id="cputc" name="cputc">,
1362 <ref id="cputcxy" name="cputcxy">,
1363 <ref id="cputsxy" name="cputsxy">,
1364 <ref id="vcprintf" name="vcprintf">
1370 <sect1>cputsxy<label id="cputsxy"><p>
1374 <tag/Function/Output a string to the console at a given position.
1375 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1376 <tag/Declaration/<tt/void __fastcall__ cputsxy (unsigned char x, unsigned char y, const char* s);/
1377 <tag/Description/<tt/cputsxy/ moves the cursor to the given x/y position,
1378 and outputs the string <tt/s/.
1379 <tag/Limits/<itemize>
1380 <item>Like all other <tt/conio/ output functions, <tt/cputsxy/ distinguishes
1381 between <tt/\r/ and <tt/\n/.
1382 <item>The function is only available as fastcall function, so it may only
1383 be used in presence of a prototype.
1385 <tag/Availability/cc65
1387 <ref id="cprintf" name="cprintf">,
1388 <ref id="cputc" name="cputc">,
1389 <ref id="cputcxy" name="cputcxy">,
1390 <ref id="cputs" name="cputs">,
1391 <ref id="vcprintf" name="vcprintf">
1397 <sect1>cursor<label id="cursor"><p>
1401 <tag/Function/Enable/disable a blinking cursor when waiting for keyboard input.
1402 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1403 <tag/Declaration/<tt/unsigned char __fastcall__ cursor (unsigned char onoff);/
1404 <tag/Description/If the argument to the function is non zero, a blinking cursor
1405 will be enabled when the <tt/cgetc/ function waits for input from the keyboard.
1406 If the argument is zero, <tt/cgetc/ will wait without a blinking cursor.
1407 <tag/Limits/<itemize>
1408 <item>The function is only available as fastcall function, so it may only
1409 be used in presence of a prototype.
1411 <tag/Availability/cc65
1413 <ref id="cgetc" name="cgetc">,
1414 <ref id="kbhit" name="kbhit">
1420 <sect1>cvline<label id="cvline"><p>
1424 <tag/Function/Output a vertical line in text mode.
1425 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1426 <tag/Declaration/<tt/void __fastcall__ cvline (unsigned char length);/
1427 <tag/Description/The function outputs a vertical line with the given length
1428 starting at the current cursor position.
1429 <tag/Limits/<itemize>
1430 <item>The character used to draw the vertical line is system dependent.
1431 If available, a line drawing character is used. Drawing a line that is partially
1432 off screen leads to undefined behaviour.
1433 <item>The function is only available as fastcall function, so it may only be
1434 used in presence of a prototype.
1436 <tag/Availability/cc65
1438 <ref id="chline" name="chline">,
1439 <ref id="chlinexy" name="chlinexy">,
1440 <ref id="cvlinexy" name="cvlinexy">
1446 <sect1>cvlinexy<label id="cvlinexy"><p>
1450 <tag/Function/Output a vertical line at a given position in text mode.
1451 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1452 <tag/Declaration/<tt/void __fastcall__ cvlinexy (unsigned char x, unsigned char y, unsigned char length);/
1453 <tag/Description/The function outputs a vertical line with the given length
1454 starting at a given position.
1455 <tag/Limits/<itemize>
1456 <item>The character used to draw the vertical line is system dependent.
1457 If available, a line drawing character is used. Drawing a line that is partially
1458 off screen leads to undefined behaviour.
1459 <item>The function is only available as fastcall function, so it may only be
1460 used in presence of a prototype.
1462 <tag/Availability/cc65
1464 <ref id="chline" name="chline">,
1465 <ref id="chlinexy" name="chlinexy">,
1466 <ref id="cvline" name="cvline">
1472 <sect1>div<label id="div"><p>
1476 <tag/Function/Divide two ints and return quotient and remainder.
1477 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1478 <tag/Declaration/<tt/div_t __fastcall__ div (int numer, int denom);/
1479 <tag/Description/<tt/div/ divides <tt/numer/ by <tt/denom/ and returns the
1480 quotient and remainder in a <tt/div_t/ structure.
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
1494 <sect1>em_commit<label id="em_commit"><p>
1498 <tag/Function/Commit changes into extended memory.
1499 <tag/Header/<tt/<ref id="em.h" name="em.h">/
1500 <tag/Declaration/<tt/void __fastcall__ em_commit (void);/
1501 <tag/Description/Commit changes in the memory window to extended storage. If
1502 the contents of the memory window have been changed, these changes may be lost
1503 if <tt/<ref id="em_map" name="em_map">/, <tt/<ref id="em_use" name="em_use">/,
1504 <tt/<ref id="em_copyfrom" name="em_copyfrom">/ or <tt/<ref id="em_copyto"
1505 name="em_copyto">/ are called without calling <tt/em_commit/ first.
1506 <tag/Limits/<itemize>
1507 <item>Calling <tt/em_commit/ does not necessarily mean that changes to the
1508 memory window are discarded, it does just mean that the drivers is allowed
1510 <item>The function is only available as fastcall function, so it may only be
1511 used in presence of a prototype.
1512 <item>The function produces undefined results if no extended memory driver is
1515 <tag/Availability/cc65
1517 <ref id="em_load_driver" name="em_load_driver">,
1518 <ref id="em_map" name="em_map">,
1519 <ref id="em_use" name="em_use">
1525 <sect1>em_copyfrom<label id="em_copyfrom"><p>
1529 <tag/Function/Copy from extended into normal memory.
1530 <tag/Header/<tt/<ref id="em.h" name="em.h">/
1531 <tag/Declaration/<tt/void __fastcall__ em_copyfrom (const struct em_copy* copy_data);/
1532 <tag/Description/Copy data from extended memory into linear memory. Source and
1533 target addresses as well as the number of bytes to transfer are specified in
1534 the <tt/em_copy/ structure that is passed as a parameter.
1535 <tag/Limits/<itemize>
1536 <item>Calling <tt/em_copyfrom/ will invalidate the memory window, so if you
1537 made any changes to the data in the window, call <tt/<ref id="em_commit"
1538 name="em_commit">/ first, or the changes are lost.
1539 <item>The function is only available as fastcall function, so it may only be
1540 used in presence of a prototype.
1541 <item>The function produces undefined results if no extended memory driver is
1544 <tag/Availability/cc65
1546 <ref id="em_commit" name="em_commit">,
1547 <ref id="em_copyto" name="em_copyto">,
1548 <ref id="em_load_driver" name="em_load_driver">
1554 <sect1>em_copyto<label id="em_copyto"><p>
1558 <tag/Function/Copy from normal into extended memory.
1559 <tag/Header/<tt/<ref id="em.h" name="em.h">/
1560 <tag/Declaration/<tt/void __fastcall__ em_copyto (const struct em_copy* copy_data);/
1561 <tag/Description/Copy data from linear into extended memory. Source and
1562 target addresses as well as the number of bytes to transfer are specified in
1563 the <tt/em_copy/ structure that is passed as a parameter.
1564 <tag/Limits/<itemize>
1565 <item>Calling <tt/em_copyto/ will invalidate the memory window, so if you
1566 made any changes to the data in the window, call <tt/<ref id="em_commit"
1567 name="em_commit">/ first, or the changes are lost.
1568 <item>The function is only available as fastcall function, so it may only be
1569 used in presence of a prototype.
1570 <item>The function produces undefined results if no extended memory driver is
1573 <tag/Availability/cc65
1575 <ref id="em_commit" name="em_commit">,
1576 <ref id="em_copyfrom" name="em_copyfrom">,
1577 <ref id="em_load_driver" name="em_load_driver">
1583 <sect1>em_load_driver<label id="em_load_driver"><p>
1587 <tag/Function/Load and initialize an extended memory driver.
1588 <tag/Header/<tt/<ref id="em.h" name="em.h">/
1589 <tag/Declaration/<tt/void __fastcall__ em_load_driver (const char* name);/
1590 <tag/Description/Load an extended memory driver into memory and initialize
1591 it. The function returns an error code that tells if all this has been
1593 <tag/Limits/<itemize>
1594 <item>Not all drivers are able to detect if the supported hardware is really
1596 <item>The function is only available as fastcall function, so it may only be
1597 used in presence of a prototype.
1598 <item>The driver is loaded by name, so currently you must know the type of
1599 extended memory that should be supported. There is no autodetect capability.
1601 <tag/Availability/cc65
1603 <ref id="em_unload" name="em_unload">
1609 <sect1>em_map<label id="em_map"><p>
1613 <tag/Function/Make a page of extended memory accessible.
1614 <tag/Header/<tt/<ref id="em.h" name="em.h">/
1615 <tag/Declaration/<tt/void* __fastcall__ em_map (unsigned page);/
1616 <tag/Description/The function maps one page of extended memory into linear
1617 memory and returns a pointer to the page frame. Depending on the hardware
1618 and driver, the data is either mapped into the address space or transfered
1619 into a buffer. If you don't need the actual contents of the page (for example
1620 because you're going to overwrite it completely, it is better to call
1621 <tt/<ref id="em_use" name="em_use">/ instead. <tt/em_use/ will not transfer the
1622 data if it is possible to avoid that.
1623 <tag/Limits/<itemize>
1624 <item>Calling <tt/em_map/ will invalidate the memory window, so if you
1625 made any changes to the data in the window, call <tt/<ref id="em_commit"
1626 name="em_commit">/ first, or the changes are lost.
1627 <item>The function is only available as fastcall function, so it may only be
1628 used in presence of a prototype.
1629 <item>The function produces undefined results if no extended memory driver is
1632 <tag/Availability/cc65
1634 <ref id="em_commit" name="em_commit">,
1635 <ref id="em_load_driver" name="em_load_driver">,
1636 <ref id="em_use" name="em_use">
1642 <sect1>em_pagecount<label id="em_pagecount"><p>
1646 <tag/Function/Return the number of available extended memory pages.
1647 <tag/Header/<tt/<ref id="em.h" name="em.h">/
1648 <tag/Declaration/<tt/unsigned __fastcall__ em_pagecount (void);/
1649 <tag/Description/The function returns the size of the extended memory supported
1650 by the driver in 256 byte pages.
1651 <tag/Limits/<itemize>
1652 <item>The function returns zero if no extended memory driver is loaded.
1653 <item>The function may return zero if the supported hardware was not detected.
1655 <tag/Availability/cc65
1657 <ref id="em_load_driver" name="em_load_driver">
1663 <sect1>em_unload<label id="em_unload"><p>
1667 <tag/Function/Unload an extended memory driver.
1668 <tag/Header/<tt/<ref id="em.h" name="em.h">/
1669 <tag/Declaration/<tt/void __fastcall__ em_unload (void);/
1670 <tag/Description/The function unloads a loaded extended memory driver and
1671 frees all memory allocated for the driver.
1672 <tag/Limits/<itemize>
1673 <item>The function does nothing if no driver is loaded.
1675 <tag/Availability/cc65
1677 <ref id="em_load_driver" name="em_load_driver">
1683 <sect1>em_use<label id="em_use"><p>
1687 <tag/Function/Prepare an extended memory page for use.
1688 <tag/Header/<tt/<ref id="em.h" name="em.h">/
1689 <tag/Declaration/<tt/void* __fastcall__ em_use (unsigned page);/
1690 <tag/Description/The function maps one page of extended memory into linear
1691 memory and returns a pointer to the page frame. This function is similar to
1692 <tt/<ref id="em_map" name="em_map">/, but will not transfer data into the
1693 actual memory window in the assumption that the existing data is wrong or
1694 will get overwritten.
1695 <tag/Limits/<itemize>
1696 <item>Calling <tt/em_use/ will invalidate the memory window, so if you
1697 made any changes to the data in the window, call <tt/<ref id="em_commit"
1698 name="em_commit">/ first, or the changes are lost.
1699 <item>The function is only available as fastcall function, so it may only be
1700 used in presence of a prototype.
1701 <item>The function produces undefined results if no extended memory driver is
1704 <tag/Availability/cc65
1706 <ref id="em_commit" name="em_commit">,
1707 <ref id="em_load_driver" name="em_load_driver">,
1708 <ref id="em_map" name="em_map">
1714 <sect1>exit<label id="exit"><p>
1718 <tag/Function/Terminate the program.
1719 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1720 <tag/Declaration/<tt/void __fastcall__ exit (int status);/
1721 <tag/Description/<tt/exit/ terminates the program. The argument specifies the
1722 return code of the program. Before termination, all files are closed, buffered
1723 output is written and any functions registered with <tt/<ref id="atexit"
1724 name="atexit">/ are called. Common values for status are <tt/EXIT_SUCCESS/ and
1725 <tt/EXIT_FAILURE/ which are also defined in <tt/<ref id="stdlib.h"
1727 <tag/Limits/<itemize>
1728 <item>The function is only available as fastcall function, so it may only
1729 be used in presence of a prototype.
1730 <item>It depends on the host machine if the program return code can be
1731 evaluated or is ignored.
1733 <tag/Availability/ISO 9899
1735 <ref id="abort" name="abort">,
1736 <ref id="exit" name="exit">
1742 <sect1>fast<label id="fast"><p>
1746 <tag/Function/Switch the C128 into 2MHz mode.
1747 <tag/Header/<tt/<ref id="c128.h" name="c128.h">/
1748 <tag/Declaration/<tt/void fast (void);/
1749 <tag/Description/The function will switch the clock of the C128 to 2MHz. This
1750 will nearly double the speed compared to slow mode.
1751 <tag/Limits/<itemize>
1752 <item>The function is specific to the C128.
1753 <item>2MHz clock will not work in 40 column mode.
1755 <tag/Availability/C128
1757 <ref id="slow" name="slow">,
1758 <ref id="toggle_videomode" name="toggle_videomode">
1764 <sect1>free<label id="free"><p>
1768 <tag/Function/Free a block of dynamic memory.
1769 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1770 <tag/Declaration/<tt/void __fastcall__ free (void* block);/
1771 <tag/Description/Free a block of dynamic memory previously allocated with
1772 <tt/<ref id="malloc" name="malloc">/, <tt/<ref id="calloc" name="calloc">/
1773 or <tt/<ref id="realloc" name="realloc">/. As an exception, if the passed
1774 pointer is <tt/NULL/, no action is performed.
1777 <item>Passing an already free'd block to <tt/free/ again will cause undefined
1778 behaviour and may crash your program.
1779 <item>The function is only available as fastcall function, so it may only
1780 be used in presence of a prototype.
1782 <tag/Availability/ISO 9899
1784 <ref id="_heapadd" name="_heapadd">,
1785 <ref id="_heapmaxavail" name="_heapmaxavail">,
1786 <ref id="_heapmemavail" name="_heapmemavail">,
1787 <ref id="calloc" name="calloc">,
1788 <ref id="malloc" name="malloc">,
1789 <ref id="realloc" name="realloc">
1795 <sect1>getenv<label id="getenv"><p>
1799 <tag/Function/Return a value from the environment.
1800 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1801 <tag/Declaration/<tt/char* __fastcall__ getenv (const char* name);/
1802 <tag/Description/The function searches the environment for an entry that
1803 matches <tt/name/ and returns its value. The environment consists of a list
1804 of strings in the form <tt/name=value/. If there is no match, <tt/getenv/
1806 <tag/Limits/<itemize>
1807 <item>What exactly is stored in the environment depends on the machine the
1808 program is running on.
1809 <item>The function is only available as fastcall function, so it may only
1810 be used in presence of a prototype.
1812 <tag/Availability/ISO 9899
1818 <sect1>getcpu<label id="getcpu"><p>
1822 <tag/Function/Determine on which CPU the program is running.
1823 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
1824 <tag/Declaration/<tt/unsigned char getcpu (void);/
1825 <tag/Description/The function checks on which CPU the code is running. It
1826 returns one of the constants<itemize>
1828 <item><tt/CPU_65C02/
1829 <item><tt/CPU_65816/
1831 <tag/Limits/<itemize>
1832 <item>Other, more exotic CPU types are not disinguished.
1834 <tag/Availability/cc65
1840 <sect1>gotox<label id="gotox"><p>
1844 <tag/Function/Move the text mode cursor to a new X position.
1845 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1846 <tag/Declaration/<tt/void __fastcall__ gotox (unsigned char x);/
1847 <tag/Description/The function moves the text mode cursor to the specified X
1848 position while leaving the Y position untouched. The leftmost position on the
1849 screen has the coordinate 0.
1850 <tag/Limits/<itemize>
1851 <item>The function is only available as fastcall function, so it may
1852 only be used in presence of a prototype.
1853 <item>Invalid values for the X position (out of screen coordinates) may
1854 lead to undefined behaviour.
1856 <tag/Availability/cc65
1858 <ref id="gotoy" name="gotoy">,
1859 <ref id="gotoxy" name="gotoxy">,
1860 <ref id="wherex" name="wherex">,
1861 <ref id="wherey" name="wherey">
1867 <sect1>gotoxy<label id="gotoxy"><p>
1871 <tag/Function/Move the text mode cursor to a new position.
1872 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1873 <tag/Declaration/<tt/void __fastcall__ gotoxy (unsigned char x, unsigned char y);/
1874 <tag/Description/The function moves the text mode cursor to the specified
1875 position. The leftmost position on the screen has the X coordinate 0, the
1876 topmost line has the Y coordinate 0.
1877 <tag/Limits/<itemize>
1878 <item>The function is only available as fastcall function, so it may only be
1879 used in presence of a prototype.
1880 <item>Invalid values for any of both coordinates (out of screen positions) may
1881 lead to undefined behaviour.
1883 <tag/Availability/cc65
1885 <ref id="gotox" name="gotox">,
1886 <ref id="gotoy" name="gotoy">,
1887 <ref id="wherex" name="wherex">,
1888 <ref id="wherey" name="wherey">
1894 <sect1>gotoy<label id="gotoy"><p>
1898 <tag/Function/Move the text mode cursor to a new Y position.
1899 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1900 <tag/Declaration/<tt/void __fastcall__ gotoy (unsigned char x);/
1901 <tag/Description/The function moves the text mode cursor to the specified Y
1902 position while leaving the X position untouched. The uppermost position on the
1903 screen has the coordinate 0.
1904 <tag/Limits/<itemize>
1905 <item>The function is only available as fastcall function, so it may
1906 only be used in presence of a prototype.
1907 <item>Invalid values for the Y position (out of screen coordinates) may lead
1908 to undefined behaviour.
1910 <tag/Availability/cc65
1912 <ref id="gotox" name="gotox">,
1913 <ref id="gotoxy" name="gotoxy">,
1914 <ref id="wherex" name="wherex">,
1915 <ref id="wherey" name="wherey">
1921 <sect1>isalnum<label id="isalnum"><p>
1925 <tag/Function/Check if a given character is a letter or digit.
1926 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
1927 <tag/Declaration/<tt/int __fastcall__ isalnum (int c);/
1928 <tag/Description/The function returns a value of zero if the given argument
1929 is a letter or digit. The return value is non zero if the character
1931 <tag/Limits/<itemize>
1932 <item>When compiling with <tt/-Os/ the function is actually a macro. The
1933 inline sequence generated by the macro will not work correctly for values
1934 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
1935 this range. The non inline function may be accessed by <tt/#undef/'ing
1937 <item>When compiling without <tt/-Os/, the function is only available as
1938 fastcall function, so it may only be used in presence of a prototype.
1940 <tag/Availability/ISO 9899
1942 <ref id="isalpha" name="isalpha">,
1943 <ref id="isascii" name="isascii">,
1944 <ref id="isblank" name="isblank">,
1945 <ref id="iscntrl" name="iscntrl">,
1946 <ref id="isdigit" name="isdigit">,
1947 <ref id="isgraph" name="isgraph">,
1948 <ref id="islower" name="islower">,
1949 <ref id="isprint" name="isprint">,
1950 <ref id="ispunct" name="ispunct">,
1951 <ref id="isspace" name="isspace">,
1952 <ref id="isupper" name="isupper">,
1953 <ref id="isxdigit" name="isxdigit">
1959 <sect1>isalpha<label id="isalpha"><p>
1963 <tag/Function/Check if a given character is a letter.
1964 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
1965 <tag/Declaration/<tt/int __fastcall__ isalpha (int c);/
1966 <tag/Description/The function returns a value of zero if the given argument
1967 is a letter. The return value is non zero if the character is anything else.
1968 <tag/Limits/<itemize>
1969 <item>When compiling with <tt/-Os/ the function is actually a macro. The
1970 inline sequence generated by the macro will not work correctly for values
1971 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
1972 this range. The non inline function may be accessed by <tt/#undef/'ing the
1974 <item>When compiling without <tt/-Os/, the function is only available as
1975 fastcall function, so it may only be used in presence of a prototype.
1977 <tag/Availability/ISO 9899
1979 <ref id="isalnum" name="isalnum">,
1980 <ref id="isascii" name="isascii">,
1981 <ref id="isblank" name="isblank">,
1982 <ref id="iscntrl" name="iscntrl">,
1983 <ref id="isdigit" name="isdigit">,
1984 <ref id="isgraph" name="isgraph">,
1985 <ref id="islower" name="islower">,
1986 <ref id="isprint" name="isprint">,
1987 <ref id="ispunct" name="ispunct">,
1988 <ref id="isspace" name="isspace">,
1989 <ref id="isupper" name="isupper">,
1990 <ref id="isxdigit" name="isxdigit">
1996 <sect1>isascii<label id="isascii"><p>
2000 <tag/Function/Check if a given character is in the ASCII (0..127) range.
2001 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2002 <tag/Declaration/<tt/int __fastcall__ isascii (int c);/
2003 <tag/Description/The function returns a value of zero if the given argument
2004 is in the range 0..127 (the range of valid ASCII characters) and a non zero
2006 <tag/Limits/<itemize>
2007 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2008 inline sequence generated by the macro will not work correctly for values
2009 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2010 this range. The non inline function may be accessed by <tt/#undef/'ing the
2012 <item>When compiling without <tt/-Os/, the function is only available as
2013 fastcall function, so it may only be used in presence of a prototype.
2015 <tag/Availability/ISO 9899
2017 <ref id="isalnum" name="isalnum">,
2018 <ref id="isalpha" name="isalpha">,
2019 <ref id="isblank" name="isblank">,
2020 <ref id="iscntrl" name="iscntrl">,
2021 <ref id="isdigit" name="isdigit">,
2022 <ref id="isgraph" name="isgraph">,
2023 <ref id="islower" name="islower">,
2024 <ref id="isprint" name="isprint">,
2025 <ref id="ispunct" name="ispunct">,
2026 <ref id="isspace" name="isspace">,
2027 <ref id="isupper" name="isupper">,
2028 <ref id="isxdigit" name="isxdigit">
2034 <sect1>isblank<label id="isblank"><p>
2038 <tag/Function/Check if a given character is a space or tab.
2039 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2040 <tag/Declaration/<tt/int __fastcall__ isblank (int c);/
2041 <tag/Description/The function returns a value of zero if the given argument
2042 is a space or tab character. The return value is non zero if the character
2044 <tag/Limits/<itemize>
2045 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2046 inline sequence generated by the macro will not work correctly for values
2047 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2048 this range. The non inline function may be accessed by <tt/#undef/'ing the
2050 <item>When compiling without <tt/-Os/, the function is only available as
2051 fastcall function, so it may only be used in presence of a prototype.
2053 <tag/Availability/cc65
2055 <ref id="isalnum" name="isalnum">,
2056 <ref id="isalpha" name="isalpha">,
2057 <ref id="isascii" name="isascii">,
2058 <ref id="iscntrl" name="iscntrl">,
2059 <ref id="isdigit" name="isdigit">,
2060 <ref id="isgraph" name="isgraph">,
2061 <ref id="islower" name="islower">,
2062 <ref id="isprint" name="isprint">,
2063 <ref id="ispunct" name="ispunct">,
2064 <ref id="isspace" name="isspace">,
2065 <ref id="isupper" name="isupper">,
2066 <ref id="isxdigit" name="isxdigit">
2072 <sect1>iscntrl<label id="iscntrl"><p>
2076 <tag/Function/Check if a given character is a control character.
2077 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2078 <tag/Declaration/<tt/int __fastcall__ iscntrl (int c);/
2079 <tag/Description/The function returns a value of zero if the given argument
2080 is a control character. The return value is non zero if the character
2082 <tag/Limits/<itemize>
2083 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2084 inline sequence generated by the macro will not work correctly for values
2085 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2086 this range. The non inline function may be accessed by <tt/#undef/'ing the
2088 <item>When compiling without <tt/-Os/, the function is only available as
2089 fastcall function, so it may only be used in presence of a prototype.
2091 <tag/Availability/ISO 9899
2093 <ref id="isalnum" name="isalnum">,
2094 <ref id="isalpha" name="isalpha">,
2095 <ref id="isascii" name="isascii">,
2096 <ref id="isblank" name="isblank">,
2097 <ref id="isdigit" name="isdigit">,
2098 <ref id="isgraph" name="isgraph">,
2099 <ref id="islower" name="islower">,
2100 <ref id="isprint" name="isprint">,
2101 <ref id="ispunct" name="ispunct">,
2102 <ref id="isspace" name="isspace">,
2103 <ref id="isupper" name="isupper">,
2104 <ref id="isxdigit" name="isxdigit">
2110 <sect1>isdigit<label id="isdigit"><p>
2114 <tag/Function/Check if a given character is a digit.
2115 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2116 <tag/Declaration/<tt/int __fastcall__ isdigit (int c);/
2117 <tag/Description/The function returns a value of zero if the given argument
2118 is a digit. The return value is non zero if the character is anything else.
2119 <tag/Limits/<itemize>
2120 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2121 inline sequence generated by the macro will not work correctly for values
2122 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2123 this range. The non inline function may be accessed by <tt/#undef/'ing the
2125 <item>When compiling without <tt/-Os/, the function is only available as
2126 fastcall function, so it may only be used in presence of a prototype.
2128 <tag/Availability/ISO 9899
2130 <ref id="isalnum" name="isalnum">,
2131 <ref id="isalpha" name="isalpha">,
2132 <ref id="isascii" name="isascii">,
2133 <ref id="isblank" name="isblank">,
2134 <ref id="iscntrl" name="iscntrl">,
2135 <ref id="isgraph" name="isgraph">,
2136 <ref id="islower" name="islower">,
2137 <ref id="isprint" name="isprint">,
2138 <ref id="ispunct" name="ispunct">,
2139 <ref id="isspace" name="isspace">,
2140 <ref id="isupper" name="isupper">,
2141 <ref id="isxdigit" name="isxdigit">
2147 <sect1>isgraph<label id="isgraph"><p>
2151 <tag/Function/Check if a given character is a printable character (except
2153 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2154 <tag/Declaration/<tt/int __fastcall__ isgraph (int c);/
2155 <tag/Description/The function returns a value of zero if the given argument
2156 is a printable character with the exception of space. The return value is non
2157 zero if the character is anything else.
2158 <tag/Limits/<itemize>
2159 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2160 inline sequence generated by the macro will not work correctly for values
2161 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2162 this range. The non inline function may be accessed by <tt/#undef/'ing the
2164 <item>When compiling without <tt/-Os/, the function is only available as
2165 fastcall function, so it may only be used in presence of a prototype.
2167 <tag/Availability/ISO 9899
2169 <ref id="isalnum" name="isalnum">,
2170 <ref id="isalpha" name="isalpha">,
2171 <ref id="isascii" name="isascii">,
2172 <ref id="isblank" name="isblank">,
2173 <ref id="iscntrl" name="iscntrl">,
2174 <ref id="isdigit" name="isdigit">,
2175 <ref id="islower" name="islower">,
2176 <ref id="isprint" name="isprint">,
2177 <ref id="ispunct" name="ispunct">,
2178 <ref id="isspace" name="isspace">,
2179 <ref id="isupper" name="isupper">,
2180 <ref id="isxdigit" name="isxdigit">
2186 <sect1>islower<label id="islower"><p>
2190 <tag/Function/Check if a given character is a lower case letter.
2191 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2192 <tag/Declaration/<tt/int __fastcall__ islower (int c);/
2193 <tag/Description/The function returns a value of zero if the given argument
2194 is a lower case letter. The return value is non zero if the character is
2196 <tag/Limits/<itemize>
2197 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2198 inline sequence generated by the macro will not work correctly for values
2199 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2200 this range. The non inline function may be accessed by <tt/#undef/'ing the
2202 <item>When compiling without <tt/-Os/, the function is only available as
2203 fastcall function, so it may only be used in presence of a prototype.
2205 <tag/Availability/ISO 9899
2207 <ref id="isalnum" name="isalnum">,
2208 <ref id="isalpha" name="isalpha">,
2209 <ref id="isascii" name="isascii">,
2210 <ref id="isblank" name="isblank">,
2211 <ref id="iscntrl" name="iscntrl">,
2212 <ref id="isdigit" name="isdigit">,
2213 <ref id="isgraph" name="isgraph">,
2214 <ref id="isprint" name="isprint">,
2215 <ref id="ispunct" name="ispunct">,
2216 <ref id="isspace" name="isspace">,
2217 <ref id="isupper" name="isupper">,
2218 <ref id="isxdigit" name="isxdigit">
2224 <sect1>isprint<label id="isprint"><p>
2228 <tag/Function/Check if a given character is a printable character.
2229 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2230 <tag/Declaration/<tt/int __fastcall__ isprint (int c);/
2231 <tag/Description/The function returns a value of zero if the given argument
2232 is a printable character (this includes the space character). The return value
2233 is non zero if the character is anything else.
2234 <tag/Limits/<itemize>
2235 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2236 inline sequence generated by the macro will not work correctly for values
2237 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2238 this range. The non inline function may be accessed by <tt/#undef/'ing the
2240 <item>When compiling without <tt/-Os/, the function is only available as
2241 fastcall function, so it may only be used in presence of a prototype.
2243 <tag/Availability/ISO 9899
2245 <ref id="isalnum" name="isalnum">,
2246 <ref id="isalpha" name="isalpha">,
2247 <ref id="isascii" name="isascii">,
2248 <ref id="isblank" name="isblank">,
2249 <ref id="iscntrl" name="iscntrl">,
2250 <ref id="isdigit" name="isdigit">,
2251 <ref id="isgraph" name="isgraph">,
2252 <ref id="islower" name="islower">,
2253 <ref id="ispunct" name="ispunct">,
2254 <ref id="isspace" name="isspace">,
2255 <ref id="isupper" name="isupper">,
2256 <ref id="isxdigit" name="isxdigit">
2262 <sect1>ispunct<label id="ispunct"><p>
2266 <tag/Function/Check if a given character is a printable character but not a
2267 space or an alphanumeric character.
2268 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2269 <tag/Declaration/<tt/int __fastcall__ ispunct (int c);/
2270 <tag/Description/The function returns a value of zero if the given argument
2271 is a printable character, but not a space or anything alphanumeric. The return
2272 value is non zero if the character is anything else.
2273 <tag/Limits/<itemize>
2274 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2275 inline sequence generated by the macro will not work correctly for values
2276 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2277 this range. The non inline function may be accessed by <tt/#undef/'ing the
2279 <item>When compiling without <tt/-Os/, the function is only available as
2280 fastcall function, so it may only be used in presence of a prototype.
2282 <tag/Availability/ISO 9899
2284 <ref id="isalnum" name="isalnum">,
2285 <ref id="isalpha" name="isalpha">,
2286 <ref id="isascii" name="isascii">,
2287 <ref id="isblank" name="isblank">,
2288 <ref id="iscntrl" name="iscntrl">,
2289 <ref id="isdigit" name="isdigit">,
2290 <ref id="isgraph" name="isgraph">,
2291 <ref id="islower" name="islower">,
2292 <ref id="isprint" name="isprint">,
2293 <ref id="isspace" name="isspace">,
2294 <ref id="isupper" name="isupper">,
2295 <ref id="isxdigit" name="isxdigit">
2301 <sect1>isspace<label id="isspace"><p>
2305 <tag/Function/Check if a given character is a a white-space character.
2306 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2307 <tag/Declaration/<tt/int __fastcall__ isspace (int c);/
2308 <tag/Description/The function returns a value of zero if the given argument
2309 is a white space character. The return value is non zero if the character is
2310 anything else. The standard white space characters are: space, formfeed ('\f'),
2311 newline ('\n'), carriage return ('\r'), horizontal tab ('\t'), and vertical tab
2313 <tag/Limits/<itemize>
2314 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2315 inline sequence generated by the macro will not work correctly for values
2316 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2317 this range. The non inline function may be accessed by <tt/#undef/'ing the
2319 <item>When compiling without <tt/-Os/, the function is only available as
2320 fastcall function, so it may only be used in presence of a prototype.
2322 <tag/Availability/ISO 9899
2324 <ref id="isalnum" name="isalnum">,
2325 <ref id="isalpha" name="isalpha">,
2326 <ref id="isascii" name="isascii">,
2327 <ref id="isblank" name="isblank">,
2328 <ref id="iscntrl" name="iscntrl">,
2329 <ref id="isdigit" name="isdigit">,
2330 <ref id="isgraph" name="isgraph">,
2331 <ref id="islower" name="islower">,
2332 <ref id="isprint" name="isprint">,
2333 <ref id="ispunct" name="ispunct">,
2334 <ref id="isupper" name="isupper">,
2335 <ref id="isxdigit" name="isxdigit">
2341 <sect1>isupper<label id="isupper"><p>
2345 <tag/Function/Check if a given character is an upper case letter.
2346 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2347 <tag/Declaration/<tt/int __fastcall__ isupper (int c);/
2348 <tag/Description/The function returns a value of zero if the given argument
2349 is an upper case letter. The return value is non zero if the character is
2351 <tag/Limits/<itemize>
2352 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2353 inline sequence generated by the macro will not work correctly for values
2354 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2355 this range. The non inline function may be accessed by <tt/#undef/'ing the
2357 <item>When compiling without <tt/-Os/, the function is only available as
2358 fastcall function, so it may only be used in presence of a prototype.
2360 <tag/Availability/ISO 9899
2362 <ref id="isalnum" name="isalnum">,
2363 <ref id="isalpha" name="isalpha">,
2364 <ref id="isascii" name="isascii">,
2365 <ref id="isblank" name="isblank">,
2366 <ref id="iscntrl" name="iscntrl">,
2367 <ref id="isdigit" name="isdigit">,
2368 <ref id="isgraph" name="isgraph">,
2369 <ref id="islower" name="islower">,
2370 <ref id="isprint" name="isprint">,
2371 <ref id="ispunct" name="ispunct">,
2372 <ref id="isspace" name="isspace">,
2373 <ref id="isxdigit" name="isxdigit">
2379 <sect1>isxdigit<label id="isxdigit"><p>
2383 <tag/Function/Check if a given character is a hexadecimal digit.
2384 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2385 <tag/Declaration/<tt/int __fastcall__ isxdigit (int c);/
2386 <tag/Description/The function returns a value of zero if the given argument
2387 is a hexadecimal digit (0..9, a..f and A..F). The return value is non zero
2388 if the character is anything else.
2389 <tag/Limits/<itemize>
2390 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2391 inline sequence generated by the macro will not work correctly for values
2392 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2393 this range. The non inline function may be accessed by <tt/#undef/'ing the
2395 <item>When compiling without <tt/-Os/, the function is only available as
2396 fastcall function, so it may only be used in presence of a prototype.
2398 <tag/Availability/ISO 9899
2400 <ref id="isalnum" name="isalnum">,
2401 <ref id="isalpha" name="isalpha">,
2402 <ref id="isascii" name="isascii">,
2403 <ref id="isblank" name="isblank">,
2404 <ref id="iscntrl" name="iscntrl">,
2405 <ref id="isdigit" name="isdigit">,
2406 <ref id="isgraph" name="isgraph">,
2407 <ref id="islower" name="islower">,
2408 <ref id="isprint" name="isprint">,
2409 <ref id="ispunct" name="ispunct">,
2410 <ref id="isspace" name="isspace">,
2411 <ref id="isupper" name="isupper">
2417 <sect1>itoa<label id="itoa"><p>
2421 <tag/Function/Convert an integer into a string.
2422 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
2423 <tag/Declaration/<tt/char* __fastcall__ itoa (int val, char* buf, int radix);/
2424 <tag/Description/<tt/itoa/ converts the integer <tt/val/ into a string using
2425 <tt/radix/ as the base.
2426 <tag/Limits/<itemize>
2427 <item>There are no provisions to prevent a buffer overflow.
2428 <item>If <tt/val/ contains <tt/INT_MIN/, the behaviour is undefined.
2429 <item>The function is non standard, so it is not available in strict ANSI mode.
2430 You should probably use <tt/sprintf/ instead.
2431 <item>The function is only available as fastcall function, so it may only be
2432 used in presence of a prototype.
2434 <tag/Availability/cc65
2436 <ref id="atoi" name="atoi">,
2437 <ref id="atol" name="atol">,
2438 <ref id="ltoa" name="ltoa">,
2439 <ref id="ultoa" name="ultoa">,
2440 <ref id="utoa" name="utoa">
2446 <sect1>kbhit<label id="kbhit"><p>
2450 <tag/Function/Check if there's a key waiting in the keyboard buffer.
2451 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2452 <tag/Declaration/<tt/unsigned char kbhit (void);/
2453 <tag/Description/The function returns a value of zero if there is no character
2454 waiting to be read from the keyboard. It returns non zero otherwise.
2455 <tag/Limits/<itemize>
2456 <item>If the system does not support a keyboard buffer (most systems
2457 do), the function is rather useless.
2459 <tag/Availability/cc65
2461 <ref id="cgetc" name="cgetc">,
2462 <ref id="cursor" name="cursor">
2468 <sect1>labs<label id="labs"><p>
2472 <tag/Function/Returns the absolute value of a long integer.
2473 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
2474 <tag/Declaration/<tt/long __fastcall__ labs (long v);/
2475 <tag/Description/<tt/labs/ returns the absolute value of the argument passed to
2477 <tag/Limits/<itemize>
2478 <item>The return value is undefined if <tt/LONG_MIN/ is passed to the function.
2479 <item>The function is only available as fastcall function, so it may only be
2480 used in presence of a prototype.
2482 <tag/Availability/ISO 9899
2484 <ref id="abs" name="abs">
2490 <sect1>ltoa<label id="ltoa"><p>
2494 <tag/Function/Convert a long integer into a string.
2495 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
2496 <tag/Declaration/<tt/char* __fastcall__ ltoa (long val, char* buf, int radix);/
2497 <tag/Description/<tt/itoa/ converts the long integer <tt/val/ into a string
2498 using <tt/radix/ as the base.
2499 <tag/Limits/<itemize>
2500 <item>There are no provisions to prevent a buffer overflow.
2501 <item>If <tt/val/ contains <tt/LONG_MIN/, the behaviour is undefined.
2502 <item>The function is non standard, so it is not available in strict ANSI mode.
2503 You should probably use <tt/sprintf/ instead.
2504 <item>The function is only available as fastcall function, so it may only be
2505 used in presence of a prototype.
2507 <tag/Availability/cc65
2509 <ref id="atoi" name="atoi">,
2510 <ref id="atol" name="atol">,
2511 <ref id="itoa" name="itoa">,
2512 <ref id="ultoa" name="ultoa">,
2513 <ref id="utoa" name="utoa">
2519 <sect1>localeconv<label id="localeconv"><p>
2523 <tag/Function/Returns a pointer to the current locale structure.
2524 <tag/Header/<tt/<ref id="locale.h" name="locale.h">/
2525 <tag/Declaration/<tt/struct lconv* localeconv (void);/
2526 <tag/Description/<tt/localeconv/ returns a pointer to the current locale
2528 <tag/Limits/<itemize>
2529 <item>cc65 supports only the "C" locale, so even after setting a new locale
2530 using <tt/<ref id="setlocale" name="setlocale">/, the structure returned will
2533 <tag/Availability/ISO 9899
2535 <ref id="setlocale" name="setlocale">
2541 <sect1>malloc<label id="malloc"><p>
2545 <tag/Function/Allocate dynamic memory.
2546 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
2547 <tag/Declaration/<tt/void* __fastcall__ malloc (size_t size);/
2548 <tag/Description/<tt/malloc/ allocates size bytes on the heap and returns a
2549 pointer to the allocated memory block. On error (not enough memory available),
2550 <tt/malloc/ returns <tt/NULL/.
2553 <item>The function is only available as fastcall function, so it may only
2554 be used in presence of a prototype.
2556 <tag/Availability/ISO 9899
2558 <ref id="_heapadd" name="_heapadd">,
2559 <ref id="_heapmaxavail" name="_heapmaxavail">,
2560 <ref id="_heapmemavail" name="_heapmemavail">,
2561 <ref id="calloc" name="calloc">,
2562 <ref id="free" name="free">,
2563 <ref id="realloc" name="realloc">,
2564 <ref id="strdup" name="strdup">
2570 <sect1>memchr<label id="memchr"><p>
2574 <tag/Function/Search for a character in a block of raw memory.
2575 <tag/Header/<tt/<ref id="string.h" name="string.h">/
2576 <tag/Declaration/<tt/void* __fastcall__ strchr (const void* mem, int c, size_t count);/
2577 <tag/Description/The <tt/memchr/ function locates the first occurrence of <tt/c/
2578 (converted to a char) in the block of raw memory string pointed to by <tt/mem/
2579 that is of size <tt/count/. Upon completion, the function returns a pointer to
2580 the character found, or a null pointer if the character was not found.
2581 <tag/Limits/<itemize>
2582 <item>The function is only available as fastcall function, so it may only
2583 be used in presence of a prototype.
2585 <tag/Availability/ISO 9899
2587 <ref id="strchr" name="strchr">
2593 <sect1>memcpy<label id="memcpy"><p>
2597 <tag/Function/Copy a memory area.
2598 <tag/Header/<tt/<ref id="string.h" name="string.h">/
2599 <tag/Declaration/<tt/void* __fastcall__ memcpy (void* dest, const void* src, size_t count);/
2600 <tag/Description/<tt/memcpy/ copies <tt/count/ bytes from the memory area
2601 pointed to by <tt/src/ into the memory area pointed to by <tt/dest/. It returns
2605 <item>The result is undefined if the memory areas do overlap. Use
2606 <tt/<ref id="memmove" name="memmove">/ to copy overlapping memory areas.
2607 <item>The function is only available as fastcall function, so it may only
2608 be used in presence of a prototype.
2610 <tag/Availability/ISO 9899
2612 <ref id="_swap" name="_swap">,
2613 <ref id="memmove" name="memmove">,
2614 <ref id="memset" name="memset">
2620 <sect1>memmove<label id="memmove"><p>
2624 <tag/Function/Copy a memory area.
2625 <tag/Header/<tt/<ref id="string.h" name="string.h">/
2626 <tag/Declaration/<tt/void* __fastcall__ memmove (void* dest, const void* src, size_t count);/
2627 <tag/Description/<tt/memmove/ copies <tt/count/ bytes from the memory area
2628 pointed to by <tt/src/ into the memory area pointed to by <tt/dest/. It returns
2632 <item>While <tt/memmove/ allows the memory areas to overlap, it has some
2633 additional overhead compared to <tt/<ref id="memcpy" name="memcpy">/.
2634 <item>The function is only available as fastcall function, so it may only
2635 be used in presence of a prototype.
2637 <tag/Availability/ISO 9899
2639 <ref id="_swap" name="_swap">,
2640 <ref id="memcpy" name="memcpy">,
2641 <ref id="memset" name="memset">
2647 <sect1>memset<label id="memset"><p>
2651 <tag/Function/Fill a memory area.
2652 <tag/Header/<tt/<ref id="string.h" name="string.h">/
2653 <tag/Declaration/<tt/void* __fastcall__ memset (void* p, int val, size_t count);/
2654 <tag/Description/<tt/memset/ fills the memory area pointed to by <tt/p/ with
2655 the value <tt/val/. The function returns <tt/p/.
2658 <item>The function is only available as fastcall function, so it may only
2659 be used in presence of a prototype.
2661 <tag/Availability/ISO 9899
2663 <ref id="_swap" name="_swap">,
2664 <ref id="bzero" name="bzero">,
2665 <ref id="memcpy" name="memcpy">,
2666 <ref id="memmove" name="memmove">
2672 <sect1>offsetof<label id="offsetof"><p>
2676 <tag/Function/Calculate the offset of a struct or union member.
2677 <tag/Header/<tt/<ref id="stddef.h" name="stddef.h">/
2678 <tag/Declaration/<tt/size_t offsetof (type, member);/
2679 <tag/Description/<tt/offsetof/ calculates the address offset of a <tt/struct/
2680 or <tt/union/ member.
2681 <tag/Limits/<itemize>
2682 <item>The function is actually a macro.
2684 <tag/Availability/ISO 9899
2690 <sect1>open<label id="open"><p>
2694 <tag/Function/Open and possibly create a file.
2695 <tag/Header/<tt/<ref id="fcntl.h" name="fcntl.h">/
2696 <tag/Declaration/<tt/int open (const char* name, int flags, ...);/
2697 <tag/Description/<tt/open/ opens a file and returns the file descriptor
2698 associated with it. On error, -1 is returned and an error code is stored in
2699 <tt/errno/. Several flags may be passed to <tt/open/ that change the behaviour.
2700 <tag/Limits/<itemize>
2701 <item>POSIX specifies an additional <tt/mode/ argument that may be passed to
2702 open, which is used as the permission mask when a new file is created. While
2703 cc65 allows to pass this argument, it is ignored.
2705 <tag/Availability/POSIX
2707 <ref id="close" name="close">,
2708 <ref id="creat" name="creat">
2714 <sect1>perror<label id="perror"><p>
2718 <tag/Function/Print an error message for the error in <tt/errno/.
2719 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
2720 <tag/Declaration/<tt/void __fastcall__ perror (const char* s);/
2721 <tag/Description/<tt/perror/ prints an error message to <tt/stderr/. If <tt/s/
2722 is not <tt/NULL/ and not an empty string, it is printed followed by a colon and
2723 a blank. Then the error message for the current contents of <tt/errno/ is
2724 printed followed by a newline. The message output is the same as returned by
2725 <tt/<ref id="strerror" name="strerror">/ with an argument of <tt/errno/.
2728 <item>The function is only available as fastcall function, so it may only
2729 be used in presence of a prototype.
2731 <tag/Availability/ISO 9899
2733 <ref id="_poserror" name="_poserror">,
2734 <ref id="strerror" name="strerror">,
2740 <sect1>qsort<label id="qsort"><p>
2744 <tag/Function/Sort an array.
2745 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
2746 <tag/Declaration/<tt/void __fastcall__ qsort (void* base, size_t count,
2747 size_t size, int (*compare) (const void*, const void*));/
2748 <tag/Description/<tt/qsort/ sorts an array according to a given compare
2749 function <tt/compare/. <tt/base/ is the address of the array, <tt/count/
2750 is the number of elements, <tt/size/ the size of an element and <tt/compare/
2751 the function used to compare the members.
2754 <item>If there are multiple members with the same key, the order after calling
2755 the function is undefined.
2756 <item>The function is only available as fastcall function, so it may only
2757 be used in presence of a prototype.
2759 <tag/Availability/ISO 9899
2761 <ref id="bsearch" name="bsearch">
2767 <sect1>raise<label id="raise"><p>
2771 <tag/Function/Send a signal to the executing program.
2772 <tag/Header/<tt/<ref id="signal.h" name="signal.h">/
2773 <tag/Declaration/<tt/int __fastcall__ raise (int sig);/
2774 <tag/Description/<tt/raise/ sends the given signal to the program. If the
2775 program has installed a signal handler for the signal, this signal handler
2776 will be executed. If no handler has been installed, the default action for
2777 the raised signal will be taken. The function returns zero on success,
2779 <tag/Limits/<itemize>
2780 <item>The function is only available as fastcall function, so it may only
2781 be used in presence of a prototype.
2783 <tag/Availability/ISO 9899
2785 <ref id="abort" name="abort">,
2786 <ref id="signal" name="signal">
2792 <sect1>rand<label id="rand"><p>
2796 <tag/Function/Return a pseudo random number.
2797 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
2798 <tag/Declaration/<tt/int rand (void);/
2799 <tag/Description/The function returns a pseudo random number
2800 between 0 and <tt/RAND_MAX/ (exclusive).
2801 <tag/Limits/<itemize>
2802 <item>Without using <tt><ref id="srand" name="srand"></tt>, always the same
2803 flow of numbers is generated.
2804 <item>On startup, the function behaves as if <ref id="srand" name="srand">
2805 had been used with an argument of 1.
2807 <tag/Availability/ISO 9899
2809 <ref id="_randomize" name="_randomize">,
2810 <ref id="srand" name="srand">
2816 <sect1>realloc<label id="realloc"><p>
2820 <tag/Function/Change the size of an allocated memory block.
2821 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
2822 <tag/Declaration/<tt/void* __fastcall__ realloc (void* block, size_t size);/
2823 <tag/Description/<tt/realloc/ changes the size of the memory block pointed to
2824 by <tt/block/ to <tt/size/ bytes. If <tt/block/ is <tt/NULL/, <tt/realloc/
2825 behaves as if <tt/malloc/ had been called. If <tt/size/ is zero, <tt/realloc/
2826 behaves as if <tt/free/ had been called. On error (not enough memory
2827 available), <tt/realloc/ returns <tt/NULL/.
2830 <item>The part of the memory block that is returned will have its contents
2832 <item>This function is somewhat dangerous to use. Be careful to save the
2833 pointer you're passing somewhere else, otherwise
2835 ptr = realloc (ptr, size);
2837 will loose your only copy of <tt/ptr/ if <tt/realloc/ returns <tt/NULL/.
2838 <item>The function is only available as fastcall function, so it may only
2839 be used in presence of a prototype.
2841 <tag/Availability/ISO 9899
2843 <ref id="_heapadd" name="_heapadd">,
2844 <ref id="_heapmaxavail" name="_heapmaxavail">,
2845 <ref id="_heapmemavail" name="_heapmemavail">,
2846 <ref id="calloc" name="calloc">,
2847 <ref id="free" name="free">,
2848 <ref id="realloc" name="realloc">
2854 <sect1>remove<label id="remove"><p>
2858 <tag/Function/Delete a file.
2859 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
2860 <tag/Declaration/<tt/int __fastcall__ remove (const char* name);/
2861 <tag/Description/<tt/remove/ deletes the file with the given name. On success,
2862 zero is returned. On error, -1 is returned and <tt/errno/ is set to an error
2863 code describing the reason for the failure.
2866 <item>This function is not available on all cc65 targets (depends on the
2867 availability of file I/O).
2868 <item>The function is only available as fastcall function, so it may only
2869 be used in presence of a prototype.
2871 <tag/Availability/ISO 9899
2873 <ref id="unlink" name="unlink">
2875 #include <stdio.h>
2877 #define FILENAME "helloworld"
2879 if (remove (FILENAME) == 0) {
2880 printf ("We deleted %s successfully\n", FILENAME);
2882 printf ("There was a problem deleting %s\n", FILENAME);
2888 <sect1>reset_brk<label id="reset_brk"><p>
2892 <tag/Function/Resets the break vector to its original value.
2893 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
2894 <tag/Declaration/<tt/void __fastcall__ reset_brk (void);/
2895 <tag/Description/<tt/reset_brk/ resets the break vector to the value it had
2896 before a call to <tt/set_brk/.
2899 <item>Since <tt/<ref id="set_brk" name="set_brk">/ installs an exit handler,
2900 it is not strictly necessary to call this function as part of the cleanup when
2903 <tag/Availability/cc65
2905 <ref id="set_brk" name="set_brk">
2911 <sect1>revers<label id="revers"><p>
2915 <tag/Function/Control revers character display.
2916 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2917 <tag/Declaration/<tt/unsigned char __fastcall__ revers (unsigned char onoff);/
2918 <tag/Description/If the argument is non zero, the function enables reverse
2919 character display. If the argument is zero, reverse character display is
2920 switched off. The old value of the setting is returned.
2921 <tag/Limits/<itemize>
2922 <item>The function may not be supported by the hardware, in which case
2923 the call is ignored.
2924 <item>The function is only available as fastcall function, so it may only
2925 be used in presence of a prototype.
2927 <tag/Availability/cc65
2929 <ref id="textcolor" name="textcolor">
2935 <sect1>screensize<label id="screensize"><p>
2939 <tag/Function/Return the dimensions of the text mode screen.
2940 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2941 <tag/Declaration/<tt/void __fastcall__ screensize (unsigned char* x, unsigned char* y);/
2942 <tag/Description/The function returns the dimensions of the text mode screen.
2943 <tag/Limits/<itemize>
2944 <item>The function is only available as fastcall function, so it may only
2945 be used in presence of a prototype.
2947 <tag/Availability/cc65
2949 <ref id="gotox" name="gotox">,
2950 <ref id="gotoxy" name="gotoxy">,
2951 <ref id="gotoy" name="gotoy">,
2952 <ref id="wherex" name="wherex">,
2953 <ref id="wherey" name="wherey">
2959 <sect1>set_brk<label id="set_brk"><p>
2963 <tag/Function/Set the break vector to a user function.
2964 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
2965 <tag/Declaration/<tt/void __fastcall__ set_brk (brk_handler func);/
2966 <tag/Description/<tt/set_brk/ allows a user program to handle breaks within the
2967 program code by letting the vector point to a user written C function. The
2968 runtime library installs a small stub that saves the registers into global
2969 variables that may be accessed (and changed) by the break handler.
2972 <item>The function is only available as fastcall function, so it may only
2973 be used in presence of a prototype.
2974 <item>The stub saves the zero page registers used by the C runtime and switches
2975 to a small break handler stack. This means that it is safe to execute C code,
2976 even if C code was interrupted. Be careful however not to use too many local
2977 variables, and do not enable stack checks for the handler function or any other
2978 function called from it.
2979 <item>The <tt/brk_pc/ variable points to the <tt/BRK/ instruction. If you want
2980 the continue with the interrupted code, you have to adjust <tt/brk_pc/,
2981 otherwise the <tt/BRK/ instruction will get executed over and over again.
2982 <item>Since <tt/set_brk/ installs an exit handler, it is not strictly necessary
2983 to call <tt/<ref id="reset_brk" name="reset_brk">/ as part of the cleanup when
2984 the program terminates.
2986 <tag/Availability/cc65
2988 <ref id="reset_brk" name="reset_brk">
2994 <sect1>setlocale<label id="setlocale"><p>
2998 <tag/Function/Selects a locale.
2999 <tag/Header/<tt/<ref id="locale.h" name="locale.h">/
3000 <tag/Declaration/<tt/char* __fastcall__ setlocale (int category, const char* locale);/
3001 <tag/Description/<tt/setlocale/ sets or queries the program's locale.
3004 <item>The function is only available as fastcall function, so it may only
3005 be used in presence of a prototype.
3006 <item>cc65 supports only the "C" locale, so calling this function to set a
3007 different locale has no effect.
3009 <tag/Availability/ISO 9899
3011 <ref id="localeconv" name="localeconv">,
3012 <ref id="strcoll" name="strcoll">
3018 <sect1>signal<label id="signal"><p>
3022 <tag/Function/Install a signal handler.
3023 <tag/Header/<tt/<ref id="signal.h" name="signal.h">/
3024 <tag/Declaration/<tt/__sigfunc __fastcall__ signal (int sig, __sigfunc func);/
3025 <tag/Description/<tt/signal/ installs a handler for the given signal. The
3026 handler may either be a user supplied function, or one of the predefined
3027 signal handlers <tt/SIG_IGN/ or <tt/SIG_DFL/. The function returns the
3028 previous value if the signal , or the special function vector SIG_ERR in
3030 <tag/Limits/<itemize>
3031 <item>The function is only available as fastcall function, so it may only
3032 be used in presence of a prototype.
3034 <tag/Availability/ISO 9899
3036 <ref id="abort" name="abort">,
3037 <ref id="raise" name="raise">
3043 <sect1>sleep<label id="sleep"><p>
3047 <tag/Function/Sleep for a specified amount of time.
3048 <tag/Header/<tt/<ref id="unistd.h" name="unistd.h">/
3049 <tag/Declaration/<tt/void __fastcall__ sleep (unsigned seconds);/
3050 <tag/Description/The function will return after the specified number of
3051 seconds have elapsed.
3052 <tag/Limits/<itemize>
3053 <item>The function is only available as fastcall function, so it may only
3054 be used in presence of a prototype.
3056 <tag/Availability/POSIX
3062 <sect1>slow<label id="slow"><p>
3066 <tag/Function/Switch the C128 into 1MHz mode.
3067 <tag/Header/<tt/<ref id="c128.h" name="c128.h">/
3068 <tag/Declaration/<tt/void slow (void);/
3069 <tag/Description/The function will switch the clock of the C128 to 1MHz. This
3070 will halve the speed compared to fast mode.
3071 <tag/Limits/<itemize>
3072 <item>The function is specific to the C128.
3074 <tag/Availability/C128
3076 <ref id="fast" name="fast">,
3077 <ref id="toggle_videomode" name="toggle_videomode">
3083 <sect1>srand<label id="srand"><p>
3087 <tag/Function/Initialize the pseudo random number generator.
3088 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
3089 <tag/Declaration/<tt/void __fastcall__ srand (unsigned seed);/
3090 <tag/Description/The function initializes the random number generator using
3091 the given seed. On program startup, the generator behaves as if <tt/srand/ has
3092 been called with an argument of 1.
3093 <tag/Limits/<itemize>
3094 <item>The function is only available as fastcall function, so it may only
3095 be used in presence of a prototype.
3097 <tag/Availability/ISO 9899
3099 <ref id="_randomize" name="_randomize">,
3100 <ref id="rand" name="rand">
3106 <sect1>strcasecmp<label id="strcasecmp"><p>
3110 <tag/Function/Compare two strings case insensitive.
3111 <tag/Header/<tt/<ref id="string.h" name="string.h">/
3112 <tag/Declaration/<tt/int __fastcall__ strcasecmp (const char* s1, const char* s2);/
3113 <tag/Description/The <tt/strcasecmp/ function compares the two strings passed
3114 as parameters without case sensitivity. It returns a value that is less than
3115 zero if <tt/s1/ is less than <tt/s2/, zero if <tt/s1/ is the same as <tt/s2/,
3116 and a value greater than zero if <tt/s1/ is greater than <tt/s2/.
3117 <tag/Limits/<itemize>
3118 <item>The function is only available as fastcall function, so it may only
3119 be used in presence of a prototype.
3120 <item>The function is not available in strict ANSI mode.
3122 <tag/Availability/cc65
3124 <ref id="strcmp" name="strcmp">,
3125 <ref id="strcoll" name="strcoll">,
3126 <ref id="stricmp" name="stricmp">
3132 <sect1>strcat<label id="strcat"><p>
3136 <tag/Function/Concatentate two strings.
3137 <tag/Header/<tt/<ref id="string.h" name="string.h">/
3138 <tag/Declaration/<tt/char* __fastcall__ strcat (char* s1, const char* s2);/
3139 <tag/Description/The <tt/strcat/ function appends a copy of the string
3140 pointed to by s2 (including the terminating null byte) to the end of the
3141 string pointed to by s1. The initial byte of s2 overwrites the null byte at
3143 <tag/Limits/<itemize>
3144 <item>The function is only available as fastcall function, so it may only
3145 be used in presence of a prototype.
3146 <item>If copying takes place between objects that overlap, the behavior
3149 <tag/Availability/ISO 9899
3151 <ref id="strcpy" name="strcpy">
3152 <ref id="strncpy" name="strncpy">
3158 <sect1>strchr<label id="strchr"><p>
3162 <tag/Function/Search for a character in a string.
3163 <tag/Header/<tt/<ref id="string.h" name="string.h">/
3164 <tag/Declaration/<tt/char* __fastcall__ strchr (const char* s, int c);/
3165 <tag/Description/The <tt/strchr/ function locates the first occurrence of <tt/c/
3166 (converted to a char) in the string pointed to by <tt/s/. The terminating null
3167 byte is considered to be part of the string. Upon completion, the function
3168 returns a pointer to the byte, or a null pointer if the byte was not found.
3169 <tag/Limits/<itemize>
3170 <item>The function is only available as fastcall function, so it may only
3171 be used in presence of a prototype.
3173 <tag/Availability/ISO 9899
3175 <ref id="memchr" name="memchr">,
3176 <ref id="strrchr" name="strrchr">
3182 <sect1>strcmp<label id="strcmp"><p>
3186 <tag/Function/Compare two strings.
3187 <tag/Header/<tt/<ref id="string.h" name="string.h">/
3188 <tag/Declaration/<tt/int __fastcall__ strcmp (const char* s1, const char* s2);/
3189 <tag/Description/The <tt/strcmp/ function compares the two strings passed as
3190 parameters. It returns a value that is less than zero if <tt/s1/ is less than
3191 <tt/s2/, zero if <tt/s1/ is the same as <tt/s2/, and a value greater than zero
3192 if <tt/s1/ is greater than <tt/s2/.
3193 <tag/Limits/<itemize>
3194 <item>The function is only available as fastcall function, so it may only
3195 be used in presence of a prototype.
3197 <tag/Availability/ISO 9899
3199 <ref id="strcasecmp" name="strcasecmp">,
3200 <ref id="strcoll" name="strcoll">,
3201 <ref id="stricmp" name="stricmp">
3207 <sect1>strcoll<label id="strcoll"><p>
3211 <tag/Function/Compare two strings.
3212 <tag/Header/<tt/<ref id="string.h" name="string.h">/
3213 <tag/Declaration/<tt/int __fastcall__ strcoll (const char* s1, const char* s2);/
3214 <tag/Description/The <tt/strcoll/ function compares the two strings passed as
3215 parameters, according to the collating sequence set by <tt/<ref id="setlocale"
3216 name="setlocale">/. It returns a value that is less than zero if <tt/s1/ is
3217 less than <tt/s2/, zero if <tt/s1/ is the same as <tt/s2/, and a value greater
3218 than zero if <tt/s1/ is greater than <tt/s2/.
3219 <tag/Limits/<itemize>
3220 <item>The function is only available as fastcall function, so it may only
3221 be used in presence of a prototype.
3223 <tag/Availability/ISO 9899
3225 <ref id="setlocale" name="setlocale">,
3226 <ref id="strcasecmp" name="strcasecmp">,
3227 <ref id="strcmp" name="strcmp">,
3228 <ref id="stricmp" name="stricmp">
3234 <sect1>strcpy<label id="strcpy"><p>
3238 <tag/Function/Copy a string.
3239 <tag/Header/<tt/<ref id="string.h" name="string.h">/
3240 <tag/Declaration/<tt/char* __fastcall__ strcpy (char* s1, const char* s2);/
3241 <tag/Description/The <tt/strcpy/ function copies the string pointed to by
3242 <tt/s2/ (including the terminating null byte) into the array pointed to by
3243 <tt/s1/. The function will always return <tt/s1/.
3244 <tag/Limits/<itemize>
3245 <item>The function is only available as fastcall function, so it may only
3246 be used in presence of a prototype.
3247 <item>If copying takes place between objects that overlap, the behavior
3250 <tag/Availability/ISO 9899
3252 <ref id="strcat" name="strcat">,
3253 <ref id="strncpy" name="strncpy">
3256 #include <string.h>
3258 static char hello[14];
3260 strcpy (hello, "Hello world!\n");
3266 <sect1>strcspn<label id="strcspn"><p>
3270 <tag/Function/Compute the length of a substring.
3271 <tag/Header/<tt/<ref id="string.h" name="string.h">/
3272 <tag/Declaration/<tt/size_t __fastcall__ strcspn (const char* s, const char* set);/
3273 <tag/Description/The <tt/strcspn/ function computes and returns the length of
3274 the substring pointed to by <tt/s/ which does <em>not</em> consist of
3275 characters contained in the string <tt/set/.
3276 <tag/Limits/<itemize>
3277 <item>The function is only available as fastcall function, so it may only
3278 be used in presence of a prototype.
3280 <tag/Availability/ISO 9899
3282 <ref id="strspn" name="strspn">,
3283 <ref id="strstr" name="strstr">
3289 <sect1>strdup<label id="strdup"><p>
3293 <tag/Function/Allocate a copy of a string on the heap.
3294 <tag/Header/<tt/<ref id="string.h" name="string.h">/
3295 <tag/Declaration/<tt/char* __fastcall__ strdup (const char* s);/
3296 <tag/Description/<tt/strdup/ allocates a memory block on the heap, big enough
3297 to hold a copy of <tt/s/ including the terminating zero. If the allocation
3298 fails, <tt/NULL/ is returned, otherwise <tt/s/ is copied into the allocated
3299 memory block, and a pointer to the block is returned.
3300 <tag/Limits/<itemize>
3301 <item>The function is only available as fastcall function, so it may only
3302 be used in presence of a prototype.
3303 <item>It is up to the caller to free the allocated memory block.
3305 <tag/Availability/ISO 9899
3307 <ref id="free" name="free">,
3308 <ref id="malloc" name="malloc">
3314 <sect1>strerror<label id="strerror"><p>
3318 <tag/Function/Return a string describing an error code.
3319 <tag/Header/<tt/<ref id="string.h" name="string.h">/
3320 <tag/Declaration/<tt/char* __fastcall__ strerror (int errcode);/
3321 <tag/Description/The <tt/strerror/ function returns a string describing the
3322 given error code. If an invalid error code is passed, the string "Unknown
3323 error" is returned, and <tt/errno/ is set to <tt/EINVAL/. In all other cases,
3324 <tt/errno/ is left untouched.
3325 <tag/Limits/<itemize>
3326 <item>The function is only available as fastcall function, so it may only
3327 be used in presence of a prototype.
3328 <item>While the return type of the function is a <tt/char*/, the returned
3329 string must not be modified by the caller!
3331 <tag/Availability/ISO 9899
3333 <ref id="_stroserror" name="_stroserror">
3339 <sect1>stricmp<label id="stricmp"><p>
3343 <tag/Function/Compare two strings case insensitive.
3344 <tag/Header/<tt/<ref id="string.h" name="string.h">/
3345 <tag/Declaration/<tt/int __fastcall__ stricmp (const char* s1, const char* s2);/
3346 <tag/Description/The <tt/stricmp/ function compares the two strings passed as
3347 parameters without case sensitivity. It returns a value that is less than zero
3348 if <tt/s1/ is less than <tt/s2/, zero if <tt/s1/ is the same as <tt/s2/, and a
3349 value greater than zero if <tt/s1/ is greater than <tt/s2/.
3350 <tag/Limits/<itemize>
3351 <item>The function is only available as fastcall function, so it may only
3352 be used in presence of a prototype.
3353 <item>The function is not available in strict ANSI mode.
3355 <tag/Availability/cc65
3357 <ref id="strcasecmp" name="strcasecmp">,
3358 <ref id="strcmp" name="strcmp">,
3359 <ref id="strcoll" name="strcoll">
3365 <sect1>strlen<label id="strlen"><p>
3369 <tag/Function/Return the length of a string.
3370 <tag/Header/<tt/<ref id="string.h" name="string.h">/
3371 <tag/Declaration/<tt/size_t __fastcall__ strlen (const char* s);/
3372 <tag/Description/The <tt/strlen/ function computes the number of bytes in the
3373 string to which s points, not including the terminating null byte.
3374 <tag/Limits/<itemize>
3375 <item>The function is only available as fastcall function, so it may only
3376 be used in presence of a prototype.
3377 <item>When compiling with <tt/-Os/ (inline known standard functions), the
3378 function does not work correctly for strings with more than 255 characters.
3380 <tag/Availability/ISO 9899
3382 <ref id="strcpy" name="strcpy">
3388 <sect1>strlower<label id="strlower"><p>
3392 <tag/Function/Make a string lower case.
3393 <tag/Header/<tt/<ref id="string.h" name="string.h">/
3394 <tag/Declaration/<tt/char* __fastcall__ strlower (char* s);/
3395 <tag/Description/The <tt/strlower/ function will apply the <tt/tolower/
3396 function to each character of a string. The function will always return <tt/s/.
3397 <tag/Limits/<itemize>
3398 <item>The function is only available as fastcall function, so it may only
3399 be used in presence of a prototype.
3400 <item>The function prototype is unavailable when compiling in strict ANSI mode.
3401 <item>An alias name for this function is <tt/strlwr/.
3403 <tag/Availability/cc65
3405 <ref id="strupper" name="strupper">
3406 <ref id="tolower" name="tolower">
3412 <sect1>strlwr<label id="strlwr"><p>
3419 <sect1>strncpy<label id="strncpy"><p>
3423 <tag/Function/Copy part of a string.
3424 <tag/Header/<tt/<ref id="string.h" name="string.h">/
3425 <tag/Declaration/<tt/char* __fastcall__ strcpy (char* s1, const char* s2, size_t n);/
3426 <tag/Description/The <tt/strncpy/ function copies not more than n bytes from
3427 the array pointed to by <tt/s2/ to the array pointed to by <tt/s1/. If the array
3428 pointed to by <tt/s2/ is a string that is shorter than n bytes, null bytes are
3429 appended to the copy in the array pointed to by <tt/s1/, until <tt/n/ bytes are
3430 written. The function will always return <tt/s1/.
3431 <tag/Limits/<itemize>
3432 <item>The function is only available as fastcall function, so it may only
3433 be used in presence of a prototype. If there is no null byte in the first <tt/n/
3434 bytes of the array pointed to by <tt/s2/, the result is not null-terminated.
3435 <item>If copying takes place between objects that overlap, the behavior is
3438 <tag/Availability/ISO 9899
3440 <ref id="strcat" name="strcat">
3441 <ref id="strcpy" name="strcpy">
3446 static char hello[6];
3448 strcpy (hello, "Hello world!\n", sizeof (hello) - 1);
3455 <sect1>strrchr<label id="strrchr"><p>
3459 <tag/Function/Search for a character in a string.
3460 <tag/Header/<tt/<ref id="string.h" name="string.h">/
3461 <tag/Declaration/<tt/char* __fastcall__ strrchr (const char* s, int c);/
3462 <tag/Description/The <tt/strrchr/ function locates the last occurrence of <tt/c/
3463 (converted to a char) in the string pointed to by <tt/s/. The terminating null
3464 byte is considered to be part of the string. Upon completion, the function
3465 returns a pointer to the byte, or a null pointer if the byte was not found.
3466 <tag/Limits/<itemize>
3467 <item>The function is only available as fastcall function, so it may only
3468 be used in presence of a prototype.
3470 <tag/Availability/ISO 9899
3472 <ref id="strchr" name="strchr">
3478 <sect1>strspn<label id="strspn"><p>
3482 <tag/Function/Compute the length of a substring.
3483 <tag/Header/<tt/<ref id="string.h" name="string.h">/
3484 <tag/Declaration/<tt/size_t __fastcall__ strspn (const char* s, const char* set);/
3485 <tag/Description/The <tt/strspn/ function computes and returns the length of
3486 the substring pointed to by <tt/s/ which does consist only of characters
3487 contained in the string <tt/set/.
3488 <tag/Limits/<itemize>
3489 <item>The function is only available as fastcall function, so it may only
3490 be used in presence of a prototype.
3492 <tag/Availability/ISO 9899
3494 <ref id="strcspn" name="strcspn">,
3495 <ref id="strstr" name="strstr">
3501 <sect1>strstr<label id="strstr"><p>
3505 <tag/Function/Find a substring.
3506 <tag/Header/<tt/<ref id="string.h" name="string.h">/
3507 <tag/Declaration/<tt/char* __fastcall__ strstr (const char* str, const char* substr);/
3508 <tag/Description/<tt/strstr/ searches for the first occurance of the string
3509 <tt/substr/ within <tt/str/. If found, it returns a pointer to the copy,
3510 otherwise it returns <tt/NULL/.
3511 <tag/Limits/<itemize>
3512 <item>The function is only available as fastcall function, so it may only
3513 be used in presence of a prototype.
3515 <tag/Availability/ISO 9899
3517 <ref id="strcspn" name="strcspn">,
3518 <ref id="strspn" name="strspn">
3524 <sect1>strupper<label id="strupper"><p>
3528 <tag/Function/Make a string upper case.
3529 <tag/Header/<tt/<ref id="string.h" name="string.h">/
3530 <tag/Declaration/<tt/char* __fastcall__ strupper (char* s);/
3531 <tag/Description/The <tt/strupper/ function will apply the <tt/toupper/
3532 function to each character of a string. The function will always return <tt/s/.
3533 <tag/Limits/<itemize>
3534 <item>The function is only available as fastcall function, so it may only
3535 be used in presence of a prototype.
3536 <item>The function prototype is unavailable when compiling in strict ANSI mode.
3537 <item>An alias name for this function is <tt/strupr/.
3539 <tag/Availability/cc65
3541 <ref id="strlower" name="strlower">
3542 <ref id="toupper" name="toupper">
3548 <sect1>strupr<label id="strupr"><p>
3555 <sect1>textcolor<label id="textcolor"><p>
3559 <tag/Function/Set the text color.
3560 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
3561 <tag/Declaration/<tt/unsigned char __fastcall__ textcolor (unsigned char color);/
3562 <tag/Description/The function will set a new text color. It returns the old
3563 (current) text color. Text output using any <tt/conio.h/ function will use
3564 the color set by this function.
3565 <tag/Limits/<itemize>
3566 <item>Text colors are system dependent. The function may have no effect
3567 on systems where the text color cannot be changed.
3568 <item>The function is only available as fastcall function, so it may only
3569 be used in presence of a prototype.
3571 <tag/Availability/cc65
3573 <ref id="bgcolor" name="bgcolor">,
3574 <ref id="bordercolor" name="bordercolor">
3580 <sect1>toggle_videomode<label id="toggle_videomode"><p>
3584 <tag/Function/Toggle between 40 and 80 column mode.
3585 <tag/Header/<tt/<ref id="c128.h" name="c128.h">/
3586 <tag/Declaration/<tt/void toggle_videomode (void);/
3587 <tag/Description/Toggle between 40 and 80 column mode. The settings for the
3588 old mode (cursor position, color and so on) are saved and restored together
3590 <tag/Limits/<itemize>
3591 <item>The function is specific to the C128.
3593 <tag/Availability/C128
3595 <ref id="fast" name="fast">,
3596 <ref id="slow" name="slow">
3602 <sect1>tolower<label id="tolower"><p>
3606 <tag/Function/Convert a character into its lower case representation.
3607 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
3608 <tag/Declaration/<tt/int __fastcall__ tolower (int c);/
3609 <tag/Description/The function returns the given character converted to lower
3610 case. If the given character is not a letter, it is returned unchanged.
3611 <tag/Limits/<itemize>
3612 <item>The function is only available as fastcall function, so it may
3613 only be used in presence of a prototype.
3615 <tag/Availability/ISO 9899
3617 <ref id="islower" name="islower">,
3618 <ref id="isupper" name="isupper">,
3619 <ref id="toupper" name="toupper">
3625 <sect1>toupper<label id="toupper"><p>
3629 <tag/Function/Convert a character into its upper case representation.
3630 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
3631 <tag/Declaration/<tt/int __fastcall__ toupper (int c);/
3632 <tag/Description/The function returns the given character converted to upper
3633 case. If the given character is not a letter, it is returned unchanged.
3634 <tag/Limits/<itemize>
3635 <item>The function is only available as fastcall function, so it may
3636 only be used in presence of a prototype.
3638 <tag/Availability/ISO 9899
3640 <ref id="islower" name="islower">,
3641 <ref id="isupper" name="isupper">,
3642 <ref id="tolower" name="tolower">
3648 <sect1>ultoa<label id="ultoa"><p>
3652 <tag/Function/Convert an unsigned long integer into a string.
3653 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
3654 <tag/Declaration/<tt/char* __fastcall__ ultoa (unsigned long val, char* buf, int radix);/
3655 <tag/Description/<tt/itoa/ converts the unsigned long integer <tt/val/ into a
3656 string using <tt/radix/ as the base.
3657 <tag/Limits/<itemize>
3658 <item>There are no provisions to prevent a buffer overflow.
3659 <item>The function is non standard, so it is not available in strict ANSI mode.
3660 You should probably use <tt/sprintf/ instead.
3661 <item>The function is only available as fastcall function, so it may only be
3662 used in presence of a prototype.
3664 <tag/Availability/cc65
3666 <ref id="atoi" name="atoi">,
3667 <ref id="atol" name="atol">,
3668 <ref id="itoa" name="itoa">,
3669 <ref id="ltoa" name="ltoa">,
3670 <ref id="utoa" name="utoa">
3676 <sect1>unlink<label id="unlink"><p>
3680 <tag/Function/Delete a file.
3681 <tag/Header/<tt/<ref id="unistd.h" name="unistd.h">/
3682 <tag/Declaration/<tt/int __fastcall__ unlink (const char* name);/
3683 <tag/Description/<tt/unlink/ deletes the file with the given name. On success,
3684 zero is returned. On error, -1 is returned and <tt/errno/ is set to an error
3685 code describing the reason for the failure.
3688 <item>The use of this function is discouraged. Please use <tt/<ref id="remove"
3689 name="remove">/ instead, which is a native ANSI C function and does the same.
3690 <item>This function is not available on all cc65 targets (depends on the
3691 availability of file I/O).
3692 <item>The function is only available as fastcall function, so it may only
3693 be used in presence of a prototype.
3695 <tag/Availability/POSIX
3697 <ref id="remove" name="remove">
3699 #include <stdio.h>
3700 #include <unistd.h>
3702 #define FILENAME "helloworld"
3704 if (unlink (FILENAME) == 0) {
3705 printf ("We deleted %s successfully\n", FILENAME);
3707 printf ("There was a problem deleting %s\n", FILENAME);
3713 <sect1>utoa<label id="utoa"><p>
3717 <tag/Function/Convert an unsigned integer into a string.
3718 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
3719 <tag/Declaration/<tt/char* __fastcall__ utoa (unsigned val, char* buf, int radix);/
3720 <tag/Description/<tt/itoa/ converts the unsigned integer <tt/val/ into a string
3721 using <tt/radix/ as the base.
3722 <tag/Limits/<itemize>
3723 <item>There are no provisions to prevent a buffer overflow.
3724 <item>The function is non standard, so it is not available in strict ANSI mode.
3725 You should probably use <tt/sprintf/ instead.
3726 <item>The function is only available as fastcall function, so it may only be
3727 used in presence of a prototype.
3729 <tag/Availability/cc65
3731 <ref id="atoi" name="atoi">,
3732 <ref id="atol" name="atol">,
3733 <ref id="itoa" name="itoa">,
3734 <ref id="ltoa" name="ltoa">,
3735 <ref id="ultoa" name="ultoa">
3741 <sect1>vcprintf<label id="vcprintf"><p>
3745 <tag/Function/Formatted output to the console.
3746 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
3747 <tag/Declaration/<tt/int __fastcall__ vcprintf (const char* format, va_list ap);/
3748 <tag/Description/The arguments specified as a <tt/va_list/ are converted to
3749 text where necessary and formatted according to the format string given. The
3750 resulting string is output to the console. <tt/vcprintf/ supports the same
3751 format specifiers as <tt/vprintf/. <!-- <tt/<ref id="vprintf" name="vprintf">/. -->
3752 <tag/Limits/<itemize>
3753 <item>Like all other <tt/conio/ output functions, <tt/vcprintf/ distinguishes
3754 between <tt/\r/ and <tt/\n/.
3755 <item>The function is only available as fastcall function, so it may only be
3756 used in presence of a prototype.
3758 <tag/Availability/cc65
3760 <ref id="cprintf" name="cprintf">,
3761 <ref id="cputc" name="cputc">,
3762 <ref id="cputcxy" name="cputcxy">,
3763 <ref id="cputs" name="cputs">,
3764 <ref id="cputsxy" name="cputsxy">
3770 <sect1>wherex<label id="wherex"><p>
3774 <tag/Function/Return the current X position of the text mode cursor.
3775 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
3776 <tag/Declaration/<tt/unsigned char wherex (void);/
3777 <tag/Description/The function returns the current X position of the text mode
3778 cursor. Zero is returned for the leftmost screen position.
3779 <tag/Availability/cc65
3781 <ref id="gotox" name="gotox">,
3782 <ref id="gotoy" name="gotoy">,
3783 <ref id="gotoxy" name="gotoxy">,
3784 <ref id="wherey" name="wherey">
3790 <sect1>wherey<label id="wherey"><p>
3794 <tag/Function/Return the current Y position of the text mode cursor.
3795 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
3796 <tag/Declaration/<tt/unsigned char wherey (void);/
3797 <tag/Description/The function returns the current Y position of the text mode
3798 cursor. Zero is returned for the uppermost screen position.
3799 <tag/Availability/cc65
3801 <ref id="gotox" name="gotox">,
3802 <ref id="gotoy" name="gotoy">,
3803 <ref id="gotoxy" name="gotoxy">,
3804 <ref id="wherex" name="wherex">