Skip to content

Commit 45aa9f8

Browse files
committed
Extend Effect interface with a function that is called once per VBlank (backported from 73520a0)
1 parent c12ed56 commit 45aa9f8

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

include/effect.h

+14-6
Original file line numberDiff line numberDiff line change
@@ -46,34 +46,41 @@ typedef enum {
4646
EFFECT_RUNNING = 4,
4747
} EffectStateT;
4848

49+
typedef void (*EffectFuncT)(void);
50+
4951
typedef struct Effect {
5052
const char *name;
5153
EffectStateT state;
5254
/*
5355
* Executed in background task when other effect is running.
5456
* Precalculates data for the effect to be launched.
5557
*/
56-
void (*Load)(void);
58+
EffectFuncT Load;
5759
/*
5860
* Frees all resources allocated by "Load" step.
5961
*/
60-
void (*UnLoad)(void);
62+
EffectFuncT UnLoad;
6163
/*
6264
* Does all initialization steps required to launch the effect:
6365
* 1) Allocate memory for buffers
6466
* 2) Generate copper lists
6567
* (setup for display window, display data fetch, palette, sprites, etc.)
6668
* 3) Set up interrupts and DMA channels (copper, blitter, etc.)
6769
*/
68-
void (*Init)(void);
70+
EffectFuncT Init;
6971
/*
7072
* Frees all resources allocated by "Init" step.
7173
*/
72-
void (*Kill)(void);
74+
EffectFuncT Kill;
7375
/*
7476
* Renders single frame of an effect.
7577
*/
76-
void (*Render)(void);
78+
EffectFuncT Render;
79+
/*
80+
* Called each frame during VBlank interrupt.
81+
* Effect::data will be passed as the argument.
82+
*/
83+
EffectFuncT VBlank;
7784
} EffectT;
7885

7986
void EffectLoad(EffectT *effect);
@@ -82,7 +89,7 @@ void EffectKill(EffectT *effect);
8289
void EffectUnLoad(EffectT *effect);
8390
void EffectRun(EffectT *effect);
8491

85-
#define EFFECT(NAME, L, U, I, K, R) \
92+
#define EFFECT(NAME, L, U, I, K, R, V) \
8693
EffectT NAME##Effect = { \
8794
.name = #NAME, \
8895
.state = 0, \
@@ -91,6 +98,7 @@ void EffectRun(EffectT *effect);
9198
.Init = (I), \
9299
.Kill = (K), \
93100
.Render = (R), \
101+
.VBlank = (V) \
94102
}; \
95103
ALIAS(NAME##Effect, Effect);
96104

0 commit comments

Comments
 (0)