Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
pause_spirits.c File Reference

Go to the source code of this file.

Functions

void pause_spirits_draw_contents (MenuPanel *menu, s32 baseX, s32 baseY, s32 width, s32 height, s32 opacity, s32 darkening)
 
void pause_spirits_draw_title (MenuPanel *menu, s32 baseX, s32 baseY, s32 width, s32 height, s32 opacity, s32 darkening)
 
void pause_spirits_init (MenuPanel *panel)
 
void pause_spirits_handle_input (MenuPanel *panel)
 
void pause_spirits_update (MenuPanel *panel)
 
void pause_spirits_cleanup (MenuPanel *panel)
 

Variables

Gfx PauseGfxSpiritsBg []
 
s8 pause_spirits_bg_png []
 
Vp gPauseSpiritsViewport
 
s32 gPauseSpiritsSpriteAnims [][4]
 
s8 gPauseSpiritsGridData []
 
Vec2i gPauseSpiritsPositions []
 
s32 gPauseSpiritsDrawOrder [] = { 6, 0, 1, 5, 2, 4, 3 }
 
Vec2i gPauseSpiritsCursorPositions []
 
MenuWindowBP gPauseSpiritsWindowsBPs []
 
MenuPanel gPausePanelSpirits
 

Function Documentation

◆ pause_spirits_draw_contents()

void pause_spirits_draw_contents ( MenuPanel * menu,
s32 baseX,
s32 baseY,
s32 width,
s32 height,
s32 opacity,
s32 darkening )

Definition at line 145 of file pause_spirits.c.

145 {
148 s32 i;
149 s32 color;
150 s32 alpha;
151 s32 index;
152 f32 x, y;
153 f32 offsetY;
154 s32 x1, y1, x2, y2;
155 f32 frameCounter;
156
160
161 for (i = 0; i < 5; i++) {
163 0, i * 22, 127, i * 22 + 21, 0,
165 pause_draw_rect((baseX + 15) * 4, (baseY + 22 + i * 22) * 4, (baseX + 271) * 4, (baseY + 22 + i * 22 + 22) * 4, 0, 16, 16 + i * 704, 0x400, 0x400);
167 }
168
169 guOrthoF(matrix1, 0.0f, 320.0f, 240.0f, 0.0f, -1000.0f, 1000.0f, 1.0f);
172 guTranslateF(matrix1, 0.0f, 0.0f, 0.0f);
175
176 for (i = 0; i < gPauseSpiritsNumSpirits; i++) {
177 index = gPauseSpiritsDrawOrder[i];
178 frameCounter = gGameStatusPtr->frameCounter * 4;
179 x = gPauseSpiritsPositions[index].x;
180 y = gPauseSpiritsPositions[index].y;
181
182 if (gPlayerData.maxStarPower < index + 1) {
183 color = 0;
184 alpha = 128;
185 offsetY = 0.0f;
186 } else {
187 color = 255;
188 alpha = 255;
189 offsetY = sin_deg(index * index * index + frameCounter * 0.4321 + frameCounter * (index * 0.02 + 0.1324))
190 * 5.0f
191 * sin_deg(index * 0.25 + frameCounter + frameCounter * (0.0432 - index * 0.01));
192
193 }
194
195 set_npc_imgfx_all(gPauseSpiritsSpriteIDs[gPauseSpiritsIndexes[index]], IMGFX_SET_TINT, color, color, color, alpha, 64);
196 guTranslateF(matrix1, baseX + 22 + x, baseY + 77 + y + offsetY, 0.0f);
197 guRotateF(matrix2, 180.0f, 0.0f, 0.0f, 1.0f);
199
200 if (index == 1 || index == 2 || index == 3) {
201 guRotateF(matrix2, 180.0f, 0.0f, 1.0f, 0.0f);
203 }
204
205 guScaleF(matrix2, 0.9f, 0.9f, 0.9f);
207 spr_draw_npc_sprite(gPauseSpiritsSpriteIDs[gPauseSpiritsIndexes[index]], 0, 0, 0, matrix1);
208 }
209
211
212 x1 = baseX + 7;
213 y1 = baseY + 14;
214 x2 = baseX + 279;
215 y2 = baseY + 140;
216
217 if (x1 <= 0) {
218 x1 = 1;
219 }
220 if (y1 <= 0) {
221 y1 = 1;
222 }
223
224 if (x2 <= 0 || y2 <= 0 || x1 >= SCREEN_WIDTH - 1 || y1 >= SCREEN_HEIGHT - 1) {
225 return;
226 }
227
228 if (x2 >= SCREEN_WIDTH - 1) {
229 x2 = SCREEN_WIDTH - 1;
230 }
231 if (y2 >= SCREEN_HEIGHT - 1) {
232 y2 = SCREEN_HEIGHT - 1;
233 }
234
236 draw_box(0, &gPauseWS_25, baseX + 7, baseY + 14, 0, 272, 126, opacity, darkening, 1.0f, 1.0f, 0, 0, 0, 0, 0, 0, width, height, 0);
237
238 if (gPauseMenuCurrentTab == 5) {
240 }
241}
BSS s32 PopupMenu_SelectedIndex
Mtx matrixStack[0x200]
f32 Matrix4f[4][4]
#define guRotateF
#define guOrthoF
#define guMtxF2L
#define sin_deg
#define guTranslateF
#define guMtxCatF
#define draw_box
#define guScaleF
@ IMGFX_SET_TINT
Definition enums.h:4710
@ WIN_PAUSE_SPIRITS
Definition enums.h:4867
s8 gPauseMenuCurrentTab
Definition pause_main.c:28
void pause_set_cursor_pos(s32 windowID, s32 posX, s32 posY)
Definition pause_main.c:225
void pause_draw_rect(s32 ulx, s32 uly, s32 lrx, s32 lry, s32 tileIdx, s32 uls, s32 ult, s32 dsdx, s32 dtdy)
Definition pause_main.c:837
WindowStyleCustom gPauseWS_25
s8 pause_spirits_bg_png[]
s32 gPauseSpiritsDrawOrder[]
Gfx PauseGfxSpiritsBg[]
Definition pause_gfx.c:325
Vec2i gPauseSpiritsPositions[]
Vp gPauseSpiritsViewport
Vec2i gPauseSpiritsCursorPositions[]
#define SCREEN_WIDTH
Definition macros.h:108
#define SCREEN_HEIGHT
Definition macros.h:109
void set_npc_imgfx_all(s32 spriteIdx, ImgFXType imgfxType, s32 imgfxArg1, s32 imgfxArg2, s32 imgfxArg3, s32 imgfxArg4, s32 imgfxArg5)
Definition sprite.c:1238
s32 spr_draw_npc_sprite(s32 spriteInstanceID, s32 yaw, s32 alphaIn, PAL_PTR *paletteList, Matrix4f mtx)
Definition sprite.c:1094
GameStatus * gGameStatusPtr
Definition main_loop.c:31
Gfx * gMainGfxPos
Definition cam_main.c:14
PlayerData gPlayerData
Definition 77480.c:39
u16 gMatrixListPos
Definition main_loop.c:44
DisplayContext * gDisplayContext
Definition cam_main.c:15

◆ pause_spirits_draw_title()

void pause_spirits_draw_title ( MenuPanel * menu,
s32 baseX,
s32 baseY,
s32 width,
s32 height,
s32 opacity,
s32 darkening )

Definition at line 243 of file pause_spirits.c.

243 {
244 s32 msgID;
245
246 if (gPauseMenuCurrentTab == 5) {
247 if (gPlayerData.maxStarPower > gPauseSpiritsIndexes[menu->selected]) {
248 msgID = gPauseSpiritsIndexes[menu->selected] + MSG_Menus_SpiritName_Eldstar;
249 } else {
251 }
252 draw_msg(msgID, baseX + ((width - get_msg_width(msgID, 0)) >> 1), baseY + 1, 255, MSG_PAL_WHITE, 0);
253 }
254}
#define get_msg_width
#define draw_msg
@ MSG_PAL_WHITE
Definition enums.h:4990
s32 pause_get_menu_msg(s32 index)
Definition pause_gfx.c:583
@ PAUSE_MSG_UNKNOWN_SPIRIT

◆ pause_spirits_init()

void pause_spirits_init ( MenuPanel * panel)

Definition at line 256 of file pause_spirits.c.

256 {
257 s32 i;
258
259 gPauseSpiritsNumSpirits = 0;
260
261 for (i = 0; i < ARRAY_COUNT(gPauseSpiritsIndexes); i++) {
262 gPauseSpiritsIndexes[gPauseSpiritsNumSpirits] = i;
263 gPauseSpiritsNumSpirits++;
264 }
265
266 for (i = 0; i < ARRAY_COUNT(gPauseSpiritsSpriteAnims); i++) {
267 gPauseSpiritsSpriteIDs[i] = spr_load_npc_sprite(gPauseSpiritsSpriteAnims[i][0], gPauseSpiritsSpriteAnims[i]);
268 }
269
270 for (i = 0; i < ARRAY_COUNT(gPauseSpiritsWindowsBPs); i++) {
272 }
274 panel->initialized = true;
275}
void setup_pause_menu_tab(MenuWindowBP *bpArray, s32 arraySize)
Definition windows.c:461
s32 gPauseSpiritsSpriteAnims[][4]
MenuWindowBP gPauseSpiritsWindowsBPs[]
#define ARRAY_COUNT(arr)
Definition macros.h:39
s32 spr_load_npc_sprite(s32 animID, u32 *extraAnimList)
Definition sprite.c:1015
MenuPanel * tab

◆ pause_spirits_handle_input()

void pause_spirits_handle_input ( MenuPanel * panel)

Definition at line 277 of file pause_spirits.c.

277 {
278 s32 oldSelected = panel->selected;
279
281 while (true) {
282 panel->col--;
283 if (panel->col < 0) {
284 panel->col = 0;
285 break;
286 }
287
288 if (panel->selected != MENU_PANEL_SELECTED_GRID_DATA(panel)) {
289 break;
290 }
291 }
292 }
293
295 while (true) {
296 panel->col++;
297 if (panel->col >= panel->numCols) {
298 panel->col = panel->numCols - 1;
299 break;
300 }
301
302 if (panel->selected != MENU_PANEL_SELECTED_GRID_DATA(panel)) {
303 break;
304 }
305 }
306 }
307
309 if (panel->selected == 2) {
310 panel->col = 3;
311 panel->row = 0;
312 } else if (panel->selected == 5) {
313 panel->col = 1;
314 panel->row = 0;
315 } else {
316 while (true) {
317 panel->row--;
318 if (panel->row < 0) {
319 panel->row = 0;
320 break;
321 }
322 if (panel->selected != MENU_PANEL_SELECTED_GRID_DATA(panel)) {
323 break;
324 }
325 }
326 }
327 }
328
330 if (panel->selected == 2) {
331 panel->col = 3;
332 panel->row = 1;
333 } else if (panel->selected == 5) {
334 panel->col = 1;
335 panel->row = 1;
336 } else {
337 while (true) {
338 panel->row++;
339 if (panel->row >= panel->numRows) {
340 panel->row = panel->numRows - 1;
341 break;
342 }
343 if (panel->selected != MENU_PANEL_SELECTED_GRID_DATA(panel)) {
344 break;
345 }
346 }
347 }
348 }
349
351
352 if (panel->selected == 4) {
353 panel->col = 1;
354 panel->row = 1;
355 }
356
357 if (panel->selected != oldSelected) {
359 }
360
364 return;
365 }
366
368
369 if (gPlayerData.maxStarPower <= gPauseSpiritsIndexes[panel->selected]) {
371 } else {
372 gPauseCurrentDescMsg = MSG_Menus_SpiritDesc_Eldstar + gPauseSpiritsIndexes[panel->selected];
373 }
374}
@ BUTTON_STICK_UP
Definition enums.h:2777
@ BUTTON_STICK_DOWN
Definition enums.h:2778
@ BUTTON_STICK_LEFT
Definition enums.h:2779
@ BUTTON_STICK_RIGHT
Definition enums.h:2780
@ BUTTON_B
Definition enums.h:2775
@ SOUND_MENU_BACK
Definition enums.h:704
@ SOUND_MENU_CHANGE_SELECTION
Definition enums.h:701
s32 gPausePressedButtons
Definition pause_main.c:24
HudScript * gPauseCurrentDescIconScript
Definition pause_main.c:26
s32 gPauseHeldButtons
Definition pause_main.c:23
s32 gPauseCurrentDescMsg
Definition pause_main.c:25
void sfx_play_sound(s32 soundID)
#define MENU_PANEL_SELECTED_GRID_DATA(panel)
Definition macros.h:75

◆ pause_spirits_update()

void pause_spirits_update ( MenuPanel * panel)

Definition at line 376 of file pause_spirits.c.

376 {
377 s32 i;
378
379 for (i = 0; i < gPauseSpiritsNumSpirits; i++) {
381 spr_update_sprite(gPauseSpiritsSpriteIDs[i], gPauseSpiritsSpriteAnims[i][1], 1.0f);
382 } else {
383 spr_update_sprite(gPauseSpiritsSpriteIDs[i], gPauseSpiritsSpriteAnims[i][0], 1.0f);
384 }
385 }
386}
s32 spr_update_sprite(s32 spriteInstanceID, s32 animID, f32 timeScale)
Definition sprite.c:1061

◆ pause_spirits_cleanup()

void pause_spirits_cleanup ( MenuPanel * panel)

Definition at line 388 of file pause_spirits.c.

388 {
389 s32 i;
390
391 for (i = 0; i < ARRAY_COUNT(gPauseSpiritsSpriteIDs); i++) {
392 spr_free_sprite(gPauseSpiritsSpriteIDs[i]);
393 }
394}
s32 spr_free_sprite(s32 spriteInstanceID)
Definition sprite.c:1162

Variable Documentation

◆ PauseGfxSpiritsBg

◆ pause_spirits_bg_png

s8 pause_spirits_bg_png[]
extern

◆ gPauseSpiritsViewport

Vp gPauseSpiritsViewport
Initial value:
= {
.vp = {
.vscale = { 640, 480, 511, 0 },
.vtrans = { 640, 480, 511, 0 },
}
}

Definition at line 26 of file pause_spirits.c.

26 {
27 .vp = {
28 .vscale = { 640, 480, 511, 0 },
29 .vtrans = { 640, 480, 511, 0 },
30 }
31};

Referenced by pause_spirits_draw_contents().

◆ gPauseSpiritsSpriteAnims

◆ gPauseSpiritsGridData

s8 gPauseSpiritsGridData[]
Initial value:
= {
5, 6, 0, 1, 2,
5, 4, 4, 3, 2
}

Definition at line 76 of file pause_spirits.c.

76 {
77 5, 6, 0, 1, 2,
78 5, 4, 4, 3, 2
79};

◆ gPauseSpiritsPositions

Vec2i gPauseSpiritsPositions[]
Initial value:
= {
{ .x = 120, .y = -5 },
{ .x = 179, .y = -2 },
{ .x = 222, .y = 28 },
{ .x = 165, .y = 45 },
{ .x = 76, .y = 45 },
{ .x = 17, .y = 28 },
{ .x = 59, .y = -2 }
}

Definition at line 80 of file pause_spirits.c.

80 {
81 { .x = 120, .y = -5 },
82 { .x = 179, .y = -2 },
83 { .x = 222, .y = 28 },
84 { .x = 165, .y = 45 },
85 { .x = 76, .y = 45 },
86 { .x = 17, .y = 28 },
87 { .x = 59, .y = -2 }
88};

Referenced by pause_spirits_draw_contents().

◆ gPauseSpiritsDrawOrder

s32 gPauseSpiritsDrawOrder[] = { 6, 0, 1, 5, 2, 4, 3 }

Definition at line 89 of file pause_spirits.c.

89{ 6, 0, 1, 5, 2, 4, 3 };

Referenced by pause_spirits_draw_contents().

◆ gPauseSpiritsCursorPositions

Vec2i gPauseSpiritsCursorPositions[]
Initial value:
= {
{ .x = 120, .y = 50 },
{ .x = 180, .y = 55 },
{ .x = 220, .y = 90 },
{ .x = 165, .y = 110 },
{ .x = 75, .y = 110 },
{ .x = 20, .y = 90 },
{ .x = 60, .y = 55 }
}

Definition at line 90 of file pause_spirits.c.

90 {
91 { .x = 120, .y = 50 },
92 { .x = 180, .y = 55 },
93 { .x = 220, .y = 90 },
94 { .x = 165, .y = 110 },
95 { .x = 75, .y = 110 },
96 { .x = 20, .y = 90 },
97 { .x = 60, .y = 55 }
98};

Referenced by pause_spirits_draw_contents().

◆ gPauseSpiritsWindowsBPs

MenuWindowBP gPauseSpiritsWindowsBPs[]
Initial value:
= {
{
.windowID = WIN_PAUSE_SPIRITS,
.unk_01 = 0,
.pos = { .x = 3, .y = 16 },
.width = 289,
.height = 154,
.priority = WINDOW_PRIORITY_1,
.fpDrawContents = &pause_spirits_draw_contents,
.tab = nullptr,
.parentID = WIN_PAUSE_MAIN,
.fpUpdate = { WINDOW_UPDATE_HIDE },
.extraFlags = 0,
.style = { .customStyle = &gPauseWS_23 }
},
{
.unk_01 = 0,
.pos = { .x = 86, .y = 124 },
.width = 120,
.height = 20,
.priority = WINDOW_PRIORITY_0,
.fpDrawContents = &pause_spirits_draw_title,
.tab = nullptr,
.parentID = WIN_PAUSE_SPIRITS,
.fpUpdate = { WINDOW_UPDATE_SHOW },
.extraFlags = 0,
.style = { .customStyle = &gPauseWS_24 }
}
}
@ WINDOW_PRIORITY_1
Definition enums.h:3217
@ WINDOW_PRIORITY_0
Definition enums.h:3216
@ WINDOW_UPDATE_SHOW
Definition enums.h:4896
@ WINDOW_UPDATE_HIDE
Definition enums.h:4897
@ WIN_PAUSE_MAIN
Definition enums.h:4848
@ WIN_PAUSE_SPIRITS_TITLE
Definition enums.h:4868
WindowStyleCustom gPauseWS_23
WindowStyleCustom gPauseWS_24
void pause_spirits_draw_title(MenuPanel *menu, s32 baseX, s32 baseY, s32 width, s32 height, s32 opacity, s32 darkening)
void pause_spirits_draw_contents(MenuPanel *menu, s32 baseX, s32 baseY, s32 width, s32 height, s32 opacity, s32 darkening)

Definition at line 99 of file pause_spirits.c.

99 {
100 {
101 .windowID = WIN_PAUSE_SPIRITS,
102 .unk_01 = 0,
103 .pos = { .x = 3, .y = 16 },
104 .width = 289,
105 .height = 154,
106 .priority = WINDOW_PRIORITY_1,
107 .fpDrawContents = &pause_spirits_draw_contents,
108 .tab = nullptr,
109 .parentID = WIN_PAUSE_MAIN,
110 .fpUpdate = { WINDOW_UPDATE_HIDE },
111 .extraFlags = 0,
112 .style = { .customStyle = &gPauseWS_23 }
113 },
114 {
115 .windowID = WIN_PAUSE_SPIRITS_TITLE,
116 .unk_01 = 0,
117 .pos = { .x = 86, .y = 124 },
118 .width = 120,
119 .height = 20,
120 .priority = WINDOW_PRIORITY_0,
121 .fpDrawContents = &pause_spirits_draw_title,
122 .tab = nullptr,
123 .parentID = WIN_PAUSE_SPIRITS,
124 .fpUpdate = { WINDOW_UPDATE_SHOW },
125 .extraFlags = 0,
126 .style = { .customStyle = &gPauseWS_24 }
127 }
128};

Referenced by pause_spirits_init().

◆ gPausePanelSpirits

MenuPanel gPausePanelSpirits
Initial value:
= {
.initialized = false,
.col = 2,
.row = 0,
.selected = 0,
.state = 0,
.numCols = 5,
.numRows = 2,
.numPages = 0,
.gridData = gPauseSpiritsGridData,
.fpInit = &pause_spirits_init,
.fpHandleInput = &pause_spirits_handle_input,
.fpUpdate = &pause_spirits_update,
.fpCleanup = &pause_spirits_cleanup
}
void pause_spirits_init(MenuPanel *panel)
void pause_spirits_handle_input(MenuPanel *panel)
s8 gPauseSpiritsGridData[]
void pause_spirits_cleanup(MenuPanel *panel)
void pause_spirits_update(MenuPanel *panel)

Definition at line 129 of file pause_spirits.c.

129 {
130 .initialized = false,
131 .col = 2,
132 .row = 0,
133 .selected = 0,
134 .state = 0,
135 .numCols = 5,
136 .numRows = 2,
137 .numPages = 0,
138 .gridData = gPauseSpiritsGridData,
139 .fpInit = &pause_spirits_init,
140 .fpHandleInput = &pause_spirits_handle_input,
141 .fpUpdate = &pause_spirits_update,
142 .fpCleanup = &pause_spirits_cleanup
143};