diff --git a/asm/battle_frontier_2.s b/asm/battle_frontier_2.s index 280a8a483..c7966b48d 100644 --- a/asm/battle_frontier_2.s +++ b/asm/battle_frontier_2.s @@ -4,410 +4,6 @@ .syntax unified .text - - - - - thumb_func_start sub_819F654 -sub_819F654: @ 819F654 - push {r4,lr} - adds r4, r0, 0 - adds r0, 0x3F - ldrb r1, [r0] - movs r0, 0x20 - ands r0, r1 - cmp r0, 0 - beq _0819F694 - ldrb r0, [r4, 0x3] - lsls r0, 26 - lsrs r0, 27 - bl FreeOamMatrix - movs r1, 0x3C - ldrsh r0, [r4, r1] - cmp r0, 0x1 - bne _0819F688 - ldr r0, =sFactorySwapScreen - ldr r0, [r0] - adds r0, 0x30 - movs r1, 0 - strb r1, [r0] - b _0819F68E - .pool -_0819F688: - movs r0, 0 - bl sub_819BE20 -_0819F68E: - adds r0, r4, 0 - bl DestroySprite -_0819F694: - pop {r4} - pop {r0} - bx r0 - thumb_func_end sub_819F654 - - thumb_func_start sub_819F69C -sub_819F69C: @ 819F69C - push {r4,r5,lr} - lsls r0, 24 - lsrs r5, r0, 24 - lsls r0, r5, 2 - adds r0, r5 - lsls r0, 3 - ldr r1, =gTasks - adds r4, r0, r1 - movs r1, 0x8 - ldrsh r0, [r4, r1] - cmp r0, 0x1 - beq _0819F71A - cmp r0, 0x1 - bgt _0819F6C4 - cmp r0, 0 - beq _0819F6CA - b _0819F77C - .pool -_0819F6C4: - cmp r0, 0x2 - beq _0819F73C - b _0819F77C -_0819F6CA: - movs r0, 0x58 - strh r0, [r4, 0xE] - movs r0, 0x98 - strh r0, [r4, 0x38] - movs r0, 0x40 - strh r0, [r4, 0x12] - movs r0, 0x41 - strh r0, [r4, 0x18] - movs r1, 0x80 - lsls r1, 6 - movs r0, 0 - bl SetGpuRegBits - ldrh r1, [r4, 0xE] - lsls r1, 8 - ldrh r0, [r4, 0x38] - orrs r1, r0 - lsls r1, 16 - lsrs r1, 16 - movs r0, 0x40 - bl SetGpuReg - ldrh r1, [r4, 0x12] - lsls r1, 8 - ldrh r0, [r4, 0x18] - orrs r1, r0 - lsls r1, 16 - lsrs r1, 16 - movs r0, 0x44 - bl SetGpuReg - movs r0, 0x48 - movs r1, 0x3F - bl SetGpuReg - movs r0, 0x4A - movs r1, 0x37 - bl SetGpuReg - b _0819F7A6 -_0819F71A: - movs r0, 0x3 - bl ShowBg - ldr r1, =0x00001248 - movs r0, 0x50 - bl SetGpuReg - ldr r1, =0x0000040b - movs r0, 0x52 - bl SetGpuReg - b _0819F7A6 - .pool -_0819F73C: - ldrh r0, [r4, 0x12] - subs r0, 0x4 - strh r0, [r4, 0x12] - ldrh r1, [r4, 0x18] - adds r1, 0x4 - strh r1, [r4, 0x18] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0x20 - ble _0819F758 - lsls r0, r1, 16 - asrs r0, 16 - cmp r0, 0x5F - ble _0819F760 -_0819F758: - movs r0, 0x20 - strh r0, [r4, 0x12] - movs r0, 0x60 - strh r0, [r4, 0x18] -_0819F760: - ldrh r1, [r4, 0x12] - lsls r1, 8 - ldrh r0, [r4, 0x18] - orrs r1, r0 - lsls r1, 16 - lsrs r1, 16 - movs r0, 0x44 - bl SetGpuReg - movs r2, 0x12 - ldrsh r0, [r4, r2] - cmp r0, 0x20 - bne _0819F7AC - b _0819F7A6 -_0819F77C: - adds r0, r5, 0 - bl DestroyTask - ldr r0, =gTasks - lsls r1, r5, 2 - adds r1, r5 - lsls r1, 3 - adds r1, r0 - movs r2, 0x16 - ldrsh r0, [r1, r2] - cmp r0, 0x1 - bne _0819F7A0 - bl sub_819F8E0 - b _0819F7AC - .pool -_0819F7A0: - bl sub_819BD70 - b _0819F7AC -_0819F7A6: - ldrh r0, [r4, 0x8] - adds r0, 0x1 - strh r0, [r4, 0x8] -_0819F7AC: - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end sub_819F69C - - thumb_func_start sub_819F7B4 -sub_819F7B4: @ 819F7B4 - push {r4,r5,lr} - lsls r0, 24 - lsrs r5, r0, 24 - lsls r0, r5, 2 - adds r0, r5 - lsls r0, 3 - ldr r1, =gTasks - adds r4, r0, r1 - movs r1, 0x8 - ldrsh r0, [r4, r1] - cmp r0, 0 - beq _0819F844 - cmp r0, 0x1 - beq _0819F894 - movs r0, 0x3 - bl HideBg - ldr r3, =gSprites - movs r0, 0x14 - ldrsh r1, [r4, r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r3 - ldrh r1, [r4, 0x16] - strh r1, [r0, 0x3C] - movs r0, 0x14 - ldrsh r1, [r4, r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r3 - adds r0, 0x3E - ldrb r2, [r0] - movs r1, 0x5 - negs r1, r1 - ands r1, r2 - strb r1, [r0] - movs r0, 0x14 - ldrsh r1, [r4, r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r1, r3, 0 - adds r1, 0x1C - adds r0, r1 - ldr r1, =sub_819F654 - str r1, [r0] - movs r0, 0x14 - ldrsh r1, [r4, r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r3 - movs r1, 0x1 - bl StartSpriteAffineAnim - movs r1, 0x80 - lsls r1, 6 - movs r0, 0 - bl ClearGpuRegBits - adds r0, r5, 0 - bl DestroyTask - b _0819F8D8 - .pool -_0819F844: - movs r0, 0x58 - strh r0, [r4, 0xE] - movs r0, 0x98 - strh r0, [r4, 0x38] - movs r0, 0x20 - strh r0, [r4, 0x12] - movs r0, 0x60 - strh r0, [r4, 0x18] - movs r1, 0x80 - lsls r1, 6 - movs r0, 0 - bl SetGpuRegBits - ldrh r1, [r4, 0xE] - lsls r1, 8 - ldrh r0, [r4, 0x38] - orrs r1, r0 - lsls r1, 16 - lsrs r1, 16 - movs r0, 0x40 - bl SetGpuReg - ldrh r1, [r4, 0x12] - lsls r1, 8 - ldrh r0, [r4, 0x18] - orrs r1, r0 - lsls r1, 16 - lsrs r1, 16 - movs r0, 0x44 - bl SetGpuReg - movs r0, 0x48 - movs r1, 0x3F - bl SetGpuReg - movs r0, 0x4A - movs r1, 0x37 - bl SetGpuReg - b _0819F8D2 -_0819F894: - ldrh r0, [r4, 0x12] - adds r0, 0x4 - strh r0, [r4, 0x12] - ldrh r1, [r4, 0x18] - subs r1, 0x4 - strh r1, [r4, 0x18] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0x3F - bgt _0819F8B0 - lsls r0, r1, 16 - asrs r0, 16 - cmp r0, 0x41 - bgt _0819F8B8 -_0819F8B0: - movs r0, 0x40 - strh r0, [r4, 0x12] - movs r0, 0x41 - strh r0, [r4, 0x18] -_0819F8B8: - ldrh r1, [r4, 0x12] - lsls r1, 8 - ldrh r0, [r4, 0x18] - orrs r1, r0 - lsls r1, 16 - lsrs r1, 16 - movs r0, 0x44 - bl SetGpuReg - movs r1, 0x12 - ldrsh r0, [r4, r1] - cmp r0, 0x40 - bne _0819F8D8 -_0819F8D2: - ldrh r0, [r4, 0x8] - adds r0, 0x1 - strh r0, [r4, 0x8] -_0819F8D8: - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end sub_819F7B4 - - thumb_func_start sub_819F8E0 -sub_819F8E0: @ 819F8E0 - push {r4-r6,lr} - sub sp, 0x10 - ldr r0, =sFactorySwapScreen - ldr r1, [r0] - ldrb r0, [r1, 0x14] - cmp r0, 0 - bne _0819F900 - ldrb r1, [r1, 0x3] - movs r0, 0x64 - muls r1, r0 - ldr r0, =gPlayerParty - b _0819F908 - .pool -_0819F900: - ldrb r1, [r1, 0x3] - movs r0, 0x64 - muls r1, r0 - ldr r0, =gEnemyParty -_0819F908: - adds r6, r1, r0 - adds r0, r6, 0 - movs r1, 0xB - movs r2, 0 - bl GetMonData - adds r4, r0, 0 - lsls r4, 16 - lsrs r4, 16 - adds r0, r6, 0 - movs r1, 0 - movs r2, 0 - bl GetMonData - adds r5, r0, 0 - adds r0, r6, 0 - movs r1, 0x1 - movs r2, 0 - bl GetMonData - adds r1, r0, 0 - movs r0, 0x58 - str r0, [sp] - movs r0, 0x20 - str r0, [sp, 0x4] - movs r0, 0xF - str r0, [sp, 0x8] - ldr r0, =0x0000ffff - str r0, [sp, 0xC] - adds r0, r4, 0 - adds r2, r5, 0 - movs r3, 0x1 - bl CreateMonPicSprite_HandleDeoxys - ldr r2, =sFactorySwapScreen - ldr r1, [r2] - adds r1, 0x2C - movs r3, 0 - strb r0, [r1] - ldr r4, =gSprites - ldr r0, [r2] - adds r0, 0x2C - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r4 - adds r0, 0x28 - strb r3, [r0] - ldr r0, [r2] - adds r0, 0x2C - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r4 - adds r0, 0x29 - strb r3, [r0] - ldr r0, [r2] - adds r0, 0x30 - strb r3, [r0] - add sp, 0x10 - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_819F8E0 - -@ Battle Factory ends here thumb_func_start sub_819F99C sub_819F99C: @ 819F99C @@ -12655,7 +12251,7 @@ nullsub_123: @ 81A6184 sub_81A6188: @ 81A6188 push {lr} bl ZeroPlayerPartyMons - bl sub_819A4F8 + bl DoBattleFactorySelectScreen pop {r0} bx r0 thumb_func_end sub_81A6188 @@ -12663,7 +12259,7 @@ sub_81A6188: @ 81A6188 thumb_func_start sub_81A6198 sub_81A6198: @ 81A6198 push {lr} - bl sub_819DC00 + bl DoBattleFactorySwapScreen pop {r0} bx r0 thumb_func_end sub_81A6198 diff --git a/asm/battle_tent.s b/asm/battle_tent.s deleted file mode 100644 index 8de98850f..000000000 --- a/asm/battle_tent.s +++ /dev/null @@ -1,260 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .syntax unified - - .text - - - - thumb_func_start sub_81BA040 -sub_81BA040: @ 81BA040 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x10 - movs r0, 0 - mov r10, r0 - ldr r1, =gFacilityTrainers - ldr r0, =gSlateportBattleTentTrainers - str r0, [r1] - ldr r1, =gFacilityTrainerMons - ldr r0, =gSlateportBattleTentMons - str r0, [r1] - ldr r7, =gSaveBlock2Ptr - ldr r1, =0x0000ffff - mov r8, r1 -_081BA062: - mov r2, r10 - lsls r6, r2, 1 -_081BA066: - bl Random - lsls r0, 16 - lsrs r0, 16 - movs r1, 0x1E - bl __umodsi3 - lsls r0, 16 - lsrs r3, r0, 16 - movs r5, 0 - ldr r1, [r7] - ldr r4, =0x00000cb2 - adds r0, r1, r4 - ldrh r0, [r0] - cmp r5, r0 - bge _081BA0AA - ldr r2, =0x00000cb4 - adds r0, r1, r2 - ldrh r0, [r0] - cmp r0, r3 - beq _081BA0AA - ldr r0, =gSaveBlock2Ptr - ldr r1, [r0] - adds r0, r1, r4 - ldrh r2, [r0] - adds r4, 0x2 - adds r1, r4 -_081BA09C: - adds r1, 0x2 - adds r5, 0x1 - cmp r5, r2 - bge _081BA0AA - ldrh r0, [r1] - cmp r0, r3 - bne _081BA09C -_081BA0AA: - ldr r0, [r7] - ldr r1, =0x00000cb2 - adds r0, r1 - ldrh r0, [r0] - cmp r5, r0 - bne _081BA066 - ldr r2, =gTrainerBattleOpponent_A - strh r3, [r2] - ldrh r3, [r2] - ldr r4, =gFacilityTrainers - ldr r1, [r4] - movs r0, 0x34 - muls r0, r3 - adds r0, r1 - ldr r0, [r0, 0x30] - adds r1, r6, r0 - ldrh r0, [r1] - cmp r0, r8 - beq _081BA0DE - ldr r3, =0x0000ffff -_081BA0D2: - adds r1, 0x2 - movs r6, 0x1 - add r10, r6 - ldrh r0, [r1] - cmp r0, r3 - bne _081BA0D2 -_081BA0DE: - mov r0, r10 - cmp r0, 0x8 - bgt _081BA110 - movs r1, 0 - mov r10, r1 - b _081BA062 - .pool -_081BA110: - ldr r0, =gSaveBlock2Ptr - ldr r1, [r0] - ldr r6, =0x00000cb2 - adds r3, r1, r6 - ldrh r0, [r3] - cmp r0, 0x1 - bhi _081BA12A - lsls r0, 1 - ldr r3, =0x00000cb4 - adds r1, r3 - adds r1, r0 - ldrh r0, [r2] - strh r0, [r1] -_081BA12A: - ldrh r1, [r2] - ldr r2, [r4] - movs r0, 0x34 - muls r0, r1 - adds r0, r2 - ldr r0, [r0, 0x30] - mov r9, r0 - movs r5, 0 - ldr r7, =gUnknown_03001298 - mov r8, sp -_081BA13E: - bl Random - lsls r0, 16 - lsrs r0, 16 - mov r1, r10 - bl __modsi3 - lsls r0, 1 - add r0, r9 - ldrh r0, [r0] - strh r0, [r7] - movs r2, 0 - ldrh r0, [r7] - ldr r4, =gFacilityTrainerMons - ldr r3, [r4] - lsls r0, 4 - adds r0, r3 - ldr r1, =gSaveBlock2Ptr - ldrh r6, [r0] - ldr r1, [r1] -_081BA166: - movs r4, 0xE7 - lsls r4, 4 - adds r0, r1, r4 - ldrh r0, [r0] - lsls r0, 4 - adds r0, r3 - ldrh r0, [r0] - cmp r6, r0 - beq _081BA180 - adds r1, 0xC - adds r2, 0x1 - cmp r2, 0x5 - ble _081BA166 -_081BA180: - cmp r2, 0x6 - bne _081BA220 - movs r4, 0 - cmp r4, r5 - bge _081BA1B0 - mov r0, sp - ldrh r0, [r0] - cmp r0, r6 - beq _081BA1B0 - ldr r6, =gUnknown_03001298 - ldr r3, =gFacilityTrainerMons - mov r2, sp -_081BA198: - adds r2, 0x2 - adds r4, 0x1 - cmp r4, r5 - bge _081BA1B0 - ldrh r0, [r6] - ldr r1, [r3] - lsls r0, 4 - adds r0, r1 - ldrh r1, [r2] - ldrh r0, [r0] - cmp r1, r0 - bne _081BA198 -_081BA1B0: - cmp r4, r5 - bne _081BA220 - movs r4, 0 - cmp r4, r5 - bge _081BA1E6 - ldr r6, =gBattleFrontierHeldItems - mov r12, r6 - add r3, sp, 0x8 -_081BA1C0: - ldrh r2, [r3] - cmp r2, 0 - beq _081BA1DE - ldr r1, =gUnknown_03001298 - ldrh r0, [r1] - ldr r6, =gFacilityTrainerMons - ldr r1, [r6] - lsls r0, 4 - adds r0, r1 - ldrb r0, [r0, 0xA] - lsls r0, 1 - add r0, r12 - ldrh r0, [r0] - cmp r2, r0 - beq _081BA1E6 -_081BA1DE: - adds r3, 0x2 - adds r4, 0x1 - cmp r4, r5 - blt _081BA1C0 -_081BA1E6: - cmp r4, r5 - bne _081BA220 - lsls r2, r5, 1 - ldrh r0, [r7] - ldr r1, =gFacilityTrainerMons - ldr r4, [r1] - lsls r0, 4 - adds r0, r4 - ldrh r0, [r0] - mov r3, r8 - strh r0, [r3] - add r1, sp, 0x8 - adds r1, r2 - ldr r3, =gBattleFrontierHeldItems - ldrh r0, [r7] - lsls r0, 4 - adds r0, r4 - ldrb r0, [r0, 0xA] - lsls r0, 1 - adds r0, r3 - ldrh r0, [r0] - strh r0, [r1] - ldr r0, =gUnknown_03006298 - adds r2, r0 - ldrh r0, [r7] - strh r0, [r2] - movs r4, 0x2 - add r8, r4 - adds r5, 0x1 -_081BA220: - cmp r5, 0x3 - bne _081BA13E - add sp, 0x10 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81BA040 - - .align 2, 0 @ Don't pad with nop. diff --git a/common_syms/save.txt b/common_syms/save.txt index 92d31eb14..d7668c332 100644 --- a/common_syms/save.txt +++ b/common_syms/save.txt @@ -8,3 +8,6 @@ gUnknown_03006208 gSaveUnusedVar gSaveFileStatus gGameContinueCallback +gRamSaveSectionLocations +gSaveUnusedVar2 +gUnknown_03006294 diff --git a/data/battle_frontier_2.s b/data/battle_frontier_2.s index f2e2dd650..dc38826a7 100644 --- a/data/battle_frontier_2.s +++ b/data/battle_frontier_2.s @@ -6,29 +6,6 @@ .section .rodata -gUnknown_08610918:: @ 8610918 - .byte 0x00, 0x00, 0x00, 0x00, 0xff, 0x7f, 0x00, 0x00, 0x1f, 0x00 - -gUnknown_08610922:: @ 8610922 - .byte 0x00, 0x02, 0x00 - -gUnknown_08610925:: @ 8610925 - .byte 0x00, 0x04, 0x00 - - .align 2 -gUnknown_08610928:: @ 8610928 - .4byte 0x00000001, sub_819F20C - .4byte 0x00000001, sub_819F20C - .4byte 0x00000001, sub_819F20C - .4byte 0x00000003, sub_819F1AC - - .align 2 -gUnknown_08610948:: @ 8610948 - .4byte 0x00000001, sub_819F20C - .4byte 0x00000001, sub_819F20C - .4byte 0x00000001, sub_819F20C - .4byte 0x00000002, sub_819F1DC - .4byte 0x00000003, sub_819F1AC .align 2 @ struct, eight bytes x6 for names in different languages, then 0x28 more bytes of data gUnknown_08610970:: @ 8610970 diff --git a/include/battle_factory.h b/include/battle_factory.h new file mode 100644 index 000000000..1b0e44943 --- /dev/null +++ b/include/battle_factory.h @@ -0,0 +1,7 @@ +#ifndef GUARD_BATTLE_FACTORY_H +#define GUARD_BATTLE_FACTORY_H + +void DoBattleFactorySelectScreen(void); +void DoBattleFactorySwapScreen(void); + +#endif // GUARD_BATTLE_FACTORY_H diff --git a/include/battle_frontier_2.h b/include/battle_frontier_2.h index 09e974068..4ef860e80 100644 --- a/include/battle_frontier_2.h +++ b/include/battle_frontier_2.h @@ -9,8 +9,6 @@ bool8 InBattlePike(void); void sub_819FA50(void); void sub_81AA078(u16*, u8); void sub_81A4C30(void); -void sub_819A4F8(void); -void sub_819DC00(void); bool8 sub_81A6BF4(void); #endif // GUARD_BATTLE_FRONTIER_2_H diff --git a/include/battle_tower.h b/include/battle_tower.h index f07e9e544..5879a73bb 100644 --- a/include/battle_tower.h +++ b/include/battle_tower.h @@ -31,7 +31,7 @@ struct BattleFrontierTrainer u16 speechBefore[6]; u16 speechWin[6]; u16 speechLose[6]; - u16 *btMonPool; + const u16 *btMonPool; }; struct FacilityMon diff --git a/include/menu.h b/include/menu.h index b52b165f2..309667b19 100644 --- a/include/menu.h +++ b/include/menu.h @@ -35,7 +35,6 @@ void SetStandardWindowBorderStyle(u8 a0, u8 a1); void sub_8197930(void); u8 GetPlayerTextSpeed(void); void sub_81978B0(u16 arg0); - void AddTextPrinterWithCallbackForMessage(bool8 a1, void (*callback)(struct TextSubPrinter *, u16)); void AddTextPrinterParameterized3(u8 windowId, u8 fontId, u8 left, u8 top, const u8 *color, s8 speed, const u8 *str); void sub_8198070(u8 windowId, bool8 copyToVram); @@ -87,5 +86,6 @@ u8 AddMapNamePopUpWindow(void); void AddTextPrinterParameterized5(u8 windowId, u8 fontId, const u8 *str, u8 left, u8 top, u8 speed, void (*callback)(struct TextSubPrinter *, u16), u8 letterSpacing, u8 lineSpacing); void sub_8199C30(u8 bgId, u8 left, u8 top, u8 width, u8 height, u8 palette); void sub_8199D3C(void *ptr, int delta, int width, int height, bool32 is8BPP); +void sub_8198204(const u8 *string, const u8 *string2, u8 a3, u8 a4, bool8 copyToVram); #endif // GUARD_MENU_H diff --git a/include/save.h b/include/save.h index 9859870b4..a87e31e99 100644 --- a/include/save.h +++ b/include/save.h @@ -1,8 +1,6 @@ #ifndef GUARD_SAVE_H #define GUARD_SAVE_H -extern u16 gSaveFileStatus; - struct SaveSectionLocation { void *data; @@ -58,6 +56,20 @@ enum #define SECTION_ID_RECORDED_BATTLE 31 +extern u16 gLastWrittenSector; +extern u32 gLastSaveCounter; +extern u16 gLastKnownGoodSector; +extern u32 gDamagedSaveSectors; +extern u32 gSaveCounter; +extern struct SaveSection *gFastSaveSection; +extern u16 gUnknown_03006208; +extern u16 gSaveFileStatus; +extern void (*gGameContinueCallback)(void); +extern struct SaveSectionLocation gRamSaveSectionLocations[]; +extern u16 gUnknown_03006294; + +extern struct SaveSection gSaveDataBuffer; + void ClearSaveData(void); void Save_ResetSaveCounters(void); bool32 SetDamagedSectorBits(u8 op, u8 bit); diff --git a/ld_script.txt b/ld_script.txt index eec0bbc68..26e6fa2e3 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -256,7 +256,6 @@ SECTIONS { src/item_icon.o(.text); asm/party_menu.o(.text); src/battle_tent.o(.text); - asm/battle_tent.o(.text); src/unk_text_util_2.o(.text); src/multiboot.o(.text); src/unk_81BAD84.o(.text); diff --git a/src/battle_factory.c b/src/battle_factory.c index 486449f94..07c5c9e10 100644 --- a/src/battle_factory.c +++ b/src/battle_factory.c @@ -1,4 +1,5 @@ #include "global.h" +#include "battle_factory.h" #include "sprite.h" #include "event_data.h" #include "overworld.h" @@ -115,14 +116,10 @@ struct FactorySwapMonsStruct u8 yesNoCursorPos; u8 actionsCount; const struct SwapActionIdAndFunc *actionsData; - u8 unk1C; - u8 unk1D; - u8 unk1E; - u8 unk1F; + u8 unused1C[4]; bool8 monSwapped; u8 fadeSpeciesNameTaskId; - u8 unk22; - u8 unk23; + bool8 unk22; u16 unk24; bool8 unk26; u8 unk27; @@ -142,9 +139,11 @@ extern const struct BattleFrontierTrainer gBattleFrontierTrainers[]; extern const u8 gUnknown_085B18AC[]; extern void SetMonMoveAvoidReturn(struct Pokemon *mon, u16 move, u8 moveSlot); +extern u8 sub_81A6F70(u8 battleMode, u8 lvlMode); +extern u8 sub_81A6CA8(u8 arg0, u8 arg1); // This file's functions. -void sub_819A44C(struct Sprite *sprite); +static void sub_819A44C(struct Sprite *sprite); static void CB2_InitSelectScreen(void); static void Select_SetWinRegs(s16 mWin0H, s16 nWin0H, s16 mWin0V, s16 nWin0V); static void Select_InitMonsData(void); @@ -168,95 +167,97 @@ static void Task_HandleSelectionScreenMenu(u8 taskId); static void CreateFrontierFactorySelectableMons(u8 firstMonId); static void CreateTentFactorySelectableMons(u8 firstMonId); static void Select_SetBallSpritePaletteNum(u8 id); -void sub_819F444(struct UnkFactoryStruct arg0, bool8 *arg1); +static void sub_819F444(struct UnkFactoryStruct arg0, bool8 *arg1); static void sub_819B958(u8 windowId); -void sub_819F2B4(u8 *arg0, bool8 *arg1, bool8 swapScreen); -void sub_819F3F8(struct UnkFactoryStruct arg0, bool8 *arg1, bool8 swapScreen); +static void sub_819F2B4(u8 *arg0, bool8 *arg1, bool8 swapScreen); +static void sub_819F3F8(struct UnkFactoryStruct arg0, bool8 *arg1, bool8 swapScreen); static u8 Select_RunMenuOptionFunc(void); static u8 sub_819BC9C(void); static u8 Select_OptionSummary(void); static u8 Select_OptionOthers(void); static u8 Select_OptionRentDeselect(void); -u8 sub_81A6F70(u8 battleMode, u8 lvlMode); -u8 sub_81A6CA8(u8 arg0, u8 arg1); static bool32 Select_AreSpeciesValid(u16 monSetId); -void Swap_DestroyAllSprites(void); -void Swap_ShowYesNoOptions(void); -void sub_819E8EC(void); -void sub_819EAC0(void); -void Swap_UpdateYesNoCursorPosition(s8 direction); -void Swap_UpdateMenuCursorPosition(s8 direction); -void sub_819EA64(u8 windowId); -void sub_819D770(u8 taskId); -void Task_HandleSwapScreenChooseMons(u8 taskId); -void sub_819D588(u8 taskId); -void sub_819F7B4(u8 taskId); -void Swap_PrintOnInfoWindow(const u8 *str); -void Swap_ShowMenuOptions(void); -void Swap_PrintMenuOptions(void); -void Swap_PrintYesNoOptions(void); -void Swap_PrintMonSpecies(void); -void Swap_PrintMonSpecies2(void); -void Swap_PrintMonSpecies3(void); -void Swap_PrintMonCategory(void); -void Swap_InitAllSprites(void); -void Swap_PrintPkmnSwap(void); -void sub_819EADC(void); -void sub_819EAF8(void); -void CB2_InitSwapScreen(void); -void Swap_ShowSummaryMonSprite(void); -void Swap_UpdateActionCursorPosition(s8 direction); -void Swap_UpdateBallCursorPosition(s8 direction); -void Swap_RunMenuOptionFunc(u8 taskId); -void sub_819F0CC(u8 taskId); -void sub_819F114(u8 taskId); -void sub_819F134(u8 taskId); -void Swap_RunActionFunc(u8 taskId); -void sub_819F69C(u8 taskId); -void Task_SwapCantHaveSameMons(u8 taskId); -void Swap_PrintActionStrings(void); -void Swap_PrintActionStrings2(void); -void Swap_PrintOneActionString(u8 which); -void Swap_InitActions(u8 id); -void sub_819E838(u8 arg0); -bool8 Swap_AlreadyHasSameSpecies(u8 monId); -void sub_819F600(struct Sprite *sprite); +static void Swap_DestroyAllSprites(void); +static void Swap_ShowYesNoOptions(void); +static void sub_819E8EC(void); +static void sub_819EAC0(void); +static void Swap_UpdateYesNoCursorPosition(s8 direction); +static void Swap_UpdateMenuCursorPosition(s8 direction); +static void sub_819EA64(u8 windowId); +static void sub_819D770(u8 taskId); +static void Task_HandleSwapScreenChooseMons(u8 taskId); +static void sub_819D588(u8 taskId); +static void sub_819F7B4(u8 taskId); +static void Swap_PrintOnInfoWindow(const u8 *str); +static void Swap_ShowMenuOptions(void); +static void Swap_PrintMenuOptions(void); +static void Swap_PrintYesNoOptions(void); +static void Swap_PrintMonSpecies(void); +static void Swap_PrintMonSpecies2(void); +static void Swap_PrintMonSpecies3(void); +static void Swap_PrintMonCategory(void); +static void Swap_InitAllSprites(void); +static void Swap_PrintPkmnSwap(void); +static void sub_819EADC(void); +static void sub_819EAF8(void); +static void CB2_InitSwapScreen(void); +static void Swap_ShowSummaryMonSprite(void); +static void Swap_UpdateActionCursorPosition(s8 direction); +static void Swap_UpdateBallCursorPosition(s8 direction); +static void Swap_RunMenuOptionFunc(u8 taskId); +static void sub_819F0CC(u8 taskId); +static void sub_819F114(u8 taskId); +static void sub_819F134(u8 taskId); +static void Swap_RunActionFunc(u8 taskId); +static void sub_819F69C(u8 taskId); +static void Task_SwapCantHaveSameMons(u8 taskId); +static void Swap_ShowMonSprite(void); +static void Swap_PrintActionStrings(void); +static void Swap_PrintActionStrings2(void); +static void Swap_PrintOneActionString(u8 which); +static void Swap_InitActions(u8 id); +static void sub_819E838(u8 arg0); +static bool8 Swap_AlreadyHasSameSpecies(u8 monId); +static void sub_819F600(struct Sprite *sprite); +static void Swap_ActionMon(u8 taskId); +static void Swap_ActionCancel(u8 taskId); +static void Swap_ActionPkmnForSwap(u8 taskId); // Ewram variables -EWRAM_DATA u8 *gUnknown_0203CE2C = NULL; -EWRAM_DATA u8 *gUnknown_0203CE30 = NULL; -EWRAM_DATA u8 *gUnknown_0203CE34 = NULL; -EWRAM_DATA u8 *gUnknown_0203CE38 = NULL; -EWRAM_DATA struct Pokemon *sFactorySelectMons = NULL; -EWRAM_DATA u8 *gUnknown_0203CE40 = NULL; -EWRAM_DATA u8 *gUnknown_0203CE44 = NULL; -EWRAM_DATA u8 *gUnknown_0203CE48 = NULL; -EWRAM_DATA u8 *gUnknown_0203CE4C = NULL; +static EWRAM_DATA u8 *sSelectMenuTilesetBuffer = NULL; +static EWRAM_DATA u8 *sSelectMonCardBgTilesetBuffer = NULL; +static EWRAM_DATA u8 *sSelectMenuTilemapBuffer = NULL; +static EWRAM_DATA u8 *sSelectMonCardBgTilemapBuffer = NULL; +static EWRAM_DATA struct Pokemon *sFactorySelectMons = NULL; +static EWRAM_DATA u8 *sSwapMenuTilesetBuffer = NULL; +static EWRAM_DATA u8 *sSwapMonCardBgTilesetBuffer = NULL; +static EWRAM_DATA u8 *sSwapMenuTilemapBuffer = NULL; +static EWRAM_DATA u8 *sSwapMonCardBgTilemapBuffer = NULL; // IWRAM bss -IWRAM_DATA struct FactorySelectMonsStruct *sFactorySelectScreen; -IWRAM_DATA void (*gUnknown_03001280)(u8 taskId); -IWRAM_DATA struct FactorySwapMonsStruct *sFactorySwapScreen; +static IWRAM_DATA struct FactorySelectMonsStruct *sFactorySelectScreen; +static IWRAM_DATA void (*sSwap_CurrentTableFunc)(u8 taskId); +static IWRAM_DATA struct FactorySwapMonsStruct *sFactorySwapScreen; // Const rom data. -const u16 gUnknown_0860F13C[] = INCBIN_U16("graphics/unknown/unknown_60F13C.gbapal"); -const u16 gUnknown_0860F15C[] = INCBIN_U16("graphics/unknown/unknown_60F15C.gbapal"); -const u16 gUnknown_0860F17C[] = INCBIN_U16("graphics/unknown/unknown_60F17C.gbapal"); -const u8 gUnknown_0860F1BC[] = INCBIN_U8("graphics/unknown/unknown_60F1BC.4bpp"); -const u8 gUnknown_0860F3BC[] = INCBIN_U8("graphics/unknown/unknown_60F3BC.4bpp"); -const u8 gUnknown_0860F43C[] = INCBIN_U8("graphics/unknown/unknown_60F43C.4bpp"); -const u8 gUnknown_0860F53C[] = INCBIN_U8("graphics/unknown/unknown_60F53C.4bpp"); -const u8 gUnknown_0860F63C[] = INCBIN_U8("graphics/unknown/unknown_60F63C.4bpp"); -const u8 gUnknown_0860F6BC[] = INCBIN_U8("graphics/unknown/unknown_60F6BC.4bpp"); -const u8 gUnknown_0860F7BC[] = INCBIN_U8("graphics/unknown/unknown_60F7BC.4bpp"); -const u8 gUnknown_0860F83C[] = INCBIN_U8("graphics/unknown/unknown_60F83C.4bpp"); -const u8 gUnknown_0860F93C[] = INCBIN_U8("graphics/unknown/unknown_60F93C.4bpp"); -const u8 gUnknown_0860FA3C[] = INCBIN_U8("graphics/unknown/unknown_60FA3C.4bpp"); -const u8 gUnknown_0861023C[] = INCBIN_U8("graphics/unknown/unknown_61023C.bin"); -const u8 gUnknown_0861033C[] = INCBIN_U8("graphics/unknown/unknown_61033C.4bpp"); -const u16 gUnknown_0861039C[] = INCBIN_U16("graphics/unknown/unknown_61039C.gbapal"); +static const u16 gUnknown_0860F13C[] = INCBIN_U16("graphics/unknown/unknown_60F13C.gbapal"); +static const u16 gUnknown_0860F15C[] = INCBIN_U16("graphics/unknown/unknown_60F15C.gbapal"); +static const u16 gUnknown_0860F17C[] = INCBIN_U16("graphics/unknown/unknown_60F17C.gbapal"); +static const u8 gUnknown_0860F1BC[] = INCBIN_U8("graphics/unknown/unknown_60F1BC.4bpp"); +static const u8 gUnknown_0860F3BC[] = INCBIN_U8("graphics/unknown/unknown_60F3BC.4bpp"); +static const u8 gUnknown_0860F43C[] = INCBIN_U8("graphics/unknown/unknown_60F43C.4bpp"); +static const u8 gUnknown_0860F53C[] = INCBIN_U8("graphics/unknown/unknown_60F53C.4bpp"); +static const u8 gUnknown_0860F63C[] = INCBIN_U8("graphics/unknown/unknown_60F63C.4bpp"); +static const u8 gUnknown_0860F6BC[] = INCBIN_U8("graphics/unknown/unknown_60F6BC.4bpp"); +static const u8 gUnknown_0860F7BC[] = INCBIN_U8("graphics/unknown/unknown_60F7BC.4bpp"); +static const u8 gUnknown_0860F83C[] = INCBIN_U8("graphics/unknown/unknown_60F83C.4bpp"); +static const u8 gUnknown_0860F93C[] = INCBIN_U8("graphics/unknown/unknown_60F93C.4bpp"); +static const u8 gUnknown_0860FA3C[] = INCBIN_U8("graphics/unknown/unknown_60FA3C.4bpp"); +static const u8 gUnknown_0861023C[] = INCBIN_U8("graphics/unknown/unknown_61023C.bin"); +static const u8 gUnknown_0861033C[] = INCBIN_U8("graphics/unknown/unknown_61033C.4bpp"); +static const u16 gUnknown_0861039C[] = INCBIN_U16("graphics/unknown/unknown_61039C.gbapal"); -const struct SpriteSheet gUnknown_086103BC[] = +static const struct SpriteSheet gUnknown_086103BC[] = { {gUnknown_0860F3BC, sizeof(gUnknown_0860F3BC), TAG_TILE_65}, {gUnknown_0860F43C, sizeof(gUnknown_0860F43C), TAG_TILE_66}, @@ -265,13 +266,13 @@ const struct SpriteSheet gUnknown_086103BC[] = {}, }; -const struct CompressedSpriteSheet gUnknown_086103E4[] = +static const struct CompressedSpriteSheet gUnknown_086103E4[] = { {gUnknown_085B18AC, 0x800, TAG_TILE_64}, {}, }; -const struct SpritePalette gUnknown_086103F4[] = +static const struct SpritePalette gUnknown_086103F4[] = { {gUnknown_0860F13C, TAG_PAL_BALL_GREY}, {gUnknown_0860F15C, TAG_PAL_BALL_SELECTED}, @@ -280,14 +281,14 @@ const struct SpritePalette gUnknown_086103F4[] = {}, }; -u8 (* const sSelect_MenuOptionFuncs[])(void) = +u8 static (* const sSelect_MenuOptionFuncs[])(void) = { [MENU_SUMMARY] = Select_OptionSummary, [MENU_RENT] /*Or Deselect*/ = Select_OptionRentDeselect, [MENU_OTHERS] = Select_OptionOthers }; -static const struct BgTemplate gUnknown_08610428[3] = +static const struct BgTemplate sSelect_BgTemplates[] = { { .bg = 0, @@ -318,7 +319,7 @@ static const struct BgTemplate gUnknown_08610428[3] = }, }; -static const struct WindowTemplate gUnknown_08610434[] = +static const struct WindowTemplate sSelect_WindowTemplates[] = { { .priority = 0, @@ -551,8 +552,8 @@ static const union AffineAnimCmd * const gUnknown_086105CC[] = static const struct SpriteTemplate gUnknown_086105D8 = { - .tileTag = 0x0064, - .paletteTag = 0x0064, + .tileTag = TAG_TILE_64, + .paletteTag = TAG_PAL_BALL_GREY, .oam = &gUnknown_0861047C, .anims = gUnknown_08610504, .images = NULL, @@ -562,8 +563,8 @@ static const struct SpriteTemplate gUnknown_086105D8 = static const struct SpriteTemplate gUnknown_086105F0 = { - .tileTag = 0x0065, - .paletteTag = 0x0066, + .tileTag = TAG_TILE_65, + .paletteTag = TAG_PAL_66, .oam = &gUnknown_08610484, .anims = gUnknown_086104FC, .images = NULL, @@ -573,8 +574,8 @@ static const struct SpriteTemplate gUnknown_086105F0 = static const struct SpriteTemplate gUnknown_08610608 = { - .tileTag = 0x0066, - .paletteTag = 0x0066, + .tileTag = TAG_TILE_66, + .paletteTag = TAG_PAL_66, .oam = &gUnknown_0861048C, .anims = gUnknown_086104FC, .images = NULL, @@ -584,8 +585,8 @@ static const struct SpriteTemplate gUnknown_08610608 = static const struct SpriteTemplate gUnknown_08610620 = { - .tileTag = 0x0067, - .paletteTag = 0x0066, + .tileTag = TAG_TILE_67, + .paletteTag = TAG_PAL_66, .oam = &gUnknown_0861048C, .anims = gUnknown_086104FC, .images = NULL, @@ -595,8 +596,8 @@ static const struct SpriteTemplate gUnknown_08610620 = static const struct SpriteTemplate gUnknown_08610638 = { - .tileTag = 0x006d, - .paletteTag = 0x0067, + .tileTag = TAG_TILE_6D, + .paletteTag = TAG_PAL_67, .oam = &gUnknown_08610494, .anims = gUnknown_08610500, .images = NULL, @@ -606,30 +607,30 @@ static const struct SpriteTemplate gUnknown_08610638 = static const struct SpriteSheet gUnknown_08610650[] = { - {gUnknown_0860F3BC, 0x0080, 0x0065}, - {gUnknown_0860F43C, 0x0100, 0x0066}, - {gUnknown_0860F53C, 0x0100, 0x0067}, - {gUnknown_0860F63C, 0x0080, 0x0068}, - {gUnknown_0860F6BC, 0x0100, 0x0069}, - {gUnknown_0860F7BC, 0x0100, 0x006a}, - {gUnknown_0860F83C, 0x0100, 0x006b}, - {gUnknown_0860F93C, 0x0100, 0x006c}, - {gUnknown_0860FA3C, 0x0800, 0x006d}, + {gUnknown_0860F3BC, sizeof(gUnknown_0860F3BC), TAG_TILE_65}, + {gUnknown_0860F43C, sizeof(gUnknown_0860F43C), TAG_TILE_66}, + {gUnknown_0860F53C, sizeof(gUnknown_0860F53C), TAG_TILE_67}, + {gUnknown_0860F63C, sizeof(gUnknown_0860F63C), TAG_TILE_68}, + {gUnknown_0860F6BC, sizeof(gUnknown_0860F6BC), TAG_TILE_69}, + {gUnknown_0860F7BC, 0x100, TAG_TILE_6A}, + {gUnknown_0860F83C, sizeof(gUnknown_0860F83C), TAG_TILE_6B}, + {gUnknown_0860F93C, sizeof(gUnknown_0860F93C), TAG_TILE_6C}, + {gUnknown_0860FA3C, sizeof(gUnknown_0860FA3C), TAG_TILE_6D}, {}, }; static const struct CompressedSpriteSheet gUnknown_086106A0[] = { - {gUnknown_085B18AC, 0x0800, 0x0064}, + {gUnknown_085B18AC, 0x800, TAG_TILE_64}, {}, }; static const struct SpritePalette gUnknown_086106B0[] = { - {gUnknown_0860F13C, 0x0064}, - {gUnknown_0860F15C, 0x0065}, - {gUnknown_0860F17C, 0x0066}, - {gUnknown_0861039C, 0x0067}, + {gUnknown_0860F13C, TAG_PAL_BALL_GREY}, + {gUnknown_0860F15C, TAG_PAL_BALL_SELECTED}, + {gUnknown_0860F17C, TAG_PAL_66}, + {gUnknown_0861039C, TAG_PAL_67}, {}, }; @@ -802,8 +803,8 @@ static const union AffineAnimCmd * const gUnknown_08610828[] = static const struct SpriteTemplate gUnknown_08610834 = { - .tileTag = 0x0064, - .paletteTag = 0x0064, + .tileTag = TAG_TILE_64, + .paletteTag = TAG_PAL_BALL_GREY, .oam = &gUnknown_086106D8, .anims = gUnknown_08610760, .images = NULL, @@ -813,8 +814,8 @@ static const struct SpriteTemplate gUnknown_08610834 = static const struct SpriteTemplate gUnknown_0861084C = { - .tileTag = 0x0065, - .paletteTag = 0x0066, + .tileTag = TAG_TILE_65, + .paletteTag = TAG_PAL_66, .oam = &gUnknown_086106E0, .anims = gUnknown_08610758, .images = NULL, @@ -824,8 +825,8 @@ static const struct SpriteTemplate gUnknown_0861084C = static const struct SpriteTemplate gUnknown_08610864 = { - .tileTag = 0x0066, - .paletteTag = 0x0066, + .tileTag = TAG_TILE_66, + .paletteTag = TAG_PAL_66, .oam = &gUnknown_086106E8, .anims = gUnknown_08610758, .images = NULL, @@ -835,8 +836,8 @@ static const struct SpriteTemplate gUnknown_08610864 = static const struct SpriteTemplate gUnknown_0861087C = { - .tileTag = 0x0067, - .paletteTag = 0x0066, + .tileTag = TAG_TILE_67, + .paletteTag = TAG_PAL_66, .oam = &gUnknown_086106E8, .anims = gUnknown_08610758, .images = NULL, @@ -846,8 +847,8 @@ static const struct SpriteTemplate gUnknown_0861087C = static const struct SpriteTemplate gUnknown_08610894 = { - .tileTag = 0x006d, - .paletteTag = 0x0067, + .tileTag = TAG_TILE_6D, + .paletteTag = TAG_PAL_67, .oam = &gUnknown_086106F0, .anims = gUnknown_0861075C, .images = NULL, @@ -855,14 +856,14 @@ static const struct SpriteTemplate gUnknown_08610894 = .callback = SpriteCallbackDummy }; -void (* const sSwap_MenuOptionFuncs[])(u8 taskId) = +void static (* const sSwap_MenuOptionFuncs[])(u8 taskId) = { sub_819F114, sub_819F0CC, sub_819F134, }; -static const struct BgTemplate gUnknown_086108B8[4] = +static const struct BgTemplate sSwap_BgTemplates[4] = { { .bg = 0, @@ -902,7 +903,7 @@ static const struct BgTemplate gUnknown_086108B8[4] = }, }; -static const struct WindowTemplate gUnknown_086108C8[] = +static const struct WindowTemplate sSwap_WindowTemplates[] = { { .priority = 0, @@ -988,13 +989,26 @@ static const struct WindowTemplate gUnknown_086108C8[] = DUMMY_WIN_TEMPLATE, }; -//const u16 gUnknown_08610918[] = {0x00, 0x00, 0x00, 0x00, 0xff, 0x7f, 0x00, 0x00, 0x1f, 0x00}; // palette -//const u8 gUnknown_08610922[] = {0x00, 0x02, 0x00}; -//const u8 gUnknown_08610925[] = {0x00, 0x04, 0x00}; +static const u16 gUnknown_08610918[] = {0x0, 0x0, 0x7FFF, 0x0, 0x1F}; // Palette. +static const u8 gUnknown_08610922[] = {0x0, 0x02, 0x0}; +static const u8 gUnknown_08610925[] = {0x0, 0x04, 0x0}; -extern const u16 gUnknown_08610918[]; -extern const u8 gUnknown_08610922[]; -extern const u8 gUnknown_08610925[]; +static const struct SwapActionIdAndFunc sSwap_PlayerScreenActions[] = +{ + {1, Swap_ActionMon}, + {1, Swap_ActionMon}, + {1, Swap_ActionMon}, + {3, Swap_ActionCancel}, +}; + +static const struct SwapActionIdAndFunc sSwap_EnemyScreenActions[] = +{ + {1, Swap_ActionMon}, + {1, Swap_ActionMon}, + {1, Swap_ActionMon}, + {2, Swap_ActionPkmnForSwap}, + {3, Swap_ActionCancel}, +}; // gfx extern const u8 gFrontierFactorySelectMenu_Gfx[]; @@ -1029,7 +1043,7 @@ extern const u8 gText_SamePkmnInPartyAlready[]; extern const u8 gText_Cancel3[]; // code -void sub_819A44C(struct Sprite *sprite) +static void sub_819A44C(struct Sprite *sprite) { if (sprite->oam.paletteNum == IndexOfSpritePaletteTag(TAG_PAL_BALL_SELECTED)) { @@ -1076,7 +1090,7 @@ static void Select_VblankCb(void) TransferPlttBuffer(); } -void sub_819A4F8(void) +void DoBattleFactorySelectScreen(void) { sFactorySelectScreen = NULL; SetMainCallback2(CB2_InitSelectScreen); @@ -1095,16 +1109,16 @@ static void CB2_InitSelectScreen(void) SetVBlankCallback(NULL); CpuFill32(0, (void *)VRAM, VRAM_SIZE); ResetBgsAndClearDma3BusyFlags(0); - InitBgsFromTemplates(0, gUnknown_08610428, ARRAY_COUNT(gUnknown_08610428)); - InitWindows(gUnknown_08610434); + InitBgsFromTemplates(0, sSelect_BgTemplates, ARRAY_COUNT(sSelect_BgTemplates)); + InitWindows(sSelect_WindowTemplates); DeactivateAllTextPrinters(); gMain.state++; break; case 1: - gUnknown_0203CE2C = Alloc(0x440); - gUnknown_0203CE30 = AllocZeroed(0x440); - gUnknown_0203CE34 = Alloc(0x800); - gUnknown_0203CE38 = AllocZeroed(0x800); + sSelectMenuTilesetBuffer = Alloc(0x440); + sSelectMonCardBgTilesetBuffer = AllocZeroed(0x440); + sSelectMenuTilemapBuffer = Alloc(0x800); + sSelectMonCardBgTilemapBuffer = AllocZeroed(0x800); ChangeBgX(0, 0, 0); ChangeBgY(0, 0, 0); ChangeBgX(1, 0, 0); @@ -1128,12 +1142,12 @@ static void CB2_InitSelectScreen(void) ResetSpriteData(); ResetTasks(); FreeAllSpritePalettes(); - CpuCopy16(gFrontierFactorySelectMenu_Gfx, gUnknown_0203CE2C, 0x440); - CpuCopy16(gUnknown_0861033C, gUnknown_0203CE30, 0x60); - LoadBgTiles(1, gUnknown_0203CE2C, 0x440, 0); - LoadBgTiles(3, gUnknown_0203CE30, 0x60, 0); - CpuCopy16(gFrontierFactorySelectMenu_Tilemap, gUnknown_0203CE34, 0x800); - LoadBgTilemap(1, gUnknown_0203CE34, 0x800, 0); + CpuCopy16(gFrontierFactorySelectMenu_Gfx, sSelectMenuTilesetBuffer, 0x440); + CpuCopy16(gUnknown_0861033C, sSelectMonCardBgTilesetBuffer, 0x60); + LoadBgTiles(1, sSelectMenuTilesetBuffer, 0x440, 0); + LoadBgTiles(3, sSelectMonCardBgTilesetBuffer, 0x60, 0); + CpuCopy16(gFrontierFactorySelectMenu_Tilemap, sSelectMenuTilemapBuffer, 0x800); + LoadBgTilemap(1, sSelectMenuTilemapBuffer, 0x800, 0); LoadPalette(gFrontierFactorySelectMenu_Pal, 0, 0x40); LoadPalette(gUnknown_0861046C, 0xF0, 8); LoadPalette(gUnknown_0861046C, 0xE0, 10); @@ -1143,7 +1157,7 @@ static void CB2_InitSelectScreen(void) gMain.state++; break; case 3: - SetBgTilemapBuffer(3, gUnknown_0203CE38); + SetBgTilemapBuffer(3, sSelectMonCardBgTilemapBuffer); CopyToBgTilemapBufferRect(3, gUnknown_0861023C, 11, 4, 8, 8); CopyToBgTilemapBufferRect(3, gUnknown_0861023C, 2, 4, 8, 8); CopyToBgTilemapBufferRect(3, gUnknown_0861023C, 20, 4, 8, 8); @@ -1405,10 +1419,10 @@ static void Task_FromSelectScreenToSummaryScreen(u8 taskId) DestroyTask(sFactorySelectScreen->fadeSpeciesNameTaskId); sub_819F444(sFactorySelectScreen->unk294[1], &sFactorySelectScreen->unk2A0); Select_DestroyAllSprites(); - FREE_AND_SET_NULL(gUnknown_0203CE2C); - FREE_AND_SET_NULL(gUnknown_0203CE30); - FREE_AND_SET_NULL(gUnknown_0203CE34); - FREE_AND_SET_NULL(gUnknown_0203CE38); + FREE_AND_SET_NULL(sSelectMenuTilesetBuffer); + FREE_AND_SET_NULL(sSelectMonCardBgTilesetBuffer); + FREE_AND_SET_NULL(sSelectMenuTilemapBuffer); + FREE_AND_SET_NULL(sSelectMonCardBgTilemapBuffer); FreeAllWindowBuffers(); gTasks[taskId].data[0] = 8; } @@ -1442,9 +1456,9 @@ static void Task_CloseSelectionScreen(u8 taskId) Select_CopyMonsToPlayerParty(); DestroyTask(sFactorySelectScreen->fadeSpeciesNameTaskId); Select_DestroyAllSprites(); - FREE_AND_SET_NULL(gUnknown_0203CE2C); - FREE_AND_SET_NULL(gUnknown_0203CE34); - FREE_AND_SET_NULL(gUnknown_0203CE38); + FREE_AND_SET_NULL(sSelectMenuTilesetBuffer); + FREE_AND_SET_NULL(sSelectMenuTilemapBuffer); + FREE_AND_SET_NULL(sSelectMonCardBgTilemapBuffer); FREE_AND_SET_NULL(sFactorySelectScreen); FreeAllWindowBuffers(); SetMainCallback2(CB2_ReturnToFieldContinueScript); @@ -1924,7 +1938,7 @@ static void Select_PrintMonCategory(void) } } -void sub_819BD70(void) +static void Summary_ShowMonSprite(void) { u8 monId = sFactorySelectScreen->cursorPos; struct Pokemon *mon = &sFactorySelectScreen->mons[monId].monData; @@ -1939,7 +1953,7 @@ void sub_819BD70(void) sFactorySelectScreen->unk2A0 = FALSE; } -void sub_819BE20(bool8 arg0) +static void sub_819BE20(bool8 arg0) { sFactorySelectScreen->unk2A0 = arg0; } @@ -2231,7 +2245,7 @@ static void Task_SelectFadeSpeciesName(u8 taskId) // Swap Screen's section begins here. -void Swap_CB2(void) +static void Swap_CB2(void) { AnimateSprites(); BuildOamBuffer(); @@ -2240,14 +2254,14 @@ void Swap_CB2(void) RunTasks(); } -void Swap_VblankCb(void) +static void Swap_VblankCb(void) { LoadOam(); ProcessSpriteCopyRequests(); TransferPlttBuffer(); } -void CopySwappedMonData(void) +static void CopySwappedMonData(void) { u8 happiness; @@ -2260,7 +2274,7 @@ void CopySwappedMonData(void) gSaveBlock2Ptr->frontier.field_E70[sFactorySwapScreen->playerMonId].abilityBit = GetBoxMonData(&gEnemyParty[sFactorySwapScreen->enemyMonId].box, MON_DATA_ALT_ABILITY, NULL); } -void Task_FromSwapScreenToSummaryScreen(u8 taskId) +static void Task_FromSwapScreenToSummaryScreen(u8 taskId) { switch (gTasks[taskId].data[0]) { @@ -2274,10 +2288,10 @@ void Task_FromSwapScreenToSummaryScreen(u8 taskId) DestroyTask(sFactorySwapScreen->fadeSpeciesNameTaskId); sub_819F444(sFactorySwapScreen->unk2C, &sFactorySwapScreen->unk30); Swap_DestroyAllSprites(); - FREE_AND_SET_NULL(gUnknown_0203CE40); - FREE_AND_SET_NULL(gUnknown_0203CE44); - FREE_AND_SET_NULL(gUnknown_0203CE48); - FREE_AND_SET_NULL(gUnknown_0203CE4C); + FREE_AND_SET_NULL(sSwapMenuTilesetBuffer); + FREE_AND_SET_NULL(sSwapMonCardBgTilesetBuffer); + FREE_AND_SET_NULL(sSwapMenuTilemapBuffer); + FREE_AND_SET_NULL(sSwapMonCardBgTilemapBuffer); FreeAllWindowBuffers(); gTasks[taskId].data[0] = 8; } @@ -2291,7 +2305,7 @@ void Task_FromSwapScreenToSummaryScreen(u8 taskId) } } -void Task_CloseSwapScreen(u8 taskId) +static void Task_CloseSwapScreen(u8 taskId) { if (sFactorySwapScreen->unk30 != TRUE) { @@ -2326,10 +2340,10 @@ void Task_CloseSwapScreen(u8 taskId) { DestroyTask(sFactorySwapScreen->fadeSpeciesNameTaskId); Swap_DestroyAllSprites(); - FREE_AND_SET_NULL(gUnknown_0203CE40); - FREE_AND_SET_NULL(gUnknown_0203CE44); - FREE_AND_SET_NULL(gUnknown_0203CE48); - FREE_AND_SET_NULL(gUnknown_0203CE4C); + FREE_AND_SET_NULL(sSwapMenuTilesetBuffer); + FREE_AND_SET_NULL(sSwapMonCardBgTilesetBuffer); + FREE_AND_SET_NULL(sSwapMenuTilemapBuffer); + FREE_AND_SET_NULL(sSwapMonCardBgTilemapBuffer); FREE_AND_SET_NULL(sFactorySwapScreen); FreeAllWindowBuffers(); SetMainCallback2(CB2_ReturnToFieldContinueScript); @@ -2340,7 +2354,7 @@ void Task_CloseSwapScreen(u8 taskId) } } -void Task_HandleSwapScreenYesNo(u8 taskId) +static void Task_HandleSwapScreenYesNo(u8 taskId) { u16 loPtr, hiPtr; @@ -2396,7 +2410,7 @@ void Task_HandleSwapScreenYesNo(u8 taskId) } } -void sub_819CBDC(u8 taskId) +static void sub_819CBDC(u8 taskId) { if (gTasks[taskId].data[1] == 1) { @@ -2413,7 +2427,7 @@ void sub_819CBDC(u8 taskId) } } -void sub_819CC24(u8 taskId) +static void sub_819CC24(u8 taskId) { if (gTasks[taskId].data[0] == 0) { @@ -2426,7 +2440,7 @@ void sub_819CC24(u8 taskId) } } -void sub_819CC74(u8 taskId) +static void sub_819CC74(u8 taskId) { sub_819F3F8(sFactorySwapScreen->unk2C, &sFactorySwapScreen->unk30, TRUE); if (gTasks[taskId].data[1] == 1) @@ -2444,7 +2458,7 @@ void sub_819CC74(u8 taskId) } } -void sub_819CCD4(u8 taskId) +static void sub_819CCD4(u8 taskId) { if (gTasks[taskId].data[0] == 0) { @@ -2458,7 +2472,7 @@ void sub_819CCD4(u8 taskId) } } -void Task_HandleSwapScreenMenu(u8 taskId) +static void Task_HandleSwapScreenMenu(u8 taskId) { switch (gTasks[taskId].data[0]) { @@ -2506,14 +2520,14 @@ void Task_HandleSwapScreenMenu(u8 taskId) } } -void Task_HandleSwapScreenChooseMons(u8 taskId) +static void Task_HandleSwapScreenChooseMons(u8 taskId) { switch (gTasks[taskId].data[0]) { case 0: if (!gPaletteFade.active) { - sFactorySwapScreen->unk22 = 1; + sFactorySwapScreen->unk22 = TRUE; gTasks[taskId].data[0] = 1; } break; @@ -2521,7 +2535,7 @@ void Task_HandleSwapScreenChooseMons(u8 taskId) if (gMain.newKeys & A_BUTTON) { PlaySE(SE_SELECT); - sFactorySwapScreen->unk22 = 0; + sFactorySwapScreen->unk22 = FALSE; Swap_PrintMonSpecies2(); sub_819EAC0(); Swap_RunActionFunc(taskId); @@ -2529,7 +2543,7 @@ void Task_HandleSwapScreenChooseMons(u8 taskId) else if (gMain.newKeys & B_BUTTON) { PlaySE(SE_SELECT); - sFactorySwapScreen->unk22 = 0; + sFactorySwapScreen->unk22 = FALSE; Swap_PrintMonSpecies2(); sub_819EAC0(); gTasks[taskId].data[6] = (u32)(sub_819CC24) >> 16; @@ -2566,7 +2580,7 @@ void Task_HandleSwapScreenChooseMons(u8 taskId) } } -void Task_SwapFadeSpeciesName(u8 taskId) +static void Task_SwapFadeSpeciesName(u8 taskId) { switch (gTasks[taskId].data[0]) { @@ -2621,7 +2635,7 @@ void Task_SwapFadeSpeciesName(u8 taskId) } } -void Task_SwapFadeSpeciesName2(u8 taskId) +static void Task_SwapFadeSpeciesName2(u8 taskId) { switch (gTasks[taskId].data[0]) { @@ -2652,7 +2666,7 @@ void Task_SwapFadeSpeciesName2(u8 taskId) } } -void sub_819D12C(u8 taskId) +static void sub_819D12C(u8 taskId) { s8 i; u8 var_2C; @@ -2728,7 +2742,7 @@ void sub_819D12C(u8 taskId) } } -void sub_819D324(u8 taskId) +static void sub_819D324(u8 taskId) { u8 i, j; s32 posX = 0; @@ -2840,7 +2854,7 @@ void sub_819D324(u8 taskId) } } -void sub_819D588(u8 taskId) +static void sub_819D588(u8 taskId) { u8 anotherTaskId; u16 loPtr, hiPtr; @@ -2918,7 +2932,7 @@ void sub_819D588(u8 taskId) } } -void sub_819D770(u8 taskId) +static void sub_819D770(u8 taskId) { u8 anotherTaskId; u16 loPtr, hiPtr; @@ -3010,7 +3024,7 @@ void sub_819D770(u8 taskId) case 8: Swap_PrintMonSpecies3(); sub_819EADC(); - sFactorySwapScreen->unk22 = 1; + sFactorySwapScreen->unk22 = TRUE; gTasks[taskId].data[0] = gTasks[taskId].data[5]; loPtr = gTasks[taskId].data[6]; hiPtr = gTasks[taskId].data[7]; @@ -3019,7 +3033,7 @@ void sub_819D770(u8 taskId) } } -void sub_819D9EC(u8 taskId) +static void sub_819D9EC(u8 taskId) { u8 i; if (sFactorySwapScreen->unk30 == TRUE) @@ -3074,7 +3088,7 @@ void sub_819D9EC(u8 taskId) } } -void Swap_InitStruct(void) +static void Swap_InitStruct(void) { if (sFactorySwapScreen == NULL) { @@ -3085,13 +3099,13 @@ void Swap_InitStruct(void) } } -void sub_819DC00(void) +void DoBattleFactorySwapScreen(void) { sFactorySwapScreen = NULL; SetMainCallback2(CB2_InitSwapScreen); } -void CB2_InitSwapScreen(void) +static void CB2_InitSwapScreen(void) { u8 taskId; @@ -3102,16 +3116,16 @@ void CB2_InitSwapScreen(void) SetVBlankCallback(NULL); CpuFill32(0, (void *)VRAM, VRAM_SIZE); ResetBgsAndClearDma3BusyFlags(0); - InitBgsFromTemplates(0, gUnknown_086108B8, ARRAY_COUNT(gUnknown_086108B8)); - InitWindows(gUnknown_086108C8); + InitBgsFromTemplates(0, sSwap_BgTemplates, ARRAY_COUNT(sSwap_BgTemplates)); + InitWindows(sSwap_WindowTemplates); DeactivateAllTextPrinters(); gMain.state++; break; case 1: - gUnknown_0203CE40 = Alloc(0x440); - gUnknown_0203CE44 = AllocZeroed(0x440); - gUnknown_0203CE48 = Alloc(0x800); - gUnknown_0203CE4C = AllocZeroed(0x800); + sSwapMenuTilesetBuffer = Alloc(0x440); + sSwapMonCardBgTilesetBuffer = AllocZeroed(0x440); + sSwapMenuTilemapBuffer = Alloc(0x800); + sSwapMonCardBgTilemapBuffer = AllocZeroed(0x800); ChangeBgX(0, 0, 0); ChangeBgY(0, 0, 0); ChangeBgX(1, 0, 0); @@ -3136,12 +3150,12 @@ void CB2_InitSwapScreen(void) ResetTasks(); FreeAllSpritePalettes(); ResetAllPicSprites(); - CpuCopy16(gFrontierFactorySelectMenu_Gfx, gUnknown_0203CE40, 0x440); - CpuCopy16(gUnknown_0861033C, gUnknown_0203CE44, 0x60); - LoadBgTiles(1, gUnknown_0203CE40, 0x440, 0); - LoadBgTiles(3, gUnknown_0203CE44, 0x60, 0); - CpuCopy16(gFrontierFactorySelectMenu_Tilemap, gUnknown_0203CE48, 0x800); - LoadBgTilemap(1, gUnknown_0203CE48, 0x800, 0); + CpuCopy16(gFrontierFactorySelectMenu_Gfx, sSwapMenuTilesetBuffer, 0x440); + CpuCopy16(gUnknown_0861033C, sSwapMonCardBgTilesetBuffer, 0x60); + LoadBgTiles(1, sSwapMenuTilesetBuffer, 0x440, 0); + LoadBgTiles(3, sSwapMonCardBgTilesetBuffer, 0x60, 0); + CpuCopy16(gFrontierFactorySelectMenu_Tilemap, sSwapMenuTilemapBuffer, 0x800); + LoadBgTilemap(1, sSwapMenuTilemapBuffer, 0x800, 0); LoadPalette(gFrontierFactorySelectMenu_Pal, 0, 0x40); LoadPalette(gUnknown_08610918, 0xF0, 10); LoadPalette(gUnknown_08610918, 0xE0, 10); @@ -3149,7 +3163,7 @@ void CB2_InitSwapScreen(void) gMain.state++; break; case 3: - SetBgTilemapBuffer(3, gUnknown_0203CE4C); + SetBgTilemapBuffer(3, sSwapMonCardBgTilemapBuffer); CopyToBgTilemapBufferRect(3, gUnknown_0861023C, 11, 4, 8, 8); CopyBgTilemapBufferToVram(3); gMain.state++; @@ -3247,13 +3261,7 @@ void CB2_InitSwapScreen(void) } } -extern const struct SpriteTemplate gUnknown_08610834; -extern const struct SpriteTemplate gUnknown_0861084C; -extern const struct SpriteTemplate gUnknown_08610864; -extern const struct SpriteTemplate gUnknown_0861087C; -extern const struct SpriteTemplate gUnknown_08610894; - -void Swap_InitAllSprites(void) +static void Swap_InitAllSprites(void) { u8 i; u8 x; @@ -3344,7 +3352,7 @@ void Swap_InitAllSprites(void) gSprites[sFactorySwapScreen->unk8[0][2]].invisible = 0; } -void Swap_DestroyAllSprites(void) +static void Swap_DestroyAllSprites(void) { u8 i, j; @@ -3365,7 +3373,7 @@ void Swap_DestroyAllSprites(void) } } -void Swap_HandleActionCursorChange(u8 cursorId) +static void Swap_HandleActionCursorChange(u8 cursorId) { if (cursorId < 3) { @@ -3380,7 +3388,7 @@ void Swap_HandleActionCursorChange(u8 cursorId) } } -void Swap_UpdateBallCursorPosition(s8 direction) +static void Swap_UpdateBallCursorPosition(s8 direction) { u8 cursorPos; PlaySE(SE_SELECT); @@ -3403,7 +3411,7 @@ void Swap_UpdateBallCursorPosition(s8 direction) Swap_HandleActionCursorChange(cursorPos); } -void Swap_UpdateActionCursorPosition(s8 direction) +static void Swap_UpdateActionCursorPosition(s8 direction) { u8 cursorPos; PlaySE(SE_SELECT); @@ -3430,7 +3438,7 @@ void Swap_UpdateActionCursorPosition(s8 direction) Swap_HandleActionCursorChange(cursorPos); } -void Swap_UpdateYesNoCursorPosition(s8 direction) +static void Swap_UpdateYesNoCursorPosition(s8 direction) { if (direction > 0) // Move cursor down. { @@ -3451,7 +3459,7 @@ void Swap_UpdateYesNoCursorPosition(s8 direction) gSprites[sFactorySwapScreen->menuCursor2SpriteId].pos1.y = (sFactorySwapScreen->yesNoCursorPos * 16) + 112; } -void Swap_UpdateMenuCursorPosition(s8 direction) +static void Swap_UpdateMenuCursorPosition(s8 direction) { PlaySE(SE_SELECT); if (direction > 0) // Move cursor down. @@ -3473,7 +3481,7 @@ void Swap_UpdateMenuCursorPosition(s8 direction) gSprites[sFactorySwapScreen->menuCursor2SpriteId].pos1.y = (sFactorySwapScreen->menuCursorPos * 16) + 112; } -void sub_819E838(u8 arg0) +static void sub_819E838(u8 arg0) { u8 i; @@ -3494,7 +3502,7 @@ void sub_819E838(u8 arg0) } } -void sub_819E8EC(void) +static void sub_819E8EC(void) { u8 i; @@ -3506,7 +3514,7 @@ void sub_819E8EC(void) } } -void Swap_ShowMenuOptions(void) +static void Swap_ShowMenuOptions(void) { if (sFactorySwapScreen->fromSummaryScreen == TRUE) sFactorySwapScreen->fromSummaryScreen = FALSE; @@ -3524,7 +3532,7 @@ void Swap_ShowMenuOptions(void) Swap_PrintMenuOptions(); } -void Swap_ShowYesNoOptions(void) +static void Swap_ShowYesNoOptions(void) { sFactorySwapScreen->yesNoCursorPos = 0; @@ -3539,7 +3547,7 @@ void Swap_ShowYesNoOptions(void) Swap_PrintYesNoOptions(); } -void sub_819EA64(u8 windowId) +static void sub_819EA64(u8 windowId) { gSprites[sFactorySwapScreen->menuCursor1SpriteId].invisible = 1; gSprites[sFactorySwapScreen->menuCursor2SpriteId].invisible = 1; @@ -3548,21 +3556,21 @@ void sub_819EA64(u8 windowId) ClearWindowTilemap(windowId); } -void sub_819EAC0(void) +static void sub_819EAC0(void) { PutWindowTilemap(1); FillWindowPixelBuffer(1, 0); CopyWindowToVram(1, 2); } -void sub_819EADC(void) +static void sub_819EADC(void) { PutWindowTilemap(7); FillWindowPixelBuffer(7, 0); CopyWindowToVram(7, 2); } -void sub_819EAF8(void) +static void sub_819EAF8(void) { sub_819EAC0(); PutWindowTilemap(5); @@ -3570,14 +3578,14 @@ void sub_819EAF8(void) CopyWindowToVram(5, 2); } -void Swap_PrintPkmnSwap(void) +static void Swap_PrintPkmnSwap(void) { FillWindowPixelBuffer(0, 0x11); AddTextPrinterParameterized(0, 1, gText_PkmnSwap, 2, 1, 0, NULL); CopyWindowToVram(0, 3); } -void Swap_PrintMonSpecies(void) +static void Swap_PrintMonSpecies(void) { u16 species; u8 x; @@ -3601,14 +3609,14 @@ void Swap_PrintMonSpecies(void) } } -void Swap_PrintOnInfoWindow(const u8 *str) +static void Swap_PrintOnInfoWindow(const u8 *str) { FillWindowPixelBuffer(2, 0); AddTextPrinterParameterized(2, 1, str, 2, 5, 0, NULL); CopyWindowToVram(2, 2); } -void Swap_PrintMenuOptions(void) +static void Swap_PrintMenuOptions(void) { PutWindowTilemap(3); FillWindowPixelBuffer(3, 0); @@ -3618,7 +3626,7 @@ void Swap_PrintMenuOptions(void) CopyWindowToVram(3, 3); } -void Swap_PrintYesNoOptions(void) +static void Swap_PrintYesNoOptions(void) { PutWindowTilemap(4); FillWindowPixelBuffer(4, 0); @@ -3627,13 +3635,13 @@ void Swap_PrintYesNoOptions(void) CopyWindowToVram(4, 3); } -void Swap_PrintActionString(const u8 *str, u32 y, u32 windowId) +static void Swap_PrintActionString(const u8 *str, u32 y, u32 windowId) { s32 x = GetStringRightAlignXOffset(0, str, 0x46); AddTextPrinterParameterized3(windowId, 0, x, y, gUnknown_08610922, 0, str); } -void Swap_PrintActionStrings(void) +static void Swap_PrintActionStrings(void) { FillWindowPixelBuffer(5, 0); switch (sFactorySwapScreen->inEnemyScreen) @@ -3647,7 +3655,7 @@ void Swap_PrintActionStrings(void) CopyWindowToVram(5, 3); } -void Swap_PrintActionStrings2(void) +static void Swap_PrintActionStrings2(void) { FillWindowPixelBuffer(3, 0); switch (sFactorySwapScreen->inEnemyScreen) @@ -3661,7 +3669,7 @@ void Swap_PrintActionStrings2(void) CopyWindowToVram(3, 3); } -void Swap_PrintOneActionString(u8 which) +static void Swap_PrintOneActionString(u8 which) { switch (which) { @@ -3676,7 +3684,7 @@ void Swap_PrintOneActionString(u8 which) CopyWindowToVram(3, 3); } -void Swap_PrintMonSpecies2(void) +static void Swap_PrintMonSpecies2(void) { u16 species; u8 x; @@ -3709,7 +3717,7 @@ void Swap_PrintMonSpecies2(void) } } -void Swap_PrintMonSpecies3(void) +static void Swap_PrintMonSpecies3(void) { u16 species; u8 x; @@ -3735,7 +3743,7 @@ void Swap_PrintMonSpecies3(void) } } -void Swap_PrintMonCategory(void) +static void Swap_PrintMonCategory(void) { u16 species; u8 text[30]; @@ -3761,10 +3769,7 @@ void Swap_PrintMonCategory(void) } } -extern const struct SwapActionIdAndFunc gUnknown_08610928[4]; -extern const struct SwapActionIdAndFunc gUnknown_08610948[5]; - -void Swap_InitActions(u8 id) +static void Swap_InitActions(u8 id) { if (sFactorySwapScreen->fromSummaryScreen != TRUE) { @@ -3773,26 +3778,26 @@ void Swap_InitActions(u8 id) case ACTIONS_PLAYER_SCREEN: sFactorySwapScreen->inEnemyScreen = FALSE; sFactorySwapScreen->cursorPos = 0; - sFactorySwapScreen->actionsCount = ARRAY_COUNT(gUnknown_08610928); - sFactorySwapScreen->actionsData = gUnknown_08610928; + sFactorySwapScreen->actionsCount = ARRAY_COUNT(sSwap_PlayerScreenActions); + sFactorySwapScreen->actionsData = sSwap_PlayerScreenActions; break; case ACTIONS_ENEMY_SCREEN: sFactorySwapScreen->inEnemyScreen = TRUE; sFactorySwapScreen->cursorPos = 0; - sFactorySwapScreen->actionsCount = ARRAY_COUNT(gUnknown_08610948); - sFactorySwapScreen->actionsData = gUnknown_08610948; + sFactorySwapScreen->actionsCount = ARRAY_COUNT(sSwap_EnemyScreenActions); + sFactorySwapScreen->actionsData = sSwap_EnemyScreenActions; break; } } } -void Swap_RunMenuOptionFunc(u8 taskId) +static void Swap_RunMenuOptionFunc(u8 taskId) { - gUnknown_03001280 = sSwap_MenuOptionFuncs[sFactorySwapScreen->menuCursorPos]; - gUnknown_03001280(taskId); + sSwap_CurrentTableFunc = sSwap_MenuOptionFuncs[sFactorySwapScreen->menuCursorPos]; + sSwap_CurrentTableFunc(taskId); } -void sub_819F0CC(u8 taskId) +static void sub_819F0CC(u8 taskId) { sub_819F3F8(sFactorySwapScreen->unk2C, &sFactorySwapScreen->unk30, TRUE); sFactorySwapScreen->playerMonId = sFactorySwapScreen->cursorPos; @@ -3801,13 +3806,13 @@ void sub_819F0CC(u8 taskId) gTasks[taskId].func = sub_819D9EC; } -void sub_819F114(u8 taskId) +static void sub_819F114(u8 taskId) { gTasks[taskId].data[0] = 6; gTasks[taskId].func = Task_FromSwapScreenToSummaryScreen; } -void sub_819F134(u8 taskId) +static void sub_819F134(u8 taskId) { sub_819F3F8(sFactorySwapScreen->unk2C, &sFactorySwapScreen->unk30, TRUE); sub_819EA64(3); @@ -3818,13 +3823,13 @@ void sub_819F134(u8 taskId) gTasks[taskId].func = sub_819D770; } -void Swap_RunActionFunc(u8 taskId) +static void Swap_RunActionFunc(u8 taskId) { - gUnknown_03001280 = sFactorySwapScreen->actionsData[sFactorySwapScreen->cursorPos].func; - gUnknown_03001280(taskId); + sSwap_CurrentTableFunc = sFactorySwapScreen->actionsData[sFactorySwapScreen->cursorPos].func; + sSwap_CurrentTableFunc(taskId); } -void sub_819F1AC(u8 taskId) +static void Swap_ActionCancel(u8 taskId) { gTasks[taskId].data[6] = (u32)(sub_819CC24) >> 0x10; gTasks[taskId].data[7] = (u32)(sub_819CC24); @@ -3833,7 +3838,7 @@ void sub_819F1AC(u8 taskId) gTasks[taskId].func = sub_819D588; } -void sub_819F1DC(u8 taskId) +static void Swap_ActionPkmnForSwap(u8 taskId) { gTasks[taskId].data[6] = (u32)(sub_819D9EC) >> 0x10; gTasks[taskId].data[7] = (u32)(sub_819D9EC); @@ -3842,7 +3847,7 @@ void sub_819F1DC(u8 taskId) gTasks[taskId].func = sub_819D588; } -void sub_819F20C(u8 taskId) +static void Swap_ActionMon(u8 taskId) { if (!sFactorySwapScreen->inEnemyScreen) { @@ -3868,7 +3873,7 @@ void sub_819F20C(u8 taskId) gTasks[taskId].func = sub_819D588; } -void sub_819F2B4(u8 *arg0, bool8 *arg1, bool8 swapScreen) +static void sub_819F2B4(u8 *arg0, bool8 *arg1, bool8 swapScreen) { *arg0 = CreateSprite(&gUnknown_08610894, 120, 64, 1); gSprites[*arg0].callback = sub_819F600; @@ -3876,7 +3881,7 @@ void sub_819F2B4(u8 *arg0, bool8 *arg1, bool8 swapScreen) *arg1 = TRUE; } -void Swap_ShowSummaryMonSprite(void) +static void Swap_ShowSummaryMonSprite(void) { struct Pokemon *mon; u16 species; @@ -3897,7 +3902,7 @@ void Swap_ShowSummaryMonSprite(void) gSprites[sFactorySwapScreen->unk2C.field1].invisible = 1; } -void sub_819F3F8(struct UnkFactoryStruct arg0, bool8 *arg1, bool8 swapScreen) +static void sub_819F3F8(struct UnkFactoryStruct arg0, bool8 *arg1, bool8 swapScreen) { u8 taskId; @@ -3909,7 +3914,7 @@ void sub_819F3F8(struct UnkFactoryStruct arg0, bool8 *arg1, bool8 swapScreen) *arg1 = TRUE; } -void sub_819F444(struct UnkFactoryStruct arg0, bool8 *arg1) +static void sub_819F444(struct UnkFactoryStruct arg0, bool8 *arg1) { FreeAndDestroyMonPicSprite(arg0.field0); FreeOamMatrix(gSprites[arg0.field1].oam.matrixNum); @@ -3917,7 +3922,7 @@ void sub_819F444(struct UnkFactoryStruct arg0, bool8 *arg1) *arg1 = FALSE; } -void Task_SwapCantHaveSameMons(u8 taskId) +static void Task_SwapCantHaveSameMons(u8 taskId) { if (sFactorySwapScreen->unk30 == TRUE) return; @@ -3952,14 +3957,14 @@ void Task_SwapCantHaveSameMons(u8 taskId) case 4: Swap_PrintMonSpecies3(); sub_819EADC(); - sFactorySwapScreen->unk22 = 1; + sFactorySwapScreen->unk22 = TRUE; gTasks[taskId].data[0] = gTasks[taskId].data[5]; gTasks[taskId].func = Task_HandleSwapScreenChooseMons; break; } } -bool8 Swap_AlreadyHasSameSpecies(u8 monId) +static bool8 Swap_AlreadyHasSameSpecies(u8 monId) { u8 i; u16 species = GetMonData(&gEnemyParty[monId], MON_DATA_SPECIES, NULL); @@ -3972,7 +3977,7 @@ bool8 Swap_AlreadyHasSameSpecies(u8 monId) return FALSE; } -void sub_819F600(struct Sprite *sprite) +static void sub_819F600(struct Sprite *sprite) { u8 taskId; @@ -3985,3 +3990,124 @@ void sub_819F600(struct Sprite *sprite) sprite->callback = SpriteCallbackDummy; } } + +static void sub_819F654(struct Sprite *sprite) +{ + if (sprite->affineAnimEnded) + { + FreeOamMatrix(sprite->oam.matrixNum); + if (sprite->data[7] == TRUE) + sFactorySwapScreen->unk30 = FALSE; + else + sub_819BE20(FALSE); + DestroySprite(sprite); + } +} + +static void sub_819F69C(u8 taskId) +{ + struct Task *task = &gTasks[taskId]; + switch (task->data[0]) + { + case 0: + task->data[3] = 88; + task->data[24] = 152; // BUG: writing outside the array's bounds. + task->data[5] = 64; + task->data[8] = 65; + SetGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_WIN0_ON); + SetGpuReg(REG_OFFSET_WIN0H, WIN_RANGE(task->data[3], task->data[24])); + SetGpuReg(REG_OFFSET_WIN0V, WIN_RANGE(task->data[5], task->data[8])); + SetGpuReg(REG_OFFSET_WININ, WININ_WIN0_BG_ALL | WININ_WIN0_CLR | WININ_WIN0_OBJ); + SetGpuReg(REG_OFFSET_WINOUT, WINOUT_WIN01_BG0 | WINOUT_WIN01_BG1 | WINOUT_WIN01_BG2 | WINOUT_WIN01_CLR | WINOUT_WIN01_OBJ); + break; + case 1: + ShowBg(3); + SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_TGT1_BG3 | BLDCNT_EFFECT_BLEND | BLDCNT_TGT2_BG1 | BLDCNT_TGT2_OBJ); + SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(11, 4)); + break; + case 2: + task->data[5] -= 4; + task->data[8] += 4; + if (task->data[5] <= 32 || task->data[8] >= 96) + { + task->data[5] = 32; + task->data[8] = 96; + } + SetGpuReg(REG_OFFSET_WIN0V, WIN_RANGE(task->data[5], task->data[8])); + if (task->data[5] != 32) + return; + break; + default: + DestroyTask(taskId); + // UB: Should not use the task after it has been deleted. + if (gTasks[taskId].data[7] == TRUE) + Swap_ShowMonSprite(); + else + Summary_ShowMonSprite(); + return; + } + task->data[0]++; +} + +static void sub_819F7B4(u8 taskId) +{ + struct Task *task = &gTasks[taskId]; + switch (task->data[0]) + { + default: + HideBg(3); + gSprites[task->data[6]].data[7] = task->data[7]; + gSprites[task->data[6]].invisible = 0; + gSprites[task->data[6]].callback = sub_819F654; + StartSpriteAffineAnim(&gSprites[task->data[6]], 1); + ClearGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_WIN0_ON); + DestroyTask(taskId); + break; + case 0: + task->data[3] = 88; + task->data[24] = 152; // BUG: writing outside the array's bounds. + task->data[5] = 32; + task->data[8] = 96; + SetGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_WIN0_ON); + SetGpuReg(REG_OFFSET_WIN0H, WIN_RANGE(task->data[3], task->data[24])); + SetGpuReg(REG_OFFSET_WIN0V, WIN_RANGE(task->data[5], task->data[8])); + SetGpuReg(REG_OFFSET_WININ, WININ_WIN0_BG_ALL | WININ_WIN0_CLR | WININ_WIN0_OBJ); + SetGpuReg(REG_OFFSET_WINOUT, WINOUT_WIN01_BG0 | WINOUT_WIN01_BG1 | WINOUT_WIN01_BG2 | WINOUT_WIN01_CLR | WINOUT_WIN01_OBJ); + task->data[0]++; + break; + case 1: + task->data[5] += 4; + task->data[8] -= 4; + if (task->data[5] >= 64 || task->data[8] <= 65) + { + task->data[5] = 64; + task->data[8] = 65; + } + SetGpuReg(REG_OFFSET_WIN0V, WIN_RANGE(task->data[5], task->data[8])); + if (task->data[5] == 64) + task->data[0]++; + break; + } +} + +static void Swap_ShowMonSprite(void) +{ + struct Pokemon *mon; + u16 species; + u32 personality, otId; + + if (!sFactorySwapScreen->inEnemyScreen) + mon = &gPlayerParty[sFactorySwapScreen->cursorPos]; + else + mon = &gEnemyParty[sFactorySwapScreen->cursorPos]; + + species = GetMonData(mon, MON_DATA_SPECIES, NULL); + personality = GetMonData(mon, MON_DATA_PERSONALITY, NULL); + otId = GetMonData(mon, MON_DATA_OT_ID, NULL); + + sFactorySwapScreen->unk2C.field0 = CreateMonPicSprite_HandleDeoxys(species, otId, personality, TRUE, 88, 32, 15, 0xFFFF); + gSprites[sFactorySwapScreen->unk2C.field0].centerToCornerVecX = 0; + gSprites[sFactorySwapScreen->unk2C.field0].centerToCornerVecY = 0; + + sFactorySwapScreen->unk30 = FALSE; +} diff --git a/src/battle_tent.c b/src/battle_tent.c index 516f3fc4d..e30cac386 100644 --- a/src/battle_tent.c +++ b/src/battle_tent.c @@ -1,13 +1,15 @@ #include "global.h" +#include "battle_tent.h" #include "overworld.h" #include "event_data.h" #include "region_map.h" #include "battle.h" #include "battle_setup.h" #include "battle_tower.h" -#include "battle_frontier_2.h" #include "random.h" #include "item.h" +#include "battle_factory.h" +#include "battle_frontier_2.h" #include "constants/items.h" #include "constants/region_map_sections.h" @@ -15,35 +17,40 @@ extern const struct BattleFrontierTrainer gSlateportBattleTentTrainers[]; extern const struct FacilityMon gSlateportBattleTentMons[]; extern const u16 gBattleFrontierHeldItems[]; +extern u16 gUnknown_03006298[]; + // This file's functions. -void sub_81B99D4(void); -void sub_81B9A28(void); -void sub_81B9A44(void); -void sub_81B9A60(void); -void sub_81B9A90(void); -void sub_81B9ABC(void); -void sub_81B9B00(void); -void sub_81B9B28(void); -void sub_81B9BA0(void); -void sub_81B9BF4(void); -void sub_81B9C10(void); -void sub_81B9C2C(void); -void sub_81B9C70(void); -void sub_81B9C98(void); -void sub_81B9CF0(void); -void sub_81B9D28(void); -void sub_81B9D7C(void); -void sub_81B9D98(void); -void sub_81B9DB4(void); -void sub_81B9DF8(void); -void sub_81B9E20(void); -void sub_81B9E78(void); -void sub_81B9E88(void); -void sub_81BA040(void); -void sub_81B9EC0(void); +static void sub_81B99D4(void); +static void sub_81B9A28(void); +static void sub_81B9A44(void); +static void sub_81B9A60(void); +static void sub_81B9A90(void); +static void sub_81B9ABC(void); +static void sub_81B9B00(void); +static void sub_81B9B28(void); +static void sub_81B9BA0(void); +static void sub_81B9BF4(void); +static void sub_81B9C10(void); +static void sub_81B9C2C(void); +static void sub_81B9C70(void); +static void sub_81B9C98(void); +static void sub_81B9CF0(void); +static void sub_81B9D28(void); +static void sub_81B9D7C(void); +static void sub_81B9D98(void); +static void sub_81B9DB4(void); +static void sub_81B9DF8(void); +static void sub_81B9E20(void); +static void sub_81B9E78(void); +static void sub_81B9E88(void); +static void sub_81BA040(void); +static void sub_81B9EC0(void); + +// IWRAM bss +static IWRAM_DATA u16 sRandMonSetId; // const rom data -void (*const gUnknown_086160B4[])(void) = +void static (*const gUnknown_086160B4[])(void) = { sub_81B99D4, sub_81B9A28, @@ -57,7 +64,7 @@ void (*const gUnknown_086160B4[])(void) = static const u16 sVerdanturfTentRewards[] = {ITEM_NEST_BALL}; -void (*const gUnknown_086160D8[])(void) = +void static (*const gUnknown_086160D8[])(void) = { sub_81B9BA0, sub_81B9BF4, @@ -70,7 +77,7 @@ void (*const gUnknown_086160D8[])(void) = static const u16 sFallarborTentRewards[] = {ITEM_HYPER_POTION}; -void (*const gUnknown_086160F8[])(void) = +void static (*const gUnknown_086160F8[])(void) = { sub_81B9D28, sub_81B9D7C, @@ -92,7 +99,7 @@ void sub_81B99B4(void) gUnknown_086160B4[gSpecialVar_0x8004](); } -void sub_81B99D4(void) +static void sub_81B99D4(void) { gSaveBlock2Ptr->frontier.field_CA8 = 0; gSaveBlock2Ptr->frontier.field_CB2 = 0; @@ -100,29 +107,29 @@ void sub_81B99D4(void) saved_warp2_set(0, gSaveBlock1Ptr->location.mapGroup, gSaveBlock1Ptr->location.mapNum, -1); } -void sub_81B9A28(void) +static void sub_81B9A28(void) { gSpecialVar_Result = gSaveBlock2Ptr->frontier.field_E6A; } -void sub_81B9A44(void) +static void sub_81B9A44(void) { gSaveBlock2Ptr->frontier.field_E6A = gSpecialVar_0x8006; } -void sub_81B9A60(void) +static void sub_81B9A60(void) { gTrainerBattleOpponent_A = (u32)((Random() % 255) * 5) / 64; sub_8162614(gTrainerBattleOpponent_A, 0); } -void sub_81B9A90(void) +static void sub_81B9A90(void) { if (gTrainerBattleOpponent_A < 300) ConvertBattleFrontierTrainerSpeechToString(gFacilityTrainers[gTrainerBattleOpponent_A].speechBefore); } -void sub_81B9ABC(void) +static void sub_81B9ABC(void) { gSaveBlock2Ptr->frontier.field_CA8 = gSpecialVar_0x8005; VarSet(VAR_TEMP_0, 0); @@ -130,12 +137,12 @@ void sub_81B9ABC(void) sub_81A4C30(); } -void sub_81B9B00(void) +static void sub_81B9B00(void) { gSaveBlock2Ptr->frontier.field_E6A = sVerdanturfTentRewards[Random() % ARRAY_COUNT(sVerdanturfTentRewards)]; } -void sub_81B9B28(void) +static void sub_81B9B28(void) { if (AddBagItem(gSaveBlock2Ptr->frontier.field_E6A, 1) == TRUE) { @@ -154,7 +161,7 @@ void sub_81B9B80(void) gUnknown_086160D8[gSpecialVar_0x8004](); } -void sub_81B9BA0(void) +static void sub_81B9BA0(void) { gSaveBlock2Ptr->frontier.field_CA8 = 0; gSaveBlock2Ptr->frontier.field_CB2 = 0; @@ -162,17 +169,17 @@ void sub_81B9BA0(void) saved_warp2_set(0, gSaveBlock1Ptr->location.mapGroup, gSaveBlock1Ptr->location.mapNum, -1); } -void sub_81B9BF4(void) +static void sub_81B9BF4(void) { gSpecialVar_Result = gSaveBlock2Ptr->frontier.field_E6C; } -void sub_81B9C10(void) +static void sub_81B9C10(void) { gSaveBlock2Ptr->frontier.field_E6C = gSpecialVar_0x8006; } -void sub_81B9C2C(void) +static void sub_81B9C2C(void) { gSaveBlock2Ptr->frontier.field_CA8 = gSpecialVar_0x8005; VarSet(VAR_TEMP_0, 0); @@ -180,12 +187,12 @@ void sub_81B9C2C(void) sub_81A4C30(); } -void sub_81B9C70(void) +static void sub_81B9C70(void) { gSaveBlock2Ptr->frontier.field_E6C = sFallarborTentRewards[Random() % ARRAY_COUNT(sFallarborTentRewards)]; } -void sub_81B9C98(void) +static void sub_81B9C98(void) { if (AddBagItem(gSaveBlock2Ptr->frontier.field_E6C, 1) == TRUE) { @@ -199,7 +206,7 @@ void sub_81B9C98(void) } } -void sub_81B9CF0(void) +static void sub_81B9CF0(void) { GetFrontierTrainerName(gStringVar1, gTrainerBattleOpponent_A); } @@ -209,7 +216,7 @@ void sub_81B9D08(void) gUnknown_086160F8[gSpecialVar_0x8004](); } -void sub_81B9D28(void) +static void sub_81B9D28(void) { gSaveBlock2Ptr->frontier.field_CA8 = 0; gSaveBlock2Ptr->frontier.field_CB2 = 0; @@ -217,17 +224,17 @@ void sub_81B9D28(void) saved_warp2_set(0, gSaveBlock1Ptr->location.mapGroup, gSaveBlock1Ptr->location.mapNum, -1); } -void sub_81B9D7C(void) +static void sub_81B9D7C(void) { gSpecialVar_Result = gSaveBlock2Ptr->frontier.field_E6E; } -void sub_81B9D98(void) +static void sub_81B9D98(void) { gSaveBlock2Ptr->frontier.field_E6E = gSpecialVar_0x8006; } -void sub_81B9DB4(void) +static void sub_81B9DB4(void) { gSaveBlock2Ptr->frontier.field_CA8 = gSpecialVar_0x8005; VarSet(VAR_TEMP_0, 0); @@ -235,12 +242,12 @@ void sub_81B9DB4(void) sub_81A4C30(); } -void sub_81B9DF8(void) +static void sub_81B9DF8(void) { gSaveBlock2Ptr->frontier.field_E6E = sSlateportTentRewards[Random() % ARRAY_COUNT(sSlateportTentRewards)]; } -void sub_81B9E20(void) +static void sub_81B9E20(void) { if (AddBagItem(gSaveBlock2Ptr->frontier.field_E6E, 1) == TRUE) { @@ -254,15 +261,15 @@ void sub_81B9E20(void) } } -void sub_81B9E78(void) +static void sub_81B9E78(void) { ZeroPlayerPartyMons(); - sub_819A4F8(); + DoBattleFactorySelectScreen(); } -void sub_81B9E88(void) +static void sub_81B9E88(void) { - sub_819DC00(); + DoBattleFactorySwapScreen(); } bool8 sub_81B9E94(void) @@ -273,7 +280,7 @@ bool8 sub_81B9E94(void) // This function was written very...oddly. #ifdef NONMATCHING -void sub_81B9EC0(void) +static void sub_81B9EC0(void) { s32 i, j; u16 currMonId = 0, currSpecies = 0; @@ -335,7 +342,7 @@ void sub_81B9EC0(void) } #else NAKED -void sub_81B9EC0(void) +static void sub_81B9EC0(void) { asm_unified("\n\ push {r4-r7,lr}\n\ @@ -526,3 +533,74 @@ _081BA024:\n\ "); } #endif // NONMATCHING + +static void sub_81BA040(void) +{ + u16 trainerId; + s32 i, j, k; + register const u16 *monSetsPool asm("r9"); // Fix me. Compiler insists on moving that variable into stack. + u16 species[3]; + u16 heldItems[3]; + s32 monPoolCount = 0; + + gFacilityTrainers = gSlateportBattleTentTrainers; + gFacilityTrainerMons = gSlateportBattleTentMons; + + while (1) + { + do + { + trainerId = Random() % 30; + for (i = 0; i < gSaveBlock2Ptr->frontier.field_CB2; i++) + { + if (gSaveBlock2Ptr->frontier.field_CB4[i] == trainerId) + break; + } + } while (i != gSaveBlock2Ptr->frontier.field_CB2); + + gTrainerBattleOpponent_A = trainerId; + while (gFacilityTrainers[gTrainerBattleOpponent_A].btMonPool[monPoolCount] != 0xFFFF) + monPoolCount++; + if (monPoolCount > 8) + break; + monPoolCount = 0; + } + + if (gSaveBlock2Ptr->frontier.field_CB2 < 2) + gSaveBlock2Ptr->frontier.field_CB4[gSaveBlock2Ptr->frontier.field_CB2] = gTrainerBattleOpponent_A; + + monSetsPool = gFacilityTrainers[gTrainerBattleOpponent_A].btMonPool; + i = 0; + while (i != 3) + { + sRandMonSetId = monSetsPool[Random() % monPoolCount]; + for (j = 0; j < 6; j++) + { + if (gFacilityTrainerMons[sRandMonSetId].species == gFacilityTrainerMons[gSaveBlock2Ptr->frontier.field_E70[j].monId].species) + break; + } + if (j != 6) + continue; + + for (k = 0; k < i; k++) + { + if (species[k] == gFacilityTrainerMons[sRandMonSetId].species) + break; + } + if (k != i) + continue; + + for (k = 0; k < i; k++) + { + if (heldItems[k] != 0 && heldItems[k] == gBattleFrontierHeldItems[gFacilityTrainerMons[sRandMonSetId].itemTableId]) + break; + } + if (k != i) + continue; + + species[i] = gFacilityTrainerMons[sRandMonSetId].species; + heldItems[i] = gBattleFrontierHeldItems[gFacilityTrainerMons[sRandMonSetId].itemTableId]; + gUnknown_03006298[i] = sRandMonSetId; + i++; + } +} diff --git a/src/hall_of_fame.c b/src/hall_of_fame.c index b739ba66d..522d11d4f 100644 --- a/src/hall_of_fame.c +++ b/src/hall_of_fame.c @@ -28,6 +28,7 @@ #include "overworld.h" #include "menu.h" #include "trainer_pokemon_sprites.h" +#include "data2.h" struct HallofFameMon { @@ -57,10 +58,6 @@ static EWRAM_DATA struct HofGfx *sHofGfxPtr = NULL; extern bool8 gHasHallOfFameRecords; extern struct MusicPlayerInfo gMPlayInfo_BGM; -extern MainCallback gGameContinueCallback; -extern u32 gDamagedSaveSectors; -extern u8 gReservedSpritePaletteCount; -extern const u8 gSpeciesNames[][11]; #define HALL_OF_FAME_MAX_TEAMS 50 @@ -84,10 +81,6 @@ extern const u8 gContestConfetti_Gfx[]; extern const u8 gContestConfetti_Pal[]; extern void sub_8175620(void); -extern u8 TrySavingData(u8); -extern void sub_8197434(u8, u8); -extern u16 sub_818D97C(u8 playerGender, u8); -extern void sub_8198204(u8 *dst, const u8 *src, u8, u8, u8); extern bool8 sub_80F9C30(void); extern void sub_8198314(void); extern void ReturnFromHallOfFamePC(void); @@ -182,20 +175,18 @@ static const u8 sUnknown_085E5388[] = {0, 1, 2, 0}; static const u8 sUnknown_085E538C[] = {0, 2, 3, 0, 4, 5, 0, 0}; -static const struct CompressedSpriteSheet sHallOfFame_ConfettiSpriteSheet = +static const struct CompressedSpriteSheet sHallOfFame_ConfettiSpriteSheet[] = { - gContestConfetti_Gfx, 0x220, 1001 + {gContestConfetti_Gfx, 0x220, 1001}, + {}, }; -static const u8 sUnused0[8] = {}; - -static const struct CompressedSpritePalette sHallOfFame_ConfettiSpritePalette = +static const struct CompressedSpritePalette sHallOfFame_ConfettiSpritePalette[] = { - gContestConfetti_Pal, 1001 + {gContestConfetti_Pal, 1001}, + {}, }; -static const u8 sUnused1[8] = {}; - static const s16 sHallOfFame_MonFullTeamPositions[6][4] = { {120, 210, 120, 40}, @@ -610,7 +601,7 @@ static void Task_Hof_DisplayMon(u8 taskId) gSprites[spriteId].tSpecies = currMon->species; gSprites[spriteId].callback = SpriteCB_GetOnScreenAndAnimate; gTasks[taskId].tMonSpriteId(currMonId) = spriteId; - sub_8197434(0, 1); + sub_8197434(0, TRUE); gTasks[taskId].func = Task_Hof_PrintMonInfoAfterAnimating; } @@ -964,9 +955,9 @@ static void Task_HofPC_DrawSpritesPrintText(u8 taskId) StringExpandPlaceholders(gStringVar4, gText_HOFNumber); if (gTasks[taskId].tCurrTeamNo <= 0) - sub_8198204(gStringVar4, gText_PickCancel, 0, 0, 1); + sub_8198204(gStringVar4, gText_PickCancel, 0, 0, TRUE); else - sub_8198204(gStringVar4, gText_PickNextCancel, 0, 0, 1); + sub_8198204(gStringVar4, gText_PickNextCancel, 0, 0, TRUE); gTasks[taskId].func = Task_HofPC_PrintMonInfo; } @@ -1300,8 +1291,8 @@ static void sub_8174F70(void) ResetAllPicSprites(); FreeAllSpritePalettes(); gReservedSpritePaletteCount = 8; - LoadCompressedObjectPic(&sHallOfFame_ConfettiSpriteSheet); - LoadCompressedObjectPalette(&sHallOfFame_ConfettiSpritePalette); + LoadCompressedObjectPic(sHallOfFame_ConfettiSpriteSheet); + LoadCompressedObjectPalette(sHallOfFame_ConfettiSpritePalette); } static void sub_8174FAC(void) @@ -1517,8 +1508,8 @@ static void sub_8175364(u8 taskId) gSpecialVar_0x8004 = var; gSpecialVar_0x8005 = 0xFFFF; } - LoadCompressedObjectPic(&sHallOfFame_ConfettiSpriteSheet); - LoadCompressedObjectPalette(&sHallOfFame_ConfettiSpritePalette); + LoadCompressedObjectPic(sHallOfFame_ConfettiSpriteSheet); + LoadCompressedObjectPalette(sHallOfFame_ConfettiSpritePalette); data[0]++; break; case 1: diff --git a/src/save.c b/src/save.c index 81731692e..68427c4c3 100644 --- a/src/save.c +++ b/src/save.c @@ -9,8 +9,6 @@ // for the chunk declarations -extern struct SaveSectionLocation gRamSaveSectionLocations[0xE]; -extern u16 gUnknown_03006294; extern bool8 gSoftResetDisabled; extern u32 gUnknown_0203CF5C; @@ -83,6 +81,9 @@ u16 gUnknown_03006208; u16 gSaveUnusedVar; u16 gSaveFileStatus; void (*gGameContinueCallback)(void); +struct SaveSectionLocation gRamSaveSectionLocations[0xE]; +u16 gSaveUnusedVar2; +u16 gUnknown_03006294; EWRAM_DATA struct SaveSection gSaveDataBuffer = {0}; diff --git a/src/save_failed_screen.c b/src/save_failed_screen.c index 4c1da8620..2587bf10a 100644 --- a/src/save_failed_screen.c +++ b/src/save_failed_screen.c @@ -4,6 +4,7 @@ #include "palette.h" #include "gpu_regs.h" #include "bg.h" +#include "decompress.h" #include "task.h" #include "window.h" #include "menu.h" @@ -14,16 +15,11 @@ #define MSG_WIN_TOP 12 #define CLOCK_WIN_TOP (MSG_WIN_TOP - 4) -extern void (*gGameContinueCallback)(void); - -extern u32 gDamagedSaveSectors; - extern const u8 gBirchHelpGfx[]; extern const u8 gBirchBagTilemap[]; extern const u8 gBirchGrassTilemap[]; extern const u16 gBirchBagGrassPal[]; extern const u16 gUnknown_0860F074[]; -extern struct SaveSection gSaveDataBuffer; extern u8 gText_SaveFailedCheckingBackup[]; extern u8 gText_BackupMemoryDamaged[]; @@ -32,8 +28,6 @@ extern u8 gText_SaveCompleteGameCannotContinue[]; extern u8 gText_SaveCompletePressA[]; extern u8 gText_GamePlayCannotBeContinued[]; -extern u8 gDecompressionBuffer[]; - // gSaveFailedClockInfo enum enum { diff --git a/sym_bss.txt b/sym_bss.txt index 5f055e8e4..08b1a58bd 100644 --- a/sym_bss.txt +++ b/sym_bss.txt @@ -98,9 +98,7 @@ gUnknown_03001290: @ 3001290 gUnknown_03001294: @ 3001294 .space 0x4 -gUnknown_03001298: @ 3001298 - .space 0x4 - + .include "src/battle_tent.o" .include "src/multiboot.o" .space 0x4 @ XXX: why is this needed? diff --git a/sym_common.txt b/sym_common.txt index 96796d941..282ef7f72 100644 --- a/sym_common.txt +++ b/sym_common.txt @@ -99,14 +99,6 @@ gUnknown_030061EC: @ 30061EC .include "save.o" - .space 0x8 - -gRamSaveSectionLocations: @ 3006220 - .space 0x74 - -gUnknown_03006294: @ 3006294 - .space 0x4 - gUnknown_03006298: @ 3006298 .space 0x8