AnimaEngine  1.0.0
Nintendo DS Pokemon Black, White, Black 2, and White 2 sprite extraction and preview toolchain
Functions
nmcr.c File Reference
#include "nmcr.h"
#include "file_util.h"
#include "nitro_util.h"

Functions

int Nmcr_Parse (const u8 *data, size_t size, NmcrFile *out_nmcr)
 Parses an unpacked .NMCR layout mapping resource block from raw bytes. More...
 
void Nmcr_Free (NmcrFile *nmcr)
 Deallocates all resources held inside an NmcrFile structure. More...
 
static int Gcd (int a, int b)
 
static int Lcm (int a, int b)
 
int Nmcr_MaxFrameCount (const NmcrMap *map, const NanrFile *nanr)
 Computes maximum frames required to play a composite layout. More...
 
int Nmcr_CountValidRecords (const NmcrMap *map, const NanrFile *nanr, const NcerFile *ncer, int frame_index)
 Counts valid active cell records inside layout mapping for specified frame index. More...
 
int Nmcr_ComputeBreakScore (const NmcrMap *idle_map, const NmcrMap *candidate_map, const NanrFile *nanr, const NcerFile *ncer)
 Measures similarity index difference scores to identify rare break animation map candidate. More...
 
void Nmcr_PrintInfo (const NmcrFile *nmcr)
 Debug prints NMCR layout stats to stdout. More...
 

Function Documentation

◆ Gcd()

static int Gcd ( int  a,
int  b 
)
static

◆ Lcm()

static int Lcm ( int  a,
int  b 
)
static

◆ Nmcr_ComputeBreakScore()

int Nmcr_ComputeBreakScore ( const NmcrMap idle_map,
const NmcrMap candidate_map,
const NanrFile nanr,
const NcerFile ncer 
)

Measures similarity index difference scores to identify rare break animation map candidate.

Parameters
idle_mapBase idle layout map.
candidate_mapAlternative layout candidate.
nanrPointer to parsed .NANR timeline.
ncerPointer to parsed .NCER cells.
Returns
Score difference value (lower score implies higher layout similarity).

◆ Nmcr_CountValidRecords()

int Nmcr_CountValidRecords ( const NmcrMap map,
const NanrFile nanr,
const NcerFile ncer,
int  frame_index 
)

Counts valid active cell records inside layout mapping for specified frame index.

Parameters
mapPointer to cell layout map.
nanrPointer to parsed .NANR timeline.
ncerPointer to parsed .NCER cells.
frame_indexFrame index request.
Returns
Number of active drawing sub-cells.

◆ Nmcr_Free()

void Nmcr_Free ( NmcrFile nmcr)

Deallocates all resources held inside an NmcrFile structure.

Parameters
nmcrPointer to structure.

◆ Nmcr_MaxFrameCount()

int Nmcr_MaxFrameCount ( const NmcrMap map,
const NanrFile nanr 
)

Computes maximum frames required to play a composite layout.

Parameters
mapPointer to cell layout map.
nanrPointer to parsed .NANR timeline sequences.
Returns
Total frame duration count.

◆ Nmcr_Parse()

int Nmcr_Parse ( const u8 data,
size_t  size,
NmcrFile out_nmcr 
)

Parses an unpacked .NMCR layout mapping resource block from raw bytes.

Parameters
dataRaw binary input buffer.
sizeInput stream size in bytes.
out_nmcrDestination NmcrFile structure.
Returns
0 on success; negative value on formatting or invalid signature errors.

◆ Nmcr_PrintInfo()

void Nmcr_PrintInfo ( const NmcrFile nmcr)

Debug prints NMCR layout stats to stdout.

Parameters
nmcrPointer to parsed NMCR.