Digimon World 3 decomp
The European version, SLES_039.36
Loading...
Searching...
No Matches
update_tile_lift.inc.c
Go to the documentation of this file.
1/*
2 * The lift: moves the map objects of animations 3 and 2 (shown only while it
3 * moves) and the player 0x7F up or down each time an event sets TASK_DONE,
4 * shaken by the stage's tileLiftShake before and after
5 */
6void updateTileLift(Lift *task) {
7 StageTile *object;
8 StageTile *tile0;
9 StageTile *tile1;
10 Actor *player;
11 s32 d;
12
13 switch (task->state) {
14 case TASK_INIT:
15 default:
16 task->nextState(task);
17 for (object = FIELDSTG_state.objects; object->margin != 0; object++) {
18 switch (object->anim) {
19 case 2:
20 task->tiles[1] = object;
21 task->homeY[1] = object->y;
22 if (task->raised) {
23 object->y -= 0x7F;
24 }
25 object->visible = 0;
26 break;
27 case 3:
28 task->tiles[0] = object;
29 task->homeY[0] = object->y;
30 if (task->raised) {
31 object->y -= 0x7F;
32 }
33 object->visible = 1;
34 break;
35 }
36 }
37 task->raised = 0;
38 break;
39 case TASK_RUN:
40 break;
41 case TASK_DONE:
42 tile0 = task->tiles[0];
43 tile1 = task->tiles[1];
45 switch (task->substate) {
46 case 0:
47 default:
48 tile1->visible = 1;
49 task->timer = 0;
50 task->y[0] = tile0->y;
51 task->y[1] = tile1->y;
52 task->playerY = player->pos.y;
54 task->nextSubstate(task);
55 break;
56 case 1:
57 task->timer += GFX.funcs.getFrameTime();
58 if (task->timer >= 0x1E) {
59 task->shake = 0;
60 task->nextSubstate(task);
62 }
63 break;
64 case 2:
65 case 4:
66 d = tileLiftShake[task->shake];
67 if (d != 0x3E8) {
68 tile0->y = task->y[0] + d;
69 tile1->y = task->y[1] + d;
70 player->pos.y = task->playerY + d;
71 task->shake++;
72 } else {
73 task->nextSubstate(task);
74 task->shake = 0;
75 }
76 break;
77 case 3:
78 if (++task->shake >= 0xFE) {
79 if (task->raised) {
80 tile0->y = task->homeY[0];
81 tile1->y = task->homeY[1];
82 player->pos.y = task->playerY + 0x7F00;
83 } else {
84 tile0->y = task->homeY[0] - 0x7F;
85 tile1->y = task->homeY[1] - 0x7F;
86 player->pos.y = task->playerY - 0x7F00;
87 }
88 task->y[0] = tile0->y;
89 task->y[1] = tile1->y;
90 task->playerY = player->pos.y;
91 task->nextSubstate(task);
92 task->shake = 0;
93 } else if (task->shake & 1) {
94 if (task->raised) {
95 tile0->y++;
96 tile1->y++;
97 player->pos.y += 0x100;
98 } else {
99 tile0->y--;
100 tile1->y--;
101 player->pos.y -= 0x100;
102 }
103 }
104 break;
105 case 5:
106 tile1->visible = 0;
107 task->setState(task, TASK_RUN);
108 task->raised ^= 1;
109 break;
110 }
111 break;
112 case TASK_KILL:
113 break;
114 }
115}
signed int s32
Definition common.h:11
GfxState GFX
GFX: the graphics state and its methods.
Definition display.c:209
#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_TASK_ACTOR
every character (FIELDSTG_createActor)
Definition field_map.h:26
FieldState FIELDSTG_state
Definition fieldstg.c:2641
TaskRegistry TASK_REGISTRY
Definition registry.c:122
SoundState SOUND
rsin and rcos (libgte) read rsin_tbl[a - 0x800] and the like: their addresses before the table fall i...
Definition sound.c:180
#define SOUND_SWITCH01
Definition sound.h:50
#define SOUND_ELEVATER
Definition sound.h:60
A character on the field (FIELDSTG_createActor): the player (kind 0) and the other characters.
Definition field_map.h:334
Vec2 pos
Definition field_map.h:336
StageTile * objects
the map objects, up to the first margin 0
Definition field_map.h:446
s32(* getFrameTime)(void)
Definition gfx.h:32
GfxFuncs funcs
Definition gfx.h:77
void(* setState)(struct Lift *task, s32 state)
Definition field_map.h:239
void(* nextSubstate)(struct Lift *task)
Definition field_map.h:239
s32 substate
Definition field_map.h:239
s16 y[2]
the objects' y when the move started
Definition field_map.h:246
s16 raised
the objects are 0x7F up from their place, and the next move takes them down (LIFT_DOWN; flag 0x1C3D a...
Definition field_map.h:241
s16 shake
the step of the shake table, then a frame count
Definition field_map.h:244
StageTile * tiles[2]
the map objects 3 and 2
Definition field_map.h:240
void(* nextState)(struct Lift *task)
Definition field_map.h:239
s16 timer
Definition field_map.h:243
s16 homeY[2]
the objects' place on the map
Definition field_map.h:248
s32 state
Definition field_map.h:239
s32 playerY
Definition field_map.h:247
short(* playSound)(s32 id)
returns the voice of a key-on
Definition sound.h:187
An object of a map, which FIELDSTG draws: a record of the table at FieldState.objects,...
Definition field_map.h:208
u8 anim
which of a stage's animations sets frame (1-3); FIELDSTG finds objects by it (its lift,...
Definition field_map.h:210
void *(* find)(s32 id, s32 key1, s32 key2)
Definition task.h:18
TaskFuncs funcs
Definition task.h:76
s32 y
Definition gfx.h:354
void updateTileLift(Lift *task)
The lift: moves the map objects of animations 3 and 2 (shown only while it moves) and the player 0x7F...
s16 tileLiftShake[]
Defined below, after the code that uses them.
Definition wstag261.c:169