2021-03-19 11:25:14 +01:00
|
|
|
#include "common.h"
|
|
|
|
|
2021-07-08 17:53:00 +02:00
|
|
|
s32 D_800778A0[] = {
|
|
|
|
&D_8038F800, &D_803B5000, &D_803DA800, 0x00000000, 0xFFFFFF00, 0xFFFFFF00, 0x00000000, 0x00000000, 0x00000000,
|
|
|
|
0x00000000,
|
|
|
|
};
|
|
|
|
|
|
|
|
Gfx D_800778C8[] = {
|
|
|
|
gsDPPipeSync(),
|
|
|
|
gsDPSetCycleType(G_CYC_COPY),
|
|
|
|
gsDPSetTexturePersp(G_TP_NONE),
|
|
|
|
gsDPSetTextureLUT(G_TT_NONE),
|
|
|
|
gsDPSetCombineMode(G_CC_DECALRGB, G_CC_DECALRGB),
|
|
|
|
gsDPSetRenderMode(G_RM_NOOP, G_RM_NOOP2),
|
|
|
|
gsDPSetTextureFilter(G_TF_POINT),
|
|
|
|
gsSPEndDisplayList(),
|
|
|
|
};
|
|
|
|
|
|
|
|
// BSS
|
2021-03-19 11:25:14 +01:00
|
|
|
extern s32 D_800A0904;
|
|
|
|
extern s32 D_800A0908;
|
2020-08-04 08:49:11 +02:00
|
|
|
|
2021-06-30 04:27:12 +02:00
|
|
|
void state_init_battle(void) {
|
2020-08-12 20:48:51 +02:00
|
|
|
D_800A0900 = 5;
|
|
|
|
}
|
2020-08-04 08:49:11 +02:00
|
|
|
|
2021-03-19 11:25:14 +01:00
|
|
|
#ifdef NON_MATCHING
|
2021-06-30 04:27:12 +02:00
|
|
|
void state_step_battle(void) {
|
2021-03-19 11:25:14 +01:00
|
|
|
s32 phi_a0;
|
2021-04-26 19:47:38 +02:00
|
|
|
u32 currentBattleSection;
|
|
|
|
u32 unk_47B;
|
2021-03-19 11:25:14 +01:00
|
|
|
|
2021-04-23 13:55:30 +02:00
|
|
|
if (D_800A0900 == 5) {
|
2021-03-19 11:25:14 +01:00
|
|
|
if (D_8009A658[1] != D_8009A64C) {
|
|
|
|
return;
|
|
|
|
}
|
2021-04-26 19:47:38 +02:00
|
|
|
D_800A0900--;
|
2021-04-23 13:55:30 +02:00
|
|
|
gOverrideFlags |= 0x8;
|
2021-03-19 11:25:14 +01:00
|
|
|
nuContRmbForceStop();
|
|
|
|
}
|
|
|
|
|
2021-04-23 13:55:30 +02:00
|
|
|
if (D_800A0900 >= 0) {
|
|
|
|
if (D_800A0900 > 0) {
|
2021-04-26 19:47:38 +02:00
|
|
|
D_800A0900--;
|
2021-06-30 04:27:12 +02:00
|
|
|
return;
|
2021-03-19 11:25:14 +01:00
|
|
|
} else {
|
2021-04-23 13:55:30 +02:00
|
|
|
D_800A0900 = -1;
|
2021-03-19 11:25:14 +01:00
|
|
|
nuGfxSetCfb(&D_800778A0, 2);
|
|
|
|
nuContRmbForceStopEnd();
|
2021-03-26 15:46:45 +01:00
|
|
|
sfx_stop_env_sounds();
|
2021-03-19 11:25:14 +01:00
|
|
|
func_8003B1A8();
|
2021-03-23 03:25:48 +01:00
|
|
|
gGameStatusPtr->isBattle = TRUE;
|
2021-03-19 11:25:14 +01:00
|
|
|
allocate_hit_tables();
|
|
|
|
func_8002D160();
|
|
|
|
func_802B20B4();
|
2021-06-30 04:27:12 +02:00
|
|
|
sfx_clear_env_sounds(0);
|
2021-03-19 11:25:14 +01:00
|
|
|
|
2021-04-26 19:47:38 +02:00
|
|
|
currentBattleSection = gBattleStatus.currentBattleSection;
|
|
|
|
unk_47B = gBattleStatus.unk_47B;
|
|
|
|
|
2021-03-19 11:25:14 +01:00
|
|
|
// This part sucks
|
2021-06-30 04:27:12 +02:00
|
|
|
if ((gGameStatusPtr->peachFlags & 1) || (currentBattleSection == 0x26 && unk_47B == 0)) {
|
2021-04-26 19:47:38 +02:00
|
|
|
gGameStatusPtr->peachFlags |= 1;
|
2021-06-30 04:27:12 +02:00
|
|
|
spr_init_sprites(6);
|
2021-03-19 11:25:14 +01:00
|
|
|
} else {
|
2021-06-30 04:27:12 +02:00
|
|
|
spr_init_sprites(5);
|
2021-03-19 11:25:14 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
clear_model_data();
|
2021-06-30 04:27:12 +02:00
|
|
|
clear_sprite_shading_data();
|
|
|
|
reset_background_settings();
|
2021-03-19 11:25:14 +01:00
|
|
|
clear_entity_models();
|
2021-06-30 04:27:12 +02:00
|
|
|
clear_animator_list();
|
|
|
|
clear_generic_entity_list();
|
|
|
|
set_hud_element_nonworld_cache(0, 0);
|
|
|
|
clear_hud_element_cache();
|
2021-03-19 11:25:14 +01:00
|
|
|
reset_status_menu();
|
|
|
|
clear_item_entity_data();
|
|
|
|
clear_script_list();
|
2021-06-30 04:27:12 +02:00
|
|
|
clear_npcs();
|
2021-03-19 11:25:14 +01:00
|
|
|
clear_entity_data(1);
|
|
|
|
clear_trigger_data();
|
2021-04-23 13:55:30 +02:00
|
|
|
dma_copy(&_16C8E0_ROM_START, &_16C8E0_ROM_END, &_16C8E0_VRAM);
|
2021-03-19 11:25:14 +01:00
|
|
|
initialize_battle();
|
2021-06-30 04:27:12 +02:00
|
|
|
btl_save_world_cameras();
|
2021-03-19 11:25:14 +01:00
|
|
|
load_battle_section();
|
|
|
|
D_800A0904 = gPlayerStatusPtr->animFlags;
|
|
|
|
gPlayerStatusPtr->animFlags &= ~0x40;
|
2021-04-23 13:55:30 +02:00
|
|
|
D_800A0908 = get_time_freeze_mode();
|
2021-04-22 05:19:31 +02:00
|
|
|
set_time_freeze_mode(0);
|
2021-04-23 13:55:30 +02:00
|
|
|
gOverrideFlags &= ~0x8;
|
2021-03-19 11:25:14 +01:00
|
|
|
|
|
|
|
if (D_800A0900 >= 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-06-30 04:27:12 +02:00
|
|
|
update_encounters();
|
|
|
|
btl_update();
|
|
|
|
update_npcs();
|
2021-03-19 11:25:14 +01:00
|
|
|
update_item_entities();
|
|
|
|
update_effects();
|
|
|
|
func_80116674();
|
|
|
|
update_cameras();
|
|
|
|
}
|
|
|
|
#else
|
2021-07-08 18:50:23 +02:00
|
|
|
INCLUDE_ASM(void, "state_battle", state_step_battle, void);
|
2021-03-19 11:25:14 +01:00
|
|
|
#endif
|
|
|
|
|
2021-06-30 04:27:12 +02:00
|
|
|
void state_drawUI_battle(void) {
|
2021-02-06 16:20:35 +01:00
|
|
|
draw_encounter_ui();
|
2020-08-15 09:01:33 +02:00
|
|
|
if (D_800A0900 < 0) {
|
2021-06-30 04:27:12 +02:00
|
|
|
btl_draw_ui();
|
2020-08-15 09:01:33 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-06-30 04:27:12 +02:00
|
|
|
void state_init_end_battle(void) {
|
2021-04-23 13:55:30 +02:00
|
|
|
gOverrideFlags |= 0x8;
|
2020-08-15 09:01:33 +02:00
|
|
|
nuContRmbForceStop();
|
|
|
|
D_800A0900 = 5;
|
|
|
|
}
|
|
|
|
|
2021-07-08 18:50:23 +02:00
|
|
|
INCLUDE_ASM(void, "state_battle", state_step_end_battle, void);
|
2020-08-15 09:01:33 +02:00
|
|
|
|
2021-06-30 04:27:12 +02:00
|
|
|
void state_drawUI_end_battle(void) {
|
2020-08-18 18:43:55 +02:00
|
|
|
}
|