diff --git a/asm/secret_base.s b/asm/secret_base.s index 80cf3e37a..4027dda1a 100644 --- a/asm/secret_base.s +++ b/asm/secret_base.s @@ -5,127 +5,6 @@ .text - thumb_func_start sub_80EA250 -sub_80EA250: @ 80EA250 - push {lr} - ldr r0, =0x00004054 - bl VarGet - lsls r0, 24 - lsrs r0, 24 - bl sub_80EA20C - lsls r0, 24 - lsrs r0, 24 - adds r1, r0, 0 - cmp r0, 0 - bne _080EA278 - ldr r0, =gUnknown_08274966 - b _080EA2DA - .pool -_080EA278: - cmp r0, 0x1 - bne _080EA284 - ldr r0, =gUnknown_08274D13 - b _080EA2DA - .pool -_080EA284: - cmp r0, 0x2 - bne _080EA290 - ldr r0, =gUnknown_08274FFE - b _080EA2DA - .pool -_080EA290: - cmp r0, 0x3 - bne _080EA29C - ldr r0, =gUnknown_08275367 - b _080EA2DA - .pool -_080EA29C: - cmp r0, 0x4 - bne _080EA2A8 - ldr r0, =gUnknown_082756C7 - b _080EA2DA - .pool -_080EA2A8: - cmp r0, 0x5 - bne _080EA2B4 - ldr r0, =gUnknown_08274B24 - b _080EA2DA - .pool -_080EA2B4: - cmp r0, 0x6 - bne _080EA2C0 - ldr r0, =gUnknown_08274E75 - b _080EA2DA - .pool -_080EA2C0: - cmp r0, 0x7 - bne _080EA2CC - ldr r0, =gUnknown_082751E1 - b _080EA2DA - .pool -_080EA2CC: - cmp r1, 0x8 - beq _080EA2D8 - ldr r0, =gUnknown_082758CC - b _080EA2DA - .pool -_080EA2D8: - ldr r0, =gUnknown_082754F6 -_080EA2DA: - pop {r1} - bx r1 - .pool - thumb_func_end sub_80EA250 - - thumb_func_start sub_80EA2E4 -sub_80EA2E4: @ 80EA2E4 - push {lr} - movs r0, 0x1 - bl sub_813BADC - ldr r1, =gTrainerBattleOpponent_A - movs r2, 0x80 - lsls r2, 3 - adds r0, r2, 0 - strh r0, [r1] - ldr r1, =gBattleTypeFlags - ldr r0, =0x08000008 - str r0, [r1] - pop {r0} - bx r0 - .pool - thumb_func_end sub_80EA2E4 - - thumb_func_start sub_80EA30C -sub_80EA30C: @ 80EA30C - push {lr} - ldr r0, =0x00004054 - bl VarGet - ldr r1, =gSaveBlock1Ptr - ldr r3, [r1] - lsls r0, 16 - lsrs r0, 16 - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 5 - adds r3, r1 - ldr r0, =gScriptResult - ldrb r0, [r0] - ldr r1, =0x00001a9d - adds r3, r1 - movs r1, 0x1 - ands r1, r0 - lsls r1, 5 - ldrb r2, [r3] - movs r0, 0x21 - negs r0, r0 - ands r0, r2 - orrs r0, r1 - strb r0, [r3] - pop {r0} - bx r0 - .pool - thumb_func_end sub_80EA30C - thumb_func_start sub_80EA354 sub_80EA354: @ 80EA354 push {r4-r7,lr} diff --git a/include/battle.h b/include/battle.h index 3328c691f..4278d0a62 100644 --- a/include/battle.h +++ b/include/battle.h @@ -987,5 +987,6 @@ extern u8 gBattleOutcome; extern u16 gLastUsedItem; extern u32 gBattleTypeFlags; extern struct MonSpritesGfx* gMonSpritesGfxPtr; +extern u16 gTrainerBattleOpponent_A; #endif // GUARD_BATTLE_H diff --git a/include/event_scripts.h b/include/event_scripts.h index 259e463c8..f85118e00 100755 --- a/include/event_scripts.h +++ b/include/event_scripts.h @@ -362,4 +362,14 @@ extern const u8 gPokeNewsTextLilycove_Ending[]; extern const u8 gPokeNewsTextBlendMaster_Upcoming[]; extern const u8 gPokeNewsTextBlendMaster_Ongoing[]; extern const u8 gPokeNewsTextBlendMaster_Ending[]; +extern const u8 gUnknown_08274966[]; +extern const u8 gUnknown_08274D13[]; +extern const u8 gUnknown_08274FFE[]; +extern const u8 gUnknown_08275367[]; +extern const u8 gUnknown_082756C7[]; +extern const u8 gUnknown_08274B24[]; +extern const u8 gUnknown_08274E75[]; +extern const u8 gUnknown_082751E1[]; +extern const u8 gUnknown_082754F6[]; +extern const u8 gUnknown_082758CC[]; #endif //GUARD_EVENT_SCRIPTS_H diff --git a/include/rom6.h b/include/rom6.h index 0e9927855..a6aab998c 100644 --- a/include/rom6.h +++ b/include/rom6.h @@ -3,5 +3,6 @@ void sub_81357FC(u8, void(void)); u8 GetLeadMonIndex(void); +void sub_813BADC(bool8); #endif //GUARD_ROM6_H diff --git a/src/secret_base.c b/src/secret_base.c index a18dbbb0b..68a663cfe 100644 --- a/src/secret_base.c +++ b/src/secret_base.c @@ -29,6 +29,8 @@ #include "strings.h" #include "international_string_util.h" #include "event_data.h" +#include "battle.h" +#include "rom6.h" #include "decoration.h" #include "decoration_inventory.h" #include "secret_base.h" @@ -1211,3 +1213,59 @@ u8 sub_80EA20C(u8 sbId) { return (gSaveBlock1Ptr->secretBases[sbId].trainerId[0] % 5) + (gSaveBlock1Ptr->secretBases[sbId].gender * 5); } + +const u8 *sub_80EA250(void) +{ + u8 param; + + param = sub_80EA20C(VarGet(VAR_0x4054)); + if (param == 0) + { + return gUnknown_08274966; + } + if (param == 1) + { + return gUnknown_08274D13; + } + if (param == 2) + { + return gUnknown_08274FFE; + } + if (param == 3) + { + return gUnknown_08275367; + } + if (param == 4) + { + return gUnknown_082756C7; + } + if (param == 5) + { + return gUnknown_08274B24; + } + if (param == 6) + { + return gUnknown_08274E75; + } + if (param == 7) + { + return gUnknown_082751E1; + } + if (param == 8) + { + return gUnknown_082754F6; + } + return gUnknown_082758CC; +} + +void sub_80EA2E4(void) +{ + sub_813BADC(TRUE); + gTrainerBattleOpponent_A = 0x400; + gBattleTypeFlags = BATTLE_TYPE_TRAINER | BATTLE_TYPE_SECRET_BASE; +} + +void sub_80EA30C(void) +{ + gSaveBlock1Ptr->secretBases[VarGet(VAR_0x4054)].sbr_field_1_5 = gScriptResult; +}