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

Go to the source code of this file.

Functions

void state_init_battle (void)
 
void state_step_battle (void)
 
void state_drawUI_battle (void)
 
void state_init_end_battle (void)
 
void state_step_end_battle (void)
 
void state_drawUI_end_battle (void)
 

Variables

u16 gFrameBuf0 []
 
u16 gFrameBuf1 []
 
u16 gFrameBuf2 []
 
u16 * bFrameBuffers []
 
s32 D_800778AC []
 
BSS s8 D_800A0900
 
BSS s32 D_800A0904
 
BSS s32 D_800A0908
 
ShapeFile gMapShapeData
 

Function Documentation

◆ state_init_battle()

void state_init_battle ( void )

Definition at line 32 of file state_battle.c.

32 {
33 D_800A0900 = 5;
34}
BSS s8 D_800A0900

◆ state_step_battle()

void state_step_battle ( void )

Definition at line 36 of file state_battle.c.

36 {
37 u32 currentBattleSelection;
38 u32 currentBattleIndex;
39
40 if (D_800A0900 == 5) {
41 if (nuGfxCfb[1] != nuGfxCfb_ptr) {
42 return;
43 }
44 D_800A0900--;
46 nuContRmbForceStop();
47 }
48
49 if (D_800A0900 >= 0) {
50 if (D_800A0900 > 0) {
51 D_800A0900--;
52 return;
53 }
54
55 D_800A0900 = -1;
56 nuGfxSetCfb(bFrameBuffers, 2);
57 nuContRmbForceStopEnd();
62
63#if !VERSION_IQUE
65#endif
67
69
70 currentBattleSelection = UNPACK_BTL_AREA(gCurrentBattleID);
71 currentBattleIndex = UNPACK_BTL_INDEX(gCurrentBattleID);
72
74 (currentBattleSelection == BTL_AREA_KKJ && currentBattleIndex == 0)) {
77 } else {
79 }
80
92 clear_npcs();
95 DMA_COPY_SEGMENT(battle_code);
100 gPlayerStatusPtr->animFlags &= ~PA_FLAG_PULSE_STONE_VISIBLE;
103 gOverrideFlags &= ~GLOBAL_OVERRIDES_DISABLE_DRAW_FRAME;
104
105 if (D_800A0900 >= 0) {
106 return;
107 }
108 }
109
111 btl_update();
112 update_npcs();
116}
u16 * nuGfxCfb_ptr
Definition cam_main.c:14
@ PEACH_FLAG_IS_PEACH
Definition enums.h:2488
@ TIME_FREEZE_NONE
Definition enums.h:3464
@ CONTEXT_BATTLE
Definition enums.h:3530
@ PLAYER_SPRITES_PEACH_BATTLE
Definition enums.h:6352
@ PLAYER_SPRITES_MARIO_BATTLE
Definition enums.h:6351
@ GLOBAL_OVERRIDES_DISABLE_DRAW_FRAME
Definition enums.h:4322
void clear_script_list(void)
void clear_item_entity_data(void)
void btl_update(void)
Definition 16C8E0.c:254
void clear_animator_list(void)
Definition animator.c:222
void load_battle_section(void)
Definition battle.c:111
void reset_status_bar(void)
Definition inventory.c:1671
void clear_model_data(void)
Definition model.c:2364
void clear_trigger_data(void)
Definition trigger.c:13
void clear_sprite_shading_data(void)
void clear_entity_data(b32)
Definition entity.c:787
void update_effects(void)
Definition effects.c:56
void backup_map_collision_data(void)
Definition collision.c:80
void load_obfuscation_shims(void)
void update_cameras(void)
Definition cam_main.c:19
void clear_worker_list(void)
Definition worker.c:10
void shim_battle_heap_create_obfuscated(void)
void btl_save_world_cameras(void)
Definition 16C8E0.c:1070
s32 get_time_freeze_mode(void)
Definition main_loop.c:390
void update_item_entities(void)
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
void clear_entity_models(void)
void reset_background_settings(void)
Definition background.c:33
void initialize_battle(void)
Definition 16C8E0.c:160
void hud_element_set_aux_cache(void *base, s32 size)
void hud_element_clear_cache(void)
u16 ** nuGfxCfb
Definition main_loop.c:13
void update_encounters(void)
Definition npc.c:2270
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
#define DMA_COPY_SEGMENT(segment)
Definition macros.h:525
#define UNPACK_BTL_AREA(battleID)
Definition macros.h:148
#define UNPACK_BTL_INDEX(battleID)
Definition macros.h:149
void spr_init_sprites(s32 playerSpriteSet)
Definition sprite.c:764
@ BTL_AREA_KKJ
Definition battle.h:49
u16 * bFrameBuffers[]
BSS s32 D_800A0904
BSS s32 D_800A0908
s32 gCurrentBattleID
Definition battle.c:16
s32 gOverrideFlags
Definition main_loop.c:11
PlayerStatus * gPlayerStatusPtr
GameStatus * gGameStatusPtr
Definition main_loop.c:32

◆ state_drawUI_battle()

void state_drawUI_battle ( void )

Definition at line 118 of file state_battle.c.

118 {
120 if (D_800A0900 < 0) {
121 btl_draw_ui();
122 }
123}
void btl_draw_ui(void)
Definition 16C8E0.c:486
void draw_encounter_ui(void)
Definition npc.c:2294

◆ state_init_end_battle()

void state_init_end_battle ( void )

Definition at line 125 of file state_battle.c.

125 {
127 nuContRmbForceStop();
128 D_800A0900 = 5;
129}

◆ state_step_end_battle()

void state_step_end_battle ( void )

Definition at line 131 of file state_battle.c.

131 {
132 PlayerStatus* playerStatus = &gPlayerStatus;
133 PlayerData* playerData = &gPlayerData;
134 MapSettings* mapSettings;
135 MapConfig* mapConfig;
136
137 if (D_800A0900 >= 0) {
138 D_800A0900--;
139 if (D_800A0900 == 0) {
140 D_800A0900 = -1;
141 nuGfxSetCfb(bFrameBuffers, 3);
142 gOverrideFlags &= ~GLOBAL_OVERRIDES_DISABLE_DRAW_FRAME;
143 nuContRmbForceStopEnd();
145 mapSettings = get_current_map_settings();
152 gGameStatusPtr->peachFlags &= ~PEACH_FLAG_IS_PEACH;
167
170 playerStatus->animFlags = D_800A0904;
172 } else {
173 void* mapShape;
174 u32 sizeTemp;
175
178 mapShape = load_asset_by_name(wMapShapeName, &sizeTemp);
179 decode_yay0(mapShape, &gMapShapeData);
180 general_heap_free(mapShape);
183
184 if (mapConfig->dmaStart != NULL) {
185 dma_copy(mapConfig->dmaStart, mapConfig->dmaEnd, mapConfig->dmaDest);
186 }
187
188 load_map_bg(mapConfig->bgName);
189 if (mapSettings->background != NULL) {
190 set_background(mapSettings->background);
191 } else {
192 set_background_size(296, 200, 12, 20);
193 }
194
195 mdl_load_all_textures(mapSettings->modelTreeRoot, get_asset_offset(wMapTexName, &sizeTemp), sizeTemp);
198
199 playerStatus->animFlags = D_800A0904;
200 if (D_800A0908 != 0) {
202 }
204 }
205 }
206 }
207}
@ DEMO_BTL_FLAG_ENABLED
Definition enums.h:3543
@ CONTEXT_WORLD
Definition enums.h:3529
void init_item_entity_list(void)
void func_8005AF84(void)
Definition collision.c:105
void init_entity_models(void)
void init_entity_data(void)
Definition entity.c:840
void * load_asset_by_name(const char *assetName, u32 *decompressedSize)
Definition world.c:251
void init_trigger_list(void)
Definition trigger.c:45
void set_background(BackgroundHeader *)
Definition background.c:40
void mdl_calculate_model_sizes(void)
Definition model.c:2455
u32 dma_copy(Addr romStart, Addr romEnd, void *vramDest)
Definition 43F0.c:444
void load_map_bg(char *optAssetName)
Definition background.c:14
s32 get_asset_offset(char *, s32 *)
Definition world.c:273
void initialize_collision(void)
Definition collision.c:111
void set_background_size(s16, s16, s16, s16)
Definition background.c:50
void mdl_load_all_textures(struct ModelNode *model, s32 romOffset, s32 size)
Definition model.c:2322
void init_script_list(void)
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)
s32 battle_heap_create(void)
Definition heap.c:22
void restore_map_collision_data(void)
Definition collision.c:135
void btl_restore_world_cameras(void)
Definition 16C8E0.c:1086
s32 func_8002ACDC(void)
Definition heap.c:30
void init_sprite_shading_data(void)
void partner_init_after_battle(s32 arg0)
Definition partners.c:926
void set_game_mode(s32 modeID)
Definition game_modes.c:127
@ GAME_MODE_DEMO
Definition game_modes.h:22
@ GAME_MODE_WORLD
Definition game_modes.h:12
void init_hud_element_list(void)
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 init_npc_list(void)
Points the current NPC list to the world or battle lists depending on game state.
Definition npc.c:77
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
char wMapTexName[]
Definition world.c:28
void * dmaEnd
Definition map.h:53
void * dmaDest
Definition map.h:54
BackgroundHeader * background
Definition map.h:39
void * dmaStart
Definition map.h:52
struct ModelNode * modelTreeRoot
Definition map.h:27
Fields other than main, entryList, entryCount, background, and tattle are initialised when the map lo...
Definition map.h:26
ShapeFile gMapShapeData
Definition heaps.c:16
PlayerData gPlayerData
Definition 77480.c:40
PlayerStatus gPlayerStatus
Definition 77480.c:39

◆ state_drawUI_end_battle()

void state_drawUI_end_battle ( void )

Definition at line 209 of file state_battle.c.

209 {
210}

Variable Documentation

◆ gFrameBuf0

u16 gFrameBuf0[]
extern

Definition at line 5 of file heaps3.c.

◆ gFrameBuf1

u16 gFrameBuf1[]
extern

Definition at line 6 of file heaps3.c.

◆ gFrameBuf2

u16 gFrameBuf2[]
extern

Definition at line 7 of file heaps3.c.

◆ bFrameBuffers

u16* bFrameBuffers[]
Initial value:
= {
}
u16 gFrameBuf2[]
Definition heaps3.c:7
u16 gFrameBuf1[]
Definition heaps3.c:6
u16 gFrameBuf0[]
Definition heaps3.c:5

Definition at line 14 of file state_battle.c.

Referenced by state_step_battle(), and state_step_end_battle().

◆ D_800778AC

s32 D_800778AC[]
Initial value:
= {
0x00000000, 0xFFFFFF00, 0xFFFFFF00, 0x00000000, 0x00000000
}

Definition at line 18 of file state_battle.c.

18 {
19 0x00000000, 0xFFFFFF00, 0xFFFFFF00, 0x00000000, 0x00000000
20};

◆ D_800A0900

◆ D_800A0904

BSS s32 D_800A0904

Definition at line 23 of file state_battle.c.

Referenced by state_step_battle(), and state_step_end_battle().

◆ D_800A0908

BSS s32 D_800A0908

Definition at line 24 of file state_battle.c.

Referenced by state_step_battle(), and state_step_end_battle().

◆ gMapShapeData

ShapeFile gMapShapeData
extern

Definition at line 16 of file heaps.c.

Referenced by state_step_end_battle().