From 845307b3a6f5d1cb65669e8a971bee22ae6419d0 Mon Sep 17 00:00:00 2001 From: Phlosioneer Date: Mon, 1 Apr 2019 22:09:14 -0400 Subject: [PATCH 01/22] Rename contest AI stuff --- data/contest_ai_scripts.s | 67 ++-- include/contest.h | 10 +- src/contest.c | 2 +- src/contest_ai.c | 583 ++++++++++++++++++----------------- src/data/contest_opponents.h | 192 ++++++------ 5 files changed, 429 insertions(+), 425 deletions(-) diff --git a/data/contest_ai_scripts.s b/data/contest_ai_scripts.s index 6eb254dae..7346876d7 100644 --- a/data/contest_ai_scripts.s +++ b/data/contest_ai_scripts.s @@ -11,39 +11,40 @@ enum MON_4 .align 2 -gContestAIs:: @ 82DE350 - .4byte AI_CheckForBadMove - .4byte AI_CheckForCombo - .4byte AI_CheckBoring - .4byte AI_CheckExcitement - .4byte AI_CheckOrder - .4byte AI_CheckForGoodMove - .4byte AI_Erratic - .4byte AI_Nothing - .4byte AI_Nothing - .4byte AI_Nothing - .4byte AI_Nothing - .4byte AI_Nothing - .4byte AI_Nothing - .4byte AI_Nothing - .4byte AI_Nothing - .4byte AI_Nothing - .4byte AI_Nothing - .4byte AI_Nothing - .4byte AI_Nothing - .4byte AI_Nothing - .4byte AI_Nothing - .4byte AI_Nothing - .4byte AI_Nothing - .4byte AI_Nothing - .4byte AI_Nothing - .4byte AI_Nothing - .4byte AI_Nothing - .4byte AI_Nothing - .4byte AI_Nothing - .4byte AI_Nothing - .4byte AI_Nothing - .4byte AI_Nothing +gContestAIChecks:: @ 82DE350 + .4byte AI_CheckForBadMove // 0x00000001 + .4byte AI_CheckForCombo // 0x00000002 + .4byte AI_CheckBoring // 0x00000004 + .4byte AI_CheckExcitement // 0x00000008 + .4byte AI_CheckOrder // 0x00000010 + .4byte AI_CheckForGoodMove // 0x00000020 + .4byte AI_Erratic // 0x00000040 + .4byte AI_Nothing // 0x00000080 + .4byte AI_Nothing // 0x00000100 + .4byte AI_Nothing // 0x00000200 + .4byte AI_Nothing // 0x00000400 + .4byte AI_Nothing // 0x00000800 + .4byte AI_Nothing // 0x00001000 + .4byte AI_Nothing // 0x00002000 + .4byte AI_Nothing // 0x00004000 + .4byte AI_Nothing // 0x00008000 + .4byte AI_Nothing // 0x00010000 + .4byte AI_Nothing // 0x00020000 + .4byte AI_Nothing // 0x00040000 + .4byte AI_Nothing // 0x00080000 + .4byte AI_Nothing // 0x00100000 + .4byte AI_Nothing // 0x00200000 + .4byte AI_Nothing // 0x00400000 + .4byte AI_Nothing // 0x00800000 + .4byte AI_Nothing // 0x01000000 + .4byte AI_Nothing // 0x02000000 + .4byte AI_Nothing // 0x04000000 + .4byte AI_Nothing // 0x08000000 + .4byte AI_Nothing // 0x10000000 + .4byte AI_Nothing // 0x20000000 + .4byte AI_Nothing // 0x40000000 + .4byte AI_Nothing // 0x80000000 + @ Unreferenced AI routine to encourage moves that improve condition on the first @ turn. Additionally, it checks the appeal order of the user and the effect diff --git a/include/contest.h b/include/contest.h index a0b1a6b34..5178d657b 100644 --- a/include/contest.h +++ b/include/contest.h @@ -216,7 +216,7 @@ struct ContestPokemon /*0x02*/ u8 nickname[POKEMON_NAME_LENGTH + 1]; /*0x0D*/ u8 trainerName[PLAYER_NAME_LENGTH + 1]; /*0x15*/ u8 trainerGfxId; - /*0x18*/ u32 flags; + /*0x18*/ u32 aiChecks; /*0x1C*/ u8 whichRank:2; // 0x1 0x2 u8 aiPool_Cool:1; // 0x4 u8 aiPool_Beauty:1; // 0x8 @@ -352,13 +352,13 @@ struct UnknownContestStruct7 struct ContestAIInfo { /*0x00*/ u8 aiState; - /*0x02*/ u16 unk2; - /*0x04*/ u8 unk4; + /*0x02*/ u16 nextMove; + /*0x04*/ u8 nextMoveIndex; /*0x05*/ u8 unk5[4]; /*0x09*/ u8 aiAction; /*0x0A*/ u8 fillerA[0x6]; // TODO: don't know what's here - /*0x10*/ u8 unk10; - /*0x14*/ u32 flags; + /*0x10*/ u8 currentAICheck; + /*0x14*/ u32 aiChecks; /*0x18*/ s16 scriptResult; /*0x1A*/ s16 scriptArr[3]; /*0x20*/ const u8 *stack[8]; diff --git a/src/contest.c b/src/contest.c index 0591668ff..6f4bb32be 100644 --- a/src/contest.c +++ b/src/contest.c @@ -2623,7 +2623,7 @@ void sub_80DA8C8(u8 partyIndex) gContestMons[gContestPlayerMonIndex].trainerGfxId = EVENT_OBJ_GFX_LINK_BRENDAN; else gContestMons[gContestPlayerMonIndex].trainerGfxId = EVENT_OBJ_GFX_LINK_MAY; - gContestMons[gContestPlayerMonIndex].flags = 0; + gContestMons[gContestPlayerMonIndex].aiChecks = 0; gContestMons[gContestPlayerMonIndex].unk2C[0] = 0; gContestMons[gContestPlayerMonIndex].species = GetMonData(&gPlayerParty[partyIndex], MON_DATA_SPECIES); GetMonData(&gPlayerParty[partyIndex], MON_DATA_NICKNAME, name); diff --git a/src/contest_ai.c b/src/contest_ai.c index 97e8c8f29..8c0106280 100644 --- a/src/contest_ai.c +++ b/src/contest_ai.c @@ -6,29 +6,29 @@ #include "contest_effect.h" extern const u8 *gAIScriptPtr; -extern const u8 *gContestAIs[]; +extern const u8 *gContestAIChecks[]; -static void ContestAICmd_unk_00(void); +static void ContestAICmd_score(void); static void ContestAICmd_get_turn(void); -static void ContestAICmd_unk_02(void); -static void ContestAICmd_unk_03(void); -static void ContestAICmd_unk_04(void); -static void ContestAICmd_unk_05(void); +static void ContestAICmd_if_turn_less_than(void); +static void ContestAICmd_if_turn_more_than(void); +static void ContestAICmd_if_turn_eq(void); +static void ContestAICmd_if_turn_not_eq(void); static void ContestAICmd_get_excitement(void); -static void ContestAICmd_unk_07(void); -static void ContestAICmd_unk_08(void); -static void ContestAICmd_unk_09(void); -static void ContestAICmd_unk_0A(void); +static void ContestAICmd_if_excitement_less_than(void); +static void ContestAICmd_if_excitement_more_than(void); +static void ContestAICmd_if_excitement_eq(void); +static void ContestAICmd_if_excitement_not_eq(void); static void ContestAICmd_get_user_order(void); -static void ContestAICmd_unk_0C(void); -static void ContestAICmd_unk_0D(void); -static void ContestAICmd_unk_0E(void); -static void ContestAICmd_unk_0F(void); -static void ContestAICmd_get_user_condition_maybe(void); -static void ContestAICmd_unk_11(void); -static void ContestAICmd_unk_12(void); -static void ContestAICmd_unk_13(void); -static void ContestAICmd_unk_14(void); +static void ContestAICmd_if_user_order_less_than(void); +static void ContestAICmd_if_user_order_more_than(void); +static void ContestAICmd_if_user_order_eq(void); +static void ContestAICmd_if_user_order_not_eq(void); +static void ContestAICmd_get_user_condition(void); +static void ContestAICmd_if_user_condition_less_than(void); +static void ContestAICmd_if_user_condition_more_than(void); +static void ContestAICmd_if_user_condition_eq(void); +static void ContestAICmd_if_user_condition_not_eq(void); static void ContestAICmd_unk_15(void); static void ContestAICmd_unk_16(void); static void ContestAICmd_unk_17(void); @@ -40,21 +40,21 @@ static void ContestAICmd_unk_1C(void); static void ContestAICmd_unk_1D(void); static void ContestAICmd_unk_1E(void); static void ContestAICmd_get_contest_type(void); -static void ContestAICmd_unk_20(void); -static void ContestAICmd_unk_21(void); +static void ContestAICmd_if_contest_type_eq(void); +static void ContestAICmd_if_contest_type_not_eq(void); static void ContestAICmd_get_move_excitement(void); -static void ContestAICmd_unk_23(void); -static void ContestAICmd_unk_24(void); -static void ContestAICmd_unk_25(void); -static void ContestAICmd_unk_26(void); +static void ContestAICmd_if_move_excitement_less_than(void); +static void ContestAICmd_if_move_excitement_greater_than(void); +static void ContestAICmd_if_move_excitement_eq(void); +static void ContestAICmd_if_move_excitement_not_eq(void); static void ContestAICmd_get_move_effect(void); -static void ContestAICmd_unk_28(void); -static void ContestAICmd_unk_29(void); +static void ContestAICmd_if_move_effect_eq(void); +static void ContestAICmd_if_move_effect_not_eq(void); static void ContestAICmd_get_move_effect_type(void); -static void ContestAICmd_unk_2B(void); -static void ContestAICmd_unk_2C(void); -static void ContestAICmd_check_move_has_highest_appeal(void); -static void ContestAICmd_unk_2E(void); +static void ContestAICmd_if_move_effect_type_eq(void); +static void ContestAICmd_if_move_effect_type_not_eq(void); +static void ContestAICmd_check_most_appealing_move(void); +static void ContestAICmd_if_most_appealing_move(void); static void ContestAICmd_unk_2F(void); static void ContestAICmd_unk_30(void); static void ContestAICmd_unk_31(void); @@ -68,35 +68,35 @@ static void ContestAICmd_unk_38(void); static void ContestAICmd_unk_39(void); static void ContestAICmd_unk_3A(void); static void ContestAICmd_get_move_used_count(void); -static void ContestAICmd_unk_3C(void); -static void ContestAICmd_unk_3D(void); -static void ContestAICmd_unk_3E(void); -static void ContestAICmd_unk_3F(void); +static void ContestAICmd_if_most_used_count_less_than(void); +static void ContestAICmd_if_most_used_count_more_than(void); +static void ContestAICmd_if_most_used_count_eq(void); +static void ContestAICmd_if_most_used_count_not_eq(void); static void ContestAICmd_check_combo_starter(void); -static void ContestAICmd_unk_41(void); -static void ContestAICmd_unk_42(void); +static void ContestAICmd_if_combo_starter(void); +static void ContestAICmd_if_not_combo_starter(void); static void ContestAICmd_check_combo_finisher(void); -static void ContestAICmd_unk_44(void); -static void ContestAICmd_unk_45(void); +static void ContestAICmd_if_combo_finisher(void); +static void ContestAICmd_if_not_combo_finisher(void); static void ContestAICmd_check_would_finish_combo(void); -static void ContestAICmd_unk_47(void); -static void ContestAICmd_unk_48(void); +static void ContestAICmd_if_would_finish_combo(void); +static void ContestAICmd_if_would_not_finish_combo(void); static void ContestAICmd_get_condition(void); -static void ContestAICmd_unk_4A(void); -static void ContestAICmd_unk_4B(void); -static void ContestAICmd_unk_4C(void); -static void ContestAICmd_unk_4D(void); +static void ContestAICmd_if_condition_less_than(void); +static void ContestAICmd_if_condition_more_than(void); +static void ContestAICmd_if_condition_eq(void); +static void ContestAICmd_if_condition_not_eq(void); static void ContestAICmd_get_used_combo_starter(void); -static void ContestAICmd_unk_4F(void); -static void ContestAICmd_unk_50(void); -static void ContestAICmd_unk_51(void); -static void ContestAICmd_unk_52(void); +static void ContestAICmd_if_used_combo_starter_less_than(void); +static void ContestAICmd_if_used_combo_starter_more_than(void); +static void ContestAICmd_if_used_combo_starter_eq(void); +static void ContestAICmd_if_used_combo_starter_not_eq(void); static void ContestAICmd_check_can_participate(void); -static void ContestAICmd_unk_54(void); -static void ContestAICmd_unk_55(void); +static void ContestAICmd_if_can_participate(void); +static void ContestAICmd_if_cannot_participate(void); static void ContestAICmd_get_val_812A188(void); static void ContestAICmd_unk_57(void); -static void ContestAICmd_unk_58(void); +static void ContestAICmd_contest_58(void); static void ContestAICmd_unk_59(void); static void ContestAICmd_unk_5A(void); static void ContestAICmd_unk_5B(void); @@ -133,158 +133,158 @@ static void ContestAICmd_unk_79(void); static void ContestAICmd_unk_7A(void); static void ContestAICmd_unk_7B(void); static void ContestAICmd_unk_7C(void); -static void ContestAICmd_unk_7D(void); +static void ContestAICmd_if_random(void); static void ContestAICmd_unk_7E(void); -static void ContestAICmd_unk_7F(void); -static void ContestAICmd_unk_80(void); -static void ContestAICmd_unk_81(void); -static void ContestAICmd_check_for_exciting_move(void); -static void ContestAICmd_unk_83(void); -static void ContestAICmd_unk_84(void); +static void ContestAICmd_jump(void); +static void ContestAICmd_call(void); +static void ContestAICmd_end(void); +static void ContestAICmd_check_user_has_exciting_move(void); +static void ContestAICmd_if_user_has_exciting_move(void); +static void ContestAICmd_if_user_doesnt_have_exciting_move(void); static void ContestAICmd_unk_85(void); static void ContestAICmd_unk_86(void); -static void ContestAICmd_unk_87(void); +static void ContestAICmd_if_effect_in_user_moveset(void); typedef void (* ContestAICmdFunc)(void); static const ContestAICmdFunc sContestAICmdTable[] = { - ContestAICmd_unk_00, // 0x00 - ContestAICmd_get_turn, // 0x01 - ContestAICmd_unk_02, // 0x02 - ContestAICmd_unk_03, // 0x03 - ContestAICmd_unk_04, // 0x04 - ContestAICmd_unk_05, // 0x05 - ContestAICmd_get_excitement, // 0x06 - ContestAICmd_unk_07, // 0x07 - ContestAICmd_unk_08, // 0x08 - ContestAICmd_unk_09, // 0x09 - ContestAICmd_unk_0A, // 0x0A - ContestAICmd_get_user_order, // 0x0B - ContestAICmd_unk_0C, // 0x0C - ContestAICmd_unk_0D, // 0x0D - ContestAICmd_unk_0E, // 0x0E - ContestAICmd_unk_0F, // 0x0F - ContestAICmd_get_user_condition_maybe, // 0x10 - ContestAICmd_unk_11, // 0x11 - ContestAICmd_unk_12, // 0x12 - ContestAICmd_unk_13, // 0x13 - ContestAICmd_unk_14, // 0x14 - ContestAICmd_unk_15, // 0x15 - ContestAICmd_unk_16, // 0x16 - ContestAICmd_unk_17, // 0x17 - ContestAICmd_unk_18, // 0x18 - ContestAICmd_unk_19, // 0x19 - ContestAICmd_unk_1A, // 0x1A - ContestAICmd_unk_1B, // 0x1B - ContestAICmd_unk_1C, // 0x1C - ContestAICmd_unk_1D, // 0x1D - ContestAICmd_unk_1E, // 0x1E - ContestAICmd_get_contest_type, // 0x1F - ContestAICmd_unk_20, // 0x20 - ContestAICmd_unk_21, // 0x21 - ContestAICmd_get_move_excitement, // 0x22 - ContestAICmd_unk_23, // 0x23 - ContestAICmd_unk_24, // 0x24 - ContestAICmd_unk_25, // 0x25 - ContestAICmd_unk_26, // 0x26 - ContestAICmd_get_move_effect, // 0x27 - ContestAICmd_unk_28, // 0x28 - ContestAICmd_unk_29, // 0x29 - ContestAICmd_get_move_effect_type, // 0x2A - ContestAICmd_unk_2B, // 0x2B - ContestAICmd_unk_2C, // 0x2C - ContestAICmd_check_move_has_highest_appeal, // 0x2D - ContestAICmd_unk_2E, // 0x2E - ContestAICmd_unk_2F, // 0x2F - ContestAICmd_unk_30, // 0x30 - ContestAICmd_unk_31, // 0x31 - ContestAICmd_unk_32, // 0x32 - ContestAICmd_unk_33, // 0x33 - ContestAICmd_unk_34, // 0x34 - ContestAICmd_unk_35, // 0x35 - ContestAICmd_unk_36, // 0x36 - ContestAICmd_unk_37, // 0x37 - ContestAICmd_unk_38, // 0x38 - ContestAICmd_unk_39, // 0x39 - ContestAICmd_unk_3A, // 0x3A - ContestAICmd_get_move_used_count, // 0x3B - ContestAICmd_unk_3C, // 0x3C - ContestAICmd_unk_3D, // 0x3D - ContestAICmd_unk_3E, // 0x3E - ContestAICmd_unk_3F, // 0x3F - ContestAICmd_check_combo_starter, // 0x40 - ContestAICmd_unk_41, // 0x41 - ContestAICmd_unk_42, // 0x42 - ContestAICmd_check_combo_finisher, // 0x43 - ContestAICmd_unk_44, // 0x44 - ContestAICmd_unk_45, // 0x45 - ContestAICmd_check_would_finish_combo, // 0x46 - ContestAICmd_unk_47, // 0x47 - ContestAICmd_unk_48, // 0x48 - ContestAICmd_get_condition, // 0x49 - ContestAICmd_unk_4A, // 0x4A - ContestAICmd_unk_4B, // 0x4B - ContestAICmd_unk_4C, // 0x4C - ContestAICmd_unk_4D, // 0x4D - ContestAICmd_get_used_combo_starter, // 0x4E - ContestAICmd_unk_4F, // 0x4F - ContestAICmd_unk_50, // 0x50 - ContestAICmd_unk_51, // 0x51 - ContestAICmd_unk_52, // 0x52 - ContestAICmd_check_can_participate, // 0x53 - ContestAICmd_unk_54, // 0x54 - ContestAICmd_unk_55, // 0x55 - ContestAICmd_get_val_812A188, // 0x56 - ContestAICmd_unk_57, // 0x57 - ContestAICmd_unk_58, // 0x58 - ContestAICmd_unk_59, // 0x59 - ContestAICmd_unk_5A, // 0x5A - ContestAICmd_unk_5B, // 0x5B - ContestAICmd_unk_5C, // 0x5C - ContestAICmd_unk_5D, // 0x5D - ContestAICmd_unk_5E, // 0x5E - ContestAICmd_unk_5F, // 0x5F - ContestAICmd_unk_60, // 0x60 - ContestAICmd_unk_61, // 0x61 - ContestAICmd_unk_62, // 0x62 - ContestAICmd_unk_63, // 0x63 - ContestAICmd_unk_64, // 0x64 - ContestAICmd_unk_65, // 0x65 - ContestAICmd_unk_66, // 0x66 - ContestAICmd_unk_67, // 0x67 - ContestAICmd_unk_68, // 0x68 - ContestAICmd_unk_69, // 0x69 - ContestAICmd_unk_6A, // 0x6A - ContestAICmd_unk_6B, // 0x6B - ContestAICmd_unk_6C, // 0x6C - ContestAICmd_unk_6D, // 0x6D - ContestAICmd_unk_6E, // 0x6E - ContestAICmd_unk_6F, // 0x6F - ContestAICmd_unk_70, // 0x70 - ContestAICmd_unk_71, // 0x71 - ContestAICmd_unk_72, // 0x72 - ContestAICmd_unk_73, // 0x73 - ContestAICmd_unk_74, // 0x74 - ContestAICmd_unk_75, // 0x75 - ContestAICmd_unk_76, // 0x76 - ContestAICmd_unk_77, // 0x77 - ContestAICmd_unk_78, // 0x78 - ContestAICmd_unk_79, // 0x79 - ContestAICmd_unk_7A, // 0x7A - ContestAICmd_unk_7B, // 0x7B - ContestAICmd_unk_7C, // 0x7C - ContestAICmd_unk_7D, // 0x7D - ContestAICmd_unk_7E, // 0x7E - ContestAICmd_unk_7F, // 0x7F - ContestAICmd_unk_80, // 0x80 - ContestAICmd_unk_81, // 0x81 - ContestAICmd_check_for_exciting_move, // 0x82 - ContestAICmd_unk_83, // 0x83 - ContestAICmd_unk_84, // 0x84 - ContestAICmd_unk_85, // 0x85 - ContestAICmd_unk_86, // 0x86 - ContestAICmd_unk_87, // 0x87 + ContestAICmd_score, // 0x00 + ContestAICmd_get_turn, // 0x01 + ContestAICmd_if_turn_less_than, // 0x02 + ContestAICmd_if_turn_more_than, // 0x03 + ContestAICmd_if_turn_eq, // 0x04 + ContestAICmd_if_turn_not_eq, // 0x05 + ContestAICmd_get_excitement, // 0x06 + ContestAICmd_if_excitement_less_than, // 0x07 + ContestAICmd_if_excitement_more_than, // 0x08 + ContestAICmd_if_excitement_eq, // 0x09 + ContestAICmd_if_excitement_not_eq, // 0x0A + ContestAICmd_get_user_order, // 0x0B + ContestAICmd_if_user_order_less_than, // 0x0C + ContestAICmd_if_user_order_more_than, // 0x0D + ContestAICmd_if_user_order_eq, // 0x0E + ContestAICmd_if_user_order_not_eq, // 0x0F + ContestAICmd_get_user_condition, // 0x10 + ContestAICmd_if_user_condition_less_than, // 0x11 + ContestAICmd_if_user_condition_more_than, // 0x12 + ContestAICmd_if_user_condition_eq, // 0x13 + ContestAICmd_if_user_condition_not_eq, // 0x14 + ContestAICmd_unk_15, // 0x15 + ContestAICmd_unk_16, // 0x16 + ContestAICmd_unk_17, // 0x17 + ContestAICmd_unk_18, // 0x18 + ContestAICmd_unk_19, // 0x19 + ContestAICmd_unk_1A, // 0x1A + ContestAICmd_unk_1B, // 0x1B + ContestAICmd_unk_1C, // 0x1C + ContestAICmd_unk_1D, // 0x1D + ContestAICmd_unk_1E, // 0x1E + ContestAICmd_get_contest_type, // 0x1F + ContestAICmd_if_contest_type_eq, // 0x20 + ContestAICmd_if_contest_type_not_eq, // 0x21 + ContestAICmd_get_move_excitement, // 0x22 + ContestAICmd_if_move_excitement_less_than, // 0x23 + ContestAICmd_if_move_excitement_greater_than, // 0x24 + ContestAICmd_if_move_excitement_eq, // 0x25 + ContestAICmd_if_move_excitement_not_eq, // 0x26 + ContestAICmd_get_move_effect, // 0x27 + ContestAICmd_if_move_effect_eq, // 0x28 + ContestAICmd_if_move_effect_not_eq, // 0x29 + ContestAICmd_get_move_effect_type, // 0x2A + ContestAICmd_if_move_effect_type_eq, // 0x2B + ContestAICmd_if_move_effect_type_not_eq, // 0x2C + ContestAICmd_check_most_appealing_move, // 0x2D + ContestAICmd_if_most_appealing_move, // 0x2E + ContestAICmd_unk_2F, // 0x2F + ContestAICmd_unk_30, // 0x30 + ContestAICmd_unk_31, // 0x31 + ContestAICmd_unk_32, // 0x32 + ContestAICmd_unk_33, // 0x33 + ContestAICmd_unk_34, // 0x34 + ContestAICmd_unk_35, // 0x35 + ContestAICmd_unk_36, // 0x36 + ContestAICmd_unk_37, // 0x37 + ContestAICmd_unk_38, // 0x38 + ContestAICmd_unk_39, // 0x39 + ContestAICmd_unk_3A, // 0x3A + ContestAICmd_get_move_used_count, // 0x3B + ContestAICmd_if_most_used_count_less_than, // 0x3C + ContestAICmd_if_most_used_count_more_than, // 0x3D + ContestAICmd_if_most_used_count_eq, // 0x3E + ContestAICmd_if_most_used_count_not_eq, // 0x3F + ContestAICmd_check_combo_starter, // 0x40 + ContestAICmd_if_combo_starter, // 0x41 + ContestAICmd_if_not_combo_starter, // 0x42 + ContestAICmd_check_combo_finisher, // 0x43 + ContestAICmd_if_combo_finisher, // 0x44 + ContestAICmd_if_not_combo_finisher, // 0x45 + ContestAICmd_check_would_finish_combo, // 0x46 + ContestAICmd_if_would_finish_combo, // 0x47 + ContestAICmd_if_would_not_finish_combo, // 0x48 + ContestAICmd_get_condition, // 0x49 + ContestAICmd_if_condition_less_than, // 0x4A + ContestAICmd_if_condition_more_than, // 0x4B + ContestAICmd_if_condition_eq, // 0x4C + ContestAICmd_if_condition_not_eq, // 0x4D + ContestAICmd_get_used_combo_starter, // 0x4E + ContestAICmd_if_used_combo_starter_less_than, // 0x4F + ContestAICmd_if_used_combo_starter_more_than, // 0x50 + ContestAICmd_if_used_combo_starter_eq, // 0x51 + ContestAICmd_if_used_combo_starter_not_eq, // 0x52 + ContestAICmd_check_can_participate, // 0x53 + ContestAICmd_if_can_participate, // 0x54 + ContestAICmd_if_cannot_participate, // 0x55 + ContestAICmd_get_val_812A188, // 0x56 + ContestAICmd_unk_57, // 0x57 + ContestAICmd_contest_58, // 0x58 + ContestAICmd_unk_59, // 0x59 + ContestAICmd_unk_5A, // 0x5A + ContestAICmd_unk_5B, // 0x5B + ContestAICmd_unk_5C, // 0x5C + ContestAICmd_unk_5D, // 0x5D + ContestAICmd_unk_5E, // 0x5E + ContestAICmd_unk_5F, // 0x5F + ContestAICmd_unk_60, // 0x60 + ContestAICmd_unk_61, // 0x61 + ContestAICmd_unk_62, // 0x62 + ContestAICmd_unk_63, // 0x63 + ContestAICmd_unk_64, // 0x64 + ContestAICmd_unk_65, // 0x65 + ContestAICmd_unk_66, // 0x66 + ContestAICmd_unk_67, // 0x67 + ContestAICmd_unk_68, // 0x68 + ContestAICmd_unk_69, // 0x69 + ContestAICmd_unk_6A, // 0x6A + ContestAICmd_unk_6B, // 0x6B + ContestAICmd_unk_6C, // 0x6C + ContestAICmd_unk_6D, // 0x6D + ContestAICmd_unk_6E, // 0x6E + ContestAICmd_unk_6F, // 0x6F + ContestAICmd_unk_70, // 0x70 + ContestAICmd_unk_71, // 0x71 + ContestAICmd_unk_72, // 0x72 + ContestAICmd_unk_73, // 0x73 + ContestAICmd_unk_74, // 0x74 + ContestAICmd_unk_75, // 0x75 + ContestAICmd_unk_76, // 0x76 + ContestAICmd_unk_77, // 0x77 + ContestAICmd_unk_78, // 0x78 + ContestAICmd_unk_79, // 0x79 + ContestAICmd_unk_7A, // 0x7A + ContestAICmd_unk_7B, // 0x7B + ContestAICmd_unk_7C, // 0x7C + ContestAICmd_if_random, // 0x7D + ContestAICmd_unk_7E, // 0x7E + ContestAICmd_jump, // 0x7F + ContestAICmd_call, // 0x80 + ContestAICmd_end, // 0x81 + ContestAICmd_check_user_has_exciting_move, // 0x82 + ContestAICmd_if_user_has_exciting_move, // 0x83 + ContestAICmd_if_user_doesnt_have_exciting_move, // 0x84 + ContestAICmd_unk_85, // 0x85 + ContestAICmd_unk_86, // 0x86 + ContestAICmd_if_effect_in_user_moveset, // 0x87 }; static void ContestAI_DoAIProcessing(void); @@ -302,21 +302,21 @@ void ContestAI_ResetAI(u8 contestantAI) eContestAI->contestantId = contestantAI; eContestAI->stackSize = 0; - eContestAI->flags = gContestMons[eContestAI->contestantId].flags; + eContestAI->aiChecks = gContestMons[eContestAI->contestantId].aiChecks; } u8 ContestAI_GetActionToUse(void) { - while (eContestAI->flags != 0) + while (eContestAI->aiChecks != 0) { - if (eContestAI->flags & 1) + if (eContestAI->aiChecks & 1) { - eContestAI->aiState = 0; + eContestAI->aiState = CONTESTAI_SETTING_UP; ContestAI_DoAIProcessing(); } - eContestAI->flags >>= 1; - eContestAI->unk10++; - eContestAI->unk4 = 0; + eContestAI->aiChecks >>= 1; + eContestAI->currentAICheck++; + eContestAI->nextMoveIndex = 0; } while (1) @@ -343,28 +343,31 @@ static void ContestAI_DoAIProcessing(void) case CONTESTAI_DO_NOT_PROCESS: break; case CONTESTAI_SETTING_UP: - gAIScriptPtr = gContestAIs[eContestAI->unk10]; + gAIScriptPtr = gContestAIChecks[eContestAI->currentAICheck]; - if (gContestMons[eContestAI->contestantId].moves[eContestAI->unk4] == 0) - eContestAI->unk2 = 0; // don't process a move that doesn't exist. + if (gContestMons[eContestAI->contestantId].moves[eContestAI->nextMoveIndex] == 0) + eContestAI->nextMove = 0; // don't process a move that doesn't exist. else - eContestAI->unk2 = gContestMons[eContestAI->contestantId].moves[eContestAI->unk4]; + eContestAI->nextMove = gContestMons[eContestAI->contestantId].moves[eContestAI->nextMoveIndex]; eContestAI->aiState++; break; case CONTESTAI_PROCESSING: - if (eContestAI->unk2 != 0) + if (eContestAI->nextMove != 0) + { sContestAICmdTable[*gAIScriptPtr](); // run the command. + } else { - eContestAI->unk5[eContestAI->unk4] = 0; // don't consider a move that doesn't exist. + eContestAI->unk5[eContestAI->nextMoveIndex] = 0; // don't consider a move that doesn't exist. eContestAI->aiAction |= 1; } if (eContestAI->aiAction & 1) { - eContestAI->unk4++; - if (eContestAI->unk4 < 4) + eContestAI->nextMoveIndex++; + if (eContestAI->nextMoveIndex < 4) eContestAI->aiState = 0; else + // aiState = CONTESTAI_FINISHED eContestAI->aiState++; eContestAI->aiAction &= 0xFE; // TODO: Define action flags } @@ -384,16 +387,16 @@ static u8 sub_81563B0(u8 var) return i; } -static void ContestAICmd_unk_00(void) +static void ContestAICmd_score(void) { - s16 score = eContestAI->unk5[eContestAI->unk4] + (s8)gAIScriptPtr[1]; + s16 score = eContestAI->unk5[eContestAI->nextMoveIndex] + (s8)gAIScriptPtr[1]; if (score > 255) score = 255; else if (score < 0) score = 0; - eContestAI->unk5[eContestAI->unk4] = score; + eContestAI->unk5[eContestAI->nextMoveIndex] = score; gAIScriptPtr += 2; } @@ -404,7 +407,7 @@ static void ContestAICmd_get_turn(void) gAIScriptPtr += 1; } -static void ContestAICmd_unk_02(void) +static void ContestAICmd_if_turn_less_than(void) { ContestAICmd_get_turn(); @@ -414,7 +417,7 @@ static void ContestAICmd_unk_02(void) gAIScriptPtr += 5; } -static void ContestAICmd_unk_03(void) +static void ContestAICmd_if_turn_more_than(void) { ContestAICmd_get_turn(); @@ -424,7 +427,7 @@ static void ContestAICmd_unk_03(void) gAIScriptPtr += 5; } -static void ContestAICmd_unk_04(void) +static void ContestAICmd_if_turn_eq(void) { ContestAICmd_get_turn(); @@ -434,7 +437,7 @@ static void ContestAICmd_unk_04(void) gAIScriptPtr += 5; } -static void ContestAICmd_unk_05(void) +static void ContestAICmd_if_turn_not_eq(void) { ContestAICmd_get_turn(); @@ -450,7 +453,7 @@ static void ContestAICmd_get_excitement(void) gAIScriptPtr += 1; } -static void ContestAICmd_unk_07(void) +static void ContestAICmd_if_excitement_less_than(void) { ContestAICmd_get_excitement(); @@ -460,7 +463,7 @@ static void ContestAICmd_unk_07(void) gAIScriptPtr += 5; } -static void ContestAICmd_unk_08(void) +static void ContestAICmd_if_excitement_more_than(void) { ContestAICmd_get_excitement(); @@ -470,7 +473,7 @@ static void ContestAICmd_unk_08(void) gAIScriptPtr += 5; } -static void ContestAICmd_unk_09(void) +static void ContestAICmd_if_excitement_eq(void) { ContestAICmd_get_excitement(); @@ -480,7 +483,7 @@ static void ContestAICmd_unk_09(void) gAIScriptPtr += 5; } -static void ContestAICmd_unk_0A(void) +static void ContestAICmd_if_excitement_not_eq(void) { ContestAICmd_get_excitement(); @@ -496,7 +499,7 @@ static void ContestAICmd_get_user_order(void) gAIScriptPtr += 1; } -static void ContestAICmd_unk_0C(void) +static void ContestAICmd_if_user_order_less_than(void) { ContestAICmd_get_user_order(); @@ -506,7 +509,7 @@ static void ContestAICmd_unk_0C(void) gAIScriptPtr += 5; } -static void ContestAICmd_unk_0D(void) +static void ContestAICmd_if_user_order_more_than(void) { ContestAICmd_get_user_order(); @@ -516,7 +519,7 @@ static void ContestAICmd_unk_0D(void) gAIScriptPtr += 5; } -static void ContestAICmd_unk_0E(void) +static void ContestAICmd_if_user_order_eq(void) { ContestAICmd_get_user_order(); @@ -526,7 +529,7 @@ static void ContestAICmd_unk_0E(void) gAIScriptPtr += 5; } -static void ContestAICmd_unk_0F(void) +static void ContestAICmd_if_user_order_not_eq(void) { ContestAICmd_get_user_order(); @@ -536,15 +539,15 @@ static void ContestAICmd_unk_0F(void) gAIScriptPtr += 5; } -static void ContestAICmd_get_user_condition_maybe(void) +static void ContestAICmd_get_user_condition(void) { eContestAI->scriptResult = sContestantStatus[eContestAI->contestantId].condition / 10; gAIScriptPtr += 1; } -static void ContestAICmd_unk_11(void) +static void ContestAICmd_if_user_condition_less_than(void) { - ContestAICmd_get_user_condition_maybe(); + ContestAICmd_get_user_condition(); if (eContestAI->scriptResult < gAIScriptPtr[0]) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1); @@ -552,9 +555,9 @@ static void ContestAICmd_unk_11(void) gAIScriptPtr += 5; } -static void ContestAICmd_unk_12(void) +static void ContestAICmd_if_user_condition_more_than(void) { - ContestAICmd_get_user_condition_maybe(); + ContestAICmd_get_user_condition(); if (eContestAI->scriptResult > gAIScriptPtr[0]) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1); @@ -562,9 +565,9 @@ static void ContestAICmd_unk_12(void) gAIScriptPtr += 5; } -static void ContestAICmd_unk_13(void) +static void ContestAICmd_if_user_condition_eq(void) { - ContestAICmd_get_user_condition_maybe(); + ContestAICmd_get_user_condition(); if (eContestAI->scriptResult == gAIScriptPtr[0]) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1); @@ -572,9 +575,9 @@ static void ContestAICmd_unk_13(void) gAIScriptPtr += 5; } -static void ContestAICmd_unk_14(void) +static void ContestAICmd_if_user_condition_not_eq(void) { - ContestAICmd_get_user_condition_maybe(); + ContestAICmd_get_user_condition(); if (eContestAI->scriptResult != gAIScriptPtr[0]) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1); @@ -680,7 +683,7 @@ static void ContestAICmd_get_contest_type(void) gAIScriptPtr += 1; } -static void ContestAICmd_unk_20(void) +static void ContestAICmd_if_contest_type_eq(void) { ContestAICmd_get_contest_type(); @@ -690,7 +693,7 @@ static void ContestAICmd_unk_20(void) gAIScriptPtr += 5; } -static void ContestAICmd_unk_21(void) +static void ContestAICmd_if_contest_type_not_eq(void) { ContestAICmd_get_contest_type(); @@ -702,11 +705,11 @@ static void ContestAICmd_unk_21(void) static void ContestAICmd_get_move_excitement(void) { - eContestAI->scriptResult = Contest_GetMoveExcitement(gContestMons[eContestAI->contestantId].moves[eContestAI->unk4]); + eContestAI->scriptResult = Contest_GetMoveExcitement(gContestMons[eContestAI->contestantId].moves[eContestAI->nextMoveIndex]); gAIScriptPtr += 1; } -static void ContestAICmd_unk_23(void) +static void ContestAICmd_if_move_excitement_less_than(void) { ContestAICmd_get_move_excitement(); @@ -716,7 +719,7 @@ static void ContestAICmd_unk_23(void) gAIScriptPtr += 5; } -static void ContestAICmd_unk_24(void) +static void ContestAICmd_if_move_excitement_greater_than(void) { ContestAICmd_get_move_excitement(); @@ -726,7 +729,7 @@ static void ContestAICmd_unk_24(void) gAIScriptPtr += 5; } -static void ContestAICmd_unk_25(void) +static void ContestAICmd_if_move_excitement_eq(void) { ContestAICmd_get_move_excitement(); @@ -736,7 +739,7 @@ static void ContestAICmd_unk_25(void) gAIScriptPtr += 5; } -static void ContestAICmd_unk_26(void) +static void ContestAICmd_if_move_excitement_not_eq(void) { ContestAICmd_get_move_excitement(); @@ -748,13 +751,13 @@ static void ContestAICmd_unk_26(void) static void ContestAICmd_get_move_effect(void) { - u16 move = gContestMons[eContestAI->contestantId].moves[eContestAI->unk4]; + u16 move = gContestMons[eContestAI->contestantId].moves[eContestAI->nextMoveIndex]; eContestAI->scriptResult = gContestMoves[move].effect; gAIScriptPtr += 1; } -static void ContestAICmd_unk_28(void) +static void ContestAICmd_if_move_effect_eq(void) { ContestAICmd_get_move_effect(); @@ -764,7 +767,7 @@ static void ContestAICmd_unk_28(void) gAIScriptPtr += 5; } -static void ContestAICmd_unk_29(void) +static void ContestAICmd_if_move_effect_not_eq(void) { ContestAICmd_get_move_effect(); @@ -776,13 +779,13 @@ static void ContestAICmd_unk_29(void) static void ContestAICmd_get_move_effect_type(void) { - u16 move = gContestMons[eContestAI->contestantId].moves[eContestAI->unk4]; + u16 move = gContestMons[eContestAI->contestantId].moves[eContestAI->nextMoveIndex]; eContestAI->scriptResult = gContestEffects[gContestMoves[move].effect].effectType; gAIScriptPtr += 1; } -static void ContestAICmd_unk_2B(void) +static void ContestAICmd_if_move_effect_type_eq(void) { ContestAICmd_get_move_effect_type(); @@ -792,7 +795,7 @@ static void ContestAICmd_unk_2B(void) gAIScriptPtr += 5; } -static void ContestAICmd_unk_2C(void) +static void ContestAICmd_if_move_effect_type_not_eq(void) { ContestAICmd_get_move_effect_type(); @@ -802,10 +805,10 @@ static void ContestAICmd_unk_2C(void) gAIScriptPtr += 5; } -static void ContestAICmd_check_move_has_highest_appeal(void) +static void ContestAICmd_check_most_appealing_move(void) { int i; - u16 move = gContestMons[eContestAI->contestantId].moves[eContestAI->unk4]; + u16 move = gContestMons[eContestAI->contestantId].moves[eContestAI->nextMoveIndex]; u8 appeal = gContestEffects[gContestMoves[move].effect].appeal; for (i = 0; i < MAX_MON_MOVES; i++) @@ -823,9 +826,9 @@ static void ContestAICmd_check_move_has_highest_appeal(void) gAIScriptPtr += 1; } -static void ContestAICmd_unk_2E(void) +static void ContestAICmd_if_most_appealing_move(void) { - ContestAICmd_check_move_has_highest_appeal(); + ContestAICmd_check_most_appealing_move(); if (eContestAI->scriptResult != FALSE) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 0); @@ -836,7 +839,7 @@ static void ContestAICmd_unk_2E(void) static void ContestAICmd_unk_2F(void) { int i; - u16 move = gContestMons[eContestAI->contestantId].moves[eContestAI->unk4]; + u16 move = gContestMons[eContestAI->contestantId].moves[eContestAI->nextMoveIndex]; u8 jam = gContestEffects[gContestMoves[move].effect].jam; for (i = 0; i < MAX_MON_MOVES; i++) @@ -866,7 +869,7 @@ static void ContestAICmd_unk_30(void) static void ContestAICmd_unk_31(void) { - u16 move = gContestMons[eContestAI->contestantId].moves[eContestAI->unk4]; + u16 move = gContestMons[eContestAI->contestantId].moves[eContestAI->nextMoveIndex]; eContestAI->scriptResult = gContestEffects[gContestMoves[move].effect].appeal / 10; gAIScriptPtr += 1; @@ -914,7 +917,7 @@ static void ContestAICmd_unk_35(void) static void ContestAICmd_unk_36(void) { - u16 move = gContestMons[eContestAI->contestantId].moves[eContestAI->unk4]; + u16 move = gContestMons[eContestAI->contestantId].moves[eContestAI->nextMoveIndex]; eContestAI->scriptResult = gContestEffects[gContestMoves[move].effect].jam / 10; gAIScriptPtr += 1; @@ -963,7 +966,7 @@ static void ContestAICmd_unk_3A(void) static void ContestAICmd_get_move_used_count(void) { s16 result; - u16 move = gContestMons[eContestAI->contestantId].moves[eContestAI->unk4]; + u16 move = gContestMons[eContestAI->contestantId].moves[eContestAI->nextMoveIndex]; if (move != sContestantStatus[eContestAI->contestantId].prevMove) result = 0; // move is unique and not reused. @@ -974,7 +977,7 @@ static void ContestAICmd_get_move_used_count(void) gAIScriptPtr += 1; } -static void ContestAICmd_unk_3C(void) +static void ContestAICmd_if_most_used_count_less_than(void) { ContestAICmd_get_move_used_count(); @@ -984,7 +987,7 @@ static void ContestAICmd_unk_3C(void) gAIScriptPtr += 5; } -static void ContestAICmd_unk_3D(void) +static void ContestAICmd_if_most_used_count_more_than(void) { ContestAICmd_get_move_used_count(); @@ -994,7 +997,7 @@ static void ContestAICmd_unk_3D(void) gAIScriptPtr += 5; } -static void ContestAICmd_unk_3E(void) +static void ContestAICmd_if_most_used_count_eq(void) { ContestAICmd_get_move_used_count(); @@ -1004,7 +1007,7 @@ static void ContestAICmd_unk_3E(void) gAIScriptPtr += 5; } -static void ContestAICmd_unk_3F(void) +static void ContestAICmd_if_most_used_count_not_eq(void) { ContestAICmd_get_move_used_count(); @@ -1018,7 +1021,7 @@ static void ContestAICmd_check_combo_starter(void) { u8 result = 0; int i; - u16 move = gContestMons[eContestAI->contestantId].moves[eContestAI->unk4]; + u16 move = gContestMons[eContestAI->contestantId].moves[eContestAI->nextMoveIndex]; for (i = 0; i < MAX_MON_MOVES; i++) { @@ -1040,7 +1043,7 @@ static void ContestAICmd_check_combo_starter(void) gAIScriptPtr += 1; } -static void ContestAICmd_unk_41(void) +static void ContestAICmd_if_combo_starter(void) { ContestAICmd_check_combo_starter(); @@ -1050,7 +1053,7 @@ static void ContestAICmd_unk_41(void) gAIScriptPtr += 4; } -static void ContestAICmd_unk_42(void) +static void ContestAICmd_if_not_combo_starter(void) { ContestAICmd_check_combo_starter(); @@ -1064,7 +1067,7 @@ static void ContestAICmd_check_combo_finisher(void) { u8 result = 0; int i; - u16 move = gContestMons[eContestAI->contestantId].moves[eContestAI->unk4]; + u16 move = gContestMons[eContestAI->contestantId].moves[eContestAI->nextMoveIndex]; for (i = 0; i < MAX_MON_MOVES; i++) { @@ -1086,7 +1089,7 @@ static void ContestAICmd_check_combo_finisher(void) gAIScriptPtr += 1; } -static void ContestAICmd_unk_44(void) +static void ContestAICmd_if_combo_finisher(void) { ContestAICmd_check_combo_finisher(); @@ -1096,7 +1099,7 @@ static void ContestAICmd_unk_44(void) gAIScriptPtr += 4; } -static void ContestAICmd_unk_45(void) +static void ContestAICmd_if_not_combo_finisher(void) { ContestAICmd_check_combo_finisher(); @@ -1109,7 +1112,7 @@ static void ContestAICmd_unk_45(void) static void ContestAICmd_check_would_finish_combo(void) { u8 result = 0; - u16 move = gContestMons[eContestAI->contestantId].moves[eContestAI->unk4]; + u16 move = gContestMons[eContestAI->contestantId].moves[eContestAI->nextMoveIndex]; if (sContestantStatus[eContestAI->contestantId].prevMove) result = AreMovesContestCombo(sContestantStatus[eContestAI->contestantId].prevMove, move); @@ -1121,7 +1124,7 @@ static void ContestAICmd_check_would_finish_combo(void) gAIScriptPtr += 1; } -static void ContestAICmd_unk_47(void) +static void ContestAICmd_if_would_finish_combo(void) { ContestAICmd_check_would_finish_combo(); @@ -1131,7 +1134,7 @@ static void ContestAICmd_unk_47(void) gAIScriptPtr += 4; } -static void ContestAICmd_unk_48(void) +static void ContestAICmd_if_would_not_finish_combo(void) { ContestAICmd_check_would_finish_combo(); @@ -1149,7 +1152,7 @@ static void ContestAICmd_get_condition(void) gAIScriptPtr += 2; } -static void ContestAICmd_unk_4A(void) +static void ContestAICmd_if_condition_less_than(void) { ContestAICmd_get_condition(); @@ -1159,7 +1162,7 @@ static void ContestAICmd_unk_4A(void) gAIScriptPtr += 5; } -static void ContestAICmd_unk_4B(void) +static void ContestAICmd_if_condition_more_than(void) { ContestAICmd_get_condition(); @@ -1169,7 +1172,7 @@ static void ContestAICmd_unk_4B(void) gAIScriptPtr += 5; } -static void ContestAICmd_unk_4C(void) +static void ContestAICmd_if_condition_eq(void) { ContestAICmd_get_condition(); @@ -1179,7 +1182,7 @@ static void ContestAICmd_unk_4C(void) gAIScriptPtr += 5; } -static void ContestAICmd_unk_4D(void) +static void ContestAICmd_if_condition_not_eq(void) { ContestAICmd_get_condition(); @@ -1201,7 +1204,7 @@ static void ContestAICmd_get_used_combo_starter(void) gAIScriptPtr += 2; } -static void ContestAICmd_unk_4F(void) +static void ContestAICmd_if_used_combo_starter_less_than(void) { ContestAICmd_get_used_combo_starter(); @@ -1211,7 +1214,7 @@ static void ContestAICmd_unk_4F(void) gAIScriptPtr += 5; } -static void ContestAICmd_unk_50(void) +static void ContestAICmd_if_used_combo_starter_more_than(void) { ContestAICmd_get_used_combo_starter(); @@ -1221,7 +1224,7 @@ static void ContestAICmd_unk_50(void) gAIScriptPtr += 5; } -static void ContestAICmd_unk_51(void) +static void ContestAICmd_if_used_combo_starter_eq(void) { ContestAICmd_get_used_combo_starter(); @@ -1231,7 +1234,7 @@ static void ContestAICmd_unk_51(void) gAIScriptPtr += 5; } -static void ContestAICmd_unk_52(void) +static void ContestAICmd_if_used_combo_starter_not_eq(void) { ContestAICmd_get_used_combo_starter(); @@ -1251,7 +1254,7 @@ static void ContestAICmd_check_can_participate(void) gAIScriptPtr += 2; } -static void ContestAICmd_unk_54(void) +static void ContestAICmd_if_can_participate(void) { ContestAICmd_check_can_participate(); @@ -1261,7 +1264,7 @@ static void ContestAICmd_unk_54(void) gAIScriptPtr += 4; } -static void ContestAICmd_unk_55(void) +static void ContestAICmd_if_cannot_participate(void) { ContestAICmd_check_can_participate(); @@ -1289,7 +1292,7 @@ static void ContestAICmd_unk_57(void) gAIScriptPtr += 4; } -static void ContestAICmd_unk_58(void) +static void ContestAICmd_contest_58(void) { ContestAICmd_get_val_812A188(); @@ -1620,7 +1623,7 @@ static void ContestAICmd_unk_7C(void) gAIScriptPtr += 7; } -static void ContestAICmd_unk_7D(void) +static void ContestAICmd_if_random(void) { if ((Random() & 0xFF) < eContestAI->scriptArr[gAIScriptPtr[1]]) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 2); @@ -1637,18 +1640,18 @@ static void ContestAICmd_unk_7E(void) } // jump -static void ContestAICmd_unk_7F(void) +static void ContestAICmd_jump(void) { gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1); } -static void ContestAICmd_unk_80(void) +static void ContestAICmd_call(void) { AIStackPushVar(gAIScriptPtr + 5); gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1); } -static void ContestAICmd_unk_81(void) +static void ContestAICmd_end(void) { if (!AIStackPop()) eContestAI->aiAction |= 1; @@ -1673,7 +1676,7 @@ static bool8 AIStackPop(void) } } -static void ContestAICmd_check_for_exciting_move(void) +static void ContestAICmd_check_user_has_exciting_move(void) { int result = 0; int i; @@ -1694,9 +1697,9 @@ static void ContestAICmd_check_for_exciting_move(void) gAIScriptPtr += 1; } -static void ContestAICmd_unk_83(void) +static void ContestAICmd_if_user_has_exciting_move(void) { - ContestAICmd_check_for_exciting_move(); + ContestAICmd_check_user_has_exciting_move(); if (eContestAI->scriptResult != 0) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 0); @@ -1704,9 +1707,9 @@ static void ContestAICmd_unk_83(void) gAIScriptPtr += 4; } -static void ContestAICmd_unk_84(void) +static void ContestAICmd_if_user_doesnt_have_exciting_move(void) { - ContestAICmd_check_for_exciting_move(); + ContestAICmd_check_user_has_exciting_move(); if (eContestAI->scriptResult == 0) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 0); @@ -1744,7 +1747,7 @@ static void ContestAICmd_unk_86(void) gAIScriptPtr += 4; } -static void ContestAICmd_unk_87(void) +static void ContestAICmd_if_effect_in_user_moveset(void) { ContestAICmd_unk_85(); diff --git a/src/data/contest_opponents.h b/src/data/contest_opponents.h index ef1fdba9f..010559e3b 100644 --- a/src/data/contest_opponents.h +++ b/src/data/contest_opponents.h @@ -183,7 +183,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("POOCHY"), .trainerName = _("JIMMY"), .trainerGfxId = EVENT_OBJ_GFX_BOY_1, - .flags = 0xC000FFF, + .aiChecks = 0xC000FFF, .whichRank = CONTEST_RANK_NORMAL, .aiPool_Cool = TRUE, .aiPool_Beauty = FALSE, @@ -212,7 +212,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("MUSILLE"), .trainerName = _("EDITH"), .trainerGfxId = EVENT_OBJ_GFX_GIRL_1, - .flags = 0x82000FFF, + .aiChecks = 0x82000FFF, .whichRank = CONTEST_RANK_NORMAL, .aiPool_Cool = FALSE, .aiPool_Beauty = FALSE, @@ -241,7 +241,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("DUSTER"), .trainerName = _("EVAN"), .trainerGfxId = EVENT_OBJ_GFX_LITTLE_BOY, - .flags = 0x21000FFF, + .aiChecks = 0x21000FFF, .whichRank = CONTEST_RANK_NORMAL, .aiPool_Cool = FALSE, .aiPool_Beauty = TRUE, @@ -270,7 +270,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("DOTS"), .trainerName = _("KELSEY"), .trainerGfxId = EVENT_OBJ_GFX_WOMAN_1, - .flags = 0x20800FFF, + .aiChecks = 0x20800FFF, .whichRank = CONTEST_RANK_NORMAL, .aiPool_Cool = FALSE, .aiPool_Beauty = FALSE, @@ -299,7 +299,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("TATAY"), .trainerName = _("MADISON"), .trainerGfxId = EVENT_OBJ_GFX_POKEFAN_F, - .flags = 0x80400FFF, + .aiChecks = 0x80400FFF, .whichRank = CONTEST_RANK_NORMAL, .aiPool_Cool = TRUE, .aiPool_Beauty = FALSE, @@ -328,7 +328,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("NINDA"), .trainerName = _("RAYMOND"), .trainerGfxId = EVENT_OBJ_GFX_BLACK_BELT, - .flags = 0x10200FFF, + .aiChecks = 0x10200FFF, .whichRank = CONTEST_RANK_NORMAL, .aiPool_Cool = FALSE, .aiPool_Beauty = FALSE, @@ -357,7 +357,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("SMISH"), .trainerName = _("GRANT"), .trainerGfxId = EVENT_OBJ_GFX_YOUNGSTER, - .flags = 0x20100FFF, + .aiChecks = 0x20100FFF, .whichRank = CONTEST_RANK_NORMAL, .aiPool_Cool = FALSE, .aiPool_Beauty = FALSE, @@ -386,7 +386,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("SLEAL"), .trainerName = _("PAIGE"), .trainerGfxId = EVENT_OBJ_GFX_WOMAN_4, - .flags = 0x8080FFF, + .aiChecks = 0x8080FFF, .whichRank = CONTEST_RANK_NORMAL, .aiPool_Cool = FALSE, .aiPool_Beauty = TRUE, @@ -415,7 +415,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("SLOKTH"), .trainerName = _("ALEC"), .trainerGfxId = EVENT_OBJ_GFX_CAMPER, - .flags = 0x40040FFF, + .aiChecks = 0x40040FFF, .whichRank = CONTEST_RANK_NORMAL, .aiPool_Cool = FALSE, .aiPool_Beauty = TRUE, @@ -444,7 +444,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("WHIRIS"), .trainerName = _("SYDNEY"), .trainerGfxId = EVENT_OBJ_GFX_LASS, - .flags = 0x80020FFF, + .aiChecks = 0x80020FFF, .whichRank = CONTEST_RANK_NORMAL, .aiPool_Cool = TRUE, .aiPool_Beauty = FALSE, @@ -473,7 +473,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("MAHITA"), .trainerName = _("MORRIS"), .trainerGfxId = EVENT_OBJ_GFX_SCHOOL_KID_M, - .flags = 0x8010FFF, + .aiChecks = 0x8010FFF, .whichRank = CONTEST_RANK_NORMAL, .aiPool_Cool = TRUE, .aiPool_Beauty = FALSE, @@ -502,7 +502,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("RONAR"), .trainerName = _("MARIAH"), .trainerGfxId = EVENT_OBJ_GFX_GIRL_2, - .flags = 0x8008FFF, + .aiChecks = 0x8008FFF, .whichRank = CONTEST_RANK_NORMAL, .aiPool_Cool = TRUE, .aiPool_Beauty = FALSE, @@ -531,7 +531,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("BATRO"), .trainerName = _("RUSSELL"), .trainerGfxId = EVENT_OBJ_GFX_MAN_3, - .flags = 0x90004FFF, + .aiChecks = 0x90004FFF, .whichRank = CONTEST_RANK_NORMAL, .aiPool_Cool = FALSE, .aiPool_Beauty = TRUE, @@ -560,7 +560,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("GULIN"), .trainerName = _("MELANIE"), .trainerGfxId = EVENT_OBJ_GFX_TWIN, - .flags = 0x40002FFF, + .aiChecks = 0x40002FFF, .whichRank = CONTEST_RANK_NORMAL, .aiPool_Cool = FALSE, .aiPool_Beauty = FALSE, @@ -589,7 +589,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("RIKELEC"), .trainerName = _("CHANCE"), .trainerGfxId = EVENT_OBJ_GFX_RICH_BOY, - .flags = 0x80001FFF, + .aiChecks = 0x80001FFF, .whichRank = CONTEST_RANK_NORMAL, .aiPool_Cool = TRUE, .aiPool_Beauty = TRUE, @@ -618,7 +618,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("BULBY"), .trainerName = _("AGATHA"), .trainerGfxId = EVENT_OBJ_GFX_WOMAN_2, - .flags = 0xC000FFF, + .aiChecks = 0xC000FFF, .whichRank = CONTEST_RANK_NORMAL, .aiPool_Cool = FALSE, .aiPool_Beauty = FALSE, @@ -647,7 +647,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("FUTTERBE"), .trainerName = _("BEAU"), .trainerGfxId = EVENT_OBJ_GFX_HEX_MANIAC, - .flags = 0x82000FFF, + .aiChecks = 0x82000FFF, .whichRank = CONTEST_RANK_NORMAL, .aiPool_Cool = FALSE, .aiPool_Beauty = TRUE, @@ -676,7 +676,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("PIDEOT"), .trainerName = _("KAY"), .trainerGfxId = EVENT_OBJ_GFX_WOMAN_5, - .flags = 0x21000FFF, + .aiChecks = 0x21000FFF, .whichRank = CONTEST_RANK_NORMAL, .aiPool_Cool = TRUE, .aiPool_Beauty = TRUE, @@ -705,7 +705,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("DIGLE"), .trainerName = _("CALE"), .trainerGfxId = EVENT_OBJ_GFX_HIKER, - .flags = 0x20800FFF, + .aiChecks = 0x20800FFF, .whichRank = CONTEST_RANK_NORMAL, .aiPool_Cool = FALSE, .aiPool_Beauty = FALSE, @@ -734,7 +734,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("WAGIL"), .trainerName = _("CAITLIN"), .trainerGfxId = EVENT_OBJ_GFX_TUBER_F, - .flags = 0x80400FFF, + .aiChecks = 0x80400FFF, .whichRank = CONTEST_RANK_NORMAL, .aiPool_Cool = FALSE, .aiPool_Beauty = TRUE, @@ -763,7 +763,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("TOTDIL"), .trainerName = _("COLBY"), .trainerGfxId = EVENT_OBJ_GFX_NINJA_BOY, - .flags = 0x10200FFF, + .aiChecks = 0x10200FFF, .whichRank = CONTEST_RANK_NORMAL, .aiPool_Cool = TRUE, .aiPool_Beauty = TRUE, @@ -792,7 +792,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("BALEDY"), .trainerName = _("KYLIE"), .trainerGfxId = EVENT_OBJ_GFX_BEAUTY, - .flags = 0x20100FFF, + .aiChecks = 0x20100FFF, .whichRank = CONTEST_RANK_NORMAL, .aiPool_Cool = TRUE, .aiPool_Beauty = FALSE, @@ -821,7 +821,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("BIRDLY"), .trainerName = _("LIAM"), .trainerGfxId = EVENT_OBJ_GFX_MAN_5, - .flags = 0x8080FFF, + .aiChecks = 0x8080FFF, .whichRank = CONTEST_RANK_NORMAL, .aiPool_Cool = FALSE, .aiPool_Beauty = FALSE, @@ -850,7 +850,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("TARVITAR"), .trainerName = _("MILO"), .trainerGfxId = EVENT_OBJ_GFX_MANIAC, - .flags = 0x40040FFF, + .aiChecks = 0x40040FFF, .whichRank = CONTEST_RANK_NORMAL, .aiPool_Cool = FALSE, .aiPool_Beauty = FALSE, @@ -879,7 +879,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("RELIA"), .trainerName = _("KARINA"), .trainerGfxId = EVENT_OBJ_GFX_PICNICKER, - .flags = 0x24000FFF, + .aiChecks = 0x24000FFF, .whichRank = CONTEST_RANK_SUPER, .aiPool_Cool = FALSE, .aiPool_Beauty = TRUE, @@ -908,7 +908,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("DUODO"), .trainerName = _("BOBBY"), .trainerGfxId = EVENT_OBJ_GFX_RUNNING_TRIATHLETE_M, - .flags = 0x82000FFF, + .aiChecks = 0x82000FFF, .whichRank = CONTEST_RANK_SUPER, .aiPool_Cool = TRUE, .aiPool_Beauty = TRUE, @@ -937,7 +937,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("PINCHIN"), .trainerName = _("CLAIRE"), .trainerGfxId = EVENT_OBJ_GFX_GIRL_1, - .flags = 0x81000FFF, + .aiChecks = 0x81000FFF, .whichRank = CONTEST_RANK_SUPER, .aiPool_Cool = FALSE, .aiPool_Beauty = FALSE, @@ -966,7 +966,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("NACAC"), .trainerName = _("WILLIE"), .trainerGfxId = EVENT_OBJ_GFX_LITTLE_BOY, - .flags = 0x80800FFF, + .aiChecks = 0x80800FFF, .whichRank = CONTEST_RANK_SUPER, .aiPool_Cool = TRUE, .aiPool_Beauty = FALSE, @@ -995,7 +995,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("SHRAND"), .trainerName = _("CASSIDY"), .trainerGfxId = EVENT_OBJ_GFX_POKEFAN_F, - .flags = 0x10400FFF, + .aiChecks = 0x10400FFF, .whichRank = CONTEST_RANK_SUPER, .aiPool_Cool = TRUE, .aiPool_Beauty = FALSE, @@ -1024,7 +1024,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("TOYBAL"), .trainerName = _("MORGAN"), .trainerGfxId = EVENT_OBJ_GFX_BLACK_BELT, - .flags = 0x8200FFF, + .aiChecks = 0x8200FFF, .whichRank = CONTEST_RANK_SUPER, .aiPool_Cool = FALSE, .aiPool_Beauty = TRUE, @@ -1053,7 +1053,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("CHAMCHAM"), .trainerName = _("SUMMER"), .trainerGfxId = EVENT_OBJ_GFX_WOMAN_4, - .flags = 0x10100FFF, + .aiChecks = 0x10100FFF, .whichRank = CONTEST_RANK_SUPER, .aiPool_Cool = TRUE, .aiPool_Beauty = TRUE, @@ -1082,7 +1082,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("SPININ"), .trainerName = _("MILES"), .trainerGfxId = EVENT_OBJ_GFX_CAMPER, - .flags = 0x80080FFF, + .aiChecks = 0x80080FFF, .whichRank = CONTEST_RANK_SUPER, .aiPool_Cool = FALSE, .aiPool_Beauty = FALSE, @@ -1111,7 +1111,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("SWABY"), .trainerName = _("AUDREY"), .trainerGfxId = EVENT_OBJ_GFX_LASS, - .flags = 0xA0040FFF, + .aiChecks = 0xA0040FFF, .whichRank = CONTEST_RANK_SUPER, .aiPool_Cool = FALSE, .aiPool_Beauty = TRUE, @@ -1140,7 +1140,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("POINKER"), .trainerName = _("AVERY"), .trainerGfxId = EVENT_OBJ_GFX_SCHOOL_KID_M, - .flags = 0x80020FFF, + .aiChecks = 0x80020FFF, .whichRank = CONTEST_RANK_SUPER, .aiPool_Cool = FALSE, .aiPool_Beauty = FALSE, @@ -1169,7 +1169,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("KECON"), .trainerName = _("ARIANA"), .trainerGfxId = EVENT_OBJ_GFX_GIRL_2, - .flags = 0x80010FFF, + .aiChecks = 0x80010FFF, .whichRank = CONTEST_RANK_SUPER, .aiPool_Cool = FALSE, .aiPool_Beauty = FALSE, @@ -1198,7 +1198,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("GOLDEN"), .trainerName = _("ASHTON"), .trainerGfxId = EVENT_OBJ_GFX_MAN_3, - .flags = 0x80008FFF, + .aiChecks = 0x80008FFF, .whichRank = CONTEST_RANK_SUPER, .aiPool_Cool = TRUE, .aiPool_Beauty = TRUE, @@ -1227,7 +1227,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("BOBOACH"), .trainerName = _("SANDRA"), .trainerGfxId = EVENT_OBJ_GFX_TWIN, - .flags = 0x80004FFF, + .aiChecks = 0x80004FFF, .whichRank = CONTEST_RANK_SUPER, .aiPool_Cool = FALSE, .aiPool_Beauty = FALSE, @@ -1256,7 +1256,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("CORPY"), .trainerName = _("CARSON"), .trainerGfxId = EVENT_OBJ_GFX_YOUNGSTER, - .flags = 0x8002FFF, + .aiChecks = 0x8002FFF, .whichRank = CONTEST_RANK_SUPER, .aiPool_Cool = TRUE, .aiPool_Beauty = TRUE, @@ -1285,7 +1285,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("TADO"), .trainerName = _("KATRINA"), .trainerGfxId = EVENT_OBJ_GFX_WOMAN_1, - .flags = 0x8001FFF, + .aiChecks = 0x8001FFF, .whichRank = CONTEST_RANK_SUPER, .aiPool_Cool = FALSE, .aiPool_Beauty = TRUE, @@ -1314,7 +1314,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("BROWLO"), .trainerName = _("LUKE"), .trainerGfxId = EVENT_OBJ_GFX_FAT_MAN, - .flags = 0xC000FFF, + .aiChecks = 0xC000FFF, .whichRank = CONTEST_RANK_SUPER, .aiPool_Cool = FALSE, .aiPool_Beauty = FALSE, @@ -1343,7 +1343,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("FETCHIN"), .trainerName = _("RAUL"), .trainerGfxId = EVENT_OBJ_GFX_MAN_5, - .flags = 0x82000FFF, + .aiChecks = 0x82000FFF, .whichRank = CONTEST_RANK_SUPER, .aiPool_Cool = TRUE, .aiPool_Beauty = FALSE, @@ -1372,7 +1372,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("SEELEY"), .trainerName = _("JADA"), .trainerGfxId = EVENT_OBJ_GFX_WOMAN_2, - .flags = 0x21000FFF, + .aiChecks = 0x21000FFF, .whichRank = CONTEST_RANK_SUPER, .aiPool_Cool = FALSE, .aiPool_Beauty = TRUE, @@ -1401,7 +1401,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("DROWZIN"), .trainerName = _("ZEEK"), .trainerGfxId = EVENT_OBJ_GFX_PSYCHIC_M, - .flags = 0x20800FFF, + .aiChecks = 0x20800FFF, .whichRank = CONTEST_RANK_SUPER, .aiPool_Cool = FALSE, .aiPool_Beauty = TRUE, @@ -1430,7 +1430,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("HITEMON"), .trainerName = _("DIEGO"), .trainerGfxId = EVENT_OBJ_GFX_EXPERT_M, - .flags = 0x80400FFF, + .aiChecks = 0x80400FFF, .whichRank = CONTEST_RANK_SUPER, .aiPool_Cool = TRUE, .aiPool_Beauty = FALSE, @@ -1459,7 +1459,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("BLISS"), .trainerName = _("ALIYAH"), .trainerGfxId = EVENT_OBJ_GFX_TEALA, - .flags = 0x10200FFF, + .aiChecks = 0x10200FFF, .whichRank = CONTEST_RANK_SUPER, .aiPool_Cool = FALSE, .aiPool_Beauty = TRUE, @@ -1488,7 +1488,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("KIDLEK"), .trainerName = _("NATALIA"), .trainerGfxId = EVENT_OBJ_GFX_POKEFAN_F, - .flags = 0x20100FFF, + .aiChecks = 0x20100FFF, .whichRank = CONTEST_RANK_SUPER, .aiPool_Cool = TRUE, .aiPool_Beauty = FALSE, @@ -1517,7 +1517,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("SNUBBINS"), .trainerName = _("DEVIN"), .trainerGfxId = EVENT_OBJ_GFX_GENTLEMAN, - .flags = 0x8080FFF, + .aiChecks = 0x8080FFF, .whichRank = CONTEST_RANK_SUPER, .aiPool_Cool = FALSE, .aiPool_Beauty = FALSE, @@ -1546,7 +1546,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("DREAVIS"), .trainerName = _("TYLOR"), .trainerGfxId = EVENT_OBJ_GFX_HEX_MANIAC, - .flags = 0x40040FFF, + .aiChecks = 0x40040FFF, .whichRank = CONTEST_RANK_SUPER, .aiPool_Cool = FALSE, .aiPool_Beauty = TRUE, @@ -1575,7 +1575,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("LAIRN"), .trainerName = _("RONNIE"), .trainerGfxId = EVENT_OBJ_GFX_HIKER, - .flags = 0x84000FFF, + .aiChecks = 0x84000FFF, .whichRank = CONTEST_RANK_HYPER, .aiPool_Cool = FALSE, .aiPool_Beauty = FALSE, @@ -1604,7 +1604,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("SHIFTY"), .trainerName = _("CLAUDIA"), .trainerGfxId = EVENT_OBJ_GFX_GIRL_1, - .flags = 0x82000FFF, + .aiChecks = 0x82000FFF, .whichRank = CONTEST_RANK_HYPER, .aiPool_Cool = TRUE, .aiPool_Beauty = TRUE, @@ -1633,7 +1633,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("NINAS"), .trainerName = _("ELIAS"), .trainerGfxId = EVENT_OBJ_GFX_LITTLE_BOY, - .flags = 0x81000FFF, + .aiChecks = 0x81000FFF, .whichRank = CONTEST_RANK_HYPER, .aiPool_Cool = FALSE, .aiPool_Beauty = FALSE, @@ -1662,7 +1662,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("WELOW"), .trainerName = _("JADE"), .trainerGfxId = EVENT_OBJ_GFX_POKEFAN_F, - .flags = 0x80800FFF, + .aiChecks = 0x80800FFF, .whichRank = CONTEST_RANK_HYPER, .aiPool_Cool = TRUE, .aiPool_Beauty = TRUE, @@ -1691,7 +1691,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("YENA"), .trainerName = _("FRANCIS"), .trainerGfxId = EVENT_OBJ_GFX_BLACK_BELT, - .flags = 0x80400FFF, + .aiChecks = 0x80400FFF, .whichRank = CONTEST_RANK_HYPER, .aiPool_Cool = FALSE, .aiPool_Beauty = FALSE, @@ -1720,7 +1720,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("TIFLY"), .trainerName = _("ALISHA"), .trainerGfxId = EVENT_OBJ_GFX_WOMAN_4, - .flags = 0x80200FFF, + .aiChecks = 0x80200FFF, .whichRank = CONTEST_RANK_HYPER, .aiPool_Cool = FALSE, .aiPool_Beauty = TRUE, @@ -1749,7 +1749,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("KINGSEA"), .trainerName = _("SAUL"), .trainerGfxId = EVENT_OBJ_GFX_CAMPER, - .flags = 0x80100FFF, + .aiChecks = 0x80100FFF, .whichRank = CONTEST_RANK_HYPER, .aiPool_Cool = TRUE, .aiPool_Beauty = FALSE, @@ -1778,7 +1778,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("CASTER"), .trainerName = _("FELICIA"), .trainerGfxId = EVENT_OBJ_GFX_LASS, - .flags = 0x80080FFF, + .aiChecks = 0x80080FFF, .whichRank = CONTEST_RANK_HYPER, .aiPool_Cool = TRUE, .aiPool_Beauty = TRUE, @@ -1807,7 +1807,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("CHOKEM"), .trainerName = _("EMILIO"), .trainerGfxId = EVENT_OBJ_GFX_SCHOOL_KID_M, - .flags = 0x80040FFF, + .aiChecks = 0x80040FFF, .whichRank = CONTEST_RANK_HYPER, .aiPool_Cool = TRUE, .aiPool_Beauty = FALSE, @@ -1836,7 +1836,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("LOMBE"), .trainerName = _("KARLA"), .trainerGfxId = EVENT_OBJ_GFX_GIRL_2, - .flags = 0x80020FFF, + .aiChecks = 0x80020FFF, .whichRank = CONTEST_RANK_HYPER, .aiPool_Cool = FALSE, .aiPool_Beauty = TRUE, @@ -1865,7 +1865,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("VIPES"), .trainerName = _("DARRYL"), .trainerGfxId = EVENT_OBJ_GFX_MAN_3, - .flags = 0x80010FFF, + .aiChecks = 0x80010FFF, .whichRank = CONTEST_RANK_HYPER, .aiPool_Cool = FALSE, .aiPool_Beauty = FALSE, @@ -1894,7 +1894,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("MERAIL"), .trainerName = _("SELENA"), .trainerGfxId = EVENT_OBJ_GFX_EXPERT_F, - .flags = 0x80008FFF, + .aiChecks = 0x80008FFF, .whichRank = CONTEST_RANK_HYPER, .aiPool_Cool = FALSE, .aiPool_Beauty = TRUE, @@ -1923,7 +1923,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("KARPAG"), .trainerName = _("NOEL"), .trainerGfxId = EVENT_OBJ_GFX_YOUNGSTER, - .flags = 0x80004FFF, + .aiChecks = 0x80004FFF, .whichRank = CONTEST_RANK_HYPER, .aiPool_Cool = FALSE, .aiPool_Beauty = FALSE, @@ -1952,7 +1952,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("LUNONE"), .trainerName = _("LACEY"), .trainerGfxId = EVENT_OBJ_GFX_WOMAN_1, - .flags = 0x80002FFF, + .aiChecks = 0x80002FFF, .whichRank = CONTEST_RANK_HYPER, .aiPool_Cool = FALSE, .aiPool_Beauty = TRUE, @@ -1981,7 +1981,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("ABSO"), .trainerName = _("CORBIN"), .trainerGfxId = EVENT_OBJ_GFX_MANIAC, - .flags = 0x80001FFF, + .aiChecks = 0x80001FFF, .whichRank = CONTEST_RANK_HYPER, .aiPool_Cool = TRUE, .aiPool_Beauty = TRUE, @@ -2010,7 +2010,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("EGGSOR"), .trainerName = _("GRACIE"), .trainerGfxId = EVENT_OBJ_GFX_PICNICKER, - .flags = 0xC000FFF, + .aiChecks = 0xC000FFF, .whichRank = CONTEST_RANK_HYPER, .aiPool_Cool = FALSE, .aiPool_Beauty = FALSE, @@ -2039,7 +2039,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("CUBIN"), .trainerName = _("COLTIN"), .trainerGfxId = EVENT_OBJ_GFX_MAN_4, - .flags = 0x82000FFF, + .aiChecks = 0x82000FFF, .whichRank = CONTEST_RANK_HYPER, .aiPool_Cool = FALSE, .aiPool_Beauty = FALSE, @@ -2068,7 +2068,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("HITMON"), .trainerName = _("ELLIE"), .trainerGfxId = EVENT_OBJ_GFX_EXPERT_F, - .flags = 0x21000FFF, + .aiChecks = 0x21000FFF, .whichRank = CONTEST_RANK_HYPER, .aiPool_Cool = TRUE, .aiPool_Beauty = FALSE, @@ -2097,7 +2097,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("SURTLE"), .trainerName = _("MARCUS"), .trainerGfxId = EVENT_OBJ_GFX_SAILOR, - .flags = 0x20800FFF, + .aiChecks = 0x20800FFF, .whichRank = CONTEST_RANK_HYPER, .aiPool_Cool = FALSE, .aiPool_Beauty = FALSE, @@ -2126,7 +2126,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("KHANKAN"), .trainerName = _("KIARA"), .trainerGfxId = EVENT_OBJ_GFX_GIRL_3, - .flags = 0x80400FFF, + .aiChecks = 0x80400FFF, .whichRank = CONTEST_RANK_HYPER, .aiPool_Cool = TRUE, .aiPool_Beauty = FALSE, @@ -2155,7 +2155,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("PINOC"), .trainerName = _("BRYCE"), .trainerGfxId = EVENT_OBJ_GFX_BUG_CATCHER, - .flags = 0x10200FFF, + .aiChecks = 0x10200FFF, .whichRank = CONTEST_RANK_HYPER, .aiPool_Cool = FALSE, .aiPool_Beauty = TRUE, @@ -2184,7 +2184,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("DILTOT"), .trainerName = _("JAMIE"), .trainerGfxId = EVENT_OBJ_GFX_WOMAN_5, - .flags = 0x20100FFF, + .aiChecks = 0x20100FFF, .whichRank = CONTEST_RANK_HYPER, .aiPool_Cool = FALSE, .aiPool_Beauty = FALSE, @@ -2213,7 +2213,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("DOOMOND"), .trainerName = _("JORGE"), .trainerGfxId = EVENT_OBJ_GFX_GENTLEMAN, - .flags = 0x8080FFF, + .aiChecks = 0x8080FFF, .whichRank = CONTEST_RANK_HYPER, .aiPool_Cool = TRUE, .aiPool_Beauty = TRUE, @@ -2242,7 +2242,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("MILKAN"), .trainerName = _("DEVON"), .trainerGfxId = EVENT_OBJ_GFX_POKEFAN_M, - .flags = 0x40040FFF, + .aiChecks = 0x40040FFF, .whichRank = CONTEST_RANK_HYPER, .aiPool_Cool = FALSE, .aiPool_Beauty = TRUE, @@ -2271,7 +2271,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("RADOS"), .trainerName = _("JUSTINA"), .trainerGfxId = EVENT_OBJ_GFX_PICNICKER, - .flags = 0x84000FFF, + .aiChecks = 0x84000FFF, .whichRank = CONTEST_RANK_MASTER, .aiPool_Cool = TRUE, .aiPool_Beauty = TRUE, @@ -2300,7 +2300,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("LOUDERD"), .trainerName = _("RALPH"), .trainerGfxId = EVENT_OBJ_GFX_EXPERT_M, - .flags = 0x82000FFF, + .aiChecks = 0x82000FFF, .whichRank = CONTEST_RANK_MASTER, .aiPool_Cool = TRUE, .aiPool_Beauty = FALSE, @@ -2329,7 +2329,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("SITTY"), .trainerName = _("ROSA"), .trainerGfxId = EVENT_OBJ_GFX_GIRL_1, - .flags = 0x81000FFF, + .aiChecks = 0x81000FFF, .whichRank = CONTEST_RANK_MASTER, .aiPool_Cool = FALSE, .aiPool_Beauty = TRUE, @@ -2358,7 +2358,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("SLING"), .trainerName = _("KEATON"), .trainerGfxId = EVENT_OBJ_GFX_LITTLE_BOY, - .flags = 0x80800FFF, + .aiChecks = 0x80800FFF, .whichRank = CONTEST_RANK_MASTER, .aiPool_Cool = FALSE, .aiPool_Beauty = FALSE, @@ -2387,7 +2387,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("TARIA"), .trainerName = _("MAYRA"), .trainerGfxId = EVENT_OBJ_GFX_POKEFAN_F, - .flags = 0x80400FFF, + .aiChecks = 0x80400FFF, .whichRank = CONTEST_RANK_MASTER, .aiPool_Cool = TRUE, .aiPool_Beauty = TRUE, @@ -2416,7 +2416,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("LIRKI"), .trainerName = _("LAMAR"), .trainerGfxId = EVENT_OBJ_GFX_RICH_BOY, - .flags = 0x80200FFF, + .aiChecks = 0x80200FFF, .whichRank = CONTEST_RANK_MASTER, .aiPool_Cool = TRUE, .aiPool_Beauty = FALSE, @@ -2445,7 +2445,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("BLOSSOM"), .trainerName = _("AUBREY"), .trainerGfxId = EVENT_OBJ_GFX_WOMAN_4, - .flags = 0x80100FFF, + .aiChecks = 0x80100FFF, .whichRank = CONTEST_RANK_MASTER, .aiPool_Cool = FALSE, .aiPool_Beauty = TRUE, @@ -2474,7 +2474,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("EYESAB"), .trainerName = _("NIGEL"), .trainerGfxId = EVENT_OBJ_GFX_CAMPER, - .flags = 0x80080FFF, + .aiChecks = 0x80080FFF, .whichRank = CONTEST_RANK_MASTER, .aiPool_Cool = FALSE, .aiPool_Beauty = FALSE, @@ -2503,7 +2503,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("UTAN"), .trainerName = _("CAMILLE"), .trainerGfxId = EVENT_OBJ_GFX_LASS, - .flags = 0x80040FFF, + .aiChecks = 0x80040FFF, .whichRank = CONTEST_RANK_MASTER, .aiPool_Cool = FALSE, .aiPool_Beauty = FALSE, @@ -2532,7 +2532,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("PEDOS"), .trainerName = _("DEON"), .trainerGfxId = EVENT_OBJ_GFX_SCHOOL_KID_M, - .flags = 0x80020FFF, + .aiChecks = 0x80020FFF, .whichRank = CONTEST_RANK_MASTER, .aiPool_Cool = TRUE, .aiPool_Beauty = FALSE, @@ -2561,7 +2561,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("LUVIS"), .trainerName = _("JANELLE"), .trainerGfxId = EVENT_OBJ_GFX_GIRL_2, - .flags = 0x80010FFF, + .aiChecks = 0x80010FFF, .whichRank = CONTEST_RANK_MASTER, .aiPool_Cool = FALSE, .aiPool_Beauty = FALSE, @@ -2590,7 +2590,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("HEROSS"), .trainerName = _("HEATH"), .trainerGfxId = EVENT_OBJ_GFX_MAN_3, - .flags = 0x80008FFF, + .aiChecks = 0x80008FFF, .whichRank = CONTEST_RANK_MASTER, .aiPool_Cool = TRUE, .aiPool_Beauty = FALSE, @@ -2619,7 +2619,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("RODLECT"), .trainerName = _("SASHA"), .trainerGfxId = EVENT_OBJ_GFX_TWIN, - .flags = 0x80004FFF, + .aiChecks = 0x80004FFF, .whichRank = CONTEST_RANK_MASTER, .aiPool_Cool = TRUE, .aiPool_Beauty = TRUE, @@ -2648,7 +2648,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("CHUPY"), .trainerName = _("FRANKIE"), .trainerGfxId = EVENT_OBJ_GFX_YOUNGSTER, - .flags = 0x80002FFF, + .aiChecks = 0x80002FFF, .whichRank = CONTEST_RANK_MASTER, .aiPool_Cool = FALSE, .aiPool_Beauty = TRUE, @@ -2677,7 +2677,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("WOBET"), .trainerName = _("HELEN"), .trainerGfxId = EVENT_OBJ_GFX_WOMAN_1, - .flags = 0x80001FFF, + .aiChecks = 0x80001FFF, .whichRank = CONTEST_RANK_MASTER, .aiPool_Cool = TRUE, .aiPool_Beauty = TRUE, @@ -2706,7 +2706,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("GAREN"), .trainerName = _("CAMILE"), .trainerGfxId = EVENT_OBJ_GFX_HEX_MANIAC, - .flags = 0xC000FFF, + .aiChecks = 0xC000FFF, .whichRank = CONTEST_RANK_MASTER, .aiPool_Cool = TRUE, .aiPool_Beauty = FALSE, @@ -2735,7 +2735,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("GONPOR"), .trainerName = _("MARTIN"), .trainerGfxId = EVENT_OBJ_GFX_SCIENTIST_1, - .flags = 0x82000FFF, + .aiChecks = 0x82000FFF, .whichRank = CONTEST_RANK_MASTER, .aiPool_Cool = TRUE, .aiPool_Beauty = TRUE, @@ -2764,7 +2764,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("DRITE"), .trainerName = _("SERGIO"), .trainerGfxId = EVENT_OBJ_GFX_BOY_1, - .flags = 0x21000FFF, + .aiChecks = 0x21000FFF, .whichRank = CONTEST_RANK_MASTER, .aiPool_Cool = TRUE, .aiPool_Beauty = FALSE, @@ -2793,7 +2793,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("MEOWY"), .trainerName = _("KAILEY"), .trainerGfxId = EVENT_OBJ_GFX_TWIN, - .flags = 0x20800FFF, + .aiChecks = 0x20800FFF, .whichRank = CONTEST_RANK_MASTER, .aiPool_Cool = FALSE, .aiPool_Beauty = FALSE, @@ -2822,7 +2822,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("NYX"), .trainerName = _("PERLA"), .trainerGfxId = EVENT_OBJ_GFX_BEAUTY, - .flags = 0x80400FFF, + .aiChecks = 0x80400FFF, .whichRank = CONTEST_RANK_MASTER, .aiPool_Cool = FALSE, .aiPool_Beauty = TRUE, @@ -2851,7 +2851,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("GEPITO"), .trainerName = _("CLARA"), .trainerGfxId = EVENT_OBJ_GFX_WOMAN_2, - .flags = 0x10200FFF, + .aiChecks = 0x10200FFF, .whichRank = CONTEST_RANK_MASTER, .aiPool_Cool = FALSE, .aiPool_Beauty = FALSE, @@ -2880,7 +2880,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("SPEON"), .trainerName = _("JAKOB"), .trainerGfxId = EVENT_OBJ_GFX_PSYCHIC_M, - .flags = 0x20100FFF, + .aiChecks = 0x20100FFF, .whichRank = CONTEST_RANK_MASTER, .aiPool_Cool = TRUE, .aiPool_Beauty = TRUE, @@ -2909,7 +2909,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("SLOWGO"), .trainerName = _("TREY"), .trainerGfxId = EVENT_OBJ_GFX_SAILOR, - .flags = 0x8080FFF, + .aiChecks = 0x8080FFF, .whichRank = CONTEST_RANK_MASTER, .aiPool_Cool = FALSE, .aiPool_Beauty = FALSE, @@ -2938,7 +2938,7 @@ const struct ContestPokemon gContestOpponents[] = .nickname = _("URSING"), .trainerName = _("LANE"), .trainerGfxId = EVENT_OBJ_GFX_BLACK_BELT, - .flags = 0x40040FFF, + .aiChecks = 0x40040FFF, .whichRank = CONTEST_RANK_MASTER, .aiPool_Cool = TRUE, .aiPool_Beauty = FALSE, From c3200c0beb50b17311da7aa4402f6a682af1da01 Mon Sep 17 00:00:00 2001 From: Phlosioneer Date: Tue, 2 Apr 2019 00:35:57 -0400 Subject: [PATCH 02/22] Cleanup some of gContestResources --- include/contest.h | 29 +-- src/contest.c | 605 ++++++++++++++++++++++--------------------- src/contest_ai.c | 398 ++++++++++++++-------------- src/contest_effect.c | 506 ++++++++++++++++++------------------ 4 files changed, 776 insertions(+), 762 deletions(-) diff --git a/include/contest.h b/include/contest.h index 5178d657b..be4bea489 100644 --- a/include/contest.h +++ b/include/contest.h @@ -235,10 +235,8 @@ struct ContestPokemon /*0x3C*/ u32 otId; // otId }; -struct Shared18000 +struct Shared1A004 { - /*0x18000*/ u8 unk18000; - /*0x18001*/ u8 filler18001[3]; /*0x18004*/ u16 unk18004[16][16]; /*0x18204*/ u16 unk18204[0x200]; /*0x18604*/ u16 unk18604[0x200]; @@ -294,11 +292,11 @@ struct ContestantStatus { /*0x00*/ s16 appeal1; // move appeal? /*0x02*/ s16 appeal2; // final appeal after end of turn, maybe? - /*0x04*/ s16 unk4; + /*0x04*/ s16 pointTotal; /*0x06*/ u16 currMove; /*0x08*/ u16 prevMove; /*0x0A*/ u8 moveCategory; - /*0x0B*/ u8 unkB_0:2; + /*0x0B*/ u8 ranking:2; u8 unkB_2:2; u8 moveRepeatCount:3; u8 noMoreTurns:1; // used a one-time move? @@ -408,7 +406,7 @@ struct ContestResourcesField20 struct ContestResources { - struct Contest *field_0; + struct Contest *contest; struct ContestantStatus *field_4; struct UnknownContestStruct7 *field_8; struct ContestAIInfo *field_C; @@ -423,15 +421,16 @@ struct ContestResources void * field_3c; }; -#define sContest (*gContestResources->field_0) -#define sContestantStatus (gContestResources->field_4) -#define shared192D0 (*gContestResources->field_8) -#define eContestAI (gContestResources->field_C) -#define shared19328 (*gContestResources->field_10) -#define shared19338 (*gContestResources->field_14) -#define shared15800 (gHeap + 0x18000) -#define shared16800 (gHeap + 0x19000) -#define shared18000 (*(struct Shared18000 *)(gHeap + 0x1a000)) +#define eContest (*gContestResources->contest) +#define eContestantStatus (gContestResources->field_4) +#define eContestResources8 (*gContestResources->field_8) +#define eContestAI (*gContestResources->field_C) +#define eContestResources10 (*gContestResources->field_10) +#define eContestResources14 (*gContestResources->field_14) +#define eUnknownHeap18000 (gHeap + 0x18000) +#define eUnknownHeap19000 (gHeap + 0x19000) +#define eUnknownHeap1A000 (gHeap[0x1a000]) +#define eUnknownHeap1A004 (*(struct Shared1A004 *)(gHeap + 0x1a004)) extern struct ContestPokemon gContestMons[4]; extern s16 gContestMonConditions[4]; diff --git a/src/contest.c b/src/contest.c index 6f4bb32be..50a98fedc 100644 --- a/src/contest.c +++ b/src/contest.c @@ -901,7 +901,7 @@ void LoadContestBgAfterMoveAnim(void) { u32 var = 5 + i; - LoadPalette(shared18000.unk18004[var], 16 * (5 + gUnknown_02039F26[i]), 16 * sizeof(u16)); + LoadPalette(eUnknownHeap1A004.unk18004[var], 16 * (5 + gUnknown_02039F26[i]), 16 * sizeof(u16)); } } @@ -947,10 +947,10 @@ static void sub_80D787C(void) { s32 i; - *gContestResources->field_0 = (struct Contest){}; + eContest = (struct Contest){}; for (i = 0; i < 4; i++) { - gContestResources->field_0->unk19206[i] = 0xFF; + eContest.unk19206[i] = 0xFF; } for (i = 0; i < 4; i++) { @@ -958,7 +958,7 @@ static void sub_80D787C(void) } for (i = 0; i < 4; i++) { - gContestResources->field_4[i].unkB_0 = 0; + gContestResources->field_4[i].ranking = 0; gContestResources->field_4[i].effectStringId = CONTEST_STRING_NONE; gContestResources->field_4[i].effectStringId2 = CONTEST_STRING_NONE; } @@ -971,7 +971,7 @@ static void sub_80D787C(void) for (i = 0; i < 4; i++) { gContestResources->field_4[i].nextTurnOrder = 0xFF; - gContestResources->field_0->unk19218[i] = gUnknown_02039F26[i]; + eContest.unk19218[i] = gUnknown_02039F26[i]; } sub_80DD590(); memset(gContestResources->field_1c, 0, sizeof(*gContestResources->field_1c) * 4); @@ -980,7 +980,7 @@ static void sub_80D787C(void) static void sub_80D7988(void) { gContestResources = AllocZeroed(sizeof(struct ContestResources)); - gContestResources->field_0 = AllocZeroed(sizeof(struct Contest)); + gContestResources->contest = AllocZeroed(sizeof(struct Contest)); gContestResources->field_4 = AllocZeroed(sizeof(struct ContestantStatus) * 4); gContestResources->field_8 = AllocZeroed(sizeof(struct UnknownContestStruct7)); gContestResources->field_C = AllocZeroed(sizeof(struct ContestAIInfo)); @@ -1002,7 +1002,7 @@ static void sub_80D7988(void) static void sub_80D7A5C(void) { - FREE_AND_SET_NULL(gContestResources->field_0); + FREE_AND_SET_NULL(gContestResources->contest); FREE_AND_SET_NULL(gContestResources->field_4); FREE_AND_SET_NULL(gContestResources->field_8); FREE_AND_SET_NULL(gContestResources->field_C); @@ -1044,8 +1044,7 @@ void sub_80D7B24(void) ResetTasks(); FreeAllSpritePalettes(); gReservedSpritePaletteCount = 4; - //shared18000.unk18000 = 0; - gHeap[0x1a000] = 0; + eUnknownHeap1A000 = 0; ClearBattleMonForms(); sub_80D787C(); gMain.state++; @@ -1054,9 +1053,9 @@ void sub_80D7B24(void) gMain.state++; break; case 2: - if (sub_80D7E44(&gContestResources->field_0->unk1925D)) + if (sub_80D7E44(&eContest.unk1925D)) { - gContestResources->field_0->unk1925D = 0; + eContest.unk1925D = 0; gMain.state++; } break; @@ -1067,7 +1066,7 @@ void sub_80D7B24(void) BeginFastPaletteFade(2); gPaletteFade.bufferTransferDisabled = FALSE; SetVBlankCallback(vblank_cb_battle); - gContestResources->field_0->mainTaskId = CreateTask(sub_80D7C7C, 10); + eContest.mainTaskId = CreateTask(sub_80D7C7C, 10); SetMainCallback2(sub_80D823C); if (gIsLinkContest & 2) { @@ -1148,7 +1147,7 @@ static void sub_80D7DE8(u8 taskId) { GetMultiplayerId(); // unused return value DestroyTask(taskId); - gTasks[gContestResources->field_0->mainTaskId].func = sub_80D80C8; + gTasks[eContest.mainTaskId].func = sub_80D80C8; gRngValue = gContestRngValue; } } @@ -1171,7 +1170,7 @@ static u8 sub_80D7E44(u8 *a) break; case 2: LZDecompressVram(gContestAudienceGfx, (void *)(BG_SCREEN_ADDR(4))); - DmaCopyLarge32(3, (void *)(BG_SCREEN_ADDR(4)), shared15800, 0x2000, 0x1000); + DmaCopyLarge32(3, (void *)(BG_SCREEN_ADDR(4)), eUnknownHeap18000, 0x2000, 0x1000); break; case 3: CopyToBgTilemapBuffer(3, gUnknown_08C16FA8, 0, 0); @@ -1180,7 +1179,7 @@ static u8 sub_80D7E44(u8 *a) case 4: CopyToBgTilemapBuffer(2, gUnknown_08C17170, 0, 0); CopyBgTilemapBufferToVram(2); - DmaCopy32Defvars(3, gContestResources->field_24[2], shared18000.unk18A04, 0x800); + DmaCopy32Defvars(3, gContestResources->field_24[2], eUnknownHeap1A004.unk18A04, 0x800); break; case 5: LoadCompressedPalette(gUnknown_08C16E90, 0, 0x200); @@ -1188,14 +1187,14 @@ static u8 sub_80D7E44(u8 *a) CpuCopy32(gPlttBufferUnfaded + (5 + gContestPlayerMonIndex) * 16, sp20, 16 * sizeof(u16)); CpuCopy32(sp20, gPlttBufferUnfaded + 128, 16 * sizeof(u16)); CpuCopy32(sp0, gPlttBufferUnfaded + (5 + gContestPlayerMonIndex) * 16, 16 * sizeof(u16)); - DmaCopy32Defvars(3, gPlttBufferUnfaded, shared18000.unk18004, 0x200); + DmaCopy32Defvars(3, gPlttBufferUnfaded, eUnknownHeap1A004.unk18004, 0x200); sub_80D782C(); break; case 6: sub_80DD04C(); sub_80DBF90(); sub_80DB2BC(); - gContestResources->field_0->unk19216 = sub_80DB120(); + eContest.unk19216 = sub_80DB120(); sub_80DC2BC(); sub_80DC4F0(); CreateApplauseMeterSprite(); @@ -1273,7 +1272,7 @@ static void sub_80D8108(u8 taskId) } case 4: default: - if (gContestResources->field_0->unk1920A_6) + if (eContest.unk1920A_6) break; gTasks[taskId].data[0] = 0; gTasks[taskId].data[1] = 0; @@ -1326,8 +1325,8 @@ static void sub_80D833C(u8 taskId) gBattle_BG0_Y = 0; gBattle_BG2_Y = 0; sub_80DCD48(); - DmaCopy32Defvars(3, gPlttBufferUnfaded, shared18000.unk18204, 0x400); - ConvertIntToDecimalStringN(gStringVar1, gContestResources->field_0->turnNumber + 1, STR_CONV_MODE_LEFT_ALIGN, 1); + DmaCopy32Defvars(3, gPlttBufferUnfaded, eUnknownHeap1A004.unk18204, 0x400); + ConvertIntToDecimalStringN(gStringVar1, eContest.turnNumber + 1, STR_CONV_MODE_LEFT_ALIGN, 1); if (!Contest_IsMonsTurnDisabled(gContestPlayerMonIndex)) StringCopy(gDisplayedStringBattle, gText_0827D507); else @@ -1397,8 +1396,8 @@ static void sub_80D8490(u8 taskId) Contest_PrintTextToBg0WindowAt(i + 5, sp8, 5, 1, 7); } - sub_80D880C(gContestResources->field_0->playerMoveChoice); - prints_contest_move_description(gContestMons[gContestPlayerMonIndex].moves[gContestResources->field_0->playerMoveChoice]); + sub_80D880C(eContest.playerMoveChoice); + prints_contest_move_description(gContestMons[gContestPlayerMonIndex].moves[eContest.playerMoveChoice]); gTasks[taskId].func = sub_80D8610; } @@ -1425,7 +1424,7 @@ static void sub_80D8610(u8 taskId) case B_BUTTON: PlaySE(SE_SELECT); sub_80DC490(FALSE); - ConvertIntToDecimalStringN(gStringVar1, gContestResources->field_0->turnNumber + 1, STR_CONV_MODE_LEFT_ALIGN, 1); + ConvertIntToDecimalStringN(gStringVar1, eContest.turnNumber + 1, STR_CONV_MODE_LEFT_ALIGN, 1); if (!Contest_IsMonsTurnDisabled(gContestPlayerMonIndex)) StringCopy(gDisplayedStringBattle, gText_0827D507); else @@ -1441,24 +1440,24 @@ static void sub_80D8610(u8 taskId) case DPAD_RIGHT: break; case DPAD_UP: - sub_80D883C(gContestResources->field_0->playerMoveChoice); - if (gContestResources->field_0->playerMoveChoice == 0) - gContestResources->field_0->playerMoveChoice = numMoves - 1; + sub_80D883C(eContest.playerMoveChoice); + if (eContest.playerMoveChoice == 0) + eContest.playerMoveChoice = numMoves - 1; else - gContestResources->field_0->playerMoveChoice--; - sub_80D880C(gContestResources->field_0->playerMoveChoice); - prints_contest_move_description(gContestMons[gContestPlayerMonIndex].moves[gContestResources->field_0->playerMoveChoice]); + eContest.playerMoveChoice--; + sub_80D880C(eContest.playerMoveChoice); + prints_contest_move_description(gContestMons[gContestPlayerMonIndex].moves[eContest.playerMoveChoice]); if (numMoves > 1) PlaySE(SE_SELECT); break; case DPAD_DOWN: - sub_80D883C(gContestResources->field_0->playerMoveChoice); - if (gContestResources->field_0->playerMoveChoice == numMoves - 1) - gContestResources->field_0->playerMoveChoice = 0; + sub_80D883C(eContest.playerMoveChoice); + if (eContest.playerMoveChoice == numMoves - 1) + eContest.playerMoveChoice = 0; else - gContestResources->field_0->playerMoveChoice++; - sub_80D880C(gContestResources->field_0->playerMoveChoice); - prints_contest_move_description(gContestMons[gContestPlayerMonIndex].moves[gContestResources->field_0->playerMoveChoice]); + eContest.playerMoveChoice++; + sub_80D880C(eContest.playerMoveChoice); + prints_contest_move_description(gContestMons[gContestPlayerMonIndex].moves[eContest.playerMoveChoice]); if (numMoves > 1) PlaySE(SE_SELECT); break; @@ -1501,7 +1500,7 @@ static void sub_80D8894(u8 taskId) static void sub_80D892C(u8 taskId) { DestroyTask(taskId); - gTasks[gContestResources->field_0->mainTaskId].func = sub_80D895C; + gTasks[eContest.mainTaskId].func = sub_80D895C; } static void sub_80D895C(u8 taskId) @@ -1521,8 +1520,8 @@ static void sub_80D895C(u8 taskId) } Contest_SetBgCopyFlags(0); - DmaCopy32Defvars(3, gPlttBufferFaded, shared18000.unk18604, 0x400); - LoadPalette(shared18000.unk18204, 0, 0x400); + DmaCopy32Defvars(3, gPlttBufferFaded, eUnknownHeap1A004.unk18604, 0x400); + LoadPalette(eUnknownHeap1A004.unk18204, 0, 0x400); gTasks[taskId].data[0] = 0; gTasks[taskId].data[1] = 0; gTasks[taskId].func = sub_80D8A04; @@ -1544,7 +1543,7 @@ static void sub_80D8A04(u8 taskId) static void sub_80D8A50(u8 taskId) { - if (!gContestResources->field_0->unk1920A_6 && !gContestResources->field_0->unk1920B_1) + if (!eContest.unk1920A_6 && !eContest.unk1920B_1) gTasks[taskId].func = sub_80D8A88; } @@ -1552,8 +1551,8 @@ static void sub_80D8A88(u8 taskId) { if (++gTasks[taskId].data[0] > 19) { - gContestResources->field_0->unk19214 = 0; - gContestResources->field_0->unk1921C = gRngValue; + eContest.unk19214 = 0; + eContest.unk1921C = gRngValue; if ((gIsLinkContest & 1) && sub_80DA8A4()) { s32 i; @@ -1572,24 +1571,24 @@ static void sub_80D8B38(u8 taskId) { u8 spriteId; s32 i; - u8 r6 = gContestResources->field_0->unk19215; + u8 r6 = eContest.unk19215; s8 r3; switch (gTasks[taskId].data[0]) { case 0: sub_80DCD48(); - for (i = 0; gContestResources->field_0->unk19214 != gContestResources->field_8->turnOrder[i]; i++) + for (i = 0; eContest.unk19214 != gContestResources->field_8->turnOrder[i]; i++) ; - gContestResources->field_0->unk19215 = i; - r6 = gContestResources->field_0->unk19215; + eContest.unk19215 = i; + r6 = eContest.unk19215; if (gIsLinkContest & 1) { u8 taskId2; - gContestResources->field_0->unk1920B_2 = 1; + eContest.unk1920B_2 = 1; if (sub_80DA8A4()) - sub_80DD080(gContestResources->field_0->unk19215); + sub_80DD080(eContest.unk19215); taskId2 = CreateTask(sub_80FCC88, 0); SetTaskFuncWithFollowupFunc(taskId2, sub_80FCC88, sub_80DA110); sub_80DBF68(); @@ -1597,12 +1596,12 @@ static void sub_80D8B38(u8 taskId) } else { - sub_80DD080(gContestResources->field_0->unk19215); + sub_80DD080(eContest.unk19215); gTasks[taskId].data[0] = 2; } return; case 1: - if (!gContestResources->field_0->unk1920B_2) + if (!eContest.unk1920B_2) gTasks[taskId].data[0] = 2; return; case 2: @@ -1624,17 +1623,17 @@ static void sub_80D8B38(u8 taskId) for (i = 0; i < 4; i++) gBattleMonForms[i] = 0; memset(gContestResources->field_18, 0, sizeof(*gContestResources->field_18)); - sub_80DE9DC(gContestResources->field_0->unk19215); + sub_80DE9DC(eContest.unk19215); spriteId = sub_80DB174( - gContestMons[gContestResources->field_0->unk19215].species, - gContestMons[gContestResources->field_0->unk19215].otId, - gContestMons[gContestResources->field_0->unk19215].personality, - gContestResources->field_0->unk19215); + gContestMons[eContest.unk19215].species, + gContestMons[eContest.unk19215].otId, + gContestMons[eContest.unk19215].personality, + eContest.unk19215); gSprites[spriteId].pos2.x = 120; gSprites[spriteId].callback = sub_80DA134; gTasks[taskId].data[2] = spriteId; gBattlerSpriteIds[gBattlerAttacker] = spriteId; - sub_80DCBE8(sub_80DC9EC(gContestResources->field_0->unk19215), FALSE); + sub_80DCBE8(sub_80DC9EC(eContest.unk19215), FALSE); gTasks[taskId].data[0] = 4; return; case 4: @@ -1666,16 +1665,16 @@ static void sub_80D8B38(u8 taskId) case 6: if (!Contest_RunTextPrinters()) { - gContestResources->field_0->unk1925E = 0; + eContest.unk1925E = 0; gTasks[taskId].data[0] = 7; } return; case 7: { - u16 move = SanitizeMove(gContestResources->field_4[gContestResources->field_0->unk19215].currMove); + u16 move = SanitizeMove(gContestResources->field_4[eContest.unk19215].currMove); - sub_80DE864(gContestResources->field_0->unk19215); - sub_80DE9DC(gContestResources->field_0->unk19215); + sub_80DE864(eContest.unk19215); + sub_80DE9DC(eContest.unk19215); SelectContestMoveBankTarget(move); DoMoveAnim(move); gTasks[taskId].data[0] = 8; @@ -1686,7 +1685,7 @@ static void sub_80D8B38(u8 taskId) if (!gAnimScriptActive) { sub_80DE9B0(r6); - if (gContestResources->field_0->unk1925E != 0) + if (eContest.unk1925E != 0) { gTasks[taskId].data[10] = 0; gTasks[taskId].data[0] = 9; @@ -1766,7 +1765,7 @@ static void sub_80D8B38(u8 taskId) gTasks[taskId].data[0] = 49; return; case 49: - if (!gContestResources->field_0->unk1920A_4) + if (!eContest.unk1920A_4) gTasks[taskId].data[0] = 47; return; case 47: @@ -1778,7 +1777,7 @@ static void sub_80D8B38(u8 taskId) gTasks[taskId].data[0] = 13; return; case 13: - if (!gContestResources->field_14[gContestResources->field_0->unk19215].unk2_2) + if (!gContestResources->field_14[eContest.unk19215].unk2_2) gTasks[taskId].data[0] = 35; return; case 35: @@ -1787,7 +1786,7 @@ static void sub_80D8B38(u8 taskId) gTasks[taskId].data[0] = 36; return; case 36: - if (!gContestResources->field_0->unk1920A_4) + if (!eContest.unk1920A_4) gTasks[taskId].data[0] = 37; return; case 37: @@ -1958,9 +1957,9 @@ static void sub_80D8B38(u8 taskId) } return; case 45: - if (!gContestResources->field_0->unk1920A_4) + if (!eContest.unk1920A_4) { - sub_80DC9B4(gContestResources->field_0->unk19215); + sub_80DC9B4(eContest.unk19215); gTasks[taskId].data[0] = 15; } return; @@ -2005,7 +2004,7 @@ static void sub_80D8B38(u8 taskId) } return; case 46: - if (!gContestResources->field_0->unk1920A_4) + if (!eContest.unk1920A_4) gTasks[taskId].data[0] = 19; return; case 19: @@ -2049,9 +2048,9 @@ static void sub_80D8B38(u8 taskId) } sub_80DB89C(); StringCopy(gStringVar1, gContestMons[r6].nickname); - gContestResources->field_0->applauseLevel += r3; - if (gContestResources->field_0->applauseLevel < 0) - gContestResources->field_0->applauseLevel = 0; + eContest.applauseLevel += r3; + if (eContest.applauseLevel < 0) + eContest.applauseLevel = 0; if (r3 == 0) { gTasks[taskId].data[0] = 55; @@ -2060,7 +2059,7 @@ static void sub_80D8B38(u8 taskId) { if (r3 < 0) StringExpandPlaceholders(gStringVar4, gText_0827E73C); - else if (r3 > 0 && gContestResources->field_0->applauseLevel <= 4) + else if (r3 > 0 && eContest.applauseLevel <= 4) StringExpandPlaceholders(gStringVar4, gText_0827E717); else StringExpandPlaceholders(gStringVar4, gText_0827E76A); @@ -2083,14 +2082,14 @@ static void sub_80D8B38(u8 taskId) gTasks[taskId].data[10]++; break; case 1: - if (!gContestResources->field_0->unk1920B_0 && !Contest_RunTextPrinters()) + if (!eContest.unk1920B_0 && !Contest_RunTextPrinters()) { sub_80DDCDC(-1); gTasks[taskId].data[10]++; } break; case 2: - if (!gContestResources->field_0->unk1920A_5) + if (!eContest.unk1920A_5) { if (gTasks[taskId].data[11]++ > 29) { @@ -2121,7 +2120,7 @@ static void sub_80D8B38(u8 taskId) } break; case 1: - if (!gContestResources->field_0->unk1920B_0) + if (!eContest.unk1920B_0) { sub_80DDE0C(); PlaySE(SE_W227B); @@ -2130,7 +2129,7 @@ static void sub_80D8B38(u8 taskId) } break; case 2: - if (!gContestResources->field_0->unk1920A_5) + if (!eContest.unk1920A_5) { if (gTasks[taskId].data[11]++ > 29) { @@ -2144,7 +2143,7 @@ static void sub_80D8B38(u8 taskId) case 3: if (!gContestResources->field_14[r6].unk2_2) { - if (!gContestResources->field_0->unk1920A_7) + if (!eContest.unk1920A_7) { sub_80DDED0(1, -1); gTasks[taskId].data[10]++; @@ -2212,11 +2211,11 @@ static void sub_80D8B38(u8 taskId) gTasks[taskId].data[0] = 56; return; case 56: - if (!gContestResources->field_0->unk1920A_6) + if (!eContest.unk1920A_6) { - if (gContestResources->field_0->applauseLevel > 4) + if (eContest.applauseLevel > 4) { - gContestResources->field_0->applauseLevel = 0; + eContest.applauseLevel = 0; sub_80DD940(); } gTasks[taskId].data[0] = 10; @@ -2259,7 +2258,7 @@ static void sub_80D8B38(u8 taskId) } return; case 22: - if (++gContestResources->field_0->unk19214 == 4) + if (++eContest.unk19214 == 4) { gTasks[taskId].data[0] = 0; gTasks[taskId].data[1] = 0; @@ -2276,7 +2275,7 @@ static void sub_80D8B38(u8 taskId) static void sub_80DA110(u8 taskId) { - sContest.unk1920B_2 = 0; + eContest.unk1920B_2 = 0; DestroyTask(taskId); } @@ -2315,7 +2314,7 @@ static void sub_80DA198(u8 taskId) { u8 taskId2; - sContest.unk1920B_2 = 1; + eContest.unk1920B_2 = 1; if (sub_80DA8A4()) { sub_80DB944(); @@ -2334,7 +2333,7 @@ static void sub_80DA198(u8 taskId) } break; case 1: - if (!sContest.unk1920B_2) + if (!eContest.unk1920B_2) gTasks[taskId].data[0] = 2; break; case 2: @@ -2365,7 +2364,7 @@ static void sub_80DA28C(u8 taskId) } break; case 1: - if (!sContest.unk1920B_1) + if (!eContest.unk1920B_1) { if (++gTasks[taskId].data[1] > 20) { @@ -2391,7 +2390,7 @@ static void sub_80DA31C(u8 taskId) static void sub_80DA348(u8 taskId) { - DmaCopy32Defvars(3, shared18000.unk18204, gPlttBufferUnfaded, 0x400); + DmaCopy32Defvars(3, eUnknownHeap1A004.unk18204, gPlttBufferUnfaded, 0x400); gTasks[taskId].data[0] = 0; gTasks[taskId].data[1] = 2; gTasks[taskId].func = sub_80DA38C; @@ -2411,7 +2410,7 @@ static void sub_80DA3CC(u8 taskId) { if (gTasks[taskId].data[0] == 0) { - u8 r4 = sContestantStatus[gContestPlayerMonIndex].attentionLevel; + u8 r4 = eContestantStatus[gContestPlayerMonIndex].attentionLevel; sub_80DB89C(); StringCopy(gStringVar1, gContestMons[gContestPlayerMonIndex].nickname); @@ -2469,8 +2468,8 @@ static void sub_80DA51C(u8 taskId) ((vBgCnt *)&sp2)->priority = 0; SetGpuReg(REG_OFFSET_BG0CNT, sp0); SetGpuReg(REG_OFFSET_BG2CNT, sp2); - sContest.turnNumber++; - if (sContest.turnNumber == 5) + eContest.turnNumber++; + if (eContest.turnNumber == 5) { gTasks[taskId].func = sub_80DA5E8; } @@ -2483,7 +2482,7 @@ static void sub_80DA51C(u8 taskId) static void sub_80DA5B4(u8 taskId) { - if (!sContest.unk1920A_6) + if (!eContest.unk1920A_6) gTasks[taskId].func = sub_80D833C; } @@ -2494,11 +2493,11 @@ static void sub_80DA5E8(u8 taskId) gBattle_BG0_Y = 0; gBattle_BG2_Y = 0; for (i = 0; i < 4; i++) - gUnknown_02039F10[i] = sContestantStatus[i].unk4; + gUnknown_02039F10[i] = eContestantStatus[i].pointTotal; sub_80DBD18(); sub_80DB89C(); if (!(gIsLinkContest & 1)) - BravoTrainerPokemonProfile_BeforeInterview1(sContestantStatus[gContestPlayerMonIndex].prevMove); + BravoTrainerPokemonProfile_BeforeInterview1(eContestantStatus[gContestPlayerMonIndex].prevMove); else { sub_80DF250(); @@ -2568,7 +2567,7 @@ static void sub_80DA7EC(u8 taskId) { DestroyTask(taskId); BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, 0); - gTasks[sContest.mainTaskId].func = sub_80DA830; + gTasks[eContest.mainTaskId].func = sub_80DA830; } static void sub_80DA830(u8 taskId) @@ -3092,17 +3091,17 @@ static bool8 sub_80DB5B8(u8 contestantIdx, bool8 resetMod) u8 r6; s32 r4; - if (sContestantStatus[contestantIdx].conditionMod == 0) + if (eContestantStatus[contestantIdx].conditionMod == 0) return FALSE; r6 = gUnknown_02039F26[contestantIdx] * 5 + 2; - r4 = sContestantStatus[contestantIdx].condition / 10; - if (sContestantStatus[contestantIdx].conditionMod == 1) + r4 = eContestantStatus[contestantIdx].condition / 10; + if (eContestantStatus[contestantIdx].conditionMod == 1) { ContestBG_FillBoxWithTile(0, sub_80DB5B0(), 19, r6, 1, r4, 17); if (resetMod) { PlaySE(SE_EXPMAX); - sContestantStatus[contestantIdx].conditionMod = 0; + eContestantStatus[contestantIdx].conditionMod = 0; } } else @@ -3111,7 +3110,7 @@ static bool8 sub_80DB5B8(u8 contestantIdx, bool8 resetMod) if (resetMod) { PlaySE(SE_FU_ZAKU2); - sContestantStatus[contestantIdx].conditionMod = 0; + eContestantStatus[contestantIdx].conditionMod = 0; } } return TRUE; @@ -3127,7 +3126,7 @@ static void sub_80DB69C(void) u8 r4 = gUnknown_02039F26[i] * 5 + 2; u16 r5 = sub_80DB5B0(); - r6 = sContestantStatus[i].condition / 10; + r6 = eContestantStatus[i].condition / 10; ContestBG_FillBoxWithTile(0, r5, 19, r4, 1, r6, 17); ContestBG_FillBoxWithTile(0, 0, 19, r4 + r6, 1, 3 - r6, 17); } @@ -3165,11 +3164,11 @@ static bool8 sub_80DB798(u8 a) u16 r8 = 0; u8 r7 = gUnknown_02039F26[a] * 5 + 2; - if (sContestantStatus[a].resistant != 0 || sContestantStatus[a].immune != 0 || sContestantStatus[a].jamSafetyCount != 0 || sContestantStatus[a].jamReduction != 0) + if (eContestantStatus[a].resistant != 0 || eContestantStatus[a].immune != 0 || eContestantStatus[a].jamSafetyCount != 0 || eContestantStatus[a].jamReduction != 0) r8 = sub_80DB748(0); - else if (sContestantStatus[a].nervous) + else if (eContestantStatus[a].nervous) r8 = sub_80DB748(1); - else if (sContestantStatus[a].numTurnsSkipped != 0 || sContestantStatus[a].noMoreTurns) + else if (eContestantStatus[a].numTurnsSkipped != 0 || eContestantStatus[a].noMoreTurns) r8 = sub_80DB748(2); else r9 = FALSE; @@ -3206,7 +3205,7 @@ static u16 GetChosenMove(u8 a) return 0; if (a == gContestPlayerMonIndex) { - return gContestMons[a].moves[sContest.playerMoveChoice]; + return gContestMons[a].moves[eContest.playerMoveChoice]; } else { @@ -3223,7 +3222,7 @@ static void sub_80DB918(void) s32 i; for (i = 0; i < 4; i++) - sContestantStatus[i].currMove = GetChosenMove(i); + eContestantStatus[i].currMove = GetChosenMove(i); } static void sub_80DB944(void) @@ -3234,9 +3233,11 @@ static void sub_80DB944(void) for (i = 0; i < 4; i++) { - sContestantStatus[i].unk4 += sContestantStatus[i].appeal2; - arr[i] = sContestantStatus[i].unk4; + eContestantStatus[i].pointTotal += eContestantStatus[i].appeal2; + arr[i] = eContestantStatus[i].pointTotal; } + + // Sort the point totals using bubble-sort. for (i = 0; i < 3; i++) { for (j = 3; j > i; j--) @@ -3250,13 +3251,23 @@ static void sub_80DB944(void) } } } + + // For each contestant, find the best rank with their point total. + // Normally, each point total is different, and this will output the + // rankings as expected. However, if two pokemon are tied, then they + // both get the best rank for that point total. + // + // For example if the point totals are [100, 80, 80, 50], the ranks will + // be [1, 2, 2, 4]. The pokemon with a point total of 80 stop looking + // when they see the first 80 in the array, so they both share the '2' + // rank. for (i = 0; i < 4; i++) { for (j = 0; j < 4; j++) { - if (sContestantStatus[i].unk4 == arr[j]) + if (eContestantStatus[i].pointTotal == arr[j]) { - sContestantStatus[i].unkB_0 = j; + eContestantStatus[i].ranking = j; break; } } @@ -3273,26 +3284,26 @@ static void sub_80DBA18(void) { u8 attentionLevel; - if (sContestantStatus[i].currMove == MOVE_NONE) + if (eContestantStatus[i].currMove == MOVE_NONE) attentionLevel = 5; - else if (sContestantStatus[i].appeal2 <= 0) + else if (eContestantStatus[i].appeal2 <= 0) attentionLevel = 0; - else if (sContestantStatus[i].appeal2 < 30) + else if (eContestantStatus[i].appeal2 < 30) attentionLevel = 1; - else if (sContestantStatus[i].appeal2 < 60) + else if (eContestantStatus[i].appeal2 < 60) attentionLevel = 2; - else if (sContestantStatus[i].appeal2 < 80) + else if (eContestantStatus[i].appeal2 < 80) attentionLevel = 3; else attentionLevel = 4; - sContestantStatus[i].attentionLevel = attentionLevel; + eContestantStatus[i].attentionLevel = attentionLevel; } } static bool8 sub_80DBA68(u8 a) { - if (sContestantStatus[a].numTurnsSkipped != 0 || sContestantStatus[a].noMoreTurns) + if (eContestantStatus[a].numTurnsSkipped != 0 || eContestantStatus[a].noMoreTurns) return FALSE; else return TRUE; @@ -3304,50 +3315,50 @@ static void sub_80DBAA0(void) for (i = 0; i < 4; i++) { - sContestantStatus[i].appeal2 = 0; - sContestantStatus[i].appeal1 = 0; - sContestantStatus[i].jamSafetyCount = 0; - if (sContestantStatus[i].numTurnsSkipped > 0) - sContestantStatus[i].numTurnsSkipped--; - sContestantStatus[i].jam = 0; - sContestantStatus[i].resistant = 0; - sContestantStatus[i].jamReduction = 0; - sContestantStatus[i].immune = 0; - sContestantStatus[i].moreEasilyStartled = 0; - sContestantStatus[i].usedRepeatableMove = 0; - sContestantStatus[i].nervous = 0; - sContestantStatus[i].effectStringId = CONTEST_STRING_NONE; - sContestantStatus[i].effectStringId2 = CONTEST_STRING_NONE; - sContestantStatus[i].conditionMod = 0; - sContestantStatus[i].unk15_2 = sContestantStatus[i].disappointedRepeat; - sContestantStatus[i].disappointedRepeat = FALSE; - sContestantStatus[i].turnOrderModAction = 0; - sContestantStatus[i].appealTripleCondition = 0; - if (sContestantStatus[i].turnSkipped) + eContestantStatus[i].appeal2 = 0; + eContestantStatus[i].appeal1 = 0; + eContestantStatus[i].jamSafetyCount = 0; + if (eContestantStatus[i].numTurnsSkipped > 0) + eContestantStatus[i].numTurnsSkipped--; + eContestantStatus[i].jam = 0; + eContestantStatus[i].resistant = 0; + eContestantStatus[i].jamReduction = 0; + eContestantStatus[i].immune = 0; + eContestantStatus[i].moreEasilyStartled = 0; + eContestantStatus[i].usedRepeatableMove = 0; + eContestantStatus[i].nervous = 0; + eContestantStatus[i].effectStringId = CONTEST_STRING_NONE; + eContestantStatus[i].effectStringId2 = CONTEST_STRING_NONE; + eContestantStatus[i].conditionMod = 0; + eContestantStatus[i].unk15_2 = eContestantStatus[i].disappointedRepeat; + eContestantStatus[i].disappointedRepeat = FALSE; + eContestantStatus[i].turnOrderModAction = 0; + eContestantStatus[i].appealTripleCondition = 0; + if (eContestantStatus[i].turnSkipped) { - sContestantStatus[i].numTurnsSkipped = 1; - sContestantStatus[i].turnSkipped = 0; + eContestantStatus[i].numTurnsSkipped = 1; + eContestantStatus[i].turnSkipped = 0; } - if (sContestantStatus[i].exploded) + if (eContestantStatus[i].exploded) { - sContestantStatus[i].noMoreTurns = 1; - sContestantStatus[i].exploded = 0; + eContestantStatus[i].noMoreTurns = 1; + eContestantStatus[i].exploded = 0; } - sContestantStatus[i].overrideCategoryExcitementMod = 0; + eContestantStatus[i].overrideCategoryExcitementMod = 0; } for (i = 0; i < 4; i++) { - sContestantStatus[i].prevMove = sContestantStatus[i].currMove; - sContest.unk19220[sContest.turnNumber][i] = sContestantStatus[i].currMove; - sContest.unk19248[sContest.turnNumber][i] = Contest_GetMoveExcitement(sContestantStatus[i].currMove); - sContestantStatus[i].currMove = MOVE_NONE; + eContestantStatus[i].prevMove = eContestantStatus[i].currMove; + eContest.unk19220[eContest.turnNumber][i] = eContestantStatus[i].currMove; + eContest.unk19248[eContest.turnNumber][i] = Contest_GetMoveExcitement(eContestantStatus[i].currMove); + eContestantStatus[i].currMove = MOVE_NONE; } - shared19328.excitementFrozen = 0; + eContestResources10.excitementFrozen = 0; } bool8 Contest_IsMonsTurnDisabled(u8 a) { - if (sContestantStatus[a].numTurnsSkipped != 0 || sContestantStatus[a].noMoreTurns) + if (eContestantStatus[a].numTurnsSkipped != 0 || eContestantStatus[a].noMoreTurns) return TRUE; else return FALSE; @@ -3640,7 +3651,7 @@ static void sub_80DC308(u8 a) gContestResources->field_14[a].unk2_0 = 1; spriteId = gContestResources->field_14[a].unk0; - r5 = sContestantStatus[a].unk4 / 10 * 2; + r5 = eContestantStatus[a].pointTotal / 10 * 2; if (r5 > 56) r5 = 56; else if (r5 < 0) @@ -3740,7 +3751,7 @@ static void CreateApplauseMeterSprite(void) LoadSpritePalette(&gUnknown_08587BB8); spriteId = CreateSprite(&gSpriteTemplate_8587BC8, 30, 44, 1); gSprites[spriteId].invisible = TRUE; - sContest.applauseMeterSpriteId = spriteId; + eContest.applauseMeterSpriteId = spriteId; } static void sub_80DC5E8(void) @@ -3748,15 +3759,15 @@ static void sub_80DC5E8(void) u8 i; u8 taskId = CreateTask(sub_80DC728, 30); - sContest.unk19211 = taskId; + eContest.unk19211 = taskId; for (i = 0; i < 4; i++) gTasks[taskId].data[i * 4] = 0xFF; } static void sub_80DC630(u8 a) { - gTasks[sContest.unk19211].data[a * 4 + 0] = 0; - gTasks[sContest.unk19211].data[a * 4 + 1] = 0; + gTasks[eContest.unk19211].data[a * 4 + 0] = 0; + gTasks[eContest.unk19211].data[a * 4 + 1] = 0; } static void sub_80DC674(u8 a) @@ -3770,12 +3781,12 @@ static void sub_80DC6A4(u8 taskId) { u8 r4 = gTasks[taskId].data[0]; - if (gTasks[sContest.unk19211].data[r4 * 4 + 0] == 0 - || gTasks[sContest.unk19211].data[r4 * 4 + 0] == 0xFF) + if (gTasks[eContest.unk19211].data[r4 * 4 + 0] == 0 + || gTasks[eContest.unk19211].data[r4 * 4 + 0] == 0xFF) { - gTasks[sContest.unk19211].data[r4 * 4 + 0] = 0xFF; - gTasks[sContest.unk19211].data[r4 * 4 + 1] = 0; - BlendPalette((sContest.unk19218[r4] + 5) * 16 + 6, 2, 0, RGB(31, 31, 18)); + gTasks[eContest.unk19211].data[r4 * 4 + 0] = 0xFF; + gTasks[eContest.unk19211].data[r4 * 4 + 1] = 0; + BlendPalette((eContest.unk19218[r4] + 5) * 16 + 6, 2, 0, RGB(31, 31, 18)); DestroyTask(taskId); } } @@ -3800,7 +3811,7 @@ static void sub_80DC728(u8 taskId) gTasks[taskId].data[r3 + 1] ^= 1; BlendPalette( - (sContest.unk19218[i] + 5) * 16 + 6, + (eContest.unk19218[i] + 5) * 16 + 6, 2, gTasks[taskId].data[r3 + 0], RGB(31, 31, 18)); @@ -3812,15 +3823,15 @@ static void sub_80DC7EC(void) { s32 i; - sContest.unk19212 = CreateTask(sub_80DC8D0, 30); + eContest.unk19212 = CreateTask(sub_80DC8D0, 30); for (i = 0; i < 4; i++) sub_80DC81C(i); } static void sub_80DC81C(u8 a) { - gTasks[sContest.unk19212].data[a * 4 + 0] = 0xFF; - gTasks[sContest.unk19212].data[a * 4 + 1] = 0; + gTasks[eContest.unk19212].data[a * 4 + 0] = 0xFF; + gTasks[eContest.unk19212].data[a * 4 + 1] = 0; } static void sub_80DC864(void) @@ -3882,7 +3893,7 @@ static void sub_80DC8D0(u8 taskId) static void sub_80DC9B4(u8 a) { - if (sContestantStatus[a].hasJudgesAttention) + if (eContestantStatus[a].hasJudgesAttention) sub_80DC630(a); else sub_80DC674(a); @@ -3992,14 +4003,15 @@ static void sub_80DCCD8(struct Sprite *sprite) sub_80DCBD0(); } +// Unused. static void sub_80DCD08(void) { - if(gHeap[0x1A000] == 1) - gHeap[0x1A000] = 0; + if(eUnknownHeap1A000 == 1) + eUnknownHeap1A000 = 0; else - gHeap[0x1A000] = 1; + eUnknownHeap1A000 = 1; - if(gHeap[0x1A000] == 0) + if(eUnknownHeap1A000 == 0) { sub_80DAEA4(); sub_80DB2BC(); @@ -4020,7 +4032,7 @@ static void sub_80DCD48(void) if (gUnknown_020322D5 == 0) return; - switch (gHeap[0x1A000]) + switch (eUnknownHeap1A000) { case 0: break; @@ -4028,14 +4040,17 @@ static void sub_80DCD48(void) case 3: sub_80DF750(); break; + // The only other possible value is 1, which is only set by sub_80DCD08, which is unused. + // So this code is unreachable. + // case 1: default: for (i = 0; i < 4; i++) FillWindowPixelBuffer(i, PIXEL_FILL(0)); for (i = 0; i < 4; i++) { - value = sContestantStatus[i].unk4; + value = eContestantStatus[i].pointTotal; txtPtr = text; - if (sContestantStatus[i].unk4 < 0) + if (eContestantStatus[i].pointTotal < 0) { value *= -1; txtPtr = StringCopy(txtPtr, gText_OneDash); @@ -4045,9 +4060,9 @@ static void sub_80DCD48(void) } for (i = 0; i < 4; i++) { - value = sContestantStatus[i].appeal2; + value = eContestantStatus[i].appeal2; txtPtr = text; - if (sContestantStatus[i].appeal2 < 0) + if (eContestantStatus[i].appeal2 < 0) { value *= -1; txtPtr = StringCopy(txtPtr, gText_OneDash); @@ -4109,7 +4124,7 @@ void sub_80DCE58(u8 a) memset(sp0, 0xFF, sizeof(sp0)); for (i = 0; i < 4; i++) { - u8 r2 = sContestantStatus[i].unkB_0; + u8 r2 = eContestantStatus[i].ranking; while (1) { @@ -4127,7 +4142,7 @@ void sub_80DCE58(u8 a) { for (r4 = 3; r4 > i; r4--) { - if (sContestantStatus[r4 - 1].unkB_0 == sContestantStatus[r4].unkB_0 + if (eContestantStatus[r4 - 1].ranking == eContestantStatus[r4].ranking && gUnknown_02039F26[r4 - 1] < gUnknown_02039F26[r4] && sp4[r4 - 1] < sp4[r4]) { @@ -4160,100 +4175,100 @@ static void sub_80DD080(u8 contestant) bool8 r8; s32 i; - sContestantStatus[contestant].appeal2 = 0; - sContestantStatus[contestant].appeal1 = 0; + eContestantStatus[contestant].appeal2 = 0; + eContestantStatus[contestant].appeal1 = 0; r8 = sub_80DBA68(contestant); if (!r8) return; - move = sContestantStatus[contestant].currMove; + move = eContestantStatus[contestant].currMove; effect = gContestMoves[move].effect; - sContestantStatus[contestant].moveCategory = gContestMoves[sContestantStatus[contestant].currMove].contestCategory; - if (sContestantStatus[contestant].currMove == sContestantStatus[contestant].prevMove && sContestantStatus[contestant].currMove != MOVE_NONE) + eContestantStatus[contestant].moveCategory = gContestMoves[eContestantStatus[contestant].currMove].contestCategory; + if (eContestantStatus[contestant].currMove == eContestantStatus[contestant].prevMove && eContestantStatus[contestant].currMove != MOVE_NONE) { - sContestantStatus[contestant].disappointedRepeat = TRUE; - sContestantStatus[contestant].moveRepeatCount++; + eContestantStatus[contestant].disappointedRepeat = TRUE; + eContestantStatus[contestant].moveRepeatCount++; } else { - sContestantStatus[contestant].moveRepeatCount = 0; + eContestantStatus[contestant].moveRepeatCount = 0; } - sContestantStatus[contestant].appeal1 = gContestEffects[effect].appeal; - sContestantStatus[contestant].appeal2 = sContestantStatus[contestant].appeal1; - shared192D0.jam = gContestEffects[effect].jam; - shared192D0.jam2 = shared192D0.jam; + eContestantStatus[contestant].appeal1 = gContestEffects[effect].appeal; + eContestantStatus[contestant].appeal2 = eContestantStatus[contestant].appeal1; + eContestResources8.jam = gContestEffects[effect].jam; + eContestResources8.jam2 = eContestResources8.jam; - shared192D0.contestant = contestant; + eContestResources8.contestant = contestant; for (i = 0; i < 4; i++) { - sContestantStatus[i].jam = 0; - shared192D0.unnervedPokes[i] = 0; + eContestantStatus[i].jam = 0; + eContestResources8.unnervedPokes[i] = 0; } - if (sContestantStatus[contestant].hasJudgesAttention - && !AreMovesContestCombo(sContestantStatus[contestant].prevMove, sContestantStatus[contestant].currMove)) - sContestantStatus[contestant].hasJudgesAttention = 0; + if (eContestantStatus[contestant].hasJudgesAttention + && !AreMovesContestCombo(eContestantStatus[contestant].prevMove, eContestantStatus[contestant].currMove)) + eContestantStatus[contestant].hasJudgesAttention = 0; gContestEffectFuncs[effect](); - if (sContestantStatus[contestant].conditionMod == 1) - sContestantStatus[contestant].appeal2 += sContestantStatus[contestant].condition - 10; - else if (sContestantStatus[contestant].appealTripleCondition) - sContestantStatus[contestant].appeal2 += sContestantStatus[contestant].condition * 3; + if (eContestantStatus[contestant].conditionMod == 1) + eContestantStatus[contestant].appeal2 += eContestantStatus[contestant].condition - 10; + else if (eContestantStatus[contestant].appealTripleCondition) + eContestantStatus[contestant].appeal2 += eContestantStatus[contestant].condition * 3; else - sContestantStatus[contestant].appeal2 += sContestantStatus[contestant].condition; + eContestantStatus[contestant].appeal2 += eContestantStatus[contestant].condition; - sContestantStatus[contestant].unk16 = 0; - sContestantStatus[contestant].unk15_6 = 0; + eContestantStatus[contestant].unk16 = 0; + eContestantStatus[contestant].unk15_6 = 0; if (sub_80DE1E8(contestant)) { - u8 r2 = AreMovesContestCombo(sContestantStatus[contestant].prevMove, sContestantStatus[contestant].currMove); + u8 r2 = AreMovesContestCombo(eContestantStatus[contestant].prevMove, eContestantStatus[contestant].currMove); - if (r2 != 0 && sContestantStatus[contestant].hasJudgesAttention) + if (r2 != 0 && eContestantStatus[contestant].hasJudgesAttention) { - sContestantStatus[contestant].unk16 = r2; - sContestantStatus[contestant].unk15_6 = 1; - sContestantStatus[contestant].hasJudgesAttention = 0; - sContestantStatus[contestant].unk17 = sContestantStatus[contestant].appeal1 * sContestantStatus[contestant].unk16; - sContestantStatus[contestant].unk15_3 = 1; + eContestantStatus[contestant].unk16 = r2; + eContestantStatus[contestant].unk15_6 = 1; + eContestantStatus[contestant].hasJudgesAttention = 0; + eContestantStatus[contestant].unk17 = eContestantStatus[contestant].appeal1 * eContestantStatus[contestant].unk16; + eContestantStatus[contestant].unk15_3 = 1; } else { - if (gContestMoves[sContestantStatus[contestant].currMove].comboStarterId != 0) + if (gContestMoves[eContestantStatus[contestant].currMove].comboStarterId != 0) { - sContestantStatus[contestant].hasJudgesAttention = 1; - sContestantStatus[contestant].unk15_6 = 1; + eContestantStatus[contestant].hasJudgesAttention = 1; + eContestantStatus[contestant].unk15_6 = 1; } else { - sContestantStatus[contestant].hasJudgesAttention = 0; + eContestantStatus[contestant].hasJudgesAttention = 0; } } } - if (sContestantStatus[contestant].disappointedRepeat) - sContestantStatus[contestant].unk18 = (sContestantStatus[contestant].moveRepeatCount + 1) * 10; + if (eContestantStatus[contestant].disappointedRepeat) + eContestantStatus[contestant].unk18 = (eContestantStatus[contestant].moveRepeatCount + 1) * 10; - if (sContestantStatus[contestant].nervous) + if (eContestantStatus[contestant].nervous) { - sContestantStatus[contestant].hasJudgesAttention = 0; - sContestantStatus[contestant].appeal2 = 0; - sContestantStatus[contestant].appeal1 = 0; + eContestantStatus[contestant].hasJudgesAttention = 0; + eContestantStatus[contestant].appeal2 = 0; + eContestantStatus[contestant].appeal1 = 0; } - shared19328.bits_0 = Contest_GetMoveExcitement(sContestantStatus[contestant].currMove); - if (sContestantStatus[contestant].overrideCategoryExcitementMod) - shared19328.bits_0 = 1; + eContestResources10.bits_0 = Contest_GetMoveExcitement(eContestantStatus[contestant].currMove); + if (eContestantStatus[contestant].overrideCategoryExcitementMod) + eContestResources10.bits_0 = 1; - if (shared19328.bits_0 > 0) + if (eContestResources10.bits_0 > 0) { - if (sContest.applauseLevel + shared19328.bits_0 > 4) - shared19328.unk2 = 60; + if (eContest.applauseLevel + eContestResources10.bits_0 > 4) + eContestResources10.unk2 = 60; else - shared19328.unk2 = 10; + eContestResources10.unk2 = 10; } else { - shared19328.unk2 = 0; + eContestResources10.unk2 = 0; } rnd = Random() % 3; @@ -4266,17 +4281,17 @@ static void sub_80DD080(u8 contestant) rnd--; } } - sContestantStatus[contestant].unk1B = i; + eContestantStatus[contestant].unk1B = i; } void SetContestantEffectStringID(u8 a, u8 b) { - sContestantStatus[a].effectStringId = b; + eContestantStatus[a].effectStringId = b; } void SetContestantEffectStringID2(u8 a, u8 b) { - sContestantStatus[a].effectStringId2 = b; + eContestantStatus[a].effectStringId2 = b; } void SetStartledString(u8 contestant, u8 jam) @@ -4296,14 +4311,14 @@ void SetStartledString(u8 contestant, u8 jam) static void sub_80DD45C(u8 contestant, u8 stringId) { StringCopy(gStringVar1, gContestMons[contestant].nickname); - StringCopy(gStringVar2, gMoveNames[sContestantStatus[contestant].currMove]); - if (gContestMoves[sContestantStatus[shared192D0.contestant].currMove].contestCategory == CONTEST_CATEGORY_COOL) + StringCopy(gStringVar2, gMoveNames[eContestantStatus[contestant].currMove]); + if (gContestMoves[eContestantStatus[eContestResources8.contestant].currMove].contestCategory == CONTEST_CATEGORY_COOL) StringCopy(gStringVar3, gText_Contest_Shyness); - else if (gContestMoves[sContestantStatus[shared192D0.contestant].currMove].contestCategory == CONTEST_CATEGORY_BEAUTY) + else if (gContestMoves[eContestantStatus[eContestResources8.contestant].currMove].contestCategory == CONTEST_CATEGORY_BEAUTY) StringCopy(gStringVar3, gText_Contest_Anxiety); - else if (gContestMoves[sContestantStatus[shared192D0.contestant].currMove].contestCategory == CONTEST_CATEGORY_CUTE) + else if (gContestMoves[eContestantStatus[eContestResources8.contestant].currMove].contestCategory == CONTEST_CATEGORY_CUTE) StringCopy(gStringVar3, gText_Contest_Laziness); - else if (gContestMoves[sContestantStatus[shared192D0.contestant].currMove].contestCategory == CONTEST_CATEGORY_SMART) + else if (gContestMoves[eContestantStatus[eContestResources8.contestant].currMove].contestCategory == CONTEST_CATEGORY_SMART) StringCopy(gStringVar3, gText_Contest_Hesitancy); else StringCopy(gStringVar3, gText_Contest_Fear); @@ -4314,8 +4329,8 @@ static void sub_80DD45C(u8 contestant, u8 stringId) void MakeContestantNervous(u8 p) { - sContestantStatus[p].nervous = 1; - sContestantStatus[p].currMove = MOVE_NONE; + eContestantStatus[p].nervous = 1; + eContestantStatus[p].currMove = MOVE_NONE; } static void sub_80DD590(void) @@ -4336,7 +4351,7 @@ static void sub_80DD590(void) { for (j = 0; j < 4; j++) { - if (sContestantStatus[j].nextTurnOrder == i) + if (eContestantStatus[j].nextTurnOrder == i) { sp0[j] = i; sp4[j] = 1; @@ -4347,7 +4362,7 @@ static void sub_80DD590(void) { for (j = 0; j < 4; j++) { - if (sp4[j] == 0 && sContestantStatus[j].nextTurnOrder == 0xFF) + if (sp4[j] == 0 && eContestantStatus[j].nextTurnOrder == 0xFF) { r12 = j; j++; @@ -4356,7 +4371,7 @@ static void sub_80DD590(void) } for (; j < 4; j++) { - if (sp4[j] == 0 && sContestantStatus[j].nextTurnOrder == 0xFF + if (sp4[j] == 0 && eContestantStatus[j].nextTurnOrder == 0xFF && gUnknown_02039F26[r12] > gUnknown_02039F26[j]) r12 = j; } @@ -4367,9 +4382,9 @@ static void sub_80DD590(void) for (i = 0; i < 4; i++) { - shared192D0.turnOrder[i] = sp0[i]; - sContestantStatus[i].nextTurnOrder = 0xFF; - sContestantStatus[i].turnOrderMod = 0; + eContestResources8.turnOrder[i] = sp0[i]; + eContestantStatus[i].nextTurnOrder = 0xFF; + eContestantStatus[i].turnOrderMod = 0; gUnknown_02039F26[i] = sp0[i]; } } @@ -4381,13 +4396,13 @@ static void sub_80DD6DC(struct Sprite *sprite) sprite->data[1] = 0; sprite->invisible = TRUE; sprite->callback = SpriteCallbackDummy; - sContest.unk1920A_4 = 0; + eContest.unk1920A_4 = 0; } } static void sub_80DD720(u8 a) { - u8 spriteId = sContest.unk19216; + u8 spriteId = eContest.unk19216; switch (a) { @@ -4429,7 +4444,7 @@ static void sub_80DD720(u8 a) gSprites[spriteId].data[1] = 0; gSprites[spriteId].invisible = FALSE; gSprites[spriteId].callback = sub_80DD6DC; - sContest.unk1920A_4 = 1; + eContest.unk1920A_4 = 1; } static void sub_80DD940(void) @@ -4440,14 +4455,14 @@ static void sub_80DD940(void) { const u8 *src; - if (i < sContest.applauseLevel) + if (i < eContest.applauseLevel) src = gContestApplauseMeterGfx + 64; else src = gContestApplauseMeterGfx; - CpuCopy32(src, (void *)(VRAM + 0x10000 + (gSprites[sContest.applauseMeterSpriteId].oam.tileNum + 17 + i) * 32), 32); - CpuCopy32(src + 32, (void *)(VRAM + 0x10000 + (gSprites[sContest.applauseMeterSpriteId].oam.tileNum + 25 + i) * 32), 32); + CpuCopy32(src, (void *)(VRAM + 0x10000 + (gSprites[eContest.applauseMeterSpriteId].oam.tileNum + 17 + i) * 32), 32); + CpuCopy32(src + 32, (void *)(VRAM + 0x10000 + (gSprites[eContest.applauseMeterSpriteId].oam.tileNum + 25 + i) * 32), 32); - if (sContest.applauseLevel > 4) + if (eContest.applauseLevel > 4) sub_80DDA20(); } } @@ -4479,7 +4494,7 @@ static void c3_08130B10(u8 taskId) if (gTasks[taskId].data[4] == 0 || gTasks[taskId].data[4] == 16) { gTasks[taskId].data[3] ^= 1; - if (sContest.applauseLevel < 5) + if (eContest.applauseLevel < 5) { BlendPalette(264 + gTasks[taskId].data[2] * 16, 1, 0, RGB(31, 0, 0)); DestroyTask(taskId); @@ -4491,14 +4506,14 @@ static void c3_08130B10(u8 taskId) static void sub_80DDB0C(void) { CreateTask(sub_80DDB6C, 10); - gSprites[sContest.applauseMeterSpriteId].pos2.x = -70; - gSprites[sContest.applauseMeterSpriteId].invisible = FALSE; - sContest.unk1920A_6 = 1; + gSprites[eContest.applauseMeterSpriteId].pos2.x = -70; + gSprites[eContest.applauseMeterSpriteId].invisible = FALSE; + eContest.unk1920A_6 = 1; } static void sub_80DDB6C(u8 taskId) { - struct Sprite *sprite = &gSprites[sContest.applauseMeterSpriteId]; + struct Sprite *sprite = &gSprites[eContest.applauseMeterSpriteId]; gTasks[taskId].data[10] += 1664; sprite->pos2.x += gTasks[taskId].data[10] >> 8; @@ -4507,28 +4522,28 @@ static void sub_80DDB6C(u8 taskId) sprite->pos2.x = 0; if (sprite->pos2.x == 0) { - sContest.unk1920A_6 = 0; + eContest.unk1920A_6 = 0; DestroyTask(taskId); } } static void sub_80DDBE8(void) { - if (gSprites[sContest.applauseMeterSpriteId].invisible == TRUE) + if (gSprites[eContest.applauseMeterSpriteId].invisible == TRUE) { - sContest.unk1920A_6 = 0; + eContest.unk1920A_6 = 0; } else { CreateTask(task08_080CD1CC, 10); - gSprites[sContest.applauseMeterSpriteId].pos2.x = 0; - sContest.unk1920A_6 = 1; + gSprites[eContest.applauseMeterSpriteId].pos2.x = 0; + eContest.unk1920A_6 = 1; } } static void task08_080CD1CC(u8 taskId) { - struct Sprite *sprite = &gSprites[sContest.applauseMeterSpriteId]; + struct Sprite *sprite = &gSprites[eContest.applauseMeterSpriteId]; gTasks[taskId].data[10] += 1664; sprite->pos2.x -= gTasks[taskId].data[10] >> 8; @@ -4538,7 +4553,7 @@ static void task08_080CD1CC(u8 taskId) if (sprite->pos2.x == -70) { sprite->invisible = TRUE; - sContest.unk1920A_6 = 0; + eContest.unk1920A_6 = 0; DestroyTask(taskId); } } @@ -4548,7 +4563,7 @@ static void sub_80DDCDC(s8 a) u8 taskId = CreateTask(sub_80DDD20, 5); gTasks[taskId].data[0] = a; - sContest.unk1920A_5 = 1; + eContest.unk1920A_5 = 1; } static void sub_80DDD20(u8 taskId) @@ -4560,7 +4575,7 @@ static void sub_80DDD20(u8 taskId) gTasks[taskId].data[10]++; break; case 1: - if (!sContest.unk1920A_6) + if (!eContest.unk1920A_6) { gTasks[taskId].data[10]++; } @@ -4570,7 +4585,7 @@ static void sub_80DDD20(u8 taskId) { gTasks[taskId].data[11] = 0; sub_80DD940(); - sContest.unk1920A_5 = 0; + eContest.unk1920A_5 = 0; DestroyTask(taskId); } break; @@ -4579,19 +4594,19 @@ static void sub_80DDD20(u8 taskId) void unref_sub_80DDDA8(void) { - gSprites[sContest.applauseMeterSpriteId].pos2.x = 0; - gSprites[sContest.applauseMeterSpriteId].invisible = FALSE; + gSprites[eContest.applauseMeterSpriteId].pos2.x = 0; + gSprites[eContest.applauseMeterSpriteId].invisible = FALSE; } void unref_sub_80DDDE4(void) { - gSprites[sContest.applauseMeterSpriteId].invisible = TRUE; + gSprites[eContest.applauseMeterSpriteId].invisible = TRUE; } static void sub_80DDE0C(void) { CreateTask(sub_80DDE30, 15); - sContest.unk1920A_7 = 1; + eContest.unk1920A_7 = 1; } static void sub_80DDE30(u8 taskId) @@ -4601,11 +4616,11 @@ static void sub_80DDE30(u8 taskId) gTasks[taskId].data[10] = 0; if (gTasks[taskId].data[11] == 0) { - RequestDma3Copy(shared16800, (void *)(BG_SCREEN_ADDR(4)), 0x1000, 1); + RequestDma3Copy(eUnknownHeap19000, (void *)(BG_SCREEN_ADDR(4)), 0x1000, 1); } else { - RequestDma3Copy(shared15800, (void *)(BG_SCREEN_ADDR(4)), 0x1000, 1); + RequestDma3Copy(eUnknownHeap18000, (void *)(BG_SCREEN_ADDR(4)), 0x1000, 1); gTasks[taskId].data[12]++; } @@ -4613,7 +4628,7 @@ static void sub_80DDE30(u8 taskId) if (gTasks[taskId].data[12] == 9) { - sContest.unk1920A_7 = 0; + eContest.unk1920A_7 = 0; DestroyTask(taskId); } } @@ -4635,11 +4650,11 @@ static void sub_80DDED0(s8 a, s8 b) if (b > 0) { blendCoeff = 0; - r3 = sContest.applauseLevel * 3; + r3 = eContest.applauseLevel * 3; } else { - blendCoeff = sContest.applauseLevel * 3; + blendCoeff = eContest.applauseLevel * 3; r3 = 0; } } @@ -4661,7 +4676,7 @@ static void sub_80DDED0(s8 a, s8 b) gTasks[taskId].tBlendCoeff = blendCoeff; gTasks[taskId].data[2] = b; gTasks[taskId].data[3] = r3; - sContest.unk1920B_0 = 0; + eContest.unk1920B_0 = 0; } static void sub_80DDF80(u8 taskId) @@ -4678,7 +4693,7 @@ static void sub_80DDF80(u8 taskId) if (gTasks[taskId].tBlendCoeff == gTasks[taskId].data[3]) { DestroyTask(taskId); - sContest.unk1920B_0 = 0; + eContest.unk1920B_0 = 0; } } } @@ -4692,7 +4707,7 @@ static void sub_80DE008(bool8 a) for (i = 0; i < 4; i++) { - if (sContestantStatus[i].turnOrderMod != 0 && a) + if (eContestantStatus[i].turnOrderMod != 0 && a) { CpuCopy32(GetTurnOrderNumberGfx(i), (void *)(VRAM + 0x10000 + (gSprites[gContestResources->field_14[i].unk1].oam.tileNum + 6) * 32), 32); gSprites[gContestResources->field_14[i].unk1].pos1.y = gUnknown_08587A70[gUnknown_02039F26[i]]; @@ -4707,10 +4722,10 @@ static void sub_80DE008(bool8 a) static const u8 *GetTurnOrderNumberGfx(u8 contestant) { - if (sContestantStatus[contestant].turnOrderMod != 1) + if (eContestantStatus[contestant].turnOrderMod != 1) return gContestNextTurnRandomGfx; else - return gContestNextTurnNumbersGfx + sContestantStatus[contestant].nextTurnOrder * 32; + return gContestNextTurnNumbersGfx + eContestantStatus[contestant].nextTurnOrder * 32; } static void sub_80DE12C(void) @@ -4722,7 +4737,7 @@ static void sub_80DE12C(void) for (r7 = 0; r7 < 4; r7++) { - if (shared192D0.unnervedPokes[r7] != 0 && !Contest_IsMonsTurnDisabled(r7)) + if (eContestResources8.unnervedPokes[r7] != 0 && !Contest_IsMonsTurnDisabled(r7)) { u32 r6 = gUnknown_02039F26[r7] * 5 + 2; u16 var = sub_80DB748(3); @@ -4737,7 +4752,7 @@ static void sub_80DE12C(void) bool8 sub_80DE1E8(u8 a) { - if (sContestantStatus[a].disappointedRepeat || sContestantStatus[a].nervous) + if (eContestantStatus[a].disappointedRepeat || eContestantStatus[a].nervous) return FALSE; else return TRUE; @@ -4836,7 +4851,7 @@ static void sub_80DE4A8(u8 taskId) { case 0: for (i = 0; i < 4; i++) - sContest.unk19218[i] = gUnknown_02039F26[i]; + eContest.unk19218[i] = gUnknown_02039F26[i]; sub_80DBF90(); sub_80DC864(); sub_80DB69C(); @@ -4850,7 +4865,7 @@ static void sub_80DE4A8(u8 taskId) { u8 taskId2; - sContest.unk1920B_2 = 1; + eContest.unk1920B_2 = 1; if (sub_80DA8A4()) sub_80DBAA0(); taskId2 = CreateTask(sub_80FCC88, 0); @@ -4865,7 +4880,7 @@ static void sub_80DE4A8(u8 taskId) } break; case 2: - if (!sContest.unk1920B_2) + if (!eContest.unk1920B_2) gTasks[taskId].data[0] = 3; break; case 3: @@ -4946,7 +4961,7 @@ static void sub_80DE69C(u8 a) } taskId = CreateTask(sub_80DE794, 5); gTasks[taskId].data[0] = a; - sContest.unk1920B_1 = 1; + eContest.unk1920B_1 = 1; } static void sub_80DE794(u8 taskId) @@ -4962,7 +4977,7 @@ static void sub_80DE794(u8 taskId) } for (i = 0; i < 4; i++) FreeSpriteOamMatrix(&gSprites[gContestResources->field_14[i].unk0]); - sContest.unk1920B_1 = 0; + eContest.unk1920B_1 = 0; DestroyTask(taskId); } } @@ -4984,7 +4999,7 @@ static u16 SanitizeSpecies(u16 species) static void sub_80DE864(u8 a) { s32 i; - u16 move = SanitizeMove(sContestantStatus[a].currMove); + u16 move = SanitizeMove(eContestantStatus[a].currMove); u16 species = SanitizeSpecies(gContestMons[a].species); u8 r5_2; @@ -5002,7 +5017,7 @@ static void sub_80DE864(u8 a) break; case MOVE_TRANSFORM: case MOVE_ROLE_PLAY: - r5_2 = sContestantStatus[a].unk1B; + r5_2 = eContestantStatus[a].unk1B; gContestResources->field_18->unk2 = SanitizeSpecies(gContestMons[r5_2].species); gContestResources->field_18->unk10 = gContestMons[r5_2].personality; gContestResources->field_18->unk4_0 = 1; @@ -5017,9 +5032,9 @@ static void sub_80DE864(u8 a) case MOVE_RAZOR_WIND: case MOVE_SKULL_BASH: case MOVE_SKY_ATTACK: - if (sContest.unk1925E == 0) + if (eContest.unk1925E == 0) { - sContest.unk1925E = 2; + eContest.unk1925E = 2; gAnimMoveTurn = 0; } else @@ -5034,8 +5049,8 @@ static void sub_80DE864(u8 a) static void sub_80DE9B0(u8 unused) { memset(&gContestResources->field_18->species, 0, 0x14); - if (sContest.unk1925E != 0) - sContest.unk1925E--; + if (eContest.unk1925E != 0) + eContest.unk1925E--; } static void sub_80DE9DC(u8 a) @@ -5346,13 +5361,13 @@ static void sub_80DF080(u8 contestant) { gContestResources->field_1c[contestant].unkC |= 0x80; gContestResources->field_1c[contestant].unkE_1 = 1; - gContestResources->field_1c[contestant].unk0[gContestResources->field_0->turnNumber] = gContestResources->field_4[contestant].currMove; + gContestResources->field_1c[contestant].unk0[eContest.turnNumber] = gContestResources->field_4[contestant].currMove; } if (gContestResources->field_4[contestant].disappointedRepeat) gContestResources->field_1c[contestant].unkD |= 2; - if (gContestResources->field_0->applauseLevel == 4 + if (eContest.applauseLevel == 4 && !gContestResources->field_10->excitementFrozen && gContestResources->field_10->bits_0 < 0) { @@ -5574,19 +5589,19 @@ static void sub_80DF4F8(void) // Unused void sub_80DF704(u8 arg0) { - if (gHeap[0x1A000] == 0) + if (eUnknownHeap1A000 == 0) { if (arg0 == 0) - gHeap[0x1A000] = 2; + eUnknownHeap1A000 = 2; else - gHeap[0x1A000] = 3; + eUnknownHeap1A000 = 3; } else { - gHeap[0x1A000] = 0; + eUnknownHeap1A000 = 0; } - if (gHeap[0x1A000] == 0) + if (eUnknownHeap1A000 == 0) { sub_80DAEA4(); sub_80DB2BC(); @@ -5608,13 +5623,13 @@ static void sub_80DF750(void) if (gUnknown_020322D5 == 0) return; - if (gHeap[0x1A000] != 2 && gHeap[0x1A000] != 3) + if (eUnknownHeap1A000 != 2 && eUnknownHeap1A000 != 3) return; for (i = 0; i < 4; i++) FillWindowPixelBuffer(i, PIXEL_FILL(0)); - if (gHeap[0x1A000] == 2) + if (eUnknownHeap1A000 == 2) { for (i = 0; i < 4; i++) { diff --git a/src/contest_ai.c b/src/contest_ai.c index 8c0106280..42a09259e 100644 --- a/src/contest_ai.c +++ b/src/contest_ai.c @@ -295,38 +295,38 @@ static u8 AIStackPop(void); void ContestAI_ResetAI(u8 contestantAI) { int i; - memset(eContestAI, 0, sizeof(struct ContestAIInfo)); + memset(&eContestAI, 0, sizeof(struct ContestAIInfo)); for (i = 0; i < 4; i++) - eContestAI->unk5[i] = 100; + eContestAI.unk5[i] = 100; - eContestAI->contestantId = contestantAI; - eContestAI->stackSize = 0; - eContestAI->aiChecks = gContestMons[eContestAI->contestantId].aiChecks; + eContestAI.contestantId = contestantAI; + eContestAI.stackSize = 0; + eContestAI.aiChecks = gContestMons[eContestAI.contestantId].aiChecks; } u8 ContestAI_GetActionToUse(void) { - while (eContestAI->aiChecks != 0) + while (eContestAI.aiChecks != 0) { - if (eContestAI->aiChecks & 1) + if (eContestAI.aiChecks & 1) { - eContestAI->aiState = CONTESTAI_SETTING_UP; + eContestAI.aiState = CONTESTAI_SETTING_UP; ContestAI_DoAIProcessing(); } - eContestAI->aiChecks >>= 1; - eContestAI->currentAICheck++; - eContestAI->nextMoveIndex = 0; + eContestAI.aiChecks >>= 1; + eContestAI.currentAICheck++; + eContestAI.nextMoveIndex = 0; } while (1) { u8 rval = Random() & 3; - u8 r2 = eContestAI->unk5[rval]; + u8 r2 = eContestAI.unk5[rval]; int i; for (i = 0; i < 4; i++) { - if (r2 < eContestAI->unk5[i]) + if (r2 < eContestAI.unk5[i]) break; } if (i == 4) @@ -336,40 +336,40 @@ u8 ContestAI_GetActionToUse(void) static void ContestAI_DoAIProcessing(void) { - while (eContestAI->aiState != CONTESTAI_FINISHED) + while (eContestAI.aiState != CONTESTAI_FINISHED) { - switch(eContestAI->aiState) + switch(eContestAI.aiState) { case CONTESTAI_DO_NOT_PROCESS: break; case CONTESTAI_SETTING_UP: - gAIScriptPtr = gContestAIChecks[eContestAI->currentAICheck]; + gAIScriptPtr = gContestAIChecks[eContestAI.currentAICheck]; - if (gContestMons[eContestAI->contestantId].moves[eContestAI->nextMoveIndex] == 0) - eContestAI->nextMove = 0; // don't process a move that doesn't exist. + if (gContestMons[eContestAI.contestantId].moves[eContestAI.nextMoveIndex] == 0) + eContestAI.nextMove = 0; // don't process a move that doesn't exist. else - eContestAI->nextMove = gContestMons[eContestAI->contestantId].moves[eContestAI->nextMoveIndex]; - eContestAI->aiState++; + eContestAI.nextMove = gContestMons[eContestAI.contestantId].moves[eContestAI.nextMoveIndex]; + eContestAI.aiState++; break; case CONTESTAI_PROCESSING: - if (eContestAI->nextMove != 0) + if (eContestAI.nextMove != 0) { sContestAICmdTable[*gAIScriptPtr](); // run the command. } else { - eContestAI->unk5[eContestAI->nextMoveIndex] = 0; // don't consider a move that doesn't exist. - eContestAI->aiAction |= 1; + eContestAI.unk5[eContestAI.nextMoveIndex] = 0; // don't consider a move that doesn't exist. + eContestAI.aiAction |= 1; } - if (eContestAI->aiAction & 1) + if (eContestAI.aiAction & 1) { - eContestAI->nextMoveIndex++; - if (eContestAI->nextMoveIndex < 4) - eContestAI->aiState = 0; + eContestAI.nextMoveIndex++; + if (eContestAI.nextMoveIndex < 4) + eContestAI.aiState = 0; else // aiState = CONTESTAI_FINISHED - eContestAI->aiState++; - eContestAI->aiAction &= 0xFE; // TODO: Define action flags + eContestAI.aiState++; + eContestAI.aiAction &= 0xFE; // TODO: Define action flags } break; } @@ -381,7 +381,7 @@ static u8 sub_81563B0(u8 var) int i; for (i = 0; i < 4; i++) - if (shared192D0.turnOrder[i] == var) + if (eContestResources8.turnOrder[i] == var) break; return i; @@ -389,21 +389,21 @@ static u8 sub_81563B0(u8 var) static void ContestAICmd_score(void) { - s16 score = eContestAI->unk5[eContestAI->nextMoveIndex] + (s8)gAIScriptPtr[1]; + s16 score = eContestAI.unk5[eContestAI.nextMoveIndex] + (s8)gAIScriptPtr[1]; if (score > 255) score = 255; else if (score < 0) score = 0; - eContestAI->unk5[eContestAI->nextMoveIndex] = score; + eContestAI.unk5[eContestAI.nextMoveIndex] = score; gAIScriptPtr += 2; } static void ContestAICmd_get_turn(void) { - eContestAI->scriptResult = sContest.turnNumber; + eContestAI.scriptResult = eContest.turnNumber; gAIScriptPtr += 1; } @@ -411,7 +411,7 @@ static void ContestAICmd_if_turn_less_than(void) { ContestAICmd_get_turn(); - if (eContestAI->scriptResult < gAIScriptPtr[0]) + if (eContestAI.scriptResult < gAIScriptPtr[0]) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1); else gAIScriptPtr += 5; @@ -421,7 +421,7 @@ static void ContestAICmd_if_turn_more_than(void) { ContestAICmd_get_turn(); - if (eContestAI->scriptResult > gAIScriptPtr[0]) + if (eContestAI.scriptResult > gAIScriptPtr[0]) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1); else gAIScriptPtr += 5; @@ -431,7 +431,7 @@ static void ContestAICmd_if_turn_eq(void) { ContestAICmd_get_turn(); - if (eContestAI->scriptResult == gAIScriptPtr[0]) + if (eContestAI.scriptResult == gAIScriptPtr[0]) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1); else gAIScriptPtr += 5; @@ -441,7 +441,7 @@ static void ContestAICmd_if_turn_not_eq(void) { ContestAICmd_get_turn(); - if (eContestAI->scriptResult != gAIScriptPtr[0]) + if (eContestAI.scriptResult != gAIScriptPtr[0]) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1); else gAIScriptPtr += 5; @@ -449,7 +449,7 @@ static void ContestAICmd_if_turn_not_eq(void) static void ContestAICmd_get_excitement(void) { - eContestAI->scriptResult = sContest.applauseLevel; + eContestAI.scriptResult = eContest.applauseLevel; gAIScriptPtr += 1; } @@ -457,7 +457,7 @@ static void ContestAICmd_if_excitement_less_than(void) { ContestAICmd_get_excitement(); - if (eContestAI->scriptResult < gAIScriptPtr[0]) + if (eContestAI.scriptResult < gAIScriptPtr[0]) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1); else gAIScriptPtr += 5; @@ -467,7 +467,7 @@ static void ContestAICmd_if_excitement_more_than(void) { ContestAICmd_get_excitement(); - if (eContestAI->scriptResult > gAIScriptPtr[0]) + if (eContestAI.scriptResult > gAIScriptPtr[0]) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1); else gAIScriptPtr += 5; @@ -477,7 +477,7 @@ static void ContestAICmd_if_excitement_eq(void) { ContestAICmd_get_excitement(); - if (eContestAI->scriptResult == gAIScriptPtr[0]) + if (eContestAI.scriptResult == gAIScriptPtr[0]) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1); else gAIScriptPtr += 5; @@ -487,7 +487,7 @@ static void ContestAICmd_if_excitement_not_eq(void) { ContestAICmd_get_excitement(); - if (eContestAI->scriptResult != gAIScriptPtr[0]) + if (eContestAI.scriptResult != gAIScriptPtr[0]) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1); else gAIScriptPtr += 5; @@ -495,7 +495,7 @@ static void ContestAICmd_if_excitement_not_eq(void) static void ContestAICmd_get_user_order(void) { - eContestAI->scriptResult = shared192D0.turnOrder[eContestAI->contestantId]; + eContestAI.scriptResult = eContestResources8.turnOrder[eContestAI.contestantId]; gAIScriptPtr += 1; } @@ -503,7 +503,7 @@ static void ContestAICmd_if_user_order_less_than(void) { ContestAICmd_get_user_order(); - if (eContestAI->scriptResult < gAIScriptPtr[0]) + if (eContestAI.scriptResult < gAIScriptPtr[0]) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1); else gAIScriptPtr += 5; @@ -513,7 +513,7 @@ static void ContestAICmd_if_user_order_more_than(void) { ContestAICmd_get_user_order(); - if (eContestAI->scriptResult > gAIScriptPtr[0]) + if (eContestAI.scriptResult > gAIScriptPtr[0]) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1); else gAIScriptPtr += 5; @@ -523,7 +523,7 @@ static void ContestAICmd_if_user_order_eq(void) { ContestAICmd_get_user_order(); - if (eContestAI->scriptResult == gAIScriptPtr[0]) + if (eContestAI.scriptResult == gAIScriptPtr[0]) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1); else gAIScriptPtr += 5; @@ -533,7 +533,7 @@ static void ContestAICmd_if_user_order_not_eq(void) { ContestAICmd_get_user_order(); - if (eContestAI->scriptResult != gAIScriptPtr[0]) + if (eContestAI.scriptResult != gAIScriptPtr[0]) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1); else gAIScriptPtr += 5; @@ -541,7 +541,7 @@ static void ContestAICmd_if_user_order_not_eq(void) static void ContestAICmd_get_user_condition(void) { - eContestAI->scriptResult = sContestantStatus[eContestAI->contestantId].condition / 10; + eContestAI.scriptResult = eContestantStatus[eContestAI.contestantId].condition / 10; gAIScriptPtr += 1; } @@ -549,7 +549,7 @@ static void ContestAICmd_if_user_condition_less_than(void) { ContestAICmd_get_user_condition(); - if (eContestAI->scriptResult < gAIScriptPtr[0]) + if (eContestAI.scriptResult < gAIScriptPtr[0]) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1); else gAIScriptPtr += 5; @@ -559,7 +559,7 @@ static void ContestAICmd_if_user_condition_more_than(void) { ContestAICmd_get_user_condition(); - if (eContestAI->scriptResult > gAIScriptPtr[0]) + if (eContestAI.scriptResult > gAIScriptPtr[0]) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1); else gAIScriptPtr += 5; @@ -569,7 +569,7 @@ static void ContestAICmd_if_user_condition_eq(void) { ContestAICmd_get_user_condition(); - if (eContestAI->scriptResult == gAIScriptPtr[0]) + if (eContestAI.scriptResult == gAIScriptPtr[0]) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1); else gAIScriptPtr += 5; @@ -579,7 +579,7 @@ static void ContestAICmd_if_user_condition_not_eq(void) { ContestAICmd_get_user_condition(); - if (eContestAI->scriptResult != gAIScriptPtr[0]) + if (eContestAI.scriptResult != gAIScriptPtr[0]) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1); else gAIScriptPtr += 5; @@ -587,7 +587,7 @@ static void ContestAICmd_if_user_condition_not_eq(void) static void ContestAICmd_unk_15(void) { - eContestAI->scriptResult = sContestantStatus[eContestAI->contestantId].unk4; + eContestAI.scriptResult = eContestantStatus[eContestAI.contestantId].pointTotal; gAIScriptPtr += 1; } @@ -595,7 +595,7 @@ static void ContestAICmd_unk_16(void) { ContestAICmd_unk_15(); - if (eContestAI->scriptResult < (s16)T1_READ_16(gAIScriptPtr + 0)) + if (eContestAI.scriptResult < (s16)T1_READ_16(gAIScriptPtr + 0)) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 2); else gAIScriptPtr += 6; @@ -605,7 +605,7 @@ static void ContestAICmd_unk_17(void) { ContestAICmd_unk_15(); - if (eContestAI->scriptResult > (s16)T1_READ_16(gAIScriptPtr + 0)) + if (eContestAI.scriptResult > (s16)T1_READ_16(gAIScriptPtr + 0)) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 2); else gAIScriptPtr += 6; @@ -615,7 +615,7 @@ static void ContestAICmd_unk_18(void) { ContestAICmd_unk_15(); - if (eContestAI->scriptResult == (s16)T1_READ_16(gAIScriptPtr + 0)) + if (eContestAI.scriptResult == (s16)T1_READ_16(gAIScriptPtr + 0)) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 2); else gAIScriptPtr += 6; @@ -625,7 +625,7 @@ static void ContestAICmd_unk_19(void) { ContestAICmd_unk_15(); - if (eContestAI->scriptResult != (s16)T1_READ_16(gAIScriptPtr + 0)) + if (eContestAI.scriptResult != (s16)T1_READ_16(gAIScriptPtr + 0)) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 2); else gAIScriptPtr += 6; @@ -633,7 +633,7 @@ static void ContestAICmd_unk_19(void) static void ContestAICmd_unk_1A(void) { - eContestAI->scriptResult = gContestMonConditions[eContestAI->contestantId]; + eContestAI.scriptResult = gContestMonConditions[eContestAI.contestantId]; gAIScriptPtr += 1; } @@ -641,7 +641,7 @@ static void ContestAICmd_unk_1B(void) { ContestAICmd_unk_1A(); - if (eContestAI->scriptResult < (s16)T1_READ_16(gAIScriptPtr + 0)) + if (eContestAI.scriptResult < (s16)T1_READ_16(gAIScriptPtr + 0)) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 2); else gAIScriptPtr += 6; @@ -651,7 +651,7 @@ static void ContestAICmd_unk_1C(void) { ContestAICmd_unk_1A(); - if (eContestAI->scriptResult > (s16)T1_READ_16(gAIScriptPtr + 0)) + if (eContestAI.scriptResult > (s16)T1_READ_16(gAIScriptPtr + 0)) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 2); else gAIScriptPtr += 6; @@ -661,7 +661,7 @@ static void ContestAICmd_unk_1D(void) { ContestAICmd_unk_1A(); - if (eContestAI->scriptResult == (s16)T1_READ_16(gAIScriptPtr + 0)) + if (eContestAI.scriptResult == (s16)T1_READ_16(gAIScriptPtr + 0)) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 2); else gAIScriptPtr += 6; @@ -671,7 +671,7 @@ static void ContestAICmd_unk_1E(void) { ContestAICmd_unk_1A(); - if (eContestAI->scriptResult != (s16)T1_READ_16(gAIScriptPtr + 0)) + if (eContestAI.scriptResult != (s16)T1_READ_16(gAIScriptPtr + 0)) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 2); else gAIScriptPtr += 6; @@ -679,7 +679,7 @@ static void ContestAICmd_unk_1E(void) static void ContestAICmd_get_contest_type(void) { - eContestAI->scriptResult = gSpecialVar_ContestCategory; + eContestAI.scriptResult = gSpecialVar_ContestCategory; gAIScriptPtr += 1; } @@ -687,7 +687,7 @@ static void ContestAICmd_if_contest_type_eq(void) { ContestAICmd_get_contest_type(); - if (eContestAI->scriptResult == gAIScriptPtr[0]) + if (eContestAI.scriptResult == gAIScriptPtr[0]) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1); else gAIScriptPtr += 5; @@ -697,7 +697,7 @@ static void ContestAICmd_if_contest_type_not_eq(void) { ContestAICmd_get_contest_type(); - if (eContestAI->scriptResult != gAIScriptPtr[0]) + if (eContestAI.scriptResult != gAIScriptPtr[0]) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1); else gAIScriptPtr += 5; @@ -705,7 +705,7 @@ static void ContestAICmd_if_contest_type_not_eq(void) static void ContestAICmd_get_move_excitement(void) { - eContestAI->scriptResult = Contest_GetMoveExcitement(gContestMons[eContestAI->contestantId].moves[eContestAI->nextMoveIndex]); + eContestAI.scriptResult = Contest_GetMoveExcitement(gContestMons[eContestAI.contestantId].moves[eContestAI.nextMoveIndex]); gAIScriptPtr += 1; } @@ -713,7 +713,7 @@ static void ContestAICmd_if_move_excitement_less_than(void) { ContestAICmd_get_move_excitement(); - if (eContestAI->scriptResult < (s8)gAIScriptPtr[0]) + if (eContestAI.scriptResult < (s8)gAIScriptPtr[0]) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1); else gAIScriptPtr += 5; @@ -723,7 +723,7 @@ static void ContestAICmd_if_move_excitement_greater_than(void) { ContestAICmd_get_move_excitement(); - if (eContestAI->scriptResult > (s8)gAIScriptPtr[0]) + if (eContestAI.scriptResult > (s8)gAIScriptPtr[0]) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1); else gAIScriptPtr += 5; @@ -733,7 +733,7 @@ static void ContestAICmd_if_move_excitement_eq(void) { ContestAICmd_get_move_excitement(); - if (eContestAI->scriptResult == (s8)gAIScriptPtr[0]) + if (eContestAI.scriptResult == (s8)gAIScriptPtr[0]) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1); else gAIScriptPtr += 5; @@ -743,7 +743,7 @@ static void ContestAICmd_if_move_excitement_not_eq(void) { ContestAICmd_get_move_excitement(); - if (eContestAI->scriptResult != (s8)gAIScriptPtr[0]) + if (eContestAI.scriptResult != (s8)gAIScriptPtr[0]) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1); else gAIScriptPtr += 5; @@ -751,9 +751,9 @@ static void ContestAICmd_if_move_excitement_not_eq(void) static void ContestAICmd_get_move_effect(void) { - u16 move = gContestMons[eContestAI->contestantId].moves[eContestAI->nextMoveIndex]; + u16 move = gContestMons[eContestAI.contestantId].moves[eContestAI.nextMoveIndex]; - eContestAI->scriptResult = gContestMoves[move].effect; + eContestAI.scriptResult = gContestMoves[move].effect; gAIScriptPtr += 1; } @@ -761,7 +761,7 @@ static void ContestAICmd_if_move_effect_eq(void) { ContestAICmd_get_move_effect(); - if (eContestAI->scriptResult == gAIScriptPtr[0]) + if (eContestAI.scriptResult == gAIScriptPtr[0]) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1); else gAIScriptPtr += 5; @@ -771,7 +771,7 @@ static void ContestAICmd_if_move_effect_not_eq(void) { ContestAICmd_get_move_effect(); - if (eContestAI->scriptResult != gAIScriptPtr[0]) + if (eContestAI.scriptResult != gAIScriptPtr[0]) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1); else gAIScriptPtr += 5; @@ -779,9 +779,9 @@ static void ContestAICmd_if_move_effect_not_eq(void) static void ContestAICmd_get_move_effect_type(void) { - u16 move = gContestMons[eContestAI->contestantId].moves[eContestAI->nextMoveIndex]; + u16 move = gContestMons[eContestAI.contestantId].moves[eContestAI.nextMoveIndex]; - eContestAI->scriptResult = gContestEffects[gContestMoves[move].effect].effectType; + eContestAI.scriptResult = gContestEffects[gContestMoves[move].effect].effectType; gAIScriptPtr += 1; } @@ -789,7 +789,7 @@ static void ContestAICmd_if_move_effect_type_eq(void) { ContestAICmd_get_move_effect_type(); - if (eContestAI->scriptResult == gAIScriptPtr[0]) + if (eContestAI.scriptResult == gAIScriptPtr[0]) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1); else gAIScriptPtr += 5; @@ -799,7 +799,7 @@ static void ContestAICmd_if_move_effect_type_not_eq(void) { ContestAICmd_get_move_effect_type(); - if (eContestAI->scriptResult != gAIScriptPtr[0]) + if (eContestAI.scriptResult != gAIScriptPtr[0]) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1); else gAIScriptPtr += 5; @@ -808,20 +808,20 @@ static void ContestAICmd_if_move_effect_type_not_eq(void) static void ContestAICmd_check_most_appealing_move(void) { int i; - u16 move = gContestMons[eContestAI->contestantId].moves[eContestAI->nextMoveIndex]; + u16 move = gContestMons[eContestAI.contestantId].moves[eContestAI.nextMoveIndex]; u8 appeal = gContestEffects[gContestMoves[move].effect].appeal; for (i = 0; i < MAX_MON_MOVES; i++) { - u16 newMove = gContestMons[eContestAI->contestantId].moves[i]; + u16 newMove = gContestMons[eContestAI.contestantId].moves[i]; if (newMove != 0 && appeal < gContestEffects[gContestMoves[newMove].effect].appeal) break; } if (i == MAX_MON_MOVES) - eContestAI->scriptResult = TRUE; + eContestAI.scriptResult = TRUE; else - eContestAI->scriptResult = FALSE; + eContestAI.scriptResult = FALSE; gAIScriptPtr += 1; } @@ -830,7 +830,7 @@ static void ContestAICmd_if_most_appealing_move(void) { ContestAICmd_check_most_appealing_move(); - if (eContestAI->scriptResult != FALSE) + if (eContestAI.scriptResult != FALSE) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 0); else gAIScriptPtr += 4; @@ -839,20 +839,20 @@ static void ContestAICmd_if_most_appealing_move(void) static void ContestAICmd_unk_2F(void) { int i; - u16 move = gContestMons[eContestAI->contestantId].moves[eContestAI->nextMoveIndex]; + u16 move = gContestMons[eContestAI.contestantId].moves[eContestAI.nextMoveIndex]; u8 jam = gContestEffects[gContestMoves[move].effect].jam; for (i = 0; i < MAX_MON_MOVES; i++) { - u16 newMove = gContestMons[eContestAI->contestantId].moves[i]; + u16 newMove = gContestMons[eContestAI.contestantId].moves[i]; if (newMove != 0 && jam < gContestEffects[gContestMoves[newMove].effect].jam) break; } if (i == MAX_MON_MOVES) - eContestAI->scriptResult = TRUE; + eContestAI.scriptResult = TRUE; else - eContestAI->scriptResult = FALSE; + eContestAI.scriptResult = FALSE; gAIScriptPtr += 1; } @@ -861,7 +861,7 @@ static void ContestAICmd_unk_30(void) { ContestAICmd_unk_2F(); - if (eContestAI->scriptResult != FALSE) + if (eContestAI.scriptResult != FALSE) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1); else gAIScriptPtr += 5; @@ -869,9 +869,9 @@ static void ContestAICmd_unk_30(void) static void ContestAICmd_unk_31(void) { - u16 move = gContestMons[eContestAI->contestantId].moves[eContestAI->nextMoveIndex]; + u16 move = gContestMons[eContestAI.contestantId].moves[eContestAI.nextMoveIndex]; - eContestAI->scriptResult = gContestEffects[gContestMoves[move].effect].appeal / 10; + eContestAI.scriptResult = gContestEffects[gContestMoves[move].effect].appeal / 10; gAIScriptPtr += 1; } @@ -879,7 +879,7 @@ static void ContestAICmd_unk_32(void) { ContestAICmd_unk_31(); - if (eContestAI->scriptResult < gAIScriptPtr[0]) + if (eContestAI.scriptResult < gAIScriptPtr[0]) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1); else gAIScriptPtr += 5; @@ -889,7 +889,7 @@ static void ContestAICmd_unk_33(void) { ContestAICmd_unk_31(); - if (eContestAI->scriptResult > gAIScriptPtr[0]) + if (eContestAI.scriptResult > gAIScriptPtr[0]) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1); else gAIScriptPtr += 5; @@ -899,7 +899,7 @@ static void ContestAICmd_unk_34(void) { ContestAICmd_unk_31(); - if (eContestAI->scriptResult == gAIScriptPtr[0]) + if (eContestAI.scriptResult == gAIScriptPtr[0]) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1); else gAIScriptPtr += 5; @@ -909,7 +909,7 @@ static void ContestAICmd_unk_35(void) { ContestAICmd_unk_31(); - if (eContestAI->scriptResult != gAIScriptPtr[0]) + if (eContestAI.scriptResult != gAIScriptPtr[0]) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1); else gAIScriptPtr += 5; @@ -917,9 +917,9 @@ static void ContestAICmd_unk_35(void) static void ContestAICmd_unk_36(void) { - u16 move = gContestMons[eContestAI->contestantId].moves[eContestAI->nextMoveIndex]; + u16 move = gContestMons[eContestAI.contestantId].moves[eContestAI.nextMoveIndex]; - eContestAI->scriptResult = gContestEffects[gContestMoves[move].effect].jam / 10; + eContestAI.scriptResult = gContestEffects[gContestMoves[move].effect].jam / 10; gAIScriptPtr += 1; } @@ -927,7 +927,7 @@ static void ContestAICmd_unk_37(void) { ContestAICmd_unk_36(); - if (eContestAI->scriptResult < gAIScriptPtr[0]) + if (eContestAI.scriptResult < gAIScriptPtr[0]) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1); else gAIScriptPtr += 5; @@ -937,7 +937,7 @@ static void ContestAICmd_unk_38(void) { ContestAICmd_unk_36(); - if (eContestAI->scriptResult > gAIScriptPtr[0]) + if (eContestAI.scriptResult > gAIScriptPtr[0]) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1); else gAIScriptPtr += 5; @@ -947,7 +947,7 @@ static void ContestAICmd_unk_39(void) { ContestAICmd_unk_36(); - if (eContestAI->scriptResult == gAIScriptPtr[0]) + if (eContestAI.scriptResult == gAIScriptPtr[0]) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1); else gAIScriptPtr += 5; @@ -957,7 +957,7 @@ static void ContestAICmd_unk_3A(void) { ContestAICmd_unk_36(); - if (eContestAI->scriptResult != gAIScriptPtr[0]) + if (eContestAI.scriptResult != gAIScriptPtr[0]) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1); else gAIScriptPtr += 5; @@ -966,14 +966,14 @@ static void ContestAICmd_unk_3A(void) static void ContestAICmd_get_move_used_count(void) { s16 result; - u16 move = gContestMons[eContestAI->contestantId].moves[eContestAI->nextMoveIndex]; + u16 move = gContestMons[eContestAI.contestantId].moves[eContestAI.nextMoveIndex]; - if (move != sContestantStatus[eContestAI->contestantId].prevMove) + if (move != eContestantStatus[eContestAI.contestantId].prevMove) result = 0; // move is unique and not reused. else - result = sContestantStatus[eContestAI->contestantId].moveRepeatCount + 1; + result = eContestantStatus[eContestAI.contestantId].moveRepeatCount + 1; - eContestAI->scriptResult = result; + eContestAI.scriptResult = result; gAIScriptPtr += 1; } @@ -981,7 +981,7 @@ static void ContestAICmd_if_most_used_count_less_than(void) { ContestAICmd_get_move_used_count(); - if (eContestAI->scriptResult < gAIScriptPtr[0]) + if (eContestAI.scriptResult < gAIScriptPtr[0]) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1); else gAIScriptPtr += 5; @@ -991,7 +991,7 @@ static void ContestAICmd_if_most_used_count_more_than(void) { ContestAICmd_get_move_used_count(); - if (eContestAI->scriptResult > gAIScriptPtr[0]) + if (eContestAI.scriptResult > gAIScriptPtr[0]) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1); else gAIScriptPtr += 5; @@ -1001,7 +1001,7 @@ static void ContestAICmd_if_most_used_count_eq(void) { ContestAICmd_get_move_used_count(); - if (eContestAI->scriptResult == gAIScriptPtr[0]) + if (eContestAI.scriptResult == gAIScriptPtr[0]) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1); else gAIScriptPtr += 5; @@ -1011,7 +1011,7 @@ static void ContestAICmd_if_most_used_count_not_eq(void) { ContestAICmd_get_move_used_count(); - if (eContestAI->scriptResult != gAIScriptPtr[0]) + if (eContestAI.scriptResult != gAIScriptPtr[0]) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1); else gAIScriptPtr += 5; @@ -1021,13 +1021,13 @@ static void ContestAICmd_check_combo_starter(void) { u8 result = 0; int i; - u16 move = gContestMons[eContestAI->contestantId].moves[eContestAI->nextMoveIndex]; + u16 move = gContestMons[eContestAI.contestantId].moves[eContestAI.nextMoveIndex]; for (i = 0; i < MAX_MON_MOVES; i++) { - if (gContestMons[eContestAI->contestantId].moves[i]) + if (gContestMons[eContestAI.contestantId].moves[i]) { - result = AreMovesContestCombo(move, gContestMons[eContestAI->contestantId].moves[i]); + result = AreMovesContestCombo(move, gContestMons[eContestAI.contestantId].moves[i]); if (result) { result = 1; @@ -1039,7 +1039,7 @@ static void ContestAICmd_check_combo_starter(void) if (result) result = 1; - eContestAI->scriptResult = result; + eContestAI.scriptResult = result; gAIScriptPtr += 1; } @@ -1047,7 +1047,7 @@ static void ContestAICmd_if_combo_starter(void) { ContestAICmd_check_combo_starter(); - if (eContestAI->scriptResult != 0) + if (eContestAI.scriptResult != 0) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 0); else gAIScriptPtr += 4; @@ -1057,7 +1057,7 @@ static void ContestAICmd_if_not_combo_starter(void) { ContestAICmd_check_combo_starter(); - if (eContestAI->scriptResult == 0) + if (eContestAI.scriptResult == 0) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 0); else gAIScriptPtr += 4; @@ -1067,13 +1067,13 @@ static void ContestAICmd_check_combo_finisher(void) { u8 result = 0; int i; - u16 move = gContestMons[eContestAI->contestantId].moves[eContestAI->nextMoveIndex]; + u16 move = gContestMons[eContestAI.contestantId].moves[eContestAI.nextMoveIndex]; for (i = 0; i < MAX_MON_MOVES; i++) { - if (gContestMons[eContestAI->contestantId].moves[i]) + if (gContestMons[eContestAI.contestantId].moves[i]) { - result = AreMovesContestCombo(gContestMons[eContestAI->contestantId].moves[i], move); + result = AreMovesContestCombo(gContestMons[eContestAI.contestantId].moves[i], move); if (result) { result = 1; @@ -1085,7 +1085,7 @@ static void ContestAICmd_check_combo_finisher(void) if (result) result = 1; - eContestAI->scriptResult = result; + eContestAI.scriptResult = result; gAIScriptPtr += 1; } @@ -1093,7 +1093,7 @@ static void ContestAICmd_if_combo_finisher(void) { ContestAICmd_check_combo_finisher(); - if (eContestAI->scriptResult != 0) + if (eContestAI.scriptResult != 0) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 0); else gAIScriptPtr += 4; @@ -1103,7 +1103,7 @@ static void ContestAICmd_if_not_combo_finisher(void) { ContestAICmd_check_combo_finisher(); - if (eContestAI->scriptResult == 0) + if (eContestAI.scriptResult == 0) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 0); else gAIScriptPtr += 4; @@ -1112,15 +1112,15 @@ static void ContestAICmd_if_not_combo_finisher(void) static void ContestAICmd_check_would_finish_combo(void) { u8 result = 0; - u16 move = gContestMons[eContestAI->contestantId].moves[eContestAI->nextMoveIndex]; + u16 move = gContestMons[eContestAI.contestantId].moves[eContestAI.nextMoveIndex]; - if (sContestantStatus[eContestAI->contestantId].prevMove) - result = AreMovesContestCombo(sContestantStatus[eContestAI->contestantId].prevMove, move); + if (eContestantStatus[eContestAI.contestantId].prevMove) + result = AreMovesContestCombo(eContestantStatus[eContestAI.contestantId].prevMove, move); if (result) result = 1; - eContestAI->scriptResult = result; + eContestAI.scriptResult = result; gAIScriptPtr += 1; } @@ -1128,7 +1128,7 @@ static void ContestAICmd_if_would_finish_combo(void) { ContestAICmd_check_would_finish_combo(); - if (eContestAI->scriptResult != 0) + if (eContestAI.scriptResult != 0) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 0); else gAIScriptPtr += 4; @@ -1138,7 +1138,7 @@ static void ContestAICmd_if_would_not_finish_combo(void) { ContestAICmd_check_would_finish_combo(); - if (eContestAI->scriptResult == 0) + if (eContestAI.scriptResult == 0) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 0); else gAIScriptPtr += 4; @@ -1148,7 +1148,7 @@ static void ContestAICmd_get_condition(void) { int var = sub_81563B0(gAIScriptPtr[1]); - eContestAI->scriptResult = sContestantStatus[var].condition / 10; + eContestAI.scriptResult = eContestantStatus[var].condition / 10; gAIScriptPtr += 2; } @@ -1156,7 +1156,7 @@ static void ContestAICmd_if_condition_less_than(void) { ContestAICmd_get_condition(); - if (eContestAI->scriptResult < gAIScriptPtr[0]) + if (eContestAI.scriptResult < gAIScriptPtr[0]) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1); else gAIScriptPtr += 5; @@ -1166,7 +1166,7 @@ static void ContestAICmd_if_condition_more_than(void) { ContestAICmd_get_condition(); - if (eContestAI->scriptResult > gAIScriptPtr[0]) + if (eContestAI.scriptResult > gAIScriptPtr[0]) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1); else gAIScriptPtr += 5; @@ -1176,7 +1176,7 @@ static void ContestAICmd_if_condition_eq(void) { ContestAICmd_get_condition(); - if (eContestAI->scriptResult == gAIScriptPtr[0]) + if (eContestAI.scriptResult == gAIScriptPtr[0]) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1); else gAIScriptPtr += 5; @@ -1186,7 +1186,7 @@ static void ContestAICmd_if_condition_not_eq(void) { ContestAICmd_get_condition(); - if (eContestAI->scriptResult != gAIScriptPtr[0]) + if (eContestAI.scriptResult != gAIScriptPtr[0]) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1); else gAIScriptPtr += 5; @@ -1198,9 +1198,9 @@ static void ContestAICmd_get_used_combo_starter(void) u8 var = sub_81563B0(gAIScriptPtr[1]); if (sub_80DE1E8(var)) - result = gContestMoves[sContestantStatus[var].prevMove].comboStarterId ? 1 : 0; + result = gContestMoves[eContestantStatus[var].prevMove].comboStarterId ? 1 : 0; - eContestAI->scriptResult = result; + eContestAI.scriptResult = result; gAIScriptPtr += 2; } @@ -1208,7 +1208,7 @@ static void ContestAICmd_if_used_combo_starter_less_than(void) { ContestAICmd_get_used_combo_starter(); - if (eContestAI->scriptResult < gAIScriptPtr[0]) + if (eContestAI.scriptResult < gAIScriptPtr[0]) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1); else gAIScriptPtr += 5; @@ -1218,7 +1218,7 @@ static void ContestAICmd_if_used_combo_starter_more_than(void) { ContestAICmd_get_used_combo_starter(); - if (eContestAI->scriptResult > gAIScriptPtr[0]) + if (eContestAI.scriptResult > gAIScriptPtr[0]) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1); else gAIScriptPtr += 5; @@ -1228,7 +1228,7 @@ static void ContestAICmd_if_used_combo_starter_eq(void) { ContestAICmd_get_used_combo_starter(); - if (eContestAI->scriptResult == gAIScriptPtr[0]) + if (eContestAI.scriptResult == gAIScriptPtr[0]) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1); else gAIScriptPtr += 5; @@ -1238,7 +1238,7 @@ static void ContestAICmd_if_used_combo_starter_not_eq(void) { ContestAICmd_get_used_combo_starter(); - if (eContestAI->scriptResult != gAIScriptPtr[0]) + if (eContestAI.scriptResult != gAIScriptPtr[0]) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1); else gAIScriptPtr += 5; @@ -1247,9 +1247,9 @@ static void ContestAICmd_if_used_combo_starter_not_eq(void) static void ContestAICmd_check_can_participate(void) { if (Contest_IsMonsTurnDisabled(sub_81563B0(gAIScriptPtr[1]))) - eContestAI->scriptResult = FALSE; + eContestAI.scriptResult = FALSE; else - eContestAI->scriptResult = TRUE; + eContestAI.scriptResult = TRUE; gAIScriptPtr += 2; } @@ -1258,7 +1258,7 @@ static void ContestAICmd_if_can_participate(void) { ContestAICmd_check_can_participate(); - if (eContestAI->scriptResult != 0) + if (eContestAI.scriptResult != 0) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 0); else gAIScriptPtr += 4; @@ -1268,7 +1268,7 @@ static void ContestAICmd_if_cannot_participate(void) { ContestAICmd_check_can_participate(); - if (eContestAI->scriptResult == 0) + if (eContestAI.scriptResult == 0) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 0); else gAIScriptPtr += 4; @@ -1278,7 +1278,7 @@ static void ContestAICmd_get_val_812A188(void) { u8 var = sub_81563B0(gAIScriptPtr[1]); - eContestAI->scriptResult = sContestantStatus[var].unk15_3; + eContestAI.scriptResult = eContestantStatus[var].unk15_3; gAIScriptPtr += 2; } @@ -1286,7 +1286,7 @@ static void ContestAICmd_unk_57(void) { ContestAICmd_get_val_812A188(); - if (eContestAI->scriptResult != 0) + if (eContestAI.scriptResult != 0) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 0); else gAIScriptPtr += 4; @@ -1296,7 +1296,7 @@ static void ContestAICmd_contest_58(void) { ContestAICmd_get_val_812A188(); - if (eContestAI->scriptResult == 0) + if (eContestAI.scriptResult == 0) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 0); else gAIScriptPtr += 4; @@ -1306,7 +1306,7 @@ static void ContestAICmd_unk_59(void) { u8 var = sub_81563B0(gAIScriptPtr[1]); - eContestAI->scriptResult = sContestantStatus[var].unk4 - sContestantStatus[eContestAI->contestantId].unk4; + eContestAI.scriptResult = eContestantStatus[var].pointTotal - eContestantStatus[eContestAI.contestantId].pointTotal; gAIScriptPtr += 2; } @@ -1314,7 +1314,7 @@ static void ContestAICmd_unk_5A(void) { ContestAICmd_unk_59(); - if (eContestAI->scriptResult < 0) + if (eContestAI.scriptResult < 0) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 0); else gAIScriptPtr += 4; @@ -1324,7 +1324,7 @@ static void ContestAICmd_unk_5B(void) { ContestAICmd_unk_59(); - if (eContestAI->scriptResult > 0) + if (eContestAI.scriptResult > 0) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 0); else gAIScriptPtr += 4; @@ -1334,7 +1334,7 @@ static void ContestAICmd_unk_5C(void) { ContestAICmd_unk_59(); - if (eContestAI->scriptResult == 0) + if (eContestAI.scriptResult == 0) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 0); else gAIScriptPtr += 4; @@ -1344,7 +1344,7 @@ static void ContestAICmd_unk_5D(void) { ContestAICmd_unk_59(); - if (eContestAI->scriptResult != 0) + if (eContestAI.scriptResult != 0) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 0); else gAIScriptPtr += 4; @@ -1354,7 +1354,7 @@ static void ContestAICmd_unk_5E(void) { u8 var = sub_81563B0(gAIScriptPtr[1]); - eContestAI->scriptResult = gContestMonConditions[var] - gContestMonConditions[eContestAI->contestantId]; + eContestAI.scriptResult = gContestMonConditions[var] - gContestMonConditions[eContestAI.contestantId]; gAIScriptPtr += 2; } @@ -1362,7 +1362,7 @@ static void ContestAICmd_unk_5F(void) { ContestAICmd_unk_5E(); - if (eContestAI->scriptResult < 0) + if (eContestAI.scriptResult < 0) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 0); else gAIScriptPtr += 4; @@ -1372,7 +1372,7 @@ static void ContestAICmd_unk_60(void) { ContestAICmd_unk_5E(); - if (eContestAI->scriptResult > 0) + if (eContestAI.scriptResult > 0) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 0); else gAIScriptPtr += 4; @@ -1382,7 +1382,7 @@ static void ContestAICmd_unk_61(void) { ContestAICmd_unk_5E(); - if (eContestAI->scriptResult == 0) + if (eContestAI.scriptResult == 0) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 0); else gAIScriptPtr += 4; @@ -1392,7 +1392,7 @@ static void ContestAICmd_unk_62(void) { ContestAICmd_unk_5E(); - if (eContestAI->scriptResult != 0) + if (eContestAI.scriptResult != 0) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 0); else gAIScriptPtr += 4; @@ -1402,9 +1402,9 @@ static void ContestAICmd_unk_63(void) { u8 var = sub_81563B0(gAIScriptPtr[1]); u8 var2 = gAIScriptPtr[2]; - u16 move = sContest.unk19220[var2][var]; + u16 move = eContest.unk19220[var2][var]; - eContestAI->scriptResult = gContestMoves[move].effect; + eContestAI.scriptResult = gContestMoves[move].effect; gAIScriptPtr += 3; } @@ -1412,7 +1412,7 @@ static void ContestAICmd_unk_64(void) { ContestAICmd_unk_63(); - if (eContestAI->scriptResult < gAIScriptPtr[0]) + if (eContestAI.scriptResult < gAIScriptPtr[0]) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1); else gAIScriptPtr += 5; @@ -1422,7 +1422,7 @@ static void ContestAICmd_unk_65(void) { ContestAICmd_unk_63(); - if (eContestAI->scriptResult > gAIScriptPtr[0]) + if (eContestAI.scriptResult > gAIScriptPtr[0]) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1); else gAIScriptPtr += 5; @@ -1432,7 +1432,7 @@ static void ContestAICmd_unk_66(void) { ContestAICmd_unk_63(); - if (eContestAI->scriptResult == gAIScriptPtr[0]) + if (eContestAI.scriptResult == gAIScriptPtr[0]) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1); else gAIScriptPtr += 5; @@ -1442,7 +1442,7 @@ static void ContestAICmd_unk_67(void) { ContestAICmd_unk_63(); - if (eContestAI->scriptResult != gAIScriptPtr[0]) + if (eContestAI.scriptResult != gAIScriptPtr[0]) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1); else gAIScriptPtr += 5; @@ -1452,9 +1452,9 @@ static void ContestAICmd_unk_68(void) { u8 var = sub_81563B0(gAIScriptPtr[1]); u8 var2 = gAIScriptPtr[2]; - s8 result = sContest.unk19248[var2][var]; + s8 result = eContest.unk19248[var2][var]; - eContestAI->scriptResult = result; + eContestAI.scriptResult = result; gAIScriptPtr += 3; } @@ -1462,7 +1462,7 @@ static void ContestAICmd_unk_69(void) { ContestAICmd_unk_68(); - if (eContestAI->scriptResult < gAIScriptPtr[0]) + if (eContestAI.scriptResult < gAIScriptPtr[0]) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1); else gAIScriptPtr += 5; @@ -1472,7 +1472,7 @@ static void ContestAICmd_unk_6A(void) { ContestAICmd_unk_68(); - if (eContestAI->scriptResult > gAIScriptPtr[0]) + if (eContestAI.scriptResult > gAIScriptPtr[0]) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1); else gAIScriptPtr += 5; @@ -1482,7 +1482,7 @@ static void ContestAICmd_unk_6B(void) { ContestAICmd_unk_68(); - if (eContestAI->scriptResult == gAIScriptPtr[0]) + if (eContestAI.scriptResult == gAIScriptPtr[0]) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1); else gAIScriptPtr += 5; @@ -1492,7 +1492,7 @@ static void ContestAICmd_unk_6C(void) { ContestAICmd_unk_68(); - if (eContestAI->scriptResult != gAIScriptPtr[0]) + if (eContestAI.scriptResult != gAIScriptPtr[0]) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1); else gAIScriptPtr += 5; @@ -1502,9 +1502,9 @@ static void ContestAICmd_unk_6D(void) { u8 var = sub_81563B0(gAIScriptPtr[1]); u8 var2 = gAIScriptPtr[2]; - u16 move = sContest.unk19220[var2][var]; + u16 move = eContest.unk19220[var2][var]; - eContestAI->scriptResult = gContestEffects[gContestMoves[move].effect].effectType; + eContestAI.scriptResult = gContestEffects[gContestMoves[move].effect].effectType; gAIScriptPtr += 3; } @@ -1512,7 +1512,7 @@ static void ContestAICmd_unk_6E(void) { ContestAICmd_unk_6D(); - if (eContestAI->scriptResult == gAIScriptPtr[0]) + if (eContestAI.scriptResult == gAIScriptPtr[0]) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1); else gAIScriptPtr += 5; @@ -1522,7 +1522,7 @@ static void ContestAICmd_unk_6F(void) { ContestAICmd_unk_6D(); - if (eContestAI->scriptResult != gAIScriptPtr[0]) + if (eContestAI.scriptResult != gAIScriptPtr[0]) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1); else gAIScriptPtr += 5; @@ -1530,38 +1530,38 @@ static void ContestAICmd_unk_6F(void) static void ContestAICmd_unk_70(void) { - eContestAI->scriptArr[gAIScriptPtr[1]] = eContestAI->scriptResult; + eContestAI.scriptArr[gAIScriptPtr[1]] = eContestAI.scriptResult; gAIScriptPtr += 2; } static void ContestAICmd_unk_71(void) { - eContestAI->scriptArr[gAIScriptPtr[1]] = T1_READ_16(gAIScriptPtr + 2); + eContestAI.scriptArr[gAIScriptPtr[1]] = T1_READ_16(gAIScriptPtr + 2); gAIScriptPtr += 4; } static void ContestAICmd_unk_72(void) { // wtf? shouldn't T1_READ_16 work here? why the signed 8 load by gAIScriptPtr[2]? - eContestAI->scriptArr[gAIScriptPtr[1]] += ((s8)gAIScriptPtr[2] | gAIScriptPtr[3] << 8); + eContestAI.scriptArr[gAIScriptPtr[1]] += ((s8)gAIScriptPtr[2] | gAIScriptPtr[3] << 8); gAIScriptPtr += 4; } static void ContestAICmd_unk_73(void) { - eContestAI->scriptArr[gAIScriptPtr[1]] += eContestAI->scriptArr[gAIScriptPtr[2]]; + eContestAI.scriptArr[gAIScriptPtr[1]] += eContestAI.scriptArr[gAIScriptPtr[2]]; gAIScriptPtr += 3; } static void ContestAICmd_unk_74(void) { - eContestAI->scriptArr[gAIScriptPtr[1]] += eContestAI->scriptArr[gAIScriptPtr[2]]; + eContestAI.scriptArr[gAIScriptPtr[1]] += eContestAI.scriptArr[gAIScriptPtr[2]]; gAIScriptPtr += 3; } static void ContestAICmd_unk_75(void) { - if (eContestAI->scriptArr[gAIScriptPtr[1]] < T1_READ_16(gAIScriptPtr + 2)) + if (eContestAI.scriptArr[gAIScriptPtr[1]] < T1_READ_16(gAIScriptPtr + 2)) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 4); else gAIScriptPtr += 8; @@ -1569,7 +1569,7 @@ static void ContestAICmd_unk_75(void) static void ContestAICmd_unk_76(void) { - if (eContestAI->scriptArr[gAIScriptPtr[1]] > T1_READ_16(gAIScriptPtr + 2)) + if (eContestAI.scriptArr[gAIScriptPtr[1]] > T1_READ_16(gAIScriptPtr + 2)) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 4); else gAIScriptPtr += 8; @@ -1577,7 +1577,7 @@ static void ContestAICmd_unk_76(void) static void ContestAICmd_unk_77(void) { - if (eContestAI->scriptArr[gAIScriptPtr[1]] == T1_READ_16(gAIScriptPtr + 2)) + if (eContestAI.scriptArr[gAIScriptPtr[1]] == T1_READ_16(gAIScriptPtr + 2)) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 4); else gAIScriptPtr += 8; @@ -1585,7 +1585,7 @@ static void ContestAICmd_unk_77(void) static void ContestAICmd_unk_78(void) { - if (eContestAI->scriptArr[gAIScriptPtr[1]] != T1_READ_16(gAIScriptPtr + 2)) + if (eContestAI.scriptArr[gAIScriptPtr[1]] != T1_READ_16(gAIScriptPtr + 2)) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 4); else gAIScriptPtr += 8; @@ -1593,7 +1593,7 @@ static void ContestAICmd_unk_78(void) static void ContestAICmd_unk_79(void) { - if (eContestAI->scriptArr[gAIScriptPtr[1]] < (eContestAI->scriptArr[gAIScriptPtr[2]])) + if (eContestAI.scriptArr[gAIScriptPtr[1]] < (eContestAI.scriptArr[gAIScriptPtr[2]])) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 3); else gAIScriptPtr += 7; @@ -1601,7 +1601,7 @@ static void ContestAICmd_unk_79(void) static void ContestAICmd_unk_7A(void) { - if (eContestAI->scriptArr[gAIScriptPtr[1]] > (eContestAI->scriptArr[gAIScriptPtr[2]])) + if (eContestAI.scriptArr[gAIScriptPtr[1]] > (eContestAI.scriptArr[gAIScriptPtr[2]])) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 3); else gAIScriptPtr += 7; @@ -1609,7 +1609,7 @@ static void ContestAICmd_unk_7A(void) static void ContestAICmd_unk_7B(void) { - if (eContestAI->scriptArr[gAIScriptPtr[1]] == (eContestAI->scriptArr[gAIScriptPtr[2]])) + if (eContestAI.scriptArr[gAIScriptPtr[1]] == (eContestAI.scriptArr[gAIScriptPtr[2]])) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 3); else gAIScriptPtr += 7; @@ -1617,7 +1617,7 @@ static void ContestAICmd_unk_7B(void) static void ContestAICmd_unk_7C(void) { - if (eContestAI->scriptArr[gAIScriptPtr[1]] != (eContestAI->scriptArr[gAIScriptPtr[2]])) + if (eContestAI.scriptArr[gAIScriptPtr[1]] != (eContestAI.scriptArr[gAIScriptPtr[2]])) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 3); else gAIScriptPtr += 7; @@ -1625,7 +1625,7 @@ static void ContestAICmd_unk_7C(void) static void ContestAICmd_if_random(void) { - if ((Random() & 0xFF) < eContestAI->scriptArr[gAIScriptPtr[1]]) + if ((Random() & 0xFF) < eContestAI.scriptArr[gAIScriptPtr[1]]) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 2); else gAIScriptPtr += 6; @@ -1633,7 +1633,7 @@ static void ContestAICmd_if_random(void) static void ContestAICmd_unk_7E(void) { - if ((Random() & 0xFF) > eContestAI->scriptArr[gAIScriptPtr[1]]) + if ((Random() & 0xFF) > eContestAI.scriptArr[gAIScriptPtr[1]]) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 2); else gAIScriptPtr += 6; @@ -1654,20 +1654,20 @@ static void ContestAICmd_call(void) static void ContestAICmd_end(void) { if (!AIStackPop()) - eContestAI->aiAction |= 1; + eContestAI.aiAction |= 1; } static void AIStackPushVar(const u8 *ptr) { - eContestAI->stack[eContestAI->stackSize++] = ptr; + eContestAI.stack[eContestAI.stackSize++] = ptr; } static bool8 AIStackPop(void) { - if (eContestAI->stackSize != 0) + if (eContestAI.stackSize != 0) { - --eContestAI->stackSize; - gAIScriptPtr = eContestAI->stack[eContestAI->stackSize]; + --eContestAI.stackSize; + gAIScriptPtr = eContestAI.stack[eContestAI.stackSize]; return TRUE; } else @@ -1683,9 +1683,9 @@ static void ContestAICmd_check_user_has_exciting_move(void) for (i = 0; i < MAX_MON_MOVES; i++) { - if (gContestMons[eContestAI->contestantId].moves[i]) + if (gContestMons[eContestAI.contestantId].moves[i]) { - if (Contest_GetMoveExcitement(gContestMons[eContestAI->contestantId].moves[i]) == 1) + if (Contest_GetMoveExcitement(gContestMons[eContestAI.contestantId].moves[i]) == 1) { result = 1; break; @@ -1693,7 +1693,7 @@ static void ContestAICmd_check_user_has_exciting_move(void) } } - eContestAI->scriptResult = result; + eContestAI.scriptResult = result; gAIScriptPtr += 1; } @@ -1701,7 +1701,7 @@ static void ContestAICmd_if_user_has_exciting_move(void) { ContestAICmd_check_user_has_exciting_move(); - if (eContestAI->scriptResult != 0) + if (eContestAI.scriptResult != 0) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 0); else gAIScriptPtr += 4; @@ -1711,7 +1711,7 @@ static void ContestAICmd_if_user_doesnt_have_exciting_move(void) { ContestAICmd_check_user_has_exciting_move(); - if (eContestAI->scriptResult == 0) + if (eContestAI.scriptResult == 0) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 0); else gAIScriptPtr += 4; @@ -1725,7 +1725,7 @@ static void ContestAICmd_unk_85(void) for (i = 0; i < MAX_MON_MOVES; i++) { - u16 move = gContestMons[eContestAI->contestantId].moves[i]; + u16 move = gContestMons[eContestAI.contestantId].moves[i]; if (move == arg) { result = 1; @@ -1733,7 +1733,7 @@ static void ContestAICmd_unk_85(void) } } - eContestAI->scriptResult = result; + eContestAI.scriptResult = result; gAIScriptPtr += 3; } @@ -1741,7 +1741,7 @@ static void ContestAICmd_unk_86(void) { ContestAICmd_unk_85(); - if (eContestAI->scriptResult != 0) + if (eContestAI.scriptResult != 0) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 0); else gAIScriptPtr += 4; @@ -1751,7 +1751,7 @@ static void ContestAICmd_if_effect_in_user_moveset(void) { ContestAICmd_unk_85(); - if (eContestAI->scriptResult == 0) + if (eContestAI.scriptResult == 0) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 0); else gAIScriptPtr += 4; diff --git a/src/contest_effect.c b/src/contest_effect.c index 760d74d69..369850bb4 100644 --- a/src/contest_effect.c +++ b/src/contest_effect.c @@ -82,101 +82,101 @@ static void ContestEffect_HighlyAppealing(void) // After this move, the user is more easily startled. static void ContestEffect_UserMoreEasilyStartled(void) { - sContestantStatus[shared192D0.contestant].moreEasilyStartled = TRUE; - SetContestantEffectStringID(shared192D0.contestant, CONTEST_STRING_MORE_CONSCIOUS); + eContestantStatus[eContestResources8.contestant].moreEasilyStartled = TRUE; + SetContestantEffectStringID(eContestResources8.contestant, CONTEST_STRING_MORE_CONSCIOUS); } // Makes a great appeal, but allows no more to the end. static void ContestEffect_GreatAppealButNoMoreMoves(void) { - sContestantStatus[shared192D0.contestant].exploded = TRUE; - SetContestantEffectStringID(shared192D0.contestant, CONTEST_STRING_NO_APPEAL); + eContestantStatus[eContestResources8.contestant].exploded = TRUE; + SetContestantEffectStringID(eContestResources8.contestant, CONTEST_STRING_NO_APPEAL); } // Can be used repeatedly without boring the JUDGE. static void ContestEffect_RepetitionNotBoring(void) { - sContestantStatus[shared192D0.contestant].usedRepeatableMove = TRUE; - sContestantStatus[shared192D0.contestant].disappointedRepeat = FALSE; - sContestantStatus[shared192D0.contestant].moveRepeatCount = 0; + eContestantStatus[eContestResources8.contestant].usedRepeatableMove = TRUE; + eContestantStatus[eContestResources8.contestant].disappointedRepeat = FALSE; + eContestantStatus[eContestResources8.contestant].moveRepeatCount = 0; } // Can avoid being startled by others once. static void ContestEffect_AvoidStartleOnce(void) { - sContestantStatus[shared192D0.contestant].jamSafetyCount = 1; - SetContestantEffectStringID(shared192D0.contestant, CONTEST_STRING_SETTLE_DOWN); + eContestantStatus[eContestResources8.contestant].jamSafetyCount = 1; + SetContestantEffectStringID(eContestResources8.contestant, CONTEST_STRING_SETTLE_DOWN); } // Can avoid being startled by others. static void ContestEffect_AvoidStartle(void) { - sContestantStatus[shared192D0.contestant].immune = TRUE; - SetContestantEffectStringID(shared192D0.contestant, CONTEST_STRING_OBLIVIOUS_TO_OTHERS); + eContestantStatus[eContestResources8.contestant].immune = TRUE; + SetContestantEffectStringID(eContestResources8.contestant, CONTEST_STRING_OBLIVIOUS_TO_OTHERS); } // Can avoid being startled by others a little. static void ContestEffect_AvoidStartleSlightly(void) { - sContestantStatus[shared192D0.contestant].jamReduction = 20; - SetContestantEffectStringID(shared192D0.contestant,CONTEST_STRING_LESS_AWARE); + eContestantStatus[eContestResources8.contestant].jamReduction = 20; + SetContestantEffectStringID(eContestResources8.contestant,CONTEST_STRING_LESS_AWARE); } // After this move, the user is less likely to be startled. static void ContestEffect_UserLessEasilyStartled(void) { - sContestantStatus[shared192D0.contestant].resistant = TRUE; - SetContestantEffectStringID(shared192D0.contestant,CONTEST_STRING_STOPPED_CARING); + eContestantStatus[eContestResources8.contestant].resistant = TRUE; + SetContestantEffectStringID(eContestResources8.contestant,CONTEST_STRING_STOPPED_CARING); } -// Slightly startles the POKéMON in front. +// Slightly startles the POK�MON in front. static void ContestEffect_StartleFrontMon(void) { u8 idx = 0; - u8 a = shared192D0.contestant; + u8 a = eContestResources8.contestant; - if (shared192D0.turnOrder[a] != 0) { + if (eContestResources8.turnOrder[a] != 0) { int i; for (i = 0; i < 4; i++) { - if (shared192D0.turnOrder[a] - 1 == shared192D0.turnOrder[i]) + if (eContestResources8.turnOrder[a] - 1 == eContestResources8.turnOrder[i]) break; } - shared192D0.jamQueue[0] = i; - shared192D0.jamQueue[1] = 0xFF; + eContestResources8.jamQueue[0] = i; + eContestResources8.jamQueue[1] = 0xFF; idx = WasAtLeastOneOpponentJammed(); } if (idx == 0) - SetContestantEffectStringID2(shared192D0.contestant, CONTEST_STRING_MESSED_UP2); - SetContestantEffectStringID(shared192D0.contestant, CONTEST_STRING_ATTEMPT_STARTLE); + SetContestantEffectStringID2(eContestResources8.contestant, CONTEST_STRING_MESSED_UP2); + SetContestantEffectStringID(eContestResources8.contestant, CONTEST_STRING_ATTEMPT_STARTLE); } // Slightly startles those that have made appeals. static void ContestEffect_StartlePrevMons(void) { u8 idx = 0; - u8 a = shared192D0.contestant; + u8 a = eContestResources8.contestant; - if (shared192D0.turnOrder[a] != 0) + if (eContestResources8.turnOrder[a] != 0) { int i, j; for (i = 0, j = 0; i < 4; i++) { - if (shared192D0.turnOrder[a] > shared192D0.turnOrder[i]) - shared192D0.jamQueue[j++] = i; + if (eContestResources8.turnOrder[a] > eContestResources8.turnOrder[i]) + eContestResources8.jamQueue[j++] = i; } - shared192D0.jamQueue[j] = 0xFF; + eContestResources8.jamQueue[j] = 0xFF; idx = WasAtLeastOneOpponentJammed(); } if (idx == 0) - SetContestantEffectStringID2(shared192D0.contestant, CONTEST_STRING_MESSED_UP2); - SetContestantEffectStringID(shared192D0.contestant, CONTEST_STRING_ATTEMPT_STARTLE); + SetContestantEffectStringID2(eContestResources8.contestant, CONTEST_STRING_MESSED_UP2); + SetContestantEffectStringID(eContestResources8.contestant, CONTEST_STRING_ATTEMPT_STARTLE); } -// Startles the POKéMON that appealed before the user. +// Startles the POK�MON that appealed before the user. static void ContestEffect_StartlePrevMon2(void) { u8 rval = Random() % 10; @@ -189,16 +189,16 @@ static void ContestEffect_StartlePrevMon2(void) else jam = 60; - shared192D0.jam = jam; + eContestResources8.jam = jam; ContestEffect_StartleFrontMon(); } -// Startles all POKéMON that appealed before the user. +// Startles all POK�MON that appealed before the user. static void ContestEffect_StartlePrevMons2(void) { u8 numStartled = 0; - u8 contestant = shared192D0.contestant; - u8 turnOrder = shared192D0.turnOrder[contestant]; + u8 contestant = eContestResources8.contestant; + u8 turnOrder = eContestResources8.turnOrder[contestant]; if (turnOrder != 0) { @@ -206,12 +206,12 @@ static void ContestEffect_StartlePrevMons2(void) for (i = 0; i < 4; i++) { - if (shared192D0.turnOrder[contestant] > shared192D0.turnOrder[i]) + if (eContestResources8.turnOrder[contestant] > eContestResources8.turnOrder[i]) { u8 rval, jam; - shared192D0.jamQueue[0] = i; - shared192D0.jamQueue[1] = 0xFF; + eContestResources8.jamQueue[0] = i; + eContestResources8.jamQueue[1] = 0xFF; rval = Random() % 10; if (rval == 0) @@ -227,141 +227,141 @@ static void ContestEffect_StartlePrevMons2(void) else jam = 60; - shared192D0.jam = jam; + eContestResources8.jam = jam; if (WasAtLeastOneOpponentJammed()) numStartled++; } } } - SetContestantEffectStringID(shared192D0.contestant, CONTEST_STRING_ATTEMPT_STARTLE); + SetContestantEffectStringID(eContestResources8.contestant, CONTEST_STRING_ATTEMPT_STARTLE); if (numStartled == 0) - SetContestantEffectStringID2(shared192D0.contestant, CONTEST_STRING_MESSED_UP2); + SetContestantEffectStringID2(eContestResources8.contestant, CONTEST_STRING_MESSED_UP2); } -// Shifts the JUDGE’s attention from others. +// Shifts the JUDGE�s attention from others. static void ContestEffect_ShiftJudgeAttention(void) { bool32 hitAny = FALSE; - u8 contestant = shared192D0.contestant; + u8 contestant = eContestResources8.contestant; - if (shared192D0.turnOrder[shared192D0.contestant] != 0) + if (eContestResources8.turnOrder[eContestResources8.contestant] != 0) { int i; for (i = 0; i < 4; i++) { - if (shared192D0.turnOrder[contestant] > shared192D0.turnOrder[i] && - sContestantStatus[i].hasJudgesAttention && + if (eContestResources8.turnOrder[contestant] > eContestResources8.turnOrder[i] && + eContestantStatus[i].hasJudgesAttention && CanUnnerveContestant(i)) { - sContestantStatus[i].hasJudgesAttention = FALSE; - sContestantStatus[i].judgesAttentionWasRemoved = TRUE; + eContestantStatus[i].hasJudgesAttention = FALSE; + eContestantStatus[i].judgesAttentionWasRemoved = TRUE; SetContestantEffectStringID(i, CONTEST_STRING_JUDGE_LOOK_AWAY2); hitAny = TRUE; } } } - SetContestantEffectStringID(shared192D0.contestant,CONTEST_STRING_DAZZLE_ATTEMPT); + SetContestantEffectStringID(eContestResources8.contestant,CONTEST_STRING_DAZZLE_ATTEMPT); if (!hitAny) { - SetContestantEffectStringID2(shared192D0.contestant, CONTEST_STRING_MESSED_UP2); + SetContestantEffectStringID2(eContestResources8.contestant, CONTEST_STRING_MESSED_UP2); } } -// Startles the POKéMON that has the JUDGE’s attention. +// Startles the POK�MON that has the JUDGE�s attention. static void ContestEffect_StartleMonWithJudgesAttention(void) { u8 numStartled = 0; - u8 contestant = shared192D0.contestant; + u8 contestant = eContestResources8.contestant; - if (shared192D0.turnOrder[shared192D0.contestant] != 0) + if (eContestResources8.turnOrder[eContestResources8.contestant] != 0) { int i; for (i = 0; i < 4; i++) { - if (shared192D0.turnOrder[contestant] > shared192D0.turnOrder[i]) + if (eContestResources8.turnOrder[contestant] > eContestResources8.turnOrder[i]) { - if (sContestantStatus[i].hasJudgesAttention) - shared192D0.jam = 50; + if (eContestantStatus[i].hasJudgesAttention) + eContestResources8.jam = 50; else - shared192D0.jam = 10; - shared192D0.jamQueue[0] = i; - shared192D0.jamQueue[1] = 0xFF; + eContestResources8.jam = 10; + eContestResources8.jamQueue[0] = i; + eContestResources8.jamQueue[1] = 0xFF; if (WasAtLeastOneOpponentJammed()) numStartled++; } } } - SetContestantEffectStringID(shared192D0.contestant, CONTEST_STRING_ATTEMPT_STARTLE); + SetContestantEffectStringID(eContestResources8.contestant, CONTEST_STRING_ATTEMPT_STARTLE); if (numStartled == 0) - SetContestantEffectStringID2(shared192D0.contestant, CONTEST_STRING_MESSED_UP2); + SetContestantEffectStringID2(eContestResources8.contestant, CONTEST_STRING_MESSED_UP2); } // Jams the others, and misses one turn of appeals. static void ContestEffect_JamsOthersButMissOneTurn(void) { - sContestantStatus[shared192D0.contestant].turnSkipped = TRUE; + eContestantStatus[eContestResources8.contestant].turnSkipped = TRUE; ContestEffect_StartlePrevMons(); - SetContestantEffectStringID(shared192D0.contestant, CONTEST_STRING_ATTEMPT_STARTLE); + SetContestantEffectStringID(eContestResources8.contestant, CONTEST_STRING_ATTEMPT_STARTLE); } -// Startles POKéMON that made a same-type appeal. +// Startles POK�MON that made a same-type appeal. static void ContestEffect_StartleMonsSameTypeAppeal(void) { - u16 move = sContestantStatus[shared192D0.contestant].currMove; + u16 move = eContestantStatus[eContestResources8.contestant].currMove; JamByMoveCategory(gContestMoves[move].contestCategory); - SetContestantEffectStringID(shared192D0.contestant, CONTEST_STRING_ATTEMPT_STARTLE); + SetContestantEffectStringID(eContestResources8.contestant, CONTEST_STRING_ATTEMPT_STARTLE); } -// Badly startles POKéMON that made COOL appeals. +// Badly startles POK�MON that made COOL appeals. static void ContestEffect_StartleMonsCoolAppeal(void) { JamByMoveCategory(CONTEST_CATEGORY_COOL); - SetContestantEffectStringID(shared192D0.contestant, CONTEST_STRING_ATTEMPT_STARTLE); + SetContestantEffectStringID(eContestResources8.contestant, CONTEST_STRING_ATTEMPT_STARTLE); } -// Badly startles POKéMON that made BEAUTY appeals. +// Badly startles POK�MON that made BEAUTY appeals. static void ContestEffect_StartleMonsBeautyAppeal(void) { JamByMoveCategory(CONTEST_CATEGORY_BEAUTY); - SetContestantEffectStringID(shared192D0.contestant, CONTEST_STRING_ATTEMPT_STARTLE); + SetContestantEffectStringID(eContestResources8.contestant, CONTEST_STRING_ATTEMPT_STARTLE); } -// Badly startles POKéMON that made CUTE appeals. +// Badly startles POK�MON that made CUTE appeals. static void ContestEffect_StartleMonsCuteAppeal(void) { JamByMoveCategory(CONTEST_CATEGORY_CUTE); - SetContestantEffectStringID(shared192D0.contestant, CONTEST_STRING_ATTEMPT_STARTLE); + SetContestantEffectStringID(eContestResources8.contestant, CONTEST_STRING_ATTEMPT_STARTLE); } -// Badly startles POKéMON that made SMART appeals. +// Badly startles POK�MON that made SMART appeals. static void ContestEffect_StartleMonsSmartAppeal(void) { JamByMoveCategory(CONTEST_CATEGORY_SMART); - SetContestantEffectStringID(shared192D0.contestant, CONTEST_STRING_ATTEMPT_STARTLE); + SetContestantEffectStringID(eContestResources8.contestant, CONTEST_STRING_ATTEMPT_STARTLE); } -// Badly startles POKéMON that made TOUGH appeals. +// Badly startles POK�MON that made TOUGH appeals. static void ContestEffect_StartleMonsToughAppeal(void) { JamByMoveCategory(CONTEST_CATEGORY_TOUGH); - SetContestantEffectStringID(shared192D0.contestant, CONTEST_STRING_ATTEMPT_STARTLE); + SetContestantEffectStringID(eContestResources8.contestant, CONTEST_STRING_ATTEMPT_STARTLE); } -// Makes one POKéMON after the user nervous. +// Makes one POK�MON after the user nervous. static void ContestEffect_MakeFollowingMonNervous(void) { bool32 hitAny = FALSE; - if (shared192D0.turnOrder[shared192D0.contestant] != 3) + if (eContestResources8.turnOrder[eContestResources8.contestant] != 3) { int i; for (i = 0; i < 4; i++) { - if (shared192D0.turnOrder[shared192D0.contestant] + 1 == shared192D0.turnOrder[i]) + if (eContestResources8.turnOrder[eContestResources8.contestant] + 1 == eContestResources8.turnOrder[i]) { if (CanUnnerveContestant(i)) { @@ -377,12 +377,12 @@ static void ContestEffect_MakeFollowingMonNervous(void) } } } - SetContestantEffectStringID(shared192D0.contestant, CONTEST_STRING_UNNERVE_ATTEMPT); + SetContestantEffectStringID(eContestResources8.contestant, CONTEST_STRING_UNNERVE_ATTEMPT); if (!hitAny) - SetContestantEffectStringID2(shared192D0.contestant, CONTEST_STRING_MESSED_UP2); + SetContestantEffectStringID2(eContestResources8.contestant, CONTEST_STRING_MESSED_UP2); } -// Makes all POKéMON after the user nervous. +// Makes all POK�MON after the user nervous. static void ContestEffect_MakeFollowingMonsNervous(void) { u8 numUnnerved = 0; @@ -396,8 +396,8 @@ static void ContestEffect_MakeFollowingMonsNervous(void) memset(contestantIds, 0xFF, ARRAY_COUNT(contestantIds)); for (i = 0, numAfter = 0; i < 4; i++) { - if (shared192D0.turnOrder[shared192D0.contestant] < shared192D0.turnOrder[i] && - !sContestantStatus[i].nervous && !Contest_IsMonsTurnDisabled(i)) + if (eContestResources8.turnOrder[eContestResources8.contestant] < eContestResources8.turnOrder[i] && + !eContestantStatus[i].nervous && !Contest_IsMonsTurnDisabled(i)) contestantIds[numAfter++] = i; } @@ -423,11 +423,11 @@ static void ContestEffect_MakeFollowingMonsNervous(void) } for (i = 0; i < 4; i++) { - if (sContestantStatus[i].hasJudgesAttention && sub_80DE1E8(i)) - oddsMod[i] = gComboStarterLookupTable[gContestMoves[sContestantStatus[i].prevMove].comboStarterId] * 10; + if (eContestantStatus[i].hasJudgesAttention && sub_80DE1E8(i)) + oddsMod[i] = gComboStarterLookupTable[gContestMoves[eContestantStatus[i].prevMove].comboStarterId] * 10; else oddsMod[i] = 0; - oddsMod[i] -= (sContestantStatus[i].condition / 10) * 10; + oddsMod[i] -= (eContestantStatus[i].condition / 10) * 10; } if (odds[0] != 0) { @@ -457,12 +457,12 @@ static void ContestEffect_MakeFollowingMonsNervous(void) SetContestantEffectStringID(contestantIds[i], CONTEST_STRING_UNAFFECTED); numUnnerved++; } - shared192D0.unnervedPokes[contestantIds[i]] = 1; + eContestResources8.unnervedPokes[contestantIds[i]] = 1; } } - SetContestantEffectStringID(shared192D0.contestant, CONTEST_STRING_UNNERVE_WAITING); + SetContestantEffectStringID(eContestResources8.contestant, CONTEST_STRING_UNNERVE_WAITING); if (numUnnerved == 0) - SetContestantEffectStringID2(shared192D0.contestant, CONTEST_STRING_MESSED_UP2); + SetContestantEffectStringID2(eContestResources8.contestant, CONTEST_STRING_MESSED_UP2); } // Worsens the condition of those that made appeals. @@ -473,23 +473,23 @@ static void ContestEffect_WorsenConditionOfPrevMons(void) for (i = 0; i < 4; i++) { - if (shared192D0.turnOrder[shared192D0.contestant] > shared192D0.turnOrder[i] && - sContestantStatus[i].condition > 0 && + if (eContestResources8.turnOrder[eContestResources8.contestant] > eContestResources8.turnOrder[i] && + eContestantStatus[i].condition > 0 && CanUnnerveContestant(i)) { - sContestantStatus[i].condition = 0; - sContestantStatus[i].conditionMod = 2; + eContestantStatus[i].condition = 0; + eContestantStatus[i].conditionMod = 2; SetContestantEffectStringID(i, CONTEST_STRING_REGAINED_FORM); numHit++; } } - SetContestantEffectStringID(shared192D0.contestant, CONTEST_STRING_TAUNT_WELL); + SetContestantEffectStringID(eContestResources8.contestant, CONTEST_STRING_TAUNT_WELL); if (numHit == 0) - SetContestantEffectStringID2(shared192D0.contestant, CONTEST_STRING_IGNORED); + SetContestantEffectStringID2(eContestResources8.contestant, CONTEST_STRING_IGNORED); } -// Badly startles POKéMON in good condition. +// Badly startles POK�MON in good condition. static void ContestEffect_BadlyStartlesMonsInGoodCondition(void) { u8 numHit = 0; @@ -497,42 +497,42 @@ static void ContestEffect_BadlyStartlesMonsInGoodCondition(void) for (i = 0; i < 4; i++) { - if (shared192D0.turnOrder[shared192D0.contestant] > shared192D0.turnOrder[i]) + if (eContestResources8.turnOrder[eContestResources8.contestant] > eContestResources8.turnOrder[i]) { - if (sContestantStatus[i].condition > 0) - shared192D0.jam = 40; + if (eContestantStatus[i].condition > 0) + eContestResources8.jam = 40; else - shared192D0.jam = 10; - shared192D0.jamQueue[0] = i; - shared192D0.jamQueue[1] = 0xFF; + eContestResources8.jam = 10; + eContestResources8.jamQueue[0] = i; + eContestResources8.jamQueue[1] = 0xFF; if (WasAtLeastOneOpponentJammed()) numHit++; } } - SetContestantEffectStringID(shared192D0.contestant, CONTEST_STRING_JAM_WELL); + SetContestantEffectStringID(eContestResources8.contestant, CONTEST_STRING_JAM_WELL); if (numHit == 0) - SetContestantEffectStringID2(shared192D0.contestant, CONTEST_STRING_IGNORED); + SetContestantEffectStringID2(eContestResources8.contestant, CONTEST_STRING_IGNORED); } // The appeal works great if performed first. static void ContestEffect_BetterIfFirst(void) { - if (gUnknown_02039F26[shared192D0.contestant] == 0) + if (gUnknown_02039F26[eContestResources8.contestant] == 0) { - u16 move = sContestantStatus[shared192D0.contestant].currMove; - sContestantStatus[shared192D0.contestant].appeal2 += 2 * gContestEffects[gContestMoves[move].effect].appeal; - SetContestantEffectStringID(shared192D0.contestant, CONTEST_STRING_HUSTLE_STANDOUT); + u16 move = eContestantStatus[eContestResources8.contestant].currMove; + eContestantStatus[eContestResources8.contestant].appeal2 += 2 * gContestEffects[gContestMoves[move].effect].appeal; + SetContestantEffectStringID(eContestResources8.contestant, CONTEST_STRING_HUSTLE_STANDOUT); } } // The appeal works great if performed last. static void ContestEffect_BetterIfLast(void) { - if (gUnknown_02039F26[shared192D0.contestant] == 3) + if (gUnknown_02039F26[eContestResources8.contestant] == 3) { - u16 move = sContestantStatus[shared192D0.contestant].currMove; - sContestantStatus[shared192D0.contestant].appeal2 += 2 * gContestEffects[gContestMoves[move].effect].appeal; - SetContestantEffectStringID(shared192D0.contestant, CONTEST_STRING_WORK_HARD_UNNOTICED); + u16 move = eContestantStatus[eContestResources8.contestant].currMove; + eContestantStatus[eContestResources8.contestant].appeal2 += 2 * gContestEffects[gContestMoves[move].effect].appeal; + SetContestantEffectStringID(eContestResources8.contestant, CONTEST_STRING_WORK_HARD_UNNOTICED); } } @@ -544,22 +544,22 @@ static void ContestEffect_AppealAsGoodAsPrevOnes(void) for (i = 0, appealSum = 0; i < 4; i++) { - if (shared192D0.turnOrder[shared192D0.contestant] > shared192D0.turnOrder[i]) - appealSum += sContestantStatus[i].appeal2; + if (eContestResources8.turnOrder[eContestResources8.contestant] > eContestResources8.turnOrder[i]) + appealSum += eContestantStatus[i].appeal2; } if (appealSum < 0) appealSum = 0; - if (shared192D0.turnOrder[shared192D0.contestant] == 0 || appealSum == 0) + if (eContestResources8.turnOrder[eContestResources8.contestant] == 0 || appealSum == 0) { - SetContestantEffectStringID(shared192D0.contestant, CONTEST_STRING_APPEAL_NOT_WELL); + SetContestantEffectStringID(eContestResources8.contestant, CONTEST_STRING_APPEAL_NOT_WELL); } else { - sContestantStatus[shared192D0.contestant].appeal2 += appealSum / 2; - SetContestantEffectStringID(shared192D0.contestant, CONTEST_STRING_WORK_BEFORE); + eContestantStatus[eContestResources8.contestant].appeal2 += appealSum / 2; + SetContestantEffectStringID(eContestResources8.contestant, CONTEST_STRING_WORK_BEFORE); } - sContestantStatus[shared192D0.contestant].appeal2 = RoundTowardsZero(sContestantStatus[shared192D0.contestant].appeal2); + eContestantStatus[eContestResources8.contestant].appeal2 = RoundTowardsZero(eContestantStatus[eContestResources8.contestant].appeal2); } // Makes the appeal as good as the one before it. @@ -567,45 +567,45 @@ static void ContestEffect_AppealAsGoodAsPrevOne(void) { s16 appeal = 0; - if (shared192D0.turnOrder[shared192D0.contestant] != 0) + if (eContestResources8.turnOrder[eContestResources8.contestant] != 0) { int i; for (i = 0; i < 4; i++) { - if (shared192D0.turnOrder[shared192D0.contestant] - 1 == shared192D0.turnOrder[i]) - appeal = sContestantStatus[i].appeal2; + if (eContestResources8.turnOrder[eContestResources8.contestant] - 1 == eContestResources8.turnOrder[i]) + appeal = eContestantStatus[i].appeal2; } } - if (shared192D0.turnOrder[shared192D0.contestant] == 0 || appeal <= 0) + if (eContestResources8.turnOrder[eContestResources8.contestant] == 0 || appeal <= 0) { - SetContestantEffectStringID(shared192D0.contestant, CONTEST_STRING_APPEAL_NOT_WELL2); + SetContestantEffectStringID(eContestResources8.contestant, CONTEST_STRING_APPEAL_NOT_WELL2); } else { - sContestantStatus[shared192D0.contestant].appeal2 += appeal; - SetContestantEffectStringID(shared192D0.contestant, CONTEST_STRING_WORK_PRECEDING); + eContestantStatus[eContestResources8.contestant].appeal2 += appeal; + SetContestantEffectStringID(eContestResources8.contestant, CONTEST_STRING_WORK_PRECEDING); } } // The appeal works better the later it is performed. static void ContestEffect_BetterWhenLater(void) { - u8 whichTurn = shared192D0.turnOrder[shared192D0.contestant]; + u8 whichTurn = eContestResources8.turnOrder[eContestResources8.contestant]; if (whichTurn == 0) - sContestantStatus[shared192D0.contestant].appeal2 = 10; + eContestantStatus[eContestResources8.contestant].appeal2 = 10; else - sContestantStatus[shared192D0.contestant].appeal2 = 20 * whichTurn; + eContestantStatus[eContestResources8.contestant].appeal2 = 20 * whichTurn; if (whichTurn == 0) - SetContestantEffectStringID(shared192D0.contestant, CONTEST_STRING_APPEAL_NOT_SHOWN_WELL); + SetContestantEffectStringID(eContestResources8.contestant, CONTEST_STRING_APPEAL_NOT_SHOWN_WELL); else if (whichTurn == 1) - SetContestantEffectStringID(shared192D0.contestant, CONTEST_STRING_APPEAL_SLIGHTLY_WELL); + SetContestantEffectStringID(eContestResources8.contestant, CONTEST_STRING_APPEAL_SLIGHTLY_WELL); else if (whichTurn == 2) - SetContestantEffectStringID(shared192D0.contestant, CONTEST_STRING_APPEAL_PRETTY_WELL); + SetContestantEffectStringID(eContestResources8.contestant, CONTEST_STRING_APPEAL_PRETTY_WELL); else - SetContestantEffectStringID(shared192D0.contestant, CONTEST_STRING_APPEAL_EXCELLENTLY); + SetContestantEffectStringID(eContestResources8.contestant, CONTEST_STRING_APPEAL_EXCELLENTLY); } -// The appeal’s quality varies depending on its timing. +// The appeal�s quality varies depending on its timing. static void ContestEffect_QualityDependsOnTiming(void) { u8 rval = Random() % 10; @@ -614,31 +614,31 @@ static void ContestEffect_QualityDependsOnTiming(void) if (rval < 3) { appeal = 10; - SetContestantEffectStringID(shared192D0.contestant, CONTEST_STRING_APPEAL_NOT_VERY_WELL); + SetContestantEffectStringID(eContestResources8.contestant, CONTEST_STRING_APPEAL_NOT_VERY_WELL); } else if (rval < 6) { appeal = 20; - SetContestantEffectStringID(shared192D0.contestant, CONTEST_STRING_APPEAL_SLIGHTLY_WELL2); + SetContestantEffectStringID(eContestResources8.contestant, CONTEST_STRING_APPEAL_SLIGHTLY_WELL2); } else if (rval < 8) { appeal = 40; - SetContestantEffectStringID(shared192D0.contestant, CONTEST_STRING_APPEAL_PRETTY_WELL2); + SetContestantEffectStringID(eContestResources8.contestant, CONTEST_STRING_APPEAL_PRETTY_WELL2); } else if (rval < 9) { appeal = 60; - SetContestantEffectStringID(shared192D0.contestant, CONTEST_STRING_APPEAL_VERY_WELL); + SetContestantEffectStringID(eContestResources8.contestant, CONTEST_STRING_APPEAL_VERY_WELL); } else { appeal = 80; - SetContestantEffectStringID(shared192D0.contestant, CONTEST_STRING_APPEAL_EXCELLENTLY2); + SetContestantEffectStringID(eContestResources8.contestant, CONTEST_STRING_APPEAL_EXCELLENTLY2); } - sContestantStatus[shared192D0.contestant].appeal2 = appeal; + eContestantStatus[eContestResources8.contestant].appeal2 = appeal; } static void ContestEffect_BetterIfSameType(void) { - s8 turnOrder = shared192D0.turnOrder[shared192D0.contestant]; + s8 turnOrder = eContestResources8.turnOrder[eContestResources8.contestant]; s8 i = turnOrder - 1, j; u16 move; @@ -649,10 +649,10 @@ static void ContestEffect_BetterIfSameType(void) { for (j = 0; j < 4; j++) { - if (shared192D0.turnOrder[j] == i) + if (eContestResources8.turnOrder[j] == i) break; } - if (sContestantStatus[j].noMoreTurns || sContestantStatus[j].nervous || sContestantStatus[j].numTurnsSkipped) + if (eContestantStatus[j].noMoreTurns || eContestantStatus[j].nervous || eContestantStatus[j].numTurnsSkipped) { if (--i < 0) return; @@ -663,29 +663,29 @@ static void ContestEffect_BetterIfSameType(void) } } - move = sContestantStatus[shared192D0.contestant].currMove; - if (gContestMoves[move].contestCategory == gContestMoves[sContestantStatus[j].currMove].contestCategory) + move = eContestantStatus[eContestResources8.contestant].currMove; + if (gContestMoves[move].contestCategory == gContestMoves[eContestantStatus[j].currMove].contestCategory) { - sContestantStatus[shared192D0.contestant].appeal2 += gContestEffects[gContestMoves[move].effect].appeal * 2; - SetContestantEffectStringID(shared192D0.contestant, CONTEST_STRING_SAME_TYPE_GOOD); + eContestantStatus[eContestResources8.contestant].appeal2 += gContestEffects[gContestMoves[move].effect].appeal * 2; + SetContestantEffectStringID(eContestResources8.contestant, CONTEST_STRING_SAME_TYPE_GOOD); } } // Works well if different in type than the one before. static void ContestEffect_BetterIfDiffType(void) { - if (shared192D0.turnOrder[shared192D0.contestant] != 0) + if (eContestResources8.turnOrder[eContestResources8.contestant] != 0) { - u16 move = sContestantStatus[shared192D0.contestant].currMove; + u16 move = eContestantStatus[eContestResources8.contestant].currMove; int i; for (i = 0; i < 4; i++) { - if (shared192D0.turnOrder[shared192D0.contestant] - 1 == shared192D0.turnOrder[i] && - gContestMoves[move].contestCategory != gContestMoves[sContestantStatus[i].currMove].contestCategory) + if (eContestResources8.turnOrder[eContestResources8.contestant] - 1 == eContestResources8.turnOrder[i] && + gContestMoves[move].contestCategory != gContestMoves[eContestantStatus[i].currMove].contestCategory) { - sContestantStatus[shared192D0.contestant].appeal2 += gContestEffects[gContestMoves[move].effect].appeal * 2; - SetContestantEffectStringID(shared192D0.contestant, CONTEST_STRING_DIFF_TYPE_GOOD); + eContestantStatus[eContestResources8.contestant].appeal2 += gContestEffects[gContestMoves[move].effect].appeal * 2; + SetContestantEffectStringID(eContestResources8.contestant, CONTEST_STRING_DIFF_TYPE_GOOD); break; } } @@ -695,52 +695,52 @@ static void ContestEffect_BetterIfDiffType(void) // Affected by how well the appeal in front goes. static void ContestEffect_AffectedByPrevAppeal(void) { - if (shared192D0.turnOrder[shared192D0.contestant] != 0) + if (eContestResources8.turnOrder[eContestResources8.contestant] != 0) { int i; for (i = 0; i < 4; i++) { - if (shared192D0.turnOrder[shared192D0.contestant] - 1 == shared192D0.turnOrder[i]) + if (eContestResources8.turnOrder[eContestResources8.contestant] - 1 == eContestResources8.turnOrder[i]) { - if (sContestantStatus[shared192D0.contestant].appeal2 > sContestantStatus[i].appeal2) + if (eContestantStatus[eContestResources8.contestant].appeal2 > eContestantStatus[i].appeal2) { - sContestantStatus[shared192D0.contestant].appeal2 *= 2; - SetContestantEffectStringID(shared192D0.contestant, CONTEST_STRING_STOOD_OUT_AS_MUCH); + eContestantStatus[eContestResources8.contestant].appeal2 *= 2; + SetContestantEffectStringID(eContestResources8.contestant, CONTEST_STRING_STOOD_OUT_AS_MUCH); } - else if (sContestantStatus[shared192D0.contestant].appeal2 < sContestantStatus[i].appeal2) + else if (eContestantStatus[eContestResources8.contestant].appeal2 < eContestantStatus[i].appeal2) { - sContestantStatus[shared192D0.contestant].appeal2 = 0; - SetContestantEffectStringID(shared192D0.contestant, CONTEST_STRING_NOT_AS_WELL); + eContestantStatus[eContestResources8.contestant].appeal2 = 0; + SetContestantEffectStringID(eContestResources8.contestant, CONTEST_STRING_NOT_AS_WELL); } } } } } -// Ups the user’s condition. Helps prevent nervousness. +// Ups the user�s condition. Helps prevent nervousness. static void ContestEffect_ImproveConditionPreventNervousness(void) { - if (sContestantStatus[shared192D0.contestant].condition < 30) + if (eContestantStatus[eContestResources8.contestant].condition < 30) { - sContestantStatus[shared192D0.contestant].condition += 10; - sContestantStatus[shared192D0.contestant].conditionMod = 1; - SetContestantEffectStringID(shared192D0.contestant, CONTEST_STRING_CONDITION_ROSE); + eContestantStatus[eContestResources8.contestant].condition += 10; + eContestantStatus[eContestResources8.contestant].conditionMod = 1; + SetContestantEffectStringID(eContestResources8.contestant, CONTEST_STRING_CONDITION_ROSE); } else { - SetContestantEffectStringID(shared192D0.contestant, CONTEST_STRING_NO_CONDITION_IMPROVE); + SetContestantEffectStringID(eContestResources8.contestant, CONTEST_STRING_NO_CONDITION_IMPROVE); } } -// The appeal works well if the user’s condition is good. +// The appeal works well if the user�s condition is good. static void ContestEffect_BetterWithGoodCondition(void) { - sContestantStatus[shared192D0.contestant].appealTripleCondition = TRUE; - if (sContestantStatus[shared192D0.contestant].condition != 0) - SetContestantEffectStringID(shared192D0.contestant, CONTEST_STRING_HOT_STATUS); + eContestantStatus[eContestResources8.contestant].appealTripleCondition = TRUE; + if (eContestantStatus[eContestResources8.contestant].condition != 0) + SetContestantEffectStringID(eContestResources8.contestant, CONTEST_STRING_HOT_STATUS); else - SetContestantEffectStringID(shared192D0.contestant, CONTEST_STRING_BAD_CONDITION_WEAK_APPEAL); + SetContestantEffectStringID(eContestResources8.contestant, CONTEST_STRING_BAD_CONDITION_WEAK_APPEAL); } // The next appeal can be made earlier next turn. @@ -750,20 +750,20 @@ static void ContestEffect_NextAppealEarlier(void) s8 j; u8 turnOrder[4]; - if (sContest.turnNumber != 4) + if (eContest.turnNumber != 4) { for (i = 0; i < 4; i++) - turnOrder[i] = sContestantStatus[i].nextTurnOrder; + turnOrder[i] = eContestantStatus[i].nextTurnOrder; - turnOrder[shared192D0.contestant] = 0xFF; + turnOrder[eContestResources8.contestant] = 0xFF; for (i = 0; i < 4; i++) { for (j = 0; j < 4; j++) { - if (j != shared192D0.contestant && + if (j != eContestResources8.contestant && i == turnOrder[j] && - turnOrder[j] == sContestantStatus[j].nextTurnOrder) + turnOrder[j] == eContestantStatus[j].nextTurnOrder) { turnOrder[j]++; break; @@ -773,15 +773,15 @@ static void ContestEffect_NextAppealEarlier(void) break; } - turnOrder[shared192D0.contestant] = 0; - sContestantStatus[shared192D0.contestant].turnOrderMod = 1; + turnOrder[eContestResources8.contestant] = 0; + eContestantStatus[eContestResources8.contestant].turnOrderMod = 1; for (i = 0; i < 4; i++) { - sContestantStatus[i].nextTurnOrder = turnOrder[i]; + eContestantStatus[i].nextTurnOrder = turnOrder[i]; } - sContestantStatus[shared192D0.contestant].turnOrderModAction = 1; - SetContestantEffectStringID(shared192D0.contestant, CONTEST_STRING_MOVE_UP_LINE); + eContestantStatus[eContestResources8.contestant].turnOrderModAction = 1; + SetContestantEffectStringID(eContestResources8.contestant, CONTEST_STRING_MOVE_UP_LINE); } } @@ -792,20 +792,20 @@ static void ContestEffect_NextAppealLater(void) s8 j; u8 turnOrder[4]; - if (sContest.turnNumber != 4) + if (eContest.turnNumber != 4) { for (i = 0; i < 4; i++) - turnOrder[i] = sContestantStatus[i].nextTurnOrder; + turnOrder[i] = eContestantStatus[i].nextTurnOrder; - turnOrder[shared192D0.contestant] = 0xFF; + turnOrder[eContestResources8.contestant] = 0xFF; for (i = 3; i > -1; i--) { for (j = 0; j < 4; j++) { - if (j != shared192D0.contestant && + if (j != eContestResources8.contestant && i == turnOrder[j] && - turnOrder[j] == sContestantStatus[j].nextTurnOrder) + turnOrder[j] == eContestantStatus[j].nextTurnOrder) { turnOrder[j]--; break; @@ -815,19 +815,19 @@ static void ContestEffect_NextAppealLater(void) break; } - turnOrder[shared192D0.contestant] = 3; - sContestantStatus[shared192D0.contestant].turnOrderMod = 1; + turnOrder[eContestResources8.contestant] = 3; + eContestantStatus[eContestResources8.contestant].turnOrderMod = 1; for (i = 0; i < 4; i++) { - sContestantStatus[i].nextTurnOrder = turnOrder[i]; + eContestantStatus[i].nextTurnOrder = turnOrder[i]; } - sContestantStatus[shared192D0.contestant].turnOrderModAction = 2; - SetContestantEffectStringID(shared192D0.contestant, CONTEST_STRING_MOVE_BACK_LINE); + eContestantStatus[eContestResources8.contestant].turnOrderModAction = 2; + SetContestantEffectStringID(eContestResources8.contestant, CONTEST_STRING_MOVE_BACK_LINE); } } -// Makes the next turn’s order more easily scrambled. +// Makes the next turn�s order more easily scrambled. static void ContestEffect_MakeScramblingTurnOrderEasier(void) { // dummied out? @@ -841,11 +841,11 @@ static void ContestEffect_ScrambleNextTurnOrder(void) u8 turnOrder[4]; u8 unselectedContestants[4]; - if (sContest.turnNumber != 4) + if (eContest.turnNumber != 4) { for (i = 0; i < 4; i++) { - turnOrder[i] = sContestantStatus[i].nextTurnOrder; + turnOrder[i] = eContestantStatus[i].nextTurnOrder; unselectedContestants[i] = i; } @@ -871,24 +871,24 @@ static void ContestEffect_ScrambleNextTurnOrder(void) for (i = 0; i < 4; i++) { - sContestantStatus[i].nextTurnOrder = turnOrder[i]; - sContestantStatus[i].turnOrderMod = 2; + eContestantStatus[i].nextTurnOrder = turnOrder[i]; + eContestantStatus[i].turnOrderMod = 2; } - sContestantStatus[shared192D0.contestant].turnOrderModAction = 3; - SetContestantEffectStringID(shared192D0.contestant, CONTEST_STRING_SCRAMBLE_ORDER); + eContestantStatus[eContestResources8.contestant].turnOrderModAction = 3; + SetContestantEffectStringID(eContestResources8.contestant, CONTEST_STRING_SCRAMBLE_ORDER); } } // An appeal that excites the audience in any CONTEST. static void ContestEffect_ExciteAudienceInAnyContest(void) { - if (gContestMoves[sContestantStatus[shared192D0.contestant].currMove].contestCategory != gSpecialVar_ContestCategory) + if (gContestMoves[eContestantStatus[eContestResources8.contestant].currMove].contestCategory != gSpecialVar_ContestCategory) { - sContestantStatus[shared192D0.contestant].overrideCategoryExcitementMod = TRUE; + eContestantStatus[eContestResources8.contestant].overrideCategoryExcitementMod = TRUE; } } -// Badly startles all POKéMON that made good appeals. +// Badly startles all POK�MON that made good appeals. static void ContestEffect_BadlyStartleMonsWithGoodAppeals(void) { int i; @@ -896,24 +896,24 @@ static void ContestEffect_BadlyStartleMonsWithGoodAppeals(void) for (i = 0; i < 4; i++) { - if (shared192D0.turnOrder[shared192D0.contestant] > shared192D0.turnOrder[i]) + if (eContestResources8.turnOrder[eContestResources8.contestant] > eContestResources8.turnOrder[i]) { - if (sContestantStatus[i].appeal2 > 0) + if (eContestantStatus[i].appeal2 > 0) { - shared192D0.jam = sContestantStatus[i].appeal2 / 2; - shared192D0.jam = RoundUp(shared192D0.jam); + eContestResources8.jam = eContestantStatus[i].appeal2 / 2; + eContestResources8.jam = RoundUp(eContestResources8.jam); } else - shared192D0.jam = 10; - shared192D0.jamQueue[0] = i; - shared192D0.jamQueue[1] = 0xFF; + eContestResources8.jam = 10; + eContestResources8.jamQueue[0] = i; + eContestResources8.jamQueue[1] = 0xFF; if (WasAtLeastOneOpponentJammed()) numJammed++; } } if (numJammed == 0) - SetContestantEffectStringID2(shared192D0.contestant, CONTEST_STRING_MESSED_UP2); - SetContestantEffectStringID(shared192D0.contestant, CONTEST_STRING_ATTEMPT_STARTLE); + SetContestantEffectStringID2(eContestResources8.contestant, CONTEST_STRING_MESSED_UP2); + SetContestantEffectStringID(eContestResources8.contestant, CONTEST_STRING_ATTEMPT_STARTLE); } // The appeal works best the more the crowd is excited. @@ -921,42 +921,42 @@ static void ContestEffect_BetterWhenAudienceExcited(void) { s16 appeal; - if (sContest.applauseLevel == 0) + if (eContest.applauseLevel == 0) { appeal = 10; - SetContestantEffectStringID(shared192D0.contestant, CONTEST_STRING_APPEAL_NOT_VERY_WELL); + SetContestantEffectStringID(eContestResources8.contestant, CONTEST_STRING_APPEAL_NOT_VERY_WELL); } - else if (sContest.applauseLevel == 1) + else if (eContest.applauseLevel == 1) { appeal = 20; - SetContestantEffectStringID(shared192D0.contestant, CONTEST_STRING_APPEAL_SLIGHTLY_WELL2); + SetContestantEffectStringID(eContestResources8.contestant, CONTEST_STRING_APPEAL_SLIGHTLY_WELL2); } - else if (sContest.applauseLevel == 2) + else if (eContest.applauseLevel == 2) { appeal = 30; - SetContestantEffectStringID(shared192D0.contestant, CONTEST_STRING_APPEAL_PRETTY_WELL2); + SetContestantEffectStringID(eContestResources8.contestant, CONTEST_STRING_APPEAL_PRETTY_WELL2); } - else if (sContest.applauseLevel == 3) + else if (eContest.applauseLevel == 3) { appeal = 50; - SetContestantEffectStringID(shared192D0.contestant, CONTEST_STRING_APPEAL_VERY_WELL); + SetContestantEffectStringID(eContestResources8.contestant, CONTEST_STRING_APPEAL_VERY_WELL); } else { appeal = 60; - SetContestantEffectStringID(shared192D0.contestant, CONTEST_STRING_APPEAL_EXCELLENTLY2); + SetContestantEffectStringID(eContestResources8.contestant, CONTEST_STRING_APPEAL_EXCELLENTLY2); } - sContestantStatus[shared192D0.contestant].appeal2 = appeal; + eContestantStatus[eContestResources8.contestant].appeal2 = appeal; } // Temporarily stops the crowd from growing excited. static void ContestEffect_DontExciteAudience(void) { - if (!shared19328.excitementFrozen) + if (!eContestResources10.excitementFrozen) { - shared19328.excitementFrozen = TRUE; - shared19328.excitementFreezer = shared192D0.contestant; - SetContestantEffectStringID(shared192D0.contestant, CONTEST_STRING_ATTRACTED_ATTENTION); + eContestResources10.excitementFrozen = TRUE; + eContestResources10.excitementFreezer = eContestResources8.contestant; + SetContestantEffectStringID(eContestResources8.contestant, CONTEST_STRING_ATTRACTED_ATTENTION); } } @@ -967,38 +967,38 @@ static void JamByMoveCategory(u8 category) for (i = 0; i < 4; i++) { - if (shared192D0.turnOrder[shared192D0.contestant] > shared192D0.turnOrder[i]) + if (eContestResources8.turnOrder[eContestResources8.contestant] > eContestResources8.turnOrder[i]) { - if (category == gContestMoves[sContestantStatus[i].currMove].contestCategory) - shared192D0.jam = 40; + if (category == gContestMoves[eContestantStatus[i].currMove].contestCategory) + eContestResources8.jam = 40; else - shared192D0.jam = 10; - shared192D0.jamQueue[0] = i; - shared192D0.jamQueue[1] = 0xFF; + eContestResources8.jam = 10; + eContestResources8.jamQueue[0] = i; + eContestResources8.jamQueue[1] = 0xFF; if (WasAtLeastOneOpponentJammed()) numJammed++; } } if (numJammed == 0) - SetContestantEffectStringID2(shared192D0.contestant, CONTEST_STRING_MESSED_UP2); + SetContestantEffectStringID2(eContestResources8.contestant, CONTEST_STRING_MESSED_UP2); } static bool8 CanUnnerveContestant(u8 i) { - shared192D0.unnervedPokes[i] = 1; - if (sContestantStatus[i].immune) + eContestResources8.unnervedPokes[i] = 1; + if (eContestantStatus[i].immune) { SetContestantEffectStringID(i, CONTEST_STRING_AVOID_SEEING); return FALSE; } - else if (sContestantStatus[i].jamSafetyCount != 0) + else if (eContestantStatus[i].jamSafetyCount != 0) { - sContestantStatus[i].jamSafetyCount--; + eContestantStatus[i].jamSafetyCount--; SetContestantEffectStringID(i, CONTEST_STRING_AVERT_GAZE); return FALSE; } - else if (!sContestantStatus[i].noMoreTurns && sContestantStatus[i].numTurnsSkipped == 0) + else if (!eContestantStatus[i].noMoreTurns && eContestantStatus[i].numTurnsSkipped == 0) { return TRUE; } @@ -1013,32 +1013,32 @@ static bool8 WasAtLeastOneOpponentJammed(void) s16 jamBuffer[4] = {0}; int i; - for (i = 0; shared192D0.jamQueue[i] != 0xFF; i++) + for (i = 0; eContestResources8.jamQueue[i] != 0xFF; i++) { - u8 contestant = shared192D0.jamQueue[i]; + u8 contestant = eContestResources8.jamQueue[i]; if (CanUnnerveContestant(contestant)) { - shared192D0.jam2 = shared192D0.jam; - if (sContestantStatus[contestant].moreEasilyStartled) - shared192D0.jam2 *= 2; - if (sContestantStatus[contestant].resistant) + eContestResources8.jam2 = eContestResources8.jam; + if (eContestantStatus[contestant].moreEasilyStartled) + eContestResources8.jam2 *= 2; + if (eContestantStatus[contestant].resistant) { - shared192D0.jam2 = 10; + eContestResources8.jam2 = 10; SetContestantEffectStringID(contestant, CONTEST_STRING_LITTLE_DISTRACTED); } else { - shared192D0.jam2 -= sContestantStatus[contestant].jamReduction; - if (shared192D0.jam2 <= 0) + eContestResources8.jam2 -= eContestantStatus[contestant].jamReduction; + if (eContestResources8.jam2 <= 0) { - shared192D0.jam2 = 0; + eContestResources8.jam2 = 0; SetContestantEffectStringID(contestant, CONTEST_STRING_NOT_FAZED); } else { - JamContestant(contestant, shared192D0.jam2); - SetStartledString(contestant, shared192D0.jam2); - jamBuffer[contestant] = shared192D0.jam2; + JamContestant(contestant, eContestResources8.jam2); + SetStartledString(contestant, eContestResources8.jam2); + jamBuffer[contestant] = eContestResources8.jam2; } } } @@ -1054,8 +1054,8 @@ static bool8 WasAtLeastOneOpponentJammed(void) static void JamContestant(u8 i, u8 jam) { - sContestantStatus[i].appeal2 -= jam; - sContestantStatus[i].jam += jam; + eContestantStatus[i].appeal2 -= jam; + eContestantStatus[i].jam += jam; } static s16 RoundTowardsZero(s16 score) From 99e8e8e53f1b23cf4fae3223af87c54feddfe1a2 Mon Sep 17 00:00:00 2001 From: Phlosioneer Date: Tue, 2 Apr 2019 20:00:05 -0400 Subject: [PATCH 03/22] More cleanup, document contestant sorting --- include/contest.h | 22 ++- src/contest.c | 380 ++++++++++++++++++++----------------- src/contest_effect.c | 4 +- src/contest_link_80F57C4.c | 2 +- src/contest_link_80FC4F4.c | 16 +- src/contest_link_81D9DE4.c | 2 +- 6 files changed, 232 insertions(+), 194 deletions(-) diff --git a/include/contest.h b/include/contest.h index be4bea489..c62749770 100644 --- a/include/contest.h +++ b/include/contest.h @@ -1,6 +1,8 @@ #ifndef GUARD_CONTEST_H #define GUARD_CONTEST_H +#define CONTESTANT_COUNT 4 + enum { CONTEST_CATEGORY_COOL, @@ -258,7 +260,7 @@ struct Contest { /*0x0*/ u8 playerMoveChoice; /*0x1*/ u8 turnNumber; - /*0x2*/ u8 unk19206[4]; // seems to only be used by an unref function + /*0x2*/ u8 unused2[CONTESTANT_COUNT]; /*0x6*/ u16 unk1920A_0:1; // Task active flags? u16 unk1920A_1:1; u16 unk1920A_2:1; @@ -279,7 +281,7 @@ struct Contest /*0x11*/ u8 unk19215; /*0x12*/ u8 unk19216; // sprite ID /*0x13*/ s8 applauseLevel; - /*0x19218*/ u8 unk19218[4]; + /*0x19218*/ u8 unk19218[CONTESTANT_COUNT]; /*0x1921C*/ u32 unk1921C; // saved RNG value? u16 unk19220[5][4]; // move history? u8 unk19248[5][4]; // excitement history @@ -339,11 +341,11 @@ struct ContestantStatus struct UnknownContestStruct7 { - u8 turnOrder[4]; + u8 turnOrder[CONTESTANT_COUNT]; s16 jam; s16 jam2; u8 jamQueue[5]; - u8 unnervedPokes[4]; + u8 unnervedPokes[CONTESTANT_COUNT]; u8 contestant; }; @@ -407,9 +409,9 @@ struct ContestResourcesField20 struct ContestResources { struct Contest *contest; - struct ContestantStatus *field_4; + struct ContestantStatus *status; struct UnknownContestStruct7 *field_8; - struct ContestAIInfo *field_C; + struct ContestAIInfo *aiData; struct UnknownContestStruct5 *field_10; struct UnknownContestStruct4 *field_14; struct ContestStruct_field_18 *field_18; @@ -422,9 +424,9 @@ struct ContestResources }; #define eContest (*gContestResources->contest) -#define eContestantStatus (gContestResources->field_4) +#define eContestantStatus (gContestResources->status) #define eContestResources8 (*gContestResources->field_8) -#define eContestAI (*gContestResources->field_C) +#define eContestAI (*gContestResources->aiData) #define eContestResources10 (*gContestResources->field_10) #define eContestResources14 (*gContestResources->field_14) #define eUnknownHeap18000 (gHeap + 0x18000) @@ -440,7 +442,7 @@ extern s16 gUnknown_02039F18[4]; extern u8 gContestFinalStandings[4]; extern u8 gContestMonPartyIndex; extern u8 gContestPlayerMonIndex; -extern u8 gUnknown_02039F26[4]; +extern u8 gContestantTurnOrder[4]; extern u8 gIsLinkContest; extern u8 gUnknown_02039F2B; extern u16 gSpecialVar_ContestCategory; @@ -467,7 +469,7 @@ void sub_80DB09C(u8 contestCategory); bool8 IsSpeciesNotUnown(u16 species); bool8 Contest_IsMonsTurnDisabled(u8 a); void sub_80DBED4(void); -void sub_80DCE58(u8 a); +void SortContestants(bool8 a); void SetContestantEffectStringID(u8 a, u8 b); void SetContestantEffectStringID2(u8 a, u8 b); void SetStartledString(u8 contestant, u8 jam); diff --git a/src/contest.c b/src/contest.c index 50a98fedc..57c8b46d6 100644 --- a/src/contest.c +++ b/src/contest.c @@ -200,7 +200,7 @@ EWRAM_DATA s16 gUnknown_02039F18[4] = {0}; EWRAM_DATA u8 gContestFinalStandings[4] = {0}; EWRAM_DATA u8 gContestMonPartyIndex = 0; EWRAM_DATA u8 gContestPlayerMonIndex = 0; -EWRAM_DATA u8 gUnknown_02039F26[4] = {0}; +EWRAM_DATA u8 gContestantTurnOrder[4] = {0}; EWRAM_DATA u8 gIsLinkContest = 0; // Bit 0: Is a link contest // Bit 1: Link contest uses wireless adapter @@ -901,7 +901,7 @@ void LoadContestBgAfterMoveAnim(void) { u32 var = 5 + i; - LoadPalette(eUnknownHeap1A004.unk18004[var], 16 * (5 + gUnknown_02039F26[i]), 16 * sizeof(u16)); + LoadPalette(eUnknownHeap1A004.unk18004[var], 16 * (5 + gContestantTurnOrder[i]), 16 * sizeof(u16)); } } @@ -943,51 +943,53 @@ static void sub_80D782C(void) FillPalette(RGB(31, 17, 31), 0xF3, 2); } -static void sub_80D787C(void) +static void InitContestResources(void) { s32 i; eContest = (struct Contest){}; - for (i = 0; i < 4; i++) + for (i = 0; i < CONTESTANT_COUNT; i++) { - eContest.unk19206[i] = 0xFF; + eContest.unused2[i] = 0xFF; } - for (i = 0; i < 4; i++) + for (i = 0; i < CONTESTANT_COUNT; i++) { - gContestResources->field_4[i] = (struct ContestantStatus){}; + eContestantStatus[i] = (struct ContestantStatus){}; } - for (i = 0; i < 4; i++) + for (i = 0; i < CONTESTANT_COUNT; i++) { - gContestResources->field_4[i].ranking = 0; - gContestResources->field_4[i].effectStringId = CONTEST_STRING_NONE; - gContestResources->field_4[i].effectStringId2 = CONTEST_STRING_NONE; + eContestantStatus[i].ranking = 0; + eContestantStatus[i].effectStringId = CONTEST_STRING_NONE; + eContestantStatus[i].effectStringId2 = CONTEST_STRING_NONE; } - *gContestResources->field_8 = (struct UnknownContestStruct7){}; - *gContestResources->field_C = (struct ContestAIInfo){}; + eContestResources8 = (struct UnknownContestStruct7){}; + eContestAI = (struct ContestAIInfo){}; *gContestResources->field_10 = (struct UnknownContestStruct5){}; - memset(gContestResources->field_14, 0, 4 * sizeof(struct UnknownContestStruct4)); + memset(gContestResources->field_14, 0, CONTESTANT_COUNT * sizeof(struct UnknownContestStruct4)); + if (!(gIsLinkContest & 1)) - sub_80DCE58(0); - for (i = 0; i < 4; i++) + SortContestants(FALSE); + + for (i = 0; i < CONTESTANT_COUNT; i++) { - gContestResources->field_4[i].nextTurnOrder = 0xFF; - eContest.unk19218[i] = gUnknown_02039F26[i]; + eContestantStatus[i].nextTurnOrder = 0xFF; + eContest.unk19218[i] = gContestantTurnOrder[i]; } sub_80DD590(); - memset(gContestResources->field_1c, 0, sizeof(*gContestResources->field_1c) * 4); + memset(gContestResources->field_1c, 0, sizeof(*gContestResources->field_1c) * CONTESTANT_COUNT); } -static void sub_80D7988(void) +static void AllocContestResources(void) { gContestResources = AllocZeroed(sizeof(struct ContestResources)); gContestResources->contest = AllocZeroed(sizeof(struct Contest)); - gContestResources->field_4 = AllocZeroed(sizeof(struct ContestantStatus) * 4); + gContestResources->status = AllocZeroed(sizeof(struct ContestantStatus) * CONTESTANT_COUNT); gContestResources->field_8 = AllocZeroed(sizeof(struct UnknownContestStruct7)); - gContestResources->field_C = AllocZeroed(sizeof(struct ContestAIInfo)); - gContestResources->field_10 = AllocZeroed(sizeof(struct UnknownContestStruct5) * 4); - gContestResources->field_14 = AllocZeroed(sizeof(struct UnknownContestStruct4) * 4); + gContestResources->aiData = AllocZeroed(sizeof(struct ContestAIInfo)); + gContestResources->field_10 = AllocZeroed(sizeof(struct UnknownContestStruct5) * CONTESTANT_COUNT); + gContestResources->field_14 = AllocZeroed(sizeof(struct UnknownContestStruct4) * CONTESTANT_COUNT); gContestResources->field_18 = AllocZeroed(sizeof(struct ContestStruct_field_18)); - gContestResources->field_1c = AllocZeroed(sizeof(struct ContestResourcesField1C) * 4); + gContestResources->field_1c = AllocZeroed(sizeof(struct ContestResourcesField1C) * CONTESTANT_COUNT); gContestResources->field_20 = AllocZeroed(sizeof(struct ContestResourcesField20)); gContestResources->field_24[0] = AllocZeroed(0x1000); gContestResources->field_24[1] = AllocZeroed(0x1000); @@ -1000,12 +1002,12 @@ static void sub_80D7988(void) gUnknown_02023060 = gContestResources->field_24[1]; } -static void sub_80D7A5C(void) +static void FreeContestResources(void) { FREE_AND_SET_NULL(gContestResources->contest); - FREE_AND_SET_NULL(gContestResources->field_4); + FREE_AND_SET_NULL(gContestResources->status); FREE_AND_SET_NULL(gContestResources->field_8); - FREE_AND_SET_NULL(gContestResources->field_C); + FREE_AND_SET_NULL(gContestResources->aiData); FREE_AND_SET_NULL(gContestResources->field_10); FREE_AND_SET_NULL(gContestResources->field_14); FREE_AND_SET_NULL(gContestResources->field_18); @@ -1029,7 +1031,7 @@ void sub_80D7B24(void) { case 0: sContestBgCopyFlags = 0; - sub_80D7988(); + AllocContestResources(); AllocateMonSpritesGfx(); FREE_AND_SET_NULL(gMonSpritesGfxPtr->firstDecompressed); gMonSpritesGfxPtr->firstDecompressed = AllocZeroed(0x4000); @@ -1046,7 +1048,7 @@ void sub_80D7B24(void) gReservedSpritePaletteCount = 4; eUnknownHeap1A000 = 0; ClearBattleMonForms(); - sub_80D787C(); + InitContestResources(); gMain.state++; break; case 1: @@ -1376,15 +1378,15 @@ static void sub_80D8490(u8 taskId) u16 move = gContestMons[gContestPlayerMonIndex].moves[i]; u8 *r5 = sp8; - if (gContestResources->field_4[gContestPlayerMonIndex].prevMove != MOVE_NONE + if (eContestantStatus[gContestPlayerMonIndex].prevMove != MOVE_NONE && sub_80DE1E8(gContestPlayerMonIndex) - && AreMovesContestCombo(gContestResources->field_4[gContestPlayerMonIndex].prevMove, move) != 0 - && gContestResources->field_4[gContestPlayerMonIndex].hasJudgesAttention) + && AreMovesContestCombo(eContestantStatus[gContestPlayerMonIndex].prevMove, move) != 0 + && eContestantStatus[gContestPlayerMonIndex].hasJudgesAttention) { r5 = StringCopy(sp8, gText_ColorLightShadowDarkGrey); } else if (move != 0 - && gContestResources->field_4[gContestPlayerMonIndex].prevMove == move + && eContestantStatus[gContestPlayerMonIndex].prevMove == move && gContestMoves[move].effect != CONTEST_EFFECT_REPETITION_NOT_BORING) { // Gray the text because it is a repeated move @@ -1483,7 +1485,7 @@ static void sub_80D8894(u8 taskId) u16 var = GetChosenMove(gContestPlayerMonIndex); u8 taskId2; - gContestResources->field_4[gContestPlayerMonIndex].currMove = var; + eContestantStatus[gContestPlayerMonIndex].currMove = var; taskId2 = CreateTask(sub_80FC9F8, 0); SetTaskFuncWithFollowupFunc(taskId2, sub_80FC9F8, sub_80D892C); gTasks[taskId].func = TaskDummy1; @@ -1559,7 +1561,7 @@ static void sub_80D8A88(u8 taskId) for (i = 0; i + gNumLinkContestPlayers < 4; i++) { - gContestResources->field_4[gNumLinkContestPlayers + i].currMove = GetChosenMove(gNumLinkContestPlayers + i); + eContestantStatus[gNumLinkContestPlayers + i].currMove = GetChosenMove(gNumLinkContestPlayers + i); } } gTasks[taskId].data[0] = 0; @@ -1607,8 +1609,8 @@ static void sub_80D8B38(u8 taskId) case 2: sub_80DF080(r6); sub_80DF750(); - if (gContestResources->field_4[r6].numTurnsSkipped != 0 - || gContestResources->field_4[r6].noMoreTurns) + if (eContestantStatus[r6].numTurnsSkipped != 0 + || eContestantStatus[r6].noMoreTurns) { gTasks[taskId].data[0] = 31; } @@ -1645,7 +1647,7 @@ static void sub_80D8B38(u8 taskId) } return; case 5: - if (gContestResources->field_4[r6].nervous) + if (eContestantStatus[r6].nervous) { gTasks[taskId].data[0] = 33; } @@ -1653,10 +1655,10 @@ static void sub_80D8B38(u8 taskId) { sub_80DB89C(); StringCopy(gStringVar1, gContestMons[r6].nickname); - if (gContestResources->field_4[r6].currMove < MOVES_COUNT) - StringCopy(gStringVar2, gMoveNames[gContestResources->field_4[r6].currMove]); + if (eContestantStatus[r6].currMove < MOVES_COUNT) + StringCopy(gStringVar2, gMoveNames[eContestantStatus[r6].currMove]); else - StringCopy(gStringVar2, gUnknown_08587F1C[gContestResources->field_4[r6].moveCategory]); + StringCopy(gStringVar2, gUnknown_08587F1C[eContestantStatus[r6].moveCategory]); StringExpandPlaceholders(gStringVar4, gText_0827D55A); Contest_StartTextPrinter(gStringVar4, 1); gTasks[taskId].data[0] = 6; @@ -1671,7 +1673,7 @@ static void sub_80D8B38(u8 taskId) return; case 7: { - u16 move = SanitizeMove(gContestResources->field_4[eContest.unk19215].currMove); + u16 move = SanitizeMove(eContestantStatus[eContest.unk19215].currMove); sub_80DE864(eContest.unk19215); sub_80DE9DC(eContest.unk19215); @@ -1692,7 +1694,7 @@ static void sub_80D8B38(u8 taskId) } else { - if (!gContestResources->field_4[r6].hasJudgesAttention) + if (!eContestantStatus[r6].hasJudgesAttention) sub_80DC674(r6); sub_80DE12C(); gTasks[taskId].data[0] = 23; @@ -1708,25 +1710,25 @@ static void sub_80D8B38(u8 taskId) return; case 23: gTasks[taskId].data[1] = 0; - if (gContestResources->field_4[r6].effectStringId != CONTEST_STRING_NONE) + if (eContestantStatus[r6].effectStringId != CONTEST_STRING_NONE) { - sub_80DD45C(r6, gContestResources->field_4[r6].effectStringId); - gContestResources->field_4[r6].effectStringId = CONTEST_STRING_NONE; + sub_80DD45C(r6, eContestantStatus[r6].effectStringId); + eContestantStatus[r6].effectStringId = CONTEST_STRING_NONE; gTasks[taskId].data[0] = 24; } else { - if (gContestResources->field_4[r6].effectStringId2 != CONTEST_STRING_NONE) + if (eContestantStatus[r6].effectStringId2 != CONTEST_STRING_NONE) { for (i = 0; i < 4; i++) { - if (i != r6 && gContestResources->field_4[i].effectStringId != CONTEST_STRING_NONE) + if (i != r6 && eContestantStatus[i].effectStringId != CONTEST_STRING_NONE) break; } if (i == 4) { - sub_80DD45C(r6, gContestResources->field_4[r6].effectStringId2); - gContestResources->field_4[r6].effectStringId2 = CONTEST_STRING_NONE; + sub_80DD45C(r6, eContestantStatus[r6].effectStringId2); + eContestantStatus[r6].effectStringId2 = CONTEST_STRING_NONE; gTasks[taskId].data[0] = 24; } else @@ -1745,15 +1747,15 @@ static void sub_80D8B38(u8 taskId) gTasks[taskId].data[0] = 23; return; case 48: - if (gContestResources->field_4[r6].turnOrderModAction == 1) + if (eContestantStatus[r6].turnOrderModAction == 1) { sub_80DD720(5); } - else if (gContestResources->field_4[r6].turnOrderModAction == 2) + else if (eContestantStatus[r6].turnOrderModAction == 2) { sub_80DD720(6); } - else if (gContestResources->field_4[r6].turnOrderModAction == 3) + else if (eContestantStatus[r6].turnOrderModAction == 3) { sub_80DD720(7); } @@ -1773,7 +1775,7 @@ static void sub_80D8B38(u8 taskId) gTasks[taskId].data[0] = 12; return; case 12: - sub_80DC028(0, gContestResources->field_4[r6].appeal2, r6); + sub_80DC028(0, eContestantStatus[r6].appeal2, r6); gTasks[taskId].data[0] = 13; return; case 13: @@ -1781,7 +1783,7 @@ static void sub_80D8B38(u8 taskId) gTasks[taskId].data[0] = 35; return; case 35: - if (gContestResources->field_4[r6].conditionMod == 1) + if (eContestantStatus[r6].conditionMod == 1) sub_80DD720(8); gTasks[taskId].data[0] = 36; return; @@ -1826,8 +1828,8 @@ static void sub_80D8B38(u8 taskId) r3 = 0; for (r2 = 0; r2 < 4; r2++) { - if (r2 != r6 && gUnknown_02039F26[r2] == i - && gContestResources->field_4[r2].effectStringId != CONTEST_STRING_NONE) + if (r2 != r6 && gContestantTurnOrder[r2] == i + && eContestantStatus[r2].effectStringId != CONTEST_STRING_NONE) { r3 = 1; break; @@ -1838,9 +1840,9 @@ static void sub_80D8B38(u8 taskId) } if (r3) { - gTasks[taskId].data[1] = gUnknown_02039F26[r2]; - sub_80DD45C(r2, gContestResources->field_4[r2].effectStringId); - gContestResources->field_4[r2].effectStringId = CONTEST_STRING_NONE; + gTasks[taskId].data[1] = gContestantTurnOrder[r2]; + sub_80DD45C(r2, eContestantStatus[r2].effectStringId); + eContestantStatus[r2].effectStringId = CONTEST_STRING_NONE; gTasks[taskId].data[0] = 27; } else @@ -1857,19 +1859,19 @@ static void sub_80D8B38(u8 taskId) gTasks[taskId].data[0] = 28; return; case 28: - for (i = 0; gTasks[taskId].data[1] != gUnknown_02039F26[i]; i++) + for (i = 0; gTasks[taskId].data[1] != gContestantTurnOrder[i]; i++) ; - sub_80DC028(gContestResources->field_4[i].appeal2 + gContestResources->field_4[i].jam, -gContestResources->field_4[i].jam, i); + sub_80DC028(eContestantStatus[i].appeal2 + eContestantStatus[i].jam, -eContestantStatus[i].jam, i); gTasks[taskId].data[0] = 29; return; case 29: - for (i = 0; gTasks[taskId].data[1] != gUnknown_02039F26[i]; i++) + for (i = 0; gTasks[taskId].data[1] != gContestantTurnOrder[i]; i++) ; if (!gContestResources->field_14[i].unk2_2) gTasks[taskId].data[0] = 39; return; case 39: - for (i = 0; gTasks[taskId].data[1] != gUnknown_02039F26[i]; i++) + for (i = 0; gTasks[taskId].data[1] != gContestantTurnOrder[i]; i++) ; if (sub_80DB5B8(i, 1)) { @@ -1891,17 +1893,17 @@ static void sub_80D8B38(u8 taskId) case 30: for (i = 0; i < 4; i++) { - if (gUnknown_02039F26[i] == gTasks[taskId].data[1]) + if (gContestantTurnOrder[i] == gTasks[taskId].data[1]) break; } if (sub_80DB798(i)) PlaySE(SE_C_PASI); else PlaySE(SE_C_SYU); - if (gContestResources->field_4[i].judgesAttentionWasRemoved) + if (eContestantStatus[i].judgesAttentionWasRemoved) { sub_80DC674(i); - gContestResources->field_4[i].judgesAttentionWasRemoved = 0; + eContestantStatus[i].judgesAttentionWasRemoved = 0; } gTasks[taskId].data[1]++; gTasks[taskId].data[0] = 26; @@ -1910,8 +1912,8 @@ static void sub_80D8B38(u8 taskId) if (gTasks[taskId].data[10]++ > 9) { gTasks[taskId].data[10] = 0; - if (gContestResources->field_4[r6].numTurnsSkipped != 0 - || gContestResources->field_4[r6].turnSkipped) + if (eContestantStatus[r6].numTurnsSkipped != 0 + || eContestantStatus[r6].turnSkipped) { sub_80DB89C(); StringCopy(gStringVar1, gContestMons[r6].nickname); @@ -1924,15 +1926,15 @@ static void sub_80D8B38(u8 taskId) case 52: if (!Contest_RunTextPrinters()) { - if (!gContestResources->field_4[r6].unk15_6) + if (!eContestantStatus[r6].unk15_6) gTasks[taskId].data[0] = 17; else gTasks[taskId].data[0] = 14; } return; case 14: - r3 = gContestResources->field_4[r6].unk16; - if (gContestResources->field_4[r6].unk16 != 0) + r3 = eContestantStatus[r6].unk16; + if (eContestantStatus[r6].unk16 != 0) { sub_80DB89C(); if (r3 == 1) @@ -1968,13 +1970,13 @@ static void sub_80D8B38(u8 taskId) { if (++gTasks[taskId].data[10] > 50) { - if (!gContestResources->field_4[r6].hasJudgesAttention) + if (!eContestantStatus[r6].hasJudgesAttention) { sub_80DC028( - gContestResources->field_4[r6].appeal2, - gContestResources->field_4[r6].unk17, + eContestantStatus[r6].appeal2, + eContestantStatus[r6].unk17, r6); - gContestResources->field_4[r6].appeal2 += gContestResources->field_4[r6].unk17; + eContestantStatus[r6].appeal2 += eContestantStatus[r6].unk17; } gTasks[taskId].data[0] = 16; } @@ -1988,7 +1990,7 @@ static void sub_80D8B38(u8 taskId) } return; case 17: - if (gContestResources->field_4[r6].disappointedRepeat) + if (eContestantStatus[r6].disappointedRepeat) { sub_80DB89C(); StringCopy(gStringVar1, gContestMons[r6].nickname); @@ -2010,8 +2012,8 @@ static void sub_80D8B38(u8 taskId) case 19: if (!Contest_RunTextPrinters()) { - sub_80DC028(gContestResources->field_4[r6].appeal2, -gContestResources->field_4[r6].unk18, r6); - gContestResources->field_4[r6].appeal2 -= gContestResources->field_4[r6].unk18; + sub_80DC028(eContestantStatus[r6].appeal2, -eContestantStatus[r6].unk18, r6); + eContestantStatus[r6].appeal2 -= eContestantStatus[r6].unk18; gTasks[taskId].data[0] = 18; } return; @@ -2032,18 +2034,18 @@ static void sub_80D8B38(u8 taskId) else { r3 = gContestResources->field_10->bits_0; - if (gContestResources->field_4[r6].overrideCategoryExcitementMod) + if (eContestantStatus[r6].overrideCategoryExcitementMod) { r3 = 1; - StringCopy(gStringVar3, gMoveNames[gContestResources->field_4[r6].currMove]); + StringCopy(gStringVar3, gMoveNames[eContestantStatus[r6].currMove]); } else { - StringCopy(gStringVar3, gUnknown_08587F08[gContestMoves[gContestResources->field_4[r6].currMove].contestCategory]); + StringCopy(gStringVar3, gUnknown_08587F08[gContestMoves[eContestantStatus[r6].currMove].contestCategory]); } if (r3 > 0) { - if (gContestResources->field_4[r6].disappointedRepeat) + if (eContestantStatus[r6].disappointedRepeat) r3 = 0; } sub_80DB89C(); @@ -2134,8 +2136,8 @@ static void sub_80D8B38(u8 taskId) if (gTasks[taskId].data[11]++ > 29) { gTasks[taskId].data[11] = 0; - sub_80DC028(gContestResources->field_4[r6].appeal2, gContestResources->field_10->unk2, r6); - gContestResources->field_4[r6].appeal2 += gContestResources->field_10->unk2; + sub_80DC028(eContestantStatus[r6].appeal2, gContestResources->field_10->unk2, r6); + eContestantStatus[r6].appeal2 += gContestResources->field_10->unk2; gTasks[taskId].data[10]++; } } @@ -2171,7 +2173,7 @@ static void sub_80D8B38(u8 taskId) sub_80DB89C(); StringCopy(gStringVar3, gContestMons[gContestResources->field_10->excitementFreezer].nickname); StringCopy(gStringVar1, gContestMons[r6].nickname); - StringCopy(gStringVar2, gMoveNames[gContestResources->field_4[r6].currMove]); + StringCopy(gStringVar2, gMoveNames[eContestantStatus[r6].currMove]); StringExpandPlaceholders(gStringVar4, gText_0827E7EA); Contest_StartTextPrinter(gStringVar4, 1); gTasks[taskId].data[0] = 58; @@ -2193,11 +2195,11 @@ static void sub_80D8B38(u8 taskId) } return; case 33: - if (gContestResources->field_4[r6].hasJudgesAttention) - gContestResources->field_4[r6].hasJudgesAttention = 0; + if (eContestantStatus[r6].hasJudgesAttention) + eContestantStatus[r6].hasJudgesAttention = 0; sub_80DC9B4(r6); StringCopy(gStringVar1, gContestMons[r6].nickname); - StringCopy(gStringVar2, gMoveNames[gContestResources->field_4[r6].currMove]); + StringCopy(gStringVar2, gMoveNames[eContestantStatus[r6].currMove]); StringExpandPlaceholders(gStringVar4, gText_0827E58A); Contest_StartTextPrinter(gStringVar4, 1); gTasks[taskId].data[0] = 34; @@ -2577,7 +2579,7 @@ static void sub_80DA830(u8 taskId) DestroyTask(taskId); gFieldCallback = sub_80DA874; FreeAllWindowBuffers(); - sub_80D7A5C(); + FreeContestResources(); FreeMonSpritesGfx(); SetMainCallback2(CB2_ReturnToField); } @@ -2831,7 +2833,7 @@ static void sub_80DAEA4(void) for (i = 0; i < 4; i++) { - FillWindowPixelBuffer(gUnknown_02039F26[i], PIXEL_FILL(0)); + FillWindowPixelBuffer(gContestantTurnOrder[i], PIXEL_FILL(0)); sub_80DAF04(i); sub_80DAF88(i); } @@ -2862,7 +2864,7 @@ static void sub_80DAF1C(u8 a0, u8 a1) offset = GetStringRightAlignXOffset(7, gDisplayedStringBattle, 0x60); if (offset > 55) offset = 55; - Contest_PrintTextToBg0WindowAt(gUnknown_02039F26[a0], gDisplayedStringBattle, offset, 1, 7); + Contest_PrintTextToBg0WindowAt(gContestantTurnOrder[a0], gDisplayedStringBattle, offset, 1, 7); } static void sub_80DAF88(u8 a0) @@ -2873,7 +2875,7 @@ static void sub_80DAF88(u8 a0) static void sub_80DAFA0(u8 a0, u8 a1) { sub_80DAED4(gContestMons[a0].nickname, a1); - Contest_PrintTextToBg0WindowAt(gUnknown_02039F26[a0], gDisplayedStringBattle, 5, 1, 7); + Contest_PrintTextToBg0WindowAt(gContestantTurnOrder[a0], gDisplayedStringBattle, 5, 1, 7); } static u16 sub_80DAFE0(u8 who, u8 contestCategory) @@ -3058,7 +3060,7 @@ static void prints_contest_move_description(u16 a) static void sub_80DB4E0(u16 move, u8 b) { - u8 r7 = gUnknown_02039F26[b] * 5 + 2; + u8 r7 = gContestantTurnOrder[b] * 5 + 2; if (!Contest_IsMonsTurnDisabled(b) && move != MOVE_NONE) { @@ -3078,7 +3080,7 @@ static void sub_80DB584(void) s32 i; for (i = 0; i < 4; i++) - sub_80DB4E0(gContestResources->field_4[i].currMove, i); + sub_80DB4E0(eContestantStatus[i].currMove, i); } static u16 sub_80DB5B0(void) @@ -3093,7 +3095,7 @@ static bool8 sub_80DB5B8(u8 contestantIdx, bool8 resetMod) if (eContestantStatus[contestantIdx].conditionMod == 0) return FALSE; - r6 = gUnknown_02039F26[contestantIdx] * 5 + 2; + r6 = gContestantTurnOrder[contestantIdx] * 5 + 2; r4 = eContestantStatus[contestantIdx].condition / 10; if (eContestantStatus[contestantIdx].conditionMod == 1) { @@ -3123,7 +3125,7 @@ static void sub_80DB69C(void) for (i = 0; i < 4; i++) { - u8 r4 = gUnknown_02039F26[i] * 5 + 2; + u8 r4 = gContestantTurnOrder[i] * 5 + 2; u16 r5 = sub_80DB5B0(); r6 = eContestantStatus[i].condition / 10; @@ -3162,7 +3164,7 @@ static bool8 sub_80DB798(u8 a) { bool8 r9 = TRUE; u16 r8 = 0; - u8 r7 = gUnknown_02039F26[a] * 5 + 2; + u8 r7 = gContestantTurnOrder[a] * 5 + 2; if (eContestantStatus[a].resistant != 0 || eContestantStatus[a].immune != 0 || eContestantStatus[a].jamSafetyCount != 0 || eContestantStatus[a].jamReduction != 0) r8 = sub_80DB748(0); @@ -3272,7 +3274,7 @@ static void sub_80DB944(void) } } } - sub_80DCE58(1); + SortContestants(TRUE); sub_80DD590(); } @@ -3614,7 +3616,7 @@ static void sub_80DC0F4(u8 taskId) r11 = 1; r5-= 8; } - ContestBG_FillBoxWithTile(0, r6, r5 + 22, gUnknown_02039F26[r7] * 5 + 2 + r11, 1, 1, 17); + ContestBG_FillBoxWithTile(0, r6, r5 + 22, gContestantTurnOrder[r7] * 5 + 2 + r11, 1, 1, 17); if (r1 > 0) { PlaySE(SE_C_GAJI); @@ -3638,7 +3640,7 @@ static void sub_80DC2BC(void) LoadSpriteSheet(&gUnknown_08587A74); for (i = 0; i < 4; i++) { - u8 y = gUnknown_08587A6C[gUnknown_02039F26[i]]; + u8 y = gUnknown_08587A6C[gContestantTurnOrder[i]]; gContestResources->field_14[i].unk0 = CreateSprite(&gSpriteTemplate_8587AD0, 180, y, 1); } @@ -3707,7 +3709,7 @@ static void sub_80DC44C(void) s32 i; for (i = 0; i < 4; i++) - gSprites[gContestResources->field_14[i].unk0].pos1.y = gUnknown_08587A6C[gUnknown_02039F26[i]]; + gSprites[gContestResources->field_14[i].unk0].pos1.y = gUnknown_08587A6C[gContestantTurnOrder[i]]; } static void sub_80DC490(bool8 a) @@ -3716,7 +3718,7 @@ static void sub_80DC490(bool8 a) for (i = 0; i < 4; i++) { - if (gUnknown_02039F26[i] > 1) + if (gContestantTurnOrder[i] > 1) { if (!a) gSprites[gContestResources->field_14[i].unk0].pos1.x = 180; @@ -3736,7 +3738,7 @@ static void sub_80DC4F0(void) LoadCompressedSpriteSheet(&gUnknown_08587AE8[i]); gContestResources->field_14[i].unk1 = CreateSprite(&gSpriteTemplate_8587B18[i], 204, - gUnknown_08587A70[gUnknown_02039F26[i]], + gUnknown_08587A70[gContestantTurnOrder[i]], 0); SetSubspriteTables(&gSprites[gContestResources->field_14[i].unk1], gSubspriteTables_8587B80); gSprites[gContestResources->field_14[i].unk1].invisible = TRUE; @@ -3902,7 +3904,7 @@ static void sub_80DC9B4(u8 a) static u8 sub_80DC9EC(u8 a) { u8 spriteId1, spriteId2; - u8 x = gUnknown_02039F26[a] * 40 + 32; + u8 x = gContestantTurnOrder[a] * 40 + 32; LoadCompressedSpriteSheet(&sUnknown_08589904[a]); LoadSpritePalette(&sUnknown_08589924[a]); @@ -3913,12 +3915,12 @@ static u8 sub_80DC9EC(u8 a) CopySpriteTiles(0, 3, (void *)VRAM, - (u16 *)(BG_SCREEN_ADDR(28) + gUnknown_02039F26[a] * 5 * 64 + 0x26), + (u16 *)(BG_SCREEN_ADDR(28) + gContestantTurnOrder[a] * 5 * 64 + 0x26), gContestResources->field_34); CopySpriteTiles(0, 3, (void *)VRAM, - (u16 *)(BG_SCREEN_ADDR(28) + gUnknown_02039F26[a] * 5 * 64 + 0x36), + (u16 *)(BG_SCREEN_ADDR(28) + gContestantTurnOrder[a] * 5 * 64 + 0x36), gContestResources->field_38); CpuFill32(0, gContestResources->field_34 + 0x500, 0x300); @@ -4056,7 +4058,7 @@ static void sub_80DCD48(void) txtPtr = StringCopy(txtPtr, gText_OneDash); } ConvertIntToDecimalStringN(txtPtr, value, STR_CONV_MODE_LEFT_ALIGN, 4); - Contest_PrintTextToBg0WindowAt(gUnknown_02039F26[i], text, 55, 1, 7); + Contest_PrintTextToBg0WindowAt(gContestantTurnOrder[i], text, 55, 1, 7); } for (i = 0; i < 4; i++) { @@ -4068,88 +4070,122 @@ static void sub_80DCD48(void) txtPtr = StringCopy(txtPtr, gText_OneDash); } ConvertIntToDecimalStringN(txtPtr, value, STR_CONV_MODE_LEFT_ALIGN, 4); - Contest_PrintTextToBg0WindowAt(gUnknown_02039F26[i], text, 5, 1, 7); + Contest_PrintTextToBg0WindowAt(gContestantTurnOrder[i], text, 5, 1, 7); } sub_80DB2BC(); break; } } -void sub_80DCE58(u8 a) +void SortContestants(bool8 useRanking) { - u8 sp0[4]; - u16 sp4[4] = {0}; + u8 scratch[CONTESTANT_COUNT]; + u16 randomOrdering[CONTESTANT_COUNT] = {0}; s32 i; - s32 r2; - s32 r4; + s32 v3; - for (i = 0; i < 4; i++) + // Generate a unique random number for each contestant. + for (i = 0; i < CONTESTANT_COUNT; i++) { - sp4[i] = Random(); - for (r2 = 0; r2 < i; r2++) + s32 j; + randomOrdering[i] = Random(); + + // Loop through all the numbers generated so far. + for (j = 0; j < i; j++) { - if (sp4[i] == sp4[r2]) + if (randomOrdering[i] == randomOrdering[j]) { + // This number isn't unique; try generating again. i--; break; } } } - if (a == 0) + if (!useRanking) { - for (i = 0; i < 4; i++) + // Order based on the results of the Conditions round using Insertion Sort. + // Use the randomOrdering to break ties. + for (i = 0; i < CONTESTANT_COUNT; i++) { - gUnknown_02039F26[i] = i; - for (r4 = 0; r4 < i; r4++) + // Append this contestant to the list. + gContestantTurnOrder[i] = i; + + // Determine where the contestant should be ordered. + for (v3 = 0; v3 < i; v3++) { - if (gContestMonConditions[gUnknown_02039F26[r4]] < gContestMonConditions[i] - || (gContestMonConditions[gUnknown_02039F26[r4]] == gContestMonConditions[i] && sp4[gUnknown_02039F26[r4]] < sp4[i])) + if (gContestMonConditions[gContestantTurnOrder[v3]] < gContestMonConditions[i] + || (gContestMonConditions[gContestantTurnOrder[v3]] == gContestMonConditions[i] && randomOrdering[gContestantTurnOrder[v3]] < randomOrdering[i])) { - for (r2 = i; r2 > r4; r2--) - gUnknown_02039F26[r2] = gUnknown_02039F26[r2 - 1]; - gUnknown_02039F26[r4] = i; + // Shift everything larger up to make room. + s32 j; + for (j = i; j > v3; j--) + gContestantTurnOrder[j] = gContestantTurnOrder[j - 1]; + + // Insert into the new spot. + gContestantTurnOrder[v3] = i; break; } } - if (r4 == i) - gUnknown_02039F26[i] = i; + + // This is redundant. + // Perhaps GF switched from true insertion sort to in-place insertion sort, and forgot to + // remove this check? + if (v3 == i) + gContestantTurnOrder[i] = i; } - memcpy(sp0, gUnknown_02039F26, sizeof(sp0)); - for (i = 0; i < 4; i++) - gUnknown_02039F26[sp0[i]] = i; + + // Invert gContestantTurnOrder; above, it was a list of contestant IDs. Now it's a list of turn orderings. + // + // For example, if contestant 3 had the first turn, then `gContestantTurnOrder[1] = 3`. The turn is the index, + // the contestant is the data. After inverting the list, `gContestantTurnOrder[3] = 1`. The contestant is the index, + // and the turn is the data. + memcpy(scratch, gContestantTurnOrder, sizeof(scratch)); + for (i = 0; i < CONTESTANT_COUNT; i++) + gContestantTurnOrder[scratch[i]] = i; } else { - memset(sp0, 0xFF, sizeof(sp0)); - for (i = 0; i < 4; i++) + // Order contestants based on their ranking. + // If contestants have tied ranking, fill in the next available slot. + // + // Note that ranking is calculated so that shared places still take up a ranking + // space. A ranking like [1, 2, 2, 3] is not possible; it would be [1, 2, 2, 4] + // instead. + memset(scratch, 0xFF, sizeof(scratch)); + for (i = 0; i < CONTESTANT_COUNT; i++) { - u8 r2 = eContestantStatus[i].ranking; + u8 j = eContestantStatus[i].ranking; while (1) { - u8 *ptr = &sp0[r2]; + u8 *ptr = &scratch[j]; if (*ptr == 0xFF) { *ptr = i; - gUnknown_02039F26[i] = r2; + gContestantTurnOrder[i] = j; break; } - r2++; + j++; } } - for (i = 0; i < 3; i++) - { - for (r4 = 3; r4 > i; r4--) - { - if (eContestantStatus[r4 - 1].ranking == eContestantStatus[r4].ranking - && gUnknown_02039F26[r4 - 1] < gUnknown_02039F26[r4] - && sp4[r4 - 1] < sp4[r4]) - { - u8 temp = gUnknown_02039F26[r4]; - gUnknown_02039F26[r4] = gUnknown_02039F26[r4 - 1]; - gUnknown_02039F26[r4 - 1] = temp; + // Randomize the order of contestants with tied rankings using Selection Sort. + // + // Look through the array for tied ranks, and use randomOrdering to break the tie. + // This ensures that contestants with the same rank will be randomly ordered. This + // uses an in-place slection sort, which involves a lot of extra swapping. + for (i = 0; i < CONTESTANT_COUNT - 1; i++) + { + for (v3 = CONTESTANT_COUNT - 1; v3 > i; v3--) + { + if (eContestantStatus[v3 - 1].ranking == eContestantStatus[v3].ranking + && gContestantTurnOrder[v3 - 1] < gContestantTurnOrder[v3] + && randomOrdering[v3 - 1] < randomOrdering[v3]) + { + u8 temp = gContestantTurnOrder[v3]; + gContestantTurnOrder[v3] = gContestantTurnOrder[v3 - 1]; + gContestantTurnOrder[v3 - 1] = temp; } } } @@ -4162,7 +4198,7 @@ static void sub_80DD04C(void) for (i = 0; i < 4; i++) { - LoadPalette(&gHeap[0x1A004] + (i + 5) * 32, (gUnknown_02039F26[i] + 5) * 16, 32); + LoadPalette(&gHeap[0x1A004] + (i + 5) * 32, (gContestantTurnOrder[i] + 5) * 16, 32); } sub_80DAEA4(); } @@ -4343,7 +4379,7 @@ static void sub_80DD590(void) for (i = 0; i < 4; i++) { - sp0[i] = gUnknown_02039F26[i]; + sp0[i] = gContestantTurnOrder[i]; sp4[i] = 0; } @@ -4372,7 +4408,7 @@ static void sub_80DD590(void) for (; j < 4; j++) { if (sp4[j] == 0 && eContestantStatus[j].nextTurnOrder == 0xFF - && gUnknown_02039F26[r12] > gUnknown_02039F26[j]) + && gContestantTurnOrder[r12] > gContestantTurnOrder[j]) r12 = j; } sp0[r12] = i; @@ -4385,7 +4421,7 @@ static void sub_80DD590(void) eContestResources8.turnOrder[i] = sp0[i]; eContestantStatus[i].nextTurnOrder = 0xFF; eContestantStatus[i].turnOrderMod = 0; - gUnknown_02039F26[i] = sp0[i]; + gContestantTurnOrder[i] = sp0[i]; } } @@ -4710,7 +4746,7 @@ static void sub_80DE008(bool8 a) if (eContestantStatus[i].turnOrderMod != 0 && a) { CpuCopy32(GetTurnOrderNumberGfx(i), (void *)(VRAM + 0x10000 + (gSprites[gContestResources->field_14[i].unk1].oam.tileNum + 6) * 32), 32); - gSprites[gContestResources->field_14[i].unk1].pos1.y = gUnknown_08587A70[gUnknown_02039F26[i]]; + gSprites[gContestResources->field_14[i].unk1].pos1.y = gUnknown_08587A70[gContestantTurnOrder[i]]; gSprites[gContestResources->field_14[i].unk1].invisible = FALSE; } else @@ -4739,7 +4775,7 @@ static void sub_80DE12C(void) { if (eContestResources8.unnervedPokes[r7] != 0 && !Contest_IsMonsTurnDisabled(r7)) { - u32 r6 = gUnknown_02039F26[r7] * 5 + 2; + u32 r6 = gContestantTurnOrder[r7] * 5 + 2; u16 var = sub_80DB748(3); ContestBG_FillBoxWithIncrementingTile(0, var, 0x14, r6, r10, r8, r9, r8); @@ -4851,7 +4887,7 @@ static void sub_80DE4A8(u8 taskId) { case 0: for (i = 0; i < 4; i++) - eContest.unk19218[i] = gUnknown_02039F26[i]; + eContest.unk19218[i] = gContestantTurnOrder[i]; sub_80DBF90(); sub_80DC864(); sub_80DB69C(); @@ -5321,13 +5357,13 @@ static void sub_80DF080(u8 contestant) if (!gContestResources->field_10->excitementFrozen && gContestResources->field_10->bits_0 > 0 - && !gContestResources->field_4[contestant].disappointedRepeat) + && !eContestantStatus[contestant].disappointedRepeat) { gContestResources->field_1c[contestant].unkC |= 1; gContestResources->field_1c[contestant].unkE_2 = 1; } - if (gContestResources->field_4[contestant].nervous) + if (eContestantStatus[contestant].nervous) gContestResources->field_1c[contestant].unkC |= 2; if (!gContestResources->field_10->excitementFrozen @@ -5337,34 +5373,34 @@ static void sub_80DF080(u8 contestant) gContestResources->field_1c[contestant].unkC |= 4; } - if (gContestResources->field_4[contestant].unk15_6 - && gContestResources->field_4[contestant].unk16 != 0) + if (eContestantStatus[contestant].unk15_6 + && eContestantStatus[contestant].unk16 != 0) { gContestResources->field_1c[contestant].unkC |= 8; } for (i = 0; i < 4; i++) { - if (i != contestant && gContestResources->field_4[i].jam != 0) + if (i != contestant && eContestantStatus[i].jam != 0) { gContestResources->field_1c[contestant].unkC |= 0x10; gContestResources->field_1c[i].unkC |= 0x40; } } - if (gContestResources->field_4[contestant].numTurnsSkipped != 0 - || gContestResources->field_4[contestant].noMoreTurns) + if (eContestantStatus[contestant].numTurnsSkipped != 0 + || eContestantStatus[contestant].noMoreTurns) { gContestResources->field_1c[contestant].unkC |= 0x20; } - else if (!gContestResources->field_4[contestant].nervous) + else if (!eContestantStatus[contestant].nervous) { gContestResources->field_1c[contestant].unkC |= 0x80; gContestResources->field_1c[contestant].unkE_1 = 1; - gContestResources->field_1c[contestant].unk0[eContest.turnNumber] = gContestResources->field_4[contestant].currMove; + gContestResources->field_1c[contestant].unk0[eContest.turnNumber] = eContestantStatus[contestant].currMove; } - if (gContestResources->field_4[contestant].disappointedRepeat) + if (eContestantStatus[contestant].disappointedRepeat) gContestResources->field_1c[contestant].unkD |= 2; if (eContest.applauseLevel == 4 @@ -5634,7 +5670,7 @@ static void sub_80DF750(void) for (i = 0; i < 4; i++) { txtPtr = StringCopy(text1, gText_CDot); - Contest_PrintTextToBg0WindowAt(gUnknown_02039F26[i], text1, 5, 1, 7); + Contest_PrintTextToBg0WindowAt(gContestantTurnOrder[i], text1, 5, 1, 7); bits = gContestResources->field_1c[i].unkC; for (j = 7; j > -1; j--) // Weird loop. { @@ -5646,8 +5682,8 @@ static void sub_80DF750(void) text2[j] = text1[j]; text2[j] = EOS; - Contest_PrintTextToBg0WindowAt(gUnknown_02039F26[i], text2, 5, 1, 7); - Contest_PrintTextToBg0WindowAt(gUnknown_02039F26[i], text1 + j, 55, 1, 7); + Contest_PrintTextToBg0WindowAt(gContestantTurnOrder[i], text2, 5, 1, 7); + Contest_PrintTextToBg0WindowAt(gContestantTurnOrder[i], text1 + j, 55, 1, 7); } } else @@ -5667,8 +5703,8 @@ static void sub_80DF750(void) text2[j] = text1[j]; text2[j] = EOS; - Contest_PrintTextToBg0WindowAt(gUnknown_02039F26[i], text2, 5, 1, 7); - Contest_PrintTextToBg0WindowAt(gUnknown_02039F26[i], text1 + j, 55, 1, 7); + Contest_PrintTextToBg0WindowAt(gContestantTurnOrder[i], text2, 5, 1, 7); + Contest_PrintTextToBg0WindowAt(gContestantTurnOrder[i], text1 + j, 55, 1, 7); } } sub_80DB2BC(); diff --git a/src/contest_effect.c b/src/contest_effect.c index 369850bb4..7a7f3e3a5 100644 --- a/src/contest_effect.c +++ b/src/contest_effect.c @@ -517,7 +517,7 @@ static void ContestEffect_BadlyStartlesMonsInGoodCondition(void) // The appeal works great if performed first. static void ContestEffect_BetterIfFirst(void) { - if (gUnknown_02039F26[eContestResources8.contestant] == 0) + if (gContestantTurnOrder[eContestResources8.contestant] == 0) { u16 move = eContestantStatus[eContestResources8.contestant].currMove; eContestantStatus[eContestResources8.contestant].appeal2 += 2 * gContestEffects[gContestMoves[move].effect].appeal; @@ -528,7 +528,7 @@ static void ContestEffect_BetterIfFirst(void) // The appeal works great if performed last. static void ContestEffect_BetterIfLast(void) { - if (gUnknown_02039F26[eContestResources8.contestant] == 3) + if (gContestantTurnOrder[eContestResources8.contestant] == 3) { u16 move = eContestantStatus[eContestResources8.contestant].currMove; eContestantStatus[eContestResources8.contestant].appeal2 += 2 * gContestEffects[gContestMoves[move].effect].appeal; diff --git a/src/contest_link_80F57C4.c b/src/contest_link_80F57C4.c index 59f41d72a..a8aab95d9 100644 --- a/src/contest_link_80F57C4.c +++ b/src/contest_link_80F57C4.c @@ -3069,7 +3069,7 @@ _080F8678:\n\ static void sub_80F86B8(u8 taskId) { - sub_80DCE58(0); + SortContestants(FALSE); SetTaskFuncWithFollowupFunc(taskId, sub_80FCFD0, sub_80F8714); } diff --git a/src/contest_link_80FC4F4.c b/src/contest_link_80FC4F4.c index f582626f8..f64f1824b 100644 --- a/src/contest_link_80FC4F4.c +++ b/src/contest_link_80FC4F4.c @@ -269,7 +269,7 @@ void sub_80FC9F8(u8 taskId) case 0: if (IsLinkTaskFinished()) { - if (sub_80FC4F4(&gContestResources->field_4[gContestPlayerMonIndex].currMove, sizeof(gContestResources->field_4[gContestPlayerMonIndex].currMove)) == TRUE) + if (sub_80FC4F4(&eContestantStatus[gContestPlayerMonIndex].currMove, sizeof(eContestantStatus[gContestPlayerMonIndex].currMove)) == TRUE) gTasks[taskId].data[0]++; } break; @@ -277,7 +277,7 @@ void sub_80FC9F8(u8 taskId) if (sub_80FC55C()) { for (i = 0; i < gNumLinkContestPlayers; i++) - gContestResources->field_4[i].currMove = gBlockRecvBuffer[i][0]; + eContestantStatus[i].currMove = gBlockRecvBuffer[i][0]; gTasks[taskId].data[0]++; } @@ -373,14 +373,14 @@ void sub_80FCC88(u8 taskId) case 0: if (IsLinkTaskFinished()) { - if (sub_80FC4F4(gContestResources->field_4, 4 * sizeof(struct ContestantStatus)) == 1) + if (sub_80FC4F4(eContestantStatus, 4 * sizeof(struct ContestantStatus)) == 1) gTasks[taskId].data[0]++; } break; case 1: if (sub_80FC55C()) { - memcpy(gContestResources->field_4, gBlockRecvBuffer[gUnknown_02039F2B], 4 * sizeof(struct ContestantStatus)); + memcpy(eContestantStatus, gBlockRecvBuffer[gUnknown_02039F2B], 4 * sizeof(struct ContestantStatus)); gTasks[taskId].data[0]++; } break; @@ -425,14 +425,14 @@ void sub_80FCC88(u8 taskId) case 9: if (IsLinkTaskFinished()) { - if (sub_80FC4F4(gUnknown_02039F26, sizeof(gUnknown_02039F26)) == 1) + if (sub_80FC4F4(gContestantTurnOrder, sizeof(gContestantTurnOrder)) == 1) gTasks[taskId].data[0]++; } break; case 10: if (sub_80FC55C()) { - memcpy(gUnknown_02039F26, gBlockRecvBuffer[gUnknown_02039F2B], sizeof(gUnknown_02039F26)); + memcpy(gContestantTurnOrder, gBlockRecvBuffer[gUnknown_02039F2B], sizeof(gContestantTurnOrder)); gTasks[taskId].data[0]++; } break; @@ -528,14 +528,14 @@ void sub_80FCFD0(u8 taskId) case 0: if (IsLinkTaskFinished()) { - if (sub_80FC4F4(gUnknown_02039F26, sizeof(gUnknown_02039F26)) == 1) + if (sub_80FC4F4(gContestantTurnOrder, sizeof(gContestantTurnOrder)) == 1) gTasks[taskId].data[0]++; } break; case 1: if (sub_80FC55C()) { - memcpy(gUnknown_02039F26, gBlockRecvBuffer[gUnknown_02039F2B], sizeof(gUnknown_02039F26)); + memcpy(gContestantTurnOrder, gBlockRecvBuffer[gUnknown_02039F2B], sizeof(gContestantTurnOrder)); gTasks[taskId].data[0]++; } break; diff --git a/src/contest_link_81D9DE4.c b/src/contest_link_81D9DE4.c index 4b56c9c38..8060b6cdc 100644 --- a/src/contest_link_81D9DE4.c +++ b/src/contest_link_81D9DE4.c @@ -134,7 +134,7 @@ static void sub_81DA10C(u8 taskId) static void sub_81DA138(u8 taskId) { - sub_80DCE58(0); + SortContestants(FALSE); SetTaskFuncWithFollowupFunc(taskId, sub_80FCFD0, sub_80F8714); } From f79a2fda68cdaf2a36cccf5c8cd0c94ce321d92b Mon Sep 17 00:00:00 2001 From: Phlosioneer Date: Tue, 2 Apr 2019 20:46:18 -0400 Subject: [PATCH 04/22] Document the nextTurnOrder calculations --- src/contest.c | 76 +++++++++++++++++++++++++++++++++------------------ 1 file changed, 49 insertions(+), 27 deletions(-) diff --git a/src/contest.c b/src/contest.c index 57c8b46d6..4e54797c8 100644 --- a/src/contest.c +++ b/src/contest.c @@ -116,7 +116,7 @@ static void sub_80DC5E8(void); static void sub_80DC7EC(void); static void sub_80DCD48(void); static void sub_80DD04C(void); -static void sub_80DD590(void); +static void ApplyNextTurnOrder(void); static void sub_80DDB0C(void); static void sub_80DDBE8(void); static void sub_80DE224(void); @@ -975,7 +975,7 @@ static void InitContestResources(void) eContestantStatus[i].nextTurnOrder = 0xFF; eContest.unk19218[i] = gContestantTurnOrder[i]; } - sub_80DD590(); + ApplyNextTurnOrder(); memset(gContestResources->field_1c, 0, sizeof(*gContestResources->field_1c) * CONTESTANT_COUNT); } @@ -3275,7 +3275,7 @@ static void sub_80DB944(void) } } SortContestants(TRUE); - sub_80DD590(); + ApplyNextTurnOrder(); } static void sub_80DBA18(void) @@ -4369,59 +4369,81 @@ void MakeContestantNervous(u8 p) eContestantStatus[p].currMove = MOVE_NONE; } -static void sub_80DD590(void) +// This function calculates the new turn order for the next round. The +// algorithm first checks for explicit turn assignments in the +// ContestantStatus::nextTurnOrder field of each contestant. The remaining +// turns are assigned such that the turn order will reverse. +// +// For example, if no pokemon have a defined nextTurnOrder, then the 4th +// will become 1st, the 3rd will become 2nd, etc. +// +// Note: This function assumes that multiple pokemon cannot have the same +// nextTurnOrder value. +static void ApplyNextTurnOrder(void) { - u8 r12 = 0; + u8 nextContestant = 0; s32 i; s32 j; - u8 sp0[4]; - u8 sp4[4]; + u8 newTurnOrder[CONTESTANT_COUNT]; + bool8 isContestantOrdered[CONTESTANT_COUNT]; - for (i = 0; i < 4; i++) + // Copy the current turn order. + for (i = 0; i < CONTESTANT_COUNT; i++) { - sp0[i] = gContestantTurnOrder[i]; - sp4[i] = 0; + newTurnOrder[i] = gContestantTurnOrder[i]; + isContestantOrdered[i] = FALSE; } - for (i = 0; i < 4; i++) + // For each turn, assign a contestant to that turn. + for (i = 0; i < CONTESTANT_COUNT; i++) { - for (j = 0; j < 4; j++) + // Look for explicit turn assignments. + for (j = 0; j < CONTESTANT_COUNT; j++) { if (eContestantStatus[j].nextTurnOrder == i) { - sp0[j] = i; - sp4[j] = 1; + newTurnOrder[j] = i; + isContestantOrdered[j] = TRUE; break; } } - if (j == 4) + + if (j == CONTESTANT_COUNT) { - for (j = 0; j < 4; j++) + // No contestant was assigned to this turn. Look for the unassigned contestant + // with the highest turn order. + // + // First, look for the first unassigned contestant. + for (j = 0; j < CONTESTANT_COUNT; j++) { - if (sp4[j] == 0 && eContestantStatus[j].nextTurnOrder == 0xFF) + if (!isContestantOrdered[j] && eContestantStatus[j].nextTurnOrder == 0xFF) { - r12 = j; + nextContestant = j; j++; break; } } - for (; j < 4; j++) + + // Then, look for a better candidate, with a higher turn order. + for (; j < CONTESTANT_COUNT; j++) { - if (sp4[j] == 0 && eContestantStatus[j].nextTurnOrder == 0xFF - && gContestantTurnOrder[r12] > gContestantTurnOrder[j]) - r12 = j; + if (!isContestantOrdered[j] && eContestantStatus[j].nextTurnOrder == 0xFF + && gContestantTurnOrder[nextContestant] > gContestantTurnOrder[j]) + nextContestant = j; } - sp0[r12] = i; - sp4[r12] = 1; + + // Assign the contestant to this turn. + newTurnOrder[nextContestant] = i; + isContestantOrdered[nextContestant] = TRUE; } } - for (i = 0; i < 4; i++) + for (i = 0; i < CONTESTANT_COUNT; i++) { - eContestResources8.turnOrder[i] = sp0[i]; + eContestResources8.turnOrder[i] = newTurnOrder[i]; eContestantStatus[i].nextTurnOrder = 0xFF; eContestantStatus[i].turnOrderMod = 0; - gContestantTurnOrder[i] = sp0[i]; + gContestantTurnOrder[i] = newTurnOrder[i]; } } From 8f13e991d2b8245556a485ff014fbcba3813ca34 Mon Sep 17 00:00:00 2001 From: Phlosioneer Date: Tue, 2 Apr 2019 21:51:21 -0400 Subject: [PATCH 05/22] Found a debug system for pokemon contests --- include/contest.h | 16 +++- include/new_game.h | 4 +- src/berry_blender.c | 2 +- src/contest.c | 145 +++++++++++++++++++------------------ src/contest_link_80F57C4.c | 2 +- src/new_game.c | 2 +- 6 files changed, 92 insertions(+), 79 deletions(-) diff --git a/include/contest.h b/include/contest.h index c62749770..9b4ecc10a 100644 --- a/include/contest.h +++ b/include/contest.h @@ -3,6 +3,14 @@ #define CONTESTANT_COUNT 4 +#define CONTEST_DEBUG_MODE_OFF 0 +// Prints the totalPoints value for each contestant. +#define CONTEST_DEBUG_MODE_PRINT_POINT_TOTAL 1 +// Prints the ContestResourcesField1C::unk_C value as a bitstring for each contestant. +#define CONTEST_DEBUG_MODE_PRINT_UNK_C 2 +// Prints the ContestResourcesField1C::unk_D value as a bitstring for each contestant. +#define CONTEST_DEBUG_MODE_PRINT_UNK_D 3 + enum { CONTEST_CATEGORY_COOL, @@ -281,7 +289,7 @@ struct Contest /*0x11*/ u8 unk19215; /*0x12*/ u8 unk19216; // sprite ID /*0x13*/ s8 applauseLevel; - /*0x19218*/ u8 unk19218[CONTESTANT_COUNT]; + /*0x19218*/ u8 prevTurnOrder[CONTESTANT_COUNT]; /*0x1921C*/ u32 unk1921C; // saved RNG value? u16 unk19220[5][4]; // move history? u8 unk19248[5][4]; // excitement history @@ -417,7 +425,7 @@ struct ContestResources struct ContestStruct_field_18 *field_18; struct ContestResourcesField1C * field_1c; struct ContestResourcesField20 * field_20; - u8 * field_24[4]; + u8 * ContestantInfoTilemaps[CONTESTANT_COUNT]; void * field_34; void * field_38; void * field_3c; @@ -431,7 +439,7 @@ struct ContestResources #define eContestResources14 (*gContestResources->field_14) #define eUnknownHeap18000 (gHeap + 0x18000) #define eUnknownHeap19000 (gHeap + 0x19000) -#define eUnknownHeap1A000 (gHeap[0x1a000]) +#define eContestDebugMode (gHeap[0x1a000]) #define eUnknownHeap1A004 (*(struct Shared1A004 *)(gHeap + 0x1a004)) extern struct ContestPokemon gContestMons[4]; @@ -460,7 +468,7 @@ extern u32 gContestRngValue; // contest.c void ResetLinkContestBoolean(void); void LoadContestBgAfterMoveAnim(void); -void sub_80D7B24(void); +void CB2_ContestMain(void); void sub_80DA8C8(u8 partyIndex); void sub_80DAB8C(u8 contestType, u8 rank); void sub_80DACBC(u8 contestType, u8 rank, bool32 isPostgame); diff --git a/include/new_game.h b/include/new_game.h index 8fab05483..9b96ba478 100644 --- a/include/new_game.h +++ b/include/new_game.h @@ -2,7 +2,9 @@ #define GUARD_NEW_GAME_H extern bool8 gDifferentSaveFile; -extern bool8 gUnknown_020322D5; // The purpose of this variable is unknown as it's read only 3 times(2 times in contest.c and 1 time in berry_blender.c), never written to. +// Shortcuts some randomness in berry_blender.c, and enables debug printing +// in contest.c. +extern bool8 gEnableContestDebugging; void SetTrainerId(u32 trainerId, u8 *dst); u32 GetTrainerId(u8 *trainerId); diff --git a/src/berry_blender.c b/src/berry_blender.c index 26327a634..d1e8e1ab8 100644 --- a/src/berry_blender.c +++ b/src/berry_blender.c @@ -2037,7 +2037,7 @@ static void sub_8081744(void) sBerryBlenderData->field_4C--; sBerryBlenderData->field_72 = 0; } - if (gUnknown_020322D5 && gMain.newKeys & L_BUTTON) + if (gEnableContestDebugging && gMain.newKeys & L_BUTTON) sBerryBlenderData->field_123 ^= 1; } diff --git a/src/contest.c b/src/contest.c index 4e54797c8..431942181 100644 --- a/src/contest.c +++ b/src/contest.c @@ -114,7 +114,7 @@ static void sub_80DC4F0(void); static void CreateApplauseMeterSprite(void); static void sub_80DC5E8(void); static void sub_80DC7EC(void); -static void sub_80DCD48(void); +static void ContestDebugDoPrint(void); static void sub_80DD04C(void); static void ApplyNextTurnOrder(void); static void sub_80DDB0C(void); @@ -186,7 +186,7 @@ static void sub_80DEA5C(void); static void sub_80DF250(void); static void sub_80DF4F8(void); static void sub_80DF080(u8); -static void sub_80DF750(void); +static void ContestDebugPrintBitStrings(void); static void sub_80DF9D4(u8 *); static void sub_80DF9E0(u8 *, s32); static void sub_80DB2BC(void); @@ -574,7 +574,7 @@ const u16 gUnknown_08587C30[] = INCBIN_U16("graphics/unknown/unknown_587C30.gbap #include "data/contest_text_tables.h" -const struct BgTemplate gUnknown_08587F34[] = +static const struct BgTemplate sContestantInfoBgTemplates[] = { { .bg = 0, @@ -614,7 +614,7 @@ const struct BgTemplate gUnknown_08587F34[] = } }; -const struct WindowTemplate gUnknown_08587F44[] = +static const struct WindowTemplate sContestWindowTemplates[] = { { .bg = 0, @@ -861,7 +861,7 @@ void ResetLinkContestBoolean(void) gIsLinkContest = 0; } -static void sub_80D7678(void) +static void SetupContestGpuRegs(void) { u16 savedIme; @@ -905,22 +905,22 @@ void LoadContestBgAfterMoveAnim(void) } } -static void sub_80D779C(void) +static void InitContestInfoBgs(void) { s32 i; ResetBgsAndClearDma3BusyFlags(0); - InitBgsFromTemplates(0, gUnknown_08587F34, ARRAY_COUNT(gUnknown_08587F34)); + InitBgsFromTemplates(0, sContestantInfoBgTemplates, ARRAY_COUNT(sContestantInfoBgTemplates)); SetBgAttribute(3, BG_ATTR_WRAPAROUND, 1); - for (i = 0; i < 4; i++) + for (i = 0; i < CONTESTANT_COUNT; i++) { - SetBgTilemapBuffer(i, gContestResources->field_24[i]); + SetBgTilemapBuffer(i, gContestResources->ContestantInfoTilemaps[i]); } } -static void sub_80D77E4(void) +static void InitContestWindows(void) { - InitWindows(gUnknown_08587F44); + InitWindows(sContestWindowTemplates); DeactivateAllTextPrinters(); if (gIsLinkContest & 1) { @@ -973,8 +973,10 @@ static void InitContestResources(void) for (i = 0; i < CONTESTANT_COUNT; i++) { eContestantStatus[i].nextTurnOrder = 0xFF; - eContest.unk19218[i] = gContestantTurnOrder[i]; + eContest.prevTurnOrder[i] = gContestantTurnOrder[i]; } + // Calling this here while all the nextTurnOrder values are 0xFF will actually + // just reverse the turn order. ApplyNextTurnOrder(); memset(gContestResources->field_1c, 0, sizeof(*gContestResources->field_1c) * CONTESTANT_COUNT); } @@ -991,15 +993,15 @@ static void AllocContestResources(void) gContestResources->field_18 = AllocZeroed(sizeof(struct ContestStruct_field_18)); gContestResources->field_1c = AllocZeroed(sizeof(struct ContestResourcesField1C) * CONTESTANT_COUNT); gContestResources->field_20 = AllocZeroed(sizeof(struct ContestResourcesField20)); - gContestResources->field_24[0] = AllocZeroed(0x1000); - gContestResources->field_24[1] = AllocZeroed(0x1000); - gContestResources->field_24[2] = AllocZeroed(0x1000); - gContestResources->field_24[3] = AllocZeroed(0x1000); + gContestResources->ContestantInfoTilemaps[0] = AllocZeroed(0x1000); + gContestResources->ContestantInfoTilemaps[1] = AllocZeroed(0x1000); + gContestResources->ContestantInfoTilemaps[2] = AllocZeroed(0x1000); + gContestResources->ContestantInfoTilemaps[3] = AllocZeroed(0x1000); gContestResources->field_34 = AllocZeroed(0x800); gContestResources->field_38 = AllocZeroed(0x800); gContestResources->field_3c = AllocZeroed(0x2000); gUnknown_0202305C = gContestResources->field_3c; - gUnknown_02023060 = gContestResources->field_24[1]; + gUnknown_02023060 = gContestResources->ContestantInfoTilemaps[1]; } static void FreeContestResources(void) @@ -1013,10 +1015,10 @@ static void FreeContestResources(void) FREE_AND_SET_NULL(gContestResources->field_18); FREE_AND_SET_NULL(gContestResources->field_1c); FREE_AND_SET_NULL(gContestResources->field_20); - FREE_AND_SET_NULL(gContestResources->field_24[0]); - FREE_AND_SET_NULL(gContestResources->field_24[1]); - FREE_AND_SET_NULL(gContestResources->field_24[2]); - FREE_AND_SET_NULL(gContestResources->field_24[3]); + FREE_AND_SET_NULL(gContestResources->ContestantInfoTilemaps[0]); + FREE_AND_SET_NULL(gContestResources->ContestantInfoTilemaps[1]); + FREE_AND_SET_NULL(gContestResources->ContestantInfoTilemaps[2]); + FREE_AND_SET_NULL(gContestResources->ContestantInfoTilemaps[3]); FREE_AND_SET_NULL(gContestResources->field_34); FREE_AND_SET_NULL(gContestResources->field_38); FREE_AND_SET_NULL(gContestResources->field_3c); @@ -1025,7 +1027,7 @@ static void FreeContestResources(void) gUnknown_02023060 = NULL; } -void sub_80D7B24(void) +void CB2_ContestMain(void) { switch (gMain.state) { @@ -1036,9 +1038,9 @@ void sub_80D7B24(void) FREE_AND_SET_NULL(gMonSpritesGfxPtr->firstDecompressed); gMonSpritesGfxPtr->firstDecompressed = AllocZeroed(0x4000); SetVBlankCallback(NULL); - sub_80D779C(); - sub_80D77E4(); - sub_80D7678(); + InitContestInfoBgs(); + InitContestWindows(); + SetupContestGpuRegs(); ScanlineEffect_Clear(); ResetPaletteFade(); gPaletteFade.bufferTransferDisabled = TRUE; @@ -1046,7 +1048,7 @@ void sub_80D7B24(void) ResetTasks(); FreeAllSpritePalettes(); gReservedSpritePaletteCount = 4; - eUnknownHeap1A000 = 0; + eContestDebugMode = CONTEST_DEBUG_MODE_OFF; ClearBattleMonForms(); InitContestResources(); gMain.state++; @@ -1181,7 +1183,7 @@ static u8 sub_80D7E44(u8 *a) case 4: CopyToBgTilemapBuffer(2, gUnknown_08C17170, 0, 0); CopyBgTilemapBufferToVram(2); - DmaCopy32Defvars(3, gContestResources->field_24[2], eUnknownHeap1A004.unk18A04, 0x800); + DmaCopy32Defvars(3, gContestResources->ContestantInfoTilemaps[2], eUnknownHeap1A004.unk18A04, 0x800); break; case 5: LoadCompressedPalette(gUnknown_08C16E90, 0, 0x200); @@ -1326,7 +1328,7 @@ static void sub_80D833C(u8 taskId) { gBattle_BG0_Y = 0; gBattle_BG2_Y = 0; - sub_80DCD48(); + ContestDebugDoPrint(); DmaCopy32Defvars(3, gPlttBufferUnfaded, eUnknownHeap1A004.unk18204, 0x400); ConvertIntToDecimalStringN(gStringVar1, eContest.turnNumber + 1, STR_CONV_MODE_LEFT_ALIGN, 1); if (!Contest_IsMonsTurnDisabled(gContestPlayerMonIndex)) @@ -1579,7 +1581,7 @@ static void sub_80D8B38(u8 taskId) switch (gTasks[taskId].data[0]) { case 0: - sub_80DCD48(); + ContestDebugDoPrint(); for (i = 0; eContest.unk19214 != gContestResources->field_8->turnOrder[i]; i++) ; eContest.unk19215 = i; @@ -1608,7 +1610,7 @@ static void sub_80D8B38(u8 taskId) return; case 2: sub_80DF080(r6); - sub_80DF750(); + ContestDebugPrintBitStrings(); if (eContestantStatus[r6].numTurnsSkipped != 0 || eContestantStatus[r6].noMoreTurns) { @@ -2018,7 +2020,7 @@ static void sub_80D8B38(u8 taskId) } return; case 18: - sub_80DCD48(); + ContestDebugDoPrint(); if (!gContestResources->field_14[r6].unk2_2) { gTasks[taskId].data[10] = 0; @@ -2426,7 +2428,7 @@ static void sub_80DA3CC(u8 taskId) { gTasks[taskId].data[0] = 0; gTasks[taskId].func = sub_80DA464; - sub_80DCD48(); + ContestDebugDoPrint(); } } } @@ -2504,7 +2506,7 @@ static void sub_80DA5E8(u8 taskId) { sub_80DF250(); sub_80DF4F8(); - sub_80DF750(); + ContestDebugPrintBitStrings(); } gContestRngValue = gRngValue; StringExpandPlaceholders(gStringVar4, gText_0827D597); @@ -2987,8 +2989,8 @@ bool8 IsSpeciesNotUnown(u16 species) static void sub_80DB2BC(void) { - CpuCopy16(gContestResources->field_24[0], gContestResources->field_24[0] + 0x500, 0x280); - CpuCopy16(gContestResources->field_24[2], gContestResources->field_24[2] + 0x500, 0x280); + CpuCopy16(gContestResources->ContestantInfoTilemaps[0], gContestResources->ContestantInfoTilemaps[0] + 0x500, 0x280); + CpuCopy16(gContestResources->ContestantInfoTilemaps[2], gContestResources->ContestantInfoTilemaps[2] + 0x500, 0x280); } static u16 sub_80DB2EC(u16 a0, u8 a1) @@ -3788,7 +3790,7 @@ static void sub_80DC6A4(u8 taskId) { gTasks[eContest.unk19211].data[r4 * 4 + 0] = 0xFF; gTasks[eContest.unk19211].data[r4 * 4 + 1] = 0; - BlendPalette((eContest.unk19218[r4] + 5) * 16 + 6, 2, 0, RGB(31, 31, 18)); + BlendPalette((eContest.prevTurnOrder[r4] + 5) * 16 + 6, 2, 0, RGB(31, 31, 18)); DestroyTask(taskId); } } @@ -3813,7 +3815,7 @@ static void sub_80DC728(u8 taskId) gTasks[taskId].data[r3 + 1] ^= 1; BlendPalette( - (eContest.unk19218[i] + 5) * 16 + 6, + (eContest.prevTurnOrder[i] + 5) * 16 + 6, 2, gTasks[taskId].data[r3 + 0], RGB(31, 31, 18)); @@ -4006,45 +4008,45 @@ static void sub_80DCCD8(struct Sprite *sprite) } // Unused. -static void sub_80DCD08(void) +static void ContestDebugTogglePointTotal(void) { - if(eUnknownHeap1A000 == 1) - eUnknownHeap1A000 = 0; + if(eContestDebugMode == CONTEST_DEBUG_MODE_PRINT_POINT_TOTAL) + eContestDebugMode = CONTEST_DEBUG_MODE_OFF; else - eUnknownHeap1A000 = 1; + eContestDebugMode = CONTEST_DEBUG_MODE_PRINT_POINT_TOTAL; - if(eUnknownHeap1A000 == 0) + if(eContestDebugMode == CONTEST_DEBUG_MODE_OFF) { sub_80DAEA4(); sub_80DB2BC(); } else { - sub_80DCD48(); + ContestDebugDoPrint(); } } -static void sub_80DCD48(void) +static void ContestDebugDoPrint(void) { u8 i; s16 value; u8 *txtPtr; u8 text[8]; - if (gUnknown_020322D5 == 0) + if (!gEnableContestDebugging) return; - switch (eUnknownHeap1A000) + switch (eContestDebugMode) { - case 0: + case CONTEST_DEBUG_MODE_OFF: break; - case 2: - case 3: - sub_80DF750(); + case CONTEST_DEBUG_MODE_PRINT_UNK_C: + case CONTEST_DEBUG_MODE_PRINT_UNK_D: + ContestDebugPrintBitStrings(); break; - // The only other possible value is 1, which is only set by sub_80DCD08, which is unused. - // So this code is unreachable. - // case 1: + // The only other possible value is 1, which is only set by ContestDebugTogglePointTotal. + // + // case CONTEST_DEBUG_MODE_PRINT_POINT_TOTAL: default: for (i = 0; i < 4; i++) FillWindowPixelBuffer(i, PIXEL_FILL(0)); @@ -4842,7 +4844,7 @@ static void sub_80DE224(void) SetGpuReg(REG_OFFSET_BG1HOFS, gBattle_BG1_X); SetGpuReg(REG_OFFSET_BG1VOFS, gBattle_BG1_Y); - CpuFill32(0, gContestResources->field_24[1], 0x1000); + CpuFill32(0, gContestResources->ContestantInfoTilemaps[1], 0x1000); CopyToBgTilemapBuffer(1, gUnknown_08C17980, 0, 0); Contest_SetBgCopyFlags(1); @@ -4860,7 +4862,7 @@ static void sub_80DE350(void) u16 bg1Cnt; RequestDma3Fill(0,(void *)(BG_CHAR_ADDR(2)), 0x2000, 0x1); - CpuFill32(0, gContestResources->field_24[1], 0x1000); + CpuFill32(0, gContestResources->ContestantInfoTilemaps[1], 0x1000); Contest_SetBgCopyFlags(1); bg1Cnt = GetGpuReg(REG_OFFSET_BG1CNT); ((vBgCnt *) &bg1Cnt)->priority = 1; @@ -4909,7 +4911,7 @@ static void sub_80DE4A8(u8 taskId) { case 0: for (i = 0; i < 4; i++) - eContest.unk19218[i] = gContestantTurnOrder[i]; + eContest.prevTurnOrder[i] = gContestantTurnOrder[i]; sub_80DBF90(); sub_80DC864(); sub_80DB69C(); @@ -5645,32 +5647,32 @@ static void sub_80DF4F8(void) } // Unused -void sub_80DF704(u8 arg0) +void ContestDebugToggleBitfields(bool8 showUnkD) { - if (eUnknownHeap1A000 == 0) + if (eContestDebugMode == CONTEST_DEBUG_MODE_OFF) { - if (arg0 == 0) - eUnknownHeap1A000 = 2; + if (!showUnkD) + eContestDebugMode = CONTEST_DEBUG_MODE_PRINT_UNK_C; else - eUnknownHeap1A000 = 3; + eContestDebugMode = CONTEST_DEBUG_MODE_PRINT_UNK_D; } else { - eUnknownHeap1A000 = 0; + eContestDebugMode = CONTEST_DEBUG_MODE_OFF; } - if (eUnknownHeap1A000 == 0) + if (eContestDebugMode == CONTEST_DEBUG_MODE_OFF) { sub_80DAEA4(); sub_80DB2BC(); } else { - sub_80DF750(); + ContestDebugPrintBitStrings(); } } -static void sub_80DF750(void) +static void ContestDebugPrintBitStrings(void) { u8 i; s8 j; @@ -5679,17 +5681,18 @@ static void sub_80DF750(void) u8 *txtPtr; u32 bits; - if (gUnknown_020322D5 == 0) + if (!gEnableContestDebugging) return; - if (eUnknownHeap1A000 != 2 && eUnknownHeap1A000 != 3) + + if (eContestDebugMode != CONTEST_DEBUG_MODE_PRINT_UNK_C && eContestDebugMode != CONTEST_DEBUG_MODE_PRINT_UNK_D) return; - for (i = 0; i < 4; i++) + for (i = 0; i < CONTESTANT_COUNT; i++) FillWindowPixelBuffer(i, PIXEL_FILL(0)); - if (eUnknownHeap1A000 == 2) + if (eContestDebugMode == CONTEST_DEBUG_MODE_PRINT_UNK_C) { - for (i = 0; i < 4; i++) + for (i = 0; i < CONTESTANT_COUNT; i++) { txtPtr = StringCopy(text1, gText_CDot); Contest_PrintTextToBg0WindowAt(gContestantTurnOrder[i], text1, 5, 1, 7); @@ -5710,7 +5713,7 @@ static void sub_80DF750(void) } else { - for (i = 0; i < 4; i++) + for (i = 0; i < CONTESTANT_COUNT; i++) { StringCopy(text1, gText_BDot); bits = gContestResources->field_1c[i].unkD; diff --git a/src/contest_link_80F57C4.c b/src/contest_link_80F57C4.c index a8aab95d9..8d0491efd 100644 --- a/src/contest_link_80F57C4.c +++ b/src/contest_link_80F57C4.c @@ -2830,7 +2830,7 @@ void sub_80F8390(void) void sub_80F83D0(void) { - SetMainCallback2(sub_80D7B24); + SetMainCallback2(CB2_ContestMain); } static void sub_80F83E0(u8 taskId) diff --git a/src/new_game.c b/src/new_game.c index 19f3461b4..feab258d9 100644 --- a/src/new_game.c +++ b/src/new_game.c @@ -56,7 +56,7 @@ static void ResetMiniGamesResults(void); // EWRAM vars EWRAM_DATA bool8 gDifferentSaveFile = FALSE; -EWRAM_DATA bool8 gUnknown_020322D5 = FALSE; +EWRAM_DATA bool8 gEnableContestDebugging = FALSE; // const rom data static const struct ContestWinner sContestWinnerPicDummy = From f82bdb332af669681fdc7edda689753c97ebeede Mon Sep 17 00:00:00 2001 From: Phlosioneer Date: Wed, 3 Apr 2019 03:00:06 -0400 Subject: [PATCH 06/22] Document applause meter code --- include/contest.h | 15 ++-- include/graphics.h | 4 +- src/contest.c | 220 ++++++++++++++++++++++++--------------------- src/graphics.c | 4 +- 4 files changed, 130 insertions(+), 113 deletions(-) diff --git a/include/contest.h b/include/contest.h index 9b4ecc10a..c4e752072 100644 --- a/include/contest.h +++ b/include/contest.h @@ -1,7 +1,10 @@ #ifndef GUARD_CONTEST_H #define GUARD_CONTEST_H +#include "palette.h" + #define CONTESTANT_COUNT 4 +#define APPLAUSE_METER_SIZE 5 #define CONTEST_DEBUG_MODE_OFF 0 // Prints the totalPoints value for each contestant. @@ -247,10 +250,10 @@ struct ContestPokemon struct Shared1A004 { - /*0x18004*/ u16 unk18004[16][16]; - /*0x18204*/ u16 unk18204[0x200]; - /*0x18604*/ u16 unk18604[0x200]; - /*0x18A04*/ u8 unk18A04[0x800]; + u16 unk18004[16][16]; // Saved palette data before a move happens? + u16 unk18204[PLTT_BUFFER_SIZE]; // Saved copy of gPlttBufferUnfaded + u16 unk18604[PLTT_BUFFER_SIZE]; // Saved copy of gPlttBufferFaded + u8 savedJunk[0x800]; }; struct ContestStruct_field_18 @@ -274,8 +277,8 @@ struct Contest u16 unk1920A_2:1; u16 unk1920A_3:1; u16 unk1920A_4:1; - u16 unk1920A_5:1; - u16 unk1920A_6:1; + u16 isShowingApplauseMeter:1; + u16 applauseMeterIsMoving:1; u16 unk1920A_7:1; /*0x7*/ u16 unk1920B_0:1; u16 unk1920B_1:1; diff --git a/include/graphics.h b/include/graphics.h index 2584e713e..39c2895bd 100644 --- a/include/graphics.h +++ b/include/graphics.h @@ -4761,8 +4761,8 @@ extern const u32 gContestAudienceGfx[]; extern const u8 gContestApplauseMeterGfx[]; extern const u8 gContestNextTurnNumbersGfx[]; extern const u8 gContestNextTurnRandomGfx[]; -extern const u32 gUnknown_08C16FA8[]; -extern const u32 gUnknown_08C16E90[]; +extern const u32 gOldContestGfx[]; +extern const u32 gOldContestPalette[]; extern const u32 gUnknown_08C17170[]; extern const u32 gUnknown_08C17980[]; extern const u32 gTiles_8C19450[]; diff --git a/src/contest.c b/src/contest.c index 431942181..5263b961f 100644 --- a/src/contest.c +++ b/src/contest.c @@ -45,6 +45,9 @@ #include "constants/rgb.h" #include "contest_ai.h" +#define CONTESTANT_WINDOW_START 5 +#define APPLAUSE_METER_GFX_TAG 0xABE2 + // This file's functions. static void sub_80D782C(void); static void sub_80D7C7C(u8 taskId); @@ -117,8 +120,8 @@ static void sub_80DC7EC(void); static void ContestDebugDoPrint(void); static void sub_80DD04C(void); static void ApplyNextTurnOrder(void); -static void sub_80DDB0C(void); -static void sub_80DDBE8(void); +static void StartMoveApplauseMeterOnscreen(void); +static void TryMoveApplauseMeterOffscreen(void); static void sub_80DE224(void); static void sub_80DE350(void); static void sub_80DE424(u8); @@ -127,7 +130,7 @@ static void sub_80DEA20(void); static void Contest_StartTextPrinter(const u8 *, u32); static void ContestBG_FillBoxWithIncrementingTile(u8, u16, u8, u8, u8, u8, u8, s16); static bool32 Contest_RunTextPrinters(void); -static void Contest_SetBgCopyFlags(u32); +static void Contest_SetBgCopyFlags(u32 flagIndex); static void sub_80DBD18(void); static void sub_80DD080(u8); static void sub_80DE9DC(u8); @@ -148,9 +151,9 @@ static bool8 sub_80DB798(u8); static void sub_80DB884(void); static void sub_80DC9B4(u8); static void sub_80DDED0(s8, s8); -static void sub_80DDCDC(s8); +static void ShowAndUpdateApplauseMeter(s8 unused); static void sub_80DDE0C(void); -static void sub_80DD940(void); +static void UpdateApplauseMeter(void); static void sub_80DB944(void); static void sub_80DBA18(void); static void sub_80DC3AC(void); @@ -169,11 +172,11 @@ static void sub_80DC81C(u8); static void sub_80DC87C(u8); static void sub_80DCC84(struct Sprite *); static void sub_80DCCD8(struct Sprite *sprite); -static u8 sub_80DDA20(void); -static void c3_08130B10(u8); -static void sub_80DDB6C(u8); -static void task08_080CD1CC(u8); -static void sub_80DDD20(u8); +static u8 StartApplauseOverflowAnimation(void); +static void Task_ApplauseOverflowAnimation(u8); +static void Task_MoveApplauseMeterOnscreen(u8); +static void Task_MoveApplauseMeterOffscreen(u8); +static void Task_ShowAndUpdateApplauseMeter(u8); static void sub_80DDE30(u8); static void sub_80DDF80(u8); static const u8 *GetTurnOrderNumberGfx(u8); @@ -470,20 +473,20 @@ const struct SpriteTemplate gSpriteTemplate_8587B98 = .callback = SpriteCallbackDummy }; -const struct CompressedSpriteSheet gUnknown_08587BB0 = +static const struct CompressedSpriteSheet sApplauseMeterSpriteSheet = { .data = gContestApplauseGfx, .size = 0x400, - .tag = 0xABE2 + .tag = APPLAUSE_METER_GFX_TAG }; -const struct SpritePalette gUnknown_08587BB8 = +static const struct SpritePalette sApplauseMeterPalette = { .data = gContestPal, - .tag = 0xABE2 + .tag = APPLAUSE_METER_GFX_TAG }; -const struct OamData gOamData_8587BC0 = +static const struct OamData sApplauseMeterOamData = { .y = 0, .affineMode = 0, @@ -500,11 +503,11 @@ const struct OamData gOamData_8587BC0 = .affineParam = 0 }; -const struct SpriteTemplate gSpriteTemplate_8587BC8 = +static const struct SpriteTemplate sApplauseMeterSpriteTemplate = { - .tileTag = 0xABE2, - .paletteTag = 0xABE2, - .oam = &gOamData_8587BC0, + .tileTag = APPLAUSE_METER_GFX_TAG, + .paletteTag = APPLAUSE_METER_GFX_TAG, + .oam = &sApplauseMeterOamData, .anims = gDummySpriteAnimTable, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, @@ -661,7 +664,7 @@ static const struct WindowTemplate sContestWindowTemplates[] = .paletteNum = 0xF, .baseBlock = 0x260 }, - { + [CONTESTANT_WINDOW_START] = { .bg = 0, .tilemapLeft = 1, .tilemapTop = 0x1F, @@ -893,15 +896,15 @@ void LoadContestBgAfterMoveAnim(void) LZDecompressVram(gContestMiscGfx, (void *)VRAM); LZDecompressVram(gContestAudienceGfx, (void *)(BG_SCREEN_ADDR(4))); - CopyToBgTilemapBuffer(3, gUnknown_08C16FA8, 0, 0); + CopyToBgTilemapBuffer(3, gOldContestGfx, 0, 0); CopyBgTilemapBufferToVram(3); - LoadCompressedPalette(gUnknown_08C16E90, 0, 0x200); + LoadCompressedPalette(gOldContestPalette, 0, 0x200); sub_80D782C(); - for (i = 0; i < MAX_MON_MOVES; i++) + for (i = 0; i < CONTESTANT_COUNT; i++) { - u32 var = 5 + i; + u32 contestantWindowId = CONTESTANT_WINDOW_START + i; - LoadPalette(eUnknownHeap1A004.unk18004[var], 16 * (5 + gContestantTurnOrder[i]), 16 * sizeof(u16)); + LoadPalette(eUnknownHeap1A004.unk18004[contestantWindowId], 16 * (CONTESTANT_WINDOW_START + gContestantTurnOrder[i]), sizeof((eUnknownHeap1A004.unk18004[contestantWindowId]))); } } @@ -1177,21 +1180,22 @@ static u8 sub_80D7E44(u8 *a) DmaCopyLarge32(3, (void *)(BG_SCREEN_ADDR(4)), eUnknownHeap18000, 0x2000, 0x1000); break; case 3: - CopyToBgTilemapBuffer(3, gUnknown_08C16FA8, 0, 0); + CopyToBgTilemapBuffer(3, gOldContestGfx, 0, 0); CopyBgTilemapBufferToVram(3); break; case 4: CopyToBgTilemapBuffer(2, gUnknown_08C17170, 0, 0); CopyBgTilemapBufferToVram(2); - DmaCopy32Defvars(3, gContestResources->ContestantInfoTilemaps[2], eUnknownHeap1A004.unk18A04, 0x800); + // This is a bug, and copies random junk. savedJunk is never read. + DmaCopy32Defvars(3, gContestResources->ContestantInfoTilemaps[2], eUnknownHeap1A004.savedJunk, 0x800); break; case 5: - LoadCompressedPalette(gUnknown_08C16E90, 0, 0x200); + LoadCompressedPalette(gOldContestPalette, 0, 0x200); CpuCopy32(gPlttBufferUnfaded + 128, sp0, 16 * sizeof(u16)); - CpuCopy32(gPlttBufferUnfaded + (5 + gContestPlayerMonIndex) * 16, sp20, 16 * sizeof(u16)); + CpuCopy32(gPlttBufferUnfaded + (CONTESTANT_WINDOW_START + gContestPlayerMonIndex) * 16, sp20, 16 * sizeof(u16)); CpuCopy32(sp20, gPlttBufferUnfaded + 128, 16 * sizeof(u16)); - CpuCopy32(sp0, gPlttBufferUnfaded + (5 + gContestPlayerMonIndex) * 16, 16 * sizeof(u16)); - DmaCopy32Defvars(3, gPlttBufferUnfaded, eUnknownHeap1A004.unk18004, 0x200); + CpuCopy32(sp0, gPlttBufferUnfaded + (CONTESTANT_WINDOW_START + gContestPlayerMonIndex) * 16, 16 * sizeof(u16)); + DmaCopy32Defvars(3, gPlttBufferUnfaded, eUnknownHeap1A004.unk18004, sizeof(eUnknownHeap1A004.unk18004)); sub_80D782C(); break; case 6: @@ -1270,13 +1274,13 @@ static void sub_80D8108(u8 taskId) ((struct BgCnt *)&bg2Cnt)->priority = 0; SetGpuReg(REG_OFFSET_BG0CNT, bg0Cnt); SetGpuReg(REG_OFFSET_BG2CNT, bg2Cnt); - sub_80DDB0C(); + StartMoveApplauseMeterOnscreen(); gTasks[taskId].data[0]++; break; } case 4: default: - if (eContest.unk1920A_6) + if (eContest.applauseMeterIsMoving) break; gTasks[taskId].data[0] = 0; gTasks[taskId].data[1] = 0; @@ -1329,7 +1333,7 @@ static void sub_80D833C(u8 taskId) gBattle_BG0_Y = 0; gBattle_BG2_Y = 0; ContestDebugDoPrint(); - DmaCopy32Defvars(3, gPlttBufferUnfaded, eUnknownHeap1A004.unk18204, 0x400); + DmaCopy32Defvars(3, gPlttBufferUnfaded, eUnknownHeap1A004.unk18204, PLTT_BUFFER_SIZE * 2); ConvertIntToDecimalStringN(gStringVar1, eContest.turnNumber + 1, STR_CONV_MODE_LEFT_ALIGN, 1); if (!Contest_IsMonsTurnDisabled(gContestPlayerMonIndex)) StringCopy(gDisplayedStringBattle, gText_0827D507); @@ -1396,8 +1400,8 @@ static void sub_80D8490(u8 taskId) } r5 = StringCopy(r5, gMoveNames[move]); - FillWindowPixelBuffer(i + 5, PIXEL_FILL(0)); - Contest_PrintTextToBg0WindowAt(i + 5, sp8, 5, 1, 7); + FillWindowPixelBuffer(i + CONTESTANT_WINDOW_START, PIXEL_FILL(0)); + Contest_PrintTextToBg0WindowAt(i + CONTESTANT_WINDOW_START, sp8, 5, 1, 7); } sub_80D880C(eContest.playerMoveChoice); @@ -1484,10 +1488,10 @@ static void sub_80D8894(u8 taskId) { if (gIsLinkContest & 1) { - u16 var = GetChosenMove(gContestPlayerMonIndex); + u16 move = GetChosenMove(gContestPlayerMonIndex); u8 taskId2; - eContestantStatus[gContestPlayerMonIndex].currMove = var; + eContestantStatus[gContestPlayerMonIndex].currMove = move; taskId2 = CreateTask(sub_80FC9F8, 0); SetTaskFuncWithFollowupFunc(taskId2, sub_80FC9F8, sub_80D892C); gTasks[taskId].func = TaskDummy1; @@ -1516,16 +1520,16 @@ static void sub_80D895C(u8 taskId) gBattle_BG2_Y = 0; sub_80DC490(FALSE); - for (i = 0; i < 4; i++) + for (i = 0; i < CONTESTANT_COUNT; i++) { - FillWindowPixelBuffer(5 + i, PIXEL_FILL(0)); - PutWindowTilemap(5 + i); - CopyWindowToVram(5 + i, 2); + FillWindowPixelBuffer(CONTESTANT_WINDOW_START + i, PIXEL_FILL(0)); + PutWindowTilemap(CONTESTANT_WINDOW_START + i); + CopyWindowToVram(CONTESTANT_WINDOW_START + i, 2); } Contest_SetBgCopyFlags(0); - - DmaCopy32Defvars(3, gPlttBufferFaded, eUnknownHeap1A004.unk18604, 0x400); - LoadPalette(eUnknownHeap1A004.unk18204, 0, 0x400); + // This seems to be a bug; it should have just copied PLTT_BUFFER_SIZE. + DmaCopy32Defvars(3, gPlttBufferFaded, eUnknownHeap1A004.unk18604, PLTT_BUFFER_SIZE * 2); + LoadPalette(eUnknownHeap1A004.unk18204, 0, PLTT_BUFFER_SIZE * 2); gTasks[taskId].data[0] = 0; gTasks[taskId].data[1] = 0; gTasks[taskId].func = sub_80D8A04; @@ -1538,7 +1542,7 @@ static void sub_80D8A04(u8 taskId) gTasks[taskId].data[0] = 0; if (++gTasks[taskId].data[1] == 2) { - sub_80DDBE8(); + TryMoveApplauseMeterOffscreen(); sub_80DE69C(1); gTasks[taskId].func = sub_80D8A50; } @@ -1547,7 +1551,7 @@ static void sub_80D8A04(u8 taskId) static void sub_80D8A50(u8 taskId) { - if (!eContest.unk1920A_6 && !eContest.unk1920B_1) + if (!eContest.applauseMeterIsMoving && !eContest.unk1920B_1) gTasks[taskId].func = sub_80D8A88; } @@ -2088,12 +2092,12 @@ static void sub_80D8B38(u8 taskId) case 1: if (!eContest.unk1920B_0 && !Contest_RunTextPrinters()) { - sub_80DDCDC(-1); + ShowAndUpdateApplauseMeter(-1); gTasks[taskId].data[10]++; } break; case 2: - if (!eContest.unk1920A_5) + if (!eContest.isShowingApplauseMeter) { if (gTasks[taskId].data[11]++ > 29) { @@ -2128,12 +2132,12 @@ static void sub_80D8B38(u8 taskId) { sub_80DDE0C(); PlaySE(SE_W227B); - sub_80DDCDC(1); + ShowAndUpdateApplauseMeter(1); gTasks[taskId].data[10]++; } break; case 2: - if (!eContest.unk1920A_5) + if (!eContest.isShowingApplauseMeter) { if (gTasks[taskId].data[11]++ > 29) { @@ -2211,16 +2215,16 @@ static void sub_80D8B38(u8 taskId) gTasks[taskId].data[0] = 55; return; case 55: - sub_80DDBE8(); + TryMoveApplauseMeterOffscreen(); gTasks[taskId].data[0] = 56; return; case 56: - if (!eContest.unk1920A_6) + if (!eContest.applauseMeterIsMoving) { if (eContest.applauseLevel > 4) { eContest.applauseLevel = 0; - sub_80DD940(); + UpdateApplauseMeter(); } gTasks[taskId].data[0] = 10; } @@ -2394,7 +2398,7 @@ static void sub_80DA31C(u8 taskId) static void sub_80DA348(u8 taskId) { - DmaCopy32Defvars(3, eUnknownHeap1A004.unk18204, gPlttBufferUnfaded, 0x400); + DmaCopy32Defvars(3, eUnknownHeap1A004.unk18204, gPlttBufferUnfaded, PLTT_BUFFER_SIZE * 2); gTasks[taskId].data[0] = 0; gTasks[taskId].data[1] = 2; gTasks[taskId].func = sub_80DA38C; @@ -2479,14 +2483,14 @@ static void sub_80DA51C(u8 taskId) } else { - sub_80DDB0C(); + StartMoveApplauseMeterOnscreen(); gTasks[taskId].func = sub_80DA5B4; } } static void sub_80DA5B4(u8 taskId) { - if (!eContest.unk1920A_6) + if (!eContest.applauseMeterIsMoving) gTasks[taskId].func = sub_80D833C; } @@ -3225,7 +3229,7 @@ static void sub_80DB918(void) { s32 i; - for (i = 0; i < 4; i++) + for (i = 0; i < CONTESTANT_COUNT; i++) eContestantStatus[i].currMove = GetChosenMove(i); } @@ -3718,7 +3722,7 @@ static void sub_80DC490(bool8 a) { s32 i; - for (i = 0; i < 4; i++) + for (i = 0; i < CONTESTANT_COUNT; i++) { if (gContestantTurnOrder[i] > 1) { @@ -3751,9 +3755,9 @@ static void CreateApplauseMeterSprite(void) { u8 spriteId; - LoadCompressedSpriteSheet(&gUnknown_08587BB0); - LoadSpritePalette(&gUnknown_08587BB8); - spriteId = CreateSprite(&gSpriteTemplate_8587BC8, 30, 44, 1); + LoadCompressedSpriteSheet(&sApplauseMeterSpriteSheet); + LoadSpritePalette(&sApplauseMeterPalette); + spriteId = CreateSprite(&sApplauseMeterSpriteTemplate, 30, 44, 1); gSprites[spriteId].invisible = TRUE; eContest.applauseMeterSpriteId = spriteId; } @@ -3790,7 +3794,7 @@ static void sub_80DC6A4(u8 taskId) { gTasks[eContest.unk19211].data[r4 * 4 + 0] = 0xFF; gTasks[eContest.unk19211].data[r4 * 4 + 1] = 0; - BlendPalette((eContest.prevTurnOrder[r4] + 5) * 16 + 6, 2, 0, RGB(31, 31, 18)); + BlendPalette((eContest.prevTurnOrder[r4] + CONTESTANT_WINDOW_START) * 16 + 6, 2, 0, RGB(31, 31, 18)); DestroyTask(taskId); } } @@ -3815,7 +3819,7 @@ static void sub_80DC728(u8 taskId) gTasks[taskId].data[r3 + 1] ^= 1; BlendPalette( - (eContest.prevTurnOrder[i] + 5) * 16 + 6, + (eContest.prevTurnOrder[i] + CONTESTANT_WINDOW_START) * 16 + 6, 2, gTasks[taskId].data[r3 + 0], RGB(31, 31, 18)); @@ -3853,12 +3857,12 @@ static void sub_80DC87C(u8 a) sub_80DC81C(a); - r0 = a + 5; + r0 = a + CONTESTANT_WINDOW_START; DmaCopy16Defvars(3, gPlttBufferUnfaded + r0 * 16 + 10, gPlttBufferFaded + r0 * 16 + 10, 2); - var = (a + 5) * 16 + 12 + a; + var = (a + CONTESTANT_WINDOW_START) * 16 + 12 + a; DmaCopy16Defvars(3, gPlttBufferUnfaded + var, gPlttBufferFaded + var, @@ -3888,8 +3892,8 @@ static void sub_80DC8D0(u8 taskId) || gTasks[taskId].data[r3 + 0] == 0) gTasks[taskId].data[r3 + 1] ^= 1; - BlendPalette((i + 5) * 16 + 10, 1, gTasks[taskId].data[r3 + 0], RGB(31, 31, 18)); - BlendPalette((i + 5) * 16 + 12 + i, 1, gTasks[taskId].data[r3 + 0], RGB(31, 31, 18)); + BlendPalette((i + CONTESTANT_WINDOW_START) * 16 + 10, 1, gTasks[taskId].data[r3 + 0], RGB(31, 31, 18)); + BlendPalette((i + CONTESTANT_WINDOW_START) * 16 + 12 + i, 1, gTasks[taskId].data[r3 + 0], RGB(31, 31, 18)); } } } @@ -4200,7 +4204,7 @@ static void sub_80DD04C(void) for (i = 0; i < 4; i++) { - LoadPalette(&gHeap[0x1A004] + (i + 5) * 32, (gContestantTurnOrder[i] + 5) * 16, 32); + LoadPalette(&gHeap[0x1A004] + (i + CONTESTANT_WINDOW_START) * 32, (gContestantTurnOrder[i] + CONTESTANT_WINDOW_START) * 16, 32); } sub_80DAEA4(); } @@ -4507,23 +4511,23 @@ static void sub_80DD720(u8 a) eContest.unk1920A_4 = 1; } -static void sub_80DD940(void) +static void UpdateApplauseMeter(void) { s32 i; - for (i = 0; i < 5; i++) + for (i = 0; i < APPLAUSE_METER_SIZE; i++) { const u8 *src; if (i < eContest.applauseLevel) - src = gContestApplauseMeterGfx + 64; + src = &gContestApplauseMeterGfx[64]; else src = gContestApplauseMeterGfx; CpuCopy32(src, (void *)(VRAM + 0x10000 + (gSprites[eContest.applauseMeterSpriteId].oam.tileNum + 17 + i) * 32), 32); CpuCopy32(src + 32, (void *)(VRAM + 0x10000 + (gSprites[eContest.applauseMeterSpriteId].oam.tileNum + 25 + i) * 32), 32); if (eContest.applauseLevel > 4) - sub_80DDA20(); + StartApplauseOverflowAnimation(); } } @@ -4532,46 +4536,54 @@ s8 Contest_GetMoveExcitement(u16 move) return gContestExcitementTable[gSpecialVar_ContestCategory][gContestMoves[move].contestCategory]; } -static u8 sub_80DDA20(void) +static u8 StartApplauseOverflowAnimation(void) { - u8 taskId = CreateTask(c3_08130B10, 10); + u8 taskId = CreateTask(Task_ApplauseOverflowAnimation, 10); gTasks[taskId].data[1] = 1; - gTasks[taskId].data[2] = IndexOfSpritePaletteTag(0x0ABE2); + gTasks[taskId].data[2] = IndexOfSpritePaletteTag(APPLAUSE_METER_GFX_TAG); return taskId; } -static void c3_08130B10(u8 taskId) +static void Task_ApplauseOverflowAnimation(u8 taskId) { + // Skip every other frame. if (++gTasks[taskId].data[0] == 1) { gTasks[taskId].data[0] = 0; + + // Alternate between normal colors and white. if (gTasks[taskId].data[3] == 0) gTasks[taskId].data[4]++; else gTasks[taskId].data[4]--; - BlendPalette(264 + gTasks[taskId].data[2] * 16, 1, gTasks[taskId].data[4], RGB(31, 31, 31)); + + BlendPalette(264 + gTasks[taskId].data[2] * 16, 1, gTasks[taskId].data[4], RGB_WHITE); + + // At the maximum or minimum blending, switch directions. if (gTasks[taskId].data[4] == 0 || gTasks[taskId].data[4] == 16) { gTasks[taskId].data[3] ^= 1; + + // Continue the animation until the applause meter is cleared. if (eContest.applauseLevel < 5) { - BlendPalette(264 + gTasks[taskId].data[2] * 16, 1, 0, RGB(31, 0, 0)); + BlendPalette(264 + gTasks[taskId].data[2] * 16, 1, 0, RGB_RED); DestroyTask(taskId); } } } } -static void sub_80DDB0C(void) +static void StartMoveApplauseMeterOnscreen(void) { - CreateTask(sub_80DDB6C, 10); + CreateTask(Task_MoveApplauseMeterOnscreen, 10); gSprites[eContest.applauseMeterSpriteId].pos2.x = -70; gSprites[eContest.applauseMeterSpriteId].invisible = FALSE; - eContest.unk1920A_6 = 1; + eContest.applauseMeterIsMoving = TRUE; } -static void sub_80DDB6C(u8 taskId) +static void Task_MoveApplauseMeterOnscreen(u8 taskId) { struct Sprite *sprite = &gSprites[eContest.applauseMeterSpriteId]; @@ -4582,26 +4594,26 @@ static void sub_80DDB6C(u8 taskId) sprite->pos2.x = 0; if (sprite->pos2.x == 0) { - eContest.unk1920A_6 = 0; + eContest.applauseMeterIsMoving = FALSE; DestroyTask(taskId); } } -static void sub_80DDBE8(void) +static void TryMoveApplauseMeterOffscreen(void) { if (gSprites[eContest.applauseMeterSpriteId].invisible == TRUE) { - eContest.unk1920A_6 = 0; + eContest.applauseMeterIsMoving = FALSE; } else { - CreateTask(task08_080CD1CC, 10); + CreateTask(Task_MoveApplauseMeterOffscreen, 10); gSprites[eContest.applauseMeterSpriteId].pos2.x = 0; - eContest.unk1920A_6 = 1; + eContest.applauseMeterIsMoving = TRUE; } } -static void task08_080CD1CC(u8 taskId) +static void Task_MoveApplauseMeterOffscreen(u8 taskId) { struct Sprite *sprite = &gSprites[eContest.applauseMeterSpriteId]; @@ -4613,29 +4625,29 @@ static void task08_080CD1CC(u8 taskId) if (sprite->pos2.x == -70) { sprite->invisible = TRUE; - eContest.unk1920A_6 = 0; + eContest.applauseMeterIsMoving = FALSE; DestroyTask(taskId); } } -static void sub_80DDCDC(s8 a) +static void ShowAndUpdateApplauseMeter(s8 unused) { - u8 taskId = CreateTask(sub_80DDD20, 5); + u8 taskId = CreateTask(Task_ShowAndUpdateApplauseMeter, 5); - gTasks[taskId].data[0] = a; - eContest.unk1920A_5 = 1; + gTasks[taskId].data[0] = unused; + eContest.isShowingApplauseMeter = TRUE; } -static void sub_80DDD20(u8 taskId) +static void Task_ShowAndUpdateApplauseMeter(u8 taskId) { switch (gTasks[taskId].data[10]) { case 0: - sub_80DDB0C(); + StartMoveApplauseMeterOnscreen(); gTasks[taskId].data[10]++; break; case 1: - if (!eContest.unk1920A_6) + if (!eContest.applauseMeterIsMoving) { gTasks[taskId].data[10]++; } @@ -4644,21 +4656,23 @@ static void sub_80DDD20(u8 taskId) if (gTasks[taskId].data[11]++ > 20) { gTasks[taskId].data[11] = 0; - sub_80DD940(); - eContest.unk1920A_5 = 0; + UpdateApplauseMeter(); + eContest.isShowingApplauseMeter = FALSE; DestroyTask(taskId); } break; } } -void unref_sub_80DDDA8(void) +// Unused. +void HideApplauseMeterNoAnim(void) { gSprites[eContest.applauseMeterSpriteId].pos2.x = 0; gSprites[eContest.applauseMeterSpriteId].invisible = FALSE; } -void unref_sub_80DDDE4(void) +// Unused. +void ShowApplauseMeterNoAnim(void) { gSprites[eContest.applauseMeterSpriteId].invisible = TRUE; } @@ -5256,9 +5270,9 @@ static bool32 Contest_RunTextPrinters(void) return IsTextPrinterActive(4); } -static void Contest_SetBgCopyFlags(u32 var) +static void Contest_SetBgCopyFlags(u32 flagIndex) { - sContestBgCopyFlags |= 1 << var; + sContestBgCopyFlags |= 1 << flagIndex; } void ResetContestLinkResults(void) diff --git a/src/graphics.c b/src/graphics.c index c243c64a5..c3ed90fb6 100644 --- a/src/graphics.c +++ b/src/graphics.c @@ -446,8 +446,8 @@ const u32 gUnusedTilemap_OldContest[] = INCBIN_U32("graphics/unused/old_contest. const u32 gUnknownTilemap_C15BC0[] = INCBIN_U32("graphics/unknown/unknown_C15BC0.bin.lz"); const u32 gUnusedGfx_OldContest2[] = INCBIN_U32("graphics/unused/old_contest_2.4bpp.lz"); -const u32 gUnknown_08C16E90[] = INCBIN_U32("graphics/unused/old_contest_2.gbapal.lz"); -const u32 gUnknown_08C16FA8[] = INCBIN_U32("graphics/unused/old_contest_2.bin.lz"); +const u32 gOldContestPalette[] = INCBIN_U32("graphics/unused/old_contest_2.gbapal.lz"); +const u32 gOldContestGfx[] = INCBIN_U32("graphics/unused/old_contest_2.bin.lz"); const u32 gUnknown_08C17170[] = INCBIN_U32("graphics/unknown/unknown_C17170.bin.lz"); From 3a2ea401882d9ce47709d048f57a6d18f890b5f4 Mon Sep 17 00:00:00 2001 From: Phlosioneer Date: Wed, 3 Apr 2019 17:24:32 -0400 Subject: [PATCH 07/22] Rename and document more contest setup functions Also properly label the link contest flags variable, and label the contest window ID's. --- data/event_scripts.s | 2 +- include/contest.h | 16 +- include/link.h | 2 +- src/battle_main.c | 6 +- src/berry_blender.c | 4 +- src/berry_crush.c | 2 +- src/contest.c | 253 ++++++++++++++++-------------- src/contest_link_80F57C4.c | 26 +-- src/contest_link_80FC4F4.c | 8 +- src/evolution_scene.c | 2 +- src/link_rfu.c | 2 +- src/overworld.c | 4 +- src/reshow_battle_screen.c | 2 +- src/script_pokemon_util_80F87D8.c | 26 +-- src/trade.c | 6 +- src/trainer_card.c | 2 +- src/union_room.c | 10 +- src/union_room_chat.c | 2 +- 18 files changed, 199 insertions(+), 176 deletions(-) diff --git a/data/event_scripts.s b/data/event_scripts.s index 5c3c408aa..76cae6ca8 100644 --- a/data/event_scripts.s +++ b/data/event_scripts.s @@ -3460,7 +3460,7 @@ EventScript_GotoTrainerScript:: @ 82742F6 gUnknown_0827E8CE:: @ 827E8CE .string "Missed turn$" -gUnknown_0827E8DA:: @ 827E8DA +gText_LinkStandby4:: @ 827E8DA .string "Link standby!$" gUnknown_0827E8E8:: @ 827E8E8 diff --git a/include/contest.h b/include/contest.h index c4e752072..2f986f217 100644 --- a/include/contest.h +++ b/include/contest.h @@ -14,6 +14,10 @@ // Prints the ContestResourcesField1C::unk_D value as a bitstring for each contestant. #define CONTEST_DEBUG_MODE_PRINT_UNK_D 3 +#define LINK_CONTEST_FLAG_IS_LINK (1 << 0) +#define LINK_CONTEST_FLAG_IS_WIRELESS (1 << 1) +#define LINK_CONTEST_FLAG_HAS_RS_PLAYER (1 << 2) + enum { CONTEST_CATEGORY_COOL, @@ -250,7 +254,7 @@ struct ContestPokemon struct Shared1A004 { - u16 unk18004[16][16]; // Saved palette data before a move happens? + u16 cachedWindowPalettes[16][16]; // Saved palette data before a move happens? u16 unk18204[PLTT_BUFFER_SIZE]; // Saved copy of gPlttBufferUnfaded u16 unk18604[PLTT_BUFFER_SIZE]; // Saved copy of gPlttBufferFaded u8 savedJunk[0x800]; @@ -297,7 +301,7 @@ struct Contest u16 unk19220[5][4]; // move history? u8 unk19248[5][4]; // excitement history u8 applauseMeterSpriteId; // sprite ID - /*0x1925D*/ u8 unk1925D; + /*0x1925D*/ u8 contestSetupState; /*0x1925E*/ u8 unk1925E; }; @@ -428,7 +432,7 @@ struct ContestResources struct ContestStruct_field_18 *field_18; struct ContestResourcesField1C * field_1c; struct ContestResourcesField20 * field_20; - u8 * ContestantInfoTilemaps[CONTESTANT_COUNT]; + u8 * contestBgTilemaps[CONTESTANT_COUNT]; void * field_34; void * field_38; void * field_3c; @@ -440,7 +444,7 @@ struct ContestResources #define eContestAI (*gContestResources->aiData) #define eContestResources10 (*gContestResources->field_10) #define eContestResources14 (*gContestResources->field_14) -#define eUnknownHeap18000 (gHeap + 0x18000) +#define eUnzippedContestAudienceGfx (gHeap + 0x18000) #define eUnknownHeap19000 (gHeap + 0x19000) #define eContestDebugMode (gHeap[0x1a000]) #define eUnknownHeap1A004 (*(struct Shared1A004 *)(gHeap + 0x1a004)) @@ -454,7 +458,7 @@ extern u8 gContestFinalStandings[4]; extern u8 gContestMonPartyIndex; extern u8 gContestPlayerMonIndex; extern u8 gContestantTurnOrder[4]; -extern u8 gIsLinkContest; +extern u8 gLinkContestFlags; extern u8 gUnknown_02039F2B; extern u16 gSpecialVar_ContestCategory; extern u16 gSpecialVar_ContestRank; @@ -471,7 +475,7 @@ extern u32 gContestRngValue; // contest.c void ResetLinkContestBoolean(void); void LoadContestBgAfterMoveAnim(void); -void CB2_ContestMain(void); +void CB2_StartContest(void); void sub_80DA8C8(u8 partyIndex); void sub_80DAB8C(u8 contestType, u8 rank); void sub_80DACBC(u8 contestType, u8 rank, bool32 isPostgame); diff --git a/include/link.h b/include/link.h index 62ae7761c..a50991762 100644 --- a/include/link.h +++ b/include/link.h @@ -235,7 +235,7 @@ void LinkVSync(void); void Timer3Intr(void); void SerialCB(void); bool32 InUnionRoom(void); -void sub_800E0E8(void); +void LoadWirelessStatusIndicatorSprite(void); bool8 IsLinkTaskFinished(void); void CreateWirelessStatusIndicatorSprite(u8, u8); void sub_800ADF8(void); diff --git a/src/battle_main.c b/src/battle_main.c index 19fd01e3c..7a215384e 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -981,7 +981,7 @@ static void CB2_HandleStartBattle(void) gBattleCommunication[MULTIUSE_STATE] = 1; } if (gWirelessCommType) - sub_800E0E8(); + LoadWirelessStatusIndicatorSprite(); break; case 1: if (gBattleTypeFlags & BATTLE_TYPE_LINK) @@ -1176,7 +1176,7 @@ static void CB2_HandleStartMultiPartnerBattle(void) gBattleCommunication[MULTIUSE_STATE] = 1; } if (gWirelessCommType) - sub_800E0E8(); + LoadWirelessStatusIndicatorSprite(); // fall through case 1: if (gBattleTypeFlags & BATTLE_TYPE_LINK) @@ -1576,7 +1576,7 @@ static void CB2_HandleStartMultiBattle(void) gBattleCommunication[MULTIUSE_STATE] = 1; } if (gWirelessCommType) - sub_800E0E8(); + LoadWirelessStatusIndicatorSprite(); break; case 1: if (gBattleTypeFlags & BATTLE_TYPE_LINK) diff --git a/src/berry_blender.c b/src/berry_blender.c index d1e8e1ab8..70b10b764 100644 --- a/src/berry_blender.c +++ b/src/berry_blender.c @@ -996,7 +996,7 @@ static void sub_807FAC8(void) } if (gReceivedRemoteLinkPlayers != 0 && gWirelessCommType) { - sub_800E0E8(); + LoadWirelessStatusIndicatorSprite(); CreateWirelessStatusIndicatorSprite(0, 0); } SetVBlankCallback(VBlankCB0_BerryBlender); @@ -1202,7 +1202,7 @@ static void sub_8080018(void) } if (gReceivedRemoteLinkPlayers != 0 && gWirelessCommType) { - sub_800E0E8(); + LoadWirelessStatusIndicatorSprite(); CreateWirelessStatusIndicatorSprite(0, 0); } sBerryBlenderData->mainState++; diff --git a/src/berry_crush.c b/src/berry_crush.c index 51dbe8203..404a9b70c 100755 --- a/src/berry_crush.c +++ b/src/berry_crush.c @@ -511,7 +511,7 @@ int sub_802104C(void) CopyBgTilemapBufferToVram(3); break; case 8: - sub_800E0E8(); + LoadWirelessStatusIndicatorSprite(); CreateWirelessStatusIndicatorSprite(0, 0); sub_8022730(var0); SetGpuReg(REG_OFFSET_BG1VOFS, -gSpriteCoordOffsetY); diff --git a/src/contest.c b/src/contest.c index 5263b961f..381301632 100644 --- a/src/contest.c +++ b/src/contest.c @@ -45,9 +45,26 @@ #include "constants/rgb.h" #include "contest_ai.h" -#define CONTESTANT_WINDOW_START 5 #define APPLAUSE_METER_GFX_TAG 0xABE2 +// An index into a palette where the text color for each contestant is stored. +// Contestant 0 will use palette color 10, contestant 1 will use color 11, etc. +#define CONTESTANT_TEXT_COLOR_START 10 + +#define CONTEST_WINDOW_UNK_0 0 +#define CONTEST_WINDOW_UNK_1 1 +#define CONTEST_WINDOW_UNK_2 2 +#define CONTEST_WINDOW_UNK_3 3 +#define CONTEST_WINDOW_UNK_4 4 +#define CONTEST_WINDOW_CONTESTANT1 5 +#define CONTEST_WINDOW_CONTESTANT2 6 +#define CONTEST_WINDOW_CONTESTANT3 7 +#define CONTEST_WINDOW_CONTESTANT4 8 +#define CONTEST_WINDOW_UNK_9 9 +#define CONTEST_WINDOW_UNK_10 10 + +#define CONTESTANT_WINDOW_START CONTEST_WINDOW_CONTESTANT1 + // This file's functions. static void sub_80D782C(void); static void sub_80D7C7C(u8 taskId); @@ -55,11 +72,11 @@ static void sub_80D7CB4(u8 taskId); static void sub_80D7DAC(u8 taskId); static void sub_80D7DC8(u8 taskId); static void sub_80D7DE8(u8 taskId); -static bool8 sub_80D7E44(u8 *); +static bool8 SetupContestGraphics(u8 *stateVar); static void sub_80D80C8(u8 taskId); static void sub_80D8108(u8 taskId); static void vblank_cb_battle(void); -static void sub_80D823C(void); +static void CB2_ContestMain(void); static void sub_80D833C(u8 taskId); static void sub_80D8424(u8 taskId); static void sub_80D8610(u8 taskId); @@ -97,10 +114,10 @@ static void sub_80DA7EC(u8); static void sub_80DA830(u8); static void sub_80DA874(void); static bool8 sub_80DA8A4(void); -static void sub_80DAF04(u8); -static void sub_80DAF1C(u8 a0, u8 a1); -static void sub_80DAF88(u8); -static void sub_80DAFA0(u8, u8); +static void PrintContestantTrainerName(u8); +static void PrintContestantTrainerNameWithColor(u8 a0, u8 a1); +static void PrintContestantMonName(u8); +static void PrintContestantMonNameWithColor(u8, u8); static u8 sub_80DB0C4(void); static u8 sub_80DB120(void); static u8 sub_80DB174(u16, u32, u32, u32); @@ -110,7 +127,7 @@ static void sub_80DB89C(void); static u16 GetChosenMove(u8); static void sub_80DB918(void); static void sub_80DBF68(void); -static void sub_80DBF90(void); +static void FillContestantWindowBgs(void); static void sub_80DC2BC(void); static void sub_80DC490(bool8); static void sub_80DC4F0(void); @@ -118,7 +135,7 @@ static void CreateApplauseMeterSprite(void); static void sub_80DC5E8(void); static void sub_80DC7EC(void); static void ContestDebugDoPrint(void); -static void sub_80DD04C(void); +static void DrawContestantWindows(void); static void ApplyNextTurnOrder(void); static void StartMoveApplauseMeterOnscreen(void); static void TryMoveApplauseMeterOffscreen(void); @@ -204,7 +221,7 @@ EWRAM_DATA u8 gContestFinalStandings[4] = {0}; EWRAM_DATA u8 gContestMonPartyIndex = 0; EWRAM_DATA u8 gContestPlayerMonIndex = 0; EWRAM_DATA u8 gContestantTurnOrder[4] = {0}; -EWRAM_DATA u8 gIsLinkContest = 0; +EWRAM_DATA u8 gLinkContestFlags = 0; // Bit 0: Is a link contest // Bit 1: Link contest uses wireless adapter EWRAM_DATA u8 gUnknown_02039F2B = 0; @@ -221,7 +238,7 @@ EWRAM_DATA u8 gUnknown_02039F5D = 0; // IWRAM common vars. u32 gContestRngValue; -extern const u8 *const gUnknown_0827E8DA[]; +extern const u8 gText_LinkStandby4[]; extern const u8 gText_0827D55A[]; extern const u8 gText_0827E793[]; extern const u8 gText_0827E32E[]; @@ -577,7 +594,7 @@ const u16 gUnknown_08587C30[] = INCBIN_U16("graphics/unknown/unknown_587C30.gbap #include "data/contest_text_tables.h" -static const struct BgTemplate sContestantInfoBgTemplates[] = +static const struct BgTemplate sContestBgTemplates[] = { { .bg = 0, @@ -619,7 +636,7 @@ static const struct BgTemplate sContestantInfoBgTemplates[] = static const struct WindowTemplate sContestWindowTemplates[] = { - { + [CONTEST_WINDOW_UNK_0] = { .bg = 0, .tilemapLeft = 18, .tilemapTop = 0, @@ -628,7 +645,7 @@ static const struct WindowTemplate sContestWindowTemplates[] = .paletteNum = 0xF, .baseBlock = 0x200 }, - { + [CONTEST_WINDOW_UNK_1] = { .bg = 0, .tilemapLeft = 18, .tilemapTop = 5, @@ -637,7 +654,7 @@ static const struct WindowTemplate sContestWindowTemplates[] = .paletteNum = 0xF, .baseBlock = 0x218 }, - { + [CONTEST_WINDOW_UNK_2] = { .bg = 0, .tilemapLeft = 18, .tilemapTop = 10, @@ -646,7 +663,7 @@ static const struct WindowTemplate sContestWindowTemplates[] = .paletteNum = 0xF, .baseBlock = 0x230 }, - { + [CONTEST_WINDOW_UNK_3] = { .bg = 0, .tilemapLeft = 18, .tilemapTop = 15, @@ -655,7 +672,7 @@ static const struct WindowTemplate sContestWindowTemplates[] = .paletteNum = 0xF, .baseBlock = 0x248 }, - { + [CONTEST_WINDOW_UNK_4] = { .bg = 0, .tilemapLeft = 1, .tilemapTop = 15, @@ -664,7 +681,7 @@ static const struct WindowTemplate sContestWindowTemplates[] = .paletteNum = 0xF, .baseBlock = 0x260 }, - [CONTESTANT_WINDOW_START] = { + [CONTEST_WINDOW_CONTESTANT1] = { .bg = 0, .tilemapLeft = 1, .tilemapTop = 0x1F, @@ -673,7 +690,7 @@ static const struct WindowTemplate sContestWindowTemplates[] = .paletteNum = 0xF, .baseBlock = 0x2A4 }, - { + [CONTEST_WINDOW_CONTESTANT2] = { .bg = 0, .tilemapLeft = 1, .tilemapTop = 0x21, @@ -682,7 +699,7 @@ static const struct WindowTemplate sContestWindowTemplates[] = .paletteNum = 0xF, .baseBlock = 0x2B6 }, - { + [CONTEST_WINDOW_CONTESTANT3] = { .bg = 0, .tilemapLeft = 1, .tilemapTop = 0x23, @@ -691,7 +708,7 @@ static const struct WindowTemplate sContestWindowTemplates[] = .paletteNum = 0xF, .baseBlock = 0x2C8 }, - { + [CONTEST_WINDOW_CONTESTANT4] = { .bg = 0, .tilemapLeft = 1, .tilemapTop = 0x25, @@ -700,7 +717,7 @@ static const struct WindowTemplate sContestWindowTemplates[] = .paletteNum = 0xF, .baseBlock = 0x2DA }, - { + [CONTEST_WINDOW_UNK_9] = { .bg = 0, .tilemapLeft = 16, .tilemapTop = 0x1F, @@ -709,7 +726,7 @@ static const struct WindowTemplate sContestWindowTemplates[] = .paletteNum = 0xF, .baseBlock = 0x2EC }, - { + [CONTEST_WINDOW_UNK_10] = { .bg = 0, .tilemapLeft = 11, .tilemapTop = 0x23, @@ -861,7 +878,7 @@ static void TaskDummy1(u8 taskId) void ResetLinkContestBoolean(void) { - gIsLinkContest = 0; + gLinkContestFlags = 0; } static void SetupContestGpuRegs(void) @@ -904,7 +921,7 @@ void LoadContestBgAfterMoveAnim(void) { u32 contestantWindowId = CONTESTANT_WINDOW_START + i; - LoadPalette(eUnknownHeap1A004.unk18004[contestantWindowId], 16 * (CONTESTANT_WINDOW_START + gContestantTurnOrder[i]), sizeof((eUnknownHeap1A004.unk18004[contestantWindowId]))); + LoadPalette(eUnknownHeap1A004.cachedWindowPalettes[contestantWindowId], 16 * (CONTESTANT_WINDOW_START + gContestantTurnOrder[i]), sizeof((eUnknownHeap1A004.cachedWindowPalettes[contestantWindowId]))); } } @@ -913,11 +930,11 @@ static void InitContestInfoBgs(void) s32 i; ResetBgsAndClearDma3BusyFlags(0); - InitBgsFromTemplates(0, sContestantInfoBgTemplates, ARRAY_COUNT(sContestantInfoBgTemplates)); + InitBgsFromTemplates(0, sContestBgTemplates, ARRAY_COUNT(sContestBgTemplates)); SetBgAttribute(3, BG_ATTR_WRAPAROUND, 1); for (i = 0; i < CONTESTANT_COUNT; i++) { - SetBgTilemapBuffer(i, gContestResources->ContestantInfoTilemaps[i]); + SetBgTilemapBuffer(i, gContestResources->contestBgTilemaps[i]); } } @@ -925,7 +942,7 @@ static void InitContestWindows(void) { InitWindows(sContestWindowTemplates); DeactivateAllTextPrinters(); - if (gIsLinkContest & 1) + if (gLinkContestFlags & LINK_CONTEST_FLAG_IS_LINK) { gTextFlags.canABSpeedUpPrint = FALSE; } @@ -970,7 +987,7 @@ static void InitContestResources(void) *gContestResources->field_10 = (struct UnknownContestStruct5){}; memset(gContestResources->field_14, 0, CONTESTANT_COUNT * sizeof(struct UnknownContestStruct4)); - if (!(gIsLinkContest & 1)) + if (!(gLinkContestFlags & LINK_CONTEST_FLAG_IS_LINK)) SortContestants(FALSE); for (i = 0; i < CONTESTANT_COUNT; i++) @@ -996,15 +1013,15 @@ static void AllocContestResources(void) gContestResources->field_18 = AllocZeroed(sizeof(struct ContestStruct_field_18)); gContestResources->field_1c = AllocZeroed(sizeof(struct ContestResourcesField1C) * CONTESTANT_COUNT); gContestResources->field_20 = AllocZeroed(sizeof(struct ContestResourcesField20)); - gContestResources->ContestantInfoTilemaps[0] = AllocZeroed(0x1000); - gContestResources->ContestantInfoTilemaps[1] = AllocZeroed(0x1000); - gContestResources->ContestantInfoTilemaps[2] = AllocZeroed(0x1000); - gContestResources->ContestantInfoTilemaps[3] = AllocZeroed(0x1000); + gContestResources->contestBgTilemaps[0] = AllocZeroed(0x1000); + gContestResources->contestBgTilemaps[1] = AllocZeroed(0x1000); + gContestResources->contestBgTilemaps[2] = AllocZeroed(0x1000); + gContestResources->contestBgTilemaps[3] = AllocZeroed(0x1000); gContestResources->field_34 = AllocZeroed(0x800); gContestResources->field_38 = AllocZeroed(0x800); gContestResources->field_3c = AllocZeroed(0x2000); gUnknown_0202305C = gContestResources->field_3c; - gUnknown_02023060 = gContestResources->ContestantInfoTilemaps[1]; + gUnknown_02023060 = gContestResources->contestBgTilemaps[1]; } static void FreeContestResources(void) @@ -1018,10 +1035,10 @@ static void FreeContestResources(void) FREE_AND_SET_NULL(gContestResources->field_18); FREE_AND_SET_NULL(gContestResources->field_1c); FREE_AND_SET_NULL(gContestResources->field_20); - FREE_AND_SET_NULL(gContestResources->ContestantInfoTilemaps[0]); - FREE_AND_SET_NULL(gContestResources->ContestantInfoTilemaps[1]); - FREE_AND_SET_NULL(gContestResources->ContestantInfoTilemaps[2]); - FREE_AND_SET_NULL(gContestResources->ContestantInfoTilemaps[3]); + FREE_AND_SET_NULL(gContestResources->contestBgTilemaps[0]); + FREE_AND_SET_NULL(gContestResources->contestBgTilemaps[1]); + FREE_AND_SET_NULL(gContestResources->contestBgTilemaps[2]); + FREE_AND_SET_NULL(gContestResources->contestBgTilemaps[3]); FREE_AND_SET_NULL(gContestResources->field_34); FREE_AND_SET_NULL(gContestResources->field_38); FREE_AND_SET_NULL(gContestResources->field_3c); @@ -1030,7 +1047,7 @@ static void FreeContestResources(void) gUnknown_02023060 = NULL; } -void CB2_ContestMain(void) +void CB2_StartContest(void) { switch (gMain.state) { @@ -1060,9 +1077,9 @@ void CB2_ContestMain(void) gMain.state++; break; case 2: - if (sub_80D7E44(&eContest.unk1925D)) + if (SetupContestGraphics(&eContest.contestSetupState)) { - eContest.unk1925D = 0; + eContest.contestSetupState = 0; gMain.state++; } break; @@ -1074,10 +1091,10 @@ void CB2_ContestMain(void) gPaletteFade.bufferTransferDisabled = FALSE; SetVBlankCallback(vblank_cb_battle); eContest.mainTaskId = CreateTask(sub_80D7C7C, 10); - SetMainCallback2(sub_80D823C); - if (gIsLinkContest & 2) + SetMainCallback2(CB2_ContestMain); + if (gLinkContestFlags & LINK_CONTEST_FLAG_IS_WIRELESS) { - sub_800E0E8(); + LoadWirelessStatusIndicatorSprite(); CreateWirelessStatusIndicatorSprite(8, 8); } break; @@ -1095,9 +1112,9 @@ static void sub_80D7C7C(u8 taskId) static void sub_80D7CB4(u8 taskId) { - if (gIsLinkContest & 1) + if (gLinkContestFlags & LINK_CONTEST_FLAG_IS_LINK) { - if (gIsLinkContest & 2) + if (gLinkContestFlags & LINK_CONTEST_FLAG_IS_WIRELESS) { switch (gTasks[taskId].data[0]) { @@ -1123,7 +1140,7 @@ static void sub_80D7CB4(u8 taskId) if (!gPaletteFade.active) { gPaletteFade.bufferTransferDisabled = FALSE; - if (!(gIsLinkContest & 2)) + if (!(gLinkContestFlags & LINK_CONTEST_FLAG_IS_WIRELESS)) sub_80DBF68(); CreateTask(sub_80D7DAC, 0); gTasks[taskId].data[0] = 0; @@ -1159,12 +1176,12 @@ static void sub_80D7DE8(u8 taskId) } } -static u8 sub_80D7E44(u8 *a) +static bool8 SetupContestGraphics(u8 *stateVar) { - u16 sp0[16]; - u16 sp20[16]; + u16 tempPalette1[16]; + u16 tempPalette2[16]; - switch (*a) + switch (*stateVar) { case 0: gPaletteFade.bufferTransferDisabled = TRUE; @@ -1177,7 +1194,7 @@ static u8 sub_80D7E44(u8 *a) break; case 2: LZDecompressVram(gContestAudienceGfx, (void *)(BG_SCREEN_ADDR(4))); - DmaCopyLarge32(3, (void *)(BG_SCREEN_ADDR(4)), eUnknownHeap18000, 0x2000, 0x1000); + DmaCopyLarge32(3, (void *)(BG_SCREEN_ADDR(4)), eUnzippedContestAudienceGfx, 0x2000, 0x1000); break; case 3: CopyToBgTilemapBuffer(3, gOldContestGfx, 0, 0); @@ -1187,20 +1204,20 @@ static u8 sub_80D7E44(u8 *a) CopyToBgTilemapBuffer(2, gUnknown_08C17170, 0, 0); CopyBgTilemapBufferToVram(2); // This is a bug, and copies random junk. savedJunk is never read. - DmaCopy32Defvars(3, gContestResources->ContestantInfoTilemaps[2], eUnknownHeap1A004.savedJunk, 0x800); + DmaCopy32Defvars(3, gContestResources->contestBgTilemaps[2], eUnknownHeap1A004.savedJunk, sizeof(eUnknownHeap1A004.savedJunk)); break; case 5: LoadCompressedPalette(gOldContestPalette, 0, 0x200); - CpuCopy32(gPlttBufferUnfaded + 128, sp0, 16 * sizeof(u16)); - CpuCopy32(gPlttBufferUnfaded + (CONTESTANT_WINDOW_START + gContestPlayerMonIndex) * 16, sp20, 16 * sizeof(u16)); - CpuCopy32(sp20, gPlttBufferUnfaded + 128, 16 * sizeof(u16)); - CpuCopy32(sp0, gPlttBufferUnfaded + (CONTESTANT_WINDOW_START + gContestPlayerMonIndex) * 16, 16 * sizeof(u16)); - DmaCopy32Defvars(3, gPlttBufferUnfaded, eUnknownHeap1A004.unk18004, sizeof(eUnknownHeap1A004.unk18004)); + CpuCopy32(gPlttBufferUnfaded + 128, tempPalette1, 16 * sizeof(u16)); + CpuCopy32(gPlttBufferUnfaded + (CONTESTANT_WINDOW_START + gContestPlayerMonIndex) * 16, tempPalette2, 16 * sizeof(u16)); + CpuCopy32(tempPalette2, gPlttBufferUnfaded + 128, 16 * sizeof(u16)); + CpuCopy32(tempPalette1, gPlttBufferUnfaded + (CONTESTANT_WINDOW_START + gContestPlayerMonIndex) * 16, 16 * sizeof(u16)); + DmaCopy32Defvars(3, gPlttBufferUnfaded, eUnknownHeap1A004.cachedWindowPalettes, sizeof(eUnknownHeap1A004.cachedWindowPalettes)); sub_80D782C(); break; case 6: - sub_80DD04C(); - sub_80DBF90(); + DrawContestantWindows(); + FillContestantWindowBgs(); sub_80DB2BC(); eContest.unk19216 = sub_80DB120(); sub_80DC2BC(); @@ -1226,11 +1243,11 @@ static u8 sub_80D7E44(u8 *a) ShowBg(1); break; default: - *a = 0; + *stateVar = 0; return 1; } - (*a)++; + (*stateVar)++; return 0; } @@ -1289,7 +1306,7 @@ static void sub_80D8108(u8 taskId) } } -static void sub_80D823C(void) +static void CB2_ContestMain(void) { s32 i; @@ -1486,7 +1503,7 @@ static void sub_80D883C(s8 a0) static void sub_80D8894(u8 taskId) { - if (gIsLinkContest & 1) + if (gLinkContestFlags & LINK_CONTEST_FLAG_IS_LINK) { u16 move = GetChosenMove(gContestPlayerMonIndex); u8 taskId2; @@ -1561,7 +1578,7 @@ static void sub_80D8A88(u8 taskId) { eContest.unk19214 = 0; eContest.unk1921C = gRngValue; - if ((gIsLinkContest & 1) && sub_80DA8A4()) + if ((gLinkContestFlags & LINK_CONTEST_FLAG_IS_LINK) && sub_80DA8A4()) { s32 i; @@ -1590,7 +1607,7 @@ static void sub_80D8B38(u8 taskId) ; eContest.unk19215 = i; r6 = eContest.unk19215; - if (gIsLinkContest & 1) + if (gLinkContestFlags & LINK_CONTEST_FLAG_IS_LINK) { u8 taskId2; @@ -2318,7 +2335,7 @@ static void sub_80DA198(u8 taskId) switch (gTasks[taskId].data[0]) { case 0: - if (gIsLinkContest & 1) + if (gLinkContestFlags & LINK_CONTEST_FLAG_IS_LINK) { u8 taskId2; @@ -2504,7 +2521,7 @@ static void sub_80DA5E8(u8 taskId) gUnknown_02039F10[i] = eContestantStatus[i].pointTotal; sub_80DBD18(); sub_80DB89C(); - if (!(gIsLinkContest & 1)) + if (!(gLinkContestFlags & LINK_CONTEST_FLAG_IS_LINK)) BravoTrainerPokemonProfile_BeforeInterview1(eContestantStatus[gContestPlayerMonIndex].prevMove); else { @@ -2549,7 +2566,7 @@ static void sub_80DA740(u8 taskId) if (gTasks[taskId].data[0]++ >= 50) { gTasks[taskId].data[0] = 0; - if (gIsLinkContest & 1) + if (gLinkContestFlags & LINK_CONTEST_FLAG_IS_LINK) { gTasks[taskId].func = sub_80DA7A0; } @@ -2599,7 +2616,7 @@ static void sub_80DA874(void) static void sub_80DA884(void) { - if (!(gIsLinkContest & 1)) + if (!(gLinkContestFlags & LINK_CONTEST_FLAG_IS_LINK)) gContestPlayerMonIndex = 3; } @@ -2621,7 +2638,7 @@ void sub_80DA8C8(u8 partyIndex) s16 tough; StringCopy(name, gSaveBlock2Ptr->playerName); - if (gIsLinkContest & 1) + if (gLinkContestFlags & LINK_CONTEST_FLAG_IS_LINK) { sub_80DF9D4(name); } @@ -2635,7 +2652,7 @@ void sub_80DA8C8(u8 partyIndex) gContestMons[gContestPlayerMonIndex].species = GetMonData(&gPlayerParty[partyIndex], MON_DATA_SPECIES); GetMonData(&gPlayerParty[partyIndex], MON_DATA_NICKNAME, name); StringGetEnd10(name); - if (gIsLinkContest & 1) + if (gLinkContestFlags & LINK_CONTEST_FLAG_IS_LINK) { sub_80DF9E0(name, GetMonData(&gPlayerParty[partyIndex], MON_DATA_LANGUAGE)); } @@ -2697,7 +2714,7 @@ void sub_80DAB8C(u8 contestType, u8 rank) sub_80DA884(); - if (FlagGet(FLAG_SYS_GAME_CLEAR) && !(gIsLinkContest & 1)) + if (FlagGet(FLAG_SYS_GAME_CLEAR) && !(gLinkContestFlags & LINK_CONTEST_FLAG_IS_LINK)) r7 = TRUE; // Find all suitable opponents @@ -2833,55 +2850,55 @@ u8 sub_80DAE0C(struct Pokemon *pkmn) return retVal; } -static void sub_80DAEA4(void) +static void DrawContestantWindowText(void) { s32 i; - for (i = 0; i < 4; i++) + for (i = 0; i < CONTESTANT_COUNT; i++) { FillWindowPixelBuffer(gContestantTurnOrder[i], PIXEL_FILL(0)); - sub_80DAF04(i); - sub_80DAF88(i); + PrintContestantTrainerName(i); + PrintContestantMonName(i); } } -static u8 *sub_80DAED4(const u8 *src, u8 color) +static u8 *Contest_CopyStringWithColor(const u8 *string, u8 color) { u8 * ptr = StringCopy(gDisplayedStringBattle, gText_ColorTransparent); - ptr[-1] = color; - ptr = StringCopy(ptr, src); + ptr[-1] = color; // Overwrites the "{COLOR TRANSPARENT}" part of the string. + ptr = StringCopy(ptr, string); return ptr; } -static void sub_80DAF04(u8 a0) +static void PrintContestantTrainerName(u8 contestant) { - sub_80DAF1C(a0, a0 + 10); + PrintContestantTrainerNameWithColor(contestant, contestant + CONTESTANT_TEXT_COLOR_START); } -static void sub_80DAF1C(u8 a0, u8 a1) +static void PrintContestantTrainerNameWithColor(u8 contestant, u8 color) { u8 buffer[32]; s32 offset; StringCopy(buffer, gText_Slash); - StringAppend(buffer, gContestMons[a0].trainerName); - sub_80DAED4(buffer, a1); + StringAppend(buffer, gContestMons[contestant].trainerName); + Contest_CopyStringWithColor(buffer, color); offset = GetStringRightAlignXOffset(7, gDisplayedStringBattle, 0x60); if (offset > 55) offset = 55; - Contest_PrintTextToBg0WindowAt(gContestantTurnOrder[a0], gDisplayedStringBattle, offset, 1, 7); + Contest_PrintTextToBg0WindowAt(gContestantTurnOrder[contestant], gDisplayedStringBattle, offset, 1, 7); } -static void sub_80DAF88(u8 a0) +static void PrintContestantMonName(u8 contestant) { - sub_80DAFA0(a0, a0 + 10); + PrintContestantMonNameWithColor(contestant, contestant + CONTESTANT_TEXT_COLOR_START); } -static void sub_80DAFA0(u8 a0, u8 a1) +static void PrintContestantMonNameWithColor(u8 contestant, u8 color) { - sub_80DAED4(gContestMons[a0].nickname, a1); - Contest_PrintTextToBg0WindowAt(gContestantTurnOrder[a0], gDisplayedStringBattle, 5, 1, 7); + Contest_CopyStringWithColor(gContestMons[contestant].nickname, color); + Contest_PrintTextToBg0WindowAt(gContestantTurnOrder[contestant], gDisplayedStringBattle, 5, 1, 7); } static u16 sub_80DAFE0(u8 who, u8 contestCategory) @@ -2993,8 +3010,9 @@ bool8 IsSpeciesNotUnown(u16 species) static void sub_80DB2BC(void) { - CpuCopy16(gContestResources->ContestantInfoTilemaps[0], gContestResources->ContestantInfoTilemaps[0] + 0x500, 0x280); - CpuCopy16(gContestResources->ContestantInfoTilemaps[2], gContestResources->ContestantInfoTilemaps[2] + 0x500, 0x280); + + CpuCopy16(gContestResources->contestBgTilemaps[0], gContestResources->contestBgTilemaps[0] + 0x500, 0x280); + CpuCopy16(gContestResources->contestBgTilemaps[2], gContestResources->contestBgTilemaps[2] + 0x500, 0x280); } static u16 sub_80DB2EC(u16 a0, u8 a1) @@ -3454,7 +3472,7 @@ static void DetermineFinalStandings(void) void sub_80DBED4(void) { - if ((gIsLinkContest & 1)) + if ((gLinkContestFlags & LINK_CONTEST_FLAG_IS_LINK)) { gSaveBlock2Ptr->contestLinkResults[gSpecialVar_ContestCategory][gContestFinalStandings[gContestPlayerMonIndex]] = ((gSaveBlock2Ptr->contestLinkResults[gSpecialVar_ContestCategory][gContestFinalStandings[gContestPlayerMonIndex]] + 1) > 9999) ? 9999 : @@ -3487,14 +3505,14 @@ static void sub_80DBF68(void) gBattle_BG0_Y = 0; gBattle_BG2_Y = 0; sub_80DB89C(); - Contest_StartTextPrinter((u8*) &gUnknown_0827E8DA, 0); + Contest_StartTextPrinter(gText_LinkStandby4, 0); } -static void sub_80DBF90(void) +static void FillContestantWindowBgs(void) { int i; - for(i = 0; i < 4; i++) + for(i = 0; i < CONTESTANT_COUNT; i++) { ContestBG_FillBoxWithTile(0, 0, 0x16, 2 + i * 5, 8, 2, 0x11); } @@ -4021,7 +4039,7 @@ static void ContestDebugTogglePointTotal(void) if(eContestDebugMode == CONTEST_DEBUG_MODE_OFF) { - sub_80DAEA4(); + DrawContestantWindowText(); sub_80DB2BC(); } else @@ -4198,15 +4216,16 @@ void SortContestants(bool8 useRanking) } } -static void sub_80DD04C(void) +static void DrawContestantWindows(void) { s32 i; - for (i = 0; i < 4; i++) + for (i = 0; i < CONTESTANT_COUNT; i++) { - LoadPalette(&gHeap[0x1A004] + (i + CONTESTANT_WINDOW_START) * 32, (gContestantTurnOrder[i] + CONTESTANT_WINDOW_START) * 16, 32); + s32 windowId = i + CONTESTANT_WINDOW_START; + LoadPalette(eUnknownHeap1A004.cachedWindowPalettes[windowId], (gContestantTurnOrder[i] + CONTESTANT_WINDOW_START) * 16, sizeof(eUnknownHeap1A004.cachedWindowPalettes[0])); } - sub_80DAEA4(); + DrawContestantWindowText(); } static void sub_80DD080(u8 contestant) @@ -4694,7 +4713,7 @@ static void sub_80DDE30(u8 taskId) } else { - RequestDma3Copy(eUnknownHeap18000, (void *)(BG_SCREEN_ADDR(4)), 0x1000, 1); + RequestDma3Copy(eUnzippedContestAudienceGfx, (void *)(BG_SCREEN_ADDR(4)), 0x1000, 1); gTasks[taskId].data[12]++; } @@ -4858,7 +4877,7 @@ static void sub_80DE224(void) SetGpuReg(REG_OFFSET_BG1HOFS, gBattle_BG1_X); SetGpuReg(REG_OFFSET_BG1VOFS, gBattle_BG1_Y); - CpuFill32(0, gContestResources->ContestantInfoTilemaps[1], 0x1000); + CpuFill32(0, gContestResources->contestBgTilemaps[1], 0x1000); CopyToBgTilemapBuffer(1, gUnknown_08C17980, 0, 0); Contest_SetBgCopyFlags(1); @@ -4876,7 +4895,7 @@ static void sub_80DE350(void) u16 bg1Cnt; RequestDma3Fill(0,(void *)(BG_CHAR_ADDR(2)), 0x2000, 0x1); - CpuFill32(0, gContestResources->ContestantInfoTilemaps[1], 0x1000); + CpuFill32(0, gContestResources->contestBgTilemaps[1], 0x1000); Contest_SetBgCopyFlags(1); bg1Cnt = GetGpuReg(REG_OFFSET_BG1CNT); ((vBgCnt *) &bg1Cnt)->priority = 1; @@ -4924,18 +4943,18 @@ static void sub_80DE4A8(u8 taskId) switch (gTasks[taskId].data[0]) { case 0: - for (i = 0; i < 4; i++) + for (i = 0; i < CONTESTANT_COUNT; i++) eContest.prevTurnOrder[i] = gContestantTurnOrder[i]; - sub_80DBF90(); + FillContestantWindowBgs(); sub_80DC864(); sub_80DB69C(); - sub_80DD04C(); + DrawContestantWindows(); sub_80DE008(TRUE); sub_80DC44C(); gTasks[taskId].data[0] = 1; break; case 1: - if (gIsLinkContest & 1) + if (gLinkContestFlags & LINK_CONTEST_FLAG_IS_LINK) { u8 taskId2; @@ -5242,7 +5261,7 @@ static void Contest_StartTextPrinter(const u8 *currChar, bool32 b) } else { - if (gIsLinkContest & 1) + if (gLinkContestFlags & LINK_CONTEST_FLAG_IS_LINK) speed = 4; else speed = GetPlayerTextSpeedDelay(); @@ -5253,15 +5272,15 @@ static void Contest_StartTextPrinter(const u8 *currChar, bool32 b) Contest_SetBgCopyFlags(0); } -static void ContestBG_FillBoxWithIncrementingTile(u8 a, u16 b, u8 c, u8 d, u8 e, u8 f, u8 g, s16 h) +static void ContestBG_FillBoxWithIncrementingTile(u8 bg, u16 firstTileNum, u8 x, u8 y, u8 width, u8 height, u8 paletteSlot, s16 tileNumData) { - WriteSequenceToBgTilemapBuffer(a, b, c, d, e, f, g, h); - Contest_SetBgCopyFlags(a); + WriteSequenceToBgTilemapBuffer(bg, firstTileNum, x, y, width, height, paletteSlot, tileNumData); + Contest_SetBgCopyFlags(bg); } -static void ContestBG_FillBoxWithTile(u8 a, u16 b, u8 c, u8 d, u8 e, u8 f, u8 g) +static void ContestBG_FillBoxWithTile(u8 bg, u16 firstTileNum, u8 x, u8 y, u8 width, u8 height, u8 paletteSlot) { - ContestBG_FillBoxWithIncrementingTile(a, b, c, d, e, f, g, 0); + ContestBG_FillBoxWithIncrementingTile(bg, firstTileNum, x, y, width, height, paletteSlot, 0); } static bool32 Contest_RunTextPrinters(void) @@ -5324,7 +5343,7 @@ bool8 sub_80DEDA8(u8 a) gSaveBlock1Ptr->contestWinners[r4].trainerId = gContestMons[i].otId; StringCopy(gSaveBlock1Ptr->contestWinners[r4].monName, gContestMons[i].nickname); StringCopy(gSaveBlock1Ptr->contestWinners[r4].trainerName, gContestMons[i].trainerName); - if(gIsLinkContest & 1) + if(gLinkContestFlags & LINK_CONTEST_FLAG_IS_LINK) gSaveBlock1Ptr->contestWinners[r4].contestRank = 4; else gSaveBlock1Ptr->contestWinners[r4].contestRank = gSpecialVar_ContestRank; @@ -5677,7 +5696,7 @@ void ContestDebugToggleBitfields(bool8 showUnkD) if (eContestDebugMode == CONTEST_DEBUG_MODE_OFF) { - sub_80DAEA4(); + DrawContestantWindowText(); sub_80DB2BC(); } else diff --git a/src/contest_link_80F57C4.c b/src/contest_link_80F57C4.c index 8d0491efd..274893cc0 100644 --- a/src/contest_link_80F57C4.c +++ b/src/contest_link_80F57C4.c @@ -309,7 +309,7 @@ void sub_80F5B00(void) gBattle_WIN1V = 0x80A0; CreateTask(sub_80F68B4, 20); sub_80F7880(); - if (gIsLinkContest & 0x2) + if (gLinkContestFlags & LINK_CONTEST_FLAG_IS_WIRELESS) gPaletteFade.bufferTransferDisabled = 1; else PlayBGM(MUS_CON_K); @@ -351,7 +351,7 @@ static void sub_80F5CE4(u8 taskId) { u16 var; - if (gIsLinkContest & 1) + if (gLinkContestFlags & LINK_CONTEST_FLAG_IS_LINK) { switch (gTasks[taskId].data[0]) { @@ -381,7 +381,7 @@ static void sub_80F5CE4(u8 taskId) break; case 1: gTasks[taskId].data[0]++; - if (!(gIsLinkContest & 0x2)) + if (!(gLinkContestFlags & LINK_CONTEST_FLAG_IS_WIRELESS)) gTasks[taskId].data[0] = 100; break; case 2: @@ -406,7 +406,7 @@ static void sub_80F5CE4(u8 taskId) if (!gPaletteFade.active) { gTasks[taskId].data[0] = 0; - if (gIsLinkContest & 0x1) + if (gLinkContestFlags & LINK_CONTEST_FLAG_IS_LINK) { sub_80F707C(gText_CommunicationStandby); gTasks[taskId].func = sub_80F5ED8; @@ -742,7 +742,7 @@ static void sub_80F66B4(u8 taskId) if (gMain.newKeys & A_BUTTON) { - if (!(gIsLinkContest & 0x1)) + if (!(gLinkContestFlags & LINK_CONTEST_FLAG_IS_LINK)) { for (i = 0; i < 4; i++) { @@ -758,7 +758,7 @@ static void sub_80F66B4(u8 taskId) static void sub_80F671C(u8 taskId) { - if (gIsLinkContest & 0x1) + if (gLinkContestFlags & LINK_CONTEST_FLAG_IS_LINK) { if (!gTasks[taskId].data[10]) { @@ -777,7 +777,7 @@ static void sub_80F677C(u8 taskId) { if (!gReceivedRemoteLinkPlayers) { - if (gIsLinkContest & 0x2) + if (gLinkContestFlags & LINK_CONTEST_FLAG_IS_WIRELESS) DestroyWirelessStatusIndicatorSprite(); sub_80F7144(); @@ -787,7 +787,7 @@ static void sub_80F677C(u8 taskId) static void sub_80F67C4(u8 taskId) { - if (!(gIsLinkContest & 0x1)) + if (!(gLinkContestFlags & LINK_CONTEST_FLAG_IS_LINK)) BravoTrainerPokemonProfile_BeforeInterview2(gContestFinalStandings[gContestPlayerMonIndex]); BeginHardwarePaletteFade(0xFF, 0, 0, 16, 0); @@ -907,9 +907,9 @@ static void sub_80F6AE8(void) u16 sheet; u8 spriteId; - if (gIsLinkContest & 0x2) + if (gLinkContestFlags & LINK_CONTEST_FLAG_IS_WIRELESS) { - sub_800E0E8(); + LoadWirelessStatusIndicatorSprite(); CreateWirelessStatusIndicatorSprite(8, 8); gSprites[gWirelessStatusIndicatorSpriteId].subpriority = 1; sheet = LoadSpriteSheet(&gUnknown_0858D8E0); @@ -1392,7 +1392,7 @@ static void sub_80F71C8(void) x = 5; y = 1; - if (gIsLinkContest & 0x1) + if (gLinkContestFlags & LINK_CONTEST_FLAG_IS_LINK) { CopyToBgTilemapBufferRect(2, gUnknown_08DC6498, 5, 1, 5, 2); x = 10; @@ -2830,7 +2830,7 @@ void sub_80F8390(void) void sub_80F83D0(void) { - SetMainCallback2(CB2_ContestMain); + SetMainCallback2(CB2_StartContest); } static void sub_80F83E0(u8 taskId) @@ -2886,7 +2886,7 @@ void sub_80F84C4(u8 taskId) static void sub_80F8508(u8 taskId) { - if (gIsLinkContest & 0x4) + if (gLinkContestFlags & LINK_CONTEST_FLAG_HAS_RS_PLAYER) { sub_80DA8C8(gContestMonPartyIndex); SetTaskFuncWithFollowupFunc(taskId, sub_80FC6BC, sub_80F8568); diff --git a/src/contest_link_80FC4F4.c b/src/contest_link_80FC4F4.c index f64f1824b..d6cfea638 100644 --- a/src/contest_link_80FC4F4.c +++ b/src/contest_link_80FC4F4.c @@ -72,22 +72,22 @@ static void sub_80FC5DC(u8 taskId) gContestPlayerMonIndex = GetMultiplayerId(); gNumLinkContestPlayers = GetLinkPlayerCount(); - gIsLinkContest = 1; + gLinkContestFlags = LINK_CONTEST_FLAG_IS_LINK; if (gWirelessCommType == 1) - gIsLinkContest = 3; + gLinkContestFlags = LINK_CONTEST_FLAG_IS_LINK | LINK_CONTEST_FLAG_IS_WIRELESS; for (i = 0; i < gNumLinkContestPlayers && (u32)(gLinkPlayers[i].version & 0xFF) - 1 > VERSION_RUBY - 1; i++) ; if (i < gNumLinkContestPlayers) - gIsLinkContest |= 0x4; + gLinkContestFlags |= LINK_CONTEST_FLAG_HAS_RS_PLAYER; SwitchTaskToFollowupFunc(taskId); } bool32 sub_80FC670(s16 *arg0) { - if (gIsLinkContest & 0x4) + if (gLinkContestFlags & LINK_CONTEST_FLAG_HAS_RS_PLAYER) return TRUE; switch (*arg0) diff --git a/src/evolution_scene.c b/src/evolution_scene.c index 8c4847b8d..00f8df0f2 100644 --- a/src/evolution_scene.c +++ b/src/evolution_scene.c @@ -445,7 +445,7 @@ static void CB2_TradeEvolutionSceneLoadGraphics(void) case 6: if (gWirelessCommType) { - sub_800E0E8(); + LoadWirelessStatusIndicatorSprite(); CreateWirelessStatusIndicatorSprite(0, 0); } BlendPalettes(-1,0x10, 0); diff --git a/src/link_rfu.c b/src/link_rfu.c index a430f6e24..4e14a3ffd 100644 --- a/src/link_rfu.c +++ b/src/link_rfu.c @@ -2254,7 +2254,7 @@ void DestroyWirelessStatusIndicatorSprite(void) } } -void sub_800E0E8(void) +void LoadWirelessStatusIndicatorSprite(void) { if (GetSpriteTileStartByTag(sWirelessStatusIndicatorSpriteSheet.tag) == 0xFFFF) { diff --git a/src/overworld.c b/src/overworld.c index ce1e21ab1..7c3bbeb5c 100644 --- a/src/overworld.c +++ b/src/overworld.c @@ -1874,7 +1874,7 @@ static bool32 map_loading_iteration_3(u8 *state) case 11: if (gWirelessCommType != 0) { - sub_800E0E8(); + LoadWirelessStatusIndicatorSprite(); CreateWirelessStatusIndicatorSprite(0, 0); } (*state)++; @@ -2046,7 +2046,7 @@ static bool32 map_loading_iteration_2_link(u8 *state) case 11: if (gWirelessCommType != 0) { - sub_800E0E8(); + LoadWirelessStatusIndicatorSprite(); CreateWirelessStatusIndicatorSprite(0, 0); } (*state)++; diff --git a/src/reshow_battle_screen.c b/src/reshow_battle_screen.c index dd177f884..e37a5f8a5 100644 --- a/src/reshow_battle_screen.c +++ b/src/reshow_battle_screen.c @@ -154,7 +154,7 @@ static void CB2_ReshowBattleScreenAfterMenu(void) if (gWirelessCommType != 0 && gReceivedRemoteLinkPlayers != 0) { - sub_800E0E8(); + LoadWirelessStatusIndicatorSprite(); CreateWirelessStatusIndicatorSprite(0, 0); } } diff --git a/src/script_pokemon_util_80F87D8.c b/src/script_pokemon_util_80F87D8.c index 7e4c14531..fc2d7cf08 100755 --- a/src/script_pokemon_util_80F87D8.c +++ b/src/script_pokemon_util_80F87D8.c @@ -227,7 +227,7 @@ void sub_80F8AFC(void) { int i; - if (gIsLinkContest & 1) + if (gLinkContestFlags & LINK_CONTEST_FLAG_IS_LINK) { for (i = 0; i < gNumLinkContestPlayers; i++) { @@ -256,7 +256,7 @@ void sub_80F8B94(void) struct Sprite *sprite; gReservedSpritePaletteCount = 12; - if (gIsLinkContest & 1) + if (gLinkContestFlags & LINK_CONTEST_FLAG_IS_LINK) { for (i = 0; i < gNumLinkContestPlayers; i++) { @@ -339,9 +339,9 @@ void ShowContestEntryMonPic(void) gMultiuseSpriteTemplate.paletteTag = palette->tag; spriteId = CreateSprite(&gMultiuseSpriteTemplate, (left + 1) * 8 + 32, (top * 8) + 40, 0); - if (gIsLinkContest & 1) + if (gLinkContestFlags & LINK_CONTEST_FLAG_IS_LINK) { - if (!(gIsLinkContest & 4)) + if (!(gLinkContestFlags & LINK_CONTEST_FLAG_HAS_RS_PLAYER)) DoMonFrontSpriteAnimation(&gSprites[spriteId], species, FALSE, 0); } else @@ -403,7 +403,7 @@ static void sub_80F8EE8(u8 taskId) void ScriptGetMultiplayerId(void) { - if ((gIsLinkContest & 1) && gNumLinkContestPlayers == 4 && !(gIsLinkContest & 2)) + if ((gLinkContestFlags & LINK_CONTEST_FLAG_IS_LINK) && gNumLinkContestPlayers == 4 && !(gLinkContestFlags & LINK_CONTEST_FLAG_IS_WIRELESS)) gSpecialVar_Result = GetMultiplayerId(); else gSpecialVar_Result = 4; @@ -414,7 +414,7 @@ void ScriptRandom(void) u16 random; u16 *scriptPtr; - if (gIsLinkContest & 1) + if (gLinkContestFlags & LINK_CONTEST_FLAG_IS_LINK) { gContestRngValue = 1103515245 * gContestRngValue + 24691; random = gContestRngValue >> 16; @@ -436,7 +436,7 @@ u16 sub_80F903C(void) u8 sub_80F905C(void) { - if (gIsLinkContest & 2) + if (gLinkContestFlags & LINK_CONTEST_FLAG_IS_WIRELESS) { CreateTask(sub_80F9088, 5); return 1; @@ -473,11 +473,11 @@ static void sub_80F9088(u8 taskId) void sub_80F90DC(void) { - if (gIsLinkContest & 2) + if (gLinkContestFlags & LINK_CONTEST_FLAG_IS_WIRELESS) { if (gReceivedRemoteLinkPlayers) { - sub_800E0E8(); + LoadWirelessStatusIndicatorSprite(); CreateWirelessStatusIndicatorSprite(8, 8); } } @@ -485,7 +485,7 @@ void sub_80F90DC(void) void sub_80F910C(void) { - if (gIsLinkContest & 2) + if (gLinkContestFlags & LINK_CONTEST_FLAG_IS_WIRELESS) { if (gReceivedRemoteLinkPlayers) DestroyWirelessStatusIndicatorSprite(); @@ -494,7 +494,7 @@ void sub_80F910C(void) u8 sub_80F9134(void) { - if (gIsLinkContest & 4) + if (gLinkContestFlags & LINK_CONTEST_FLAG_HAS_RS_PLAYER) return 1; else return 0; @@ -502,12 +502,12 @@ u8 sub_80F9134(void) void sub_80F9154(void) { - gIsLinkContest = 0; + gLinkContestFlags = 0; } u8 sub_80F9160(void) { - if (gIsLinkContest & 2) + if (gLinkContestFlags & LINK_CONTEST_FLAG_IS_WIRELESS) return 1; else return 0; diff --git a/src/trade.c b/src/trade.c index 80c74d2cd..99c92a949 100644 --- a/src/trade.c +++ b/src/trade.c @@ -1626,7 +1626,7 @@ static void sub_80773D0(void) if (sub_8010500()) { gMain.state++; - sub_800E0E8(); + LoadWirelessStatusIndicatorSprite(); CreateWirelessStatusIndicatorSprite(0, 0); } } @@ -1820,7 +1820,7 @@ static void sub_8077B74(void) case 5: if (gWirelessCommType) { - sub_800E0E8(); + LoadWirelessStatusIndicatorSprite(); CreateWirelessStatusIndicatorSprite(0, 0); } gMain.state++; @@ -4246,7 +4246,7 @@ void sub_807AE50(void) { if (gWirelessCommType) { - sub_800E0E8(); + LoadWirelessStatusIndicatorSprite(); CreateWirelessStatusIndicatorSprite(0, 0); } SetMainCallback2(sub_807EA2C); diff --git a/src/trainer_card.c b/src/trainer_card.c index 01839d598..41ebf46a5 100755 --- a/src/trainer_card.c +++ b/src/trainer_card.c @@ -381,7 +381,7 @@ static void sub_80C2760(u8 taskId) case 7: if (gWirelessCommType == 1 && gReceivedRemoteLinkPlayers == TRUE) { - sub_800E0E8(); + LoadWirelessStatusIndicatorSprite(); CreateWirelessStatusIndicatorSprite(230, 150); } BlendPalettes(0xFFFFFFFF, 16, sData->var_52C); diff --git a/src/union_room.c b/src/union_room.c index ad33112e4..62ae34336 100644 --- a/src/union_room.c +++ b/src/union_room.c @@ -1406,7 +1406,7 @@ void sub_8012780(u8 taskId) switch (sub_80170B8(&data->textState, sub_801064C(ReadAsU16(data->field_0->arr[data->field_13].unk.field_0.unk_00.playerTrainerId), data->field_0->arr[data->field_13].unk.playerName))) { case 0: - sub_800E0E8(); + LoadWirelessStatusIndicatorSprite(); CreateWirelessStatusIndicatorSprite(0, 0); data->field_19 = 5; sub_8010688(5, ReadAsU16(data->field_0->arr[data->field_13].unk.field_0.unk_00.playerTrainerId), data->field_0->arr[data->field_13].unk.playerName); @@ -2132,7 +2132,7 @@ u32 sub_8013B8C(struct UnkStruct_Group *arg0, s32 id) void sub_8013BD8(struct UnkStruct_Group *data, s32 id) { data->field_F = id; - sub_800E0E8(); + LoadWirelessStatusIndicatorSprite(); CreateWirelessStatusIndicatorSprite(0, 0); RedrawListMenu(data->listTaskId); sub_8018404(gStringVar1, &data->field_0->arr[data->field_F]); @@ -2784,7 +2784,7 @@ void sub_8014A40(u8 taskId) switch (mevent_message_print_and_prompt_yes_no(&data->textState, &data->field_14, 0, gStringVar4)) { case 0: - sub_800E0E8(); + LoadWirelessStatusIndicatorSprite(); CreateWirelessStatusIndicatorSprite(0, 0); data->field_0->arr[data->field_13].field_1B = 0; RedrawListMenu(data->listTaskId); @@ -2987,7 +2987,7 @@ void sub_8014F48(u8 taskId) if (data->field_0->arr[id].field_1A_0 == 1 && !data->field_0->arr[id].unk.field_0.unk_0a_7) { data->field_F = id; - sub_800E0E8(); + LoadWirelessStatusIndicatorSprite(); CreateWirelessStatusIndicatorSprite(0, 0); RedrawListMenu(data->listTaskId); sub_8018404(gStringVar1, &data->field_0->arr[data->field_F]); @@ -3150,7 +3150,7 @@ void sub_80152F4(u8 taskId) { data->field_F = 0; data->field_14 = 0; - sub_800E0E8(); + LoadWirelessStatusIndicatorSprite(); CreateWirelessStatusIndicatorSprite(0, 0); sub_8011FC8(data->field_0->arr[0].unk.playerName, ReadAsU16(data->field_0->arr[0].unk.field_0.unk_00.playerTrainerId)); PlaySE(SE_PN_ON); diff --git a/src/union_room_chat.c b/src/union_room_chat.c index 120252d36..25f68f875 100755 --- a/src/union_room_chat.c +++ b/src/union_room_chat.c @@ -281,7 +281,7 @@ static void c2_081284E0(void) SetMainCallback2(sub_801DF38); gUnknown_02022C84->unkE = CreateTask(sub_801DF54, 8); gUnknown_02022C84->unkF = CreateTask(sub_801F2B4, 7); - sub_800E0E8(); + LoadWirelessStatusIndicatorSprite(); CreateWirelessStatusIndicatorSprite(232, 150); } break; From 3b3b2dd031868f116e09b7bbff7e8b8b6ceb7a9a Mon Sep 17 00:00:00 2001 From: Phlosioneer Date: Wed, 3 Apr 2019 20:43:23 -0400 Subject: [PATCH 08/22] General cleanup of the second half of contest.c --- data/text/contest_strings.inc | 2 +- include/contest.h | 9 +- src/contest.c | 461 +++++++++++++++++----------------- src/contest_ai.c | 6 +- src/contest_link_80F57C4.c | 2 +- 5 files changed, 246 insertions(+), 234 deletions(-) diff --git a/data/text/contest_strings.inc b/data/text/contest_strings.inc index 1406ba3cb..e332e16bb 100644 --- a/data/text/contest_strings.inc +++ b/data/text/contest_strings.inc @@ -633,7 +633,7 @@ gText_0827E6C4:: @ 827E6C4 .string "{STR_VAR_1} was\n" .string "unaffected.{PAUSE 0x0F}{PAUSE 0x0F}{PAUSE 0x0F}{PAUSE 0x0F}$" -gText_0827E6E3:: @ 827E6E3 +gText_RepeatedAppeal:: @ 827E6E3 .string "{STR_VAR_1} disappointed\n" .string "by repeating an appeal.{PAUSE 0x0F}{PAUSE 0x0F}{PAUSE 0x0F}{PAUSE 0x0F}$" diff --git a/include/contest.h b/include/contest.h index 2f986f217..1fba54885 100644 --- a/include/contest.h +++ b/include/contest.h @@ -5,6 +5,7 @@ #define CONTESTANT_COUNT 4 #define APPLAUSE_METER_SIZE 5 +#define CONTEST_TURN_COUNT 5 #define CONTEST_DEBUG_MODE_OFF 0 // Prints the totalPoints value for each contestant. @@ -298,9 +299,9 @@ struct Contest /*0x13*/ s8 applauseLevel; /*0x19218*/ u8 prevTurnOrder[CONTESTANT_COUNT]; /*0x1921C*/ u32 unk1921C; // saved RNG value? - u16 unk19220[5][4]; // move history? - u8 unk19248[5][4]; // excitement history - u8 applauseMeterSpriteId; // sprite ID + u16 moveHistory[CONTEST_TURN_COUNT][CONTESTANT_COUNT]; + u8 excitementHistory[CONTEST_TURN_COUNT][CONTESTANT_COUNT]; + u8 applauseMeterSpriteId; /*0x1925D*/ u8 contestSetupState; /*0x1925E*/ u8 unk1925E; }; @@ -483,7 +484,7 @@ u8 sub_80DAE0C(struct Pokemon *pkmn); void sub_80DB09C(u8 contestCategory); bool8 IsSpeciesNotUnown(u16 species); bool8 Contest_IsMonsTurnDisabled(u8 a); -void sub_80DBED4(void); +void SaveLinkContestResults(void); void SortContestants(bool8 a); void SetContestantEffectStringID(u8 a, u8 b); void SetContestantEffectStringID2(u8 a, u8 b); diff --git a/src/contest.c b/src/contest.c index 381301632..9ca99c146 100644 --- a/src/contest.c +++ b/src/contest.c @@ -51,19 +51,23 @@ // Contestant 0 will use palette color 10, contestant 1 will use color 11, etc. #define CONTESTANT_TEXT_COLOR_START 10 -#define CONTEST_WINDOW_UNK_0 0 -#define CONTEST_WINDOW_UNK_1 1 -#define CONTEST_WINDOW_UNK_2 2 -#define CONTEST_WINDOW_UNK_3 3 -#define CONTEST_WINDOW_UNK_4 4 -#define CONTEST_WINDOW_CONTESTANT1 5 -#define CONTEST_WINDOW_CONTESTANT2 6 -#define CONTEST_WINDOW_CONTESTANT3 7 -#define CONTEST_WINDOW_CONTESTANT4 8 -#define CONTEST_WINDOW_UNK_9 9 -#define CONTEST_WINDOW_UNK_10 10 +// The "{Pokemon Name} / {Trainer Name}" windows. +#define CONTEST_WINDOW_CONTESTANT0_NAME 0 +#define CONTEST_WINDOW_CONTESTANT1_NAME 1 +#define CONTEST_WINDOW_CONTESTANT2_NAME 2 +#define CONTEST_WINDOW_CONTESTANT3_NAME 3 +#define CONTEST_WINDOW_GENERAL_TEXT 4 +// The available moves, from top to bottom +#define CONTEST_WINDOW_MOVE0 5 +#define CONTEST_WINDOW_MOVE1 6 +#define CONTEST_WINDOW_MOVE2 7 +#define CONTEST_WINDOW_MOVE3 8 +// The small "/" character between the move category and the +// appeal/jam display +#define CONTEST_WINDOW_SLASH 9 +#define CONTEST_WINDOW_MOVE_DESCRIPTION 10 -#define CONTESTANT_WINDOW_START CONTEST_WINDOW_CONTESTANT1 +#define MOVE_WINDOWS_START CONTEST_WINDOW_MOVE0 // This file's functions. static void sub_80D782C(void); @@ -121,12 +125,12 @@ static void PrintContestantMonNameWithColor(u8, u8); static u8 sub_80DB0C4(void); static u8 sub_80DB120(void); static u8 sub_80DB174(u16, u32, u32, u32); -static void prints_contest_move_description(u16); +static void PrintContestMoveDescription(u16); static u16 SanitizeSpecies(u16); -static void sub_80DB89C(void); +static void ContestClearGeneralTextWindow(void); static u16 GetChosenMove(u8); -static void sub_80DB918(void); -static void sub_80DBF68(void); +static void GetAllChosenMoves(void); +static void ContestPrintLinkStandby(void); static void FillContestantWindowBgs(void); static void sub_80DC2BC(void); static void sub_80DC490(bool8); @@ -171,7 +175,7 @@ static void sub_80DDED0(s8, s8); static void ShowAndUpdateApplauseMeter(s8 unused); static void sub_80DDE0C(void); static void UpdateApplauseMeter(void); -static void sub_80DB944(void); +static void RankContestants(void); static void sub_80DBA18(void); static void sub_80DC3AC(void); static bool8 sub_80DC3C4(void); @@ -209,7 +213,7 @@ static void sub_80DF080(u8); static void ContestDebugPrintBitStrings(void); static void sub_80DF9D4(u8 *); static void sub_80DF9E0(u8 *, s32); -static void sub_80DB2BC(void); +static void SwapMoveDescAndContestTilemaps(void); // EWRAM vars. EWRAM_DATA struct ContestPokemon gContestMons[4] = {0}; @@ -245,7 +249,7 @@ extern const u8 gText_0827E32E[]; extern const u8 gText_0827E35B[]; extern const u8 gText_0827E38D[]; extern const u8 gText_0827E2FE[]; -extern const u8 gText_0827E6E3[]; +extern const u8 gText_RepeatedAppeal[]; extern const u8 gText_0827E73C[]; extern const u8 gText_0827E717[]; extern const u8 gText_0827E76A[]; @@ -636,7 +640,7 @@ static const struct BgTemplate sContestBgTemplates[] = static const struct WindowTemplate sContestWindowTemplates[] = { - [CONTEST_WINDOW_UNK_0] = { + [CONTEST_WINDOW_CONTESTANT0_NAME] = { .bg = 0, .tilemapLeft = 18, .tilemapTop = 0, @@ -645,7 +649,7 @@ static const struct WindowTemplate sContestWindowTemplates[] = .paletteNum = 0xF, .baseBlock = 0x200 }, - [CONTEST_WINDOW_UNK_1] = { + [CONTEST_WINDOW_CONTESTANT1_NAME] = { .bg = 0, .tilemapLeft = 18, .tilemapTop = 5, @@ -654,7 +658,7 @@ static const struct WindowTemplate sContestWindowTemplates[] = .paletteNum = 0xF, .baseBlock = 0x218 }, - [CONTEST_WINDOW_UNK_2] = { + [CONTEST_WINDOW_CONTESTANT2_NAME] = { .bg = 0, .tilemapLeft = 18, .tilemapTop = 10, @@ -663,7 +667,7 @@ static const struct WindowTemplate sContestWindowTemplates[] = .paletteNum = 0xF, .baseBlock = 0x230 }, - [CONTEST_WINDOW_UNK_3] = { + [CONTEST_WINDOW_CONTESTANT3_NAME] = { .bg = 0, .tilemapLeft = 18, .tilemapTop = 15, @@ -672,7 +676,7 @@ static const struct WindowTemplate sContestWindowTemplates[] = .paletteNum = 0xF, .baseBlock = 0x248 }, - [CONTEST_WINDOW_UNK_4] = { + [CONTEST_WINDOW_GENERAL_TEXT] = { .bg = 0, .tilemapLeft = 1, .tilemapTop = 15, @@ -681,55 +685,55 @@ static const struct WindowTemplate sContestWindowTemplates[] = .paletteNum = 0xF, .baseBlock = 0x260 }, - [CONTEST_WINDOW_CONTESTANT1] = { + [CONTEST_WINDOW_MOVE0] = { .bg = 0, .tilemapLeft = 1, - .tilemapTop = 0x1F, + .tilemapTop = 31, .width = 9, .height = 2, .paletteNum = 0xF, .baseBlock = 0x2A4 }, - [CONTEST_WINDOW_CONTESTANT2] = { + [CONTEST_WINDOW_MOVE1] = { .bg = 0, .tilemapLeft = 1, - .tilemapTop = 0x21, + .tilemapTop = 33, .width = 9, .height = 2, .paletteNum = 0xF, .baseBlock = 0x2B6 }, - [CONTEST_WINDOW_CONTESTANT3] = { + [CONTEST_WINDOW_MOVE2] = { .bg = 0, .tilemapLeft = 1, - .tilemapTop = 0x23, + .tilemapTop = 35, .width = 9, .height = 2, .paletteNum = 0xF, .baseBlock = 0x2C8 }, - [CONTEST_WINDOW_CONTESTANT4] = { + [CONTEST_WINDOW_MOVE3] = { .bg = 0, .tilemapLeft = 1, - .tilemapTop = 0x25, + .tilemapTop = 37, .width = 9, .height = 2, .paletteNum = 0xF, .baseBlock = 0x2DA }, - [CONTEST_WINDOW_UNK_9] = { + [CONTEST_WINDOW_SLASH] = { .bg = 0, .tilemapLeft = 16, - .tilemapTop = 0x1F, + .tilemapTop = 31, .width = 1, .height = 2, .paletteNum = 0xF, .baseBlock = 0x2EC }, - [CONTEST_WINDOW_UNK_10] = { + [CONTEST_WINDOW_MOVE_DESCRIPTION] = { .bg = 0, .tilemapLeft = 11, - .tilemapTop = 0x23, + .tilemapTop = 35, .width = 18, .height = 4, .paletteNum = 0xF, @@ -919,9 +923,9 @@ void LoadContestBgAfterMoveAnim(void) sub_80D782C(); for (i = 0; i < CONTESTANT_COUNT; i++) { - u32 contestantWindowId = CONTESTANT_WINDOW_START + i; + u32 contestantWindowId = MOVE_WINDOWS_START + i; - LoadPalette(eUnknownHeap1A004.cachedWindowPalettes[contestantWindowId], 16 * (CONTESTANT_WINDOW_START + gContestantTurnOrder[i]), sizeof((eUnknownHeap1A004.cachedWindowPalettes[contestantWindowId]))); + LoadPalette(eUnknownHeap1A004.cachedWindowPalettes[contestantWindowId], 16 * (MOVE_WINDOWS_START + gContestantTurnOrder[i]), sizeof((eUnknownHeap1A004.cachedWindowPalettes[contestantWindowId]))); } } @@ -1119,7 +1123,7 @@ static void sub_80D7CB4(u8 taskId) switch (gTasks[taskId].data[0]) { case 0: - sub_80DBF68(); + ContestPrintLinkStandby(); gTasks[taskId].data[0]++; // fallthrough case 1: @@ -1141,7 +1145,7 @@ static void sub_80D7CB4(u8 taskId) { gPaletteFade.bufferTransferDisabled = FALSE; if (!(gLinkContestFlags & LINK_CONTEST_FLAG_IS_WIRELESS)) - sub_80DBF68(); + ContestPrintLinkStandby(); CreateTask(sub_80D7DAC, 0); gTasks[taskId].data[0] = 0; gTasks[taskId].func = TaskDummy1; @@ -1209,16 +1213,16 @@ static bool8 SetupContestGraphics(u8 *stateVar) case 5: LoadCompressedPalette(gOldContestPalette, 0, 0x200); CpuCopy32(gPlttBufferUnfaded + 128, tempPalette1, 16 * sizeof(u16)); - CpuCopy32(gPlttBufferUnfaded + (CONTESTANT_WINDOW_START + gContestPlayerMonIndex) * 16, tempPalette2, 16 * sizeof(u16)); + CpuCopy32(gPlttBufferUnfaded + (MOVE_WINDOWS_START + gContestPlayerMonIndex) * 16, tempPalette2, 16 * sizeof(u16)); CpuCopy32(tempPalette2, gPlttBufferUnfaded + 128, 16 * sizeof(u16)); - CpuCopy32(tempPalette1, gPlttBufferUnfaded + (CONTESTANT_WINDOW_START + gContestPlayerMonIndex) * 16, 16 * sizeof(u16)); + CpuCopy32(tempPalette1, gPlttBufferUnfaded + (MOVE_WINDOWS_START + gContestPlayerMonIndex) * 16, 16 * sizeof(u16)); DmaCopy32Defvars(3, gPlttBufferUnfaded, eUnknownHeap1A004.cachedWindowPalettes, sizeof(eUnknownHeap1A004.cachedWindowPalettes)); sub_80D782C(); break; case 6: DrawContestantWindows(); FillContestantWindowBgs(); - sub_80DB2BC(); + SwapMoveDescAndContestTilemaps(); eContest.unk19216 = sub_80DB120(); sub_80DC2BC(); sub_80DC4F0(); @@ -1244,11 +1248,11 @@ static bool8 SetupContestGraphics(u8 *stateVar) break; default: *stateVar = 0; - return 1; + return TRUE; } (*stateVar)++; - return 0; + return FALSE; } static void sub_80D80C8(u8 taskId) @@ -1356,9 +1360,9 @@ static void sub_80D833C(u8 taskId) StringCopy(gDisplayedStringBattle, gText_0827D507); else StringCopy(gDisplayedStringBattle, gText_0827D531); - sub_80DB89C(); + ContestClearGeneralTextWindow(); StringExpandPlaceholders(gStringVar4, gDisplayedStringBattle); - Contest_StartTextPrinter(gStringVar4, 1); + Contest_StartTextPrinter(gStringVar4, TRUE); gTasks[taskId].data[0]++; } else @@ -1417,12 +1421,12 @@ static void sub_80D8490(u8 taskId) } r5 = StringCopy(r5, gMoveNames[move]); - FillWindowPixelBuffer(i + CONTESTANT_WINDOW_START, PIXEL_FILL(0)); - Contest_PrintTextToBg0WindowAt(i + CONTESTANT_WINDOW_START, sp8, 5, 1, 7); + FillWindowPixelBuffer(i + MOVE_WINDOWS_START, PIXEL_FILL(0)); + Contest_PrintTextToBg0WindowAt(i + MOVE_WINDOWS_START, sp8, 5, 1, 7); } sub_80D880C(eContest.playerMoveChoice); - prints_contest_move_description(gContestMons[gContestPlayerMonIndex].moves[eContest.playerMoveChoice]); + PrintContestMoveDescription(gContestMons[gContestPlayerMonIndex].moves[eContest.playerMoveChoice]); gTasks[taskId].func = sub_80D8610; } @@ -1454,7 +1458,7 @@ static void sub_80D8610(u8 taskId) StringCopy(gDisplayedStringBattle, gText_0827D507); else StringCopy(gDisplayedStringBattle, gText_0827D531); - sub_80DB89C(); + ContestClearGeneralTextWindow(); StringExpandPlaceholders(gStringVar4, gDisplayedStringBattle); Contest_StartTextPrinter(gStringVar4, 0); gBattle_BG0_Y = 0; @@ -1471,7 +1475,7 @@ static void sub_80D8610(u8 taskId) else eContest.playerMoveChoice--; sub_80D880C(eContest.playerMoveChoice); - prints_contest_move_description(gContestMons[gContestPlayerMonIndex].moves[eContest.playerMoveChoice]); + PrintContestMoveDescription(gContestMons[gContestPlayerMonIndex].moves[eContest.playerMoveChoice]); if (numMoves > 1) PlaySE(SE_SELECT); break; @@ -1482,7 +1486,7 @@ static void sub_80D8610(u8 taskId) else eContest.playerMoveChoice++; sub_80D880C(eContest.playerMoveChoice); - prints_contest_move_description(gContestMons[gContestPlayerMonIndex].moves[eContest.playerMoveChoice]); + PrintContestMoveDescription(gContestMons[gContestPlayerMonIndex].moves[eContest.playerMoveChoice]); if (numMoves > 1) PlaySE(SE_SELECT); break; @@ -1512,12 +1516,12 @@ static void sub_80D8894(u8 taskId) taskId2 = CreateTask(sub_80FC9F8, 0); SetTaskFuncWithFollowupFunc(taskId2, sub_80FC9F8, sub_80D892C); gTasks[taskId].func = TaskDummy1; - sub_80DBF68(); + ContestPrintLinkStandby(); sub_80DC490(FALSE); } else { - sub_80DB918(); + GetAllChosenMoves(); gTasks[taskId].func = sub_80D895C; } } @@ -1532,16 +1536,16 @@ static void sub_80D895C(u8 taskId) { s32 i; - sub_80DB89C(); + ContestClearGeneralTextWindow(); gBattle_BG0_Y = 0; gBattle_BG2_Y = 0; sub_80DC490(FALSE); for (i = 0; i < CONTESTANT_COUNT; i++) { - FillWindowPixelBuffer(CONTESTANT_WINDOW_START + i, PIXEL_FILL(0)); - PutWindowTilemap(CONTESTANT_WINDOW_START + i); - CopyWindowToVram(CONTESTANT_WINDOW_START + i, 2); + FillWindowPixelBuffer(MOVE_WINDOWS_START + i, PIXEL_FILL(0)); + PutWindowTilemap(MOVE_WINDOWS_START + i); + CopyWindowToVram(MOVE_WINDOWS_START + i, 2); } Contest_SetBgCopyFlags(0); // This seems to be a bug; it should have just copied PLTT_BUFFER_SIZE. @@ -1616,7 +1620,7 @@ static void sub_80D8B38(u8 taskId) sub_80DD080(eContest.unk19215); taskId2 = CreateTask(sub_80FCC88, 0); SetTaskFuncWithFollowupFunc(taskId2, sub_80FCC88, sub_80DA110); - sub_80DBF68(); + ContestPrintLinkStandby(); gTasks[taskId].data[0] = 1; } else @@ -1639,7 +1643,7 @@ static void sub_80D8B38(u8 taskId) } else { - sub_80DB89C(); + ContestClearGeneralTextWindow(); gTasks[taskId].data[10] = 0; gTasks[taskId].data[0] = 3; } @@ -1676,7 +1680,7 @@ static void sub_80D8B38(u8 taskId) } else { - sub_80DB89C(); + ContestClearGeneralTextWindow(); StringCopy(gStringVar1, gContestMons[r6].nickname); if (eContestantStatus[r6].currMove < MOVES_COUNT) StringCopy(gStringVar2, gMoveNames[eContestantStatus[r6].currMove]); @@ -1938,7 +1942,7 @@ static void sub_80D8B38(u8 taskId) if (eContestantStatus[r6].numTurnsSkipped != 0 || eContestantStatus[r6].turnSkipped) { - sub_80DB89C(); + ContestClearGeneralTextWindow(); StringCopy(gStringVar1, gContestMons[r6].nickname); StringExpandPlaceholders(gStringVar4, gText_0827E793); Contest_StartTextPrinter(gStringVar4, 1); @@ -1959,20 +1963,20 @@ static void sub_80D8B38(u8 taskId) r3 = eContestantStatus[r6].unk16; if (eContestantStatus[r6].unk16 != 0) { - sub_80DB89C(); + ContestClearGeneralTextWindow(); if (r3 == 1) - Contest_StartTextPrinter(gText_0827E32E, 1); + Contest_StartTextPrinter(gText_0827E32E, TRUE); else if (r3 == 2) - Contest_StartTextPrinter(gText_0827E35B, 1); + Contest_StartTextPrinter(gText_0827E35B, TRUE); else - Contest_StartTextPrinter(gText_0827E38D, 1); + Contest_StartTextPrinter(gText_0827E38D, TRUE); sub_80DD720(3); gTasks[taskId].data[10] = 0; gTasks[taskId].data[0] = 45; } else { - sub_80DB89C(); + ContestClearGeneralTextWindow(); StringCopy(gStringVar1, gContestMons[r6].nickname); StringExpandPlaceholders(gStringVar4, gText_0827E2FE); Contest_StartTextPrinter(gStringVar4, 1); @@ -2015,10 +2019,10 @@ static void sub_80D8B38(u8 taskId) case 17: if (eContestantStatus[r6].disappointedRepeat) { - sub_80DB89C(); + ContestClearGeneralTextWindow(); StringCopy(gStringVar1, gContestMons[r6].nickname); - StringExpandPlaceholders(gStringVar4, gText_0827E6E3); - Contest_StartTextPrinter(gStringVar4, 1); + StringExpandPlaceholders(gStringVar4, gText_RepeatedAppeal); + Contest_StartTextPrinter(gStringVar4, TRUE); gTasks[taskId].data[10] = 0; sub_80DD720(0); gTasks[taskId].data[0] = 46; @@ -2045,7 +2049,7 @@ static void sub_80D8B38(u8 taskId) if (!gContestResources->field_14[r6].unk2_2) { gTasks[taskId].data[10] = 0; - sub_80DB89C(); + ContestClearGeneralTextWindow(); gTasks[taskId].data[0] = 41; } return; @@ -2071,7 +2075,7 @@ static void sub_80D8B38(u8 taskId) if (eContestantStatus[r6].disappointedRepeat) r3 = 0; } - sub_80DB89C(); + ContestClearGeneralTextWindow(); StringCopy(gStringVar1, gContestMons[r6].nickname); eContest.applauseLevel += r3; if (eContest.applauseLevel < 0) @@ -2188,32 +2192,32 @@ static void sub_80D8B38(u8 taskId) case 43: if (!gContestResources->field_14[r6].unk2_2) { - sub_80DB89C(); + ContestClearGeneralTextWindow(); gTasks[taskId].data[0] = 55; } return; case 57: - sub_80DB89C(); + ContestClearGeneralTextWindow(); StringCopy(gStringVar3, gContestMons[gContestResources->field_10->excitementFreezer].nickname); StringCopy(gStringVar1, gContestMons[r6].nickname); StringCopy(gStringVar2, gMoveNames[eContestantStatus[r6].currMove]); StringExpandPlaceholders(gStringVar4, gText_0827E7EA); - Contest_StartTextPrinter(gStringVar4, 1); + Contest_StartTextPrinter(gStringVar4, TRUE); gTasks[taskId].data[0] = 58; return; case 58: if (!Contest_RunTextPrinters()) { - sub_80DB89C(); + ContestClearGeneralTextWindow(); StringExpandPlaceholders(gStringVar4, gText_0827E817); - Contest_StartTextPrinter(gStringVar4, 1); + Contest_StartTextPrinter(gStringVar4, TRUE); gTasks[taskId].data[0] = 59; } return; case 59: if (!Contest_RunTextPrinters()) { - sub_80DB89C(); + ContestClearGeneralTextWindow(); gTasks[taskId].data[0] = 55; } return; @@ -2224,7 +2228,7 @@ static void sub_80D8B38(u8 taskId) StringCopy(gStringVar1, gContestMons[r6].nickname); StringCopy(gStringVar2, gMoveNames[eContestantStatus[r6].currMove]); StringExpandPlaceholders(gStringVar4, gText_0827E58A); - Contest_StartTextPrinter(gStringVar4, 1); + Contest_StartTextPrinter(gStringVar4, TRUE); gTasks[taskId].data[0] = 34; return; case 34: @@ -2265,10 +2269,10 @@ static void sub_80D8B38(u8 taskId) gTasks[taskId].data[0] = 21; return; case 31: - sub_80DB89C(); + ContestClearGeneralTextWindow(); StringCopy(gStringVar1, gContestMons[r6].nickname); StringExpandPlaceholders(gStringVar4, gText_0827D56F); - Contest_StartTextPrinter(gStringVar4, 1); + Contest_StartTextPrinter(gStringVar4, TRUE); gTasks[taskId].data[0] = 32; return; case 32: @@ -2342,17 +2346,17 @@ static void sub_80DA198(u8 taskId) eContest.unk1920B_2 = 1; if (sub_80DA8A4()) { - sub_80DB944(); + RankContestants(); sub_80DBA18(); } taskId2 = CreateTask(sub_80FCC88, 0); SetTaskFuncWithFollowupFunc(taskId2, sub_80FCC88, sub_80DA110); - sub_80DBF68(); + ContestPrintLinkStandby(); gTasks[taskId].data[0] = 1; } else { - sub_80DB944(); + RankContestants(); sub_80DBA18(); gTasks[taskId].data[0] = 2; } @@ -2437,10 +2441,10 @@ static void sub_80DA3CC(u8 taskId) { u8 r4 = eContestantStatus[gContestPlayerMonIndex].attentionLevel; - sub_80DB89C(); + ContestClearGeneralTextWindow(); StringCopy(gStringVar1, gContestMons[gContestPlayerMonIndex].nickname); StringExpandPlaceholders(gStringVar4, gUnknown_08587D90[r4]); - Contest_StartTextPrinter(gStringVar4, 1); + Contest_StartTextPrinter(gStringVar4, TRUE); gTasks[taskId].data[0]++; } else @@ -2520,7 +2524,7 @@ static void sub_80DA5E8(u8 taskId) for (i = 0; i < 4; i++) gUnknown_02039F10[i] = eContestantStatus[i].pointTotal; sub_80DBD18(); - sub_80DB89C(); + ContestClearGeneralTextWindow(); if (!(gLinkContestFlags & LINK_CONTEST_FLAG_IS_LINK)) BravoTrainerPokemonProfile_BeforeInterview1(eContestantStatus[gContestPlayerMonIndex].prevMove); else @@ -2531,7 +2535,7 @@ static void sub_80DA5E8(u8 taskId) } gContestRngValue = gRngValue; StringExpandPlaceholders(gStringVar4, gText_0827D597); - Contest_StartTextPrinter(gStringVar4, 1); + Contest_StartTextPrinter(gStringVar4, TRUE); gTasks[taskId].data[2] = 0; gTasks[taskId].func = sub_80DA6B4; } @@ -2554,7 +2558,7 @@ static void sub_80DA700(u8 taskId) gBattle_BG1_Y -= 7; if ((s16)gBattle_BG1_Y < 0) gBattle_BG1_Y = 0; - if (gBattle_BG1_Y == 0) // Why cast? + if (gBattle_BG1_Y == 0) { gTasks[taskId].func = sub_80DA740; gTasks[taskId].data[0] = 0; @@ -2584,7 +2588,7 @@ static void sub_80DA7A0(u8 taskId) SetTaskFuncWithFollowupFunc(taskId2, sub_80FCACC, sub_80DA7EC); gTasks[taskId].func = TaskDummy1; - sub_80DBF68(); + ContestPrintLinkStandby(); sub_80DC490(FALSE); } @@ -2614,7 +2618,7 @@ static void sub_80DA874(void) EnableBothScriptContexts(); } -static void sub_80DA884(void) +static void TryPutPlayerLast(void) { if (!(gLinkContestFlags & LINK_CONTEST_FLAG_IS_LINK)) gContestPlayerMonIndex = 3; @@ -2712,7 +2716,7 @@ void sub_80DAB8C(u8 contestType, u8 rank) bool8 r7 = FALSE; const u8 * r3; - sub_80DA884(); + TryPutPlayerLast(); if (FlagGet(FLAG_SYS_GAME_CLEAR) && !(gLinkContestFlags & LINK_CONTEST_FLAG_IS_LINK)) r7 = TRUE; @@ -3008,11 +3012,13 @@ bool8 IsSpeciesNotUnown(u16 species) return TRUE; } -static void sub_80DB2BC(void) +// The contestant info windows and general-purpose text box are drawn on one half, while +// the moves and move description windows are drawn on another screen. Only the first 32 * 20 +// tiles are actually drawn on screen. +static void SwapMoveDescAndContestTilemaps(void) { - - CpuCopy16(gContestResources->contestBgTilemaps[0], gContestResources->contestBgTilemaps[0] + 0x500, 0x280); - CpuCopy16(gContestResources->contestBgTilemaps[2], gContestResources->contestBgTilemaps[2] + 0x500, 0x280); + CpuCopy16(gContestResources->contestBgTilemaps[0], gContestResources->contestBgTilemaps[0] + 0x500, 32 * 20); + CpuCopy16(gContestResources->contestBgTilemaps[2], gContestResources->contestBgTilemaps[2] + 0x500, 32 * 20); } static u16 sub_80DB2EC(u16 a0, u8 a1) @@ -3038,12 +3044,13 @@ static u16 sub_80DB2EC(u16 a0, u8 a1) return var; } -static void prints_contest_move_description(u16 a) +static void PrintContestMoveDescription(u16 a) { u8 category; u16 categoryTile; u8 numHearts; + // The contest category icon is implemented as a 5x2 group of tiles. category = gContestMoves[a].contestCategory; if (category == CONTEST_CATEGORY_COOL) categoryTile = 0x4040; @@ -3065,7 +3072,9 @@ static void prints_contest_move_description(u16 a) numHearts = gContestEffects[gContestMoves[a].effect].appeal / 10; if (numHearts > 8) numHearts = 8; + // Filled-in hearts ContestBG_FillBoxWithTile(0, 0x5035, 0x15, 0x1f, 0x08, 0x01, 0x11); + // Empty hearts ContestBG_FillBoxWithTile(0, 0x5012, 0x15, 0x1f, numHearts, 0x01, 0x11); if (gContestEffects[gContestMoves[a].effect].jam == 0xFF) @@ -3074,12 +3083,14 @@ static void prints_contest_move_description(u16 a) numHearts = gContestEffects[gContestMoves[a].effect].jam / 10; if (numHearts > 8) numHearts = 8; + // Filled-in hearts ContestBG_FillBoxWithTile(0, 0x5036, 0x15, 0x20, 0x08, 0x01, 0x11); + // Empty hearts ContestBG_FillBoxWithTile(0, 0x5014, 0x15, 0x20, numHearts, 0x01, 0x11); - FillWindowPixelBuffer(10, PIXEL_FILL(0)); - Contest_PrintTextToBg0WindowStd(10, gContestEffectDescriptionPointers[gContestMoves[a].effect]); - Contest_PrintTextToBg0WindowStd(9, gText_Slash); + FillWindowPixelBuffer(CONTEST_WINDOW_MOVE_DESCRIPTION, PIXEL_FILL(0)); + Contest_PrintTextToBg0WindowStd(CONTEST_WINDOW_MOVE_DESCRIPTION, gContestEffectDescriptionPointers[gContestMoves[a].effect]); + Contest_PrintTextToBg0WindowStd(CONTEST_WINDOW_SLASH, gText_Slash); } static void sub_80DB4E0(u16 move, u8 b) @@ -3147,7 +3158,7 @@ static void sub_80DB69C(void) s32 i; s32 r6; - for (i = 0; i < 4; i++) + for (i = 0; i < CONTESTANT_COUNT; i++) { u8 r4 = gContestantTurnOrder[i] * 5 + 2; u16 r5 = sub_80DB5B0(); @@ -3218,32 +3229,32 @@ static void sub_80DB884(void) sub_80DB798(i); } -static void sub_80DB89C(void) +static void ContestClearGeneralTextWindow(void) { - FillWindowPixelBuffer(4, PIXEL_FILL(0)); - CopyWindowToVram(4, 2); + FillWindowPixelBuffer(CONTEST_WINDOW_GENERAL_TEXT, PIXEL_FILL(0)); + CopyWindowToVram(CONTEST_WINDOW_GENERAL_TEXT, 2); Contest_SetBgCopyFlags(0); } -static u16 GetChosenMove(u8 a) +static u16 GetChosenMove(u8 contestant) { - if (Contest_IsMonsTurnDisabled(a)) + if (Contest_IsMonsTurnDisabled(contestant)) return 0; - if (a == gContestPlayerMonIndex) + if (contestant == gContestPlayerMonIndex) { - return gContestMons[a].moves[eContest.playerMoveChoice]; + return gContestMons[contestant].moves[eContest.playerMoveChoice]; } else { u8 moveChoice; - ContestAI_ResetAI(a); + ContestAI_ResetAI(contestant); moveChoice = ContestAI_GetActionToUse(); - return gContestMons[a].moves[moveChoice]; + return gContestMons[contestant].moves[moveChoice]; } } -static void sub_80DB918(void) +static void GetAllChosenMoves(void) { s32 i; @@ -3251,13 +3262,13 @@ static void sub_80DB918(void) eContestantStatus[i].currMove = GetChosenMove(i); } -static void sub_80DB944(void) +static void RankContestants(void) { s32 i; s32 j; - s16 arr[4]; + s16 arr[CONTESTANT_COUNT]; - for (i = 0; i < 4; i++) + for (i = 0; i < CONTESTANT_COUNT; i++) { eContestantStatus[i].pointTotal += eContestantStatus[i].appeal2; arr[i] = eContestantStatus[i].pointTotal; @@ -3287,9 +3298,9 @@ static void sub_80DB944(void) // be [1, 2, 2, 4]. The pokemon with a point total of 80 stop looking // when they see the first 80 in the array, so they both share the '2' // rank. - for (i = 0; i < 4; i++) + for (i = 0; i < CONTESTANT_COUNT; i++) { - for (j = 0; j < 4; j++) + for (j = 0; j < CONTESTANT_COUNT; j++) { if (eContestantStatus[i].pointTotal == arr[j]) { @@ -3306,7 +3317,7 @@ static void sub_80DBA18(void) { s32 i; - for (i = 0; i < 4; i++) + for (i = 0; i < CONTESTANT_COUNT; i++) { u8 attentionLevel; @@ -3327,9 +3338,9 @@ static void sub_80DBA18(void) } } -static bool8 sub_80DBA68(u8 a) +static bool8 ContestantCanUseTurn(u8 contestant) { - if (eContestantStatus[a].numTurnsSkipped != 0 || eContestantStatus[a].noMoreTurns) + if (eContestantStatus[contestant].numTurnsSkipped != 0 || eContestantStatus[contestant].noMoreTurns) return FALSE; else return TRUE; @@ -3339,7 +3350,7 @@ static void sub_80DBAA0(void) { s32 i; - for (i = 0; i < 4; i++) + for (i = 0; i < CONTESTANT_COUNT; i++) { eContestantStatus[i].appeal2 = 0; eContestantStatus[i].appeal1 = 0; @@ -3352,7 +3363,7 @@ static void sub_80DBAA0(void) eContestantStatus[i].immune = 0; eContestantStatus[i].moreEasilyStartled = 0; eContestantStatus[i].usedRepeatableMove = 0; - eContestantStatus[i].nervous = 0; + eContestantStatus[i].nervous = FALSE; eContestantStatus[i].effectStringId = CONTEST_STRING_NONE; eContestantStatus[i].effectStringId2 = CONTEST_STRING_NONE; eContestantStatus[i].conditionMod = 0; @@ -3372,11 +3383,11 @@ static void sub_80DBAA0(void) } eContestantStatus[i].overrideCategoryExcitementMod = 0; } - for (i = 0; i < 4; i++) + for (i = 0; i < CONTESTANT_COUNT; i++) { eContestantStatus[i].prevMove = eContestantStatus[i].currMove; - eContest.unk19220[eContest.turnNumber][i] = eContestantStatus[i].currMove; - eContest.unk19248[eContest.turnNumber][i] = Contest_GetMoveExcitement(eContestantStatus[i].currMove); + eContest.moveHistory[eContest.turnNumber][i] = eContestantStatus[i].currMove; + eContest.excitementHistory[eContest.turnNumber][i] = Contest_GetMoveExcitement(eContestantStatus[i].currMove); eContestantStatus[i].currMove = MOVE_NONE; } eContestResources10.excitementFrozen = 0; @@ -3390,41 +3401,41 @@ bool8 Contest_IsMonsTurnDisabled(u8 a) return FALSE; } -static void sub_80DBCE0(u8 a) +static void sub_80DBCE0(u8 contestant) { - gUnknown_02039F18[a] = sub_80DBD34(a); - gUnknown_02039F08[a] = gContestMonConditions[a] + gUnknown_02039F18[a]; + gUnknown_02039F18[contestant] = sub_80DBD34(contestant); + gUnknown_02039F08[contestant] = gContestMonConditions[contestant] + gUnknown_02039F18[contestant]; } static void sub_80DBD18(void) { s32 i; - for (i = 0; i < 4; i++) + for (i = 0; i < CONTESTANT_COUNT; i++) sub_80DBCE0(i); DetermineFinalStandings(); } -static s16 sub_80DBD34(u8 a) +static s16 sub_80DBD34(u8 contestant) { - return gUnknown_02039F10[a] * 2; + return gUnknown_02039F10[contestant] * 2; } static void DetermineFinalStandings(void) { - u16 sp0[4] = {0}; - struct UnknownContestStruct6 sp8[4]; + u16 randomOrdering[CONTESTANT_COUNT] = {0}; + struct UnknownContestStruct6 sp8[CONTESTANT_COUNT]; s32 i; s32 j; - for (i = 0; i < 4; i++) + for (i = 0; i < CONTESTANT_COUNT; i++) { s32 r2; - sp0[i] = Random(); + randomOrdering[i] = Random(); for (r2 = 0; r2 < i; r2++) { - if (sp0[i] == sp0[r2]) + if (randomOrdering[i] == randomOrdering[r2]) { i--; break; @@ -3432,11 +3443,11 @@ static void DetermineFinalStandings(void) } } - for (i = 0; i < 4; i++) + for (i = 0; i < CONTESTANT_COUNT; i++) { sp8[i].unk0 = gUnknown_02039F08[i]; sp8[i].unk4 = gContestMonConditions[i]; - sp8[i].unk8 = sp0[i]; + sp8[i].unk8 = randomOrdering[i]; sp8[i].unkC = i; } @@ -3466,11 +3477,11 @@ static void DetermineFinalStandings(void) } } - for (i = 0; i < 4; i++) + for (i = 0; i < CONTESTANT_COUNT; i++) gContestFinalStandings[sp8[i].unkC] = i; } -void sub_80DBED4(void) +void SaveLinkContestResults(void) { if ((gLinkContestFlags & LINK_CONTEST_FLAG_IS_LINK)) { @@ -3500,11 +3511,11 @@ static bool8 sub_80DBF30(s32 a, s32 b, struct UnknownContestStruct6 *c) return retVal; } -static void sub_80DBF68(void) +static void ContestPrintLinkStandby(void) { gBattle_BG0_Y = 0; gBattle_BG2_Y = 0; - sub_80DB89C(); + ContestClearGeneralTextWindow(); Contest_StartTextPrinter(gText_LinkStandby4, 0); } @@ -3662,7 +3673,7 @@ static void sub_80DC2BC(void) s32 i; LoadSpriteSheet(&gUnknown_08587A74); - for (i = 0; i < 4; i++) + for (i = 0; i < CONTESTANT_COUNT; i++) { u8 y = gUnknown_08587A6C[gContestantTurnOrder[i]]; @@ -3670,20 +3681,20 @@ static void sub_80DC2BC(void) } } -static void sub_80DC308(u8 a) +static void sub_80DC308(u8 contestant) { u8 spriteId; s16 r5; - gContestResources->field_14[a].unk2_0 = 1; - spriteId = gContestResources->field_14[a].unk0; - r5 = eContestantStatus[a].pointTotal / 10 * 2; + gContestResources->field_14[contestant].unk2_0 = 1; + spriteId = gContestResources->field_14[contestant].unk0; + r5 = eContestantStatus[contestant].pointTotal / 10 * 2; if (r5 > 56) r5 = 56; else if (r5 < 0) r5 = 0; gSprites[spriteId].invisible = FALSE; - gSprites[spriteId].data[0] = a; + gSprites[spriteId].data[0] = contestant; gSprites[spriteId].data[1] = r5; if (gSprites[spriteId].data[1] > gSprites[spriteId].pos2.x) gSprites[spriteId].data[2] = 1; @@ -3696,7 +3707,7 @@ static void sub_80DC3AC(void) { s32 i; - for (i = 0; i < 4; i++) + for (i = 0; i < CONTESTANT_COUNT; i++) sub_80DC308(i); } @@ -3704,12 +3715,12 @@ static bool8 sub_80DC3C4(void) { s32 i; - for (i = 0; i < 4; i++) + for (i = 0; i < CONTESTANT_COUNT; i++) { if (gContestResources->field_14[i].unk2_0) break; } - if (i == 4) + if (i == CONTESTANT_COUNT) return TRUE; else return FALSE; @@ -3732,7 +3743,7 @@ static void sub_80DC44C(void) { s32 i; - for (i = 0; i < 4; i++) + for (i = 0; i < CONTESTANT_COUNT; i++) gSprites[gContestResources->field_14[i].unk0].pos1.y = gUnknown_08587A6C[gContestantTurnOrder[i]]; } @@ -3757,7 +3768,7 @@ static void sub_80DC4F0(void) s32 i; LoadSpritePalette(&gUnknown_08587B08); - for (i = 0; i < 4; i++) + for (i = 0; i < CONTESTANT_COUNT; i++) { LoadCompressedSpriteSheet(&gUnknown_08587AE8[i]); gContestResources->field_14[i].unk1 = CreateSprite(&gSpriteTemplate_8587B18[i], @@ -3786,7 +3797,7 @@ static void sub_80DC5E8(void) u8 taskId = CreateTask(sub_80DC728, 30); eContest.unk19211 = taskId; - for (i = 0; i < 4; i++) + for (i = 0; i < CONTESTANT_COUNT; i++) gTasks[taskId].data[i * 4] = 0xFF; } @@ -3812,7 +3823,7 @@ static void sub_80DC6A4(u8 taskId) { gTasks[eContest.unk19211].data[r4 * 4 + 0] = 0xFF; gTasks[eContest.unk19211].data[r4 * 4 + 1] = 0; - BlendPalette((eContest.prevTurnOrder[r4] + CONTESTANT_WINDOW_START) * 16 + 6, 2, 0, RGB(31, 31, 18)); + BlendPalette((eContest.prevTurnOrder[r4] + MOVE_WINDOWS_START) * 16 + 6, 2, 0, RGB(31, 31, 18)); DestroyTask(taskId); } } @@ -3821,7 +3832,7 @@ static void sub_80DC728(u8 taskId) { u8 i; - for (i = 0; i < 4; i++) + for (i = 0; i < CONTESTANT_COUNT; i++) { u8 r3 = i * 4; @@ -3837,7 +3848,7 @@ static void sub_80DC728(u8 taskId) gTasks[taskId].data[r3 + 1] ^= 1; BlendPalette( - (eContest.prevTurnOrder[i] + CONTESTANT_WINDOW_START) * 16 + 6, + (eContest.prevTurnOrder[i] + MOVE_WINDOWS_START) * 16 + 6, 2, gTasks[taskId].data[r3 + 0], RGB(31, 31, 18)); @@ -3850,14 +3861,14 @@ static void sub_80DC7EC(void) s32 i; eContest.unk19212 = CreateTask(sub_80DC8D0, 30); - for (i = 0; i < 4; i++) + for (i = 0; i < CONTESTANT_COUNT; i++) sub_80DC81C(i); } -static void sub_80DC81C(u8 a) +static void sub_80DC81C(u8 contestant) { - gTasks[eContest.unk19212].data[a * 4 + 0] = 0xFF; - gTasks[eContest.unk19212].data[a * 4 + 1] = 0; + gTasks[eContest.unk19212].data[contestant * 4 + 0] = 0xFF; + gTasks[eContest.unk19212].data[contestant * 4 + 1] = 0; } static void sub_80DC864(void) @@ -3868,22 +3879,22 @@ static void sub_80DC864(void) sub_80DC87C(i); } -static void sub_80DC87C(u8 a) +static void sub_80DC87C(u8 contestant) { - u32 var; - u32 r0; + u32 windowId1; + u32 windowId2; - sub_80DC81C(a); + sub_80DC81C(contestant); - r0 = a + CONTESTANT_WINDOW_START; + windowId1 = contestant + MOVE_WINDOWS_START; DmaCopy16Defvars(3, - gPlttBufferUnfaded + r0 * 16 + 10, - gPlttBufferFaded + r0 * 16 + 10, + gPlttBufferUnfaded + windowId1 * 16 + 10, + gPlttBufferFaded + windowId1 * 16 + 10, 2); - var = (a + CONTESTANT_WINDOW_START) * 16 + 12 + a; + windowId2 = (contestant + MOVE_WINDOWS_START) * 16 + 12 + contestant; DmaCopy16Defvars(3, - gPlttBufferUnfaded + var, - gPlttBufferFaded + var, + gPlttBufferUnfaded + windowId2, + gPlttBufferFaded + windowId2, 2); } @@ -3891,7 +3902,7 @@ static void sub_80DC8D0(u8 taskId) { u8 i; - for (i = 0; i < 4; i++) + for (i = 0; i < CONTESTANT_COUNT; i++) { u8 r3 = i * 4; @@ -3910,41 +3921,41 @@ static void sub_80DC8D0(u8 taskId) || gTasks[taskId].data[r3 + 0] == 0) gTasks[taskId].data[r3 + 1] ^= 1; - BlendPalette((i + CONTESTANT_WINDOW_START) * 16 + 10, 1, gTasks[taskId].data[r3 + 0], RGB(31, 31, 18)); - BlendPalette((i + CONTESTANT_WINDOW_START) * 16 + 12 + i, 1, gTasks[taskId].data[r3 + 0], RGB(31, 31, 18)); + BlendPalette((i + MOVE_WINDOWS_START) * 16 + 10, 1, gTasks[taskId].data[r3 + 0], RGB(31, 31, 18)); + BlendPalette((i + MOVE_WINDOWS_START) * 16 + 12 + i, 1, gTasks[taskId].data[r3 + 0], RGB(31, 31, 18)); } } } } -static void sub_80DC9B4(u8 a) +static void sub_80DC9B4(u8 contestant) { - if (eContestantStatus[a].hasJudgesAttention) - sub_80DC630(a); + if (eContestantStatus[contestant].hasJudgesAttention) + sub_80DC630(contestant); else - sub_80DC674(a); + sub_80DC674(contestant); } -static u8 sub_80DC9EC(u8 a) +static u8 sub_80DC9EC(u8 contestant) { u8 spriteId1, spriteId2; - u8 x = gContestantTurnOrder[a] * 40 + 32; + u8 x = gContestantTurnOrder[contestant] * 40 + 32; - LoadCompressedSpriteSheet(&sUnknown_08589904[a]); - LoadSpritePalette(&sUnknown_08589924[a]); - spriteId1 = CreateSprite(&gSpriteTemplate_858998C[a], 184, x, 29); - spriteId2 = CreateSprite(&gSpriteTemplate_858998C[a], 248, x, 29); + LoadCompressedSpriteSheet(&sUnknown_08589904[contestant]); + LoadSpritePalette(&sUnknown_08589924[contestant]); + spriteId1 = CreateSprite(&gSpriteTemplate_858998C[contestant], 184, x, 29); + spriteId2 = CreateSprite(&gSpriteTemplate_858998C[contestant], 248, x, 29); gSprites[spriteId2].oam.tileNum += 64; CopySpriteTiles(0, 3, (void *)VRAM, - (u16 *)(BG_SCREEN_ADDR(28) + gContestantTurnOrder[a] * 5 * 64 + 0x26), + (u16 *)(BG_SCREEN_ADDR(28) + gContestantTurnOrder[contestant] * 5 * 64 + 0x26), gContestResources->field_34); CopySpriteTiles(0, 3, (void *)VRAM, - (u16 *)(BG_SCREEN_ADDR(28) + gContestantTurnOrder[a] * 5 * 64 + 0x36), + (u16 *)(BG_SCREEN_ADDR(28) + gContestantTurnOrder[contestant] * 5 * 64 + 0x36), gContestResources->field_38); CpuFill32(0, gContestResources->field_34 + 0x500, 0x300); @@ -3963,8 +3974,8 @@ static u8 sub_80DC9EC(u8 a) gSprites[spriteId1].data[0] = spriteId2; gSprites[spriteId2].data[0] = spriteId1; - gSprites[spriteId1].data[1] = a; - gSprites[spriteId2].data[1] = a; + gSprites[spriteId1].data[1] = contestant; + gSprites[spriteId2].data[1] = contestant; return spriteId1; } @@ -4040,7 +4051,7 @@ static void ContestDebugTogglePointTotal(void) if(eContestDebugMode == CONTEST_DEBUG_MODE_OFF) { DrawContestantWindowText(); - sub_80DB2BC(); + SwapMoveDescAndContestTilemaps(); } else { @@ -4070,9 +4081,9 @@ static void ContestDebugDoPrint(void) // // case CONTEST_DEBUG_MODE_PRINT_POINT_TOTAL: default: - for (i = 0; i < 4; i++) + for (i = 0; i < CONTESTANT_COUNT; i++) FillWindowPixelBuffer(i, PIXEL_FILL(0)); - for (i = 0; i < 4; i++) + for (i = 0; i < CONTESTANT_COUNT; i++) { value = eContestantStatus[i].pointTotal; txtPtr = text; @@ -4084,7 +4095,7 @@ static void ContestDebugDoPrint(void) ConvertIntToDecimalStringN(txtPtr, value, STR_CONV_MODE_LEFT_ALIGN, 4); Contest_PrintTextToBg0WindowAt(gContestantTurnOrder[i], text, 55, 1, 7); } - for (i = 0; i < 4; i++) + for (i = 0; i < CONTESTANT_COUNT; i++) { value = eContestantStatus[i].appeal2; txtPtr = text; @@ -4096,7 +4107,7 @@ static void ContestDebugDoPrint(void) ConvertIntToDecimalStringN(txtPtr, value, STR_CONV_MODE_LEFT_ALIGN, 4); Contest_PrintTextToBg0WindowAt(gContestantTurnOrder[i], text, 5, 1, 7); } - sub_80DB2BC(); + SwapMoveDescAndContestTilemaps(); break; } } @@ -4222,8 +4233,8 @@ static void DrawContestantWindows(void) for (i = 0; i < CONTESTANT_COUNT; i++) { - s32 windowId = i + CONTESTANT_WINDOW_START; - LoadPalette(eUnknownHeap1A004.cachedWindowPalettes[windowId], (gContestantTurnOrder[i] + CONTESTANT_WINDOW_START) * 16, sizeof(eUnknownHeap1A004.cachedWindowPalettes[0])); + s32 windowId = i + MOVE_WINDOWS_START; + LoadPalette(eUnknownHeap1A004.cachedWindowPalettes[windowId], (gContestantTurnOrder[i] + MOVE_WINDOWS_START) * 16, sizeof(eUnknownHeap1A004.cachedWindowPalettes[0])); } DrawContestantWindowText(); } @@ -4238,7 +4249,7 @@ static void sub_80DD080(u8 contestant) eContestantStatus[contestant].appeal2 = 0; eContestantStatus[contestant].appeal1 = 0; - r8 = sub_80DBA68(contestant); + r8 = ContestantCanUseTurn(contestant); if (!r8) return; @@ -4333,7 +4344,7 @@ static void sub_80DD080(u8 contestant) } rnd = Random() % 3; - for (i = 0; i < 4; i++) + for (i = 0; i < CONTESTANT_COUNT; i++) { if (i != contestant) { @@ -4384,13 +4395,13 @@ static void sub_80DD45C(u8 contestant, u8 stringId) else StringCopy(gStringVar3, gText_Contest_Fear); StringExpandPlaceholders(gStringVar4, gUnknown_08587E10[stringId]); - sub_80DB89C(); + ContestClearGeneralTextWindow(); Contest_StartTextPrinter(gStringVar4, 1); } void MakeContestantNervous(u8 p) { - eContestantStatus[p].nervous = 1; + eContestantStatus[p].nervous = TRUE; eContestantStatus[p].currMove = MOVE_NONE; } @@ -4828,7 +4839,7 @@ static void sub_80DE12C(void) u8 r8 = 1; u8 r9 = 0x11; - for (r7 = 0; r7 < 4; r7++) + for (r7 = 0; r7 < CONTESTANT_COUNT; r7++) { if (eContestResources8.unnervedPokes[r7] != 0 && !Contest_IsMonsTurnDisabled(r7)) { @@ -4843,9 +4854,9 @@ static void sub_80DE12C(void) } } -bool8 sub_80DE1E8(u8 a) +bool8 sub_80DE1E8(u8 contestant) { - if (eContestantStatus[a].disappointedRepeat || eContestantStatus[a].nervous) + if (eContestantStatus[contestant].disappointedRepeat || eContestantStatus[contestant].nervous) return FALSE; else return TRUE; @@ -4894,7 +4905,7 @@ static void sub_80DE350(void) s32 i; u16 bg1Cnt; - RequestDma3Fill(0,(void *)(BG_CHAR_ADDR(2)), 0x2000, 0x1); + RequestDma3Fill(0,(void *)(BG_CHAR_ADDR(2)), 0x2000, 1); CpuFill32(0, gContestResources->contestBgTilemaps[1], 0x1000); Contest_SetBgCopyFlags(1); bg1Cnt = GetGpuReg(REG_OFFSET_BG1CNT); @@ -4908,7 +4919,7 @@ static void sub_80DE350(void) gBattle_BG1_X = 0; gBattle_BG1_Y = 0; - for (i = 0; i < 4; i++) + for (i = 0; i < CONTESTANT_COUNT; i++) { gSprites[gContestResources->field_14[i].unk0].oam.priority = 0; gSprites[gContestResources->field_14[i].unk1].oam.priority = 0; @@ -4963,7 +4974,7 @@ static void sub_80DE4A8(u8 taskId) sub_80DBAA0(); taskId2 = CreateTask(sub_80FCC88, 0); SetTaskFuncWithFollowupFunc(taskId2, sub_80FCC88, sub_80DA110); - sub_80DBF68(); + ContestPrintLinkStandby(); gTasks[taskId].data[0] = 2; } else @@ -4978,7 +4989,7 @@ static void sub_80DE4A8(u8 taskId) break; case 3: sub_80DB884(); - sub_80DB2BC(); + SwapMoveDescAndContestTilemaps(); gTasks[taskId].data[0] = 0; gTasks[taskId].func = sub_80DE5F4; break; @@ -5041,7 +5052,7 @@ static void sub_80DE69C(u8 a) s32 i; u8 taskId; - for (i = 0; i < 4; i++) + for (i = 0; i < CONTESTANT_COUNT; i++) { gSprites[gContestResources->field_14[i].unk0].oam.matrixNum = AllocOamMatrix(); gSprites[gContestResources->field_14[i].unk0].oam.affineMode = 1; @@ -5065,10 +5076,10 @@ static void sub_80DE794(u8 taskId) { if ((u8)gTasks[taskId].data[0] == 1) { - for (i = 0; i < 4; i++) + for (i = 0; i < CONTESTANT_COUNT; i++) gSprites[gContestResources->field_14[i].unk0].invisible = TRUE; } - for (i = 0; i < 4; i++) + for (i = 0; i < CONTESTANT_COUNT; i++) FreeSpriteOamMatrix(&gSprites[gContestResources->field_14[i].unk0]); eContest.unk1920B_1 = 0; DestroyTask(taskId); @@ -5098,7 +5109,7 @@ static void sub_80DE864(u8 a) memset(&gContestResources->field_18->species, 0, 0x14); ClearBattleAnimationVars(); - for (i = 0; i < 4; i++) + for (i = 0; i < CONTESTANT_COUNT; i++) gBattleMonForms[i] = 0; switch (move) { @@ -5141,17 +5152,17 @@ static void sub_80DE864(u8 a) static void sub_80DE9B0(u8 unused) { - memset(&gContestResources->field_18->species, 0, 0x14); + memset(gContestResources->field_18, 0, sizeof(struct ContestStruct_field_18)); if (eContest.unk1925E != 0) eContest.unk1925E--; } -static void sub_80DE9DC(u8 a) +static void sub_80DE9DC(u8 contestant) { - gContestResources->field_18->unk5 = a; - gContestResources->field_18->species = SanitizeSpecies(gContestMons[a].species); - gContestResources->field_18->unk8 = gContestMons[a].personality; - gContestResources->field_18->unkC = gContestMons[a].otId; + gContestResources->field_18->unk5 = contestant; + gContestResources->field_18->species = SanitizeSpecies(gContestMons[contestant].species); + gContestResources->field_18->unk8 = gContestMons[contestant].personality; + gContestResources->field_18->unkC = gContestMons[contestant].otId; } static void sub_80DEA20(void) @@ -5299,7 +5310,7 @@ void ResetContestLinkResults(void) s32 i; s32 j; - for(i = 0; i < 5; i++) + for(i = 0; i < CONTEST_CATEGORIES_COUNT; i++) for(j = 0; j < 4; j++) gSaveBlock2Ptr->contestLinkResults[i][j] = 0; } @@ -5309,7 +5320,7 @@ bool8 sub_80DEDA8(u8 a) s32 i; u8 r7 = Random() % 3; - for (i = 0; i < 3; i++) + for (i = 0; i < CONTESTANT_COUNT - 1; i++) { if (gContestFinalStandings[i] == 0) break; @@ -5492,7 +5503,7 @@ static void sub_80DF250(void) } gContestResources->field_1c[r1].unkD |= 1; - for (i = 0; i < 4; i++) + for (i = 0; i < CONTESTANT_COUNT; i++) { if (i != var_38 && gUnknown_02039F08[var_38] - gUnknown_02039F08[i] <= 50) gContestResources->field_1c[i].unkD |= 4; @@ -5500,7 +5511,7 @@ static void sub_80DF250(void) if (!gContestResources->field_1c[i].unkE_2) gContestResources->field_1c[i].unkD |= 8; - for (j = 0; j < 4; j++) + for (j = 0; j < CONTESTANT_COUNT; j++) { if (gContestMonConditions[i] < gContestMonConditions[j]) break; @@ -5593,7 +5604,7 @@ static void sub_80DF4F8(void) return; r7 = 0; - for (i = 0; i < 4; i++) + for (i = 0; i < CONTESTANT_COUNT; i++) { if (gContestFinalStandings[i] == 0) r7 = i; @@ -5601,7 +5612,7 @@ static void sub_80DF4F8(void) r9 = 0; r10 = 0; - for (i = 0; i < 4; i++) + for (i = 0; i < CONTESTANT_COUNT; i++) { if (gContestMonConditions[r7] < gContestMonConditions[i]) r9++; @@ -5645,7 +5656,7 @@ static void sub_80DF4F8(void) } r5 = 1; - for (; i < 4; i++) + for (; i < CONTESTANT_COUNT; i++) { if (i != r7) { @@ -5697,7 +5708,7 @@ void ContestDebugToggleBitfields(bool8 showUnkD) if (eContestDebugMode == CONTEST_DEBUG_MODE_OFF) { DrawContestantWindowText(); - sub_80DB2BC(); + SwapMoveDescAndContestTilemaps(); } else { @@ -5765,7 +5776,7 @@ static void ContestDebugPrintBitStrings(void) Contest_PrintTextToBg0WindowAt(gContestantTurnOrder[i], text1 + j, 55, 1, 7); } } - sub_80DB2BC(); + SwapMoveDescAndContestTilemaps(); } static u8 sub_80DF940(u8 *nickname) diff --git a/src/contest_ai.c b/src/contest_ai.c index 42a09259e..723c503ab 100644 --- a/src/contest_ai.c +++ b/src/contest_ai.c @@ -1402,7 +1402,7 @@ static void ContestAICmd_unk_63(void) { u8 var = sub_81563B0(gAIScriptPtr[1]); u8 var2 = gAIScriptPtr[2]; - u16 move = eContest.unk19220[var2][var]; + u16 move = eContest.moveHistory[var2][var]; eContestAI.scriptResult = gContestMoves[move].effect; gAIScriptPtr += 3; @@ -1452,7 +1452,7 @@ static void ContestAICmd_unk_68(void) { u8 var = sub_81563B0(gAIScriptPtr[1]); u8 var2 = gAIScriptPtr[2]; - s8 result = eContest.unk19248[var2][var]; + s8 result = eContest.excitementHistory[var2][var]; eContestAI.scriptResult = result; gAIScriptPtr += 3; @@ -1502,7 +1502,7 @@ static void ContestAICmd_unk_6D(void) { u8 var = sub_81563B0(gAIScriptPtr[1]); u8 var2 = gAIScriptPtr[2]; - u16 move = eContest.unk19220[var2][var]; + u16 move = eContest.moveHistory[var2][var]; eContestAI.scriptResult = gContestEffects[gContestMoves[move].effect].effectType; gAIScriptPtr += 3; diff --git a/src/contest_link_80F57C4.c b/src/contest_link_80F57C4.c index 274893cc0..4ae7c1ac2 100644 --- a/src/contest_link_80F57C4.c +++ b/src/contest_link_80F57C4.c @@ -356,7 +356,7 @@ static void sub_80F5CE4(u8 taskId) switch (gTasks[taskId].data[0]) { case 0: - sub_80DBED4(); + SaveLinkContestResults(); if (gContestFinalStandings[gContestPlayerMonIndex] == 0) { IncrementGameStat(GAME_STAT_WON_LINK_CONTEST); From 83b6210dcb1e8344a3d5ec67073fb96af927e8bc Mon Sep 17 00:00:00 2001 From: Phlosioneer Date: Wed, 3 Apr 2019 20:56:47 -0400 Subject: [PATCH 09/22] Forgot to add asm files --- asm/dodrio_berry_picking.s | 2 +- asm/pokemon_jump.s | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/asm/dodrio_berry_picking.s b/asm/dodrio_berry_picking.s index 505f305b9..94139338a 100755 --- a/asm/dodrio_berry_picking.s +++ b/asm/dodrio_berry_picking.s @@ -377,7 +377,7 @@ _08024C5A: ldrb r0, [r0] cmp r0, 0 beq _08024D20 - bl sub_800E0E8 + bl LoadWirelessStatusIndicatorSprite movs r0, 0 movs r1, 0 bl CreateWirelessStatusIndicatorSprite diff --git a/asm/pokemon_jump.s b/asm/pokemon_jump.s index e9aa9089d..00b656635 100755 --- a/asm/pokemon_jump.s +++ b/asm/pokemon_jump.s @@ -416,7 +416,7 @@ _0802AD0C: ldr r0, [r4] adds r0, 0xA4 bl sub_802D074 - bl sub_800E0E8 + bl LoadWirelessStatusIndicatorSprite movs r0, 0 movs r1, 0 bl CreateWirelessStatusIndicatorSprite From 50da52c29b3ee075c43f9832aaa4a7b8848e0ec7 Mon Sep 17 00:00:00 2001 From: Phlosioneer Date: Thu, 4 Apr 2019 16:00:25 -0400 Subject: [PATCH 10/22] Fix utf8 errors in contest_effect's comments --- src/contest_effect.c | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/src/contest_effect.c b/src/contest_effect.c index 7a7f3e3a5..d6b06c3ba 100644 --- a/src/contest_effect.c +++ b/src/contest_effect.c @@ -129,7 +129,7 @@ static void ContestEffect_UserLessEasilyStartled(void) SetContestantEffectStringID(eContestResources8.contestant,CONTEST_STRING_STOPPED_CARING); } -// Slightly startles the POK�MON in front. +// Slightly startles the POKéMON in front. static void ContestEffect_StartleFrontMon(void) { u8 idx = 0; @@ -176,7 +176,7 @@ static void ContestEffect_StartlePrevMons(void) SetContestantEffectStringID(eContestResources8.contestant, CONTEST_STRING_ATTEMPT_STARTLE); } -// Startles the POK�MON that appealed before the user. +// Startles the POKéMON that appealed before the user. static void ContestEffect_StartlePrevMon2(void) { u8 rval = Random() % 10; @@ -193,7 +193,7 @@ static void ContestEffect_StartlePrevMon2(void) ContestEffect_StartleFrontMon(); } -// Startles all POK�MON that appealed before the user. +// Startles all POKéMON that appealed before the user. static void ContestEffect_StartlePrevMons2(void) { u8 numStartled = 0; @@ -239,7 +239,7 @@ static void ContestEffect_StartlePrevMons2(void) SetContestantEffectStringID2(eContestResources8.contestant, CONTEST_STRING_MESSED_UP2); } -// Shifts the JUDGE�s attention from others. +// Shifts the JUDGE's attention from others. static void ContestEffect_ShiftJudgeAttention(void) { bool32 hitAny = FALSE; @@ -269,7 +269,7 @@ static void ContestEffect_ShiftJudgeAttention(void) } } -// Startles the POK�MON that has the JUDGE�s attention. +// Startles the POKéMON that has the JUDGE's attention. static void ContestEffect_StartleMonWithJudgesAttention(void) { u8 numStartled = 0; @@ -307,7 +307,7 @@ static void ContestEffect_JamsOthersButMissOneTurn(void) SetContestantEffectStringID(eContestResources8.contestant, CONTEST_STRING_ATTEMPT_STARTLE); } -// Startles POK�MON that made a same-type appeal. +// Startles POKéMON that made a same-type appeal. static void ContestEffect_StartleMonsSameTypeAppeal(void) { u16 move = eContestantStatus[eContestResources8.contestant].currMove; @@ -315,42 +315,42 @@ static void ContestEffect_StartleMonsSameTypeAppeal(void) SetContestantEffectStringID(eContestResources8.contestant, CONTEST_STRING_ATTEMPT_STARTLE); } -// Badly startles POK�MON that made COOL appeals. +// Badly startles POKéMON that made COOL appeals. static void ContestEffect_StartleMonsCoolAppeal(void) { JamByMoveCategory(CONTEST_CATEGORY_COOL); SetContestantEffectStringID(eContestResources8.contestant, CONTEST_STRING_ATTEMPT_STARTLE); } -// Badly startles POK�MON that made BEAUTY appeals. +// Badly startles POKéMON that made BEAUTY appeals. static void ContestEffect_StartleMonsBeautyAppeal(void) { JamByMoveCategory(CONTEST_CATEGORY_BEAUTY); SetContestantEffectStringID(eContestResources8.contestant, CONTEST_STRING_ATTEMPT_STARTLE); } -// Badly startles POK�MON that made CUTE appeals. +// Badly startles POKéMON that made CUTE appeals. static void ContestEffect_StartleMonsCuteAppeal(void) { JamByMoveCategory(CONTEST_CATEGORY_CUTE); SetContestantEffectStringID(eContestResources8.contestant, CONTEST_STRING_ATTEMPT_STARTLE); } -// Badly startles POK�MON that made SMART appeals. +// Badly startles POKéMON that made SMART appeals. static void ContestEffect_StartleMonsSmartAppeal(void) { JamByMoveCategory(CONTEST_CATEGORY_SMART); SetContestantEffectStringID(eContestResources8.contestant, CONTEST_STRING_ATTEMPT_STARTLE); } -// Badly startles POK�MON that made TOUGH appeals. +// Badly startles POKéMON that made TOUGH appeals. static void ContestEffect_StartleMonsToughAppeal(void) { JamByMoveCategory(CONTEST_CATEGORY_TOUGH); SetContestantEffectStringID(eContestResources8.contestant, CONTEST_STRING_ATTEMPT_STARTLE); } -// Makes one POK�MON after the user nervous. +// Makes one POKéMON after the user nervous. static void ContestEffect_MakeFollowingMonNervous(void) { bool32 hitAny = FALSE; @@ -382,7 +382,7 @@ static void ContestEffect_MakeFollowingMonNervous(void) SetContestantEffectStringID2(eContestResources8.contestant, CONTEST_STRING_MESSED_UP2); } -// Makes all POK�MON after the user nervous. +// Makes all POKéMON after the user nervous. static void ContestEffect_MakeFollowingMonsNervous(void) { u8 numUnnerved = 0; @@ -489,7 +489,7 @@ static void ContestEffect_WorsenConditionOfPrevMons(void) SetContestantEffectStringID2(eContestResources8.contestant, CONTEST_STRING_IGNORED); } -// Badly startles POK�MON in good condition. +// Badly startles POKéMON in good condition. static void ContestEffect_BadlyStartlesMonsInGoodCondition(void) { u8 numHit = 0; @@ -605,7 +605,7 @@ static void ContestEffect_BetterWhenLater(void) SetContestantEffectStringID(eContestResources8.contestant, CONTEST_STRING_APPEAL_EXCELLENTLY); } -// The appeal�s quality varies depending on its timing. +// The appeal's quality varies depending on its timing. static void ContestEffect_QualityDependsOnTiming(void) { u8 rval = Random() % 10; @@ -718,7 +718,7 @@ static void ContestEffect_AffectedByPrevAppeal(void) } } -// Ups the user�s condition. Helps prevent nervousness. +// Ups the user's condition. Helps prevent nervousness. static void ContestEffect_ImproveConditionPreventNervousness(void) { if (eContestantStatus[eContestResources8.contestant].condition < 30) @@ -733,7 +733,7 @@ static void ContestEffect_ImproveConditionPreventNervousness(void) } } -// The appeal works well if the user�s condition is good. +// The appeal works well if the user's condition is good. static void ContestEffect_BetterWithGoodCondition(void) { eContestantStatus[eContestResources8.contestant].appealTripleCondition = TRUE; @@ -827,7 +827,7 @@ static void ContestEffect_NextAppealLater(void) } } -// Makes the next turn�s order more easily scrambled. +// Makes the next turn's order more easily scrambled. static void ContestEffect_MakeScramblingTurnOrderEasier(void) { // dummied out? @@ -888,7 +888,7 @@ static void ContestEffect_ExciteAudienceInAnyContest(void) } } -// Badly startles all POK�MON that made good appeals. +// Badly startles all POKéMON that made good appeals. static void ContestEffect_BadlyStartleMonsWithGoodAppeals(void) { int i; From 1360b3a477f1107785900cd0c4e73ebf018f058c Mon Sep 17 00:00:00 2001 From: Phlosioneer Date: Thu, 4 Apr 2019 17:05:46 -0400 Subject: [PATCH 11/22] RGB Constants --- asm/dodrio_berry_picking.s | 2 +- asm/pokemon_jump.s | 2 +- include/contest.h | 17 ++++++++------ include/link.h | 2 +- src/battle_controller_player.c | 9 ++++---- src/battle_controller_safari.c | 3 ++- src/battle_controller_wally.c | 3 ++- src/battle_factory_screen.c | 12 +++++----- src/battle_main.c | 6 ++--- src/battle_records.c | 5 +++-- src/battle_script_commands.c | 7 +++--- src/battle_transition.c | 17 +++++++------- src/berry_blender.c | 15 +++++++------ src/berry_crush.c | 2 +- src/berry_tag_screen.c | 5 +++-- src/clear_save_data_screen.c | 2 +- src/contest.c | 37 +++++++++++++++++-------------- src/contest_link_80F57C4.c | 2 +- src/diploma.c | 5 +++-- src/easy_chat.c | 7 +++--- src/egg_hatch.c | 9 ++++---- src/evolution_graphics.c | 11 ++++----- src/evolution_scene.c | 27 +++++++++++----------- src/field_region_map.c | 5 +++-- src/hof_pc.c | 3 ++- src/item_menu.c | 5 +++-- src/link.c | 3 ++- src/link_rfu.c | 2 +- src/mail.c | 5 +++-- src/main_menu.c | 10 ++++----- src/mevent_801BAAC.c | 17 +++++++------- src/mystery_event_menu.c | 5 +++-- src/naming_screen.c | 5 +++-- src/option_menu.c | 5 +++-- src/overworld.c | 4 ++-- src/pokeblock.c | 5 +++-- src/pokeblock_feed.c | 5 +++-- src/pokedex.c | 2 +- src/rayquaza_scene.c | 20 ++++++++--------- src/recorded_battle.c | 3 ++- src/region_map.c | 5 +++-- src/reset_rtc_screen.c | 5 +++-- src/reshow_battle_screen.c | 2 +- src/save_failed_screen.c | 2 +- src/script_pokemon_util_80F87D8.c | 2 +- src/shop.c | 2 +- src/slot_machine.c | 4 ++-- src/start_menu.c | 5 +++-- src/starter_choose.c | 3 ++- src/title_screen.c | 10 ++++----- src/trade.c | 6 ++--- src/trainer_card.c | 3 ++- src/union_room.c | 12 +++++----- src/union_room_chat.c | 2 +- src/unk_transition.c | 3 ++- src/wallclock.c | 7 +++--- 56 files changed, 211 insertions(+), 173 deletions(-) diff --git a/asm/dodrio_berry_picking.s b/asm/dodrio_berry_picking.s index 94139338a..f5d3ea0c4 100755 --- a/asm/dodrio_berry_picking.s +++ b/asm/dodrio_berry_picking.s @@ -377,7 +377,7 @@ _08024C5A: ldrb r0, [r0] cmp r0, 0 beq _08024D20 - bl LoadWirelessStatusIndicatorSprite + bl LoadWirelessStatusIndicatorSpriteGfx movs r0, 0 movs r1, 0 bl CreateWirelessStatusIndicatorSprite diff --git a/asm/pokemon_jump.s b/asm/pokemon_jump.s index 00b656635..1cd92d94e 100755 --- a/asm/pokemon_jump.s +++ b/asm/pokemon_jump.s @@ -416,7 +416,7 @@ _0802AD0C: ldr r0, [r4] adds r0, 0xA4 bl sub_802D074 - bl LoadWirelessStatusIndicatorSprite + bl LoadWirelessStatusIndicatorSpriteGfx movs r0, 0 movs r1, 0 bl CreateWirelessStatusIndicatorSprite diff --git a/include/contest.h b/include/contest.h index 1fba54885..a4e209bcb 100644 --- a/include/contest.h +++ b/include/contest.h @@ -7,13 +7,16 @@ #define APPLAUSE_METER_SIZE 5 #define CONTEST_TURN_COUNT 5 -#define CONTEST_DEBUG_MODE_OFF 0 -// Prints the totalPoints value for each contestant. -#define CONTEST_DEBUG_MODE_PRINT_POINT_TOTAL 1 -// Prints the ContestResourcesField1C::unk_C value as a bitstring for each contestant. -#define CONTEST_DEBUG_MODE_PRINT_UNK_C 2 -// Prints the ContestResourcesField1C::unk_D value as a bitstring for each contestant. -#define CONTEST_DEBUG_MODE_PRINT_UNK_D 3 +enum +{ + CONTEST_DEBUG_MODE_OFF, + // Prints the totalPoints value for each contestant. + CONTEST_DEBUG_MODE_PRINT_POINT_TOTAL, + // Prints the ContestResourcesField1C::unk_C value as a bitstring for each contestant. + CONTEST_DEBUG_MODE_PRINT_UNK_C, + // Prints the ContestResourcesField1C::unk_D value as a bitstring for each contestant. + CONTEST_DEBUG_MODE_PRINT_UNK_D +}; #define LINK_CONTEST_FLAG_IS_LINK (1 << 0) #define LINK_CONTEST_FLAG_IS_WIRELESS (1 << 1) diff --git a/include/link.h b/include/link.h index a50991762..c14084066 100644 --- a/include/link.h +++ b/include/link.h @@ -235,7 +235,7 @@ void LinkVSync(void); void Timer3Intr(void); void SerialCB(void); bool32 InUnionRoom(void); -void LoadWirelessStatusIndicatorSprite(void); +void LoadWirelessStatusIndicatorSpriteGfx(void); bool8 IsLinkTaskFinished(void); void CreateWirelessStatusIndicatorSprite(u8, u8); void sub_800ADF8(void); diff --git a/src/battle_controller_player.c b/src/battle_controller_player.c index b377ecf64..c4e2face2 100644 --- a/src/battle_controller_player.c +++ b/src/battle_controller_player.c @@ -33,6 +33,7 @@ #include "constants/moves.h" #include "constants/songs.h" #include "constants/trainers.h" +#include "constants/rgb.h" extern struct MusicPlayerInfo gMPlayInfo_BGM; @@ -2408,7 +2409,7 @@ static void PlayerHandleFaintAnimation(void) static void PlayerHandlePaletteFade(void) { - BeginNormalPaletteFade(0xFFFFFFFF, 2, 0, 16, 0); + BeginNormalPaletteFade(0xFFFFFFFF, 2, 0, 16, RGB_BLACK); PlayerBufferExecCompleted(); } @@ -2630,7 +2631,7 @@ static void PlayerHandleChooseItem(void) { s32 i; - BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, 0); + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, RGB_BLACK); gBattlerControllerFuncs[gActiveBattler] = OpenBagAndChooseItem; gBattlerInMenuId = gActiveBattler; @@ -2657,7 +2658,7 @@ static void PlayerHandleChoosePokemon(void) *(&gBattleStruct->battlerPreventingSwitchout) = gBattleBufferA[gActiveBattler][1] >> 4; *(&gBattleStruct->field_8B) = gBattleBufferA[gActiveBattler][2]; *(&gBattleStruct->abilityPreventingSwitchout) = gBattleBufferA[gActiveBattler][3]; - BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, 0); + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, RGB_BLACK); gBattlerControllerFuncs[gActiveBattler] = OpenPartyMenuToChooseMon; gBattlerInMenuId = gActiveBattler; } @@ -2666,7 +2667,7 @@ static void PlayerHandleChoosePokemon(void) static void PlayerHandleCmd23(void) { BattleStopLowHpSound(); - BeginNormalPaletteFade(0xFFFFFFFF, 2, 0, 16, 0); + BeginNormalPaletteFade(0xFFFFFFFF, 2, 0, 16, RGB_BLACK); PlayerBufferExecCompleted(); } diff --git a/src/battle_controller_safari.c b/src/battle_controller_safari.c index e9da16252..2c6514daa 100644 --- a/src/battle_controller_safari.c +++ b/src/battle_controller_safari.c @@ -22,6 +22,7 @@ #include "window.h" #include "constants/battle_anim.h" #include "constants/songs.h" +#include "constants/rgb.h" extern const struct CompressedSpritePalette gTrainerBackPicPaletteTable[]; @@ -473,7 +474,7 @@ static void SafariHandleChooseItem(void) { s32 i; - BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, 0); + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, RGB_BLACK); gBattlerControllerFuncs[gActiveBattler] = SafariOpenPokeblockCase; gBattlerInMenuId = gActiveBattler; } diff --git a/src/battle_controller_wally.c b/src/battle_controller_wally.c index f1b783b21..c131df0ca 100644 --- a/src/battle_controller_wally.c +++ b/src/battle_controller_wally.c @@ -30,6 +30,7 @@ #include "constants/moves.h" #include "constants/songs.h" #include "constants/trainers.h" +#include "constants/rgb.h" extern const struct CompressedSpritePalette gTrainerBackPicPaletteTable[]; @@ -1244,7 +1245,7 @@ static void WallyHandleChooseMove(void) static void WallyHandleChooseItem(void) { - BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, 0); + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, RGB_BLACK); gBattlerControllerFuncs[gActiveBattler] = OpenBagAfterPaletteFade; gBattlerInMenuId = gActiveBattler; } diff --git a/src/battle_factory_screen.c b/src/battle_factory_screen.c index 367c1401f..126e3d5e6 100644 --- a/src/battle_factory_screen.c +++ b/src/battle_factory_screen.c @@ -1166,7 +1166,7 @@ static void CB2_InitSelectScreen(void) ShowBg(0); ShowBg(1); SetVBlankCallback(Select_VblankCb); - BeginNormalPaletteFade(0xFFFFFFFF, 0, 0x10, 0, 0); + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0x10, 0, RGB_BLACK); SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJ_ON | DISPCNT_BG0_ON | DISPCNT_BG1_ON | DISPCNT_OBJ_1D_MAP); if (sFactorySelectScreen->fromSummaryScreen == TRUE) { @@ -1405,7 +1405,7 @@ static void Task_FromSelectScreenToSummaryScreen(u8 taskId) { case 6: gPlttBufferUnfaded[228] = gPlttBufferFaded[228]; - BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, 0); + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, RGB_BLACK); gTasks[taskId].data[0] = 7; break; case 7: @@ -1442,7 +1442,7 @@ static void Task_CloseSelectionScreen(u8 taskId) switch (gTasks[taskId].data[0]) { case 0: - BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, 0); + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, RGB_BLACK); gTasks[taskId].data[0]++; break; case 1: @@ -2274,7 +2274,7 @@ static void Task_FromSwapScreenToSummaryScreen(u8 taskId) switch (gTasks[taskId].data[0]) { case 6: - BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, 0); + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, RGB_BLACK); gTasks[taskId].data[0] = 7; break; case 7: @@ -2327,7 +2327,7 @@ static void Task_CloseSwapScreen(u8 taskId) gTasks[taskId].data[0]++; break; case 2: - BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, 0); + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, RGB_BLACK); gTasks[taskId].data[0]++; break; case 3: @@ -3218,7 +3218,7 @@ static void CB2_InitSwapScreen(void) gMain.state++; break; case 14: - BeginNormalPaletteFade(0xFFFFFFFF, 0, 0x10, 0, 0); + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0x10, 0, RGB_BLACK); SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJ_ON | DISPCNT_OBJ_1D_MAP); ShowBg(0); ShowBg(1); diff --git a/src/battle_main.c b/src/battle_main.c index 7a215384e..5bcbc6f59 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -981,7 +981,7 @@ static void CB2_HandleStartBattle(void) gBattleCommunication[MULTIUSE_STATE] = 1; } if (gWirelessCommType) - LoadWirelessStatusIndicatorSprite(); + LoadWirelessStatusIndicatorSpriteGfx(); break; case 1: if (gBattleTypeFlags & BATTLE_TYPE_LINK) @@ -1176,7 +1176,7 @@ static void CB2_HandleStartMultiPartnerBattle(void) gBattleCommunication[MULTIUSE_STATE] = 1; } if (gWirelessCommType) - LoadWirelessStatusIndicatorSprite(); + LoadWirelessStatusIndicatorSpriteGfx(); // fall through case 1: if (gBattleTypeFlags & BATTLE_TYPE_LINK) @@ -1576,7 +1576,7 @@ static void CB2_HandleStartMultiBattle(void) gBattleCommunication[MULTIUSE_STATE] = 1; } if (gWirelessCommType) - LoadWirelessStatusIndicatorSprite(); + LoadWirelessStatusIndicatorSpriteGfx(); break; case 1: if (gBattleTypeFlags & BATTLE_TYPE_LINK) diff --git a/src/battle_records.c b/src/battle_records.c index fdd915d07..3d4cabcb0 100644 --- a/src/battle_records.c +++ b/src/battle_records.c @@ -22,6 +22,7 @@ #include "gpu_regs.h" #include "constants/game_stat.h" #include "trainer_hill.h" +#include "constants/rgb.h" // this file's functions static void Task_CloseTrainerHillRecordsOnButton(u8 taskId); @@ -364,7 +365,7 @@ static void Task_CloseTrainerHillRecordsOnButton(u8 taskId) static void Task_BeginPaletteFade(u8 taskId) { - BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, 0); + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, RGB_BLACK); gTasks[taskId].func = Task_ExitTrainerHillRecords; } @@ -511,7 +512,7 @@ static void CB2_ShowTrainerHillRecords(void) gMain.state++; break; case 6: - BeginNormalPaletteFade(0xFFFFFFFF, 0, 0x10, 0, 0); + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0x10, 0, RGB_BLACK); gMain.state++; break; case 7: diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 0a0c34ad2..e9db4a1ad 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -50,6 +50,7 @@ #include "pokemon_summary_screen.h" #include "pokenav.h" #include "menu_specialized.h" +#include "constants/rgb.h" extern struct MusicPlayerInfo gMPlayInfo_BGM; @@ -5695,7 +5696,7 @@ static void atk5A_yesnoboxlearnmove(void) if (gBattleCommunication[1] == 0) { HandleBattleWindow(0x18, 0x8, 0x1D, 0xD, WINDOW_CLEAR); - BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, 0); + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, RGB_BLACK); gBattleScripting.learnMoveState++; } else @@ -10274,7 +10275,7 @@ static void atkF2_displaydexinfo(void) switch (gBattleCommunication[0]) { case 0: - BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, 0); + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, RGB_BLACK); gBattleCommunication[0]++; break; case 1: @@ -10305,7 +10306,7 @@ static void atkF2_displaydexinfo(void) case 4: if (!IsDma3ManagerBusyWithBgCopy()) { - BeginNormalPaletteFade(0xFFFF, 0, 0x10, 0, 0); + BeginNormalPaletteFade(0xFFFF, 0, 0x10, 0, RGB_BLACK); ShowBg(0); ShowBg(3); gBattleCommunication[0]++; diff --git a/src/battle_transition.c b/src/battle_transition.c index df6180d19..6ad1f57d6 100644 --- a/src/battle_transition.c +++ b/src/battle_transition.c @@ -23,6 +23,7 @@ #include "constants/field_effects.h" #include "constants/songs.h" #include "constants/trainers.h" +#include "constants/rgb.h" struct TransitionData { @@ -1076,7 +1077,7 @@ static bool8 Phase2_Blur_Func2(struct Task *task) { task->tData1 = 4; if (++task->tData2 == 10) - BeginNormalPaletteFade(0xFFFFFFFF, -1, 0, 0x10, 0); + BeginNormalPaletteFade(0xFFFFFFFF, -1, 0, 0x10, RGB_BLACK); SetGpuReg(REG_OFFSET_MOSAIC, (task->tData2 & 15) * 17); if (task->tData2 > 14) task->tState++; @@ -1103,7 +1104,7 @@ static bool8 Phase2_Swirl_Func1(struct Task *task) { sub_8149F08(); ScanlineEffect_Clear(); - BeginNormalPaletteFade(0xFFFFFFFF, 4, 0, 0x10, 0); + BeginNormalPaletteFade(0xFFFFFFFF, 4, 0, 0x10, RGB_BLACK); sub_8149F98(gScanlineEffectRegBuffers[1], sTransitionStructPtr->field_14, 0, 2, 0, 160); SetVBlankCallback(VBlankCB_Phase2_Swirl); @@ -1158,7 +1159,7 @@ static bool8 Phase2_Shuffle_Func1(struct Task *task) sub_8149F08(); ScanlineEffect_Clear(); - BeginNormalPaletteFade(0xFFFFFFFF, 4, 0, 0x10, 0); + BeginNormalPaletteFade(0xFFFFFFFF, 4, 0, 0x10, RGB_BLACK); memset(gScanlineEffectRegBuffers[1], sTransitionStructPtr->field_16, 0x140); SetVBlankCallback(VBlankCB_Phase2_Shuffle); @@ -1461,7 +1462,7 @@ static bool8 Phase2_Kyogre_Func5(struct Task *task) static bool8 Phase2_WeatherDuo_Func6(struct Task *task) { - BeginNormalPaletteFade(0xFFFF8000, 1, 0, 0x10, 0); + BeginNormalPaletteFade(0xFFFF8000, 1, 0, 0x10, RGB_BLACK); task->tState++; return FALSE; } @@ -1546,7 +1547,7 @@ static bool8 Phase2_FramesCountdown(struct Task *task) static bool8 Phase2_WeatherTrio_Func1(struct Task *task) { - BeginNormalPaletteFade(0x0000FFFF, 1, 0, 0x10, 0); + BeginNormalPaletteFade(0x0000FFFF, 1, 0, 0x10, RGB_BLACK); task->tState++; return FALSE; } @@ -1969,7 +1970,7 @@ static bool8 Phase2_Ripple_Func2(struct Task *task) if (++task->tData3 == 81) { task->tData4++; - BeginNormalPaletteFade(0xFFFFFFFF, -2, 0, 0x10, 0); + BeginNormalPaletteFade(0xFFFFFFFF, -2, 0, 0x10, RGB_BLACK); } if (task->tData4 != 0 && !gPaletteFade.active) @@ -3159,7 +3160,7 @@ static bool8 Phase2_Rayquaza_Func6(struct Task *task) { task->tState++; task->tData1 = 0; - BeginNormalPaletteFade(0xFFFF8000, 2, 0, 0x10, 0); + BeginNormalPaletteFade(0xFFFF8000, 2, 0, 0x10, RGB_BLACK); } return FALSE; @@ -3978,7 +3979,7 @@ static bool8 Phase2_30_Func4(struct Task *task) if (++task->tData3 == 101) { task->tData4++; - BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, 0); + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, RGB_BLACK); } if (task->tData4 != 0 && !gPaletteFade.active) diff --git a/src/berry_blender.c b/src/berry_blender.c index 70b10b764..c1c664c1a 100644 --- a/src/berry_blender.c +++ b/src/berry_blender.c @@ -36,6 +36,7 @@ #include "new_game.h" #include "save.h" #include "link.h" +#include "constants/rgb.h" #define BLENDER_SCORE_BEST 0 #define BLENDER_SCORE_GOOD 1 @@ -996,7 +997,7 @@ static void sub_807FAC8(void) } if (gReceivedRemoteLinkPlayers != 0 && gWirelessCommType) { - LoadWirelessStatusIndicatorSprite(); + LoadWirelessStatusIndicatorSpriteGfx(); CreateWirelessStatusIndicatorSprite(0, 0); } SetVBlankCallback(VBlankCB0_BerryBlender); @@ -1004,7 +1005,7 @@ static void sub_807FAC8(void) } break; case 2: - BeginNormalPaletteFade(0xFFFFFFFF, 0, 0x10, 0, 0); + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0x10, 0, RGB_BLACK); sub_8082D28(); sBerryBlenderData->mainState++; break; @@ -1018,7 +1019,7 @@ static void sub_807FAC8(void) sBerryBlenderData->mainState++; break; case 5: - BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, 0); + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, RGB_BLACK); sBerryBlenderData->mainState++; break; case 6: @@ -1202,13 +1203,13 @@ static void sub_8080018(void) } if (gReceivedRemoteLinkPlayers != 0 && gWirelessCommType) { - LoadWirelessStatusIndicatorSprite(); + LoadWirelessStatusIndicatorSpriteGfx(); CreateWirelessStatusIndicatorSprite(0, 0); } sBerryBlenderData->mainState++; break; case 3: - BeginNormalPaletteFade(0xFFFFFFFF, 0, 0x10, 0, 0); + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0x10, 0, RGB_BLACK); sBerryBlenderData->mainState++; break; case 4: @@ -1534,7 +1535,7 @@ static void sub_80808D4(void) sBerryBlenderData->mainState++; break; case 3: - BeginNormalPaletteFade(0xFFFFFFFF, 0, 0x10, 0, 0); + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0x10, 0, RGB_BLACK); sBerryBlenderData->mainState++; sBerryBlenderData->framesToWait = 0; break; @@ -2700,7 +2701,7 @@ static void CB2_HandlePlayerLinkPlayAgainChoice(void) case 9: if (IsLinkTaskFinished()) { - BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, 0); + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, RGB_BLACK); sBerryBlenderData->gameEndState++; } break; diff --git a/src/berry_crush.c b/src/berry_crush.c index 404a9b70c..8429e39cc 100755 --- a/src/berry_crush.c +++ b/src/berry_crush.c @@ -511,7 +511,7 @@ int sub_802104C(void) CopyBgTilemapBufferToVram(3); break; case 8: - LoadWirelessStatusIndicatorSprite(); + LoadWirelessStatusIndicatorSpriteGfx(); CreateWirelessStatusIndicatorSprite(0, 0); sub_8022730(var0); SetGpuReg(REG_OFFSET_BG1VOFS, -gSpriteCoordOffsetY); diff --git a/src/berry_tag_screen.c b/src/berry_tag_screen.c index a7cf4daf2..d0f89ab8a 100644 --- a/src/berry_tag_screen.c +++ b/src/berry_tag_screen.c @@ -28,6 +28,7 @@ #include "item_menu_icons.h" #include "decompress.h" #include "international_string_util.h" +#include "constants/rgb.h" // There are 4 windows used in berry tag screen. enum @@ -279,7 +280,7 @@ static bool8 InitBerryTagScreen(void) gMain.state++; break; case 15: - BeginNormalPaletteFade(0xFFFFFFFF, 0, 0x10, 0, 0); + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0x10, 0, RGB_BLACK); gPaletteFade.bufferTransferDisabled = 0; gMain.state++; break; @@ -513,7 +514,7 @@ static void DestroyFlavorCircleSprites(void) static void PrepareToCloseBerryTagScreen(u8 taskId) { PlaySE(SE_SELECT); - BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, 0); + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, RGB_BLACK); gTasks[taskId].func = Task_CloseBerryTagScreen; } diff --git a/src/clear_save_data_screen.c b/src/clear_save_data_screen.c index c1d6930c7..b91506352 100644 --- a/src/clear_save_data_screen.c +++ b/src/clear_save_data_screen.c @@ -163,7 +163,7 @@ static bool8 SetupClearSaveDataScreen(void) ShowBg(3); SetGpuReg(REG_OFFSET_BLDCNT, 0); InitClearSaveDataScreenWindows(); - BeginNormalPaletteFade(0x0000FFFF, 0, 0x10, 0, 0xFFFF); + BeginNormalPaletteFade(0x0000FFFF, 0, 0x10, 0, RGB_WHITEALPHA); EnableInterrupts(INTR_FLAG_VBLANK); SetVBlankCallback(VBlankCB); gMain.state = 1; diff --git a/src/contest.c b/src/contest.c index 9ca99c146..2d13dd581 100644 --- a/src/contest.c +++ b/src/contest.c @@ -51,21 +51,24 @@ // Contestant 0 will use palette color 10, contestant 1 will use color 11, etc. #define CONTESTANT_TEXT_COLOR_START 10 +enum +{ // The "{Pokemon Name} / {Trainer Name}" windows. -#define CONTEST_WINDOW_CONTESTANT0_NAME 0 -#define CONTEST_WINDOW_CONTESTANT1_NAME 1 -#define CONTEST_WINDOW_CONTESTANT2_NAME 2 -#define CONTEST_WINDOW_CONTESTANT3_NAME 3 -#define CONTEST_WINDOW_GENERAL_TEXT 4 -// The available moves, from top to bottom -#define CONTEST_WINDOW_MOVE0 5 -#define CONTEST_WINDOW_MOVE1 6 -#define CONTEST_WINDOW_MOVE2 7 -#define CONTEST_WINDOW_MOVE3 8 -// The small "/" character between the move category and the -// appeal/jam display -#define CONTEST_WINDOW_SLASH 9 -#define CONTEST_WINDOW_MOVE_DESCRIPTION 10 + CONTEST_WINDOW_CONTESTANT0_NAME, + CONTEST_WINDOW_CONTESTANT1_NAME, + CONTEST_WINDOW_CONTESTANT2_NAME, + CONTEST_WINDOW_CONTESTANT3_NAME, + CONTEST_WINDOW_GENERAL_TEXT, + // The available moves, from top to bottom + CONTEST_WINDOW_MOVE0, + CONTEST_WINDOW_MOVE1, + CONTEST_WINDOW_MOVE2, + CONTEST_WINDOW_MOVE3, + // The small "/" character between the move category and the + // appeal/jam display + CONTEST_WINDOW_SLASH, + CONTEST_WINDOW_MOVE_DESCRIPTION +}; #define MOVE_WINDOWS_START CONTEST_WINDOW_MOVE0 @@ -1098,7 +1101,7 @@ void CB2_StartContest(void) SetMainCallback2(CB2_ContestMain); if (gLinkContestFlags & LINK_CONTEST_FLAG_IS_WIRELESS) { - LoadWirelessStatusIndicatorSprite(); + LoadWirelessStatusIndicatorSpriteGfx(); CreateWirelessStatusIndicatorSprite(8, 8); } break; @@ -2576,7 +2579,7 @@ static void sub_80DA740(u8 taskId) } else { - BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, 0); + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK); gTasks[taskId].func = sub_80DA830; } } @@ -2595,7 +2598,7 @@ static void sub_80DA7A0(u8 taskId) static void sub_80DA7EC(u8 taskId) { DestroyTask(taskId); - BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, 0); + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK); gTasks[eContest.mainTaskId].func = sub_80DA830; } diff --git a/src/contest_link_80F57C4.c b/src/contest_link_80F57C4.c index 4ae7c1ac2..0c16d8c81 100644 --- a/src/contest_link_80F57C4.c +++ b/src/contest_link_80F57C4.c @@ -909,7 +909,7 @@ static void sub_80F6AE8(void) if (gLinkContestFlags & LINK_CONTEST_FLAG_IS_WIRELESS) { - LoadWirelessStatusIndicatorSprite(); + LoadWirelessStatusIndicatorSpriteGfx(); CreateWirelessStatusIndicatorSprite(8, 8); gSprites[gWirelessStatusIndicatorSpriteId].subpriority = 1; sheet = LoadSpriteSheet(&gUnknown_0858D8E0); diff --git a/src/diploma.c b/src/diploma.c index 2113b09ed..92c7df703 100644 --- a/src/diploma.c +++ b/src/diploma.c @@ -14,6 +14,7 @@ #include "overworld.h" #include "menu.h" #include "pokedex.h" +#include "constants/rgb.h" extern const u8 gText_DexNational[]; extern const u8 gText_DexHoenn[]; @@ -83,7 +84,7 @@ void CB2_ShowDiploma(void) CopyBgTilemapBufferToVram(1); DisplayDiplomaText(); BlendPalettes(-1, 16, 0); - BeginNormalPaletteFade(0xFFFFFFFF, 0, 16, 0, 0); + BeginNormalPaletteFade(0xFFFFFFFF, 0, 16, 0, RGB_BLACK); EnableInterrupts(1); SetVBlankCallback(VBlankCB); SetMainCallback2(MainCB2); @@ -108,7 +109,7 @@ static void Task_DiplomaWaitForKeyPress(u8 taskId) { if (gMain.newKeys & (A_BUTTON | B_BUTTON)) { - BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, 0); + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK); gTasks[taskId].func = Task_DiplomaFadeOut; } } diff --git a/src/easy_chat.c b/src/easy_chat.c index 1cb7b0fe8..239ada5df 100644 --- a/src/easy_chat.c +++ b/src/easy_chat.c @@ -32,6 +32,7 @@ #include "constants/flags.h" #include "constants/songs.h" #include "constants/species.h" +#include "constants/rgb.h" #define EZCHAT_TASK_STATE 0 #define EZCHAT_TASK_TYPE 1 @@ -1139,20 +1140,20 @@ static void sub_811A2FC(u8 taskId) case 0: SetVBlankCallback(VBlankCallback_EasyChatScreen); BlendPalettes(0xFFFFFFFF, 16, 0); - BeginNormalPaletteFade(0xFFFFFFFF, -1, 16, 0, 0); + BeginNormalPaletteFade(0xFFFFFFFF, -1, 16, 0, RGB_BLACK); data[EZCHAT_TASK_STATE] = 5; break; case 1: v0 = sub_811AAAC(); if (sub_811A88C(v0)) { - BeginNormalPaletteFade(0xFFFFFFFF, -2, 0, 16, 0); + BeginNormalPaletteFade(0xFFFFFFFF, -2, 0, 16, RGB_BLACK); data[EZCHAT_TASK_STATE] = 3; data[EZCHAT_TASK_UNK06] = v0; } else if (v0 == 0x18) { - BeginNormalPaletteFade(0xFFFFFFFF, -1, 0, 16, 0); + BeginNormalPaletteFade(0xFFFFFFFF, -1, 0, 16, RGB_BLACK); data[EZCHAT_TASK_STATE] = 4; } else if (v0 != 0) diff --git a/src/egg_hatch.c b/src/egg_hatch.c index fc559e001..dd1ae6bcd 100644 --- a/src/egg_hatch.c +++ b/src/egg_hatch.c @@ -34,6 +34,7 @@ #include "pokemon_storage_system.h" #include "field_screen_effect.h" #include "battle.h" // to get rid of later +#include "constants/rgb.h" struct EggHatchData { @@ -596,7 +597,7 @@ static void CB2_EggHatch_1(void) switch (sEggHatchData->CB2_state) { case 0: - BeginNormalPaletteFade(0xFFFFFFFF, 0, 0x10, 0, 0); + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0x10, 0, RGB_BLACK); sEggHatchData->eggSpriteID = CreateSprite(&sSpriteTemplate_EggHatch, 120, 75, 5); ShowBg(0); ShowBg(1); @@ -679,7 +680,7 @@ static void CB2_EggHatch_1(void) } break; case 11: - BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, 0); + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, RGB_BLACK); sEggHatchData->CB2_state++; break; case 12: @@ -789,7 +790,7 @@ static void SpriteCB_Egg_4(struct Sprite* sprite) { s16 i; if (sprite->data[0] == 0) - BeginNormalPaletteFade(0xFFFFFFFF, -1, 0, 0x10, 0xFFFF); + BeginNormalPaletteFade(0xFFFFFFFF, -1, 0, 0x10, RGB_WHITEALPHA); if (sprite->data[0] < 4u) { for (i = 0; i <= 3; i++) @@ -813,7 +814,7 @@ static void SpriteCB_Egg_5(struct Sprite* sprite) StartSpriteAffineAnim(&gSprites[sEggHatchData->pokeSpriteID], 1); } if (sprite->data[0] == 8) - BeginNormalPaletteFade(0xFFFFFFFF, -1, 0x10, 0, 0xFFFF); + BeginNormalPaletteFade(0xFFFFFFFF, -1, 0x10, 0, RGB_WHITEALPHA); if (sprite->data[0] <= 9) gSprites[sEggHatchData->pokeSpriteID].pos1.y -= 1; if (sprite->data[0] > 40) diff --git a/src/evolution_graphics.c b/src/evolution_graphics.c index e36d47c2b..816929f8b 100644 --- a/src/evolution_graphics.c +++ b/src/evolution_graphics.c @@ -8,6 +8,7 @@ #include "sound.h" #include "constants/songs.h" #include "palette.h" +#include "constants/rgb.h" // this file's functions static void EvoSparkle_DummySpriteCb(struct Sprite* sprite); @@ -268,7 +269,7 @@ static void EvoTask_BeginPreSet1_FadeAndPlaySE(u8 taskID) { SetEvoSparklesMatrices(); gTasks[taskID].tFrameCounter = 0; - BeginNormalPaletteFade(3 << gTasks[taskID].data[1], 0xA, 0, 0x10, 0x7FFF); + BeginNormalPaletteFade(3 << gTasks[taskID].data[1], 0xA, 0, 0x10, RGB_WHITE); gTasks[taskID].func = EvoTask_CreatePreEvoSparkleSet1; PlaySE(SE_W025); } @@ -386,7 +387,7 @@ static void EvoTask_BeginPostSparklesSet2_AndFlash(u8 taskID) SetEvoSparklesMatrices(); gTasks[taskID].tFrameCounter = 0; CpuSet(&gPlttBufferFaded[0x20], &gPlttBufferUnfaded[0x20], 0x30); - BeginNormalPaletteFade(0xFFF9041C, 0, 0, 0x10, 0x7FFF); // was 0xFFF9001C in R/S + BeginNormalPaletteFade(0xFFF9041C, 0, 0, 0x10, RGB_WHITE); // was 0xFFF9001C in R/S gTasks[taskID].func = EvoTask_CreatePostEvoSparklesSet2_AndFlash; PlaySE(SE_W080); } @@ -407,7 +408,7 @@ static void EvoTask_CreatePostEvoSparklesSet2_AndFlash(u8 taskID) CreatePostEvoSparkleSet2(i); break; case 32: - BeginNormalPaletteFade(0xFFFF041C, 0x10, 0x10, 0, 0x7FFF); // was 0xFFF9001C in R/S + BeginNormalPaletteFade(0xFFFF041C, 0x10, 0x10, 0, RGB_WHITE); // was 0xFFF9001C in R/S break; } gTasks[taskID].tFrameCounter++; @@ -434,7 +435,7 @@ static void EvoTask_BeginPostSparklesSet2_AndFlash_Trade(u8 taskID) SetEvoSparklesMatrices(); gTasks[taskID].tFrameCounter = 0; CpuSet(&gPlttBufferFaded[0x20], &gPlttBufferUnfaded[0x20], 0x30); - BeginNormalPaletteFade(0xFFF90400, 0, 0, 0x10, 0x7FFF); // was 0xFFFF0001 in R/S + BeginNormalPaletteFade(0xFFF90400, 0, 0, 0x10, RGB_WHITE); // was 0xFFFF0001 in R/S gTasks[taskID].func = EvoTask_CreatePostEvoSparklesSet2_AndFlash_Trade; PlaySE(SE_W080); } @@ -455,7 +456,7 @@ static void EvoTask_CreatePostEvoSparklesSet2_AndFlash_Trade(u8 taskID) CreatePostEvoSparkleSet2(i); break; case 32: - BeginNormalPaletteFade(0xFFFF0400, 0x10, 0x10, 0, 0x7FFF); // was 0xFFFF0001 in R/S + BeginNormalPaletteFade(0xFFFF0400, 0x10, 0x10, 0, RGB_WHITE); // was 0xFFFF0001 in R/S break; } gTasks[taskID].tFrameCounter++; diff --git a/src/evolution_scene.c b/src/evolution_scene.c index 00f8df0f2..a7c786e69 100644 --- a/src/evolution_scene.c +++ b/src/evolution_scene.c @@ -32,6 +32,7 @@ #include "constants/battle_string_ids.h" #include "constants/species.h" #include "constants/songs.h" +#include "constants/rgb.h" struct EvoInfo { @@ -171,7 +172,7 @@ static void Task_BeginEvolutionScene(u8 taskID) switch (gTasks[taskID].tState) { case 0: - BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, 0); + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, RGB_BLACK); gTasks[taskID].tState++; break; case 1: @@ -368,7 +369,7 @@ static void CB2_EvolutionSceneLoadGraphics(void) SetVBlankCallback(VBlankCB_EvolutionScene); SetMainCallback2(CB2_EvolutionSceneUpdate); - BeginNormalPaletteFade(0xFFFFFFFF, 0, 0x10, 0, 0); + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0x10, 0, RGB_BLACK); ShowBg(0); ShowBg(1); @@ -445,14 +446,14 @@ static void CB2_TradeEvolutionSceneLoadGraphics(void) case 6: if (gWirelessCommType) { - LoadWirelessStatusIndicatorSprite(); + LoadWirelessStatusIndicatorSpriteGfx(); CreateWirelessStatusIndicatorSprite(0, 0); } BlendPalettes(-1,0x10, 0); gMain.state++; break; case 7: - BeginNormalPaletteFade(0xFFFFFFFF, 0, 0x10, 0, 0); + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0x10, 0, RGB_BLACK); sub_807B140(); ShowBg(0); ShowBg(1); @@ -605,7 +606,7 @@ static void Task_EvolutionScene(u8 taskID) switch (gTasks[taskID].tState) { case 0: - BeginNormalPaletteFade(0xFFFFFFFF, 0, 0x10, 0, 0); + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0x10, 0, RGB_BLACK); gSprites[sEvoStructPtr->preEvoSpriteID].invisible = FALSE; gTasks[taskID].tState++; ShowBg(0); @@ -640,7 +641,7 @@ static void Task_EvolutionScene(u8 taskID) { PlayNewMapMusic(MUS_SHINKA); gTasks[taskID].tState++; - BeginNormalPaletteFade(0x1C, 4, 0, 0x10, 0); + BeginNormalPaletteFade(0x1C, 4, 0, 0x10, RGB_BLACK); } break; case 5: // launch moving bg task, preapre evo sparkles @@ -698,7 +699,7 @@ static void Task_EvolutionScene(u8 taskID) m4aMPlayAllStop(); memcpy(&gPlttBufferUnfaded[0x20], sEvoStructPtr->savedPalette, 0x60); sub_8140174(); - BeginNormalPaletteFade(0x1C, 0, 0x10, 0, 0); + BeginNormalPaletteFade(0x1C, 0, 0x10, 0, RGB_BLACK); gTasks[taskID].tState++; } break; @@ -753,7 +754,7 @@ static void Task_EvolutionScene(u8 taskID) } else // no move to learn { - BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, 0); + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, RGB_BLACK); gTasks[taskID].tState++; } } @@ -781,7 +782,7 @@ static void Task_EvolutionScene(u8 taskID) if (!gTasks[sEvoGraphicsTaskID].isActive) { m4aMPlayAllStop(); - BeginNormalPaletteFade(0x6001C, 0, 0x10, 0, 0x7FFF); + BeginNormalPaletteFade(0x6001C, 0, 0x10, 0, RGB_WHITE); gTasks[taskID].tState++; } break; @@ -887,7 +888,7 @@ static void Task_EvolutionScene(u8 taskID) { gTasks[taskID].tLearnMoveState = gTasks[taskID].tData7; if (gTasks[taskID].tLearnMoveState == 5) - BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, 0); + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, RGB_BLACK); } } if (gMain.newKeys & B_BUTTON) @@ -1009,7 +1010,7 @@ static void Task_TradeEvolutionScene(u8 taskID) { PlayBGM(MUS_SHINKA); gTasks[taskID].tState++; - BeginNormalPaletteFade(0x1C, 4, 0, 0x10, 0); + BeginNormalPaletteFade(0x1C, 4, 0, 0x10, RGB_BLACK); } break; case 4: @@ -1130,7 +1131,7 @@ static void Task_TradeEvolutionScene(u8 taskID) if (!gTasks[sEvoGraphicsTaskID].isActive) { m4aMPlayAllStop(); - BeginNormalPaletteFade((1 << (gSprites[sEvoStructPtr->preEvoSpriteID].oam.paletteNum + 16)) | (0x4001C), 0, 0x10, 0, 0x7FFF); + BeginNormalPaletteFade((1 << (gSprites[sEvoStructPtr->preEvoSpriteID].oam.paletteNum + 16)) | (0x4001C), 0, 0x10, 0, RGB_WHITE); gTasks[taskID].tState++; } break; @@ -1213,7 +1214,7 @@ static void Task_TradeEvolutionScene(u8 taskID) sub_807F1A8(0, gDisplayedStringBattle, 1); gTasks[taskID].tLearnMoveState = gTasks[taskID].tData7; if (gTasks[taskID].tLearnMoveState == 5) - BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, 0); + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, RGB_BLACK); break; case 1: case -1: diff --git a/src/field_region_map.c b/src/field_region_map.c index 1d54333fb..ac1b26154 100644 --- a/src/field_region_map.c +++ b/src/field_region_map.c @@ -11,6 +11,7 @@ #include "text.h" #include "text_window.h" #include "window.h" +#include "constants/rgb.h" // Static type declarations @@ -145,7 +146,7 @@ static void FieldUpdateRegionMap(void) schedule_bg_copy_tilemap_to_vram(0); DrawStdFrameWithCustomTileAndPalette(0, 0, 0x27, 0xd); PrintRegionMapSecName(); - BeginNormalPaletteFade(0xFFFFFFFF, 0, 16, 0, 0); + BeginNormalPaletteFade(0xFFFFFFFF, 0, 16, 0, RGB_BLACK); sFieldRegionMapHandler->state++; break; case 2: @@ -173,7 +174,7 @@ static void FieldUpdateRegionMap(void) } break; case 5: - BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, 0); + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK); sFieldRegionMapHandler->state++; break; case 6: diff --git a/src/hof_pc.c b/src/hof_pc.c index d76f04372..01015ee81 100644 --- a/src/hof_pc.c +++ b/src/hof_pc.c @@ -6,6 +6,7 @@ #include "script.h" #include "script_menu.h" #include "task.h" +#include "constants/rgb.h" static void ReshowPCMenuAfterHallOfFamePC(void); static void Task_WaitForPaletteFade(u8); @@ -28,7 +29,7 @@ static void ReshowPCMenuAfterHallOfFamePC(void) Overworld_PlaySpecialMapMusic(); ScrSpecial_CreatePCMenu(); ScriptMenu_DisplayPCStartupPrompt(); - BeginNormalPaletteFade(0xFFFFFFFF, 0, 0x10, 0, 0); + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0x10, 0, RGB_BLACK); CreateTask(Task_WaitForPaletteFade, 10); } diff --git a/src/item_menu.c b/src/item_menu.c index 8edf6f279..8bec5407e 100755 --- a/src/item_menu.c +++ b/src/item_menu.c @@ -49,6 +49,7 @@ #include "window.h" #include "apprentice.h" #include "battle_pike.h" +#include "constants/rgb.h" void GoToBagMenu(u8 bagMenuType, u8 pocketId, void ( *postExitMenuMainCallback2)()); void CB2_Bag(void); @@ -659,7 +660,7 @@ bool8 setup_bag_menu(void) gMain.state++; break; case 20: - BeginNormalPaletteFade(0xFFFFFFFF, 0, 16, 0, 0); + BeginNormalPaletteFade(0xFFFFFFFF, 0, 16, 0, RGB_BLACK); gPaletteFade.bufferTransferDisabled = FALSE; gMain.state++; break; @@ -942,7 +943,7 @@ void free_bag_item_list_buffers(void) void unknown_ItemMenu_Confirm(u8 taskId) { - BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, 0); + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK); gTasks[taskId].func = task_close_bag_menu_2; } diff --git a/src/link.c b/src/link.c index 525d50d7c..bcdcb52a4 100644 --- a/src/link.c +++ b/src/link.c @@ -27,6 +27,7 @@ #include "battle.h" #include "link.h" #include "link_rfu.h" +#include "constants/rgb.h" extern u16 gHeldKeyCodeToSend; @@ -444,7 +445,7 @@ static void LinkTestProcessKeyInput(void) } if (gMain.newKeys & L_BUTTON) { - BeginNormalPaletteFade(0xFFFFFFFF, 0, 16, 0, 2); + BeginNormalPaletteFade(0xFFFFFFFF, 0, 16, 0, RGB(2, 0, 0)); } if (gMain.newKeys & START_BUTTON) { diff --git a/src/link_rfu.c b/src/link_rfu.c index 4e14a3ffd..abbab63f2 100644 --- a/src/link_rfu.c +++ b/src/link_rfu.c @@ -2254,7 +2254,7 @@ void DestroyWirelessStatusIndicatorSprite(void) } } -void LoadWirelessStatusIndicatorSprite(void) +void LoadWirelessStatusIndicatorSpriteGfx(void) { if (GetSpriteTileStartByTag(sWirelessStatusIndicatorSpriteSheet.tag) == 0xFFFF) { diff --git a/src/mail.c b/src/mail.c index 9cca4492e..0078bc4fc 100644 --- a/src/mail.c +++ b/src/mail.c @@ -19,6 +19,7 @@ #include "constants/species.h" #include "alloc.h" #include "easy_chat.h" +#include "constants/rgb.h" extern const u16 gMailPalette_Orange[]; extern const u16 gMailPalette_Harbor[]; @@ -417,7 +418,7 @@ static bool8 MailReadBuildGraphics(void) ShowBg(0); ShowBg(1); ShowBg(2); - BeginNormalPaletteFade(0xFFFFFFFF, 0, 16, 0, 0); + BeginNormalPaletteFade(0xFFFFFFFF, 0, 16, 0, RGB_BLACK); gPaletteFade.bufferTransferDisabled = FALSE; sMailRead->callback2 = CB2_WaitForPaletteExitOnKeyPress; return TRUE; @@ -526,7 +527,7 @@ static void CB2_ExitOnKeyPress(void) { if (gMain.newKeys & (A_BUTTON | B_BUTTON)) { - BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, 0); + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK); sMailRead->callback2 = CB2_ExitMailReadFreeVars; } } diff --git a/src/main_menu.c b/src/main_menu.c index 8c9612c24..6639f6559 100644 --- a/src/main_menu.c +++ b/src/main_menu.c @@ -584,9 +584,9 @@ static u32 InitMainMenu(bool8 returningFromOptionsMenu) ResetSpriteData(); FreeAllSpritePalettes(); if (returningFromOptionsMenu) - BeginNormalPaletteFade(0xFFFFFFFF, 0, 0x10, 0, 0x0000); // fade to black + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0x10, 0, RGB_BLACK); // fade to black else - BeginNormalPaletteFade(0xFFFFFFFF, 0, 0x10, 0, 0xFFFF); // fade to white + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0x10, 0, RGB_WHITEALPHA); // fade to white ResetBgsAndClearDma3BusyFlags(0); InitBgsFromTemplates(0, sMainMenuBgTemplates, ARRAY_COUNT(sMainMenuBgTemplates)); ChangeBgX(0, 0, 0); @@ -1098,7 +1098,7 @@ static void Task_HandleMainMenuAPressed(u8 taskId) SetGpuReg(REG_OFFSET_BG1VOFS, 0); SetGpuReg(REG_OFFSET_BG0HOFS, 0); SetGpuReg(REG_OFFSET_BG0VOFS, 0); - BeginNormalPaletteFade(0xFFFFFFFF, 0, 16, 0, 0); + BeginNormalPaletteFade(0xFFFFFFFF, 0, 16, 0, RGB_BLACK); return; } FreeAllWindowBuffers(); @@ -1287,7 +1287,7 @@ static void Task_NewGameBirchSpeech_Init(u8 taskId) FreeAllSpritePalettes(); ResetAllPicSprites(); AddBirchSpeechObjects(taskId); - BeginNormalPaletteFade(0xFFFFFFFF, 0, 16, 0, 0); + BeginNormalPaletteFade(0xFFFFFFFF, 0, 16, 0, RGB_BLACK); gTasks[taskId].tBG1HOFS = 0; gTasks[taskId].func = Task_NewGameBirchSpeech_WaitToShowBirch; gTasks[taskId].tPlayerSpriteId = 0xFF; @@ -1846,7 +1846,7 @@ static void CB2_NewGameBirchSpeech_ReturnFromNamingScreen(void) gSprites[spriteId].invisible = FALSE; gTasks[taskId].tPlayerSpriteId = spriteId; SetGpuReg(REG_OFFSET_BG1HOFS, -60); - BeginNormalPaletteFade(0xFFFFFFFF, 0, 16, 0, 0); + BeginNormalPaletteFade(0xFFFFFFFF, 0, 16, 0, RGB_BLACK); SetGpuReg(REG_OFFSET_WIN0H, 0); SetGpuReg(REG_OFFSET_WIN0V, 0); SetGpuReg(REG_OFFSET_WININ, 0); diff --git a/src/mevent_801BAAC.c b/src/mevent_801BAAC.c index 24a999f69..09a959429 100644 --- a/src/mevent_801BAAC.c +++ b/src/mevent_801BAAC.c @@ -14,6 +14,7 @@ #include "link_rfu.h" #include "mevent.h" #include "mystery_gift.h" +#include "constants/rgb.h" struct UnkStruct_8467FB8 { @@ -186,7 +187,7 @@ s32 FadeToWonderCardMenu(void) switch(sWonderCardData->unk_0174) { case 0: - BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, 0); + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK); break; case 1: if (UpdatePaletteFade()) @@ -231,7 +232,7 @@ s32 FadeToWonderCardMenu(void) ShowBg(2); gPaletteFade.bufferTransferDisabled = FALSE; sub_801C4C0(); - BeginNormalPaletteFade(0xFFFFFFFF, 0, 16, 0, 0); + BeginNormalPaletteFade(0xFFFFFFFF, 0, 16, 0, RGB_BLACK); UpdatePaletteFade(); break; default: @@ -251,7 +252,7 @@ s32 FadeOutFromWonderCard(bool32 flag) switch (sWonderCardData->unk_0174) { case 0: - BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, 0); + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK); break; case 1: if (UpdatePaletteFade()) @@ -279,7 +280,7 @@ s32 FadeOutFromWonderCard(bool32 flag) case 5: PrintMysteryGiftOrEReaderTopMenu(gGiftIsFromEReader, flag); CopyBgTilemapBufferToVram(0); - BeginNormalPaletteFade(0xFFFFFFFF, 0, 16, 0, 0); + BeginNormalPaletteFade(0xFFFFFFFF, 0, 16, 0, RGB_BLACK); break; default: if (UpdatePaletteFade()) @@ -575,7 +576,7 @@ s32 FadeToWonderNewsMenu(void) switch (sWonderNewsData->unk_01C0_1) { case 0: - BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, 0); + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK); break; case 1: if (UpdatePaletteFade()) @@ -629,7 +630,7 @@ s32 FadeToWonderNewsMenu(void) ShowBg(3); gPaletteFade.bufferTransferDisabled = FALSE; sWonderNewsData->unk_01C1 = AddScrollIndicatorArrowPair(&sWonderNewsData->unk_0394, &sWonderNewsData->unk_01C6); - BeginNormalPaletteFade(0xFFFFFFFF, 0, 16, 0, 0); + BeginNormalPaletteFade(0xFFFFFFFF, 0, 16, 0, RGB_BLACK); UpdatePaletteFade(); break; default: @@ -650,7 +651,7 @@ s32 FadeOutFromWonderNews(bool32 flag) switch (sWonderNewsData->unk_01C0_1) { case 0: - BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, 0); + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK); break; case 1: if (UpdatePaletteFade()) @@ -692,7 +693,7 @@ s32 FadeOutFromWonderNews(bool32 flag) MG_DrawCheckerboardPattern(3); CopyBgTilemapBufferToVram(0); CopyBgTilemapBufferToVram(3); - BeginNormalPaletteFade(0xFFFFFFFF, 0, 16, 0, 0); + BeginNormalPaletteFade(0xFFFFFFFF, 0, 16, 0, RGB_BLACK); break; default: if (UpdatePaletteFade()) diff --git a/src/mystery_event_menu.c b/src/mystery_event_menu.c index 850b22d5b..c77a48615 100644 --- a/src/mystery_event_menu.c +++ b/src/mystery_event_menu.c @@ -18,6 +18,7 @@ #include "gpu_regs.h" #include "text_window.h" #include "decompress.h" +#include "constants/rgb.h" // this file's functions static void CB2_MysteryEventMenu(void); @@ -137,7 +138,7 @@ static void CB2_MysteryEventMenu(void) PutWindowTilemap(0); CopyWindowToVram(0, 3); ShowBg(0); - BeginNormalPaletteFade(0xFFFFFFFF, 0, 0x10, 0, 0); + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0x10, 0, RGB_BLACK); gMain.state++; break; case 1: @@ -280,7 +281,7 @@ static void CB2_MysteryEventMenu(void) } break; case 15: - BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, 0); + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, RGB_BLACK); gMain.state++; break; case 16: diff --git a/src/naming_screen.c b/src/naming_screen.c index 75b7c8566..c264cfeed 100644 --- a/src/naming_screen.c +++ b/src/naming_screen.c @@ -27,6 +27,7 @@ #include "text_window.h" #include "overworld.h" #include "constants/event_objects.h" +#include "constants/rgb.h" EWRAM_DATA static struct NamingScreenData *gNamingScreenData = NULL; extern u16 gKeyRepeatStartDelay; @@ -463,7 +464,7 @@ static bool8 MainState_BeginFadeIn(void) CopyBgTilemapBufferToVram(2); CopyBgTilemapBufferToVram(3); BlendPalettes(-1, 16, 0); - BeginNormalPaletteFade(0xFFFFFFFF, 0, 16, 0, 0); + BeginNormalPaletteFade(0xFFFFFFFF, 0, 16, 0, RGB_BLACK); gNamingScreenData->state++; return FALSE; } @@ -517,7 +518,7 @@ static bool8 MainState_6(void) static bool8 MainState_BeginFadeInOut(void) { - BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, 0); + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK); gNamingScreenData->state++; return FALSE; } diff --git a/src/option_menu.c b/src/option_menu.c index 2fc0d6f3e..3ffb2738f 100644 --- a/src/option_menu.c +++ b/src/option_menu.c @@ -14,6 +14,7 @@ #include "international_string_util.h" #include "strings.h" #include "gba/m4a_internal.h" +#include "constants/rgb.h" // Task data enum @@ -250,7 +251,7 @@ void CB2_InitOptionMenu(void) break; } case 11: - BeginNormalPaletteFade(0xFFFFFFFF, 0, 0x10, 0, 0); + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0x10, 0, RGB_BLACK); SetVBlankCallback(VBlankCB); SetMainCallback2(MainCB2); return; @@ -359,7 +360,7 @@ static void Task_OptionMenuSave(u8 taskId) gSaveBlock2Ptr->optionsButtonMode = gTasks[taskId].data[TD_BUTTONMODE]; gSaveBlock2Ptr->optionsWindowFrameType = gTasks[taskId].data[TD_FRAMETYPE]; - BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, 0); + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, RGB_BLACK); gTasks[taskId].func = Task_OptionMenuFadeOut; } diff --git a/src/overworld.c b/src/overworld.c index 7c3bbeb5c..c46440012 100644 --- a/src/overworld.c +++ b/src/overworld.c @@ -1874,7 +1874,7 @@ static bool32 map_loading_iteration_3(u8 *state) case 11: if (gWirelessCommType != 0) { - LoadWirelessStatusIndicatorSprite(); + LoadWirelessStatusIndicatorSpriteGfx(); CreateWirelessStatusIndicatorSprite(0, 0); } (*state)++; @@ -2046,7 +2046,7 @@ static bool32 map_loading_iteration_2_link(u8 *state) case 11: if (gWirelessCommType != 0) { - LoadWirelessStatusIndicatorSprite(); + LoadWirelessStatusIndicatorSpriteGfx(); CreateWirelessStatusIndicatorSprite(0, 0); } (*state)++; diff --git a/src/pokeblock.c b/src/pokeblock.c index 325c2d5d0..0d8469132 100644 --- a/src/pokeblock.c +++ b/src/pokeblock.c @@ -32,6 +32,7 @@ #include "text_window.h" #include "constants/items.h" #include "constants/songs.h" +#include "constants/rgb.h" #define POKEBLOCK_MAX_FEEL 99 #define FIELD_E75_COUNT 7 @@ -585,7 +586,7 @@ static bool8 InitPokeblockMenu(void) gMain.state++; break; case 18: - BeginNormalPaletteFade(0xFFFFFFFF, 0, 0x10, 0, 0); + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0x10, 0, RGB_BLACK); gPaletteFade.bufferTransferDisabled = 0; gMain.state++; break; @@ -948,7 +949,7 @@ static void sub_8136470(struct Sprite *sprite) static void FadePaletteAndSetTaskToClosePokeblockCase(u8 taskId) { - BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, 0); + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, RGB_BLACK); gTasks[taskId].func = Task_FreeDataAndExitPokeblockCase; } diff --git a/src/pokeblock_feed.c b/src/pokeblock_feed.c index 59ba1b4dc..9c1be0f15 100644 --- a/src/pokeblock_feed.c +++ b/src/pokeblock_feed.c @@ -23,6 +23,7 @@ #include "text_window.h" #include "trig.h" #include "util.h" +#include "constants/rgb.h" struct PokeblockFeedStruct { @@ -591,7 +592,7 @@ static bool8 TransitionToPokeblockFeedScene(void) gMain.state++; break; case 13: - BeginNormalPaletteFade(0xFFFFFFFF, 0, 0x10, 0, 0); + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0x10, 0, RGB_BLACK); gPaletteFade.bufferTransferDisabled = 0; gMain.state++; break; @@ -805,7 +806,7 @@ static void Task_ReturnAfterPaletteFade(u8 taskId) static void Task_PaletteFadeToReturn(u8 taskId) { - BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, 0); + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, RGB_BLACK); gTasks[taskId].func = Task_ReturnAfterPaletteFade; } diff --git a/src/pokedex.c b/src/pokedex.c index cceb50ba1..94feaf440 100644 --- a/src/pokedex.c +++ b/src/pokedex.c @@ -2969,7 +2969,7 @@ void sub_80BEA24(u8 taskId) r3 = 0x14; if (gTasks[taskId].data[1] != 0) r3 |= (1 << (gSprites[gTasks[taskId].data[4]].oam.paletteNum + 16)); - BeginNormalPaletteFade(~r3, 0, 16, 0, 0); + BeginNormalPaletteFade(~r3, 0, 16, 0, RGB_BLACK); SetVBlankCallback(gUnknown_030060B4); gMain.state++; } diff --git a/src/rayquaza_scene.c b/src/rayquaza_scene.c index e2497a8dc..fc2860797 100644 --- a/src/rayquaza_scene.c +++ b/src/rayquaza_scene.c @@ -1563,7 +1563,7 @@ static void Task_DuoFightAnim(u8 taskId) } BlendPalettes(-1, 0x10, 0); - BeginNormalPaletteFade(0xFFFFFFFF, 0, 0x10, 0, 0); + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0x10, 0, RGB_BLACK); SetVBlankCallback(VBlankCB_DuoFight); PlaySE(SE_T_OOAME); } @@ -1715,7 +1715,7 @@ static void sub_81D752C(u8 taskId) static void DuoFightEnd(u8 taskId, s8 palDelay) { PlaySE(SE_T_OOAME_E); - BeginNormalPaletteFade(0xFFFFFFFF, palDelay, 0, 0x10, 0); + BeginNormalPaletteFade(0xFFFFFFFF, palDelay, 0, 0x10, RGB_BLACK); gTasks[taskId].func = Task_DuoFightEnd; } @@ -1971,7 +1971,7 @@ static void Task_HandleRayTakesFlight(u8 taskId) case 0: if (data[1] == 8) { - BeginNormalPaletteFade(0xFFFFFFFF, 0, 0x10, 0, 0); + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0x10, 0, RGB_BLACK); data[2] = 0; data[3] = 30; data[4] = 0; @@ -2012,7 +2012,7 @@ static void Task_HandleRayTakesFlight(u8 taskId) if (data[1] > 295) { data[0]++; - BeginNormalPaletteFade(0xFFFFFFFF, 6, 0, 0x10, 0); + BeginNormalPaletteFade(0xFFFFFFFF, 6, 0, 0x10, RGB_BLACK); } } break; @@ -2174,7 +2174,7 @@ static void Task_HandleRayDescends(u8 taskId) case 0: if (data[1] == 8) { - BeginNormalPaletteFade(0xFFFFFFFF, 0, 0x10, 0, 0); + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0x10, 0, RGB_BLACK); data[1] = 0; data[0]++; } @@ -2219,7 +2219,7 @@ static void Task_HandleRayDescends(u8 taskId) } break; case 4: - BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, 0); + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, RGB_BLACK); gTasks[taskId].func = Task_RayDescendsEnd; break; } @@ -2366,7 +2366,7 @@ static void Task_HandleRayCharges(u8 taskId) case 0: if (data[1] == 8) { - BeginNormalPaletteFade(0xFFFFFFFF, 0, 0x10, 0, 0); + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0x10, 0, RGB_BLACK); data[1] = 0; data[0]++; } @@ -2399,7 +2399,7 @@ static void Task_HandleRayCharges(u8 taskId) } break; case 3: - BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, 0); + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, RGB_BLACK); gTasks[taskId].func = Task_RayChargesEnd; break; } @@ -2532,7 +2532,7 @@ static void Task_HandleRayChasesAway(u8 taskId) if (data[1] == 8) { sub_81D90A8(taskId); - BeginNormalPaletteFade(0xFFFFFFFF, 0, 0x10, 0, 0); + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0x10, 0, RGB_BLACK); data[1] = 0; data[0]++; } @@ -2574,7 +2574,7 @@ static void Task_HandleRayChasesAway(u8 taskId) } break; case 3: - BeginNormalPaletteFade(0xFFFFFFFF, 4, 0, 0x10, 0); + BeginNormalPaletteFade(0xFFFFFFFF, 4, 0, 0x10, RGB_BLACK); gTasks[taskId].func = Task_RayChasesAwayEnd; break; } diff --git a/src/recorded_battle.c b/src/recorded_battle.c index acd4c2ce6..6af849bca 100644 --- a/src/recorded_battle.c +++ b/src/recorded_battle.c @@ -17,6 +17,7 @@ #include "battle_setup.h" #include "frontier_util.h" #include "constants/trainers.h" +#include "constants/rgb.h" #define BATTLER_RECORD_SIZE 664 #define ILLEGAL_BATTLE_TYPES ((BATTLE_TYPE_LINK | BATTLE_TYPE_SAFARI | BATTLE_TYPE_FIRST_BATTLE \ @@ -220,7 +221,7 @@ u8 RecordedBattle_GetBattlerAction(u8 battlerId) { gSpecialVar_Result = gBattleOutcome = B_OUTCOME_PLAYER_TELEPORTED; // hah ResetPaletteFadeControl(); - BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, 0); + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, RGB_BLACK); SetMainCallback2(CB2_QuitRecordedBattle); return 0xFF; } diff --git a/src/region_map.c b/src/region_map.c index 25b47479d..90017a4ad 100644 --- a/src/region_map.c +++ b/src/region_map.c @@ -26,6 +26,7 @@ #include "heal_location.h" #include "constants/heal_locations.h" #include "constants/map_types.h" +#include "constants/rgb.h" #define MAP_WIDTH 28 #define MAP_HEIGHT 15 @@ -1941,7 +1942,7 @@ static void sub_8124D14(void) switch (sFlyMap->unk_004) { case 0: - BeginNormalPaletteFade(0xFFFFFFFF, 0, 16, 0, 0); + BeginNormalPaletteFade(0xFFFFFFFF, 0, 16, 0, RGB_BLACK); sFlyMap->unk_004++; break; case 1: @@ -1988,7 +1989,7 @@ static void sub_8124E0C(void) switch (sFlyMap->unk_004) { case 0: - BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, 0); + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK); sFlyMap->unk_004++; break; case 1: diff --git a/src/reset_rtc_screen.c b/src/reset_rtc_screen.c index 6ee757607..d675c49d1 100644 --- a/src/reset_rtc_screen.c +++ b/src/reset_rtc_screen.c @@ -17,6 +17,7 @@ #include "bg.h" #include "window.h" #include "gpu_regs.h" +#include "constants/rgb.h" struct ResetRtcStruct { @@ -552,7 +553,7 @@ static void Task_ResetRtcScreen(u8 taskId) switch (data[0]) { case 0: - BeginNormalPaletteFade(0xFFFFFFFF, 1, 0x10, 0, 0xFFFF); + BeginNormalPaletteFade(0xFFFFFFFF, 1, 0x10, 0, RGB_WHITEALPHA); data[0] = 1; break; case 1: @@ -621,7 +622,7 @@ static void Task_ResetRtcScreen(u8 taskId) case 5: if (gMain.newKeys & A_BUTTON) { - BeginNormalPaletteFade(0xFFFFFFFF, 1, 0, 0x10, 0xFFFF); + BeginNormalPaletteFade(0xFFFFFFFF, 1, 0, 0x10, RGB_WHITEALPHA); data[0] = 6; } else diff --git a/src/reshow_battle_screen.c b/src/reshow_battle_screen.c index e37a5f8a5..22214336a 100644 --- a/src/reshow_battle_screen.c +++ b/src/reshow_battle_screen.c @@ -154,7 +154,7 @@ static void CB2_ReshowBattleScreenAfterMenu(void) if (gWirelessCommType != 0 && gReceivedRemoteLinkPlayers != 0) { - LoadWirelessStatusIndicatorSprite(); + LoadWirelessStatusIndicatorSpriteGfx(); CreateWirelessStatusIndicatorSprite(0, 0); } } diff --git a/src/save_failed_screen.c b/src/save_failed_screen.c index 415907585..6d45370b8 100644 --- a/src/save_failed_screen.c +++ b/src/save_failed_screen.c @@ -321,7 +321,7 @@ static void CB2_FadeAndReturnToTitleScreen(void) if (gMain.newKeys & A_BUTTON) { - BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, 0); + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK); SetVBlankCallback(VBlankCB); SetMainCallback2(CB2_ReturnToTitleScreen); } diff --git a/src/script_pokemon_util_80F87D8.c b/src/script_pokemon_util_80F87D8.c index fc2d7cf08..66fcae51d 100755 --- a/src/script_pokemon_util_80F87D8.c +++ b/src/script_pokemon_util_80F87D8.c @@ -477,7 +477,7 @@ void sub_80F90DC(void) { if (gReceivedRemoteLinkPlayers) { - LoadWirelessStatusIndicatorSprite(); + LoadWirelessStatusIndicatorSpriteGfx(); CreateWirelessStatusIndicatorSprite(8, 8); } } diff --git a/src/shop.c b/src/shop.c index 32caafb64..0d6ee00f8 100755 --- a/src/shop.c +++ b/src/shop.c @@ -1154,7 +1154,7 @@ static void BuyMenuPrintItemQuantityAndPrice(u8 taskId) static void ExitBuyMenu(u8 taskId) { gFieldCallback = MapPostLoadHook_ReturnToShopMenu; - BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, 0); + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK); gTasks[taskId].func = Task_ExitBuyMenu; } diff --git a/src/slot_machine.c b/src/slot_machine.c index a2e1f1554..b853daa39 100644 --- a/src/slot_machine.c +++ b/src/slot_machine.c @@ -658,7 +658,7 @@ static void Task_FadeToSlotMachine(u8 taskId) switch (gTasks[taskId].tState) { case 0: - BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, 0); + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, RGB_BLACK); gTasks[taskId].tState++; break; case 1: @@ -718,7 +718,7 @@ static void CB2_SlotMachineSetup(void) gMain.state++; break; case 7: - BeginNormalPaletteFade(-1, 0, 0x10, 0, 0); + BeginNormalPaletteFade(-1, 0, 0x10, 0, RGB_BLACK); ShowBg(0); ShowBg(1); ShowBg(2); diff --git a/src/start_menu.c b/src/start_menu.c index 5b527e15e..fcde176ac 100644 --- a/src/start_menu.c +++ b/src/start_menu.c @@ -45,6 +45,7 @@ #include "constants/songs.h" #include "rom_8011DC0.h" #include "union_room.h" +#include "constants/rgb.h" // Menu actions enum @@ -1237,7 +1238,7 @@ static void sub_80A0550(u8 taskId) DrawTextBorderOuter(0, 8, 14); PutWindowTilemap(0); CopyWindowToVram(0, 3); - BeginNormalPaletteFade(0xFFFFFFFF, 0, 16, 0, 0); + BeginNormalPaletteFade(0xFFFFFFFF, 0, 16, 0, RGB_BLACK); if (gWirelessCommType != 0 && InUnionRoom()) { @@ -1270,7 +1271,7 @@ static void sub_80A0550(u8 taskId) } break; case 3: - BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, 0); + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK); *step = 4; break; case 4: diff --git a/src/starter_choose.c b/src/starter_choose.c index c3d636175..c4cb07d6a 100644 --- a/src/starter_choose.c +++ b/src/starter_choose.c @@ -22,6 +22,7 @@ #include "window.h" #include "constants/songs.h" #include "constants/species.h" +#include "constants/rgb.h" #define STARTER_MON_COUNT 3 @@ -429,7 +430,7 @@ void CB2_ChooseStarter(void) LoadCompressedSpriteSheet(&gUnknown_085B1ED8[0]); LoadCompressedSpriteSheet(&gUnknown_085B1EE8[0]); LoadSpritePalettes(gUnknown_085B1EF8); - BeginNormalPaletteFade(0xFFFFFFFF, 0, 0x10, 0, 0); + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0x10, 0, RGB_BLACK); EnableInterrupts(DISPSTAT_VBLANK); SetVBlankCallback(VblankCB_StarterChoose); diff --git a/src/title_screen.c b/src/title_screen.c index b9ef53000..8310ef811 100644 --- a/src/title_screen.c +++ b/src/title_screen.c @@ -575,7 +575,7 @@ void CB2_InitTitleScreen(void) break; } case 3: - BeginNormalPaletteFade(0xFFFFFFFF, 1, 0x10, 0, 0xFFFF); + BeginNormalPaletteFade(0xFFFFFFFF, 1, 0x10, 0, RGB_WHITEALPHA); SetVBlankCallback(VBlankCB); gMain.state = 4; break; @@ -725,7 +725,7 @@ static void Task_TitleScreenPhase3(u8 taskId) if ((gMain.newKeys & A_BUTTON) || (gMain.newKeys & START_BUTTON)) { FadeOutBGM(4); - BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, 0xFFFF); + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, RGB_WHITEALPHA); SetMainCallback2(CB2_GoToMainMenu); } else if ((gMain.heldKeys & CLEAR_SAVE_BUTTON_COMBO) == CLEAR_SAVE_BUTTON_COMBO) @@ -736,13 +736,13 @@ static void Task_TitleScreenPhase3(u8 taskId) && CanResetRTC() == TRUE) { FadeOutBGM(4); - BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, 0); + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, RGB_BLACK); SetMainCallback2(CB2_GoToResetRtcScreen); } else if ((gMain.heldKeys & BERRY_UPDATE_BUTTON_COMBO) == BERRY_UPDATE_BUTTON_COMBO) { FadeOutBGM(4); - BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, 0); + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, RGB_BLACK); SetMainCallback2(CB2_GoToBerryFixScreen); } else @@ -759,7 +759,7 @@ static void Task_TitleScreenPhase3(u8 taskId) UpdateLegendaryMarkingColor(gTasks[taskId].tCounter); if ((gMPlayInfo_BGM.status & 0xFFFF) == 0) { - BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, 0xFFFF); + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, RGB_WHITEALPHA); SetMainCallback2(CB2_GoToCopyrightScreen); } } diff --git a/src/trade.c b/src/trade.c index 99c92a949..6f1f6e853 100644 --- a/src/trade.c +++ b/src/trade.c @@ -1626,7 +1626,7 @@ static void sub_80773D0(void) if (sub_8010500()) { gMain.state++; - LoadWirelessStatusIndicatorSprite(); + LoadWirelessStatusIndicatorSpriteGfx(); CreateWirelessStatusIndicatorSprite(0, 0); } } @@ -1820,7 +1820,7 @@ static void sub_8077B74(void) case 5: if (gWirelessCommType) { - LoadWirelessStatusIndicatorSprite(); + LoadWirelessStatusIndicatorSpriteGfx(); CreateWirelessStatusIndicatorSprite(0, 0); } gMain.state++; @@ -4246,7 +4246,7 @@ void sub_807AE50(void) { if (gWirelessCommType) { - LoadWirelessStatusIndicatorSprite(); + LoadWirelessStatusIndicatorSpriteGfx(); CreateWirelessStatusIndicatorSprite(0, 0); } SetMainCallback2(sub_807EA2C); diff --git a/src/trainer_card.c b/src/trainer_card.c index 41ebf46a5..52a060ae9 100755 --- a/src/trainer_card.c +++ b/src/trainer_card.c @@ -30,6 +30,7 @@ #include "constants/flags.h" #include "constants/game_stat.h" #include "constants/battle_frontier.h" +#include "constants/rgb.h" enum { @@ -381,7 +382,7 @@ static void sub_80C2760(u8 taskId) case 7: if (gWirelessCommType == 1 && gReceivedRemoteLinkPlayers == TRUE) { - LoadWirelessStatusIndicatorSprite(); + LoadWirelessStatusIndicatorSpriteGfx(); CreateWirelessStatusIndicatorSprite(230, 150); } BlendPalettes(0xFFFFFFFF, 16, sData->var_52C); diff --git a/src/union_room.c b/src/union_room.c index 62ae34336..c708c12d8 100644 --- a/src/union_room.c +++ b/src/union_room.c @@ -1406,7 +1406,7 @@ void sub_8012780(u8 taskId) switch (sub_80170B8(&data->textState, sub_801064C(ReadAsU16(data->field_0->arr[data->field_13].unk.field_0.unk_00.playerTrainerId), data->field_0->arr[data->field_13].unk.playerName))) { case 0: - LoadWirelessStatusIndicatorSprite(); + LoadWirelessStatusIndicatorSpriteGfx(); CreateWirelessStatusIndicatorSprite(0, 0); data->field_19 = 5; sub_8010688(5, ReadAsU16(data->field_0->arr[data->field_13].unk.field_0.unk_00.playerTrainerId), data->field_0->arr[data->field_13].unk.playerName); @@ -2132,7 +2132,7 @@ u32 sub_8013B8C(struct UnkStruct_Group *arg0, s32 id) void sub_8013BD8(struct UnkStruct_Group *data, s32 id) { data->field_F = id; - LoadWirelessStatusIndicatorSprite(); + LoadWirelessStatusIndicatorSpriteGfx(); CreateWirelessStatusIndicatorSprite(0, 0); RedrawListMenu(data->listTaskId); sub_8018404(gStringVar1, &data->field_0->arr[data->field_F]); @@ -2784,7 +2784,7 @@ void sub_8014A40(u8 taskId) switch (mevent_message_print_and_prompt_yes_no(&data->textState, &data->field_14, 0, gStringVar4)) { case 0: - LoadWirelessStatusIndicatorSprite(); + LoadWirelessStatusIndicatorSpriteGfx(); CreateWirelessStatusIndicatorSprite(0, 0); data->field_0->arr[data->field_13].field_1B = 0; RedrawListMenu(data->listTaskId); @@ -2987,7 +2987,7 @@ void sub_8014F48(u8 taskId) if (data->field_0->arr[id].field_1A_0 == 1 && !data->field_0->arr[id].unk.field_0.unk_0a_7) { data->field_F = id; - LoadWirelessStatusIndicatorSprite(); + LoadWirelessStatusIndicatorSpriteGfx(); CreateWirelessStatusIndicatorSprite(0, 0); RedrawListMenu(data->listTaskId); sub_8018404(gStringVar1, &data->field_0->arr[data->field_F]); @@ -3150,7 +3150,7 @@ void sub_80152F4(u8 taskId) { data->field_F = 0; data->field_14 = 0; - LoadWirelessStatusIndicatorSprite(); + LoadWirelessStatusIndicatorSpriteGfx(); CreateWirelessStatusIndicatorSprite(0, 0); sub_8011FC8(data->field_0->arr[0].unk.playerName, ReadAsU16(data->field_0->arr[0].unk.field_0.unk_00.playerTrainerId)); PlaySE(SE_PN_ON); @@ -3907,7 +3907,7 @@ void sub_80156E0(u8 taskId) } break; case 53: - BeginNormalPaletteFade(-1, 0, 0, 0x10, 0); + BeginNormalPaletteFade(-1, 0, 0, 0x10, RGB_BLACK); data->state = 54; break; case 54: diff --git a/src/union_room_chat.c b/src/union_room_chat.c index 25f68f875..55f826066 100755 --- a/src/union_room_chat.c +++ b/src/union_room_chat.c @@ -281,7 +281,7 @@ static void c2_081284E0(void) SetMainCallback2(sub_801DF38); gUnknown_02022C84->unkE = CreateTask(sub_801DF54, 8); gUnknown_02022C84->unkF = CreateTask(sub_801F2B4, 7); - LoadWirelessStatusIndicatorSprite(); + LoadWirelessStatusIndicatorSpriteGfx(); CreateWirelessStatusIndicatorSprite(232, 150); } break; diff --git a/src/unk_transition.c b/src/unk_transition.c index 99479c866..cd91af07e 100644 --- a/src/unk_transition.c +++ b/src/unk_transition.c @@ -8,6 +8,7 @@ #include "trig.h" #include "bg.h" #include "gpu_regs.h" +#include "constants/rgb.h" typedef bool8 (*TransitionStateFunc)(struct Task *task); @@ -361,7 +362,7 @@ static bool8 sub_81DAB4C(struct Task *task) { if (task->data[3] == 31) { - BeginNormalPaletteFade(0xFFFFFFFF, -1, 0, 0x10, 0); + BeginNormalPaletteFade(0xFFFFFFFF, -1, 0, 0x10, RGB_BLACK); task->tState++; } else diff --git a/src/wallclock.c b/src/wallclock.c index 810abb1d1..01900dc8e 100644 --- a/src/wallclock.c +++ b/src/wallclock.c @@ -18,6 +18,7 @@ #include "trig.h" #include "wallclock.h" #include "window.h" +#include "constants/rgb.h" #include "constants/songs.h" // static declarations @@ -671,7 +672,7 @@ static void LoadWallClockGraphics(void) static void WallClockInit(void) { - BeginNormalPaletteFade(0xFFFFFFFF, 0, 16, 0, 0); + BeginNormalPaletteFade(0xFFFFFFFF, 0, 16, 0, RGB_BLACK); EnableInterrupts(INTR_FLAG_VBLANK); SetVBlankCallback(WallClockVblankCallback); SetMainCallback2(WallClockMainCallback); @@ -864,7 +865,7 @@ static void Task_SetClock4(u8 taskId) static void Task_SetClock5(u8 taskId) { RtcInitLocalTimeOffset(gTasks[taskId].tHours, gTasks[taskId].tMinutes); - BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, 0); + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK); gTasks[taskId].func = Task_SetClock6; } @@ -896,7 +897,7 @@ static void Task_ViewClock2(u8 taskId) static void Task_ViewClock3(u8 taskId) { - BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, 0); + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK); gTasks[taskId].func = Task_ViewClock4; } From 92851ba4e60bcd3710b9db89d3f588833e591531 Mon Sep 17 00:00:00 2001 From: Phlosioneer Date: Sun, 7 Apr 2019 22:28:31 -0400 Subject: [PATCH 12/22] Trim headers from pokenav.c --- src/pokenav.c | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/src/pokenav.c b/src/pokenav.c index 68cdb0e89..5fcf9e9bb 100644 --- a/src/pokenav.c +++ b/src/pokenav.c @@ -6,18 +6,6 @@ #include "field_weather.h" #include "palette.h" #include "pokemon_storage_system.h" -#include "sound.h" -#include "constants/songs.h" -#include "window.h" -#include "gpu_regs.h" -#include "bg.h" -#include "menu.h" -#include "graphics.h" -#include "dma3.h" -#include "gba/macro.h" -#include "decompress.h" -#include "strings.h" -#include "constants/rgb.h" #include "pokenav.h" enum From 2c432c314a95b5c48f411075fb6f2ff62fa69617 Mon Sep 17 00:00:00 2001 From: ultima-soul Date: Sun, 7 Apr 2019 18:36:10 -0700 Subject: [PATCH 13/22] Match sub_8159308 --- include/battle_anim.h | 2 +- src/battle_anim.c | 2 +- src/battle_anim_sound_tasks.c | 71 ++++++----------------------------- 3 files changed, 14 insertions(+), 61 deletions(-) diff --git a/include/battle_anim.h b/include/battle_anim.h index 949bc236b..a7b71bd85 100644 --- a/include/battle_anim.h +++ b/include/battle_anim.h @@ -62,7 +62,7 @@ void MoveBattlerSpriteToBG(u8 battlerId, bool8 toBG_2, bool8 setSpriteInvisible) bool8 IsContest(void); s8 BattleAnimAdjustPanning(s8 pan); s8 BattleAnimAdjustPanning2(s8 pan); -s16 KeepPanInRange(s16 a); +s16 KeepPanInRange(s16 a, int oldPan); s16 CalculatePanIncrement(s16 sourcePan, s16 targetPan, s16 incrementPan); void sub_80A4720(u16 a, u16 *b, u32 c, u8 d); void sub_80A477C(bool8); diff --git a/src/battle_anim.c b/src/battle_anim.c index a667c6177..b265bf7bc 100644 --- a/src/battle_anim.c +++ b/src/battle_anim.c @@ -2936,7 +2936,7 @@ s8 BattleAnimAdjustPanning2(s8 pan) return pan; } -s16 KeepPanInRange(s16 panArg) +s16 KeepPanInRange(s16 panArg, int oldPan) { s16 pan = panArg; diff --git a/src/battle_anim_sound_tasks.c b/src/battle_anim_sound_tasks.c index e5f0cd165..8f90a6a16 100644 --- a/src/battle_anim_sound_tasks.c +++ b/src/battle_anim_sound_tasks.c @@ -53,7 +53,7 @@ static void sub_8158B98(u8 taskId) PlaySE12WithPanning(gTasks[taskId].data[0], pan); } pan += panIncrement; - gTasks[taskId].data[2] = KeepPanInRange(pan); + gTasks[taskId].data[2] = KeepPanInRange(pan, panIncrement); } } @@ -116,9 +116,12 @@ static void sub_8158D08(u8 taskId) if (gTasks[taskId].data[10]++ == gTasks[taskId].data[5]) { + u16 dPan, oldPan; gTasks[taskId].data[10] = 0; - gTasks[taskId].data[11] += gTasks[taskId].data[3]; - gTasks[taskId].data[11] = KeepPanInRange(gTasks[taskId].data[11]); + dPan = gTasks[taskId].data[3]; + oldPan = gTasks[taskId].data[11] ; + gTasks[taskId].data[11] = dPan + oldPan; + gTasks[taskId].data[11] = KeepPanInRange(gTasks[taskId].data[11], oldPan); } } // task end @@ -368,71 +371,21 @@ void sub_8159278(u8 taskId) sub_8159308(taskId); } -#ifdef NONMATCHING void sub_8159308(u8 taskId) { - s16 panIncrement = gTasks[taskId].data[3]; + u16 panIncrement = gTasks[taskId].data[3]; if (gTasks[taskId].data[10]++ == gTasks[taskId].data[5]) { + u16 oldPan; gTasks[taskId].data[10] = 0; - - gTasks[taskId].data[11] += panIncrement; - gTasks[taskId].data[11] = KeepPanInRange(gTasks[taskId].data[11]); + oldPan = gTasks[taskId].data[11]; + gTasks[taskId].data[11] = panIncrement + oldPan; + gTasks[taskId].data[11] = KeepPanInRange(gTasks[taskId].data[11], oldPan); } gUnknown_02038440 = gTasks[taskId].data[11]; if (gTasks[taskId].data[11] == gTasks[taskId].data[2]) DestroyAnimVisualTask(taskId); } -#else -NAKED -void sub_8159308(u8 taskId) -{ - asm_unified(" push {r4,r5,lr}\n\ - lsls r0, 24\n\ - lsrs r0, 24\n\ - adds r5, r0, 0\n\ - ldr r1, =gTasks\n\ - lsls r0, r5, 2\n\ - adds r0, r5\n\ - lsls r0, 3\n\ - adds r4, r0, r1\n\ - ldrh r2, [r4, 0xE]\n\ - ldrh r0, [r4, 0x1C]\n\ - adds r1, r0, 0x1\n\ - strh r1, [r4, 0x1C]\n\ - lsls r0, 16\n\ - asrs r0, 16\n\ - movs r3, 0x12\n\ - ldrsh r1, [r4, r3]\n\ - cmp r0, r1\n\ - bne _08159342\n\ - movs r0, 0\n\ - strh r0, [r4, 0x1C]\n\ - ldrh r1, [r4, 0x1E]\n\ - adds r0, r2, r1\n\ - strh r0, [r4, 0x1E]\n\ - movs r2, 0x1E\n\ - ldrsh r0, [r4, r2]\n\ - bl KeepPanInRange\n\ - strh r0, [r4, 0x1E]\n\ -_08159342:\n\ - ldr r1, =gUnknown_02038440\n\ - ldrh r0, [r4, 0x1E]\n\ - strb r0, [r1]\n\ - movs r3, 0x1E\n\ - ldrsh r1, [r4, r3]\n\ - movs r2, 0xC\n\ - ldrsh r0, [r4, r2]\n\ - cmp r1, r0\n\ - bne _0815935A\n\ - adds r0, r5, 0\n\ - bl DestroyAnimVisualTask\n\ -_0815935A:\n\ - pop {r4,r5}\n\ - pop {r0}\n\ - bx r0\n\ - .pool"); -} -#endif + From 21722d99317b8deb06467e13a09cfde52a7b6e86 Mon Sep 17 00:00:00 2001 From: ultima-soul Date: Sun, 7 Apr 2019 18:38:01 -0700 Subject: [PATCH 14/22] Fix formatting --- src/battle_anim_sound_tasks.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/battle_anim_sound_tasks.c b/src/battle_anim_sound_tasks.c index 8f90a6a16..573feb41c 100644 --- a/src/battle_anim_sound_tasks.c +++ b/src/battle_anim_sound_tasks.c @@ -116,10 +116,10 @@ static void sub_8158D08(u8 taskId) if (gTasks[taskId].data[10]++ == gTasks[taskId].data[5]) { - u16 dPan, oldPan; + u16 dPan, oldPan; gTasks[taskId].data[10] = 0; - dPan = gTasks[taskId].data[3]; - oldPan = gTasks[taskId].data[11] ; + dPan = gTasks[taskId].data[3]; + oldPan = gTasks[taskId].data[11] ; gTasks[taskId].data[11] = dPan + oldPan; gTasks[taskId].data[11] = KeepPanInRange(gTasks[taskId].data[11], oldPan); } @@ -377,9 +377,9 @@ void sub_8159308(u8 taskId) if (gTasks[taskId].data[10]++ == gTasks[taskId].data[5]) { - u16 oldPan; + u16 oldPan; gTasks[taskId].data[10] = 0; - oldPan = gTasks[taskId].data[11]; + oldPan = gTasks[taskId].data[11]; gTasks[taskId].data[11] = panIncrement + oldPan; gTasks[taskId].data[11] = KeepPanInRange(gTasks[taskId].data[11], oldPan); } From 608245058b40b1d6fcb7e85e519b1e0d83013785 Mon Sep 17 00:00:00 2001 From: Sewef Date: Sun, 7 Apr 2019 20:31:30 +0200 Subject: [PATCH 15/22] Update charmap.txt French is beautiful. (Lie) --- charmap.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/charmap.txt b/charmap.txt index 26d48e101..43ff737a0 100644 --- a/charmap.txt +++ b/charmap.txt @@ -61,6 +61,10 @@ UP_ARROW = 79 DOWN_ARROW = 7A LEFT_ARROW = 7B RIGHT_ARROW = 7C +SUPER_E = 84 +'<' = 85 +'>' = 86 +SUPER_RE = A0 '0' = A1 '1' = A2 '2' = A3 From fff1679bcfd5c13f6c311bec399463b5d85d1f21 Mon Sep 17 00:00:00 2001 From: Sewef Date: Sun, 7 Apr 2019 20:35:15 +0200 Subject: [PATCH 16/22] Update .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index ed21493bf..a92cf57b6 100644 --- a/.gitignore +++ b/.gitignore @@ -28,3 +28,4 @@ build/ .DS_Store *.ddump porymap.project.cfg +.vscode/ From c8ce1a0a1f533a265d5134660c31b1ec6e8b86e0 Mon Sep 17 00:00:00 2001 From: Sewef Date: Sun, 7 Apr 2019 20:45:50 +0200 Subject: [PATCH 17/22] Two labels from pokeruby. --- src/strings.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/strings.c b/src/strings.c index ac7a32709..793256edb 100644 --- a/src/strings.c +++ b/src/strings.c @@ -162,8 +162,8 @@ const u8 gText_DexSearchTypeNone[] = _("NONE"); const u8 gText_SelectorArrow[] = _("â–¶"); const u8 gUnknown_085E8B3C[] = _(" "); const u8 gText_WelcomeToHOF[] = _("Welcome to the HALL OF FAME!"); -const u8 gUnknown_085E8B5B[] = _("Spotted POKéMON: {STR_VAR_1}!\nOwned POKéMON: {STR_VAR_2}!\pPROF. BIRCH's POKéDEX rating!\pPROF. BIRCH: Let's see…\p"); -const u8 gUnknown_085E8BBA[] = _("SAVING…\nDON'T TURN OFF THE POWER."); +const u8 gText_HOFDexRating[] = _("Spotted POKéMON: {STR_VAR_1}!\nOwned POKéMON: {STR_VAR_2}!\pPROF. BIRCH's POKéDEX rating!\pPROF. BIRCH: Let's see…\p"); +const u8 gText_HOFDexSaving[] = _("SAVING…\nDON'T TURN OFF THE POWER."); const u8 gText_HOFCorrupted[] = _("The HALL OF FAME data is corrupted."); const u8 gText_HOFNumber[] = _("HALL OF FAME No. {STR_VAR_1}"); const u8 gText_LeagueChamp[] = _("LEAGUE CHAMPION!\nCONGRATULATIONS!"); From 382a29ad40b19956ae696461cc88a50097c85587 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Tue, 9 Apr 2019 12:08:15 +0200 Subject: [PATCH 18/22] Update battle_anim_script.inc --- asm/macros/battle_anim_script.inc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/asm/macros/battle_anim_script.inc b/asm/macros/battle_anim_script.inc index 32d9de82c..5426cdfba 100644 --- a/asm/macros/battle_anim_script.inc +++ b/asm/macros/battle_anim_script.inc @@ -144,7 +144,7 @@ .byte \pan .endm - .macro panse_1B se:req, param1:req, param2:req, param3:req, param4 + .macro panse_1B se:req, param1:req, param2:req, param3:req, param4:req .byte 0x1b .2byte \se .byte \param1 @@ -215,7 +215,7 @@ .byte \param2 .endm - .macro panse_26 se:req, param1:req, param2:req, param3:req, param4 + .macro panse_26 se:req, param1:req, param2:req, param3:req, param4:req .byte 0x26 .2byte \se .byte \param1 @@ -224,7 +224,7 @@ .byte \param4 .endm - .macro panse_27 se:req, param1:req, param2:req, param3:req, param4 + .macro panse_27 se:req, param1:req, param2:req, param3:req, param4:req .byte 0x27 .2byte \se .byte \param1 From 8a617c3d94b52f496585f7c5e132618a2e8ea0f8 Mon Sep 17 00:00:00 2001 From: Marcus Huderle Date: Tue, 9 Apr 2019 19:37:54 -0500 Subject: [PATCH 19/22] Decompile more pokemon_jump.c --- asm/pokemon_jump.s | 570 --------------------------------------------- src/pokemon_jump.c | 288 ++++++++++++++++++++--- 2 files changed, 260 insertions(+), 598 deletions(-) diff --git a/asm/pokemon_jump.s b/asm/pokemon_jump.s index 8a705e32e..108c3dbf1 100755 --- a/asm/pokemon_jump.s +++ b/asm/pokemon_jump.s @@ -5,576 +5,6 @@ .text - thumb_func_start sub_802BD84 -sub_802BD84: @ 802BD84 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x4 - lsls r0, 24 - lsrs r0, 24 - mov r10, r0 - lsls r0, 2 - add r0, r10 - lsls r0, 3 - ldr r1, =gTasks + 0x8 - adds r6, r0, r1 - mov r0, r10 - movs r1, 0xE - bl GetWordTaskArg - mov r8, r0 - movs r1, 0 - ldrsh r0, [r6, r1] - cmp r0, 0 - beq _0802BDC8 - cmp r0, 0x1 - beq _0802BDDC - b _0802BE48 - .pool -_0802BDBC: - bl sub_802AB20 - mov r0, r10 - bl DestroyTask - b _0802BE48 -_0802BDC8: - movs r1, 0 - adds r0, r6, 0 - adds r0, 0x8 -_0802BDCE: - strh r1, [r0, 0x4] - subs r0, 0x2 - cmp r0, r6 - bge _0802BDCE - ldrh r0, [r6] - adds r0, 0x1 - strh r0, [r6] -_0802BDDC: - mov r3, r8 - ldrb r1, [r3, 0x6] - lsls r0, r1, 1 - adds r0, r1 - lsls r0, 2 - ldr r4, =0x000082a8 - adds r0, r4 - add r0, r8 - bl sub_802E0AC - movs r2, 0 - adds r5, r6, 0x4 - mov r9, r2 - movs r7, 0x83 - lsls r7, 8 - add r7, r8 - add r4, r8 -_0802BDFE: - movs r1, 0 - ldrsh r0, [r5, r1] - cmp r0, 0 - bne _0802BE38 - adds r0, r2, 0 - adds r1, r4, 0 - str r2, [sp] - bl sub_802E0D0 - ldr r2, [sp] - cmp r0, 0 - beq _0802BE38 - ldr r1, =gLinkPlayers + 8 - add r1, r9 - adds r0, r7, 0 - bl StringCopy - movs r0, 0x1 - strh r0, [r5] - ldrh r0, [r6, 0x2] - adds r0, 0x1 - strh r0, [r6, 0x2] - movs r3, 0x2 - ldrsh r0, [r6, r3] - ldr r2, [sp] - mov r1, r8 - ldrb r1, [r1, 0x5] - cmp r0, r1 - beq _0802BDBC -_0802BE38: - adds r5, 0x2 - movs r3, 0x1C - add r9, r3 - adds r7, 0x28 - adds r4, 0xC - adds r2, 0x1 - cmp r2, 0x4 - ble _0802BDFE -_0802BE48: - add sp, 0x4 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_802BD84 - - thumb_func_start sub_802BE60 -sub_802BE60: @ 802BE60 - push {lr} - lsls r1, 24 - lsrs r1, 24 - bl CreateTask - lsls r0, 24 - lsrs r0, 24 - ldr r1, =gUnknown_02022CFC - ldr r2, [r1] - movs r1, 0xE - bl SetWordTaskArg - pop {r0} - bx r0 - .pool - thumb_func_end sub_802BE60 - - thumb_func_start sub_802BE80 -sub_802BE80: @ 802BE80 - ldr r0, =gUnknown_02022CFC - ldr r2, [r0] - adds r0, r2, 0 - adds r0, 0x4A - movs r1, 0 - strh r1, [r0] - movs r0, 0x6 - str r0, [r2, 0x14] - strh r1, [r2, 0x34] - str r1, [r2, 0x1C] - strh r1, [r2, 0x36] - str r1, [r2, 0x10] - bx lr - .pool - thumb_func_end sub_802BE80 - - thumb_func_start sub_802BEA0 -sub_802BEA0: @ 802BEA0 - push {r4,lr} - ldr r3, =gUnknown_02022CFC - ldr r0, [r3] - adds r1, r0, 0 - adds r1, 0x4A - movs r4, 0 - movs r2, 0 - strh r2, [r1] - ldr r1, =0x000006ff - strh r1, [r0, 0x34] - movs r1, 0x7 - str r1, [r0, 0x14] - strh r2, [r0, 0x36] - str r2, [r0, 0x10] - adds r0, 0x51 - strb r4, [r0] - ldr r0, [r3] - adds r0, 0x50 - strb r4, [r0] - ldr r0, [r3] - str r2, [r0, 0x20] - adds r1, r0, 0 - adds r1, 0x4E - strh r2, [r1] - str r2, [r0, 0x6C] - bl sub_802BF7C - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_802BEA0 - - thumb_func_start sub_802BEE4 -sub_802BEE4: @ 802BEE4 - push {r4,lr} - ldr r4, =gUnknown_02022CFC - ldr r1, [r4] - adds r0, r1, 0 - adds r0, 0x46 - ldrb r0, [r0] - cmp r0, 0 - beq _0802BF34 - adds r1, 0x4A - ldrh r0, [r1] - adds r0, 0x1 - strh r0, [r1] - bl sub_802BF48 - ldr r3, [r4] - ldrh r1, [r3, 0x34] - adds r2, r1, r0 - strh r2, [r3, 0x34] - lsls r1, r2, 16 - ldr r0, =0x09fe0000 - cmp r1, r0 - bls _0802BF16 - ldr r1, =0xfffff601 - adds r0, r2, r1 - strh r0, [r3, 0x34] -_0802BF16: - ldr r1, [r4] - ldr r2, [r1, 0x14] - str r2, [r1, 0x18] - ldrh r0, [r1, 0x34] - lsrs r0, 8 - str r0, [r1, 0x14] - cmp r0, 0x6 - bls _0802BF34 - cmp r2, 0x6 - bhi _0802BF34 - ldrh r0, [r1, 0x36] - adds r0, 0x1 - strh r0, [r1, 0x36] - bl sub_802BF7C -_0802BF34: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_802BEE4 - - thumb_func_start sub_802BF48 -sub_802BF48: @ 802BF48 - push {lr} - ldr r0, =gUnknown_02022CFC - ldr r2, [r0] - ldr r0, [r2, 0x10] - cmp r0, 0 - beq _0802BF5C - movs r0, 0 - b _0802BF72 - .pool -_0802BF5C: - ldr r3, [r2, 0x1C] - ldrh r1, [r2, 0x34] - ldr r0, =0x000005ff - cmp r1, r0 - bhi _0802BF70 - ldr r0, [r2, 0x20] - adds r0, 0x50 - str r0, [r2, 0x20] - lsrs r0, 8 - adds r3, r0 -_0802BF70: - adds r0, r3, 0 -_0802BF72: - pop {r1} - bx r1 - .pool - thumb_func_end sub_802BF48 - - thumb_func_start sub_802BF7C -sub_802BF7C: @ 802BF7C - push {r4,lr} - ldr r4, =gUnknown_02022CFC - ldr r3, [r4] - movs r0, 0 - str r0, [r3, 0x20] - adds r1, r3, 0 - adds r1, 0x4E - ldrh r0, [r1] - cmp r0, 0 - beq _0802BFC0 - subs r0, 0x1 - strh r0, [r1] - ldr r0, [r3, 0x6C] - cmp r0, 0 - beq _0802C08A - bl sub_802C098 - movs r1, 0x3 - ands r1, r0 - cmp r1, 0 - beq _0802BFB0 - ldr r1, [r4] - b _0802C086 - .pool -_0802BFB0: - ldr r1, [r4] - ldr r0, [r1, 0x28] - cmp r0, 0x36 - bls _0802BFBC - movs r0, 0x1E - b _0802C088 -_0802BFBC: - movs r0, 0x52 - b _0802C088 -_0802BFC0: - adds r2, r3, 0 - adds r2, 0x50 - ldrb r1, [r2] - movs r0, 0x8 - ands r0, r1 - cmp r0, 0 - bne _0802C014 - ldr r0, =gUnknown_082FB63C - ldrb r1, [r2] - lsls r1, 1 - adds r1, r0 - adds r0, r3, 0 - adds r0, 0x51 - ldrb r2, [r0] - lsls r0, r2, 3 - subs r0, r2 - ldrh r1, [r1] - adds r0, r1 - str r0, [r3, 0x28] - bl sub_802C098 - ldr r2, [r4] - ldr r3, =gUnknown_082FB64C - movs r1, 0x3 - ands r1, r0 - lsls r1, 1 - adds r1, r3 - ldrh r0, [r1] - adds r0, 0x2 - adds r1, r2, 0 - adds r1, 0x4E - strh r0, [r1] - adds r2, 0x50 - ldrb r0, [r2] - adds r0, 0x1 - strb r0, [r2] - b _0802C082 - .pool -_0802C014: - lsls r0, r1, 24 - lsrs r0, 24 - cmp r0, 0x8 - bne _0802C030 - adds r1, r3, 0 - adds r1, 0x51 - ldrb r0, [r1] - cmp r0, 0x2 - bhi _0802C02C - adds r0, 0x1 - strb r0, [r1] - b _0802C030 -_0802C02C: - movs r0, 0x1 - str r0, [r3, 0x6C] -_0802C030: - ldr r2, =gUnknown_082FB63C - ldr r4, =gUnknown_02022CFC - ldr r0, [r4] - mov r12, r0 - mov r3, r12 - adds r3, 0x50 - ldrb r0, [r3] - movs r1, 0xF - subs r1, r0 - lsls r1, 1 - adds r1, r2 - mov r0, r12 - adds r0, 0x51 - ldrb r2, [r0] - lsls r0, r2, 3 - subs r0, r2 - ldrh r1, [r1] - adds r0, r1 - mov r1, r12 - str r0, [r1, 0x28] - ldrb r0, [r3] - adds r0, 0x1 - strb r0, [r3] - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0xF - bls _0802C082 - bl sub_802C098 - movs r1, 0x3 - ands r1, r0 - cmp r1, 0 - bne _0802C07A - ldr r1, [r4] - ldr r0, [r1, 0x28] - subs r0, 0x5 - str r0, [r1, 0x28] -_0802C07A: - ldr r0, [r4] - adds r0, 0x50 - movs r1, 0 - strb r1, [r0] -_0802C082: - ldr r0, =gUnknown_02022CFC - ldr r1, [r0] -_0802C086: - ldr r0, [r1, 0x28] -_0802C088: - str r0, [r1, 0x1C] -_0802C08A: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_802BF7C - - thumb_func_start sub_802C098 -sub_802C098: @ 802C098 - ldr r0, =gUnknown_02022CFC - ldr r2, [r0] - ldr r1, [r2, 0x24] - ldr r0, =0x41c64e6d - muls r0, r1 - ldr r1, =0x00006073 - adds r0, r1 - str r0, [r2, 0x24] - lsrs r0, 16 - bx lr - .pool - thumb_func_end sub_802C098 - - thumb_func_start sub_802C0B8 -sub_802C0B8: @ 802C0B8 - push {lr} - ldr r0, =gUnknown_02022CFC - ldr r1, [r0] - movs r0, 0x1 - str r0, [r1, 0x10] - movs r0, 0x6 - str r0, [r1, 0x14] - ldr r0, =0x000005ff - strh r0, [r1, 0x34] - bl sub_802C270 - pop {r0} - bx r0 - .pool - thumb_func_end sub_802C0B8 - - thumb_func_start sub_802C0DC -sub_802C0DC: @ 802C0DC - ldr r0, =gUnknown_02022CFC - ldr r0, [r0] - ldr r0, [r0, 0x10] - bx lr - .pool - thumb_func_end sub_802C0DC - - thumb_func_start sub_802C0E8 -sub_802C0E8: @ 802C0E8 - push {r4,r5,lr} - ldr r5, =gUnknown_02022CFC - ldr r4, =0x000082f8 - movs r3, 0 - movs r2, 0 - movs r1, 0x4 -_0802C0F4: - ldr r0, [r5] - adds r0, r4 - adds r0, r2 - str r3, [r0] - adds r2, 0x28 - subs r1, 0x1 - cmp r1, 0 - bge _0802C0F4 - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_802C0E8 - - thumb_func_start sub_802C114 -sub_802C114: @ 802C114 - ldr r0, =gUnknown_02022CFC - ldr r0, [r0] - ldr r1, =0x000083ac - adds r0, r1 - ldr r1, [r0] - movs r2, 0 - strh r2, [r1, 0x10] - ldr r0, [r0] - strh r2, [r0, 0x12] - bx lr - .pool - thumb_func_end sub_802C114 - - thumb_func_start sub_802C130 -sub_802C130: @ 802C130 - push {lr} - lsls r0, 16 - lsrs r0, 16 - ldr r1, =gUnknown_02022CFC - ldr r2, [r1] - ldrb r3, [r2, 0x6] - lsls r1, r3, 2 - adds r1, r3 - lsls r1, 3 - adds r2, r1 - ldr r1, =0x000082f4 - adds r2, r1 - ldrh r1, [r2] - cmp r1, r0 - beq _0802C15C - movs r0, 0 - b _0802C15E - .pool -_0802C15C: - movs r0, 0x1 -_0802C15E: - pop {r1} - bx r1 - thumb_func_end sub_802C130 - - thumb_func_start sub_802C164 -sub_802C164: @ 802C164 - ldr r0, =gUnknown_02022CFC - ldr r0, [r0] - ldr r1, =0x000083ac - adds r2, r0, r1 - ldr r1, [r2] - adds r0, 0x4A - ldrh r0, [r0] - strh r0, [r1, 0xE] - ldr r1, [r2] - ldrh r0, [r1, 0x10] - strh r0, [r1, 0x12] - ldr r1, [r2] - movs r0, 0x1 - strh r0, [r1, 0x10] - bx lr - .pool - thumb_func_end sub_802C164 - - thumb_func_start sub_802C18C -sub_802C18C: @ 802C18C - push {r4,lr} - ldr r0, =gUnknown_02022CFC - ldr r2, [r0] - ldr r0, =0x000083ac - adds r3, r2, r0 - ldr r1, [r3] - ldrh r0, [r1, 0x10] - strh r0, [r1, 0x12] - ldr r0, [r3] - movs r4, 0x2 - strh r4, [r0, 0x10] - ldr r1, [r3] - adds r2, 0x4A - ldrh r0, [r2] - strh r0, [r1, 0xE] - ldr r0, [r3] - str r4, [r0, 0x14] - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_802C18C - - thumb_func_start sub_802C1BC -sub_802C1BC: @ 802C1BC - ldr r0, =gUnknown_02022CFC - ldr r0, [r0] - ldr r1, =0x000083ac - adds r0, r1 - ldr r1, [r0] - ldrh r2, [r1, 0x10] - movs r3, 0 - strh r2, [r1, 0x12] - ldr r0, [r0] - strh r3, [r0, 0x10] - bx lr - .pool - thumb_func_end sub_802C1BC - thumb_func_start sub_802C1DC sub_802C1DC: @ 802C1DC push {r4,r5,lr} diff --git a/src/pokemon_jump.c b/src/pokemon_jump.c index 2ef81bd19..d893768f9 100755 --- a/src/pokemon_jump.c +++ b/src/pokemon_jump.c @@ -9,6 +9,7 @@ #include "save.h" #include "sound.h" #include "sprite.h" +#include "string_util.h" #include "task.h" #include "pokemon.h" #include "pokemon_jump.h" @@ -34,7 +35,7 @@ struct PokemonJump1_82E4 u16 unk12; int unk14; int unk18; - u8 filler1C[0xC]; + u8 unk1C[11]; }; struct PokemonJump1 @@ -48,16 +49,16 @@ struct PokemonJump1 u16 unkA; u16 unkC; u16 unkE; - u8 filler10[0x4]; - int unk14; - int unk18; + int unk10; + u32 unk14; + u32 unk18; int unk1C; - u8 filler20[0x4]; - int unk24; - u8 filler28[0x4]; + u32 unk20; + u32 unk24; + u32 unk28; int unk2C; u32 unk30; - u8 filler34[0x2]; + u16 unk34; u16 unk36; u8 filler38[0x2]; u16 unk3A; @@ -74,7 +75,10 @@ struct PokemonJump1 u16 unk4A; u8 unk4C; u8 unk4D; - u8 filler4E[0x6]; + u16 unk4E; + u8 unk50; + u8 unk51; + u8 filler52[0x2]; int unk54; int unk58; int unk5C; @@ -87,15 +91,15 @@ struct PokemonJump1 u16 unk72; u16 unk74; int unk78; - u8 unk7C[5]; + u8 unk7C[MAX_RFU_PLAYERS]; u8 filler81[0xA]; - u8 unk8B[5]; - u16 unk90[5]; - u16 unk9A[5]; + u8 unk8B[MAX_RFU_PLAYERS]; + u16 unk90[MAX_RFU_PLAYERS]; + u16 unk9A[MAX_RFU_PLAYERS]; void **unkA4; u8 fillerA8[0x8200]; - struct PokemonJump1_MonInfo unk82A8[5]; - struct PokemonJump1_82E4 unk82E4[5]; + struct PokemonJump1_MonInfo unk82A8[MAX_RFU_PLAYERS]; + struct PokemonJump1_82E4 unk82E4[MAX_RFU_PLAYERS]; struct PokemonJump1_82E4 *unk83AC; }; @@ -150,17 +154,20 @@ static bool32 sub_802BA58(void); static bool32 sub_802BB84(void); static bool32 sub_802BC60(void); static bool32 sub_802BD30(void); -void sub_802BD84(u8 taskId); -void sub_802BE60(TaskFunc func, u8 taskPriority); -void sub_802BE80(void); -void sub_802BEA0(void); -void sub_802BEE4(void); -void sub_802C0B8(void); -void sub_802C0E8(void); -void sub_802C114(void); -void sub_802C164(void); +static void sub_802BD84(u8 taskId); +static void sub_802BE60(TaskFunc func, u8 taskPriority); +static void sub_802BE80(void); +static void sub_802BEA0(void); +static void sub_802BEE4(void); +static int sub_802BF48(void); +static void sub_802BF7C(void); +static int sub_802C098(void); +static void sub_802C0B8(void); +static void sub_802C0E8(void); +static void sub_802C114(void); +static bool32 sub_802C130(u16); +static void sub_802C164(void); void sub_802C1DC(void); -bool32 sub_802C130(u16); void sub_802C260(void); void sub_802C270(void); void sub_802C43C(void); @@ -192,6 +199,8 @@ void sub_802DDCC(void); void sub_802DDE0(void); void sub_802DDF4(int); int sub_802DE08(void); +void sub_802E0AC(struct PokemonJump1_MonInfo *); +bool32 sub_802E0D0(int, struct PokemonJump1_MonInfo *); void sub_802E138(struct PokemonJump1_82E4 *, u8 *); bool32 sub_802E1BC(struct PokemonJump1_82E4 *, struct Unk802B078 *); void sub_802E234(struct PokemonJump1_82E4 *, u8 , u16); @@ -332,6 +341,9 @@ bool32 (* const gUnknown_082FB618[])(void) = sub_802B720, }; +extern const u16 gUnknown_082FB63C[]; +extern const u16 gUnknown_082FB64C[4]; + void sub_802A9A8(u16 partyIndex, MainCallback callback) { u8 taskId; @@ -408,7 +420,7 @@ void sub_802AA94(struct PokemonJump1 *arg0) sub_802AB98(); sub_802C0E8(); - for (i = 0; i < 5; i++) + for (i = 0; i < MAX_RFU_PLAYERS; i++) { arg0->unk7C[i] = 0; arg0->unk9A[i] = 0; @@ -421,7 +433,7 @@ void sub_802AB20(void) int i; s16 index; - for (i = 0; i < 5; i++) + for (i = 0; i < MAX_RFU_PLAYERS; i++) { index = sub_802AC00(gUnknown_02022CFC->unk82A8[i].species); gUnknown_02022CFC->unk82E4[i].unkC = gPkmnJumpSpecies[index].unk2; @@ -489,7 +501,7 @@ static void sub_802AB98(void) { int i; - for (i = 0; i < 5; i++) + for (i = 0; i < MAX_RFU_PLAYERS; i++) { gUnknown_02022CFC->unk82E4[i].unkE = 0; gUnknown_02022CFC->unk82E4[i].unk10 = 0; @@ -1464,3 +1476,223 @@ static bool32 sub_802BD30(void) return TRUE; } + +static void sub_802BD84(u8 taskId) +{ + int i; + s16 *taskData = gTasks[taskId].data; + struct PokemonJump1 *ptr = (struct PokemonJump1 *)GetWordTaskArg(taskId, 14); + + switch (taskData[0]) + { + case 0: + for (i = 0; i < MAX_RFU_PLAYERS; i++) + taskData[i + 2] = 0; + + taskData[0]++; + // fall through + case 1: + sub_802E0AC(&ptr->unk82A8[ptr->unk6]); + for (i = 0; i < MAX_RFU_PLAYERS; i++) + { + if (!taskData[i + 2] && sub_802E0D0(i, &ptr->unk82A8[i])) + { + StringCopy(ptr->unk82E4[i].unk1C, gLinkPlayers[i].name); + taskData[i + 2] = 1; + taskData[1]++; + if (taskData[1] == ptr->unk5) + { + sub_802AB20(); + DestroyTask(taskId); + break; + } + } + } + break; + } +} + +static void sub_802BE60(TaskFunc func, u8 taskPriority) +{ + u8 taskId = CreateTask(func, taskPriority); + SetWordTaskArg(taskId, 14, (u32)gUnknown_02022CFC); +} + +static void sub_802BE80(void) +{ + gUnknown_02022CFC->unk4A = 0; + gUnknown_02022CFC->unk14 = 6; + gUnknown_02022CFC->unk34 = 0; + gUnknown_02022CFC->unk1C = 0; + gUnknown_02022CFC->unk36 = 0; + gUnknown_02022CFC->unk10 = 0; +} + +static void sub_802BEA0(void) +{ + gUnknown_02022CFC->unk4A = 0; + gUnknown_02022CFC->unk34 = 0x6FF; + gUnknown_02022CFC->unk14 = 7; + gUnknown_02022CFC->unk36 = 0; + gUnknown_02022CFC->unk10 = 0; + gUnknown_02022CFC->unk51 = 0; + gUnknown_02022CFC->unk50 = 0; + gUnknown_02022CFC->unk20 = 0; + gUnknown_02022CFC->unk4E = 0; + gUnknown_02022CFC->unk6C = 0; + sub_802BF7C(); +} + +static void sub_802BEE4(void) +{ + if (gUnknown_02022CFC->unk46) + { + gUnknown_02022CFC->unk4A++; + gUnknown_02022CFC->unk34 += sub_802BF48(); + if (gUnknown_02022CFC->unk34 >= 0x9FF) + gUnknown_02022CFC->unk34 -= 0x9FF; + + gUnknown_02022CFC->unk18 = gUnknown_02022CFC->unk14; + gUnknown_02022CFC->unk14 = gUnknown_02022CFC->unk34 >> 8; + if (gUnknown_02022CFC->unk14 > 6 && gUnknown_02022CFC->unk18 < 7) + { + gUnknown_02022CFC->unk36++; + sub_802BF7C(); + } + } +} + +static int sub_802BF48(void) +{ + int result; + + if (gUnknown_02022CFC->unk10) + return 0; + + result = gUnknown_02022CFC->unk1C; + if (gUnknown_02022CFC->unk34 <= 0x5FF) + { + gUnknown_02022CFC->unk20 += 80; + result += gUnknown_02022CFC->unk20 >> 8; + } + + return result; +} + +static void sub_802BF7C(void) +{ + int var0; + + gUnknown_02022CFC->unk20 = 0; + if (gUnknown_02022CFC->unk4E) + { + gUnknown_02022CFC->unk4E--; + if (gUnknown_02022CFC->unk6C) + { + if (sub_802C098() % 4 != 0) + { + gUnknown_02022CFC->unk1C = gUnknown_02022CFC->unk28; + } + else + { + if (gUnknown_02022CFC->unk28 > 54) + gUnknown_02022CFC->unk1C = 30; + else + gUnknown_02022CFC->unk1C = 82; + } + } + } + else + { + if (!(gUnknown_02022CFC->unk50 & 8)) + { + gUnknown_02022CFC->unk28 = gUnknown_082FB63C[gUnknown_02022CFC->unk50] + (gUnknown_02022CFC->unk51 * 7); + gUnknown_02022CFC->unk4E = gUnknown_082FB64C[sub_802C098() % ARRAY_COUNT(gUnknown_082FB64C)] + 2; + gUnknown_02022CFC->unk50++; + } + else + { + if (gUnknown_02022CFC->unk50 == 8) + { + if (gUnknown_02022CFC->unk51 < 3) + gUnknown_02022CFC->unk51++; + else + gUnknown_02022CFC->unk6C = 1; + } + + var0 = gUnknown_082FB63C[15 - gUnknown_02022CFC->unk50]; + gUnknown_02022CFC->unk28 = var0 + (gUnknown_02022CFC->unk51 * 7); + if (++gUnknown_02022CFC->unk50 > 15) + { + if (sub_802C098() % 4 == 0) + gUnknown_02022CFC->unk28 -= 5; + + gUnknown_02022CFC->unk50 = 0; + } + } + + gUnknown_02022CFC->unk1C = gUnknown_02022CFC->unk28; + } +} + +static int sub_802C098(void) +{ + // The number 1103515245 comes from the example implementation of rand and srand + gUnknown_02022CFC->unk24 = gUnknown_02022CFC->unk24 * 1103515245 + 24691; + return gUnknown_02022CFC->unk24 >> 16; +} + +static void sub_802C0B8(void) +{ + gUnknown_02022CFC->unk10 = 1; + gUnknown_02022CFC->unk14 = 6; + gUnknown_02022CFC->unk34 = 0x5FF; + sub_802C270(); +} + +int sub_802C0DC(void) +{ + return gUnknown_02022CFC->unk10; +} + +static void sub_802C0E8(void) +{ + int i; + for (i = 0; i < MAX_RFU_PLAYERS; i++) + gUnknown_02022CFC->unk82E4[i].unk14 = 0; +} + +static void sub_802C114(void) +{ + gUnknown_02022CFC->unk83AC->unk10 = 0; + gUnknown_02022CFC->unk83AC->unk12 = 0; +} + +static bool32 sub_802C130(u16 arg0) +{ + if (gUnknown_02022CFC->unk82E4[gUnknown_02022CFC->unk6].unk10 == arg0) + return TRUE; + else + return FALSE; +} + +static void sub_802C164(void) +{ + gUnknown_02022CFC->unk83AC->unkE = gUnknown_02022CFC->unk4A; + gUnknown_02022CFC->unk83AC->unk12 = gUnknown_02022CFC->unk83AC->unk10; + gUnknown_02022CFC->unk83AC->unk10 = 1; +} + +void sub_802C18C(void) +{ + gUnknown_02022CFC->unk83AC->unk12 = gUnknown_02022CFC->unk83AC->unk10; + gUnknown_02022CFC->unk83AC->unk10 = 2; + gUnknown_02022CFC->unk83AC->unkE = gUnknown_02022CFC->unk4A; + gUnknown_02022CFC->unk83AC->unk14 = 2; +} + +void sub_802C1BC(void) +{ + gUnknown_02022CFC->unk83AC->unk12 = gUnknown_02022CFC->unk83AC->unk10; + gUnknown_02022CFC->unk83AC->unk10 = 0; +} From a65cffef42ff84f437675408895c91f15c6205ab Mon Sep 17 00:00:00 2001 From: Marcus Huderle Date: Wed, 10 Apr 2019 20:28:40 -0500 Subject: [PATCH 20/22] Decompile more pokemon_jump.c --- asm/pokemon_jump.s | 843 -------------------------------------------- data/pokemon_jump.s | 2 + src/pokemon_jump.c | 419 +++++++++++++++++++++- 3 files changed, 403 insertions(+), 861 deletions(-) diff --git a/asm/pokemon_jump.s b/asm/pokemon_jump.s index 108c3dbf1..423bb26eb 100755 --- a/asm/pokemon_jump.s +++ b/asm/pokemon_jump.s @@ -5,849 +5,6 @@ .text - thumb_func_start sub_802C1DC -sub_802C1DC: @ 802C1DC - push {r4,r5,lr} - ldr r4, =gUnknown_02022CFC - ldr r1, [r4] - ldr r0, [r1, 0x5C] - cmp r0, 0 - beq _0802C21C - ldr r0, [r1, 0x78] - bl sub_802DD64 - ldr r1, [r4] - movs r5, 0 - str r5, [r1, 0x5C] - adds r0, r1, 0 - adds r0, 0x4D - ldrb r0, [r0] - cmp r0, 0 - beq _0802C21C - adds r0, r1, 0 - adds r0, 0x71 - ldrb r0, [r0] - bl sub_802DCCC - ldr r1, =gUnknown_082FB654 - subs r0, 0x2 - lsls r0, 1 - adds r0, r1 - ldrh r0, [r0] - bl PlaySE - ldr r0, [r4] - adds r0, 0x4D - strb r5, [r0] -_0802C21C: - ldr r0, =gUnknown_02022CFC - ldr r0, [r0] - adds r0, 0x74 - ldrh r0, [r0] - bl sub_802DD74 - bl sub_802C280 - bl sub_802C240 - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_802C1DC - - thumb_func_start sub_802C240 -sub_802C240: @ 802C240 - push {lr} - ldr r0, =gUnknown_02022CFC - ldr r1, [r0] - adds r0, r1, 0 - adds r0, 0x46 - ldrb r0, [r0] - cmp r0, 0 - beq _0802C256 - ldr r0, [r1, 0x14] - bl sub_802DC9C -_0802C256: - pop {r0} - bx r0 - .pool - thumb_func_end sub_802C240 - - thumb_func_start sub_802C260 -sub_802C260: @ 802C260 - ldr r0, =gUnknown_02022CFC - ldr r0, [r0] - adds r0, 0x46 - movs r1, 0 - strb r1, [r0] - bx lr - .pool - thumb_func_end sub_802C260 - - thumb_func_start sub_802C270 -sub_802C270: @ 802C270 - ldr r0, =gUnknown_02022CFC - ldr r0, [r0] - adds r0, 0x46 - movs r1, 0x1 - strb r1, [r0] - bx lr - .pool - thumb_func_end sub_802C270 - - thumb_func_start sub_802C280 -sub_802C280: @ 802C280 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x4 - movs r6, 0 - ldr r2, =gUnknown_02022CFC - ldr r0, [r2] - ldrb r0, [r0, 0x5] - mov r9, r0 - movs r5, 0 - cmp r6, r9 - bge _0802C360 - mov r10, r2 - mov r8, r5 - movs r7, 0 -_0802C2A2: - mov r0, r10 - ldr r3, [r0] - adds r1, r3, r7 - ldr r2, =0x000082f4 - adds r0, r1, r2 - ldrh r2, [r0] - cmp r2, 0x1 - beq _0802C2D4 - cmp r2, 0x1 - bgt _0802C2C4 - cmp r2, 0 - beq _0802C2CA - b _0802C354 - .pool -_0802C2C4: - cmp r2, 0x2 - beq _0802C338 - b _0802C354 -_0802C2CA: - adds r0, r5, 0 - movs r1, 0 - bl sub_802DC80 - b _0802C354 -_0802C2D4: - ldr r0, =0x000082f6 - adds r4, r1, r0 - ldrh r0, [r4] - cmp r0, 0x1 - bne _0802C2F6 - ldr r0, =0x000082f2 - adds r0, r1 - adds r1, r3, 0 - adds r1, 0x9A - add r1, r8 - str r1, [sp] - ldrh r1, [r0] - mov r12, r1 - ldr r0, [sp] - ldrh r0, [r0] - cmp r12, r0 - beq _0802C31E -_0802C2F6: - ldrb r3, [r3, 0x6] - cmp r5, r3 - bne _0802C2FE - strh r2, [r4] -_0802C2FE: - orrs r6, r2 - mov r1, r10 - ldr r2, [r1] - ldr r1, =0x000082e8 - adds r0, r2, r1 - adds r0, r7 - ldr r1, =0x7fffffff - str r1, [r0] - adds r1, r2, 0 - adds r1, 0x9A - add r1, r8 - adds r2, r7 - ldr r0, =0x000082f2 - adds r2, r0 - ldrh r0, [r2] - strh r0, [r1] -_0802C31E: - adds r0, r5, 0 - bl sub_802C398 - b _0802C354 - .pool -_0802C338: - ldr r0, =0x000082f6 - adds r1, r0 - ldrh r0, [r1] - cmp r0, 0x2 - beq _0802C354 - ldrb r3, [r3, 0x6] - cmp r5, r3 - bne _0802C34A - strh r2, [r1] -_0802C34A: - orrs r6, r2 - lsls r0, r5, 24 - lsrs r0, 24 - bl sub_802DD88 -_0802C354: - movs r1, 0x2 - add r8, r1 - adds r7, 0x28 - adds r5, 0x1 - cmp r5, r9 - blt _0802C2A2 -_0802C360: - movs r0, 0x2 - ands r0, r6 - cmp r0, 0 - beq _0802C378 - movs r0, 0x83 - lsls r0, 1 - bl PlaySE - b _0802C386 - .pool -_0802C378: - movs r0, 0x1 - ands r6, r0 - cmp r6, 0 - beq _0802C386 - movs r0, 0xA - bl PlaySE -_0802C386: - add sp, 0x4 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end sub_802C280 - - thumb_func_start sub_802C398 -sub_802C398: @ 802C398 - push {r4-r6,lr} - adds r6, r0, 0 - ldr r0, =gUnknown_02022CFC - ldr r2, [r0] - ldr r0, [r2, 0x68] - cmp r0, 0 - bne _0802C432 - lsls r0, r6, 2 - adds r0, r6 - lsls r0, 3 - ldr r1, =0x000082e4 - adds r0, r1 - adds r5, r2, r0 - ldr r1, [r5, 0x4] - ldr r0, =0x7fffffff - cmp r1, r0 - beq _0802C3D0 - adds r0, r1, 0x1 - str r0, [r5, 0x4] - adds r3, r0, 0 - b _0802C3E8 - .pool -_0802C3D0: - adds r0, r2, 0 - adds r0, 0x4A - ldrh r1, [r0] - ldrh r0, [r5, 0xE] - subs r3, r1, r0 - ldr r0, =0x0000fde7 - cmp r3, r0 - ble _0802C3E6 - ldr r0, =0xffff0218 - adds r3, r0 - adds r3, r1 -_0802C3E6: - str r3, [r5, 0x4] -_0802C3E8: - cmp r3, 0x3 - ble _0802C432 - subs r3, 0x4 - cmp r3, 0x2F - bgt _0802C414 - ldr r2, =gUnknown_082FB65C - ldrh r1, [r5, 0xC] - lsls r0, r1, 1 - adds r0, r1 - lsls r0, 4 - adds r0, r3, r0 - adds r0, r2 - movs r4, 0 - ldrsb r4, [r0, r4] - b _0802C416 - .pool -_0802C414: - movs r4, 0 -_0802C416: - adds r1, r4, 0 - adds r0, r6, 0 - bl sub_802DC80 - cmp r4, 0 - bne _0802C430 - ldr r0, =gUnknown_02022CFC - ldr r0, [r0] - ldrb r0, [r0, 0x6] - cmp r6, r0 - bne _0802C430 - bl sub_802C1BC -_0802C430: - str r4, [r5] -_0802C432: - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_802C398 - - thumb_func_start sub_802C43C -sub_802C43C: @ 802C43C - push {r4,r5,lr} - ldr r5, =gUnknown_02022CFC - ldr r1, [r5] - ldr r0, [r1, 0x14] - cmp r0, 0x8 - bne _0802C4CE - ldr r0, [r1, 0x18] - cmp r0, 0x7 - bne _0802C4CE - ldr r4, [r1, 0x58] - cmp r4, 0 - bne _0802C46C - bl sub_802C780 - ldr r0, [r5] - str r4, [r0, 0x54] - movs r1, 0x1 - str r1, [r0, 0x58] - adds r0, 0x71 - strb r4, [r0] - b _0802C4CE - .pool -_0802C46C: - ldr r0, [r1, 0x54] - cmp r0, 0x5 - bne _0802C480 - ldrh r0, [r1, 0xC] - adds r0, 0x1 - strh r0, [r1, 0xC] - ldrh r0, [r1, 0xC] - bl sub_802C7A0 - b _0802C484 -_0802C480: - movs r0, 0 - strh r0, [r1, 0xC] -_0802C484: - ldr r4, =gUnknown_02022CFC - ldr r1, [r4] - ldr r0, [r1, 0x54] - cmp r0, 0x1 - ble _0802C49E - movs r0, 0x1 - str r0, [r1, 0x64] - adds r0, r1, 0 - adds r0, 0x86 - adds r1, 0x81 - movs r2, 0x5 - bl memcpy -_0802C49E: - bl sub_802C780 - ldr r0, [r4] - movs r2, 0 - str r2, [r0, 0x54] - movs r1, 0x1 - str r1, [r0, 0x58] - adds r0, 0x71 - strb r2, [r0] - ldr r0, [r4] - adds r2, r0, 0 - adds r2, 0x74 - ldrh r1, [r2] - ldr r0, =0x0000270e - cmp r1, r0 - bhi _0802C4C2 - adds r0, r1, 0x1 - strh r0, [r2] -_0802C4C2: - movs r0, 0xA - bl sub_802C688 - movs r0, 0x3 - bl sub_802AE14 -_0802C4CE: - ldr r4, =gUnknown_02022CFC - ldr r0, [r4] - ldr r0, [r0, 0x64] - cmp r0, 0 - beq _0802C504 - bl sub_802C618 - cmp r0, 0x1 - beq _0802C4E8 - ldr r0, [r4] - ldr r0, [r0, 0x14] - cmp r0, 0 - bne _0802C504 -_0802C4E8: - ldr r0, [r4] - adds r0, 0x86 - bl sub_802C73C - bl sub_802C790 - bl sub_802C688 - movs r0, 0x3 - bl sub_802AE14 - ldr r1, [r4] - movs r0, 0 - str r0, [r1, 0x64] -_0802C504: - ldr r4, =gUnknown_02022CFC - ldr r0, [r4] - ldr r0, [r0, 0x58] - cmp r0, 0 - beq _0802C52A - bl sub_802C6B0 - adds r2, r0, 0 - ldr r1, [r4] - ldr r0, [r1, 0x54] - cmp r2, r0 - ble _0802C52A - str r2, [r1, 0x54] - adds r0, r1, 0 - adds r0, 0x81 - adds r1, 0x7C - movs r2, 0x5 - bl memcpy -_0802C52A: - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_802C43C - - thumb_func_start sub_802C538 -sub_802C538: @ 802C538 - push {r4,r5,lr} - ldr r5, =gUnknown_02022CFC - ldr r1, [r5] - ldr r0, [r1, 0x14] - cmp r0, 0x6 - bne _0802C582 - ldr r4, =0x000083ac - adds r0, r1, r4 - ldr r1, [r0] - ldr r0, [r1] - cmp r0, 0 - bne _0802C582 - ldrh r0, [r1, 0x12] - cmp r0, 0x1 - bne _0802C578 - bl sub_802C0DC - adds r1, r0, 0 - cmp r1, 0x1 - bne _0802C578 - ldr r0, [r5] - adds r0, r4 - ldr r0, [r0] - str r1, [r0, 0x14] - b _0802C582 - .pool -_0802C574: - movs r0, 0 - b _0802C5CA -_0802C578: - bl sub_802C18C - movs r0, 0x3 - bl sub_802AE14 -_0802C582: - ldr r0, =gUnknown_02022CFC - ldr r1, [r0] - ldr r0, [r1, 0x14] - cmp r0, 0x7 - bne _0802C5A8 - ldr r0, [r1, 0x18] - cmp r0, 0x6 - bne _0802C5A8 - ldr r2, =0x000083ac - adds r0, r1, r2 - ldr r1, [r0] - ldrh r0, [r1, 0x10] - cmp r0, 0x2 - beq _0802C5A8 - movs r0, 0x1 - str r0, [r1, 0x14] - movs r0, 0x3 - bl sub_802AE14 -_0802C5A8: - movs r2, 0 - ldr r0, =gUnknown_02022CFC - ldr r0, [r0] - ldrb r1, [r0, 0x5] - cmp r2, r1 - bge _0802C5C8 - adds r3, r1, 0 - ldr r4, =0x000082f4 - adds r1, r0, r4 -_0802C5BA: - ldrh r0, [r1] - cmp r0, 0x2 - beq _0802C574 - adds r1, 0x28 - adds r2, 0x1 - cmp r2, r3 - blt _0802C5BA -_0802C5C8: - movs r0, 0x1 -_0802C5CA: - pop {r4,r5} - pop {r1} - bx r1 - .pool - thumb_func_end sub_802C538 - - thumb_func_start sub_802C5DC -sub_802C5DC: @ 802C5DC - push {r4,lr} - ldr r0, =gUnknown_02022CFC - ldr r0, [r0] - ldrb r3, [r0, 0x5] - movs r4, 0 - cmp r4, r3 - bge _0802C600 - ldr r1, =0x000082f8 - adds r2, r0, r1 - adds r1, r3, 0 -_0802C5F0: - ldr r0, [r2] - cmp r0, 0 - beq _0802C5F8 - adds r4, 0x1 -_0802C5F8: - adds r2, 0x28 - subs r1, 0x1 - cmp r1, 0 - bne _0802C5F0 -_0802C600: - movs r0, 0 - cmp r4, r3 - bne _0802C608 - movs r0, 0x1 -_0802C608: - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end sub_802C5DC - - thumb_func_start sub_802C618 -sub_802C618: @ 802C618 - push {r4,lr} - movs r2, 0 - ldr r0, =gUnknown_02022CFC - ldr r0, [r0] - ldrb r1, [r0, 0x5] - cmp r2, r1 - bge _0802C648 - adds r3, r1, 0 - ldr r4, =0x000082f8 - adds r1, r0, r4 -_0802C62C: - ldr r0, [r1] - cmp r0, 0x1 - beq _0802C640 - movs r0, 0 - b _0802C64A - .pool -_0802C640: - adds r1, 0x28 - adds r2, 0x1 - cmp r2, r3 - blt _0802C62C -_0802C648: - movs r0, 0x1 -_0802C64A: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_802C618 - - thumb_func_start sub_802C650 -sub_802C650: @ 802C650 - push {lr} - ldr r0, =gUnknown_02022CFC - ldr r1, [r0] - adds r0, r1, 0 - adds r0, 0x45 - ldrb r0, [r0] - cmp r0, 0x1 - bne _0802C668 -_0802C660: - movs r0, 0 - b _0802C684 - .pool -_0802C668: - movs r2, 0x1 - ldrb r0, [r1, 0x5] - cmp r2, r0 - bge _0802C682 - adds r3, r0, 0 - adds r1, 0x92 -_0802C674: - ldrh r0, [r1] - cmp r0, 0x1 - beq _0802C660 - adds r1, 0x2 - adds r2, 0x1 - cmp r2, r3 - blt _0802C674 -_0802C682: - movs r0, 0x1 -_0802C684: - pop {r1} - bx r1 - thumb_func_end sub_802C650 - - thumb_func_start sub_802C688 -sub_802C688: @ 802C688 - push {lr} - ldr r1, =gUnknown_02022CFC - ldr r2, [r1] - ldr r1, [r2, 0x78] - adds r1, r0 - str r1, [r2, 0x78] - movs r0, 0x1 - str r0, [r2, 0x5C] - ldr r0, =0x00018695 - cmp r1, r0 - bls _0802C6A2 - adds r0, 0x1 - str r0, [r2, 0x78] -_0802C6A2: - pop {r0} - bx r0 - .pool - thumb_func_end sub_802C688 - - thumb_func_start sub_802C6B0 -sub_802C6B0: @ 802C6B0 - push {r4-r7,lr} - movs r5, 0 - ldr r1, =gUnknown_02022CFC - ldr r0, [r1] - ldrb r4, [r0, 0x5] - movs r2, 0 - cmp r5, r4 - bge _0802C702 - mov r12, r1 - movs r3, 0 - ldr r7, =0x000082e4 - movs r6, 0x1E - negs r6, r6 -_0802C6CA: - mov r0, r12 - ldr r1, [r0] - adds r0, r1, r7 - adds r0, r3 - ldr r0, [r0] - cmp r0, r6 - bne _0802C6F0 - adds r0, r1, 0 - adds r0, 0x7C - adds r0, r2 - movs r1, 0x1 - strb r1, [r0] - adds r5, 0x1 - b _0802C6FA - .pool -_0802C6F0: - adds r0, r1, 0 - adds r0, 0x7C - adds r0, r2 - movs r1, 0 - strb r1, [r0] -_0802C6FA: - adds r3, 0x28 - adds r2, 0x1 - cmp r2, r4 - blt _0802C6CA -_0802C702: - adds r0, r5, 0 - pop {r4-r7} - pop {r1} - bx r1 - thumb_func_end sub_802C6B0 - - thumb_func_start sub_802C70C -sub_802C70C: @ 802C70C - push {lr} - movs r2, 0 - ldr r1, =gUnknown_03005000 - ldr r3, =0x000009e6 - adds r0, r1, r3 - ldrb r0, [r0] - cmp r0, 0 - bne _0802C728 - ldr r3, =0x00000c1a - adds r0, r1, r3 - ldrb r0, [r0] - cmp r0, 0 - bne _0802C728 - movs r2, 0x1 -_0802C728: - adds r0, r2, 0 - pop {r1} - bx r1 - .pool - thumb_func_end sub_802C70C - - thumb_func_start sub_802C73C -sub_802C73C: @ 802C73C - push {r4-r6,lr} - adds r4, r0, 0 - movs r1, 0 - movs r2, 0 - movs r3, 0 - ldr r6, =gUnknown_02022CFC - movs r5, 0x1 -_0802C74A: - adds r0, r4, r1 - ldrb r0, [r0] - cmp r0, 0 - beq _0802C75A - adds r0, r5, 0 - lsls r0, r1 - orrs r2, r0 - adds r3, 0x1 -_0802C75A: - adds r1, 0x1 - cmp r1, 0x4 - ble _0802C74A - ldr r0, [r6] - adds r0, 0x71 - strb r2, [r0] - cmp r2, 0 - beq _0802C772 - ldr r0, [r6] - adds r0, 0x4D - movs r1, 0x1 - strb r1, [r0] -_0802C772: - adds r0, r3, 0 - pop {r4-r6} - pop {r1} - bx r1 - .pool - thumb_func_end sub_802C73C - - thumb_func_start sub_802C780 -sub_802C780: @ 802C780 - ldr r0, =gUnknown_02022CFC - ldr r0, [r0] - adds r0, 0x44 - movs r1, 0 - strb r1, [r0] - bx lr - .pool - thumb_func_end sub_802C780 - - thumb_func_start sub_802C790 -sub_802C790: @ 802C790 - ldr r1, =gUnknown_082FB6EC - lsls r0, 2 - adds r0, r1 - ldr r0, [r0] - bx lr - .pool - thumb_func_end sub_802C790 - - thumb_func_start sub_802C7A0 -sub_802C7A0: @ 802C7A0 - push {lr} - lsls r0, 16 - lsrs r1, r0, 16 - ldr r0, =gUnknown_02022CFC - ldr r0, [r0] - ldrh r2, [r0, 0xE] - cmp r1, r2 - bls _0802C7B2 - strh r1, [r0, 0xE] -_0802C7B2: - pop {r0} - bx r0 - .pool - thumb_func_end sub_802C7A0 - - thumb_func_start sub_802C7BC -sub_802C7BC: @ 802C7BC - push {lr} - ldr r0, =gUnknown_02022CFC - ldr r0, [r0] - ldr r1, =gUnknown_082FB714 - ldr r2, [r0, 0x78] - ldr r0, [r1] - cmp r2, r0 - bcs _0802C7D8 - movs r0, 0 - b _0802C7DA - .pool -_0802C7D8: - movs r0, 0x1 -_0802C7DA: - pop {r1} - bx r1 - thumb_func_end sub_802C7BC - - thumb_func_start sub_802C7E0 -sub_802C7E0: @ 802C7E0 - push {r4,lr} - bl sub_802C818 - adds r4, r0, 0 - lsls r4, 16 - lsrs r4, 16 - bl sub_802C838 - lsls r0, 16 - lsrs r0, 4 - ldr r1, =0x00000fff - ands r4, r1 - orrs r0, r4 - lsls r0, 16 - lsrs r0, 16 - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end sub_802C7E0 - - thumb_func_start sub_802C808 -sub_802C808: @ 802C808 - lsls r0, 16 - lsrs r3, r0, 28 - strh r3, [r2] - lsls r0, 4 - lsrs r0, 20 - strh r0, [r1] - bx lr - thumb_func_end sub_802C808 - - thumb_func_start sub_802C818 -sub_802C818: @ 802C818 - push {lr} - bl Random - lsls r0, 16 - movs r1, 0xE0 - lsls r1, 11 - ands r1, r0 - ldr r0, =gUnknown_082FB704 - lsrs r1, 15 - adds r1, r0 - ldrh r0, [r1] - pop {r1} - bx r1 - .pool - thumb_func_end sub_802C818 - thumb_func_start sub_802C838 sub_802C838: @ 802C838 push {r4-r6,lr} diff --git a/data/pokemon_jump.s b/data/pokemon_jump.s index 362965053..b10c37600 100755 --- a/data/pokemon_jump.s +++ b/data/pokemon_jump.s @@ -24,12 +24,14 @@ gUnknown_082FB65C:: @ 82FB65C .byte 0xee, 0xef, 0xf1, 0xf3, 0xf5, 0xf8, 0xfa, 0xfc .byte 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + .byte 0xfd, 0xfa, 0xf7, 0xf5, 0xf2, 0xf0, 0xee, 0xec .byte 0xea, 0xe8, 0xe6, 0xe4, 0xe3, 0xe2, 0xe2, 0xe4 .byte 0xe6, 0xe8, 0xea, 0xec, 0xee, 0xf0, 0xf2, 0xf5 .byte 0xf7, 0xfa, 0xfc, 0xff, 0x00, 0x00, 0x00, 0x00 .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + .byte 0xfd, 0xfa, 0xf7, 0xf5, 0xf3, 0xf1, 0xef, 0xed .byte 0xeb, 0xe9, 0xe7, 0xe5, 0xe4, 0xe3, 0xe2, 0xe2 .byte 0xe2, 0xe2, 0xe3, 0xe3, 0xe4, 0xe4, 0xe5, 0xe5 diff --git a/src/pokemon_jump.c b/src/pokemon_jump.c index d893768f9..7af1d496a 100755 --- a/src/pokemon_jump.c +++ b/src/pokemon_jump.c @@ -2,6 +2,7 @@ #include "alloc.h" #include "item.h" #include "link.h" +#include "link_rfu.h" #include "main.h" #include "menu.h" #include "palette.h" @@ -90,9 +91,10 @@ struct PokemonJump1 u8 unk71; u16 unk72; u16 unk74; - int unk78; + u32 unk78; u8 unk7C[MAX_RFU_PLAYERS]; - u8 filler81[0xA]; + u8 unk81[MAX_RFU_PLAYERS]; + u8 unk86[MAX_RFU_PLAYERS]; u8 unk8B[MAX_RFU_PLAYERS]; u16 unk90[MAX_RFU_PLAYERS]; u16 unk9A[MAX_RFU_PLAYERS]; @@ -167,18 +169,31 @@ static void sub_802C0E8(void); static void sub_802C114(void); static bool32 sub_802C130(u16); static void sub_802C164(void); -void sub_802C1DC(void); -void sub_802C260(void); -void sub_802C270(void); -void sub_802C43C(void); -void sub_802C808(u16, u16 *, u16 *); -bool32 sub_802C538(void); -bool32 sub_802C650(void); -bool32 sub_802C5DC(void); -bool32 sub_802C70C(void); -bool32 sub_802C7BC(void); -u16 sub_802C7E0(void); +static void sub_802C1DC(void); +static void sub_802C240(void); +static void sub_802C260(void); +static void sub_802C270(void); +static void sub_802C280(void); +static void sub_802C398(int); +static void sub_802C43C(void); +static bool32 sub_802C538(void); +static bool32 sub_802C5DC(void); +static bool32 sub_802C618(void); +static bool32 sub_802C650(void); +static void sub_802C688(int); +static int sub_802C6B0(void); +static bool32 sub_802C70C(void); +static int sub_802C73C(u8 *); +static void sub_802C780(void); +static int sub_802C790(int); +static void sub_802C7A0(u16); +static bool32 sub_802C7BC(void); +static u16 sub_802C7E0(void); +static void sub_802C808(u16, u16 *, u16 *); +static u16 sub_802C818(void); +u16 sub_802C838(void); u16 sub_802C880(u16, u16); +void sub_802DC9C(u32); void sub_802D074(void *); void sub_802D0AC(void); void sub_802D0C8(int); @@ -190,9 +205,13 @@ void sub_802D884(u16); void sub_802D8FC(u16); bool32 sub_802D974(void); void sub_802DA14(void); +void sub_802DC80(int, s8); +void sub_802DD88(u8); bool32 sub_802DA44(void); void sub_802DD64(int); s8 sub_802DA8C(void); +int sub_802DCCC(u8); +void sub_802DD74(u16); void sub_802DDA0(u8); int sub_802DDB8(int); void sub_802DDCC(void); @@ -343,6 +362,11 @@ bool32 (* const gUnknown_082FB618[])(void) = extern const u16 gUnknown_082FB63C[]; extern const u16 gUnknown_082FB64C[4]; +extern const u16 gUnknown_082FB654[]; +extern s8 gUnknown_082FB65C[][48]; +extern int gUnknown_082FB6EC[]; +extern int gUnknown_082FB714[]; +extern u16 gUnknown_082FB704[8]; void sub_802A9A8(u16 partyIndex, MainCallback callback) { @@ -383,7 +407,7 @@ static void sub_802AA60(struct PokemonJump1 *arg0) arg0->unk72 = 0; sub_802AB20(); sub_802AA94(arg0); - if (arg0->unk5 == 5) + if (arg0->unk5 == MAX_RFU_PLAYERS) sub_802E3A8(); } @@ -614,7 +638,7 @@ static void sub_802ACA0(u8 taskId) } } -void sub_802AE14(int arg0) +static void sub_802AE14(int arg0) { if (arg0 == 0) { @@ -1650,7 +1674,7 @@ static void sub_802C0B8(void) sub_802C270(); } -int sub_802C0DC(void) +static int sub_802C0DC(void) { return gUnknown_02022CFC->unk10; } @@ -1683,7 +1707,7 @@ static void sub_802C164(void) gUnknown_02022CFC->unk83AC->unk10 = 1; } -void sub_802C18C(void) +static void sub_802C18C(void) { gUnknown_02022CFC->unk83AC->unk12 = gUnknown_02022CFC->unk83AC->unk10; gUnknown_02022CFC->unk83AC->unk10 = 2; @@ -1691,8 +1715,367 @@ void sub_802C18C(void) gUnknown_02022CFC->unk83AC->unk14 = 2; } -void sub_802C1BC(void) +static void sub_802C1BC(void) { gUnknown_02022CFC->unk83AC->unk12 = gUnknown_02022CFC->unk83AC->unk10; gUnknown_02022CFC->unk83AC->unk10 = 0; } + +static void sub_802C1DC(void) +{ + if (gUnknown_02022CFC->unk5C) + { + sub_802DD64(gUnknown_02022CFC->unk78); + gUnknown_02022CFC->unk5C = 0; + if (gUnknown_02022CFC->unk4D) + { + int index = sub_802DCCC(gUnknown_02022CFC->unk71); + PlaySE(gUnknown_082FB654[index - 2]); + gUnknown_02022CFC->unk4D = 0; + } + } + + sub_802DD74(gUnknown_02022CFC->unk74); + sub_802C280(); + sub_802C240(); +} + +static void sub_802C240(void) +{ + if (gUnknown_02022CFC->unk46) + sub_802DC9C(gUnknown_02022CFC->unk14); +} + +static void sub_802C260(void) +{ + gUnknown_02022CFC->unk46 = 0; +} + +static void sub_802C270(void) +{ + gUnknown_02022CFC->unk46 = 1; +} + +static void sub_802C280(void) +{ + int i; + int whichSound = 0; + int numLinkPlayers = gUnknown_02022CFC->unk5; + + for (i = 0; i < numLinkPlayers; i++) + { + switch (gUnknown_02022CFC->unk82E4[i].unk10) + { + case 0: + sub_802DC80(i, 0); + break; + case 1: + if (gUnknown_02022CFC->unk82E4[i].unk12 != 1 || gUnknown_02022CFC->unk82E4[i].unkE != gUnknown_02022CFC->unk9A[i]) + { + if (i == gUnknown_02022CFC->unk6) + gUnknown_02022CFC->unk82E4[i].unk12 = 1; + + whichSound |= 0x1; + gUnknown_02022CFC->unk82E4[i].unk4 = 0x7FFFFFFF; + gUnknown_02022CFC->unk9A[i] = gUnknown_02022CFC->unk82E4[i].unkE; + } + + sub_802C398(i); + break; + case 2: + if (gUnknown_02022CFC->unk82E4[i].unk12 != 2) + { + if (i == gUnknown_02022CFC->unk6) + gUnknown_02022CFC->unk82E4[i].unk12 = 2; + + whichSound |= 0x2; + sub_802DD88(i); + } + break; + } + } + + if (whichSound & 0x2) + PlaySE(SE_RG_NAWAMISS); + else if (whichSound & 0x1) + PlaySE(SE_DANSA); +} + +static void sub_802C398(int multiplayerId) +{ + int var0; + int var1; + struct PokemonJump1_82E4 *player; + + if (gUnknown_02022CFC->unk68) + return; + + player = &gUnknown_02022CFC->unk82E4[multiplayerId]; + if (player->unk4 != 0x7FFFFFFF) + { + player->unk4++; + var0 = player->unk4; + } + else + { + var0 = gUnknown_02022CFC->unk4A - player->unkE; + if (var0 >= 65000) + { + var0 -= 65000; + var0 += gUnknown_02022CFC->unk4A; + } + + player->unk4 = var0; + } + + if (var0 < 4) + return; + + var0 -= 4; + if (var0 < 48) + var1 = gUnknown_082FB65C[player->unkC][var0]; + else + var1 = 0; + + sub_802DC80(multiplayerId, var1); + if (!var1 && multiplayerId == gUnknown_02022CFC->unk6) + sub_802C1BC(); + + player->unk0 = var1; +} + +static void sub_802C43C(void) +{ + if (gUnknown_02022CFC->unk14 == 8 && gUnknown_02022CFC->unk18 == 7) + { + if (gUnknown_02022CFC->unk58 == 0) + { + sub_802C780(); + gUnknown_02022CFC->unk54 = 0; + gUnknown_02022CFC->unk58 = 1; + gUnknown_02022CFC->unk71 = 0; + } + else + { + if (gUnknown_02022CFC->unk54 == 5) + { + gUnknown_02022CFC->unkC++; + sub_802C7A0(gUnknown_02022CFC->unkC); + } + else + { + gUnknown_02022CFC->unkC = 0; + } + + if (gUnknown_02022CFC->unk54 > 1) + { + gUnknown_02022CFC->unk64 = 1; + memcpy(gUnknown_02022CFC->unk86, gUnknown_02022CFC->unk81, sizeof(u8) * MAX_RFU_PLAYERS); + } + + sub_802C780(); + gUnknown_02022CFC->unk54 = 0; + gUnknown_02022CFC->unk58 = 1; + gUnknown_02022CFC->unk71 = 0; + if (gUnknown_02022CFC->unk74 < 9999) + gUnknown_02022CFC->unk74++; + + sub_802C688(10); + sub_802AE14(3); + } + } + + if (gUnknown_02022CFC->unk64 && (sub_802C618() == TRUE || !gUnknown_02022CFC->unk14)) + { + int var0 = sub_802C73C(gUnknown_02022CFC->unk86); + sub_802C688(sub_802C790(var0)); + sub_802AE14(3); + gUnknown_02022CFC->unk64 = 0; + } + + if (gUnknown_02022CFC->unk58) + { + int var1 = sub_802C6B0(); + if (var1 > gUnknown_02022CFC->unk54) + { + gUnknown_02022CFC->unk54 = var1; + memcpy(gUnknown_02022CFC->unk81, gUnknown_02022CFC->unk7C, sizeof(u8) * MAX_RFU_PLAYERS); + } + } +} + +static bool32 sub_802C538(void) +{ + int i; + + if (gUnknown_02022CFC->unk14 == 6 && !gUnknown_02022CFC->unk83AC->unk0) + { + if (gUnknown_02022CFC->unk83AC->unk12 == 1 && sub_802C0DC() == 1) + { + gUnknown_02022CFC->unk83AC->unk14 = 1; + } + else + { + sub_802C18C(); + sub_802AE14(3); + } + } + + if (gUnknown_02022CFC->unk14 == 7 + && gUnknown_02022CFC->unk18 == 6 + && gUnknown_02022CFC->unk83AC->unk10 != 2) + { + gUnknown_02022CFC->unk83AC->unk14 = 1; + sub_802AE14(3); + } + + for (i = 0; i < gUnknown_02022CFC->unk5; i++) + { + if (gUnknown_02022CFC->unk82E4[i].unk10 == 2) + return FALSE; + } + + return TRUE; +} + +static bool32 sub_802C5DC(void) +{ + int i; + int numPlayers = gUnknown_02022CFC->unk5; + int count = 0; + for (i = 0; i < numPlayers; i++) + { + if (gUnknown_02022CFC->unk82E4[i].unk14) + count++; + } + + return count == numPlayers; +} + +static bool32 sub_802C618(void) +{ + int i; + for (i = 0; i < gUnknown_02022CFC->unk5; i++) + { + if (gUnknown_02022CFC->unk82E4[i].unk14 != 1) + return FALSE; + } + + return TRUE; +} + +static bool32 sub_802C650(void) +{ + int i; + + if (gUnknown_02022CFC->unk45 == 1) + return FALSE; + + for (i = 1; i < gUnknown_02022CFC->unk5; i++) + { + if (gUnknown_02022CFC->unk90[i] == 1) + return FALSE; + } + + return TRUE; +} + +static void sub_802C688(int arg0) +{ + gUnknown_02022CFC->unk78 += arg0; + gUnknown_02022CFC->unk5C = 1; + if (gUnknown_02022CFC->unk78 >= 99990) + gUnknown_02022CFC->unk78 = 99990; +} + +static int sub_802C6B0(void) +{ + int i; + int count = 0; + int numPlayers = gUnknown_02022CFC->unk5; + + for (i = 0; i < numPlayers; i++) + { + if (gUnknown_02022CFC->unk82E4[i].unk0 == -30) + { + gUnknown_02022CFC->unk7C[i] = 1; + count++; + } + else + { + gUnknown_02022CFC->unk7C[i] = 0; + } + } + + return count; +} + +static bool32 sub_802C70C(void) +{ + return !gUnknown_03005000.unk_124.unk_8c2 && !gUnknown_03005000.unk_9e8.unk_232; +} + +static int sub_802C73C(u8 *arg0) +{ + int i; + int flags; + int count; + + for (i = 0, flags = 0, count = 0; i < MAX_RFU_PLAYERS; i++) + { + if (arg0[i]) + { + flags |= 1 << i; + count++; + } + } + + gUnknown_02022CFC->unk71 = flags; + if (flags) + gUnknown_02022CFC->unk4D = 1; + + return count; +} + +static void sub_802C780(void) +{ + gUnknown_02022CFC->unk44 = 0; +} + +static int sub_802C790(int arg0) +{ + return gUnknown_082FB6EC[arg0]; +} + +static void sub_802C7A0(u16 arg0) +{ + if (arg0 > gUnknown_02022CFC->unkE) + gUnknown_02022CFC->unkE = arg0; +} + +static bool32 sub_802C7BC(void) +{ + if (gUnknown_02022CFC->unk78 >= gUnknown_082FB714[0]) + return TRUE; + else + return FALSE; +} + +static u16 sub_802C7E0(void) +{ + u16 lo = sub_802C818(); + u16 hi = sub_802C838(); + return (hi << 12) | (lo & 0xFFF); +} + +static void sub_802C808(u16 arg0, u16 *arg1, u16 *arg2) +{ + *arg2 = arg0 >> 12; + *arg1 = arg0 & 0xFFF; +} + +static u16 sub_802C818(void) +{ + u16 index = Random() % ARRAY_COUNT(gUnknown_082FB704); + return gUnknown_082FB704[index]; +} From 5bc640da9b754e3eae70bb82288c7e86dd5b29de Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Wed, 10 Apr 2019 20:49:10 +0200 Subject: [PATCH 21/22] nonmatchings --- src/battle_anim_effects_2.c | 81 +------ src/berry_crush.c | 2 +- src/contest_link_80F57C4.c | 458 +++++++----------------------------- 3 files changed, 99 insertions(+), 442 deletions(-) diff --git a/src/battle_anim_effects_2.c b/src/battle_anim_effects_2.c index 580b13864..65cc55604 100755 --- a/src/battle_anim_effects_2.c +++ b/src/battle_anim_effects_2.c @@ -1734,90 +1734,25 @@ void sub_8103FE8(struct Sprite *sprite) sprite->callback = sub_8104018; } -#ifdef NONMATCHING static void sub_8104018(struct Sprite *sprite) { - u16 r7; - u16 r5; + u16 id, val; int i; + if (++sprite->data[1] == 2) { sprite->data[1] = 0; - r5 = sprite->data[0]; - r7 = gPlttBufferFaded[8 + r5]; - for (i = 0; i < 8; i++) - { - gPlttBufferFaded[i + r5 + 8] = gPlttBufferFaded[i + r5 + 9]; - } - gPlttBufferFaded[r5 + 15] = r7; + id = sprite->data[0]; + val = gPlttBufferFaded[8 + id]; + for (i = 8; i < 16; i++) + gPlttBufferFaded[i + id] = gPlttBufferFaded[i + id + 1]; + + gPlttBufferFaded[id + 15] = val; if (++sprite->data[2] == 24) DestroyAnimSprite(sprite); } } -#else -NAKED -static void sub_8104018(struct Sprite *sprite) -{ - asm(".syntax unified\n\ - push {r4-r7,lr}\n\ - adds r4, r0, 0\n\ - ldrh r0, [r4, 0x30]\n\ - adds r0, 0x1\n\ - strh r0, [r4, 0x30]\n\ - lsls r0, 16\n\ - asrs r0, 16\n\ - cmp r0, 0x2\n\ - bne _0810407C\n\ - movs r0, 0\n\ - strh r0, [r4, 0x30]\n\ - ldrh r5, [r4, 0x2E]\n\ - ldr r1, =gPlttBufferFaded\n\ - adds r0, r5, 0\n\ - adds r0, 0x8\n\ - lsls r0, 1\n\ - adds r0, r1 \n\ - ldrh r7, [r0]\n\ - adds r6, r1, 0\n\ - adds r1, r5, 0\n\ - adds r1, 0x9\n\ - lsls r0, r5, 1\n\ - adds r0, r6\n\ - adds r2, r0, 0\n\ - adds r2, 0x10\n\ - movs r3, 0x7\n\ - lsls r1, 1\n\ - adds r1, r6\n\ -_08104050:\n\ - ldrh r0, [r1]\n\ - strh r0, [r2]\n\ - adds r1, 0x2\n\ - adds r2, 0x2\n\ - subs r3, 0x1\n\ - cmp r3, 0\n\ - bge _08104050\n\ - adds r0, r5, 0\n\ - adds r0, 0xF\n\ - lsls r0, 1\n\ - adds r0, r6\n\ - strh r7, [r0]\n\ - ldrh r0, [r4, 0x32]\n\ - adds r0, 0x1\n\ - strh r0, [r4, 0x32]\n\ - lsls r0, 16\n\ - asrs r0, 16\n\ - cmp r0, 0x18\n\ - bne _0810407C\n\ - adds r0, r4, 0\n\ - bl DestroyAnimSprite\n\ -_0810407C:\n\ - pop {r4-r7}\n\ - pop {r0}\n\ - bx r0\n\ - .pool\n\ -.syntax divided\n"); -} -#endif void sub_8104088(struct Sprite *sprite) { diff --git a/src/berry_crush.c b/src/berry_crush.c index 8efb5906b..a5d964cc9 100755 --- a/src/berry_crush.c +++ b/src/berry_crush.c @@ -337,7 +337,7 @@ void sub_8020FC4(struct BerryCrushGame *arg0) for (i = 0; i < arg0->unk9; i++) StringCopy(arg0->unk84.players[i].unk14, gLinkPlayers[i].name); - + for (; i < 5; i++) { memset(arg0->unk84.players[i].unk14, 1, PLAYER_NAME_LENGTH); diff --git a/src/contest_link_80F57C4.c b/src/contest_link_80F57C4.c index aa3c67050..bae7859b5 100644 --- a/src/contest_link_80F57C4.c +++ b/src/contest_link_80F57C4.c @@ -121,7 +121,7 @@ static void sub_80F5F30(u8); static void sub_80F5F74(u8); static void sub_80F7144(void); static void sub_80F68F0(u8); -s16 sub_80F6B78(const u8 *, u8); +s32 sub_80F6B78(const u8 *, u8); static void sub_80F6E9C(s16, u16, u16, u16); static void sub_80F6058(u8); static void sub_80F7A80(u8, u8); @@ -919,39 +919,76 @@ static void sub_80F6AE8(void) } } -// s16 sub_80F6B78(const u8 *text, u8 spriteId) -// { -// int i; -// int origWidth, strWidth; -// const u8 *r8; -// u8 sp10[0x10]; -// struct WindowTemplate windowTemplate; -// int spC; -// u8 *windowTileData; -// u8 windowId; +// Functionally equivalent, the same except compiler generated variables from +// src are placed on different stack positions. -// memset(windowTemplate, 0, sizeof(*windowTemplate)); -// windowTemplate.width = 30; -// windowTemplate.height = 2; -// windowId = AddWindow(&windowTemplate); -// FillWindowPixelBuffer(windowId, PIXEL_FILL(1)); -// origWidth = GetStringWidth(1, text, 0) + 9; -// strWidth = origWidth; -// if (strWidth < 0) -// strWidth += 7; +#ifdef NONMATCHING +s32 sub_80F6B78(const u8 *text, u8 spriteId) +{ + u8 *windowTilesPtr; + u16 windowId; + int origWidth; + struct WindowTemplate windowTemplate; + int strWidth; + u8 *spriteTilePtrs[4]; + u8 *dst; + int i; + struct Sprite *sprite; + const u8 *src; // The culprit. -// strWidth >>= 3; -// if (strWidth > 30) -// strWidth = 30; + memset(&windowTemplate, 0, sizeof(windowTemplate)); + windowTemplate.width = 30; + windowTemplate.height = 2; + windowId = AddWindow(&windowTemplate); + FillWindowPixelBuffer(windowId, PIXEL_FILL(1)); -// AddTextPrinterParameterized3(windowId, 1, (strWidth * 8 - origWidth) / 2, 1, gUnknown_0858D8E8, -1, text); -// windowTileData = (u8 *)GetWindowAttribute(windowId, WINDOW_TILE_DATA); -// r8 = gUnknown_0858D6D0; -// // .... -// } + origWidth = GetStringWidth(1, text, 0); + strWidth = (origWidth + 9) / 8; + if (strWidth > 30) + strWidth = 30; + AddTextPrinterParameterized3(windowId, 1, (strWidth * 8 - origWidth) / 2, 1, gUnknown_0858D8E8, -1, text); + windowTilesPtr = (u8 *)(GetWindowAttribute(windowId, WINDOW_TILE_DATA)); + src = (u8 *)(gUnknown_0858D6D0); + + sprite = &gSprites[spriteId]; + spriteTilePtrs[0] = (u8 *)(sprite->oam.tileNum * 32 + VRAM + 0x10000); + + for (i = 1; i < 4; i++) + spriteTilePtrs[i] = (void*)(gSprites[sprite->data[i - 1]].oam.tileNum * 32 + VRAM + 0x10000); + + for (i = 0; i < 4; i++) + CpuFill32(0, spriteTilePtrs[i], 0x400); + + dst = spriteTilePtrs[0]; + CpuCopy32(src, dst, 0x20); + CpuCopy32(src + 128, dst + 0x100, 0x20); + CpuCopy32(src + 128, dst + 0x200, 0x20); + CpuCopy32(src + 64, dst + 0x300, 0x20); + + for (i = 0; i < strWidth; i++) + { + dst = &spriteTilePtrs[(i + 1) / 8][((i + 1) % 8) * 32]; + CpuCopy32(src + 192, dst, 0x20); + CpuCopy32(windowTilesPtr, dst + 0x100, 0x20); + CpuCopy32(windowTilesPtr + 960, dst + 0x200, 0x20); + CpuCopy32(src + 224, dst + 0x300, 0x20); + windowTilesPtr += 0x20; + } + + dst = &spriteTilePtrs[(i + 1) / 8][((i + 1) % 8) * 32]; + CpuCopy32(src + 32, dst, 0x20); + CpuCopy32(src + 160, dst + 0x100, 0x20); + CpuCopy32(src + 160, dst + 0x200, 0x20); + CpuCopy32(src + 96, dst + 0x300, 0x20); + RemoveWindow(windowId); + + return (240 - (strWidth + 2) * 8) / 2; +} + +#else NAKED -s16 sub_80F6B78(const u8 *text, u8 spriteId) +s32 sub_80F6B78(const u8 *text, u8 spriteId) { asm_unified("\n\ push {r4-r7,lr}\n\ @@ -1224,6 +1261,7 @@ _080F6D3E:\n\ bx r1\n\ .pool"); } +#endif // NONMATCHING static void sub_80F6DC0(void) { @@ -1630,7 +1668,7 @@ void sub_80F7768(struct Sprite *sprite) sprite->pos1.y++; if (gUnknown_0203A034->unk0->unk9) sprite->invisible = 1; - + if (sprite->pos1.x > 248 || sprite->pos1.y > 116) { DestroySprite(sprite); @@ -2091,7 +2129,7 @@ _080F7A70:\n\ // if (spC) // PlaySE(SE_PIN); - + // if (sp8) // PlaySE(SE_BAN); // } @@ -2358,38 +2396,32 @@ _080F7C96:\n\ bx r0"); } -#ifdef NONMATCHING void sub_80F7CA8(u8 taskId) { - register int r4 asm("r4"); - int r9; - u8 r6; - s16 r7; - s16 r12; int i; u8 var0; u16 tileNum; + bool32 r4 = FALSE; + bool32 endTask = FALSE; + u8 r6 = gTasks[taskId].data[0]; + s16 r7 = gTasks[taskId].data[1]; + s16 r12 = gTasks[taskId].data[2]; - r4 = 0; - r9 = 0; - r6 = gTasks[taskId].data[0]; - r7 = gTasks[taskId].data[1]; - r12 = gTasks[taskId].data[2]; if (r12) { if (gUnknown_0203A034->unk0->unkC[r6] <= 0) - r4 = 1; + r4 = TRUE; } else { if (gUnknown_0203A034->unk0->unkC[r6] > 87) - r4 = 1; + r4 = TRUE; } if (gUnknown_0203A034->unk0->unkC[r6] == r7) - r9 = 1; + endTask = TRUE; - if (!r9) + if (!endTask) { if (r4) gUnknown_0203A034->unk0->unkC[r6] = r7; @@ -2399,220 +2431,32 @@ void sub_80F7CA8(u8 taskId) gUnknown_0203A034->unk0->unkC[r6] = gUnknown_0203A034->unk0->unkC[r6] + 1; } - if (!r4 && !r9) + if (!r4 && !endTask) { for (i = 0; i < 11; i++) { if (gUnknown_0203A034->unk0->unkC[r6] >= (i + 1) * 8) - { var0 = 8; - } else if (gUnknown_0203A034->unk0->unkC[r6] >= i * 8) - { - int var2 = gUnknown_0203A034->unk0->unkC[r6]; - int var1 = var2; - if (var1 < 0) - var1 += 7; - - var0 = var2 - ((var1 >> 3) << 3); - } + var0 = gUnknown_0203A034->unk0->unkC[r6] % 8; else - { var0 = 0; - } if (var0 < 4) - tileNum = 0x504C; + tileNum = 0x504C + var0; else - tileNum = 0x5057; + tileNum = 0x5057 + var0; - FillBgTilemapBufferRect_Palette0(2, tileNum + var0, i + 7, r6 * 3 + 6, 1, 1); + FillBgTilemapBufferRect_Palette0(2, tileNum, i + 7, r6 * 3 + 6, 1, 1); } } - - if (r9) + + if (endTask) { gUnknown_0203A034->unk0->unk14--; DestroyTask(taskId); } } -#else -NAKED -void sub_80F7CA8(u8 taskId) -{ - asm_unified("\n\ - push {r4-r7,lr}\n\ - mov r7, r9\n\ - mov r6, r8\n\ - push {r6,r7}\n\ - sub sp, 0x8\n\ - lsls r0, 24\n\ - lsrs r0, 24\n\ - mov r8, r0\n\ - movs r4, 0\n\ - mov r9, r4\n\ - ldr r1, =gTasks\n\ - lsls r0, 2\n\ - add r0, r8\n\ - lsls r0, 3\n\ - adds r0, r1\n\ - ldrb r6, [r0, 0x8]\n\ - ldrh r7, [r0, 0xA]\n\ - ldrh r1, [r0, 0xC]\n\ - mov r12, r1\n\ - movs r2, 0xC\n\ - ldrsh r0, [r0, r2]\n\ - cmp r0, 0\n\ - beq _080F7CF8\n\ - ldr r2, =gUnknown_0203A034\n\ - ldr r0, [r2]\n\ - ldr r0, [r0]\n\ - lsls r1, r6, 1\n\ - adds r0, 0xC\n\ - adds r0, r1\n\ - movs r3, 0\n\ - ldrsh r0, [r0, r3]\n\ - adds r5, r1, 0\n\ - cmp r0, 0\n\ - bgt _080F7D10\n\ - b _080F7D0E\n\ - .pool\n\ -_080F7CF8:\n\ - ldr r2, =gUnknown_0203A034\n\ - ldr r0, [r2]\n\ - ldr r0, [r0]\n\ - lsls r1, r6, 1\n\ - adds r0, 0xC\n\ - adds r0, r1\n\ - movs r3, 0\n\ - ldrsh r0, [r0, r3]\n\ - adds r5, r1, 0\n\ - cmp r0, 0x57\n\ - ble _080F7D10\n\ -_080F7D0E:\n\ - movs r4, 0x1\n\ -_080F7D10:\n\ - ldr r0, [r2]\n\ - ldr r0, [r0]\n\ - adds r0, 0xC\n\ - adds r2, r0, r5\n\ - ldrh r3, [r2]\n\ - movs r0, 0\n\ - ldrsh r1, [r2, r0]\n\ - lsls r0, r7, 16\n\ - asrs r0, 16\n\ - cmp r1, r0\n\ - bne _080F7D2A\n\ - movs r1, 0x1\n\ - mov r9, r1\n\ -_080F7D2A:\n\ - mov r0, r9\n\ - cmp r0, 0\n\ - bne _080F7D4A\n\ - cmp r4, 0\n\ - beq _080F7D3C\n\ - strh r7, [r2]\n\ - b _080F7D4A\n\ - .pool\n\ -_080F7D3C:\n\ - mov r1, r12\n\ - cmp r1, 0\n\ - beq _080F7D46\n\ - subs r0, r3, 0x1\n\ - b _080F7D48\n\ -_080F7D46:\n\ - adds r0, r3, 0x1\n\ -_080F7D48:\n\ - strh r0, [r2]\n\ -_080F7D4A:\n\ - cmp r4, 0\n\ - bne _080F7DC4\n\ - mov r2, r9\n\ - cmp r2, 0\n\ - bne _080F7DCA\n\ - movs r2, 0\n\ -_080F7D56:\n\ - ldr r0, =gUnknown_0203A034\n\ - ldr r0, [r0]\n\ - ldr r0, [r0]\n\ - adds r0, 0xC\n\ - adds r0, r5\n\ - movs r1, 0\n\ - ldrsh r3, [r0, r1]\n\ - adds r0, r2, 0x1\n\ - lsls r1, r0, 3\n\ - adds r4, r0, 0\n\ - cmp r3, r1\n\ - blt _080F7D78\n\ - movs r0, 0x8\n\ - b _080F7D94\n\ - .pool\n\ -_080F7D78:\n\ - lsls r0, r2, 3\n\ - cmp r3, r0\n\ - blt _080F7D92\n\ - adds r0, r3, 0\n\ - cmp r3, 0\n\ - bge _080F7D86\n\ - adds r0, r3, 0x7\n\ -_080F7D86:\n\ - asrs r0, 3\n\ - lsls r0, 3\n\ - subs r0, r3, r0\n\ - lsls r0, 24\n\ - lsrs r0, 24\n\ - b _080F7D94\n\ -_080F7D92:\n\ - movs r0, 0\n\ -_080F7D94:\n\ - cmp r0, 0x3\n\ - bhi _080F7DA0\n\ - ldr r3, =0x0000504c\n\ - b _080F7DA2\n\ - .pool\n\ -_080F7DA0:\n\ - ldr r3, =0x00005057\n\ -_080F7DA2:\n\ - adds r1, r0, r3\n\ - adds r2, 0x7\n\ - lsls r2, 24\n\ - lsrs r2, 24\n\ - adds r3, r5, r6\n\ - adds r3, 0x6\n\ - lsls r3, 24\n\ - movs r0, 0x1\n\ - str r0, [sp]\n\ - str r0, [sp, 0x4]\n\ - movs r0, 0x2\n\ - lsrs r3, 24\n\ - bl FillBgTilemapBufferRect_Palette0\n\ - adds r2, r4, 0\n\ - cmp r2, 0xA\n\ - ble _080F7D56\n\ -_080F7DC4:\n\ - mov r0, r9\n\ - cmp r0, 0\n\ - beq _080F7DDC\n\ -_080F7DCA:\n\ - ldr r0, =gUnknown_0203A034\n\ - ldr r0, [r0]\n\ - ldr r1, [r0]\n\ - ldrb r0, [r1, 0x14]\n\ - subs r0, 0x1\n\ - strb r0, [r1, 0x14]\n\ - mov r0, r8\n\ - bl DestroyTask\n\ -_080F7DDC:\n\ - add sp, 0x8\n\ - pop {r3,r4}\n\ - mov r8, r3\n\ - mov r9, r4\n\ - pop {r4-r7}\n\ - pop {r0}\n\ - bx r0\n\ - .pool"); -} -#endif // NONMATCHING static void sub_80F7DF4(void) { @@ -2913,10 +2757,9 @@ static void sub_80F85A0(u8 taskId) SetTaskFuncWithFollowupFunc(taskId, sub_80FC894, sub_80F85BC); } -#ifdef NONMATCHING static void sub_80F85BC(u8 taskId) { - u32 i; + u8 i; u8 sp0[4]; u8 sp4[4]; @@ -2926,9 +2769,10 @@ static void sub_80F85BC(u8 taskId) for (i = 0; i < gNumLinkContestPlayers; i++) sp0[i] = gTasks[taskId].data[i + 1]; - for (i = 0; i < gNumLinkContestPlayers; i++) + for (i = 0; i < gNumLinkContestPlayers;) { - if (sp0[0] != sp0[i + 1]) + i++; + if (i >= gNumLinkContestPlayers || sp0[0] != sp0[i]) break; } @@ -2939,133 +2783,11 @@ static void sub_80F85BC(u8 taskId) for (i = 0; i < gNumLinkContestPlayers; i++) sp4[i] = gTasks[taskId].data[i + 5]; - + gUnknown_02039F2B = sub_80F86E0(sp4); sub_80DB09C(gSpecialVar_ContestCategory); SetTaskFuncWithFollowupFunc(taskId, sub_80FCF40, sub_80F86B8); } -#else -NAKED -static void sub_80F85BC(u8 taskId) -{ - asm_unified("\n\ - push {r4-r7,lr}\n\ - mov r7, r9\n\ - mov r6, r8\n\ - push {r6,r7}\n\ - sub sp, 0x8\n\ - lsls r0, 24\n\ - lsrs r6, r0, 24\n\ - movs r0, 0\n\ - str r0, [sp]\n\ - str r0, [sp, 0x4]\n\ - movs r3, 0\n\ - ldr r5, =gNumLinkContestPlayers\n\ - mov r12, r5\n\ - ldr r0, =gSpecialVar_0x8004\n\ - mov r9, r0\n\ - add r1, sp, 0x4\n\ - mov r8, r1\n\ - ldrb r0, [r5]\n\ - cmp r3, r0\n\ - bcs _080F8606\n\ - lsls r0, r6, 2\n\ - adds r0, r6\n\ - lsls r4, r0, 3\n\ - ldr r7, =gTasks + 0x8\n\ -_080F85EC:\n\ - mov r1, sp\n\ - adds r2, r1, r3\n\ - adds r1, r3, 0x1\n\ - lsls r0, r1, 1\n\ - adds r0, r4\n\ - adds r0, r7\n\ - ldrh r0, [r0]\n\ - strb r0, [r2]\n\ - lsls r1, 24\n\ - lsrs r3, r1, 24\n\ - ldrb r0, [r5]\n\ - cmp r3, r0\n\ - bcc _080F85EC\n\ -_080F8606:\n\ - movs r3, 0\n\ - mov r1, r12\n\ - ldrb r0, [r1]\n\ - cmp r3, r0\n\ - bcs _080F862A\n\ - adds r4, r0, 0\n\ - mov r2, sp\n\ -_080F8614:\n\ - adds r0, r3, 0x1\n\ - lsls r0, 24\n\ - lsrs r3, r0, 24\n\ - cmp r3, r4\n\ - bcs _080F862A\n\ - mov r0, sp\n\ - adds r1, r0, r3\n\ - ldrb r0, [r2]\n\ - ldrb r1, [r1]\n\ - cmp r0, r1\n\ - beq _080F8614\n\ -_080F862A:\n\ - mov r1, r12\n\ - ldrb r1, [r1]\n\ - cmp r3, r1\n\ - bne _080F8644\n\ - movs r0, 0\n\ - b _080F8646\n\ - .pool\n\ -_080F8644:\n\ - movs r0, 0x1\n\ -_080F8646:\n\ - mov r1, r9\n\ - strh r0, [r1]\n\ - movs r3, 0\n\ - mov r4, r12\n\ - ldrb r0, [r4]\n\ - cmp r3, r0\n\ - bcs _080F8678\n\ - mov r5, r8\n\ - lsls r0, r6, 2\n\ - adds r0, r6\n\ - lsls r2, r0, 3\n\ - ldr r7, =gTasks + 0x8\n\ -_080F865E:\n\ - adds r1, r5, r3\n\ - adds r0, r3, 0x5\n\ - lsls r0, 1\n\ - adds r0, r2\n\ - adds r0, r7\n\ - ldrh r0, [r0]\n\ - strb r0, [r1]\n\ - adds r0, r3, 0x1\n\ - lsls r0, 24\n\ - lsrs r3, r0, 24\n\ - ldrb r1, [r4]\n\ - cmp r3, r1\n\ - bcc _080F865E\n\ -_080F8678:\n\ - mov r0, r8\n\ - bl sub_80F86E0\n\ - ldr r1, =gUnknown_02039F2B\n\ - strb r0, [r1]\n\ - ldr r0, =gSpecialVar_ContestCategory\n\ - ldrb r0, [r0]\n\ - bl sub_80DB09C\n\ - ldr r1, =sub_80FCF40\n\ - ldr r2, =sub_80F86B8\n\ - adds r0, r6, 0\n\ - bl SetTaskFuncWithFollowupFunc\n\ - add sp, 0x8\n\ - pop {r3,r4}\n\ - mov r8, r3\n\ - mov r9, r4\n\ - pop {r4-r7}\n\ - pop {r0}\n\ - bx r0\n\ - .pool"); -} -#endif // NONMATCHING static void sub_80F86B8(u8 taskId) { From 518f9c0638af5890af6bd573b2538bad462f39e5 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Thu, 11 Apr 2019 12:05:56 +0200 Subject: [PATCH 22/22] Some nonmatchings --- src/ice.c | 508 ++++----------------------- src/pokedex.c | 29 +- src/pokemon_jump.c | 59 +--- src/roulette.c | 610 ++------------------------------ src/water.c | 850 ++++++++++++--------------------------------- 5 files changed, 331 insertions(+), 1725 deletions(-) diff --git a/src/ice.c b/src/ice.c index fa1913b96..8f0c97d82 100644 --- a/src/ice.c +++ b/src/ice.c @@ -47,7 +47,7 @@ void AnimIceBallParticle(struct Sprite *); void AnimTask_Haze2(u8); void AnimTask_OverlayFogTiles(u8); void AnimTask_Hail2(u8); -bool8 GenerateHailParticle(u8, u8, u8, u8); +bool8 GenerateHailParticle(u8 hailStructId, u8 affineAnimNum, u8 taskId, u8 c); const union AnimCmd gUnknown_08595A48[] = { @@ -522,37 +522,33 @@ const struct SpriteTemplate gUnknown_08595DFC = .callback = InitIceBallParticle, }; - // probably unused -#ifdef NONMATCHING static void sub_810B6C4(struct Sprite *sprite) { s16 targetX, targetY, attackerX, attackerY; - s16 i; sprite->oam.tileNum += 7; - targetX = GetBattlerSpriteCoord(gBattleAnimTarget, 2); - targetY = GetBattlerSpriteCoord(gBattleAnimTarget, 3); - attackerX = GetBattlerSpriteCoord(gBattleAnimAttacker, 2); - attackerY = GetBattlerSpriteCoord(gBattleAnimAttacker, 3); + targetX = GetBattlerSpriteCoord(gBattleAnimTarget, BATTLER_COORD_X_2); + targetY = GetBattlerSpriteCoord(gBattleAnimTarget, BATTLER_COORD_Y_PIC_OFFSET); + attackerX = GetBattlerSpriteCoord(gBattleAnimAttacker, BATTLER_COORD_X_2); + attackerY = GetBattlerSpriteCoord(gBattleAnimAttacker, BATTLER_COORD_Y_PIC_OFFSET); sprite->data[0] = gBattleAnimArgs[4]; sprite->data[1] = gBattleAnimArgs[0] + attackerX; sprite->data[2] = gBattleAnimArgs[2] + targetX; sprite->data[3] = gBattleAnimArgs[1] + attackerY; sprite->data[4] = gBattleAnimArgs[3] + targetY; sub_80A64EC(sprite); - while ((targetX >= -32 && targetX <= 272) && (targetY >= -32 && targetY <= 192)) - { - targetX += sprite->data[1]; - targetY += sprite->data[2]; - } + + for (;(targetX >= -32 && targetX <= 272) && (targetY >= -32 && targetY <= 192); + targetX += sprite->data[1], targetY += sprite->data[2]) + ; + sprite->data[1] = -sprite->data[1]; sprite->data[2] = -sprite->data[2]; - while ((attackerX >= -32 && attackerX <= 272) && (attackerY >= -32 && attackerY <= 192)) - { - attackerX += sprite->data[1]; - attackerY += sprite->data[2]; - } + for (;(attackerX >= -32 && attackerX <= 272) && (attackerY >= -32 && attackerY <= 192); + attackerX += sprite->data[1], attackerY += sprite->data[2]) + ; + sprite->pos1.x = attackerX; sprite->pos1.y = attackerY; sprite->data[0] = gBattleAnimArgs[4]; @@ -565,195 +561,6 @@ static void sub_810B6C4(struct Sprite *sprite) sprite->data[4] = gBattleAnimArgs[6]; sprite->callback = sub_810B848; } -#else -NAKED -static void sub_810B6C4(struct Sprite *sprite) -{ - asm_unified("push {r4-r7,lr}\n\ - mov r7, r10\n\ - mov r6, r9\n\ - mov r5, r8\n\ - push {r5-r7}\n\ - sub sp, 0x4\n\ - adds r5, r0, 0\n\ - ldrh r2, [r5, 0x4]\n\ - lsls r1, r2, 22\n\ - lsrs r1, 22\n\ - adds r1, 0x7\n\ - ldr r3, =0x000003ff\n\ - adds r0, r3, 0\n\ - ands r1, r0\n\ - ldr r0, =0xfffffc00\n\ - ands r0, r2\n\ - orrs r0, r1\n\ - strh r0, [r5, 0x4]\n\ - ldr r4, =gBattleAnimTarget\n\ - ldrb r0, [r4]\n\ - movs r1, 0x2\n\ - bl GetBattlerSpriteCoord\n\ - lsls r0, 24\n\ - lsrs r0, 24\n\ - mov r9, r0\n\ - ldrb r0, [r4]\n\ - movs r1, 0x3\n\ - bl GetBattlerSpriteCoord\n\ - lsls r0, 24\n\ - lsrs r0, 24\n\ - mov r8, r0\n\ - ldr r4, =gBattleAnimAttacker\n\ - ldrb r0, [r4]\n\ - movs r1, 0x2\n\ - bl GetBattlerSpriteCoord\n\ - lsls r0, 24\n\ - lsrs r3, r0, 24\n\ - ldrb r0, [r4]\n\ - movs r1, 0x3\n\ - str r3, [sp]\n\ - bl GetBattlerSpriteCoord\n\ - lsls r0, 24\n\ - lsrs r6, r0, 24\n\ - ldr r1, =gBattleAnimArgs\n\ - ldrh r0, [r1, 0x8]\n\ - strh r0, [r5, 0x2E]\n\ - ldrh r0, [r1]\n\ - ldr r3, [sp]\n\ - adds r0, r3\n\ - strh r0, [r5, 0x30]\n\ - ldrh r0, [r1, 0x4]\n\ - mov r4, r9\n\ - adds r0, r4, r0\n\ - strh r0, [r5, 0x32]\n\ - ldrh r0, [r1, 0x2]\n\ - adds r0, r6\n\ - strh r0, [r5, 0x34]\n\ - ldrh r0, [r1, 0x6]\n\ - mov r7, r8\n\ - adds r0, r7, r0\n\ - strh r0, [r5, 0x36]\n\ - adds r0, r5, 0\n\ - bl sub_80A64EC\n\ - adds r4, 0x20\n\ - movs r0, 0x98\n\ - lsls r0, 1\n\ - mov r12, r0\n\ - ldr r3, [sp]\n\ - cmp r4, r12\n\ - bhi _0810B79E\n\ - adds r0, r7, 0\n\ - adds r0, 0x20\n\ - ldrh r1, [r5, 0x30]\n\ - ldrh r2, [r5, 0x32]\n\ - cmp r0, 0xE0\n\ - bhi _0810B79E\n\ - adds r4, r1, 0\n\ - mov r10, r12\n\ -_0810B76A:\n\ - mov r7, r9\n\ - lsls r1, r7, 16\n\ - asrs r1, 16\n\ - adds r1, r4\n\ - lsls r1, 16\n\ - mov r7, r8\n\ - lsls r0, r7, 16\n\ - asrs r0, 16\n\ - adds r0, r2\n\ - lsls r0, 16\n\ - lsrs r0, 16\n\ - mov r8, r0\n\ - lsrs r0, r1, 16\n\ - mov r9, r0\n\ - movs r7, 0x80\n\ - lsls r7, 14\n\ - adds r1, r7\n\ - lsrs r1, 16\n\ - cmp r1, r10\n\ - bhi _0810B79E\n\ - mov r1, r8\n\ - lsls r0, r1, 16\n\ - adds r0, r7\n\ - lsrs r0, 16\n\ - cmp r0, 0xE0\n\ - bls _0810B76A\n\ -_0810B79E:\n\ - ldrh r0, [r5, 0x30]\n\ - negs r7, r0\n\ - strh r7, [r5, 0x30]\n\ - ldrh r0, [r5, 0x32]\n\ - negs r4, r0\n\ - strh r4, [r5, 0x32]\n\ - lsls r0, r3, 16\n\ - movs r1, 0x80\n\ - lsls r1, 14\n\ - adds r0, r1\n\ - lsrs r0, 16\n\ - movs r2, 0x98\n\ - lsls r2, 1\n\ - mov r12, r2\n\ - ldr r1, =gBattleAnimArgs\n\ - mov r10, r1\n\ - cmp r0, r12\n\ - bhi _0810B80A\n\ - lsls r1, r6, 16\n\ - movs r2, 0x80\n\ - lsls r2, 14\n\ - adds r0, r1, r2\n\ - b _0810B802\n\ - .pool\n\ -_0810B7E0:\n\ - lsls r1, r3, 16\n\ - asrs r1, 16\n\ - adds r1, r7\n\ - lsls r1, 16\n\ - asrs r0, r2, 16\n\ - adds r0, r4\n\ - lsls r0, 16\n\ - lsrs r6, r0, 16\n\ - lsrs r3, r1, 16\n\ - movs r0, 0x80\n\ - lsls r0, 14\n\ - adds r1, r0\n\ - lsrs r1, 16\n\ - cmp r1, r12\n\ - bhi _0810B80A\n\ - lsls r1, r6, 16\n\ - adds r0, r1, r0\n\ -_0810B802:\n\ - lsrs r0, 16\n\ - adds r2, r1, 0\n\ - cmp r0, 0xE0\n\ - bls _0810B7E0\n\ -_0810B80A:\n\ - strh r3, [r5, 0x20]\n\ - strh r6, [r5, 0x22]\n\ - mov r1, r10\n\ - ldrh r0, [r1, 0x8]\n\ - strh r0, [r5, 0x2E]\n\ - strh r3, [r5, 0x30]\n\ - mov r2, r9\n\ - strh r2, [r5, 0x32]\n\ - strh r6, [r5, 0x34]\n\ - mov r3, r8\n\ - strh r3, [r5, 0x36]\n\ - adds r0, r5, 0\n\ - bl sub_80A64EC\n\ - mov r7, r10\n\ - ldrh r0, [r7, 0xA]\n\ - strh r0, [r5, 0x34]\n\ - ldrh r0, [r7, 0xC]\n\ - strh r0, [r5, 0x36]\n\ - ldr r0, =sub_810B848\n\ - str r0, [r5, 0x1C]\n\ - add sp, 0x4\n\ - pop {r3-r5}\n\ - mov r8, r3\n\ - mov r9, r4\n\ - mov r10, r5\n\ - pop {r4-r7}\n\ - pop {r0}\n\ - bx r0\n\ - .pool\n"); -} -#endif void sub_810B848(struct Sprite *sprite) { @@ -797,14 +604,14 @@ void AnimIcePunchSwirlingParticle(struct Sprite *sprite) void AnimIceBeamParticle(struct Sprite *sprite) { InitSpritePosToAnimAttacker(sprite, TRUE); - sprite->data[2] = GetBattlerSpriteCoord(gBattleAnimTarget, 2); + sprite->data[2] = GetBattlerSpriteCoord(gBattleAnimTarget, BATTLER_COORD_X_2); if (GetBattlerSide(gBattleAnimAttacker) != B_SIDE_PLAYER) sprite->data[2] -= gBattleAnimArgs[2]; else sprite->data[2] += gBattleAnimArgs[2]; - sprite->data[4] = GetBattlerSpriteCoord(gBattleAnimTarget, 3) + gBattleAnimArgs[3]; + sprite->data[4] = GetBattlerSpriteCoord(gBattleAnimTarget, BATTLER_COORD_Y_PIC_OFFSET) + gBattleAnimArgs[3]; sprite->data[0] = gBattleAnimArgs[4]; StoreSpriteCallbackInData6(sprite, DestroyAnimSprite); sprite->callback = StartAnimLinearTranslation; @@ -863,8 +670,8 @@ void AnimSwirlingSnowball_Step1(struct Sprite *sprite) if (!gBattleAnimArgs[5]) { - sprite->data[2] = GetBattlerSpriteCoord(gBattleAnimTarget, 2); - sprite->data[4] = GetBattlerSpriteCoord(gBattleAnimTarget, 3) + gBattleAnimArgs[3]; + sprite->data[2] = GetBattlerSpriteCoord(gBattleAnimTarget, BATTLER_COORD_X_2); + sprite->data[4] = GetBattlerSpriteCoord(gBattleAnimTarget, BATTLER_COORD_Y_PIC_OFFSET) + gBattleAnimArgs[3]; } else { @@ -983,8 +790,8 @@ void AnimMoveParticleBeyondTarget(struct Sprite *sprite) if (!gBattleAnimArgs[7]) { - sprite->data[2] = GetBattlerSpriteCoord(gBattleAnimTarget, 2); - sprite->data[4] = GetBattlerSpriteCoord(gBattleAnimTarget, 3); + sprite->data[2] = GetBattlerSpriteCoord(gBattleAnimTarget, BATTLER_COORD_X_2); + sprite->data[4] = GetBattlerSpriteCoord(gBattleAnimTarget, BATTLER_COORD_Y_PIC_OFFSET); } else { @@ -1274,8 +1081,8 @@ void AnimTask_Haze2(u8 taskId) // arg 5: ??? unknown (seems to vibrate target mon somehow) void AnimThrowMistBall(struct Sprite *sprite) { - sprite->pos1.x = GetBattlerSpriteCoord(gBattleAnimAttacker, 2); - sprite->pos1.y = GetBattlerSpriteCoord(gBattleAnimAttacker, 3); + sprite->pos1.x = GetBattlerSpriteCoord(gBattleAnimAttacker, BATTLER_COORD_X_2); + sprite->pos1.y = GetBattlerSpriteCoord(gBattleAnimAttacker, BATTLER_COORD_Y_PIC_OFFSET); sprite->callback = TranslateAnimSpriteToTargetMonLocation; } @@ -1380,7 +1187,7 @@ void InitPoisonGasCloudAnim(struct Sprite *sprite) { sprite->data[0] = gBattleAnimArgs[0]; - if (GetBattlerSpriteCoord(gBattleAnimAttacker, 2) < GetBattlerSpriteCoord(gBattleAnimTarget, 2)) + if (GetBattlerSpriteCoord(gBattleAnimAttacker, BATTLER_COORD_X_2) < GetBattlerSpriteCoord(gBattleAnimTarget, BATTLER_COORD_X_2)) sprite->data[7] = 0x8000; if (!(gBattlerPositions[gBattleAnimTarget] & 1)) @@ -1394,22 +1201,22 @@ void InitPoisonGasCloudAnim(struct Sprite *sprite) sprite->data[6] = 1; } - sprite->pos1.x = GetBattlerSpriteCoord(gBattleAnimAttacker, 2); - sprite->pos1.y = GetBattlerSpriteCoord(gBattleAnimAttacker, 3); + sprite->pos1.x = GetBattlerSpriteCoord(gBattleAnimAttacker, BATTLER_COORD_X_2); + sprite->pos1.y = GetBattlerSpriteCoord(gBattleAnimAttacker, BATTLER_COORD_Y_PIC_OFFSET); if (gBattleAnimArgs[7]) { sprite->data[1] = sprite->pos1.x + gBattleAnimArgs[1]; - sprite->data[2] = GetBattlerSpriteCoord(gBattleAnimTarget, 2) + gBattleAnimArgs[3]; + sprite->data[2] = GetBattlerSpriteCoord(gBattleAnimTarget, BATTLER_COORD_X_2) + gBattleAnimArgs[3]; sprite->data[3] = sprite->pos1.y + gBattleAnimArgs[2]; - sprite->data[4] = GetBattlerSpriteCoord(gBattleAnimTarget, 3) + gBattleAnimArgs[4]; + sprite->data[4] = GetBattlerSpriteCoord(gBattleAnimTarget, BATTLER_COORD_Y_PIC_OFFSET) + gBattleAnimArgs[4]; sprite->data[7] |= GetBattlerSpriteBGPriority(gBattleAnimTarget) << 8; } else { sprite->data[1] = sprite->pos1.x + gBattleAnimArgs[1]; - sprite->data[2] = GetBattlerSpriteCoord(gBattleAnimTarget, 0) + gBattleAnimArgs[3]; + sprite->data[2] = GetBattlerSpriteCoord(gBattleAnimTarget, BATTLER_COORD_X) + gBattleAnimArgs[3]; sprite->data[3] = sprite->pos1.y + gBattleAnimArgs[2]; - sprite->data[4] = GetBattlerSpriteCoord(gBattleAnimTarget, 1) + gBattleAnimArgs[4]; + sprite->data[4] = GetBattlerSpriteCoord(gBattleAnimTarget, BATTLER_COORD_Y) + gBattleAnimArgs[4]; sprite->data[7] |= GetBattlerSpriteBGPriority(gBattleAnimTarget) << 8; } @@ -1441,7 +1248,7 @@ void MovePoisonGasCloud(struct Sprite *sprite) if (sprite->data[0] <= 0) { sprite->data[0] = 80; - sprite->pos1.x = GetBattlerSpriteCoord(gBattleAnimTarget, 0); + sprite->pos1.x = GetBattlerSpriteCoord(gBattleAnimTarget, BATTLER_COORD_X); sprite->data[1] = sprite->pos1.x; sprite->data[2] = sprite->pos1.x; sprite->pos1.y += sprite->pos2.y; @@ -1575,238 +1382,63 @@ void AnimTask_Hail2(u8 taskId) } } -#ifdef NONMATCHING -bool8 GenerateHailParticle(u8 a, u8 b, u8 taskId, u8 c) +bool8 GenerateHailParticle(u8 hailStructId, u8 affineAnimNum, u8 taskId, u8 c) { - bool8 possibleBool = FALSE; - // s8 unk = gUnknown_08595CB4[a].unk3; - const struct HailStruct *hailData = &gUnknown_08595CB4[a]; - s8 unk = hailData->unk3; - u8 battler; + u8 id; s16 battlerX, battlerY; - u8 spriteId; - // struct Sprite *sprite; s16 spriteX; + bool8 possibleBool = FALSE; + s8 unk = gUnknown_08595CB4[hailStructId].unk3; if (unk != 2) { - battler = GetBattlerAtPosition(hailData->unk2); - if (IsBattlerSpriteVisible(battler)) + id = GetBattlerAtPosition(gUnknown_08595CB4[hailStructId].unk2); + if (IsBattlerSpriteVisible(id)) { possibleBool = TRUE; - battlerX = GetBattlerSpriteCoord(battler, 2); - battlerY = GetBattlerSpriteCoord(battler, 3); + battlerX = GetBattlerSpriteCoord(id, BATTLER_COORD_X_2); + battlerY = GetBattlerSpriteCoord(id, BATTLER_COORD_Y_PIC_OFFSET); switch (unk) { - case 0: - battlerX -= GetBattlerSpriteCoordAttr(battler, BATTLER_COORD_ATTR_WIDTH) / 6; - battlerY -= GetBattlerSpriteCoordAttr(battler, BATTLER_COORD_ATTR_HEIGHT) / 6; - break; - case 1: - battlerX += GetBattlerSpriteCoordAttr(battler, BATTLER_COORD_ATTR_WIDTH) / 6; - battlerY += GetBattlerSpriteCoordAttr(battler, BATTLER_COORD_ATTR_HEIGHT) / 6; - break; + case 0: + battlerX -= GetBattlerSpriteCoordAttr(id, BATTLER_COORD_ATTR_WIDTH) / 6; + battlerY -= GetBattlerSpriteCoordAttr(id, BATTLER_COORD_ATTR_HEIGHT) / 6; + break; + case 1: + battlerX += GetBattlerSpriteCoordAttr(id, BATTLER_COORD_ATTR_WIDTH) / 6; + battlerY += GetBattlerSpriteCoordAttr(id, BATTLER_COORD_ATTR_HEIGHT) / 6; + break; } } + else + { + battlerX = (gUnknown_08595CB4[hailStructId].unk0); + battlerY = (gUnknown_08595CB4[hailStructId].unk1); + } } else { - battlerX = (hailData->unk0); - battlerY = (hailData->unk1); + battlerX = (gUnknown_08595CB4[hailStructId].unk0); + battlerY = (gUnknown_08595CB4[hailStructId].unk1); } spriteX = battlerX - ((battlerY + 8) / 2); - spriteId = CreateSprite(&gUnknown_08595D2C, spriteX, -8, 18); - if (spriteId == MAX_SPRITES) + id = CreateSprite(&gUnknown_08595D2C, spriteX, -8, 18); + if (id == MAX_SPRITES) + { return FALSE; - // sprite = &gSprites[spriteId]; - StartSpriteAffineAnim(&gSprites[spriteId], b); - gSprites[spriteId].data[0] = possibleBool; - gSprites[spriteId].data[3] = battlerX; - gSprites[spriteId].data[4] = battlerY; - gSprites[spriteId].data[5] = b; - gSprites[spriteId].data[6] = taskId; - gSprites[spriteId].data[7] = c; - return TRUE; + } + else + { + StartSpriteAffineAnim(&gSprites[id], affineAnimNum); + gSprites[id].data[0] = possibleBool; + gSprites[id].data[3] = battlerX; + gSprites[id].data[4] = battlerY; + gSprites[id].data[5] = affineAnimNum; + gSprites[id].data[6] = taskId; + gSprites[id].data[7] = c; + return TRUE; + } } -#else -NAKED -bool8 GenerateHailParticle(u8 a, u8 b, u8 taskId, u8 c) -{ - asm_unified("push {r4-r7,lr}\n\ - mov r7, r10\n\ - mov r6, r9\n\ - mov r5, r8\n\ - push {r5-r7}\n\ - sub sp, 0x8\n\ - lsls r0, 24\n\ - lsls r1, 24\n\ - lsrs r1, 24\n\ - mov r9, r1\n\ - lsls r2, 24\n\ - lsrs r2, 24\n\ - str r2, [sp]\n\ - lsls r3, 24\n\ - lsrs r3, 24\n\ - mov r10, r3\n\ - movs r1, 0\n\ - str r1, [sp, 0x4]\n\ - ldr r1, =gUnknown_08595CB4\n\ - lsrs r0, 22\n\ - adds r4, r0, r1\n\ - ldrb r0, [r4, 0x3]\n\ - lsls r0, 24\n\ - asrs r0, 28\n\ - mov r8, r0\n\ - cmp r0, 0x2\n\ - beq _0810CAD0\n\ - ldrh r0, [r4, 0x2]\n\ - lsls r0, 20\n\ - lsrs r0, 24\n\ - bl GetBattlerAtPosition\n\ - lsls r0, 24\n\ - lsrs r5, r0, 24\n\ - adds r0, r5, 0\n\ - bl IsBattlerSpriteVisible\n\ - lsls r0, 24\n\ - cmp r0, 0\n\ - beq _0810CAD0\n\ - movs r0, 0x1\n\ - str r0, [sp, 0x4]\n\ - adds r0, r5, 0\n\ - movs r1, 0x2\n\ - bl GetBattlerSpriteCoord\n\ - lsls r0, 24\n\ - lsrs r7, r0, 24\n\ - adds r0, r5, 0\n\ - movs r1, 0x3\n\ - bl GetBattlerSpriteCoord\n\ - lsls r0, 24\n\ - lsrs r6, r0, 24\n\ - mov r1, r8\n\ - cmp r1, 0\n\ - beq _0810CA60\n\ - cmp r1, 0x1\n\ - beq _0810CA96\n\ - b _0810CAE2\n\ - .pool\n\ -_0810CA60:\n\ - adds r0, r5, 0\n\ - movs r1, 0x1\n\ - bl GetBattlerSpriteCoordAttr\n\ - lsls r0, 16\n\ - asrs r0, 16\n\ - movs r1, 0x6\n\ - bl __divsi3\n\ - lsls r1, r7, 16\n\ - asrs r1, 16\n\ - subs r1, r0\n\ - lsls r1, 16\n\ - lsrs r7, r1, 16\n\ - adds r0, r5, 0\n\ - movs r1, 0\n\ - bl GetBattlerSpriteCoordAttr\n\ - lsls r0, 16\n\ - asrs r0, 16\n\ - movs r1, 0x6\n\ - bl __divsi3\n\ - lsls r1, r6, 16\n\ - asrs r1, 16\n\ - subs r1, r0\n\ - b _0810CACA\n\ -_0810CA96:\n\ - adds r0, r5, 0\n\ - movs r1, 0x1\n\ - bl GetBattlerSpriteCoordAttr\n\ - lsls r0, 16\n\ - asrs r0, 16\n\ - movs r1, 0x6\n\ - bl __divsi3\n\ - lsls r1, r7, 16\n\ - asrs r1, 16\n\ - adds r1, r0\n\ - lsls r1, 16\n\ - lsrs r7, r1, 16\n\ - adds r0, r5, 0\n\ - movs r1, 0\n\ - bl GetBattlerSpriteCoordAttr\n\ - lsls r0, 16\n\ - asrs r0, 16\n\ - movs r1, 0x6\n\ - bl __divsi3\n\ - lsls r1, r6, 16\n\ - asrs r1, 16\n\ - adds r1, r0\n\ -_0810CACA:\n\ - lsls r1, 16\n\ - lsrs r6, r1, 16\n\ - b _0810CAE2\n\ -_0810CAD0:\n\ - ldrh r0, [r4]\n\ - lsls r0, 22\n\ - asrs r0, 6\n\ - lsrs r7, r0, 16\n\ - ldr r0, [r4]\n\ - lsls r0, 12\n\ - asrs r0, 22\n\ - lsls r0, 16\n\ - lsrs r6, r0, 16\n\ -_0810CAE2:\n\ - lsls r0, r6, 16\n\ - asrs r0, 16\n\ - adds r0, 0x8\n\ - lsrs r1, r0, 31\n\ - adds r0, r1\n\ - asrs r0, 1\n\ - lsls r1, r7, 16\n\ - asrs r1, 16\n\ - subs r1, r0\n\ - ldr r0, =gUnknown_08595D2C\n\ - lsls r1, 16\n\ - asrs r1, 16\n\ - movs r2, 0x8\n\ - negs r2, r2\n\ - movs r3, 0x12\n\ - bl CreateSprite\n\ - lsls r0, 24\n\ - lsrs r5, r0, 24\n\ - cmp r5, 0x40\n\ - beq _0810CB44\n\ - lsls r4, r5, 4\n\ - adds r4, r5\n\ - lsls r4, 2\n\ - ldr r0, =gSprites\n\ - adds r4, r0\n\ - adds r0, r4, 0\n\ - mov r1, r9\n\ - bl StartSpriteAffineAnim\n\ - mov r0, sp\n\ - ldrh r0, [r0, 0x4]\n\ - strh r0, [r4, 0x2E]\n\ - strh r7, [r4, 0x34]\n\ - strh r6, [r4, 0x36]\n\ - mov r1, r9\n\ - strh r1, [r4, 0x38]\n\ - mov r0, sp\n\ - ldrh r0, [r0]\n\ - strh r0, [r4, 0x3A]\n\ - mov r1, r10\n\ - strh r1, [r4, 0x3C]\n\ - movs r0, 0x1\n\ - b _0810CB46\n\ - .pool\n\ -_0810CB44:\n\ - movs r0, 0\n\ -_0810CB46:\n\ - add sp, 0x8\n\ - pop {r3-r5}\n\ - mov r8, r3\n\ - mov r9, r4\n\ - mov r10, r5\n\ - pop {r4-r7}\n\ - pop {r1}\n\ - bx r1\n"); -} -#endif void AnimHailBegin(struct Sprite *sprite) { @@ -1874,8 +1506,8 @@ void InitIceBallAnim(struct Sprite *sprite) if (GetBattlerSide(gBattleAnimAttacker) != B_SIDE_PLAYER) gBattleAnimArgs[2] = -gBattleAnimArgs[2]; - sprite->data[2] = GetBattlerSpriteCoord(gBattleAnimTarget, 2) + gBattleAnimArgs[2]; - sprite->data[4] = GetBattlerSpriteCoord(gBattleAnimTarget, 3) + gBattleAnimArgs[3]; + sprite->data[2] = GetBattlerSpriteCoord(gBattleAnimTarget, BATTLER_COORD_X_2) + gBattleAnimArgs[2]; + sprite->data[4] = GetBattlerSpriteCoord(gBattleAnimTarget, BATTLER_COORD_Y_PIC_OFFSET) + gBattleAnimArgs[3]; sprite->data[5] = gBattleAnimArgs[5]; InitAnimArcTranslation(sprite); diff --git a/src/pokedex.c b/src/pokedex.c index 0dae8a7b3..3343854cd 100644 --- a/src/pokedex.c +++ b/src/pokedex.c @@ -205,7 +205,7 @@ void blockset_load_palette_to_gpu(u8); void sub_80C01CC(struct Sprite *sprite); void sub_80C020C(u32, u32, u32, u32); void sub_80C0354(u16, u8, u8); -void sub_80C0460(u16, u8, u8); +void sub_80C0460(u16 weight, u8 left, u8 top); void sub_80C09B0(u16); u8 sub_80C0B44(u8, u16, u8, u8); void sub_80C0D30(u8, u16); @@ -3926,9 +3926,6 @@ void sub_80C020C(u32 num, u32 value, u32 c, u32 d) sub_80BE8DC(text3, GetStringCenterAlignXOffset(1, text3, 0xF0), 0x5F); } -#define CHAR_PRIME (0xB4) -#define CHAR_DOUBLE_PRIME (0xB2) - void sub_80C0354(u16 height, u8 left, u8 top) { u8 buffer[16]; @@ -3954,10 +3951,10 @@ void sub_80C0354(u16 height, u8 left, u8 top) buffer[i++] = feet / 10 + CHAR_0; buffer[i++] = (feet % 10) + CHAR_0; } - buffer[i++] = CHAR_PRIME; + buffer[i++] = CHAR_SGL_QUOT_RIGHT; buffer[i++] = (inches / 10) + CHAR_0; buffer[i++] = (inches % 10) + CHAR_0; - buffer[i++] = CHAR_DOUBLE_PRIME; + buffer[i++] = CHAR_DBL_QUOT_RIGHT; buffer[i++] = EOS; sub_80BE8DC(buffer, left, top); } @@ -3968,12 +3965,11 @@ void sub_80C0354(u16 height, u8 left, u8 top) void sub_80C0460(u16 weight, u8 left, u8 top) { u8 buffer[16]; - u32 lbs; - u8 i = 0; bool8 output; + u8 i = 0; + u32 lbs = (weight * 100000) / 4536; - lbs = (weight * 100000) / 4536; - if (lbs % 10 >= 5) + if (lbs % 10u >= 5) lbs += 10; output = FALSE; @@ -3988,9 +3984,9 @@ void sub_80C0460(u16 weight, u8 left, u8 top) i++; } - lbs = (lbs % 100000); + lbs %= 100000; buffer[i] = (lbs / 10000) + CHAR_0; - if (buffer[i] == CHAR_0 && output == FALSE) + if (buffer[i] == CHAR_0 && !output) { buffer[i++] = 0x77; } @@ -4000,9 +3996,9 @@ void sub_80C0460(u16 weight, u8 left, u8 top) i++; } - lbs = (lbs % 10000); + lbs %= 10000; buffer[i] = (lbs / 1000) + CHAR_0; - if (buffer[i] == CHAR_0 && output == FALSE) + if (buffer[i] == CHAR_0 && !output) { buffer[i++] = 0x77; } @@ -4010,9 +4006,10 @@ void sub_80C0460(u16 weight, u8 left, u8 top) { i++; } - lbs = (lbs % 1000); + + lbs %= 1000; buffer[i++] = (lbs / 100) + CHAR_0; - lbs = (lbs % 100); + lbs %= 100; buffer[i++] = CHAR_PERIOD; buffer[i++] = (lbs / 10) + CHAR_0; buffer[i++] = CHAR_SPACE; diff --git a/src/pokemon_jump.c b/src/pokemon_jump.c index 7af1d496a..8aec7bed1 100755 --- a/src/pokemon_jump.c +++ b/src/pokemon_jump.c @@ -451,11 +451,9 @@ void sub_802AA94(struct PokemonJump1 *arg0) } } -#ifdef NONMATCHING void sub_802AB20(void) { - int i; - s16 index; + int i, index; for (i = 0; i < MAX_RFU_PLAYERS; i++) { @@ -465,61 +463,6 @@ void sub_802AB20(void) gUnknown_02022CFC->unk83AC = &gUnknown_02022CFC->unk82E4[gUnknown_02022CFC->unk6]; } -#else -NAKED -void sub_802AB20(void) -{ - asm_unified("\n\ - push {r4-r7,lr}\n\ - mov r7, r8\n\ - push {r7}\n\ - ldr r7, =gUnknown_02022CFC\n\ - movs r6, 0\n\ - movs r5, 0\n\ - ldr r0, =gPkmnJumpSpecies\n\ - mov r8, r0\n\ - movs r4, 0x4\n\ -_0802AB32:\n\ - ldr r0, [r7]\n\ - adds r0, r5\n\ - ldr r1, =0x000082a8\n\ - adds r0, r1\n\ - ldrh r0, [r0]\n\ - bl sub_802AC00\n\ - lsls r0, 16\n\ - ldr r1, [r7]\n\ - adds r1, r6\n\ - asrs r0, 14\n\ - add r0, r8\n\ - ldrh r0, [r0, 0x2]\n\ - ldr r2, =0x000082f0\n\ - adds r1, r2\n\ - strh r0, [r1]\n\ - adds r6, 0x28\n\ - adds r5, 0xC\n\ - subs r4, 0x1\n\ - cmp r4, 0\n\ - bge _0802AB32\n\ - ldr r0, =gUnknown_02022CFC\n\ - ldr r1, [r0]\n\ - ldr r0, =0x000083ac\n\ - adds r3, r1, r0\n\ - ldrb r2, [r1, 0x6]\n\ - lsls r0, r2, 2\n\ - adds r0, r2\n\ - lsls r0, 3\n\ - ldr r2, =0x000082e4\n\ - adds r0, r2\n\ - adds r1, r0\n\ - str r1, [r3]\n\ - pop {r3}\n\ - mov r8, r3\n\ - pop {r4-r7}\n\ - pop {r0}\n\ - bx r0\n\ - .pool"); -} -#endif // NONMATCHING static void sub_802AB98(void) { diff --git a/src/roulette.c b/src/roulette.c index 39db5630b..25c079cda 100644 --- a/src/roulette.c +++ b/src/roulette.c @@ -902,7 +902,7 @@ static void sub_8140470(void) { sub_815168C(&gUnknown_0203AB88->varB8, i, &gUnknown_085B6388[i]); } - + for (i = 0; i < PARTY_SIZE; i++) { switch (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2)) @@ -953,7 +953,7 @@ static void sub_81405CC(void) case 4: if (free_temp_tile_data_buffers_if_possible()) return; - + sub_8140470(); CopyToBgTilemapBuffer(2, gUnknown_085B5FA0, 0, 0); break; @@ -1379,8 +1379,6 @@ static u8 sub_814118C(u16 r0, u16 r1) } } -// r7/r8 swap -#ifdef NONMATCHING static void sub_8141344(u8 taskId) { u8 randf; @@ -1412,8 +1410,7 @@ static void sub_8141344(u8 taskId) g = S16TOPOSFLOAT(g) / 5.0f; gUnknown_0203AB88->var82 = g * 3; - gUnknown_0203AB88->var84 = g; - gUnknown_0203AB88->var86 = g; + gUnknown_0203AB88->var86 = gUnknown_0203AB88->var84 = g; gUnknown_0203AB88->var88 = S16TOPOSFLOAT(angles[(rand & 1) + r5]); gUnknown_0203AB88->var8C = S16TOPOSFLOAT(gUnknown_085B6348[gUnknown_0203AB88->var04_0].var18); @@ -1424,260 +1421,6 @@ static void sub_8141344(u8 taskId) gUnknown_0203AB88->varA0 = 36.0f; gTasks[taskId].func = sub_814155C; } -#else -static const u16 gUnknown_085B6422[4] = {0, 180, 90, 270}; -NAKED -static void sub_8141344(u8 taskId) -{ - asm_unified(" push {r4-r7,lr}\n\ - mov r7, r10\n\ - mov r6, r9\n\ - mov r5, r8\n\ - push {r5-r7}\n\ - sub sp, 0x8\n\ - lsls r0, 24\n\ - lsrs r0, 24\n\ - mov r10, r0\n\ - movs r4, 0\n\ - ldr r1, =gUnknown_085B6422\n\ - mov r0, sp\n\ - movs r2, 0x8\n\ - bl memcpy\n\ - bl Random\n\ - lsls r0, 16\n\ - lsrs r7, r0, 16\n\ - adds r0, r7, 0\n\ - movs r1, 0x64\n\ - bl __umodsi3\n\ - lsls r0, 16\n\ - lsrs r6, r0, 16\n\ - ldr r3, =gUnknown_0203AB88\n\ - ldr r0, [r3]\n\ - ldr r2, =gTasks\n\ - mov r5, r10\n\ - lsls r1, r5, 2\n\ - add r1, r10\n\ - lsls r1, 3\n\ - adds r1, r2\n\ - ldrh r2, [r1, 0x14]\n\ - adds r0, 0x7C\n\ - strb r2, [r0]\n\ - ldr r0, [r3]\n\ - adds r2, r0, 0\n\ - adds r2, 0x7F\n\ - strb r4, [r2]\n\ - subs r2, 0x1\n\ - strb r4, [r2]\n\ - adds r0, 0x7D\n\ - strb r4, [r0]\n\ - ldrh r0, [r1, 0x18]\n\ - adds r1, r7, 0\n\ - bl sub_814118C\n\ - adds r4, r0, 0\n\ - lsls r4, 24\n\ - lsrs r1, r4, 24\n\ - adds r0, r7, 0\n\ - bl __modsi3\n\ - lsrs r4, 25\n\ - subs r0, r4\n\ - lsls r0, 24\n\ - lsrs r4, r0, 24\n\ - ldr r0, =gLocalTime\n\ - ldrb r0, [r0, 0x2]\n\ - lsls r0, 24\n\ - asrs r0, 24\n\ - movs r5, 0x1\n\ - cmp r0, 0xC\n\ - bgt _081413C8\n\ - movs r5, 0\n\ -_081413C8:\n\ - cmp r6, 0x4F\n\ - bhi _081413E0\n\ - lsls r0, r5, 25\n\ - b _081413EA\n\ - .pool\n\ -_081413E0:\n\ - lsls r1, r5, 24\n\ - asrs r1, 24\n\ - movs r0, 0x1\n\ - subs r0, r1\n\ - lsls r0, 25\n\ -_081413EA:\n\ - lsrs r5, r0, 24\n\ - ldr r0, _08141530 @ =gUnknown_0203AB88\n\ - ldr r6, [r0]\n\ - ldrb r0, [r6, 0x4]\n\ - lsls r0, 30\n\ - lsrs r0, 25\n\ - ldr r1, _08141534 @ =gUnknown_085B6348\n\ - adds r0, r1\n\ - lsls r4, 24\n\ - asrs r4, 24\n\ - ldrh r0, [r0, 0x1A]\n\ - adds r4, r0\n\ - adds r0, r6, 0\n\ - adds r0, 0x80\n\ - strh r4, [r0]\n\ - lsls r4, 16\n\ - asrs r4, 16\n\ - adds r0, r4, 0\n\ - bl __floatsisf\n\ - cmp r4, 0\n\ - bge _0814141C\n\ - ldr r1, _08141538 @ =0x47800000\n\ - bl __addsf3\n\ -_0814141C:\n\ - ldr r1, _0814153C @ =0x40A00000\n\ - bl __divsf3\n\ - bl __fixunssfsi\n\ - lsls r0, 16\n\ - lsrs r4, r0, 16\n\ - lsls r0, r4, 1\n\ - adds r0, r4\n\ - movs r2, 0x82\n\ - adds r2, r6\n\ - mov r8, r2\n\ - strh r0, [r2]\n\ - adds r0, r6, 0\n\ - adds r0, 0x84\n\ - strh r4, [r0]\n\ - adds r0, 0x2\n\ - strh r4, [r0]\n\ - movs r0, 0x88\n\ - adds r0, r6\n\ - mov r9, r0\n\ - movs r0, 0x1\n\ - ands r0, r7\n\ - lsls r1, r5, 24\n\ - asrs r1, 24\n\ - adds r0, r1\n\ - lsls r0, 1\n\ - add r0, sp\n\ - movs r1, 0\n\ - ldrsh r4, [r0, r1]\n\ - adds r0, r4, 0\n\ - bl __floatsisf\n\ - cmp r4, 0\n\ - bge _08141468\n\ - ldr r1, _08141538 @ =0x47800000\n\ - bl __addsf3\n\ -_08141468:\n\ - mov r2, r9\n\ - str r0, [r2]\n\ - adds r7, r6, 0\n\ - adds r7, 0x8C\n\ - ldrb r0, [r6, 0x4]\n\ - lsls r0, 30\n\ - lsrs r0, 25\n\ - ldr r5, _08141534 @ =gUnknown_085B6348\n\ - adds r0, r5\n\ - movs r1, 0x18\n\ - ldrsh r4, [r0, r1]\n\ - adds r0, r4, 0\n\ - bl __floatsisf\n\ - adds r5, r0, 0\n\ - cmp r4, 0\n\ - bge _08141492\n\ - ldr r1, _08141538 @ =0x47800000\n\ - bl __addsf3\n\ - adds r5, r0, 0\n\ -_08141492:\n\ - str r5, [r7]\n\ - adds r7, r6, 0\n\ - adds r7, 0x90\n\ - ldr r1, _08141540 @ =0x3F000000\n\ - adds r0, r5, 0\n\ - bl __mulsf3\n\ - adds r1, r5, 0\n\ - bl __subsf3\n\ - adds r5, r0, 0\n\ - mov r2, r8\n\ - movs r0, 0\n\ - ldrsh r4, [r2, r0]\n\ - adds r0, r4, 0\n\ - bl __floatsisf\n\ - adds r2, r0, 0\n\ - cmp r4, 0\n\ - bge _081414C2\n\ - ldr r1, _08141538 @ =0x47800000\n\ - bl __addsf3\n\ - adds r2, r0, 0\n\ -_081414C2:\n\ - adds r0, r5, 0\n\ - adds r1, r2, 0\n\ - bl __divsf3\n\ - str r0, [r7]\n\ - adds r1, r6, 0\n\ - adds r1, 0x94\n\ - ldr r0, _08141544 @ =0x42880000\n\ - str r0, [r1]\n\ - adds r1, 0x8\n\ - ldr r0, _08141548 @ =0x00000000\n\ - str r0, [r1]\n\ - adds r5, r6, 0\n\ - adds r5, 0x98\n\ - mov r1, r8\n\ - movs r2, 0\n\ - ldrsh r4, [r1, r2]\n\ - adds r0, r4, 0\n\ - bl __floatsisf\n\ - adds r2, r0, 0\n\ - cmp r4, 0\n\ - bge _081414F8\n\ - ldr r1, _08141538 @ =0x47800000\n\ - bl __addsf3\n\ - adds r2, r0, 0\n\ -_081414F8:\n\ - ldr r0, _0814154C @ =0x41000000\n\ - adds r1, r2, 0\n\ - bl __divsf3\n\ - bl __negsf2\n\ - str r0, [r5]\n\ - adds r1, r6, 0\n\ - adds r1, 0xA0\n\ - ldr r0, _08141550 @ =0x42100000\n\ - str r0, [r1]\n\ - ldr r1, _08141554 @ =gTasks\n\ - mov r5, r10\n\ - lsls r0, r5, 2\n\ - add r0, r10\n\ - lsls r0, 3\n\ - adds r0, r1\n\ - ldr r1, _08141558 @ =sub_814155C\n\ - str r1, [r0]\n\ - add sp, 0x8\n\ - pop {r3-r5}\n\ - mov r8, r3\n\ - mov r9, r4\n\ - mov r10, r5\n\ - pop {r4-r7}\n\ - pop {r0}\n\ - bx r0\n\ - .align 2, 0\n\ -_08141530:\n\ - .4byte gUnknown_0203AB88\n\ -_08141534:\n\ - .4byte gUnknown_085B6348\n\ -_08141538:\n\ - .4byte 0x47800000\n\ -_0814153C:\n\ - .4byte 0x40A00000\n\ -_08141540:\n\ - .4byte 0x3F000000\n\ -_08141544:\n\ - .4byte 0x42880000\n\ -_08141548:\n\ - .4byte 0x00000000\n\ -_0814154C:\n\ - .4byte 0x41000000\n\ -_08141550:\n\ - .4byte 0x42100000\n\ -_08141554:\n\ - .4byte gTasks\n\ -_08141558:\n\ - .4byte sub_814155C"); -} -#endif // NONMATCHING static void sub_814155C(u8 taskId) { @@ -4345,17 +4088,17 @@ static void sub_81448B8(struct Sprite *sprite) gUnknown_0203AB88->var38 = sprite; } -#ifdef NONMATCHING static void sub_8144A24(struct Sprite *sprite) { u8 z; u16 o; - u8 h = 0; // r10 (sp+0xc) - u8 j = 5; // r9 (r9) - u8 p = 0; // sp+0xc (sp+0x10) - u8 i; - u8 s[10] = {}; // sp+0 (sp+0) - u16 t = Random(); // sp+0x10 (r10) + u8 h = 0; + u8 j = 5; + u8 p = 0; + u8 i = 0; + u8 val; + u8 s[10] = {}; + u16 rand = Random(); gUnknown_0203AB88->var7D = 1; gUnknown_0203AB88->var03_5 = TRUE; @@ -4364,13 +4107,14 @@ static void sub_8144A24(struct Sprite *sprite) gUnknown_0203AB88->var88 = sprite->data[3]; gUnknown_0203AB88->var98 = 0.0f; gUnknown_0203AB88->var8C = gUnknown_085B6348[gUnknown_0203AB88->var04_0].var1C; + o = (gUnknown_0203AB88->var04_0 * 30 + 33) + (0x1 - gUnknown_0203AB88->var03_0) * 15; for (i = 0; i < 4; i++) { if (o < sprite->data[3] && sprite->data[3] <= o + 90) { sprite->data[0] = i / 2; - gUnknown_0203AB88->var03_0 = i & 1; + gUnknown_0203AB88->var03_0 = i % 2; break; } if (i == 3) @@ -4381,354 +4125,52 @@ static void sub_8144A24(struct Sprite *sprite) } o += 90; } + if (gUnknown_0203AB88->var03_0) { if (sprite->data[0]) - { PlayCry1(SPECIES_TAILLOW, -63); - } else - { PlayCry1(SPECIES_TAILLOW, 63); - } } else { PlayCry1(SPECIES_SHROOMISH, -63); } - i = 2; + + val = 2; z = (gUnknown_0203AB88->var7F + 2) % 12; + if (gUnknown_0203AB88->var03_0 == 1 && gUnknown_0203AB88->var04_0 == 1) j += 6; else - j += i; - for (; i < j; i++) + j += val; + + for (i = val; i < j; i++) { if (!(gUnknown_0203AB88->var08 & gUnknown_085B62E4[z].var04)) { s[h++] = i; - if (!p && (gUnknown_085B62E4[z].var04 & gUnknown_085B6154[gUnknown_0203AB88->var1B[gUnknown_0203AB88->var1A_0]].var00)) - { + if (p == 0 && (gUnknown_085B62E4[z].var04 & gUnknown_085B6154[gUnknown_0203AB88->var1B[gUnknown_0203AB88->var1A_0]].var0C)) p = i; - } } z = (z + 1) % 0xC; } + if ((gUnknown_0203AB88->var03_0 + 1) & gUnknown_0203AB88->var02) { - if (p && (t & 0xFF) < 0xc0) - { + if (p && (rand & 0xFF) < 0xc0) sprite->data[7] = p; - } else - { - sprite->data[7] = s[t % h]; - } + sprite->data[7] = s[rand % h]; } else { - sprite->data[7] = s[t % h]; + sprite->data[7] = s[rand % h]; } + sprite->callback = sub_8144168; } -#else -NAKED -static void sub_8144A24(struct Sprite *sprite) -{ - asm_unified("push {r4-r7,lr}\n\ - mov r7, r10\n\ - mov r6, r9\n\ - mov r5, r8\n\ - push {r5-r7}\n\ - sub sp, 0x14\n\ - adds r7, r0, 0\n\ - movs r0, 0\n\ - mov r9, r0\n\ - movs r1, 0x5\n\ - mov r8, r1\n\ - str r0, [sp, 0xC]\n\ - mov r0, sp\n\ - movs r1, 0\n\ - movs r2, 0xA\n\ - bl memset\n\ - bl Random\n\ - lsls r0, 16\n\ - lsrs r0, 16\n\ - str r0, [sp, 0x10]\n\ - ldr r3, _08144B10 @ =gUnknown_0203AB88\n\ - ldr r0, [r3]\n\ - adds r0, 0x7D\n\ - movs r5, 0x1\n\ - strb r5, [r0]\n\ - ldr r2, [r3]\n\ - ldrb r0, [r2, 0x3]\n\ - movs r1, 0x20\n\ - orrs r0, r1\n\ - strb r0, [r2, 0x3]\n\ - ldr r2, [r3]\n\ - ldrb r1, [r2, 0x3]\n\ - movs r0, 0x41\n\ - negs r0, r0\n\ - ands r0, r1\n\ - strb r0, [r2, 0x3]\n\ - ldr r0, [r3]\n\ - adds r0, 0x7E\n\ - movs r1, 0xFF\n\ - strb r1, [r0]\n\ - ldr r6, [r3]\n\ - adds r4, r6, 0\n\ - adds r4, 0x88\n\ - movs r1, 0x34\n\ - ldrsh r0, [r7, r1]\n\ - bl __floatsisf\n\ - str r0, [r4]\n\ - adds r1, r6, 0\n\ - adds r1, 0x98\n\ - ldr r0, _08144B14 @ =0x00000000\n\ - str r0, [r1]\n\ - adds r2, r6, 0\n\ - adds r2, 0x8C\n\ - ldr r1, _08144B18 @ =gUnknown_085B6348\n\ - ldrb r0, [r6, 0x4]\n\ - lsls r0, 30\n\ - lsrs r0, 25\n\ - adds r1, 0x1C\n\ - adds r0, r1\n\ - ldr r0, [r0]\n\ - str r0, [r2]\n\ - ldrb r0, [r6, 0x4]\n\ - lsls r0, 30\n\ - lsrs r0, 30\n\ - lsls r1, r0, 4\n\ - subs r1, r0\n\ - lsls r1, 1\n\ - adds r1, 0x21\n\ - ldrb r0, [r6, 0x3]\n\ - lsls r0, 27\n\ - lsrs r0, 27\n\ - subs r5, r0\n\ - lsls r0, r5, 4\n\ - subs r0, r5\n\ - adds r1, r0\n\ - lsls r1, 16\n\ - lsrs r1, 16\n\ - mov r5, r9\n\ - movs r0, 0x34\n\ - ldrsh r2, [r7, r0]\n\ -_08144ACA:\n\ - cmp r1, r2\n\ - bge _08144AD6\n\ - adds r0, r1, 0\n\ - adds r0, 0x5A\n\ - cmp r2, r0\n\ - ble _08144B38\n\ -_08144AD6:\n\ - cmp r5, 0x3\n\ - beq _08144B1C\n\ - adds r0, r1, 0\n\ - adds r0, 0x5A\n\ - lsls r0, 16\n\ - lsrs r1, r0, 16\n\ - adds r0, r5, 0x1\n\ - lsls r0, 24\n\ - lsrs r5, r0, 24\n\ - cmp r5, 0x3\n\ - bls _08144ACA\n\ -_08144AEC:\n\ - ldr r0, _08144B10 @ =gUnknown_0203AB88\n\ - ldr r0, [r0]\n\ - ldrb r1, [r0, 0x3]\n\ - movs r0, 0x1F\n\ - ands r0, r1\n\ - cmp r0, 0\n\ - beq _08144B64\n\ - movs r1, 0x2E\n\ - ldrsh r0, [r7, r1]\n\ - cmp r0, 0\n\ - beq _08144B58\n\ - movs r0, 0x98\n\ - lsls r0, 1\n\ - movs r1, 0x3F\n\ - negs r1, r1\n\ - bl PlayCry1\n\ - b _08144B70\n\ - .align 2, 0\n\ -_08144B10:\n\ - .4byte gUnknown_0203AB88\n\ -_08144B14:\n\ - .4byte 0x00000000\n\ -_08144B18:\n\ - .4byte gUnknown_085B6348\n\ -_08144B1C:\n\ - movs r0, 0x1\n\ - strh r0, [r7, 0x2E]\n\ - ldr r0, =gUnknown_0203AB88\n\ - ldr r2, [r0]\n\ - ldrb r1, [r2, 0x3]\n\ - movs r0, 0x20\n\ - negs r0, r0\n\ - ands r0, r1\n\ - movs r1, 0x1\n\ - orrs r0, r1\n\ - strb r0, [r2, 0x3]\n\ - b _08144AEC\n\ - .pool\n\ -_08144B38:\n\ - lsrs r0, r5, 1\n\ - strh r0, [r7, 0x2E]\n\ - ldr r0, =gUnknown_0203AB88\n\ - ldr r3, [r0]\n\ - movs r1, 0x1\n\ - ands r1, r5\n\ - ldrb r2, [r3, 0x3]\n\ - movs r0, 0x20\n\ - negs r0, r0\n\ - ands r0, r2\n\ - orrs r0, r1\n\ - strb r0, [r3, 0x3]\n\ - b _08144AEC\n\ - .pool\n\ -_08144B58:\n\ - movs r0, 0x98\n\ - lsls r0, 1\n\ - movs r1, 0x3F\n\ - bl PlayCry1\n\ - b _08144B70\n\ -_08144B64:\n\ - movs r0, 0x99\n\ - lsls r0, 1\n\ - movs r1, 0x3F\n\ - negs r1, r1\n\ - bl PlayCry1\n\ -_08144B70:\n\ - movs r0, 0x2\n\ - mov r10, r0\n\ - ldr r4, =gUnknown_0203AB88\n\ - ldr r5, [r4]\n\ - adds r0, r5, 0\n\ - adds r0, 0x7F\n\ - ldrb r0, [r0]\n\ - adds r0, 0x2\n\ - movs r1, 0xC\n\ - bl __modsi3\n\ - lsls r0, 24\n\ - lsrs r6, r0, 24\n\ - ldrb r1, [r5, 0x3]\n\ - movs r0, 0x1F\n\ - ands r0, r1\n\ - cmp r0, 0x1\n\ - bne _08144BA8\n\ - ldrb r1, [r5, 0x4]\n\ - movs r0, 0x3\n\ - ands r0, r1\n\ - cmp r0, 0x1\n\ - bne _08144BA8\n\ - mov r0, r8\n\ - adds r0, 0x6\n\ - b _08144BAC\n\ - .pool\n\ -_08144BA8:\n\ - mov r0, r8\n\ - add r0, r10\n\ -_08144BAC:\n\ - lsls r0, 24\n\ - lsrs r0, 24\n\ - mov r8, r0\n\ - mov r5, r10\n\ - cmp r5, r8\n\ - bcs _08144C18\n\ - ldr r1, =gUnknown_085B6154+0xC\n\ - mov r10, r1\n\ -_08144BBC:\n\ - ldr r3, [r4]\n\ - lsls r0, r6, 3\n\ - ldr r1, =gUnknown_085B62E4+0x4\n\ - adds r0, r1\n\ - ldr r1, [r3, 0x8]\n\ - ldr r2, [r0]\n\ - ands r1, r2\n\ - cmp r1, 0\n\ - bne _08144C02\n\ - mov r0, r9\n\ - adds r1, r0, 0x1\n\ - lsls r1, 24\n\ - lsrs r1, 24\n\ - mov r9, r1\n\ - add r0, sp\n\ - strb r5, [r0]\n\ - ldr r0, [sp, 0xC]\n\ - cmp r0, 0\n\ - bne _08144C02\n\ - ldrb r1, [r3, 0x1A]\n\ - lsls r1, 28\n\ - lsrs r1, 28\n\ - adds r0, r3, 0\n\ - adds r0, 0x1B\n\ - adds r0, r1\n\ - ldrb r1, [r0]\n\ - lsls r0, r1, 2\n\ - adds r0, r1\n\ - lsls r0, 2\n\ - add r0, r10\n\ - ldr r0, [r0]\n\ - ands r2, r0\n\ - cmp r2, 0\n\ - beq _08144C02\n\ - str r5, [sp, 0xC]\n\ -_08144C02:\n\ - adds r0, r6, 0x1\n\ - movs r1, 0xC\n\ - bl __modsi3\n\ - lsls r0, 24\n\ - lsrs r6, r0, 24\n\ - adds r0, r5, 0x1\n\ - lsls r0, 24\n\ - lsrs r5, r0, 24\n\ - cmp r5, r8\n\ - bcc _08144BBC\n\ -_08144C18:\n\ - ldr r0, [r4]\n\ - ldrb r1, [r0, 0x3]\n\ - lsls r1, 27\n\ - lsrs r1, 27\n\ - adds r1, 0x1\n\ - ldrb r0, [r0, 0x2]\n\ - ands r1, r0\n\ - cmp r1, 0\n\ - beq _08144C48\n\ - ldr r1, [sp, 0xC]\n\ - cmp r1, 0\n\ - beq _08144C48\n\ - movs r0, 0xFF\n\ - ldr r1, [sp, 0x10]\n\ - ands r0, r1\n\ - cmp r0, 0xBF\n\ - bhi _08144C48\n\ - mov r0, sp\n\ - ldrh r0, [r0, 0xC]\n\ - b _08144C54\n\ - .pool\n\ -_08144C48:\n\ - ldr r0, [sp, 0x10]\n\ - mov r1, r9\n\ - bl __modsi3\n\ - add r0, sp\n\ - ldrb r0, [r0]\n\ -_08144C54:\n\ - strh r0, [r7, 0x3C]\n\ - ldr r1, =sub_8144168\n\ - str r1, [r7, 0x1C]\n\ - add sp, 0x14\n\ - pop {r3-r5}\n\ - mov r8, r3\n\ - mov r9, r4\n\ - mov r10, r5\n\ - pop {r4-r7}\n\ - pop {r0}\n\ - bx r0\n\ - .pool"); -} -#endif // NONMATCHING static const u16 gUnknown_085B7B1A[] = { 0x907, @@ -4955,7 +4397,7 @@ static void sub_81450D8(struct Sprite *sprite) static void sub_8145218(struct Sprite *sprite) { s8 t[2] = {-1, 1}; - + if (sprite->data[1]-- >= 0) { sprite->pos1.x += t[gUnknown_0203AB88->var38->data[0]] * 2; diff --git a/src/water.c b/src/water.c index 9aa08bf01..4480c3f43 100644 --- a/src/water.c +++ b/src/water.c @@ -1405,479 +1405,71 @@ void sub_8107CC4(u8 taskId) } } -#ifdef NONMATCHING void sub_8107D58(u8 taskId) { s16 i; struct ScanlineEffectParams params; struct Task *task = &gTasks[taskId]; - // u16 *scanlineBuffer; switch (task->data[0]) { - case 0: - for (i = 0; i < task->data[4]; i++) - { - /* scanlineBuffer = &gScanlineEffectRegBuffers[0][i]; - *(u16 *)(&gScanlineEffect) = task->data[2]; - *scanlineBuffer = task->data[2] & -1; */ - gScanlineEffectRegBuffers[1][i] = task->data[2]; - gScanlineEffectRegBuffers[0][i] = (u16)((int)(task->data[2] & 0xFFFF)); - } - for (i = task->data[4]; i < task->data[5]; i++) - { - gScanlineEffectRegBuffers[1][i] = task->data[1]; - gScanlineEffectRegBuffers[0][i] = (u16)((int)(task->data[1] & 0xFFFF)); - } - for (i = task->data[5]; i < 160; i++) - { - gScanlineEffectRegBuffers[1][i] = task->data[2]; - gScanlineEffectRegBuffers[0][i] = (u16)((int)(task->data[2] & 0xFFFF)); - } - if (task->data[4] == 0) - { - gScanlineEffectRegBuffers[1][i] = task->data[1]; - gScanlineEffectRegBuffers[0][i] = task->data[1]; - } - else - { - gScanlineEffectRegBuffers[1][i] = task->data[2]; - gScanlineEffectRegBuffers[0][i] = task->data[2]; - } - params.dmaDest = (vu16 *)REG_ADDR_BLDALPHA; - params.dmaControl = SCANLINE_EFFECT_DMACNT_16BIT; - params.initState = 1; - params.unused9 = 0; - ScanlineEffect_SetParams(params); - task->data[0]++; - break; - case 1: - if (task->data[3] == 0) - { - if (--task->data[4] <= 0) - { - task->data[4] = 0; - task->data[0]++; - } - } - else if (++task->data[5] > 111) + case 0: + for (i = 0; i < task->data[4]; i++) + gScanlineEffectRegBuffers[0][i] = gScanlineEffectRegBuffers[1][i] = task->data[2]; + for (i = task->data[4]; i < task->data[5]; i++) + gScanlineEffectRegBuffers[0][i] = gScanlineEffectRegBuffers[1][i] = task->data[1]; + for (i = task->data[5]; i < 160; i++) + gScanlineEffectRegBuffers[0][i] = gScanlineEffectRegBuffers[1][i] = task->data[2]; + + if (task->data[4] == 0) + gScanlineEffectRegBuffers[0][i] = gScanlineEffectRegBuffers[1][i] = task->data[1]; + else + gScanlineEffectRegBuffers[0][i] = gScanlineEffectRegBuffers[1][i] = task->data[2]; + + params.dmaDest = (vu16 *)REG_ADDR_BLDALPHA; + params.dmaControl = SCANLINE_EFFECT_DMACNT_16BIT; + params.initState = 1; + params.unused9 = 0; + ScanlineEffect_SetParams(params); + task->data[0]++; + break; + case 1: + if (task->data[3] == 0) + { + if (--task->data[4] <= 0) { + task->data[4] = 0; task->data[0]++; } - for (i = 0; i < task->data[4]; i++) - { - gScanlineEffectRegBuffers[gScanlineEffect.srcBuffer][i] = task->data[2]; - } - for (i = task->data[4]; i < task->data[5]; i++) - { - gScanlineEffectRegBuffers[gScanlineEffect.srcBuffer][i] = task->data[1]; - } - for (i = task->data[5]; i < 160; i++) - { - gScanlineEffectRegBuffers[gScanlineEffect.srcBuffer][i] = task->data[2]; - } - break; - case 2: - for (i = 0; i < task->data[4]; i++) - { - gScanlineEffectRegBuffers[gScanlineEffect.srcBuffer][i] = task->data[2]; - } - for (i = task->data[4]; i < task->data[5]; i++) - { - gScanlineEffectRegBuffers[gScanlineEffect.srcBuffer][i] = task->data[1]; - } - for (i = task->data[5]; i < 160; i++) - { - gScanlineEffectRegBuffers[gScanlineEffect.srcBuffer][i] = task->data[2]; - } - if (task->data[15] == -1) - { - ScanlineEffect_Stop(); - DestroyTask(taskId); - } - break; + } + else if (++task->data[5] > 111) + { + task->data[0]++; + } + + for (i = 0; i < task->data[4]; i++) + gScanlineEffectRegBuffers[gScanlineEffect.srcBuffer][i] = task->data[2]; + for (i = task->data[4]; i < task->data[5]; i++) + gScanlineEffectRegBuffers[gScanlineEffect.srcBuffer][i] = task->data[1]; + for (i = task->data[5]; i < 160; i++) + gScanlineEffectRegBuffers[gScanlineEffect.srcBuffer][i] = task->data[2]; + break; + case 2: + for (i = 0; i < task->data[4]; i++) + gScanlineEffectRegBuffers[gScanlineEffect.srcBuffer][i] = task->data[2]; + for (i = task->data[4]; i < task->data[5]; i++) + gScanlineEffectRegBuffers[gScanlineEffect.srcBuffer][i] = task->data[1]; + for (i = task->data[5]; i < 160; i++) + gScanlineEffectRegBuffers[gScanlineEffect.srcBuffer][i] = task->data[2]; + + if (task->data[15] == -1) + { + ScanlineEffect_Stop(); + DestroyTask(taskId); + } + break; } } -#else -NAKED -void sub_8107D58(u8 taskId) -{ - asm_unified("push {r4-r7,lr}\n\ - sub sp, 0xC\n\ - lsls r0, 24\n\ - lsrs r7, r0, 24\n\ - lsls r0, r7, 2\n\ - adds r0, r7\n\ - lsls r0, 3\n\ - ldr r1, =gTasks\n\ - adds r4, r0, r1\n\ - movs r1, 0x8\n\ - ldrsh r0, [r4, r1]\n\ - cmp r0, 0x1\n\ - bne _08107D74\n\ - b _08107EAC\n\ -_08107D74:\n\ - cmp r0, 0x1\n\ - bgt _08107D84\n\ - cmp r0, 0\n\ - beq _08107D8C\n\ - b _08108022\n\ - .pool\n\ -_08107D84:\n\ - cmp r0, 0x2\n\ - bne _08107D8A\n\ - b _08107F78\n\ -_08107D8A:\n\ - b _08108022\n\ -_08107D8C:\n\ - movs r3, 0\n\ - movs r2, 0x10\n\ - ldrsh r0, [r4, r2]\n\ - ldr r1, =gScanlineEffectRegBuffers\n\ - mov r12, r1\n\ - cmp r3, r0\n\ - bge _08107DCA\n\ - mov r7, r12\n\ - movs r5, 0xF0\n\ - lsls r5, 3\n\ - add r5, r12\n\ - ldr r6, =0x0000ffff\n\ -_08107DA4:\n\ - lsls r2, r3, 16\n\ - asrs r2, 16\n\ - lsls r1, r2, 1\n\ - adds r3, r1, r7\n\ - adds r1, r5\n\ - ldrh r0, [r4, 0xC]\n\ - strh r0, [r1]\n\ - ldrh r1, [r4, 0xC]\n\ - adds r0, r6, 0\n\ - ands r0, r1\n\ - strh r0, [r3]\n\ - adds r2, 0x1\n\ - lsls r2, 16\n\ - lsrs r3, r2, 16\n\ - asrs r2, 16\n\ - movs r1, 0x10\n\ - ldrsh r0, [r4, r1]\n\ - cmp r2, r0\n\ - blt _08107DA4\n\ -_08107DCA:\n\ - ldrh r3, [r4, 0x10]\n\ - lsls r2, r3, 16\n\ - asrs r1, r2, 16\n\ - movs r3, 0x12\n\ - ldrsh r0, [r4, r3]\n\ - cmp r1, r0\n\ - bge _08107E04\n\ - ldr r5, =gScanlineEffectRegBuffers\n\ - movs r0, 0xF0\n\ - lsls r0, 3\n\ - adds r6, r5, r0\n\ - ldr r7, =0x0000ffff\n\ -_08107DE2:\n\ - asrs r2, 16\n\ - lsls r1, r2, 1\n\ - adds r3, r1, r5\n\ - adds r1, r6\n\ - ldrh r0, [r4, 0xA]\n\ - strh r0, [r1]\n\ - ldrh r1, [r4, 0xA]\n\ - adds r0, r7, 0\n\ - ands r0, r1\n\ - strh r0, [r3]\n\ - adds r2, 0x1\n\ - lsls r2, 16\n\ - asrs r1, r2, 16\n\ - movs r3, 0x12\n\ - ldrsh r0, [r4, r3]\n\ - cmp r1, r0\n\ - blt _08107DE2\n\ -_08107E04:\n\ - ldrh r3, [r4, 0x12]\n\ - lsls r2, r3, 16\n\ - asrs r0, r2, 16\n\ - cmp r0, 0x9F\n\ - bgt _08107E3A\n\ - ldr r5, =gScanlineEffectRegBuffers\n\ - movs r0, 0xF0\n\ - lsls r0, 3\n\ - adds r6, r5, r0\n\ - ldr r7, =0x0000ffff\n\ -_08107E18:\n\ - asrs r2, 16\n\ - lsls r1, r2, 1\n\ - adds r3, r1, r5\n\ - adds r1, r6\n\ - ldrh r0, [r4, 0xC]\n\ - strh r0, [r1]\n\ - ldrh r1, [r4, 0xC]\n\ - adds r0, r7, 0\n\ - ands r0, r1\n\ - strh r0, [r3]\n\ - adds r2, 0x1\n\ - lsls r2, 16\n\ - lsrs r3, r2, 16\n\ - lsls r2, r3, 16\n\ - asrs r0, r2, 16\n\ - cmp r0, 0x9F\n\ - ble _08107E18\n\ -_08107E3A:\n\ - movs r1, 0x10\n\ - ldrsh r0, [r4, r1]\n\ - cmp r0, 0\n\ - bne _08107E64\n\ - lsls r0, r3, 16\n\ - asrs r0, 15\n\ - mov r3, r12\n\ - adds r2, r0, r3\n\ - movs r1, 0xF0\n\ - lsls r1, 3\n\ - add r1, r12\n\ - adds r0, r1\n\ - ldrh r1, [r4, 0xA]\n\ - strh r1, [r0]\n\ - ldrh r0, [r4, 0xA]\n\ - b _08107E7A\n\ - .pool\n\ -_08107E64:\n\ - lsls r0, r3, 16\n\ - asrs r0, 15\n\ - mov r1, r12\n\ - adds r2, r0, r1\n\ - movs r1, 0xF0\n\ - lsls r1, 3\n\ - add r1, r12\n\ - adds r0, r1\n\ - ldrh r1, [r4, 0xC]\n\ - strh r1, [r0]\n\ - ldrh r0, [r4, 0xC]\n\ -_08107E7A:\n\ - strh r0, [r2]\n\ - ldr r0, =0x04000052\n\ - str r0, [sp]\n\ - ldr r0, =0xa2600001\n\ - str r0, [sp, 0x4]\n\ - mov r1, sp\n\ - movs r2, 0\n\ - movs r0, 0x1\n\ - strb r0, [r1, 0x8]\n\ - mov r0, sp\n\ - strb r2, [r0, 0x9]\n\ - ldr r0, [sp]\n\ - ldr r1, [sp, 0x4]\n\ - ldr r2, [sp, 0x8]\n\ - bl ScanlineEffect_SetParams\n\ - ldrh r0, [r4, 0x8]\n\ - adds r0, 0x1\n\ - strh r0, [r4, 0x8]\n\ - b _08108022\n\ - .pool\n\ -_08107EAC:\n\ - movs r2, 0xE\n\ - ldrsh r1, [r4, r2]\n\ - cmp r1, 0\n\ - bne _08107EC4\n\ - ldrh r0, [r4, 0x10]\n\ - subs r0, 0x1\n\ - strh r0, [r4, 0x10]\n\ - lsls r0, 16\n\ - cmp r0, 0\n\ - bgt _08107ED8\n\ - strh r1, [r4, 0x10]\n\ - b _08107ED2\n\ -_08107EC4:\n\ - ldrh r0, [r4, 0x12]\n\ - adds r0, 0x1\n\ - strh r0, [r4, 0x12]\n\ - lsls r0, 16\n\ - asrs r0, 16\n\ - cmp r0, 0x6F\n\ - ble _08107ED8\n\ -_08107ED2:\n\ - ldrh r0, [r4, 0x8]\n\ - adds r0, 0x1\n\ - strh r0, [r4, 0x8]\n\ -_08107ED8:\n\ - movs r3, 0\n\ - movs r1, 0x10\n\ - ldrsh r0, [r4, r1]\n\ - cmp r3, r0\n\ - bge _08107F0C\n\ - ldr r6, =gScanlineEffectRegBuffers\n\ - ldr r5, =gScanlineEffect\n\ -_08107EE6:\n\ - lsls r1, r3, 16\n\ - asrs r1, 16\n\ - lsls r3, r1, 1\n\ - ldrb r2, [r5, 0x14]\n\ - lsls r0, r2, 4\n\ - subs r0, r2\n\ - lsls r0, 7\n\ - adds r3, r0\n\ - adds r3, r6\n\ - ldrh r0, [r4, 0xC]\n\ - strh r0, [r3]\n\ - adds r1, 0x1\n\ - lsls r1, 16\n\ - lsrs r3, r1, 16\n\ - asrs r1, 16\n\ - movs r2, 0x10\n\ - ldrsh r0, [r4, r2]\n\ - cmp r1, r0\n\ - blt _08107EE6\n\ -_08107F0C:\n\ - ldrh r3, [r4, 0x10]\n\ - lsls r2, r3, 16\n\ - asrs r1, r2, 16\n\ - movs r3, 0x12\n\ - ldrsh r0, [r4, r3]\n\ - cmp r1, r0\n\ - bge _08107F40\n\ - ldr r6, =gScanlineEffectRegBuffers\n\ - ldr r5, =gScanlineEffect\n\ -_08107F1E:\n\ - asrs r3, r2, 16\n\ - lsls r2, r3, 1\n\ - ldrb r1, [r5, 0x14]\n\ - lsls r0, r1, 4\n\ - subs r0, r1\n\ - lsls r0, 7\n\ - adds r2, r0\n\ - adds r2, r6\n\ - ldrh r0, [r4, 0xA]\n\ - strh r0, [r2]\n\ - adds r3, 0x1\n\ - lsls r2, r3, 16\n\ - asrs r1, r2, 16\n\ - movs r3, 0x12\n\ - ldrsh r0, [r4, r3]\n\ - cmp r1, r0\n\ - blt _08107F1E\n\ -_08107F40:\n\ - ldrh r3, [r4, 0x12]\n\ - lsls r1, r3, 16\n\ - asrs r0, r1, 16\n\ - cmp r0, 0x9F\n\ - bgt _08108022\n\ - ldr r6, =gScanlineEffectRegBuffers\n\ - ldr r5, =gScanlineEffect\n\ -_08107F4E:\n\ - asrs r3, r1, 16\n\ - lsls r2, r3, 1\n\ - ldrb r1, [r5, 0x14]\n\ - lsls r0, r1, 4\n\ - subs r0, r1\n\ - lsls r0, 7\n\ - adds r2, r0\n\ - adds r2, r6\n\ - ldrh r0, [r4, 0xC]\n\ - strh r0, [r2]\n\ - adds r3, 0x1\n\ - lsls r1, r3, 16\n\ - asrs r0, r1, 16\n\ - cmp r0, 0x9F\n\ - ble _08107F4E\n\ - b _08108022\n\ - .pool\n\ -_08107F78:\n\ - movs r3, 0\n\ - movs r1, 0x10\n\ - ldrsh r0, [r4, r1]\n\ - cmp r3, r0\n\ - bge _08107FAC\n\ - ldr r6, =gScanlineEffectRegBuffers\n\ - ldr r5, =gScanlineEffect\n\ -_08107F86:\n\ - lsls r1, r3, 16\n\ - asrs r1, 16\n\ - lsls r3, r1, 1\n\ - ldrb r2, [r5, 0x14]\n\ - lsls r0, r2, 4\n\ - subs r0, r2\n\ - lsls r0, 7\n\ - adds r3, r0\n\ - adds r3, r6\n\ - ldrh r0, [r4, 0xC]\n\ - strh r0, [r3]\n\ - adds r1, 0x1\n\ - lsls r1, 16\n\ - lsrs r3, r1, 16\n\ - asrs r1, 16\n\ - movs r2, 0x10\n\ - ldrsh r0, [r4, r2]\n\ - cmp r1, r0\n\ - blt _08107F86\n\ -_08107FAC:\n\ - ldrh r3, [r4, 0x10]\n\ - lsls r2, r3, 16\n\ - asrs r1, r2, 16\n\ - movs r3, 0x12\n\ - ldrsh r0, [r4, r3]\n\ - cmp r1, r0\n\ - bge _08107FE0\n\ - ldr r6, =gScanlineEffectRegBuffers\n\ - ldr r5, =gScanlineEffect\n\ -_08107FBE:\n\ - asrs r3, r2, 16\n\ - lsls r2, r3, 1\n\ - ldrb r1, [r5, 0x14]\n\ - lsls r0, r1, 4\n\ - subs r0, r1\n\ - lsls r0, 7\n\ - adds r2, r0\n\ - adds r2, r6\n\ - ldrh r0, [r4, 0xA]\n\ - strh r0, [r2]\n\ - adds r3, 0x1\n\ - lsls r2, r3, 16\n\ - asrs r1, r2, 16\n\ - movs r3, 0x12\n\ - ldrsh r0, [r4, r3]\n\ - cmp r1, r0\n\ - blt _08107FBE\n\ -_08107FE0:\n\ - ldrh r3, [r4, 0x12]\n\ - lsls r1, r3, 16\n\ - asrs r0, r1, 16\n\ - cmp r0, 0x9F\n\ - bgt _0810800C\n\ - ldr r6, =gScanlineEffectRegBuffers\n\ - ldr r5, =gScanlineEffect\n\ -_08107FEE:\n\ - asrs r3, r1, 16\n\ - lsls r2, r3, 1\n\ - ldrb r1, [r5, 0x14]\n\ - lsls r0, r1, 4\n\ - subs r0, r1\n\ - lsls r0, 7\n\ - adds r2, r0\n\ - adds r2, r6\n\ - ldrh r0, [r4, 0xC]\n\ - strh r0, [r2]\n\ - adds r3, 0x1\n\ - lsls r1, r3, 16\n\ - asrs r0, r1, 16\n\ - cmp r0, 0x9F\n\ - ble _08107FEE\n\ -_0810800C:\n\ - movs r0, 0x26\n\ - ldrsh r1, [r4, r0]\n\ - movs r0, 0x1\n\ - negs r0, r0\n\ - cmp r1, r0\n\ - bne _08108022\n\ - bl ScanlineEffect_Stop\n\ - adds r0, r7, 0\n\ - bl DestroyTask\n\ -_08108022:\n\ - add sp, 0xC\n\ - pop {r4-r7}\n\ - pop {r0}\n\ - bx r0\n\ - .pool\n"); -} -#endif void sub_8108034(struct Sprite *sprite) { @@ -1925,82 +1517,82 @@ void sub_8108140(u8 taskId) switch (task->data[0]) { - case 0: - sub_80A805C(task, task->data[15], 0x100, 0x100, 224, 0x200, 32); + case 0: + sub_80A805C(task, task->data[15], 0x100, 0x100, 224, 0x200, 32); + task->data[0]++; + case 1: + if (++task->data[3] > 1) + { + task->data[3] = 0; + if (++task->data[4] & 1) + { + gSprites[task->data[15]].pos2.x = 3; + gSprites[task->data[15]].pos1.y++; + } + else + { + gSprites[task->data[15]].pos2.x = -3; + } + } + if (sub_80A80C8(task) == 0) + { + SetBattlerSpriteYOffsetFromYScale(task->data[15]); + gSprites[task->data[15]].pos2.x = 0; + task->data[3] = 0; + task->data[4] = 0; task->data[0]++; - case 1: - if (++task->data[3] > 1) - { - task->data[3] = 0; - if (++task->data[4] & 1) - { - gSprites[task->data[15]].pos2.x = 3; - gSprites[task->data[15]].pos1.y++; - } - else - { - gSprites[task->data[15]].pos2.x = -3; - } - } - if (sub_80A80C8(task) == 0) - { - SetBattlerSpriteYOffsetFromYScale(task->data[15]); - gSprites[task->data[15]].pos2.x = 0; - task->data[3] = 0; - task->data[4] = 0; - task->data[0]++; - } - break; - case 2: - if (++task->data[3] > 4) - { - sub_80A805C(task, task->data[15], 224, 0x200, 384, 224, 8); - task->data[3] = 0; - task->data[0]++; - } - break; - case 3: - if (sub_80A80C8(task) == 0) - { - task->data[3] = 0; - task->data[4] = 0; - task->data[0]++; - } - break; - case 4: - sub_8108408(task, taskId); + } + break; + case 2: + if (++task->data[3] > 4) + { + sub_80A805C(task, task->data[15], 224, 0x200, 384, 224, 8); + task->data[3] = 0; task->data[0]++; - case 5: - if (++task->data[3] > 1) + } + break; + case 3: + if (sub_80A80C8(task) == 0) + { + task->data[3] = 0; + task->data[4] = 0; + task->data[0]++; + } + break; + case 4: + sub_8108408(task, taskId); + task->data[0]++; + case 5: + if (++task->data[3] > 1) + { + task->data[3] = 0; + if (++task->data[4] & 1) + gSprites[task->data[15]].pos2.y += 2; + else + gSprites[task->data[15]].pos2.y -= 2; + if (task->data[4] == 10) { + sub_80A805C(task, task->data[15], 384, 224, 0x100, 0x100, 8); task->data[3] = 0; - if (++task->data[4] & 1) - gSprites[task->data[15]].pos2.y += 2; - else - gSprites[task->data[15]].pos2.y -= 2; - if (task->data[4] == 10) - { - sub_80A805C(task, task->data[15], 384, 224, 0x100, 0x100, 8); - task->data[3] = 0; - task->data[4] = 0; - task->data[0]++; - } - } - break; - case 6: - gSprites[task->data[15]].pos1.y--; - if (sub_80A80C8(task) == 0) - { - ResetSpriteRotScale(task->data[15]); - gSprites[task->data[15]].pos1.y = task->data[5]; task->data[4] = 0; task->data[0]++; } - break; - case 7: - if (task->data[2] == 0) - DestroyAnimVisualTask(taskId); - break; + } + break; + case 6: + gSprites[task->data[15]].pos1.y--; + if (sub_80A80C8(task) == 0) + { + ResetSpriteRotScale(task->data[15]); + gSprites[task->data[15]].pos1.y = task->data[5]; + task->data[4] = 0; + task->data[0]++; + } + break; + case 7: + if (task->data[2] == 0) + DestroyAnimVisualTask(taskId); + break; } } @@ -2073,21 +1665,21 @@ void sub_810851C(struct Sprite *sprite) { switch (sprite->data[0]) { - case 0: - sprite->data[4] += (sprite->data[1] % 6) * 3; - sprite->data[5] += (sprite->data[1] % 3) * 3; - sprite->data[0]++; - case 1: - sprite->data[2] += sprite->data[4]; - sprite->data[3] += sprite->data[5]; - sprite->pos1.x = sprite->data[2] >> 4; - sprite->pos1.y = sprite->data[3] >> 4; - if (sprite->pos1.x < -8 || sprite->pos1.x > 248 || sprite->pos1.y < -8 || sprite->pos1.y > 120) - { - gTasks[sprite->data[6]].data[sprite->data[7]]--; - DestroySprite(sprite); - } - break; + case 0: + sprite->data[4] += (sprite->data[1] % 6) * 3; + sprite->data[5] += (sprite->data[1] % 3) * 3; + sprite->data[0]++; + case 1: + sprite->data[2] += sprite->data[4]; + sprite->data[3] += sprite->data[5]; + sprite->pos1.x = sprite->data[2] >> 4; + sprite->pos1.y = sprite->data[3] >> 4; + if (sprite->pos1.x < -8 || sprite->pos1.x > 248 || sprite->pos1.y < -8 || sprite->pos1.y > 120) + { + gTasks[sprite->data[6]].data[sprite->data[7]]--; + DestroySprite(sprite); + } + break; } } @@ -2119,39 +1711,39 @@ void sub_810862C(u8 taskId) switch (task->data[0]) { - case 0: - if (++task->data[2] > 2) + case 0: + if (++task->data[2] > 2) + { + task->data[2] = 0; + sub_810871C(task, taskId); + } + if (task->data[10] != 0 && task->data[13] == 0) + { + gBattleAnimArgs[0] = 1; + gBattleAnimArgs[1] = 0; + gBattleAnimArgs[2] = 12; + taskId2 = CreateTask(sub_81152DC, 80); + if (taskId2 != 0xFF) { - task->data[2] = 0; - sub_810871C(task, taskId); + gTasks[taskId2].func(taskId2); + gAnimVisualTaskCount++; } - if (task->data[10] != 0 && task->data[13] == 0) + gBattleAnimArgs[0] = 3; + taskId2 = CreateTask(sub_81152DC, 80); + if (taskId2 != 0xFF) { - gBattleAnimArgs[0] = 1; - gBattleAnimArgs[1] = 0; - gBattleAnimArgs[2] = 12; - taskId2 = CreateTask(sub_81152DC, 80); - if (taskId2 != 0xFF) - { - gTasks[taskId2].func(taskId2); - gAnimVisualTaskCount++; - } - gBattleAnimArgs[0] = 3; - taskId2 = CreateTask(sub_81152DC, 80); - if (taskId2 != 0xFF) - { - gTasks[taskId2].func(taskId2); - gAnimVisualTaskCount++; - } - task->data[13] = 1; + gTasks[taskId2].func(taskId2); + gAnimVisualTaskCount++; } - if (task->data[11] >= task->data[12]) - task->data[0]++; - break; - case 1: - if (task->data[9] == 0) - DestroyAnimVisualTask(taskId); - break; + task->data[13] = 1; + } + if (task->data[11] >= task->data[12]) + task->data[0]++; + break; + case 1: + if (task->data[9] == 0) + DestroyAnimVisualTask(taskId); + break; } } @@ -2232,66 +1824,66 @@ void sub_8108978(u8 taskId) switch (task->data[0]) { - case 0: - sub_8108AC0(task); - if (task->data[10] != 0) - task->data[0]++; - break; - case 1: - sub_8108AC0(task); - if (++task->data[1] > 16) + case 0: + sub_8108AC0(task); + if (task->data[10] != 0) + task->data[0]++; + break; + case 1: + sub_8108AC0(task); + if (++task->data[1] > 16) + { + task->data[1] = 0; + task->data[0]++; + } + break; + case 2: + sub_8108AC0(task); + task->data[5] += task->data[7] * 6; + if (!(task->data[5] >= -16 && task->data[5] <= 256)) + { + if (++task->data[12] > 2) + { + task->data[13] = 1; + task->data[0] = 6; + task->data[1] = 0; + } + else { task->data[1] = 0; task->data[0]++; } - break; - case 2: - sub_8108AC0(task); - task->data[5] += task->data[7] * 6; - if (!(task->data[5] >= -16 && task->data[5] <= 256)) - { - if (++task->data[12] > 2) - { - task->data[13] = 1; - task->data[0] = 6; - task->data[1] = 0; - } - else - { - task->data[1] = 0; - task->data[0]++; - } - } - break; - case 3: - sub_8108AC0(task); - task->data[6] -= task->data[7] * 2; - if (++task->data[1] > 7) - task->data[0]++; - break; - case 4: - sub_8108AC0(task); - task->data[5] -= task->data[7] * 6; - if (!(task->data[5] >= -16 && task->data[5] <= 256)) - { - task->data[12]++; - task->data[1] = 0; - task->data[0]++; - } - break; - case 5: - sub_8108AC0(task); - task->data[6] -= task->data[7] * 2; - if (++task->data[1] > 7) - task->data[0] = 2; - break; - case 6: - if (task->data[8] == 0) - task->data[0]++; - break; - default: - DestroyAnimVisualTask(taskId); - break; + } + break; + case 3: + sub_8108AC0(task); + task->data[6] -= task->data[7] * 2; + if (++task->data[1] > 7) + task->data[0]++; + break; + case 4: + sub_8108AC0(task); + task->data[5] -= task->data[7] * 6; + if (!(task->data[5] >= -16 && task->data[5] <= 256)) + { + task->data[12]++; + task->data[1] = 0; + task->data[0]++; + } + break; + case 5: + sub_8108AC0(task); + task->data[6] -= task->data[7] * 2; + if (++task->data[1] > 7) + task->data[0] = 2; + break; + case 6: + if (task->data[8] == 0) + task->data[0]++; + break; + default: + DestroyAnimVisualTask(taskId); + break; } }