DCDecomp
A decompilation of Dark Cloud for the PlayStation 2
Loading...
Searching...
No Matches
titleloop.cpp
1#ifdef PAL
2#pragma argument_flag 0
3#pragma argument_flag_ones 14, 16, 20, 22, 31, 33, 45, 47, 129
4#else
5#pragma argument_flag 0
6#pragma argument_flag_ones 14, 16, 20, 22, 31, 33, 45, 47, 109, 418
7#pragma argument_flag_ones 430, 452, 453, 463, 464, 474, 475, 485, 486, 533
8#pragma argument_flag_ones 534, 537, 547, 548, 551, 561, 562, 565, 585, 586
9#pragma argument_flag_ones 589, 599, 600, 603, 615, 616, 619, 629, 630, 633
10#pragma argument_flag_ones 643, 644, 647, 657, 658, 661, 671, 672, 675, 685
11#pragma argument_flag_ones 686, 689, 699, 700, 703, 713, 714, 717, 727, 728
12#pragma argument_flag_ones 731, 744, 745, 748, 762, 768, 775
13#endif
14/* The title screen's own loop. Retail compiles it apart from the rest of the
15 title unit: its constants are a run of their own, which is why the three
16 names it shares with the code before it are spelled twice in the image. */
17
18#include "common.h"
19
20#include <libgraph.h>
21#include <libpkt.h>
22#include <libvu0.h>
23
24#include <cmath>
25#include <cstdlib>
26#include <cstring>
27
28#include "camera.hpp"
29#include "camerafollow.hpp"
30#include "character.hpp"
31#include "dataalloc.hpp"
32#include "dataread.hpp"
33#include "frame.hpp"
34#include "framevu1.hpp"
35#include "gamepad.hpp"
36#include "mathutil.hpp"
37#include "mds.hpp"
38#include "savedata.hpp"
39#include "snd.hpp"
40#include "sound.hpp"
41#include "title/cursol.hpp"
42#include "title/logo.hpp"
43#include "title/scfader.hpp"
44#include "title/sprite.hpp"
45
46/* The rectangle every 2D draw takes, declared here rather than reached through rect.h because the
47 two constructors that header states are not this file's: every rectangle here is built by one
48 that assigns x, y, w and h in that order, and rect.h's assigns them in the other. */
49template <class T>
50class CRect {
51public:
52 T x;
53 T y;
54 T w;
55 T h;
57 CRect() {}
58
59 CRect(T left, T top, T width, T height) {
60 x = left;
61 y = top;
62 w = width;
63 h = height;
64 }
65};
66
67/* One piece of scenery the third scene lays out: the model file, where it stands and how far it is
68 turned about the vertical axis, in degrees. */
69struct MAP_INFO {
70 char *name;
71 float position[3];
72 float rotation;
73};
74
75void MGStretchMoveImage(sceGsTex0 *src, const CRect<int> &src_rect, sceGsTex0 *dst, const CRect<int> &dst_rect);
76
77/* The rectangle DrawObjectVibe takes by value. It is four ints and not a CRect: the two are the
78 same fields and the name the call encodes is this one. */
79struct RECT {
80 int x;
81 int y;
82 int w;
83 int h;
84};
85
86void InitOpeningBook(u_long128 *pack, int *param);
87int OpeningBookKey();
88void OpeningBookDraw();
89
90#include "editloop.hpp"
91#include "gamemode.hpp"
92#include "main.hpp"
93#include "memcard.hpp"
94#include "menu_save.hpp"
95#include "mglib.hpp"
96#include "object.hpp"
97#include "texture.hpp"
98#include "title/dispfade.hpp"
99#include "title/op_a.hpp"
100#include "title/op_b.hpp"
101#include "title/op_c.hpp"
102#include "title/rushmovi.hpp"
103#include "title/script.hpp"
104#include "title/title.hpp"
105#include "title/titleloop.hpp"
106#include "vutext.hpp"
107#ifdef PAL
108#include "mainselect.hpp"
109#endif
110#include "wind.hpp"
111
112/* The classes this movie places in the world, declared here rather than reached through headers of
113 their own because each is another unit's to type. Only the members this file touches are named;
114 the extents are the sizes the executable gives the objects below. */
115
116/* The rippling water plane the outdoor scenes stand on. The frame is where the plane sits in the
117 world. */
118class CWater {
119public:
120 char unk_00[176];
123 CWater();
124
125 void SetVertex(float *corner0, float *corner1, float *corner2, float *corner3);
126 void SetSize(int row_count, int column_count, CDataAlloc2<1> *arena);
127 void SetParam(float speed, float damping_rate, float scale, float shift);
128 void SetColor(u_char red, u_char green, u_char blue, u_char alpha);
129 void Shake(int x, int y, float height_change);
130 void Hamon();
131 int DrawVu1(RenderInfo *info, sceVif1Packet *packet, u_long128 *parent_info);
132};
133
134/* Named rather than included, because a unit's include list is a dial on the order a call's
135 floating-point arguments are set up in and nothing here needs the definition: adding
136 renderinfo.h alone takes RushInit's three-float SetFollow out of the order the image has. */
137
138/* A frame parented to an object, which is what lets the world transform drive a model. */
139class CObjectFrame : public CObject {
140public:
141 virtual void FrameObjectOnOff(char *name, int on);
142 virtual void Draw();
143
144 void SetFrame(CFrameVu1 *frame, int level);
145};
146
147/* One piece of scenery. The movie builds a table of them, hands each its model, and drives them
148 through the object dispatch like anything else in the world. */
149class CMapObject : public CObjectFrame {
150public:
151 char unk_18[36];
152 CFrameVu1 *unk_D4;
153 char unk_4C[8];
154 float unk_E0;
155 int category_no;
156 int handle;
157 char unk_EC[4];
158
159 CMapObject();
160
161 virtual void Draw();
162
163 void Initialize();
164 void DrawShadow(int fast);
165};
166
167/* The dust the running feet kick up, declared here for the same reason. */
168class CRunEffect {
169public:
170 char unk_00[208];
171
172 CRunEffect();
173
174 void Lighting(int enabled);
175 void Set(float *origin);
176 void Step();
177 void Draw();
178};
179
180class CTexture;
181
182/* The movie's one fire, which is a light rather than a model. */
183class CFireOmni {
184public:
185 char unk_18[32];
186 sceVu0FVECTOR position;
187 s32 texture_set;
188 CTexture *core;
189 CTexture *glow;
190 s32 unk_3C;
191
192 CFireOmni();
193
194 void FireStep();
195 void FireCreate();
196
197 void SetPosition(float x, float y, float z) {
198 position[0] = 10.0f * x;
199 position[1] = 10.0f * y;
200 position[2] = 10.0f * z;
201 position[3] = 1.0f;
202 }
203
204 void DrawFire(int unused0, int unused1, CCamera *camera, float *eye, float scale, int layers, float camera_offset);
205};
206
207/* A run of frames the world draws as one. */
208class CMap {
209public:
210 char unk_00[2800];
211
212 void Initialize();
213 CMapObject *SetObject(CFrameVu1 *frame, int category_no, int handle);
214 CMapObject *SetObject(int index, CFrameVu1 *frame, int category_no, int handle);
215 CMapObject *GetObject(int index);
216 void Draw();
217};
218
219void InitializeDataBuffer();
220void set2DSprite(sceVif1Packet *packet, CTexture *texture, const CRect<int> &dst, const CRect<int> &src, u_char alpha);
221void set2DSprite(sceVif1Packet *packet, CTexture *texture, const CRect<int> &dst, const CRect<int> &src, u_char r, u_char g, u_char b, u_char a);
222
223void TiPlayVolSE(int group, int no, int voice, float volume);
224
225/* Nothing reads this, and nothing in the image stands for it: the link this file was built by
226 removed it. It is here because the compiler carries state from one definition to the next, and
227 the follow camera below is constructed with its four arguments evaluated in an order no
228 declaration that emits nothing reaches. Deleting it puts three of those four constants in the
229 wrong registers. */
230
231int Fade1;
232int Fade2;
233int Fade3;
234int Fade4;
235int Wait;
236int opcnt;
237int keywait;
238u_char brink;
239int brinkcnt;
240int EffCnt;
241
242void TitleInit(int mode) {
243 int i;
244 float scale = 750.0f;
245 float far_z = 65535.0f;
246
247 InitializeDataBuffer();
248 SetDataBuffer(&VisualData, 200000);
249 SetDataBuffer(&MotionData, 500000);
250 SetDataBuffer(&TextureData, 300000);
251 SetPacketReadBuffer(40000, 300000);
252
253 MGSetRenderInfo(scale, 4.0f, far_z);
254 Camera.SetRef(0, 0.0f, 0.0f, 0.0f);
255 /* One of these five calls is written from a named zero and the rest are not, and where
256 the name is declared is what it is for: this compiler evaluates a call's constant
257 arguments in an order set by the declarations standing above the call. */
258 float zero = 0.0f;
259 Camera.SetPos(0, zero, zero, zero);
260 FCamera.SetFollow(0.0f, 0.0f, 0.0f);
261 FCamera.SetAngle(0.0f);
262 FCamera.SetDistance(180.0f);
263 FCamera.SetHeight(2.0f);
264 MGSetBGColor(0.0f, 0.0f, 0.0f, 128.0f);
265 setbilinear(1);
266
267 LOADTEXTURE_INFO tex[] = {
268#ifndef PAL
269 {"#frame_image_mes#640#448#4", 26, 0},
270#endif
271 {"#fukidashibase#640#" HALF_BUFFER_HEIGHT_STR "#4", 26, 0},
272 {"#fontbase#512#256#1", 26, 0},
273 {"meswin/gaiji.img", 26, 0},
274 {"meswin/fuki256.img", 26, 0},
275 {"meswin/syst04.img", 26, 0},
276 {"", 0, 0}
277 };
278
279 TexManager.Initialize(16352);
280 TexManager.LoadTextureBlock(-1, tex, read_buffer);
281 LoadFileMenuData("stayframe.img", (u_int *) read_buffer);
282 TexManager.EnterFixTextureZ((u_char *) read_buffer);
283
284#ifdef PAL
285 switch (LanguageCode) {
286 case LANG_JAPANESE:
287 LoadFile("titledat/title.pak", (void *) read_buffer, 0);
288 break;
289 case LANG_ENGLISH_US:
290 LoadFile("titledat/title.pak", (void *) read_buffer, 0);
291 break;
292 case LANG_ENGLISH_UK:
293 LoadFile("titledat/title_eu.pak", (void *) read_buffer, 0);
294 break;
295 case LANG_FRENCH:
296 LoadFile("titledat/title_f.pak", (void *) read_buffer, 0);
297 break;
298 case LANG_GERMAN:
299 LoadFile("titledat/title_g.pak", (void *) read_buffer, 0);
300 break;
301 case LANG_ITALIAN:
302 LoadFile("titledat/title_i.pak", (void *) read_buffer, 0);
303 break;
304 case LANG_SPANISH:
305 LoadFile("titledat/title_s.pak", (void *) read_buffer, 0);
306 break;
307 }
308#else
309 LoadFile("titledat/title.pak", (void *) read_buffer, 0);
310#endif
311
312#ifdef PAL
313 LOADTEXTURE_INFO2 tex2[] = {
314 {(char *) "#frame_image#640#" HALF_BUFFER_HEIGHT_STR "#4", 0, 0},
315 {(char *) "#frame_image#640#" HALF_BUFFER_HEIGHT_STR "#4", 1, 0},
316 {0, 0, 0},
317 {0, 1, 0},
318 {0, 1, 0},
319 {0, 1, 0},
320 {0, 1, 0},
321 {0, 1, 0},
322 {0, 1, 0},
323 {0, 1, 0},
324 {0, 0, 0}
325 };
326
327 tex2[2].name = (char *) GetPackFile(read_buffer, "bg.img", 0);
328 tex2[3].name = (char *) GetPackFile(read_buffer, "title.img", 0);
329 tex2[4].name = (char *) GetPackFile(read_buffer, "main.img", 0);
330 tex2[5].name = (char *) GetPackFile(read_buffer, "pat01.img", 0);
331 tex2[6].name = (char *) GetPackFile(read_buffer, "pat02.img", 0);
332 tex2[7].name = (char *) GetPackFile(read_buffer, "start.img", 0);
333 tex2[8].name = (char *) GetPackFile(read_buffer, "start3.img", 0);
334 tex2[9].name = (char *) GetPackFile(read_buffer, "icon01.img", 0);
335#else
336 LOADTEXTURE_INFO2 tex2[] = {
337 {(char *) "#frame_image#640#224#4", 0, 0},
338 {(char *) "#frame_image#640#224#4", 1, 0},
339 {(char *) "#frame_image#640#224#4", 2, 0},
340 {(char *) "#frame_image#640#224#4", 3, 0},
341 {0, 0, 0},
342 {0, 1, 0},
343 {0, 1, 0},
344 {0, 1, 0},
345 {0, 1, 0},
346 {0, 1, 0},
347 {0, 1, 0},
348 {0, 1, 0},
349 {0, 1, 0},
350 {0, 0, 0}
351 };
352
353 tex2[4].name = (char *) GetPackFile(read_buffer, "bg.img", 0);
354 tex2[5].name = (char *) GetPackFile(read_buffer, "title.img", 0);
355 tex2[6].name = (char *) GetPackFile(read_buffer, "main.img", 0);
356 tex2[7].name = (char *) GetPackFile(read_buffer, "pat01.img", 0);
357 tex2[8].name = (char *) GetPackFile(read_buffer, "pat02.img", 0);
358 tex2[9].name = (char *) GetPackFile(read_buffer, "start.img", 0);
359 tex2[10].name = (char *) GetPackFile(read_buffer, "start3.img", 0);
360 tex2[11].name = (char *) GetPackFile(read_buffer, "icon01.img", 0);
361 tex2[12].name = (char *) GetPackFile(read_buffer, "trial.img", 0);
362#endif
363 TexManager.LoadTextureBlock(-1, tex2);
364
365 sceVu0FVECTOR pos;
366
367 ObjectFrame3 = LoadMDSFile(GetPackFile(read_buffer, "sky.mds", 0), 2, 0);
368 pos[0] = 0.0f;
369 pos[1] = 0.0f;
370 pos[2] = -28.0f;
371 ObjectFrame3->SetPosition(pos);
372
373 Cloud__2.LoadPackData(read_buffer, "cloud.cfg", &MotionData, 0);
374 Cloud__2.motion_type.state.time = 100.0f;
375 Cloud__2.motion_type.state.blend_step = 0.1f;
376 Cloud__2.motion_type.state.motion_no = 0;
377 Cloud__2.motion_type.state.playing_no = 0;
378 Cloud__2.motion_type.state.blending = false;
379 Cloud__2.motion_no = 0;
380 Cloud__2.SetPosition(0.0f, 0.0f, -5.0f);
381
382 Logo.LoadPackData(read_buffer, "logo.cfg", &MotionData, 0);
383 Logo.motion_type.state.time = 1.0f;
384 Logo.motion_type.state.blend_step = 0.1f;
385 Logo.motion_type.state.motion_no = 0;
387 Logo.motion_type.state.blending = false;
388 Logo.motion_no = 0;
389
390 char *name[9] = {
391 "logo_p1.cfg", "logo_p2.cfg", "logo_p3.cfg", "logo_p4.cfg", "logo_p5.cfg",
392 "logo_p6.cfg", "logo_p7.cfg", "logo_p8.cfg", "logo_p9.cfg"};
393
394 for (i = 0; i < 9; i++) {
395 Spark[i].LoadPackData(read_buffer, name[i], &MotionData, 0);
396 Spark[i].motion_type.state.time = 1.0f;
397 Spark[i].motion_type.state.blend_step = 0.1f;
398 Spark[i].motion_type.state.motion_no = 0;
399 Spark[i].motion_type.state.playing_no = 0;
400 Spark[i].motion_type.state.blending = false;
401 Spark[i].motion_no = 0;
402 Spark[i].SetPosition(0.0f, 11.599f, -19.099f);
403 }
404
405 CSnd.SetReverb(0, 4, 5);
406 CSnd.SetReverb(1, 0, 0);
407 CSnd.LoadSoundFileFromPack("title.txt", read_buffer);
408 CSnd.SetVol(MIDI_PORT_SE_TITLE, 256);
409 CSnd.SetVol(MIDI_PORT_SE_DEFAULT, 256);
410 CSnd.SetVol(MIDI_PORT_UNK_D, 256);
411 CSnd.SetVol(MIDI_PORT_SE_SPECIAL, 256);
412 CSnd.SQ_Play(MIDI_PORT_AMBIENT, 0);
413
414 Fade1 = Fade2 = Fade3 = Fade4 = Wait = 0;
415 opcnt = 0;
416 keywait = 0;
417 brinkcnt = 0;
418 brink = 0;
419 EffCnt = 0;
420 CProcess.no = TITLE_STEP_FADE_IN;
421 CFade.value = 0;
422
423 CSprite.Init();
424 CLogo.Init();
425 CCursol.Init();
426
427 if (mode == 1) {
428 CCursol.select = TITLE_MENU_LOAD;
429 CCursol.Set(316.0f);
430
431 for (i = 0; i < 10; i++) {
432 CCursol.Move();
433 }
434 }
435
436 GamePad.SetAutoRepeat(PAD_UP | PAD_DOWN, 30, 9);
437 GamePad.MenuModeOn(120);
438}
439
440int TitleLoop() {
441 sceVu0FVECTOR pos;
442 sceVu0FMATRIX matrix;
443 int i;
444
445 sceVif1PkCall(Vif1Packet, (u_long128 *) Vu_prog0f, 0);
446 FCamera.GetPos(pos);
447 FCamera.Step(1);
448 FCamera.GetCameraMatrix(matrix);
449 MGSetViewMatrix(matrix, pos);
450 Cloud__2.Step();
451
452 switch (CProcess.no) {
453 case TITLE_STEP_FADE_IN:
454 if (CFade.In()) {
455 CProcess.no = TITLE_STEP_WAIT;
456 }
457
458 if (GamePad.Down(PAD_START) && EffCnt > 16) {
459 CFade.Skip();
460 CProcess.no = TITLE_STEP_LOGO;
461 }
462
463 if (EffCnt < 100) {
464 EffCnt++;
465 }
466
467 break;
468
469 case TITLE_STEP_RETURN_FADE_IN:
470 if (CFade.In2()) {
471 CProcess.no = TITLE_STEP_MENU;
472 }
473
474 break;
475
476 case TITLE_STEP_WAIT:
477 if (Wait < 120) {
478 Wait++;
479 } else {
480 CProcess.no = TITLE_STEP_LOGO;
481 }
482
483 if (GamePad.Down(PAD_START)) {
484 CProcess.no = TITLE_STEP_LOGO;
485 }
486
487 break;
488
489 case TITLE_STEP_LOGO:
490 if (CSprite.Se() == 0) {
491 TiPlayVolSE(MIDI_PORT_SE_DEFAULT, 38, 21, 1.0f);
492 }
493
494 CSprite.Move();
495
496 if (GamePad.Down(PAD_START)) {
497 Logo.motion_type.state.time = 116.0f;
498 Fade1 = 128;
499 CSprite.x[0] = 700.0f;
500 }
501
502 if (CSprite.x[0] > 100.0f) {
503 if (Logo.motion_type.state.time < 116.0f) {
504 for (i = 0; i < 9; i++) {
505 Spark[i].Step();
506 }
507
508 Logo.Step();
509 CLogo.Fade();
510 } else {
511 if (Fade1 < 128) {
512 Fade1++;
513 } else {
514 Fade2 = (Fade2 + 2) & 0x7f;
515 keywait++;
516
517 if (keywait >= 500) {
518 keywait = 500;
519 }
520 }
521
522 CLogo.Move();
523 }
524
525 if (Fade1 > 127 && GamePad.Down(PAD_START)) {
526 TiPlayVolSE(MIDI_PORT_UNK_D, 122, 25, 1.0f);
527 CProcess.no = TITLE_STEP_MENU;
528 opcnt = 0;
529 }
530
531 if (Fade1 > 127) {
532 if (opcnt > 1800) {
533 CCursol.select = TITLE_MENU_ATTRACT;
534 CProcess.no = TITLE_STEP_ATTRACT_FADE_OUT;
535 } else {
536 opcnt++;
537 }
538 }
539 }
540
541 break;
542
543 case TITLE_STEP_MENU:
544 CLogo.Move();
545
546 if (CCursol.Move()) {
547 if (GamePad.Down(PAD_UP)) {
548 CCursol.select--;
549 opcnt = 0;
550 TiPlayVolSE(MIDI_PORT_UNK_D, 122, 24, 1.0f);
551 }
552
553 if (GamePad.Down(PAD_DOWN)) {
554 CCursol.select++;
555 opcnt = 0;
556 TiPlayVolSE(MIDI_PORT_UNK_D, 122, 24, 1.0f);
557 }
558
559 if (CCursol.select < 0) {
560 CCursol.select = TITLE_MENU_OPTION;
561 }
562
563 if (CCursol.select > 2) {
564 CCursol.select = TITLE_MENU_NEW_GAME;
565 }
566
567 switch (CCursol.select) {
568#ifdef PAL
569 case TITLE_MENU_NEW_GAME:
570 CCursol.Set(304.0f);
571#else
572 case TITLE_MENU_NEW_GAME:
573 CCursol.Set(288.0f);
574#endif
575 break;
576#ifdef PAL
577 case TITLE_MENU_LOAD:
578 CCursol.Set(332.0f);
579#else
580 case TITLE_MENU_LOAD:
581 CCursol.Set(316.0f);
582#endif
583 break;
584#ifdef PAL
585 case TITLE_MENU_OPTION:
586 CCursol.Set(364.0f);
587#else
588 case TITLE_MENU_OPTION:
589 CCursol.Set(348.0f);
590#endif
591 break;
592 }
593
594 if (GamePad.Down(PAD_START) || GamePad.Down(PAD_CROSS)) {
595 TiPlayVolSE(MIDI_PORT_SE_DEFAULT, 38, 20, 1.0f);
596 CProcess.no = TITLE_STEP_MENU_BLINK;
597 opcnt = 0;
598 }
599
600 if (GamePad.Down(PAD_CIRCLE)) {
601 Fade1 = Fade2 = Fade3 = Fade4 = 0;
602 CSprite.Init();
603 CLogo.Init();
604 CCursol.Init();
605 CProcess.no = TITLE_STEP_LOGO;
606 opcnt = 0;
607 }
608
609 if (opcnt > 1800) {
610 CCursol.select = TITLE_MENU_ATTRACT;
611 CProcess.no = TITLE_STEP_ATTRACT_FADE_OUT;
612 } else {
613 opcnt++;
614 }
615 }
616
617 break;
618
619 case TITLE_STEP_MENU_BLINK:
620 CLogo.Move();
621 brink = 1;
622 brinkcnt++;
623
624 if (brinkcnt > 60) {
625 CProcess.no = TITLE_STEP_MENU_FADE_OUT;
626 }
627
628 break;
629
630 case TITLE_STEP_MENU_FADE_OUT:
631 brinkcnt++;
632
633 if (CFade.Out()) {
634 switch (CCursol.GetSelect()) {
635 case TITLE_MENU_NEW_GAME:
636 CProcess.no = TITLE_STEP_OPENING_BOOK_INIT;
637 break;
638 case TITLE_MENU_LOAD:
639 CProcess.no = TITLE_STEP_SAVE_INIT;
640 break;
641 case TITLE_MENU_OPTION:
642 CProcess.no = TITLE_STEP_OPTION_INIT;
643 break;
644 }
645 }
646
647 break;
648
649 case TITLE_STEP_ATTRACT_FADE_OUT:
650 if (CFade.Out()) {
651 SndStopAllSe();
652 CSnd.Stop(MIDI_PORT_BGM);
653 CSnd.StopVoice(0);
654 CProcess.no = TITLE_STEP_EXIT;
655 }
656
657 break;
658
659 case TITLE_STEP_OPENING_BOOK_INIT:
660 SndStopAllSe();
661 CSnd.Stop(MIDI_PORT_BGM);
662 CSnd.StopVoice(0);
663 CSnd.SetReverb(0, 4, 40);
664 CSnd.SetVol(MIDI_PORT_SE_TITLE, 256);
665 CSnd.SetVol(MIDI_PORT_SE_DEFAULT, 256);
666 CSnd.SetVol(MIDI_PORT_UNK_D, 256);
667 CSnd.SetVol(MIDI_PORT_SE_SPECIAL, 256);
668 CSnd.SQ_Play(MIDI_PORT_BGM, 0);
669 TiPlayVolSE(MIDI_PORT_SE_TITLE, 16, 24, 0.5f);
670 {
671 int book[2] = {2, 60};
672
673 InitOpeningBook((u_long128 *) read_buffer, book);
674 }
675 CProcess.no = TITLE_STEP_OPENING_BOOK;
676 break;
677
678 case TITLE_STEP_OPENING_BOOK:
679 if (OpeningBookKey()) {
680 CProcess.no = TITLE_STEP_EXIT;
681 }
682
683 break;
684
685 case TITLE_STEP_SAVE_INIT:
686 InitMenuSave(SAVE_MENU_MODE_LOAD, 2, 0);
687 CProcess.no = TITLE_STEP_SAVE;
688 break;
689
690 case TITLE_STEP_SAVE:
691 switch (MenuSaveKey()) {
692 case MENU_SAVE_RUNNING:
693 CFade.In();
694 break;
695 case MENU_SAVE_LOADED:
696 /* CSaveData::map_no is private and retail reaches it from another
697 translation unit, so this is the offset main.cpp uses rather than
698 a getter the class does not have. */
699 MapJump(*(s32 *) ((char *) SaveData + 0x1C8), -1);
700 CProcess.no = TITLE_STEP_EXIT;
701 break;
702 case MENU_SAVE_CLOSED:
703 brink = 0;
704 CFade.value = 0;
705 CProcess.no = TITLE_STEP_RETURN_FADE_IN;
706 break;
707 }
708
709 break;
710
711 case TITLE_STEP_OPTION_INIT:
712 InitMenuOption(OPTION_OPEN_TITLE, 2, 0);
713 CProcess.no = TITLE_STEP_OPTION;
714 break;
715
716 case TITLE_STEP_OPTION:
717 CFade.In();
718
719 if (MenuOptionKey()) {
720 brink = 0;
721 CFade.value = 0;
722 CProcess.no = TITLE_STEP_RETURN_FADE_IN;
723 }
724
725 break;
726
727 case TITLE_STEP_EXIT:
728 SndStopAllSe();
729 CSnd.Stop(MIDI_PORT_BGM);
730 CSnd.StopVoice(0);
731 return CCursol.GetSelect() + 1;
732 }
733
734 TitleDraw();
735 CSnd.Step();
736 return 0;
737}
738
739/* A title menu row's height on screen, laid out for NTSC's picture and lowered to stay centred in
740 the taller PAL one. */
741#define MENU_Y(y) ((y) + (SCREEN_HEIGHT - 448) / 2)
742
743void TitleDraw() {
744 sceVu0FVECTOR light0 = {2.4578f, 9.9294f, -2.8074f, 0.0f};
745 sceVu0FVECTOR light1 = {4.6086f, -10.4028f, -0.8286f, 0.0f};
746 sceVu0FVECTOR light2 = {0.0f, 0.0f, -10.0f, 0.0f};
747 sceVu0FMATRIX light;
748 sceVu0FMATRIX color = {
749 {191.0f, 105.0f, 76.0f, 128.0f},
750 {63.0f, 51.0f, 127.0f, 128.0f},
751 {40.0f, 30.0f, 30.0f, 128.0f},
752 {0.0f, 0.0f, 0.0f, 0.0f }
753 };
754 sceVu0FVECTOR light0b = {0.0f, 6.0f, -8.0f, 0.0f};
755 sceVu0FVECTOR light1b = {0.0f, 0.0f, 0.0f, 0.0f};
756 sceVu0FVECTOR light2b = {0.0f, 0.0f, 0.0f, 0.0f};
757 sceVu0FMATRIX lightb;
758 sceVu0FMATRIX colorb = {
759 {128.0f, 128.0f, 112.0f, 128.0f},
760 {0.0f, 0.0f, 0.0f, 0.0f },
761 {0.0f, 0.0f, 0.0f, 0.0f },
762 {0.0f, 0.0f, 0.0f, 0.0f }
763 };
764 sceVu0FVECTOR ambient = {0.0f, 0.0f, 0.0f, 100.0f};
765 int i;
766
767 if (CProcess.no == TITLE_STEP_FADE_IN || (CProcess.no == TITLE_STEP_MENU_FADE_OUT && CCursol.GetSelect() == TITLE_MENU_NEW_GAME) || CProcess.no == TITLE_STEP_ATTRACT_FADE_OUT) {
768 ambient[3] = (float) CFade.Get(128);
769 } else {
770 ambient[3] = 128.0f;
771 }
772
773 MGSetAmbient(ambient);
774
775 sceVu0Normalize(light0, light0);
776 sceVu0Normalize(light1, light1);
777 sceVu0Normalize(light2, light2);
778 sceVu0NormalLightMatrix(light, light0, light1, light2);
779 MGSetPLight(light, color);
780
781 if (CProcess.no != TITLE_STEP_OPENING_BOOK && CProcess.no != TITLE_STEP_EXIT) {
782 static float rot[4] = {0.0f, 0.0f, 0.0f, 0.0f};
783
784 TexManager.ReloadTexture(GetVif1Packet(), 0);
785 rot[1] += 0.001f;
786
787 if (rot[1] > 3.14f) {
788 rot[1] -= 6.28f;
789 }
790
791 ObjectFrame3->SetRotation(rot[0], rot[1], rot[2]);
792 MGDraw(ObjectFrame3);
793 }
794
795 if (CProcess.no != TITLE_STEP_OPENING_BOOK && CProcess.no != TITLE_STEP_EXIT) {
796 TexManager.ReloadTexture(GetVif1Packet(), 1);
797
798 if (CProcess.no == TITLE_STEP_FADE_IN || (CProcess.no == TITLE_STEP_MENU_FADE_OUT && CCursol.GetSelect() == TITLE_MENU_NEW_GAME) || CProcess.no == TITLE_STEP_ATTRACT_FADE_OUT) {
799 ambient[3] = (float) CFade.Get(100);
800 } else {
801 ambient[3] = 100.0f;
802 }
803
804 MGSetAmbient(ambient);
805 Cloud__2.Draw();
806 }
807
808 if (CProcess.no != TITLE_STEP_FADE_IN || CFade.Get(128) >= 4) {
809 sceGsTest test;
810
811 MGSetGsTEST(&test);
812 test.bits.date = 0;
813 test.bits.ate = 0;
814 MGSetGsTEST(&test);
815 setbilinear(1);
816
817 set2DSprite(GetVif1Packet(), TexManager.GetTexture("frame_image", -1), CRect<int>(0, 0, 640, 85), CRect<int>(1, 0, 639, 45), 112);
818
819 for (i = 1; i < 4; i++) {
820 set2DSprite(GetVif1Packet(), TexManager.GetTexture("frame_image", -1), CRect<int>(0, i * 84 + 1, 640, 84), CRect<int>(1, i * 42, 639, 45), 114);
821 }
822
823 set2DSprite(GetVif1Packet(), TexManager.GetTexture("frame_image", -1), CRect<int>(0, 336, 640, 105), CRect<int>(1, 167, 639, 57), 114);
824#ifdef PAL
825 set2DSprite(GetVif1Packet(), TexManager.GetTexture("frame_image", -1), CRect<int>(0, 441, 640, 39), CRect<int>(1, 220, 639, 19), 114);
826#else
827 set2DSprite(GetVif1Packet(), TexManager.GetTexture("frame_image", -1), CRect<int>(0, 440, 640, 8), CRect<int>(1, 220, 639, 3), 114);
828#endif
829
830 MGSetGsTEST(0);
831 }
832
833 {
834 sceGsTex0 tex0;
835 sceGsTex0 image;
836
837 MGGetFBuffTex(&tex0);
838 image = *(sceGsTex0 *) &TexManager.GetTexture("frame_image", -1)->tex0;
839 tex0.PSM = 1;
840 MGStretchMoveImage(&tex0, CRect<int>(0, 0, 10240, SCREEN_HALF_HEIGHT * 16), &image, CRect<int>(0, 0, 10240, SCREEN_HALF_HEIGHT * 16));
841 }
842 MGClearZBuffer(0);
843
844 switch (CProcess.no) {
845 case TITLE_STEP_LOGO:
846 case TITLE_STEP_RETURN_FADE_IN:
847 case TITLE_STEP_MENU:
848 case TITLE_STEP_MENU_BLINK:
849 case TITLE_STEP_MENU_FADE_OUT:
850 case TITLE_STEP_ATTRACT_FADE_OUT:
851 sceVu0Normalize(light0b, light0b);
852 sceVu0Normalize(light1b, light1b);
853 sceVu0Normalize(light2b, light2b);
854 sceVu0NormalLightMatrix(lightb, light0b, light1b, light2b);
855 MGSetPLight(lightb, colorb);
857 CLogo.Draw();
858
859 set2DSprite(GetVif1Packet(), TexManager.GetTexture("main", -1), CRect<int>(0, 62, 288, 170), CRect<int>(0, 0, 288, 170), (u_char) CFade.Get(Fade4));
860 set2DSprite(GetVif1Packet(), TexManager.GetTexture("main", -1), CRect<int>(288, 112, 72, 190), CRect<int>(288, 50, 72, 190), (u_char) CFade.Get(Fade4));
861 set2DSprite(GetVif1Packet(), TexManager.GetTexture("main", -1), CRect<int>(360, 142, 412, 160), CRect<int>(360, 80, 412, 160), (u_char) CFade.Get(Fade4));
862
863 ambient[3] = (float) CFade.Get(128);
864 MGSetAmbient(ambient);
865
866 if (CFade.Get(128) == 128) {
867 CSprite.Draw();
868 }
869
870 set2DSprite(GetVif1Packet(), TexManager.GetTexture("start", -1), CRect<int>(64, MENU_Y(362), 512, 64), CRect<int>(0, 64, 512, 64), (u_char) CFade.Get(Fade1));
871
872 if (CProcess.no == TITLE_STEP_LOGO) {
873 set2DSprite(GetVif1Packet(), TexManager.GetTexture("start", -1), CRect<int>(64, MENU_Y(296), 512, 64), CRect<int>(0, 0, 512, 64), (u_char) CFade.Get(Fade2));
874 } else {
875 static int br = 128;
876
877 if (brink) {
878 if (brinkcnt % 3 == 0) {
879 br = 32;
880 } else {
881 br = 128;
882 }
883 } else {
884 br = 128;
885 }
886
887 switch (CCursol.GetSelect()) {
888 case TITLE_MENU_NEW_GAME:
889 set2DSprite(GetVif1Packet(), TexManager.GetTexture("start3", -1), CRect<int>(193, MENU_Y(280), 256, 32), CRect<int>(0, 0, 256, 32), (u_char) CFade.Get(br));
890 set2DSprite(GetVif1Packet(), TexManager.GetTexture("start3", -1), CRect<int>(193, MENU_Y(312), 256, 32), CRect<int>(0, 32, 256, 32), (u_char) CFade.Get(32));
891 set2DSprite(GetVif1Packet(), TexManager.GetTexture("start3", -1), CRect<int>(193, MENU_Y(344), 256, 32), CRect<int>(0, 64, 256, 32), (u_char) CFade.Get(32));
892 break;
893
894 case TITLE_MENU_LOAD:
895 set2DSprite(GetVif1Packet(), TexManager.GetTexture("start3", -1), CRect<int>(193, MENU_Y(280), 256, 32), CRect<int>(0, 0, 256, 32), (u_char) CFade.Get(32));
896 set2DSprite(GetVif1Packet(), TexManager.GetTexture("start3", -1), CRect<int>(193, MENU_Y(312), 256, 32), CRect<int>(0, 32, 256, 32), (u_char) CFade.Get(br));
897 set2DSprite(GetVif1Packet(), TexManager.GetTexture("start3", -1), CRect<int>(193, MENU_Y(344), 256, 32), CRect<int>(0, 64, 256, 32), (u_char) CFade.Get(32));
898 break;
899
900 case TITLE_MENU_OPTION:
901 set2DSprite(GetVif1Packet(), TexManager.GetTexture("start3", -1), CRect<int>(193, MENU_Y(280), 256, 32), CRect<int>(0, 0, 256, 32), (u_char) CFade.Get(32));
902 set2DSprite(GetVif1Packet(), TexManager.GetTexture("start3", -1), CRect<int>(193, MENU_Y(312), 256, 32), CRect<int>(0, 32, 256, 32), (u_char) CFade.Get(32));
903 set2DSprite(GetVif1Packet(), TexManager.GetTexture("start3", -1), CRect<int>(193, MENU_Y(344), 256, 32), CRect<int>(0, 64, 256, 32), (u_char) CFade.Get(br));
904 break;
905 }
906
907 if (CProcess.no != TITLE_STEP_ATTRACT_FADE_OUT) {
908 setbilinear(0);
909 CursorVibeCnt++;
910
911 RECT rect = {0, 0, 32, 32};
912
913 DrawObjectVibe(225, CCursol.GetPos(), TexManager.GetTexture("icon01", -1), rect, 128, CFade.Get(128));
914 setbilinear(1);
915 }
916 }
917
918 break;
919
920 case TITLE_STEP_OPENING_BOOK:
921 TexManager.ReloadTexture(GetVif1Packet(), 2);
922 OpeningBookDraw();
923 break;
924
925 case TITLE_STEP_SAVE:
926 TexManager.ReloadTexture(GetVif1Packet(), 2);
927 DrawMenuSave(0);
928 break;
929
930 case TITLE_STEP_OPTION:
931 TexManager.ReloadTexture(GetVif1Packet(), 2);
932 DrawMenuOption();
933 break;
934 }
935
936 {
937 sceGsTex0 backtex;
938
939 MGGetFBuffBackTex(&backtex);
940
941 CTexture texture;
942
943 texture.tex0 = *(u_long *) &backtex;
944 set2DSprite(Vif1Packet, &texture, CRect<int>(0, 0, 640, 448), CRect<int>(0, 0, 640, 224), 128, 128, 128, 35);
945 }
946}
void SetHeight(float height)
void SetFollow(float x, float y, float z)
void SetDistance(float distance)
virtual void Step(int steps)
void SetAngle(float angle)
void GetCameraMatrix(float(*matrix)[4])
Definition camera.cpp:153
void SetRef(CFrame *parent, float x, float y, float z)
Definition camera.cpp:124
void SetPos(CFrame *parent, float x, float y, float z)
Definition camera.cpp:103
void GetPos(float *pos)
Definition camera.cpp:230
virtual void LoadPackData(unsigned int *pack, char *name, CDataAlloc2< 1 > *model_alloc, CDataAlloc2< 1 > *texture_alloc)
virtual void Step()
tagMOTION_TYPE motion_type
virtual void Draw()
virtual void SetPosition(float x, float y, float z)
void Set(float new_target_y)
Definition cursol.cpp:172
int Move()
Definition cursol.cpp:29
int GetPos()
Definition cursol.cpp:180
int GetSelect()
Definition cursol.cpp:176
int select
Definition cursol.hpp:27
void Init()
Definition cursol.cpp:14
CTexture * core
Definition op_a.cpp:110
s32 texture_set
Definition op_a.cpp:109
sceVu0FVECTOR position
Definition op_c.cpp:109
CTexture * glow
Definition op_a.cpp:111
int Down(int mask)
Definition gamepad.cpp:583
void MenuModeOn(int threshold)
Definition gamepad.cpp:613
void SetAutoRepeat(int mask, int initial_delay, int repeat_delay)
Definition gamepad.cpp:485
Definition logo.hpp:10
void Sparkdraw(float time)
Definition logo.cpp:79
void Init()
Definition logo.cpp:26
void Fade()
Definition logo.cpp:51
void Move()
Definition logo.cpp:142
void Draw()
Definition logo.cpp:121
int handle
Definition op_b.cpp:96
int category_no
Definition title.cpp:134
Definition op_a.cpp:90
CFrameVu1 * frame[4]
Definition op_b.cpp:76
int no
Definition title.hpp:188
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
void Lighting(int on)
void Step()
void Set(float *position)
void Draw()
void Skip()
Definition scfader.cpp:57
int In()
Definition scfader.cpp:3
int In2()
Definition scfader.cpp:17
int Get(int limit)
Definition scfader.cpp:45
int value
Definition scfader.hpp:10
int Out()
Definition scfader.cpp:31
void StopVoice(int core)
Definition sound.cpp:69
int LoadSoundFileFromPack(char *name, unsigned int *pack)
Definition sound.cpp:186
void Step()
Definition sound.cpp:814
void SetVol(int port, int volume)
Definition sound.cpp:983
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
void Init()
Definition sprite.cpp:53
float x[12]
Definition sprite.hpp:7
int Se()
Definition sprite.cpp:150
void Move()
Definition sprite.cpp:65
void Draw()
Definition sprite.cpp:126
char name[32]
Definition texture.hpp:56
u_long tex0
Definition texture.hpp:57
u_int * packet[3]
Definition op_c.cpp:143
CFrameVu1 frame
Definition op_c.cpp:151
float rotation
Definition rushmovi.cpp:211
char * name
Definition rushmovi.cpp:209
float position[3]
Definition rushmovi.cpp:210
float blend_step
Definition gameutil.hpp:190
Definition title.cpp:61
int w
Definition title.cpp:64
int h
Definition title.cpp:65
int y
Definition title.cpp:63
int x
Definition title.cpp:62
MOTION_STATE state
Definition gameutil.hpp:273