341{
343 u8 primR, primG, primB, primA, envR, envG, envB, envA;
348 u32 bgWidth, bgHeight;
349 u32 cornerWidth, cornerHeight;
350 s32 masks, maskt;
351 Vtx* quads;
352 s32 idx;
353 s32 i, j;
354 s32 tmem = 0x100;
355 u32 bgScrollOffsetX, bgScrollOffsetY;
356
357 s32 foo;
358 s32 alpha = foo * opacity / 255;
359
362
363 primR = defaultStyle->
color1.
r;
364 primG = defaultStyle->
color1.
g;
365 primB = defaultStyle->
color1.
b;
366 primA = defaultStyle->
color1.
a * opacity / 255;
371
374 } else {
383
387 }
388 {
389 u8* bgImage;
390 u8* cornersImage;
391 s32 bgFmt;
392 s32 bgMasks;
393 s32 bgMaskt;
395 u32 cornersFmt;
396 u32 cornersBitDepth;
397 Mtx* sp154;
398
399 bgFmt = background->
fmt;
400 cornersImage = corners->
imgData;
401
402 bgWidth = background->
width;
404 bgHeight = background->
height;
405
408
409 quads = NULL;
410 sp154 = NULL;
412 cornersFmt = corners->
fmt;
413 cornersBitDepth = corners->
bitDepth;
414
415 if (width <= 0 || height <= 0 || opacity == 0 || posX <= -768 || posY <= -768) {
416 return TRUE;
417 }
418
420 return TRUE;
421 }
422
423 if (posX + width >= 768 || posY + height >= 768 || posX + width <= 0 || posY + height <= 0) {
424 return TRUE;
425 }
426
431 }
432 }
433
441 }
442
443 if (defaultStyle != NULL) {
446 } else {
448 if (primA != 255) {
450 } else {
452 }
453 }
454
457
458 if (quads != NULL) {
460 guFrustumF(mtx1, -80.0f, 80.0f, 60.0f, -60.0f, 160.0f, 480.0f, 1.0f);
464 guPositionF(mtx1, rotX, rotY, rotZ, 1.0f, posX + width / 2, posY + height / 2, posZ);
465 if (scaleX != 1.0f || scaleY != 1.0f) {
466 guScaleF(mtx2, scaleX, scaleY, 1.0f);
468 }
469 if (rotScaleMtx != 0) {
470 guTranslateF(mtx2, -translateX / 2, -translateY / 2, 0.0f);
473 }
474 if (outMtx) {
475 for (i = 0; i < 4; i++) {
476 for (j = 0; j < 4; j++) {
477 outMtx[i][j] = mtx1[i][j];
478 }
479 }
480 }
483 gSPClearGeometryMode(
gMainGfxPos++, G_CULL_BOTH | G_LIGHTING);
486 }
491 } else {
493 }
494
495 gSPTexture(
gMainGfxPos++, 0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_ON);
499 gDPSetPrimColor(
gMainGfxPos++, 0, 0, primR, primG, primB, primA);
500 gDPSetEnvColor(
gMainGfxPos++, envR, envG, envB, envA);
501 if (bgImage != NULL) {
503 case G_IM_SIZ_4b:
504 gDPLoadTextureTile_4b(
gMainGfxPos++, bgImage, bgFmt, bgWidth, bgHeight, 0, 0, bgWidth - 1, bgHeight - 1, 0, G_TX_WRAP, G_TX_WRAP, bgMasks, bgMaskt, G_TX_NOLOD, G_TX_NOLOD);
505 break;
506 case G_IM_SIZ_8b:
507 gDPLoadTextureTile(
gMainGfxPos++, bgImage, bgFmt, G_IM_SIZ_8b, bgWidth, bgHeight, 0, 0, bgWidth - 1, bgHeight - 1, 0, G_TX_WRAP, G_TX_WRAP, bgMasks, bgMaskt, G_TX_NOLOD, G_TX_NOLOD);
508 break;
509 case G_IM_SIZ_16b:
510 gDPLoadTextureTile(
gMainGfxPos++, bgImage, bgFmt, G_IM_SIZ_16b, bgWidth, bgHeight, 0, 0, bgWidth - 1, bgHeight - 1, 0, G_TX_WRAP, G_TX_WRAP, bgMasks, bgMaskt, G_TX_NOLOD, G_TX_NOLOD);
511 break;
512 case G_IM_SIZ_32b:
513 gDPLoadTextureTile(
gMainGfxPos++, bgImage, bgFmt, G_IM_SIZ_32b, bgWidth, bgHeight, 0, 0, bgWidth - 1, bgHeight - 1, 0, G_TX_WRAP, G_TX_WRAP, bgMasks, bgMaskt, G_TX_NOLOD, G_TX_NOLOD);
514 break;
515 }
516
519 bgScrollOffsetX = 511 - bgScrollOffsetY;
521 width / 2 * 4 + bgScrollOffsetX,
522 height / 2 * 4 + bgScrollOffsetY,
523 (width / 2 + bgWidth - 1) * 4 + bgScrollOffsetX,
524 (height / 2 + bgHeight - 1) * 4 + bgScrollOffsetY);
525 } else {
526 gDPSetTileSize(
gMainGfxPos++, G_TX_RENDERTILE, width / 2 * 4, height / 2 * 4,
527 (width / 2 + bgWidth - 1) * 4, (height / 2 + bgHeight - 1)* 4);
528 }
529 }
530
531 if (cornersImage != NULL) {
532 for (idx = 0; idx < 4; idx++) {
533 cornerWidth = cornersSizes[idx].x;
534 cornerHeight = cornersSizes[idx].y;
537
538 switch (cornersBitDepth) {
539 case G_IM_SIZ_4b:
540 gDPLoadMultiTile_4b(
gMainGfxPos++, cornersImage, tmem, 1, cornersFmt, cornerWidth, cornerHeight, 0, 0, cornerWidth - 1, cornerHeight - 1, 0, G_TX_CLAMP, G_TX_CLAMP, masks, maskt, G_TX_NOLOD, G_TX_NOLOD);
541 cornersImage += cornerWidth * cornerHeight / 2;
542 break;
543 case G_IM_SIZ_8b:
544 gDPLoadMultiTile(
gMainGfxPos++, cornersImage, tmem, 1, cornersFmt, G_IM_SIZ_8b, cornerWidth, cornerHeight, 0, 0, cornerWidth - 1, cornerHeight - 1, 0, G_TX_CLAMP, G_TX_CLAMP, masks, maskt, G_TX_NOLOD, G_TX_NOLOD);
545 cornersImage += cornerWidth * cornerHeight;
546 break;
547 case G_IM_SIZ_16b:
548 gDPLoadMultiTile(
gMainGfxPos++, cornersImage, tmem, 1, cornersFmt, G_IM_SIZ_16b, cornerWidth, cornerHeight, 0, 0, cornerWidth - 1, cornerHeight - 1, 0, G_TX_CLAMP, G_TX_CLAMP, masks, maskt, G_TX_NOLOD, G_TX_NOLOD);
549 cornersImage += cornerWidth * cornerHeight * 2;
550 break;
551 case G_IM_SIZ_32b:
552 gDPLoadMultiTile(
gMainGfxPos++, cornersImage, tmem, 1, cornersFmt, G_IM_SIZ_32b, cornerWidth, cornerHeight, 0, 0, cornerWidth - 1, cornerHeight - 1, 0, G_TX_CLAMP, G_TX_CLAMP, masks, maskt, G_TX_NOLOD, G_TX_NOLOD);
553 cornersImage += cornerWidth * cornerHeight * 4;
554 break;
555 }
556
557 switch(idx) {
558 case 1:
559 gDPSetTileSize(
gMainGfxPos++, 1, (width - cornerWidth) * 4, 0, (width - 1) * 4, (cornerHeight - 1) * 4);
560 break;
561 case 2:
562 gDPSetTileSize(
gMainGfxPos++, 1, 0, (height - cornerHeight) * 4, (cornerWidth - 1) * 4, (height - 1) * 4);
563 break;
564 case 3:
565 gDPSetTileSize(
gMainGfxPos++, 1, (width - cornerWidth) * 4, (height - cornerHeight) * 4, (width - 1) * 4, (height - 1) * 4);
566 break;
567 }
568
569 if (quads != NULL) {
570 switch(idx) {
571 case 0:
572 quads[0].v.ob[0] = -width / 2;
573 quads[0].v.ob[1] = -height / 2;
574 quads[0].v.ob[2] = 0;
575
576 quads[1].v.ob[0] = 0;
577 quads[1].v.ob[1] = -height / 2;
578 quads[1].v.ob[2] = 0;
579
580 quads[2].v.ob[0] = -width / 2;
581 quads[2].v.ob[1] = 0;
582 quads[2].v.ob[2] = 0;
583
584 quads[3].v.ob[0] = 0;
585 quads[3].v.ob[1] = 0;
586 quads[3].v.ob[2] = 0;
587
588 quads[0].v.tc[0] = 0;
589 quads[0].v.tc[1] = 0;
590
591 quads[1].v.tc[0] = (width / 2) * 32;
592 quads[1].v.tc[1] = 0;
593
594 quads[2].v.tc[0] = 0;
595 quads[2].v.tc[1] = (height / 2) * 32;
596
597 quads[3].v.tc[0] = (width / 2) * 32;
598 quads[3].v.tc[1] = (height / 2) * 32;
599 break;
600 case 1:
601 quads[4].v.ob[0] = 0;
602 quads[4].v.ob[1] = -height / 2;
603 quads[4].v.ob[2] = 0;
604
605 quads[5].v.ob[0] = (-width / 2) + width;
606 quads[5].v.ob[1] = -height / 2;
607 quads[5].v.ob[2] = 0;
608
609 quads[6].v.ob[0] = 0;
610 quads[6].v.ob[1] = 0;
611 quads[6].v.ob[2] = 0;
612
613 quads[7].v.ob[0] = (-width / 2) + width;
614 quads[7].v.ob[1] = 0;
615 quads[7].v.ob[2] = 0;
616
617 quads[4].v.tc[0] = (width / 2) * 32;
618 quads[4].v.tc[1] = 0;
619
620 quads[5].v.tc[0] = width * 32;
621 quads[5].v.tc[1] = 0;
622
623 quads[6].v.tc[0] = (width / 2) * 32;
624 quads[6].v.tc[1] = (height / 2) * 32;
625
626 quads[7].v.tc[0] = width * 32;
627 quads[7].v.tc[1] = (height / 2) * 32;
628
629#ifndef SHIFT
630 quads += 4;
631#endif
632 break;
633 case 2:
634 quads[8].v.ob[0] = -width / 2;
635 quads[8].v.ob[1] = 0;
636 quads[8].v.ob[2] = 0;
637
638 quads[9].v.ob[0] = 0;
639 quads[9].v.ob[1] = 0;
640 quads[9].v.ob[2] = 0;
641
642 quads[10].v.ob[0] = -width / 2;
643 quads[10].v.ob[1] = height / 2;
644 quads[10].v.ob[2] = 0;
645
646 quads[11].v.ob[0] = 0;
647 quads[11].v.ob[1] = height / 2;
648 quads[11].v.ob[2] = 0;
649
650 quads[8].v.tc[0] = 0;
651 quads[8].v.tc[1] = (height / 2) * 32;
652
653 quads[9].v.tc[0] = (width / 2) * 32;
654 quads[9].v.tc[1] = (height / 2) * 32;
655
656 quads[10].v.tc[0] = 0;
657 quads[10].v.tc[1] = height * 32;
658
659 quads[11].v.tc[0] = (width / 2) * 32;
660 quads[11].v.tc[1] = height * 32;
661
662#ifndef SHIFT
663 quads += 8;
664#endif
665 break;
666 case 3:
667 quads[12].v.ob[0] = 0;
668 quads[12].v.ob[1] = 0;
669 quads[12].v.ob[2] = 0;
670
671 quads[13].v.ob[0] = (-width / 2) + width;
672 quads[13].v.ob[1] = 0;
673 quads[13].v.ob[2] = 0;
674
675 quads[14].v.ob[0] = 0;
676 quads[14].v.ob[1] = height / 2;
677 quads[14].v.ob[2] = 0;
678
679 quads[15].v.ob[0] = (-width / 2) + width;
680 quads[15].v.ob[1] = height / 2;
681 quads[15].v.ob[2] = 0;
682
683 quads[12].v.tc[0] = (width / 2) * 32;
684 quads[12].v.tc[1] = (height / 2) * 32;
685
686 quads[13].v.tc[0] = width * 32;
687 quads[13].v.tc[1] = (height / 2) * 32;
688
689 quads[14].v.tc[0] = (width / 2) * 32;
690 quads[14].v.tc[1] = height * 32;
691
692 quads[15].v.tc[0] = width * 32;
693 quads[15].v.tc[1] = height * 32;
694
695#ifndef SHIFT
696 quads += 12;
697#endif
698 break;
699 }
700#ifdef SHIFT
702#else
704#endif
705 gSP2Triangles(
gMainGfxPos++, 0, 3, 1, 0, 0, 2, 3, 0);
706 } else {
707 switch (idx) {
708 case 0:
709 gSPScisTextureRectangle(
gMainGfxPos++, posX * 4, posY * 4, (posX + width / 2) * 4, (posY + height / 2) * 4, G_TX_RENDERTILE, 0, 0, 0x400, 0x400);
710 break;
711 case 1:
712 gSPScisTextureRectangle(
gMainGfxPos++, (posX + width / 2) * 4, posY * 4, (posX + width) * 4, (posY + height / 2) * 4, G_TX_RENDERTILE, (width / 2) * 32, 0, 0x400, 0x400);
713 break;
714 case 2:
715 gSPScisTextureRectangle(
gMainGfxPos++, posX * 4, (posY + height / 2) * 4, (posX + width / 2) * 4, (posY + height) * 4, G_TX_RENDERTILE, 0, (height / 2) * 32, 0x400, 0x400);
716 break;
717 case 3:
718 gSPScisTextureRectangle(
gMainGfxPos++, (posX + width / 2) * 4, (posY + height / 2) * 4, (posX + width) * 4, (posY + height) * 4, G_TX_RENDERTILE, (width / 2) * 32, (height / 2) * 32, 0x400, 0x400);
719 break;
720 }
721
722 }
724 }
725 } else if (bgImage != NULL) {
726 if (quads != NULL) {
727 quads[0].v.ob[0] = -width / 2;
728 quads[0].v.ob[1] = -height / 2;
729 quads[0].v.ob[2] = 0;
730
731 quads[1].v.ob[0] = (-width / 2) + width;
732 quads[1].v.ob[1] = -height / 2;
733 quads[1].v.ob[2] = 0;
734
735 quads[2].v.ob[0] = -width / 2;
736 quads[2].v.ob[1] = height / 2;
737 quads[2].v.ob[2] = 0;
738
739 quads[3].v.ob[0] = (-width / 2) + width;
740 quads[3].v.ob[1] = height / 2;
741 quads[3].v.ob[2] = 0;
742
743 quads[0].v.tc[0] = 0;
744 quads[0].v.tc[1] = 0;
745
746 quads[1].v.tc[1] = 0;
747 quads[1].v.tc[0] = width * 32;
748
749 quads[2].v.tc[0] = 0;
750 quads[2].v.tc[1] = height * 32;
751
752 quads[3].v.tc[0] = width * 32;
753 quads[3].v.tc[1] = height * 32;
754
756 gSP2Triangles(
gMainGfxPos++, 0, 3, 1, 0, 0, 2, 3, 0);
757 } else {
758 gSPScisTextureRectangle(
gMainGfxPos++, posX * 4, posY * 4, (posX + width) * 4, (posY + height) * 4, G_TX_RENDERTILE, 0, 0, 0x0400, 0x0400);
759 }
761 }
762
765 if(fpDrawContents != NULL) {
766 if (quads != NULL) {
768 if(mdl_address != 0) {
769 gDPSetColorImage(
gMainGfxPos++, G_IM_FMT_RGBA, G_IM_SIZ_16b, width, OS_K0_TO_PHYSICAL(mdl_address));
770 gDPSetScissor(
gMainGfxPos++, G_SC_NON_INTERLACE, 0, 0, width, height);
773 gDPSetRenderMode(
gMainGfxPos++, G_RM_NOOP, G_RM_NOOP2);
774 gDPFillRectangle(
gMainGfxPos++, 0, 0, width - 1, height - 1);
776 gDPSetScissorFrac(
gMainGfxPos++, G_SC_NON_INTERLACE, 4, 4, (width - 1) * 4.0f, (height - 1) * 4.0f);
778
779 fpDrawContents((s32)drawContentsArg0, 0, 0, width, height, opacity, darkening);
780
783 gDPSetScissor(
gMainGfxPos++, G_SC_NON_INTERLACE, 0, 0, 320, 240);
785 gSPMatrix(
gMainGfxPos++, sp154, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION);
786 gSPTexture(
gMainGfxPos++, 0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_ON);
789 gDPSetCombineMode(
gMainGfxPos++, G_CC_DECALRGBA, G_CC_DECALRGBA);
790 gDPSetRenderMode(
gMainGfxPos++, G_RM_CLD_SURF, G_RM_NOOP2);
798 for (idx = 0; idx < height / 6; idx++) {
799 s32 extraHeight, lineHeight;
800 if (idx == height / 6 - 1) {
801 extraHeight = 0;
802 if (height % 6 != 0) {
803 extraHeight = 1;
804 }
805 } else {
806 extraHeight = 1;
807 }
808 lineHeight = extraHeight + 5;
809 gDPLoadTextureTile(
gMainGfxPos++, OS_K0_TO_PHYSICAL(mdl_address), G_IM_FMT_RGBA, G_IM_SIZ_16b, width, 0,
810 0, idx * 6, width - 1, idx * 6 + lineHeight, 0,
811 G_TX_CLAMP, G_TX_CLAMP, 9, 3, G_TX_NOLOD, G_TX_NOLOD);
812 gDPSetTileSize(
gMainGfxPos++, G_TX_RENDERTILE, (160 - width / 2) * 4, 0, ((160 - width / 2) + width - 1) * 4, lineHeight * 4);
814 gSP2Triangles(
gMainGfxPos++, 0, 3, 1, 0, 0, 2, 3, 0);
817 }
818 }
819 } else {
820 fpDrawContents((s32)drawContentsArg0, posX, posY, width, height, opacity, darkening);
821 }
822 }
823 if (quads != NULL) {
827 }
828 return FALSE;
829 }
830}
WindowBackground background
Gfx transparentCombineMode
WindowStyleCustom * customStyle
DefaultWindowStyle gBoxDefaultStyles[]
BSS Vtx gBoxQuadBuffer[21][16]
WindowCorners gBoxCorners[]
#define BOX_QUAD_BUFFER_NUM
WindowBackground gBoxBackground[]
@ DRAW_FLAG_ANIMATED_BACKGROUND
void * mdl_get_next_texture_address(s32)
#define PACK_FILL_COLOR(r, g, b, a)
GameStatus * gGameStatusPtr
DisplayContext * gDisplayContext