GBDK 2020 Docs
4.3.0
API Documentation for GBDK 2020
|
Go to the source code of this file.
Macros | |
#define | BCD_HEX(v) ((BCD)(v)) |
#define | MAKE_BCD(v) BCD_HEX(0x ## v) |
Typedefs | |
typedef uint32_t | BCD |
Functions | |
void | uint2bcd (uint16_t i, BCD *value) |
void | bcd_add (BCD *sour, const BCD *value) |
void | bcd_sub (BCD *sour, const BCD *value) |
uint8_t | bcd2text (const BCD *bcd, uint8_t tile_offset, uint8_t *buffer) |
Support for working with BCD (Binary Coded Decimal)
See the example BCD project for additional details.
#define BCD_HEX | ( | v | ) | ((BCD)(v)) |
#define MAKE_BCD | ( | v | ) | BCD_HEX(0x ## v) |
Converts an integer value into BCD format
A maximum of 8 digits may be used
Converts integer i into BCD format (Binary Coded Decimal)
i | Numeric value to convert |
value | Pointer to a BCD variable to store the converted result |
Adds two numbers in BCD format: sour += value
sour | Pointer to a BCD value to add to (and where the result is stored) |
value | Pointer to the BCD value to add to sour |
Subtracts two numbers in BCD format: sour -= value
sour | Pointer to a BCD value to subtract from (and where the result is stored) |
value | Pointer to the BCD value to subtract from sour |
Convert a BCD number into an asciiz (null terminated) string and return the length
bcd | Pointer to BCD value to convert |
tile_offset | Optional per-character offset value to add (use 0 for none) |
buffer | Buffer to store the result in |
Returns: Length in characters (always 8)
buffer should be large enough to store the converted string (9 bytes: 8 characters + 1 for terminator)
There are a couple different ways to use tile_offset. For example: