52#ifndef OPENSNES_ANIM_H
53#define OPENSNES_ANIM_H
63#define ANIM_F_FINISHED 0x01
66#define ANIM_NONE 0xFFFF
105#define ANIM_PLAYER_INIT {0, 0, 0, 0, 0}
144#define animFrame(_p) ((_p)->clip ? (_p)->clip->frames[(_p)->frame] : ANIM_NONE)
147#define animDone(_p) ((_p)->flags & ANIM_F_FINISHED)
150#define animStop(_p) do { (_p)->clip = 0; (_p)->flags = 0; } while (0)
163#define animTickOam(_p, _id) do { \
164 u16 _af = animTick(_p); \
165 if (_af != ANIM_NONE && oambuffer[_id].oamframeid != _af) { \
166 oambuffer[_id].oamframeid = _af; \
167 oambuffer[_id].oamrefresh = 1; \
184#define animTickMeta(_p, _tbl) ((_tbl)[animTick(_p)])
200#define DECLARE_ANIM_CLIP(name, mode_, speed_, ...) \
201 static const u16 name##_frames[] = { __VA_ARGS__ }; \
202 _Static_assert(sizeof(name##_frames) / sizeof(u16) <= 255, \
203 "DECLARE_ANIM_CLIP: a clip holds at most 255 frames"); \
204 static const AnimClip name = { \
207 (u8)(sizeof(name##_frames) / sizeof(u16)), \
u16 animTick(AnimPlayer *p)
Advance one tick; return the current frame value.
void animPlay(AnimPlayer *p, const AnimClip *clip)
Start (or keep) a clip — continue-if-same semantics.
void animRestart(AnimPlayer *p)
Force-restart the current clip from frame 0, even mid-flight.
unsigned short u16
16-bit unsigned integer (0 to 65535)
Definition types.h:53
unsigned char u8
8-bit unsigned integer (0 to 255)
Definition types.h:47
An animation clip — ROM-resident, 12 bytes.
Definition anim.h:80
u8 mode
Definition anim.h:85
const u8 * durations
Definition anim.h:82
u8 len
Definition anim.h:83
u8 reserved
Definition anim.h:86
u8 speed
Definition anim.h:84
const u16 * frames
Definition anim.h:81
A playback head — RAM, 8 bytes, array-friendly.
Definition anim.h:96
u8 flags
Definition anim.h:100
u8 ticks
Definition anim.h:99
u8 frame
Definition anim.h:98
u8 reserved
Definition anim.h:101
const AnimClip * clip
Definition anim.h:97