49#ifndef OPENSNES_ANIM_H
50#define OPENSNES_ANIM_H
60#define ANIM_F_FINISHED 0x01
63#define ANIM_NONE 0xFFFF
102#define ANIM_PLAYER_INIT {0, 0, 0, 0, 0}
136#define animFrame(_p) ((_p)->clip ? (_p)->clip->frames[(_p)->frame] : ANIM_NONE)
139#define animDone(_p) ((_p)->flags & ANIM_F_FINISHED)
142#define animStop(_p) do { (_p)->clip = 0; (_p)->flags = 0; } while (0)
155#define animTickOam(_p, _id) do { \
156 u16 _af = animTick(_p); \
157 if (_af != ANIM_NONE && oambuffer[_id].oamframeid != _af) { \
158 oambuffer[_id].oamframeid = _af; \
159 oambuffer[_id].oamrefresh = 1; \
176#define animTickMeta(_p, _tbl) ((_tbl)[animTick(_p)])
189#define DECLARE_ANIM_CLIP(name, mode_, speed_, ...) \
190 static const u16 name##_frames[] = { __VA_ARGS__ }; \
191 static const AnimClip name = { \
194 (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:77
u8 mode
Definition anim.h:82
const u8 * durations
Definition anim.h:79
u8 len
Definition anim.h:80
u8 reserved
Definition anim.h:83
u8 speed
Definition anim.h:81
const u16 * frames
Definition anim.h:78
A playback head — RAM, 8 bytes, array-friendly.
Definition anim.h:93
u8 flags
Definition anim.h:97
u8 ticks
Definition anim.h:96
u8 frame
Definition anim.h:95
u8 reserved
Definition anim.h:98
const AnimClip * clip
Definition anim.h:94