pagegpak.c 19 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 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542

#include "viewer.h"
#include "status.h"
#include "gametex.h"
#include "uilogic.h"
#include "font.h"
#include "gzip.h"
#include "texrect.h"
#include "page.h"
#include "pagetop.h"
#include "pagegame.h"
#include "texture.h"
#include "texture/gpak_t_gz.c"
#include "gameticket.h"
#include "audrenderer.h"

extern UiTable gConfirmTable;
extern UiRow   gConfirmRow[3];
extern UiImage gCYesImg;
extern UiImage gCYeshImg;
extern UiImage gCNoImg;
extern UiImage gCNohImg;
extern UiImage gCpakrowImg;
extern UiImage gDstarImg;

int      gPageGpakInit = 0;
UiTable  gPageGpakTable;

int          gNumGpaks = 0;
SaGpak       gGpaks[SA_META_MAX_TICKETS];
int          gGpakIdx = 0;
SaGpakCopy   gGpak __attribute__ ((aligned (16)));

void drawPageGpakBg();
void initPageGpakAssets();
void onGpakRowHilite(int idx);
void onGpakRowSelect(int idx, u32 button);
void onGpakCopyRowSelect(int idx, u32 button);
void onGpakDelConfirmHilite(int idx);
void onGpakDelConfirmSelect(int idx, u32 button);
void onGpakCpyConfirmHilite(int idx);
void onGpakCpyConfirmSelect(int idx, u32 button);

static int gPrevGpakIdx=0;
static int gGpakDelConfirmIdx = 0;
static int gGpakCpyConfirmIdx = 0;

#define PAGE_GPAK_ROWS    6

void initPageGpak(int trow, int hrow)
{
    int i, j, idx=0;

    initPageGpakAssets();
    initConfirmTable(2);
    gPageNo = PAGE_GPAK;
    gNumGpaks = uiGetGpaks(gGpaks);

    if (gNumGpaks==0) {

    for ( i=0; i<PAGE_GPAK_ROWS; i++) {
        gPageGpakRow[i].col_cnt = 3;
        gPageGpakRow[i].cell_h = TEX_PAKROW_H;
        gPageGpakRow[i].txt_color = 0xFFFF;
        gPageGpakRow[i].bg_color  = 0;
        gPageGpakRow[i].bg = &gGameRowBg;
        
        for (j=0; j<gPageGpakRow[i].col_cnt; j++) 
            gPageGpakRow[i].data[j] = NULL; 
    }

    } else {

    for ( i=0; i<gNumGpaks; i++) {
        gPageGpakRow[i].col_cnt = 3;
        gPageGpakRow[i].cell_h = TEX_PAKROW_H;
        gPageGpakRow[i].txt_color = 0xFFFF;
        gPageGpakRow[i].bg_color  = 0;
        gPageGpakRow[i].bg = &gGameRowBg;
        sprintf(gGpakIdxStr+3*i, "%d", i+1);

        for (j=0; j<gpTickets->numTickets;j++) {
            if (gGpaks[i].cid==gpTickets->ticket[j].cmd.head.id) {
                idx = j;
                break;
            }
        }

        for (j=0; j<gPageGpakRow[i].col_cnt; j++) {
            gPageGpakRow[i].cell_w[j] = (j==0) ? 100 : 
                                        (j==1) ? 16: GAME_TITLE_W + 6;
            gPageGpakRow[i].cell_x[j] = (j==0) ? 110 : ((j==1) ? 40 : 66);
            gPageGpakRow[i].cell_y[j] =  4;
            gPageGpakRow[i].type[j] = (j==0) ? CELL_TYPE_STRING : CELL_TYPE_TEXTURE;
            gPageGpakRow[i].data[j] = (j==0) ? gGpakIdxStr+i*3 : 
                                      (j==1) ? ((gGpaks[i].dirty==1) ? (void*)(&gDstarImg) : NULL) 
                                      : (void*)(&gGameTitleImg[idx]);
        }
    }

    }

    gPageGpakTable.x           = 0;
    gPageGpakTable.y           = FRAME_Y + TOP_BAR_H + 72;
    gPageGpakTable.total_rows  = gNumGpaks;
    gPageGpakTable.screen_rows = PAGE_GPAK_ROWS;
    gPageGpakTable.hilite_row  = hrow;
    gPageGpakTable.top_row     = trow;
    gPageGpakTable.rows        = gPageGpakRow;
    gPageGpakTable.row_layout  = ROW_LAYOUT_VERTICAL;

    gPrevGpakIdx = hrow;
    gStatus = VW_OK;
}

void doPageGpak()
{
    if ( (gStatus==VW_OK || gStatus==VW_GP_CPY_SRC_SELECT) && gTicketStatus != VW_ERR_TICKET && gNumGpaks!=0) {
        updateRowHilite( &gPageGpakTable );
    } else if (gStatus==VW_GP_DEL_CNF || gStatus==VW_GP_CPY_CNF) {
        updateRowHilite( &gConfirmTable );
    }
    drawPageGpakBg();

    switch (gStatus) {
    case VW_OK:
        if (gButton==CONT_B) {
            gButton = 0;
            playSound(SOUND_MENU_UP, AUDIO_NOWAIT);
            initPageTop(PAGE_MANAGE);
            return;
        }

        if (gTicketStatus==VW_ERR_TICKET) {
            drawError(gsError_3,
                      (TEX_BOARD_W - 8*(TEX_ZH_GLYPH_W+1))/2,
                      (TEX_BOARD_H - (TEX_ZH_GLYPH_H+2))/2 );
        } else if (gTicketStatus==VW_ERR_NO_TICKET ||  // no ticket file
                   (gClubTicketIdx!=-1 && gpTickets->numTickets==1)) { // or only club app
            drawError(gsError_1, 
                      (TEX_BOARD_W - 10*(TEX_ZH_GLYPH_W+1))/2,
                      (TEX_BOARD_H - 2*(TEX_ZH_GLYPH_H+2))/2 );
        } else {
            if (gNumGpaks!=0) {
                drawColorString(gsError_25, GPAK_TEXT_X, GPAK_TEXT_Y, 0xFFFF);
                drawTable( &gPageGpakTable, &onGpakRowHilite, &onGpakRowSelect );
            } else {
                if (gButton==CONT_A) {
                    gButton = 0;
                    playSound(SOUND_MENU_DOWN, AUDIO_NOWAIT);
                    gStatus = VW_GP_CPY_SRC_CARD;
                }
                drawColorString(gsError_13, GPAK_TEXT_X, GPAK_TEXT_Y, 0xFFFF);
                drawTable( &gPageGpakTable, NULL, NULL);
            }
        }
        break;
    case VW_GP_DEL_CNF: 
        drawTable( &gPageGpakTable, NULL, NULL );
        drawTexRectCI( texBoard,
                       G_IM_FMT_CI, G_IM_SIZ_8b,
                       TEX_BOARD_W, TEX_BOARD_H,
                       32, 32, 1<<10, 1<<10,
                       TEX_BOARD_W, TEX_BOARD_H,
                       (SCREEN_WD-TEX_BOARD_W)/2, (SCREEN_HT-TEX_BOARD_H)/2);
        drawColorString(gsError_14,  
                   (SCREEN_WD-TEX_BOARD_W)/2 + 20,
                   (SCREEN_HT-TEX_BOARD_H)/2 + 20, 0xFFFF);
        drawTable( &gConfirmTable, &onGpakDelConfirmHilite, &onGpakDelConfirmSelect);
        break;
    case VW_GP_CPY_SRC_CARD:  // waiting for src card for gpak copy
        if (gButton==CONT_B) {
            gButton = 0;
            playSound(SOUND_MENU_UP, AUDIO_NOWAIT);
            gStatus = VW_OK;
            return;
        }
        gButton = 0;
        drawTable( &gPageGpakTable, NULL, NULL );
        drawTexRectCI( texBoard,
                       G_IM_FMT_CI, G_IM_SIZ_8b,
                       TEX_BOARD_W, TEX_BOARD_H,
                       32, 32, 1<<10, 1<<10,
                       TEX_BOARD_W, TEX_BOARD_H,
                       (SCREEN_WD-TEX_BOARD_W)/2, (SCREEN_HT-TEX_BOARD_H)/2);
        drawColorString(gsError_15, 
                    (SCREEN_WD-TEX_BOARD_W)/2 + (TEX_BOARD_W-26*7)/2,
                    (SCREEN_HT-TEX_BOARD_H)/2 + (TEX_BOARD_H-26*2)/2, 0xFFFF);
        break;
    case VW_GP_CPY_SRC_SELECT:  // select gpak from src. card
        drawColorString(gsError_26, GPAK_TEXT_X, GPAK_TEXT_Y+13, 0xFFFF);
        drawTable( &gPageGpakTable, &onGpakRowHilite, &onGpakCopyRowSelect );
        break;
    case VW_ERR_GP_CPY_SRC_NO_TICKET:
        if (gButton==CONT_B) {
            gButton = 0;
            playSound(SOUND_MENU_UP, AUDIO_NOWAIT);
            gStatus = VW_GP_CPY_CANCEL;
            return;
        }
        gButton = 0;
        drawTable( &gPageGpakTable, NULL, NULL );
        drawTexRectCI( texBoard,
                       G_IM_FMT_CI, G_IM_SIZ_8b,
                       TEX_BOARD_W, TEX_BOARD_H,
                       32, 32, 1<<10, 1<<10,
                       TEX_BOARD_W, TEX_BOARD_H,
                       (SCREEN_WD-TEX_BOARD_W)/2, (SCREEN_HT-TEX_BOARD_H)/2);
        drawColorString(gsError_16, 
                    (SCREEN_WD-TEX_BOARD_W)/2 + (TEX_BOARD_W-26*11)/2,
                    (SCREEN_HT-TEX_BOARD_H)/2 + (TEX_BOARD_H-26*3)/2, 0xFFFF);
        break;
    case VW_ERR_GP_CPY_SRC_NO_GPAK:
        if (gButton==CONT_B) {
            gButton = 0;
            playSound(SOUND_MENU_UP, AUDIO_NOWAIT);
            gStatus = VW_GP_CPY_CANCEL;
            return;
        }
        gButton = 0;
        drawTable( &gPageGpakTable, NULL, NULL );
        drawTexRectCI( texBoard,
                       G_IM_FMT_CI, G_IM_SIZ_8b,
                       TEX_BOARD_W, TEX_BOARD_H,
                       32, 32, 1<<10, 1<<10,
                       TEX_BOARD_W, TEX_BOARD_H,
                       (SCREEN_WD-TEX_BOARD_W)/2, (SCREEN_HT-TEX_BOARD_H)/2);
        drawColorString(gsError_18,  // no game state found
                    (SCREEN_WD-TEX_BOARD_W)/2 + (TEX_BOARD_W-26*11)/2,
                    (SCREEN_HT-TEX_BOARD_H)/2 + (TEX_BOARD_H-26*3)/2, 0xFFFF);
        break;
    case VW_GP_CPY_DST_CARD: // waiting for dst. card for gpak copy
        gButton = 0;
        drawTable( &gPageGpakTable, NULL, NULL );
        drawTexRectCI( texBoard,
                       G_IM_FMT_CI, G_IM_SIZ_8b,
                       TEX_BOARD_W, TEX_BOARD_H,
                       32, 32, 1<<10, 1<<10,
                       TEX_BOARD_W, TEX_BOARD_H,
                       (SCREEN_WD-TEX_BOARD_W)/2, (SCREEN_HT-TEX_BOARD_H)/2);
        drawColorString(gsError_19,  
                    (SCREEN_WD-TEX_BOARD_W)/2 + (TEX_BOARD_W-26*9)/2,
                    (SCREEN_HT-TEX_BOARD_H)/2 + (TEX_BOARD_H-26)/2, 0xFFFF);
        break;
    case VW_GP_CPY_CNF: // gpak already exists, overwrite?
        drawTable( &gPageGpakTable, NULL, NULL );
        drawTexRectCI( texBoard,
                       G_IM_FMT_CI, G_IM_SIZ_8b,
                       TEX_BOARD_W, TEX_BOARD_H,
                       32, 32, 1<<10, 1<<10,
                       TEX_BOARD_W, TEX_BOARD_H,
                       (SCREEN_WD-TEX_BOARD_W)/2, (SCREEN_HT-TEX_BOARD_H)/2);
        drawColorString(gsError_17,  
                    (SCREEN_WD-TEX_BOARD_W)/2 + 20,
                    (SCREEN_HT-TEX_BOARD_H)/2 + 20, 0xFFFF);
        drawTable( &gConfirmTable, &onGpakCpyConfirmHilite, &onGpakCpyConfirmSelect);
        break;
    case VW_GP_CPY_YES:
        uiCopyGpak( &gGpak );
        initPageGpak(0, 0);
        drawTable( &gPageGpakTable, NULL, NULL );
        playSound(SOUND_MENU_UP, AUDIO_NOWAIT);
        gStatus = VW_GP_CPY_SUCCESS;
        break;
    case VW_GP_CPY_SUCCESS:
        if (gButton==CONT_A) {
            gButton = 0;
            playSound(SOUND_MENU_UP, AUDIO_NOWAIT);
            initPageGpak(0, 0);
        }
        drawTable( &gPageGpakTable, NULL, NULL );
        drawTexRectCI( texBoard,
                       G_IM_FMT_CI, G_IM_SIZ_8b,
                       TEX_BOARD_W, TEX_BOARD_H,
                       32, 32, 1<<10, 1<<10,
                       TEX_BOARD_W, TEX_BOARD_H,
                       (SCREEN_WD-TEX_BOARD_W)/2, (SCREEN_HT-TEX_BOARD_H)/2);
        drawColorString(gsError_27, 
                    (SCREEN_WD-TEX_BOARD_W)/2 + (TEX_BOARD_W-26*9)/2,
                    (SCREEN_HT-TEX_BOARD_H)/2 + (TEX_BOARD_H-26)/2, 0xFFFF);
        break;
    case VW_GP_CPY_CANCEL:
        gButton = 0;
        drawTable( &gPageGpakTable, NULL, NULL );
        drawTexRectCI( texBoard,
                       G_IM_FMT_CI, G_IM_SIZ_8b,
                       TEX_BOARD_W, TEX_BOARD_H,
                       32, 32, 1<<10, 1<<10,
                       TEX_BOARD_W, TEX_BOARD_H,
                       (SCREEN_WD-TEX_BOARD_W)/2, (SCREEN_HT-TEX_BOARD_H)/2);
        drawColorString(gsError_23, 
                    (SCREEN_WD-TEX_BOARD_W)/2 + (TEX_BOARD_W-26*10)/2,
                    (SCREEN_HT-TEX_BOARD_H)/2 + (TEX_BOARD_H-26*2)/2, 0xFFFF);
        break;
    case VW_ERR_GP_CPY_DST_NO_SPACE:
        if (gButton==CONT_B) {
            gButton = 0;
            playSound(SOUND_MENU_UP, AUDIO_NOWAIT);
            resetViewer();
            if (gStatus!=VW_ERR_ID_MISMATCH && gStatus!=VW_ERR_FS) 
                initPageGpak(0, 0);
            return;
        }

        gButton = 0;
        drawTable( &gPageGpakTable, NULL, NULL );
        drawTexRectCI( texBoard,
                       G_IM_FMT_CI, G_IM_SIZ_8b,
                       TEX_BOARD_W, TEX_BOARD_H,
                       32, 32, 1<<10, 1<<10,
                       TEX_BOARD_W, TEX_BOARD_H,
                       (SCREEN_WD-TEX_BOARD_W)/2, (SCREEN_HT-TEX_BOARD_H)/2);
        drawColorString(gsError_20, 
                    (SCREEN_WD-TEX_BOARD_W)/2 + (TEX_BOARD_W-26*11)/2,
                    (SCREEN_HT-TEX_BOARD_H)/2 + (TEX_BOARD_H-26*3)/2, 0xFFFF);
        break;
    case VW_ERR_GP_CPY_DST_NO_TICKET:
        if (gButton==CONT_B) {
            gButton = 0;
            playSound(SOUND_MENU_UP, AUDIO_NOWAIT);
            resetViewer();
            if (gStatus!=VW_ERR_ID_MISMATCH && gStatus!=VW_ERR_FS) 
                initPageGpak(0, 0);
            return;
        }

        gButton = 0;
        drawTable( &gPageGpakTable, NULL, NULL );
        drawTexRectCI( texBoard,
                       G_IM_FMT_CI, G_IM_SIZ_8b,
                       TEX_BOARD_W, TEX_BOARD_H,
                       32, 32, 1<<10, 1<<10,
                       TEX_BOARD_W, TEX_BOARD_H,
                       (SCREEN_WD-TEX_BOARD_W)/2, (SCREEN_HT-TEX_BOARD_H)/2);
        drawColorString(gsError_21, 
                   (SCREEN_WD-TEX_BOARD_W)/2 + 5,
                   (SCREEN_HT-TEX_BOARD_H)/2 + 8, 0xFFF);
        break;
    case VW_ERR_GP_CPY_WRONG_DST_CARD:
        if (gButton==CONT_B) {
            gButton = 0;
            playSound(SOUND_MENU_UP, AUDIO_NOWAIT);
            gStatus = VW_GP_CPY_CANCEL;
            return;
        }

        gButton = 0;
        drawTable( &gPageGpakTable, NULL, NULL );
        drawTexRectCI( texBoard,
                       G_IM_FMT_CI, G_IM_SIZ_8b,
                       TEX_BOARD_W, TEX_BOARD_H,
                       32, 32, 1<<10, 1<<10,
                       TEX_BOARD_W, TEX_BOARD_H,
                       (SCREEN_WD-TEX_BOARD_W)/2, (SCREEN_HT-TEX_BOARD_H)/2);
        drawColorString(gsError_22,  
                    (SCREEN_WD-TEX_BOARD_W)/2 + 10,
                    (SCREEN_HT-TEX_BOARD_H)/2 + 20, 0xFFFF);
        break;
    case VW_ERR_NO_CARD:
        drawError( gsError_5, 
                   (TEX_BOARD_W - 11*(TEX_ZH_GLYPH_W+1))/2,
                   (TEX_BOARD_H - 2*(TEX_ZH_GLYPH_H+2))/2 );
        break;
    }
}

void onGpakRowHilite(int idx)
{
    int j;


    if (idx != gPrevGpakIdx) {
        gPrevGpakIdx = idx;
        playSound(SOUND_SELECTION_MOVE, AUDIO_NOWAIT);
    }

    for (j=0; j<gPageGpakTable.total_rows; j++) {
        if (j!=idx) {
            gPageGpakRow[j].bg = &gGameRowBg;
        } else {
            gPageGpakRow[j].bg = &gGameRowHBg;
        }
    }
}

void onGpakRowSelect(int idx, u32 button)
{
    gGpakIdx = idx;

    if (button==CONT_A) {
        playSound(SOUND_MENU_DOWN, AUDIO_NOWAIT);
        gStatus = VW_GP_CPY_SRC_CARD; 
    } else if (button==CONT_G) {
        playSound(SOUND_MENU_DOWN, AUDIO_NOWAIT);
        gStatus = VW_GP_DEL_CNF;
    }
}

void onGpakCopyRowSelect(int idx, u32 button)
{
    gGpakIdx = idx;

    if (button==CONT_A) {
        uiGetGpakCopy(gGpaks[gGpakIdx].cid, &gGpak);
        playSound(SOUND_MENU_DOWN, AUDIO_NOWAIT);
        gStatus = VW_GP_CPY_DST_CARD; 
    } 
}

void onGpakDelConfirmHilite(int idx) 
{
    if (gGpakDelConfirmIdx != idx) {
        playSound(SOUND_SELECTION_MOVE, AUDIO_NOWAIT);
        gGpakDelConfirmIdx = idx;
    }
    if (idx==0) {
        gConfirmRow[0].data[0]  = (void*)(&gCYeshImg);
        gConfirmRow[1].data[0]  = (void*)(&gCNoImg);
    } else if (idx==1) {
        gConfirmRow[0].data[0]  = (void*)(&gCYesImg);
        gConfirmRow[1].data[0]  = (void*)(&gCNohImg);
    }
}

void onGpakDelConfirmSelect(int idx, u32 button)
{
    if (button==CONT_A) {
        if (idx==0) {    // delete gpak
            uiDeleteGpak(gGpaks[gGpakIdx].cid);
            playSound(SOUND_MENU_UP, AUDIO_NOWAIT);
            initPageGpak(0, 0);
        } else if (idx==1) {  // cancel
            gStatus = VW_OK;
            playSound(SOUND_MENU_UP, AUDIO_NOWAIT);
        }
    }
}

void onGpakCpyConfirmHilite(int idx) 
{
    if (gGpakCpyConfirmIdx != idx) {
        playSound(SOUND_SELECTION_MOVE, AUDIO_NOWAIT);
        gGpakCpyConfirmIdx = idx;
    }
    if (idx==0) {
        gConfirmRow[0].data[0]  = (void*)(&gCYeshImg);
        gConfirmRow[1].data[0]  = (void*)(&gCNoImg);
    } else if (idx==1) {
        gConfirmRow[0].data[0]  = (void*)(&gCYesImg);
        gConfirmRow[1].data[0]  = (void*)(&gCNohImg);
    }
}

void onGpakCpyConfirmSelect(int idx, u32 button)
{
    if (button==CONT_A) {
        gButton = 0;
        if (idx==0) {    // yes: copy gpak
            uiCopyGpak( &gGpak );
            playSound(SOUND_MENU_UP, AUDIO_NOWAIT);
            initPageGpak(0, 0);
            gStatus = VW_GP_CPY_SUCCESS;
        } else if (idx==1) {  // no: cancel copying gpak
            playSound(SOUND_MENU_UP, AUDIO_NOWAIT);
            gStatus = VW_OK;
        }
    } 
}

void initPageGpakAssets()
{
    int outsize;

    if (!gPageGpakInit) {

        initPageGame(0, 0);

        bzero(texGpakTitle, TEX_GPAK_TITLE_W*TEX_GPAK_TITLE_H*2);
        outsize = expand_gzip( gzTexGpakTitle, texGpakTitle, gzTexGpakTitleSize, TEX_GPAK_TITLE_W*TEX_GPAK_TITLE_H*2);

        gPageGpakInit = 1;
    }
}

void drawPageGpakBg()
{
    gDPSetCycleType(gpGfxList++, G_CYC_FILL);
    gDPSetFillColor(gpGfxList++, (GPACK_RGBA5551(13, 1, 77, 1) << 16) | GPACK_RGBA5551(13, 1, 77, 1));
    gDPFillRectangle( gpGfxList++, 0, 0, SCREEN_WD-1, SCREEN_HT-1 );
    gDPSetFillColor(gpGfxList++, (GPACK_RGBA5551(0, 0, 0, 1) << 16) | GPACK_RGBA5551(0, 0, 0, 1));

    if (gStatus==VW_GP_CPY_SRC_SELECT || 
        gStatus==VW_ERR_GP_CPY_SRC_NO_GPAK ||
        gStatus==VW_ERR_GP_CPY_SRC_NO_TICKET || 
        gStatus==VW_ERR_GP_CPY_WRONG_DST_CARD ||
        gStatus==VW_GP_CPY_DST_CARD ) {
        drawTexRect( texGpakTitle,
                     G_IM_FMT_RGBA, G_IM_SIZ_16b,
                     TEX_GPAK_TITLE_W, TEX_GPAK_TITLE_H,
                     32, 32, 1<<10, 1<<10,
                     TEX_GPAK_TITLE_W, TEX_GPAK_TITLE_H,
                     (SCREEN_WD-TEX_GPAK_TITLE_W-TEX_SCARD_W)/2,
                      FRAME_Y+TOP_BAR_H+(72-TEX_GPAK_TITLE_H)/2 );
        drawTexRect( texScard,
                     G_IM_FMT_RGBA, G_IM_SIZ_16b,
                     TEX_SCARD_W, TEX_SCARD_H, 
                     32, 32, 1<<10, 1<<10,
                     TEX_SCARD_W, TEX_SCARD_H, 
                     (SCREEN_WD-TEX_GPAK_TITLE_W-TEX_SCARD_W)/2 + TEX_GPAK_TITLE_W+5,
                      FRAME_Y+TOP_BAR_H+(72-TEX_SCARD_H)/2 );
    } else if (gStatus==VW_GP_CPY_CNF ||
               gStatus==VW_GP_CPY_YES || 
               gStatus==VW_GP_CPY_SUCCESS || 
               gStatus==VW_ERR_GP_CPY_DST_NO_SPACE ||
               gStatus==VW_ERR_GP_CPY_DST_NO_TICKET ) {
        drawTexRect( texGpakTitle,
                     G_IM_FMT_RGBA, G_IM_SIZ_16b,
                     TEX_GPAK_TITLE_W, TEX_GPAK_TITLE_H,
                     32, 32, 1<<10, 1<<10,
                     TEX_GPAK_TITLE_W, TEX_GPAK_TITLE_H,
                     (SCREEN_WD-TEX_GPAK_TITLE_W-TEX_DCARD_W)/2,
                      FRAME_Y+TOP_BAR_H+(72-TEX_GPAK_TITLE_H)/2 );
        drawTexRect( texDcard,
                     G_IM_FMT_RGBA, G_IM_SIZ_16b,
                     TEX_DCARD_W, TEX_DCARD_H, 
                     32, 32, 1<<10, 1<<10,
                     TEX_DCARD_W, TEX_DCARD_H, 
                     (SCREEN_WD-TEX_GPAK_TITLE_W-TEX_DCARD_W)/2 + TEX_GPAK_TITLE_W+5,
                      FRAME_Y+TOP_BAR_H+(72-TEX_DCARD_H)/2 );
    } else {
        drawTexRect( texGpakTitle,
                     G_IM_FMT_RGBA, G_IM_SIZ_16b,
                     TEX_GPAK_TITLE_W, TEX_GPAK_TITLE_H,
                     32, 32, 1<<10, 1<<10,
                     TEX_GPAK_TITLE_W, TEX_GPAK_TITLE_H,
                     (SCREEN_WD-TEX_GPAK_TITLE_W)/2,
                      FRAME_Y+TOP_BAR_H+(72-TEX_GPAK_TITLE_H)/2 );
    }

    drawFrame(PAGE_GPAK);
}