| 
    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 | BIOS_UNPACK_OFFSET_ADD_ALWAYS (1u << 31) | 
| For TUnpackStruct.dataOffset, this flag signals that all destination writes, zero or non-zero, should be offset.  | |
| #define | BIOS_UNPACK_OFFSET_ADD_NON_ZERO (0u << 31) | 
| For TUnpackStruct.dataOffset, this flag signals that only non-zero destination writes should be offset.  | |
| #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 return a raw byte of the stream.   | |
| typedef u16(* | getHalfWordCallback) (u16 *source) | 
| Should return a raw halfword of the stream.   | |
| typedef int(* | getHeaderCallback) (u8 *source, u16 *dest, u32 arg) | 
| Should return the header of a compressed stream of bytes.   | |
| typedef int(* | getResultCallback) (u8 *source) | 
| Should verify the result after data got decompressed.   | |
| typedef u32(* | getWordCallback) (u32 *source) | 
| Should return a raw word of the stream.   | |
| 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 | |
| static void | swiChangeSoundBias (int enabled, int delay) | 
| Increments or decrements the sound bias once per delay.   | |
| static void | swiCopy (const void *source, void *dest, int flags) | 
| Copies or fills some memory.   | |
| static uint16_t | swiCRC16 (uint16_t crc, const void *data, uint32_t size) | 
| Calculates a CRC-16 checksum using the following configuration:   | |
| static void | swiDecodeDelta16 (const void *source, void *destination) | 
| Decodes a stream of bytes based on the difference of the bytes.   | |
| static void | swiDecodeDelta8 (const void *source, void *destination) | 
| Decodes a stream of bytes based on the difference of the bytes.   | |
| static int | swiDecompressHuffman (const void *source, void *destination, uint32_t toGetSize, TDecompressionStream *stream) | 
| Decompresses Huffman compressed data.   | |
| int | swiDecompressLZSSVram (const void *source, void *destination, uint32_t toGetSize, TDecompressionStream *stream) | 
| Decompresses LZSS compressed data vram safe.   | |
| static void | swiDecompressLZSSWram (const void *source, void *destination) | 
| Decompresses LZSS compressed data.   | |
| static int | swiDecompressRLEVram (const void *source, void *destination, uint32_t toGetSize, TDecompressionStream *stream) | 
| Decompresses RLE compressed data vram safe.   | |
| static void | swiDecompressRLEWram (const void *source, void *destination) | 
| Decompresses RLE compressed data.   | |
| static void | swiDelay (uint32_t duration) | 
| Delays the code.   | |
| static int | swiDivide (int numerator, int divisor) | 
| Divides 2 numbers.   | |
| static void | swiDivMod (int numerator, int divisor, int *result, int *remainder) | 
| Divides 2 numbers and stores both the result and the remainder.   | |
| static void | swiFastCopy (const void *source, void *dest, int flags) | 
| Copies or fills some memory.   | |
| static uint16_t | swiGetPitchTable (int index) | 
| Returns an entry in the pitch table.   | |
| static uint16_t | swiGetSineTable (int index) | 
| Returns an entry in the sine table.   | |
| static uint8_t | swiGetVolumeTable (int index) | 
| Returns an entry in the volume table.   | |
| static void | swiHalt (void) | 
| Halts the CPU until an interupt occures.   | |
| static int | swiIsDebugger (void) | 
| Returns 1 if running on a Nintendo hardware debugger.   | |
| static int | swiRemainder (int numerator, int divisor) | 
| Calculate the remainder of an division.   | |
| void | swiSetHaltCR (uint32_t data) | 
| Writes a word of the data to 0x04000300:32.   | |
| void | swiSetHaltCR (uint8_t data) | 
| Writes a byte of the data to 0x04000301:8.   | |
| static void | swiSleep (void) | 
| Halts the CPU and most of the hardware untill an interupt occures.   | |
| void | swiSoftReset (void) | 
| Resets the CPU that called this function.   | |
| static int | swiSqrt (int value) | 
| Calculates the square root.   | |
| void | swiSwitchToGBAMode (void) | 
| Switches the DS to GBA mode.   | |
| static void | swiUnpackBits (const void *source, void *destination, TUnpackStruct *params) | 
| Unpack data stored in multiple elements in a byte to a larger space.   | |
| static void | swiWaitForIRQ (void) | 
| Wait for any interrupt.   | |
Nintendo DS BIOS functions.
See gbatek for more information.
Should return a raw byte of the stream.
| source | A pointer to the byte. | 
Should return a raw halfword of the stream.
| source | A pointer to the halfword. | 
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.
getResultCallback 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. | 
Should return a raw word of the stream.
| source | A pointer to the word. | 
      
  | 
  inlinestatic | 
Increments or decrements the sound bias once per delay.
| enabled | Set to 0 to decrement it until it reaches 0x000, set to 1 to increment it until it reaches 0x200. | 
| delay | Is in the same units of time as swiDelay. | 
      
  | 
  inlinestatic | 
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). | 
      
  | 
  inlinestatic | 
Calculates a CRC-16 checksum using the following configuration:
| crc | Initial CRC-16 value. | 
| data | Pointer to data (processed nibble by nibble) | 
| size | Size in bytes. | 
      
  | 
  inlinestatic | 
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. | 
      
  | 
  inlinestatic | 
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. | 
      
  | 
  inlinestatic | 
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 | ( | const void * | source, | 
| void * | destination, | ||
| uint32_t | 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. | 
      
  | 
  inlinestatic | 
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. | 
      
  | 
  inlinestatic | 
Decompresses RLE compressed data vram safe.
Compressed data format:
| 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. | 
      
  | 
  inlinestatic | 
Decompresses RLE compressed data.
Compressed data format:
| 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. | 
      
  | 
  inlinestatic | 
Delays the code.
Delays for for a period "X + Y * duration" where X is the swi overhead and Y is a cycle of Thumb fetches in BIOS memory. 
     loop:
       sub r0, #1
       bgt loop
| duration | Length of delay. | 
      
  | 
  inlinestatic | 
Divides 2 numbers.
| numerator | Signed integer to divide. | 
| divisor | Signed integer to divide by. | 
      
  | 
  inlinestatic | 
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. | 
      
  | 
  inlinestatic | 
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). | 
      
  | 
  inlinestatic | 
Returns an entry in the pitch table.
| index | The index of the pitch table (0 - 767). | 
      
  | 
  inlinestatic | 
Returns an entry in the sine table.
| index | The index of the sine table (0 - 63). | 
      
  | 
  inlinestatic | 
Returns an entry in the volume table.
| index | The index of the volume table (0 - 723). | 
      
  | 
  inlinestatic | 
Halts the CPU until an interupt occures.
      
  | 
  inlinestatic | 
Returns 1 if running on a Nintendo hardware debugger.
      
  | 
  inlinestatic | 
Calculate the remainder of an division.
| numerator | Signed integer to divide | 
| divisor | Signed integer to divide by | 
| void swiSetHaltCR | ( | uint32_t | data | ) | 
Writes a word of the data to 0x04000300:32.
| data | The word to write. | 
| void swiSetHaltCR | ( | uint8_t | data | ) | 
Writes a byte of the data to 0x04000301:8.
| data | The byte to write. | 
      
  | 
  inlinestatic | 
Halts the CPU and most of the hardware untill an interupt occures.
| void swiSoftReset | ( | void | ) | 
Resets the CPU that called this function.
      
  | 
  inlinestatic | 
Calculates the square root.
| value | The value to calculate. | 
| void swiSwitchToGBAMode | ( | void | ) | 
Switches the DS to GBA mode.
      
  | 
  inlinestatic | 
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. | 
      
  | 
  inlinestatic | 
Wait for any interrupt.