From c6eacc9be5423fab39c90ade16b147de4cd032fe Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Wed, 6 Sep 2017 17:19:08 +0200 Subject: [PATCH] start porting pokemon1 --- asm/battle_4.s | 22 +- asm/daycare.s | 12 +- asm/egg_hatch.s | 2 +- asm/evolution_scene.s | 16 +- asm/pokemon_1.s | 1137 +-------------------------- asm/pokemon_2.s | 26 +- asm/pokemon_3.s | 20 +- asm/rom_815A0D4.s | 4 +- asm/rom_8161F74.s | 8 +- asm/rom_818CFC8.s | 36 +- asm/rom_81BE66C.s | 6 +- asm/script_pokemon_util_80F87D8.s | 2 +- asm/wild_encounter.s | 2 +- data/level_up_learnset_pointers.inc | 2 +- include/pokemon.h | 198 ++++- include/text.h | 74 +- ld_script.txt | 1 + src/pokemon_1.c | 325 ++++++++ sym_ewram.txt | 4 +- 19 files changed, 703 insertions(+), 1194 deletions(-) create mode 100644 src/pokemon_1.c diff --git a/asm/battle_4.s b/asm/battle_4.s index ea8b469e5..8f81b543e 100644 --- a/asm/battle_4.s +++ b/asm/battle_4.s @@ -14635,7 +14635,7 @@ atk59_learnmove_inbattle: @ 804DEEC ldr r1, =gPlayerParty adds r0, r1 ldrb r1, [r2, 0x9] - bl sub_8069318 + bl MonTryLearningNewMove lsls r0, 16 lsrs r5, r0, 16 ldr r0, =0x0000fffe @@ -14651,7 +14651,7 @@ _0804DF3A: ldr r1, =gPlayerParty adds r0, r1 movs r1, 0 - bl sub_8069318 + bl MonTryLearningNewMove lsls r0, 16 lsrs r5, r0, 16 cmp r5, r7 @@ -14703,7 +14703,7 @@ _0804DF88: bne _0804DFC8 adds r0, r2, r4 adds r1, r5, 0 - bl sub_80691B0 + bl GiveMoveToBattleMon _0804DFC8: ldr r0, =gBattleTypeFlags ldr r0, [r0] @@ -14740,7 +14740,7 @@ _0804DFC8: bne _0804E014 adds r0, r2, r4 adds r1, r5, 0 - bl sub_80691B0 + bl GiveMoveToBattleMon _0804E014: ldr r0, =gBattlescriptCurrInstr str r6, [r0] @@ -14898,7 +14898,7 @@ _0804E170: lsls r2, 24 lsrs r2, 24 ldr r3, =sub_80A92F8 - ldr r4, =gUnknown_020244E2 + ldr r4, =gMoveToLearn ldrh r4, [r4] str r4, [sp] bl sub_81BFA38 @@ -15023,10 +15023,10 @@ _0804E274: muls r1, r0 adds r0, r1, 0 adds r0, r7 - ldr r7, =gUnknown_020244E2 + ldr r7, =gMoveToLearn ldrh r1, [r7] adds r2, r5, 0 - bl sub_80691F4 + bl SetMonMoveSlot ldr r0, =gBattlePartyID ldr r1, [r6] ldrh r0, [r0] @@ -15056,7 +15056,7 @@ _0804E274: ldrh r1, [r7] adds r0, r4, 0 adds r2, r5, 0 - bl sub_8069234 + bl SetBattleMonMoveSlot _0804E30A: ldr r0, =gBattleTypeFlags ldr r0, [r0] @@ -15096,11 +15096,11 @@ _0804E30A: adds r0, r4, 0 adds r1, r5, 0 bl sub_806B9E4 - ldr r0, =gUnknown_020244E2 + ldr r0, =gMoveToLearn ldrh r1, [r0] adds r0, r4, 0 adds r2, r5, 0 - bl sub_8069234 + bl SetBattleMonMoveSlot b _0804E3B8 .pool _0804E38C: @@ -17178,7 +17178,7 @@ sub_804F574: @ 804F574 strb r0, [r2] movs r0, 0x2 strb r0, [r2, 0x1] - ldr r0, =gUnknown_020244E2 + ldr r0, =gMoveToLearn ldrh r1, [r0] strb r1, [r2, 0x2] movs r0, 0xFF diff --git a/asm/daycare.s b/asm/daycare.s index 0f67d0200..608e2b9ca 100644 --- a/asm/daycare.s +++ b/asm/daycare.s @@ -347,14 +347,14 @@ _0806FCC4: movs r6, 0 cmp r0, r7 bne _0806FCD4 - ldr r0, =gUnknown_020244E2 + ldr r0, =gMoveToLearn ldrh r1, [r0] adds r0, r4, 0 bl DeleteFirstMoveAndGiveMoveToMon _0806FCD4: adds r0, r4, 0 adds r1, r6, 0 - bl sub_8069318 + bl MonTryLearningNewMove lsls r0, 16 lsrs r0, 16 cmp r0, 0 @@ -1439,7 +1439,7 @@ _08070546: adds r1, r0, 0 adds r0, r7, 0 str r2, [sp, 0x8] - bl GiveMoveToBoxMon_ + bl GiveMoveToMon lsls r0, 16 lsrs r0, 16 ldr r2, [sp, 0x8] @@ -1500,7 +1500,7 @@ _080705C2: beq _080705FE ldrh r1, [r4] adds r0, r7, 0 - bl GiveMoveToBoxMon_ + bl GiveMoveToMon lsls r0, 16 lsrs r0, 16 cmp r0, r6 @@ -1601,7 +1601,7 @@ _0807068A: adds r1, r0, 0 adds r0, r7, 0 str r2, [sp, 0x8] - bl GiveMoveToBoxMon_ + bl GiveMoveToMon lsls r0, 16 lsrs r0, 16 ldr r2, [sp, 0x8] @@ -1747,7 +1747,7 @@ _080707C6: lsls r4, 1 adds r0, r6, 0 adds r1, r4, 0 - bl GiveMoveToBoxMon_ + bl GiveMoveToMon lsls r0, 16 ldr r1, =0xffff0000 cmp r0, r1 diff --git a/asm/egg_hatch.s b/asm/egg_hatch.s index db900298e..8620a4926 100644 --- a/asm/egg_hatch.s +++ b/asm/egg_hatch.s @@ -246,7 +246,7 @@ sub_80714B8: @ 80714B8 movs r1, 0x23 bl SetMonData adds r0, r5, 0 - bl sub_806E924 + bl RestoreMonMovesPP adds r0, r5, 0 bl CalculateMonStats add sp, 0x14 diff --git a/asm/evolution_scene.s b/asm/evolution_scene.s index 84bacd78b..ffdffb9d6 100644 --- a/asm/evolution_scene.s +++ b/asm/evolution_scene.s @@ -1679,7 +1679,7 @@ _0813EA2A: adds r4, r0, r1 ldrb r1, [r4, 0x10] mov r0, r9 - bl sub_8069318 + bl MonTryLearningNewMove lsls r0, 16 lsrs r6, r0, 16 cmp r6, 0 @@ -2237,7 +2237,7 @@ _0813EF3E: lsls r2, 24 lsrs r2, 24 ldr r3, =sub_813DD7C - ldr r4, =gUnknown_020244E2 + ldr r4, =gMoveToLearn ldrh r4, [r4] str r4, [sp] bl sub_81BFA38 @@ -2318,11 +2318,11 @@ _0813F014: mov r0, r9 adds r1, r4, 0 bl sub_806B9A8 - ldr r0, =gUnknown_020244E2 + ldr r0, =gMoveToLearn ldrh r1, [r0] mov r0, r9 adds r2, r4, 0 - bl sub_80691F4 + bl SetMonMoveSlot ldr r0, =gTasks mov r3, r8 adds r1, r3, r7 @@ -2870,7 +2870,7 @@ _0813F58C: adds r5, r0, r1 ldrb r1, [r5, 0x10] mov r0, r9 - bl sub_8069318 + bl MonTryLearningNewMove lsls r0, 16 lsrs r6, r0, 16 mov r8, r4 @@ -3388,7 +3388,7 @@ _0813FA3E: lsls r2, 24 lsrs r2, 24 ldr r3, =sub_813DF70 - ldr r4, =gUnknown_020244E2 + ldr r4, =gMoveToLearn ldrh r4, [r4] str r4, [sp] bl sub_81BFA38 @@ -3471,11 +3471,11 @@ _0813FB3C: mov r0, r9 adds r1, r4, 0 bl sub_806B9A8 - ldr r0, =gUnknown_020244E2 + ldr r0, =gMoveToLearn ldrh r1, [r0] mov r0, r9 adds r2, r4, 0 - bl sub_80691F4 + bl SetMonMoveSlot ldr r0, =gUnknown_085CC270 movs r1, 0xCF lsls r1, 2 diff --git a/asm/pokemon_1.s b/asm/pokemon_1.s index 003150afe..b101c2c8a 100644 --- a/asm/pokemon_1.s +++ b/asm/pokemon_1.s @@ -5,1069 +5,8 @@ .text - thumb_func_start ZeroBoxMonData -@ void ZeroBoxMonData(pokemon *mon) -ZeroBoxMonData: @ 8067A74 - push {lr} - adds r2, r0, 0 - movs r1, 0 - movs r3, 0 -_08067A7C: - adds r0, r2, r1 - strb r3, [r0] - adds r1, 0x1 - cmp r1, 0x4F - bls _08067A7C - pop {r0} - bx r0 - thumb_func_end ZeroBoxMonData - thumb_func_start ZeroMonData -@ void ZeroMonData(pokemon *mon) -ZeroMonData: @ 8067A8C - push {r4,lr} - sub sp, 0x4 - adds r4, r0, 0 - bl ZeroBoxMonData - movs r0, 0 - str r0, [sp] - adds r0, r4, 0 - movs r1, 0x37 - mov r2, sp - bl SetMonData - adds r0, r4, 0 - movs r1, 0x38 - mov r2, sp - bl SetMonData - adds r0, r4, 0 - movs r1, 0x39 - mov r2, sp - bl SetMonData - adds r0, r4, 0 - movs r1, 0x3A - mov r2, sp - bl SetMonData - adds r0, r4, 0 - movs r1, 0x3B - mov r2, sp - bl SetMonData - adds r0, r4, 0 - movs r1, 0x3C - mov r2, sp - bl SetMonData - adds r0, r4, 0 - movs r1, 0x3D - mov r2, sp - bl SetMonData - adds r0, r4, 0 - movs r1, 0x3E - mov r2, sp - bl SetMonData - adds r0, r4, 0 - movs r1, 0x3F - mov r2, sp - bl SetMonData - movs r0, 0xFF - str r0, [sp] - adds r0, r4, 0 - movs r1, 0x40 - mov r2, sp - bl SetMonData - add sp, 0x4 - pop {r4} - pop {r0} - bx r0 - thumb_func_end ZeroMonData - thumb_func_start ZeroPlayerPartyMons -@ void ZeroPlayerPartyMons() -ZeroPlayerPartyMons: @ 8067B0C - push {r4,r5,lr} - ldr r4, =gPlayerParty - movs r0, 0xFA - lsls r0, 1 - adds r5, r4, r0 -_08067B16: - adds r0, r4, 0 - bl ZeroMonData - adds r4, 0x64 - cmp r4, r5 - ble _08067B16 - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end ZeroPlayerPartyMons - - thumb_func_start ZeroEnemyPartyMons -ZeroEnemyPartyMons: @ 8067B2C - push {r4,r5,lr} - ldr r4, =gEnemyParty - movs r0, 0xFA - lsls r0, 1 - adds r5, r4, r0 -_08067B36: - adds r0, r4, 0 - bl ZeroMonData - adds r4, 0x64 - cmp r4, r5 - ble _08067B36 - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end ZeroEnemyPartyMons - - thumb_func_start CreateMon -@ void CreateMon(pokemon *mon, s16 species_num, u8 level, u8 forced_iv, char pokemon_id_is_nonrandom, int pokemon_id, u8 trainer_id_mode, int trainer_id) -CreateMon: @ 8067B4C - push {r4-r7,lr} - mov r7, r8 - push {r7} - sub sp, 0x1C - mov r8, r0 - adds r6, r1, 0 - ldr r4, [sp, 0x34] - ldr r7, [sp, 0x38] - ldr r5, [sp, 0x3C] - lsls r6, 16 - lsrs r6, 16 - add r0, sp, 0x10 - strb r2, [r0] - lsls r3, 24 - lsrs r3, 24 - lsls r4, 24 - lsrs r4, 24 - lsls r5, 24 - lsrs r5, 24 - mov r0, r8 - str r3, [sp, 0x18] - bl ZeroMonData - str r4, [sp] - str r7, [sp, 0x4] - str r5, [sp, 0x8] - ldr r0, [sp, 0x40] - str r0, [sp, 0xC] - mov r0, r8 - adds r1, r6, 0 - add r2, sp, 0x10 - ldrb r2, [r2] - ldr r3, [sp, 0x18] - bl CreateBoxMon - mov r0, r8 - movs r1, 0x38 - add r2, sp, 0x10 - bl SetMonData - movs r0, 0xFF - str r0, [sp, 0x14] - add r2, sp, 0x14 - mov r0, r8 - movs r1, 0x40 - bl SetMonData - mov r0, r8 - bl CalculateMonStats - add sp, 0x1C - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end CreateMon - - thumb_func_start CreateBoxMon -@ void CreateBoxMon(pokemon *mon, s16 species_num, u8 level, u8 forced_iv, char pokemon_id_is_nonrandom, int pokemon_id, u8 trainer_id_mode, int trainer_id) -CreateBoxMon: @ 8067BBC - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x20 - adds r7, r0, 0 - ldr r4, [sp, 0x40] - ldr r0, [sp, 0x48] - movs r5, 0xE - add r5, sp - strh r1, [r5] - add r6, sp, 0x10 - strb r2, [r6] - mov r5, sp - adds r5, 0x11 - strb r3, [r5] - lsls r4, 24 - lsrs r4, 24 - lsls r0, 24 - lsrs r0, 24 - mov r10, r0 - adds r0, r7, 0 - bl ZeroBoxMonData - cmp r4, 0 - beq _08067BF8 - ldr r0, [sp, 0x44] - str r0, [sp, 0x14] - b _08067C0C -_08067BF8: - bl Random - adds r4, r0, 0 - bl Random - lsls r4, 16 - lsrs r4, 16 - lsls r0, 16 - orrs r4, r0 - str r4, [sp, 0x14] -_08067C0C: - add r2, sp, 0x14 - adds r0, r7, 0 - movs r1, 0 - bl SetBoxMonData - add r0, sp, 0x18 - mov r9, r0 - add r5, sp, 0xC - mov r1, r10 - cmp r1, 0x2 - bne _08067C64 - ldr r2, =0xffff0000 - mov r8, r2 - ldr r6, =0x0000ffff -_08067C28: - bl Random - adds r4, r0, 0 - bl Random - lsls r4, 16 - lsrs r4, 16 - lsls r0, 16 - orrs r4, r0 - str r4, [sp, 0x18] - adds r1, r4, 0 - mov r3, r8 - ands r1, r3 - lsrs r1, 16 - ands r4, r6 - eors r1, r4 - ldr r2, [sp, 0x14] - adds r0, r2, 0 - ands r0, r3 - lsrs r0, 16 - eors r1, r0 - ands r2, r6 - eors r1, r2 - cmp r1, 0x7 - bls _08067C28 - b _08067C8A - .pool -_08067C64: - mov r0, r10 - cmp r0, 0x1 - bne _08067C70 - ldr r0, [sp, 0x4C] - str r0, [sp, 0x18] - b _08067C8A -_08067C70: - ldr r0, =gSaveBlock2Ptr - ldr r2, [r0] - ldrb r1, [r2, 0xA] - ldrb r0, [r2, 0xB] - lsls r0, 8 - orrs r1, r0 - ldrb r0, [r2, 0xC] - lsls r0, 16 - orrs r1, r0 - ldrb r0, [r2, 0xD] - lsls r0, 24 - orrs r1, r0 - str r1, [sp, 0x18] -_08067C8A: - adds r0, r7, 0 - movs r1, 0x1 - mov r2, r9 - bl SetBoxMonData - adds r0, r7, 0 - bl CalculateBoxMonChecksum - strh r0, [r5] - adds r0, r7, 0 - movs r1, 0x9 - adds r2, r5, 0 - bl SetBoxMonData - adds r0, r7, 0 - bl EncryptBoxMon - mov r0, sp - ldrh r1, [r0, 0xE] - bl GetSpeciesName - adds r0, r7, 0 - movs r1, 0x2 - mov r2, sp - bl SetBoxMonData - ldr r2, =gGameLanguage - adds r0, r7, 0 - movs r1, 0x3 - bl SetBoxMonData - ldr r5, =gSaveBlock2Ptr - ldr r2, [r5] - adds r0, r7, 0 - movs r1, 0x7 - bl SetBoxMonData - adds r0, r7, 0 - movs r1, 0xB - mov r2, sp - adds r2, 0xE - bl SetBoxMonData - ldr r4, =gBaseStats - mov r2, sp - ldrh r1, [r2, 0xE] - lsls r0, r1, 3 - subs r0, r1 - lsls r0, 2 - adds r0, r4 - ldrb r1, [r0, 0x13] - movs r0, 0xCA - lsls r0, 1 - adds r2, r1, 0 - muls r2, r0 - mov r3, sp - ldrb r0, [r3, 0x10] - lsls r0, 2 - ldr r1, =gExperienceTables - adds r0, r1 - adds r2, r0 - adds r0, r7, 0 - movs r1, 0x19 - bl SetBoxMonData - mov r1, sp - ldrh r0, [r1, 0xE] - lsls r2, r0, 3 - subs r2, r0 - lsls r2, 2 - adds r4, 0x12 - adds r2, r4 - adds r0, r7, 0 - movs r1, 0x20 - bl SetBoxMonData - bl sav1_map_get_name - lsls r0, 24 - lsrs r0, 24 - str r0, [sp, 0x18] - adds r0, r7, 0 - movs r1, 0x23 - mov r2, r9 - bl SetBoxMonData - adds r0, r7, 0 - movs r1, 0x24 - add r2, sp, 0x10 - bl SetBoxMonData - ldr r2, =gGameVersion - adds r0, r7, 0 - movs r1, 0x25 - bl SetBoxMonData - movs r0, 0x4 - str r0, [sp, 0x18] - adds r0, r7, 0 - movs r1, 0x26 - mov r2, r9 - bl SetBoxMonData - ldr r2, [r5] - adds r2, 0x8 - adds r0, r7, 0 - movs r1, 0x31 - bl SetBoxMonData - mov r2, sp - ldrb r0, [r2, 0x11] - cmp r0, 0x1F - bhi _08067DC8 - adds r0, r7, 0 - movs r1, 0x27 - adds r2, 0x11 - bl SetBoxMonData - adds r0, r7, 0 - movs r1, 0x28 - mov r2, sp - adds r2, 0x11 - bl SetBoxMonData - adds r0, r7, 0 - movs r1, 0x29 - mov r2, sp - adds r2, 0x11 - bl SetBoxMonData - adds r0, r7, 0 - movs r1, 0x2A - mov r2, sp - adds r2, 0x11 - bl SetBoxMonData - adds r0, r7, 0 - movs r1, 0x2B - mov r2, sp - adds r2, 0x11 - bl SetBoxMonData - adds r0, r7, 0 - movs r1, 0x2C - mov r2, sp - adds r2, 0x11 - bl SetBoxMonData - b _08067E50 - .pool -_08067DC8: - bl Random - lsls r0, 16 - lsrs r0, 16 - str r0, [sp, 0x18] - movs r3, 0x1F - mov r8, r3 - ands r0, r3 - str r0, [sp, 0x1C] - add r4, sp, 0x1C - adds r0, r7, 0 - movs r1, 0x27 - adds r2, r4, 0 - bl SetBoxMonData - ldr r0, [sp, 0x18] - movs r6, 0xF8 - lsls r6, 2 - ands r0, r6 - lsrs r0, 5 - str r0, [sp, 0x1C] - adds r0, r7, 0 - movs r1, 0x28 - adds r2, r4, 0 - bl SetBoxMonData - ldr r0, [sp, 0x18] - movs r5, 0xF8 - lsls r5, 7 - ands r0, r5 - lsrs r0, 10 - str r0, [sp, 0x1C] - adds r0, r7, 0 - movs r1, 0x29 - adds r2, r4, 0 - bl SetBoxMonData - bl Random - lsls r0, 16 - lsrs r0, 16 - str r0, [sp, 0x18] - mov r1, r8 - ands r0, r1 - str r0, [sp, 0x1C] - adds r0, r7, 0 - movs r1, 0x2A - adds r2, r4, 0 - bl SetBoxMonData - ldr r0, [sp, 0x18] - ands r0, r6 - lsrs r0, 5 - str r0, [sp, 0x1C] - adds r0, r7, 0 - movs r1, 0x2B - adds r2, r4, 0 - bl SetBoxMonData - ldr r0, [sp, 0x18] - ands r0, r5 - lsrs r0, 10 - str r0, [sp, 0x1C] - adds r0, r7, 0 - movs r1, 0x2C - adds r2, r4, 0 - bl SetBoxMonData -_08067E50: - ldr r2, =gBaseStats - mov r3, sp - ldrh r1, [r3, 0xE] - lsls r0, r1, 3 - subs r0, r1 - lsls r0, 2 - adds r0, r2 - ldrb r0, [r0, 0x17] - cmp r0, 0 - beq _08067E76 - ldr r0, [sp, 0x14] - movs r1, 0x1 - ands r0, r1 - str r0, [sp, 0x18] - adds r0, r7, 0 - movs r1, 0x2E - mov r2, r9 - bl SetBoxMonData -_08067E76: - adds r0, r7, 0 - bl GiveBoxMonInitialMoveset - add sp, 0x20 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end CreateBoxMon - - thumb_func_start CreateMonWithNature -CreateMonWithNature: @ 8067E90 - push {r4-r7,lr} - mov r7, r9 - mov r6, r8 - push {r6,r7} - sub sp, 0x10 - mov r9, r0 - ldr r0, [sp, 0x2C] - lsls r1, 16 - lsrs r1, 16 - mov r8, r1 - lsls r2, 24 - lsrs r7, r2, 24 - lsls r3, 24 - lsrs r6, r3, 24 - lsls r0, 24 - lsrs r5, r0, 24 -_08067EB0: - bl Random - adds r4, r0, 0 - bl Random - lsls r4, 16 - lsrs r4, 16 - lsls r0, 16 - orrs r4, r0 - adds r0, r4, 0 - bl GetNatureFromPersonality - lsls r0, 24 - lsrs r0, 24 - cmp r5, r0 - bne _08067EB0 - movs r0, 0x1 - str r0, [sp] - str r4, [sp, 0x4] - movs r0, 0 - str r0, [sp, 0x8] - str r0, [sp, 0xC] - mov r0, r9 - mov r1, r8 - adds r2, r7, 0 - adds r3, r6, 0 - bl CreateMon - add sp, 0x10 - pop {r3,r4} - mov r8, r3 - mov r9, r4 - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end CreateMonWithNature - - thumb_func_start CreateMonWithGenderNatureLetter -CreateMonWithGenderNatureLetter: @ 8067EF8 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x18 - str r0, [sp, 0x10] - ldr r4, [sp, 0x38] - ldr r5, [sp, 0x3C] - ldr r0, [sp, 0x40] - lsls r1, 16 - lsrs r7, r1, 16 - lsls r2, 24 - lsrs r2, 24 - str r2, [sp, 0x14] - lsls r3, 24 - lsrs r3, 24 - mov r10, r3 - lsls r4, 24 - lsrs r4, 24 - mov r8, r4 - lsls r5, 24 - lsrs r6, r5, 24 - lsls r0, 24 - lsrs r1, r0, 24 - mov r9, r1 - movs r1, 0xFF - lsls r1, 24 - adds r0, r1 - lsrs r0, 24 - cmp r0, 0x1B - bhi _08067F9E -_08067F38: - bl Random - adds r4, r0, 0 - bl Random - lsls r4, 16 - lsrs r4, 16 - lsls r0, 16 - orrs r4, r0 - movs r0, 0xC0 - lsls r0, 18 - ands r0, r4 - lsrs r0, 18 - movs r1, 0xC0 - lsls r1, 10 - ands r1, r4 - lsrs r1, 12 - orrs r0, r1 - movs r1, 0xC0 - lsls r1, 2 - ands r1, r4 - lsrs r1, 6 - orrs r0, r1 - movs r1, 0x3 - ands r1, r4 - orrs r0, r1 - movs r1, 0x1C - bl __umodsi3 - lsls r0, 16 - lsrs r5, r0, 16 - adds r0, r4, 0 - bl GetNatureFromPersonality - lsls r0, 24 - lsrs r0, 24 - cmp r6, r0 - bne _08067F38 - adds r0, r7, 0 - adds r1, r4, 0 - bl GetGenderFromSpeciesAndPersonality - lsls r0, 24 - lsrs r0, 24 - cmp r8, r0 - bne _08067F38 - mov r0, r9 - subs r0, 0x1 - cmp r5, r0 - bne _08067F38 - b _08067FCE -_08067F9E: - bl Random - adds r4, r0, 0 - bl Random - lsls r4, 16 - lsrs r4, 16 - lsls r0, 16 - orrs r4, r0 - adds r0, r4, 0 - bl GetNatureFromPersonality - lsls r0, 24 - lsrs r0, 24 - cmp r6, r0 - bne _08067F9E - adds r0, r7, 0 - adds r1, r4, 0 - bl GetGenderFromSpeciesAndPersonality - lsls r0, 24 - lsrs r0, 24 - cmp r8, r0 - bne _08067F9E -_08067FCE: - movs r0, 0x1 - str r0, [sp] - str r4, [sp, 0x4] - movs r0, 0 - str r0, [sp, 0x8] - str r0, [sp, 0xC] - ldr r0, [sp, 0x10] - adds r1, r7, 0 - ldr r2, [sp, 0x14] - mov r3, r10 - bl CreateMon - add sp, 0x18 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end CreateMonWithGenderNatureLetter - - thumb_func_start CreateMaleMon -CreateMaleMon: @ 8067FF8 - push {r4-r7,lr} - mov r7, r8 - push {r7} - sub sp, 0x10 - mov r8, r0 - lsls r1, 16 - lsrs r6, r1, 16 - lsls r2, 24 - lsrs r7, r2, 24 -_0806800A: - bl Random - adds r4, r0, 0 - bl Random - lsls r4, 16 - lsrs r5, r4, 16 - lsls r0, 16 - orrs r5, r0 - bl Random - adds r4, r0, 0 - bl Random - lsls r4, 16 - lsrs r4, 16 - lsls r0, 16 - orrs r4, r0 - adds r0, r6, 0 - adds r1, r4, 0 - bl GetGenderFromSpeciesAndPersonality - lsls r0, 24 - cmp r0, 0 - bne _0806800A - movs r0, 0x1 - str r0, [sp] - str r4, [sp, 0x4] - str r0, [sp, 0x8] - str r5, [sp, 0xC] - mov r0, r8 - adds r1, r6, 0 - adds r2, r7, 0 - movs r3, 0x20 - bl CreateMon - add sp, 0x10 - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end CreateMaleMon - - thumb_func_start CreateMonWithIVsPersonality -CreateMonWithIVsPersonality: @ 8068060 - push {r4,lr} - sub sp, 0x14 - adds r4, r0, 0 - str r3, [sp, 0x10] - ldr r3, [sp, 0x1C] - lsls r1, 16 - lsrs r1, 16 - lsls r2, 24 - lsrs r2, 24 - movs r0, 0x1 - str r0, [sp] - str r3, [sp, 0x4] - movs r0, 0 - str r0, [sp, 0x8] - str r0, [sp, 0xC] - adds r0, r4, 0 - movs r3, 0 - bl CreateMon - adds r0, r4, 0 - movs r1, 0x42 - add r2, sp, 0x10 - bl SetMonData - adds r0, r4, 0 - bl CalculateMonStats - add sp, 0x14 - pop {r4} - pop {r0} - bx r0 - thumb_func_end CreateMonWithIVsPersonality - - thumb_func_start CreateMonWithIVsOTID -CreateMonWithIVsOTID: @ 80680A0 - push {r4,r5,lr} - sub sp, 0x10 - adds r5, r0, 0 - adds r4, r3, 0 - ldr r3, [sp, 0x1C] - lsls r1, 16 - lsrs r1, 16 - lsls r2, 24 - lsrs r2, 24 - movs r0, 0 - str r0, [sp] - str r0, [sp, 0x4] - movs r0, 0x1 - str r0, [sp, 0x8] - str r3, [sp, 0xC] - adds r0, r5, 0 - movs r3, 0 - bl CreateMon - adds r0, r5, 0 - movs r1, 0x27 - adds r2, r4, 0 - bl SetMonData - adds r2, r4, 0x1 - adds r0, r5, 0 - movs r1, 0x28 - bl SetMonData - adds r2, r4, 0x2 - adds r0, r5, 0 - movs r1, 0x29 - bl SetMonData - adds r2, r4, 0x3 - adds r0, r5, 0 - movs r1, 0x2A - bl SetMonData - adds r2, r4, 0x4 - adds r0, r5, 0 - movs r1, 0x2B - bl SetMonData - adds r4, 0x5 - adds r0, r5, 0 - movs r1, 0x2C - adds r2, r4, 0 - bl SetMonData - adds r0, r5, 0 - bl CalculateMonStats - add sp, 0x10 - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end CreateMonWithIVsOTID - - thumb_func_start CreateMonWithEVSpread -CreateMonWithEVSpread: @ 8068114 - push {r4-r7,lr} - mov r7, r8 - push {r7} - sub sp, 0x14 - adds r7, r0, 0 - ldr r0, [sp, 0x2C] - lsls r1, 16 - lsrs r1, 16 - lsls r2, 24 - lsrs r2, 24 - lsls r3, 24 - lsrs r3, 24 - lsls r0, 24 - lsrs r0, 24 - mov r8, r0 - movs r6, 0 - str r6, [sp] - str r6, [sp, 0x4] - str r6, [sp, 0x8] - str r6, [sp, 0xC] - adds r0, r7, 0 - bl CreateMon - mov r4, r8 - movs r1, 0x1 - movs r5, 0x5 -_08068148: - adds r0, r4, 0 - ands r0, r1 - cmp r0, 0 - beq _08068152 - adds r6, 0x1 -_08068152: - lsrs r4, 1 - subs r5, 0x1 - cmp r5, 0 - bge _08068148 - movs r0, 0xFF - lsls r0, 1 - adds r1, r6, 0 - bl __divsi3 - add r1, sp, 0x10 - strh r0, [r1] - movs r4, 0x1 - movs r5, 0 -_0806816C: - mov r0, r8 - ands r0, r4 - cmp r0, 0 - beq _08068180 - adds r1, r5, 0 - adds r1, 0x1A - adds r0, r7, 0 - add r2, sp, 0x10 - bl SetMonData -_08068180: - lsls r0, r4, 25 - lsrs r4, r0, 24 - adds r5, 0x1 - cmp r5, 0x5 - ble _0806816C - adds r0, r7, 0 - bl CalculateMonStats - add sp, 0x14 - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end CreateMonWithEVSpread - - thumb_func_start sub_806819C -sub_806819C: @ 806819C - push {r4-r7,lr} - mov r7, r9 - mov r6, r8 - push {r6,r7} - sub sp, 0x34 - adds r7, r0, 0 - adds r6, r1, 0 - ldrh r1, [r6] - ldrb r2, [r6, 0xC] - movs r3, 0x1 - str r3, [sp] - ldr r0, [r6, 0x1C] - str r0, [sp, 0x4] - str r3, [sp, 0x8] - ldr r0, [r6, 0x14] - str r0, [sp, 0xC] - adds r0, r7, 0 - movs r3, 0 - bl CreateMon - movs r5, 0 - add r0, sp, 0x30 - mov r9, r0 - movs r1, 0x31 - add r1, sp - mov r8, r1 - adds r4, r6, 0x4 -_080681D2: - ldrh r1, [r4] - lsls r2, r5, 24 - lsrs r2, 24 - adds r0, r7, 0 - bl sub_80691F4 - adds r4, 0x2 - adds r5, 0x1 - cmp r5, 0x3 - ble _080681D2 - adds r2, r6, 0 - adds r2, 0xD - adds r0, r7, 0 - movs r1, 0x15 - bl SetMonData - adds r2, r6, 0x2 - adds r0, r7, 0 - movs r1, 0xC - bl SetMonData - adds r2, r6, 0 - adds r2, 0x2B - adds r0, r7, 0 - movs r1, 0x20 - bl SetMonData - adds r1, r6, 0 - adds r1, 0x20 - add r0, sp, 0x10 - bl StringCopy - add r0, sp, 0x10 - ldrb r0, [r0] - cmp r0, 0xFC - bne _08068230 - add r0, sp, 0x10 - ldrb r0, [r0, 0x1] - cmp r0, 0x15 - bne _08068230 - movs r0, 0x1 - mov r1, r9 - strb r0, [r1] - add r0, sp, 0x10 - bl StripExtCtrlCodes - b _08068236 -_08068230: - movs r0, 0x2 - mov r1, r9 - strb r0, [r1] -_08068236: - adds r0, r7, 0 - movs r1, 0x3 - mov r2, r9 - bl SetMonData - adds r0, r7, 0 - movs r1, 0x2 - add r2, sp, 0x10 - bl SetMonData - adds r2, r6, 0 - adds r2, 0xE - adds r0, r7, 0 - movs r1, 0x1A - bl SetMonData - adds r2, r6, 0 - adds r2, 0xF - adds r0, r7, 0 - movs r1, 0x1B - bl SetMonData - adds r2, r6, 0 - adds r2, 0x10 - adds r0, r7, 0 - movs r1, 0x1C - bl SetMonData - adds r2, r6, 0 - adds r2, 0x11 - adds r0, r7, 0 - movs r1, 0x1D - bl SetMonData - adds r2, r6, 0 - adds r2, 0x12 - adds r0, r7, 0 - movs r1, 0x1E - bl SetMonData - adds r2, r6, 0 - adds r2, 0x13 - adds r0, r7, 0 - movs r1, 0x1F - bl SetMonData - ldrb r0, [r6, 0x1B] - lsrs r0, 7 - mov r1, r8 - strb r0, [r1] - adds r0, r7, 0 - movs r1, 0x2E - mov r2, r8 - bl SetMonData - ldrb r0, [r6, 0x18] - lsls r0, 27 - lsrs r0, 27 - mov r1, r8 - strb r0, [r1] - adds r0, r7, 0 - movs r1, 0x27 - mov r2, r8 - bl SetMonData - ldrh r0, [r6, 0x18] - lsls r0, 22 - lsrs r0, 27 - mov r1, r8 - strb r0, [r1] - adds r0, r7, 0 - movs r1, 0x28 - mov r2, r8 - bl SetMonData - ldrb r0, [r6, 0x19] - lsls r0, 25 - lsrs r0, 27 - mov r1, r8 - strb r0, [r1] - adds r0, r7, 0 - movs r1, 0x29 - mov r2, r8 - bl SetMonData - ldr r0, [r6, 0x18] - lsls r0, 12 - lsrs r0, 27 - mov r1, r8 - strb r0, [r1] - adds r0, r7, 0 - movs r1, 0x2A - mov r2, r8 - bl SetMonData - ldrh r0, [r6, 0x1A] - lsls r0, 23 - lsrs r0, 27 - mov r1, r8 - strb r0, [r1] - adds r0, r7, 0 - movs r1, 0x2B - mov r2, r8 - bl SetMonData - ldrb r0, [r6, 0x1B] - lsls r0, 26 - lsrs r0, 27 - mov r1, r8 - strb r0, [r1] - adds r0, r7, 0 - movs r1, 0x2C - mov r2, r8 - bl SetMonData - adds r0, r7, 0 - bl sub_806E924 - adds r0, r7, 0 - bl CalculateMonStats - add sp, 0x34 - pop {r3,r4} - mov r8, r3 - mov r9, r4 - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end sub_806819C thumb_func_start sub_8068338 sub_8068338: @ 8068338 @@ -1150,7 +89,7 @@ _080683D2: lsls r2, r5, 24 lsrs r2, 24 adds r0, r7, 0 - bl sub_80691F4 + bl SetMonMoveSlot adds r4, 0x2 adds r5, 0x1 cmp r5, 0x3 @@ -1284,7 +223,7 @@ _08068430: mov r2, r8 bl SetMonData adds r0, r7, 0 - bl sub_806E924 + bl RestoreMonMovesPP adds r0, r7, 0 bl CalculateMonStats add sp, 0x58 @@ -1377,7 +316,7 @@ _080685BE: lsls r2, r4, 24 lsrs r2, 24 adds r0, r7, 0 - bl sub_80691F4 + bl SetMonMoveSlot adds r5, 0x2 adds r4, 0x1 cmp r4, 0x3 @@ -1720,8 +659,8 @@ _08068738: .pool thumb_func_end sub_80686FC - thumb_func_start sub_80688A8 -sub_80688A8: @ 80688A8 + thumb_func_start CreateObedientMon +CreateObedientMon: @ 80688A8 push {r4-r7,lr} mov r7, r8 push {r7} @@ -1759,7 +698,7 @@ sub_80688A8: @ 80688A8 pop {r4-r7} pop {r0} bx r0 - thumb_func_end sub_80688A8 + thumb_func_end CreateObedientMon thumb_func_start sub_80688F8 sub_80688F8: @ 80688F8 @@ -2152,7 +1091,7 @@ DoScriptedWildBattle: @ 8068C18 adds r1, r5, 0 adds r2, r4, 0 movs r3, 0x20 - bl sub_80688A8 + bl CreateObedientMon cmp r6, 0 beq _08068C60 add r0, sp, 0x10 @@ -2182,22 +1121,22 @@ CalculateBoxMonChecksum: @ 8068C78 movs r6, 0 ldr r1, [r4] movs r2, 0 - bl pokemon_data_permutator + bl GetSubstruct adds r5, r0, 0 ldr r1, [r4] adds r0, r4, 0 movs r2, 0x1 - bl pokemon_data_permutator + bl GetSubstruct adds r7, r0, 0 ldr r1, [r4] adds r0, r4, 0 movs r2, 0x2 - bl pokemon_data_permutator + bl GetSubstruct mov r8, r0 ldr r1, [r4] adds r0, r4, 0 movs r2, 0x3 - bl pokemon_data_permutator + bl GetSubstruct adds r3, r0, 0 movs r1, 0x5 _08068CB2: @@ -2335,7 +1274,7 @@ CalculateMonStats: @ 8068D0C lsls r0, 16 lsrs r7, r0, 16 adds r0, r5, 0 - bl level_by_exp + bl GetLevelFromMonExp lsls r0, 24 lsrs r0, 24 str r0, [sp] @@ -2638,8 +1577,8 @@ sub_8069004: @ 8069004 bx r0 thumb_func_end sub_8069004 - thumb_func_start level_by_exp -level_by_exp: @ 8069054 + thumb_func_start GetLevelFromMonExp +GetLevelFromMonExp: @ 8069054 push {r4-r6,lr} adds r5, r0, 0 movs r1, 0xB @@ -2690,7 +1629,7 @@ _080690AA: pop {r1} bx r1 .pool - thumb_func_end level_by_exp + thumb_func_end GetLevelFromMonExp thumb_func_start GetLevelFromBoxMonExp GetLevelFromBoxMonExp: @ 80690C0 @@ -2746,8 +1685,8 @@ _08069116: .pool thumb_func_end GetLevelFromBoxMonExp - thumb_func_start GiveMoveToBoxMon_ -GiveMoveToBoxMon_: @ 806912C + thumb_func_start GiveMoveToMon +GiveMoveToMon: @ 806912C push {lr} lsls r1, 16 lsrs r1, 16 @@ -2756,7 +1695,7 @@ GiveMoveToBoxMon_: @ 806912C lsrs r0, 16 pop {r1} bx r1 - thumb_func_end GiveMoveToBoxMon_ + thumb_func_end GiveMoveToMon thumb_func_start GiveMoveToBoxMon GiveMoveToBoxMon: @ 8069140 @@ -2815,8 +1754,8 @@ _080691A4: .pool thumb_func_end GiveMoveToBoxMon - thumb_func_start sub_80691B0 -sub_80691B0: @ 80691B0 + thumb_func_start GiveMoveToBattleMon +GiveMoveToBattleMon: @ 80691B0 push {r4,r5,lr} lsls r1, 16 lsrs r4, r1, 16 @@ -2852,10 +1791,10 @@ _080691EA: pop {r1} bx r1 .pool - thumb_func_end sub_80691B0 + thumb_func_end GiveMoveToBattleMon - thumb_func_start sub_80691F4 -sub_80691F4: @ 80691F4 + thumb_func_start SetMonMoveSlot +SetMonMoveSlot: @ 80691F4 push {r4,r5,lr} sub sp, 0x4 adds r5, r0, 0 @@ -2885,10 +1824,10 @@ sub_80691F4: @ 80691F4 pop {r0} bx r0 .pool - thumb_func_end sub_80691F4 + thumb_func_end SetMonMoveSlot - thumb_func_start sub_8069234 -sub_8069234: @ 8069234 + thumb_func_start SetBattleMonMoveSlot +SetBattleMonMoveSlot: @ 8069234 push {r4,lr} lsls r1, 16 lsrs r1, 16 @@ -2912,7 +1851,7 @@ sub_8069234: @ 8069234 pop {r0} bx r0 .pool - thumb_func_end sub_8069234 + thumb_func_end SetBattleMonMoveSlot thumb_func_start GiveMonInitialMoveset GiveMonInitialMoveset: @ 8069264 @@ -2942,7 +1881,7 @@ GiveBoxMonInitialMoveset: @ 8069270 lsls r0, 24 lsrs r0, 24 mov r10, r0 - ldr r0, =gLevelUpLearnsetPointers + ldr r0, =gLevelUpLearnsets lsls r6, r4, 2 adds r0, r6, r0 ldr r0, [r0] @@ -2954,7 +1893,7 @@ GiveBoxMonInitialMoveset: @ 8069270 mov r9, r2 movs r3, 0 _080692AE: - ldr r0, =gLevelUpLearnsetPointers + ldr r0, =gLevelUpLearnsets adds r7, r6, r0 ldr r0, [r7] adds r0, r3, r0 @@ -3004,8 +1943,8 @@ _080692FC: .pool thumb_func_end GiveBoxMonInitialMoveset - thumb_func_start sub_8069318 -sub_8069318: @ 8069318 + thumb_func_start MonTryLearningNewMove +MonTryLearningNewMove: @ 8069318 push {r4-r7,lr} mov r7, r10 mov r6, r9 @@ -3033,11 +1972,11 @@ sub_8069318: @ 8069318 mov r10, r0 cmp r4, 0 beq _080693B0 - ldr r4, =gUnknown_020244E8 + ldr r4, =sLearningMoveTableID mov r1, sp ldrb r1, [r1] strb r1, [r4] - ldr r2, =gLevelUpLearnsetPointers + ldr r2, =gLevelUpLearnsets mov r5, r9 lsls r3, r5, 2 adds r5, r3, r2 @@ -3078,11 +2017,11 @@ _080693A8: cmp r0, r4 bne _08069384 _080693B0: - ldr r3, =gLevelUpLearnsetPointers + ldr r3, =gLevelUpLearnsets mov r1, r9 lsls r4, r1, 2 adds r1, r4, r3 - ldr r2, =gUnknown_020244E8 + ldr r2, =sLearningMoveTableID ldrb r0, [r2] ldr r1, [r1] lsls r0, 1 @@ -3099,7 +2038,7 @@ _080693B0: cmp r0, r1 bne _08069402 _080693D8: - ldr r2, =gUnknown_020244E2 + ldr r2, =gMoveToLearn mov r0, r12 adds r1, r3, r0 ldrb r0, [r6] @@ -3115,7 +2054,7 @@ _080693D8: strb r0, [r6] ldrh r1, [r2] mov r0, r8 - bl GiveMoveToBoxMon_ + bl GiveMoveToMon lsls r0, 16 lsrs r0, 16 str r0, [sp] @@ -3131,7 +2070,7 @@ _08069404: pop {r1} bx r1 .pool - thumb_func_end sub_8069318 + thumb_func_end MonTryLearningNewMove thumb_func_start DeleteFirstMoveAndGiveMoveToMon DeleteFirstMoveAndGiveMoveToMon: @ 8069424 diff --git a/asm/pokemon_2.s b/asm/pokemon_2.s index 96da3e639..95b5bca9d 100644 --- a/asm/pokemon_2.s +++ b/asm/pokemon_2.s @@ -592,9 +592,9 @@ _0806A256: bx r0 thumb_func_end pokemon_decrypt - thumb_func_start pokemon_data_permutator -@ int pokemon_data_permutator(pokemon *mon, int a2, u8 a3) -pokemon_data_permutator: @ 806A270 + thumb_func_start GetSubstruct +@ int GetSubstruct(pokemon *mon, int a2, u8 a3) +GetSubstruct: @ 806A270 push {r4-r6,lr} adds r5, r0, 0 adds r0, r1, 0 @@ -980,7 +980,7 @@ _0806A510: pop {r4-r6} pop {r1} bx r1 - thumb_func_end pokemon_data_permutator + thumb_func_end GetSubstruct thumb_func_start GetMonData @ int GetMonData(pokemon *mon, enum pokemon_data_request req, void *data) @@ -1160,23 +1160,23 @@ GetBoxMonData: @ 806A674 ble _0806A6F2 ldr r1, [r0] movs r2, 0 - bl pokemon_data_permutator + bl GetSubstruct mov r9, r0 mov r0, r8 ldr r1, [r0] movs r2, 0x1 - bl pokemon_data_permutator + bl GetSubstruct mov r10, r0 mov r2, r8 ldr r1, [r2] mov r0, r8 movs r2, 0x2 - bl pokemon_data_permutator + bl GetSubstruct adds r7, r0, 0 mov r0, r8 ldr r1, [r0] movs r2, 0x3 - bl pokemon_data_permutator + bl GetSubstruct adds r5, r0, 0 mov r0, r8 bl pokemon_decrypt @@ -2083,22 +2083,22 @@ SetBoxMonData: @ 806AD9C ldr r1, [r7] adds r0, r7, 0 movs r2, 0 - bl pokemon_data_permutator + bl GetSubstruct mov r8, r0 ldr r1, [r7] adds r0, r7, 0 movs r2, 0x1 - bl pokemon_data_permutator + bl GetSubstruct mov r9, r0 ldr r1, [r7] adds r0, r7, 0 movs r2, 0x2 - bl pokemon_data_permutator + bl GetSubstruct adds r6, r0, 0 ldr r1, [r7] adds r0, r7, 0 movs r2, 0x3 - bl pokemon_data_permutator + bl GetSubstruct adds r5, r0, 0 adds r0, r7, 0 bl pokemon_decrypt @@ -2963,7 +2963,7 @@ _0806B4B2: cmp r0, 0 bne _0806B514 mov r0, r8 - bl sub_806E924 + bl RestoreMonMovesPP adds r0, r4, 0 mov r1, r8 movs r2, 0x50 diff --git a/asm/pokemon_3.s b/asm/pokemon_3.s index 6465575f9..6ed10cd5c 100644 --- a/asm/pokemon_3.s +++ b/asm/pokemon_3.s @@ -4528,7 +4528,7 @@ _0806E0EA: cmp r5, 0x3 ble _0806E0EA movs r5, 0 - ldr r6, =gLevelUpLearnsetPointers + ldr r6, =gLevelUpLearnsets lsls r1, r7, 2 adds r2, r1, r6 ldr r3, [r2] @@ -4562,7 +4562,7 @@ _0806E118: cmp r1, r0 beq _0806E168 ldr r0, [sp, 0x14] - ldr r1, =gLevelUpLearnsetPointers + ldr r1, =gLevelUpLearnsets adds r6, r0, r1 ldr r2, =0x000001ff mov r8, r2 @@ -4598,7 +4598,7 @@ _0806E168: cmp r2, r0 beq _0806E1AC ldr r1, [sp, 0x14] - ldr r2, =gLevelUpLearnsetPointers + ldr r2, =gLevelUpLearnsets adds r6, r1, r2 ldr r0, =0x000001ff mov r8, r0 @@ -4667,7 +4667,7 @@ sub_806E204: @ 806E204 lsls r0, 16 movs r5, 0 movs r4, 0 - ldr r1, =gLevelUpLearnsetPointers + ldr r1, =gLevelUpLearnsets lsrs r0, 14 adds r0, r1 ldr r2, [r0] @@ -4752,7 +4752,7 @@ _0806E2A0: cmp r5, 0x3 ble _0806E2A0 movs r5, 0 - ldr r3, =gLevelUpLearnsetPointers + ldr r3, =gLevelUpLearnsets ldr r2, [sp, 0x38] adds r1, r2, r3 ldr r0, [r1] @@ -4788,7 +4788,7 @@ _0806E2D0: cmp r1, r0 beq _0806E322 ldr r0, [sp, 0x38] - ldr r1, =gLevelUpLearnsetPointers + ldr r1, =gLevelUpLearnsets adds r6, r0, r1 ldr r2, =0x000001ff mov r8, r2 @@ -4825,7 +4825,7 @@ _0806E322: cmp r2, r0 beq _0806E368 ldr r2, [sp, 0x38] - ldr r0, =gLevelUpLearnsetPointers + ldr r0, =gLevelUpLearnsets adds r6, r2, r0 ldr r2, =0x000001ff mov r8, r2 @@ -5533,13 +5533,13 @@ _0806E91E: bx r1 thumb_func_end sub_806E8D4 - thumb_func_start sub_806E924 -sub_806E924: @ 806E924 + thumb_func_start RestoreMonMovesPP +RestoreMonMovesPP: @ 806E924 push {lr} bl pokemon_restore_pp pop {r0} bx r0 - thumb_func_end sub_806E924 + thumb_func_end RestoreMonMovesPP thumb_func_start pokemon_restore_pp pokemon_restore_pp: @ 806E930 diff --git a/asm/rom_815A0D4.s b/asm/rom_815A0D4.s index fa6cbd285..1c226ca28 100644 --- a/asm/rom_815A0D4.s +++ b/asm/rom_815A0D4.s @@ -12852,7 +12852,7 @@ _081609A8: lsls r1, 16 lsrs r1, 16 adds r0, r4, 0 - bl GiveMoveToBoxMon_ + bl GiveMoveToMon lsls r0, 16 ldr r1, =0xffff0000 cmp r0, r1 @@ -13291,7 +13291,7 @@ _08160D6C: adds r0, 0x45 ldrb r2, [r0] adds r0, r4, 0 - bl sub_80691F4 + bl SetMonMoveSlot ldr r4, =gStringVar2 bl sub_8161054 mov r1, r8 diff --git a/asm/rom_8161F74.s b/asm/rom_8161F74.s index 32922aa54..79e8ee48d 100644 --- a/asm/rom_8161F74.s +++ b/asm/rom_8161F74.s @@ -2379,7 +2379,7 @@ _081633B8: mov r7, r10 adds r0, r3, r7 str r3, [sp, 0x38] - bl sub_80691F4 + bl SetMonMoveSlot ldr r0, [r5] ldr r1, [sp, 0x3C] adds r0, r1, r0 @@ -6179,7 +6179,7 @@ _081654DE: ldr r0, [sp, 0x64] ldrb r2, [r0] adds r0, r4, r6 - bl sub_80691F4 + bl SetMonMoveSlot ldr r0, [sp, 0x44] adds r0, 0x1 str r0, [sp, 0x44] @@ -6311,7 +6311,7 @@ _08165604: lsrs r2, 24 adds r0, r4, r3 str r3, [sp, 0x68] - bl sub_80691F4 + bl SetMonMoveSlot ldr r0, [r6] adds r0, r5, r0 ldr r2, [sp, 0x44] @@ -7578,7 +7578,7 @@ _0816602E: mov r0, r8 add r0, r10 str r3, [sp, 0x34] - bl sub_80691F4 + bl SetMonMoveSlot ldr r3, [sp, 0x34] ldr r0, [r3] adds r0, r5, r0 diff --git a/asm/rom_818CFC8.s b/asm/rom_818CFC8.s index 13e89f2ba..cbeda186e 100644 --- a/asm/rom_818CFC8.s +++ b/asm/rom_818CFC8.s @@ -5177,7 +5177,7 @@ _0818FB18: adds r0, r7, r2 mov r2, r12 str r3, [sp, 0x24] - bl sub_80691F4 + bl SetMonMoveSlot ldr r7, =gSaveBlock2Ptr ldr r0, [r7] add r0, r9 @@ -14798,7 +14798,7 @@ _08194DEA: adds r0, r7, r1 movs r1, 0xA6 str r3, [sp, 0x4] - bl sub_80691F4 + bl SetMonMoveSlot ldr r3, [sp, 0x4] _08194E00: mov r6, r8 @@ -36656,7 +36656,7 @@ _0819FFE4: adds r1, r3 ldrh r1, [r1] str r1, [sp, 0x8] - ldr r1, =gLevelUpLearnsetPointers + ldr r1, =gLevelUpLearnsets ldr r2, [sp, 0x8] lsls r0, r2, 2 adds r0, r1 @@ -36922,7 +36922,7 @@ sub_81A01E8: @ 81A01E8 bne _081A0204 movs r4, 0x32 _081A0204: - ldr r1, =gLevelUpLearnsetPointers + ldr r1, =gLevelUpLearnsets lsls r0, r2, 2 adds r0, r1 ldr r6, [r0] @@ -44759,7 +44759,7 @@ _081A4508: adds r0, r7, 0 movs r1, 0xA6 adds r2, r6, 0 - bl sub_80691F4 + bl SetMonMoveSlot _081A4516: mov r4, r10 lsls r0, r4, 24 @@ -46018,7 +46018,7 @@ _081A4F6A: adds r0, r6, r3 adds r1, r4, 0 str r3, [sp, 0x40] - bl sub_80691F4 + bl SetMonMoveSlot ldr r3, [sp, 0x40] cmp r4, 0xDA bne _081A4F9C @@ -49892,7 +49892,7 @@ sub_81A7024: @ 81A7024 bne _081A7034 movs r1, 0xDA _081A7034: - bl sub_80691F4 + bl SetMonMoveSlot pop {r0} bx r0 thumb_func_end sub_81A7024 @@ -51446,7 +51446,7 @@ _081A7CBA: lsls r2, r4, 24 lsrs r2, 24 ldr r0, =gEnemyParty - bl sub_80691F4 + bl SetMonMoveSlot adds r4, 0x1 cmp r4, 0x3 ble _081A7CBA @@ -54887,7 +54887,7 @@ _081A98EE: mov r5, r10 adds r0, r7, r5 movs r1, 0xA6 - bl sub_80691F4 + bl SetMonMoveSlot _081A9900: mov r6, r8 cmp r6, 0x3 @@ -55449,7 +55449,7 @@ _081A9DA4: lsls r2, 24 lsrs r2, 24 ldr r0, =gEnemyParty - bl sub_80691F4 + bl SetMonMoveSlot ldr r0, [sp, 0xC] adds r0, 0x1 str r0, [sp, 0xC] @@ -80216,7 +80216,7 @@ sub_81B6DC4: @ 81B6DC4 beq _081B6E78 ldrh r1, [r7, 0xE] adds r0, r5, 0 - bl GiveMoveToBoxMon_ + bl GiveMoveToMon lsls r0, 16 ldr r1, =0xffff0000 cmp r0, r1 @@ -80644,7 +80644,7 @@ sub_81B71D4: @ 81B71D4 lsrs r2, 24 adds r0, r4, 0 adds r1, r5, 0 - bl sub_80691F4 + bl SetMonMoveSlot adds r0, r6, 0 bl sub_81B6EB4 _081B7220: @@ -81202,7 +81202,7 @@ _081B772C: ldr r1, =gPlayerParty adds r0, r1 movs r1, 0x1 - bl sub_8069318 + bl MonTryLearningNewMove lsls r0, 16 lsrs r1, r0, 16 strh r6, [r4, 0x10] @@ -81261,7 +81261,7 @@ sub_81B77AC: @ 81B77AC ldr r1, =gPlayerParty adds r0, r1 movs r1, 0 - bl sub_8069318 + bl MonTryLearningNewMove lsls r0, 16 lsrs r1, r0, 16 ldr r0, =0x0000fffe @@ -81363,7 +81363,7 @@ sub_81B787C: @ 81B787C ldr r1, =gStringVar1 bl GetMonNickname ldr r0, =gStringVar2 - ldr r6, =gUnknown_020244E2 + ldr r6, =gMoveToLearn ldrh r2, [r6] movs r1, 0xD muls r1, r2 @@ -82059,7 +82059,7 @@ sub_81B7E4C: @ 81B7E4C beq _081B7EF8 ldrh r1, [r7, 0xE] adds r0, r5, 0 - bl GiveMoveToBoxMon_ + bl GiveMoveToMon lsls r0, 16 ldr r1, =0xffff0000 cmp r0, r1 @@ -85026,7 +85026,7 @@ sub_81B9770: @ 81B9770 ldr r4, =gSpecialVar_0x8005 ldrb r2, [r4] movs r1, 0 - bl sub_80691F4 + bl SetMonMoveSlot mov r1, r8 ldrh r0, [r1] muls r0, r6 @@ -86877,4 +86877,4 @@ GetGlyphWidthFont6: @ 81BA6CC thumb_func_end GetGlyphWidthFont6 - .align 2, 0 @ Don't pad with nop. \ No newline at end of file + .align 2, 0 @ Don't pad with nop. diff --git a/asm/rom_81BE66C.s b/asm/rom_81BE66C.s index a444df913..4f1266463 100644 --- a/asm/rom_81BE66C.s +++ b/asm/rom_81BE66C.s @@ -33116,7 +33116,7 @@ sub_81CF8E4: @ 81CF8E4 lsls r0, 24 lsrs r5, r0, 24 adds r0, r4, 0 - bl level_by_exp + bl GetLevelFromMonExp lsls r0, 24 lsrs r7, r0, 24 ldr r2, =gStringVar3 @@ -34492,7 +34492,7 @@ sub_81D035C: @ 81D035C lsls r0, 24 lsrs r5, r0, 24 adds r0, r4, 0 - bl level_by_exp + bl GetLevelFromMonExp lsls r0, 24 lsrs r0, 24 mov r8, r0 @@ -34982,7 +34982,7 @@ sub_81D06E4: @ 81D06E4 adds r2, r5, 0 bl GetMonData adds r0, r4, 0 - bl level_by_exp + bl GetLevelFromMonExp strb r0, [r7] adds r0, r4, 0 bl pokemon_get_gender diff --git a/asm/script_pokemon_util_80F87D8.s b/asm/script_pokemon_util_80F87D8.s index 4dd19bc62..5327960b7 100644 --- a/asm/script_pokemon_util_80F87D8.s +++ b/asm/script_pokemon_util_80F87D8.s @@ -1520,7 +1520,7 @@ _080F941C: ldr r1, =gPlayerParty adds r0, r1 adds r1, r4, 0 - bl sub_80691F4 + bl SetMonMoveSlot pop {r4} pop {r0} bx r0 diff --git a/asm/wild_encounter.s b/asm/wild_encounter.s index df6196372..c22a9d5e9 100644 --- a/asm/wild_encounter.s +++ b/asm/wild_encounter.s @@ -1063,7 +1063,7 @@ _080B50A2: lsls r2, r4, 24 lsrs r2, 24 ldr r0, =gEnemyParty - bl sub_80691F4 + bl SetMonMoveSlot adds r0, r4, 0x1 lsls r0, 16 lsrs r4, r0, 16 diff --git a/data/level_up_learnset_pointers.inc b/data/level_up_learnset_pointers.inc index 823124c55..4b757dda9 100644 --- a/data/level_up_learnset_pointers.inc +++ b/data/level_up_learnset_pointers.inc @@ -1,5 +1,5 @@ .align 2 -gLevelUpLearnsetPointers:: @ 832937C +gLevelUpLearnsets:: @ 832937C .4byte gBulbasaurLevelUpLearnset .4byte gBulbasaurLevelUpLearnset .4byte gIvysaurLevelUpLearnset diff --git a/include/pokemon.h b/include/pokemon.h index 449cf37c0..7a3274418 100644 --- a/include/pokemon.h +++ b/include/pokemon.h @@ -65,7 +65,7 @@ #define MON_DATA_SPD 61 #define MON_DATA_SPATK 62 #define MON_DATA_SPDEF 63 -#define MON_DATA_64 64 +#define MON_DATA_MAIL 64 #define MON_DATA_SPECIES2 65 #define MON_DATA_IVS 66 #define MON_DATA_CHAMPION_RIBBON 67 @@ -89,7 +89,11 @@ #define MON_DATA_DEF2 85 #define MON_DATA_SPD2 86 #define MON_DATA_SPATK2 87 -#define MON_DATA_SPDEF2 88 +#define MON_DATA_SPDEF2 88 + +#define OT_ID_RANDOM_NO_SHINY 2 +#define OT_ID_PRESET 1 +#define OT_ID_PLAYER_ID 0 #define MON_MALE 0x00 #define MON_FEMALE 0xFE @@ -114,7 +118,34 @@ #define TYPE_DRAGON 0x10 #define TYPE_DARK 0x11 -enum { +#define PARTY_SIZE 6 +#define MAX_TOTAL_EVS 510 +#define NUM_STATS 6 +#define UNOWN_FORM_COUNT 28 +#define MAX_MON_LEVEL 100 + +enum +{ + EGG_GROUP_NONE, + EGG_GROUP_MONSTER, + EGG_GROUP_WATER_1, + EGG_GROUP_BUG, + EGG_GROUP_FLYING, + EGG_GROUP_FIELD, + EGG_GROUP_FAIRY, + EGG_GROUP_GRASS, + EGG_GROUP_HUMAN_LIKE, + EGG_GROUP_WATER_3, + EGG_GROUP_MINERAL, + EGG_GROUP_AMORPHOUS, + EGG_GROUP_WATER_2, + EGG_GROUP_DITTO, + EGG_GROUP_DRAGON, + EGG_GROUP_UNDISCOVERED +}; + +enum +{ NATURE_HARDY, NATURE_LONELY, NATURE_BRAVE, @@ -258,9 +289,6 @@ struct Pokemon u16 spDefense; }; -extern struct Pokemon gPlayerParty[6]; -extern struct Pokemon gEnemyParty[6]; - struct PokemonStorage { /*0x0000*/ u8 currentBox; @@ -269,6 +297,33 @@ struct PokemonStorage /*0x83C2*/ u8 boxWallpapers[14]; }; +struct UnknownPokemonStruct +{ + u16 species; + u16 heldItem; + u16 moves[4]; + u8 level; + u8 ppBonuses; + u8 hpEV; + u8 attackEV; + u8 defenseEV; + u8 speedEV; + u8 spAttackEV; + u8 spDefenseEV; + u32 otId; + u32 hpIV:5; + u32 attackIV:5; + u32 defenseIV:5; + u32 speedIV:5; + u32 spAttackIV:5; + u32 spDefenseIV:5; + u32 gap:1; + u32 altAbility:1; + u32 personality; + u8 nickname[POKEMON_NAME_LENGTH + 1]; + u8 friendship; +}; + struct BattlePokemon { /*0x00*/ u16 species; @@ -348,7 +403,8 @@ struct BaseStats /* 0x16 */ u8 ability1; /* 0x17 */ u8 ability2; /* 0x18 */ u8 safariZoneFleeRate; - /* 0x19 */ u8 bodyColor; + /* 0x19 */ u8 bodyColor : 7; + u8 noFlip : 1; }; struct BattleMove @@ -361,14 +417,138 @@ struct BattleMove u8 secondaryEffectChance; u8 target; u8 priority; - u32 flags; + u8 flags; }; +struct __attribute__((packed)) LevelUpMove +{ + u16 move:9; + u16 level:7; +}; + +enum +{ + GROWTH_MEDIUM_FAST, + GROWTH_ERRATIC, + GROWTH_FLUCTUATING, + GROWTH_MEDIUM_SLOW, + GROWTH_FAST, + GROWTH_SLOW +}; + +enum +{ + BODY_COLOR_RED, + BODY_COLOR_BLUE, + BODY_COLOR_YELLOW, + BODY_COLOR_GREEN, + BODY_COLOR_BLACK, + BODY_COLOR_BROWN, + BODY_COLOR_PURPLE, + BODY_COLOR_GRAY, + BODY_COLOR_WHITE, + BODY_COLOR_PINK +}; + +#define EVO_FRIENDSHIP 0x0001 // Pokémon levels up with friendship ≥ 220 +#define EVO_FRIENDSHIP_DAY 0x0002 // Pokémon levels up during the day with friendship ≥ 220 +#define EVO_FRIENDSHIP_NIGHT 0x0003 // Pokémon levels up at night with friendship ≥ 220 +#define EVO_LEVEL 0x0004 // Pokémon reaches the specified level +#define EVO_TRADE 0x0005 // Pokémon is traded +#define EVO_TRADE_ITEM 0x0006 // Pokémon is traded while it's holding the specified item +#define EVO_ITEM 0x0007 // specified item is used on Pokémon +#define EVO_LEVEL_ATK_GT_DEF 0x0008 // Pokémon reaches the specified level with attack > defense +#define EVO_LEVEL_ATK_EQ_DEF 0x0009 // Pokémon reaches the specified level with attack = defense +#define EVO_LEVEL_ATK_LT_DEF 0x000a // Pokémon reaches the specified level with attack < defense +#define EVO_LEVEL_SILCOON 0x000b // Pokémon reaches the specified level with a Silcoon personality value +#define EVO_LEVEL_CASCOON 0x000c // Pokémon reaches the specified level with a Cascoon personality value +#define EVO_LEVEL_NINJASK 0x000d // Pokémon reaches the specified level (special value for Ninjask) +#define EVO_LEVEL_SHEDINJA 0x000e // Pokémon reaches the specified level (special value for Shedinja) +#define EVO_BEAUTY 0x000f // Pokémon levels up with beauty ≥ specified value + +struct Evolution +{ + u16 method; + u16 param; + u16 targetSpecies; +}; + +struct EvolutionData +{ + struct Evolution evolutions[5]; +}; + +extern u8 gPlayerPartyCount; +extern struct Pokemon gPlayerParty[PARTY_SIZE]; +extern u8 gEnemyPartyCount; +extern struct Pokemon gEnemyParty[PARTY_SIZE]; +extern const struct BaseStats gBaseStats[]; +extern const struct EvolutionData gEvolutionTable[]; +extern struct PokemonStorage* gPokemonStoragePtr; +extern const u32 gExperienceTables[][MAX_MON_LEVEL + 1]; + +void ZeroBoxMonData(struct BoxPokemon *boxMon); +void ZeroMonData(struct Pokemon *mon); +void ZeroPlayerPartyMons(void); +void ZeroEnemyPartyMons(void); +void CreateMon(struct Pokemon *mon, u16 species, u8 level, u8 fixedIV, u8 hasFixedPersonality, u32 fixedPersonality, u8 otIdType, u32 fixedOtId); +void CreateBoxMon(struct BoxPokemon *boxMon, u16 species, u8 level, u8 fixedIV, u8 hasFixedPersonality, u32 fixedPersonality, u8 otIdType, u32 fixedOtId); +void CreateMonWithNature(struct Pokemon *mon, u16 species, u8 level, u8 fixedIV, u8 nature); +void CreateMonWithGenderNatureLetter(struct Pokemon *mon, u16 species, u8 level, u8 fixedIV, u8 gender, u8 nature, u8 unownLetter); +void CreateMaleMon(struct Pokemon *mon, u16 species, u8 level); +void CreateMonWithIVsPersonality(struct Pokemon *mon, u16 species, u8 level, u32 ivs, u32 personality); +void CreateMonWithIVsOTID(struct Pokemon *mon, u16 species, u8 level, u8 *ivs, u32 otId); +void CreateMonWithEVSpread(struct Pokemon *mon, u16 species, u8 level, u8 fixedIV, u8 evSpread); +u16 CalculateBoxMonChecksum(struct BoxPokemon *boxMon); +void CalculateMonStats(struct Pokemon *mon); +u8 GetLevelFromMonExp(struct Pokemon *mon); +u8 GetLevelFromBoxMonExp(struct BoxPokemon *boxMon); +u16 GiveMoveToMon(struct Pokemon *mon, u16 move); +u16 GiveMoveToBoxMon(struct BoxPokemon *boxMon, u16 move); +u16 GiveMoveToBattleMon(struct BattlePokemon *mon, u16 move); +void RestoreMonMovesPP(struct Pokemon *mon); +void SetMonMoveSlot(struct Pokemon *mon, u16 move, u8 slot); +void SetBattleMonMoveSlot(struct BattlePokemon *mon, u16 move, u8 slot); +void GiveMonInitialMoveset(struct Pokemon *mon); +void GiveBoxMonInitialMoveset(struct BoxPokemon *boxMon); +void DeleteFirstMoveAndGiveMoveToMon(struct Pokemon *mon, u16 move); +void DeleteFirstMoveAndGiveMoveToBoxMon(struct BoxPokemon *boxMon, u16 move); + +u8 GetMonGender(struct Pokemon *mon); +u8 GetBoxMonGender(struct BoxPokemon *boxMon); +u8 GetGenderFromSpeciesAndPersonality(u16 species, u32 personality); +void EncryptBoxMon(struct BoxPokemon *boxMon); +void DecryptBoxMon(struct BoxPokemon *boxMon); + // These are full type signatures for GetMonData() and GetBoxMonData(), // but they are not used since some code erroneously omits the third arg. // u32 GetMonData(struct Pokemon *mon, s32 field, u8 *data); +// u32 GetBoxMonData(struct BoxPokemon *boxMon, s32 field, u8 *data); u32 GetMonData(); +u32 GetBoxMonData(); -u8 GetGenderFromSpeciesAndPersonality(u16 species, u32 personality); +void SetMonData(struct Pokemon *mon, s32 field, const void *data); +void SetBoxMonData(struct BoxPokemon *boxMon, s32 field, const void *data); +void CopyMon(void *dest, void *src, size_t size); +u8 GiveMonToPlayer(struct Pokemon *mon); +u8 SendMonToPC(struct Pokemon *mon); +u8 CalculatePlayerPartyCount(void); +u8 CalculateEnemyPartyCount(void); + +u8 GetAbilityBySpecies(u16 species, bool8 altAbility); +u8 GetMonAbility(struct Pokemon *mon); +void CreateSecretBaseEnemyParty(struct SecretBaseRecord *secretBaseRecord); +u8 GetSecretBaseTrainerPicIndex(void); +u8 GetSecretBaseTrainerNameIndex(void); +u8 PlayerPartyAndPokemonStorageFull(void); +u8 PokemonStorageFull(void); +void GetSpeciesName(u8 *name, u16 species); +u8 CalculatePPWithBonus(u16 move, u8 ppBonuses, u8 moveIndex); +void RemoveMonPPBonus(struct Pokemon *mon, u8 moveIndex); +void RemoveBattleMonPPBonus(struct BattlePokemon *mon, u8 moveIndex); +void CopyPlayerPartyMonToBattleData(u8 battleIndex, u8 partyIndex); + +u8 GetNature(struct Pokemon *mon); +u8 GetNatureFromPersonality(u32 personality); #endif // GUARD_POKEMON_H diff --git a/include/text.h b/include/text.h index 2c5bf7bee..f52336d84 100644 --- a/include/text.h +++ b/include/text.h @@ -2,14 +2,78 @@ #define GUARD_TEXT_H #define CHAR_SPACE 0x00 +#define CHAR_0 0xA1 #define CHAR_QUESTION_MARK 0xAC +#define CHAR_PERIOD 0xAD #define CHAR_HYPHEN 0xAE +#define CHAR_ELLIPSIS 0xB0 +#define CHAR_MALE 0xB5 +#define CHAR_FEMALE 0xB6 #define CHAR_CURRENCY 0xB7 +#define CHAR_COMMA 0xB8 +#define CHAR_MULT_SIGN 0xB9 +#define CHAR_SLASH 0xBA +#define CHAR_A 0xBB +#define CHAR_B 0xBC +#define CHAR_C 0xBD +#define CHAR_D 0xBE +#define CHAR_E 0xBF +#define CHAR_F 0xC0 +#define CHAR_G 0xC1 +#define CHAR_H 0xC2 +#define CHAR_I 0xC3 +#define CHAR_J 0xC4 +#define CHAR_K 0xC5 +#define CHAR_L 0xC6 +#define CHAR_M 0xC7 +#define CHAR_N 0xC8 +#define CHAR_O 0xC9 +#define CHAR_P 0xCA +#define CHAR_Q 0xCB +#define CHAR_R 0xCC +#define CHAR_S 0xCD +#define CHAR_T 0xCE +#define CHAR_U 0xCF +#define CHAR_V 0xD0 +#define CHAR_W 0xD1 +#define CHAR_X 0xD2 +#define CHAR_Y 0xD3 +#define CHAR_Z 0xD4 +#define CHAR_a 0xD5 +#define CHAR_b 0xD6 +#define CHAR_c 0xD7 +#define CHAR_d 0xD8 +#define CHAR_e 0xD9 +#define CHAR_f 0xDA +#define CHAR_g 0xDB +#define CHAR_h 0xDC +#define CHAR_i 0xDD +#define CHAR_j 0xDE +#define CHAR_k 0xDF +#define CHAR_l 0xE0 +#define CHAR_m 0xE1 +#define CHAR_n 0xE2 +#define CHAR_o 0xE3 +#define CHAR_p 0xE4 +#define CHAR_q 0xE5 +#define CHAR_r 0xE6 +#define CHAR_s 0xE7 +#define CHAR_t 0xE8 +#define CHAR_u 0xE9 +#define CHAR_v 0xEA +#define CHAR_w 0xEB +#define CHAR_x 0xEC +#define CHAR_y 0xED +#define CHAR_z 0xEE #define CHAR_COLON 0xF0 +#define CHAR_PROMPT_SCROLL 0xFA // waits for button press and scrolls dialog +#define CHAR_PROMPT_CLEAR 0xFB // waits for button press and clears dialog #define EXT_CTRL_CODE_BEGIN 0xFC // extended control code #define PLACEHOLDER_BEGIN 0xFD // string placeholder #define CHAR_NEWLINE 0xFE -#define EOS 0xFF // end of string +#define EOS 0xFF // end of string + +#define EXT_CTRL_CODE_JPN 0x15 #define NUM_TEXT_PRINTERS 32 @@ -30,9 +94,9 @@ struct TextPrinter u8 bgColor:4; u8 shadowColor:4; } subPrinter; - + void (*callback)(struct TextSubPrinter *, u16); // 0x10 - + union { struct TextPrinterSubStruct { @@ -48,10 +112,10 @@ struct TextPrinter u8 field_6; u8 active; } sub; - + u8 sub_fields[8]; } sub_union; - + u8 state; // 0x1C u8 text_speed; u8 delayCounter; diff --git a/ld_script.txt b/ld_script.txt index cd42757fe..53571ee9b 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -66,6 +66,7 @@ SECTIONS { asm/battle_controller_opponent.o(.text); asm/battle_9.o(.text); asm/battle_controller_linkopponent.o(.text); + src/pokemon_1.o(.text); asm/pokemon_1.o(.text); src/calculate_base_damage.o(.text); asm/pokemon_2.o(.text); diff --git a/src/pokemon_1.c b/src/pokemon_1.c new file mode 100644 index 000000000..caf7161e1 --- /dev/null +++ b/src/pokemon_1.c @@ -0,0 +1,325 @@ +#include "global.h" +#include "pokemon.h" +#include "rng.h" +#include "main.h" +#include "items.h" +#include "string_util.h" +#include "text.h" + +//Extracts the upper 16 bits of a 32-bit number +#define HIHALF(n) (((n) & 0xFFFF0000) >> 16) + +//Extracts the lower 16 bits of a 32-bit number +#define LOHALF(n) ((n) & 0xFFFF) + +extern u8 sav1_map_get_name(void); + +void ZeroBoxMonData(struct BoxPokemon *boxMon) +{ + u8 *raw = (u8 *)boxMon; + u32 i; + for (i = 0; i < sizeof(struct BoxPokemon); i++) + raw[i] = 0; +} + +void ZeroMonData(struct Pokemon *mon) +{ + u32 arg; + ZeroBoxMonData(&mon->box); + arg = 0; + SetMonData(mon, MON_DATA_STATUS, &arg); + SetMonData(mon, MON_DATA_LEVEL, &arg); + SetMonData(mon, MON_DATA_HP, &arg); + SetMonData(mon, MON_DATA_MAX_HP, &arg); + SetMonData(mon, MON_DATA_ATK, &arg); + SetMonData(mon, MON_DATA_DEF, &arg); + SetMonData(mon, MON_DATA_SPD, &arg); + SetMonData(mon, MON_DATA_SPATK, &arg); + SetMonData(mon, MON_DATA_SPDEF, &arg); + arg = 255; + SetMonData(mon, MON_DATA_MAIL, &arg); +} + +void ZeroPlayerPartyMons(void) +{ + s32 i; + for (i = 0; i < 6; i++) + ZeroMonData(&gPlayerParty[i]); +} + +void ZeroEnemyPartyMons(void) +{ + s32 i; + for (i = 0; i < 6; i++) + ZeroMonData(&gEnemyParty[i]); +} + +void CreateMon(struct Pokemon *mon, u16 species, u8 level, u8 fixedIV, u8 hasFixedPersonality, u32 fixedPersonality, u8 otIdType, u32 fixedOtId) +{ + u32 arg; + ZeroMonData(mon); + CreateBoxMon(&mon->box, species, level, fixedIV, hasFixedPersonality, fixedPersonality, otIdType, fixedOtId); + SetMonData(mon, MON_DATA_LEVEL, &level); + arg = 255; + SetMonData(mon, MON_DATA_MAIL, &arg); + CalculateMonStats(mon); +} + +void CreateBoxMon(struct BoxPokemon *boxMon, u16 species, u8 level, u8 fixedIV, u8 hasFixedPersonality, u32 fixedPersonality, u8 otIdType, u32 fixedOtId) +{ + u8 speciesName[POKEMON_NAME_LENGTH + 1]; + u32 personality; + u32 value; + u16 checksum; + + ZeroBoxMonData(boxMon); + + if (hasFixedPersonality) + personality = fixedPersonality; + else + personality = Random32(); + + SetBoxMonData(boxMon, MON_DATA_PERSONALITY, &personality); + + //Determine original trainer ID + if (otIdType == OT_ID_RANDOM_NO_SHINY) //Pokemon cannot be shiny + { + u32 shinyValue; + do + { + value = Random32(); + shinyValue = HIHALF(value) ^ LOHALF(value) ^ HIHALF(personality) ^ LOHALF(personality); + } while (shinyValue < 8); + } + else if (otIdType == OT_ID_PRESET) //Pokemon has a preset OT ID + { + value = fixedOtId; + } + else //Player is the OT + { + value = gSaveBlock2Ptr->playerTrainerId[0] + | (gSaveBlock2Ptr->playerTrainerId[1] << 8) + | (gSaveBlock2Ptr->playerTrainerId[2] << 16) + | (gSaveBlock2Ptr->playerTrainerId[3] << 24); + } + + SetBoxMonData(boxMon, MON_DATA_OT_ID, &value); + + checksum = CalculateBoxMonChecksum(boxMon); + SetBoxMonData(boxMon, MON_DATA_CHECKSUM, &checksum); + EncryptBoxMon(boxMon); + GetSpeciesName(speciesName, species); + SetBoxMonData(boxMon, MON_DATA_NICKNAME, speciesName); + SetBoxMonData(boxMon, MON_DATA_LANGUAGE, &gGameLanguage); + SetBoxMonData(boxMon, MON_DATA_OT_NAME, gSaveBlock2Ptr->playerName); + SetBoxMonData(boxMon, MON_DATA_SPECIES, &species); + SetBoxMonData(boxMon, MON_DATA_EXP, &gExperienceTables[gBaseStats[species].growthRate][level]); + SetBoxMonData(boxMon, MON_DATA_FRIENDSHIP, &gBaseStats[species].friendship); + value = sav1_map_get_name(); + SetBoxMonData(boxMon, MON_DATA_MET_LOCATION, &value); + SetBoxMonData(boxMon, MON_DATA_MET_LEVEL, &level); + SetBoxMonData(boxMon, MON_DATA_MET_GAME, &gGameVersion); + value = ITEM_POKE_BALL; + SetBoxMonData(boxMon, MON_DATA_POKEBALL, &value); + SetBoxMonData(boxMon, MON_DATA_OT_GENDER, &gSaveBlock2Ptr->playerGender); + + if (fixedIV < 32) + { + SetBoxMonData(boxMon, MON_DATA_HP_IV, &fixedIV); + SetBoxMonData(boxMon, MON_DATA_ATK_IV, &fixedIV); + SetBoxMonData(boxMon, MON_DATA_DEF_IV, &fixedIV); + SetBoxMonData(boxMon, MON_DATA_SPD_IV, &fixedIV); + SetBoxMonData(boxMon, MON_DATA_SPATK_IV, &fixedIV); + SetBoxMonData(boxMon, MON_DATA_SPDEF_IV, &fixedIV); + } + else + { + u32 iv; + value = Random(); + + iv = value & 0x1F; + SetBoxMonData(boxMon, MON_DATA_HP_IV, &iv); + iv = (value & 0x3E0) >> 5; + SetBoxMonData(boxMon, MON_DATA_ATK_IV, &iv); + iv = (value & 0x7C00) >> 10; + SetBoxMonData(boxMon, MON_DATA_DEF_IV, &iv); + + value = Random(); + + iv = value & 0x1F; + SetBoxMonData(boxMon, MON_DATA_SPD_IV, &iv); + iv = (value & 0x3E0) >> 5; + SetBoxMonData(boxMon, MON_DATA_SPATK_IV, &iv); + iv = (value & 0x7C00) >> 10; + SetBoxMonData(boxMon, MON_DATA_SPDEF_IV, &iv); + } + + if (gBaseStats[species].ability2) + { + value = personality & 1; + SetBoxMonData(boxMon, MON_DATA_ALT_ABILITY, &value); + } + + GiveBoxMonInitialMoveset(boxMon); +} + +void CreateMonWithNature(struct Pokemon *mon, u16 species, u8 level, u8 fixedIV, u8 nature) +{ + u32 personality; + + do + { + personality = Random32(); + } + while (nature != GetNatureFromPersonality(personality)); + + CreateMon(mon, species, level, fixedIV, 1, personality, OT_ID_PLAYER_ID, 0); +} + +void CreateMonWithGenderNatureLetter(struct Pokemon *mon, u16 species, u8 level, u8 fixedIV, u8 gender, u8 nature, u8 unownLetter) +{ + u32 personality; + + if ((u8)(unownLetter - 1) < 28) + { + u16 actualLetter; + + do + { + personality = Random32(); + actualLetter = ((((personality & 0x3000000) >> 18) | ((personality & 0x30000) >> 12) | ((personality & 0x300) >> 6) | (personality & 0x3)) % 28); + } + while (nature != GetNatureFromPersonality(personality) + || gender != GetGenderFromSpeciesAndPersonality(species, personality) + || actualLetter != unownLetter - 1); + } + else + { + do + { + personality = Random32(); + } + while (nature != GetNatureFromPersonality(personality) + || gender != GetGenderFromSpeciesAndPersonality(species, personality)); + } + + CreateMon(mon, species, level, fixedIV, 1, personality, OT_ID_PLAYER_ID, 0); +} + +// This is only used to create Wally's Ralts. +void CreateMaleMon(struct Pokemon *mon, u16 species, u8 level) +{ + u32 personality; + u32 otId; + + do + { + otId = Random32(); + personality = Random32(); + } + while (GetGenderFromSpeciesAndPersonality(species, personality) != MON_MALE); + CreateMon(mon, species, level, 32, 1, personality, OT_ID_PRESET, otId); +} + +void CreateMonWithIVsPersonality(struct Pokemon *mon, u16 species, u8 level, u32 ivs, u32 personality) +{ + CreateMon(mon, species, level, 0, 1, personality, OT_ID_PLAYER_ID, 0); + SetMonData(mon, MON_DATA_IVS, &ivs); + CalculateMonStats(mon); +} + +void CreateMonWithIVsOTID(struct Pokemon *mon, u16 species, u8 level, u8 *ivs, u32 otId) +{ + CreateMon(mon, species, level, 0, 0, 0, OT_ID_PRESET, otId); + SetMonData(mon, MON_DATA_HP_IV, &ivs[0]); + SetMonData(mon, MON_DATA_ATK_IV, &ivs[1]); + SetMonData(mon, MON_DATA_DEF_IV, &ivs[2]); + SetMonData(mon, MON_DATA_SPD_IV, &ivs[3]); + SetMonData(mon, MON_DATA_SPATK_IV, &ivs[4]); + SetMonData(mon, MON_DATA_SPDEF_IV, &ivs[5]); + CalculateMonStats(mon); +} + +void CreateMonWithEVSpread(struct Pokemon *mon, u16 species, u8 level, u8 fixedIV, u8 evSpread) +{ + s32 i; + s32 statCount = 0; + u16 evAmount; + u8 temp; + + CreateMon(mon, species, level, fixedIV, 0, 0, 0, 0); + + temp = evSpread; + + for (i = 0; i < 6; i++) + { + if (temp & 1) + statCount++; + temp >>= 1; + } + + evAmount = 510 / statCount; + + temp = 1; + + for (i = 0; i < 6; i++) + { + if (evSpread & temp) + SetMonData(mon, MON_DATA_HP_EV + i, &evAmount); + temp <<= 1; + } + + CalculateMonStats(mon); +} + +void sub_806819C(struct Pokemon *mon, struct UnknownPokemonStruct *src) +{ + s32 i; + u8 nickname[30]; + u8 language; + u8 value; + + CreateMon(mon, src->species, src->level, 0, 1, src->personality, 1, src->otId); + + for (i = 0; i < 4; i++) + SetMonMoveSlot(mon, src->moves[i], i); + + SetMonData(mon, MON_DATA_PP_BONUSES, &src->ppBonuses); + SetMonData(mon, MON_DATA_HELD_ITEM, &src->heldItem); + SetMonData(mon, MON_DATA_FRIENDSHIP, &src->friendship); + + StringCopy(nickname, src->nickname); + + if (nickname[0] == EXT_CTRL_CODE_BEGIN && nickname[1] == EXT_CTRL_CODE_JPN) + { + language = LANGUAGE_JAPANESE; + StripExtCtrlCodes(nickname); + } + else + language = GAME_LANGUAGE; + + SetMonData(mon, MON_DATA_LANGUAGE, &language); + SetMonData(mon, MON_DATA_NICKNAME, nickname); + SetMonData(mon, MON_DATA_HP_EV, &src->hpEV); + SetMonData(mon, MON_DATA_ATK_EV, &src->attackEV); + SetMonData(mon, MON_DATA_DEF_EV, &src->defenseEV); + SetMonData(mon, MON_DATA_SPD_EV, &src->speedEV); + SetMonData(mon, MON_DATA_SPATK_EV, &src->spAttackEV); + SetMonData(mon, MON_DATA_SPDEF_EV, &src->spDefenseEV); + value = src->altAbility; + SetMonData(mon, MON_DATA_ALT_ABILITY, &value); + value = src->hpIV; + SetMonData(mon, MON_DATA_HP_IV, &value); + value = src->attackIV; + SetMonData(mon, MON_DATA_ATK_IV, &value); + value = src->defenseIV; + SetMonData(mon, MON_DATA_DEF_IV, &value); + value = src->speedIV; + SetMonData(mon, MON_DATA_SPD_IV, &value); + value = src->spAttackIV; + SetMonData(mon, MON_DATA_SPATK_IV, &value); + value = src->spDefenseIV; + SetMonData(mon, MON_DATA_SPDEF_IV, &value); + RestoreMonMovesPP(mon); + CalculateMonStats(mon); +} diff --git a/sym_ewram.txt b/sym_ewram.txt index a4bfea346..b03fe1c8f 100644 --- a/sym_ewram.txt +++ b/sym_ewram.txt @@ -586,13 +586,13 @@ gUnknown_020244DC: @ 20244DC gBattleMovePower: @ 20244E0 .space 0x2 -gUnknown_020244E2: @ 20244E2 +gMoveToLearn: @ 20244E2 .space 0x2 gUnknown_020244E4: @ 20244E4 .space 0x4 -gUnknown_020244E8: @ 20244E8 +sLearningMoveTableID: @ 20244E8 .space 0x1 gPlayerPartyCount: @ 20244E9