Alchemy
Loading...
Searching...
No Matches

thrash.c

Go to the documentation of this file.
1/// @file
2/// Thrash, Quick Strike and Vorpal Slash.
3/// Part of effect.c, the battle effect object, compiled only through it.
4
6
7/// One 120x120 picture of a flashing strike; two fill work->imageStorage and
8/// two more Ram_MapCellBuffer.
9#define FLASHING_STRIKE_PICTURE_BYTES (120 * 120)
10
11/// The user leaps high at the first target, then a burst of 32 sparks rises
12/// beneath it.
13///
14/// Abilities: Thrash (kind 388).
15///
16/// The leap takes the user three quarters of the way in 24 steps, starting up
17/// at 12.2 pixels a frame (16.16); after 29 frames the spark group plays with
18/// effect->variant set to 4, overriding the ability's own.
20 BattleMotion_ApproachTargetFar(effect->actor, effect->actors[0], 24, 0xc3333);
21 WaitFrames(29);
22 effect->variant = 4;
23 BattleFx_RunSparkGroups(effect, 2);
24}
25
26/// The user leaps at the first target, then a burst of 340 sparks rises
27/// beneath it and the canvas flashes.
28///
29/// Abilities: none (kind 387).
30///
31/// A lower leap than Thrash's (7.2 pixels a frame up), and the spark group
32/// after 12 frames with effect->variant set to 3, overriding the ability's
33/// own.
35 BattleMotion_ApproachTargetFar(effect->actor, effect->actors[0], 24, 0x73333);
36 WaitFrames(12);
37 effect->variant = 3;
38 BattleFx_RunSparkGroups(effect, 2);
39}
40
41/// The user leaps at the first target, four pictures flash across the effect
42/// layer, then it fills with one colour as the target is struck.
43///
44/// Abilities: Quick Strike (kind 52).
47}
48
49/// The user steps up to the first target, four pictures flash across the
50/// effect layer, then it fills with one colour as the target is struck.
51///
52/// Abilities: Vorpal Slash (kind 65).
55}
56
57/// Plays a flashing strike, the runner of BattleFx_RunQuickStrike (mode 1)
58/// and BattleFx_RunVorpalSlash (mode 2); nothing passes mode 0.
59///
60/// The user steps up to the first target over 16 frames. Then four 120x120
61/// pictures show for four frames each (mirrored when effect->side is 1), the
62/// canvas fills with colour 0x3f on frames 16 to 19, the battle shows the
63/// damage on frame 18, and on frame 20 the target reels and the screen
64/// shakes. 21 frames.
65///
66/// Opens and closes the canvas layer; the pictures take work->imageStorage
67/// and the start of Ram_MapCellBuffer.
68///
69/// mode: picks the pictures (RevealMaskE and F for 0, C and D for 1, A and B
70/// for 2); mode 1 also makes the step a hop.
72 void **slots;
73 struct BattleEffectWork *work;
74 void *canvas;
75 DrawRectangle draw[2];
76 s32 frame;
77
78 slots = gBattleFxWork;
79 EFFECT_GET_WORK_AND_CANVAS(slots, work, canvas);
80 work->effect = effect;
82 REG_BLDCNT = 0;
83
84 // Each resource holds two pictures: the first fills work->imageStorage, up
85 // to the particles, and the second the start of Ram_MapCellBuffer.
86 if (mode == 0) {
88 1, 0);
90 1, 1);
91 } else if (mode == 1) {
93 1, 0);
95 1, 1);
96 } else {
98 1, 0);
100 1, 1);
101 }
103
104 // The step: three quarters of the way in 16 steps, a hop of 8 pixels a
105 // frame up for Quick Strike.
106 if (mode == 1)
108 0x80000);
109 else
111 WaitFrames(16);
112
113 if (work->effect->side == 1)
116 else
120 for (frame = 0; frame != 21; frame++) {
121 if (frame <= 3)
122 draw[0](canvas, work->imageStorage, 0, 0, 120, 120);
123 else if (frame <= 7)
124 draw[0](canvas, work->imageStorage + FLASHING_STRIKE_PICTURE_BYTES, 0, 0,
125 120, 120);
126 else if (frame <= 11)
127 draw[0](canvas, Ram_MapCellBuffer, 0, 0, 120, 120);
128 else if (frame <= 15)
129 draw[0](canvas, Ram_MapCellBuffer + FLASHING_STRIKE_PICTURE_BYTES, 0, 0,
130 120, 120);
131 if (frame >= 16 && frame <= 19)
132 Iwram_FillWords(canvas, CANVAS_BYTES, 0x3f3f3f3f);
133 if (frame == 18)
135 if (frame == 20) {
136 work->shakeFrames = 8;
138 }
139 Camera_ApplyShake(16, 16);
140 EFFECT_END_FRAME(work);
141 }
142 // Releases the blitter before stopping the transfer, the other way round
143 // from EFFECT_FINISH_CANVAS_ONE_BLITTER.
147}
148
149#undef FLASHING_STRIKE_PICTURE_BYTES
void * gBattleFxWork[]
@ COMPOSITE_FLIP_X
@ COMPOSITE_COPY
BattleEffectDrawRectangle DrawRectangle
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.
What every part of the battle effect object shares: its includes, macros and frame-loop helpers.
@ CANVAS_COPY_AND_CLEAR
copy, then fill the canvas with transferValue
#define EFFECT_GET_WORK_AND_CANVAS(cursor, work, canvas)
The work block and canvas occupy adjacent slots, starting at HEAP_SLOT_BATTLE_EFFECT.
#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...
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_BLITTER
Definition heap_state.h:46
#define REG_BLDCNT
Definition io_reg.h:119
static s32 Iwram_FillWords(void *destination, s32 size, u32 value)
Definition iwram_call.h:59
void Runtime_ReleaseHeapBlock(s32 slot)
void BattleFx_RunSparkGroups(struct BattleEffectArgument *effect, s32 mode)
One to three bursts, 8 frames apart: each flashes, rings itself with twelve smaller flashes that fade...
Definition plasma.c:234
#define Ram_MapCellBuffer
Definition ram_buffer.h:10
char ResourceId_RevealMaskC
char ResourceId_RevealMaskE
char ResourceId_RevealMaskF
char ResourceId_RevealMaskB
char ResourceId_RevealMaskA
char ResourceId_RevealMaskD
s32 Scheduler_RemoveCallback(SchedulerCallback callback)
Unschedules the task running callback: clears its routine and gives it order 0x7fff,...
Definition scheduler.c:146
#define SE_212
Definition songs.h:207
#define SE_HEAVY_IMPACT
Definition songs.h:127
void * gWorkSlot[]
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)
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
void BattleFx_RunSparkApproachVariant3(struct BattleEffectArgument *effect)
The user leaps at the first target, then a burst of 340 sparks rises beneath it and the canvas flashe...
Definition thrash.c:34
void BattleFx_RunThrash(struct BattleEffectArgument *effect)
The user leaps high at the first target, then a burst of 32 sparks rises beneath it.
Definition thrash.c:19
void BattleFx_RunFlashingStrike(struct BattleEffectArgument *effect, s32 mode)
Plays a flashing strike, the runner of BattleFx_RunQuickStrike (mode 1) and BattleFx_RunVorpalSlash (...
Definition thrash.c:71
#define FLASHING_STRIKE_PICTURE_BYTES
One 120x120 picture of a flashing strike; two fill work->imageStorage and two more Ram_MapCellBuffer.
Definition thrash.c:9
void BattleFx_RunVorpalSlash(struct BattleEffectArgument *effect)
The user steps up to the first target, four pictures flash across the effect layer,...
Definition thrash.c:53
void BattleFx_RunQuickStrike(struct BattleEffectArgument *effect)
The user leaps at the first target, four pictures flash across the effect layer, then it fills with o...
Definition thrash.c:45
signed int s32
Definition types.h:14
#define EFFECT_CLIP_BOUNDS
Clips overflow on all four sides.
Definition effect.h:224