Digimon World 3 decomp
The European version, SLES_039.36
Loading...
Searching...
No Matches
commands.c
Go to the documentation of this file.
1/* The field commands (FIELD_COMMAND_*) that the stages' event scripts send
2 through script command 813: the partners halted, the player icon's
3 animations, map objects shown or hidden, the camera's shake and sounds.
4 The first object of FIELDSTG.PRO (see data/fieldstg.c). */
5
6#include "field/field_mode.h"
7
8/* The task of script command 813: on substate 1 it stops the partners
9 following */
11 switch (task->state) {
12 case TASK_INIT:
13 case TASK_RUN:
14 default:
15 if (task->substate == 1) {
17 task->setSubstate(task, 0);
18 }
19 break;
20 case TASK_DONE:
21 case TASK_KILL:
22 break;
23 }
24}
25
26/* The commands that hide or show a group of the map objects (by their anim) */
27static inline void showObjectGroups(s32 command) {
28 StageTile *object;
29
30 switch (command) {
32 for (object = FIELDSTG_state.objects; object->margin != 0; object++) {
33 if (object->anim == command - FIELD_COMMAND_HIDE_OBJECTS(0) + FIELD_OBJECT_GROUP_ANIM) {
34 object->visible = 0;
35 }
36 }
37 break;
39 for (object = FIELDSTG_state.objects; object->margin != 0; object++) {
40 if (object->anim == command - FIELD_COMMAND_SHOW_OBJECTS(0) + FIELD_OBJECT_GROUP_ANIM) {
41 object->visible = 1;
42 }
43 }
44 break;
45 }
46}
47
48/* The commands that play a sound */
49static inline void playCommandSound(s32 command) {
50 switch (command) {
53 break;
56 break;
59 break;
62 break;
65 break;
68 break;
71 break;
74 break;
77 break;
80 break;
83 break;
86 break;
89 break;
92 break;
95 break;
98 break;
101 break;
104 break;
107 break;
110 break;
113 break;
116 break;
117 }
118}
119
120/* The commands that play a sound that goes on until a stop command keys it
121 off (FIELDSTG_heldVoice) */
138
139/* The commands that stop that sound */
156
157/*
158 * Runs a field command (FIELD_COMMAND_*) of an event script: halts the
159 * partners through the command task, sets the player icon's substate, hides
160 * or shows a group of map objects, shakes the camera, searches the event
161 * spot, or plays a sound; four sounds are held, to be keyed off by a later
162 * command.
163 */
165 Task *icon;
166 s32 n;
167
168 if (task == NULL) {
169 return;
170 }
171 n = 0;
172 if (command == FIELD_COMMAND_HALT_PARTNERS) {
173 task->setSubstate(task, 1);
174 }
175 switch (command) {
177 n++;
178 /* fallthrough */
180 n++;
181 /* fallthrough */
183 n++;
184 icon = TASK_REGISTRY.funcs.find(FIELD_TASK_ICON, -1, -1);
185 icon->setSubstate(icon, n);
186 break;
187 }
188 showObjectGroups(command);
189 switch (command) {
192 break;
195 break;
196 }
197 if (command == FIELD_COMMAND_SEARCH_EVENT_SPOT) {
199 }
200 playCommandSound(command);
201 playHeldSound(command);
202 stopHeldSound(command);
203}
204
205/* Creates the task of script command 813 (the create of
206 FIELDSTG_scriptCommands) */
void FIELDSTG_shakeCamera(s32 shaking)
Starts or stops the camera's shake.
Definition camera.c:175
void FIELDSTG_updateCommandTask(Task *task)
The task of script command 813: on substate 1 it stops the partners following.
Definition commands.c:10
static void playHeldSound(s32 command)
The commands that play a sound that goes on until a stop command keys it off (FIELDSTG_heldVoice)
Definition commands.c:122
static void stopHeldSound(s32 command)
The commands that stop that sound.
Definition commands.c:140
void FIELDSTG_handleFieldCommand(Task *task, s32 command)
Runs a field command (FIELD_COMMAND_*) of an event script: halts the partners through the command tas...
Definition commands.c:164
void FIELDSTG_startCommandTask(void)
Creates the task of script command 813 (the create of FIELDSTG_scriptCommands)
Definition commands.c:207
static void showObjectGroups(s32 command)
The commands that hide or show a group of the map objects (by their anim)
Definition commands.c:27
static void playCommandSound(s32 command)
The commands that play a sound.
Definition commands.c:49
#define NULL
Definition common.h:17
signed int s32
Definition common.h:11
#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
void FIELDSTG_haltPartners(void)
Makes the partners stop following: each walks out the rest of its trail (FIELDSTG_drainTrail)
Definition actor.c:7
#define FIELD_COMMAND_PLAY_WEAR_OFF
Definition field_map.h:52
#define FIELD_COMMAND_PLAY_BM_ERASE
Definition field_map.h:58
#define FIELD_COMMAND_PLAY_SE000002
Definition field_map.h:54
#define FIELD_COMMAND_PLAY_DEMO_BGM
Definition field_map.h:53
#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 FIELD_COMMAND_PLAY_COMCD201
Definition field_map.h:75
#define FIELD_COMMAND_PLAY_SAVEDEMO
Definition field_map.h:65
#define FIELD_COMMAND_STOP_COMCD115
Definition field_map.h:80
#define FIELD_OBJECT_GROUP_ANIM
the StageTile.anim of group 0; group n has 100 + n
Definition field_map.h:48
#define FIELD_COMMAND_PLAY_PIYOPIYO
Definition field_map.h:73
#define FIELD_COMMAND_STOP_CAMERA_SHAKE
Definition field_map.h:63
#define FIELD_COMMAND_SHAKE_CAMERA
Definition field_map.h:62
#define FIELD_COMMAND_ICON3
its substate 3, with ITEM_GET
Definition field_map.h:44
#define FIELD_COMMAND_PLAY_MASK_SET
Definition field_map.h:57
#define FIELD_COMMAND_STOP_GAYALOOP
Definition field_map.h:51
#define FIELD_COMMAND_STOP_BEAM_HIT
Definition field_map.h:81
#define FIELD_COMMAND_PLAY_SN_ENTRY
Definition field_map.h:68
#define FIELD_COMMAND_SEARCH_EVENT_SPOT
FIELDSTG_searchEventSpot.
Definition field_map.h:66
#define FIELD_COMMAND_PLAY_INFO_SIG
Definition field_map.h:49
#define FIELD_COMMAND_SHOW_OBJECTS(n)
shows them
Definition field_map.h:46
#define FIELD_COMMAND_PLAY_BEAM_HIT
Definition field_map.h:77
#define FIELD_COMMAND_PLAY_SWITCH02
Definition field_map.h:56
#define FIELD_OBJECT_GROUPS
Definition field_map.h:47
#define FIELD_COMMAND_PLAY_PLAYER11
Definition field_map.h:60
#define FIELD_COMMAND_ICON1
the player icon's substate 1, with ITEM_GET
Definition field_map.h:42
#define FIELD_COMMAND_ICON2
its substate 2
Definition field_map.h:43
#define FIELD_TASK_ICON
the icon over the player's head
Definition field_map.h:31
#define FIELD_COMMAND_PLAY_SWITCH03
Definition field_map.h:67
#define FIELD_COMMAND_PLAY_TRAP_OFF
Definition field_map.h:64
#define FIELD_COMMAND_PLAY_COMCD111
Definition field_map.h:76
#define FIELD_COMMAND_PLAY_SWITCH01
Definition field_map.h:78
#define FIELD_COMMAND_PLAY_BULB_003
Definition field_map.h:71
#define FIELD_COMMAND_PLAY_BEAM_SHT
Definition field_map.h:55
#define FIELD_COMMAND_PLAY_GONDRA_S
Definition field_map.h:72
#define FIELD_COMMAND_STOP_PLAYER11
Definition field_map.h:61
#define FIELD_COMMAND_PLAY_GAYALOOP
Definition field_map.h:50
#define FIELD_COMMAND_PLAY_COMCD103
Definition field_map.h:74
#define FIELD_COMMAND_PLAY_TELEPORT
Definition field_map.h:70
#define FIELD_COMMAND_PLAY_COMCD115
Definition field_map.h:79
#define FIELD_COMMAND_PLAY_LD_ERASE
Definition field_map.h:59
#define FIELD_TASK_COMMANDS
script command 813 (FIELDSTG_startCommandTask): the field commands
Definition field_map.h:33
#define FIELD_COMMAND_PLAY_SN_ERASE
Definition field_map.h:69
#define FIELD_COMMAND_HIDE_OBJECTS(n)
hides the map objects of group n
Definition field_map.h:45
FIELDSTG.PRO: the field mode, where the player walks around the map.
#define SOUND_LD_ERASE
Definition field_mode.h:53
#define SOUND_BEAM_HIT
held
Definition field_mode.h:72
#define SOUND_DEMO_BGM
Definition field_mode.h:54
#define SOUND_TRAP_OFF
Definition field_mode.h:50
#define SOUND_SN_ERASE
Definition field_mode.h:69
#define SOUND_COMCD201
Definition field_mode.h:56
#define SOUND_BULB_003
Definition field_mode.h:49
#define SOUND_BEAM_SHT
Definition field_mode.h:66
#define SOUND_COMCD111
Definition field_mode.h:55
#define SOUND_BM_ERASE
Definition field_mode.h:52
#define SOUND_WEAR_OFF
Definition field_mode.h:67
#define SOUND_SN_ENTRY
Definition field_mode.h:68
#define SOUND_MASK_SET
Definition field_mode.h:65
#define SOUND_GAYALOOP
held
Definition field_mode.h:74
#define SOUND_SAVEDEMO
Definition field_mode.h:47
#define SOUND_PIYOPIYO
Definition field_mode.h:46
#define SOUND_INFO_SIG
Definition field_mode.h:51
s16 FIELDSTG_heldVoice
the voice of FIELDSTG_handleFieldCommand's held sound
Definition fieldstg.c:3754
FieldState FIELDSTG_state
Definition fieldstg.c:2641
void FIELDSTG_searchEventSpot(void)
Searches the hidden spots off the map (x 1000 and up), for an event.
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_SWITCH03
Definition sound.h:52
#define SOUND_COMCD115
held until SOUND.keyOff
Definition sound.h:54
#define SOUND_COMCD103
Definition sound.h:53
#define SOUND_TELEPORT
TELEPORT.
Definition sound.h:47
#define SOUND_GONDRA_S
Definition sound.h:58
#define SOUND_SE000002
Definition sound.h:59
#define SOUND_SWITCH02
Definition sound.h:51
#define SOUND_PLAYER11
held until SOUND.keyOff
Definition sound.h:56
StageTile * objects
the map objects, up to the first margin 0
Definition field_map.h:446
short(* playSound)(s32 id)
returns the voice of a key-on
Definition sound.h:187
void(* keyOff)(s32 id, s16 voice)
Definition sound.h:189
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
Any task, seen through its header.
Definition task.h:62
void(* setSubstate)(struct Task *task, s32 substate)
Definition task.h:63
s32 substate
Definition task.h:63
s32 state
Definition task.h:63
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