AnimaEngine  1.0.0
Nintendo DS Pokemon Black, White, Black 2, and White 2 sprite extraction and preview toolchain
ncer.h
Go to the documentation of this file.
1 
6 #ifndef NCER_H
7 #define NCER_H
8 
9 #include "common.h"
10 #include "ncgr.h"
11 #include "nclr.h"
12 #include "ppm.h"
13 
17 typedef struct NcerOam {
18  int x;
19  int y;
21  int width;
22  int height;
24  int shape;
25  int size;
27  int tile_index;
28  int palette;
29  int priority;
31  int flip_h;
32  int flip_v;
33  int affine;
35  int obj_mode;
42 
46 typedef struct NcerCell {
47  int oam_count;
48  int cell_attr;
52 
56 typedef struct NcerFile {
57  int cell_count;
60 
68 int Ncer_Parse(
69  const u8 *data,
70  size_t size,
71  NcerFile *out_ncer
72 );
73 
78 void Ncer_Free(NcerFile *ncer);
79 
84 void Ncer_PrintInfo(const NcerFile *ncer);
85 
93  const NcerOam *oam,
94  int *out_x,
95  int *out_y
96 );
97 
110  const NcerFile *ncer,
111  int cell_index,
112  const NcgrImage *ncgr,
113  const NclrPalette *palette,
114  RgbaColor **out_pixels,
115  int *out_width,
116  int *out_height
117 );
118 
132  const NcerFile *ncer,
133  int cell_index,
134  const NcgrImage *ncgr,
135  const NclrPalette *palette,
136  int tile_stride,
137  RgbaColor **out_pixels,
138  int *out_width,
139  int *out_height
140 );
141 
150 void Ncer_CellBounds(
151  const NcerCell *cell,
152  int *out_min_x,
153  int *out_min_y,
154  int *out_max_x,
155  int *out_max_y
156 );
157 
158 #endif
159 
Common types, macros, and standard library includes used throughout AnimaEngine.
unsigned int u32
Definition: common.h:16
unsigned short u16
Definition: common.h:15
unsigned char u8
Definition: common.h:14
struct NcerCell NcerCell
A composite cell sprite made of multiple sub-sprite hardware OAM entries.
void Ncer_PrintInfo(const NcerFile *ncer)
Prints parsed .NCER layout metadata to stdout.
Definition: ncer.c:277
void Ncer_GetOamDrawOrigin(const NcerOam *oam, int *out_x, int *out_y)
Calculates resolved horizontal and vertical origins for drawing an OAM.
Definition: ncer.c:98
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.
Definition: ncer.c:451
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.
Definition: ncer.c:325
void Ncer_Free(NcerFile *ncer)
Deallocates all resources held inside an NcerFile structure.
Definition: ncer.c:257
struct NcerOam NcerOam
Represents a single Object Attribute Memory (OAM) hardware sub-sprite element.
int Ncer_Parse(const u8 *data, size_t size, NcerFile *out_ncer)
Parses an unpacked .NCER cell layout block from raw bytes.
Definition: ncer.c:152
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.
Definition: ncer.c:303
struct NcerFile NcerFile
Unpacked representation of a complete .NCER resource.
Nintendo Character Graphic Resource (.NCGR) 2D tile character graphics structures.
Nintendo Color Resource (.NCLR) palette parser.
Portable Pixmap (PPM) format writer utilities and color structures.
A composite cell sprite made of multiple sub-sprite hardware OAM entries.
Definition: ncer.h:46
u32 raw_oam_offset
Definition: ncer.h:49
NcerOam * oams
Definition: ncer.h:50
int cell_attr
Definition: ncer.h:48
int oam_count
Definition: ncer.h:47
Unpacked representation of a complete .NCER resource.
Definition: ncer.h:56
int cell_count
Definition: ncer.h:57
NcerCell * cells
Definition: ncer.h:58
Represents a single Object Attribute Memory (OAM) hardware sub-sprite element.
Definition: ncer.h:17
int height
Definition: ncer.h:22
int double_size
Definition: ncer.h:34
int width
Definition: ncer.h:21
int tile_index
Definition: ncer.h:27
int x
Definition: ncer.h:18
int y
Definition: ncer.h:19
int affine
Definition: ncer.h:33
int flip_h
Definition: ncer.h:31
int priority
Definition: ncer.h:29
int obj_mode
Definition: ncer.h:35
int flip_v
Definition: ncer.h:32
int size
Definition: ncer.h:25
u16 attr2
Definition: ncer.h:40
int affine_index
Definition: ncer.h:36
u16 attr0
Definition: ncer.h:38
int palette
Definition: ncer.h:28
u16 attr1
Definition: ncer.h:39
int shape
Definition: ncer.h:24
Container representing parsed NCGR image tile graphics.
Definition: ncgr.h:15
Container representing parsed NCLR color palette data.
Definition: nclr.h:17
32-bit RGBA color representation struct.
Definition: ppm.h:14