Alchemy
Loading...
Searching...
No Matches

effect_slot.h

Go to the documentation of this file.
1#ifndef ALCHEMY_EFFECT_SLOT_H
2#define ALCHEMY_EFFECT_SLOT_H
3
4/// @file
5/// Effect slots: the particles Psynergy effects move and draw.
6
7#include "edition.h"
8#include "types.h"
9#include "static_assert.h"
10
11#define EFFECT_NO_TARGET ((s32)0x80000000)
12
13struct EffectSlot;
14typedef void (*EffectCallback)(struct EffectSlot *);
15
16/// A particle a Psynergy effect moves and draws: its sprite, its position and
17/// target, its speed, scale and heading, and its per-frame callback.
18struct EffectSlot {
19 void *object; ///< the slot's sprite, released with the slot
20 s32 x; ///< 16.16 fixed-point pixels
21 s32 z; ///< 16.16 fixed-point pixels
22 s32 targetX; ///< 16.16 fixed-point pixels; EFFECT_NO_TARGET at rest
23 s32 targetZ; ///< 16.16 fixed-point pixels; EFFECT_NO_TARGET at rest
24 s32 originX; ///< 16.16 fixed-point pixels; where the slot started
25 s32 originZ; ///< 16.16 fixed-point pixels; where the slot started
26 s32 speed; ///< 16.16 fixed-point pixels per frame
27 s32 maxSpeed; ///< 16.16 fixed-point pixels per frame
28 s32 acceleration; ///< 16.16 fixed-point pixels per frame, each frame
29 s32 scaleX; ///< 16.16 fixed point, 0x10000 full size
30 s32 scaleY; ///< 16.16 fixed point, 0x10000 full size
31 u16 heading; ///< 1/65536 turns
32 s16 maxTurnStep; ///< 1/65536 turns a frame
33 EffectCallback callback; ///< run each frame once callbackDelay is 0
34 u16 age; ///< frames
35 s16 callbackDelay; ///< frames
36 s16 orbitRadius; ///< pixels
37 s16 orbitAngle; ///< 1/32 turns
38 s8 state; ///< the callback's own step; 0 when it is given
39 s8 stopAtTarget; ///< nonzero: lands on the target within 8 pixels
40 s8 limitTurnStep; ///< Clamp steering to maxTurnStep; zero faces the target
41 ///< directly.
42 s8 updateMotion; ///< nonzero: EffectSlot_UpdateMotion moves it each frame
43 s8 render; ///< nonzero: drawn each frame
44 s8 active; ///< nonzero while the slot is in use
45 u8 randomValue; ///< random when filled; not read by name in TBS
46 /// bits: 2 z also lifts the sprite (set when the slot is filled)
48};
49
50STATIC_ASSERT(sizeof(struct EffectSlot) == 0x48);
51STATIC_ASSERT(offsetof(struct EffectSlot, orbitRadius) == 0x3c);
52STATIC_ASSERT(offsetof(struct EffectSlot, state) == 0x40);
53
54#endif
The edition's language, for C to compare (LANGUAGE == LANGUAGE_GERMAN).
void(*) EffectCallback(struct EffectSlot *)
Definition effect_slot.h:14
STATIC_ASSERT, a compile-time check that emits nothing.
#define STATIC_ASSERT(condition)
C89 permits repeated extern declarations of the same array.
#define offsetof(type, member)
Definition stddef.h:19
A particle a Psynergy effect moves and draws: its sprite, its position and target,...
Definition effect_slot.h:18
s16 callbackDelay
frames
Definition effect_slot.h:35
s16 orbitRadius
pixels
Definition effect_slot.h:36
s32 speed
16.16 fixed-point pixels per frame
Definition effect_slot.h:26
s32 scaleY
16.16 fixed point, 0x10000 full size
Definition effect_slot.h:30
EffectCallback callback
run each frame once callbackDelay is 0
Definition effect_slot.h:33
s8 state
the callback's own step; 0 when it is given
Definition effect_slot.h:38
u16 heading
1/65536 turns
Definition effect_slot.h:31
void * object
the slot's sprite, released with the slot
Definition effect_slot.h:19
s32 originX
16.16 fixed-point pixels; where the slot started
Definition effect_slot.h:24
s32 z
16.16 fixed-point pixels
Definition effect_slot.h:21
s32 x
16.16 fixed-point pixels
Definition effect_slot.h:20
s16 maxTurnStep
1/65536 turns a frame
Definition effect_slot.h:32
s8 limitTurnStep
Clamp steering to maxTurnStep; zero faces the target directly.
Definition effect_slot.h:40
s32 originZ
16.16 fixed-point pixels; where the slot started
Definition effect_slot.h:25
s32 targetZ
16.16 fixed-point pixels; EFFECT_NO_TARGET at rest
Definition effect_slot.h:23
s32 scaleX
16.16 fixed point, 0x10000 full size
Definition effect_slot.h:29
s32 targetX
16.16 fixed-point pixels; EFFECT_NO_TARGET at rest
Definition effect_slot.h:22
s8 active
nonzero while the slot is in use
Definition effect_slot.h:44
s8 updateMotion
nonzero: EffectSlot_UpdateMotion moves it each frame
Definition effect_slot.h:42
u8 flags
bits: 2 z also lifts the sprite (set when the slot is filled)
Definition effect_slot.h:47
s32 maxSpeed
16.16 fixed-point pixels per frame
Definition effect_slot.h:27
s16 orbitAngle
1/32 turns
Definition effect_slot.h:37
u16 age
frames
Definition effect_slot.h:34
u8 randomValue
random when filled; not read by name in TBS
Definition effect_slot.h:45
s8 stopAtTarget
nonzero: lands on the target within 8 pixels
Definition effect_slot.h:39
s32 acceleration
16.16 fixed-point pixels per frame, each frame
Definition effect_slot.h:28
s8 render
nonzero: drawn each frame
Definition effect_slot.h:43
The integer types, TRUE, UNUSED and the fixed-address macros.
signed int s32
Definition types.h:14
signed char s8
Definition types.h:10
signed short s16
Definition types.h:12
unsigned short u16
Definition types.h:13
unsigned char u8
Definition types.h:11