From 198b4724d78ad2d40dedd67a5a79cba97cdc3c33 Mon Sep 17 00:00:00 2001 From: drifloony Date: Sun, 16 Jul 2017 02:02:24 -0700 Subject: fix CreateMonWithEVSpread --- src/pokemon_1.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/pokemon_1.c b/src/pokemon_1.c index c55105ef3..185caaed2 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); -- cgit v1.2.3 From c46baaf6732d68f5908a1f3c826e9aa2f88c3ff3 Mon Sep 17 00:00:00 2001 From: drifloony Date: Sun, 16 Jul 2017 02:50:55 -0700 Subject: remove goto in CalculateMonStats --- src/pokemon_1.c | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/src/pokemon_1.c b/src/pokemon_1.c index 185caaed2..231fc33ed 100644 --- a/src/pokemon_1.c +++ b/src/pokemon_1.c @@ -444,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) -- cgit v1.2.3