Digimon World 3 decomp
The European version, SLES_039.36
Loading...
Searching...
No Matches
shot_camera.c
Go to the documentation of this file.
1/* FIGHTSTG's shot camera, which goes through lists of shots while the player
2 picks a command. */
3
5
6/* FIGHTSTG_updateShotCamera's shots: how long each lasts and the substate that makes it,
7 in four lists that end with a time of -1 */
9 { { 1800, 1 }, { 480, 9 }, { 360, 3 }, { 300, 4 }, { 480, 9 }, { -1, 0 } },
10 { { 360, 6 }, { 900, 1 }, { 300, 5 }, { 480, 9 }, { -1, 0 }, { 0, 0 } },
11 { { 1920, 1 }, { 360, 6 }, { 180, 7 }, { 480, 9 }, { -1, 0 }, { 0, 0 } },
12 { { 90, 10 }, { 90, 5 }, { -1, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 } },
13};
14/* the lists that can follow each one */
16 { 1, 2, 1 }, { 0, 2, 2 }, { 0, 1, 0 }, { 0, 1, 2 },
17};
18
19/* Shows both models again and starts the list's next shot, or the first
20 shot of a list picked at random among those that can follow. */
21static inline void startNextShot(ShotCamera *task) {
22 task->models->get(task->models, 0)->layers[0].enabled = 1;
23 task->models->get(task->models, 0x10)->layers[0].enabled = 1;
24 if (FIGHTSTG_cameraShots[task->list][++task->shot].time == -1) {
25 task->list = FIGHTSTG_nextShotLists[task->list][RANDOM.next() % 3];
26 task->shot = 0;
27 }
28 task->time = FIGHTSTG_cameraShots[task->list][task->shot].time;
29 task->setSubstate(task, FIGHTSTG_cameraShots[task->list][task->shot].substate);
30}
31
32/* Shot 1: turns around the fighters from the enemy's view, going on from
33 where the last turn stopped (in stage 4, a half turn ends the shot). */
34static inline void turnAroundFighters(ShotCamera *task) {
35 if (task->step == 0) {
36 task->view = task->camera->getEnemyView(task->camera);
37 task->turned = 0;
38 task->step++;
39 if ((BATTLE_SETUP.stage & 0xF) != 4) {
40 task->view->rot.vy = task->ry;
41 }
42 }
43 task->view->rot.vy += GFX.funcs.getFrameTime() * 2;
44 task->turned += GFX.funcs.getFrameTime() * 2;
45 if (task->view->rot.vy >= 0x1000) {
46 task->view->rot.vy -= 0x1000;
47 }
48 task->ry = task->view->rot.vy;
49 if ((BATTLE_SETUP.stage & 0xF) == 4 && task->turned > 0x800) {
50 task->time = 0;
51 }
52}
53
54/* Shot 2: a fixed view, set off to the side of the enemy's view. */
55static inline void viewFromSide(ShotCamera *task) {
56 task->view = task->camera->getEnemyView(task->camera);
57 task->view->vpx = -0x1E80;
58 task->view->vpy = -0x500;
59 task->view->vpz = 0;
60 task->view->vrx = 0;
61 task->view->vry = 0x500;
62 task->view->vrz = 0;
63 task->view->proj = 0x98;
64}
65
66/* Shot 9: a turning view, set high above the enemy's view. */
67static inline void viewFromAbove(ShotCamera *task) {
68 task->view = task->camera->getEnemyView(task->camera);
69 task->view->vpx = -0x1400;
70 task->view->vpy = -0x2800;
71 task->view->vpz = 0;
72 task->view->vrx = 0;
73 task->view->vry = 0;
74 task->view->vrz = 0;
75 task->view->proj = 0xC8;
76 task->speed = 1;
77 task->view->rot.vy -= 0x155;
78}
79
80/* Views the partner's side, with the enemy's model hidden. */
81static inline void viewPartnerSide(ShotCamera *task) {
82 task->models->get(task->models, 0x10)->layers[0].enabled = 0;
83 task->view = task->camera->getFighterView(task->camera, 0, 8);
84 task->view->tz -= 0x1400;
85 task->view->vpz += 0x1400;
86 task->view->vrz += 0x1400;
87 task->speed = 1;
88}
89
90/* Views the enemy's side, with the partner's model hidden. */
91static inline void viewEnemySide(ShotCamera *task) {
92 task->models->get(task->models, 0)->layers[0].enabled = 0;
93 task->view = task->camera->getFighterView(task->camera, 0x10, 0);
94 task->view->tz += 0x1400;
95 task->view->vpz -= 0x1400;
96 task->view->vrz -= 0x1400;
97 task->speed = 1;
98}
99
100/* Turns the view around at the shot's speed. */
101static inline void spinView(ShotCamera *task) {
102 task->view->rot.vy += GFX.funcs.getFrameTime() * task->speed;
103 if (task->view->rot.vy >= 0x1000) {
104 task->view->rot.vy -= 0x1000;
105 }
106}
107
108/* Turns the view around the other way at the shot's speed. */
109static inline void spinViewBack(ShotCamera *task) {
110 task->view->rot.vy -= GFX.funcs.getFrameTime() * task->speed;
111 if (task->view->rot.vy < 0) {
112 task->view->rot.vy += 0x1000;
113 }
114}
115
116/* A camera that plays lists of shots (FIGHTSTG_cameraShots): turns around the
117 fighters, fixed views and views of one side with the other side's model
118 hidden */
120 switch (task->state) {
121 case 0:
122 default:
123 task->nextState(task);
124 task->list = 3;
125 task->shot = 0;
126 task->time = FIGHTSTG_cameraShots[task->list][task->shot].time;
127 task->setSubstate(task, FIGHTSTG_cameraShots[task->list][task->shot].substate);
130 task->view = task->camera->getEnemyView(task->camera);
131 task->ry = task->view->rot.vy;
132 break;
133 case 1:
134 if (task->time <= 0) {
135 startNextShot(task);
136 }
137 switch (task->substate) {
138 case 1:
139 default:
140 turnAroundFighters(task);
141 break;
142 case 2:
143 if (task->step == 0) {
144 viewFromSide(task);
145 task->step++;
146 }
147 break;
148 case 3:
149 if (task->step == 0) {
150 viewPartnerSide(task);
151 task->step++;
152 }
153 spinView(task);
154 break;
155 case 4:
156 if (task->step == 0) {
157 viewEnemySide(task);
158 task->step++;
159 }
160 spinViewBack(task);
161 break;
162 case 5:
163 if (task->step == 0) {
164 viewPartnerSide(task);
165 task->step++;
166 task->view->rot.vy += 0xE3;
167 }
168 spinViewBack(task);
169 break;
170 case 6:
171 if (task->step == 0) {
172 viewEnemySide(task);
173 task->step++;
174 task->view->rot.vy -= 0xE3;
175 }
176 spinView(task);
177 break;
178 case 7:
179 if (task->step == 0) {
180 task->models->get(task->models, 0x10)->layers[0].enabled = 0;
181 task->view = task->camera->getFighterView(task->camera, 0, 10);
182 task->step++;
183 }
184 break;
185 case 8:
186 if (task->step == 0) {
187 task->models->get(task->models, 0x10)->layers[0].enabled = 0;
188 task->view = task->camera->getFighterView(task->camera, 0, 8);
189 task->step++;
190 }
191 break;
192 case 9:
193 if (task->step == 0) {
194 viewFromAbove(task);
195 task->step++;
196 }
197 spinView(task);
198 break;
199 case 10:
200 if (task->step == 0) {
201 task->view = task->camera->getEnemyView(task->camera);
202 task->step++;
203 }
204 break;
205 }
206 if (task->view != NULL) {
207 task->camera->set(task->camera, task->view);
208 }
209 task->time -= GFX.funcs.getFrameTime();
210 break;
211 case 3:
212 task->models->get(task->models, 0)->layers[0].enabled = 1;
213 task->models->get(task->models, 0x10)->layers[0].enabled = 1;
214 task->view = task->camera->getEnemyView(task->camera);
215 task->camera->set(task->camera, task->view);
216 break;
217 case 2:
218 break;
219 }
220}
221
222/* Starts the camera that plays lists of shots (FIGHTSTG_updateShotCamera) */
#define BATTLE_TASK_CAMERA
Definition types.h:21
#define BATTLE_TASK_MODELS
the fighters'
Definition types.h:23
FIGHTSTG.PRO: the battle.
#define NULL
Definition common.h:17
unsigned char u8
Definition common.h:8
GfxState GFX
GFX: the graphics state and its methods.
Definition display.c:209
BattleSetup BATTLE_SETUP
Definition items.c:886
Random RANDOM
Definition random.c:533
TaskRegistry TASK_REGISTRY
Definition registry.c:122
static void viewPartnerSide(ShotCamera *task)
Views the partner's side, with the enemy's model hidden.
Definition shot_camera.c:81
static void viewFromAbove(ShotCamera *task)
Shot 9: a turning view, set high above the enemy's view.
Definition shot_camera.c:67
static void spinViewBack(ShotCamera *task)
Turns the view around the other way at the shot's speed.
static void startNextShot(ShotCamera *task)
Shows both models again and starts the list's next shot, or the first shot of a list picked at random...
Definition shot_camera.c:21
static void turnAroundFighters(ShotCamera *task)
Shot 1: turns around the fighters from the enemy's view, going on from where the last turn stopped (i...
Definition shot_camera.c:34
static void viewEnemySide(ShotCamera *task)
Views the enemy's side, with the partner's model hidden.
Definition shot_camera.c:91
void FIGHTSTG_updateShotCamera(ShotCamera *task)
A camera that plays lists of shots (FIGHTSTG_cameraShots): turns around the fighters,...
CameraShot FIGHTSTG_cameraShots[4][6]
FIGHTSTG_updateShotCamera's shots: how long each lasts and the substate that makes it,...
Definition shot_camera.c:8
ShotCamera * FIGHTSTG_createShotCamera(void)
Starts the camera that plays lists of shots (FIGHTSTG_updateShotCamera)
u8 FIGHTSTG_nextShotLists[8][3]
the lists that can follow each one
Definition shot_camera.c:15
static void viewFromSide(ShotCamera *task)
Shot 2: a fixed view, set off to the side of the enemy's view.
Definition shot_camera.c:55
static void spinView(ShotCamera *task)
Turns the view around at the shot's speed.
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
s32 stage
the battle's fight stage
Definition game_state.h:383
A shot of FIGHTSTG_updateShotCamera's camera.
Definition camera.h:26
s16 substate
Definition camera.h:28
s16 time
-1 ends the list
Definition camera.h:27
s32 vry
Definition camera.h:54
s32 vpy
Definition camera.h:51
s32 tz
Definition camera.h:58
s32 vrx
Definition camera.h:53
SVECTOR rot
Definition camera.h:59
s32 vpx
Definition camera.h:50
s32 vpz
Definition camera.h:52
s32 proj
the projection distance
Definition camera.h:61
s32 vrz
Definition camera.h:55
s32(* getFrameTime)(void)
Definition gfx.h:32
GfxFuncs funcs
Definition gfx.h:77
s32 enabled
Definition model.h:112
struct ModelControl::@3 layers[2]
the model is drawn once for each one enabled
ModelControl *(* get)(struct Models *task, s32 id)
Definition model.h:289
s32(* next)(void)
0 to RANDOM_COUNT - 1
Definition random.h:15
A camera (FIGHTSTG_createShotCamera) that goes through lists of shots (FIGHTSTG_cameraShots),...
Definition camera.h:34
s16 ry
where the turn of substate 1 is
Definition camera.h:41
s32 speed
Definition camera.h:44
s32 step
Definition camera.h:35
struct CameraView * view
Definition camera.h:37
s16 shot
Definition camera.h:40
void(* nextState)(struct ShotCamera *task)
Definition camera.h:35
s32 state
Definition camera.h:35
void(* setSubstate)(struct ShotCamera *task, s32 substate)
Definition camera.h:35
struct BattleCamera * camera
Definition camera.h:36
struct Models * models
Definition camera.h:38
s16 turned
Definition camera.h:42
s32 substate
Definition camera.h:35
s32 time
Definition camera.h:43
s16 list
Definition camera.h:39
void *(* find)(s32 id, s32 key1, s32 key2)
Definition task.h:18
TaskFuncs funcs
Definition task.h:76
void * createTask(void(*update)(), s32 size, s32 childrenSize)
createTaskWithId for a task nothing needs to find
Definition task.c:105