AnimaEngine  1.0.0
Nintendo DS Pokemon Black, White, Black 2, and White 2 sprite extraction and preview toolchain
Functions
nitro_util.h File Reference

Common section parsing and binary parsing helpers matching Nintendo Nitro specifications. More...

#include "common.h"

Go to the source code of this file.

Functions

int Nitro_HasMagic (const u8 *data, size_t size, const char *magic)
 Verifies if the buffer starts with the target 4-character magic signature. More...
 
int Nitro_FindSection (const u8 *data, size_t size, const char *magic, size_t *out_offset, u32 *out_size)
 Searches for a section starting with a specific 4-character magic string. More...
 
void Nitro_GetPrintableMagic (const u8 *data, size_t size, char out[5])
 Safely reads the first 4 bytes of a buffer and formats them as a null-terminated string. More...
 
int Nitro_AbsInt (int value)
 Math helper returning absolute value of an integer. More...
 
s32 Nitro_ReadS32LE (const u8 *p)
 Safely reads a little-endian signed 32-bit value. More...
 
s16 Nitro_ReadS16LE (const u8 *p)
 Safely reads a little-endian signed 16-bit value. More...
 

Detailed Description

Common section parsing and binary parsing helpers matching Nintendo Nitro specifications.

Function Documentation

◆ Nitro_AbsInt()

int Nitro_AbsInt ( int  value)

Math helper returning absolute value of an integer.

Parameters
valueInteger value.
Returns
Absolute integer value.

◆ Nitro_FindSection()

int Nitro_FindSection ( const u8 data,
size_t  size,
const char *  magic,
size_t *  out_offset,
u32 out_size 
)

Searches for a section starting with a specific 4-character magic string.

Parameters
dataRaw file data buffer.
sizeBuffer size in bytes.
magicSection magic identifier to search for (e.g. "PLTT", "CHAR").
out_offsetDestination pointer to store the section start offset.
out_sizeDestination pointer to store the section size in bytes.
Returns
0 on success; negative value if the section is not found.

◆ Nitro_GetPrintableMagic()

void Nitro_GetPrintableMagic ( const u8 data,
size_t  size,
char  out[5] 
)

Safely reads the first 4 bytes of a buffer and formats them as a null-terminated string.

Parameters
dataData buffer.
sizeData size.
outDestination char array buffer (must be at least 5 bytes).

◆ Nitro_HasMagic()

int Nitro_HasMagic ( const u8 data,
size_t  size,
const char *  magic 
)

Verifies if the buffer starts with the target 4-character magic signature.

Parameters
dataData buffer pointer.
sizeBuffer size in bytes.
magic4-character format magic string (e.g. "NCLR").
Returns
1 if magic matches; 0 otherwise.

◆ Nitro_ReadS16LE()

s16 Nitro_ReadS16LE ( const u8 p)

Safely reads a little-endian signed 16-bit value.

Parameters
pPointer to byte stream.
Returns
Signed 16-bit integer.

◆ Nitro_ReadS32LE()

s32 Nitro_ReadS32LE ( const u8 p)

Safely reads a little-endian signed 32-bit value.

Parameters
pPointer to byte stream.
Returns
Signed 32-bit integer.