From 78cad0dee52e69ab7cca6b8ddc793820697ba01f Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Sun, 26 Aug 2018 15:27:06 +0200 Subject: [PATCH] try battle tent and fail --- asm/battle_frontier_1.s | 351 ---------------------------------------- asm/battle_frontier_2.s | 6 +- asm/battle_tower.s | 66 ++++---- include/battle_tower.h | 10 ++ include/global.h | 14 +- ld_script.txt | 1 + src/battle_dome.c | 20 +-- src/battle_frontier_1.c | 118 ++++++++++++++ src/battle_tent.c | 83 +++++++++- src/field_specials.c | 6 +- src/pokemon.c | 9 +- src/unk_text_util_2.c | 1 + 12 files changed, 264 insertions(+), 421 deletions(-) create mode 100644 src/battle_frontier_1.c diff --git a/asm/battle_frontier_1.s b/asm/battle_frontier_1.s index 193bd5e34..7ebc2f256 100644 --- a/asm/battle_frontier_1.s +++ b/asm/battle_frontier_1.s @@ -7,357 +7,6 @@ - - - thumb_func_start sub_8195960 -sub_8195960: @ 8195960 - push {lr} - ldr r1, =gUnknown_0860DE50 - ldr r0, =gSpecialVar_0x8004 - ldrh r0, [r0] - lsls r0, 2 - adds r0, r1 - ldr r0, [r0] - bl _call_via_r0 - pop {r0} - bx r0 - .pool - thumb_func_end sub_8195960 - - thumb_func_start sub_8195980 -sub_8195980: @ 8195980 - push {r4-r7,lr} - ldr r4, =gSaveBlock2Ptr - ldr r0, [r4] - ldr r1, =0x00000ca9 - adds r0, r1 - ldrb r0, [r0] - lsls r0, 30 - lsrs r5, r0, 30 - ldr r0, =0x000040ce - bl VarGet - lsls r0, 16 - lsrs r7, r0, 16 - ldr r0, [r4] - ldr r2, =0x00000ca8 - adds r0, r2 - movs r6, 0 - strb r6, [r0] - ldr r1, [r4] - adds r2, 0xA - adds r0, r1, r2 - strh r6, [r0] - ldr r0, =0x00000ca9 - adds r1, r0 - ldrb r2, [r1] - movs r0, 0x5 - negs r0, r0 - ands r0, r2 - strb r0, [r1] - ldr r1, [r4] - ldr r2, =0x00000ca9 - adds r1, r2 - ldrb r2, [r1] - movs r0, 0x9 - negs r0, r0 - ands r0, r2 - strb r0, [r1] - ldr r4, [r4] - ldr r0, =0x00000cdc - adds r3, r4, r0 - ldr r2, =gUnknown_0860DE98 - lsls r1, r5, 2 - lsls r0, r7, 3 - adds r1, r0 - adds r1, r2 - ldr r0, [r3] - ldr r1, [r1] - ands r0, r1 - cmp r0, 0 - bne _081959F2 - lsls r0, r5, 1 - lsls r1, r7, 2 - adds r0, r1 - ldr r2, =0x00000dc8 - adds r1, r4, r2 - adds r1, r0 - strh r6, [r1] -_081959F2: - ldr r0, =gSaveBlock1Ptr - ldr r0, [r0] - movs r1, 0x4 - ldrsb r1, [r0, r1] - movs r2, 0x5 - ldrsb r2, [r0, r2] - movs r3, 0x1 - negs r3, r3 - movs r0, 0 - bl saved_warp2_set - ldr r0, =gTrainerBattleOpponent_A - strh r6, [r0] - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8195980 - - thumb_func_start sub_8195A38 -sub_8195A38: @ 8195A38 - push {r4-r7,lr} - ldr r5, =gSaveBlock2Ptr - ldr r0, [r5] - ldr r1, =0x00000ca9 - adds r0, r1 - ldrb r0, [r0] - lsls r0, 30 - lsrs r7, r0, 30 - ldr r0, =0x000040ce - bl VarGet - lsls r0, 16 - lsrs r6, r0, 16 - ldr r0, =gSpecialVar_0x8005 - ldrh r0, [r0] - cmp r0, 0x1 - beq _08195A90 - cmp r0, 0x1 - bgt _08195A74 - cmp r0, 0 - beq _08195A7A - b _08195AD0 - .pool -_08195A74: - cmp r0, 0x2 - beq _08195AB0 - b _08195AD0 -_08195A7A: - ldr r0, =gSpecialVar_Result - ldr r1, [r5] - ldr r2, =0x00000dc6 - adds r1, r2 - ldrh r1, [r1] - strh r1, [r0] - b _08195AD0 - .pool -_08195A90: - ldr r3, =gSpecialVar_Result - ldr r0, [r5] - lsls r1, r7, 1 - lsls r2, r6, 2 - adds r1, r2 - ldr r2, =0x00000dc8 - adds r0, r2 - adds r0, r1 - ldrh r0, [r0] - strh r0, [r3] - b _08195AD0 - .pool -_08195AB0: - ldr r4, =gSpecialVar_Result - ldr r2, [r5] - ldr r0, =0x00000cdc - adds r2, r0 - ldr r3, =gUnknown_0860DE98 - lsls r0, r7, 2 - lsls r1, r6, 3 - adds r0, r1 - adds r0, r3 - ldr r1, [r2] - ldr r0, [r0] - ands r1, r0 - negs r0, r1 - orrs r0, r1 - lsrs r0, 31 - strh r0, [r4] -_08195AD0: - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8195A38 - - thumb_func_start sub_8195AE4 -sub_8195AE4: @ 8195AE4 - push {r4-r6,lr} - ldr r6, =gSaveBlock2Ptr - ldr r0, [r6] - ldr r1, =0x00000ca9 - adds r0, r1 - ldrb r0, [r0] - lsls r0, 30 - lsrs r5, r0, 30 - ldr r0, =0x000040ce - bl VarGet - lsls r0, 16 - lsrs r4, r0, 16 - ldr r0, =gSpecialVar_0x8005 - ldrh r0, [r0] - cmp r0, 0x1 - beq _08195B3C - cmp r0, 0x1 - bgt _08195B20 - cmp r0, 0 - beq _08195B26 - b _08195BA0 - .pool -_08195B20: - cmp r0, 0x2 - beq _08195B5C - b _08195BA0 -_08195B26: - ldr r0, [r6] - ldr r1, =gSpecialVar_0x8006 - ldrh r1, [r1] - ldr r2, =0x00000dc6 - adds r0, r2 - strh r1, [r0] - b _08195BA0 - .pool -_08195B3C: - ldr r2, [r6] - lsls r0, r5, 1 - lsls r1, r4, 2 - adds r0, r1 - ldr r1, =0x00000dc8 - adds r2, r1 - adds r2, r0 - ldr r0, =gSpecialVar_0x8006 - ldrh r0, [r0] - strh r0, [r2] - b _08195BA0 - .pool -_08195B5C: - ldr r0, =gSpecialVar_0x8006 - ldrh r0, [r0] - cmp r0, 0 - beq _08195B88 - ldr r2, [r6] - ldr r0, =0x00000cdc - adds r2, r0 - ldr r3, =gUnknown_0860DE98 - lsls r1, r5, 2 - lsls r0, r4, 3 - adds r1, r0 - adds r1, r3 - ldr r0, [r2] - ldr r1, [r1] - orrs r0, r1 - b _08195B9E - .pool -_08195B88: - ldr r2, [r6] - ldr r1, =0x00000cdc - adds r2, r1 - ldr r3, =gUnknown_0860DEA8 - lsls r1, r5, 2 - lsls r0, r4, 3 - adds r1, r0 - adds r1, r3 - ldr r0, [r2] - ldr r1, [r1] - ands r0, r1 -_08195B9E: - str r0, [r2] -_08195BA0: - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8195AE4 - - thumb_func_start sub_8195BB0 -sub_8195BB0: @ 8195BB0 - push {r4,lr} - ldr r0, =0x000040ce - bl VarGet - lsls r0, 16 - ldr r1, =gSaveBlock2Ptr - ldr r2, [r1] - ldr r3, =0x00000ca9 - adds r1, r2, r3 - ldrb r1, [r1] - lsls r1, 30 - lsrs r1, 29 - lsrs r0, 14 - adds r1, r0 - ldr r0, =0x00000dc8 - adds r2, r0 - adds r2, r1 - ldrh r0, [r2] - cmp r0, 0x31 - bhi _08195C00 - ldr r4, =gSpecialVar_Result - bl Random - lsls r0, 16 - lsrs r0, 16 - movs r1, 0x3 - bl __umodsi3 - strh r0, [r4] - b _08195C16 - .pool -_08195C00: - cmp r0, 0x62 - bhi _08195C10 - ldr r1, =gSpecialVar_Result - movs r0, 0x3 - b _08195C14 - .pool -_08195C10: - ldr r1, =gSpecialVar_Result - movs r0, 0x4 -_08195C14: - strh r0, [r1] -_08195C16: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8195BB0 - - thumb_func_start sub_8195C20 -sub_8195C20: @ 8195C20 - push {r4,lr} - ldr r4, =gTrainerBattleOpponent_A - bl Random - lsls r0, 16 - lsrs r0, 16 - movs r1, 0xFF - bl __umodsi3 - lsls r0, 16 - lsrs r0, 16 - lsls r1, r0, 2 - adds r1, r0 - lsrs r1, 6 - strh r1, [r4] - ldrh r0, [r4] - movs r1, 0 - bl sub_8162614 - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8195C20 - - thumb_func_start sub_8195C50 -sub_8195C50: @ 8195C50 - push {lr} - ldr r3, =gTrainerBattleOpponent_A - ldrh r1, [r3] - ldr r0, =0x0000012b - cmp r1, r0 - bhi _08195C6C - ldr r2, =gFacilityTrainers - movs r0, 0x34 - muls r1, r0 - ldr r0, [r2] - adds r0, r1 - adds r0, 0xC - bl ConvertBattleFrontierTrainerSpeechToString -_08195C6C: - pop {r0} - bx r0 - .pool - thumb_func_end sub_8195C50 - thumb_func_start sub_8195C7C sub_8195C7C: @ 8195C7C push {r4-r7,lr} diff --git a/asm/battle_frontier_2.s b/asm/battle_frontier_2.s index e7cb14530..1a2233a97 100644 --- a/asm/battle_frontier_2.s +++ b/asm/battle_frontier_2.s @@ -20059,7 +20059,7 @@ _081A4E46: bl ZeroEnemyPartyMons movs r1, 0 str r1, [sp, 0x18] - bl GetFrontierEnemyMonLevel + bl GetFacilityEnemyMonLevel lsls r0, 24 lsrs r0, 24 str r0, [sp, 0x1C] @@ -23702,7 +23702,7 @@ sub_81A6CD0: @ 81A6CD0 lsls r0, 24 lsrs r0, 24 str r0, [sp, 0x24] - bl GetFrontierEnemyMonLevel + bl GetFacilityEnemyMonLevel lsls r0, 24 lsrs r0, 24 str r0, [sp, 0x20] @@ -29517,7 +29517,7 @@ _081A9C56: bl SetMonData cmp r5, 0 beq _081A9CD4 - bl GetFrontierEnemyMonLevel + bl GetFacilityEnemyMonLevel lsls r0, 24 lsrs r5, r0, 24 ldr r1, [sp, 0x10] diff --git a/asm/battle_tower.s b/asm/battle_tower.s index 1ece38af9..bdc49fed2 100644 --- a/asm/battle_tower.s +++ b/asm/battle_tower.s @@ -391,7 +391,7 @@ _081622B2: adds r4, r1, r0 mov r0, r10 str r2, [sp, 0x38] - bl BattleFrontierGetOpponentLvl + bl GetFrontierEnemyMonLevel ldrb r1, [r4] lsls r0, 24 lsrs r0, 24 @@ -551,7 +551,7 @@ _08162414: bl __udivsi3 lsls r0, 16 lsrs r5, r0, 16 - bl GetFrontierEnemyMonLevel + bl GetFacilityEnemyMonLevel subs r4, 0x2 cmp r4, 0x1 bhi _08162488 @@ -784,7 +784,7 @@ sub_8162614: @ 8162614 adds r6, r4, 0 lsls r1, 24 lsrs r5, r1, 24 - bl GetFrontierEnemyMonLevel + bl GetFacilityEnemyMonLevel movs r0, 0xFA lsls r0, 1 cmp r4, r0 @@ -962,7 +962,7 @@ sub_81627A4: @ 81627A4 lsls r0, 16 lsrs r4, r0, 16 adds r5, r4, 0 - bl GetFrontierEnemyMonLevel + bl GetFacilityEnemyMonLevel movs r0, 0xFA lsls r0, 1 cmp r4, r0 @@ -1335,7 +1335,7 @@ GetFrontierTrainerFrontSpriteId: @ 8162AA0 lsls r0, 16 lsrs r4, r0, 16 adds r5, r4, 0 - bl GetFrontierEnemyMonLevel + bl GetFacilityEnemyMonLevel movs r0, 0xFA lsls r0, 1 cmp r4, r0 @@ -1462,7 +1462,7 @@ GetFrontierOpponentClass: @ 8162BD8 lsls r0, 16 lsrs r4, r0, 16 adds r5, r4, 0 - bl GetFrontierEnemyMonLevel + bl GetFacilityEnemyMonLevel movs r0, 0xFA lsls r0, 1 cmp r4, r0 @@ -1602,7 +1602,7 @@ sub_8162D34: @ 8162D34 lsls r0, 16 lsrs r4, r0, 16 adds r5, r4, 0 - bl GetFrontierEnemyMonLevel + bl GetFacilityEnemyMonLevel movs r0, 0xFA lsls r0, 1 cmp r4, r0 @@ -1704,7 +1704,7 @@ GetFrontierTrainerName: @ 8162E20 lsls r1, 16 lsrs r5, r1, 16 movs r4, 0 - bl GetFrontierEnemyMonLevel + bl GetFacilityEnemyMonLevel movs r0, 0xFA lsls r0, 1 cmp r5, r0 @@ -1854,7 +1854,7 @@ sub_8162F68: @ 8162F68 lsls r0, 16 lsrs r4, r0, 16 adds r5, r4, 0 - bl GetFrontierEnemyMonLevel + bl GetFacilityEnemyMonLevel movs r0, 0xFA lsls r0, 1 cmp r4, r0 @@ -2025,7 +2025,7 @@ sub_81630C4: @ 81630C4 add r4, sp, 0x14 movs r0, 0xFF strb r0, [r4] - bl GetFrontierEnemyMonLevel + bl GetFacilityEnemyMonLevel lsls r0, 24 lsrs r0, 24 str r0, [sp, 0x20] @@ -2551,7 +2551,7 @@ RandomizeFacilityTrainerMonId: @ 8163524 adds r4, r0, 0 lsls r4, 16 lsrs r4, 16 - bl GetFrontierEnemyMonLevel + bl GetFacilityEnemyMonLevel lsls r0, 24 lsrs r6, r0, 24 ldr r0, =gFacilityTrainers @@ -2728,7 +2728,7 @@ _081636A4: movs r0, 0x1F _081636A6: str r0, [sp, 0x18] - bl GetFrontierEnemyMonLevel + bl GetFacilityEnemyMonLevel lsls r0, 24 lsrs r0, 24 str r0, [sp, 0x14] @@ -3029,7 +3029,7 @@ _0816390A: thumb_func_start sub_8163914 sub_8163914: @ 8163914 push {lr} - bl GetFrontierEnemyMonLevel + bl GetFacilityEnemyMonLevel ldr r0, =gSpecialVar_0x8005 ldrh r0, [r0] cmp r0, 0 @@ -3979,7 +3979,7 @@ _081641E6: lsls r0, r1, 24 lsrs r0, 24 str r2, [sp, 0x18] - bl BattleFrontierGetOpponentLvl + bl GetFrontierEnemyMonLevel ldrb r1, [r4] lsls r0, 24 lsrs r0, 24 @@ -4091,7 +4091,7 @@ sub_81642A0: @ 81642A0 movs r2, 0 bl GetMonData str r0, [sp, 0x20] - bl GetFrontierEnemyMonLevel + bl GetFacilityEnemyMonLevel movs r7, 0 ldr r0, [sp, 0x18] lsls r0, 24 @@ -4464,7 +4464,7 @@ _081645B8: lsls r0, r1, 24 lsrs r0, 24 str r3, [sp, 0x48] - bl BattleFrontierGetOpponentLvl + bl GetFrontierEnemyMonLevel ldrb r1, [r4] lsls r0, 24 lsrs r0, 24 @@ -4556,7 +4556,7 @@ sub_81646BC: @ 81646BC movs r0, 0 mov r9, r0 mov r10, r0 - bl GetFrontierEnemyMonLevel + bl GetFacilityEnemyMonLevel movs r0, 0xFA lsls r0, 1 cmp r5, r0 @@ -4705,7 +4705,7 @@ sub_8164828: @ 8164828 mov r5, r8 push {r5-r7} sub sp, 0x8 - bl GetFrontierEnemyMonLevel + bl GetFacilityEnemyMonLevel bl sub_81A39C4 lsls r0, 16 lsrs r0, 16 @@ -6073,7 +6073,7 @@ sub_8165404: @ 8165404 sub sp, 0x70 lsls r0, 16 lsrs r7, r0, 16 - bl GetFrontierEnemyMonLevel + bl GetFacilityEnemyMonLevel ldr r0, =0x00000c03 cmp r7, r0 beq _08165420 @@ -6228,7 +6228,7 @@ _08165564: bls _0816556C b _081656E8 _0816556C: - bl GetFrontierEnemyMonLevel + bl GetFacilityEnemyMonLevel lsls r0, 24 lsrs r0, 24 str r0, [sp, 0x50] @@ -7083,8 +7083,8 @@ _08165C2A: .pool thumb_func_end sub_8165B88 - thumb_func_start GetFrontierEnemyMonLevel -GetFrontierEnemyMonLevel: @ 8165C40 + thumb_func_start GetFacilityEnemyMonLevel +GetFacilityEnemyMonLevel: @ 8165C40 push {lr} ldr r0, =gSaveBlock2Ptr ldr r0, [r0] @@ -7104,20 +7104,20 @@ GetFrontierEnemyMonLevel: @ 8165C40 ldrb r0, [r2] lsls r0, 30 lsrs r0, 30 - bl BattleFrontierGetOpponentLvl + bl GetFrontierEnemyMonLevel b _08165C88 .pool _08165C84: - bl sub_8165D78 + bl GetTentEnemyMonLevel _08165C88: lsls r0, 24 lsrs r0, 24 pop {r1} bx r1 - thumb_func_end GetFrontierEnemyMonLevel + thumb_func_end GetFacilityEnemyMonLevel - thumb_func_start BattleFrontierGetOpponentLvl -BattleFrontierGetOpponentLvl: @ 8165C90 + thumb_func_start GetFrontierEnemyMonLevel +GetFrontierEnemyMonLevel: @ 8165C90 push {lr} lsls r0, 24 lsrs r0, 24 @@ -7138,7 +7138,7 @@ _08165CA2: _08165CB0: pop {r1} bx r1 - thumb_func_end BattleFrontierGetOpponentLvl + thumb_func_end GetFrontierEnemyMonLevel thumb_func_start sub_8165CB4 sub_8165CB4: @ 8165CB4 @@ -7246,8 +7246,8 @@ _08165D72: bx r1 thumb_func_end sub_8165D40 - thumb_func_start sub_8165D78 -sub_8165D78: @ 8165D78 + thumb_func_start GetTentEnemyMonLevel +GetTentEnemyMonLevel: @ 8165D78 push {lr} ldr r0, =0x000040cf bl VarGet @@ -7300,7 +7300,7 @@ _08165E02: pop {r1} bx r1 .pool - thumb_func_end sub_8165D78 + thumb_func_end GetTentEnemyMonLevel thumb_func_start sub_8165E18 sub_8165E18: @ 8165E18 @@ -7384,7 +7384,7 @@ sub_8165EA4: @ 8165EA4 lsls r2, 24 lsrs r2, 24 str r2, [sp, 0x1C] - bl sub_8165D78 + bl GetTentEnemyMonLevel lsls r0, 24 lsrs r0, 24 str r0, [sp, 0x20] @@ -7756,7 +7756,7 @@ sub_8166188: @ 8166188 ands r0, r1 cmp r0, 0 beq _081661E8 - bl GetFrontierEnemyMonLevel + bl GetFacilityEnemyMonLevel lsls r0, 24 movs r5, 0 ldr r7, =gBaseStats diff --git a/include/battle_tower.h b/include/battle_tower.h index 87581074e..d7ff70006 100644 --- a/include/battle_tower.h +++ b/include/battle_tower.h @@ -32,7 +32,17 @@ struct BattleFrontierTrainer u16 *btMonPool; }; +struct FacilityMon +{ + u16 species; + u16 moves[4]; + u8 itemTableId; + u8 evSpread; + u8 nature; +}; + extern const struct BattleFrontierTrainer *gFacilityTrainers; +extern const struct FacilityMon *gFacilityTrainerMons; u16 sub_8164FCC(u8, u8); void sub_81659DC(struct RSBattleTowerRecord *a0, struct RSBattleTowerRecord *a1); diff --git a/include/global.h b/include/global.h index bb843bddd..ab31e3c5d 100644 --- a/include/global.h +++ b/include/global.h @@ -337,6 +337,12 @@ struct FrontierMonData u8 nature; }; +struct Struct_field_E70 +{ + u16 monId; + u8 unk2[9]; +}; + struct BattleDomeTrainer { u16 trainerId:10; @@ -398,10 +404,8 @@ struct BattleFrontier /*0xD24*/ struct BattleDomeTrainer domeTrainers[DOME_TOURNAMENT_TRAINERS_COUNT]; /*0xD64*/ u16 domeMonId[DOME_TOURNAMENT_TRAINERS_COUNT][3]; /*0xD64*/ u16 field_DC4[2]; - /*0xDC8*/ u16 field_DC8[2]; - /*0xDCC*/ u8 filler_DCC[4]; - /*0xDD0*/ u16 field_DD0[2]; - /*0xDD4*/ u16 field_DD4[2]; + /*0xDC8*/ u16 field_DC8[2][2]; + /*0xDD0*/ u16 field_DD0[2][2]; /*0xDD8*/ u16 field_DD8; /*0xDDA*/ u16 field_DDA[2]; /*0xDDE*/ u16 field_DDE[2]; @@ -429,7 +433,7 @@ struct BattleFrontier /*0xE6A*/ u16 field_E6A; /*0xE6C*/ u16 field_E6C; /*0xE6E*/ u16 field_E6E; - /*0xE70*/ u8 field_E70[72]; + /*0xE70*/ struct Struct_field_E70 field_E70[6]; /*0xEB8*/ u16 frontierBattlePoints; /*0xEBA*/ u8 field_EBA; /*0xEBB*/ u8 field_EBB; diff --git a/ld_script.txt b/ld_script.txt index e2c0151ad..c06b410f1 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -243,6 +243,7 @@ SECTIONS { src/trainer_pokemon_sprites.o(.text); src/lilycove_lady.o(.text); src/battle_dome.o(.text); + src/battle_frontier_1.o(.text); asm/battle_frontier_1.o(.text); src/menu.o(.text); asm/battle_frontier_2.o(.text); diff --git a/src/battle_dome.c b/src/battle_dome.c index 058d253ab..c54b14ccc 100644 --- a/src/battle_dome.c +++ b/src/battle_dome.c @@ -39,15 +39,6 @@ #define DOME_FINAL 3 #define DOME_ROUNDS_COUNT 4 -struct FacilityMon -{ - u16 species; - u16 moves[4]; - u8 itemTableId; - u8 evSpread; - u8 nature; -}; - struct BattleDomeStruct { u8 arr[DOME_TOURNAMENT_TRAINERS_COUNT]; @@ -66,7 +57,7 @@ extern void sub_81B8558(void); extern u32 sub_81A39C4(void); extern u16 sub_8162548(u8, u8); extern u16 RandomizeFacilityTrainerMonId(u16); -extern u8 GetFrontierEnemyMonLevel(void); +extern u8 GetFacilityEnemyMonLevel(void); extern u16 sub_81A5060(u8 monId, u8 moveSlotId); extern u8 sub_81A50F0(u8, u8); extern u8 sub_81A50B0(u8); @@ -87,7 +78,6 @@ extern u16 gBattle_BG2_X; extern u16 gBattle_BG2_Y; extern u16 gBattle_BG3_X; extern u16 gBattle_BG3_Y; -extern const struct FacilityMon *gFacilityTrainerMons; extern void (* const gUnknown_0860D090[])(void); extern const u32 gUnknown_0860D0EC[][2]; @@ -822,7 +812,7 @@ void InitDomeTrainers(void) monTypesBits >>= 1; } - monLevel = GetFrontierEnemyMonLevel(); + monLevel = GetFacilityEnemyMonLevel(); statSums[0] += (monTypesCount * monLevel) / 20; for (i = 1; i < DOME_TOURNAMENT_TRAINERS_COUNT; i++) @@ -995,7 +985,7 @@ static void CreateDomeMon(u8 monPartyId, u16 tournamentTrainerId, u8 tournamentM s32 i; u8 happiness = 0xFF; u8 fixedIv = GetDomeTrainerMonIvs(tournamentTrainerId); // BUG: Should be using trainerId instead of tournamentTrainerId. As a result, all Pokemon have ivs of 3. - u8 level = GetFrontierEnemyMonLevel(); + u8 level = GetFacilityEnemyMonLevel(); CreateMonWithEVSpreadPersonalityOTID(&gEnemyParty[monPartyId], gFacilityTrainerMons[gSaveBlock2Ptr->frontier.domeMonId[tournamentTrainerId][tournamentMonId]].species, level, @@ -3716,7 +3706,7 @@ static u16 GetWinningMove(s32 winnerTournamentId, s32 loserTournamentId, u8 roun u16 bestScore = 0; u16 bestId = 0; s32 movePower = 0; - GetFrontierEnemyMonLevel(); // Unused return variable. + GetFacilityEnemyMonLevel(); // Unused return variable. // Calc move points of all 4 moves for all 3 pokemon hitting all 3 target mons. for (i = 0; i < 3; i++) @@ -4580,7 +4570,7 @@ static void DecideRoundWinners(u8 roundId) static void CopyDomeTrainerName(u8 *dst, u16 trainerId) { s32 i = 0; - GetFrontierEnemyMonLevel(); // Unused return value. + GetFacilityEnemyMonLevel(); // Unused return value. if (trainerId == TRAINER_FRONTIER_BRAIN) { diff --git a/src/battle_frontier_1.c b/src/battle_frontier_1.c new file mode 100644 index 000000000..ee8a42954 --- /dev/null +++ b/src/battle_frontier_1.c @@ -0,0 +1,118 @@ +#include "global.h" +#include "event_data.h" +#include "battle_setup.h" +#include "overworld.h" +#include "random.h" +#include "battle_tower.h" + +extern void sub_8162614(u16, u8); + +extern void (* const gUnknown_0860DE50[])(void); +extern const u32 gUnknown_0860DE98[][2]; +extern const u32 gUnknown_0860DEA8[][2]; + +// code +void sub_8195960(void) +{ + gUnknown_0860DE50[gSpecialVar_0x8004](); +} + +void sub_8195980(void) +{ + u32 lvlMode = gSaveBlock2Ptr->frontier.lvlMode; + u32 battleMode = VarGet(VAR_FRONTIER_BATTLE_MODE); + + gSaveBlock2Ptr->frontier.field_CA8 = 0; + gSaveBlock2Ptr->frontier.field_CB2 = 0; + gSaveBlock2Ptr->frontier.field_CA9_a = 0; + gSaveBlock2Ptr->frontier.field_CA9_b = 0; + if (!(gSaveBlock2Ptr->frontier.field_CDC & gUnknown_0860DE98[battleMode][lvlMode])) + gSaveBlock2Ptr->frontier.field_DC8[battleMode][lvlMode] = 0; + + saved_warp2_set(0, gSaveBlock1Ptr->location.mapGroup, gSaveBlock1Ptr->location.mapNum, -1); + gTrainerBattleOpponent_A = 0; +} + +void sub_8195A38(void) +{ + u32 lvlMode = gSaveBlock2Ptr->frontier.lvlMode; + u32 battleMode = VarGet(VAR_FRONTIER_BATTLE_MODE); + + switch (gSpecialVar_0x8005) + { + case 0: + gSpecialVar_Result = gSaveBlock2Ptr->frontier.field_DC4[1]; + break; + case 1: + gSpecialVar_Result = gSaveBlock2Ptr->frontier.field_DC8[battleMode][lvlMode]; + break; + case 2: + gSpecialVar_Result = ((gSaveBlock2Ptr->frontier.field_CDC & gUnknown_0860DE98[battleMode][lvlMode]) != 0); + break; + } +} + +void sub_8195AE4(void) +{ + u32 lvlMode = gSaveBlock2Ptr->frontier.lvlMode; + u32 battleMode = VarGet(VAR_FRONTIER_BATTLE_MODE); + + switch (gSpecialVar_0x8005) + { + case 0: + gSaveBlock2Ptr->frontier.field_DC4[1] = gSpecialVar_0x8006; + break; + case 1: + gSaveBlock2Ptr->frontier.field_DC8[battleMode][lvlMode] = gSpecialVar_0x8006; + break; + case 2: + if (gSpecialVar_0x8006) + gSaveBlock2Ptr->frontier.field_CDC |= gUnknown_0860DE98[battleMode][lvlMode]; + else + gSaveBlock2Ptr->frontier.field_CDC &= gUnknown_0860DEA8[battleMode][lvlMode]; + break; + } +} + +void sub_8195BB0(void) +{ + u32 battleMode = VarGet(VAR_FRONTIER_BATTLE_MODE); + u32 lvlMode = gSaveBlock2Ptr->frontier.lvlMode; + + if (gSaveBlock2Ptr->frontier.field_DC8[battleMode][lvlMode] < 50) + gSpecialVar_Result = Random() % 3; + else if (gSaveBlock2Ptr->frontier.field_DC8[battleMode][lvlMode] < 99) + gSpecialVar_Result = 3; + else + gSpecialVar_Result = 4; +} + +void sub_8195C20(void) +{ + gTrainerBattleOpponent_A = 5 *(Random() % 255) / 64u; + sub_8162614(gTrainerBattleOpponent_A, 0); +} + +void sub_8195C50(void) +{ + if (gTrainerBattleOpponent_A < 300) + ConvertBattleFrontierTrainerSpeechToString(gFacilityTrainers[gTrainerBattleOpponent_A].speechBefore); +} + +/* +void sub_8195C7C(void) +{ + u8 lvlMode = gSaveBlock2Ptr->frontier.lvlMode; + u8 battleMode = VarGet(VAR_FRONTIER_BATTLE_MODE); + + if (gSaveBlock2Ptr->frontier.field_DC8[battleMode][lvlMode] < 9999) + { + u16 wat = 0; + gSaveBlock2Ptr->frontier.field_DC8[battleMode][lvlMode]++; + if (lvlMode < gSaveBlock2Ptr->frontier.field_DD0[battleMode][lvlMode]) + wat = 1; + if (gSaveBlock2Ptr->frontier.field_DC8[battleMode][wat] != 0) + gSaveBlock2Ptr->frontier.field_DD0[battleMode][lvlMode] = gSaveBlock2Ptr->frontier.field_DC8[battleMode][lvlMode]; + } +} +*/ diff --git a/src/battle_tent.c b/src/battle_tent.c index dbea37fb7..f39bf8837 100644 --- a/src/battle_tent.c +++ b/src/battle_tent.c @@ -11,6 +11,10 @@ #include "constants/items.h" #include "constants/region_map_sections.h" +extern const struct BattleFrontierTrainer gSlateportBattleTentTrainers[]; +extern const struct FacilityMon gSlateportBattleTentMons[]; +extern const u16 gBattleFrontierHeldItems[]; + // This file's functions. void sub_81B99D4(void); void sub_81B9A28(void); @@ -51,7 +55,7 @@ void (*const gUnknown_086160B4[])(void) = sub_81B9B28 }; -const u16 gUnknown_086160D4[] = {ITEM_NEST_BALL, ITEM_NONE}; +static const u16 sVerdanturfTentRewards[] = {ITEM_NEST_BALL}; void (*const gUnknown_086160D8[])(void) = { @@ -64,7 +68,7 @@ void (*const gUnknown_086160D8[])(void) = sub_81B9CF0 }; -const u16 gUnknown_086160F4[] = {ITEM_HYPER_POTION, ITEM_NONE}; +static const u16 sFallarborTentRewards[] = {ITEM_HYPER_POTION}; void (*const gUnknown_086160F8[])(void) = { @@ -80,7 +84,7 @@ void (*const gUnknown_086160F8[])(void) = sub_81B9EC0 }; -const u16 gUnknown_08616120[] = {ITEM_FULL_HEAL, ITEM_NONE}; +static const u16 sSlateportTentRewards[] = {ITEM_FULL_HEAL}; // code void sub_81B99B4(void) @@ -128,7 +132,7 @@ void sub_81B9ABC(void) void sub_81B9B00(void) { - gSaveBlock2Ptr->frontier.field_E6A = gUnknown_086160D4[Random() % 1]; + gSaveBlock2Ptr->frontier.field_E6A = sVerdanturfTentRewards[Random() % ARRAY_COUNT(sVerdanturfTentRewards)]; } void sub_81B9B28(void) @@ -178,7 +182,7 @@ void sub_81B9C2C(void) void sub_81B9C70(void) { - gSaveBlock2Ptr->frontier.field_E6C = gUnknown_086160F4[Random() % 1]; + gSaveBlock2Ptr->frontier.field_E6C = sFallarborTentRewards[Random() % ARRAY_COUNT(sFallarborTentRewards)]; } void sub_81B9C98(void) @@ -233,7 +237,7 @@ void sub_81B9DB4(void) void sub_81B9DF8(void) { - gSaveBlock2Ptr->frontier.field_E6E = gUnknown_08616120[Random() % 1]; + gSaveBlock2Ptr->frontier.field_E6E = sSlateportTentRewards[Random() % ARRAY_COUNT(sSlateportTentRewards)]; } void sub_81B9E20(void) @@ -266,3 +270,70 @@ bool8 sub_81B9E94(void) return (gMapHeader.regionMapSectionId == MAPSEC_SLATEPORT_CITY && ((gMapHeader.mapLayoutId == 385) | (gMapHeader.mapLayoutId == 386))); } + +// This function was written very...oddly. +/* +void sub_81B9EC0(void) +{ + s32 i, j; + u16 currMonId, currSpecies; + u16 species[PARTY_SIZE]; + u16 monIds[PARTY_SIZE]; + u16 heldItems[PARTY_SIZE]; + s32 var; + + gFacilityTrainers = gSlateportBattleTentTrainers; + for (i = 0; i < PARTY_SIZE; i++) + { + species[i] = 0; + monIds[i] = 0; + heldItems[i] = 0; + } + gFacilityTrainerMons = gSlateportBattleTentMons; + + currSpecies = 0; + i = 0; + while (i != PARTY_SIZE) + { + // Cannot have two pokemon of the same species. + currMonId = Random() % 70; + j = 0; + var = 0 + i; + while (j < var && monIds[j] != currMonId) + { + if (species[j] == gFacilityTrainerMons[currMonId].species) + { + if (currSpecies == 0) + currSpecies = gFacilityTrainerMons[currMonId].species; + else + break; + } + j++; + } + if (j != var) + continue; + + // Cannot have two same held items. + for (j = 0; j < var; j++) + { + if (heldItems[j] == 0) + continue; + if (heldItems[j] == gBattleFrontierHeldItems[gFacilityTrainerMons[currMonId].itemTableId]) + { + if (gFacilityTrainerMons[currMonId].species == currSpecies) + currSpecies = 0; + else + break; + } + } + if (j != var) + continue; + + gSaveBlock2Ptr->frontier.field_E70[var].monId = currMonId; + species[var] = gFacilityTrainerMons[currMonId].species; + heldItems[var] = gBattleFrontierHeldItems[gFacilityTrainerMons[currMonId].itemTableId]; + monIds[var] = currMonId; + i++; + } +} +*/ diff --git a/src/field_specials.c b/src/field_specials.c index f5728c3a4..84852e6b5 100644 --- a/src/field_specials.c +++ b/src/field_specials.c @@ -2188,13 +2188,13 @@ void sub_8139F20(void) } break; case 6: - if (gSaveBlock2Ptr->frontier.field_DC8[0] >= gSaveBlock2Ptr->frontier.field_DC8[1]) + if (gSaveBlock2Ptr->frontier.field_DC8[0][0] >= gSaveBlock2Ptr->frontier.field_DC8[0][1]) { - unk = gSaveBlock2Ptr->frontier.field_DC8[0]; + unk = gSaveBlock2Ptr->frontier.field_DC8[0][0]; } else { - unk = gSaveBlock2Ptr->frontier.field_DC8[1]; + unk = gSaveBlock2Ptr->frontier.field_DC8[0][1]; } break; case 7: diff --git a/src/pokemon.c b/src/pokemon.c index eafb0c2cd..9022f69ea 100644 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -81,8 +81,7 @@ extern void set_unknown_box_id(u8); extern void sub_803FA70(u8 battlerId); extern u8 sav1_map_get_name(void); extern const u8 *sub_81A1650(u8, u8 language); -extern u8 BattleFrontierGetOpponentLvl(u8); -extern u16 FacilityClassToPicIndex(u16); +extern u8 GetFrontierEnemyMonLevel(u8); extern bool8 InBattlePyramid(void); extern bool8 InBattlePike(void); extern bool8 sub_806F104(void); @@ -956,7 +955,7 @@ const u16 gHoennToNationalOrder[] = // Assigns Hoenn Dex Pokémon (Using Nationa NATIONAL_DEX_BLAZIKEN, // HOENN_DEX_BLAZIKEN NATIONAL_DEX_MUDKIP, // HOENN_DEX_MUDKIP NATIONAL_DEX_MARSHTOMP, // HOENN_DEX_MARSHTOMP - NATIONAL_DEX_SWAMPERT, // HOENN_DEX_SWAMPERT + NATIONAL_DEX_SWAMPERT, // HOENN_DEX_SWAMPERT NATIONAL_DEX_POOCHYENA, // HOENN_DEX_POOCHYENA NATIONAL_DEX_MIGHTYENA, // HOENN_DEX_MIGHTYENA NATIONAL_DEX_ZIGZAGOON, // HOENN_DEX_ZIGZAGOON @@ -2821,7 +2820,7 @@ void sub_8068338(struct Pokemon *mon, struct UnknownPokemonStruct *src, bool8 lv u8 value; if (gSaveBlock2Ptr->frontier.lvlMode != FRONTIER_LVL_50) - level = BattleFrontierGetOpponentLvl(gSaveBlock2Ptr->frontier.lvlMode); + level = GetFrontierEnemyMonLevel(gSaveBlock2Ptr->frontier.lvlMode); else if (lvl50) level = 50; else @@ -2885,7 +2884,7 @@ void sub_8068528(struct Pokemon *mon, const struct UnknownPokemonStruct2 *src, u CreateMon(mon, src->mons[monId].species, - BattleFrontierGetOpponentLvl(src->field_0_1 - 1), + GetFrontierEnemyMonLevel(src->field_0_1 - 1), 0x1F, TRUE, personality, diff --git a/src/unk_text_util_2.c b/src/unk_text_util_2.c index ca8246128..4821ed776 100644 --- a/src/unk_text_util_2.c +++ b/src/unk_text_util_2.c @@ -4,6 +4,7 @@ #include "text.h" #include "sound.h" +ALIGNED(4) static const u8 sUnknown_08616124[] = {1, 2, 4}; static const u16 sFont6BrailleGlyphs[] = INCBIN_U16("data/graphics/fonts/font6.fwjpnfont");