start porting pokemon1

This commit is contained in:
DizzyEggg 2017-09-06 17:19:08 +02:00
parent 577e23a87d
commit c6eacc9be5
19 changed files with 703 additions and 1194 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

File diff suppressed because it is too large Load Diff

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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.
.align 2, 0 @ Don't pad with nop.

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -1,5 +1,5 @@
.align 2
gLevelUpLearnsetPointers:: @ 832937C
gLevelUpLearnsets:: @ 832937C
.4byte gBulbasaurLevelUpLearnset
.4byte gBulbasaurLevelUpLearnset
.4byte gIvysaurLevelUpLearnset

View File

@ -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

View File

@ -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;

View File

@ -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);

325
src/pokemon_1.c Normal file
View File

@ -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);
}

View File

@ -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