diff options
-rw-r--r-- | src/pokemon_1.c | 41 |
1 files changed, 20 insertions, 21 deletions
diff --git a/src/pokemon_1.c b/src/pokemon_1.c index c55105ef3..231fc33ed 100644 --- a/src/pokemon_1.c +++ b/src/pokemon_1.c @@ -249,29 +249,30 @@ void CreateMonWithIVsOTID(struct Pokemon *mon, u16 species, u8 level, u8 *ivs, u void CreateMonWithEVSpread(struct Pokemon *mon, u16 species, u8 level, u8 fixedIV, u8 evSpread) { s32 i; - register u32 temp asm("r4"); s32 statCount = 0; u16 evAmount; - register u32 mask1 asm("r1"); - u8 mask2; + u8 temp; CreateMon(mon, species, level, fixedIV, 0, 0, 0, 0); + temp = evSpread; - mask1 = 1; - for (i = 5; i >= 0; i--) + + for (i = 0; i < 6; i++) { - if (temp & mask1) + if (temp & 1) statCount++; temp >>= 1; } evAmount = 510 / statCount; - mask2 = 1; + + temp = 1; + for (i = 0; i < 6; i++) { - if (evSpread & mask2) + if (evSpread & temp) SetMonData(mon, MON_DATA_HP_EV + i, (u8 *)&evAmount); - mask2 <<= 1; + temp <<= 1; } CalculateMonStats(mon); @@ -443,23 +444,21 @@ void CalculateMonStats(struct Pokemon *mon) if (species == SPECIES_SHEDINJA) { if (currentHP != 0 || oldMaxHP == 0) - { currentHP = 1; - goto set_hp; - } + else + return; } else { - if (currentHP != 0 || oldMaxHP == 0) - { - if (currentHP != 0) - currentHP += newMaxHP - oldMaxHP; - else if (oldMaxHP == 0) - currentHP = newMaxHP; - set_hp: - SetMonData(mon, MON_DATA_HP, (u8 *)¤tHP); - } + if (currentHP == 0 && oldMaxHP == 0) + currentHP = newMaxHP; + else if (currentHP != 0) + currentHP += newMaxHP - oldMaxHP; + else + return; } + + SetMonData(mon, MON_DATA_HP, (u8 *)¤tHP); } void sub_803B4B4(struct Pokemon *src, struct Pokemon *dest) |