1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
|
/**
* d_error_msg.cpp
* Disk Error Message screen handler
*/
#include "d/dolzel.h" // IWYU pragma: keep
#include <string>
#include "JSystem/J2DGraph/J2DOrthoGraph.h"
#include "JSystem/J2DGraph/J2DPicture.h"
#include "JSystem/J2DGraph/J2DTextBox.h"
#include "JSystem/JUtility/JUTResFont.h"
#include "JSystem/JUtility/JUTTexture.h"
#include "d/d_error_msg.h"
#include "m_Do/m_Do_Reset.h"
#include "m_Do/m_Do_graphic.h"
#include "assets/black_tex.h"
#include "assets/msg_data.h"
#if VERSION == VERSION_GCN_PAL
#include "assets/msg_data_ge.h"
#include "assets/msg_data_fr.h"
#include "assets/msg_data_sp.h"
#include "assets/msg_data_it.h"
#endif
#include "assets/font_data.h"
#define MSG_READING_DISC 0
#define MSG_COVER_OPEN 1
#define MSG_NO_DISK 2
#define MSG_WRONG_DISK 3
#define MSG_READ_ERROR 4
#define MSG_FATAL_ERROR 5
// made up
struct BMG_INF1 : JUTDataBlockHeader {
/* 0x08 */ u8 m08[0x10 - 0x08];
/* 0x10 */ u32 entries[6];
};
#if (VERSION == VERSION_GCN_JPN) || (VERSION == VERSION_WII_JPN)
#define LINE_HEIGHT 30.0f
#define LINE_SPACE 30.0f
#define CHAR_SPACE 3.0f
#else
#define LINE_HEIGHT 23.0f
#define LINE_SPACE 23.0f
#define CHAR_SPACE 1.0f
#endif
static void messageSet(u32 status, bool i_drawBg) {
BMG_INF1* inf1;
const char* msg_p;
#if VERSION == VERSION_GCN_PAL
if (dComIfGs_getPalLanguage() == dSv_player_config_c::LANGUAGE_GERMAN) {
inf1 = (BMG_INF1*)&msg_data_ge[0x20];
} else if (dComIfGs_getPalLanguage() == dSv_player_config_c::LANGUAGE_FRENCH) {
inf1 = (BMG_INF1*)&msg_data_fr[0x20];
} else if (dComIfGs_getPalLanguage() == dSv_player_config_c::LANGUAGE_SPANISH) {
inf1 = (BMG_INF1*)&msg_data_sp[0x20];
} else if (dComIfGs_getPalLanguage() == dSv_player_config_c::LANGUAGE_ITALIAN) {
inf1 = (BMG_INF1*)&msg_data_it[0x20];
} else {
inf1 = (BMG_INF1*)&msg_data[0x20];
}
#else
inf1 = (BMG_INF1*)&msg_data[0x20];
#endif
msg_p = (const char*)((u8*)inf1->getNext() + sizeof(JUTDataBlockHeader) + inf1->entries[status]);
JUT_ASSERT(102, strlen(msg_p)-1 < 512);
J2DTextBox tpane('TEXT1', JGeometry::TBox2<f32>(0.0f, 0.0f, FB_WIDTH, 200.0f), (ResFONT*)font_data, msg_p, 512, HBIND_CENTER, VBIND_CENTER);
J2DTextBox spane('TEXT2', JGeometry::TBox2<f32>(0.0f, 0.0f, FB_WIDTH, 200.0f), (ResFONT*)font_data, msg_p, 512, HBIND_CENTER, VBIND_CENTER);
J2DPicture ppane('PICT1', JGeometry::TBox2<f32>(0.0f, 0.0f, FB_WIDTH, FB_HEIGHT), (ResTIMG*)black_tex, NULL);
JUTResFont font((ResFONT*)font_data, NULL);
JUTFont* pfont = (JUTFont*)&font;
JUtility::TColor tcharcolor(0xC8, 0xC8, 0xC8, 0xFF);
JUtility::TColor scharcolor(0xFF, 0xFF, 0xFF, 0xFF);
JUtility::TColor tgradcolor(0xFF, 0xFF, 0xFF, 0xFF);
JUtility::TColor sgradcolor(0xFF, 0xFF, 0xAD, 0xFF);
JUtility::TColor twhite(0xC8, 0xC8, 0xC8, 0xFF);
JUtility::TColor swhite(0x00, 0x00, 0x00, 0xFF);
JUtility::TColor tblack(0x00, 0x00, 0x00, 0x00);
JUtility::TColor sblack(0x00, 0x00, 0x00, 0x00);
J2DTextBox::TFontSize size;
size.mSizeX = 23.0f;
size.mSizeY = 22.0f;
tpane.setFontSize(size);
tpane.setCharSpace(CHAR_SPACE);
tpane.setLineSpace(LINE_SPACE);
tpane.setCharColor(tcharcolor);
tpane.setGradColor(tgradcolor);
tpane.setBlackWhite(tblack, twhite);
spane.setFontSize(size);
spane.setCharSpace(CHAR_SPACE);
spane.setLineSpace(LINE_SPACE);
spane.setCharColor(scharcolor);
spane.setGradColor(sgradcolor);
spane.setBlackWhite(sblack, swhite);
const int lineMax = 10;
f32 height = LINE_HEIGHT;
f32 maxWidth = 0.0f;
int cnt = 0;
f32 lineWidth[lineMax];
for (int i = 0; i < lineMax; i++) {
lineWidth[i] = 0.0f;
}
for (; *msg_p != '\0'; msg_p++) {
if (*msg_p == '\n') {
height += LINE_HEIGHT;
cnt++;
JUT_ASSERT(191, cnt < lineMax);
continue;
}
int c = (u8)*msg_p;
#if (VERSION == VERSION_GCN_JPN) || (VERSION == VERSION_WII_JPN)
if (pfont->isLeadByte_ShiftJIS(c)) {
#else
if (pfont->isLeadByte_EUC(c)) {
#endif
msg_p++;
c = (c << 8) | (u8)*msg_p;
}
lineWidth[cnt] += CHAR_SPACE + size.mSizeX * ((f32)pfont->getWidth(c) / (f32)pfont->getCellWidth());
}
for (int i = 0; i < lineMax; i++) {
f32 width = lineWidth[i];
if (maxWidth < width)
maxWidth = width;
}
#if (VERSION == VERSION_GCN_JPN) || (VERSION == VERSION_WII_JPN)
f32 temp_0 = 0.0f; // fixes load order
f32 y = temp_0 + ((FB_HEIGHT - height) / 2);
if (i_drawBg) {
ppane.mAlpha = 0x82;
ppane.draw(0.0f, 0.0f, FB_WIDTH, FB_HEIGHT, false, false, false);
}
spane.draw(2.0f, y + 10.0f + 2.0f, FB_WIDTH, HBIND_CENTER);
tpane.draw(0.0f, y + 10.0f, FB_WIDTH, HBIND_CENTER);
#else
f32 temp_0 = 0.0f; // fixes load order
f32 x = temp_0 + ((FB_WIDTH - maxWidth) / 2);
f32 y = temp_0 + ((FB_HEIGHT - height) / 2);
if (i_drawBg) {
ppane.mAlpha = 0x82;
ppane.draw(0.0f, 0.0f, FB_WIDTH, FB_HEIGHT, false, false, false);
}
#if VERSION == VERSION_GCN_PAL
if (dComIfGs_getPalLanguage() == dSv_player_config_c::LANGUAGE_ENGLISH) {
spane.draw(x + 2.0f, y + 10.0f + 2.0f, FB_WIDTH, HBIND_LEFT);
tpane.draw(x, y + 10.0f, FB_WIDTH, HBIND_LEFT);
} else {
spane.draw(2.0f, y + 10.0f + 2.0f, FB_WIDTH, HBIND_CENTER);
tpane.draw(0.0f, y + 10.0f, FB_WIDTH, HBIND_CENTER);
}
#else
spane.draw(x + 2.0f, y + 10.0f + 2.0f, FB_WIDTH, HBIND_LEFT);
tpane.draw(x, y + 10.0f, FB_WIDTH, HBIND_LEFT);
#endif
#endif
}
void dDvdErrorMsg_c::draw(s32 status) {
JUtility::TColor backColor = g_clearColor;
JFWDisplay::getManager()->setClearColor(backColor);
mDoGph_gInf_c::beginRender();
GXSetAlphaUpdate(GX_FALSE);
j3dSys.drawInit();
J2DOrthoGraph draw2D(0.0f, 0.0f, FB_WIDTH, FB_HEIGHT, -1.0f, 1.0f);
draw2D.setOrtho(0.0f, 0.0f, FB_WIDTH, FB_HEIGHT, -1.0f, 1.0f);
draw2D.setPort();
dComIfGp_setCurrentGrafPort(&draw2D);
if (status == DVD_STATE_NO_DISK) {
messageSet(MSG_NO_DISK, true);
} else if (status == DVD_STATE_COVER_OPEN) {
messageSet(MSG_COVER_OPEN, true);
} else if (status == DVD_STATE_FATAL_ERROR) {
messageSet(MSG_FATAL_ERROR, true);
} else if (status == DVD_STATE_WRONG_DISK) {
messageSet(MSG_WRONG_DISK, true);
} else if (status == DVD_STATE_RETRY) {
messageSet(MSG_READ_ERROR, true);
} else if (status == DVD_STATE_BUSY) {
messageSet(MSG_READING_DISC, true);
}
mDoGph_gInf_c::endRender();
JFWDisplay::getManager()->resetFader();
}
bool dDvdErrorMsg_c::execute() {
static bool l_dvdError;
s32 drive_status = DVDGetDriveStatus();
if (drive_status != DVD_STATE_END && drive_status != DVD_STATE_BUSY && !l_dvdError) {
l_dvdError = true;
}
if (l_dvdError) {
OSReport_Error("DVD Error !! <%d>\n", drive_status);
if (drive_status == DVD_STATE_END) {
l_dvdError = false;
} else if (mDoRst::isReset() &&
(drive_status == DVD_STATE_NO_DISK || drive_status == DVD_STATE_COVER_OPEN || drive_status == DVD_STATE_WRONG_DISK || drive_status == DVD_STATE_RETRY))
{
mDoRst::onReturnToMenu();
} else {
draw(drive_status);
}
}
return l_dvdError;
}
static u8 l_captureAlpha = 0xFF;
static void drawCapture(u8 alpha) {
static bool l_texCopied = false;
if (!l_texCopied) {
GXSetTexCopySrc(0, 0, FB_WIDTH, FB_HEIGHT);
GXSetTexCopyDst(FB_WIDTH / 2, FB_HEIGHT / 2, (GXTexFmt)mDoGph_gInf_c::getFrameBufferTimg()->format, GX_TRUE);
GXCopyTex(mDoGph_gInf_c::getFrameBufferTex(), GX_FALSE);
l_texCopied = true;
}
mDoGph_gInf_c::setClearColor(g_clearColor);
mDoGph_gInf_c::beginRender();
GXSetAlphaUpdate(GX_FALSE);
j3dSys.drawInit();
GXInitTexObj(mDoGph_gInf_c::getFrameBufferTexObj(), mDoGph_gInf_c::getFrameBufferTex(), FB_WIDTH / 2, FB_HEIGHT / 2, (GXTexFmt)mDoGph_gInf_c::getFrameBufferTimg()->format, GX_CLAMP, GX_CLAMP, GX_FALSE);
GXInitTexObjLOD(mDoGph_gInf_c::getFrameBufferTexObj(), GX_LINEAR, GX_LINEAR, 0.0f, 0.0f, 0.0f, GX_FALSE, GX_FALSE, GX_ANISO_1);
GXLoadTexObj(mDoGph_gInf_c::getFrameBufferTexObj(), GX_TEXMAP0);
GXSetNumChans(0);
GXSetNumIndStages(0);
GXSetNumTexGens(1);
GXSetTexCoordGen2(GX_TEXCOORD0, GX_TG_MTX2x4, GX_TG_TEX0, 60, GX_FALSE, GX_PTIDENTITY);
GXSetNumTevStages(1);
GXColor color = {0, 0, 0, alpha};
GXSetTevColor(GX_TEVREG0, color);
GXSetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD0, GX_TEXMAP0, GX_COLOR_NULL);
GXSetTevColorIn(GX_TEVSTAGE0, GX_CC_ZERO, GX_CC_TEXC, GX_CC_A0, GX_CC_ZERO);
GXSetTevColorOp(GX_TEVSTAGE0, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, GX_TRUE, GX_TEVPREV);
GXSetTevAlphaIn(GX_TEVSTAGE0, GX_CA_ZERO, GX_CA_ZERO, GX_CA_ZERO, GX_CA_ZERO);
GXSetTevAlphaOp(GX_TEVSTAGE0, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, GX_TRUE, GX_TEVPREV);
GXSetZCompLoc(GX_TRUE);
GXSetZMode(GX_DISABLE, GX_ALWAYS, GX_DISABLE);
GXSetBlendMode(GX_BM_NONE, GX_BL_SRCALPHA, GX_BL_ONE, GX_LO_CLEAR);
GXSetAlphaCompare(GX_ALWAYS, 0, GX_AOP_OR, GX_ALWAYS, 0);
GXSetFog(GX_FOG_NONE, 0.0f, 0.0f, 0.0f, 0.0f, g_clearColor);
GXSetFogRangeAdj(GX_DISABLE, 0, NULL);
GXSetCullMode(GX_CULL_NONE);
GXSetDither(GX_ENABLE);
Mtx44 m;
C_MTXOrtho(m, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 10.0f);
GXLoadPosMtxImm(g_mDoMtx_identity, GX_PNMTX0);
GXSetProjection(m, GX_ORTHOGRAPHIC);
GXSetCurrentMtx(0);
GXClearVtxDesc();
GXSetVtxDesc(GX_VA_POS, GX_DIRECT);
GXSetVtxDesc(GX_VA_TEX0, GX_DIRECT);
GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_CLR_RGB, GX_RGB8, 0);
GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_TEX0, GX_CLR_RGBA, GX_RGB8, 0);
mDoGph_drawFilterQuad(1, 1);
mDoGph_gInf_c::endRender();
JFWDisplay::getManager()->resetFader();
}
bool dShutdownErrorMsg_c::execute() {
if (!mDoRst::isShutdown() && !mDoRst::isReturnToMenu()) {
return false;
}
if (l_captureAlpha == 0xFF) {
if (Z2AudioMgr::getInterface()->isResetting() && !mDoAud_resetRecover()) {
drawCapture(l_captureAlpha);
return true;
}
if (mDoAud_zelAudio_c::isInitFlag()) {
Z2AudioMgr::getInterface()->resetProcess(0x10, true);
}
}
drawCapture(l_captureAlpha);
if (cLib_chaseUC(&l_captureAlpha, 0, 15) != 0) {
if (mDoRst::isReturnToMenu()) {
mDoRst_reset(1, 0x80000000, 0);
} else {
mDoRst_reset(1, 1, 1);
}
}
return true;
}
|