Digimon World 3 decomp
The European version, SLES_039.36
Loading...
Searching...
No Matches
wstag261.c
Go to the documentation of this file.
1/*
2 * WSTAG261: Cargo Tower, Amaterasu City. On the Amaterasu server; its Asuka
3 * server twin is WSTAG260.
4 */
5
6#include "common.h"
7#include "field/stage.h"
8/* Defined below, after the code that uses them */
9extern s16 tileLiftShake[];
10
12
13/* Runs a script command of the lift's: moves it up or down */
14void handleCommand827(Lift *task, s32 id) {
15 if (task != NULL) {
16 switch (id) {
17 case LIFT_UP:
18 task->setState(task, TASK_DONE);
19 task->raised = 0;
20 break;
21 case LIFT_DOWN:
22 task->setState(task, TASK_DONE);
23 task->raised = 1;
24 break;
25 }
26 }
27}
28
29/* Creates the lift (updateTileLift), raised when flag 0x1C3D is set */
31 Lift *task = createTaskWithId(updateTileLift, sizeof(Lift), 0, id);
32
34 task->raised = 1;
35 } else {
36 task->raised = 0;
37 }
38 return task;
39}
40
41/* The stage task: creates the object of map object 0x33B */
42void updateStage(StageTask *task, void **children) {
43 switch (task->state) {
44 case TASK_INIT:
45 default:
46 task->nextState(task);
47 children[0] = createCommand827(0x33B);
48 break;
49 case TASK_RUN:
50 case TASK_DONE:
51 case TASK_KILL:
52 break;
53 }
54}
55
56#define STAGE_CHILDREN_SIZE 4
58
59/* the color the setup copies to FIELDSTG_state.spriteColor */
60const CVECTOR stageColor = { 0x80, 0x80, 0x80, 0 };
61
62#if VERSION_US || VERSION_JP
63#define STAGE_TEXT TEXT_FILE(TEXT_TALKS_03)
64#define EVENT_TEXT_FILE (TEXT_EVENTS_200 - 1)
65#define STAGE_FILE 0x517
66#elif VERSION_EU
67#define STAGE_TEXT TEXT_FILE(TEXT_TALKS_03)
68#define EVENT_TEXT_FILE (TEXT_EVENTS_200 - 1)
69#define STAGE_FILE 0x527
70#endif
71/* Sets the stage up: its map, actors and events, playing the ambience ENV_0204 */
92
94 SCRIPT_WALK(2, 0xBF, 0x190, 3),
95 SCRIPT_PLACE(0x3F, 0xB0, 0x188),
96 SCRIPT_POSE(0x3F, 1, 0),
100 SCRIPT_WAIT(0x3C),
101 SCRIPT_POSE(2, 1, 6),
102 SCRIPT_WAIT(0x1E),
103 SCRIPT_POSE(2, 1, 5),
104 SCRIPT_WAIT(0x1E),
105 SCRIPT_POSE(2, 1, 6),
106 SCRIPT_WAIT(0x1E),
107 SCRIPT_POSE(2, 1, 7),
108 SCRIPT_WAIT(0x1E),
109 SCRIPT_POSE(2, 1, 6),
110 SCRIPT_WAIT(0x1E),
111 SCRIPT_POSE(2, 1, 7),
112 SCRIPT_WAIT(0x1E),
113 SCRIPT_POSE(2, 1, 7),
114 SCRIPT_WAIT(0x1E),
115 SCRIPT_POSE(2, 1, 5),
116 SCRIPT_WAIT(0x1E),
117 SCRIPT_WALK(2, 0xEC, 0x178, 5),
119 SCRIPT_WALK(2, 0x108, 0x184, 7),
121 SCRIPT_TALK(0, 1, 2, 0),
122 SCRIPT_POSE(2, 1, 3),
124 SCRIPT_PLACE(0x3F, 0xB0, 0x109),
125 SCRIPT_POSE(0x3F, 1, 0),
126 SCRIPT_COMMAND(0x33B, LIFT_UP, 2),
127 SCRIPT_WAIT(0x12C),
128 SCRIPT_WAIT(0x1E),
130};
132 SCRIPT_WALK(2, 0xBF, 0x111, 3),
133 SCRIPT_PLACE(0x3F, 0xB0, 0x109),
134 SCRIPT_POSE(0x3F, 1, 0),
138 SCRIPT_WAIT(0x3C),
139 SCRIPT_POSE(2, 1, 6),
140 SCRIPT_WAIT(0x1E),
141 SCRIPT_POSE(2, 1, 5),
142 SCRIPT_WAIT(0x1E),
143 SCRIPT_POSE(2, 1, 6),
144 SCRIPT_WAIT(0x1E),
145 SCRIPT_POSE(2, 1, 7),
146 SCRIPT_WAIT(0x1E),
147 SCRIPT_POSE(2, 1, 6),
148 SCRIPT_WAIT(0x1E),
149 SCRIPT_POSE(2, 1, 7),
150 SCRIPT_WAIT(0x1E),
151 SCRIPT_POSE(2, 1, 7),
152 SCRIPT_WAIT(0x1E),
153 SCRIPT_POSE(2, 1, 5),
154 SCRIPT_WAIT(0x1E),
155 SCRIPT_WALK(2, 0xEF, 0xF9, 5),
157 SCRIPT_WALK(2, 0x108, 0x105, 7),
159 SCRIPT_TALK(0, 1, 2, 0),
160 SCRIPT_POSE(2, 1, 3),
162 SCRIPT_PLACE(0x3F, 0xB0, 0x188),
163 SCRIPT_POSE(0x3F, 1, 0),
164 SCRIPT_COMMAND(0x33B, LIFT_DOWN, 2),
165 SCRIPT_WAIT(0x12C),
166 SCRIPT_WAIT(0x1E),
168};
170 1, 2, 1, 0, -1, -2, -1, 0,
171 0x3E8, 0,
172};
174 { 0x200, 0x100, 0x21C, 0x1A6, 0x70, 0xA6, 0x230, 0x1FE },
175 { 0x200, 0x100, 0x200, 0x100, 0, 0, 0x220, 0x1FE },
176 { 0x200, 0x100, 0x216, 0x138, 0x58, 0x38, 0x200, 0x1FD },
177 { 0x200, 0x100, 0x208, 0x1BC, 0x20, 0xBC, 0x210, 0x1FD },
178 { 0x200, 0x100, 0x210, 0x1BC, 0x40, 0xBC, 0x220, 0x1FD },
179 { 0x200, 0x100, 0x200, 0x1BC, 0, 0xBC, 0x230, 0x1FD },
180 { 0, 0, 0, 0, 0, 0, 0, 0 },
181};
205 &actor0,
206 &actor1,
207 NULL,
208};
210 { 0, 1, 0x44, 2, 0x3A, 2, 0, 1, 4, 0, 312, 282, 0, 0 },
211 { 1, 2, 0x40, 2, 0x32, 1, 0x32, 0x39, 4, 0, 135, 358, 0, 0 },
212 { 1, 0, 0x40, 6, 0x3C, 0, 0, 0, 0, 0, 328, 194, 0, 0 },
213 { 1, 0, 0x40, 6, 1, 0, 0, 0, 0, 0, 192, 417, 0, 0 },
214 { 1, 3, 0xCD, 6, 0, 0, 0, 0, 0, 0, 160, 338, 0, 0 },
215 { 1, 0, 0x40, 0xA, 0x3E, 0, 0, 0, 0, 0, 328, 272, 0, 0 },
216 { 1, 0, 0x48, 0xA, 0x14, 0, 0, 0, 0, 0, 128, 202, 0, 0 },
217 { 1, 0, 0x49, 0xA, 0x15, 0, 0, 0, 0, 0, 200, 183, 0, 0 },
218 { 1, 0, 0x40, 4, 0x3D, 0, 0, 0, 0, 0, 336, 166, 193, 0 },
219 { 1, 0, 0x40, 8, 0x3F, 0, 0, 0, 0, 0, 336, 244, 277, 0 },
220 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
221};
223 { { { CODES_END, 0 }, { CODES_END, 0 } }, SLOT_EXIT, 0x271, 0x368, 0xF4, 1, 0, 0, 0 },
224 { { { CODES_END, 0 }, { CODES_END, 0 } }, SLOT_EXIT, 0x281, 0x2FE, 0xA5, 1, 0, 0, 0 },
225 { { { CODES_END, 0 }, { CODES_END, 0 } }, SLOT_MAP, 1, 0, 0, 0, 0, 0, 0 },
226 { { { CODES_END, 0 }, { CODES_END, 0 } }, SLOT_DEPTH, 8, 0, 0, 0, 0, 0, 0 },
227 { { { CODES_END, 0 }, { CODES_END, 0 } }, 0, 0, 0, 0, 0, 0, 0, 0 },
228};
229void (*stageFuncs[])(void) = {
231};
233 { 1321, script1321, EVENT_TEXT(0x2E), NULL, NULL },
234 { 1326, script1326, EVENT_TEXT(0x2F), NULL, NULL },
235 { -1, NULL, 0, NULL, NULL },
236};
#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
GameFlags FLAGS_00
The flag bitset FLAGS_00 and the event functions.
Definition events.c:701
#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
The stage overlays (AAA/PRO/WSTAG###.PRO), loaded at 0x800A4CA4 on top of FIELDSTG.
#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 SCRIPT_WAIT_WALK(id)
until the character gets to its goal
Definition field_map.h:168
#define FIELD_COMMAND_HALT_PARTNERS
The field commands, which an event script hands FIELD_TASK_COMMANDS as the first argument of a pose c...
Definition field_map.h:41
#define SLOT_DEPTH
the player's depth, arg
Definition field_map.h:259
#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 SLOT_MAP
the map the player is on, arg (FieldMap.setMap)
Definition field_map.h:260
#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_COMMAND_PLAY_SWITCH02
Definition field_map.h:56
#define SCRIPT_WALK(id, x, y, dir)
Actor.setGoal: walks to (x, y), then faces dir.
Definition field_map.h:162
#define FIELD_MAP_FLOOR1
Definition field_map.h:86
#define LIFT_DOWN
and back down to the objects' place on the map
Definition field_map.h:236
#define LIFT_UP
The lift: the map objects 3 (always shown) and 2 (shown while it moves), which move 0x7F pixels up or...
Definition field_map.h:235
#define SCRIPT_WAIT_BOX
until box 0 closes
Definition field_map.h:167
#define SLOT_EXIT
The kinds of StageSlot (type).
Definition field_map.h:255
#define SCRIPT_POSE(id, set, dir)
Actor.setPose: its animation set, facing dir.
Definition field_map.h:158
#define FIELD_MAP_TRIGGERS
a cell's value: a direction (3 bits) and a StageSlot (5)
Definition field_map.h:88
#define SCRIPT_WAIT(frames)
Definition field_map.h:166
#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 START_EVENT(index)
action: FIELDSTG_startListedEvent
Definition game_state.h:81
#define CODES_END
Definition game_state.h:83
#define MUSIC_CARGO_TOWER
ENV_0204: the Cargo Tower.
Definition sound.h:143
#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,...
#define FLAG_LIFT_RAISED
lift.c / wstag261 Cargo Tower: "There's a switch here! Let's push it." sets it, "let's go downstairs"...
Definition story.h:1245
Where an actor's frames go in VRAM: one of the records after the FieldImage (Actor....
Definition field_map.h:114
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
StageSlot * slots
up to the first type 0
Definition field_map.h:447
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
CVECTOR spriteColor
the field's sprites' color, unless cd is 0
Definition field_map.h:458
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
What a character says (FIELDSTG_runActorAction): the first whose conditions hold, or the last,...
Definition field_map.h:176
s32(* checkCondition)(u16 code, u16 value)
Definition game_state.h:53
void(* setState)(struct Lift *task, s32 state)
Definition field_map.h:239
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
What the player can trigger on a map (FIELDSTG_updateTriggers): a record of the table at FieldState....
Definition field_map.h:276
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
Definition gfx.h:352
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
void updateTileLift(Lift *task)
The lift: moves the map objects of animations 3 and 2 (shown only while it moves) and the player 0x7F...
u16 actor1Conditions[]
Definition wstag261.c:201
u16 actor0Talk0Actions[]
Definition wstag261.c:183
FieldActorEntry actor0
Definition wstag261.c:202
void(* stageFuncs[])(void)
The stage's functions (common/start_stage.inc.c calls the first): a StageFuncs in the stages with a t...
Definition wstag261.c:229
u16 actor0Talk0Conditions[]
Definition wstag261.c:182
u16 actor0Talk1Conditions[]
Definition wstag261.c:184
u16 actor1Talk1Conditions[]
Definition wstag261.c:188
const CVECTOR stageColor
the color the setup copies to FIELDSTG_state.spriteColor
Definition wstag261.c:60
FieldActorEntry * stageActors[]
Definition wstag261.c:204
u16 actor0Talk1Actions[]
Definition wstag261.c:185
void handleCommand827(Lift *task, s32 id)
Runs a script command of the lift's: moves it up or down.
Definition wstag261.c:14
FieldTalk actor1Talks[]
Definition wstag261.c:195
u16 actor1Talk0Conditions[]
Definition wstag261.c:186
FieldTalk actor0Talks[]
Definition wstag261.c:190
ActorImage stageImages[]
Definition wstag261.c:173
u16 actor1Talk1Actions[]
Definition wstag261.c:189
void setupStage(void)
Sets the stage up: its map, actors and events, playing the ambience ENV_0204.
Definition wstag261.c:72
s16 script1326[]
Definition wstag261.c:131
StageTile stageObjects[]
The tables and color setupStage gives FIELDSTG_state (FieldState)
Definition wstag261.c:209
Lift * createCommand827(s32 id)
Creates the lift (updateTileLift), raised when flag 0x1C3D is set.
Definition wstag261.c:30
StageSlot stageSlots[]
Definition wstag261.c:222
u16 actor1Talk0Actions[]
Definition wstag261.c:187
s16 script1321[]
Definition wstag261.c:93
FieldActorEntry actor1
Definition wstag261.c:203
#define STAGE_FILE
Definition wstag261.c:69
s16 tileLiftShake[]
Defined below, after the code that uses them.
Definition wstag261.c:169
#define STAGE_TEXT
Definition wstag261.c:67
FieldEvent stageEvents[]
Definition wstag261.c:232
u16 actor0Conditions[]
Definition wstag261.c:200