# cc65 function reference

## Ullrich von Bassewitz,
Greg King

cc65 is a C compiler for 6502 based systems. This function reference describes the C functions available in the standard library.

## 1. Introduction

## 2. Functions by header file

- 2.1 `6502.h`
- 2.2 `accelerator.h`
- 2.3 `apple2.h`
- 2.4 `apple2enh.h`
- 2.5 `assert.h`
- 2.6 `atari.h`
- 2.7 `atmos.h`
- 2.8 `c128.h`
- 2.9 `c16.h`
- 2.10 `c64.h`
- 2.11 `cbm.h`
- 2.12 `cbm510.h`
- 2.13 `cbm610.h`
- 2.14 `cc65.h`
- 2.15 `conio.h`
- 2.16 `ctype.h`
- 2.17 `cx16.h`
- 2.18 `dbg.h`
- 2.19 `device.h`
- 2.20 `dio.h`
- 2.21 `dirent.h`
- 2.22 `em.h`
- 2.23 `errno.h`
- 2.24 `fcntl.h`
- 2.25 `gamate.h`
- 2.26 `geos.h`
- 2.27 `joystick.h`
- 2.28 `locale.h`
- 2.29 `lynx.h`
- 2.30 `lz4.h`
- 2.31 `modload.h`
- 2.32 `mouse.h`
- 2.33 `nes.h`
- 2.34 `o65.h`
- 2.35 `pce.h`
- 2.36 `peekpoke.h`
- 2.37 `pen.h`
- 2.38 `pet.h`
- 2.39 `plus4.h`
- 2.40 `serial.h`
- 2.41 `setjmp.h`
- 2.42 `signal.h`
- 2.43 `stdarg.h`
- 2.44 `stdbool.h`
- 2.45 `stddef.h`
- 2.46 `stdio.h`
- 2.47 `stdlib.h`
- 2.48 `string.h`
- 2.49 `telestrat.h`
- 2.50 `tgi.h`
- 2.51 `time.h`
- 2.52 `unistd.h`
- 2.53 `vic20.h`
- 2.54 `zlib.h`

## 3. Alphabetical function reference

- 3.1 _DE_ISDIR
- 3.2 _DE_ISLBL
- 3.3 _DE_ISLNK
- 3.4 _DE_ISREG
- 3.5 _heapadd
- 3.6 _heapblocksize
- 3.7 _heapmaxavail
- 3.8 _heapmemavail
- 3.9 _is_cmdline_dos
- 3.10 _poserror
- 3.11 _randomize
- 3.12 _stroserror
- 3.13 _swap
- 3.14 _sys
- 3.15 BRK
- 3.16 CLI
- 3.17 PEEK
- 3.18 PEEKW
- 3.19 POKE
- 3.20 POKEW
- 3.21 SEI
- 3.22 abort
- 3.23 abs
- 3.24 assert
- 3.25 atexit
- 3.26 atmos_explode
- 3.27 atmos_load
- 3.28 atmos_ping
- 3.29 atmos_save
- 3.30 atmos_shoot
- 3.31 atmos_tick
- 3.32 atmos_tock
- 3.33 atmos_zap
- 3.34 atoi
- 3.35 atol
- 3.36 bgcolor
- 3.37 bordercolor
- 3.38 bsearch
- 3.39 bzero
- 3.40 c64mode
- 3.41 calloc
- 3.42 cbm_k_acptr
- 3.43 cbm_k_basin
- 3.44 cbm_k_bsout
- 3.45 cbm_k_chkin
- 3.46 cbm_k_ciout
- 3.47 cbm_k_ckout
- 3.48 cbm_k_clall
- 3.49 cbm_k_close
- 3.50 cbm_k_clrch
- 3.51 cbm_k_getin
- 3.52 cbm_k_iobase
- 3.53 cbm_k_listen
- 3.54 cbm_k_load
- 3.55 cbm_k_open
- 3.56 cbm_k_readst
- 3.57 cbm_k_save
- 3.58 cbm_k_scnkey
- 3.59 cmb_k_second
- 3.60 cbm_k_setlfs
- 3.61 cbm_k_setnam
- 3.62 cbm_k_settim
- 3.63 cbm_k_talk
- 3.64 cbm_k_tksa
- 3.65 cbm_k_udtim
- 3.66 cbm_k_unlsn
- 3.67 cbm_k_untlk
- 3.68 cclear
- 3.69 cclearxy
- 3.70 cgetc
- 3.71 chline
- 3.72 chlinexy
- 3.73 clearerr
- 3.74 clock
- 3.75 clock_getres
- 3.76 clock_gettime
- 3.77 clock_settime
- 3.78 clrscr
- 3.79 close
- 3.80 closedir
- 3.81 cpeekc
- 3.82 cpeekcolor
- 3.83 cpeekrevers
- 3.84 cpeeks
- 3.85 creat
- 3.86 cprintf
- 3.87 cputc
- 3.88 cputcxy
- 3.89 cputs
- 3.90 cputsxy
- 3.91 cursor
- 3.92 cvline
- 3.93 cvlinexy
- 3.94 decompress_lz4
- 3.95 detect_c128
- 3.96 detect_c64dtv
- 3.97 detect_c65
- 3.98 detect_chameleon
- 3.99 detect_scpu
- 3.100 detect_turbomaster
- 3.101 div
- 3.102 doesclrscrafterexit
- 3.103 em_commit
- 3.104 em_copyfrom
- 3.105 em_copyto
- 3.106 em_install
- 3.107 em_load_driver
- 3.108 em_map
- 3.109 em_pagecount
- 3.110 em_uninstall
- 3.111 em_unload
- 3.112 em_use
- 3.113 exit
- 3.114 exec
- 3.115 fast
- 3.116 feof
- 3.117 ferror
- 3.118 fileno
- 3.119 free
- 3.120 get_ostype
- 3.121 get_c128_speed
- 3.122 get_c64dtv_speed
- 3.123 get_c65_speed
- 3.124 get_chameleon_speed
- 3.125 get_scpu_speed
- 3.126 get_turbomaster_speed
- 3.127 getcpu
- 3.128 getcurrentdevice
- 3.129 getcwd
- 3.130 getdevicedir
- 3.131 getenv
- 3.132 getfirstdevice
- 3.133 getnextdevice
- 3.134 getopt
- 3.135 gotox
- 3.136 gotoxy
- 3.137 gotoy
- 3.138 isalnum
- 3.139 isalpha
- 3.140 isascii
- 3.141 isblank
- 3.142 iscntrl
- 3.143 isdigit
- 3.144 isfast
- 3.145 isgraph
- 3.146 islower
- 3.147 isprint
- 3.148 ispunct
- 3.149 isspace
- 3.150 isupper
- 3.151 isxdigit
- 3.152 itoa
- 3.153 joy_count
- 3.154 joy_install
- 3.155 joy_load_driver
- 3.156 joy_read
- 3.157 joy_uninstall
- 3.158 joy_unload
- 3.159 kbhit
- 3.160 kbrepeat
- 3.161 labs
- 3.162 ltoa
- 3.163 localeconv
- 3.164 longjmp
- 3.165 malloc
- 3.166 memchr
- 3.167 memcmp
- 3.168 memcpy
- 3.169 memmove
- 3.170 memset
- 3.171 mod_free
- 3.172 mod_load
- 3.173 mouse_setbox
- 3.174 mouse_getbox
- 3.175 mouse_buttons
- 3.176 mouse_geterrormsg
- 3.177 mouse_hide
- 3.178 mouse_info
- 3.179 mouse_install
- 3.180 mouse_ioctl
- 3.181 mouse_load_driver
- 3.182 mouse_move
- 3.183 mouse_pos
- 3.184 mouse_show
- 3.185 mouse_uninstall
- 3.186 mouse_unload
- 3.187 mul20
- 3.188 mul40
- 3.189 offsetof
- 3.190 open
- 3.191 opendir
- 3.192 peekbsys
- 3.193 peekwsys
- 3.194 perror
- 3.195 pokebsys
- 3.196 pokewsys
- 3.197 qsort
- 3.198 raise
- 3.199 rand
- 3.200 readdir
- 3.201 realloc
- 3.202 remove
- 3.203 rename
- 3.204 reset_brk
- 3.205 reset_irq
- 3.206 revers
- 3.207 rewinddir
- 3.208 screensize
- 3.209 seekdir
- 3.210 ser_close
- 3.211 ser_get
- 3.212 ser_install
- 3.213 ser_ioctl
- 3.214 ser_load_driver
- 3.215 ser_open
- 3.216 ser_put
- 3.217 ser_status
- 3.218 ser_uninstall
- 3.219 ser_unload
- 3.220 set_brk
- 3.221 set_irq
- 3.222 set_c128_speed
- 3.223 set_c64dtv_speed
- 3.224 set_c65_speed
- 3.225 set_chameleon_speed
- 3.226 set_scpu_speed
- 3.227 set_turbomaster_speed
- 3.228 setjmp
- 3.229 setlocale
- 3.230 signal
- 3.231 sleep
- 3.232 slow
- 3.233 srand
- 3.234 strcasecmp
- 3.235 strcat
- 3.236 strchr
- 3.237 strcmp
- 3.238 strcoll
- 3.239 strcpy
- 3.240 strcspn
- 3.241 strdup
- 3.242 strerror
- 3.243 stricmp
- 3.244 strlen
- 3.245 strlower
- 3.246 strlwr
- 3.247 strncasecmp
- 3.248 strncat
- 3.249 strncmp
- 3.250 strncpy
- 3.251 strnicmp
- 3.252 strpbrk
- 3.253 strqtok
- 3.254 strrchr
- 3.255 strspn
- 3.256 strstr
- 3.257 strtok
- 3.258 strxfrm
- 3.259 strupper
- 3.260 strupr
- 3.261 telldir
- 3.262 textcolor
- 3.263 time
- 3.264 toggle_videomode
- 3.265 tolower
- 3.266 toupper
- 3.267 ultoa
- 3.268 unlink
- 3.269 utoa
- 3.270 vcprintf
- 3.271 videomode
- 3.272 waitvsync
- 3.273 wherex
- 3.274 wherey

## 1. Introduction

cc65 is a C compiler for 6502-based systems. It implements a subset of the ISO C standard plus additional functions specially crafted for 6502 systems or just some of the supported machines. This function reference describes the available functions together with any limitations.

For an overview about the available libraries, their purpose, and any differences to the ISO standard, please have a look at the cc65 Library Overview.

Note: Standard C functions are listed here, but not described in detail. Because those functions behave identically on all standard-compliant systems, they are described in any book covering standard C.

Each entry for a function contains a detailed description

> Function

>   Summary of what function does.

> Header

>   The header file that contains the declaration.

> Declaration

>   Describes the needed header files and declaration of the function.

> Description

>   Description of the function.

> Notes

>   Notes on the function.

> Availability

>   The availability of the function.

> See also

>   Other related functions.

> Example

>   A piece of actual code using the function.

## 2. Functions by header file

## 2.1 `6502.h`

- BRK
- CLI
- SEI
- _sys
- getcpu
- reset_brk
- reset_irq
- set_brk
- set_irq

## 2.2 `accelerator.h`

- detect_c128
- detect_c64dtv
- detect_c65
- detect_chameleon
- detect_scpu
- detect_turbomaster
- get_c128_speed
- get_c64dtv_speed
- get_c65_speed
- get_chameleon_speed
- get_scpu_speed
- get_turbomaster_speed
- set_c128_speed
- set_c64dtv_speed
- set_c65_speed
- set_chameleon_speed
- set_scpu_speed
- set_turbomaster_speed

## 2.3 `apple2.h`

- _dos_type
- get_ostype
- rebootafterexit

## 2.4 `apple2enh.h`

- _dos_type
- get_ostype
- rebootafterexit
- videomode

## 2.5 `assert.h`

- assert

## 2.6 `atari.h`

- _is_cmdline_dos
- get_ostype

(incomplete)

## 2.7 `atmos.h`

- atmos_explode
- atmos_load
- atmos_ping
- atmos_save
- atmos_shoot
- atmos_tick
- atmos_tock
- atmos_zap

## 2.8 `c128.h`

- c64mode
- fast
- isfast
- slow
- toggle_videomode
- videomode

## 2.9 `c16.h`

- fast
- isfast
- slow

(incomplete)

## 2.10 `c64.h`

- get_ostype

## 2.11 `cbm.h`

- cbm_k_acptr
- cbm_k_basin
- cbm_k_bsout
- cbm_k_chkin
- cbm_k_ciout
- cbm_k_ckout
- cbm_k_clall
- cbm_k_close
- cbm_k_clrch
- cbm_k_getin
- cbm_k_iobase
- cbm_k_listen
- cbm_k_load
- cbm_k_open
- cbm_k_readst
- cbm_k_save
- cbm_k_scnkey
- cbm_k_second
- cbm_k_setlfs
- cbm_k_setnam
- cbm_k_settim
- cbm_k_talk
- cbm_k_tksa
- cbm_k_udtim
- cbm_k_unlsn
- cbm_k_untlk
- kbrepeat
- waitvsync

(incomplete)

## 2.12 `cbm510.h`

- peekbsys
- peekwsys
- pokebsys
- pokewsys

## 2.13 `cbm610.h`

- peekbsys
- peekwsys
- pokebsys
- pokewsys

## 2.14 `cc65.h`

- doesclrscrafterexit
- mul20
- mul40

(incomplete)

## 2.15 `conio.h`

- bgcolor
- bordercolor
- cclear
- cclearxy
- cgetc
- chline
- chlinexy
- clrscr
- cpeekc
- cpeekcolor
- cpeekrevers
- cpeeks
- cprintf
- cputc
- cputcxy
- cputs
- cputsxy
- cursor
- cvline
- cvlinexy
- gotox
- gotoxy
- gotoy
- kbhit
- revers
- screensize
- textcolor
- vcprintf
- wherex
- wherey

## 2.16 `ctype.h`

- isalnum
- isalpha
- isascii
- isblank
- iscntrl
- isdigit
- isgraph
- islower
- isprint
- ispunct
- isspace
- isupper
- isxdigit
- tolower
- toupper

## 2.17 `cx16.h`

- videomode

(incomplete)

## 2.18 `dbg.h`

(incomplete)

## 2.19 `device.h`

- getcurrentdevice
- getdevicedir
- getfirstdevice
- getnextdevice

## 2.20 `dio.h`

Low-level disk I/O API.

## 2.21 `dirent.h`

- _DE_ISDIR
- _DE_ISLBL
- _DE_ISLNK
- _DE_ISREG
- closedir
- opendir
- readdir
- rewinddir
- seekdir
- telldir

## 2.22 `em.h`

This header file contains definitions for extended memory access, see also `testcode/lib/em-test.c` and `samples/multidemo.c`.

- em_commit
- em_copyfrom
- em_copyto
- em_install
- em_load_driver
- em_map
- em_pagecount
- em_uninstall
- em_unload
- em_use

## 2.23 `errno.h`

(incomplete)

## 2.24 `fcntl.h`

- close
- creat
- open

## 2.25 `gamate.h`

- waitvsync

(incomplete)

## 2.26 `geos.h`

GEOS API.

## 2.27 `joystick.h`

- joy_count
- joy_install
- joy_load_driver
- joy_read
- joy_uninstall
- joy_unload

## 2.28 `locale.h`

- localeconv
- setlocale

## 2.29 `lynx.h`

(incomplete)

## 2.30 `lz4.h`

- decompress_lz4

## 2.31 `modload.h`

- mod_load
- mod_free

## 2.32 `mouse.h`

- mouse_buttons
- mouse_getbox
- mouse_geterrormsg
- mouse_hide
- mouse_info
- mouse_install
- mouse_ioctl
- mouse_load_driver
- mouse_move
- mouse_pos
- mouse_setbox
- mouse_show
- mouse_uninstall
- mouse_unload

## 2.33 `nes.h`

- waitvsync

(incomplete)

## 2.34 `o65.h`

The `o65.h` header file contains structure and constant definitions that may be used when dealing with files in the o65 format. It does not declare any functions.

## 2.35 `pce.h`

- waitvsync

(incomplete)

## 2.36 `peekpoke.h`

- PEEK
- PEEKW
- POKE
- POKEW

## 2.37 `pen.h`

(incomplete)

## 2.38 `pet.h`

(incomplete)

## 2.39 `plus4.h`

- fast
- isfast
- slow

(incomplete)

## 2.40 `serial.h`

This header file contains definitions for initializing serial communication, see also `testcode/lib/ser-test.c`.

- ser_close
- ser_get
- ser_install
- ser_ioctl
- ser_load_driver
- ser_open
- ser_put
- ser_status
- ser_uninstall
- ser_unload

## 2.41 `setjmp.h`

- setjmp
- longjmp

## 2.42 `signal.h`

- raise
- signal

## 2.43 `stdarg.h`

(incomplete)

## 2.44 `stdbool.h`

(incomplete)

## 2.45 `stddef.h`

- offsetof

## 2.46 `stdio.h`

- _poserror
- clearerr
- feof
- ferror
- fileno
- rename
- remove

(incomplete)

## 2.47 `stdlib.h`

- _heapadd
- _heapblocksize
- _heapmaxavail
- _heapmemavail
- _randomize
- _swap
- abort
- abs
- atexit
- atoi
- atol
- bsearch
- calloc
- div
- exit
- free
- getenv
- itoa
- labs
- ltoa
- malloc
- perror
- qsort
- rand
- realloc
- srand
- ultoa
- utoa

(incomplete)

## 2.48 `string.h`

- _stroserror
- bzero
- memchr
- memcmp
- memcpy
- memmove
- memset
- strcasecmp
- strcat
- strchr
- strcmp
- strcoll
- strcpy
- strcspn
- strdup
- strerror
- stricmp
- strlen
- strlower
- strlwr
- strncasecmp
- strncat
- strncmp
- strncpy
- strnicmp
- strpbrk
- strqtok
- strrchr
- strspn
- strstr
- strtok
- strxfrm
- strupper
- strupr

## 2.49 `telestrat.h`

- explode
- ping
- shoot
- zap

(incomplete)

## 2.50 `tgi.h`

Tiny Graphics Interface.

## 2.51 `time.h`

- clock
- clock_getres
- clock_gettime
- clock_settime
- time

(incomplete)

## 2.52 `unistd.h`

- exec
- getcwd
- getopt
- sleep
- unlink

(incomplete)

## 2.53 `vic20.h`

(incomplete)

## 2.54 `zlib.h`

(incomplete)

## 3. Alphabetical function reference

## 3.1 _DE_ISDIR

> Function

>   Determine if a directory entry specifies a directory.

> Header

>   `dirent.h`

> Declaration

>   `int _DE_ISDIR(unsigned char type);`

> Description

>   The function is called with the type of a directory entry taken from a `struct dirent` and returns true if the entry designates a directory.

> Notes

>   - The function is actually a macro.
> Availability

>   cc65

> See also

>   _DE_ISLBL, _DE_ISLNK, _DE_ISREG

> Example

>   None.

## 3.2 _DE_ISLBL

> Function

>   Determine if a directory entry specifies a disk label.

> Header

>   `dirent.h`

> Declaration

>   `int _DE_ISLBL(unsigned char type);`

> Description

>   The function is called with the type of a directory entry taken from a `struct dirent` and returns true if the entry designates a disk label.

> Notes

>   - The function is actually a macro.
> Availability

>   cc65

> See also

>   _DE_ISDIR, _DE_ISLNK, _DE_ISREG

> Example

>   None.

## 3.3 _DE_ISLNK

> Function

>   Determine if a directory entry specifies a link.

> Header

>   `dirent.h`

> Declaration

>   `int _DE_ISLNK(unsigned char type);`

> Description

>   The function is called with the type of a directory entry taken from a `struct dirent` and returns true if the entry designates a link.

> Notes

>   - The function is actually a macro.
> Availability

>   cc65

> See also

>   _DE_ISDIR, _DE_ISLBL, _DE_ISREG

> Example

>   None.

## 3.4 _DE_ISREG

> Function

>   Determine if a directory entry specifies a regular file.

> Header

>   `dirent.h`

> Declaration

>   `int _DE_ISREG(unsigned char type);`

> Description

>   The function is called with the type of a directory entry taken from a `struct dirent` and returns true if the entry designates a regular file.

> Notes

>   - The function is actually a macro.
>   - A "regular file" means anything with data in it. This might still mean that special processing is needed, when accessing the file. Relative files of the CBM systems are classified as being "regular" files, for example.
> Availability

>   cc65

> See also

>   _DE_ISDIR, _DE_ISLBL, _DE_ISLNK

> Example

>   None.

## 3.5 _heapadd

> Function

>   Add a block to the heap.

> Header

>   `stdlib.h`

> Declaration

>   `void __fastcall__ _heapadd (void* mem, size_t size);`

> Description

>   The function adds a block of raw memory to the heap.

> Notes

>   - The minimum blocksize that can be added is 6 bytes; the function will ignore smaller blocks.
>   - The function is available only as a fastcall function; so, it may be used only in the presence of a prototype.
> Availability

>   cc65

> See also

>   _heapblocksize, _heapmaxavail, _heapmemavail, calloc, free, malloc, realloc

> Example

>   None.

## 3.6 _heapblocksize

> Function

>   Return the size of an allocated block.

> Header

>   `stdlib.h`

> Declaration

>   `size_t __fastcall__ _heapblocksize (const void* block);`

> Description

>   The function returns the size of a block that must have previously been allocated by `malloc`, `calloc` or `realloc`.

> Notes

>   - Passing a pointer to a block that was is not the result of one of the allocation functions, or that has been free'd will give unpredicable results.
>   - The function is available only as a fastcall function; so, it may be used only in the presence of a prototype.
> Availability

>   cc65

> See also

>   _heapadd, _heapmaxavail, _heapmemavail, calloc, free, malloc, realloc

> Example

>   None.

## 3.7 _heapmaxavail

> Function

>   Return the largest block that is available on the heap.

> Header

>   `stdlib.h`

> Declaration

>   `size_t _heapmaxavail (void);`

> Description

>   The function returns the size of the largest block that may be allocated from the heap using `malloc`.

> Availability

>   cc65

> See also

>   _heapadd, _heapblocksize, _heapmemavail, calloc, free, malloc, realloc

> Example

>   None.

## 3.8 _heapmemavail

> Function

>   Return the total available space on the heap.

> Header

>   `stdlib.h`

> Declaration

>   `size_t _heapmemavail (void);`

> Description

>   The function returns the total number of bytes available on the heap.

> Notes

>   - This function is of less use than usually assumed, since the returned heap space may be available but not in one block. So even if this function says that several times more heap space is available than needed, malloc may still return `NULL`.
> Availability

>   cc65

> See also

>   _heapadd, _heapblocksize, _heapmaxavail, calloc, free, malloc, realloc

> Example

>   None.

## 3.9 _is_cmdline_dos

> Function

>   Determines whether the underlying DOS supports command line arguments.

> Header

>   `atari.h`

> Declaration

>   `unsigned char _is_cmdline_dos (void);`

> Description

>   The function returns 0 if the DOS doesn't support command line arguments. It returns 1 if it does.

> Availability

>   cc65 (`atari` and `atarixl` platforms)

## 3.10 _poserror

> Function

>   Print an error message for the error in `_oserror`.

> Header

>   `stdio.h`

> Declaration

>   `void __fastcall__ _poserror (const char* msg);`

> Description

>   `_poserror` prints an error message to `stderr`. If `msg` is not `NULL` and not an empty string, it is printed followed by a colon and a blank. Then the error message for the current contents of `_oserror` are printed followed by a newline. The message output is the same as returned by `_stroserror` with an argument of `_oserror`.

> Notes

>   - Since operating system specific error code are - you guessed it - operating system specific, the value in `_oserror` and the message that is printed depends on the cc65 target.
>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
> Availability

>   cc65

> See also

>   _stroserror, perror

> Example

>   None.

## 3.11 _randomize

> Function

>   Initialize the pseudo random number generator.

> Header

>   `stdlib.h`

> Declaration

>   `void _randomize (void);`

> Description

>   The function initializes the random number generator with a seed derived from fast changing hardware events, so the seed itself can be considered random to a certain degree.

> Notes

>   - The randomness of the seed depends on the machine hardware.
> Availability

>   cc65

> See also

>   rand, srand

> Example

>   None.

## 3.12 _stroserror

> Function

>   Return a string describing an OS specific error code.

> Header

>   `string.h`

> Declaration

>   `const char* __fastcall__ _stroserror (unsigned char errcode);`

> Description

>   `_stroserror` will return a string describing the given operating system specific error code.

> Notes

>   - Since operating system specific error code are - you guessed it - operating system specific, the parameter and the string returned depend on the cc65 target.
>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
> Availability

>   cc65

> See also

>   strerror

> Example

>   None.

## 3.13 _swap

> Function

>   Swap the contents of memory areas.

> Header

>   `stdlib.h`

> Declaration

>   `void __fastcall__ _swap (void* p, void* q, size_t size);`

> Description

>   `_swap` will swap (exchange) the contents of the two memory areas pointed to by `p` and `q`. Both memory areas are assumed to be `size` bytes in size.

> Notes

>   - The memory areas may not overlap, otherwise the results are undefined.
>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
> Availability

>   cc65

> See also

>   memcpy, memmove

> Example

>   None.

## 3.14 _sys

> Function

>   Call a subroutine passing register values.

> Header

>   `6502.h`

> Declaration

>   `void __fastcall__ _sys (struct regs* r);`

> Description

>   The function will call the subroutine at the address specified in the `pc` member of the passed `regs` structure. All registers and the CPU flags are set to the values given in the `regs` structure. On return from the subroutine, the new values of the registers and flags are stored back overwriting the old values.

> Notes

>   - Bits 4 and 5 of the flags value in the `regs` structure are ignored when calling the subroutine (they are unchanged from their current values).
>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
> Availability

>   cc65

> Example

>   None.

## 3.15 BRK

> Function

>   Insert a 6502 BRK instrunction into the code.

> Header

>   `6502.h`

> Declaration

>   `void BRK (void);`

> Description

>   The function will insert a 6502 BRK instruction into the code which may be used to trigger a debugger.

> Notes

>   - The function is actually a macro.
>   - The inserted instruction may lead to unexpected results if no debugger is present.
> Availability

>   cc65

> See also

>   CLI, SEI

> Example

>   None.

## 3.16 CLI

> Function

>   Insert a 6502 CLI instrunction into the code.

> Header

>   `6502.h`

> Declaration

>   `void CLI (void);`

> Description

>   The function will insert a 6502 CLI instruction into the code, so interrupts are enabled. Enabling interrupts has no effects if they are already enabled (the default).

> Notes

>   - The function is actually a macro.
>   - Disabling interrupts may lead to unexpected results.
> Availability

>   cc65

> See also

>   BRK, SEI

> Example

>   None.

## 3.17 PEEK

> Function

>   Read a byte from memory.

> Header

>   `peekpoke.h`

> Declaration

>   `unsigned char PEEK (unsigned addr);`

> Description

>   The function will read the absolute memory given by `addr` and return the value read.

> Notes

>   - The function is actually a macro.
>   - This function depends highly on the platform and environment.
> Availability

>   cc65

> See also

>   PEEKW, POKE

> Example

>   None.

## 3.18 PEEKW

> Function

>   Read a word (two bytes) from memory.

> Header

>   `peekpoke.h`

> Declaration

>   `unsigned PEEKW (unsigned addr);`

> Description

>   The function will read the absolute memory given by `addr` and return the value read. The byte read from the higher address is the high byte of the return value.

> Notes

>   - The function is actually a macro.
>   - This function depends highly on the platform and environment.
>   - The order in which the two bytes are read is unspecified and may depend of the address expression used.
> Availability

>   cc65

> See also

>   PEEK, POKE

> Example

>   None.

## 3.19 POKE

> Function

>   Write a byte to memory.

> Header

>   `peekpoke.h`

> Declaration

>   `void POKE (unsigned addr, unsigned char val);`

> Description

>   The function writes the value `val` to the absolute memory address given by `addr`.

> Notes

>   - The function is actually a macro.
>   - This function depends highly on the platform and environment.
>   - Careless use will cause the program to act strange or may crash the machine.
> Availability

>   cc65

> See also

>   PEEK, POKEW

> Example

>   None.

## 3.20 POKEW

> Function

>   Write a word (two bytes) to memory.

> Header

>   `peekpoke.h`

> Declaration

>   `void POKEW (unsigned addr, unsigned val);`

> Description

>   The function writes the value `val` to the absolute memory address given by `addr`. The low byte of `val` is written to the `addr`, the high byte is written to `addr+1`.

> Notes

>   - The function is actually a macro.
>   - This function depends highly on the platform and environment.
>   - Careless use will cause the program to act strange or may crash the machine.
>   - The order in which the two bytes are written is unspecified and may depend of the address expression used.
> Availability

>   cc65

> See also

>   PEEK, POKE

> Example

>   None.

## 3.21 SEI

> Function

>   Insert a 6502 SEI instrunction into the code.

> Header

>   `6502.h`

> Declaration

>   `void SEI (void);`

> Description

>   The function will insert a 6502 SEI instruction into the code, so interrupts are disabled. Note that non maskable interrupts cannot be disabled.

> Notes

>   - The function is actually a macro.
>   - Disabling interrupts may lead to unexpected results.
> Availability

>   cc65

> See also

>   BRK, CLI

> Example

>   None.

## 3.22 abort

> Function

>   Terminate a program abnormally.

> Header

>   `stdlib.h`

> Declaration

>   `void abort (void);`

> Description

>   `abort()` raises `SIGABRT`, writes a termination message on `stderr`, then terminates the program with an exit code of 3.

> Availability

>   ISO 9899

> See also

>   assert, exit, signal

> Example

>   None.

## 3.23 abs

> Function

>   Returns the absolute value of an integer.

> Header

>   `stdlib.h`

> Declaration

>   `int __fastcall__ abs (int v);`

> Description

>   `abs` returns the absolute value of the argument passed to the function.

> Notes

>   - The return value is undefined if `INT_MIN` is passed to the function.
>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
> Availability

>   ISO 9899

> See also

>   labs

> Example

>   None.

## 3.24 assert

> Function

>   Test a condition, and possibly abort.

> Header

>   `assert.h`

> Declaration

>   `void assert (int cond);`

> Description

>   `assert()` is a macro that expands to an `if` statement. If the condition evaluates to zero (false), `assert()` raises `SIGABRT`, prints a message on `stderr`, then exits the program with an exit code of 2.

> Notes

>   - The function is actually a macro.
> Availability

>   ISO 9899

> See also

>   abort, exit, signal

> Example

>   None.

## 3.25 atexit

> Function

>   Register an exit function.

> Header

>   `stdlib.h`

> Declaration

>   `int __fastcall__ atexit (void (*exitfunc) (void));`

> Description

>   `atexit` registers the function pointed to by `exitfunc` as an exit function. Exit functions are called when the program terminates, they are called in LIFO order (the last function registered is called first). `atexit` returns zero on success and a nonzero value on failure.

> Notes

>   - A maximum of 5 exit functions can be registered.
>   - There is no way to unregister an exit function.
>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
> Availability

>   ISO 9899

> See also

>   abort, exit

> Example

>   None.

## 3.26 atmos_explode

> Function

>   Bomb sound effect.

> Header

>   `atmos.h`

> Declaration

>   `void __fastcall__ atmos_explode(void);`

> Description

>   `atmos_explode` plays the BASIC sound.

> Notes

>   - The function is available only as a fastcall function; so, it may be used only in the presence of a prototype.
> Availability

>   cc65

> See also

>   atmos_ping, atmos_shoot, atmos_tick, atmos_tock, atmos_zap

> Example

>   None.

## 3.27 atmos_load

> Function

>   Load Atmos tape.

> Header

>   `atmos.h`

> Declaration

>   `void __fastcall__ atmos_load(const char* name);`

> Description

>   `atmos_load` reads a memory block from tape.

> Notes

>   - The function is available only as a fastcall function; so, it may be used only in the presence of a prototype.
> Availability

>   cc65

> See also

>   atmos_save

> Example

>   None.

## 3.28 atmos_ping

> Function

>   Bell or ricochet sound effect.

> Header

>   `atmos.h`

> Declaration

>   `void __fastcall__ atmos_ping(void);`

> Description

>   `atmos_ping` plays the BASIC sound.

> Notes

>   - The function is available only as a fastcall function; so, it may be used only in the presence of a prototype.
> Availability

>   cc65

> See also

>   atmos_explode, atmos_shoot, atmos_tick, atmos_tock, atmos_zap

> Example

>   None.

## 3.29 atmos_save

> Function

>   Save Atmos tape.

> Header

>   `atmos.h`

> Declaration

>   `void __fastcall__ atmos_save(const char* name, const void* start, const void* end);`

> Description

>   `atmos_save` writes a memory block to tape.

> Notes

>   - The function is available only as a fastcall function; so, it may be used only in the presence of a prototype.
> Availability

>   cc65

> See also

>   atmos_load

> Example

>       atmos_save("hires", 0xa000, 0xc000);

## 3.30 atmos_shoot

> Function

>   Pistol sound effect.

> Header

>   `atmos.h`

> Declaration

>   `void __fastcall__ atmos_shoot(void);`

> Description

>   `atmos_shoot` plays the BASIC sound.

> Notes

>   - The function is available only as a fastcall function; so, it may be used only in the presence of a prototype.
> Availability

>   cc65

> See also

>   atmos_explode, atmos_ping, atmos_tick, atmos_tock, atmos_zap

> Example

>   None.

## 3.31 atmos_tick

> Function

>   High-pitch click.

> Header

>   `atmos.h`

> Declaration

>   `void __fastcall__ atmos_tick(void);`

> Description

>   `atmos_tick` plays the system sound.

> Notes

>   - The function is available only as a fastcall function; so, it may be used only in the presence of a prototype.
> Availability

>   cc65

> See also

>   atmos_explode, atmos_ping, atmos_shoot, atmos_tock, atmos_zap

> Example

>   None.

## 3.32 atmos_tock

> Function

>   Low-pitch click.

> Header

>   `atmos.h`

> Declaration

>   `void __fastcall__ atmos_tock(void);`

> Description

>   `atmos_tock` plays the system sound.

> Notes

>   - The function is available only as a fastcall function; so, it may be used only in the presence of a prototype.
> Availability

>   cc65

> See also

>   atmos_explode, atmos_ping, atmos_shoot, atmos_tick, atmos_zap

> Example

>   None.

## 3.33 atmos_zap

> Function

>   Raygun sound effect.

> Header

>   `atmos.h`

> Declaration

>   `void __fastcall__ atmos_zap(void);`

> Description

>   `atmos_zap` plays the BASIC sound.

> Notes

>   - The function is available only as a fastcall function; so, it may be used only in the presence of a prototype.
> Availability

>   cc65

> See also

>   atmos_explode, atmos_ping, atmos_shoot, atmos_tick, atmos_tock

> Example

>   None.

## 3.34 atoi

> Function

>   Convert a string to an integer.

> Header

>   `stdlib.h`

> Declaration

>   `int __fastcall__ atoi (const char* s);`

> Description

>   `atoi` converts the given string into an integer. Conversion stops as soon as any invalid character is encountered.

> Notes

>   - There is no way to detect any conversion errors.
>   - The function does not check for an numerical overflow when converting.
>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
> Availability

>   ISO 9899

> See also

>   atol, itoa, ltoa, ultoa, utoa

> Example

>   None.

## 3.35 atol

> Function

>   Convert a string to a long integer.

> Header

>   `stdlib.h`

> Declaration

>   `long __fastcall__ atol (const char* s);`

> Description

>   `atol` converts the given string into a long integer. Conversion stops as soon as any invalid character is encountered.

> Notes

>   - There is no way to detect any conversion errors.
>   - The function does not check for an numerical overflow when converting.
>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
> Availability

>   ISO 9899

> See also

>   atoi, itoa, ltoa, ultoa, utoa

> Example

>   None.

## 3.36 bgcolor

> Function

>   Set the background text color.

> Header

>   `conio.h`

> Declaration

>   `unsigned char __fastcall__ bgcolor (unsigned char color);`

> Description

>   The function will set a new background color and return the old (current) one. The background color is valid for the whole text output area of the screen, not just for new text.

> Notes

>   - Background colors are system dependent. The function may have no effect on systems where the background color cannot be changed.
>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
> Availability

>   cc65

> See also

>   bordercolor, textcolor

> Example

>   None.

## 3.37 bordercolor

> Function

>   Set the border (frame) color.

> Header

>   `conio.h`

> Declaration

>   `unsigned char __fastcall__ bordercolor (unsigned char color);`

> Description

>   The function will set a new border color. It returns the old (current) border color.

> Notes

>   - Border colors are system dependent. The function may have no effect on systems where the border color cannot be changed.
>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
> Availability

>   cc65

> See also

>   bgcolor, textcolor

> Example

>   None.

## 3.38 bsearch

> Function

>   Do a binary search in a sorted array.

> Header

>   `stdlib.h`

> Declaration

>   `void* __fastcall__ bsearch (const void* key, const void* base, size_t n, size_t size, int __fastcall__ (* cmp) (const void*, const void*));`

> Description

>   `bsearch` searches a sorted array for a member that matches the one pointed to by `key`. `base` is the address of the array, `n` is the number of elements, `size` the size of an element and `cmp` the function used to compare the members against the key. The function returns a pointer to the member found, or `NULL` if there was no match.

> Notes

>   - The contents of the array must be sorted in ascending order according to the compare function given.
>   - If there are multiple members that match the key, the function will return one of the members.
>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
>   - The function to which `cmp` points must have the `fastcall` calling convention.
> Availability

>   ISO 9899

> See also

>   qsort

> Example

>   None.

## 3.39 bzero

> Function

>   Fill a memory area with zeroes.

> Header

>   `string.h`

> Declaration

>   `void __fastcall__ bzero (void* p, size_t count);`

> Description

>   `bzero` fills the memory area pointed to by `p` with zero.

> Notes

>   - The function is non standard and therefore only available in non ANSI mode. You should use `memset` instead.
>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
> Availability

>   cc65

> See also

>   _swap, memcpy, memmove, memset,

> Example

>   None.

## 3.40 c64mode

> Function

>   Switch the C128 into C64 compatible mode.

> Header

>   `c128.h`

> Declaration

>   `void c64mode (void);`

> Description

>   The function will cause the machine to reboot into C64 mode.

> Notes

>   - The function is specific to the C128.
>   - The function will not return to the caller.
> Availability

>   C128

> Example

>   None.

## 3.41 calloc

> Function

>   Allocate and clear memory.

> Header

>   `stdlib.h`

> Declaration

>   `void* __fastcall__ calloc (size_t n, size_t size);`

> Description

>   `calloc` allocates memory for an array of `n` elements of size `size`, clears the whole block with binary zeroes and returns a pointer to it. On error (not enough memory available), `calloc` returns `NULL`.

> Notes

>   - Clearing the memory may not have the expected effect on all platforms: pointers in the block may not be `NULL` and floating point variables may not be zero (0.0). In other words: The "clearing" effect of this function should be used with care for portable programs.
>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
> Availability

>   ISO 9899

> See also

>   _heapadd, _heapblocksize, _heapmaxavail, _heapmemavail, free, malloc, realloc

> Example

>   None.

## 3.42 cbm_k_acptr

> Function

>   Input byte from serial bus

> Header

>   `cbm.h`

> Declaration

>   `unsigned char cbm_k_acptr (void);`

> Description

>   The function returns a byte of data, which it gets from the current TALKer on the serial bus. In order to receive the data, the device must have previously been sent a command to TALK and a secondary address if it needs one.

> Notes

> Availability

>   cc65

> See also

>   cbm_k_talk,

> Example

>   None.

## 3.43 cbm_k_basin

> Function

>   Input a Character from the Current Device

> Header

>   `cbm.h`

> Declaration

>   `unsigned char cbm_k_basin (void);`

> Description

>   The function returns a character from the current input device. Device must first have been OPENed and then designated as the input channel by the CHKIN routine. When this function is called, the next byte of data available from the device is returned. Exception is the routine for the keyboard device (which is the default input device).

> Notes

> Availability

>   cc65

> See also

>   cbm_k_open, cbm_k_chkin

> Example

>   None.

## 3.44 cbm_k_bsout

> Function

>   Output a byte

> Header

>   `cbm.h`

> Declaration

>   `void __fastcall__ cbm_k_bsout (unsigned char C);`

> Description

>   Function sends the character to the current output device. Unless a device has been OPENed and designated as the current output channel using the CHKOUT routine, the character is printed to the screen, which is the default output device. If the cassette is the current device, outputting a byte will only add it to the buffer. No actual transmission of data will occur until the 192-byte buffer is full.

> Notes

>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
> Availability

>   cc65

> See also

>   cbm_k_open, cbm_k_chkout

> Example

>   None.

## 3.45 cbm_k_chkin

> Function

>   Designate a Logical File As the Current Input Channel

> Header

>   `cbm.h`

> Declaration

>   `unsigned char __fastcall__ cbm_k_chkin (unsigned char FN);`

> Description

>   If you wish to get data from any device other than the keyboard, this function must be called after OPENing the device, before you can get a data byte with the cbm_k_basin or cbm_k_getin routine. When called, the routine will designate the logical file whose file number was supplied as the current file, its device as the current device, and its secondary address as the current secondary address. If the device on the channel is a serial device, which requires a TALK command and sometimes a secondary address, function will send them over the serial bus.

> Notes

>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
> Availability

>   cc65

> See also

>   cbm_k_open, cbm_k_basin, cbm_k_getin

> Example

>   None.

## 3.46 cbm_k_ciout

> Function

>   Transmit a byte over the serial bus

> Header

>   `cbm.h`

> Declaration

>   `void __fastcall__ cbm_k_ciout (unsigned char C);`

> Description

>   Purpose of this function is to send a byte of data over the serial bus. In order for the data to be received, the serial device must have first been commanded to LISTEN and been given a secondary address if necessary. This routine always buffers the current character, and defers sending it until the next byte is buffered. When the UNLISTEN command is sent, the last byte will be sent with an End or Identify (EOI).

> Notes

>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
> Availability

>   cc65

> See also

>   cbm_k_listen, cbm_k_unlsn

> Example

>   None.

## 3.47 cbm_k_ckout

> Function

>   Designate a Logical File As the Current Output Channel

> Header

>   `cbm.h`

> Declaration

>   `unsigned char __fastcall__ cbm_k_ckout (unsigned char FN);`

> Description

>   If you wish to output data to any device other than the screen, this routine must be called after OPENing the device, and before you output a data byte with the cbm_k_bsout() function. When called, the function will designate the logical file whose file number was supplied as the current file, its device as the current device, and its secondary address as the current secondary address. If the device on the channel uses the serial bus, and therefore requires a LISTEN command and possibly a secondary address, this information will be sent on the bus.

> Notes

>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
> Availability

>   cc65

> See also

>   cbm_k_bsout, cbm_k_listen

> Example

>   None.

## 3.48 cbm_k_clall

> Function

>   Close All Logical I/O Files

> Header

>   `cbm.h`

> Declaration

>   `void cbm_k_clall (void);`

> Description

>   It closes all open files, by resetting the index into open files to zero and restores the default I/O devices.

> Notes

> Availability

>   cc65

> See also

>   cbm_k_open, cbm_k_close

> Example

>   None.

## 3.49 cbm_k_close

> Function

>   Close a Logical I/O File

> Header

>   `cbm.h`

> Declaration

>   `void __fastcall__ cbm_k_close (unsigned char FN);`

> Description

>   It is used to close a logical file after all I/O operations involving that file have been completed.

> Notes

>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
> Availability

>   cc65

> See also

>   cbm_k_open, cbm_k_clall

> Example

>   None.

## 3.50 cbm_k_clrch

> Function

>   Restore Current Input and Output Devices to the Default Devices

> Header

>   `cbm.h`

> Declaration

>   `void cbm_k_clrch (void);`

> Description

>   It sets the current input device to the keyboard, and the current output device to the screen. Also, if the current input device was formerly a serial device, the routine sends it an UNTALK command on the serial bus, and if a serial device was formerly the current output device, the routine sends it an UNLISTEN command.

> Notes

> Availability

>   cc65

> See also

>   cbm_k_chkin, cbm_k_ckout

> Example

>   None.

## 3.51 cbm_k_getin

> Function

>   Get One Byte from the Input Device

> Header

>   `cbm.h`

> Declaration

>   `unsigned char cbm_k_getin (void);`

> Description

>   Function gets a character from the current input device.

> Notes

> Availability

>   cc65

> See also

>   cbm_k_basin

> Example

>   None.

## 3.52 cbm_k_iobase

> Function

>   Return Base Address of Memory-Mapped I/O Devices

> Header

>   `cbm.h`

> Declaration

>   `unsigned cbm_k_iobase (void);`

> Description

>   This function returns the address of the memory section where the memory mapped I/O devices are located. This address can then be used with an offset to access the memory mapped I/O devices in the Commodore 64. The offset is the number of locations from the beginning of the page on which the I/O register you want is located. This function exists to provide compatibility between the Commodore 64, VIC-20, and future models of the Commodore 64. If the I/O locations for a program are set by a call to this function, they should still remain compatible with future versions of the Commodore 64, the KERNAL and BASIC.

> Notes

> Availability

>   cc65

> See also
> Example

>   None.

## 3.53 cbm_k_listen

> Function

>   Command a device on the serial bus to LISTEN

> Header

>   `cbm.h`

> Declaration

>   `void __fastcall__ cbm_k_listen (unsigned char dev);`

> Description

>   This function will command a device on the serial bus to receive data. The KERNAL routine will OR the supplied device number bit by bit to convert it to a listen address, then transmits this data as a command on the serial bus. The specified device will then go into listen mode, and be ready to accept information.

> Notes

>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
> Availability

>   cc65

> See also

>   cbm_k_unlsn

> Example

>   None.

## 3.54 cbm_k_load

> Function

>   Load RAM from a Device

> Header

>   `cbm.h`

> Declaration

>   `unsigned int __fastcall__ cbm_k_load(unsigned char flag, unsigned addr);`

> Description

>   This function LOADs data bytes from any input device directly into the memory. It can also be used for a verify operation, comparing data from a device with the data already in memory, while leaving the data stored in RAM unchanged. The flag must be set to 0 for a LOAD operation, or 1 for a verify, If the input device is OPENed with a secondary address (SA) of 0 the header information from the device is ignored. In this case, the starting address for the load must be supplied. If the device is addressed with a secondary address of 1, then the data is loaded into memory starting at the location specified by the header. Function returns the address of the highest RAM location loaded. Before this function can be called, the KERNAL SETLFS, and SETNAM routines must be called.

> Notes

>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
> Availability

>   cc65

> See also

>   cbm_k_save, cbm_k_setlfs, cbm_k_setnam

> Example

>   None.

## 3.55 cbm_k_open

> Function

>   Open a Logical I/O File

> Header

>   `cbm.h`

> Declaration

>   `unsigned char cbm_k_open (void);`

> Description

>   This function assigns a logical file to a device, so that it can be used for Input/Output operations. In order to specify the logical file number, the device number, and the secondary address if any, the cbm_k_setlfs() function must first be called. Likewise, in order to designate the filename, the cbm_k_setnam() function must be used first. After these two functions are called, cbm_k_open() is then called.

> Notes

> Availability

>   cc65

> See also

>   cbm_k_close, cbm_k_setlfs, cbm_k_setnam

> Example

>   None.

## 3.56 cbm_k_readst

> Function

>   Read status word

> Header

>   `cbm.h`

> Declaration

>   `unsigned char cbm_k_readst (void);`

> Description

>   This function returns the current status of the I/O devices. It is usually called after new communication to an I/O device and gives information about device status, or errors that have occurred during the I/O operation.

> Notes

> Availability

>   cc65

> See also
> Example

>   None.

## 3.57 cbm_k_save

> Function

>   Save RAM to a Device

> Header

>   `cbm.h`

> Declaration

>   `unsigned char __fastcall__ cbm_k_save(unsigned int start, unsigned int end)`

> Description

>   This function saves a section of memory. The cbm_k_setlfs() and cbm_k_setnam() functions must be used before calling this function. However, a file name is not required to SAVE to device 1 (the Datassette(TM) recorder). Any attempt to save to other devices without using a file name results in an error. NOTE: Device 0 (the keyboard), device 2 (RS-232), and device 3 (the screen) cannot be SAVEd to. If the attempt is made, an error occurs, and the SAVE is stopped.

> Notes

>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
> Availability

>   cc65

> See also

>   cbm_k_load, cbm_k_setlfs, cbm_k_setnam

> Example

>   None.

## 3.58 cbm_k_scnkey

> Function

>   Scan the keyboard matrix.

> Header

>   `cbm.h`

> Declaration

>   `void cbm_k_scnkey (void);`

> Description

>   This function looks at the switches in the keyboard, to see if any of them are being pressed. If they are, then code numbers for them are stored in RAM. Other functions use those numbers to input text. Normally, the keyboard is scanned by the Kernal's Interrupt Service Routine. But, if you divert the "Jiffy interrupt" to a C-code ISR, then that ISR must call this function, in order to provide input from the keyboard.

> Availability

>   cc65

> See also

>   cbm_k_getin, cbm_k_udtim, cgetc,

> Example

>   None.

## 3.59 cmb_k_second

> Function

>   Send secondary address for LISTEN.

> Header

>   `cbm.h`

> Declaration

>   `void __fastcall__ cbm_k_second (unsigned char addr);`

> Description

>   This function is used to send a secondary address to an I/O device after a call to LISTEN is made, and the device is commanded to LISTEN.

> Notes

>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
>   - The function can only be called after a call to LISTEN.
>   - The function will not work after a TALK.
>   - When a secondary address is to be sent to a device on the serial bus, the address must first be ORed with $60.
> Availability

>   cc65

> See also

>   cbm_k_listen

> Exampe

>   None.

## 3.60 cbm_k_setlfs

> Function

>   Set up a logical file

> Header

>   `cbm.h`

> Declaration

>   `void __fastcall__ cbm_k_setlfs (unsigned char LFN, unsigned char DEV, unsigned char SA);`

> Description

>   This functions sets up the logical file by setting its number, device address, and secondary address.

> Notes

>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
> Availability

>   cc65

> See also

>   cbm_k_load, cbm_k_open, cbm_k_save, cbm_k_setnam

> Example

>   None.

## 3.61 cbm_k_setnam

> Function

>   Set Filename Parameters

> Header

>   `cbm.h`

> Declaration

>   `void __fastcall__ cbm_k_setnam (const char* Name);`

> Description

>   This function is used to set up the file name for the OPEN, SAVE, or LOAD operations.

> Notes

>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
> Availability

>   cc65

> See also

>   cbm_k_load, cbm_k_open, cbm_k_save, cbm_k_setlfs

> Example

>   None.

## 3.62 cbm_k_settim

> Function

>   Set the Jiffy clock.

> Header

>   `cbm.h`

> Declaration

>   `void __fastcall__ cbm_k_settim (unsigned long timer);`

> Description

>   This function changes the Jiffy clock to a different value. That clock counts sixtieths of a second. It is used by the library's `clock()` function. The Jiffy clock is updated by the Kernal's Interrupt Service Routine.

> Notes

>   - The function is available only as a fastcall function; therefore, it may be used only in the presence of a prototype.
> Availability

>   cc65

> See also

>   cbm_k_udtim, clock

> Example

>   None.

## 3.63 cbm_k_talk

> Function

>   Commands device to TALK

> Header

>   `cbm.h`

> Declaration

>   `void __fastcall__ cbm_k_talk (unsigned char dev);`

> Description

>   When called, it ORs the device number with the TALK code (64, $40) and sends it on the serial bus. This commands the device to TALK.

> Notes

>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
> Availability

>   cc65

> See also

>   cbm_k_acptr

> Example

>   None.

## 3.64 cbm_k_tksa

> Function

>   Send TALK secondary address to serial bus

> Header

>   `cbm.h`

> Declaration

>   `void __fastcall__ cbm_k_tksa (unsigned char addr);`

> Description

>   This function transmits a secondary address on the serial bus for a TALK device.

> Notes

>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
>   - The function can only be called after a call to TALK.
>   - The function will not work after a LISTEN.
> Availability

>   cc65

> See also

>   cbm_k_talk

> Example

>   None.

## 3.65 cbm_k_udtim

> Function

>   Update the Jiffy clock.

> Header

>   `cbm.h`

> Declaration

>   `void cbm_k_udtim (void);`

> Description

>   This function adds one count to the Jiffy clock. That clock counts sixtieths of a second. It is used by the library's `clock()` function. Normally, the Jiffy clock is updated by the Kernal's Interrupt Service Routine. But, if you divert the "Jiffy interrupt" to a C-code ISR, then that ISR must call this function, in order to keep the clock valid.

> Availability

>   cc65

> See also

>   cbm_k_scnkey, cbm_k_settim, clock

> Example

>   None.

## 3.66 cbm_k_unlsn

> Function

>   Send an UNLISTEN command

> Header

>   `cbm.h`

> Declaration

>   `void cbm_k_unlsn (void);`

> Description

>   This function commands all devices on the serial bus to stop receiving data from the host computer (i.e., UNLISTEN). Calling this function results in an UNLISTEN command being transmitted on the serial bus. Only devices previously commanded to LISTEN are affected. This function is normally used after the host computer is finished sending data to external devices. Sending the UNLISTEN commands the listening devices to get off the serial bus so it can be used for other purposes.

> Availability

>   cc65

> See also

>   cbm_k_listen

> Example

>   None.

## 3.67 cbm_k_untlk

> Function

>   Send an UNTALK command

> Header

>   `cbm.h`

> Declaration

>   `void cbm_k_untlk (void);`

> Description

>   This function commands all devices on the serial bus to stop sending data to the host computer (i.e., UNTALK). Calling this function results in an UNTALK command being transmitted on the serial bus. Only devices previously commanded to TALK are affected. This function is normally used after the host computer is finished listening to data from an external device. Sending the UNTALK commands the sending devices to get off the serial bus so it can be used for other purposes.

> Availability

>   cc65

> See also

>   cbm_k_talk

> Example

>   None.

## 3.68 cclear

> Function

>   Clear part of a line (write a given number of spaces).

> Header

>   `conio.h`

> Declaration

>   `void __fastcall__ cclear (unsigned char length);`

> Description

>   The function clears part of a line by writing `length` spaces in the current text color.

> Notes

>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
> Availability

>   cc65

> See also

>   cclearxy, clrscr

> Example

>   None.

## 3.69 cclearxy

> Function

>   Clear part of a line (write a given number of spaces) starting at a specific screen position.

> Header

>   `conio.h`

> Declaration

>   `void __fastcall__ cclearxy (unsigned char x, unsigned char y, unsigned char length);`

> Description

>   The function moves the cursor to a specific position, and will then clear part of the line by writing `length` spaces in the current text color.

> Notes

>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
> Availability

>   cc65

> See also

>   cclear, clrscr

> Example

>   None.

## 3.70 cgetc

> Function

>   Read a character from the keyboard.

> Header

>   `conio.h`

> Declaration

>   `char cgetc (void);`

> Description

>   The function reads a character from the keyboard. If there is no character available, `cgetc()` waits until the user presses a key. If the cursor is enabled by use of the `cursor` function, a blinking cursor is displayed while waiting.

> Notes

>   - If the system supports a keyboard buffer, `cgetc()` will fetch a key from that buffer; and, wait only if the buffer is empty.
>   - The keyboard must be scanned periodically, in order for this function to see anything that you type. (See the description of `cbm_k_scnkey()`.)
> Availability

>   cc65

> See also

>   cbm_k_scnkey, cursor, kbhit

> Example

>   None.

## 3.71 chline

> Function

>   Output a horizontal line in text mode.

> Header

>   `conio.h`

> Declaration

>   `void __fastcall__ chline (unsigned char length);`

> Description

>   The function outputs a horizontal line with the given length starting at the current cursor position.

> Notes

>   - The character used to draw the horizontal line is system dependent. If available, a line drawing character is used. Drawing a line that is partially off screen leads to undefined behaviour.
>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
> Availability

>   cc65

> See also

>   chlinexy, cvline, cvlinexy

> Example

>   None.

## 3.72 chlinexy

> Function

>   Output a horizontal line at a given position in text mode.

> Header

>   `conio.h`

> Declaration

>   `void __fastcall__ chlinexy (unsigned char x, unsigned char y, unsigned char length);`

> Description

>   The function outputs a horizontal line with the given length starting at a given position.

> Notes

>   - The character used to draw the horizontal line is system dependent. If available, a line drawing character is used. Drawing a line that is partially off screen leads to undefined behaviour.
>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
> Availability

>   cc65

> See also

>   chline, cvline, cvlinexy

> Example

>   None.

## 3.73 clearerr

> Function

>   Clear error and end-of-file status of a stream.

> Header

>   `stdio.h`

> Declaration

>   `void __fastcall__ clearerr (FILE* f);`

> Description

>   `clearerr` clears the error and end-of-file status indicators for the stream `f`.

> Notes

>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
> Availability

>   ISO 9899

> See also

>   feof, ferror

> Example

>   None.

## 3.74 clock

> Function

>   Determine the processor time used.

> Header

>   `time.h`

> Declaration

>   `clock_t clock (void);`

> Description

>   The `clock` function returns an approximaton of processor time used by the program. The time is returned in implementation-defined units. It can be converted to seconds by dividing by the value of the macro `CLOCKS_PER_SEC`.

> Notes

>   - Since the machines that cc65-generated programs run on cannot run multiple processes, the function actually will return the time since some implementation-defined point in the past.
>   - The Jiffy clock must be "running", in order for this function to return changing values. (See the description of `cbm_k_udtim()`.)
> Availability

>   ISO 9899

> See also

>   cbm_k_settim, cbm_k_udtim, time

> Example

>   None.

## 3.75 clock_getres

> Function

>   Determine the realtime clock resolution.

> Header

>   `time.h`

> Declaration

>   `int __fastcall__ clock_getres (clockid_t clock_id, struct timespec *res);`

> Description

>   The `clock_getres` function finds the resolution (precision) of the realtime clock. `clock_id` has to be `CLOCK_REALTIME`. If `res` is not `NULL`, the resolution of the realtime clock is stored in the location pointed to by `res`. If `res` is `NULL`, the clock resolution is not returned. If the `tp` argument of `clock_settime` is not a multiple of `res`, then the value is truncated to a multiple of `res`. On success, zero is returned. On error, -1 is returned and `errno` is set to an error code describing the reason for the failure.

> Notes

>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
>   - Depending on the target either the `tv_sec` or the `tv_nsec` field of the `struct timespec` returned is zero.
> Availability

>   POSIX 1003.1

> See also

>   clock_gettime, clock_settime

> Example

>   None.

## 3.76 clock_gettime

> Function

>   Get the time from the realtime clock.

> Header

>   `time.h`

> Declaration

>   `int __fastcall__ clock_gettime (clockid_t clock_id, struct timespec *tp);`

> Description

>   The `clock_gettime` function retrieves the time since the 1970-01-01 00:00:00 measured in nanoseconds. `clock_id` has to be `CLOCK_REALTIME`. On success, zero is returned. On error, -1 is returned and `errno` is set to an error code describing the reason for the failure.

> Notes

>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
>   - Many platforms supported by cc65 do not have a realtime clock, so the retrieved value may not be valid. See also the platform-specific information.
> Availability

>   POSIX 1003.1

> See also

>   clock_getres, clock_settime, time

> Example

>   None.

## 3.77 clock_settime

> Function

>   Set the time on the realtime clock.

> Header

>   `time.h`

> Declaration

>   `int __fastcall__ clock_settime (clockid_t clock_id, const struct timespec *tp);`

> Description

>   The `clock_settime` function sets the time since the 1970-01-01 00:00:00 measured in nanoseconds. `clock_id` has to be `CLOCK_REALTIME`. On success, zero is returned. On error, -1 is returned and `errno` is set to an error code describing the reason for the failure.

> Notes

>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
>   - Many platforms supported by cc65 do not have a realtime clock, so setting the time may not work. See also the platform-specific information.
> Availability

>   POSIX 1003.1

> See also

>   clock_getres, clock_gettime

> Example

>   None.

## 3.78 clrscr

> Function

>   Clear the text screen.

> Header

>   `conio.h`

> Declaration

>   `void clrscr (void);`

> Description

>   The function clears the text screen and moves the cursor to the upper left corner.

> Availability

>   cc65

> See also

>   cclear, cclearxy

> Example

>   None.

## 3.79 close

> Function

>   Close a file descriptor.

> Header

>   `fcntl.h`

> Declaration

>   `int __fastcall__ close (int fd);`

> Description

>   The function closes the given file descriptor. It returns zero on success and -1 on error. If an error occurs, the cause can be determined by reading the `errno` variable.

> Notes

>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
> Availability

>   POSIX 1003.1

> See also

>   creat, open

> Example

>   None.

## 3.80 closedir

> Function

>   Close a directory.

> Header

>   `dirent.h`

> Declaration

>   `int __fastcall__ closedir (DIR* dir);`

> Description

>   The function closes the given directory descriptor. It returns zero on success and -1 on error. If an error occurs, the cause can be determined by reading the `errno` variable.

> Notes

>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
> Availability

>   POSIX 1003.1

> See also

>   opendir, readdir

> Example

>   None.

## 3.81 cpeekc

> Function

>   Get a character from the display memory.

> Header

>   `conio.h`

> Declaration

>   `char cpeekc (void);`

> Description

>   The function gets the character that's at the current location of the cursor in the display screen RAM. That character is converted, if needed, into the encoding that can be passed to `cputc()`.

> Notes

>   - Conio peek functions don't have `cpeek...xy()` versions. That was done to make it obvious that peeking doesn't move the cursor in any way. Your program must place the cursor where it wants to peek before it calls any of those functions.
> Availability

>   cc65

> See also

>   cpeekcolor, cpeekrevers, cpeeks, cputc

> Example

>   None.

## 3.82 cpeekcolor

> Function

>   Get a color from the display memory.

> Header

>   `conio.h`

> Declaration

>   `unsigned char cpeekcolor (void);`

> Description

>   The function gets the color number that's at the current location of the cursor in the display screen RAM. That number can be passed to `textcolor()`.

> Notes

>   - Conio peek functions don't have `cpeek...xy()` versions. That was done to make it obvious that peeking doesn't move the cursor in any way. Your program must place the cursor where it wants to peek before it calls any of those functions.
> Availability

>   cc65

> See also

>   cpeekc, cpeekrevers, cpeeks, cputc, textcolor

> Example

>   None.

## 3.83 cpeekrevers

> Function

>   Get a reverse-character attribute from the display memory.

> Header

>   `conio.h`

> Declaration

>   `unsigned char cpeekrevers (void);`

> Description

>   The function gets the "reverse-mode" attribute of the character that's at the current location of the cursor in the display screen RAM. It returns a boolean value (0/1) that can be passed to `revers()`.

> Notes

>   - Conio peek functions don't have `cpeek...xy()` versions. That was done to make it obvious that peeking doesn't move the cursor in any way. Your program must place the cursor where it wants to peek before it calls any of those functions.
> Availability

>   cc65

> See also

>   cpeekc, cpeekcolor, cpeeks, cputc, revers

> Example

>   None.

## 3.84 cpeeks

> Function

>   Get a string from the display memory.

> Header

>   `conio.h`

> Declaration

>   `void __fastcall__ cpeeks (char* s, unsigned length);`

> Description

>   The function gets a fixed-length string ('\0'-terminated) of characters that start at the current location of the cursor in the display screen RAM. Those characters are converted, if needed, into the encoding that can be passed to `cputs()`. The first argument must point to a RAM area that's large enough to hold "length + 1" bytes.

> Notes

>   - Conio peek functions don't have `cpeek...xy()` versions. That was done to make it obvious that peeking doesn't move the cursor in any way. Your program must place the cursor where it wants to peek before it calls any of those functions.
>   - The function is available as only a fastcall function; so, it may be used only in the presence of a prototype.
> Availability

>   cc65

> See also

>   cpeekc, cpeekcolor, cpeekrevers, cputc, cputs

> Example

>   None.

## 3.85 creat

> Function

>   Create a file.

> Header

>   `fcntl.h`

> Declaration

>   `int __fastcall__ creat (const char* name, unsigned mode);`

> Description

>   `creat` creates a new file and returns the file descriptor associated with it. On error, -1 is returned and an error code is stored in `errno`.

> Notes

>   - `creat` is identical to calling `open` with `flags` equal to `O_WRONLY | O_CREAT | O_TRUNC`.
>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
> Availability

>   POSIX 1003.1

> See also

>   close, open

> Example

>   None.

## 3.86 cprintf

> Function

>   Formatted output to the console.

> Header

>   `conio.h`

> Declaration

>   `int cprintf (const char* format, ...);`

> Description

>   The arguments are converted to text where necessary and formatted according to the format string given. The resulting string is output to the console. `cprintf` supports the same format specifiers as `printf`.

> Notes

>   - Like all other `conio` output functions, `cprintf` distinguishes between `\r` and `\n`.
> Availability

>   cc65

> See also

>   cputc, cputcxy, cputs, cputsxy, vcprintf

> Example

>   None.

## 3.87 cputc

> Function

>   Output a character directly to the console.

> Header

>   `conio.h`

> Declaration

>   `void __fastcall__ cputc (char c);`

> Description

>   Output one character to the console at the current cursor position.

> Notes

>   - Like all other `conio` output functions, `cputc` distinguishes between `\r` and `\n`.
>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
> Availability

>   cc65

> See also

>   cprintf, cputcxy, cputs, cputsxy, vcprintf

> Example

>   None.

## 3.88 cputcxy

> Function

>   Output a character at a specific screen position.

> Header

>   `conio.h`

> Declaration

>   `void __fastcall__ cputcxy (unsigned char x, unsigned char y, char c);`

> Description

>   `cputcxy` moves the cursor to the given x/y position on the screen and outputs one character.

> Notes

>   - Like all other `conio` output functions, `cputcxy` distinguishes between `\r` and `\n`.
>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
> Availability

>   cc65

> See also

>   cprintf, cputc, cputs, cputsxy, vcprintf

> Example

>   None.

## 3.89 cputs

> Function

>   Output a string directly to the console.

> Header

>   `conio.h`

> Declaration

>   `void __fastcall__ cputs (const char* s);`

> Description

>   The function outputs the given string on the console at the current cursor position.

> Notes

>   - Like all other `conio` output functions, `cputs` distinguishes between `\r` and `\n`.
>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
> Availability

>   cc65

> See also

>   cprintf, cputc, cputcxy, cputsxy, vcprintf

> Example

>   None.

## 3.90 cputsxy

> Function

>   Output a string to the console at a given position.

> Header

>   `conio.h`

> Declaration

>   `void __fastcall__ cputsxy (unsigned char x, unsigned char y, const char* s);`

> Description

>   `cputsxy` moves the cursor to the given x/y position, and outputs the string `s`.

> Notes

>   - Like all other `conio` output functions, `cputsxy` distinguishes between `\r` and `\n`.
>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
> Availability

>   cc65

> See also

>   cprintf, cputc, cputcxy, cputs, vcprintf

> Example

>   None.

## 3.91 cursor

> Function

>   Enable/disable a blinking cursor when waiting for keyboard input.

> Header

>   `conio.h`

> Declaration

>   `unsigned char __fastcall__ cursor (unsigned char onoff);`

> Description

>   If the argument to the function is non zero, a blinking cursor will be enabled when the `cgetc` function waits for input from the keyboard. If the argument is zero, `cgetc` will wait without a blinking cursor.

> Notes

>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
> Availability

>   cc65

> See also

>   cgetc, kbhit

> Example

>   None.

## 3.92 cvline

> Function

>   Output a vertical line in text mode.

> Header

>   `conio.h`

> Declaration

>   `void __fastcall__ cvline (unsigned char length);`

> Description

>   The function outputs a vertical line with the given length starting at the current cursor position.

> Notes

>   - The character used to draw the vertical line is system dependent. If available, a line drawing character is used. Drawing a line that is partially off screen leads to undefined behaviour.
>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
> Availability

>   cc65

> See also

>   chline, chlinexy, cvlinexy

> Example

>   None.

## 3.93 cvlinexy

> Function

>   Output a vertical line at a given position in text mode.

> Header

>   `conio.h`

> Declaration

>   `void __fastcall__ cvlinexy (unsigned char x, unsigned char y, unsigned char length);`

> Description

>   The function outputs a vertical line with the given length starting at a given position.

> Notes

>   - The character used to draw the vertical line is system dependent. If available, a line drawing character is used. Drawing a line that is partially off screen leads to undefined behaviour.
>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
> Availability

>   cc65

> See also

>   chline, chlinexy, cvline

> Example

>   None.

## 3.94 decompress_lz4

> Function

>   Uncompress a LZ4-compressed buffer.

> Header

>   `lz4.h`

> Declaration

>   `void decompress_lz4 (const unsigned char* src, unsigned char* const dst, const unsigned short uncompressed_size);`

> Description

>   `decompress_lz4` uncompresses a LZ4-compressed buffer.

> Notes

>   - Use LZ4_compress_HC with compression level 16 for best compression.
> Availability

>   cc65

> Example

>   None.

## 3.95 detect_c128

> Function

>   Check if a C128 CPU is the current CPU.

> Header

>   `accelerator.h`

> Declaration

>   `unsigned char detect_c128 (void);`

> Description

>   The function returns a 1 if a C128 CPU is the current CPU.

> Notes

>   - The function is specific to the C64 and C128.
> Availability

>   cc65 (not all platforms)

> See also

>   get_c128_speed, set_c128_speed,

> Example

>   None.

## 3.96 detect_c64dtv

> Function

>   Check for the presence of the C64DTV.

> Header

>   `accelerator.h`

> Declaration

>   `unsigned char detect_c64dtv (void);`

> Description

>   The function returns a 1 if a C64DTV has been detected.

> Notes

>   - The function is specific to the C64.
> Availability

>   cc65 (not all platforms)

> See also

>   get_c64dtv_speed, set_c64dtv_speed,

> Example

>   None.

## 3.97 detect_c65

> Function

>   Check for the presence of a C65/C64DX in C64 mode.

> Header

>   `accelerator.h`

> Declaration

>   `unsigned char detect_c65 (void);`

> Description

>   The function returns a 1 if a C65/C64DX in C64 mode has been detected.

> Notes

>   - The function is specific to the C64.
> Availability

>   cc65 (not all platforms)

> See also

>   get_c65_speed, set_c65_speed,

> Example

>   None.

## 3.98 detect_chameleon

> Function

>   Check for the presence of the C64 Chameleon cartridge.

> Header

>   `accelerator.h`

> Declaration

>   `unsigned char detect_chameleon (void);`

> Description

>   The function returns a 1 if a C64 Chameleon cartridge has been detected.

> Notes

>   - The function is specific to the C64.
> Availability

>   cc65 (not all platforms)

> See also

>   get_chameleon_speed, set_chameleon_speed,

> Example

>   None.

## 3.99 detect_scpu

> Function

>   Check for the presence of the C64/C128 SuperCPU cartridge.

> Header

>   `accelerator.h`

> Declaration

>   `unsigned char detect_scpu (void);`

> Description

>   The function returns a 1 if a SuperCPU cartridge has been detected.

> Notes

>   - The function is specific to the C128 and C64.
> Availability

>   cc65 (not all platforms)

> See also

>   get_scpu_speed, set_scpu_speed,

> Example

>   None.

## 3.100 detect_turbomaster

> Function

>   Check for the presence of the C64 Turbo Master cartridge.

> Header

>   `accelerator.h`

> Declaration

>   `unsigned char detect_turbomaster (void);`

> Description

>   The function returns a 1 if a C64 Turbo Master cartridge has been detected.

> Notes

>   - The function is specific to the C64.
> Availability

>   cc65 (not all platforms)

> See also

>   get_turbomaster_speed, set_turbomaster_speed,

> Example

>   None.

## 3.101 div

> Function

>   Divide two ints and return quotient and remainder.

> Header

>   `stdlib.h`

> Declaration

>   `div_t __fastcall__ div (int numer, int denom);`

> Description

>   `div` divides `numer` by `denom` and returns the quotient and remainder in a `div_t` structure.

> Notes

>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
> Availability

>   ISO 9899

> See also

>   ldiv

> Example

>   None.

## 3.102 doesclrscrafterexit

> Function

>   Determines whether the screen is going to be cleared after program exit.

> Header

>   `cc65.h`

> Declaration

>   `unsigned char doesclrscrafterexit (void);`

> Description

>   The function returns zero if the screen won't be cleared immediately after program termination. It returns a non-zero value if it will.

> Notes

>   - Some systems, maybe depending on configuration, immediately clear the screen after a program exits. Therefore it might be difficult to read the last messages printed by the program prior to its exit. This function can be used to decide if a delay or wait for a key press should be executed when then program exits.
> Availability

>   cc65

> Example

>       /* Hello World */
>       #include <stdio.h>
>       #include <unistd.h>
>       #include <cc65.h>
>       int main(void)
>       {
>           printf("Hello World\n");
>           if (doesclrscrafterexit())
>               sleep(5);
>           return 0;
>       }

## 3.103 em_commit

> Function

>   Commit changes into extended memory.

> Header

>   `em.h`

> Declaration

>   `void em_commit (void);`

> Description

>   Commit changes in the memory window to extended storage. If the contents of the memory window have been changed, these changes may be lost if `em_map`, `em_use`, `em_copyfrom` or `em_copyto` are called without calling `em_commit` first.

> Notes

>   - Calling `em_commit` does not necessarily mean that changes to the memory window are discarded, it does just mean that the drivers is allowed to discard it.
>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
>   - The function produces undefined results if no extended memory driver is loaded.
> Availability

>   cc65

> See also

>   em_load_driver, em_map, em_use

> Example

>   None.

## 3.104 em_copyfrom

> Function

>   Copy from extended into normal memory.

> Header

>   `em.h`

> Declaration

>   `void __fastcall__ em_copyfrom (const struct em_copy* copy_data);`

> Description

>   Copy data from extended memory into linear memory. Source and target addresses as well as the number of bytes to transfer are specified in the `em_copy` structure that is passed as a parameter.

> Notes

>   - Calling `em_copyfrom` will invalidate the memory window, so if you made any changes to the data in the window, call `em_commit` first, or the changes are lost.
>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
>   - The function produces undefined results if no extended memory driver is loaded.
> Availability

>   cc65

> See also

>   em_commit, em_copyto, em_load_driver

> Example

>   None.

## 3.105 em_copyto

> Function

>   Copy from normal into extended memory.

> Header

>   `em.h`

> Declaration

>   `void __fastcall__ em_copyto (const struct em_copy* copy_data);`

> Description

>   Copy data from linear into extended memory. Source and target addresses as well as the number of bytes to transfer are specified in the `em_copy` structure that is passed as a parameter.

> Notes

>   - Calling `em_copyto` will invalidate the memory window, so if you made any changes to the data in the window, call `em_commit` first, or the changes are lost.
>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
>   - The function produces undefined results if no extended memory driver is loaded.
> Availability

>   cc65

> See also

>   em_commit, em_copyfrom, em_load_driver

> Example

>   None.

## 3.106 em_install

> Function

>   Install an already loaded extended memory driver.

> Header

>   `em.h`

> Declaration

>   `unsigned char _fastcall__ em_install (void* driver);`

> Description

>   The function installs an already loaded extended memory driver and returns an error code. The function may be used to install a driver linked statically to the program.

> Notes

>   - Not all drivers are able to detect if the supported hardware is really present.
>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
> Availability

>   cc65

> See also

>   em_load_driver, em_uninstall, em_unload

> Example

>   None.

## 3.107 em_load_driver

> Function

>   Load and initialize an extended memory driver.

> Header

>   `em.h`

> Declaration

>   `unsigned char __fastcall__ em_load_driver (const char* name);`

> Description

>   Load an extended memory driver into memory and initialize it. The function returns an error code that tells if all this has been successful.

> Notes

>   - Not all drivers are able to detect if the supported hardware is really present.
>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
>   - The driver is loaded by name, so currently you must know the type of extended memory that should be supported. There is no autodetect capability.
> Availability

>   cc65

> See also

>   em_unload

> Example

>   None.

## 3.108 em_map

> Function

>   Make a page of extended memory accessible.

> Header

>   `em.h`

> Declaration

>   `void* __fastcall__ em_map (unsigned page);`

> Description

>   The function maps one page of extended memory into linear memory and returns a pointer to the page frame. Depending on the hardware and driver, the data is either mapped into the address space or transfered into a buffer. If you don't need the actual contents of the page (for example because you're going to overwrite it completely), it is better to call `em_use` instead. `em_use` will not transfer the data if it is possible to avoid that.

> Notes

>   - Calling `em_map` will invalidate the memory window, so if you made any changes to the data in the window, call `em_commit` first, or the changes are lost.
>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
>   - The function produces undefined results if no extended memory driver is loaded.
> Availability

>   cc65

> See also

>   em_commit, em_load_driver, em_use

> Example

>   None.

## 3.109 em_pagecount

> Function

>   Return the number of available extended memory pages.

> Header

>   `em.h`

> Declaration

>   `unsigned em_pagecount (void);`

> Description

>   The function returns the size of the extended memory supported by the driver in 256 byte pages.

> Notes

>   - The function returns zero if no extended memory driver is loaded.
>   - The function may return zero if the supported hardware was not detected.
> Availability

>   cc65

> See also

>   em_load_driver

> Example

>   None.

## 3.110 em_uninstall

> Function

>   Uninstall an already loaded extended memory driver.

> Header

>   `em.h`

> Declaration

>   `unsigned char em_uninstall (void);`

> Description

>   The function uninstalls an already loaded extended memory driver but doesn't remove it from memory.

> Notes

>   - If the driver has been loaded using `em_load_driver`, `em_unload` should be used instead of `em_uninstall` so the driver is also removed from memory.
> Availability

>   cc65

> See also

>   em_install, em_load_driver, em_unload

> Example

>   None.

## 3.111 em_unload

> Function

>   Unload an extended memory driver.

> Header

>   `em.h`

> Declaration

>   `unsigned char em_unload (void);`

> Description

>   The function unloads a loaded extended memory driver and frees all memory allocated for the driver.

> Notes

>   - The function does nothing if no driver is loaded.
> Availability

>   cc65

> See also

>   em_load_driver

> Example

>   None.

## 3.112 em_use

> Function

>   Prepare an extended memory page for use.

> Header

>   `em.h`

> Declaration

>   `void* __fastcall__ em_use (unsigned page);`

> Description

>   The function maps one page of extended memory into linear memory and returns a pointer to the page frame. This function is similar to `em_map`, but will not transfer data into the actual memory window in the assumption that the existing data is wrong or will get overwritten.

> Notes

>   - Calling `em_use` will invalidate the memory window, so if you made any changes to the data in the window, call `em_commit` first, or the changes are lost.
>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
>   - The function produces undefined results if no extended memory driver is loaded.
> Availability

>   cc65

> See also

>   em_commit, em_load_driver, em_map

> Example

>   None.

## 3.113 exit

> Function

>   Terminate the program.

> Header

>   `stdlib.h`

> Declaration

>   `void __fastcall__ exit (int status);`

> Description

>   `exit` terminates the program. The argument specifies the return code of the program. Before termination, all files are closed, buffered output is written and any functions registered with `atexit` are called. Common values for status are `EXIT_SUCCESS` and `EXIT_FAILURE` which are also defined in `stdlib.h`.

> Notes

>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
>   - It depends on the host machine if the program return code can be evaluated or is ignored.
> Availability

>   ISO 9899

> See also

>   abort, exit

> Example

>   None.

## 3.114 exec

> Function

>   Execute a program file.

> Header

>   `unistd.h`

> Declaration

>   `int __fastcall__ exec (const char* progname, const char* cmdline);`

> Description

>   `exec` replaces the currently running program by a new one. Calling `exec()` is identical to calling `exit()`, then loading and starting the program named in the first argument, passing the command line specified as second argument. Instead of an empty string, a `NULL` pointer may be passed as second parameter. On success, the function does not return. On failure, -1 is returned and `errno` contains an error code.

> Notes

>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
>   - On most platforms, the function needs to copy a small stub loader to some memory area outside the program space. This may collide with other programs. See the platform specific docs on this.
>   - Because it is necessary to terminate the running program before the memory can be reused to load the new one, there is a high chance that the function may not be able to return on errors.
>   - The command line is passed to the new program in the same way as cc65 programs expect the command line. If the new program is not a cc65 generated program, it may not be able to read it.
> Availability

>   cc65

> See also

>   exit

> Example

>   None.

## 3.115 fast

> Function

>   Switch the CPU into fast mode (C128: 2MHz mode, C16/Plus4: double clock mode).

> Header

>   `c128.h, c16.h, plus4.h`

> Declaration

>   `void fast (void);`

> Description

>   The function will switch the clock of the CPU to fast mode. For the C128 target it means switching the CPU into 2MHz mode. For the C16/Plus4 target it means switching the CPU into double clock mode.

> Notes

>   - The function is specific to the C128, C16 and Plus4.
>   - On the C128 the 2MHz clock will not work in 40 column mode.
> Availability

>   cc65 (not all platforms)

> See also

>   isfast, slow,

> Example

>   None.

## 3.116 feof

> Function

>   Return the end-of-file indicator of a stream.

> Header

>   `stdio.h`

> Declaration

>   `int __fastcall__ feof (FILE* f);`

> Description

>   `feof` tests the end-of-file indicator ofthe stream `f`, and returns a non zero value if it is set.

> Notes

>   - The indicator is set only after a read past the end of a file is attempted.
>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
> Availability

>   ISO 9899

> See also

>   clearerr, ferror

> Example

>   None.

## 3.117 ferror

> Function

>   Return the error indicator of a stream.

> Header

>   `stdio.h`

> Declaration

>   `int __fastcall__ ferror (FILE* f);`

> Description

>   `ferror` tests the error indicator of the stream `f`, and returns a non zero value if it is set.

> Notes

>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
> Availability

>   ISO 9899

> See also

>   clearerr, feof

> Example

>   None.

## 3.118 fileno

> Function

>   Return the file handle used by a stream.

> Header

>   `stdio.h`

> Declaration

>   `int __fastcall__ fileno (FILE* f);`

> Description

>   The `fileno` function returns the file handle used internally by a C stream. This file handle (an integer) can be used as a handle for the POSIX input/output functions.

> Notes

>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
>   - Mixing C file I/O functions and POSIX file I/O functions for the same file may have unpredictable results.
> Availability

>   POSIX 1003.1

> See also

>   creat, open

> Example

>   None.

## 3.119 free

> Function

>   Free a block of dynamic memory.

> Header

>   `stdlib.h`

> Declaration

>   `void __fastcall__ free (void* block);`

> Description

>   Free a block of dynamic memory previously allocated with `malloc`, `calloc` or `realloc`. As an exception, if the passed pointer is `NULL`, no action is performed.

> Notes

>   - Passing an already free'd block to `free` again will cause undefined behaviour and may crash your program.
>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
> Availability

>   ISO 9899

> See also

>   _heapadd, _heapblocksize, _heapmaxavail, _heapmemavail, calloc, malloc, realloc

> Example

>   None.

## 3.120 get_ostype

> Function

>   The function returns the operating system, the program runs on.

> Header

>   `apple2.h, atari.h, c64.h`

> Declaration

>   `unsigned char get_ostype (void);`

> Description

>   `get_ostype` is machine dependent and does not exist for all supported targets. If it exists, it returns a number that identifies the operating system or machine type, the program runs on. The machine dependent header files define constants that can be used to check the return code.

> Notes

>   - The function does not exist on all platforms.
>   - The return codes are platform dependent.
> Availability

>   cc65 (not all platforms)

> Example

>   None.

## 3.121 get_c128_speed

> Function

>   Get the current speed of the C128 CPU.

> Header

>   `accelerator.h`

> Declaration

>   `unsigned char get_c128_speed (void);`

> Description

>   The function returns the current speed of the C128 CPU.

> Notes

>   - The function is specific to the C64 and C128.
>   - The function does not check if the C128 CPU is the current CPU.
>   - See the accelerator.h header for the speed definitions.
> Availability

>   cc65 (not all platforms)

> See also

>   detect_c128, set_c128_speed,

> Example

>   None.

## 3.122 get_c64dtv_speed

> Function

>   Get the current speed of the C64DTV.

> Header

>   `accelerator.h`

> Declaration

>   `unsigned char get_c64dtv_speed (void);`

> Description

>   The function returns the current speed of the C64DTV.

> Notes

>   - The function is specific to the C64.
>   - The function does not check for the presence of the C64DTV.
>   - See the accelerator.h header for the speed definitions.
> Availability

>   cc65 (not all platforms)

> See also

>   detect_c64dtv, set_c64dtv_speed,

> Example

>   None.

## 3.123 get_c65_speed

> Function

>   Get the current speed of the C65/C64DX in C64 mode.

> Header

>   `accelerator.h`

> Declaration

>   `unsigned char get_c65_speed (void);`

> Description

>   The function returns the current speed of the C65/C64DX in C64 mode.

> Notes

>   - The function is specific to the C64.
>   - The function does not check for the presence of a C65/C64DX in C64 mode.
>   - See the accelerator.h header for the speed definitions.
> Availability

>   cc65 (not all platforms)

> See also

>   detect_c65, set_c65_speed,

> Example

>   None.

## 3.124 get_chameleon_speed

> Function

>   Get the current speed of the C64 Chameleon cartridge.

> Header

>   `accelerator.h`

> Declaration

>   `unsigned char get_chameleon_speed (void);`

> Description

>   The function returns the current speed of the C64 Chameleon cartridge.

> Notes

>   - The function is specific to the C64.
>   - The function does not check for the presence of the C64 Chameleon cartridge.
>   - See the accelerator.h header for the speed definitions.
> Availability

>   cc65 (not all platforms)

> See also

>   detect_chameleon, set_chameleon_speed,

> Example

>   None.

## 3.125 get_scpu_speed

> Function

>   Get the current speed of the C64/C128 SuperCPU cartridge.

> Header

>   `accelerator.h`

> Declaration

>   `unsigned char get_scpu_speed (void);`

> Description

>   The function returns the current speed of the SuperCPU cartridge.

> Notes

>   - The function is specific to the C128 and C64.
>   - The function does not check for the presence of the cartridge.
>   - See the accelerator.h header for the speed definitions.
> Availability

>   cc65 (not all platforms)

> See also

>   detect_scpu, set_scpu_speed,

> Example

>   None.

## 3.126 get_turbomaster_speed

> Function

>   Get the current speed of the C64 Turbo Master cartridge.

> Header

>   `accelerator.h`

> Declaration

>   `unsigned char get_turbomaster_speed (void);`

> Description

>   The function returns the current speed of the C64 Turbo Master cartridge.

> Notes

>   - The function is specific to the C64.
>   - The function does not check for the presence of the C64 Turbo Master cartridge.
>   - See the accelerator.h header for the speed definitions.
> Availability

>   cc65 (not all platforms)

> See also

>   detect_turbomaster, set_turbomaster_speed,

> Example

>   None.

## 3.127 getcpu

> Function

>   Determine on which CPU the program is running.

> Header

>   `6502.h`

> Declaration

>   `unsigned char getcpu (void);`

> Description

>   The function checks on which CPU the code is running. It returns one of the constants

>   - `CPU_6502`
>   - `CPU_65C02`
>   - `CPU_65816`
>   - `CPU_4510`
>   - `CPU_65SC02`
>   - `CPU_65CE02`
>   - `CPU_HUC6280`
>   - `CPU_2A0x`
> Notes

>   - Other, more exotic CPU types are not disinguished.
> Availability

>   cc65

> Example

>   None.

## 3.128 getcurrentdevice

> Function

>   Get current device.

> Header

>   `device.h`

> Declaration

>   `unsigned char getcurrentdevice (void);`

> Description

>   The function returns the current device. It allows to access the current device with the Low-level disk I/O API or cbm_* I/O functions requiring a 'device' parameter.

> Availability

>   cc65

> See also

>   getdevicedir, getfirstdevice, getnextdevice

> Example

>       dio_open (getcurrentdevice ());

## 3.129 getcwd

> Function

>   Get current working directory.

> Header

>   `unistd.h`

> Declaration

>   `char* __fastcall__ getcwd (char* buf, size_t size);`

> Description

>   The function will return the current working directory.

> Notes

>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
> Availability

>   POSIX 1003.1

> Example

>   None.

## 3.130 getdevicedir

> Function

>   Get device directory.

> Header

>   `device.h`

> Declaration

>   `char* __fastcall__ getdevicedir (unsigned char device, char* buf, size_t size);`

> Description

>   The function returns the directory representing `device`. It allows to access the device on filesystem level by calling chdir() with the directory returned.

> Notes

>   - Calling getdevicedir() does check for a (formatted) disk in a floppy-disk-type device and returns NULL if that check fails.
>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
> Availability

>   cc65

> See also

>   getcwd, getcurrentdevice, getfirstdevice, getnextdevice

> Example

>       chdir (getdevicedir (device, buf, sizeof buf));

>   cf. `samples`enumdevdir.c/

## 3.131 getenv

> Function

>   Return a value from the environment.

> Header

>   `stdlib.h`

> Declaration

>   `char* __fastcall__ getenv (const char* name);`

> Description

>   The function searches the environment for an entry that matches `name` and returns its value. The environment consists of a list of strings in the form `name=value`. If there is no match, `getenv` returns `NULL`.

> Notes

>   - What exactly is stored in the environment depends on the machine the program is running on.
>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
> Availability

>   ISO 9899

> Example

>   None.

## 3.132 getfirstdevice

> Function

>   Get first device.

> Header

>   `device.h`

> Declaration

>   `unsigned char getfirstdevice (void);`

> Description

>   The function returns the first device. The constant `INVALID_DEVICE` indicates no device.

> Notes

>   - Calling getfirstdevice() does not turn on the motor of a drive-type device and does not check for a disk in the drive.
> Availability

>   cc65

> See also

>   getcurrentdevice, getdevicedir, getnextdevice

> Example

>       unsigned char dev = getfirstdevice ();
>       while (dev != INVALID_DEVICE) {
>               printf ("%d\n", dev);
>               dev = getnextdevice (dev);
>               }

## 3.133 getnextdevice

> Function

>   Get next device.

> Header

>   `device.h`

> Declaration

>   `unsigned char __fastcall__ getnextdevice (unsigned char device);`

> Description

>   The function returns the next device after `device`. The constant `INVALID_DEVICE` indicates no further device.

> Notes

>   - Calling getnextdevice() does not turn on the motor of a drive-type device and does not check for a disk in the drive.
>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
> Availability

>   cc65

> See also

>   getcurrentdevice, getdevicedir, getfirstdevice

> Example

>       unsigned char dev = getfirstdevice ();
>       while (dev != INVALID_DEVICE) {
>               printf ("%d\n", dev);
>               dev = getnextdevice (dev);
>               }

## 3.134 getopt

> Function

>   Parse command line options.

> Header

>   `unistd.h`

> Declaration

>   `int __fastcall__ getopt (int argc, char* const* argv, const char* optstring);`

> Description

>   The function parses command line arguments, `argc` and `argv` are the argument count and array passed to `main`. `optstring` is a string that contains command line option characters. If a character in `optstring` is followed by a colon, the option requires an argument. An option on the command line is recognized if it is one of the option characters preceeded by a '-'. `getopt` must be called repeatedly. It will return each option character found on the command line and `EOF` (-1) if there is no other option. An option argument is placed in `optarg`, the index of the next element on the command line to be processed is placed in `optind`.

> Notes

>   - The implementation will not reorder options. A non option on the command line will terminate option processing. All remaining arguments are not recognized as options, even if the start with a '-' character.
>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
> Availability

>   POSIX.2

> Example

>   None.

## 3.135 gotox

> Function

>   Move the text mode cursor to a new X position.

> Header

>   `conio.h`

> Declaration

>   `void __fastcall__ gotox (unsigned char x);`

> Description

>   The function moves the text mode cursor to the specified X position while leaving the Y position untouched. The leftmost position on the screen has the coordinate 0.

> Notes

>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
>   - Invalid values for the X position (out of screen coordinates) may lead to undefined behaviour.
> Availability

>   cc65

> See also

>   gotoy, gotoxy, wherex, wherey

> Example

>   None.

## 3.136 gotoxy

> Function

>   Move the text mode cursor to a new position.

> Header

>   `conio.h`

> Declaration

>   `void __fastcall__ gotoxy (unsigned char x, unsigned char y);`

> Description

>   The function moves the text mode cursor to the specified position. The leftmost position on the screen has the X coordinate 0, the topmost line has the Y coordinate 0.

> Notes

>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
>   - Invalid values for any of both coordinates (out of screen positions) may lead to undefined behaviour.
> Availability

>   cc65

> See also

>   gotox, gotoy, wherex, wherey

> Example

>   None.

## 3.137 gotoy

> Function

>   Move the text mode cursor to a new Y position.

> Header

>   `conio.h`

> Declaration

>   `void __fastcall__ gotoy (unsigned char x);`

> Description

>   The function moves the text mode cursor to the specified Y position while leaving the X position untouched. The uppermost position on the screen has the coordinate 0.

> Notes

>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
>   - Invalid values for the Y position (out of screen coordinates) may lead to undefined behaviour.
> Availability

>   cc65

> See also

>   gotox, gotoxy, wherex, wherey

> Example

>   None.

## 3.138 isalnum

> Function

>   Check if a given character is a letter or digit.

> Header

>   `ctype.h`

> Declaration

>   `int __fastcall__ isalnum (int c);`

> Description

>   The function returns a non zero value if the given argument is a letter or digit. The return value is zero if the character is anything else.

> Notes

>   - When compiling without `-Os`, the function is only available as fastcall function, so it may only be used in presence of a prototype.
> Availability

>   ISO 9899

> See also

>   isalpha, isascii, isblank, iscntrl, isdigit, isgraph, islower, isprint, ispunct, isspace, isupper, isxdigit

> Example

>   None.

## 3.139 isalpha

> Function

>   Check if a given character is a letter.

> Header

>   `ctype.h`

> Declaration

>   `int __fastcall__ isalpha (int c);`

> Description

>   The function returns a non zero value if the given argument is a letter. The return value is zero if the character is anything else.

> Notes

>   - When compiling without `-Os`, the function is only available as fastcall function, so it may only be used in presence of a prototype.
> Availability

>   ISO 9899

> See also

>   isalnum, isascii, isblank, iscntrl, isdigit, isgraph, islower, isprint, ispunct, isspace, isupper, isxdigit

> Example

>   None.

## 3.140 isascii

> Function

>   Check if a given character is in the ASCII (0..127) range.

> Header

>   `ctype.h`

> Declaration

>   `int __fastcall__ isascii (int c);`

> Description

>   The function returns a non zero value if the given argument is in the range 0..127 (the range of valid ASCII characters), and zero if not.

> Notes

>   - When compiling without `-Os`, the function is only available as fastcall function, so it may only be used in presence of a prototype.
> Availability

>   ISO 9899

> See also

>   isalnum, isalpha, isblank, iscntrl, isdigit, isgraph, islower, isprint, ispunct, isspace, isupper, isxdigit

> Example

>   None.

## 3.141 isblank

> Function

>   Check if a given character is a space or tab.

> Header

>   `ctype.h`

> Declaration

>   `int __fastcall__ isblank (int c);`

> Description

>   The function returns a non zero value if the given argument is a space or tab character. The return value is zero if the character is anything else.

> Notes

>   - When compiling without `-Os`, the function is only available as fastcall function, so it may only be used in presence of a prototype.
> Availability

>   ISO 9899

> See also

>   isalnum, isalpha, isascii, iscntrl, isdigit, isgraph, islower, isprint, ispunct, isspace, isupper, isxdigit

> Example

>   None.

## 3.142 iscntrl

> Function

>   Check if a given character is a control character.

> Header

>   `ctype.h`

> Declaration

>   `int __fastcall__ iscntrl (int c);`

> Description

>   The function returns a non zero value if the given argument is a control character. The return value is zero if the character is anything else.

> Notes

>   - When compiling without `-Os`, the function is only available as fastcall function, so it may only be used in presence of a prototype.
> Availability

>   ISO 9899

> See also

>   isalnum, isalpha, isascii, isblank, isdigit, isgraph, islower, isprint, ispunct, isspace, isupper, isxdigit

> Example

>   None.

## 3.143 isdigit

> Function

>   Check if a given character is a digit.

> Header

>   `ctype.h`

> Declaration

>   `int __fastcall__ isdigit (int c);`

> Description

>   The function returns a non zero value if the given argument is a digit. The return value is zero if the character is anything else.

> Notes

>   - When compiling without `-Os`, the function is only available as fastcall function, so it may only be used in presence of a prototype.
> Availability

>   ISO 9899

> See also

>   isalnum, isalpha, isascii, isblank, iscntrl, isgraph, islower, isprint, ispunct, isspace, isupper, isxdigit

> Example

>   None.

## 3.144 isfast

> Function

>   Check if the CPU is in fast mode (C128: 2MHz mode, C16/Plus4: double clock mode).

> Header

>   `c128.h, c16.h, plus4.h`

> Declaration

>   `unsigned char isfast (void);`

> Description

>   The function returns a 1 if the CPU is in fast mode (C128: 2MHz mode, C16/Plus4: double clock mode).

> Notes

>   - The function is specific to the C128, C16 and Plus4.
> Availability

>   cc65 (not all platforms)

> See also

>   fast, slow,

> Example

>   None.

## 3.145 isgraph

> Function

>   Check if a given character is a printable character (except space).

> Header

>   `ctype.h`

> Declaration

>   `int __fastcall__ isgraph (int c);`

> Description

>   The function returns a non zero value if the given argument is a printable character with the exception of space. The return value is zero if the character is anything else.

> Notes

>   - When compiling without `-Os`, the function is only available as fastcall function, so it may only be used in presence of a prototype.
> Availability

>   ISO 9899

> See also

>   isalnum, isalpha, isascii, isblank, iscntrl, isdigit, islower, isprint, ispunct, isspace, isupper, isxdigit

> Example

>   None.

## 3.146 islower

> Function

>   Check if a given character is a lower case letter.

> Header

>   `ctype.h`

> Declaration

>   `int __fastcall__ islower (int c);`

> Description

>   The function returns a non zero value if the given argument is a lower case letter. The return value is zero if the character is anything else.

> Notes

>   - When compiling without `-Os`, the function is only available as fastcall function, so it may only be used in presence of a prototype.
> Availability

>   ISO 9899

> See also

>   isalnum, isalpha, isascii, isblank, iscntrl, isdigit, isgraph, isprint, ispunct, isspace, isupper, isxdigit

> Example

>   None.

## 3.147 isprint

> Function

>   Check if a given character is a printable character.

> Header

>   `ctype.h`

> Declaration

>   `int __fastcall__ isprint (int c);`

> Description

>   The function returns a non zero value if the given argument is a printable character (this includes the space character). The return value is zero if the character is anything else.

> Notes

>   - When compiling without `-Os`, the function is only available as fastcall function, so it may only be used in presence of a prototype.
> Availability

>   ISO 9899

> See also

>   isalnum, isalpha, isascii, isblank, iscntrl, isdigit, isgraph, islower, ispunct, isspace, isupper, isxdigit

> Example

>   None.

## 3.148 ispunct

> Function

>   Check if a given character is a printable character but not a space or an alphanumeric character.

> Header

>   `ctype.h`

> Declaration

>   `int __fastcall__ ispunct (int c);`

> Description

>   The function returns a non zero value if the given argument is a printable character, but not a space or anything alphanumeric. The return value is zero if the character is anything else.

> Notes

>   - When compiling without `-Os`, the function is only available as fastcall function, so it may only be used in presence of a prototype.
> Availability

>   ISO 9899

> See also

>   isalnum, isalpha, isascii, isblank, iscntrl, isdigit, isgraph, islower, isprint, isspace, isupper, isxdigit

> Example

>   None.

## 3.149 isspace

> Function

>   Check if a given character is a white-space character.

> Header

>   `ctype.h`

> Declaration

>   `int __fastcall__ isspace (int c);`

> Description

>   The function returns a non zero value if the given argument is a white space character. The return value is zero if the character is anything else. The standard white space characters are: space, formfeed ('\f'), newline ('\n'), carriage return ('\r'), horizontal tab ('\t'), and vertical tab ('\v').

> Notes

>   - When compiling without `-Os`, the function is only available as fastcall function, so it may only be used in presence of a prototype.
> Availability

>   ISO 9899

> See also

>   isalnum, isalpha, isascii, isblank, iscntrl, isdigit, isgraph, islower, isprint, ispunct, isupper, isxdigit

> Example

>   None.

## 3.150 isupper

> Function

>   Check if a given character is an upper case letter.

> Header

>   `ctype.h`

> Declaration

>   `int __fastcall__ isupper (int c);`

> Description

>   The function returns a non zero value if the given argument is an upper case letter. The return value is zero if the character is anything else.

> Notes

>   - When compiling without `-Os`, the function is only available as fastcall function, so it may only be used in presence of a prototype.
> Availability

>   ISO 9899

> See also

>   isalnum, isalpha, isascii, isblank, iscntrl, isdigit, isgraph, islower, isprint, ispunct, isspace, isxdigit

> Example

>   None.

## 3.151 isxdigit

> Function

>   Check if a given character is a hexadecimal digit.

> Header

>   `ctype.h`

> Declaration

>   `int __fastcall__ isxdigit (int c);`

> Description

>   The function returns a non zero value if the given argument is a hexadecimal digit (0..9, a..f and A..F). The return value is zero if the character is anything else.

> Notes

>   - When compiling without `-Os`, the function is only available as fastcall function, so it may only be used in presence of a prototype.
> Availability

>   ISO 9899

> See also

>   isalnum, isalpha, isascii, isblank, iscntrl, isdigit, isgraph, islower, isprint, ispunct, isspace, isupper

> Example

>   None.

## 3.152 itoa

> Function

>   Convert an integer into a string.

> Header

>   `stdlib.h`

> Declaration

>   `char* __fastcall__ itoa (int val, char* buf, int radix);`

> Description

>   `itoa` converts the integer `val` into a string using `radix` as the base.

> Notes

>   - There are no provisions to prevent a buffer overflow.
>   - If `val` contains `INT_MIN`, the behaviour is undefined.
>   - The function is non standard, so it is not available in strict ANSI mode. You should probably use `sprintf` instead.
>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
> Availability

>   cc65

> See also

>   atoi, atol, ltoa, ultoa, utoa

> Example

>   None.

## 3.153 joy_count

> Function

>   Return the number of joysticks supported by the current driver.

> Header

>   `joystick.h`

> Declaration

>   `unsigned char joy_count (void);`

> Description

>   The function returns a the number of joysticks supported by the current joystick driver.

> Notes

>   - A joystick driver must be loaded using joy_load_driver before calling this function.
>   - The function returns the number of joysticks supported by the driver. There's no way to check for the number of actually connected joysticks.
> Availability

>   cc65

> See also

>   joy_load_driver, joy_read

> Example

>   None.

## 3.154 joy_install

> Function

>   Install an already loaded driver and return an error code.

> Header

>   `joystick.h`

> Declaration

>   `unsigned char __fastcall__ joy_install (void* driver);`

> Description

>   The function installs a driver that was already loaded into memory (or linked statically to the program). It returns an error code (`JOY_ERR_OK` in case of success).

> Notes

>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
> Availability

>   cc65

> See also

>   joy_load_driver, joy_uninstall, joy_unload

> Example

>   None.

## 3.155 joy_load_driver

> Function

>   Load a driver from disk and install it.

> Header

>   `joystick.h`

> Declaration

>   `unsigned char __fastcall__ joy_load_driver (const char* driver);`

> Description

>   The function loads a driver with the given name from disk and installs it. An error code is returned, which is `JOY_ERR_OK` if the driver was successfully loaded and installed.

> Notes

>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
> Availability

>   cc65

> See also

>   joy_install, joy_uninstall, joy_unload

> Example

>   None.

## 3.156 joy_read

> Function

>   Read the status of a joystick.

> Header

>   `joystick.h`

> Declaration

>   `unsigned char __fastcall__ joy_read (unsigned char joystick);`

> Description

>   The function reads the status bits for a joystick. The number of the joystick is passed as parameter. The result may be examined by using one of the `JOY_xxx` macros from joystick.h.

> Notes

>   - A joystick driver must be loaded using joy_load_driver before calling this function.
>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
> Availability

>   cc65

> See also

>   joy_count, joy_load_driver, joy_unload

> Example

>   None.

## 3.157 joy_uninstall

> Function

>   Uninstall the current joystick driver.

> Header

>   `joystick.h`

> Declaration

>   `unsigned char joy_uninstall (void);`

> Description

>   The function uninstalls the currently installed joystick driver. It does not remove the driver from memory. The function returns an error code, which is `JOY_ERR_OK` if the driver was successfully uninstalled.

> Notes

>   - A joystick driver must be installed using joy_install before calling this function.
> Availability

>   cc65

> See also

>   joy_install, joy_load_driver, joy_unload

> Example

>   None.

## 3.158 joy_unload

> Function

>   Uninstall, then unload the current joystick driver.

> Header

>   `joystick.h`

> Declaration

>   `unsigned char joy_unload (void);`

> Description

>   The function uninstalls the currently installed joystick driver and removes it from memory. An error code is returned, which is `JOY_ERR_OK` if the driver was successfully uninstalled.

> Notes

>   - A joystick driver must be loaded using joy_load_driver before calling this function.
> Availability

>   cc65

> See also

>   joy_load_driver

> Example

>   None.

## 3.159 kbhit

> Function

>   Check if there's a key waiting in the keyboard buffer.

> Header

>   `conio.h`

> Declaration

>   `unsigned char kbhit (void);`

> Description

>   The function returns a value of zero if there is no character waiting to be read from the keyboard. It returns non zero otherwise.

> Notes

>   - If the system does not support a keyboard buffer (most systems do), the function is rather useless.
> Availability

>   cc65

> See also

>   cgetc, cursor

> Example

>   None.

## 3.160 kbrepeat

> Function

>   Set the keyboard repeat mode.

> Header

>   `cbm.h`

> Declaration

>   `unsigned char __fastcall__ kbrepeat (unsigned char mode);`

> Description

>   This function changes which keys have automatic repeat when being held down for a certain time. Possible values are `KBREPEAT_CURSOR` (repeat only cursor-related keys), `KBREPEAT_NONE` (no repeat for any keys), and `KBREPEAT_ALL` (repeat all keys). The old mode is returned, so it can be restored later.

> Notes

>   - The function is available only as a fastcall function; so, it may be used only in the presence of a prototype.
> Availability

>   cc65

> Example

>   None.

## 3.161 labs

> Function

>   Returns the absolute value of a long integer.

> Header

>   `stdlib.h`

> Declaration

>   `long __fastcall__ labs (long v);`

> Description

>   `labs` returns the absolute value of the argument passed to the function.

> Notes

>   - The return value is undefined if `LONG_MIN` is passed to the function.
>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
> Availability

>   ISO 9899

> See also

>   abs

> Example

>   None.

## 3.162 ltoa

> Function

>   Convert a long integer into a string.

> Header

>   `stdlib.h`

> Declaration

>   `char* __fastcall__ ltoa (long val, char* buf, int radix);`

> Description

>   `itoa` converts the long integer `val` into a string using `radix` as the base.

> Notes

>   - There are no provisions to prevent a buffer overflow.
>   - If `val` contains `LONG_MIN`, the behaviour is undefined.
>   - The function is non standard, so it is not available in strict ANSI mode. You should probably use `sprintf` instead.
>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
> Availability

>   cc65

> See also

>   atoi, atol, itoa, ultoa, utoa

> Example

>   None.

## 3.163 localeconv

> Function

>   Returns a pointer to the current locale structure.

> Header

>   `locale.h`

> Declaration

>   `struct lconv* localeconv (void);`

> Description

>   `localeconv` returns a pointer to the current locale structure.

> Notes

>   - cc65 supports only the "C" locale, so even after setting a new locale using `setlocale`, the structure returned will always be the same.
> Availability

>   ISO 9899

> See also

>   setlocale

> Example

>   None.

## 3.164 longjmp

> Function

>   Non local goto.

> Header

>   `setjmp.h`

> Declaration

>   `void __fastcall__ longjmp (jmp_buf buf, int retval);`

> Description

>   The `longjmp` function restores a program context from the data in `buf`, which must have been set by a preceeding call to `setjmp`. Program execution continues as if the call to `setjmp` has just returned the value `retval`.

> Notes

>   - If the parameter `retval` is zero, the function will behave as if it was called with a value of one.
>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
> Availability

>   ISO 9899

> See also

>   setjmp

> Example

>   None.

## 3.165 malloc

> Function

>   Allocate dynamic memory.

> Header

>   `stdlib.h`

> Declaration

>   `void* __fastcall__ malloc (size_t size);`

> Description

>   `malloc` allocates size bytes on the heap and returns a pointer to the allocated memory block. On error (not enough memory available), `malloc` returns `NULL`.

> Notes

>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
> Availability

>   ISO 9899

> See also

>   _heapadd, _heapblocksize, _heapmaxavail, _heapmemavail, calloc, free, realloc, strdup

> Example

>   None.

## 3.166 memchr

> Function

>   Search for a character in a block of raw memory.

> Header

>   `string.h`

> Declaration

>   `void* __fastcall__ strchr (const void* mem, int c, size_t count);`

> Description

>   The `memchr` function locates the first occurrence of `c` (converted to a char) in the block of raw memory string pointed to by `mem` that is of size `count`. Upon completion, the function returns a pointer to the character found, or a null pointer if the character was not found.

> Notes

>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
> Availability

>   ISO 9899

> See also

>   strchr

> Example

>   None.

## 3.167 memcmp

> Function

>   Compare two memory areas.

> Header

>   `string.h`

> Declaration

>   `int __fastcall__ memcmp (const void* p1, const void* p2, size_t count);`

> Description

>   `memcmp` compares `count` bytes from the memory area pointed to by `p1` into the memory area pointed to by `p2`. It returns a value that is less than zero if `p1` is less than `p2`, zero if `p1` is the same as `p2`, and a value greater than zero if `p1` is greater than `p2`.

> Notes

>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
> Availability

>   ISO 9899

> See also

>   strcmp, memmove, memset

> Example

>   None.

## 3.168 memcpy

> Function

>   Copy a memory area.

> Header

>   `string.h`

> Declaration

>   `void* __fastcall__ memcpy (void* dest, const void* src, size_t count);`

> Description

>   `memcpy` copies `count` bytes from the memory area pointed to by `src` into the memory area pointed to by `dest`. It returns `dest`.

> Notes

>   - The result is undefined if the memory areas do overlap. Use `memmove` to copy overlapping memory areas.
>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
> Availability

>   ISO 9899

> See also

>   _swap, memmove, memset

> Example

>   None.

## 3.169 memmove

> Function

>   Copy a memory area.

> Header

>   `string.h`

> Declaration

>   `void* __fastcall__ memmove (void* dest, const void* src, size_t count);`

> Description

>   `memmove` copies `count` bytes from the memory area pointed to by `src` into the memory area pointed to by `dest`. It returns `dest`.

> Notes

>   - While `memmove` allows the memory areas to overlap, it has some additional overhead compared to `memcpy`.
>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
> Availability

>   ISO 9899

> See also

>   _swap, memcpy, memset

> Example

>   None.

## 3.170 memset

> Function

>   Fill a memory area.

> Header

>   `string.h`

> Declaration

>   `void* __fastcall__ memset (void* p, int val, size_t count);`

> Description

>   `memset` fills the memory area pointed to by `p` with the value `val`. The function returns `p`.

> Notes

>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
> Availability

>   ISO 9899

> See also

>   _swap, bzero, memcpy, memmove

> Example

>   None.

## 3.171 mod_free

> Function

>   Free a relocatable module.

> Header

>   `modload.h`

> Declaration

>   `void __fastcall__ mod_free (void* module);`

> Description

>   The function will free a module loaded into memory by use of the `mod_load` function.

> Notes

>   - The pointer passed as parameter is the pointer to the module memory, not the pointer to the control structure.
>   - The function is available only as a fastcall function; so, it may be used only in the presence of a prototype.
> Availability

>   cc65

> See also

>   mod_load

> Example

>   None.

## 3.172 mod_load

> Function

>   Load a relocatable module.

> Header

>   `modload.h`

> Declaration

>   `unsigned char __fastcall__ mod_load (struct mod_ctrl* ctrl);`

> Description

>   The function will load a code module into memory and relocate it. The function will return an error code. If `MLOAD_OK` is returned, the outgoing fields in the passed `mod_ctrl` struct contain information about the module just loaded. Possible error codes are:

>   - `MLOAD_OK` - Module load successful
>   - `MLOAD_ERR_READ` - Read error
>   - `MLOAD_ERR_HDR` - Header error
>   - `MLOAD_ERR_OS` - Wrong operating system
>   - `MLOAD_ERR_FMT` - Data format error
>   - `MLOAD_ERR_MEM` - Not enough memory
> Notes

>   - The ld65 linker is needed to create relocatable o65 modules for use with this function.
>   - The function is available only as a fastcall function; so, it may be used only in the presence of a prototype.
> Availability

>   cc65

> See also

>   mod_free

> Example

>   None.

## 3.173 mouse_setbox

> Function

>   Specify a bounding box for the mouse cursor.

> Header

>   `mouse.h`

> Declaration

>   `void __fastcall__ mouse_setbox (const struct mouse_box* box);`

> Description

>   The function allows to set a bounding box for mouse movement.

> Notes

>   - The function does not check if the mouse cursor is currently within the given rectangle. Placing the mouse cursor within the bounding box is the responsibility of the programmer.
>   - While the bounding box may be larger than the actual screen size, the standard mouse cursor draw routines may fail to set the cursor to coordinates outside of the screen area. Depending on the platform, you may have to supply your own mouse cursor routines.
>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
> Availability

>   cc65

> See also

>   mouse_getbox, mouse_move

> Example

>   None.

## 3.174 mouse_getbox

> Function

>   Return the current bounding box for the mouse cursor.

> Header

>   `mouse.h`

> Declaration

>   `void __fastcall__ mouse_getbox (struct mouse_box* box);`

> Description

>   The function queries the current bounding box for mouse movement.

> Notes

>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
> Availability

>   cc65

> See also

>   mouse_move, mouse_setbox

> Example

>   None.

## 3.175 mouse_buttons

> Function

>   Return a bit mask encoding the state of the mouse buttons.

> Header

>   `mouse.h`

> Declaration

>   `unsigned char mouse_buttons (void);`

> Description

>   The function returns a bit mask that encodes the state of the mouse buttons. You may use the `MOUSE_BTN_XXX` flags to decode the function return value.

> Availability

>   cc65

> See also

>   mouse_info, mouse_pos

> Example

>   None.

## 3.176 mouse_geterrormsg

> Function

>   Return a readable error message for an error code.

> Header

>   `mouse.h`

> Declaration

>   `const char* __fastcall__ mouse_geterrormsg (unsigned char code);`

> Description

>   The function returns an error message (in english) for the error code passed parameter.

> Notes

>   - The function will return "Unknown error" for invalid error codes.
>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
> Availability

>   cc65

> See also

>   mouse_load_driver, mouse_uninstall, mouse_unload

> Example

>   None.

## 3.177 mouse_hide

> Function

>   Hide the mouse pointer.

> Header

>   `mouse.h`

> Declaration

>   `void mouse_hide (void);`

> Description

>   The function hides the mouse pointer. It manages a counter that is shared between `mouse_show` and `mouse_hide` so that every call call to `mouse_hide` must be followed by a call to `mouse_show` to make the mouse cursor visible.

> Availability

>   cc65

> See also

>   mouse_show

> Example

>   None.

## 3.178 mouse_info

> Function

>   Return the state of the mouse buttons and the position of the mouse.

> Header

>   `mouse.h`

> Declaration

>   `void __fastcall__ mouse_info (struct mouse_info* info);`

> Description

>   The function returns the state of the mouse buttons and the position of the mouse in the `mouse_info` structure passed as parameter.

> Notes

>   - The `mouse_info` struct is a superset of the `mouse_pos` struct, so if you just need the mouse position, call `mouse_pos` instead.
>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
> Availability

>   cc65

> See also

>   mouse_buttons, mouse_pos

> Example

>   None.

## 3.179 mouse_install

> Function

>   Install an already loaded mouse driver.

> Header

>   `mouse.h`

> Declaration

>   `unsigned char __fastcall__ mouse_install (const struct mouse_callbacks* c, void* driver);`

> Description

>   The function installs an already loaded mouse driver and returns an error code. The `mouse_callbacks` structure passed as first parameter contains pointers to routines needed to move or hide/show the mouse pointer. Defaults for these routines are supplied by the library, so if you can live with these defaults (which are platform specific), just pass a pointer to `mouse_def_callbacks`. The function may be used to install a driver linked statically to the program.

> Notes

>   - Not all drivers are able to detect if the supported hardware is really present.
>   - After installing a driver, the mouse cursor is hidden.
>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
> Availability

>   cc65

> See also

>   mouse_load_driver, mouse_uninstall, mouse_unload

> Example

>   None.

## 3.180 mouse_ioctl

> Function

>   Call the driver specific ioctl function.

> Header

>   `mouse.h`

> Declaration

>   `unsigned char __fastcall__ mouse_ioctl (unsigned char code, void* data);`

> Description

>   The function calls the IOCTL entry in the mouse driver, which is driver specific. The `code` parameter will choose between different IOCTL functions, and the `data` depends on code. The function returns an error code. The purpose of this function is to allow for driver specific extensions. See the documentation for a specific mouse driver for supported ioctl calls.

> Notes

>   - Calling this function is non portable, because each driver may implement different ioctl calls (or none at all).
>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
> Availability

>   cc65

> Example

>   None.

## 3.181 mouse_load_driver

> Function

>   Load and initialize a mouse driver.

> Header

>   `mouse.h`

> Declaration

>   `unsigned char __fastcall__ mouse_load_driver (const struct mouse_callbacks* c, const char* driver);`

> Description

>   Load a mouse driver into memory and initialize it. The function returns an error code that tells if the call has been successful. The `mouse_callbacks` structure passed as first parameter contains pointers to routines needed to move or hide/show the mouse pointer. Defaults for these routines are supplied by the library, so if you can live with these defaults (which are platform specific), just pass a pointer to `mouse_def_callbacks`.

> Notes

>   - The driver is loaded by name, so currently you must know the type of mouse that should be supported. There is no autodetect capability.
>   - Not all drivers are able to detect if the supported hardware is really present.
>   - After installing a driver, the mouse cursor is hidden.
>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
> Availability

>   cc65

> See also

>   mouse_install, mouse_uninstall, mouse_unload

> Example

>   None.

## 3.182 mouse_move

> Function

>   Move the mouse cursor to a specific position.

> Header

>   `mouse.h`

> Declaration

>   `void __fastcall__ mouse_move (int x, int y);`

> Description

>   The function updates the mouse position. If the mouse cursor is visible, it is shown at the new position.

> Notes

>   - The function does not check if the new position is within the bounding box specified with `mouse_setbox`.
>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
> Availability

>   cc65

> See also

>   mouse_getbox, mouse_setbox

> Example

>   None.

## 3.183 mouse_pos

> Function

>   Return the position of the mouse.

> Header

>   `mouse.h`

> Declaration

>   `void __fastcall__ mouse_pos (struct mouse_pos* pos);`

> Description

>   The function returns the position of the mouse in the `mouse_pos` structure passed as parameter.

> Notes

>   - The `mouse_pos` struct is a subset of the `mouse_info` struct, so if you do also need the mouse buttons, call `mouse_info` instead.
>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
> Availability

>   cc65

> See also

>   mouse_buttons, mouse_info

> Example

>   None.

## 3.184 mouse_show

> Function

>   Show the mouse pointer.

> Header

>   `mouse.h`

> Declaration

>   `void mouse_show (void);`

> Description

>   The function shows the mouse pointer. It manages a counter that is shared between `mouse_hide` and `mouse_show`. The mouse cursor is visible if there was one more call to `mouse_show` than to `mouse_hide`.

> Availability

>   cc65

> See also

>   mouse_hide

> Example

>   None.

## 3.185 mouse_uninstall

> Function

>   Uninstall an already loaded mouse driver.

> Header

>   `mouse.h`

> Declaration

>   `unsigned char mouse_uninstall (void);`

> Description

>   The function uninstalls an already loaded mouse driver but don't removes it from memory.

> Notes

>   - If the driver has been loaded using `mouse_load_driver`, `mouse_unload` should be used instead of `mouse_uninstall` so the driver is also removed from memory.
> Availability

>   cc65

> See also

>   mouse_install, mouse_load_driver, mouse_unload

> Example

>   None.

## 3.186 mouse_unload

> Function

>   Unload a mouse driver.

> Header

>   `mouse.h`

> Declaration

>   `unsigned char mouse_unload (void);`

> Description

>   The function unloads a loaded mouse driver and frees all memory allocated for the driver.

> Notes

>   - The function does nothing if no driver is loaded.
> Availability

>   cc65

> See also

>   mouse_install, mouse_load_driver, mouse_uninstall

> Example

>   None.

## 3.187 mul20

> Function

>   Multiplies argument by 20.

> Header

>   `cc65.h`

> Declaration

>   `unsigned int __fastcall__ mul20 (unsigned char value);`

> Description

>   Speed optimized function to multiply an 8 bit unsigned value by 20 to get a 16 bit result.

> Availability

>   cc65

## 3.188 mul40

> Function

>   Multiplies argument by 40.

> Header

>   `cc65.h`

> Declaration

>   `unsigned int __fastcall__ mul40 (unsigned char value);`

> Description

>   Speed optimized function to multiply an 8 bit unsigned value by 40 to get a 16 bit result.

> Availability

>   cc65

## 3.189 offsetof

> Function

>   Calculate the offset of a struct or union member.

> Header

>   `stddef.h`

> Declaration

>   `size_t offsetof (type, member);`

> Description

>   `offsetof` calculates the address offset of a `struct` or `union` member.

> Notes

>   - The function is actually a macro.
> Availability

>   ISO 9899

> Example

>   None.

## 3.190 open

> Function

>   Open and possibly create a file.

> Header

>   `fcntl.h`

> Declaration

>   `int open (const char* name, int flags, ...);`

> Description

>   `open` opens a file and returns the file descriptor associated with it. On error, -1 is returned and an error code is stored in `errno`. Several flags may be passed to `open` that change the behaviour.

> Notes

>   - POSIX specifies an additional `mode` argument that may be passed to open, which is used as the permission mask when a new file is created. While cc65 allows to pass this argument, it is ignored.
> Availability

>   POSIX 1003.1

> See also

>   close, creat

> Example

>   None.

## 3.191 opendir

> Function

>   Open a directory.

> Header

>   `dirent.h`

> Declaration

>   `DIR* __fastcall__ opendir (const char* name);`

> Description

>   `opendir` opens a directory and returns the direcory descriptor associated with it. On error, NULL is returned and an error code is stored in `errno`.

> Notes

>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
> Availability

>   POSIX 1003.1

> See also

>   closedir, readdir

> Example

>   None.

## 3.192 peekbsys

> Function

>   Read one byte from a location in the system bank.

> Header

>   `cbm610.h`, `cbm510.h`

> Declaration

>   `unsigned char __fastcall__ peekbsys (unsigned addr);`

> Description

>   `peekbsys` reads one byte from the given address in the system bank (bank 15) of the CBM PET-II machines and returns it.

> Notes

>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
>   - This function may be a macro depending on the compiler options. The actual function is accessible by #undef'ing the macro.
> Availability

>   cc65

> See also

>   PEEK, PEEKW, peekwsys, pokebsys, pokewsys

> Example

>   None.

## 3.193 peekwsys

> Function

>   Read one word from a location in the system bank.

> Header

>   `cbm610.h`, `cbm510.h`

> Declaration

>   `unsigned __fastcall__ peekwsys (unsigned addr);`

> Description

>   `peekwsys` reads one word from the given address in the system bank (bank 15) of the CBM PET-II machines and returns it. Following the usual 6502 conventions, the low byte is read from `addr`, and the high byte is read from `addr+1`.

> Notes

>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
>   - The order in which the two bytes are read is undefined.
> Availability

>   cc65

> See also

>   PEEK, PEEKW, peekbsys, pokebsys, pokewsys

> Example

>   None.

## 3.194 perror

> Function

>   Print an error message for the error in `errno`.

> Header

>   `stdio.h`

> Declaration

>   `void __fastcall__ perror (const char* s);`

> Description

>   `perror` prints an error message to `stderr`. If `s` is not `NULL` and not an empty string, it is printed followed by a colon and a blank. Then the error message for the current contents of `errno` is printed followed by a newline. The message output is the same as returned by `strerror` with an argument of `errno`.

> Notes

>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
> Availability

>   ISO 9899

> See also

>   _poserror, strerror

> Example

>   None.

## 3.195 pokebsys

> Function

>   Write one byte to a location in the system bank.

> Header

>   `cbm610.h`, `cbm510.h`

> Declaration

>   `void __fastcall__ pokebsys (unsigned addr, unsigned char val);`

> Description

>   `pokebsys` writes one byte to the given address in the system bank (bank 15) of the CBM PET-II machines.

> Notes

>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
> Availability

>   cc65

> See also

>   POKE, POKEW, peekbsys, peekwsys, pokewsys

> Example

>   None.

## 3.196 pokewsys

> Function

>   Write one word to a location in the system bank.

> Header

>   `cbm610.h`, `cbm510.h`

> Declaration

>   `void __fastcall__ pokewsys (unsigned addr, unsigned val);`

> Description

>   `pokewsys` writes one word to the given address in the system bank (bank 15) of the CBM PET-II machines. Following the usual 6502 conventions, the low byte of `val` is written to `addr`, and the high byte is written to `addr+1`.

> Notes

>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
>   - The order in which the two bytes are written is undefined.
> Availability

>   cc65

> See also

>   POKE, POKEW, peekbsys, peekwsys, pokebsys

> Example

>   None.

## 3.197 qsort

> Function

>   Sort an array.

> Header

>   `stdlib.h`

> Declaration

>   `void __fastcall__ qsort (void* base, size_t count, size_t size, int __fastcall__ (* compare) (const void*, const void*));`

> Description

>   `qsort` sorts an array according to a given compare function `compare`. `base` is the address of the array, `count` is the number of elements, `size` the size of an element and `compare` the function used to compare the members.

> Notes

>   - If there are multiple members with the same key, the order after calling the function is undefined.
>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
>   - The function to which `compare` points must have the `fastcall` calling convention.
> Availability

>   ISO 9899

> See also

>   bsearch

> Example

>   None.

## 3.198 raise

> Function

>   Send a signal to the executing program.

> Header

>   `signal.h`

> Declaration

>   `int __fastcall__ raise (int sig);`

> Description

>   `raise()` sends the given signal to the program. If the program has installed a signal handler for the signal, this signal handler will be executed. If no handler has been installed, the default action for the raised signal will be taken. The function returns zero on success, non-zero otherwise.

> Notes

>   - The function is available only as a fastcall function, so it may be used only in the presence of a prototype.
> Availability

>   ISO 9899

> See also

>   abort, assert, signal

> Example

>   None.

## 3.199 rand

> Function

>   Return a pseudo random number.

> Header

>   `stdlib.h`

> Declaration

>   `int rand (void);`

> Description

>   The function returns a pseudo random number between 0 and `RAND_MAX` (exclusive).

> Notes

>   - Without using `srand`, always the same flow of numbers is generated.
>   - On startup, the function behaves as if srand had been used with an argument of 1.
> Availability

>   ISO 9899

> See also

>   _randomize, srand

> Example

>   None.

## 3.200 readdir

> Function

>   Read a directory.

> Header

>   `dirent.h`

> Declaration

>   `struct dirent* __fastcall__ readdir (DIR* dir);`

> Description

>   `readdir` reads the next directory entry from the directory stream pointed to by `dir`. It stores the data in a `dirent` structure and returns a pointer to it. If the end of directory is reached, or an error occurs, NULL is returned. In case of errors, an error code is stored into `errno`.

> Notes

>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
>   - The returned pointer may point to a statically allocated instance of `struct dirent`, so it may get overwritten by subsequent calls to `readdir`.
>   - On several platforms, namely the CBMs and the Atari, the disk drives get confused when opening/closing files between directory reads. So for example a program that reads the list of files on a disk, and after each call to `readdir`, opens the file to process it, will fail.
>     Possible solutions are reading the directory into memory before processing the file list, or to reset the directory by seeking to the correct position after opening/closing a file:

>                 seekdir (DIR, telldir (DIR));

>     Platforms known to work without problems are: Apple.
> Availability

>   POSIX 1003.1

> See also

>   closedir, opendir

> Example

>   None.

## 3.201 realloc

> Function

>   Change the size of an allocated memory block.

> Header

>   `stdlib.h`

> Declaration

>   `void* __fastcall__ realloc (void* block, size_t size);`

> Description

>   `realloc` changes the size of the memory block pointed to by `block` to `size` bytes. If `block` is `NULL`, `realloc` behaves as if `malloc` had been called. If `size` is zero, `realloc` behaves as if `free` had been called. On error (not enough memory available), `realloc` returns `NULL`.

> Notes

>   - The part of the memory block that is returned will have its contents unchanged.
>   - This function is somewhat dangerous to use. Be careful to save the pointer you're passing somewhere else, otherwise

>     > `

>     >             ptr = realloc (ptr, size);

>     > `

>     will loose your only copy of `ptr` if `realloc` returns `NULL`.
>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
> Availability

>   ISO 9899

> See also

>   _heapadd, _heapblocksize, _heapmaxavail, _heapmemavail, calloc, free, realloc

> Example

>   None.

## 3.202 remove

> Function

>   Delete a file.

> Header

>   `stdio.h`

> Declaration

>   `int __fastcall__ remove (const char* name);`

> Description

>   `remove` deletes the file with the given name. On success, zero is returned. On error, -1 is returned and `errno` is set to an error code describing the reason for the failure.

> Notes

>   - This function is not available on all cc65 targets (depends on the availability of file I/O).
>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
> Availability

>   ISO 9899

> See also

>   rename, unlink

> Example

>       #include <stdio.h>

>       #define FILENAME "helloworld"

>       if (remove (FILENAME) == 0) {
>           printf ("We deleted %s successfully\n", FILENAME);
>       } else {
>           printf ("There was a problem deleting %s\n", FILENAME);
>       }

## 3.203 rename

> Function

>   Rename a file.

> Header

>   `stdio.h`

> Declaration

>   `int __fastcall__ rename (const char* oldname, const char* newname);`

> Description

>   `rename` renames a file (gives it a new name). On success, zero is returned. On error, -1 is returned and `errno` is set to an error code describing the reason for the failure.

> Notes

>   - This function is not available on all cc65 targets (depends on the capabilities of the storage devices).
>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
> Availability

>   ISO 9899

> See also

>   remove

> Example

>       #include <stdio.h>

>       #define OLDNAME "textfile.txt"
>       #define NEWNAME "textfile.bak"

>       if (rename (OLDNAME, NEWNAME) == 0) {
>           printf ("Renamed %s to %s\n", OLDNAME, NEWNAME);
>       } else {
>           printf ("Error renaming %s to %s\n", OLDNAME, NEWNAME);
>       }

## 3.204 reset_brk

> Function

>   Resets the break vector to its original value.

> Header

>   `6502.h`

> Declaration

>   `void reset_brk (void);`

> Description

>   `reset_brk` resets the break vector to the value it had before a call to `set_brk`.

> Notes

>   - The break vector is reset on program termination, so it's not strictly necessary to call this function as a part of your clean-up when exiting the program.
> Availability

>   cc65

> See also

>   reset_irq, set_brk, set_irq

> Example

>   None.

## 3.205 reset_irq

> Function

>   Resets the C level interrupt request vector.

> Header

>   `6502.h`

> Declaration

>   `void reset_irq (void);`

> Description

>   `reset_irq` resets the C level interrupt request vector.

> Notes

>   - The interrupt vector is reset on program termination, so it's not strictly necessary to call this function as a part of your clean-up when exiting the program.
> Availability

>   cc65

> See also

>   reset_brk, set_brk, set_irq

> Example

>   None.

## 3.206 revers

> Function

>   Control revers character display.

> Header

>   `conio.h`

> Declaration

>   `unsigned char __fastcall__ revers (unsigned char onoff);`

> Description

>   If the argument is non zero, the function enables reverse character display. If the argument is zero, reverse character display is switched off. The old value of the setting is returned.

> Notes

>   - The function may not be supported by the hardware, in which case the call is ignored.
>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
> Availability

>   cc65

> See also

>   textcolor

> Example

>   None.

## 3.207 rewinddir

> Function

>   Reset a directory stream.

> Header

>   `dirent.h`

> Declaration

>   `void __fastcall__ rewinddir (DIR* dir);`

> Description

>   `rewinddir` sets the position of the directory stream pointed to by `dir` to the start of the directory.

> Notes

>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
> Availability

>   POSIX 1003.1

> See also

>   seekdir, telldir

> Example

>   None.

## 3.208 screensize

> Function

>   Return the dimensions of the text mode screen.

> Header

>   `conio.h`

> Declaration

>   `void __fastcall__ screensize (unsigned char* x, unsigned char* y);`

> Description

>   The function returns the dimensions of the text mode screen.

> Notes

>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
> Availability

>   cc65

> See also

>   gotox, gotoxy, gotoy, wherex, wherey

> Example

>   None.

## 3.209 seekdir

> Function

>   Set the position of a directory stream.

> Header

>   `dirent.h`

> Declaration

>   `void __fastcall__ seekdir (DIR* dir, long offset);`

> Description

>   `seekdir` sets the position of the directory stream pointed to by `dir` to the value given in `offset`, which should be a value returned by `telldir`.

> Notes

>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
> Availability

>   POSIX 1003.1

> See also

>   rewinddir, telldir

> Example

>   None.

## 3.210 ser_close

> Function

>   Close the port and disable interrupts

> Header

>   `serial.h`

> Declaration

>   `unsigned char ser_close (void);`

> Description

>   Close the port by clearing buffers and disable interrupts.

> Availability

>   cc65

> See also

>   Other serial functions.

> Example

>       #include <serial.h>

>       static void initialize(){
>         struct ser_params params = {
>           SER_BAUD_9600,
>           SER_BITS_8,
>           SER_STOP_1,
>           SER_PAR_MARK,
>           SER_HS_NONE
>         };
>         ser_install(lynx_comlynx); // This will activate the ComLynx
>         CLI();
>         ser_open(&params);
>       }

## 3.211 ser_get

> Function

>   Read a character from serial port.

> Header

>   `serial.h`

> Declaration

>   `unsigned char __fastcall__ ser_get (char* b);`

> Description

>   Get a character from the serial port. If no characters are available, the function will return SER_ERR_NO_DATA, so this is not a fatal error.

> Notes

>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
> Availability

>   cc65

> See also

>   Other serial functions.

> Example

>   Wait for a character to be available from a serial port.

>       char ch;
>       while (ser_get(&ch) == SER_ERR_NO_DATA)
>         ;

## 3.212 ser_install

> Function

>   Install an already loaded driver and return an error code.

> Header

>   `serial.h`

> Declaration

>   `unsigned char __fastcall__ ser_install (void* driver);`

> Description

>   The function installs a driver that was already loaded into memory (or linked statically to the program). It returns an error code (`SER_ERR_OK` in case of success).

> Notes

>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
> Availability

>   cc65

> See also

>   ser_load_driver, ser_uninstall, ser_unload

> Example

>       ser_install(lynx_comlynx); //Include the driver statically instead of loading it.

## 3.213 ser_ioctl

> Function

>   Platform dependent code extensions.

> Header

>   `serial.h`

> Declaration

>   `unsigned __fastcall__ ser_ioctl (unsigned char code, void* data);`

> Description

>   Some platforms have extra serial functions that are not supported by standard serial driver functions. You can extend the driver to support this extra functionality bt using ser_ioctl functions.

> Notes

>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
>   - These functions are not easily portable to other cc65 platforms.
> Availability

>   cc65

> See also

>   Other serial functions.

> Example

>   None

## 3.214 ser_load_driver

> Function

>   Load and install a serial driver.

> Header

>   `serial.h`

> Declaration

>   `unsigned char __fastcall__ ser_load_driver (const char *name);`

> Description

>   Load and install the driver by name. Will just load the driver and check if loading was successful.

> Notes

>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
> Availability

>   cc65

> See also

>   Other serial functions.

> Example

>   None.

## 3.215 ser_open

> Function

>   Open the port by setting the port parameters and enable interrupts

> Header

>   `serial.h`

> Declaration

>   `unsigned char __fastcall__ ser_open (const struct ser_params* params);`

> Description

>   Open the port by setting the port parameters and enable interrupts.

> Notes

>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
> Availability

>   cc65

> See also

>   Other serial functions.

> Example

>       #include <serial.h>

>       static void initialize(){
>         struct ser_params params = {
>           SER_BAUD_9600,
>           SER_BITS_8,
>           SER_STOP_1,
>           SER_PAR_MARK,
>           SER_HS_NONE
>         };
>         ser_install(lynx_comlynx); // This will activate the ComLynx
>         CLI();
>         ser_open(&params);
>       }

## 3.216 ser_put

> Function

>   Write a character to a serial port.

> Header

>   `serial.h`

> Declaration

>   `unsigned char __fastcall__ ser_put (char b);`

> Description

>   Send a character via the serial port. There is a transmit buffer, but transmitting is not done via interrupt. The function returns SER_ERR_OVERFLOW if there is no space left in the transmit buffer.

> Notes

>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
> Availability

>   cc65

> See also

>   Other serial functions.

> Example

>       ser_put('A');

## 3.217 ser_status

> Function

>   Return the serial port status.

> Header

>   `serial.h`

> Declaration

>   `unsigned char __fastcall__ ser_status (unsigned char* status);`

> Description

>   Return the serial port status.

> Notes

>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
> Availability

>   cc65

> See also

>   Other serial functions.

> Example

>   None

## 3.218 ser_uninstall

> Function

>   Uninstall the currently loaded driver but do not unload it.

> Header

>   `serial.h`

> Declaration

>   `unsigned char ser_uninstall (void);`

> Description

>   Uninstall the currently loaded driver but do not unload it.

> Availability

>   cc65

> See also

>   Other serial functions.

> Example

>   None.

## 3.219 ser_unload

> Function

>   Uninstall, then unload the currently loaded driver.

> Header

>   `serial.h`

> Declaration

>   `unsigned char ser_unload (void);`

> Description

>   Uninstall, then unload the currently loaded driver.

> Availability

>   cc65

> See also

>   Other serial functions.

> Example

>   None.

## 3.220 set_brk

> Function

>   Set the break vector to a user function.

> Header

>   `6502.h`

> Declaration

>   `void __fastcall__ set_brk (brk_handler func);`

> Description

>   `set_brk` allows a user program to handle breaks within the program code by letting the vector point to a user written C function. The runtime library installs a small stub that saves the registers into global variables that may be accessed (and changed) by the break handler.

> Notes

>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
>   - The stub saves the zero page registers used by the C runtime and switches to a small break handler stack. This means that it is safe to execute C code, even if C code was interrupted. Be careful however not to use too many local variables, and do not enable stack checks for the handler function or any other function called from it.
>   - The `brk_pc` variable points to the `BRK` instruction. If you want the continue with the interrupted code, you have to adjust `brk_pc`, otherwise the `BRK` instruction will get executed over and over again.
>   - The break vector is reset on program termination, so it's not strictly necessary to call `reset_brk` as a part of your clean-up when exiting the program.
> Availability

>   cc65

> See also

>   reset_brk

> Example

>   None.

## 3.221 set_irq

> Function

>   Set the C level interrupt request vector to the given address.

> Header

>   `6502.h`

> Declaration

>   `void __fastcall__ set_irq (irq_handler f, void *stack_addr, size_t stack_size);`

> Description

>   `set_irq` allows a user program to handle interrupt requests (IRQs) within the program code by letting the vector point to a user written C function. The runtime library installs a small stub that saves the zero page registers used by the C runtime before calling the handler function and restores them after the handler function returns. Additionally the stub temporarily switches the C runtime stack to the stack area provided as parameter. If the handler function was set up to handle a "private", "exclusive" interrupt request source it must return the value `IRQ_HANDLED` if and only if it has verified that the current interrupt request actually stems from that source. In all other cases it must return the value `IRQ_NOT_HANDLED`.

> Notes

>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
>   - The stub saves the registers and zero page locations used by the C runtime and switches to the provided stack area. As a consequence, there is some runtime overhead, but it it is safe to execute C code, even if other C code was interrupted. Be careful however not to call C library functions, and do not enable stack checks for the handler function or any other function called from it.
>   - The interrupt vector is reset on program termination, so it's not strictly necessary to call `reset_irq` as a part of your clean-up when exiting the program.
> Availability

>   cc65

> See also

>   reset_brk, reset_irq, set_brk

> Example

>   None.

## 3.222 set_c128_speed

> Function

>   Set the current speed of a C128 CPU.

> Header

>   `accelerator.h`

> Declaration

>   `unsigned char __fastcall__ set_c128_speed (unsigned char speed);`

> Description

>   The function returns the speed after trying to set the speed of the C128 CPU.

> Notes

>   - The function is specific to the C64 and C128.
>   - The function does not check if the C128 CPU is the current CPU.
>   - See the accelerator.h header for the speed definitions.
> Availability

>   cc65 (not all platforms)

> See also

>   detect_c128, get_c128_speed,

> Example

>   None.

## 3.223 set_c64dtv_speed

> Function

>   Set the current speed of the C64DTV.

> Header

>   `accelerator.h`

> Declaration

>   `unsigned char __fastcall__ set_c64dtv_speed (unsigned char speed);`

> Description

>   The function returns the speed after trying to set the speed of the C64DTV.

> Notes

>   - The function is specific to the C64.
>   - The function does not check for the presence of the C64DTV.
>   - See the accelerator.h header for the speed definitions.
> Availability

>   cc65 (not all platforms)

> See also

>   detect_c64dtv, get_c64dtv_speed,

> Example

>   None.

## 3.224 set_c65_speed

> Function

>   Set the current speed of the C65/C64DX in C64 mode.

> Header

>   `accelerator.h`

> Declaration

>   `unsigned char __fastcall__ set_c65_speed (unsigned char speed);`

> Description

>   The function returns the speed after trying to set the speed of the C65/C64DX in C64 mode.

> Notes

>   - The function is specific to the C64.
>   - The function does not check for the presence of a C65/C64DX in C64 mode.
>   - See the accelerator.h header for the speed definitions.
> Availability

>   cc65 (not all platforms)

> See also

>   detect_c65, get_c65_speed,

> Example

>   None.

## 3.225 set_chameleon_speed

> Function

>   Set the current speed of the C64 Chameleon cartridge.

> Header

>   `accelerator.h`

> Declaration

>   `unsigned char __fastcall__ set_chameleon_speed (unsigned char speed);`

> Description

>   The function returns the speed after trying to set the speed of the C64 Chameleon cartridge.

> Notes

>   - The function is specific to the C64.
>   - The function does not check for the presence of the C64 Chameleon cartridge.
>   - See the accelerator.h header for the speed definitions.
> Availability

>   cc65 (not all platforms)

> See also

>   detect_chameleon, get_chameleon_speed,

> Example

>   None.

## 3.226 set_scpu_speed

> Function

>   Set the current speed of the C64/C128 SuperCPU cartridge.

> Header

>   `accelerator.h`

> Declaration

>   `unsigned char __fastcall__ set_scpu_speed (unsigned char speed);`

> Description

>   The function returns the speed after trying to set the speed of the SuperCPU cartridge.

> Notes

>   - The function is specific to the C128 and C64.
>   - The function does not check for the presence of the cartridge.
>   - See the accelerator.h header for the speed definitions.
> Availability

>   cc65 (not all platforms)

> See also

>   detect_scpu, get_scpu_speed,

> Example

>   None.

## 3.227 set_turbomaster_speed

> Function

>   Set the current speed of the C64 Turbo Master cartridge.

> Header

>   `accelerator.h`

> Declaration

>   `unsigned char __fastcall__ set_turbomaster_speed (unsigned char speed);`

> Description

>   The function returns the speed after trying to set the speed of the C64 Turbo Master cartridge.

> Notes

>   - The function is specific to the C64.
>   - The function does not check for the presence of the C64 Turbo Master cartridge.
>   - See the accelerator.h header for the speed definitions.
> Availability

>   cc65 (not all platforms)

> See also

>   detect_turbomaster, get_turbomaster_speed,

> Example

>   None.

## 3.228 setjmp

> Function

>   Save the context for use with `longjmp`.

> Header

>   `setjmp.h`

> Declaration

>   `int __fastcall__ setjmp (jmp_buf buf);`

> Description

>   The `setjmp` function saves the current context in `buf` for subsequent use by the `longjmp` function and returns zero.

> Notes

>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
>   - `setjmp` is actually a macro as required by the ISO standard.
>   - `setjmp` will not save the signal context.
> Availability

>   ISO 9899

> See also

>   longjmp

> Example

>   None.

## 3.229 setlocale

> Function

>   Selects a locale.

> Header

>   `locale.h`

> Declaration

>   `char* __fastcall__ setlocale (int category, const char* locale);`

> Description

>   `setlocale` sets or queries the program's locale.

> Notes

>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
>   - cc65 supports only the "C" locale, so calling this function to set a different locale has no effect.
> Availability

>   ISO 9899

> See also

>   localeconv, strcoll strxfrm

> Example

>   None.

## 3.230 signal

> Function

>   Install a signal handler.

> Header

>   `signal.h`

> Declaration

>   `__sigfunc __fastcall__ signal (int sig, __sigfunc func);`

> Description

>   `signal` installs a handler for the given signal. The handler may either be a user supplied function, or one of the predefined signal handlers `SIG_IGN` or `SIG_DFL`. The function returns the previous value if the signal , or the special function vector SIG_ERR in case of an error.

> Notes

>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
> Availability

>   ISO 9899

> See also

>   abort, assert, raise

> Example

>   None.

## 3.231 sleep

> Function

>   Sleep for a specified amount of time.

> Header

>   `unistd.h`

> Declaration

>   `void __fastcall__ sleep (unsigned seconds);`

> Description

>   The function will return after the specified number of seconds have elapsed.

> Notes

>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
> Availability

>   POSIX 1003.1

> Example

>   None.

## 3.232 slow

> Function

>   Switch the CPU into slow mode (C128: 1MHz mode, C16/Plus4: single clock mode).

> Header

>   `c128.h, c16.h, plus4.h`

> Declaration

>   `void slow (void);`

> Description

>   The function will switch the clock of the CPU to slow mode. for the C128 target it means switching the CPU into 1MHz mode. for the C16/Plus4 target it means switching the CPU into single clock mode.

> Notes

>   - The function is specific to the C128, C16 and Plus4.
> Availability

>   cc65 (not all platforms)

> See also

>   fast, isfast,

> Example

>   None.

## 3.233 srand

> Function

>   Initialize the pseudo random number generator.

> Header

>   `stdlib.h`

> Declaration

>   `void __fastcall__ srand (unsigned seed);`

> Description

>   The function initializes the random number generator using the given seed. On program startup, the generator behaves as if `srand` has been called with an argument of 1.

> Notes

>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
> Availability

>   ISO 9899

> See also

>   _randomize, rand

> Example

>   None.

## 3.234 strcasecmp

> Function

>   Compare two strings case insensitive.

> Header

>   `string.h`

> Declaration

>   `int __fastcall__ strcasecmp (const char* s1, const char* s2);`

> Description

>   The `strcasecmp` function compares the two strings passed as parameters without case sensitivity. It returns a value that is less than zero if `s1` is less than `s2`, zero if `s1` is the same as `s2`, and a value greater than zero if `s1` is greater than `s2`.

> Notes

>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
>   - The function is not available in strict ANSI mode.
> Availability

>   cc65

> See also

>   strcmp, strcoll, stricmp, strncmp, strxfrm

> Example

>   None.

## 3.235 strcat

> Function

>   Concatentate two strings.

> Header

>   `string.h`

> Declaration

>   `char* __fastcall__ strcat (char* s1, const char* s2);`

> Description

>   The `strcat` function appends a copy of the string pointed to by s2 (including the terminating null byte) to the end of the string pointed to by s1. The initial byte of s2 overwrites the null byte at the end of s1.

> Notes

>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
>   - If copying takes place between objects that overlap, the behaviour is undefined.
> Availability

>   ISO 9899

> See also

>   strcpy, strncat, strncpy

> Example

>   None.

## 3.236 strchr

> Function

>   Search for a character in a string.

> Header

>   `string.h`

> Declaration

>   `char* __fastcall__ strchr (const char* s, int c);`

> Description

>   The `strchr` function locates the first occurrence of `c` (converted to a char) in the string pointed to by `s`. The terminating null byte is considered to be part of the string. Upon completion, the function returns a pointer to the byte, or a null pointer if the byte was not found.

> Notes

>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
> Availability

>   ISO 9899

> See also

>   memchr, strrchr

> Example

>   None.

## 3.237 strcmp

> Function

>   Compare two strings.

> Header

>   `string.h`

> Declaration

>   `int __fastcall__ strcmp (const char* s1, const char* s2);`

> Description

>   The `strcmp` function compares the two strings passed as parameters. It returns a value that is less than zero if `s1` is less than `s2`, zero if `s1` is the same as `s2`, and a value greater than zero if `s1` is greater than `s2`.

> Notes

>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
> Availability

>   ISO 9899

> See also

>   strcasecmp, strcoll, stricmp, strncmp strxfrm

> Example

>   None.

## 3.238 strcoll

> Function

>   Compare two strings.

> Header

>   `string.h`

> Declaration

>   `int __fastcall__ strcoll (const char* s1, const char* s2);`

> Description

>   The `strcoll` function compares the two strings passed as parameters, according to the collating sequence set by `setlocale`. It returns a value that is less than zero if `s1` is less than `s2`, zero if `s1` is the same as `s2`, and a value greater than zero if `s1` is greater than `s2`.

> Notes

>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
> Availability

>   ISO 9899

> See also

>   setlocale, strcasecmp, strcmp, stricmp, strncmp, strxfrm

> Example

>   None.

## 3.239 strcpy

> Function

>   Copy a string.

> Header

>   `string.h`

> Declaration

>   `char* __fastcall__ strcpy (char* s1, const char* s2);`

> Description

>   The `strcpy` function copies the string pointed to by `s2` (including the terminating null byte) into the array pointed to by `s1`. The function will always return `s1`.

> Notes

>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
>   - If copying takes place between objects that overlap, the behaviour is undefined.
> Availability

>   ISO 9899

> See also

>   strcat, strncat, strncpy

> Example

>       #include <string.h>

>       static char hello[14];

>       strcpy (hello, "Hello world!\n");

## 3.240 strcspn

> Function

>   Compute the length of a substring.

> Header

>   `string.h`

> Declaration

>   `size_t __fastcall__ strcspn (const char* s, const char* set);`

> Description

>   The `strcspn` function computes and returns the length of the substring pointed to by `s` which does not consist of characters contained in the string `set`.

> Notes

>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
> Availability

>   ISO 9899

> See also

>   strpbrk, strqtok, strspn, strstr, strtok

> Example

>   None.

## 3.241 strdup

> Function

>   Allocate a copy of a string on the heap.

> Header

>   `string.h`

> Declaration

>   `char* __fastcall__ strdup (const char* s);`

> Description

>   `strdup` allocates a memory block on the heap, big enough to hold a copy of `s` including the terminating zero. If the allocation fails, `NULL` is returned, otherwise `s` is copied into the allocated memory block, and a pointer to the block is returned.

> Notes

>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
>   - It is up to the caller to free the allocated memory block.
> Availability

>   ISO 9899

> See also

>   free, malloc

> Example

>   None.

## 3.242 strerror

> Function

>   Return a string describing an error code.

> Header

>   `string.h`

> Declaration

>   `char* __fastcall__ strerror (int errcode);`

> Description

>   The `strerror` function returns a string describing the given error code. If an invalid error code is passed, the string "Unknown error" is returned, and `errno` is set to `EINVAL`. In all other cases, `errno` is left untouched.

> Notes

>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
>   - While the return type of the function is a `char*`, the returned string must not be modified by the caller!
> Availability

>   ISO 9899

> See also

>   _stroserror

> Example

>   None.

## 3.243 stricmp

> Function

>   Compare two strings case insensitive.

> Header

>   `string.h`

> Declaration

>   `int __fastcall__ stricmp (const char* s1, const char* s2);`

> Description

>   The `stricmp` function compares the two strings passed as parameters without case sensitivity. It returns a value that is less than zero if `s1` is less than `s2`, zero if `s1` is the same as `s2`, and a value greater than zero if `s1` is greater than `s2`.

> Notes

>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
>   - The function is not available in strict ANSI mode.
> Availability

>   cc65

> See also

>   strcasecmp, strcmp, strcoll, strncmp, strxfrm

> Example

>   None.

## 3.244 strlen

> Function

>   Return the length of a string.

> Header

>   `string.h`

> Declaration

>   `size_t __fastcall__ strlen (const char* s);`

> Description

>   The `strlen` function computes the number of bytes in the string to which s points, not including the terminating null byte.

> Notes

>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
>   - When compiling with `-Os` (inline known standard functions), the function does not work correctly for strings with more than 255 characters.
> Availability

>   ISO 9899

> See also

>   strcpy

> Example

>   None.

## 3.245 strlower

> Function

>   Make a string lower case.

> Header

>   `string.h`

> Declaration

>   `char* __fastcall__ strlower (char* s);`

> Description

>   The `strlower` function will apply the `tolower` function to each character of a string. The function will always return `s`.

> Notes

>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
>   - The function prototype is unavailable when compiling in strict ANSI mode.
>   - An alias name for this function is `strlwr`.
> Availability

>   cc65

> See also

>   strupper, tolower

> Example

>   None.

## 3.246 strlwr

> See `strlower`.

## 3.247 strncasecmp

> Function

>   Compare two strings case insensitive.

> Header

>   `string.h`

> Declaration

>   `int __fastcall__ strncasecmp (const char* s1, const char* s2, size_t count);`

> Description

>   The `strncasecmp` function compares the two strings passed as parameters without case sensitivity. It returns a value that is less than zero if `s1` is less than `s2`, zero if `s1` is the same as `s2`, and a value greater than zero if `s1` is greater than `s2`.

> Notes

>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
>   - The function is not available in strict ANSI mode.
> Availability

>   cc65

> See also

>   strcmp, strcoll, stricmp, strncmp, strxfrm

> Example

>   None.

## 3.248 strncat

> Function

>   Concatentate two strings.

> Header

>   `string.h`

> Declaration

>   `char* __fastcall__ strncat (char* s1, const char* s2, size_t n);`

> Description

>   The `strncat` function appends not more than n characters of the string pointed to by s2 to the end of the string pointed to by s1. The terminating null character at the end of s1 is overwritten. A terminating null character is appended to the result, even if not all of s2 is appended to s1.

> Notes

>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
>   - If copying takes place between objects that overlap, the behaviour is undefined.
> Availability

>   ISO 9899

> See also

>   strcpy, strncat, strncpy

> Example

>   None.

## 3.249 strncmp

> Function

>   Compare two strings.

> Header

>   `string.h`

> Declaration

>   `int __fastcall__ strncmp (const char* s1, const char* s2, size_t count);`

> Description

>   The `strncmp` function compares not more than `count` characters of the two strings passed as parameters. It returns a value that is less than zero if the first `count` characters of `s1` are less than `s2`, zero if they are identical, and a value greater than zero they are greater.

> Notes

>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
> Availability

>   ISO 9899

> See also

>   strcasecmp, strcmp, strcoll, stricmp, strxfrm

> Example

>   None.

## 3.250 strncpy

> Function

>   Copy part of a string.

> Header

>   `string.h`

> Declaration

>   `char* __fastcall__ strncpy (char* s1, const char* s2, size_t n);`

> Description

>   The `strncpy` function copies not more than `n` bytes from the array pointed to by `s2` to the array pointed to by `s1`. If the array pointed to by `s2` is a string that is shorter than `n` bytes, null bytes are appended to the copy in the array pointed to by `s1`, until `n` bytes are written. The function always will return `s1`.

> Notes

>   - The function is available only as a fastcall function; so, it may be used only in the presence of a prototype.
>   - If there is no null byte in the first `n` bytes of the array pointed to by `s2`, the result is not null-terminated!
>   - If copying takes place between objects that overlap, the behaviour is undefined.
> Availability

>   ISO 9899

> See also

>   memcpy, strcat, strcpy, strncat

> Example

>       #include <string.h>

>       static char hello[6];

>       strncpy (hello, "Hello world!\n", sizeof hello - 1)[5] = '\0';

## 3.251 strnicmp

> Function

>   Compare two strings case insensitive.

> Header

>   `string.h`

> Declaration

>   `int __fastcall__ strnicmp (const char* s1, const char* s2, size_t count);`

> Description

>   The `strnicmp` function compares the two strings passed as parameters without case sensitivity. It returns a value that is less than zero if `s1` is less than `s2`, zero if `s1` is the same as `s2`, and a value greater than zero if `s1` is greater than `s2`.

> Notes

>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
>   - The function is not available in strict ANSI mode.
> Availability

>   cc65

> See also

>   strcasecmp, strcmp, strcoll, strncmp, strxfrm

> Example

>   None.

## 3.252 strpbrk

> Function

>   Find a character in a string, from a set of characters.

> Header

>   `string.h`

> Declaration

>   `char* __fastcall__ strpbrk (const char* str, const char* set);`

> Description

>   `strpbrk()` searches within `str` for the first occurance of any character from `set`. It returns a pointer to that character if found; otherwise, it returns `NULL`.

> Notes

>   - The function is available only as a fastcall function; so, it should be used only in the presence of a prototype.
> Availability

>   ISO 9899

> See also

>   strchr, strcspn, strqtok, strspn, strtok

> Example

>   None.

## 3.253 strqtok

> Function

>   Break a string into tokens.

> Header

>   `string.h`

> Declaration

>   `char* __fastcall__ strqtok (char* s1, const char* s2);`

> Description

>   `strqtok()` will break the string `s1` into a sequence of tokens, which are delimited by either quotation marks or characters from the string `s2`. Tokens inside quotation marks may contain characters from `s2` (they aren't delimiters there). The first call to `strqtok()` will return a pointer to the first token in the string `s1`. The following calls must pass a `NULL` pointer as `s1`, in order to get the next token in the string. Different sets of delimiters may be used for the subsequent calls to `strqtok()`.

> Notes

>   - The function is available only as a fastcall function; so, it may be used only in the presence of a prototype.
>   - `strqtok()` will modify the string `s1`.
>   - The function will forget where it is in the `s1` string if it is given a second `s1` string before it finishes the first one.
> Availability

>   cc65

> See also

>   strcspn, strpbrk, strspn, strtok

> Example

>   None.

## 3.254 strrchr

> Function

>   Search for a character in a string.

> Header

>   `string.h`

> Declaration

>   `char* __fastcall__ strrchr (const char* s, int c);`

> Description

>   The `strrchr` function locates the last occurrence of `c` (converted to a char) in the string pointed to by `s`. The terminating null byte is considered to be part of the string. Upon completion, the function returns a pointer to the byte, or a null pointer if the byte was not found.

> Notes

>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
> Availability

>   ISO 9899

> See also

>   strchr

> Example

>   None.

## 3.255 strspn

> Function

>   Compute the length of a substring.

> Header

>   `string.h`

> Declaration

>   `size_t __fastcall__ strspn (const char* s, const char* set);`

> Description

>   The `strspn` function computes and returns the length of the substring pointed to by `s` which does consist only of characters contained in the string `set`.

> Notes

>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
> Availability

>   ISO 9899

> See also

>   strcspn, strpbrk, strstr

> Example

>   None.

## 3.256 strstr

> Function

>   Find a substring.

> Header

>   `string.h`

> Declaration

>   `char* __fastcall__ strstr (const char* str, const char* substr);`

> Description

>   `strstr` searches for the first occurance of the string `substr` within `str`. If found, it returns a pointer to the copy, otherwise it returns `NULL`.

> Notes

>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
> Availability

>   ISO 9899

> See also

>   strcspn, strspn

> Example

>   None.

## 3.257 strtok

> Function

>   Break a string into tokens.

> Header

>   `string.h`

> Declaration

>   `char* __fastcall__ strtok (char* s1, const char* s2);`

> Description

>   `strtok()` will break the string `s1` into a sequence of tokens, which are delimited by characters from the string `s2`. The first call to `strtok()` will return a pointer to the first token in the string `s1`. The following calls must pass a `NULL` pointer as `s1`, in order to get the next token in the string. Different sets of delimiters may be used for the subsequent calls to `strtok()`.

> Notes

>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
>   - `strtok()` will modify the string `s1`.
>   - The function will forget where it is in the `s1` string if it is given a second `s1` string before it finishes the first one.
> Availability

>   ISO 9899

> See also

>   strcspn, strpbrk, strqtok, strspn

> Example

>   None.

## 3.258 strxfrm

> Function

>   Transform a string.

> Header

>   `string.h`

> Declaration

>   `size_t __fastcall__ strxfrm (char* s1, const char* s2, size_t n);`

> Description

>   The `strxfrm` function transforms the string pointed to by s2 and places the resulting string into the string pointed to by s1. The transformation is such that if the `strcmp` function is applied to two transformed strings, it returns a value greater than, equal to, or less than zero, corresponding to the result of the `strcoll` function applied to the same two original strings. No more than n characters are placed into the resulting array pointed to by s1, including the terminating null character.

> Notes

>   - `s1` and `s2` must not point to the same memory area, otherwise the behaviour is undefined.
>   - If `n` is zero, `s1` may be a NULL pointer.
>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
>   - Since cc65 doesn't support different charcter sets, `strxfrm` will just copy s2 to s1 using `strncpy`.
> Availability

>   ISO 9899

> See also

>   strcmp, strcoll, strncpy

> Example

>   None.

## 3.259 strupper

> Function

>   Make a string upper case.

> Header

>   `string.h`

> Declaration

>   `char* __fastcall__ strupper (char* s);`

> Description

>   The `strupper` function will apply the `toupper` function to each character of a string. The function will always return `s`.

> Notes

>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
>   - The function prototype is unavailable when compiling in strict ANSI mode.
>   - An alias name for this function is `strupr`.
> Availability

>   cc65

> See also

>   strlower toupper

> Example

>   None.

## 3.260 strupr

> See `strupper`.

## 3.261 telldir

> Function

>   Return the current position of a directory stream.

> Header

>   `dirent.h`

> Declaration

>   `long __fastcall__ telldir (DIR* dir);`

> Description

>   `telldir` returns the current position of a directory stream. The return value may be used in subsequent calls to `seekdir`.

> Notes

>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
> Availability

>   POSIX 1003.1

> See also

>   seekdir, telldir

> Example

>   None.

## 3.262 textcolor

> Function

>   Set the text color.

> Header

>   `conio.h`

> Declaration

>   `unsigned char __fastcall__ textcolor (unsigned char color);`

> Description

>   The function will set a new text color. It returns the old (current) text color. Text output using any `conio.h` function will use the color set by this function.

> Notes

>   - Text colors are system dependent. The function may have no effect on systems where the text color cannot be changed.
>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
> Availability

>   cc65

> See also

>   bgcolor, bordercolor

> Example

>   None.

## 3.263 time

> Function

>   Get the time.

> Header

>   `time.h`

> Declaration

>   `time_t __fastcall__ time (time_t* t);`

> Description

>   The function returns the time since the 1970-01-01 00:00:00 measured in seconds. If the pointer `t` is not `NULL`, the function result will also be stored there. If no time is available, `(time_t)-1` is returned and an error code is stored in `errno`.

> Notes

>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
>   - Many platforms supported by cc65 do not have a realtime clock, so the returned value may not be valid.
> Availability

>   ISO 9899

> See also

>   clock, clock_gettime

> Example

>   None.

## 3.264 toggle_videomode

> Function

>   Toggle between 40 and 80 column mode.

> Header

>   `c128.h`

> Declaration

>   `void toggle_videomode (void);`

> Description

>   Toggle between 40 and 80 column mode. The settings for the old mode (cursor position, color and so on) are saved and restored together with the mode.

> Notes

>   - The function is specific to the C128.
>   - This function is deprecated. Please use videomode instead!
> Availability

>   C128

> See also

>   fast, isfast, slow, videomode

> Example

>   None.

## 3.265 tolower

> Function

>   Convert a character into its lower case representation.

> Header

>   `ctype.h`

> Declaration

>   `int __fastcall__ tolower (int c);`

> Description

>   The function returns the given character converted to lower case. If the given character is not a letter, it is returned unchanged.

> Notes

>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
> Availability

>   ISO 9899

> See also

>   islower, isupper, toupper

> Example

>   None.

## 3.266 toupper

> Function

>   Convert a character into its upper case representation.

> Header

>   `ctype.h`

> Declaration

>   `int __fastcall__ toupper (int c);`

> Description

>   The function returns the given character converted to upper case. If the given character is not a letter, it is returned unchanged.

> Notes

>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
> Availability

>   ISO 9899

> See also

>   islower, isupper, tolower

> Example

>   None.

## 3.267 ultoa

> Function

>   Convert an unsigned long integer into a string.

> Header

>   `stdlib.h`

> Declaration

>   `char* __fastcall__ ultoa (unsigned long val, char* buf, int radix);`

> Description

>   `itoa` converts the unsigned long integer `val` into a string using `radix` as the base.

> Notes

>   - There are no provisions to prevent a buffer overflow.
>   - The function is non standard, so it is not available in strict ANSI mode. You should probably use `sprintf` instead.
>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
> Availability

>   cc65

> See also

>   atoi, atol, itoa, ltoa, utoa

> Example

>   None.

## 3.268 unlink

> Function

>   Delete a file.

> Header

>   `unistd.h`

> Declaration

>   `int __fastcall__ unlink (const char* name);`

> Description

>   `unlink` deletes the file with the given name. On success, zero is returned. On error, -1 is returned and `errno` is set to an error code describing the reason for the failure.

> Notes

>   - The use of this function is discouraged. Please use `remove` instead, which is a native ANSI C function and does the same.
>   - This function is not available on all cc65 targets (depends on the availability of file I/O).
>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
>   - Instead of `unlink`, `remove` should be used, which has the same semantics, but is more portable, because it conforms to the ISO C standard.
> Availability

>   POSIX 1003.1

> See also

>   remove

> Example

>       #include <stdio.h>
>       #include <unistd.h>

>       #define FILENAME "helloworld"

>       if (unlink (FILENAME) == 0) {
>           printf ("We deleted %s successfully\n", FILENAME);
>       } else {
>           printf ("There was a problem deleting %s\n", FILENAME);
>       }

## 3.269 utoa

> Function

>   Convert an unsigned integer into a string.

> Header

>   `stdlib.h`

> Declaration

>   `char* __fastcall__ utoa (unsigned val, char* buf, int radix);`

> Description

>   `itoa` converts the unsigned integer `val` into a string using `radix` as the base.

> Notes

>   - There are no provisions to prevent a buffer overflow.
>   - The function is non standard, so it is not available in strict ANSI mode. You should probably use `sprintf` instead.
>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
> Availability

>   cc65

> See also

>   atoi, atol, itoa, ltoa, ultoa

> Example

>   None.

## 3.270 vcprintf

> Function

>   Formatted output to the console.

> Header

>   `conio.h`

> Declaration

>   `int __fastcall__ vcprintf (const char* format, va_list ap);`

> Description

>   The arguments specified as a `va_list` are converted to text where necessary and formatted according to the format string given. The resulting string is output to the console. `vcprintf` supports the same format specifiers as `vprintf`.

> Notes

>   - Like all other `conio` output functions, `vcprintf` distinguishes between `\r` and `\n`.
>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
> Availability

>   cc65

> See also

>   cprintf, cputc, cputcxy, cputs, cputsxy

> Example

>   None.

## 3.271 videomode

> Function

>   Switch to either 40- or 80-column text mode, or a standard graphics mode.

> Header

>   `apple2enh.h, c128.h, cx16.h`

> Declaration

>   `unsigned __fastcall__ videomode (unsigned Mode); /* for apple2enh and c128 */`
>   `signed char __fastcall__ videomode (signed char Mode); /* for cx16 */`

> Description

>   Switch to a 40- or 80-column text or graphics mode, depending on the argument. If the requested mode is already active, nothing happens. The old mode is returned from the call.

> Notes

>   - The function is specific to the Commodore 128, the enhanced Apple //e, and the Commander X16.
>   - This function replaces toggle_videomode.
>   - The function is available as only a fastcall function, so it may be used only in the presence of a prototype.
> Availability

>   C128, enhanced Apple //e, and CX16

> See also

>   fast, isfast, slow, toggle_videomode

> Example

>   None.

## 3.272 waitvsync

> Function

>   Wait until the start of the next video frame.

> Header

>   `cbm.h, gamate.h, nes.h, pce.h`

> Declaration

>   `void waitvsync (void);`

> Description

>   Wait for vertical sync, to reduce flickering.

> Availability

>   Platforms served by the headers above

> Example

>   None.

## 3.273 wherex

> Function

>   Return the current X position of the text mode cursor.

> Header

>   `conio.h`

> Declaration

>   `unsigned char wherex (void);`

> Description

>   The function returns the current X position of the text mode cursor. Zero is returned for the leftmost screen position.

> Availability

>   cc65

> See also

>   gotox, gotoy, gotoxy, wherey

> Example

>   None.

## 3.274 wherey

> Function

>   Return the current Y position of the text mode cursor.

> Header

>   `conio.h`

> Declaration

>   `unsigned char wherey (void);`

> Description

>   The function returns the current Y position of the text mode cursor. Zero is returned for the uppermost screen position.

> Availability

>   cc65

> See also

>   gotox, gotoy, gotoxy, wherex

> Example

>   None.