diff --git a/include/battle_controllers.h b/include/battle_controllers.h index 064c080f6181..56ceb2fb3c00 100644 --- a/include/battle_controllers.h +++ b/include/battle_controllers.h @@ -99,6 +99,23 @@ enum { // Special return values in gBattleBufferB from Battle Controller functions. #define RET_VALUE_LEVELED_UP 11 +#ifndef UBFIX +#define SetMonData16(mon, type, arg) SetMonData(mon, type, arg) +#define SetMonData32(mon, type, arg) SetMonData(mon, type, arg) +#else +#define SetMonData16(mon, type, arg) \ +{ \ + u16 value = T1_READ_16(arg); \ + SetMonData(mon, type, &value); \ +} + +#define SetMonData32(mon, type, arg) \ +{ \ + u32 value = T1_READ_32(arg); \ + SetMonData(mon, type, &value); \ +} +#endif + struct UnusedControllerStruct { u8 unk:7; diff --git a/src/battle_controller_link_opponent.c b/src/battle_controller_link_opponent.c index 2104298775a5..3871bcef02a3 100644 --- a/src/battle_controller_link_opponent.c +++ b/src/battle_controller_link_opponent.c @@ -932,10 +932,10 @@ static void SetLinkOpponentMonData(u8 monId) } break; case REQUEST_SPECIES_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_SPECIES, &gBattleBufferA[gActiveBattler][3]); + SetMonData16(&gEnemyParty[monId], MON_DATA_SPECIES, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_HELDITEM_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_HELD_ITEM, &gBattleBufferA[gActiveBattler][3]); + SetMonData16(&gEnemyParty[monId], MON_DATA_HELD_ITEM, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_MOVES_PP_BATTLE: for (i = 0; i < MAX_MON_MOVES; i++) @@ -949,7 +949,7 @@ static void SetLinkOpponentMonData(u8 monId) case REQUEST_MOVE2_BATTLE: case REQUEST_MOVE3_BATTLE: case REQUEST_MOVE4_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_MOVE1 + gBattleBufferA[gActiveBattler][1] - REQUEST_MOVE1_BATTLE, &gBattleBufferA[gActiveBattler][3]); + SetMonData16(&gEnemyParty[monId], MON_DATA_MOVE1 + gBattleBufferA[gActiveBattler][1] - REQUEST_MOVE1_BATTLE, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_PP_DATA_BATTLE: SetMonData(&gEnemyParty[monId], MON_DATA_PP1, &gBattleBufferA[gActiveBattler][3]); @@ -965,10 +965,10 @@ static void SetLinkOpponentMonData(u8 monId) SetMonData(&gEnemyParty[monId], MON_DATA_PP1 + gBattleBufferA[gActiveBattler][1] - REQUEST_PPMOVE1_BATTLE, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_OTID_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_OT_ID, &gBattleBufferA[gActiveBattler][3]); + SetMonData32(&gEnemyParty[monId], MON_DATA_OT_ID, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_EXP_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_EXP, &gBattleBufferA[gActiveBattler][3]); + SetMonData32(&gEnemyParty[monId], MON_DATA_EXP, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_HP_EV_BATTLE: SetMonData(&gEnemyParty[monId], MON_DATA_HP_EV, &gBattleBufferA[gActiveBattler][3]); @@ -1033,37 +1033,37 @@ static void SetLinkOpponentMonData(u8 monId) SetMonData(&gEnemyParty[monId], MON_DATA_SPDEF_IV, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_PERSONALITY_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_PERSONALITY, &gBattleBufferA[gActiveBattler][3]); + SetMonData32(&gEnemyParty[monId], MON_DATA_PERSONALITY, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_CHECKSUM_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_CHECKSUM, &gBattleBufferA[gActiveBattler][3]); + SetMonData16(&gEnemyParty[monId], MON_DATA_CHECKSUM, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_STATUS_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_STATUS, &gBattleBufferA[gActiveBattler][3]); + SetMonData32(&gEnemyParty[monId], MON_DATA_STATUS, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_LEVEL_BATTLE: SetMonData(&gEnemyParty[monId], MON_DATA_LEVEL, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_HP_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_HP, &gBattleBufferA[gActiveBattler][3]); + SetMonData16(&gEnemyParty[monId], MON_DATA_HP, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_MAX_HP_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_MAX_HP, &gBattleBufferA[gActiveBattler][3]); + SetMonData16(&gEnemyParty[monId], MON_DATA_MAX_HP, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_ATK_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_ATK, &gBattleBufferA[gActiveBattler][3]); + SetMonData16(&gEnemyParty[monId], MON_DATA_ATK, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_DEF_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_DEF, &gBattleBufferA[gActiveBattler][3]); + SetMonData16(&gEnemyParty[monId], MON_DATA_DEF, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_SPEED_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_SPEED, &gBattleBufferA[gActiveBattler][3]); + SetMonData16(&gEnemyParty[monId], MON_DATA_SPEED, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_SPATK_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_SPATK, &gBattleBufferA[gActiveBattler][3]); + SetMonData16(&gEnemyParty[monId], MON_DATA_SPATK, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_SPDEF_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_SPDEF, &gBattleBufferA[gActiveBattler][3]); + SetMonData16(&gEnemyParty[monId], MON_DATA_SPDEF, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_COOL_BATTLE: SetMonData(&gEnemyParty[monId], MON_DATA_COOL, &gBattleBufferA[gActiveBattler][3]); diff --git a/src/battle_controller_link_partner.c b/src/battle_controller_link_partner.c index 054563ad3a8e..456c60d9ad32 100644 --- a/src/battle_controller_link_partner.c +++ b/src/battle_controller_link_partner.c @@ -826,10 +826,10 @@ static void SetLinkPartnerMonData(u8 monId) } break; case REQUEST_SPECIES_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SPECIES, &gBattleBufferA[gActiveBattler][3]); + SetMonData16(&gPlayerParty[monId], MON_DATA_SPECIES, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_HELDITEM_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_HELD_ITEM, &gBattleBufferA[gActiveBattler][3]); + SetMonData16(&gPlayerParty[monId], MON_DATA_HELD_ITEM, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_MOVES_PP_BATTLE: for (i = 0; i < MAX_MON_MOVES; i++) @@ -843,7 +843,7 @@ static void SetLinkPartnerMonData(u8 monId) case REQUEST_MOVE2_BATTLE: case REQUEST_MOVE3_BATTLE: case REQUEST_MOVE4_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_MOVE1 + gBattleBufferA[gActiveBattler][1] - REQUEST_MOVE1_BATTLE, &gBattleBufferA[gActiveBattler][3]); + SetMonData16(&gPlayerParty[monId], MON_DATA_MOVE1 + gBattleBufferA[gActiveBattler][1] - REQUEST_MOVE1_BATTLE, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_PP_DATA_BATTLE: SetMonData(&gPlayerParty[monId], MON_DATA_PP1, &gBattleBufferA[gActiveBattler][3]); @@ -927,37 +927,37 @@ static void SetLinkPartnerMonData(u8 monId) SetMonData(&gPlayerParty[monId], MON_DATA_SPDEF_IV, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_PERSONALITY_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_PERSONALITY, &gBattleBufferA[gActiveBattler][3]); + SetMonData32(&gPlayerParty[monId], MON_DATA_PERSONALITY, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_CHECKSUM_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_CHECKSUM, &gBattleBufferA[gActiveBattler][3]); + SetMonData16(&gPlayerParty[monId], MON_DATA_CHECKSUM, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_STATUS_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_STATUS, &gBattleBufferA[gActiveBattler][3]); + SetMonData32(&gPlayerParty[monId], MON_DATA_STATUS, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_LEVEL_BATTLE: SetMonData(&gPlayerParty[monId], MON_DATA_LEVEL, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_HP_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_HP, &gBattleBufferA[gActiveBattler][3]); + SetMonData16(&gPlayerParty[monId], MON_DATA_HP, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_MAX_HP_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_MAX_HP, &gBattleBufferA[gActiveBattler][3]); + SetMonData16(&gPlayerParty[monId], MON_DATA_MAX_HP, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_ATK_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_ATK, &gBattleBufferA[gActiveBattler][3]); + SetMonData16(&gPlayerParty[monId], MON_DATA_ATK, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_DEF_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_DEF, &gBattleBufferA[gActiveBattler][3]); + SetMonData16(&gPlayerParty[monId], MON_DATA_DEF, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_SPEED_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SPEED, &gBattleBufferA[gActiveBattler][3]); + SetMonData16(&gPlayerParty[monId], MON_DATA_SPEED, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_SPATK_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SPATK, &gBattleBufferA[gActiveBattler][3]); + SetMonData16(&gPlayerParty[monId], MON_DATA_SPATK, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_SPDEF_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SPDEF, &gBattleBufferA[gActiveBattler][3]); + SetMonData16(&gPlayerParty[monId], MON_DATA_SPDEF, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_COOL_BATTLE: SetMonData(&gPlayerParty[monId], MON_DATA_COOL, &gBattleBufferA[gActiveBattler][3]); @@ -1695,3 +1695,4 @@ static void LinkPartnerHandleEndLinkBattle(void) static void LinkPartnerCmdEnd(void) { } + diff --git a/src/battle_controller_opponent.c b/src/battle_controller_opponent.c index e434e3ee6237..68a690d3a509 100644 --- a/src/battle_controller_opponent.c +++ b/src/battle_controller_opponent.c @@ -946,10 +946,10 @@ static void SetOpponentMonData(u8 monId) } break; case REQUEST_SPECIES_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_SPECIES, &gBattleBufferA[gActiveBattler][3]); + SetMonData16(&gEnemyParty[monId], MON_DATA_SPECIES, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_HELDITEM_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_HELD_ITEM, &gBattleBufferA[gActiveBattler][3]); + SetMonData16(&gEnemyParty[monId], MON_DATA_HELD_ITEM, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_MOVES_PP_BATTLE: for (i = 0; i < MAX_MON_MOVES; i++) @@ -963,7 +963,7 @@ static void SetOpponentMonData(u8 monId) case REQUEST_MOVE2_BATTLE: case REQUEST_MOVE3_BATTLE: case REQUEST_MOVE4_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_MOVE1 + gBattleBufferA[gActiveBattler][1] - REQUEST_MOVE1_BATTLE, &gBattleBufferA[gActiveBattler][3]); + SetMonData16(&gEnemyParty[monId], MON_DATA_MOVE1 + gBattleBufferA[gActiveBattler][1] - REQUEST_MOVE1_BATTLE, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_PP_DATA_BATTLE: SetMonData(&gEnemyParty[monId], MON_DATA_PP1, &gBattleBufferA[gActiveBattler][3]); @@ -1047,37 +1047,37 @@ static void SetOpponentMonData(u8 monId) SetMonData(&gEnemyParty[monId], MON_DATA_SPDEF_IV, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_PERSONALITY_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_PERSONALITY, &gBattleBufferA[gActiveBattler][3]); + SetMonData32(&gEnemyParty[monId], MON_DATA_PERSONALITY, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_CHECKSUM_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_CHECKSUM, &gBattleBufferA[gActiveBattler][3]); + SetMonData16(&gEnemyParty[monId], MON_DATA_CHECKSUM, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_STATUS_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_STATUS, &gBattleBufferA[gActiveBattler][3]); + SetMonData32(&gEnemyParty[monId], MON_DATA_STATUS, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_LEVEL_BATTLE: SetMonData(&gEnemyParty[monId], MON_DATA_LEVEL, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_HP_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_HP, &gBattleBufferA[gActiveBattler][3]); + SetMonData16(&gEnemyParty[monId], MON_DATA_HP, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_MAX_HP_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_MAX_HP, &gBattleBufferA[gActiveBattler][3]); + SetMonData16(&gEnemyParty[monId], MON_DATA_MAX_HP, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_ATK_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_ATK, &gBattleBufferA[gActiveBattler][3]); + SetMonData16(&gEnemyParty[monId], MON_DATA_ATK, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_DEF_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_DEF, &gBattleBufferA[gActiveBattler][3]); + SetMonData16(&gEnemyParty[monId], MON_DATA_DEF, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_SPEED_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_SPEED, &gBattleBufferA[gActiveBattler][3]); + SetMonData16(&gEnemyParty[monId], MON_DATA_SPEED, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_SPATK_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_SPATK, &gBattleBufferA[gActiveBattler][3]); + SetMonData16(&gEnemyParty[monId], MON_DATA_SPATK, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_SPDEF_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_SPDEF, &gBattleBufferA[gActiveBattler][3]); + SetMonData16(&gEnemyParty[monId], MON_DATA_SPDEF, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_COOL_BATTLE: SetMonData(&gEnemyParty[monId], MON_DATA_COOL, &gBattleBufferA[gActiveBattler][3]); diff --git a/src/battle_controller_player.c b/src/battle_controller_player.c index 357912d4b63d..042349fad29e 100644 --- a/src/battle_controller_player.c +++ b/src/battle_controller_player.c @@ -1993,10 +1993,10 @@ static void SetPlayerMonData(u8 monId) } break; case REQUEST_SPECIES_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SPECIES, &gBattleBufferA[gActiveBattler][3]); + SetMonData16(&gPlayerParty[monId], MON_DATA_SPECIES, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_HELDITEM_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_HELD_ITEM, &gBattleBufferA[gActiveBattler][3]); + SetMonData16(&gPlayerParty[monId], MON_DATA_HELD_ITEM, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_MOVES_PP_BATTLE: for (i = 0; i < MAX_MON_MOVES; i++) @@ -2010,7 +2010,7 @@ static void SetPlayerMonData(u8 monId) case REQUEST_MOVE2_BATTLE: case REQUEST_MOVE3_BATTLE: case REQUEST_MOVE4_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_MOVE1 + gBattleBufferA[gActiveBattler][1] - REQUEST_MOVE1_BATTLE, &gBattleBufferA[gActiveBattler][3]); + SetMonData16(&gPlayerParty[monId], MON_DATA_MOVE1 + gBattleBufferA[gActiveBattler][1] - REQUEST_MOVE1_BATTLE, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_PP_DATA_BATTLE: SetMonData(&gPlayerParty[monId], MON_DATA_PP1, &gBattleBufferA[gActiveBattler][3]); @@ -2094,37 +2094,37 @@ static void SetPlayerMonData(u8 monId) SetMonData(&gPlayerParty[monId], MON_DATA_SPDEF_IV, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_PERSONALITY_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_PERSONALITY, &gBattleBufferA[gActiveBattler][3]); + SetMonData32(&gPlayerParty[monId], MON_DATA_PERSONALITY, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_CHECKSUM_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_CHECKSUM, &gBattleBufferA[gActiveBattler][3]); + SetMonData16(&gPlayerParty[monId], MON_DATA_CHECKSUM, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_STATUS_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_STATUS, &gBattleBufferA[gActiveBattler][3]); + SetMonData32(&gPlayerParty[monId], MON_DATA_STATUS, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_LEVEL_BATTLE: SetMonData(&gPlayerParty[monId], MON_DATA_LEVEL, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_HP_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_HP, &gBattleBufferA[gActiveBattler][3]); + SetMonData16(&gPlayerParty[monId], MON_DATA_HP, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_MAX_HP_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_MAX_HP, &gBattleBufferA[gActiveBattler][3]); + SetMonData16(&gPlayerParty[monId], MON_DATA_MAX_HP, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_ATK_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_ATK, &gBattleBufferA[gActiveBattler][3]); + SetMonData16(&gPlayerParty[monId], MON_DATA_ATK, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_DEF_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_DEF, &gBattleBufferA[gActiveBattler][3]); + SetMonData16(&gPlayerParty[monId], MON_DATA_DEF, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_SPEED_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SPEED, &gBattleBufferA[gActiveBattler][3]); + SetMonData16(&gPlayerParty[monId], MON_DATA_SPEED, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_SPATK_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SPATK, &gBattleBufferA[gActiveBattler][3]); + SetMonData16(&gPlayerParty[monId], MON_DATA_SPATK, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_SPDEF_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SPDEF, &gBattleBufferA[gActiveBattler][3]); + SetMonData16(&gPlayerParty[monId], MON_DATA_SPDEF, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_COOL_BATTLE: SetMonData(&gPlayerParty[monId], MON_DATA_COOL, &gBattleBufferA[gActiveBattler][3]); diff --git a/src/battle_controller_player_partner.c b/src/battle_controller_player_partner.c index 236a66ce83df..63ba0ea777d9 100644 --- a/src/battle_controller_player_partner.c +++ b/src/battle_controller_player_partner.c @@ -1010,10 +1010,10 @@ static void SetPlayerPartnerMonData(u8 monId) } break; case REQUEST_SPECIES_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SPECIES, &gBattleBufferA[gActiveBattler][3]); + SetMonData16(&gPlayerParty[monId], MON_DATA_SPECIES, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_HELDITEM_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_HELD_ITEM, &gBattleBufferA[gActiveBattler][3]); + SetMonData16(&gPlayerParty[monId], MON_DATA_HELD_ITEM, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_MOVES_PP_BATTLE: for (i = 0; i < MAX_MON_MOVES; i++) @@ -1027,7 +1027,7 @@ static void SetPlayerPartnerMonData(u8 monId) case REQUEST_MOVE2_BATTLE: case REQUEST_MOVE3_BATTLE: case REQUEST_MOVE4_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_MOVE1 + gBattleBufferA[gActiveBattler][1] - REQUEST_MOVE1_BATTLE, &gBattleBufferA[gActiveBattler][3]); + SetMonData16(&gPlayerParty[monId], MON_DATA_MOVE1 + gBattleBufferA[gActiveBattler][1] - REQUEST_MOVE1_BATTLE, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_PP_DATA_BATTLE: SetMonData(&gPlayerParty[monId], MON_DATA_PP1, &gBattleBufferA[gActiveBattler][3]); @@ -1111,37 +1111,37 @@ static void SetPlayerPartnerMonData(u8 monId) SetMonData(&gPlayerParty[monId], MON_DATA_SPDEF_IV, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_PERSONALITY_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_PERSONALITY, &gBattleBufferA[gActiveBattler][3]); + SetMonData32(&gPlayerParty[monId], MON_DATA_PERSONALITY, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_CHECKSUM_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_CHECKSUM, &gBattleBufferA[gActiveBattler][3]); + SetMonData16(&gPlayerParty[monId], MON_DATA_CHECKSUM, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_STATUS_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_STATUS, &gBattleBufferA[gActiveBattler][3]); + SetMonData32(&gPlayerParty[monId], MON_DATA_STATUS, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_LEVEL_BATTLE: SetMonData(&gPlayerParty[monId], MON_DATA_LEVEL, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_HP_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_HP, &gBattleBufferA[gActiveBattler][3]); + SetMonData16(&gPlayerParty[monId], MON_DATA_HP, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_MAX_HP_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_MAX_HP, &gBattleBufferA[gActiveBattler][3]); + SetMonData16(&gPlayerParty[monId], MON_DATA_MAX_HP, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_ATK_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_ATK, &gBattleBufferA[gActiveBattler][3]); + SetMonData16(&gPlayerParty[monId], MON_DATA_ATK, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_DEF_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_DEF, &gBattleBufferA[gActiveBattler][3]); + SetMonData16(&gPlayerParty[monId], MON_DATA_DEF, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_SPEED_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SPEED, &gBattleBufferA[gActiveBattler][3]); + SetMonData16(&gPlayerParty[monId], MON_DATA_SPEED, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_SPATK_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SPATK, &gBattleBufferA[gActiveBattler][3]); + SetMonData16(&gPlayerParty[monId], MON_DATA_SPATK, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_SPDEF_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SPDEF, &gBattleBufferA[gActiveBattler][3]); + SetMonData16(&gPlayerParty[monId], MON_DATA_SPDEF, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_COOL_BATTLE: SetMonData(&gPlayerParty[monId], MON_DATA_COOL, &gBattleBufferA[gActiveBattler][3]); diff --git a/src/battle_controller_recorded_opponent.c b/src/battle_controller_recorded_opponent.c index 9c37cd0a92bd..2f31cd06c330 100644 --- a/src/battle_controller_recorded_opponent.c +++ b/src/battle_controller_recorded_opponent.c @@ -918,10 +918,10 @@ static void SetRecordedOpponentMonData(u8 monId) } break; case REQUEST_SPECIES_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_SPECIES, &gBattleBufferA[gActiveBattler][3]); + SetMonData16(&gEnemyParty[monId], MON_DATA_SPECIES, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_HELDITEM_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_HELD_ITEM, &gBattleBufferA[gActiveBattler][3]); + SetMonData16(&gEnemyParty[monId], MON_DATA_HELD_ITEM, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_MOVES_PP_BATTLE: for (i = 0; i < MAX_MON_MOVES; i++) @@ -935,7 +935,7 @@ static void SetRecordedOpponentMonData(u8 monId) case REQUEST_MOVE2_BATTLE: case REQUEST_MOVE3_BATTLE: case REQUEST_MOVE4_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_MOVE1 + gBattleBufferA[gActiveBattler][1] - REQUEST_MOVE1_BATTLE, &gBattleBufferA[gActiveBattler][3]); + SetMonData16(&gEnemyParty[monId], MON_DATA_MOVE1 + gBattleBufferA[gActiveBattler][1] - REQUEST_MOVE1_BATTLE, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_PP_DATA_BATTLE: SetMonData(&gEnemyParty[monId], MON_DATA_PP1, &gBattleBufferA[gActiveBattler][3]); @@ -951,10 +951,10 @@ static void SetRecordedOpponentMonData(u8 monId) SetMonData(&gEnemyParty[monId], MON_DATA_PP1 + gBattleBufferA[gActiveBattler][1] - REQUEST_PPMOVE1_BATTLE, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_OTID_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_OT_ID, &gBattleBufferA[gActiveBattler][3]); + SetMonData32(&gEnemyParty[monId], MON_DATA_OT_ID, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_EXP_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_EXP, &gBattleBufferA[gActiveBattler][3]); + SetMonData32(&gEnemyParty[monId], MON_DATA_EXP, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_HP_EV_BATTLE: SetMonData(&gEnemyParty[monId], MON_DATA_HP_EV, &gBattleBufferA[gActiveBattler][3]); @@ -1019,37 +1019,37 @@ static void SetRecordedOpponentMonData(u8 monId) SetMonData(&gEnemyParty[monId], MON_DATA_SPDEF_IV, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_PERSONALITY_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_PERSONALITY, &gBattleBufferA[gActiveBattler][3]); + SetMonData32(&gEnemyParty[monId], MON_DATA_PERSONALITY, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_CHECKSUM_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_CHECKSUM, &gBattleBufferA[gActiveBattler][3]); + SetMonData16(&gEnemyParty[monId], MON_DATA_CHECKSUM, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_STATUS_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_STATUS, &gBattleBufferA[gActiveBattler][3]); + SetMonData32(&gEnemyParty[monId], MON_DATA_STATUS, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_LEVEL_BATTLE: SetMonData(&gEnemyParty[monId], MON_DATA_LEVEL, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_HP_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_HP, &gBattleBufferA[gActiveBattler][3]); + SetMonData16(&gEnemyParty[monId], MON_DATA_HP, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_MAX_HP_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_MAX_HP, &gBattleBufferA[gActiveBattler][3]); + SetMonData16(&gEnemyParty[monId], MON_DATA_MAX_HP, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_ATK_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_ATK, &gBattleBufferA[gActiveBattler][3]); + SetMonData16(&gEnemyParty[monId], MON_DATA_ATK, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_DEF_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_DEF, &gBattleBufferA[gActiveBattler][3]); + SetMonData16(&gEnemyParty[monId], MON_DATA_DEF, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_SPEED_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_SPEED, &gBattleBufferA[gActiveBattler][3]); + SetMonData16(&gEnemyParty[monId], MON_DATA_SPEED, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_SPATK_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_SPATK, &gBattleBufferA[gActiveBattler][3]); + SetMonData16(&gEnemyParty[monId], MON_DATA_SPATK, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_SPDEF_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_SPDEF, &gBattleBufferA[gActiveBattler][3]); + SetMonData16(&gEnemyParty[monId], MON_DATA_SPDEF, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_COOL_BATTLE: SetMonData(&gEnemyParty[monId], MON_DATA_COOL, &gBattleBufferA[gActiveBattler][3]); @@ -1786,3 +1786,4 @@ static void RecordedOpponentHandleEndLinkBattle(void) static void RecordedOpponentCmdEnd(void) { } + diff --git a/src/battle_controller_recorded_player.c b/src/battle_controller_recorded_player.c index 591ddb67e306..243bb2c52677 100644 --- a/src/battle_controller_recorded_player.c +++ b/src/battle_controller_recorded_player.c @@ -901,10 +901,10 @@ static void SetRecordedPlayerMonData(u8 monId) } break; case REQUEST_SPECIES_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SPECIES, &gBattleBufferA[gActiveBattler][3]); + SetMonData16(&gPlayerParty[monId], MON_DATA_SPECIES, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_HELDITEM_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_HELD_ITEM, &gBattleBufferA[gActiveBattler][3]); + SetMonData16(&gPlayerParty[monId], MON_DATA_HELD_ITEM, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_MOVES_PP_BATTLE: for (i = 0; i < MAX_MON_MOVES; i++) @@ -918,7 +918,7 @@ static void SetRecordedPlayerMonData(u8 monId) case REQUEST_MOVE2_BATTLE: case REQUEST_MOVE3_BATTLE: case REQUEST_MOVE4_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_MOVE1 + gBattleBufferA[gActiveBattler][1] - REQUEST_MOVE1_BATTLE, &gBattleBufferA[gActiveBattler][3]); + SetMonData16(&gPlayerParty[monId], MON_DATA_MOVE1 + gBattleBufferA[gActiveBattler][1] - REQUEST_MOVE1_BATTLE, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_PP_DATA_BATTLE: SetMonData(&gPlayerParty[monId], MON_DATA_PP1, &gBattleBufferA[gActiveBattler][3]); @@ -1002,37 +1002,37 @@ static void SetRecordedPlayerMonData(u8 monId) SetMonData(&gPlayerParty[monId], MON_DATA_SPDEF_IV, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_PERSONALITY_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_PERSONALITY, &gBattleBufferA[gActiveBattler][3]); + SetMonData32(&gPlayerParty[monId], MON_DATA_PERSONALITY, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_CHECKSUM_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_CHECKSUM, &gBattleBufferA[gActiveBattler][3]); + SetMonData16(&gPlayerParty[monId], MON_DATA_CHECKSUM, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_STATUS_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_STATUS, &gBattleBufferA[gActiveBattler][3]); + SetMonData32(&gPlayerParty[monId], MON_DATA_STATUS, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_LEVEL_BATTLE: SetMonData(&gPlayerParty[monId], MON_DATA_LEVEL, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_HP_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_HP, &gBattleBufferA[gActiveBattler][3]); + SetMonData16(&gPlayerParty[monId], MON_DATA_HP, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_MAX_HP_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_MAX_HP, &gBattleBufferA[gActiveBattler][3]); + SetMonData16(&gPlayerParty[monId], MON_DATA_MAX_HP, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_ATK_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_ATK, &gBattleBufferA[gActiveBattler][3]); + SetMonData16(&gPlayerParty[monId], MON_DATA_ATK, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_DEF_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_DEF, &gBattleBufferA[gActiveBattler][3]); + SetMonData16(&gPlayerParty[monId], MON_DATA_DEF, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_SPEED_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SPEED, &gBattleBufferA[gActiveBattler][3]); + SetMonData16(&gPlayerParty[monId], MON_DATA_SPEED, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_SPATK_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SPATK, &gBattleBufferA[gActiveBattler][3]); + SetMonData16(&gPlayerParty[monId], MON_DATA_SPATK, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_SPDEF_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SPDEF, &gBattleBufferA[gActiveBattler][3]); + SetMonData16(&gPlayerParty[monId], MON_DATA_SPDEF, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_COOL_BATTLE: SetMonData(&gPlayerParty[monId], MON_DATA_COOL, &gBattleBufferA[gActiveBattler][3]); @@ -1810,3 +1810,4 @@ static void RecordedPlayerHandleEndLinkBattle(void) static void RecordedPlayerCmdEnd(void) { } + diff --git a/src/battle_controller_wally.c b/src/battle_controller_wally.c index ce357319a59e..96c821992a63 100644 --- a/src/battle_controller_wally.c +++ b/src/battle_controller_wally.c @@ -828,10 +828,10 @@ static void SetWallyMonData(u8 monId) } break; case REQUEST_SPECIES_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SPECIES, &gBattleBufferA[gActiveBattler][3]); + SetMonData16(&gPlayerParty[monId], MON_DATA_SPECIES, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_HELDITEM_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_HELD_ITEM, &gBattleBufferA[gActiveBattler][3]); + SetMonData16(&gPlayerParty[monId], MON_DATA_HELD_ITEM, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_MOVES_PP_BATTLE: for (i = 0; i < MAX_MON_MOVES; i++) @@ -845,7 +845,7 @@ static void SetWallyMonData(u8 monId) case REQUEST_MOVE2_BATTLE: case REQUEST_MOVE3_BATTLE: case REQUEST_MOVE4_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_MOVE1 + gBattleBufferA[gActiveBattler][1] - REQUEST_MOVE1_BATTLE, &gBattleBufferA[gActiveBattler][3]); + SetMonData16(&gPlayerParty[monId], MON_DATA_MOVE1 + gBattleBufferA[gActiveBattler][1] - REQUEST_MOVE1_BATTLE, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_PP_DATA_BATTLE: SetMonData(&gPlayerParty[monId], MON_DATA_PP1, &gBattleBufferA[gActiveBattler][3]); @@ -929,37 +929,37 @@ static void SetWallyMonData(u8 monId) SetMonData(&gPlayerParty[monId], MON_DATA_SPDEF_IV, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_PERSONALITY_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_PERSONALITY, &gBattleBufferA[gActiveBattler][3]); + SetMonData32(&gPlayerParty[monId], MON_DATA_PERSONALITY, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_CHECKSUM_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_CHECKSUM, &gBattleBufferA[gActiveBattler][3]); + SetMonData16(&gPlayerParty[monId], MON_DATA_CHECKSUM, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_STATUS_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_STATUS, &gBattleBufferA[gActiveBattler][3]); + SetMonData32(&gPlayerParty[monId], MON_DATA_STATUS, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_LEVEL_BATTLE: SetMonData(&gPlayerParty[monId], MON_DATA_LEVEL, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_HP_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_HP, &gBattleBufferA[gActiveBattler][3]); + SetMonData16(&gPlayerParty[monId], MON_DATA_HP, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_MAX_HP_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_MAX_HP, &gBattleBufferA[gActiveBattler][3]); + SetMonData16(&gPlayerParty[monId], MON_DATA_MAX_HP, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_ATK_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_ATK, &gBattleBufferA[gActiveBattler][3]); + SetMonData16(&gPlayerParty[monId], MON_DATA_ATK, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_DEF_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_DEF, &gBattleBufferA[gActiveBattler][3]); + SetMonData16(&gPlayerParty[monId], MON_DATA_DEF, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_SPEED_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SPEED, &gBattleBufferA[gActiveBattler][3]); + SetMonData16(&gPlayerParty[monId], MON_DATA_SPEED, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_SPATK_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SPATK, &gBattleBufferA[gActiveBattler][3]); + SetMonData16(&gPlayerParty[monId], MON_DATA_SPATK, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_SPDEF_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SPDEF, &gBattleBufferA[gActiveBattler][3]); + SetMonData16(&gPlayerParty[monId], MON_DATA_SPDEF, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_COOL_BATTLE: SetMonData(&gPlayerParty[monId], MON_DATA_COOL, &gBattleBufferA[gActiveBattler][3]); @@ -1568,3 +1568,4 @@ static void WallyHandleEndLinkBattle(void) static void WallyCmdEnd(void) { } + diff --git a/src/evolution_scene.c b/src/evolution_scene.c index 133afe3b0dd2..be8005f41118 100644 --- a/src/evolution_scene.c +++ b/src/evolution_scene.c @@ -552,7 +552,7 @@ static void CreateShedinja(u16 preEvoSpecies, struct Pokemon *mon) { s32 i; struct Pokemon *shedinja = &gPlayerParty[gPlayerPartyCount]; - +#ifndef UBFIX CopyMon(&gPlayerParty[gPlayerPartyCount], mon, sizeof(struct Pokemon)); SetMonData(&gPlayerParty[gPlayerPartyCount], MON_DATA_SPECIES, &gEvolutionTable[preEvoSpecies][1].targetSpecies); SetMonData(&gPlayerParty[gPlayerPartyCount], MON_DATA_NICKNAME, gSpeciesNames[gEvolutionTable[preEvoSpecies][1].targetSpecies]); @@ -568,7 +568,25 @@ static void CreateShedinja(u16 preEvoSpecies, struct Pokemon *mon) SetMonData(&gPlayerParty[gPlayerPartyCount], MON_DATA_STATUS, &data); data = MAIL_NONE; SetMonData(&gPlayerParty[gPlayerPartyCount], MON_DATA_MAIL, &data); +#else + u16 data2 = 0; + u8 data3 = 0; + + CopyMon(shedinja, mon, sizeof(struct Pokemon)); + SetMonData(shedinja, MON_DATA_NICKNAME, gSpeciesNames[gEvolutionTable[preEvoSpecies][1].targetSpecies]); + SetMonData(shedinja, MON_DATA_HELD_ITEM, &data2); + SetMonData(shedinja, MON_DATA_MARKINGS, &data3); + SetMonData(shedinja, MON_DATA_ENCRYPT_SEPARATOR, &data); + + for (i = MON_DATA_COOL_RIBBON; i < MON_DATA_COOL_RIBBON + CONTEST_CATEGORIES_COUNT; i++) + SetMonData(shedinja, i, &data3); + for (i = MON_DATA_CHAMPION_RIBBON; i <= MON_DATA_UNUSED_RIBBONS; i++) + SetMonData(shedinja, i, &data3); + SetMonData(shedinja, MON_DATA_STATUS, &data); + data2 = MAIL_NONE; + SetMonData(shedinja, MON_DATA_MAIL, &data); +#endif CalculateMonStats(&gPlayerParty[gPlayerPartyCount]); CalculatePlayerPartyCount(); diff --git a/src/field_specials.c b/src/field_specials.c index 7d20d3571d0c..534cb389150e 100644 --- a/src/field_specials.c +++ b/src/field_specials.c @@ -1423,9 +1423,19 @@ void SetShoalItemFlag(u16 unused) void LoadWallyZigzagoon(void) { u16 monData; + #ifdef UBFIX + bool8 monDataU8; + #endif + CreateMon(&gPlayerParty[0], SPECIES_ZIGZAGOON, 7, USE_RANDOM_IVS, FALSE, 0, OT_ID_PLAYER_ID, 0); + #ifdef UBFIX + monDataU8 = TRUE; + SetMonData(&gPlayerParty[0], MON_DATA_ABILITY_NUM, &monDataU8); + #else monData = TRUE; SetMonData(&gPlayerParty[0], MON_DATA_ABILITY_NUM, &monData); + #endif + monData = MOVE_TACKLE; SetMonData(&gPlayerParty[0], MON_DATA_MOVE1, &monData); monData = MOVE_NONE; diff --git a/src/mail_data.c b/src/mail_data.c index ed152faf2ced..ae68962fb21f 100644 --- a/src/mail_data.c +++ b/src/mail_data.c @@ -44,13 +44,18 @@ bool8 MonHasMail(struct Pokemon *mon) u8 GiveMailToMonByItemId(struct Pokemon *mon, u16 itemId) { - u8 heldItem[2]; u8 id, i; u16 species; u32 personality; + + #ifndef UBFIX + u8 heldItem[2]; heldItem[0] = itemId; heldItem[1] = itemId >> 8; + #else + u16 *heldItem = &itemId; + #endif for (id = 0; id < PARTY_SIZE; id++) { @@ -110,7 +115,14 @@ u16 MailSpeciesToSpecies(u16 mailSpecies, u16 *buffer) u8 GiveMailToMon(struct Pokemon *mon, struct Mail *mail) { + +// Use a u16 pointer insted of a u8 heldItem as u16 is guaranteed to be aligned properly +#ifndef UBFIX u8 heldItem[2]; +#else + u16 *heldItem; +#endif + u16 itemId = mail->itemId; u8 mailId = GiveMailToMonByItemId(mon, itemId); @@ -121,8 +133,12 @@ u8 GiveMailToMon(struct Pokemon *mon, struct Mail *mail) SetMonData(mon, MON_DATA_MAIL, &mailId); +#ifndef UBFIX heldItem[0] = itemId; heldItem[1] = itemId >> 8; +#else + heldItem = &itemId; +#endif SetMonData(mon, MON_DATA_HELD_ITEM, heldItem); @@ -136,16 +152,28 @@ static bool32 UNUSED DummyMailFunc(void) void TakeMailFromMon(struct Pokemon *mon) { - u8 heldItem[2]; u8 mailId; if (MonHasMail(mon)) { + #ifdef UBFIX + u16 *heldItem; + u16 heldItemVar; + #else + u8 heldItem[2]; + #endif mailId = GetMonData(mon, MON_DATA_MAIL); gSaveBlock1Ptr->mail[mailId].itemId = ITEM_NONE; mailId = MAIL_NONE; + + #ifdef UBFIX + heldItemVar = ITEM_NONE; + heldItem = &heldItemVar; + #else heldItem[0] = ITEM_NONE; heldItem[1] = ITEM_NONE << 8; + #endif + SetMonData(mon, MON_DATA_MAIL, &mailId); SetMonData(mon, MON_DATA_HELD_ITEM, heldItem); } @@ -159,11 +187,18 @@ void ClearMailItemId(u8 mailId) u8 TakeMailFromMonAndSave(struct Pokemon *mon) { u8 i; - u8 newHeldItem[2]; u8 newMailId; + #ifndef UBFIX + u8 newHeldItem[2]; + newHeldItem[0] = ITEM_NONE; newHeldItem[1] = ITEM_NONE << 8; + #else + u16 heldItemVar = ITEM_NONE; + u16 *newHeldItem = &heldItemVar; + #endif + newMailId = MAIL_NONE; for (i = PARTY_SIZE; i < MAIL_COUNT; i++) @@ -203,3 +238,4 @@ bool8 ItemIsMail(u16 itemId) return FALSE; } } + diff --git a/src/party_menu.c b/src/party_menu.c index 9b076755c844..bfc189760c37 100755 --- a/src/party_menu.c +++ b/src/party_menu.c @@ -1798,15 +1798,25 @@ static void DisplaySwitchedHeldItemMessage(u16 item, u16 item2, bool8 keepOpen) static void GiveItemToMon(struct Pokemon *mon, u16 item) { + #ifndef UBFIX u8 itemBytes[2]; + #else + u16 *itemBytes; + #endif if (ItemIsMail(item) == TRUE) { if (GiveMailToMonByItemId(mon, item) == MAIL_NONE) return; } + +#ifndef UBFIX itemBytes[0] = item; itemBytes[1] = item >> 8; +#else + itemBytes = &item; +#endif + SetMonData(mon, MON_DATA_HELD_ITEM, itemBytes); } diff --git a/src/pokemon.c b/src/pokemon.c index 6ee052fda576..90226dd5754d 100644 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -2162,6 +2162,7 @@ void ZeroBoxMonData(struct BoxPokemon *boxMon) void ZeroMonData(struct Pokemon *mon) { +#ifndef UBFIX u32 arg; ZeroBoxMonData(&mon->box); arg = 0; @@ -2176,6 +2177,11 @@ void ZeroMonData(struct Pokemon *mon) SetMonData(mon, MON_DATA_SPDEF, &arg); arg = MAIL_NONE; SetMonData(mon, MON_DATA_MAIL, &arg); +#else + u16 mail = MAIL_NONE; + memset(mon, 0, sizeof(*mon)); + SetMonData(mon, MON_DATA_MAIL, &mail); +#endif } void ZeroPlayerPartyMons(void) @@ -2780,9 +2786,14 @@ void CreateEnemyEventMon(void) CreateEventMon(&gEnemyParty[0], species, level, USE_RANDOM_IVS, FALSE, 0, OT_ID_PLAYER_ID, 0); if (itemId) { +#ifndef UBFIX u8 heldItem[2]; heldItem[0] = itemId; heldItem[1] = itemId >> 8; +#else + // gSpecialVar_0x8006 is a u16 + u16 *heldItem = &gSpecialVar_0x8006; +#endif SetMonData(&gEnemyParty[0], MON_DATA_HELD_ITEM, heldItem); } } @@ -4066,13 +4077,19 @@ u32 GetBoxMonData3(struct BoxPokemon *boxMon, s32 field, u8 *data) u32 GetBoxMonData2(struct BoxPokemon *boxMon, s32 field) __attribute__((alias("GetBoxMonData3"))); +#ifndef UBFIX #define SET8(lhs) (lhs) = *data #define SET16(lhs) (lhs) = data[0] + (data[1] << 8) #define SET32(lhs) (lhs) = data[0] + (data[1] << 8) + (data[2] << 16) + (data[3] << 24) +#else +#define SET8(lhs) (lhs) = *(u8 *)data +#define SET16(lhs) (lhs) = *(u16 *)data +#define SET32(lhs) (lhs) = *(u32 *)data +#endif void SetMonData(struct Pokemon *mon, s32 field, const void *dataArg) { - const u8 *data = dataArg; + const void *data = dataArg; switch (field) { @@ -4116,7 +4133,11 @@ void SetMonData(struct Pokemon *mon, s32 field, const void *dataArg) void SetBoxMonData(struct BoxPokemon *boxMon, s32 field, const void *dataArg) { + #ifndef UBFIX const u8 *data = dataArg; + #else + const void* data = dataArg; + #endif struct PokemonSubstruct0 *substruct0 = NULL; struct PokemonSubstruct1 *substruct1 = NULL; @@ -4152,10 +4173,14 @@ void SetBoxMonData(struct BoxPokemon *boxMon, s32 field, const void *dataArg) break; case MON_DATA_NICKNAME: { + #ifndef UBFIX s32 i; for (i = 0; i < POKEMON_NAME_LENGTH; i++) boxMon->nickname[i] = data[i]; break; + #else + memcpy(boxMon->nickname, data, POKEMON_NAME_LENGTH); + #endif } case MON_DATA_LANGUAGE: SET8(boxMon->language); @@ -4171,9 +4196,13 @@ void SetBoxMonData(struct BoxPokemon *boxMon, s32 field, const void *dataArg) break; case MON_DATA_OT_NAME: { + #ifndef UBFIX s32 i; for (i = 0; i < PLAYER_NAME_LENGTH; i++) boxMon->otName[i] = data[i]; + #else + memcpy(boxMon->otName, data, PLAYER_NAME_LENGTH); + #endif break; } case MON_DATA_MARKINGS: @@ -4262,8 +4291,12 @@ void SetBoxMonData(struct BoxPokemon *boxMon, s32 field, const void *dataArg) break; case MON_DATA_MET_LEVEL: { + #ifndef UBFIX u8 metLevel = *data; substruct3->metLevel = metLevel; + #else + SET8(substruct3->metLevel); + #endif break; } case MON_DATA_MET_GAME: @@ -4271,8 +4304,12 @@ void SetBoxMonData(struct BoxPokemon *boxMon, s32 field, const void *dataArg) break; case MON_DATA_POKEBALL: { + #ifndef UBFIX u8 pokeball = *data; substruct3->pokeball = pokeball; + #else + SET8(substruct3->pokeball); + #endif break; } case MON_DATA_OT_GENDER: @@ -4365,7 +4402,13 @@ void SetBoxMonData(struct BoxPokemon *boxMon, s32 field, const void *dataArg) break; case MON_DATA_IVS: { + #ifndef UBFIX u32 ivs = data[0] | (data[1] << 8) | (data[2] << 16) | (data[3] << 24); + #else + u32 ivs; + SET32(ivs); + #endif + substruct3->hpIV = ivs & MAX_IV_MASK; substruct3->attackIV = (ivs >> 5) & MAX_IV_MASK; substruct3->defenseIV = (ivs >> 10) & MAX_IV_MASK; diff --git a/src/script_pokemon_util.c b/src/script_pokemon_util.c index 6e5653884b23..9f20828230ff 100755 --- a/src/script_pokemon_util.c +++ b/src/script_pokemon_util.c @@ -62,12 +62,22 @@ u8 ScriptGiveMon(u16 species, u8 level, u16 item, u32 unused1, u32 unused2, u8 u { u16 nationalDexNum; int sentToPc; - u8 heldItem[2]; struct Pokemon mon; +#ifndef UBFIX + u8 heldItem[2]; +#else + u16 *heldItem; +#endif CreateMon(&mon, species, level, USE_RANDOM_IVS, FALSE, 0, OT_ID_PLAYER_ID, 0); + +#ifndef UBFIX heldItem[0] = item; heldItem[1] = item >> 8; +#else + heldItem = &item; +#endif + SetMonData(&mon, MON_DATA_HELD_ITEM, heldItem); sentToPc = GiveMonToPlayer(&mon); nationalDexNum = SpeciesToNationalPokedexNum(species); @@ -136,14 +146,17 @@ bool8 DoesPartyHaveEnigmaBerry(void) void CreateScriptedWildMon(u16 species, u8 level, u16 item) { - u8 heldItem[2]; - ZeroEnemyPartyMons(); CreateMon(&gEnemyParty[0], species, level, USE_RANDOM_IVS, 0, 0, OT_ID_PLAYER_ID, 0); if (item) { +#ifndef UBFIX + u8 heldItem[2]; heldItem[0] = item; heldItem[1] = item >> 8; +#else + u16 *heldItem = &item; +#endif SetMonData(&gEnemyParty[0], MON_DATA_HELD_ITEM, heldItem); } }