Alchemy
Loading...
Searching...
No Matches

battle_effect_work.h

Go to the documentation of this file.
1#ifndef ALCHEMY_BATTLE_EFFECT_WORK_H
2#define ALCHEMY_BATTLE_EFFECT_WORK_H
3
4/// @file
5/// BattleEffectWork, the running battle effect's work, and its animation
6/// objects.
7
8#include "effect_step.h"
10#include "static_assert.h"
11#include "types.h"
12
13struct AnimationObject;
14
15/// Two adjacent affine background coordinates, queued together for BG2X/BG2Y.
17 s32 x; ///< BG2X, 8 fractional bits
18 s32 y; ///< BG2Y, 8 fractional bits
19 /// Written after staging the coordinates; no reader has been identified.
21};
22
23STATIC_ASSERT(sizeof(struct BattleCanvasOrigin) == 0x0c);
25
26/// The running battle effect's work: its canvas image, 64 particles, the
27/// display registers it stages and its animation objects. It lives in the
28/// HEAP_SLOT_BATTLE_EFFECT work slot.
30 /// Images and scanline tables reuse the storage before the particles.
31 /// The tile-animation mask extends beyond sheet into the table area.
32 union {
33 struct {
34 u8 sheet[0x6980]; ///< the effect's decoded pictures, at fixed offsets
35 s32 bg2xLines[160]; ///< BG2X for each scanline, for an HBlank DMA
36 u8 unk_6c00[0x480]; ///< not named by TBS code
37 };
38 u8 imageStorage[0x7080];
39 /// The tracked elemental scene stages its origin inside the image area.
40 struct {
41 u8 image[0x13c4];
44 };
45 struct EffectStep particles[64]; ///< free while variant is -1
46 /// How the canvas transfer callbacks treat the canvas after each copy
47 /// (enum CanvasTransferMode in effect_internal.h).
49 /// The transfer mode's argument: the fill value, the share kept (50 or 75
50 /// percent) or the darken or brighten amount.
52 s32 unk_7788; ///< not named by TBS code
53 s32 frame; ///< frame counter some effects keep, from 0
54 s32 scrollTimer; ///< frames since the last interval scroll step
55 s32 scrollInterval; ///< frames between interval scroll steps
56 s32 scrollStepX; ///< added to BG1 or BG2 x at each step
57 s32 scrollStepY; ///< added to BG1 or BG2 y at each step
58 s32 savedBg1X; ///< BG1 scroll restored when a shake ends
59 s32 savedBg1Y; ///< BG1 scroll restored when a shake ends
60 s32 shakeFrames; ///< shake frames left; Camera_ApplyShake counts down
61 s32 cameraDelta; ///< camera yaw turned per effect frame
62 /// The effect sets 1 after a frame; Camera_ApplyPhasedDelta then turns the
63 /// whole cameraDelta and sets 0, else turns half and toggles 0 and 2.
65 s32 fadeFrames; ///< backdrop fade frames left (Palette_StepFadeTransfer)
66 s32 fadeStep; ///< CANVAS_FADE_STEPs the backdrop has darkened so far
67 /// Window, display and blend registers, which
68 /// Graphics_ApplyWindowBlendRegisters writes all at once.
69 ///@{
79 ///@}
80 u16 unk_77ce; ///< not named by TBS code
81 /// BG2's reference point, written to BG2X and BG2Y by
82 /// Display_ApplyBg2Reference and BattleFx_AdvanceBg2OnInterval.
83 ///@{
86 ///@}
87 struct AnimationObject *objects[16]; ///< the effect's animation objects
88 /// Each target's flash timer in frames, for effect->actors[n]: set by
89 /// ObjectGroup_UpdateMembers, counted down by ObjectGroup_TickMemberTimers.
91 s32 framesSinceTransfer; ///< 1 on a canvas copy's frame, then counts up
92 /// 1 once the effect has drawn a frame (EFFECT_PRESENT_FRAME); the canvas
93 /// transfer callback copies the canvas and clears it.
95 struct BattleEffectArgument *effect; ///< the command being run
96};
97
98STATIC_ASSERT(offsetof(struct BattleEffectWork, bg2xLines) == 0x6980);
99STATIC_ASSERT(offsetof(struct BattleEffectWork, imageStorage) == 0);
100STATIC_ASSERT(offsetof(struct BattleEffectWork, trackedCanvas.origin) ==
101 0x13c4);
102STATIC_ASSERT(offsetof(struct BattleEffectWork, particles) == 0x7080);
103STATIC_ASSERT(offsetof(struct BattleEffectWork, transferMode) == 0x7780);
104STATIC_ASSERT(offsetof(struct BattleEffectWork, transferValue) == 0x7784);
105STATIC_ASSERT(offsetof(struct BattleEffectWork, frame) == 0x778c);
106STATIC_ASSERT(offsetof(struct BattleEffectWork, scrollTimer) == 0x7790);
107STATIC_ASSERT(offsetof(struct BattleEffectWork, scrollStepX) == 0x7798);
108STATIC_ASSERT(offsetof(struct BattleEffectWork, savedBg1X) == 0x77a0);
109STATIC_ASSERT(offsetof(struct BattleEffectWork, shakeFrames) == 0x77a8);
110STATIC_ASSERT(offsetof(struct BattleEffectWork, cameraDelta) == 0x77ac);
111STATIC_ASSERT(offsetof(struct BattleEffectWork, fadeFrames) == 0x77b4);
112STATIC_ASSERT(offsetof(struct BattleEffectWork, fadeStep) == 0x77b8);
113STATIC_ASSERT(offsetof(struct BattleEffectWork, win0h) == 0x77bc);
114STATIC_ASSERT(offsetof(struct BattleEffectWork, bg2x) == 0x77d0);
115STATIC_ASSERT(offsetof(struct BattleEffectWork, objects) == 0x77d8);
116STATIC_ASSERT(offsetof(struct BattleEffectWork, actorTimers) == 0x7818);
117STATIC_ASSERT(offsetof(struct BattleEffectWork, framesSinceTransfer) == 0x7820);
118STATIC_ASSERT(offsetof(struct BattleEffectWork, transferPending) == 0x7824);
119STATIC_ASSERT(offsetof(struct BattleEffectWork, effect) == 0x7828);
120STATIC_ASSERT(sizeof(struct BattleEffectWork) == 0x782c);
121
122#endif
BattleEffectArgument, the command an effect's caller, dispatcher and handlers share,...
EffectStep and EffectPosition, the positions effects move through.
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
An animated sprite: its image and shadow, scale, rotation, size and up to four animation layers.
Definition animspr.h:108
Two adjacent affine background coordinates, queued together for BG2X/BG2Y.
s32 y
BG2Y, 8 fractional bits.
s32 unk_08
Written after staging the coordinates; no reader has been identified.
s32 x
BG2X, 8 fractional bits.
The command shared by an effect's caller, dispatcher and handlers.
s32 bg2xLines[160]
BG2X for each scanline, for an HBlank DMA.
u8 sheet[0x6980]
the effect's decoded pictures, at fixed offsets
The running battle effect's work: its canvas image, 64 particles, the display registers it stages and...
s32 fadeFrames
backdrop fade frames left (Palette_StepFadeTransfer)
s32 frame
frame counter some effects keep, from 0
s32 savedBg1Y
BG1 scroll restored when a shake ends.
s32 savedBg1X
BG1 scroll restored when a shake ends.
s32 framesSinceTransfer
1 on a canvas copy's frame, then counts up
s32 transferPending
1 once the effect has drawn a frame (EFFECT_PRESENT_FRAME); the canvas transfer callback copies the c...
u16 unk_77ce
not named by TBS code
s32 fadeStep
CANVAS_FADE_STEPs the backdrop has darkened so far.
s32 cameraDelta
camera yaw turned per effect frame
s32 shakeFrames
shake frames left; Camera_ApplyShake counts down
s32 bg2x
BG2's reference point, written to BG2X and BG2Y by Display_ApplyBg2Reference and BattleFx_AdvanceBg2O...
struct AnimationObject * objects[16]
the effect's animation objects
u16 win0h
Window, display and blend registers, which Graphics_ApplyWindowBlendRegisters writes all at once.
s32 transferMode
How the canvas transfer callbacks treat the canvas after each copy (enum CanvasTransferMode in effect...
s32 scrollStepY
added to BG1 or BG2 y at each step
s32 cameraPhase
The effect sets 1 after a frame; Camera_ApplyPhasedDelta then turns the whole cameraDelta and sets 0,...
s32 transferValue
The transfer mode's argument: the fill value, the share kept (50 or 75 percent) or the darken or brig...
s32 scrollTimer
frames since the last interval scroll step
s32 unk_7788
not named by TBS code
u8 actorTimers[8]
Each target's flash timer in frames, for effect->actors[n]: set by ObjectGroup_UpdateMembers,...
struct BattleEffectArgument * effect
the command being run
s32 scrollStepX
added to BG1 or BG2 x at each step
s32 scrollInterval
frames between interval scroll steps
struct EffectStep particles[64]
free while variant is -1
A moving point of an effect: its position, its velocity and a value each effect uses its own way (a s...
Definition effect_step.h:13
The integer types, TRUE, UNUSED and the fixed-address macros.
signed int s32
Definition types.h:14
unsigned short u16
Definition types.h:13
unsigned char u8
Definition types.h:11
struct BattleEffectWork::@373103066325350007065203236361136300263037235225::@176071035131147025350251206375011036352346374172 trackedCanvas