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

Go to the source code of this file.

Functions

void gfx_init_state (void)
 
void gfx_draw_background (void)
 Logic for the drawing the scene background.
 
void step_game_loop (void)
 
void gfx_task_background (void)
 
void gfx_draw_frame (void)
 
void load_engine_data (void)
 
void set_time_freeze_mode (s32 mode)
 Time freeze modes: 0: none 1: NPCs move, can't be interacted with 2: NPCs don't move, no partner ability, can't interact, can't use exits 3: NPCs don't more or animate 4: NPCs can move, animations don't update, can use exits.
 
s32 get_time_freeze_mode (void)
 

Variables

s32 gOverrideFlags
 
s32 gTimeFreezeMode
 
u16 ** nuGfxCfb
 
BSS s16 SoftResetDelay
 
DisplayContext DisplayContexts [2]
 
s8 gGameStepDelayAmount = 1
 
s8 gGameStepDelayCount = 5
 
GameStatus gGameStatus
 
GameStatusgGameStatusPtr = &gGameStatus
 
s16 SoftResetOverlayAlpha = 0
 
s16 SoftResetState = 0
 
s32 D_800741A4 = 0
 
Mtx MasterIdentityMtx
 
s32 D_800741E8 [2] = {0, 0}
 
u16 gMatrixListPos = 0
 
u16 D_800741F2 = 0
 
s32 gCurrentDisplayContextIndex = 0
 
s32 gPauseBackgroundFade = 0
 
s32 D_800741FC = 0
 

Function Documentation

◆ gfx_init_state()

void gfx_init_state ( void )

Definition at line 34 of file background_gfx.c.

34 {
35 gSPSegment(gMainGfxPos++, 0x00, 0x0);
36 gSPDisplayList(gMainGfxPos++, OS_K0_TO_PHYSICAL(D_80074230));
37 gSPDisplayList(gMainGfxPos++, OS_K0_TO_PHYSICAL(D_80074210));
38}
Gfx D_80074230[]
Gfx D_80074210[]
Gfx * gMainGfxPos
Definition cam_main.c:15

Referenced by gfx_task_background().

◆ gfx_draw_background()

void gfx_draw_background ( void )

Logic for the drawing the scene background.

In normal operation, it draws the regular background. While opening pause menu, it does the following:

  • Extracts coverage from the current framebuffer and saves it to nuGfxCfb[1] on the first frame.
  • Copies the current framebuffer to the depth buffer to save it and applies a filter on the saved framebuffer based on the saved coverage values one frame later.
  • Draws the saved framebuffer to the current framebuffer while the pause screen is opened, fading it in over time.
Bug
In 1-cycle mode, the two combiner cycles should be identical. Using Texel1 here in the second cycle, which is the actual cycle of the combiner used on hardware in 1-cycle mode, actually samples the next pixel's texel value instead of the current pixel's. This results in a one-pixel offset.
Bug
Due to the previous issue with the incorrect second cycle combiner, the devs added a 1-pixel offset to texture coordinates in this texrect to compensate for the combiner error.

Definition at line 314 of file background_gfx.c.

314 {
315 Camera* camera;
316 s32 bgRenderState;
317 s32 backgroundMinX;
318 s32 backgroundMaxX;
319 s32 backgroundMinY;
320 s32 backgroundMaxY;
321 s32 viewportStartX;
322 s32 i;
323 s32 a = SCREEN_COPY_TILE_HEIGHT << 2;
324
325 gDPSetScissor(gMainGfxPos++, G_SC_NON_INTERLACE, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
326
327 camera = &gCameras[gCurrentCameraID];
329
330 switch (bgRenderState) {
332 // Save coverage to nunGfxCfb[1] using the VISCVG render mode
333 gDPPipeSync(gMainGfxPos++);
334 gDPSetColorImage(gMainGfxPos++, G_IM_FMT_RGBA, G_IM_SIZ_16b, SCREEN_WIDTH, nuGfxCfb[1]);
335 gDPSetCycleType(gMainGfxPos++, G_CYC_1CYCLE);
336 gDPSetBlendColor(gMainGfxPos++, 0x80, 0x80, 0x80, 0xFF);
337 gDPSetPrimDepth(gMainGfxPos++, 0xFFFF, 0xFFFF);
338 gDPSetDepthSource(gMainGfxPos++, G_ZS_PRIM);
339 gDPSetRenderMode(gMainGfxPos++, G_RM_VISCVG, G_RM_VISCVG2);
340 gDPFillRectangle(gMainGfxPos++, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
341 gDPPipeSync(gMainGfxPos++);
342 gDPSetDepthSource(gMainGfxPos++, G_ZS_PIXEL);
343 gGameStatusPtr->backgroundFlags &= ~BACKGROUND_RENDER_STATE_MASK;
345 break;
347 // Save the framebuffer into the depth buffer and run a filter on it based on the saved coverage values
348 gfx_transfer_frame_to_depth(nuGfxCfb[0], nuGfxCfb[1], nuGfxZBuffer); // applies filters to the framebuffer
350 gGameStatusPtr->backgroundFlags &= ~BACKGROUND_RENDER_STATE_MASK;
352 // fallthrough
354 // Draw the saved framebuffer to the background, fading in at a rate of 16 opacity per frame until reaching 128 opacity
356 if (gPauseBackgroundFade > 128) {
358 }
359
360 gDPPipeSync(gMainGfxPos++);
361 gDPSetScissor(gMainGfxPos++, G_SC_NON_INTERLACE, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
362 gDPSetCycleType(gMainGfxPos++, G_CYC_FILL);
363 gDPSetRenderMode(gMainGfxPos++, G_RM_NOOP, G_RM_NOOP2);
364 gDPSetColorImage(gMainGfxPos++, G_IM_FMT_RGBA, G_IM_SIZ_16b, SCREEN_WIDTH, nuGfxCfb_ptr);
365 gDPSetFillColor(gMainGfxPos++, PACK_FILL_COLOR(0, 0, 0, 1));
366 gDPFillRectangle(gMainGfxPos++, 0, 0, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1);
367 gDPSetCycleType(gMainGfxPos++, G_CYC_1CYCLE);
368 gDPSetTexturePersp(gMainGfxPos++, G_TP_NONE);
369 gDPSetTextureLUT(gMainGfxPos++, G_TT_NONE);
370 gDPSetRenderMode(gMainGfxPos++, G_RM_OPA_SURF, G_RM_OPA_SURF2);
374 gDPSetCombineMode(gMainGfxPos++, PM_CC_43, PM_CC_44);
375 gDPSetPrimColor(gMainGfxPos++, 0, 0, 40, 40, 40, gPauseBackgroundFade);
376 gDPSetTextureFilter(gMainGfxPos++, G_TF_POINT);
377
378 for (i = 0; i < 40; i++) {
379 gDPLoadTextureTile(gMainGfxPos++, nuGfxZBuffer + (i * SCREEN_WIDTH * SCREEN_COPY_TILE_HEIGHT), G_IM_FMT_RGBA, G_IM_SIZ_16b, SCREEN_WIDTH,
380 SCREEN_HEIGHT, 0, 0, SCREEN_WIDTH - 1, SCREEN_COPY_TILE_HEIGHT - 1, 0, G_TX_NOMIRROR | G_TX_WRAP,
381 G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD);
384 gSPTextureRectangle(gMainGfxPos++,
385 // ulx, uly, lrx, lry
386 0 << 2, i * a, SCREEN_WIDTH << 2, a + (i * (SCREEN_COPY_TILE_HEIGHT << 2)),
387 // tile
388 G_TX_RENDERTILE,
389 // s, t, dsdx, dtdy
390 -1 << 5, 0 << 5, 1 << 10, 1 << 10);
391 gDPPipeSync(gMainGfxPos++);
392 }
393 break;
394 default:
395 // Draw the scene's background as normal
397 gDPSetColorImage(gMainGfxPos++, G_IM_FMT_RGBA, G_IM_SIZ_16b, SCREEN_WIDTH, osVirtualToPhysical(nuGfxCfb_ptr));
398 return;
399 }
400
401 gDPSetDepthImage(gMainGfxPos++, OS_K0_TO_PHYSICAL(nuGfxZBuffer));
402 gDPSetCycleType(gMainGfxPos++, G_CYC_FILL);
403 gDPSetRenderMode(gMainGfxPos++, G_RM_NOOP, G_RM_NOOP2);
404 gDPSetColorImage(gMainGfxPos++, G_IM_FMT_RGBA, G_IM_SIZ_16b, SCREEN_WIDTH, OS_K0_TO_PHYSICAL(nuGfxZBuffer));
405 gDPSetFillColor(gMainGfxPos++, PACK_FILL_DEPTH(G_MAXFBZ, 0));
406 gDPFillRectangle(gMainGfxPos++, 0, 0, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1);
407 gDPPipeSync(gMainGfxPos++);
408 gDPSetColorImage(gMainGfxPos++, G_IM_FMT_RGBA, G_IM_SIZ_16b, SCREEN_WIDTH, osVirtualToPhysical(nuGfxCfb_ptr));
409 gDPSetFillColor(gMainGfxPos++, PACK_FILL_COLOR(camera->bgColor[0], camera->bgColor[1], camera->bgColor[2], 1));
410
411 backgroundMinX = gGameStatusPtr->backgroundMinX;
412 backgroundMaxX = backgroundMinX + gGameStatusPtr->backgroundMaxX;
413 backgroundMinY = gGameStatusPtr->backgroundMinY;
414 backgroundMaxY = backgroundMinY + gGameStatusPtr->backgroundMaxY;
415 viewportStartX = camera->viewportStartX;
416
417 if (backgroundMinX < viewportStartX) {
418 backgroundMinX = viewportStartX;
419 }
420
421 if (backgroundMinY < camera->viewportStartY) {
422 backgroundMinY = camera->viewportStartY;
423 }
424
425 if (backgroundMaxX > viewportStartX + camera->viewportW) {
426 backgroundMaxX = viewportStartX + camera->viewportW;
427 }
428
429 if (backgroundMaxY > camera->viewportStartY + camera->viewportH) {
430 backgroundMaxY = camera->viewportStartY + camera->viewportH;
431 }
432
433 if (backgroundMinX < 0) {
434 backgroundMinX = 0;
435 }
436
437 if (backgroundMinY < 0) {
438 backgroundMinY = 0;
439 }
440
441 if (backgroundMaxX < 1) {
442 backgroundMaxX = 1;
443 }
444
445 if (backgroundMaxY < 1) {
446 backgroundMaxY = 1;
447 }
448
449 if (backgroundMinX > SCREEN_WIDTH - 1) {
450 backgroundMinX = SCREEN_WIDTH - 1;
451 }
452
453 if (backgroundMinY > SCREEN_HEIGHT - 1) {
454 backgroundMinY = SCREEN_HEIGHT - 1;
455 }
456
457 if (backgroundMaxX > SCREEN_WIDTH) {
458 backgroundMaxX = SCREEN_WIDTH;
459 }
460
461 if (backgroundMaxY > SCREEN_HEIGHT) {
462 backgroundMaxY = SCREEN_HEIGHT;
463 }
464
466 gDPFillRectangle(gMainGfxPos++, backgroundMinX, backgroundMinY, backgroundMaxX - 1, backgroundMaxY - 1);
467 } else {
469 }
470
471 gDPPipeSync(gMainGfxPos++);
472 gDPSetCycleType(gMainGfxPos++, G_CYC_FILL);
473 gDPSetRenderMode(gMainGfxPos++, G_RM_NOOP, G_RM_NOOP2);
474 gDPSetFillColor(gMainGfxPos++, PACK_FILL_COLOR(0, 0, 0, 1));
475 gDPPipeSync(gMainGfxPos++);
476
477 if (backgroundMinY > 0) {
478 gDPFillRectangle(gMainGfxPos++, 0, 0, SCREEN_WIDTH - 1, backgroundMinY - 1);
479 gDPNoOp(gMainGfxPos++);
480 }
481
482 if (backgroundMinX > 0) {
483 gDPFillRectangle(gMainGfxPos++, 0, backgroundMinY, backgroundMinX - 1, backgroundMaxY - 1);
484 gDPNoOp(gMainGfxPos++);
485 }
486
487 if (backgroundMaxX < SCREEN_WIDTH) {
488 gDPFillRectangle(gMainGfxPos++, backgroundMaxX, backgroundMinY, SCREEN_WIDTH - 1, backgroundMaxY - 1);
489 gDPNoOp(gMainGfxPos++);
490 }
491
492 if (backgroundMaxY < SCREEN_HEIGHT) {
493 gDPFillRectangle(gMainGfxPos++, 0, backgroundMaxY, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1);
494 gDPNoOp(gMainGfxPos++);
495 }
496 break;
497 }
498 gDPPipeSync(gMainGfxPos++);
499}
s32 gPauseBackgroundFade
Definition main_loop.c:48
void gfx_transfer_frame_to_depth(u16 *frameBuffer0, u16 *frameBuffer1, u16 *zBuffer)
u16 * nuGfxCfb_ptr
Definition cam_main.c:14
@ BACKGROUND_FLAG_TEXTURE
Definition enums.h:6285
@ BACKGROUND_RENDER_STATE_MASK
Definition enums.h:6290
@ BACKGROUND_RENDER_STATE_FILTER_PAUSED
Definition enums.h:6288
@ BACKGROUND_RENDER_STATE_BEGIN_PAUSED
Definition enums.h:6287
@ BACKGROUND_RENDER_STATE_SHOW_PAUSED
Definition enums.h:6289
@ GLOBAL_OVERRIDES_DISABLE_DRAW_FRAME
Definition enums.h:4322
void appendGfx_background_texture(void)
Definition background.c:62
u16 * nuGfxZBuffer
Definition main.c:46
u16 ** nuGfxCfb
Definition main_loop.c:13
#define SCREEN_WIDTH
Definition macros.h:105
#define PM_CC_43
Definition macros.h:469
#define SCREEN_HEIGHT
Definition macros.h:106
#define SCREEN_COPY_TILE_HEIGHT
Definition macros.h:123
#define PACK_FILL_DEPTH(z, dz)
Definition macros.h:164
#define PM_CC_44
Definition macros.h:470
#define PACK_FILL_COLOR(r, g, b, a)
Definition macros.h:163
s16 bgColor[3]
s16 viewportStartX
s16 viewportStartY
s32 gOverrideFlags
Definition main_loop.c:11
GameStatus * gGameStatusPtr
Definition main_loop.c:32
Camera gCameras[4]
Definition cam_main.c:17
s32 gCurrentCameraID
Definition cam_math.c:4

Referenced by gfx_task_background().

◆ step_game_loop()

void step_game_loop ( void )

Definition at line 54 of file main_loop.c.

54 {
56
57 PlayerData* playerData = &gPlayerData;
58 const int MAX_GAME_TIME = 1000*60*60*60 - 1; // 1000 hours minus one frame at 60 fps
59
60#if !VERSION_JP
63#endif
64
66
67 playerData->frameCounter += 2;
68 if (playerData->frameCounter > MAX_GAME_TIME) {
69 playerData->frameCounter = MAX_GAME_TIME;
70 }
71
72#if VERSION_JP
75#endif
76
78
79 if (gGameStepDelayCount != 0) {
81 if (gGameStepDelayCount == 0) {
83 } else {
84 return;
85 }
86 }
87
109
111 switch (SoftResetState) {
112 case 0:
115
116 if (SoftResetOverlayAlpha == 255) {
117 SoftResetState = 1;
118 SoftResetDelay = 3;
119 } else {
121 if (SoftResetOverlayAlpha > 255) {
123 }
124 }
125 break;
126 case 1:
129 if (SoftResetDelay == 0) {
132 gOverrideFlags &= ~GLOBAL_OVERRIDES_SOFT_RESET;
133 }
134 break;
135 }
136 } else {
138 SoftResetState = 0;
139 }
140
143 } else {
144 gOverrideFlags &= ~GLOBAL_OVERRIDES_PREV_DISABLE_BATTLES;
145 }
146
149 } else {
150 gOverrideFlags &= ~GLOBAL_OVERRIDES_PREV_200;
151 }
152
155 } else {
156 gOverrideFlags &= ~GLOBAL_OVERRIDES_PREV_400;
157 }
158
161 } else {
162 gOverrideFlags &= ~GLOBAL_OVERRIDES_PREV_800;
163 }
164
165 // Unused rand_int used to advance the global random seed each visual frame
166 rand_int(1);
167}
#define rand_int
@ GLOBAL_OVERRIDES_SOFT_RESET
Definition enums.h:4324
@ GLOBAL_OVERRIDES_800
Definition enums.h:4330
@ GLOBAL_OVERRIDES_200
Definition enums.h:4328
@ GLOBAL_OVERRIDES_PREV_400
Definition enums.h:4333
@ GLOBAL_OVERRIDES_400
Definition enums.h:4329
@ GLOBAL_OVERRIDES_PREV_200
Definition enums.h:4332
@ GLOBAL_OVERRIDES_DISABLE_BATTLES
Definition enums.h:4327
@ GLOBAL_OVERRIDES_PREV_800
Definition enums.h:4334
@ GLOBAL_OVERRIDES_PREV_DISABLE_BATTLES
Definition enums.h:4331
void update_ambient_sounds(void)
Definition ambience.c:32
void mdl_reset_transform_flags(void)
Definition model.c:3756
s32 disable_player_input(void)
Definition 77480.c:990
void update_curtains(void)
Definition curtains.c:220
void update_scripts(void)
void update_triggers(void)
Definition trigger.c:89
void update_entities(void)
Definition entity.c:82
void update_input(void)
Definition input.c:31
void update_max_rumble_duration(void)
Definition rumble.c:34
void bgm_update_music_settings(void)
void update_windows(void)
Definition windows.c:143
void update_workers(void)
Definition worker.c:125
void func_80138198(void)
void update_messages(void)
Definition msg.c:247
void set_game_mode(s32 modeID)
Definition game_modes.c:127
void step_game_mode(void)
Definition game_modes.c:163
@ GAME_MODE_STARTUP
Definition game_modes.h:7
void update_hud_elements(void)
s16 SoftResetOverlayAlpha
Definition main_loop.c:33
s32 gOverrideFlags
Definition main_loop.c:11
BSS s16 SoftResetDelay
Definition main_loop.c:14
GameStatus * gGameStatusPtr
Definition main_loop.c:32
s16 SoftResetState
Definition main_loop.c:34
s8 gGameStepDelayCount
Definition main_loop.c:19
s8 gGameStepDelayAmount
Definition main_loop.c:18
#define profiler_frame_setup()
Definition profiling.h:159
#define profiler_update(which, delta)
Definition profiling.h:157
@ PROFILER_TIME_CONTROLLERS
Definition profiling.h:54
@ PROFILER_TIME_ENTITIES
Definition profiling.h:61
@ PROFILER_TIME_MESSAGES
Definition profiling.h:58
@ PROFILER_TIME_HUD_ELEMENTS
Definition profiling.h:59
@ PROFILER_TIME_TRIGGERS
Definition profiling.h:56
@ PROFILER_TIME_STEP_GAME_MODE
Definition profiling.h:60
@ PROFILER_TIME_WORKERS
Definition profiling.h:55
@ PROFILER_TIME_EVT
Definition profiling.h:57
void sfx_update_env_sound_params(void)
Definition sfx.c:334
void sfx_stop_env_sounds(void)
Definition sfx.c:361
PlayerData gPlayerData
Definition 77480.c:40

Referenced by gfxRetrace_Callback().

◆ gfx_task_background()

void gfx_task_background ( void )

Definition at line 169 of file main_loop.c.

169 {
172
175
176 gDPFullSync(gMainGfxPos++);
177 gSPEndDisplayList(gMainGfxPos++);
178
179 // TODO these << 3 >> 3 shouldn't be necessary. There's almost definitely something we're missing here...
180 ASSERT((s32)((u32)((gMainGfxPos - gDisplayContext->backgroundGfx) << 3) >> 3) < ARRAY_COUNT(
182
183 nuGfxTaskStart(&gDisplayContext->backgroundGfx[0], (u32)(gMainGfxPos - gDisplayContext->backgroundGfx) * 8,
184 NU_GFX_UCODE_F3DEX2, NU_SC_NOSWAPBUFFER);
185}
Gfx backgroundGfx[0x200]
#define ASSERT(condition)
DisplayContext DisplayContexts[2]
Definition main_loop.c:16
void gfx_draw_background(void)
Logic for the drawing the scene background.
void gfx_init_state(void)
s32 gCurrentDisplayContextIndex
Definition main_loop.c:47
#define ARRAY_COUNT(arr)
Definition macros.h:40
DisplayContext * gDisplayContext
Definition cam_main.c:16

Referenced by gfxRetrace_Callback().

◆ gfx_draw_frame()

void gfx_draw_frame ( void )

Definition at line 187 of file main_loop.c.

187 {
188 profiler_gfx_started();
189
190 gMatrixListPos = 0;
192
195 return;
196 }
197
198 gSPMatrix(gMainGfxPos++, &MasterIdentityMtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
199
201
203
205 render_frame(FALSE);
206 }
207
210
217
220 }
221
223
225 render_frame(TRUE);
226 }
227
230 ) {
232 }
233
237
240 ) {
242 }
243
245
248 }
249
252 }
253
255
257 switch (SoftResetState) {
258 case 0:
259 case 1:
261 break;
262 }
263 }
264
266
267 profiler_gfx_completed();
269
270 #if DX_DEBUG_MENU
271 dx_debug_console_main();
272 #endif
273
275
276 gDPFullSync(gMainGfxPos++);
277 gSPEndDisplayList(gMainGfxPos++);
278
279 nuGfxTaskStart(gDisplayContext->mainGfx, (u32)(gMainGfxPos - gDisplayContext->mainGfx) * 8, NU_GFX_UCODE_F3DEX2,
280 NU_SC_TASK_LODABLE | NU_SC_SWAPBUFFER);
283}
Gfx mainGfx[0x2080]
@ OVERLAY_SCREEN_MARIO
Definition enums.h:2395
@ DEBUG_SCRIPTS_NONE
Definition enums.h:4275
@ GLOBAL_OVERRIDES_MESSAGES_OVER_FRONTUI
Definition enums.h:4323
@ GLOBAL_OVERRIDES_MESSAGES_OVER_CURTAINS
Definition enums.h:4338
@ GLOBAL_OVERRIDES_DISABLE_RENDER_WORLD
Definition enums.h:4321
@ GLOBAL_OVERRIDES_WINDOWS_OVER_CURTAINS
Definition enums.h:4335
void render_workers_frontUI(void)
Definition worker.c:150
void render_screen_overlay_backUI(void)
void func_802C3EE4(void)
void render_messages(void)
Definition msg.c:568
void render_workers_backUI(void)
Definition worker.c:163
void player_render_interact_prompts(void)
Definition 77480.c:1028
void render_curtains(void)
Definition curtains.c:223
void crash_screen_set_draw_info(u16 *frameBufPtr, s16 width, s16 height)
void render_frame(s32 flag)
Definition cam_main.c:91
void render_window_root(void)
Definition windows.c:347
void render_screen_overlay_frontUI(void)
void render_effects_UI(void)
Definition effects.c:136
void render_game_mode_backUI(void)
Definition game_modes.c:172
void render_game_mode_frontUI(void)
Definition game_modes.c:180
void render_hud_elements_frontUI(void)
void render_hud_elements_backUI(void)
u16 gMatrixListPos
Definition main_loop.c:45
Mtx MasterIdentityMtx
Definition main_loop.c:37
void _render_transition_stencil(u8, f32, ScreenOverlay *)
#define GFX_PROFILER_SWITCH(complete, begin)
Definition profiling.h:212
@ PROFILER_TIME_SUB_GFX_HUD_ELEMENTS
Definition profiling.h:67
@ PROFILER_TIME_SUB_GFX_BACK_UI
Definition profiling.h:67
@ PROFILER_TIME_SUB_GFX_FRONT_UI
Definition profiling.h:67
@ PROFILER_TIME_SUB_GFX_UPDATE
Definition profiling.h:67
#define profiler_print_times()
Definition profiling.h:158
#define GFX_PROFILER_COMPLETE(which)
Definition profiling.h:217
void spr_render_init(void)
Definition sprite.c:814

Referenced by gfxRetrace_Callback().

◆ load_engine_data()

void load_engine_data ( void )

Definition at line 285 of file main_loop.c.

285 {
286 s32 i;
287
288 DMA_COPY_SEGMENT(engine4);
289 DMA_COPY_SEGMENT(engine1);
290 DMA_COPY_SEGMENT(evt);
291 DMA_COPY_SEGMENT(entity);
292 DMA_COPY_SEGMENT(engine2);
293 DMA_COPY_SEGMENT(font_width);
294
295 gOverrideFlags = 0;
326 clear_npcs();
329 clear_entity_data(FALSE);
341 poll_rumble();
342
343 for (i = 0; i < ARRAY_COUNT(gGameStatusPtr->unk_50); i++) {
344 gGameStatusPtr->unk_50[i] = 3;
345 gGameStatusPtr->unk_48[i] = 12;
346 }
347
350}
Vec2b altViewportOffset
@ INTRO_PART_NONE
Definition enums.h:3556
@ TIME_FREEZE_NONE
Definition enums.h:3464
@ PLAYER_SPRITES_MARIO_WORLD
Definition enums.h:6346
void clear_script_list(void)
void clear_item_entity_data(void)
void create_cameras(void)
Definition cam_main.c:255
void clear_animator_list(void)
Definition animator.c:222
void clear_saved_variables(void)
Definition vars_access.c:5
void clear_screen_overlays(void)
void initialize_curtains(void)
Definition curtains.c:212
void clear_render_tasks(void)
Definition model.c:4536
void clear_model_data(void)
Definition model.c:2364
void clear_trigger_data(void)
Definition trigger.c:13
void clear_character_set(void)
Definition msg.c:192
void clear_sprite_shading_data(void)
void clear_entity_data(b32)
Definition entity.c:787
void func_80028838(void)
Definition input.c:23
void clear_printers(void)
Definition msg.c:196
void clear_player_status(void)
Definition 77480.c:807
void clear_effect_data(void)
Definition effects.c:37
HeapNode * general_heap_create(void)
Definition heap.c:6
void clear_worker_list(void)
Definition worker.c:10
void reset_ambient_sounds(void)
Definition ambience.c:28
void clear_windows(void)
Definition windows.c:135
void clear_player_data(void)
Definition inventory.c:49
void bgm_reset_sequence_players(void)
void clear_entity_models(void)
void reset_background_settings(void)
Definition background.c:33
void poll_rumble(void)
Definition rumble.c:10
void fio_init_flash(void)
Definition fio.c:232
void clear_game_mode(void)
Definition game_modes.c:150
void hud_element_clear_cache(void)
s32 gTimeFreezeMode
Definition main_loop.c:12
void clear_npcs(void)
Definition npc.c:60
void init_encounter_status(void)
Definition npc.c:2191
void sfx_clear_sounds(void)
Definition sfx.c:304
#define DMA_COPY_SEGMENT(segment)
Definition macros.h:525
void spr_init_sprites(s32 playerSpriteSet)
Definition sprite.c:764

Referenced by load_engine_data_obfuscated().

◆ set_time_freeze_mode()

void set_time_freeze_mode ( s32 mode)

Time freeze modes: 0: none 1: NPCs move, can't be interacted with 2: NPCs don't move, no partner ability, can't interact, can't use exits 3: NPCs don't more or animate 4: NPCs can move, animations don't update, can use exits.

Definition at line 358 of file main_loop.c.

358 {
359 switch (mode) {
360 case TIME_FREEZE_NONE:
361 gTimeFreezeMode = mode;
364 break;
366 gTimeFreezeMode = mode;
370 break;
371 case TIME_FREEZE_FULL:
372 gTimeFreezeMode = mode;
376 break;
378 gTimeFreezeMode = mode;
379 gOverrideFlags &= ~GLOBAL_OVERRIDES_800;
382 break;
383 case TIME_FREEZE_EXIT:
384 gTimeFreezeMode = mode;
386 break;
387 }
388}
@ TIME_FREEZE_FULL
Definition enums.h:3466
@ TIME_FREEZE_POPUP_MENU
Definition enums.h:3467
@ TIME_FREEZE_PARTIAL
Definition enums.h:3465
@ TIME_FREEZE_EXIT
Definition enums.h:3468
@ EVT_GROUP_FLAG_MENUS
Definition evt.h:135
@ EVT_GROUP_FLAG_INTERACT
Definition evt.h:134
s32 resume_all_group(s32 groupFlags)
void suspend_all_group(s32 groupFlags)

Referenced by _use_partner_ability(), action_update_parasol(), check_input_open_menus(), entity_HeartBlock_show_tutorial_message(), entity_HeartBlock_wait_for_close_tutorial(), entity_HeartBlockContent__anim_heal(), entity_HeartBlockContent_anim_idle(), entity_HiddenPanel_flip_over(), entity_SaveBlock_pause_game(), entity_SaveBlock_resume_game(), pre_battle(), state_init_file_select(), state_init_pause(), state_step_battle(), state_step_change_map(), state_step_end_battle(), state_step_enter_world(), state_step_exit_file_select(), state_step_unpause(), and update_item_entity_pickup().

◆ get_time_freeze_mode()

s32 get_time_freeze_mode ( void )

Variable Documentation

◆ gOverrideFlags

s32 gOverrideFlags

Definition at line 11 of file main_loop.c.

Referenced by action_update_hit_fire(), action_update_hit_lava(), action_update_use_munchlesia(), action_update_use_spinning_flower(), auto_collect_item_entity(), bgm_pop_battle_song(), bgm_push_battle_song(), btl_restore_world_cameras(), can_open_world_menu(), check_for_item_collision(), check_input_open_menus(), draw_ui_item_entities(), entity_BlueWarpPipe_idle(), entity_BlueWarpPipe_start_bound_script(), entity_HeartBlock_show_tutorial_message(), entity_HeartBlock_wait_for_close_tutorial(), entity_HeartBlockContent__anim_heal(), entity_HeartBlockContent_anim_idle(), entity_SuperBlockContent_idle(), execute_render_tasks(), gfx_draw_background(), gfx_draw_frame(), init_enter_world_shared(), initialize_battle(), load_demo_battle(), load_engine_data(), load_map_by_IDs(), npc_get_render_yaw(), set_time_freeze_mode(), state_init_end_battle(), state_init_exit_file_select(), state_init_file_select(), state_init_logos(), state_init_startup(), state_init_title_screen(), state_step_battle(), state_step_change_map(), state_step_demo(), state_step_end_battle(), state_step_enter_world(), state_step_exit_file_select(), state_step_game_over(), state_step_intro(), state_step_pause(), state_step_startup(), state_step_title_screen(), state_step_unpause(), step_game_loop(), test_item_entity_position(), test_item_player_collision(), update_effects(), update_encounters_neutral(), update_item_entities(), update_item_entity_collectable(), update_item_entity_pickup(), update_item_entity_stationary(), and update_npcs().

◆ gTimeFreezeMode

◆ nuGfxCfb

u16** nuGfxCfb

◆ SoftResetDelay

BSS s16 SoftResetDelay

Definition at line 14 of file main_loop.c.

Referenced by step_game_loop().

◆ DisplayContexts

DisplayContext DisplayContexts[2]

Definition at line 16 of file main_loop.c.

Referenced by appendGfx_reset_tile_pattern(), and gfx_task_background().

◆ gGameStepDelayAmount

s8 gGameStepDelayAmount = 1

Definition at line 18 of file main_loop.c.

Referenced by step_game_loop().

◆ gGameStepDelayCount

s8 gGameStepDelayCount = 5

Definition at line 19 of file main_loop.c.

Referenced by load_engine_data(), and step_game_loop().

◆ gGameStatus

GameStatus gGameStatus
Initial value:
= {
.curButtons = { 0 },
.pressedButtons = { 0 },
.heldButtons = { 0 },
.prevButtons = { 0 },
.stickX = { 0 },
.stickY = { 0 },
.unk_48 = { 0 },
.unk_50 = { 0 },
}

Definition at line 21 of file main_loop.c.

21 {
22 .curButtons = { 0 },
23 .pressedButtons = { 0 },
24 .heldButtons = { 0 },
25 .prevButtons = { 0 },
26 .stickX = { 0 },
27 .stickY = { 0 },
28 .unk_48 = { 0 },
29 .unk_50 = { 0 },
30};

Referenced by action_update_idle_peach(), action_update_parasol(), action_update_step_up_set_peach_anim(), action_update_walk_set_peach_anim(), fio_deserialize_state(), fio_serialize_state(), load_map_by_IDs(), state_init_startup(), state_init_world(), state_step_startup(), update_player(), and ver_deserialize_standard().

◆ gGameStatusPtr

GameStatus* gGameStatusPtr = &gGameStatus

Definition at line 32 of file main_loop.c.

Referenced by _bgm_set_song(), _update_message(), _use_partner_ability(), action_command_init_status(), action_update_first_strike(), action_update_state_23(), action_update_use_spinning_flower(), add_part_decor_sparkles(), advance_rng(), ALT_clear_hud_element_cache(), ALT_load_entity_model(), appendGfx_background_texture(), appendGfx_darkness_stencil(), appendGfx_intro_logos(), appendGfx_message(), appendGfx_pulse_stone_icon(), appendGfx_title_screen(), basic_ai_chase(), bgm_get_map_default_variation(), bgm_pop_battle_song(), bgm_pop_song(), bgm_push_battle_song(), bgm_push_song(), boot_main(), btl_draw_enemy_health_bars(), btl_state_draw_first_stike(), btl_state_update_begin_turn(), btl_state_update_celebration(), btl_state_update_end_battle(), btl_state_update_end_demo_battle(), btl_state_update_enemy_move(), btl_state_update_first_strike(), btl_state_update_normal_start(), btl_state_update_partner_menu(), btl_state_update_partner_move(), btl_state_update_player_menu(), btl_state_update_player_move(), btl_state_update_run_away(), btl_submenu_moves_update(), btl_update(), btl_update_strats_menu(), can_open_world_menu(), check_block_input(), check_for_pulse_stone(), check_for_treadmill_overlaps(), check_input_open_menus(), check_input_status_bar(), check_player_action_debug(), clear_animator_list(), clear_area_flags(), clear_encounter_status(), clear_entity_data(), clear_entity_models(), clear_item_entity_data(), clear_model_data(), clear_npcs(), clear_script_list(), clear_trigger_data(), clear_virtual_entity_list(), clear_worker_list(), coin_counter_draw_content(), collision_heap_free(), collision_heap_malloc(), count_power_plus(), create_effect_instance(), create_mesh_animator(), create_model_animator(), create_npc_impl(), create_status_icon_set(), create_worker_backUI(), create_worker_frontUI(), create_worker_world(), destroy_popup_menu(), draw(), draw_all_status_icons(), draw_box(), draw_encounters_pre_battle(), draw_entity_model_A(), draw_entity_model_B(), draw_entity_model_C(), draw_entity_model_D(), draw_mash_meter(), draw_shop_items(), draw_ui_item_entity_collectable(), entity_BlueWarpPipe_wait_for_player_to_get_off(), entity_Chest_adjust_camera(), entity_Chest_reset_camera(), entity_GiantChest_open(), entity_SaveBlock_save_data(), evt_execute_next_command(), exec_entity_model_commandlist(), filemenu_draw_contents_copy_arrow(), filemenu_draw_contents_mono(), filemenu_draw_contents_stereo(), filemenu_init(), filemenu_main_handle_input(), filemenu_update(), filemenu_yesno_handle_input(), fio_load_game(), fio_save_game(), fire_breath_render(), firework_rocket_appendGfx(), flame_appendGfx(), free_worker(), func_800287F0(), func_800F102C(), func_8014A964(), func_E0024324(), func_E00243BC(), game_input_to_move_vector(), get_entity_list(), get_lava_reset_pos(), get_player_normal_pitch(), get_player_normal_yaw(), get_shadow_list(), gfx_draw_background(), gfx_draw_frame(), goto_map(), heap_free(), heap_malloc(), hud_element_clear_cache(), hud_element_create(), hud_element_load_script(), imgfx_appendGfx_mesh_basic(), imgfx_mesh_anim_update(), imgfx_mesh_make_wavy(), init_enter_world_shared(), init_entity_data(), init_entity_models(), init_hud_element_list(), init_item_entity_list(), init_model_animators(), init_model_data(), init_npc_list(), init_script_list(), init_sprite_shading_data(), init_trigger_list(), init_virtual_entity_list(), init_worker_list(), initialize_battle(), is_ability_active(), is_entity_data_loaded(), ispy_notification_update(), item_entity_load(), item_entity_update(), lightning_bolt_render(), lightning_main(), load_area_specific_entity_data(), load_demo_battle(), load_engine_data(), load_entity_model(), load_map_by_IDs(), load_partner_actor(), load_player_actor(), load_simple_entity_data(), load_split_entity_data(), make_item_entity(), make_item_entity_at_player(), make_npcs(), map_init(), mdl_load_all_textures(), msg_draw_choice_pointer(), npc_raycast_down(), parasol_get_npc(), partner_flying_update_motion(), partner_reset_data(), partner_use_ability(), partner_walking_update_motion(), pause_badges_draw_contents(), pause_map_draw_contents(), pause_map_handle_input(), pause_spirits_draw_contents(), peach_check_for_parasol_input(), peach_force_disguise_action(), peach_make_disguise_npc(), play_ambient_sounds(), player_raycast_below(), player_raycast_down(), popup_menu_update(), post_battle(), render_animated_model(), render_animated_model_with_vertices(), render_curtains(), render_effects_UI(), render_effects_world(), render_entities(), render_frame(), render_player(), render_screen_overlay_backUI(), render_screen_overlay_frontUI(), reset_animator_list(), reset_background_settings(), reset_battle_status(), reset_model_animators(), reset_player_status(), set_background(), set_background_size(), set_cam_viewport(), set_npc_shadow_scale(), set_peach_shadow_scale(), set_standard_shadow_scale(), sfx_clear_env_sounds(), sfx_compute_spatialized_sound_params_ignore_depth(), sfx_play_sound_with_params(), sfx_stop_env_sounds(), shop_draw_item_desc(), shop_draw_item_name(), shop_get_sell_price(), shop_open_item_select_popup(), shop_owner_begin_speech(), shop_owner_buy_dialog(), shop_owner_continue_speech(), shop_owner_continue_speech_with_quantity(), shop_owner_end_speech(), shop_owner_reset_speech(), shop_update_item_select_popup(), should_continue_pulse_stone(), spr_appendGfx_component_flat(), spr_init_sprites(), star_update(), start_rumble(), startup_fade_screen_in(), startup_fade_screen_out(), startup_fade_screen_update(), startup_set_fade_screen_alpha(), startup_set_fade_screen_color(), state_drawUI_enter_world(), state_drawUI_title_screen(), state_init_change_map(), state_init_demo(), state_init_intro(), state_init_logos(), state_init_title_screen(), state_step_battle(), state_step_change_map(), state_step_demo(), state_step_end_battle(), state_step_enter_world(), state_step_game_over(), state_step_intro(), state_step_logos(), state_step_pause(), state_step_startup(), state_step_title_screen(), state_step_unpause(), status_bar_start_blinking_coins(), status_bar_start_blinking_fp(), status_bar_start_blinking_hp(), step_game_loop(), tattle_cam_pre_render(), try_player_footstep_sounds(), update_effects(), update_encounters_neutral(), update_encounters_post_battle(), update_encounters_pre_battle(), update_entities(), update_exit_map_screen_overlay(), update_input(), update_item_entities(), update_item_entity_pickup(), update_max_rumble_duration(), update_merlee_message(), update_model_animator(), update_model_animator_with_transform(), update_partner_timers(), update_player_blink(), update_player_input(), update_player_shadow(), update_scripts(), update_status_bar(), update_triggers(), water_block_appendGfx(), and water_splash_appendGfx().

◆ SoftResetOverlayAlpha

s16 SoftResetOverlayAlpha = 0

Definition at line 33 of file main_loop.c.

Referenced by gfx_draw_frame(), and step_game_loop().

◆ SoftResetState

s16 SoftResetState = 0

Definition at line 34 of file main_loop.c.

Referenced by gfx_draw_frame(), and step_game_loop().

◆ D_800741A4

s32 D_800741A4 = 0

Definition at line 35 of file main_loop.c.

◆ MasterIdentityMtx

Mtx MasterIdentityMtx
Initial value:
1.000000, 0.000000, 0.000000, 0.000000,
0.000000, 1.000000, 0.000000, 0.000000,
0.000000, 0.000000, 1.000000, 0.000000,
0.000000, 0.000000, 0.000000, 1.000000
)
#define RDP_MATRIX( Ax, Bx, Cx, Dx, Ay, By, Cy, Dy, Az, Bz, Cz, Dz, Aw, Bw, Cw, Dw)
Definition macros.h:233

Definition at line 37 of file main_loop.c.

Referenced by gfx_draw_frame().

◆ D_800741E8

s32 D_800741E8[2] = {0, 0}

Definition at line 44 of file main_loop.c.

44{0, 0}; // padding?

◆ gMatrixListPos

u16 gMatrixListPos = 0

Definition at line 45 of file main_loop.c.

Referenced by _render_transition_stencil(), appendGfx_animator(), appendGfx_animator_node(), appendGfx_darkness_stencil(), appendGfx_entity_model(), appendGfx_interact_prompt(), appendGfx_ispy_icon(), appendGfx_item_entity(), appendGfx_pulse_stone_icon(), appendGfx_reset_tile_pattern(), appendGfx_speech_bubble(), aura_appendGfx(), balloon_appendGfx(), big_smoke_puff_appendGfx(), big_snowflakes_appendGfx(), blast_appendGfx(), bombette_breaking_appendGfx(), breaking_junk_appendGfx(), butterflies_appendGfx(), chomp_drop_appendGfx(), cloud_puff_appendGfx(), cloud_trail_appendGfx(), cold_breath_appendGfx(), confetti_appendGfx(), damage_indicator_render_impl(), damage_stars_appendGfx(), debuff_appendGfx(), draw_box(), draw_coin_sparkles(), draw_entity_model_E(), drop_leaves_appendGfx(), dust_appendGfx(), effect_3D_appendGfx(), effect_46_appendGfx(), effect_63_appendGfx(), effect_65_appendGfx(), effect_75_appendGfx(), effect_86_appendGfx(), embers_appendGfx(), emote_appendGfx(), ending_decals_appendGfx(), energy_in_out_appendGfx(), energy_orb_wave_appendGfx(), energy_shockwave_appendGfx(), entity_ArrowSign_setupGfx(), entity_BlueWarpPipe_setupGfx(), Entity_BoardedFloor_setupGfx(), entity_BombableRock_setupGfx(), entity_Chest_setupGfx(), entity_HeartBlockContent__setupGfx(), entity_HiddenPanel_setupGfx(), entity_Padlock_setupGfx(), entity_PinkFlowerLight_setupGfx(), entity_SaveBlock_setupGfx(), entity_shattering_setupGfx(), entity_SpinningFlower_setupGfx(), entity_StarBoxLauncher_setupGfx(), entity_SuperBlockContent_setupGfx(), entity_Tweester_render_inner_whirl(), entity_Tweester_render_outer_whirl(), entity_WoodenCrate_setupGfx(), execute_render_tasks(), explosion_appendGfx(), falling_leaves_appendGfx(), filemenu_draw_contents_copy_arrow(), fire_breath_appendGfx(), fire_flower_appendGfx(), flame_appendGfx(), flashing_box_shockwave_appendGfx(), floating_cloud_puff_appendGfx(), floating_flower_appendGfx(), floating_rock_appendGfx(), flower_splash_appendGfx(), flower_trail_appendGfx(), footprint_appendGfx(), fright_jar_appendGfx(), func_800F102C(), func_E005E334(), func_E0080448(), func_E0082580(), func_E00826C4(), func_E00863B4(), func_E0090444(), func_E00AC2A4(), func_E0112330(), func_E01166E8(), gather_energy_pink_appendGfx(), gather_magic_appendGfx(), gfx_build_knocked_down_player(), gfx_draw_frame(), got_item_outline_appendGfx(), green_impact_appendGfx(), hieroglyphs_appendGfx(), huff_puff_breath_appendGfx(), ice_pillar_appendGfx(), ice_shard_appendGfx(), imgfx_appendGfx_mesh_anim(), imgfx_appendGfx_mesh_strip(), landing_dust_appendGfx(), lens_flare_appendGfx(), light_rays_appendGfx(), lightning_appendGfx(), lightning_bolt_appendGfx(), lil_oink_appendGfx(), mdl_update_transform_matrices(), merlin_house_stars_appendGfx(), misc_particles_appendGfx(), moving_cloud_appendGfx(), msg_draw_speech_arrow(), msg_draw_speech_bubble(), msg_update_rewind_arrow(), music_note_appendGfx(), pause_partners_draw_contents(), pause_spirits_draw_contents(), pause_tutorial_draw_contents(), peach_star_beam_appendGfx(), pink_sparkles_appendGfx(), purple_ring_appendGfx(), quizmo_assistant_appendGfx(), quizmo_audience_appendGfx(), quizmo_stage_appendGfx(), radial_shimmer_appendGfx(), radiating_energy_orb_appendGfx(), red_impact_appendGfx(), render_frame(), render_hud_element(), render_item_entities(), ring_blast_appendGfx(), rising_bubble_appendGfx(), shape_spell_appendGfx(), shattering_stones_appendGfx(), shimmer_burst_appendGfx(), shimmer_wave_appendGfx(), shiny_flare_appendGfx(), shockwave_appendGfx(), sleep_bubble_appendGfx(), small_gold_sparkle_appendGfx(), smoke_burst_appendGfx(), smoke_impact_appendGfx(), smoke_ring_appendGfx(), snaking_static_appendGfx(), snowfall_appendGfx(), snowflake_appendGfx(), snowman_doll_appendGfx(), sparkles_appendGfx(), spiky_white_aura_appendGfx(), spr_appendGfx_component(), squirt_appendGfx(), star_appendGfx(), star_outline_appendGfx(), star_spirits_energy_appendGfx(), stars_burst_appendGfx(), stars_shimmer_appendGfx(), stars_spread_appendGfx(), static_status_appendGfx(), steam_burst_appendGfx(), stop_watch_appendGfx(), sun_appendGfx(), sweat_appendGfx(), throw_spiny_appendGfx(), thunderbolt_ring_appendGfx(), tubba_heart_attack_appendGfx(), underwater_appendGfx(), walking_dust_appendGfx(), water_block_appendGfx(), water_fountain_appendGfx(), water_splash_appendGfx(), waterfall_appendGfx(), whirlwind_appendGfx(), and windy_leaves_appendGfx().

◆ D_800741F2

u16 D_800741F2 = 0

Definition at line 46 of file main_loop.c.

◆ gCurrentDisplayContextIndex

◆ gPauseBackgroundFade

s32 gPauseBackgroundFade = 0

Definition at line 48 of file main_loop.c.

Referenced by gfx_draw_background().

◆ D_800741FC

s32 D_800741FC = 0

Definition at line 49 of file main_loop.c.