c128lib Framework
A Commodore 128 software framework for enabling high-level development of C128 programs.
|
Functions | |
macro | c128lib_StringCompare (string1Address, string2Address, switchToFastModeWhileRunning) |
String manipulation module. | |
macro | c128lib_StringLength (stringAddress, switchToFastModeWhileRunning) |
macro | c128lib_StringCopy (sourceAddress, destinationAddress, switchToFastModeWhileRunning) |
macro | c128lib_StringCopyLeft (sourceAddress, destinationAddress, numChars, switchToFastModeWhileRunning) |
macro | c128lib_StringCopyRight (sourceAddress, destinationAddress, sourceStrLength, numChars, switchToFastModeWhileRunning) |
macro | c128lib_StringCopyMid (sourceAddress, destinationAddress, startPos, numChars, switchToFastModeWhileRunning) |
macro | c128lib_StringConcatenate (string1Address, string2Address, string1Length, switchToFastModeWhileRunning) |
macro | c128lib_Int8ToString (int8Address, stringAddress, switchToFastMode) |
macro | c128lib_Int16ToString (int16Address, stringAddress, switchToFastMode) |
macro c128lib_StringCompare | ( | string1Address | , |
string2Address | , | ||
switchToFastModeWhileRunning | ) |
String manipulation module.
The strings are a maximum of 255 bytes long and are null terminated. The null character makes the interal storage a max of 256 bytes. For strings 256 bytes and longer, these macros can be repeated for each set of 256 bytes.
String addresses can be absolute addresses or post-indexed indirect, "(Zero-Page), Y". To be clear, if passing a zero-page address, it is implied that the address is an indirect address that will be post-indexed by Y by the macro. So, the zero page address will hold the absolute address (small endian) of the string. Only pass the zero-page address without brackets, such as $FA. Last usable zero-page address for post-indexed indirect addressing mode is $FE, so do not pass $FF.
Numeric parameters must be an address. That is, store the number in an address (zero-page or 16-bit) and then pass the address to the parameter. In the comments, these parameters will be dereferenced by the *, as in C notation. For example, numChars is the address, and numChars is the value stored at address numChars.
Notes: When a post condition is that the carry is set, a programmer can repeat these macros for strings 256 chars or longer. The programmer would call the macros as many times as the number of 256-byte strings needed for memory allocation of the string. In this way, a programmer can create a string data type with length longer than 255.
In this case, multiple 256-byte strings could be used to represent a long string, with each 256-byte string holding 256 characters, excluding the terminator (#0), except for the last byte 256-byte string which must be terminated at 255.
Examples will be given in the official documentation.
[in] | string1Address | Address of string1 |
[in] | string2Address | Address of string2 |
[in] | switchToFastModeWhileRunning | If true, fast mode will be enabled at start and disabled at end. |
macro c128lib_StringLength | ( | stringAddress | , |
switchToFastModeWhileRunning | ) |
Find the length of a string.
[in] | stringAddress | Address of string |
[in] | switchToFastModeWhileRunning | If true, fast mode will be enabled at start and disabled at end. |
macro c128lib_StringCopy | ( | sourceAddress | , |
destinationAddress | , | ||
switchToFastModeWhileRunning | ) |
Copies a string from a source address to a destination address
[in] | sourceAddress | Address of source string |
[out] | destinationAddress | Destination address for copied string |
[in] | switchToFastModeWhileRunning | If true, fast mode will be enabled at start and disabled at end. |
macro c128lib_StringCopyLeft | ( | sourceAddress | , |
destinationAddress | , | ||
numChars | , | ||
switchToFastModeWhileRunning | ) |
Copies a left substring of length *numChars from a source address to a destination address.
[in] | sourceAddress | Address of source string |
[out] | destinationAddress | Destination address for copied substring |
[in] | numChars | Address storing the number of characters from left to copy |
[in] | switchToFastModeWhileRunning | If true, fast mode will be enabled at start and disabled at end. |
macro c128lib_StringCopyRight | ( | sourceAddress | , |
destinationAddress | , | ||
sourceStrLength | , | ||
numChars | , | ||
switchToFastModeWhileRunning | ) |
Copies a right substring of length *numChars from a source address to a destination address.
[in] | sourceAddress | Address of source string |
[out] | destinationAddress | Destination address for copied substring |
[in] | sourceStrLength | Address storing the length of source string (required for performance, use StringLength()) |
[in] | numChars | Address storing the number of characters from right to copy |
[in] | switchToFastModeWhileRunning | If true, fast mode will be enabled at start and disabled at end. |
macro c128lib_StringCopyMid | ( | sourceAddress | , |
destinationAddress | , | ||
startPos | , | ||
numChars | , | ||
switchToFastModeWhileRunning | ) |
Copies a substring of a string, starting from a given index, and of length numChars from a source address to a destination address.
[in] | sourceAddress | Address of source string |
[out] | destinationAddress | Destination address for copied substring |
[in] | startPos | Address of memory holding starting position of the substring, where the first postion is 0 |
[in] | numChars | Address of memory holding the number of characters from the starting position of the substring |
[in] | switchToFastModeWhileRunning | If true, fast mode will be enabled at start and disabled at end. |
macro c128lib_StringConcatenate | ( | string1Address | , |
string2Address | , | ||
string1Length | , | ||
switchToFastModeWhileRunning | ) |
Concatenate string2 to string1. The resulting string will be located at the address of string1.
[in,out] | string1Address | Address of first string |
[in] | string2Address | Address of second string |
[in] | string1Length | Address to the length of string1 (required for performance, use StringLength()) |
[in] | switchToFastModeWhileRunning | If true, fast mode will be enabled at start and disabled at end. |
macro c128lib_Int8ToString | ( | int8Address | , |
stringAddress | , | ||
switchToFastMode | ) |
Convert an 8-bit integer to an ASCII string.
[in] | int8Address | Address of 8-bit integer |
[out] | stringAddress | Address of 3-byte ASCII string representation of *int8Arg |
[in] | switchToFastMode | If true, fast mode will be enabled at start and disabled at end. |
macro c128lib_Int16ToString | ( | int16Address | , |
stringAddress | , | ||
switchToFastMode | ) |
Convert a 16-bit integer to an ASCII string.
[in] | int16Address | Address of 16-bit integer |
[out] | stringAddress | Address of 5-byte ASCII string representation of *int16Address |
[in] | switchToFastMode | If true, fast mode will be enabled at start and disabled at end. |