Alchemy
Loading...
Searching...
No Matches

burst_scene.c

Go to the documentation of this file.
1/// @file
2/// Gust, Flying Attack and the rush bursts.
3/// Part of effect.c, the battle effect object, compiled only through it.
4
6
7/// Gust: the burst scene in mode 6, 7 or 8 as the variant grows, one to
8/// three strikes that each fill the canvas with light.
9///
10/// Abilities: Gust (kind 219); Rapid Smash, Sonic Smash, Slice (kind 310).
12 if (effect->variant == 0) {
13 BattleFx_RunBurstScene(effect, 6);
14 return;
15 }
16 if (effect->variant == 1) {
17 BattleFx_RunBurstScene(effect, 7);
18 return;
19 }
20 BattleFx_RunBurstScene(effect, 8);
21}
22
23/// Bear Claw: five strikes, the burst scene in mode 0.
24///
25/// Abilities: Bear Claw (kind 317); Counterstrike (kind 342).
27 BattleFx_RunBurstScene(effect, 0);
28}
29
30/// Ransack: the same five strikes as Bear Claw (mode 0).
31///
32/// Abilities: Ransack (kind 321); Mad Dash (kind 343).
34 BattleFx_RunBurstScene(effect, 0);
35}
36
37/// Bacteria Rush: seven strikes in the lime palette (mode 1).
38///
39/// Abilities: Bacteria Rush (kind 328).
41 BattleFx_RunBurstScene(effect, 1);
42}
43
44/// Freebite Rush: nine strikes in the blue palette (mode 2).
45///
46/// Abilities: Freebite Rush (kind 334).
48 BattleFx_RunBurstScene(effect, 2);
49}
50
51/// Flying Attack: the burst scene in mode 3, 4 or 5 as the variant grows, one
52/// to three strikes.
53///
54/// Abilities: Flying Attack (kind 319); Swift Strike (kind 329).
56 if (effect->variant == 0) {
57 BattleFx_RunBurstScene(effect, 3);
58 return;
59 }
60 if (effect->variant == 1) {
61 BattleFx_RunBurstScene(effect, 4);
62 return;
63 }
64 BattleFx_RunBurstScene(effect, 5);
65}
66
67/// The bytes of a gBurstScene_Records row, one row a mode.
69 BURST_SCENE_ARC_SHEET, ///< 0: blue arc A, else B; 1 also draws every strike
70 ///< as an arc
71 BURST_SCENE_PALETTE, ///< the palette's resource (0 to 3)
72 BURST_SCENE_STRIKES, ///< the strikes
73 BURST_SCENE_MOTES, ///< motes thrown by each strike
74 BURST_SCENE_INTERVAL, ///< frames between strikes
75 BURST_SCENE_FRAMES, ///< frames in the whole effect
76 BURST_SCENE_FLASH ///< 1 fills the canvas on each hit
77};
78
79/// The flash pictures, packed to half width after the arcs.
80#define BURST_SCENE_FLASH_CELLS 0x5100
81/// The wave pictures, in the map buffer past the motes.
82#define BURST_SCENE_WAVE_CELLS (Ram_MapCellBuffer + 0x5e00)
83
84/// Flurry: the user closes on the first target and strikes it again and
85/// again; each strike shows an arc (or, in rows with arc sheet 0, a wave
86/// for the third and fourth of every four), flashes and throws motes. A
87/// strike lands 2 frames after it starts: an odd one jolts the target, and
88/// the last knocks it back, shakes the screen harder and ends the attack.
89/// The motes wait above the target until their strike releases them, then
90/// bounce off the ground and die out.
91///
92/// Called by the six wrappers above it, with the mode their ability needs.
93/// Uses PARTICLES 0 to 767 for the motes, 32 a strike, and both blitter
94/// slots, rebuilt twice a frame; loads palette colours 0 to 63 from the
95/// row's palette resource.
96///
97/// effect: the user and the targets; prelude 1 brings in a Jupiter Djinni
98/// first.
99/// mode : the row of gBurstScene_Records.
101 struct EffectPosition actorPos;
102 struct EffectPosition targetPos;
103 struct EffectPosition screen;
104 s32 screenX;
105 s32 screenY;
106 BlitterPair draw;
107 struct BattleEffectWork *work;
108 void *canvas;
109 s32 frame;
110 u8 *sprites;
111 struct BattleCamera *camera;
112 struct MotionObject *target;
113 u8 *palette;
114 s32 paletteId;
115 s32 row;
116 s32 col;
117 s32 i;
118 s32 j;
119
122 sprites = *(gWorkSlot + HEAP_SLOT_BATTLE_SHEET);
123 camera = *(gWorkSlot + HEAP_SLOT_CAMERA);
124 work->effect = effect;
126 REG_BLDALPHA = BLEND_ALPHA(16, 16);
127 if (work->effect->prelude == 1)
128 BattleFx_RunDjinniEntrance(effect, 7, work->effect->side, 2, &screenX,
129 &screenY);
130
132
133 // Pack the flash (40x288) to half width at BURST_SCENE_FLASH_CELLS, as the
134 // canvas is shown at double width.
136 0);
137 for (row = 0; row != 288; row++) {
138 for (col = 0; col != 40; col++) {
139 s32 src = row * 40 + col;
140 s32 dst = row * 20 + col / 2 + BURST_SCENE_FLASH_CELLS;
141
142 work->sheet[dst] = work->sheet[src];
143 }
144 }
147 1);
148 else
150 1);
152 1, 0);
154 case 0:
155 paletteId = (s32)&ResourceId_MarsDjinnSheet;
156 break;
157 case 1:
158 paletteId = (s32)&ResourceId_LimePalette;
159 break;
160 case 2:
161 paletteId = (s32)&ResourceId_BlueArcSheetB;
162 break;
163 default:
164 paletteId = (s32)&ResourceId_EmberStreakSheet;
165 break;
166 }
167 palette = Resource_GetTableEntry(paletteId);
168 Iwram_CopyWords((void *)BG_PLTT, palette, 128);
169 WaitFrames(1);
170
172 // Trails: each transfer keeps 3/4 of every canvas level.
174
175 // Motes wait 25 pixels above the target, set to fly towards the middle
176 // of the field at up to 16 pixels a frame. Strike i releases PARTICLES
177 // i * 32 onwards, as many as its row's BURST_SCENE_MOTES.
178 target = GetBattleObjectSlotFar(work->effect->actors[0])->object;
179 for (i = 0; i != 768; i++) {
180 struct EffectStep *mote = &PARTICLES[i];
181
182 SET_POSITION(mote, target->x, target->y + 0x190000, target->z);
183 SET_VELOCITY(mote, (Random16() & 255) << 12,
184 ((Random16() & 255) - 127) << 12,
185 ((Random16() & 255) - 127) << 12);
186 if (mote->x > 0)
187 mote->velocityX = -mote->velocityX;
188 mote->variant = -1; // frames left (negative: not out yet)
189 }
191 4, 0);
192
193 // Each frame draws the strikes in progress, then the motes. Strike i
194 // starts on frame i * interval: its arc or wave plays for 6 frames, it
195 // hits on its third frame, and its flash plays for the 12 after that.
196 for (frame = 0; frame != gBurstScene_Records[mode][BURST_SCENE_FRAMES];
197 frame++) {
199
201 actorPos.x /= 2;
202
203 // Arcs and waves; odd strikes are drawn flipped upside down, and on
204 // side 1 both are mirrored.
205 if (work->effect->side == 0) {
209 } else {
214 }
217 for (i = 0; i != bursts; i++) {
219
220 if (frame >= start && frame < start + 6) {
221 s32 step = frame - start;
222
223 if ((i & 3) <= 1 ||
225 // The arc: six 48x72 frames.
226 if (work->effect->side == 0)
227 draw[i & 1](canvas, work->sheet + step * (48 * 72),
228 targetPos.x / 2 - 16, targetPos.y - 40, 48, 72);
229 else
230 draw[i & 1](canvas, work->sheet + step * (48 * 72),
231 targetPos.x / 2 - 32, targetPos.y - 40, 48, 72);
232 } else {
233 // The wave: six 48x16 frames.
234 if (work->effect->side == 0)
235 draw[i & 1](canvas, BURST_SCENE_WAVE_CELLS + step * (48 * 16),
236 targetPos.x / 2 - 16, actorPos.y - 8, 48, 16);
237 else
238 draw[i & 1](canvas, BURST_SCENE_WAVE_CELLS + step * (48 * 16),
239 targetPos.x / 2 - 32, actorPos.y - 8, 48, 16);
240 }
241 }
242 if (frame == start + 2) {
243 // The hit; the last strike ends the attack.
244 // A flash row fills the canvas with level 47.
246 Iwram_FillWords(canvas, CANVAS_BYTES, 0x2f2f2f2f);
248 POSE_DAMAGE, 0, 4);
249 if (i == bursts - 1) {
251 work->shakeFrames = 8;
253 } else {
254 if (i & 1)
256 work->shakeFrames = 4;
258 }
259 for (j = 0; j != gBurstScene_Records[mode][BURST_SCENE_MOTES]; j++)
260 PARTICLES[i * 32 + j].variant = (Random16() & 7) + 15;
261 }
262 // The flash: six 20x48 frames, 2 frames each.
263 if (frame >= start + 2 && frame < start + 14)
264 draw[0](canvas,
265 work->sheet + ((frame - start - 2) / 2) * (20 * 48) +
267 targetPos.x / 2 - 10, targetPos.y - 24, 20, 48);
268 }
270
271 // Motes: a released mote's variant is its life, 15 to 22 frames, and
272 // it shrinks from a 3- to a 1-pixel mote as the life runs out. It
273 // bounces at half speed when it falls below 8 pixels over the ground.
274 // Only the first 512 are drawn; strikes never reach past 288.
282 for (i = 0; i != 512; i++) {
283 struct EffectStep *mote = &PARTICLES[i];
284
285 s32 size = mote->variant;
286
287 if (size > 0) {
288 EffectPosition_ProjectPoint(&mote->x, &screen);
289 screen.x /= 2;
290 size >>= 3;
291 size++;
292 EFFECT_DRAW_MOTE(draw[(i / 2) & 1], canvas, sprites, screen.x, screen.y,
293 size);
294 EffectStep_AdvanceWithGravity3D(mote, 60, -0x400);
295 if (mote->y < 0x80000)
296 mote->velocityY = -mote->velocityY / 2;
297 mote->variant--;
298 }
299 }
301 Camera_ApplyShake(8, 8);
302 EFFECT_END_FRAME(work);
303 }
306}
307
308#undef BURST_SCENE_FLASH_CELLS
309#undef BURST_SCENE_WAVE_CELLS
@ SPRITE_COLOR_WHITE
solid colour 15, white
Definition animspr.h:26
@ POSE_DAMAGE
taking damage
Definition battle.h:176
@ COMPOSITE_FLIP_X
@ COMPOSITE_FLIP
@ COMPOSITE_FLIP_Y
@ COMPOSITE_ADDITIVE
@ COMPOSITE_MAX
BattleEffectDrawRectangle DrawRectangle
void BattleFx_RunRansack(struct BattleEffectArgument *effect)
Ransack: the same five strikes as Bear Claw (mode 0).
Definition burst_scene.c:33
void BattleFx_RunGust(struct BattleEffectArgument *effect)
Gust: the burst scene in mode 6, 7 or 8 as the variant grows, one to three strikes that each fill the...
Definition burst_scene.c:11
BurstField
The bytes of a gBurstScene_Records row, one row a mode.
Definition burst_scene.c:68
@ BURST_SCENE_PALETTE
the palette's resource (0 to 3)
Definition burst_scene.c:71
@ BURST_SCENE_MOTES
motes thrown by each strike
Definition burst_scene.c:73
@ BURST_SCENE_INTERVAL
frames between strikes
Definition burst_scene.c:74
@ BURST_SCENE_FRAMES
frames in the whole effect
Definition burst_scene.c:75
@ BURST_SCENE_ARC_SHEET
0: blue arc A, else B; 1 also draws every strike as an arc
Definition burst_scene.c:69
@ BURST_SCENE_STRIKES
the strikes
Definition burst_scene.c:72
@ BURST_SCENE_FLASH
1 fills the canvas on each hit
Definition burst_scene.c:76
void BattleFx_RunFlyingAttack(struct BattleEffectArgument *effect)
Flying Attack: the burst scene in mode 3, 4 or 5 as the variant grows, one to three strikes.
Definition burst_scene.c:55
void BattleFx_RunBearClaw(struct BattleEffectArgument *effect)
Bear Claw: five strikes, the burst scene in mode 0.
Definition burst_scene.c:26
#define BURST_SCENE_WAVE_CELLS
The wave pictures, in the map buffer past the motes.
Definition burst_scene.c:82
void BattleFx_RunFreebiteRush(struct BattleEffectArgument *effect)
Freebite Rush: nine strikes in the blue palette (mode 2).
Definition burst_scene.c:47
void BattleFx_RunBacteriaRush(struct BattleEffectArgument *effect)
Bacteria Rush: seven strikes in the lime palette (mode 1).
Definition burst_scene.c:40
void BattleFx_RunBurstScene(struct BattleEffectArgument *effect, s32 mode)
Flurry: the user closes on the first target and strikes it again and again; each strike shows an arc ...
#define BURST_SCENE_FLASH_CELLS
The flash pictures, packed to half width after the arcs.
Definition burst_scene.c:80
void BattleFx_ProcessPendingGraphicsTransfer(void)
Copies the canvas to VRAM once the effect has finished drawing a frame (transferPending): the 128x128...
Definition canvas.c:103
void BattleFx_BeginCanvasLayer(s32 bgControl)
Opens the canvas layer: starts the background palette fade, makes BG2 the canvas, alpha-blended over ...
Definition canvas.c:314
void BattleFx_EndCanvasLayer(void)
Closes the canvas layer: plays the closing sound, restores BG1's scroll and the projection centre,...
Definition canvas.c:490
void Resource_LoadAndDecompress(s32 id, void *dst, s32 skipPalette, s32 copyPalette)
Decompresses a resource whose first 128 bytes may be a palette.
void ObjectGroup_UpdateMembers(s32 actorId, s32 palette, s32 animation, s32 timerSlot, s32 timerFrames)
Updates every animation group of one battler's object.
Definition dispatch.c:254
What every part of the battle effect object shares: its includes, macros and frame-loop helpers.
#define EFFECT_RELEASE_BLITTERS()
Frees the two blitters, the alternate first.
#define EFFECT_DRAW_MOTE(draw, canvas, sheet, x, y, size)
Particle sheets hold ten mote cells, 1x2 to 10x20 pixels.
@ CANVAS_COPY_AND_FADE
copy, keeping 50% or 75% (transferValue) of each pixel in the canvas for the next frame
#define CANVAS_BYTES
The canvas: 128x128 pixels, one byte each, in its heap slot and in VRAM at BG_CHAR_BLOCK(1).
#define EFFECT_SHOW_DAMAGE(hitSound)
Lets the battle show the damage: resumes its paused playback, which plays hitSound (an SE_ id; 0 keep...
#define EFFECT_START_TRANSFER(work, mode, value)
Sets the transfer, then starts copying the canvas to VRAM once a frame.
#define EFFECT_LOAD_BLITTER(slot, flags, mode)
Builds a blitter for the 128x128 canvas (1 << 7 pixels each way) in work slot slot: BattleFx_BuildBli...
#define EFFECT_END_FRAME(work)
The usual end of an effect frame: counts down the targets' flash timers (ObjectGroup_TickMemberTimers...
#define EFFECT_VIEW_FROM_CAMERA(camera)
Starts a frame's 3D projection from the battle camera: resets the transform, then looks from camera->...
u8 gBurstScene_Records[][7]
Each burst scene mode, by the BURST_SCENE_ columns (burst_scene.c).
struct BattleObj * GetBattleObjectSlotFar(s32 objectId)
Far call to BattleObjGet.
void BattleMotion_ApproachTargetFar(s32 actorId, s32 targetId, s32 travel_divisor, s32 initial_velocity_y)
void BattleMotion_ApplyVariantMotionFar(s32 id, s32 variant)
void AudioCommand_PlayFar(s32 id)
void WaitFrames(s32 frames)
The game's frame loop: runs frames frames and returns.
Definition frame.c:97
void Camera_ApplyShake(s32 rangeX, u32 rangeY)
Shakes the battle view while gBattleFxWork's shakeFrames lasts, moving BG1 and the projection centre ...
Definition hail.c:364
@ HEAP_SLOT_BATTLE_EFFECT
Definition heap_state.h:42
@ HEAP_SLOT_BLITTER_ALTERNATE
Definition heap_state.h:47
@ HEAP_SLOT_BATTLE_SHEET
Definition heap_state.h:44
@ HEAP_SLOT_CAMERA
Definition heap_state.h:38
@ HEAP_SLOT_BLITTER
Definition heap_state.h:46
@ HEAP_SLOT_BATTLE_CANVAS
Definition heap_state.h:43
#define BLEND_ALPHA(top, bottom)
A REG_BLDALPHA value: top and bottom are the two targets' weights, out of 16.
Definition io_reg.h:145
#define REG_BLDALPHA
Definition io_reg.h:142
#define BG_PLTT
Definition io_reg.h:157
static s32 Iwram_CopyWords(volatile void *destination, const volatile void *source, s32 size)
Definition iwram_call.h:85
static s32 Iwram_FillWords(void *destination, s32 size, u32 value)
Definition iwram_call.h:59
#define SET_VELOCITY(p, vx, vy, vz)
Definition macros.h:18
#define SET_POSITION(p, px, py, pz)
Sets the position or the velocity of a particle, a piece of debris or an object in one statement.
Definition macros.h:16
u32 Random16(void)
Advances the game's random number generator (the C library's classic linear congruential one),...
Definition math.c:10
void EffectPosition_ProjectScaledBattler(s32 id, struct EffectPosition *position)
The screen position of a battler, scaled for the battle view, 16 pixels higher.
Definition positions.c:88
void EffectStep_AdvanceWithGravity3D(struct EffectStep *step, s32 damping, s32 gravity)
Moves a particle one frame in three dimensions: adds its velocity, then gravity to its vertical speed...
Definition positions.c:29
s32 EffectPosition_ProjectPoint(const void *point, struct EffectPosition *position)
Projects a point in the current transform onto the screen, 16 pixels higher, and returns the projecti...
Definition positions.c:64
void BattleFx_RunDjinniEntrance(struct BattleEffectArgument *effect, s32 mode, s32 side, s32 anchor, s32 *outX, s32 *outY)
Djinni entrance: sparks swirl around a point that travels from the user to the goal and gather into t...
Definition projectiles.c:29
char ResourceId_BlueArcSheetB
char ResourceId_YellowOrbSheet
char ResourceId_LimePalette
char ResourceId_BlueArcSheetA
char ResourceId_MarsDjinnSheet
char ResourceId_ParticleSpritesA
char ResourceId_WaveSheet
char ResourceId_EmberStreakSheet
s32 Scheduler_RemoveCallback(SchedulerCallback callback)
Unschedules the task running callback: clears its routine and gives it order 0x7fff,...
Definition scheduler.c:146
#define SE_HEAVY_IMPACT
Definition songs.h:127
void * gWorkSlot[]
The battle camera: its eye, the focus it turns about, and its pitch, yaw and distance.
The command shared by an effect's caller, dispatcher and handlers.
s32 actor
the user's unit id
s32 side
1 when the targets are the party, 0 for enemies
s16 actors[8]
the targets' unit ids, count of them
s32 variant
the ability's size, from 0 (Quake, then Earthquake)
s32 prelude
1 plays a prelude: in some effects a Djinni appears
The running battle effect's work: its canvas image, 64 particles, the display registers it stages and...
s32 frame
frame counter some effects keep, from 0
s32 shakeFrames
shake frames left; Camera_ApplyShake counts down
struct BattleEffectArgument * effect
the command being run
struct MotionObject * object
NULL once released.
A point projected onto the screen, with its depth.
Definition effect_step.h:46
s32 y
screen pixels
Definition effect_step.h:59
s32 x
screen pixels
Definition effect_step.h:58
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
s32 velocityX
16.16 fixed-point pixels per frame
Definition effect_step.h:28
s32 variant
each effect's own: a size, a countdown, -1 for idle
Definition effect_step.h:31
s32 x
16.16 fixed-point pixels
Definition effect_step.h:24
s32 y
16.16 fixed-point pixels
Definition effect_step.h:25
s32 velocityY
16.16 fixed-point pixels per frame
Definition effect_step.h:29
An effect object that moves and draws one sprite: its position, scale, velocity and target,...
Definition motobj.h:20
s32 z
16.16 fixed-point pixels
Definition motobj.h:25
s32 y
16.16 fixed-point pixels
Definition motobj.h:24
s32 x
16.16 fixed-point pixels
Definition motobj.h:23
void * Resource_GetTableEntry(s32 index)
Returns the ROM address of resource index from the resource directory.
Definition system.c:150
signed int s32
Definition types.h:14
unsigned char u8
Definition types.h:11
#define EFFECT_CLIP_BOUNDS
Clips overflow on all four sides.
Definition effect.h:224
#define PARTICLES
The map cell buffer (gMapCellBuffer), which the effects borrow, has two views here: Ram_MapCellBuffer...
Definition effect.h:221
DrawRectangle BlitterPair[2]
A blitter pair: [0] built in HEAP_SLOT_BLITTER and [1] in HEAP_SLOT_BLITTER_ALTERNATE (BattleFx_Fetch...
Definition effect.h:244