DCDecomp
A decompilation of Dark Cloud for the PlayStation 2
Loading...
Searching...
No Matches
langset.cpp
1#include "langset.hpp"
2
3#include <libpkt.h>
4
5#include "dataalloc.hpp"
6#include "dataread.hpp"
7#include "dataset.hpp"
8#include "fader.hpp"
9#include "gamepad.hpp"
10#include "mainselect.hpp"
11#include "mglib.hpp"
12#include "rect.hpp"
13#include "snd.hpp"
14#include "texture.hpp"
15#include "vutext.hpp"
16
17Fader Fade;
18int Cursor;
19int Proc;
20
22int Alpha[5];
23
24void LangsetInit() {
25 InitializeDataBuffer();
26 SetDataBuffer(&VisualData, 200000);
27 SetDataBuffer(&MotionData, 500000);
28 SetDataBuffer(&TextureData, 300000);
29 SetPacketReadBuffer(40000, 300000);
30 MGSetBGColor(0.0f, 0.0f, 0.0f, 128.0f);
31 LOADTEXTURE_INFO textures[] = {
32 {"#frame_image_mes#640#" SCREEN_HEIGHT_STR "#4", 26, 0},
33 {"#fukidashibase#640#" HALF_BUFFER_HEIGHT_STR "#4", 26, 0},
34 {"#fontbase#512#256#1", 26, 0},
35 {"titledat/lang_set.img", 0, 0},
36 {"", 0, 0},
37 };
38 TexManager.Initialize(0x3FE0);
39 TexManager.LoadTextureBlock(-1, textures, read_buffer);
40 GamePad.SetAutoRepeat(PAD_UP | PAD_DOWN, 30, 9);
41 GamePad.MenuModeOn(120);
42 Fade.value = 0;
43 Cursor = 0;
44 Proc = LANGSET_FADE_IN;
45}
46
47int LangsetLoop() {
48 sceVif1PkCall(Vif1Packet, (u_long128 *) Vu_prog0f, 0);
49 sceVif1PkTerminate(Vif1Packet);
50
51 switch (Proc) {
52 case LANGSET_FADE_IN:
53 if (Fade.In() != 0) {
54 Proc = LANGSET_SELECT;
55 }
56
57 break;
58 case LANGSET_SELECT:
59 if (LangsetProc() != 0) {
60 Proc = LANGSET_FADE_OUT;
61 }
62
63 break;
65 if (Fade.Out() != 0) {
66 // The first two codes are not offered here, so the cursor
67 // counts from the third.
68 LanguageCode = Cursor + 2;
69 return 1;
70 }
71
72 break;
73 }
74
75 LangsetDraw();
76 return 0;
77}
78
79int LangsetProc() {
80 if (GamePad.Down(PAD_UP) != 0) {
81 Cursor--;
82 }
83
84 if (GamePad.Down(PAD_DOWN) != 0) {
85 Cursor++;
86 }
87
88 if (Cursor < 0) {
89 Cursor = 4;
90 }
91
92 if (Cursor > 4) {
93 Cursor = 0;
94 }
95
96 if (GamePad.Down(PAD_START) != 0 || GamePad.Down(PAD_CROSS) != 0) {
97 return 1;
98 }
99
100 return 0;
101}
102
106static inline void SetRect(RECT *rect, int x, int y, int width, int height) {
107 rect->x = x;
108 rect->y = y;
109 rect->width = width;
110 rect->height = height;
111}
112
113void LangsetDraw() {
114 RECT rect;
115 int language;
116 int alpha;
117
118 setbilinear(1);
119
120 for (language = 0; language < 5; language++) {
121 Alpha[language] = 0x40;
122 }
123
124 Alpha[Cursor] = 0x80;
125
126 TexManager.ReloadTexture(GetVif1Packet(), 0);
127 SetRect(&rect, 0x9E, 0, 0x144, 0x5A);
128 alpha = Fade.Get(0x80);
129 set2DSprite(GetVif1Packet(), TexManager.GetTexture("lang_set", -1), &rect, &rect, alpha);
130 SetRect(&rect, 0x9E, 0x5F, 0x144, 0x3C);
131 alpha = Fade.Get(Alpha[0]);
132 set2DSprite(GetVif1Packet(), TexManager.GetTexture("lang_set", -1), &rect, &rect, alpha);
133 SetRect(&rect, 0x9E, 0x9C, 0x144, 0x3C);
134 alpha = Fade.Get(Alpha[1]);
135 set2DSprite(GetVif1Packet(), TexManager.GetTexture("lang_set", -1), &rect, &rect, alpha);
136 SetRect(&rect, 0x9E, 0xD9, 0x144, 0x3C);
137 alpha = Fade.Get(Alpha[2]);
138 set2DSprite(GetVif1Packet(), TexManager.GetTexture("lang_set", -1), &rect, &rect, alpha);
139 SetRect(&rect, 0x9E, 0x116, 0x144, 0x3C);
140 alpha = Fade.Get(Alpha[3]);
141 set2DSprite(GetVif1Packet(), TexManager.GetTexture("lang_set", -1), &rect, &rect, alpha);
142 SetRect(&rect, 0x9E, 0x153, 0x144, 0x3C);
143 alpha = Fade.Get(Alpha[4]);
144 set2DSprite(GetVif1Packet(), TexManager.GetTexture("lang_set", -1), &rect, &rect, alpha);
145}
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 fader.hpp:8
int Get(int maximum)
Definition fader.cpp:26
int In()
Definition fader.cpp:3
int value
Definition fader.hpp:10
int Out()
Definition fader.cpp:17
@ LANGSET_FADE_OUT
Definition langset.hpp:17
@ LANGSET_SELECT
Definition langset.hpp:16
@ LANGSET_FADE_IN
Definition langset.hpp:15
Definition title.cpp:61
s32 width
Definition rect.hpp:36
s32 height
Definition rect.hpp:37
int y
Definition title.cpp:63
int x
Definition title.cpp:62