papermario
Decompilation of Paper Mario
 
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Loading...
Searching...
No Matches
main_loop.c File Reference

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 D_80164000 [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

◆ get_time_freeze_mode()

◆ 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.

Referenced by gfx_task_background().

◆ gfx_draw_frame()

void gfx_draw_frame ( void )

Referenced by gfxRetrace_Callback().

◆ gfx_init_state()

void gfx_init_state ( void )

Referenced by gfx_task_background().

◆ gfx_task_background()

void gfx_task_background ( void )

Referenced by gfxRetrace_Callback().

◆ load_engine_data()

void load_engine_data ( void )

◆ set_time_freeze_mode()

◆ step_game_loop()

void step_game_loop ( void )

Referenced by gfxRetrace_Callback().

Variable Documentation

◆ D_800741A4

s32 D_800741A4 = 0

◆ D_800741E8

s32 D_800741E8[2] = {0, 0}

◆ D_800741F2

u16 D_800741F2 = 0

◆ D_800741FC

s32 D_800741FC = 0

◆ D_80164000

◆ gCurrentDisplayContextIndex

◆ gGameStatus

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

◆ gGameStatusPtr

GameStatus* gGameStatusPtr = &gGameStatus

Referenced by _bgm_set_song(), _update_message(), _use_partner_ability(), action_command_init_status(), action_update_first_strike(), action_update_idle_peach(), action_update_parasol(), action_update_state_23(), action_update_use_spinning_flower(), add_part_decor_sparkles(), advance_rng(), ALT_clear_hud_element_cache(), ALT_load_entity_model(), animate_and_draw_record(), appendGfx_background_texture(), appendGfx_darkness_stencil(), appendGfx_FallingSprite(), appendGfx_intro_logos(), appendGfx_message(), appendGfx_pulse_stone_icon(), appendGfx_records(), 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_scene(), 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_deserialize_state(), fio_load_game(), fio_save_game(), fio_serialize_state(), fire_breath_render(), firework_rocket_appendGfx(), flame_appendGfx(), free_worker(), func_800287F0(), func_8002B608(), func_8014A964(), func_80241610_990DF0(), func_802B6198_E24768(), func_802B6550_E23C30(), 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(), phys_adjust_cam_on_landing(), phys_should_player_be_sliding(), 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_scene(), render_effects_UI(), 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(), spawn_default_surface_effects(), spr_appendGfx_component_flat(), spr_init_sprites(), star_power_shimmer_draw(), 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_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_language_select(), state_step_game_over(), state_step_intro(), state_step_language_select(), 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(), surface_standard_behavior(), 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(), update_player_blink(), update_player_input(), update_player_shadow(), update_scripts(), update_status_bar(), update_triggers(), water_block_appendGfx(), water_splash_appendGfx(), and worker_update_phonograph_hud().

◆ gGameStepDelayAmount

s8 gGameStepDelayAmount = 1

Referenced by step_game_loop().

◆ gGameStepDelayCount

s8 gGameStepDelayCount = 5

Referenced by load_engine_data(), and step_game_loop().

◆ gMatrixListPos

u16 gMatrixListPos = 0

Referenced by _render_transition_stencil(), appendGfx_animator(), appendGfx_animator_node(), appendGfx_darkness_stencil(), appendGfx_entity_model(), appendGfx_FallingSprite(), appendGfx_interact_prompt(), appendGfx_ispy_icon(), appendGfx_item_entity(), appendGfx_pulse_stone_icon(), appendGfx_reset_tile_pattern(), appendGfx_ritual_card(), appendGfx_speech_bubble(), appendGfx_sticker(), aura_appendGfx(), balloon_appendGfx(), big_smoke_puff_appendGfx(), big_snowflakes_appendGfx(), blast_appendGfx(), bombette_breaking_appendGfx(), breaking_junk_appendGfx(), build_gfx_floor(), build_gfx_lamp_halos(), build_gfx_thread(), butterflies_appendGfx(), CharAnim_FadeIn_0(), CharAnim_FadeIn_1(), CharAnim_FadeIn_2(), CharAnim_FadeIn_3(), CharAnim_FadeIn_4(), CharAnim_FadeOut_0(), CharAnim_FadeOut_1(), CharAnim_FadeOut_2(), CharAnim_HoldClearImgFX(), 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_8024033C_A1B43C(), func_80241610_97F0E0(), func_80241610_990DF0(), func_80241610_993D40(), 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_build_splashes(), 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(), setup_gfx_fountain_stars(), setup_gfx_fountain_water(), setup_gfx_geyser(), 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_power_shimmer_draw(), 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().

◆ gOverrideFlags

s32 gOverrideFlags

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_exit_language_select(), state_init_file_select(), state_init_language_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_exit_language_select(), state_step_game_over(), state_step_intro(), state_step_language_select(), 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().

◆ gPauseBackgroundFade

s32 gPauseBackgroundFade = 0

Referenced by gfx_draw_background().

◆ gTimeFreezeMode

◆ 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:244

Referenced by gfx_draw_frame().

◆ nuGfxCfb

u16** nuGfxCfb

◆ SoftResetDelay

BSS s16 SoftResetDelay

Referenced by step_game_loop().

◆ SoftResetOverlayAlpha

s16 SoftResetOverlayAlpha = 0

Referenced by gfx_draw_frame(), and step_game_loop().

◆ SoftResetState

s16 SoftResetState = 0

Referenced by gfx_draw_frame(), and step_game_loop().