AnimaEngine  1.0.0
Nintendo DS Pokemon Black, White, Black 2, and White 2 sprite extraction and preview toolchain
Data Structures | Typedefs | Functions
ncer.h File Reference

Nintendo Cell Resource (.NCER) parser representing individual 2D sprite composite elements. More...

#include "common.h"
#include "ncgr.h"
#include "nclr.h"
#include "ppm.h"

Go to the source code of this file.

Data Structures

struct  NcerOam
 Represents a single Object Attribute Memory (OAM) hardware sub-sprite element. More...
 
struct  NcerCell
 A composite cell sprite made of multiple sub-sprite hardware OAM entries. More...
 
struct  NcerFile
 Unpacked representation of a complete .NCER resource. More...
 

Typedefs

typedef struct NcerOam NcerOam
 Represents a single Object Attribute Memory (OAM) hardware sub-sprite element. More...
 
typedef struct NcerCell NcerCell
 A composite cell sprite made of multiple sub-sprite hardware OAM entries. More...
 
typedef struct NcerFile NcerFile
 Unpacked representation of a complete .NCER resource. More...
 

Functions

int Ncer_Parse (const u8 *data, size_t size, NcerFile *out_ncer)
 Parses an unpacked .NCER cell layout block from raw bytes. More...
 
void Ncer_Free (NcerFile *ncer)
 Deallocates all resources held inside an NcerFile structure. More...
 
void Ncer_PrintInfo (const NcerFile *ncer)
 Prints parsed .NCER layout metadata to stdout. More...
 
void Ncer_GetOamDrawOrigin (const NcerOam *oam, int *out_x, int *out_y)
 Calculates resolved horizontal and vertical origins for drawing an OAM. More...
 
int Ncer_RenderCellToImage (const NcerFile *ncer, int cell_index, const NcgrImage *ncgr, const NclrPalette *palette, RgbaColor **out_pixels, int *out_width, int *out_height)
 Renders a composite cell into a raw RGBA pixels buffer. More...
 
int Ncer_RenderCellToImageWithTileStride (const NcerFile *ncer, int cell_index, const NcgrImage *ncgr, const NclrPalette *palette, int tile_stride, RgbaColor **out_pixels, int *out_width, int *out_height)
 Renders a composite cell using specific tile character width stride formatting constraints. More...
 
void Ncer_CellBounds (const NcerCell *cell, int *out_min_x, int *out_min_y, int *out_max_x, int *out_max_y)
 Computes bounding box limits for a cell. More...
 

Detailed Description

Nintendo Cell Resource (.NCER) parser representing individual 2D sprite composite elements.

Typedef Documentation

◆ NcerCell

typedef struct NcerCell NcerCell

A composite cell sprite made of multiple sub-sprite hardware OAM entries.

◆ NcerFile

typedef struct NcerFile NcerFile

Unpacked representation of a complete .NCER resource.

◆ NcerOam

typedef struct NcerOam NcerOam

Represents a single Object Attribute Memory (OAM) hardware sub-sprite element.

Function Documentation

◆ Ncer_CellBounds()

void Ncer_CellBounds ( const NcerCell cell,
int *  out_min_x,
int *  out_min_y,
int *  out_max_x,
int *  out_max_y 
)

Computes bounding box limits for a cell.

Parameters
cellCell structure.
out_min_xMinimum horizontal coordinate.
out_min_yMinimum vertical coordinate.
out_max_xMaximum horizontal coordinate.
out_max_yMaximum vertical coordinate.

◆ Ncer_Free()

void Ncer_Free ( NcerFile ncer)

Deallocates all resources held inside an NcerFile structure.

Parameters
ncerPointer to structure.

◆ Ncer_GetOamDrawOrigin()

void Ncer_GetOamDrawOrigin ( const NcerOam oam,
int *  out_x,
int *  out_y 
)

Calculates resolved horizontal and vertical origins for drawing an OAM.

Parameters
oamSub-sprite structure.
out_xOutput coordinate (horizontal).
out_yOutput coordinate (vertical).

◆ Ncer_Parse()

int Ncer_Parse ( const u8 data,
size_t  size,
NcerFile out_ncer 
)

Parses an unpacked .NCER cell layout block from raw bytes.

Parameters
dataPointer to raw binary file data buffer.
sizeBuffer size in bytes.
out_ncerDestination structure.
Returns
0 on success; negative value on formatting or invalid signature errors.

◆ Ncer_PrintInfo()

void Ncer_PrintInfo ( const NcerFile ncer)

Prints parsed .NCER layout metadata to stdout.

Parameters
ncerPointer to parsed NCER file.

◆ Ncer_RenderCellToImage()

int Ncer_RenderCellToImage ( const NcerFile ncer,
int  cell_index,
const NcgrImage ncgr,
const NclrPalette palette,
RgbaColor **  out_pixels,
int *  out_width,
int *  out_height 
)

Renders a composite cell into a raw RGBA pixels buffer.

Parameters
ncerNCER resource.
cell_indexIndex of the cell to draw.
ncgrNCGR tile graphic resource.
paletteNCLR palette resource.
out_pixelsOutput pointer to destination buffer, allocated inside this function.
out_widthWidth of rendered cell.
out_heightHeight of rendered cell.
Returns
0 on success; negative value on failure.

◆ Ncer_RenderCellToImageWithTileStride()

int Ncer_RenderCellToImageWithTileStride ( const NcerFile ncer,
int  cell_index,
const NcgrImage ncgr,
const NclrPalette palette,
int  tile_stride,
RgbaColor **  out_pixels,
int *  out_width,
int *  out_height 
)

Renders a composite cell using specific tile character width stride formatting constraints.

Parameters
ncerNCER resource.
cell_indexIndex of the cell to draw.
ncgrNCGR tile graphic resource.
paletteNCLR palette resource.
tile_strideWidth stride (in tiles) of NCGR image data.
out_pixelsOutput pointer to destination buffer.
out_widthWidth of rendered cell.
out_heightHeight of rendered cell.
Returns
0 on success; negative value on failure.