pagedata.c
13.1 KB
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
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
#include "viewer.h"
#include "status.h"
#include "uilogic.h"
#include "pagecommon.h"
#include "pagedata.h"
#include "pagegame.h"
#include "font.h"
#include "texrect.h"
#include "status.h"
#include "shadowicon.h"
#include "cpak.h"
#include "texture/dgpak.c"
#include "texture/igpak.c"
#include "texture/ccpak.c"
#include "texture/dcpak.c"
#define DATA_DIALOG_ICON_W 128
#define DATA_DIALOG_ICON_H 32
#define GPAK_DIALOG_TOP_DEL 0
#define GPAK_DIALOG_TOP_IMP 1
#define GPAK_DIALOG_TOP_COPY 2
#define GPAK_DIALOG_TOP_EMPTY 3
#define GPAK_DIALOG_TOP_MAX 4
UiShadowIcon gGPakDialogTop[GPAK_DIALOG_TOP_MAX];
#define GPAK_DIALOG_CFM_YES 0
#define GPAK_DIALOG_CFM_NO 1
#define GPAK_DIALOG_CFM_MAX 2
UiShadowIcon gGPakDialogCfm[GPAK_DIALOG_CFM_MAX];
#define GPAK_DIALOG_CNT_OKAY 0
#define GPAK_DIALOG_CNT_CANCEL 1
#define GPAK_DIALOG_CNT_MAX 2
UiShadowIcon gGPakDialogCnt[GPAK_DIALOG_CNT_MAX];
int gGPakDialogInit = 0;
void onGPakDialogInit1();
void onGPakDialogInit2();
void onGPakDialogInit3();
void onGPakDialogHilite();
void onGPakDialogSelect( int idx, u32 button );
int gGPakIdxMax;
u32 gGPakIds[SA_META_MAX_TICKETS];
int gGPakIconPageIdx;
UiShadowIcon gGPakIcons[MAX_GAME_ICON];
void onGPakIconInit();
int gGPakIconInit = 0;
int gDataIconTarget;
// copied data
u8 CPakData[32*1024];
int CPakDataSigned;
u32 CPakCid;
int CPakDstCell;
// extern functions
extern void onGameIconInit();
extern void onGameIconHilite(int idx);
// extern data
extern unsigned short texYes[];
extern unsigned short texNo[];
extern UiShadowIcon gCPakIcon[MAX_CONT_PAK];
void initPageData()
{
gGPakIdxMax = uiGetGPaks(gGPakIds);
}
void doPageData()
{
drawPageCommon();
switch (gStatus) {
case VW_OK:
gCPakInit = 0;
drawShadowIcon(gGPakDialogTop, 4, (gGPakDialogInit == 1), &onGPakDialogInit1 );
drawCursor();
checkCursorCommon();
checkCursorIcon(gGPakDialogTop, 4, &onGPakDialogHilite, &onGPakDialogSelect);
break;
case VW_DATA_GP_DEL:
if (gGPakIdxMax != 0) {
drawShadowIcon(gGPakIcons, MAX_GAME_ICON, gGPakIconInit, &onGPakIconInit);
drawString("Select Game Pak to Delete:", gStringMap, 115, 135);
drawCursor();
checkCursorCommon();
checkCursorIcon(gGPakIcons, MAX_GAME_ICON, &onGPakDialogHilite, &onGPakDialogSelect);
} else {
drawString("Game Pak is empty", gStringMap, 115, 125);
drawCursor();
checkCursorCommon();
}
break;
case VW_DATA_GP_DEL_CNF:
drawString("Delete Game Pak?", gStringMap, 115, 125);
drawShadowIcon(gGPakIcons, MAX_GAME_ICON, gGPakIconInit, &onGPakIconInit);
drawString(gGPakIcons[gDataIconTarget].text, gStringMap, 280, 362);
drawShadowIcon(gGPakDialogCfm, 2, (gGPakDialogInit == 2), &onGPakDialogInit2 );
drawCursor();
checkCursorCommon();
checkCursorIcon(gGPakDialogCfm, 2, &onGPakDialogHilite, &onGPakDialogSelect);
break;
case VW_DATA_GP_IMP:
if( uiGPakFull() ) {
drawString("Game Pak Full!", gStringMap, 115, 125);
drawString("You must delete some Game Paks", gStringMap, 115, 200);
drawString("before importing to this card.", gStringMap, 115, 232);
drawCursor();
checkCursorCommon();
} else {
drawString("Please insert iQue Card\nto import the game\npak from", gStringMap, 125, 150);
drawCursor();
checkCursorCommon();
}
break;
case VW_DATA_GP_IMP_SRC_CARD:
if (gGPakIdxMax != 0) {
drawShadowIcon(gGPakIcons, MAX_GAME_ICON, gGPakIconInit, &onGPakIconInit);
drawString("Select game pak to import", gStringMap, 115, 125);
drawCursor();
//checkCursorCommon();
checkCursorIcon(gGPakIcons, MAX_GAME_ICON, &onGPakDialogHilite, &onGPakDialogSelect);
} else {
drawString("Game Pak is empty", gStringMap, 115, 125);
drawCursor();
//checkCursorCommon();
}
break;
case VW_DATA_GP_IMP_SRC_CARD_CNF:
drawString("game and results\nwill be removed from\nthis card and\ncopied to the original\ncard. Are you sure?", gStringMap, 115, 125);
drawShadowIcon(gGPakDialogCnt, 2, (gGPakDialogInit == 3), &onGPakDialogInit3 );
drawCursor();
//checkCursorCommon();
checkCursorIcon(gGPakDialogCnt, 2, &onGPakDialogHilite, &onGPakDialogSelect);
break;
case VW_DATA_GP_IMP_DST_CARD:
drawString("Please insert original\ncard to finish importing", gStringMap, 115, 135);
drawCursor();
checkCursorCommon();
break;
case VW_DATA_GP_IMP_COMPLETE:
drawString("import game pak successful", gStringMap, 115, 135);
drawCursor();
checkCursorCommon();
break;
case VW_DATA_CP_CPY:
drawString("Please insert iQue card\nwith the memory cell to\ncopy from", gStringMap, 115, 125);
drawCursor();
checkCursorCommon();
break;
case VW_DATA_CP_CPY_SRC_SEL:
drawString("Select cell to copy", gStringMap, 115, 125);
drawCPak(0);
drawCursor();
checkCursorCommon();
checkCursorIcon(gCPakIcon, MAX_CONT_PAK, &onGPakDialogHilite, &onGPakDialogSelect);
break;
case VW_DATA_CP_CPY_DST:
drawString("Please insert the original\ncard to finish copying", gStringMap, 115, 125);
drawCursor();
checkCursorCommon();
break;
case VW_DATA_CP_CPY_DST_SEL:
drawString("Select the memory cell\nto copy to", gStringMap, 115, 125);
drawCPak(1);
drawCursor();
checkCursorCommon();
checkCursorIcon(gCPakIcon, MAX_CONT_PAK, &onGPakDialogHilite, &onGPakDialogSelect);
break;
case VW_DATA_CP_CPY_DST_CNF:
drawString("Are you sure?", gStringMap, 115, 125);
drawCPak(1);
drawShadowIcon(gGPakDialogCfm, 2, (gGPakDialogInit == 2), &onGPakDialogInit2 );
drawCursor();
checkCursorCommon();
checkCursorIcon(gGPakDialogCfm, 2, &onGPakDialogHilite, &onGPakDialogSelect);
break;
case VW_DATA_CP_CPY_COMPLETE:
drawString("Memory cell copy successful", gStringMap, 115, 125);
drawCPak(1);
drawCursor();
checkCursorCommon();
break;
case VW_DATA_CP_EMP:
drawString("Select Cont Pak to empty", gStringMap, 125, 125);
drawCPak(0);
drawCursor();
checkCursorCommon();
checkCursorIcon(gCPakIcon, MAX_CONT_PAK, &onGPakDialogHilite, &onGPakDialogSelect);
break;
case VW_DATA_CP_EMP_CNF:
drawString("Empty Mem Cell?", gStringMap, 115, 125);
drawCPak(0);
drawShadowIcon(gGPakDialogCfm, 2, (gGPakDialogInit == 2), &onGPakDialogInit2 );
drawCursor();
checkCursorCommon();
checkCursorIcon(gGPakDialogCfm, 2, &onGPakDialogHilite, &onGPakDialogSelect);
break;
}
}
void resetPageData()
{
gGPakIconInit = 0;
gGPakDialogInit = 0;
}
void onGPakIconInit()
{
int i, total, start;
u32 aIdx[MAX_GAME_ICON];
total = (gGPakIdxMax-1) / MAX_GAME_ICON;
if (gGPakIconPageIdx<0) gGPakIconPageIdx = 0;
if (gGPakIconPageIdx>total) gGPakIconPageIdx = total;
start = gGPakIconPageIdx * MAX_GAME_ICON;
PRINTF("gGPakIconPageIdx=%d gGPakIdxMax=%d\n", gGPakIconPageIdx, gGPakIdxMax);
for( i = 0; i <MAX_GAME_ICON; i++, start++ ) {
if ( start<(gGPakIdxMax) )
aIdx[i] = gGPakIds[start];
else
aIdx[i] = -1;
}
initGameIconGroup(gGPakIcons, MAX_GAME_ICON, aIdx);
gGPakIconInit = 1;
}
void onGPakDialogInit1()
{
int i;
int top_x[GPAK_DIALOG_TOP_MAX] = {200, 200, 200, 200};
int top_y[GPAK_DIALOG_TOP_MAX] = {150, 198, 271, 319};
u16* pTopTex[GPAK_DIALOG_TOP_MAX];
u8* pTopText[GPAK_DIALOG_TOP_MAX] = {NULL};
// group 1: dialog top
for( i = 0; i < GPAK_DIALOG_TOP_MAX; i++ ) {
switch( i ) {
case( GPAK_DIALOG_TOP_DEL ): pTopTex[i] = texDGPak; break;
case( GPAK_DIALOG_TOP_IMP ): pTopTex[i] = texIGPak; break;
case( GPAK_DIALOG_TOP_COPY ): pTopTex[i] = texCCPak; break;
case( GPAK_DIALOG_TOP_EMPTY ): pTopTex[i] = texDCPak; break;
}
}
initShadowIconGroup(gGPakDialogTop, GPAK_DIALOG_TOP_MAX,
top_x, top_y, DATA_DIALOG_ICON_W, DATA_DIALOG_ICON_H,
1<<10, 1<<10,
pTopTex, pTopText, gShadowMap);
gGPakDialogInit = 1;
}
void onGPakDialogInit2()
{
int i;
int cfm_x[GPAK_DIALOG_CFM_MAX] = {400, 448};
int cfm_y[GPAK_DIALOG_CFM_MAX] = {125, 125};
u16* pCfmTex[GPAK_DIALOG_CFM_MAX];
u8* pCfmText[GPAK_DIALOG_CFM_MAX] = {NULL};
// group 2: confirm top
for( i = 0; i < GPAK_DIALOG_CFM_MAX; i++ ) {
switch( i ) {
case( GPAK_DIALOG_CFM_YES ): pCfmTex[i] = texYes; break;
case( GPAK_DIALOG_CFM_NO ): pCfmTex[i] = texNo; break;
}
}
initShadowIconGroup(gGPakDialogCfm, GPAK_DIALOG_CFM_MAX,
cfm_x, cfm_y, 32, 32, 1<<10, 1<<10,
pCfmTex, pCfmText, gShadowMap);
gGPakDialogInit = 2;
}
void onGPakDialogInit3()
{
int i;
int cnt_x[GPAK_DIALOG_CNT_MAX] = {175, 375};
int cnt_y[GPAK_DIALOG_CNT_MAX] = {300, 300};
u16* pCntTex[GPAK_DIALOG_CNT_MAX];
u8* pCntText[GPAK_DIALOG_CNT_MAX] = {NULL};
// group 2: continue
for( i = 0; i < GPAK_DIALOG_CNT_MAX; i++ ) {
switch( i ) {
case( GPAK_DIALOG_CNT_OKAY ): pCntTex[i] = texYes; break;
case( GPAK_DIALOG_CNT_CANCEL ): pCntTex[i] = texNo; break;
}
}
initShadowIconGroup(gGPakDialogCnt, GPAK_DIALOG_CNT_MAX,
cnt_x, cnt_y, 32, 32, 1<<10, 1<<10,
pCntTex, pCntText, gShadowMap);
gGPakDialogInit = 3;
}
void onGPakDialogHilite( int idx )
{
if( (gStatus == VW_DATA_GP_DEL) || (gStatus == VW_DATA_GP_IMP_SRC_CARD) ) {
drawString(gGPakIcons[idx].text, gStringMap, 280, 362);
}
}
void onGPakDialogSelect( int idx, u32 button )
{
char *pData = NULL;
if (button==CONT_A)
{
switch (gStatus) {
case VW_OK:
switch( idx ) {
case 0 : gStatus = VW_DATA_GP_DEL; break;
case 1 : gStatus = VW_DATA_GP_IMP; break;
case 2 : gStatus = VW_DATA_CP_CPY; break;
case 3 : gStatus = VW_DATA_CP_EMP; break;
}
break;
case VW_DATA_GP_DEL:
gStatus = VW_DATA_GP_DEL_CNF;
gDataIconTarget = idx;
break;
case VW_DATA_GP_DEL_CNF:
if( idx == 0 ) { // yes
uiDeleteGPak(gGPakIds[gGPakIconPageIdx*MAX_GAME_ICON + gDataIconTarget]);
onGPakIconInit();
}
gStatus = VW_DATA_GP_DEL;
break;
case VW_DATA_GP_IMP:
if( idx == 0 ) { // okay
gStatus = VW_DATA_GP_IMP_SRC_CARD;
} else {
gStatus = VW_OK;
}
break;
case VW_DATA_GP_IMP_SRC_CARD:
gDataIconTarget = idx;
gStatus = VW_DATA_GP_IMP_SRC_CARD_CNF;
break;
case VW_DATA_GP_IMP_SRC_CARD_CNF:
if( idx == 0 ) { // okay
uiImportFromGPak(gGPakIds[gGPakIconPageIdx*MAX_GAME_ICON + gDataIconTarget], pData);
gStatus = VW_DATA_GP_IMP_DST_CARD;
} else {
gStatus = VW_OK;
}
break;
case VW_DATA_GP_IMP_DST_CARD:
if( idx == 0 ) { // okay
uiImportToGPak(gGPakIds[gGPakIconPageIdx*MAX_GAME_ICON + gDataIconTarget], pData);
gStatus = VW_DATA_GP_IMP_COMPLETE;
} else {
gStatus = VW_OK;
}
break;
case VW_DATA_CP_CPY:
if( idx == 0 ) { // okay
gStatus = VW_DATA_CP_CPY_SRC_SEL;
} else {
gStatus = VW_OK;
}
break;
case VW_DATA_CP_CPY_SRC_SEL:
// get cell binding
CPakCid = gCPakList[idx].cid;
// get game data
uiCopyFromCPak( idx, CPakData, &CPakDataSigned );
gStatus = VW_DATA_CP_CPY_DST;
break;
case VW_DATA_CP_CPY_DST:
if( idx == 0 ) { // okay
resetCPak();
gStatus = VW_DATA_CP_CPY_DST_SEL;
} else {
gStatus = VW_DATA_CP_CPY;
}
break;
case VW_DATA_CP_CPY_DST_SEL:
CPakDstCell = idx;
gStatus = VW_DATA_CP_CPY_DST_CNF;
break;
case VW_DATA_CP_CPY_DST_CNF:
if( idx == 0 ) { // okay
// copy cell
uiCopyToCPak( CPakDstCell, CPakCid, CPakData, CPakDataSigned);
resetCPak();
gStatus = VW_DATA_CP_CPY_COMPLETE;
} else {
gStatus = VW_DATA_CP_CPY;
}
break;
case VW_DATA_CP_EMP:
gStatus = VW_DATA_CP_EMP_CNF;
gDataIconTarget = idx;
break;
case VW_DATA_CP_EMP_CNF:
if( idx == 0 ) { // yes
uiEmptyCPak(gDataIconTarget);
resetCPak();
}
gStatus = VW_DATA_CP_EMP;
break;
}
}
}