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

Go to the source code of this file.

Macros

#define MAP_TITLE_X   56
 
#define MAP_TITLE_WIDTH   180
 

Functions

void pause_map_draw_contents (MenuPanel *menu, s32 baseX, s32 baseY, s32 width, s32 height, s32 opacity, s32 darkening)
 
void pause_map_draw_title (MenuPanel *menu, s32 baseX, s32 baseY, s32 width, s32 height, s32 opacity, s32 darkening)
 
void pause_map_init (MenuPanel *tab)
 
void pause_map_handle_input (MenuPanel *tab)
 
void pause_map_update (MenuPanel *tab)
 
void pause_map_cleanup (MenuPanel *tab)
 
void pause_map_calc_path_points (PauseMapSpace *space)
 
void pause_map_draw_border_arrows (s32 imageIndex, s32 x, s32 y)
 

Variables

Gfx PauseGfxWorldMap []
 
Gfx PauseGfxPathPoints []
 
Gfx PauseGfxArrows []
 
u8 pause_world_map_png []
 
HudScriptPauseMapHudScripts [] = { &HES_MapWalk0 }
 
s32 D_8024FA34 = -1
 
s32 PauseMapArrowWobble [] = { 0, 2, 3, 3, 4, 4, 4, 4, 3, 2, 1, 0 }
 
MenuWindowBP PauseMapWindowBPs []
 
MenuPanel gPausePanelMap
 

Macro Definition Documentation

◆ MAP_TITLE_X

#define MAP_TITLE_X   56

Definition at line 8 of file pause_map.c.

◆ MAP_TITLE_WIDTH

#define MAP_TITLE_WIDTH   180

Definition at line 9 of file pause_map.c.

Function Documentation

◆ pause_map_draw_contents()

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

Definition at line 133 of file pause_map.c.

133 {
134 s32 cameraX = PauseMapCameraX;
135 s32 cameraY = PauseMapCameraY;
136 s32 i, j;
138 s32 x1, y1, x2, y2;
139 s32 posX, posY;
140 s32 ult;
142 s32 camX, camY;
143 s32 pathX, pathY;
148 Vec2b* path;
149 s32 pathLength;
150
152 ult = -cameraX * 32;
153 for (i = 0; i < 60; i++) {
154 if (4 * i + 4 < 111) {
155 tileHeight = 4;
156 } else {
157 tileHeight = 111 - 4 * i;
158 }
159
161 0, i * 4 - cameraY, 319, i * 4 + tileHeight - 1 - cameraY, 0,
163 pause_draw_rect((baseX + 26) * 4, (baseY + 22 + 4 * i) * 4, (baseX + 260) * 4,
164 (baseY + 22 + i * 4 + tileHeight) * 4, 0, ult, (-cameraY + i * 4) * 32, 0x400, 0x400);
166
167 if (4 * i + 4 >= 110) {
168 break;
169 }
170 }
171
173
174 x1 = baseX + 26;
175 y1 = baseY + 22;
176 x2 = baseX + 260;
177 y2 = baseY + 132;
178
179 if (x1 <= 0) {
180 x1 = 1;
181 }
182 if (y1 <= 0) {
183 y1 = 1;
184 }
185
186 if (x2 <= 0 || y2 <= 0 || x1 >= SCREEN_WIDTH - 1 || y1 >= SCREEN_HEIGHT - 1) {
187 return;
188 }
189
190 if (x2 >= SCREEN_WIDTH - 1) {
191 x2 = SCREEN_WIDTH - 1;
192 }
193 if (y2 >= SCREEN_HEIGHT - 1) {
194 y2 = SCREEN_HEIGHT - 1;
195 }
196
198
200 camX = cameraX + baseX;
201 camY = cameraY + baseY;
202 for (i = 0; i < ARRAY_COUNT(PauseMapSpaces); i++, mapSpace++) {
203 posX = mapSpace->pos.x;
204 posY = mapSpace->pos.y;
205
206 if (evt_get_variable(nullptr, GF_MAP_ToadTown + i) == 0) {
207 continue;
208 }
209
210 if (i != PauseMapCursorCurrentOption) {
211 gDPSetPrimColor(gMainGfxPos++, 0, 0, 220, 80, 30, 255);
212 } else {
213 gDPSetPrimColor(gMainGfxPos++, 0, 0, (gGameStatusPtr->frameCounter * 10) % 120 + 120,
214 (gGameStatusPtr->frameCounter * 10) % 120 + 120,
215 (gGameStatusPtr->frameCounter * 10) % 120, 255);
216 }
217
218 bigPointX = camX + 26 + posX;
219 bigPointY = camY + 22 + posY;
220 pause_draw_rect((bigPointX - 8) * 4, (bigPointY - 8) * 4, (bigPointX + 8) * 4, (bigPointY + 8) * 4, 0, 0, 0, 0x400, 0x400);
222 gDPSetPrimColor(gMainGfxPos++, 0, 0, 230, 190, 180, 255);
223
224 pathLength = mapSpace->pathLength;
225 path = mapSpace->path;
226 if (path) {
227 pathX = 0;
228 pathY = 0;
229 for (j = 0; j < pathLength; j++, path++) {
230 pathX += path->x;
231 pathY += path->y;
232 pause_draw_rect((camX + 26 + posX + pathX - 8) * 4, (camY + 22 + posY + pathY - 8) * 4, (camX + 26 + posX + pathX + 8) * 4, (camY + 22 + posY + pathY + 8) * 4, 1, 0, 0, 0x400, 0x400);
233 }
234 }
235 }
236
237 mapULX = baseX + 26 + cameraX;
238 mapULY = baseY + 22 + cameraY;
239 hud_element_set_render_pos(PauseMapHIDs[0], mapULX + PauseMapMarioX, mapULY + PauseMapMarioY - 7);
240 hud_element_draw_without_clipping(PauseMapHIDs[0]);
241
243 if (currentTab == 6) {
244 pause_set_cursor_pos(WIN_PAUSE_MAP, mapULX + PauseMapTargetX - 8.0f, mapULY + PauseMapTargetY);
245
248 offsetLeft = offset;
249 offsetRight = offset;
250 offsetUp = offset;
251 offsetDown = offset;
252
254
255 if (!(PauseMapCameraX < 0.0f)) {
256 offsetLeft = 0;
257 }
258 pause_map_draw_border_arrows(0, baseX + 26 - offsetLeft, baseY + height / 2 - 8);
259
260 if (!(PauseMapCameraX > -86.0f)) {
261 offsetRight = 0;
262 }
263 pause_map_draw_border_arrows(1, baseX + width - 50 + offsetRight, baseY + height / 2 - 8);
264
265 if (!(PauseMapCameraY < 0.0f)) {
266 offsetUp = 0;
267 }
268 pause_map_draw_border_arrows(2, baseX + width / 2 - 8, baseY + 24 - offsetUp);
269
270 if (!(PauseMapCameraY > -210.0f)) {
271 offsetDown = 0;
272 }
273 pause_map_draw_border_arrows(3, baseX + width / 2 - 8, baseY + height - 44 + offsetDown);
274 }
275 }
276 {
277 s32 x1, y1, x2, y2;
278
279 x1 = baseX + 18;
280 y1 = baseY + 14;
281 x2 = baseX + 268;
282 y2 = baseY + 140;
283
284 if (x1 <= 0) {
285 x1 = 1;
286 }
287 if (y1 <= 0) {
288 y1 = 1;
289 }
290
291 if (x2 <= 0 || y2 <= 0 || x1 >= SCREEN_WIDTH - 1 || y1 >= SCREEN_HEIGHT - 1) {
292 return;
293 }
294
295 if (x2 >= SCREEN_WIDTH - 1) {
296 x2 = SCREEN_WIDTH - 1;
297 }
298 if (y2 >= SCREEN_HEIGHT - 1) {
299 y2 = SCREEN_HEIGHT - 1;
300 }
301
303 }
304 draw_box(0, &gPauseWS_27, baseX + 18, baseY + 14, 0, 250, 126, opacity, darkening, 1.0f, 1.0f, 0, 0, 0, 0, 0, 0, width, height, 0);
305}
BSS s32 PopupMenu_SelectedIndex
#define draw_box
@ WIN_PAUSE_MAP
Definition enums.h:4869
s32 evt_get_variable(Evt *script, Bytecode var)
Definition evt.c:1730
void hud_element_draw_without_clipping(s32 id)
void hud_element_set_render_pos(s32 id, s32 x, s32 y)
WindowStyleCustom gPauseWS_27
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
void pause_map_draw_border_arrows(s32 imageIndex, s32 x, s32 y)
Definition pause_map.c:114
s32 PauseMapArrowWobble[]
Definition pause_map.c:40
Gfx PauseGfxArrows[]
Definition pause_gfx.c:246
Gfx PauseGfxPathPoints[]
Definition pause_gfx.c:226
Gfx PauseGfxWorldMap[]
Definition pause_gfx.c:208
u8 pause_world_map_png[]
@ GF_MAP_ToadTown
#define SCREEN_WIDTH
Definition macros.h:108
#define ARRAY_COUNT(arr)
Definition macros.h:39
#define SCREEN_HEIGHT
Definition macros.h:109
GameStatus * gGameStatusPtr
Definition main_loop.c:31
Gfx * gMainGfxPos
Definition cam_main.c:14

◆ pause_map_draw_title()

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

Definition at line 307 of file pause_map.c.

307 {
308 s32 msgWidth;
309 s32 msgID;
310
311 if (gPauseMenuCurrentTab == 6) {
312 if (PauseMapCursorCurrentOption != -1) {
313 msgWidth = get_msg_width(MSG_Menus_00F2 + (PauseMapCursorCurrentOption * 3), 0);
314 msgID = MSG_Menus_00F2 + (PauseMapCursorCurrentOption * 3);
315 draw_msg(msgID, baseX + ((width - msgWidth) >> 1), baseY + 1, 255, MSG_PAL_WHITE, 0);
316 }
317 }
318}
#define get_msg_width
#define draw_msg
@ MSG_PAL_WHITE
Definition enums.h:4990

◆ pause_map_init()

void pause_map_init ( MenuPanel * tab)

Definition at line 320 of file pause_map.c.

320 {
322 s32 i;
323
324 for (i = 0; i < ARRAY_COUNT(PauseMapHudScripts); i++) {
325 PauseMapHIDs[i] = hud_element_create(PauseMapHudScripts[i]);
327 }
328
329 for (i = 0; i < ARRAY_COUNT(PauseMapWindowBPs); i++) {
330 PauseMapWindowBPs[i].tab = tab;
331 }
332
334 PauseMapCursorCurrentOption = -1;
335 PauseMapSpacesInSnapRange = 0;
336 PauseMapCursorCurrentOptionCopy = -1;
338
339 for (i = 0; i < ARRAY_COUNT(PauseMapSpaces); i++) {
340 if (PauseMapSpaces[i].id == currentLocation) {
341 break;
342 }
343 }
344
345 if (i < ARRAY_COUNT(PauseMapSpaces)) {
346 PauseMapMarioX = PauseMapSpaces[i].pos.x;
347 PauseMapMarioY = PauseMapSpaces[i].pos.y;
348 } else {
349 PauseMapMarioX = 0;
350 PauseMapMarioY = 0;
351 }
352 PauseMapTargetX = PauseMapMarioX;
353 PauseMapTargetY = PauseMapMarioY;
354
355 PauseMapCameraX = 0.0f;
356 PauseMapCameraY = 0.0f;
357 PauseMapCameraX -= (s32)(PauseMapTargetX + PauseMapCameraX - 117.0);
358 PauseMapCameraY -= (s32)(PauseMapTargetY + PauseMapCameraY - 55.0);
359
360 if (PauseMapCameraX > 0) {
361 PauseMapCameraX = 0;
362 }
363 if (PauseMapCameraY > 0) {
364 PauseMapCameraY = 0;
365 }
366
367 if (PauseMapCameraX <= -86.0f) {
368 PauseMapCameraX = -85.0f;
369 }
370 if (PauseMapCameraY <= -210.0f) {
371 PauseMapCameraY = -209.0f;
372 }
373
374 tab->initialized = true;
375}
void setup_pause_menu_tab(MenuWindowBP *bpArray, s32 arraySize)
Definition windows.c:461
HudElemID hud_element_create(HudScript *anim)
Creates a new HUD element and returns its ID.
void hud_element_set_flags(s32 id, s32 flags)
Turns on the given flags.
@ HUD_ELEMENT_FLAG_MANUAL_RENDER
Definition hud_element.h:78
HudScript * PauseMapHudScripts[]
Definition pause_map.c:35
MenuWindowBP PauseMapWindowBPs[]
Definition pause_map.c:41
@ GB_WorldLocation
MenuPanel * tab

◆ pause_map_handle_input()

void pause_map_handle_input ( MenuPanel * tab)

Definition at line 377 of file pause_map.c.

377 {
378 f32 xMovement = gGameStatusPtr->stickX[0] * 0.05f;
379 f32 yMovement = -gGameStatusPtr->stickY[0] * 0.05f;
380 f32 PauseMapTargetYPosTemp = PauseMapTargetY;
381 f32 PauseMapTargetXPosTemp = PauseMapTargetX;
382 s32 xTemp;
383 s32 yTemp;
384
385 if (xMovement == 0.0f && yMovement == 0.0f && PauseMapCursorCurrentOption != -1) {
386 PauseMapSpace* mapSpace = &PauseMapSpaces[PauseMapCursorCurrentOption];
387
390
391 xMovement *= 0.32;
392 yMovement *= 0.32;
393 }
394
395 PauseMapTargetX += xMovement;
396 PauseMapTargetY += yMovement;
397
398 if (PauseMapTargetX < 16.0f) {
399 PauseMapTargetX = 16.0f;
400 }
401
402 if (PauseMapTargetY < 8.0f) {
403 PauseMapTargetY = 8.0f;
404 }
405
406 if (PauseMapTargetX >= 316.0f) {
407 PauseMapTargetX = 315.0f;
408 }
409
410 if (PauseMapTargetY >= 308.0f) {
411 PauseMapTargetY = 307.0f;
412 }
413
414 xTemp = PauseMapTargetX + PauseMapCameraX - 117.0;
415 yTemp = PauseMapTargetY + PauseMapCameraY - 55.0;
416
417 if (xTemp >= 53.0) {
418 PauseMapCameraX -= xTemp - 53.0;
419 }
420
421 if (xTemp <= -37.0) {
422 PauseMapCameraX -= xTemp + 37.0;
423 }
424
425 if (yTemp >= 15.0) {
426 PauseMapCameraY -= yTemp - 15.0;
427 }
428
429 if (yTemp <= -15.0) {
430 PauseMapCameraY -= yTemp + 15.0;
431 }
432
433 if (PauseMapCameraX > 0.0f) {
434 PauseMapCameraX = 0.0f;
435 }
436
437 if (PauseMapCameraY > 0.0f) {
438 PauseMapCameraY = 0.0f;
439 }
440
441 if (PauseMapCameraX < -86.0f) {
442 PauseMapCameraX = -86.0f;
443 }
444
445 if (PauseMapCameraY < -210.0f) {
446 PauseMapCameraY = -210.0f;
447 }
448
452 return;
453 }
454
456 if (PauseMapCursorCurrentOption == -1) {
458 return;
459 }
460
461 gPauseCurrentDescMsg = MSG_Menus_00F3 + (PauseMapCursorCurrentOption * 3);
462
463 // If the story has progressed enough, show the "after" description
464 if (evt_get_variable(0, GB_StoryProgress) >= PauseMapSpaces[PauseMapCursorCurrentOption].afterRequirement) {
466 }
467}
@ BUTTON_B
Definition enums.h:2775
@ SOUND_MENU_BACK
Definition enums.h:704
s32 gPausePressedButtons
Definition pause_main.c:24
HudScript * gPauseCurrentDescIconScript
Definition pause_main.c:26
s32 gPauseCurrentDescMsg
Definition pause_main.c:25
void sfx_play_sound(s32 soundID)
@ GB_StoryProgress

◆ pause_map_update()

void pause_map_update ( MenuPanel * tab)

Definition at line 469 of file pause_map.c.

469 {
471 f32 lowestSqSum = 10000.0f;
472 f32 cursorOption = -1.0f;
473 s32 i;
474
475 PauseMapCursorCurrentOption = -1;
476 PauseMapSpacesInSnapRange = 0;
477
478 for (i = 0; i < ARRAY_COUNT(PauseMapSpaces); i++, mapSpace++) {
479 if (evt_get_variable(0, GF_MAP_ToadTown + i) != 0) {
480 f32 deltaX = PauseMapTargetX - mapSpace->pos.x;
481 f32 deltaY = PauseMapTargetY - mapSpace->pos.y;
482 f32 sqSum = SQ(deltaX) + SQ(deltaY);
483
484 if (sqSum < 400.0f) {
485 PauseMapSpacesInSnapRange++;
486 }
487
488 if (sqSum < lowestSqSum && sqSum < 200.0f) {
490 cursorOption = i;
491 }
492 }
493 }
494
495 PauseMapCursorCurrentOption = cursorOption;
496 PauseMapCursorCurrentOptionCopy = cursorOption;
497}
#define SQ(x)
Definition macros.h:177

◆ pause_map_cleanup()

void pause_map_cleanup ( MenuPanel * tab)

Definition at line 499 of file pause_map.c.

499 {
500 s32 i;
501
502 for (i = 0; i < ARRAY_COUNT(PauseMapHIDs); i++) {
503 hud_element_free(PauseMapHIDs[i]);
504 }
505}
void hud_element_free(s32 id)

◆ pause_map_calc_path_points()

void pause_map_calc_path_points ( PauseMapSpace * space)

Definition at line 92 of file pause_map.c.

92 {
93 Vec2b* path = space->path;
94 s32 pathLength = space->pathLength;
95 s32 x1 = PauseMapSpaces[space->parent].pos.x;
96 s32 y1 = PauseMapSpaces[space->parent].pos.y;
97 s32 x2 = space->pos.x;
98 s32 y2 = space->pos.y;
99 s32 xThingPrev = 0;
100 s32 yThingPrev = 0;
101 s32 i;
102
103 for (i = 0; i < pathLength; i++) {
104 s32 xThing = ((x1 - x2) * (i + 1)) / (pathLength + 1);
105 s32 yThing = ((y1 - y2) * (i + 1)) / (pathLength + 1);
106
107 path[i].x = xThing - xThingPrev;
108 path[i].y = yThing - yThingPrev;
111 }
112}

◆ pause_map_draw_border_arrows()

void pause_map_draw_border_arrows ( s32 imageIndex,
s32 x,
s32 y )

Definition at line 114 of file pause_map.c.

114 {
115 s32 size = 16;
116
117 switch (imageIndex) {
118 case 0:
119 pause_draw_rect(x * 4, y * 4, (x + size) * 4, (y + size) * 4, 0, 0, 0, 0x400, 0x400);
120 break;
121 case 1:
122 pause_draw_rect(x * 4, y * 4, (x + size) * 4, (y + size) * 4, 0, 0, 0x200, 0x400, 0x400);
123 break;
124 case 2:
125 pause_draw_rect(x * 4, y * 4, (x + size) * 4, (y + size) * 4, 0, 0, 0x400, 0x400, 0x400);
126 break;
127 default:
128 pause_draw_rect(x * 4, y * 4, (x + size) * 4, (y + size) * 4, 0, 0, 0x600, 0x400, 0x400);
129 break;
130 }
131}

Referenced by pause_map_draw_contents().

Variable Documentation

◆ PauseGfxWorldMap

◆ PauseGfxPathPoints

◆ PauseGfxArrows

◆ pause_world_map_png

u8 pause_world_map_png[]
extern

Referenced by pause_map_draw_contents().

◆ PauseMapHudScripts

HudScript* PauseMapHudScripts[] = { &HES_MapWalk0 }

Definition at line 35 of file pause_map.c.

35{ &HES_MapWalk0 };
HudScript HES_MapWalk0

Referenced by pause_map_init().

◆ D_8024FA34

s32 D_8024FA34 = -1

Definition at line 36 of file pause_map.c.

◆ PauseMapArrowWobble

s32 PauseMapArrowWobble[] = { 0, 2, 3, 3, 4, 4, 4, 4, 3, 2, 1, 0 }

Definition at line 40 of file pause_map.c.

40{ 0, 2, 3, 3, 4, 4, 4, 4, 3, 2, 1, 0 };

Referenced by pause_map_draw_contents().

◆ PauseMapWindowBPs

MenuWindowBP PauseMapWindowBPs[]

Definition at line 41 of file pause_map.c.

41 {
42 {
43 .windowID = WIN_PAUSE_MAP,
44 .unk_01 = 0,
45 .pos = { .x = 3, .y = 16 },
46 .width = 289,
47 .height = 154,
48 .priority = WINDOW_PRIORITY_1,
49 .fpDrawContents = &pause_map_draw_contents,
50 .tab = nullptr,
51 .parentID = WIN_PAUSE_MAIN,
52 .fpUpdate = { WINDOW_UPDATE_HIDE },
53 .extraFlags = 0,
54 .style = { .customStyle = &gPauseWS_26 }
55 },
56 {
57 .windowID = WIN_PAUSE_MAP_TITLE,
58 .unk_01 = 0,
59 .pos = { .x = MAP_TITLE_X, .y = 124 },
60 .width = MAP_TITLE_WIDTH,
61 .height = 20,
62 .priority = WINDOW_PRIORITY_0,
63 .fpDrawContents = &pause_map_draw_title,
64 .tab = nullptr,
65 .parentID = WIN_PAUSE_MAP,
66 .fpUpdate = { WINDOW_UPDATE_SHOW },
67 .extraFlags = 0,
68 .style = { .customStyle = &gPauseWS_28 }
69 },
70 {},
71 {},
72 {},
73 {},
74 {}
75};
@ 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_MAP_TITLE
Definition enums.h:4870
@ WIN_PAUSE_MAIN
Definition enums.h:4848
WindowStyleCustom gPauseWS_26
WindowStyleCustom gPauseWS_28
#define MAP_TITLE_WIDTH
Definition pause_map.c:9
#define MAP_TITLE_X
Definition pause_map.c:8
void pause_map_draw_title(MenuPanel *menu, s32 baseX, s32 baseY, s32 width, s32 height, s32 opacity, s32 darkening)
Definition pause_map.c:307
void pause_map_draw_contents(MenuPanel *menu, s32 baseX, s32 baseY, s32 width, s32 height, s32 opacity, s32 darkening)
Definition pause_map.c:133

Referenced by pause_map_init().

◆ gPausePanelMap

MenuPanel gPausePanelMap
Initial value:
= {
.initialized = false,
.col = 0,
.row = 0,
.selected = 0,
.state = 0,
.numCols = 0,
.numRows = 0,
.numPages = 0,
.gridData = nullptr,
.fpInit = &pause_map_init,
.fpHandleInput = &pause_map_handle_input,
.fpUpdate = &pause_map_update,
.fpCleanup = &pause_map_cleanup
}
void pause_map_update(MenuPanel *tab)
Definition pause_map.c:469
void pause_map_handle_input(MenuPanel *tab)
Definition pause_map.c:377
void pause_map_init(MenuPanel *tab)
Definition pause_map.c:320
void pause_map_cleanup(MenuPanel *tab)
Definition pause_map.c:499

Definition at line 76 of file pause_map.c.

76 {
77 .initialized = false,
78 .col = 0,
79 .row = 0,
80 .selected = 0,
81 .state = 0,
82 .numCols = 0,
83 .numRows = 0,
84 .numPages = 0,
85 .gridData = nullptr,
86 .fpInit = &pause_map_init,
87 .fpHandleInput = &pause_map_handle_input,
88 .fpUpdate = &pause_map_update,
89 .fpCleanup = &pause_map_cleanup
90};