Digimon World 3 decomp
The European version, SLES_039.36
Loading...
Searching...
No Matches
update_stage_effect.inc.c
Go to the documentation of this file.
1/*
2 * A StageEffect's update: its sprite with its palette animated
3 * (effectClutFrames) while it runs, and the one-shot animation
4 * (effectFrames) above it once done, until it ends
5 */
8 s32 done;
9 s32 frame;
10
11 switch (task->state) {
12 case TASK_INIT:
13 default:
14 task->key1 = task->x;
15 task->key2 = task->y;
16 task->anim.index = 0;
18 task->clutAnim.index = 0;
20 task->nextState(task);
21 break;
22 case TASK_RUN:
23 task->sprites[0].frame = task->frame;
24 task->sprites[0].clutRow = stepAnimation(&task->clutAnim, effectClutFrames, 0, 0);
25 if (task->sprites[0].frame != 0 && isOnScreen(task->x, task->y, 0x20, 0x20)) {
26 layer->addSortedCallback(layer, drawStageEffect, task, task->y, 0);
27 }
28 break;
29 case TASK_DONE:
30 if (task->substate == 0) {
31 task->anim.index = 0;
33 task->clutAnim.index = 0;
35 task->setSubstate(task, 1);
36 }
37 task->sprites[0].frame = task->frame;
38 task->sprites[0].clutRow = stepAnimation(&task->clutAnim, effectClutFrames, 0, 0);
39 done = 0;
40 frame = stepAnimation(&task->anim, effectFrames, 1, 0);
41 switch (frame) {
42 case 0xFF:
43 task->sprites[1].frame = 0;
44 done = 1;
45 break;
46 case 0x12C:
47 task->sprites[1].frame = 0;
48 break;
49 default:
50 task->sprites[1].frame = task->frame + frame;
51 break;
52 }
53 if (done) {
54 task->setState(task, TASK_RUN);
55 }
56 if (task->sprites[0].frame != 0 && isOnScreen(task->x, task->y, 0x20, 0x20)) {
57 layer->addSortedCallback(layer, drawStageEffect, task, task->y, 0);
58 }
59 if (task->sprites[1].frame != 0 && isOnScreen(task->x, task->y - 0x20, 0x20, 0x40)) {
60 layer->addSortedCallback(layer, drawStageEffect, task, task->y + 0x12, 1);
61 }
62 break;
63 case TASK_KILL:
64 break;
65 }
66}
signed int s32
Definition common.h:11
GfxState GFX
GFX: the graphics state and its methods.
Definition display.c:209
void drawStageEffect(StageEffect *task, void *arg, s32 idx)
Draws sprite idx of a StageEffect (the second, the one-shot one, 0x20 higher) on LAYER,...
#define TASK_RUN
Definition task.h:35
#define TASK_KILL
Definition task.h:37
#define TASK_INIT
Tasks: every game object is a task, a heap block that starts with this header and is updated once per...
Definition task.h:34
#define TASK_DONE
Definition task.h:36
#define FIELD_LAYER_MAP
the map, its objects and characters, and the menus
Definition field_map.h:20
s32 isOnScreen(s32 x, s32 y, s32 w, s32 h)
Whether the rectangle (x, y, w, h) is in the view of the map's layer.
s32 stepAnimation(AnimState *anim, AnimFrame *frames, s32 once, s32 depth)
Steps ANIM through FRAMES by the frame time (at most 4) and returns its frame: at the end (frame 0xFF...
s16 duration
Definition gfx.h:298
s16 index
Definition gfx.h:302
s16 timer
Definition gfx.h:303
struct Layer *(* getLayer)(s32 id)
Definition gfx.h:28
GfxFuncs funcs
Definition gfx.h:77
A drawing layer (GFX.funcs.createLayer): a DRAWENV with a pair of ordering tables,...
Definition gfx.h:128
void(* addSortedCallback)()
Definition gfx.h:160
A sprite at (x, y) from the stage's sheet (FieldState.sheetEntry) with an animated palette,...
Definition stage.h:79
s32 key2
Definition stage.h:80
s32 x
Definition stage.h:82
s32 frame
Definition stage.h:81
s32 state
Definition stage.h:80
AnimState anim
the one-shot animation
Definition stage.h:84
void(* nextState)(struct StageEffect *task)
Definition stage.h:80
s32 key1
Definition stage.h:80
void(* setSubstate)(struct StageEffect *task, s32 substate)
Definition stage.h:80
StageSprite sprites[2]
drawn at depth 6 and 4
Definition stage.h:86
AnimState clutAnim
Definition stage.h:85
void(* setState)(struct StageEffect *task, s32 state)
Definition stage.h:80
s32 y
Definition stage.h:83
s32 substate
Definition stage.h:80
s16 clutRow
Definition stage.h:71
s16 frame
Definition stage.h:70
void updateStageEffect(StageEffect *task)
A StageEffect's update: its sprite with its palette animated (effectClutFrames) while it runs,...
AnimFrame effectClutFrames[]
Definition wstag311.c:1046
AnimFrame effectFrames[]
Definition wstag311.c:1050