OpenSNES
Modern Open-Source SNES Development SDK
Loading...
Searching...
No Matches
anim.h
Go to the documentation of this file.
1
48
49#ifndef OPENSNES_ANIM_H
50#define OPENSNES_ANIM_H
51
52#include <snes/types.h>
53
55#define ANIM_LOOP 0
57#define ANIM_ONCE 1
58
60#define ANIM_F_FINISHED 0x01
61
63#define ANIM_NONE 0xFFFF
64
77typedef struct {
78 const u16 *frames;
79 const u8 *durations;
84} AnimClip;
85
100
102#define ANIM_PLAYER_INIT {0, 0, 0, 0, 0}
103
117void animPlay(AnimPlayer *p, const AnimClip *clip);
118
123
134
136#define animFrame(_p) ((_p)->clip ? (_p)->clip->frames[(_p)->frame] : ANIM_NONE)
137
139#define animDone(_p) ((_p)->flags & ANIM_F_FINISHED)
140
142#define animStop(_p) do { (_p)->clip = 0; (_p)->flags = 0; } while (0)
143
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; \
160 } \
161} while (0)
162
176#define animTickMeta(_p, _tbl) ((_tbl)[animTick(_p)])
177
189#define DECLARE_ANIM_CLIP(name, mode_, speed_, ...) \
190 static const u16 name##_frames[] = { __VA_ARGS__ }; \
191 static const AnimClip name = { \
192 name##_frames, \
193 0, \
194 (u8)(sizeof(name##_frames) / sizeof(u16)), \
195 (speed_), \
196 (mode_), \
197 0, \
198 }
199
200#endif /* OPENSNES_ANIM_H */
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
OpenSNES Standard Types.