Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
screen_overlays.c
Go to the documentation of this file.
1#include "common.h"
2#include "overlay.h"
3#include "include_asset.h"
4
11
13
14INCLUDE_IMG("ui/stencil/star.png", ui_stencil_star_png);
15
16INCLUDE_IMG("ui/stencil/mario.png", ui_stencil_mario_png);
17
18INCLUDE_IMG("ui/stencil/sharp_circle.png", ui_stencil_sharp_circle_png);
19
20INCLUDE_IMG("ui/stencil/blurry_circle.png", ui_stencil_blurry_circle_png);
21
22#include "vtx/stencil1.vtx.inc.c"
23
25 gsSPTexture(0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_ON),
26 gsDPPipeSync(),
27 gsDPSetCycleType(G_CYC_1CYCLE),
28 gsDPSetTextureDetail(G_TD_CLAMP),
29 gsDPSetTextureLOD(G_TL_TILE),
30 gsDPSetTextureFilter(G_TF_AVERAGE),
31 gsDPSetTextureConvert(G_TC_FILT),
32 gsDPSetTexturePersp(G_TP_NONE),
33 gsDPSetColorDither(G_CD_MAGICSQ),
34 gsDPSetAlphaDither(G_AD_PATTERN),
35 gsDPSetCombineMode(PM_CC_3A, PM_CC_3A),
36 gsDPSetRenderMode(G_RM_CLD_SURF, G_RM_CLD_SURF2),
37 gsSPClearGeometryMode(G_ZBUFFER | G_SHADE | G_CULL_BOTH | G_FOG | G_LIGHTING | G_TEXTURE_GEN | G_TEXTURE_GEN_LINEAR | G_LOD | G_SHADING_SMOOTH | G_CLIPPING | 0x0040F9FA),
38 gsSPSetGeometryMode(G_SHADE | G_SHADING_SMOOTH),
39 gsSPEndDisplayList()
40};
41
43 gsSPDisplayList(Gfx_LoadStencilTex_CommonParams),
44 gsDPSetTextureLUT(G_TT_NONE),
45 gsDPLoadTextureTile_4b(ui_stencil_sharp_circle_png, G_IM_FMT_I, 32, 0, 0, 0, 31, 31, 0, G_TX_MIRROR | G_TX_CLAMP, G_TX_MIRROR | G_TX_CLAMP, 5, 5, G_TX_NOLOD, G_TX_NOLOD),
46 gsDPSetTileSize(G_TX_RENDERTILE, 0, 0, 0x00FC, 0x00FC),
47 gsSPEndDisplayList()
48};
49
51 gsSPDisplayList(Gfx_LoadStencilTex_CommonParams),
52 gsDPSetTextureLUT(G_TT_NONE),
53 gsDPLoadTextureTile_4b(ui_stencil_mario_png, G_IM_FMT_I, 64, 0, 0, 0, 63, 63, 0, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMIRROR | G_TX_CLAMP, 6, 6, G_TX_NOLOD, G_TX_NOLOD),
54 gsSPEndDisplayList()
55};
56
58 gsSPDisplayList(Gfx_LoadStencilTex_CommonParams),
59 gsDPSetTextureLUT(G_TT_NONE),
60 gsDPLoadTextureTile_4b(ui_stencil_star_png, G_IM_FMT_I, 32, 0, 0, 0, 31, 63, 0, G_TX_MIRROR | G_TX_CLAMP, G_TX_NOMIRROR | G_TX_CLAMP, 5, 6, G_TX_NOLOD, G_TX_NOLOD),
61 gsDPSetTileSize(G_TX_RENDERTILE, 0, 0, 0x00FC, 0x00FC),
62 gsSPEndDisplayList(),
63};
64
66 gsSPDisplayList(Gfx_LoadStencilTex_CommonParams),
67 gsDPSetTextureLUT(G_TT_NONE),
68 gsDPSetTextureImage(G_IM_FMT_I, G_IM_SIZ_8b, 64, ui_stencil_blurry_circle_png),
69 gsDPSetTile(G_IM_FMT_I, G_IM_SIZ_8b, 8, 0x0000, G_TX_LOADTILE, 0, G_TX_MIRROR | G_TX_CLAMP, 6, G_TX_NOLOD, G_TX_MIRROR | G_TX_CLAMP, 6, G_TX_NOLOD),
70 gsDPLoadSync(),
71 gsDPLoadTile(G_TX_LOADTILE, 0, 0, 0x00FC, 0x00FC),
72 gsDPPipeSync(),
73 gsDPSetTile(G_IM_FMT_I, G_IM_SIZ_8b, 8, 0x0000, G_TX_RENDERTILE, 0, G_TX_MIRROR | G_TX_CLAMP, 6, G_TX_NOLOD, G_TX_MIRROR | G_TX_CLAMP, 6, G_TX_NOLOD),
74 gsDPSetTileSize(G_TX_RENDERTILE, 0, 0, 0x00FC, 0x00FC),
75 gsDPSetTileSize(G_TX_RENDERTILE, 0, 0, 0x01FC, 0x01FC),
76 gsSPEndDisplayList()
77};
78
79#include "vtx/stencil2.vtx.inc.c"
80
81Gfx D_8014E8F0[] = {
82 gsSPTexture(0x8000, 0x8000, 0, G_TX_RENDERTILE, G_OFF),
83 gsDPPipeSync(),
84 gsDPSetCycleType(G_CYC_1CYCLE),
85 gsDPSetDepthSource(G_ZS_PRIM),
86 gsDPSetPrimDepth(0, 0),
87 gsDPSetRenderMode(Z_UPD | IM_RD | CVG_DST_SAVE | ZMODE_OPA | FORCE_BL | GBL_c1(G_BL_CLR_MEM, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA), Z_UPD | IM_RD | CVG_DST_SAVE | ZMODE_OPA | FORCE_BL | GBL_c2(G_BL_CLR_MEM, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA)),
88 gsDPSetCombineMode(PM_CC_SCREEN_OVERLAY, PM_CC_SCREEN_OVERLAY),
89 gsDPSetTexturePersp(G_TP_PERSP),
90 gsDPSetTextureDetail(G_TD_CLAMP),
91 gsDPSetTextureLOD(G_TL_TILE),
92 gsDPSetTextureLUT(G_TT_NONE),
93 gsDPSetTextureFilter(G_TF_BILERP),
94 gsDPSetTextureConvert(G_TC_FILT),
95 gsSPClearGeometryMode(G_CULL_BOTH | G_LIGHTING | G_SHADING_SMOOTH),
96 gsSPSetGeometryMode(G_ZBUFFER | G_SHADE | G_CULL_BACK),
97 gsSPVertex(&vtx_stencil1, 10, 0),
98 gsSP2Triangles(0, 1, 2, 0, 3, 0, 2, 0),
99 gsSP2Triangles(0, 4, 1, 0, 3, 5, 0, 0),
100 gsSP2Triangles(1, 6, 2, 0, 7, 3, 2, 0),
101 gsSP2Triangles(8, 7, 2, 0, 7, 9, 3, 0),
102 gsDPPipeSync(),
103 gsDPSetDepthSource(G_ZS_PIXEL),
104 gsSPEndDisplayList()
105};
106
107Gfx D_8014E9A8[] = {
108 gsDPPipeSync(),
109 gsDPSetDepthSource(G_ZS_PRIM),
110 gsDPSetPrimDepth(20, 0),
111 gsDPSetRenderMode(G_RM_ZB_XLU_SURF, G_RM_ZB_XLU_SURF2),
112 gsDPSetCombineMode(PM_CC_SCREEN_OVERLAY, PM_CC_SCREEN_OVERLAY),
113 gsSPClearGeometryMode(G_CULL_BOTH | G_LIGHTING | G_SHADING_SMOOTH),
114 gsSPSetGeometryMode(G_ZBUFFER | G_SHADE),
115 gsDPSetColorDither(G_CD_MAGICSQ),
116 gsDPSetCycleType(G_CYC_1CYCLE),
117 gsDPSetTextureFilter(G_TF_BILERP),
118 gsDPSetTexturePersp(G_TP_NONE),
119 gsDPSetTextureLOD(G_TL_TILE),
120 gsDPSetTextureLUT(G_TT_NONE),
121 gsDPSetTextureDetail(G_TD_CLAMP),
122 gsDPSetTextureConvert(G_TC_FILT),
123 gsDPFillRectangle(0, 0, 320, 240),
124 gsDPSetColorDither(G_CD_DISABLE),
125 gsDPPipeSync(),
126 gsDPSetDepthSource(G_ZS_PIXEL),
127 gsSPEndDisplayList()
128};
129
130Gfx D_8014EA48[] = {
131 gsDPSetDepthSource(G_ZS_PRIM),
132 gsDPSetPrimDepth(20, 0),
133 gsDPSetRenderMode(Z_CMP | CVG_DST_FULL | ZMODE_OPA | ALPHA_CVG_SEL | GBL_c1(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_A_MEM), Z_CMP | CVG_DST_FULL | ZMODE_OPA | ALPHA_CVG_SEL | GBL_c2(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_A_MEM)),
134 gsSPClearGeometryMode(G_CULL_BOTH | G_LIGHTING),
135 gsSPClearGeometryMode(G_SHADING_SMOOTH),
136 gsSPTexture(0x8000, 0x8000, 0, G_TX_RENDERTILE, G_ON),
137 gsDPPipeSync(),
138 gsDPSetCombineMode(G_CC_MODULATEIA, G_CC_MODULATEIA),
139 gsDPSetTexturePersp(G_TP_PERSP),
140 gsDPSetTextureDetail(G_TD_CLAMP),
141 gsDPSetTextureLOD(G_TL_TILE),
142 gsDPSetTextureLUT(G_TT_NONE),
143 gsDPSetTextureFilter(G_TF_BILERP),
144 gsDPSetTextureConvert(G_TC_FILT),
145 gsSPVertex(&vtx_stencil2, 24, 0),
146 gsDPLoadTextureTile(&D_80156910, G_IM_FMT_RGBA, G_IM_SIZ_16b, 160, 0, 0, 0, 159, 11, 0, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMIRROR | G_TX_CLAMP, 8, 4, G_TX_NOLOD, G_TX_NOLOD),
147 gsSP2Triangles(0, 2, 1, 0, 3, 1, 2, 0),
148 gsDPLoadTextureTile(&D_80156910, G_IM_FMT_RGBA, G_IM_SIZ_16b, 160, 0, 0, 11, 159, 22, 0, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMIRROR | G_TX_CLAMP, 8, 4, G_TX_NOLOD, G_TX_NOLOD),
149 gsSP2Triangles(2, 4, 3, 0, 5, 3, 4, 0),
150 gsDPLoadTextureTile(&D_80156910, G_IM_FMT_RGBA, G_IM_SIZ_16b, 160, 0, 0, 22, 159, 33, 0, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMIRROR | G_TX_CLAMP, 8, 4, G_TX_NOLOD, G_TX_NOLOD),
151 gsSP2Triangles(4, 6, 5, 0, 7, 5, 6, 0),
152 gsDPLoadTextureTile(&D_80156910, G_IM_FMT_RGBA, G_IM_SIZ_16b, 160, 0, 0, 33, 159, 44, 0, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMIRROR | G_TX_CLAMP, 8, 4, G_TX_NOLOD, G_TX_NOLOD),
153 gsSP2Triangles(6, 8, 7, 0, 9, 7, 8, 0),
154 gsDPLoadTextureTile(&D_80156910, G_IM_FMT_RGBA, G_IM_SIZ_16b, 160, 0, 0, 44, 159, 55, 0, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMIRROR | G_TX_CLAMP, 8, 4, G_TX_NOLOD, G_TX_NOLOD),
155 gsSP2Triangles(8, 10, 9, 0, 11, 9, 10, 0),
156 gsDPLoadTextureTile(&D_80156910, G_IM_FMT_RGBA, G_IM_SIZ_16b, 160, 0, 0, 55, 159, 66, 0, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMIRROR | G_TX_CLAMP, 8, 4, G_TX_NOLOD, G_TX_NOLOD),
157 gsSP2Triangles(10, 12, 11, 0, 13, 11, 12, 0),
158 gsDPLoadTextureTile(&D_80156910, G_IM_FMT_RGBA, G_IM_SIZ_16b, 160, 0, 0, 66, 159, 77, 0, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMIRROR | G_TX_CLAMP, 8, 4, G_TX_NOLOD, G_TX_NOLOD),
159 gsSP2Triangles(12, 14, 13, 0, 15, 13, 14, 0),
160 gsDPLoadTextureTile(&D_80156910, G_IM_FMT_RGBA, G_IM_SIZ_16b, 160, 0, 0, 77, 159, 88, 0, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMIRROR | G_TX_CLAMP, 8, 4, G_TX_NOLOD, G_TX_NOLOD),
161 gsSP2Triangles(14, 16, 15, 0, 17, 15, 16, 0),
162 gsDPLoadTextureTile(&D_80156910, G_IM_FMT_RGBA, G_IM_SIZ_16b, 160, 0, 0, 88, 159, 99, 0, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMIRROR | G_TX_CLAMP, 8, 4, G_TX_NOLOD, G_TX_NOLOD),
163 gsSP2Triangles(16, 18, 17, 0, 19, 17, 18, 0),
164 gsDPLoadTextureTile(&D_80156910, G_IM_FMT_RGBA, G_IM_SIZ_16b, 160, 0, 0, 99, 159, 110, 0, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMIRROR | G_TX_CLAMP, 8, 4, G_TX_NOLOD, G_TX_NOLOD),
165 gsSP2Triangles(18, 20, 19, 0, 21, 19, 20, 0),
166 gsDPLoadTextureTile(&D_80156910, G_IM_FMT_RGBA, G_IM_SIZ_16b, 160, 0, 0, 110, 159, 119, 0, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMIRROR | G_TX_CLAMP, 8, 4, G_TX_NOLOD, G_TX_NOLOD),
167 gsSP2Triangles(20, 22, 21, 0, 23, 21, 22, 0),
168 gsDPPipeSync(),
169 gsDPSetDepthSource(G_ZS_PIXEL)
170};
171
172void _render_transition_stencil(u8 stencilType, f32 progress, ScreenOverlay* overlay) {
173 Camera* camera = &gCameras[gCurrentCameraID];
174 u8 colR, colG, colB;
175 s32 x1, y1, x2, y2;
176 f32 alpha;
177 s16 v0;
178 s16 s0;
179 Mtx* matrixStack = gDisplayContext->matrixStack;
180
181 if (progress == 0.0f) {
182 return;
183 }
184
185 if (overlay != NULL) {
186 colR = overlay->color.r;
187 colG = overlay->color.g;
188 colB = overlay->color.b;
189 x1 = overlay->screenPos[0][0];
190 y1 = overlay->screenPos[0][1];
191 x2 = overlay->screenPos[1][0];
192 y2 = overlay->screenPos[1][1];
193 alpha = overlay->alpha;
194 } else {
195 colR = colG = colB = 0;
196 x1 = y1 = x2 = y2 = 0;
197 alpha = 0.0f;
198 }
199
200 switch (stencilType) {
202 gDPPipeSync(gMainGfxPos++);
203 gDPSetColorDither(gMainGfxPos++, G_CD_MAGICSQ);
204 gDPSetAlphaDither(gMainGfxPos++, G_AD_PATTERN);
205 gDPSetCycleType(gMainGfxPos++, G_CYC_1CYCLE);
206 if (progress == 255.0f) {
207 gDPSetRenderMode(gMainGfxPos++, CVG_DST_SAVE | G_RM_OPA_SURF, CVG_DST_SAVE | G_RM_OPA_SURF2);
208 } else {
209 gDPSetRenderMode(gMainGfxPos++, G_RM_CLD_SURF, G_RM_CLD_SURF2);
210 }
211 gDPSetCombineMode(gMainGfxPos++, G_CC_PRIMITIVE, G_CC_PRIMITIVE);
212 gDPSetPrimColor(gMainGfxPos++, 0, 0, colR, colG, colB, progress);
213 gDPSetScissor(gMainGfxPos++, G_SC_NON_INTERLACE, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
214 gDPFillRectangle(gMainGfxPos++, 0, 0, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1);
215 gDPSetColorDither(gMainGfxPos++, G_CD_DISABLE);
216 return;
218 gDPPipeSync(gMainGfxPos++);
219 gDPSetColorDither(gMainGfxPos++, G_CD_MAGICSQ);
220 gDPSetAlphaDither(gMainGfxPos++, G_AD_PATTERN);
221 gDPSetCycleType(gMainGfxPos++, G_CYC_1CYCLE);
222 if (progress == 255.0f) {
223 gDPSetRenderMode(gMainGfxPos++, CVG_DST_SAVE | G_RM_OPA_SURF, CVG_DST_SAVE | G_RM_OPA_SURF2);
224 } else {
225 gDPSetRenderMode(gMainGfxPos++, G_RM_CLD_SURF, G_RM_CLD_SURF2);
226 }
227 gDPSetCombineMode(gMainGfxPos++, G_CC_PRIMITIVE, G_CC_PRIMITIVE);
228 gDPSetPrimColor(gMainGfxPos++, 0, 0, colR, colG, colB, progress);
229 gDPSetScissor(gMainGfxPos++, G_SC_NON_INTERLACE, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
230 gDPFillRectangle(gMainGfxPos++, camera->viewportStartX, camera->viewportStartY,
231 camera->viewportStartX + camera->viewportW, camera->viewportStartY + camera->viewportH);
232 gDPSetColorDither(gMainGfxPos++, G_CD_DISABLE);
233 return;
234 }
235
236 guOrtho(&matrixStack[gMatrixListPos], 0.0f, 320.0f, 0.0f, 240.0f, -1000.0f, 1000.0f, 1.0f);
237 gSPMatrix(gMainGfxPos++, &matrixStack[gMatrixListPos++], G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION);
238
239 switch (stencilType) {
241 gSPDisplayList(gMainGfxPos++, Gfx_LoadStencilTex_Mario);
242 appendGfx_screen_transition_stencil(SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2, progress, colR, colG, colB, progress * alpha / 255.0f, gCurrentCameraID);
243 break;
245 gSPDisplayList(gMainGfxPos++, Gfx_LoadStencilTex_Mario);
246 appendGfx_screen_transition_stencil(SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2, progress, colR, colG, colB, progress * alpha / 255.0f, -1);
247 break;
249 gSPDisplayList(gMainGfxPos++, Gfx_LoadStencilTex_Star);
250 appendGfx_screen_transition_stencil(SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2, progress, colR, colG, colB, progress * alpha / 255.0f, gCurrentCameraID);
251 break;
253 gSPDisplayList(gMainGfxPos++, Gfx_LoadStencilTex_Star);
254 appendGfx_screen_transition_stencil(SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2, progress, colR, colG, colB, progress * alpha / 255.0f, -1);
255 break;
258 appendGfx_screen_transition_stencil(x1, y1, progress, 0, 0, 0, 0, gCurrentCameraID);
259 break;
262 appendGfx_screen_transition_stencil(x1, y1, progress, 0, 0, 0, 0, -1);
263 break;
264 case OVERLAY_TYPE_2:
265 s0 = progress;
266 guTranslate(&matrixStack[gMatrixListPos], 80.0f, 120.0f, 0.0f);
267 gSPMatrix(gMainGfxPos++, &matrixStack[gMatrixListPos++], G_MTX_PUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
268 guScale(&matrixStack[gMatrixListPos], (1.0f - s0 / 255.0f) * 0.8, (1.0f - s0 / 255.0f) * 0.8, 1.0f);
269 gSPMatrix(gMainGfxPos++, &matrixStack[gMatrixListPos++], G_MTX_NOPUSH | G_MTX_MUL | G_MTX_MODELVIEW);
270 guRotate(&matrixStack[gMatrixListPos], s0 * 0.5f, 0.0f, 0.0f, 1.0f);
271 gSPMatrix(gMainGfxPos++, &matrixStack[gMatrixListPos++], G_MTX_NOPUSH | G_MTX_MUL | G_MTX_MODELVIEW);
272 gSPDisplayList(gMainGfxPos++, D_8014E8F0);
273 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
274
275 guTranslate(&matrixStack[gMatrixListPos], 240.0f, 120.0f, 0.0f);
276 gSPMatrix(gMainGfxPos++, &matrixStack[gMatrixListPos++], G_MTX_PUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
277 guScale(&matrixStack[gMatrixListPos], (1.0f - s0 / 255.0f) * 0.8, (1.0f - s0 / 255.0f) * 0.8, 1.0f);
278 gSPMatrix(gMainGfxPos++, &matrixStack[gMatrixListPos++], G_MTX_NOPUSH | G_MTX_MUL | G_MTX_MODELVIEW);
279 guRotate(&matrixStack[gMatrixListPos], s0 * 0.5f, 0.0f, 0.0f, 1.0f);
280 gSPMatrix(gMainGfxPos++, &matrixStack[gMatrixListPos++], G_MTX_NOPUSH | G_MTX_MUL | G_MTX_MODELVIEW);
281 gSPDisplayList(gMainGfxPos++, D_8014E8F0);
282 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
283
284 guTranslate(&matrixStack[gMatrixListPos], 0.0f, 0.0f, 0.0f);
285 gSPMatrix(gMainGfxPos++, &matrixStack[gMatrixListPos++], G_MTX_PUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
286 gSPDisplayList(gMainGfxPos++, D_8014EA48);
287 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
288 break;
289 case OVERLAY_TYPE_9:
290 s0 = progress;
291 gDPSetPrimColor(gMainGfxPos++, 0, 0, 0, 0, 0, 0);
292 guTranslate(&matrixStack[gMatrixListPos], x1, SCREEN_HEIGHT - y1, 0.0f);
293 gSPMatrix(gMainGfxPos++, &matrixStack[gMatrixListPos++], G_MTX_PUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
294 guScale(&matrixStack[gMatrixListPos], (1.0f - s0 / 255.0f) * 0.8, (1.0f - s0 / 255.0f) * 0.8, 1.0f);
295 gSPMatrix(gMainGfxPos++, &matrixStack[gMatrixListPos++], G_MTX_NOPUSH | G_MTX_MUL | G_MTX_MODELVIEW);
296 guRotate(&matrixStack[gMatrixListPos], -s0, 0.0f, 0.0f, 1.0f);
297 gSPMatrix(gMainGfxPos++, &matrixStack[gMatrixListPos++], G_MTX_NOPUSH | G_MTX_MUL | G_MTX_MODELVIEW);
298 gSPDisplayList(gMainGfxPos++, D_8014E8F0);
299 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
300
301 guTranslate(&matrixStack[gMatrixListPos], x2, SCREEN_HEIGHT - y2, 0.0f);
302 gSPMatrix(gMainGfxPos++, &matrixStack[gMatrixListPos++], G_MTX_PUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
303 guScale(&matrixStack[gMatrixListPos], (1.0f - s0 / 255.0f) * 0.8, (1.0f - s0 / 255.0f) * 0.8, 1.0f);
304 gSPMatrix(gMainGfxPos++, &matrixStack[gMatrixListPos++], G_MTX_NOPUSH | G_MTX_MUL | G_MTX_MODELVIEW);
305 guRotate(&matrixStack[gMatrixListPos], -s0, 0.0f, 0.0f, 1.0f);
306 gSPMatrix(gMainGfxPos++, &matrixStack[gMatrixListPos++], G_MTX_NOPUSH | G_MTX_MUL | G_MTX_MODELVIEW);
307 gSPDisplayList(gMainGfxPos++, D_8014E8F0);
308 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
309
310 guTranslate(&matrixStack[gMatrixListPos], 0.0f, 0.0f, 0.0f);
311 gSPMatrix(gMainGfxPos++, &matrixStack[gMatrixListPos++], G_MTX_PUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
312 gDPSetPrimColor(gMainGfxPos++, 0, 0, 0, 0, 0, alpha);
313 gSPDisplayList(gMainGfxPos++, D_8014E9A8);
314 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
315 break;
317 s0 = progress;
318 gDPSetPrimColor(gMainGfxPos++, 0, 0, 0, 0, 0, 0);
319 guTranslate(&matrixStack[gMatrixListPos], x1, SCREEN_HEIGHT - y1, 0.0f);
320 gSPMatrix(gMainGfxPos++, &matrixStack[gMatrixListPos++], G_MTX_PUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
321 guScale(&matrixStack[gMatrixListPos], (1.0f - s0 / 255.0f) * 0.8, (1.0f - s0 / 255.0f) * 0.8, 1.0f);
322 gSPMatrix(gMainGfxPos++, &matrixStack[gMatrixListPos++], G_MTX_NOPUSH | G_MTX_MUL | G_MTX_MODELVIEW);
323 guRotate(&matrixStack[gMatrixListPos], (f32)(-s0) * 0.5, 0.0f, 0.0f, 1.0f);
324 gSPMatrix(gMainGfxPos++, &matrixStack[gMatrixListPos++], G_MTX_NOPUSH | G_MTX_MUL | G_MTX_MODELVIEW);
325 gSPDisplayList(gMainGfxPos++, D_8014E8F0);
326 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
327
328 guTranslate(&matrixStack[gMatrixListPos], 0.0f, 0.0f, 0.0f);
329 gSPMatrix(gMainGfxPos++, &matrixStack[gMatrixListPos++], G_MTX_PUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
330 gDPSetPrimColor(gMainGfxPos++, 0, 0, 0, 0, 0, alpha);
331 gSPDisplayList(gMainGfxPos++, D_8014E9A8);
332 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
333 v0 = progress + 40;
334 if (progress > 170) {
335 v0 = 170;
336 }
338 break;
341 appendGfx_darkness_stencil(TRUE, x2, y2, alpha, progress);
342 break;
343 case OVERLAY_BLUR:
344 draw_prev_frame_buffer_at_screen_pos(x1, y1, x2, y2, progress);
345 break;
348 appendGfx_darkness_stencil(FALSE, x1, y1, alpha, progress);
349 break;
350 case OVERLAY_INTRO_1:
351 case OVERLAY_INTRO_2:
352 break;
353 }
354
355 gSPMatrix(gMainGfxPos++, &gDisplayContext->camPerspMatrix[gCurrentCameraID], G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION);
356}
357
358void set_screen_overlay_params_front(u8 type, f32 zoom) {
361}
362
363void set_screen_overlay_params_back(u8 type, f32 zoom) {
366}
367
368void get_screen_overlay_params(s32 layer, u8* type, f32* zoom) {
369 switch (layer) {
373 break;
377 break;
378 }
379}
380
381void set_screen_overlay_color(s32 layer, u8 r, u8 g, u8 b) {
382 switch (layer) {
385 ScreenOverlays[layer].color.r = r;
386 ScreenOverlays[layer].color.g = g;
387 ScreenOverlays[layer].color.b = b;
388 break;
389 }
390}
391
392void set_screen_overlay_center(s32 layer, s32 arg1, s32 screenPosX, s32 screenPosY) {
393 switch (layer) {
396 switch (arg1) {
397 case 0:
398 ScreenOverlays[layer].screenPos[0][0] = screenPosX;
399 ScreenOverlays[layer].screenPos[0][1] = screenPosY;
400 break;
401 case 1:
402 ScreenOverlays[layer].screenPos[1][0] = screenPosX;
403 ScreenOverlays[layer].screenPos[1][1] = screenPosY;
404 break;
405 }
406 break;
407 }
408}
409
410void set_screen_overlay_center_worldpos(s32 layer, s32 posIdx, s32 worldPosX, s32 worldPosY, s32 worldPosZ) {
411 Camera* camera = &gCameras[gCurrentCameraID];
412 f32 tx, ty, tz, tw;
413
414 switch (layer) {
417 transform_point(camera->mtxPerspective, worldPosX, worldPosY, worldPosZ, 1.0f, &tx, &ty, &tz, &tw);
418 tw = 1.0f / tw;
419 tx *= tw;
420 ty *= -tw;
421 tz *= tw;
422 tx = (((tx * camera->viewportW) + camera->viewportW) * 0.5) + camera->viewportStartX;
423 ty = (((ty * camera->viewportH) + camera->viewportH) * 0.5) + camera->viewportStartY;
424
425 switch (posIdx) {
426 case 0:
427 ScreenOverlays[layer].screenPos[0][0] = tx;
428 ScreenOverlays[layer].screenPos[0][1] = ty;
429 break;
430 case 1:
431 ScreenOverlays[layer].screenPos[1][0] = tx;
432 ScreenOverlays[layer].screenPos[1][1] = ty;
433 break;
434 }
435 break;
436 }
437}
438
439void set_screen_overlay_alpha(s32 layer, f32 alpha) {
440 switch (layer) {
443 ScreenOverlays[layer].alpha = alpha;
444 break;
445 }
446}
447
449 ScreenOverlay* it;
450 s32 i;
451
456
457 for (it = &ScreenOverlays[0], i = 0; i < ARRAY_COUNT(ScreenOverlays); i++, it++) {
458 it->color.b = 0;
459 it->color.g = 0;
460 it->color.r = 0;
461 it->screenPos[1][1] = 0;
462 it->screenPos[1][0] = 0;
463 it->screenPos[0][1] = 0;
464 it->screenPos[0][0] = 0;
465 it->alpha = 255.0f;
466 }
467}
468
469void func_80138188(void) {
471}
472
473void func_80138198(void) {
474}
475
484
493
497
505
507 u8 overlayColor;
508 u8 fadeOutType = OVERLAY_SCREEN_COLOR;
509 u8 r = 0;
510 u8 g = 0;
511 u8 b = 0;
512 s16 t = 0;
513 s32 fadeRate = STANDARD_FADE_RATE;
514
515 switch (CurrentScreenTransition) {
517 fadeOutType = OVERLAY_VIEWPORT_COLOR;
518 break;
520 fadeOutType = OVERLAY_SCREEN_COLOR;
521 break;
523 fadeOutType = OVERLAY_VIEWPORT_COLOR;
524 fadeRate = FAST_FADE_RATE;
525 break;
527 r = g = b = 208;
528 fadeOutType = OVERLAY_VIEWPORT_COLOR;
529 fadeRate = SLOWER_FADE_RATE;
532 }
533 break;
536 fadeOutType = OVERLAY_VIEWPORT_COLOR;
537 fadeRate = SLOW_FADE_RATE;
538 break;
540 r = g = b = 208;
541 fadeOutType = OVERLAY_VIEWPORT_COLOR;
542 break;
546 }
547 r = g = b = 208;
548 fadeOutType = OVERLAY_VIEWPORT_COLOR;
549 fadeRate = SLOW_FADE_RATE;
550 break;
553 r = g = b = 208;
554 fadeOutType = OVERLAY_VIEWPORT_COLOR;
555 fadeRate = SLOW_FADE_RATE;
556 break;
558 r = g = b = 208;
559 fadeOutType = OVERLAY_VIEWPORT_COLOR;
560 fadeRate = FAST_FADE_RATE;
561 break;
564 fadeOutType = OVERLAY_VIEWPORT_MARIO;
565 break;
567 r = g = b = 208;
569 fadeOutType = OVERLAY_VIEWPORT_MARIO;
570 fadeRate = SLOW_FADE_RATE;
571 break;
574 fadeOutType = OVERLAY_VIEWPORT_MARIO;
575 fadeRate = SLOW_FADE_RATE;
576 break;
579 r = g = b = 208;
580 fadeOutType = OVERLAY_VIEWPORT_STAR;
581 fadeRate = SLOW_FADE_RATE;
582 break;
585 fadeOutType = OVERLAY_VIEWPORT_STAR;
586 fadeRate = SLOW_FADE_RATE;
587 break;
592 *progress = 255;
593 return 1;
594 }
595
597 overlayColor = ((255 - *progress) * 208) / 255;
598 set_screen_overlay_color(SCREEN_LAYER_FRONT, overlayColor, overlayColor, overlayColor);
599 set_screen_overlay_params_front(fadeOutType, 255.0f);
600 if (*progress == 255) {
601 return 1;
602 }
603
604 *progress += fadeRate;
605 if (*progress > 255) {
606 *progress = 255;
607 }
608 } else {
609 set_screen_overlay_color(t, r, g, b);
610
611 if (t == 0) {
612 set_screen_overlay_params_front(fadeOutType, *progress);
613 } else {
614 set_screen_overlay_params_back(fadeOutType, *progress);
615 }
616
617 if (*progress == 255) {
618 return 1;
619 }
620
621 *progress += fadeRate;
622 if (*progress > 255) {
623 *progress = 255;
624 }
625 }
626 return 0;
627}
628
630 u8 fadeInType = OVERLAY_SCREEN_COLOR;
631 s32 fadeRate = STANDARD_FADE_RATE;
632 u8 ret = FALSE;
633
634 switch (CurrentScreenTransition) {
637 fadeRate = FAST_FADE_RATE;
638 break;
640 fadeInType = OVERLAY_VIEWPORT_COLOR;
641 fadeRate = FAST_FADE_RATE;
642 break;
648 fadeInType = OVERLAY_VIEWPORT_COLOR;
649 fadeRate = SLOW_FADE_RATE;
650 break;
656 fadeInType = OVERLAY_VIEWPORT_COLOR;
657 break;
660 fadeInType = OVERLAY_VIEWPORT_MARIO;
661 break;
663 fadeInType = OVERLAY_VIEWPORT_STAR;
664 fadeRate = SLOW_FADE_RATE;
665 break;
667 fadeInType = OVERLAY_VIEWPORT_MARIO;
668 fadeRate = SLOW_FADE_RATE;
669 break;
674 fadeRate = VERY_SLOW_FADE_RATE;
675 break;
676 }
677
679 set_screen_overlay_params_front(fadeInType, *progress);
680 }
681
682 if (*progress == 0) {
683 ret = TRUE;
684 }
685
686 *progress -= fadeRate;
687
688 if (*progress < 0) {
689 *progress = 0;
690 }
691
692 return ret;
693}
Mtx matrixStack[0x200]
#define transform_point
#define draw_prev_frame_buffer_at_screen_pos
#define guTranslate
@ OVERLAY_VIEWPORT_STAR
Definition enums.h:2393
@ OVERLAY_NONE
Definition enums.h:2387
@ OVERLAY_BLUR
Definition enums.h:2400
@ OVERLAY_SCREEN_MARIO
Definition enums.h:2395
@ OVERLAY_VIEWPORT_MARIO
Definition enums.h:2392
@ OVERLAY_START_BATTLE
Definition enums.h:2398
@ OVERLAY_SCREEN_SPOTLIGHT
Definition enums.h:2394
@ OVERLAY_SCREEN_COLOR
Definition enums.h:2388
@ OVERLAY_VIEWPORT_COLOR
Definition enums.h:2389
@ OVERLAY_INTRO_2
Definition enums.h:2403
@ OVERLAY_INTRO_1
Definition enums.h:2402
@ OVERLAY_BATTLE_DARKNESS
Definition enums.h:2401
@ OVERLAY_TYPE_2
Definition enums.h:2390
@ OVERLAY_WORLD_DARKNESS
Definition enums.h:2399
@ OVERLAY_VIEWPORT_SPOTLIGHT
Definition enums.h:2391
@ OVERLAY_TYPE_9
Definition enums.h:2397
@ OVERLAY_SCREEN_STAR
Definition enums.h:2396
ScreenTransition
Definition enums.h:2361
@ TRANSITION_SLOW_BLUR_MOTION
Definition enums.h:2378
@ TRANSITION_END_PEACH_INTERLUDE
Definition enums.h:2374
@ TRANSITION_AFTER_SAVE_PROMPT
Definition enums.h:2373
@ TRANSITION_END_CHAPTER_INTERRUPTED
Definition enums.h:2377
@ TRANSITION_BEGIN_OR_END_CHAPTER
Definition enums.h:2368
@ TRANSITION_GET_STAR_CARD
Definition enums.h:2376
@ TRANSITION_MARIO_BLACK
Definition enums.h:2372
@ TRANSITION_END_DEMO_SCENE_BLACK
Definition enums.h:2364
@ TRANSITION_ENTER_WORLD
Definition enums.h:2370
@ TRANSITION_END_DEMO_SCENE_WHITE
Definition enums.h:2365
@ TRANSITION_BEGIN_OR_END_GAME
Definition enums.h:2366
@ TRANSITION_MARIO_WHITE
Definition enums.h:2371
@ TRANSITION_PEACH_CAPTURED
Definition enums.h:2375
@ TRANSITION_OUTRO_END_SCENE
Definition enums.h:2367
@ TRANSITION_TOY_TRAIN
Definition enums.h:2363
@ TRANSITION_STANDARD
Definition enums.h:2362
@ TRANSITION_SLOW_FADE_TO_WHITE
Definition enums.h:2369
@ SCREEN_LAYER_FRONT
Definition enums.h:2382
@ SCREEN_LAYER_BACK
Definition enums.h:2383
@ CONTEXT_PAUSE
Definition enums.h:3531
@ DEMO_STATE_CHANGE_MAP
Definition enums.h:3537
#define INCLUDE_IMG(FILENAME, SYMBOLNAME)
Color_RGB8 color
Definition overlay.h:7
void appendGfx_darkness_stencil(s32, s32, s32, f32, f32)
s32 screenPos[2][2]
Definition overlay.h:9
void appendGfx_screen_transition_stencil(s32, s32, f32, s32, s32, s32, s32, s32)
Gfx D_8014E8F0[]
BSS s32 screen_overlay_frontType
void render_screen_overlay_backUI(void)
BSS s32 D_80156910
void clear_screen_overlays(void)
void set_screen_overlay_params_front(u8 type, f32 zoom)
s16 update_enter_map_screen_overlay(s16 *progress)
BSS f32 screen_overlay_frontZoom
Gfx D_8014EA48[]
Gfx Gfx_LoadStencilTex_Star[]
Gfx Gfx_LoadStencilTex_BlurryCircle[]
Gfx Gfx_LoadStencilTex_CommonParams[]
void set_screen_overlay_center(s32 layer, s32 arg1, s32 screenPosX, s32 screenPosY)
void set_map_transition_effect(ScreenTransition transition)
Gfx Gfx_LoadStencilTex_SharpCircle[]
void _render_transition_stencil(u8 stencilType, f32 progress, ScreenOverlay *overlay)
void set_screen_overlay_center_worldpos(s32 layer, s32 posIdx, s32 worldPosX, s32 worldPosY, s32 worldPosZ)
void set_screen_overlay_color(s32 layer, u8 r, u8 g, u8 b)
BSS s32 screen_overlay_backType
Gfx D_8014E9A8[]
Gfx Gfx_LoadStencilTex_Mario[]
s16 update_exit_map_screen_overlay(s16 *progress)
void func_80138188(void)
ScreenTransition CurrentScreenTransition
void render_screen_overlay_frontUI(void)
BSS f32 screen_overlay_backZoom
void get_screen_overlay_params(s32 layer, u8 *type, f32 *zoom)
void func_80138198(void)
ScreenOverlay ScreenOverlays[2]
void set_screen_overlay_params_back(u8 type, f32 zoom)
void set_screen_overlay_alpha(s32 layer, f32 alpha)
ScreenFadeRates
@ SLOWER_FADE_RATE
@ SLOW_FADE_RATE
@ STANDARD_FADE_RATE
@ FAST_FADE_RATE
@ VERY_SLOW_FADE_RATE
#define SCREEN_WIDTH
Definition macros.h:105
#define BSS
Definition macros.h:7
#define ARRAY_COUNT(arr)
Definition macros.h:40
#define SCREEN_HEIGHT
Definition macros.h:106
#define PM_CC_SCREEN_OVERLAY
Definition macros.h:400
#define PM_CC_3A
Definition macros.h:398
#define LAST_DEMO_SCENE_IDX
Definition macros.h:108
s16 viewportStartX
s16 viewportStartY
Matrix4f mtxPerspective
GameStatus * gGameStatusPtr
Definition main_loop.c:32
Camera gCameras[4]
Definition cam_main.c:17
Gfx * gMainGfxPos
Definition cam_main.c:15
u16 gMatrixListPos
Definition main_loop.c:45
s32 gCurrentCameraID
Definition cam_math.c:4
DisplayContext * gDisplayContext
Definition cam_main.c:16