Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
state_battle.c
Go to the documentation of this file.
1#include "common.h"
2#include "nu/nusys.h"
3#include "hud_element.h"
4#include "ld_addrs.h"
5#include "sprite.h"
6#include "battle/battle.h"
7#include "model.h"
8#include "game_modes.h"
9
10extern u16 gFrameBuf0[];
11extern u16 gFrameBuf1[];
12extern u16 gFrameBuf2[];
13
17
18s32 D_800778AC[] = {
19 0x00000000, 0xFFFFFF00, 0xFFFFFF00, 0x00000000, 0x00000000
20};
21
25
26#if defined(SHIFT) || VERSION_IQUE
27#define shim_battle_heap_create_obfuscated battle_heap_create
28#endif
29
31
33 D_800A0900 = 5;
34}
35
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}
117
120 if (D_800A0900 < 0) {
121 btl_draw_ui();
122 }
123}
124
127 nuContRmbForceStop();
128 D_800A0900 = 5;
129}
130
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}
208
210}
u16 * nuGfxCfb_ptr
Definition cam_main.c:14
@ PEACH_FLAG_IS_PEACH
Definition enums.h:2488
@ DEMO_BTL_FLAG_ENABLED
Definition enums.h:3543
@ TIME_FREEZE_NONE
Definition enums.h:3464
@ CONTEXT_BATTLE
Definition enums.h:3530
@ CONTEXT_WORLD
Definition enums.h:3529
@ 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 init_item_entity_list(void)
void func_8005AF84(void)
Definition collision.c:105
void load_battle_section(void)
Definition battle.c:111
void init_entity_models(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 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
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 get_asset_offset(char *, s32 *)
Definition world.c:273
void initialize_collision(void)
Definition collision.c:111
void load_obfuscation_shims(void)
void update_cameras(void)
Definition cam_main.c:19
void btl_draw_ui(void)
Definition 16C8E0.c:486
void clear_worker_list(void)
Definition worker.c:10
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)
void shim_battle_heap_create_obfuscated(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)
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
s32 battle_heap_create(void)
Definition heap.c:22
void restore_map_collision_data(void)
Definition collision.c:135
void clear_entity_models(void)
void reset_background_settings(void)
Definition background.c:33
void initialize_battle(void)
Definition 16C8E0.c:160
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 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 draw_encounter_ui(void)
Definition npc.c:2294
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 BSS
Definition macros.h:7
#define UNPACK_BTL_INDEX(battleID)
Definition macros.h:149
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
void spr_init_sprites(s32 playerSpriteSet)
Definition sprite.c:764
@ BTL_AREA_KKJ
Definition battle.h:49
void state_step_end_battle(void)
BSS s8 D_800A0900
s32 D_800778AC[]
void state_init_battle(void)
u16 gFrameBuf2[]
Definition heaps3.c:7
void state_drawUI_end_battle(void)
u16 gFrameBuf1[]
Definition heaps3.c:6
ShapeFile gMapShapeData
Definition heaps.c:16
u16 * bFrameBuffers[]
void state_drawUI_battle(void)
BSS s32 D_800A0904
void state_init_end_battle(void)
u16 gFrameBuf0[]
Definition heaps3.c:5
BSS s32 D_800A0908
void state_step_battle(void)
s32 gCurrentBattleID
Definition battle.c:16
s32 gOverrideFlags
Definition main_loop.c:11
PlayerStatus * gPlayerStatusPtr
GameStatus * gGameStatusPtr
Definition main_loop.c:32
PlayerData gPlayerData
Definition 77480.c:40
PlayerStatus gPlayerStatus
Definition 77480.c:39