Advertisement
fig02

Untitled

Aug 1st, 2022
1,010
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 4.45 KB | None | 0 0
  1. /**
  2.  * Sets up the frame for drawing.
  3.  * <some explanation here of the first part>
  4.  * The whole screen is filled with the color supplied as arguments.
  5.  * Letterbox is also applied here, and will share the color of the screen base.
  6.  */
  7. void Gfx_SetupFrame(GraphicsContext* gfxCtx, u8 r, u8 g, u8 b) {
  8.     OPEN_DISPS(gfxCtx, "../z_rcp.c", 2386);
  9.  
  10.     gSPDisplayList(POLY_OPA_DISP++, sFillSetupDL);
  11.     gSPDisplayList(POLY_XLU_DISP++, sFillSetupDL);
  12.     gSPDisplayList(OVERLAY_DISP++, sFillSetupDL);
  13.  
  14.     // whats this doing?
  15.     gDPSetScissor(POLY_OPA_DISP++, G_SC_NON_INTERLACE, 0, 0, gScreenWidth, gScreenHeight);
  16.     gDPSetScissor(POLY_XLU_DISP++, G_SC_NON_INTERLACE, 0, 0, gScreenWidth, gScreenHeight);
  17.     gDPSetScissor(OVERLAY_DISP++, G_SC_NON_INTERLACE, 0, 0, gScreenWidth, gScreenHeight);
  18.  
  19.     // whats this doing?
  20.     gDPSetColorImage(POLY_OPA_DISP++, G_IM_FMT_RGBA, G_IM_SIZ_16b, gScreenWidth, gfxCtx->curFrameBuffer);
  21.     gDPSetColorImage(POLY_OPA_DISP++, G_IM_FMT_RGBA, G_IM_SIZ_16b, gScreenWidth, gfxCtx->curFrameBuffer);
  22.     gDPSetColorImage(POLY_XLU_DISP++, G_IM_FMT_RGBA, G_IM_SIZ_16b, gScreenWidth, gfxCtx->curFrameBuffer);
  23.     gDPSetColorImage(OVERLAY_DISP++, G_IM_FMT_RGBA, G_IM_SIZ_16b, gScreenWidth, gfxCtx->curFrameBuffer);
  24.  
  25.     // whats this doing?
  26.     gDPSetDepthImage(POLY_OPA_DISP++, gZBuffer);
  27.     gDPSetDepthImage(POLY_XLU_DISP++, gZBuffer);
  28.     gDPSetDepthImage(OVERLAY_DISP++, gZBuffer);
  29.  
  30.     if ((R_PAUSE_MENU_MODE < 2) && (gTrnsnUnkState < 2)) {
  31.         s32 letterboxSize = Letterbox_GetSize();
  32.  
  33.         if (HREG(80) == 16) {
  34.             if (HREG(95) != 16) {
  35.                 HREG(81) = 3;
  36.                 HREG(82) = 3;
  37.                 HREG(83) = 0;
  38.                 HREG(84) = 0;
  39.                 HREG(85) = 0;
  40.                 HREG(86) = 0;
  41.                 HREG(87) = 0;
  42.                 HREG(88) = 0;
  43.                 HREG(89) = 0;
  44.                 HREG(90) = 0;
  45.                 HREG(91) = 0;
  46.                 HREG(92) = 0;
  47.                 HREG(93) = 0;
  48.                 HREG(94) = 0;
  49.                 HREG(95) = 16;
  50.             }
  51.  
  52.             if (HREG(81) & 1) {
  53.                 HREG(83) = letterboxSize;
  54.             }
  55.  
  56.             if (HREG(81) & 2) {
  57.                 HREG(84) = r;
  58.                 HREG(85) = g;
  59.                 HREG(86) = b;
  60.             }
  61.  
  62.             if (HREG(82) & 1) {
  63.                 letterboxSize = HREG(83);
  64.             }
  65.  
  66.             if (HREG(82) & 2) {
  67.                 r = HREG(84);
  68.                 g = HREG(85);
  69.                 b = HREG(86);
  70.             }
  71.         }
  72.        
  73.         // Set the whole z buffer to maximum depth.
  74.         // Dont bother with pixels that are being covered by the letterbox.
  75.         gDPSetColorImage(POLY_OPA_DISP++, G_IM_FMT_RGBA, G_IM_SIZ_16b, gScreenWidth, gZBuffer);
  76.         gDPSetCycleType(POLY_OPA_DISP++, G_CYC_FILL);
  77.         gDPSetRenderMode(POLY_OPA_DISP++, G_RM_NOOP, G_RM_NOOP2);
  78.         gDPSetFillColor(POLY_OPA_DISP++, (GPACK_ZDZ(G_MAXFBZ, 0) << 16) | GPACK_ZDZ(G_MAXFBZ, 0));
  79.         gDPFillRectangle(POLY_OPA_DISP++, 0, letterboxSize, gScreenWidth - 1, gScreenHeight - letterboxSize - 1);
  80.         gDPPipeSync(POLY_OPA_DISP++);
  81.  
  82.         // Fill the whole screen with the base color.
  83.         // Dont bother with pixels that are being covered by the letterbox.
  84.         gDPSetColorImage(POLY_OPA_DISP++, G_IM_FMT_RGBA, G_IM_SIZ_16b, gScreenWidth, gfxCtx->curFrameBuffer);
  85.         gDPSetCycleType(POLY_OPA_DISP++, G_CYC_FILL);
  86.         gDPSetRenderMode(POLY_OPA_DISP++, G_RM_NOOP, G_RM_NOOP2);
  87.         gDPSetFillColor(POLY_OPA_DISP++, (GPACK_RGBA5551(r, g, b, 1) << 16) | GPACK_RGBA5551(r, g, b, 1));
  88.         gDPFillRectangle(POLY_OPA_DISP++, 0, letterboxSize, gScreenWidth - 1, gScreenHeight - letterboxSize - 1);
  89.         gDPPipeSync(POLY_OPA_DISP++);
  90.  
  91.         // Draw the letterbox if applicable.
  92.         // Use the same color as the screen base.
  93.         if (letterboxSize > 0) {
  94.             gDPPipeSync(OVERLAY_DISP++);
  95.             gDPSetCycleType(OVERLAY_DISP++, G_CYC_FILL);
  96.             gDPSetRenderMode(OVERLAY_DISP++, G_RM_NOOP, G_RM_NOOP2);
  97.             gDPSetFillColor(OVERLAY_DISP++, (GPACK_RGBA5551(r, g, b, 1) << 16) | GPACK_RGBA5551(r, g, b, 1));
  98.             gDPFillRectangle(OVERLAY_DISP++, 0, 0, gScreenWidth - 1, letterboxSize - 1);
  99.             gDPFillRectangle(OVERLAY_DISP++, 0, gScreenHeight - letterboxSize, gScreenWidth - 1, gScreenHeight - 1);
  100.             gDPPipeSync(OVERLAY_DISP++);
  101.         }
  102.     }
  103.  
  104.     CLOSE_DISPS(gfxCtx, "../z_rcp.c", 2497);
  105. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement