|
AnimaEngine
1.0.0
Nintendo DS Pokemon Black, White, Black 2, and White 2 sprite extraction and preview toolchain
|
#include "anima_backend.h"#include "common.h"#include "file_util.h"#include "nds_header.h"#include "nds_fnt.h"#include "nds_fat.h"#include "narc.h"#include "lz.h"#include "nitro_guess.h"#include "nitro_util.h"#include "nclr.h"#include "ncgr.h"#include "ncer.h"#include "nanr.h"#include "nmcr.h"#include "nmar.h"#include "ppm.h"#include "png_writer.h"#include "png_pipeline.h"#include "gif_writer.h"#include "gif_pipeline.h"#include "json_export.h"#include "sprite_composer.h"#include "coords.h"Data Structures | |
| struct | PokemonMemberSpec |
| struct | PreviewResourceSet |
Macros | |
| #define | PATH_BUFFER_SIZE ANIMA_PATH_BUFFER_SIZE |
| #define | BW_TILE_STRIDE ANIMA_BW_TILE_STRIDE |
| #define | COMPOSITE_MARGIN ANIMA_COMPOSITE_MARGIN |
| #define | ANIMA_DIR_RAW_MEMBERS "raw_narc_members" |
| #define | ANIMA_DIR_NDS_FILES "nds_files" |
| #define | ANIMA_DIR_JSON "reconstruction_json" |
| #define | ANIMA_DIR_SPRITESHEETS "spritesheet_png" |
| #define | ANIMA_DIR_STATIC "static_png" |
| #define | ANIMA_DIR_IDLE_GIF "animated_idle_gif" |
| #define | ANIMA_DIR_BREAK_GIF "idle_break_gif" |
| #define | ANIMA_DIR_COMPOSED_GIF "composed_gif" |
Typedefs | |
| typedef enum PokemonMemberRole | PokemonMemberRole |
| typedef struct PokemonMemberSpec | PokemonMemberSpec |
| typedef struct PreviewResourceSet | PreviewResourceSet |
Functions | |
| static int | ResolveBreakMapValidated (const NmarFile *nmar, int idle_map, const NmcrFile *nmcr, const NanrFile *nanr, const NcerFile *ncer) |
| static int | FindIdleNmarAnimationIndex (const NmarFile *nmar) |
| static int | FindBreakNmarAnimationIndex (const NmarFile *nmar, int idle_map, int break_map, const NmcrFile *nmcr, const NanrFile *nanr, const NcerFile *ncer) |
| static int | RenderComposedAnimationSmart (const NcerFile *ncer, const NanrFile *nanr, const NmcrFile *nmcr, const NmarFile *nmar, int idle_map, int break_map, int preferred_break_animation_index, const NcgrImage *ncgr, const NclrPalette *palette, int idle_repetitions, int tile_stride, int margin, u8 **out_frames, int *out_frame_count, int *out_width, int *out_height, const CoordFile *coords, int delay_cs) |
| static void | PrintFirstFourBytes (const u8 *data, size_t size) |
| static int | ExtractDecodedMember (const NarcArchive *narc, int member_id, const PokemonMemberSpec *spec, u8 **out_data, size_t *out_size) |
| static int | AnimaBackend_GetFormBlockIndex (int species, int form_index) |
| static PokemonMemberRole | ResolveMemberRole (PokemonMemberRole role, const AnimaPreviewOptions *opts) |
| static int | ExtractDecodedPokemonRoleExt (const NarcArchive *narc, int species, PokemonMemberRole role, const AnimaPreviewOptions *opts, u8 **out_data, size_t *out_size) |
| static int | ExtractDecodedPokemonRole (const NarcArchive *narc, int species, PokemonMemberRole role, u8 **out_data, size_t *out_size) |
| static int | InitPokegraFromRom (const char *rom_path, u8 **out_rom, size_t *out_rom_size, NarcArchive *out_pokegra) |
| static int | WritePokemonBlockMembers (const NarcArchive *narc, int species, int block_index, const char *out_dir) |
| static void | GeneratePokemonTilePreviews (int species, const char *out_dir) |
| static void | GeneratePokemonCellPreviews (int species, const char *out_dir) |
| static int | GenerateAssembledStaticAndLeaves (const char *out_dir, const GifExportOptions *gif_options, int export_idle_break_gifs, int export_composed_gifs) |
| void | AnimaExtractOptions_Init (AnimaExtractOptions *options) |
| Initialises default options for extraction. More... | |
| int | AnimaBackend_BuildFrontNormalGifPath (const char *out_dir, char *buffer, size_t buffer_size) |
| Helper to generate output path for front normal battle idle GIF. More... | |
| int | AnimaBackend_BuildFrontNormalIdleBreakGifPath (const char *out_dir, char *buffer, size_t buffer_size) |
| Helper to generate output path for front normal idle break battle GIF. More... | |
| int | AnimaBackend_BuildFrontNormalStaticPath (const char *out_dir, char *buffer, size_t buffer_size) |
| Helper to generate output path for static normal front static preview PNG. More... | |
| static void | RemoveChildDirectory (const char *out_dir, const char *child) |
| static int | OptionsRequestOnlyDsFiles (const AnimaExtractOptions *options) |
| static int | ResolveIdleMapIndex (const NmcrFile *nmcr, const NanrFile *nanr, const NcerFile *ncer, const NmarFile *nmar) |
| static void | PreviewResources_Free (PreviewResourceSet *res) |
| static int | PreviewResources_Load (const char *rom_path, int species, const AnimaPreviewOptions *opts, PreviewResourceSet *res) |
| static void | ComposerTransformFromNmarFrame (const NmarFrame *frame, ComposerTransform *out_transform) |
| static int | NmcrMapIsUsable (const NmcrFile *nmcr, const NanrFile *nanr, const NcerFile *ncer, int map_index) |
| static int | NmarAnimationFirstMap (const NmarFile *nmar, int animation_index) |
| static int | NmarAnimationIsUsable (const NmarFile *nmar, const NmcrFile *nmcr, const NanrFile *nanr, const NcerFile *ncer, int animation_index) |
| static int | NmarAnimationReferencesMap (const NmarFile *nmar, int map_index) |
| static int | NmarAnimationContainsMapOtherThan (const NmarFile *nmar, int animation_index, int map_index) |
| static int | NmarAnimationFrameCountForPreview (const NmarFile *nmar, int animation_index, int delay_cs) |
| static int | IsStrongBreakLabel (const char *label) |
| static int | CopyIndexedFramesToPreview (const u8 *indices, int frame_count, int width, int height, const NclrPalette *palette, int delay_cs, AnimaIdlePreview *out_preview) |
| int | AnimaBackend_LoadIdlePreview (const char *rom_path, int species, AnimaIdlePreview *out_preview) |
| High-level loader to construct a basic idle preview (Base front normal). More... | |
| int | AnimaBackend_LoadSpritesheetPreview (const char *rom_path, int species, AnimaIdlePreview *out_preview) |
| High-level loader to build the spritesheet PNG preview buffer (Base front normal). More... | |
| int | AnimaBackend_LoadIdleBreakPreview (const char *rom_path, int species, AnimaIdlePreview *out_preview) |
| High-level loader to build the idle break variant preview buffer. More... | |
| int | AnimaBackend_LoadComposedPreview (const char *rom_path, int species, int idle_repetitions, AnimaIdlePreview *out_preview) |
| High-level loader to build unified composed idle-to-break animation loop. More... | |
| void | AnimaIdlePreview_Free (AnimaIdlePreview *preview) |
| Deallocates memory within an AnimaIdlePreview container. More... | |
| static int | RenderNmcrMapPreviewFromResources (const PreviewResourceSet *res, int map_index, AnimaIdlePreview *out_preview) |
| static int | RenderNmarAnimationPreviewFromResources (const PreviewResourceSet *res, int animation_index, AnimaIdlePreview *out_preview) |
| static int | WritePreviewGifFromPalette (const char *out_path, const AnimaIdlePreview *preview, const NclrPalette *palette) |
| int | AnimaBackend_LoadNmarAnimationPreviewExt (const char *rom_path, int species, int animation_index, const AnimaPreviewOptions *opts, AnimaIdlePreview *out_preview) |
| Builds custom NMAR-selected animation preview from direct timeline records. More... | |
| int | AnimaBackend_LoadNmcrMapPreviewExt (const char *rom_path, int species, int map_index, const AnimaPreviewOptions *opts, AnimaIdlePreview *out_preview) |
| Builds direct static NMCR-selected composite layout preview frame. More... | |
| static void | FillAssetText (AnimaPreviewAssetInfo *asset, AnimaPreviewAssetType type, int animation_index, int map_index, int frame_count, const char *label, const char *display_name) |
| static int | AddAsset (AnimaPreviewAssetInfo *assets, int max_assets, int *count, AnimaPreviewAssetType type, int animation_index, int map_index, int frame_count, const char *label, const char *display_name) |
| int | AnimaBackend_ListPreviewAssets (const char *rom_path, int species, const AnimaPreviewOptions *opts, AnimaPreviewAssetInfo *out_assets, int max_assets, int *out_count) |
| Scans active Nitro headers in Pokegra member block to discover and populate all available assets. More... | |
| int | AnimaBackend_ExtractPokemon (const char *rom_path, int species, const char *out_dir, const AnimaExtractOptions *options) |
| Performs a full asset extraction pipeline for a specific Pokemon species. More... | |
| int | AnimaBackend_HasFemaleSprite (const char *rom_path, int species) |
| Verifies whether the specified species contains dedicated gender variant graphics. More... | |
| int | AnimaBackend_LoadIdlePreviewExt (const char *rom_path, int species, const AnimaPreviewOptions *opts, AnimaIdlePreview *out_preview) |
| Extended loader for basic idle previews targeting custom shiny, perspective, or form variables. More... | |
| int | AnimaBackend_LoadSpritesheetPreviewExt (const char *rom_path, int species, const AnimaPreviewOptions *opts, AnimaIdlePreview *out_preview) |
| Extended spritesheet preview builder with complete variant option mappings. More... | |
| int | AnimaBackend_LoadIdleBreakPreviewExt (const char *rom_path, int species, const AnimaPreviewOptions *opts, AnimaIdlePreview *out_preview) |
| Extended idle break preview builder supporting shiny and perspective parameters. More... | |
| int | AnimaBackend_LoadComposedPreviewExt (const char *rom_path, int species, int idle_repetitions, const AnimaPreviewOptions *opts, AnimaIdlePreview *out_preview) |
| Extended composed idle-to-break preview builder supporting complete variant selections. More... | |
| static int | ResolvePreviewGifDelayCs (const AnimaPreviewOptions *opts) |
| int | AnimaBackend_ExportCurrentAsset (const char *rom_path, int species, int preview_mode, const AnimaPreviewOptions *opts, const char *out_path) |
| Renders and exports the active target preview buffer to a local file. More... | |
Variables | |
| static int | s_game_is_sequel = 0 |
| static const PokemonMemberSpec | g_member_specs [20] |
| #define ANIMA_DIR_BREAK_GIF "idle_break_gif" |
| #define ANIMA_DIR_COMPOSED_GIF "composed_gif" |
| #define ANIMA_DIR_IDLE_GIF "animated_idle_gif" |
| #define ANIMA_DIR_JSON "reconstruction_json" |
| #define ANIMA_DIR_NDS_FILES "nds_files" |
| #define ANIMA_DIR_RAW_MEMBERS "raw_narc_members" |
| #define ANIMA_DIR_SPRITESHEETS "spritesheet_png" |
| #define ANIMA_DIR_STATIC "static_png" |
| #define BW_TILE_STRIDE ANIMA_BW_TILE_STRIDE |
| #define COMPOSITE_MARGIN ANIMA_COMPOSITE_MARGIN |
| #define PATH_BUFFER_SIZE ANIMA_PATH_BUFFER_SIZE |
| typedef enum PokemonMemberRole PokemonMemberRole |
| typedef struct PokemonMemberSpec PokemonMemberSpec |
| typedef struct PreviewResourceSet PreviewResourceSet |
| enum PokemonMemberRole |
|
static |
| int AnimaBackend_BuildFrontNormalGifPath | ( | const char * | out_dir, |
| char * | buffer, | ||
| size_t | buffer_size | ||
| ) |
Helper to generate output path for front normal battle idle GIF.
| out_dir | Root output directory. |
| buffer | Output path container. |
| buffer_size | Size of destination path buffer. |
| int AnimaBackend_BuildFrontNormalIdleBreakGifPath | ( | const char * | out_dir, |
| char * | buffer, | ||
| size_t | buffer_size | ||
| ) |
Helper to generate output path for front normal idle break battle GIF.
| out_dir | Root output directory. |
| buffer | Output path container. |
| buffer_size | Size of destination path buffer. |
| int AnimaBackend_BuildFrontNormalStaticPath | ( | const char * | out_dir, |
| char * | buffer, | ||
| size_t | buffer_size | ||
| ) |
Helper to generate output path for static normal front static preview PNG.
| out_dir | Root output directory. |
| buffer | Output path container. |
| buffer_size | Size of destination path buffer. |
| int AnimaBackend_ExportCurrentAsset | ( | const char * | rom_path, |
| int | species, | ||
| int | preview_mode, | ||
| const AnimaPreviewOptions * | opts, | ||
| const char * | out_path | ||
| ) |
Renders and exports the active target preview buffer to a local file.
| rom_path | Path to the Pokemon Black/White .nds ROM. |
| species | National Dex ID. |
| preview_mode | Selected preview type matching AnimaPreviewAssetType. |
| opts | Rendering configurations. |
| out_path | Path to output destination file (PNG or GIF). |
| int AnimaBackend_ExtractPokemon | ( | const char * | rom_path, |
| int | species, | ||
| const char * | out_dir, | ||
| const AnimaExtractOptions * | options | ||
| ) |
Performs a full asset extraction pipeline for a specific Pokemon species.
| rom_path | Path to the Pokemon Black/White .nds ROM. |
| species | National Dex ID of the Pokemon (1 to 649). |
| out_dir | Root directory where asset files will be exported. |
| options | Extraction parameters selecting formats and blocks. |
|
static |
| int AnimaBackend_HasFemaleSprite | ( | const char * | rom_path, |
| int | species | ||
| ) |
Verifies whether the specified species contains dedicated gender variant graphics.
| rom_path | Path to the Pokemon Black/White .nds ROM. |
| species | National Dex ID of the Pokemon. |
| int AnimaBackend_ListPreviewAssets | ( | const char * | rom_path, |
| int | species, | ||
| const AnimaPreviewOptions * | opts, | ||
| AnimaPreviewAssetInfo * | out_assets, | ||
| int | max_assets, | ||
| int * | out_count | ||
| ) |
Scans active Nitro headers in Pokegra member block to discover and populate all available assets.
| rom_path | Path to the Pokemon Black/White .nds ROM. |
| species | National Dex ID. |
| opts | Discovery configurations (side, gender, form, shiny context). |
| out_assets | Array pointer to populate with discovered asset info. |
| max_assets | Capacity limit of the out_assets array. |
| out_count | Output pointer filled with total count of discovered assets. |
| int AnimaBackend_LoadComposedPreview | ( | const char * | rom_path, |
| int | species, | ||
| int | idle_repetitions, | ||
| AnimaIdlePreview * | out_preview | ||
| ) |
High-level loader to build unified composed idle-to-break animation loop.
| rom_path | Path to the Pokemon Black/White .nds ROM. |
| species | National Dex ID. |
| idle_repetitions | Pre-calculated or target number of idle iterations before break. |
| out_preview | Output container. |
| int AnimaBackend_LoadComposedPreviewExt | ( | const char * | rom_path, |
| int | species, | ||
| int | idle_repetitions, | ||
| const AnimaPreviewOptions * | opts, | ||
| AnimaIdlePreview * | out_preview | ||
| ) |
Extended composed idle-to-break preview builder supporting complete variant selections.
| rom_path | Path to the Pokemon Black/White .nds ROM. |
| species | National Dex ID. |
| idle_repetitions | Target number of idle iterations before break. |
| opts | Rendering configurations. |
| out_preview | Output container. |
| int AnimaBackend_LoadIdleBreakPreview | ( | const char * | rom_path, |
| int | species, | ||
| AnimaIdlePreview * | out_preview | ||
| ) |
High-level loader to build the idle break variant preview buffer.
| rom_path | Path to the Pokemon Black/White .nds ROM. |
| species | National Dex ID. |
| out_preview | Output container. |
| int AnimaBackend_LoadIdleBreakPreviewExt | ( | const char * | rom_path, |
| int | species, | ||
| const AnimaPreviewOptions * | opts, | ||
| AnimaIdlePreview * | out_preview | ||
| ) |
Extended idle break preview builder supporting shiny and perspective parameters.
| rom_path | Path to the Pokemon Black/White .nds ROM. |
| species | National Dex ID. |
| opts | Rendering configurations. |
| out_preview | Output container. |
| int AnimaBackend_LoadIdlePreview | ( | const char * | rom_path, |
| int | species, | ||
| AnimaIdlePreview * | out_preview | ||
| ) |
High-level loader to construct a basic idle preview (Base front normal).
| rom_path | Path to the Pokemon Black/White .nds ROM. |
| species | National Dex ID. |
| out_preview | Output container to hold RGBA buffer. |
| int AnimaBackend_LoadIdlePreviewExt | ( | const char * | rom_path, |
| int | species, | ||
| const AnimaPreviewOptions * | opts, | ||
| AnimaIdlePreview * | out_preview | ||
| ) |
Extended loader for basic idle previews targeting custom shiny, perspective, or form variables.
| rom_path | Path to the Pokemon Black/White .nds ROM. |
| species | National Dex ID. |
| opts | Rendering configurations. |
| out_preview | Output container to hold RGBA buffer. |
| int AnimaBackend_LoadNmarAnimationPreviewExt | ( | const char * | rom_path, |
| int | species, | ||
| int | animation_index, | ||
| const AnimaPreviewOptions * | opts, | ||
| AnimaIdlePreview * | out_preview | ||
| ) |
Builds custom NMAR-selected animation preview from direct timeline records.
| rom_path | Path to the Pokemon Black/White .nds ROM. |
| species | National Dex ID. |
| animation_index | Direct NMAR animation timeline sequence index. |
| opts | Rendering configurations. |
| out_preview | Output container. |
| int AnimaBackend_LoadNmcrMapPreviewExt | ( | const char * | rom_path, |
| int | species, | ||
| int | map_index, | ||
| const AnimaPreviewOptions * | opts, | ||
| AnimaIdlePreview * | out_preview | ||
| ) |
Builds direct static NMCR-selected composite layout preview frame.
| rom_path | Path to the Pokemon Black/White .nds ROM. |
| species | National Dex ID. |
| map_index | Direct NMCR map record index. |
| opts | Rendering configurations. |
| out_preview | Output container. |
| int AnimaBackend_LoadSpritesheetPreview | ( | const char * | rom_path, |
| int | species, | ||
| AnimaIdlePreview * | out_preview | ||
| ) |
High-level loader to build the spritesheet PNG preview buffer (Base front normal).
| rom_path | Path to the Pokemon Black/White .nds ROM. |
| species | National Dex ID. |
| out_preview | Output container. |
| int AnimaBackend_LoadSpritesheetPreviewExt | ( | const char * | rom_path, |
| int | species, | ||
| const AnimaPreviewOptions * | opts, | ||
| AnimaIdlePreview * | out_preview | ||
| ) |
Extended spritesheet preview builder with complete variant option mappings.
| rom_path | Path to the Pokemon Black/White .nds ROM. |
| species | National Dex ID. |
| opts | Rendering configurations. |
| out_preview | Output container. |
| void AnimaExtractOptions_Init | ( | AnimaExtractOptions * | options | ) |
Initialises default options for extraction.
| options | Pointer to options struct to populate. |
| void AnimaIdlePreview_Free | ( | AnimaIdlePreview * | preview | ) |
Deallocates memory within an AnimaIdlePreview container.
| preview | Pointer to preview struct to clean. |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |