decomp pokemon.s file

This commit is contained in:
DizzyEggg
2024-02-07 10:25:55 +01:00
parent ce21bef061
commit cc6b0e2db2
8 changed files with 289 additions and 679 deletions

View File

@@ -1,647 +0,0 @@
.include "asm/macros/function.inc"
.include "constants/gba_constants.inc"
.text
.syntax unified
thumb_func_start GiveGiftRibbonToParty
GiveGiftRibbonToParty: @ 0x0200C130
push {r4, r5, r6, r7, lr}
sub sp, #8
lsls r0, r0, #0x18
lsrs r4, r0, #0x18
lsls r1, r1, #0x18
lsrs r5, r1, #0x18
movs r7, #0
ldr r1, =gGiftRibbonMonDataIds
mov r0, sp
movs r2, #7
bl memcpy
cmp r4, #0xa
bhi _0200C19E
cmp r5, #0x40
bhi _0200C19E
cmp r4, #6
bhi _0200C19E
ldr r0, =gGiftRibbonsPtr
ldr r0, [r0]
adds r0, r0, r4
strb r5, [r0]
movs r5, #0
ldr r6, =gPlayerPartyPtr
_0200C160:
movs r0, #0x64
adds r4, r5, #0
muls r4, r0, r4
ldr r0, [r6]
adds r0, r4, r0
movs r1, #0xb
movs r2, #0
bl GetBoxMonData
cmp r0, #0
beq _0200C188
ldr r0, [r6]
adds r0, r4, r0
movs r1, #6
movs r2, #0
bl GetBoxMonData
cmp r0, #0
bne _0200C188
movs r7, #1
_0200C188:
adds r5, #1
cmp r5, #5
ble _0200C160
cmp r7, #0
beq _0200C19E
ldr r0, =gAgbPmRomParams
ldr r0, [r0]
adds r0, #0xf0
ldr r0, [r0]
bl SetFlag
_0200C19E:
add sp, #8
pop {r4, r5, r6, r7}
pop {r0}
bx r0
.align 2, 0
.pool
thumb_func_start GetMonData
GetMonData: @ 0x0200C1B8
push {lr}
adds r3, r0, #0
adds r0, r1, #0
subs r0, #0x37
cmp r0, #9
bhi _0200C248
lsls r0, r0, #2
ldr r1, =_0200C1D4
adds r0, r0, r1
ldr r0, [r0]
mov pc, r0
.align 2, 0
.pool
_0200C1D4: @ jump table
.4byte _0200C1FC @ case 0
.4byte _0200C200 @ case 1
.4byte _0200C208 @ case 2
.4byte _0200C210 @ case 3
.4byte _0200C218 @ case 4
.4byte _0200C220 @ case 5
.4byte _0200C228 @ case 6
.4byte _0200C230 @ case 7
.4byte _0200C238 @ case 8
.4byte _0200C240 @ case 9
_0200C1FC:
ldr r0, [r3, #0x50]
b _0200C24E
_0200C200:
adds r0, r3, #0
adds r0, #0x54
ldrb r0, [r0]
b _0200C24E
_0200C208:
adds r0, r3, #0
adds r0, #0x56
ldrh r0, [r0]
b _0200C24E
_0200C210:
adds r0, r3, #0
adds r0, #0x58
ldrh r0, [r0]
b _0200C24E
_0200C218:
adds r0, r3, #0
adds r0, #0x5a
ldrh r0, [r0]
b _0200C24E
_0200C220:
adds r0, r3, #0
adds r0, #0x5c
ldrh r0, [r0]
b _0200C24E
_0200C228:
adds r0, r3, #0
adds r0, #0x5e
ldrh r0, [r0]
b _0200C24E
_0200C230:
adds r0, r3, #0
adds r0, #0x60
ldrh r0, [r0]
b _0200C24E
_0200C238:
adds r0, r3, #0
adds r0, #0x62
ldrh r0, [r0]
b _0200C24E
_0200C240:
adds r0, r3, #0
adds r0, #0x55
ldrb r0, [r0]
b _0200C24E
_0200C248:
adds r0, r3, #0
bl GetBoxMonData
_0200C24E:
pop {r1}
bx r1
.align 2, 0
thumb_func_start GetMonGender
GetMonGender: @ 0x0200C254
push {r4, r5, r6, lr}
adds r4, r0, #0
ldr r0, =gAgbPmRomParams
ldr r0, [r0]
adds r0, #0xbc
ldr r6, [r0]
adds r0, r4, #0
movs r1, #0xb
movs r2, #0
bl GetBoxMonData
lsls r0, r0, #0x10
lsrs r5, r0, #0x10
adds r0, r4, #0
movs r1, #0
movs r2, #0
bl GetBoxMonData
adds r2, r0, #0
lsls r0, r5, #3
subs r0, r0, r5
lsls r0, r0, #2
adds r0, r0, r6
ldrb r0, [r0, #0x10]
cmp r0, #0
beq _0200C2B2
cmp r0, #0
blt _0200C294
cmp r0, #0xff
bgt _0200C294
cmp r0, #0xfe
bge _0200C2B2
_0200C294:
lsls r0, r5, #3
subs r0, r0, r5
lsls r0, r0, #2
adds r0, r0, r6
movs r1, #0xff
ands r1, r2
ldrb r0, [r0, #0x10]
cmp r0, r1
bls _0200C2B0
movs r0, #0xfe
b _0200C2B2
.align 2, 0
.pool
_0200C2B0:
movs r0, #0
_0200C2B2:
lsls r0, r0, #0x18
lsrs r0, r0, #0x18
pop {r4, r5, r6}
pop {r1}
bx r1
thumb_func_start GetMonPalettePtrBySpeciesIdPersonality
GetMonPalettePtrBySpeciesIdPersonality: @ 0x0200C2BC
push {r4, r5, lr}
adds r3, r2, #0
lsls r0, r0, #0x10
lsrs r4, r0, #0x10
adds r5, r4, #0
movs r0, #0xce
lsls r0, r0, #1
cmp r4, r0
bls _0200C2DC
ldr r0, =gAgbPmRomParams
ldr r0, [r0]
ldr r0, [r0, #0x30]
b _0200C30E
.align 2, 0
.pool
_0200C2DC:
lsrs r0, r1, #0x10
ldr r2, =0x0000FFFF
ands r1, r2
eors r0, r1
lsrs r1, r3, #0x10
eors r0, r1
ands r3, r2
eors r0, r3
cmp r0, #7
bls _0200C304
ldr r0, =gAgbPmRomParams
ldr r0, [r0]
lsls r1, r4, #3
ldr r0, [r0, #0x30]
b _0200C30C
.align 2, 0
.pool
_0200C304:
ldr r0, =gAgbPmRomParams
ldr r0, [r0]
lsls r1, r5, #3
ldr r0, [r0, #0x34]
_0200C30C:
adds r0, r0, r1
_0200C30E:
pop {r4, r5}
pop {r1}
bx r1
.align 2, 0
.pool
thumb_func_start FixUnownSpecies
FixUnownSpecies: @ 0x0200C318
push {lr}
adds r2, r1, #0
lsls r0, r0, #0x10
lsrs r1, r0, #0x10
cmp r1, #0xc9
bne _0200C366
movs r0, #0xc0
lsls r0, r0, #0x12
ands r0, r2
lsrs r0, r0, #0x12
movs r1, #0xc0
lsls r1, r1, #0xa
ands r1, r2
lsrs r1, r1, #0xc
orrs r0, r1
movs r1, #0xc0
lsls r1, r1, #2
ands r1, r2
lsrs r1, r1, #6
orrs r0, r1
movs r1, #3
ands r1, r2
orrs r0, r1
movs r1, #0x1c
bl __umodsi3
lsls r0, r0, #0x10
lsrs r0, r0, #0x10
cmp r0, #0
bne _0200C358
movs r0, #0xc9
b _0200C362
_0200C358:
movs r1, #0xce
lsls r1, r1, #1
adds r0, r0, r1
lsls r0, r0, #0x10
lsrs r0, r0, #0x10
_0200C362:
adds r1, r0, #0
b _0200C372
_0200C366:
movs r0, #0xce
lsls r0, r0, #1
cmp r1, r0
bls _0200C372
movs r1, #0x82
lsls r1, r1, #1
_0200C372:
adds r0, r1, #0
pop {r1}
bx r1
thumb_func_start GetSpeciesName
GetSpeciesName: @ 0x0200C378
push {r4, r5, r6, r7, lr}
mov r7, sl
mov r6, sb
mov r5, r8
push {r5, r6, r7}
sub sp, #4
mov ip, r0
adds r5, r1, #0
ldr r0, =gAgbPmRomParams
ldr r0, [r0]
ldr r3, [r0, #0x44]
movs r1, #0
adds r4, r0, #0
adds r4, #0x76
adds r2, r0, #0
adds r2, #0x82
ldrb r6, [r2]
ldrb r7, [r4]
adds r0, r6, r7
cmp r1, r0
bge _0200C3E4
movs r0, #0xb
muls r0, r5, r0
adds r0, r0, r3
mov sl, r0
mov sb, r2
mov r2, ip
movs r0, #0xce
lsls r0, r0, #1
mov r8, r0
str r4, [sp]
_0200C3B6:
cmp r5, r8
ble _0200C3C4
adds r0, r3, r1
b _0200C3C8
.align 2, 0
.pool
_0200C3C4:
mov r4, sl
adds r0, r4, r1
_0200C3C8:
ldrb r0, [r0]
strb r0, [r2]
ldrb r0, [r2]
cmp r0, #0xff
beq _0200C3E4
adds r2, #1
adds r1, #1
mov r6, sb
ldrb r7, [r6]
ldr r6, [sp]
ldrb r6, [r6]
adds r0, r7, r6
cmp r1, r0
blt _0200C3B6
_0200C3E4:
add r1, ip
movs r0, #0xff
strb r0, [r1]
add sp, #4
pop {r3, r4, r5}
mov r8, r3
mov sb, r4
mov sl, r5
pop {r4, r5, r6, r7}
pop {r0}
bx r0
.align 2, 0
thumb_func_start GetMonType
GetMonType: @ 0x0200C3FC
push {r4, r5, lr}
adds r4, r1, #0
ldr r1, =gAgbPmRomParams
ldr r1, [r1]
adds r1, #0xbc
ldr r5, [r1]
movs r1, #0xb
movs r2, #0
bl GetBoxMonData
adds r1, r0, #0
cmp r4, #1
beq _0200C424
cmp r4, #2
beq _0200C430
movs r0, #0
b _0200C43A
.align 2, 0
.pool
_0200C424:
lsls r0, r1, #3
subs r0, r0, r1
lsls r0, r0, #2
adds r0, r0, r5
ldrb r0, [r0, #6]
b _0200C43A
_0200C430:
lsls r0, r1, #3
subs r0, r0, r1
lsls r0, r0, #2
adds r0, r0, r5
ldrb r0, [r0, #7]
_0200C43A:
pop {r4, r5}
pop {r1}
bx r1
thumb_func_start GetMonSpritePaletteNumByBaseBlock
GetMonSpritePaletteNumByBaseBlock: @ 0x0200C440
ldr r1, =gTypeToPaletteNumber
adds r0, r0, r1
ldrb r0, [r0]
bx lr
.align 2, 0
.pool
thumb_func_start GetAbilityName
GetAbilityName: @ 0x0200C44C
adds r2, r0, #0
ldr r0, =gAgbPmRomParams
ldr r0, [r0]
adds r0, #0xc0
ldr r0, [r0]
movs r1, #0xd
muls r1, r2, r1
adds r0, r0, r1
bx lr
.align 2, 0
.pool
thumb_func_start GetAbilityDescription
GetAbilityDescription: @ 0x0200C464
ldr r1, =gAgbPmRomParams
ldr r1, [r1]
adds r1, #0xc4
ldr r1, [r1]
lsls r0, r0, #2
adds r0, r0, r1
ldr r0, [r0]
bx lr
.align 2, 0
.pool
thumb_func_start CalculatePPWithBonus
CalculatePPWithBonus: @ 0x0200C478
push {r4, lr}
ldr r3, =gAgbPmRomParams
ldr r3, [r3]
adds r3, #0xcc
ldr r4, [r3]
lsls r3, r0, #1
adds r3, r3, r0
lsls r3, r3, #2
adds r3, r3, r4
ldrb r4, [r3, #4]
ldr r0, =gPPUpReadMasks
adds r0, r2, r0
ldrb r0, [r0]
ands r1, r0
lsls r2, r2, #1
asrs r1, r2
lsls r0, r1, #2
adds r0, r0, r1
lsls r0, r0, #2
muls r0, r4, r0
movs r1, #0x64
bl __divsi3
adds r4, r4, r0
adds r0, r4, #0
pop {r4}
pop {r1}
bx r1
.align 2, 0
.pool
thumb_func_start CopyMoveName
CopyMoveName: @ 0x0200C4B8
push {r4, r5, r6, r7, lr}
adds r3, r0, #0
mov ip, r1
ldr r0, =gAgbPmRomParams
ldr r0, [r0]
ldr r1, [r0, #0x48]
movs r2, #0
adds r7, r0, #0
adds r7, #0x78
adds r4, r0, #0
adds r4, #0x82
ldrb r5, [r4]
ldrb r6, [r7]
adds r0, r5, r6
cmp r2, r0
bge _0200C510
movs r0, #0xd
mov r5, ip
muls r5, r0, r5
adds r0, r5, #0
adds r1, r0, r1
ldrb r0, [r1]
strb r0, [r3]
lsls r0, r0, #0x18
lsrs r0, r0, #0x18
cmp r0, #0xff
beq _0200C510
adds r6, r4, #0
adds r5, r1, #0
adds r4, r7, #0
_0200C4F4:
adds r2, #1
ldrb r7, [r6]
ldrb r1, [r4]
adds r0, r7, r1
cmp r2, r0
bge _0200C510
adds r1, r3, r2
adds r0, r5, r2
ldrb r0, [r0]
strb r0, [r1]
lsls r0, r0, #0x18
lsrs r0, r0, #0x18
cmp r0, #0xff
bne _0200C4F4
_0200C510:
adds r1, r3, r2
movs r0, #0xff
strb r0, [r1]
pop {r4, r5, r6, r7}
pop {r0}
bx r0
.align 2, 0
.pool
thumb_func_start GetPtrToEmptyPartySlot
GetPtrToEmptyPartySlot: @ 0x0200C520
ldr r0, =gPlayerPartyCountPtr
ldr r1, [r0]
ldrb r0, [r1]
cmp r0, #6
beq _0200C540
ldr r2, =gPlayerPartyPtr
movs r0, #0x64
ldrb r1, [r1]
muls r1, r0, r1
ldr r0, [r2]
adds r0, r0, r1
b _0200C542
.align 2, 0
.pool
_0200C540:
movs r0, #0
_0200C542:
bx lr
thumb_func_start GetMonGender2
GetMonGender2: @ 0x0200C544
push {r4, r5, r6, lr}
adds r4, r0, #0
ldr r0, =gAgbPmRomParams
ldr r0, [r0]
adds r0, #0xbc
ldr r6, [r0]
adds r0, r4, #0
movs r1, #0xb
movs r2, #0
bl GetBoxMonData
lsls r0, r0, #0x10
lsrs r5, r0, #0x10
adds r0, r4, #0
movs r1, #0
movs r2, #0
bl GetBoxMonData
adds r2, r0, #0
lsls r0, r5, #3
subs r0, r0, r5
lsls r0, r0, #2
adds r0, r0, r6
ldrb r0, [r0, #0x10]
cmp r0, #0
beq _0200C5A2
cmp r0, #0
blt _0200C584
cmp r0, #0xff
bgt _0200C584
cmp r0, #0xfe
bge _0200C5A2
_0200C584:
lsls r0, r5, #3
subs r0, r0, r5
lsls r0, r0, #2
adds r0, r0, r6
movs r1, #0xff
ands r1, r2
ldrb r0, [r0, #0x10]
cmp r0, r1
bhi _0200C5A0
movs r0, #0
b _0200C5A2
.align 2, 0
.pool
_0200C5A0:
movs r0, #0xfe
_0200C5A2:
pop {r4, r5, r6}
pop {r1}
bx r1
thumb_func_start GetUnownLetterByPersonality
GetUnownLetterByPersonality: @ 0x0200C5A8
push {lr}
adds r2, r0, #0
movs r0, #0xc0
lsls r0, r0, #0x12
ands r0, r2
lsrs r0, r0, #0x12
movs r1, #0xc0
lsls r1, r1, #0xa
ands r1, r2
lsrs r1, r1, #0xc
orrs r0, r1
movs r1, #0xc0
lsls r1, r1, #2
ands r1, r2
lsrs r1, r1, #6
orrs r0, r1
movs r1, #3
ands r1, r2
orrs r0, r1
movs r1, #0x1c
bl __umodsi3
lsls r0, r0, #0x10
lsrs r0, r0, #0x10
pop {r1}
bx r1

View File

@@ -33,9 +33,11 @@
#define NELEMS(arr) (sizeof(arr)/sizeof(*(arr)))
#define MOVE_NAME_LENGTH 12
#define POKEMON_NAME_LENGTH 10
#define OT_NAME_LENGTH 7
#define PLAYER_NAME_LENGTH 7
#define ABILITY_NAME_LENGTH 12
#define CONTEST_CATEGORY_COOL 0
#define CONTEST_CATEGORY_BEAUTY 1

View File

@@ -13,8 +13,8 @@ struct RomInfo
/*0x38*/ const u8 *const *monIconTable;
/*0x3C*/ const u8 *gMonIconPaletteIndices;
/*0x40*/ const struct SpritePalette *monIconPaletteTable;
/*0x44*/ const u8 *speciesNames;
/*0x48*/ const u8 *moveNames;
/*0x44*/ const u8 (*speciesNames)[][POKEMON_NAME_LENGTH + 1];
/*0x48*/ const u8 (*moveNames)[][MOVE_NAME_LENGTH + 1];
/*0x4C*/ const struct Decoration *decorations;
/*0x50*/ u32 flagsOffs;
/*0x54*/ u32 varsOffs;
@@ -57,8 +57,8 @@ struct RomInfo
/*0xB8*/ u32 unkB8_0:1;
/*0xB8*/ u32 unkB8_1:1;
/*0xBC*/ const struct SpeciesInfo *baseStats;
/*0xC0*/ const u8 *abilityNames;
/*0xC4*/ const u8 *abilityDescriptions;
/*0xC0*/ const u8 (*abilityNames)[][ABILITY_NAME_LENGTH + 1];
/*0xC4*/ const u8 **abilityDescriptions;
/*0xC8*/ const struct Item *items;
/*0xCC*/ const struct BattleMove *battleMoves;
/*0xD0*/ const struct CompressedSpriteSheet *ballSpriteSheets;

View File

@@ -181,6 +181,19 @@ struct PokemonStorage
/*0x83c2*/ u8 wallpaper[14];
};
struct BattleMove
{
u8 effect;
u8 power;
u8 type;
u8 accuracy;
u8 pp;
u8 secondaryEffectChance;
u8 target;
s8 priority;
u8 flags;
};
struct SpindaSpot
{
u8 x, y;

View File

@@ -3,5 +3,6 @@
u8 *StringCopy(u8 *dst, const u8 *src);
u16 GetStringSizeHandleExtCtrlCodes(u8 *str);
bool32 SetFlag(s32 flag);
#endif // GUARD_unk_200C5DC_H

View File

@@ -32,7 +32,6 @@ SECTIONS {
src/libpmagb/save.o(.text);
asm/libpmagb/save.o(.text);
src/pokemon.o(.text);
asm/pokemon.o(.text);
src/libpmagb/berry.o(.text);
src/unk_200C5DC.o(.text);
asm/unk_0200C5DC.o(.text);

View File

@@ -480,9 +480,33 @@ u32 GetBoxMonData(struct BoxPokemon *boxMon, s32 field, u8 *data)
return retVal;
}
static inline u32 GetMonData(struct Pokemon *mon, s32 attr, u8 *strbuf)
static inline u32 GetMonDataInline(struct Pokemon *mon, s32 attr, u8 *strbuf)
{
return GetBoxMonData(&mon->box, attr, strbuf);
switch (attr)
{
case MON_DATA_STATUS:
return mon->status;
case MON_DATA_LEVEL:
return mon->level;
case MON_DATA_HP:
return mon->hp;
case MON_DATA_MAX_HP:
return mon->maxHP;
case MON_DATA_ATK:
return mon->attack;
case MON_DATA_DEF:
return mon->defense;
case MON_DATA_SPEED:
return mon->speed;
case MON_DATA_SPATK:
return mon->spAttack;
case MON_DATA_SPDEF:
return mon->spDefense;
case MON_DATA_MAIL:
return mon->mail;
default:
return GetBoxMonData(&mon->box, attr, strbuf);
}
}
//Extracts the upper 16 bits of a 32-bit number
@@ -495,9 +519,9 @@ const struct CompressedSpritePalette *GetBoxMonPalettePtr(u32 partyId)
{
u32 shinyValue = 0;
u16 species = GetMonData(&gPlayerPartyPtr[partyId], MON_DATA_SPECIES2, NULL);
u32 otId = GetMonData(&gPlayerPartyPtr[partyId], MON_DATA_OT_ID, NULL);
u32 personality = GetMonData(&gPlayerPartyPtr[partyId], MON_DATA_PERSONALITY, NULL);
u16 species = GetMonDataInline(&gPlayerPartyPtr[partyId], MON_DATA_SPECIES2, NULL);
u32 otId = GetMonDataInline(&gPlayerPartyPtr[partyId], MON_DATA_OT_ID, NULL);
u32 personality = GetMonDataInline(&gPlayerPartyPtr[partyId], MON_DATA_PERSONALITY, NULL);
if (species > NUM_SPECIES)
return &gAgbPmRomParams->monPaletteTable[SPECIES_NONE];
@@ -614,7 +638,7 @@ u32 CheckPartyPokerus(struct Pokemon *party, u8 selection)
{
do
{
if ((selection & 1) && (GetMonData(&party[partyIndex], MON_DATA_POKERUS, 0) & 0xF))
if ((selection & 1) && (GetMonDataInline(&party[partyIndex], MON_DATA_POKERUS, 0) & 0xF))
retVal |= curBit;
partyIndex++;
curBit <<= 1;
@@ -622,7 +646,7 @@ u32 CheckPartyPokerus(struct Pokemon *party, u8 selection)
}
while (selection);
}
else if (GetMonData(&party[0], MON_DATA_POKERUS, 0) & 0xF)
else if (GetMonDataInline(&party[0], MON_DATA_POKERUS, 0) & 0xF)
{
retVal = 1;
}
@@ -650,10 +674,10 @@ u32 GetMonStatus(struct Pokemon *mon)
{
u32 statusAilment;
if (mon->hp == 0)
if (GetMonDataInline(mon, MON_DATA_HP, NULL) == 0)
return STATUS_PRIMARY_FAINTED;
statusAilment = GetPrimaryStatus(mon->status);
statusAilment = GetPrimaryStatus(GetMonDataInline(mon, MON_DATA_STATUS, NULL));
if (statusAilment == STATUS_PRIMARY_NONE)
{
if (!CheckPartyPokerus(mon, 0))
@@ -677,7 +701,7 @@ u32 CheckPartyHasHadPokerus(struct Pokemon *party, u8 selection)
{
do
{
if ((selection & 1) && GetMonData(&party[partyIndex], MON_DATA_POKERUS, 0))
if ((selection & 1) && GetMonDataInline(&party[partyIndex], MON_DATA_POKERUS, 0))
retVal |= curBit;
partyIndex++;
curBit <<= 1;
@@ -685,7 +709,7 @@ u32 CheckPartyHasHadPokerus(struct Pokemon *party, u8 selection)
}
while (selection);
}
else if (GetMonData(&party[0], MON_DATA_POKERUS, 0))
else if (GetMonDataInline(&party[0], MON_DATA_POKERUS, 0))
{
retVal = 1;
}
@@ -821,6 +845,10 @@ void SetBoxMonData(struct BoxPokemon *boxMon, s32 field, const void *dataArg)
break;
case MON_DATA_SPECIES:
{
#ifndef NONMATCHING // For some reason the compiler puts substruct0 in r8 instead of r9.
register struct PokemonSubstruct0 *fakeMatch asm("r9") = substruct0;
substruct0 = fakeMatch;
#endif // NONMATCHING
SET16(substruct0->species);
if (substruct0->species)
boxMon->hasSpecies = 1;
@@ -1062,3 +1090,217 @@ void SetMonData(struct Pokemon *mon, s32 field, const void *dataArg)
break;
}
}
extern const u8 gGiftRibbonMonDataIds[7];
void GiveGiftRibbonToParty(u8 index, u8 ribbonId)
{
s32 i;
bool32 gotRibbon = FALSE;
u8 arr[7];
memcpy(arr, gGiftRibbonMonDataIds, 7);
/*
u8 arr[] = {
MON_DATA_MARINE_RIBBON,
MON_DATA_LAND_RIBBON,
MON_DATA_SKY_RIBBON,
MON_DATA_COUNTRY_RIBBON,
MON_DATA_NATIONAL_RIBBON,
MON_DATA_EARTH_RIBBON,
MON_DATA_WORLD_RIBBON,
};
*/
if (index < 11 && ribbonId < 65 && index < 7)
{
gGiftRibbonsPtr[index] = ribbonId;
for (i = 0; i < PARTY_SIZE; i++)
{
if (GetMonDataInline(&gPlayerPartyPtr[i], MON_DATA_SPECIES, NULL) != 0 && GetMonDataInline(&gPlayerPartyPtr[i], MON_DATA_SANITY_BIT3, NULL) == 0)
gotRibbon = TRUE;
}
if (gotRibbon)
SetFlag(gAgbPmRomParams->giftRibbonsOffs);
}
}
u32 GetMonData(struct Pokemon *mon, s32 field, u8 *data)
{
return GetMonDataInline(mon, field, data);
}
static inline u8 GetGenderFromSpeciesAndPersonality(u16 species, u32 personality, const struct SpeciesInfo *speciesInfo)
{
switch (speciesInfo[species].genderRatio)
{
case MON_MALE:
case MON_FEMALE:
case MON_GENDERLESS:
return speciesInfo[species].genderRatio;
}
if (speciesInfo[species].genderRatio > (personality & 0xFF))
return MON_FEMALE;
else
return MON_MALE;
}
u8 GetMonGender(struct Pokemon *mon)
{
const struct SpeciesInfo *speciesInfo = gAgbPmRomParams->baseStats;
u16 species = GetMonDataInline(mon, MON_DATA_SPECIES, NULL);
u32 personality = GetMonDataInline(mon, MON_DATA_PERSONALITY, NULL);
return GetGenderFromSpeciesAndPersonality(species, personality, speciesInfo);
}
const struct CompressedSpritePalette *GetMonPalettePtrBySpeciesIdPersonality(u16 species, u32 otId, u32 personality)
{
u32 shinyValue = 0;
if (species > NUM_SPECIES)
return &gAgbPmRomParams->monPaletteTable[SPECIES_NONE];
shinyValue = HIHALF(otId) ^ LOHALF(otId) ^ HIHALF(personality) ^ LOHALF(personality);
if (shinyValue <= 7)
return &gAgbPmRomParams->monShinyPaletteTable[species];
else
return &gAgbPmRomParams->monPaletteTable[species];
}
static inline u16 GetUnownLetterByPersonalityInline(u32 personality)
{
return (((personality & 0x3000000) >> 18) | ((personality & 0x30000) >> 12) | ((personality & 0x300) >> 6) | (personality & 0x3)) % 0x1C;
}
u16 FixUnownSpecies(u16 species, u32 personality)
{
u16 result;
if (species == SPECIES_UNOWN)
{
u16 letter = GetUnownLetterByPersonalityInline(personality);
if (letter == 0)
letter = SPECIES_UNOWN;
else
letter += (SPECIES_UNOWN_B - 1);
result = letter;
}
else
{
if (species > SPECIES_EGG)
result = 260;
else
result = species;
}
return result;
}
void GetSpeciesName(u8 *name, s32 species)
{
s32 i;
const u8 (*speciesNames)[][POKEMON_NAME_LENGTH + 1] = gAgbPmRomParams->speciesNames;
for (i = 0; i < gAgbPmRomParams->pokemonNameLength_1 + gAgbPmRomParams->unk82; i++)
{
if (species > NUM_SPECIES)
name[i] = (*speciesNames)[0][i];
else
name[i] = (*speciesNames)[species][i];
if (name[i] == EOS)
break;
}
name[i] = EOS;
}
u32 GetMonType(struct Pokemon *mon, u32 which)
{
const struct SpeciesInfo *speciesInfo = gAgbPmRomParams->baseStats;
u32 species = GetMonDataInline(mon, MON_DATA_SPECIES, NULL);
switch (which)
{
default:
return 0;
case 1:
return speciesInfo[species].types[0];
case 2:
return speciesInfo[species].types[1];
}
}
u32 GetMonSpritePaletteNumByBaseBlock(u32 id)
{
return gTypeToPaletteNumber[id];
}
const u8 *GetAbilityName(u32 species)
{
const u8 (*abilityNames)[][ABILITY_NAME_LENGTH + 1] = gAgbPmRomParams->abilityNames;
return (*abilityNames)[species];
}
const u8 *GetAbilityDescription(u32 ability)
{
const u8 **desriptions = gAgbPmRomParams->abilityDescriptions;
return desriptions[ability];
}
s32 CalculatePPWithBonus(u32 move, s32 ppBonuses, u32 moveIndex)
{
const struct BattleMove *moves = gAgbPmRomParams->battleMoves;
s32 basePP = moves[move].pp;
return basePP + ((basePP * 20 * ((gPPUpReadMasks[moveIndex] & ppBonuses) >> (2 * moveIndex))) / 100);
}
void CopyMoveName(u8 *dst, u32 move)
{
s32 i;
const u8 (*moveNames)[][ABILITY_NAME_LENGTH + 1] = gAgbPmRomParams->moveNames;
for (i = 0; i < gAgbPmRomParams->unk78 + gAgbPmRomParams->unk82; i++)
{
dst[i] = (*moveNames)[move][i];
if (dst[i] == EOS)
break;
}
dst[i] = EOS;
}
struct Pokemon *GetPtrToEmptyPartySlot(void)
{
if (*gPlayerPartyCountPtr == PARTY_SIZE)
return NULL;
else
return &gPlayerPartyPtr[*gPlayerPartyCountPtr];
};
// The same as GetMonGender except GetGenderFromSpeciesAndPersonality isn't called by copied.
UNUSED u8 GetMonGender2(struct Pokemon *mon)
{
const struct SpeciesInfo *speciesInfo = gAgbPmRomParams->baseStats;
u16 species = GetMonDataInline(mon, MON_DATA_SPECIES, NULL);
u32 personality = GetMonDataInline(mon, MON_DATA_PERSONALITY, NULL);
switch (speciesInfo[species].genderRatio)
{
case MON_MALE:
case MON_FEMALE:
case MON_GENDERLESS:
return speciesInfo[species].genderRatio;
}
if (speciesInfo[species].genderRatio > (personality & 0xFF))
return MON_FEMALE;
else
return MON_MALE;
}
UNUSED u16 GetUnownLetterByPersonality(u32 personality)
{
return GetUnownLetterByPersonalityInline(personality);
}

View File

@@ -14,8 +14,8 @@ struct RomInfo gAgbPmRomParams_AXVE_rev0 = {
.monIconTable = (const u8 *const *)0x083bbd20,
.gMonIconPaletteIndices = (const u8 *)0x083bc400,
.monIconPaletteTable = (const struct SpritePalette *)0x083bc5b8,
.speciesNames = (const u8 *)0x081f716c,
.moveNames = (const u8 *)0x081f8320,
.speciesNames = (const u8 (*)[][POKEMON_NAME_LENGTH + 1])0x081f716c,
.moveNames = (const u8 (*)[][MOVE_NAME_LENGTH + 1])0x081f8320,
.decorations = (const struct Decoration *)0x083eb6c4,
.flagsOffs = offsetof(struct SaveBlock1, flags),
.varsOffs = offsetof(struct SaveBlock1, vars),
@@ -58,8 +58,8 @@ struct RomInfo gAgbPmRomParams_AXVE_rev0 = {
.unkB8_0 = FALSE,
.unkB8_1 = FALSE,
.baseStats = (const struct SpeciesInfo *)0x081fec18,
.abilityNames = (const u8 *)0x081fa248,
.abilityDescriptions = (const u8 *)0x081fa110,
.abilityNames = (const u8 (*)[][ABILITY_NAME_LENGTH + 1])0x081fa248,
.abilityDescriptions = (const u8 **)0x081fa110,
.items = (const struct Item *)0x083c5564,
.battleMoves = (const struct BattleMove *)0x081fb12c,
.ballSpriteSheets = (const struct CompressedSpriteSheet *)0x0820a92c,
@@ -91,8 +91,8 @@ struct RomInfo gAgbPmRomParams_AXVE_rev2 = {
.monIconTable = (const u8 *const *)0x083bbd3c,
.gMonIconPaletteIndices = (const u8 *)0x083bc41c,
.monIconPaletteTable = (const struct SpritePalette *)0x083bc5d4,
.speciesNames = (const u8 *)0x081f7184,
.moveNames = (const u8 *)0x081f8338,
.speciesNames = (const u8 (*)[][POKEMON_NAME_LENGTH + 1])0x081f7184,
.moveNames = (const u8 (*)[][MOVE_NAME_LENGTH + 1])0x081f8338,
.decorations = (const struct Decoration *)0x083eb6e0,
.flagsOffs = offsetof(struct SaveBlock1, flags),
.varsOffs = offsetof(struct SaveBlock1, vars),
@@ -135,8 +135,8 @@ struct RomInfo gAgbPmRomParams_AXVE_rev2 = {
.unkB8_0 = FALSE,
.unkB8_1 = FALSE,
.baseStats = (const struct SpeciesInfo *)0x081fec30,
.abilityNames = (const u8 *)0x081fa260,
.abilityDescriptions = (const u8 *)0x081fa128,
.abilityNames = (const u8 (*)[][ABILITY_NAME_LENGTH + 1])0x081fa260,
.abilityDescriptions = (const u8 **)0x081fa128,
.items = (const struct Item *)0x083c5580,
.battleMoves = (const struct BattleMove *)0x081fb144,
.ballSpriteSheets = (const struct CompressedSpriteSheet *)0x0820a944,
@@ -168,8 +168,8 @@ struct RomInfo gAgbPmRomParams_AXPE_rev0 = {
.monIconTable = (const u8 *const *)0x083bbd78,
.gMonIconPaletteIndices = (const u8 *)0x083bc458,
.monIconPaletteTable = (const struct SpritePalette *)0x083bc610,
.speciesNames = (const u8 *)0x081f70fc,
.moveNames = (const u8 *)0x081f82b0,
.speciesNames = (const u8 (*)[][POKEMON_NAME_LENGTH + 1])0x081f70fc,
.moveNames = (const u8 (*)[][MOVE_NAME_LENGTH + 1])0x081f82b0,
.decorations = (const struct Decoration *)0x083eb71c,
.flagsOffs = offsetof(struct SaveBlock1, flags),
.varsOffs = offsetof(struct SaveBlock1, vars),
@@ -212,8 +212,8 @@ struct RomInfo gAgbPmRomParams_AXPE_rev0 = {
.unkB8_0 = FALSE,
.unkB8_1 = FALSE,
.baseStats = (const struct SpeciesInfo *)0x081feba8,
.abilityNames = (const u8 *)0x081fa1d8,
.abilityDescriptions = (const u8 *)0x081fa0a0,
.abilityNames = (const u8 (*)[][ABILITY_NAME_LENGTH + 1])0x081fa1d8,
.abilityDescriptions = (const u8 **)0x081fa0a0,
.items = (const struct Item *)0x083c55bc,
.battleMoves = (const struct BattleMove *)0x081fb0bc,
.ballSpriteSheets = (const struct CompressedSpriteSheet *)0x0820a8bc,
@@ -245,8 +245,8 @@ struct RomInfo gAgbPmRomParams_AXPE_rev2 = {
.monIconTable = (const u8 *const *)0x083bbd98,
.gMonIconPaletteIndices = (const u8 *)0x083bc478,
.monIconPaletteTable = (const struct SpritePalette *)0x083bc630,
.speciesNames = (const u8 *)0x081f7114,
.moveNames = (const u8 *)0x081f82c8,
.speciesNames = (const u8 (*)[][POKEMON_NAME_LENGTH + 1])0x081f7114,
.moveNames = (const u8 (*)[][MOVE_NAME_LENGTH + 1])0x081f82c8,
.decorations = (const struct Decoration *)0x083eb73c,
.flagsOffs = offsetof(struct SaveBlock1, flags),
.varsOffs = offsetof(struct SaveBlock1, vars),
@@ -289,8 +289,8 @@ struct RomInfo gAgbPmRomParams_AXPE_rev2 = {
.unkB8_0 = FALSE,
.unkB8_1 = FALSE,
.baseStats = (const struct SpeciesInfo *)0x081febc0,
.abilityNames = (const u8 *)0x081fa1f0,
.abilityDescriptions = (const u8 *)0x081fa0b8,
.abilityNames = (const u8 (*)[][ABILITY_NAME_LENGTH + 1])0x081fa1f0,
.abilityDescriptions = (const u8 **)0x081fa0b8,
.items = (const struct Item *)0x083c55dc,
.battleMoves = (const struct BattleMove *)0x081fb0d4,
.ballSpriteSheets = (const struct CompressedSpriteSheet *)0x0820a8d4,