6502.h
accelerator.h
apple2.h
apple2enh.h
assert.h
atari.h
atmos.h
c128.h
c16.h
c64.h
cbm.h
cbm510.h
cbm610.h
cc65.h
conio.h
creativision.h
ctype.h
cx16.h
dbg.h
device.h
dio.h
dirent.h
em.h
errno.h
fcntl.h
gamate.h
geos.h
inet.h
joystick.h
kim1.h
locale.h
lynx.h
lz4.h
modload.h
mouse.h
nes.h
o65.h
pce.h
peekpoke.h
pen.h
pet.h
plus4.h
serial.h
setjmp.h
signal.h
stdarg.h
stdbool.h
stddef.h
stdio.h
stdlib.h
string.h
sym1.h
telestrat.h
tgi.h
time.h
unistd.h
stat.h
statvfs.h
vic20.h
zlib.h
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.
6502.h
accelerator.h
apple2.h
apple2enh.h
assert.h
atari.h
(incomplete)
atmos.h
c128.h
c16.h
(incomplete)
c64.h
cbm.h
(incomplete)
cbm510.h
cbm610.h
cc65.h
(incomplete)
conio.h
creativision.h
ctype.h
cx16.h
(incomplete)
dbg.h
(incomplete)
device.h
dio.h
dirent.h
em.h
This header file contains definitions for extended memory access,
see also testcode/lib/em-test.c
and samples/multidemo.c
.
errno.h
(incomplete)
fcntl.h
gamate.h
(incomplete)
geos.h
inet.h
joystick.h
kim1.h
(incomplete)
locale.h
lynx.h
(incomplete)
lz4.h
modload.h
mouse.h
nes.h
(incomplete)
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.
pce.h
(incomplete)
peekpoke.h
pen.h
(incomplete)
pet.h
(incomplete)
plus4.h
(incomplete)
serial.h
This header file contains definitions for initializing serial
communication, see also testcode/lib/ser-test.c
.
setjmp.h
signal.h
stdarg.h
(incomplete)
stdbool.h
(incomplete)
stddef.h
stdio.h
(incomplete)
stdlib.h
(incomplete)
string.h
sym1.h
telestrat.h
(incomplete)
tgi.h
time.h
(incomplete)
unistd.h
(incomplete)
stat.h
statvfs.h
vic20.h
(incomplete)
zlib.h
(incomplete)
- Function
Determine if a directory entry specifies a directory.
- Header
- 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
- Example
None.
- Function
Determine if a directory entry specifies a disk label.
- Header
- 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
- Example
None.
- Function
Determine if a directory entry specifies a link.
- Header
- 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
- Example
None.
- Function
Determine if a directory entry specifies a regular file.
- Header
- 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
- Example
None.
- Function
Add a block to the heap.
- Header
- 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.
- Function
Return the size of an allocated block.
- Header
- 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
orrealloc
.- 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 unpredictable 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.
- Function
Return the largest block that is available on the heap.
- Header
- 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.
- Function
Return the total available space on the heap.
- Header
- 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.
- Function
Determines whether the underlying DOS supports command line arguments.
- Header
- 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
andatarixl
platforms)
- Function
Print an error message for the error in
_oserror
.- Header
- Declaration
void __fastcall__ _poserror (const char* msg);
- Description
_poserror
prints an error message tostderr
. Ifmsg
is notNULL
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
- Example
None.
- Function
Initialize the pseudo random number generator.
- Header
- 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
- Example
None.
- Function
Use the speaker to produce sound in a specified voice. (Atari only)
- Header
- Declaration
void __fastcall__ _sound (unsigned char voice, unsigned char pitch, unsigned char distortion, unsigned char volume);
- Description
The function produces a sound with the specified parameters using any of the 4 available oscillators (voices) controlled by the POKEY chip. Sound is non cpu-blocking and it keeps oscillating until program sends 0 in all the other parameters.
- Notes
- The function is available only as a fastcall function; so, it may be used only in the presence of a prototype.
- The function is specific to the Atari 8 bit.
- Voice can be any of 0-3 different sound channels.
- Pitch goes from 0-255 (about 125 Hz to 32 Khz).
- Distortion (0-14) uses poly dividers to reshape wave in order to create a noise effect. Use 10 for a "pure" square-wave sound.
- Volume (0-15) is the intensity for the wave.
- Extra bits in those parameters will be ignored.
- Parameters are the same as for the AtariBASIC SOUND statement.
- Availability
cc65 (
atari
andatarixl
platforms)- Example
#include <stdio.h> int main(void) { int i=0; unsigned char j; printf("playing sound \n"); for (j=0; j<144; j++) { _sound(1,144-j,10,8); //change the pitch for voice 1 for (i=0; i<50; i++); //pause for sound duration } _sound(1,0,0,0); //use zero in other parameters to stop the sound return 0; }
- Function
Return a string describing an OS specific error code.
- Header
- 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
- Example
None.
- Function
Swap the contents of memory areas.
- Header
- 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 byp
andq
. Both memory areas are assumed to besize
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
- Example
None.
- Function
Call a subroutine passing register values.
- Header
- Declaration
void __fastcall__ _sys (struct regs* r);
- Description
The function will call the subroutine at the address specified in the
pc
member of the passedregs
structure. All registers and the CPU flags are set to the values given in theregs
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.
- Function
Insert a 6502 BRK instrunction into the code.
- Header
- 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
- Example
None.
- Function
Insert a 6502 CLI instrunction into the code.
- Header
- 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
- Example
None.
- Function
Read a byte from memory.
- Header
- 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
- Example
None.
- Function
Read a word (two bytes) from memory.
- Header
- 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
- Example
None.
- Function
Write a byte to memory.
- Header
- Declaration
void POKE (unsigned addr, unsigned char val);
- Description
The function writes the value
val
to the absolute memory address given byaddr
.- 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
- Example
None.
- Function
Write a word (two bytes) to memory.
- Header
- Declaration
void POKEW (unsigned addr, unsigned val);
- Description
The function writes the value
val
to the absolute memory address given byaddr
. The low byte ofval
is written to theaddr
, the high byte is written toaddr+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
- Example
None.
- Function
Insert a 6502 SEI instrunction into the code.
- Header
- 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
- Example
None.
- Function
Returns the absolute value of an integer.
- Header
- 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
- Example
None.
- Function
Test a condition, and possibly abort.
- Header
- Declaration
void assert (int cond);
- Description
assert()
is a macro that expands to anif
statement. If the condition evaluates to zero (false),assert()
raisesSIGABRT
, prints a message onstderr
, then exits the program with an exit code of 2.- Notes
- The function is actually a macro.
- Availability
ISO 9899
- See also
- Example
None.
- Function
Register an exit function.
- Header
- Declaration
int __fastcall__ atexit (void (*exitfunc) (void));
- Description
atexit
registers the function pointed to byexitfunc
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
- Example
None.
- Function
Bomb sound effect.
- Header
- 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
- Example
None.
- Function
Load Atmos tape.
- Header
- 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
- Example
None.
- Function
Bell or ricochet sound effect.
- Header
- 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.
- Function
Save Atmos tape.
- Header
- 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
- Example
atmos_save("hires", 0xa000, 0xc000);
- Function
Pistol sound effect.
- Header
- 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.
- Function
High-pitch click.
- Header
- 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.
- Function
Low-pitch click.
- Header
- 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.
- Function
Raygun sound effect.
- Header
- 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.
- Function
Convert a string to an integer.
- Header
- 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
- Example
None.
- Function
Convert a string to a long integer.
- Header
- 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
- Example
None.
- Function
Set the background text color.
- Header
- 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
- Example
None.
- Function
Play a sequence of musical notes.
- Header
- Declaration
void __fastcall__ bios_playsound (const void *a, unsigned char b);
- Description
The function plays chords based on a BASIC statement. Notes and durations are defined in the BASIC manual, chapter 13 on pages 102 resp. 103.
- Notes
- BASIC has a fixed tempo of 18.
- The function is only available as fastcall function, so it may only be used in presence of a prototype.
- Availability
cc65
- See also
- Example
#include <creativision.h> void main (void) { static const unsigned char notes[] = { 0x77, 0x4F, 0x37, 0x4B, 0x05, 0xBB, 0x4F, 0x27, 0x83, 0x93, 0x9B, 0x93, 0x17, 0x4F, 0x96, // played backwards 0xAB, 0x17, 0x4F, // three-note chords 0x0E // tempo }; bios_playsound (notes, sizeof notes); }
- Function
Set the border (frame) color.
- Header
- 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
- Example
None.
- Function
Do a binary search in a sorted array.
- Header
- 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 bykey
.base
is the address of the array,n
is the number of elements,size
the size of an element andcmp
the function used to compare the members against the key. The function returns a pointer to the member found, orNULL
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 thefastcall
calling convention.- Availability
ISO 9899
- See also
- Example
None.
- Function
Fill a memory area with zeroes.
- Header
- Declaration
void __fastcall__ bzero (void* p, size_t count);
- Description
bzero
fills the memory area pointed to byp
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
- Example
None.
- Function
Switch the C128 into C64 compatible mode.
- Header
- 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
cc65
- Example
None.
- Function
Allocate and clear memory.
- Header
- Declaration
void* __fastcall__ calloc (size_t n, size_t size);
- Description
calloc
allocates memory for an array ofn
elements of sizesize
, clears the whole block with binary zeroes and returns a pointer to it. On error (not enough memory available),calloc
returnsNULL
.- 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.
- Function
Input byte from serial bus
- Header
- 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
- Example
None.
- Function
Input a Character from the Current Device
- Header
- 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
- Example
None.
- Function
Output a byte
- Header
- 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
- Example
None.
- Function
Designate a Logical File As the Current Input Channel
- Header
- 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
- Example
None.
- Function
Transmit a byte over the serial bus
- Header
- 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
- Example
None.
- Function
Designate a Logical File As the Current Output Channel
- Header
- 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
- Example
None.
- Function
Close All Logical I/O Files
- Header
- 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
- Example
None.
- Function
Close a Logical I/O File
- Header
- 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
- Example
None.
- Function
Restore Current Input and Output Devices to the Default Devices
- Header
- 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
- Example
None.
- Function
Get One Byte from the Input Device
- Header
- Declaration
unsigned char cbm_k_getin (void);
- Description
Function gets a character from the current input device.
- Notes
- Availability
cc65
- See also
- Example
None.
- Function
Return Base Address of Memory-Mapped I/O Devices
- Header
- 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.
- Function
Command a device on the serial bus to LISTEN
- Header
- 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
- Example
None.
- Function
Load RAM from a Device
- Header
- 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
- Example
None.
- Function
Open a Logical I/O File
- Header
- 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
- Example
None.
- Function
Read status word
- Header
- 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.
- Function
Save RAM to a Device
- Header
- 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
- Example
None.
- Function
Scan the keyboard matrix.
- Header
- 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
- Example
None.
- Function
Send secondary address for LISTEN.
- Header
- 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
- Exampe
None.
- Function
Set up a logical file
- Header
- 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
- Example
None.
- Function
Set Filename Parameters
- Header
- 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
- Example
None.
- Function
Set the Jiffy clock.
- Header
- 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
- Example
None.
- Function
Commands device to TALK
- Header
- 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
- Example
None.
- Function
Send TALK secondary address to serial bus
- Header
- 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
- Example
None.
- Function
Update the Jiffy clock.
- Header
- 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
- Example
None.
- Function
Send an UNLISTEN command
- Header
- 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
- Example
None.
- Function
Send an UNTALK command
- Header
- 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
- Example
None.
- Function
Clear part of a line (write a given number of spaces).
- Header
- 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
- Example
None.
- Function
Clear part of a line (write a given number of spaces) starting at a specific screen position.
- Header
- 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
- Example
None.
- Function
Read a character from the keyboard.
- Header
- 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 thecursor
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
- Example
None.
- Function
Output a horizontal line in text mode.
- Header
- 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
- Example
None.
- Function
Output a horizontal line at a given position in text mode.
- Header
- 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
- Example
None.
- Function
Clear error and end-of-file status of a stream.
- Header
- Declaration
void __fastcall__ clearerr (FILE* f);
- Description
clearerr
clears the error and end-of-file status indicators for the streamf
.- 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
- Example
None.
- Function
Determine the processor time used.
- Header
- 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 macroCLOCKS_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
- Example
None.
- Function
Determine the realtime clock resolution.
- Header
- 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 beCLOCK_REALTIME
. Ifres
is notNULL
, the resolution of the realtime clock is stored in the location pointed to byres
. Ifres
isNULL
, the clock resolution is not returned. If thetp
argument ofclock_settime
is not a multiple ofres
, then the value is truncated to a multiple ofres
. On success, zero is returned. On error, -1 is returned anderrno
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 thetv_nsec
field of thestruct timespec
returned is zero.- Availability
POSIX 1003.1
- See also
- Example
None.
- Function
Get the time from the realtime clock.
- Header
- 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 beCLOCK_REALTIME
. On success, zero is returned. On error, -1 is returned anderrno
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
- Example
None.
- Function
Set the time on the realtime clock.
- Header
- 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 beCLOCK_REALTIME
. On success, zero is returned. On error, -1 is returned anderrno
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
- Example
None.
- Function
Converts a ProDOS date to a struct tm.
- Header
- Declaration
struct tm* __fastcall__ gmtime_dt (const struct datetime* dt);
- Description
The
gmtime_dt
function converts the given proDOS date/time to a struct tm. On error, NULL is returned anderrno
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.
- This function is only available on Apple II.
- On Apple II, you can't stat() an opened file. stat() before opening.
- Availability
cc65
- Example
#include <stdio.h> #include <time.h> #include <sys/stat.h> int main(void) { struct stat st; struct tm* tm; if (stat ("/disk/file", &st) == 0) { tm = gmtime_dt (&st.st_ctime); if (tm) printf ("File created on %s\n", asctime(tm)); } }
- Function
Converts a ProDOS date to a time_t.
- Header
- Declaration
time_t __fastcall__ mktime_dt (const struct datetime* dt);
- Description
The
mktime_dt
function parses the given proDOS date/time and returns a time_t timestamp. On error, 0 is returned, and errno is set.- Notes
- The function is only available as fastcall function, so it may only be used in presence of a prototype.
- This function is only available on Apple II.
- Availability
cc65
- Example
#include <stdio.h> #include <time.h> #include <sys/stat.h> int main(void) { struct stat st; if (stat ("/disk/file", &st) == 0) { printf ("File created on %s\n", localtime (mktime_dt (&st.st_ctime))); } }
- Function
Close a file descriptor.
- Header
- 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
- Example
None.
- Function
Close a directory.
- Header
- 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
- Example
None.
- Function
Get a character from the display memory.
- Header
- 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
- Example
None.
- Function
Get a color from the display memory.
- Header
- 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.- On the cx16 (Commander X16) target, this function returns two values: the background color, in the high nybble, and the text color, in the low nybble.
- Availability
cc65
- See also
- Example
None.
- Function
Get a reverse-character attribute from the display memory.
- Header
- 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
- Example
None.
- Function
Get a string from the display memory.
- Header
- 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
- Example
None.
- Function
Create a file.
- Header
- 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 inerrno
.- Notes
creat
is identical to callingopen
withflags
equal toO_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
- Example
None.
- Function
Formatted output to the console.
- Header
- 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 asprintf
.- Notes
- Like all other
conio
output functions,cprintf
distinguishes between\r
and\n
.- Availability
cc65
- See also
- Example
None.
- Function
Output a character directly to the console.
- Header
- 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
- Example
None.
- Function
Output a character at a specific screen position.
- Header
- 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
- Example
None.
- Function
Output a string directly to the console.
- Header
- 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
- Example
None.
- Function
Output a string to the console at a given position.
- Header
- 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 strings
.- 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
- Example
None.
- Function
Enable/disable a blinking cursor when waiting for keyboard input.
- Header
- 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
- Example
None.
- Function
Output a vertical line in text mode.
- Header
- 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
- Example
None.
- Function
Output a vertical line at a given position in text mode.
- Header
- 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
- Example
None.
- Function
Uncompress a LZ4-compressed buffer.
- Header
- 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.
- Function
Check if a C128 CPU is the current CPU.
- Header
- 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
- Example
None.
- Function
Check for the presence of the C64DTV.
- Header
- 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
- Example
None.
- Function
Check for the presence of a C65/C64DX in C64 mode.
- Header
- 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
- Example
None.
- Function
Check for the presence of the C64 Chameleon cartridge.
- Header
- 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
- Example
None.
- Function
Check whether we are running on an Apple IIgs..
- Header
- Declaration
unsigned char detect_iigs (void);
- Description
The function returns a 1 if running on an Apple IIgs.
- Notes
- The function is specific to the Apple2 and Apple2enh platforms.
- Availability
cc65 (not all platforms)
- See also
- Example
None.
- Function
Check for the presence of the C64/C128 SuperCPU cartridge.
- Header
- 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
- Example
None.
- Function
Check for the presence of the C64 Turbo Master cartridge.
- Header
- 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
- Example
None.
- Function
Returns the number of entries in the directory.
- Header
- Declaration
unsigned int __fastcall__ dir_entry_count(DIR *dir);
- Description
dir_entry_count
is machine dependent and does not exist for all supported targets. If it exists, it returns the number of active (non-deleted) files and directories in the directory.- Notes
- The function does not exist on all platforms.
- Availability
cc65 (not all platforms)
- Example
None.
- Function
Divide two ints and return quotient and remainder.
- Header
- Declaration
div_t __fastcall__ div (int numer, int denom);
- Description
div
dividesnumer
bydenom
and returns the quotient and remainder in adiv_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.
- Function
Determines whether the screen is going to be cleared after program exit.
- Header
- 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; }
- Function
Dump memory to tape.
- Header
- Declaration
int __fastcall__ dumpt (unsigned char id, const void* start, const void* end);
- Description
dumpt
saves memory onto data tape.- Notes
- The function is specific to the Sym-1 and KIM-1.
- The return value is status. Non-zero status indicates an error.
- The function is only available as fastcall function, so it may only be used in presence of a prototype.
- Availability
cc65
- See also
- Example
None.
- Function
Commit changes into extended memory.
- Header
- 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
orem_copyto
are called without callingem_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
- Example
None.
- Function
Copy from extended into normal memory.
- Header
- 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, callem_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
- Example
None.
- Function
Copy from normal into extended memory.
- Header
- 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, callem_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
- Example
None.
- Function
Install an already loaded extended memory driver.
- Header
- Declaration
unsigned char _fastcall__ em_install (const 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
- Example
None.
- Function
Load and initialize an extended memory driver.
- Header
- 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
- Example
None.
- Function
Make a page of extended memory accessible.
- Header
- 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 transferred 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, callem_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
- Example
None.
- Function
Return the number of available extended memory pages.
- Header
- 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
- Example
None.
- Function
Uninstall an already loaded extended memory driver.
- Header
- 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 ofem_uninstall
so the driver is also removed from memory.- Availability
cc65
- See also
- Example
None.
- Function
Unload an extended memory driver.
- Header
- 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
- Example
None.
- Function
Prepare an extended memory page for use.
- Header
- 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, callem_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
- Example
None.
- Function
Terminate the program.
- Header
- 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 withatexit
are called. Common values for status areEXIT_SUCCESS
andEXIT_FAILURE
which are also defined instdlib.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
- Example
None.
- Function
Execute a program file.
- Header
- Declaration
int __fastcall__ exec (const char* progname, const char* cmdline);
- Description
exec
replaces the currently running program by a new one. Callingexec()
is identical to callingexit()
, then loading and starting the program named in the first argument, passing the command line specified as second argument. Instead of an empty string, aNULL
pointer may be passed as second parameter. On success, the function does not return. On failure, -1 is returned anderrno
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
- Example
None.
- Function
Switch the CPU into fast mode (C128: 2MHz mode, C16/Plus4: double clock mode).
- Header
- 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
- Example
None.
- Function
Flash front-panel display.
- Header
- Declaration
void fdisp(void);
- Description
fdisp
flashes front-panel display.- Notes
- The function is specific to the Sym-1.
- The front-panel display buffer must be loaded prior to calling fdisp. See the DISPLAY struct definition in sym1.h.
- Availability
cc65
- See also
- Example
None.
- Function
Return the end-of-file indicator of a stream.
- Header
- Declaration
int __fastcall__ feof (FILE* f);
- Description
feof
tests the end-of-file indicator of the streamf
, 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
- Example
None.
- Function
Return the error indicator of a stream.
- Header
- Declaration
int __fastcall__ ferror (FILE* f);
- Description
ferror
tests the error indicator of the streamf
, 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
- Example
None.
- Function
Return the file handle used by a stream.
- Header
- 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
- Example
None.
- Function
Free a block of dynamic memory.
- Header
- Declaration
void __fastcall__ free (void* block);
- Description
Free a block of dynamic memory previously allocated with
malloc
,calloc
orrealloc
. As an exception, if the passed pointer isNULL
, 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.
- Function
The function returns the operating system, the program runs on.
- Header
- 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.
- Function
Get the current speed of the C128 CPU.
- Header
- 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
- Example
None.
- Function
Get the current speed of the C64DTV.
- Header
- 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
- Example
None.
- Function
Get the current speed of the C65/C64DX in C64 mode.
- Header
- 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
- Example
None.
- Function
Get the current speed of the C64 Chameleon cartridge.
- Header
- 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
- Example
None.
- Function
Get the current speed of the Apple IIgs.
- Header
- Declaration
unsigned char get_iigs_speed (void);
- Description
The function returns the current speed of the Apple IIgs.
- Notes
- The function is specific to the Apple2 and Apple2enh platforms.
- See the accelerator.h header for the speed definitions.
- Availability
cc65 (not all platforms)
- See also
- Example
None.
- Function
Get the current speed of the C64/C128 SuperCPU cartridge.
- Header
- 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
- Example
None.
- Function
Get the current speed of the C64 Turbo Master cartridge.
- Header
- 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
- Example
None.
- Function
Determine on which CPU the program is running.
- Header
- 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.
- Function
Get current device.
- Header
- 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
- Example
dio_open (getcurrentdevice ());
- Function
Get current working directory.
- Header
- 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.
- Function
Get device directory.
- Header
- 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
- Example
chdir (getdevicedir (device, buf, sizeof buf));cf.samples/enumdevdir.c
- Function
Return a value from the environment.
- Header
- 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 formname=value
. If there is no match,getenv
returnsNULL
.- 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.
- Function
Get first device.
- Header
- 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
- Example
unsigned char dev = getfirstdevice (); while (dev != INVALID_DEVICE) { printf ("%d\n", dev); dev = getnextdevice (dev); }
- Function
Get next device.
- Header
- Declaration
unsigned char __fastcall__ getnextdevice (unsigned char device);
- Description
The function returns the next device after
device
. The constantINVALID_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
- Example
unsigned char dev = getfirstdevice (); while (dev != INVALID_DEVICE) { printf ("%d\n", dev); dev = getnextdevice (dev); }
- Function
Parse command line options.
- Header
- Declaration
int __fastcall__ getopt (int argc, char* const* argv, const char* optstring);
- Description
The function parses command line arguments,
argc
andargv
are the argument count and array passed tomain
.optstring
is a string that contains command line option characters. If a character inoptstring
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 preceded by a '-'.getopt
must be called repeatedly. It will return each option character found on the command line andEOF
(-1) if there is no other option. An option argument is placed inoptarg
, the index of the next element on the command line to be processed is placed inoptind
.- 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.
- Function
Move the text mode cursor to a new X position.
- Header
- 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
- Example
None.
- Function
Move the text mode cursor to a new position.
- Header
- 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
- Example
None.
- Function
Move the text mode cursor to a new Y position.
- Header
- 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
- Example
None.
- Function
Swaps byte order in a 32 bit word.
- Header
- Declaration
int htonl(val)
- Description
Converts a 32 bit word from from network byte order (big endian) to little endian (or vice-versa).
- Notes
- The function is only available as fastcall function, so it may only be used in presence of a prototype.
- See also
- Availability
cc65
- Function
Swaps byte order in a 16 bit word.
- Header
- Declaration
int htons(val)
- Description
Converts a 16 bit word from from network byte order (big endian) to little endian (or vice-versa) by swapping both its bytes.
- Notes
- The function is only available as fastcall function, so it may only be used in presence of a prototype.
- See also
- Availability
cc65
- Function
Check if a given character is a letter or digit.
- Header
- 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.
- Function
Check if a given character is a letter.
- Header
- 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.
- Function
Check if a given character is in the ASCII (0..127) range.
- Header
- 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.
- Function
Check if a given character is a space or tab.
- Header
- 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.
- Function
Check if a given character is a control character.
- Header
- 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.
- Function
Check if a given character is a digit.
- Header
- 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.
- Function
Check if the CPU is in fast mode (C128: 2MHz mode, C16/Plus4: double clock mode).
- Header
- 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
- Example
None.
- Function
Check if a given character is a printable character (except space).
- Header
- 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.
- Function
Check if a given character is a lower case letter.
- Header
- 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.
- Function
Check if a given character is a printable character.
- Header
- 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.
- Function
Check if a given character is a printable character but not a space or an alphanumeric character.
- Header
- 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.
- Function
Check if a given character is a white-space character.
- Header
- 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.
- Function
Check if a given character is an upper case letter.
- Header
- 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.
- Function
Check if a given character is a hexadecimal digit.
- Header
- 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.
- Function
Convert an integer into a string.
- Header
- Declaration
char* __fastcall__ itoa (int val, char* buf, int radix);
- Description
itoa
converts the integerval
into a string usingradix
as the base.- Notes
- There are no provisions to prevent a buffer overflow.
- If
val
containsINT_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
- Example
None.
- Function
Return the number of joysticks supported by the current driver.
- Header
- 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
- Example
None.
- Function
Install an already loaded driver and return an error code.
- Header
- Declaration
unsigned char __fastcall__ joy_install (const 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
- Example
None.
- Function
Load a driver from disk and install it.
- Header
- 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
- Example
None.
- Function
Read the status of a joystick.
- Header
- 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
- Example
None.
- Function
Uninstall the current joystick driver.
- Header
- 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
- Example
None.
- Function
Uninstall, then unload the current joystick driver.
- Header
- 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
- Example
None.
- Function
Check if there's a key waiting in the keyboard buffer.
- Header
- 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
- Example
None.
- Function
Set the keyboard repeat mode.
- Header
- 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), andKBREPEAT_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.
- Function
Returns the absolute value of a long integer.
- Header
- 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
- Example
None.
- Function
Load memory from tape.
- Header
- Declaration
int __fastcall__ loadt (unsigned char id);
- Description
loadt
loads memory from data tape.- Notes
- The function is specific to the Sym-1 and KIM-1.
- The return value is status. Non-zero status indicates an error.
- The function is only available as fastcall function, so it may only be used in presence of a prototype.
- Availability
cc65
- See also
- Example
None.
- Function
Convert a long integer into a string.
- Header
- Declaration
char* __fastcall__ ltoa (long val, char* buf, int radix);
- Description
itoa
converts the long integerval
into a string usingradix
as the base.- Notes
- There are no provisions to prevent a buffer overflow.
- If
val
containsLONG_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
- Example
None.
- Function
Returns a pointer to the current locale structure.
- Header
- 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
- Example
None.
- Function
Non local goto.
- Header
- Declaration
void __fastcall__ longjmp (jmp_buf buf, int retval);
- Description
The
longjmp
function restores a program context from the data inbuf
, which must have been set by a preceding call tosetjmp
. Program execution continues as if the call tosetjmp
has just returned the valueretval
.- 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
- Example
None.
- Function
Allocate dynamic memory.
- Header
- 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
returnsNULL
.- 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.
- Function
Search for a character in a block of raw memory.
- Header
- Declaration
void* __fastcall__ strchr (const void* mem, int c, size_t count);
- Description
The
memchr
function locates the first occurrence ofc
(converted to a char) in the block of raw memory string pointed to bymem
that is of sizecount
. 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
- Example
None.
- Function
Compare two memory areas.
- Header
- Declaration
int __fastcall__ memcmp (const void* p1, const void* p2, size_t count);
- Description
memcmp
comparescount
bytes from the memory area pointed to byp1
into the memory area pointed to byp2
. It returns a value that is less than zero ifp1
is less thanp2
, zero ifp1
is the same asp2
, and a value greater than zero ifp1
is greater thanp2
.- 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
- Example
None.
- Function
Copy a memory area.
- Header
- Declaration
void* __fastcall__ memcpy (void* dest, const void* src, size_t count);
- Description
memcpy
copiescount
bytes from the memory area pointed to bysrc
into the memory area pointed to bydest
. It returnsdest
.- 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
- Example
None.
- Function
Copy a memory area.
- Header
- Declaration
void* __fastcall__ memmove (void* dest, const void* src, size_t count);
- Description
memmove
copiescount
bytes from the memory area pointed to bysrc
into the memory area pointed to bydest
. It returnsdest
.- Notes
- While
memmove
allows the memory areas to overlap, it has some additional overhead compared tomemcpy
.- The function is only available as fastcall function, so it may only be used in presence of a prototype.
- Availability
ISO 9899
- See also
- Example
None.
- Function
Fill a memory area.
- Header
- Declaration
void* __fastcall__ memset (void* p, int val, size_t count);
- Description
memset
fills the memory area pointed to byp
with the valueval
. The function returnsp
.- 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
- Example
None.
- Function
Free a relocatable module.
- Header
- 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
- Example
None.
- Function
Load a relocatable module.
- Header
- 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 passedmod_ctrl
struct contain information about the module just loaded. Possible error codes are:
MLOAD_OK
- Module load successfulMLOAD_ERR_READ
- Read errorMLOAD_ERR_HDR
- Header errorMLOAD_ERR_OS
- Wrong operating systemMLOAD_ERR_FMT
- Data format errorMLOAD_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
- Example
None.
- Function
Specify a bounding box for the mouse cursor.
- Header
- 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
- Example
None.
- Function
Return the current bounding box for the mouse cursor.
- Header
- 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
- Example
None.
- Function
Return a bit mask encoding the state of the mouse buttons.
- Header
- 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
- Example
None.
- Function
Return a readable error message for an error code.
- Header
- 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
- Example
None.
- Function
Hide the mouse pointer.
- Header
- Declaration
void mouse_hide (void);
- Description
The function hides the mouse pointer. It manages a counter that is shared between
mouse_show
andmouse_hide
so that every call call tomouse_hide
must be followed by a call tomouse_show
to make the mouse cursor visible.- Availability
cc65
- See also
- Example
None.
- Function
Return the state of the mouse buttons and the position of the mouse.
- Header
- 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 themouse_pos
struct, so if you just need the mouse position, callmouse_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
- Example
None.
- Function
Install an already loaded mouse driver.
- Header
- 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 tomouse_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
- Example
None.
- Function
Call the driver specific ioctl function.
- Header
- 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 thedata
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.
- Function
Load and initialize a mouse driver.
- Header
- 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 tomouse_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
- Example
None.
- Function
Move the mouse cursor to a specific position.
- Header
- 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
- Example
None.
- Function
Return the position of the mouse.
- Header
- 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 themouse_info
struct, so if you do also need the mouse buttons, callmouse_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
- Example
None.
- Function
Show the mouse pointer.
- Header
- Declaration
void mouse_show (void);
- Description
The function shows the mouse pointer. It manages a counter that is shared between
mouse_hide
andmouse_show
. The mouse cursor is visible if there was one more call tomouse_show
than tomouse_hide
.- Availability
cc65
- See also
- Example
None.
- Function
Uninstall an already loaded mouse driver.
- Header
- 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 ofmouse_uninstall
so the driver is also removed from memory.- Availability
cc65
- See also
- Example
None.
- Function
Unload a mouse driver.
- Header
- 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
- Example
None.
- Function
Multiplies argument by 20.
- Header
- 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
- Function
Multiplies argument by 40.
- Header
- 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
- Function
Swaps byte order in a 32 bit word.
- Header
- Declaration
int __fastcall__ ntohl (int val);
- Description
Converts a 32 bit word from from host byte order (little endian) to big endian (or vice-versa).
- Notes
- The function is only available as fastcall function, so it may only be used in presence of a prototype.
- See also
- Availability
cc65
- Function
Swaps byte order in a 16 bit word.
- Header
- Declaration
int __fastcall__ ntohs (int val);
- Description
Converts a 16 bit word from from host byte order (little endian) to big endian (or vice-versa) by swapping both its bytes.
- Notes
- The function is only available as fastcall function, so it may only be used in presence of a prototype.
- See also
- Availability
cc65
- Function
Calculate the offset of a struct or union member.
- Header
- Declaration
size_t offsetof (type, member);
- Description
offsetof
calculates the address offset of astruct
orunion
member.- Notes
- The function is actually a macro.
- Availability
ISO 9899
- Example
None.
- Function
Open and possibly create a file.
- Header
- 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 inerrno
. Several flags may be passed toopen
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
- Example
None.
- Function
Open a directory.
- Header
- Declaration
DIR* __fastcall__ opendir (const char* name);
- Description
opendir
opens a directory and returns the directory descriptor associated with it. On error, NULL is returned and an error code is stored inerrno
.- 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
- Example
None.
- Function
Read one byte from a location in the system bank.
- Header
- 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
- Example
None.
- Function
Read one word from a location in the system bank.
- Header
- 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 fromaddr
, and the high byte is read fromaddr+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
- Example
None.
- Function
Print an error message for the error in
errno
.- Header
- Declaration
void __fastcall__ perror (const char* s);
- Description
perror
prints an error message tostderr
. Ifs
is notNULL
and not an empty string, it is printed followed by a colon and a blank. Then the error message for the current contents oferrno
is printed followed by a newline. The message output is the same as returned bystrerror
with an argument oferrno
.- 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
- Example
None.
- Function
Write one byte to a location in the system bank.
- Header
- 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
- Example
None.
- Function
Write one word to a location in the system bank.
- Header
- 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 ofval
is written toaddr
, and the high byte is written toaddr+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
- Example
None.
- Function
Delay for a short period of time.
- Header
- Declaration
void __fastcall__ psg_delay (unsigned char b);
- Description
The function specifies how long each note or pause between notes should last.
- Notes
- The function is only available as fastcall function, so it may only be used in presence of a prototype.
- Availability
cc65
- See also
- Example
None.
- Function
Output a byte to the PSG.
- Header
- Declaration
void __fastcall__ psg_outb (unsigned char b);
- Description
The function sends a byte to the Programmable Sound Generator, then waits for the PSG to acknowledge.
- Notes
- The function is only available as fastcall function, so it may only be used in presence of a prototype.
- Availability
cc65
- See also
- Example
#include <creativision.h> void main (void) { psg_outb (0x80); // Latch frequency psg_outb (0x07); // Frequency byte 2 psg_outb (0x90); // Channel 0 full volume psg_delay (100); psg_silence (); }
- Function
Set volume off on each PSG channel.
- Header
- Declaration
void psg_silence (void);
- Description
The function resets the Programmable Sound Generator, then sends $9F, $BF, $DF, $FF to the PSG.
- Availability
cc65
- See also
- Example
None.
- Function
Sort an array.
- Header
- 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 functioncompare
.base
is the address of the array,count
is the number of elements,size
the size of an element andcompare
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 thefastcall
calling convention.- Availability
ISO 9899
- See also
- Example
None.
- Function
Send a signal to the executing program.
- Header
- 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
- Example
None.
- Function
Return a pseudo random number.
- Header
- Declaration
int rand (void);
- Description
The function returns a pseudo random number between 0 and
RAND_MAX
(exclusive).- Notes
- Availability
ISO 9899
- See also
- Example
None.
- Function
Read a directory.
- Header
- Declaration
struct dirent* __fastcall__ readdir (DIR* dir);
- Description
readdir
reads the next directory entry from the directory stream pointed to bydir
. It stores the data in adirent
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 intoerrno
.- 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 toreaddir
.- On the Apple II platform, the d_ctime and d_mtime returned are in the ProDOS format. You can convert them to more portable time representations using the ProDOS datetime conversion functions.
- 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
- Example
None.
- Function
Change the size of an allocated memory block.
- Header
- Declaration
void* __fastcall__ realloc (void* block, size_t size);
- Description
realloc
changes the size of the memory block pointed to byblock
tosize
bytes. Ifblock
isNULL
,realloc
behaves as ifmalloc
had been called. Ifsize
is zero,realloc
behaves as iffree
had been called. On error (not enough memory available),realloc
returnsNULL
.- 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
will lose your only copy of
ptr = realloc (ptr, size);ptr
ifrealloc
returnsNULL
.- 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.
- Function
Delete a file.
- Header
- 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 anderrno
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
- 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); }
- Function
Rename a file.
- Header
- 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 anderrno
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
- 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); }
- Function
Resets the break vector to its original value.
- Header
- Declaration
void reset_brk (void);
- Description
reset_brk
resets the break vector to the value it had before a call toset_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
- Example
None.
- Function
Resets the C level interrupt request vector.
- Header
- 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
- Example
None.
- Function
Control revers character display.
- Header
- 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
- Example
None.
- Function
Reset a directory stream.
- Header
- Declaration
void __fastcall__ rewinddir (DIR* dir);
- Description
rewinddir
sets the position of the directory stream pointed to bydir
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
- Example
None.
- Function
Return the dimensions of the text mode screen.
- Header
- 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
- Example
None.
- Function
Set the position of a directory stream.
- Header
- Declaration
void __fastcall__ seekdir (DIR* dir, long offset);
- Description
seekdir
sets the position of the directory stream pointed to bydir
to the value given inoffset
, which should be a value returned bytelldir
.- 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
- Example
None.
- Function
Close the port and disable interrupts
- Header
- 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(¶ms); }
- Function
Read a character from serial port.
- Header
- 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) ;
- Function
Install an already loaded driver and return an error code.
- Header
- Declaration
unsigned char __fastcall__ ser_install (const 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
- Example
ser_install(lynx_comlynx); //Include the driver statically instead of loading it.
- Function
Platform dependent code extensions.
- Header
- 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
- Function
Load and install a serial driver.
- Header
- 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.
- Function
Open the port by setting the port parameters and enable interrupts
- Header
- 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(¶ms); }
- Function
Write a character to a serial port.
- Header
- 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');
- Function
Return the serial port status.
- Header
- 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
- Function
Uninstall the currently loaded driver but do not unload it.
- Header
- Declaration
unsigned char ser_uninstall (void);
- Description
Uninstall the currently loaded driver but do not unload it. This function returns SER_ERR_NO_DRIVER if no driver was installed, 0 otherwise.
- Availability
cc65
- See also
Other serial functions.
- Example
None.
- Function
Uninstall, then unload the currently loaded driver.
- Header
- Declaration
unsigned char ser_unload (void);
- Description
Uninstall, then unload the currently loaded driver.
- Availability
cc65
- See also
Other serial functions.
- Example
None.
- Function
Set the break vector to a user function.
- Header
- 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 theBRK
instruction. If you want the continue with the interrupted code, you have to adjustbrk_pc
, otherwise theBRK
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
- Example
None.
- Function
Set the C level interrupt request vector to the given address.
- Header
- 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 valueIRQ_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 valueIRQ_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
- Example
None.
- Function
Set the current speed of a C128 CPU.
- Header
- 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
- Example
None.
- Function
Set the current speed of the C64DTV.
- Header
- 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
- Example
None.
- Function
Set the current speed of the C65/C64DX in C64 mode.
- Header
- 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
- Example
None.
- Function
Set the current speed of the C64 Chameleon cartridge.
- Header
- 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
- Example
None.
- Function
Set the current speed of the Apple IIgs.
- Header
- Declaration
unsigned char __fastcall__ set_iigs_speed (unsigned char speed);
- Description
The function sets the speed of the Apple IIgs CPU (and returns the new speed).
- Notes
- The function is specific to the Apple2 and Apple2enh platforms.
- See the accelerator.h header for the speed definitions.
- Accepted parameters are SPEED_SLOW and SPEED_FAST (all other values are considered SPEED_FAST).
- Availability
cc65 (not all platforms)
- See also
- Example
None.
- Function
Set the current speed of the C64/C128 SuperCPU cartridge.
- Header
- 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
- Example
None.
- Function
Set the current speed of the C64 Turbo Master cartridge.
- Header
- 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
- Example
None.
- Function
Save the context for use with
longjmp
.- Header
- Declaration
int __fastcall__ setjmp (jmp_buf buf);
- Description
The
setjmp
function saves the current context inbuf
for subsequent use by thelongjmp
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
- Example
None.
- Function
Selects a locale.
- Header
- 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
- Example
None.
- Function
Install a signal handler.
- Header
- 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 handlersSIG_IGN
orSIG_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
- Example
None.
- Function
Sleep for a specified amount of time.
- Header
- 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.
- Function
Switch the CPU into slow mode (C128: 1MHz mode, C16/Plus4: single clock mode).
- Header
- 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
- Example
None.
- Function
Initialize the pseudo random number generator.
- Header
- 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
- Example
None.
- Function
Get file status.
- Header
- Declaration
int __fastcall__ stat (const char* pathname, struct stat* statbuf);
- Description
stat
gets information for the file with the given name. On success, zero is returned. On error, -1 is returned anderrno
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.
- On the Apple II platform, the st_ctim, st_mtim and st_atim members are left to zero, for size and performance reasons. The ProDOS creation and modification dates are returned in the ProDOS format in st_ctime and st_mtime. The access date does not exist. You can convert them to POSIX-style time representations using the ProDOS datetime conversion functions.
- Availability
POSIX 1003.1
- See also
- Example
#include <sys/stat.h> #define FILENAME "helloworld" struct stat stbuf; if (stat (FILENAME, &stbuf) == 0) { printf ("%s size is %lu bytes (created on %s)\n", FILENAME, stbuf.st_size, #ifndef __APPLE2__ localtime (&stbuf.st_ctim.tv_sec) #else localtime (mktime_dt (&stbuf.st_ctime)) #endif ); } else { printf ("There was a problem stat'ing %s: %d\n", FILENAME, errno); }
- Function
Get filesystem statistics.
- Header
- Declaration
int __fastcall__ statvfs (const char* pathname, struct statvfs* buf);
- Description
statvfs
gets information for the filesytem on which the given file resides. On success, zero is returned. On error, -1 is returned anderrno
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.
- The function requires an absolute pathname.
- Availability
POSIX 1003.1
- See also
- Example
#include <sys/statvfs.h> #define FILENAME "/disk/helloworld" struct statvfs stvbuf; if (statvfs (FILENAME, &stvbuf) == 0) { printf ("%s filesystem has %u blocks of %u size, %u of them free.\n", FILENAME, stvbuf.f_blocks, stvbuf.f_bsize, stvbuf.f_bfree); } else { printf ("There was a problem statvfs'ing %s: %d\n", FILENAME, errno); }
- Function
Compare two strings case insensitive.
- Header
- 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 ifs1
is less thans2
, zero ifs1
is the same ass2
, and a value greater than zero ifs1
is greater thans2
.- 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
- Example
None.
- Function
Concatenate two strings.
- Header
- 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
- Example
None.
- Function
Search for a character in a string.
- Header
- Declaration
char* __fastcall__ strchr (const char* s, int c);
- Description
The
strchr
function locates the first occurrence ofc
(converted to a char) in the string pointed to bys
. 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
- Example
None.
- Function
Compare two strings.
- Header
- 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 ifs1
is less thans2
, zero ifs1
is the same ass2
, and a value greater than zero ifs1
is greater thans2
.- 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
- Example
None.
- Function
Compare two strings.
- Header
- 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 bysetlocale
. It returns a value that is less than zero ifs1
is less thans2
, zero ifs1
is the same ass2
, and a value greater than zero ifs1
is greater thans2
.- 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
- Example
None.
- Function
Copy a string.
- Header
- Declaration
char* __fastcall__ strcpy (char* s1, const char* s2);
- Description
The
strcpy
function copies the string pointed to bys2
(including the terminating null byte) into the array pointed to bys1
. The function will always returns1
.- 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
- Example
#include <string.h> static char hello[14]; strcpy (hello, "Hello world!\n");
- Function
Compute the length of a substring.
- Header
- 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 bys
which does not consist of characters contained in the stringset
.- 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
- Example
None.
- Function
Allocate a copy of a string on the heap.
- Header
- Declaration
char* __fastcall__ strdup (const char* s);
- Description
strdup
allocates a memory block on the heap, big enough to hold a copy ofs
including the terminating zero. If the allocation fails,NULL
is returned, otherwises
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
- Example
None.
- Function
Return a string describing an error code.
- Header
- 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, anderrno
is set toEINVAL
. 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
- Example
None.
- Function
Compare two strings case insensitive.
- Header
- 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 ifs1
is less thans2
, zero ifs1
is the same ass2
, and a value greater than zero ifs1
is greater thans2
.- 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
- Example
None.
- Function
Return the length of a string.
- Header
- 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
- Example
None.
- Function
Make a string lower case.
- Header
- Declaration
char* __fastcall__ strlower (char* s);
- Description
The
strlower
function will apply thetolower
function to each character of a string. The function will always returns
.- 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
- Example
None.
See strlower
.
- Function
Compare two strings case insensitive.
- Header
- 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 ifs1
is less thans2
, zero ifs1
is the same ass2
, and a value greater than zero ifs1
is greater thans2
.- 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
- Example
None.
- Function
Concatenate two strings.
- Header
- 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
- Example
None.
- Function
Compare two strings.
- Header
- Declaration
int __fastcall__ strncmp (const char* s1, const char* s2, size_t count);
- Description
The
strncmp
function compares not more thancount
characters of the two strings passed as parameters. It returns a value that is less than zero if the firstcount
characters ofs1
are less thans2
, 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
- Example
None.
- Function
Copy part of a string.
- Header
- Declaration
char* __fastcall__ strncpy (char* s1, const char* s2, size_t n);
- Description
The
strncpy
function copies not more thann
bytes from the array pointed to bys2
to the array pointed to bys1
. If the array pointed to bys2
is a string that is shorter thann
bytes, null bytes are appended to the copy in the array pointed to bys1
, untiln
bytes are written. The function always will returns1
.- 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 bys2
, the result is not null-terminated!- If copying takes place between objects that overlap, the behaviour is undefined.
- Availability
ISO 9899
- See also
- Example
#include <string.h> static char hello[6]; strncpy (hello, "Hello world!\n", sizeof hello - 1)[5] = '\0';
- Function
Compare two strings case insensitive.
- Header
- 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 ifs1
is less thans2
, zero ifs1
is the same ass2
, and a value greater than zero ifs1
is greater thans2
.- 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
- Example
None.
- Function
Find a character in a string, from a set of characters.
- Header
- Declaration
char* __fastcall__ strpbrk (const char* str, const char* set);
- Description
strpbrk()
searches withinstr
for the first occurrence of any character fromset
. It returns a pointer to that character if found; otherwise, it returnsNULL
.- 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
- Example
None.
- Function
Break a string into tokens.
- Header
- Declaration
char* __fastcall__ strqtok (char* s1, const char* s2);
- Description
strqtok()
will break the strings1
into a sequence of tokens, which are delimited by either quotation marks or characters from the strings2
. Tokens inside quotation marks may contain characters froms2
(they aren't delimiters there). The first call tostrqtok()
will return a pointer to the first token in the strings1
. The following calls must pass aNULL
pointer ass1
, in order to get the next token in the string. Different sets of delimiters may be used for the subsequent calls tostrqtok()
.- 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 strings1
.- The function will forget where it is in the
s1
string if it is given a seconds1
string before it finishes the first one.- Availability
cc65
- See also
- Example
None.
- Function
Search for a character in a string.
- Header
- Declaration
char* __fastcall__ strrchr (const char* s, int c);
- Description
The
strrchr
function locates the last occurrence ofc
(converted to a char) in the string pointed to bys
. 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
- Example
None.
- Function
Compute the length of a substring.
- Header
- 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 bys
which does consist only of characters contained in the stringset
.- 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
- Example
None.
- Function
Find a substring, case-insensitive.
- Header
- Declaration
char* __fastcall__ strcasestr (const char* str, const char* substr);
- Description
strcasestr
searches for the first occurrence of the stringsubstr
withinstr
. If found, it returns a pointer to the start of the match instr
, otherwise it returnsNULL
.- 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
- Example
None.
- Function
Find a substring, case-sensitive.
- Header
- Declaration
char* __fastcall__ strstr (const char* str, const char* substr);
- Description
strstr
searches for the first occurrence of the stringsubstr
withinstr
. If found, it returns a pointer to the start of the match instr
, otherwise it returnsNULL
.- 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
- Example
None.
- Function
Break a string into tokens.
- Header
- Declaration
char* __fastcall__ strtok (char* s1, const char* s2);
- Description
strtok()
will break the strings1
into a sequence of tokens, which are delimited by characters from the strings2
. The first call tostrtok()
will return a pointer to the first token in the strings1
. The following calls must pass aNULL
pointer ass1
, in order to get the next token in the string. Different sets of delimiters may be used for the subsequent calls tostrtok()
.- Notes
- The function is only available as fastcall function, so it may only be used in presence of a prototype.
strtok()
will modify the strings1
.- The function will forget where it is in the
s1
string if it is given a seconds1
string before it finishes the first one.- Availability
ISO 9899
- See also
- Example
None.
- Function
Transform a string.
- Header
- 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 thestrcmp
function is applied to two transformed strings, it returns a value greater than, equal to, or less than zero, corresponding to the result of thestrcoll
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
ands2
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 character sets,
strxfrm
will just copy s2 to s1 usingstrncpy
.- Availability
ISO 9899
- See also
- Example
None.
- Function
Make a string upper case.
- Header
- Declaration
char* __fastcall__ strupper (char* s);
- Description
The
strupper
function will apply thetoupper
function to each character of a string. The function will always returns
.- 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
- Example
None.
See strupper
.
- Function
Return the current position of a directory stream.
- Header
- 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 toseekdir
.- 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
- Example
None.
- Function
Set the text color.
- Header
- 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
- Example
None.
- Function
Get the time.
- Header
- 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 notNULL
, the function result will also be stored there. If no time is available,(time_t)-1
is returned and an error code is stored inerrno
.- 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
- Example
None.
- Function
Toggle between 40 and 80 column mode.
- Header
- 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
- Example
None.
- Function
Convert a character into its lower case representation.
- Header
- 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
- Example
None.
- Function
Convert a character into its upper case representation.
- Header
- 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
- Example
None.
- Function
Convert an unsigned long integer into a string.
- Header
- Declaration
char* __fastcall__ ultoa (unsigned long val, char* buf, int radix);
- Description
itoa
converts the unsigned long integerval
into a string usingradix
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
- Example
None.
- Function
Delete a file.
- Header
- 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 anderrno
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
- 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); }
- Function
Convert an unsigned integer into a string.
- Header
- Declaration
char* __fastcall__ utoa (unsigned val, char* buf, int radix);
- Description
itoa
converts the unsigned integerval
into a string usingradix
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
- Example
None.
- Function
Formatted output to the console.
- Header
- 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 asvprintf
.- 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
- Example
None.
- Function
Switch to either 40- or 80-column text mode, or a standard graphics mode.
- Header
- 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
- Example
None.
- Function
Return the current X position of the text mode cursor.
- Header
- 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
- Example
None.
- Function
Return the current Y position of the text mode cursor.
- Header
- 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
- Example
None.