summaryrefslogtreecommitdiff
path: root/src/battle_dome.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/battle_dome.c')
-rw-r--r--src/battle_dome.c369
1 files changed, 68 insertions, 301 deletions
diff --git a/src/battle_dome.c b/src/battle_dome.c
index 3654d2ccf..0d1bee8cf 100644
--- a/src/battle_dome.c
+++ b/src/battle_dome.c
@@ -33,7 +33,6 @@
#include "graphics.h"
#include "constants/battle_dome.h"
#include "constants/frontier_util.h"
-#include "constants/species.h"
#include "constants/moves.h"
#include "constants/pokemon.h"
#include "constants/trainers.h"
@@ -49,7 +48,7 @@
// An 'Info Card' is a trainer or match information page that can be viewed on the Tourney Tree
struct TourneyTreeInfoCard
{
- u8 spriteIds[NUM_INFOCARD_SPRITES];
+ u8 spriteIds[NUM_INFOCARD_SPRITES];
u8 pos;
u8 tournamentIds[NUM_INFOCARD_TRAINERS];
};
@@ -499,7 +498,7 @@ static const u8 sBattleStyleMovePoints[MOVES_COUNT][NUM_MOVE_POINT_TYPES] =
[MOVE_PSYCHO_BOOST] = {[MOVE_POINTS_DMG] = 1, [MOVE_POINTS_POWERFUL] = 1, [MOVE_POINTS_STRONG] = 1, [MOVE_POINTS_LOW_PP] = 1, [MOVE_POINTS_EFFECT] = 1},
};
-// This array is searched in-order to determine what battle style a tourney trainer uses.
+// This array is searched in-order to determine what battle style a tourney trainer uses.
// If the sum of the points for the party's moves meets/exceeds all the point totals of an element, then they use that battle style
static const u8 sBattleStyleThresholds[NUM_BATTLE_STYLES - 1][NUM_MOVE_POINT_TYPES] =
{
@@ -864,7 +863,9 @@ static const struct WindowTemplate sInfoCardWindowTemplates[] =
.paletteNum = 15,
.baseBlock = 372,
},
- // UB: No DUMMY_WIN_TEMPLATE at the array's end.
+ #ifdef UBFIX
+ DUMMY_WIN_TEMPLATE,
+ #endif
};
static const struct ScanlineEffectParams sTourneyTreeScanlineEffectParams =
@@ -1188,11 +1189,11 @@ static const u8 sIdToMatchNumber[DOME_TOURNAMENT_TRAINERS_COUNT][DOME_ROUNDS_COU
{ 7, 11, 13, 14},
};
-static const u8 sLastMatchCardNum[DOME_ROUNDS_COUNT] =
+static const u8 sLastMatchCardNum[DOME_ROUNDS_COUNT] =
{
- [DOME_ROUND1] = 23,
- [DOME_ROUND2] = 27,
- [DOME_SEMIFINAL] = 29,
+ [DOME_ROUND1] = 23,
+ [DOME_ROUND2] = 27,
+ [DOME_SEMIFINAL] = 29,
[DOME_FINAL] = 30
};
@@ -1324,12 +1325,12 @@ static const u8 sSpeciesNameTextYCoords[] = {0, 4, 0};
// Offsets within sBattleDomeOpponentStatsTexts for stat combinations
// SPDEF has no offset because by then all stat combinations have been reached, so it has no combination texts
-static const u8 sStatTextOffsets[NUM_STATS - 1] =
+static const u8 sStatTextOffsets[NUM_STATS - 1] =
{
- DOME_TEXT_HP,
- DOME_TEXT_ATK,
- DOME_TEXT_DEF,
- DOME_TEXT_SPEED,
+ DOME_TEXT_HP,
+ DOME_TEXT_ATK,
+ DOME_TEXT_DEF,
+ DOME_TEXT_SPEED,
DOME_TEXT_SPATK
};
@@ -1421,7 +1422,7 @@ static const u8 sTrainerNamePositions[DOME_TOURNAMENT_TRAINERS_COUNT][2] =
static const u8 sTourneyTreePokeballCoords[DOME_TOURNAMENT_TRAINERS_COUNT + DOME_TOURNAMENT_MATCHES_COUNT][2] =
{
{ 68, 33}, // Left side trainers
- { 68, 49},
+ { 68, 49},
{ 68, 65},
{ 68, 81},
{ 68, 97},
@@ -1495,7 +1496,7 @@ static const u8 sTourneyTreePokeballCoords[DOME_TOURNAMENT_TRAINERS_COUNT + DOME
{.src = 0x6021, .y = 0x10, .x = 0x09}, \
{.src = 0x6023, .y = 0x10, .x = 0x0a}, \
{.src = 0x6047, .y = 0x11, .x = 0x0a}, \
- {.src = lastSrc, .y = 0x11, .x = 0x0b},
+ {.src = lastSrc, .y = 0x11, .x = 0x0b},
#define LINESECTION_ROUND1_TRAINER4(lastSrc) \
{.src = 0x602b, .y = 0x12, .x = 0x09}, \
@@ -2395,7 +2396,7 @@ static void InitDomeTrainers(void)
rankingScores[i] += (monTypesCount * monLevel) / 20;
}
- // Seed tourney trainers according to their ranking
+ // Seed tourney trainers according to their ranking
for (i = 0; i < DOME_TOURNAMENT_TRAINERS_COUNT - 1; i++)
{
for (j = i + 1; j < DOME_TOURNAMENT_TRAINERS_COUNT; j++)
@@ -2527,7 +2528,11 @@ static void CreateDomeOpponentMon(u8 monPartyId, u16 tournamentTrainerId, u8 tou
{
int i;
u8 friendship = MAX_FRIENDSHIP;
- u8 fixedIv = GetDomeTrainerMonIvs(tournamentTrainerId); // BUG: Should be using (DOME_TRAINERS[tournamentTrainerId].trainerId) instead of (tournamentTrainerId). As a result, all Pokemon have ivs of 3.
+ #ifdef BUGFIX
+ u8 fixedIv = GetDomeTrainerMonIvs(DOME_TRAINERS[tournamentTrainerId].trainerId);
+ #else
+ u8 fixedIv = GetDomeTrainerMonIvs(tournamentTrainerId); // BUG: Using the wrong ID. As a result, all Pokemon have ivs of 3.
+ #endif
u8 level = SetFacilityPtrsGetLevel();
CreateMonWithEVSpreadNatureOTID(&gEnemyParty[monPartyId],
gFacilityTrainerMons[DOME_MONS[tournamentTrainerId][tournamentMonId]].species,
@@ -2676,7 +2681,7 @@ static int SelectOpponentMonsFromParty(int *partyMovePoints, bool8 allowRandom)
partyPositions[i] = i;
// All party mons have equal move score totals, choose randomly
- if (partyMovePoints[0] == partyMovePoints[1]
+ if (partyMovePoints[0] == partyMovePoints[1]
&& partyMovePoints[0] == partyMovePoints[2])
{
if (allowRandom)
@@ -2731,9 +2736,6 @@ static int SelectOpponentMonsFromParty(int *partyMovePoints, bool8 allowRandom)
#define TYPE_x2 40
#define TYPE_x4 80
-// Functionally equivalent, while loop is impossible to match.
-// arg2 is either 2, a personality, or an OTID
-#ifdef NONMATCHING
static int GetTypeEffectivenessPoints(int move, int targetSpecies, int arg2)
{
int defType1, defType2, defAbility, moveType;
@@ -2762,13 +2764,15 @@ static int GetTypeEffectivenessPoints(int move, int targetSpecies, int arg2)
i += 3;
continue;
}
- else if (TYPE_EFFECT_ATK_TYPE(i) == moveType)
+ if (TYPE_EFFECT_ATK_TYPE(i) == moveType)
{
- // BUG: * 2 is not necessary and makes the condition always false if the ability is wonder guard.
- if (TYPE_EFFECT_DEF_TYPE(i) == defType1 && (defAbility != ABILITY_WONDER_GUARD || TYPE_EFFECT_MULTIPLIER(i) == TYPE_MUL_SUPER_EFFECTIVE * 2))
- typePower = (typePower * TYPE_EFFECT_MULTIPLIER(i)) / 10;
- if (TYPE_EFFECT_DEF_TYPE(i) == defType2 && defType1 != defType2 && (defAbility != ABILITY_WONDER_GUARD || TYPE_EFFECT_MULTIPLIER(i) == TYPE_MUL_SUPER_EFFECTIVE * 2))
- typePower = (typePower * TYPE_EFFECT_MULTIPLIER(i)) / 10;
+ // BUG: TYPE_x2 is not necessary and makes the condition always false if the ability is wonder guard.
+ if (TYPE_EFFECT_DEF_TYPE(i) == defType1)
+ if ((defAbility == ABILITY_WONDER_GUARD && TYPE_EFFECT_MULTIPLIER(i) == TYPE_x2) || defAbility != ABILITY_WONDER_GUARD)
+ typePower = (typePower * TYPE_EFFECT_MULTIPLIER(i)) / 10;
+ if (TYPE_EFFECT_DEF_TYPE(i) == defType2 && defType1 != defType2)
+ if ((defAbility == ABILITY_WONDER_GUARD && TYPE_EFFECT_MULTIPLIER(i) == TYPE_x2) || defAbility != ABILITY_WONDER_GUARD)
+ typePower = (typePower * TYPE_EFFECT_MULTIPLIER(i)) / 10;
}
i += 3;
}
@@ -2848,247 +2852,6 @@ static int GetTypeEffectivenessPoints(int move, int targetSpecies, int arg2)
return typePower;
}
-#else
-NAKED
-static int GetTypeEffectivenessPoints(int move, int species, int arg2)
-{
- asm_unified("\n\
- push {r4-r7,lr}\n\
- mov r7, r10\n\
- mov r6, r9\n\
- mov r5, r8\n\
- push {r5-r7}\n\
- sub sp, 0x8\n\
- adds r3, r0, 0\n\
- adds r4, r1, 0\n\
- str r2, [sp]\n\
- movs r6, 0\n\
- movs r2, 0x14\n\
- cmp r3, 0\n\
- beq _0818FFF0\n\
- ldr r0, =0x0000ffff\n\
- cmp r3, r0\n\
- beq _0818FFF0\n\
- ldr r0, =gBattleMoves\n\
- lsls r1, r3, 1\n\
- adds r1, r3\n\
- lsls r1, 2\n\
- adds r3, r1, r0\n\
- ldrb r0, [r3, 0x1]\n\
- cmp r0, 0\n\
- bne _0818FFFC\n\
-_0818FFF0:\n\
- movs r0, 0\n\
- b _08190156\n\
- .pool\n\
-_0818FFFC:\n\
- ldr r1, =gBaseStats\n\
- lsls r0, r4, 3\n\
- subs r0, r4\n\
- lsls r0, 2\n\
- adds r0, r1\n\
- ldrb r1, [r0, 0x6]\n\
- mov r10, r1\n\
- ldrb r1, [r0, 0x7]\n\
- mov r9, r1\n\
- ldrb r0, [r0, 0x16]\n\
- mov r8, r0\n\
- ldrb r3, [r3, 0x2]\n\
- str r3, [sp, 0x4]\n\
- cmp r0, 0x1A\n\
- bne _0819002C\n\
- cmp r3, 0x4\n\
- bne _0819002C\n\
- ldr r0, [sp]\n\
- cmp r0, 0x1\n\
- bne _081900AA\n\
- movs r2, 0x8\n\
- b _081900A4\n\
- .pool\n\
-_0819002C:\n\
- ldr r0, =gTypeEffectiveness\n\
- adds r1, r6, r0\n\
- ldrb r0, [r1]\n\
- ldr r7, =gTypeEffectiveness\n\
- cmp r0, 0xFF\n\
- beq _081900A4\n\
- adds r4, r1, 0\n\
-_0819003A:\n\
- ldrb r0, [r4]\n\
- cmp r0, 0xFE\n\
- beq _08190096\n\
- ldrb r0, [r4]\n\
- ldr r1, [sp, 0x4]\n\
- cmp r0, r1\n\
- bne _08190096\n\
- ldrb r0, [r4, 0x1]\n\
- adds r5, r6, 0x1\n\
- cmp r0, r10\n\
- bne _0819006C\n\
- adds r1, r6, 0x2\n\
- mov r0, r8\n\
- cmp r0, 0x19\n\
- bne _0819005E\n\
- ldrb r0, [r4, 0x2]\n\
- cmp r0, 0x28\n\
- bne _0819006C\n\
-_0819005E:\n\
- adds r0, r1, r7\n\
- ldrb r0, [r0]\n\
- muls r0, r2\n\
- movs r1, 0xA\n\
- bl __divsi3\n\
- adds r2, r0, 0\n\
-_0819006C:\n\
- adds r0, r5, r7\n\
- ldrb r0, [r0]\n\
- cmp r0, r9\n\
- bne _08190096\n\
- cmp r10, r9\n\
- beq _08190096\n\
- adds r1, r6, 0x2\n\
- mov r0, r8\n\
- cmp r0, 0x19\n\
- bne _08190088\n\
- adds r0, r1, r7\n\
- ldrb r0, [r0]\n\
- cmp r0, 0x28\n\
- bne _08190096\n\
-_08190088:\n\
- adds r0, r1, r7\n\
- ldrb r0, [r0]\n\
- muls r0, r2\n\
- movs r1, 0xA\n\
- bl __divsi3\n\
- adds r2, r0, 0\n\
-_08190096:\n\
- adds r4, 0x3\n\
- adds r6, 0x3\n\
- ldr r1, =gTypeEffectiveness\n\
- adds r0, r6, r1\n\
- ldrb r0, [r0]\n\
- cmp r0, 0xFF\n\
- bne _0819003A\n\
-_081900A4:\n\
- ldr r0, [sp]\n\
- cmp r0, 0x1\n\
- beq _081900E0\n\
-_081900AA:\n\
- ldr r1, [sp]\n\
- cmp r1, 0x1\n\
- bgt _081900BC\n\
- cmp r1, 0\n\
- beq _081900C4\n\
- b _08190154\n\
- .pool\n\
-_081900BC:\n\
- ldr r0, [sp]\n\
- cmp r0, 0x2\n\
- beq _08190114\n\
- b _08190154\n\
-_081900C4:\n\
- cmp r2, 0xA\n\
- beq _08190146\n\
- cmp r2, 0xA\n\
- ble _08190146\n\
- cmp r2, 0x28\n\
- beq _0819014A\n\
- cmp r2, 0x28\n\
- bgt _081900DA\n\
- cmp r2, 0x14\n\
- beq _08190104\n\
- b _08190146\n\
-_081900DA:\n\
- cmp r2, 0x50\n\
- bne _08190146\n\
- b _08190100\n\
-_081900E0:\n\
- cmp r2, 0xA\n\
- beq _08190104\n\
- cmp r2, 0xA\n\
- bgt _081900F2\n\
- cmp r2, 0\n\
- beq _08190100\n\
- cmp r2, 0x5\n\
- beq _0819014A\n\
- b _08190146\n\
-_081900F2:\n\
- cmp r2, 0x28\n\
- beq _08190108\n\
- cmp r2, 0x28\n\
- ble _08190146\n\
- cmp r2, 0x50\n\
- beq _0819010E\n\
- b _08190146\n\
-_08190100:\n\
- movs r2, 0x8\n\
- b _08190154\n\
-_08190104:\n\
- movs r2, 0x2\n\
- b _08190154\n\
-_08190108:\n\
- movs r2, 0x2\n\
- negs r2, r2\n\
- b _08190154\n\
-_0819010E:\n\
- movs r2, 0x4\n\
- negs r2, r2\n\
- b _08190154\n\
-_08190114:\n\
- cmp r2, 0xA\n\
- beq _08190146\n\
- cmp r2, 0xA\n\
- bgt _08190126\n\
- cmp r2, 0\n\
- beq _0819013A\n\
- cmp r2, 0x5\n\
- beq _08190140\n\
- b _08190146\n\
-_08190126:\n\
- cmp r2, 0x28\n\
- beq _0819014E\n\
- cmp r2, 0x28\n\
- bgt _08190134\n\
- cmp r2, 0x14\n\
- beq _0819014A\n\
- b _08190146\n\
-_08190134:\n\
- cmp r2, 0x50\n\
- beq _08190152\n\
- b _08190146\n\
-_0819013A:\n\
- movs r2, 0x10\n\
- negs r2, r2\n\
- b _08190154\n\
-_08190140:\n\
- movs r2, 0x8\n\
- negs r2, r2\n\
- b _08190154\n\
-_08190146:\n\
- movs r2, 0\n\
- b _08190154\n\
-_0819014A:\n\
- movs r2, 0x4\n\
- b _08190154\n\
-_0819014E:\n\
- movs r2, 0xC\n\
- b _08190154\n\
-_08190152:\n\
- movs r2, 0x14\n\
-_08190154:\n\
- adds r0, r2, 0\n\
-_08190156:\n\
- add sp, 0x8\n\
- pop {r3-r5}\n\
- mov r8, r3\n\
- mov r9, r4\n\
- mov r10, r5\n\
- pop {r4-r7}\n\
- pop {r1}\n\
- bx r1\n\
- ");
-}
-#endif // NONMATCHING
// Duplicate of GetFrontierTrainerFixedIvs
// NOTE: In CreateDomeOpponentMon a tournament trainer ID (0-15) is passed instead, resulting in all IVs of 3
@@ -4353,7 +4116,7 @@ static u8 Task_GetInfoCardInput(u8 taskId)
u8 tourneyId = sTourneyTreeTrainerIds[position];
u16 roundId = gSaveBlock2Ptr->frontier.curChallengeBattleNum;
- if (gMain.newKeys & (A_BUTTON | B_BUTTON))
+ if (JOY_NEW(A_BUTTON | B_BUTTON))
input = INFOCARD_INPUT_AB;
// Next opponent card cant scroll
@@ -4364,7 +4127,7 @@ static u8 Task_GetInfoCardInput(u8 taskId)
{
// For trainer info cards, pos is 0 when on a trainer info card (not viewing that trainer's match progression)
// Scrolling up/down from a trainer info card goes to other trainer info cards
- if (gMain.newKeys & DPAD_UP && sInfoCard->pos == 0)
+ if (JOY_NEW(DPAD_UP) && sInfoCard->pos == 0)
{
if (position == 0)
position = DOME_TOURNAMENT_TRAINERS_COUNT - 1;
@@ -4372,7 +4135,7 @@ static u8 Task_GetInfoCardInput(u8 taskId)
position--;
input = TRAINERCARD_INPUT_UP;
}
- else if (gMain.newKeys & DPAD_DOWN && sInfoCard->pos == 0)
+ else if (JOY_NEW(DPAD_DOWN) && sInfoCard->pos == 0)
{
if (position == DOME_TOURNAMENT_TRAINERS_COUNT - 1)
position = 0;
@@ -4381,13 +4144,13 @@ static u8 Task_GetInfoCardInput(u8 taskId)
input = TRAINERCARD_INPUT_DOWN;
}
// Scrolling left can only be done after scrolling right
- else if (gMain.newKeys & DPAD_LEFT && sInfoCard->pos != 0)
+ else if (JOY_NEW(DPAD_LEFT) && sInfoCard->pos != 0)
{
sInfoCard->pos--;
input = TRAINERCARD_INPUT_LEFT;
}
// Scrolling right from a trainer info card shows their match progression
- else if (gMain.newKeys & DPAD_RIGHT)
+ else if (JOY_NEW(DPAD_RIGHT))
{
// Can only scroll right from a trainer card until the round they were eliminated
if (DOME_TRAINERS[tourneyId].isEliminated && sInfoCard->pos - 1 < DOME_TRAINERS[tourneyId].eliminatedAt)
@@ -4415,7 +4178,7 @@ static u8 Task_GetInfoCardInput(u8 taskId)
{
// For match info cards, pos is 1 when on the match card, 0 when on the left trainer, and 1 when on the right trainer
// Scrolling up/down from a match info card goes to the next/previous match
- if (gMain.newKeys & DPAD_UP && sInfoCard->pos == 1)
+ if (JOY_NEW(DPAD_UP) && sInfoCard->pos == 1)
{
if (position == DOME_TOURNAMENT_TRAINERS_COUNT)
position = sLastMatchCardNum[roundId];
@@ -4423,7 +4186,7 @@ static u8 Task_GetInfoCardInput(u8 taskId)
position--;
input = MATCHCARD_INPUT_UP;
}
- else if (gMain.newKeys & DPAD_DOWN && sInfoCard->pos == 1)
+ else if (JOY_NEW(DPAD_DOWN) && sInfoCard->pos == 1)
{
if (position == sLastMatchCardNum[roundId])
position = DOME_TOURNAMENT_TRAINERS_COUNT;
@@ -4432,12 +4195,12 @@ static u8 Task_GetInfoCardInput(u8 taskId)
input = MATCHCARD_INPUT_DOWN;
}
// Scrolling left/right from a match info card shows the trainer info card of the competitors for that match
- else if (gMain.newKeys & DPAD_LEFT && sInfoCard->pos != 0)
+ else if (JOY_NEW(DPAD_LEFT) && sInfoCard->pos != 0)
{
input = MATCHCARD_INPUT_LEFT;
sInfoCard->pos--;
}
- else if (gMain.newKeys & DPAD_RIGHT && (sInfoCard->pos == 0 || sInfoCard->pos == 1))
+ else if (JOY_NEW(DPAD_RIGHT) && (sInfoCard->pos == 0 || sInfoCard->pos == 1))
{
input = MATCHCARD_INPUT_RIGHT;
sInfoCard->pos++;
@@ -4538,7 +4301,7 @@ static void DisplayTrainerInfoOnCard(u8 flags, u8 trainerTourneyId)
if (flags & MOVE_CARD)
gSprites[sInfoCard->spriteIds[2 + i + arrId]].invisible = TRUE;
}
-
+
// Initialize the text printer
textPrinter.fontId = 2;
textPrinter.x = 0;
@@ -4776,7 +4539,7 @@ static void DisplayTrainerInfoOnCard(u8 flags, u8 trainerTourneyId)
// If 2 good stats have been found already, choose which to use
if (i == 2)
{
-
+
if (allocatedArray[6] < allocatedArray[k])
{
if (allocatedArray[7] < allocatedArray[k])
@@ -4893,7 +4656,7 @@ static int BufferDomeWinString(u8 matchNum, u8 *tournamentIds)
for (i = sCompetitorRangeByMatch[matchNum][0]; i < sCompetitorRangeByMatch[matchNum][0] + sCompetitorRangeByMatch[matchNum][1]; i++)
{
tournamentId = sTourneyTreeTrainerIds2[i];
-
+
if (DOME_TRAINERS[tournamentId].isEliminated
&& DOME_TRAINERS[tournamentId].eliminatedAt >= sCompetitorRangeByMatch[matchNum][2])
{
@@ -5285,12 +5048,12 @@ static u8 UpdateTourneyTreeCursor(u8 taskId)
int tourneyTreeCursorSpriteId = gTasks[taskId].data[1];
int roundId = gSaveBlock2Ptr->frontier.curChallengeBattleNum;
- if (gMain.newKeys == B_BUTTON || (gMain.newKeys & A_BUTTON && tourneyTreeCursorSpriteId == TOURNEY_TREE_CLOSE_BUTTON))
+ if (gMain.newKeys == B_BUTTON || (JOY_NEW(A_BUTTON) && tourneyTreeCursorSpriteId == TOURNEY_TREE_CLOSE_BUTTON))
{
PlaySE(SE_SELECT);
selection = TOURNEY_TREE_SELECTED_CLOSE;
}
- else if (gMain.newKeys & A_BUTTON)
+ else if (JOY_NEW(A_BUTTON))
{
if (tourneyTreeCursorSpriteId < DOME_TOURNAMENT_TRAINERS_COUNT)
{
@@ -5353,7 +5116,7 @@ static void ResolveDomeRoundWinners(void)
DOME_TRAINERS[TrainerIdToTournamentId(gTrainerBattleOpponent_A)].isEliminated = TRUE;
DOME_TRAINERS[TrainerIdToTournamentId(gTrainerBattleOpponent_A)].eliminatedAt = gSaveBlock2Ptr->frontier.curChallengeBattleNum;
gSaveBlock2Ptr->frontier.domeWinningMoves[TrainerIdToTournamentId(gTrainerBattleOpponent_A)] = gBattleResults.lastUsedMovePlayer;
-
+
// If the player's match was the final one, no NPC vs NPC matches to decide
if (gSaveBlock2Ptr->frontier.curChallengeBattleNum < DOME_FINAL)
DecideRoundWinners(gSaveBlock2Ptr->frontier.curChallengeBattleNum);
@@ -5363,7 +5126,7 @@ static void ResolveDomeRoundWinners(void)
DOME_TRAINERS[TrainerIdToTournamentId(TRAINER_PLAYER)].isEliminated = TRUE;
DOME_TRAINERS[TrainerIdToTournamentId(TRAINER_PLAYER)].eliminatedAt = gSaveBlock2Ptr->frontier.curChallengeBattleNum;
gSaveBlock2Ptr->frontier.domeWinningMoves[TrainerIdToTournamentId(TRAINER_PLAYER)] = gBattleResults.lastUsedMoveOpponent;
-
+
if (gBattleOutcome == B_OUTCOME_FORFEITED || gSpecialVar_0x8005 == DOME_PLAYER_RETIRED)
DOME_TRAINERS[TrainerIdToTournamentId(TRAINER_PLAYER)].forfeited = TRUE;
@@ -5401,7 +5164,7 @@ static u16 GetWinningMove(int winnerTournamentId, int loserTournamentId, u8 roun
movePower = 40;
else if (movePower == 1)
movePower = 60;
- else if (moveIds[i * MAX_MON_MOVES + j] == MOVE_SELF_DESTRUCT
+ else if (moveIds[i * MAX_MON_MOVES + j] == MOVE_SELF_DESTRUCT
|| moveIds[i * MAX_MON_MOVES + j] == MOVE_EXPLOSION)
movePower /= 2;
@@ -5534,7 +5297,7 @@ static void Task_ShowTourneyTree(u8 taskId)
gTasks[taskId].tState++;
break;
case 2:
- sTilemapBuffer = AllocZeroed(0x800);
+ sTilemapBuffer = AllocZeroed(BG_SCREEN_SIZE);
LZDecompressWram(gDomeTourneyLineMask_Tilemap, sTilemapBuffer);
SetBgTilemapBuffer(1, sTilemapBuffer);
CopyBgTilemapBufferToVram(1);
@@ -5558,7 +5321,7 @@ static void Task_ShowTourneyTree(u8 taskId)
{
for (i = 0; i < ARRAY_COUNT(sTourneyTreePokeballCoords); i++)
CreateSprite(&sTourneyTreePokeballSpriteTemplate, sTourneyTreePokeballCoords[i][0], sTourneyTreePokeballCoords[i][1], 0);
-
+
if (gTasks[taskId].tIsPrevTourneyTree)
CreateSprite(&sExitButtonSpriteTemplate, 218, 12, 0);
else
@@ -5698,7 +5461,7 @@ static void Task_ShowTourneyTree(u8 taskId)
gTasks[i].tState = 0;
}
ScanlineEffect_Clear();
-
+
i = 0;
while (i < 91)
{
@@ -5713,7 +5476,7 @@ static void Task_ShowTourneyTree(u8 taskId)
gScanlineEffectRegBuffers[1][i] = BGCNT_PRIORITY(1) | BGCNT_SCREENBASE(31) | BGCNT_16COLOR | BGCNT_CHARBASE(2) | BGCNT_TXT256x256;
i++;
}
-
+
ScanlineEffect_SetParams(sTourneyTreeScanlineEffectParams);
DestroyTask(taskId);
break;
@@ -5794,7 +5557,7 @@ static void Task_HandleStaticTourneyTreeInput(u8 taskId)
gTasks[taskId].tState = STATE_WAIT_FOR_INPUT;
break;
case STATE_WAIT_FOR_INPUT:
- if (gMain.newKeys & (A_BUTTON | B_BUTTON))
+ if (JOY_NEW(A_BUTTON | B_BUTTON))
{
BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, RGB_BLACK);
gTasks[taskId].tState = STATE_CLOSE_TOURNEY_TREE;
@@ -5851,67 +5614,67 @@ static void HblankCb_TourneyTree(void)
if (vCount < 42)
{
- REG_WININ = WININ_WIN0_BG_ALL | WININ_WIN0_CLR | WININ_WIN0_OBJ
+ REG_WININ = WININ_WIN0_BG_ALL | WININ_WIN0_CLR | WININ_WIN0_OBJ
| WININ_WIN1_BG_ALL | WININ_WIN1_CLR | WININ_WIN1_OBJ;
SET_WIN0H_WIN1H(0, 0);
}
else if (vCount < 50)
{
- REG_WININ = WININ_WIN0_BG0 | WININ_WIN0_BG1 | WININ_WIN0_BG3 | WININ_WIN0_OBJ | WININ_WIN0_CLR
+ REG_WININ = WININ_WIN0_BG0 | WININ_WIN0_BG1 | WININ_WIN0_BG3 | WININ_WIN0_OBJ | WININ_WIN0_CLR
| WININ_WIN1_BG0 | WININ_WIN1_BG1 | WININ_WIN1_BG3 | WININ_WIN1_OBJ | WININ_WIN1_CLR;
SET_WIN0H_WIN1H(WIN_RANGE(152, 155), WIN_RANGE(85, 88));
}
else if (vCount < 58)
{
- REG_WININ = WININ_WIN0_BG_ALL | WININ_WIN0_CLR | WININ_WIN0_OBJ
+ REG_WININ = WININ_WIN0_BG_ALL | WININ_WIN0_CLR | WININ_WIN0_OBJ
| WININ_WIN1_BG_ALL | WININ_WIN1_CLR | WININ_WIN1_OBJ;
SET_WIN0H_WIN1H(0, 0);
}
else if (vCount < 75)
{
- REG_WININ = WININ_WIN0_BG0 | WININ_WIN0_BG1 | WININ_WIN0_BG3 | WININ_WIN0_OBJ | WININ_WIN0_CLR
+ REG_WININ = WININ_WIN0_BG0 | WININ_WIN0_BG1 | WININ_WIN0_BG3 | WININ_WIN0_OBJ | WININ_WIN0_CLR
| WININ_WIN1_BG0 | WININ_WIN1_BG1 | WININ_WIN1_BG3 | WININ_WIN1_OBJ | WININ_WIN1_CLR;
SET_WIN0H_WIN1H(WIN_RANGE(144, 152), WIN_RANGE(88, 96));
}
else if (vCount < 82)
{
- REG_WININ = WININ_WIN0_BG0 | WININ_WIN0_BG1 | WININ_WIN0_BG3 | WININ_WIN0_OBJ | WININ_WIN0_CLR
+ REG_WININ = WININ_WIN0_BG0 | WININ_WIN0_BG1 | WININ_WIN0_BG3 | WININ_WIN0_OBJ | WININ_WIN0_CLR
| WININ_WIN1_BG0 | WININ_WIN1_BG1 | WININ_WIN1_BG3 | WININ_WIN1_OBJ | WININ_WIN1_CLR;
SET_WIN0H_WIN1H(WIN_RANGE(152, 155), WIN_RANGE(85, 88));
}
else if (vCount < 95)
{
- REG_WININ = WININ_WIN0_BG_ALL | WININ_WIN0_CLR | WININ_WIN0_OBJ
+ REG_WININ = WININ_WIN0_BG_ALL | WININ_WIN0_CLR | WININ_WIN0_OBJ
| WININ_WIN1_BG_ALL | WININ_WIN1_CLR | WININ_WIN1_OBJ;
SET_WIN0H_WIN1H(0, 0);
}
else if (vCount < 103)
{
- REG_WININ = WININ_WIN0_BG0 | WININ_WIN0_BG1 | WININ_WIN0_BG2 | WININ_WIN0_OBJ | WININ_WIN0_CLR
+ REG_WININ = WININ_WIN0_BG0 | WININ_WIN0_BG1 | WININ_WIN0_BG2 | WININ_WIN0_OBJ | WININ_WIN0_CLR
| WININ_WIN1_BG0 | WININ_WIN1_BG1 | WININ_WIN1_BG2 | WININ_WIN1_OBJ | WININ_WIN1_CLR;
SET_WIN0H_WIN1H(WIN_RANGE(152, 155), WIN_RANGE(85, 88));
}
else if (vCount < 119)
{
- REG_WININ = WININ_WIN0_BG0 | WININ_WIN0_BG1 | WININ_WIN0_BG2 | WININ_WIN0_OBJ | WININ_WIN0_CLR
+ REG_WININ = WININ_WIN0_BG0 | WININ_WIN0_BG1 | WININ_WIN0_BG2 | WININ_WIN0_OBJ | WININ_WIN0_CLR
| WININ_WIN1_BG0 | WININ_WIN1_BG1 | WININ_WIN1_BG2 | WININ_WIN1_OBJ | WININ_WIN1_CLR;
SET_WIN0H_WIN1H(WIN_RANGE(144, 152), WIN_RANGE(88, 96));
}
else if (vCount < 127)
{
- REG_WININ = WININ_WIN0_BG_ALL | WININ_WIN0_CLR | WININ_WIN0_OBJ
+ REG_WININ = WININ_WIN0_BG_ALL | WININ_WIN0_CLR | WININ_WIN0_OBJ
| WININ_WIN1_BG_ALL | WININ_WIN1_CLR | WININ_WIN1_OBJ;
SET_WIN0H_WIN1H(0, 0);
}
else if (vCount < 135)
{
- REG_WININ = WININ_WIN0_BG0 | WININ_WIN0_BG1 | WININ_WIN0_BG2 | WININ_WIN0_OBJ | WININ_WIN0_CLR
+ REG_WININ = WININ_WIN0_BG0 | WININ_WIN0_BG1 | WININ_WIN0_BG2 | WININ_WIN0_OBJ | WININ_WIN0_CLR
| WININ_WIN1_BG0 | WININ_WIN1_BG1 | WININ_WIN1_BG2 | WININ_WIN1_OBJ | WININ_WIN1_CLR;
SET_WIN0H_WIN1H(WIN_RANGE(152, 155), WIN_RANGE(85, 88));
}
else
{
- REG_WININ = WININ_WIN0_BG_ALL | WININ_WIN0_CLR | WININ_WIN0_OBJ
+ REG_WININ = WININ_WIN0_BG_ALL | WININ_WIN0_CLR | WININ_WIN0_OBJ
| WININ_WIN1_BG_ALL | WININ_WIN1_CLR | WININ_WIN1_OBJ;
SET_WIN0H_WIN1H(0, 0);
}
@@ -6207,6 +5970,10 @@ static void DecideRoundWinners(u8 roundId)
else if (tournamentId2 != 0xFF)
{
// BUG: points1 and points2 are not cleared at the beginning of the loop resulting in not fair results.
+ #ifdef BUGFIX
+ points1 = 0;
+ points2 = 0;
+ #endif
// Calculate points for both trainers.
for (monId1 = 0; monId1 < FRONTIER_PARTY_SIZE; monId1++)