Digimon World 3 decomp
The European version, SLES_039.36
Loading...
Searching...
No Matches
effect.c
Go to the documentation of this file.
1/* The effects of up to four animations at a spot */
2
3#include "field/field_mode.h"
4
5/* Steps one of an effect's animations, catching up on up to 4 frames, and
6 returns its frame, or 0xFF at its end */
8 AnimFrame *frame = &frames[anim->anim.index];
9 s32 elapsed = GFX.funcs.getFrameTime();
10
11 if (elapsed > 4) {
12 elapsed = 4;
13 }
14 if (depth == 0) {
15 anim->anim.timer -= elapsed;
16 }
17 if (anim->anim.timer <= 0) {
18 frame++;
19 anim->anim.index++;
20 anim->anim.timer += frame->duration;
21 if (frame->frame == 0xFF) {
22 return 0xFF;
23 }
24 FIELDSTG_stepEffectAnim(anim, frames, depth + 1);
25 }
26 return frame->frame;
27}
28
29/* An effect's update: draws its animations at its spot until they end */
32 SpriteDrawer sprite;
33 s32 i;
34 s32 j;
35 s32 frame;
36
37 switch (task->state) {
38 default:
39 case TASK_INIT:
40 for (i = 0; i < 4; i++) {
41 task->anims[i].active = 1;
42 task->anims[i].anim.index = 0;
43 task->anims[i].anim.timer = FIELDSTG_effectAnims[task->set][i][0].duration;
44 }
45 task->nextState(task);
46 break;
47 case TASK_RUN:
48 for (j = 0; j < 4; j++) {
49 if (task->anims[j].active != 0) {
50 frame = FIELDSTG_stepEffectAnim(&task->anims[j], FIELDSTG_effectAnims[task->set][j], 0);
51 switch (frame) {
52 case 0x12C:
53 break;
54 case 0xFF:
55 task->anims[j].active = 0;
56 break;
57 default:
58 initSpriteDrawer(&sprite);
60 sprite.setLayer(layer, 0);
61 sprite.setClutRow(0);
62 sprite.draw(FILE_CACHE.getEntry(FIELD_SPRITES_FILE << 16 | 1), frame, task->x, task->y);
63 break;
64 }
65 }
66 }
67 if (task->anims[0].active == 0 && task->anims[1].active == 0 && task->anims[2].active == 0
68 && task->anims[3].active == 0) {
69 task->setState(task, TASK_KILL);
70 }
71 break;
72 case TASK_DONE:
73 case TASK_KILL:
74 break;
75 }
76}
77
78/* Creates the effect of a set at (x, y) */
81
82 task->x = x;
83 task->y = y;
84 task->set = set;
85 return task;
86}
signed int s32
Definition common.h:11
GfxState GFX
GFX: the graphics state and its methods.
Definition display.c:209
s32 FIELDSTG_stepEffectAnim(EffectAnim *anim, AnimFrame *frames, s32 depth)
Steps one of an effect's animations, catching up on up to 4 frames, and returns its frame,...
Definition effect.c:7
void FIELDSTG_updateEffect(FieldEffect *task)
An effect's update: draws its animations at its spot until they end.
Definition effect.c:30
FieldEffect * FIELDSTG_createEffect(s32 x, s32 y, s32 set)
Creates the effect of a set at (x, y)
Definition effect.c:79
#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
FIELDSTG.PRO: the field mode, where the player walks around the map.
#define FIELD_SPRITES_FILE
The field's effect sprites (FIELDSTG_drawSpotEffect): the discs number their files differently.
Definition field_mode.h:591
#define FIELD_SPRITES_Y
Definition field_mode.h:29
#define FIELD_SPRITES2_X
Definition field_mode.h:28
AnimFrame * FIELDSTG_effectAnims[][4]
FIELDSTG_updateEffect's animations of each set.
Definition fieldstg.c:1396
FileCache FILE_CACHE
The file cache.
Definition file_cache.c:7
void initSpriteDrawer(SpriteDrawer *obj)
Clears a sprite drawer to neutral (no scale, gray tint, follows the scroll), gives it its methods and...
One frame of a sprite animation; frame 0xFF ends it (or loops it)
Definition gfx.h:296
s16 frame
Definition gfx.h:297
s16 duration
Definition gfx.h:298
s16 index
Definition gfx.h:302
s16 timer
Definition gfx.h:303
An animation of an FieldEffect (FIELDSTG_stepEffectAnim)
Definition field_mode.h:386
AnimState anim
Definition field_mode.h:388
An effect of up to four animations at a spot (FIELDSTG_createEffect)
Definition field_mode.h:392
void(* setState)(struct FieldEffect *task, s32 state)
Definition field_mode.h:393
s16 set
the row of FIELDSTG_effectAnims
Definition field_mode.h:396
void(* nextState)(struct FieldEffect *task)
Definition field_mode.h:393
EffectAnim anims[4]
Definition field_mode.h:397
void *(* getEntry)(u32 fileAndIndex)
Definition file.h:96
s32(* getFrameTime)(void)
Definition gfx.h:32
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
Draws sprites from a sprite sheet (such as file 0x277, the menu graphics): a sheet has a table of fra...
Definition gfx.h:223
void(* setLayer)()
(layer, depth)
Definition gfx.h:245
void(* setClutRow)()
(row)
Definition gfx.h:247
void(* draw)()
(sheet, frame, x, y)
Definition gfx.h:246
void(* setTexture)()
(x, y)
Definition gfx.h:242
void * createTask(void(*update)(), s32 size, s32 childrenSize)
createTaskWithId for a task nothing needs to find
Definition task.c:105