DCDecomp
A decompilation of Dark Cloud for the PlayStation 2
Loading...
Searching...
No Matches
op_d.cpp
1
2#include "common.h"
3
4#include <libgraph.h>
5#include <libpkt.h>
6#include <libvu0.h>
7
8#include <cmath>
9#include <cstdlib>
10
11#include "camera.hpp"
12#include "camerafollow.hpp"
13#include "character.hpp"
14#include "dataalloc.hpp"
15#include "dataread.hpp"
16#include "frame.hpp"
17#include "framevu1.hpp"
18#include "main.hpp"
19#include "mathutil.hpp"
20#include "mds.hpp"
21#include "mdt.hpp"
22#include "mglib.hpp"
23#include "renderinfo.hpp"
24#include "snd.hpp"
25#include "sound.hpp"
26#include "texture.hpp"
27#include "title/op_a.hpp"
28#include "title/op_b.hpp"
29#include "title/op_d.hpp"
30#include "title/opening.hpp"
31#include "title/script.hpp"
32#include "title/seireiking.hpp"
33#include "visual.hpp"
34#include "wind.hpp"
35
39// clang-format off
40enum OpDSprite {
41 OPD_SPRITE_NONE = 0,
42 OPD_SPRITE_HALL_LIGHT = 1,
43 OPD_SPRITE_RUIN_STILL_1 = 2,
44 OPD_SPRITE_RUIN_STILL_2 = 3,
45 OPD_SPRITE_RUIN_STILL_3 = 4,
46 OPD_SPRITE_CAPTION_1 = 5,
47 OPD_SPRITE_CAPTION_2 = 6,
48};
49
50// clang-format on
51
52/* The rectangle a texture transfer takes, declared here rather than reached through rect.h for the
53 reason op_b.cpp and op_c.cpp declare their own: rect.h's four-argument constructor assigns h, w,
54 y and x in that order and every rectangle this file builds assigns them the other way round. */
55template <class T>
56class CRect {
57public:
58 T x;
59 T y;
60 T w;
61 T h;
63 CRect() {
64 h = 0;
65 w = 0;
66 y = 0;
67 x = 0;
68 }
69
70 CRect(T left, T top, T width, T height) {
71 x = left;
72 y = top;
73 w = width;
74 h = height;
75 }
76} __attribute__((aligned(16)));
77
78/* The two classes this scene places in the world, declared here rather than reached through headers
79 of their own because each is another unit's to type. Only the members this file touches are
80 named; the extents are the sizes the executable gives the objects below. */
81
82/* A frame parented to an object, which is what lets the world transform drive a model. */
83class CObjectFrame : public CObject {
84public:
85 CFrameVu1 *frame[4];
87 s32 draw_on;
89 virtual void FrameObjectOnOff(char *name, int on);
90 virtual void Draw();
91
92 void SetFrame(CFrameVu1 *frame, int level);
93};
94
95/* One piece of scenery. The scene builds a table of them, hands each its model, and drives them
96 through the object dispatch like anything else in the world. The frame it was handed is read back
97 out of it here, which is what names the first member. */
98class CMapObject : public CObjectFrame {
99public:
104 float shadow_offset;
105 int unk_34;
106 int handle;
107 char unk_3C[4];
108
109 CMapObject();
110
111 virtual void Draw();
112
113 void Initialize();
114 void DrawShadow(int fast);
115};
116
117/* One piece of scenery as the scene was laid out: the model, the model its shadow is drawn
118 from, where it stands in tenths of a world unit, and its three rotations in degrees. */
119struct MAPOBJ_INFO {
120 char *name;
121 char *shadow_name;
122 float position[3];
123 float rotation[3];
124};
125
126/* One actor's face, as this scene animates it. The eyes and the mouth are two strips of frames
127 stacked bottom-up in one 256-wide texture — the eyes down the left half and the mouth down the
128 right — and a tick copies the current frame of each over the model's face plate. The two offsets
129 are measured from the bottom edge of the 128-pixel plate. */
130struct FACE_INFO {
131 char *plate;
132 char *strip;
133 int eye_bottom;
134 int eye_height;
135 int mouth_bottom;
136 int mouth_height;
137 int eye;
138 int mouth;
139 int strip_bottom;
140 int unk_24;
141 int unk_28;
142};
143
144void MoveImageTest(sceVif1Packet *packet, int sbp, int sbw, int spsm, const CRect<int> &rect, int dbp, int dbw, int dpsm, int dsax, int dsay, int dir);
145void set2DSprite(sceVif1Packet *packet, CTexture *texture, const CRect<int> &src, const CRect<int> &dst, u_char alpha);
146void DepthOfField(float *dist, int level, int alpha, int blur);
147
148static void SkyColor(CFrameVu1 *frame);
149static void EffectAtraPrizum();
150static void RollLight(float *target);
151static void EffectSeireiKing(float size);
152static void LensFreaProcess();
153static void Setsumei();
154static void HamonProcess();
155void FaceChangeMovie(int actor);
156
157static CWind Wind;
158static CFrameVu1 *Hamon[4];
159static float HScale[5];
160static CCharacter Effect;
161static CSeireiKing SeireiKing;
162
163static int amb3;
164static CFrameVu1 *SkyFrame;
165
166/* One actor's blinking and speaking. The eyes and the mouth are two strips of frames in one
167 256-wide texture, and a tick copies the current frame of each over the actor's face plate. The
168 mouth is driven from the script's own clock rather than from a motion: while the actor is talking
169 a new frame is picked at random every sixth hundredth of a second left on the timer, and the
170 timer running out closes the mouth and ends the line. */
171void FaceChange(int actor_no) {
172 static FACE_INFO face[21] = {
173 {0, 0, 42, 40, 87, 35, 0, 0, 256, 2, 0},
174 {0, 0, 42, 40, 87, 35, 0, 0, 320, 2, 0},
175 {0, 0, 32, 40, 84, 35, 0, 0, 448, 3, 0},
176 {"c09a01", "c09a01an", 10, 40, 73, 35, 0, 0, 448, 2, 0},
177 {0, 0, 42, 40, 87, 35, 0, 0, 320, 2, 0},
178 {0, 0, 42, 40, 87, 35, 0, 0, 320, 2, 0},
179 {0, 0, 8, 40, 76, 35, 0, 0, 256, 2, 0},
180 {0, 0, 42, 40, 87, 35, 0, 0, 320, 2, 0},
181 {0, 0, 42, 40, 87, 35, 0, 0, 320, 2, 0},
182 {"p09a01", "p09a01an_3", 44, 40, 92, 32, 0, 0, 192, 2, 0},
183 {0, 0, 42, 40, 87, 35, 0, 0, 320, 2, 0},
184 {"c01d01", "c01d01an_3", 27, 48, 78, 44, 0, 0, 512, 3, 0},
185 {0, 0, 42, 40, 87, 35, 0, 0, 320, 2, 0},
186 {0, 0, 42, 40, 87, 35, 0, 0, 320, 2, 0},
187 {0, 0, 42, 40, 87, 35, 0, 0, 320, 2, 0},
188 {0, 0, 42, 40, 87, 35, 0, 0, 320, 2, 0},
189 {0, 0, 42, 40, 87, 35, 0, 0, 320, 2, 0},
190 {0, 0, 42, 40, 87, 35, 0, 0, 320, 2, 0},
191 {0, 0, 42, 40, 87, 35, 0, 0, 320, 2, 0},
192 {0, 0, 42, 40, 87, 35, 0, 0, 320, 2, 0},
193 {0, 0, 42, 40, 87, 35, 0, 0, 320, 2, 0}
194 };
195 CTexture *plate;
196 CTexture *strip;
197 int sbp;
198 int dbp;
199 int sbw;
200 int dbw;
201
202 sceVif1PkCnt(Vif1Packet, 0);
203 sceVif1PkOpenDirectCode(Vif1Packet, 0);
204 sceVif1PkOpenGifTag(Vif1Packet, *(u_long128 *) &GiftagAD);
205 sceVif1PkAddGsAD(Vif1Packet, SCE_GS_TEXFLUSH, 0);
206 sceVif1PkCloseGifTag(Vif1Packet);
207 sceVif1PkCloseDirectCode(Vif1Packet);
208
209 if (face[actor_no].plate == 0) {
210 return;
211 }
212
213 plate = TexManager.GetTexture(face[actor_no].plate, -1);
214 strip = TexManager.GetTexture(face[actor_no].strip, -1);
215
216 if (plate == 0 || strip == 0) {
217 return;
218 }
219
220 sbp = strip->tex0 & 0x3fff;
221 dbp = plate->tex0 & 0x3fff;
222 sbw = (strip->tex0 >> 14) & 0x3f;
223 dbw = (plate->tex0 >> 14) & 0x3f;
224
225 face[actor_no].eye = CScript__2.obj[actor_no].eye;
226
227 CRect<int> eye(0, face[actor_no].strip_bottom - face[actor_no].eye_height * (face[actor_no].eye + 1), 128, face[actor_no].eye_height);
228
229 MoveImageTest(Vif1Packet, sbp, sbw, SCE_GS_PSMT8, eye, dbp, dbw, SCE_GS_PSMT8, 0, 128 - face[actor_no].eye_height - face[actor_no].eye_bottom, 0);
230
231 if (!Pause) {
232 if (CScript__2.obj[actor_no].mouth_time >= CScript__2.motion_step) {
233 CScript__2.obj[actor_no].mouth_time -= CScript__2.motion_step;
234
235 if (CScript__2.obj[actor_no].talk) {
236 if ((int) (100.0f * CScript__2.obj[actor_no].mouth_time) % 6 == 0) {
237 CScript__2.obj[actor_no].mouth = rand() % 4;
238 }
239 }
240 } else {
241 CScript__2.obj[actor_no].mouth = 0;
242 CScript__2.obj[actor_no].talk = false;
243 }
244 }
245
246 face[actor_no].mouth = CScript__2.obj[actor_no].mouth;
247
248 CRect<int> mouth(128, face[actor_no].strip_bottom - face[actor_no].mouth_height * (face[actor_no].mouth + 1), 128, face[actor_no].mouth_height);
249
250 MoveImageTest(Vif1Packet, sbp, sbw, SCE_GS_PSMT8, mouth, dbp, dbw, SCE_GS_PSMT8, 0, 128 - face[actor_no].mouth_height - face[actor_no].mouth_bottom, 0);
251
252 sceVif1PkCnt(Vif1Packet, 0);
253 sceVif1PkOpenDirectCode(Vif1Packet, 0);
254 sceVif1PkOpenGifTag(Vif1Packet, *(u_long128 *) &GiftagAD);
255 sceVif1PkAddGsAD(Vif1Packet, SCE_GS_TEXFLUSH, 0);
256 sceVif1PkCloseGifTag(Vif1Packet);
257 sceVif1PkCloseDirectCode(Vif1Packet);
258}
259
260/* The background loads are one wrapper per file because the script names them by index: each waits
261 for the previous read to land, starts the next, and marks the load done by putting the script's
262 own load number back to none. The second one also starts the music bank packed behind the scene
263 in the same file, because the second half of the scene is scored differently from the first. */
264void OpD_LoadDataBG() {
265 while (ReadBGSync())
266 ;
267
268 LoadFileBG("opdat/norn4/seirei.pak", (u_long128 *) read_buffer, 0);
269 CScript__2.load_no = OP_SCENE_NONE;
270}
271
272void OpD_LoadDataBG2() {
273 int size;
274
275 while (ReadBGSync())
276 ;
277
278 LoadFileBG("opdat/norn4/seirei2.pak", (u_long128 *) read_buffer, &size);
279 SndBgmLoadBG(0, (u_int *) ((u_long128 *) read_buffer + (size >> 4) + 1), 0);
280 CScript__2.load_no = OP_SCENE_NONE;
281}
282
283/* The set-up for the first of the scene's two halves, the spirit king's hall. Every texture block
284 the scene before it left is dropped first, because this is the point in the opening that arrives
285 with the most already loaded. The three actors are the king, the king speaking and the girl; the
286 ripples the hall's floor carries are one model drawn four times, which is what the four-entry
287 frame table and the five-entry scale table are. */
288void OpD_InitProcess() {
289 while (ReadBGSync())
290 ;
291
292 for (int i = 0; i < 17; i++) {
293 TexManager.DeleteTextureBlock(i);
294 }
295
296 TexManager.CleanUpBuffer();
297
298 LOADTEXTURE_INFO2 tex[] = {
299 {"#blender#640#" HALF_BUFFER_HEIGHT_STR "#4", 0, 0},
300 {0, 11, 0},
301 {0, 11, 0},
302 {0, 4, 0},
303 {0, 4, 0},
304 {0, 4, 0},
305 {0, 4, 0},
306 {0, 4, 0},
307 {0, 0, 0}
308 };
309
310 tex[1].name = (char *) GetPackFile(read_buffer, "b0401.img", 0);
311 tex[2].name = (char *) GetPackFile(read_buffer, "b0402.img", 0);
312 tex[3].name = (char *) GetPackFile(read_buffer, "eef01.img", 0);
313 tex[4].name = (char *) GetPackFile(read_buffer, "eef02.img", 0);
314 tex[5].name = (char *) GetPackFile(read_buffer, "eef03.img", 0);
315 tex[6].name = (char *) GetPackFile(read_buffer, "eef04.img", 0);
316 tex[7].name = (char *) GetPackFile(read_buffer, "eef05.img", 0);
317
318 TexManager.LoadTextureBlock(-1, tex);
319
320 tex[0].name = (char *) GetPackFile(read_buffer, "c01d01.img", 0);
321 tex[0].block_no = 1;
322 tex[0].mipmap = false;
323 tex[1].name = (char *) GetPackFile(read_buffer, "c01d01an.img", 0);
324 tex[1].block_no = 1;
325 tex[1].mipmap = false;
326 tex[2].name = 0;
327
328 TexManager.LoadTextureBlock(1, tex);
329
330 tex[0].name = (char *) GetPackFile(read_buffer, "c03c01.img", 0);
331 tex[0].block_no = 2;
332 tex[0].mipmap = false;
333 tex[1].name = 0;
334
335 TexManager.LoadTextureBlock(2, tex);
336 MapDataBuffer.used = 0;
337
338 CFrameVu1 *frame = LoadMDSFile((u_int *) GetPackFile(read_buffer, "b0401.mds", 0), &MapDataBuffer, 2, 0, 0);
339 CMapObject &hall = OP_NornMapObj[0];
340
341 hall.Initialize();
342 hall.SetFrame(frame, 0);
343 OP_NornMapObj[0].handle = 0;
344 OP_NornMapObj[0].unk_34 = 0;
345 hall.SetPosition(CVector3_f_(0.0f, 0.0f, 0.0f));
346 hall.SetRotation(CVector3_f_(0.0f, 0.0f, 0.0f));
347 Hamon[0] = LoadMDSFile((u_int *) GetPackFile(read_buffer, "b0402.mds", 0), &CharaDataBuffer__2[6], 2, 0, 0);
348 Hamon[1] = Hamon[2] = Hamon[3] = Hamon[0];
349 HScale[0] = 0.0f;
350 HScale[1] = -0.8f;
351 HScale[2] = -1.6f;
352 HScale[3] = -2.4f;
353 HScale[4] = -3.2f;
354 OP_FireList = 0;
355 OPAnalyz("opdat/seirei.cfg");
356 OPMdsLoad();
357 CharaDataBuffer__2[6].used = 0;
358 Chara__3[8].LoadPackData(read_buffer, "05c01d.cfg", &CharaDataBuffer__2[6], 0);
359
360 CFrameAttr attr8;
361
362 attr8.clip_enable = false;
363 Chara__3[8].frame->SetAttr(attr8, 1, 4);
364 Chara__3[8].motion_type.state.time = 60.0f;
365 Chara__3[8].motion_type.state.blend_step = 0.05f;
366 Chara__3[8].motion_type.state.motion_no = 0;
367 Chara__3[8].motion_type.state.playing_no = 0;
368 CharaTex__2[8] = 1;
369 Chara__3[11].LoadPackData(read_buffer, "05c01e.cfg", &CharaDataBuffer__2[6], 0);
370 attr8.clip_enable = false;
371 Chara__3[11].frame->SetAttr(attr8, 1, 4);
372 Chara__3[11].motion_type.state.time = 75.0f;
373 Chara__3[11].motion_type.state.blend_step = 0.05f;
374 Chara__3[11].motion_type.state.motion_no = 1;
375 Chara__3[11].motion_type.state.playing_no = 1;
376 CharaTex__2[11] = 1;
377 Chara__3[21].LoadPackData(read_buffer, "05c03c.cfg", &CharaDataBuffer__2[6], 0);
378
379 CFrameAttr attr21;
380
381 attr21.clip_enable = false;
382 Chara__3[21].frame->SetAttr(attr21, 1, 4);
383 Chara__3[21].motion_type.state.time = 1.0f;
384 Chara__3[21].motion_type.state.blend_step = 0.05f;
385 Chara__3[21].motion_type.state.motion_no = 0;
386 Chara__3[21].motion_type.state.playing_no = 0;
387 CharaTex__2[21] = 2;
388 Effect.LoadPackData(read_buffer, "atrpeff1.cfg", &CharaDataBuffer__2[6], 0);
389
390 CFrameAttr effect_attr;
391
392 effect_attr.clip_enable = false;
393 Effect.frame->SetAttr(effect_attr, 1, 4);
394 Effect.motion_type.state.time = 1.0f;
395 Effect.motion_type.state.blend_step = 1.0f;
396 Effect.motion_type.state.motion_no = 0;
397 Effect.motion_type.state.playing_no = 0;
398 CSnd.SetReverb(0, 4, 50);
399 CSnd.SetReverb(1, 2, 5);
400 CSnd.LoadSoundFileFromPack("o04a.txt", read_buffer);
401 CSnd.SetVol(MIDI_PORT_SE_TITLE, 256);
402 CSnd.SetVol(MIDI_PORT_SE_DEFAULT, 256);
403 CSnd.SetVol(MIDI_PORT_UNK_D, 256);
404 CSnd.SetVol(MIDI_PORT_SE_SPECIAL, 256);
405
406 LOADTEXTURE_INFO img[] = {
407 {"opdat/norn4/i00002.img", 5, 0},
408 {"opdat/norn4/i00006.img", 5, 0},
409 {"opdat/norn4/i00022.img", 6, 0},
410 {"opdat/norn4/0519.img", 7, 0},
411 {"opdat/norn4/0519p.img", 7, 0},
412 {0, 0, 0},
413 {0, 0, 0},
414 {0, 0, 0},
415 {0, 0, 0},
416 {0, 0, 0},
417 {0, 0, 0},
418 {0, 0, 0},
419 {0, 0, 0},
420 {0, 0, 0},
421 {0, 0, 0}
422 };
423
424 TexManager.LoadTextureBlock(-1, img, read_buffer);
425 SeireiKing.Initialize();
426 amb3 = 0;
427 CScript__2.init_no = 0;
428}
429
430/* The set-up for the second half, the meadow the girl walks out into. Ten models are placed from a
431 table of this file's own rather than from a configuration file: the seventh is the flowers, which
432 take a frame attribute the rest do not and whose one named frame is drawn again later under a
433 light of its own, the eighth is the sky, whose vertex colours this file writes itself, and the
434 tenth is kept aside because the lens flare is aimed at a frame inside it. */
435void OpD_InitProcess2() {
436 while (ReadBGSync())
437 ;
438
439 LOADTEXTURE_INFO2 tex[] = {
440 {0, 10, 0},
441 {0, 10, 0},
442 {0, 10, 0},
443 {0, 10, 0},
444 {0, 10, 0},
445 {0, 10, 0},
446 {0, 3, 0},
447 {0, 10, 0},
448 {0, 0, 0}
449 };
450
451 tex[0].name = (char *) GetPackFile(read_buffer, "b0403.img", 0);
452 tex[1].name = (char *) GetPackFile(read_buffer, "e01b01.img", 0);
453 tex[2].name = (char *) GetPackFile(read_buffer, "t0401.img", 0);
454 tex[3].name = (char *) GetPackFile(read_buffer, "e01s01.img", 0);
455 tex[4].name = (char *) GetPackFile(read_buffer, "e01s06.img", 0);
456 tex[5].name = (char *) GetPackFile(read_buffer, "t0402.img", 0);
457 tex[6].name = (char *) GetPackFile(read_buffer, "buterfly.img", 0);
458 tex[7].name = (char *) GetPackFile(read_buffer, "lensfler.img", 0);
459
460 TexManager.LoadTextureBlock(-1, tex);
461
462 MAPOBJ_INFO map[] = {
463 {"b0403.mds", 0, {0.0f, 0.0f, 0.0f}, {0.0f, 0.0f, 0.0f}},
464 {"e01g02_0.mds", 0, {0.0f, 0.0f, 0.0f}, {0.0f, 0.0f, 0.0f}},
465 {"e01g03_0.mds", 0, {0.0f, 0.0f, 0.0f}, {0.0f, 0.0f, 0.0f}},
466 {"e01g04_0.mds", 0, {0.0f, 0.0f, 0.0f}, {0.0f, 0.0f, 0.0f}},
467 {"e01h06_2.mds", 0, {0.0f, 4.7424f, 79.274f}, {0.0f, 0.0f, 0.0f}},
468 {"e01a02_2.mds", 0, {0.0f, 0.0f, 59.965f}, {0.0f, 0.0f, 0.0f}},
469 {"flower.mds", 0, {0.0f, 0.0f, 0.0f}, {0.0f, 0.0f, 0.0f}},
470 {"e01s05_0.mds", 0, {0.0f, 0.0f, 0.0f}, {0.0f, 0.0f, 0.0f}},
471 {"e01s01_0.mds", 0, {0.0f, 0.0f, 0.0f}, {0.0f, 0.0f, 0.0f}},
472 {"e01s01_1.mds", 0, {104.195f, 3.399f, -150.395f}, {0.0f, 0.0f, 0.0f}}
473 };
474 CFrameAttr attr;
475 CFrameVu1 *frame;
476 int i;
477
478 attr.fog_enable = true;
479
480 for (i = 1; i < 11; i++) {
481 frame = LoadMDSFile((u_int *) GetPackFile(read_buffer, map[i - 1].name, 0), &MapDataBuffer, 2, 0, 0);
482
483 if (i == 7) {
484 attr.use_color = true;
485 frame->SetAttr(attr, 512, 0);
486 }
487
488 if (i < 8) {
489 frame->SetAttr(attr, 1, 64);
490 SetFrameAttr(frame, 1);
491 }
492
493 if (i == 8) {
494 SkyColor(frame);
495 }
496
497 if (i == 10) {
498 SkyFrame = frame;
499 }
500
501 CMapObject &object = OP_NornMapObj[i];
502
503 object.Initialize();
504 object.SetFrame(frame, 0);
505 OP_NornMapObj[i].handle = 0;
506 OP_NornMapObj[i].unk_34 = 0;
507
508 if (i == 7) {
509 object.FrameObjectOnOff("flo_S", 0);
510 }
511
512 object.SetPosition(CVector3_f_(10.0f * map[i - 1].position[0], 10.0f * map[i - 1].position[1], 10.0f * map[i - 1].position[2]));
513 object.SetRotation(CVector3_f_((float) (PI_D * map[i - 1].rotation[0] / 180), (float) (PI_D * map[i - 1].rotation[1] / 180), (float) (PI_D * map[i - 1].rotation[2] / 180)));
514 }
515
516 Chara__3[22].LoadPackData(read_buffer, "buterfly.cfg", &CharaDataBuffer__2[6], 0);
517
518 CFrameAttr attr22;
519
520 attr22.clip_enable = false;
521 Chara__3[22].frame->SetAttr(attr22, 1, 4);
522 Chara__3[22].motion_type.state.time = 1.0f;
523 Chara__3[22].motion_type.state.blend_step = 0.05f;
524 Chara__3[22].motion_type.state.motion_no = 0;
525 Chara__3[22].motion_type.state.playing_no = 0;
526 CharaTex__2[22] = 3;
527 Chara__3[5].LoadPackData(read_buffer, "buterfly.cfg", &CharaDataBuffer__2[6], 0);
528 attr22.clip_enable = false;
529 Chara__3[5].frame->SetAttr(attr22, 1, 4);
530 Chara__3[5].motion_type.state.time = 1.0f;
531 Chara__3[5].motion_type.state.blend_step = 0.05f;
532 Chara__3[5].motion_type.state.motion_no = 0;
533 Chara__3[5].motion_type.state.playing_no = 0;
534 CharaTex__2[5] = 3;
535 CSnd.SetReverb(0, 4, 30);
536 CSnd.SetReverb(1, 2, 5);
537 CSnd.LoadSoundFileFromPack("o04b.txt", read_buffer);
538 CSnd.SetVol(MIDI_PORT_SE_TITLE, 256);
539 CSnd.SetVol(MIDI_PORT_SE_DEFAULT, 256);
540 CSnd.SetVol(MIDI_PORT_UNK_D, 256);
541 CSnd.SetVol(MIDI_PORT_SE_SPECIAL, 256);
542 CScript__2.init_no = 0;
543}
544
555static void SkyColor(CFrameVu1 *frame) {
556 if (frame) {
557 CVisualVu1 *visual = frame->GetVisual();
558
559 if (visual) {
560 MDT_HEADER *model = (MDT_HEADER *) visual->GetMDTDataAddress();
561
562 if (model) {
563 if (model->colour_count) {
564 sceVu0FVECTOR *color = (sceVu0FVECTOR *) ((char *) model + model->colour_ofs);
565 sceVu0FVECTOR color0 = {50.0f, 100.0f, 255.0f, 0.0f};
566 sceVu0FVECTOR color1 = {255.0f, 255.0f, 255.0f, 0.0f};
567
568 color0[0] = color0[0] / 128.0f;
569 color0[1] = color0[1] / 128.0f;
570 color0[2] = color0[2] / 128.0f;
571 color1[0] = color1[0] / 128.0f;
572 color1[1] = color1[1] / 128.0f;
573 color1[2] = color1[2] / 128.0f;
574
575 for (int i = 0; i < 32; i++) {
576 if (i % 4 < 2) {
577 color[i][0] = color0[0];
578 color[i][1] = color0[1];
579 color[i][2] = color0[2];
580 color[i][3] = 1.0f;
581 } else {
582 color[i][0] = color1[0];
583 color[i][1] = color1[1];
584 color[i][2] = color1[2];
585 color[i][3] = 1.0f;
586 }
587 }
588
589 frame->attr.remake_pending = 1;
590 }
591 }
592 }
593 }
594}
595
596/* The tick's motion. Every actor the script has asked for takes what it last asked, and the ones
597 the scene animates are then placed from a frame of the camera's own model found by name. The wind
598 picks up when the scene moves outdoors, and a change of camera settles the girl's dress with no
599 time passing rather than letting it swing into place. */
600void OpD_MotionProcess() {
601 {
602 register float zero = 0.0f;
603
604 for (int i = 0; i < 23; i++) {
605 if (CScript__2.obj[i].disp) {
606 if (CScript__2.obj[i].motion_end != -1) {
607 if (Chara__3[i].motion_type.state.time > (float) (Chara__3[i].motion_type.motion_info[CScript__2.obj[i].motion].end - 1)) {
608 CScript__2.obj[i].motion = CScript__2.obj[i].motion_end;
609 CScript__2.obj[i].motion_end = -1;
610 }
611 }
612
613 Chara__3[i].motion_type.state.blend_step = CScript__2.obj[i].step;
614
615 if (CScript__2.obj[i].step == 1.0f) {
616 if (CScript__2.obj[i].motion != Chara__3[i].motion_no) {
617 Chara__3[i].motion_type.state.time = (float) Chara__3[i].motion_type.motion_info[CScript__2.obj[i].motion].start;
618 }
619 }
620
621 Chara__3[i].motion_no = CScript__2.obj[i].motion;
622 Chara__3[i].motion_flags = 0;
623 Chara__3[i].motion_speed = -1.0f;
624 }
625 }
626
627 char *frame_names[23] = {"", "", "", "", "", "tyou2", "", "", "c01d", "", "", "c01d", "", "", "", "",
628 "", "", "", "", "", "c03c", "tyou"};
629 sceVu0FMATRIX matrix;
630
631 for (int i = 0; i < 23; i++) {
632 if (CScript__2.obj[i].disp) {
633 CFrame *frame = Cam__2[SceneNp__2].frame->SearchFrame(frame_names[i]);
634
635 if (frame) {
636 frame->GetLWMatrix(matrix);
637 Chara__3[i].SetRotation(zero, atan2f(matrix[2][0], matrix[2][2]), zero);
638 float x = matrix[3][0];
639 float y = matrix[3][1];
640 float z = matrix[3][2];
641 Chara__3[i].SetPosition(x, y, z);
642 }
643 }
644 }
645 }
646
647 sceVu0FVECTOR dir;
648
649 if (CScript__2.camera_start < 115) {
650 dir[0] = 0.0f;
651 dir[2] = 0.0f;
652 dir[1] = 0.0f;
653 dir[3] = 0.0f;
654 Wind.SetDir(dir);
655 Wind.SetVelocity(0.0f);
656 } else {
657 dir[0] = -0.1f;
658 dir[2] = 0.1f;
659 dir[1] = 0.0f;
660 dir[3] = 0.0f;
661 Wind.SetDir(dir);
662 Wind.SetVelocity(0.2f);
663 }
664
665 int cloth_actor;
666
667 if (CScript__2.camera_start > 111) {
668 cloth_actor = 11;
669 } else {
670 cloth_actor = 8;
671 }
672
673 Chara__3[cloth_actor].wind = (int) &Wind;
674 Wind.Step();
675
676 static int camera = 0;
677
678 if (camera != CScript__2.camera_start) {
679 camera = CScript__2.camera_start;
680
681 switch (camera) {
682 case 101:
683 case 104:
684 case 123:
685 Chara__3[cloth_actor].ClothStep(-1);
686
687 for (int i = 0; i < 20; i++) {
688 Chara__3[cloth_actor].ClothStep(0);
689 }
690
691 break;
692
693 case 106:
694 case 109:
695 case 112:
696 case 115:
697 case 125:
698 Chara__3[cloth_actor].ClothStep(-1);
699
700 for (int i = 0; i < 10; i++) {
701 Chara__3[cloth_actor].ClothStep(0);
702 }
703
704 break;
705 }
706 }
707}
708
709/* The tick's sound, which is a set of camera marks rather than a table: each one acts once and
710 clears itself again when the camera moves off it, which is what the flag behind every one is for.
711 The last of them reloads the whole sound file, because the second half of the scene is scored
712 differently from the first. The one footfall is a window on the girl's own motion frame with a
713 wait behind it, so a motion that stalls inside the window plays the step once. */
714void OpD_SoundProcess() {
715 {
716 static int se = 0;
717
718 if (CScript__2.camera_start == 111) {
719 if (!se) {
720 OpPlayVolSE(MIDI_PORT_SE_DEFAULT, 40, 42, 1.0f);
721 OpPlayVolSE(MIDI_PORT_SE_DEFAULT, 40, 44, 1.0f);
722 OpPlayVolSE(MIDI_PORT_SE_DEFAULT, 40, 49, 1.0f);
723 OpPlayVolSE(MIDI_PORT_SE_DEFAULT, 40, 51, 1.0f);
724 OpPlayVolSE(MIDI_PORT_SE_DEFAULT, 40, 45, 1.0f);
725 OpPlayVolSE(MIDI_PORT_SE_DEFAULT, 40, 47, 1.0f);
726 OpPlayVolSE(MIDI_PORT_SE_DEFAULT, 40, 48, 1.0f);
727 se = 1;
728 }
729 } else {
730 se = 0;
731 }
732 }
733
734 {
735 static int mus = 0;
736
737 if (CScript__2.camera_start == 101) {
738 if (CScript__2.mes_no == 101) {
739 if (!mus) {
740 OpBgmPlay();
741 CSnd.SQ_Play(MIDI_PORT_AMBIENT, 0);
742 mus = 1;
743 }
744 }
745 } else {
746 mus = 0;
747 }
748 }
749
750 {
751 static int se = 0;
752
753 if (CScript__2.camera_start == 110) {
754 if (!se) {
755 CSnd.Fade(MIDI_PORT_BGM, -1.0f, 0);
756 se = 1;
757 }
758 } else {
759 se = 0;
760 }
761 }
762
763 {
764 static int mus = 0;
765
766 if (CScript__2.camera_start == 115) {
767 if (!mus) {
768 OpBgmPlay();
769 CSnd.SQ_Play(MIDI_PORT_AMBIENT, 0);
770 mus = 1;
771 }
772 } else {
773 mus = 0;
774 }
775 }
776
777 {
778 static int se = 0;
779
780 if (CScript__2.camera_start == 118) {
781 if (!se) {
782 CSnd.Fade(MIDI_PORT_BGM, -1.0f, 0);
783 se = 1;
784 }
785 } else {
786 se = 0;
787 }
788 }
789
790 {
791 static int mus = 0;
792
793 if (CScript__2.camera_start == 123) {
794 if (!mus) {
795 SndStopAllSe();
796 CSnd.Stop(MIDI_PORT_BGM);
797 CSnd.StopVoice(0);
798 CSnd.SetReverb(0, 4, 30);
799 CSnd.SetReverb(1, 2, 5);
800 CSnd.LoadSoundFileFromPack("o04c.txt", read_buffer);
801 CSnd.SetVol(MIDI_PORT_SE_TITLE, 256);
802 CSnd.SetVol(MIDI_PORT_SE_DEFAULT, 256);
803 CSnd.SetVol(MIDI_PORT_UNK_D, 256);
804 CSnd.SetVol(MIDI_PORT_SE_SPECIAL, 256);
805
806 while (SndSyncBG())
807 ;
808
809 SndBgmPlay(0);
810 CSnd.SQ_Play(MIDI_PORT_AMBIENT, 0);
811 mus = 1;
812 }
813 } else {
814 mus = 0;
815 }
816 }
817
818 if (CScript__2.obj[21].disp) {
819 static int wait = 0;
820 sceVu0FVECTOR position;
821 float motion_frame;
822
823 sceVu0CopyVector(position, Chara__3[21].pos);
824 motion_frame = (int) Chara__3[21].motion_type.state.time;
825
826 if (wait == 0) {
827 if (motion_frame > 43.0f && motion_frame < 45.0f) {
828 OpPlayVolPanSE(position, 50.0f, 300.0f, MIDI_PORT_SE_DEFAULT, 21, 20);
829 wait = 4;
830 } else if (motion_frame > 53.0f && motion_frame < 55.0f) {
831 OpPlayVolPanSE(position, 50.0f, 300.0f, MIDI_PORT_SE_DEFAULT, 21, 21);
832 wait = 4;
833 }
834 } else {
835 wait = wait - 1;
836 }
837 }
838}
839
840/* The tick's drawing in the order the frame is built. The hall is one object under an ambient the
841 script raises a step at a time; the meadow is ten, one of which is held back because the flowers
842 are drawn a second time under a light of their own. Then the shadows, the actors, the spirit
843 king's effect, and last the three screen fades and the caption. */
844void OpD_DrawProcess() {
845 OP_CharaFrame__2 = Cam__2[SceneNp__2].frame;
846
847 switch (CScript__2.camera_start) {
848 case 106:
849 case 107:
850 case 108:
851 case 112:
852 case 113:
853 case 121:
854 case 123:
855 case 125:
856 MGSetRenderInfo(mgRenderInfo.scale[0], 1.0f, 0xffff);
857 break;
858
859 case 115:
860 case 118:
861 case 126:
862 MGSetRenderInfo(mgRenderInfo.scale[0], 20.0f, 0xffff);
863 break;
864
865 default:
866 MGSetRenderInfo(mgRenderInfo.scale[0], 8.0f, 0xffff);
867 break;
868 }
869
870 if (CScript__2.camera_start < 115) {
871 TexManager.ReloadTexture(Vif1Packet, 11);
872
873 if (CScript__2.sprite == OPD_SPRITE_HALL_LIGHT && amb3 < 127) {
874 amb3 = amb3 + 1;
875 }
876
877 sceVu0FVECTOR ambient;
878
879 sceVu0CopyVector(ambient, ambientlight);
880 ambient[3] = (float) amb3;
881 MGSetAmbient(ambient);
882
883 CMapObject &hall = OP_NornMapObj[0];
884
885 hall.Draw();
886 MGSetAmbient(ambientlight);
887 } else {
888 float green = 100.0f;
889 float blue = 255.0f;
890 MGSetBGColor(50.0f, green, blue, 128.0f);
891 TexManager.ReloadTexture(Vif1Packet, 10);
892
893 for (int i = 1; i < 11; i++) {
894 if (i == 8) {
895 mgRenderInfo.unlit = 1;
896 } else {
897 mgRenderInfo.unlit = 0;
898 }
899
900 if (i != 7) {
901 CMapObject &object = OP_NornMapObj[i];
902
903 object.Draw();
904 }
905 }
906
907 if (CScript__2.camera_start > 119) {
908 CMapObject &flower = OP_NornMapObj[7];
909
910 flower.FrameObjectOnOff("flo_S", 0);
911 flower.Draw();
912 flower.FrameObjectOnOff("flo_S", 1);
913
914 CFrame *frame = flower.frame[0]->SearchFrame("flo_S");
915 sceVu0FVECTOR ambient;
916
917 sceVu0CopyVector(ambient, ambientlight);
918 ambient[3] = 70.0f;
919 MGSetAmbient(ambient);
920 MGDraw(frame);
921 MGSetAmbient(ambientlight);
922 }
923
924 if (CScript__2.camera_start == 124) {
925 LensFreaProcess();
926 }
927 }
928
929 if (CScript__2.camera_start < 106) {
930 HamonProcess();
931 }
932
933 TexManager.ReloadTexture(Vif1Packet, 22);
934
935 float dof[2] = {400.0f, 1000.0f};
936
937 DepthOfField(dof, 2, 64, 0);
938
939 for (int i = 0; i < 23; i++) {
940 if (i != 22 && i != 5 && CScript__2.obj[i].disp) {
941 TexManager.ReloadTexture(Vif1Packet, 23);
942 MGBeginDrawShadow(*(sceGsTex0 *) &TexManager.GetTexture("shadow_buff", -1)->tex0);
943
944 if (!Pause) {
945 Chara__3[i].ShadowStep();
946 }
947
948 Chara__3[i].DrawShadow();
949 MGEndDrawShadow(52);
950 }
951 }
952
953 for (int i = 0; i < 23; i++) {
954 if (CScript__2.obj[i].disp) {
955 TexManager.ReloadTexture(Vif1Packet, CharaTex__2[i]);
956
957 if (!Pause) {
958 Chara__3[i].Step();
959 Chara__3[i].ClothStep(0);
960 }
961
962 if (i == 8 || i == 11) {
963 FaceChangeMovie(i);
964 }
965
966 if (CScript__2.camera_start >= 111 && CScript__2.camera_start < 114) {
967 sceVu0FVECTOR position;
968
969 sceVu0CopyVector(position, Chara__3[i].frame->position);
970 RollLight(position);
971 }
972
973 Chara__3[i].Draw();
974 MGSetPLight(light, lightcolor);
975 }
976 }
977
978 switch (CScript__2.camera_start) {
979 case 111:
980 EffectSeireiKing(2.0f);
981 break;
982
983 case 118:
984 case 119:
985 if (CScript__2.mes_wait == 0) {
986 EffectSeireiKing(4.0f);
987 }
988
989 break;
990
991 case 112:
992 case 113:
993 EffectAtraPrizum();
994 break;
995 }
996
997 static int fade1 = 0;
998 static int fade2 = 0;
999 static int fade3 = 0;
1000
1001 if (CScript__2.sprite == OPD_SPRITE_RUIN_STILL_1) {
1002 fade1 = 128;
1003 } else if (fade1 > 0) {
1004 fade1 = fade1 - 2;
1005 }
1006
1007 if (CScript__2.sprite == OPD_SPRITE_RUIN_STILL_2) {
1008 if (fade2 < 128) {
1009 fade2 = fade2 + 2;
1010 }
1011 } else if (fade2 > 0) {
1012 fade2 = fade2 - 2;
1013 }
1014
1015 if (CScript__2.sprite == OPD_SPRITE_RUIN_STILL_3) {
1016 if (fade3 < 128) {
1017 fade3 = fade3 + 2;
1018 }
1019 } else if (fade3 > 0) {
1020 fade3 = fade3 - 1;
1021 }
1022
1023 if (fade1) {
1024 TexManager.ReloadTexture(Vif1Packet, 5);
1025 set2DSprite(GetVif1Packet(), TexManager.GetTexture("i00002", -1), CRect<int>(0, 0, 640, SCREEN_HEIGHT), CRect<int>(0, 0, 640, 448), (u_char) fade1);
1026 }
1027
1028 if (fade2) {
1029 TexManager.ReloadTexture(Vif1Packet, 5);
1030 set2DSprite(GetVif1Packet(), TexManager.GetTexture("i00006", -1), CRect<int>(0, 0, 640, SCREEN_HEIGHT), CRect<int>(0, 0, 640, 448), (u_char) fade2);
1031 }
1032
1033 if (fade3) {
1034 TexManager.ReloadTexture(Vif1Packet, 6);
1035 set2DSprite(GetVif1Packet(), TexManager.GetTexture("i00022", -1), CRect<int>(0, 0, 640, SCREEN_HEIGHT), CRect<int>(0, 0, 640, 448), (u_char) fade3);
1036 }
1037
1038 switch (CScript__2.sprite) {
1039 case OPD_SPRITE_CAPTION_1:
1040 case OPD_SPRITE_CAPTION_2:
1041 TexManager.ReloadTexture(Vif1Packet, 7);
1042 Setsumei();
1043 break;
1044 }
1045}
1046
1056static void EffectAtraPrizum() {
1057 if (CScript__2.obj[11].disp) {
1058 static float rot1 = 0.0f;
1059 static float rot2 = 0.0f;
1060
1061 if (!Pause) {
1062 rot1 += 0.01f;
1063
1064 if (rot1 > 3.14f) {
1065 rot1 = rot1 - 6.28f;
1066 }
1067
1068 rot2 = rot2 - 0.01f;
1069
1070 if (rot2 < -3.14f) {
1071 rot2 += 6.28f;
1072 }
1073 }
1074
1075 sceVu0FMATRIX matrix;
1076 sceVu0FVECTOR ambient;
1077
1078 sceVu0CopyVector(ambient, ambientlight);
1079 ambient[3] = 32.0f;
1080 MGSetAmbient(ambient);
1081
1082 sceGsAlpha alpha = mgAlpha;
1083
1084 alpha.bits.a = 0;
1085 alpha.bits.b = 2;
1086 alpha.bits.c = 0;
1087 alpha.bits.d = 1;
1088 setAlphaFlag(Vif1Packet, &alpha);
1089 TexManager.ReloadTexture(Vif1Packet, 4);
1090
1091 CFrame *frame = Chara__3[11].frame->SearchFrame("atrp");
1092
1093 if (frame) {
1094 frame->GetLWMatrix(matrix);
1095
1096 if (CScript__2.camera_start == 112) {
1097 sceVu0FVECTOR position;
1098 sceVu0FMATRIX spin;
1099
1100 sceVu0CopyVector(position, matrix[3]);
1101 sceVu0UnitMatrix(spin);
1102 sceVu0RotMatrixY(spin, spin, rot1);
1103 sceVu0MulMatrix(matrix, matrix, spin);
1104 sceVu0CopyVector(matrix[3], position);
1105 Effect.frame->SetTransMatrix(matrix);
1106 Effect.motion_no = 0;
1107 Effect.motion_flags = 0;
1108 Effect.motion_speed = -1.0f;
1109
1110 if (!Pause) {
1111 Effect.Step();
1112 }
1113
1114 Effect.Draw();
1115 frame->GetLWMatrix(matrix);
1116 sceVu0CopyVector(position, matrix[3]);
1117 sceVu0UnitMatrix(spin);
1118 sceVu0RotMatrixY(spin, spin, rot2);
1119 sceVu0MulMatrix(matrix, matrix, spin);
1120 sceVu0CopyVector(matrix[3], position);
1121 Effect.frame->SetTransMatrix(matrix);
1122 MGDraw(Effect.frame);
1123 }
1124 }
1125
1126 if (!Pause) {
1127 SeireiKing.Step();
1128 }
1129
1130 SeireiKing.Draw(matrix[3], 0.2f, 1);
1131
1132 sceVu0FVECTOR eye;
1133
1134 sceVu0CopyVector(eye, OP_CharaFrame__2->position);
1135 SeireiKing.Draw2(&OP_MainCamera, matrix[3], eye);
1136 setAlphaFlag(Vif1Packet, &mgAlpha);
1137 MGSetAmbient(ambientlight);
1138 }
1139}
1140
1152static void RollLight(float *target) {
1153 if (CScript__2.camera_start >= 111 && CScript__2.camera_start < 114) {
1154 CFrame *frame;
1155
1156 if (CScript__2.camera_start == 111) {
1157 frame = Cam__2[SceneNp__2].frame->SearchFrame("hikari");
1158 } else {
1159 frame = Chara__3[11].frame->SearchFrame("atrp");
1160 }
1161
1162 sceVu0FMATRIX matrix;
1163 sceVu0FMATRIX dirs;
1164 sceVu0FMATRIX colors;
1165 sceVu0FVECTOR dir;
1166
1167 frame->GetLWMatrix(matrix);
1168
1169 switch (CScript__2.camera_start) {
1170 case 111:
1171 case 112:
1172 dir[0] = matrix[3][0] - target[0];
1173 dir[1] = matrix[3][1];
1174 dir[2] = matrix[3][2] - target[2];
1175 sceVu0Normalize(dir, dir);
1176 sceVu0CopyMatrix(dirs, light);
1177 sceVu0CopyMatrix(colors, lightcolor);
1178 dirs[0][1] = dir[0];
1179 dirs[1][1] = dir[1];
1180 dirs[2][1] = dir[2];
1181 colors[1][0] = 255.0f;
1182 colors[1][1] = 255.0f;
1183 colors[1][2] = 255.0f;
1184 break;
1185
1186 case 113: {
1187 static float angle = 0.0f;
1188
1189 angle += 0.03f;
1190
1191 if (angle > 3.14f) {
1192 angle = angle - 6.28f;
1193 }
1194
1195 dir[0] = (float) (matrix[3][0] + sin(angle) * 25.0 - target[0]);
1196 dir[1] = (float) (matrix[3][1] + 5.0);
1197 dir[2] = (float) (matrix[3][2] + cos(angle) * 25.0 - target[2]);
1198 sceVu0Normalize(dir, dir);
1199 sceVu0CopyMatrix(dirs, light);
1200 sceVu0CopyMatrix(colors, lightcolor);
1201 dirs[0][1] = dir[0];
1202 dirs[1][1] = dir[1];
1203 dirs[2][1] = dir[2];
1204 colors[1][0] = 128.0f;
1205 colors[1][1] = 128.0f;
1206 colors[1][2] = 128.0f;
1207 } break;
1208 }
1209
1210 MGSetPLight(dirs, colors);
1211 }
1212}
1213
1224static void EffectSeireiKing(float size) {
1225 CFrame *frame = Cam__2[SceneNp__2].frame->SearchFrame("hikari");
1226
1227 if (frame) {
1228 sceVu0FMATRIX matrix;
1229
1230 frame->GetLWMatrix(matrix);
1231 TexManager.ReloadTexture(Vif1Packet, 4);
1232
1233 sceVu0FVECTOR head;
1234
1235 head[0] = matrix[3][0];
1236 head[1] = matrix[3][1];
1237 head[2] = matrix[3][2];
1238
1239 if (!Pause) {
1240 static int cnt = 0;
1241
1242 cnt = cnt + 1;
1243
1244 if (cnt > 1) {
1245 cnt = 0;
1246 }
1247
1248 if (cnt == 0) {
1249 SeireiKing.Step();
1250 }
1251 }
1252
1253 SeireiKing.Draw(head, size, 2);
1254 }
1255}
1256
1266static void LensFreaProcess() {
1267 sceVu0FVECTOR world;
1268 int screen[4];
1269 sceVu0FVECTOR local = {0.0f, 0.0f, 0.0f, 1.0f};
1270 CFrame *frame = SkyFrame->SearchFrame("sun1");
1271
1272 if (frame) {
1273 frame->GetWorldPosition(world, local);
1274
1275 if (MGRotTransPers2D(screen, world, 0)) {
1276 if (TexManager.GetTexture("lensfler", -1)) {
1277 LensFlare(TexManager.GetTexture("lensfler", -1), world, 255, 255, 255);
1278 }
1279 }
1280 }
1281}
1282
1295#ifdef PAL
1296static void Setsumei() {
1297 static int cnt1 = 0;
1298 static int cntA = 0;
1299
1300 cnt1 = cnt1 + 1;
1301
1302 if (cnt1 > 30) {
1303 cnt1 = 0;
1304 cntA = cntA + 1;
1305
1306 if (cntA > 1) {
1307 cntA = 0;
1308 }
1309 }
1310
1311 static int cnt2 = 0;
1312 static int cntB = 0;
1313
1314 cnt2 = cnt2 + 1;
1315
1316 if (cnt2 > 30) {
1317 cnt2 = 0;
1318 cntB = cntB + 1;
1319
1320 if (cntB > 2) {
1321 cntB = 0;
1322 }
1323 }
1324
1325 static int fadeA1 = 128;
1326 static int fadeA2 = 0;
1327
1328 if (cntA == 0) {
1329 fadeA1 = 128;
1330
1331 if (fadeA2 > 0) {
1332 fadeA2 = fadeA2 - 8;
1333 }
1334 } else {
1335 fadeA2 = 128;
1336
1337 if (fadeA1 > 0) {
1338 fadeA1 = fadeA1 - 8;
1339 }
1340 }
1341
1342 static int fadeB1 = 128;
1343 static int fadeB2 = 0;
1344 static int fadeB3 = 0;
1345
1346 switch (cntB) {
1347 case 0:
1348 fadeB1 = 128;
1349
1350 if (fadeB2 > 0) {
1351 fadeB2 = fadeB2 - 8;
1352 }
1353
1354 if (fadeB3 > 0) {
1355 fadeB3 = fadeB3 - 8;
1356 }
1357
1358 break;
1359
1360 case 1:
1361 fadeB2 = 128;
1362
1363 if (fadeB1 > 0) {
1364 fadeB1 = fadeB1 - 8;
1365 }
1366
1367 if (fadeB3 > 0) {
1368 fadeB3 = fadeB3 - 8;
1369 }
1370
1371 break;
1372
1373 case 2:
1374 fadeB3 = 128;
1375
1376 if (fadeB1 > 0) {
1377 fadeB1 = fadeB1 - 8;
1378 }
1379
1380 if (fadeB2 > 0) {
1381 fadeB2 = fadeB2 - 8;
1382 }
1383
1384 break;
1385 }
1386
1387 set2DSprite(GetVif1Packet(), TexManager.GetTexture("0519", -1), CRect<int>(0, 0, 640, SCREEN_HEIGHT), CRect<int>(0, 0, 640, 448), 128);
1388 set2DSprite(GetVif1Packet(), TexManager.GetTexture("0519p", -1), CRect<int>(540, 254, 88, 128), CRect<int>(89, 206, 88, 119), (u_char) fadeA1);
1389 set2DSprite(GetVif1Packet(), TexManager.GetTexture("0519p", -1), CRect<int>(540, 254, 88, 128), CRect<int>(0, 206, 88, 119), (u_char) fadeA2);
1390 set2DSprite(GetVif1Packet(), TexManager.GetTexture("0519p", -1), CRect<int>(450, 27, 105, 113), CRect<int>(117, 448, 105, 105), (u_char) fadeB1);
1391 set2DSprite(GetVif1Packet(), TexManager.GetTexture("0519p", -1), CRect<int>(450, 27, 105, 113), CRect<int>(222, 448, 105, 105), (u_char) fadeB2);
1392 set2DSprite(GetVif1Packet(), TexManager.GetTexture("0519p", -1), CRect<int>(450, 27, 105, 113), CRect<int>(327, 448, 105, 105), (u_char) fadeB3);
1393 set2DSprite(GetVif1Packet(), TexManager.GetTexture("0519p", -1), CRect<int>(350, 139, 208, 62), CRect<int>(432, 448, 208, 58), (u_char) fadeB1);
1394 set2DSprite(GetVif1Packet(), TexManager.GetTexture("0519p", -1), CRect<int>(350, 139, 208, 62), CRect<int>(432, 506, 208, 58), (u_char) fadeB2);
1395 set2DSprite(GetVif1Packet(), TexManager.GetTexture("0519p", -1), CRect<int>(350, 139, 208, 62), CRect<int>(432, 564, 208, 58), (u_char) fadeB3);
1396 set2DSprite(GetVif1Packet(), TexManager.GetTexture("0519p", -1), CRect<int>(100, 188, 117, 60), CRect<int>(0, 325, 117, 56), (u_char) fadeA1);
1397 set2DSprite(GetVif1Packet(), TexManager.GetTexture("0519p", -1), CRect<int>(100, 188, 117, 60), CRect<int>(0, 381, 117, 56), (u_char) fadeA2);
1398
1399 if (CScript__2.sprite == OPD_SPRITE_CAPTION_1) {
1400 set2DSprite(GetVif1Packet(), TexManager.GetTexture("0519p", -1), CRect<int>(6, 245, 178, 191), CRect<int>(388, 0, 178, 178), (u_char) fadeA1);
1401 set2DSprite(GetVif1Packet(), TexManager.GetTexture("0519p", -1), CRect<int>(184, 245, 178, 191), CRect<int>(388, 0, 178, 178), (u_char) fadeA1);
1402 set2DSprite(GetVif1Packet(), TexManager.GetTexture("0519p", -1), CRect<int>(362, 245, 178, 191), CRect<int>(388, 0, 178, 178), (u_char) fadeA1);
1403 set2DSprite(GetVif1Packet(), TexManager.GetTexture("0519p", -1), CRect<int>(6, 245, 178, 191), CRect<int>(210, 0, 178, 178), (u_char) fadeA2);
1404 set2DSprite(GetVif1Packet(), TexManager.GetTexture("0519p", -1), CRect<int>(184, 245, 178, 191), CRect<int>(210, 0, 178, 178), (u_char) fadeA2);
1405 set2DSprite(GetVif1Packet(), TexManager.GetTexture("0519p", -1), CRect<int>(362, 245, 178, 191), CRect<int>(210, 0, 178, 178), (u_char) fadeA2);
1406 } else {
1407 static float x = 6.0f;
1408 static float y = 245.0f;
1409 static float rot = -1.57f;
1410 static float x2 = 184.0f;
1411 static float y2 = 245.0f;
1412 static float rot2 = 1.57f;
1413 static float x3 = 362.0f;
1414 static float y3 = 245.0f;
1415 static float rot3 = 1.57f;
1416
1417 float heading = atan2f((float) (-100.0f - x), -107.0f - y);
1418
1419 if (heading < rot) {
1420 rot = rot - 0.05f;
1421 }
1422
1423 if (heading > rot) {
1424 rot += 0.05f;
1425 }
1426
1427#ifdef PAL_TIMING
1428 x = x + (float) (sin(rot) * 4.8f);
1429 y = y + (float) (cos(rot) * 4.8f);
1430#else
1431 x = x + (float) (sin(rot) * 4.0);
1432 y = y + (float) (cos(rot) * 4.0);
1433#endif
1434
1435 int alpha;
1436
1437 if (y < 32.0f) {
1438 alpha = (int) (128.0f - 4.0f * (32.0f - y));
1439 } else {
1440 alpha = 128;
1441 }
1442
1443 if (alpha < 0) {
1444 alpha = 0;
1445 }
1446
1447 if (y <= 0.0f) {
1448 x = 6.0f;
1449 y = 245.0f;
1450 }
1451
1452 int cut = (int) ((245.0f - y) / 2.0f);
1453
1454 set2DSprite(GetVif1Packet(), TexManager.GetTexture("0519p", -1), CRect<int>((int) x, (int) y, 178 - cut, 191 - cut), CRect<int>(210, 0, 178, 178), (u_char) alpha);
1455
1456 float heading2 = atan2f(500.0f - x2, -107.0f - y2);
1457
1458 if (heading2 < rot2) {
1459 rot2 = rot2 - 0.05f;
1460 }
1461
1462 if (heading2 > rot2) {
1463 rot2 += 0.05f;
1464 }
1465
1466#ifdef PAL_TIMING
1467 x2 = x2 + (float) (sin(rot2) * 4.8f);
1468 y2 = y2 + (float) (cos(rot2) * 4.8f);
1469#else
1470 x2 = x2 + (float) (sin(rot2) * 4.0);
1471 y2 = y2 + (float) (cos(rot2) * 4.0);
1472#endif
1473
1474 int alpha2;
1475
1476 if (y2 < 32.0f) {
1477 alpha2 = (int) (128.0f - 4.0f * (32.0f - y2));
1478 } else {
1479 alpha2 = 128;
1480 }
1481
1482 if (alpha2 < 0) {
1483 alpha2 = 0;
1484 }
1485
1486 if (y2 <= 0.0f) {
1487 x2 = 184.0f;
1488 y2 = 245.0f;
1489 }
1490
1491 int cut2 = (int) ((245.0f - y2) / 2.0f);
1492
1493 set2DSprite(GetVif1Packet(), TexManager.GetTexture("0519p", -1), CRect<int>((int) x2, (int) y2, 178 - cut2, 191 - cut2), CRect<int>(210, 0, 178, 178), (u_char) alpha2);
1494
1495 float heading3 = atan2f(900.0f - x3, -107.0f - y3);
1496
1497 if (heading3 < rot3) {
1498 rot3 = rot3 - 0.05f;
1499 }
1500
1501 if (heading3 > rot3) {
1502 rot3 += 0.05f;
1503 }
1504
1505#ifdef PAL_TIMING
1506 x3 = x3 + (float) (sin(rot3) * 4.8f);
1507 y3 = y3 + (float) (cos(rot3) * 4.8f);
1508#else
1509 x3 = x3 + (float) (sin(rot3) * 4.0);
1510 y3 = y3 + (float) (cos(rot3) * 4.0);
1511#endif
1512
1513 int alpha3;
1514
1515 if (y3 < 32.0f) {
1516 alpha3 = (int) (128.0f - 4.0f * (32.0f - y3));
1517 } else {
1518 alpha3 = 128;
1519 }
1520
1521 if (alpha3 < 0) {
1522 alpha3 = 0;
1523 }
1524
1525 if (y3 <= 0.0f) {
1526 x3 = 362.0f;
1527 y3 = 245.0f;
1528 }
1529
1530 int cut3 = (int) ((245.0f - y3) / 2.0f);
1531
1532 set2DSprite(GetVif1Packet(), TexManager.GetTexture("0519p", -1), CRect<int>((int) x3, (int) y3, 178 - cut3, 191 - cut3), CRect<int>(210, 0, 178, 178), (u_char) alpha3);
1533 }
1534
1535 static float x = 426.0f;
1536 static float y = -221.0f;
1537 static float x2 = 726;
1538 static float y2 = -328.0f;
1539
1540 float dx, dy;
1541
1542 dy = 193.0f - y;
1543 dx = 40.0f - x;
1544 float heading = atan2f(dx, dy);
1545
1546#ifdef PAL_TIMING
1547 x = x + (float) (sin(heading) * 3.6f);
1548 y = y + (float) (cos(heading) * 3.6f);
1549#else
1550 x = x + (float) (sin(heading) * 3.0);
1551 y = y + (float) (cos(heading) * 3.0);
1552#endif
1553
1554 int alpha;
1555
1556 if (y > 148.0f) {
1557 alpha = (int) (128.0f - 4.0f * (y - 159.0f));
1558
1559 if (alpha < 0) {
1560 alpha = 0;
1561 }
1562 } else {
1563 alpha = 128;
1564 }
1565
1566 if (y >= 191.0f) {
1567 x = 426.0f;
1568 y = -221.0f;
1569 }
1570
1571 set2DSprite(GetVif1Packet(), TexManager.GetTexture("0519p", -1), CRect<int>((int) x, (int) y, 210, 221), CRect<int>(0, 0, 210, 206), (u_char) alpha);
1572
1573 float heading2 = atan2f(240.0f - x2, 193.0f - y2);
1574
1575#ifdef PAL_TIMING
1576 x2 = x2 + (float) (sin(heading2) * 3.6f);
1577 y2 = y2 + (float) (cos(heading2) * 3.6f);
1578#else
1579 x2 = x2 + (float) (sin(heading2) * 3.0);
1580 y2 = y2 + (float) (cos(heading2) * 3.0);
1581#endif
1582
1583 int alpha2;
1584
1585 if (y2 > 148.0f) {
1586 alpha2 = (int) (128.0f - 4.0f * (y2 - 159.0f));
1587
1588 if (alpha2 < 0) {
1589 alpha2 = 0;
1590 }
1591 } else {
1592 alpha2 = 128;
1593 }
1594
1595 if (y2 >= 191.0f) {
1596 x2 = 726;
1597 y2 = -328.0f;
1598 }
1599
1600 set2DSprite(GetVif1Packet(), TexManager.GetTexture("0519p", -1), CRect<int>((int) x2, (int) y2, 210, 221), CRect<int>(0, 0, 210, 206), (u_char) alpha2);
1601
1602 if (CScript__2.sprite == OPD_SPRITE_CAPTION_2) {
1603 set2DSprite(GetVif1Packet(), TexManager.GetTexture("0519p", -1), CRect<int>(40, 193, 463, 221), CRect<int>(177, 206, 463, 242), (u_char) fadeA1);
1604 }
1605}
1606#else
1607static void Setsumei() {
1608 static int cnt1 = 0;
1609 static int cntA = 0;
1610
1611 cnt1 = cnt1 + 1;
1612
1613 if (cnt1 > 30) {
1614 cnt1 = 0;
1615 cntA = cntA + 1;
1616
1617 if (cntA > 1) {
1618 cntA = 0;
1619 }
1620 }
1621
1622 static int cnt2 = 0;
1623 static int cntB = 0;
1624
1625 cnt2 = cnt2 + 1;
1626
1627 if (cnt2 > 30) {
1628 cnt2 = 0;
1629 cntB = cntB + 1;
1630
1631 if (cntB > 2) {
1632 cntB = 0;
1633 }
1634 }
1635
1636 static int fadeA1 = 128;
1637 static int fadeA2 = 0;
1638
1639 if (cntA == 0) {
1640 fadeA1 = 128;
1641
1642 if (fadeA2 > 0) {
1643 fadeA2 = fadeA2 - 8;
1644 }
1645 } else {
1646 fadeA2 = 128;
1647
1648 if (fadeA1 > 0) {
1649 fadeA1 = fadeA1 - 8;
1650 }
1651 }
1652
1653 static int fadeB1 = 128;
1654 static int fadeB2 = 0;
1655 static int fadeB3 = 0;
1656
1657 switch (cntB) {
1658 case 0:
1659 fadeB1 = 128;
1660
1661 if (fadeB2 > 0) {
1662 fadeB2 = fadeB2 - 8;
1663 }
1664
1665 if (fadeB3 > 0) {
1666 fadeB3 = fadeB3 - 8;
1667 }
1668
1669 break;
1670
1671 case 1:
1672 fadeB2 = 128;
1673
1674 if (fadeB1 > 0) {
1675 fadeB1 = fadeB1 - 8;
1676 }
1677
1678 if (fadeB3 > 0) {
1679 fadeB3 = fadeB3 - 8;
1680 }
1681
1682 break;
1683
1684 case 2:
1685 fadeB3 = 128;
1686
1687 if (fadeB1 > 0) {
1688 fadeB1 = fadeB1 - 8;
1689 }
1690
1691 if (fadeB2 > 0) {
1692 fadeB2 = fadeB2 - 8;
1693 }
1694
1695 break;
1696 }
1697
1698 set2DSprite(GetVif1Packet(), TexManager.GetTexture("0519", -1), CRect<int>(0, 0, 640, 448), CRect<int>(0, 0, 640, 448), 128);
1699 set2DSprite(GetVif1Packet(), TexManager.GetTexture("0519p", -1), CRect<int>(540, 237, 88, 119), CRect<int>(89, 206, 88, 119), (u_char) fadeA1);
1700 set2DSprite(GetVif1Packet(), TexManager.GetTexture("0519p", -1), CRect<int>(540, 237, 88, 119), CRect<int>(0, 206, 88, 119), (u_char) fadeA2);
1701 set2DSprite(GetVif1Packet(), TexManager.GetTexture("0519p", -1), CRect<int>(450, 25, 105, 105), CRect<int>(117, 448, 105, 105), (u_char) fadeB1);
1702 set2DSprite(GetVif1Packet(), TexManager.GetTexture("0519p", -1), CRect<int>(450, 25, 105, 105), CRect<int>(222, 448, 105, 105), (u_char) fadeB2);
1703 set2DSprite(GetVif1Packet(), TexManager.GetTexture("0519p", -1), CRect<int>(450, 25, 105, 105), CRect<int>(327, 448, 105, 105), (u_char) fadeB3);
1704 set2DSprite(GetVif1Packet(), TexManager.GetTexture("0519p", -1), CRect<int>(350, 130, 208, 58), CRect<int>(432, 448, 208, 58), (u_char) fadeB1);
1705 set2DSprite(GetVif1Packet(), TexManager.GetTexture("0519p", -1), CRect<int>(350, 130, 208, 58), CRect<int>(432, 506, 208, 58), (u_char) fadeB2);
1706 set2DSprite(GetVif1Packet(), TexManager.GetTexture("0519p", -1), CRect<int>(350, 130, 208, 58), CRect<int>(432, 564, 208, 58), (u_char) fadeB3);
1707 set2DSprite(GetVif1Packet(), TexManager.GetTexture("0519p", -1), CRect<int>(100, 175, 117, 56), CRect<int>(0, 325, 117, 56), (u_char) fadeA1);
1708 set2DSprite(GetVif1Packet(), TexManager.GetTexture("0519p", -1), CRect<int>(100, 175, 117, 56), CRect<int>(0, 381, 117, 56), (u_char) fadeA2);
1709
1710 if (CScript__2.sprite == OPD_SPRITE_CAPTION_1) {
1711 set2DSprite(GetVif1Packet(), TexManager.GetTexture("0519p", -1), CRect<int>(6, 229, 178, 178), CRect<int>(388, 0, 178, 178), (u_char) fadeA1);
1712 set2DSprite(GetVif1Packet(), TexManager.GetTexture("0519p", -1), CRect<int>(184, 229, 178, 178), CRect<int>(388, 0, 178, 178), (u_char) fadeA1);
1713 set2DSprite(GetVif1Packet(), TexManager.GetTexture("0519p", -1), CRect<int>(362, 229, 178, 178), CRect<int>(388, 0, 178, 178), (u_char) fadeA1);
1714 set2DSprite(GetVif1Packet(), TexManager.GetTexture("0519p", -1), CRect<int>(6, 229, 178, 178), CRect<int>(210, 0, 178, 178), (u_char) fadeA2);
1715 set2DSprite(GetVif1Packet(), TexManager.GetTexture("0519p", -1), CRect<int>(184, 229, 178, 178), CRect<int>(210, 0, 178, 178), (u_char) fadeA2);
1716 set2DSprite(GetVif1Packet(), TexManager.GetTexture("0519p", -1), CRect<int>(362, 229, 178, 178), CRect<int>(210, 0, 178, 178), (u_char) fadeA2);
1717 } else {
1718 static float x = 6.0f;
1719 static float y = 229.0f;
1720 static float rot = -1.57f;
1721 static float x2 = 184.0f;
1722 static float y2 = 229.0f;
1723 static float rot2 = 1.57f;
1724 static float x3 = 362.0f;
1725 static float y3 = 229.0f;
1726 static float rot3 = 1.57f;
1727
1728 float heading = atan2f((float) (-100.0f - x), -100.0f - y);
1729
1730 if (heading < rot) {
1731 rot = rot - 0.05f;
1732 }
1733
1734 if (heading > rot) {
1735 rot += 0.05f;
1736 }
1737
1738 x = x + (float) (sin(rot) * 4.0);
1739 y = y + (float) (cos(rot) * 4.0);
1740
1741 int alpha;
1742
1743 if (y < 32.0f) {
1744 alpha = (int) (128.0f - 4.0f * (32.0f - y));
1745 } else {
1746 alpha = 128;
1747 }
1748
1749 if (alpha < 0) {
1750 alpha = 0;
1751 }
1752
1753 if (y <= 0.0f) {
1754 x = 6.0f;
1755 y = 229.0f;
1756 }
1757
1758 int cut = (int) ((229.0f - y) / 2.0f);
1759
1760 set2DSprite(GetVif1Packet(), TexManager.GetTexture("0519p", -1), CRect<int>((int) x, (int) y, 178 - cut, 178 - cut), CRect<int>(210, 0, 178, 178), (u_char) alpha);
1761
1762 float heading2 = atan2f(500.0f - x2, -100.0f - y2);
1763
1764 if (heading2 < rot2) {
1765 rot2 = rot2 - 0.05f;
1766 }
1767
1768 if (heading2 > rot2) {
1769 rot2 += 0.05f;
1770 }
1771
1772 x2 = x2 + (float) (sin(rot2) * 4.0);
1773 y2 = y2 + (float) (cos(rot2) * 4.0);
1774
1775 int alpha2;
1776
1777 if (y2 < 32.0f) {
1778 alpha2 = (int) (128.0f - 4.0f * (32.0f - y2));
1779 } else {
1780 alpha2 = 128;
1781 }
1782
1783 if (alpha2 < 0) {
1784 alpha2 = 0;
1785 }
1786
1787 if (y2 <= 0.0f) {
1788 x2 = 184.0f;
1789 y2 = 229.0f;
1790 }
1791
1792 int cut2 = (int) ((229.0f - y2) / 2.0f);
1793
1794 set2DSprite(GetVif1Packet(), TexManager.GetTexture("0519p", -1), CRect<int>((int) x2, (int) y2, 178 - cut2, 178 - cut2), CRect<int>(210, 0, 178, 178), (u_char) alpha2);
1795
1796 float heading3 = atan2f(900.0f - x3, -100.0f - y3);
1797
1798 if (heading3 < rot3) {
1799 rot3 = rot3 - 0.05f;
1800 }
1801
1802 if (heading3 > rot3) {
1803 rot3 += 0.05f;
1804 }
1805
1806 x3 = x3 + (float) (sin(rot3) * 4.0);
1807 y3 = y3 + (float) (cos(rot3) * 4.0);
1808
1809 int alpha3;
1810
1811 if (y3 < 32.0f) {
1812 alpha3 = (int) (128.0f - 4.0f * (32.0f - y3));
1813 } else {
1814 alpha3 = 128;
1815 }
1816
1817 if (alpha3 < 0) {
1818 alpha3 = 0;
1819 }
1820
1821 if (y3 <= 0.0f) {
1822 x3 = 362.0f;
1823 y3 = 229.0f;
1824 }
1825
1826 int cut3 = (int) ((229.0f - y3) / 2.0f);
1827
1828 set2DSprite(GetVif1Packet(), TexManager.GetTexture("0519p", -1), CRect<int>((int) x3, (int) y3, 178 - cut3, 178 - cut3), CRect<int>(210, 0, 178, 178), (u_char) alpha3);
1829 }
1830
1831 static float x = 426.0f;
1832 static float y = -206.0f;
1833 static float x2 = 726;
1834 static float y2 = -306.0f;
1835
1836 float dx, dy;
1837
1838 dy = 180.0f - y;
1839 dx = 40.0f - x;
1840 float heading = atan2f(dx, dy);
1841
1842 x = x + (float) (sin(heading) * 3.0);
1843 y = y + (float) (cos(heading) * 3.0);
1844
1845 int alpha;
1846
1847 if (y > 148.0f) {
1848 alpha = (int) (128.0f - 4.0f * (y - 148.0f));
1849
1850 if (alpha < 0) {
1851 alpha = 0;
1852 }
1853 } else {
1854 alpha = 128;
1855 }
1856
1857 if (y >= 178.0f) {
1858 x = 426.0f;
1859 y = -206.0f;
1860 }
1861
1862 set2DSprite(GetVif1Packet(), TexManager.GetTexture("0519p", -1), CRect<int>((int) x, (int) y, 210, 206), CRect<int>(0, 0, 210, 206), (u_char) alpha);
1863
1864 float heading2 = atan2f(240.0f - x2, 180.0f - y2);
1865
1866 x2 = x2 + (float) (sin(heading2) * 3.0);
1867 y2 = y2 + (float) (cos(heading2) * 3.0);
1868
1869 int alpha2;
1870
1871 if (y2 > 148.0f) {
1872 alpha2 = (int) (128.0f - 4.0f * (y2 - 148.0f));
1873
1874 if (alpha2 < 0) {
1875 alpha2 = 0;
1876 }
1877 } else {
1878 alpha2 = 128;
1879 }
1880
1881 if (y2 >= 178.0f) {
1882 x2 = 726;
1883 y2 = -306.0f;
1884 }
1885
1886 set2DSprite(GetVif1Packet(), TexManager.GetTexture("0519p", -1), CRect<int>((int) x2, (int) y2, 210, 206), CRect<int>(0, 0, 210, 206), (u_char) alpha2);
1887
1888 if (CScript__2.sprite == OPD_SPRITE_CAPTION_2) {
1889 set2DSprite(GetVif1Packet(), TexManager.GetTexture("0519p", -1), CRect<int>(40, 180, 463, 206), CRect<int>(177, 206, 463, 242), (u_char) fadeA1);
1890 }
1891}
1892#endif
1893
1905static void HamonProcess() {
1906 sceVu0FVECTOR ambient;
1907
1908 sceVu0CopyVector(ambient, ambientlight);
1909
1910 for (int i = 0; i < 5; i++) {
1911 static int se[5] = {0, 0, 0, 0, 0};
1912
1913 if (!Pause && HScale[i] < 3.2f) {
1914 HScale[i] += 0.005f;
1915 }
1916
1917 if (HScale[i] > 0.0f) {
1918 if (!se[i]) {
1919 switch (i) {
1920 case 0:
1921 OpPlayVolSE(MIDI_PORT_SE_DEFAULT, 40, 46, 1.0f);
1922 break;
1923
1924 case 1:
1925 OpPlayVolSE(MIDI_PORT_SE_DEFAULT, 40, 46, 0.85f);
1926 break;
1927
1928 case 2:
1929 OpPlayVolSE(MIDI_PORT_SE_DEFAULT, 40, 46, 0.6f);
1930 break;
1931
1932 case 3:
1933 OpPlayVolSE(MIDI_PORT_SE_DEFAULT, 40, 46, 0.45f);
1934 break;
1935
1936 case 4:
1937 OpPlayVolSE(MIDI_PORT_SE_DEFAULT, 40, 46, 0.3f);
1938 break;
1939 }
1940
1941 se[i] = 1;
1942 }
1943
1944 if (i < 4) {
1945 Hamon[i]->SetScale(HScale[i], HScale[i], HScale[i]);
1946 Hamon[i]->SetPosition((float) (i - i), 0.01f + (float) i / 100.0f, 0.0f);
1947 ambient[3] = 128.0f - 40.0f * HScale[i];
1948
1949 if (ambient[3] < 0.0f) {
1950 ambient[3] = 0.0f;
1951 }
1952
1953 MGSetAmbient(ambient);
1954
1955 sceGsAlpha alpha = mgAlpha;
1956
1957 alpha.bits.a = 0;
1958 alpha.bits.b = 2;
1959 alpha.bits.c = 0;
1960 alpha.bits.d = 1;
1961 setAlphaFlag(Vif1Packet, &alpha);
1962 MGDraw(Hamon[i]);
1963 setAlphaFlag(Vif1Packet, &mgAlpha);
1964 }
1965 }
1966 }
1967
1968 MGSetAmbient(ambientlight);
1969}
CFrame * frame
virtual void LoadPackData(unsigned int *pack, char *name, CDataAlloc2< 1 > *model_alloc, CDataAlloc2< 1 > *texture_alloc)
virtual void Step()
virtual void ShadowStep()
tagMOTION_TYPE motion_type
virtual void SetRotation(float x, float y, float z)
virtual void DrawShadow()
float motion_speed
virtual void Draw()
virtual void SetPosition(float x, float y, float z)
virtual void ClothStep(int step)
char clip_enable
Definition frame.hpp:29
char remake_pending
Definition frame.hpp:31
char use_color
Definition frame.hpp:38
char fog_enable
Definition frame.hpp:33
CVisualVu1 * GetVisual()
Definition frame.cpp:1337
CFrameAttr attr
Definition frame.hpp:65
sceVu0FVECTOR position
Definition frame.hpp:76
float shadow_offset
Definition op_b.cpp:94
CFrameVu1 * collision_frame
Definition op_b.cpp:90
int handle
Definition op_b.cpp:96
int unk_34
Definition op_b.cpp:95
CFrameVu1 * shadow_frame
Definition op_b.cpp:91
CFrameVu1 * shade_frame
Definition op_b.cpp:92
CFrameVu1 * camera_frame
Definition op_b.cpp:93
virtual void FrameObjectOnOff(char *name, int on)
Definition mapobject.cpp:27
virtual void SetRotation(CVector3_f_ rotation)
s32 rotation_changed
Definition op_b.cpp:77
CFrameVu1 * frame[4]
Definition op_b.cpp:76
s32 draw_on
Definition op_b.cpp:78
virtual void SetPosition(CVector3_f_ position)
Definition object.cpp:38
Definition op_a.cpp:55
T h
Definition op_a.cpp:60
T y
Definition op_a.cpp:58
T x
Definition op_a.cpp:57
T w
Definition op_a.cpp:59
SCRIPT_OBJ obj[23]
Definition script.hpp:149
float motion_step
Definition script.hpp:152
int load_no
Definition script.hpp:143
int sprite
Definition script.hpp:141
int mes_no
Definition script.hpp:155
int mes_wait
Definition script.hpp:145
int camera_start
Definition script.hpp:135
int init_no
Definition script.hpp:144
void Initialize()
void Draw(float *origin, float size, int spread)
void Draw2(CCamera *camera, float *head, float *source)
void StopVoice(int core)
Definition sound.cpp:69
int LoadSoundFileFromPack(char *name, unsigned int *pack)
Definition sound.cpp:186
void SetVol(int port, int volume)
Definition sound.cpp:983
void Fade(int port, float step, int volume)
Definition sound.cpp:755
void Stop(int port)
Definition sound.cpp:978
void SQ_Play(int port, int seq_no)
Definition sound.cpp:495
void SetReverb(int core, int mode, int depth)
Definition sound.cpp:74
char name[32]
Definition texture.hpp:56
u_long tex0
Definition texture.hpp:57
Definition wind.hpp:12
void SetVelocity(float speed)
Definition wind.cpp:9
void SetDir(float *direction)
Definition wind.cpp:5
void Step()
Definition wind.cpp:21
char * plate
Definition op_a.cpp:180
char * strip
Definition op_a.cpp:181
int eye_bottom
Definition op_a.cpp:182
int strip_bottom
Definition op_a.cpp:188
int mouth
Definition op_a.cpp:187
int mouth_height
Definition op_a.cpp:185
int eye_height
Definition op_a.cpp:183
int eye
Definition op_a.cpp:186
int mouth_bottom
Definition op_a.cpp:184
float rotation[3]
Definition op_b.cpp:175
char * name
Definition op_b.cpp:172
float position[3]
Definition op_b.cpp:174
char * shadow_name
Definition op_b.cpp:173
int colour_ofs
Definition mdt.hpp:17
int colour_count
Definition mdt.hpp:16
float blend_step
Definition gameutil.hpp:190
sceVu0FVECTOR scale
float step
Definition script.hpp:125
int motion_end
Definition script.hpp:113
float mouth_time
Definition script.hpp:120
MOTION_STATE state
Definition gameutil.hpp:273