diff options
-rw-r--r-- | asm/post_battle_event_funcs.s | 131 | ||||
-rw-r--r-- | data/specials.inc | 2 | ||||
-rw-r--r-- | include/rom4.h | 4 | ||||
-rw-r--r-- | ld_script.txt | 2 | ||||
-rw-r--r-- | src/post_battle_event_funcs.c | 70 |
5 files changed, 74 insertions, 135 deletions
diff --git a/asm/post_battle_event_funcs.s b/asm/post_battle_event_funcs.s deleted file mode 100644 index 8161203bb..000000000 --- a/asm/post_battle_event_funcs.s +++ /dev/null @@ -1,131 +0,0 @@ - .include "constants/gba_constants.inc" - .include "constants/species_constants.inc" - .include "asm/macros.inc" - - .syntax unified - - .text - - thumb_func_start sub_810D180 -sub_810D180: @ 810D180 - push {r4-r7,lr} - sub sp, 0x4 - bl HealPlayerParty - ldr r4, _0810D1A0 @ =0x00000804 - adds r0, r4, 0 - bl FlagGet - lsls r0, 24 - lsrs r1, r0, 24 - cmp r1, 0x1 - bne _0810D1A8 - ldr r0, _0810D1A4 @ =gUnknown_02039324 - strb r1, [r0] - b _0810D1B4 - .align 2, 0 -_0810D1A0: .4byte 0x00000804 -_0810D1A4: .4byte gUnknown_02039324 -_0810D1A8: - ldr r1, _0810D1E8 @ =gUnknown_02039324 - movs r0, 0 - strb r0, [r1] - adds r0, r4, 0 - bl FlagSet -_0810D1B4: - movs r0, 0x1 - bl GetGameStat - cmp r0, 0 - bne _0810D1D4 - ldr r2, _0810D1EC @ =gSaveBlock2 - ldrh r1, [r2, 0xE] - lsls r1, 16 - ldrb r0, [r2, 0x10] - lsls r0, 8 - orrs r1, r0 - ldrb r0, [r2, 0x11] - orrs r1, r0 - movs r0, 0x1 - bl SetGameStat -_0810D1D4: - bl SetSecretBase2Field_9 - ldr r0, _0810D1EC @ =gSaveBlock2 - ldrb r0, [r0, 0x8] - cmp r0, 0 - bne _0810D1F0 - movs r0, 0x1 - bl sub_80537CC - b _0810D1F6 - .align 2, 0 -_0810D1E8: .4byte gUnknown_02039324 -_0810D1EC: .4byte gSaveBlock2 -_0810D1F0: - movs r0, 0x2 - bl sub_80537CC -_0810D1F6: - movs r6, 0 - movs r5, 0 - mov r7, sp -_0810D1FC: - movs r0, 0x64 - adds r1, r5, 0 - muls r1, r0 - ldr r0, _0810D260 @ =gPlayerParty - adds r4, r1, r0 - adds r0, r4, 0 - movs r1, 0x5 - bl GetMonData - cmp r0, 0 - beq _0810D23A - adds r0, r4, 0 - movs r1, 0x6 - bl GetMonData - cmp r0, 0 - bne _0810D23A - adds r0, r4, 0 - movs r1, 0x43 - bl GetMonData - cmp r0, 0 - bne _0810D23A - movs r0, 0x1 - strb r0, [r7] - adds r0, r4, 0 - movs r1, 0x43 - mov r2, sp - bl SetMonData - movs r6, 0x1 -_0810D23A: - adds r5, 0x1 - cmp r5, 0x5 - ble _0810D1FC - cmp r6, 0x1 - bne _0810D250 - movs r0, 0x2A - bl IncrementGameStat - ldr r0, _0810D264 @ =0x0000083b - bl FlagSet -_0810D250: - ldr r0, _0810D268 @ =sub_8141F90 - bl SetMainCallback2 - movs r0, 0 - add sp, 0x4 - pop {r4-r7} - pop {r1} - bx r1 - .align 2, 0 -_0810D260: .4byte gPlayerParty -_0810D264: .4byte 0x0000083b -_0810D268: .4byte sub_8141F90 - thumb_func_end sub_810D180 - - thumb_func_start sp0C8_whiteout_maybe -sp0C8_whiteout_maybe: @ 810D26C - push {lr} - ldr r0, _0810D27C @ =CB2_WhiteOut - bl SetMainCallback2 - movs r0, 0 - pop {r1} - bx r1 - .align 2, 0 -_0810D27C: .4byte CB2_WhiteOut - thumb_func_end sp0C8_whiteout_maybe - - .align 2, 0 @ Don't pad with nop. diff --git a/data/specials.inc b/data/specials.inc index a955fe3eb..11572e1f3 100644 --- a/data/specials.inc +++ b/data/specials.inc @@ -272,7 +272,7 @@ gSpecials:: .4byte CheckLeadMonTough .4byte sub_80C7958 .4byte DoSoftReset - .4byte sub_810D180 + .4byte GameClear .4byte sub_810EBEC .4byte ShowGlassWorkshopMenu .4byte SpawnCameraDummy diff --git a/include/rom4.h b/include/rom4.h index 5aae277a6..f78386213 100644 --- a/include/rom4.h +++ b/include/rom4.h @@ -26,7 +26,7 @@ void sub_8053050(void); void ResetGameStats(void); void IncrementGameStat(u8 index); u32 GetGameStat(u8 index); -// SetGameStat +void SetGameStat(u8, u32); // sub_8053154 // sub_8053198 void update_saveblock1_field_object_coords(u8, s16, s16); @@ -59,7 +59,7 @@ void sub_80536E4(s8, s8, s8, s8, s8); void sub_8053720(s16, s16); // sub_8053778 // unref_sub_8053790 -// sub_80537CC +void sub_80537CC(u8); void gpu_sync_bg_hide(); // sub_8053818 // sub_8053850 diff --git a/ld_script.txt b/ld_script.txt index b045abe92..03b434ea1 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -213,7 +213,7 @@ SECTIONS { src/rom6.o(.text); asm/pokeblock.o(.text); asm/fldeff_flash.o(.text); - asm/post_battle_event_funcs.o(.text); + src/post_battle_event_funcs.o(.text); asm/time_events.o(.text); asm/birch_pc.o(.text); asm/hof_pc.o(.text); diff --git a/src/post_battle_event_funcs.c b/src/post_battle_event_funcs.c new file mode 100644 index 000000000..56e1518eb --- /dev/null +++ b/src/post_battle_event_funcs.c @@ -0,0 +1,70 @@ +#include "global.h" +#include "main.h" +#include "script_pokemon_80C4.h" +#include "event_data.h" +#include "pokemon.h" +#include "rom4.h" +#include "load_save.h" + +extern void sub_8141F90(void); + +extern u8 gUnknown_02039324; + +int GameClear(void) +{ + int i; + bool32 ribbonGet; + + HealPlayerParty(); + + if (FlagGet(SYS_GAME_CLEAR) == TRUE) + { + gUnknown_02039324 = 1; + } + else + { + gUnknown_02039324 = 0; + FlagSet(SYS_GAME_CLEAR); + } + + if (!GetGameStat(1)) + SetGameStat(1, (gSaveBlock2.playTimeHours << 16) | (gSaveBlock2.playTimeMinutes << 8) | gSaveBlock2.playTimeSeconds); + + SetSecretBase2Field_9(); + + if (gSaveBlock2.playerGender == MALE) + sub_80537CC(1); + else + sub_80537CC(2); + + ribbonGet = FALSE; + + for (i = 0; i < 6; i++) + { + u8 val; + u8 *ptr = &val; + if (GetMonData(&gPlayerParty[i], MON_DATA_SANITY_BIT2) + && !GetMonData(&gPlayerParty[i], MON_DATA_SANITY_BIT3) + && !GetMonData(&gPlayerParty[i], MON_DATA_CHAMPION_RIBBON)) + { + *ptr = 1; + SetMonData(&gPlayerParty[i], MON_DATA_CHAMPION_RIBBON, ptr); + ribbonGet = TRUE; + } + } + + if (ribbonGet == TRUE) + { + IncrementGameStat(42); + FlagSet(SYS_RIBBON_GET); + } + + SetMainCallback2(sub_8141F90); + return 0; +} + +int sp0C8_whiteout_maybe(void) +{ + SetMainCallback2(CB2_WhiteOut); + return 0; +} |