Digimon World 3 decomp
The European version, SLES_039.36
Loading...
Searching...
No Matches
wstag680.c
Go to the documentation of this file.
1/*
2 * WSTAG680: Storage Room, Byakko City. The basement the player falls into; no
3 * Bai Hu copy.
4 */
5
6#include "common.h"
7#include "field/stage.h"
8/* Defined below, after the code that uses them */
10
11/* Steps a mover's looping animation, its last frame setting how far it moves */
13 StageRiserFrame *frame = &frames[obj->anim.index];
15
16 if (dt > 4) {
17 dt = 4;
18 }
19 if (depth == 0) {
20 obj->anim.timer -= dt;
21 }
22 if (obj->anim.timer <= 0) {
23 frame++;
24 obj->anim.index++;
25 obj->anim.timer += frame->duration;
26 if (frame->frame == 0xFF) {
27 obj->move = frame->move;
28 frame = frames;
29 obj->anim.index = 0;
30 obj->anim.timer += frame->duration;
31 }
32 stepRiser(obj, frames, depth + 1);
33 }
34 return frame->frame;
35}
36
37/* Animates and moves the map objects of the stage's table (lifts for animations 8-10) and pushes the player */
39 StageTile *object;
40 StageTile *tile;
41 Actor *actor;
42 s32 i;
43 s32 j;
44
45 switch (task->state) {
46 case TASK_INIT:
47 default:
48 i = 0;
49 j = 0;
50 for (object = FIELDSTG_state.objects; object->margin != 0; object++) {
51 switch (object->anim) {
52 case 0:
53 break;
54 case 8:
55 case 9:
56 case 10:
57 task->lifts[j].active = 0;
58 task->lifts[j].speed = 0;
59 task->lifts[j].tile = object;
60 j++;
61 break;
62 default:
63 task->risers[i].tileAnim = object->anim;
64 task->risers[i].y = object->y << 8;
65 task->risers[i].active = 0;
66 task->risers[i].anim.index = 0;
68 task->risers[i].tile = object;
69 i++;
70 break;
71 }
72 }
73 task->nextState(task);
74 break;
75 case TASK_RUN:
76 for (i = 0; i < 11; i++) {
77 if (task->risers[i].active) {
78 tile = task->risers[i].tile;
79 tile->frame = stepRiser(&task->risers[i], updateRisersFrames[i], 0);
80 tile->y += task->risers[i].move;
81 task->risers[i].move = 0;
82 if (tile->y > 0x190) {
83 task->risers[i].active = 0;
84 }
85 }
86 }
87 for (i = 0; i < 3; i++) {
88 if (task->lifts[i].active) {
89 tile = task->lifts[i].tile;
90 task->lifts[i].speed += GFX.funcs.getFrameTime() << 7;
91 tile->y += task->lifts[i].speed >> 8;
92 if (tile->y > 0x190) {
93 task->lifts[i].active = 0;
94 }
95 }
96 }
97 if (task->pushing) {
99 task->push += 0x40;
100 actor->pos.y += task->push;
101 if (task->timer++ > 0x78) {
102 task->pushing = 0;
103 }
104 }
105 break;
106 case TASK_DONE:
107 case TASK_KILL:
108 break;
109 }
110}
111
112/* Starts the map objects an event moves (the handler of the events the task gets) */
113void handleCommand814(void *arg, s32 event) {
114 StageRisers *task = arg;
115 Actor *player;
116 s32 anim;
117 s32 i;
118
119 if (task != NULL) {
120 player = TASK_REGISTRY.funcs.find(FIELD_TASK_ACTOR, -1, 0);
121 anim = 0;
122 switch (event) {
123 case 0x344:
124 anim = 0;
125 break;
126 case 0x33D:
127 anim = 1;
128 break;
129 case 0x33E:
130 anim = 2;
131 break;
132 case 0x33F:
133 task->lifts[0].active = 1;
134 anim = 3;
135 break;
136 case 0x340:
137 anim = 4;
138 break;
139 case 0x341:
140 task->lifts[2].active = 1;
141 anim = 5;
142 break;
143 case 0x342:
144 anim = 6;
145 break;
146 case 0x343:
147 anim = 7;
148 task->lifts[1].active = 1;
149 player->hasShadow = 0;
150 break;
151 case 0x37B:
152 task->pushing = 1;
153 return;
154 }
155 if (anim != 0) {
156 for (i = 0; i < 11; i++) {
157 if (anim == task->risers[i].tileAnim) {
158 task->risers[i].active = 1;
159 }
160 }
162 }
163 }
164}
165
166/*
167 * Command 814 of the event scripts: the lifts that rise and carry the player
168 * off in event 412 (updateRisers)
169 */
171 return createTaskWithId(updateRisers, sizeof(StageRisers), 0, arg);
172}
173
174/* Creates the event object of story progress 0xF */
175void updateStage(StageTask *task, void **children) {
176 switch (task->state) {
177 case TASK_INIT:
178 default:
180 children[0] = FIELDSTG_startEvent(0x19C);
181 }
182 task->nextState(task);
183 break;
184 case TASK_RUN:
185 case TASK_DONE:
186 case TASK_KILL:
187 break;
188 }
189}
190
191#define STAGE_CHILDREN_SIZE 4
193
194#if VERSION_US || VERSION_JP
195#define STAGE_TEXT TEXT_FILE(TEXT_TALKS_01)
196#define EVENT_TEXT_FILE (TEXT_EVENTS_600 - 1)
197#define STAGE_FILE 0x62D
198#elif VERSION_EU
199#define STAGE_TEXT TEXT_FILE(TEXT_TALKS_01)
200#define EVENT_TEXT_FILE (TEXT_EVENTS_600 - 1)
201#define STAGE_FILE 0x63D
202#endif
203/* Sets the stage up: its map, actors and events, playing the ambience ENV_0019 */
220
222 SCRIPT_LOOK_AT(1, 0xA2, 0x7A),
223 SCRIPT_PLACE(1, 0x104, 0xBA),
224 SCRIPT_POSE(1, 1, 3),
225 SCRIPT_COMMAND(0x32E, 0x344, 1),
226 SCRIPT_WAIT(0x1E),
227 SCRIPT_WALK(1, 0x90, 0x80, 1),
229 SCRIPT_POSE(1, 1, 1),
230 SCRIPT_WAIT(0x1E),
231 SCRIPT_POSE(1, 0x3A, 1),
232 SCRIPT_WAIT(0x3C),
233 SCRIPT_POSE(1, 1, 1),
234 SCRIPT_WAIT(0x1E),
235 SCRIPT_TALK(0, 1, 1, 0),
237 SCRIPT_WAIT(0x1E),
238 SCRIPT_COMMAND(0x32E, 0x33D, 0x32E),
239 SCRIPT_WAIT_ANIM(0x32E),
240 SCRIPT_WAIT(0x1E),
241 SCRIPT_COMMAND(0x323, 0x325, 1),
243 SCRIPT_WAIT(0x3C),
244 SCRIPT_COMMAND(0x323, 0x326, 1),
245 SCRIPT_WAIT(0x1E),
246 SCRIPT_POSE(1, 1, 7),
247 SCRIPT_WAIT(0x3C),
248 SCRIPT_COMMAND(0x32E, 0x33E, 0x32E),
249 SCRIPT_WAIT_ANIM(0x32E),
250 SCRIPT_WAIT(0x1E),
251 SCRIPT_TALK(0, 2, 1, 0),
253 SCRIPT_WAIT(0x1E),
254 SCRIPT_COMMAND(0x32E, 0x33F, 0x32E),
255 SCRIPT_WAIT_ANIM(0x32E),
256 SCRIPT_WAIT(0x3C),
257 SCRIPT_POSE(1, 1, 1),
258 SCRIPT_WAIT(0x1E),
259 SCRIPT_COMMAND(0x323, 0x325, 1),
260 SCRIPT_WAIT(0x3C),
261 SCRIPT_COMMAND(0x323, 0x326, 1),
262 SCRIPT_WAIT(0x1E),
263 SCRIPT_WALK(1, 0xB0, 0x70, 1),
265 SCRIPT_COMMAND(0x32E, 0x340, 0x32E),
266 SCRIPT_WAIT_ANIM(0x32E),
267 SCRIPT_POSE(1, 1, 1),
268 SCRIPT_WAIT(0x3C),
269 SCRIPT_COMMAND(0x32E, 0x341, 0x32E),
270 SCRIPT_WAIT_ANIM(0x32E),
271 SCRIPT_POSE(1, 0x33, 7),
272 SCRIPT_WAIT(0x1E),
273 SCRIPT_TALK(0, 3, 1, 0),
274 SCRIPT_POSE(1, 1, 7),
276 SCRIPT_WAIT(0x1E),
277 SCRIPT_POSE(1, 1, 7),
278 SCRIPT_COMMAND(0x323, 0x325, 1),
279 SCRIPT_WAIT(0x3C),
280 SCRIPT_COMMAND(0x323, 0x326, 1),
281 SCRIPT_WAIT(0x1E),
282 SCRIPT_WALK(1, 0x90, 0x60, 7),
284 SCRIPT_COMMAND(0x32E, 0x342, 0x32E),
285 SCRIPT_WAIT_ANIM(0x32E),
286 SCRIPT_WAIT(0x5A),
287 SCRIPT_COMMAND(0x32E, 0x343, 0x32E),
288 SCRIPT_WAIT_ANIM(0x32E),
289 SCRIPT_COMMAND(0x323, 0x325, 1),
290 SCRIPT_WAIT(0x3C),
291 SCRIPT_COMMAND(0x323, 0x326, 1),
292 SCRIPT_WAIT(0x1E),
293 SCRIPT_POSE(1, 0x25, 7),
294 SCRIPT_WAIT(0x1E),
295 SCRIPT_TALK(0, 4, 1, 3),
297 SCRIPT_COMMAND(0x32E, 0x37B, 1),
298 SCRIPT_WAIT(0x5A),
299 SCRIPT_LEAVE(0x260, 0x330, 0x108, 0),
301};
303 { 14, 6, 0 },
304 { 15, 6, 0 },
305 { 16, 6, 0 },
306 { 255, 0, 72 },
307};
309 { 10, 6, 0 },
310 { 11, 6, 0 },
311 { 12, 6, 0 },
312 { 255, 0, 80 },
313};
315 { 5, 6, 0 },
316 { 6, 6, 0 },
317 { 7, 6, 0 },
318 { 8, 6, 0 },
319 { 255, 0, 80 },
320};
335 { 0x200, 0x100, 0x21C, 0x1A6, 0x70, 0xA6, 0x230, 0x1FE },
336 { 0x200, 0x100, 0x200, 0x100, 0, 0, 0x220, 0x1FE },
337 { 0x200, 0x100, 0x216, 0x138, 0x58, 0x38, 0x200, 0x1FD },
338 { 0x200, 0x100, 0x208, 0x1BC, 0x20, 0xBC, 0x210, 0x1FD },
339 { 0x200, 0x100, 0x210, 0x1BC, 0x40, 0xBC, 0x220, 0x1FD },
340 { 0x200, 0x100, 0x200, 0x1BC, 0, 0xBC, 0x230, 0x1FD },
341 { 0x140, 0x100, 0x176, 0x164, 0xD8, 0x64, 0x150, 0x1FF },
342};
346 &actor0,
347 NULL,
348};
350 { 1, 0, 0x40, 2, 0x32, 2, 0, 1, 6, 0, 56, 56, 0, 0 },
351 { 1, 0, 0x40, 2, 0x32, 2, 0, 1, 6, 0, 124, 22, 0, 0 },
352 { 1, 0, 0x40, 6, 3, 0, 0, 0, 0, 0, 240, 176, 0, 0 },
353 { 1, 1, 0x40, 6, 0xD, 0, 0, 0, 0, 0, 208, 160, 0, 0 },
354 { 1, 2, 0x40, 6, 9, 0, 0, 0, 0, 0, 176, 144, 0, 0 },
355 { 1, 3, 0x40, 6, 0xD, 0, 0, 0, 0, 0, 112, 144, 0, 0 },
356 { 1, 3, 0x40, 6, 9, 0, 0, 0, 0, 0, 80, 128, 0, 0 },
357 { 1, 4, 0x40, 6, 9, 0, 0, 0, 0, 0, 144, 128, 0, 0 },
358 { 1, 3, 0x40, 6, 0xD, 0, 0, 0, 0, 0, 48, 112, 0, 0 },
359 { 1, 4, 0x40, 6, 4, 0, 0, 0, 0, 0, 112, 112, 0, 0 },
360 { 1, 5, 0x40, 6, 0xD, 0, 0, 0, 0, 0, 176, 112, 0, 0 },
361 { 1, 4, 0x40, 6, 9, 0, 0, 0, 0, 0, 80, 96, 0, 0 },
362 { 1, 6, 0x40, 6, 4, 0, 0, 0, 0, 0, 144, 96, 0, 0 },
363 { 1, 7, 0x40, 6, 4, 0, 0, 0, 0, 0, 112, 80, 0, 0 },
364 { 1, 8, 0x40, 6, 0, 0, 0, 0, 0, 0, 55, 119, 0, 0 },
365 { 1, 0xA, 0x40, 6, 1, 0, 0, 0, 0, 0, 122, 85, 0, 0 },
366 { 1, 9, 0x40, 6, 2, 0, 0, 0, 0, 0, 216, 127, 0, 0 },
367 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
368};
369void (*stageFuncs[])(void) = {
371};
373 { 412, script412, EVENT_TEXT(2), NULL, NULL },
374 { -1, NULL, 0, NULL, NULL },
375};
#define NULL
Definition common.h:17
signed int s32
Definition common.h:11
signed short s16
Definition common.h:9
unsigned short u16
Definition common.h:10
GfxState GFX
GFX: the graphics state and its methods.
Definition display.c:209
GameState GAME
The save data, the game mode and the methods.
Definition state.c:64
#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
EventTask * FIELDSTG_startEvent(s32 id)
Starts the event id of FieldState.events: its script, start and end, and its text; the player stands ...
Definition event.c:250
The stage overlays (AAA/PRO/WSTAG###.PRO), loaded at 0x800A4CA4 on top of FIELDSTG.
#define SOUND_FLOOR_DN
Definition stage.h:751
#define EVENT_TEXT(n)
An entry of the stage's events' text file, for FieldEvent.text.
Definition stage.h:732
void updateStage()
The names every stage defines, each its own (config/<version>/stages/<stage>.txt).
#define FIELD_COMMAND_PLAY_DEMO_BGM
Definition field_map.h:53
#define SCRIPT_WAIT_WALK(id)
until the character gets to its goal
Definition field_map.h:168
#define SCRIPT_END
The commands of an event script (FieldEvent.script), as FIELDSTG_runEvent reads them: a halfword kind...
Definition field_map.h:156
#define SCRIPT_LOOK_AT(snap, x, y)
FIELDSTG_pointCamera.
Definition field_map.h:172
#define SCRIPT_LEAVE(mode, x, y, dir)
FIELDSTG_leaveField; ends the event.
Definition field_map.h:170
#define SCRIPT_COMMAND(id, command, arg)
the same word for a script command's id: FIELDSTG_setEventPose creates its task if none runs and hand...
Definition field_map.h:161
#define FIELD_MAP_FLOOR0
Some of FieldMap's maps (files): those of the floors the player walks on come first,...
Definition field_map.h:85
#define FIELD_TASK_ACTOR
every character (FIELDSTG_createActor)
Definition field_map.h:26
#define SCRIPT_WALK(id, x, y, dir)
Actor.setGoal: walks to (x, y), then faces dir.
Definition field_map.h:162
#define SCRIPT_WAIT_BOX
until box 0 closes
Definition field_map.h:167
#define SCRIPT_POSE(id, set, dir)
Actor.setPose: its animation set, facing dir.
Definition field_map.h:158
#define SCRIPT_WAIT(frames)
Definition field_map.h:166
#define SCRIPT_WAIT_ANIM(id)
until its animation ends
Definition field_map.h:169
#define FIELD_TASK_COMMANDS
script command 813 (FIELDSTG_startCommandTask): the field commands
Definition field_map.h:33
#define SCRIPT_PLACE(id, x, y)
puts a character at (x, y)
Definition field_map.h:157
#define SCRIPT_TALK(box, entry, id, kind)
box of the event's boxes shows the event text's entry: a talk box at the corner kind next to the char...
Definition field_map.h:165
FieldMap FIELDSTG_map
Definition fieldstg.c:3660
FieldState FIELDSTG_state
Definition fieldstg.c:2641
#define CODES_END
Definition game_state.h:83
#define PROGRESS(n)
GAME.progress is n.
Definition game_state.h:69
#define FLAG(group, id)
The codes of the (code, value) pairs that FLAGS_00 checks as conditions and applies as actions (event...
Definition game_state.h:68
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 MUSIC_STORAGE_ROOM
ENV_0019: Byakko City's Storage Room.
Definition sound.h:135
#define MUSIC_BANK(music)
The sound bank of a music, which a stage loads for it (FieldState.soundBank)
Definition sound.h:148
FIELDSTG's start of the stage (StageEntry.init in FIELDSTG_stages): the stage's task,...
@ STORY_DE_SINCERITY
WSTAG460 (Reliability Spot), event 370: the Qing Long Chief, asked for the Digi-Egg of Knowledge,...
Definition story.h:70
Where an actor's frames go in VRAM: one of the records after the FieldImage (Actor....
Definition field_map.h:114
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
s32 hasShadow
drawn with a shadow
Definition field_map.h:343
s16 index
Definition gfx.h:302
s16 timer
Definition gfx.h:303
A character of the field (FieldState.actors, a list of pointers up to NULL), which FIELDSTG_updateFie...
Definition field_map.h:194
An event of the table FieldState.events, up to the first id -1, which FIELDSTG_startEvent starts.
Definition field_map.h:141
void(* setFile)(s32 index, s32 file)
FIELDSTG_setMapFile.
Definition field_map.h:100
void(* setFirstMap)(s32 index)
FIELDSTG_setFirstMap: the map the player starts on (GAME.mapIndex), when the mode is new.
Definition field_map.h:104
s32 sheetEntry
the stage's sprite sheet, loaded before the field starts, or 0
Definition field_map.h:445
FieldEvent * events
up to the first id -1
Definition field_map.h:451
s32 soundBank
SOUND.loadBank's, or 0.
Definition field_map.h:459
StageTile * objects
the map objects, up to the first margin 0
Definition field_map.h:446
s32 imageFile
or an image archive file, or 0
Definition field_map.h:449
Vec2 start
where the player starts
Definition field_map.h:456
ActorImage * actors
then the actors', from actors[2]
Definition field_map.h:454
s32 mapFile
the file of the map's tiles (FIELDSTG_createMapStreamer)
Definition field_map.h:444
s32 startDir
and its direction
Definition field_map.h:457
s32 textFile
the stage's text file, for the talks
Definition field_map.h:461
union FieldState::@12 images
s32 music
SOUND.playSound's, or 0.
Definition field_map.h:460
s32(* getFrameTime)(void)
Definition gfx.h:32
GfxFuncs funcs
Definition gfx.h:77
short(* playSound)(s32 id)
returns the voice of a key-on
Definition sound.h:187
StageTile * tile
Definition stage.h:409
s16 active
Definition stage.h:407
s16 speed
Definition stage.h:408
A frame of a StageRiser's animation; the last (frame 0xFF) sets move.
Definition stage.h:389
A map object animated and moved by its animation.
Definition stage.h:396
s16 tileAnim
Definition stage.h:400
s32 move
added to the map object's y
Definition stage.h:398
s32 y
8.8
Definition stage.h:397
StageTile * tile
Definition stage.h:402
s16 active
Definition stage.h:399
AnimState anim
Definition stage.h:401
Map objects that events start moving.
Definition stage.h:413
StageRiser risers[11]
Definition stage.h:415
s16 push
Definition stage.h:419
StageLift lifts[3]
Definition stage.h:416
s32 state
Definition stage.h:414
s32 timer
Definition stage.h:417
s16 pushing
moves the player
Definition stage.h:418
void(* nextState)(struct StageRisers *task)
Definition stage.h:414
The task a stage starts (startStage), updated by its updateStage.
Definition stage.h:26
void(* nextState)(struct StageTask *task)
Definition stage.h:27
s32 state
Definition stage.h:27
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
Definition gfx.h:352
s32 y
Definition gfx.h:354
void * createTaskWithId(void(*update)(), s32 size, s32 childrenSize, s32 id)
Allocates a zeroed task of size bytes (header included) with room for childrenSize / 4 child tasks.
Definition task.c:80
FieldActorEntry actor0
Definition wstag680.c:344
void(* stageFuncs[])(void)
The stage's functions (common/start_stage.inc.c calls the first): a StageFuncs in the stages with a t...
Definition wstag680.c:369
StageRiserFrame updateRisersFrames_6[]
Definition wstag680.c:314
StageRiserFrame updateRisersFrames_0[]
Definition wstag680.c:302
FieldActorEntry * stageActors[]
Definition wstag680.c:345
void updateRisers(StageRisers *task)
Animates and moves the map objects of the stage's table (lifts for animations 8-10) and pushes the pl...
Definition wstag680.c:38
StageRiserFrame updateRisersFrames_1[]
Definition wstag680.c:308
ActorImage stageImages[]
Definition wstag680.c:334
void setupStage(void)
Sets the stage up: its map, actors and events, playing the ambience ENV_0019.
Definition wstag680.c:204
StageTile stageObjects[]
The tables and color setupStage gives FIELDSTG_state (FieldState)
Definition wstag680.c:349
void handleCommand814(void *arg, s32 event)
Starts the map objects an event moves (the handler of the events the task gets)
Definition wstag680.c:113
s16 script412[]
Definition wstag680.c:221
s32 stepRiser(StageRiser *obj, StageRiserFrame *frames, s32 depth)
Steps a mover's looping animation, its last frame setting how far it moves.
Definition wstag680.c:12
#define STAGE_FILE
Definition wstag680.c:201
void * createCommand814(s32 arg)
Command 814 of the event scripts: the lifts that rise and carry the player off in event 412 (updateRi...
Definition wstag680.c:170
#define STAGE_TEXT
Definition wstag680.c:199
StageRiserFrame * updateRisersFrames[]
Defined below, after the code that uses them.
Definition wstag680.c:321
FieldEvent stageEvents[]
Definition wstag680.c:372
u16 actor0Conditions[]
Definition wstag680.c:343