Digimon World 3 decomp
The European version, SLES_039.36
Loading...
Searching...
No Matches
entrance.c
Go to the documentation of this file.
1/* FIGHTSTG's entrances: a fighter's model coming into the battle. */
2
4
5/* Loads what fighter 0x1D2 (its stage file) or 0x1D3 (its music, fading the
6 current one out) brings, then ends the loading state. */
7static inline void loadEntranceExtras(Entrance *task, s32 is1D2) {
8 switch (task->step) {
9 case 0:
10 default:
11 if (is1D2) {
13 } else {
15 SOUND.loadBank(0x26);
16 }
17 task->nextStep(task);
18 break;
19 case 1:
20 if (is1D2) {
22 task->nextState(task);
23 }
24 } else if (SOUND.isLoading() == 0) {
25 task->nextState(task);
26 }
27 break;
28 }
29}
30
31/* Gives the loaded model the fighter's id and shows it in its entrance motion,
32 with the camera on it. */
33static inline void showEnteringModel(Entrance *task, Models *models, BattleCamera *camera) {
34 ModelControl *control;
35
36 models->setId(models, task->key2 + 1, task->key2);
37 models->face(models, task->key2);
38 control = models->get(models, task->key2);
40 control->layers[0].enabled = 1;
41 control->layers[0].wireframe = 0;
42 control->motion = 13;
43 camera->set(camera, camera->getFighterView(camera, task->key2, task->key2 != 0 ? 2 : 10));
44}
45
46/* Fighter 0x1D2 changes the fight stage and 0x1D3 the music. */
47static inline void applyEntranceExtras(FightStage *stage, s32 is1D2, s32 is1D3) {
48 if (is1D2) {
49 BATTLE_SETUP.stage = 0x16;
50 stage->setStage(stage, 0x16, 1, 1);
51 }
52 if (is1D3) {
55 }
56}
57
58/* A fighter's entrance: loads its model and adds it, then shows it behind a fade
59 (FIGHTSTG_startWhiteFlash) and turns the camera to it; fighter 0x1D2 changes the fight
60 stage and 0x1D3 the music. */
62 Models *models = task->models;
63 BattleCamera *camera = task->camera;
64 FightStage *stage = task->stage;
65 s32 is1D2 = task->key1 == 0x1D2;
66 s32 is1D3 = task->key1 == 0x1D3;
67 ModelControl *entering;
68
69 switch (task->state) {
70 case 0:
71 default:
72 switch (task->substate) {
73 case 0:
74 default:
76 task->models = models;
79 task->file = FIGHTSTG_fighterCache.funcs.getInfo(task->key1)->model >> 16;
80 FILE_CACHE.request(task->file);
81 task->nextSubstate(task);
82 /* fallthrough */
83 case 1:
84 if (FILE_CACHE.isLoading(task->file) != 0) {
85 break;
86 }
87 models->add(models, task->key2 + 1, task->key1, 0);
88 if (!is1D2 && !is1D3) {
89 task->nextState(task);
90 break;
91 }
92 task->nextSubstate(task);
93 /* fallthrough */
94 case 2:
95 loadEntranceExtras(task, is1D2);
96 break;
97 }
98 break;
99 case 1:
100 switch (task->substate) {
101 case 0:
102 camera->fade(camera, NULL, camera->getFighterView(camera, task->key2, task->key2 != 0 ? 2 : 10), 60);
103 task->nextSubstate(task);
104 /* fallthrough */
105 case 1:
106 task->counter += GFX.funcs.getFrameTime();
107 switch (task->step) {
108 case 0:
109 default:
110 if (task->counter < 30) {
111 break;
112 }
113 models->get(models, task->key2 == 0 ? 0x10 : 0)->layers[0].enabled = 0;
114 task->step++;
115 /* fallthrough */
116 case 1:
117 if (task->counter >= 60) {
118 task->nextSubstate(task);
119 }
120 break;
121 }
122 break;
123 case 2:
125 *children = FIGHTSTG_startWhiteFlash(60);
126 task->nextSubstate(task);
127 /* fallthrough */
128 case 3:
129 if ((*children)->substate == 0) {
130 break;
131 }
132 task->nextSubstate(task);
133 task->done = 1;
134 showEnteringModel(task, models, camera);
135 applyEntranceExtras(stage, is1D2, is1D3);
136 break;
137 case 4:
138 FIGHTSTG_endWhiteFlash(*children, 60);
139 task->nextSubstate(task);
140 /* fallthrough */
141 case 5:
142 if (*children != NULL) {
143 break;
144 }
145 task->nextSubstate(task);
146 /* fallthrough */
147 case 6:
148 task->step += GFX.funcs.getFrameTime();
149 if (is1D2 ? task->step < 10 : task->step < 120) {
150 break;
151 }
152 task->nextSubstate(task);
153 /* fallthrough */
154 case 7:
155 camera->fade(camera, NULL, camera->getEnemyView(camera), task->key2 != 0 ? 1 : 60);
156 entering = models->get(models, task->key2);
157 if (task->weak != 0) {
158 entering->motion = 2;
159 } else {
160 entering->motion = 1;
161 }
162 models->get(models, task->key2 == 0 ? 0x10 : 0)->layers[0].enabled = 1;
163 task->setState(task, 3);
164 break;
165 }
166 break;
167 case 2:
168 case 3:
169 break;
170 }
171}
172
173/* Starts a fighter's entrance: Digimon id on the player's side (side 0) or
174 the enemy's */
177
178 task->key1 = id;
179 if (side) {
180 task->key2 = 0x10;
181 } else {
182 task->key2 = 0;
183 }
184 task->weak = weak;
185 return task;
186}
FighterCache FIGHTSTG_fighterCache
the fighters' data, loaded one at a time
Definition battle.c:21
#define BATTLE_TASK_CAMERA
Definition types.h:21
#define BATTLE_TASK_MODELS
the fighters'
Definition types.h:23
#define BATTLE_TASK_STAGE
Definition types.h:24
#define BATTLE_LAYER_MODELS
Definition types.h:30
FIGHTSTG.PRO: the battle.
#define NULL
Definition common.h:17
signed int s32
Definition common.h:11
GfxState GFX
GFX: the graphics state and its methods.
Definition display.c:209
#define FILE_ENTRANCE_1D2
What fighter 0x1D2's entrance (FIGHTSTG_updateEntrance) loads.
Definition effect.h:20
static void loadEntranceExtras(Entrance *task, s32 is1D2)
Loads what fighter 0x1D2 (its stage file) or 0x1D3 (its music, fading the current one out) brings,...
Definition entrance.c:7
static void showEnteringModel(Entrance *task, Models *models, BattleCamera *camera)
Gives the loaded model the fighter's id and shows it in its entrance motion, with the camera on it.
Definition entrance.c:33
Entrance * FIGHTSTG_startEntrance(s32 id, s32 side, s32 weak)
Starts a fighter's entrance: Digimon id on the player's side (side 0) or the enemy's.
Definition entrance.c:175
static void applyEntranceExtras(FightStage *stage, s32 is1D2, s32 is1D3)
Fighter 0x1D2 changes the fight stage and 0x1D3 the music.
Definition entrance.c:47
void FIGHTSTG_updateEntrance(Entrance *task, WhiteFlash **children)
A fighter's entrance: loads its model and adds it, then shows it behind a fade (FIGHTSTG_startWhiteFl...
Definition entrance.c:61
FileCache FILE_CACHE
The file cache.
Definition file_cache.c:7
BattleSetup BATTLE_SETUP
Definition items.c:886
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_LAST_BOSS_2
LASTB_02: Lord Megadeath's second form (WSTAG820, fighter 0x1D3's entrance)
Definition sound.h:112
#define SOUND_PLAYER11
held until SOUND.keyOff
Definition sound.h:56
#define MUSIC_LAST_BOSS
LASTBOSS: Lord Megadeath's battle (WSTAG820)
Definition sound.h:110
The battle camera (FIGHTSTG_createBattleCamera), registered as BATTLE_TASK_CAMERA on a layer: set put...
Definition camera.h:66
CameraView *(* getFighterView)(struct BattleCamera *task, s32 id, s32 camera)
Definition camera.h:77
CameraView *(* getEnemyView)(struct BattleCamera *task)
Definition camera.h:76
void(* set)(struct BattleCamera *task, CameraView *view)
Definition camera.h:74
void(* fade)(struct BattleCamera *task, CameraView *from, CameraView *to, s32 time)
from: NULL for the current
Definition camera.h:75
s32 music
the battle's music
Definition game_state.h:385
s32 stage
the battle's fight stage
Definition game_state.h:383
A fighter's entrance (FIGHTSTG_startEntrance): key1 its Digimon, key2 its side.
Definition effect.h:131
s32 step
Definition effect.h:132
void(* nextSubstate)(struct Entrance *task)
Definition effect.h:132
s32 state
Definition effect.h:132
s32 weak
it comes in with motion 2 (WFIGHTMN_setIdleMotion's weak one)
Definition effect.h:138
void(* setState)(struct Entrance *task, s32 state)
Definition effect.h:132
s32 key1
Definition effect.h:132
struct FightStage * stage
Definition effect.h:136
s32 done
Definition effect.h:133
struct BattleCamera * camera
Definition effect.h:135
struct Models * models
Definition effect.h:134
void(* nextStep)(struct Entrance *task)
Definition effect.h:132
s32 key2
Definition effect.h:132
s32 counter
Definition effect.h:132
s32 substate
Definition effect.h:132
s32 file
its model's
Definition effect.h:137
void(* nextState)(struct Entrance *task)
Definition effect.h:132
The fight stage (FIGHTSTG_createStage), registered as BATTLE_TASK_STAGE: its model,...
Definition stage.h:38
void(* setStage)(struct FightStage *task, s32 stage, s32 fadeOutTime, s32 fadeInTime)
Definition stage.h:54
FighterInfoFuncs funcs
Definition model.h:272
FighterInfo *(* getInfo)(s32 id)
Definition model.h:258
s32 model
Definition model.h:226
s32(* isLoading)(s32 file)
Definition file.h:88
void(* request)(s32 file)
Definition file.h:90
s32(* getFrameTime)(void)
Definition gfx.h:32
GfxFuncs funcs
Definition gfx.h:77
What drives a Model, owned by whoever created it.
Definition model.h:99
s32 wireframe
they are drawn as wireframe (Mesh.drawWireframe)
Definition model.h:114
s32 enabled
Definition model.h:112
s32 layerId
the layer its meshes are drawn in
Definition model.h:113
struct ModelControl::@3 layers[2]
the model is drawn once for each one enabled
s32 motion
the motion to play
Definition model.h:102
The fighters' models (FIGHTSTG_createModels), registered as BATTLE_TASK_MODELS: up to four,...
Definition model.h:284
void(* setId)(struct Models *task, s32 id, s32 newId)
Definition model.h:290
void(* face)(struct Models *task, s32 id)
ids under 0x10 are one side
Definition model.h:292
void(* add)(struct Models *task, s32 id, s32 fighter, s32 visible)
Definition model.h:288
ModelControl *(* get)(struct Models *task, s32 id)
Definition model.h:289
s32(* isLoading)(void)
Definition sound.h:193
void(* fadeOut)(s32 id)
Definition sound.h:196
void(* loadBank)(s32 id)
Definition sound.h:190
short(* playSound)(s32 id)
returns the voice of a key-on
Definition sound.h:187
void *(* find)(s32 id, s32 key1, s32 key2)
Definition task.h:18
TaskFuncs funcs
Definition task.h:76
The white flash (FIGHTSTG_startWhiteFlash): fades the screen to white, and back once ended.
Definition effect.h:105
void * createTask(void(*update)(), s32 size, s32 childrenSize)
createTaskWithId for a task nothing needs to find
Definition task.c:105
WhiteFlash * FIGHTSTG_startWhiteFlash(s32 frames)
Starts a white flash that whitens the screen over FRAMES.
Definition white_flash.c:70
void FIGHTSTG_endWhiteFlash(WhiteFlash *task, s32 frames)
Fades the white flash back out over FRAMES.
Definition white_flash.c:64