pagecpak.c 17.8 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

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

extern UiTable gCpakTable;
extern UiImage gCpakrowImg;
extern UiImage gCpakrowhImg;

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

extern UiRow   gCpakRow[MAX_CONT_PAK];
extern UiImage gCpakImg[MAX_CONT_PAK];
extern UiImage gSaveImg;
extern u8      gCpakControllerStr[MAX_CONT_PAK * 3];

void onManageCpakHilite(int idx);
void onManageCpakSelect(int idx, u32 button);
void drawPageCpakBg();
void initPageCpakAssets();
void onCpakDelConfirmHilite(int idx);
void onCpakDelConfirmSelect(int idx, u32 button);
void onManageCpakCopyFromSelect(int idx, u32 button);
void onManageCpakCopyToSelect(int idx, u32 button);
void onCpakCpyConfirmHilite(int idx);
void onCpakCpyConfirmSelect(int idx, u32 button);

SaCpakCopy gCpak __attribute__ ((aligned (16)));
int        gPageCpakAssetsInit = 0;
static int gManageCpakIdx = 0;
static int gCpakDelConfirmIdx = 0;
static int gCpakCpyConfirmIdx = 0;

void initPageCpak(int row) 
{   
    initPageGame(0, 0);
    initPageCpakAssets();

    initCpakTable(1);
    initConfirmTable(2);
    gCpakTable.y = FRAME_Y+TOP_BAR_H+72;

    gPageNo = PAGE_CPAK;
    gManageCpakIdx = row;
    gStatus = VW_OK;
}

void doPageCpak()
{
    if (gStatus==VW_OK || gStatus==VW_CP_CPY_SRC_SELECT || gStatus==VW_CP_CPY_DST_SELECT)
        updateRowHilite( &gCpakTable );
    else if (gStatus==VW_CP_DEL_CNF || gStatus==VW_CP_CPY_CNF) 
        updateRowHilite( &gConfirmTable);

    drawPageCpakBg();

    switch (gStatus) {
    case VW_OK:
        if (gButton==CONT_B) {
            gButton = 0;
            gStatus = VW_OK;
            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 {
            drawColorString(gsError_38, CPAK_TEXT_X, CPAK_TEXT_Y, 0xFFFF);
            drawTable( &gCpakTable, &onManageCpakHilite, &onManageCpakSelect);
        }
        break;
    case VW_CP_DEL_CNF:
        drawTable( &gCpakTable, 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_30, 
                   (SCREEN_WD-TEX_BOARD_W)/2 + 20,
                   (SCREEN_HT-TEX_BOARD_H)/2 + 20, 0xFFFF);
        drawTable( &gConfirmTable, &onCpakDelConfirmHilite, &onCpakDelConfirmSelect);
        break;
    case VW_CP_CPY_SRC_CARD:
        if (gButton==CONT_B) {
            gButton = 0;
            gStatus = VW_OK;
            playSound(SOUND_MENU_UP, AUDIO_NOWAIT);
            return;
        } 
        gButton = 0;
        drawTable( &gCpakTable, 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_31, 
                   (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_CP_CPY_SRC_SELECT:  // select cpak from src. card
        drawColorString(gsError_39, GPAK_TEXT_X, GPAK_TEXT_Y+13, 0xFFFF);
        drawTable( &gCpakTable, &onManageCpakHilite, &onManageCpakCopyFromSelect);
        break;
    case VW_ERR_CP_CPY_SRC_EMPTY: 
        if (gButton==CONT_A) {
            gButton = 0;
            playSound(SOUND_MENU_UP, AUDIO_NOWAIT);
            gStatus = VW_CP_CPY_SRC_SELECT;
            return;
        } else if (gButton==CONT_B) {
            gButton = 0;
            playSound(SOUND_MENU_UP, AUDIO_NOWAIT);
            gStatus = VW_CP_CPY_CANCEL;
            return;
        }
        drawTable( &gCpakTable, 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_43, 
                   (SCREEN_WD-TEX_BOARD_W)/2 + (TEX_BOARD_W-26*9)/2,
                   (SCREEN_HT-TEX_BOARD_H)/2 + (TEX_BOARD_H-26*3)/2, 0xFFFF);
        break;
    case VW_ERR_CP_CPY_SRC_NO_TICKET:
        if (gButton==CONT_B) {
            gButton = 0;
            playSound(SOUND_MENU_UP, AUDIO_NOWAIT);
            gStatus = VW_CP_CPY_CANCEL;
            return;
        }
        gButton = 0;
        drawTable( &gCpakTable, 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_32,  
                        (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_CP_CPY_SRC_NO_CPAK:
        if (gButton==CONT_B) {
            gButton = 0;
            playSound(SOUND_MENU_UP, AUDIO_NOWAIT);
            gStatus = VW_CP_CPY_CANCEL;
            return;
        }
        gButton = 0;
        drawTable( &gCpakTable, 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_34,  // no cpak 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_CP_CPY_DST_CARD: // waiting for dst. card for cpak copy
        gButton = 0;
        drawTable( &gCpakTable, 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_35, 
                    (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_CP_CPY_CNF: // cpak exists, overwrite?
        drawTable( &gCpakTable, 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_33, 
                    (SCREEN_WD-TEX_BOARD_W)/2 + 20,
                    (SCREEN_HT-TEX_BOARD_H)/2 + 20, 0xFFFF);
        drawTable( &gConfirmTable, &onCpakCpyConfirmHilite, &onCpakCpyConfirmSelect);
        break;
    case VW_CP_CPY_SUCCESS:
        if (gButton==CONT_A) {
            gButton = 0;
            playSound(SOUND_MENU_UP, AUDIO_NOWAIT);
            gStatus = VW_OK;
        }
        drawTable( &gCpakTable, 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_42,  
                    (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_CP_CPY_CANCEL:
        gButton = 0;
        drawTable( &gCpakTable, 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_37, 
                    (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_CP_CPY_DST_SELECT:
        drawColorString(gsError_40, GPAK_TEXT_X, GPAK_TEXT_Y+13, 0xFFFF);
        drawTable( &gCpakTable, &onManageCpakHilite, &onManageCpakCopyToSelect);
        break;
    case VW_ERR_CP_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) 
                initPageCpak(0);
            return;
        }

        gButton = 0;
        drawTable( &gCpakTable, 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_41,  
                    (SCREEN_WD-TEX_BOARD_W)/2 + 5,
                    (SCREEN_HT-TEX_BOARD_H)/2 + 8, 0xFFF);
        break;
    case VW_ERR_CP_CPY_WRONG_DST_CARD:
        if (gButton==CONT_B) {
            gButton = 0;
            playSound(SOUND_MENU_UP, AUDIO_NOWAIT);
            gStatus = VW_CP_CPY_CANCEL;
            return;
        }

        gButton = 0;
        drawTable( &gCpakTable, 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_36, 
                    (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 onManageCpakHilite( int idx )
{
    int i;

    if (gManageCpakIdx != idx) {
        playSound(SOUND_SELECTION_MOVE, AUDIO_NOWAIT);
        gManageCpakIdx = idx;
    }
    for (i=0; i<gCpakTable.total_rows; i++) {
        if (i!=idx)
            gCpakRow[i].bg = &gCpakrowImg;
        else 
            gCpakRow[i].bg = &gCpakrowhImg;
    }
}

void onManageCpakSelect( int idx, u32 button )
{
    if (button==CONT_B) { 
        playSound(SOUND_MENU_UP, AUDIO_NOWAIT);
        initPageTop(PAGE_MANAGE);
        gStatus = VW_OK;
    } else if (button==CONT_G) {
        if (gCpakList[idx].cid!=0) {
            playSound(SOUND_MENU_DOWN, AUDIO_NOWAIT);
            gManageCpakIdx = idx;
            gStatus = VW_CP_DEL_CNF;
        }
    } else if (button==CONT_A) {
        playSound(SOUND_MENU_DOWN, AUDIO_NOWAIT);
        gStatus = VW_CP_CPY_SRC_CARD;
    }
}

void onManageCpakCopyFromSelect(int idx, u32 button)
{
    s32 fd;
    char state_file[16];
    sprintf(state_file, "%d.pak", idx);

    gManageCpakIdx = idx;

    if (button==CONT_A) {
        if ((fd=osBbFOpen(state_file, "r"))<0)  {
            playSound(SOUND_MENU_DOWN, AUDIO_NOWAIT);
            gStatus = VW_ERR_CP_CPY_SRC_EMPTY;
        } else if (gCpakList[idx].cid!=0) {
            osBbFClose(fd);
            uiGetCpakCopy(idx, &gCpak);
            playSound(SOUND_MENU_DOWN, AUDIO_NOWAIT);
            gStatus = VW_CP_CPY_DST_CARD;
        } 
    }
}

void onManageCpakCopyToSelect(int idx, u32 button)
{
    gManageCpakIdx = idx;

    if (button==CONT_A) {
        gButton = 0;
        if (gCpakList[idx].cid!=0) {
            gStatus = VW_CP_CPY_CNF;
        } else {
            uiCopyCpak( gManageCpakIdx, &gCpak );
            playSound(SOUND_MENU_UP, AUDIO_NOWAIT);
            initPageCpak(gManageCpakIdx);
            gStatus = VW_CP_CPY_SUCCESS;
        }
    }
}

void onCpakDelConfirmHilite( int idx )
{
    if (gCpakDelConfirmIdx != idx) {
        playSound(SOUND_SELECTION_MOVE, AUDIO_NOWAIT);
        gCpakDelConfirmIdx = 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 onCpakDelConfirmSelect( int idx, u32 button ) 
{
    if (button==CONT_A) {
        gButton = 0;
        if (idx==0) {    // delete cpak
            uiEmptyCpak(gManageCpakIdx);
            playSound(SOUND_LOAD_MCELL, AUDIO_NOWAIT);
            initPageCpak(gManageCpakIdx);
        } else if (idx==1) {  // cancel
            playSound(SOUND_MENU_UP, AUDIO_NOWAIT);
            gStatus = VW_OK;
        }
    }
}

void onCpakCpyConfirmHilite( int idx )
{
    if (gCpakCpyConfirmIdx != idx) {
        playSound(SOUND_SELECTION_MOVE, AUDIO_NOWAIT);
        gCpakCpyConfirmIdx = 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 onCpakCpyConfirmSelect( int idx, u32 button ) 
{
    if (button==CONT_A) {
        gButton = 0;
        if (idx==0) {    // copy cpak
            uiCopyCpak(gManageCpakIdx, &gCpak);
            playSound(SOUND_LOAD_MCELL, AUDIO_NOWAIT);
            initPageCpak(gManageCpakIdx);
            gStatus = VW_CP_CPY_SUCCESS;
        } else if (idx==1) {  // cancel
            playSound(SOUND_MENU_UP, AUDIO_NOWAIT);
            gStatus = VW_OK;
        }
    }
}

void drawPageCpakBg()
{
    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_CP_CPY_SRC_SELECT ||
        gStatus==VW_ERR_CP_CPY_SRC_EMPTY || 
        gStatus==VW_ERR_CP_CPY_SRC_NO_TICKET || 
        gStatus==VW_ERR_CP_CPY_SRC_NO_CPAK ||
        gStatus==VW_ERR_CP_CPY_WRONG_DST_CARD ||
        gStatus==VW_CP_CPY_DST_CARD) {
        drawTexRect( texCpakTitle,
                     G_IM_FMT_RGBA, G_IM_SIZ_16b,
                     TEX_CPAK_TITLE_W, TEX_CPAK_TITLE_H,
                     32, 32, 1<<10, 1<<10,
                     TEX_CPAK_TITLE_W, TEX_CPAK_TITLE_H,
                     (SCREEN_WD-TEX_CPAK_TITLE_W-TEX_SCARD_W)/2, 
                     FRAME_Y+TOP_BAR_H+(72-TEX_CPAK_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_CPAK_TITLE_W-TEX_SCARD_W)/2+TEX_CPAK_TITLE_W+5, 
                     FRAME_Y+TOP_BAR_H+(72-TEX_SCARD_H)/2);
    } else if (gStatus==VW_CP_CPY_CNF ||
               gStatus==VW_CP_CPY_SUCCESS ||
               gStatus==VW_CP_CPY_DST_SELECT || 
               gStatus==VW_ERR_CP_CPY_DST_NO_TICKET) {
        drawTexRect( texCpakTitle,
                     G_IM_FMT_RGBA, G_IM_SIZ_16b,
                     TEX_CPAK_TITLE_W, TEX_CPAK_TITLE_H,
                     32, 32, 1<<10, 1<<10,
                     TEX_CPAK_TITLE_W, TEX_CPAK_TITLE_H,
                     (SCREEN_WD-TEX_CPAK_TITLE_W-TEX_DCARD_W)/2, 
                     FRAME_Y+TOP_BAR_H+(72-TEX_CPAK_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_CPAK_TITLE_W-TEX_DCARD_W)/2+TEX_CPAK_TITLE_W+5, 
                     FRAME_Y+TOP_BAR_H+(72-TEX_DCARD_H)/2);
    } else {
        drawTexRect( texCpakTitle,
                     G_IM_FMT_RGBA, G_IM_SIZ_16b,
                     TEX_CPAK_TITLE_W, TEX_CPAK_TITLE_H,
                     32, 32, 1<<10, 1<<10,
                     TEX_CPAK_TITLE_W, TEX_CPAK_TITLE_H,
                     (SCREEN_WD-TEX_CPAK_TITLE_W)/2, FRAME_Y+TOP_BAR_H+(72-TEX_CPAK_TITLE_H)/2);
    }

    drawFrame(PAGE_CPAK);
}

void initPageCpakAssets()
{
    int outsize;

    if (!gPageCpakAssetsInit) {
        bzero(texCpakTitle, TEX_CPAK_TITLE_H*TEX_CPAK_TITLE_W*2);
        outsize = expand_gzip( gzTexCpakTitle, texCpakTitle, gzTexCpakTitleSize, TEX_CPAK_TITLE_H*TEX_CPAK_TITLE_W*2);

        gPageCpakAssetsInit = 1;
    }
}