Merge branch 'master' of https://github.com/pret/pokefirered
This commit is contained in:
@@ -14,7 +14,7 @@
|
||||
extern const u8 gText_DepositItem[];
|
||||
|
||||
const u16 gUnknown_8453098[] = INCBIN_U16("data/bag/bag_window_pal.gbapal");
|
||||
const struct TextColor gUnknown_84530B8[] = {
|
||||
const u8 gUnknown_84530B8[][3] = {
|
||||
{0, 1, 2},
|
||||
{0, 2, 3},
|
||||
{0, 3, 2},
|
||||
@@ -229,13 +229,13 @@ void sub_810B858(void)
|
||||
|
||||
void sub_810B8F0(u8 windowId, u8 fontId, const u8 * str, u8 x, u8 y, u8 letterSpacing, u8 lineSpacing, s8 speed, u8 colorIdx)
|
||||
{
|
||||
AddTextPrinterParameterized4(windowId, fontId, x, y, letterSpacing, lineSpacing, &gUnknown_84530B8[colorIdx], speed, str);
|
||||
AddTextPrinterParameterized4(windowId, fontId, x, y, letterSpacing, lineSpacing, gUnknown_84530B8[colorIdx], speed, str);
|
||||
}
|
||||
|
||||
void sub_810B958(const u8 * str)
|
||||
{
|
||||
u32 x = 0x48 - GetStringWidth(1, str, 0);
|
||||
AddTextPrinterParameterized3(2, 1, x / 2, 1, &gUnknown_84530B8[0], 0, str);
|
||||
AddTextPrinterParameterized3(2, 1, x / 2, 1, gUnknown_84530B8[0], 0, str);
|
||||
}
|
||||
|
||||
void sub_810B994(void)
|
||||
|
||||
+115
-124
@@ -1,16 +1,17 @@
|
||||
#include "global.h"
|
||||
#include "battle.h"
|
||||
#include "battle_main.h"
|
||||
#include "util.h"
|
||||
#include "item.h"
|
||||
#include "random.h"
|
||||
#include "pokemon.h"
|
||||
#include "battle_ai_script_commands.h"
|
||||
#include "constants/species.h"
|
||||
#include "constants/abilities.h"
|
||||
#include "constants/battle_ai.h"
|
||||
#include "constants/battle_move_effects.h"
|
||||
#include "constants/moves.h"
|
||||
|
||||
extern u16 Random(void);
|
||||
extern void sub_80C7164(void);
|
||||
|
||||
#define AI_ACTION_DONE 0x0001
|
||||
#define AI_ACTION_FLEE 0x0002
|
||||
#define AI_ACTION_WATCH 0x0004
|
||||
@@ -20,8 +21,8 @@ extern void sub_80C7164(void);
|
||||
#define AI_ACTION_UNK7 0x0040
|
||||
#define AI_ACTION_UNK8 0x0080
|
||||
|
||||
#define AI_THINKING_STRUCT ((struct AI_ThinkingStruct *)(gBattleResources->ai))
|
||||
#define BATTLE_HISTORY ((struct BattleHistory *)(gBattleResources->battleHistory))
|
||||
#define AI_THINKING_STRUCT (gBattleResources->ai)
|
||||
#define BATTLE_HISTORY (gBattleResources->battleHistory)
|
||||
|
||||
// AI states
|
||||
enum
|
||||
@@ -32,9 +33,16 @@ enum
|
||||
AIState_DoNotProcess
|
||||
};
|
||||
|
||||
/*
|
||||
gAIScriptPtr is a pointer to the next battle AI cmd command to read.
|
||||
when a command finishes processing, gAIScriptPtr is incremented by
|
||||
the number of bytes that the current command had reserved for arguments
|
||||
in order to read the next command correctly. refer to battle_ai_scripts.s for the
|
||||
AI scripts.
|
||||
*/
|
||||
|
||||
extern const u8 *gAIScriptPtr;
|
||||
extern u8 *BattleAIs[];
|
||||
extern u16 gLastUsedMove[];
|
||||
extern u8 *gBattleAI_ScriptsTable[];
|
||||
|
||||
static void BattleAICmd_if_random_less_than(void);
|
||||
static void BattleAICmd_if_random_greater_than(void);
|
||||
@@ -131,6 +139,11 @@ static void BattleAICmd_if_level_compare(void);
|
||||
static void BattleAICmd_if_taunted(void);
|
||||
static void BattleAICmd_if_not_taunted(void);
|
||||
|
||||
static void RecordLastUsedMoveByTarget(void);
|
||||
static void BattleAI_DoAIProcessing(void);
|
||||
static void AIStackPushVar(const u8 *ptr);
|
||||
static bool8 AIStackPop(void);
|
||||
|
||||
typedef void (*BattleAICmdFunc)(void);
|
||||
|
||||
static const BattleAICmdFunc sBattleAICmdTable[] =
|
||||
@@ -248,23 +261,6 @@ static const u16 sDiscouragedPowerfulMoveEffects[] =
|
||||
0xFFFF
|
||||
};
|
||||
|
||||
// TODO: move these
|
||||
extern u8 sBattler_AI;
|
||||
extern const u32 gBitTable[]; // util.h
|
||||
extern u32 gStatuses3[]; // battle_2.h
|
||||
extern u16 gSideAffecting[2];
|
||||
extern const struct BattleMove gBattleMoves[];
|
||||
extern u16 gDynamicBasePower;
|
||||
extern u8 gMoveResultFlags;
|
||||
extern u8 gCritMultiplier;
|
||||
extern u16 gCurrentMove;
|
||||
extern s32 gBattleMoveDamage;
|
||||
|
||||
void BattleAI_SetupAIData(void);
|
||||
void BattleAI_DoAIProcessing(void);
|
||||
void AIStackPushVar(const u8 *ptr);
|
||||
bool8 AIStackPop(void);
|
||||
|
||||
void BattleAI_HandleItemUseBeforeAISetup(void)
|
||||
{
|
||||
s32 i;
|
||||
@@ -275,9 +271,9 @@ void BattleAI_HandleItemUseBeforeAISetup(void)
|
||||
|
||||
// Items are allowed to use in ONLY trainer battles.
|
||||
// TODO: Use proper flags
|
||||
if ((gBattleTypeFlags & 0x8)
|
||||
if ((gBattleTypeFlags & BATTLE_TYPE_TRAINER)
|
||||
&& (gTrainerBattleOpponent_A != 0x400)
|
||||
&& !(gBattleTypeFlags & 0x80982)
|
||||
&& !(gBattleTypeFlags & (BATTLE_TYPE_TRAINER_TOWER | BATTLE_TYPE_EREADER_TRAINER | BATTLE_TYPE_BATTLE_TOWER | BATTLE_TYPE_SAFARI | BATTLE_TYPE_LINK))
|
||||
)
|
||||
{
|
||||
for (i = 0; i < 4; i++)
|
||||
@@ -318,7 +314,7 @@ void BattleAI_SetupAIData(void)
|
||||
}
|
||||
|
||||
gBattleResources->AI_ScriptsStack->size = 0;
|
||||
sBattler_AI = gActiveBattler;
|
||||
gBattlerAttacker = gActiveBattler;
|
||||
|
||||
// Decide a random target battlerId in doubles.
|
||||
if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE)
|
||||
@@ -331,7 +327,7 @@ void BattleAI_SetupAIData(void)
|
||||
// There's only one choice in single battles.
|
||||
else
|
||||
{
|
||||
gBattlerTarget = sBattler_AI ^ BIT_SIDE;
|
||||
gBattlerTarget = gBattlerAttacker ^ BIT_SIDE;
|
||||
}
|
||||
|
||||
// Choose proper trainer ai scripts.
|
||||
@@ -348,12 +344,12 @@ void BattleAI_SetupAIData(void)
|
||||
}
|
||||
else if (!(gBattleTypeFlags & (0x80900)) && (gTrainerBattleOpponent_A != 0x400)) // _080C6ECC
|
||||
{
|
||||
if(gBattleTypeFlags & (0x80 << 10))
|
||||
if (gBattleTypeFlags & (0x80 << 10))
|
||||
{
|
||||
AI_THINKING_STRUCT->aiFlags = 1;
|
||||
return;
|
||||
}
|
||||
else if(gBattleTypeFlags & (0x80 << 11))
|
||||
else if (gBattleTypeFlags & (0x80 << 11))
|
||||
{
|
||||
AI_THINKING_STRUCT->aiFlags = 7;
|
||||
return;
|
||||
@@ -367,14 +363,14 @@ void BattleAI_SetupAIData(void)
|
||||
AI_THINKING_STRUCT->aiFlags = gTrainers[gTrainerBattleOpponent_A].aiFlags;
|
||||
}
|
||||
|
||||
u8 BattleAI_GetAIActionToUse(void)
|
||||
u8 BattleAI_ChooseMoveOrAction(void)
|
||||
{
|
||||
u8 currentMoveArray[MAX_MON_MOVES];
|
||||
u8 consideredMoveArray[MAX_MON_MOVES];
|
||||
u8 numOfBestMoves;
|
||||
s32 i;
|
||||
|
||||
sub_80C7164();
|
||||
RecordLastUsedMoveByTarget();
|
||||
while (AI_THINKING_STRUCT->aiFlags != 0)
|
||||
{
|
||||
if (AI_THINKING_STRUCT->aiFlags & 1)
|
||||
@@ -415,7 +411,7 @@ u8 BattleAI_GetAIActionToUse(void)
|
||||
return consideredMoveArray[Random() % numOfBestMoves]; // break any ties that exist.
|
||||
}
|
||||
|
||||
void BattleAI_DoAIProcessing(void)
|
||||
static void BattleAI_DoAIProcessing(void)
|
||||
{
|
||||
while (AI_THINKING_STRUCT->aiState != AIState_FinishedProcessing)
|
||||
{
|
||||
@@ -424,14 +420,14 @@ void BattleAI_DoAIProcessing(void)
|
||||
case AIState_DoNotProcess: //Needed to match.
|
||||
break;
|
||||
case AIState_SettingUp:
|
||||
gAIScriptPtr = BattleAIs[AI_THINKING_STRUCT->aiLogicId]; // set the AI ptr.
|
||||
if (gBattleMons[sBattler_AI].pp[AI_THINKING_STRUCT->movesetIndex] == 0)
|
||||
gAIScriptPtr = gBattleAI_ScriptsTable[AI_THINKING_STRUCT->aiLogicId]; // set the AI ptr.
|
||||
if (gBattleMons[gBattlerAttacker].pp[AI_THINKING_STRUCT->movesetIndex] == 0)
|
||||
{
|
||||
AI_THINKING_STRUCT->moveConsidered = 0; // don't consider a move you have 0 PP for, idiot.
|
||||
}
|
||||
else
|
||||
{
|
||||
AI_THINKING_STRUCT->moveConsidered = gBattleMons[sBattler_AI].moves[AI_THINKING_STRUCT->movesetIndex];
|
||||
AI_THINKING_STRUCT->moveConsidered = gBattleMons[gBattlerAttacker].moves[AI_THINKING_STRUCT->movesetIndex];
|
||||
}
|
||||
AI_THINKING_STRUCT->aiState++;
|
||||
break;
|
||||
@@ -458,7 +454,7 @@ void BattleAI_DoAIProcessing(void)
|
||||
}
|
||||
}
|
||||
|
||||
void sub_80C7164(void)
|
||||
static void RecordLastUsedMoveByTarget(void)
|
||||
{
|
||||
s32 i;
|
||||
|
||||
@@ -466,30 +462,31 @@ void sub_80C7164(void)
|
||||
{
|
||||
if (BATTLE_HISTORY->usedMoves[gBattlerTarget >> 1][i] == 0)
|
||||
{
|
||||
BATTLE_HISTORY->usedMoves[gBattlerTarget >> 1][i] = gLastUsedMove[gBattlerTarget];
|
||||
BATTLE_HISTORY->usedMoves[gBattlerTarget >> 1][i] = gLastMoves[gBattlerTarget];
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void sub_80C71A8(u8 a)
|
||||
// not used
|
||||
static void ClearBattlerMoveHistory(u8 battlerId)
|
||||
{
|
||||
s32 i;
|
||||
|
||||
for (i = 0; i < 8; i++)
|
||||
BATTLE_HISTORY->usedMoves[a / 2][i] = 0;
|
||||
BATTLE_HISTORY->usedMoves[battlerId / 2][i] = MOVE_NONE;
|
||||
}
|
||||
|
||||
void sub_80C71D0(u8 a, u8 b)
|
||||
void RecordAbilityBattle(u8 battlerId, u8 abilityId)
|
||||
{
|
||||
if (GetBattlerSide(a) == 0)
|
||||
BATTLE_HISTORY->abilities[GetBattlerPosition(a) & 1] = b;
|
||||
if (GetBattlerSide(battlerId) == 0)
|
||||
BATTLE_HISTORY->abilities[GetBattlerPosition(battlerId) & 1] = abilityId;
|
||||
}
|
||||
|
||||
void sub_80C7208(u8 a, u8 b)
|
||||
void RecordItemEffectBattle(u8 battlerId, u8 itemEffect)
|
||||
{
|
||||
if (GetBattlerSide(a) == 0)
|
||||
BATTLE_HISTORY->itemEffects[GetBattlerPosition(a) & 1] = b;
|
||||
if (GetBattlerSide(battlerId) == 0)
|
||||
BATTLE_HISTORY->itemEffects[GetBattlerPosition(battlerId) & 1] = itemEffect;
|
||||
}
|
||||
|
||||
static void BattleAICmd_if_random_less_than(void)
|
||||
@@ -544,7 +541,7 @@ static void BattleAICmd_if_hp_less_than(void)
|
||||
u16 index;
|
||||
|
||||
if (gAIScriptPtr[1] == USER)
|
||||
index = sBattler_AI;
|
||||
index = gBattlerAttacker;
|
||||
else
|
||||
index = gBattlerTarget;
|
||||
|
||||
@@ -559,7 +556,7 @@ static void BattleAICmd_if_hp_more_than(void)
|
||||
u16 index;
|
||||
|
||||
if (gAIScriptPtr[1] == USER)
|
||||
index = sBattler_AI;
|
||||
index = gBattlerAttacker;
|
||||
else
|
||||
index = gBattlerTarget;
|
||||
|
||||
@@ -574,7 +571,7 @@ static void BattleAICmd_if_hp_equal(void)
|
||||
u16 index;
|
||||
|
||||
if (gAIScriptPtr[1] == USER)
|
||||
index = sBattler_AI;
|
||||
index = gBattlerAttacker;
|
||||
else
|
||||
index = gBattlerTarget;
|
||||
|
||||
@@ -589,7 +586,7 @@ static void BattleAICmd_if_hp_not_equal(void)
|
||||
u16 index;
|
||||
|
||||
if (gAIScriptPtr[1] == USER)
|
||||
index = sBattler_AI;
|
||||
index = gBattlerAttacker;
|
||||
else
|
||||
index = gBattlerTarget;
|
||||
|
||||
@@ -605,7 +602,7 @@ static void BattleAICmd_if_status(void)
|
||||
u32 arg;
|
||||
|
||||
if (gAIScriptPtr[1] == USER)
|
||||
index = sBattler_AI;
|
||||
index = gBattlerAttacker;
|
||||
else
|
||||
index = gBattlerTarget;
|
||||
|
||||
@@ -623,7 +620,7 @@ static void BattleAICmd_if_not_status(void)
|
||||
u32 arg;
|
||||
|
||||
if (gAIScriptPtr[1] == USER)
|
||||
index = sBattler_AI;
|
||||
index = gBattlerAttacker;
|
||||
else
|
||||
index = gBattlerTarget;
|
||||
|
||||
@@ -641,7 +638,7 @@ static void BattleAICmd_if_status2(void)
|
||||
u32 arg;
|
||||
|
||||
if (gAIScriptPtr[1] == USER)
|
||||
index = sBattler_AI;
|
||||
index = gBattlerAttacker;
|
||||
else
|
||||
index = gBattlerTarget;
|
||||
|
||||
@@ -659,7 +656,7 @@ static void BattleAICmd_if_not_status2(void)
|
||||
u32 arg;
|
||||
|
||||
if (gAIScriptPtr[1] == USER)
|
||||
index = sBattler_AI;
|
||||
index = gBattlerAttacker;
|
||||
else
|
||||
index = gBattlerTarget;
|
||||
|
||||
@@ -677,7 +674,7 @@ static void BattleAICmd_if_status3(void)
|
||||
u32 arg;
|
||||
|
||||
if (gAIScriptPtr[1] == USER)
|
||||
index = sBattler_AI;
|
||||
index = gBattlerAttacker;
|
||||
else
|
||||
index = gBattlerTarget;
|
||||
|
||||
@@ -695,7 +692,7 @@ static void BattleAICmd_if_not_status3(void)
|
||||
u32 arg;
|
||||
|
||||
if (gAIScriptPtr[1] == USER)
|
||||
index = sBattler_AI;
|
||||
index = gBattlerAttacker;
|
||||
else
|
||||
index = gBattlerTarget;
|
||||
|
||||
@@ -713,14 +710,14 @@ static void BattleAICmd_if_status4(void)
|
||||
u32 arg1, arg2;
|
||||
|
||||
if (gAIScriptPtr[1] == USER)
|
||||
index = sBattler_AI;
|
||||
index = gBattlerAttacker;
|
||||
else
|
||||
index = gBattlerTarget;
|
||||
|
||||
arg1 = GetBattlerPosition(index) & 1;
|
||||
arg2 = T1_READ_32(gAIScriptPtr + 2);
|
||||
|
||||
if ((gSideAffecting[arg1] & arg2) != 0)
|
||||
if ((gSideStatuses[arg1] & arg2) != 0)
|
||||
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 6);
|
||||
else
|
||||
gAIScriptPtr += 10;
|
||||
@@ -732,14 +729,14 @@ static void BattleAICmd_if_not_status4(void)
|
||||
u32 arg1, arg2;
|
||||
|
||||
if (gAIScriptPtr[1] == USER)
|
||||
index = sBattler_AI;
|
||||
index = gBattlerAttacker;
|
||||
else
|
||||
index = gBattlerTarget;
|
||||
|
||||
arg1 = GetBattlerPosition(index) & 1;
|
||||
arg2 = T1_READ_32(gAIScriptPtr + 2);
|
||||
|
||||
if ((gSideAffecting[arg1] & arg2) == 0)
|
||||
if ((gSideStatuses[arg1] & arg2) == 0)
|
||||
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 6);
|
||||
else
|
||||
gAIScriptPtr += 10;
|
||||
@@ -907,8 +904,8 @@ static void BattleAICmd_if_user_can_damage(void)
|
||||
|
||||
for (i = 0; i < MAX_MON_MOVES; i++)
|
||||
{
|
||||
if (gBattleMons[sBattler_AI].moves[i] != 0
|
||||
&& gBattleMoves[gBattleMons[sBattler_AI].moves[i]].power != 0)
|
||||
if (gBattleMons[gBattlerAttacker].moves[i] != 0
|
||||
&& gBattleMoves[gBattleMons[gBattlerAttacker].moves[i]].power != 0)
|
||||
break;
|
||||
}
|
||||
if (i == MAX_MON_MOVES)
|
||||
@@ -923,8 +920,8 @@ static void BattleAICmd_if_user_cant_damage(void)
|
||||
|
||||
for (i = 0; i < MAX_MON_MOVES; i++)
|
||||
{
|
||||
if (gBattleMons[sBattler_AI].moves[i] != 0
|
||||
&& gBattleMoves[gBattleMons[sBattler_AI].moves[i]].power != 0)
|
||||
if (gBattleMons[gBattlerAttacker].moves[i] != 0
|
||||
&& gBattleMoves[gBattleMons[gBattlerAttacker].moves[i]].power != 0)
|
||||
break;
|
||||
}
|
||||
if (i != MAX_MON_MOVES)
|
||||
@@ -944,13 +941,13 @@ static void BattleAICmd_get_type(void)
|
||||
switch (gAIScriptPtr[1])
|
||||
{
|
||||
case 1: // player primary type
|
||||
AI_THINKING_STRUCT->funcResult = gBattleMons[sBattler_AI].type1;
|
||||
AI_THINKING_STRUCT->funcResult = gBattleMons[gBattlerAttacker].type1;
|
||||
break;
|
||||
case 0: // enemy primary type
|
||||
AI_THINKING_STRUCT->funcResult = gBattleMons[gBattlerTarget].type1;
|
||||
break;
|
||||
case 3: // player secondary type
|
||||
AI_THINKING_STRUCT->funcResult = gBattleMons[sBattler_AI].type2;
|
||||
AI_THINKING_STRUCT->funcResult = gBattleMons[gBattlerAttacker].type2;
|
||||
break;
|
||||
case 2: // enemy secondary type
|
||||
AI_THINKING_STRUCT->funcResult = gBattleMons[gBattlerTarget].type2;
|
||||
@@ -992,17 +989,17 @@ static void BattleAICmd_is_most_powerful_move(void)
|
||||
{
|
||||
for (i = 0; sDiscouragedPowerfulMoveEffects[i] != 0xFFFF; i++)
|
||||
{
|
||||
if (gBattleMoves[gBattleMons[sBattler_AI].moves[checkedMove]].effect == sDiscouragedPowerfulMoveEffects[i])
|
||||
if (gBattleMoves[gBattleMons[gBattlerAttacker].moves[checkedMove]].effect == sDiscouragedPowerfulMoveEffects[i])
|
||||
break;
|
||||
}
|
||||
|
||||
if (gBattleMons[sBattler_AI].moves[checkedMove] != MOVE_NONE
|
||||
if (gBattleMons[gBattlerAttacker].moves[checkedMove] != MOVE_NONE
|
||||
&& sDiscouragedPowerfulMoveEffects[i] == 0xFFFF
|
||||
&& gBattleMoves[gBattleMons[sBattler_AI].moves[checkedMove]].power > 1)
|
||||
&& gBattleMoves[gBattleMons[gBattlerAttacker].moves[checkedMove]].power > 1)
|
||||
{
|
||||
gCurrentMove = gBattleMons[sBattler_AI].moves[checkedMove];
|
||||
AI_CalcDmg(sBattler_AI, gBattlerTarget);
|
||||
TypeCalc(gCurrentMove, sBattler_AI, gBattlerTarget);
|
||||
gCurrentMove = gBattleMons[gBattlerAttacker].moves[checkedMove];
|
||||
AI_CalcDmg(gBattlerAttacker, gBattlerTarget);
|
||||
TypeCalc(gCurrentMove, gBattlerAttacker, gBattlerTarget);
|
||||
moveDmgs[checkedMove] = gBattleMoveDamage * AI_THINKING_STRUCT->simulatedRNG[checkedMove] / 100;
|
||||
if (moveDmgs[checkedMove] == 0)
|
||||
moveDmgs[checkedMove] = 1;
|
||||
@@ -1035,9 +1032,9 @@ static void BattleAICmd_is_most_powerful_move(void)
|
||||
static void BattleAICmd_get_move(void)
|
||||
{
|
||||
if (gAIScriptPtr[1] == USER)
|
||||
AI_THINKING_STRUCT->funcResult = gLastUsedMove[sBattler_AI];
|
||||
AI_THINKING_STRUCT->funcResult = gLastMoves[gBattlerAttacker];
|
||||
else
|
||||
AI_THINKING_STRUCT->funcResult = gLastUsedMove[gBattlerTarget];
|
||||
AI_THINKING_STRUCT->funcResult = gLastMoves[gBattlerTarget];
|
||||
|
||||
gAIScriptPtr += 2;
|
||||
}
|
||||
@@ -1060,7 +1057,7 @@ static void BattleAICmd_if_arg_not_equal(void)
|
||||
|
||||
static void BattleAICmd_if_would_go_first(void)
|
||||
{
|
||||
if (GetWhoStrikesFirst(sBattler_AI, gBattlerTarget, TRUE) == gAIScriptPtr[1])
|
||||
if (GetWhoStrikesFirst(gBattlerAttacker, gBattlerTarget, TRUE) == gAIScriptPtr[1])
|
||||
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 2);
|
||||
else
|
||||
gAIScriptPtr += 6;
|
||||
@@ -1068,7 +1065,7 @@ static void BattleAICmd_if_would_go_first(void)
|
||||
|
||||
static void BattleAICmd_if_would_not_go_first(void)
|
||||
{
|
||||
if (GetWhoStrikesFirst(sBattler_AI, gBattlerTarget, TRUE) != gAIScriptPtr[1])
|
||||
if (GetWhoStrikesFirst(gBattlerAttacker, gBattlerTarget, TRUE) != gAIScriptPtr[1])
|
||||
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 2);
|
||||
else
|
||||
gAIScriptPtr += 6;
|
||||
@@ -1092,7 +1089,7 @@ static void BattleAICmd_count_alive_pokemon(void)
|
||||
AI_THINKING_STRUCT->funcResult = 0;
|
||||
|
||||
if (gAIScriptPtr[1] == USER)
|
||||
index = sBattler_AI;
|
||||
index = gBattlerAttacker;
|
||||
else
|
||||
index = gBattlerTarget;
|
||||
|
||||
@@ -1145,7 +1142,7 @@ static void BattleAICmd_get_ability(void)
|
||||
u8 index;
|
||||
|
||||
if (gAIScriptPtr[1] == USER)
|
||||
index = sBattler_AI;
|
||||
index = gBattlerAttacker;
|
||||
else
|
||||
index = gBattlerTarget;
|
||||
|
||||
@@ -1218,11 +1215,11 @@ static void BattleAICmd_get_highest_possible_damage(void)
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
gBattleMoveDamage = 40;
|
||||
gCurrentMove = gBattleMons[sBattler_AI].moves[i];
|
||||
gCurrentMove = gBattleMons[gBattlerAttacker].moves[i];
|
||||
|
||||
if (gCurrentMove != 0)
|
||||
{
|
||||
TypeCalc(gCurrentMove, sBattler_AI, gBattlerTarget);
|
||||
TypeCalc(gCurrentMove, gBattlerAttacker, gBattlerTarget);
|
||||
|
||||
if (gBattleMoveDamage == 120) // Super effective STAB.
|
||||
gBattleMoveDamage = AI_EFFECTIVENESS_x2;
|
||||
@@ -1257,7 +1254,7 @@ static void BattleAICmd_if_type_effectiveness(void)
|
||||
gBattleMoveDamage = AI_EFFECTIVENESS_x1;
|
||||
gCurrentMove = AI_THINKING_STRUCT->moveConsidered;
|
||||
|
||||
TypeCalc(gCurrentMove, sBattler_AI, gBattlerTarget);
|
||||
TypeCalc(gCurrentMove, gBattlerAttacker, gBattlerTarget);
|
||||
|
||||
if (gBattleMoveDamage == 120) // Super effective STAB.
|
||||
gBattleMoveDamage = AI_EFFECTIVENESS_x2;
|
||||
@@ -1373,7 +1370,7 @@ static void BattleAICmd_get_weather(void)
|
||||
AI_THINKING_STRUCT->funcResult = WEATHER_TYPE_RAIN;
|
||||
if (gBattleWeather & WEATHER_SANDSTORM_ANY)
|
||||
AI_THINKING_STRUCT->funcResult = WEATHER_TYPE_SANDSTORM;
|
||||
if (gBattleWeather & WEATHER_SUNNY_ANY)
|
||||
if (gBattleWeather & WEATHER_SUN_ANY)
|
||||
AI_THINKING_STRUCT->funcResult = WEATHER_TYPE_SUNNY;
|
||||
if (gBattleWeather & WEATHER_HAIL)
|
||||
AI_THINKING_STRUCT->funcResult = WEATHER_TYPE_HAIL;
|
||||
@@ -1402,7 +1399,7 @@ static void BattleAICmd_if_stat_level_less_than(void)
|
||||
u32 party;
|
||||
|
||||
if (gAIScriptPtr[1] == USER)
|
||||
party = sBattler_AI;
|
||||
party = gBattlerAttacker;
|
||||
else
|
||||
party = gBattlerTarget;
|
||||
|
||||
@@ -1417,7 +1414,7 @@ static void BattleAICmd_if_stat_level_more_than(void)
|
||||
u32 party;
|
||||
|
||||
if (gAIScriptPtr[1] == USER)
|
||||
party = sBattler_AI;
|
||||
party = gBattlerAttacker;
|
||||
else
|
||||
party = gBattlerTarget;
|
||||
|
||||
@@ -1432,7 +1429,7 @@ static void BattleAICmd_if_stat_level_equal(void)
|
||||
u32 party;
|
||||
|
||||
if (gAIScriptPtr[1] == USER)
|
||||
party = sBattler_AI;
|
||||
party = gBattlerAttacker;
|
||||
else
|
||||
party = gBattlerTarget;
|
||||
|
||||
@@ -1447,7 +1444,7 @@ static void BattleAICmd_if_stat_level_not_equal(void)
|
||||
u32 party;
|
||||
|
||||
if (gAIScriptPtr[1] == USER)
|
||||
party = sBattler_AI;
|
||||
party = gBattlerAttacker;
|
||||
else
|
||||
party = gBattlerTarget;
|
||||
|
||||
@@ -1471,8 +1468,8 @@ static void BattleAICmd_if_can_faint(void)
|
||||
gMoveResultFlags = 0;
|
||||
gCritMultiplier = 1;
|
||||
gCurrentMove = AI_THINKING_STRUCT->moveConsidered;
|
||||
AI_CalcDmg(sBattler_AI, gBattlerTarget);
|
||||
TypeCalc(gCurrentMove, sBattler_AI, gBattlerTarget);
|
||||
AI_CalcDmg(gBattlerAttacker, gBattlerTarget);
|
||||
TypeCalc(gCurrentMove, gBattlerAttacker, gBattlerTarget);
|
||||
|
||||
gBattleMoveDamage = gBattleMoveDamage * AI_THINKING_STRUCT->simulatedRNG[AI_THINKING_STRUCT->movesetIndex] / 100;
|
||||
|
||||
@@ -1500,8 +1497,8 @@ static void BattleAICmd_if_cant_faint(void)
|
||||
gMoveResultFlags = 0;
|
||||
gCritMultiplier = 1;
|
||||
gCurrentMove = AI_THINKING_STRUCT->moveConsidered;
|
||||
AI_CalcDmg(sBattler_AI, gBattlerTarget);
|
||||
TypeCalc(gCurrentMove, sBattler_AI, gBattlerTarget);
|
||||
AI_CalcDmg(gBattlerAttacker, gBattlerTarget);
|
||||
TypeCalc(gCurrentMove, gBattlerAttacker, gBattlerTarget);
|
||||
|
||||
gBattleMoveDamage = gBattleMoveDamage * AI_THINKING_STRUCT->simulatedRNG[AI_THINKING_STRUCT->movesetIndex] / 100;
|
||||
|
||||
@@ -1524,7 +1521,7 @@ static void BattleAICmd_if_has_move(void)
|
||||
case 3:
|
||||
for (i = 0; i < MAX_MON_MOVES; i++)
|
||||
{
|
||||
if (gBattleMons[sBattler_AI].moves[i] == *temp_ptr)
|
||||
if (gBattleMons[gBattlerAttacker].moves[i] == *temp_ptr)
|
||||
break;
|
||||
}
|
||||
if (i == MAX_MON_MOVES)
|
||||
@@ -1558,7 +1555,7 @@ static void BattleAICmd_if_dont_have_move(void)
|
||||
case 3:
|
||||
for (i = 0; i < MAX_MON_MOVES; i++)
|
||||
{
|
||||
if (gBattleMons[sBattler_AI].moves[i] == *temp_ptr)
|
||||
if (gBattleMons[gBattlerAttacker].moves[i] == *temp_ptr)
|
||||
break;
|
||||
}
|
||||
if (i != MAX_MON_MOVES)
|
||||
@@ -1591,7 +1588,7 @@ static void BattleAICmd_if_move_effect(void)
|
||||
case 3:
|
||||
for (i = 0; i < MAX_MON_MOVES; i++)
|
||||
{
|
||||
if (gBattleMons[sBattler_AI].moves[i] != 0 && gBattleMoves[gBattleMons[sBattler_AI].moves[i]].effect == gAIScriptPtr[2])
|
||||
if (gBattleMons[gBattlerAttacker].moves[i] != 0 && gBattleMoves[gBattleMons[gBattlerAttacker].moves[i]].effect == gAIScriptPtr[2])
|
||||
break;
|
||||
}
|
||||
if (i != MAX_MON_MOVES)
|
||||
@@ -1603,7 +1600,7 @@ static void BattleAICmd_if_move_effect(void)
|
||||
case 2:
|
||||
for (i = 0; i < 8; i++)
|
||||
{
|
||||
if (gBattleMons[sBattler_AI].moves[i] != 0 && gBattleMoves[BATTLE_HISTORY->usedMoves[gBattlerTarget >> 1][i]].effect == gAIScriptPtr[2])
|
||||
if (gBattleMons[gBattlerAttacker].moves[i] != 0 && gBattleMoves[BATTLE_HISTORY->usedMoves[gBattlerTarget >> 1][i]].effect == gAIScriptPtr[2])
|
||||
break;
|
||||
}
|
||||
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 3);
|
||||
@@ -1620,7 +1617,7 @@ static void BattleAICmd_if_not_move_effect(void)
|
||||
case 3:
|
||||
for (i = 0; i < MAX_MON_MOVES; i++)
|
||||
{
|
||||
if (gBattleMons[sBattler_AI].moves[i] != 0 && gBattleMoves[gBattleMons[sBattler_AI].moves[i]].effect == gAIScriptPtr[2])
|
||||
if (gBattleMons[gBattlerAttacker].moves[i] != 0 && gBattleMoves[gBattleMons[gBattlerAttacker].moves[i]].effect == gAIScriptPtr[2])
|
||||
break;
|
||||
}
|
||||
if (i != MAX_MON_MOVES)
|
||||
@@ -1644,13 +1641,13 @@ static void BattleAICmd_if_last_move_did_damage(void)
|
||||
u8 index;
|
||||
|
||||
if (gAIScriptPtr[1] == USER)
|
||||
index = sBattler_AI;
|
||||
index = gBattlerAttacker;
|
||||
else
|
||||
index = gBattlerTarget;
|
||||
|
||||
if (gAIScriptPtr[2] == 0)
|
||||
{
|
||||
if (gDisableStructs[index].disabledMove == 0)
|
||||
if (gDisableStructs[index].disabledMove == MOVE_NONE)
|
||||
{
|
||||
gAIScriptPtr += 7;
|
||||
return;
|
||||
@@ -1663,7 +1660,7 @@ static void BattleAICmd_if_last_move_did_damage(void)
|
||||
gAIScriptPtr += 7;
|
||||
return;
|
||||
}
|
||||
else if (gDisableStructs[index].encoredMove != 0)
|
||||
else if (gDisableStructs[index].encoredMove != MOVE_NONE)
|
||||
{
|
||||
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 3);
|
||||
return;
|
||||
@@ -1707,22 +1704,22 @@ static void BattleAICmd_frlg_safari(void)
|
||||
{
|
||||
u8 var;
|
||||
|
||||
if(gBattleStruct->safariGoNearCounter)
|
||||
if (gBattleStruct->safariGoNearCounter)
|
||||
{
|
||||
var = gBattleStruct->safariEscapeFactor * 2;
|
||||
if(var > 20)
|
||||
if (var > 20)
|
||||
var = 20;
|
||||
}
|
||||
else if(gBattleStruct->safariPkblThrowCounter != 0) // _080C91DC
|
||||
else if (gBattleStruct->safariPkblThrowCounter != 0) // _080C91DC
|
||||
{
|
||||
var = gBattleStruct->safariEscapeFactor / 4;
|
||||
if(var == 0)
|
||||
if (var == 0)
|
||||
var = 1;
|
||||
}
|
||||
else
|
||||
var = gBattleStruct->safariEscapeFactor;
|
||||
var *= 5;
|
||||
if((u8)(Random() % 100) < var)
|
||||
if ((u8)(Random() % 100) < var)
|
||||
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1);
|
||||
else
|
||||
gAIScriptPtr += 5;
|
||||
@@ -1739,7 +1736,7 @@ static void BattleAICmd_get_hold_effect(void)
|
||||
u16 side;
|
||||
|
||||
if (gAIScriptPtr[1] == USER)
|
||||
index = sBattler_AI;
|
||||
index = gBattlerAttacker;
|
||||
else
|
||||
index = gBattlerTarget;
|
||||
|
||||
@@ -1759,7 +1756,7 @@ static void BattleAICmd_get_gender(void)
|
||||
u8 index;
|
||||
|
||||
if (gAIScriptPtr[1] == USER)
|
||||
index = sBattler_AI;
|
||||
index = gBattlerAttacker;
|
||||
else
|
||||
index = gBattlerTarget;
|
||||
|
||||
@@ -1773,7 +1770,7 @@ static void BattleAICmd_is_first_turn(void)
|
||||
u8 index;
|
||||
|
||||
if (gAIScriptPtr[1] == USER)
|
||||
index = sBattler_AI;
|
||||
index = gBattlerAttacker;
|
||||
else
|
||||
index = gBattlerTarget;
|
||||
|
||||
@@ -1787,7 +1784,7 @@ static void BattleAICmd_get_stockpile_count(void)
|
||||
u8 index;
|
||||
|
||||
if (gAIScriptPtr[1] == USER)
|
||||
index = sBattler_AI;
|
||||
index = gBattlerAttacker;
|
||||
else
|
||||
index = gBattlerTarget;
|
||||
|
||||
@@ -1808,17 +1805,11 @@ static void BattleAICmd_get_used_held_item(void)
|
||||
u8 battlerId;
|
||||
|
||||
if (gAIScriptPtr[1] == AI_USER)
|
||||
battlerId = sBattler_AI;
|
||||
battlerId = gBattlerAttacker;
|
||||
else
|
||||
battlerId = gBattlerTarget;
|
||||
|
||||
// This is likely a leftover from Ruby's code and its ugly ewram access.
|
||||
#ifdef NONMATCHING
|
||||
AI_THINKING_STRUCT->funcResult = gBattleStruct->usedHeldItems[battlerId];
|
||||
#else
|
||||
AI_THINKING_STRUCT->funcResult = *(u8*)((u8*)(gBattleStruct) + offsetof(struct BattleStruct, usedHeldItems) + (battlerId * 2));
|
||||
#endif // NONMATCHING
|
||||
|
||||
AI_THINKING_STRUCT->funcResult = ((u8 *)gBattleStruct->usedHeldItems)[battlerId * 2];
|
||||
gAIScriptPtr += 2;
|
||||
}
|
||||
|
||||
@@ -1848,7 +1839,7 @@ static void BattleAICmd_get_protect_count(void)
|
||||
u8 index;
|
||||
|
||||
if (gAIScriptPtr[1] == USER)
|
||||
index = sBattler_AI;
|
||||
index = gBattlerAttacker;
|
||||
else
|
||||
index = gBattlerTarget;
|
||||
|
||||
@@ -1903,7 +1894,7 @@ static void BattleAICmd_if_level_compare(void)
|
||||
switch (gAIScriptPtr[1])
|
||||
{
|
||||
case 0: // greater than
|
||||
if (gBattleMons[sBattler_AI].level > gBattleMons[gBattlerTarget].level)
|
||||
if (gBattleMons[gBattlerAttacker].level > gBattleMons[gBattlerTarget].level)
|
||||
{
|
||||
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 2);
|
||||
return;
|
||||
@@ -1911,7 +1902,7 @@ static void BattleAICmd_if_level_compare(void)
|
||||
gAIScriptPtr += 6;
|
||||
return;
|
||||
case 1: // less than
|
||||
if (gBattleMons[sBattler_AI].level < gBattleMons[gBattlerTarget].level)
|
||||
if (gBattleMons[gBattlerAttacker].level < gBattleMons[gBattlerTarget].level)
|
||||
{
|
||||
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 2);
|
||||
return;
|
||||
@@ -1919,7 +1910,7 @@ static void BattleAICmd_if_level_compare(void)
|
||||
gAIScriptPtr += 6;
|
||||
return;
|
||||
case 2: // equal
|
||||
if (gBattleMons[sBattler_AI].level == gBattleMons[gBattlerTarget].level)
|
||||
if (gBattleMons[gBattlerAttacker].level == gBattleMons[gBattlerTarget].level)
|
||||
{
|
||||
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 2);
|
||||
return;
|
||||
@@ -1931,7 +1922,7 @@ static void BattleAICmd_if_level_compare(void)
|
||||
|
||||
static void BattleAICmd_if_taunted(void)
|
||||
{
|
||||
if (gDisableStructs[gBattlerTarget].tauntTimer1 != 0)
|
||||
if (gDisableStructs[gBattlerTarget].tauntTimer != 0)
|
||||
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1);
|
||||
else
|
||||
gAIScriptPtr += 5;
|
||||
@@ -1939,24 +1930,24 @@ static void BattleAICmd_if_taunted(void)
|
||||
|
||||
static void BattleAICmd_if_not_taunted(void)
|
||||
{
|
||||
if (gDisableStructs[gBattlerTarget].tauntTimer1 == 0)
|
||||
if (gDisableStructs[gBattlerTarget].tauntTimer == 0)
|
||||
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1);
|
||||
else
|
||||
gAIScriptPtr += 5;
|
||||
}
|
||||
|
||||
void AIStackPushVar(const u8 *var)
|
||||
static void AIStackPushVar(const u8 *var)
|
||||
{
|
||||
gBattleResources->AI_ScriptsStack->ptr[gBattleResources->AI_ScriptsStack->size++] = var;
|
||||
}
|
||||
|
||||
// unused
|
||||
void AIStackPushVar_cursor(void)
|
||||
static void AIStackPushVar_cursor(void)
|
||||
{
|
||||
gBattleResources->AI_ScriptsStack->ptr[gBattleResources->AI_ScriptsStack->size++] = gAIScriptPtr;
|
||||
}
|
||||
|
||||
bool8 AIStackPop(void)
|
||||
static bool8 AIStackPop(void)
|
||||
{
|
||||
if (gBattleResources->AI_ScriptsStack->size != 0)
|
||||
{
|
||||
|
||||
@@ -0,0 +1,676 @@
|
||||
#include "global.h"
|
||||
#include "battle.h"
|
||||
#include "battle_anim.h"
|
||||
#include "battle_controllers.h"
|
||||
#include "pokemon.h"
|
||||
#include "random.h"
|
||||
#include "util.h"
|
||||
#include "constants/abilities.h"
|
||||
#include "constants/item_effects.h"
|
||||
#include "constants/items.h"
|
||||
#include "constants/moves.h"
|
||||
#include "constants/species.h"
|
||||
#include "constants/pokemon.h"
|
||||
|
||||
static bool8 HasSuperEffectiveMoveAgainstOpponents(bool8 noRng);
|
||||
static bool8 FindMonWithFlagsAndSuperEffective(u8 flags, u8 moduloPercent);
|
||||
static bool8 ShouldUseItem(void);
|
||||
|
||||
static bool8 ShouldSwitchIfPerishSong(void)
|
||||
{
|
||||
if (gStatuses3[gActiveBattler] & STATUS3_PERISH_SONG
|
||||
&& gDisableStructs[gActiveBattler].perishSongTimer == 0)
|
||||
{
|
||||
*(gBattleStruct->AI_monToSwitchIntoId + (GetBattlerPosition(gActiveBattler) >> 1)) = PARTY_SIZE;
|
||||
BtlController_EmitTwoReturnValues(1, B_ACTION_SWITCH, 0);
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
static bool8 ShouldSwitchIfWonderGuard(void)
|
||||
{
|
||||
u8 opposingBattler;
|
||||
u8 moveFlags;
|
||||
s32 i, j;
|
||||
u16 move;
|
||||
|
||||
if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE)
|
||||
return FALSE;
|
||||
if (gBattleMons[GetBattlerAtPosition(B_POSITION_PLAYER_LEFT)].ability == ABILITY_WONDER_GUARD)
|
||||
{
|
||||
// Check if Pokemon has a super effective move.
|
||||
for (opposingBattler = GetBattlerAtPosition(B_POSITION_PLAYER_LEFT), i = 0; i < MAX_MON_MOVES; ++i)
|
||||
{
|
||||
move = gBattleMons[gActiveBattler].moves[i];
|
||||
if (move == MOVE_NONE)
|
||||
continue;
|
||||
moveFlags = AI_TypeCalc(move, gBattleMons[opposingBattler].species, gBattleMons[opposingBattler].ability);
|
||||
if (moveFlags & MOVE_RESULT_SUPER_EFFECTIVE)
|
||||
return FALSE;
|
||||
}
|
||||
// Find a Pokemon in the party that has a super effective move.
|
||||
for (i = 0; i < PARTY_SIZE; ++i)
|
||||
{
|
||||
if (GetMonData(&gEnemyParty[i], MON_DATA_HP) == 0
|
||||
|| GetMonData(&gEnemyParty[i], MON_DATA_SPECIES2) == SPECIES_NONE
|
||||
|| GetMonData(&gEnemyParty[i], MON_DATA_SPECIES2) == SPECIES_EGG
|
||||
|| i == gBattlerPartyIndexes[gActiveBattler])
|
||||
continue;
|
||||
GetMonData(&gEnemyParty[i], MON_DATA_SPECIES); // Unused return value.
|
||||
GetMonData(&gEnemyParty[i], MON_DATA_ABILITY_NUM); // Unused return value.
|
||||
for (opposingBattler = GetBattlerAtPosition(B_POSITION_PLAYER_LEFT), j = 0; j < MAX_MON_MOVES; ++j)
|
||||
{
|
||||
move = GetMonData(&gEnemyParty[i], MON_DATA_MOVE1 + j);
|
||||
if (move == MOVE_NONE)
|
||||
continue;
|
||||
moveFlags = AI_TypeCalc(move, gBattleMons[opposingBattler].species, gBattleMons[opposingBattler].ability);
|
||||
if (moveFlags & MOVE_RESULT_SUPER_EFFECTIVE && Random() % 3 < 2)
|
||||
{
|
||||
// We found a mon.
|
||||
*(gBattleStruct->AI_monToSwitchIntoId + (GetBattlerPosition(gActiveBattler) >> 1)) = i;
|
||||
BtlController_EmitTwoReturnValues(1, B_ACTION_SWITCH, 0);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return FALSE; // There is not a single Pokemon in the party that has a super effective move against a mon with Wonder Guard.
|
||||
}
|
||||
|
||||
static bool8 FindMonThatAbsorbsOpponentsMove(void)
|
||||
{
|
||||
u8 battlerIn1, battlerIn2;
|
||||
u8 absorbingTypeAbility;
|
||||
s32 i;
|
||||
|
||||
if ((HasSuperEffectiveMoveAgainstOpponents(TRUE) && Random() % 3)
|
||||
|| (gLastLandedMoves[gActiveBattler] == MOVE_NONE))
|
||||
return FALSE;
|
||||
if (gLastLandedMoves[gActiveBattler] == 0xFFFF
|
||||
|| gBattleMoves[gLastLandedMoves[gActiveBattler]].power == 0)
|
||||
return FALSE;
|
||||
if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE)
|
||||
{
|
||||
battlerIn1 = gActiveBattler;
|
||||
if (gAbsentBattlerFlags & gBitTable[GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(gActiveBattler)))])
|
||||
battlerIn2 = gActiveBattler;
|
||||
else
|
||||
battlerIn2 = GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(gActiveBattler)));
|
||||
}
|
||||
else
|
||||
{
|
||||
battlerIn1 = gActiveBattler;
|
||||
battlerIn2 = gActiveBattler;
|
||||
}
|
||||
if (gBattleMoves[gLastLandedMoves[gActiveBattler]].type == TYPE_FIRE)
|
||||
absorbingTypeAbility = ABILITY_FLASH_FIRE;
|
||||
else if (gBattleMoves[gLastLandedMoves[gActiveBattler]].type == TYPE_WATER)
|
||||
absorbingTypeAbility = ABILITY_WATER_ABSORB;
|
||||
else if (gBattleMoves[gLastLandedMoves[gActiveBattler]].type == TYPE_ELECTRIC)
|
||||
absorbingTypeAbility = ABILITY_VOLT_ABSORB;
|
||||
else
|
||||
return FALSE;
|
||||
if (gBattleMons[gActiveBattler].ability == absorbingTypeAbility)
|
||||
return FALSE;
|
||||
for (i = 0; i < PARTY_SIZE; ++i)
|
||||
{
|
||||
u16 species;
|
||||
u8 monAbility;
|
||||
|
||||
if ((GetMonData(&gEnemyParty[i], MON_DATA_HP) == 0)
|
||||
|| (GetMonData(&gEnemyParty[i], MON_DATA_SPECIES2) == SPECIES_NONE)
|
||||
|| (GetMonData(&gEnemyParty[i], MON_DATA_SPECIES2) == SPECIES_EGG)
|
||||
|| (i == gBattlerPartyIndexes[battlerIn1])
|
||||
|| (i == gBattlerPartyIndexes[battlerIn2])
|
||||
|| (i == *(gBattleStruct->monToSwitchIntoId + battlerIn1))
|
||||
|| (i == *(gBattleStruct->monToSwitchIntoId + battlerIn2)))
|
||||
continue;
|
||||
species = GetMonData(&gEnemyParty[i], MON_DATA_SPECIES);
|
||||
if (GetMonData(&gEnemyParty[i], MON_DATA_ABILITY_NUM) != ABILITY_NONE)
|
||||
monAbility = gBaseStats[species].abilities[1];
|
||||
else
|
||||
monAbility = gBaseStats[species].abilities[0];
|
||||
if (absorbingTypeAbility == monAbility && Random() & 1)
|
||||
{
|
||||
// we found a mon
|
||||
*(gBattleStruct->AI_monToSwitchIntoId + (GetBattlerPosition(gActiveBattler) >> 1)) = i;
|
||||
BtlController_EmitTwoReturnValues(1, B_ACTION_SWITCH, 0);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static bool8 ShouldSwitchIfNaturalCure(void)
|
||||
{
|
||||
if (!(gBattleMons[gActiveBattler].status1 & STATUS1_SLEEP)
|
||||
|| (gBattleMons[gActiveBattler].ability != ABILITY_NATURAL_CURE)
|
||||
|| (gBattleMons[gActiveBattler].hp < gBattleMons[gActiveBattler].maxHP / 2))
|
||||
return FALSE;
|
||||
if ((gLastLandedMoves[gActiveBattler] == MOVE_NONE || gLastLandedMoves[gActiveBattler] == 0xFFFF) && Random() & 1)
|
||||
{
|
||||
*(gBattleStruct->AI_monToSwitchIntoId + (GetBattlerPosition(gActiveBattler) >> 1)) = PARTY_SIZE;
|
||||
BtlController_EmitTwoReturnValues(1, B_ACTION_SWITCH, 0);
|
||||
return TRUE;
|
||||
}
|
||||
else if (gBattleMoves[gLastLandedMoves[gActiveBattler]].power == 0 && Random() & 1)
|
||||
{
|
||||
*(gBattleStruct->AI_monToSwitchIntoId + (GetBattlerPosition(gActiveBattler) >> 1)) = PARTY_SIZE;
|
||||
BtlController_EmitTwoReturnValues(1, B_ACTION_SWITCH, 0);
|
||||
return TRUE;
|
||||
}
|
||||
if (FindMonWithFlagsAndSuperEffective(MOVE_RESULT_DOESNT_AFFECT_FOE, 1)
|
||||
|| FindMonWithFlagsAndSuperEffective(MOVE_RESULT_NOT_VERY_EFFECTIVE, 1))
|
||||
return TRUE;
|
||||
if (Random() & 1)
|
||||
{
|
||||
*(gBattleStruct->AI_monToSwitchIntoId + (GetBattlerPosition(gActiveBattler) >> 1)) = PARTY_SIZE;
|
||||
BtlController_EmitTwoReturnValues(1, B_ACTION_SWITCH, 0);
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static bool8 HasSuperEffectiveMoveAgainstOpponents(bool8 noRng)
|
||||
{
|
||||
u8 opposingBattler;
|
||||
s32 i;
|
||||
u8 moveFlags;
|
||||
u16 move;
|
||||
|
||||
opposingBattler = GetBattlerAtPosition(B_POSITION_PLAYER_LEFT);
|
||||
if (!(gAbsentBattlerFlags & gBitTable[opposingBattler]))
|
||||
{
|
||||
for (i = 0; i < MAX_MON_MOVES; ++i)
|
||||
{
|
||||
move = gBattleMons[gActiveBattler].moves[i];
|
||||
if (move == MOVE_NONE)
|
||||
continue;
|
||||
|
||||
moveFlags = AI_TypeCalc(move, gBattleMons[opposingBattler].species, gBattleMons[opposingBattler].ability);
|
||||
if (moveFlags & MOVE_RESULT_SUPER_EFFECTIVE)
|
||||
{
|
||||
if (noRng || (Random() % 10))
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!(gBattleTypeFlags & BATTLE_TYPE_DOUBLE))
|
||||
return FALSE;
|
||||
opposingBattler = GetBattlerAtPosition(BATTLE_PARTNER(B_POSITION_PLAYER_LEFT));
|
||||
if (!(gAbsentBattlerFlags & gBitTable[opposingBattler]))
|
||||
{
|
||||
for (i = 0; i < MAX_MON_MOVES; ++i)
|
||||
{
|
||||
move = gBattleMons[gActiveBattler].moves[i];
|
||||
if (move == MOVE_NONE)
|
||||
continue;
|
||||
moveFlags = AI_TypeCalc(move, gBattleMons[opposingBattler].species, gBattleMons[opposingBattler].ability);
|
||||
if (moveFlags & MOVE_RESULT_SUPER_EFFECTIVE)
|
||||
{
|
||||
if (noRng)
|
||||
return TRUE;
|
||||
if (Random() % 10 != 0)
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static bool8 AreStatsRaised(void)
|
||||
{
|
||||
u8 buffedStatsValue = 0;
|
||||
s32 i;
|
||||
|
||||
for (i = 0; i < NUM_BATTLE_STATS; ++i)
|
||||
{
|
||||
if (gBattleMons[gActiveBattler].statStages[i] > 6)
|
||||
buffedStatsValue += gBattleMons[gActiveBattler].statStages[i] - 6;
|
||||
}
|
||||
return (buffedStatsValue > 3);
|
||||
}
|
||||
|
||||
static bool8 FindMonWithFlagsAndSuperEffective(u8 flags, u8 moduloPercent)
|
||||
{
|
||||
u8 battlerIn1, battlerIn2;
|
||||
s32 i, j;
|
||||
u16 move;
|
||||
u8 moveFlags;
|
||||
|
||||
if (gLastLandedMoves[gActiveBattler] == 0)
|
||||
return FALSE;
|
||||
if ((gLastLandedMoves[gActiveBattler] == 0xFFFF)
|
||||
|| (gLastHitBy[gActiveBattler] == 0xFF)
|
||||
|| (gBattleMoves[gLastLandedMoves[gActiveBattler]].power == 0))
|
||||
return FALSE;
|
||||
if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE)
|
||||
{
|
||||
battlerIn1 = gActiveBattler;
|
||||
if (gAbsentBattlerFlags & gBitTable[GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(gActiveBattler)))])
|
||||
battlerIn2 = gActiveBattler;
|
||||
else
|
||||
battlerIn2 = GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(gActiveBattler)));
|
||||
}
|
||||
else
|
||||
{
|
||||
battlerIn1 = gActiveBattler;
|
||||
battlerIn2 = gActiveBattler;
|
||||
}
|
||||
for (i = 0; i < PARTY_SIZE; ++i)
|
||||
{
|
||||
u16 species;
|
||||
u8 monAbility;
|
||||
|
||||
if ((GetMonData(&gEnemyParty[i], MON_DATA_HP) == 0)
|
||||
|| (GetMonData(&gEnemyParty[i], MON_DATA_SPECIES2) == SPECIES_NONE)
|
||||
|| (GetMonData(&gEnemyParty[i], MON_DATA_SPECIES2) == SPECIES_EGG)
|
||||
|| (i == gBattlerPartyIndexes[battlerIn1])
|
||||
|| (i == gBattlerPartyIndexes[battlerIn2])
|
||||
|| (i == *(gBattleStruct->monToSwitchIntoId + battlerIn1))
|
||||
|| (i == *(gBattleStruct->monToSwitchIntoId + battlerIn2)))
|
||||
continue;
|
||||
species = GetMonData(&gEnemyParty[i], MON_DATA_SPECIES);
|
||||
if (GetMonData(&gEnemyParty[i], MON_DATA_ABILITY_NUM) != ABILITY_NONE)
|
||||
monAbility = gBaseStats[species].abilities[1];
|
||||
else
|
||||
monAbility = gBaseStats[species].abilities[0];
|
||||
moveFlags = AI_TypeCalc(gLastLandedMoves[gActiveBattler], species, monAbility);
|
||||
if (moveFlags & flags)
|
||||
{
|
||||
battlerIn1 = gLastHitBy[gActiveBattler];
|
||||
for (j = 0; j < MAX_MON_MOVES; ++j)
|
||||
{
|
||||
move = GetMonData(&gEnemyParty[i], MON_DATA_MOVE1 + j);
|
||||
if (move == MOVE_NONE)
|
||||
continue;
|
||||
moveFlags = AI_TypeCalc(move, gBattleMons[battlerIn1].species, gBattleMons[battlerIn1].ability);
|
||||
if (moveFlags & MOVE_RESULT_SUPER_EFFECTIVE && Random() % moduloPercent == 0)
|
||||
{
|
||||
*(gBattleStruct->AI_monToSwitchIntoId + (GetBattlerPosition(gActiveBattler) >> 1)) = i;
|
||||
BtlController_EmitTwoReturnValues(1, B_ACTION_SWITCH, 0);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static bool8 ShouldSwitch(void)
|
||||
{
|
||||
u8 battlerIn1, battlerIn2;
|
||||
s32 i;
|
||||
s32 availableToSwitch;
|
||||
|
||||
if ((gBattleMons[gActiveBattler].status2 & (STATUS2_WRAPPED | STATUS2_ESCAPE_PREVENTION))
|
||||
|| (gStatuses3[gActiveBattler] & STATUS3_ROOTED)
|
||||
|| AbilityBattleEffects(ABILITYEFFECT_CHECK_OTHER_SIDE, gActiveBattler, ABILITY_SHADOW_TAG, 0, 0)
|
||||
|| AbilityBattleEffects(ABILITYEFFECT_CHECK_OTHER_SIDE, gActiveBattler, ABILITY_ARENA_TRAP, 0, 0))
|
||||
return FALSE; // misses the flying or levitate check
|
||||
if (AbilityBattleEffects(ABILITYEFFECT_FIELD_SPORT, 0, ABILITY_MAGNET_PULL, 0, 0))
|
||||
if ((gBattleMons[gActiveBattler].type1 == TYPE_STEEL) || (gBattleMons[gActiveBattler].type2 == TYPE_STEEL))
|
||||
return FALSE;
|
||||
availableToSwitch = 0;
|
||||
if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE)
|
||||
{
|
||||
battlerIn1 = gActiveBattler;
|
||||
if (gAbsentBattlerFlags & gBitTable[GetBattlerAtPosition(GetBattlerPosition(gActiveBattler) ^ BIT_FLANK)])
|
||||
battlerIn2 = gActiveBattler;
|
||||
else
|
||||
battlerIn2 = GetBattlerAtPosition(GetBattlerPosition(gActiveBattler) ^ BIT_FLANK);
|
||||
}
|
||||
else
|
||||
{
|
||||
battlerIn2 = gActiveBattler;
|
||||
battlerIn1 = gActiveBattler;
|
||||
}
|
||||
for (i = 0; i < PARTY_SIZE; ++i)
|
||||
{
|
||||
if ((GetMonData(&gEnemyParty[i], MON_DATA_HP) == 0)
|
||||
|| (GetMonData(&gEnemyParty[i], MON_DATA_SPECIES2) == SPECIES_NONE)
|
||||
|| (GetMonData(&gEnemyParty[i], MON_DATA_SPECIES2) == SPECIES_EGG)
|
||||
|| (i == gBattlerPartyIndexes[battlerIn1])
|
||||
|| (i == gBattlerPartyIndexes[battlerIn2])
|
||||
|| (i == *(gBattleStruct->monToSwitchIntoId + battlerIn1))
|
||||
|| (i == *(gBattleStruct->monToSwitchIntoId + battlerIn2)))
|
||||
continue;
|
||||
++availableToSwitch;
|
||||
}
|
||||
if (!availableToSwitch)
|
||||
return FALSE;
|
||||
if (ShouldSwitchIfPerishSong()
|
||||
|| ShouldSwitchIfWonderGuard()
|
||||
|| FindMonThatAbsorbsOpponentsMove()
|
||||
|| ShouldSwitchIfNaturalCure())
|
||||
return TRUE;
|
||||
if (HasSuperEffectiveMoveAgainstOpponents(FALSE)
|
||||
|| AreStatsRaised())
|
||||
return FALSE;
|
||||
if (FindMonWithFlagsAndSuperEffective(MOVE_RESULT_DOESNT_AFFECT_FOE, 2)
|
||||
|| FindMonWithFlagsAndSuperEffective(MOVE_RESULT_NOT_VERY_EFFECTIVE, 3))
|
||||
return TRUE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void AI_TrySwitchOrUseItem(void)
|
||||
{
|
||||
u8 battlerIn1, battlerIn2;
|
||||
|
||||
if (gBattleTypeFlags & BATTLE_TYPE_TRAINER)
|
||||
{
|
||||
if (ShouldSwitch())
|
||||
{
|
||||
if (*(gBattleStruct->AI_monToSwitchIntoId + (GetBattlerPosition(gActiveBattler) >> 1)) == 6)
|
||||
{
|
||||
s32 monToSwitchId = GetMostSuitableMonToSwitchInto();
|
||||
if (monToSwitchId == 6)
|
||||
{
|
||||
if (!(gBattleTypeFlags & BATTLE_TYPE_DOUBLE))
|
||||
{
|
||||
battlerIn1 = GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT);
|
||||
battlerIn2 = battlerIn1;
|
||||
}
|
||||
else
|
||||
{
|
||||
battlerIn1 = GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT);
|
||||
battlerIn2 = GetBattlerAtPosition(B_POSITION_OPPONENT_RIGHT);
|
||||
}
|
||||
for (monToSwitchId = 0; monToSwitchId < PARTY_SIZE; ++monToSwitchId)
|
||||
{
|
||||
if ((!GetMonData(&gEnemyParty[monToSwitchId], MON_DATA_HP) == 0)
|
||||
&& (monToSwitchId != gBattlerPartyIndexes[battlerIn1])
|
||||
&& (monToSwitchId != gBattlerPartyIndexes[battlerIn2])
|
||||
&& (monToSwitchId != *(gBattleStruct->monToSwitchIntoId + battlerIn1))
|
||||
&& (monToSwitchId != *(gBattleStruct->monToSwitchIntoId + battlerIn2)))
|
||||
break;
|
||||
}
|
||||
}
|
||||
*(gBattleStruct->AI_monToSwitchIntoId + (GetBattlerPosition(gActiveBattler) >> 1)) = monToSwitchId;
|
||||
}
|
||||
*(gBattleStruct->monToSwitchIntoId + gActiveBattler) = *(gBattleStruct->AI_monToSwitchIntoId + (GetBattlerPosition(gActiveBattler) >> 1));
|
||||
return;
|
||||
}
|
||||
else if (ShouldUseItem())
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
BtlController_EmitTwoReturnValues(1, B_ACTION_USE_MOVE, (gActiveBattler ^ BIT_SIDE) << 8);
|
||||
}
|
||||
|
||||
static void ModulateByTypeEffectiveness(u8 atkType, u8 defType1, u8 defType2, u8 *var)
|
||||
{
|
||||
s32 i = 0;
|
||||
|
||||
while (TYPE_EFFECT_ATK_TYPE(i) != TYPE_ENDTABLE)
|
||||
{
|
||||
if (TYPE_EFFECT_ATK_TYPE(i) == TYPE_FORESIGHT)
|
||||
{
|
||||
i += 3;
|
||||
continue;
|
||||
}
|
||||
else if (TYPE_EFFECT_ATK_TYPE(i) == atkType)
|
||||
{
|
||||
// Check type1.
|
||||
if (TYPE_EFFECT_DEF_TYPE(i) == defType1)
|
||||
*var = (*var * TYPE_EFFECT_MULTIPLIER(i)) / 10;
|
||||
// Check type2.
|
||||
if (TYPE_EFFECT_DEF_TYPE(i) == defType2 && defType1 != defType2)
|
||||
*var = (*var * TYPE_EFFECT_MULTIPLIER(i)) / 10;
|
||||
}
|
||||
i += 3;
|
||||
}
|
||||
}
|
||||
|
||||
u8 GetMostSuitableMonToSwitchInto(void)
|
||||
{
|
||||
u8 opposingBattler;
|
||||
u8 bestDmg; // Note : should be changed to u32 for obvious reasons.
|
||||
u8 bestMonId;
|
||||
u8 battlerIn1, battlerIn2;
|
||||
s32 i, j;
|
||||
u8 invalidMons;
|
||||
u16 move;
|
||||
|
||||
if (*(gBattleStruct->monToSwitchIntoId + gActiveBattler) != PARTY_SIZE)
|
||||
return *(gBattleStruct->monToSwitchIntoId + gActiveBattler);
|
||||
if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE)
|
||||
{
|
||||
battlerIn1 = gActiveBattler;
|
||||
if (gAbsentBattlerFlags & gBitTable[GetBattlerAtPosition(GetBattlerPosition(gActiveBattler) ^ BIT_FLANK)])
|
||||
battlerIn2 = gActiveBattler;
|
||||
else
|
||||
battlerIn2 = GetBattlerAtPosition(GetBattlerPosition(gActiveBattler) ^ BIT_FLANK);
|
||||
// UB: It considers the opponent only player's side even though it can battle alongside player.
|
||||
opposingBattler = Random() & BIT_FLANK;
|
||||
if (gAbsentBattlerFlags & gBitTable[opposingBattler])
|
||||
opposingBattler ^= BIT_FLANK;
|
||||
}
|
||||
else
|
||||
{
|
||||
opposingBattler = GetBattlerAtPosition(B_POSITION_PLAYER_LEFT);
|
||||
battlerIn1 = gActiveBattler;
|
||||
battlerIn2 = gActiveBattler;
|
||||
}
|
||||
invalidMons = 0;
|
||||
while (invalidMons != 0x3F) // All mons are invalid.
|
||||
{
|
||||
bestDmg = 0;
|
||||
bestMonId = 6;
|
||||
// Find the mon whose type is the most suitable offensively.
|
||||
for (i = 0; i < PARTY_SIZE; ++i)
|
||||
{
|
||||
u16 species = GetMonData(&gEnemyParty[i], MON_DATA_SPECIES);
|
||||
if (species != SPECIES_NONE
|
||||
&& GetMonData(&gEnemyParty[i], MON_DATA_HP) != 0
|
||||
&& !(gBitTable[i] & invalidMons)
|
||||
&& gBattlerPartyIndexes[battlerIn1] != i
|
||||
&& gBattlerPartyIndexes[battlerIn2] != i
|
||||
&& i != *(gBattleStruct->monToSwitchIntoId + battlerIn1)
|
||||
&& i != *(gBattleStruct->monToSwitchIntoId + battlerIn2))
|
||||
{
|
||||
u8 type1 = gBaseStats[species].type1;
|
||||
u8 type2 = gBaseStats[species].type2;
|
||||
u8 typeDmg = 10;
|
||||
ModulateByTypeEffectiveness(gBattleMons[opposingBattler].type1, type1, type2, &typeDmg);
|
||||
ModulateByTypeEffectiveness(gBattleMons[opposingBattler].type2, type1, type2, &typeDmg);
|
||||
if (bestDmg < typeDmg)
|
||||
{
|
||||
bestDmg = typeDmg;
|
||||
bestMonId = i;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
invalidMons |= gBitTable[i];
|
||||
}
|
||||
}
|
||||
// Ok, we know the mon has the right typing but does it have at least one super effective move?
|
||||
if (bestMonId != PARTY_SIZE)
|
||||
{
|
||||
for (i = 0; i < MAX_MON_MOVES; ++i)
|
||||
{
|
||||
move = GetMonData(&gEnemyParty[bestMonId], MON_DATA_MOVE1 + i);
|
||||
if (move != MOVE_NONE && TypeCalc(move, gActiveBattler, opposingBattler) & MOVE_RESULT_SUPER_EFFECTIVE)
|
||||
break;
|
||||
}
|
||||
if (i != MAX_MON_MOVES)
|
||||
return bestMonId; // Has both the typing and at least one super effective move.
|
||||
|
||||
invalidMons |= gBitTable[bestMonId]; // Sorry buddy, we want something better.
|
||||
}
|
||||
else
|
||||
{
|
||||
invalidMons = 0x3F; // No viable mon to switch.
|
||||
}
|
||||
}
|
||||
gDynamicBasePower = 0;
|
||||
gBattleStruct->dynamicMoveType = 0;
|
||||
gBattleScripting.dmgMultiplier = 1;
|
||||
gMoveResultFlags = 0;
|
||||
gCritMultiplier = 1;
|
||||
bestDmg = 0;
|
||||
bestMonId = 6;
|
||||
// If we couldn't find the best mon in terms of typing, find the one that deals most damage.
|
||||
for (i = 0; i < PARTY_SIZE; ++i)
|
||||
{
|
||||
if (((u16)(GetMonData(&gEnemyParty[i], MON_DATA_SPECIES)) == SPECIES_NONE)
|
||||
|| (GetMonData(&gEnemyParty[i], MON_DATA_HP) == 0)
|
||||
|| (gBattlerPartyIndexes[battlerIn1] == i)
|
||||
|| (gBattlerPartyIndexes[battlerIn2] == i)
|
||||
|| (i == *(gBattleStruct->monToSwitchIntoId + battlerIn1))
|
||||
|| (i == *(gBattleStruct->monToSwitchIntoId + battlerIn2)))
|
||||
continue;
|
||||
for (j = 0; j < MAX_MON_MOVES; ++j)
|
||||
{
|
||||
move = GetMonData(&gEnemyParty[i], MON_DATA_MOVE1 + j);
|
||||
gBattleMoveDamage = 0;
|
||||
if (move != MOVE_NONE && gBattleMoves[move].power != 1)
|
||||
{
|
||||
AI_CalcDmg(gActiveBattler, opposingBattler);
|
||||
TypeCalc(move, gActiveBattler, opposingBattler);
|
||||
}
|
||||
if (bestDmg < gBattleMoveDamage)
|
||||
{
|
||||
bestDmg = gBattleMoveDamage;
|
||||
bestMonId = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
return bestMonId;
|
||||
}
|
||||
|
||||
static u8 GetAI_ItemType(u8 itemId, const u8 *itemEffect) // NOTE: should take u16 as item Id argument
|
||||
{
|
||||
if (itemId == ITEM_FULL_RESTORE)
|
||||
return AI_ITEM_FULL_RESTORE;
|
||||
else if (itemEffect[4] & ITEM4_HEAL_HP)
|
||||
return AI_ITEM_HEAL_HP;
|
||||
else if (itemEffect[3] & ITEM3_STATUS_ALL)
|
||||
return AI_ITEM_CURE_CONDITION;
|
||||
else if (itemEffect[0] & (ITEM0_HIGH_CRIT | ITEM0_X_ATTACK) || itemEffect[1] != 0 || itemEffect[2] != 0)
|
||||
return AI_ITEM_X_STAT;
|
||||
else if (itemEffect[3] & ITEM3_MIST)
|
||||
return AI_ITEM_GUARD_SPECS;
|
||||
else
|
||||
return AI_ITEM_NOT_RECOGNIZABLE;
|
||||
}
|
||||
|
||||
static bool8 ShouldUseItem(void)
|
||||
{
|
||||
s32 i;
|
||||
u8 validMons = 0;
|
||||
bool8 shouldUse = FALSE;
|
||||
|
||||
for (i = 0; i < PARTY_SIZE; ++i)
|
||||
if (GetMonData(&gEnemyParty[i], MON_DATA_HP) != 0
|
||||
&& GetMonData(&gEnemyParty[i], MON_DATA_SPECIES2) != SPECIES_NONE
|
||||
&& GetMonData(&gEnemyParty[i], MON_DATA_SPECIES2) != SPECIES_EGG)
|
||||
++validMons;
|
||||
for (i = 0; i < MAX_MON_MOVES; ++i)
|
||||
{
|
||||
u16 item;
|
||||
const u8 *itemEffects;
|
||||
u8 paramOffset;
|
||||
u8 battlerSide;
|
||||
|
||||
if (i && validMons > (gBattleResources->battleHistory->itemsNo - i) + 1)
|
||||
continue;
|
||||
item = gBattleResources->battleHistory->trainerItems[i];
|
||||
if (item == ITEM_NONE || gItemEffectTable[item - ITEM_POTION] == NULL)
|
||||
continue;
|
||||
if (item == ITEM_ENIGMA_BERRY)
|
||||
itemEffects = gSaveBlock1Ptr->enigmaBerry.itemEffect;
|
||||
else
|
||||
itemEffects = gItemEffectTable[item - ITEM_POTION];
|
||||
*(gBattleStruct->AI_itemType + gActiveBattler / 2) = GetAI_ItemType(item, itemEffects);
|
||||
switch (*(gBattleStruct->AI_itemType + gActiveBattler / 2))
|
||||
{
|
||||
case AI_ITEM_FULL_RESTORE:
|
||||
if (gBattleMons[gActiveBattler].hp >= gBattleMons[gActiveBattler].maxHP / 4)
|
||||
break;
|
||||
if (gBattleMons[gActiveBattler].hp == 0)
|
||||
break;
|
||||
shouldUse = TRUE;
|
||||
break;
|
||||
case AI_ITEM_HEAL_HP:
|
||||
paramOffset = GetItemEffectParamOffset(item, 4, 4);
|
||||
if (paramOffset == 0 || gBattleMons[gActiveBattler].hp == 0)
|
||||
break;
|
||||
if (gBattleMons[gActiveBattler].hp < gBattleMons[gActiveBattler].maxHP / 4 || gBattleMons[gActiveBattler].maxHP - gBattleMons[gActiveBattler].hp > itemEffects[paramOffset])
|
||||
shouldUse = TRUE;
|
||||
break;
|
||||
case AI_ITEM_CURE_CONDITION:
|
||||
*(gBattleStruct->AI_itemFlags + gActiveBattler / 2) = 0;
|
||||
if (itemEffects[3] & ITEM3_SLEEP && gBattleMons[gActiveBattler].status1 & STATUS1_SLEEP)
|
||||
{
|
||||
*(gBattleStruct->AI_itemFlags + gActiveBattler / 2) |= 0x20;
|
||||
shouldUse = TRUE;
|
||||
}
|
||||
if (itemEffects[3] & ITEM3_POISON && (gBattleMons[gActiveBattler].status1 & STATUS1_POISON || gBattleMons[gActiveBattler].status1 & STATUS1_TOXIC_POISON))
|
||||
{
|
||||
*(gBattleStruct->AI_itemFlags + gActiveBattler / 2) |= 0x10;
|
||||
shouldUse = TRUE;
|
||||
}
|
||||
if (itemEffects[3] & ITEM3_BURN && gBattleMons[gActiveBattler].status1 & STATUS1_BURN)
|
||||
{
|
||||
*(gBattleStruct->AI_itemFlags + gActiveBattler / 2) |= 0x8;
|
||||
shouldUse = TRUE;
|
||||
}
|
||||
if (itemEffects[3] & ITEM3_FREEZE && gBattleMons[gActiveBattler].status1 & STATUS1_FREEZE)
|
||||
{
|
||||
*(gBattleStruct->AI_itemFlags + gActiveBattler / 2) |= 0x4;
|
||||
shouldUse = TRUE;
|
||||
}
|
||||
if (itemEffects[3] & ITEM3_PARALYSIS && gBattleMons[gActiveBattler].status1 & STATUS1_PARALYSIS)
|
||||
{
|
||||
*(gBattleStruct->AI_itemFlags + gActiveBattler / 2) |= 0x2;
|
||||
shouldUse = TRUE;
|
||||
}
|
||||
if (itemEffects[3] & ITEM3_CONFUSION && gBattleMons[gActiveBattler].status2 & STATUS2_CONFUSION)
|
||||
{
|
||||
*(gBattleStruct->AI_itemFlags + gActiveBattler / 2) |= 0x1;
|
||||
shouldUse = TRUE;
|
||||
}
|
||||
break;
|
||||
case AI_ITEM_X_STAT:
|
||||
*(gBattleStruct->AI_itemFlags + gActiveBattler / 2) = 0;
|
||||
if (!gDisableStructs[gActiveBattler].isFirstTurn)
|
||||
break;
|
||||
if (itemEffects[0] & ITEM0_X_ATTACK)
|
||||
*(gBattleStruct->AI_itemFlags + gActiveBattler / 2) |= 0x1;
|
||||
if (itemEffects[1] & ITEM1_X_DEFEND)
|
||||
*(gBattleStruct->AI_itemFlags + gActiveBattler / 2) |= 0x2;
|
||||
if (itemEffects[1] & ITEM1_X_SPEED)
|
||||
*(gBattleStruct->AI_itemFlags + gActiveBattler / 2) |= 0x4;
|
||||
if (itemEffects[2] & ITEM2_X_SPATK)
|
||||
*(gBattleStruct->AI_itemFlags + gActiveBattler / 2) |= 0x8;
|
||||
if (itemEffects[2] & ITEM2_X_ACCURACY)
|
||||
*(gBattleStruct->AI_itemFlags + gActiveBattler / 2) |= 0x20;
|
||||
if (itemEffects[0] & ITEM0_HIGH_CRIT)
|
||||
*(gBattleStruct->AI_itemFlags + gActiveBattler / 2) |= 0x80;
|
||||
shouldUse = TRUE;
|
||||
break;
|
||||
case AI_ITEM_GUARD_SPECS:
|
||||
battlerSide = GetBattlerSide(gActiveBattler);
|
||||
if (gDisableStructs[gActiveBattler].isFirstTurn && gSideTimers[battlerSide].mistTimer == 0)
|
||||
shouldUse = TRUE;
|
||||
break;
|
||||
case AI_ITEM_NOT_RECOGNIZABLE:
|
||||
return FALSE;
|
||||
}
|
||||
if (shouldUse)
|
||||
{
|
||||
BtlController_EmitTwoReturnValues(1, B_ACTION_USE_ITEM, 0);
|
||||
*(gBattleStruct->chosenItem + (gActiveBattler / 2) * 2) = item;
|
||||
gBattleResources->battleHistory->trainerItems[i] = 0;
|
||||
return shouldUse;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
+246
-118
@@ -6,43 +6,91 @@
|
||||
|
||||
#define abs(x) ((x) < 0 ? -(x) : (x))
|
||||
|
||||
void sub_8098A6C(u8 taskId);
|
||||
void sub_8098C08(u8 taskId);
|
||||
void sub_8098D54(u8 taskId);
|
||||
void sub_8098EF0(u8 taskId);
|
||||
void sub_8099004(u8 taskId);
|
||||
void sub_80990AC(struct Sprite * sprite);
|
||||
void sub_8099120(struct Sprite * sprite);
|
||||
void sub_8099144(struct Sprite * sprite);
|
||||
void sub_8099190(struct Sprite * sprite);
|
||||
void sub_80991B4(struct Sprite * sprite);
|
||||
void sub_8099270(struct Sprite * sprite);
|
||||
void sub_80992E0(struct Sprite * sprite);
|
||||
void sub_8099394(struct Sprite * sprite);
|
||||
void sub_809946C(struct Sprite * sprite);
|
||||
void sub_8099530(u8 taskId);
|
||||
void sub_8099594(u8 taskId);
|
||||
void sub_80996B8(u8 taskId);
|
||||
void sub_8099788(u8 taskId);
|
||||
void sub_8099908(u8 taskId);
|
||||
void sub_8099B54(u8 taskId);
|
||||
void sub_8099CB8(u8 taskId);
|
||||
static void AnimTask_ShakeMonStep(u8 taskId);
|
||||
static void AnimTask_ShakeMon2Step(u8 taskId);
|
||||
static void AnimTask_ShakeMonInPlaceStep(u8 taskId);
|
||||
static void AnimTask_ShakeAndSinkMonStep(u8 taskId);
|
||||
static void AnimTask_TranslateMonEllipticalStep(u8 taskId);
|
||||
static void DoHorizontalLunge(struct Sprite * sprite);
|
||||
static void ReverseHorizontalLungeDirection(struct Sprite * sprite);
|
||||
static void DoVerticalDip(struct Sprite * sprite);
|
||||
static void ReverseVerticalDipDirection(struct Sprite * sprite);
|
||||
static void SlideMonToOriginalPos(struct Sprite * sprite);
|
||||
static void SlideMonToOriginalPosStep(struct Sprite * sprite);
|
||||
static void SlideMonToOffset(struct Sprite * sprite);
|
||||
static void sub_8099394(struct Sprite * sprite);
|
||||
static void sub_809946C(struct Sprite * sprite);
|
||||
static void AnimTask_WindUpLungePart1(u8 taskId);
|
||||
static void AnimTask_WindUpLungePart2(u8 taskId);
|
||||
static void sub_80996B8(u8 taskId);
|
||||
static void AnimTask_SwayMonStep(u8 taskId);
|
||||
static void AnimTask_ScaleMonAndRestoreStep(u8 taskId);
|
||||
static void sub_8099B54(u8 taskId);
|
||||
static void sub_8099CB8(u8 taskId);
|
||||
|
||||
const struct SpriteTemplate gUnknown_83D4E4C[] = {
|
||||
{
|
||||
0, 0, &gDummyOamData, gDummySpriteAnimTable, NULL, gDummySpriteAffineAnimTable, sub_80990AC
|
||||
}, {
|
||||
0, 0, &gDummyOamData, gDummySpriteAnimTable, NULL, gDummySpriteAffineAnimTable, sub_8099144
|
||||
}, {
|
||||
0, 0, &gDummyOamData, gDummySpriteAnimTable, NULL, gDummySpriteAffineAnimTable, sub_80991B4
|
||||
}, {
|
||||
0, 0, &gDummyOamData, gDummySpriteAnimTable, NULL, gDummySpriteAffineAnimTable, sub_80992E0
|
||||
}, {
|
||||
0, 0, &gDummyOamData, gDummySpriteAnimTable, NULL, gDummySpriteAffineAnimTable, sub_8099394
|
||||
}
|
||||
const struct SpriteTemplate gHorizontalLungeSpriteTemplate =
|
||||
{
|
||||
.tileTag = 0,
|
||||
.paletteTag = 0,
|
||||
.oam = &gDummyOamData,
|
||||
.anims = gDummySpriteAnimTable,
|
||||
.images = NULL,
|
||||
.affineAnims = gDummySpriteAffineAnimTable,
|
||||
.callback = DoHorizontalLunge,
|
||||
};
|
||||
|
||||
void sub_80989F8(u8 taskId)
|
||||
const struct SpriteTemplate gVerticalDipSpriteTemplate =
|
||||
{
|
||||
.tileTag = 0,
|
||||
.paletteTag = 0,
|
||||
.oam = &gDummyOamData,
|
||||
.anims = gDummySpriteAnimTable,
|
||||
.images = NULL,
|
||||
.affineAnims = gDummySpriteAffineAnimTable,
|
||||
.callback = DoVerticalDip,
|
||||
};
|
||||
|
||||
const struct SpriteTemplate gSlideMonToOriginalPosSpriteTemplate =
|
||||
{
|
||||
.tileTag = 0,
|
||||
.paletteTag = 0,
|
||||
.oam = &gDummyOamData,
|
||||
.anims = gDummySpriteAnimTable,
|
||||
.images = NULL,
|
||||
.affineAnims = gDummySpriteAffineAnimTable,
|
||||
.callback = SlideMonToOriginalPos,
|
||||
};
|
||||
|
||||
const struct SpriteTemplate gSlideMonToOffsetSpriteTemplate =
|
||||
{
|
||||
.tileTag = 0,
|
||||
.paletteTag = 0,
|
||||
.oam = &gDummyOamData,
|
||||
.anims = gDummySpriteAnimTable,
|
||||
.images = NULL,
|
||||
.affineAnims = gDummySpriteAffineAnimTable,
|
||||
.callback = SlideMonToOffset,
|
||||
};
|
||||
|
||||
const struct SpriteTemplate gUnknown_83D4EB4 =
|
||||
{
|
||||
.tileTag = 0,
|
||||
.paletteTag = 0,
|
||||
.oam = &gDummyOamData,
|
||||
.anims = gDummySpriteAnimTable,
|
||||
.images = NULL,
|
||||
.affineAnims = gDummySpriteAffineAnimTable,
|
||||
.callback = sub_8099394,
|
||||
};
|
||||
|
||||
// Task to facilitate simple shaking of a pokemon's picture in battle.
|
||||
// The shaking alternates between the original position and the target position.
|
||||
// arg 0: anim battler
|
||||
// arg 1: x pixel offset
|
||||
// arg 2: y pixel offset
|
||||
// arg 3: num times to shake
|
||||
// arg 4: frame delay
|
||||
void AnimTask_ShakeMon(u8 taskId)
|
||||
{
|
||||
u8 spriteId = GetAnimBankSpriteId(gBattleAnimArgs[0]);
|
||||
|
||||
@@ -58,12 +106,12 @@ void sub_80989F8(u8 taskId)
|
||||
gTasks[taskId].data[3] = gBattleAnimArgs[4];
|
||||
gTasks[taskId].data[4] = gBattleAnimArgs[1];
|
||||
gTasks[taskId].data[5] = gBattleAnimArgs[2];
|
||||
gTasks[taskId].func = sub_8098A6C;
|
||||
gTasks[taskId].func = AnimTask_ShakeMonStep;
|
||||
gTasks[taskId].func(taskId);
|
||||
}
|
||||
}
|
||||
|
||||
void sub_8098A6C(u8 taskId)
|
||||
static void AnimTask_ShakeMonStep(u8 taskId)
|
||||
{
|
||||
if (gTasks[taskId].data[3] == 0)
|
||||
{
|
||||
@@ -87,7 +135,14 @@ void sub_8098A6C(u8 taskId)
|
||||
gTasks[taskId].data[3]--;
|
||||
}
|
||||
|
||||
void sub_8098B1C(u8 taskId)
|
||||
// Task to facilitate simple shaking of a pokemon's picture in battle.
|
||||
// The shaking alternates between the positive and negative versions of the specified pixel offsets.
|
||||
// arg 0: anim battler
|
||||
// arg 1: x pixel offset
|
||||
// arg 2: y pixel offset
|
||||
// arg 3: num times to shake
|
||||
// arg 4: frame delay
|
||||
void AnimTask_ShakeMon2(u8 taskId)
|
||||
{
|
||||
bool8 abort = FALSE;
|
||||
u8 spriteId;
|
||||
@@ -116,7 +171,7 @@ void sub_8098B1C(u8 taskId)
|
||||
battlerId = GetBattlerAtPosition(B_POSITION_OPPONENT_RIGHT);
|
||||
break;
|
||||
}
|
||||
if (!sub_8072DF0(battlerId))
|
||||
if (!IsBattlerSpriteVisible(battlerId))
|
||||
abort = TRUE;
|
||||
spriteId = gBattlerSpriteIds[battlerId];
|
||||
}
|
||||
@@ -134,12 +189,12 @@ void sub_8098B1C(u8 taskId)
|
||||
gTasks[taskId].data[3] = gBattleAnimArgs[4];
|
||||
gTasks[taskId].data[4] = gBattleAnimArgs[1];
|
||||
gTasks[taskId].data[5] = gBattleAnimArgs[2];
|
||||
gTasks[taskId].func = sub_8098C08;
|
||||
gTasks[taskId].func = AnimTask_ShakeMon2Step;
|
||||
gTasks[taskId].func(taskId);
|
||||
}
|
||||
}
|
||||
|
||||
void sub_8098C08(u8 taskId)
|
||||
static void AnimTask_ShakeMon2Step(u8 taskId)
|
||||
{
|
||||
if (gTasks[taskId].data[3] == 0)
|
||||
{
|
||||
@@ -163,7 +218,15 @@ void sub_8098C08(u8 taskId)
|
||||
gTasks[taskId].data[3]--;
|
||||
}
|
||||
|
||||
void sub_8098CD0(u8 taskId)
|
||||
// Task to facilitate simple shaking of a pokemon's picture in battle.
|
||||
// The shaking alternates between the positive and negative versions of the specified pixel offsets
|
||||
// with respect to the current location of the mon's picture.
|
||||
// arg 0: battler
|
||||
// arg 1: x offset
|
||||
// arg 2: y offset
|
||||
// arg 3: num shakes
|
||||
// arg 4: delay
|
||||
void AnimTask_ShakeMonInPlace(u8 taskId)
|
||||
{
|
||||
u8 spriteId = GetAnimBankSpriteId(gBattleAnimArgs[0]);
|
||||
|
||||
@@ -180,12 +243,12 @@ void sub_8098CD0(u8 taskId)
|
||||
gTasks[taskId].data[4] = gBattleAnimArgs[4];
|
||||
gTasks[taskId].data[5] = gBattleAnimArgs[1] * 2;
|
||||
gTasks[taskId].data[6] = gBattleAnimArgs[2] * 2;
|
||||
gTasks[taskId].func = sub_8098D54;
|
||||
gTasks[taskId].func = AnimTask_ShakeMonInPlaceStep;
|
||||
gTasks[taskId].func(taskId);
|
||||
}
|
||||
}
|
||||
|
||||
void sub_8098D54(u8 taskId)
|
||||
static void AnimTask_ShakeMonInPlaceStep(u8 taskId)
|
||||
{
|
||||
if (gTasks[taskId].data[3] == 0)
|
||||
{
|
||||
@@ -219,7 +282,13 @@ void sub_8098D54(u8 taskId)
|
||||
gTasks[taskId].data[3]--;
|
||||
}
|
||||
|
||||
void sub_8098E90(u8 taskId)
|
||||
// Shakes a mon bg horizontally and moves it downward linearly.
|
||||
// arg 0: battler
|
||||
// arg 1: x offset
|
||||
// arg 2: frame delay between each movement
|
||||
// arg 3: downward speed (subpixel)
|
||||
// arg 4: duration
|
||||
void AnimTask_ShakeAndSinkMon(u8 taskId)
|
||||
{
|
||||
u8 spriteId = GetAnimBankSpriteId(gBattleAnimArgs[0]);
|
||||
|
||||
@@ -229,11 +298,11 @@ void sub_8098E90(u8 taskId)
|
||||
gTasks[taskId].data[2] = gBattleAnimArgs[2];
|
||||
gTasks[taskId].data[3] = gBattleAnimArgs[3];
|
||||
gTasks[taskId].data[4] = gBattleAnimArgs[4];
|
||||
gTasks[taskId].func = sub_8098EF0;
|
||||
gTasks[taskId].func = AnimTask_ShakeAndSinkMonStep;
|
||||
gTasks[taskId].func(taskId);
|
||||
}
|
||||
|
||||
void sub_8098EF0(u8 taskId)
|
||||
static void AnimTask_ShakeAndSinkMonStep(u8 taskId)
|
||||
{
|
||||
u8 spriteId = gTasks[taskId].data[0];
|
||||
s16 data1 = gTasks[taskId].data[1];
|
||||
@@ -251,25 +320,32 @@ void sub_8098EF0(u8 taskId)
|
||||
DestroyAnimVisualTask(taskId);
|
||||
}
|
||||
|
||||
void sub_8098F84(u8 taskId)
|
||||
// Moves a mon bg picture along an elliptical path that begins
|
||||
// and ends at the mon's origin location.
|
||||
// arg 0: battler
|
||||
// arg 1: ellipse width
|
||||
// arg 2: ellipse height
|
||||
// arg 3: num loops
|
||||
// arg 4: speed (valid values are 0-5)
|
||||
void AnimTask_TranslateMonElliptical(u8 taskId)
|
||||
{
|
||||
u8 r6 = 1;
|
||||
u8 wavePeriod = 1;
|
||||
u8 i;
|
||||
u8 spriteId = GetAnimBankSpriteId(gBattleAnimArgs[0]);
|
||||
if (gBattleAnimArgs[4] > 5)
|
||||
gBattleAnimArgs[4] = 5;
|
||||
for (i = 0; i < gBattleAnimArgs[4]; i++)
|
||||
r6 *= 2;
|
||||
wavePeriod *= 2;
|
||||
gTasks[taskId].data[0] = spriteId;
|
||||
gTasks[taskId].data[1] = gBattleAnimArgs[1];
|
||||
gTasks[taskId].data[2] = gBattleAnimArgs[2];
|
||||
gTasks[taskId].data[3] = gBattleAnimArgs[3];
|
||||
gTasks[taskId].data[4] = r6;
|
||||
gTasks[taskId].func = sub_8099004;
|
||||
gTasks[taskId].data[4] = wavePeriod;
|
||||
gTasks[taskId].func = AnimTask_TranslateMonEllipticalStep;
|
||||
gTasks[taskId].func(taskId);
|
||||
}
|
||||
|
||||
void sub_8099004(u8 taskId)
|
||||
static void AnimTask_TranslateMonEllipticalStep(u8 taskId)
|
||||
{
|
||||
u8 spriteId = gTasks[taskId].data[0];
|
||||
gSprites[spriteId].pos2.x = Sin(gTasks[taskId].data[5], gTasks[taskId].data[1]);
|
||||
@@ -287,14 +363,26 @@ void sub_8099004(u8 taskId)
|
||||
}
|
||||
}
|
||||
|
||||
void sub_809907C(u8 taskId)
|
||||
// Moves a mon bg picture along an elliptical path that begins
|
||||
// and ends at the mon's origin location. Reverses the direction
|
||||
// of the path if it's not on the player's side of the battle.
|
||||
// arg 0: battler
|
||||
// arg 1: ellipse width
|
||||
// arg 2: ellipse height
|
||||
// arg 3: num loops
|
||||
// arg 4: speed (valid values are 0-5)
|
||||
void AnimTask_TranslateMonEllipticalRespectSide(u8 taskId)
|
||||
{
|
||||
if (GetBattlerSide(gBattleAnimAttacker) != B_SIDE_PLAYER)
|
||||
gBattleAnimArgs[1] = -gBattleAnimArgs[1];
|
||||
sub_8098F84(taskId);
|
||||
AnimTask_TranslateMonElliptical(taskId);
|
||||
}
|
||||
|
||||
void sub_80990AC(struct Sprite * sprite)
|
||||
// Performs a simple horizontal lunge, where the mon moves
|
||||
// horizontally, and then moves back in the opposite direction.
|
||||
// arg 0: duration of single lunge direction
|
||||
// arg 1: x pixel delta that is applied each frame
|
||||
static void DoHorizontalLunge(struct Sprite * sprite)
|
||||
{
|
||||
sprite->invisible = TRUE;
|
||||
if (GetBattlerSide(gBattleAnimAttacker) != B_SIDE_PLAYER)
|
||||
@@ -305,19 +393,24 @@ void sub_80990AC(struct Sprite * sprite)
|
||||
sprite->data[2] = 0;
|
||||
sprite->data[3] = gBattlerSpriteIds[gBattleAnimAttacker];
|
||||
sprite->data[4] = gBattleAnimArgs[0];
|
||||
StoreSpriteCallbackInData6(sprite, sub_8099120);
|
||||
sprite->callback = sub_8074DC4;
|
||||
StoreSpriteCallbackInData6(sprite, ReverseHorizontalLungeDirection);
|
||||
sprite->callback = TranslateMonSpriteLinear;
|
||||
}
|
||||
|
||||
void sub_8099120(struct Sprite * sprite)
|
||||
static void ReverseHorizontalLungeDirection(struct Sprite * sprite)
|
||||
{
|
||||
sprite->data[0] = sprite->data[4];
|
||||
sprite->data[1] = -sprite->data[1];
|
||||
sprite->callback = sub_8074DC4;
|
||||
sprite->callback = TranslateMonSpriteLinear;
|
||||
StoreSpriteCallbackInData6(sprite, DestroyAnimSprite);
|
||||
}
|
||||
|
||||
void sub_8099144(struct Sprite * sprite)
|
||||
// Performs a simple vertical dipping motion, where moves vertically, and then
|
||||
// moves back in the opposite direction.
|
||||
// arg 0: duration of single dip direction
|
||||
// arg 1: y pixel delta that is applied each frame
|
||||
// arg 2: battler
|
||||
static void DoVerticalDip(struct Sprite * sprite)
|
||||
{
|
||||
u8 spriteId;
|
||||
sprite->invisible = TRUE;
|
||||
@@ -327,19 +420,24 @@ void sub_8099144(struct Sprite * sprite)
|
||||
sprite->data[2] = gBattleAnimArgs[1];
|
||||
sprite->data[3] = spriteId;
|
||||
sprite->data[4] = gBattleAnimArgs[0];
|
||||
StoreSpriteCallbackInData6(sprite, sub_8099190);
|
||||
sprite->callback = sub_8074DC4;
|
||||
StoreSpriteCallbackInData6(sprite, ReverseVerticalDipDirection);
|
||||
sprite->callback = TranslateMonSpriteLinear;
|
||||
}
|
||||
|
||||
void sub_8099190(struct Sprite * sprite)
|
||||
static void ReverseVerticalDipDirection(struct Sprite * sprite)
|
||||
{
|
||||
sprite->data[0] = sprite->data[4];
|
||||
sprite->data[2] = -sprite->data[2];
|
||||
sprite->callback = sub_8074DC4;
|
||||
sprite->callback = TranslateMonSpriteLinear;
|
||||
StoreSpriteCallbackInData6(sprite, DestroyAnimSprite);
|
||||
}
|
||||
|
||||
void sub_80991B4(struct Sprite * sprite)
|
||||
// Linearly slides a mon's bg picture back to its original sprite position.
|
||||
// The sprite parameter is a dummy sprite used for facilitating the movement with its callback.
|
||||
// arg 0: 1 = target or 0 = attacker
|
||||
// arg 1: direction (0 = horizontal and vertical, 1 = horizontal only, 2 = vertical only)
|
||||
// arg 2: duration
|
||||
static void SlideMonToOriginalPos(struct Sprite * sprite)
|
||||
{
|
||||
u8 spriteId;
|
||||
if (gBattleAnimArgs[0] == 0)
|
||||
@@ -351,7 +449,7 @@ void sub_80991B4(struct Sprite * sprite)
|
||||
sprite->data[2] = gSprites[spriteId].pos1.x;
|
||||
sprite->data[3] = gSprites[spriteId].pos1.y + gSprites[spriteId].pos2.y;
|
||||
sprite->data[4] = gSprites[spriteId].pos1.y;
|
||||
sub_80754B8(sprite);
|
||||
InitSpriteDataForLinearTranslation(sprite);
|
||||
sprite->data[3] = 0;
|
||||
sprite->data[4] = 0;
|
||||
sprite->data[5] = gSprites[spriteId].pos2.x;
|
||||
@@ -363,10 +461,10 @@ void sub_80991B4(struct Sprite * sprite)
|
||||
sprite->data[1] = 0;
|
||||
sprite->data[7] = gBattleAnimArgs[1];
|
||||
sprite->data[7] |= spriteId << 8;
|
||||
sprite->callback = sub_8099270;
|
||||
sprite->callback = SlideMonToOriginalPosStep;
|
||||
}
|
||||
|
||||
void sub_8099270(struct Sprite * sprite)
|
||||
static void SlideMonToOriginalPosStep(struct Sprite * sprite)
|
||||
{
|
||||
u8 data7 = sprite->data[7];
|
||||
struct Sprite *otherSprite = &gSprites[sprite->data[7] >> 8];
|
||||
@@ -388,7 +486,15 @@ void sub_8099270(struct Sprite * sprite)
|
||||
}
|
||||
}
|
||||
|
||||
void sub_80992E0(struct Sprite * sprite)
|
||||
// Linearly translates a mon to a target offset. The horizontal offset
|
||||
// is mirrored for the opponent's pokemon, and the vertical offset
|
||||
// is only mirrored if arg 3 is set to 1.
|
||||
// arg 0: 0 = attacker, 1 = target
|
||||
// arg 1: target x pixel offset
|
||||
// arg 2: target y pixel offset
|
||||
// arg 3: mirror vertical translation for opposite battle side
|
||||
// arg 4: duration
|
||||
static void SlideMonToOffset(struct Sprite * sprite)
|
||||
{
|
||||
u8 battlerId;
|
||||
u8 spriteId;
|
||||
@@ -408,16 +514,16 @@ void sub_80992E0(struct Sprite * sprite)
|
||||
sprite->data[2] = gSprites[spriteId].pos1.x + gBattleAnimArgs[1];
|
||||
sprite->data[3] = gSprites[spriteId].pos1.y;
|
||||
sprite->data[4] = gSprites[spriteId].pos1.y + gBattleAnimArgs[2];
|
||||
sub_80754B8(sprite);
|
||||
InitSpriteDataForLinearTranslation(sprite);
|
||||
sprite->data[3] = 0;
|
||||
sprite->data[4] = 0;
|
||||
sprite->data[5] = spriteId;
|
||||
sprite->invisible = TRUE;
|
||||
StoreSpriteCallbackInData6(sprite, DestroyAnimSprite);
|
||||
sprite->callback = sub_8074E14;
|
||||
sprite->callback = TranslateMonSpriteLinearFixedPoint;
|
||||
}
|
||||
|
||||
void sub_8099394(struct Sprite * sprite)
|
||||
static void sub_8099394(struct Sprite * sprite)
|
||||
{
|
||||
u8 battlerId;
|
||||
u8 spriteId;
|
||||
@@ -438,7 +544,7 @@ void sub_8099394(struct Sprite * sprite)
|
||||
sprite->data[2] = sprite->data[1] + gBattleAnimArgs[1];
|
||||
sprite->data[3] = gSprites[spriteId].pos1.y + gSprites[spriteId].pos2.y;
|
||||
sprite->data[4] = sprite->data[3] + gBattleAnimArgs[2];
|
||||
sub_80754B8(sprite);
|
||||
InitSpriteDataForLinearTranslation(sprite);
|
||||
sprite->data[3] = gSprites[spriteId].pos2.x << 8;
|
||||
sprite->data[4] = gSprites[spriteId].pos2.y << 8;
|
||||
sprite->data[5] = spriteId;
|
||||
@@ -447,19 +553,29 @@ void sub_8099394(struct Sprite * sprite)
|
||||
StoreSpriteCallbackInData6(sprite, DestroyAnimSprite);
|
||||
else
|
||||
StoreSpriteCallbackInData6(sprite, sub_809946C);
|
||||
sprite->callback = sub_8074E14;
|
||||
sprite->callback = TranslateMonSpriteLinearFixedPoint;
|
||||
}
|
||||
|
||||
void sub_809946C(struct Sprite * sprite)
|
||||
static void sub_809946C(struct Sprite * sprite)
|
||||
{
|
||||
gSprites[sprite->data[5]].pos2.x = 0;
|
||||
gSprites[sprite->data[5]].pos2.y = 0;
|
||||
DestroyAnimSprite(sprite);
|
||||
}
|
||||
|
||||
void sub_809949C(u8 taskId)
|
||||
// Task to facilitate a two-part translation animation, in which the sprite
|
||||
// is first translated in an arc to one position. Then, it "lunges" to a target
|
||||
// x offset. Used in TAKE_DOWN, for example.
|
||||
// arg 0: anim bank
|
||||
// arg 1: horizontal speed (subpixel)
|
||||
// arg 2: wave amplitude
|
||||
// arg 3: first duration
|
||||
// arg 4: delay before starting lunge
|
||||
// arg 5: target x offset for lunge
|
||||
// arg 6: lunge duration
|
||||
void AnimTask_WindUpLunge(u8 taskId)
|
||||
{
|
||||
u16 r7 = 0x8000 / gBattleAnimArgs[3];
|
||||
u16 wavePeriod = 0x8000 / gBattleAnimArgs[3];
|
||||
if (GetBattlerSide(gBattleAnimAttacker) != B_SIDE_PLAYER)
|
||||
{
|
||||
gBattleAnimArgs[1] = -gBattleAnimArgs[1];
|
||||
@@ -472,11 +588,11 @@ void sub_809949C(u8 taskId)
|
||||
gTasks[taskId].data[4] = gBattleAnimArgs[4];
|
||||
gTasks[taskId].data[5] = gBattleAnimArgs[5] * 256 / gBattleAnimArgs[6];
|
||||
gTasks[taskId].data[6] = gBattleAnimArgs[6];
|
||||
gTasks[taskId].data[7] = r7;
|
||||
gTasks[taskId].func = sub_8099530;
|
||||
gTasks[taskId].data[7] = wavePeriod;
|
||||
gTasks[taskId].func = AnimTask_WindUpLungePart1;
|
||||
}
|
||||
|
||||
void sub_8099530(u8 taskId)
|
||||
static void AnimTask_WindUpLungePart1(u8 taskId)
|
||||
{
|
||||
u8 spriteId = gTasks[taskId].data[0];
|
||||
gTasks[taskId].data[11] += gTasks[taskId].data[1];
|
||||
@@ -484,10 +600,10 @@ void sub_8099530(u8 taskId)
|
||||
gSprites[spriteId].pos2.y = Sin((u8)(gTasks[taskId].data[10] >> 8), gTasks[taskId].data[2]);
|
||||
gTasks[taskId].data[10] += gTasks[taskId].data[7];
|
||||
if (--gTasks[taskId].data[3] == 0)
|
||||
gTasks[taskId].func = sub_8099594;
|
||||
gTasks[taskId].func = AnimTask_WindUpLungePart2;
|
||||
}
|
||||
|
||||
void sub_8099594(u8 taskId)
|
||||
static void AnimTask_WindUpLungePart2(u8 taskId)
|
||||
{
|
||||
u8 spriteId;
|
||||
|
||||
@@ -514,7 +630,7 @@ void sub_80995FC(u8 taskId)
|
||||
spriteId = GetAnimBankSpriteId(gBattleAnimArgs[0]);
|
||||
break;
|
||||
case 2:
|
||||
if (!sub_8072DF0(gBattleAnimAttacker ^ BIT_FLANK))
|
||||
if (!IsBattlerSpriteVisible(gBattleAnimAttacker ^ BIT_FLANK))
|
||||
{
|
||||
DestroyAnimVisualTask(taskId);
|
||||
return;
|
||||
@@ -522,7 +638,7 @@ void sub_80995FC(u8 taskId)
|
||||
spriteId = gBattlerSpriteIds[gBattleAnimAttacker ^ BIT_FLANK];
|
||||
break;
|
||||
case 3:
|
||||
if (!sub_8072DF0(gBattleAnimTarget ^ BIT_FLANK))
|
||||
if (!IsBattlerSpriteVisible(gBattleAnimTarget ^ BIT_FLANK))
|
||||
{
|
||||
DestroyAnimVisualTask(taskId);
|
||||
return;
|
||||
@@ -541,7 +657,7 @@ void sub_80995FC(u8 taskId)
|
||||
gTasks[taskId].func = sub_80996B8;
|
||||
}
|
||||
|
||||
void sub_80996B8(u8 taskId)
|
||||
static void sub_80996B8(u8 taskId)
|
||||
{
|
||||
u8 spriteId = gTasks[taskId].data[0];
|
||||
gSprites[spriteId].pos2.x += gTasks[taskId].data[1];
|
||||
@@ -549,7 +665,15 @@ void sub_80996B8(u8 taskId)
|
||||
DestroyAnimVisualTask(taskId);
|
||||
}
|
||||
|
||||
void sub_8099704(u8 taskId)
|
||||
// Task that facilitates translating the mon bg picture back and forth
|
||||
// in a swaying motion (uses Sine wave). It can sway either horizontally
|
||||
// or vertically, but not both.
|
||||
// arg 0: direction (0 = horizontal, 1 = vertical)
|
||||
// arg 1: wave amplitude
|
||||
// arg 2: wave period
|
||||
// arg 3: num sways
|
||||
// arg 4: which mon (0 = attacker, 1 = target)
|
||||
void AnimTask_SwayMon(u8 taskId)
|
||||
{
|
||||
u8 spriteId;
|
||||
if (GetBattlerSide(gBattleAnimAttacker) != B_SIDE_PLAYER)
|
||||
@@ -565,32 +689,32 @@ void sub_8099704(u8 taskId)
|
||||
else
|
||||
gTasks[taskId].data[5] = gBattleAnimTarget;
|
||||
gTasks[taskId].data[12] = 1;
|
||||
gTasks[taskId].func = sub_8099788;
|
||||
gTasks[taskId].func = AnimTask_SwayMonStep;
|
||||
}
|
||||
|
||||
void sub_8099788(u8 taskId)
|
||||
static void AnimTask_SwayMonStep(u8 taskId)
|
||||
{
|
||||
u8 spriteId;
|
||||
u32 r8;
|
||||
s16 r5;
|
||||
u16 tmp;
|
||||
u32 waveIndex;
|
||||
s16 sineValue;
|
||||
u16 sineIndex;
|
||||
|
||||
spriteId = gTasks[taskId].data[4];
|
||||
tmp = gTasks[taskId].data[10] + gTasks[taskId].data[2];
|
||||
gTasks[taskId].data[10] = tmp;
|
||||
r8 = tmp >> 8;
|
||||
r5 = Sin(r8, gTasks[taskId].data[1]);
|
||||
sineIndex = gTasks[taskId].data[10] + gTasks[taskId].data[2];
|
||||
gTasks[taskId].data[10] = sineIndex;
|
||||
waveIndex = sineIndex >> 8;
|
||||
sineValue = Sin(waveIndex, gTasks[taskId].data[1]);
|
||||
if (gTasks[taskId].data[0] == 0)
|
||||
{
|
||||
gSprites[spriteId].pos2.x = r5;
|
||||
gSprites[spriteId].pos2.x = sineValue;
|
||||
}
|
||||
else if (GetBattlerSide(gTasks[taskId].data[5]) == B_SIDE_PLAYER)
|
||||
{
|
||||
gSprites[spriteId].pos2.y = abs(r5);
|
||||
gSprites[spriteId].pos2.y = abs(sineValue);
|
||||
}
|
||||
else
|
||||
gSprites[spriteId].pos2.y = -abs(r5);
|
||||
if ((r8 > 0x7F && gTasks[taskId].data[11] == 0 && gTasks[taskId].data[12] == 1) || (r8 < 0x7F && gTasks[taskId].data[11] == 1 && gTasks[taskId].data[12] == 0))
|
||||
gSprites[spriteId].pos2.y = -abs(sineValue);
|
||||
if ((waveIndex > 0x7F && gTasks[taskId].data[11] == 0 && gTasks[taskId].data[12] == 1) || (waveIndex < 0x7F && gTasks[taskId].data[11] == 1 && gTasks[taskId].data[12] == 0))
|
||||
{
|
||||
gTasks[taskId].data[11] ^= 1;
|
||||
gTasks[taskId].data[12] ^= 1;
|
||||
@@ -603,10 +727,16 @@ void sub_8099788(u8 taskId)
|
||||
}
|
||||
}
|
||||
|
||||
void sub_80998B0(u8 taskId)
|
||||
// Scales a mon's sprite, and then scales back to its original dimensions.
|
||||
// arg 0: x scale delta
|
||||
// arg 1: y scale delta
|
||||
// arg 2: duration
|
||||
// arg 3: anim bank
|
||||
// arg 4: sprite object mode
|
||||
void AnimTask_ScaleMonAndRestore(u8 taskId)
|
||||
{
|
||||
u8 spriteId = GetAnimBankSpriteId(gBattleAnimArgs[3]);
|
||||
sub_80758E0(spriteId, gBattleAnimArgs[4]);
|
||||
PrepareBattlerSpriteForRotScale(spriteId, gBattleAnimArgs[4]);
|
||||
gTasks[taskId].data[0] = gBattleAnimArgs[0];
|
||||
gTasks[taskId].data[1] = gBattleAnimArgs[1];
|
||||
gTasks[taskId].data[2] = gBattleAnimArgs[2];
|
||||
@@ -614,16 +744,16 @@ void sub_80998B0(u8 taskId)
|
||||
gTasks[taskId].data[4] = spriteId;
|
||||
gTasks[taskId].data[10] = 0x100;
|
||||
gTasks[taskId].data[11] = 0x100;
|
||||
gTasks[taskId].func = sub_8099908;
|
||||
gTasks[taskId].func = AnimTask_ScaleMonAndRestoreStep;
|
||||
}
|
||||
|
||||
void sub_8099908(u8 taskId)
|
||||
static void AnimTask_ScaleMonAndRestoreStep(u8 taskId)
|
||||
{
|
||||
u8 spriteId;
|
||||
gTasks[taskId].data[10] += gTasks[taskId].data[0];
|
||||
gTasks[taskId].data[11] += gTasks[taskId].data[1];
|
||||
spriteId = gTasks[taskId].data[4];
|
||||
obj_id_set_rotscale(spriteId, gTasks[taskId].data[10], gTasks[taskId].data[11], 0);
|
||||
SetSpriteRotScale(spriteId, gTasks[taskId].data[10], gTasks[taskId].data[11], 0);
|
||||
if (--gTasks[taskId].data[2] == 0)
|
||||
{
|
||||
if (gTasks[taskId].data[3] > 0)
|
||||
@@ -635,7 +765,7 @@ void sub_8099908(u8 taskId)
|
||||
}
|
||||
else
|
||||
{
|
||||
sub_8075980(spriteId);
|
||||
ResetSpriteRotScale(spriteId);
|
||||
DestroyAnimVisualTask(taskId);
|
||||
}
|
||||
}
|
||||
@@ -644,7 +774,7 @@ void sub_8099908(u8 taskId)
|
||||
void sub_8099980(u8 taskId)
|
||||
{
|
||||
u8 spriteId = GetAnimBankSpriteId(gBattleAnimArgs[2]);
|
||||
sub_80758E0(spriteId, 0);
|
||||
PrepareBattlerSpriteForRotScale(spriteId, 0);
|
||||
gTasks[taskId].data[1] = 0;
|
||||
gTasks[taskId].data[2] = gBattleAnimArgs[0];
|
||||
if (gBattleAnimArgs[3] != 1)
|
||||
@@ -654,7 +784,7 @@ void sub_8099980(u8 taskId)
|
||||
gTasks[taskId].data[4] = gBattleAnimArgs[1];
|
||||
gTasks[taskId].data[5] = spriteId;
|
||||
gTasks[taskId].data[6] = gBattleAnimArgs[3];
|
||||
if (sub_8073788())
|
||||
if (IsContest())
|
||||
gTasks[taskId].data[7] = 1;
|
||||
else
|
||||
{
|
||||
@@ -663,7 +793,7 @@ void sub_8099980(u8 taskId)
|
||||
else
|
||||
gTasks[taskId].data[7] = GetBattlerSide(gBattleAnimTarget) == B_SIDE_PLAYER ? 1 : 0;
|
||||
}
|
||||
if (gTasks[taskId].data[7] && !sub_8073788())
|
||||
if (gTasks[taskId].data[7] && !IsContest())
|
||||
{
|
||||
s16 tmp;
|
||||
tmp = gTasks[taskId].data[3];
|
||||
@@ -677,7 +807,7 @@ void sub_8099980(u8 taskId)
|
||||
void sub_8099A78(u8 taskId)
|
||||
{
|
||||
u8 spriteId = GetAnimBankSpriteId(gBattleAnimArgs[2]);
|
||||
sub_80758E0(spriteId, 0);
|
||||
PrepareBattlerSpriteForRotScale(spriteId, 0);
|
||||
gTasks[taskId].data[1] = 0;
|
||||
gTasks[taskId].data[2] = gBattleAnimArgs[0];
|
||||
if (gBattleAnimArgs[2] == 0)
|
||||
@@ -709,11 +839,10 @@ void sub_8099A78(u8 taskId)
|
||||
gTasks[taskId].func = sub_8099B54;
|
||||
}
|
||||
|
||||
void sub_8099B54(u8 taskId)
|
||||
static void sub_8099B54(u8 taskId)
|
||||
{
|
||||
s16 tmp;
|
||||
gTasks[taskId].data[3] += gTasks[taskId].data[4];
|
||||
obj_id_set_rotscale(gTasks[taskId].data[5], 0x100, 0x100, gTasks[taskId].data[3]);
|
||||
SetSpriteRotScale(gTasks[taskId].data[5], 0x100, 0x100, gTasks[taskId].data[3]);
|
||||
if (gTasks[taskId].data[7])
|
||||
sub_80759DC(gTasks[taskId].data[5]);
|
||||
if (++gTasks[taskId].data[1] >= gTasks[taskId].data[2])
|
||||
@@ -721,7 +850,7 @@ void sub_8099B54(u8 taskId)
|
||||
switch (gTasks[taskId].data[6])
|
||||
{
|
||||
case 1:
|
||||
sub_8075980(gTasks[taskId].data[5]);
|
||||
ResetSpriteRotScale(gTasks[taskId].data[5]);
|
||||
// fallthrough
|
||||
case 0:
|
||||
default:
|
||||
@@ -729,8 +858,7 @@ void sub_8099B54(u8 taskId)
|
||||
break;
|
||||
case 2:
|
||||
gTasks[taskId].data[1] = 0;
|
||||
tmp = gTasks[taskId].data[4];
|
||||
gTasks[taskId].data[4] = -tmp;
|
||||
gTasks[taskId].data[4] *= -1;
|
||||
gTasks[taskId].data[6] = 1;
|
||||
break;
|
||||
}
|
||||
@@ -741,7 +869,7 @@ void sub_8099BD4(u8 taskId)
|
||||
{
|
||||
if (gBattleAnimArgs[0] == 0)
|
||||
{
|
||||
gTasks[taskId].data[15] = gUnknown_2037EEC / 12;
|
||||
gTasks[taskId].data[15] = gAnimMovePower / 12;
|
||||
if (gTasks[taskId].data[15] < 1)
|
||||
gTasks[taskId].data[15] = 1;
|
||||
if (gTasks[taskId].data[15] > 16)
|
||||
@@ -749,7 +877,7 @@ void sub_8099BD4(u8 taskId)
|
||||
}
|
||||
else
|
||||
{
|
||||
gTasks[taskId].data[15] = gUnknown_2037EE8 / 12;
|
||||
gTasks[taskId].data[15] = gAnimMoveDmg / 12;
|
||||
if (gTasks[taskId].data[15] < 1)
|
||||
gTasks[taskId].data[15] = 1;
|
||||
if (gTasks[taskId].data[15] > 16)
|
||||
@@ -769,7 +897,7 @@ void sub_8099BD4(u8 taskId)
|
||||
gTasks[taskId].func = sub_8099CB8;
|
||||
}
|
||||
|
||||
void sub_8099CB8(u8 taskId)
|
||||
static void sub_8099CB8(u8 taskId)
|
||||
{
|
||||
struct Task *task = &gTasks[taskId];
|
||||
if (++task->data[0] > task->data[1])
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,677 @@
|
||||
#include "global.h"
|
||||
#include "battle.h"
|
||||
#include "battle_anim.h"
|
||||
#include "battle_controllers.h"
|
||||
#include "battle_interface.h"
|
||||
#include "battle_message.h"
|
||||
#include "bg.h"
|
||||
#include "data.h"
|
||||
#include "item_menu.h"
|
||||
#include "link.h"
|
||||
#include "main.h"
|
||||
#include "m4a.h"
|
||||
#include "palette.h"
|
||||
#include "pokeball.h"
|
||||
#include "pokemon.h"
|
||||
#include "reshow_battle_screen.h"
|
||||
#include "sound.h"
|
||||
#include "task.h"
|
||||
#include "text.h"
|
||||
#include "util.h"
|
||||
#include "window.h"
|
||||
#include "strings.h"
|
||||
#include "constants/songs.h"
|
||||
#include "constants/battle_anim.h"
|
||||
|
||||
static void SafariHandleGetMonData(void);
|
||||
static void SafariHandleGetRawMonData(void);
|
||||
static void SafariHandleSetMonData(void);
|
||||
static void SafariHandleSetRawMonData(void);
|
||||
static void SafariHandleLoadMonSprite(void);
|
||||
static void SafariHandleSwitchInAnim(void);
|
||||
static void SafariHandleReturnMonToBall(void);
|
||||
static void SafariHandleDrawTrainerPic(void);
|
||||
static void SafariHandleTrainerSlide(void);
|
||||
static void SafariHandleTrainerSlideBack(void);
|
||||
static void SafariHandleFaintAnimation(void);
|
||||
static void SafariHandlePaletteFade(void);
|
||||
static void SafariHandleSuccessBallThrowAnim(void);
|
||||
static void SafariHandleBallThrowAnim(void);
|
||||
static void SafariHandlePause(void);
|
||||
static void SafariHandleMoveAnimation(void);
|
||||
static void SafariHandlePrintString(void);
|
||||
static void SafariHandlePrintSelectionString(void);
|
||||
static void SafariHandleChooseAction(void);
|
||||
static void SafariHandleUnknownYesNoBox(void);
|
||||
static void SafariHandleChooseMove(void);
|
||||
static void SafariHandleChooseItem(void);
|
||||
static void SafariHandleChoosePokemon(void);
|
||||
static void SafariHandleCmd23(void);
|
||||
static void SafariHandleHealthBarUpdate(void);
|
||||
static void SafariHandleExpUpdate(void);
|
||||
static void SafariHandleStatusIconUpdate(void);
|
||||
static void SafariHandleStatusAnimation(void);
|
||||
static void SafariHandleStatusXor(void);
|
||||
static void SafariHandleDataTransfer(void);
|
||||
static void SafariHandleDMA3Transfer(void);
|
||||
static void SafariHandlePlayBGM(void);
|
||||
static void SafariHandleCmd32(void);
|
||||
static void SafariHandleTwoReturnValues(void);
|
||||
static void SafariHandleChosenMonReturnValue(void);
|
||||
static void SafariHandleOneReturnValue(void);
|
||||
static void SafariHandleOneReturnValue_Duplicate(void);
|
||||
static void SafariHandleCmd37(void);
|
||||
static void SafariHandleCmd38(void);
|
||||
static void SafariHandleCmd39(void);
|
||||
static void SafariHandleCmd40(void);
|
||||
static void SafariHandleHitAnimation(void);
|
||||
static void SafariHandleCmd42(void);
|
||||
static void SafariHandlePlaySE(void);
|
||||
static void SafariHandlePlayFanfareOrBGM(void);
|
||||
static void SafariHandleFaintingCry(void);
|
||||
static void SafariHandleIntroSlide(void);
|
||||
static void SafariHandleIntroTrainerBallThrow(void);
|
||||
static void SafariHandleDrawPartyStatusSummary(void);
|
||||
static void SafariHandleHidePartyStatusSummary(void);
|
||||
static void SafariHandleEndBounceEffect(void);
|
||||
static void SafariHandleSpriteInvisibility(void);
|
||||
static void SafariHandleBattleAnimation(void);
|
||||
static void SafariHandleLinkStandbyMsg(void);
|
||||
static void SafariHandleResetActionMoveSelection(void);
|
||||
static void SafariHandleCmd55(void);
|
||||
static void SafariCmdEnd(void);
|
||||
|
||||
static void SafariBufferRunCommand(void);
|
||||
static void SafariBufferExecCompleted(void);
|
||||
static void CompleteWhenChosePokeblock(void);
|
||||
|
||||
static void (*const sSafariBufferCommands[CONTROLLER_CMDS_COUNT])(void) =
|
||||
{
|
||||
SafariHandleGetMonData,
|
||||
SafariHandleGetRawMonData,
|
||||
SafariHandleSetMonData,
|
||||
SafariHandleSetRawMonData,
|
||||
SafariHandleLoadMonSprite,
|
||||
SafariHandleSwitchInAnim,
|
||||
SafariHandleReturnMonToBall,
|
||||
SafariHandleDrawTrainerPic,
|
||||
SafariHandleTrainerSlide,
|
||||
SafariHandleTrainerSlideBack,
|
||||
SafariHandleFaintAnimation,
|
||||
SafariHandlePaletteFade,
|
||||
SafariHandleSuccessBallThrowAnim,
|
||||
SafariHandleBallThrowAnim,
|
||||
SafariHandlePause,
|
||||
SafariHandleMoveAnimation,
|
||||
SafariHandlePrintString,
|
||||
SafariHandlePrintSelectionString,
|
||||
SafariHandleChooseAction,
|
||||
SafariHandleUnknownYesNoBox,
|
||||
SafariHandleChooseMove,
|
||||
SafariHandleChooseItem,
|
||||
SafariHandleChoosePokemon,
|
||||
SafariHandleCmd23,
|
||||
SafariHandleHealthBarUpdate,
|
||||
SafariHandleExpUpdate,
|
||||
SafariHandleStatusIconUpdate,
|
||||
SafariHandleStatusAnimation,
|
||||
SafariHandleStatusXor,
|
||||
SafariHandleDataTransfer,
|
||||
SafariHandleDMA3Transfer,
|
||||
SafariHandlePlayBGM,
|
||||
SafariHandleCmd32,
|
||||
SafariHandleTwoReturnValues,
|
||||
SafariHandleChosenMonReturnValue,
|
||||
SafariHandleOneReturnValue,
|
||||
SafariHandleOneReturnValue_Duplicate,
|
||||
SafariHandleCmd37,
|
||||
SafariHandleCmd38,
|
||||
SafariHandleCmd39,
|
||||
SafariHandleCmd40,
|
||||
SafariHandleHitAnimation,
|
||||
SafariHandleCmd42,
|
||||
SafariHandlePlaySE,
|
||||
SafariHandlePlayFanfareOrBGM,
|
||||
SafariHandleFaintingCry,
|
||||
SafariHandleIntroSlide,
|
||||
SafariHandleIntroTrainerBallThrow,
|
||||
SafariHandleDrawPartyStatusSummary,
|
||||
SafariHandleHidePartyStatusSummary,
|
||||
SafariHandleEndBounceEffect,
|
||||
SafariHandleSpriteInvisibility,
|
||||
SafariHandleBattleAnimation,
|
||||
SafariHandleLinkStandbyMsg,
|
||||
SafariHandleResetActionMoveSelection,
|
||||
SafariHandleCmd55,
|
||||
SafariCmdEnd,
|
||||
};
|
||||
|
||||
// not used
|
||||
static void SpriteCB_Null4(struct Sprite *sprite)
|
||||
{
|
||||
}
|
||||
|
||||
void SetControllerToSafari(void)
|
||||
{
|
||||
gBattlerControllerFuncs[gActiveBattler] = SafariBufferRunCommand;
|
||||
}
|
||||
|
||||
static void SafariBufferRunCommand(void)
|
||||
{
|
||||
if (gBattleControllerExecFlags & gBitTable[gActiveBattler])
|
||||
{
|
||||
if (gBattleBufferA[gActiveBattler][0] < NELEMS(sSafariBufferCommands))
|
||||
sSafariBufferCommands[gBattleBufferA[gActiveBattler][0]]();
|
||||
else
|
||||
SafariBufferExecCompleted();
|
||||
}
|
||||
}
|
||||
|
||||
static void HandleInputChooseAction(void)
|
||||
{
|
||||
if (JOY_NEW(A_BUTTON))
|
||||
{
|
||||
PlaySE(SE_SELECT);
|
||||
|
||||
switch (gActionSelectionCursor[gActiveBattler])
|
||||
{
|
||||
case 0:
|
||||
BtlController_EmitTwoReturnValues(1, B_ACTION_SAFARI_BALL, 0);
|
||||
break;
|
||||
case 1:
|
||||
BtlController_EmitTwoReturnValues(1, B_ACTION_SAFARI_POKEBLOCK, 0);
|
||||
break;
|
||||
case 2:
|
||||
BtlController_EmitTwoReturnValues(1, B_ACTION_SAFARI_GO_NEAR, 0);
|
||||
break;
|
||||
case 3:
|
||||
BtlController_EmitTwoReturnValues(1, B_ACTION_SAFARI_RUN, 0);
|
||||
break;
|
||||
}
|
||||
SafariBufferExecCompleted();
|
||||
}
|
||||
else if (JOY_NEW(DPAD_LEFT))
|
||||
{
|
||||
if (gActionSelectionCursor[gActiveBattler] & 1)
|
||||
{
|
||||
PlaySE(SE_SELECT);
|
||||
ActionSelectionDestroyCursorAt(gActionSelectionCursor[gActiveBattler]);
|
||||
gActionSelectionCursor[gActiveBattler] ^= 1;
|
||||
ActionSelectionCreateCursorAt(gActionSelectionCursor[gActiveBattler], 0);
|
||||
}
|
||||
}
|
||||
else if (JOY_NEW(DPAD_RIGHT))
|
||||
{
|
||||
if (!(gActionSelectionCursor[gActiveBattler] & 1))
|
||||
{
|
||||
PlaySE(SE_SELECT);
|
||||
ActionSelectionDestroyCursorAt(gActionSelectionCursor[gActiveBattler]);
|
||||
gActionSelectionCursor[gActiveBattler] ^= 1;
|
||||
ActionSelectionCreateCursorAt(gActionSelectionCursor[gActiveBattler], 0);
|
||||
}
|
||||
}
|
||||
else if (JOY_NEW(DPAD_UP))
|
||||
{
|
||||
if (gActionSelectionCursor[gActiveBattler] & 2)
|
||||
{
|
||||
PlaySE(SE_SELECT);
|
||||
ActionSelectionDestroyCursorAt(gActionSelectionCursor[gActiveBattler]);
|
||||
gActionSelectionCursor[gActiveBattler] ^= 2;
|
||||
ActionSelectionCreateCursorAt(gActionSelectionCursor[gActiveBattler], 0);
|
||||
}
|
||||
}
|
||||
else if (JOY_NEW(DPAD_DOWN))
|
||||
{
|
||||
if (!(gActionSelectionCursor[gActiveBattler] & 2))
|
||||
{
|
||||
PlaySE(SE_SELECT);
|
||||
ActionSelectionDestroyCursorAt(gActionSelectionCursor[gActiveBattler]);
|
||||
gActionSelectionCursor[gActiveBattler] ^= 2;
|
||||
ActionSelectionCreateCursorAt(gActionSelectionCursor[gActiveBattler], 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void CompleteOnBattlerSpriteCallbackDummy(void)
|
||||
{
|
||||
if (gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
|
||||
SafariBufferExecCompleted();
|
||||
}
|
||||
|
||||
static void CompleteOnInactiveTextPrinter(void)
|
||||
{
|
||||
if (!IsTextPrinterActive(0))
|
||||
SafariBufferExecCompleted();
|
||||
}
|
||||
|
||||
static void CompleteOnHealthboxSpriteCallbackDummy(void)
|
||||
{
|
||||
if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
|
||||
SafariBufferExecCompleted();
|
||||
}
|
||||
|
||||
static void sub_80DD7B0(void)
|
||||
{
|
||||
if (!gPaletteFade.active)
|
||||
{
|
||||
gMain.inBattle = FALSE;
|
||||
gMain.callback1 = gPreBattleCallback1;
|
||||
SetMainCallback2(gMain.savedCallback);
|
||||
}
|
||||
}
|
||||
|
||||
static void CompleteOnSpecialAnimDone(void)
|
||||
{
|
||||
if (!gDoingBattleAnim || !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive)
|
||||
SafariBufferExecCompleted();
|
||||
}
|
||||
|
||||
static void SafariOpenPokeblockCase(void)
|
||||
{
|
||||
if (!gPaletteFade.active)
|
||||
gBattlerControllerFuncs[gActiveBattler] = CompleteWhenChosePokeblock;
|
||||
}
|
||||
|
||||
static void CompleteWhenChosePokeblock(void)
|
||||
{
|
||||
if (gMain.callback2 == BattleMainCB2 && !gPaletteFade.active)
|
||||
{
|
||||
BtlController_EmitOneReturnValue(1, gSpecialVar_ItemId);
|
||||
SafariBufferExecCompleted();
|
||||
}
|
||||
}
|
||||
|
||||
static void CompleteOnFinishedBattleAnimation(void)
|
||||
{
|
||||
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animFromTableActive)
|
||||
SafariBufferExecCompleted();
|
||||
}
|
||||
|
||||
static void SafariBufferExecCompleted(void)
|
||||
{
|
||||
gBattlerControllerFuncs[gActiveBattler] = SafariBufferRunCommand;
|
||||
if (gBattleTypeFlags & BATTLE_TYPE_LINK)
|
||||
{
|
||||
u8 playerId = GetMultiplayerId();
|
||||
|
||||
PrepareBufferDataTransferLink(2, 4, &playerId);
|
||||
gBattleBufferA[gActiveBattler][0] = CONTROLLER_TERMINATOR_NOP;
|
||||
}
|
||||
else
|
||||
{
|
||||
gBattleControllerExecFlags &= ~gBitTable[gActiveBattler];
|
||||
}
|
||||
}
|
||||
|
||||
// not used
|
||||
static void CompleteOnFinishedStatusAnimation(void)
|
||||
{
|
||||
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].statusAnimActive)
|
||||
SafariBufferExecCompleted();
|
||||
}
|
||||
|
||||
static void SafariHandleGetMonData(void)
|
||||
{
|
||||
SafariBufferExecCompleted();
|
||||
}
|
||||
|
||||
static void SafariHandleGetRawMonData(void)
|
||||
{
|
||||
SafariBufferExecCompleted();
|
||||
}
|
||||
|
||||
static void SafariHandleSetMonData(void)
|
||||
{
|
||||
SafariBufferExecCompleted();
|
||||
}
|
||||
|
||||
static void SafariHandleSetRawMonData(void)
|
||||
{
|
||||
SafariBufferExecCompleted();
|
||||
}
|
||||
|
||||
static void SafariHandleLoadMonSprite(void)
|
||||
{
|
||||
SafariBufferExecCompleted();
|
||||
}
|
||||
|
||||
static void SafariHandleSwitchInAnim(void)
|
||||
{
|
||||
SafariBufferExecCompleted();
|
||||
}
|
||||
|
||||
static void SafariHandleReturnMonToBall(void)
|
||||
{
|
||||
SafariBufferExecCompleted();
|
||||
}
|
||||
|
||||
static void SafariHandleDrawTrainerPic(void)
|
||||
{
|
||||
DecompressTrainerBackPalette(gSaveBlock2Ptr->playerGender, gActiveBattler);
|
||||
SetMultiuseSpriteTemplateToTrainerBack(gSaveBlock2Ptr->playerGender, GetBattlerPosition(gActiveBattler));
|
||||
gBattlerSpriteIds[gActiveBattler] = CreateSprite(&gMultiuseSpriteTemplate,
|
||||
80,
|
||||
(8 - gTrainerBackPicCoords[gSaveBlock2Ptr->playerGender].size) * 4 + 80,
|
||||
30);
|
||||
gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = gActiveBattler;
|
||||
gSprites[gBattlerSpriteIds[gActiveBattler]].pos2.x = 240;
|
||||
gSprites[gBattlerSpriteIds[gActiveBattler]].data[0] = -2;
|
||||
gSprites[gBattlerSpriteIds[gActiveBattler]].callback = sub_8033EEC;
|
||||
gBattlerControllerFuncs[gActiveBattler] = CompleteOnBattlerSpriteCallbackDummy;
|
||||
}
|
||||
|
||||
static void SafariHandleTrainerSlide(void)
|
||||
{
|
||||
SafariBufferExecCompleted();
|
||||
}
|
||||
|
||||
static void SafariHandleTrainerSlideBack(void)
|
||||
{
|
||||
SafariBufferExecCompleted();
|
||||
}
|
||||
|
||||
static void SafariHandleFaintAnimation(void)
|
||||
{
|
||||
SafariBufferExecCompleted();
|
||||
}
|
||||
|
||||
static void SafariHandlePaletteFade(void)
|
||||
{
|
||||
SafariBufferExecCompleted();
|
||||
}
|
||||
|
||||
static void SafariHandleSuccessBallThrowAnim(void)
|
||||
{
|
||||
gBattleSpritesDataPtr->animationData->ballThrowCaseId = BALL_3_SHAKES_SUCCESS;
|
||||
gDoingBattleAnim = TRUE;
|
||||
InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT), B_ANIM_SAFARI_BALL_THROW);
|
||||
gBattlerControllerFuncs[gActiveBattler] = CompleteOnSpecialAnimDone;
|
||||
}
|
||||
|
||||
static void SafariHandleBallThrowAnim(void)
|
||||
{
|
||||
u8 ballThrowCaseId = gBattleBufferA[gActiveBattler][1];
|
||||
|
||||
gBattleSpritesDataPtr->animationData->ballThrowCaseId = ballThrowCaseId;
|
||||
gDoingBattleAnim = TRUE;
|
||||
InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT), B_ANIM_SAFARI_BALL_THROW);
|
||||
gBattlerControllerFuncs[gActiveBattler] = CompleteOnSpecialAnimDone;
|
||||
}
|
||||
|
||||
static void SafariHandlePause(void)
|
||||
{
|
||||
SafariBufferExecCompleted();
|
||||
}
|
||||
|
||||
static void SafariHandleMoveAnimation(void)
|
||||
{
|
||||
SafariBufferExecCompleted();
|
||||
}
|
||||
|
||||
static void SafariHandlePrintString(void)
|
||||
{
|
||||
u16 *stringId;
|
||||
|
||||
gBattle_BG0_X = 0;
|
||||
gBattle_BG0_Y = 0;
|
||||
stringId = (u16 *)(&gBattleBufferA[gActiveBattler][2]);
|
||||
BufferStringBattle(*stringId);
|
||||
if (sub_80D89B0(*stringId))
|
||||
BattlePutTextOnWindow(gDisplayedStringBattle, 0x40);
|
||||
else
|
||||
BattlePutTextOnWindow(gDisplayedStringBattle, 0);
|
||||
gBattlerControllerFuncs[gActiveBattler] = CompleteOnInactiveTextPrinter;
|
||||
}
|
||||
|
||||
static void SafariHandlePrintSelectionString(void)
|
||||
{
|
||||
if (GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER)
|
||||
SafariHandlePrintString();
|
||||
else
|
||||
SafariBufferExecCompleted();
|
||||
}
|
||||
|
||||
static void HandleChooseActionAfterDma3(void)
|
||||
{
|
||||
if (!IsDma3ManagerBusyWithBgCopy())
|
||||
{
|
||||
gBattle_BG0_X = 0;
|
||||
gBattle_BG0_Y = 160;
|
||||
gBattlerControllerFuncs[gActiveBattler] = HandleInputChooseAction;
|
||||
}
|
||||
}
|
||||
|
||||
static void SafariHandleChooseAction(void)
|
||||
{
|
||||
s32 i;
|
||||
|
||||
gBattlerControllerFuncs[gActiveBattler] = HandleChooseActionAfterDma3;
|
||||
BattlePutTextOnWindow(gUnknown_83FDA4C, 0);
|
||||
BattlePutTextOnWindow(gUnknown_83FE747, 2);
|
||||
for (i = 0; i < 4; ++i)
|
||||
ActionSelectionDestroyCursorAt(i);
|
||||
ActionSelectionCreateCursorAt(gActionSelectionCursor[gActiveBattler], 0);
|
||||
BattleStringExpandPlaceholdersToDisplayedString(gUnknown_83FE6E6);
|
||||
BattlePutTextOnWindow(gDisplayedStringBattle, 1);
|
||||
}
|
||||
|
||||
static void SafariHandleUnknownYesNoBox(void)
|
||||
{
|
||||
SafariBufferExecCompleted();
|
||||
}
|
||||
|
||||
static void SafariHandleChooseMove(void)
|
||||
{
|
||||
SafariBufferExecCompleted();
|
||||
}
|
||||
|
||||
static void SafariHandleChooseItem(void)
|
||||
{
|
||||
s32 i;
|
||||
|
||||
BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, RGB_BLACK);
|
||||
gBattlerControllerFuncs[gActiveBattler] = SafariOpenPokeblockCase;
|
||||
gBattlerInMenuId = gActiveBattler;
|
||||
}
|
||||
|
||||
static void SafariHandleChoosePokemon(void)
|
||||
{
|
||||
SafariBufferExecCompleted();
|
||||
}
|
||||
|
||||
static void SafariHandleCmd23(void)
|
||||
{
|
||||
SafariBufferExecCompleted();
|
||||
}
|
||||
|
||||
static void SafariHandleHealthBarUpdate(void)
|
||||
{
|
||||
SafariBufferExecCompleted();
|
||||
}
|
||||
|
||||
static void SafariHandleExpUpdate(void)
|
||||
{
|
||||
SafariBufferExecCompleted();
|
||||
}
|
||||
|
||||
static void SafariHandleStatusIconUpdate(void)
|
||||
{
|
||||
UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler], &gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], HEALTHBOX_SAFARI_BALLS_TEXT);
|
||||
SafariBufferExecCompleted();
|
||||
}
|
||||
|
||||
static void SafariHandleStatusAnimation(void)
|
||||
{
|
||||
SafariBufferExecCompleted();
|
||||
}
|
||||
|
||||
static void SafariHandleStatusXor(void)
|
||||
{
|
||||
SafariBufferExecCompleted();
|
||||
}
|
||||
|
||||
static void SafariHandleDataTransfer(void)
|
||||
{
|
||||
SafariBufferExecCompleted();
|
||||
}
|
||||
|
||||
static void SafariHandleDMA3Transfer(void)
|
||||
{
|
||||
SafariBufferExecCompleted();
|
||||
}
|
||||
|
||||
static void SafariHandlePlayBGM(void)
|
||||
{
|
||||
SafariBufferExecCompleted();
|
||||
}
|
||||
|
||||
static void SafariHandleCmd32(void)
|
||||
{
|
||||
SafariBufferExecCompleted();
|
||||
}
|
||||
|
||||
static void SafariHandleTwoReturnValues(void)
|
||||
{
|
||||
SafariBufferExecCompleted();
|
||||
}
|
||||
|
||||
static void SafariHandleChosenMonReturnValue(void)
|
||||
{
|
||||
SafariBufferExecCompleted();
|
||||
}
|
||||
|
||||
static void SafariHandleOneReturnValue(void)
|
||||
{
|
||||
SafariBufferExecCompleted();
|
||||
}
|
||||
|
||||
static void SafariHandleOneReturnValue_Duplicate(void)
|
||||
{
|
||||
SafariBufferExecCompleted();
|
||||
}
|
||||
|
||||
static void SafariHandleCmd37(void)
|
||||
{
|
||||
SafariBufferExecCompleted();
|
||||
}
|
||||
|
||||
static void SafariHandleCmd38(void)
|
||||
{
|
||||
SafariBufferExecCompleted();
|
||||
}
|
||||
|
||||
static void SafariHandleCmd39(void)
|
||||
{
|
||||
SafariBufferExecCompleted();
|
||||
}
|
||||
|
||||
static void SafariHandleCmd40(void)
|
||||
{
|
||||
SafariBufferExecCompleted();
|
||||
}
|
||||
|
||||
static void SafariHandleHitAnimation(void)
|
||||
{
|
||||
SafariBufferExecCompleted();
|
||||
}
|
||||
|
||||
static void SafariHandleCmd42(void)
|
||||
{
|
||||
SafariBufferExecCompleted();
|
||||
}
|
||||
|
||||
static void SafariHandlePlaySE(void)
|
||||
{
|
||||
s8 pan;
|
||||
|
||||
if (GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER)
|
||||
pan = SOUND_PAN_ATTACKER;
|
||||
else
|
||||
pan = SOUND_PAN_TARGET;
|
||||
PlaySE12WithPanning(gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8), pan);
|
||||
SafariBufferExecCompleted();
|
||||
}
|
||||
|
||||
static void SafariHandlePlayFanfareOrBGM(void)
|
||||
{
|
||||
PlayFanfare(gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8));
|
||||
SafariBufferExecCompleted();
|
||||
}
|
||||
|
||||
static void SafariHandleFaintingCry(void)
|
||||
{
|
||||
u16 species = GetMonData(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_SPECIES);
|
||||
|
||||
PlayCry1(species, 25);
|
||||
SafariBufferExecCompleted();
|
||||
}
|
||||
|
||||
static void SafariHandleIntroSlide(void)
|
||||
{
|
||||
HandleIntroSlide(gBattleBufferA[gActiveBattler][1]);
|
||||
gIntroSlideFlags |= 1;
|
||||
SafariBufferExecCompleted();
|
||||
}
|
||||
|
||||
static void SafariHandleIntroTrainerBallThrow(void)
|
||||
{
|
||||
UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler], &gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], HEALTHBOX_SAFARI_ALL_TEXT);
|
||||
sub_804BD94(gActiveBattler);
|
||||
SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]);
|
||||
gBattlerControllerFuncs[gActiveBattler] = CompleteOnHealthboxSpriteCallbackDummy;
|
||||
}
|
||||
|
||||
static void SafariHandleDrawPartyStatusSummary(void)
|
||||
{
|
||||
SafariBufferExecCompleted();
|
||||
}
|
||||
|
||||
static void SafariHandleHidePartyStatusSummary(void)
|
||||
{
|
||||
SafariBufferExecCompleted();
|
||||
}
|
||||
|
||||
static void SafariHandleEndBounceEffect(void)
|
||||
{
|
||||
SafariBufferExecCompleted();
|
||||
}
|
||||
|
||||
static void SafariHandleSpriteInvisibility(void)
|
||||
{
|
||||
SafariBufferExecCompleted();
|
||||
}
|
||||
|
||||
static void SafariHandleBattleAnimation(void)
|
||||
{
|
||||
u8 animationId = gBattleBufferA[gActiveBattler][1];
|
||||
u16 argument = gBattleBufferA[gActiveBattler][2] | (gBattleBufferA[gActiveBattler][3] << 8);
|
||||
|
||||
if (TryHandleLaunchBattleTableAnimation(gActiveBattler, gActiveBattler, gActiveBattler, animationId, argument))
|
||||
SafariBufferExecCompleted();
|
||||
else
|
||||
gBattlerControllerFuncs[gActiveBattler] = CompleteOnFinishedBattleAnimation;
|
||||
}
|
||||
|
||||
static void SafariHandleLinkStandbyMsg(void)
|
||||
{
|
||||
SafariBufferExecCompleted();
|
||||
}
|
||||
|
||||
static void SafariHandleResetActionMoveSelection(void)
|
||||
{
|
||||
SafariBufferExecCompleted();
|
||||
}
|
||||
|
||||
static void SafariHandleCmd55(void)
|
||||
{
|
||||
gBattleOutcome = gBattleBufferA[gActiveBattler][1];
|
||||
FadeOutMapMusic(5);
|
||||
BeginFastPaletteFade(3);
|
||||
SafariBufferExecCompleted();
|
||||
if ((gBattleTypeFlags & BATTLE_TYPE_LINK) && !(gBattleTypeFlags & BATTLE_TYPE_IS_MASTER))
|
||||
gBattlerControllerFuncs[gActiveBattler] = sub_80DD7B0;
|
||||
}
|
||||
|
||||
static void SafariCmdEnd(void)
|
||||
{
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
+13
-13
@@ -58,7 +58,7 @@ static const struct WindowTemplate sWindowTemplates[] = {
|
||||
}, DUMMY_WIN_TEMPLATE
|
||||
};
|
||||
|
||||
static const struct TextColor sTextColor = {
|
||||
static const u8 sTextColor[3] = {
|
||||
0, 2, 3
|
||||
};
|
||||
|
||||
@@ -279,7 +279,7 @@ static void ResetBGPos(void)
|
||||
ChangeBgY(3, 0, 0);
|
||||
}
|
||||
|
||||
static void InitLinkBattleRecord(struct LinkBattleRecord * record)
|
||||
static void ClearLinkBattleRecord(struct LinkBattleRecord *record)
|
||||
{
|
||||
CpuFill16(0, record, sizeof(*record));
|
||||
record->name[0] = EOS;
|
||||
@@ -289,12 +289,12 @@ static void InitLinkBattleRecord(struct LinkBattleRecord * record)
|
||||
record->draws = 0;
|
||||
}
|
||||
|
||||
static void InitLinkBattleRecords_(struct LinkBattleRecords * records)
|
||||
static void ClearLinkBattleRecords(struct LinkBattleRecords *records)
|
||||
{
|
||||
s32 i;
|
||||
|
||||
for (i = 0; i < LINK_B_RECORDS_COUNT; i++)
|
||||
InitLinkBattleRecord(&records->entries[i]);
|
||||
ClearLinkBattleRecord(&records->entries[i]);
|
||||
SetGameStat(GAME_STAT_LINK_BATTLE_WINS, 0);
|
||||
SetGameStat(GAME_STAT_LINK_BATTLE_LOSSES, 0);
|
||||
SetGameStat(GAME_STAT_LINK_BATTLE_DRAWS, 0);
|
||||
@@ -404,7 +404,7 @@ static void AddOpponentLinkBattleRecord(struct LinkBattleRecords * records, cons
|
||||
{
|
||||
i = LINK_B_RECORDS_COUNT - 1;
|
||||
record = &records->entries[LINK_B_RECORDS_COUNT - 1];
|
||||
InitLinkBattleRecord(record);
|
||||
ClearLinkBattleRecord(record);
|
||||
StringCopyN(record->name, namebuf, OT_NAME_LENGTH);
|
||||
record->trainerId = trainerId;
|
||||
}
|
||||
@@ -412,9 +412,9 @@ static void AddOpponentLinkBattleRecord(struct LinkBattleRecords * records, cons
|
||||
SortLinkBattleRecords(records);
|
||||
}
|
||||
|
||||
void InitLinkBattleRecords(void)
|
||||
void ClearPlayerLinkBattleRecords(void)
|
||||
{
|
||||
InitLinkBattleRecords_(&gSaveBlock2Ptr->linkBattleRecords);
|
||||
ClearLinkBattleRecords(&gSaveBlock2Ptr->linkBattleRecords);
|
||||
}
|
||||
|
||||
static void IncTrainerCardWinCount(s32 battlerId)
|
||||
@@ -494,7 +494,7 @@ static void PrintTotalRecord(struct LinkBattleRecords * records)
|
||||
}
|
||||
|
||||
StringExpandPlaceholders(gStringVar4, gString_BattleRecords_TotalRecord);
|
||||
AddTextPrinterParameterized4(0, 2, 12, 24, 0, 2, &sTextColor, 0, gStringVar4);
|
||||
AddTextPrinterParameterized4(0, 2, 12, 24, 0, 2, sTextColor, 0, gStringVar4);
|
||||
}
|
||||
|
||||
static void PrintOpponentBattleRecord(struct LinkBattleRecord * record, u8 y)
|
||||
@@ -504,7 +504,7 @@ static void PrintOpponentBattleRecord(struct LinkBattleRecord * record, u8 y)
|
||||
|
||||
if (record->wins == 0 && record->losses == 0 && record->draws == 0)
|
||||
{
|
||||
AddTextPrinterParameterized4(0, 2, 0, y, 0, 2, &sTextColor, 0, gString_BattleRecords_7Dashes);
|
||||
AddTextPrinterParameterized4(0, 2, 0, y, 0, 2, sTextColor, 0, gString_BattleRecords_7Dashes);
|
||||
for (i = 0; i < 3; i++)
|
||||
{
|
||||
if (i == 0)
|
||||
@@ -513,7 +513,7 @@ static void PrintOpponentBattleRecord(struct LinkBattleRecord * record, u8 y)
|
||||
x = 0x84;
|
||||
else
|
||||
x = 0xB4;
|
||||
AddTextPrinterParameterized4(0, 2, x, y, 0, 2, &sTextColor, 0, gString_BattleRecords_4Dashes);
|
||||
AddTextPrinterParameterized4(0, 2, x, y, 0, 2, sTextColor, 0, gString_BattleRecords_4Dashes);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -541,7 +541,7 @@ static void PrintOpponentBattleRecord(struct LinkBattleRecord * record, u8 y)
|
||||
x = 0xB4;
|
||||
ConvertIntToDecimalStringN(gStringVar1, record->draws, STR_CONV_MODE_RIGHT_ALIGN, 4);
|
||||
}
|
||||
AddTextPrinterParameterized4(0, 2, x, y, 0, 2, &sTextColor, 0, gStringVar1);
|
||||
AddTextPrinterParameterized4(0, 2, x, y, 0, 2, sTextColor, 0, gStringVar1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -554,9 +554,9 @@ static void PrintBattleRecords(void)
|
||||
FillWindowPixelRect(0, PIXEL_FILL(0), 0, 0, 0xD8, 0x90);
|
||||
StringExpandPlaceholders(gStringVar4, gString_BattleRecords_PlayersBattleResults);
|
||||
left = 0xD0 - GetStringWidth(2, gStringVar4, -1);
|
||||
AddTextPrinterParameterized4(0, 2, left / 2, 4, 0, 2, &sTextColor, 0, gStringVar4);
|
||||
AddTextPrinterParameterized4(0, 2, left / 2, 4, 0, 2, sTextColor, 0, gStringVar4);
|
||||
PrintTotalRecord(&gSaveBlock2Ptr->linkBattleRecords);
|
||||
AddTextPrinterParameterized4(0, 2, 0x54, 0x30, 0, 2, &sTextColor, 0, gString_BattleRecords_ColumnHeaders);
|
||||
AddTextPrinterParameterized4(0, 2, 0x54, 0x30, 0, 2, sTextColor, 0, gString_BattleRecords_ColumnHeaders);
|
||||
for (i = 0; i < LINK_B_RECORDS_COUNT; i++)
|
||||
PrintOpponentBattleRecord(&gSaveBlock2Ptr->linkBattleRecords.entries[i], 0x3D + 14 * i);
|
||||
CommitWindow(0);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
+3200
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,96 @@
|
||||
#include "global.h"
|
||||
#include "bg.h"
|
||||
#include "battle.h"
|
||||
#include "pokemon.h"
|
||||
#include "malloc.h"
|
||||
#include "trainer_tower.h"
|
||||
#include "battle_util2.h"
|
||||
|
||||
void AllocateBattleResources(void)
|
||||
{
|
||||
if (gBattleTypeFlags & BATTLE_TYPE_TRAINER_TOWER)
|
||||
InitTrainerTowerBattleStruct();
|
||||
if (gBattleTypeFlags & BATTLE_TYPE_POKEDUDE)
|
||||
{
|
||||
s32 i;
|
||||
|
||||
for (i = 0; i < 4; ++i)
|
||||
gUnknown_3005EE0[i] = AllocZeroed(8);
|
||||
}
|
||||
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->beforeLvlUp = AllocZeroed(sizeof(*gBattleResources->beforeLvlUp));
|
||||
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_2022BB8 = AllocZeroed(0x2000);
|
||||
gUnknown_2022BBC = AllocZeroed(0x1000);
|
||||
SetBgTilemapBuffer(1, gUnknown_2022BBC);
|
||||
SetBgTilemapBuffer(2, gUnknown_2022BBC);
|
||||
}
|
||||
|
||||
void FreeBattleResources(void)
|
||||
{
|
||||
if (gBattleTypeFlags & BATTLE_TYPE_TRAINER_TOWER)
|
||||
FreeTrainerTowerBattleStruct();
|
||||
if (gBattleTypeFlags & BATTLE_TYPE_POKEDUDE)
|
||||
{
|
||||
s32 i;
|
||||
|
||||
for (i = 0; i < 4; ++i)
|
||||
{
|
||||
FREE_AND_SET_NULL(gUnknown_3005EE0[i]);
|
||||
}
|
||||
}
|
||||
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->beforeLvlUp);
|
||||
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_2022BB8);
|
||||
FREE_AND_SET_NULL(gUnknown_2022BBC);
|
||||
}
|
||||
}
|
||||
|
||||
void AdjustFriendshipOnBattleFaint(u8 battlerId)
|
||||
{
|
||||
u8 opposingBattlerId, opposingBattlerId2;
|
||||
|
||||
if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE)
|
||||
{
|
||||
opposingBattlerId = GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT);
|
||||
opposingBattlerId2 = GetBattlerAtPosition(B_POSITION_OPPONENT_RIGHT);
|
||||
if (gBattleMons[opposingBattlerId2].level > gBattleMons[opposingBattlerId].level)
|
||||
opposingBattlerId = opposingBattlerId2;
|
||||
}
|
||||
else
|
||||
{
|
||||
opposingBattlerId = GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT);
|
||||
}
|
||||
if (gBattleMons[opposingBattlerId].level > gBattleMons[battlerId].level)
|
||||
{
|
||||
if (gBattleMons[opposingBattlerId].level - gBattleMons[battlerId].level > 29)
|
||||
AdjustFriendship(&gPlayerParty[gBattlerPartyIndexes[battlerId]], 9);
|
||||
else
|
||||
AdjustFriendship(&gPlayerParty[gBattlerPartyIndexes[battlerId]], 7);
|
||||
}
|
||||
else
|
||||
{
|
||||
AdjustFriendship(&gPlayerParty[gBattlerPartyIndexes[battlerId]], 7);
|
||||
}
|
||||
}
|
||||
+1528
File diff suppressed because it is too large
Load Diff
+12
-12
@@ -11,12 +11,12 @@
|
||||
|
||||
EWRAM_DATA u8 gUnknown_203F464 = 0;
|
||||
|
||||
u32 sub_815EE3C(u32 * a0)
|
||||
u32 DecryptBerryPowder(u32 * a0)
|
||||
{
|
||||
return *a0 ^ gSaveBlock2Ptr->encryptionKey;
|
||||
}
|
||||
|
||||
void sub_815EE54(u32 * a0, u32 a1)
|
||||
void SetBerryPowder(u32 * a0, u32 a1)
|
||||
{
|
||||
*a0 = gSaveBlock2Ptr->encryptionKey ^ a1;
|
||||
}
|
||||
@@ -28,7 +28,7 @@ void sub_815EE6C(u32 a0)
|
||||
|
||||
bool8 sub_815EE88(u32 a0)
|
||||
{
|
||||
if (sub_815EE3C(&gSaveBlock2Ptr->berryCrush.berryPowderAmount) < a0)
|
||||
if (DecryptBerryPowder(&gSaveBlock2Ptr->berryCrush.berryPowderAmount) < a0)
|
||||
return FALSE;
|
||||
else
|
||||
return TRUE;
|
||||
@@ -36,7 +36,7 @@ bool8 sub_815EE88(u32 a0)
|
||||
|
||||
bool8 sub_815EEB0(void)
|
||||
{
|
||||
if (sub_815EE3C(&gSaveBlock2Ptr->berryCrush.berryPowderAmount) < gSpecialVar_0x8004)
|
||||
if (DecryptBerryPowder(&gSaveBlock2Ptr->berryCrush.berryPowderAmount) < gSpecialVar_0x8004)
|
||||
return FALSE;
|
||||
else
|
||||
return TRUE;
|
||||
@@ -45,15 +45,15 @@ bool8 sub_815EEB0(void)
|
||||
bool8 sub_815EEE0(u32 a0)
|
||||
{
|
||||
u32 * ptr = &gSaveBlock2Ptr->berryCrush.berryPowderAmount;
|
||||
u32 amount = sub_815EE3C(ptr) + a0;
|
||||
u32 amount = DecryptBerryPowder(ptr) + a0;
|
||||
if (amount > 99999)
|
||||
{
|
||||
sub_815EE54(ptr, 99999);
|
||||
SetBerryPowder(ptr, 99999);
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
sub_815EE54(ptr, amount);
|
||||
SetBerryPowder(ptr, amount);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
@@ -65,8 +65,8 @@ bool8 sub_815EF20(u32 a0)
|
||||
return FALSE;
|
||||
else
|
||||
{
|
||||
u32 amount = sub_815EE3C(ptr);
|
||||
sub_815EE54(ptr, amount - a0);
|
||||
u32 amount = DecryptBerryPowder(ptr);
|
||||
SetBerryPowder(ptr, amount - a0);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
@@ -78,15 +78,15 @@ bool8 sub_815EF5C(void)
|
||||
return FALSE;
|
||||
else
|
||||
{
|
||||
u32 amount = sub_815EE3C(ptr);
|
||||
sub_815EE54(ptr, amount - gSpecialVar_0x8004);
|
||||
u32 amount = DecryptBerryPowder(ptr);
|
||||
SetBerryPowder(ptr, amount - gSpecialVar_0x8004);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
u32 GetBerryPowder(void)
|
||||
{
|
||||
return sub_815EE3C(&gSaveBlock2Ptr->berryCrush.berryPowderAmount);
|
||||
return DecryptBerryPowder(&gSaveBlock2Ptr->berryCrush.berryPowderAmount);
|
||||
}
|
||||
|
||||
void sub_815EFBC(u8 windowId, u32 powder, u8 x, u8 y, u8 speed)
|
||||
|
||||
+43
-43
@@ -17,20 +17,20 @@ u16 Font6Func(struct TextPrinter *textPrinter)
|
||||
u16 char_;
|
||||
struct TextPrinterSubStruct *sub;
|
||||
|
||||
sub = &textPrinter->sub_union.sub;
|
||||
sub = &textPrinter->subUnion.sub;
|
||||
switch (textPrinter->state)
|
||||
{
|
||||
case 0:
|
||||
if (gMain.heldKeys & (A_BUTTON | B_BUTTON) && sub->font_type_upper)
|
||||
if (gMain.heldKeys & (A_BUTTON | B_BUTTON) && sub->hasPrintBeenSpedUp)
|
||||
{
|
||||
textPrinter->delayCounter = 0;
|
||||
}
|
||||
if (textPrinter->delayCounter && textPrinter->text_speed)
|
||||
if (textPrinter->delayCounter && textPrinter->textSpeed)
|
||||
{
|
||||
textPrinter->delayCounter --;
|
||||
if (gTextFlags.canABSpeedUpPrint && gMain.newKeys & (A_BUTTON | B_BUTTON))
|
||||
{
|
||||
sub->font_type_upper = TRUE;
|
||||
sub->hasPrintBeenSpedUp = TRUE;
|
||||
textPrinter->delayCounter = 0;
|
||||
}
|
||||
return 3;
|
||||
@@ -41,62 +41,62 @@ u16 Font6Func(struct TextPrinter *textPrinter)
|
||||
}
|
||||
else
|
||||
{
|
||||
textPrinter->delayCounter = textPrinter->text_speed;
|
||||
textPrinter->delayCounter = textPrinter->textSpeed;
|
||||
}
|
||||
char_ = *textPrinter->subPrinter.currentChar++;
|
||||
char_ = *textPrinter->printerTemplate.currentChar++;
|
||||
switch (char_)
|
||||
{
|
||||
case EOS:
|
||||
return 1;
|
||||
case CHAR_NEWLINE:
|
||||
textPrinter->subPrinter.currentX = textPrinter->subPrinter.x;
|
||||
textPrinter->subPrinter.currentY += gFonts[textPrinter->subPrinter.fontId].maxLetterHeight + textPrinter->subPrinter.lineSpacing;
|
||||
textPrinter->printerTemplate.currentX = textPrinter->printerTemplate.x;
|
||||
textPrinter->printerTemplate.currentY += gFonts[textPrinter->printerTemplate.fontId].maxLetterHeight + textPrinter->printerTemplate.lineSpacing;
|
||||
return 2;
|
||||
case PLACEHOLDER_BEGIN:
|
||||
textPrinter->subPrinter.currentChar++;
|
||||
textPrinter->printerTemplate.currentChar++;
|
||||
return 2;
|
||||
case EXT_CTRL_CODE_BEGIN:
|
||||
char_ = *textPrinter->subPrinter.currentChar++;
|
||||
char_ = *textPrinter->printerTemplate.currentChar++;
|
||||
switch (char_)
|
||||
{
|
||||
case 1:
|
||||
textPrinter->subPrinter.fgColor = *textPrinter->subPrinter.currentChar++;
|
||||
GenerateFontHalfRowLookupTable(textPrinter->subPrinter.fgColor, textPrinter->subPrinter.bgColor, textPrinter->subPrinter.shadowColor);
|
||||
textPrinter->printerTemplate.fgColor = *textPrinter->printerTemplate.currentChar++;
|
||||
GenerateFontHalfRowLookupTable(textPrinter->printerTemplate.fgColor, textPrinter->printerTemplate.bgColor, textPrinter->printerTemplate.shadowColor);
|
||||
return 2;
|
||||
case 2:
|
||||
textPrinter->subPrinter.bgColor = *textPrinter->subPrinter.currentChar++;
|
||||
GenerateFontHalfRowLookupTable(textPrinter->subPrinter.fgColor, textPrinter->subPrinter.bgColor, textPrinter->subPrinter.shadowColor);
|
||||
textPrinter->printerTemplate.bgColor = *textPrinter->printerTemplate.currentChar++;
|
||||
GenerateFontHalfRowLookupTable(textPrinter->printerTemplate.fgColor, textPrinter->printerTemplate.bgColor, textPrinter->printerTemplate.shadowColor);
|
||||
return 2;
|
||||
case 3:
|
||||
textPrinter->subPrinter.shadowColor = *textPrinter->subPrinter.currentChar++;
|
||||
GenerateFontHalfRowLookupTable(textPrinter->subPrinter.fgColor, textPrinter->subPrinter.bgColor, textPrinter->subPrinter.shadowColor);
|
||||
textPrinter->printerTemplate.shadowColor = *textPrinter->printerTemplate.currentChar++;
|
||||
GenerateFontHalfRowLookupTable(textPrinter->printerTemplate.fgColor, textPrinter->printerTemplate.bgColor, textPrinter->printerTemplate.shadowColor);
|
||||
return 2;
|
||||
case 4:
|
||||
textPrinter->subPrinter.fgColor = *textPrinter->subPrinter.currentChar;
|
||||
textPrinter->subPrinter.bgColor = *++textPrinter->subPrinter.currentChar;
|
||||
textPrinter->subPrinter.shadowColor = *++textPrinter->subPrinter.currentChar;
|
||||
textPrinter->subPrinter.currentChar++;
|
||||
textPrinter->printerTemplate.fgColor = *textPrinter->printerTemplate.currentChar;
|
||||
textPrinter->printerTemplate.bgColor = *++textPrinter->printerTemplate.currentChar;
|
||||
textPrinter->printerTemplate.shadowColor = *++textPrinter->printerTemplate.currentChar;
|
||||
textPrinter->printerTemplate.currentChar++;
|
||||
|
||||
GenerateFontHalfRowLookupTable(textPrinter->subPrinter.fgColor, textPrinter->subPrinter.bgColor, textPrinter->subPrinter.shadowColor);
|
||||
GenerateFontHalfRowLookupTable(textPrinter->printerTemplate.fgColor, textPrinter->printerTemplate.bgColor, textPrinter->printerTemplate.shadowColor);
|
||||
return 2;
|
||||
case 5:
|
||||
textPrinter->subPrinter.currentChar++;
|
||||
textPrinter->printerTemplate.currentChar++;
|
||||
return 2;
|
||||
case 6:
|
||||
sub->font_type = *textPrinter->subPrinter.currentChar;
|
||||
textPrinter->subPrinter.currentChar++;
|
||||
sub->glyphId = *textPrinter->printerTemplate.currentChar;
|
||||
textPrinter->printerTemplate.currentChar++;
|
||||
return 2;
|
||||
case 7:
|
||||
return 2;
|
||||
case 8:
|
||||
textPrinter->delayCounter = *textPrinter->subPrinter.currentChar++;
|
||||
textPrinter->delayCounter = *textPrinter->printerTemplate.currentChar++;
|
||||
textPrinter->state = 6;
|
||||
return 2;
|
||||
case 9:
|
||||
textPrinter->state = 1;
|
||||
if (gTextFlags.autoScroll)
|
||||
{
|
||||
sub->frames_visible_counter = 0;
|
||||
sub->autoScrollDelay = 0;
|
||||
}
|
||||
return 3;
|
||||
case 10:
|
||||
@@ -104,19 +104,19 @@ u16 Font6Func(struct TextPrinter *textPrinter)
|
||||
return 3;
|
||||
case 11:
|
||||
case 16:
|
||||
textPrinter->subPrinter.currentChar += 2;
|
||||
textPrinter->printerTemplate.currentChar += 2;
|
||||
return 2;
|
||||
case 12:
|
||||
char_ = *++textPrinter->subPrinter.currentChar;
|
||||
char_ = *++textPrinter->printerTemplate.currentChar;
|
||||
break;
|
||||
case 13:
|
||||
textPrinter->subPrinter.currentX = textPrinter->subPrinter.x + *textPrinter->subPrinter.currentChar++;
|
||||
textPrinter->printerTemplate.currentX = textPrinter->printerTemplate.x + *textPrinter->printerTemplate.currentChar++;
|
||||
return 2;
|
||||
case 14:
|
||||
textPrinter->subPrinter.currentY = textPrinter->subPrinter.y + *textPrinter->subPrinter.currentChar++;
|
||||
textPrinter->printerTemplate.currentY = textPrinter->printerTemplate.y + *textPrinter->printerTemplate.currentChar++;
|
||||
return 2;
|
||||
case 15:
|
||||
FillWindowPixelBuffer(textPrinter->subPrinter.windowId, PIXEL_FILL(textPrinter->subPrinter.bgColor));
|
||||
FillWindowPixelBuffer(textPrinter->printerTemplate.windowId, PIXEL_FILL(textPrinter->printerTemplate.bgColor));
|
||||
return 2;
|
||||
}
|
||||
break;
|
||||
@@ -129,15 +129,15 @@ u16 Font6Func(struct TextPrinter *textPrinter)
|
||||
TextPrinterInitDownArrowCounters(textPrinter);
|
||||
return 3;
|
||||
case 0xF9:
|
||||
char_ = *textPrinter->subPrinter.currentChar++| 0x100;
|
||||
char_ = *textPrinter->printerTemplate.currentChar++| 0x100;
|
||||
break;
|
||||
case 0xF8:
|
||||
textPrinter->subPrinter.currentChar++;
|
||||
textPrinter->printerTemplate.currentChar++;
|
||||
return 0;
|
||||
}
|
||||
DecompressGlyphFont6(char_);
|
||||
CopyGlyphToWindow(textPrinter);
|
||||
textPrinter->subPrinter.currentX += gGlyphInfo[0x80] + textPrinter->subPrinter.letterSpacing;
|
||||
textPrinter->printerTemplate.currentX += gGlyphInfo[0x80] + textPrinter->printerTemplate.letterSpacing;
|
||||
return 0;
|
||||
case 1:
|
||||
if (TextPrinterWait(textPrinter))
|
||||
@@ -148,9 +148,9 @@ u16 Font6Func(struct TextPrinter *textPrinter)
|
||||
case 2:
|
||||
if (TextPrinterWaitWithDownArrow(textPrinter))
|
||||
{
|
||||
FillWindowPixelBuffer(textPrinter->subPrinter.windowId, PIXEL_FILL(textPrinter->subPrinter.bgColor));
|
||||
textPrinter->subPrinter.currentX = textPrinter->subPrinter.x;
|
||||
textPrinter->subPrinter.currentY = textPrinter->subPrinter.y;
|
||||
FillWindowPixelBuffer(textPrinter->printerTemplate.windowId, PIXEL_FILL(textPrinter->printerTemplate.bgColor));
|
||||
textPrinter->printerTemplate.currentX = textPrinter->printerTemplate.x;
|
||||
textPrinter->printerTemplate.currentY = textPrinter->printerTemplate.y;
|
||||
textPrinter->state = 0;
|
||||
}
|
||||
return 3;
|
||||
@@ -158,8 +158,8 @@ u16 Font6Func(struct TextPrinter *textPrinter)
|
||||
if (TextPrinterWaitWithDownArrow(textPrinter))
|
||||
{
|
||||
TextPrinterClearDownArrow(textPrinter);
|
||||
textPrinter->scrollDistance = gFonts[textPrinter->subPrinter.fontId].maxLetterHeight + textPrinter->subPrinter.lineSpacing;
|
||||
textPrinter->subPrinter.currentX = textPrinter->subPrinter.x;
|
||||
textPrinter->scrollDistance = gFonts[textPrinter->printerTemplate.fontId].maxLetterHeight + textPrinter->printerTemplate.lineSpacing;
|
||||
textPrinter->printerTemplate.currentX = textPrinter->printerTemplate.x;
|
||||
textPrinter->state = 4;
|
||||
}
|
||||
return 3;
|
||||
@@ -168,15 +168,15 @@ u16 Font6Func(struct TextPrinter *textPrinter)
|
||||
{
|
||||
if (textPrinter->scrollDistance < gUnknown_846FB08[gSaveBlock2Ptr->optionsTextSpeed])
|
||||
{
|
||||
ScrollWindow(textPrinter->subPrinter.windowId, 0, textPrinter->scrollDistance, PIXEL_FILL(textPrinter->subPrinter.bgColor));
|
||||
ScrollWindow(textPrinter->printerTemplate.windowId, 0, textPrinter->scrollDistance, PIXEL_FILL(textPrinter->printerTemplate.bgColor));
|
||||
textPrinter->scrollDistance = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
ScrollWindow(textPrinter->subPrinter.windowId, 0, gUnknown_846FB08[gSaveBlock2Ptr->optionsTextSpeed], PIXEL_FILL(textPrinter->subPrinter.bgColor));
|
||||
ScrollWindow(textPrinter->printerTemplate.windowId, 0, gUnknown_846FB08[gSaveBlock2Ptr->optionsTextSpeed], PIXEL_FILL(textPrinter->printerTemplate.bgColor));
|
||||
textPrinter->scrollDistance -= gUnknown_846FB08[gSaveBlock2Ptr->optionsTextSpeed];
|
||||
}
|
||||
CopyWindowToVram(textPrinter->subPrinter.windowId, 2);
|
||||
CopyWindowToVram(textPrinter->printerTemplate.windowId, 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -216,7 +216,7 @@ static void DecompressGlyphFont6(u16 glyph)
|
||||
gGlyphInfo[0x81] = 0x10;
|
||||
}
|
||||
|
||||
u32 GetGlyphWidthFont6(u16 font_type, bool32 isJapanese)
|
||||
s32 GetGlyphWidthFont6(u16 font_type, bool32 isJapanese)
|
||||
{
|
||||
return 0x10;
|
||||
}
|
||||
|
||||
+5
-17
@@ -148,23 +148,11 @@ static const struct WindowTemplate sShopBuyMenuYesNoWindowTemplate =
|
||||
.baseBlock = 0xC1,
|
||||
};
|
||||
|
||||
static const struct TextColor sShopBuyMenuTextColors[] =
|
||||
static const u8 sShopBuyMenuTextColors[][3] =
|
||||
{
|
||||
{
|
||||
.fgColor = 0,
|
||||
.bgColor = 1,
|
||||
.shadowColor = 2,
|
||||
},
|
||||
{
|
||||
.fgColor = 0,
|
||||
.bgColor = 2,
|
||||
.shadowColor = 3,
|
||||
},
|
||||
{
|
||||
.fgColor = 0,
|
||||
.bgColor = 3,
|
||||
.shadowColor = 2,
|
||||
},
|
||||
{0, 1, 2},
|
||||
{0, 2, 3},
|
||||
{0, 3, 2}
|
||||
};
|
||||
|
||||
void BuyMenuInitWindows(bool32 isSellingTM)
|
||||
@@ -191,7 +179,7 @@ void BuyMenuDrawMoneyBox(void)
|
||||
|
||||
void BuyMenuPrint(u8 windowId, u8 font, const u8 *text, u8 x, u8 y, u8 letterSpacing, u8 lineSpacing, s8 speed, u8 color)
|
||||
{
|
||||
AddTextPrinterParameterized4(windowId, font, x, y, letterSpacing, lineSpacing, &sShopBuyMenuTextColors[color], speed, text);
|
||||
AddTextPrinterParameterized4(windowId, font, x, y, letterSpacing, lineSpacing, sShopBuyMenuTextColors[color], speed, text);
|
||||
}
|
||||
|
||||
void BuyMenuDisplayMessage(u8 taskId, const u8 *text, TaskFunc callback)
|
||||
|
||||
+2168
File diff suppressed because it is too large
Load Diff
+1
-1
@@ -6059,4 +6059,4 @@
|
||||
"secondaryId": 0
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
+175
-175
@@ -63,7 +63,7 @@ struct EggHatchData
|
||||
u8 unused_9;
|
||||
u8 unused_A;
|
||||
u16 species;
|
||||
struct TextColor textColor;
|
||||
u8 textColor[3];
|
||||
};
|
||||
|
||||
extern const u8 gText_MaleSymbol4[];
|
||||
@@ -168,215 +168,215 @@ static const u8 sEggHatchTiles[] = INCBIN_U8("graphics/misc/egg_hatch.4bpp");
|
||||
static const u8 sEggShardTiles[] = INCBIN_U8("graphics/misc/egg_shard.4bpp");
|
||||
|
||||
static const struct OamData sOamData_EggHatch =
|
||||
{
|
||||
.y = 0,
|
||||
.affineMode = 0,
|
||||
.objMode = 0,
|
||||
.mosaic = 0,
|
||||
.bpp = 0,
|
||||
.shape = SPRITE_SHAPE(32x32),
|
||||
.x = 0,
|
||||
.matrixNum = 0,
|
||||
.size = SPRITE_SIZE(32x32),
|
||||
.tileNum = 0,
|
||||
.priority = 1,
|
||||
.paletteNum = 0,
|
||||
.affineParam = 0,
|
||||
};
|
||||
{
|
||||
.y = 0,
|
||||
.affineMode = 0,
|
||||
.objMode = 0,
|
||||
.mosaic = 0,
|
||||
.bpp = 0,
|
||||
.shape = SPRITE_SHAPE(32x32),
|
||||
.x = 0,
|
||||
.matrixNum = 0,
|
||||
.size = SPRITE_SIZE(32x32),
|
||||
.tileNum = 0,
|
||||
.priority = 1,
|
||||
.paletteNum = 0,
|
||||
.affineParam = 0,
|
||||
};
|
||||
|
||||
static const union AnimCmd sSpriteAnim_EggHatch0[] =
|
||||
{
|
||||
ANIMCMD_FRAME(0, 5),
|
||||
ANIMCMD_END
|
||||
};
|
||||
{
|
||||
ANIMCMD_FRAME(0, 5),
|
||||
ANIMCMD_END
|
||||
};
|
||||
|
||||
static const union AnimCmd sSpriteAnim_EggHatch1[] =
|
||||
{
|
||||
ANIMCMD_FRAME(16, 5),
|
||||
ANIMCMD_END
|
||||
};
|
||||
{
|
||||
ANIMCMD_FRAME(16, 5),
|
||||
ANIMCMD_END
|
||||
};
|
||||
|
||||
static const union AnimCmd sSpriteAnim_EggHatch2[] =
|
||||
{
|
||||
ANIMCMD_FRAME(32, 5),
|
||||
ANIMCMD_END
|
||||
};
|
||||
{
|
||||
ANIMCMD_FRAME(32, 5),
|
||||
ANIMCMD_END
|
||||
};
|
||||
|
||||
static const union AnimCmd sSpriteAnim_EggHatch3[] =
|
||||
{
|
||||
ANIMCMD_FRAME(48, 5),
|
||||
ANIMCMD_END
|
||||
};
|
||||
{
|
||||
ANIMCMD_FRAME(48, 5),
|
||||
ANIMCMD_END
|
||||
};
|
||||
|
||||
static const union AnimCmd *const sSpriteAnimTable_EggHatch[] =
|
||||
{
|
||||
sSpriteAnim_EggHatch0,
|
||||
sSpriteAnim_EggHatch1,
|
||||
sSpriteAnim_EggHatch2,
|
||||
sSpriteAnim_EggHatch3,
|
||||
};
|
||||
{
|
||||
sSpriteAnim_EggHatch0,
|
||||
sSpriteAnim_EggHatch1,
|
||||
sSpriteAnim_EggHatch2,
|
||||
sSpriteAnim_EggHatch3,
|
||||
};
|
||||
|
||||
static const struct SpriteSheet sEggHatch_Sheet =
|
||||
{
|
||||
.data = sEggHatchTiles,
|
||||
.size = 2048,
|
||||
.tag = 12345,
|
||||
};
|
||||
{
|
||||
.data = sEggHatchTiles,
|
||||
.size = 2048,
|
||||
.tag = 12345,
|
||||
};
|
||||
|
||||
static const struct SpriteSheet sEggShards_Sheet =
|
||||
{
|
||||
.data = sEggShardTiles,
|
||||
.size = 128,
|
||||
.tag = 23456,
|
||||
};
|
||||
{
|
||||
.data = sEggShardTiles,
|
||||
.size = 128,
|
||||
.tag = 23456,
|
||||
};
|
||||
|
||||
static const struct SpritePalette sEgg_SpritePalette =
|
||||
{
|
||||
.data = sEggPalette,
|
||||
.tag = 54321
|
||||
};
|
||||
{
|
||||
.data = sEggPalette,
|
||||
.tag = 54321
|
||||
};
|
||||
|
||||
static const struct SpriteTemplate sSpriteTemplate_EggHatch =
|
||||
{
|
||||
.tileTag = 12345,
|
||||
.paletteTag = 54321,
|
||||
.oam = &sOamData_EggHatch,
|
||||
.anims = sSpriteAnimTable_EggHatch,
|
||||
.images = NULL,
|
||||
.affineAnims = gDummySpriteAffineAnimTable,
|
||||
.callback = SpriteCallbackDummy
|
||||
};
|
||||
{
|
||||
.tileTag = 12345,
|
||||
.paletteTag = 54321,
|
||||
.oam = &sOamData_EggHatch,
|
||||
.anims = sSpriteAnimTable_EggHatch,
|
||||
.images = NULL,
|
||||
.affineAnims = gDummySpriteAffineAnimTable,
|
||||
.callback = SpriteCallbackDummy
|
||||
};
|
||||
|
||||
static const struct OamData sOamData_EggShard =
|
||||
{
|
||||
.y = 0,
|
||||
.affineMode = 0,
|
||||
.objMode = 0,
|
||||
.mosaic = 0,
|
||||
.bpp = 0,
|
||||
.shape = SPRITE_SHAPE(8x8),
|
||||
.x = 0,
|
||||
.matrixNum = 0,
|
||||
.size = SPRITE_SIZE(8x8),
|
||||
.tileNum = 0,
|
||||
.priority = 2,
|
||||
.paletteNum = 0,
|
||||
.affineParam = 0,
|
||||
};
|
||||
{
|
||||
.y = 0,
|
||||
.affineMode = 0,
|
||||
.objMode = 0,
|
||||
.mosaic = 0,
|
||||
.bpp = 0,
|
||||
.shape = SPRITE_SHAPE(8x8),
|
||||
.x = 0,
|
||||
.matrixNum = 0,
|
||||
.size = SPRITE_SIZE(8x8),
|
||||
.tileNum = 0,
|
||||
.priority = 2,
|
||||
.paletteNum = 0,
|
||||
.affineParam = 0,
|
||||
};
|
||||
|
||||
static const union AnimCmd sSpriteAnim_EggShard0[] =
|
||||
{
|
||||
ANIMCMD_FRAME(0, 5),
|
||||
ANIMCMD_END
|
||||
};
|
||||
{
|
||||
ANIMCMD_FRAME(0, 5),
|
||||
ANIMCMD_END
|
||||
};
|
||||
|
||||
static const union AnimCmd sSpriteAnim_EggShard1[] =
|
||||
{
|
||||
ANIMCMD_FRAME(1, 5),
|
||||
ANIMCMD_END
|
||||
};
|
||||
{
|
||||
ANIMCMD_FRAME(1, 5),
|
||||
ANIMCMD_END
|
||||
};
|
||||
|
||||
static const union AnimCmd sSpriteAnim_EggShard2[] =
|
||||
{
|
||||
ANIMCMD_FRAME(2, 5),
|
||||
ANIMCMD_END
|
||||
};
|
||||
{
|
||||
ANIMCMD_FRAME(2, 5),
|
||||
ANIMCMD_END
|
||||
};
|
||||
|
||||
static const union AnimCmd sSpriteAnim_EggShard3[] =
|
||||
{
|
||||
ANIMCMD_FRAME(3, 5),
|
||||
ANIMCMD_END
|
||||
};
|
||||
{
|
||||
ANIMCMD_FRAME(3, 5),
|
||||
ANIMCMD_END
|
||||
};
|
||||
|
||||
static const union AnimCmd *const sSpriteAnimTable_EggShard[] =
|
||||
{
|
||||
sSpriteAnim_EggShard0,
|
||||
sSpriteAnim_EggShard1,
|
||||
sSpriteAnim_EggShard2,
|
||||
sSpriteAnim_EggShard3,
|
||||
};
|
||||
{
|
||||
sSpriteAnim_EggShard0,
|
||||
sSpriteAnim_EggShard1,
|
||||
sSpriteAnim_EggShard2,
|
||||
sSpriteAnim_EggShard3,
|
||||
};
|
||||
|
||||
static const struct SpriteTemplate sSpriteTemplate_EggShard =
|
||||
{
|
||||
.tileTag = 23456,
|
||||
.paletteTag = 54321,
|
||||
.oam = &sOamData_EggShard,
|
||||
.anims = sSpriteAnimTable_EggShard,
|
||||
.images = NULL,
|
||||
.affineAnims = gDummySpriteAffineAnimTable,
|
||||
.callback = SpriteCB_EggShard
|
||||
};
|
||||
{
|
||||
.tileTag = 23456,
|
||||
.paletteTag = 54321,
|
||||
.oam = &sOamData_EggShard,
|
||||
.anims = sSpriteAnimTable_EggShard,
|
||||
.images = NULL,
|
||||
.affineAnims = gDummySpriteAffineAnimTable,
|
||||
.callback = SpriteCB_EggShard
|
||||
};
|
||||
|
||||
static const struct BgTemplate sBgTemplates_EggHatch[2] =
|
||||
{
|
||||
{
|
||||
.bg = 0,
|
||||
.charBaseIndex = 2,
|
||||
.mapBaseIndex = 24,
|
||||
.screenSize = 3,
|
||||
.paletteMode = 0,
|
||||
.priority = 0,
|
||||
.baseTile = 0
|
||||
},
|
||||
|
||||
{
|
||||
.bg = 1,
|
||||
.charBaseIndex = 0,
|
||||
.mapBaseIndex = 8,
|
||||
.screenSize = 1,
|
||||
.paletteMode = 0,
|
||||
.priority = 2,
|
||||
.baseTile = 0
|
||||
},
|
||||
};
|
||||
|
||||
static const struct WindowTemplate sWinTemplates_EggHatch[2] =
|
||||
{
|
||||
{
|
||||
.bg = 0,
|
||||
.tilemapLeft = 2,
|
||||
.tilemapTop = 15,
|
||||
.width = 26,
|
||||
.height = 4,
|
||||
.paletteNum = 0,
|
||||
.baseBlock = 64
|
||||
},
|
||||
DUMMY_WIN_TEMPLATE
|
||||
};
|
||||
|
||||
static const struct WindowTemplate sYesNoWinTemplate =
|
||||
{
|
||||
{
|
||||
.bg = 0,
|
||||
.tilemapLeft = 21,
|
||||
.tilemapTop = 9,
|
||||
.width = 6,
|
||||
.charBaseIndex = 2,
|
||||
.mapBaseIndex = 24,
|
||||
.screenSize = 3,
|
||||
.paletteMode = 0,
|
||||
.priority = 0,
|
||||
.baseTile = 0
|
||||
},
|
||||
|
||||
{
|
||||
.bg = 1,
|
||||
.charBaseIndex = 0,
|
||||
.mapBaseIndex = 8,
|
||||
.screenSize = 1,
|
||||
.paletteMode = 0,
|
||||
.priority = 2,
|
||||
.baseTile = 0
|
||||
},
|
||||
};
|
||||
|
||||
static const struct WindowTemplate sWinTemplates_EggHatch[2] =
|
||||
{
|
||||
{
|
||||
.bg = 0,
|
||||
.tilemapLeft = 2,
|
||||
.tilemapTop = 15,
|
||||
.width = 26,
|
||||
.height = 4,
|
||||
.paletteNum = 15,
|
||||
.baseBlock = 424
|
||||
};
|
||||
.paletteNum = 0,
|
||||
.baseBlock = 64
|
||||
},
|
||||
DUMMY_WIN_TEMPLATE
|
||||
};
|
||||
|
||||
static const struct WindowTemplate sYesNoWinTemplate =
|
||||
{
|
||||
.bg = 0,
|
||||
.tilemapLeft = 21,
|
||||
.tilemapTop = 9,
|
||||
.width = 6,
|
||||
.height = 4,
|
||||
.paletteNum = 15,
|
||||
.baseBlock = 424
|
||||
};
|
||||
|
||||
static const s16 sEggShardVelocities[][2] =
|
||||
{
|
||||
{Q_8_8(-1.5), Q_8_8(-3.75)},
|
||||
{Q_8_8(-5), Q_8_8(-3)},
|
||||
{Q_8_8(3.5), Q_8_8(-3)},
|
||||
{Q_8_8(-4), Q_8_8(-3.75)},
|
||||
{Q_8_8(2), Q_8_8(-1.5)},
|
||||
{Q_8_8(-0.5), Q_8_8(-6.75)},
|
||||
{Q_8_8(5), Q_8_8(-2.25)},
|
||||
{Q_8_8(-1.5), Q_8_8(-3.75)},
|
||||
{Q_8_8(4.5), Q_8_8(-1.5)},
|
||||
{Q_8_8(-1), Q_8_8(-6.75)},
|
||||
{Q_8_8(4), Q_8_8(-2.25)},
|
||||
{Q_8_8(-3.5), Q_8_8(-3.75)},
|
||||
{Q_8_8(1), Q_8_8(-1.5)},
|
||||
{Q_8_8(-3.515625), Q_8_8(-6.75)},
|
||||
{Q_8_8(4.5), Q_8_8(-2.25)},
|
||||
{Q_8_8(-0.5), Q_8_8(-7.5)},
|
||||
{Q_8_8(1), Q_8_8(-4.5)},
|
||||
{Q_8_8(-2.5), Q_8_8(-2.25)},
|
||||
{Q_8_8(2.5), Q_8_8(-7.5)},
|
||||
};
|
||||
{
|
||||
{Q_8_8(-1.5), Q_8_8(-3.75)},
|
||||
{Q_8_8(-5), Q_8_8(-3)},
|
||||
{Q_8_8(3.5), Q_8_8(-3)},
|
||||
{Q_8_8(-4), Q_8_8(-3.75)},
|
||||
{Q_8_8(2), Q_8_8(-1.5)},
|
||||
{Q_8_8(-0.5), Q_8_8(-6.75)},
|
||||
{Q_8_8(5), Q_8_8(-2.25)},
|
||||
{Q_8_8(-1.5), Q_8_8(-3.75)},
|
||||
{Q_8_8(4.5), Q_8_8(-1.5)},
|
||||
{Q_8_8(-1), Q_8_8(-6.75)},
|
||||
{Q_8_8(4), Q_8_8(-2.25)},
|
||||
{Q_8_8(-3.5), Q_8_8(-3.75)},
|
||||
{Q_8_8(1), Q_8_8(-1.5)},
|
||||
{Q_8_8(-3.515625), Q_8_8(-6.75)},
|
||||
{Q_8_8(4.5), Q_8_8(-2.25)},
|
||||
{Q_8_8(-0.5), Q_8_8(-7.5)},
|
||||
{Q_8_8(1), Q_8_8(-4.5)},
|
||||
{Q_8_8(-2.5), Q_8_8(-2.25)},
|
||||
{Q_8_8(2.5), Q_8_8(-7.5)},
|
||||
};
|
||||
|
||||
// code
|
||||
|
||||
@@ -2202,8 +2202,8 @@ static void CreateEggShardSprite(u8 x, u8 y, s16 data1, s16 data2, s16 data3, u8
|
||||
static void EggHatchPrintMessage(u8 windowId, u8* string, u8 x, u8 y, u8 speed)
|
||||
{
|
||||
FillWindowPixelBuffer(windowId, 0xFF);
|
||||
sEggHatchData->textColor.fgColor = 0;
|
||||
sEggHatchData->textColor.bgColor = 5;
|
||||
sEggHatchData->textColor.shadowColor = 6;
|
||||
AddTextPrinterParameterized4(windowId, 3, x, y, 1, 1, &sEggHatchData->textColor, speed, string);
|
||||
sEggHatchData->textColor[0] = 0;
|
||||
sEggHatchData->textColor[1] = 5;
|
||||
sEggHatchData->textColor[2] = 6;
|
||||
AddTextPrinterParameterized4(windowId, 3, x, y, 1, 1, sEggHatchData->textColor, speed, string);
|
||||
}
|
||||
|
||||
+4
-4
@@ -52,7 +52,7 @@ static const u8 gUnknown_84159B3[] = _("{HIGHLIGHT TRANSPARENT}
|
||||
static const u8 gUnknown_84159ED[] = _("{COLOR RED}{HIGHLIGHT TRANSPARENT}ゲームフリーク");
|
||||
static const u8 gUnknown_84159FB[] = _("{COLOR RED}{HIGHLIGHT TRANSPARENT}");
|
||||
|
||||
static const ALIGNED(4) struct TextColor gUnknown_8415A04 = {0, 2, 3};
|
||||
static const ALIGNED(4) u8 gUnknown_8415A04[3] = {0, 2, 3};
|
||||
|
||||
static const struct BgTemplate gUnknown_8415A08[] = {
|
||||
{
|
||||
@@ -276,10 +276,10 @@ static void DiplomaPrintText(void)
|
||||
FillWindowPixelBuffer(0, 0);
|
||||
DynamicPlaceholderTextUtil_ExpandPlaceholders(arr, gUnknown_841B60E);
|
||||
width = GetStringWidth(2, arr, -1);
|
||||
AddTextPrinterParameterized3(0, 2, 0x78 - (width / 2), 4, &gUnknown_8415A04, -1, arr);
|
||||
AddTextPrinterParameterized3(0, 2, 0x78 - (width / 2), 4, gUnknown_8415A04, -1, arr);
|
||||
DynamicPlaceholderTextUtil_ExpandPlaceholders(arr, gUnknown_841B619);
|
||||
width = GetStringWidth(2, arr, -1);
|
||||
AddTextPrinterParameterized3(0, 0x2, 0x78 - (width / 2), 0x1E, &gUnknown_8415A04, -1, arr);
|
||||
AddTextPrinterParameterized3(0, 0x2, 0x78, 0x69, &gUnknown_8415A04, 0, gUnknown_841B684);
|
||||
AddTextPrinterParameterized3(0, 0x2, 0x78 - (width / 2), 0x1E, gUnknown_8415A04, -1, arr);
|
||||
AddTextPrinterParameterized3(0, 0x2, 0x78, 0x69, gUnknown_8415A04, 0, gUnknown_841B684);
|
||||
PutWindowTilemap(0);
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ int EReader_Send(size_t r6, const void * r5)
|
||||
{
|
||||
GetKeyInput();
|
||||
if (TEST_BUTTON(sJoyNew, B_BUTTON))
|
||||
gUnknown_3003F84 = 2;
|
||||
gShouldAdvanceLinkState = 2;
|
||||
|
||||
sSendRecvStatus = EReaderHandleTransfer(1, r6, r5, NULL);
|
||||
if ((sSendRecvStatus & 0x13) == 0x10)
|
||||
@@ -71,7 +71,7 @@ int EReader_Send(size_t r6, const void * r5)
|
||||
}
|
||||
else
|
||||
{
|
||||
gUnknown_3003F84 = 0;
|
||||
gShouldAdvanceLinkState = 0;
|
||||
VBlankIntrWait();
|
||||
}
|
||||
}
|
||||
@@ -90,7 +90,7 @@ int EReader_Recv(void * r5)
|
||||
{
|
||||
GetKeyInput();
|
||||
if (TEST_BUTTON(sJoyNew, B_BUTTON))
|
||||
gUnknown_3003F84 = 2;
|
||||
gShouldAdvanceLinkState = 2;
|
||||
|
||||
sSendRecvStatus = EReaderHandleTransfer(0, 0, NULL, r5);
|
||||
if ((sSendRecvStatus & 0x13) == 0x10)
|
||||
@@ -110,7 +110,7 @@ int EReader_Recv(void * r5)
|
||||
}
|
||||
else
|
||||
{
|
||||
gUnknown_3003F84 = 0;
|
||||
gShouldAdvanceLinkState = 0;
|
||||
VBlankIntrWait();
|
||||
}
|
||||
}
|
||||
@@ -150,7 +150,7 @@ static void OpenSerial32(void)
|
||||
REG_RCNT = 0;
|
||||
REG_SIOCNT = SIO_INTR_ENABLE | SIO_32BIT_MODE;
|
||||
REG_SIOCNT |= SIO_MULTI_SD;
|
||||
gUnknown_3003F84 = 0;
|
||||
gShouldAdvanceLinkState = 0;
|
||||
sCounter1 = 0;
|
||||
sCounter2 = 0;
|
||||
}
|
||||
@@ -167,7 +167,7 @@ u16 EReaderHandleTransfer(u8 mode, size_t size, const void * data, void * recvBu
|
||||
case 1:
|
||||
if (DetermineSendRecvState(mode))
|
||||
EnableSio();
|
||||
if (gUnknown_3003F84 == 2)
|
||||
if (gShouldAdvanceLinkState == 2)
|
||||
{
|
||||
sSendRecvMgr.field_04 = 2;
|
||||
sSendRecvMgr.state = 6;
|
||||
@@ -179,7 +179,7 @@ u16 EReaderHandleTransfer(u8 mode, size_t size, const void * data, void * recvBu
|
||||
sSendRecvMgr.state = 3;
|
||||
// fallthrough
|
||||
case 3:
|
||||
if (gUnknown_3003F84 == 2)
|
||||
if (gShouldAdvanceLinkState == 2)
|
||||
{
|
||||
sSendRecvMgr.field_04 = 2;
|
||||
sSendRecvMgr.state = 6;
|
||||
|
||||
+10
-10
@@ -152,9 +152,9 @@ static const u16 sOakSpritePalette[] = INCBIN_U16("data/fame_checker/pal_845f580
|
||||
static const u16 gUnknown_845F5A0[] = INCBIN_U16("data/fame_checker/pal_845f5a0.gbapal"); // unused?
|
||||
static const u16 sSilhouettePalette[] = INCBIN_U16("data/fame_checker/pal_845f5c0.gbapal");
|
||||
|
||||
static const struct TextColor sTextColor_White = {TEXT_COLOR_TRANSPARENT, TEXT_COLOR_WHITE, TEXT_COLOR_DARK_GREY};
|
||||
static const struct TextColor sTextColor_DkGrey = {TEXT_COLOR_TRANSPARENT, TEXT_COLOR_DARK_GREY, 0x03};
|
||||
static const struct TextColor sTextColor_Green = {TEXT_COLOR_TRANSPARENT, 0x06, 0x07};
|
||||
static const u8 sTextColor_White[3] = {0, 1, 2};
|
||||
static const u8 sTextColor_DkGrey[3] = {0, 2, 3};
|
||||
static const u8 sTextColor_Green[3] = {0, 6, 7};
|
||||
|
||||
static const u16 sTrainerIdxs[] = {
|
||||
FC_NONTRAINER_START + 0, // OAK
|
||||
@@ -900,7 +900,7 @@ static void PrintUIHelp(u8 state)
|
||||
}
|
||||
width = GetStringWidth(0, src, 0);
|
||||
FillWindowPixelRect(FCWINDOWID_UIHELP, 0x00, 0, 0, 0xc0, 0x10);
|
||||
AddTextPrinterParameterized4(FCWINDOWID_UIHELP, 0, 188 - width, 0, 0, 2, &sTextColor_White, -1, src);
|
||||
AddTextPrinterParameterized4(FCWINDOWID_UIHELP, 0, 188 - width, 0, 0, 2, sTextColor_White, -1, src);
|
||||
FC_PutWindowTilemapAndCopyWindowToVramMode3(FCWINDOWID_UIHELP);
|
||||
}
|
||||
|
||||
@@ -1213,10 +1213,10 @@ static void UpdateIconDescriptionBox(u8 whichText)
|
||||
gIconDescriptionBoxIsOpen = 1;
|
||||
FillWindowPixelRect(FCWINDOWID_ICONDESC, 0x00, 0, 0, 0x58, 0x20);
|
||||
width = (0x54 - GetStringWidth(0, sFlavorTextOriginLocationTexts[idx], 0)) / 2;
|
||||
AddTextPrinterParameterized4(FCWINDOWID_ICONDESC, 0, width, 0, 0, 2, &sTextColor_DkGrey, -1, sFlavorTextOriginLocationTexts[idx]);
|
||||
AddTextPrinterParameterized4(FCWINDOWID_ICONDESC, 0, width, 0, 0, 2, sTextColor_DkGrey, -1, sFlavorTextOriginLocationTexts[idx]);
|
||||
StringExpandPlaceholders(gStringVar1, sFlavorTextOriginObjectNameTexts[idx]);
|
||||
width = (0x54 - GetStringWidth(0, gStringVar1, 0)) / 2;
|
||||
AddTextPrinterParameterized4(FCWINDOWID_ICONDESC, 0, width, 10, 0, 2, &sTextColor_DkGrey, -1, gStringVar1);
|
||||
AddTextPrinterParameterized4(FCWINDOWID_ICONDESC, 0, width, 10, 0, 2, sTextColor_DkGrey, -1, gStringVar1);
|
||||
FC_PutWindowTilemapAndCopyWindowToVramMode3(FCWINDOWID_ICONDESC);
|
||||
}
|
||||
|
||||
@@ -1341,14 +1341,14 @@ static void FC_DoMoveCursor(s32 itemIndex, bool8 onInit)
|
||||
u16 who;
|
||||
ListMenuGetScrollAndRow(sFameCheckerData->listMenuTaskId, &listY, &cursorY);
|
||||
who = listY + cursorY;
|
||||
AddTextPrinterParameterized4(FCWINDOWID_LIST, 2, 8, 14 * cursorY + 4, 0, 0, &sTextColor_Green, 0, sListMenuItems[itemIndex].label);
|
||||
AddTextPrinterParameterized4(FCWINDOWID_LIST, 2, 8, 14 * cursorY + 4, 0, 0, sTextColor_Green, 0, sListMenuItems[itemIndex].label);
|
||||
if (!onInit)
|
||||
{
|
||||
if (listY < sFameCheckerData->listMenuTopIdx2)
|
||||
sFameCheckerData->listMenuDrawnSelIdx++;
|
||||
else if (listY > sFameCheckerData->listMenuTopIdx2 && who != sFameCheckerData->numUnlockedPersons - 1)
|
||||
sFameCheckerData->listMenuDrawnSelIdx--;
|
||||
AddTextPrinterParameterized4(FCWINDOWID_LIST, 2, 8, 14 * sFameCheckerData->listMenuDrawnSelIdx + 4, 0, 0, &sTextColor_DkGrey, 0, sListMenuItems[sFameCheckerData->listMenuCurIdx].label);
|
||||
AddTextPrinterParameterized4(FCWINDOWID_LIST, 2, 8, 14 * sFameCheckerData->listMenuDrawnSelIdx + 4, 0, 0, sTextColor_DkGrey, 0, sListMenuItems[sFameCheckerData->listMenuCurIdx].label);
|
||||
|
||||
}
|
||||
sFameCheckerData->listMenuCurIdx = itemIndex;
|
||||
@@ -1546,7 +1546,7 @@ static void PlaceListMenuCursor(bool8 isActive)
|
||||
{
|
||||
u16 cursorY = ListMenuGetYCoordForPrintingArrowCursor(sFameCheckerData->listMenuTaskId);
|
||||
if (isActive == TRUE)
|
||||
AddTextPrinterParameterized4(FCWINDOWID_LIST, 2, 0, cursorY, 0, 0, &sTextColor_DkGrey, 0, gFameCheckerText_ListMenuCursor);
|
||||
AddTextPrinterParameterized4(FCWINDOWID_LIST, 2, 0, cursorY, 0, 0, sTextColor_DkGrey, 0, gFameCheckerText_ListMenuCursor);
|
||||
else
|
||||
AddTextPrinterParameterized4(FCWINDOWID_LIST, 2, 0, cursorY, 0, 0, &sTextColor_White, 0, gFameCheckerText_ListMenuCursor);
|
||||
AddTextPrinterParameterized4(FCWINDOWID_LIST, 2, 0, cursorY, 0, 0, sTextColor_White, 0, gFameCheckerText_ListMenuCursor);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,965 @@
|
||||
#include "global.h"
|
||||
#include "palette.h"
|
||||
#include "field_fadetransition.h"
|
||||
#include "overworld.h"
|
||||
#include "fldeff.h"
|
||||
#include "field_weather.h"
|
||||
#include "map_preview_screen.h"
|
||||
#include "field_player_avatar.h"
|
||||
#include "task.h"
|
||||
#include "script.h"
|
||||
#include "cable_club.h"
|
||||
#include "fieldmap.h"
|
||||
#include "metatile_behavior.h"
|
||||
#include "quest_log.h"
|
||||
#include "link.h"
|
||||
#include "map_obj_80688E4.h"
|
||||
#include "sound.h"
|
||||
#include "field_door.h"
|
||||
#include "field_effect.h"
|
||||
#include "field_screen_effect.h"
|
||||
#include "field_map_obj.h"
|
||||
#include "field_map_obj_helpers.h"
|
||||
#include "field_specials.h"
|
||||
#include "map_obj_lock.h"
|
||||
#include "start_menu.h"
|
||||
#include "constants/songs.h"
|
||||
|
||||
static void sub_807DF4C(u8 a0);
|
||||
static void sub_807DFBC(u8 taskId);
|
||||
static void task_map_chg_seq_0807E20C(u8 taskId);
|
||||
static void task_map_chg_seq_0807E2CC(u8 taskId);
|
||||
static void sub_807E31C(u8 taskId);
|
||||
static void sub_807E718(u8 taskId);
|
||||
static void sub_807E784(u8 taskId);
|
||||
static void sub_807E80C(u8 taskId);
|
||||
static void sub_807E980(u8 taskId);
|
||||
static void sub_807EB64(u16, s16*, s16*);
|
||||
static void sub_807EBBC(u8 a0, s16 *a1, s16 *a2);
|
||||
static void sub_807EAC4(s16, s16, s16*, s16*, s16*);
|
||||
static void sub_807EC34(u8 taskId);
|
||||
static void sub_807ECBC(s16 *, s16 *, s16 *, s16 *, s16 *);
|
||||
static bool8 sub_807EDA0(s16 *, s16 *, s16 *, s16 *, s16 *);
|
||||
|
||||
void palette_bg_faded_fill_white(void)
|
||||
{
|
||||
CpuFastFill16(RGB_WHITE, gPlttBufferFaded, 0x400);
|
||||
}
|
||||
|
||||
void palette_bg_faded_fill_black(void)
|
||||
{
|
||||
CpuFastFill16(RGB_BLACK, gPlttBufferFaded, 0x400);
|
||||
}
|
||||
|
||||
void pal_fill_for_maplights(void)
|
||||
{
|
||||
switch (sub_80C9DCC(get_map_light_from_warp0(), GetCurrentMapType()))
|
||||
{
|
||||
case 0:
|
||||
palette_bg_faded_fill_black();
|
||||
fade_screen(0, 0);
|
||||
palette_bg_faded_fill_black();
|
||||
break;
|
||||
case 1:
|
||||
palette_bg_faded_fill_white();
|
||||
fade_screen(2, 0);
|
||||
palette_bg_faded_fill_white();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void sub_807DBAC(void)
|
||||
{
|
||||
switch (sub_80C9DCC(get_map_light_from_warp0(), GetCurrentMapType()))
|
||||
{
|
||||
case 0:
|
||||
palette_bg_faded_fill_black();
|
||||
fade_screen(0, 3);
|
||||
palette_bg_faded_fill_black();
|
||||
break;
|
||||
case 1:
|
||||
palette_bg_faded_fill_white();
|
||||
fade_screen(2, 3);
|
||||
palette_bg_faded_fill_white();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void sub_807DC00(void)
|
||||
{
|
||||
palette_bg_faded_fill_black();
|
||||
fade_screen(0, 0);
|
||||
palette_bg_faded_fill_black();
|
||||
}
|
||||
|
||||
void sub_807DC18(void)
|
||||
{
|
||||
const struct MapHeader *header = warp1_get_mapheader();
|
||||
if (header->regionMapSectionId != gMapHeader.regionMapSectionId && sub_80F8110(header->regionMapSectionId, FALSE))
|
||||
fade_screen(1, 0);
|
||||
else
|
||||
{
|
||||
switch (sub_80C9D7C(GetCurrentMapType(), header->mapType))
|
||||
{
|
||||
case 0:
|
||||
fade_screen(1, 0);
|
||||
break;
|
||||
case 1:
|
||||
fade_screen(3, 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void sub_807DC70(void)
|
||||
{
|
||||
switch (sub_80C9D7C(GetCurrentMapType(), warp1_get_mapheader()->mapType))
|
||||
{
|
||||
case 0:
|
||||
fade_screen(1, 3);
|
||||
break;
|
||||
case 1:
|
||||
fade_screen(3, 3);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void sub_807DCB0(bool8 arg)
|
||||
{
|
||||
sub_805CB04(!arg);
|
||||
}
|
||||
|
||||
static void task0A_nop_for_a_while(u8 taskId)
|
||||
{
|
||||
if (sub_807E418() == TRUE)
|
||||
DestroyTask(taskId);
|
||||
}
|
||||
|
||||
void sub_807DCE4(void)
|
||||
{
|
||||
ScriptContext2_Enable();
|
||||
Overworld_PlaySpecialMapMusic();
|
||||
sub_807DC00();
|
||||
CreateTask(task0A_nop_for_a_while, 10);
|
||||
}
|
||||
|
||||
static void task0A_asap_script_env_2_enable_and_set_ctx_running(u8 taskId)
|
||||
{
|
||||
if (sub_807E418() == TRUE)
|
||||
{
|
||||
DestroyTask(taskId);
|
||||
EnableBothScriptContexts();
|
||||
}
|
||||
}
|
||||
|
||||
void FieldCallback_ReturnToEventScript2(void)
|
||||
{
|
||||
ScriptContext2_Enable();
|
||||
Overworld_PlaySpecialMapMusic();
|
||||
sub_807DC00();
|
||||
CreateTask(task0A_asap_script_env_2_enable_and_set_ctx_running, 10);
|
||||
}
|
||||
|
||||
void sub_807DD44(void)
|
||||
{
|
||||
ScriptContext2_Enable();
|
||||
sub_807DC00();
|
||||
CreateTask(task0A_asap_script_env_2_enable_and_set_ctx_running, 10);
|
||||
}
|
||||
|
||||
static void task_mpl_807DD60(u8 taskId)
|
||||
{
|
||||
struct Task *task = &gTasks[taskId];
|
||||
switch (task->data[0])
|
||||
{
|
||||
case 0:
|
||||
task->data[1] = sub_8081150();
|
||||
task->data[0]++;
|
||||
break;
|
||||
case 1:
|
||||
if (gTasks[task->data[1]].isActive != TRUE)
|
||||
{
|
||||
pal_fill_for_maplights();
|
||||
task->data[0]++;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
if (sub_807E418() == TRUE)
|
||||
{
|
||||
ScriptContext2_Disable();
|
||||
DestroyTask(taskId);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void sub_807DDD0(void)
|
||||
{
|
||||
ScriptContext2_Enable();
|
||||
Overworld_PlaySpecialMapMusic();
|
||||
palette_bg_faded_fill_black();
|
||||
CreateTask(task_mpl_807DD60, 10);
|
||||
}
|
||||
|
||||
static void sub_807DDF0(u8 taskId)
|
||||
{
|
||||
struct Task *task = &gTasks[taskId];
|
||||
switch (task->data[0])
|
||||
{
|
||||
case 0:
|
||||
sub_800AB9C();
|
||||
task->data[0]++;
|
||||
break;
|
||||
case 1:
|
||||
if (IsLinkTaskFinished())
|
||||
{
|
||||
pal_fill_for_maplights();
|
||||
task->data[0]++;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
if (sub_807E418() == TRUE)
|
||||
{
|
||||
sub_8009FE8();
|
||||
ScriptContext2_Disable();
|
||||
DestroyTask(taskId);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void sub_807DE58(void)
|
||||
{
|
||||
ScriptContext2_Enable();
|
||||
Overworld_PlaySpecialMapMusic();
|
||||
palette_bg_faded_fill_black();
|
||||
CreateTask(sub_807DDF0, 10);
|
||||
}
|
||||
|
||||
static void sub_807DE78(bool8 a0)
|
||||
{
|
||||
s16 x, y;
|
||||
u32 behavior;
|
||||
TaskFunc func;
|
||||
|
||||
PlayerGetDestCoords(&x, &y);
|
||||
behavior = MapGridGetMetatileBehaviorAt(x, y);
|
||||
if (MetatileBehavior_IsWarpDoor_2(behavior) == TRUE)
|
||||
{
|
||||
func = sub_807DFBC;
|
||||
switch (sub_80C9DCC(get_map_light_from_warp0(), GetCurrentMapType()))
|
||||
{
|
||||
case 0:
|
||||
palette_bg_faded_fill_black();
|
||||
break;
|
||||
case 1:
|
||||
palette_bg_faded_fill_white();
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
sub_807DF4C(a0);
|
||||
if (MetatileBehavior_IsCaveDoor(behavior) == TRUE)
|
||||
func = task_map_chg_seq_0807E20C;
|
||||
else if (MetatileBehavior_IsUnknownWarp6C_to_6F(behavior) == TRUE)
|
||||
{
|
||||
u8 tmp = gUnknown_2031DE0;
|
||||
func = task_map_chg_seq_0807E2CC;
|
||||
if (!tmp)
|
||||
func = sub_807EC34;
|
||||
}
|
||||
else
|
||||
func = task_map_chg_seq_0807E2CC;
|
||||
}
|
||||
gUnknown_2031DE0 = FALSE;
|
||||
CreateTask(func, 10);
|
||||
}
|
||||
|
||||
static void sub_807DF4C(bool8 a0)
|
||||
{
|
||||
if (!a0)
|
||||
pal_fill_for_maplights();
|
||||
else
|
||||
sub_807DC00();
|
||||
}
|
||||
|
||||
void sub_807DF64(void)
|
||||
{
|
||||
Overworld_PlaySpecialMapMusic();
|
||||
sub_8111CF0();
|
||||
sub_807DE78(FALSE);
|
||||
ScriptContext2_Enable();
|
||||
}
|
||||
|
||||
void sub_807DF7C(void)
|
||||
{
|
||||
Overworld_PlaySpecialMapMusic();
|
||||
sub_8111CF0();
|
||||
sub_807DE78(TRUE);
|
||||
ScriptContext2_Enable();
|
||||
}
|
||||
|
||||
static void sub_807DF94(void)
|
||||
{
|
||||
Overworld_PlaySpecialMapMusic();
|
||||
pal_fill_for_maplights();
|
||||
sub_8111CF0();
|
||||
PlaySE(SE_RU_GASHIN);
|
||||
CreateTask(sub_807E31C, 10);
|
||||
ScriptContext2_Enable();
|
||||
}
|
||||
|
||||
static void sub_807DFBC(u8 taskId)
|
||||
{
|
||||
struct Task * task = &gTasks[taskId];
|
||||
s16 *x = &task->data[2];
|
||||
s16 *y = &task->data[3];
|
||||
|
||||
if (task->data[0] == 0)
|
||||
task->data[0] = 5;
|
||||
|
||||
switch (task->data[0])
|
||||
{
|
||||
case 0: // Never reached
|
||||
sub_807DCB0(0);
|
||||
player_bitmagic();
|
||||
PlayerGetDestCoords(x, y);
|
||||
FieldSetDoorOpened(*x, *y);
|
||||
task->data[0] = 1;
|
||||
break;
|
||||
case 5:
|
||||
sub_807DCB0(0);
|
||||
player_bitmagic();
|
||||
sub_807F114();
|
||||
sub_807DBAC();
|
||||
task->data[0] = 6;
|
||||
break;
|
||||
case 6:
|
||||
task->data[15]++;
|
||||
if (task->data[15] == 25)
|
||||
{
|
||||
PlayerGetDestCoords(x, y);
|
||||
PlaySE(GetDoorSoundEffect(*x, *y));
|
||||
FieldAnimateDoorOpen(*x, *y);
|
||||
task->data[0] = 7;
|
||||
}
|
||||
break;
|
||||
case 7:
|
||||
if (!FieldIsDoorAnimationRunning())
|
||||
{
|
||||
PlayerGetDestCoords(&task->data[12], &task->data[13]);
|
||||
sub_807DCB0(TRUE);
|
||||
FieldObjectSetHeldMovement(&gMapObjects[GetFieldObjectIdByLocalIdAndMap(0xFF, 0, 0)], 16);
|
||||
task->data[0] = 8;
|
||||
}
|
||||
break;
|
||||
case 8:
|
||||
task->data[14]++;
|
||||
if (task->data[14] == 14)
|
||||
{
|
||||
FieldAnimateDoorClose(task->data[12], task->data[13]);
|
||||
task->data[0] = 9;
|
||||
}
|
||||
break;
|
||||
case 9:
|
||||
if (sub_807E418() && walkrun_is_standing_still() && !FieldIsDoorAnimationRunning() && !FuncIsActiveTask(sub_807F204))
|
||||
{
|
||||
FieldObjectClearHeldMovementIfFinished(&gMapObjects[GetFieldObjectIdByLocalIdAndMap(0xFF, 0, 0)]);
|
||||
task->data[0] = 4;
|
||||
}
|
||||
break;
|
||||
// Legacy RS
|
||||
case 1:
|
||||
if (sub_807E418())
|
||||
{
|
||||
sub_807DCB0(TRUE);
|
||||
FieldObjectSetHeldMovement(&gMapObjects[GetFieldObjectIdByLocalIdAndMap(0xFF, 0, 0)], 16);
|
||||
task->data[0] = 2;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
if (walkrun_is_standing_still())
|
||||
{
|
||||
task->data[1] = FieldAnimateDoorClose(*x, *y);
|
||||
FieldObjectClearHeldMovementIfFinished(&gMapObjects[GetFieldObjectIdByLocalIdAndMap(0xFF, 0, 0)]);
|
||||
task->data[0] = 3;
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
if (task->data[1] < 0 || gTasks[task->data[1]].isActive != TRUE)
|
||||
task->data[0] = 4;
|
||||
break;
|
||||
case 4:
|
||||
UnfreezeMapObjects();
|
||||
ScriptContext2_Disable();
|
||||
DestroyTask(taskId);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void task_map_chg_seq_0807E20C(u8 taskId)
|
||||
{
|
||||
struct Task * task = &gTasks[taskId];
|
||||
s16 *x = &task->data[2];
|
||||
s16 *y = &task->data[3];
|
||||
|
||||
switch (task->data[0])
|
||||
{
|
||||
case 0:
|
||||
sub_807DCB0(0);
|
||||
player_bitmagic();
|
||||
PlayerGetDestCoords(x, y);
|
||||
task->data[0] = 1;
|
||||
break;
|
||||
case 1:
|
||||
if (sub_807E418())
|
||||
{
|
||||
sub_807DCB0(TRUE);
|
||||
FieldObjectSetHeldMovement(&gMapObjects[GetFieldObjectIdByLocalIdAndMap(0xFF, 0, 0)], sub_8063F84(GetPlayerFacingDirection()));
|
||||
task->data[0] = 2;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
if (walkrun_is_standing_still())
|
||||
{
|
||||
task->data[0] = 3;
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
UnfreezeMapObjects();
|
||||
ScriptContext2_Disable();
|
||||
DestroyTask(taskId);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void task_map_chg_seq_0807E2CC(u8 taskId)
|
||||
{
|
||||
switch (gTasks[taskId].data[0])
|
||||
{
|
||||
case 0:
|
||||
player_bitmagic();
|
||||
ScriptContext2_Enable();
|
||||
gTasks[taskId].data[0]++;
|
||||
break;
|
||||
case 1:
|
||||
if (sub_807E418())
|
||||
{
|
||||
UnfreezeMapObjects();
|
||||
ScriptContext2_Disable();
|
||||
DestroyTask(taskId);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void sub_807E31C(u8 taskId)
|
||||
{
|
||||
switch (gTasks[taskId].data[0])
|
||||
{
|
||||
case 0:
|
||||
player_bitmagic();
|
||||
ScriptContext2_Enable();
|
||||
sub_805DC04();
|
||||
gTasks[taskId].data[0]++;
|
||||
break;
|
||||
case 1:
|
||||
if (sub_807E418() && sub_805DC24() != TRUE)
|
||||
{
|
||||
UnfreezeMapObjects();
|
||||
ScriptContext2_Disable();
|
||||
DestroyTask(taskId);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void sub_807E378(u8 taskId)
|
||||
{
|
||||
if (sub_807E418() == TRUE)
|
||||
{
|
||||
DestroyTask(taskId);
|
||||
CreateTask(sub_806F1F0, 80);
|
||||
}
|
||||
}
|
||||
|
||||
void sub_807E3A0(void)
|
||||
{
|
||||
sub_807DC00();
|
||||
CreateTask(sub_807E378, 80);
|
||||
ScriptContext2_Enable();
|
||||
}
|
||||
|
||||
bool32 sub_807E3BC(void)
|
||||
{
|
||||
sub_806F1D4();
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void task_mpl_807E3C8(u8 taskId)
|
||||
{
|
||||
if (sub_807E418() == TRUE)
|
||||
{
|
||||
ScriptContext2_Disable();
|
||||
DestroyTask(taskId);
|
||||
sub_80696C0();
|
||||
}
|
||||
}
|
||||
|
||||
void sub_807E3EC(void)
|
||||
{
|
||||
ScriptContext2_Enable();
|
||||
Overworld_PlaySpecialMapMusic();
|
||||
sub_807DC00();
|
||||
CreateTask(task_mpl_807E3C8, 10);
|
||||
}
|
||||
|
||||
static bool32 sub_807E40C(void)
|
||||
{
|
||||
return gPaletteFade.active;
|
||||
}
|
||||
|
||||
bool32 sub_807E418(void)
|
||||
{
|
||||
if (sub_807AA70() == TRUE && sub_80F83B0())
|
||||
return TRUE;
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void DoWarp(void)
|
||||
{
|
||||
ScriptContext2_Enable();
|
||||
sub_8055F88();
|
||||
sub_807DC18();
|
||||
PlayRainStoppingSoundEffect();
|
||||
PlaySE(SE_KAIDAN);
|
||||
gFieldCallback = sub_807DF64;
|
||||
CreateTask(sub_807E718, 10);
|
||||
}
|
||||
|
||||
void DoDiveWarp(void)
|
||||
{
|
||||
ScriptContext2_Enable();
|
||||
sub_8055F88();
|
||||
sub_807DC18();
|
||||
PlayRainStoppingSoundEffect();
|
||||
gFieldCallback = sub_807DF64;
|
||||
CreateTask(sub_807E718, 10);
|
||||
}
|
||||
|
||||
void sub_807E4A0(u16 a, u16 b)
|
||||
{
|
||||
u8 taskId = CreateTask(sub_807E980, 10);
|
||||
gTasks[taskId].data[1] = a;
|
||||
gTasks[taskId].data[15] = b;
|
||||
sub_807E980(taskId);
|
||||
}
|
||||
|
||||
void DoDoorWarp(void)
|
||||
{
|
||||
ScriptContext2_Enable();
|
||||
gFieldCallback = sub_807DF64;
|
||||
CreateTask(sub_807E80C, 10);
|
||||
}
|
||||
|
||||
void sub_807E500(void)
|
||||
{
|
||||
ScriptContext2_Enable();
|
||||
CreateTask(sub_807E718, 10);
|
||||
gFieldCallback = sub_807DF94;
|
||||
}
|
||||
|
||||
void sub_807E524(void)
|
||||
{
|
||||
ScriptContext2_Enable();
|
||||
gFieldCallback = sub_807DF64;
|
||||
CreateTask(sub_807E784, 10);
|
||||
}
|
||||
|
||||
void DoFallWarp(void)
|
||||
{
|
||||
DoDiveWarp();
|
||||
gFieldCallback = sub_8084454;
|
||||
}
|
||||
|
||||
void sub_807E560(u8 a0)
|
||||
{
|
||||
ScriptContext2_Enable();
|
||||
sub_8084784(a0, 10);
|
||||
}
|
||||
|
||||
void sub_807E57C(void)
|
||||
{
|
||||
ScriptContext2_Enable();
|
||||
sub_8084F2C(10);
|
||||
}
|
||||
|
||||
void sub_807E58C(void)
|
||||
{
|
||||
ScriptContext2_Enable();
|
||||
sub_80853CC(10);
|
||||
}
|
||||
|
||||
void sub_807E59C(void)
|
||||
{
|
||||
ScriptContext2_Enable();
|
||||
sub_8055F88();
|
||||
CreateTask(sub_807E784, 10);
|
||||
gFieldCallback = sub_807DF94;
|
||||
}
|
||||
|
||||
void sub_807E5C4(void)
|
||||
{
|
||||
ScriptContext2_Enable();
|
||||
sub_807DC18();
|
||||
CreateTask(sub_807E718, 10);
|
||||
gFieldCallback = nullsub_60;
|
||||
}
|
||||
|
||||
static void sub_807E5EC(u8 taskId)
|
||||
{
|
||||
struct Task * task = &gTasks[taskId];
|
||||
switch (task->data[0])
|
||||
{
|
||||
case 0:
|
||||
ScriptContext2_Enable();
|
||||
task->data[0]++;
|
||||
break;
|
||||
case 1:
|
||||
if (!sub_807E40C() && sub_8055FC4())
|
||||
task->data[0]++;
|
||||
break;
|
||||
case 2:
|
||||
WarpIntoMap();
|
||||
SetMainCallback2(sub_8056788);
|
||||
DestroyTask(taskId);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void sub_807E654(void)
|
||||
{
|
||||
ScriptContext2_Enable();
|
||||
sub_8055F88();
|
||||
sub_807DC18();
|
||||
PlaySE(SE_KAIDAN);
|
||||
CreateTask(sub_807E5EC, 10);
|
||||
}
|
||||
|
||||
static void sub_807E678(u8 taskId)
|
||||
{
|
||||
s16 * data = gTasks[taskId].data;
|
||||
switch (data[0])
|
||||
{
|
||||
case 0:
|
||||
ClearLinkCallback_2();
|
||||
fade_screen(1, 0);
|
||||
sub_8055F88();
|
||||
PlaySE(SE_KAIDAN);
|
||||
data[0]++;
|
||||
break;
|
||||
case 1:
|
||||
if (!sub_807E40C() && sub_8055FC4())
|
||||
{
|
||||
sub_800AAC0();
|
||||
data[0]++;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
if (gReceivedRemoteLinkPlayers == 0)
|
||||
{
|
||||
WarpIntoMap();
|
||||
SetMainCallback2(CB2_LoadMap);
|
||||
DestroyTask(taskId);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void sub_807E704(void)
|
||||
{
|
||||
CreateTask(sub_807E678, 10);
|
||||
}
|
||||
|
||||
static void sub_807E718(u8 taskId)
|
||||
{
|
||||
struct Task *task = &gTasks[taskId];
|
||||
switch (task->data[0])
|
||||
{
|
||||
case 0:
|
||||
player_bitmagic();
|
||||
ScriptContext2_Enable();
|
||||
task->data[0]++;
|
||||
break;
|
||||
case 1:
|
||||
if (!sub_807E40C() && sub_8055FC4())
|
||||
task->data[0]++;
|
||||
break;
|
||||
case 2:
|
||||
WarpIntoMap();
|
||||
SetMainCallback2(CB2_LoadMap);
|
||||
DestroyTask(taskId);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void sub_807E784(u8 taskId)
|
||||
{
|
||||
struct Task *task = &gTasks[taskId];
|
||||
switch (task->data[0])
|
||||
{
|
||||
case 0:
|
||||
player_bitmagic();
|
||||
ScriptContext2_Enable();
|
||||
PlaySE(SE_FU_ZUZUZU);
|
||||
sub_805DAB0();
|
||||
task->data[0]++;
|
||||
break;
|
||||
case 1:
|
||||
if (!sub_805DAD0())
|
||||
{
|
||||
sub_807DC18();
|
||||
task->data[0]++;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
if (!sub_807E40C() && sub_8055FC4())
|
||||
task->data[0]++;
|
||||
break;
|
||||
case 3:
|
||||
WarpIntoMap();
|
||||
SetMainCallback2(CB2_LoadMap);
|
||||
DestroyTask(taskId);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void sub_807E80C(u8 taskId)
|
||||
{
|
||||
struct Task *task = &gTasks[taskId];
|
||||
s16 * xp = &task->data[2];
|
||||
s16 * yp = &task->data[3];
|
||||
switch (task->data[0])
|
||||
{
|
||||
case 0:
|
||||
player_bitmagic();
|
||||
PlayerGetDestCoords(xp, yp);
|
||||
PlaySE(GetDoorSoundEffect(*xp, *yp - 1));
|
||||
task->data[1] = FieldAnimateDoorOpen(*xp, *yp - 1);
|
||||
task->data[0] = 1;
|
||||
break;
|
||||
case 1:
|
||||
if (task->data[1] < 0 || gTasks[task->data[1]].isActive != TRUE)
|
||||
{
|
||||
FieldObjectClearAnimIfSpecialAnimActive(&gMapObjects[GetFieldObjectIdByLocalIdAndMap(0xFF, 0, 0)]);
|
||||
FieldObjectSetHeldMovement(&gMapObjects[GetFieldObjectIdByLocalIdAndMap(0xFF, 0, 0)], 17);
|
||||
task->data[0] = 2;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
if (walkrun_is_standing_still())
|
||||
{
|
||||
task->data[1] = FieldAnimateDoorClose(*xp, *yp - 1);
|
||||
FieldObjectClearHeldMovementIfFinished(&gMapObjects[GetFieldObjectIdByLocalIdAndMap(0xFF, 0, 0)]);
|
||||
sub_807DCB0(FALSE);
|
||||
task->data[0] = 3;
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
if (task->data[1] < 0 || gTasks[task->data[1]].isActive != TRUE)
|
||||
{
|
||||
task->data[0] = 4;
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
sub_8055F88();
|
||||
sub_807DC18();
|
||||
PlayRainStoppingSoundEffect();
|
||||
task->data[0] = 0;
|
||||
task->func = sub_807E718;
|
||||
break;
|
||||
case 5:
|
||||
sub_8055F88();
|
||||
PlayRainStoppingSoundEffect();
|
||||
task->data[0] = 0;
|
||||
task->func = sub_807E718;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void sub_807E980(u8 taskId)
|
||||
{
|
||||
s16 * data = gTasks[taskId].data;
|
||||
struct MapObject *playerObj = &gMapObjects[gPlayerAvatar.mapObjectId];
|
||||
struct Sprite *playerSpr = &gSprites[gPlayerAvatar.spriteId];
|
||||
switch (data[0])
|
||||
{
|
||||
case 0:
|
||||
ScriptContext2_Enable();
|
||||
player_bitmagic();
|
||||
CameraObjectReset2();
|
||||
data[0]++;
|
||||
break;
|
||||
case 1:
|
||||
if (!FieldObjectIsMovementOverridden(playerObj) || FieldObjectClearHeldMovementIfFinished(playerObj))
|
||||
{
|
||||
if (data[15] != 0)
|
||||
data[15]--;
|
||||
else
|
||||
{
|
||||
sub_8055F88();
|
||||
PlayRainStoppingSoundEffect();
|
||||
playerSpr->oam.priority = 1;
|
||||
sub_807EB64(data[1], &data[2], &data[3]);
|
||||
PlaySE(SE_KAIDAN);
|
||||
data[0]++;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
sub_807EAC4(data[2], data[3], &data[4], &data[5], &data[6]);
|
||||
data[15]++;
|
||||
if (data[15] >= 12)
|
||||
{
|
||||
sub_807DC18();
|
||||
data[0]++;
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
sub_807EAC4(data[2], data[3], &data[4], &data[5], &data[6]);
|
||||
if (!sub_807E40C() && sub_8055FC4())
|
||||
data[0]++;
|
||||
break;
|
||||
default:
|
||||
gFieldCallback = sub_807DF64;
|
||||
WarpIntoMap();
|
||||
SetMainCallback2(CB2_LoadMap);
|
||||
DestroyTask(taskId);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void sub_807EAC4(s16 a0, s16 a1, s16 *a2, s16 *a3, s16 *a4)
|
||||
{
|
||||
struct Sprite *playerSpr = &gSprites[gPlayerAvatar.spriteId];
|
||||
struct MapObject *playerObj = &gMapObjects[gPlayerAvatar.mapObjectId];
|
||||
if (a1 > 0 || *a4 > 6)
|
||||
*a3 += a1;
|
||||
*a2 += a0;
|
||||
(*a4)++;
|
||||
playerSpr->pos2.x = *a2 >> 5;
|
||||
playerSpr->pos2.y = *a3 >> 5;
|
||||
if (playerObj->mapobj_bit_7)
|
||||
{
|
||||
FieldObjectForceSetSpecialAnim(playerObj, GetStepInPlaceDelay16AnimId(GetPlayerFacingDirection()));
|
||||
}
|
||||
}
|
||||
|
||||
static void sub_807EB64(u16 a0, s16 *a1, s16 *a2)
|
||||
{
|
||||
FieldObjectForceSetSpecialAnim(&gMapObjects[gPlayerAvatar.mapObjectId], GetStepInPlaceDelay16AnimId(GetPlayerFacingDirection()));
|
||||
sub_807EBBC(a0, a1, a2);
|
||||
}
|
||||
|
||||
static void sub_807EBBC(u8 a0, s16 *a1, s16 *a2)
|
||||
{
|
||||
if (MetatileBehavior_IsUnknownWarp6C(a0))
|
||||
{
|
||||
*a1 = 16;
|
||||
*a2 = -10;
|
||||
}
|
||||
else if (MetatileBehavior_IsUnknownWarp6D(a0))
|
||||
{
|
||||
*a1 = -17;
|
||||
*a2 = -10;
|
||||
}
|
||||
else if (MetatileBehavior_IsUnknownWarp6E(a0))
|
||||
{
|
||||
*a1 = 17;
|
||||
*a2 = 3;
|
||||
}
|
||||
else if (MetatileBehavior_IsUnknownWarp6F(a0))
|
||||
{
|
||||
*a1 = -17;
|
||||
*a2 = 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
*a1 = 0;
|
||||
*a2 = 0;
|
||||
}
|
||||
}
|
||||
|
||||
static void sub_807EC34(u8 taskId)
|
||||
{
|
||||
s16 * data = gTasks[taskId].data;
|
||||
switch (data[0])
|
||||
{
|
||||
default:
|
||||
if (sub_807E418() == TRUE)
|
||||
{
|
||||
CameraObjectReset1();
|
||||
ScriptContext2_Disable();
|
||||
DestroyTask(taskId);
|
||||
}
|
||||
break;
|
||||
case 0:
|
||||
Overworld_PlaySpecialMapMusic();
|
||||
pal_fill_for_maplights();
|
||||
ScriptContext2_Enable();
|
||||
sub_807ECBC(&data[1], &data[2], &data[3], &data[4], &data[5]);
|
||||
data[0]++;
|
||||
break;
|
||||
case 1:
|
||||
if (!sub_807EDA0(&data[1], &data[2], &data[3], &data[4], &data[5]))
|
||||
data[0]++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void sub_807ECBC(s16 *a0, s16 *a1, s16 *a2, s16 *a3, s16 *a4)
|
||||
{
|
||||
s16 x, y;
|
||||
u8 behavior;
|
||||
s32 r1;
|
||||
struct Sprite *sprite;
|
||||
PlayerGetDestCoords(&x, &y);
|
||||
behavior = MapGridGetMetatileBehaviorAt(x, y);
|
||||
if (MetatileBehavior_IsUnknownWarp6E(behavior) || MetatileBehavior_IsUnknownWarp6C(behavior))
|
||||
r1 = 3;
|
||||
else
|
||||
r1 = 4;
|
||||
FieldObjectForceSetSpecialAnim(&gMapObjects[gPlayerAvatar.mapObjectId], sub_8064270(r1));
|
||||
sub_807EBBC(behavior, a0, a1);
|
||||
*a2 = *a0 * 16;
|
||||
*a3 = *a1 * 16;
|
||||
*a4 = 16;
|
||||
sprite = &gSprites[gPlayerAvatar.spriteId];
|
||||
sprite->pos2.x = *a2 >> 5;
|
||||
sprite->pos2.y = *a3 >> 5;
|
||||
*a0 *= -1;
|
||||
*a1 *= -1;
|
||||
}
|
||||
|
||||
static bool8 sub_807EDA0(s16 *a0, s16 *a1, s16 *a2, s16 *a3, s16 *a4)
|
||||
{
|
||||
struct Sprite *sprite;
|
||||
sprite = &gSprites[gPlayerAvatar.spriteId];
|
||||
if (*a4 != 0)
|
||||
{
|
||||
*a2 += *a0;
|
||||
*a3 += *a1;
|
||||
sprite->pos2.x = *a2 >> 5;
|
||||
sprite->pos2.y = *a3 >> 5;
|
||||
(*a4)--;
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
sprite->pos2.x = 0;
|
||||
sprite->pos2.y = 0;
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -833,7 +833,7 @@ s32 sub_80596FC(struct MapConnection *connection, s32 x, s32 y)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
struct MapConnection *sub_805973C(s16 x, s16 y)
|
||||
struct MapConnection *GetMapConnectionAtPos(s16 x, s16 y)
|
||||
{
|
||||
s32 count;
|
||||
struct MapConnection *connection;
|
||||
|
||||
+7
-7
@@ -25,7 +25,7 @@ struct HelpSystemVideoState
|
||||
/*0x0c*/ u16 savedBg0Hofs;
|
||||
/*0x0e*/ u16 savedBg0Vofs;
|
||||
/*0x10*/ u16 savedBldCnt;
|
||||
/*0x12*/ struct TextColor savedTextColor;
|
||||
/*0x12*/ u8 savedTextColor[3];
|
||||
/*0x15*/ u8 state;
|
||||
};
|
||||
|
||||
@@ -171,9 +171,9 @@ void SaveMapTiles(void)
|
||||
void SaveMapTextColors(void)
|
||||
{
|
||||
SaveTextColors(
|
||||
&sVideoState.savedTextColor.fgColor,
|
||||
&sVideoState.savedTextColor.bgColor,
|
||||
&sVideoState.savedTextColor.shadowColor
|
||||
&sVideoState.savedTextColor[0],
|
||||
&sVideoState.savedTextColor[1],
|
||||
&sVideoState.savedTextColor[2]
|
||||
);
|
||||
}
|
||||
|
||||
@@ -200,9 +200,9 @@ void RestoreMapTiles(void)
|
||||
void RestoreMapTextColors(void)
|
||||
{
|
||||
RestoreTextColors(
|
||||
&sVideoState.savedTextColor.fgColor,
|
||||
&sVideoState.savedTextColor.bgColor,
|
||||
&sVideoState.savedTextColor.shadowColor
|
||||
&sVideoState.savedTextColor[0],
|
||||
&sVideoState.savedTextColor[1],
|
||||
&sVideoState.savedTextColor[2]
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -561,7 +561,7 @@ static bool8 sub_80EC62C(void)
|
||||
}
|
||||
break;
|
||||
case 142:
|
||||
sub_800B388();
|
||||
ResetSerial();
|
||||
SetMainCallback2(sub_80EC5B8);
|
||||
break;
|
||||
}
|
||||
|
||||
+1
-1
@@ -326,7 +326,7 @@ void ClearPCItemSlots(void)
|
||||
}
|
||||
}
|
||||
|
||||
void ClearItemSlotsInAllBagPockets(void)
|
||||
void ClearBag(void)
|
||||
{
|
||||
u16 i;
|
||||
|
||||
|
||||
+3
-3
@@ -1,6 +1,6 @@
|
||||
#include "global.h"
|
||||
#include "bg.h"
|
||||
#include "data2.h"
|
||||
#include "data.h"
|
||||
#include "decompress.h"
|
||||
#include "gpu_regs.h"
|
||||
#include "graphics.h"
|
||||
@@ -125,7 +125,7 @@ static const struct MenuAction sItemPcSubmenuOptions[] = {
|
||||
{gFameCheckerText_Cancel, {.void_u8 = Task_ItemPcCancel}}
|
||||
};
|
||||
|
||||
static const struct TextColor gUnknown_8453F8C[] = {
|
||||
static const u8 gUnknown_8453F8C[][3] = {
|
||||
{0, 1, 2},
|
||||
{0, 2, 3},
|
||||
{0, 3, 2},
|
||||
@@ -1111,7 +1111,7 @@ static void unused_ItemPc_AddTextPrinterParameterized(u8 windowId, const u8 * st
|
||||
|
||||
static void ItemPc_AddTextPrinterParameterized(u8 windowId, u8 fontId, const u8 * str, u8 x, u8 y, u8 letterSpacing, u8 lineSpacing, u8 speed, u8 colorIdx)
|
||||
{
|
||||
AddTextPrinterParameterized4(windowId, fontId, x, y, letterSpacing, lineSpacing, &gUnknown_8453F8C[colorIdx], speed, str);
|
||||
AddTextPrinterParameterized4(windowId, fontId, x, y, letterSpacing, lineSpacing, gUnknown_8453F8C[colorIdx], speed, str);
|
||||
}
|
||||
|
||||
static void ItemPc_SetBorderStyleOnWindow(u8 windowId)
|
||||
|
||||
+5
-5
@@ -274,7 +274,7 @@ void ItemUseOnFieldCB_Rod(u8 taskId)
|
||||
void ItemUseOutOfBattle_Itemfinder(u8 taskId)
|
||||
{
|
||||
IncrementGameStat(GAME_STAT_USED_ITEMFINDER);
|
||||
sItemUseOnFieldCB = sub_813EC8C;
|
||||
sItemUseOnFieldCB = ItemUseOnFieldCB_Itemfinder;
|
||||
sub_80A103C(taskId);
|
||||
}
|
||||
|
||||
@@ -435,7 +435,7 @@ void FieldUseFunc_BerryPouch(u8 taskId)
|
||||
|
||||
void InitBerryPouchFromBag(void)
|
||||
{
|
||||
InitBerryPouch(0, ReturnToBagFromKeyItem, 0);
|
||||
InitBerryPouch(BERRYPOUCH_FROMFIELD, ReturnToBagFromKeyItem, 0);
|
||||
}
|
||||
|
||||
void Task_InitBerryPouchFromField(u8 taskId)
|
||||
@@ -444,7 +444,7 @@ void Task_InitBerryPouchFromField(u8 taskId)
|
||||
{
|
||||
CleanupOverworldWindowsAndTilemaps();
|
||||
sub_80A1184();
|
||||
InitBerryPouch(0, CB2_ReturnToField, 1);
|
||||
InitBerryPouch(BERRYPOUCH_FROMFIELD, CB2_ReturnToField, 1);
|
||||
DestroyTask(taskId);
|
||||
}
|
||||
}
|
||||
@@ -457,7 +457,7 @@ void BattleUseFunc_BerryPouch(u8 taskId)
|
||||
|
||||
void InitBerryPouchFromBattle(void)
|
||||
{
|
||||
InitBerryPouch(4, sub_8107ECC, 0);
|
||||
InitBerryPouch(BERRYPOUCH_FROMBATTLE, sub_8107ECC, 0);
|
||||
}
|
||||
|
||||
void FieldUseFunc_TeachyTv(u8 taskId)
|
||||
@@ -852,7 +852,7 @@ void FieldUseFunc_OakStopsYou(u8 taskId)
|
||||
if (GetPocketByItemId(gSpecialVar_ItemId) == POCKET_BERRY_POUCH)
|
||||
{
|
||||
StringExpandPlaceholders(gStringVar4, gUnknown_8416425);
|
||||
DisplayItemMessageInBerryPouch(taskId, 4, gStringVar4, sub_813E2B8);
|
||||
DisplayItemMessageInBerryPouch(taskId, 4, gStringVar4, Task_BerryPouch_DestroyDialogueWindowAndRefreshListMenu);
|
||||
}
|
||||
else
|
||||
sub_80A1110(taskId, gTasks[taskId].data[3]);
|
||||
|
||||
@@ -0,0 +1,659 @@
|
||||
#include "global.h"
|
||||
#include "task.h"
|
||||
#include "new_menu_helpers.h"
|
||||
#include "strings.h"
|
||||
#include "event_scripts.h"
|
||||
#include "map_obj_lock.h"
|
||||
#include "script.h"
|
||||
#include "sound.h"
|
||||
#include "event_data.h"
|
||||
#include "field_player_avatar.h"
|
||||
#include "field_specials.h"
|
||||
#include "fieldmap.h"
|
||||
#include "itemfinder.h"
|
||||
#include "constants/songs.h"
|
||||
|
||||
static void Task_NoResponse_CleanUp(u8 taskId);
|
||||
static void Task_ItemfinderResponseSoundsAndAnims(u8 taskId);
|
||||
static void Task_ItemfinderUnderfootSoundsAndAnims(u8 taskId);
|
||||
static bool8 HiddenItemIsWithinRangeOfPlayer(struct MapEvents * events, u8 taskId);
|
||||
static void SetUnderfootHiddenItem(u8 taskId, struct HiddenItemStruct hiddenItem);
|
||||
static void SetNormalHiddenItem(u8 taskId);
|
||||
static void FindHiddenItemsInConnectedMaps(u8 taskId);
|
||||
static void RegisterHiddenItemRelativeCoordsIfCloser(u8 taskId, s16 dx, s16 dy);
|
||||
static u8 GetPlayerDirectionTowardsHiddenItem(s16 itemX, s16 itemY);
|
||||
static void Task_ItemfinderResponsePrintMessage(u8 taskId);
|
||||
static void Task_ItemfinderResponseCleanUp(u8 taskId);
|
||||
static void Task_ItemfinderUnderfootPrintMessage(u8 taskId);
|
||||
static void Task_ItemfinderUnderfootDigUpItem(u8 taskId);
|
||||
static void DestroyArrowAndStarTiles(void);
|
||||
static void LoadArrowAndStarTiles(void);
|
||||
static void CreateArrowSprite(u8 animNum, u8 direction);
|
||||
static void SpriteCallback_Arrow(struct Sprite * sprite);
|
||||
static void SpriteCallback_DestroyArrow(struct Sprite * sprite);
|
||||
static u8 CreateStarSprite(void);
|
||||
static void SpriteCallback_Star(struct Sprite * sprite);
|
||||
static void SpriteCallback_DestroyStar(struct Sprite * sprite);
|
||||
|
||||
#define ARROW_TILE_TAG 2000
|
||||
|
||||
static const u16 sArrowAndStarSpriteTiles[] = INCBIN_U16("data/itemfinder/spr_tiles.4bpp");
|
||||
|
||||
static const union AnimCmd sArrowAnim0[] = {
|
||||
ANIMCMD_FRAME( 0, 10),
|
||||
ANIMCMD_END
|
||||
};
|
||||
|
||||
static const union AnimCmd sArrowAnim1[] = {
|
||||
ANIMCMD_FRAME( 4, 10),
|
||||
ANIMCMD_END
|
||||
};
|
||||
|
||||
static const union AnimCmd sArrowAnim2[] = {
|
||||
ANIMCMD_FRAME( 8, 10),
|
||||
ANIMCMD_END
|
||||
};
|
||||
|
||||
static const union AnimCmd sArrowAnim3[] = {
|
||||
ANIMCMD_FRAME(12, 10),
|
||||
ANIMCMD_END
|
||||
};
|
||||
|
||||
static const union AnimCmd sStarAnim[] = {
|
||||
ANIMCMD_FRAME(16, 10),
|
||||
ANIMCMD_END
|
||||
};
|
||||
|
||||
static const union AnimCmd *const sArrowAndStarSpriteAnimTable[] = {
|
||||
sArrowAnim0,
|
||||
sArrowAnim1,
|
||||
sArrowAnim2,
|
||||
sArrowAnim3,
|
||||
sStarAnim
|
||||
};
|
||||
|
||||
static const struct OamData sArrowAndStarSpriteOamData = {
|
||||
.affineMode = ST_OAM_AFFINE_NORMAL,
|
||||
.shape = ST_OAM_SQUARE,
|
||||
.size = ST_OAM_SIZE_1
|
||||
};
|
||||
|
||||
static const union AffineAnimCmd sAffineAnim_Left[] = {
|
||||
AFFINEANIMCMD_FRAME(0, 0, 0x00, 1),
|
||||
AFFINEANIMCMD_END
|
||||
};
|
||||
|
||||
static const union AffineAnimCmd sAffineAnim_Down[] = {
|
||||
AFFINEANIMCMD_FRAME(0, 0, 0x40, 1),
|
||||
AFFINEANIMCMD_END
|
||||
};
|
||||
|
||||
static const union AffineAnimCmd sAffineAnim_Right[] = {
|
||||
AFFINEANIMCMD_FRAME(0, 0, 0x80, 1),
|
||||
AFFINEANIMCMD_END
|
||||
};
|
||||
|
||||
static const union AffineAnimCmd sAffineAnim_Up[] = {
|
||||
AFFINEANIMCMD_FRAME(0, 0, 0xc0, 1),
|
||||
AFFINEANIMCMD_END
|
||||
};
|
||||
|
||||
static const union AffineAnimCmd *const sArrowAndStarSpriteAffineAnimTable[] = {
|
||||
sAffineAnim_Left,
|
||||
sAffineAnim_Down,
|
||||
sAffineAnim_Right,
|
||||
sAffineAnim_Up
|
||||
};
|
||||
|
||||
static const struct SpriteTemplate gUnknown_84647E4 = {
|
||||
.tileTag = ARROW_TILE_TAG,
|
||||
.paletteTag = 0xFFFF,
|
||||
.oam = &sArrowAndStarSpriteOamData,
|
||||
.anims = sArrowAndStarSpriteAnimTable,
|
||||
.affineAnims = sArrowAndStarSpriteAffineAnimTable,
|
||||
.callback = SpriteCallback_Arrow
|
||||
};
|
||||
|
||||
static const struct SpriteSheet sArrowAndStarSpriteSheet = {
|
||||
.data = sArrowAndStarSpriteTiles,
|
||||
.size = sizeof(sArrowAndStarSpriteTiles),
|
||||
.tag = ARROW_TILE_TAG
|
||||
};
|
||||
|
||||
#define tItemX data[0]
|
||||
#define tItemY data[1]
|
||||
#define tHiddenItemFound data[2]
|
||||
#define tDingTimer data[3]
|
||||
#define tNumDingsRemaining data[4]
|
||||
#define tDingNum data[5]
|
||||
#define tUnderfoot data[6]
|
||||
#define tStartSpriteId data[7]
|
||||
|
||||
void ItemUseOnFieldCB_Itemfinder(u8 taskId)
|
||||
{
|
||||
u8 i;
|
||||
for (i = 0; i < 16; i++)
|
||||
gTasks[taskId].data[i] = 0;
|
||||
if (HiddenItemIsWithinRangeOfPlayer(gMapHeader.events, taskId) == TRUE)
|
||||
{
|
||||
LoadArrowAndStarTiles();
|
||||
if (gTasks[taskId].tUnderfoot == TRUE)
|
||||
gTasks[taskId].func = Task_ItemfinderUnderfootSoundsAndAnims;
|
||||
else
|
||||
gTasks[taskId].func = Task_ItemfinderResponseSoundsAndAnims;
|
||||
}
|
||||
else
|
||||
{
|
||||
DisplayItemMessageOnField(taskId, 2, gText_NopeTheresNoResponse, Task_NoResponse_CleanUp);
|
||||
}
|
||||
}
|
||||
|
||||
static void Task_NoResponse_CleanUp(u8 taskId)
|
||||
{
|
||||
ClearDialogWindowAndFrame(0, TRUE);
|
||||
sub_80696C0();
|
||||
ScriptContext2_Disable();
|
||||
DestroyTask(taskId);
|
||||
}
|
||||
|
||||
static void Task_ItemfinderResponseSoundsAndAnims(u8 taskId)
|
||||
{
|
||||
s16 *data = gTasks[taskId].data;
|
||||
u8 direction;
|
||||
if (tDingTimer % 25 == 0)
|
||||
{
|
||||
direction = GetPlayerDirectionTowardsHiddenItem(tItemX, tItemY);
|
||||
if (tNumDingsRemaining == 0)
|
||||
{
|
||||
gTasks[taskId].func = Task_ItemfinderResponsePrintMessage;
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
PlaySE(SE_TOY_F);
|
||||
CreateArrowSprite(tDingNum, direction);
|
||||
tDingNum++;
|
||||
tNumDingsRemaining--;
|
||||
}
|
||||
}
|
||||
tDingTimer++;
|
||||
}
|
||||
|
||||
static void Task_ItemfinderUnderfootSoundsAndAnims(u8 taskId)
|
||||
{
|
||||
s16 *data = gTasks[taskId].data;
|
||||
if (tDingTimer % 25 == 0)
|
||||
{
|
||||
if (tNumDingsRemaining == 0)
|
||||
{
|
||||
gTasks[taskId].func = Task_ItemfinderUnderfootPrintMessage;
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
PlaySE(SE_TOY_F);
|
||||
tStartSpriteId = CreateStarSprite();
|
||||
tDingNum++;
|
||||
tNumDingsRemaining--;
|
||||
}
|
||||
}
|
||||
tDingTimer++;
|
||||
}
|
||||
|
||||
static bool8 HiddenItemIsWithinRangeOfPlayer(struct MapEvents * events, u8 taskId)
|
||||
{
|
||||
s16 x, y, i, dx, dy;
|
||||
PlayerGetDestCoords(&x, &y);
|
||||
gTasks[taskId].tHiddenItemFound = FALSE;
|
||||
for (i = 0; i < events->bgEventCount; i++)
|
||||
{
|
||||
if (events->bgEvents[i].kind == 7 && !FlagGet(GetHiddenItemAttr(events->bgEvents[i].bgUnion.hiddenItem, HIDDEN_ITEM_FLAG)))
|
||||
{
|
||||
dx = events->bgEvents[i].x + 7 - x;
|
||||
dy = events->bgEvents[i].y + 7 - y;
|
||||
if (GetHiddenItemAttr(events->bgEvents[i].bgUnion.hiddenItem, HIDDEN_ITEM_UNDERFOOT) == TRUE)
|
||||
{
|
||||
if (dx == 0 && dy == 0)
|
||||
{
|
||||
SetUnderfootHiddenItem(taskId, events->bgEvents[i].bgUnion.hiddenItem);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
else if (
|
||||
dx >= -7
|
||||
&& dx <= 7
|
||||
&& dy >= -5
|
||||
&& dy <= 5
|
||||
)
|
||||
{
|
||||
RegisterHiddenItemRelativeCoordsIfCloser(taskId, dx, dy);
|
||||
}
|
||||
}
|
||||
}
|
||||
FindHiddenItemsInConnectedMaps(taskId);
|
||||
if (gTasks[taskId].tHiddenItemFound == TRUE)
|
||||
{
|
||||
SetNormalHiddenItem(taskId);
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void SetUnderfootHiddenItem(u8 taskId, struct HiddenItemStruct hiddenItem)
|
||||
{
|
||||
s16 *data = gTasks[taskId].data;
|
||||
gSpecialVar_0x8004 = GetHiddenItemAttr(hiddenItem, HIDDEN_ITEM_FLAG);
|
||||
gSpecialVar_0x8005 = GetHiddenItemAttr(hiddenItem, HIDDEN_ITEM_ID);
|
||||
gSpecialVar_0x8006 = 1;
|
||||
TV_PrintIntToStringVar(0, gSpecialVar_0x8005);
|
||||
tHiddenItemFound = TRUE;
|
||||
tItemX = 0;
|
||||
tItemY = 0;
|
||||
tNumDingsRemaining = 3;
|
||||
tUnderfoot = TRUE;
|
||||
}
|
||||
|
||||
static void SetNormalHiddenItem(u8 taskId)
|
||||
{
|
||||
s16 *data = gTasks[taskId].data;
|
||||
s16 absY = tItemY;
|
||||
s16 absX = tItemX;
|
||||
|
||||
// The strength of the response increases inversely with distance to the item.
|
||||
if (tItemX == 0 && tItemY == 0)
|
||||
tNumDingsRemaining = 4;
|
||||
else
|
||||
{
|
||||
if (tItemX < 0)
|
||||
absX = tItemX * -1;
|
||||
if (tItemY < 0)
|
||||
absY = tItemY * -1;
|
||||
if (absX > absY)
|
||||
{
|
||||
if (absX > 3)
|
||||
tNumDingsRemaining = 2;
|
||||
else
|
||||
tNumDingsRemaining = 4;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (absY > 3)
|
||||
tNumDingsRemaining = 2;
|
||||
else
|
||||
tNumDingsRemaining = 4;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static bool8 HiddenItemAtPos(struct MapEvents * events, s16 x, s16 y)
|
||||
{
|
||||
u8 bgEventCount = events->bgEventCount;
|
||||
struct BgEvent * bgEvents = events->bgEvents;
|
||||
u16 eventFlag;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < bgEventCount; i++)
|
||||
{
|
||||
if (
|
||||
bgEvents[i].kind == 7
|
||||
&& x == bgEvents[i].x
|
||||
&& y == bgEvents[i].y
|
||||
)
|
||||
{
|
||||
eventFlag = GetHiddenItemAttr(bgEvents[i].bgUnion.hiddenItem, HIDDEN_ITEM_FLAG);
|
||||
if (GetHiddenItemAttr(bgEvents[i].bgUnion.hiddenItem, HIDDEN_ITEM_UNDERFOOT) != TRUE && !FlagGet(eventFlag))
|
||||
return TRUE;
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static bool8 HiddenItemInConnectedMapAtPos(struct MapConnection * connection, s32 x, s32 y)
|
||||
{
|
||||
const struct MapHeader * mapHeader;
|
||||
u16 localX, localY;
|
||||
u32 localOffset;
|
||||
s32 localLength;
|
||||
|
||||
mapHeader = mapconnection_get_mapheader(connection);
|
||||
|
||||
switch (connection->direction)
|
||||
{
|
||||
// same weird temp variable behavior seen in HiddenItemAtPos
|
||||
case 2:
|
||||
localOffset = connection->offset + 7;
|
||||
localX = x - localOffset;
|
||||
localLength = mapHeader->mapData->height - 7;
|
||||
localY = localLength + y; // additions are reversed for some reason
|
||||
break;
|
||||
case 1:
|
||||
localOffset = connection->offset + 7;
|
||||
localX = x - localOffset;
|
||||
localLength = gMapHeader.mapData->height + 7;
|
||||
localY = y - localLength;
|
||||
break;
|
||||
case 3:
|
||||
localLength = mapHeader->mapData->width - 7;
|
||||
localX = localLength + x; // additions are reversed for some reason
|
||||
localOffset = connection->offset + 7;
|
||||
localY = y - localOffset;
|
||||
break;
|
||||
case 4:
|
||||
localLength = gMapHeader.mapData->width + 7;
|
||||
localX = x - localLength;
|
||||
localOffset = connection->offset + 7;
|
||||
localY = y - localOffset;
|
||||
break;
|
||||
default:
|
||||
return FALSE;
|
||||
}
|
||||
return HiddenItemAtPos(mapHeader->events, localX, localY);
|
||||
}
|
||||
|
||||
static void FindHiddenItemsInConnectedMaps(u8 taskId)
|
||||
{
|
||||
s16 x, y;
|
||||
s16 curX, curY;
|
||||
s16 width = gMapHeader.mapData->width + 7;
|
||||
s16 height = gMapHeader.mapData->height + 7;
|
||||
|
||||
s16 var1 = 7;
|
||||
s16 var2 = 7;
|
||||
|
||||
PlayerGetDestCoords(&x, &y);
|
||||
|
||||
for (curX = x - 7; curX <= x + 7; curX++)
|
||||
{
|
||||
for (curY = y - 5; curY <= y + 5; curY++)
|
||||
{
|
||||
if (var1 > curX
|
||||
|| curX >= width
|
||||
|| var2 > curY
|
||||
|| curY >= height)
|
||||
{
|
||||
struct MapConnection * conn = GetMapConnectionAtPos(curX, curY);
|
||||
if (conn != NULL && HiddenItemInConnectedMapAtPos(conn, curX, curY) == TRUE)
|
||||
RegisterHiddenItemRelativeCoordsIfCloser(taskId, curX - x, curY - y);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void RegisterHiddenItemRelativeCoordsIfCloser(u8 taskId, s16 dx, s16 dy)
|
||||
{
|
||||
s16 *data = gTasks[taskId].data;
|
||||
s16 dx2, dy2, dx3, dy3;
|
||||
|
||||
if (tHiddenItemFound == FALSE)
|
||||
{
|
||||
tItemX = dx;
|
||||
tItemY = dy;
|
||||
tHiddenItemFound = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
// tItemX and tItemY contain the player's coordinates.
|
||||
// dx and dy contain the item's coordinates.
|
||||
if (tItemX < 0)
|
||||
dx2 = tItemX * -1; // item is to the left
|
||||
else
|
||||
dx2 = tItemX; // item is to the right
|
||||
|
||||
if (tItemY < 0)
|
||||
dy2 = tItemY * -1; // item is to the north
|
||||
else
|
||||
dy2 = tItemY; // item is to the south
|
||||
|
||||
if (dx < 0)
|
||||
dx3 = dx * -1;
|
||||
else
|
||||
dx3 = dx;
|
||||
|
||||
if (dy < 0)
|
||||
dy3 = dy * -1;
|
||||
else
|
||||
dy3 = dy;
|
||||
|
||||
if (dx2 + dy2 > dx3 + dy3)
|
||||
{
|
||||
tItemX = dx;
|
||||
tItemY = dy;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (dx2 + dy2 == dx3 + dy3 && (dy2 > dy3 || (dy2 == dy3 && tItemY < dy)))
|
||||
{
|
||||
tItemX = dx;
|
||||
tItemY = dy;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static u8 GetPlayerDirectionTowardsHiddenItem(s16 itemX, s16 itemY)
|
||||
{
|
||||
s16 abX, abY;
|
||||
|
||||
if (itemX == 0 && itemY == 0)
|
||||
return DIR_NONE; // player is standing on the item.
|
||||
|
||||
// get absolute X distance.
|
||||
if (itemX < 0)
|
||||
abX = itemX * -1;
|
||||
else
|
||||
abX = itemX;
|
||||
|
||||
// get absolute Y distance.
|
||||
if (itemY < 0)
|
||||
abY = itemY * -1;
|
||||
else
|
||||
abY = itemY;
|
||||
|
||||
if (abX > abY)
|
||||
{
|
||||
if (itemX < 0)
|
||||
return DIR_EAST;
|
||||
else
|
||||
return DIR_NORTH;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (abX < abY)
|
||||
{
|
||||
if (itemY < 0)
|
||||
return DIR_SOUTH;
|
||||
else
|
||||
return DIR_WEST;
|
||||
}
|
||||
if (abX == abY)
|
||||
{
|
||||
if (itemY < 0)
|
||||
return DIR_SOUTH;
|
||||
else
|
||||
return DIR_WEST;
|
||||
}
|
||||
return DIR_NONE; // should never get here. return something so it doesnt crash.
|
||||
}
|
||||
}
|
||||
|
||||
static void Task_ItemfinderResponsePrintMessage(u8 taskId)
|
||||
{
|
||||
DisplayItemMessageOnField(taskId, 2, gText_ItemfinderResponding, Task_ItemfinderResponseCleanUp);
|
||||
}
|
||||
|
||||
static void Task_ItemfinderResponseCleanUp(u8 taskId)
|
||||
{
|
||||
DestroyArrowAndStarTiles();
|
||||
ClearDialogWindowAndFrame(0, TRUE);
|
||||
sub_80696C0();
|
||||
ScriptContext2_Disable();
|
||||
DestroyTask(taskId);
|
||||
}
|
||||
|
||||
static void Task_ItemfinderUnderfootPrintMessage(u8 taskId)
|
||||
{
|
||||
DisplayItemMessageOnField(taskId, 2, gText_ItemfinderShakingWildly, Task_ItemfinderUnderfootDigUpItem);
|
||||
}
|
||||
|
||||
static void Task_ItemfinderUnderfootDigUpItem(u8 taskId)
|
||||
{
|
||||
DestroyArrowAndStarTiles();
|
||||
DestroyTask(taskId);
|
||||
ScriptContext1_SetupScript(EventScript_ItemfinderDigUpUnderfootItem);
|
||||
ScriptContext2_Enable();
|
||||
}
|
||||
|
||||
#undef tStartSpriteId
|
||||
#undef tUnderfoot
|
||||
#undef tDingNum
|
||||
#undef tNumDingsRemaining
|
||||
#undef tDingTimer
|
||||
#undef tHiddenItemFound
|
||||
#undef tItemY
|
||||
#undef tItemX
|
||||
|
||||
#define spData0 data[0]
|
||||
#define spDeltaX data[1]
|
||||
#define spDeltaY data[2]
|
||||
#define spCurX data[3]
|
||||
#define spCurY data[4]
|
||||
#define spCenterX data[5]
|
||||
#define spCenterY data[6]
|
||||
#define spAnimNum data[7]
|
||||
|
||||
static void LoadArrowAndStarTiles(void)
|
||||
{
|
||||
LoadSpriteSheet(&sArrowAndStarSpriteSheet);
|
||||
}
|
||||
|
||||
static void DestroyArrowAndStarTiles(void)
|
||||
{
|
||||
FreeSpriteTilesByTag(ARROW_TILE_TAG);
|
||||
}
|
||||
|
||||
static void CreateArrowSprite(u8 animNum, u8 direction)
|
||||
{
|
||||
u8 spriteId = CreateSprite(&gUnknown_84647E4, 120, 76, 0);
|
||||
gSprites[spriteId].oam.paletteNum = 0;
|
||||
StartSpriteAnim(&gSprites[spriteId], animNum);
|
||||
gSprites[spriteId].spAnimNum = animNum;
|
||||
gSprites[spriteId].spData0 = 0;
|
||||
gSprites[spriteId].spCurX = 0;
|
||||
gSprites[spriteId].spCurY = 0;
|
||||
gSprites[spriteId].spCenterX = 120;
|
||||
gSprites[spriteId].spCenterY = 76;
|
||||
switch (direction)
|
||||
{
|
||||
case DIR_NONE:
|
||||
switch (GetPlayerFacingDirection())
|
||||
{
|
||||
case DIR_WEST:
|
||||
gSprites[spriteId].spDeltaX = -100;
|
||||
gSprites[spriteId].spDeltaY = 0;
|
||||
StartSpriteAffineAnim(&gSprites[spriteId], 0);
|
||||
break;
|
||||
case DIR_NORTH:
|
||||
gSprites[spriteId].spDeltaX = 0;
|
||||
gSprites[spriteId].spDeltaY = -100;
|
||||
StartSpriteAffineAnim(&gSprites[spriteId], 3);
|
||||
break;
|
||||
case DIR_EAST:
|
||||
gSprites[spriteId].spDeltaX = 100;
|
||||
gSprites[spriteId].spDeltaY = 0;
|
||||
StartSpriteAffineAnim(&gSprites[spriteId], 2);
|
||||
break;
|
||||
case DIR_SOUTH:
|
||||
gSprites[spriteId].spDeltaX = 0;
|
||||
gSprites[spriteId].spDeltaY = 100;
|
||||
StartSpriteAffineAnim(&gSprites[spriteId], 1);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case DIR_SOUTH:
|
||||
gSprites[spriteId].spDeltaX = 0;
|
||||
gSprites[spriteId].spDeltaY = -100;
|
||||
StartSpriteAffineAnim(&gSprites[spriteId], 3);
|
||||
break;
|
||||
case DIR_NORTH:
|
||||
gSprites[spriteId].spDeltaX = 100;
|
||||
gSprites[spriteId].spDeltaY = 0;
|
||||
StartSpriteAffineAnim(&gSprites[spriteId], 2);
|
||||
break;
|
||||
case DIR_WEST:
|
||||
gSprites[spriteId].spDeltaX = 0;
|
||||
gSprites[spriteId].spDeltaY = 100;
|
||||
StartSpriteAffineAnim(&gSprites[spriteId], 1);
|
||||
break;
|
||||
case DIR_EAST:
|
||||
gSprites[spriteId].spDeltaX = -100;
|
||||
gSprites[spriteId].spDeltaY = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void SpriteCallback_Arrow(struct Sprite * sprite)
|
||||
{
|
||||
s16 x, y;
|
||||
sprite->spCurX += sprite->spDeltaX;
|
||||
sprite->spCurY += sprite->spDeltaY;
|
||||
sprite->pos1.x = sprite->spCenterX + (sprite->spCurX >> 8);
|
||||
sprite->pos1.y = sprite->spCenterY + (sprite->spCurY >> 8);
|
||||
if (sprite->pos1.x <= 104
|
||||
|| sprite->pos1.x > 132
|
||||
|| sprite->pos1.y <= 60
|
||||
|| sprite->pos1.y > 88)
|
||||
sprite->callback = SpriteCallback_DestroyArrow;
|
||||
}
|
||||
|
||||
static void SpriteCallback_DestroyArrow(struct Sprite * sprite)
|
||||
{
|
||||
FreeSpriteOamMatrix(sprite);
|
||||
DestroySprite(sprite);
|
||||
}
|
||||
|
||||
static u8 CreateStarSprite(void)
|
||||
{
|
||||
u8 spriteId = CreateSprite(&gUnknown_84647E4, 120, 76, 0);
|
||||
gSprites[spriteId].oam.paletteNum = 0;
|
||||
gSprites[spriteId].callback = SpriteCallback_Star;
|
||||
StartSpriteAnim(&gSprites[spriteId], 4);
|
||||
gSprites[spriteId].spAnimNum = 0;
|
||||
gSprites[spriteId].spData0 = 0;
|
||||
gSprites[spriteId].spCurX = 0;
|
||||
gSprites[spriteId].spCurY = 0;
|
||||
gSprites[spriteId].spCenterX = 120;
|
||||
gSprites[spriteId].spCenterY = 76;
|
||||
gSprites[spriteId].spDeltaX = 0;
|
||||
gSprites[spriteId].spDeltaY = -100;
|
||||
return spriteId;
|
||||
}
|
||||
|
||||
static void SpriteCallback_Star(struct Sprite * sprite)
|
||||
{
|
||||
s16 x, y;
|
||||
sprite->spCurX += sprite->spDeltaX;
|
||||
sprite->spCurY += sprite->spDeltaY;
|
||||
sprite->pos1.x = sprite->spCenterX + (sprite->spCurX >> 8);
|
||||
sprite->pos1.y = sprite->spCenterY + (sprite->spCurY >> 8);
|
||||
if (sprite->pos1.x <= 104
|
||||
|| sprite->pos1.x > 132
|
||||
|| sprite->pos1.y <= 60
|
||||
|| sprite->pos1.y > 88)
|
||||
sprite->callback = SpriteCallback_DestroyStar;
|
||||
}
|
||||
|
||||
static void SpriteCallback_DestroyStar(struct Sprite * sprite)
|
||||
{
|
||||
DestroySprite(sprite);
|
||||
}
|
||||
|
||||
#undef spAnimNum
|
||||
#undef spCenterY
|
||||
#undef spCenterX
|
||||
#undef spCurY
|
||||
#undef spCurX
|
||||
#undef spDeltaY
|
||||
#undef spDeltaX
|
||||
#undef spData0
|
||||
+2259
File diff suppressed because it is too large
Load Diff
+9
-9
@@ -368,21 +368,21 @@ static u8 ListMenuInitInternal(struct ListMenuTemplate *listMenuTemplate, u16 sc
|
||||
|
||||
static void ListMenuPrint(struct ListMenu *list, const u8 *str, u8 x, u8 y)
|
||||
{
|
||||
struct TextColor colors;
|
||||
u8 colors[3];
|
||||
if (gListMenuOverride.enabled)
|
||||
{
|
||||
colors.fgColor = gListMenuOverride.fillValue;
|
||||
colors.bgColor = gListMenuOverride.cursorPal;
|
||||
colors.shadowColor = gListMenuOverride.cursorShadowPal;
|
||||
AddTextPrinterParameterized4(list->template.windowId, gListMenuOverride.fontId, x, y, gListMenuOverride.lettersSpacing, 0, &colors, TEXT_SPEED_FF, str);
|
||||
colors[0] = gListMenuOverride.fillValue;
|
||||
colors[1] = gListMenuOverride.cursorPal;
|
||||
colors[2] = gListMenuOverride.cursorShadowPal;
|
||||
AddTextPrinterParameterized4(list->template.windowId, gListMenuOverride.fontId, x, y, gListMenuOverride.lettersSpacing, 0, colors, TEXT_SPEED_FF, str);
|
||||
gListMenuOverride.enabled = FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
colors.fgColor = list->template.fillValue;
|
||||
colors.bgColor = list->template.cursorPal;
|
||||
colors.shadowColor = list->template.cursorShadowPal;
|
||||
AddTextPrinterParameterized4(list->template.windowId, list->template.fontId, x, y, list->template.lettersSpacing, 0, &colors, TEXT_SPEED_FF, str);
|
||||
colors[0] = list->template.fillValue;
|
||||
colors[1] = list->template.cursorPal;
|
||||
colors[2] = list->template.cursorShadowPal;
|
||||
AddTextPrinterParameterized4(list->template.windowId, list->template.fontId, x, y, list->template.lettersSpacing, 0, colors, TEXT_SPEED_FF, str);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,143 @@
|
||||
#include "global.h"
|
||||
#include "malloc.h"
|
||||
#include "window.h"
|
||||
#include "menu.h"
|
||||
#include "string_util.h"
|
||||
#include "new_menu_helpers.h"
|
||||
#include "list_menu.h"
|
||||
#include "player_pc.h"
|
||||
#include "strings.h"
|
||||
#include "menu_indicators.h"
|
||||
#include "sound.h"
|
||||
#include "constants/songs.h"
|
||||
|
||||
static EWRAM_DATA u8 sWindowIds[3] = {};
|
||||
static EWRAM_DATA struct ListMenuItem * sListMenuItems = NULL;
|
||||
|
||||
static void MoveCursorFunc(s32 itemIndex, bool8 onInit, struct ListMenu * list);
|
||||
|
||||
static const struct WindowTemplate sWindowTemplates[] = {
|
||||
{
|
||||
.bg = 0,
|
||||
.tilemapLeft = 1,
|
||||
.tilemapTop = 1,
|
||||
.width = 10,
|
||||
.height = 2,
|
||||
.paletteNum = 15,
|
||||
.baseBlock = 0x008
|
||||
}, {
|
||||
.bg = 0,
|
||||
.tilemapLeft = 19,
|
||||
.tilemapTop = 1,
|
||||
.width = 10,
|
||||
.height = 18,
|
||||
.paletteNum = 15,
|
||||
.baseBlock = 0x01c
|
||||
}, {
|
||||
.bg = 0,
|
||||
.tilemapLeft = 1,
|
||||
.tilemapTop = 1,
|
||||
.width = 15,
|
||||
.height = 8,
|
||||
.paletteNum = 15,
|
||||
.baseBlock = 0x01c
|
||||
}
|
||||
};
|
||||
|
||||
static const u8 sTextColor[3] = {1, 2, 3};
|
||||
static const u8 sString_Dummy[] = _("");
|
||||
|
||||
bool8 MailboxPC_InitBuffers(u8 num)
|
||||
{
|
||||
u8 i;
|
||||
|
||||
sListMenuItems = Alloc(sizeof(struct ListMenuItem) * (num + 1));
|
||||
if (sListMenuItems == NULL)
|
||||
return FALSE;
|
||||
for (i = 0; i < NELEMS(sWindowIds); i++)
|
||||
sWindowIds[i] = 0xFF;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
u8 MailboxPC_GetAddWindow(u8 winIdx)
|
||||
{
|
||||
if (sWindowIds[winIdx] == 0xFF)
|
||||
{
|
||||
sWindowIds[winIdx] = AddWindow(&sWindowTemplates[winIdx]);
|
||||
SetStdWindowBorderStyle(sWindowIds[winIdx], 0);
|
||||
}
|
||||
return sWindowIds[winIdx];
|
||||
}
|
||||
|
||||
void MailboxPC_RemoveWindow(u8 winIdx)
|
||||
{
|
||||
ClearStdWindowAndFrameToTransparent(sWindowIds[winIdx], FALSE);
|
||||
ClearWindowTilemap(sWindowIds[winIdx]);
|
||||
RemoveWindow(sWindowIds[winIdx]);
|
||||
sWindowIds[winIdx] = 0xFF;
|
||||
}
|
||||
|
||||
u8 MailboxPC_GetWindowId(u8 winIdx)
|
||||
{
|
||||
return sWindowIds[winIdx];
|
||||
}
|
||||
|
||||
static void ItemPrintFunc(u8 windowId, s32 itemId, u8 y)
|
||||
{
|
||||
u8 strbuf[30];
|
||||
if (itemId != -2)
|
||||
{
|
||||
StringCopy(strbuf, gSaveBlock1Ptr->mail[itemId + PARTY_SIZE].playerName);
|
||||
if (StringLength(strbuf) <= 5)
|
||||
ConvertInternationalString(strbuf, LANGUAGE_JAPANESE);
|
||||
AddTextPrinterParameterized4(windowId, 2, 8, y, 0, 0, sTextColor, -1, strbuf);
|
||||
}
|
||||
}
|
||||
|
||||
u8 MailboxPC_InitListMenu(struct PlayerPC_Unk_203AAC4 * playerPcStruct)
|
||||
{
|
||||
u16 i;
|
||||
for (i = 0; i < playerPcStruct->unk_5; i++)
|
||||
{
|
||||
sListMenuItems[i].label = sString_Dummy;
|
||||
sListMenuItems[i].index = i;
|
||||
}
|
||||
sListMenuItems[i].label = gFameCheckerText_Cancel;
|
||||
sListMenuItems[i].index = -2;
|
||||
|
||||
gMultiuseListMenuTemplate.items = sListMenuItems;
|
||||
gMultiuseListMenuTemplate.totalItems = playerPcStruct->unk_5 + 1;
|
||||
gMultiuseListMenuTemplate.windowId = sWindowIds[1];
|
||||
gMultiuseListMenuTemplate.header_X = 0;
|
||||
gMultiuseListMenuTemplate.item_X = GetMenuCursorDimensionByFont(2, 0);
|
||||
gMultiuseListMenuTemplate.cursor_X = 0;
|
||||
gMultiuseListMenuTemplate.lettersSpacing = 0;
|
||||
gMultiuseListMenuTemplate.itemVerticalPadding = 2;
|
||||
gMultiuseListMenuTemplate.maxShowed = 8;
|
||||
gMultiuseListMenuTemplate.fontId = 2;
|
||||
gMultiuseListMenuTemplate.upText_Y = 10;
|
||||
gMultiuseListMenuTemplate.cursorPal = 2;
|
||||
gMultiuseListMenuTemplate.fillValue = 1;
|
||||
gMultiuseListMenuTemplate.cursorShadowPal = 3;
|
||||
gMultiuseListMenuTemplate.moveCursorFunc = MoveCursorFunc;
|
||||
gMultiuseListMenuTemplate.itemPrintFunc = ItemPrintFunc;
|
||||
gMultiuseListMenuTemplate.cursorKind = 0;
|
||||
gMultiuseListMenuTemplate.scrollMultiple = 0;
|
||||
return ListMenuInit(&gMultiuseListMenuTemplate, playerPcStruct->scrollOffset, playerPcStruct->selectedRow);
|
||||
}
|
||||
|
||||
static void MoveCursorFunc(s32 itemIndex, bool8 onInit, struct ListMenu * list)
|
||||
{
|
||||
if (onInit != TRUE)
|
||||
PlaySE(SE_SELECT);
|
||||
}
|
||||
|
||||
void MailboxPC_AddScrollIndicatorArrows(struct PlayerPC_Unk_203AAC4 * playerPcStruct)
|
||||
{
|
||||
playerPcStruct->unk_A = AddScrollIndicatorArrowPairParameterized(2, 0xC2, 0xC, 0x94, playerPcStruct->unk_5 - playerPcStruct->unk_4 + 1, 110, 110, &playerPcStruct->scrollOffset);
|
||||
}
|
||||
|
||||
void MailboxPC_DestroyListMenuBuffer(void)
|
||||
{
|
||||
Free(sListMenuItems);
|
||||
}
|
||||
@@ -447,21 +447,21 @@ u16 sub_80F8318(u8 mapsec)
|
||||
{
|
||||
u16 windowId;
|
||||
u32 xctr;
|
||||
struct TextColor color[0];
|
||||
u8 color[0];
|
||||
|
||||
windowId = AddWindow(&sMapNameWindow);
|
||||
FillWindowPixelBuffer(windowId, PIXEL_FILL(1));
|
||||
PutWindowTilemap(windowId);
|
||||
color->fgColor = 1; // Access violation
|
||||
color->bgColor = 4; // Access violation
|
||||
color->shadowColor = 3; // Access violation
|
||||
color[0] = 1; // Access violation
|
||||
color[1] = 4; // Access violation
|
||||
color[2] = 3; // Access violation
|
||||
GetMapName(gStringVar4, mapsec, 0);
|
||||
xctr = 104 - GetStringWidth(2, gStringVar4, 0);
|
||||
AddTextPrinterParameterized4(windowId, 2, xctr / 2, 2, 0, 0, color/* Access violation */, -1, gStringVar4);
|
||||
return windowId;
|
||||
}
|
||||
|
||||
bool8 sub_80F83B0(void)
|
||||
bool32 sub_80F83B0(void)
|
||||
{
|
||||
if (FuncIsActiveTask(sub_80F83D0) == TRUE)
|
||||
{
|
||||
|
||||
+11
-16
@@ -41,12 +41,7 @@ static void WindowFunc_DrawStdFrameWithCustomTileAndPalette(u8 bg, u8 tilemapLef
|
||||
static void WindowFunc_ClearStdWindowAndFrameToTransparent(u8 bg, u8 tilemapLeft, u8 tilemapTop, u8 width, u8 height, u8 paletteNum);
|
||||
static u8 MultichoiceGrid_MoveCursor(s8 deltaX, s8 deltaY);
|
||||
|
||||
static const struct TextColor gUnknown_8456618 =
|
||||
{
|
||||
.fgColor = 15,
|
||||
.bgColor = 1,
|
||||
.shadowColor = 2,
|
||||
};
|
||||
static const u8 gUnknown_8456618[3] = {15, 1, 2};
|
||||
|
||||
void DrawDialogFrameWithCustomTileAndPalette(u8 windowId, bool8 copyToVram, u16 tileNum, u8 paletteNum)
|
||||
{
|
||||
@@ -205,7 +200,7 @@ void TopBarWindowPrintString(const u8 *string, u8 unused, bool8 copyToVram)
|
||||
PutWindowTilemap(sTopBarWindowId);
|
||||
FillWindowPixelBuffer(sTopBarWindowId, PIXEL_FILL(15));
|
||||
width = GetStringWidth(0, string, 0);
|
||||
AddTextPrinterParameterized3(sTopBarWindowId, 0, -20 - width, 1, &gUnknown_8456618, 0, string);
|
||||
AddTextPrinterParameterized3(sTopBarWindowId, 0, -20 - width, 1, gUnknown_8456618, 0, string);
|
||||
if (copyToVram)
|
||||
CopyWindowToVram(sTopBarWindowId, 3);
|
||||
}
|
||||
@@ -213,22 +208,22 @@ void TopBarWindowPrintString(const u8 *string, u8 unused, bool8 copyToVram)
|
||||
|
||||
void TopBarWindowPrintTwoStrings(const u8 *string, const u8 *string2, bool8 fgColorChooser, u8 unused, bool8 copyToVram)
|
||||
{
|
||||
struct TextColor color;
|
||||
u8 color[3];
|
||||
s32 fgColor, width;
|
||||
|
||||
if ( sTopBarWindowId != 0xFF )
|
||||
{
|
||||
if (fgColorChooser)
|
||||
{
|
||||
color.fgColor = 0;
|
||||
color.bgColor = 1;
|
||||
color.shadowColor = 2;
|
||||
color[0] = 0;
|
||||
color[1] = 1;
|
||||
color[2] = 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
color.fgColor = 15;
|
||||
color.bgColor = 1;
|
||||
color.shadowColor = 2;
|
||||
color[0] = 15;
|
||||
color[1] = 1;
|
||||
color[2] = 2;
|
||||
}
|
||||
|
||||
PutWindowTilemap(sTopBarWindowId);
|
||||
@@ -236,9 +231,9 @@ void TopBarWindowPrintTwoStrings(const u8 *string, const u8 *string2, bool8 fgCo
|
||||
if (string2)
|
||||
{
|
||||
width = GetStringWidth(0, string2, 0);
|
||||
AddTextPrinterParameterized3(sTopBarWindowId, 0, -20 - width, 1, &color, 0, string2);
|
||||
AddTextPrinterParameterized3(sTopBarWindowId, 0, -20 - width, 1, color, 0, string2);
|
||||
}
|
||||
AddTextPrinterParameterized4(sTopBarWindowId, 1, 4, 1, 0, 0, &color, 0, string);
|
||||
AddTextPrinterParameterized4(sTopBarWindowId, 1, 4, 1, 0, 0, color, 0, string);
|
||||
if (copyToVram)
|
||||
CopyWindowToVram(sTopBarWindowId, 3);
|
||||
}
|
||||
|
||||
+77
-262
@@ -1,5 +1,6 @@
|
||||
#include "global.h"
|
||||
#include "text.h"
|
||||
#include "blit.h"
|
||||
#include "gpu_regs.h"
|
||||
#include "task.h"
|
||||
#include "wild_encounter.h"
|
||||
@@ -424,7 +425,7 @@ static const u8 gUnknown_845FD54[][5] = {
|
||||
[SPECIES_OLD_UNOWN_QMARK - 1] = {0x20, 0x23, 0x08, 0x20, 0x2d}
|
||||
};
|
||||
|
||||
void AddTextPrinterParameterized3(u8 windowId, u8 fontId, u8 x, u8 y, const struct TextColor * color, s8 speed, const u8 * str)
|
||||
void AddTextPrinterParameterized3(u8 windowId, u8 fontId, u8 x, u8 y, const u8 * color, s8 speed, const u8 * str)
|
||||
{
|
||||
struct TextPrinterTemplate printer;
|
||||
|
||||
@@ -438,13 +439,13 @@ void AddTextPrinterParameterized3(u8 windowId, u8 fontId, u8 x, u8 y, const stru
|
||||
printer.letterSpacing = GetFontAttribute(fontId, 2);
|
||||
printer.lineSpacing = GetFontAttribute(fontId, 3);
|
||||
printer.unk = 0;
|
||||
printer.fgColor = color->bgColor;
|
||||
printer.bgColor = color->fgColor;
|
||||
printer.shadowColor = color->shadowColor;
|
||||
printer.fgColor = color[1];
|
||||
printer.bgColor = color[0];
|
||||
printer.shadowColor = color[2];
|
||||
AddTextPrinter(&printer, speed, NULL);
|
||||
}
|
||||
|
||||
void AddTextPrinterParameterized4(u8 windowId, u8 fontId, u8 x, u8 y, u8 letterSpacing, u8 lineSpacing, const struct TextColor *color, s8 speed, const u8 *str)
|
||||
void AddTextPrinterParameterized4(u8 windowId, u8 fontId, u8 x, u8 y, u8 letterSpacing, u8 lineSpacing, const u8 *color, s8 speed, const u8 *str)
|
||||
{
|
||||
struct TextPrinterTemplate printer;
|
||||
|
||||
@@ -458,9 +459,9 @@ void AddTextPrinterParameterized4(u8 windowId, u8 fontId, u8 x, u8 y, u8 letterS
|
||||
printer.letterSpacing = letterSpacing;
|
||||
printer.lineSpacing = lineSpacing;
|
||||
printer.unk = 0;
|
||||
printer.fgColor = color->bgColor;
|
||||
printer.bgColor = color->fgColor;
|
||||
printer.shadowColor = color->shadowColor;
|
||||
printer.fgColor = color[1];
|
||||
printer.bgColor = color[0];
|
||||
printer.shadowColor = color[2];
|
||||
AddTextPrinter(&printer, speed, NULL);
|
||||
}
|
||||
|
||||
@@ -502,261 +503,75 @@ void sub_812E6DC(u8 windowId, const u8 * src, u16 x, u16 y)
|
||||
}
|
||||
}
|
||||
|
||||
// Yeah, no, I'm not bothering with this
|
||||
NAKED
|
||||
static void sub_812E768(void * a0, void * a1, u16 a2, u16 a3, u16 a4, u16 a5, u16 a6, u16 a7)
|
||||
static void sub_812E768(const struct Bitmap *src, struct Bitmap *dst, u16 srcX, u16 srcY, u16 dstX, u16 dstY, u16 width, u16 height)
|
||||
{
|
||||
asm_unified("\tpush {r4-r7,lr}\n"
|
||||
"\tmov r7, r10\n"
|
||||
"\tmov r6, r9\n"
|
||||
"\tmov r5, r8\n"
|
||||
"\tpush {r5-r7}\n"
|
||||
"\tsub sp, 0x28\n"
|
||||
"\tstr r0, [sp]\n"
|
||||
"\tstr r1, [sp, 0x4]\n"
|
||||
"\tldr r0, [sp, 0x48]\n"
|
||||
"\tldr r4, [sp, 0x4C]\n"
|
||||
"\tldr r1, [sp, 0x50]\n"
|
||||
"\tldr r5, [sp, 0x54]\n"
|
||||
"\tlsls r2, 16\n"
|
||||
"\tlsrs r2, 16\n"
|
||||
"\tstr r2, [sp, 0x8]\n"
|
||||
"\tlsls r3, 16\n"
|
||||
"\tlsrs r3, 16\n"
|
||||
"\tlsls r0, 16\n"
|
||||
"\tlsrs r0, 16\n"
|
||||
"\tstr r0, [sp, 0xC]\n"
|
||||
"\tlsls r4, 16\n"
|
||||
"\tlsrs r4, 16\n"
|
||||
"\tlsls r1, 16\n"
|
||||
"\tlsrs r1, 16\n"
|
||||
"\tlsls r5, 16\n"
|
||||
"\tlsrs r5, 16\n"
|
||||
"\tldr r2, [sp, 0x4]\n"
|
||||
"\tldrh r0, [r2, 0x4]\n"
|
||||
"\tldr r2, [sp, 0xC]\n"
|
||||
"\tsubs r0, r2\n"
|
||||
"\tldr r2, [sp, 0x8]\n"
|
||||
"\tadds r2, r1, r2\n"
|
||||
"\tstr r2, [sp, 0x10]\n"
|
||||
"\tcmp r0, r1\n"
|
||||
"\tbge _0812E7B4\n"
|
||||
"\tldr r1, [sp, 0x8]\n"
|
||||
"\tadds r0, r1\n"
|
||||
"\tstr r0, [sp, 0x10]\n"
|
||||
"_0812E7B4:\n"
|
||||
"\tldr r2, [sp, 0x4]\n"
|
||||
"\tldrh r1, [r2, 0x6]\n"
|
||||
"\tsubs r0, r1, r4\n"
|
||||
"\tcmp r0, r5\n"
|
||||
"\tbge _0812E7C6\n"
|
||||
"\tadds r0, r3, r1\n"
|
||||
"\tsubs r0, r4\n"
|
||||
"\tstr r0, [sp, 0x14]\n"
|
||||
"\tb _0812E7CA\n"
|
||||
"_0812E7C6:\n"
|
||||
"\tadds r5, r3, r5\n"
|
||||
"\tstr r5, [sp, 0x14]\n"
|
||||
"_0812E7CA:\n"
|
||||
"\tldr r0, [sp]\n"
|
||||
"\tldrh r1, [r0, 0x4]\n"
|
||||
"\tmovs r2, 0x7\n"
|
||||
"\tadds r0, r1, 0\n"
|
||||
"\tands r0, r2\n"
|
||||
"\tadds r1, r0\n"
|
||||
"\tasrs r1, 3\n"
|
||||
"\tstr r1, [sp, 0x18]\n"
|
||||
"\tldr r0, [sp, 0x4]\n"
|
||||
"\tldrh r1, [r0, 0x4]\n"
|
||||
"\tadds r0, r1, 0\n"
|
||||
"\tands r0, r2\n"
|
||||
"\tadds r1, r0\n"
|
||||
"\tasrs r1, 3\n"
|
||||
"\tstr r1, [sp, 0x1C]\n"
|
||||
"\tmov r12, r3\n"
|
||||
"\tmov r8, r4\n"
|
||||
"\tldr r1, [sp, 0x14]\n"
|
||||
"\tcmp r12, r1\n"
|
||||
"\tblt _0812E7F4\n"
|
||||
"\tb _0812E932\n"
|
||||
"_0812E7F4:\n"
|
||||
"\tldr r5, [sp, 0x8]\n"
|
||||
"\tldr r6, [sp, 0xC]\n"
|
||||
"\tmov r2, r12\n"
|
||||
"\tadds r2, 0x1\n"
|
||||
"\tstr r2, [sp, 0x20]\n"
|
||||
"\tmov r0, r8\n"
|
||||
"\tadds r0, 0x1\n"
|
||||
"\tstr r0, [sp, 0x24]\n"
|
||||
"\tldr r1, [sp, 0x10]\n"
|
||||
"\tcmp r5, r1\n"
|
||||
"\tblt _0812E80C\n"
|
||||
"\tb _0812E922\n"
|
||||
"_0812E80C:\n"
|
||||
"\tmovs r7, 0x1\n"
|
||||
"\tmovs r2, 0xF0\n"
|
||||
"\tmov r10, r2\n"
|
||||
"\tmovs r0, 0xF\n"
|
||||
"\tmov r9, r0\n"
|
||||
"_0812E816:\n"
|
||||
"\tasrs r0, r5, 1\n"
|
||||
"\tmovs r1, 0x3\n"
|
||||
"\tands r0, r1\n"
|
||||
"\tldr r2, [sp]\n"
|
||||
"\tldr r1, [r2]\n"
|
||||
"\tadds r1, r0\n"
|
||||
"\tasrs r0, r5, 3\n"
|
||||
"\tlsls r0, 5\n"
|
||||
"\tadds r1, r0\n"
|
||||
"\tmov r2, r12\n"
|
||||
"\tasrs r0, r2, 3\n"
|
||||
"\tldr r2, [sp, 0x18]\n"
|
||||
"\tmuls r0, r2\n"
|
||||
"\tlsls r0, 5\n"
|
||||
"\tadds r1, r0\n"
|
||||
"\tmov r2, r12\n"
|
||||
"\tlsls r0, r2, 29\n"
|
||||
"\tlsrs r0, 27\n"
|
||||
"\tadds r3, r1, r0\n"
|
||||
"\tasrs r0, r6, 1\n"
|
||||
"\tmovs r1, 0x3\n"
|
||||
"\tands r0, r1\n"
|
||||
"\tldr r2, [sp, 0x4]\n"
|
||||
"\tldr r1, [r2]\n"
|
||||
"\tadds r1, r0\n"
|
||||
"\tasrs r0, r6, 3\n"
|
||||
"\tlsls r0, 5\n"
|
||||
"\tadds r1, r0\n"
|
||||
"\tmov r2, r8\n"
|
||||
"\tasrs r0, r2, 3\n"
|
||||
"\tldr r2, [sp, 0x1C]\n"
|
||||
"\tmuls r0, r2\n"
|
||||
"\tlsls r0, 5\n"
|
||||
"\tadds r1, r0\n"
|
||||
"\tmov r2, r8\n"
|
||||
"\tlsls r0, r2, 29\n"
|
||||
"\tlsrs r0, 27\n"
|
||||
"\tadds r4, r1, r0\n"
|
||||
"\tadds r0, r4, 0\n"
|
||||
"\tands r0, r7\n"
|
||||
"\tcmp r0, 0\n"
|
||||
"\tbeq _0812E8C2\n"
|
||||
"\tsubs r4, 0x1\n"
|
||||
"\tadds r0, r6, 0\n"
|
||||
"\tands r0, r7\n"
|
||||
"\tcmp r0, 0\n"
|
||||
"\tbeq _0812E89A\n"
|
||||
"\tldrh r0, [r4]\n"
|
||||
"\tldr r2, _0812E88C @ =0x00000fff\n"
|
||||
"\tands r2, r0\n"
|
||||
"\tadds r0, r5, 0\n"
|
||||
"\tands r0, r7\n"
|
||||
"\tcmp r0, 0\n"
|
||||
"\tbeq _0812E890\n"
|
||||
"\tldrb r1, [r3]\n"
|
||||
"\tmov r0, r10\n"
|
||||
"\tands r0, r1\n"
|
||||
"\tlsls r0, 8\n"
|
||||
"\tb _0812E912\n"
|
||||
"\t.align 2, 0\n"
|
||||
"_0812E88C: .4byte 0x00000fff\n"
|
||||
"_0812E890:\n"
|
||||
"\tldrb r1, [r3]\n"
|
||||
"\tmov r0, r9\n"
|
||||
"\tands r0, r1\n"
|
||||
"\tlsls r0, 12\n"
|
||||
"\tb _0812E912\n"
|
||||
"_0812E89A:\n"
|
||||
"\tldrh r0, [r4]\n"
|
||||
"\tldr r2, _0812E8B4 @ =0x0000f0ff\n"
|
||||
"\tands r2, r0\n"
|
||||
"\tadds r0, r5, 0\n"
|
||||
"\tands r0, r7\n"
|
||||
"\tcmp r0, 0\n"
|
||||
"\tbeq _0812E8B8\n"
|
||||
"\tldrb r1, [r3]\n"
|
||||
"\tmov r0, r10\n"
|
||||
"\tands r0, r1\n"
|
||||
"\tlsls r0, 4\n"
|
||||
"\tb _0812E912\n"
|
||||
"\t.align 2, 0\n"
|
||||
"_0812E8B4: .4byte 0x0000f0ff\n"
|
||||
"_0812E8B8:\n"
|
||||
"\tldrb r1, [r3]\n"
|
||||
"\tmov r0, r9\n"
|
||||
"\tands r0, r1\n"
|
||||
"\tlsls r0, 8\n"
|
||||
"\tb _0812E912\n"
|
||||
"_0812E8C2:\n"
|
||||
"\tadds r0, r6, 0\n"
|
||||
"\tands r0, r7\n"
|
||||
"\tcmp r0, 0\n"
|
||||
"\tbeq _0812E8EE\n"
|
||||
"\tldrh r0, [r4]\n"
|
||||
"\tldr r2, _0812E8E0 @ =0x0000ff0f\n"
|
||||
"\tands r2, r0\n"
|
||||
"\tadds r0, r5, 0\n"
|
||||
"\tands r0, r7\n"
|
||||
"\tcmp r0, 0\n"
|
||||
"\tbeq _0812E8E4\n"
|
||||
"\tldrb r1, [r3]\n"
|
||||
"\tmov r0, r10\n"
|
||||
"\tb _0812E910\n"
|
||||
"\t.align 2, 0\n"
|
||||
"_0812E8E0: .4byte 0x0000ff0f\n"
|
||||
"_0812E8E4:\n"
|
||||
"\tldrb r1, [r3]\n"
|
||||
"\tmov r0, r9\n"
|
||||
"\tands r0, r1\n"
|
||||
"\tlsls r0, 4\n"
|
||||
"\tb _0812E912\n"
|
||||
"_0812E8EE:\n"
|
||||
"\tldrh r0, [r4]\n"
|
||||
"\tldr r2, _0812E908 @ =0x0000fff0\n"
|
||||
"\tands r2, r0\n"
|
||||
"\tadds r0, r5, 0\n"
|
||||
"\tands r0, r7\n"
|
||||
"\tcmp r0, 0\n"
|
||||
"\tbeq _0812E90C\n"
|
||||
"\tldrb r1, [r3]\n"
|
||||
"\tmov r0, r10\n"
|
||||
"\tands r0, r1\n"
|
||||
"\tlsrs r0, 4\n"
|
||||
"\tb _0812E912\n"
|
||||
"\t.align 2, 0\n"
|
||||
"_0812E908: .4byte 0x0000fff0\n"
|
||||
"_0812E90C:\n"
|
||||
"\tldrb r1, [r3]\n"
|
||||
"\tmov r0, r9\n"
|
||||
"_0812E910:\n"
|
||||
"\tands r0, r1\n"
|
||||
"_0812E912:\n"
|
||||
"\torrs r2, r0\n"
|
||||
"\tstrh r2, [r4]\n"
|
||||
"\tadds r5, 0x1\n"
|
||||
"\tadds r6, 0x1\n"
|
||||
"\tldr r0, [sp, 0x10]\n"
|
||||
"\tcmp r5, r0\n"
|
||||
"\tbge _0812E922\n"
|
||||
"\tb _0812E816\n"
|
||||
"_0812E922:\n"
|
||||
"\tldr r1, [sp, 0x20]\n"
|
||||
"\tmov r12, r1\n"
|
||||
"\tldr r2, [sp, 0x24]\n"
|
||||
"\tmov r8, r2\n"
|
||||
"\tldr r0, [sp, 0x14]\n"
|
||||
"\tcmp r12, r0\n"
|
||||
"\tbge _0812E932\n"
|
||||
"\tb _0812E7F4\n"
|
||||
"_0812E932:\n"
|
||||
"\tadd sp, 0x28\n"
|
||||
"\tpop {r3-r5}\n"
|
||||
"\tmov r8, r3\n"
|
||||
"\tmov r9, r4\n"
|
||||
"\tmov r10, r5\n"
|
||||
"\tpop {r4-r7}\n"
|
||||
"\tpop {r0}\n"
|
||||
"\tbx r0");
|
||||
s32 loopSrcY, loopDstY, loopSrcX, loopDstX, xEnd, yEnd, multiplierSrcY, multiplierDstY;
|
||||
u16 toOrr;
|
||||
const u8 *pixelsSrc;
|
||||
u16 *pixelsDst;
|
||||
|
||||
if (dst->width - dstX < width)
|
||||
xEnd = dst->width - dstX + srcX;
|
||||
else
|
||||
xEnd = width + srcX;
|
||||
|
||||
if (dst->height - dstY < height)
|
||||
yEnd = srcY + dst->height - dstY;
|
||||
else
|
||||
yEnd = srcY + height;
|
||||
multiplierSrcY = (src->width + (src->width & 7)) >> 3;
|
||||
multiplierDstY = (dst->width + (dst->width & 7)) >> 3;
|
||||
for (loopSrcY = srcY, loopDstY = dstY; loopSrcY < yEnd; loopSrcY++, loopDstY++)
|
||||
{
|
||||
for (loopSrcX = srcX, loopDstX = dstX; loopSrcX < xEnd; loopSrcX++, loopDstX++)
|
||||
{
|
||||
#ifndef NONMATCHING
|
||||
asm("":::"r4");
|
||||
#endif
|
||||
pixelsSrc = src->pixels + ((loopSrcX >> 1) & 3) + ((loopSrcX >> 3) << 5) + (((loopSrcY >> 3) * multiplierSrcY) << 5) + ((u32)(loopSrcY << 0x1d) >> 0x1B);
|
||||
pixelsDst = (u16 *)(dst->pixels + ((loopDstX >> 1) & 3) + ((loopDstX >> 3) << 5) + ((( loopDstY >> 3) * multiplierDstY) << 5) + ((u32)( loopDstY << 0x1d) >> 0x1B));
|
||||
|
||||
if ((uintptr_t)pixelsDst & 0x1)
|
||||
{
|
||||
pixelsDst = (void *)pixelsDst - 1;
|
||||
if (loopDstX & 0x1)
|
||||
{
|
||||
toOrr = *pixelsDst & 0x0fff;
|
||||
if (loopSrcX & 0x1)
|
||||
*pixelsDst = toOrr | ((*pixelsSrc & 0xf0) << 8);
|
||||
else
|
||||
*pixelsDst = toOrr | ((*pixelsSrc & 0x0f) << 12);
|
||||
}
|
||||
else
|
||||
{
|
||||
toOrr = *pixelsDst & 0xf0ff;
|
||||
if (loopSrcX & 0x1)
|
||||
*pixelsDst = toOrr | ((*pixelsSrc & 0xf0) << 4);
|
||||
else
|
||||
*pixelsDst = toOrr | ((*pixelsSrc & 0x0f) << 8);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (loopDstX & 1)
|
||||
{
|
||||
toOrr = *pixelsDst & 0xff0f;
|
||||
if (loopSrcX & 1)
|
||||
*pixelsDst = toOrr | ((*pixelsSrc & 0xf0) << 0);
|
||||
else
|
||||
*pixelsDst = toOrr | ((*pixelsSrc & 0x0f) << 4);
|
||||
}
|
||||
else
|
||||
{
|
||||
toOrr = *pixelsDst & 0xfff0;
|
||||
if (loopSrcX & 1)
|
||||
*pixelsDst = toOrr | ((*pixelsSrc & 0xf0) >> 4);
|
||||
else
|
||||
*pixelsDst = toOrr | ((*pixelsSrc & 0x0f) >> 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#define tEvA data[0]
|
||||
|
||||
+1
-1
@@ -95,7 +95,7 @@ u8 sub_80BF66C(void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool8 sub_80BF6A8(u16 itemId)
|
||||
bool8 itemid_link_can_give_berry(u16 itemId)
|
||||
{
|
||||
if (itemId != ITEM_ENIGMA_BERRY)
|
||||
return TRUE;
|
||||
|
||||
+8
-8
@@ -126,7 +126,7 @@ u8 sub_8143674(struct MEvent_Str_1 *mgr)
|
||||
resp = 2;
|
||||
if (mgr->status & 4)
|
||||
resp = 3;
|
||||
gUnknown_3003F84 = 0;
|
||||
gShouldAdvanceLinkState = 0;
|
||||
return resp;
|
||||
}
|
||||
|
||||
@@ -134,7 +134,7 @@ static void ResetTTDataBuffer(void)
|
||||
{
|
||||
memset(gDecompressionBuffer, 0, 0x2000);
|
||||
gLinkType = 0x5502;
|
||||
sub_8009804();
|
||||
OpenLink();
|
||||
SetSuppressLinkErrorMessage(TRUE);
|
||||
}
|
||||
|
||||
@@ -143,7 +143,7 @@ bool32 sub_81436EC(void)
|
||||
vu16 imeBak = REG_IME;
|
||||
u16 data[4];
|
||||
REG_IME = 0;
|
||||
*(u64 *)data = gSioMlt_Recv;
|
||||
*(u64 *)data = *(u64 *)gLink.tempRecvBuffer;
|
||||
REG_IME = imeBak;
|
||||
if ( data[0] == 0xB9A0
|
||||
&& data[1] == 0xCCD0
|
||||
@@ -156,7 +156,7 @@ bool32 sub_81436EC(void)
|
||||
|
||||
static bool32 IsEReaderConnectionSane(void)
|
||||
{
|
||||
if (sub_800AA48() && GetLinkPlayerCount_2() == 2)
|
||||
if (IsLinkMaster() && GetLinkPlayerCount_2() == 2)
|
||||
return TRUE;
|
||||
return FALSE;
|
||||
}
|
||||
@@ -171,7 +171,7 @@ u32 sub_8143770(u8 * r4, u16 * r5)
|
||||
switch (*r4)
|
||||
{
|
||||
case 0:
|
||||
if (sub_800AA48() && GetLinkPlayerCount_2() > 1)
|
||||
if (IsLinkMaster() && GetLinkPlayerCount_2() > 1)
|
||||
{
|
||||
*r4 = 1;
|
||||
;
|
||||
@@ -193,7 +193,7 @@ u32 sub_8143770(u8 * r4, u16 * r5)
|
||||
if (GetLinkPlayerCount_2() == 2)
|
||||
{
|
||||
PlaySE(SE_TOY_G);
|
||||
sub_800A5BC();
|
||||
CheckShouldAdvanceLinkState();
|
||||
*r5 = 0;
|
||||
*r4 = 3;
|
||||
}
|
||||
@@ -588,7 +588,7 @@ void DestroyWonderCard(void)
|
||||
ClearRamScript();
|
||||
sub_806E2D0();
|
||||
sub_806E370();
|
||||
sub_80E7524(gSaveBlock2Ptr->unk_4A0);
|
||||
sub_80E7524(gSaveBlock2Ptr->unk_B0.field_3F0);
|
||||
}
|
||||
|
||||
bool32 sub_8143F68(const struct MEventBuffer_32E0_Sub * data)
|
||||
@@ -769,7 +769,7 @@ void sub_81442CC(struct MEventStruct_Unk1442CC * data)
|
||||
data->unk_14 = 0;
|
||||
for (i = 0; i < 4; i++)
|
||||
data->unk_16[i] = gSaveBlock1Ptr->unk_3120.unk_338[i];
|
||||
CopyUnalignedWord(data->unk_4C, gSaveBlock2Ptr->playerTrainerId);
|
||||
CopyTrainerId(data->unk_4C, gSaveBlock2Ptr->playerTrainerId);
|
||||
StringCopy(data->unk_45, gSaveBlock2Ptr->playerName);
|
||||
for (i = 0; i < 6; i++)
|
||||
data->unk_50[i] = gSaveBlock1Ptr->unk2CA0[i];
|
||||
|
||||
+12
-12
@@ -61,7 +61,7 @@ void sub_81461D8(void);
|
||||
|
||||
extern const struct OamData gOamData_83AC9F8;
|
||||
|
||||
const struct TextColor gUnknown_8467068[] = {
|
||||
const u8 gUnknown_8467068[][3] = {
|
||||
{0, 2, 3},
|
||||
{0, 1, 2}
|
||||
};
|
||||
@@ -348,28 +348,28 @@ void sub_8145D18(u8 whichWindow)
|
||||
case 0:
|
||||
{
|
||||
s32 x;
|
||||
AddTextPrinterParameterized3(windowId, 3, 0, 1, &gUnknown_8467068[gUnknown_203F3C8->unk_0170->textPal1], 0, gUnknown_203F3C8->unk_018B);
|
||||
AddTextPrinterParameterized3(windowId, 3, 0, 1, gUnknown_8467068[gUnknown_203F3C8->unk_0170->textPal1], 0, gUnknown_203F3C8->unk_018B);
|
||||
x = 160 - GetStringWidth(3, gUnknown_203F3C8->unk_01B4, GetFontAttribute(3, 2));
|
||||
if (x < 0)
|
||||
x = 0;
|
||||
AddTextPrinterParameterized3(windowId, 3, x, 17, &gUnknown_8467068[gUnknown_203F3C8->unk_0170->textPal1], 0, gUnknown_203F3C8->unk_01B4);
|
||||
AddTextPrinterParameterized3(windowId, 3, x, 17, gUnknown_8467068[gUnknown_203F3C8->unk_0170->textPal1], 0, gUnknown_203F3C8->unk_01B4);
|
||||
if (gUnknown_203F3C8->unk_0000.unk_04 != 0)
|
||||
{
|
||||
AddTextPrinterParameterized3(windowId, 2, 166, 17, &gUnknown_8467068[gUnknown_203F3C8->unk_0170->textPal1], 0, gUnknown_203F3C8->unk_01DD);
|
||||
AddTextPrinterParameterized3(windowId, 2, 166, 17, gUnknown_8467068[gUnknown_203F3C8->unk_0170->textPal1], 0, gUnknown_203F3C8->unk_01DD);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
for (; sp0C < 4; sp0C++)
|
||||
{
|
||||
AddTextPrinterParameterized3(windowId, 3, 0, 16 * sp0C + 2, &gUnknown_8467068[gUnknown_203F3C8->unk_0170->textPal2], 0, gUnknown_203F3C8->unk_01E4[sp0C]);
|
||||
AddTextPrinterParameterized3(windowId, 3, 0, 16 * sp0C + 2, gUnknown_8467068[gUnknown_203F3C8->unk_0170->textPal2], 0, gUnknown_203F3C8->unk_01E4[sp0C]);
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
AddTextPrinterParameterized3(windowId, 3, 0, gUnknown_8467070[gUnknown_203F3C8->unk_0000.unk_08_0], &gUnknown_8467068[gUnknown_203F3C8->unk_0170->textPal3], 0, gUnknown_203F3C8->unk_0288);
|
||||
AddTextPrinterParameterized3(windowId, 3, 0, gUnknown_8467070[gUnknown_203F3C8->unk_0000.unk_08_0], gUnknown_8467068[gUnknown_203F3C8->unk_0170->textPal3], 0, gUnknown_203F3C8->unk_0288);
|
||||
if (gUnknown_203F3C8->unk_0000.unk_08_0 != 2)
|
||||
{
|
||||
AddTextPrinterParameterized3(windowId, 3, 0, 16 + gUnknown_8467070[gUnknown_203F3C8->unk_0000.unk_08_0], &gUnknown_8467068[gUnknown_203F3C8->unk_0170->textPal3], 0, gUnknown_203F3C8->unk_02B1);
|
||||
AddTextPrinterParameterized3(windowId, 3, 0, 16 + gUnknown_8467070[gUnknown_203F3C8->unk_0000.unk_08_0], gUnknown_8467068[gUnknown_203F3C8->unk_0170->textPal3], 0, gUnknown_203F3C8->unk_02B1);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -378,11 +378,11 @@ void sub_8145D18(u8 whichWindow)
|
||||
s32 spacing = GetFontAttribute(3, 2);
|
||||
for (; sp0C < gUnknown_203F3C8->unk_0175; sp0C++)
|
||||
{
|
||||
AddTextPrinterParameterized3(windowId, 3, x, y, &gUnknown_8467068[gUnknown_203F3C8->unk_0170->textPal3], 0, gUnknown_203F3C8->unk_02DC[sp0C].unk_01);
|
||||
AddTextPrinterParameterized3(windowId, 3, x, y, gUnknown_8467068[gUnknown_203F3C8->unk_0170->textPal3], 0, gUnknown_203F3C8->unk_02DC[sp0C].unk_01);
|
||||
if (gUnknown_203F3C8->unk_02DC[sp0C].unk_42[0] != EOS)
|
||||
{
|
||||
x += GetStringWidth(3, gUnknown_203F3C8->unk_02DC[sp0C].unk_01, spacing);
|
||||
AddTextPrinterParameterized3(windowId, 2, x, y, &gUnknown_8467068[gUnknown_203F3C8->unk_0170->textPal3], 0, gUnknown_203F3C8->unk_02DC[sp0C].unk_42);
|
||||
AddTextPrinterParameterized3(windowId, 2, x, y, gUnknown_8467068[gUnknown_203F3C8->unk_0170->textPal3], 0, gUnknown_203F3C8->unk_02DC[sp0C].unk_42);
|
||||
x += GetStringWidth(3, gUnknown_203F3C8->unk_02DC[sp0C].unk_42, spacing) + gUnknown_203F3C8->unk_02DC[sp0C].unk_00;
|
||||
}
|
||||
}
|
||||
@@ -471,7 +471,7 @@ void sub_8146980(void);
|
||||
void sub_8146A30(void);
|
||||
void sub_8146B58(void);
|
||||
|
||||
const struct TextColor gUnknown_8468038[] = {
|
||||
const u8 gUnknown_8468038[][3] = {
|
||||
{0, 2, 3},
|
||||
{0, 1, 2}
|
||||
};
|
||||
@@ -758,10 +758,10 @@ void sub_8146A30(void)
|
||||
x = (0xe0 - GetStringWidth(3, gUnknown_203F3CC->unk_01CE, GetFontAttribute(3, 2))) / 2;
|
||||
if (x < 0)
|
||||
x = 0;
|
||||
AddTextPrinterParameterized3(gUnknown_203F3CC->unk_01C8[0], 3, x, 6, &gUnknown_8468038[gUnknown_203F3CC->unk_01BC->textPal1], 0, gUnknown_203F3CC->unk_01CE);
|
||||
AddTextPrinterParameterized3(gUnknown_203F3CC->unk_01C8[0], 3, x, 6, gUnknown_8468038[gUnknown_203F3CC->unk_01BC->textPal1], 0, gUnknown_203F3CC->unk_01CE);
|
||||
for (; i < 10; ++i)
|
||||
{
|
||||
AddTextPrinterParameterized3(gUnknown_203F3CC->unk_01C8[1], 3, 0, 16 * i + 2, &gUnknown_8468038[gUnknown_203F3CC->unk_01BC->textPal2], 0, gUnknown_203F3CC->unk_01F7[i]);
|
||||
AddTextPrinterParameterized3(gUnknown_203F3CC->unk_01C8[1], 3, 0, 16 * i + 2, gUnknown_8468038[gUnknown_203F3CC->unk_01BC->textPal2], 0, gUnknown_203F3CC->unk_01F7[i]);
|
||||
}
|
||||
CopyWindowToVram(gUnknown_203F3CC->unk_01C8[0], 3);
|
||||
CopyWindowToVram(gUnknown_203F3CC->unk_01C8[1], 3);
|
||||
|
||||
+1
-1
@@ -226,7 +226,7 @@ static u32 ish_mainseq_4(struct mevent_client * svr)
|
||||
sub_8069EA4(svr->recvBuffer, 1000);
|
||||
break;
|
||||
case 18:
|
||||
memcpy(gSaveBlock2Ptr->unk_4A0, svr->recvBuffer, 0xbc);
|
||||
memcpy(gSaveBlock2Ptr->unk_B0.field_3F0, svr->recvBuffer, 0xbc);
|
||||
ValidateEReaderTrainer();
|
||||
break;
|
||||
case 21:
|
||||
|
||||
@@ -155,7 +155,7 @@ static bool32 mevent_send_func(struct mevent_srv_sub * svr)
|
||||
switch (svr->seqno)
|
||||
{
|
||||
case 0:
|
||||
if (sub_800A4BC())
|
||||
if (IsLinkTaskFinished())
|
||||
{
|
||||
header.ident = svr->sendIdent;
|
||||
header.size = svr->sendSize;
|
||||
@@ -167,7 +167,7 @@ static bool32 mevent_send_func(struct mevent_srv_sub * svr)
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
if (sub_800A4BC())
|
||||
if (IsLinkTaskFinished())
|
||||
{
|
||||
if (mevent_has_received(svr->sendPlayerNo))
|
||||
{
|
||||
@@ -189,7 +189,7 @@ static bool32 mevent_send_func(struct mevent_srv_sub * svr)
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
if (sub_800A4BC())
|
||||
if (IsLinkTaskFinished())
|
||||
{
|
||||
if (CalcCRC16WithTable(svr->sendBfr, svr->sendSize) != svr->sendCRC)
|
||||
sub_80FA190();
|
||||
|
||||
@@ -281,7 +281,7 @@ bool8 MEScrCmd_givepokemon(struct ScriptContext *ctx)
|
||||
bool8 MEScrCmd_addtrainer(struct ScriptContext *ctx)
|
||||
{
|
||||
u32 data = ScriptReadWord(ctx) - ctx->data[1] + ctx->data[0];
|
||||
memcpy(gSaveBlock2Ptr->unk_4A0, (void *)data, 0xBC);
|
||||
memcpy(gSaveBlock2Ptr->unk_B0.field_3F0, (void *)data, 0xBC);
|
||||
ValidateEReaderTrainer();
|
||||
StringExpandPlaceholders(gStringVar4, gText_MysteryGiftNewTrainer);
|
||||
ctx->data[2] = 2;
|
||||
|
||||
+12
-12
@@ -409,9 +409,9 @@ const u8 *const Unref_08366ED8[] = {
|
||||
gText_ReturnToTitle
|
||||
};
|
||||
|
||||
ALIGNED(4) const struct TextColor sMG_Ereader_TextColor_1 = { 0, 1, 2 };
|
||||
ALIGNED(4) const struct TextColor sMG_Ereader_TextColor_1_Copy = { 0, 1, 2 };
|
||||
ALIGNED(4) const struct TextColor sMG_Ereader_TextColor_2 = { 1, 2, 3 };
|
||||
ALIGNED(4) const u8 sMG_Ereader_TextColor_1[3] = { 0, 1, 2 };
|
||||
ALIGNED(4) const u8 sMG_Ereader_TextColor_1_Copy[3] = { 0, 1, 2 };
|
||||
ALIGNED(4) const u8 sMG_Ereader_TextColor_2[3] = { 1, 2, 3 };
|
||||
|
||||
const u8 gUnknown_8466EF3[] = _("テスト");
|
||||
const u8 gUnknown_8466EF7[] = _("むげんのチケット");
|
||||
@@ -538,14 +538,14 @@ void PrintMysteryGiftOrEReaderTopMenu(bool8 mg_or_ereader, bool32 usePickOkCance
|
||||
if (!mg_or_ereader)
|
||||
{
|
||||
src = usePickOkCancel == TRUE ? gText_PickOKExit : gText_PickOKCancel;
|
||||
AddTextPrinterParameterized4(0, 2, 2, 2, 0, 0, &sMG_Ereader_TextColor_1, 0, gText_MysteryGift);
|
||||
AddTextPrinterParameterized4(0, 2, 2, 2, 0, 0, sMG_Ereader_TextColor_1, 0, gText_MysteryGift);
|
||||
width = 222 - GetStringWidth(0, src, 0);
|
||||
AddTextPrinterParameterized4(0, 0, width, 2, 0, 0, &sMG_Ereader_TextColor_1, 0, src);
|
||||
AddTextPrinterParameterized4(0, 0, width, 2, 0, 0, sMG_Ereader_TextColor_1, 0, src);
|
||||
}
|
||||
else
|
||||
{
|
||||
AddTextPrinterParameterized4(0, 2, 2, 2, 0, 0, &sMG_Ereader_TextColor_1, 0, gJPText_MysteryGift);
|
||||
AddTextPrinterParameterized4(0, 0, 0x78, 2, 0, 0, &sMG_Ereader_TextColor_1, 0, gJPText_DecideStop);
|
||||
AddTextPrinterParameterized4(0, 2, 2, 2, 0, 0, sMG_Ereader_TextColor_1, 0, gJPText_MysteryGift);
|
||||
AddTextPrinterParameterized4(0, 0, 0x78, 2, 0, 0, sMG_Ereader_TextColor_1, 0, gJPText_DecideStop);
|
||||
}
|
||||
CopyWindowToVram(0, 2);
|
||||
PutWindowTilemap(0);
|
||||
@@ -596,7 +596,7 @@ void AddTextPrinterToWindow1(const u8 *str)
|
||||
{
|
||||
StringExpandPlaceholders(gStringVar4, str);
|
||||
FillWindowPixelBuffer(1, 0x11);
|
||||
AddTextPrinterParameterized4(1, 2, 0, 2, 0, 2, &sMG_Ereader_TextColor_2, 0, gStringVar4);
|
||||
AddTextPrinterParameterized4(1, 2, 0, 2, 0, 2, sMG_Ereader_TextColor_2, 0, gStringVar4);
|
||||
DrawTextBorderOuter(1, 0x001, 0xF);
|
||||
PutWindowTilemap(1);
|
||||
CopyWindowToVram(1, 3);
|
||||
@@ -737,7 +737,7 @@ s8 mevent_message_print_and_prompt_yes_no(u8 * textState, u16 * windowId, bool8
|
||||
*windowId = AddWindow(&sWindowTemplate_PromptYesOrNo_Width20);
|
||||
}
|
||||
FillWindowPixelBuffer(*windowId, 0x11);
|
||||
AddTextPrinterParameterized4(*windowId, 2, 0, 2, 0, 2, &sMG_Ereader_TextColor_2, 0, gStringVar4);
|
||||
AddTextPrinterParameterized4(*windowId, 2, 0, 2, 0, 2, sMG_Ereader_TextColor_2, 0, gStringVar4);
|
||||
DrawTextBorderOuter(*windowId, 0x001, 0x0F);
|
||||
CopyWindowToVram(*windowId, 2);
|
||||
PutWindowTilemap(*windowId);
|
||||
@@ -798,7 +798,7 @@ s32 HandleMysteryGiftListMenu(u8 * textState, u16 * windowId, bool32 cannotToss,
|
||||
}
|
||||
*windowId = AddWindow(&sMysteryGiftMenuWindowTemplate);
|
||||
FillWindowPixelBuffer(*windowId, 0x11);
|
||||
AddTextPrinterParameterized4(*windowId, 2, 0, 2, 0, 2, &sMG_Ereader_TextColor_2, 0, gStringVar4);
|
||||
AddTextPrinterParameterized4(*windowId, 2, 0, 2, 0, 2, sMG_Ereader_TextColor_2, 0, gStringVar4);
|
||||
DrawTextBorderOuter(*windowId, 0x001, 0x0F);
|
||||
CopyWindowToVram(*windowId, 2);
|
||||
PutWindowTilemap(*windowId);
|
||||
@@ -1436,7 +1436,7 @@ void task00_mystery_gift(u8 taskId)
|
||||
}
|
||||
break;
|
||||
case 13:
|
||||
if (IsNoOneConnected())
|
||||
if (IsRfuTaskFinished())
|
||||
{
|
||||
DestroyWirelessStatusIndicatorSprite();
|
||||
data->state = 14;
|
||||
@@ -1712,7 +1712,7 @@ void task00_mystery_gift(u8 taskId)
|
||||
data->state = 34;
|
||||
break;
|
||||
case 34:
|
||||
if (IsNoOneConnected())
|
||||
if (IsRfuTaskFinished())
|
||||
{
|
||||
DestroyWirelessStatusIndicatorSprite();
|
||||
data->state = 35;
|
||||
|
||||
+161
@@ -0,0 +1,161 @@
|
||||
#include "global.h"
|
||||
#include "new_game.h"
|
||||
#include "random.h"
|
||||
#include "main.h"
|
||||
#include "overworld.h"
|
||||
#include "constants/maps.h"
|
||||
#include "load_save.h"
|
||||
#include "item_menu.h"
|
||||
#include "tm_case.h"
|
||||
#include "berry_pouch.h"
|
||||
#include "quest_log.h"
|
||||
#include "wild_encounter.h"
|
||||
#include "event_data.h"
|
||||
#include "string_util.h"
|
||||
#include "mail_data.h"
|
||||
#include "play_time.h"
|
||||
#include "money.h"
|
||||
#include "battle_records.h"
|
||||
#include "pokemon_size_record.h"
|
||||
#include "pokemon_storage_system.h"
|
||||
#include "roamer.h"
|
||||
#include "item.h"
|
||||
#include "player_pc.h"
|
||||
#include "berry.h"
|
||||
#include "easy_chat.h"
|
||||
#include "union_room_chat.h"
|
||||
#include "mevent.h"
|
||||
#include "trainer_tower.h"
|
||||
#include "script.h"
|
||||
#include "berry_powder.h"
|
||||
#include "pokemon_jump.h"
|
||||
#include "event_scripts.h"
|
||||
|
||||
// this file's functions
|
||||
static void ResetMiniGamesResults(void);
|
||||
|
||||
// EWRAM vars
|
||||
EWRAM_DATA bool8 gDifferentSaveFile = FALSE;
|
||||
|
||||
void SetTrainerId(u32 trainerId, u8 *dst)
|
||||
{
|
||||
dst[0] = trainerId;
|
||||
dst[1] = trainerId >> 8;
|
||||
dst[2] = trainerId >> 16;
|
||||
dst[3] = trainerId >> 24;
|
||||
}
|
||||
|
||||
void CopyTrainerId(u8 *dst, u8 *src)
|
||||
{
|
||||
s32 i;
|
||||
for (i = 0; i < 4; i++)
|
||||
dst[i] = src[i];
|
||||
}
|
||||
|
||||
static void InitPlayerTrainerId(void)
|
||||
{
|
||||
u32 trainerId = (Random() << 0x10) | GetGeneratedTrainerIdLower();
|
||||
SetTrainerId(trainerId, gSaveBlock2Ptr->playerTrainerId);
|
||||
}
|
||||
|
||||
static void SetDefaultOptions(void)
|
||||
{
|
||||
gSaveBlock2Ptr->optionsTextSpeed = OPTIONS_TEXT_SPEED_MID;
|
||||
gSaveBlock2Ptr->optionsWindowFrameType = 0;
|
||||
gSaveBlock2Ptr->optionsSound = OPTIONS_SOUND_MONO;
|
||||
gSaveBlock2Ptr->optionsBattleStyle = OPTIONS_BATTLE_STYLE_SHIFT;
|
||||
gSaveBlock2Ptr->optionsBattleSceneOff = FALSE;
|
||||
gSaveBlock2Ptr->regionMapZoom = FALSE;
|
||||
gSaveBlock2Ptr->optionsButtonMode = OPTIONS_BUTTON_MODE_NORMAL;
|
||||
}
|
||||
|
||||
static void ClearPokedexFlags(void)
|
||||
{
|
||||
memset(&gSaveBlock2Ptr->pokedex.owned, 0, sizeof(gSaveBlock2Ptr->pokedex.owned));
|
||||
memset(&gSaveBlock2Ptr->pokedex.seen, 0, sizeof(gSaveBlock2Ptr->pokedex.seen));
|
||||
}
|
||||
|
||||
static void sub_80549D4(void)
|
||||
{
|
||||
CpuFill32(0, &gSaveBlock2Ptr->unk_B0, sizeof(gSaveBlock2Ptr->unk_B0));
|
||||
}
|
||||
|
||||
static void WarpToPlayersRoom(void)
|
||||
{
|
||||
SetWarpDestination(MAP_GROUP(PALLET_TOWN_PLAYERS_HOUSE_2F), MAP_NUM(PALLET_TOWN_PLAYERS_HOUSE_2F), -1, 6, 6);
|
||||
WarpIntoMap();
|
||||
}
|
||||
|
||||
void Sav2_ClearSetDefault(void)
|
||||
{
|
||||
ClearSav2();
|
||||
SetDefaultOptions();
|
||||
}
|
||||
|
||||
void ResetMenuAndMonGlobals(void)
|
||||
{
|
||||
gDifferentSaveFile = FALSE;
|
||||
ZeroPlayerPartyMons();
|
||||
ZeroEnemyPartyMons();
|
||||
sub_81089BC();
|
||||
ResetTMCaseCursorPos();
|
||||
BerryPouch_CursorResetToTop();
|
||||
sub_811089C();
|
||||
sub_8083214(Random());
|
||||
sub_806E6FC();
|
||||
}
|
||||
|
||||
void NewGameInitData(void)
|
||||
{
|
||||
u8 rivalName[PLAYER_NAME_LENGTH];
|
||||
|
||||
StringCopy(rivalName, gSaveBlock1Ptr->rivalName);
|
||||
gDifferentSaveFile = TRUE;
|
||||
gSaveBlock2Ptr->encryptionKey = 0;
|
||||
ZeroPlayerPartyMons();
|
||||
ZeroEnemyPartyMons();
|
||||
sub_80549D4();
|
||||
ClearSav1();
|
||||
ClearMailData();
|
||||
gSaveBlock2Ptr->specialSaveWarpFlags = 0;
|
||||
gSaveBlock2Ptr->field_A8 = 0;
|
||||
gSaveBlock2Ptr->field_AC = 1;
|
||||
gSaveBlock2Ptr->field_AD = 0;
|
||||
InitPlayerTrainerId();
|
||||
PlayTimeCounter_Reset();
|
||||
ClearPokedexFlags();
|
||||
InitEventData();
|
||||
ResetFameChecker();
|
||||
SetMoney(&gSaveBlock1Ptr->money, 3000);
|
||||
ResetGameStats();
|
||||
ClearPlayerLinkBattleRecords();
|
||||
sub_80A0904();
|
||||
sub_80A0958();
|
||||
sub_806E190();
|
||||
gPlayerPartyCount = 0;
|
||||
ZeroPlayerPartyMons();
|
||||
ResetPokemonStorageSystem();
|
||||
ClearRoamerData();
|
||||
gSaveBlock1Ptr->registeredItem = 0;
|
||||
ClearBag();
|
||||
NewGameInitPCItems();
|
||||
sub_809C794();
|
||||
InitEasyChatPhrases();
|
||||
sub_8113044();
|
||||
copy_strings_to_sav1();
|
||||
ResetMiniGamesResults();
|
||||
sub_8143D24();
|
||||
sub_815D838();
|
||||
WarpToPlayersRoom();
|
||||
ScriptContext2_RunNewScript(EventScript_ResetAllMapFlags);
|
||||
StringCopy(gSaveBlock1Ptr->rivalName, rivalName);
|
||||
ResetTrainerTowerResults();
|
||||
}
|
||||
|
||||
static void ResetMiniGamesResults(void)
|
||||
{
|
||||
CpuFill16(0, &gSaveBlock2Ptr->berryCrush, sizeof(struct BerryCrush));
|
||||
SetBerryPowder(&gSaveBlock2Ptr->berryCrush.berryPowderAmount, 0);
|
||||
ResetPokeJumpResults();
|
||||
CpuFill16(0, &gSaveBlock2Ptr->berryPick, sizeof(struct BerryPickingResults));
|
||||
}
|
||||
+15
-15
@@ -37,7 +37,7 @@ struct OakSpeechResources
|
||||
u16 unk_0010;
|
||||
u16 unk_0012;
|
||||
u16 unk_0014[4];
|
||||
struct TextColor textColor;
|
||||
u8 textColor[3];
|
||||
u8 textSpeed;
|
||||
u8 filler_0020[0x1800];
|
||||
u8 bg2TilemapBuffer[0x400];
|
||||
@@ -273,11 +273,11 @@ static const struct WindowTemplate sNewGameAdventureIntroWindowTemplates[] = {
|
||||
}, DUMMY_WIN_TEMPLATE
|
||||
};
|
||||
|
||||
ALIGNED(4) const struct TextColor sTextColor_HelpSystem = {
|
||||
const u8 sTextColor_HelpSystem[4] = {
|
||||
0x00, 0x01, 0x02
|
||||
};
|
||||
|
||||
ALIGNED(4) const struct TextColor sTextColor_OakSpeech = {
|
||||
const u8 sTextColor_OakSpeech[4] = {
|
||||
0x00, 0x02, 0x03
|
||||
};
|
||||
|
||||
@@ -576,7 +576,7 @@ static void CreateHelpDocsPage1(void)
|
||||
sOakSpeechResources->unk_0014[0] = AddWindow(sHelpDocsWindowTemplatePtrs[sOakSpeechResources->unk_0012]);
|
||||
PutWindowTilemap(sOakSpeechResources->unk_0014[0]);
|
||||
FillWindowPixelBuffer(sOakSpeechResources->unk_0014[0], 0x00);
|
||||
AddTextPrinterParameterized4(sOakSpeechResources->unk_0014[0], 2, 2, 0, 1, 1, &sTextColor_HelpSystem, 0, gNewGame_HelpDocs1);
|
||||
AddTextPrinterParameterized4(sOakSpeechResources->unk_0014[0], 2, 2, 0, 1, 1, sTextColor_HelpSystem, 0, gNewGame_HelpDocs1);
|
||||
CopyWindowToVram(sOakSpeechResources->unk_0014[0], 3);
|
||||
FillBgTilemapBufferRect_Palette0(1, 0x3000, 1, 3, 5, 16);
|
||||
CopyBgTilemapBufferToVram(1);
|
||||
@@ -598,7 +598,7 @@ static void Task_OakSpeech4(u8 taskId)
|
||||
sOakSpeechResources->unk_0014[i] = AddWindow(&sHelpDocsWindowTemplatePtrs[sOakSpeechResources->unk_0012][i]);
|
||||
PutWindowTilemap(sOakSpeechResources->unk_0014[i]);
|
||||
FillWindowPixelBuffer(sOakSpeechResources->unk_0014[i], 0x00);
|
||||
AddTextPrinterParameterized4(sOakSpeechResources->unk_0014[i], 2, 6, 0, 1, 1, &sTextColor_HelpSystem, 0, sHelpDocsPtrs[i + r7 * 3]);
|
||||
AddTextPrinterParameterized4(sOakSpeechResources->unk_0014[i], 2, 6, 0, 1, 1, sTextColor_HelpSystem, 0, sHelpDocsPtrs[i + r7 * 3]);
|
||||
CopyWindowToVram(sOakSpeechResources->unk_0014[i], 3);
|
||||
}
|
||||
|
||||
@@ -730,7 +730,7 @@ static void Task_OakSpeech6(u8 taskId)
|
||||
sOakSpeechResources->unk_0012 = 0;
|
||||
gMain.state = 0;
|
||||
data[15] = 16;
|
||||
AddTextPrinterParameterized4(data[14], 2, 3, 5, 1, 0, &sTextColor_OakSpeech, 0, sNewGameAdventureIntroTextPointers[0]);
|
||||
AddTextPrinterParameterized4(data[14], 2, 3, 5, 1, 0, sTextColor_OakSpeech, 0, sNewGameAdventureIntroTextPointers[0]);
|
||||
data[5] = CreateTextCursorSpriteForOakSpeech(0, 0xe2, 0x91, 0, 0);
|
||||
gSprites[data[5]].oam.objMode = ST_OAM_OBJ_BLEND;
|
||||
gSprites[data[5]].oam.priority = 0;
|
||||
@@ -790,7 +790,7 @@ static void Task_OakSpeech7(u8 taskId)
|
||||
if (data[15] <= 0)
|
||||
{
|
||||
FillWindowPixelBuffer(data[14], 0x00);
|
||||
AddTextPrinterParameterized4(data[14], 2, 3, 5, 1, 0, &sTextColor_OakSpeech, 0, sNewGameAdventureIntroTextPointers[sOakSpeechResources->unk_0012]);
|
||||
AddTextPrinterParameterized4(data[14], 2, 3, 5, 1, 0, sTextColor_OakSpeech, 0, sNewGameAdventureIntroTextPointers[sOakSpeechResources->unk_0012]);
|
||||
if (sOakSpeechResources->unk_0012 == 0)
|
||||
{
|
||||
ClearTopBarWindow();
|
||||
@@ -1056,14 +1056,14 @@ static void Task_OakSpeech19(u8 taskId)
|
||||
PutWindowTilemap(gTasks[taskId].data[13]);
|
||||
DrawStdFrameWithCustomTileAndPalette(gTasks[taskId].data[13], 1, GetStdWindowBaseTileNum(), 14);
|
||||
FillWindowPixelBuffer(gTasks[taskId].data[13], 0x11);
|
||||
sOakSpeechResources->textColor.fgColor = 1;
|
||||
sOakSpeechResources->textColor.bgColor = 2;
|
||||
sOakSpeechResources->textColor.shadowColor = 3;
|
||||
AddTextPrinterParameterized3(gTasks[taskId].data[13], 2, 8, 1, &sOakSpeechResources->textColor, 0, gText_Boy);
|
||||
sOakSpeechResources->textColor.fgColor = 1;
|
||||
sOakSpeechResources->textColor.bgColor = 2;
|
||||
sOakSpeechResources->textColor.shadowColor = 3;
|
||||
AddTextPrinterParameterized3(gTasks[taskId].data[13], 2, 8, 17, &sOakSpeechResources->textColor, 0, gText_Girl);
|
||||
sOakSpeechResources->textColor[0] = 1;
|
||||
sOakSpeechResources->textColor[1] = 2;
|
||||
sOakSpeechResources->textColor[2] = 3;
|
||||
AddTextPrinterParameterized3(gTasks[taskId].data[13], 2, 8, 1, sOakSpeechResources->textColor, 0, gText_Boy);
|
||||
sOakSpeechResources->textColor[0] = 1;
|
||||
sOakSpeechResources->textColor[1] = 2;
|
||||
sOakSpeechResources->textColor[2] = 3;
|
||||
AddTextPrinterParameterized3(gTasks[taskId].data[13], 2, 8, 17, sOakSpeechResources->textColor, 0, gText_Girl);
|
||||
Menu_InitCursor(gTasks[taskId].data[13], 2, 0, 1, GetFontAttribute(2, 1) + 2, 2, 0);
|
||||
CopyWindowToVram(gTasks[taskId].data[13], 3);
|
||||
gTasks[taskId].func = Task_OakSpeech20;
|
||||
|
||||
+989
@@ -0,0 +1,989 @@
|
||||
#include "global.h"
|
||||
#include "palette.h"
|
||||
#include "util.h"
|
||||
#include "decompress.h"
|
||||
#include "gpu_regs.h"
|
||||
#include "task.h"
|
||||
|
||||
enum
|
||||
{
|
||||
NORMAL_FADE,
|
||||
FAST_FADE,
|
||||
HARDWARE_FADE,
|
||||
};
|
||||
|
||||
#define NUM_PALETTE_STRUCTS 16
|
||||
|
||||
// unused palette struct
|
||||
struct PaletteStructTemplate
|
||||
{
|
||||
u16 uid;
|
||||
u16 *src;
|
||||
u16 pst_field_8_0:1;
|
||||
u16 pst_field_8_1:9;
|
||||
u16 size:5;
|
||||
u16 pst_field_9_7:1;
|
||||
u8 pst_field_A;
|
||||
u8 srcCount:5;
|
||||
u8 pst_field_B_5:3;
|
||||
u8 pst_field_C;
|
||||
};
|
||||
|
||||
struct PaletteStruct
|
||||
{
|
||||
const struct PaletteStructTemplate *base;
|
||||
u32 ps_field_4_0:1;
|
||||
u16 ps_field_4_1:1;
|
||||
u32 baseDestOffset:9;
|
||||
u16 destOffset:10;
|
||||
u16 srcIndex:7;
|
||||
u8 ps_field_8;
|
||||
u8 ps_field_9;
|
||||
};
|
||||
|
||||
static void sub_8070790(struct PaletteStruct *, u32 *);
|
||||
static void sub_80708F4(struct PaletteStruct *, u32 *);
|
||||
static void sub_80709B4(struct PaletteStruct *);
|
||||
static u8 GetPaletteNumByUid(u16);
|
||||
static u8 UpdateNormalPaletteFade(void);
|
||||
static void BeginFastPaletteFadeInternal(u8);
|
||||
static u8 UpdateFastPaletteFade(void);
|
||||
static u8 UpdateHardwarePaletteFade(void);
|
||||
static void UpdateBlendRegisters(void);
|
||||
static bool8 IsSoftwarePaletteFadeFinishing(void);
|
||||
static void sub_80718B8(u8 taskId);
|
||||
|
||||
ALIGNED(4) EWRAM_DATA u16 gPlttBufferUnfaded[PLTT_BUFFER_SIZE] = {0};
|
||||
ALIGNED(4) EWRAM_DATA u16 gPlttBufferFaded[PLTT_BUFFER_SIZE] = {0};
|
||||
static EWRAM_DATA struct PaletteStruct sPaletteStructs[NUM_PALETTE_STRUCTS] = {0};
|
||||
EWRAM_DATA struct PaletteFadeControl gPaletteFade = {0};
|
||||
static EWRAM_DATA u32 sPlttBufferTransferPending = 0;
|
||||
EWRAM_DATA u8 gPaletteDecompressionBuffer[PLTT_DECOMP_BUFFER_SIZE] = {0};
|
||||
|
||||
static const struct PaletteStructTemplate gDummyPaletteStructTemplate =
|
||||
{
|
||||
.uid = 0xFFFF,
|
||||
.pst_field_B_5 = 1
|
||||
};
|
||||
|
||||
static const u8 sRoundedDownGrayscaleMap[] =
|
||||
{
|
||||
0, 0, 0, 0, 0,
|
||||
5, 5, 5, 5, 5,
|
||||
11, 11, 11, 11, 11,
|
||||
16, 16, 16, 16, 16,
|
||||
21, 21, 21, 21, 21,
|
||||
27, 27, 27, 27, 27,
|
||||
31, 31
|
||||
};
|
||||
|
||||
void LoadCompressedPalette(const u32 *src, u16 offset, u16 size)
|
||||
{
|
||||
LZDecompressWram(src, gPaletteDecompressionBuffer);
|
||||
CpuCopy16(gPaletteDecompressionBuffer, gPlttBufferUnfaded + offset, size);
|
||||
CpuCopy16(gPaletteDecompressionBuffer, gPlttBufferFaded + offset, size);
|
||||
}
|
||||
|
||||
void LoadPalette(const void *src, u16 offset, u16 size)
|
||||
{
|
||||
CpuCopy16(src, gPlttBufferUnfaded + offset, size);
|
||||
CpuCopy16(src, gPlttBufferFaded + offset, size);
|
||||
}
|
||||
|
||||
void FillPalette(u16 value, u16 offset, u16 size)
|
||||
{
|
||||
CpuFill16(value, gPlttBufferUnfaded + offset, size);
|
||||
CpuFill16(value, gPlttBufferFaded + offset, size);
|
||||
}
|
||||
|
||||
void TransferPlttBuffer(void)
|
||||
{
|
||||
if (!gPaletteFade.bufferTransferDisabled)
|
||||
{
|
||||
void *src = gPlttBufferFaded;
|
||||
void *dest = (void *)PLTT;
|
||||
DmaCopy16(3, src, dest, PLTT_SIZE);
|
||||
sPlttBufferTransferPending = 0;
|
||||
if (gPaletteFade.mode == HARDWARE_FADE && gPaletteFade.active)
|
||||
UpdateBlendRegisters();
|
||||
}
|
||||
}
|
||||
|
||||
u8 UpdatePaletteFade(void)
|
||||
{
|
||||
u8 result;
|
||||
u8 dummy = 0;
|
||||
|
||||
if (sPlttBufferTransferPending)
|
||||
return PALETTE_FADE_STATUS_LOADING;
|
||||
if (gPaletteFade.mode == NORMAL_FADE)
|
||||
result = UpdateNormalPaletteFade();
|
||||
else if (gPaletteFade.mode == FAST_FADE)
|
||||
result = UpdateFastPaletteFade();
|
||||
else
|
||||
result = UpdateHardwarePaletteFade();
|
||||
sPlttBufferTransferPending = gPaletteFade.multipurpose1 | dummy;
|
||||
return result;
|
||||
}
|
||||
|
||||
void ResetPaletteFade(void)
|
||||
{
|
||||
u8 i;
|
||||
|
||||
for (i = 0; i < 16; ++i)
|
||||
ResetPaletteStruct(i);
|
||||
ResetPaletteFadeControl();
|
||||
}
|
||||
|
||||
void ReadPlttIntoBuffers(void)
|
||||
{
|
||||
u16 i;
|
||||
u16 *pltt = (u16 *)PLTT;
|
||||
|
||||
for (i = 0; i < PLTT_SIZE / 2; ++i)
|
||||
{
|
||||
gPlttBufferUnfaded[i] = pltt[i];
|
||||
gPlttBufferFaded[i] = pltt[i];
|
||||
}
|
||||
}
|
||||
|
||||
bool8 BeginNormalPaletteFade(u32 selectedPalettes, s8 delay, u8 startY, u8 targetY, u16 blendColor)
|
||||
{
|
||||
u8 temp;
|
||||
u16 color = blendColor;
|
||||
|
||||
if (gPaletteFade.active)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
gPaletteFade.deltaY = 2;
|
||||
if (delay < 0)
|
||||
{
|
||||
gPaletteFade.deltaY += (delay * -1);
|
||||
delay = 0;
|
||||
}
|
||||
gPaletteFade_selectedPalettes = selectedPalettes;
|
||||
gPaletteFade.delayCounter = delay;
|
||||
gPaletteFade_delay = delay;
|
||||
gPaletteFade.y = startY;
|
||||
gPaletteFade.targetY = targetY;
|
||||
gPaletteFade.blendColor = color;
|
||||
gPaletteFade.active = TRUE;
|
||||
gPaletteFade.mode = NORMAL_FADE;
|
||||
if (startY < targetY)
|
||||
gPaletteFade.yDec = FALSE;
|
||||
else
|
||||
gPaletteFade.yDec = TRUE;
|
||||
UpdatePaletteFade();
|
||||
temp = gPaletteFade.bufferTransferDisabled;
|
||||
gPaletteFade.bufferTransferDisabled = FALSE;
|
||||
CpuCopy32(gPlttBufferFaded, (void *)PLTT, PLTT_SIZE);
|
||||
sPlttBufferTransferPending = 0;
|
||||
if (gPaletteFade.mode == HARDWARE_FADE && gPaletteFade.active)
|
||||
UpdateBlendRegisters();
|
||||
gPaletteFade.bufferTransferDisabled = temp;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
// not used
|
||||
static bool8 sub_80706D0(u32 a1, u8 a2, u8 a3, u8 a4, u16 a5)
|
||||
{
|
||||
ReadPlttIntoBuffers();
|
||||
return BeginNormalPaletteFade(a1, a2, a3, a4, a5);
|
||||
}
|
||||
|
||||
// not used
|
||||
static void sub_8070718(u8 a1, u32 *a2)
|
||||
{
|
||||
u8 i;
|
||||
|
||||
for (i = 0; i < NUM_PALETTE_STRUCTS; ++i)
|
||||
{
|
||||
struct PaletteStruct *palstruct = &sPaletteStructs[i];
|
||||
|
||||
if (palstruct->ps_field_4_0)
|
||||
{
|
||||
if (palstruct->base->pst_field_8_0 == a1)
|
||||
{
|
||||
u8 val1 = palstruct->srcIndex;
|
||||
u8 val2 = palstruct->base->srcCount;
|
||||
|
||||
if (val1 == val2)
|
||||
{
|
||||
sub_80709B4(palstruct);
|
||||
if (!palstruct->ps_field_4_0)
|
||||
continue;
|
||||
}
|
||||
if (palstruct->ps_field_8 == 0)
|
||||
sub_8070790(palstruct, a2);
|
||||
else
|
||||
--palstruct->ps_field_8;
|
||||
sub_80708F4(palstruct, a2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// not used
|
||||
static void sub_8070790(struct PaletteStruct *a1, u32 *a2)
|
||||
{
|
||||
s32 srcIndex;
|
||||
s32 srcCount;
|
||||
u8 i = 0;
|
||||
u16 srcOffset = a1->srcIndex * a1->base->size;
|
||||
|
||||
if (!a1->base->pst_field_8_0)
|
||||
{
|
||||
while (i < a1->base->size)
|
||||
{
|
||||
gPlttBufferUnfaded[a1->destOffset] = a1->base->src[srcOffset];
|
||||
gPlttBufferFaded[a1->destOffset] = a1->base->src[srcOffset];
|
||||
++i;
|
||||
++a1->destOffset;
|
||||
++srcOffset;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
while (i < a1->base->size)
|
||||
{
|
||||
gPlttBufferFaded[a1->destOffset] = a1->base->src[srcOffset];
|
||||
++i;
|
||||
++a1->destOffset;
|
||||
++srcOffset;
|
||||
}
|
||||
}
|
||||
a1->destOffset = a1->baseDestOffset;
|
||||
a1->ps_field_8 = a1->base->pst_field_A;
|
||||
++a1->srcIndex;
|
||||
srcIndex = a1->srcIndex;
|
||||
srcCount = a1->base->srcCount;
|
||||
if (srcIndex >= srcCount)
|
||||
{
|
||||
if (a1->ps_field_9)
|
||||
--a1->ps_field_9;
|
||||
a1->srcIndex = 0;
|
||||
}
|
||||
*a2 |= 1 << (a1->baseDestOffset >> 4);
|
||||
}
|
||||
|
||||
// not used
|
||||
static void sub_80708F4(struct PaletteStruct *a1, u32 *a2)
|
||||
{
|
||||
if (gPaletteFade.active && ((1 << (a1->baseDestOffset >> 4)) & gPaletteFade_selectedPalettes))
|
||||
{
|
||||
if (!a1->base->pst_field_8_0)
|
||||
{
|
||||
if (gPaletteFade.delayCounter != gPaletteFade_delay)
|
||||
BlendPalette(a1->baseDestOffset,
|
||||
a1->base->size,
|
||||
gPaletteFade.y,
|
||||
gPaletteFade.blendColor);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!gPaletteFade.delayCounter)
|
||||
{
|
||||
if (a1->ps_field_8 != a1->base->pst_field_A)
|
||||
{
|
||||
u32 srcOffset = a1->srcIndex * a1->base->size;
|
||||
u8 i;
|
||||
|
||||
for (i = 0; i < a1->base->size; ++i)
|
||||
gPlttBufferFaded[a1->baseDestOffset + i] = a1->base->src[srcOffset + i];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// not used
|
||||
static void sub_80709B4(struct PaletteStruct *a1)
|
||||
{
|
||||
if (!a1->ps_field_9)
|
||||
{
|
||||
s32 val = a1->base->pst_field_B_5;
|
||||
|
||||
if (!val)
|
||||
{
|
||||
a1->srcIndex = 0;
|
||||
a1->ps_field_8 = a1->base->pst_field_A;
|
||||
a1->ps_field_9 = a1->base->pst_field_C;
|
||||
a1->destOffset = a1->baseDestOffset;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (val < 0)
|
||||
return;
|
||||
if (val > 2)
|
||||
return;
|
||||
ResetPaletteStructByUid(a1->base->uid);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
--a1->ps_field_9;
|
||||
}
|
||||
}
|
||||
|
||||
void ResetPaletteStructByUid(u16 a1)
|
||||
{
|
||||
u8 paletteNum = GetPaletteNumByUid(a1);
|
||||
if (paletteNum != 16)
|
||||
ResetPaletteStruct(paletteNum);
|
||||
}
|
||||
|
||||
void ResetPaletteStruct(u8 paletteNum)
|
||||
{
|
||||
sPaletteStructs[paletteNum].base = &gDummyPaletteStructTemplate;
|
||||
sPaletteStructs[paletteNum].ps_field_4_0 = 0;
|
||||
sPaletteStructs[paletteNum].baseDestOffset = 0;
|
||||
sPaletteStructs[paletteNum].destOffset = 0;
|
||||
sPaletteStructs[paletteNum].srcIndex = 0;
|
||||
sPaletteStructs[paletteNum].ps_field_4_1 = 0;
|
||||
sPaletteStructs[paletteNum].ps_field_8 = 0;
|
||||
sPaletteStructs[paletteNum].ps_field_9 = 0;
|
||||
}
|
||||
|
||||
void ResetPaletteFadeControl(void)
|
||||
{
|
||||
gPaletteFade.multipurpose1 = 0;
|
||||
gPaletteFade.multipurpose2 = 0;
|
||||
gPaletteFade.delayCounter = 0;
|
||||
gPaletteFade.y = 0;
|
||||
gPaletteFade.targetY = 0;
|
||||
gPaletteFade.blendColor = 0;
|
||||
gPaletteFade.active = FALSE;
|
||||
gPaletteFade.multipurpose2 = 0; // assign same value twice
|
||||
gPaletteFade.yDec = FALSE;
|
||||
gPaletteFade.bufferTransferDisabled = FALSE;
|
||||
gPaletteFade.shouldResetBlendRegisters = FALSE;
|
||||
gPaletteFade.hardwareFadeFinishing = FALSE;
|
||||
gPaletteFade.softwareFadeFinishing = FALSE;
|
||||
gPaletteFade.softwareFadeFinishingCounter = 0;
|
||||
gPaletteFade.objPaletteToggle = 0;
|
||||
gPaletteFade.deltaY = 2;
|
||||
}
|
||||
|
||||
// not used
|
||||
static void sub_8070AFC(u16 uid)
|
||||
{
|
||||
u8 paletteNum = GetPaletteNumByUid(uid);
|
||||
if (paletteNum != 16)
|
||||
sPaletteStructs[paletteNum].ps_field_4_1 = 1;
|
||||
}
|
||||
|
||||
// not used
|
||||
static void sub_8070B28(u16 uid)
|
||||
{
|
||||
u8 paletteNum = GetPaletteNumByUid(uid);
|
||||
if (paletteNum != 16)
|
||||
sPaletteStructs[paletteNum].ps_field_4_1 = 0;
|
||||
}
|
||||
|
||||
// not used
|
||||
static u8 GetPaletteNumByUid(u16 uid)
|
||||
{
|
||||
u8 i;
|
||||
|
||||
for (i = 0; i < NUM_PALETTE_STRUCTS; ++i)
|
||||
if (sPaletteStructs[i].base->uid == uid)
|
||||
return i;
|
||||
return 16;
|
||||
}
|
||||
|
||||
static u8 UpdateNormalPaletteFade(void)
|
||||
{
|
||||
u16 paletteOffset;
|
||||
u16 selectedPalettes;
|
||||
|
||||
if (!gPaletteFade.active)
|
||||
return PALETTE_FADE_STATUS_DONE;
|
||||
if (IsSoftwarePaletteFadeFinishing())
|
||||
{
|
||||
return gPaletteFade.active ? PALETTE_FADE_STATUS_ACTIVE : PALETTE_FADE_STATUS_DONE;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!gPaletteFade.objPaletteToggle)
|
||||
{
|
||||
if (gPaletteFade.delayCounter < gPaletteFade_delay)
|
||||
{
|
||||
++gPaletteFade.delayCounter;
|
||||
return 2;
|
||||
}
|
||||
gPaletteFade.delayCounter = 0;
|
||||
}
|
||||
paletteOffset = 0;
|
||||
if (!gPaletteFade.objPaletteToggle)
|
||||
{
|
||||
selectedPalettes = gPaletteFade_selectedPalettes;
|
||||
}
|
||||
else
|
||||
{
|
||||
selectedPalettes = gPaletteFade_selectedPalettes >> 16;
|
||||
paletteOffset = 256;
|
||||
}
|
||||
while (selectedPalettes)
|
||||
{
|
||||
if (selectedPalettes & 1)
|
||||
BlendPalette(paletteOffset,
|
||||
16,
|
||||
gPaletteFade.y,
|
||||
gPaletteFade.blendColor);
|
||||
selectedPalettes >>= 1;
|
||||
paletteOffset += 16;
|
||||
}
|
||||
gPaletteFade.objPaletteToggle ^= 1;
|
||||
if (!gPaletteFade.objPaletteToggle)
|
||||
{
|
||||
if (gPaletteFade.y == gPaletteFade.targetY)
|
||||
{
|
||||
gPaletteFade_selectedPalettes = 0;
|
||||
gPaletteFade.softwareFadeFinishing = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
s8 val;
|
||||
|
||||
if (!gPaletteFade.yDec)
|
||||
{
|
||||
val = gPaletteFade.y;
|
||||
val += gPaletteFade.deltaY;
|
||||
if (val > gPaletteFade.targetY)
|
||||
val = gPaletteFade.targetY;
|
||||
gPaletteFade.y = val;
|
||||
}
|
||||
else
|
||||
{
|
||||
val = gPaletteFade.y;
|
||||
val -= gPaletteFade.deltaY;
|
||||
if (val < gPaletteFade.targetY)
|
||||
val = gPaletteFade.targetY;
|
||||
gPaletteFade.y = val;
|
||||
}
|
||||
}
|
||||
}
|
||||
// gPaletteFade.active cannot change since the last time it was checked. So this
|
||||
// is equivalent to `return PALETTE_FADE_STATUS_ACTIVE;`
|
||||
return gPaletteFade.active ? PALETTE_FADE_STATUS_ACTIVE : PALETTE_FADE_STATUS_DONE;
|
||||
}
|
||||
}
|
||||
|
||||
void InvertPlttBuffer(u32 selectedPalettes)
|
||||
{
|
||||
u16 paletteOffset = 0;
|
||||
|
||||
while (selectedPalettes)
|
||||
{
|
||||
if (selectedPalettes & 1)
|
||||
{
|
||||
u8 i;
|
||||
|
||||
for (i = 0; i < 16; ++i)
|
||||
gPlttBufferFaded[paletteOffset + i] = ~gPlttBufferFaded[paletteOffset + i];
|
||||
}
|
||||
selectedPalettes >>= 1;
|
||||
paletteOffset += 16;
|
||||
}
|
||||
}
|
||||
|
||||
void TintPlttBuffer(u32 selectedPalettes, s8 r, s8 g, s8 b)
|
||||
{
|
||||
u16 paletteOffset = 0;
|
||||
|
||||
while (selectedPalettes)
|
||||
{
|
||||
if (selectedPalettes & 1)
|
||||
{
|
||||
u8 i;
|
||||
|
||||
for (i = 0; i < 16; ++i)
|
||||
{
|
||||
struct PlttData *data = (struct PlttData *)&gPlttBufferFaded[paletteOffset + i];
|
||||
|
||||
data->r += r;
|
||||
data->g += g;
|
||||
data->b += b;
|
||||
}
|
||||
}
|
||||
selectedPalettes >>= 1;
|
||||
paletteOffset += 16;
|
||||
}
|
||||
}
|
||||
|
||||
void UnfadePlttBuffer(u32 selectedPalettes)
|
||||
{
|
||||
u16 paletteOffset = 0;
|
||||
|
||||
while (selectedPalettes)
|
||||
{
|
||||
if (selectedPalettes & 1)
|
||||
{
|
||||
u8 i;
|
||||
|
||||
for (i = 0; i < 16; ++i)
|
||||
gPlttBufferFaded[paletteOffset + i] = gPlttBufferUnfaded[paletteOffset + i];
|
||||
}
|
||||
selectedPalettes >>= 1;
|
||||
paletteOffset += 16;
|
||||
}
|
||||
}
|
||||
|
||||
void BeginFastPaletteFade(u8 submode)
|
||||
{
|
||||
gPaletteFade.deltaY = 2;
|
||||
BeginFastPaletteFadeInternal(submode);
|
||||
}
|
||||
|
||||
static void BeginFastPaletteFadeInternal(u8 submode)
|
||||
{
|
||||
gPaletteFade.y = 31;
|
||||
gPaletteFade_submode = submode & 0x3F;
|
||||
gPaletteFade.active = TRUE;
|
||||
gPaletteFade.mode = FAST_FADE;
|
||||
if (submode == FAST_FADE_IN_FROM_BLACK)
|
||||
CpuFill16(RGB_BLACK, gPlttBufferFaded, PLTT_SIZE);
|
||||
if (submode == FAST_FADE_IN_FROM_WHITE)
|
||||
CpuFill16(RGB_WHITE, gPlttBufferFaded, PLTT_SIZE);
|
||||
UpdatePaletteFade();
|
||||
}
|
||||
|
||||
static u8 UpdateFastPaletteFade(void)
|
||||
{
|
||||
u16 i;
|
||||
u16 paletteOffsetStart, paletteOffsetEnd;
|
||||
s8 r0, g0, b0, r, g, b;
|
||||
|
||||
if (!gPaletteFade.active)
|
||||
return PALETTE_FADE_STATUS_DONE;
|
||||
if (IsSoftwarePaletteFadeFinishing())
|
||||
return gPaletteFade.active ? PALETTE_FADE_STATUS_ACTIVE : PALETTE_FADE_STATUS_DONE;
|
||||
if (gPaletteFade.objPaletteToggle)
|
||||
{
|
||||
paletteOffsetStart = 256;
|
||||
paletteOffsetEnd = 512;
|
||||
}
|
||||
else
|
||||
{
|
||||
paletteOffsetStart = 0;
|
||||
paletteOffsetEnd = 256;
|
||||
}
|
||||
switch (gPaletteFade_submode)
|
||||
{
|
||||
case FAST_FADE_IN_FROM_WHITE:
|
||||
for (i = paletteOffsetStart; i < paletteOffsetEnd; ++i)
|
||||
{
|
||||
struct PlttData *unfaded;
|
||||
struct PlttData *faded;
|
||||
|
||||
unfaded = (struct PlttData *)&gPlttBufferUnfaded[i];
|
||||
r0 = unfaded->r;
|
||||
g0 = unfaded->g;
|
||||
b0 = unfaded->b;
|
||||
faded = (struct PlttData *)&gPlttBufferFaded[i];
|
||||
r = faded->r - 2;
|
||||
g = faded->g - 2;
|
||||
b = faded->b - 2;
|
||||
if (r < r0)
|
||||
r = r0;
|
||||
if (g < g0)
|
||||
g = g0;
|
||||
if (b < b0)
|
||||
b = b0;
|
||||
gPlttBufferFaded[i] = r | (g << 5) | (b << 10);
|
||||
}
|
||||
break;
|
||||
case FAST_FADE_OUT_TO_WHITE:
|
||||
for (i = paletteOffsetStart; i < paletteOffsetEnd; ++i)
|
||||
{
|
||||
struct PlttData *data = (struct PlttData *)&gPlttBufferFaded[i];
|
||||
|
||||
r = data->r + 2;
|
||||
g = data->g + 2;
|
||||
b = data->b + 2;
|
||||
if (r > 31)
|
||||
r = 31;
|
||||
if (g > 31)
|
||||
g = 31;
|
||||
if (b > 31)
|
||||
b = 31;
|
||||
gPlttBufferFaded[i] = r | (g << 5) | (b << 10);
|
||||
}
|
||||
break;
|
||||
case FAST_FADE_IN_FROM_BLACK:
|
||||
for (i = paletteOffsetStart; i < paletteOffsetEnd; ++i)
|
||||
{
|
||||
struct PlttData *unfaded;
|
||||
struct PlttData *faded;
|
||||
|
||||
unfaded = (struct PlttData *)&gPlttBufferUnfaded[i];
|
||||
r0 = unfaded->r;
|
||||
g0 = unfaded->g;
|
||||
b0 = unfaded->b;
|
||||
faded = (struct PlttData *)&gPlttBufferFaded[i];
|
||||
r = faded->r + 2;
|
||||
g = faded->g + 2;
|
||||
b = faded->b + 2;
|
||||
if (r > r0)
|
||||
r = r0;
|
||||
if (g > g0)
|
||||
g = g0;
|
||||
if (b > b0)
|
||||
b = b0;
|
||||
gPlttBufferFaded[i] = r | (g << 5) | (b << 10);
|
||||
}
|
||||
break;
|
||||
case FAST_FADE_OUT_TO_BLACK:
|
||||
for (i = paletteOffsetStart; i < paletteOffsetEnd; ++i)
|
||||
{
|
||||
struct PlttData *data = (struct PlttData *)&gPlttBufferFaded[i];
|
||||
|
||||
r = data->r - 2;
|
||||
g = data->g - 2;
|
||||
b = data->b - 2;
|
||||
if (r < 0)
|
||||
r = 0;
|
||||
if (g < 0)
|
||||
g = 0;
|
||||
if (b < 0)
|
||||
b = 0;
|
||||
gPlttBufferFaded[i] = r | (g << 5) | (b << 10);
|
||||
}
|
||||
}
|
||||
gPaletteFade.objPaletteToggle ^= 1;
|
||||
if (gPaletteFade.objPaletteToggle)
|
||||
// gPaletteFade.active cannot change since the last time it was checked. So this
|
||||
// is equivalent to `return PALETTE_FADE_STATUS_ACTIVE;`
|
||||
return gPaletteFade.active ? PALETTE_FADE_STATUS_ACTIVE : PALETTE_FADE_STATUS_DONE;
|
||||
if (gPaletteFade.y - gPaletteFade.deltaY < 0)
|
||||
gPaletteFade.y = 0;
|
||||
else
|
||||
gPaletteFade.y -= gPaletteFade.deltaY;
|
||||
if (gPaletteFade.y == 0)
|
||||
{
|
||||
switch (gPaletteFade_submode)
|
||||
{
|
||||
case FAST_FADE_IN_FROM_WHITE:
|
||||
case FAST_FADE_IN_FROM_BLACK:
|
||||
CpuCopy32(gPlttBufferUnfaded, gPlttBufferFaded, PLTT_SIZE);
|
||||
break;
|
||||
case FAST_FADE_OUT_TO_WHITE:
|
||||
CpuFill32(0xFFFFFFFF, gPlttBufferFaded, PLTT_SIZE);
|
||||
break;
|
||||
case FAST_FADE_OUT_TO_BLACK:
|
||||
CpuFill32(0x00000000, gPlttBufferFaded, PLTT_SIZE);
|
||||
break;
|
||||
}
|
||||
gPaletteFade.mode = NORMAL_FADE;
|
||||
gPaletteFade.softwareFadeFinishing = TRUE;
|
||||
}
|
||||
// gPaletteFade.active cannot change since the last time it was checked. So this
|
||||
// is equivalent to `return PALETTE_FADE_STATUS_ACTIVE;`
|
||||
return gPaletteFade.active ? PALETTE_FADE_STATUS_ACTIVE : PALETTE_FADE_STATUS_DONE;
|
||||
}
|
||||
|
||||
void BeginHardwarePaletteFade(u8 blendCnt, u8 delay, u8 y, u8 targetY, u8 shouldResetBlendRegisters)
|
||||
{
|
||||
gPaletteFade_blendCnt = blendCnt;
|
||||
gPaletteFade.delayCounter = delay;
|
||||
gPaletteFade_delay = delay;
|
||||
gPaletteFade.y = y;
|
||||
gPaletteFade.targetY = targetY;
|
||||
gPaletteFade.active = TRUE;
|
||||
gPaletteFade.mode = HARDWARE_FADE;
|
||||
gPaletteFade.shouldResetBlendRegisters = shouldResetBlendRegisters & 1;
|
||||
gPaletteFade.hardwareFadeFinishing = FALSE;
|
||||
if (y < targetY)
|
||||
gPaletteFade.yDec = FALSE;
|
||||
else
|
||||
gPaletteFade.yDec = TRUE;
|
||||
}
|
||||
|
||||
static u8 UpdateHardwarePaletteFade(void)
|
||||
{
|
||||
if (!gPaletteFade.active)
|
||||
return PALETTE_FADE_STATUS_DONE;
|
||||
if (gPaletteFade.delayCounter < gPaletteFade_delay)
|
||||
{
|
||||
++gPaletteFade.delayCounter;
|
||||
return PALETTE_FADE_STATUS_DELAY;
|
||||
}
|
||||
gPaletteFade.delayCounter = 0;
|
||||
if (!gPaletteFade.yDec)
|
||||
{
|
||||
++gPaletteFade.y;
|
||||
if (gPaletteFade.y > gPaletteFade.targetY)
|
||||
{
|
||||
++gPaletteFade.hardwareFadeFinishing;
|
||||
--gPaletteFade.y;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (gPaletteFade.y-- - 1 < gPaletteFade.targetY)
|
||||
{
|
||||
++gPaletteFade.hardwareFadeFinishing;
|
||||
++gPaletteFade.y;
|
||||
}
|
||||
}
|
||||
|
||||
if (gPaletteFade.hardwareFadeFinishing)
|
||||
{
|
||||
if (gPaletteFade.shouldResetBlendRegisters)
|
||||
{
|
||||
gPaletteFade_blendCnt = 0;
|
||||
gPaletteFade.y = 0;
|
||||
}
|
||||
gPaletteFade.shouldResetBlendRegisters = FALSE;
|
||||
}
|
||||
// gPaletteFade.active cannot change since the last time it was checked. So this
|
||||
// is equivalent to `return PALETTE_FADE_STATUS_ACTIVE;`
|
||||
return gPaletteFade.active ? PALETTE_FADE_STATUS_ACTIVE : PALETTE_FADE_STATUS_DONE;
|
||||
}
|
||||
|
||||
static void UpdateBlendRegisters(void)
|
||||
{
|
||||
SetGpuReg(REG_OFFSET_BLDCNT, (u16)gPaletteFade_blendCnt);
|
||||
SetGpuReg(REG_OFFSET_BLDY, gPaletteFade.y);
|
||||
if (gPaletteFade.hardwareFadeFinishing)
|
||||
{
|
||||
gPaletteFade.hardwareFadeFinishing = FALSE;
|
||||
gPaletteFade.mode = 0;
|
||||
gPaletteFade_blendCnt = 0;
|
||||
gPaletteFade.y = 0;
|
||||
gPaletteFade.active = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
static bool8 IsSoftwarePaletteFadeFinishing(void)
|
||||
{
|
||||
if (gPaletteFade.softwareFadeFinishing)
|
||||
{
|
||||
if (gPaletteFade.softwareFadeFinishingCounter == 4)
|
||||
{
|
||||
gPaletteFade.active = FALSE;
|
||||
gPaletteFade.softwareFadeFinishing = FALSE;
|
||||
gPaletteFade.softwareFadeFinishingCounter = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
++gPaletteFade.softwareFadeFinishingCounter;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
void BlendPalettes(u32 selectedPalettes, u8 coeff, u16 color)
|
||||
{
|
||||
u16 paletteOffset;
|
||||
|
||||
for (paletteOffset = 0; selectedPalettes; paletteOffset += 16)
|
||||
{
|
||||
if (selectedPalettes & 1)
|
||||
BlendPalette(paletteOffset, 16, coeff, color);
|
||||
selectedPalettes >>= 1;
|
||||
}
|
||||
}
|
||||
|
||||
void BlendPalettesUnfaded(u32 selectedPalettes, u8 coeff, u16 color)
|
||||
{
|
||||
// This copy is done via DMA in both RUBY and EMERALD
|
||||
CpuFastCopy(gPlttBufferUnfaded, gPlttBufferFaded, 0x400);
|
||||
BlendPalettes(selectedPalettes, coeff, color);
|
||||
}
|
||||
|
||||
void TintPalette_GrayScale(u16 *palette, u16 count)
|
||||
{
|
||||
s32 r, g, b, i;
|
||||
u32 gray;
|
||||
|
||||
for (i = 0; i < count; ++i)
|
||||
{
|
||||
r = (*palette >> 0) & 0x1F;
|
||||
g = (*palette >> 5) & 0x1F;
|
||||
b = (*palette >> 10) & 0x1F;
|
||||
gray = (r * Q_8_8(0.3) + g * Q_8_8(0.59) + b * Q_8_8(0.1133)) >> 8;
|
||||
*palette++ = (gray << 10) | (gray << 5) | (gray << 0);
|
||||
}
|
||||
}
|
||||
|
||||
void TintPalette_GrayScale2(u16 *palette, u16 count)
|
||||
{
|
||||
s32 r, g, b, i;
|
||||
u32 gray;
|
||||
|
||||
for (i = 0; i < count; ++i)
|
||||
{
|
||||
r = (*palette >> 0) & 0x1F;
|
||||
g = (*palette >> 5) & 0x1F;
|
||||
b = (*palette >> 10) & 0x1F;
|
||||
gray = (r * Q_8_8(0.3) + g * Q_8_8(0.59) + b * Q_8_8(0.1133)) >> 8;
|
||||
|
||||
if (gray > 0x1F)
|
||||
gray = 0x1F;
|
||||
gray = sRoundedDownGrayscaleMap[gray];
|
||||
*palette++ = (gray << 10) | (gray << 5) | (gray << 0);
|
||||
}
|
||||
}
|
||||
|
||||
void TintPalette_SepiaTone(u16 *palette, u16 count)
|
||||
{
|
||||
s32 r, g, b, i;
|
||||
u32 gray;
|
||||
|
||||
for (i = 0; i < count; ++i)
|
||||
{
|
||||
r = (*palette >> 0) & 0x1F;
|
||||
g = (*palette >> 5) & 0x1F;
|
||||
b = (*palette >> 10) & 0x1F;
|
||||
gray = (r * Q_8_8(0.3) + g * Q_8_8(0.59) + b * Q_8_8(0.1133)) >> 8;
|
||||
r = (u16)((Q_8_8(1.2) * gray)) >> 8;
|
||||
g = (u16)((Q_8_8(1.0) * gray)) >> 8;
|
||||
b = (u16)((Q_8_8(0.94) * gray)) >> 8;
|
||||
if (r > 31)
|
||||
r = 31;
|
||||
*palette++ = (b << 10) | (g << 5) | (r << 0);
|
||||
}
|
||||
}
|
||||
|
||||
void TintPalette_CustomTone(u16 *palette, u16 count, u16 rTone, u16 gTone, u16 bTone)
|
||||
{
|
||||
s32 r, g, b, i;
|
||||
u32 gray;
|
||||
|
||||
for (i = 0; i < count; ++i)
|
||||
{
|
||||
r = (*palette >> 0) & 0x1F;
|
||||
g = (*palette >> 5) & 0x1F;
|
||||
b = (*palette >> 10) & 0x1F;
|
||||
gray = (r * Q_8_8(0.3) + g * Q_8_8(0.59) + b * Q_8_8(0.1133)) >> 8;
|
||||
r = (u16)((rTone * gray)) >> 8;
|
||||
g = (u16)((gTone * gray)) >> 8;
|
||||
b = (u16)((bTone * gray)) >> 8;
|
||||
if (r > 31)
|
||||
r = 31;
|
||||
if (g > 31)
|
||||
g = 31;
|
||||
if (b > 31)
|
||||
b = 31;
|
||||
*palette++ = (b << 10) | (g << 5) | (r << 0);
|
||||
}
|
||||
}
|
||||
|
||||
void sub_80716F8(const u16 *src, u16 *dst, u16 count, u8 a4)
|
||||
{
|
||||
s32 r, g, b, i;
|
||||
u32 gray;
|
||||
|
||||
if (!a4)
|
||||
{
|
||||
for (i = 0; i < count; ++i)
|
||||
*dst++ = *src++;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (i = 0; i < count; ++src, ++dst, ++i)
|
||||
{
|
||||
r = (*src >> 0) & 0x1F;
|
||||
g = (*src >> 5) & 0x1F;
|
||||
b = (*src >> 10) & 0x1F;
|
||||
gray = (r * Q_8_8(0.3) + g * Q_8_8(0.59) + b * Q_8_8(0.1133)) >> 8;
|
||||
r += (a4 * (gray - r) >> 4);
|
||||
g += (a4 * (gray - g) >> 4);
|
||||
b += (a4 * (gray - b) >> 4);
|
||||
*dst = (b << 10) | (g << 5) | (r << 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void sub_80717A8(u32 a1, s8 a2, u8 a3, u8 a4, u16 a5, u8 a6, u8 a7)
|
||||
{
|
||||
u8 taskId;
|
||||
|
||||
taskId = CreateTask(sub_80718B8, a6);
|
||||
gTasks[taskId].data[0] = a3;
|
||||
gTasks[taskId].data[1] = a4;
|
||||
if (a2 >= 0)
|
||||
{
|
||||
gTasks[taskId].data[3] = a2;
|
||||
gTasks[taskId].data[2] = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
gTasks[taskId].data[3] = 0;
|
||||
gTasks[taskId].data[2] = -a2 + 1;
|
||||
}
|
||||
if (a4 < a3)
|
||||
gTasks[taskId].data[2] *= -1;
|
||||
SetWordTaskArg(taskId, 5, a1);
|
||||
gTasks[taskId].data[7] = a5;
|
||||
gTasks[taskId].data[8] = a7;
|
||||
gTasks[taskId].func(taskId);
|
||||
}
|
||||
|
||||
bool32 sub_807185C(u8 var)
|
||||
{
|
||||
s32 i;
|
||||
|
||||
for (i = 0; i < NUM_TASKS; ++i)
|
||||
if (gTasks[i].isActive == TRUE
|
||||
&& gTasks[i].func == sub_80718B8
|
||||
&& gTasks[i].data[8] == var)
|
||||
return TRUE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void sub_8071898(void)
|
||||
{
|
||||
u8 taskId;
|
||||
|
||||
while (TRUE)
|
||||
{
|
||||
taskId = FindTaskIdByFunc(sub_80718B8);
|
||||
if (taskId == TASK_NONE)
|
||||
break;
|
||||
DestroyTask(taskId);
|
||||
}
|
||||
}
|
||||
|
||||
static void sub_80718B8(u8 taskId)
|
||||
{
|
||||
u32 wordVar;
|
||||
s16 *data;
|
||||
s16 temp;
|
||||
|
||||
data = gTasks[taskId].data;
|
||||
wordVar = GetWordTaskArg(taskId, 5);
|
||||
if (++data[4] > data[3])
|
||||
{
|
||||
data[4] = 0;
|
||||
BlendPalettes(wordVar, data[0], data[7]);
|
||||
temp = data[1];
|
||||
if (data[0] == temp)
|
||||
{
|
||||
DestroyTask(taskId);
|
||||
}
|
||||
else
|
||||
{
|
||||
data[0] += data[2];
|
||||
if (data[2] >= 0)
|
||||
{
|
||||
if (data[0] < temp)
|
||||
return;
|
||||
}
|
||||
else if (data[0] > temp)
|
||||
{
|
||||
return;
|
||||
}
|
||||
data[0] = temp;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,238 @@
|
||||
#include "global.h"
|
||||
#include "malloc.h"
|
||||
#include "bg.h"
|
||||
#include "decompress.h"
|
||||
#include "gpu_regs.h"
|
||||
#include "palette.h"
|
||||
#include "task.h"
|
||||
#include "wild_pokemon_area.h"
|
||||
#include "pokedex_area_markers.h"
|
||||
|
||||
static const u16 sMarkerPal[] = INCBIN_U16("data/pokedex_area_markers/marker.gbapal");
|
||||
static const u32 sMarkerTiles[] = INCBIN_U32("data/pokedex_area_markers/marker.4bpp.lz");
|
||||
|
||||
static const struct Subsprite sSubsprite0 = {
|
||||
.size = ST_OAM_SIZE_0,
|
||||
.shape = ST_OAM_SQUARE,
|
||||
.priority = 1,
|
||||
.tileOffset = 0
|
||||
};
|
||||
|
||||
static const struct Subsprite sSubsprite1 = {
|
||||
.size = ST_OAM_SIZE_0,
|
||||
.shape = ST_OAM_H_RECTANGLE,
|
||||
.priority = 1,
|
||||
.tileOffset = 1
|
||||
};
|
||||
|
||||
static const struct Subsprite sSubsprite2 = {
|
||||
.size = ST_OAM_SIZE_0,
|
||||
.shape = ST_OAM_V_RECTANGLE,
|
||||
.priority = 1,
|
||||
.tileOffset = 3
|
||||
};
|
||||
|
||||
static const struct Subsprite sSubsprite3 = {
|
||||
.size = ST_OAM_SIZE_2,
|
||||
.shape = ST_OAM_H_RECTANGLE,
|
||||
.priority = 1,
|
||||
.tileOffset = 5
|
||||
};
|
||||
|
||||
static const struct Subsprite sSubsprite4 = {
|
||||
.size = ST_OAM_SIZE_2,
|
||||
.shape = ST_OAM_V_RECTANGLE,
|
||||
.priority = 1,
|
||||
.tileOffset = 13
|
||||
};
|
||||
|
||||
static const struct Subsprite sSubsprite5 = {
|
||||
.size = ST_OAM_SIZE_2,
|
||||
.shape = ST_OAM_H_RECTANGLE,
|
||||
.priority = 1,
|
||||
.tileOffset = 21
|
||||
};
|
||||
|
||||
static const struct Subsprite sSubsprite6 = {
|
||||
.size = ST_OAM_SIZE_2,
|
||||
.shape = ST_OAM_V_RECTANGLE,
|
||||
.priority = 1,
|
||||
.tileOffset = 29
|
||||
};
|
||||
|
||||
|
||||
static const struct Subsprite *const sSubsprites[] = {
|
||||
&sSubsprite0,
|
||||
&sSubsprite1,
|
||||
&sSubsprite2,
|
||||
&sSubsprite3,
|
||||
&sSubsprite4,
|
||||
&sSubsprite5,
|
||||
&sSubsprite6
|
||||
};
|
||||
|
||||
static const s8 sSubspriteLookupTable[][4] = {
|
||||
{ 0, 0x00, 0x00 },
|
||||
{ 0, 0x36, 0x2c },
|
||||
{ 0, 0x36, 0x1c },
|
||||
{ 0, 0x36, 0x0c },
|
||||
{ 0, 0x5c, 0x0c },
|
||||
{ 0, 0x6e, 0x18 },
|
||||
{ 0, 0x5c, 0x24 },
|
||||
{ 0, 0x4c, 0x18 },
|
||||
{ 0, 0x4e, 0x34 },
|
||||
{ 0, 0x36, 0x3e },
|
||||
{ 0, 0x2a, 0x02 },
|
||||
{ 0, 0x5c, 0x18 },
|
||||
{ 2, 0x36, 0x20 },
|
||||
{ 2, 0x36, 0x10 },
|
||||
{ 1, 0x3d, 0x0c },
|
||||
{ 1, 0x4d, 0x0c },
|
||||
{ 0, 0x5c, 0x12 },
|
||||
{ 0, 0x5c, 0x1e },
|
||||
{ 0, 0x54, 0x18 },
|
||||
{ 1, 0x62, 0x18 },
|
||||
{ 1, 0x62, 0x0c },
|
||||
{ 2, 0x6e, 0x0c },
|
||||
{ 1, 0x62, 0x24 },
|
||||
{ 4, 0x6a, 0x19 },
|
||||
{ 1, 0x64, 0x2e },
|
||||
{ 2, 0x5e, 0x2d },
|
||||
{ 1, 0x55, 0x34 },
|
||||
{ 0, 0x44, 0x18 },
|
||||
{ 4, 0x3e, 0x1a },
|
||||
{ 1, 0x40, 0x34 },
|
||||
{ 0, 0x4e, 0x3c },
|
||||
{ 3, 0x37, 0x3a },
|
||||
{ 2, 0x36, 0x32 },
|
||||
{ 1, 0x28, 0x1c },
|
||||
{ 4, 0x26, 0x04 },
|
||||
{ 0, 0x5c, 0x04 },
|
||||
{ 3, 0x5a, 0xfe },
|
||||
{ 0, 0x33, 0x14 },
|
||||
{ 1, 0x3d, 0x12 },
|
||||
{ 0, 0x48, 0x08 },
|
||||
{ 0, 0x57, 0x08 },
|
||||
{ 0, 0x70, 0x0e },
|
||||
{ 0, 0x71, 0x14 },
|
||||
{ 0, 0x71, 0x19 },
|
||||
{ 1, 0x4e, 0x2c },
|
||||
{ 0, 0x41, 0x3c },
|
||||
{ 0, 0x34, 0x3e },
|
||||
{ 0, 0x2d, 0x07 },
|
||||
{ 0, 0x0a, 0x0a },
|
||||
{ 0, 0x0c, 0x23 },
|
||||
{ 0, 0x0e, 0x34 },
|
||||
{ 0, 0x0c, 0x54 },
|
||||
{ 0, 0x2d, 0x51 },
|
||||
{ 0, 0x4c, 0x54 },
|
||||
{ 0, 0x68, 0x52 },
|
||||
{ 2, 0x0e, 0x02 },
|
||||
{ 0, 0x0a, 0x0f },
|
||||
{ 0, 0x0c, 0x1d },
|
||||
{ 1, 0x02, 0x34 },
|
||||
{ 1, 0x0c, 0x38 },
|
||||
{ 1, 0x2c, 0x4a },
|
||||
{ 1, 0x24, 0x4e },
|
||||
{ 2, 0x30, 0x50 },
|
||||
{ 2, 0x34, 0x56 },
|
||||
{ 0, 0x48, 0x4a },
|
||||
{ 1, 0x48, 0x4e },
|
||||
{ 2, 0x51, 0x50 },
|
||||
{ 0, 0x4c, 0x5c },
|
||||
{ 0, 0x68, 0x4b },
|
||||
{ 0, 0x68, 0x56 },
|
||||
{ 2, 0x6c, 0x53 },
|
||||
{ 3, 0x60, 0x5a },
|
||||
{ 0, 0x0e, 0x01 },
|
||||
{ 0, 0x05, 0x34 },
|
||||
{ 0, 0x0d, 0x50 },
|
||||
{ 0, 0x36, 0x4a },
|
||||
{ 0, 0x45, 0x49 },
|
||||
{ 0, 0x4c, 0x4d },
|
||||
{ 0, 0x49, 0x5f },
|
||||
{ 3, 0x60, 0x5a }
|
||||
};
|
||||
|
||||
static void Task_ShowAreaMarkers(u8 taskId)
|
||||
{
|
||||
struct PAM_TaskData * data = (void *)gTasks[taskId].data;
|
||||
gSprites[data->spr_id].invisible = FALSE;
|
||||
}
|
||||
|
||||
u8 sub_8134230(u16 species, u16 tilesTag, u8 palIdx, u8 y)
|
||||
{
|
||||
struct SpriteTemplate spriteTemplate;
|
||||
struct CompressedSpriteSheet spriteSheet;
|
||||
u8 taskId;
|
||||
struct PAM_TaskData * data;
|
||||
struct Subsprite * subsprites;
|
||||
|
||||
spriteSheet.data = sMarkerTiles;
|
||||
spriteSheet.size = 0x4A0;
|
||||
spriteSheet.tag = tilesTag;
|
||||
LoadCompressedSpriteSheet(&spriteSheet);
|
||||
LoadPalette(sMarkerPal, 0x100 + 16 * palIdx, 0x20);
|
||||
taskId = CreateTask(Task_ShowAreaMarkers, 0);
|
||||
data = (void *)gTasks[taskId].data;
|
||||
data->unk_0C = 0;
|
||||
data->tilesTag = tilesTag;
|
||||
data->unk_10 = 0xFFFF;
|
||||
subsprites = Alloc(120 * sizeof(struct Subsprite));
|
||||
data->buffer = subsprites;
|
||||
data->subsprites.subsprites = subsprites;
|
||||
data->subsprites.subspriteCount = BuildPokedexAreaSubspriteBuffer(species, subsprites);
|
||||
SetGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_OBJWIN_ON);
|
||||
SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_TGT1_BG1 | BLDCNT_EFFECT_BLEND | BLDCNT_TGT2_BG0 | BLDCNT_TGT2_BG1 | BLDCNT_TGT2_BG2 | BLDCNT_TGT2_BG3 | BLDCNT_TGT2_BD);
|
||||
SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(12, 8));
|
||||
SetGpuReg(REG_OFFSET_BLDY, 0);
|
||||
SetGpuReg(REG_OFFSET_WININ, 0x1F1F);
|
||||
SetGpuReg(REG_OFFSET_WINOUT, 0x2F3D);
|
||||
spriteTemplate = gDummySpriteTemplate;
|
||||
spriteTemplate.tileTag = tilesTag;
|
||||
data->spr_id = CreateSprite(&spriteTemplate, 104, y + 32, 0);
|
||||
SetSubspriteTables(&gSprites[data->spr_id], &data->subsprites);
|
||||
gSprites[data->spr_id].oam.objMode = ST_OAM_OBJ_WINDOW;
|
||||
gSprites[data->spr_id].oam.paletteNum = palIdx;
|
||||
gSprites[data->spr_id].subspriteTableNum = 0;
|
||||
gSprites[data->spr_id].invisible = TRUE;
|
||||
HideBg(1);
|
||||
SetBgAttribute(1, BG_ATTR_CHARBASEINDEX, 0);
|
||||
FillBgTilemapBufferRect_Palette0(1, 0x00F, 0, 0, 30, 20);
|
||||
CopyBgTilemapBufferToVram(1);
|
||||
ShowBg(1);
|
||||
return taskId;
|
||||
}
|
||||
|
||||
void sub_81343F4(u8 taskId)
|
||||
{
|
||||
struct PAM_TaskData * data = (void *)gTasks[taskId].data;
|
||||
FreeSpriteTilesByTag(data->tilesTag);
|
||||
DestroySprite(&gSprites[data->spr_id]);
|
||||
Free(data->buffer);
|
||||
SetGpuReg(REG_OFFSET_BLDCNT, 0);
|
||||
SetGpuReg(REG_OFFSET_BLDALPHA, 0);
|
||||
SetGpuReg(REG_OFFSET_BLDY, 0);
|
||||
SetGpuReg(REG_OFFSET_WININ, 0x1F1F);
|
||||
SetGpuReg(REG_OFFSET_WINOUT, 0x1F1F);
|
||||
ClearGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_OBJWIN_ON);
|
||||
HideBg(1);
|
||||
SetBgAttribute(1, BG_ATTR_CHARBASEINDEX, 2);
|
||||
FillBgTilemapBufferRect_Palette0(1, 0x000, 0, 0, 30, 20);
|
||||
CopyBgTilemapBufferToVram(1);
|
||||
ShowBg(1);
|
||||
DestroyTask(taskId);
|
||||
}
|
||||
|
||||
void SetAreaSubsprite(s32 i, s32 whichArea, struct Subsprite * subsprites)
|
||||
{
|
||||
subsprites[i] = *sSubsprites[sSubspriteLookupTable[whichArea][0]];
|
||||
subsprites[i].x = sSubspriteLookupTable[whichArea][1];
|
||||
subsprites[i].y = sSubspriteLookupTable[whichArea][2];
|
||||
}
|
||||
|
||||
u8 sub_81344E0(u8 taskId)
|
||||
{
|
||||
struct PAM_TaskData * data = (void *)gTasks[taskId].data;
|
||||
return data->subsprites.subspriteCount;
|
||||
}
|
||||
+215
-1491
File diff suppressed because it is too large
Load Diff
+1
-1
@@ -33,7 +33,7 @@ u16 Special_GetPokedexCount(void)
|
||||
gSpecialVar_0x8005 = GetNationalPokedexCount(0);
|
||||
gSpecialVar_0x8006 = GetNationalPokedexCount(1);
|
||||
}
|
||||
return sub_806E25C();
|
||||
return IsNationalPokedexEnabled();
|
||||
}
|
||||
|
||||
const u8 * sub_80CA424(u16 count)
|
||||
|
||||
+9
-9
@@ -1,7 +1,7 @@
|
||||
#include "global.h"
|
||||
#include "constants/species.h"
|
||||
#include "constants/items.h"
|
||||
#include "data2.h"
|
||||
#include "data.h"
|
||||
#include "malloc.h"
|
||||
#include "main.h"
|
||||
#include "task.h"
|
||||
@@ -410,7 +410,7 @@ const struct WindowTemplate gUnknown_845661C[3] = {
|
||||
{ 0, 0, 14, 30, 6, 15, 0x14c }
|
||||
};
|
||||
|
||||
const struct TextColor gUnknown_8456634 = {15, 1, 12};
|
||||
const u8 gUnknown_8456634[3] = {15, 1, 12};
|
||||
|
||||
const u16 gUnknown_8456638[] = INCBIN_U16("data/graphics/unknown_8456638.bin");
|
||||
|
||||
@@ -871,7 +871,7 @@ void sub_8110F90(u8 unused)
|
||||
gSaveBlock1Ptr->location.mapNum = 19;
|
||||
gSaveBlock1Ptr->location.warpId = -1;
|
||||
gUnknown_203ADF8 = 0;
|
||||
gUnknown_2031DD8 = 1;
|
||||
gDisableMapMusicChangeOnMapLoad = 1;
|
||||
sub_8082740(1);
|
||||
sub_8111368();
|
||||
}
|
||||
@@ -923,7 +923,7 @@ void sub_8111070(u8 a0)
|
||||
StringAppend(gStringVar4, gStringVar1);
|
||||
}
|
||||
|
||||
AddTextPrinterParameterized4(gUnknown_203ADFE[0], 2, 2, 2, 1, 2, &gUnknown_8456634, 0, gStringVar4);
|
||||
AddTextPrinterParameterized4(gUnknown_203ADFE[0], 2, 2, 2, 1, 2, gUnknown_8456634, 0, gStringVar4);
|
||||
PutWindowTilemap(gUnknown_203ADFE[0]);
|
||||
PutWindowTilemap(gUnknown_203ADFE[1]);
|
||||
CopyWindowToVram(gUnknown_203ADFE[0], 2);
|
||||
@@ -986,7 +986,7 @@ void sub_8111368(void)
|
||||
{
|
||||
gUnknown_203ADFA = 2;
|
||||
sub_806E6FC();
|
||||
ClearItemSlotsInAllBagPockets();
|
||||
ClearBag();
|
||||
ClearPCItemSlots();
|
||||
if (sub_8110AC8() == 1)
|
||||
{
|
||||
@@ -1418,7 +1418,7 @@ void sub_8111D10(void)
|
||||
|
||||
PutWindowTilemap(gUnknown_203ADFE[2]);
|
||||
sub_8111D90(gUnknown_203ADFE[2]);
|
||||
AddTextPrinterParameterized4(gUnknown_203ADFE[2], 2, 2, gUnknown_8456698[count], 1, 0, &gUnknown_8456634, 0, gStringVar4);
|
||||
AddTextPrinterParameterized4(gUnknown_203ADFE[2], 2, 2, gUnknown_8456698[count], 1, 0, gUnknown_8456634, 0, gStringVar4);
|
||||
ScheduleBgCopyTilemapToVram(0);
|
||||
}
|
||||
|
||||
@@ -1567,7 +1567,7 @@ void sub_81120AC(u8 taskId)
|
||||
switch (data[0])
|
||||
{
|
||||
case 0:
|
||||
gUnknown_2031DD8 = 0;
|
||||
gDisableMapMusicChangeOnMapLoad = 0;
|
||||
Overworld_PlaySpecialMapMusic();
|
||||
sub_811229C();
|
||||
FillWindowPixelRect(gUnknown_203ADFE[0], 0xF, 0, 0, gUnknown_845661C[0].width * 8, gUnknown_845661C[0].height * 8);
|
||||
@@ -2463,13 +2463,13 @@ void sub_8112FD0(void)
|
||||
sub_8112F18(gUnknown_203B020);
|
||||
}
|
||||
|
||||
const struct TextColor gUnknown_8456930 = {
|
||||
const u8 gUnknown_8456930[3] = {
|
||||
0, 10, 2
|
||||
};
|
||||
|
||||
void sub_8112FE4(const u8 * a0)
|
||||
{
|
||||
AddTextPrinterParameterized4(gUnknown_203B020, 0x02, 2, 5, 1, 1, &gUnknown_8456930, -1, a0);
|
||||
AddTextPrinterParameterized4(gUnknown_203B020, 0x02, 2, 5, 1, 1, gUnknown_8456930, -1, a0);
|
||||
}
|
||||
|
||||
void sub_8113018(const u8 * text, u8 mode)
|
||||
|
||||
@@ -26,7 +26,7 @@ void sub_812C334(s32 *, s32 *);
|
||||
|
||||
void sub_812BFDC(void)
|
||||
{
|
||||
if (!(gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_WALLY_TUTORIAL | BATTLE_TYPE_POKEDUDE)) && (gBattleOutcome == B_OUTCOME_WON || gBattleOutcome == B_OUTCOME_CAUGHT))
|
||||
if (!(gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_OLDMAN_TUTORIAL | BATTLE_TYPE_POKEDUDE)) && (gBattleOutcome == B_OUTCOME_WON || gBattleOutcome == B_OUTCOME_CAUGHT))
|
||||
{
|
||||
struct QuestLogStruct_TrainerBattleRecord * questLogTrainerBattleRecord = Alloc(sizeof(struct QuestLogStruct_TrainerBattleRecord));
|
||||
struct QuestLogStruct_WildBattleRecord * questLogWildBattleRecord = Alloc(sizeof(struct QuestLogStruct_WildBattleRecord));
|
||||
|
||||
@@ -0,0 +1,322 @@
|
||||
#include "global.h"
|
||||
#include "bg.h"
|
||||
#include "palette.h"
|
||||
#include "pokemon.h"
|
||||
#include "main.h"
|
||||
#include "link.h"
|
||||
#include "data.h"
|
||||
#include "sprite.h"
|
||||
#include "text.h"
|
||||
#include "gpu_regs.h"
|
||||
#include "scanline_effect.h"
|
||||
#include "help_system.h"
|
||||
#include "battle.h"
|
||||
#include "battle_interface.h"
|
||||
#include "battle_anim.h"
|
||||
#include "battle_controllers.h"
|
||||
#include "reshow_battle_screen.h"
|
||||
#include "constants/species.h"
|
||||
|
||||
static void CB2_ReshowBattleScreenAfterMenu(void);
|
||||
static void sub_8077AAC(void);
|
||||
static bool8 LoadBattlerSpriteGfx(u8 battlerId);
|
||||
static void CreateBattlerSprite(u8 battlerId);
|
||||
static void CreateHealthboxSprite(u8 battlerId);
|
||||
|
||||
void nullsub_44(void)
|
||||
{
|
||||
}
|
||||
|
||||
void ReshowBattleScreenAfterMenu(void)
|
||||
{
|
||||
gPaletteFade.bufferTransferDisabled = 1;
|
||||
SetHBlankCallback(NULL);
|
||||
SetGpuReg(REG_OFFSET_MOSAIC, 0);
|
||||
gBattleScripting.reshowMainState = 0;
|
||||
gBattleScripting.reshowHelperState = 0;
|
||||
if (!(gBattleTypeFlags & BATTLE_TYPE_LINK))
|
||||
{
|
||||
if (gBattleTypeFlags & BATTLE_TYPE_TRAINER)
|
||||
{
|
||||
if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE)
|
||||
HelpSystem_SetSomeVariable2(0x19);
|
||||
else
|
||||
HelpSystem_SetSomeVariable2(0x18);
|
||||
}
|
||||
else if (gBattleTypeFlags & BATTLE_TYPE_SAFARI)
|
||||
{
|
||||
HelpSystem_SetSomeVariable2(0x1A);
|
||||
}
|
||||
else
|
||||
{
|
||||
HelpSystem_SetSomeVariable2(0x17);
|
||||
}
|
||||
}
|
||||
SetMainCallback2(CB2_ReshowBattleScreenAfterMenu);
|
||||
}
|
||||
|
||||
static void CB2_ReshowBattleScreenAfterMenu(void)
|
||||
{
|
||||
u8 opponentBattler;
|
||||
u16 species;
|
||||
|
||||
switch (gBattleScripting.reshowMainState)
|
||||
{
|
||||
case 0:
|
||||
ResetSpriteData();
|
||||
break;
|
||||
case 1:
|
||||
SetVBlankCallback(NULL);
|
||||
ScanlineEffect_Clear();
|
||||
sub_800F324();
|
||||
SetBgAttribute(1, BG_ATTR_CHARBASEINDEX, 0);
|
||||
SetBgAttribute(2, BG_ATTR_CHARBASEINDEX, 0);
|
||||
ShowBg(0);
|
||||
ShowBg(1);
|
||||
ShowBg(2);
|
||||
ShowBg(3);
|
||||
ResetPaletteFade();
|
||||
gBattle_BG0_X = 0;
|
||||
gBattle_BG0_Y = 0;
|
||||
gBattle_BG1_X = 0;
|
||||
gBattle_BG1_Y = 0;
|
||||
gBattle_BG2_X = 0;
|
||||
gBattle_BG2_Y = 0;
|
||||
gBattle_BG3_X = 0;
|
||||
gBattle_BG3_Y = 0;
|
||||
break;
|
||||
case 2:
|
||||
CpuFastFill(0, (void *)VRAM, VRAM_SIZE);
|
||||
break;
|
||||
case 3:
|
||||
LoadBattleTextboxAndBackground();
|
||||
break;
|
||||
case 4:
|
||||
FreeAllSpritePalettes();
|
||||
gReservedSpritePaletteCount = 4;
|
||||
break;
|
||||
case 5:
|
||||
ClearSpritesHealthboxAnimData();
|
||||
break;
|
||||
case 6:
|
||||
if (BattleLoadAllHealthBoxesGfx(gBattleScripting.reshowHelperState))
|
||||
{
|
||||
gBattleScripting.reshowHelperState = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
++gBattleScripting.reshowHelperState;
|
||||
--gBattleScripting.reshowMainState;
|
||||
}
|
||||
break;
|
||||
case 7:
|
||||
if (!LoadBattlerSpriteGfx(0))
|
||||
--gBattleScripting.reshowMainState;
|
||||
break;
|
||||
case 8:
|
||||
if (!LoadBattlerSpriteGfx(1))
|
||||
--gBattleScripting.reshowMainState;
|
||||
break;
|
||||
case 9:
|
||||
if (!LoadBattlerSpriteGfx(2))
|
||||
--gBattleScripting.reshowMainState;
|
||||
break;
|
||||
case 0xA:
|
||||
if (!LoadBattlerSpriteGfx(3))
|
||||
--gBattleScripting.reshowMainState;
|
||||
break;
|
||||
case 0xB:
|
||||
CreateBattlerSprite(0);
|
||||
break;
|
||||
case 0xC:
|
||||
CreateBattlerSprite(1);
|
||||
break;
|
||||
case 0xD:
|
||||
CreateBattlerSprite(2);
|
||||
break;
|
||||
case 0xE:
|
||||
CreateBattlerSprite(3);
|
||||
break;
|
||||
case 0xF:
|
||||
CreateHealthboxSprite(0);
|
||||
break;
|
||||
case 0x10:
|
||||
CreateHealthboxSprite(1);
|
||||
break;
|
||||
case 0x11:
|
||||
CreateHealthboxSprite(2);
|
||||
break;
|
||||
case 0x12:
|
||||
CreateHealthboxSprite(3);
|
||||
break;
|
||||
case 0x13:
|
||||
LoadAndCreateEnemyShadowSprites();
|
||||
opponentBattler = GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT);
|
||||
species = GetMonData(&gEnemyParty[gBattlerPartyIndexes[opponentBattler]], MON_DATA_SPECIES);
|
||||
SetBattlerShadowSpriteCallback(opponentBattler, species);
|
||||
if (IsDoubleBattle())
|
||||
{
|
||||
opponentBattler = GetBattlerAtPosition(B_POSITION_OPPONENT_RIGHT);
|
||||
species = GetMonData(&gEnemyParty[gBattlerPartyIndexes[opponentBattler]], MON_DATA_SPECIES);
|
||||
SetBattlerShadowSpriteCallback(opponentBattler, species);
|
||||
}
|
||||
ActionSelectionCreateCursorAt(gActionSelectionCursor[gBattlerInMenuId], 0);
|
||||
if (gWirelessCommType && gReceivedRemoteLinkPlayers)
|
||||
{
|
||||
LoadWirelessStatusIndicatorSpriteGfx();
|
||||
CreateWirelessStatusIndicatorSprite(0, 0);
|
||||
}
|
||||
break;
|
||||
case 0x14:
|
||||
SetVBlankCallback(VBlankCB_Battle);
|
||||
sub_8077AAC();
|
||||
BeginHardwarePaletteFade(0xFF, 0, 0x10, 0, 1);
|
||||
gPaletteFade.bufferTransferDisabled = 0;
|
||||
SetMainCallback2(BattleMainCB2);
|
||||
sub_80357C8();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
++gBattleScripting.reshowMainState;
|
||||
}
|
||||
|
||||
static void sub_8077AAC(void)
|
||||
{
|
||||
EnableInterrupts(INTR_FLAG_VBLANK);
|
||||
SetGpuReg(REG_OFFSET_BLDCNT, 0);
|
||||
SetGpuReg(REG_OFFSET_BLDALPHA, 0);
|
||||
SetGpuReg(REG_OFFSET_BLDY, 0);
|
||||
SetGpuReg(REG_OFFSET_WININ, 0x3F);
|
||||
SetGpuReg(REG_OFFSET_WINOUT, 0x3F);
|
||||
SetGpuReg(REG_OFFSET_WIN0H, 0);
|
||||
SetGpuReg(REG_OFFSET_WIN0V, 0);
|
||||
SetGpuReg(REG_OFFSET_WIN1H, 0);
|
||||
SetGpuReg(REG_OFFSET_WIN1V, 0);
|
||||
SetGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_OBJ_1D_MAP | DISPCNT_OBJ_ON | DISPCNT_WIN0_ON | DISPCNT_OBJWIN_ON);
|
||||
}
|
||||
|
||||
static bool8 LoadBattlerSpriteGfx(u8 battler)
|
||||
{
|
||||
if (battler < gBattlersCount)
|
||||
{
|
||||
if (GetBattlerSide(battler) != B_SIDE_PLAYER)
|
||||
{
|
||||
if ((gBattleTypeFlags & (BATTLE_TYPE_LEGENDARY | BATTLE_TYPE_GHOST)) == BATTLE_TYPE_GHOST)
|
||||
DecompressGhostFrontPic(&gEnemyParty[gBattlerPartyIndexes[battler]], battler);
|
||||
else if (!gBattleSpritesDataPtr->battlerData[battler].behindSubstitute)
|
||||
BattleLoadOpponentMonSpriteGfx(&gEnemyParty[gBattlerPartyIndexes[battler]], battler);
|
||||
else
|
||||
BattleLoadSubstituteOrMonSpriteGfx(battler, FALSE);
|
||||
}
|
||||
else if (gBattleTypeFlags & BATTLE_TYPE_SAFARI && battler == B_POSITION_PLAYER_LEFT) // Should be checking position, not battler.
|
||||
DecompressTrainerBackPalette(gSaveBlock2Ptr->playerGender, battler);
|
||||
else if (gBattleTypeFlags & BATTLE_TYPE_OLDMAN_TUTORIAL && battler == B_POSITION_PLAYER_LEFT) // Should be checking position, not battler.
|
||||
DecompressTrainerBackPalette(5, battler);
|
||||
else if (!gBattleSpritesDataPtr->battlerData[battler].behindSubstitute)
|
||||
BattleLoadPlayerMonSpriteGfx(&gPlayerParty[gBattlerPartyIndexes[battler]], battler);
|
||||
else
|
||||
BattleLoadSubstituteOrMonSpriteGfx(battler, FALSE);
|
||||
gBattleScripting.reshowHelperState = 0;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void CreateBattlerSprite(u8 battler)
|
||||
{
|
||||
if (battler < gBattlersCount)
|
||||
{
|
||||
u8 posY;
|
||||
|
||||
if ((gBattleTypeFlags & (BATTLE_TYPE_LEGENDARY | BATTLE_TYPE_GHOST)) == BATTLE_TYPE_GHOST)
|
||||
posY = GetGhostSpriteDefault_Y(battler);
|
||||
else if (gBattleSpritesDataPtr->battlerData[battler].behindSubstitute)
|
||||
posY = GetSubstituteSpriteDefault_Y(battler);
|
||||
else
|
||||
posY = GetBattlerSpriteDefault_Y(battler);
|
||||
if (GetBattlerSide(battler) != B_SIDE_PLAYER)
|
||||
{
|
||||
if (GetMonData(&gEnemyParty[gBattlerPartyIndexes[battler]], MON_DATA_HP) == 0)
|
||||
return;
|
||||
SetMultiuseSpriteTemplateToPokemon(GetMonData(&gEnemyParty[gBattlerPartyIndexes[battler]], MON_DATA_SPECIES), GetBattlerPosition(battler));
|
||||
gBattlerSpriteIds[battler] = CreateSprite(&gMultiuseSpriteTemplate, GetBattlerSpriteCoord(battler, 2), posY, GetBattlerSpriteSubpriority(battler));
|
||||
gSprites[gBattlerSpriteIds[battler]].oam.paletteNum = battler;
|
||||
gSprites[gBattlerSpriteIds[battler]].callback = SpriteCallbackDummy;
|
||||
gSprites[gBattlerSpriteIds[battler]].data[0] = battler;
|
||||
gSprites[gBattlerSpriteIds[battler]].data[2] = GetMonData(&gEnemyParty[gBattlerPartyIndexes[battler]], MON_DATA_SPECIES);
|
||||
StartSpriteAnim(&gSprites[gBattlerSpriteIds[battler]], gBattleMonForms[battler]);
|
||||
}
|
||||
else if (gBattleTypeFlags & BATTLE_TYPE_SAFARI && battler == B_POSITION_PLAYER_LEFT)
|
||||
{
|
||||
SetMultiuseSpriteTemplateToTrainerBack(gSaveBlock2Ptr->playerGender, GetBattlerPosition(B_POSITION_PLAYER_LEFT));
|
||||
gBattlerSpriteIds[battler] = CreateSprite(&gMultiuseSpriteTemplate, 0x50,
|
||||
(8 - gTrainerBackPicCoords[gSaveBlock2Ptr->playerGender].size) * 4 + 80,
|
||||
GetBattlerSpriteSubpriority(0));
|
||||
gSprites[gBattlerSpriteIds[battler]].oam.paletteNum = battler;
|
||||
gSprites[gBattlerSpriteIds[battler]].callback = SpriteCallbackDummy;
|
||||
gSprites[gBattlerSpriteIds[battler]].data[0] = battler;
|
||||
}
|
||||
else if (gBattleTypeFlags & BATTLE_TYPE_OLDMAN_TUTORIAL && battler == B_POSITION_PLAYER_LEFT)
|
||||
{
|
||||
SetMultiuseSpriteTemplateToTrainerBack(5, GetBattlerPosition(0));
|
||||
gBattlerSpriteIds[battler] = CreateSprite(&gMultiuseSpriteTemplate, 0x50,
|
||||
(8 - gTrainerBackPicCoords[5].size) * 4 + 80,
|
||||
GetBattlerSpriteSubpriority(0));
|
||||
gSprites[gBattlerSpriteIds[battler]].oam.paletteNum = battler;
|
||||
gSprites[gBattlerSpriteIds[battler]].callback = SpriteCallbackDummy;
|
||||
gSprites[gBattlerSpriteIds[battler]].data[0] = battler;
|
||||
}
|
||||
else if (GetMonData(&gPlayerParty[gBattlerPartyIndexes[battler]], MON_DATA_HP) == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
SetMultiuseSpriteTemplateToPokemon(GetMonData(&gPlayerParty[gBattlerPartyIndexes[battler]], MON_DATA_SPECIES), GetBattlerPosition(battler));
|
||||
gBattlerSpriteIds[battler] = CreateSprite(&gMultiuseSpriteTemplate, GetBattlerSpriteCoord(battler, 2), posY, GetBattlerSpriteSubpriority(battler));
|
||||
gSprites[gBattlerSpriteIds[battler]].oam.paletteNum = battler;
|
||||
gSprites[gBattlerSpriteIds[battler]].callback = SpriteCallbackDummy;
|
||||
gSprites[gBattlerSpriteIds[battler]].data[0] = battler;
|
||||
gSprites[gBattlerSpriteIds[battler]].data[2] = GetMonData(&gPlayerParty[gBattlerPartyIndexes[battler]], MON_DATA_SPECIES);
|
||||
StartSpriteAnim(&gSprites[gBattlerSpriteIds[battler]], gBattleMonForms[battler]);
|
||||
}
|
||||
gSprites[gBattlerSpriteIds[battler]].invisible = gBattleSpritesDataPtr->battlerData[battler].invisible;
|
||||
}
|
||||
}
|
||||
|
||||
static void CreateHealthboxSprite(u8 battler)
|
||||
{
|
||||
if (battler < gBattlersCount)
|
||||
{
|
||||
u8 healthboxSpriteId;
|
||||
|
||||
if (gBattleTypeFlags & BATTLE_TYPE_SAFARI && battler == B_POSITION_PLAYER_LEFT)
|
||||
healthboxSpriteId = CreateSafariPlayerHealthboxSprites();
|
||||
else if (gBattleTypeFlags & BATTLE_TYPE_OLDMAN_TUTORIAL && battler == B_POSITION_PLAYER_LEFT)
|
||||
return;
|
||||
else
|
||||
healthboxSpriteId = CreateBattlerHealthboxSprites(battler);
|
||||
gHealthboxSpriteIds[battler] = healthboxSpriteId;
|
||||
InitBattlerHealthboxCoords(battler);
|
||||
SetHealthboxSpriteVisible(healthboxSpriteId);
|
||||
if (GetBattlerSide(battler) != B_SIDE_PLAYER)
|
||||
UpdateHealthboxAttribute(gHealthboxSpriteIds[battler], &gEnemyParty[gBattlerPartyIndexes[battler]], HEALTHBOX_ALL);
|
||||
else if (gBattleTypeFlags & BATTLE_TYPE_SAFARI)
|
||||
UpdateHealthboxAttribute(gHealthboxSpriteIds[battler], &gPlayerParty[gBattlerPartyIndexes[battler]], HEALTHBOX_SAFARI_ALL_TEXT);
|
||||
else
|
||||
UpdateHealthboxAttribute(gHealthboxSpriteIds[battler], &gPlayerParty[gBattlerPartyIndexes[battler]], HEALTHBOX_ALL);
|
||||
if (GetBattlerPosition(battler) == B_POSITION_OPPONENT_RIGHT || GetBattlerPosition(battler) == B_POSITION_PLAYER_RIGHT)
|
||||
DummyBattleInterfaceFunc(gHealthboxSpriteIds[battler], TRUE);
|
||||
else
|
||||
DummyBattleInterfaceFunc(gHealthboxSpriteIds[battler], FALSE);
|
||||
if (GetBattlerSide(battler) != B_SIDE_PLAYER)
|
||||
{
|
||||
if (GetMonData(&gEnemyParty[gBattlerPartyIndexes[battler]], MON_DATA_HP) == 0)
|
||||
SetHealthboxSpriteInvisible(healthboxSpriteId);
|
||||
}
|
||||
else if (!(gBattleTypeFlags & BATTLE_TYPE_SAFARI) && GetMonData(&gPlayerParty[gBattlerPartyIndexes[battler]], MON_DATA_HP) == 0)
|
||||
{
|
||||
SetHealthboxSpriteInvisible(healthboxSpriteId);
|
||||
}
|
||||
}
|
||||
}
|
||||
+4
-4
@@ -68,7 +68,7 @@ const struct SaveSectionOffsets gSaveSectionOffsets[] =
|
||||
|
||||
extern void DoSaveFailedScreen(u8 saveType); // save_failed_screen
|
||||
extern void sub_800AB9C(void); // link
|
||||
extern bool8 sub_800A4BC(void); // link
|
||||
extern bool8 IsLinkTaskFinished(void); // link
|
||||
extern void save_serialize_map(void); // fieldmap
|
||||
extern void sub_804C1C0(void); // load_save
|
||||
extern void sav2_gender2_inplace_and_xFE(void); // load_save
|
||||
@@ -865,7 +865,7 @@ void sub_80DA634(u8 taskId)
|
||||
gTasks[taskId].data[0] = 2;
|
||||
break;
|
||||
case 2:
|
||||
if (sub_800A4BC())
|
||||
if (IsLinkTaskFinished())
|
||||
{
|
||||
save_serialize_map();
|
||||
gTasks[taskId].data[0] = 3;
|
||||
@@ -899,7 +899,7 @@ void sub_80DA634(u8 taskId)
|
||||
gTasks[taskId].data[0] = 8;
|
||||
break;
|
||||
case 8:
|
||||
if (sub_800A4BC())
|
||||
if (IsLinkTaskFinished())
|
||||
{
|
||||
sub_80DA434();
|
||||
gTasks[taskId].data[0] = 9;
|
||||
@@ -910,7 +910,7 @@ void sub_80DA634(u8 taskId)
|
||||
gTasks[taskId].data[0] = 10;
|
||||
break;
|
||||
case 10:
|
||||
if (sub_800A4BC())
|
||||
if (IsLinkTaskFinished())
|
||||
gTasks[taskId].data[0]++;
|
||||
break;
|
||||
case 11:
|
||||
|
||||
+8
-8
@@ -25,7 +25,7 @@
|
||||
#include "start_menu.h"
|
||||
#include "script_menu.h"
|
||||
#include "string_util.h"
|
||||
#include "data2.h"
|
||||
#include "data.h"
|
||||
#include "field_specials.h"
|
||||
#include "constants/items.h"
|
||||
#include "script_pokemon_util_80A0058.h"
|
||||
@@ -733,7 +733,7 @@ bool8 ScrCmd_warp(struct ScriptContext *ctx)
|
||||
u16 x = VarGet(ScriptReadHalfword(ctx));
|
||||
u16 y = VarGet(ScriptReadHalfword(ctx));
|
||||
|
||||
Overworld_SetWarpDestination(mapGroup, mapNum, warpId, x, y);
|
||||
SetWarpDestination(mapGroup, mapNum, warpId, x, y);
|
||||
DoWarp();
|
||||
ResetInitialPlayerAvatarState();
|
||||
return TRUE;
|
||||
@@ -747,7 +747,7 @@ bool8 ScrCmd_warpsilent(struct ScriptContext *ctx)
|
||||
u16 x = VarGet(ScriptReadHalfword(ctx));
|
||||
u16 y = VarGet(ScriptReadHalfword(ctx));
|
||||
|
||||
Overworld_SetWarpDestination(mapGroup, mapNum, warpId, x, y);
|
||||
SetWarpDestination(mapGroup, mapNum, warpId, x, y);
|
||||
DoDiveWarp();
|
||||
ResetInitialPlayerAvatarState();
|
||||
return TRUE;
|
||||
@@ -761,7 +761,7 @@ bool8 ScrCmd_warpdoor(struct ScriptContext *ctx)
|
||||
u16 x = VarGet(ScriptReadHalfword(ctx));
|
||||
u16 y = VarGet(ScriptReadHalfword(ctx));
|
||||
|
||||
Overworld_SetWarpDestination(mapGroup, mapNum, warpId, x, y);
|
||||
SetWarpDestination(mapGroup, mapNum, warpId, x, y);
|
||||
DoDoorWarp();
|
||||
ResetInitialPlayerAvatarState();
|
||||
return TRUE;
|
||||
@@ -778,7 +778,7 @@ bool8 ScrCmd_warphole(struct ScriptContext *ctx)
|
||||
if (mapGroup == 0xFF && mapNum == 0xFF)
|
||||
SetWarpDestinationToFixedHoleWarp(x - 7, y - 7);
|
||||
else
|
||||
Overworld_SetWarpDestination(mapGroup, mapNum, -1, x - 7, y - 7);
|
||||
SetWarpDestination(mapGroup, mapNum, -1, x - 7, y - 7);
|
||||
DoFallWarp();
|
||||
ResetInitialPlayerAvatarState();
|
||||
return TRUE;
|
||||
@@ -792,7 +792,7 @@ bool8 ScrCmd_warpteleport(struct ScriptContext *ctx)
|
||||
u16 x = VarGet(ScriptReadHalfword(ctx));
|
||||
u16 y = VarGet(ScriptReadHalfword(ctx));
|
||||
|
||||
Overworld_SetWarpDestination(mapGroup, mapNum, warpId, x, y);
|
||||
SetWarpDestination(mapGroup, mapNum, warpId, x, y);
|
||||
sub_807E59C();
|
||||
ResetInitialPlayerAvatarState();
|
||||
return TRUE;
|
||||
@@ -806,7 +806,7 @@ bool8 ScrCmd_warpteleport2(struct ScriptContext *ctx)
|
||||
u16 x = VarGet(ScriptReadHalfword(ctx));
|
||||
u16 y = VarGet(ScriptReadHalfword(ctx));
|
||||
|
||||
Overworld_SetWarpDestination(mapGroup, mapNum, warpId, x, y);
|
||||
SetWarpDestination(mapGroup, mapNum, warpId, x, y);
|
||||
sub_805DAE4(GetPlayerFacingDirection());
|
||||
sub_807E500();
|
||||
ResetInitialPlayerAvatarState();
|
||||
@@ -821,7 +821,7 @@ bool8 ScrCmd_setwarp(struct ScriptContext *ctx)
|
||||
u16 x = VarGet(ScriptReadHalfword(ctx));
|
||||
u16 y = VarGet(ScriptReadHalfword(ctx));
|
||||
|
||||
Overworld_SetWarpDestination(mapGroup, mapNum, warpId, x, y);
|
||||
SetWarpDestination(mapGroup, mapNum, warpId, x, y);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -319,7 +319,7 @@ static void Task_SeaGallop_3(void)
|
||||
gSpecialVar_0x8006 = 0;
|
||||
|
||||
warpInfo = sSeaGallopSpawnTable[gSpecialVar_0x8006];
|
||||
Overworld_SetWarpDestination(warpInfo[0], warpInfo[1], -1, warpInfo[2], warpInfo[3]);
|
||||
SetWarpDestination(warpInfo[0], warpInfo[1], -1, warpInfo[2], warpInfo[3]);
|
||||
PlayRainStoppingSoundEffect();
|
||||
PlaySE(SE_KAIDAN);
|
||||
gFieldCallback = sub_807DF64;
|
||||
|
||||
+5
-5
@@ -2074,7 +2074,7 @@ static bool32 sub_8141180(u8 a0)
|
||||
static bool8 sub_8141198(u8 * state, struct SlotMachineSetupTaskData * ptr)
|
||||
{
|
||||
u16 pal;
|
||||
struct TextColor textColor;
|
||||
u8 textColor[3];
|
||||
u32 x;
|
||||
|
||||
switch (*state)
|
||||
@@ -2125,10 +2125,10 @@ static bool8 sub_8141198(u8 * state, struct SlotMachineSetupTaskData * ptr)
|
||||
PutWindowTilemap(1);
|
||||
|
||||
x = 0xEC - GetStringWidth(0, gString_SlotMachineControls, 0);
|
||||
textColor.fgColor = 15;
|
||||
textColor.bgColor = 1;
|
||||
textColor.shadowColor = 2;
|
||||
AddTextPrinterParameterized3(1, 0, x, 0, &textColor, 0, gString_SlotMachineControls);
|
||||
textColor[0] = 15;
|
||||
textColor[1] = 1;
|
||||
textColor[2] = 2;
|
||||
AddTextPrinterParameterized3(1, 0, x, 0, textColor, 0, gString_SlotMachineControls);
|
||||
CopyBgTilemapBufferToVram(0);
|
||||
|
||||
SetGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_MODE_0 | 0x20 | DISPCNT_OBJ_1D_MAP | DISPCNT_OBJ_ON);
|
||||
|
||||
+2
-2
@@ -15,7 +15,7 @@ struct Fanfare
|
||||
};
|
||||
|
||||
// TODO: what are these
|
||||
extern u8 gUnknown_2031DD8;
|
||||
extern u8 gDisableMapMusicChangeOnMapLoad;
|
||||
extern u8 gUnknown_203ADFA;
|
||||
extern u8 gUnknown_203F174;
|
||||
|
||||
@@ -571,7 +571,7 @@ void PlayBGM(u16 songNum)
|
||||
|
||||
void PlaySE(u16 songNum)
|
||||
{
|
||||
if(gUnknown_2031DD8 == 0 && gUnknown_203ADFA != 2)
|
||||
if(gDisableMapMusicChangeOnMapLoad == 0 && gUnknown_203ADFA != 2)
|
||||
m4aSongNumStart(songNum);
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,10 @@
|
||||
#include "string_util.h"
|
||||
#include "text.h"
|
||||
|
||||
EWRAM_DATA u8 gStringVar1[32] = {};
|
||||
EWRAM_DATA u8 gStringVar2[20] = {};
|
||||
EWRAM_DATA u8 gStringVar3[20] = {};
|
||||
EWRAM_DATA u8 gStringVar4[1000] = {};
|
||||
EWRAM_DATA u8 gUnknownStringVar[16] = {0};
|
||||
|
||||
static const u8 sDigits[] = __("0123456789ABCDEF");
|
||||
|
||||
+1
-1
@@ -23,7 +23,7 @@
|
||||
#include "event_data.h"
|
||||
#include "load_save.h"
|
||||
#include "battle_transition.h"
|
||||
#include "battle_2.h"
|
||||
#include "battle_main.h"
|
||||
#include "battle.h"
|
||||
#include "global.fieldmap.h"
|
||||
#include "teachy_tv.h"
|
||||
|
||||
+351
-833
File diff suppressed because it is too large
Load Diff
+30
-30
@@ -45,27 +45,27 @@ void DeactivateAllTextPrinters (void)
|
||||
{
|
||||
int printer;
|
||||
for (printer = 0; printer < NUM_TEXT_PRINTERS; ++printer)
|
||||
sTextPrinters[printer].sub_union.sub.active = 0;
|
||||
sTextPrinters[printer].active = 0;
|
||||
}
|
||||
|
||||
u16 AddTextPrinterParameterized(u8 windowId, u8 fontId, const u8 *str, u8 x, u8 y, u8 speed, void (*callback)(struct TextPrinterTemplate *, u16))
|
||||
{
|
||||
struct TextPrinterTemplate subPrinter;
|
||||
struct TextPrinterTemplate printerTemplate;
|
||||
|
||||
subPrinter.currentChar = str;
|
||||
subPrinter.windowId = windowId;
|
||||
subPrinter.fontId = fontId;
|
||||
subPrinter.x = x;
|
||||
subPrinter.y = y;
|
||||
subPrinter.currentX = x;
|
||||
subPrinter.currentY = y;
|
||||
subPrinter.letterSpacing = gFonts[fontId].letterSpacing;
|
||||
subPrinter.lineSpacing = gFonts[fontId].lineSpacing;
|
||||
subPrinter.unk = gFonts[fontId].unk;
|
||||
subPrinter.fgColor = gFonts[fontId].fgColor;
|
||||
subPrinter.bgColor = gFonts[fontId].bgColor;
|
||||
subPrinter.shadowColor = gFonts[fontId].shadowColor;
|
||||
return AddTextPrinter(&subPrinter, speed, callback);
|
||||
printerTemplate.currentChar = str;
|
||||
printerTemplate.windowId = windowId;
|
||||
printerTemplate.fontId = fontId;
|
||||
printerTemplate.x = x;
|
||||
printerTemplate.y = y;
|
||||
printerTemplate.currentX = x;
|
||||
printerTemplate.currentY = y;
|
||||
printerTemplate.letterSpacing = gFonts[fontId].letterSpacing;
|
||||
printerTemplate.lineSpacing = gFonts[fontId].lineSpacing;
|
||||
printerTemplate.unk = gFonts[fontId].unk;
|
||||
printerTemplate.fgColor = gFonts[fontId].fgColor;
|
||||
printerTemplate.bgColor = gFonts[fontId].bgColor;
|
||||
printerTemplate.shadowColor = gFonts[fontId].shadowColor;
|
||||
return AddTextPrinter(&printerTemplate, speed, callback);
|
||||
}
|
||||
|
||||
bool16 AddTextPrinter(struct TextPrinterTemplate *textSubPrinter, u8 speed, void (*callback)(struct TextPrinterTemplate *, u16))
|
||||
@@ -76,18 +76,18 @@ bool16 AddTextPrinter(struct TextPrinterTemplate *textSubPrinter, u8 speed, void
|
||||
if (!gFonts)
|
||||
return FALSE;
|
||||
|
||||
sTempTextPrinter.sub_union.sub.active = 1;
|
||||
sTempTextPrinter.active = 1;
|
||||
sTempTextPrinter.state = 0;
|
||||
sTempTextPrinter.text_speed = speed;
|
||||
sTempTextPrinter.textSpeed = speed;
|
||||
sTempTextPrinter.delayCounter = 0;
|
||||
sTempTextPrinter.scrollDistance = 0;
|
||||
|
||||
for (i = 0; i < 7; ++i)
|
||||
{
|
||||
sTempTextPrinter.sub_union.sub_fields[i] = 0;
|
||||
sTempTextPrinter.subUnion.fields[i] = 0;
|
||||
}
|
||||
|
||||
sTempTextPrinter.subPrinter = *textSubPrinter;
|
||||
sTempTextPrinter.printerTemplate = *textSubPrinter;
|
||||
sTempTextPrinter.callback = callback;
|
||||
sTempTextPrinter.minLetterSpacing = 0;
|
||||
sTempTextPrinter.japanese = 0;
|
||||
@@ -95,12 +95,12 @@ bool16 AddTextPrinter(struct TextPrinterTemplate *textSubPrinter, u8 speed, void
|
||||
GenerateFontHalfRowLookupTable(textSubPrinter->fgColor, textSubPrinter->bgColor, textSubPrinter->shadowColor);
|
||||
if (speed != TEXT_SPEED_FF && speed != 0x0)
|
||||
{
|
||||
--sTempTextPrinter.text_speed;
|
||||
--sTempTextPrinter.textSpeed;
|
||||
sTextPrinters[textSubPrinter->windowId] = sTempTextPrinter;
|
||||
}
|
||||
else
|
||||
{
|
||||
sTempTextPrinter.text_speed = 0;
|
||||
sTempTextPrinter.textSpeed = 0;
|
||||
for (j = 0; j < 0x400; ++j)
|
||||
{
|
||||
if ((u32)RenderFont(&sTempTextPrinter) == 1)
|
||||
@@ -108,8 +108,8 @@ bool16 AddTextPrinter(struct TextPrinterTemplate *textSubPrinter, u8 speed, void
|
||||
}
|
||||
|
||||
if (speed != TEXT_SPEED_FF)
|
||||
CopyWindowToVram(sTempTextPrinter.subPrinter.windowId, 2);
|
||||
sTextPrinters[textSubPrinter->windowId].sub_union.sub.active = 0;
|
||||
CopyWindowToVram(sTempTextPrinter.printerTemplate.windowId, 2);
|
||||
sTextPrinters[textSubPrinter->windowId].active = 0;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
@@ -121,18 +121,18 @@ void RunTextPrinters(void)
|
||||
|
||||
for (i = 0; i < 0x20; ++i)
|
||||
{
|
||||
if (sTextPrinters[i].sub_union.sub.active != 0)
|
||||
if (sTextPrinters[i].active != 0)
|
||||
{
|
||||
temp = RenderFont(&sTextPrinters[i]);
|
||||
switch (temp) {
|
||||
case 0:
|
||||
CopyWindowToVram(sTextPrinters[i].subPrinter.windowId, 2);
|
||||
CopyWindowToVram(sTextPrinters[i].printerTemplate.windowId, 2);
|
||||
case 3:
|
||||
if (sTextPrinters[i].callback != 0)
|
||||
sTextPrinters[i].callback(&sTextPrinters[i].subPrinter, temp);
|
||||
sTextPrinters[i].callback(&sTextPrinters[i].printerTemplate, temp);
|
||||
break;
|
||||
case 1:
|
||||
sTextPrinters[i].sub_union.sub.active = 0;
|
||||
sTextPrinters[i].active = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -141,7 +141,7 @@ void RunTextPrinters(void)
|
||||
|
||||
bool16 IsTextPrinterActive(u8 id)
|
||||
{
|
||||
return sTextPrinters[id].sub_union.sub.active;
|
||||
return sTextPrinters[id].active;
|
||||
}
|
||||
|
||||
u32 RenderFont(struct TextPrinter *textPrinter)
|
||||
@@ -149,7 +149,7 @@ u32 RenderFont(struct TextPrinter *textPrinter)
|
||||
u32 ret;
|
||||
while (TRUE)
|
||||
{
|
||||
ret = gFonts[textPrinter->subPrinter.fontId].fontFunction(textPrinter);
|
||||
ret = gFonts[textPrinter->printerTemplate.fontId].fontFunction(textPrinter);
|
||||
if (ret != 2)
|
||||
return ret;
|
||||
}
|
||||
|
||||
+4
-4
@@ -21,7 +21,7 @@
|
||||
#include "pokemon_storage_system.h"
|
||||
#include "string_util.h"
|
||||
#include "party_menu.h"
|
||||
#include "data2.h"
|
||||
#include "data.h"
|
||||
#include "scanline_effect.h"
|
||||
#include "sound.h"
|
||||
#include "strings.h"
|
||||
@@ -185,7 +185,7 @@ static const u8 sText_SingleSpace[] = _(" ");
|
||||
|
||||
static ALIGNED(4) const u16 sPal3Override[] = {RGB(8, 8, 8), RGB(30, 16, 6)};
|
||||
|
||||
static const struct TextColor sTextColors[] = {
|
||||
static const u8 sTextColors[][3] = {
|
||||
{0, 1, 2},
|
||||
{0, 2, 3},
|
||||
{0, 3, 6},
|
||||
@@ -1317,7 +1317,7 @@ static void InitWindowTemplatesAndPals(void)
|
||||
|
||||
static void AddTextPrinterParameterized_ColorByIndex(u8 windowId, u8 fontId, const u8 * str, u8 x, u8 y, u8 letterSpacing, u8 lineSpacing, u8 speed, u8 colorIdx)
|
||||
{
|
||||
AddTextPrinterParameterized4(windowId, fontId, x, y, letterSpacing, lineSpacing, &sTextColors[colorIdx], speed, str);
|
||||
AddTextPrinterParameterized4(windowId, fontId, x, y, letterSpacing, lineSpacing, sTextColors[colorIdx], speed, str);
|
||||
}
|
||||
|
||||
static void TMCase_SetWindowBorder1(u8 windowId)
|
||||
@@ -1339,7 +1339,7 @@ static void TMCase_PrintMessageWithFollowupTask(u8 taskId, u8 windowId, const u8
|
||||
static void PrintStringTMCaseOnWindow3(void)
|
||||
{
|
||||
u32 distance = 72 - GetStringWidth(1, gText_TMCase, 0);
|
||||
AddTextPrinterParameterized3(3, 1, distance / 2, 1, &sTextColors[0], 0, gText_TMCase);
|
||||
AddTextPrinterParameterized3(3, 1, distance / 2, 1, sTextColors[0], 0, gText_TMCase);
|
||||
}
|
||||
|
||||
static void DrawMoveInfoUIMarkers(void)
|
||||
|
||||
@@ -104,7 +104,7 @@ void LoadPicPaletteByTagOrSlot(u16 species, u32 otId, u32 personality, u8 palett
|
||||
if (paletteTag == 0xFFFF)
|
||||
{
|
||||
sCreatingSpriteTemplate.paletteTag = 0xFFFF;
|
||||
LoadCompressedPalette(GetFrontSpritePalFromSpeciesAndPersonality(species, otId, personality), 0x100 + paletteSlot * 0x10, 0x20);
|
||||
LoadCompressedPalette(GetMonSpritePalFromSpeciesAndPersonality(species, otId, personality), 0x100 + paletteSlot * 0x10, 0x20);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -130,7 +130,7 @@ void LoadPicPaletteByTagOrSlot(u16 species, u32 otId, u32 personality, u8 palett
|
||||
void LoadPicPaletteBySlot(u16 species, u32 otId, u32 personality, u8 paletteSlot, bool8 isTrainer)
|
||||
{
|
||||
if (!isTrainer)
|
||||
LoadCompressedPalette(GetFrontSpritePalFromSpeciesAndPersonality(species, otId, personality), paletteSlot * 0x10, 0x20);
|
||||
LoadCompressedPalette(GetMonSpritePalFromSpeciesAndPersonality(species, otId, personality), paletteSlot * 0x10, 0x20);
|
||||
else
|
||||
LoadCompressedPalette(gTrainerFrontPicPaletteTable[species].data, paletteSlot * 0x10, 0x20);
|
||||
}
|
||||
@@ -278,7 +278,7 @@ u16 FreeAndDestroyMonPicSprite(u16 spriteId)
|
||||
return FreeAndDestroyPicSpriteInternal(spriteId);
|
||||
}
|
||||
|
||||
u16 sub_810C228(u16 species, u32 otId, u32 personality, bool8 isFrontPic, u8 paletteSlot, u8 windowId)
|
||||
u16 LoadMonPicInWindow(u16 species, u32 otId, u32 personality, bool8 isFrontPic, u8 paletteSlot, u8 windowId)
|
||||
{
|
||||
return sub_810C0C0(species, otId, personality, isFrontPic, 0, 0, paletteSlot, windowId, FALSE);
|
||||
}
|
||||
|
||||
+10
-10
@@ -17,7 +17,7 @@
|
||||
#include "battle_setup.h"
|
||||
#include "battle_transition.h"
|
||||
#include "battle.h"
|
||||
#include "battle_2.h"
|
||||
#include "battle_main.h"
|
||||
#include "overworld.h"
|
||||
#include "item.h"
|
||||
#include "window.h"
|
||||
@@ -423,7 +423,7 @@ const struct WindowTemplate gUnknown_847A218[] = {
|
||||
|
||||
const u32 gUnknown_847A228 = 0x70; // unused
|
||||
|
||||
const struct TextColor gUnknown_847A22C = {0, 2, 3};
|
||||
const u8 gUnknown_847A22C[3] = {0, 2, 3};
|
||||
|
||||
void (*const gUnknown_847A230[])(void) = {
|
||||
sub_815DD44,
|
||||
@@ -626,12 +626,12 @@ void sub_815DA28(u8 * dest)
|
||||
StringCopyN(dest, gUnknown_203F45C->unk_00, 11);
|
||||
}
|
||||
|
||||
u8 sub_815DA3C(void)
|
||||
u8 GetTrainerTowerTrainerFrontSpriteId(void)
|
||||
{
|
||||
return gFacilityClassToPicIndex[gUnknown_203F45C->unk_3D];
|
||||
}
|
||||
|
||||
void sub_815DA54(void)
|
||||
void InitTrainerTowerBattleStruct(void)
|
||||
{
|
||||
u16 r10;
|
||||
s32 r9;
|
||||
@@ -660,7 +660,7 @@ void sub_815DA54(void)
|
||||
sub_815DD2C();
|
||||
}
|
||||
|
||||
void sub_815DBDC(void)
|
||||
void FreeTrainerTowerBattleStruct(void)
|
||||
{
|
||||
Free(gUnknown_203F45C);
|
||||
gUnknown_203F45C = NULL;
|
||||
@@ -1122,7 +1122,7 @@ void sub_815E124(u8 taskId)
|
||||
|
||||
void sub_815E160(void)
|
||||
{
|
||||
gBattleTypeFlags = BATTLE_TYPE_TRAINER | BATTLE_TYPE_FACTORY;
|
||||
gBattleTypeFlags = BATTLE_TYPE_TRAINER | BATTLE_TYPE_TRAINER_TOWER;
|
||||
if (gUnknown_203F458->unk_0004.trainers[gUnknown_203F458->unk_0000].unk_002 == 1)
|
||||
gBattleTypeFlags |= BATTLE_TYPE_DOUBLE;
|
||||
gTrainerBattleOpponent_A = 0;
|
||||
@@ -1433,14 +1433,14 @@ void PrintTrainerTowerRecords(void)
|
||||
sub_815DC8C();
|
||||
FillWindowPixelRect(0, 0, 0, 0, 0xd8, 0x90);
|
||||
sub_815EC0C();
|
||||
AddTextPrinterParameterized3(0, 2, 0x4a, 0, &gUnknown_847A22C, 0, gUnknown_83FE982);
|
||||
AddTextPrinterParameterized3(0, 2, 0x4a, 0, gUnknown_847A22C, 0, gUnknown_83FE982);
|
||||
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
PRINT_TOWER_TIME(sub_815EDDC(&gSaveBlock1Ptr->unkArray[i].unk4));
|
||||
StringExpandPlaceholders(gStringVar4, gUnknown_83FE998);
|
||||
AddTextPrinterParameterized3(windowId, 2, 0x18, 0x24 + 0x14 * i, &gUnknown_847A22C, 0, gUnknown_83FE9C4[i]);
|
||||
AddTextPrinterParameterized3(windowId, 2, 0x60, 0x24 + 0x14 * i, &gUnknown_847A22C, 0, gStringVar4);
|
||||
AddTextPrinterParameterized3(windowId, 2, 0x18, 0x24 + 0x14 * i, gUnknown_847A22C, 0, gUnknown_83FE9C4[i]);
|
||||
AddTextPrinterParameterized3(windowId, 2, 0x60, 0x24 + 0x14 * i, gUnknown_847A22C, 0, gStringVar4);
|
||||
}
|
||||
|
||||
PutWindowTilemap(windowId);
|
||||
@@ -1458,7 +1458,7 @@ void sub_815EDF4(u32 * counter, u32 value)
|
||||
*counter = value ^ gSaveBlock2Ptr->encryptionKey;
|
||||
}
|
||||
|
||||
void sub_815EE0C(void)
|
||||
void ResetTrainerTowerResults(void)
|
||||
{
|
||||
s32 i;
|
||||
|
||||
|
||||
@@ -0,0 +1,308 @@
|
||||
#include "global.h"
|
||||
#include "field_specials.h"
|
||||
#include "event_data.h"
|
||||
#include "wild_encounter.h"
|
||||
#include "roamer.h"
|
||||
#include "overworld.h"
|
||||
#include "pokedex_area_markers.h"
|
||||
#include "constants/vars.h"
|
||||
#include "constants/region_map.h"
|
||||
#include "constants/species.h"
|
||||
|
||||
struct SeviiDexArea
|
||||
{
|
||||
const u16 (*lut)[2];
|
||||
s32 count;
|
||||
};
|
||||
|
||||
struct RoamerPair
|
||||
{
|
||||
u16 roamer;
|
||||
u16 starter;
|
||||
};
|
||||
|
||||
static s32 GetRoamerIndex(u16 species);
|
||||
static s32 CountRoamerNests(u16 species, struct Subsprite * subsprites);
|
||||
static bool32 PokemonInAnyEncounterTableInMap(const struct WildPokemonHeader * data, s32 species);
|
||||
static bool32 PokemonInEncounterTable(const struct WildPokemonInfo * pokemon, s32 species, s32 count);
|
||||
static u16 GetMapSecIdFromWildMonHeader(const struct WildPokemonHeader * header);
|
||||
static bool32 TryGetMapSecPokedexAreaEntry(u16 mapSecId, const u16 (*lut)[2], s32 count, s32 * lutIdx_p, u16 * tableIdx_p);
|
||||
|
||||
static const u16 sDexAreas_Kanto[][2] = {
|
||||
{ MAPSEC_PALLET_TOWN, 1 },
|
||||
{ MAPSEC_VIRIDIAN_CITY, 2 },
|
||||
{ MAPSEC_PEWTER_CITY, 3 },
|
||||
{ MAPSEC_CERULEAN_CITY, 4 },
|
||||
{ MAPSEC_LAVENDER_TOWN, 5 },
|
||||
{ MAPSEC_VERMILION_CITY, 6 },
|
||||
{ MAPSEC_CELADON_CITY, 7 },
|
||||
{ MAPSEC_FUCHSIA_CITY, 8 },
|
||||
{ MAPSEC_CINNABAR_ISLAND, 9 },
|
||||
{ MAPSEC_INDIGO_PLATEAU, 10 },
|
||||
{ MAPSEC_SAFFRON_CITY, 11 },
|
||||
{ MAPSEC_ROUTE_4_FLYDUP, 15 },
|
||||
{ MAPSEC_ROUTE_10_FLYDUP, 21 },
|
||||
{ MAPSEC_ROUTE_1, 12 },
|
||||
{ MAPSEC_ROUTE_2, 13 },
|
||||
{ MAPSEC_ROUTE_3, 14 },
|
||||
{ MAPSEC_ROUTE_4, 15 },
|
||||
{ MAPSEC_ROUTE_5, 16 },
|
||||
{ MAPSEC_ROUTE_6, 17 },
|
||||
{ MAPSEC_ROUTE_7, 18 },
|
||||
{ MAPSEC_ROUTE_8, 19 },
|
||||
{ MAPSEC_ROUTE_9, 20 },
|
||||
{ MAPSEC_ROUTE_10, 21 },
|
||||
{ MAPSEC_ROUTE_11, 22 },
|
||||
{ MAPSEC_ROUTE_12, 23 },
|
||||
{ MAPSEC_ROUTE_13, 24 },
|
||||
{ MAPSEC_ROUTE_14, 25 },
|
||||
{ MAPSEC_ROUTE_15, 26 },
|
||||
{ MAPSEC_ROUTE_16, 27 },
|
||||
{ MAPSEC_ROUTE_17, 28 },
|
||||
{ MAPSEC_ROUTE_18, 29 },
|
||||
{ MAPSEC_ROUTE_19, 30 },
|
||||
{ MAPSEC_ROUTE_20, 31 },
|
||||
{ MAPSEC_ROUTE_21, 32 },
|
||||
{ MAPSEC_ROUTE_22, 33 },
|
||||
{ MAPSEC_ROUTE_23, 34 },
|
||||
{ MAPSEC_ROUTE_24, 35 },
|
||||
{ MAPSEC_ROUTE_25, 36 },
|
||||
{ MAPSEC_VIRIDIAN_FOREST, 37 },
|
||||
{ MAPSEC_MT_MOON, 39 },
|
||||
{ MAPSEC_S_S_ANNE, 6 },
|
||||
{ MAPSEC_UNDERGROUND_PATH, 11 },
|
||||
{ MAPSEC_UNDERGROUND_PATH_2, 11 },
|
||||
{ MAPSEC_DIGLETTS_CAVE, 38 },
|
||||
{ MAPSEC_KANTO_VICTORY_ROAD, 47 },
|
||||
{ MAPSEC_ROCKET_HIDEOUT, 7 },
|
||||
{ MAPSEC_SILPH_CO, 11 },
|
||||
{ MAPSEC_POKEMON_MANSION, 46 },
|
||||
{ MAPSEC_KANTO_SAFARI_ZONE, 44 },
|
||||
{ MAPSEC_POKEMON_LEAGUE, 47 },
|
||||
{ MAPSEC_ROCK_TUNNEL, 41 },
|
||||
{ MAPSEC_SEAFOAM_ISLANDS, 45 },
|
||||
{ MAPSEC_POKEMON_TOWER, 43 },
|
||||
{ MAPSEC_CERULEAN_CAVE, 40 },
|
||||
{ MAPSEC_POWER_PLANT, 42 }
|
||||
};
|
||||
|
||||
static const u16 sDexAreas_Sevii1[][2] = {
|
||||
{ MAPSEC_KINDLE_ROAD, 55 },
|
||||
{ MAPSEC_TREASURE_BEACH, 56 },
|
||||
{ MAPSEC_ONE_ISLAND, 48 },
|
||||
{ MAPSEC_MT_EMBER, 72 }
|
||||
};
|
||||
|
||||
static const u16 sDexAreas_Sevii2[][2] = {
|
||||
{ MAPSEC_CAPE_BRINK, 57 },
|
||||
{ MAPSEC_TWO_ISLAND, 49 }
|
||||
};
|
||||
|
||||
static const u16 sDexAreas_Sevii3[][2] = {
|
||||
{ MAPSEC_BOND_BRIDGE, 58 },
|
||||
{ MAPSEC_THREE_ISLE_PORT, 59 },
|
||||
{ MAPSEC_THREE_ISLAND, 50 },
|
||||
{ MAPSEC_BERRY_FOREST, 73 },
|
||||
{ MAPSEC_THREE_ISLE_PATH, 59 }
|
||||
};
|
||||
|
||||
static const u16 sDexAreas_Sevii4[][2] = {
|
||||
{ MAPSEC_FOUR_ISLAND, 51 },
|
||||
{ MAPSEC_ICEFALL_CAVE, 74 }
|
||||
};
|
||||
|
||||
static const u16 sDexAreas_Sevii5[][2] = {
|
||||
{ MAPSEC_RESORT_GORGEOUS, 60 },
|
||||
{ MAPSEC_WATER_LABYRINTH, 61 },
|
||||
{ MAPSEC_FIVE_ISLE_MEADOW, 62 },
|
||||
{ MAPSEC_MEMORIAL_PILLAR, 63 },
|
||||
{ MAPSEC_FIVE_ISLAND, 52 },
|
||||
{ MAPSEC_ROCKET_WAREHOUSE, 62 },
|
||||
{ MAPSEC_LOST_CAVE, 75 }
|
||||
};
|
||||
|
||||
static const u16 sDexAreas_Sevii6[][2] = {
|
||||
{ MAPSEC_OUTCAST_ISLAND, 64 },
|
||||
{ MAPSEC_GREEN_PATH, 65 },
|
||||
{ MAPSEC_WATER_PATH, 66 },
|
||||
{ MAPSEC_RUIN_VALLEY, 67 },
|
||||
{ MAPSEC_DOTTED_HOLE, 78 },
|
||||
{ MAPSEC_PATTERN_BUSH, 77 },
|
||||
{ MAPSEC_ALTERING_CAVE, 76 }
|
||||
};
|
||||
|
||||
static const u16 sDexAreas_Sevii7[][2] = {
|
||||
{ MAPSEC_TRAINER_TOWER, 68 },
|
||||
{ MAPSEC_CANYON_ENTRANCE, 69 },
|
||||
{ MAPSEC_SEVAULT_CANYON, 70 },
|
||||
{ MAPSEC_TANOBY_RUINS, 71 },
|
||||
{ MAPSEC_MONEAN_CHAMBER, 79 },
|
||||
{ MAPSEC_LIPTOO_CHAMBER, 79 },
|
||||
{ MAPSEC_WEEPTH_CHAMBER, 79 },
|
||||
{ MAPSEC_DILFORD_CHAMBER, 79 },
|
||||
{ MAPSEC_SCUFIB_CHAMBER, 79 },
|
||||
{ MAPSEC_RIXY_CHAMBER, 79 },
|
||||
{ MAPSEC_VIAPOIS_CHAMBER, 79 }
|
||||
};
|
||||
|
||||
static const struct SeviiDexArea sSeviiDexAreas[] = {
|
||||
{ sDexAreas_Sevii1, 4 },
|
||||
{ sDexAreas_Sevii2, 2 },
|
||||
{ sDexAreas_Sevii3, 5 },
|
||||
{ sDexAreas_Sevii4, 2 },
|
||||
{ sDexAreas_Sevii5, 7 },
|
||||
{ sDexAreas_Sevii6, 7 },
|
||||
{ sDexAreas_Sevii7, 11 }
|
||||
};
|
||||
|
||||
static const struct RoamerPair sRoamerPairs[] = {
|
||||
{ SPECIES_ENTEI, SPECIES_BULBASAUR },
|
||||
{ SPECIES_SUICUNE, SPECIES_CHARMANDER },
|
||||
{ SPECIES_RAIKOU, SPECIES_SQUIRTLE }
|
||||
};
|
||||
|
||||
s32 BuildPokedexAreaSubspriteBuffer(u16 species, struct Subsprite * subsprites)
|
||||
{
|
||||
s32 areaCount;
|
||||
s32 j;
|
||||
s32 mapSecId;
|
||||
u16 dexAreaSubspriteIdx;
|
||||
s32 dexAreaEntryLUTidx;
|
||||
s32 seviiAreas;
|
||||
s32 alteringCaveCount;
|
||||
s32 alteringCaveNum;
|
||||
s32 i;
|
||||
|
||||
if (GetRoamerIndex(species) >= SPECIES_NONE)
|
||||
{
|
||||
return CountRoamerNests(species, subsprites);
|
||||
}
|
||||
|
||||
seviiAreas = GetUnlockedSeviiAreas();
|
||||
alteringCaveCount = 0;
|
||||
alteringCaveNum = VarGet(VAR_0x4024);
|
||||
if (alteringCaveNum > 8)
|
||||
alteringCaveNum = 0;
|
||||
for (i = 0, areaCount = 0; gWildMonHeaders[i].mapGroup != 0xFF; i++)
|
||||
{
|
||||
mapSecId = GetMapSecIdFromWildMonHeader(&gWildMonHeaders[i]);
|
||||
if (mapSecId == MAPSEC_ALTERING_CAVE)
|
||||
{
|
||||
alteringCaveCount++;
|
||||
if (alteringCaveNum != alteringCaveCount - 1)
|
||||
continue;
|
||||
}
|
||||
if (PokemonInAnyEncounterTableInMap(&gWildMonHeaders[i], species))
|
||||
{
|
||||
dexAreaEntryLUTidx = 0;
|
||||
while (TryGetMapSecPokedexAreaEntry(mapSecId, sDexAreas_Kanto, 55, &dexAreaEntryLUTidx, &dexAreaSubspriteIdx))
|
||||
{
|
||||
if (dexAreaSubspriteIdx != 0)
|
||||
{
|
||||
SetAreaSubsprite(areaCount++, dexAreaSubspriteIdx, subsprites);
|
||||
}
|
||||
}
|
||||
for (j = 0; j < NELEMS(sSeviiDexAreas); j++)
|
||||
{
|
||||
if ((seviiAreas >> j) & 1)
|
||||
{
|
||||
dexAreaEntryLUTidx = 0;
|
||||
while (TryGetMapSecPokedexAreaEntry(mapSecId, sSeviiDexAreas[j].lut, sSeviiDexAreas[j].count, &dexAreaEntryLUTidx, &dexAreaSubspriteIdx))
|
||||
{
|
||||
if (dexAreaSubspriteIdx != 0)
|
||||
{
|
||||
SetAreaSubsprite(areaCount++, dexAreaSubspriteIdx, subsprites);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return areaCount;
|
||||
}
|
||||
|
||||
static s32 GetRoamerIndex(u16 species)
|
||||
{
|
||||
s32 i;
|
||||
for (i = 0; i < NELEMS(sRoamerPairs); i++)
|
||||
{
|
||||
if (sRoamerPairs[i].roamer == species)
|
||||
return i;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
static s32 CountRoamerNests(u16 species, struct Subsprite * subsprites)
|
||||
{
|
||||
u16 roamerLocation;
|
||||
s32 roamerIdx;
|
||||
u16 dexAreaSubspriteIdx;
|
||||
s32 dexAreaEntryLUTidx;
|
||||
|
||||
roamerIdx = GetRoamerIndex(species);
|
||||
if (roamerIdx < 0)
|
||||
return 0;
|
||||
if (sRoamerPairs[roamerIdx].starter != ScrSpecial_GetStarter())
|
||||
return 0;
|
||||
roamerLocation = GetRoamerLocationMapSectionId();
|
||||
dexAreaEntryLUTidx = 0;
|
||||
if (TryGetMapSecPokedexAreaEntry(roamerLocation, sDexAreas_Kanto, 55, &dexAreaEntryLUTidx, &dexAreaSubspriteIdx))
|
||||
{
|
||||
if (dexAreaSubspriteIdx != 0)
|
||||
{
|
||||
SetAreaSubsprite(0, dexAreaSubspriteIdx, subsprites);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static bool32 PokemonInAnyEncounterTableInMap(const struct WildPokemonHeader * data, s32 species)
|
||||
{
|
||||
if (PokemonInEncounterTable(data->landMonsInfo, species, 12))
|
||||
return TRUE;
|
||||
if (PokemonInEncounterTable(data->waterMonsInfo, species, 5))
|
||||
return TRUE;
|
||||
if (PokemonInEncounterTable(data->fishingMonsInfo, species, 12))
|
||||
return TRUE;
|
||||
if (PokemonInEncounterTable(data->rockSmashMonsInfo, species, 5))
|
||||
return TRUE;
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static bool32 PokemonInEncounterTable(const struct WildPokemonInfo * info, s32 species, s32 count)
|
||||
{
|
||||
s32 i;
|
||||
if (info != NULL)
|
||||
{
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
if (info->wildPokemon[i].species == species)
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static u16 GetMapSecIdFromWildMonHeader(const struct WildPokemonHeader * header)
|
||||
{
|
||||
return get_mapheader_by_bank_and_number(header->mapGroup, header->mapNum)->regionMapSectionId;
|
||||
}
|
||||
|
||||
static bool32 TryGetMapSecPokedexAreaEntry(u16 mapSecId, const u16 (*lut)[2], s32 count, s32 * lutIdx_p, u16 * tableIdx_p)
|
||||
{
|
||||
s32 i;
|
||||
for (i = *lutIdx_p; i < count; i++)
|
||||
{
|
||||
if (lut[i][0] == mapSecId)
|
||||
{
|
||||
*tableIdx_p = lut[i][1];
|
||||
*lutIdx_p = i + 1;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
+1
-1
@@ -364,7 +364,7 @@ void FillWindowPixelRect(u8 windowId, u8 fillValue, u16 x, u16 y, u16 width, u16
|
||||
FillBitmapRect4Bit(&pixelRect, x, y, width, height, fillValue);
|
||||
}
|
||||
|
||||
void CopyToWindowPixelBuffer(u8 windowId, const u8 *src, u16 size, u16 tileOffset)
|
||||
void CopyToWindowPixelBuffer(u8 windowId, const void *src, u16 size, u16 tileOffset)
|
||||
{
|
||||
if (size != 0)
|
||||
CpuCopy16(src, gWindows[windowId].tileData + (0x20 * tileOffset), size);
|
||||
|
||||
@@ -329,37 +329,37 @@ void sub_814F46C(u8 taskId)
|
||||
|
||||
void sub_814F65C(u8 windowId, u8 fontId, const u8 * str, u8 x, u8 y, u8 palIdx)
|
||||
{
|
||||
struct TextColor textColor;
|
||||
u8 textColor[3];
|
||||
switch (palIdx)
|
||||
{
|
||||
case 0:
|
||||
textColor.fgColor = 0;
|
||||
textColor.bgColor = 2;
|
||||
textColor.shadowColor = 3;
|
||||
textColor[0] = 0;
|
||||
textColor[1] = 2;
|
||||
textColor[2] = 3;
|
||||
break;
|
||||
case 1:
|
||||
textColor.fgColor = 0;
|
||||
textColor.bgColor = 1;
|
||||
textColor.shadowColor = 3;
|
||||
textColor[0] = 0;
|
||||
textColor[1] = 1;
|
||||
textColor[2] = 3;
|
||||
break;
|
||||
case 2:
|
||||
textColor.fgColor = 0;
|
||||
textColor.bgColor = 4;
|
||||
textColor.shadowColor = 5;
|
||||
textColor[0] = 0;
|
||||
textColor[1] = 4;
|
||||
textColor[2] = 5;
|
||||
break;
|
||||
case 3:
|
||||
textColor.fgColor = 0;
|
||||
textColor.bgColor = 7;
|
||||
textColor.shadowColor = 6;
|
||||
textColor[0] = 0;
|
||||
textColor[1] = 7;
|
||||
textColor[2] = 6;
|
||||
break;
|
||||
case 4:
|
||||
textColor.fgColor = 0;
|
||||
textColor.bgColor = 1;
|
||||
textColor.shadowColor = 2;
|
||||
textColor[0] = 0;
|
||||
textColor[1] = 1;
|
||||
textColor[2] = 2;
|
||||
break;
|
||||
// default: UB
|
||||
}
|
||||
AddTextPrinterParameterized4(windowId, fontId,x, y, fontId == 0 ? 0 : 1, 0, &textColor, -1, str);
|
||||
AddTextPrinterParameterized4(windowId, fontId,x, y, fontId == 0 ? 0 : 1, 0, textColor, -1, str);
|
||||
}
|
||||
|
||||
u32 sub_814F714(struct UnkStruct_x20 * unk20, u32 * arg1)
|
||||
|
||||
Reference in New Issue
Block a user