From 37d742cbd86eab628e0d84d5957a805c407b0948 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Thu, 1 Nov 2018 15:06:50 +0100 Subject: [PATCH] Document recorded battle --- asm/battle_frontier_2.s | 507 +----------------- include/frontier_util.h | 1 + include/recorded_battle.h | 18 +- src/battle_main.c | 2 +- src/battle_tower.c | 22 +- src/frontier_util.c | 349 +++++++++++- src/recorded_battle.c | 1051 +++++-------------------------------- 7 files changed, 493 insertions(+), 1457 deletions(-) diff --git a/asm/battle_frontier_2.s b/asm/battle_frontier_2.s index d9d36ff47..646443d46 100644 --- a/asm/battle_frontier_2.s +++ b/asm/battle_frontier_2.s @@ -6,512 +6,7 @@ .text -thumb_func_start CreateFrontierBrainPokemon -CreateFrontierBrainPokemon: @ 81A4E04 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x44 - ldr r0, =0x000040cf - bl VarGet - lsls r0, 16 - lsrs r0, 16 - str r0, [sp, 0x20] - bl sub_81A513C - str r0, [sp, 0x24] - ldr r0, [sp, 0x20] - cmp r0, 0x1 - bne _081A4E44 - ldr r0, =0x000003fe - bl TrainerIdToDomeTournamentId - lsls r0, 16 - lsrs r0, 16 - bl GetTrainerMonCountInBits - adds r4, r0, 0 - b _081A4E46 - .pool -_081A4E44: - movs r4, 0x7 -_081A4E46: - bl ZeroEnemyPartyMons - movs r1, 0 - str r1, [sp, 0x18] - bl SetFacilityPtrsGetLevel - lsls r0, 24 - lsrs r0, 24 - str r0, [sp, 0x1C] - movs r2, 0 - str r2, [sp, 0x14] -_081A4E5C: - movs r0, 0x1 - ands r0, r4 - asrs r4, 1 - str r4, [sp, 0x30] - ldr r3, [sp, 0x14] - adds r3, 0x1 - str r3, [sp, 0x28] - cmp r0, 0 - bne _081A4E70 - b _081A4FC4 -_081A4E70: - ldr r4, [sp, 0x14] - lsls r4, 2 - mov r9, r4 - ldr r0, [sp, 0x24] - lsls r0, 4 - str r0, [sp, 0x38] - ldr r1, [sp, 0x20] - lsls r1, 4 - str r1, [sp, 0x34] - ldr r2, [sp, 0x1C] - lsls r2, 24 - str r2, [sp, 0x3C] - ldr r3, [sp, 0x18] - adds r3, 0x1 - str r3, [sp, 0x2C] - ldr r0, [sp, 0x14] - add r0, r9 - lsls r0, 2 - mov r8, r0 -_081A4E96: - bl Random - adds r4, r0, 0 - bl Random - lsls r4, 16 - lsrs r7, r4, 16 - lsls r0, 16 - orrs r7, r0 - ldr r0, =0x0000ef2a - adds r1, r7, 0 - bl IsShinyOtIdPersonality - lsls r0, 24 - cmp r0, 0 - bne _081A4E96 - ldr r4, [sp, 0x38] - ldr r1, [sp, 0x24] - subs r0, r4, r1 - lsls r5, r0, 2 - mov r2, r8 - adds r4, r2, r5 - ldr r3, [sp, 0x34] - ldr r1, [sp, 0x20] - subs r0, r3, r1 - lsls r6, r0, 3 - adds r4, r6 - ldr r2, =sFrontierBrainsMons - adds r4, r2 - adds r0, r7, 0 - bl GetNatureFromPersonality - ldrb r1, [r4, 0x5] - lsls r0, 24 - lsrs r0, 24 - cmp r1, r0 - bne _081A4E96 - ldr r4, [sp, 0x18] - movs r0, 0x64 - adds r3, r4, 0 - muls r3, r0 - mov r8, r3 - ldr r1, =gEnemyParty - add r1, r8 - mov r10, r1 - ldr r4, [sp, 0x14] - add r4, r9 - lsls r4, 2 - adds r0, r4, r5 - adds r0, r6 - ldr r2, =sFrontierBrainsMons - adds r0, r2 - ldrh r1, [r0] - ldr r3, [sp, 0x3C] - lsrs r2, r3, 24 - ldrb r3, [r0, 0x4] - movs r0, 0x1 - str r0, [sp] - str r7, [sp, 0x4] - str r0, [sp, 0x8] - ldr r0, =0x0000ef2a - str r0, [sp, 0xC] - mov r0, r10 - bl CreateMon - ldr r0, =sFrontierBrainsMons - adds r5, r0 - adds r5, r6, r5 - adds r4, r5, r4 - adds r4, 0x2 - mov r0, r10 - movs r1, 0xC - adds r2, r4, 0 - bl SetMonData - movs r7, 0 - mov r6, r8 - ldr r3, =gEnemyParty -_081A4F32: - adds r1, r7, 0 - adds r1, 0x1A - ldr r0, [sp, 0x14] - add r0, r9 - lsls r4, r0, 2 - adds r2, r5, r4 - adds r0, r7, 0x6 - adds r2, r0 - adds r0, r6, r3 - str r3, [sp, 0x40] - bl SetMonData - adds r7, 0x1 - ldr r3, [sp, 0x40] - cmp r7, 0x5 - ble _081A4F32 - movs r1, 0xFF - add r0, sp, 0x10 - strb r1, [r0] - movs r7, 0 - ldr r1, [sp, 0x18] - movs r2, 0x64 - adds r6, r1, 0 - muls r6, r2 - ldr r3, =gUnknown_08611578 - mov r8, r3 - ldr r3, =gEnemyParty - adds r5, r4, 0 -_081A4F6A: - ldr r4, [sp, 0x38] - ldr r0, [sp, 0x24] - subs r1, r4, r0 - lsls r1, 2 - adds r1, r5, r1 - ldr r2, [sp, 0x34] - ldr r4, [sp, 0x20] - subs r0, r2, r4 - lsls r0, 3 - adds r1, r0 - add r1, r8 - ldrh r4, [r1] - lsls r2, r7, 24 - lsrs r2, 24 - adds r0, r6, r3 - adds r1, r4, 0 - str r3, [sp, 0x40] - bl SetMonMoveSlot - ldr r3, [sp, 0x40] - cmp r4, 0xDA - bne _081A4F9C - movs r1, 0 - add r0, sp, 0x10 - strb r1, [r0] -_081A4F9C: - adds r5, 0x2 - adds r7, 0x1 - cmp r7, 0x3 - ble _081A4F6A - ldr r0, [sp, 0x18] - movs r1, 0x64 - adds r4, r0, 0 - muls r4, r1 - ldr r0, =gEnemyParty - adds r4, r0 - adds r0, r4, 0 - movs r1, 0x20 - add r2, sp, 0x10 - bl SetMonData - adds r0, r4, 0 - bl CalculateMonStats - ldr r2, [sp, 0x2C] - str r2, [sp, 0x18] -_081A4FC4: - ldr r4, [sp, 0x30] - ldr r3, [sp, 0x28] - str r3, [sp, 0x14] - cmp r3, 0x2 - bgt _081A4FD0 - b _081A4E5C -_081A4FD0: - add sp, 0x44 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool -thumb_func_end CreateFrontierBrainPokemon - - thumb_func_start sub_81A4FF0 -sub_81A4FF0: @ 81A4FF0 - push {r4,r5,lr} - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - ldr r0, =0x000040cf - bl VarGet - adds r5, r0, 0 - lsls r5, 16 - lsrs r5, 16 - bl sub_81A513C - ldr r3, =sFrontierBrainsMons - lsls r2, r4, 2 - adds r2, r4 - lsls r1, r0, 4 - subs r1, r0 - adds r1, r2 - lsls r1, 2 - lsls r0, r5, 4 - subs r0, r5 - lsls r0, 3 - adds r1, r0 - adds r1, r3 - ldrh r0, [r1] - pop {r4,r5} - pop {r1} - bx r1 - .pool - thumb_func_end sub_81A4FF0 - - thumb_func_start sub_81A5030 -sub_81A5030: @ 81A5030 - push {lr} - lsls r0, 24 - ldr r2, =gTrainerBattleOpponent_A - ldr r3, =0x000003fe - adds r1, r3, 0 - strh r1, [r2] - ldr r2, =0x00004010 - ldr r1, =gUnknown_08611C8C - lsrs r0, 23 - adds r0, r1 - ldrb r1, [r0] - adds r0, r2, 0 - bl VarSet - pop {r0} - bx r0 - .pool - thumb_func_end sub_81A5030 - - thumb_func_start sub_81A5060 -sub_81A5060: @ 81A5060 - push {r4-r6,lr} - adds r6, r0, 0 - adds r4, r1, 0 - lsls r6, 24 - lsrs r6, 24 - lsls r4, 24 - lsrs r4, 24 - ldr r0, =0x000040cf - bl VarGet - adds r5, r0, 0 - lsls r5, 16 - lsrs r5, 16 - bl sub_81A513C - ldr r2, =sFrontierBrainsMons - lsls r4, 1 - lsls r1, r6, 2 - adds r1, r6 - lsls r1, 2 - adds r4, r1 - lsls r1, r0, 4 - subs r1, r0 - lsls r1, 2 - adds r4, r1 - lsls r0, r5, 4 - subs r0, r5 - lsls r0, 3 - adds r4, r0 - adds r2, 0xC - adds r4, r2 - ldrh r0, [r4] - pop {r4-r6} - pop {r1} - bx r1 - .pool - thumb_func_end sub_81A5060 - - thumb_func_start sub_81A50B0 -sub_81A50B0: @ 81A50B0 - push {r4,r5,lr} - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - ldr r0, =0x000040cf - bl VarGet - adds r5, r0, 0 - lsls r5, 16 - lsrs r5, 16 - bl sub_81A513C - ldr r3, =sFrontierBrainsMons - lsls r2, r4, 2 - adds r2, r4 - lsls r1, r0, 4 - subs r1, r0 - adds r1, r2 - lsls r1, 2 - lsls r0, r5, 4 - subs r0, r5 - lsls r0, 3 - adds r1, r0 - adds r1, r3 - ldrb r0, [r1, 0x5] - pop {r4,r5} - pop {r1} - bx r1 - .pool - thumb_func_end sub_81A50B0 - - thumb_func_start sub_81A50F0 -sub_81A50F0: @ 81A50F0 - push {r4-r6,lr} - adds r6, r0, 0 - adds r4, r1, 0 - lsls r6, 24 - lsrs r6, 24 - lsls r4, 24 - lsrs r4, 24 - ldr r0, =0x000040cf - bl VarGet - adds r5, r0, 0 - lsls r5, 16 - lsrs r5, 16 - bl sub_81A513C - ldr r2, =sFrontierBrainsMons - lsls r1, r6, 2 - adds r1, r6 - lsls r1, 2 - adds r4, r1 - lsls r1, r0, 4 - subs r1, r0 - lsls r1, 2 - adds r4, r1 - lsls r0, r5, 4 - subs r0, r5 - lsls r0, 3 - adds r4, r0 - adds r2, 0x6 - adds r4, r2 - ldrb r0, [r4] - pop {r4-r6} - pop {r1} - bx r1 - .pool - thumb_func_end sub_81A50F0 - - thumb_func_start sub_81A513C -sub_81A513C: @ 81A513C - push {r4,r5,lr} - ldr r0, =0x000040cf - bl VarGet - lsls r0, 16 - lsrs r5, r0, 16 - lsls r0, r5, 24 - lsrs r0, 24 - bl sub_81A3B30 - lsls r0, 24 - lsrs r4, r0, 24 - cmp r4, 0x2 - bne _081A51A0 - bl GetCurrentFacilityWinStreak - lsls r0, 16 - ldr r3, =gUnknown_08611550 - lsls r2, r5, 2 - adds r1, r3, 0x3 - adds r1, r2, r1 - lsrs r0, 16 - ldrb r1, [r1] - adds r1, r0, r1 - adds r0, r2, r3 - ldrb r0, [r0] - cmp r1, r0 - bne _081A5180 - movs r4, 0 - b _081A51A0 - .pool -_081A5180: - adds r0, r3, 0x1 - adds r0, r2, r0 - ldrb r0, [r0] - cmp r1, r0 - beq _081A519E - cmp r1, r0 - ble _081A51A0 - subs r0, r1, r0 - adds r1, r3, 0x2 - adds r1, r2, r1 - ldrb r1, [r1] - bl __modsi3 - cmp r0, 0 - bne _081A51A0 -_081A519E: - movs r4, 0x1 -_081A51A0: - adds r0, r4, 0 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_81A513C - - thumb_func_start sub_81A51A8 -sub_81A51A8: @ 81A51A8 - push {r4,r5,lr} - lsls r0, 24 - lsrs r5, r0, 24 - ldr r0, =gBattleTypeFlags - ldr r0, [r0] - movs r1, 0x80 - lsls r1, 17 - ands r0, r1 - cmp r0, 0 - beq _081A51D4 - bl GetRecordedBattleFrontierFacility - lsls r0, 24 - lsrs r4, r0, 24 - bl sub_8185EAC - lsls r0, 24 - lsrs r1, r0, 24 - b _081A51E4 - .pool -_081A51D4: - ldr r0, =0x000040cf - bl VarGet - lsls r0, 16 - lsrs r4, r0, 16 - bl sub_81A513C - adds r1, r0, 0 -_081A51E4: - cmp r5, 0 - beq _081A51F4 - cmp r5, 0x1 - beq _081A5214 - b _081A5228 - .pool -_081A51F4: - ldr r0, =gStringVar4 - ldr r2, =gUnknown_08611DB0 - lsls r1, 2 - adds r1, r2 - ldr r2, [r1] - lsls r1, r4, 2 - adds r1, r2 - ldr r1, [r1] - bl StringCopy - b _081A5228 - .pool -_081A5214: - ldr r0, =gStringVar4 - ldr r2, =gUnknown_08611DB8 - lsls r1, 2 - adds r1, r2 - ldr r2, [r1] - lsls r1, r4, 2 - adds r1, r2 - ldr r1, [r1] - bl StringCopy -_081A5228: - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81A51A8 + thumb_func_start sub_81A5238 sub_81A5238: @ 81A5238 diff --git a/include/frontier_util.h b/include/frontier_util.h index 019210691..d60ba11dc 100644 --- a/include/frontier_util.h +++ b/include/frontier_util.h @@ -18,5 +18,6 @@ u8 sub_81A6CA8(u8, u8); void sub_81A3908(void); u32 GetCurrentFacilityWinStreak(void); void ClearnRankingHallRecords(void); +s32 GetFronterBrainSymbol(void); #endif // GUARD_FRONTIER_UTIL_H diff --git a/include/recorded_battle.h b/include/recorded_battle.h index 81c88a15e..84c5c2ea2 100644 --- a/include/recorded_battle.h +++ b/include/recorded_battle.h @@ -14,16 +14,16 @@ u8 sub_81850D0(void); u8 sub_81850DC(u8 *arg0); void sub_81851A8(u8 *arg0); bool32 CanCopyRecordedBattleSaveData(void); -u32 MoveRecordedBattleToSaveData(void); +bool32 MoveRecordedBattleToSaveData(void); void PlayRecordedBattle(void (*CB2_After)(void)); u8 GetRecordedBattleFrontierFacility(void); -u8 sub_8185EAC(void); +u8 GetRecordedBattleFronterBrainSymbol(void); void RecordedBattle_SaveParties(void); u8 GetActiveBattlerLinkPlayerGender(void); void sub_8185F84(void); void sub_8185F90(u16 arg0); u8 sub_8185FAC(void); -u8 GetBattleStyleInRecordedBattle(void); +u8 GetBattleSceneInRecordedBattle(void); u8 GetTextSpeedInRecordedBattle(void); void RecordedBattle_CopyBattlerMoves(void); void sub_818603C(u8 arg0); @@ -31,11 +31,11 @@ u32 GetAiScriptsInRecordedBattle(void); void sub_8186444(void); bool8 sub_8186450(void); void sub_8186468(u8 *dst); -u8 sub_818649C(void); -u8 sub_81864A8(void); -u8 sub_81864B4(void); -u8 sub_81864C0(void); -void sub_81864CC(void); -u16 *sub_81864E0(void); +u8 GetRecordedBattleRecordMixFriendClass(void); +u8 GetRecordedBattleApprenticeId(void); +u8 GetRecordedBattleRecordMixFriendLanguage(void); +u8 GetRecordedBattleApprenticeLanguage(void); +void RecordedBattle_SaveBattleOutcome(void); +u16 *GetRecordedBattleEasyChatSpeech(void); #endif // GUARD_RECORDED_BATTLE_H diff --git a/src/battle_main.c b/src/battle_main.c index 9f1ea3c01..e08e12194 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -3027,7 +3027,7 @@ static void BattleStartClearSetData(void) if (!(gBattleTypeFlags & BATTLE_TYPE_LINK) && gSaveBlock2Ptr->optionsBattleSceneOff == TRUE) gHitMarker |= HITMARKER_NO_ANIMATIONS; } - else if (!(gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_x2000000)) && GetBattleStyleInRecordedBattle()) + else if (!(gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_x2000000)) && GetBattleSceneInRecordedBattle()) gHitMarker |= HITMARKER_NO_ANIMATIONS; gBattleScripting.battleStyle = gSaveBlock2Ptr->optionsBattleStyle; diff --git a/src/battle_tower.c b/src/battle_tower.c index 4518e6ad9..f02336ef5 100644 --- a/src/battle_tower.c +++ b/src/battle_tower.c @@ -769,14 +769,14 @@ u8 GetFrontierTrainerFrontSpriteId(u16 trainerId) else if (trainerId < TRAINER_RECORD_MIXING_APPRENTICE) { if (gBattleTypeFlags & BATTLE_TYPE_RECORDED) - return gFacilityClassToPicIndex[sub_818649C()]; + return gFacilityClassToPicIndex[GetRecordedBattleRecordMixFriendClass()]; else return gFacilityClassToPicIndex[gSaveBlock2Ptr->frontier.towerRecords[trainerId - TRAINER_RECORD_MIXING_FRIEND].facilityClass]; } else { if (gBattleTypeFlags & BATTLE_TYPE_RECORDED) - return gFacilityClassToPicIndex[gApprentices[sub_81864A8()].facilityClass]; + return gFacilityClassToPicIndex[gApprentices[GetRecordedBattleApprenticeId()].facilityClass]; else return gFacilityClassToPicIndex[gApprentices[gSaveBlock2Ptr->apprentices[trainerId - TRAINER_RECORD_MIXING_APPRENTICE].id].facilityClass]; } @@ -807,7 +807,7 @@ u8 GetFrontierOpponentClass(u16 trainerId) { if (gBattleTypeFlags & BATTLE_TYPE_RECORDED) { - trainerClass = gFacilityClassToTrainerClass[sub_818649C()]; + trainerClass = gFacilityClassToTrainerClass[GetRecordedBattleRecordMixFriendClass()]; } else { @@ -819,7 +819,7 @@ u8 GetFrontierOpponentClass(u16 trainerId) { if (gBattleTypeFlags & BATTLE_TYPE_RECORDED) { - trainerClass = gFacilityClassToTrainerClass[gApprentices[sub_81864A8()].facilityClass]; + trainerClass = gFacilityClassToTrainerClass[gApprentices[GetRecordedBattleApprenticeId()].facilityClass]; } else { @@ -847,14 +847,14 @@ static u8 GetFrontierTrainerFacilityClass(u16 trainerId) else if (trainerId < TRAINER_RECORD_MIXING_APPRENTICE) { if (gBattleTypeFlags & BATTLE_TYPE_RECORDED) - facilityClass = sub_818649C(); + facilityClass = GetRecordedBattleRecordMixFriendClass(); else facilityClass = gSaveBlock2Ptr->frontier.towerRecords[trainerId - TRAINER_RECORD_MIXING_FRIEND].facilityClass; } else { if (gBattleTypeFlags & BATTLE_TYPE_RECORDED) - facilityClass = gApprentices[sub_81864A8()].facilityClass; + facilityClass = gApprentices[GetRecordedBattleApprenticeId()].facilityClass; else facilityClass = gApprentices[gSaveBlock2Ptr->apprentices[trainerId - TRAINER_RECORD_MIXING_APPRENTICE].id].facilityClass; } @@ -907,8 +907,8 @@ void GetFrontierTrainerName(u8 *dst, u16 trainerId) if (gBattleTypeFlags & BATTLE_TYPE_RECORDED) { - id = sub_81864A8(); - language = sub_81864C0(); + id = GetRecordedBattleApprenticeId(); + language = GetRecordedBattleApprenticeLanguage(); } else { @@ -1297,7 +1297,7 @@ static void HandleSpecialTrainerBattleEnd(void) { s32 i; - sub_81864CC(); + RecordedBattle_SaveBattleOutcome(); switch (gBattleScripting.specialTrainerBattleType) { case SPECIAL_BATTLE_TOWER: @@ -2527,14 +2527,14 @@ void GetBattleTowerTrainerLanguage(u8 *dst, u16 trainerId) else if (trainerId < TRAINER_RECORD_MIXING_APPRENTICE) { if (gBattleTypeFlags & BATTLE_TYPE_RECORDED) - *dst = sub_81864B4(); + *dst = GetRecordedBattleRecordMixFriendLanguage(); else *dst = gSaveBlock2Ptr->frontier.towerRecords[trainerId - TRAINER_RECORD_MIXING_FRIEND].language; } else { if (gBattleTypeFlags & BATTLE_TYPE_RECORDED) - *dst = sub_81864C0(); + *dst = GetRecordedBattleApprenticeLanguage(); else *dst = gSaveBlock2Ptr->apprentices[trainerId - TRAINER_RECORD_MIXING_APPRENTICE].language; } diff --git a/src/frontier_util.c b/src/frontier_util.c index bbf0c9af0..729b1e622 100644 --- a/src/frontier_util.c +++ b/src/frontier_util.c @@ -61,7 +61,7 @@ static void ShowArenaResultsWindow(void); static void ShowPyramidResultsWindow(void); static void ShowLinkContestResultsWindow(void); u8 sub_81A3610(void); -void sub_81A51A8(u8); +static void CopyFrontierBrainText(bool8 playerWonText); void sub_81A5030(u8); // const rom data @@ -987,7 +987,7 @@ void CopyFrontierTrainerText(u8 whichText, u16 trainerId) if (trainerId == TRAINER_EREADER) FrontierSpeechToString(gSaveBlock2Ptr->frontier.ereaderTrainer.greeting); else if (trainerId == TRAINER_FRONTIER_BRAIN) - sub_81A51A8(0); + CopyFrontierBrainText(FALSE); else if (trainerId < TRAINER_RECORD_MIXING_FRIEND) FrontierSpeechToString(gFacilityTrainers[trainerId].speechBefore); else if (trainerId < TRAINER_RECORD_MIXING_APPRENTICE) @@ -1002,7 +1002,7 @@ void CopyFrontierTrainerText(u8 whichText, u16 trainerId) } else if (trainerId == TRAINER_FRONTIER_BRAIN) { - sub_81A51A8(0); + CopyFrontierBrainText(FALSE); } else if (trainerId < TRAINER_RECORD_MIXING_FRIEND) { @@ -1011,14 +1011,14 @@ void CopyFrontierTrainerText(u8 whichText, u16 trainerId) else if (trainerId < TRAINER_RECORD_MIXING_APPRENTICE) { if (gBattleTypeFlags & BATTLE_TYPE_RECORDED) - FrontierSpeechToString(sub_81864E0()); + FrontierSpeechToString(GetRecordedBattleEasyChatSpeech()); else FrontierSpeechToString(gSaveBlock2Ptr->frontier.towerRecords[trainerId - TRAINER_RECORD_MIXING_FRIEND].speechWon); } else { if (gBattleTypeFlags & BATTLE_TYPE_RECORDED) - FrontierSpeechToString(sub_81864E0()); + FrontierSpeechToString(GetRecordedBattleEasyChatSpeech()); else FrontierSpeechToString(gSaveBlock2Ptr->apprentices[trainerId - TRAINER_RECORD_MIXING_APPRENTICE].easyChatWords); } @@ -1030,7 +1030,7 @@ void CopyFrontierTrainerText(u8 whichText, u16 trainerId) } else if (trainerId == TRAINER_FRONTIER_BRAIN) { - sub_81A51A8(1); + CopyFrontierBrainText(TRUE); } else if (trainerId < TRAINER_RECORD_MIXING_FRIEND) { @@ -1039,7 +1039,7 @@ void CopyFrontierTrainerText(u8 whichText, u16 trainerId) else if (trainerId < TRAINER_RECORD_MIXING_APPRENTICE) { if (gBattleTypeFlags & BATTLE_TYPE_RECORDED) - FrontierSpeechToString(sub_81864E0()); + FrontierSpeechToString(GetRecordedBattleEasyChatSpeech()); else FrontierSpeechToString(gSaveBlock2Ptr->frontier.towerRecords[trainerId - TRAINER_RECORD_MIXING_FRIEND].speechLost); } @@ -1047,7 +1047,7 @@ void CopyFrontierTrainerText(u8 whichText, u16 trainerId) { if (gBattleTypeFlags & BATTLE_TYPE_RECORDED) { - trainerId = sub_81864A8(); + trainerId = GetRecordedBattleApprenticeId(); FrontierSpeechToString(gApprentices[trainerId].easyChatWords); } else @@ -1766,8 +1766,6 @@ void SetFrontierBrainTrainerGfxId(void) VarSet(VAR_OBJ_GFX_ID_0, gUnknown_08611C8C[facility][0]); } -s32 sub_81A513C(void); - #define FRONTIER_BRAIN_OTID 61226 struct FrontierBrainMon @@ -1782,16 +1780,16 @@ struct FrontierBrainMon extern const struct FrontierBrainMon sFrontierBrainsMons[][2][3]; -/* +#ifdef NONMATCHING void CreateFrontierBrainPokemon(void) { s32 i, j; s32 monCountInBits; s32 monPartyId; - s32 monLevel; + s32 monLevel = 0; u8 friendship; s32 facility = VarGet(VAR_FRONTIER_FACILITY); - s32 symbol = sub_81A513C(); + s32 symbol = GetFronterBrainSymbol(); if (facility == FRONTIER_FACILITY_DOME) monCountInBits = GetTrainerMonCountInBits(TrainerIdToDomeTournamentId(TRAINER_FRONTIER_BRAIN)); @@ -1831,4 +1829,327 @@ void CreateFrontierBrainPokemon(void) monPartyId++; } } -*/ +#else +NAKED +void CreateFrontierBrainPokemon(void) +{ + asm_unified("\n\ + push {r4-r7,lr}\n\ + mov r7, r10\n\ + mov r6, r9\n\ + mov r5, r8\n\ + push {r5-r7}\n\ + sub sp, 0x44\n\ + ldr r0, =0x000040cf\n\ + bl VarGet\n\ + lsls r0, 16\n\ + lsrs r0, 16\n\ + str r0, [sp, 0x20]\n\ + bl GetFronterBrainSymbol\n\ + str r0, [sp, 0x24]\n\ + ldr r0, [sp, 0x20]\n\ + cmp r0, 0x1\n\ + bne _081A4E44\n\ + ldr r0, =0x000003fe\n\ + bl TrainerIdToDomeTournamentId\n\ + lsls r0, 16\n\ + lsrs r0, 16\n\ + bl GetTrainerMonCountInBits\n\ + adds r4, r0, 0\n\ + b _081A4E46\n\ + .pool\n\ +_081A4E44:\n\ + movs r4, 0x7\n\ +_081A4E46:\n\ + bl ZeroEnemyPartyMons\n\ + movs r1, 0\n\ + str r1, [sp, 0x18]\n\ + bl SetFacilityPtrsGetLevel\n\ + lsls r0, 24\n\ + lsrs r0, 24\n\ + str r0, [sp, 0x1C]\n\ + movs r2, 0\n\ + str r2, [sp, 0x14]\n\ +_081A4E5C:\n\ + movs r0, 0x1\n\ + ands r0, r4\n\ + asrs r4, 1\n\ + str r4, [sp, 0x30]\n\ + ldr r3, [sp, 0x14]\n\ + adds r3, 0x1\n\ + str r3, [sp, 0x28]\n\ + cmp r0, 0\n\ + bne _081A4E70\n\ + b _081A4FC4\n\ +_081A4E70:\n\ + ldr r4, [sp, 0x14]\n\ + lsls r4, 2\n\ + mov r9, r4\n\ + ldr r0, [sp, 0x24]\n\ + lsls r0, 4\n\ + str r0, [sp, 0x38]\n\ + ldr r1, [sp, 0x20]\n\ + lsls r1, 4\n\ + str r1, [sp, 0x34]\n\ + ldr r2, [sp, 0x1C]\n\ + lsls r2, 24\n\ + str r2, [sp, 0x3C]\n\ + ldr r3, [sp, 0x18]\n\ + adds r3, 0x1\n\ + str r3, [sp, 0x2C]\n\ + ldr r0, [sp, 0x14]\n\ + add r0, r9\n\ + lsls r0, 2\n\ + mov r8, r0\n\ +_081A4E96:\n\ + bl Random\n\ + adds r4, r0, 0\n\ + bl Random\n\ + lsls r4, 16\n\ + lsrs r7, r4, 16\n\ + lsls r0, 16\n\ + orrs r7, r0\n\ + ldr r0, =0x0000ef2a\n\ + adds r1, r7, 0\n\ + bl IsShinyOtIdPersonality\n\ + lsls r0, 24\n\ + cmp r0, 0\n\ + bne _081A4E96\n\ + ldr r4, [sp, 0x38]\n\ + ldr r1, [sp, 0x24]\n\ + subs r0, r4, r1\n\ + lsls r5, r0, 2\n\ + mov r2, r8\n\ + adds r4, r2, r5\n\ + ldr r3, [sp, 0x34]\n\ + ldr r1, [sp, 0x20]\n\ + subs r0, r3, r1\n\ + lsls r6, r0, 3\n\ + adds r4, r6\n\ + ldr r2, =sFrontierBrainsMons\n\ + adds r4, r2\n\ + adds r0, r7, 0\n\ + bl GetNatureFromPersonality\n\ + ldrb r1, [r4, 0x5]\n\ + lsls r0, 24\n\ + lsrs r0, 24\n\ + cmp r1, r0\n\ + bne _081A4E96\n\ + ldr r4, [sp, 0x18]\n\ + movs r0, 0x64\n\ + adds r3, r4, 0\n\ + muls r3, r0\n\ + mov r8, r3\n\ + ldr r1, =gEnemyParty\n\ + add r1, r8\n\ + mov r10, r1\n\ + ldr r4, [sp, 0x14]\n\ + add r4, r9\n\ + lsls r4, 2\n\ + adds r0, r4, r5\n\ + adds r0, r6\n\ + ldr r2, =sFrontierBrainsMons\n\ + adds r0, r2\n\ + ldrh r1, [r0]\n\ + ldr r3, [sp, 0x3C]\n\ + lsrs r2, r3, 24\n\ + ldrb r3, [r0, 0x4]\n\ + movs r0, 0x1\n\ + str r0, [sp]\n\ + str r7, [sp, 0x4]\n\ + str r0, [sp, 0x8]\n\ + ldr r0, =0x0000ef2a\n\ + str r0, [sp, 0xC]\n\ + mov r0, r10\n\ + bl CreateMon\n\ + ldr r0, =sFrontierBrainsMons\n\ + adds r5, r0\n\ + adds r5, r6, r5\n\ + adds r4, r5, r4\n\ + adds r4, 0x2\n\ + mov r0, r10\n\ + movs r1, 0xC\n\ + adds r2, r4, 0\n\ + bl SetMonData\n\ + movs r7, 0\n\ + mov r6, r8\n\ + ldr r3, =gEnemyParty\n\ +_081A4F32:\n\ + adds r1, r7, 0\n\ + adds r1, 0x1A\n\ + ldr r0, [sp, 0x14]\n\ + add r0, r9\n\ + lsls r4, r0, 2\n\ + adds r2, r5, r4\n\ + adds r0, r7, 0x6\n\ + adds r2, r0\n\ + adds r0, r6, r3\n\ + str r3, [sp, 0x40]\n\ + bl SetMonData\n\ + adds r7, 0x1\n\ + ldr r3, [sp, 0x40]\n\ + cmp r7, 0x5\n\ + ble _081A4F32\n\ + movs r1, 0xFF\n\ + add r0, sp, 0x10\n\ + strb r1, [r0]\n\ + movs r7, 0\n\ + ldr r1, [sp, 0x18]\n\ + movs r2, 0x64\n\ + adds r6, r1, 0\n\ + muls r6, r2\n\ + ldr r3, =gUnknown_08611578\n\ + mov r8, r3\n\ + ldr r3, =gEnemyParty\n\ + adds r5, r4, 0\n\ +_081A4F6A:\n\ + ldr r4, [sp, 0x38]\n\ + ldr r0, [sp, 0x24]\n\ + subs r1, r4, r0\n\ + lsls r1, 2\n\ + adds r1, r5, r1\n\ + ldr r2, [sp, 0x34]\n\ + ldr r4, [sp, 0x20]\n\ + subs r0, r2, r4\n\ + lsls r0, 3\n\ + adds r1, r0\n\ + add r1, r8\n\ + ldrh r4, [r1]\n\ + lsls r2, r7, 24\n\ + lsrs r2, 24\n\ + adds r0, r6, r3\n\ + adds r1, r4, 0\n\ + str r3, [sp, 0x40]\n\ + bl SetMonMoveSlot\n\ + ldr r3, [sp, 0x40]\n\ + cmp r4, 0xDA\n\ + bne _081A4F9C\n\ + movs r1, 0\n\ + add r0, sp, 0x10\n\ + strb r1, [r0]\n\ +_081A4F9C:\n\ + adds r5, 0x2\n\ + adds r7, 0x1\n\ + cmp r7, 0x3\n\ + ble _081A4F6A\n\ + ldr r0, [sp, 0x18]\n\ + movs r1, 0x64\n\ + adds r4, r0, 0\n\ + muls r4, r1\n\ + ldr r0, =gEnemyParty\n\ + adds r4, r0\n\ + adds r0, r4, 0\n\ + movs r1, 0x20\n\ + add r2, sp, 0x10\n\ + bl SetMonData\n\ + adds r0, r4, 0\n\ + bl CalculateMonStats\n\ + ldr r2, [sp, 0x2C]\n\ + str r2, [sp, 0x18]\n\ +_081A4FC4:\n\ + ldr r4, [sp, 0x30]\n\ + ldr r3, [sp, 0x28]\n\ + str r3, [sp, 0x14]\n\ + cmp r3, 0x2\n\ + bgt _081A4FD0\n\ + b _081A4E5C\n\ +_081A4FD0:\n\ + add sp, 0x44\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 + +u16 sub_81A4FF0(u8 monPartyId) +{ + s32 facility = VarGet(VAR_FRONTIER_FACILITY); + s32 symbol = GetFronterBrainSymbol(); + + return sFrontierBrainsMons[facility][symbol][monPartyId].species; +} + +void sub_81A5030(u8 facility) +{ + gTrainerBattleOpponent_A = TRAINER_FRONTIER_BRAIN; + VarSet(VAR_OBJ_GFX_ID_0, gUnknown_08611C8C[facility][0]); +} + +u16 sub_81A5060(u8 monId, u8 moveSlotId) +{ + s32 facility = VarGet(VAR_FRONTIER_FACILITY); + s32 symbol = GetFronterBrainSymbol(); + + return sFrontierBrainsMons[facility][symbol][monId].moves[moveSlotId]; +} + +u8 sub_81A50B0(u8 monPartyId) +{ + s32 facility = VarGet(VAR_FRONTIER_FACILITY); + s32 symbol = GetFronterBrainSymbol(); + + return sFrontierBrainsMons[facility][symbol][monPartyId].nature; +} + +u8 sub_81A50F0(u8 monId, u8 evStatId) +{ + s32 facility = VarGet(VAR_FRONTIER_FACILITY); + s32 symbol = GetFronterBrainSymbol(); + + return sFrontierBrainsMons[facility][symbol][monId].evs[evStatId]; +} + +s32 GetFronterBrainSymbol(void) +{ + s32 facility = VarGet(VAR_FRONTIER_FACILITY); + s32 symbol = sub_81A3B30(facility); + + if (symbol == 2) + { + u16 winStreak = GetCurrentFacilityWinStreak(); + if (winStreak + gUnknown_08611550[facility][3] == gUnknown_08611550[facility][0]) + symbol = 0; + else if (winStreak + gUnknown_08611550[facility][3] == gUnknown_08611550[facility][1]) + symbol = 1; + else if (winStreak + gUnknown_08611550[facility][3] > gUnknown_08611550[facility][1] + && (winStreak + gUnknown_08611550[facility][3] - gUnknown_08611550[facility][1]) % gUnknown_08611550[facility][2] == 0) + symbol = 1; + } + return symbol; +} + +extern const u8 *const *const gUnknown_08611DB0[]; +extern const u8 *const *const gUnknown_08611DB8[]; + +static void CopyFrontierBrainText(bool8 playerWonText) +{ + s32 facility; + s32 symbol; + + if (gBattleTypeFlags & BATTLE_TYPE_RECORDED) + { + facility = GetRecordedBattleFrontierFacility(); + symbol = GetRecordedBattleFronterBrainSymbol(); + } + else + { + facility = VarGet(VAR_FRONTIER_FACILITY); + symbol = GetFronterBrainSymbol(); + } + + switch (playerWonText) + { + case FALSE: + StringCopy(gStringVar4, gUnknown_08611DB0[symbol][facility]); + break; + case TRUE: + StringCopy(gStringVar4, gUnknown_08611DB8[symbol][facility]); + break; + } +} diff --git a/src/recorded_battle.c b/src/recorded_battle.c index 0a199f289..eba7039f5 100644 --- a/src/recorded_battle.c +++ b/src/recorded_battle.c @@ -14,6 +14,8 @@ #include "task.h" #include "text.h" #include "battle_setup.h" +#include "frontier_util.h" +#include "constants/trainers.h" #define BATTLER_RECORD_SIZE 664 #define ILLEGAL_BATTLE_TYPES ((BATTLE_TYPE_LINK | BATTLE_TYPE_SAFARI | BATTLE_TYPE_FIRST_BATTLE \ @@ -55,18 +57,18 @@ struct RecordedBattleSave u16 opponentB; u16 partnerId; u16 field_4FA; - u8 field_4FC; - u8 field_4FD; - u8 field_4FE; - u8 battleStyle:1; + u8 lvlMode; + u8 frontierFacility; + u8 frontierBrainSymbol; + u8 battleScene:1; u8 textSpeed:3; u32 AI_scripts; - u8 field_504[8]; - u8 field_50C; - u8 field_50D; - u16 field_50E[6]; - u8 field_51A; - u8 field_51B; + u8 recordMixFriendName[PLAYER_NAME_LENGTH + 1]; + u8 recordMixFriendClass; + u8 apprenticeId; + u16 easyChatSpeech[6]; + u8 recordMixFriendLanguage; + u8 apprenticeLanguage; u8 battleRecord[MAX_BATTLERS_COUNT][BATTLER_RECORD_SIZE]; u32 checksum; }; @@ -78,13 +80,13 @@ EWRAM_DATA static u16 sRecordedBytesNo[MAX_BATTLERS_COUNT] = {0}; EWRAM_DATA static u16 sUnknown_0203C79C[4] = {0}; EWRAM_DATA static u16 sUnknown_0203C7A4[4] = {0}; EWRAM_DATA static u8 sUnknown_0203C7AC = 0; -EWRAM_DATA static u8 sUnknown_0203C7AD = 0; +EWRAM_DATA static u8 sLvlMode = 0; EWRAM_DATA static u8 sFrontierFacility = 0; -EWRAM_DATA static u8 sUnknown_0203C7AF = 0; +EWRAM_DATA static u8 sFrontierBrainSymbol = 0; EWRAM_DATA static MainCallback sCallback2_AfterRecordedBattle = NULL; EWRAM_DATA u8 gUnknown_0203C7B4 = 0; EWRAM_DATA static u8 sUnknown_0203C7B5 = 0; -EWRAM_DATA static u8 sBattleStyle = 0; +EWRAM_DATA static u8 sBattleScene = 0; EWRAM_DATA static u8 sTextSpeed = 0; EWRAM_DATA static u32 sBattleFlags = 0; EWRAM_DATA static u32 sAI_Scripts = 0; @@ -93,17 +95,15 @@ EWRAM_DATA static struct Pokemon sSavedOpponentParty[PARTY_SIZE] = {0}; EWRAM_DATA static u16 sPlayerMonMoves[2][4] = {0}; EWRAM_DATA static struct PlayerInfo sPlayers[MAX_BATTLERS_COUNT] = {0}; EWRAM_DATA static u8 sUnknown_0203CCD0 = 0; -EWRAM_DATA static u8 sUnknown_0203CCD1[8] = {0}; -EWRAM_DATA static u8 sUnknown_0203CCD9 = 0; -EWRAM_DATA static u8 sUnknown_0203CCDA = 0; -EWRAM_DATA static u16 sUnknown_0203CCDC[6] = {0}; -EWRAM_DATA static u8 sUnknown_0203CCE8 = 0; - -extern u32 sub_81A513C(void); +EWRAM_DATA static u8 sRecordMixFriendName[PLAYER_NAME_LENGTH + 1] = {0}; +EWRAM_DATA static u8 sRecordMixFriendClass = 0; +EWRAM_DATA static u8 sApprenticeId = 0; +EWRAM_DATA static u16 sEasyChatSpeech[6] = {0}; +EWRAM_DATA static u8 sBattleOutcome = 0; // this file's functions static u8 sub_8185278(u8 *arg0, u8 *arg1, u8 *arg2); -static bool32 AllocTryCopyRecordedBattleSaveData(struct RecordedBattleSave *dst); +static bool32 CopyRecordedBattleFromSave(struct RecordedBattleSave *dst); static void RecordedBattle_RestoreSavedParties(void); static void CB2_RecordedBattle(void); @@ -140,7 +140,7 @@ void sub_8184E58(void) { gRecordedBattleRngSeed = gRngValue; sFrontierFacility = VarGet(VAR_FRONTIER_FACILITY); - sUnknown_0203C7AF = sub_81A513C(); + sFrontierBrainSymbol = GetFronterBrainSymbol(); } else if (sUnknown_0203C7AC == 2) { @@ -297,7 +297,7 @@ static u8 sub_8185278(u8 *arg0, u8 *arg1, u8 *arg2) bool32 CanCopyRecordedBattleSaveData(void) { struct RecordedBattleSave *dst = AllocZeroed(sizeof(struct RecordedBattleSave)); - bool32 ret = AllocTryCopyRecordedBattleSaveData(dst); + bool32 ret = CopyRecordedBattleFromSave(dst); Free(dst); return ret; } @@ -314,26 +314,29 @@ static bool32 IsRecordedBattleSaveValid(struct RecordedBattleSave *save) return TRUE; } -static bool32 sub_81852F0(struct RecordedBattleSave *battleSave, struct RecordedBattleSave *saveSection) +static bool32 RecordedBattleToSave(struct RecordedBattleSave *battleSave, struct RecordedBattleSave *saveSection) { - memset(saveSection, 0, sizeof(struct SaveSection)); + memset(saveSection, 0, 0x1000); memcpy(saveSection, battleSave, sizeof(*battleSave)); saveSection->checksum = CalcByteArraySum((void*)(saveSection), sizeof(*saveSection) - 4); if (sub_8153634(31, (void*)(saveSection)) != 1) return FALSE; - - return TRUE; + else + return TRUE; } -#ifdef NONMATCHING -u32 MoveRecordedBattleToSaveData(void) +bool32 MoveRecordedBattleToSaveData(void) { s32 i, j; - u8 var = 0; - struct RecordedBattleSave *battleSave = AllocZeroed(sizeof(struct RecordedBattleSave)); - struct SaveSection *savSection = AllocZeroed(sizeof(struct SaveSection)); + bool32 ret; + struct RecordedBattleSave *battleSave, *savSection; + u8 var; + + var = 0; + battleSave = AllocZeroed(sizeof(struct RecordedBattleSave)); + savSection = AllocZeroed(0x1000); for (i = 0; i < PARTY_SIZE; i++) { @@ -357,8 +360,7 @@ u32 MoveRecordedBattleToSaveData(void) if (sBattleFlags & BATTLE_TYPE_LINK) { - battleSave->battleFlags = (sBattleFlags & ~(BATTLE_TYPE_LINK | BATTLE_TYPE_20)); - battleSave->battleFlags |= BATTLE_TYPE_x2000000; + battleSave->battleFlags = (sBattleFlags & ~(BATTLE_TYPE_LINK | BATTLE_TYPE_20)) | BATTLE_TYPE_x2000000; if (sBattleFlags & BATTLE_TYPE_IS_MASTER) { @@ -390,885 +392,102 @@ u32 MoveRecordedBattleToSaveData(void) battleSave->opponentB = gTrainerBattleOpponent_B; battleSave->partnerId = gPartnerTrainerId; battleSave->field_4FA = gUnknown_0203C7B4; - battleSave->field_4FC = gSaveBlock2Ptr->field_CA9_b; - battleSave->field_4FD = sFrontierFacility; - battleSave->field_4FE = sUnknown_0203C7AF; - battleSave->battleStyle = gSaveBlock2Ptr->optionsBattleStyle; + battleSave->lvlMode = gSaveBlock2Ptr->frontier.lvlMode; + battleSave->frontierFacility = sFrontierFacility; + battleSave->frontierBrainSymbol = sFrontierBrainSymbol; + battleSave->battleScene = gSaveBlock2Ptr->optionsBattleSceneOff; battleSave->textSpeed = gSaveBlock2Ptr->optionsTextSpeed; battleSave->AI_scripts = sAI_Scripts; - /* Can't match it without proper knowledge of the Saveblock 2. - if (gTrainerBattleOpponent_A >= 300 && gTrainerBattleOpponent_A <= 399) + if (gTrainerBattleOpponent_A >= TRAINER_RECORD_MIXING_FRIEND && gTrainerBattleOpponent_A < TRAINER_RECORD_MIXING_APPRENTICE) { - for (i = 0; i < 8; i++) - { - battleSave->field_504[i] = gSaveBlock2Ptr->records[gTrainerBattleOpponent_A - 300].field_4[i]; - } - battleSave->field_50C = gSaveBlock2Ptr->records[gTrainerBattleOpponent_A - 300].field_1; + for (i = 0; i < PLAYER_NAME_LENGTH + 1; i++) + battleSave->recordMixFriendName[i] = gSaveBlock2Ptr->frontier.towerRecords[gTrainerBattleOpponent_A - TRAINER_RECORD_MIXING_FRIEND].name[i]; + battleSave->recordMixFriendClass = gSaveBlock2Ptr->frontier.towerRecords[gTrainerBattleOpponent_A - TRAINER_RECORD_MIXING_FRIEND].facilityClass; - if (sUnknown_0203CCE8 == 1) + if (sBattleOutcome == B_OUTCOME_WON) { for (i = 0; i < 6; i++) - { - battleSave->field_50E[i] = gSaveBlock2Ptr->records[gTrainerBattleOpponent_A - 300].field_28[i]; - } + battleSave->easyChatSpeech[i] = gSaveBlock2Ptr->frontier.towerRecords[gTrainerBattleOpponent_A - TRAINER_RECORD_MIXING_FRIEND].speechLost[i]; } else { for (i = 0; i < 6; i++) - { - battleSave->field_50E[i] = gSaveBlock2Ptr->records[gTrainerBattleOpponent_A - 300].field_1C[i]; - } + battleSave->easyChatSpeech[i] = gSaveBlock2Ptr->frontier.towerRecords[gTrainerBattleOpponent_A - TRAINER_RECORD_MIXING_FRIEND].speechWon[i]; } - battleSave->field_51A = gSaveBlock2Ptr->records[gTrainerBattleOpponent_A - 300].field_E4; + battleSave->recordMixFriendLanguage = gSaveBlock2Ptr->frontier.towerRecords[gTrainerBattleOpponent_A - TRAINER_RECORD_MIXING_FRIEND].language; } - else if (gTrainerBattleOpponent_B >= 300 && gTrainerBattleOpponent_B <= 399) + else if (gTrainerBattleOpponent_B >= TRAINER_RECORD_MIXING_FRIEND && gTrainerBattleOpponent_B < TRAINER_RECORD_MIXING_APPRENTICE) { - for (i = 0; i < 8; i++) - { - battleSave->field_504[i] = gSaveBlock2Ptr->records[gTrainerBattleOpponent_B - 300].field_4[i]; - } - battleSave->field_50C = gSaveBlock2Ptr->records[gTrainerBattleOpponent_B - 300].field_1; + for (i = 0; i < PLAYER_NAME_LENGTH + 1; i++) + battleSave->recordMixFriendName[i] = gSaveBlock2Ptr->frontier.towerRecords[gTrainerBattleOpponent_B - TRAINER_RECORD_MIXING_FRIEND].name[i]; + battleSave->recordMixFriendClass = gSaveBlock2Ptr->frontier.towerRecords[gTrainerBattleOpponent_B - TRAINER_RECORD_MIXING_FRIEND].facilityClass; - if (sUnknown_0203CCE8 == 1) + if (sBattleOutcome == B_OUTCOME_WON) { for (i = 0; i < 6; i++) - { - battleSave->field_50E[i] = gSaveBlock2Ptr->records[gTrainerBattleOpponent_B - 300].field_28[i]; - } + battleSave->easyChatSpeech[i] = gSaveBlock2Ptr->frontier.towerRecords[gTrainerBattleOpponent_B - TRAINER_RECORD_MIXING_FRIEND].speechLost[i]; } else { for (i = 0; i < 6; i++) - { - battleSave->field_50E[i] = gSaveBlock2Ptr->records[gTrainerBattleOpponent_B - 300].field_1C[i]; - } + battleSave->easyChatSpeech[i] = gSaveBlock2Ptr->frontier.towerRecords[gTrainerBattleOpponent_B - TRAINER_RECORD_MIXING_FRIEND].speechWon[i]; } - battleSave->field_51A = gSaveBlock2Ptr->records[gTrainerBattleOpponent_B - 300].field_E4; + battleSave->recordMixFriendLanguage = gSaveBlock2Ptr->frontier.towerRecords[gTrainerBattleOpponent_B - TRAINER_RECORD_MIXING_FRIEND].language; } - else if (gPartnerTrainerId >= 300 && gPartnerTrainerId <= 399) + else if (gPartnerTrainerId >= TRAINER_RECORD_MIXING_FRIEND && gPartnerTrainerId < TRAINER_RECORD_MIXING_APPRENTICE) { - for (i = 0; i < 8; i++) - { - battleSave->field_504[i] = gSaveBlock2Ptr->records[gPartnerTrainerId - 300].field_4[i]; - } - battleSave->field_50C = gSaveBlock2Ptr->records[gPartnerTrainerId - 300].field_1; + for (i = 0; i < PLAYER_NAME_LENGTH + 1; i++) + battleSave->recordMixFriendName[i] = gSaveBlock2Ptr->frontier.towerRecords[gPartnerTrainerId - TRAINER_RECORD_MIXING_FRIEND].name[i]; + battleSave->recordMixFriendClass = gSaveBlock2Ptr->frontier.towerRecords[gPartnerTrainerId - TRAINER_RECORD_MIXING_FRIEND].facilityClass; - if (sUnknown_0203CCE8 == 1) - { - for (i = 0; i < 6; i++) - { - battleSave->field_50E[i] = gSaveBlock2Ptr->records[gPartnerTrainerId - 300].field_28[i]; - } - } - else - { - for (i = 0; i < 6; i++) - { - battleSave->field_50E[i] = gSaveBlock2Ptr->records[gPartnerTrainerId - 300].field_1C[i]; - } - } - battleSave->field_51A = gSaveBlock2Ptr->records[gPartnerTrainerId - 300].field_E4; + battleSave->recordMixFriendLanguage = gSaveBlock2Ptr->frontier.towerRecords[gPartnerTrainerId - TRAINER_RECORD_MIXING_FRIEND].language; } - */ + if (gTrainerBattleOpponent_A >= TRAINER_RECORD_MIXING_APPRENTICE) + { + battleSave->apprenticeId = gSaveBlock2Ptr->apprentices[gTrainerBattleOpponent_A - TRAINER_RECORD_MIXING_APPRENTICE].id; + for (i = 0; i < 6; i++) + battleSave->easyChatSpeech[i] = gSaveBlock2Ptr->apprentices[gTrainerBattleOpponent_A - TRAINER_RECORD_MIXING_APPRENTICE].easyChatWords[i]; + battleSave->apprenticeLanguage = gSaveBlock2Ptr->apprentices[gTrainerBattleOpponent_A - TRAINER_RECORD_MIXING_APPRENTICE].language; + } + else if (gTrainerBattleOpponent_B >= TRAINER_RECORD_MIXING_APPRENTICE) + { + battleSave->apprenticeId = gSaveBlock2Ptr->apprentices[gTrainerBattleOpponent_B - TRAINER_RECORD_MIXING_APPRENTICE].id; + for (i = 0; i < 6; i++) + battleSave->easyChatSpeech[i] = gSaveBlock2Ptr->apprentices[gTrainerBattleOpponent_B - TRAINER_RECORD_MIXING_APPRENTICE].easyChatWords[i]; + battleSave->apprenticeLanguage = gSaveBlock2Ptr->apprentices[gTrainerBattleOpponent_B - TRAINER_RECORD_MIXING_APPRENTICE].language; + } + else if (gPartnerTrainerId >= TRAINER_RECORD_MIXING_APPRENTICE) + { + battleSave->apprenticeId = gSaveBlock2Ptr->apprentices[gPartnerTrainerId - TRAINER_RECORD_MIXING_APPRENTICE].id; + + battleSave->apprenticeLanguage = gSaveBlock2Ptr->apprentices[gPartnerTrainerId - TRAINER_RECORD_MIXING_APPRENTICE].language; + } + + for (i = 0; i < MAX_BATTLERS_COUNT; i++) + { + for (j = 0; j < BATTLER_RECORD_SIZE; j++) + { + battleSave->battleRecord[i][j] = sBattleRecords[i][j]; + } + } + + while (1) + { + ret = RecordedBattleToSave(battleSave, savSection); + if (ret == TRUE) + break; + var++; + if (var >= 3) + break; + } + + free(battleSave); + free(savSection); + return ret; } -#else -NAKED -u32 MoveRecordedBattleToSaveData(void) -{ - asm(".syntax unified\n\ - push {r4-r7,lr}\n\ - mov r7, r10\n\ - mov r6, r9\n\ - mov r5, r8\n\ - push {r5-r7}\n\ - sub sp, 0xC\n\ - movs r0, 0\n\ - str r0, [sp, 0x4]\n\ - movs r0, 0xF8\n\ - lsls r0, 4\n\ - bl AllocZeroed\n\ - adds r7, r0, 0\n\ - movs r0, 0x80\n\ - lsls r0, 5\n\ - bl AllocZeroed\n\ - str r0, [sp]\n\ - movs r6, 0\n\ -_0818535E:\n\ - movs r0, 0x64\n\ - adds r4, r6, 0\n\ - muls r4, r0\n\ - adds r5, r7, r4\n\ - ldr r1, =sSavedPlayerParty\n\ - adds r1, r4, r1\n\ - adds r0, r5, 0\n\ - movs r2, 0x64\n\ - bl memcpy\n\ - movs r1, 0x96\n\ - lsls r1, 2\n\ - adds r5, r1\n\ - ldr r0, =sSavedOpponentParty\n\ - adds r4, r0\n\ - adds r0, r5, 0\n\ - adds r1, r4, 0\n\ - movs r2, 0x64\n\ - bl memcpy\n\ - adds r6, 0x1\n\ - cmp r6, 0x5\n\ - ble _0818535E\n\ - movs r6, 0\n\ - ldr r2, =gSaveBlock2Ptr\n\ - mov r9, r2\n\ - movs r3, 0x9A\n\ - lsls r3, 3\n\ - adds r3, r7, r3\n\ - str r3, [sp, 0x8]\n\ - ldr r5, =sPlayers\n\ - mov r8, r6\n\ - mov r12, r6\n\ - movs r4, 0x96\n\ - lsls r4, 3\n\ - adds r4, r7\n\ - mov r10, r4\n\ - ldr r0, =0x000004e4\n\ - adds r4, r7, r0\n\ -_081853AC:\n\ - lsls r1, r6, 3\n\ - ldr r0, =sPlayers\n\ - adds r0, 0x4\n\ - mov r3, r8\n\ - adds r2, r3, r0\n\ - add r1, r10\n\ - movs r3, 0x7\n\ -_081853BA:\n\ - ldrb r0, [r2]\n\ - strb r0, [r1]\n\ - adds r2, 0x1\n\ - adds r1, 0x1\n\ - subs r3, 0x1\n\ - cmp r3, 0\n\ - bge _081853BA\n\ - ldr r0, [sp, 0x8]\n\ - adds r1, r0, r6\n\ - ldrb r0, [r5, 0xC]\n\ - strb r0, [r1]\n\ - ldrh r0, [r5, 0x10]\n\ - strb r0, [r4]\n\ - ldrh r0, [r5, 0xE]\n\ - strb r0, [r4, 0xC]\n\ - ldr r1, =0x000004d4\n\ - adds r0, r7, r1\n\ - add r0, r12\n\ - ldr r1, [r5]\n\ - str r1, [r0]\n\ - adds r5, 0x14\n\ - movs r2, 0x14\n\ - add r8, r2\n\ - movs r3, 0x4\n\ - add r12, r3\n\ - adds r4, 0x1\n\ - adds r6, 0x1\n\ - cmp r6, 0x3\n\ - ble _081853AC\n\ - movs r4, 0x9D\n\ - lsls r4, 3\n\ - adds r1, r7, r4\n\ - ldr r5, =gRecordedBattleRngSeed\n\ - ldr r0, [r5]\n\ - str r0, [r1]\n\ - ldr r0, =sBattleFlags\n\ - ldr r2, [r0]\n\ - movs r0, 0x2\n\ - ands r0, r2\n\ - cmp r0, 0\n\ - beq _081854DC\n\ - ldr r1, =0x000004ec\n\ - adds r3, r7, r1\n\ - movs r1, 0x23\n\ - negs r1, r1\n\ - ands r1, r2\n\ - movs r0, 0x80\n\ - lsls r0, 18\n\ - orrs r1, r0\n\ - str r1, [r3]\n\ - movs r0, 0x4\n\ - ands r0, r2\n\ - cmp r0, 0\n\ - beq _08185454\n\ - movs r0, 0x80\n\ - lsls r0, 24\n\ - orrs r1, r0\n\ - str r1, [r3]\n\ - b _081854E2\n\ - .pool\n\ -_08185454:\n\ - movs r0, 0x40\n\ - ands r2, r0\n\ - cmp r2, 0\n\ - beq _081854E2\n\ - ldr r2, =sPlayers\n\ - ldrh r0, [r2, 0xE]\n\ - cmp r0, 0x1\n\ - beq _081854A8\n\ - cmp r0, 0x1\n\ - bgt _08185474\n\ - cmp r0, 0\n\ - beq _0818547E\n\ - b _081854E2\n\ - .pool\n\ -_08185474:\n\ - cmp r0, 0x2\n\ - beq _0818547E\n\ - cmp r0, 0x3\n\ - beq _081854A8\n\ - b _081854E2\n\ -_0818547E:\n\ - ldr r3, =gUnknown_0203C7B4\n\ - ldrb r1, [r3]\n\ - lsls r0, r1, 2\n\ - adds r0, r1\n\ - lsls r0, 2\n\ - ldr r4, =sPlayers\n\ - adds r0, r4\n\ - ldrh r1, [r0, 0xE]\n\ - movs r0, 0x1\n\ - ands r0, r1\n\ - cmp r0, 0\n\ - bne _081854E2\n\ - ldr r5, =0x000004ec\n\ - adds r0, r7, r5\n\ - b _081854C4\n\ - .pool\n\ -_081854A8:\n\ - ldr r0, =gUnknown_0203C7B4\n\ - ldrb r1, [r0]\n\ - lsls r0, r1, 2\n\ - adds r0, r1\n\ - lsls r0, 2\n\ - ldr r1, =sPlayers\n\ - adds r0, r1\n\ - ldrh r1, [r0, 0xE]\n\ - movs r0, 0x1\n\ - ands r0, r1\n\ - cmp r0, 0\n\ - beq _081854E2\n\ - ldr r2, =0x000004ec\n\ - adds r0, r7, r2\n\ -_081854C4:\n\ - ldr r1, [r0]\n\ - movs r2, 0x80\n\ - lsls r2, 24\n\ - orrs r1, r2\n\ - str r1, [r0]\n\ - b _081854E2\n\ - .pool\n\ -_081854DC:\n\ - ldr r3, =0x000004ec\n\ - adds r0, r7, r3\n\ - str r2, [r0]\n\ -_081854E2:\n\ - ldr r4, =gTrainerBattleOpponent_A\n\ - ldrh r1, [r4]\n\ - ldr r5, =0x000004f4\n\ - adds r0, r7, r5\n\ - strh r1, [r0]\n\ - ldr r0, =gTrainerBattleOpponent_B\n\ - ldrh r1, [r0]\n\ - ldr r2, =0x000004f6\n\ - adds r0, r7, r2\n\ - strh r1, [r0]\n\ - ldr r3, =gPartnerTrainerId\n\ - ldrh r1, [r3]\n\ - movs r4, 0x9F\n\ - lsls r4, 3\n\ - adds r0, r7, r4\n\ - strh r1, [r0]\n\ - ldr r5, =gUnknown_0203C7B4\n\ - ldrb r1, [r5]\n\ - adds r2, 0x4\n\ - adds r0, r7, r2\n\ - strh r1, [r0]\n\ - mov r3, r9\n\ - ldr r0, [r3]\n\ - ldr r4, =0x00000ca9\n\ - adds r0, r4\n\ - ldrb r0, [r0]\n\ - lsls r0, 30\n\ - lsrs r0, 30\n\ - ldr r5, =0x000004fc\n\ - adds r1, r7, r5\n\ - strb r0, [r1]\n\ - ldr r0, =sFrontierFacility\n\ - ldrb r1, [r0]\n\ - adds r2, 0x3\n\ - adds r0, r7, r2\n\ - strb r1, [r0]\n\ - ldr r3, =sUnknown_0203C7AF\n\ - ldrb r1, [r3]\n\ - ldr r4, =0x000004fe\n\ - adds r0, r7, r4\n\ - strb r1, [r0]\n\ - mov r5, r9\n\ - ldr r0, [r5]\n\ - ldrb r1, [r0, 0x15]\n\ - lsls r1, 29\n\ - ldr r0, =0x000004ff\n\ - adds r3, r7, r0\n\ - lsrs r1, 31\n\ - ldrb r2, [r3]\n\ - movs r0, 0x2\n\ - negs r0, r0\n\ - ands r0, r2\n\ - orrs r0, r1\n\ - strb r0, [r3]\n\ - ldr r1, [r5]\n\ - ldrb r1, [r1, 0x14]\n\ - lsls r1, 29\n\ - lsrs r1, 28\n\ - movs r2, 0xF\n\ - negs r2, r2\n\ - ands r0, r2\n\ - orrs r0, r1\n\ - strb r0, [r3]\n\ - movs r2, 0xA0\n\ - lsls r2, 3\n\ - adds r1, r7, r2\n\ - ldr r3, =sAI_Scripts\n\ - ldr r0, [r3]\n\ - str r0, [r1]\n\ - ldr r4, =0xfffffed4\n\ - adds r1, r4, 0\n\ - ldr r5, =gTrainerBattleOpponent_A\n\ - ldrh r5, [r5]\n\ - adds r0, r1, r5\n\ - lsls r0, 16\n\ - lsrs r0, 16\n\ - cmp r0, 0x63\n\ - bls _08185580\n\ - b _081856C4\n\ -_08185580:\n\ - movs r6, 0\n\ - ldr r0, =0x00000504\n\ - adds r3, r7, r0\n\ - mov r10, r9\n\ - ldr r1, =gTrainerBattleOpponent_A\n\ - mov r12, r1\n\ - adds r2, r4, 0\n\ - mov r8, r2\n\ - ldr r4, =0x0000073c\n\ -_08185592:\n\ - adds r2, r3, r6\n\ - mov r5, r10\n\ - ldr r1, [r5]\n\ - mov r5, r12\n\ - ldrh r0, [r5]\n\ - add r0, r8\n\ - movs r5, 0xEC\n\ - muls r0, r5\n\ - adds r0, r6, r0\n\ - adds r1, r4\n\ - adds r1, r0\n\ - ldrb r0, [r1]\n\ - strb r0, [r2]\n\ - adds r6, 0x1\n\ - cmp r6, 0x7\n\ - ble _08185592\n\ - mov r0, r9\n\ - ldr r2, [r0]\n\ - ldr r1, =gTrainerBattleOpponent_A\n\ - ldrh r0, [r1]\n\ - ldr r3, =0xfffffed4\n\ - adds r0, r3\n\ - movs r1, 0xEC\n\ - muls r0, r1\n\ - adds r2, r0\n\ - ldr r4, =0x00000739\n\ - adds r2, r4\n\ - ldrb r1, [r2]\n\ - ldr r5, =0x0000050c\n\ - adds r0, r7, r5\n\ - strb r1, [r0]\n\ - ldr r1, =sUnknown_0203CCE8\n\ - ldrb r0, [r1]\n\ - cmp r0, 0x1\n\ - bne _08185664\n\ - movs r6, 0\n\ - ldr r2, =0x0000050e\n\ - adds r4, r7, r2\n\ - mov r10, r9\n\ - ldr r5, =gTrainerBattleOpponent_A\n\ - mov r8, r5\n\ - adds r5, r3, 0\n\ -_081855E6:\n\ - lsls r3, r6, 1\n\ - mov r0, r10\n\ - ldr r2, [r0]\n\ - mov r1, r8\n\ - ldrh r0, [r1]\n\ - adds r0, r5\n\ - movs r1, 0xEC\n\ - muls r0, r1\n\ - adds r3, r0\n\ - movs r0, 0xEC\n\ - lsls r0, 3\n\ - adds r2, r0\n\ - adds r2, r3\n\ - ldrh r0, [r2]\n\ - strh r0, [r4]\n\ - adds r4, 0x2\n\ - adds r6, 0x1\n\ - cmp r6, 0x5\n\ - ble _081855E6\n\ - b _08185696\n\ - .pool\n\ -_08185664:\n\ - movs r6, 0\n\ - ldr r1, =0x0000050e\n\ - adds r4, r7, r1\n\ - mov r10, r9\n\ - ldr r2, =gTrainerBattleOpponent_A\n\ - mov r8, r2\n\ - adds r5, r3, 0\n\ -_08185672:\n\ - lsls r3, r6, 1\n\ - mov r0, r10\n\ - ldr r2, [r0]\n\ - mov r1, r8\n\ - ldrh r0, [r1]\n\ - adds r0, r5\n\ - movs r1, 0xEC\n\ - muls r0, r1\n\ - adds r3, r0\n\ - ldr r0, =0x00000754\n\ - adds r2, r0\n\ - adds r2, r3\n\ - ldrh r0, [r2]\n\ - strh r0, [r4]\n\ - adds r4, 0x2\n\ - adds r6, 0x1\n\ - cmp r6, 0x5\n\ - ble _08185672\n\ -_08185696:\n\ - mov r1, r9\n\ - ldr r2, [r1]\n\ - ldr r3, =gTrainerBattleOpponent_A\n\ - ldrh r0, [r3]\n\ - ldr r4, =0xfffffed4\n\ - adds r0, r4\n\ - movs r1, 0xEC\n\ - muls r0, r1\n\ - adds r2, r0\n\ - ldr r5, =0x0000081c\n\ - adds r2, r5\n\ - ldrb r1, [r2]\n\ - b _08185856\n\ - .pool\n\ -_081856C4:\n\ - ldr r3, =gTrainerBattleOpponent_B\n\ - ldrh r3, [r3]\n\ - adds r0, r1, r3\n\ - lsls r0, 16\n\ - lsrs r0, 16\n\ - cmp r0, 0x63\n\ - bls _081856D4\n\ - b _081857E4\n\ -_081856D4:\n\ - movs r6, 0\n\ - ldr r4, =0x00000504\n\ - adds r3, r7, r4\n\ - mov r10, r9\n\ - ldr r5, =gTrainerBattleOpponent_B\n\ - mov r12, r5\n\ - ldr r0, =0xfffffed4\n\ - mov r8, r0\n\ - ldr r4, =0x0000073c\n\ -_081856E6:\n\ - adds r2, r3, r6\n\ - mov r5, r10\n\ - ldr r1, [r5]\n\ - mov r5, r12\n\ - ldrh r0, [r5]\n\ - add r0, r8\n\ - movs r5, 0xEC\n\ - muls r0, r5\n\ - adds r0, r6, r0\n\ - adds r1, r4\n\ - adds r1, r0\n\ - ldrb r0, [r1]\n\ - strb r0, [r2]\n\ - adds r6, 0x1\n\ - cmp r6, 0x7\n\ - ble _081856E6\n\ - mov r0, r9\n\ - ldr r2, [r0]\n\ - ldr r1, =gTrainerBattleOpponent_B\n\ - ldrh r0, [r1]\n\ - ldr r3, =0xfffffed4\n\ - adds r0, r3\n\ - movs r1, 0xEC\n\ - muls r0, r1\n\ - adds r2, r0\n\ - ldr r4, =0x00000739\n\ - adds r2, r4\n\ - ldrb r1, [r2]\n\ - ldr r5, =0x0000050c\n\ - adds r0, r7, r5\n\ - strb r1, [r0]\n\ - ldr r1, =sUnknown_0203CCE8\n\ - ldrb r0, [r1]\n\ - cmp r0, 0x1\n\ - bne _08185784\n\ - movs r6, 0\n\ - ldr r2, =0x0000050e\n\ - adds r4, r7, r2\n\ - mov r10, r9\n\ - ldr r5, =gTrainerBattleOpponent_B\n\ - mov r8, r5\n\ - adds r5, r3, 0\n\ -_0818573A:\n\ - lsls r3, r6, 1\n\ - mov r0, r10\n\ - ldr r2, [r0]\n\ - mov r1, r8\n\ - ldrh r0, [r1]\n\ - adds r0, r5\n\ - movs r1, 0xEC\n\ - muls r0, r1\n\ - adds r3, r0\n\ - movs r0, 0xEC\n\ - lsls r0, 3\n\ - adds r2, r0\n\ - adds r2, r3\n\ - ldrh r0, [r2]\n\ - strh r0, [r4]\n\ - adds r4, 0x2\n\ - adds r6, 0x1\n\ - cmp r6, 0x5\n\ - ble _0818573A\n\ - b _081857B6\n\ - .pool\n\ -_08185784:\n\ - movs r6, 0\n\ - ldr r1, =0x0000050e\n\ - adds r4, r7, r1\n\ - mov r10, r9\n\ - ldr r2, =gTrainerBattleOpponent_B\n\ - mov r8, r2\n\ - adds r5, r3, 0\n\ -_08185792:\n\ - lsls r3, r6, 1\n\ - mov r0, r10\n\ - ldr r2, [r0]\n\ - mov r1, r8\n\ - ldrh r0, [r1]\n\ - adds r0, r5\n\ - movs r1, 0xEC\n\ - muls r0, r1\n\ - adds r3, r0\n\ - ldr r0, =0x00000754\n\ - adds r2, r0\n\ - adds r2, r3\n\ - ldrh r0, [r2]\n\ - strh r0, [r4]\n\ - adds r4, 0x2\n\ - adds r6, 0x1\n\ - cmp r6, 0x5\n\ - ble _08185792\n\ -_081857B6:\n\ - mov r1, r9\n\ - ldr r2, [r1]\n\ - ldr r3, =gTrainerBattleOpponent_B\n\ - ldrh r0, [r3]\n\ - ldr r4, =0xfffffed4\n\ - adds r0, r4\n\ - movs r1, 0xEC\n\ - muls r0, r1\n\ - adds r2, r0\n\ - ldr r5, =0x0000081c\n\ - adds r2, r5\n\ - ldrb r1, [r2]\n\ - b _08185856\n\ - .pool\n\ -_081857E4:\n\ - ldr r3, =gPartnerTrainerId\n\ - ldrh r3, [r3]\n\ - adds r0, r1, r3\n\ - lsls r0, 16\n\ - lsrs r0, 16\n\ - cmp r0, 0x63\n\ - bhi _0818585C\n\ - movs r6, 0\n\ - ldr r4, =0x00000504\n\ - adds r3, r7, r4\n\ - mov r10, r9\n\ - ldr r5, =gPartnerTrainerId\n\ - mov r12, r5\n\ - ldr r0, =0xfffffed4\n\ - mov r8, r0\n\ - ldr r4, =0x0000073c\n\ -_08185804:\n\ - adds r2, r3, r6\n\ - mov r5, r10\n\ - ldr r1, [r5]\n\ - mov r5, r12\n\ - ldrh r0, [r5]\n\ - add r0, r8\n\ - movs r5, 0xEC\n\ - muls r0, r5\n\ - adds r0, r6, r0\n\ - adds r1, r4\n\ - adds r1, r0\n\ - ldrb r0, [r1]\n\ - strb r0, [r2]\n\ - adds r6, 0x1\n\ - cmp r6, 0x7\n\ - ble _08185804\n\ - mov r0, r9\n\ - ldr r1, [r0]\n\ - ldr r2, =gPartnerTrainerId\n\ - ldrh r0, [r2]\n\ - ldr r3, =0xfffffed4\n\ - adds r0, r3\n\ - movs r2, 0xEC\n\ - muls r0, r2\n\ - adds r1, r0\n\ - ldr r4, =0x00000739\n\ - adds r1, r4\n\ - ldrb r1, [r1]\n\ - ldr r5, =0x0000050c\n\ - adds r0, r7, r5\n\ - strb r1, [r0]\n\ - mov r0, r9\n\ - ldr r1, [r0]\n\ - ldr r4, =gPartnerTrainerId\n\ - ldrh r0, [r4]\n\ - adds r0, r3\n\ - muls r0, r2\n\ - adds r1, r0\n\ - ldr r5, =0x0000081c\n\ - adds r1, r5\n\ - ldrb r1, [r1]\n\ -_08185856:\n\ - ldr r2, =0x0000051a\n\ - adds r0, r7, r2\n\ - strb r1, [r0]\n\ -_0818585C:\n\ - ldr r3, =gTrainerBattleOpponent_A\n\ - ldrh r0, [r3]\n\ - ldr r1, =0x0000018f\n\ - cmp r0, r1\n\ - bls _08185900\n\ - mov r4, r9\n\ - ldr r2, [r4]\n\ - adds r1, r0, 0\n\ - ldr r3, =0xfffffe70\n\ - adds r1, r3\n\ - lsls r0, r1, 4\n\ - adds r0, r1\n\ - lsls r0, 2\n\ - adds r2, r0\n\ - adds r2, 0xDC\n\ - ldrb r0, [r2]\n\ - lsls r0, 27\n\ - lsrs r0, 27\n\ - ldr r5, =0x0000050d\n\ - adds r1, r7, r5\n\ - strb r0, [r1]\n\ - movs r6, 0\n\ - ldr r0, =0x0000050e\n\ - adds r4, r7, r0\n\ - mov r10, r9\n\ - ldr r1, =gTrainerBattleOpponent_A\n\ - mov r8, r1\n\ - adds r5, r3, 0\n\ -_08185894:\n\ - lsls r3, r6, 1\n\ - mov r0, r10\n\ - ldr r2, [r0]\n\ - mov r0, r8\n\ - ldrh r1, [r0]\n\ - adds r1, r5\n\ - lsls r0, r1, 4\n\ - adds r0, r1\n\ - lsls r0, 2\n\ - adds r3, r0\n\ - movs r1, 0x82\n\ - lsls r1, 1\n\ - adds r2, r1\n\ - adds r2, r3\n\ - ldrh r0, [r2]\n\ - strh r0, [r4]\n\ - adds r4, 0x2\n\ - adds r6, 0x1\n\ - cmp r6, 0x5\n\ - ble _08185894\n\ - mov r3, r9\n\ - ldr r2, [r3]\n\ - ldr r4, =gTrainerBattleOpponent_A\n\ - ldrh r1, [r4]\n\ - ldr r5, =0xfffffe70\n\ - adds r1, r5\n\ - b _081859AC\n\ - .pool\n\ -_08185900:\n\ - ldr r3, =gTrainerBattleOpponent_B\n\ - ldrh r0, [r3]\n\ - cmp r0, r1\n\ - bls _0818597C\n\ - mov r4, r9\n\ - ldr r2, [r4]\n\ - adds r1, r0, 0\n\ - ldr r3, =0xfffffe70\n\ - adds r1, r3\n\ - lsls r0, r1, 4\n\ - adds r0, r1\n\ - lsls r0, 2\n\ - adds r2, r0\n\ - adds r2, 0xDC\n\ - ldrb r0, [r2]\n\ - lsls r0, 27\n\ - lsrs r0, 27\n\ - ldr r5, =0x0000050d\n\ - adds r1, r7, r5\n\ - strb r0, [r1]\n\ - movs r6, 0\n\ - ldr r0, =0x0000050e\n\ - adds r4, r7, r0\n\ - mov r10, r9\n\ - ldr r1, =gTrainerBattleOpponent_B\n\ - mov r8, r1\n\ - adds r5, r3, 0\n\ -_08185936:\n\ - lsls r3, r6, 1\n\ - mov r0, r10\n\ - ldr r2, [r0]\n\ - mov r0, r8\n\ - ldrh r1, [r0]\n\ - adds r1, r5\n\ - lsls r0, r1, 4\n\ - adds r0, r1\n\ - lsls r0, 2\n\ - adds r3, r0\n\ - movs r1, 0x82\n\ - lsls r1, 1\n\ - adds r2, r1\n\ - adds r2, r3\n\ - ldrh r0, [r2]\n\ - strh r0, [r4]\n\ - adds r4, 0x2\n\ - adds r6, 0x1\n\ - cmp r6, 0x5\n\ - ble _08185936\n\ - mov r3, r9\n\ - ldr r2, [r3]\n\ - ldr r4, =gTrainerBattleOpponent_B\n\ - ldrh r1, [r4]\n\ - ldr r5, =0xfffffe70\n\ - adds r1, r5\n\ - b _081859AC\n\ - .pool\n\ -_0818597C:\n\ - ldr r3, =gPartnerTrainerId\n\ - ldrh r0, [r3]\n\ - cmp r0, r1\n\ - bls _081859C0\n\ - mov r4, r9\n\ - ldr r2, [r4]\n\ - adds r1, r0, 0\n\ - ldr r3, =0xfffffe70\n\ - adds r1, r3\n\ - lsls r0, r1, 4\n\ - adds r0, r1\n\ - lsls r0, 2\n\ - adds r2, r0\n\ - adds r2, 0xDC\n\ - ldrb r0, [r2]\n\ - lsls r0, 27\n\ - lsrs r0, 27\n\ - ldr r5, =0x0000050d\n\ - adds r1, r7, r5\n\ - strb r0, [r1]\n\ - ldr r2, [r4]\n\ - ldr r0, =gPartnerTrainerId\n\ - ldrh r1, [r0]\n\ - adds r1, r3\n\ -_081859AC:\n\ - lsls r0, r1, 4\n\ - adds r0, r1\n\ - lsls r0, 2\n\ - adds r2, r0\n\ - ldr r1, =0x0000011b\n\ - adds r0, r2, r1\n\ - ldrb r1, [r0]\n\ - ldr r2, =0x0000051b\n\ - adds r0, r7, r2\n\ - strb r1, [r0]\n\ -_081859C0:\n\ - movs r6, 0\n\ - ldr r3, =0x00000297\n\ - mov r10, r3\n\ - ldr r4, =sBattleRecords\n\ - mov r9, r4\n\ - movs r5, 0xA6\n\ - lsls r5, 2\n\ - mov r8, r5\n\ - ldr r0, =0x0000051c\n\ - adds r5, r7, r0\n\ -_081859D4:\n\ - adds r4, r6, 0x1\n\ - mov r0, r8\n\ - muls r0, r6\n\ - mov r1, r9\n\ - adds r2, r0, r1\n\ - adds r1, r0, r5\n\ - mov r3, r10\n\ - adds r3, 0x1\n\ -_081859E4:\n\ - ldrb r0, [r2]\n\ - strb r0, [r1]\n\ - adds r2, 0x1\n\ - adds r1, 0x1\n\ - subs r3, 0x1\n\ - cmp r3, 0\n\ - bne _081859E4\n\ - adds r6, r4, 0\n\ - cmp r6, 0x3\n\ - ble _081859D4\n\ -_081859F8:\n\ - adds r0, r7, 0\n\ - ldr r1, [sp]\n\ - bl sub_81852F0\n\ - adds r4, r0, 0\n\ - cmp r4, 0x1\n\ - beq _08185A14\n\ - ldr r0, [sp, 0x4]\n\ - adds r0, 0x1\n\ - lsls r0, 24\n\ - lsrs r0, 24\n\ - str r0, [sp, 0x4]\n\ - cmp r0, 0x2\n\ - bls _081859F8\n\ -_08185A14:\n\ - adds r0, r7, 0\n\ - bl Free\n\ - ldr r0, [sp]\n\ - bl Free\n\ - adds r0, r4, 0\n\ - add sp, 0xC\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\ - .pool\n\ - .syntax divided"); -} -#endif // NONMATCHING - static bool32 TryCopyRecordedBattleSaveData(struct RecordedBattleSave *dst, struct SaveSection *saveBuffer) { if (TryCopySpecialSaveSection(SECTION_ID_RECORDED_BATTLE, (void*)(saveBuffer)) != 1) @@ -1282,7 +501,7 @@ static bool32 TryCopyRecordedBattleSaveData(struct RecordedBattleSave *dst, stru return TRUE; } -static bool32 AllocTryCopyRecordedBattleSaveData(struct RecordedBattleSave *dst) +static bool32 CopyRecordedBattleFromSave(struct RecordedBattleSave *dst) { struct SaveSection *savBuffer = AllocZeroed(sizeof(struct SaveSection)); bool32 ret = TryCopyRecordedBattleSaveData(dst, savBuffer); @@ -1293,7 +512,7 @@ static bool32 AllocTryCopyRecordedBattleSaveData(struct RecordedBattleSave *dst) static void CB2_RecordedBattleEnd(void) { - gSaveBlock2Ptr->frontier.lvlMode = sUnknown_0203C7AD; + gSaveBlock2Ptr->frontier.lvlMode = sLvlMode; gBattleOutcome = 0; gBattleTypeFlags = 0; gTrainerBattleOpponent_A = 0; @@ -1316,7 +535,7 @@ static void Task_StartAfterCountdown(u8 taskId) } } -static void SetRecordedBattleVarsFromSave(struct RecordedBattleSave *src) +static void SetVariablesForRecordedBattle(struct RecordedBattleSave *src) { bool8 var; s32 i, j; @@ -1353,29 +572,29 @@ static void SetRecordedBattleVarsFromSave(struct RecordedBattleSave *src) gTrainerBattleOpponent_B = src->opponentB; gPartnerTrainerId = src->partnerId; gUnknown_0203C7B4 = src->field_4FA; - sUnknown_0203C7AD = gSaveBlock2Ptr->frontier.lvlMode; - sFrontierFacility = src->field_4FD; - sUnknown_0203C7AF = src->field_4FE; - sBattleStyle = src->battleStyle; + sLvlMode = gSaveBlock2Ptr->frontier.lvlMode; + sFrontierFacility = src->frontierFacility; + sFrontierBrainSymbol = src->frontierBrainSymbol; + sBattleScene = src->battleScene; sTextSpeed = src->textSpeed; sAI_Scripts = src->AI_scripts; - for (i = 0; i < 8; i++) + for (i = 0; i < PLAYER_NAME_LENGTH + 1; i++) { - sUnknown_0203CCD1[i] = src->field_504[i]; + sRecordMixFriendName[i] = src->recordMixFriendName[i]; } - sUnknown_0203CCD9 = src->field_50C; - sUnknown_0203CCDA = src->field_50D; - gUnknown_03001278 = src->field_51A; - gUnknown_03001279 = src->field_51B; + sRecordMixFriendClass = src->recordMixFriendClass; + sApprenticeId = src->apprenticeId; + gUnknown_03001278 = src->recordMixFriendLanguage; + gUnknown_03001279 = src->apprenticeLanguage; for (i = 0; i < 6; i++) { - sUnknown_0203CCDC[i] = src->field_50E[i]; + sEasyChatSpeech[i] = src->easyChatSpeech[i]; } - gSaveBlock2Ptr->frontier.lvlMode = src->field_4FC; + gSaveBlock2Ptr->frontier.lvlMode = src->lvlMode; for (i = 0; i < MAX_BATTLERS_COUNT; i++) { @@ -1389,12 +608,12 @@ static void SetRecordedBattleVarsFromSave(struct RecordedBattleSave *src) void PlayRecordedBattle(void (*CB2_After)(void)) { struct RecordedBattleSave *battleSave = AllocZeroed(sizeof(struct RecordedBattleSave)); - if (AllocTryCopyRecordedBattleSaveData(battleSave) == TRUE) + if (CopyRecordedBattleFromSave(battleSave) == TRUE) { u8 taskId; RecordedBattle_SaveParties(); - SetRecordedBattleVarsFromSave(battleSave); + SetVariablesForRecordedBattle(battleSave); taskId = CreateTask(Task_StartAfterCountdown, 1); gTasks[taskId].tFramesToWait = 128; @@ -1420,9 +639,9 @@ u8 GetRecordedBattleFrontierFacility(void) return sFrontierFacility; } -u8 sub_8185EAC(void) +u8 GetRecordedBattleFronterBrainSymbol(void) { - return sUnknown_0203C7AF; + return sFrontierBrainSymbol; } void RecordedBattle_SaveParties(void) @@ -1478,9 +697,9 @@ u8 sub_8185FAC(void) return sUnknown_0203C7B5; } -u8 GetBattleStyleInRecordedBattle(void) +u8 GetBattleSceneInRecordedBattle(void) { - return sBattleStyle; + return sBattleScene; } u8 GetTextSpeedInRecordedBattle(void) @@ -1630,38 +849,38 @@ void sub_8186468(u8 *dst) s32 i; for (i = 0; i < 8; i++) - dst[i] = sUnknown_0203CCD1[i]; + dst[i] = sRecordMixFriendName[i]; dst[7] = EOS; ConvertInternationalString(dst, gUnknown_03001278); } -u8 sub_818649C(void) +u8 GetRecordedBattleRecordMixFriendClass(void) { - return sUnknown_0203CCD9; + return sRecordMixFriendClass; } -u8 sub_81864A8(void) +u8 GetRecordedBattleApprenticeId(void) { - return sUnknown_0203CCDA; + return sApprenticeId; } -u8 sub_81864B4(void) +u8 GetRecordedBattleRecordMixFriendLanguage(void) { return gUnknown_03001278; } -u8 sub_81864C0(void) +u8 GetRecordedBattleApprenticeLanguage(void) { return gUnknown_03001279; } -void sub_81864CC(void) +void RecordedBattle_SaveBattleOutcome(void) { - sUnknown_0203CCE8 = gBattleOutcome; + sBattleOutcome = gBattleOutcome; } -u16 *sub_81864E0(void) +u16 *GetRecordedBattleEasyChatSpeech(void) { - return sUnknown_0203CCDC; + return sEasyChatSpeech; }