OpenSNES
Modern Open-Source SNES Development SDK
Loading...
Searching...
No Matches
main.c File Reference

End-to-end Aseprite sprite pipeline: art + timeline → animated metasprite. More...

#include <snes.h>
#include <snes/anim.h>
#include "res/hero_meta.inc"
#include "res/hero_anim.h"
#include "res/hero.inc"

Macros

#define HERO_X   112
 On-screen X of the metasprite origin (32-wide sprite, centred).
#define HERO_Y   88
 On-screen Y of the metasprite origin (48-tall sprite, centred).
#define VRAM_FONT   0x4000
 BG1 font tiles (4bpp, high VRAM so they clear the OBJ region).
#define VRAM_HERO   0x0000
 4bpp hero tiles (res/hero.pic, incbin'd in data.asm)
#define VRAM_TEXT   0x6800
 BG1 text tilemap.

Functions

static void drawLabel (u16 idx)
 Print the label for the currently playing generated clip.
int main (void)
 Entry point: animate the generated metasprite, toggle clips on A.

Variables

static AnimPlayer hero_player = ANIM_PLAYER_INIT
 Animation player driving the hero metasprite.
static const MetaspriteStyle hero_style = { .baseTile = 0, .size = OBJ_SMALL }
 Metasprite pointer table generated by gfx4snes -P.

Detailed Description

End-to-end Aseprite sprite pipeline: art + timeline → animated metasprite.

This example animates a 32×48 hero metasprite whose every byte of data is machine-generated from a single Aseprite project — no hand-authored frame tables, no hand-typed animation clips. It is the working reference for the two-tool sprite pipeline:

hero.aseprite ─┬─ gfx4snes -P → hero.pic/.pal + res/hero_meta.inc │ (tiles, palette, metasprite pointer table) └─ aseprite2snes → res/hero_anim.h (one AnimClip per Aseprite tag)

gfx4snes owns the pixels and the metasprite geometry; aseprite2snes owns the timeline (tags, per-frame durations, direction) that indexes it. They meet at the frame value: a clip's frame i selects hero_metasprites[i], resolved inline by animTickMeta().

The artist authored two tags in Aseprite — walk (forward loop) and wave (ping-pong) — with per-frame millisecond durations. aseprite2snes converted those to ticks and folded the ping-pong into the frame order; press A to toggle between the two generated clips.

SNES Concepts
  • Metasprite composition from multiple OAM entries (oamDrawMetasprite)
  • The anim.h player driving a metasprite via animTickMeta()
  • OBJSEL size mode + OBJ VRAM base for 16×16 hardware sprites
  • Sprite palette at CGRAM 128 (OBJ_CGRAM_BASE)
What to Observe
  • A hero walks in place (4-frame cycle, per-frame timing from Aseprite)
  • Press A to toggle to the ping-pong "wave" clip and back
  • The text label shows which generated clip is playing
Modules Used
console, sprite, dma, text, text4bpp, background, input, anim
See also
sprite.h, anim.h, dma.h, input.h, tools/aseprite2snes

Macro Definition Documentation

◆ HERO_X

#define HERO_X   112

On-screen X of the metasprite origin (32-wide sprite, centred).

◆ HERO_Y

#define HERO_Y   88

On-screen Y of the metasprite origin (48-tall sprite, centred).

◆ VRAM_FONT

#define VRAM_FONT   0x4000

BG1 font tiles (4bpp, high VRAM so they clear the OBJ region).

◆ VRAM_HERO

#define VRAM_HERO   0x0000

4bpp hero tiles (res/hero.pic, incbin'd in data.asm)

Hero sprite palette, 16 colours (res/hero.pal)

OBJ VRAM word address for the hero tiles (OBJSEL name base = 0)

◆ VRAM_TEXT

#define VRAM_TEXT   0x6800

BG1 text tilemap.

Function Documentation

◆ drawLabel()

void drawLabel ( u16 idx)
static

Print the label for the currently playing generated clip.

Parameters
idxOne of HERO_ANIM_WALK / HERO_ANIM_WAVE.

◆ main()

int main ( void )

Entry point: animate the generated metasprite, toggle clips on A.

Returns
Never returns (infinite loop).

Variable Documentation

◆ hero_player

AnimPlayer hero_player = ANIM_PLAYER_INIT
static

Animation player driving the hero metasprite.

◆ hero_style

const MetaspriteStyle hero_style = { .baseTile = 0, .size = OBJ_SMALL }
static

Metasprite pointer table generated by gfx4snes -P.

Defines hero_metasprite0..3 (each a MetaspriteItem[] terminated by METASPR_TERM) plus hero_metasprites[4], the pointer table the animation clips index. One entry per cell of the hero.png sheet, in sheet order.

Animation clips generated by aseprite2snes from res/hero.json.

Defines hero_walk / hero_wave (AnimClip), the hero_anims[] pointer table and the HERO_ANIM_* index enum. Frame values index hero_metasprites[] above.

The hero's sheet starts at tile 0 and its pieces are the small OBJ size; the frame comes from the animation at each call.