Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
state_pause.c
Go to the documentation of this file.
1#include "common.h"
2#include "ld_addrs.h"
3#include "npc.h"
4#include "nu/nusys.h"
5#include "hud_element.h"
6#include "sprite.h"
7#include "model.h"
8#include "game_modes.h"
9
10#if VERSION_JP
11// TODO: split this segment
12extern Addr pause_ROM_START;
13extern Addr pause_ROM_END;
14extern Addr pause_VRAM;
15extern Addr pause_TEXT_START;
16extern Addr pause_TEXT_END;
17extern Addr pause_RODATA_END;
18extern Addr pause_BSS_START;
19extern Addr pause_BSS_END;
20extern Addr pause_DATA_START;
21#endif
22
23extern u16 gFrameBuf0[];
24extern u16 gFrameBuf1[];
25extern u16 gFrameBuf2[];
27
29
30NUPiOverlaySegment PauseOverlaySegment = {
31 .romStart = pause_ROM_START,
32 .romEnd = pause_ROM_END,
33 .ramStart = pause_VRAM,
34 .textStart = pause_TEXT_START,
35 .textEnd = pause_TEXT_END,
36 .dataStart = pause_DATA_START,
37 .dataEnd = pause_RODATA_END,
38 .bssStart = pause_BSS_START,
39 .bssEnd = pause_BSS_END,
40};
41
44BSS s16 StepPauseAlpha; // effectively unused, always zero
46
47// TODO: these should be moved into player status
50
58
59extern Addr D_80200000;
60
61void state_step_pause(void) {
62 switch (StepPauseState) {
63 case 0:
68 if (nuGfxCfb[1] == nuGfxCfb_ptr) {
72 gGameStatusPtr->backgroundFlags &= ~BACKGROUND_RENDER_STATE_MASK;
74
75 }
76 break;
77 case 2:
78 if (StepPauseDelay >= 0) {
79 if (StepPauseDelay != 0) {
81 }
82
83 if (StepPauseDelay == 0) {
84 StepPauseDelay = -1;
85 nuGfxSetCfb(pause_frameBuffers, 2);
92 nuContRmbForceStop();
101 hud_element_set_aux_cache(D_80200000, 0x38000); // TODO shiftability (what should this symbol be?)
106 clear_npcs();
107 clear_entity_data(FALSE);
112 nuPiReadRomOverlay(&PauseOverlaySegment);
113 pause_init();
114 gOverrideFlags &= ~GLOBAL_OVERRIDES_DISABLE_DRAW_FRAME;
115 }
116
117 if (StepPauseDelay >= 0) {
118 break;
119 }
120 }
121
122 if (StepPauseDelay >= -10) {
123 pause_handle_input(0, 0);
125 } else {
127 }
128 StepPauseAlpha = 0;
129 break;
130 }
131}
132
134}
135
137 if (StepPauseAlpha > 0) {
138 StepPauseState = 0;
139 } else {
140 StepPauseState = 1;
141 }
142 StepPauseDelay = 4;
143}
144
146 MapSettings* mapSettings;
147 MapConfig* mapConfig;
148 void* mapShape;
149 s32 assetSize;
150
151 switch (StepPauseState) {
152 case 0:
153 case 1:
154 if (StepPauseDelay == 4) {
156 }
157
158 if (StepPauseDelay >= 0) {
159 if (StepPauseDelay != 0) {
161 }
162
163 if (StepPauseDelay == 0) {
164 StepPauseDelay = -1;
167 gOverrideFlags &= ~GLOBAL_OVERRIDES_DISABLE_DRAW_FRAME;
168 mapSettings = get_current_map_settings();
171 gGameStatusPtr->backgroundFlags &= ~BACKGROUND_RENDER_STATE_MASK;
174 nuContRmbForceStopEnd();
192 mapShape = load_asset_by_name(wMapShapeName, &assetSize);
193 decode_yay0(mapShape, &gMapShapeData);
194 general_heap_free(mapShape);
197
198 if (mapConfig->dmaStart != NULL) {
199 dma_copy(mapConfig->dmaStart, mapConfig->dmaEnd, mapConfig->dmaDest);
200 }
201
202 load_map_bg(mapConfig->bgName);
203 if (mapSettings->background != NULL) {
204 set_background(mapSettings->background);
205 } else {
206 set_background_size(296, 200, 12, 20);
207 }
208
215 StepPauseState = 3;
218
220 update_npcs();
223
224 StepPauseAlpha -= 20;
225 if (StepPauseAlpha < 0) {
226 StepPauseAlpha = 0;
227 }
228 }
229 }
230 break;
231 case 3:
233 update_npcs();
236
237 if (StepPauseAlpha == 0) {
238 StepPauseState = 4;
239 } else {
240 StepPauseAlpha -= 20;
241 if (StepPauseAlpha < 0) {
242 StepPauseAlpha = 0;
243 }
244 }
245 break;
246 case 4:
249 update_npcs();
254 break;
255 }
256}
257
259}
u16 * nuGfxCfb_ptr
Definition cam_main.c:14
s16 savedBackgroundDarkness
u32 pressedButtons[4]
@ BACKGROUND_RENDER_STATE_BEGIN_PAUSED
Definition enums.h:6287
@ TIME_FREEZE_POPUP_MENU
Definition enums.h:3467
@ TIME_FREEZE_PARTIAL
Definition enums.h:3465
@ TIME_FREEZE_NONE
Definition enums.h:3464
@ CONTEXT_PAUSE
Definition enums.h:3531
@ CONTEXT_WORLD
Definition enums.h:3529
@ WINDOW_GROUP_ALL
Definition enums.h:5323
@ WINDOW_GROUP_PAUSE
Definition enums.h:5325
@ PLAYER_SPRITES_MARIO_WORLD
Definition enums.h:6346
@ GLOBAL_OVERRIDES_DISABLE_DRAW_FRAME
Definition enums.h:4322
void clear_script_list(void)
void clear_item_entity_data(void)
void clear_animator_list(void)
Definition animator.c:222
void init_item_entity_list(void)
void func_8005AF84(void)
Definition collision.c:105
void init_entity_models(void)
void bgm_quiet_max_volume(void)
void reset_status_bar(void)
Definition inventory.c:1671
void init_entity_data(void)
Definition entity.c:840
void * load_asset_by_name(const char *assetName, u32 *decompressedSize)
Definition world.c:251
void clear_model_data(void)
Definition model.c:2364
void bgm_reset_max_volume(void)
void clear_trigger_data(void)
Definition trigger.c:13
void init_trigger_list(void)
Definition trigger.c:45
void set_background(BackgroundHeader *)
Definition background.c:40
void clear_sprite_shading_data(void)
void clear_entity_data(b32)
Definition entity.c:787
s32 disable_player_input(void)
Definition 77480.c:990
void mdl_calculate_model_sizes(void)
Definition model.c:2455
void update_effects(void)
Definition effects.c:56
void backup_map_collision_data(void)
Definition collision.c:80
u32 dma_copy(Addr romStart, Addr romEnd, void *vramDest)
Definition 43F0.c:444
void load_map_bg(char *optAssetName)
Definition background.c:14
s32 enable_player_input(void)
Definition 77480.c:998
void initialize_collision(void)
Definition collision.c:111
void pause_cleanup(void)
Definition pause_main.c:796
void clear_worker_list(void)
Definition worker.c:10
void set_background_size(s16, s16, s16, s16)
Definition background.c:50
void pause_handle_input(s32 buttonsPressed, s32 buttonsHeld)
Definition pause_main.c:718
void init_script_list(void)
void pause_init(void)
Definition pause_main.c:605
s32 general_heap_free(void *data)
Definition heap.c:18
void load_map_script_lib(void)
Definition world.c:49
void decode_yay0(void *src, void *dst)
void set_windows_visible(s32 groupIdx)
Definition windows.c:445
void set_time_freeze_mode(s32)
Time freeze modes: 0: none 1: NPCs move, can't be interacted with 2: NPCs don't move,...
Definition main_loop.c:358
s32 battle_heap_create(void)
Definition heap.c:22
void restore_map_collision_data(void)
Definition collision.c:135
void update_player(void)
Definition 77480.c:625
void clear_entity_models(void)
void reset_background_settings(void)
Definition background.c:33
s32 func_8002ACDC(void)
Definition heap.c:30
void init_sprite_shading_data(void)
void status_bar_respond_to_changes(void)
Definition inventory.c:1508
void set_game_mode(s32 modeID)
Definition game_modes.c:127
@ GAME_MODE_WORLD
Definition game_modes.h:12
void hud_element_set_aux_cache(void *base, s32 size)
void hud_element_clear_cache(void)
void init_hud_element_list(void)
u16 ** nuGfxCfb
Definition main_loop.c:13
void reset_animator_list(void)
Definition animator.c:252
void init_model_data(void)
Definition model.c:2431
void init_worker_list(void)
Definition worker.c:24
void npc_reload_all(void)
Definition npc.c:1208
void update_encounters(void)
Definition npc.c:2270
void init_npc_list(void)
Points the current NPC list to the world or battle lists depending on game state.
Definition npc.c:77
void clear_npcs(void)
Definition npc.c:60
void update_npcs(void)
Updates all NPCs.
Definition npc.c:617
void func_8003B1A8(void)
Definition npc.c:1205
void sfx_clear_env_sounds(s16 playSounds)
Definition sfx.c:313
void sfx_stop_env_sounds(void)
Definition sfx.c:361
void sfx_set_reverb_mode(s32 arg0)
Definition sfx.c:352
s32 sfx_get_reverb_mode(void)
Definition sfx.c:357
#define BSS
Definition macros.h:7
#define ARRAY_COUNT(arr)
Definition macros.h:40
MapSettings * get_current_map_settings(void)
Definition world.c:224
char wMapShapeName[]
Definition world.c:27
AreaConfig gAreas[29]
Zero-terminated.
Definition world.c:868
char * bgName
Definition map.h:55
MapConfig * maps
Definition map.h:64
void * dmaEnd
Definition map.h:53
void * dmaDest
Definition map.h:54
BackgroundHeader * background
Definition map.h:39
void * dmaStart
Definition map.h:52
Fields other than main, entryList, entryCount, background, and tattle are initialised when the map lo...
Definition map.h:26
void spr_init_sprites(s32 playerSpriteSet)
Definition sprite.c:764
u8 ReflectWallPrevAlpha
Definition state_pause.c:48
NUPiOverlaySegment PauseOverlaySegment
Definition state_pause.c:30
BSS s8 StepPauseDelay
Definition state_pause.c:42
u16 * pause_frameBuffers[]
Definition state_pause.c:26
void state_drawUI_unpause(void)
void state_step_unpause(void)
void state_init_pause(void)
Definition state_pause.c:51
void state_step_pause(void)
Definition state_pause.c:61
u16 gFrameBuf2[]
Definition heaps3.c:7
u8 ReflectFloorPrevAlpha
Definition state_pause.c:49
void state_init_unpause(void)
BSS s32 SavedReverbMode
Definition state_pause.c:45
u16 gFrameBuf1[]
Definition heaps3.c:6
ShapeFile gMapShapeData
Definition heaps.c:16
BSS s16 StepPauseAlpha
Definition state_pause.c:44
BSS s8 StepPauseState
Definition state_pause.c:43
Addr D_80200000
u16 gFrameBuf0[]
Definition heaps3.c:5
void state_drawUI_pause(void)
u8 Addr[]
Linker symbol address, as in ld_addrs.h.
Definition types.h:16
s32 gOverrideFlags
Definition main_loop.c:11
GameStatus * gGameStatusPtr
Definition main_loop.c:32
PlayerStatus gPlayerStatus
Definition 77480.c:39