libnds
|
Nintendo DS Bios functions. More...
#include "nds/ndstypes.h"
Data Structures | |
struct | DecompressionStream |
A struct that contains callback function pointers used by the decompression functions. More... | |
struct | UnpackStruct |
A struct and struct pointer with information about unpacking data. More... | |
Macros | |
#define | COPY_MODE_COPY (0) |
copy a range of memory to another piece of memory | |
#define | COPY_MODE_FILL BIT(24) |
fill a piece of memory with a value. | |
#define | COPY_MODE_HWORD (0) |
copy in chunks of halfword size. | |
#define | COPY_MODE_WORD BIT(26) |
copy in chunks of word size. | |
Typedefs | |
typedef u8(* | getByteCallback) (u8 *source) |
Should returns a raw byte of the stream. More... | |
typedef int(* | getHeaderCallback) (u8 *source, u16 *dest, u32 arg) |
Should return the header of a compressed stream of bytes. More... | |
typedef int(* | getResultCallback) (u8 *source) |
Should verify the result after data got decompressed. More... | |
typedef struct DecompressionStream | TDecompressionStream |
A struct that contains callback function pointers used by the decompression functions. | |
typedef struct UnpackStruct | TUnpackStruct |
A struct and struct pointer with information about unpacking data. | |
Functions | |
void | swiChangeSoundBias (int enabled, int delay) |
increments or decrements the sound bias once per delay. More... | |
void | swiCopy (const void *source, void *dest, int flags) |
copies or fills some memory. More... | |
uint16 | swiCRC16 (uint16 crc, void *data, uint32 size) |
calculates a CRC-16 checksum. More... | |
void | swiDecodeDelta16 (void *source, void *destination) |
Decodes a stream of bytes based on the difference of the bytes. More... | |
void | swiDecodeDelta8 (void *source, void *destination) |
Decodes a stream of bytes based on the difference of the bytes. More... | |
int | swiDecompressHuffman (void *source, void *destination, uint32 toGetSize, TDecompressionStream *stream) |
Decompresses Huffman compressed data. More... | |
int | swiDecompressLZSSVram (void *source, void *destination, uint32 toGetSize, TDecompressionStream *stream) |
Decompresses LZSS compressed data vram safe. More... | |
void | swiDecompressLZSSWram (void *source, void *destination) |
Decompresses LZSS compressed data. More... | |
int | swiDecompressRLEVram (void *source, void *destination, uint32 toGetSize, TDecompressionStream *stream) |
Decompresses RLE compressed data vram safe. More... | |
void | swiDecompressRLEWram (void *source, void *destination) |
Decompresses RLE compressed data. More... | |
void | swiDelay (uint32 duration) |
delays the code. More... | |
int | swiDivide (int numerator, int divisor) |
divides 2 numbers. More... | |
void | swiDivMod (int numerator, int divisor, int *result, int *remainder) |
divides 2 numbers and stores both the result and the remainder. More... | |
void | swiFastCopy (const void *source, void *dest, int flags) |
copies or fills some memory. can only copy in word chunks. More... | |
uint16 | swiGetPitchTable (int index) |
Returns an entry in the pitch table. More... | |
uint16 | swiGetSineTable (int index) |
Returns an entry in the sine table. More... | |
uint8 | swiGetVolumeTable (int index) |
Returns an entry in the volume table. More... | |
void | swiHalt (void) |
Halts the CPU untill an interupt occures. More... | |
int | swiIsDebugger (void) |
returns 0 if running on a nintendo hardware debugger. More... | |
int | swiRemainder (int numerator, int divisor) |
calculate the remainder of an division. More... | |
void | swiSetHaltCR (uint32 data) |
Writes a word of the data to 0x04000300:32. More... | |
void | swiSetHaltCR (uint8 data) |
Writes a byte of the data to 0x04000301:8. More... | |
void | swiSleep (void) |
Halts the CPU and most of the hardware untill an interupt occures. More... | |
void | swiSoftReset (void) |
resets the DS. | |
int | swiSqrt (int value) |
calculates the square root. More... | |
void | swiSwitchToGBAMode (void) |
Switches the DS to GBA mode. More... | |
void | swiUnpackBits (uint8 *source, uint32 *destination, PUnpackStruct params) |
Unpack data stored in multiple elements in a byte to a larger space. More... | |
void | swiWaitForIRQ (void) |
wait for any interrupt. More... | |
Nintendo DS Bios functions.
See gbatek for more information.
Should returns a raw byte of the stream.
source | A pointer to the byte. |
Should return the header of a compressed stream of bytes.
The result is a word, with the size of decompressed data in bits 8-31, and bits 0-7 are ignored. This value is also returned by the bios function, unless getResult is non-NULL and returns a negative value. This useally returns the 4 bytes that source points to.
source | A pointer to the compressed data. |
dest | A pointer to the space where the decompressed data should be copied to. |
arg | A callback value that gets passed to the bios function. |
typedef int(* getResultCallback) (u8 *source) |
Should verify the result after data got decompressed.
getResult is used to provide a result for the bios function, given the source pointer after all data has been read (or if getSize < 0). Its value is only returned if negative, otherwise the typical result is used, so it is likely some sort of error-checking procedure.
source | The current source address. |
void swiChangeSoundBias | ( | int | enabled, |
int | delay | ||
) |
increments or decrements the sound bias once per delay.
enabled | 0 to decrement it until it reaches 0x000, 1 to increment it until it reaches 0x200. |
delay | Is in the same units of time as swiDelay. |
void swiCopy | ( | const void * | source, |
void * | dest, | ||
int | flags | ||
) |
copies or fills some memory.
source | pointer to transfer source or pointer to value to fill the memory with. |
dest | pointer to transfer destination. |
flags | bits(0-20): size of data to copy/fill in words, or'd with the copy mode size (word or halfword) and type (copy or fill). |
calculates a CRC-16 checksum.
crc | starting CRC-16 value. |
data | pointer to data (processed nibble by nibble) |
size | size in bytes. |
void swiDecodeDelta16 | ( | void * | source, |
void * | destination | ||
) |
Decodes a stream of bytes based on the difference of the bytes.
source | Pointer to a header word, followed by encoded data. word(31..8) = size of data (in bytes). word(7..0) = ignored. |
destination | Destination address. |
void swiDecodeDelta8 | ( | void * | source, |
void * | destination | ||
) |
Decodes a stream of bytes based on the difference of the bytes.
source | Pointer to a header word, followed by encoded data. word(31..8) = size of data (in bytes). word(7..0) = ignored. |
destination | Destination address. |
int swiDecompressHuffman | ( | void * | source, |
void * | destination, | ||
uint32 | toGetSize, | ||
TDecompressionStream * | stream | ||
) |
Decompresses Huffman compressed data.
source | Pointer to source data (always goes through the function pointers, so could just be an offset). |
destination | Pointer to destination. |
toGetSize | Callback value that is passed to getHeaderCallback function pointer. |
stream | Pointer to struct with callback function pointers. |
int swiDecompressLZSSVram | ( | void * | source, |
void * | destination, | ||
uint32 | toGetSize, | ||
TDecompressionStream * | stream | ||
) |
Decompresses LZSS compressed data vram safe.
source | Pointer to source data (always goes through the function pointers, so could just be an offset). |
destination | Pointer to destination. |
toGetSize | Callback value that is passed to getHeaderCallback function pointer. |
stream | Pointer to struct with callback function pointers. |
void swiDecompressLZSSWram | ( | void * | source, |
void * | destination | ||
) |
Decompresses LZSS compressed data.
source | pointer to a header word, followed by compressed data. bit 0-7 of header is ignored. bit 8-31 of header is size of uncompressed data in bytes. |
destination | destination address. |
int swiDecompressRLEVram | ( | void * | source, |
void * | destination, | ||
uint32 | toGetSize, | ||
TDecompressionStream * | stream | ||
) |
Decompresses RLE compressed data vram safe.
compressed data format: bit(7): 0= uncompressed, 1= compressed. bit(0-6) when uncompressed: run length - 1, followed by run_length bytes of true data. bit(0-6) when compressed: run length - 3, followed by one byte of true data, to be repeated.
source | Pointer to source data (always goes through the function pointers, so could just be an offset). |
destination | Pointer to destination. |
toGetSize | Callback value that is passed to getHeaderCallback function pointer. |
stream | Pointer to struct with callback function pointers. |
void swiDecompressRLEWram | ( | void * | source, |
void * | destination | ||
) |
Decompresses RLE compressed data.
compressed data format: bit(7): 0= uncompressed, 1= compressed. bit(0-6) when uncompressed: run length - 1, followed by run_length bytes of true data. bit(0-6) when compressed: run length - 3, followed by one byte of true data, to be repeated.
source | pointer to a header word, followed by compressed data. bit 0-7 of header is ignored. bit 8-31 of header is size of uncompressed data in bytes. |
destination | destination address. |
void swiDelay | ( | uint32 | duration | ) |
delays the code.
Delays for for a period X + Y*duration where X is the swi overhead and Y is a cycle of
loop: sub r0, #1 bgt loop
of thumb fetches in BIOS memory
duration | length of delay |
int swiDivide | ( | int | numerator, |
int | divisor | ||
) |
divides 2 numbers.
numerator | signed integer to divide |
divisor | signed integer to divide by |
void swiDivMod | ( | int | numerator, |
int | divisor, | ||
int * | result, | ||
int * | remainder | ||
) |
divides 2 numbers and stores both the result and the remainder.
numerator | signed integer to divide |
divisor | signed integer to divide by |
result | pointer to integer set to numerator / divisor |
remainder | pointer to integer set to numerator % divisor |
void swiFastCopy | ( | const void * | source, |
void * | dest, | ||
int | flags | ||
) |
copies or fills some memory. can only copy in word chunks.
source | pointer to transfer source or pointer to value to fill the memory with. |
dest | pointer to transfer destination. |
flags | bits(0-20): size of data to copy/fill in words, or'd with the type (copy or fill). |
uint16 swiGetPitchTable | ( | int | index | ) |
Returns an entry in the pitch table.
index | The index of the pitch table (0-767). |
uint16 swiGetSineTable | ( | int | index | ) |
Returns an entry in the sine table.
index | The index of the sine table (0-63). |
uint8 swiGetVolumeTable | ( | int | index | ) |
Returns an entry in the volume table.
index | The index of the volume table (0-723). |
void swiHalt | ( | void | ) |
Halts the CPU untill an interupt occures.
int swiIsDebugger | ( | void | ) |
returns 0 if running on a nintendo hardware debugger.
int swiRemainder | ( | int | numerator, |
int | divisor | ||
) |
calculate the remainder of an division.
numerator | signed integer to divide |
divisor | signed integer to divide by |
void swiSetHaltCR | ( | uint32 | data | ) |
Writes a word of the data to 0x04000300:32.
data | the word to write. |
void swiSetHaltCR | ( | uint8 | data | ) |
Writes a byte of the data to 0x04000301:8.
data | The byte to write. |
void swiSleep | ( | void | ) |
Halts the CPU and most of the hardware untill an interupt occures.
int swiSqrt | ( | int | value | ) |
calculates the square root.
value | the value to calculate. |
void swiSwitchToGBAMode | ( | void | ) |
Switches the DS to GBA mode.
void swiUnpackBits | ( | uint8 * | source, |
uint32 * | destination, | ||
PUnpackStruct | params | ||
) |
Unpack data stored in multiple elements in a byte to a larger space.
i.e. 8 elements per byte (i.e. b/w font), into 1 element per byte.
source | Source address. |
destination | destination address (word aligned). |
params | pointer to an UnpackStruct. |
void swiWaitForIRQ | ( | void | ) |
wait for any interrupt.