6502.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
ctype.h
dbg.h
dio.h
dirent.h
em.h
errno.h
fcntl.h
geos.h
joystick.h
locale.h
lynx.h
modload.h
mouse.h
nes.h
o65.h
peekpoke.h
pet.h
plus4.h
serial.h
setjmp.h
signal.h
stdarg.h
stdbool.h
stddef.h
stdio.h
stdlib.h
string.h
tgi.h
time.h
unistd.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 refrence 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. Since these functions behave identical 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
apple2.h
apple2enh.h
assert.h
atari.h
(incomplete)
atmos.h
(incomplete)
c128.h
c16.h
(incomplete)
c64.h
cbm.h
(incomplete)
cbm510.h
cbm610.h
cc65.h
(incomplete)
conio.h
ctype.h
dbg.h
(incomplete)
dio.h
dirent.h
(incomplete)
em.h
errno.h
(incomplete)
fcntl.h
geos.h
(incomplete)
joystick.h
locale.h
lynx.h
(incomplete)
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.
peekpoke.h
pet.h
(incomplete)
plus4.h
(incomplete)
serial.h
The serial.h
header file contains definitions for initializing serial
communication.
setjmp.h
signal.h
stdarg.h
(incomplete)
stdbool.h
(incomplete)
stddef.h
stdio.h
(incomplete)
stdlib.h
(incomplete)
string.h
(incomplete)
tgi.h
time.h
(incomplete)
unistd.h
(incomplete)
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.
- 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 unpredicable results.
- 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 __fastcall__ _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
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
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 aid
statement. If the condition evaluates t zero (false), assert prints a message on stderr and aborts the program.- 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
Load Atmos tape.
- Header
- Declaration
void __fastcall__ atmos_load(const char* name);
- Description
atmos_load
reads a memory block from tape.- Availability
cc65
- See also
- 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.- Availability
cc65
- See also
- Example
atmos_save("hires", 0xa000, 0xc000);
- 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
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 (*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.
- 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
C128
- 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
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
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 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.
- Notes
- 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 this buffer and wait only if the buffer is empty.- 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, cc65 generated programs run on, cannot run multiple processes, the function will actually return the time since some implementation defined point in the past.
- Availability
ISO 9899
- See also
- Example
None.
- 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
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
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
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 (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
void __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 transfered into a buffer. If you don't need the actual contents of the page (for example because you're going to overwrite it completely), it is better to call
em_use
instead.em_use
will not transfer the data if it is possible to avoid that.- Notes
- Calling
em_map
will invalidate the memory window, so if you made any changes to the data in the window, 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 C128 into 2MHz mode.
- Header
- Declaration
void fast (void);
- Description
The function will switch the clock of the C128 to 2MHz. This will nearly double the speed compared to slow mode.
- Notes
- The function is specific to the C128.
- 2MHz clock will not work in 40 column mode.
- Availability
C128
- 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 ofthe 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
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
- Notes
- Other, more exotic CPU types are not disinguished.
- Availability
cc65
- Example
None.
- 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
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 preceeded 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
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 with
-Os
the function is actually a macro. The inline sequence generated by the macro will not work correctly for values outside the range 0..255. Note: The constantEOF
is not part of this range. The non inline function may be accessed by#undef
'ing the macro.- 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 with
-Os
the function is actually a macro. The inline sequence generated by the macro will not work correctly for values outside the range 0..255. Note: The constantEOF
is not part of this range. The non inline function may be accessed by#undef
'ing the macro.- 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 with
-Os
the function is actually a macro. The inline sequence generated by the macro will not work correctly for values outside the range 0..255. Note: The constantEOF
is not part of this range. The non inline function may be accessed by#undef
'ing the macro.- 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 with
-Os
the function is actually a macro. The inline sequence generated by the macro will not work correctly for values outside the range 0..255. Note: The constantEOF
is not part of this range. The non inline function may be accessed by#undef
'ing the macro.- 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 with
-Os
the function is actually a macro. The inline sequence generated by the macro will not work correctly for values outside the range 0..255. Note: The constantEOF
is not part of this range. The non inline function may be accessed by#undef
'ing the macro.- 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 with
-Os
the function is actually a macro. The inline sequence generated by the macro will not work correctly for values outside the range 0..255. Note: The constantEOF
is not part of this range. The non inline function may be accessed by#undef
'ing the macro.- 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 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 with
-Os
the function is actually a macro. The inline sequence generated by the macro will not work correctly for values outside the range 0..255. Note: The constantEOF
is not part of this range. The non inline function may be accessed by#undef
'ing the macro.- 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 with
-Os
the function is actually a macro. The inline sequence generated by the macro will not work correctly for values outside the range 0..255. Note: The constantEOF
is not part of this range. The non inline function may be accessed by#undef
'ing the macro.- 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 with
-Os
the function is actually a macro. The inline sequence generated by the macro will not work correctly for values outside the range 0..255. Note: The constantEOF
is not part of this range. The non inline function may be accessed by#undef
'ing the macro.- 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 with
-Os
the function is actually a macro. The inline sequence generated by the macro will not work correctly for values outside the range 0..255. Note: The constantEOF
is not part of this range. The non inline function may be accessed by#undef
'ing the macro.- 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 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 with
-Os
the function is actually a macro. The inline sequence generated by the macro will not work correctly for values outside the range 0..255. Note: The constantEOF
is not part of this range. The non inline function may be accessed by#undef
'ing the macro.- 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 with
-Os
the function is actually a macro. The inline sequence generated by the macro will not work correctly for values outside the range 0..255. Note: The constantEOF
is not part of this range. The non inline function may be accessed by#undef
'ing the macro.- 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 with
-Os
the function is actually a macro. The inline sequence generated by the macro will not work correctly for values outside the range 0..255. Note: The constantEOF
is not part of this range. The non inline function may be accessed by#undef
'ing the macro.- 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 (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
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
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 preceeding 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.
- Availability
cc65
- See also
- Example
None.
- Function
Load a relocatable module.
- Header
- Declaration
unsigned char 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.
- 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 __fastcall__ 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
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 direcory 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
Sort an array.
- Header
- Declaration
void __fastcall__ qsort (void* base, size_t count, size_t size, int (*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.
- 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, nonzero otherwise.- 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 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 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 loose 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 exitting 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 exitting 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 (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.
- 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 exitting 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 exitting the program.- Availability
cc65
- 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 C128 into 1MHz mode.
- Header
- Declaration
void slow (void);
- Description
The function will switch the clock of the C128 to 1MHz. This will halve the speed compared to fast mode.
- Notes
- The function is specific to the C128.
- Availability
C128
- 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
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
Concatentate 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
Concatentate 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
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.
- Header
- Declaration
char* __fastcall__ strstr (const char* str, const char* substr);
- Description
strstr
searches for the first occurance of the stringsubstr
withinstr
. If found, it returns a pointer to the copy, 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 charcter 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
Draw an elliptic arc in the current color.
- Header
- Declaration
void __fastcall__ tgi_arc (int x, int y, unsigned char rx, unsigned char ry, unsigned sa, unsigned ea);
- Description
The function draws an elliptic arc with center at x/y and radii rx/ry using the current drawing color. The arc covers the angle between sa and ea (startangle and endangle), which must be in the range 0..360.
- Notes
- The function is only available as fastcall function, so it may only be used in presence of a prototype.
- The function behaves unexpectedly or may crash if the angles are out of range.
- Availability
cc65
- See also
tgi_bar, tgi_circle, tgi_ellipse, tgi_pieslice, tgi_setcolor
- Example
/* Draw the upper half of an ellipse */ tgi_setcolor(TGI_COLOR_BLUE); tgi_arc (50, 50, 40, 20, 0, 180);
- Function
The function fills a rectangle on the drawpage with the current color.
- Header
- Declaration
void __fastcall__ tgi_bar (int x1, int y1, int x2, int y2);
- Description
The function fills a rectangle on the drawpage with the current 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
Other tgi function
- Example
tgi_setcolor(TGI_COLOR_GREEN); tgi_bar(10, 10, 100, 60);
- Function
The function draws a circle in the current color.
- Header
- Declaration
void __fastcall__ tgi_circle (int x, int y, unsigned char radius);
- Description
The function draws a circle in the current 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
tgi_setcolor(TGI_COLOR_BLACK); tgi_circle(50, 40, 40);
- Function
Clear the drawpage
- Header
- Declaration
void tgi_clear (void);
- Description
Clear the drawpage
- Availability
cc65
- See also
Other tgi functions
- Example
None.
- Function
End graphics mode, switch back to text mode. Will NOT uninstall or unload the driver!
- Header
- Declaration
void tgi_done (void);
- Description
End graphics mode, switch back to text mode. Will NOT uninstall or unload the driver!
- Availability
cc65
- See also
Other tgi functions
- Example
None.
- Function
The function draws an ellipse in the current color.
- Header
- Declaration
void __fastcall__ tgi_ellipse (int x, int y, unsigned char rx, unsigned char ry);
- Description
The function draws an ellipse at position x/y with radii rx and ry, using the current drawing 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
tgi_setcolor(TGI_COLOR_RED); tgi_ellipse (50, 40, 40, 20);
- Function
Free a vector font that was previously loaded into memory.
- Header
- Declaration
void __fastcall__ tgi_free_vectorfont (const tgi_vectorfont* font);
- Description
Free a vector font that was previously loaded into memory.
- 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 the pixel aspect ratio.
- Header
- Declaration
unsigned tgi_getaspectratio (void);
- Description
The function returns the pixel aspect ratio for the current driver and display as an 8.8 fixed point value. It may be used to correct geometric shapes so they look correct on the display. As an example, a circle with a radius of 100 pixels may look elliptic on some driver/display combinations if the aspect ratio is not 1.00.
- Notes
- The aspect ratio is encoded in the TGI driver which assumes a "standard" monitor for the given platform. The aspect ratio may be wrong if another monitor is used.
- No TGI function will use the aspect ratio. It is up to the programmer to make use of it.
- The tgi_setaspectratio function can be used to change the aspect ratio for a loaded driver. The value is not reset by tgi_init, so if a driver is linked statically to an application, switching into and out of graphics mode will not restore the original aspect ratio.
- Availability
cc65
- See also
- Example
None.
- Function
Return the current drawing color.
- Header
- Declaration
unsigned char tgi_getcolor (void);
- Description
The actual color is an index to a palette. During tgi_init you will get a default palette. The number of colors depend on the platform. All platforms recognize at least TGI_COLOR_BLACK and TGI_COLOR_WHITE. But some platforms have many more predefined colors. If you paint using TGI_COLOR_GREEN and then you change the green of the palette to blue using tgi_setpalette then after this painting in TGI_COLOR_GREEN will actually be blue.
- Availability
cc65
- See also
Other tgi functions
- Example
color = tgi_getcolor();
- Function
Get the number of available colors.
- Header
- Declaration
unsigned char tgi_getcolorcount (void);
- Description
Tgi platforms use indexed color palettes. This function returns the number of entries we can use in the palette.
- Availability
cc65
- See also
Other tgi functions
- Example
if (tgi_getcolorcount() == 2) { printf("Only monochrome graphics is supported\n"); }
- Function
Get the palette installed by default.
- Header
- Declaration
const unsigned char* tgi_getdefpalette (void);
- Description
The tgi driver has a default palette that is active at startup. The named colors TGI_COLOR_BLACK, TGI_COLOR_WHITE, TGI_COLOR_RED... need this palette to work correctly.
- Availability
cc65
- See also
Other tgi functions
- Example
None.
- Function
Return the error code for the last operation. This will also clear the error.
- Header
- Declaration
unsigned char tgi_geterror (void);
- Description
Return the error code for the last operation. This will also clear the error.
- Availability
cc65
- See also
Other tgi functions
- Example
None.
- Function
Get an error message describing the error.
- Header
- Declaration
const char* __fastcall__ tgi_geterrormsg (unsigned char code);
- Description
Get an error message describing the 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 tgi functions
- Example
None.
- Function
Get the highest index of the palette.
- Header
- Declaration
unsigned char tgi_getmaxcolor (void);
- Description
Get the highest index of the palette.
- Availability
cc65
- See also
Other tgi functions
- Example
None.
- Function
Get the maximum x coordinate that can be used on this screen.
- Header
- Declaration
unsigned tgi_getmaxx (void);
- Description
Get the maximum x coordinate that can be used on this screen.
- Availability
cc65
- See also
Other tgi functions
- Example
None.
- Function
Get the maximum y coordinate that can be used on this screen.
- Header
- Declaration
unsigned tgi_getmaxy (void);
- Description
Get the maximum y coordinate that can be used on this screen.
- Availability
cc65
- See also
Other tgi functions
- Example
None.
- Function