Merge origin/master into pikalaxalt/link

This commit is contained in:
PikalaxALT
2017-11-16 08:36:51 -05:00
2913 changed files with 158852 additions and 19880 deletions

View File

@@ -44,6 +44,7 @@
#include "tv.h"
#include "safari_zone.h"
#include "battle_string_ids.h"
#include "data2.h"
struct UnknownStruct6
{
@@ -354,7 +355,7 @@ static const u8 sUnknown_0831BCF3[] = {4, 4, 4, 4};
void CB2_InitBattle(void)
{
MoveSaveBlocks_ResetHeap();
AllocateBattleResrouces();
AllocateBattleResources();
AllocateBattleSpritesData();
AllocateMonSpritesGfx();
sub_8185F84();
@@ -510,7 +511,7 @@ static void sub_8036A5C(void)
gBattleStruct->field_182 = r6;
*(&gBattleStruct->field_183) = r6 >> 8;
gBattleStruct->field_183 |= FlagGet(SYS_FRONTIER_PASS) << 7;
gBattleStruct->field_183 |= FlagGet(FLAG_SYS_FRONTIER_PASS) << 7;
}
static void SetPlayerBerryDataInBattleStruct(void)
@@ -1611,7 +1612,7 @@ void BattleMainCB2(void)
if (gMain.heldKeys & B_BUTTON && gBattleTypeFlags & BATTLE_TYPE_RECORDED && sub_8186450())
{
gScriptResult = gBattleOutcome = BATTLE_PLAYER_TELEPORTED;
gSpecialVar_Result = gBattleOutcome = BATTLE_PLAYER_TELEPORTED;
ResetPaletteFadeControl();
BeginNormalPaletteFade(-1, 0, 0, 0x10, 0);
SetMainCallback2(CB2_QuitRecordedBattle);
@@ -2069,7 +2070,7 @@ static void sub_8038F34(void)
if (!gSaveBlock2Ptr->field_CA9_b && i == monsCount)
{
if (FlagGet(SYS_FRONTIER_PASS))
if (FlagGet(FLAG_SYS_FRONTIER_PASS))
{
FreeAllWindowBuffers();
SetMainCallback2(sub_80392A8);
@@ -2478,15 +2479,6 @@ static void sub_80398D0(struct Sprite *sprite)
}
}
// to get rid of once the struct is declared in a header
struct MonCoords
{
// This would use a bitfield, but sub_8079F44
// uses it as a u8 and casting won't match.
u8 coords; // u8 x:4, y:4;
u8 y_offset;
};
extern const struct MonCoords gMonFrontPicCoords[];
extern const struct MonCoords gCastformFrontSpriteCoords[];
@@ -2854,9 +2846,9 @@ static void BattleStartClearSetData(void)
*(i + 3 * 8 + (u8*)(gBattleStruct->mirrorMoveArrays) + 0) = 0;
}
for (i = 0; i < 4; i++)
for (i = 0; i < BATTLE_BANKS_COUNT; i++)
{
*(gBattleStruct->field_294 + i) = 6;
*(gBattleStruct->AI_monToSwitchIntoId + i) = 6;
}
gBattleStruct->field_DF = 0;
@@ -2936,8 +2928,8 @@ void SwitchInClearSetData(void)
{
gDisableStructs[gActiveBank].substituteHP = disableStructCopy.substituteHP;
gDisableStructs[gActiveBank].bankWithSureHit = disableStructCopy.bankWithSureHit;
gDisableStructs[gActiveBank].perishSong1 = disableStructCopy.perishSong1;
gDisableStructs[gActiveBank].perishSong2 = disableStructCopy.perishSong2;
gDisableStructs[gActiveBank].perishSongTimer1 = disableStructCopy.perishSongTimer1;
gDisableStructs[gActiveBank].perishSongTimer2 = disableStructCopy.perishSongTimer2;
gDisableStructs[gActiveBank].bankPreventingEscape = disableStructCopy.bankPreventingEscape;
}
@@ -3683,7 +3675,7 @@ static void TryDoEventsBeforeFirstTurn(void)
}
for (i = 0; i < BATTLE_BANKS_COUNT; i++)
{
*(gBattleStruct->field_5C + i) = 6;
*(gBattleStruct->monToSwitchIntoId + i) = 6;
gActionForBanks[i] = ACTION_INIT_VALUE;
gChosenMovesByBanks[i] = MOVE_NONE;
}
@@ -3794,7 +3786,7 @@ void BattleTurnPassed(void)
}
for (i = 0; i < 4; i++)
*(gBattleStruct->field_5C + i) = 6;
*(gBattleStruct->monToSwitchIntoId + i) = 6;
*(&gBattleStruct->field_91) = gAbsentBankFlags;
BattleHandleAddTextPrinter(gText_EmptyString3, 0);
@@ -3885,7 +3877,7 @@ void sub_803BDA0(u8 bank)
gUnknown_0203CF00[i] = *(bank * 3 + i + (u8*)(gBattleStruct->field_60));
r4 = pokemon_order_func(gBattlePartyID[bank]);
r1 = pokemon_order_func(*(gBattleStruct->field_5C + bank));
r1 = pokemon_order_func(*(gBattleStruct->monToSwitchIntoId + bank));
sub_81B8FB0(r4, r1);
if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE)
@@ -3933,7 +3925,7 @@ static void HandleTurnActionSelectionState(void)
gBattleCommunication[gActiveBank] = STATE_BEFORE_ACTION_CHOSEN;
break;
case STATE_BEFORE_ACTION_CHOSEN: // choose an action
*(gBattleStruct->field_5C + gActiveBank) = 6;
*(gBattleStruct->monToSwitchIntoId + gActiveBank) = 6;
if (gBattleTypeFlags & BATTLE_TYPE_MULTI
|| !(identity & BIT_MON)
|| gBattleStruct->field_91 & gBitTable[GetBankByIdentity(identity ^ BIT_MON)]
@@ -4051,9 +4043,9 @@ static void HandleTurnActionSelectionState(void)
else
{
if (gActiveBank == 2 && gActionForBanks[0] == ACTION_SWITCH)
EmitChoosePokemon(0, 0, *(gBattleStruct->field_5C + 0), ABILITY_NONE, gBattleStruct->field_60[gActiveBank]);
EmitChoosePokemon(0, 0, *(gBattleStruct->monToSwitchIntoId + 0), ABILITY_NONE, gBattleStruct->field_60[gActiveBank]);
else if (gActiveBank == 3 && gActionForBanks[1] == ACTION_SWITCH)
EmitChoosePokemon(0, 0, *(gBattleStruct->field_5C + 1), ABILITY_NONE, gBattleStruct->field_60[gActiveBank]);
EmitChoosePokemon(0, 0, *(gBattleStruct->monToSwitchIntoId + 1), ABILITY_NONE, gBattleStruct->field_60[gActiveBank]);
else
EmitChoosePokemon(0, 0, 6, ABILITY_NONE, gBattleStruct->field_60[gActiveBank]);
}
@@ -4340,7 +4332,7 @@ static void HandleTurnActionSelectionState(void)
for (i = 0; i < gNoOfAllBanks; i++)
{
if (gActionForBanks[i] == ACTION_SWITCH)
sub_80571DC(i, *(gBattleStruct->field_5C + i));
sub_80571DC(i, *(gBattleStruct->monToSwitchIntoId + i));
}
}
}
@@ -4364,7 +4356,7 @@ static bool8 sub_803CDB8(void)
static void sub_803CDF8(void)
{
*(gBattleStruct->field_5C + gActiveBank) = gBattleBufferB[gActiveBank][1];
*(gBattleStruct->monToSwitchIntoId + gActiveBank) = gBattleBufferB[gActiveBank][1];
RecordedBattle_SetBankAction(gActiveBank, gBattleBufferB[gActiveBank][1]);
if (gBattleTypeFlags & BATTLE_TYPE_LINK && gBattleTypeFlags & BATTLE_TYPE_MULTI)
@@ -4436,7 +4428,7 @@ u8 GetWhoStrikesFirst(u8 bank1, u8 bank2, bool8 ignoreChosenMoves)
// badge boost
if (!(gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_x2000000 | BATTLE_TYPE_FRONTIER))
&& FlagGet(BADGE03_GET)
&& FlagGet(FLAG_BADGE03_GET)
&& GetBankSide(bank1) == SIDE_PLAYER)
{
speedBank1 = (speedBank1 * 110) / 100;
@@ -4470,7 +4462,7 @@ u8 GetWhoStrikesFirst(u8 bank1, u8 bank2, bool8 ignoreChosenMoves)
// badge boost
if (!(gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_x2000000 | BATTLE_TYPE_FRONTIER))
&& FlagGet(BADGE03_GET)
&& FlagGet(FLAG_BADGE03_GET)
&& GetBankSide(bank2) == SIDE_PLAYER)
{
speedBank2 = (speedBank2 * 110) / 100;
@@ -4759,7 +4751,7 @@ static void HandleEndTurn_BattleWon(void)
if (gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_x2000000))
{
gScriptResult = gBattleOutcome;
gSpecialVar_Result = gBattleOutcome;
gBattleTextBuff1[0] = gBattleOutcome;
gBankAttacker = GetBankByIdentity(IDENTITY_PLAYER_MON1);
gBattlescriptCurrInstr = BattleScript_LinkBattleWonOrLost;
@@ -4768,7 +4760,7 @@ static void HandleEndTurn_BattleWon(void)
else if (gBattleTypeFlags & BATTLE_TYPE_TRAINER
&& gBattleTypeFlags & (BATTLE_TYPE_FRONTIER | BATTLE_TYPE_x4000000 | BATTLE_TYPE_EREADER_TRAINER))
{
BattleMusicStop();
BattleStopLowHpSound();
gBattlescriptCurrInstr = BattleScript_FrontierTrainerBattleWon;
if (gTrainerBattleOpponent_A == TRAINER_OPPONENT_3FE)
@@ -4778,7 +4770,7 @@ static void HandleEndTurn_BattleWon(void)
}
else if (gBattleTypeFlags & BATTLE_TYPE_TRAINER && !(gBattleTypeFlags & BATTLE_TYPE_LINK))
{
BattleMusicStop();
BattleStopLowHpSound();
gBattlescriptCurrInstr = BattleScript_LocalTrainerBattleWon;
switch (gTrainers[gTrainerBattleOpponent_A].trainerClass)
@@ -5021,7 +5013,7 @@ static void ReturnFromBattleToOverworld(void)
if (gBattleTypeFlags & BATTLE_TYPE_LINK && gReceivedRemoteLinkPlayers != 0)
return;
gScriptResult = gBattleOutcome;
gSpecialVar_Result = gBattleOutcome;
gMain.inBattle = 0;
gMain.callback1 = gPreBattleCallback1;
@@ -5619,7 +5611,7 @@ static void HandleAction_NothingIsFainted(void)
static void HandleAction_ActionFinished(void)
{
*(gBattleStruct->field_5C + gBanksByTurnOrder[gCurrentTurnActionNumber]) = 6;
*(gBattleStruct->monToSwitchIntoId + gBanksByTurnOrder[gCurrentTurnActionNumber]) = 6;
gCurrentTurnActionNumber++;
gCurrentActionFuncId = gActionsByTurnOrder[gCurrentTurnActionNumber];
SpecialStatusesClear();

View File

@@ -36,9 +36,9 @@ static bool8 ShouldUseItem(void);
static bool8 ShouldSwitchIfPerishSong(void)
{
if (gStatuses3[gActiveBank] & STATUS3_PERISH_SONG
&& gDisableStructs[gActiveBank].perishSong1 == 0)
&& gDisableStructs[gActiveBank].perishSongTimer1 == 0)
{
*(gBattleStruct->field_294 + gActiveBank) = 6;
*(gBattleStruct->AI_monToSwitchIntoId + gActiveBank) = 6;
EmitTwoReturnValues(1, ACTION_SWITCH, 0);
return TRUE;
}
@@ -120,7 +120,7 @@ static bool8 ShouldSwitchIfWonderGuard(void)
if (moveFlags & MOVESTATUS_SUPEREFFECTIVE && Random() % 3 < 2)
{
// we found a mon
*(gBattleStruct->field_294 + gActiveBank) = i;
*(gBattleStruct->AI_monToSwitchIntoId + gActiveBank) = i;
EmitTwoReturnValues(1, ACTION_SWITCH, 0);
return TRUE;
}
@@ -206,9 +206,9 @@ static bool8 FindMonThatAbsorbsOpponentsMove(void)
continue;
if (i == gBattlePartyID[bankIn2])
continue;
if (i == *(gBattleStruct->field_5C + bankIn1))
if (i == *(gBattleStruct->monToSwitchIntoId + bankIn1))
continue;
if (i == *(gBattleStruct->field_5C + bankIn2))
if (i == *(gBattleStruct->monToSwitchIntoId + bankIn2))
continue;
species = GetMonData(&party[i], MON_DATA_SPECIES);
@@ -220,7 +220,7 @@ static bool8 FindMonThatAbsorbsOpponentsMove(void)
if (absorbingTypeAbility == monAbility && Random() & 1)
{
// we found a mon
*(gBattleStruct->field_294 + gActiveBank) = i;
*(gBattleStruct->AI_monToSwitchIntoId + gActiveBank) = i;
EmitTwoReturnValues(1, ACTION_SWITCH, 0);
return TRUE;
}
@@ -240,13 +240,13 @@ static bool8 ShouldSwitchIfNaturalCure(void)
if ((gUnknown_02024250[gActiveBank] == 0 || gUnknown_02024250[gActiveBank] == 0xFFFF) && Random() & 1)
{
*(gBattleStruct->field_294 + gActiveBank) = 6;
*(gBattleStruct->AI_monToSwitchIntoId + gActiveBank) = 6;
EmitTwoReturnValues(1, ACTION_SWITCH, 0);
return TRUE;
}
else if (gBattleMoves[gUnknown_02024250[gActiveBank]].power == 0 && Random() & 1)
{
*(gBattleStruct->field_294 + gActiveBank) = 6;
*(gBattleStruct->AI_monToSwitchIntoId + gActiveBank) = 6;
EmitTwoReturnValues(1, ACTION_SWITCH, 0);
return TRUE;
}
@@ -257,7 +257,7 @@ static bool8 ShouldSwitchIfNaturalCure(void)
return TRUE;
if (Random() & 1)
{
*(gBattleStruct->field_294 + gActiveBank) = 6;
*(gBattleStruct->AI_monToSwitchIntoId + gActiveBank) = 6;
EmitTwoReturnValues(1, ACTION_SWITCH, 0);
return TRUE;
}
@@ -400,9 +400,9 @@ static bool8 FindMonWithFlagsAndSuperEffective(u8 flags, u8 moduloPercent)
continue;
if (i == gBattlePartyID[bankIn2])
continue;
if (i == *(gBattleStruct->field_5C + bankIn1))
if (i == *(gBattleStruct->monToSwitchIntoId + bankIn1))
continue;
if (i == *(gBattleStruct->field_5C + bankIn2))
if (i == *(gBattleStruct->monToSwitchIntoId + bankIn2))
continue;
species = GetMonData(&party[i], MON_DATA_SPECIES);
@@ -425,7 +425,7 @@ static bool8 FindMonWithFlagsAndSuperEffective(u8 flags, u8 moduloPercent)
moveFlags = AI_TypeCalc(move, gBattleMons[bankIn1].species, gBattleMons[bankIn1].ability);
if (moveFlags & MOVESTATUS_SUPEREFFECTIVE && Random() % moduloPercent == 0)
{
*(gBattleStruct->field_294 + gActiveBank) = i;
*(gBattleStruct->AI_monToSwitchIntoId + gActiveBank) = i;
EmitTwoReturnValues(1, ACTION_SWITCH, 0);
return TRUE;
}
@@ -508,9 +508,9 @@ static bool8 ShouldSwitch(void)
continue;
if (i == gBattlePartyID[bankIn2])
continue;
if (i == *(gBattleStruct->field_5C + bankIn1))
if (i == *(gBattleStruct->monToSwitchIntoId + bankIn1))
continue;
if (i == *(gBattleStruct->field_5C + bankIn2))
if (i == *(gBattleStruct->monToSwitchIntoId + bankIn2))
continue;
availableToSwitch++;
@@ -554,7 +554,7 @@ void AI_TrySwitchOrUseItem(void)
{
if (ShouldSwitch())
{
if (*(gBattleStruct->field_294 + gActiveBank) == 6)
if (*(gBattleStruct->AI_monToSwitchIntoId + gActiveBank) == 6)
{
s32 monToSwitchId = GetMostSuitableMonToSwitchInto();
if (monToSwitchId == 6)
@@ -590,19 +590,19 @@ void AI_TrySwitchOrUseItem(void)
continue;
if (monToSwitchId == gBattlePartyID[bankIn2])
continue;
if (monToSwitchId == *(gBattleStruct->field_5C + bankIn1))
if (monToSwitchId == *(gBattleStruct->monToSwitchIntoId + bankIn1))
continue;
if (monToSwitchId == *(gBattleStruct->field_5C + bankIn2))
if (monToSwitchId == *(gBattleStruct->monToSwitchIntoId + bankIn2))
continue;
break;
}
}
*(gBattleStruct->field_294 + gActiveBank) = monToSwitchId;
*(gBattleStruct->AI_monToSwitchIntoId + gActiveBank) = monToSwitchId;
}
*(gBattleStruct->field_5C + gActiveBank) = *(gBattleStruct->field_294 + gActiveBank);
*(gBattleStruct->monToSwitchIntoId + gActiveBank) = *(gBattleStruct->AI_monToSwitchIntoId + gActiveBank);
return;
}
else if (ShouldUseItem())
@@ -614,28 +614,25 @@ void AI_TrySwitchOrUseItem(void)
EmitTwoReturnValues(1, ACTION_USE_MOVE, (gActiveBank ^ BIT_SIDE) << 8);
}
#define TYPE_FORESIGHT 0xFE
#define TYPE_ENDTABLE 0xFF
static void ModulateByTypeEffectiveness(u8 atkType, u8 defType1, u8 defType2, u8 *var)
{
s32 i = 0;
while (gTypeEffectiveness[i] != TYPE_ENDTABLE)
while (TYPE_EFFECT_ATK_TYPE(i) != TYPE_ENDTABLE)
{
if (gTypeEffectiveness[i] == TYPE_FORESIGHT)
if (TYPE_EFFECT_ATK_TYPE(i) == TYPE_FORESIGHT)
{
i += 3;
continue;
}
else if (gTypeEffectiveness[i] == atkType)
else if (TYPE_EFFECT_ATK_TYPE(i) == atkType)
{
// check type1
if (gTypeEffectiveness[i + 1] == defType1)
*var = (*var * gTypeEffectiveness[i + 2]) / 10;
if (TYPE_EFFECT_DEF_TYPE(i) == defType1)
*var = (*var * TYPE_EFFECT_MULTIPLIER(i)) / 10;
// check type2
if (gTypeEffectiveness[i + 1] == defType2 && defType1 != defType2)
*var = (*var * gTypeEffectiveness[i + 2]) / 10;
if (TYPE_EFFECT_DEF_TYPE(i) == defType2 && defType1 != defType2)
*var = (*var * TYPE_EFFECT_MULTIPLIER(i)) / 10;
}
i += 3;
}
@@ -654,8 +651,8 @@ u8 GetMostSuitableMonToSwitchInto(void)
u8 invalidMons;
u16 move;
if (*(gBattleStruct->field_5C + gActiveBank) != 6)
return *(gBattleStruct->field_5C + gActiveBank);
if (*(gBattleStruct->monToSwitchIntoId + gActiveBank) != 6)
return *(gBattleStruct->monToSwitchIntoId + gActiveBank);
if (gBattleTypeFlags & BATTLE_TYPE_ARENA)
return gBattlePartyID[gActiveBank] + 1;
@@ -711,8 +708,8 @@ u8 GetMostSuitableMonToSwitchInto(void)
&& !(gBitTable[i] & invalidMons)
&& gBattlePartyID[bankIn1] != i
&& gBattlePartyID[bankIn2] != i
&& i != *(gBattleStruct->field_5C + bankIn1)
&& i != *(gBattleStruct->field_5C + bankIn2))
&& i != *(gBattleStruct->monToSwitchIntoId + bankIn1)
&& i != *(gBattleStruct->monToSwitchIntoId + bankIn2))
{
u8 type1 = gBaseStats[species].type1;
u8 type2 = gBaseStats[species].type2;
@@ -771,9 +768,9 @@ u8 GetMostSuitableMonToSwitchInto(void)
continue;
if (gBattlePartyID[bankIn2] == i)
continue;
if (i == *(gBattleStruct->field_5C + bankIn1))
if (i == *(gBattleStruct->monToSwitchIntoId + bankIn1))
continue;
if (i == *(gBattleStruct->field_5C + bankIn2))
if (i == *(gBattleStruct->monToSwitchIntoId + bankIn2))
continue;
for (j = 0; j < 4; j++)

View File

@@ -36,7 +36,7 @@ extern u8 gBattleBufferA[BATTLE_BANKS_COUNT][0x200];
extern u8 gBattleBufferB[BATTLE_BANKS_COUNT][0x200];
extern struct BattlePokemon gBattleMons[BATTLE_BANKS_COUNT];
extern struct SpriteTemplate gUnknown_0202499C;
extern u16 gScriptItemId;
extern u16 gSpecialVar_ItemId;
extern u8 gHealthBoxesIds[BATTLE_BANKS_COUNT];
extern u8 gBattleOutcome;
extern u16 gBattle_BG0_X;
@@ -449,7 +449,7 @@ static void sub_8064C58(void)
{
FreeSpriteOamMatrix(&gSprites[gBankSpriteIds[gActiveBank]]);
DestroySprite(&gSprites[gBankSpriteIds[gActiveBank]]);
sub_805EEE0(gActiveBank);
EnemyShadowCallbackToSetInvisible(gActiveBank);
SetHealthboxSpriteInvisible(gHealthBoxesIds[gActiveBank]);
LinkOpponentBufferExecCompleted();
}
@@ -485,7 +485,7 @@ static void sub_8064D60(void)
if (gSprites[gHealthBoxesIds[gActiveBank]].callback == SpriteCallbackDummy)
{
if (gBattleSpritesDataPtr->bankData[gActiveBank].behindSubstitute)
DoSpecialBattleAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_MON_TO_SUBSTITUTE);
InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_MON_TO_SUBSTITUTE);
gBattleBankFunc[gActiveBank] = sub_8064DD0;
}
@@ -1164,7 +1164,7 @@ static void LinkOpponentHandleLoadMonSprite(void)
gBankSpriteIds[gActiveBank] = CreateSprite(&gUnknown_0202499C,
sub_80A5C6C(gActiveBank, 2),
sub_80A6138(gActiveBank),
GetBankSpriteDefault_Y(gActiveBank),
sub_80A82E4(gActiveBank));
gSprites[gBankSpriteIds[gActiveBank]].pos2.x = -240;
@@ -1198,7 +1198,7 @@ static void sub_8066494(u8 bank, bool8 dontClearSubstituteBit)
gBankSpriteIds[bank] = CreateSprite(
&gUnknown_0202499C,
sub_80A5C6C(bank, 2),
sub_80A6138(bank),
GetBankSpriteDefault_Y(bank),
sub_80A82E4(bank));
gSprites[gUnknown_03005D7C[bank]].data1 = gBankSpriteIds[bank];
@@ -1227,7 +1227,7 @@ static void LinkOpponentHandleReturnMonToBall(void)
{
FreeSpriteOamMatrix(&gSprites[gBankSpriteIds[gActiveBank]]);
DestroySprite(&gSprites[gBankSpriteIds[gActiveBank]]);
sub_805EEE0(gActiveBank);
EnemyShadowCallbackToSetInvisible(gActiveBank);
SetHealthboxSpriteInvisible(gHealthBoxesIds[gActiveBank]);
LinkOpponentBufferExecCompleted();
}
@@ -1239,7 +1239,7 @@ static void DoSwitchOutAnimation(void)
{
case 0:
if (gBattleSpritesDataPtr->bankData[gActiveBank].behindSubstitute)
DoSpecialBattleAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SUBSTITUTE_TO_MON);
InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SUBSTITUTE_TO_MON);
gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 1;
break;
@@ -1247,7 +1247,7 @@ static void DoSwitchOutAnimation(void)
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].specialAnimActive)
{
gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 0;
DoSpecialBattleAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SWITCH_OUT_OPPONENT_MON);
InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SWITCH_OUT_OPPONENT_MON);
gBattleBankFunc[gActiveBank] = sub_8064C58;
}
break;
@@ -1382,7 +1382,7 @@ static void LinkOpponentHandleFaintAnimation(void)
if (gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState == 0)
{
if (gBattleSpritesDataPtr->bankData[gActiveBank].behindSubstitute)
DoSpecialBattleAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SUBSTITUTE_TO_MON);
InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SUBSTITUTE_TO_MON);
gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState++;
}
else
@@ -1455,7 +1455,7 @@ static void LinkOpponentDoMoveAnimation(void)
&& !gBattleSpritesDataPtr->bankData[gActiveBank].flag_x8)
{
gBattleSpritesDataPtr->bankData[gActiveBank].flag_x8 = 1;
DoSpecialBattleAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SUBSTITUTE_TO_MON);
InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SUBSTITUTE_TO_MON);
}
gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 1;
break;
@@ -1474,7 +1474,7 @@ static void LinkOpponentDoMoveAnimation(void)
sub_805EB9C(1);
if (gBattleSpritesDataPtr->bankData[gActiveBank].behindSubstitute && multihit < 2)
{
DoSpecialBattleAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_MON_TO_SUBSTITUTE);
InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_MON_TO_SUBSTITUTE);
gBattleSpritesDataPtr->bankData[gActiveBank].flag_x8 = 0;
}
gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 3;
@@ -1483,7 +1483,7 @@ static void LinkOpponentDoMoveAnimation(void)
case 3:
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].specialAnimActive)
{
sub_805E394();
CopyAllBattleSpritesInvisibilities();
TrySetBehindSubstituteSpriteBit(gActiveBank, gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8));
gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 0;
LinkOpponentBufferExecCompleted();
@@ -1586,7 +1586,7 @@ static void LinkOpponentHandleStatusAnimation(void)
{
if (!mplay_80342A4(gActiveBank))
{
DoStatusAnimation(gBattleBufferA[gActiveBank][1],
InitAndLaunchChosenStatusAnimation(gBattleBufferA[gActiveBank][1],
gBattleBufferA[gActiveBank][2] | (gBattleBufferA[gActiveBank][3] << 8) | (gBattleBufferA[gActiveBank][4] << 16) | (gBattleBufferA[gActiveBank][5] << 24));
gBattleBankFunc[gActiveBank] = CompleteOnFinishedStatusAnimation;
}
@@ -1698,7 +1698,7 @@ static void LinkOpponentHandlePlayFanfareOrBGM(void)
{
if (gBattleBufferA[gActiveBank][3])
{
BattleMusicStop();
BattleStopLowHpSound();
PlayBGM(gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8));
}
else
@@ -1850,7 +1850,7 @@ static void LinkOpponentHandleBattleAnimation(void)
u8 animationId = gBattleBufferA[gActiveBank][1];
u16 argument = gBattleBufferA[gActiveBank][2] | (gBattleBufferA[gActiveBank][3] << 8);
if (DoBattleAnimationFromTable(gActiveBank, gActiveBank, gActiveBank, animationId, argument))
if (TryHandleLaunchBattleTableAnimation(gActiveBank, gActiveBank, gActiveBank, animationId, argument))
LinkOpponentBufferExecCompleted();
else
gBattleBankFunc[gActiveBank] = CompleteOnFinishedBattleAnimation;

View File

@@ -36,7 +36,7 @@ extern u8 gBattleBufferA[BATTLE_BANKS_COUNT][0x200];
extern u8 gBattleBufferB[BATTLE_BANKS_COUNT][0x200];
extern struct BattlePokemon gBattleMons[BATTLE_BANKS_COUNT];
extern struct SpriteTemplate gUnknown_0202499C;
extern u16 gScriptItemId;
extern u16 gSpecialVar_ItemId;
extern u8 gHealthBoxesIds[BATTLE_BANKS_COUNT];
extern u8 gBattleOutcome;
extern u16 gBattle_BG0_X;
@@ -312,7 +312,7 @@ static void CompleteOnHealthbarDone(void)
}
else
{
sub_805E990(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank);
HandleLowHpMusicChange(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank);
LinkPartnerBufferExecCompleted();
}
}
@@ -373,7 +373,7 @@ static void sub_814B4E0(void)
{
CopyBattleSpriteInvisibility(gActiveBank);
if (gBattleSpritesDataPtr->bankData[gActiveBank].behindSubstitute)
DoSpecialBattleAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_MON_TO_SUBSTITUTE);
InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_MON_TO_SUBSTITUTE);
gBattleBankFunc[gActiveBank] = sub_814B554;
}
@@ -399,7 +399,7 @@ static void sub_814B5A8(void)
FreeSpritePaletteByTag(0x27F9);
CreateTask(c3_0802FDF4, 10);
sub_805E990(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank);
HandleLowHpMusicChange(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank);
StartSpriteAnim(&gSprites[gBankSpriteIds[gActiveBank]], 0);
UpdateHealthboxAttribute(gHealthBoxesIds[gActiveBank], &gPlayerParty[gBattlePartyID[gActiveBank]], HEALTHBOX_ALL);
sub_8076918(gActiveBank);
@@ -1026,7 +1026,7 @@ static void SetLinkPartnerMonData(u8 monId)
break;
}
sub_805E990(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank);
HandleLowHpMusicChange(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank);
}
static void LinkPartnerHandleSetRawMonData(void)
@@ -1050,7 +1050,7 @@ static void LinkPartnerHandleLoadMonSprite(void)
gBankSpriteIds[gActiveBank] = CreateSprite(&gUnknown_0202499C,
sub_80A5C6C(gActiveBank, 2),
sub_80A6138(gActiveBank),
GetBankSpriteDefault_Y(gActiveBank),
sub_80A82E4(gActiveBank));
gSprites[gBankSpriteIds[gActiveBank]].pos2.x = -240;
gSprites[gBankSpriteIds[gActiveBank]].data0 = gActiveBank;
@@ -1081,7 +1081,7 @@ static void sub_814CC98(u8 bank, bool8 dontClearSubstituteBit)
gBankSpriteIds[bank] = CreateSprite(
&gUnknown_0202499C,
sub_80A5C6C(bank, 2),
sub_80A6138(bank),
GetBankSpriteDefault_Y(bank),
sub_80A82E4(bank));
gSprites[gUnknown_03005D7C[bank]].data1 = gBankSpriteIds[bank];
@@ -1121,7 +1121,7 @@ static void DoSwitchOutAnimation(void)
{
case 0:
if (gBattleSpritesDataPtr->bankData[gActiveBank].behindSubstitute)
DoSpecialBattleAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SUBSTITUTE_TO_MON);
InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SUBSTITUTE_TO_MON);
gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 1;
break;
@@ -1129,7 +1129,7 @@ static void DoSwitchOutAnimation(void)
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].specialAnimActive)
{
gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 0;
DoSpecialBattleAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SWITCH_OUT_PLAYER_MON);
InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SWITCH_OUT_PLAYER_MON);
gBattleBankFunc[gActiveBank] = sub_814B3DC;
}
break;
@@ -1201,7 +1201,7 @@ static void LinkPartnerHandleFaintAnimation(void)
if (gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState == 0)
{
if (gBattleSpritesDataPtr->bankData[gActiveBank].behindSubstitute)
DoSpecialBattleAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SUBSTITUTE_TO_MON);
InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SUBSTITUTE_TO_MON);
gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState++;
}
else
@@ -1209,7 +1209,7 @@ static void LinkPartnerHandleFaintAnimation(void)
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].specialAnimActive)
{
gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 0;
sub_805E990(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank);
HandleLowHpMusicChange(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank);
PlaySE12WithPanning(SE_POKE_DEAD, PAN_SIDE_PLAYER);
gSprites[gBankSpriteIds[gActiveBank]].data1 = 0;
gSprites[gBankSpriteIds[gActiveBank]].data2 = 5;
@@ -1277,7 +1277,7 @@ static void LinkPartnerDoMoveAnimation(void)
&& !gBattleSpritesDataPtr->bankData[gActiveBank].flag_x8)
{
gBattleSpritesDataPtr->bankData[gActiveBank].flag_x8 = 1;
DoSpecialBattleAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SUBSTITUTE_TO_MON);
InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SUBSTITUTE_TO_MON);
}
gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 1;
break;
@@ -1296,7 +1296,7 @@ static void LinkPartnerDoMoveAnimation(void)
sub_805EB9C(1);
if (gBattleSpritesDataPtr->bankData[gActiveBank].behindSubstitute && multihit < 2)
{
DoSpecialBattleAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_MON_TO_SUBSTITUTE);
InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_MON_TO_SUBSTITUTE);
gBattleSpritesDataPtr->bankData[gActiveBank].flag_x8 = 0;
}
gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 3;
@@ -1305,7 +1305,7 @@ static void LinkPartnerDoMoveAnimation(void)
case 3:
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].specialAnimActive)
{
sub_805E394();
CopyAllBattleSpritesInvisibilities();
TrySetBehindSubstituteSpriteBit(gActiveBank, gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8));
gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 0;
LinkPartnerBufferExecCompleted();
@@ -1408,7 +1408,7 @@ static void LinkPartnerHandleStatusAnimation(void)
{
if (!mplay_80342A4(gActiveBank))
{
DoStatusAnimation(gBattleBufferA[gActiveBank][1],
InitAndLaunchChosenStatusAnimation(gBattleBufferA[gActiveBank][1],
gBattleBufferA[gActiveBank][2] | (gBattleBufferA[gActiveBank][3] << 8) | (gBattleBufferA[gActiveBank][4] << 16) | (gBattleBufferA[gActiveBank][5] << 24));
gBattleBankFunc[gActiveBank] = CompleteOnFinishedStatusAnimation;
}
@@ -1520,7 +1520,7 @@ static void LinkPartnerHandlePlayFanfareOrBGM(void)
{
if (gBattleBufferA[gActiveBank][3])
{
BattleMusicStop();
BattleStopLowHpSound();
PlayBGM(gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8));
}
else
@@ -1683,7 +1683,7 @@ static void LinkPartnerHandleBattleAnimation(void)
u8 animationId = gBattleBufferA[gActiveBank][1];
u16 argument = gBattleBufferA[gActiveBank][2] | (gBattleBufferA[gActiveBank][3] << 8);
if (DoBattleAnimationFromTable(gActiveBank, gActiveBank, gActiveBank, animationId, argument))
if (TryHandleLaunchBattleTableAnimation(gActiveBank, gActiveBank, gActiveBank, animationId, argument))
LinkPartnerBufferExecCompleted();
else
gBattleBankFunc[gActiveBank] = CompleteOnFinishedBattleAnimation;

View File

@@ -437,7 +437,7 @@ static void sub_805FB08(void)
{
FreeSpriteOamMatrix(&gSprites[gBankSpriteIds[gActiveBank]]);
DestroySprite(&gSprites[gBankSpriteIds[gActiveBank]]);
sub_805EEE0(gActiveBank);
EnemyShadowCallbackToSetInvisible(gActiveBank);
SetHealthboxSpriteInvisible(gHealthBoxesIds[gActiveBank]);
OpponentBufferExecCompleted();
}
@@ -473,7 +473,7 @@ static void sub_805FC10(void)
if (gSprites[gHealthBoxesIds[gActiveBank]].callback == SpriteCallbackDummy)
{
if (gBattleSpritesDataPtr->bankData[gActiveBank].behindSubstitute)
DoSpecialBattleAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_MON_TO_SUBSTITUTE);
InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_MON_TO_SUBSTITUTE);
gBattleBankFunc[gActiveBank] = sub_805FC80;
}
}
@@ -1152,7 +1152,7 @@ static void OpponentHandleLoadMonSprite(void)
gBankSpriteIds[gActiveBank] = CreateSprite(&gUnknown_0202499C,
sub_80A5C6C(gActiveBank, 2),
sub_80A6138(gActiveBank),
GetBankSpriteDefault_Y(gActiveBank),
sub_80A82E4(gActiveBank));
gSprites[gBankSpriteIds[gActiveBank]].pos2.x = -240;
@@ -1168,7 +1168,7 @@ static void OpponentHandleLoadMonSprite(void)
static void OpponentHandleSwitchInAnim(void)
{
*(gBattleStruct->field_5C + gActiveBank) = 6;
*(gBattleStruct->monToSwitchIntoId + gActiveBank) = 6;
gBattlePartyID[gActiveBank] = gBattleBufferA[gActiveBank][1];
sub_80613DC(gActiveBank, gBattleBufferA[gActiveBank][2]);
gBattleBankFunc[gActiveBank] = sub_805FDF0;
@@ -1187,7 +1187,7 @@ static void sub_80613DC(u8 bank, bool8 dontClearSubstituteBit)
gBankSpriteIds[bank] = CreateSprite(&gUnknown_0202499C,
sub_80A5C6C(bank, 2),
sub_80A6138(bank),
GetBankSpriteDefault_Y(bank),
sub_80A82E4(bank));
gSprites[gBankSpriteIds[bank]].data0 = bank;
@@ -1217,7 +1217,7 @@ static void OpponentHandleReturnMonToBall(void)
{
FreeSpriteOamMatrix(&gSprites[gBankSpriteIds[gActiveBank]]);
DestroySprite(&gSprites[gBankSpriteIds[gActiveBank]]);
sub_805EEE0(gActiveBank);
EnemyShadowCallbackToSetInvisible(gActiveBank);
SetHealthboxSpriteInvisible(gHealthBoxesIds[gActiveBank]);
OpponentBufferExecCompleted();
}
@@ -1229,7 +1229,7 @@ static void DoSwitchOutAnimation(void)
{
case 0:
if (gBattleSpritesDataPtr->bankData[gActiveBank].behindSubstitute)
DoSpecialBattleAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SUBSTITUTE_TO_MON);
InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SUBSTITUTE_TO_MON);
gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 1;
break;
@@ -1237,7 +1237,7 @@ static void DoSwitchOutAnimation(void)
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].specialAnimActive)
{
gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 0;
DoSpecialBattleAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SWITCH_OUT_OPPONENT_MON);
InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SWITCH_OUT_OPPONENT_MON);
gBattleBankFunc[gActiveBank] = sub_805FB08;
}
break;
@@ -1415,7 +1415,7 @@ static void OpponentHandleFaintAnimation(void)
if (gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState == 0)
{
if (gBattleSpritesDataPtr->bankData[gActiveBank].behindSubstitute)
DoSpecialBattleAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SUBSTITUTE_TO_MON);
InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SUBSTITUTE_TO_MON);
gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState++;
}
else
@@ -1487,7 +1487,7 @@ static void OpponentDoMoveAnimation(void)
&& !gBattleSpritesDataPtr->bankData[gActiveBank].flag_x8)
{
gBattleSpritesDataPtr->bankData[gActiveBank].flag_x8 = 1;
DoSpecialBattleAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SUBSTITUTE_TO_MON);
InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SUBSTITUTE_TO_MON);
}
gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 1;
break;
@@ -1506,7 +1506,7 @@ static void OpponentDoMoveAnimation(void)
sub_805EB9C(1);
if (gBattleSpritesDataPtr->bankData[gActiveBank].behindSubstitute && multihit < 2)
{
DoSpecialBattleAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_MON_TO_SUBSTITUTE);
InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_MON_TO_SUBSTITUTE);
gBattleSpritesDataPtr->bankData[gActiveBank].flag_x8 = 0;
}
gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 3;
@@ -1515,7 +1515,7 @@ static void OpponentDoMoveAnimation(void)
case 3:
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].specialAnimActive)
{
sub_805E394();
CopyAllBattleSpritesInvisibilities();
TrySetBehindSubstituteSpriteBit(gActiveBank, gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8));
gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 0;
OpponentBufferExecCompleted();
@@ -1627,7 +1627,7 @@ static void OpponentHandleChoosePokemon(void)
{
s32 chosenMonId;
if (*(gBattleStruct->field_294 + gActiveBank) == 6)
if (*(gBattleStruct->AI_monToSwitchIntoId + gActiveBank) == 6)
{
chosenMonId = GetMostSuitableMonToSwitchInto();
@@ -1670,12 +1670,12 @@ static void OpponentHandleChoosePokemon(void)
}
else
{
chosenMonId = *(gBattleStruct->field_294 + gActiveBank);
*(gBattleStruct->field_294 + gActiveBank) = 6;
chosenMonId = *(gBattleStruct->AI_monToSwitchIntoId + gActiveBank);
*(gBattleStruct->AI_monToSwitchIntoId + gActiveBank) = 6;
}
*(gBattleStruct->field_5C + gActiveBank) = chosenMonId;
*(gBattleStruct->monToSwitchIntoId + gActiveBank) = chosenMonId;
EmitChosenMonReturnValue(1, chosenMonId, NULL);
OpponentBufferExecCompleted();
}
@@ -1731,7 +1731,7 @@ static void OpponentHandleStatusAnimation(void)
{
if (!mplay_80342A4(gActiveBank))
{
DoStatusAnimation(gBattleBufferA[gActiveBank][1],
InitAndLaunchChosenStatusAnimation(gBattleBufferA[gActiveBank][1],
gBattleBufferA[gActiveBank][2] | (gBattleBufferA[gActiveBank][3] << 8) | (gBattleBufferA[gActiveBank][4] << 16) | (gBattleBufferA[gActiveBank][5] << 24));
gBattleBankFunc[gActiveBank] = CompleteOnFinishedStatusAnimation;
}
@@ -1843,7 +1843,7 @@ static void OpponentHandlePlayFanfareOrBGM(void)
{
if (gBattleBufferA[gActiveBank][3])
{
BattleMusicStop();
BattleStopLowHpSound();
PlayBGM(gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8));
}
else
@@ -2000,7 +2000,7 @@ static void OpponentHandleBattleAnimation(void)
u8 animationId = gBattleBufferA[gActiveBank][1];
u16 argument = gBattleBufferA[gActiveBank][2] | (gBattleBufferA[gActiveBank][3] << 8);
if (DoBattleAnimationFromTable(gActiveBank, gActiveBank, gActiveBank, animationId, argument))
if (TryHandleLaunchBattleTableAnimation(gActiveBank, gActiveBank, gActiveBank, animationId, argument))
OpponentBufferExecCompleted();
else
gBattleBankFunc[gActiveBank] = CompleteOnFinishedBattleAnimation;

View File

@@ -46,7 +46,7 @@ extern struct MusicPlayerInfo gMPlay_BGM;
extern u16 gPartnerTrainerId;
extern struct SpriteTemplate gUnknown_0202499C;
extern u8 gBattleMonForms[BATTLE_BANKS_COUNT];
extern u16 gScriptItemId;
extern u16 gSpecialVar_ItemId;
extern u8 gUnknown_0203CEE8;
extern u8 gUnknown_0203CEE9;
extern u8 gUnknown_0203CF00[];
@@ -1008,10 +1008,10 @@ static void sub_805896C(void)
FreeSpriteTilesByTag(0x27F9);
FreeSpritePaletteByTag(0x27F9);
sub_805E990(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank);
HandleLowHpMusicChange(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank);
if (IsDoubleBattle())
sub_805E990(&gPlayerParty[gBattlePartyID[gActiveBank ^ BIT_MON]], gActiveBank ^ BIT_MON);
HandleLowHpMusicChange(&gPlayerParty[gBattlePartyID[gActiveBank ^ BIT_MON]], gActiveBank ^ BIT_MON);
gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_9 = 3;
gBattleBankFunc[gActiveBank] = sub_8058924;
@@ -1107,7 +1107,7 @@ static void sub_8058EDC(void)
FreeSpritePaletteByTag(0x27F9);
if (gBattleSpritesDataPtr->bankData[gActiveBank].behindSubstitute)
DoSpecialBattleAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_MON_TO_SUBSTITUTE);
InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_MON_TO_SUBSTITUTE);
gBattleBankFunc[gActiveBank] = sub_8058FC0;
}
@@ -1119,7 +1119,7 @@ static void sub_8058FC0(void)
&& !IsCryPlayingOrClearCrySongs())
{
m4aMPlayVolumeControl(&gMPlay_BGM, 0xFFFF, 0x100);
sub_805E990(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank);
HandleLowHpMusicChange(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank);
PlayerBufferExecCompleted();
}
}
@@ -1164,7 +1164,7 @@ static void CompleteOnHealthbarDone(void)
}
else
{
sub_805E990(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank);
HandleLowHpMusicChange(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank);
PlayerBufferExecCompleted();
}
}
@@ -1305,7 +1305,7 @@ static void sub_8059544(u8 taskId)
if (IsDoubleBattle() == TRUE && monIndex == gBattlePartyID[bank ^ BIT_MON])
bank ^= BIT_MON;
DoSpecialBattleAnimation(bank, bank, bank, B_ANIM_LVL_UP);
InitAndLaunchSpecialAnimation(bank, bank, bank, B_ANIM_LVL_UP);
gTasks[taskId].func = sub_80595A4;
}
@@ -1416,7 +1416,7 @@ static void CompleteWhenChoseItem(void)
{
if (gMain.callback2 == BattleMainCB2 && !gPaletteFade.active)
{
EmitOneReturnValue(1, gScriptItemId);
EmitOneReturnValue(1, gSpecialVar_ItemId);
PlayerBufferExecCompleted();
}
}
@@ -2193,7 +2193,7 @@ static void SetPlayerMonData(u8 monId)
break;
}
sub_805E990(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank);
HandleLowHpMusicChange(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank);
}
static void PlayerHandleSetRawMonData(void)
@@ -2238,7 +2238,7 @@ static void sub_805B258(u8 bank, bool8 dontClearSubstituteBit)
gBankSpriteIds[bank] = CreateSprite(
&gUnknown_0202499C,
sub_80A5C6C(bank, 2),
sub_80A6138(bank),
GetBankSpriteDefault_Y(bank),
sub_80A82E4(bank));
gSprites[gUnknown_03005D7C[bank]].data1 = gBankSpriteIds[bank];
@@ -2278,7 +2278,7 @@ static void DoSwitchOutAnimation(void)
{
case 0:
if (gBattleSpritesDataPtr->bankData[gActiveBank].behindSubstitute)
DoSpecialBattleAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SUBSTITUTE_TO_MON);
InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SUBSTITUTE_TO_MON);
gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 1;
break;
@@ -2286,7 +2286,7 @@ static void DoSwitchOutAnimation(void)
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].specialAnimActive)
{
gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 0;
DoSpecialBattleAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SWITCH_OUT_PLAYER_MON);
InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SWITCH_OUT_PLAYER_MON);
gBattleBankFunc[gActiveBank] = sub_8059744;
}
break;
@@ -2434,7 +2434,7 @@ static void PlayerHandleFaintAnimation(void)
if (gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState == 0)
{
if (gBattleSpritesDataPtr->bankData[gActiveBank].behindSubstitute)
DoSpecialBattleAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SUBSTITUTE_TO_MON);
InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SUBSTITUTE_TO_MON);
gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState++;
}
else
@@ -2442,7 +2442,7 @@ static void PlayerHandleFaintAnimation(void)
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].specialAnimActive)
{
gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 0;
sub_805E990(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank);
HandleLowHpMusicChange(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank);
PlaySE12WithPanning(SE_POKE_DEAD, PAN_SIDE_PLAYER);
gSprites[gBankSpriteIds[gActiveBank]].data1 = 0;
gSprites[gBankSpriteIds[gActiveBank]].data2 = 5;
@@ -2462,7 +2462,7 @@ static void PlayerHandleSuccessBallThrowAnim(void)
{
gBattleSpritesDataPtr->animationData->ballThrowCaseId = BALL_3_SHAKES_SUCCESS;
gDoingBattleAnim = TRUE;
DoSpecialBattleAnimation(gActiveBank, gActiveBank, GetBankByIdentity(IDENTITY_OPPONENT_MON1), B_ANIM_BALL_THROW);
InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, GetBankByIdentity(IDENTITY_OPPONENT_MON1), B_ANIM_BALL_THROW);
gBattleBankFunc[gActiveBank] = CompleteOnSpecialAnimDone;
}
@@ -2472,7 +2472,7 @@ static void PlayerHandleBallThrowAnim(void)
gBattleSpritesDataPtr->animationData->ballThrowCaseId = ballThrowCaseId;
gDoingBattleAnim = TRUE;
DoSpecialBattleAnimation(gActiveBank, gActiveBank, GetBankByIdentity(IDENTITY_OPPONENT_MON1), B_ANIM_BALL_THROW);
InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, GetBankByIdentity(IDENTITY_OPPONENT_MON1), B_ANIM_BALL_THROW);
gBattleBankFunc[gActiveBank] = CompleteOnSpecialAnimDone;
}
@@ -2525,7 +2525,7 @@ static void PlayerDoMoveAnimation(void)
&& !gBattleSpritesDataPtr->bankData[gActiveBank].flag_x8)
{
gBattleSpritesDataPtr->bankData[gActiveBank].flag_x8 = 1;
DoSpecialBattleAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SUBSTITUTE_TO_MON);
InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SUBSTITUTE_TO_MON);
}
gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 1;
break;
@@ -2544,7 +2544,7 @@ static void PlayerDoMoveAnimation(void)
sub_805EB9C(1);
if (gBattleSpritesDataPtr->bankData[gActiveBank].behindSubstitute && multihit < 2)
{
DoSpecialBattleAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_MON_TO_SUBSTITUTE);
InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_MON_TO_SUBSTITUTE);
gBattleSpritesDataPtr->bankData[gActiveBank].flag_x8 = 0;
}
gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 3;
@@ -2553,7 +2553,7 @@ static void PlayerDoMoveAnimation(void)
case 3:
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].specialAnimActive)
{
sub_805E394();
CopyAllBattleSpritesInvisibilities();
TrySetBehindSubstituteSpriteBit(gActiveBank, gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8));
gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 0;
PlayerBufferExecCompleted();
@@ -2709,7 +2709,7 @@ static void PlayerHandleChoosePokemon(void)
static void PlayerHandleCmd23(void)
{
BattleMusicStop();
BattleStopLowHpSound();
BeginNormalPaletteFade(-1, 2, 0, 16, 0);
PlayerBufferExecCompleted();
}
@@ -2788,7 +2788,7 @@ static void PlayerHandleStatusAnimation(void)
{
if (!mplay_80342A4(gActiveBank))
{
DoStatusAnimation(gBattleBufferA[gActiveBank][1],
InitAndLaunchChosenStatusAnimation(gBattleBufferA[gActiveBank][1],
gBattleBufferA[gActiveBank][2] | (gBattleBufferA[gActiveBank][3] << 8) | (gBattleBufferA[gActiveBank][4] << 16) | (gBattleBufferA[gActiveBank][5] << 24));
gBattleBankFunc[gActiveBank] = CompleteOnFinishedStatusAnimation;
}
@@ -2930,7 +2930,7 @@ static void PlayerHandlePlayFanfareOrBGM(void)
{
if (gBattleBufferA[gActiveBank][3])
{
BattleMusicStop();
BattleStopLowHpSound();
PlayBGM(gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8));
}
else
@@ -3088,7 +3088,7 @@ static void PlayerHandleBattleAnimation(void)
u8 animationId = gBattleBufferA[gActiveBank][1];
u16 argument = gBattleBufferA[gActiveBank][2] | (gBattleBufferA[gActiveBank][3] << 8);
if (DoBattleAnimationFromTable(gActiveBank, gActiveBank, gActiveBank, animationId, argument))
if (TryHandleLaunchBattleTableAnimation(gActiveBank, gActiveBank, gActiveBank, animationId, argument))
PlayerBufferExecCompleted();
else
gBattleBankFunc[gActiveBank] = CompleteOnFinishedBattleAnimation;

View File

@@ -35,7 +35,7 @@ extern u8 gBattleBufferA[BATTLE_BANKS_COUNT][0x200];
extern u8 gBattleBufferB[BATTLE_BANKS_COUNT][0x200];
extern struct BattlePokemon gBattleMons[BATTLE_BANKS_COUNT];
extern struct SpriteTemplate gUnknown_0202499C;
extern u16 gScriptItemId;
extern u16 gSpecialVar_ItemId;
extern u8 gHealthBoxesIds[BATTLE_BANKS_COUNT];
extern u8 gBattleOutcome;
extern u16 gBattle_BG0_X;
@@ -327,7 +327,7 @@ static void CompleteOnHealthbarDone(void)
}
else
{
sub_805E990(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank);
HandleLowHpMusicChange(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank);
PlayerPartnerBufferExecCompleted();
}
}
@@ -469,7 +469,7 @@ static void sub_81BB628(u8 taskId)
if (IsDoubleBattle() == TRUE && monIndex == gBattlePartyID[bank ^ BIT_MON])
bank ^= BIT_MON;
DoSpecialBattleAnimation(bank, bank, bank, B_ANIM_LVL_UP);
InitAndLaunchSpecialAnimation(bank, bank, bank, B_ANIM_LVL_UP);
gTasks[taskId].func = sub_81BB688;
}
@@ -560,7 +560,7 @@ static void sub_81BB92C(void)
{
CopyBattleSpriteInvisibility(gActiveBank);
if (gBattleSpritesDataPtr->bankData[gActiveBank].behindSubstitute)
DoSpecialBattleAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_MON_TO_SUBSTITUTE);
InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_MON_TO_SUBSTITUTE);
gBattleBankFunc[gActiveBank] = sub_81BB9A0;
}
@@ -586,7 +586,7 @@ static void sub_81BB9F4(void)
FreeSpritePaletteByTag(0x27F9);
CreateTask(c3_0802FDF4, 10);
sub_805E990(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank);
HandleLowHpMusicChange(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank);
StartSpriteAnim(&gSprites[gBankSpriteIds[gActiveBank]], 0);
UpdateHealthboxAttribute(gHealthBoxesIds[gActiveBank], &gPlayerParty[gBattlePartyID[gActiveBank]], HEALTHBOX_ALL);
sub_8076918(gActiveBank);
@@ -1213,7 +1213,7 @@ static void SetPlayerPartnerMonData(u8 monId)
break;
}
sub_805E990(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank);
HandleLowHpMusicChange(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank);
}
static void PlayerPartnerHandleSetRawMonData(void)
@@ -1237,7 +1237,7 @@ static void PlayerPartnerHandleLoadMonSprite(void)
gBankSpriteIds[gActiveBank] = CreateSprite(&gUnknown_0202499C,
sub_80A5C6C(gActiveBank, 2),
sub_80A6138(gActiveBank),
GetBankSpriteDefault_Y(gActiveBank),
sub_80A82E4(gActiveBank));
gSprites[gBankSpriteIds[gActiveBank]].pos2.x = -240;
gSprites[gBankSpriteIds[gActiveBank]].data0 = gActiveBank;
@@ -1268,7 +1268,7 @@ static void sub_81BD0E4(u8 bank, bool8 dontClearSubstituteBit)
gBankSpriteIds[bank] = CreateSprite(
&gUnknown_0202499C,
sub_80A5C6C(bank, 2),
sub_80A6138(bank),
GetBankSpriteDefault_Y(bank),
sub_80A82E4(bank));
gSprites[gUnknown_03005D7C[bank]].data1 = gBankSpriteIds[bank];
@@ -1308,7 +1308,7 @@ static void DoSwitchOutAnimation(void)
{
case 0:
if (gBattleSpritesDataPtr->bankData[gActiveBank].behindSubstitute)
DoSpecialBattleAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SUBSTITUTE_TO_MON);
InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SUBSTITUTE_TO_MON);
gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 1;
break;
@@ -1316,7 +1316,7 @@ static void DoSwitchOutAnimation(void)
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].specialAnimActive)
{
gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 0;
DoSpecialBattleAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SWITCH_OUT_PLAYER_MON);
InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SWITCH_OUT_PLAYER_MON);
gBattleBankFunc[gActiveBank] = sub_81BB828;
}
break;
@@ -1395,7 +1395,7 @@ static void PlayerPartnerHandleFaintAnimation(void)
if (gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState == 0)
{
if (gBattleSpritesDataPtr->bankData[gActiveBank].behindSubstitute)
DoSpecialBattleAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SUBSTITUTE_TO_MON);
InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SUBSTITUTE_TO_MON);
gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState++;
}
else
@@ -1403,7 +1403,7 @@ static void PlayerPartnerHandleFaintAnimation(void)
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].specialAnimActive)
{
gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 0;
sub_805E990(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank);
HandleLowHpMusicChange(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank);
PlaySE12WithPanning(SE_POKE_DEAD, PAN_SIDE_PLAYER);
gSprites[gBankSpriteIds[gActiveBank]].data1 = 0;
gSprites[gBankSpriteIds[gActiveBank]].data2 = 5;
@@ -1470,7 +1470,7 @@ static void PlayerPartnerDoMoveAnimation(void)
&& !gBattleSpritesDataPtr->bankData[gActiveBank].flag_x8)
{
gBattleSpritesDataPtr->bankData[gActiveBank].flag_x8 = 1;
DoSpecialBattleAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SUBSTITUTE_TO_MON);
InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SUBSTITUTE_TO_MON);
}
gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 1;
break;
@@ -1489,7 +1489,7 @@ static void PlayerPartnerDoMoveAnimation(void)
sub_805EB9C(1);
if (gBattleSpritesDataPtr->bankData[gActiveBank].behindSubstitute && multihit < 2)
{
DoSpecialBattleAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_MON_TO_SUBSTITUTE);
InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_MON_TO_SUBSTITUTE);
gBattleSpritesDataPtr->bankData[gActiveBank].flag_x8 = 0;
}
gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 3;
@@ -1498,7 +1498,7 @@ static void PlayerPartnerDoMoveAnimation(void)
case 3:
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].specialAnimActive)
{
sub_805E394();
CopyAllBattleSpritesInvisibilities();
TrySetBehindSubstituteSpriteBit(gActiveBank, gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8));
gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 0;
PlayerPartnerBufferExecCompleted();
@@ -1581,7 +1581,7 @@ static void PlayerPartnerHandleChoosePokemon(void)
}
}
*(gBattleStruct->field_5C + gActiveBank) = chosenMonId;
*(gBattleStruct->monToSwitchIntoId + gActiveBank) = chosenMonId;
EmitChosenMonReturnValue(1, chosenMonId, NULL);
PlayerPartnerBufferExecCompleted();
}
@@ -1661,7 +1661,7 @@ static void PlayerPartnerHandleStatusAnimation(void)
{
if (!mplay_80342A4(gActiveBank))
{
DoStatusAnimation(gBattleBufferA[gActiveBank][1],
InitAndLaunchChosenStatusAnimation(gBattleBufferA[gActiveBank][1],
gBattleBufferA[gActiveBank][2] | (gBattleBufferA[gActiveBank][3] << 8) | (gBattleBufferA[gActiveBank][4] << 16) | (gBattleBufferA[gActiveBank][5] << 24));
gBattleBankFunc[gActiveBank] = CompleteOnFinishedStatusAnimation;
}
@@ -1773,7 +1773,7 @@ static void PlayerPartnerHandlePlayFanfareOrBGM(void)
{
if (gBattleBufferA[gActiveBank][3])
{
BattleMusicStop();
BattleStopLowHpSound();
PlayBGM(gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8));
}
else
@@ -1929,7 +1929,7 @@ static void PlayerPartnerHandleBattleAnimation(void)
u8 animationId = gBattleBufferA[gActiveBank][1];
u16 argument = gBattleBufferA[gActiveBank][2] | (gBattleBufferA[gActiveBank][3] << 8);
if (DoBattleAnimationFromTable(gActiveBank, gActiveBank, gActiveBank, animationId, argument))
if (TryHandleLaunchBattleTableAnimation(gActiveBank, gActiveBank, gActiveBank, animationId, argument))
PlayerPartnerBufferExecCompleted();
else
gBattleBankFunc[gActiveBank] = CompleteOnFinishedBattleAnimation;

View File

@@ -37,7 +37,7 @@ extern u8 gBattleBufferA[BATTLE_BANKS_COUNT][0x200];
extern u8 gBattleBufferB[BATTLE_BANKS_COUNT][0x200];
extern struct BattlePokemon gBattleMons[BATTLE_BANKS_COUNT];
extern struct SpriteTemplate gUnknown_0202499C;
extern u16 gScriptItemId;
extern u16 gSpecialVar_ItemId;
extern u8 gHealthBoxesIds[BATTLE_BANKS_COUNT];
extern u8 gBattleOutcome;
extern u16 gBattle_BG0_X;
@@ -433,7 +433,7 @@ static void sub_8186D9C(void)
{
FreeSpriteOamMatrix(&gSprites[gBankSpriteIds[gActiveBank]]);
DestroySprite(&gSprites[gBankSpriteIds[gActiveBank]]);
sub_805EEE0(gActiveBank);
EnemyShadowCallbackToSetInvisible(gActiveBank);
SetHealthboxSpriteInvisible(gHealthBoxesIds[gActiveBank]);
RecordedOpponentBufferExecCompleted();
}
@@ -469,7 +469,7 @@ static void sub_8186EA4(void)
if (gSprites[gHealthBoxesIds[gActiveBank]].callback == SpriteCallbackDummy)
{
if (gBattleSpritesDataPtr->bankData[gActiveBank].behindSubstitute)
DoSpecialBattleAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_MON_TO_SUBSTITUTE);
InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_MON_TO_SUBSTITUTE);
gBattleBankFunc[gActiveBank] = sub_8186F14;
}
@@ -1149,7 +1149,7 @@ static void RecordedOpponentHandleLoadMonSprite(void)
gBankSpriteIds[gActiveBank] = CreateSprite(&gUnknown_0202499C,
sub_80A5C6C(gActiveBank, 2),
sub_80A6138(gActiveBank),
GetBankSpriteDefault_Y(gActiveBank),
sub_80A82E4(gActiveBank));
@@ -1184,7 +1184,7 @@ static void sub_81885D8(u8 bank, bool8 dontClearSubstituteBit)
gBankSpriteIds[bank] = CreateSprite(&gUnknown_0202499C,
sub_80A5C6C(bank, 2),
sub_80A6138(bank),
GetBankSpriteDefault_Y(bank),
sub_80A82E4(bank));
gSprites[gUnknown_03005D7C[bank]].data1 = gBankSpriteIds[bank];
@@ -1213,7 +1213,7 @@ static void RecordedOpponentHandleReturnMonToBall(void)
{
FreeSpriteOamMatrix(&gSprites[gBankSpriteIds[gActiveBank]]);
DestroySprite(&gSprites[gBankSpriteIds[gActiveBank]]);
sub_805EEE0(gActiveBank);
EnemyShadowCallbackToSetInvisible(gActiveBank);
SetHealthboxSpriteInvisible(gHealthBoxesIds[gActiveBank]);
RecordedOpponentBufferExecCompleted();
}
@@ -1225,7 +1225,7 @@ static void DoSwitchOutAnimation(void)
{
case 0:
if (gBattleSpritesDataPtr->bankData[gActiveBank].behindSubstitute)
DoSpecialBattleAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SUBSTITUTE_TO_MON);
InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SUBSTITUTE_TO_MON);
gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 1;
break;
@@ -1233,7 +1233,7 @@ static void DoSwitchOutAnimation(void)
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].specialAnimActive)
{
gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 0;
DoSpecialBattleAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SWITCH_OUT_OPPONENT_MON);
InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SWITCH_OUT_OPPONENT_MON);
gBattleBankFunc[gActiveBank] = sub_8186D9C;
}
break;
@@ -1314,7 +1314,7 @@ static void RecordedOpponentHandleFaintAnimation(void)
if (gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState == 0)
{
if (gBattleSpritesDataPtr->bankData[gActiveBank].behindSubstitute)
DoSpecialBattleAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SUBSTITUTE_TO_MON);
InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SUBSTITUTE_TO_MON);
gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState++;
}
else
@@ -1386,7 +1386,7 @@ static void RecordedOpponentDoMoveAnimation(void)
&& !gBattleSpritesDataPtr->bankData[gActiveBank].flag_x8)
{
gBattleSpritesDataPtr->bankData[gActiveBank].flag_x8 = 1;
DoSpecialBattleAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SUBSTITUTE_TO_MON);
InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SUBSTITUTE_TO_MON);
}
gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 1;
break;
@@ -1405,7 +1405,7 @@ static void RecordedOpponentDoMoveAnimation(void)
sub_805EB9C(1);
if (gBattleSpritesDataPtr->bankData[gActiveBank].behindSubstitute && multihit < 2)
{
DoSpecialBattleAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_MON_TO_SUBSTITUTE);
InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_MON_TO_SUBSTITUTE);
gBattleSpritesDataPtr->bankData[gActiveBank].flag_x8 = 0;
}
gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 3;
@@ -1414,7 +1414,7 @@ static void RecordedOpponentDoMoveAnimation(void)
case 3:
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].specialAnimActive)
{
sub_805E394();
CopyAllBattleSpritesInvisibilities();
TrySetBehindSubstituteSpriteBit(gActiveBank, gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8));
gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 0;
RecordedOpponentBufferExecCompleted();
@@ -1474,8 +1474,8 @@ static void RecordedOpponentHandleChooseItem(void)
static void RecordedOpponentHandleChoosePokemon(void)
{
*(gBattleStruct->field_5C + gActiveBank) = RecordedBattle_ReadBankAction(gActiveBank);
EmitChosenMonReturnValue(1, *(gBattleStruct->field_5C + gActiveBank), NULL);
*(gBattleStruct->monToSwitchIntoId + gActiveBank) = RecordedBattle_ReadBankAction(gActiveBank);
EmitChosenMonReturnValue(1, *(gBattleStruct->monToSwitchIntoId + gActiveBank), NULL);
RecordedOpponentBufferExecCompleted();
}
@@ -1530,7 +1530,7 @@ static void RecordedOpponentHandleStatusAnimation(void)
{
if (!mplay_80342A4(gActiveBank))
{
DoStatusAnimation(gBattleBufferA[gActiveBank][1],
InitAndLaunchChosenStatusAnimation(gBattleBufferA[gActiveBank][1],
gBattleBufferA[gActiveBank][2] | (gBattleBufferA[gActiveBank][3] << 8) | (gBattleBufferA[gActiveBank][4] << 16) | (gBattleBufferA[gActiveBank][5] << 24));
gBattleBankFunc[gActiveBank] = CompleteOnFinishedStatusAnimation;
}
@@ -1642,7 +1642,7 @@ static void RecordedOpponentHandlePlayFanfareOrBGM(void)
{
if (gBattleBufferA[gActiveBank][3])
{
BattleMusicStop();
BattleStopLowHpSound();
PlayBGM(gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8));
}
else
@@ -1794,7 +1794,7 @@ static void RecordedOpponentHandleBattleAnimation(void)
u8 animationId = gBattleBufferA[gActiveBank][1];
u16 argument = gBattleBufferA[gActiveBank][2] | (gBattleBufferA[gActiveBank][3] << 8);
if (DoBattleAnimationFromTable(gActiveBank, gActiveBank, gActiveBank, animationId, argument))
if (TryHandleLaunchBattleTableAnimation(gActiveBank, gActiveBank, gActiveBank, animationId, argument))
RecordedOpponentBufferExecCompleted();
else
gBattleBankFunc[gActiveBank] = CompleteOnFinishedBattleAnimation;

View File

@@ -36,7 +36,7 @@ extern u8 gBattleBufferA[BATTLE_BANKS_COUNT][0x200];
extern u8 gBattleBufferB[BATTLE_BANKS_COUNT][0x200];
extern struct BattlePokemon gBattleMons[BATTLE_BANKS_COUNT];
extern struct SpriteTemplate gUnknown_0202499C;
extern u16 gScriptItemId;
extern u16 gSpecialVar_ItemId;
extern u8 gHealthBoxesIds[BATTLE_BANKS_COUNT];
extern u8 gBattleOutcome;
extern u16 gBattle_BG0_X;
@@ -272,9 +272,9 @@ static void sub_8189AA0(void)
FreeSpriteTilesByTag(0x27F9);
FreeSpritePaletteByTag(0x27F9);
sub_805E990(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank);
HandleLowHpMusicChange(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank);
if (IsDoubleBattle())
sub_805E990(&gPlayerParty[gBattlePartyID[gActiveBank ^ BIT_MON]], gActiveBank ^ BIT_MON);
HandleLowHpMusicChange(&gPlayerParty[gBattlePartyID[gActiveBank ^ BIT_MON]], gActiveBank ^ BIT_MON);
gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_9 = 3;
gBattleBankFunc[gActiveBank] = sub_8189A58;
@@ -397,7 +397,7 @@ static void CompleteOnHealthbarDone(void)
}
else
{
sub_805E990(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank);
HandleLowHpMusicChange(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank);
RecordedPlayerBufferExecCompleted();
}
}
@@ -458,7 +458,7 @@ static void sub_818A2B4(void)
{
CopyBattleSpriteInvisibility(gActiveBank);
if (gBattleSpritesDataPtr->bankData[gActiveBank].behindSubstitute)
DoSpecialBattleAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_MON_TO_SUBSTITUTE);
InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_MON_TO_SUBSTITUTE);
gBattleBankFunc[gActiveBank] = sub_818A328;
}
@@ -484,7 +484,7 @@ static void sub_818A37C(void)
FreeSpritePaletteByTag(0x27F9);
CreateTask(c3_0802FDF4, 10);
sub_805E990(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank);
HandleLowHpMusicChange(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank);
StartSpriteAnim(&gSprites[gBankSpriteIds[gActiveBank]], 0);
UpdateHealthboxAttribute(gHealthBoxesIds[gActiveBank], &gPlayerParty[gBattlePartyID[gActiveBank]], HEALTHBOX_ALL);
sub_8076918(gActiveBank);
@@ -1111,7 +1111,7 @@ static void SetRecordedPlayerMonData(u8 monId)
break;
}
sub_805E990(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank);
HandleLowHpMusicChange(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank);
}
static void RecordedPlayerHandleSetRawMonData(void)
@@ -1135,7 +1135,7 @@ static void RecordedPlayerHandleLoadMonSprite(void)
gBankSpriteIds[gActiveBank] = CreateSprite(&gUnknown_0202499C,
sub_80A5C6C(gActiveBank, 2),
sub_80A6138(gActiveBank),
GetBankSpriteDefault_Y(gActiveBank),
sub_80A82E4(gActiveBank));
gSprites[gBankSpriteIds[gActiveBank]].pos2.x = -240;
gSprites[gBankSpriteIds[gActiveBank]].data0 = gActiveBank;
@@ -1166,7 +1166,7 @@ static void sub_818BA6C(u8 bank, bool8 dontClearSubstituteBit)
gBankSpriteIds[bank] = CreateSprite(
&gUnknown_0202499C,
sub_80A5C6C(bank, 2),
sub_80A6138(bank),
GetBankSpriteDefault_Y(bank),
sub_80A82E4(bank));
gSprites[gUnknown_03005D7C[bank]].data1 = gBankSpriteIds[bank];
@@ -1206,7 +1206,7 @@ static void DoSwitchOutAnimation(void)
{
case 0:
if (gBattleSpritesDataPtr->bankData[gActiveBank].behindSubstitute)
DoSpecialBattleAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SUBSTITUTE_TO_MON);
InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SUBSTITUTE_TO_MON);
gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 1;
break;
@@ -1214,7 +1214,7 @@ static void DoSwitchOutAnimation(void)
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].specialAnimActive)
{
gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 0;
DoSpecialBattleAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SWITCH_OUT_PLAYER_MON);
InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SWITCH_OUT_PLAYER_MON);
gBattleBankFunc[gActiveBank] = sub_818A1B0;
}
break;
@@ -1313,7 +1313,7 @@ static void RecordedPlayerHandleFaintAnimation(void)
if (gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState == 0)
{
if (gBattleSpritesDataPtr->bankData[gActiveBank].behindSubstitute)
DoSpecialBattleAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SUBSTITUTE_TO_MON);
InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SUBSTITUTE_TO_MON);
gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState++;
}
else
@@ -1321,7 +1321,7 @@ static void RecordedPlayerHandleFaintAnimation(void)
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].specialAnimActive)
{
gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 0;
sub_805E990(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank);
HandleLowHpMusicChange(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank);
PlaySE12WithPanning(SE_POKE_DEAD, -64);
gSprites[gBankSpriteIds[gActiveBank]].data1 = 0;
gSprites[gBankSpriteIds[gActiveBank]].data2 = 5;
@@ -1388,7 +1388,7 @@ static void RecordedPlayerDoMoveAnimation(void)
&& !gBattleSpritesDataPtr->bankData[gActiveBank].flag_x8)
{
gBattleSpritesDataPtr->bankData[gActiveBank].flag_x8 = 1;
DoSpecialBattleAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SUBSTITUTE_TO_MON);
InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SUBSTITUTE_TO_MON);
}
gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 1;
break;
@@ -1407,7 +1407,7 @@ static void RecordedPlayerDoMoveAnimation(void)
sub_805EB9C(1);
if (gBattleSpritesDataPtr->bankData[gActiveBank].behindSubstitute && multihit < 2)
{
DoSpecialBattleAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_MON_TO_SUBSTITUTE);
InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_MON_TO_SUBSTITUTE);
gBattleSpritesDataPtr->bankData[gActiveBank].flag_x8 = 0;
}
gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 3;
@@ -1416,7 +1416,7 @@ static void RecordedPlayerDoMoveAnimation(void)
case 3:
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].specialAnimActive)
{
sub_805E394();
CopyAllBattleSpritesInvisibilities();
TrySetBehindSubstituteSpriteBit(gActiveBank, gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8));
gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 0;
RecordedPlayerBufferExecCompleted();
@@ -1492,8 +1492,8 @@ static void RecordedPlayerHandleChooseItem(void)
static void RecordedPlayerHandleChoosePokemon(void)
{
*(gBattleStruct->field_5C + gActiveBank) = RecordedBattle_ReadBankAction(gActiveBank);
EmitChosenMonReturnValue(1, *(gBattleStruct->field_5C + gActiveBank), NULL);
*(gBattleStruct->monToSwitchIntoId + gActiveBank) = RecordedBattle_ReadBankAction(gActiveBank);
EmitChosenMonReturnValue(1, *(gBattleStruct->monToSwitchIntoId + gActiveBank), NULL);
RecordedPlayerBufferExecCompleted();
}
@@ -1549,7 +1549,7 @@ static void RecordedPlayerHandleStatusAnimation(void)
{
if (!mplay_80342A4(gActiveBank))
{
DoStatusAnimation(gBattleBufferA[gActiveBank][1],
InitAndLaunchChosenStatusAnimation(gBattleBufferA[gActiveBank][1],
gBattleBufferA[gActiveBank][2] | (gBattleBufferA[gActiveBank][3] << 8) | (gBattleBufferA[gActiveBank][4] << 16) | (gBattleBufferA[gActiveBank][5] << 24));
gBattleBankFunc[gActiveBank] = CompleteOnFinishedStatusAnimation;
}
@@ -1661,7 +1661,7 @@ static void RecordedPlayerHandlePlayFanfareOrBGM(void)
{
if (gBattleBufferA[gActiveBank][3])
{
BattleMusicStop();
BattleStopLowHpSound();
PlayBGM(gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8));
}
else
@@ -1813,7 +1813,7 @@ static void RecordedPlayerHandleBattleAnimation(void)
u8 animationId = gBattleBufferA[gActiveBank][1];
u16 argument = gBattleBufferA[gActiveBank][2] | (gBattleBufferA[gActiveBank][3] << 8);
if (DoBattleAnimationFromTable(gActiveBank, gActiveBank, gActiveBank, animationId, argument))
if (TryHandleLaunchBattleTableAnimation(gActiveBank, gActiveBank, gActiveBank, animationId, argument))
RecordedPlayerBufferExecCompleted();
else
gBattleBankFunc[gActiveBank] = CompleteOnFinishedBattleAnimation;

View File

@@ -33,7 +33,7 @@ extern u8 gBattleBufferA[BATTLE_BANKS_COUNT][0x200];
extern u8 gBattleBufferB[BATTLE_BANKS_COUNT][0x200];
extern struct BattlePokemon gBattleMons[BATTLE_BANKS_COUNT];
extern struct SpriteTemplate gUnknown_0202499C;
extern u16 gScriptItemId;
extern u16 gSpecialVar_ItemId;
extern u8 gHealthBoxesIds[BATTLE_BANKS_COUNT];
extern u8 gBattleOutcome;
extern u16 gBattle_BG0_X;
@@ -305,7 +305,7 @@ static void CompleteWhenChosePokeblock(void)
{
if (gMain.callback2 == BattleMainCB2 && !gPaletteFade.active)
{
EmitOneReturnValue(1, gScriptItemId);
EmitOneReturnValue(1, gSpecialVar_ItemId);
SafariBufferExecCompleted();
}
}
@@ -413,7 +413,7 @@ static void SafariHandleSuccessBallThrowAnim(void)
{
gBattleSpritesDataPtr->animationData->ballThrowCaseId = BALL_3_SHAKES_SUCCESS;
gDoingBattleAnim = TRUE;
DoSpecialBattleAnimation(gActiveBank, gActiveBank, GetBankByIdentity(IDENTITY_OPPONENT_MON1), B_ANIM_SAFARI_BALL_THROW);
InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, GetBankByIdentity(IDENTITY_OPPONENT_MON1), B_ANIM_SAFARI_BALL_THROW);
gBattleBankFunc[gActiveBank] = CompleteOnSpecialAnimDone;
}
@@ -423,7 +423,7 @@ static void SafariHandleBallThrowAnim(void)
gBattleSpritesDataPtr->animationData->ballThrowCaseId = ballThrowCaseId;
gDoingBattleAnim = TRUE;
DoSpecialBattleAnimation(gActiveBank, gActiveBank, GetBankByIdentity(IDENTITY_OPPONENT_MON1), B_ANIM_SAFARI_BALL_THROW);
InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, GetBankByIdentity(IDENTITY_OPPONENT_MON1), B_ANIM_SAFARI_BALL_THROW);
gBattleBankFunc[gActiveBank] = CompleteOnSpecialAnimDone;
}
@@ -624,7 +624,7 @@ static void SafariHandlePlayFanfareOrBGM(void)
{
if (gBattleBufferA[gActiveBank][3])
{
BattleMusicStop();
BattleStopLowHpSound();
PlayBGM(gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8));
}
else
@@ -683,7 +683,7 @@ static void SafariHandleBattleAnimation(void)
u8 animationId = gBattleBufferA[gActiveBank][1];
u16 argument = gBattleBufferA[gActiveBank][2] | (gBattleBufferA[gActiveBank][3] << 8);
if (DoBattleAnimationFromTable(gActiveBank, gActiveBank, gActiveBank, animationId, argument))
if (TryHandleLaunchBattleTableAnimation(gActiveBank, gActiveBank, gActiveBank, animationId, argument))
SafariBufferExecCompleted();
else
gBattleBankFunc[gActiveBank] = CompleteOnFinishedBattleAnimation;

View File

@@ -45,7 +45,7 @@ extern struct MusicPlayerInfo gMPlay_BGM;
extern u16 gPartnerTrainerId;
extern struct SpriteTemplate gUnknown_0202499C;
extern u8 gBattleMonForms[BATTLE_BANKS_COUNT];
extern u16 gScriptItemId;
extern u16 gSpecialVar_ItemId;
extern u8 gUnknown_03005D7C[BATTLE_BANKS_COUNT];
extern u8 gHealthBoxesIds[BATTLE_BANKS_COUNT];
extern u8 gBattleOutcome;
@@ -314,7 +314,7 @@ static void CompleteOnChosenItem(void)
{
if (gMain.callback2 == BattleMainCB2 && !gPaletteFade.active)
{
EmitOneReturnValue(1, gScriptItemId);
EmitOneReturnValue(1, gSpecialVar_ItemId);
WallyBufferExecCompleted();
}
}
@@ -369,7 +369,7 @@ static void sub_8168818(void)
FreeSpritePaletteByTag(0x27F9);
CreateTask(c3_0802FDF4, 10);
sub_805E990(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank);
HandleLowHpMusicChange(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank);
WallyBufferExecCompleted();
}
@@ -387,7 +387,7 @@ static void CompleteOnHealthbarDone(void)
}
else
{
sub_805E990(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank);
HandleLowHpMusicChange(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank);
WallyBufferExecCompleted();
}
}
@@ -1029,7 +1029,7 @@ static void SetWallyMonData(u8 monId)
break;
}
sub_805E990(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank);
HandleLowHpMusicChange(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank);
}
static void WallyHandleSetRawMonData(void)
@@ -1051,7 +1051,7 @@ static void WallyHandleReturnMonToBall(void)
{
if (gBattleBufferA[gActiveBank][1] == 0)
{
DoSpecialBattleAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SWITCH_OUT_PLAYER_MON);
InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SWITCH_OUT_PLAYER_MON);
gBattleBankFunc[gActiveBank] = sub_8168A20;
}
else
@@ -1112,7 +1112,7 @@ static void WallyHandleSuccessBallThrowAnim(void)
{
gBattleSpritesDataPtr->animationData->ballThrowCaseId = BALL_3_SHAKES_SUCCESS;
gDoingBattleAnim = TRUE;
DoSpecialBattleAnimation(gActiveBank, gActiveBank, GetBankByIdentity(IDENTITY_OPPONENT_MON1), B_ANIM_SAFARI_BALL_THROW);
InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, GetBankByIdentity(IDENTITY_OPPONENT_MON1), B_ANIM_SAFARI_BALL_THROW);
gBattleBankFunc[gActiveBank] = CompleteOnFinishedAnimation;
}
@@ -1122,7 +1122,7 @@ static void WallyHandleBallThrowAnim(void)
gBattleSpritesDataPtr->animationData->ballThrowCaseId = ballThrowCaseId;
gDoingBattleAnim = TRUE;
DoSpecialBattleAnimation(gActiveBank, gActiveBank, GetBankByIdentity(IDENTITY_OPPONENT_MON1), B_ANIM_SAFARI_BALL_THROW);
InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, GetBankByIdentity(IDENTITY_OPPONENT_MON1), B_ANIM_SAFARI_BALL_THROW);
gBattleBankFunc[gActiveBank] = CompleteOnFinishedAnimation;
}
@@ -1163,7 +1163,7 @@ static void WallyDoMoveAnimation(void)
case 0:
if (gBattleSpritesDataPtr->bankData[gActiveBank].behindSubstitute)
{
DoSpecialBattleAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SUBSTITUTE_TO_MON);
InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SUBSTITUTE_TO_MON);
}
gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 1;
break;
@@ -1182,7 +1182,7 @@ static void WallyDoMoveAnimation(void)
sub_805EB9C(1);
if (gBattleSpritesDataPtr->bankData[gActiveBank].behindSubstitute)
{
DoSpecialBattleAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_MON_TO_SUBSTITUTE);
InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_MON_TO_SUBSTITUTE);
}
gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 3;
}
@@ -1190,7 +1190,7 @@ static void WallyDoMoveAnimation(void)
case 3:
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].specialAnimActive)
{
sub_805E394();
CopyAllBattleSpritesInvisibilities();
TrySetBehindSubstituteSpriteBit(gActiveBank, gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8));
gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 0;
WallyBufferExecCompleted();
@@ -1429,7 +1429,7 @@ static void WallyHandlePlayFanfareOrBGM(void)
{
if (gBattleBufferA[gActiveBank][3])
{
BattleMusicStop();
BattleStopLowHpSound();
PlayBGM(gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8));
}
else
@@ -1496,7 +1496,7 @@ static void sub_816AA80(u8 bank)
sub_806A068(species, GetBankIdentity(bank));
gBankSpriteIds[bank] = CreateSprite(&gUnknown_0202499C,
sub_80A5C6C(bank, 2),
sub_80A6138(bank),
GetBankSpriteDefault_Y(bank),
sub_80A82E4(bank));
gSprites[gUnknown_03005D7C[bank]].data1 = gBankSpriteIds[bank];
@@ -1565,7 +1565,7 @@ static void WallyHandleBattleAnimation(void)
u8 animationId = gBattleBufferA[gActiveBank][1];
u16 argument = gBattleBufferA[gActiveBank][2] | (gBattleBufferA[gActiveBank][3] << 8);
if (DoBattleAnimationFromTable(gActiveBank, gActiveBank, gActiveBank, animationId, argument))
if (TryHandleLaunchBattleTableAnimation(gActiveBank, gActiveBank, gActiveBank, animationId, argument))
WallyBufferExecCompleted();
else
gBattleBankFunc[gActiveBank] = CompleteOnFinishedBattleAnimation;

View File

@@ -119,7 +119,7 @@ static void sub_818D0C4(u16 species, u32 otId, u32 personality, u8 paletteSlot,
if (paletteTag == 0xFFFF)
{
gUnknown_0203CCEC.paletteTag |= 0xFFFF;
LoadCompressedPalette(species_and_otid_get_pal(species, otId, personality), 0x100 + paletteSlot * 0x10, 0x20);
LoadCompressedPalette(GetFrontSpritePalFromSpeciesAndPersonality(species, otId, personality), 0x100 + paletteSlot * 0x10, 0x20);
}
else
{
@@ -146,7 +146,7 @@ static void sub_818D180(u16 species, u32 otId, u32 personality, u8 paletteSlot,
{
if (!isTrainer)
{
LoadCompressedPalette(species_and_otid_get_pal(species, otId, personality), paletteSlot * 0x10, 0x20);
LoadCompressedPalette(GetFrontSpritePalFromSpeciesAndPersonality(species, otId, personality), paletteSlot * 0x10, 0x20);
}
else
{

1299
src/battle_gfx_sfx_util.c Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -1239,11 +1239,11 @@ void UpdateHpTextInHealthbox(u8 healthboxSpriteId, s16 value, u8 maxOrCurrent)
}
ConvertIntToDecimalStringN(text + 6, value, STR_CONV_MODE_RIGHT_ALIGN, 3);
RenderTextFont9(gMonSpritesGfxPtr->fontPixels, 9, text);
RenderTextFont9(gMonSpritesGfxPtr->barFontGfx, 9, text);
for (i = 0; i < 3; i++)
{
CpuCopy32(&gMonSpritesGfxPtr->fontPixels[i * 64 + 32],
CpuCopy32(&gMonSpritesGfxPtr->barFontGfx[i * 64 + 32],
(void*)((OBJ_VRAM0) + 32 * (gSprites[healthboxSpriteId].oam.tileNum + var + i)),
0x20);
}
@@ -1308,19 +1308,19 @@ static void UpdateHpTextInHealthboxInDoubles(u8 healthboxSpriteId, s16 value, u8
txtPtr = ConvertIntToDecimalStringN(text + 6, value, STR_CONV_MODE_RIGHT_ALIGN, 3);
if (!maxOrCurrent)
StringCopy(txtPtr, gText_Slash);
RenderTextFont9(gMonSpritesGfxPtr->fontPixels, 9, text);
RenderTextFont9(gMonSpritesGfxPtr->barFontGfx, 9, text);
for (i = var; i < var + 3; i++)
{
if (i < 3)
{
CpuCopy32(&gMonSpritesGfxPtr->fontPixels[((i - var) * 64) + 32],
CpuCopy32(&gMonSpritesGfxPtr->barFontGfx[((i - var) * 64) + 32],
(void*)((OBJ_VRAM0) + 32 * (1 + gSprites[r7].oam.tileNum + i)),
0x20);
}
else
{
CpuCopy32(&gMonSpritesGfxPtr->fontPixels[((i - var) * 64) + 32],
CpuCopy32(&gMonSpritesGfxPtr->barFontGfx[((i - var) * 64) + 32],
(void*)((OBJ_VRAM0 + 0x20) + 32 * (i + gSprites[r7].oam.tileNum)),
0x20);
}
@@ -1328,7 +1328,7 @@ static void UpdateHpTextInHealthboxInDoubles(u8 healthboxSpriteId, s16 value, u8
if (maxOrCurrent == HP_CURRENT)
{
CpuCopy32(&gMonSpritesGfxPtr->fontPixels[224],
CpuCopy32(&gMonSpritesGfxPtr->barFontGfx[224],
(void*)((OBJ_VRAM0) + ((gSprites[r7].oam.tileNum + 4) * 32)),
0x20);
CpuFill32(0, (void*)((OBJ_VRAM0) + (gSprites[r7].oam.tileNum * 32)), 0x20);
@@ -1350,15 +1350,15 @@ static void sub_80730D4(u8 healthboxSpriteId, struct Pokemon *mon)
{
u8 text[20];
s32 j, var2;
u8 *fontPixels;
u8 *barFontGfx;
u8 i, var, nature, healthboxSpriteId_2;
memcpy(text, sUnknown_0832C3C4, sizeof(sUnknown_0832C3C4));
fontPixels = &gMonSpritesGfxPtr->fontPixels[0x520 + (GetBankIdentity(gSprites[healthboxSpriteId].data6) * 384)];
barFontGfx = &gMonSpritesGfxPtr->barFontGfx[0x520 + (GetBankIdentity(gSprites[healthboxSpriteId].data6) * 384)];
var = 5;
nature = GetNature(mon);
StringCopy(text + 6, gNatureNamePointers[nature]);
RenderTextFont9(fontPixels, 9, text);
RenderTextFont9(barFontGfx, 9, text);
for (j = 6, i = 0; i < var; i++, j++)
{
@@ -1371,18 +1371,18 @@ static void sub_80730D4(u8 healthboxSpriteId, struct Pokemon *mon)
else
elementId = 43;
CpuCopy32(GetHealthboxElementGfxPtr(elementId), fontPixels + (i * 64), 0x20);
CpuCopy32(GetHealthboxElementGfxPtr(elementId), barFontGfx + (i * 64), 0x20);
}
for (j = 1; j < var + 1; j++)
{
var2 = (gSprites[healthboxSpriteId].oam.tileNum + (j - (j / 8 * 8)) + (j / 8 * 64)) * 32;
CpuCopy32(fontPixels, (void*)(OBJ_VRAM0) + (var2), 0x20);
fontPixels += 0x20;
CpuCopy32(barFontGfx, (void*)(OBJ_VRAM0) + (var2), 0x20);
barFontGfx += 0x20;
var2 = (8 + gSprites[healthboxSpriteId].oam.tileNum + (j - (j / 8 * 8)) + (j / 8 * 64)) * 32;
CpuCopy32(fontPixels, (void*)(OBJ_VRAM0) + (var2), 0x20);
fontPixels += 0x20;
CpuCopy32(barFontGfx, (void*)(OBJ_VRAM0) + (var2), 0x20);
barFontGfx += 0x20;
}
healthboxSpriteId_2 = gSprites[healthboxSpriteId].data5;
@@ -1390,20 +1390,20 @@ static void sub_80730D4(u8 healthboxSpriteId, struct Pokemon *mon)
ConvertIntToDecimalStringN(text + 9, gBattleStruct->field_7B, STR_CONV_MODE_RIGHT_ALIGN, 2);
text[5] = CHAR_SPACE;
text[8] = CHAR_SLASH;
RenderTextFont9(gMonSpritesGfxPtr->fontPixels, 9, text);
RenderTextFont9(gMonSpritesGfxPtr->barFontGfx, 9, text);
j = healthboxSpriteId_2; // needed to match for some reason
for (j = 0; j < 5; j++)
{
if (j <= 1)
{
CpuCopy32(&gMonSpritesGfxPtr->fontPixels[0x40 * j + 0x20],
CpuCopy32(&gMonSpritesGfxPtr->barFontGfx[0x40 * j + 0x20],
(void*)(OBJ_VRAM0) + (gSprites[healthboxSpriteId_2].oam.tileNum + 2 + j) * 32,
32);
}
else
{
CpuCopy32(&gMonSpritesGfxPtr->fontPixels[0x40 * j + 0x20],
CpuCopy32(&gMonSpritesGfxPtr->barFontGfx[0x40 * j + 0x20],
(void*)(OBJ_VRAM0 + 0xC0) + (j + gSprites[healthboxSpriteId_2].oam.tileNum) * 32,
32);
}
@@ -2545,19 +2545,19 @@ u8 GetHPBarLevel(s16 hp, s16 maxhp)
if (hp == maxhp)
{
result = 4;
result = HP_BAR_FULL;
}
else
{
u8 fraction = GetScaledHPFraction(hp, maxhp, 48);
if (fraction > 24)
result = 3;
result = HP_BAR_GREEN;
else if (fraction > 9)
result = 2;
result = HP_BAR_YELLOW;
else if (fraction > 0)
result = 1;
result = HP_BAR_RED;
else
result = 0;
result = HP_BAR_EMPTY;
}
return result;

View File

@@ -1907,7 +1907,7 @@ u32 BattleStringExpandPlaceholders(const u8* src, u8* dst)
HANDLE_NICKNAME_STRING_CASE(gBattleScripting.bank, *(&gBattleStruct->field_52))
break;
case B_TXT_PC_CREATOR_NAME: // lanette pc
if (FlagGet(SYS_PC_LANETTE))
if (FlagGet(FLAG_SYS_PC_LANETTE))
toCpy = gText_Lanettes;
else
toCpy = gText_Someones;

File diff suppressed because it is too large Load Diff

View File

@@ -1292,9 +1292,9 @@ bool8 sub_8041364(void)
gBattleTextBuff1[1] = 1;
gBattleTextBuff1[2] = 1;
gBattleTextBuff1[3] = 1;
gBattleTextBuff1[4] = gDisableStructs[gActiveBank].perishSong1;
gBattleTextBuff1[4] = gDisableStructs[gActiveBank].perishSongTimer1;
gBattleTextBuff1[5] = EOS;
if (gDisableStructs[gActiveBank].perishSong1 == 0)
if (gDisableStructs[gActiveBank].perishSongTimer1 == 0)
{
gStatuses3[gActiveBank] &= ~STATUS3_PERISH_SONG;
gBattleMoveDamage = gBattleMons[gActiveBank].hp;
@@ -1302,7 +1302,7 @@ bool8 sub_8041364(void)
}
else
{
gDisableStructs[gActiveBank].perishSong1--;
gDisableStructs[gActiveBank].perishSongTimer1--;
gBattlescriptCurrInstr = gUnknown_082DAF20;
}
BattleScriptExecute(gBattlescriptCurrInstr);
@@ -1805,7 +1805,7 @@ bool8 sub_80423F4(u8 bank, u8 r1, u8 r2)
&& GetMonData(&party[i], MON_DATA_SPECIES2) != 0
&& GetMonData(&party[i], MON_DATA_SPECIES2) != SPECIES_EGG
// FIXME: Using index[array] instead of array[index] is BAD!
&& i != r1 && i != r2 && i != r7[gBattleStruct->field_5C] && i != r6[gBattleStruct->field_5C])
&& i != r1 && i != r2 && i != r7[gBattleStruct->monToSwitchIntoId] && i != r6[gBattleStruct->monToSwitchIntoId])
break;
}
return (i == 6);
@@ -3511,16 +3511,16 @@ u8 IsPokeDisobedient(void)
return 0;
if (!IsOtherTrainer(gBattleMons[gBankAttacker].otId, gBattleMons[gBankAttacker].otName))
return 0;
if (FlagGet(BADGE08_GET))
if (FlagGet(FLAG_BADGE08_GET))
return 0;
obedienceLevel = 10;
if (FlagGet(BADGE02_GET))
if (FlagGet(FLAG_BADGE02_GET))
obedienceLevel = 30;
if (FlagGet(BADGE04_GET))
if (FlagGet(FLAG_BADGE04_GET))
obedienceLevel = 50;
if (FlagGet(BADGE06_GET))
if (FlagGet(FLAG_BADGE06_GET))
obedienceLevel = 70;
}

219
src/battle_util2.c Normal file
View File

@@ -0,0 +1,219 @@
#include "global.h"
#include "battle.h"
#include "battle_controllers.h"
#include "malloc.h"
#include "pokemon.h"
#include "event_data.h"
#include "abilities.h"
#include "rng.h"
extern struct BattlePokemon gBattleMons[BATTLE_BANKS_COUNT];
extern u16 gBattlePartyID[BATTLE_BANKS_COUNT];
extern u8 gUnknown_0203CF00[];
extern const u8* gBattlescriptCurrInstr;
extern u8 gBattleCommunication[];
extern u8 gActiveBank;
extern const u8 BattleScript_MoveUsedWokeUp[];
extern const u8 BattleScript_MoveUsedIsFrozen[];
extern const u8 BattleScript_MoveUsedUnfroze[];
extern const u8 BattleScript_MoveUsedIsAsleep[];
extern void sub_81D55D0(void);
extern void sub_81D5694(void);
extern u8 pokemon_order_func(u8);
extern void sub_81B8FB0(u8, u8);
void AllocateBattleResources(void)
{
gBattleResources = gBattleResources; // something dumb needed to match
if (gBattleTypeFlags & BATTLE_TYPE_x4000000)
sub_81D55D0();
gBattleStruct = AllocZeroed(sizeof(*gBattleStruct));
gBattleResources = AllocZeroed(sizeof(*gBattleResources));
gBattleResources->secretBase = AllocZeroed(sizeof(*gBattleResources->secretBase));
gBattleResources->flags = AllocZeroed(sizeof(*gBattleResources->flags));
gBattleResources->battleScriptsStack = AllocZeroed(sizeof(*gBattleResources->battleScriptsStack));
gBattleResources->battleCallbackStack = AllocZeroed(sizeof(*gBattleResources->battleCallbackStack));
gBattleResources->statsBeforeLvlUp = AllocZeroed(sizeof(*gBattleResources->statsBeforeLvlUp));
gBattleResources->ai = AllocZeroed(sizeof(*gBattleResources->ai));
gBattleResources->battleHistory = AllocZeroed(sizeof(*gBattleResources->battleHistory));
gBattleResources->AI_ScriptsStack = AllocZeroed(sizeof(*gBattleResources->AI_ScriptsStack));
gLinkBattleSendBuffer = AllocZeroed(BATTLE_BUFFER_LINK_SIZE);
gLinkBattleRecvBuffer = AllocZeroed(BATTLE_BUFFER_LINK_SIZE);
gUnknown_0202305C = AllocZeroed(0x2000);
gUnknown_02023060 = AllocZeroed(0x1000);
if (gBattleTypeFlags & BATTLE_TYPE_SECRET_BASE)
{
u16 currSecretBaseId = VarGet(VAR_0x4054);
CreateSecretBaseEnemyParty(&gSaveBlock1Ptr->secretBases[currSecretBaseId]);
}
}
void FreeBattleResources(void)
{
if (gBattleTypeFlags & BATTLE_TYPE_x4000000)
sub_81D5694();
if (gBattleResources != NULL)
{
FREE_AND_SET_NULL(gBattleStruct);
FREE_AND_SET_NULL(gBattleResources->secretBase);
FREE_AND_SET_NULL(gBattleResources->flags);
FREE_AND_SET_NULL(gBattleResources->battleScriptsStack);
FREE_AND_SET_NULL(gBattleResources->battleCallbackStack);
FREE_AND_SET_NULL(gBattleResources->statsBeforeLvlUp);
FREE_AND_SET_NULL(gBattleResources->ai);
FREE_AND_SET_NULL(gBattleResources->battleHistory);
FREE_AND_SET_NULL(gBattleResources->AI_ScriptsStack);
FREE_AND_SET_NULL(gBattleResources);
FREE_AND_SET_NULL(gLinkBattleSendBuffer);
FREE_AND_SET_NULL(gLinkBattleRecvBuffer);
FREE_AND_SET_NULL(gUnknown_0202305C);
FREE_AND_SET_NULL(gUnknown_02023060);
}
}
void AdjustFriendshipOnBattleFaint(u8 bank)
{
u8 opposingBank;
if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE)
{
u8 opposingBank2;
opposingBank = GetBankByIdentity(IDENTITY_OPPONENT_MON1);
opposingBank2 = GetBankByIdentity(IDENTITY_OPPONENT_MON2);
if (gBattleMons[opposingBank2].level > gBattleMons[opposingBank].level)
opposingBank = opposingBank2;
}
else
{
opposingBank = GetBankByIdentity(IDENTITY_OPPONENT_MON1);
}
if (gBattleMons[opposingBank].level > gBattleMons[bank].level)
{
if (gBattleMons[opposingBank].level - gBattleMons[bank].level > 29)
AdjustFriendship(&gPlayerParty[gBattlePartyID[bank]], 8);
else
AdjustFriendship(&gPlayerParty[gBattlePartyID[bank]], 6);
}
else
{
AdjustFriendship(&gPlayerParty[gBattlePartyID[bank]], 6);
}
}
void sub_80571DC(u8 bank, u8 arg1)
{
if (GetBankSide(bank) != SIDE_OPPONENT)
{
s32 i;
// gBattleStruct->field_60[0][i]
for (i = 0; i < 3; i++)
gUnknown_0203CF00[i] = *(0 * 3 + i + (u8*)(gBattleStruct->field_60));
sub_81B8FB0(pokemon_order_func(gBattlePartyID[bank]), pokemon_order_func(arg1));
for (i = 0; i < 3; i++)
*(0 * 3 + i + (u8*)(gBattleStruct->field_60)) = gUnknown_0203CF00[i];
}
}
u32 sub_805725C(u8 bank)
{
u32 effect = 0;
do
{
switch (gBattleCommunication[MULTIUSE_STATE])
{
case 0:
if (gBattleMons[bank].status1 & STATUS_SLEEP)
{
if (UproarWakeUpCheck(bank))
{
gBattleMons[bank].status1 &= ~(STATUS_SLEEP);
gBattleMons[bank].status2 &= ~(STATUS2_NIGHTMARE);
BattleScriptPushCursor();
gBattleCommunication[MULTISTRING_CHOOSER] = 1;
gBattlescriptCurrInstr = BattleScript_MoveUsedWokeUp;
effect = 2;
}
else
{
u32 toSub;
if (gBattleMons[bank].ability == ABILITY_EARLY_BIRD)
toSub = 2;
else
toSub = 1;
if ((gBattleMons[bank].status1 & STATUS_SLEEP) < toSub)
gBattleMons[bank].status1 &= ~(STATUS_SLEEP);
else
gBattleMons[bank].status1 -= toSub;
if (gBattleMons[bank].status1 & STATUS_SLEEP)
{
gBattlescriptCurrInstr = BattleScript_MoveUsedIsAsleep;
effect = 2;
}
else
{
gBattleMons[bank].status2 &= ~(STATUS2_NIGHTMARE);
BattleScriptPushCursor();
gBattleCommunication[MULTISTRING_CHOOSER] = 0;
gBattlescriptCurrInstr = BattleScript_MoveUsedWokeUp;
effect = 2;
}
}
}
gBattleCommunication[MULTIUSE_STATE]++;
break;
case 1:
if (gBattleMons[bank].status1 & STATUS_FREEZE)
{
if (Random() % 5 != 0)
{
gBattlescriptCurrInstr = BattleScript_MoveUsedIsFrozen;
}
else
{
gBattleMons[bank].status1 &= ~(STATUS_FREEZE);
BattleScriptPushCursor();
gBattlescriptCurrInstr = BattleScript_MoveUsedUnfroze;
gBattleCommunication[MULTISTRING_CHOOSER] = 0;
}
effect = 2;
}
gBattleCommunication[MULTIUSE_STATE]++;
break;
case 2:
break;
}
} while (gBattleCommunication[MULTIUSE_STATE] != 2 && effect == 0);
if (effect == 2)
{
gActiveBank = bank;
EmitSetMonData(0, REQUEST_STATUS_BATTLE, 0, 4, &gBattleMons[gActiveBank].status1);
MarkBufferBankForExecution(gActiveBank);
}
return effect;
}

View File

@@ -14,7 +14,7 @@ extern void CB2_ChooseBerry(void);
extern const u8* GetFieldObjectScriptPointerForComparison(void);
extern bool8 sub_8092E9C(u8, u8, u8);
extern u16 gScriptItemId;
extern u16 gSpecialVar_ItemId;
extern const u8 BerryTreeScript[];
@@ -1169,7 +1169,7 @@ void FieldObjectInteractionGetBerryTreeData(void)
id = FieldObjectGetBerryTreeId(gSelectedMapObject);
berry = GetBerryTypeByBerryTreeId(id);
ResetBerryTreeSparkleFlag(id);
unk = gScriptLastTalked;
unk = gSpecialVar_LastTalked;
num = gSaveBlock1Ptr->location.mapNum;
group = gSaveBlock1Ptr->location.mapGroup;
if (sub_8092E9C(unk, num, group))
@@ -1202,7 +1202,7 @@ void Bag_ChooseBerry(void)
void FieldObjectInteractionPlantBerryTree(void)
{
u8 berry = ItemIdToBerryType(gScriptItemId);
u8 berry = ItemIdToBerryType(gSpecialVar_ItemId);
PlantBerryTree(FieldObjectGetBerryTreeId(gSelectedMapObject), berry, 1, TRUE);
FieldObjectInteractionGetBerryTreeData();
@@ -1219,7 +1219,7 @@ void FieldObjectInteractionPickBerryTree(void)
void FieldObjectInteractionRemoveBerryTree(void)
{
RemoveBerryTree(FieldObjectGetBerryTreeId(gSelectedMapObject));
sub_8092EF0(gScriptLastTalked, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup);
sub_8092EF0(gSpecialVar_LastTalked, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup);
}
u8 PlayerHasBerries(void)

View File

@@ -1,6 +1,8 @@
// Includes
#include "global.h"
#include "bg.h"
#include "window.h"
#include "task.h"
#include "sprite.h"
// Static type declarations
@@ -11,8 +13,585 @@ IWRAM_DATA s16 gUnknown_03000DF8[6];
IWRAM_DATA s16 gUnknown_03000E04;
IWRAM_DATA s16 gUnknown_03000E06;
// Static ROM declarations
// graphics
extern const u8 gBerryBlenderArrowTiles[];
extern const u8 gBerryBlenderStartTiles[];
extern const u8 gBerryBlenderMarubatsuTiles[];
extern const u8 gBerryBlenderParticlesTiles[];
extern const u8 gBerryBlenderCountdownNumbersTiles[];
extern const u16 gBerryBlenderMiscPalette[];
extern const u16 gBerryBlenderArrowPalette[];
void sub_8080EA4(u8 taskId);
void sub_8080FD0(u8 taskId);
void sub_80810F8(u8 taskId);
void sub_80833F8(struct Sprite *sprite);
void sub_8082F68(struct Sprite *sprite);
void sub_8083010(struct Sprite *sprite);
void sub_80830C0(struct Sprite *sprite);
// .rodata
// TODO: make those static once the file is decompiled
const u16 sBlenderCenterPal[] = INCBIN_U16("graphics/berry_blender/center.gbapal");
const u8 sBlenderCenterMap[] = INCBIN_U8("graphics/berry_blender/center_map.bin");
const u16 sBlenderOuterPal[] = INCBIN_U16("graphics/berry_blender/outer.gbapal");
// unreferenced pals?
static const u16 sUnknownPal_0[] = INCBIN_U16("graphics/unknown/unknown_339514.gbapal");
static const u16 sUnknownArray_1[224] = {0};
// unused text?
static const u8 sUnusedText_YesNo[] = _("YES\nNO");
static const u8 sUnusedText_2[] = _("");
static const u8 sUnusedText_Space[] = _(" ");
static const u8 sUnusedText_Terminating[] = _("Terminating.");
static const u8 sUnusedText_LinkPartnerNotFound[] = _("Link partner(s) not found.\nPlease try again.\p");
const u8 gText_BerryBlenderStart[] = _("Starting up the BERRY BLENDER.\pPlease select a BERRY from your BAG\nto put in the BERRY BLENDER.\p");
const u8 gText_NewParagraph[] = _("\p");
const u8 gText_WasMade[] = _(" was made!");
static const u8 sText_Mister[] = _("MISTER");
static const u8 sText_Laddie[] = _("LADDIE");
static const u8 sText_Lassie[] = _("LASSIE");
static const u8 sText_Master[] = _("MASTER");
static const u8 sText_Dude[] = _("DUDE");
static const u8 sText_Miss[] = _("MISS");
const u8* const sBlenderOpponentsNames[] =
{
sText_Mister,
sText_Laddie,
sText_Lassie,
sText_Master,
sText_Dude,
sText_Miss
};
static const u8 sText_PressAToStart[] = _("Press the A Button to start.");
static const u8 sText_PleaseWaitAWhile[] = _("Please wait a while.");
const u8 sText_CommunicationStandby[] = _("Communication standby…");
const u8 sText_WouldLikeToBlendAnotherBerry[] = _("Would you like to blend another BERRY?");
const u8 sText_RunOutOfBerriesForBlending[] = _("Youve run out of BERRIES for\nblending in the BERRY BLENDER.\p");
const u8 sText_YourPokeblockCaseIsFull[] = _("Your {POKEBLOCK} CASE is full.\p");
const u8 sText_HasNoBerriesToPut[] = _(" has no BERRIES to put in\nthe BERRY BLENDER.");
const u8 sText_ApostropheSPokeblockCaseIsFull[] = _("s {POKEBLOCK} CASE is full.\p");
const u8 sText_BlendingResults[] = _("RESULTS OF BLENDING");
static const u8 sText_BerryUsed[] = _("BERRY USED");
const u8 sText_SpaceBerry[] = _(" BERRY");
const u8 sText_Time[] = _("Time:");
const u8 sText_Min[] = _(" min. ");
const u8 sText_Sec[] = _(" sec.");
const u8 sText_MaximumSpeed[] = _("MAXIMUM SPEED");
const u8 sText_RPM[] = _(" RPM");
const u8 sText_Dot[] = _(".");
const u8 sText_NewLine[] = _("\n");
static const u8 sText_Space[] = _(" ");
const u8 sText_Ranking[] = _("RANKING");
const u8 sText_TheLevelIs[] = _("The level is ");
const u8 sText_TheFeelIs[] = _(", and the feel is ");
const u8 sText_Dot2[] = _(".");
const struct BgTemplate gUnknown_08339974[3] =
{
{
.bg = 0,
.charBaseIndex = 3,
.mapBaseIndex = 31,
.screenSize = 0,
.paletteMode = 0,
.priority = 0,
.baseTile = 0,
},
{
.bg = 1,
.charBaseIndex = 2,
.mapBaseIndex = 12,
.screenSize = 0,
.paletteMode = 0,
.priority = 1,
.baseTile = 0,
},
{
.bg = 2,
.charBaseIndex = 0,
.mapBaseIndex = 8,
.screenSize = 1,
.paletteMode = 1,
.priority = 0,
.baseTile = 0,
}
};
const struct WindowTemplate gUnknown_08339980[] =
{
{0, 1, 6, 7, 2, 0xE, 0x28},
{0, 0x16, 6, 7, 2, 0xE, 0x36},
{0, 1, 0xC, 7, 2, 0xE, 0x44},
{0, 0x16, 0xC, 7, 2, 0xE, 0x52},
{0, 2, 0xF, 0x1B, 4, 0xE, 0x60},
{0, 5, 3, 0x15, 0xE, 0xE, 0x60},
DUMMY_WIN_TEMPLATE
};
const struct WindowTemplate gUnknown_083399B8 =
{
0, 0x15, 9, 5, 4, 0xE, 0xCC
};
const s8 gUnknown_083399C0[][2] =
{
{-1, -1}, {1, -1}, {-1, 1}, {1, 1}
};
const u8 sBlenderSyncArrowsPos[][2] =
{
{72, 32}, {168, 32}, {72, 128}, {168, 128}
};
const u8 gUnknown_083399D0[3][4] =
{
{-1, 0, 1, -1}, {-1, 0, 1, 2}, {0, 1, 2, 3}
};
const u16 gUnknown_083399DC[] = {0, 0xC000, 0x4000, 0x8000};
const u8 gUnknown_083399E4[] = {1, 1, 0};
const u8 gUnknown_083399E7[] = {32, 224, 96, 160, 0};
const TaskFunc gUnknown_083399EC[] =
{
sub_8080EA4, sub_8080FD0, sub_80810F8
};
static const struct OamData sOamData_8216314 =
{
.y = 0,
.affineMode = 0,
.objMode = 0,
.mosaic = 0,
.bpp = 0,
.shape = 0,
.x = 0,
.matrixNum = 0,
.size = 2,
.tileNum = 0,
.priority = 1,
.paletteNum = 0,
.affineParam = 0,
};
static const union AnimCmd sSpriteAnim_821631C[] =
{
ANIMCMD_FRAME(16, 5, 1, 1),
ANIMCMD_END
};
static const union AnimCmd sSpriteAnim_8216324[] =
{
ANIMCMD_FRAME(16, 5, .vFlip = TRUE),
ANIMCMD_END
};
static const union AnimCmd sSpriteAnim_821632C[] =
{
ANIMCMD_FRAME(16, 5, .hFlip = TRUE),
ANIMCMD_END
};
static const union AnimCmd sSpriteAnim_8216334[] =
{
ANIMCMD_FRAME(16, 5, 0, 0),
ANIMCMD_END
};
static const union AnimCmd sSpriteAnim_821633C[] =
{
ANIMCMD_FRAME(48, 2, 1, 1),
ANIMCMD_FRAME(32, 5, 1, 1),
ANIMCMD_FRAME(48, 3, 1, 1),
ANIMCMD_FRAME(16, 5, 1, 1),
ANIMCMD_END
};
static const union AnimCmd sSpriteAnim_8216350[] =
{
ANIMCMD_FRAME(48, 2, .vFlip = TRUE),
ANIMCMD_FRAME(32, 5, .vFlip = TRUE),
ANIMCMD_FRAME(48, 3, .vFlip = TRUE),
ANIMCMD_FRAME(16, 5, .vFlip = TRUE),
ANIMCMD_END
};
static const union AnimCmd sSpriteAnim_8216364[] =
{
ANIMCMD_FRAME(48, 2, .hFlip = TRUE),
ANIMCMD_FRAME(32, 5, .hFlip = TRUE),
ANIMCMD_FRAME(48, 3, .hFlip = TRUE),
ANIMCMD_FRAME(16, 5, .hFlip = TRUE),
ANIMCMD_END
};
static const union AnimCmd sSpriteAnim_8216378[] =
{
ANIMCMD_FRAME(48, 2, 0, 0),
ANIMCMD_FRAME(32, 5, 0, 0),
ANIMCMD_FRAME(48, 3, 0, 0),
ANIMCMD_FRAME(16, 5, 0, 0),
ANIMCMD_END
};
static const union AnimCmd sSpriteAnim_821638C[] =
{
ANIMCMD_FRAME(0, 5, 1, 1),
ANIMCMD_END
};
static const union AnimCmd sSpriteAnim_8216394[] =
{
ANIMCMD_FRAME(0, 5, .vFlip = TRUE),
ANIMCMD_END
};
static const union AnimCmd sSpriteAnim_821639C[] =
{
ANIMCMD_FRAME(0, 5, .hFlip = TRUE),
ANIMCMD_END
};
static const union AnimCmd sSpriteAnim_82163A4[] =
{
ANIMCMD_FRAME(0, 5, 0, 0),
ANIMCMD_END
};
static const union AnimCmd *const sSpriteAnimTable_82163AC[] =
{
sSpriteAnim_821631C,
sSpriteAnim_8216324,
sSpriteAnim_821632C,
sSpriteAnim_8216334,
sSpriteAnim_821633C,
sSpriteAnim_8216350,
sSpriteAnim_8216364,
sSpriteAnim_8216378,
sSpriteAnim_821638C,
sSpriteAnim_8216394,
sSpriteAnim_821639C,
sSpriteAnim_82163A4
};
const struct SpriteSheet sSpriteSheet_BlenderArrow =
{
gBerryBlenderArrowTiles, 0x800, 46545
};
const struct SpritePalette sSpritePal_BlenderMisc =
{
gBerryBlenderMiscPalette, 46546
};
const struct SpritePalette sSpritePal_BlenderArrow =
{
gBerryBlenderArrowPalette, 12312
};
const struct SpriteTemplate sBlenderSyncArrow_SpriteTemplate =
{
.tileTag = 46545,
.paletteTag = 12312,
.oam = &sOamData_8216314,
.anims = sSpriteAnimTable_82163AC,
.images = NULL,
.affineAnims = gDummySpriteAffineAnimTable,
.callback = sub_80833F8
};
static const struct OamData sOamData_821640C =
{
.y = 0,
.affineMode = 0,
.objMode = 0,
.mosaic = 0,
.bpp = 0,
.shape = 0,
.x = 0,
.matrixNum = 0,
.size = 1,
.tileNum = 0,
.priority = 0,
.paletteNum = 0,
.affineParam = 0,
};
static const union AnimCmd sSpriteAnim_8216414[] =
{
ANIMCMD_FRAME(0, 20),
ANIMCMD_END
};
static const union AnimCmd sSpriteAnim_821641C[] =
{
ANIMCMD_FRAME(4, 20, 1, 0),
ANIMCMD_END
};
static const union AnimCmd sSpriteAnim_8216424[] =
{
ANIMCMD_FRAME(8, 4),
ANIMCMD_FRAME(12, 4),
ANIMCMD_FRAME(8, 4),
ANIMCMD_FRAME(12, 4),
ANIMCMD_FRAME(8, 4),
ANIMCMD_END
};
static const union AnimCmd sSpriteAnim_821643C[] =
{
ANIMCMD_FRAME(8, 4),
ANIMCMD_END
};
static const union AnimCmd *const sSpriteAnimTable_8216444[] =
{
sSpriteAnim_8216414,
sSpriteAnim_821641C,
sSpriteAnim_8216424,
sSpriteAnim_821643C,
};
const struct SpriteSheet gUnknown_08339B38 =
{
gBerryBlenderMarubatsuTiles, 0x200, 48888
};
const struct SpriteTemplate gUnknown_08339B40 =
{
.tileTag = 48888,
.paletteTag = 46546,
.oam = &sOamData_821640C,
.anims = sSpriteAnimTable_8216444,
.images = NULL,
.affineAnims = gDummySpriteAffineAnimTable,
.callback = sub_8082F68
};
static const struct OamData sOamData_8216474 =
{
.y = 0,
.affineMode = 0,
.objMode = 0,
.mosaic = 0,
.bpp = 0,
.shape = 0,
.x = 0,
.matrixNum = 0,
.size = 0,
.tileNum = 0,
.priority = 1,
.paletteNum = 0,
.affineParam = 0,
};
static const union AnimCmd sSpriteAnim_821647C[] =
{
ANIMCMD_FRAME(0, 3),
ANIMCMD_FRAME(1, 4),
ANIMCMD_FRAME(3, 5),
ANIMCMD_FRAME(1, 4),
ANIMCMD_FRAME(0, 3),
ANIMCMD_END
};
static const union AnimCmd sSpriteAnim_8216494[] =
{
ANIMCMD_FRAME(0, 3),
ANIMCMD_FRAME(2, 4),
ANIMCMD_FRAME(4, 5),
ANIMCMD_FRAME(2, 4),
ANIMCMD_FRAME(0, 3),
ANIMCMD_END
};
static const union AnimCmd sSpriteAnim_82164AC[] =
{
ANIMCMD_FRAME(0, 2),
ANIMCMD_FRAME(1, 2),
ANIMCMD_FRAME(2, 2),
ANIMCMD_FRAME(4, 4),
ANIMCMD_FRAME(3, 3),
ANIMCMD_FRAME(2, 2),
ANIMCMD_FRAME(1, 2),
ANIMCMD_FRAME(0, 2),
ANIMCMD_END
};
static const union AnimCmd sSpriteAnim_82164D0[] =
{
ANIMCMD_FRAME(5, 5, 1, 1),
ANIMCMD_END
};
static const union AnimCmd sSpriteAnim_82164D8[] =
{
ANIMCMD_FRAME(6, 5, 1, 1),
ANIMCMD_END
};
static const union AnimCmd *const sSpriteAnimTable_82164E0[] =
{
sSpriteAnim_821647C,
sSpriteAnim_8216494,
sSpriteAnim_82164AC,
sSpriteAnim_82164D0,
sSpriteAnim_82164D8,
};
const struct SpriteSheet gUnknown_08339BD8 =
{
gBerryBlenderParticlesTiles, 0xE0, 23456
};
const struct SpriteTemplate gUnknown_08339BE0 =
{
.tileTag = 23456,
.paletteTag = 46546,
.oam = &sOamData_8216474,
.anims = sSpriteAnimTable_82164E0,
.images = NULL,
.affineAnims = gDummySpriteAffineAnimTable,
.callback = SpriteCallbackDummy
};
static const struct OamData sOamData_8216514 =
{
.y = 0,
.affineMode = 0,
.objMode = 0,
.mosaic = 0,
.bpp = 0,
.shape = 0,
.x = 0,
.matrixNum = 0,
.size = 2,
.tileNum = 0,
.priority = 1,
.paletteNum = 0,
.affineParam = 0,
};
static const union AnimCmd sSpriteAnim_821651C[] =
{
ANIMCMD_FRAME(32, 30),
ANIMCMD_END
};
static const union AnimCmd sSpriteAnim_8216524[] =
{
ANIMCMD_FRAME(16, 30),
ANIMCMD_END
};
static const union AnimCmd sSpriteAnim_821652C[] =
{
ANIMCMD_FRAME(0, 30),
ANIMCMD_END
};
static const union AnimCmd *const sSpriteAnimTable_8216534[] =
{
sSpriteAnim_821651C,
sSpriteAnim_8216524,
sSpriteAnim_821652C,
};
const struct SpriteSheet gUnknown_08339C24 =
{
gBerryBlenderCountdownNumbersTiles, 0x600, 12345
};
const struct SpriteTemplate gUnknown_08339C2C =
{
.tileTag = 12345,
.paletteTag = 46546,
.oam = &sOamData_8216514,
.anims = sSpriteAnimTable_8216534,
.images = NULL,
.affineAnims = gDummySpriteAffineAnimTable,
.callback = sub_8083010
};
static const struct OamData sOamData_8216560 =
{
.y = 0,
.affineMode = 0,
.objMode = 0,
.mosaic = 0,
.bpp = 0,
.shape = 1,
.x = 0,
.matrixNum = 0,
.size = 3,
.tileNum = 0,
.priority = 1,
.paletteNum = 0,
.affineParam = 0,
};
static const union AnimCmd sSpriteAnim_8216568[] =
{
ANIMCMD_FRAME(0, 30),
ANIMCMD_END
};
static const union AnimCmd *const sSpriteAnimTable_8216570[] =
{
sSpriteAnim_8216568,
};
const struct SpriteSheet gUnknown_08339C58 =
{
gBerryBlenderStartTiles, 0x400, 12346
};
const struct SpriteTemplate gUnknown_08339C60 =
{
.tileTag = 12346,
.paletteTag = 46546,
.oam = &sOamData_8216560,
.anims = sSpriteAnimTable_8216570,
.images = NULL,
.affineAnims = gDummySpriteAffineAnimTable,
.callback = sub_80830C0
};
const s16 gUnknown_08339C78[][5] =
{
{-10, 20, 10, 2, 1},
{250, 20, 10, -2, 1},
{-10, 140, 10, 2, -1},
{250, 140, 10, -2, -1},
};
const u8 gUnknown_08339CA0[][3] =
{
{4, 3, 2}, {0, 4, 3}, {1, 0, 4}, {2, 1, 0}, {3, 2, 1}, {0, 2, 3}, {1, 3, 4}, {2, 4, 0}, {3, 0, 1}, {4, 1, 2},
};
const u8 gUnknown_08339CBE[] = {30, 31, 32, 33, 34};
const u8 gUnknown_08339CC3[] = {1, 1, 2, 3, 4};
const u8 gUnknown_08339CC8[] = {0x1C, 0x16, 0x13, 0x1A, 0x19, 0x0E, 0x0D, 0x0B, 0x07, 0x15};
static const u8 gUnknown_08339CD2[] =
{
0xfe, 0x02, 0x02, 0xce, 0xd0, 0x37, 0x44, 0x07, 0x1f, 0x0c, 0x10,
0x00, 0xff, 0xfe, 0x91, 0x72, 0xce, 0xd0, 0x37, 0x44, 0x07, 0x1f,
0x0c, 0x10, 0x00, 0xff, 0x06, 0x27, 0x02, 0xff, 0x00, 0x0c, 0x48,
0x02, 0xff, 0x00, 0x01, 0x1f, 0x02, 0xff, 0x00, 0x16, 0x37, 0x02,
0xff, 0x00, 0x0d, 0x50, 0x4b, 0x02, 0xff, 0x06, 0x06, 0x06, 0x06,
0x05, 0x03, 0x03, 0x03, 0x02, 0x02, 0x03, 0x03, 0x03, 0x03, 0x02
};
const struct WindowTemplate gUnknown_08339D14[] = {0, 6, 4, 0x12, 0xB, 0xF, 8};
// .text

View File

@@ -33,7 +33,7 @@ void sub_8179944(void);
bool8 ShouldDoBrailleDigEffect(void)
{
if (!FlagGet(SYS_BRAILLE_DIG)
if (!FlagGet(FLAG_SYS_BRAILLE_DIG)
&& (gSaveBlock1Ptr->location.mapGroup == 0x18
&& gSaveBlock1Ptr->location.mapNum == 0x47))
{
@@ -58,7 +58,7 @@ void DoBrailleDigEffect(void)
MapGridSetMetatileIdAt(18, 9, 3636);
DrawWholeMapView();
PlaySE(SE_BAN);
FlagSet(SYS_BRAILLE_DIG);
FlagSet(FLAG_SYS_BRAILLE_DIG);
ScriptContext2_Disable();
}
@@ -81,7 +81,7 @@ bool8 CheckRelicanthWailord(void)
void ShouldDoBrailleStrengthEffectOld(void)
{
/*
if (!FlagGet(SYS_BRAILLE_STRENGTH) && (gSaveBlock1.location.mapGroup == MAP_GROUP_DESERT_RUINS && gSaveBlock1.location.mapNum == MAP_ID_DESERT_RUINS))
if (!FlagGet(FLAG_SYS_BRAILLE_STRENGTH) && (gSaveBlock1.location.mapGroup == MAP_GROUP_DESERT_RUINS && gSaveBlock1.location.mapNum == MAP_ID_DESERT_RUINS))
{
if (gSaveBlock1.pos.x == 10 && gSaveBlock1.pos.y == 23)
return TRUE;
@@ -105,13 +105,13 @@ void DoBrailleStrengthEffect(void)
MapGridSetMetatileIdAt(16, 27, 3636);
DrawWholeMapView();
PlaySE(SE_BAN);
FlagSet(SYS_BRAILLE_STRENGTH);
FlagSet(FLAG_SYS_BRAILLE_STRENGTH);
ScriptContext2_Disable();
}
bool8 ShouldDoBrailleFlyEffect(void)
{
if (!FlagGet(SYS_BRAILLE_FLY) && (gSaveBlock1.location.mapGroup == MAP_GROUP_ANCIENT_TOMB && gSaveBlock1.location.mapNum == MAP_ID_ANCIENT_TOMB))
if (!FlagGet(FLAG_SYS_BRAILLE_FLY) && (gSaveBlock1.location.mapGroup == MAP_GROUP_ANCIENT_TOMB && gSaveBlock1.location.mapNum == MAP_ID_ANCIENT_TOMB))
{
if (gSaveBlock1.pos.x == 8 && gSaveBlock1.pos.y == 25)
return TRUE;
@@ -151,7 +151,7 @@ void UseFlyAncientTomb_Finish(void)
MapGridSetMetatileIdAt(16, 27, 3636);
DrawWholeMapView();
PlaySE(SE_BAN);
FlagSet(SYS_BRAILLE_FLY);
FlagSet(FLAG_SYS_BRAILLE_FLY);
ScriptContext2_Disable();
}
*/
@@ -205,7 +205,7 @@ void SealedChamberShakingEffect(u8 taskId)
// moved later in the function because it was rewritten.
bool8 ShouldDoBrailleStrengthEffect(void)
{
if (!FlagGet(SYS_BRAILLE_STRENGTH) && (gSaveBlock1Ptr->location.mapGroup == 0x18 && gSaveBlock1Ptr->location.mapNum == 0x06))
if (!FlagGet(FLAG_SYS_BRAILLE_STRENGTH) && (gSaveBlock1Ptr->location.mapGroup == 0x18 && gSaveBlock1Ptr->location.mapNum == 0x06))
{
if (gSaveBlock1Ptr->pos.x == 6 && gSaveBlock1Ptr->pos.y == 23)
{ gBraillePuzzleCallbackFlag = STRENGTH_PUZZLE; return TRUE; }
@@ -240,13 +240,13 @@ void sub_8179860(void)
MapGridSetMetatileIdAt(16, 27, 3636);
DrawWholeMapView();
PlaySE(SE_BAN);
FlagSet(SYS_BRAILLE_STRENGTH);
FlagSet(FLAG_SYS_BRAILLE_STRENGTH);
ScriptContext2_Disable();
}
bool8 ShouldDoBrailleFlyEffect(void)
{
if (!FlagGet(SYS_BRAILLE_FLY) && (gSaveBlock1Ptr->location.mapGroup == 0x18 && gSaveBlock1Ptr->location.mapNum == 0x44))
if (!FlagGet(FLAG_SYS_BRAILLE_FLY) && (gSaveBlock1Ptr->location.mapGroup == 0x18 && gSaveBlock1Ptr->location.mapNum == 0x44))
{
if (gSaveBlock1Ptr->pos.x == 8 && gSaveBlock1Ptr->pos.y == 25)
{ gBraillePuzzleCallbackFlag = FLY_PUZZLE; return TRUE; }
@@ -276,7 +276,7 @@ void sub_8179944(void)
MapGridSetMetatileIdAt(16, 27, 3636);
DrawWholeMapView();
PlaySE(SE_BAN);
FlagSet(SYS_BRAILLE_FLY);
FlagSet(FLAG_SYS_BRAILLE_FLY);
ScriptContext2_Disable();
}
@@ -284,7 +284,7 @@ void sub_8179944(void)
void DoBrailleWait(void)
{
/*
if (!FlagGet(SYS_BRAILLE_WAIT))
if (!FlagGet(FLAG_SYS_BRAILLE_WAIT))
CreateTask(Task_BrailleWait, 0x50);
}
@@ -387,7 +387,7 @@ bool8 ShouldDoBrailleRegicePuzzle(void)
if (gSaveBlock1Ptr->location.mapGroup == 0x18 && gSaveBlock1Ptr->location.mapNum == 0x43)
{
// _08179A1A
if (FlagGet(SYS_BRAILLE_WAIT) != FALSE)
if (FlagGet(FLAG_SYS_BRAILLE_WAIT) != FALSE)
return FALSE;
if (FlagGet(2) == FALSE)
return FALSE;

View File

@@ -84,13 +84,13 @@ s32 CalculateBaseDamage(struct BattlePokemon *attacker, struct BattlePokemon *de
if (attacker->ability == ABILITY_HUGE_POWER || attacker->ability == ABILITY_PURE_POWER)
attack *= 2;
if (ShouldGetStatBadgeBoost(BADGE01_GET, bankAtk))
if (ShouldGetStatBadgeBoost(FLAG_BADGE01_GET, bankAtk))
attack = (110 * attack) / 100;
if (ShouldGetStatBadgeBoost(BADGE05_GET, bankDef))
if (ShouldGetStatBadgeBoost(FLAG_BADGE05_GET, bankDef))
defense = (110 * defense) / 100;
if (ShouldGetStatBadgeBoost(BADGE07_GET, bankAtk))
if (ShouldGetStatBadgeBoost(FLAG_BADGE07_GET, bankAtk))
spAttack = (110 * spAttack) / 100;
if (ShouldGetStatBadgeBoost(BADGE07_GET, bankDef))
if (ShouldGetStatBadgeBoost(FLAG_BADGE07_GET, bankDef))
spDefense = (110 * spDefense) / 100;
for (i = 0; i < 17; i++)

View File

@@ -1600,10 +1600,10 @@ void sub_81289F0(u8 taskId)
{
sCurDecorMapX = gTasks[taskId].data[0] - 7;
sCurDecorMapY = gTasks[taskId].data[1] - 7;
ScriptContext1_SetupScript(gUnknown_08275D1F);
ScriptContext1_SetupScript(EventScript_275D1F);
}
gSprites[sDecor_CameraSpriteObjectIdx1].pos1.y += 2;
if (gMapHeader.regionMapSectionId == REGION_MAP_SECRET_BASE)
if (gMapHeader.regionMapSectionId == MAPSEC_SECRET_BASE)
{
TV_PutSecretBaseVisitOnTheAir();
}
@@ -1700,7 +1700,7 @@ void sub_8128C64(u8 taskId)
data[2] ++;
break;
case 1:
ScriptContext1_SetupScript(gUnknown_08275D0C);
ScriptContext1_SetupScript(EventScript_275D0C);
data[2] ++;
break;
case 2:
@@ -2133,10 +2133,10 @@ void sub_8129708(void)
u16 i;
gSpecialVar_0x8005 = 0;
gScriptResult = 0;
gSpecialVar_Result = 0;
if (gSpecialVar_0x8004 == sCurDecorSelectedInRearrangement)
{
gScriptResult = 1;
gSpecialVar_Result = 1;
}
else if (gDecorations[gUnknown_0203A17C.items[sDecorRearrangementDataBuffer[gSpecialVar_0x8004].idx]].permission == DECORPERM_SOLID_MAT)
{
@@ -2206,7 +2206,7 @@ void sub_81298EC(u8 taskId)
case 1:
if (!gPaletteFade.active) {
DrawWholeMapView();
ScriptContext1_SetupScript(gUnknown_08275D2E);
ScriptContext1_SetupScript(EventScript_275D2E);
sub_8197434(0, 1);
gTasks[taskId].data[2] = 2;
}
@@ -2222,7 +2222,7 @@ void sub_81298EC(u8 taskId)
{
StringExpandPlaceholders(gStringVar4, gText_DecorationReturnedToPC);
DisplayItemMessageOnField(taskId, gStringVar4, sub_8129D64);
if (gMapHeader.regionMapSectionId == REGION_MAP_SECRET_BASE)
if (gMapHeader.regionMapSectionId == MAPSEC_SECRET_BASE)
{
TV_PutSecretBaseVisitOnTheAir();
}
@@ -2691,7 +2691,7 @@ void sub_812A2C4(u8 taskId)
data[2] ++;
break;
case 1:
ScriptContext1_SetupScript(gUnknown_08275D0C);
ScriptContext1_SetupScript(EventScript_275D0C);
data[2] ++;
break;
case 2:

View File

@@ -69,7 +69,7 @@ extern void play_some_sound(void);
extern void DoNamingScreen(u8, const u8*, u16, u8, u32, MainCallback);
extern void AddTextPrinterParametrized2(u8 windowId, u8 fontId, u8 x, u8 y, u8 letterSpacing, u8 lineSpacing, struct TextColor* colors, s8 speed, u8 *str);
extern u16 sub_80D22D0(void);
extern u8 sub_80C7050(u8);
extern u8 CountPartyAliveNonEggMonsExcept(u8);
static void Task_EggHatch(u8 taskID);
static void CB2_EggHatch_0(void);
@@ -882,6 +882,6 @@ u8 GetEggStepsToSubtract(void)
u16 sub_80722E0(void)
{
u16 value = sub_80D22D0();
value += sub_80C7050(6);
value += CountPartyAliveNonEggMonsExcept(6);
return value;
}

View File

@@ -17,11 +17,11 @@ EWRAM_DATA u16 gSpecialVar_0x8008 = 0;
EWRAM_DATA u16 gSpecialVar_0x8009 = 0;
EWRAM_DATA u16 gSpecialVar_0x800A = 0;
EWRAM_DATA u16 gSpecialVar_0x800B = 0;
EWRAM_DATA u16 gScriptResult = 0;
EWRAM_DATA u16 gScriptLastTalked = 0;
EWRAM_DATA u16 gScriptFacing = 0;
EWRAM_DATA u16 gSpecialVar_0x8012 = 0;
EWRAM_DATA u16 gSpecialVar_0x8013 = 0;
EWRAM_DATA u16 gSpecialVar_Result = 0;
EWRAM_DATA u16 gSpecialVar_LastTalked = 0;
EWRAM_DATA u16 gSpecialVar_Facing = 0;
EWRAM_DATA u16 gSpecialVar_MonBoxId = 0;
EWRAM_DATA u16 gSpecialVar_MonBoxPos = 0;
EWRAM_DATA u16 gSpecialVar_0x8014 = 0;
EWRAM_DATA static u8 gUnknown_020375FC[16] = {0};
@@ -40,11 +40,11 @@ void ClearTempFieldEventData(void)
{
memset(gSaveBlock1Ptr->flags, 0, TEMP_FLAGS_SIZE);
memset(gSaveBlock1Ptr->vars, 0, TEMP_VARS_SIZE);
FlagClear(SYS_ENC_UP_ITEM);
FlagClear(SYS_ENC_DOWN_ITEM);
FlagClear(SYS_USE_STRENGTH);
FlagClear(SYS_CTRL_OBJ_DELETE);
FlagClear(SYS_UNKNOWN_880);
FlagClear(FLAG_SYS_ENC_UP_ITEM);
FlagClear(FLAG_SYS_ENC_DOWN_ITEM);
FlagClear(FLAG_SYS_USE_STRENGTH);
FlagClear(FLAG_SYS_CTRL_OBJ_DELETE);
FlagClear(FLAG_SYS_UNKNOWN_880);
}
// probably had different flag splits at one point.
@@ -58,7 +58,7 @@ void DisableNationalPokedex(void)
u16 *nationalDexVar = GetVarPointer(VAR_NATIONAL_DEX);
gSaveBlock2Ptr->pokedex.nationalMagic = 0;
*nationalDexVar = 0;
FlagClear(SYS_NATIONAL_DEX);
FlagClear(FLAG_SYS_NATIONAL_DEX);
}
void EnableNationalPokedex(void)
@@ -66,7 +66,7 @@ void EnableNationalPokedex(void)
u16 *nationalDexVar = GetVarPointer(VAR_NATIONAL_DEX);
gSaveBlock2Ptr->pokedex.nationalMagic = 0xDA;
*nationalDexVar = 0x302;
FlagSet(SYS_NATIONAL_DEX);
FlagSet(FLAG_SYS_NATIONAL_DEX);
gSaveBlock2Ptr->pokedex.unknown1 = 1;
gSaveBlock2Ptr->pokedex.order = 0;
sub_80BB358();
@@ -74,7 +74,7 @@ void EnableNationalPokedex(void)
bool32 IsNationalPokedexEnabled(void)
{
if (gSaveBlock2Ptr->pokedex.nationalMagic == 0xDA && VarGet(VAR_NATIONAL_DEX) == 0x302 && FlagGet(SYS_NATIONAL_DEX))
if (gSaveBlock2Ptr->pokedex.nationalMagic == 0xDA && VarGet(VAR_NATIONAL_DEX) == 0x302 && FlagGet(FLAG_SYS_NATIONAL_DEX))
return TRUE;
else
return FALSE;
@@ -82,32 +82,32 @@ bool32 IsNationalPokedexEnabled(void)
void DisableMysteryEvent(void)
{
FlagClear(SYS_MYSTERY_EVENT_ENABLE);
FlagClear(FLAG_SYS_MYSTERY_EVENT_ENABLE);
}
void EnableMysteryEvent(void)
{
FlagSet(SYS_MYSTERY_EVENT_ENABLE);
FlagSet(FLAG_SYS_MYSTERY_EVENT_ENABLE);
}
bool32 IsMysteryEventEnabled(void)
{
return FlagGet(SYS_MYSTERY_EVENT_ENABLE);
return FlagGet(FLAG_SYS_MYSTERY_EVENT_ENABLE);
}
void DisableMysteryGift(void)
{
FlagClear(SYS_MYSTERY_GIFT_ENABLE);
FlagClear(FLAG_SYS_MYSTERY_GIFT_ENABLE);
}
void EnableMysteryGift(void)
{
FlagSet(SYS_MYSTERY_GIFT_ENABLE);
FlagSet(FLAG_SYS_MYSTERY_GIFT_ENABLE);
}
bool32 IsMysteryGiftEnabled(void)
{
return FlagGet(SYS_MYSTERY_GIFT_ENABLE);
return FlagGet(FLAG_SYS_MYSTERY_GIFT_ENABLE);
}
void sub_809D4D8(void)
@@ -145,18 +145,18 @@ void sub_809D570(void)
void DisableResetRTC(void)
{
VarSet(VAR_RESET_RTC_ENABLE, 0);
FlagClear(SYS_RESET_RTC_ENABLE);
FlagClear(FLAG_SYS_RESET_RTC_ENABLE);
}
void EnableResetRTC(void)
{
VarSet(VAR_RESET_RTC_ENABLE, 0x920);
FlagSet(SYS_RESET_RTC_ENABLE);
FlagSet(FLAG_SYS_RESET_RTC_ENABLE);
}
bool32 CanResetRTC(void)
{
if (FlagGet(SYS_RESET_RTC_ENABLE) && VarGet(VAR_RESET_RTC_ENABLE) == 0x920)
if (FlagGet(FLAG_SYS_RESET_RTC_ENABLE) && VarGet(VAR_RESET_RTC_ENABLE) == 0x920)
return TRUE;
else
return FALSE;

View File

@@ -1765,10 +1765,10 @@ void sub_808F28C(u8 localId, u8 mapNum, u8 mapGroup, u8 decorCat)
switch (decorCat)
{
case DECORCAT_DOLL:
sub_808F228(&gMapObjects[mapObjectId], gUnknown_082766A2);
sub_808F228(&gMapObjects[mapObjectId], EventScript_2766A2);
break;
case DECORCAT_CUSHION:
sub_808F228(&gMapObjects[mapObjectId], gUnknown_082766A6);
sub_808F228(&gMapObjects[mapObjectId], EventScript_2766A6);
break;
}
}

193
src/field_region_map.c Normal file
View File

@@ -0,0 +1,193 @@
// Includes
#include "global.h"
#include "main.h"
#include "malloc.h"
#include "gpu_regs.h"
#include "bg.h"
#include "text.h"
#include "window.h"
#include "text_window.h"
#include "palette.h"
#include "menu.h"
#include "strings.h"
#include "international_string_util.h"
#include "region_map.h"
// Static type declarations
// Static RAM declarations
static EWRAM_DATA struct {
MainCallback callback;
u32 filler_004;
struct RegionMap regionMap;
u16 state;
} *sFieldRegionMapHandler = NULL;
// Static ROM declarations
static void MCB2_InitRegionMapRegisters(void);
static void VBCB_FieldUpdateRegionMap(void);
static void MCB2_FieldUpdateRegionMap(void);
static void FieldUpdateRegionMap(void);
static void PrintRegionMapSecName(void);
// .rodata
static const struct BgTemplate gUnknown_085E5068[] = {
{
.bg = 0,
.charBaseIndex = 0,
.mapBaseIndex = 31,
.screenSize = 0,
.paletteMode = 0,
.priority = 0,
.baseTile = 0
}, {
.bg = 2,
.charBaseIndex = 2,
.mapBaseIndex = 28,
.screenSize = 2,
.paletteMode = 1,
.priority = 2,
.baseTile = 0
}
};
static const struct WindowTemplate gUnknown_085E5070[] = {
{ 0, 17, 17, 12, 2, 15, 0x0001 },
{ 0, 22, 1, 7, 2, 15, 0x0019 },
DUMMY_WIN_TEMPLATE
};
// .text
void sub_817018C(MainCallback callback)
{
SetVBlankCallback(NULL);
sFieldRegionMapHandler = malloc(sizeof(*sFieldRegionMapHandler));
sFieldRegionMapHandler->state = 0;
sFieldRegionMapHandler->callback = callback;
SetMainCallback2(MCB2_InitRegionMapRegisters);
}
static void MCB2_InitRegionMapRegisters(void)
{
SetGpuReg(REG_OFFSET_DISPCNT, 0);
SetGpuReg(REG_OFFSET_BG0HOFS, 0);
SetGpuReg(REG_OFFSET_BG0VOFS, 0);
SetGpuReg(REG_OFFSET_BG1HOFS, 0);
SetGpuReg(REG_OFFSET_BG1VOFS, 0);
SetGpuReg(REG_OFFSET_BG2HOFS, 0);
SetGpuReg(REG_OFFSET_BG2VOFS, 0);
SetGpuReg(REG_OFFSET_BG3HOFS, 0);
SetGpuReg(REG_OFFSET_BG3VOFS, 0);
ResetSpriteData();
FreeAllSpritePalettes();
ResetBgsAndClearDma3BusyFlags(0);
InitBgsFromTemplates(1, gUnknown_085E5068, 2);
InitWindows(gUnknown_085E5070);
DeactivateAllTextPrinters();
sub_809882C(0, 0x27, 0xd0);
clear_scheduled_bg_copies_to_vram();
SetMainCallback2(MCB2_FieldUpdateRegionMap);
SetVBlankCallback(VBCB_FieldUpdateRegionMap);
}
static void VBCB_FieldUpdateRegionMap(void)
{
LoadOam();
ProcessSpriteCopyRequests();
TransferPlttBuffer();
}
static void MCB2_FieldUpdateRegionMap(void)
{
FieldUpdateRegionMap();
AnimateSprites();
BuildOamBuffer();
UpdatePaletteFade();
do_scheduled_bg_tilemap_copies_to_vram();
}
static void FieldUpdateRegionMap(void)
{
u8 offset;
switch (sFieldRegionMapHandler->state)
{
case 0:
InitRegionMap(&sFieldRegionMapHandler->regionMap, 0);
CreateRegionMapPlayerIcon(0, 0);
CreateRegionMapCursor(1, 1);
sFieldRegionMapHandler->state++;
break;
case 1:
SetWindowBorderStyle(1, 0, 0x27, 0xd);
offset = GetStringCenterAlignXOffset(1, gText_Hoenn, 0x38);
PrintTextOnWindow(1, 1, gText_Hoenn, offset, 1, 0, NULL);
schedule_bg_copy_tilemap_to_vram(0);
SetWindowBorderStyle(0, 0, 0x27, 0xd);
PrintRegionMapSecName();
BeginNormalPaletteFade(-1, 0, 16, 0, 0);
sFieldRegionMapHandler->state++;
break;
case 2:
SetGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_OBJ_1D_MAP | DISPCNT_OBJ_ON);
ShowBg(0);
ShowBg(2);
sFieldRegionMapHandler->state++;
break;
case 3:
if (!gPaletteFade.active)
{
sFieldRegionMapHandler->state++;
}
break;
case 4:
switch (sub_81230AC())
{
case INPUT_EVENT_MOVE_END:
PrintRegionMapSecName();
break;
case INPUT_EVENT_A_BUTTON:
case INPUT_EVENT_B_BUTTON:
sFieldRegionMapHandler->state++;
break;
}
break;
case 5:
BeginNormalPaletteFade(-1, 0, 0, 16, 0);
sFieldRegionMapHandler->state++;
break;
case 6:
if (!gPaletteFade.active)
{
FreeRegionMapIconResources();
SetMainCallback2(sFieldRegionMapHandler->callback);
if (sFieldRegionMapHandler != NULL)
{
free(sFieldRegionMapHandler);
sFieldRegionMapHandler = NULL;
}
FreeAllWindowBuffers();
}
break;
}
}
static void PrintRegionMapSecName(void)
{
if (sFieldRegionMapHandler->regionMap.iconDrawType != MAPSECTYPE_NONE)
{
FillWindowPixelBuffer(0, 0x11);
PrintTextOnWindow(0, 1, sFieldRegionMapHandler->regionMap.mapSecName, 0, 1, 0, NULL);
schedule_bg_copy_tilemap_to_vram(0);
}
else
{
FillWindowPixelBuffer(0, 0x11);
CopyWindowToVram(0, 3);
}
}

View File

@@ -354,7 +354,7 @@ void sub_80FB768(void)
void sub_80FB7A4(void)
{
FlagSet(SYS_CRUISE_MODE);
FlagSet(FLAG_SYS_CRUISE_MODE);
FlagSet(0x4001);
FlagSet(0x4000);
saved_warp2_set(0, gSaveBlock1Ptr->location.mapGroup, gSaveBlock1Ptr->location.mapNum, -1);

File diff suppressed because it is too large Load Diff

83
src/heal_location.c Normal file
View File

@@ -0,0 +1,83 @@
// Includes
#include "global.h"
#include "map_constants.h"
#include "heal_location.h"
#define HEAL_LOCATION(map, x, y) {MAP_GROUP_##map, MAP_ID_##map, x, y}
// Static type declarations
// Static RAM declarations
// Static ROM declarations
// .rodata
static const struct HealLocation sHealLocations[] = {
HEAL_LOCATION(LITTLEROOT_TOWN_BRENDANS_HOUSE_2F, 4, 2),
HEAL_LOCATION(LITTLEROOT_TOWN_MAYS_HOUSE_2F, 4, 2),
HEAL_LOCATION(PETALBURG_CITY, 20, 17),
HEAL_LOCATION(SLATEPORT_CITY, 19, 20),
HEAL_LOCATION(MAUVILLE_CITY, 22, 6),
HEAL_LOCATION(RUSTBORO_CITY, 16, 39),
HEAL_LOCATION(FORTREE_CITY, 5, 7),
HEAL_LOCATION(LILYCOVE_CITY, 24, 15),
HEAL_LOCATION(MOSSDEEP_CITY, 28, 17),
HEAL_LOCATION(SOOTOPOLIS_CITY, 43, 32),
HEAL_LOCATION(EVER_GRANDE_CITY, 27, 49),
HEAL_LOCATION(LITTLEROOT_TOWN, 5, 9),
HEAL_LOCATION(LITTLEROOT_TOWN, 14, 9),
HEAL_LOCATION(OLDALE_TOWN, 6, 17),
HEAL_LOCATION(DEWFORD_TOWN, 2, 11),
HEAL_LOCATION(LAVARIDGE_TOWN, 9, 7),
HEAL_LOCATION(FALLARBOR_TOWN, 14, 8),
HEAL_LOCATION(VERDANTURF_TOWN, 16, 4),
HEAL_LOCATION(PACIFIDLOG_TOWN, 8, 16),
HEAL_LOCATION(EVER_GRANDE_CITY, 18, 6),
HEAL_LOCATION(SOUTHERN_ISLAND_EXTERIOR, 15, 20),
HEAL_LOCATION(BATTLE_FRONTIER_OUTSIDE_EAST, 3, 52)
};
#define NUM_HEAL_LOCATIONS (ARRAY_COUNT(sHealLocations))
// .text
static u32 GetHealLocationIndexFromMapGroupAndNum(u16 mapGroup, u16 mapNum)
{
u32 i;
for (i = 0; i < NUM_HEAL_LOCATIONS; i++)
{
if (sHealLocations[i].group == mapGroup && sHealLocations[i].map == mapNum)
{
return i + 1;
}
}
return 0;
}
const struct HealLocation *GetHealLocationPointerFromMapGroupAndNum(u16 mapGroup, u16 mapNum)
{
u32 loc;
loc = GetHealLocationIndexFromMapGroupAndNum(mapGroup, mapNum);
if (loc == 0)
{
return NULL;
}
return &sHealLocations[loc - 1];
}
const struct HealLocation *GetHealLocationPointer(u32 loc)
{
if (loc == 0)
{
return NULL;
}
if (loc > NUM_HEAL_LOCATIONS)
{
return NULL;
}
return &sHealLocations[loc - 1];
}

View File

@@ -165,11 +165,11 @@ bool8 HasAtLeastOneBerry(void)
{
if (CheckBagHasItem(i, 1) == TRUE)
{
gScriptResult = 1;
gSpecialVar_Result = 1;
return TRUE;
}
}
gScriptResult = 0;
gSpecialVar_Result = 0;
return FALSE;
}

View File

@@ -226,7 +226,7 @@ static EWRAM_DATA struct LilycoveLadyFavour *gUnknown_0203CD64 = NULL;
static EWRAM_DATA struct LilycoveLadyQuiz *gUnknown_0203CD68 = NULL;
static EWRAM_DATA struct LilycoveLadyContest *gUnknown_0203CD6C = NULL;
extern EWRAM_DATA u16 gScriptItemId;
extern EWRAM_DATA u16 gSpecialVar_ItemId;
u8 GetLilycoveLadyId(void)
{
@@ -242,11 +242,11 @@ void sub_818D9C0(void)
{
lilycoveLady = &gSaveBlock1Ptr->lilycoveLady;
VarSet(VAR_0x4011, gUnknown_0860B074[lilycoveLady->contest.category]);
gScriptResult = TRUE;
gSpecialVar_Result = TRUE;
}
else
{
gScriptResult = FALSE;
gSpecialVar_Result = FALSE;
}
}
@@ -308,7 +308,7 @@ void SetLilycoveLadyRandomly(void)
void sub_818DAEC(void)
{
gScriptResult = GetLilycoveLadyId();
gSpecialVar_Result = GetLilycoveLadyId();
}
static u8 sub_818DB04(const u16 *data)
@@ -459,7 +459,7 @@ static bool8 sub_818DD84(u16 itemId)
bool8 sub_818DE44(void)
{
return sub_818DD84(gScriptItemId);
return sub_818DD84(gSpecialVar_ItemId);
}
bool8 sub_818DE5C(void)
@@ -845,7 +845,7 @@ void sub_818E47C(void)
void sub_818E490(void)
{
RemoveBagItem(gScriptItemId, 1);
RemoveBagItem(gSpecialVar_ItemId, 1);
}
void sub_818E4A4(void)
@@ -853,7 +853,7 @@ void sub_818E4A4(void)
u8 i;
gUnknown_0203CD68 = &gSaveBlock1Ptr->lilycoveLady.quiz;
gUnknown_0203CD68->itemId = gScriptItemId;
gUnknown_0203CD68->itemId = gSpecialVar_ItemId;
for (i = 0; i < 4; i ++)
{
gUnknown_0203CD68->playerTrainerId[i] = gSaveBlock2Ptr->playerTrainerId[i];

View File

@@ -314,7 +314,7 @@ static void InitLocalLinkPlayer(void)
gLocalLinkPlayer.version = gGameVersion + 0x4000;
gLocalLinkPlayer.lp_field_2 = 0x8000;
gLocalLinkPlayer.name[8] = IsNationalPokedexEnabled();
if (FlagGet(SYS_UNKNOWN_87F))
if (FlagGet(FLAG_SYS_UNKNOWN_87F))
{
gLocalLinkPlayer.name[8] |= 0x10;
}
@@ -678,7 +678,7 @@ static void BuildSendCmd(u16 command)
break;
case LINKCMD_0xAAAB:
gSendCmd[0] = LINKCMD_0xAAAB;
gSendCmd[1] = gScriptItemId;
gSendCmd[1] = gSpecialVar_ItemId;
break;
case LINKCMD_0xCCCC:
gSendCmd[0] = LINKCMD_0xCCCC;

View File

@@ -42,7 +42,7 @@ void SetRandomLotteryNumber(u16 i)
void RetrieveLotteryNumber(void)
{
u16 lottoNumber = GetLotteryNumber();
gScriptResult = lottoNumber;
gSpecialVar_Result = lottoNumber;
}
void PickLotteryCornerTicket(void)
@@ -66,7 +66,7 @@ void PickLotteryCornerTicket(void)
if (!GetMonData(pkmn, MON_DATA_IS_EGG))
{
u32 otId = GetMonData(pkmn, MON_DATA_OT_ID);
u8 numMatchingDigits = GetMatchingDigits(gScriptResult, otId);
u8 numMatchingDigits = GetMatchingDigits(gSpecialVar_Result, otId);
if (numMatchingDigits > gSpecialVar_0x8004 && numMatchingDigits > 1)
{
@@ -90,7 +90,7 @@ void PickLotteryCornerTicket(void)
!GetBoxMonData(&gPokemonStoragePtr->boxes[i][j], MON_DATA_IS_EGG))
{
u32 otId = GetBoxMonData(&gPokemonStoragePtr->boxes[i][j], MON_DATA_OT_ID);
u8 numMatchingDigits = GetMatchingDigits(gScriptResult, otId);
u8 numMatchingDigits = GetMatchingDigits(gSpecialVar_Result, otId);
if (numMatchingDigits > gSpecialVar_0x8004 && numMatchingDigits > 1)
{

View File

@@ -386,7 +386,7 @@ bool8 sub_81215EC(void)
CopyBgTilemapBufferToVram(2);
break;
case 12:
LoadPalette(sub_8098C64(), 240, 32);
LoadPalette(GetOverworldTextboxPalettePtr(), 240, 32);
gPlttBufferUnfaded[250] = gUnknown_0859F2B8[gUnknown_0203A134->mailType].color10;
gPlttBufferFaded[250] = gUnknown_0859F2B8[gUnknown_0203A134->mailType].color10;
gPlttBufferUnfaded[251] = gUnknown_0859F2B8[gUnknown_0203A134->mailType].color12;

View File

@@ -59,7 +59,7 @@ extern void ResetContestLinkResults(void);
extern void ResetPokeJumpResults(void);
extern void SetBerryPowder(u32* powder, u32 newValue);
extern u8 gUnknown_082715DE[];
extern u8 EventScript_2715DE[];
void WriteUnalignedWord(u32 var, u8 *dataPtr)
{
@@ -198,7 +198,7 @@ void NewGameInitData(void)
ResetFanClub();
ResetLotteryCorner();
WarpToTruck();
ScriptContext2_RunNewScript(gUnknown_082715DE);
ScriptContext2_RunNewScript(EventScript_2715DE);
ResetMiniGamesResults();
copy_strings_to_sav1();
SetLilycoveLady();

View File

@@ -1087,10 +1087,10 @@ u8 SendMonToPC(struct Pokemon* mon)
{
MonRestorePP(mon);
CopyMon(checkingMon, &mon->box, sizeof(mon->box));
gSpecialVar_0x8012 = boxNo;
gSpecialVar_0x8013 = boxPos;
gSpecialVar_MonBoxId = boxNo;
gSpecialVar_MonBoxPos = boxPos;
if (get_unknown_box_id() != boxNo)
FlagClear(SYS_STORAGE_UNKNOWN_FLAG);
FlagClear(FLAG_SYS_STORAGE_UNKNOWN_FLAG);
VarSet(VAR_STORAGE_UNKNOWN, boxNo);
return MON_GIVEN_TO_PC;
}

View File

@@ -1234,12 +1234,12 @@ static void sub_806E6CC(u8 taskId)
DestroyTask(taskId);
}
const u8 *pokemon_get_pal(struct Pokemon *mon)
const u8 *GetMonFrontSpritePal(struct Pokemon *mon)
{
u16 species = GetMonData(mon, MON_DATA_SPECIES2, 0);
u32 otId = GetMonData(mon, MON_DATA_OT_ID, 0);
u32 personality = GetMonData(mon, MON_DATA_PERSONALITY, 0);
return species_and_otid_get_pal(species, otId, personality);
return GetFrontSpritePalFromSpeciesAndPersonality(species, otId, personality);
}
// Extracts the upper 16 bits of a 32-bit number
@@ -1248,7 +1248,7 @@ const u8 *pokemon_get_pal(struct Pokemon *mon)
// Extracts the lower 16 bits of a 32-bit number
#define LOHALF(n) ((n) & 0xFFFF)
const u8 *species_and_otid_get_pal(u16 species, u32 otId, u32 personality)
const u8 *GetFrontSpritePalFromSpeciesAndPersonality(u16 species, u32 otId, u32 personality)
{
u32 shinyValue;

View File

@@ -109,13 +109,13 @@ static void FormatMonSizeRecord(u8 *string, u32 size)
static u8 CompareMonSize(u16 species, u16 *sizeRecord)
{
if (gScriptResult == 0xFF)
if (gSpecialVar_Result == 0xFF)
{
return 0;
}
else
{
struct Pokemon *pkmn = &gPlayerParty[gScriptResult];
struct Pokemon *pkmn = &gPlayerParty[gSpecialVar_Result];
if (GetMonData(pkmn, MON_DATA_IS_EGG) == TRUE || GetMonData(pkmn, MON_DATA_SPECIES) != species)
{
@@ -173,7 +173,7 @@ void CompareSeedotSize(void)
{
u16 *sizeRecord = GetVarPointer(VAR_SEEDOT_SIZE_RECORD);
gScriptResult = CompareMonSize(SPECIES_SEEDOT, sizeRecord);
gSpecialVar_Result = CompareMonSize(SPECIES_SEEDOT, sizeRecord);
}
void InitLotadSizeRecord(void)
@@ -192,7 +192,7 @@ void CompareLotadSize(void)
{
u16 *sizeRecord = GetVarPointer(VAR_LOTAD_SIZE_RECORD);
gScriptResult = CompareMonSize(SPECIES_LOTAD, sizeRecord);
gSpecialVar_Result = CompareMonSize(SPECIES_LOTAD, sizeRecord);
}
void GiveGiftRibbonToParty(u8 index, u8 ribbonId)
@@ -217,6 +217,6 @@ void GiveGiftRibbonToParty(u8 index, u8 ribbonId)
}
}
if (gotRibbon)
FlagSet(SYS_RIBBON_GET);
FlagSet(FLAG_SYS_RIBBON_GET);
}
}

View File

@@ -1,15 +1,122 @@
// Includes
#include "global.h"
// Static type declarations
// Static RAM declarations
#include "pokemon_storage_system.h"
#include "pokemon.h"
#include "species.h"
#include "event_data.h"
#include "string_util.h"
#include "text.h"
IWRAM_DATA u8 gUnknown_03000F78[0x188];
// Static ROM declarations
u8 CountMonsInBox(u8 boxId)
{
u16 i, count;
// .rodata
for (i = 0, count = 0; i < IN_BOX_COUNT; i++)
{
if (GetBoxMonDataFromAnyBox(boxId, i, MON_DATA_SPECIES) != SPECIES_NONE)
count++;
}
// .text
return count;
}
s16 GetFirstFreeBoxSpot(u8 boxId)
{
u16 i;
for (i = 0; i < IN_BOX_COUNT; i++)
{
if (GetBoxMonDataFromAnyBox(boxId, i, MON_DATA_SPECIES) == SPECIES_NONE)
return i;
}
return -1; // all spots are taken
}
u8 CountPartyNonEggMons(void)
{
u16 i, count;
for (i = 0, count = 0; i < PARTY_SIZE; i++)
{
if (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES) != SPECIES_NONE
&& !GetMonData(&gPlayerParty[i], MON_DATA_IS_EGG))
{
count++;
}
}
return count;
}
u8 CountPartyAliveNonEggMonsExcept(u8 slotToIgnore)
{
u16 i, count;
for (i = 0, count = 0; i < PARTY_SIZE; i++)
{
if (i != slotToIgnore
&& GetMonData(&gPlayerParty[i], MON_DATA_SPECIES) != SPECIES_NONE
&& !GetMonData(&gPlayerParty[i], MON_DATA_IS_EGG)
&& GetMonData(&gPlayerParty[i], MON_DATA_HP) != 0)
{
count++;
}
}
return count;
}
u16 CountPartyAliveNonEggMons_IgnoreVar0x8004Slot(void)
{
return CountPartyAliveNonEggMonsExcept(gSpecialVar_0x8004);
}
u8 CountPartyMons(void)
{
u16 i, count;
for (i = 0, count = 0; i < PARTY_SIZE; i++)
{
if (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES) != SPECIES_NONE)
{
count++;
}
}
return count;
}
static u8 *StringCopyAndFillWithSpaces(u8 *dst, const u8 *src, u16 n)
{
u8 *str;
for (str = StringCopy(dst, src); str < dst + n; str++)
*str = CHAR_SPACE;
*str = EOS;
return str;
}
/* can't match
static void sub_80C7128(u16 *dst, u16 dstToAdd, u16 dstToMul, const u16 *src, u16 srcToAdd, u16 srcToMul, u32 size, u16 count, u16 srcBy)
{
u16 i;
size <<= 0x11;
dst += (dstToMul * 32) + dstToAdd;
src += (srcToMul * srcBy) + srcToAdd;
i = 0;
if (i < count)
{
size >>= 1;
for (i = 0; i < count; i++)
{
CpuSet(src, dst, size >> 0x10);
dst += 0x20;
src += srcBy;
}
}
}*/

1949
src/region_map.c Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -37,8 +37,8 @@ extern const union AnimCmd * const * const gMonAnimationsSpriteAnimsPtrTable[];
extern void dp12_8087EA4(void);
extern void trs_config(void);
extern bool8 IsDoubleBattle(void);
extern u8 sub_80A614C(u8 bank);
extern u8 sub_80A6138(u8 bank);
extern u8 GetSubstituteSpriteDefault_Y(u8 bank);
extern u8 GetBankSpriteDefault_Y(u8 bank);
extern u8 sub_80A82E4(u8 bank);
extern void sub_806A068(u16 species, u8 bankIdentity);
extern void sub_806A12C(u16 backPicId, u8 bankIdentity);
@@ -104,7 +104,7 @@ static void CB2_ReshowBattleScreenAfterMenu(void)
gReservedSpritePaletteCount = 4;
break;
case 5:
sub_805E350();
ClearSpritesHealthboxAnimData();
break;
case 6:
if (BattleLoadAllHealthBoxesGfx(gBattleScripting.reshowHelperState))
@@ -217,7 +217,7 @@ static bool8 LoadBankSpriteGfx(u8 bank)
if (!gBattleSpritesDataPtr->bankData[bank].behindSubstitute)
BattleLoadOpponentMonSpriteGfx(&gEnemyParty[gBattlePartyID[bank]], bank);
else
BattleLoadSubstituteSpriteGfx(bank, FALSE);
BattleLoadSubstituteOrMonSpriteGfx(bank, FALSE);
}
else if (gBattleTypeFlags & BATTLE_TYPE_SAFARI && bank == 0)
DecompressTrainerBackPic(gSaveBlock2Ptr->playerGender, bank);
@@ -226,7 +226,7 @@ static bool8 LoadBankSpriteGfx(u8 bank)
else if (!gBattleSpritesDataPtr->bankData[bank].behindSubstitute)
BattleLoadPlayerMonSpriteGfx(&gPlayerParty[gBattlePartyID[bank]], bank);
else
BattleLoadSubstituteSpriteGfx(bank, FALSE);
BattleLoadSubstituteOrMonSpriteGfx(bank, FALSE);
gBattleScripting.reshowHelperState = 0;
}
@@ -250,9 +250,9 @@ static void CreateBankSprite(u8 bank)
u8 posY;
if (gBattleSpritesDataPtr->bankData[bank].behindSubstitute)
posY = sub_80A614C(bank);
posY = GetSubstituteSpriteDefault_Y(bank);
else
posY = sub_80A6138(bank);
posY = GetBankSpriteDefault_Y(bank);
if (GetBankSide(bank) != SIDE_PLAYER)
{

View File

@@ -20,10 +20,10 @@ struct PokeblockFeeder
extern u8 gBattleOutcome;
extern void* gFieldCallback;
extern u8 gUnknown_082A4B8A[];
extern u8 gUnknown_082A4B6F[];
extern u8 gUnknown_082A4B4C[];
extern u8 gUnknown_082A4B9B[];
extern u8 EventScript_2A4B8A[];
extern u8 EventScript_2A4B6F[];
extern u8 EventScript_2A4B4C[];
extern u8 EventScript_2A4B9B[];
extern const u8* const gPokeblockNames[];
extern void sub_80EE44C(u8, u8);
@@ -50,17 +50,17 @@ static void DecrementFeederStepCounters(void);
bool32 GetSafariZoneFlag(void)
{
return FlagGet(SYS_SAFARI_MODE);
return FlagGet(FLAG_SYS_SAFARI_MODE);
}
void SetSafariZoneFlag(void)
{
FlagSet(SYS_SAFARI_MODE);
FlagSet(FLAG_SYS_SAFARI_MODE);
}
void ResetSafariZoneFlag(void)
{
FlagClear(SYS_SAFARI_MODE);
FlagClear(FLAG_SYS_SAFARI_MODE);
}
void EnterSafariMode(void)
@@ -94,7 +94,7 @@ bool8 SafariZoneTakeStep(void)
sSafariZoneStepCounter--;
if (sSafariZoneStepCounter == 0)
{
ScriptContext1_SetupScript(gUnknown_082A4B8A);
ScriptContext1_SetupScript(EventScript_2A4B8A);
return TRUE;
}
return FALSE;
@@ -102,7 +102,7 @@ bool8 SafariZoneTakeStep(void)
void SafariZoneRetirePrompt(void)
{
ScriptContext1_SetupScript(gUnknown_082A4B6F);
ScriptContext1_SetupScript(EventScript_2A4B6F);
}
void sub_80FC190(void)
@@ -116,14 +116,14 @@ void sub_80FC190(void)
}
else if (gBattleOutcome == BATTLE_SAFARI_OUT_OF_BALLS)
{
ScriptContext2_RunNewScript(gUnknown_082A4B4C);
ScriptContext2_RunNewScript(EventScript_2A4B4C);
warp_in();
gFieldCallback = sub_80AF6F0;
SetMainCallback2(c2_load_new_map);
}
else if (gBattleOutcome == BATTLE_CAUGHT)
{
ScriptContext1_SetupScript(gUnknown_082A4B9B);
ScriptContext1_SetupScript(EventScript_2A4B9B);
ScriptContext1_Stop();
SetMainCallback2(c2_exit_to_overworld_1_continue_scripts_restart_music);
}
@@ -152,13 +152,13 @@ void GetPokeblockFeederInFront(void)
&& sPokeblockFeeders[i].x == x
&& sPokeblockFeeders[i].y == y)
{
gScriptResult = i;
gSpecialVar_Result = i;
StringCopy(gStringVar1, gPokeblockNames[sPokeblockFeeders[i].pokeblock.color]);
return;
}
}
gScriptResult = -1;
gSpecialVar_Result = -1;
}
void GetPokeblockFeederWithinRange(void)
@@ -181,13 +181,13 @@ void GetPokeblockFeederWithinRange(void)
y *= -1;
if ((x + y) <= 5)
{
gScriptResult = i;
gSpecialVar_Result = i;
return;
}
}
}
gScriptResult = -1;
gSpecialVar_Result = -1;
}
// unused
@@ -195,20 +195,20 @@ struct Pokeblock *SafariZoneGetPokeblockInFront(void)
{
GetPokeblockFeederInFront();
if (gScriptResult == 0xFFFF)
if (gSpecialVar_Result == 0xFFFF)
return NULL;
else
return &sPokeblockFeeders[gScriptResult].pokeblock;
return &sPokeblockFeeders[gSpecialVar_Result].pokeblock;
}
struct Pokeblock *SafariZoneGetActivePokeblock(void)
{
GetPokeblockFeederWithinRange();
if (gScriptResult == 0xFFFF)
if (gSpecialVar_Result == 0xFFFF)
return NULL;
else
return &sPokeblockFeeders[gScriptResult].pokeblock;
return &sPokeblockFeeders[gSpecialVar_Result].pokeblock;
}
void SafariZoneActivatePokeblockFeeder(u8 pkblId)
@@ -255,13 +255,13 @@ bool8 GetInFrontFeederPokeblockAndSteps(void)
{
GetPokeblockFeederInFront();
if (gScriptResult == 0xFFFF)
if (gSpecialVar_Result == 0xFFFF)
{
return FALSE;
}
ConvertIntToDecimalStringN(gStringVar2,
sPokeblockFeeders[gScriptResult].stepCounter,
sPokeblockFeeders[gSpecialVar_Result].stepCounter,
STR_CONV_MODE_LEADING_ZEROS, 3);
return TRUE;

View File

@@ -69,9 +69,9 @@ extern u16 gSpecialVar_0x8001;
extern u16 gSpecialVar_0x8002;
extern u16 gSpecialVar_0x8004;
extern u16 gScriptResult;
extern u16 gSpecialVar_Result;
extern u16 gScriptContestCategory;
extern u16 gSpecialVar_ContestCategory;
IWRAM_DATA u8 gUnknown_03000F30;
@@ -491,25 +491,25 @@ bool8 ScrCmd_random(struct ScriptContext *ctx)
{
u16 max = VarGet(ScriptReadHalfword(ctx));
gScriptResult = Random() % max;
gSpecialVar_Result = Random() % max;
return FALSE;
}
bool8 ScrCmd_additem(struct ScriptContext *ctx)
bool8 ScrCmd_giveitem(struct ScriptContext *ctx)
{
u16 itemId = VarGet(ScriptReadHalfword(ctx));
u32 quantity = VarGet(ScriptReadHalfword(ctx));
gScriptResult = AddBagItem(itemId, (u8)quantity);
gSpecialVar_Result = AddBagItem(itemId, (u8)quantity);
return FALSE;
}
bool8 ScrCmd_removeitem(struct ScriptContext *ctx)
bool8 ScrCmd_takeitem(struct ScriptContext *ctx)
{
u16 itemId = VarGet(ScriptReadHalfword(ctx));
u32 quantity = VarGet(ScriptReadHalfword(ctx));
gScriptResult = RemoveBagItem(itemId, (u8)quantity);
gSpecialVar_Result = RemoveBagItem(itemId, (u8)quantity);
return FALSE;
}
@@ -518,7 +518,7 @@ bool8 ScrCmd_checkitemspace(struct ScriptContext *ctx)
u16 itemId = VarGet(ScriptReadHalfword(ctx));
u32 quantity = VarGet(ScriptReadHalfword(ctx));
gScriptResult = CheckBagHasSpace(itemId, (u8)quantity);
gSpecialVar_Result = CheckBagHasSpace(itemId, (u8)quantity);
return FALSE;
}
@@ -527,7 +527,7 @@ bool8 ScrCmd_checkitem(struct ScriptContext *ctx)
u16 itemId = VarGet(ScriptReadHalfword(ctx));
u32 quantity = VarGet(ScriptReadHalfword(ctx));
gScriptResult = CheckBagHasItem(itemId, (u8)quantity);
gSpecialVar_Result = CheckBagHasItem(itemId, (u8)quantity);
return FALSE;
}
@@ -535,16 +535,16 @@ bool8 ScrCmd_checkitemtype(struct ScriptContext *ctx)
{
u16 itemId = VarGet(ScriptReadHalfword(ctx));
gScriptResult = GetPocketByItemId(itemId);
gSpecialVar_Result = GetPocketByItemId(itemId);
return FALSE;
}
bool8 ScrCmd_addpcitem(struct ScriptContext *ctx)
bool8 ScrCmd_givepcitem(struct ScriptContext *ctx)
{
u16 itemId = VarGet(ScriptReadHalfword(ctx));
u16 quantity = VarGet(ScriptReadHalfword(ctx));
gScriptResult = AddPCItem(itemId, quantity);
gSpecialVar_Result = AddPCItem(itemId, quantity);
return FALSE;
}
@@ -553,23 +553,31 @@ bool8 ScrCmd_checkpcitem(struct ScriptContext *ctx)
u16 itemId = VarGet(ScriptReadHalfword(ctx));
u16 quantity = VarGet(ScriptReadHalfword(ctx));
gScriptResult = CheckPCHasItem(itemId, quantity);
gSpecialVar_Result = CheckPCHasItem(itemId, quantity);
return FALSE;
}
bool8 ScrCmd_adddecor(struct ScriptContext *ctx)
bool8 ScrCmd_givedecoration(struct ScriptContext *ctx)
{
u32 decorId = VarGet(ScriptReadHalfword(ctx));
gScriptResult = DecorationAdd(decorId);
gSpecialVar_Result = DecorationAdd(decorId);
return FALSE;
}
bool8 ScrCmd_removedecor(struct ScriptContext *ctx)
bool8 ScrCmd_takedecoration(struct ScriptContext *ctx)
{
u32 decorId = VarGet(ScriptReadHalfword(ctx));
gScriptResult = DecorationRemove(decorId);
gSpecialVar_Result = DecorationRemove(decorId);
return FALSE;
}
bool8 ScrCmd_checkdecorspace(struct ScriptContext *ctx)
{
u32 decorId = VarGet(ScriptReadHalfword(ctx));
gSpecialVar_Result = DecorationCheckSpace(decorId);
return FALSE;
}
@@ -577,15 +585,7 @@ bool8 ScrCmd_checkdecor(struct ScriptContext *ctx)
{
u32 decorId = VarGet(ScriptReadHalfword(ctx));
gScriptResult = DecorationCheckSpace(decorId);
return FALSE;
}
bool8 ScrCmd_hasdecor(struct ScriptContext *ctx)
{
u32 decorId = VarGet(ScriptReadHalfword(ctx));
gScriptResult = CheckHasDecoration(decorId);
gSpecialVar_Result = CheckHasDecoration(decorId);
return FALSE;
}
@@ -613,14 +613,14 @@ bool8 ScrCmd_incrementgamestat(struct ScriptContext *ctx)
return FALSE;
}
bool8 ScrCmd_animdarklevel(struct ScriptContext *ctx)
bool8 ScrCmd_animateflash(struct ScriptContext *ctx)
{
sub_80B009C(ScriptReadByte(ctx));
ScriptContext1_Stop();
return TRUE;
}
bool8 ScrCmd_setdarklevel(struct ScriptContext *ctx)
bool8 ScrCmd_setflashradius(struct ScriptContext *ctx)
{
u16 flashLevel = VarGet(ScriptReadHalfword(ctx));
@@ -643,12 +643,12 @@ bool8 ScrCmd_fadescreen(struct ScriptContext *ctx)
return TRUE;
}
bool8 ScrCmd_fadescreendelay(struct ScriptContext *ctx)
bool8 ScrCmd_fadescreenspeed(struct ScriptContext *ctx)
{
u8 mode = ScriptReadByte(ctx);
u8 delay = ScriptReadByte(ctx);
u8 speed = ScriptReadByte(ctx);
fade_screen(mode, delay);
fade_screen(mode, speed);
SetupNativeScript(ctx, IsPaletteNotActive);
return TRUE;
}
@@ -736,7 +736,7 @@ bool8 ScrCmd_doweather(struct ScriptContext *ctx)
return FALSE;
}
bool8 ScrCmd_tileeffect(struct ScriptContext *ctx)
bool8 ScrCmd_setstepcallback(struct ScriptContext *ctx)
{
ActivatePerStepCallback(ScriptReadByte(ctx));
return FALSE;
@@ -907,9 +907,9 @@ bool8 ScrCmd_getplayerxy(struct ScriptContext *ctx)
return FALSE;
}
bool8 ScrCmd_countpokemon(struct ScriptContext *ctx)
bool8 ScrCmd_getpartysize(struct ScriptContext *ctx)
{
gScriptResult = CalculatePlayerPartyCount();
gSpecialVar_Result = CalculatePlayerPartyCount();
return FALSE;
}
@@ -1121,7 +1121,7 @@ bool8 ScrCmd_moveobjectoffscreen(struct ScriptContext *ctx)
return FALSE;
}
bool8 ScrCmd_showobject(struct ScriptContext *ctx)
bool8 ScrCmd_showobject_at(struct ScriptContext *ctx)
{
u16 localId = VarGet(ScriptReadHalfword(ctx));
u8 mapGroup = ScriptReadByte(ctx);
@@ -1131,7 +1131,7 @@ bool8 ScrCmd_showobject(struct ScriptContext *ctx)
return FALSE;
}
bool8 ScrCmd_hideobject(struct ScriptContext *ctx)
bool8 ScrCmd_hideobject_at(struct ScriptContext *ctx)
{
u16 localId = VarGet(ScriptReadHalfword(ctx));
u8 mapGroup = ScriptReadByte(ctx);
@@ -1339,7 +1339,7 @@ static bool8 WaitForAorBPress(void)
return FALSE;
}
bool8 ScrCmd_waitbutton(struct ScriptContext *ctx)
bool8 ScrCmd_waitbuttonpress(struct ScriptContext *ctx)
{
SetupNativeScript(ctx, WaitForAorBPress);
return TRUE;
@@ -1454,7 +1454,7 @@ bool8 ScrCmd_drawboxtext(struct ScriptContext *ctx)
return FALSE;
}
bool8 ScrCmd_drawpokepic(struct ScriptContext *ctx)
bool8 ScrCmd_showmonpic(struct ScriptContext *ctx)
{
u16 species = VarGet(ScriptReadHalfword(ctx));
u8 x = ScriptReadByte(ctx);
@@ -1464,7 +1464,7 @@ bool8 ScrCmd_drawpokepic(struct ScriptContext *ctx)
return FALSE;
}
bool8 ScrCmd_erasepokepic(struct ScriptContext *ctx)
bool8 ScrCmd_hidemonpic(struct ScriptContext *ctx)
{
bool8 (*func)(void) = ScriptMenu_GetPicboxWaitFunc();
@@ -1474,7 +1474,7 @@ bool8 ScrCmd_erasepokepic(struct ScriptContext *ctx)
return TRUE;
}
bool8 ScrCmd_drawcontestwinner(struct ScriptContext *ctx)
bool8 ScrCmd_showcontestwinner(struct ScriptContext *ctx)
{
u8 v1 = ScriptReadByte(ctx);
@@ -1694,7 +1694,7 @@ bool8 ScrCmd_vmessage(struct ScriptContext *ctx)
return FALSE;
}
bool8 ScrCmd_getspeciesname(struct ScriptContext *ctx)
bool8 ScrCmd_bufferspeciesname(struct ScriptContext *ctx)
{
u8 stringVarIndex = ScriptReadByte(ctx);
u16 species = VarGet(ScriptReadHalfword(ctx));
@@ -1703,7 +1703,7 @@ bool8 ScrCmd_getspeciesname(struct ScriptContext *ctx)
return FALSE;
}
bool8 ScrCmd_getfirstpartypokename(struct ScriptContext *ctx)
bool8 ScrCmd_bufferleadmonspeciesname(struct ScriptContext *ctx)
{
u8 stringVarIndex = ScriptReadByte(ctx);
@@ -1714,7 +1714,7 @@ bool8 ScrCmd_getfirstpartypokename(struct ScriptContext *ctx)
return FALSE;
}
bool8 ScrCmd_getpartypokename(struct ScriptContext *ctx)
bool8 ScrCmd_bufferpartymonnick(struct ScriptContext *ctx)
{
u8 stringVarIndex = ScriptReadByte(ctx);
u16 partyIndex = VarGet(ScriptReadHalfword(ctx));
@@ -1724,7 +1724,7 @@ bool8 ScrCmd_getpartypokename(struct ScriptContext *ctx)
return FALSE;
}
bool8 ScrCmd_getitemname(struct ScriptContext *ctx)
bool8 ScrCmd_bufferitemname(struct ScriptContext *ctx)
{
u8 stringVarIndex = ScriptReadByte(ctx);
u16 itemId = VarGet(ScriptReadHalfword(ctx));
@@ -1733,7 +1733,7 @@ bool8 ScrCmd_getitemname(struct ScriptContext *ctx)
return FALSE;
}
bool8 ScrCmd_getitemnameplural(struct ScriptContext *ctx)
bool8 ScrCmd_bufferitemnameplural(struct ScriptContext *ctx)
{
u8 stringVarIndex = ScriptReadByte(ctx);
u16 itemId = VarGet(ScriptReadHalfword(ctx));
@@ -1743,7 +1743,7 @@ bool8 ScrCmd_getitemnameplural(struct ScriptContext *ctx)
return FALSE;
}
bool8 ScrCmd_getdecorname(struct ScriptContext *ctx)
bool8 ScrCmd_bufferdecorationname(struct ScriptContext *ctx)
{
u8 stringVarIndex = ScriptReadByte(ctx);
u16 decorId = VarGet(ScriptReadHalfword(ctx));
@@ -1752,7 +1752,7 @@ bool8 ScrCmd_getdecorname(struct ScriptContext *ctx)
return FALSE;
}
bool8 ScrCmd_getmovename(struct ScriptContext *ctx)
bool8 ScrCmd_buffermovename(struct ScriptContext *ctx)
{
u8 stringVarIndex = ScriptReadByte(ctx);
u16 moveId = VarGet(ScriptReadHalfword(ctx));
@@ -1761,7 +1761,7 @@ bool8 ScrCmd_getmovename(struct ScriptContext *ctx)
return FALSE;
}
bool8 ScrCmd_getnumberstring(struct ScriptContext *ctx)
bool8 ScrCmd_buffernumberstring(struct ScriptContext *ctx)
{
u8 stringVarIndex = ScriptReadByte(ctx);
u16 v1 = VarGet(ScriptReadHalfword(ctx));
@@ -1771,7 +1771,7 @@ bool8 ScrCmd_getnumberstring(struct ScriptContext *ctx)
return FALSE;
}
bool8 ScrCmd_getstdstring(struct ScriptContext *ctx)
bool8 ScrCmd_bufferstdstring(struct ScriptContext *ctx)
{
u8 stringVarIndex = ScriptReadByte(ctx);
u16 index = VarGet(ScriptReadHalfword(ctx));
@@ -1780,7 +1780,7 @@ bool8 ScrCmd_getstdstring(struct ScriptContext *ctx)
return FALSE;
}
bool8 ScrCmd_getcontesttype(struct ScriptContext *ctx)
bool8 ScrCmd_buffercontesttype(struct ScriptContext *ctx)
{
u8 stringVarIndex = ScriptReadByte(ctx);
u16 index = VarGet(ScriptReadHalfword(ctx));
@@ -1789,7 +1789,7 @@ bool8 ScrCmd_getcontesttype(struct ScriptContext *ctx)
return FALSE;
}
bool8 ScrCmd_getstring(struct ScriptContext *ctx)
bool8 ScrCmd_bufferstring(struct ScriptContext *ctx)
{
u8 stringVarIndex = ScriptReadByte(ctx);
const u8 *text = (u8 *)ScriptReadWord(ctx);
@@ -1806,7 +1806,7 @@ bool8 ScrCmd_vloadword(struct ScriptContext *ctx)
return FALSE;
}
bool8 ScrCmd_vgetstring(struct ScriptContext *ctx)
bool8 ScrCmd_vbufferstring(struct ScriptContext *ctx)
{
u8 stringVarIndex = ScriptReadByte(ctx);
u32 addr = ScriptReadWord(ctx);
@@ -1817,7 +1817,7 @@ bool8 ScrCmd_vgetstring(struct ScriptContext *ctx)
return FALSE;
}
bool8 ScrCmd_getboxname(struct ScriptContext *ctx)
bool8 ScrCmd_bufferboxname(struct ScriptContext *ctx)
{
u8 stringVarIndex = ScriptReadByte(ctx);
u16 boxId = VarGet(ScriptReadHalfword(ctx));
@@ -1826,7 +1826,7 @@ bool8 ScrCmd_getboxname(struct ScriptContext *ctx)
return FALSE;
}
bool8 ScrCmd_givepoke(struct ScriptContext *ctx)
bool8 ScrCmd_givemon(struct ScriptContext *ctx)
{
u16 species = VarGet(ScriptReadHalfword(ctx));
u8 level = ScriptReadByte(ctx);
@@ -1835,7 +1835,7 @@ bool8 ScrCmd_givepoke(struct ScriptContext *ctx)
u32 unkParam2 = ScriptReadWord(ctx);
u8 unkParam3 = ScriptReadByte(ctx);
gScriptResult = ScriptGiveMon(species, level, item, unkParam1, unkParam2, unkParam3);
gSpecialVar_Result = ScriptGiveMon(species, level, item, unkParam1, unkParam2, unkParam3);
return FALSE;
}
@@ -1843,11 +1843,11 @@ bool8 ScrCmd_giveegg(struct ScriptContext *ctx)
{
u16 species = VarGet(ScriptReadHalfword(ctx));
gScriptResult = ScriptGiveEgg(species);
gSpecialVar_Result = ScriptGiveEgg(species);
return FALSE;
}
bool8 ScrCmd_setpokemove(struct ScriptContext *ctx)
bool8 ScrCmd_setmonmove(struct ScriptContext *ctx)
{
u8 partyIndex = ScriptReadByte(ctx);
u8 slot = ScriptReadByte(ctx);
@@ -1857,12 +1857,12 @@ bool8 ScrCmd_setpokemove(struct ScriptContext *ctx)
return FALSE;
}
bool8 ScrCmd_checkpokemove(struct ScriptContext *ctx)
bool8 ScrCmd_checkpartymove(struct ScriptContext *ctx)
{
u8 i;
u16 moveId = ScriptReadHalfword(ctx);
gScriptResult = 6;
gSpecialVar_Result = 6;
for (i = 0; i < 6; i++)
{
u16 species = GetMonData(&gPlayerParty[i], MON_DATA_SPECIES, NULL);
@@ -1871,7 +1871,7 @@ bool8 ScrCmd_checkpokemove(struct ScriptContext *ctx)
// UB: GetMonData() arguments don't match function definition
if (!GetMonData(&gPlayerParty[i], MON_DATA_IS_EGG) && pokemon_has_move(&gPlayerParty[i], moveId) == TRUE)
{
gScriptResult = i;
gSpecialVar_Result = i;
gSpecialVar_0x8004 = species;
break;
}
@@ -1905,7 +1905,7 @@ bool8 ScrCmd_checkmoney(struct ScriptContext *ctx)
u8 ignore = ScriptReadByte(ctx);
if (!ignore)
gScriptResult = IsEnoughMoney(&gSaveBlock1Ptr->money, amount);
gSpecialVar_Result = IsEnoughMoney(&gSaveBlock1Ptr->money, amount);
return FALSE;
}
@@ -1973,7 +1973,7 @@ bool8 ScrCmd_trainerbattle(struct ScriptContext *ctx)
return FALSE;
}
bool8 ScrCmd_battlebegin(struct ScriptContext *ctx)
bool8 ScrCmd_dotrainerbattle(struct ScriptContext *ctx)
{
BattleSetup_StartTrainerBattle();
return TRUE;
@@ -2041,7 +2041,7 @@ bool8 ScrCmd_pokemart(struct ScriptContext *ctx)
return TRUE;
}
bool8 ScrCmd_pokemartdecor(struct ScriptContext *ctx)
bool8 ScrCmd_pokemartdecoration(struct ScriptContext *ctx)
{
const void *ptr = (void *)ScriptReadWord(ctx);
@@ -2050,7 +2050,7 @@ bool8 ScrCmd_pokemartdecor(struct ScriptContext *ctx)
return TRUE;
}
bool8 ScrCmd_pokemartbp(struct ScriptContext *ctx)
bool8 ScrCmd_pokemartdecoration2(struct ScriptContext *ctx)
{
const void *ptr = (void *)ScriptReadWord(ctx);
@@ -2068,7 +2068,7 @@ bool8 ScrCmd_playslotmachine(struct ScriptContext *ctx)
return TRUE;
}
bool8 ScrCmd_plantberrytree(struct ScriptContext *ctx)
bool8 ScrCmd_setberrytree(struct ScriptContext *ctx)
{
u8 treeId = ScriptReadByte(ctx);
u8 berry = ScriptReadByte(ctx);
@@ -2085,7 +2085,7 @@ bool8 ScrCmd_getpricereduction(struct ScriptContext *ctx)
{
u16 value = VarGet(ScriptReadHalfword(ctx));
gScriptResult = GetPriceReduction(value);
gSpecialVar_Result = GetPriceReduction(value);
return FALSE;
}
@@ -2113,7 +2113,7 @@ bool8 ScrCmd_showcontestresults(struct ScriptContext *ctx)
bool8 ScrCmd_contestlinktransfer(struct ScriptContext *ctx)
{
sub_80F84C4(gScriptContestCategory);
sub_80F84C4(gSpecialVar_ContestCategory);
ScriptContext1_Stop();
return TRUE;
}
@@ -2127,7 +2127,7 @@ bool8 ScrCmd_dofieldeffect(struct ScriptContext *ctx)
return FALSE;
}
bool8 ScrCmd_setfieldeffect(struct ScriptContext *ctx)
bool8 ScrCmd_setfieldeffectarg(struct ScriptContext *ctx)
{
u8 argNum = ScriptReadByte(ctx);
@@ -2150,7 +2150,7 @@ bool8 ScrCmd_waitfieldeffect(struct ScriptContext *ctx)
return TRUE;
}
bool8 ScrCmd_sethealplace(struct ScriptContext *ctx)
bool8 ScrCmd_setrespawn(struct ScriptContext *ctx)
{
u16 healLocationId = VarGet(ScriptReadHalfword(ctx));
@@ -2160,11 +2160,11 @@ bool8 ScrCmd_sethealplace(struct ScriptContext *ctx)
bool8 ScrCmd_checkplayergender(struct ScriptContext *ctx)
{
gScriptResult = gSaveBlock2Ptr->playerGender;
gSpecialVar_Result = gSaveBlock2Ptr->playerGender;
return FALSE;
}
bool8 ScrCmd_playpokecry(struct ScriptContext *ctx)
bool8 ScrCmd_playmoncry(struct ScriptContext *ctx)
{
u16 species = VarGet(ScriptReadHalfword(ctx));
u16 mode = VarGet(ScriptReadHalfword(ctx));
@@ -2173,13 +2173,13 @@ bool8 ScrCmd_playpokecry(struct ScriptContext *ctx)
return FALSE;
}
bool8 ScrCmd_waitpokecry(struct ScriptContext *ctx)
bool8 ScrCmd_waitmoncry(struct ScriptContext *ctx)
{
SetupNativeScript(ctx, IsCryFinished);
return TRUE;
}
bool8 ScrCmd_setmaptile(struct ScriptContext *ctx)
bool8 ScrCmd_setmetatile(struct ScriptContext *ctx)
{
u16 x = VarGet(ScriptReadHalfword(ctx));
u16 y = VarGet(ScriptReadHalfword(ctx));
@@ -2285,9 +2285,9 @@ bool8 ScrCmd_givecoins(struct ScriptContext *ctx)
u16 coins = VarGet(ScriptReadHalfword(ctx));
if (GiveCoins(coins) == TRUE)
gScriptResult = 0;
gSpecialVar_Result = 0;
else
gScriptResult = 1;
gSpecialVar_Result = 1;
return FALSE;
}
@@ -2296,9 +2296,9 @@ bool8 ScrCmd_takecoins(struct ScriptContext *ctx)
u16 coins = VarGet(ScriptReadHalfword(ctx));
if (TakeCoins(coins) == TRUE)
gScriptResult = 0;
gSpecialVar_Result = 0;
else
gScriptResult = 1;
gSpecialVar_Result = 1;
return FALSE;
}
@@ -2353,8 +2353,8 @@ bool8 ScrCmd_cmdD9(struct ScriptContext *ctx)
}
}
// This command will force the Pokémon to be obedient, you don't get to choose which value to set its obedience to
bool8 ScrCmd_setpokeobedient(struct ScriptContext *ctx)
// This command will force the Pokémon to be obedient, you don't get to make it disobedient
bool8 ScrCmd_setmonobedient(struct ScriptContext *ctx)
{
bool8 obedient = TRUE;
u16 partyIndex = VarGet(ScriptReadHalfword(ctx));
@@ -2363,11 +2363,11 @@ bool8 ScrCmd_setpokeobedient(struct ScriptContext *ctx)
return FALSE;
}
bool8 ScrCmd_checkpokeobedience(struct ScriptContext *ctx)
bool8 ScrCmd_checkmonobedience(struct ScriptContext *ctx)
{
u16 partyIndex = VarGet(ScriptReadHalfword(ctx));
gScriptResult = GetMonData(&gPlayerParty[partyIndex], MON_DATA_OBEDIENCE, NULL);
gSpecialVar_Result = GetMonData(&gPlayerParty[partyIndex], MON_DATA_OBEDIENCE, NULL);
return FALSE;
}
@@ -2398,7 +2398,7 @@ bool8 ScrCmd_warpD1(struct ScriptContext *ctx)
return TRUE;
}
bool8 ScrCmd_setpokemetlocation(struct ScriptContext *ctx)
bool8 ScrCmd_setmonmetlocation(struct ScriptContext *ctx)
{
u16 partyIndex = VarGet(ScriptReadHalfword(ctx));
u8 location = ScriptReadByte(ctx);
@@ -2414,7 +2414,7 @@ void sub_809BDB4(void)
RemoveWindow(gUnknown_03000F30);
}
bool8 ScrCmd_gettrainerclass(struct ScriptContext *ctx)
bool8 ScrCmd_buffertrainerclassname(struct ScriptContext *ctx)
{
u8 stringVarIndex = ScriptReadByte(ctx);
u16 trainerClassId = VarGet(ScriptReadHalfword(ctx));
@@ -2423,7 +2423,7 @@ bool8 ScrCmd_gettrainerclass(struct ScriptContext *ctx)
return FALSE;
}
bool8 ScrCmd_gettrainername(struct ScriptContext *ctx)
bool8 ScrCmd_buffertrainername(struct ScriptContext *ctx)
{
u8 stringVarIndex = ScriptReadByte(ctx);
u16 trainerClassId = VarGet(ScriptReadHalfword(ctx));

View File

@@ -175,14 +175,14 @@ void sub_80E8B6C(void)
{
u16 i;
gScriptResult = FALSE;
gSpecialVar_Result = FALSE;
for (i = 0; i < 20; i ++)
{
if (sCurSecretBaseId != gSaveBlock1Ptr->secretBases[i].secretBaseId)
{
continue;
}
gScriptResult = TRUE;
gSpecialVar_Result = TRUE;
VarSet(VAR_0x4054, i);
break;
}
@@ -192,11 +192,11 @@ void sub_80E8BC8(void)
{
if (gSaveBlock1Ptr->secretBases[0].secretBaseId != 0)
{
gScriptResult = TRUE;
gSpecialVar_Result = TRUE;
}
else
{
gScriptResult = FALSE;
gSpecialVar_Result = FALSE;
}
}
@@ -544,22 +544,22 @@ void sub_80E933C(void)
metatile = MapGridGetMetatileBehaviorAt(gSpecialVar_0x8006 + 7, gSpecialVar_0x8007 + 7);
if (MetatileBehavior_IsMB_B5(metatile) == TRUE || MetatileBehavior_IsMB_C3(metatile) == TRUE)
{
gScriptResult = gMapHeader.events->mapObjects[objIdx].graphicsId + VAR_0x3F20;
VarSet(gScriptResult, gDecorations[roomDecor[decorIdx]].tiles[0]);
gScriptResult = gMapHeader.events->mapObjects[objIdx].localId;
gSpecialVar_Result = gMapHeader.events->mapObjects[objIdx].graphicsId + VAR_0x3F20;
VarSet(gSpecialVar_Result, gDecorations[roomDecor[decorIdx]].tiles[0]);
gSpecialVar_Result = gMapHeader.events->mapObjects[objIdx].localId;
FlagClear(gSpecialVar_0x8004 + 0xAE);
show_sprite(gScriptResult, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup);
sub_808EBA8(gScriptResult, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup, gSpecialVar_0x8006, gSpecialVar_0x8007);
sub_808F254(gScriptResult, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup);
show_sprite(gSpecialVar_Result, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup);
sub_808EBA8(gSpecialVar_Result, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup, gSpecialVar_0x8006, gSpecialVar_0x8007);
sub_808F254(gSpecialVar_Result, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup);
if (CurrentMapIsSecretBase() == TRUE && VarGet(VAR_0x4054) != 0)
{
if (category == DECORCAT_DOLL)
{
sub_808F28C(gScriptResult, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup, DECORCAT_DOLL);
sub_808F28C(gSpecialVar_Result, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup, DECORCAT_DOLL);
}
else if (category == DECORCAT_CUSHION)
{
sub_808F28C(gScriptResult, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup, DECORCAT_CUSHION);
sub_808F28C(gSpecialVar_Result, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup, DECORCAT_CUSHION);
}
}
gSpecialVar_0x8004 ++;
@@ -608,14 +608,14 @@ void sub_80E9668(struct Coords16 *coords, struct MapEvents *events)
{
sub_80E9608(coords, events);
sub_80E8B6C();
ScriptContext1_SetupScript(gUnknown_08275BB7);
ScriptContext1_SetupScript(EventScript_275BB7);
}
bool8 sub_80E9680(void)
{
sub_80E8B58();
sub_80E8B6C();
if (gScriptResult == TRUE)
if (gSpecialVar_Result == TRUE)
{
return FALSE;
}
@@ -657,11 +657,11 @@ void sub_80E9744(void)
{
if (gSaveBlock1Ptr->secretBases[0].secretBaseId != sCurSecretBaseId)
{
gScriptResult = TRUE;
gSpecialVar_Result = TRUE;
}
else
{
gScriptResult = FALSE;
gSpecialVar_Result = FALSE;
}
}
@@ -1016,15 +1016,15 @@ void sub_80E9BDC(void)
{
if (sub_80E9878(VarGet(VAR_0x4054)) == TRUE)
{
gScriptResult = 1;
gSpecialVar_Result = 1;
}
else if (sub_80E9BA8() > 9)
{
gScriptResult = 2;
gSpecialVar_Result = 2;
}
else
{
gScriptResult = 0;
gSpecialVar_Result = 0;
}
}
@@ -1289,41 +1289,41 @@ const u8 *sub_80EA250(void)
param = sub_80EA20C(VarGet(VAR_0x4054));
if (param == 0)
{
return gUnknown_08274966;
return SecretBase_RedCave1_Text_274966;
}
if (param == 1)
{
return gUnknown_08274D13;
return SecretBase_RedCave1_Text_274D13;
}
if (param == 2)
{
return gUnknown_08274FFE;
return SecretBase_RedCave1_Text_274FFE;
}
if (param == 3)
{
return gUnknown_08275367;
return SecretBase_RedCave1_Text_275367;
}
if (param == 4)
{
return gUnknown_082756C7;
return SecretBase_RedCave1_Text_2756C7;
}
if (param == 5)
{
return gUnknown_08274B24;
return SecretBase_RedCave1_Text_274B24;
}
if (param == 6)
{
return gUnknown_08274E75;
return SecretBase_RedCave1_Text_274E75;
}
if (param == 7)
{
return gUnknown_082751E1;
return SecretBase_RedCave1_Text_2751E1;
}
if (param == 8)
{
return gUnknown_082754F6;
return SecretBase_RedCave1_Text_2754F6;
}
return gUnknown_082758CC;
return SecretBase_RedCave1_Text_2758CC;
}
void sub_80EA2E4(void)
@@ -1335,7 +1335,7 @@ void sub_80EA2E4(void)
void sub_80EA30C(void)
{
gSaveBlock1Ptr->secretBases[VarGet(VAR_0x4054)].sbr_field_1_5 = gScriptResult;
gSaveBlock1Ptr->secretBases[VarGet(VAR_0x4054)].sbr_field_1_5 = gSpecialVar_Result;
}
void sub_80EA354(void)
@@ -1353,7 +1353,7 @@ void sub_80EA354(void)
FlagSet(0x922);
}
gSpecialVar_0x8004 = sub_80EA20C(secretBaseRecordId);
gScriptResult = gSaveBlock1Ptr->secretBases[secretBaseRecordId].sbr_field_1_5;
gSpecialVar_Result = gSaveBlock1Ptr->secretBases[secretBaseRecordId].sbr_field_1_5;
}

View File

@@ -74,12 +74,12 @@ void AddStartMenuAction(u8 action)
static void BuildStartMenuActions_Normal(void)
{
if (FlagGet(SYS_POKEDEX_GET) == TRUE)
if (FlagGet(FLAG_SYS_POKEDEX_GET) == TRUE)
AddStartMenuAction(MENU_ACTION_POKEDEX);
if (FlagGet(SYS_POKEMON_GET) == TRUE)
if (FlagGet(FLAG_SYS_POKEMON_GET) == TRUE)
AddStartMenuAction(MENU_ACTION_POKEMON);
AddStartMenuAction(MENU_ACTION_BAG);
if (FlagGet(SYS_POKENAV_GET) == TRUE)
if (FlagGet(FLAG_SYS_POKENAV_GET) == TRUE)
AddStartMenuAction(MENU_ACTION_POKENAV);
AddStartMenuAction(MENU_ACTION_PLAYER);
AddStartMenuAction(MENU_ACTION_SAVE);
@@ -102,7 +102,7 @@ static void BuildStartMenuActions_LinkMode(void)
{
AddStartMenuAction(MENU_ACTION_POKEMON);
AddStartMenuAction(MENU_ACTION_BAG);
if (FlagGet(SYS_POKENAV_GET) == TRUE)
if (FlagGet(FLAG_SYS_POKENAV_GET) == TRUE)
AddStartMenuAction(MENU_ACTION_POKENAV);
AddStartMenuAction(MENU_ACTION_PLAYER_LINK);
AddStartMenuAction(MENU_ACTION_OPTION);
@@ -113,7 +113,7 @@ static void BuildStartMenuActions_UnionRoom(void)
{
AddStartMenuAction(MENU_ACTION_POKEMON);
AddStartMenuAction(MENU_ACTION_BAG);
if (FlagGet(SYS_POKENAV_GET) == TRUE)
if (FlagGet(FLAG_SYS_POKENAV_GET) == TRUE)
AddStartMenuAction(MENU_ACTION_POKENAV);
AddStartMenuAction(MENU_ACTION_PLAYER);
AddStartMenuAction(MENU_ACTION_OPTION);

391
src/starter_choose.c Normal file
View File

@@ -0,0 +1,391 @@
#include "global.h"
#include "starter_choose.h"
#include "palette.h"
#include "sprite.h"
#include "pokemon.h"
#include "task.h"
#include "bg.h"
#include "gpu_regs.h"
#include "main.h"
#include "window.h"
#include "text.h"
#include "decompress.h"
#include "menu.h"
#include "sound.h"
#include "songs.h"
#include "event_data.h"
#include "pokedex.h"
#include "data2.h"
#include "international_string_util.h"
#include "trig.h"
#define STARTER_MON_COUNT 3
// Position of the sprite of the selected starter Pokemon
#define STARTER_PKMN_POS_X 120
#define STARTER_PKMN_POS_Y 64
// graphics
extern const u32 gBirchHelpGfx[];
extern const u32 gBirchBagTilemap[];
extern const u32 gBirchGrassTilemap[];
extern const u16 gBirchBagGrassPal[];
// text
extern const u8 gText_BirchInTrouble[];
extern const u8 gText_ConfirmStarterChoice[];
extern const u16 sStarterMon[STARTER_MON_COUNT];
extern const struct BgTemplate gUnknown_085B1E00[3];
extern const struct WindowTemplate gUnknown_085B1DCC[];
extern const struct WindowTemplate gUnknown_085B1DDC;
extern const struct CompressedSpriteSheet gUnknown_085B1ED8[];
extern const struct CompressedSpriteSheet gUnknown_085B1EE8[];
extern const struct SpritePalette gUnknown_085B1EF8[];
extern const struct SpriteTemplate sSpriteTemplate_PokeBall;
extern const struct SpriteTemplate sSpriteTemplate_Hand;
extern const struct SpriteTemplate gUnknown_085B1F40;
extern const union AffineAnimCmd *const gUnknown_085B1ED0;
extern const u8 sPokeballCoords[STARTER_MON_COUNT][2];
extern const struct WindowTemplate gUnknown_085B1DE4;
extern const u8 gStarterChoose_LabelCoords[][2];
extern const u8 gUnknown_085B1E0C[];
extern const u8 gUnknown_085B1E28[][2];
extern void sub_809882C(u8, u16, u8);
extern void remove_some_task(void);
extern void clear_scheduled_bg_copies_to_vram(void);
extern void dp13_810BB8C(void);
extern void do_scheduled_bg_tilemap_copies_to_vram(void);
extern u16 sub_818D820(u16);
extern const u16 *GetOverworldTextboxPalettePtr(void);
extern u8 sub_818D3E4(u16 species, u32 trainerId, u32 personality, u8 flags, s16 x, s16 y, u8, u16);
// this file's functions
static void MainCallback2_StarterChoose(void);
static void sub_8134604(void);
static void Task_StarterChoose1(u8 taskId);
static void Task_StarterChoose2(u8 taskId);
static void Task_StarterChoose3(u8 taskId);
static void Task_StarterChoose4(u8 taskId);
static void Task_StarterChoose5(u8 taskId);
static void Task_StarterChoose6(u8 taskId);
static void Task_MoveStarterChooseCursor(u8 taskId);
static void sub_8134668(u8 taskId);
static void CreateStarterPokemonLabel(u8 selection);
static u8 CreatePokemonFrontSprite(u16 species, u8 x, u8 y);
static void StarterPokemonSpriteCallback(struct Sprite *sprite);
static IWRAM_DATA u16 sStarterChooseWindowId;
u16 GetStarterPokemon(u16 chosenStarterId)
{
if (chosenStarterId > STARTER_MON_COUNT)
chosenStarterId = 0;
return sStarterMon[chosenStarterId];
}
static void VblankCB_StarterChoose(void)
{
LoadOam();
ProcessSpriteCopyRequests();
TransferPlttBuffer();
}
#define tStarterSelection data[0]
#define tPkmnSpriteId data[1]
#define tCircleSpriteId data[2]
void CB2_ChooseStarter(void)
{
u16 savedIme;
u8 taskId;
u8 spriteId;
SetVBlankCallback(NULL);
SetGpuReg(REG_OFFSET_DISPCNT, 0);
SetGpuReg(REG_OFFSET_BG3CNT, 0);
SetGpuReg(REG_OFFSET_BG2CNT, 0);
SetGpuReg(REG_OFFSET_BG1CNT, 0);
SetGpuReg(REG_OFFSET_BG0CNT, 0);
ChangeBgX(0, 0, 0);
ChangeBgY(0, 0, 0);
ChangeBgX(1, 0, 0);
ChangeBgY(1, 0, 0);
ChangeBgX(2, 0, 0);
ChangeBgY(2, 0, 0);
ChangeBgX(3, 0, 0);
ChangeBgY(3, 0, 0);
DmaFill16(3, 0, VRAM, VRAM_SIZE);
DmaFill32(3, 0, OAM, OAM_SIZE);
DmaFill16(3, 0, PLTT, PLTT_SIZE);
LZ77UnCompVram(&gBirchHelpGfx, (void *)VRAM);
LZ77UnCompVram(&gBirchBagTilemap, (void *)(VRAM + 0x3000));
LZ77UnCompVram(&gBirchGrassTilemap, (void *)(VRAM + 0x3800));
ResetBgsAndClearDma3BusyFlags(0);
InitBgsFromTemplates(0, gUnknown_085B1E00, ARRAY_COUNT(gUnknown_085B1E00));
InitWindows(gUnknown_085B1DCC);
DeactivateAllTextPrinters();
sub_809882C(0, 0x2A8, 0xD0);
clear_scheduled_bg_copies_to_vram();
remove_some_task();
ResetTasks();
ResetSpriteData();
ResetPaletteFade();
FreeAllSpritePalettes();
dp13_810BB8C();
LoadPalette(GetOverworldTextboxPalettePtr(), 0xE0, 0x20);
LoadPalette(gBirchBagGrassPal, 0, 0x40);
LoadCompressedObjectPic(&gUnknown_085B1ED8[0]);
LoadCompressedObjectPic(&gUnknown_085B1EE8[0]);
LoadSpritePalettes(gUnknown_085B1EF8);
BeginNormalPaletteFade(-1, 0, 0x10, 0, 0);
EnableInterrupts(DISPSTAT_VBLANK);
SetVBlankCallback(VblankCB_StarterChoose);
SetMainCallback2(MainCallback2_StarterChoose);
SetGpuReg(REG_OFFSET_WININ, 0x3F);
SetGpuReg(REG_OFFSET_WINOUT, 0x1F);
SetGpuReg(REG_OFFSET_WIN0H, 0);
SetGpuReg(REG_OFFSET_WIN0V, 0);
SetGpuReg(REG_OFFSET_BLDCNT, 0xFE);
SetGpuReg(REG_OFFSET_BLDALPHA, 0);
SetGpuReg(REG_OFFSET_BLDY, 7);
SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_WIN0_ON | DISPCNT_OBJ_ON | DISPCNT_OBJ_1D_MAP);
ShowBg(0);
ShowBg(2);
ShowBg(3);
taskId = CreateTask(Task_StarterChoose1, 0);
gTasks[taskId].tStarterSelection = 1;
// Create hand sprite
spriteId = CreateSprite(&sSpriteTemplate_Hand, 120, 56, 2);
gSprites[spriteId].data0 = taskId;
// Create three Pokeball sprites
spriteId = CreateSprite(&sSpriteTemplate_PokeBall, sPokeballCoords[0][0], sPokeballCoords[0][1], 2);
gSprites[spriteId].data0 = taskId;
gSprites[spriteId].data1 = 0;
spriteId = CreateSprite(&sSpriteTemplate_PokeBall, sPokeballCoords[1][0], sPokeballCoords[1][1], 2);
gSprites[spriteId].data0 = taskId;
gSprites[spriteId].data1 = 1;
spriteId = CreateSprite(&sSpriteTemplate_PokeBall, sPokeballCoords[2][0], sPokeballCoords[2][1], 2);
gSprites[spriteId].data0 = taskId;
gSprites[spriteId].data1 = 2;
sStarterChooseWindowId = 0xFF;
}
static void MainCallback2_StarterChoose(void)
{
RunTasks();
AnimateSprites();
BuildOamBuffer();
do_scheduled_bg_tilemap_copies_to_vram();
UpdatePaletteFade();
}
static void Task_StarterChoose1(u8 taskId)
{
CreateStarterPokemonLabel(gTasks[taskId].tStarterSelection);
SetWindowBorderStyle(0, FALSE, 0x2A8, 0xD);
PrintTextOnWindow(0, 1, gText_BirchInTrouble, 0, 1, 0, NULL);
PutWindowTilemap(0);
schedule_bg_copy_tilemap_to_vram(0);
gTasks[taskId].func = Task_StarterChoose2;
}
static void Task_StarterChoose2(u8 taskId)
{
u8 selection = gTasks[taskId].tStarterSelection;
if (gMain.newKeys & A_BUTTON)
{
u8 spriteId;
sub_8134604();
// Create white circle background
spriteId = CreateSprite(&gUnknown_085B1F40, sPokeballCoords[selection][0], sPokeballCoords[selection][1], 1);
gTasks[taskId].tCircleSpriteId = spriteId;
// Create Pokemon sprite
spriteId = CreatePokemonFrontSprite(GetStarterPokemon(gTasks[taskId].tStarterSelection), sPokeballCoords[selection][0], sPokeballCoords[selection][1]);
gSprites[spriteId].affineAnims = &gUnknown_085B1ED0;
gSprites[spriteId].callback = StarterPokemonSpriteCallback;
gTasks[taskId].tPkmnSpriteId = spriteId;
gTasks[taskId].func = Task_StarterChoose3;
}
else if ((gMain.newKeys & DPAD_LEFT) && selection > 0)
{
gTasks[taskId].tStarterSelection--;
gTasks[taskId].func = Task_MoveStarterChooseCursor;
}
else if ((gMain.newKeys & DPAD_RIGHT) && selection < (STARTER_MON_COUNT - 1))
{
gTasks[taskId].tStarterSelection++;
gTasks[taskId].func = Task_MoveStarterChooseCursor;
}
}
static void Task_StarterChoose3(u8 taskId)
{
if (gSprites[gTasks[taskId].tCircleSpriteId].affineAnimEnded &&
gSprites[gTasks[taskId].tCircleSpriteId].pos1.x == STARTER_PKMN_POS_X &&
gSprites[gTasks[taskId].tCircleSpriteId].pos1.y == STARTER_PKMN_POS_Y)
{
gTasks[taskId].func = Task_StarterChoose4;
}
}
static void Task_StarterChoose4(u8 taskId)
{
PlayCry1(GetStarterPokemon(gTasks[taskId].tStarterSelection), 0);
FillWindowPixelBuffer(0, 0x11);
PrintTextOnWindow(0, 1, gText_ConfirmStarterChoice, 0, 1, 0, NULL);
schedule_bg_copy_tilemap_to_vram(0);
CreateYesNoMenu(&gUnknown_085B1DDC, 0x2A8, 0xD, 0);
gTasks[taskId].func = Task_StarterChoose5;
}
static void Task_StarterChoose5(u8 taskId)
{
u8 spriteId;
switch (sub_8198C58())
{
case 0: // YES
// Return the starter choice and exit.
gSpecialVar_Result = gTasks[taskId].tStarterSelection;
dp13_810BB8C();
SetMainCallback2(gMain.savedCallback);
break;
case 1: // NO
case -1: // B button
PlaySE(SE_SELECT);
spriteId = gTasks[taskId].tPkmnSpriteId;
FreeOamMatrix(gSprites[spriteId].oam.matrixNum);
sub_818D820(spriteId);
spriteId = gTasks[taskId].tCircleSpriteId;
FreeOamMatrix(gSprites[spriteId].oam.matrixNum);
DestroySprite(&gSprites[spriteId]);
gTasks[taskId].func = Task_StarterChoose6;
break;
}
}
static void Task_StarterChoose6(u8 taskId)
{
gTasks[taskId].func = Task_StarterChoose1;
}
static void CreateStarterPokemonLabel(u8 selection)
{
u8 text[32];
struct WindowTemplate winTemplate;
const u8 *speciesName;
s32 width;
u8 labelLeft, labelRight, labelTop, labelBottom;
u16 species = GetStarterPokemon(selection);
CopyMonCategoryText(SpeciesToNationalPokedexNum(species), text);
speciesName = gSpeciesNames[species];
winTemplate = gUnknown_085B1DE4;
winTemplate.tilemapLeft = gStarterChoose_LabelCoords[selection][0];
winTemplate.tilemapTop = gStarterChoose_LabelCoords[selection][1];
sStarterChooseWindowId = AddWindow(&winTemplate);
FillWindowPixelBuffer(sStarterChooseWindowId, 0);
width = GetStringCenterAlignXOffset(7, text, 0x68);
box_print(sStarterChooseWindowId, 7, width, 1, gUnknown_085B1E0C, 0, text);
width = GetStringCenterAlignXOffset(1, speciesName, 0x68);
box_print(sStarterChooseWindowId, 1, width, 0x11, gUnknown_085B1E0C, 0, speciesName);
PutWindowTilemap(sStarterChooseWindowId);
schedule_bg_copy_tilemap_to_vram(0);
labelLeft = gStarterChoose_LabelCoords[selection][0] * 8 - 4;
labelRight = (gStarterChoose_LabelCoords[selection][0] + 13) * 8 + 4;
labelTop = gStarterChoose_LabelCoords[selection][1] * 8;
labelBottom = (gStarterChoose_LabelCoords[selection][1] + 4) * 8;
SetGpuReg(REG_OFFSET_WIN0H, WIN_RANGE(labelLeft, labelRight));
SetGpuReg(REG_OFFSET_WIN0V, WIN_RANGE(labelTop, labelBottom));
}
static void sub_8134604(void)
{
FillWindowPixelBuffer(sStarterChooseWindowId, 0);
ClearWindowTilemap(sStarterChooseWindowId);
RemoveWindow(sStarterChooseWindowId);
sStarterChooseWindowId = 0xFF;
SetGpuReg(REG_OFFSET_WIN0H, 0);
SetGpuReg(REG_OFFSET_WIN0V, 0);
schedule_bg_copy_tilemap_to_vram(0);
}
static void Task_MoveStarterChooseCursor(u8 taskId)
{
sub_8134604();
gTasks[taskId].func = sub_8134668;
}
static void sub_8134668(u8 taskId)
{
CreateStarterPokemonLabel(gTasks[taskId].tStarterSelection);
gTasks[taskId].func = Task_StarterChoose2;
}
static u8 CreatePokemonFrontSprite(u16 species, u8 x, u8 y)
{
u8 spriteId;
spriteId = sub_818D3E4(species, 8, 0, 1, x, y, 0xE, 0xFFFF);
gSprites[spriteId].oam.priority = 0;
return spriteId;
}
static void sub_81346DC(struct Sprite *sprite)
{
sprite->pos1.x = gUnknown_085B1E28[gTasks[sprite->data0].tStarterSelection][0];
sprite->pos1.y = gUnknown_085B1E28[gTasks[sprite->data0].tStarterSelection][1];
sprite->pos2.y = Sin(sprite->data1, 8);
sprite->data1 = (u8)(sprite->data1) + 4;
}
static void sub_813473C(struct Sprite *sprite)
{
if (gTasks[sprite->data0].tStarterSelection == sprite->data1)
StartSpriteAnimIfDifferent(sprite, 1);
else
StartSpriteAnimIfDifferent(sprite, 0);
}
static void StarterPokemonSpriteCallback(struct Sprite *sprite)
{
//Move sprite to upper center of screen
if (sprite->pos1.x > STARTER_PKMN_POS_X)
sprite->pos1.x -= 4;
if (sprite->pos1.x < STARTER_PKMN_POS_X)
sprite->pos1.x += 4;
if (sprite->pos1.y > STARTER_PKMN_POS_Y)
sprite->pos1.y -= 2;
if (sprite->pos1.y < STARTER_PKMN_POS_Y)
sprite->pos1.y += 2;
}

View File

@@ -23,7 +23,7 @@ const struct TilesPal* sub_8098758(u8 id)
void copy_textbox_border_tile_patterns_to_vram(u8 windowId, u16 destOffset, u8 palOffset)
{
LoadBgTiles(GetWindowAttribute(windowId, WINDOW_PRIORITY), gUnknown_08DDD748, 0x1C0, destOffset);
LoadPalette(sub_8098C64(), palOffset, 0x20);
LoadPalette(GetOverworldTextboxPalettePtr(), palOffset, 0x20);
}
void box_border_load_tiles_and_pal(u8 windowId, u16 destOffset, u8 palOffset)
@@ -113,7 +113,7 @@ const u16* stdpal_get(u8 id)
return &gUnknown_0851017C[id];
}
const u16* sub_8098C64(void)
const u16* GetOverworldTextboxPalettePtr(void)
{
return gUnknown_08DDD728;
}

174
src/tv.c
View File

@@ -214,23 +214,23 @@ const struct {
// TODO: Figure out what these are, and define constants in include/flags.h
const u16 sGoldSymbolFlags[] = {
SYS_TOWER_GOLD,
SYS_DOME_GOLD,
SYS_PALACE_GOLD,
SYS_ARENA_GOLD,
SYS_FACTORY_GOLD,
SYS_PIKE_GOLD,
SYS_PYRAMID_GOLD
FLAG_SYS_TOWER_GOLD,
FLAG_SYS_DOME_GOLD,
FLAG_SYS_PALACE_GOLD,
FLAG_SYS_ARENA_GOLD,
FLAG_SYS_FACTORY_GOLD,
FLAG_SYS_PIKE_GOLD,
FLAG_SYS_PYRAMID_GOLD
};
const u16 sSilverSymbolFlags[] = {
SYS_TOWER_SILVER,
SYS_DOME_SILVER,
SYS_PALACE_SILVER,
SYS_ARENA_SILVER,
SYS_FACTORY_SILVER,
SYS_PIKE_SILVER,
SYS_PYRAMID_SILVER
FLAG_SYS_TOWER_SILVER,
FLAG_SYS_DOME_SILVER,
FLAG_SYS_PALACE_SILVER,
FLAG_SYS_ARENA_SILVER,
FLAG_SYS_FACTORY_SILVER,
FLAG_SYS_PIKE_SILVER,
FLAG_SYS_PYRAMID_SILVER
};
// TODO: Figure out what these are, and define constants in include/vars.h
@@ -823,7 +823,7 @@ u8 FindAnyTVShowOnTheAir(void)
void UpdateTVScreensOnMap(int width, int height)
{
FlagSet(SYS_TV_WATCH);
FlagSet(FLAG_SYS_TV_WATCH);
switch (CheckForBigMovieOrEmergencyNewsOnTV())
{
case 1:
@@ -836,9 +836,9 @@ void UpdateTVScreensOnMap(int width, int height)
{
SetTVMetatilesOnMap(width, height, 0x3);
}
else if (FlagGet(SYS_TV_START) && (FindAnyTVShowOnTheAir() != 0xff || FindAnyTVNewsOnTheAir() != 0xff || IsTVShowInSearchOfTrainersAiring()))
else if (FlagGet(FLAG_SYS_TV_START) && (FindAnyTVShowOnTheAir() != 0xff || FindAnyTVNewsOnTheAir() != 0xff || IsTVShowInSearchOfTrainersAiring()))
{
FlagClear(SYS_TV_WATCH);
FlagClear(FLAG_SYS_TV_WATCH);
SetTVMetatilesOnMap(width, height, 0x3);
}
break;
@@ -1263,7 +1263,7 @@ void InterviewAfter_ContestLiveUpdates(void)
show2->contestLiveUpdates.kind = TVSHOW_CONTEST_LIVE_UPDATES;
show2->contestLiveUpdates.active = TRUE;
StringCopy(show2->contestLiveUpdates.playerName, gSaveBlock2Ptr->playerName);
show2->contestLiveUpdates.category = gScriptContestCategory;
show2->contestLiveUpdates.category = gSpecialVar_ContestCategory;
show2->contestLiveUpdates.species = GetMonData(&gPlayerParty[gUnknown_02039F24], MON_DATA_SPECIES, NULL);
show2->contestLiveUpdates.winningSpecies = show->contestLiveUpdates.winningSpecies;
show2->contestLiveUpdates.appealFlags2 = show->contestLiveUpdates.appealFlags2;
@@ -1288,7 +1288,7 @@ void PutBattleUpdateOnTheAir(u8 a0, u16 a1, u16 a2, u16 a3)
if (sCurTVShowSlot != -1)
{
FindActiveBroadcastByShowType_SetScriptResult(TVSHOW_BATTLE_UPDATE);
if (gScriptResult != 1)
if (gSpecialVar_Result != 1)
{
show = &gSaveBlock1Ptr->tvShows[sCurTVShowSlot];
show->battleUpdate.kind = TVSHOW_BATTLE_UPDATE;
@@ -1337,7 +1337,7 @@ bool8 Put3CheersForPokeblocksOnTheAir(const u8 *partnersName, u8 flavor, u8 unus
return FALSE;
}
FindActiveBroadcastByShowType_SetScriptResult(TVSHOW_3_CHEERS_FOR_POKEBLOCKS);
if (gScriptResult == 1)
if (gSpecialVar_Result == 1)
{
return FALSE;
}
@@ -1527,8 +1527,8 @@ void BravoTrainerPokemonProfile_BeforeInterview2(u8 a0)
if (sCurTVShowSlot != -1)
{
show->bravoTrainer.contestResult = a0;
show->bravoTrainer.contestCategory = gScriptContestCategory;
show->bravoTrainer.contestRank = gUnknown_02039F2E;
show->bravoTrainer.contestCategory = gSpecialVar_ContestCategory;
show->bravoTrainer.contestRank = gSpecialVar_ContestRank;
show->bravoTrainer.species = GetMonData(&gPlayerParty[gUnknown_02039F24], MON_DATA_SPECIES, NULL);
GetMonData(&gPlayerParty[gUnknown_02039F24], MON_DATA_NICKNAME, show->bravoTrainer.pokemonNickname);
StripExtCtrlCodes(show->bravoTrainer.pokemonNickname);
@@ -1606,7 +1606,7 @@ void PutNameRaterShowOnTheAir(void)
TVShow *show;
InterviewBefore_NameRater();
if (gScriptResult != 1)
if (gSpecialVar_Result != 1)
{
GetMonData(&gPlayerParty[gSpecialVar_0x8004], MON_DATA_NICKNAME, gStringVar1);
if (StringLength(gSaveBlock2Ptr->playerName) > 1 && StringLength(gStringVar1) > 1)
@@ -1653,7 +1653,7 @@ void PutLilycoveContestLadyShowOnTheAir(void)
TVShow *show;
sub_80EFA88();
if (gScriptResult != TRUE)
if (gSpecialVar_Result != TRUE)
{
show = &gSaveBlock1Ptr->tvShows[sCurTVShowSlot];
sub_818E848(&show->contestLiveUpdates2.language);
@@ -1731,7 +1731,7 @@ void sub_80ED718(void)
u16 outbreakIdx;
TVShow *show;
if (FlagGet(SYS_GAME_CLEAR))
if (FlagGet(FLAG_SYS_GAME_CLEAR))
{
for (i = 0; i < 24; i ++)
{
@@ -1943,7 +1943,7 @@ void sub_80EDB44(void)
show = &gSaveBlock1Ptr->tvShows[sCurTVShowSlot];
show->rivalTrainer.kind = TVSHOW_TODAYS_RIVAL_TRAINER;
show->rivalTrainer.active = FALSE;
for (i = BADGE01_GET, nBadges = 0; i < BADGE01_GET + 8; i ++)
for (i = FLAG_BADGE01_GET, nBadges = 0; i < FLAG_BADGE01_GET + 8; i ++)
{
if (FlagGet(i))
{
@@ -2613,7 +2613,7 @@ bool8 sub_80EE7C0(void)
return TRUE;
}
FindActiveBroadcastByShowType_SetScriptResult(TVSHOW_FAN_CLUB_SPECIAL);
if (gScriptResult == TRUE)
if (gSpecialVar_Result == TRUE)
{
return TRUE;
}
@@ -2814,7 +2814,7 @@ void sub_80EED88(void)
{
u8 newsKind;
if (FlagGet(SYS_GAME_CLEAR))
if (FlagGet(FLAG_SYS_GAME_CLEAR))
{
sCurTVShowSlot = sub_80EEE30(gSaveBlock1Ptr->pokeNews);
if (sCurTVShowSlot != -1 && rbernoulli(1, 100) != TRUE)
@@ -2905,7 +2905,7 @@ void DoPokeNews(void)
i = FindAnyTVNewsOnTheAir();
if (i == 0xFF)
{
gScriptResult = FALSE;
gSpecialVar_Result = FALSE;
}
else
{
@@ -2928,7 +2928,7 @@ void DoPokeNews(void)
gSaveBlock1Ptr->pokeNews[i].state = 0;
ShowFieldMessage(sPokeNewsTextGroup_Upcoming[gSaveBlock1Ptr->pokeNews[i].kind]);
}
gScriptResult = TRUE;
gSpecialVar_Result = TRUE;
}
}
@@ -2959,7 +2959,7 @@ bool8 IsPriceDiscounted(u8 newsKind)
switch (newsKind)
{
case POKENEWS_SLATEPORT:
if (gSaveBlock1Ptr->location.mapGroup == MAP_GROUP_SLATEPORT_CITY && gSaveBlock1Ptr->location.mapNum == MAP_ID_SLATEPORT_CITY && gScriptLastTalked == 25)
if (gSaveBlock1Ptr->location.mapGroup == MAP_GROUP_SLATEPORT_CITY && gSaveBlock1Ptr->location.mapNum == MAP_ID_SLATEPORT_CITY && gSpecialVar_LastTalked == 25)
{
return TRUE;
}
@@ -3005,7 +3005,7 @@ void sub_80EF120(u16 days)
}
else
{
if (gSaveBlock1Ptr->pokeNews[i].state == 0 && FlagGet(SYS_GAME_CLEAR) == TRUE)
if (gSaveBlock1Ptr->pokeNews[i].state == 0 && FlagGet(FLAG_SYS_GAME_CLEAR) == TRUE)
{
gSaveBlock1Ptr->pokeNews[i].state = 1;
}
@@ -3189,7 +3189,7 @@ void FindActiveBroadcastByShowType_SetScriptResult(u8 kind)
{
if (gSaveBlock1Ptr->tvShows[i].common.active == TRUE)
{
gScriptResult = TRUE;
gSpecialVar_Result = TRUE;
}
else
{
@@ -3205,7 +3205,7 @@ void FindActiveBroadcastByShowType_SetScriptResult(u8 kind)
void InterviewBefore(void)
{
gScriptResult = FALSE;
gSpecialVar_Result = FALSE;
switch (gSpecialVar_0x8005)
{
case TVSHOW_FAN_CLUB_LETTER:
@@ -3244,7 +3244,7 @@ void InterviewBefore(void)
void InterviewBefore_FanClubLetter(void)
{
FindActiveBroadcastByShowType_SetScriptResult(TVSHOW_FAN_CLUB_LETTER);
if (!gScriptResult)
if (!gSpecialVar_Result)
{
StringCopy(gStringVar1, gSpeciesNames[GetMonData(&gPlayerParty[GetLeadMonIndex()], MON_DATA_SPECIES, NULL)]);
InitializeEasyChatWordArray(gSaveBlock1Ptr->tvShows[sCurTVShowSlot].fanclubLetter.words, 6);
@@ -3254,7 +3254,7 @@ void InterviewBefore_FanClubLetter(void)
void InterviewBefore_RecentHappenings(void)
{
FindActiveBroadcastByShowType_SetScriptResult(TVSHOW_RECENT_HAPPENINGS);
if (!gScriptResult)
if (!gSpecialVar_Result)
{
InitializeEasyChatWordArray(gSaveBlock1Ptr->tvShows[sCurTVShowSlot].recentHappenings.words, 6);
}
@@ -3263,7 +3263,7 @@ void InterviewBefore_RecentHappenings(void)
void InterviewBefore_PkmnFanClubOpinions(void)
{
FindActiveBroadcastByShowType_SetScriptResult(TVSHOW_PKMN_FAN_CLUB_OPINIONS);
if (!gScriptResult)
if (!gSpecialVar_Result)
{
StringCopy(gStringVar1, gSpeciesNames[GetMonData(&gPlayerParty[GetLeadMonIndex()], MON_DATA_SPECIES, NULL)]);
GetMonData(&gPlayerParty[GetLeadMonIndex()], MON_DATA_NICKNAME, gStringVar2);
@@ -3274,7 +3274,7 @@ void InterviewBefore_PkmnFanClubOpinions(void)
void InterviewBefore_Dummy(void)
{
gScriptResult = TRUE;
gSpecialVar_Result = TRUE;
}
void InterviewBefore_NameRater(void)
@@ -3285,7 +3285,7 @@ void InterviewBefore_NameRater(void)
void InterviewBefore_BravoTrainerPkmnProfile(void)
{
FindActiveBroadcastByShowType_SetScriptResult(TVSHOW_BRAVO_TRAINER_POKEMON_PROFILE);
if (!gScriptResult)
if (!gSpecialVar_Result)
{
InitializeEasyChatWordArray(gSaveBlock1Ptr->tvShows[sCurTVShowSlot].bravoTrainer.words, 2);
}
@@ -3304,7 +3304,7 @@ void InterviewBefore_3CheersForPokeblocks(void)
void InterviewBefore_BravoTrainerBTProfile(void)
{
FindActiveBroadcastByShowType_SetScriptResult(TVSHOW_BRAVO_TRAINER_BATTLE_TOWER_PROFILE);
if (!gScriptResult)
if (!gSpecialVar_Result)
{
InitializeEasyChatWordArray(gSaveBlock1Ptr->tvShows[sCurTVShowSlot].bravoTrainerTower.words, 1);
}
@@ -3313,7 +3313,7 @@ void InterviewBefore_BravoTrainerBTProfile(void)
void InterviewBefore_FanClubSpecial(void)
{
FindActiveBroadcastByShowType_SetScriptResult(TVSHOW_FAN_CLUB_SPECIAL);
if (!gScriptResult)
if (!gSpecialVar_Result)
{
InitializeEasyChatWordArray(gSaveBlock1Ptr->tvShows[sCurTVShowSlot].fanClubSpecial.words, 1);
}
@@ -3429,11 +3429,11 @@ void sub_80EFA88(void)
gSpecialVar_0x8006 = sCurTVShowSlot;
if (sCurTVShowSlot == -1)
{
gScriptResult = TRUE;
gSpecialVar_Result = TRUE;
}
else
{
gScriptResult = FALSE;
gSpecialVar_Result = FALSE;
}
}
@@ -3636,7 +3636,7 @@ void ChangeBoxPokemonNickname(void)
{
struct BoxPokemon *boxMon;
boxMon = GetBoxedMonPtr(gSpecialVar_0x8012, gSpecialVar_0x8013);
boxMon = GetBoxedMonPtr(gSpecialVar_MonBoxId, gSpecialVar_MonBoxPos);
GetBoxMonData(boxMon, MON_DATA_NICKNAME, gStringVar3);
GetBoxMonData(boxMon, MON_DATA_NICKNAME, gStringVar2);
DoNamingScreen(3, gStringVar2, GetBoxMonData(boxMon, MON_DATA_SPECIES, NULL), GetBoxMonGender(boxMon), GetBoxMonData(boxMon, MON_DATA_PERSONALITY, NULL), ChangeBoxPokemonNickname_CB);
@@ -3644,7 +3644,7 @@ void ChangeBoxPokemonNickname(void)
void ChangeBoxPokemonNickname_CB(void)
{
SetBoxMonNickFromAnyBox(gSpecialVar_0x8012, gSpecialVar_0x8013, gStringVar2);
SetBoxMonNickFromAnyBox(gSpecialVar_MonBoxId, gSpecialVar_MonBoxPos, gStringVar2);
c2_exit_to_overworld_1_continue_scripts_restart_music();
}
@@ -3658,11 +3658,11 @@ void TV_CheckMonOTIDEqualsPlayerID(void)
{
if (GetPlayerIDAsU32() == GetMonData(&gPlayerParty[gSpecialVar_0x8004], MON_DATA_OT_ID, NULL))
{
gScriptResult = FALSE;
gSpecialVar_Result = FALSE;
}
else
{
gScriptResult = TRUE;
gSpecialVar_Result = TRUE;
}
}
@@ -3712,11 +3712,11 @@ u8 CheckForBigMovieOrEmergencyNewsOnTV(void)
return 0;
}
}
if (FlagGet(SYS_TV_LATI) == TRUE)
if (FlagGet(FLAG_SYS_TV_LATI) == TRUE)
{
return 1;
}
if (FlagGet(SYS_TV_HOME) == TRUE)
if (FlagGet(FLAG_SYS_TV_HOME) == TRUE)
{
return 2;
}
@@ -4561,7 +4561,7 @@ void sub_80F0B64(void)
{
u16 i;
if (FlagGet(SYS_GAME_CLEAR) != TRUE)
if (FlagGet(FLAG_SYS_GAME_CLEAR) != TRUE)
{
for (i = 0; i < 24; i ++)
{
@@ -4736,7 +4736,7 @@ void sub_80F0F24(void)
{
u8 i;
if (FlagGet(SYS_GAME_CLEAR) != TRUE)
if (FlagGet(FLAG_SYS_GAME_CLEAR) != TRUE)
{
for (i = 0; i < 16; i ++)
{
@@ -5108,7 +5108,7 @@ void DoTVShowBravoTrainerPokemonProfile(void)
u8 state;
show = &gSaveBlock1Ptr->tvShows[gSpecialVar_0x8004];
gScriptResult = FALSE;
gSpecialVar_Result = FALSE;
state = sTVShowState;
switch (state)
{
@@ -5180,7 +5180,7 @@ void DoTVShowBravoTrainerBattleTower(void)
u8 state;
show = &gSaveBlock1Ptr->tvShows[gSpecialVar_0x8004];
gScriptResult = FALSE;
gSpecialVar_Result = FALSE;
state = sTVShowState;
switch(state)
{
@@ -5277,7 +5277,7 @@ void DoTVShowTodaysSmartShopper(void)
u8 state;
show = &gSaveBlock1Ptr->tvShows[gSpecialVar_0x8004];
gScriptResult = FALSE;
gSpecialVar_Result = FALSE;
state = sTVShowState;
switch(state)
{
@@ -5400,7 +5400,7 @@ void DoTVShowTheNameRaterShow(void)
u8 state;
show = &gSaveBlock1Ptr->tvShows[gSpecialVar_0x8004];
gScriptResult = FALSE;
gSpecialVar_Result = FALSE;
state = sTVShowState;
switch (state)
{
@@ -5498,7 +5498,7 @@ void DoTVShowPokemonTodaySuccessfulCapture(void)
u8 state;
show = &gSaveBlock1Ptr->tvShows[gSpecialVar_0x8004];
gScriptResult = FALSE;
gSpecialVar_Result = FALSE;
state = sTVShowState;
switch (state)
{
@@ -5576,7 +5576,7 @@ void DoTVShowPokemonTodayFailedCapture(void)
u8 state;
show = &gSaveBlock1Ptr->tvShows[gSpecialVar_0x8004];
gScriptResult = FALSE;
gSpecialVar_Result = FALSE;
state = sTVShowState;
switch (state)
{
@@ -5630,7 +5630,7 @@ void DoTVShowPokemonFanClubLetter(void)
u16 rval;
show = &gSaveBlock1Ptr->tvShows[gSpecialVar_0x8004];
gScriptResult = FALSE;
gSpecialVar_Result = FALSE;
state = sTVShowState;
switch (state)
{
@@ -5683,7 +5683,7 @@ void DoTVShowRecentHappenings(void)
u8 state;
show = &gSaveBlock1Ptr->tvShows[gSpecialVar_0x8004];
gScriptResult = FALSE;
gSpecialVar_Result = FALSE;
state = sTVShowState;
switch (state)
{
@@ -5718,7 +5718,7 @@ void DoTVShowPokemonFanClubOpinions(void)
u8 state;
show = &gSaveBlock1Ptr->tvShows[gSpecialVar_0x8004];
gScriptResult = FALSE;
gSpecialVar_Result = FALSE;
state = sTVShowState;
switch (state)
{
@@ -5768,7 +5768,7 @@ void DoTVShowPokemonContestLiveUpdates(void)
u8 state;
show = &gSaveBlock1Ptr->tvShows[gSpecialVar_0x8004];
gScriptResult = FALSE;
gSpecialVar_Result = FALSE;
state = sTVShowState;
switch (state)
{
@@ -6115,7 +6115,7 @@ void DoTVShowPokemonBattleUpdate(void)
u8 state;
show = &gSaveBlock1Ptr->tvShows[gSpecialVar_0x8004];
gScriptResult = FALSE;
gSpecialVar_Result = FALSE;
state = sTVShowState;
switch (state)
{
@@ -6187,7 +6187,7 @@ void DoTVShow3CheersForPokeblocks(void)
u8 state;
show = &gSaveBlock1Ptr->tvShows[gSpecialVar_0x8004];
gScriptResult = FALSE;
gSpecialVar_Result = FALSE;
state = sTVShowState;
switch (state)
{
@@ -6288,7 +6288,7 @@ void DoTVShowInSearchOfTrainers(void)
{
u8 state;
gScriptResult = FALSE;
gSpecialVar_Result = FALSE;
state = sTVShowState;
switch (state)
{
@@ -6344,7 +6344,7 @@ void DoTVShowInSearchOfTrainers(void)
CopyEasyChatWord(gStringVar1, gSaveBlock1Ptr->gabbyAndTyData.quote[0]);
StringCopy(gStringVar2, gSpeciesNames[gSaveBlock1Ptr->gabbyAndTyData.mon1]);
StringCopy(gStringVar3, gSpeciesNames[gSaveBlock1Ptr->gabbyAndTyData.mon2]);
gScriptResult = TRUE;
gSpecialVar_Result = TRUE;
sTVShowState = 0;
TakeTVShowInSearchOfTrainersOffTheAir();
break;
@@ -6358,7 +6358,7 @@ void DoTVShowPokemonAngler(void)
u8 state;
show = &gSaveBlock1Ptr->tvShows[gSpecialVar_0x8004];
gScriptResult = FALSE;
gSpecialVar_Result = FALSE;
if (show->pokemonAngler.nBites < show->pokemonAngler.nFails)
{
sTVShowState = 0;
@@ -6392,7 +6392,7 @@ void DoTVShowTheWorldOfMasters(void)
u8 state;
show = &gSaveBlock1Ptr->tvShows[gSpecialVar_0x8004];
gScriptResult = FALSE;
gSpecialVar_Result = FALSE;
state = sTVShowState;
switch (state)
{
@@ -6422,7 +6422,7 @@ void DoTVShowTodaysRivalTrainer(void)
u8 state;
show = &gSaveBlock1Ptr->tvShows[gSpecialVar_0x8004];
gScriptResult = FALSE;
gSpecialVar_Result = FALSE;
state = sTVShowState;
switch (state)
{
@@ -6432,10 +6432,10 @@ void DoTVShowTodaysRivalTrainer(void)
default:
sTVShowState = 7;
break;
case REGION_MAP_SECRET_BASE:
case MAPSEC_SECRET_BASE:
sTVShowState = 8;
break;
case REGION_MAP_NONE:
case MAPSEC_DYNAMIC:
switch (show->rivalTrainer.mapDataId)
{
case 0x115 ... 0x117:
@@ -6571,7 +6571,7 @@ void DoTVShowDewfordTrendWatcherNetwork(void)
u8 state;
show = &gSaveBlock1Ptr->tvShows[gSpecialVar_0x8004];
gScriptResult = FALSE;
gSpecialVar_Result = FALSE;
state = sTVShowState;
switch (state)
{
@@ -6627,13 +6627,13 @@ void DoTVShowHoennTreasureInvestigators(void)
u8 state;
show = &gSaveBlock1Ptr->tvShows[gSpecialVar_0x8004];
gScriptResult = FALSE;
gSpecialVar_Result = FALSE;
state = sTVShowState;
switch (state)
{
case 0:
StringCopy(gStringVar1, ItemId_GetItem(show->treasureInvestigators.item)->name);
if (show->treasureInvestigators.location == REGION_MAP_NONE)
if (show->treasureInvestigators.location == MAPSEC_DYNAMIC)
{
switch (show->treasureInvestigators.mapDataId)
{
@@ -6671,7 +6671,7 @@ void DoTVShowFindThatGamer(void)
u8 state;
show = &gSaveBlock1Ptr->tvShows[gSpecialVar_0x8004];
gScriptResult = FALSE;
gSpecialVar_Result = FALSE;
state = sTVShowState;
switch (state)
{
@@ -6745,7 +6745,7 @@ void DoTVShowBreakingNewsTV(void)
u8 state;
show = &gSaveBlock1Ptr->tvShows[gSpecialVar_0x8004];
gScriptResult = FALSE;
gSpecialVar_Result = FALSE;
state = sTVShowState;
switch (state)
{
@@ -6848,7 +6848,7 @@ void DoTVShowSecretBaseVisit(void)
u8 state;
show = &gSaveBlock1Ptr->tvShows[gSpecialVar_0x8004];
gScriptResult = FALSE;
gSpecialVar_Result = FALSE;
state = sTVShowState;
switch (state)
{
@@ -6944,7 +6944,7 @@ void DoTVShowPokemonLotteryWinnerFlashReport(void)
u8 state;
show = &gSaveBlock1Ptr->tvShows[gSpecialVar_0x8004];
gScriptResult = FALSE;
gSpecialVar_Result = FALSE;
state = sTVShowState;
TVShowConvertInternationalString(gStringVar1, show->lottoWinner.playerName, show->lottoWinner.language);
if (show->lottoWinner.whichPrize == 0)
@@ -6974,7 +6974,7 @@ void DoTVShowThePokemonBattleSeminar(void)
u8 state;
show = &gSaveBlock1Ptr->tvShows[gSpecialVar_0x8004];
gScriptResult = FALSE;
gSpecialVar_Result = FALSE;
state = sTVShowState;
switch (state)
{
@@ -7038,7 +7038,7 @@ void DoTVShowTrainerFanClubSpecial(void)
u8 state;
show = &gSaveBlock1Ptr->tvShows[gSpecialVar_0x8004];
gScriptResult = FALSE;
gSpecialVar_Result = FALSE;
state = sTVShowState;
switch (state)
{
@@ -7104,7 +7104,7 @@ void DoTVShowTrainerFanClub(void)
u32 playerId;
show = &gSaveBlock1Ptr->tvShows[gSpecialVar_0x8004];
gScriptResult = FALSE;
gSpecialVar_Result = FALSE;
state = sTVShowState;
switch (state)
{
@@ -7191,7 +7191,7 @@ void DoTVShowSpotTheCuties(void)
u32 playerId;
show = &gSaveBlock1Ptr->tvShows[gSpecialVar_0x8004];
gScriptResult = FALSE;
gSpecialVar_Result = FALSE;
state = sTVShowState;
switch (state)
{
@@ -7296,7 +7296,7 @@ void DoTVShowPokemonNewsBattleFrontier(void)
u32 playerId;
show = &gSaveBlock1Ptr->tvShows[gSpecialVar_0x8004];
gScriptResult = FALSE;
gSpecialVar_Result = FALSE;
state = sTVShowState;
switch (state)
{
@@ -7445,7 +7445,7 @@ void DoTVShowWhatsNo1InHoennToday(void)
u32 playerId;
show = &gSaveBlock1Ptr->tvShows[gSpecialVar_0x8004];
gScriptResult = FALSE;
gSpecialVar_Result = FALSE;
state = sTVShowState;
switch (state)
{
@@ -7561,7 +7561,7 @@ void DoTVShowSecretBaseSecrets(void)
u16 i;
show = &gSaveBlock1Ptr->tvShows[gSpecialVar_0x8004];
gScriptResult = FALSE;
gSpecialVar_Result = FALSE;
state = sTVShowState;
switch (state)
{
@@ -7797,7 +7797,7 @@ void DoTVShowSafariFanClub(void)
u8 state;
show = &gSaveBlock1Ptr->tvShows[gSpecialVar_0x8004];
gScriptResult = FALSE;
gSpecialVar_Result = FALSE;
state = sTVShowState;
switch (state)
{
@@ -7884,7 +7884,7 @@ void DoTVShowPokemonContestLiveUpdates2(void)
u8 state;
show = &gSaveBlock1Ptr->tvShows[gSpecialVar_0x8004];
gScriptResult = FALSE;
gSpecialVar_Result = FALSE;
state = sTVShowState;
switch (state)
{
@@ -7916,7 +7916,7 @@ void DoTVShowPokemonContestLiveUpdates2(void)
void TVShowDone(void)
{
gScriptResult = TRUE;
gSpecialVar_Result = TRUE;
sTVShowState = 0;
gSaveBlock1Ptr->tvShows[gSpecialVar_0x8004].common.active = FALSE;
}

View File

@@ -98,17 +98,17 @@ u16 TryGetWallpaperWithWaldaPhrase(void)
u16 backgroundClr, foregroundClr;
u8 patternId, iconId;
u16 trainerId = ReadUnalignedWord(gSaveBlock2Ptr->playerTrainerId);
gScriptResult = TryCalculateWallpaper(&backgroundClr, &foregroundClr, &iconId, &patternId, trainerId, GetWaldaPhrasePtr());
gSpecialVar_Result = TryCalculateWallpaper(&backgroundClr, &foregroundClr, &iconId, &patternId, trainerId, GetWaldaPhrasePtr());
if (gScriptResult)
if (gSpecialVar_Result)
{
SetWaldaWallpaperPatternId(patternId);
SetWaldaWallpaperIconId(iconId);
SetWaldaWallpaperColors(backgroundClr, foregroundClr);
}
SetWaldaWallpaperLockedOrUnlocked(gScriptResult);
return (bool8)(gScriptResult);
SetWaldaWallpaperLockedOrUnlocked(gSpecialVar_Result);
return (bool8)(gSpecialVar_Result);
}
static u8 GetLetterTableId(u8 letter)