Merge branch 'master' into doc-introcred
This commit is contained in:
@@ -2089,12 +2089,7 @@ static void Cmd_get_used_held_item(void)
|
||||
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];
|
||||
|
||||
gAIScriptPtr += 2;
|
||||
}
|
||||
|
||||
+22
-30
@@ -51,51 +51,43 @@ const struct SpriteTemplate gUnusedSpriteTemplate_08595E14 =
|
||||
.callback = AnimUnused_080B08A0,
|
||||
};
|
||||
|
||||
static const union AnimCmd sAnim_HandOrFoot[] =
|
||||
static const union AnimCmd sAnim_Fist[] =
|
||||
{
|
||||
ANIMCMD_FRAME(0, 1),
|
||||
ANIMCMD_END,
|
||||
};
|
||||
|
||||
static const union AnimCmd sAnim_SlidingKick_0[] =
|
||||
static const union AnimCmd sAnim_FootWide[] =
|
||||
{
|
||||
ANIMCMD_FRAME(16, 1),
|
||||
ANIMCMD_END,
|
||||
};
|
||||
|
||||
static const union AnimCmd sAnim_SlidingKick_1[] =
|
||||
static const union AnimCmd sAnim_FootTall[] =
|
||||
{
|
||||
ANIMCMD_FRAME(32, 1),
|
||||
ANIMCMD_END,
|
||||
};
|
||||
|
||||
static const union AnimCmd sAnim_CrossChopHand_0[] =
|
||||
static const union AnimCmd sAnim_HandLeft[] =
|
||||
{
|
||||
ANIMCMD_FRAME(48, 1),
|
||||
ANIMCMD_END,
|
||||
};
|
||||
|
||||
static const union AnimCmd sAnim_CrossChopHand_1[] =
|
||||
static const union AnimCmd sAnim_HandRight[] =
|
||||
{
|
||||
ANIMCMD_FRAME(48, 1, .hFlip = TRUE),
|
||||
ANIMCMD_END,
|
||||
};
|
||||
|
||||
static const union AnimCmd *const sAnims_HandOrFoot[] =
|
||||
static const union AnimCmd *const sAnims_HandsAndFeet[] =
|
||||
{
|
||||
sAnim_HandOrFoot,
|
||||
};
|
||||
|
||||
static const union AnimCmd *const sAnims_SlidingKick[] =
|
||||
{
|
||||
sAnim_SlidingKick_0,
|
||||
sAnim_SlidingKick_1,
|
||||
};
|
||||
|
||||
static const union AnimCmd *const sAnims_CrossChopHand[] =
|
||||
{
|
||||
sAnim_CrossChopHand_0,
|
||||
sAnim_CrossChopHand_1,
|
||||
sAnim_Fist,
|
||||
sAnim_FootWide,
|
||||
sAnim_FootTall,
|
||||
sAnim_HandLeft,
|
||||
sAnim_HandRight,
|
||||
};
|
||||
|
||||
const struct SpriteTemplate gKarateChopSpriteTemplate =
|
||||
@@ -103,7 +95,7 @@ const struct SpriteTemplate gKarateChopSpriteTemplate =
|
||||
.tileTag = ANIM_TAG_HANDS_AND_FEET,
|
||||
.paletteTag = ANIM_TAG_HANDS_AND_FEET,
|
||||
.oam = &gOamData_AffineOff_ObjNormal_32x32,
|
||||
.anims = sAnims_HandOrFoot,
|
||||
.anims = sAnims_HandsAndFeet,
|
||||
.images = NULL,
|
||||
.affineAnims = gDummySpriteAffineAnimTable,
|
||||
.callback = AnimSlideHandOrFootToTarget,
|
||||
@@ -114,7 +106,7 @@ const struct SpriteTemplate gJumpKickSpriteTemplate =
|
||||
.tileTag = ANIM_TAG_HANDS_AND_FEET,
|
||||
.paletteTag = ANIM_TAG_HANDS_AND_FEET,
|
||||
.oam = &gOamData_AffineOff_ObjNormal_32x32,
|
||||
.anims = sAnims_HandOrFoot,
|
||||
.anims = sAnims_HandsAndFeet,
|
||||
.images = NULL,
|
||||
.affineAnims = gDummySpriteAffineAnimTable,
|
||||
.callback = AnimJumpKick,
|
||||
@@ -125,7 +117,7 @@ const struct SpriteTemplate gFistFootSpriteTemplate =
|
||||
.tileTag = ANIM_TAG_HANDS_AND_FEET,
|
||||
.paletteTag = ANIM_TAG_HANDS_AND_FEET,
|
||||
.oam = &gOamData_AffineOff_ObjNormal_32x32,
|
||||
.anims = sAnims_HandOrFoot,
|
||||
.anims = sAnims_HandsAndFeet,
|
||||
.images = NULL,
|
||||
.affineAnims = gDummySpriteAffineAnimTable,
|
||||
.callback = AnimBasicFistOrFoot,
|
||||
@@ -136,7 +128,7 @@ const struct SpriteTemplate gFistFootRandomPosSpriteTemplate =
|
||||
.tileTag = ANIM_TAG_HANDS_AND_FEET,
|
||||
.paletteTag = ANIM_TAG_HANDS_AND_FEET,
|
||||
.oam = &gOamData_AffineOff_ObjNormal_32x32,
|
||||
.anims = sAnims_HandOrFoot,
|
||||
.anims = sAnims_HandsAndFeet,
|
||||
.images = NULL,
|
||||
.affineAnims = gDummySpriteAffineAnimTable,
|
||||
.callback = AnimFistOrFootRandomPos,
|
||||
@@ -147,7 +139,7 @@ const struct SpriteTemplate gCrossChopHandSpriteTemplate =
|
||||
.tileTag = ANIM_TAG_HANDS_AND_FEET,
|
||||
.paletteTag = ANIM_TAG_HANDS_AND_FEET,
|
||||
.oam = &gOamData_AffineOff_ObjNormal_32x32,
|
||||
.anims = sAnims_CrossChopHand,
|
||||
.anims = &sAnims_HandsAndFeet[3],
|
||||
.images = NULL,
|
||||
.affineAnims = gDummySpriteAffineAnimTable,
|
||||
.callback = AnimCrossChopHand,
|
||||
@@ -158,7 +150,7 @@ const struct SpriteTemplate gSlidingKickSpriteTemplate =
|
||||
.tileTag = ANIM_TAG_HANDS_AND_FEET,
|
||||
.paletteTag = ANIM_TAG_HANDS_AND_FEET,
|
||||
.oam = &gOamData_AffineOff_ObjNormal_32x32,
|
||||
.anims = sAnims_SlidingKick,
|
||||
.anims = &sAnims_HandsAndFeet[1],
|
||||
.images = NULL,
|
||||
.affineAnims = gDummySpriteAffineAnimTable,
|
||||
.callback = AnimSlidingKick,
|
||||
@@ -182,7 +174,7 @@ const struct SpriteTemplate gSpinningHandOrFootSpriteTemplate =
|
||||
.tileTag = ANIM_TAG_HANDS_AND_FEET,
|
||||
.paletteTag = ANIM_TAG_HANDS_AND_FEET,
|
||||
.oam = &gOamData_AffineDouble_ObjNormal_32x32,
|
||||
.anims = sAnims_HandOrFoot,
|
||||
.anims = sAnims_HandsAndFeet,
|
||||
.images = NULL,
|
||||
.affineAnims = sAffineAnims_SpinningHandOrFoot,
|
||||
.callback = AnimSpinningKickOrPunch,
|
||||
@@ -205,7 +197,7 @@ const struct SpriteTemplate gMegaPunchKickSpriteTemplate =
|
||||
.tileTag = ANIM_TAG_HANDS_AND_FEET,
|
||||
.paletteTag = ANIM_TAG_HANDS_AND_FEET,
|
||||
.oam = &gOamData_AffineDouble_ObjNormal_32x32,
|
||||
.anims = sAnims_HandOrFoot,
|
||||
.anims = sAnims_HandsAndFeet,
|
||||
.images = NULL,
|
||||
.affineAnims = sAffineAnims_MegaPunchKick,
|
||||
.callback = AnimSpinningKickOrPunch,
|
||||
@@ -216,7 +208,7 @@ const struct SpriteTemplate gStompFootSpriteTemplate =
|
||||
.tileTag = ANIM_TAG_HANDS_AND_FEET,
|
||||
.paletteTag = ANIM_TAG_HANDS_AND_FEET,
|
||||
.oam = &gOamData_AffineOff_ObjNormal_32x32,
|
||||
.anims = sAnims_SlidingKick,
|
||||
.anims = &sAnims_HandsAndFeet[1],
|
||||
.images = NULL,
|
||||
.affineAnims = gDummySpriteAffineAnimTable,
|
||||
.callback = AnimStompFoot,
|
||||
@@ -307,7 +299,7 @@ const struct SpriteTemplate gArmThrustHandSpriteTemplate =
|
||||
.tileTag = ANIM_TAG_HANDS_AND_FEET,
|
||||
.paletteTag = ANIM_TAG_HANDS_AND_FEET,
|
||||
.oam = &gOamData_AffineOff_ObjNormal_32x32,
|
||||
.anims = sAnims_HandOrFoot,
|
||||
.anims = sAnims_HandsAndFeet,
|
||||
.images = NULL,
|
||||
.affineAnims = gDummySpriteAffineAnimTable,
|
||||
.callback = AnimArmThrustHit,
|
||||
@@ -411,7 +403,7 @@ const struct SpriteTemplate gFocusPunchFistSpriteTemplate =
|
||||
.tileTag = ANIM_TAG_HANDS_AND_FEET,
|
||||
.paletteTag = ANIM_TAG_HANDS_AND_FEET,
|
||||
.oam = &gOamData_AffineDouble_ObjNormal_32x32,
|
||||
.anims = sAnims_HandOrFoot,
|
||||
.anims = sAnims_HandsAndFeet,
|
||||
.images = NULL,
|
||||
.affineAnims = sAffineAnims_FocusPunchFist,
|
||||
.callback = AnimFocusPunchFist,
|
||||
|
||||
@@ -1815,7 +1815,7 @@ void SetBattlerSpriteYOffsetFromYScale(u8 spriteId)
|
||||
{
|
||||
int var = 64 - GetBattlerYDeltaFromSpriteId(spriteId) * 2;
|
||||
u16 matrix = gSprites[spriteId].oam.matrixNum;
|
||||
int var2 = (var << 8) / gOamMatrices[matrix].d;
|
||||
int var2 = SAFE_DIV(var << 8, gOamMatrices[matrix].d);
|
||||
|
||||
if (var2 > 128)
|
||||
var2 = 128;
|
||||
@@ -1828,7 +1828,7 @@ void SetBattlerSpriteYOffsetFromOtherYScale(u8 spriteId, u8 otherSpriteId)
|
||||
{
|
||||
int var = 64 - GetBattlerYDeltaFromSpriteId(otherSpriteId) * 2;
|
||||
u16 matrix = gSprites[spriteId].oam.matrixNum;
|
||||
int var2 = (var << 8) / gOamMatrices[matrix].d;
|
||||
int var2 = SAFE_DIV(var << 8, gOamMatrices[matrix].d);
|
||||
|
||||
if (var2 > 128)
|
||||
var2 = 128;
|
||||
|
||||
+2
-1
@@ -774,7 +774,8 @@ void BattleArena_DeductMindPoints(u8 battler, u16 stringId)
|
||||
}
|
||||
}
|
||||
|
||||
void sub_81A586C(u8 battler) // Unused.
|
||||
// Unused
|
||||
static void UpdateHPAtStart(u8 battler)
|
||||
{
|
||||
u16 *hpAtStart = gBattleStruct->arenaStartHp;
|
||||
|
||||
|
||||
+12
-12
@@ -529,7 +529,7 @@ static const union AnimCmd * const sAnims_Select_Pokeball[] =
|
||||
sAnim_Select_Pokeball_Moving,
|
||||
};
|
||||
|
||||
static const union AffineAnimCmd gUnknown_0861050C[] =
|
||||
static const union AffineAnimCmd sAffineAnim_Select_MonPicBg_Opening[] =
|
||||
{
|
||||
AFFINEANIMCMD_FRAME(5, 5, 0, 0),
|
||||
AFFINEANIMCMD_FRAME(0, 0, 0, 1),
|
||||
@@ -545,7 +545,7 @@ static const union AffineAnimCmd gUnknown_0861050C[] =
|
||||
AFFINEANIMCMD_END,
|
||||
};
|
||||
|
||||
static const union AffineAnimCmd gUnknown_0861056C[] =
|
||||
static const union AffineAnimCmd sAffineAnim_Select_MonPicBg_Closing[] =
|
||||
{
|
||||
AFFINEANIMCMD_FRAME(128, 5, 0, 0),
|
||||
AFFINEANIMCMD_FRAME(0, 0, 0, 1),
|
||||
@@ -559,7 +559,7 @@ static const union AffineAnimCmd gUnknown_0861056C[] =
|
||||
AFFINEANIMCMD_END,
|
||||
};
|
||||
|
||||
static const union AffineAnimCmd gUnknown_086105BC[] =
|
||||
static const union AffineAnimCmd sAffineAnim_Select_MonPicBg_Open[] =
|
||||
{
|
||||
AFFINEANIMCMD_FRAME(256, 256, 0, 0),
|
||||
AFFINEANIMCMD_END,
|
||||
@@ -567,9 +567,9 @@ static const union AffineAnimCmd gUnknown_086105BC[] =
|
||||
|
||||
static const union AffineAnimCmd * const sAffineAnims_Select_MonPicBgAnim[] =
|
||||
{
|
||||
gUnknown_0861050C,
|
||||
gUnknown_0861056C,
|
||||
gUnknown_086105BC,
|
||||
sAffineAnim_Select_MonPicBg_Opening,
|
||||
sAffineAnim_Select_MonPicBg_Closing,
|
||||
sAffineAnim_Select_MonPicBg_Open,
|
||||
};
|
||||
|
||||
static const struct SpriteTemplate sSpriteTemplate_Select_Pokeball =
|
||||
@@ -780,7 +780,7 @@ static const union AnimCmd * const sAnims_Swap_Pokeball[] =
|
||||
sAnim_Swap_Pokeball_Moving,
|
||||
};
|
||||
|
||||
static const union AffineAnimCmd gUnknown_08610768[] =
|
||||
static const union AffineAnimCmd sAffineAnim_Swap_MonPicBg_Opening[] =
|
||||
{
|
||||
AFFINEANIMCMD_FRAME(5, 5, 0, 0),
|
||||
AFFINEANIMCMD_FRAME(0, 0, 0, 1),
|
||||
@@ -796,7 +796,7 @@ static const union AffineAnimCmd gUnknown_08610768[] =
|
||||
AFFINEANIMCMD_END,
|
||||
};
|
||||
|
||||
static const union AffineAnimCmd gUnknown_086107C8[] =
|
||||
static const union AffineAnimCmd sAffineAnim_Swap_MonPicBg_Closing[] =
|
||||
{
|
||||
AFFINEANIMCMD_FRAME(128, 5, 0, 0),
|
||||
AFFINEANIMCMD_FRAME(0, 0, 0, 1),
|
||||
@@ -810,7 +810,7 @@ static const union AffineAnimCmd gUnknown_086107C8[] =
|
||||
AFFINEANIMCMD_END,
|
||||
};
|
||||
|
||||
static const union AffineAnimCmd gUnknown_08610818[] =
|
||||
static const union AffineAnimCmd sAffineAnim_Swap_MonPicBg_Open[] =
|
||||
{
|
||||
AFFINEANIMCMD_FRAME(256, 256, 0, 0),
|
||||
AFFINEANIMCMD_END,
|
||||
@@ -818,9 +818,9 @@ static const union AffineAnimCmd gUnknown_08610818[] =
|
||||
|
||||
static const union AffineAnimCmd * const sAffineAnims_Swap_MonPicBgAnim[] =
|
||||
{
|
||||
gUnknown_08610768,
|
||||
gUnknown_086107C8,
|
||||
gUnknown_08610818,
|
||||
sAffineAnim_Swap_MonPicBg_Opening,
|
||||
sAffineAnim_Swap_MonPicBg_Closing,
|
||||
sAffineAnim_Swap_MonPicBg_Open,
|
||||
};
|
||||
|
||||
static const struct SpriteTemplate sSpriteTemplate_Swap_Pokeball =
|
||||
|
||||
+57
-53
@@ -68,9 +68,6 @@ extern const struct BgTemplate gBattleBgTemplates[];
|
||||
extern const struct WindowTemplate *const gBattleWindowTemplates[];
|
||||
|
||||
// this file's functions
|
||||
#if !defined(NONMATCHING) && MODERN
|
||||
#define static
|
||||
#endif
|
||||
static void CB2_InitBattleInternal(void);
|
||||
static void CB2_PreInitMultiBattle(void);
|
||||
static void CB2_PreInitIngamePlayerPartnerBattle(void);
|
||||
@@ -579,7 +576,7 @@ void CB2_InitBattle(void)
|
||||
AllocateBattleResources();
|
||||
AllocateBattleSpritesData();
|
||||
AllocateMonSpritesGfx();
|
||||
sub_8185F84();
|
||||
RecordedBattle_ClearFrontierPassFlag();
|
||||
|
||||
if (gBattleTypeFlags & BATTLE_TYPE_MULTI)
|
||||
{
|
||||
@@ -736,16 +733,16 @@ static void BufferPartyVsScreenHealth_AtStart(void)
|
||||
s32 i;
|
||||
|
||||
BUFFER_PARTY_VS_SCREEN_STATUS(gPlayerParty, flags, i);
|
||||
gBattleStruct->vsScreenHealthFlagsLo = flags;
|
||||
*(&gBattleStruct->vsScreenHealthFlagsHi) = flags >> 8;
|
||||
gBattleStruct->vsScreenHealthFlagsHi |= FlagGet(FLAG_SYS_FRONTIER_PASS) << 7;
|
||||
gBattleStruct->multiBuffer.linkBattlerHeader.vsScreenHealthFlagsLo = flags;
|
||||
*(&gBattleStruct->multiBuffer.linkBattlerHeader.vsScreenHealthFlagsHi) = flags >> 8;
|
||||
gBattleStruct->multiBuffer.linkBattlerHeader.vsScreenHealthFlagsHi |= FlagGet(FLAG_SYS_FRONTIER_PASS) << 7;
|
||||
}
|
||||
|
||||
static void SetPlayerBerryDataInBattleStruct(void)
|
||||
{
|
||||
s32 i;
|
||||
struct BattleStruct *battleStruct = gBattleStruct;
|
||||
struct BattleEnigmaBerry *battleBerry = &battleStruct->battleEnigmaBerry;
|
||||
struct BattleEnigmaBerry *battleBerry = &battleStruct->multiBuffer.linkBattlerHeader.battleEnigmaBerry;
|
||||
|
||||
if (IsEnigmaBerryValid() == TRUE)
|
||||
{
|
||||
@@ -885,52 +882,56 @@ static void SetAllPlayersBerryData(void)
|
||||
}
|
||||
}
|
||||
|
||||
static void sub_8036EB8(u8 arg0, u8 arg1)
|
||||
// This was inlined in Ruby/Sapphire
|
||||
static void FindLinkBattleMaster(u8 numPlayers, u8 multiPlayerId)
|
||||
{
|
||||
u8 var = 0;
|
||||
u8 found = 0;
|
||||
|
||||
if (gBlockRecvBuffer[0][0] == 256)
|
||||
// If player 1 is playing the minimum version, player 1 is master.
|
||||
if (gBlockRecvBuffer[0][0] == 0x100)
|
||||
{
|
||||
if (arg1 == 0)
|
||||
if (multiPlayerId == 0)
|
||||
gBattleTypeFlags |= BATTLE_TYPE_IS_MASTER | BATTLE_TYPE_TRAINER;
|
||||
else
|
||||
gBattleTypeFlags |= BATTLE_TYPE_TRAINER;
|
||||
var++;
|
||||
found++;
|
||||
}
|
||||
|
||||
if (var == 0)
|
||||
if (found == 0)
|
||||
{
|
||||
// If multiple different versions are being used, player 1 is master.
|
||||
s32 i;
|
||||
|
||||
for (i = 0; i < arg0; i++)
|
||||
for (i = 0; i < numPlayers; i++)
|
||||
{
|
||||
if (gBlockRecvBuffer[0][0] != gBlockRecvBuffer[i][0])
|
||||
break;
|
||||
}
|
||||
|
||||
if (i == arg0)
|
||||
if (i == numPlayers)
|
||||
{
|
||||
if (arg1 == 0)
|
||||
if (multiPlayerId == 0)
|
||||
gBattleTypeFlags |= BATTLE_TYPE_IS_MASTER | BATTLE_TYPE_TRAINER;
|
||||
else
|
||||
gBattleTypeFlags |= BATTLE_TYPE_TRAINER;
|
||||
var++;
|
||||
found++;
|
||||
}
|
||||
|
||||
if (var == 0)
|
||||
if (found == 0)
|
||||
{
|
||||
for (i = 0; i < arg0; i++)
|
||||
// Lowest index player with the highest game version is master.
|
||||
for (i = 0; i < numPlayers; i++)
|
||||
{
|
||||
if (gBlockRecvBuffer[i][0] == 0x300)
|
||||
if (gBlockRecvBuffer[i][0] == 0x300 && i != multiPlayerId)
|
||||
{
|
||||
if (i != arg1 && i < arg1)
|
||||
if (i < multiPlayerId)
|
||||
break;
|
||||
}
|
||||
if (gBlockRecvBuffer[i][0] > 0x300 && i != arg1)
|
||||
if (gBlockRecvBuffer[i][0] > 0x300 && i != multiPlayerId)
|
||||
break;
|
||||
}
|
||||
|
||||
if (i == arg0)
|
||||
if (i == numPlayers)
|
||||
gBattleTypeFlags |= BATTLE_TYPE_IS_MASTER | BATTLE_TYPE_TRAINER;
|
||||
else
|
||||
gBattleTypeFlags |= BATTLE_TYPE_TRAINER;
|
||||
@@ -973,8 +974,9 @@ static void CB2_HandleStartBattle(void)
|
||||
{
|
||||
if (IsLinkTaskFinished())
|
||||
{
|
||||
*(&gBattleStruct->field_180) = 0;
|
||||
*(&gBattleStruct->field_181) = 3;
|
||||
// 0x300
|
||||
*(&gBattleStruct->multiBuffer.linkBattlerHeader.versionSignatureLo) = 0;
|
||||
*(&gBattleStruct->multiBuffer.linkBattlerHeader.versionSignatureHi) = 3;
|
||||
BufferPartyVsScreenHealth_AtStart();
|
||||
SetPlayerBerryDataInBattleStruct();
|
||||
|
||||
@@ -984,7 +986,7 @@ static void CB2_HandleStartBattle(void)
|
||||
gLinkPlayers[1].id = 1;
|
||||
}
|
||||
|
||||
SendBlock(bitmask_all_link_players_but_self(), &gBattleStruct->field_180, 32);
|
||||
SendBlock(bitmask_all_link_players_but_self(), &gBattleStruct->multiBuffer.linkBattlerHeader, sizeof(gBattleStruct->multiBuffer.linkBattlerHeader));
|
||||
gBattleCommunication[MULTIUSE_STATE] = 2;
|
||||
}
|
||||
if (gWirelessCommType)
|
||||
@@ -1005,16 +1007,16 @@ static void CB2_HandleStartBattle(void)
|
||||
u8 taskId;
|
||||
|
||||
ResetBlockReceivedFlags();
|
||||
sub_8036EB8(2, playerMultiplayerId);
|
||||
FindLinkBattleMaster(2, playerMultiplayerId);
|
||||
SetAllPlayersBerryData();
|
||||
taskId = CreateTask(InitLinkBattleVsScreen, 0);
|
||||
gTasks[taskId].data[1] = 0x10E;
|
||||
gTasks[taskId].data[2] = 0x5A;
|
||||
gTasks[taskId].data[5] = 0;
|
||||
gTasks[taskId].data[3] = gBattleStruct->vsScreenHealthFlagsLo | (gBattleStruct->vsScreenHealthFlagsHi << 8);
|
||||
gTasks[taskId].data[3] = gBattleStruct->multiBuffer.linkBattlerHeader.vsScreenHealthFlagsLo | (gBattleStruct->multiBuffer.linkBattlerHeader.vsScreenHealthFlagsHi << 8);
|
||||
gTasks[taskId].data[4] = gBlockRecvBuffer[enemyMultiplayerId][1];
|
||||
sub_8185F90(gBlockRecvBuffer[playerMultiplayerId][1]);
|
||||
sub_8185F90(gBlockRecvBuffer[enemyMultiplayerId][1]);
|
||||
RecordedBattle_SetFrontierPassFlagFromHword(gBlockRecvBuffer[playerMultiplayerId][1]);
|
||||
RecordedBattle_SetFrontierPassFlagFromHword(gBlockRecvBuffer[enemyMultiplayerId][1]);
|
||||
SetDeoxysStats();
|
||||
gBattleCommunication[MULTIUSE_STATE]++;
|
||||
}
|
||||
@@ -1181,11 +1183,12 @@ static void CB2_HandleStartMultiPartnerBattle(void)
|
||||
|
||||
if (IsLinkTaskFinished())
|
||||
{
|
||||
*(&gBattleStruct->field_180) = 0;
|
||||
*(&gBattleStruct->field_181) = 3;
|
||||
// 0x300
|
||||
*(&gBattleStruct->multiBuffer.linkBattlerHeader.versionSignatureLo) = 0;
|
||||
*(&gBattleStruct->multiBuffer.linkBattlerHeader.versionSignatureHi) = 3;
|
||||
BufferPartyVsScreenHealth_AtStart();
|
||||
SetPlayerBerryDataInBattleStruct();
|
||||
SendBlock(bitmask_all_link_players_but_self(), &gBattleStruct->field_180, 32);
|
||||
SendBlock(bitmask_all_link_players_but_self(), &gBattleStruct->multiBuffer.linkBattlerHeader, sizeof(gBattleStruct->multiBuffer.linkBattlerHeader));
|
||||
gBattleCommunication[MULTIUSE_STATE] = 2;
|
||||
}
|
||||
|
||||
@@ -1207,7 +1210,7 @@ static void CB2_HandleStartMultiPartnerBattle(void)
|
||||
u8 taskId;
|
||||
|
||||
ResetBlockReceivedFlags();
|
||||
sub_8036EB8(2, playerMultiplayerId);
|
||||
FindLinkBattleMaster(2, playerMultiplayerId);
|
||||
SetAllPlayersBerryData();
|
||||
taskId = CreateTask(InitLinkBattleVsScreen, 0);
|
||||
gTasks[taskId].data[1] = 0x10E;
|
||||
@@ -1568,12 +1571,13 @@ static void CB2_HandleStartMultiBattle(void)
|
||||
{
|
||||
if (IsLinkTaskFinished())
|
||||
{
|
||||
*(&gBattleStruct->field_180) = 0;
|
||||
*(&gBattleStruct->field_181) = 3;
|
||||
// 0x300
|
||||
*(&gBattleStruct->multiBuffer.linkBattlerHeader.versionSignatureLo) = 0;
|
||||
*(&gBattleStruct->multiBuffer.linkBattlerHeader.versionSignatureHi) = 3;
|
||||
BufferPartyVsScreenHealth_AtStart();
|
||||
SetPlayerBerryDataInBattleStruct();
|
||||
|
||||
SendBlock(bitmask_all_link_players_but_self(), &gBattleStruct->field_180, 32);
|
||||
SendBlock(bitmask_all_link_players_but_self(), &gBattleStruct->multiBuffer.linkBattlerHeader, sizeof(gBattleStruct->multiBuffer.linkBattlerHeader));
|
||||
gBattleCommunication[MULTIUSE_STATE]++;
|
||||
}
|
||||
if (gWirelessCommType)
|
||||
@@ -1592,7 +1596,7 @@ static void CB2_HandleStartMultiBattle(void)
|
||||
if ((GetBlockReceivedStatus() & 0xF) == 0xF)
|
||||
{
|
||||
ResetBlockReceivedFlags();
|
||||
sub_8036EB8(4, playerMultiplayerId);
|
||||
FindLinkBattleMaster(4, playerMultiplayerId);
|
||||
SetAllPlayersBerryData();
|
||||
SetDeoxysStats();
|
||||
var = CreateTask(InitLinkBattleVsScreen, 0);
|
||||
@@ -1604,7 +1608,7 @@ static void CB2_HandleStartMultiBattle(void)
|
||||
|
||||
for (id = 0; id < MAX_LINK_PLAYERS; id++)
|
||||
{
|
||||
sub_8185F90(gBlockRecvBuffer[id][1]);
|
||||
RecordedBattle_SetFrontierPassFlagFromHword(gBlockRecvBuffer[id][1]);
|
||||
switch (gLinkPlayers[id].id)
|
||||
{
|
||||
case 0:
|
||||
@@ -1789,10 +1793,10 @@ static void CB2_HandleStartMultiBattle(void)
|
||||
case 8:
|
||||
if (IsLinkTaskFinished())
|
||||
{
|
||||
u32* ptr = (u32*)(&gBattleStruct->field_180);
|
||||
u32* ptr = gBattleStruct->multiBuffer.battleVideo;
|
||||
ptr[0] = gBattleTypeFlags;
|
||||
ptr[1] = gRecordedBattleRngSeed; // UB: overwrites berry data
|
||||
SendBlock(bitmask_all_link_players_but_self(), ptr, 8);
|
||||
SendBlock(bitmask_all_link_players_but_self(), ptr, sizeof(gBattleStruct->multiBuffer.battleVideo));
|
||||
gBattleCommunication[MULTIUSE_STATE]++;
|
||||
}
|
||||
break;
|
||||
@@ -2251,7 +2255,7 @@ static void EndLinkBattleInSteps(void)
|
||||
{
|
||||
u8 monsCount;
|
||||
|
||||
gMain.field_439_x4 = sub_8185FAC();
|
||||
gMain.anyLinkBattlerHasFrontierPass = RecordedBattle_GetFrontierPassFlag();
|
||||
|
||||
if (gBattleTypeFlags & BATTLE_TYPE_MULTI)
|
||||
monsCount = 4;
|
||||
@@ -2267,7 +2271,7 @@ static void EndLinkBattleInSteps(void)
|
||||
FreeAllWindowBuffers();
|
||||
SetMainCallback2(sub_80392A8);
|
||||
}
|
||||
else if (!gMain.field_439_x4)
|
||||
else if (!gMain.anyLinkBattlerHasFrontierPass)
|
||||
{
|
||||
SetMainCallback2(gMain.savedCallback);
|
||||
FreeBattleResources();
|
||||
@@ -2331,9 +2335,9 @@ static void EndLinkBattleInSteps(void)
|
||||
gBattleCommunication[MULTIUSE_STATE]++;
|
||||
break;
|
||||
case 9:
|
||||
if (!gMain.field_439_x4 || gWirelessCommType || gReceivedRemoteLinkPlayers != 1)
|
||||
if (!gMain.anyLinkBattlerHasFrontierPass || gWirelessCommType || gReceivedRemoteLinkPlayers != 1)
|
||||
{
|
||||
gMain.field_439_x4 = 0;
|
||||
gMain.anyLinkBattlerHasFrontierPass = 0;
|
||||
SetMainCallback2(gMain.savedCallback);
|
||||
FreeBattleResources();
|
||||
FreeBattleSpritesData();
|
||||
@@ -2429,7 +2433,7 @@ static void sub_803939C(void)
|
||||
gBattleCommunication[MULTIUSE_STATE]++;
|
||||
break;
|
||||
case 1:
|
||||
if (gMain.field_439_x4 && gReceivedRemoteLinkPlayers == 0)
|
||||
if (gMain.anyLinkBattlerHasFrontierPass && gReceivedRemoteLinkPlayers == 0)
|
||||
CreateTask(Task_ReconnectWithLinkPlayers, 5);
|
||||
gBattleCommunication[MULTIUSE_STATE]++;
|
||||
break;
|
||||
@@ -2499,7 +2503,7 @@ static void sub_803939C(void)
|
||||
if (IsLinkTaskFinished() == TRUE)
|
||||
{
|
||||
HandleBattleWindow(0x18, 8, 0x1D, 0xD, WINDOW_CLEAR);
|
||||
if (gMain.field_439_x4)
|
||||
if (gMain.anyLinkBattlerHasFrontierPass)
|
||||
{
|
||||
SetLinkStandbyCallback();
|
||||
BattlePutTextOnWindow(gText_LinkStandby3, 0);
|
||||
@@ -2510,15 +2514,15 @@ static void sub_803939C(void)
|
||||
case 8:
|
||||
if (--gBattleCommunication[1] == 0)
|
||||
{
|
||||
if (gMain.field_439_x4 && !gWirelessCommType)
|
||||
if (gMain.anyLinkBattlerHasFrontierPass && !gWirelessCommType)
|
||||
SetCloseLinkCallback();
|
||||
gBattleCommunication[MULTIUSE_STATE]++;
|
||||
}
|
||||
break;
|
||||
case 9:
|
||||
if (!gMain.field_439_x4 || gWirelessCommType || gReceivedRemoteLinkPlayers != 1)
|
||||
if (!gMain.anyLinkBattlerHasFrontierPass || gWirelessCommType || gReceivedRemoteLinkPlayers != 1)
|
||||
{
|
||||
gMain.field_439_x4 = 0;
|
||||
gMain.anyLinkBattlerHasFrontierPass = 0;
|
||||
if (!gPaletteFade.active)
|
||||
{
|
||||
SetMainCallback2(gMain.savedCallback);
|
||||
@@ -2548,7 +2552,7 @@ static void sub_803939C(void)
|
||||
case 11:
|
||||
if (IsLinkTaskFinished() == TRUE && !IsTextPrinterActive(0) && --gBattleCommunication[1] == 0)
|
||||
{
|
||||
if (gMain.field_439_x4)
|
||||
if (gMain.anyLinkBattlerHasFrontierPass)
|
||||
{
|
||||
SetLinkStandbyCallback();
|
||||
BattlePutTextOnWindow(gText_LinkStandby3, 0);
|
||||
@@ -2560,7 +2564,7 @@ static void sub_803939C(void)
|
||||
case 7:
|
||||
if (!IsTextPrinterActive(0))
|
||||
{
|
||||
if (gMain.field_439_x4)
|
||||
if (gMain.anyLinkBattlerHasFrontierPass)
|
||||
{
|
||||
if (IsLinkTaskFinished() == TRUE)
|
||||
{
|
||||
|
||||
+6
-6
@@ -57,8 +57,8 @@ static void GetRoomType(void);
|
||||
static void SetInWildMonRoom(void);
|
||||
static void ClearInWildMonRoom(void);
|
||||
static void SavePikeChallenge(void);
|
||||
static void nullsub_76(void);
|
||||
static void nullsub_124(void);
|
||||
static void PikeDummy1(void);
|
||||
static void PikeDummy2(void);
|
||||
static void GetRoomInflictedStatus(void);
|
||||
static void GetRoomInflictedStatusMon(void);
|
||||
static void HealOneOrTwoMons(void);
|
||||
@@ -488,8 +488,8 @@ static void (* const sBattlePikeFunctions[])(void) =
|
||||
[BATTLE_PIKE_FUNC_SET_IN_WILD_MON_ROOM] = SetInWildMonRoom,
|
||||
[BATTLE_PIKE_FUNC_CLEAR_IN_WILD_MON_ROOM] = ClearInWildMonRoom,
|
||||
[BATTLE_PIKE_FUNC_SAVE] = SavePikeChallenge,
|
||||
[BATTLE_PIKE_FUNC_NULL_9] = nullsub_76,
|
||||
[BATTLE_PIKE_FUNC_NULL_10] = nullsub_124,
|
||||
[BATTLE_PIKE_FUNC_DUMMY_1] = PikeDummy1,
|
||||
[BATTLE_PIKE_FUNC_DUMMY_2] = PikeDummy2,
|
||||
[BATTLE_PIKE_FUNC_GET_ROOM_STATUS] = GetRoomInflictedStatus,
|
||||
[BATTLE_PIKE_FUNC_GET_ROOM_STATUS_MON] = GetRoomInflictedStatusMon,
|
||||
[BATTLE_PIKE_FUNC_HEAL_ONE_TWO_MONS] = HealOneOrTwoMons,
|
||||
@@ -715,12 +715,12 @@ static void SavePikeChallenge(void)
|
||||
TrySavingData(SAVE_LINK);
|
||||
}
|
||||
|
||||
static void nullsub_76(void)
|
||||
static void PikeDummy1(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
static void nullsub_124(void)
|
||||
static void PikeDummy2(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@@ -258,7 +258,7 @@ static void Cmd_trysetperishsong(void);
|
||||
static void Cmd_rolloutdamagecalculation(void);
|
||||
static void Cmd_jumpifconfusedandstatmaxed(void);
|
||||
static void Cmd_furycuttercalc(void);
|
||||
static void Cmd_happinesstodamagecalculation(void);
|
||||
static void Cmd_friendshiptodamagecalculation(void);
|
||||
static void Cmd_presentdamagecalculation(void);
|
||||
static void Cmd_setsafeguard(void);
|
||||
static void Cmd_magnitudedamagecalculation(void);
|
||||
@@ -510,7 +510,7 @@ void (* const gBattleScriptingCommandsTable[])(void) =
|
||||
Cmd_rolloutdamagecalculation, //0xB3
|
||||
Cmd_jumpifconfusedandstatmaxed, //0xB4
|
||||
Cmd_furycuttercalc, //0xB5
|
||||
Cmd_happinesstodamagecalculation, //0xB6
|
||||
Cmd_friendshiptodamagecalculation, //0xB6
|
||||
Cmd_presentdamagecalculation, //0xB7
|
||||
Cmd_setsafeguard, //0xB8
|
||||
Cmd_magnitudedamagecalculation, //0xB9
|
||||
@@ -8471,7 +8471,7 @@ static void Cmd_furycuttercalc(void)
|
||||
}
|
||||
}
|
||||
|
||||
static void Cmd_happinesstodamagecalculation(void)
|
||||
static void Cmd_friendshiptodamagecalculation(void)
|
||||
{
|
||||
if (gBattleMoves[gCurrentMove].effect == EFFECT_RETURN)
|
||||
gDynamicBasePower = 10 * (gBattleMons[gBattlerAttacker].friendship) / 25;
|
||||
|
||||
+2
-6
@@ -878,12 +878,8 @@ static const u16 sFrontierTrainerIdRangesHard[][2] =
|
||||
{FRONTIER_TRAINER_JAXON, FRONTIER_TRAINER_GRETEL}, // 200 - 299
|
||||
};
|
||||
|
||||
// Trainer IDs? Don't make sense as part of previous array, min/max relationship reversed and never accessed
|
||||
static const u16 sUnused_085DFA1A[][2] =
|
||||
{
|
||||
{179, 141}, // FRONTIER_TRAINER_ALISON - FRONTIER_TRAINER_KAYDEN
|
||||
{200, 183}, // FRONTIER_TRAINER_JAXON - FRONTIER_TRAINER_HUNTER
|
||||
};
|
||||
// Unknown, unused data
|
||||
static const u16 sUnused[] = { 179, 141, 200, 183 };
|
||||
|
||||
static const u8 sBattleTowerPartySizes[FRONTIER_MODE_COUNT] =
|
||||
{
|
||||
|
||||
+2
-2
@@ -3949,7 +3949,7 @@ u8 GetMoveTarget(u16 move, u8 setTarget)
|
||||
return targetBattler;
|
||||
}
|
||||
|
||||
static bool32 IsNotEventLegalMewOrDeoxys(u8 battlerId)
|
||||
static bool32 IsMonEventLegal(u8 battlerId)
|
||||
{
|
||||
if (GetBattlerSide(battlerId) == B_SIDE_OPPONENT)
|
||||
return TRUE;
|
||||
@@ -3970,7 +3970,7 @@ u8 IsMonDisobedient(void)
|
||||
if (GetBattlerSide(gBattlerAttacker) == B_SIDE_OPPONENT)
|
||||
return 0;
|
||||
|
||||
if (IsNotEventLegalMewOrDeoxys(gBattlerAttacker)) // only if species is Mew or Deoxys
|
||||
if (IsMonEventLegal(gBattlerAttacker)) // only false if illegal Mew or Deoxys
|
||||
{
|
||||
if (gBattleTypeFlags & BATTLE_TYPE_INGAME_PARTNER && GetBattlerPosition(gBattlerAttacker) == 2)
|
||||
return 0;
|
||||
|
||||
+44
-44
@@ -889,50 +889,50 @@ const struct Berry gBerries[] =
|
||||
},
|
||||
};
|
||||
|
||||
const struct UnkStruct_0858AB24 gUnknown_0858AB24[] = {
|
||||
{ 50, 20},
|
||||
{ 50, 20},
|
||||
{ 50, 20},
|
||||
{ 50, 20},
|
||||
{ 50, 20},
|
||||
{ 50, 30},
|
||||
{ 50, 30},
|
||||
{ 50, 30},
|
||||
{ 50, 30},
|
||||
{ 50, 30},
|
||||
{ 60, 50},
|
||||
{ 60, 50},
|
||||
{ 60, 50},
|
||||
{ 60, 50},
|
||||
{ 60, 50},
|
||||
{ 80, 70},
|
||||
{ 80, 70},
|
||||
{ 80, 70},
|
||||
{ 80, 70},
|
||||
{ 80, 70},
|
||||
{100, 100},
|
||||
{100, 100},
|
||||
{100, 100},
|
||||
{100, 100},
|
||||
{100, 100},
|
||||
{130, 150},
|
||||
{130, 150},
|
||||
{130, 150},
|
||||
{130, 150},
|
||||
{130, 150},
|
||||
{160, 250},
|
||||
{160, 250},
|
||||
{160, 250},
|
||||
{160, 250},
|
||||
{160, 250},
|
||||
{180, 500},
|
||||
{180, 500},
|
||||
{180, 500},
|
||||
{180, 500},
|
||||
{180, 500},
|
||||
{200, 750},
|
||||
{200, 750},
|
||||
{150, 200}
|
||||
const struct BerryCrushBerryData gBerryCrush_BerryData[] = {
|
||||
[ITEM_CHERI_BERRY - FIRST_BERRY_INDEX] = {.difficulty = 50, .powder = 20},
|
||||
[ITEM_CHESTO_BERRY - FIRST_BERRY_INDEX] = {.difficulty = 50, .powder = 20},
|
||||
[ITEM_PECHA_BERRY - FIRST_BERRY_INDEX] = {.difficulty = 50, .powder = 20},
|
||||
[ITEM_RAWST_BERRY - FIRST_BERRY_INDEX] = {.difficulty = 50, .powder = 20},
|
||||
[ITEM_ASPEAR_BERRY - FIRST_BERRY_INDEX] = {.difficulty = 50, .powder = 20},
|
||||
[ITEM_LEPPA_BERRY - FIRST_BERRY_INDEX] = {.difficulty = 50, .powder = 30},
|
||||
[ITEM_ORAN_BERRY - FIRST_BERRY_INDEX] = {.difficulty = 50, .powder = 30},
|
||||
[ITEM_PERSIM_BERRY - FIRST_BERRY_INDEX] = {.difficulty = 50, .powder = 30},
|
||||
[ITEM_LUM_BERRY - FIRST_BERRY_INDEX] = {.difficulty = 50, .powder = 30},
|
||||
[ITEM_SITRUS_BERRY - FIRST_BERRY_INDEX] = {.difficulty = 50, .powder = 30},
|
||||
[ITEM_FIGY_BERRY - FIRST_BERRY_INDEX] = {.difficulty = 60, .powder = 50},
|
||||
[ITEM_WIKI_BERRY - FIRST_BERRY_INDEX] = {.difficulty = 60, .powder = 50},
|
||||
[ITEM_MAGO_BERRY - FIRST_BERRY_INDEX] = {.difficulty = 60, .powder = 50},
|
||||
[ITEM_AGUAV_BERRY - FIRST_BERRY_INDEX] = {.difficulty = 60, .powder = 50},
|
||||
[ITEM_IAPAPA_BERRY - FIRST_BERRY_INDEX] = {.difficulty = 60, .powder = 50},
|
||||
[ITEM_RAZZ_BERRY - FIRST_BERRY_INDEX] = {.difficulty = 80, .powder = 70},
|
||||
[ITEM_BLUK_BERRY - FIRST_BERRY_INDEX] = {.difficulty = 80, .powder = 70},
|
||||
[ITEM_NANAB_BERRY - FIRST_BERRY_INDEX] = {.difficulty = 80, .powder = 70},
|
||||
[ITEM_WEPEAR_BERRY - FIRST_BERRY_INDEX] = {.difficulty = 80, .powder = 70},
|
||||
[ITEM_PINAP_BERRY - FIRST_BERRY_INDEX] = {.difficulty = 80, .powder = 70},
|
||||
[ITEM_POMEG_BERRY - FIRST_BERRY_INDEX] = {.difficulty = 100, .powder = 100},
|
||||
[ITEM_KELPSY_BERRY - FIRST_BERRY_INDEX] = {.difficulty = 100, .powder = 100},
|
||||
[ITEM_QUALOT_BERRY - FIRST_BERRY_INDEX] = {.difficulty = 100, .powder = 100},
|
||||
[ITEM_HONDEW_BERRY - FIRST_BERRY_INDEX] = {.difficulty = 100, .powder = 100},
|
||||
[ITEM_GREPA_BERRY - FIRST_BERRY_INDEX] = {.difficulty = 100, .powder = 100},
|
||||
[ITEM_TAMATO_BERRY - FIRST_BERRY_INDEX] = {.difficulty = 130, .powder = 150},
|
||||
[ITEM_CORNN_BERRY - FIRST_BERRY_INDEX] = {.difficulty = 130, .powder = 150},
|
||||
[ITEM_MAGOST_BERRY - FIRST_BERRY_INDEX] = {.difficulty = 130, .powder = 150},
|
||||
[ITEM_RABUTA_BERRY - FIRST_BERRY_INDEX] = {.difficulty = 130, .powder = 150},
|
||||
[ITEM_NOMEL_BERRY - FIRST_BERRY_INDEX] = {.difficulty = 130, .powder = 150},
|
||||
[ITEM_SPELON_BERRY - FIRST_BERRY_INDEX] = {.difficulty = 160, .powder = 250},
|
||||
[ITEM_PAMTRE_BERRY - FIRST_BERRY_INDEX] = {.difficulty = 160, .powder = 250},
|
||||
[ITEM_WATMEL_BERRY - FIRST_BERRY_INDEX] = {.difficulty = 160, .powder = 250},
|
||||
[ITEM_DURIN_BERRY - FIRST_BERRY_INDEX] = {.difficulty = 160, .powder = 250},
|
||||
[ITEM_BELUE_BERRY - FIRST_BERRY_INDEX] = {.difficulty = 160, .powder = 250},
|
||||
[ITEM_LIECHI_BERRY - FIRST_BERRY_INDEX] = {.difficulty = 180, .powder = 500},
|
||||
[ITEM_GANLON_BERRY - FIRST_BERRY_INDEX] = {.difficulty = 180, .powder = 500},
|
||||
[ITEM_SALAC_BERRY - FIRST_BERRY_INDEX] = {.difficulty = 180, .powder = 500},
|
||||
[ITEM_PETAYA_BERRY - FIRST_BERRY_INDEX] = {.difficulty = 180, .powder = 500},
|
||||
[ITEM_APICOT_BERRY - FIRST_BERRY_INDEX] = {.difficulty = 180, .powder = 500},
|
||||
[ITEM_LANSAT_BERRY - FIRST_BERRY_INDEX] = {.difficulty = 200, .powder = 750},
|
||||
[ITEM_STARF_BERRY - FIRST_BERRY_INDEX] = {.difficulty = 200, .powder = 750},
|
||||
[ITEM_ENIGMA_BERRY - FIRST_BERRY_INDEX] = {.difficulty = 150, .powder = 200}
|
||||
};
|
||||
|
||||
const struct BerryTree gBlankBerryTree = {};
|
||||
|
||||
+1840
-1541
File diff suppressed because it is too large
Load Diff
+1
-1
@@ -904,7 +904,7 @@ static void Task_StartWirelessCableClubBattle(u8 taskId)
|
||||
{
|
||||
struct LinkPlayer *player = (struct LinkPlayer *)gBlockRecvBuffer[i];
|
||||
gLinkPlayers[i] = *player;
|
||||
sub_800B524(&gLinkPlayers[i]);
|
||||
ConvertLinkPlayerName(&gLinkPlayers[i]);
|
||||
ResetBlockReceivedFlag(i);
|
||||
}
|
||||
tState = 4;
|
||||
|
||||
+1
-1
@@ -2250,7 +2250,7 @@ const struct Item gItems[] =
|
||||
.name = _("SOOTHE BELL"),
|
||||
.itemId = ITEM_SOOTHE_BELL,
|
||||
.price = 100,
|
||||
.holdEffect = HOLD_EFFECT_HAPPINESS_UP,
|
||||
.holdEffect = HOLD_EFFECT_FRIENDSHIP_UP,
|
||||
.description = sSootheBellDesc,
|
||||
.pocket = POCKET_ITEMS,
|
||||
.type = ITEM_USE_BAG_MENU,
|
||||
|
||||
@@ -543,7 +543,7 @@ static const struct WindowTemplate sLevelUpStatsWindowTemplate =
|
||||
.baseBlock = 0x2E9,
|
||||
};
|
||||
|
||||
static const struct WindowTemplate sUnusedWindowTemplate_08615978 =
|
||||
static const struct WindowTemplate sUnusedWindowTemplate1 =
|
||||
{
|
||||
.bg = 2,
|
||||
.tilemapLeft = 2,
|
||||
@@ -554,7 +554,7 @@ static const struct WindowTemplate sUnusedWindowTemplate_08615978 =
|
||||
.baseBlock = 0x1DF,
|
||||
};
|
||||
|
||||
static const struct WindowTemplate sUnusedWindowTemplate_08615980 =
|
||||
static const struct WindowTemplate sUnusedWindowTemplate2 =
|
||||
{
|
||||
.bg = 2,
|
||||
.tilemapLeft = 0,
|
||||
@@ -669,7 +669,7 @@ static const u8 *const sDescriptionStringTable[] =
|
||||
[PARTYBOX_DESC_DONT_HAVE] = gText_DontHave,
|
||||
};
|
||||
|
||||
static const u16 sUnused_08615B94[] =
|
||||
static const u16 sUnusedData[] =
|
||||
{
|
||||
0x0108, 0x0151, 0x0160, 0x015b, 0x002e, 0x005c, 0x0102, 0x0153, 0x014b, 0x00ed, 0x00f1, 0x010d, 0x003a, 0x003b, 0x003f, 0x0071,
|
||||
0x00b6, 0x00f0, 0x00ca, 0x00db, 0x00da, 0x004c, 0x00e7, 0x0055, 0x0057, 0x0059, 0x00d8, 0x005b, 0x005e, 0x00f7, 0x0118, 0x0068,
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
+4196
-3643
File diff suppressed because it is too large
Load Diff
@@ -67,7 +67,7 @@ static bool8 TryStartCoordEventScript(struct MapPosition *);
|
||||
static bool8 TryStartWarpEventScript(struct MapPosition *, u16);
|
||||
static bool8 TryStartMiscWalkingScripts(u16);
|
||||
static bool8 TryStartStepCountScript(u16);
|
||||
static void UpdateHappinessStepCounter(void);
|
||||
static void UpdateFriendshipStepCounter(void);
|
||||
static bool8 UpdatePoisonStepCounter(void);
|
||||
|
||||
void FieldClearPlayerInput(struct FieldInput *input)
|
||||
@@ -542,7 +542,7 @@ static bool8 TryStartStepCountScript(u16 metatileBehavior)
|
||||
}
|
||||
|
||||
IncrementRematchStepCounter();
|
||||
UpdateHappinessStepCounter();
|
||||
UpdateFriendshipStepCounter();
|
||||
UpdateFarawayIslandStepCounter();
|
||||
|
||||
if (!(gPlayerAvatar.flags & PLAYER_AVATAR_FLAG_FORCED_MOVE) && !MetatileBehavior_IsForcedMovementTile(metatileBehavior))
|
||||
@@ -607,14 +607,15 @@ static bool8 TryStartStepCountScript(u16 metatileBehavior)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void Unref_ClearHappinessStepCounter(void)
|
||||
// Unused
|
||||
static void ClearFriendshipStepCounter(void)
|
||||
{
|
||||
VarSet(VAR_HAPPINESS_STEP_COUNTER, 0);
|
||||
VarSet(VAR_FRIENDSHIP_STEP_COUNTER, 0);
|
||||
}
|
||||
|
||||
static void UpdateHappinessStepCounter(void)
|
||||
static void UpdateFriendshipStepCounter(void)
|
||||
{
|
||||
u16 *ptr = GetVarPointer(VAR_HAPPINESS_STEP_COUNTER);
|
||||
u16 *ptr = GetVarPointer(VAR_FRIENDSHIP_STEP_COUNTER);
|
||||
int i;
|
||||
|
||||
(*ptr)++;
|
||||
|
||||
+30
-28
@@ -357,40 +357,42 @@ static void DrawDoor(const struct DoorGraphics *gfx, const struct DoorAnimFrame
|
||||
}
|
||||
}
|
||||
|
||||
enum
|
||||
{
|
||||
TD_FRAMELIST = 0,
|
||||
TD_GFX = 2,
|
||||
TD_FRAME = 4,
|
||||
TD_COUNTER,
|
||||
TD_X,
|
||||
TD_Y
|
||||
};
|
||||
#define tFramesHi data[0]
|
||||
#define tFramesLo data[1]
|
||||
#define tGfxHi data[2]
|
||||
#define tGfxLo data[3]
|
||||
#define tFrameId data[4]
|
||||
#define tCounter data[5]
|
||||
#define tX data[6]
|
||||
#define tY data[7]
|
||||
|
||||
static bool32 sub_808A5F0(struct DoorGraphics *gfx, struct DoorAnimFrame *frames, s16 *taskData)
|
||||
// Draws a single frame of the door animation, or skips drawing to wait between frames.
|
||||
// Returns FALSE when the final frame has been reached
|
||||
static bool32 AnimateDoorFrame(struct DoorGraphics *gfx, struct DoorAnimFrame *frames, s16 *data)
|
||||
{
|
||||
if (taskData[TD_COUNTER] == 0)
|
||||
DrawDoor(gfx, &frames[taskData[TD_FRAME]], taskData[TD_X], taskData[TD_Y]);
|
||||
if (taskData[TD_COUNTER] == frames[taskData[TD_FRAME]].time)
|
||||
if (tCounter == 0)
|
||||
DrawDoor(gfx, &frames[tFrameId], tX, tY);
|
||||
|
||||
if (tCounter == frames[tFrameId].time)
|
||||
{
|
||||
taskData[TD_COUNTER] = 0;
|
||||
taskData[TD_FRAME]++;
|
||||
if (frames[taskData[TD_FRAME]].time == 0)
|
||||
tCounter = 0;
|
||||
tFrameId++;
|
||||
if (frames[tFrameId].time == 0)
|
||||
return FALSE;
|
||||
else
|
||||
return TRUE;
|
||||
}
|
||||
taskData[TD_COUNTER]++;
|
||||
tCounter++;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void Task_AnimateDoor(u8 taskId)
|
||||
{
|
||||
u16 *taskData = gTasks[taskId].data;
|
||||
struct DoorAnimFrame *frames = (struct DoorAnimFrame *)(taskData[TD_FRAMELIST] << 16 | taskData[TD_FRAMELIST + 1]);
|
||||
struct DoorGraphics *gfx = (struct DoorGraphics *)(taskData[TD_GFX] << 16 | taskData[TD_GFX + 1]);
|
||||
u16 *data = gTasks[taskId].data;
|
||||
struct DoorAnimFrame *frames = (struct DoorAnimFrame *)(tFramesHi << 16 | tFramesLo);
|
||||
struct DoorGraphics *gfx = (struct DoorGraphics *)(tGfxHi << 16 | tGfxLo);
|
||||
|
||||
if (sub_808A5F0(gfx, frames, taskData) == FALSE)
|
||||
if (AnimateDoorFrame(gfx, frames, data) == FALSE)
|
||||
DestroyTask(taskId);
|
||||
}
|
||||
|
||||
@@ -419,16 +421,16 @@ static s8 StartDoorAnimationTask(const struct DoorGraphics *gfx, const struct Do
|
||||
else
|
||||
{
|
||||
u8 taskId = CreateTask(Task_AnimateDoor, 0x50);
|
||||
s16 *taskData = gTasks[taskId].data;
|
||||
s16 *data = gTasks[taskId].data;
|
||||
|
||||
taskData[TD_X] = x;
|
||||
taskData[TD_Y] = y;
|
||||
tX = x;
|
||||
tY = y;
|
||||
|
||||
taskData[TD_FRAMELIST + 1] = (u32)frames;
|
||||
taskData[TD_FRAMELIST] = (u32)frames >> 16;
|
||||
tFramesLo = (u32)frames;
|
||||
tFramesHi = (u32)frames >> 16;
|
||||
|
||||
taskData[TD_GFX + 1] = (u32)gfx;
|
||||
taskData[TD_GFX] = (u32)gfx >> 16;
|
||||
tGfxLo = (u32)gfx;
|
||||
tGfxHi = (u32)gfx >> 16;
|
||||
|
||||
return taskId;
|
||||
}
|
||||
|
||||
+14
-21
@@ -480,13 +480,13 @@ static const struct Subsprite sSubsprites_HofMonitorBig[] =
|
||||
|
||||
static const struct SubspriteTable sSubspriteTable_HofMonitorBig = subsprite_table(sSubsprites_HofMonitorBig);
|
||||
|
||||
const union AnimCmd gSpriteAnim_855C2CC[] =
|
||||
const union AnimCmd sAnim_Static[] =
|
||||
{
|
||||
ANIMCMD_FRAME(.imageValue = 0, .duration = 1),
|
||||
ANIMCMD_JUMP(0)
|
||||
};
|
||||
|
||||
const union AnimCmd gSpriteAnim_855C2D4[] =
|
||||
const union AnimCmd sAnim_Flicker[] =
|
||||
{
|
||||
ANIMCMD_FRAME(.imageValue = 0, .duration = 16),
|
||||
ANIMCMD_FRAME(.imageValue = 1, .duration = 16),
|
||||
@@ -499,15 +499,16 @@ const union AnimCmd gSpriteAnim_855C2D4[] =
|
||||
ANIMCMD_END
|
||||
};
|
||||
|
||||
const union AnimCmd *const gSpriteAnimTable_855C2F8[] =
|
||||
// Flicker on and off, for the Pokéballs / monitors during the PokéCenter heal effect
|
||||
const union AnimCmd *const sAnims_Flicker[] =
|
||||
{
|
||||
gSpriteAnim_855C2CC,
|
||||
gSpriteAnim_855C2D4
|
||||
sAnim_Static,
|
||||
sAnim_Flicker
|
||||
};
|
||||
|
||||
static const union AnimCmd *const sAnimTable_HofMonitor[] =
|
||||
static const union AnimCmd *const sAnims_HofMonitor[] =
|
||||
{
|
||||
gSpriteAnim_855C2CC
|
||||
sAnim_Static
|
||||
};
|
||||
|
||||
static const struct SpriteTemplate sSpriteTemplate_PokeballGlow =
|
||||
@@ -515,7 +516,7 @@ static const struct SpriteTemplate sSpriteTemplate_PokeballGlow =
|
||||
.tileTag = 0xFFFF,
|
||||
.paletteTag = FLDEFF_PAL_TAG_POKEBALL_GLOW,
|
||||
.oam = &sOam_8x8,
|
||||
.anims = gSpriteAnimTable_855C2F8,
|
||||
.anims = sAnims_Flicker,
|
||||
.images = sPicTable_PokeballGlow,
|
||||
.affineAnims = gDummySpriteAffineAnimTable,
|
||||
.callback = SpriteCB_PokeballGlow
|
||||
@@ -526,7 +527,7 @@ static const struct SpriteTemplate sSpriteTemplate_PokecenterMonitor =
|
||||
.tileTag = 0xFFFF,
|
||||
.paletteTag = FLDEFF_PAL_TAG_GENERAL_0,
|
||||
.oam = &sOam_16x16,
|
||||
.anims = gSpriteAnimTable_855C2F8,
|
||||
.anims = sAnims_Flicker,
|
||||
.images = sPicTable_PokecenterMonitor,
|
||||
.affineAnims = gDummySpriteAffineAnimTable,
|
||||
.callback = SpriteCB_PokecenterMonitor
|
||||
@@ -537,7 +538,7 @@ static const struct SpriteTemplate sSpriteTemplate_HofMonitorBig =
|
||||
.tileTag = 0xFFFF,
|
||||
.paletteTag = FLDEFF_PAL_TAG_HOF_MONITOR,
|
||||
.oam = &sOam_16x16,
|
||||
.anims = sAnimTable_HofMonitor,
|
||||
.anims = sAnims_HofMonitor,
|
||||
.images = sPicTable_HofMonitorBig,
|
||||
.affineAnims = gDummySpriteAffineAnimTable,
|
||||
.callback = SpriteCB_HallOfFameMonitor
|
||||
@@ -548,7 +549,7 @@ static const struct SpriteTemplate sSpriteTemplate_HofMonitorSmall =
|
||||
.tileTag = 0xFFFF,
|
||||
.paletteTag = FLDEFF_PAL_TAG_HOF_MONITOR,
|
||||
.oam = &sOam_32x16,
|
||||
.anims = sAnimTable_HofMonitor,
|
||||
.anims = sAnims_HofMonitor,
|
||||
.images = sPicTable_HofMonitorSmall,
|
||||
.affineAnims = gDummySpriteAffineAnimTable,
|
||||
.callback = SpriteCB_HallOfFameMonitor
|
||||
@@ -3853,16 +3854,8 @@ static void Task_MoveDeoxysRock(u8 taskId)
|
||||
case 0:
|
||||
data[4] = sprite->pos1.x << 4;
|
||||
data[5] = sprite->pos1.y << 4;
|
||||
|
||||
// UB: Possible divide by zero
|
||||
#ifdef UBFIX
|
||||
#define DIVISOR (data[8] ? data[8] : 1);
|
||||
#else
|
||||
#define DIVISOR (data[8])
|
||||
#endif
|
||||
|
||||
data[6] = (data[2] * 16 - data[4]) / DIVISOR;
|
||||
data[7] = (data[3] * 16 - data[5]) / DIVISOR;
|
||||
data[6] = SAFE_DIV(data[2] * 16 - data[4], data[8]);
|
||||
data[7] = SAFE_DIV(data[3] * 16 - data[5], data[8]);
|
||||
data[0]++;
|
||||
case 1:
|
||||
if (data[8] != 0)
|
||||
|
||||
+18
-22
@@ -16,7 +16,6 @@
|
||||
#include "constants/songs.h"
|
||||
#include "constants/map_types.h"
|
||||
|
||||
// structures
|
||||
struct FlashStruct
|
||||
{
|
||||
u8 fromType;
|
||||
@@ -26,7 +25,6 @@ struct FlashStruct
|
||||
void (*func)(void);
|
||||
};
|
||||
|
||||
// static functions
|
||||
static void FieldCallback_Flash(void);
|
||||
static void FldEff_UseFlash(void);
|
||||
static bool8 TryDoMapTransition(void);
|
||||
@@ -42,7 +40,6 @@ static void Task_EnterCaveTransition2(u8 taskId);
|
||||
static void Task_EnterCaveTransition3(u8 taskId);
|
||||
static void Task_EnterCaveTransition4(u8 taskId);
|
||||
|
||||
// rodata
|
||||
static const struct FlashStruct sTransitionTypes[] =
|
||||
{
|
||||
{MAP_TYPE_TOWN, MAP_TYPE_UNDERGROUND, TRUE, FALSE, DoEnterCaveTransition},
|
||||
@@ -64,15 +61,14 @@ static const struct FlashStruct sTransitionTypes[] =
|
||||
{},
|
||||
};
|
||||
|
||||
static const u16 gCaveTransitionPalette_White[] = INCBIN_U16("graphics/misc/cave_transition_white.gbapal");
|
||||
static const u16 gCaveTransitionPalette_Black[] = INCBIN_U16("graphics/misc/cave_transition_black.gbapal");
|
||||
static const u16 sCaveTransitionPalette_White[] = INCBIN_U16("graphics/misc/cave_transition_white.gbapal");
|
||||
static const u16 sCaveTransitionPalette_Black[] = INCBIN_U16("graphics/misc/cave_transition_black.gbapal");
|
||||
|
||||
static const u16 gUnknown_085B2890[] = INCBIN_U16("graphics/misc/85B2890.gbapal");
|
||||
static const u16 gUnknown_085B28A0[] = INCBIN_U16("graphics/misc/85B28A0.gbapal");
|
||||
static const u32 gCaveTransitionTilemap[] = INCBIN_U32("graphics/misc/cave_transition_map.bin.lz");
|
||||
static const u32 gCaveTransitionTiles[] = INCBIN_U32("graphics/misc/cave_transition.4bpp.lz");
|
||||
static const u16 sCaveTransitionPalette_Enter[] = INCBIN_U16("graphics/misc/cave_transition_enter.gbapal");
|
||||
static const u16 sCaveTransitionPalette_Exit[] = INCBIN_U16("graphics/misc/cave_transition_exit.gbapal");
|
||||
static const u32 sCaveTransitionTilemap[] = INCBIN_U32("graphics/misc/cave_transition_map.bin.lz");
|
||||
static const u32 sCaveTransitionTiles[] = INCBIN_U32("graphics/misc/cave_transition.4bpp.lz");
|
||||
|
||||
// text
|
||||
bool8 SetUpFieldMove_Flash(void)
|
||||
{
|
||||
// In Ruby and Sapphire, Registeel's tomb is opened by using Fly. In Emerald,
|
||||
@@ -220,10 +216,10 @@ static void Task_ExitCaveTransition1(u8 taskId)
|
||||
static void Task_ExitCaveTransition2(u8 taskId)
|
||||
{
|
||||
SetGpuReg(REG_OFFSET_DISPCNT, 0);
|
||||
LZ77UnCompVram(gCaveTransitionTiles, (void *)(VRAM + 0xC000));
|
||||
LZ77UnCompVram(gCaveTransitionTilemap, (void *)(VRAM + 0xF800));
|
||||
LoadPalette(gCaveTransitionPalette_White, 0xE0, 0x20);
|
||||
LoadPalette(gUnknown_085B28A0, 0xE0, 0x10);
|
||||
LZ77UnCompVram(sCaveTransitionTiles, (void *)(VRAM + 0xC000));
|
||||
LZ77UnCompVram(sCaveTransitionTilemap, (void *)(VRAM + 0xF800));
|
||||
LoadPalette(sCaveTransitionPalette_White, 0xE0, 0x20);
|
||||
LoadPalette(sCaveTransitionPalette_Exit, 0xE0, 0x10);
|
||||
SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_TGT1_BG0
|
||||
| BLDCNT_EFFECT_BLEND
|
||||
| BLDCNT_TGT2_BG1
|
||||
@@ -274,11 +270,11 @@ static void Task_ExitCaveTransition4(u8 taskId)
|
||||
if (count < 8)
|
||||
{
|
||||
gTasks[taskId].data[2]++;
|
||||
LoadPalette(&gUnknown_085B28A0[count], 0xE0, 16 - 2 * count);
|
||||
LoadPalette(&sCaveTransitionPalette_Exit[count], 0xE0, 16 - 2 * count);
|
||||
}
|
||||
else
|
||||
{
|
||||
LoadPalette(gCaveTransitionPalette_White, 0, 0x20);
|
||||
LoadPalette(sCaveTransitionPalette_White, 0, 0x20);
|
||||
gTasks[taskId].func = Task_ExitCaveTransition5;
|
||||
gTasks[taskId].data[2] = 8;
|
||||
}
|
||||
@@ -305,8 +301,8 @@ static void Task_EnterCaveTransition1(u8 taskId)
|
||||
static void Task_EnterCaveTransition2(u8 taskId)
|
||||
{
|
||||
SetGpuReg(REG_OFFSET_DISPCNT, 0);
|
||||
LZ77UnCompVram(gCaveTransitionTiles, (void *)(VRAM + 0xC000));
|
||||
LZ77UnCompVram(gCaveTransitionTilemap, (void *)(VRAM + 0xF800));
|
||||
LZ77UnCompVram(sCaveTransitionTiles, (void *)(VRAM + 0xC000));
|
||||
LZ77UnCompVram(sCaveTransitionTilemap, (void *)(VRAM + 0xF800));
|
||||
SetGpuReg(REG_OFFSET_BLDCNT, 0);
|
||||
SetGpuReg(REG_OFFSET_BLDALPHA, 0);
|
||||
SetGpuReg(REG_OFFSET_BLDY, 0);
|
||||
@@ -319,8 +315,8 @@ static void Task_EnterCaveTransition2(u8 taskId)
|
||||
| DISPCNT_OBJ_1D_MAP
|
||||
| DISPCNT_BG0_ON
|
||||
| DISPCNT_OBJ_ON);
|
||||
LoadPalette(gCaveTransitionPalette_White, 0xE0, 0x20);
|
||||
LoadPalette(gCaveTransitionPalette_Black, 0, 0x20);
|
||||
LoadPalette(sCaveTransitionPalette_White, 0xE0, 0x20);
|
||||
LoadPalette(sCaveTransitionPalette_Black, 0, 0x20);
|
||||
gTasks[taskId].func = Task_EnterCaveTransition3;
|
||||
gTasks[taskId].data[0] = 16;
|
||||
gTasks[taskId].data[1] = 0;
|
||||
@@ -335,7 +331,7 @@ static void Task_EnterCaveTransition3(u8 taskId)
|
||||
{
|
||||
gTasks[taskId].data[2]++;
|
||||
gTasks[taskId].data[2]++;
|
||||
LoadPalette(&gUnknown_085B2890[15 - count], 0xE0, 2 * (count + 1));
|
||||
LoadPalette(&sCaveTransitionPalette_Enter[15 - count], 0xE0, 2 * (count + 1));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -363,7 +359,7 @@ static void Task_EnterCaveTransition4(u8 taskId)
|
||||
}
|
||||
else
|
||||
{
|
||||
LoadPalette(gCaveTransitionPalette_Black, 0, 0x20);
|
||||
LoadPalette(sCaveTransitionPalette_Black, 0, 0x20);
|
||||
SetMainCallback2(gMain.savedCallback);
|
||||
}
|
||||
}
|
||||
|
||||
+6
-6
@@ -2383,13 +2383,13 @@ void ClearRankingHallRecords(void)
|
||||
{
|
||||
s32 i, j, k;
|
||||
|
||||
// BUG: Passing 0 as a pointer instead of a pointer holding a value of 0.
|
||||
#ifdef BUGFIX
|
||||
u8 zero = 0;
|
||||
#define ZERO (&zero)
|
||||
#else
|
||||
// UB: Passing 0 as a pointer instead of a pointer holding a value of 0.
|
||||
#ifdef UBFIX
|
||||
u8 emptyId[TRAINER_ID_LENGTH] = {0};
|
||||
#define ZERO emptyId
|
||||
#else
|
||||
#define ZERO 0
|
||||
#endif
|
||||
#endif
|
||||
|
||||
for (i = 0; i < HALL_FACILITIES_COUNT; i++)
|
||||
{
|
||||
|
||||
+3
-3
@@ -1543,9 +1543,9 @@ const u16 gUnknown_08DE3350[] = INCBIN_U16("graphics/frontier_pass/tilemap1.bin"
|
||||
const u16 gUnknown_08DE3374[] = INCBIN_U16("graphics/frontier_pass/tilemap2.bin");
|
||||
|
||||
// Berry Crush
|
||||
const u16 gUnknown_08DE3398[] = INCBIN_U16("graphics/berry_crusher/tiles.gbapal");
|
||||
const u32 gUnknown_08DE34B8[] = INCBIN_U32("graphics/berry_crusher/tiles.4bpp.lz");
|
||||
const u32 gUnknown_08DE3FD4[] = INCBIN_U32("graphics/berry_crusher/tiles.bin.lz");
|
||||
const u16 gBerryCrush_Crusher_Pal[] = INCBIN_U16("graphics/berry_crush/crusher.gbapal");
|
||||
const u32 gBerryCrush_Crusher_Gfx[] = INCBIN_U32("graphics/berry_crush/crusher.4bpp.lz");
|
||||
const u32 gBerryCrush_Crusher_Tilemap[] = INCBIN_U32("graphics/berry_crush/crusher.bin.lz");
|
||||
|
||||
// random garbage at the end.
|
||||
static const u8 sEmpty3[0x54BAC] = {0};
|
||||
|
||||
@@ -51,7 +51,9 @@ static u16 QuantizePixel_GrayscaleSmall(u16*);
|
||||
static u16 QuantizePixel_Grayscale(u16*);
|
||||
static u16 QuantizePixel_PrimaryColors(u16*);
|
||||
|
||||
extern const u8 gPointillismPoints[][3];
|
||||
#define MAX_DIMENSION 64
|
||||
|
||||
#include "data/pointillism_points.h"
|
||||
|
||||
void ApplyImageProcessingEffects(struct ImageProcessingContext *context)
|
||||
{
|
||||
@@ -169,7 +171,7 @@ static void ApplyImageEffect_RedChannelGrayscaleHighlight(u8 highlight)
|
||||
static void ApplyImageEffect_Pointillism(void)
|
||||
{
|
||||
u32 i;
|
||||
for (i = 0; i < 3200; i++)
|
||||
for (i = 0; i < ARRAY_COUNT(sPointillismPoints); i++)
|
||||
AddPointillismPoints(i);
|
||||
}
|
||||
|
||||
@@ -307,9 +309,9 @@ static void ApplyImageEffect_Shimmer(void)
|
||||
|
||||
// First, invert all of the colors.
|
||||
pixel = gCanvasPixels;
|
||||
for (i = 0; i < 64; i++)
|
||||
for (i = 0; i < MAX_DIMENSION; i++)
|
||||
{
|
||||
for (j = 0; j < 64; j++, pixel++)
|
||||
for (j = 0; j < MAX_DIMENSION; j++, pixel++)
|
||||
{
|
||||
if (!IS_ALPHA(*pixel))
|
||||
*pixel = QuantizePixel_Invert(pixel);
|
||||
@@ -317,16 +319,16 @@ static void ApplyImageEffect_Shimmer(void)
|
||||
}
|
||||
|
||||
// Blur the pixels twice.
|
||||
for (j = 0; j < 64; j++)
|
||||
for (j = 0; j < MAX_DIMENSION; j++)
|
||||
{
|
||||
pixel = &gCanvasPixels[j];
|
||||
prevPixel = *pixel;
|
||||
*pixel = RGB_ALPHA;
|
||||
for (i = 1, pixel += 64; i < 63; i++, pixel += 64)
|
||||
for (i = 1, pixel += MAX_DIMENSION; i < MAX_DIMENSION - 1; i++, pixel += MAX_DIMENSION)
|
||||
{
|
||||
if (!IS_ALPHA(*pixel))
|
||||
{
|
||||
*pixel = QuantizePixel_BlurHard(&prevPixel, pixel, pixel + 64);
|
||||
*pixel = QuantizePixel_BlurHard(&prevPixel, pixel, pixel + MAX_DIMENSION);
|
||||
prevPixel = *pixel;
|
||||
}
|
||||
}
|
||||
@@ -335,11 +337,11 @@ static void ApplyImageEffect_Shimmer(void)
|
||||
pixel = &gCanvasPixels[j];
|
||||
prevPixel = *pixel;
|
||||
*pixel = RGB_ALPHA;
|
||||
for (i = 1, pixel += 64; i < 63; i++, pixel += 64)
|
||||
for (i = 1, pixel += MAX_DIMENSION; i < MAX_DIMENSION - 1; i++, pixel += MAX_DIMENSION)
|
||||
{
|
||||
if (!IS_ALPHA(*pixel))
|
||||
{
|
||||
*pixel = QuantizePixel_BlurHard(&prevPixel, pixel, pixel + 64);
|
||||
*pixel = QuantizePixel_BlurHard(&prevPixel, pixel, pixel + MAX_DIMENSION);
|
||||
prevPixel = *pixel;
|
||||
}
|
||||
}
|
||||
@@ -351,9 +353,9 @@ static void ApplyImageEffect_Shimmer(void)
|
||||
// The above blur causes the outline areas to darken, which makes
|
||||
// this inversion give the effect of light outlines.
|
||||
pixel = gCanvasPixels;
|
||||
for (i = 0; i < 64; i++)
|
||||
for (i = 0; i < MAX_DIMENSION; i++)
|
||||
{
|
||||
for (j = 0; j < 64; j++, pixel++)
|
||||
for (j = 0; j < MAX_DIMENSION; j++, pixel++)
|
||||
{
|
||||
if (!IS_ALPHA(*pixel))
|
||||
*pixel = QuantizePixel_Invert(pixel);
|
||||
@@ -408,19 +410,19 @@ struct PointillismPoint
|
||||
u16 delta;
|
||||
};
|
||||
|
||||
static void AddPointillismPoints(u16 arg0)
|
||||
static void AddPointillismPoints(u16 point)
|
||||
{
|
||||
u8 i;
|
||||
bool8 offsetDownLeft;
|
||||
u8 colorType;
|
||||
struct PointillismPoint points[6];
|
||||
|
||||
points[0].column = gPointillismPoints[arg0][0];
|
||||
points[0].row = gPointillismPoints[arg0][1];
|
||||
points[0].delta = (gPointillismPoints[arg0][2] >> 3) & 7;
|
||||
points[0].column = sPointillismPoints[point][0];
|
||||
points[0].row = sPointillismPoints[point][1];
|
||||
points[0].delta = GET_POINT_DELTA(sPointillismPoints[point][2]);
|
||||
|
||||
colorType = (gPointillismPoints[arg0][2] >> 1) & 3;
|
||||
offsetDownLeft = gPointillismPoints[arg0][2] & 1;
|
||||
colorType = GET_POINT_COLOR_TYPE(sPointillismPoints[point][2]);
|
||||
offsetDownLeft = GET_POINT_OFFSET_DL(sPointillismPoints[point][2]);
|
||||
for (i = 1; i < points[0].delta; i++)
|
||||
{
|
||||
if (!offsetDownLeft)
|
||||
@@ -434,7 +436,7 @@ static void AddPointillismPoints(u16 arg0)
|
||||
points[i].row = points[0].row - 1;
|
||||
}
|
||||
|
||||
if (points[i].column > 63 || points[i].row > 63)
|
||||
if (points[i].column >= MAX_DIMENSION || points[i].row >= MAX_DIMENSION)
|
||||
{
|
||||
points[0].delta = i - 1;
|
||||
break;
|
||||
@@ -445,7 +447,7 @@ static void AddPointillismPoints(u16 arg0)
|
||||
|
||||
for (i = 0; i < points[0].delta; i++)
|
||||
{
|
||||
u16 *pixel = &gCanvasPixels[points[i].row * 64] + points[i].column;
|
||||
u16 *pixel = &gCanvasPixels[points[i].row * MAX_DIMENSION] + points[i].column;
|
||||
|
||||
if (!IS_ALPHA(*pixel))
|
||||
{
|
||||
@@ -457,7 +459,7 @@ static void AddPointillismPoints(u16 arg0)
|
||||
{
|
||||
case 0:
|
||||
case 1:
|
||||
switch (((gPointillismPoints[arg0][2] >> 3) & 7) % 3)
|
||||
switch (GET_POINT_DELTA(sPointillismPoints[point][2]) % 3)
|
||||
{
|
||||
case 0:
|
||||
if (red >= points[i].delta)
|
||||
|
||||
+1
-1
@@ -1746,7 +1746,7 @@ static void Task_Scene3_SpinPokeball(u8 taskId)
|
||||
gTasks[taskId].func = Task_Scene3_WaitGroudon;
|
||||
}
|
||||
|
||||
PanFadeAndZoomScreen(0x78, 0x50, 0x10000 / gTasks[taskId].tZoomDiv, gTasks[taskId].tAlpha);
|
||||
PanFadeAndZoomScreen(0x78, 0x50, SAFE_DIV(0x10000, gTasks[taskId].tZoomDiv), gTasks[taskId].tAlpha);
|
||||
|
||||
if (gIntroFrameCounter == TIMER_POKEBALL_FADE)
|
||||
BeginNormalPaletteFade(PALETTES_ALL, 0, 0, 16, RGB_WHITEALPHA);
|
||||
|
||||
@@ -19,9 +19,6 @@
|
||||
extern u16 gUnknown_0203CF30[];
|
||||
|
||||
// this file's functions
|
||||
#if !defined(NONMATCHING) && MODERN
|
||||
#define static
|
||||
#endif
|
||||
static bool8 CheckPyramidBagHasItem(u16 itemId, u16 count);
|
||||
static bool8 CheckPyramidBagHasSpace(u16 itemId, u16 count);
|
||||
|
||||
|
||||
+160
-227
@@ -41,8 +41,8 @@ struct LinkTestBGInfo
|
||||
{
|
||||
u32 screenBaseBlock;
|
||||
u32 paletteNum;
|
||||
u32 dummy_8;
|
||||
u32 dummy_C;
|
||||
u32 baseChar;
|
||||
u32 unused;
|
||||
};
|
||||
|
||||
static struct BlockTransfer sBlockSend;
|
||||
@@ -97,28 +97,26 @@ struct Link gLink;
|
||||
u8 gLastRecvQueueCount;
|
||||
u16 gLinkSavedIme;
|
||||
|
||||
EWRAM_DATA u8 gLinkTestDebugValuesEnabled = 0;
|
||||
EWRAM_DATA u8 gUnknown_020223BD = 0;
|
||||
static EWRAM_DATA u8 sLinkTestDebugValuesEnabled = 0;
|
||||
static EWRAM_DATA u8 sDummyFlag = FALSE;
|
||||
EWRAM_DATA u32 gBerryBlenderKeySendAttempts = 0;
|
||||
EWRAM_DATA u16 gBlockRecvBuffer[MAX_RFU_PLAYERS][BLOCK_BUFFER_SIZE / 2] = {};
|
||||
EWRAM_DATA u8 gBlockSendBuffer[BLOCK_BUFFER_SIZE] = {};
|
||||
EWRAM_DATA bool8 gLinkOpen = FALSE;
|
||||
static EWRAM_DATA bool8 sLinkOpen = FALSE;
|
||||
EWRAM_DATA u16 gLinkType = 0;
|
||||
EWRAM_DATA u16 gLinkTimeOutCounter = 0;
|
||||
static EWRAM_DATA u16 sTimeOutCounter = 0;
|
||||
EWRAM_DATA struct LinkPlayer gLocalLinkPlayer = {};
|
||||
EWRAM_DATA struct LinkPlayer gLinkPlayers[MAX_RFU_PLAYERS] = {};
|
||||
EWRAM_DATA struct LinkPlayer gSavedLinkPlayers[MAX_RFU_PLAYERS] = {};
|
||||
static EWRAM_DATA struct LinkPlayer sSavedLinkPlayers[MAX_RFU_PLAYERS] = {};
|
||||
EWRAM_DATA struct {
|
||||
u32 status;
|
||||
u8 lastRecvQueueCount;
|
||||
u8 lastSendQueueCount;
|
||||
u8 unk_06;
|
||||
bool8 disconnected;
|
||||
} sLinkErrorBuffer = {};
|
||||
static EWRAM_DATA u16 sReadyCloseLinkAttempts = 0; // never read
|
||||
static EWRAM_DATA void *sLinkErrorBgTilemapBuffer = NULL;
|
||||
|
||||
// Static ROM declarations
|
||||
|
||||
static void InitLocalLinkPlayer(void);
|
||||
static void VBlankCB_LinkError(void);
|
||||
static void CB2_LinkTest(void);
|
||||
@@ -131,7 +129,7 @@ static void LinkCB_BlockSend(void);
|
||||
static void LinkCB_BlockSendEnd(void);
|
||||
static void SetBlockReceivedFlag(u8 who);
|
||||
static u16 LinkTestCalcBlockChecksum(const u16 *src, u16 size);
|
||||
static void LinkTest_prnthex(u32 pos, u8 a0, u8 a1, u8 a2);
|
||||
static void LinkTest_PrintHex(u32 pos, u8 a0, u8 a1, u8 a2);
|
||||
static void LinkCB_RequestPlayerDataExchange(void);
|
||||
static void Task_PrintTestData(u8 taskId);
|
||||
|
||||
@@ -160,15 +158,13 @@ static void DoSend(void);
|
||||
static void StopTimer(void);
|
||||
static void SendRecvDone(void);
|
||||
|
||||
// .rodata
|
||||
|
||||
static const u16 sWirelessLinkDisplayPal[] = INCBIN_U16("graphics/interface/wireless_link_display.gbapal");
|
||||
static const u32 sWirelessLinkDisplayGfx[] = INCBIN_U32("graphics/interface/wireless_link_display.4bpp.lz");
|
||||
static const u32 sWirelessLinkDisplayTilemap[] = INCBIN_U32("graphics/interface/wireless_link_display.bin.lz");
|
||||
static const u16 sLinkTestDigitsPal[] = INCBIN_U16("graphics/interface/link_test_digits.gbapal");
|
||||
static const u16 sLinkTestDigitsGfx[] = INCBIN_U16("graphics/interface/link_test_digits.4bpp");
|
||||
static const u8 sUnusedTransparentWhite[] = _("{HIGHLIGHT TRANSPARENT}{COLOR WHITE}");
|
||||
static const u16 s2BlankTilesGfx[] = INCBIN_U16("graphics/interface/blank_1x2.4bpp");
|
||||
static const u16 sCommErrorBg_Gfx[] = INCBIN_U16("graphics/interface/comm_error_bg.4bpp");
|
||||
static const struct BlockRequest sBlockRequests[] = {
|
||||
{gBlockSendBuffer, 200},
|
||||
{gBlockSendBuffer, 200},
|
||||
@@ -226,15 +222,13 @@ static const struct WindowTemplate sLinkErrorWindowTemplates[] = {
|
||||
};
|
||||
|
||||
static const u8 sTextColors[] = { TEXT_COLOR_TRANSPARENT, TEXT_COLOR_WHITE, TEXT_COLOR_DARK_GREY };
|
||||
static const u8 sUnused_082ED224[] = {0x00, 0xFF, 0xFE, 0xFF, 0x00};
|
||||
|
||||
// .text
|
||||
static const u8 sUnusedData[] = {0x00, 0xFF, 0xFE, 0xFF, 0x00};
|
||||
|
||||
bool8 IsWirelessAdapterConnected(void)
|
||||
{
|
||||
SetWirelessCommType1();
|
||||
InitRFUAPI();
|
||||
if (rfu_LMAN_REQBN_softReset_and_checkID() == 0x8001)
|
||||
if (rfu_LMAN_REQBN_softReset_and_checkID() == RFU_ID)
|
||||
{
|
||||
rfu_REQ_stopMode();
|
||||
rfu_waitREQComplete();
|
||||
@@ -251,13 +245,13 @@ void Task_DestroySelf(u8 taskId)
|
||||
DestroyTask(taskId);
|
||||
}
|
||||
|
||||
static void InitLinkTestBG(u8 paletteNum, u8 bgNum, u8 screenBaseBlock, u8 charBaseBlock, u16 a4)
|
||||
static void InitLinkTestBG(u8 paletteNum, u8 bgNum, u8 screenBaseBlock, u8 charBaseBlock, u16 baseChar)
|
||||
{
|
||||
LoadPalette(sLinkTestDigitsPal, paletteNum * 16, 0x20);
|
||||
DmaCopy16(3, sLinkTestDigitsGfx, (u16 *)BG_CHAR_ADDR(charBaseBlock) + (16 * a4), sizeof sLinkTestDigitsGfx);
|
||||
DmaCopy16(3, sLinkTestDigitsGfx, (u16 *)BG_CHAR_ADDR(charBaseBlock) + (16 * baseChar), sizeof sLinkTestDigitsGfx);
|
||||
gLinkTestBGInfo.screenBaseBlock = screenBaseBlock;
|
||||
gLinkTestBGInfo.paletteNum = paletteNum;
|
||||
gLinkTestBGInfo.dummy_8 = a4;
|
||||
gLinkTestBGInfo.baseChar = baseChar;
|
||||
switch (bgNum)
|
||||
{
|
||||
case 1:
|
||||
@@ -274,17 +268,19 @@ static void InitLinkTestBG(u8 paletteNum, u8 bgNum, u8 screenBaseBlock, u8 charB
|
||||
SetGpuReg(REG_OFFSET_BG0VOFS + bgNum * 4, 0);
|
||||
}
|
||||
|
||||
void sub_80094EC(u8 paletteNum, u8 bgNum, u8 screenBaseBlock, u8 charBaseBlock)
|
||||
// Unused
|
||||
static void LoadLinkTestBgGfx(u8 paletteNum, u8 bgNum, u8 screenBaseBlock, u8 charBaseBlock)
|
||||
{
|
||||
LoadPalette(sLinkTestDigitsPal, paletteNum * 16, 0x20);
|
||||
DmaCopy16(3, sLinkTestDigitsGfx, (u16 *)BG_CHAR_ADDR(charBaseBlock), sizeof sLinkTestDigitsGfx);
|
||||
gLinkTestBGInfo.screenBaseBlock = screenBaseBlock;
|
||||
gLinkTestBGInfo.paletteNum = paletteNum;
|
||||
gLinkTestBGInfo.dummy_8 = 0;
|
||||
gLinkTestBGInfo.baseChar = 0;
|
||||
SetGpuReg(sBGControlRegs[bgNum], BGCNT_SCREENBASE(screenBaseBlock) | BGCNT_CHARBASE(charBaseBlock));
|
||||
}
|
||||
|
||||
void LinkTestScreen(void)
|
||||
// Unused
|
||||
static void LinkTestScreen(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
@@ -346,10 +342,9 @@ static void InitLink(void)
|
||||
int i;
|
||||
|
||||
for (i = 0; i < CMD_LENGTH; i++)
|
||||
{
|
||||
gSendCmd[i] = 0xEfff;
|
||||
}
|
||||
gLinkOpen = TRUE;
|
||||
gSendCmd[i] = LINKCMD_NONE;
|
||||
|
||||
sLinkOpen = TRUE;
|
||||
EnableSerial();
|
||||
}
|
||||
|
||||
@@ -402,7 +397,7 @@ void CloseLink(void)
|
||||
{
|
||||
LinkRfu_Shutdown();
|
||||
}
|
||||
gLinkOpen = FALSE;
|
||||
sLinkOpen = FALSE;
|
||||
DisableSerial();
|
||||
}
|
||||
|
||||
@@ -413,14 +408,14 @@ static void TestBlockTransfer(u8 nothing, u8 is, u8 used)
|
||||
|
||||
if (sLinkTestLastBlockSendPos != sBlockSend.pos)
|
||||
{
|
||||
LinkTest_prnthex(sBlockSend.pos, 2, 3, 2);
|
||||
LinkTest_PrintHex(sBlockSend.pos, 2, 3, 2);
|
||||
sLinkTestLastBlockSendPos = sBlockSend.pos;
|
||||
}
|
||||
for (i = 0; i < MAX_LINK_PLAYERS; i++)
|
||||
{
|
||||
if (sLinkTestLastBlockRecvPos[i] != sBlockRecv[i].pos)
|
||||
{
|
||||
LinkTest_prnthex(sBlockRecv[i].pos, 2, i + 4, 2);
|
||||
LinkTest_PrintHex(sBlockRecv[i].pos, 2, i + 4, 2);
|
||||
sLinkTestLastBlockRecvPos[i] = sBlockRecv[i].pos;
|
||||
}
|
||||
}
|
||||
@@ -435,8 +430,8 @@ static void TestBlockTransfer(u8 nothing, u8 is, u8 used)
|
||||
ResetBlockReceivedFlag(i);
|
||||
if (gLinkTestBlockChecksums[i] != 0x0342)
|
||||
{
|
||||
gLinkTestDebugValuesEnabled = FALSE;
|
||||
gUnknown_020223BD = FALSE;
|
||||
sLinkTestDebugValuesEnabled = FALSE;
|
||||
sDummyFlag = FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -469,7 +464,7 @@ static void LinkTestProcessKeyInput(void)
|
||||
{
|
||||
SetCloseLinkCallback();
|
||||
}
|
||||
if (gLinkTestDebugValuesEnabled)
|
||||
if (sLinkTestDebugValuesEnabled)
|
||||
{
|
||||
SetLinkDebugValues(gMain.vblankCounter2, gLinkCallback ? gLinkVSyncDisabled : gLinkVSyncDisabled | 0x10);
|
||||
}
|
||||
@@ -489,7 +484,7 @@ u16 LinkMain2(const u16 *heldKeys)
|
||||
{
|
||||
u8 i;
|
||||
|
||||
if (!gLinkOpen)
|
||||
if (!sLinkOpen)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@@ -555,10 +550,10 @@ static void ProcessRecvCmds(u8 unused)
|
||||
case LINKCMD_BLENDER_SEND_KEYS:
|
||||
gLinkPartnersHeldKeys[i] = gRecvCmds[i][1];
|
||||
break;
|
||||
case LINKCMD_0x5555:
|
||||
case LINKCMD_DUMMY_1:
|
||||
gLinkDummy2 = TRUE;
|
||||
break;
|
||||
case LINKCMD_0x5566:
|
||||
case LINKCMD_DUMMY_2:
|
||||
gLinkDummy2 = TRUE;
|
||||
break;
|
||||
case LINKCMD_INIT_BLOCK:
|
||||
@@ -612,7 +607,7 @@ static void ProcessRecvCmds(u8 unused)
|
||||
linkPlayer->neverRead = 0;
|
||||
linkPlayer->progressFlags = 0;
|
||||
}
|
||||
sub_800B524(linkPlayer);
|
||||
ConvertLinkPlayerName(linkPlayer);
|
||||
if (strcmp(block->magic1, sASCIIGameFreakInc) != 0
|
||||
|| strcmp(block->magic2, sASCIIGameFreakInc) != 0)
|
||||
{
|
||||
@@ -664,22 +659,19 @@ static void BuildSendCmd(u16 command)
|
||||
gSendCmd[0] = LINKCMD_BLENDER_SEND_KEYS;
|
||||
gSendCmd[1] = gMain.heldKeys;
|
||||
break;
|
||||
case LINKCMD_0x5555:
|
||||
gSendCmd[0] = LINKCMD_0x5555;
|
||||
case LINKCMD_DUMMY_1:
|
||||
gSendCmd[0] = LINKCMD_DUMMY_1;
|
||||
break;
|
||||
case LINKCMD_0x6666:
|
||||
gSendCmd[0] = LINKCMD_0x6666;
|
||||
case LINKCMD_SEND_EMPTY:
|
||||
gSendCmd[0] = LINKCMD_SEND_EMPTY;
|
||||
gSendCmd[1] = 0;
|
||||
break;
|
||||
case LINKCMD_0x7777:
|
||||
case LINKCMD_SEND_0xEE:
|
||||
{
|
||||
u8 i;
|
||||
|
||||
gSendCmd[0] = LINKCMD_0x7777;
|
||||
gSendCmd[0] = LINKCMD_SEND_0xEE;
|
||||
for (i = 0; i < 5; i++)
|
||||
{
|
||||
gSendCmd[i + 1] = 0xEE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case LINKCMD_INIT_BLOCK:
|
||||
@@ -690,8 +682,8 @@ static void BuildSendCmd(u16 command)
|
||||
case LINKCMD_BLENDER_NO_PBLOCK_SPACE:
|
||||
gSendCmd[0] = LINKCMD_BLENDER_NO_PBLOCK_SPACE;
|
||||
break;
|
||||
case LINKCMD_0xAAAB:
|
||||
gSendCmd[0] = LINKCMD_0xAAAB;
|
||||
case LINKCMD_SEND_ITEM:
|
||||
gSendCmd[0] = LINKCMD_SEND_ITEM;
|
||||
gSendCmd[1] = gSpecialVar_ItemId;
|
||||
break;
|
||||
case LINKCMD_SEND_BLOCK_REQ:
|
||||
@@ -702,14 +694,13 @@ static void BuildSendCmd(u16 command)
|
||||
gSendCmd[0] = LINKCMD_READY_CLOSE_LINK;
|
||||
gSendCmd[1] = gReadyCloseLinkType;
|
||||
break;
|
||||
case LINKCMD_0x5566:
|
||||
gSendCmd[0] = LINKCMD_0x5566;
|
||||
case LINKCMD_DUMMY_2:
|
||||
gSendCmd[0] = LINKCMD_DUMMY_2;
|
||||
break;
|
||||
case LINKCMD_SEND_HELD_KEYS:
|
||||
if (gHeldKeyCodeToSend == 0 || gLinkTransferringData)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
gSendCmd[0] = LINKCMD_SEND_HELD_KEYS;
|
||||
gSendCmd[1] = gHeldKeyCodeToSend;
|
||||
break;
|
||||
@@ -819,7 +810,7 @@ bool32 Link_AnyPartnersPlayingFRLG_JP(void)
|
||||
void OpenLinkTimed(void)
|
||||
{
|
||||
sPlayerDataExchangeStatus = EXCHANGE_NOT_STARTED;
|
||||
gLinkTimeOutCounter = 0;
|
||||
sTimeOutCounter = 0;
|
||||
OpenLink();
|
||||
}
|
||||
|
||||
@@ -892,7 +883,7 @@ u8 GetLinkPlayerDataExchangeStatusTimed(int minPlayers, int maxPlayers)
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (++gLinkTimeOutCounter > 600)
|
||||
else if (++sTimeOutCounter > 600)
|
||||
{
|
||||
sPlayerDataExchangeStatus = EXCHANGE_TIMED_OUT;
|
||||
}
|
||||
@@ -909,9 +900,7 @@ bool8 IsLinkPlayerDataExchangeComplete(void)
|
||||
for (i = 0; i < GetLinkPlayerCount(); i++)
|
||||
{
|
||||
if (gLinkPlayers[i].linkType == gLinkPlayers[0].linkType)
|
||||
{
|
||||
count++;
|
||||
}
|
||||
}
|
||||
if (count == GetLinkPlayerCount())
|
||||
{
|
||||
@@ -936,9 +925,7 @@ void ResetLinkPlayers(void)
|
||||
int i;
|
||||
|
||||
for (i = 0; i <= MAX_LINK_PLAYERS; i++)
|
||||
{
|
||||
gLinkPlayers[i] = (struct LinkPlayer){};
|
||||
}
|
||||
}
|
||||
|
||||
static void ResetBlockSend(void)
|
||||
@@ -966,9 +953,8 @@ static bool32 InitBlockSend(const void *src, size_t size)
|
||||
else
|
||||
{
|
||||
if (src != gBlockSendBuffer)
|
||||
{
|
||||
memcpy(gBlockSendBuffer, src, size);
|
||||
}
|
||||
|
||||
sBlockSend.src = gBlockSendBuffer;
|
||||
}
|
||||
BuildSendCmd(LINKCMD_INIT_BLOCK);
|
||||
@@ -980,9 +966,7 @@ static bool32 InitBlockSend(const void *src, size_t size)
|
||||
static void LinkCB_BlockSendBegin(void)
|
||||
{
|
||||
if (++sBlockSendDelayCounter > 2)
|
||||
{
|
||||
gLinkCallback = LinkCB_BlockSend;
|
||||
}
|
||||
}
|
||||
|
||||
static void LinkCB_BlockSend(void)
|
||||
@@ -1020,13 +1004,9 @@ void SetBerryBlenderLinkCallback(void)
|
||||
{
|
||||
gBerryBlenderKeySendAttempts = 0;
|
||||
if (gWirelessCommType)
|
||||
{
|
||||
Rfu_SetBerryBlenderLinkCallback();
|
||||
}
|
||||
else
|
||||
{
|
||||
gLinkCallback = LinkCB_BerryBlenderSendHeldKeys;
|
||||
}
|
||||
}
|
||||
|
||||
// Unused
|
||||
@@ -1044,9 +1024,8 @@ static void SendBerryBlenderNoSpaceForPokeblocks(void)
|
||||
u8 GetMultiplayerId(void)
|
||||
{
|
||||
if (gWirelessCommType == TRUE)
|
||||
{
|
||||
return Rfu_GetMultiplayerId();
|
||||
}
|
||||
|
||||
return SIO_MULTI_CNT->id;
|
||||
}
|
||||
|
||||
@@ -1061,18 +1040,16 @@ u8 bitmask_all_link_players_but_self(void)
|
||||
bool8 SendBlock(u8 unused, const void *src, u16 size)
|
||||
{
|
||||
if (gWirelessCommType == TRUE)
|
||||
{
|
||||
return Rfu_InitBlockSend(src, size);
|
||||
}
|
||||
|
||||
return InitBlockSend(src, size);
|
||||
}
|
||||
|
||||
bool8 SendBlockRequest(u8 blockReqType)
|
||||
{
|
||||
if (gWirelessCommType == TRUE)
|
||||
{
|
||||
return Rfu_SendBlockRequest(blockReqType);
|
||||
}
|
||||
|
||||
if (gLinkCallback == NULL)
|
||||
{
|
||||
gBlockRequestType = blockReqType;
|
||||
@@ -1085,31 +1062,25 @@ bool8 SendBlockRequest(u8 blockReqType)
|
||||
bool8 IsLinkTaskFinished(void)
|
||||
{
|
||||
if (gWirelessCommType == TRUE)
|
||||
{
|
||||
return IsLinkRfuTaskFinished();
|
||||
}
|
||||
|
||||
return gLinkCallback == NULL;
|
||||
}
|
||||
|
||||
u8 GetBlockReceivedStatus(void)
|
||||
{
|
||||
if (gWirelessCommType == TRUE)
|
||||
{
|
||||
return Rfu_GetBlockReceivedStatus();
|
||||
}
|
||||
|
||||
return (gBlockReceivedStatus[3] << 3) | (gBlockReceivedStatus[2] << 2) | (gBlockReceivedStatus[1] << 1) | (gBlockReceivedStatus[0] << 0);
|
||||
}
|
||||
|
||||
static void SetBlockReceivedFlag(u8 who)
|
||||
{
|
||||
if (gWirelessCommType == TRUE)
|
||||
{
|
||||
Rfu_SetBlockReceivedFlag(who);
|
||||
}
|
||||
else
|
||||
{
|
||||
gBlockReceivedStatus[who] = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
void ResetBlockReceivedFlags(void)
|
||||
@@ -1119,16 +1090,12 @@ void ResetBlockReceivedFlags(void)
|
||||
if (gWirelessCommType == TRUE)
|
||||
{
|
||||
for (i = 0; i < MAX_RFU_PLAYERS; i++)
|
||||
{
|
||||
Rfu_ResetBlockReceivedFlag(i);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (i = 0; i < MAX_LINK_PLAYERS; i++)
|
||||
{
|
||||
gBlockReceivedStatus[i] = FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1147,9 +1114,7 @@ void ResetBlockReceivedFlag(u8 who)
|
||||
void CheckShouldAdvanceLinkState(void)
|
||||
{
|
||||
if ((gLinkStatus & LINK_STAT_MASTER) && EXTRACT_PLAYER_COUNT(gLinkStatus) > 1)
|
||||
{
|
||||
gShouldAdvanceLinkState = 1;
|
||||
}
|
||||
}
|
||||
|
||||
static u16 LinkTestCalcBlockChecksum(const u16 *src, u16 size)
|
||||
@@ -1159,92 +1124,90 @@ static u16 LinkTestCalcBlockChecksum(const u16 *src, u16 size)
|
||||
|
||||
chksum = 0;
|
||||
for (i = 0; i < size / 2; i++)
|
||||
{
|
||||
chksum += src[i];
|
||||
}
|
||||
|
||||
return chksum;
|
||||
}
|
||||
|
||||
static void LinkTest_prnthexchar(char a0, u8 a1, u8 a2)
|
||||
static void LinkTest_PrintNumChar(char val, u8 x, u8 y)
|
||||
{
|
||||
u16 *vAddr;
|
||||
|
||||
vAddr = (u16 *)BG_SCREEN_ADDR(gLinkTestBGInfo.screenBaseBlock);
|
||||
vAddr[a2 * 32 + a1] = (gLinkTestBGInfo.paletteNum << 12) | (a0 + 1 + gLinkTestBGInfo.dummy_8);
|
||||
vAddr[y * 32 + x] = (gLinkTestBGInfo.paletteNum << 12) | (val + 1 + gLinkTestBGInfo.baseChar);
|
||||
}
|
||||
|
||||
static void LinkTest_prntchar(char a0, u8 a1, u8 a2)
|
||||
static void LinkTest_PrintChar(char val, u8 x, u8 y)
|
||||
{
|
||||
u16 *vAddr;
|
||||
|
||||
vAddr = (u16 *)BG_SCREEN_ADDR(gLinkTestBGInfo.screenBaseBlock);
|
||||
vAddr[a2 * 32 + a1] = (gLinkTestBGInfo.paletteNum << 12) | (a0 + gLinkTestBGInfo.dummy_8);
|
||||
vAddr[y * 32 + x] = (gLinkTestBGInfo.paletteNum << 12) | (val + gLinkTestBGInfo.baseChar);
|
||||
}
|
||||
|
||||
static void LinkTest_prnthex(u32 pos, u8 a0, u8 a1, u8 a2)
|
||||
static void LinkTest_PrintHex(u32 num, u8 x, u8 y, u8 length)
|
||||
{
|
||||
char sp[32 / 2];
|
||||
char buff[16];
|
||||
int i;
|
||||
|
||||
for (i = 0; i < a2; i++)
|
||||
for (i = 0; i < length; i++)
|
||||
{
|
||||
sp[i] = pos & 0xf;
|
||||
pos >>= 4;
|
||||
buff[i] = num & 0xF;
|
||||
num >>= 4;
|
||||
}
|
||||
for (i = a2 - 1; i >= 0; i--)
|
||||
for (i = length - 1; i >= 0; i--)
|
||||
{
|
||||
LinkTest_prnthexchar(sp[i], a0, a1);
|
||||
a0++;
|
||||
LinkTest_PrintNumChar(buff[i], x, y);
|
||||
x++;
|
||||
}
|
||||
}
|
||||
|
||||
static void LinkTest_prntint(int a0, u8 a1, u8 a2, u8 a3)
|
||||
static void LinkTest_PrintInt(int num, u8 x, u8 y, u8 length)
|
||||
{
|
||||
char sp[32 / 2];
|
||||
int sp10;
|
||||
char buff[16];
|
||||
int negX;
|
||||
int i;
|
||||
|
||||
sp10 = -1;
|
||||
if (a0 < 0)
|
||||
negX = -1;
|
||||
if (num < 0)
|
||||
{
|
||||
sp10 = a1;
|
||||
a0 = -a0;
|
||||
negX = x;
|
||||
num = -num;
|
||||
}
|
||||
for (i = 0; i < a3; i++)
|
||||
for (i = 0; i < length; i++)
|
||||
{
|
||||
sp[i] = a0 % 10;
|
||||
a0 /= 10;
|
||||
buff[i] = num % 10;
|
||||
num /= 10;
|
||||
}
|
||||
for (i = a3 - 1; i >= 0; i--)
|
||||
for (i = length - 1; i >= 0; i--)
|
||||
{
|
||||
LinkTest_prnthexchar(sp[i], a1, a2);
|
||||
a1++;
|
||||
}
|
||||
if (sp10 != -1)
|
||||
{
|
||||
LinkTest_prnthexchar(*"\n", sp10, a2);
|
||||
LinkTest_PrintNumChar(buff[i], x, y);
|
||||
x++;
|
||||
}
|
||||
|
||||
if (negX != -1)
|
||||
LinkTest_PrintNumChar(*"\n", negX, y);
|
||||
}
|
||||
|
||||
static void LinkTest_prntstr(const char *a0, u8 a1, u8 a2)
|
||||
static void LinkTest_PrintString(const char *str, u8 x, u8 y)
|
||||
{
|
||||
int r6;
|
||||
int xOffset;
|
||||
int i;
|
||||
int r5;
|
||||
int yOffset;
|
||||
|
||||
r5 = 0;
|
||||
r6 = 0;
|
||||
for (i = 0; a0[i] != 0; a0++)
|
||||
yOffset = 0;
|
||||
xOffset = 0;
|
||||
for (i = 0; str[i] != 0; str++)
|
||||
{
|
||||
if (a0[i] == *"\n")
|
||||
if (str[i] == *"\n")
|
||||
{
|
||||
r5++;
|
||||
r6 = 0;
|
||||
yOffset++;
|
||||
xOffset = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
LinkTest_prntchar(a0[i], a1 + r6, a2 + r5);
|
||||
r6++;
|
||||
LinkTest_PrintChar(str[i], x + xOffset, y + yOffset);
|
||||
xOffset++;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1260,29 +1223,28 @@ static void LinkCB_RequestPlayerDataExchange(void)
|
||||
|
||||
static void Task_PrintTestData(u8 taskId)
|
||||
{
|
||||
char sp[32];
|
||||
char testTitle[32];
|
||||
int i;
|
||||
|
||||
strcpy(sp, sASCIITestPrint);
|
||||
LinkTest_prntstr(sp, 5, 2);
|
||||
LinkTest_prnthex(gShouldAdvanceLinkState, 2, 1, 2);
|
||||
LinkTest_prnthex(gLinkStatus, 15, 1, 8);
|
||||
LinkTest_prnthex(gLink.state, 2, 10, 2);
|
||||
LinkTest_prnthex(EXTRACT_PLAYER_COUNT(gLinkStatus), 15, 10, 2);
|
||||
LinkTest_prnthex(GetMultiplayerId(), 15, 12, 2);
|
||||
LinkTest_prnthex(gLastSendQueueCount, 25, 1, 2);
|
||||
LinkTest_prnthex(gLastRecvQueueCount, 25, 2, 2);
|
||||
LinkTest_prnthex(GetBlockReceivedStatus(), 15, 5, 2);
|
||||
LinkTest_prnthex(gLinkDebugSeed, 2, 12, 8);
|
||||
LinkTest_prnthex(gLinkDebugFlags, 2, 13, 8);
|
||||
LinkTest_prnthex(GetSioMultiSI(), 25, 5, 1);
|
||||
LinkTest_prnthex(IsSioMultiMaster(), 25, 6, 1);
|
||||
LinkTest_prnthex(IsLinkConnectionEstablished(), 25, 7, 1);
|
||||
LinkTest_prnthex(HasLinkErrorOccurred(), 25, 8, 1);
|
||||
strcpy(testTitle, sASCIITestPrint);
|
||||
LinkTest_PrintString(testTitle, 5, 2);
|
||||
LinkTest_PrintHex(gShouldAdvanceLinkState, 2, 1, 2);
|
||||
LinkTest_PrintHex(gLinkStatus, 15, 1, 8);
|
||||
LinkTest_PrintHex(gLink.state, 2, 10, 2);
|
||||
LinkTest_PrintHex(EXTRACT_PLAYER_COUNT(gLinkStatus), 15, 10, 2);
|
||||
LinkTest_PrintHex(GetMultiplayerId(), 15, 12, 2);
|
||||
LinkTest_PrintHex(gLastSendQueueCount, 25, 1, 2);
|
||||
LinkTest_PrintHex(gLastRecvQueueCount, 25, 2, 2);
|
||||
LinkTest_PrintHex(GetBlockReceivedStatus(), 15, 5, 2);
|
||||
LinkTest_PrintHex(gLinkDebugSeed, 2, 12, 8);
|
||||
LinkTest_PrintHex(gLinkDebugFlags, 2, 13, 8);
|
||||
LinkTest_PrintHex(GetSioMultiSI(), 25, 5, 1);
|
||||
LinkTest_PrintHex(IsSioMultiMaster(), 25, 6, 1);
|
||||
LinkTest_PrintHex(IsLinkConnectionEstablished(), 25, 7, 1);
|
||||
LinkTest_PrintHex(HasLinkErrorOccurred(), 25, 8, 1);
|
||||
|
||||
for (i = 0; i < MAX_LINK_PLAYERS; i++)
|
||||
{
|
||||
LinkTest_prnthex(gLinkTestBlockChecksums[i], 10, 4 + i, 4);
|
||||
}
|
||||
LinkTest_PrintHex(gLinkTestBlockChecksums[i], 10, 4 + i, 4);
|
||||
}
|
||||
|
||||
void SetLinkDebugValues(u32 seed, u32 flags)
|
||||
@@ -1298,9 +1260,8 @@ u8 GetSavedLinkPlayerCountAsBitFlags(void)
|
||||
|
||||
flags = 0;
|
||||
for (i = 0; i < gSavedLinkPlayerCount; i++)
|
||||
{
|
||||
flags |= (1 << i);
|
||||
}
|
||||
|
||||
return flags;
|
||||
}
|
||||
|
||||
@@ -1311,9 +1272,8 @@ u8 GetLinkPlayerCountAsBitFlags(void)
|
||||
|
||||
flags = 0;
|
||||
for (i = 0; i < GetLinkPlayerCount(); i++)
|
||||
{
|
||||
flags |= (1 << i);
|
||||
}
|
||||
|
||||
return flags;
|
||||
}
|
||||
|
||||
@@ -1324,9 +1284,7 @@ void SaveLinkPlayers(u8 playerCount)
|
||||
gSavedLinkPlayerCount = playerCount;
|
||||
gSavedMultiplayerId = GetMultiplayerId();
|
||||
for (i = 0; i < MAX_RFU_PLAYERS; i++)
|
||||
{
|
||||
gSavedLinkPlayers[i] = gLinkPlayers[i];
|
||||
}
|
||||
sSavedLinkPlayers[i] = gLinkPlayers[i];
|
||||
}
|
||||
|
||||
// The number of players when trading began. This is frequently compared against the
|
||||
@@ -1349,7 +1307,7 @@ bool8 DoesLinkPlayerCountMatchSaved(void)
|
||||
|
||||
for (i = 0; i < gSavedLinkPlayerCount; i++)
|
||||
{
|
||||
if (gLinkPlayers[i].trainerId == gSavedLinkPlayers[i].trainerId)
|
||||
if (gLinkPlayers[i].trainerId == sSavedLinkPlayers[i].trainerId)
|
||||
{
|
||||
if (gLinkType == LINKTYPE_BATTLE_TOWER)
|
||||
{
|
||||
@@ -1375,12 +1333,15 @@ bool8 DoesLinkPlayerCountMatchSaved(void)
|
||||
void ClearSavedLinkPlayers(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
// Clearly not what was meant to be written, but here it is anyway.
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
CpuSet(&gSavedLinkPlayers[i], NULL, sizeof(struct LinkPlayer));
|
||||
}
|
||||
// The CpuSet loop below is incorrectly writing to NULL
|
||||
// instead of sSavedLinkPlayers.
|
||||
// Additionally it's using the wrong array size.
|
||||
#ifdef UBFIX
|
||||
memset(sSavedLinkPlayers, 0, sizeof(sSavedLinkPlayers));
|
||||
#else
|
||||
for (i = 0; i < MAX_LINK_PLAYERS; i++)
|
||||
CpuSet(&sSavedLinkPlayers[i], NULL, sizeof(struct LinkPlayer));
|
||||
#endif
|
||||
}
|
||||
|
||||
void CheckLinkPlayersMatchSaved(void)
|
||||
@@ -1389,8 +1350,8 @@ void CheckLinkPlayersMatchSaved(void)
|
||||
|
||||
for (i = 0; i < gSavedLinkPlayerCount; i++)
|
||||
{
|
||||
if (gSavedLinkPlayers[i].trainerId != gLinkPlayers[i].trainerId
|
||||
|| StringCompare(gSavedLinkPlayers[i].name, gLinkPlayers[i].name) != 0)
|
||||
if (sSavedLinkPlayers[i].trainerId != gLinkPlayers[i].trainerId
|
||||
|| StringCompare(sSavedLinkPlayers[i].name, gLinkPlayers[i].name) != 0)
|
||||
{
|
||||
gLinkErrorOccurred = TRUE;
|
||||
CloseLink();
|
||||
@@ -1413,9 +1374,8 @@ u8 GetLinkPlayerCount_2(void)
|
||||
bool8 IsLinkMaster(void)
|
||||
{
|
||||
if (gWirelessCommType)
|
||||
{
|
||||
return Rfu_IsMaster();
|
||||
}
|
||||
|
||||
return EXTRACT_MASTER(gLinkStatus);
|
||||
}
|
||||
|
||||
@@ -1568,9 +1528,8 @@ void SetLinkStandbyCallback(void)
|
||||
else
|
||||
{
|
||||
if (gLinkCallback == NULL)
|
||||
{
|
||||
gLinkCallback = LinkCB_Standby;
|
||||
}
|
||||
|
||||
gLinkDummy1 = FALSE;
|
||||
}
|
||||
}
|
||||
@@ -1606,7 +1565,7 @@ static void LinkCB_StandbyForAll(void)
|
||||
|
||||
static void CheckErrorStatus(void)
|
||||
{
|
||||
if (gLinkOpen && EXTRACT_LINK_ERRORS(gLinkStatus))
|
||||
if (sLinkOpen && EXTRACT_LINK_ERRORS(gLinkStatus))
|
||||
{
|
||||
if (!gSuppressLinkErrorMessage)
|
||||
{
|
||||
@@ -1620,12 +1579,12 @@ static void CheckErrorStatus(void)
|
||||
}
|
||||
}
|
||||
|
||||
void BufferLinkErrorInfo(u32 status, u8 lastSendQueueCount, u8 lastRecvQueueCount, bool8 unk_06)
|
||||
void BufferLinkErrorInfo(u32 status, u8 lastSendQueueCount, u8 lastRecvQueueCount, bool8 disconnected)
|
||||
{
|
||||
sLinkErrorBuffer.status = status;
|
||||
sLinkErrorBuffer.lastSendQueueCount = lastSendQueueCount;
|
||||
sLinkErrorBuffer.lastRecvQueueCount = lastRecvQueueCount;
|
||||
sLinkErrorBuffer.unk_06 = unk_06;
|
||||
sLinkErrorBuffer.disconnected = disconnected;
|
||||
}
|
||||
|
||||
void CB2_LinkError(void)
|
||||
@@ -1645,16 +1604,15 @@ void CB2_LinkError(void)
|
||||
ScanlineEffect_Stop();
|
||||
if (gWirelessCommType)
|
||||
{
|
||||
if (!sLinkErrorBuffer.unk_06)
|
||||
{
|
||||
if (!sLinkErrorBuffer.disconnected)
|
||||
gWirelessCommType = 3;
|
||||
}
|
||||
|
||||
ResetLinkRfuGFLayer();
|
||||
}
|
||||
SetVBlankCallback(VBlankCB_LinkError);
|
||||
ResetBgsAndClearDma3BusyFlags(0);
|
||||
InitBgsFromTemplates(0, sLinkErrorBgTemplates, ARRAY_COUNT(sLinkErrorBgTemplates));
|
||||
sLinkErrorBgTilemapBuffer = tilemapBuffer = malloc(0x800);
|
||||
sLinkErrorBgTilemapBuffer = tilemapBuffer = malloc(BG_SCREEN_SIZE);
|
||||
SetBgTilemapBuffer(1, tilemapBuffer);
|
||||
if (InitWindows(sLinkErrorWindowTemplates))
|
||||
{
|
||||
@@ -1680,9 +1638,9 @@ void CB2_LinkError(void)
|
||||
}
|
||||
}
|
||||
|
||||
static void sub_800B080(void)
|
||||
static void ErrorMsg_MoveCloserToPartner(void)
|
||||
{
|
||||
LoadBgTiles(0, s2BlankTilesGfx, 0x20, 0);
|
||||
LoadBgTiles(0, sCommErrorBg_Gfx, 0x20, 0);
|
||||
DecompressAndLoadBgGfxUsingHeap(1, sWirelessLinkDisplayGfx, FALSE, 0, 0);
|
||||
CopyToBgTilemapBuffer(1, sWirelessLinkDisplayTilemap, 0, 0);
|
||||
CopyBgTilemapBufferToVram(1);
|
||||
@@ -1697,9 +1655,9 @@ static void sub_800B080(void)
|
||||
CopyWindowToVram(2, 3);
|
||||
}
|
||||
|
||||
static void sub_800B138(void)
|
||||
static void ErrorMsg_CheckConnections(void)
|
||||
{
|
||||
LoadBgTiles(0, s2BlankTilesGfx, 0x20, 0);
|
||||
LoadBgTiles(0, sCommErrorBg_Gfx, 0x20, 0);
|
||||
FillWindowPixelBuffer(1, PIXEL_FILL(0));
|
||||
FillWindowPixelBuffer(2, PIXEL_FILL(0));
|
||||
AddTextPrinterParameterized3(1, 3, 2, 0, sTextColors, 0, gText_CommErrorCheckConnections);
|
||||
@@ -1714,21 +1672,17 @@ static void CB2_PrintErrorMessage(void)
|
||||
switch (gMain.state)
|
||||
{
|
||||
case 00:
|
||||
if (sLinkErrorBuffer.unk_06)
|
||||
{
|
||||
sub_800B080();
|
||||
}
|
||||
// Below is only true for the RFU, so the other error
|
||||
// type is inferred to be from a wired connection
|
||||
if (sLinkErrorBuffer.disconnected)
|
||||
ErrorMsg_MoveCloserToPartner();
|
||||
else
|
||||
{
|
||||
sub_800B138();
|
||||
}
|
||||
ErrorMsg_CheckConnections();
|
||||
break;
|
||||
case 02:
|
||||
ShowBg(0);
|
||||
if (sLinkErrorBuffer.unk_06)
|
||||
{
|
||||
if (sLinkErrorBuffer.disconnected)
|
||||
ShowBg(1);
|
||||
}
|
||||
break;
|
||||
case 30:
|
||||
PlaySE(SE_BOO);
|
||||
@@ -1741,13 +1695,9 @@ static void CB2_PrintErrorMessage(void)
|
||||
break;
|
||||
case 130:
|
||||
if (gWirelessCommType == 2)
|
||||
{
|
||||
AddTextPrinterParameterized3(0, 3, 2, 20, sTextColors, 0, gText_ABtnTitleScreen);
|
||||
}
|
||||
else if (gWirelessCommType == 1)
|
||||
{
|
||||
AddTextPrinterParameterized3(0, 3, 2, 20, sTextColors, 0, gText_ABtnRegistrationCounter);
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (gMain.state == 160)
|
||||
@@ -1758,7 +1708,7 @@ static void CB2_PrintErrorMessage(void)
|
||||
{
|
||||
PlaySE(SE_PIN);
|
||||
gWirelessCommType = 0;
|
||||
sLinkErrorBuffer.unk_06 = 0;
|
||||
sLinkErrorBuffer.disconnected = FALSE;
|
||||
sub_81700F8();
|
||||
}
|
||||
}
|
||||
@@ -1772,10 +1722,9 @@ static void CB2_PrintErrorMessage(void)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (gMain.state != 160)
|
||||
{
|
||||
gMain.state++;
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: there might be a file boundary here, let's name it
|
||||
@@ -1805,7 +1754,7 @@ bool8 HasLinkErrorOccurred(void)
|
||||
return gLinkErrorOccurred;
|
||||
}
|
||||
|
||||
void sub_800B348(void)
|
||||
void LocalLinkPlayerToBlock(void)
|
||||
{
|
||||
struct LinkPlayerBlock *block;
|
||||
|
||||
@@ -1826,11 +1775,11 @@ void LinkPlayerFromBlock(u32 who)
|
||||
block = (struct LinkPlayerBlock *)gBlockRecvBuffer[who_];
|
||||
player = &gLinkPlayers[who_];
|
||||
*player = block->linkPlayer;
|
||||
sub_800B524(player);
|
||||
if (strcmp(block->magic1, sASCIIGameFreakInc) != 0 || strcmp(block->magic2, sASCIIGameFreakInc) != 0)
|
||||
{
|
||||
ConvertLinkPlayerName(player);
|
||||
|
||||
if (strcmp(block->magic1, sASCIIGameFreakInc) != 0
|
||||
|| strcmp(block->magic2, sASCIIGameFreakInc) != 0)
|
||||
SetMainCallback2(CB2_LinkError);
|
||||
}
|
||||
}
|
||||
|
||||
bool8 HandleLinkConnection(void)
|
||||
@@ -1842,21 +1791,17 @@ bool8 HandleLinkConnection(void)
|
||||
{
|
||||
gLinkStatus = LinkMain1(&gShouldAdvanceLinkState, gSendCmd, gRecvCmds);
|
||||
LinkMain2(&gMain.heldKeys);
|
||||
if ((gLinkStatus & LINK_STAT_RECEIVED_NOTHING) && sub_808766C() == TRUE)
|
||||
{
|
||||
if ((gLinkStatus & LINK_STAT_RECEIVED_NOTHING) && IsSendingKeysOverCable() == TRUE)
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
r4 = sub_8010EC0();
|
||||
r5 = sub_8010F1C();
|
||||
if (sub_808766C() == TRUE)
|
||||
if (IsSendingKeysOverCable() == TRUE)
|
||||
{
|
||||
if (r4 == TRUE || IsRfuRecvQueueEmpty() || r5)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
@@ -1865,42 +1810,34 @@ bool8 HandleLinkConnection(void)
|
||||
void SetWirelessCommType1(void)
|
||||
{
|
||||
if (gReceivedRemoteLinkPlayers == 0)
|
||||
{
|
||||
gWirelessCommType = 1;
|
||||
}
|
||||
}
|
||||
|
||||
static void SetWirelessCommType0_Internal(void)
|
||||
{
|
||||
if (gReceivedRemoteLinkPlayers == 0)
|
||||
{
|
||||
gWirelessCommType = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void SetWirelessCommType0(void)
|
||||
{
|
||||
if (gReceivedRemoteLinkPlayers == 0)
|
||||
{
|
||||
gWirelessCommType = 0;
|
||||
}
|
||||
}
|
||||
|
||||
u32 GetLinkRecvQueueLength(void)
|
||||
{
|
||||
if (gWirelessCommType != 0)
|
||||
{
|
||||
return GetRfuRecvQueueLength();
|
||||
}
|
||||
|
||||
return gLink.recvQueue.count;
|
||||
}
|
||||
|
||||
bool32 sub_800B504(void)
|
||||
bool32 IsLinkRecvQueueLengthAtLeast3(void)
|
||||
{
|
||||
if (GetLinkRecvQueueLength() > 2)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -1910,9 +1847,9 @@ u8 GetWirelessCommType(void)
|
||||
return gWirelessCommType;
|
||||
}
|
||||
|
||||
void sub_800B524(struct LinkPlayer *player)
|
||||
void ConvertLinkPlayerName(struct LinkPlayer *player)
|
||||
{
|
||||
player->progressFlagsCopy = player->progressFlags;
|
||||
player->progressFlagsCopy = player->progressFlags; // ? Perhaps relocating for a longer name field
|
||||
ConvertInternationalString(player->name, player->language);
|
||||
}
|
||||
|
||||
@@ -2420,9 +2357,7 @@ void ResetSendBuffer(void)
|
||||
for (i = 0; i < CMD_LENGTH; i++)
|
||||
{
|
||||
for (j = 0; j < QUEUE_CAPACITY; j++)
|
||||
{
|
||||
gLink.sendQueue.data[i][j] = 0xEFFF;
|
||||
}
|
||||
gLink.sendQueue.data[i][j] = LINKCMD_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2439,9 +2374,7 @@ void ResetRecvBuffer(void)
|
||||
for (j = 0; j < CMD_LENGTH; j++)
|
||||
{
|
||||
for (k = 0; k < QUEUE_CAPACITY; k++)
|
||||
{
|
||||
gLink.recvQueue.data[i][j][k] = 0xEFFF;
|
||||
}
|
||||
gLink.recvQueue.data[i][j][k] = LINKCMD_NONE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+5
-5
@@ -1697,7 +1697,7 @@ static void sub_801084C(u8 taskId)
|
||||
if (AreNoPlayersReceiving())
|
||||
{
|
||||
ResetBlockReceivedFlags();
|
||||
sub_800B348();
|
||||
LocalLinkPlayerToBlock();
|
||||
gTasks[taskId].data[0]++;
|
||||
}
|
||||
break;
|
||||
@@ -1786,7 +1786,7 @@ static void ReceiveRfuLinkPlayers(const struct SioInfo *sioInfo)
|
||||
for (i = 0; i < MAX_RFU_PLAYERS; i++)
|
||||
{
|
||||
gLinkPlayers[i] = sioInfo->linkPlayers[i];
|
||||
sub_800B524(gLinkPlayers + i);
|
||||
ConvertLinkPlayerName(gLinkPlayers + i);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1831,7 +1831,7 @@ static void Task_ExchangeLinkPlayers(u8 taskId)
|
||||
ResetBlockReceivedFlag(r4);
|
||||
r2 = (struct LinkPlayerBlock *)gBlockRecvBuffer[r4];
|
||||
gLinkPlayers[r4] = r2->linkPlayer;
|
||||
sub_800B524(gLinkPlayers + r4);
|
||||
ConvertLinkPlayerName(gLinkPlayers + r4);
|
||||
gTasks[taskId].data[0]++;
|
||||
}
|
||||
break;
|
||||
@@ -1887,7 +1887,7 @@ static void sub_8010D0C(u8 taskId)
|
||||
case 0:
|
||||
if (Rfu.playerCount)
|
||||
{
|
||||
sub_800B348();
|
||||
LocalLinkPlayerToBlock();
|
||||
SendBlock(0, gBlockSendBuffer, sizeof(struct LinkPlayerBlock));
|
||||
gTasks[taskId].data[0]++;
|
||||
}
|
||||
@@ -2472,7 +2472,7 @@ void RfuVSync(void)
|
||||
rfu_LMAN_syncVBlank();
|
||||
}
|
||||
|
||||
void sub_8011AC8(void)
|
||||
void ClearRecvCommands(void)
|
||||
{
|
||||
CpuFill32(0, gRecvCmds, sizeof(gRecvCmds));
|
||||
}
|
||||
|
||||
@@ -1616,6 +1616,9 @@ void ply_xcmd_0C(struct MusicPlayerInfo *mplayInfo, struct MusicPlayerTrack *tra
|
||||
void ply_xcmd_0D(struct MusicPlayerInfo *mplayInfo, struct MusicPlayerTrack *track)
|
||||
{
|
||||
u32 unk;
|
||||
#ifdef UBFIX
|
||||
unk = 0;
|
||||
#endif
|
||||
|
||||
READ_XCMD_BYTE(unk, 0) // UB: uninitialized variable
|
||||
READ_XCMD_BYTE(unk, 1)
|
||||
@@ -1657,18 +1660,12 @@ start_song:
|
||||
mplayInfo = &gPokemonCryMusicPlayers[i];
|
||||
mplayInfo->ident++;
|
||||
|
||||
#define CRY ((s32)&gPokemonCrySongs + i * sizeof(struct PokemonCrySong))
|
||||
#define CRY_OFS(field) offsetof(struct PokemonCrySong, field)
|
||||
gPokemonCrySongs[i] = gPokemonCrySong;
|
||||
|
||||
memcpy((void *)CRY, &gPokemonCrySong, sizeof(struct PokemonCrySong));
|
||||
|
||||
*(u32 *)(CRY + CRY_OFS(tone)) = (u32)tone;
|
||||
*(u32 *)(CRY + CRY_OFS(part)) = CRY + CRY_OFS(part0);
|
||||
*(u32 *)(CRY + CRY_OFS(part) + 4) = CRY + CRY_OFS(part1);
|
||||
*(u32 *)(CRY + CRY_OFS(gotoTarget)) = CRY + CRY_OFS(cont);
|
||||
|
||||
#undef CRY_OFS
|
||||
#undef CRY
|
||||
gPokemonCrySongs[i].tone = tone;
|
||||
gPokemonCrySongs[i].part[0] = &gPokemonCrySongs[i].part0;
|
||||
gPokemonCrySongs[i].part[1] = &gPokemonCrySongs[i].part1;
|
||||
gPokemonCrySongs[i].gotoTarget = (u32)&gPokemonCrySongs[i].cont;
|
||||
|
||||
mplayInfo->ident = ID_NUMBER;
|
||||
|
||||
|
||||
+1
-1
@@ -593,7 +593,7 @@ static bool8 MailReadBuildGraphics(void)
|
||||
}
|
||||
break;
|
||||
case 15:
|
||||
if (sub_8087598() == TRUE)
|
||||
if (Overworld_LinkRecvQueueLengthMoreThan2() == TRUE)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
+2
-2
@@ -132,7 +132,7 @@ void AgbMain()
|
||||
DoSoftReset();
|
||||
}
|
||||
|
||||
if (sub_8087634() == 1)
|
||||
if (Overworld_SendKeysToLinkIsRunning() == TRUE)
|
||||
{
|
||||
gLinkTransferringData = TRUE;
|
||||
UpdateLinkAndCallCallbacks();
|
||||
@@ -143,7 +143,7 @@ void AgbMain()
|
||||
gLinkTransferringData = FALSE;
|
||||
UpdateLinkAndCallCallbacks();
|
||||
|
||||
if (sub_80875C8() == 1)
|
||||
if (Overworld_RecvKeysFromLinkIsRunning() == TRUE)
|
||||
{
|
||||
gMain.newKeys = 0;
|
||||
ClearSpriteCopyRequests();
|
||||
|
||||
+30
-18
@@ -197,8 +197,8 @@ static const u8 * const gBattlePyramid_MapHeaderStrings[] =
|
||||
gText_Pyramid,
|
||||
};
|
||||
|
||||
// text
|
||||
bool8 sub_80D47D4(void)
|
||||
// Unused
|
||||
static bool8 StartMenu_ShowMapNamePopup(void)
|
||||
{
|
||||
HideStartMenu();
|
||||
ShowMapNamePopup();
|
||||
@@ -333,24 +333,36 @@ static void ShowMapNamePopUpWindow(void)
|
||||
CopyWindowToVram(GetMapNamePopUpWindowId(), 3);
|
||||
}
|
||||
|
||||
static void sub_80D4A78(u8 bg, u8 x, u8 y, u8 deltaX, u8 deltaY, u8 unused)
|
||||
#define TILE_TOP_EDGE_START 0x21D
|
||||
#define TILE_TOP_EDGE_END 0x228
|
||||
#define TILE_LEFT_EDGE_TOP 0x229
|
||||
#define TILE_RIGHT_EDGE_TOP 0x22A
|
||||
#define TILE_LEFT_EDGE_MID 0x22B
|
||||
#define TILE_RIGHT_EDGE_MID 0x22C
|
||||
#define TILE_LEFT_EDGE_BOT 0x22D
|
||||
#define TILE_RIGHT_EDGE_BOT 0x22E
|
||||
#define TILE_BOT_EDGE_START 0x22F
|
||||
#define TILE_BOT_EDGE_END 0x23A
|
||||
|
||||
static void DrawMapNamePopUpFrame(u8 bg, u8 x, u8 y, u8 deltaX, u8 deltaY, u8 unused)
|
||||
{
|
||||
s32 i;
|
||||
|
||||
for (i = 0; i < 12; i++)
|
||||
{
|
||||
FillBgTilemapBufferRect(bg, 0x21D + i, i - 1 + x, y - 1, 1, 1, 0xE);
|
||||
}
|
||||
FillBgTilemapBufferRect(bg, 0x229, x - 1, y, 1, 1, 0xE);
|
||||
FillBgTilemapBufferRect(bg, 0x22A, deltaX + x, y, 1, 1, 0xE);
|
||||
FillBgTilemapBufferRect(bg, 0x22B, x - 1, y + 1 , 1, 1, 0xE);
|
||||
FillBgTilemapBufferRect(bg, 0x22C, deltaX + x, y + 1, 1, 1, 0xE);
|
||||
FillBgTilemapBufferRect(bg, 0x22D, x - 1, y + 2, 1, 1, 0xE);
|
||||
FillBgTilemapBufferRect(bg, 0x22E, deltaX + x, y + 2, 1, 1, 0xE);
|
||||
for (i = 0; i < 12; i++)
|
||||
{
|
||||
FillBgTilemapBufferRect(bg, 0x22F + i, i - 1 + x, y + deltaY, 1, 1, 0xE);
|
||||
}
|
||||
// Draw top edge
|
||||
for (i = 0; i < 1 + TILE_TOP_EDGE_END - TILE_TOP_EDGE_START; i++)
|
||||
FillBgTilemapBufferRect(bg, TILE_TOP_EDGE_START + i, i - 1 + x, y - 1, 1, 1, 14);
|
||||
|
||||
// Draw sides
|
||||
FillBgTilemapBufferRect(bg, TILE_LEFT_EDGE_TOP, x - 1, y, 1, 1, 14);
|
||||
FillBgTilemapBufferRect(bg, TILE_RIGHT_EDGE_TOP, deltaX + x, y, 1, 1, 14);
|
||||
FillBgTilemapBufferRect(bg, TILE_LEFT_EDGE_MID, x - 1, y + 1, 1, 1, 14);
|
||||
FillBgTilemapBufferRect(bg, TILE_RIGHT_EDGE_MID, deltaX + x, y + 1, 1, 1, 14);
|
||||
FillBgTilemapBufferRect(bg, TILE_LEFT_EDGE_BOT, x - 1, y + 2, 1, 1, 14);
|
||||
FillBgTilemapBufferRect(bg, TILE_RIGHT_EDGE_BOT, deltaX + x, y + 2, 1, 1, 14);
|
||||
|
||||
// Draw bottom edge
|
||||
for (i = 0; i < 1 + TILE_BOT_EDGE_END - TILE_BOT_EDGE_START; i++)
|
||||
FillBgTilemapBufferRect(bg, TILE_BOT_EDGE_START + i, i - 1 + x, y + deltaY, 1, 1, 14);
|
||||
}
|
||||
|
||||
static void LoadMapNamePopUpWindowBg(void)
|
||||
@@ -369,7 +381,7 @@ static void LoadMapNamePopUpWindowBg(void)
|
||||
popUpThemeId = gRegionMapSectionId_To_PopUpThemeIdMapping[regionMapSectionId];
|
||||
|
||||
LoadBgTiles(GetWindowAttribute(popupWindowId, WINDOW_BG), gMapPopUp_Outline_Table[popUpThemeId], 0x400, 0x21D);
|
||||
CallWindowFunction(popupWindowId, sub_80D4A78);
|
||||
CallWindowFunction(popupWindowId, DrawMapNamePopUpFrame);
|
||||
PutWindowTilemap(popupWindowId);
|
||||
if (gMapHeader.weather == WEATHER_UNDERWATER_BUBBLES)
|
||||
LoadPalette(&gUnknown_0857F444, 0xE0, 0x20);
|
||||
|
||||
@@ -425,21 +425,21 @@ static void StartBardSong(bool8 useTemporaryLyrics)
|
||||
gTasks[taskId].tUseTemporaryLyrics = useTemporaryLyrics;
|
||||
}
|
||||
|
||||
static void sub_81206F0(void)
|
||||
static void EnableTextPrinters(void)
|
||||
{
|
||||
gUnknown_03002F84 = FALSE;
|
||||
gDisableTextPrinters = FALSE;
|
||||
}
|
||||
|
||||
static void BardSong_TextSubPrinter(struct TextPrinterTemplate * printer, u16 a1)
|
||||
static void BardSong_DisableTextPrinters(struct TextPrinterTemplate * printer, u16 a1)
|
||||
{
|
||||
gUnknown_03002F84 = TRUE;
|
||||
gDisableTextPrinters = TRUE;
|
||||
}
|
||||
|
||||
static void sub_8120708(const u8 * src)
|
||||
{
|
||||
DrawDialogueFrame(0, 0);
|
||||
AddTextPrinterParameterized(0, 1, src, 0, 1, 1, BardSong_TextSubPrinter);
|
||||
gUnknown_03002F84 = TRUE;
|
||||
AddTextPrinterParameterized(0, 1, src, 0, 1, 1, BardSong_DisableTextPrinters);
|
||||
gDisableTextPrinters = TRUE;
|
||||
CopyWindowToVram(0, 3);
|
||||
}
|
||||
|
||||
@@ -620,7 +620,7 @@ static void Task_BardSong(u8 taskId)
|
||||
else if (gStringVar4[task->tCharIndex] == CHAR_SPACE)
|
||||
{
|
||||
|
||||
sub_81206F0();
|
||||
EnableTextPrinters();
|
||||
task->tCharIndex++;
|
||||
task->tState = 2;
|
||||
task->data[2] = 0;
|
||||
@@ -640,7 +640,7 @@ static void Task_BardSong(u8 taskId)
|
||||
else if (gStringVar4[task->tCharIndex] == CHAR_SONG_WORD_SEPARATOR)
|
||||
{
|
||||
gStringVar4[task->tCharIndex] = CHAR_SPACE; // restore it back to a space
|
||||
sub_81206F0();
|
||||
EnableTextPrinters();
|
||||
task->tCharIndex++;
|
||||
task->data[2] = 0;
|
||||
}
|
||||
@@ -649,7 +649,7 @@ static void Task_BardSong(u8 taskId)
|
||||
switch (task->data[1])
|
||||
{
|
||||
case 0:
|
||||
sub_81206F0();
|
||||
EnableTextPrinters();
|
||||
task->data[1]++;
|
||||
break;
|
||||
case 1:
|
||||
|
||||
+2
-2
@@ -312,14 +312,14 @@ static bool8 sub_81221D0(void)
|
||||
if (!MenuHelpers_LinkSomething())
|
||||
return FALSE;
|
||||
else
|
||||
return sub_8087598();
|
||||
return Overworld_LinkRecvQueueLengthMoreThan2();
|
||||
}
|
||||
|
||||
bool8 MenuHelpers_CallLinkSomething(void)
|
||||
{
|
||||
if (sub_81221D0() == TRUE)
|
||||
return TRUE;
|
||||
else if (sub_800B504() != TRUE)
|
||||
else if (IsLinkRecvQueueLengthAtLeast3() != TRUE)
|
||||
return FALSE;
|
||||
else
|
||||
return TRUE;
|
||||
|
||||
+436
-310
@@ -5,15 +5,366 @@
|
||||
#include "sound.h"
|
||||
#include "task.h"
|
||||
#include "trig.h"
|
||||
#include "minigame_countdown.h"
|
||||
#include "constants/songs.h"
|
||||
|
||||
/*
|
||||
This file contains two types of '3-2-1 Start' countdowns intended for use by the wireless minigames.
|
||||
|
||||
One is static, where the numbers simply appear and disappear without moving. This version is unused.
|
||||
The other (used) version has the numbers squish and bounce up as they appear.
|
||||
*/
|
||||
|
||||
#define TAG_STATIC_COUNTDOWN 0x2000
|
||||
|
||||
enum {
|
||||
STATE_IDLE = 1,
|
||||
STATE_START,
|
||||
STATE_RUN,
|
||||
STATE_END,
|
||||
};
|
||||
|
||||
enum {
|
||||
FUNC_INIT,
|
||||
FUNC_FREE,
|
||||
FUNC_START,
|
||||
FUNC_RUN,
|
||||
};
|
||||
|
||||
enum {
|
||||
ANIM_THREE,
|
||||
ANIM_TWO,
|
||||
ANIM_ONE,
|
||||
ANIM_START_LEFT,
|
||||
ANIM_START_MID,
|
||||
ANIM_START_RIGHT,
|
||||
};
|
||||
|
||||
extern const struct OamData gOamData_AffineOff_ObjNormal_32x32;
|
||||
|
||||
static void sub_802E6D0(u8 taskId);
|
||||
static void sub_802E83C(u8 taskId);
|
||||
static void sub_802E8C8(u8 taskId);
|
||||
static void sub_802EA50(u8 taskId);
|
||||
static void sub_802EAB0(u8 taskId);
|
||||
static void Task_StaticCountdown(u8 taskId);
|
||||
static void Task_StaticCountdown_Init(u8 taskId);
|
||||
static void Task_StaticCountdown_Free(u8 taskId);
|
||||
static void Task_StaticCountdown_Start(u8 taskId);
|
||||
static void Task_StaticCountdown_Run(u8 taskId);
|
||||
|
||||
static const u16 s321Start_Static_Pal[] = INCBIN_U16("graphics/minigame_countdown/321start_static.gbapal");
|
||||
static const u32 s321Start_Static_Gfx[] = INCBIN_U32("graphics/minigame_countdown/321start_static.4bpp.lz");
|
||||
|
||||
static const struct CompressedSpriteSheet sSpriteSheet_321Start_Static[] =
|
||||
{
|
||||
{s321Start_Static_Gfx, 0xC00, TAG_STATIC_COUNTDOWN},
|
||||
{},
|
||||
};
|
||||
|
||||
static const struct SpritePalette sSpritePalette_321Start_Static[] =
|
||||
{
|
||||
{s321Start_Static_Pal, TAG_STATIC_COUNTDOWN},
|
||||
{},
|
||||
};
|
||||
|
||||
static const union AnimCmd sAnim_StaticCountdown_Three[] =
|
||||
{
|
||||
ANIMCMD_FRAME(0, 0),
|
||||
ANIMCMD_END
|
||||
};
|
||||
|
||||
static const union AnimCmd sAnim_StaticCountdown_Two[] =
|
||||
{
|
||||
ANIMCMD_FRAME(16, 0),
|
||||
ANIMCMD_END
|
||||
};
|
||||
|
||||
static const union AnimCmd sAnim_StaticCountdown_One[] =
|
||||
{
|
||||
ANIMCMD_FRAME(32, 0),
|
||||
ANIMCMD_END
|
||||
};
|
||||
|
||||
static const union AnimCmd sAnim_StaticCountdown_StartLeft[] =
|
||||
{
|
||||
ANIMCMD_FRAME(64, 0),
|
||||
ANIMCMD_END
|
||||
};
|
||||
|
||||
static const union AnimCmd sAnim_StaticCountdown_StartMid[] =
|
||||
{
|
||||
ANIMCMD_FRAME(48, 0),
|
||||
ANIMCMD_END
|
||||
};
|
||||
|
||||
static const union AnimCmd sAnim_StaticCountdown_StartRight[] =
|
||||
{
|
||||
ANIMCMD_FRAME(80, 0),
|
||||
ANIMCMD_END
|
||||
};
|
||||
|
||||
static const union AnimCmd *const sAnims_StaticCountdown[] =
|
||||
{
|
||||
[ANIM_THREE] = sAnim_StaticCountdown_Three,
|
||||
[ANIM_TWO] = sAnim_StaticCountdown_Two,
|
||||
[ANIM_ONE] = sAnim_StaticCountdown_One,
|
||||
[ANIM_START_LEFT] = sAnim_StaticCountdown_StartLeft,
|
||||
[ANIM_START_MID] = sAnim_StaticCountdown_StartMid,
|
||||
[ANIM_START_RIGHT] = sAnim_StaticCountdown_StartRight
|
||||
};
|
||||
|
||||
static const struct SpriteTemplate sSpriteTemplate_StaticCountdown[] =
|
||||
{
|
||||
{
|
||||
.tileTag = TAG_STATIC_COUNTDOWN,
|
||||
.paletteTag = TAG_STATIC_COUNTDOWN,
|
||||
.oam = &gOamData_AffineOff_ObjNormal_32x32,
|
||||
.anims = sAnims_StaticCountdown,
|
||||
.images = NULL,
|
||||
.affineAnims = gDummySpriteAffineAnimTable,
|
||||
.callback = SpriteCallbackDummy,
|
||||
},
|
||||
};
|
||||
|
||||
static const TaskFunc sStaticCountdownFuncs[][4] =
|
||||
{
|
||||
{
|
||||
[FUNC_INIT] = Task_StaticCountdown_Init,
|
||||
[FUNC_FREE] = Task_StaticCountdown_Free,
|
||||
[FUNC_START] = Task_StaticCountdown_Start,
|
||||
[FUNC_RUN] = Task_StaticCountdown_Run
|
||||
},
|
||||
};
|
||||
|
||||
#define tState data[0]
|
||||
#define tFuncSetId data[1] // These 4 data elements are indexes into
|
||||
#define tSpriteTemplateId data[2] // arrays that only have 1 element with
|
||||
#define tSpriteSheetId data[3] // data. As such their only legal value
|
||||
#define tSpritePalId data[4] // is 0. Unclear why they were used.
|
||||
#define tInterval data[5]
|
||||
#define tPriority data[6]
|
||||
#define tSubpriority data[7]
|
||||
#define tNumSprites data[8]
|
||||
#define tX data[9]
|
||||
#define tY data[10]
|
||||
#define tPrevTime data[10] // Re-used
|
||||
#define tTimer data[11]
|
||||
#define tLinkTimer data[12]
|
||||
// 13-15 hold sprite ids
|
||||
// tSpriteIds(0) is used for the number sprites, and the leftmost part of 'Start'
|
||||
// tSpriteIds(1) is used for the middle part of 'Start'
|
||||
// tSpriteIds(2) is used for for the rightmost part of 'Start'
|
||||
#define tSpriteIds(i) data[13 + i]
|
||||
|
||||
#define sInterval data[1] // Never read
|
||||
#define sAnimNum data[2]
|
||||
#define sTaskId data[3]
|
||||
#define sId data[4] // Never read
|
||||
#define sNumberSpriteId data[5] // Never read
|
||||
|
||||
// Unused
|
||||
static u32 CreateStaticCountdownTask(u8 funcSetId, u8 taskPriority)
|
||||
{
|
||||
u8 taskId = CreateTask(Task_StaticCountdown, taskPriority);
|
||||
struct Task *task = &gTasks[taskId];
|
||||
|
||||
task->tState = STATE_IDLE;
|
||||
task->tFuncSetId = funcSetId;
|
||||
sStaticCountdownFuncs[funcSetId][FUNC_INIT](taskId);
|
||||
return taskId;
|
||||
}
|
||||
|
||||
static bool32 StartStaticCountdown(void)
|
||||
{
|
||||
u8 taskId = FindTaskIdByFunc(Task_StaticCountdown);
|
||||
if (taskId == TASK_NONE)
|
||||
return FALSE;
|
||||
|
||||
gTasks[taskId].tState = STATE_START;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static bool32 IsStaticCountdownRunning(void)
|
||||
{
|
||||
return FuncIsActiveTask(Task_StaticCountdown);
|
||||
}
|
||||
|
||||
static void Task_StaticCountdown(u8 taskId)
|
||||
{
|
||||
s16 *data = gTasks[taskId].data;
|
||||
|
||||
switch (tState)
|
||||
{
|
||||
// STATE_IDLE does nothing; wait until started
|
||||
case STATE_START:
|
||||
sStaticCountdownFuncs[tFuncSetId][FUNC_START](taskId);
|
||||
tState = STATE_RUN;
|
||||
break;
|
||||
case STATE_RUN:
|
||||
sStaticCountdownFuncs[tFuncSetId][FUNC_RUN](taskId);
|
||||
break;
|
||||
case STATE_END:
|
||||
sStaticCountdownFuncs[tFuncSetId][FUNC_FREE](taskId);
|
||||
DestroyTask(taskId);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void StaticCountdown_CreateSprites(u8 taskId, s16 *data)
|
||||
{
|
||||
u8 i;
|
||||
struct Sprite *sprite;
|
||||
|
||||
LoadCompressedSpriteSheet(&sSpriteSheet_321Start_Static[tSpriteSheetId]);
|
||||
LoadSpritePalette(&sSpritePalette_321Start_Static[tSpritePalId]);
|
||||
for (i = 0; i < tNumSprites; i++)
|
||||
tSpriteIds(i) = CreateSprite(&sSpriteTemplate_StaticCountdown[tSpriteTemplateId], tX, tY, tSubpriority);
|
||||
for (i = 0; i < tNumSprites; i++)
|
||||
{
|
||||
sprite = &gSprites[tSpriteIds(i)];
|
||||
sprite->oam.priority = tPriority;
|
||||
sprite->invisible = TRUE;
|
||||
sprite->sInterval = tInterval;
|
||||
sprite->sTaskId = taskId;
|
||||
sprite->sId = i;
|
||||
sprite->sNumberSpriteId = tSpriteIds(0);
|
||||
}
|
||||
}
|
||||
|
||||
static void Task_StaticCountdown_Init(u8 taskId)
|
||||
{
|
||||
s16 *data = gTasks[taskId].data;
|
||||
tSpriteTemplateId = 0;
|
||||
tSpriteSheetId = 0;
|
||||
tSpritePalId = 0;
|
||||
tInterval = 60;
|
||||
tPriority = 0;
|
||||
tSubpriority = 0;
|
||||
tNumSprites = 3;
|
||||
tX = 120;
|
||||
tY = 88;
|
||||
StaticCountdown_CreateSprites(taskId, data);
|
||||
|
||||
StartSpriteAnim(&gSprites[tSpriteIds(1)], ANIM_START_MID);
|
||||
gSprites[tSpriteIds(1)].pos2.x = -32;
|
||||
|
||||
StartSpriteAnim(&gSprites[tSpriteIds(2)], ANIM_START_RIGHT);
|
||||
gSprites[tSpriteIds(2)].pos2.x = 32;
|
||||
}
|
||||
|
||||
static void Task_StaticCountdown_Free(u8 taskId)
|
||||
{
|
||||
u8 i = 0;
|
||||
s16 *data = gTasks[taskId].data;
|
||||
|
||||
for (i = 0; i < tNumSprites; i++)
|
||||
DestroySprite(&gSprites[tSpriteIds(i)]);
|
||||
FreeSpriteTilesByTag(sSpriteSheet_321Start_Static[tSpriteSheetId].tag);
|
||||
FreeSpritePaletteByTag(sSpritePalette_321Start_Static[tSpritePalId].tag);
|
||||
}
|
||||
|
||||
static void SpriteCB_StaticCountdown(struct Sprite *sprite)
|
||||
{
|
||||
s16 *data = gTasks[sprite->sTaskId].data;
|
||||
|
||||
if (tTimer % tInterval != 0)
|
||||
return;
|
||||
if (tTimer == tPrevTime)
|
||||
return;
|
||||
|
||||
tPrevTime = tTimer;
|
||||
switch (sprite->sAnimNum)
|
||||
{
|
||||
case ANIM_THREE:
|
||||
sprite->invisible = FALSE;
|
||||
case ANIM_TWO:
|
||||
case ANIM_ONE:
|
||||
// Set sprite to a number
|
||||
PlaySE(SE_BALL_BOUNCE_1);
|
||||
StartSpriteAnim(sprite, sprite->sAnimNum);
|
||||
break;
|
||||
case ANIM_START_LEFT:
|
||||
// Set sprite to 'Start'
|
||||
PlaySE(SE_PIN);
|
||||
StartSpriteAnim(sprite, sprite->sAnimNum);
|
||||
gSprites[tSpriteIds(1)].invisible = FALSE;
|
||||
gSprites[tSpriteIds(2)].invisible = FALSE;
|
||||
break;
|
||||
case ANIM_START_LEFT + 1: // End
|
||||
// Hide countdown
|
||||
sprite->invisible = TRUE;
|
||||
gSprites[tSpriteIds(1)].invisible = TRUE;
|
||||
gSprites[tSpriteIds(2)].invisible = TRUE;
|
||||
tState = STATE_END;
|
||||
return;
|
||||
}
|
||||
sprite->sAnimNum++;
|
||||
}
|
||||
|
||||
static void Task_StaticCountdown_Start(u8 taskId)
|
||||
{
|
||||
s16 *data = gTasks[taskId].data;
|
||||
PlaySE(SE_BALL_BOUNCE_1);
|
||||
gSprites[tSpriteIds(0)].callback = SpriteCB_StaticCountdown;
|
||||
gSprites[tSpriteIds(0)].invisible = FALSE;
|
||||
gTasks[taskId].tState = STATE_RUN;
|
||||
}
|
||||
|
||||
// Increment timer for progressing the countdown.
|
||||
// If the player is the link leader, increment a
|
||||
// separate timer and send it to group members for
|
||||
// them to read and use.
|
||||
static void Task_StaticCountdown_Run(u8 taskId)
|
||||
{
|
||||
u16 packet[RFU_PACKET_SIZE];
|
||||
s16 *data = gTasks[taskId].data;
|
||||
|
||||
if (gReceivedRemoteLinkPlayers != 0)
|
||||
{
|
||||
// Read link timer
|
||||
if (gRecvCmds[0][1] == LINKCMD_COUNTDOWN)
|
||||
tTimer = gRecvCmds[0][2];
|
||||
|
||||
if (GetMultiplayerId() == 0)
|
||||
{
|
||||
// Player is link leader.
|
||||
// Send timer to group members
|
||||
tLinkTimer++;
|
||||
memset(packet, 0, sizeof(packet));
|
||||
packet[0] = LINKCMD_COUNTDOWN;
|
||||
packet[1] = tLinkTimer;
|
||||
Rfu_SendPacket(packet);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Local, just increment own timer
|
||||
tTimer++;
|
||||
}
|
||||
}
|
||||
|
||||
#undef tState
|
||||
#undef tFuncSetId
|
||||
#undef tSpriteTemplateId
|
||||
#undef tSpriteSheetId
|
||||
#undef tSpritePalId
|
||||
#undef tInterval
|
||||
#undef tPriority
|
||||
#undef tSubpriority
|
||||
#undef tNumSprites
|
||||
#undef tX
|
||||
#undef tY
|
||||
#undef tPrevTime
|
||||
#undef tTimer
|
||||
#undef tLinkTimer
|
||||
#undef tSpriteIds
|
||||
#undef sInterval
|
||||
#undef sAnimNum
|
||||
#undef sTaskId
|
||||
#undef sId
|
||||
#undef sNumberSpriteId
|
||||
|
||||
/*
|
||||
The countdown that actually gets used by
|
||||
the wireless minigames starts here
|
||||
*/
|
||||
|
||||
static void Task_MinigameCountdown(u8 taskId);
|
||||
static bool32 RunMinigameCountdownDigitsAnim(u8 spriteId);
|
||||
static bool32 IsStartGraphicAnimRunning(u8 spriteId);
|
||||
@@ -23,260 +374,8 @@ static void CreateStartSprite(u16 tileTag, u16 palTag, s16 x, s16 y, u8 subprior
|
||||
static void InitStartGraphic(u8 spriteId1, u8 spriteId2, u8 spriteId3);
|
||||
static void SpriteCB_Start(struct Sprite *sprite);
|
||||
|
||||
static const u16 sSpritePal_321Start_2[] = INCBIN_U16("graphics/link_games/321start_2.gbapal");
|
||||
static const u32 sSpriteSheet_321Start_2[] = INCBIN_U32("graphics/link_games/321start_2.4bpp.lz");
|
||||
|
||||
static const struct CompressedSpriteSheet gUnknown_082FE6C8[] =
|
||||
{
|
||||
{sSpriteSheet_321Start_2, 0xC00, 0x2000},
|
||||
{},
|
||||
};
|
||||
|
||||
static const struct SpritePalette gUnknown_082FE6D8[] =
|
||||
{
|
||||
{sSpritePal_321Start_2, 0x2000},
|
||||
{},
|
||||
};
|
||||
|
||||
static const union AnimCmd sSpriteAnim_82FE6E8[] =
|
||||
{
|
||||
ANIMCMD_FRAME(0, 0),
|
||||
ANIMCMD_END
|
||||
};
|
||||
|
||||
static const union AnimCmd sSpriteAnim_82FE6F0[] =
|
||||
{
|
||||
ANIMCMD_FRAME(16, 0),
|
||||
ANIMCMD_END
|
||||
};
|
||||
|
||||
static const union AnimCmd sSpriteAnim_82FE6F8[] =
|
||||
{
|
||||
ANIMCMD_FRAME(32, 0),
|
||||
ANIMCMD_END
|
||||
};
|
||||
|
||||
static const union AnimCmd sSpriteAnim_82FE700[] =
|
||||
{
|
||||
ANIMCMD_FRAME(64, 0),
|
||||
ANIMCMD_END
|
||||
};
|
||||
|
||||
static const union AnimCmd sSpriteAnim_82FE708[] =
|
||||
{
|
||||
ANIMCMD_FRAME(48, 0),
|
||||
ANIMCMD_END
|
||||
};
|
||||
|
||||
static const union AnimCmd sSpriteAnim_82FE710[] =
|
||||
{
|
||||
ANIMCMD_FRAME(80, 0),
|
||||
ANIMCMD_END
|
||||
};
|
||||
|
||||
static const union AnimCmd *const sSpriteAnimTable_82FE718[] =
|
||||
{
|
||||
sSpriteAnim_82FE6E8,
|
||||
sSpriteAnim_82FE6F0,
|
||||
sSpriteAnim_82FE6F8,
|
||||
sSpriteAnim_82FE700,
|
||||
sSpriteAnim_82FE708,
|
||||
sSpriteAnim_82FE710
|
||||
};
|
||||
|
||||
static const struct SpriteTemplate gUnknown_082FE730[] =
|
||||
{
|
||||
{
|
||||
.tileTag = 0x2000,
|
||||
.paletteTag = 0x2000,
|
||||
.oam = &gOamData_AffineOff_ObjNormal_32x32,
|
||||
.anims = sSpriteAnimTable_82FE718,
|
||||
.images = NULL,
|
||||
.affineAnims = gDummySpriteAffineAnimTable,
|
||||
.callback = SpriteCallbackDummy,
|
||||
},
|
||||
};
|
||||
|
||||
static const TaskFunc gUnknown_082FE748[][4] =
|
||||
{
|
||||
{
|
||||
sub_802E83C,
|
||||
sub_802E8C8,
|
||||
sub_802EA50,
|
||||
sub_802EAB0
|
||||
},
|
||||
};
|
||||
|
||||
static const u16 sSpritePal_321Start[] = INCBIN_U16("graphics/link_games/321start.gbapal");
|
||||
static const u32 sSpriteSheet_321Start[] = INCBIN_U32("graphics/link_games/321start.4bpp.lz");
|
||||
|
||||
// Unused
|
||||
static u32 sub_802E63C(u8 funcSetId, u8 taskPriority)
|
||||
{
|
||||
u8 taskId = CreateTask(sub_802E6D0, taskPriority);
|
||||
struct Task *task = &gTasks[taskId];
|
||||
|
||||
task->data[0] = 1;
|
||||
task->data[1] = funcSetId;
|
||||
gUnknown_082FE748[funcSetId][0](taskId);
|
||||
return taskId;
|
||||
}
|
||||
|
||||
static bool32 sub_802E688(void)
|
||||
{
|
||||
u8 taskId = FindTaskIdByFunc(sub_802E6D0);
|
||||
if (taskId == TASK_NONE)
|
||||
return FALSE;
|
||||
|
||||
gTasks[taskId].data[0] = 2;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static bool32 sub_802E6BC(void)
|
||||
{
|
||||
return FuncIsActiveTask(sub_802E6D0);
|
||||
}
|
||||
|
||||
static void sub_802E6D0(u8 taskId)
|
||||
{
|
||||
s16 *data = gTasks[taskId].data;
|
||||
|
||||
switch (data[0])
|
||||
{
|
||||
case 2:
|
||||
gUnknown_082FE748[data[1]][2](taskId);
|
||||
data[0] = 3;
|
||||
break;
|
||||
case 3:
|
||||
gUnknown_082FE748[data[1]][3](taskId);
|
||||
break;
|
||||
case 4:
|
||||
gUnknown_082FE748[data[1]][1](taskId);
|
||||
DestroyTask(taskId);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void sub_802E75C(u8 taskId, s16 *data)
|
||||
{
|
||||
u8 i;
|
||||
struct Sprite *sprite;
|
||||
|
||||
LoadCompressedSpriteSheet(&gUnknown_082FE6C8[data[3]]);
|
||||
LoadSpritePalette(&gUnknown_082FE6D8[data[4]]);
|
||||
for (i = 0; i < data[8]; i++)
|
||||
data[13 + i] = CreateSprite(&gUnknown_082FE730[data[2]], data[9], data[10], data[7]);
|
||||
for (i = 0; i < data[8]; i++)
|
||||
{
|
||||
sprite = &gSprites[data[13 + i]];
|
||||
sprite->oam.priority = data[6];
|
||||
sprite->invisible = TRUE;
|
||||
sprite->data[1] = data[5];
|
||||
sprite->data[3] = taskId;
|
||||
sprite->data[4] = i;
|
||||
sprite->data[5] = data[13];
|
||||
}
|
||||
}
|
||||
|
||||
static void sub_802E83C(u8 taskId)
|
||||
{
|
||||
s16 *data = gTasks[taskId].data;
|
||||
data[2] = 0;
|
||||
data[3] = 0;
|
||||
data[4] = 0;
|
||||
data[5] = 60;
|
||||
data[6] = 0;
|
||||
data[7] = 0;
|
||||
data[8] = 3;
|
||||
data[9] = 120;
|
||||
data[10] = 88;
|
||||
sub_802E75C(taskId, data);
|
||||
|
||||
StartSpriteAnim(&gSprites[data[14]], 4);
|
||||
gSprites[data[14]].pos2.x = -32;
|
||||
|
||||
StartSpriteAnim(&gSprites[data[15]], 5);
|
||||
gSprites[data[15]].pos2.x = 32;
|
||||
}
|
||||
|
||||
static void sub_802E8C8(u8 taskId)
|
||||
{
|
||||
u8 i = 0;
|
||||
s16 *data = gTasks[taskId].data;
|
||||
|
||||
for (i = 0; i < data[8]; i++)
|
||||
DestroySprite(&gSprites[data[13 + i]]);
|
||||
FreeSpriteTilesByTag(gUnknown_082FE6C8[data[3]].tag);
|
||||
FreeSpritePaletteByTag(gUnknown_082FE6D8[data[4]].tag);
|
||||
}
|
||||
|
||||
static void sub_802E938(struct Sprite *sprite)
|
||||
{
|
||||
s16 *data = gTasks[sprite->data[3]].data;
|
||||
|
||||
if (data[11] % data[5] != 0)
|
||||
return;
|
||||
if (data[11] == data[10])
|
||||
return;
|
||||
|
||||
data[10] = data[11];
|
||||
switch (sprite->data[2])
|
||||
{
|
||||
case 0:
|
||||
sprite->invisible = FALSE;
|
||||
case 1:
|
||||
case 2:
|
||||
PlaySE(SE_BALL_BOUNCE_1);
|
||||
StartSpriteAnim(sprite, sprite->data[2]);
|
||||
break;
|
||||
case 3:
|
||||
PlaySE(SE_PIN);
|
||||
StartSpriteAnim(sprite, sprite->data[2]);
|
||||
gSprites[data[14]].invisible = FALSE;
|
||||
gSprites[data[15]].invisible = FALSE;
|
||||
break;
|
||||
case 4:
|
||||
sprite->invisible = TRUE;
|
||||
gSprites[data[14]].invisible = TRUE;
|
||||
gSprites[data[15]].invisible = TRUE;
|
||||
data[0] = 4;
|
||||
return;
|
||||
}
|
||||
sprite->data[2]++;
|
||||
}
|
||||
|
||||
static void sub_802EA50(u8 taskId)
|
||||
{
|
||||
s16 *data = gTasks[taskId].data;
|
||||
PlaySE(SE_BALL_BOUNCE_1);
|
||||
gSprites[data[13]].callback = sub_802E938;
|
||||
gSprites[data[13]].invisible = FALSE;
|
||||
gTasks[taskId].data[0] = 3;
|
||||
}
|
||||
|
||||
static void sub_802EAB0(u8 taskId)
|
||||
{
|
||||
u16 packet[6];
|
||||
s16 *data = gTasks[taskId].data;
|
||||
|
||||
if (gReceivedRemoteLinkPlayers != 0)
|
||||
{
|
||||
if (gRecvCmds[0][1] == LINKCMD_0x7FFF)
|
||||
data[11] = gRecvCmds[0][2];
|
||||
if (GetMultiplayerId() == 0)
|
||||
{
|
||||
data[12]++;
|
||||
memset(packet, 0, sizeof(packet));
|
||||
packet[0] = LINKCMD_0x7FFF;
|
||||
packet[1] = data[12];
|
||||
Rfu_SendPacket(packet);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
data[11]++;
|
||||
}
|
||||
}
|
||||
static const u16 s321Start_Pal[] = INCBIN_U16("graphics/minigame_countdown/321start.gbapal");
|
||||
static const u32 s321Start_Gfx[] = INCBIN_U32("graphics/minigame_countdown/321start.4bpp.lz");
|
||||
|
||||
#define tState data[0]
|
||||
#define tTilesTag data[2]
|
||||
@@ -288,7 +387,7 @@ static void sub_802EAB0(u8 taskId)
|
||||
#define tSpriteId2 data[8]
|
||||
#define tSpriteId3 data[9]
|
||||
|
||||
void StartMinigameCountdown(s16 tilesTag, s16 palTag, s16 x, s16 y, u8 subpriority)
|
||||
void StartMinigameCountdown(u16 tilesTag, u16 palTag, s16 x, s16 y, u8 subpriority)
|
||||
{
|
||||
u8 taskId = CreateTask(Task_MinigameCountdown, 80);
|
||||
gTasks[taskId].tTilesTag = tilesTag;
|
||||
@@ -337,69 +436,82 @@ static void Task_MinigameCountdown(u8 taskId)
|
||||
}
|
||||
}
|
||||
|
||||
#define sState data[0]
|
||||
#define sTimer data[2]
|
||||
#define sAnimNum data[4]
|
||||
|
||||
static bool32 RunMinigameCountdownDigitsAnim(u8 spriteId)
|
||||
{
|
||||
struct Sprite *sprite = &gSprites[spriteId];
|
||||
|
||||
switch (sprite->data[0])
|
||||
switch (sprite->sState)
|
||||
{
|
||||
case 0:
|
||||
sub_8007E18(sprite, 0x800, 0x1A);
|
||||
sprite->data[0]++;
|
||||
sprite->sState++;
|
||||
// fallthrough
|
||||
case 1:
|
||||
if (sprite->data[2] == 0)
|
||||
if (sprite->sTimer == 0)
|
||||
PlaySE(SE_BALL_BOUNCE_2);
|
||||
if (++sprite->data[2] >= 20)
|
||||
|
||||
if (++sprite->sTimer >= 20)
|
||||
{
|
||||
sprite->data[2] = 0;
|
||||
// Ready for jump
|
||||
sprite->sTimer = 0;
|
||||
StartSpriteAffineAnim(sprite, 1);
|
||||
sprite->data[0]++;
|
||||
sprite->sState++;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
if (sprite->affineAnimEnded)
|
||||
sprite->data[0]++;
|
||||
sprite->sState++;
|
||||
break;
|
||||
case 3:
|
||||
if (++sprite->data[2] >= 4)
|
||||
if (++sprite->sTimer >= 4)
|
||||
{
|
||||
sprite->data[2] = 0;
|
||||
sprite->data[0]++;
|
||||
// Start jump
|
||||
sprite->sTimer = 0;
|
||||
sprite->sState++;
|
||||
StartSpriteAffineAnim(sprite, 2);
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
// Moving up from jump
|
||||
sprite->pos1.y -= 4;
|
||||
if (++sprite->data[2] >= 8)
|
||||
if (++sprite->sTimer >= 8)
|
||||
{
|
||||
if (sprite->data[4] <= 1)
|
||||
if (sprite->sAnimNum < 2)
|
||||
{
|
||||
StartSpriteAnim(sprite, sprite->data[4] + 1);
|
||||
sprite->data[2] = 0;
|
||||
sprite->data[0]++;
|
||||
// Swap to the next number
|
||||
StartSpriteAnim(sprite, sprite->sAnimNum + 1);
|
||||
sprite->sTimer = 0;
|
||||
sprite->sState++;
|
||||
}
|
||||
else
|
||||
{
|
||||
sprite->data[0] = 7;
|
||||
// End
|
||||
sprite->sState = 7;
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 5:
|
||||
// Falling after jump
|
||||
sprite->pos1.y += 4;
|
||||
if (++sprite->data[2] >= 8)
|
||||
if (++sprite->sTimer >= 8)
|
||||
{
|
||||
sprite->data[2] = 0;
|
||||
// Land from jump
|
||||
sprite->sTimer = 0;
|
||||
StartSpriteAffineAnim(sprite, 3);
|
||||
sprite->data[0]++;
|
||||
sprite->sState++;
|
||||
}
|
||||
break;
|
||||
case 6:
|
||||
if (sprite->affineAnimEnded)
|
||||
{
|
||||
sprite->data[4]++;
|
||||
sprite->data[0] = 1;
|
||||
// Restart for next number
|
||||
sprite->sAnimNum++;
|
||||
sprite->sState = 1;
|
||||
}
|
||||
break;
|
||||
case 7:
|
||||
@@ -409,6 +521,10 @@ static bool32 RunMinigameCountdownDigitsAnim(u8 spriteId)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#undef sState
|
||||
#undef sTimer
|
||||
#undef sAnimNum
|
||||
|
||||
// First argument is unused.
|
||||
static void InitStartGraphic(u8 spriteId1, u8 spriteId2, u8 spriteId3)
|
||||
{
|
||||
@@ -425,60 +541,70 @@ static bool32 IsStartGraphicAnimRunning(u8 spriteId)
|
||||
return gSprites[spriteId].callback == SpriteCB_Start;
|
||||
}
|
||||
|
||||
#define sState data[0]
|
||||
#define sTimer data[1]
|
||||
#define sYSpeed data[4]
|
||||
#define sY data[5]
|
||||
|
||||
static void SpriteCB_Start(struct Sprite *sprite)
|
||||
{
|
||||
int y;
|
||||
s16 *data = sprite->data;
|
||||
|
||||
switch (data[0])
|
||||
switch (sState)
|
||||
{
|
||||
case 0:
|
||||
data[4] = 64;
|
||||
data[5] = sprite->pos2.y << 4;
|
||||
data[0]++;
|
||||
sYSpeed = 64;
|
||||
sY = sprite->pos2.y << 4;
|
||||
sState++;
|
||||
case 1:
|
||||
data[5] += data[4];
|
||||
data[4]++;
|
||||
sprite->pos2.y = data[5] >> 4;
|
||||
sY += sYSpeed;
|
||||
sYSpeed++;
|
||||
sprite->pos2.y = sY >> 4;
|
||||
if (sprite->pos2.y >= 0)
|
||||
{
|
||||
PlaySE(SE_BALL_BOUNCE_2);
|
||||
sprite->pos2.y = 0;
|
||||
data[0]++;
|
||||
sState++;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
data[1] += 12;
|
||||
if (data[1] >= 128)
|
||||
sTimer += 12;
|
||||
if (sTimer >= 128)
|
||||
{
|
||||
PlaySE(SE_BALL_BOUNCE_2);
|
||||
data[1] = 0;
|
||||
data[0]++;
|
||||
sTimer = 0;
|
||||
sState++;
|
||||
}
|
||||
y = gSineTable[data[1]];
|
||||
y = gSineTable[sTimer];
|
||||
sprite->pos2.y = -(y >> 4);
|
||||
break;
|
||||
case 3:
|
||||
data[1] += 16;
|
||||
if (data[1] >= 128)
|
||||
sTimer += 16;
|
||||
if (sTimer >= 128)
|
||||
{
|
||||
PlaySE(SE_BALL_BOUNCE_2);
|
||||
data[1] = 0;
|
||||
data[0]++;
|
||||
sTimer = 0;
|
||||
sState++;
|
||||
}
|
||||
sprite->pos2.y = -(gSineTable[data[1]] >> 5);
|
||||
sprite->pos2.y = -(gSineTable[sTimer] >> 5);
|
||||
break;
|
||||
case 4:
|
||||
if (++data[1] > 40)
|
||||
if (++sTimer > 40)
|
||||
sprite->callback = SpriteCallbackDummy;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#undef sState
|
||||
#undef sTimer
|
||||
#undef sYSpeed
|
||||
#undef sY
|
||||
|
||||
static void Load321StartGfx(u16 tileTag, u16 palTag)
|
||||
{
|
||||
struct CompressedSpriteSheet spriteSheet = {sSpriteSheet_321Start, 0xE00, 0};
|
||||
struct SpritePalette spritePalette = {sSpritePal_321Start, 0};
|
||||
struct CompressedSpriteSheet spriteSheet = {s321Start_Gfx, 0xE00, 0};
|
||||
struct SpritePalette spritePalette = {s321Start_Pal, 0};
|
||||
|
||||
spriteSheet.tag = tileTag;
|
||||
spritePalette.tag = palTag;
|
||||
@@ -564,26 +690,26 @@ static const union AnimCmd *const sAnimTable_Start[] =
|
||||
sAnim_StartRight
|
||||
};
|
||||
|
||||
static const union AffineAnimCmd sAffineAnim_Numbers_0[] =
|
||||
static const union AffineAnimCmd sAffineAnim_Numbers_Normal[] =
|
||||
{
|
||||
AFFINEANIMCMD_FRAME(256, 256, 0, 0),
|
||||
AFFINEANIMCMD_END
|
||||
};
|
||||
|
||||
static const union AffineAnimCmd sAffineAnim_Numbers_1[] =
|
||||
static const union AffineAnimCmd sAffineAnim_Numbers_Squash[] =
|
||||
{
|
||||
AFFINEANIMCMD_FRAME(256, 256, 0, 0),
|
||||
AFFINEANIMCMD_FRAME(16, -16, 0, 8),
|
||||
AFFINEANIMCMD_END
|
||||
};
|
||||
|
||||
static const union AffineAnimCmd sAffineAnim_Numbers_2[] =
|
||||
static const union AffineAnimCmd sAffineAnim_Numbers_Stretch[] =
|
||||
{
|
||||
AFFINEANIMCMD_FRAME(-18, 18, 0, 8),
|
||||
AFFINEANIMCMD_END
|
||||
};
|
||||
|
||||
static const union AffineAnimCmd sAffineAnim_Numbers_3[] =
|
||||
static const union AffineAnimCmd sAffineAnim_Numbers_Land[] =
|
||||
{
|
||||
AFFINEANIMCMD_FRAME( 6, -6, 0, 8),
|
||||
AFFINEANIMCMD_FRAME( -4, 4, 0, 8),
|
||||
@@ -593,10 +719,10 @@ static const union AffineAnimCmd sAffineAnim_Numbers_3[] =
|
||||
|
||||
static const union AffineAnimCmd *const sAffineAnimTable_Numbers[] =
|
||||
{
|
||||
sAffineAnim_Numbers_0,
|
||||
sAffineAnim_Numbers_1,
|
||||
sAffineAnim_Numbers_2,
|
||||
sAffineAnim_Numbers_3
|
||||
sAffineAnim_Numbers_Normal,
|
||||
sAffineAnim_Numbers_Squash, // Push down before the jump
|
||||
sAffineAnim_Numbers_Stretch, // Stretch up for the jump
|
||||
sAffineAnim_Numbers_Land // Land after the jump
|
||||
};
|
||||
|
||||
static u8 CreateNumberSprite(u16 tileTag, u16 palTag, s16 x, s16 y, u8 subpriority)
|
||||
|
||||
+32
-20
@@ -75,7 +75,7 @@ static u8 ButtonMode_ProcessInput(u8 selection);
|
||||
static void ButtonMode_DrawChoices(u8 selection);
|
||||
static void DrawTextOption(void);
|
||||
static void DrawOptionMenuTexts(void);
|
||||
static void sub_80BB154(void);
|
||||
static void DrawBgWindowFrames(void);
|
||||
|
||||
EWRAM_DATA static bool8 sArrowPressed = FALSE;
|
||||
|
||||
@@ -228,7 +228,7 @@ void CB2_InitOptionMenu(void)
|
||||
DrawOptionMenuTexts();
|
||||
gMain.state++;
|
||||
case 9:
|
||||
sub_80BB154();
|
||||
DrawBgWindowFrames();
|
||||
gMain.state++;
|
||||
break;
|
||||
case 10:
|
||||
@@ -642,25 +642,37 @@ static void DrawOptionMenuTexts(void)
|
||||
CopyWindowToVram(WIN_OPTIONS, 3);
|
||||
}
|
||||
|
||||
static void sub_80BB154(void)
|
||||
#define TILE_TOP_CORNER_L 0x1A2
|
||||
#define TILE_TOP_EDGE 0x1A3
|
||||
#define TILE_TOP_CORNER_R 0x1A4
|
||||
#define TILE_LEFT_EDGE 0x1A5
|
||||
#define TILE_RIGHT_EDGE 0x1A7
|
||||
#define TILE_BOT_CORNER_L 0x1A8
|
||||
#define TILE_BOT_EDGE 0x1A9
|
||||
#define TILE_BOT_CORNER_R 0x1AA
|
||||
|
||||
static void DrawBgWindowFrames(void)
|
||||
{
|
||||
// bg, tileNum, x, y, width, height, pal
|
||||
FillBgTilemapBufferRect(1, 0x1A2, 1, 0, 1, 1, 7);
|
||||
FillBgTilemapBufferRect(1, 0x1A3, 2, 0, 0x1B, 1, 7);
|
||||
FillBgTilemapBufferRect(1, 0x1A4, 28, 0, 1, 1, 7);
|
||||
FillBgTilemapBufferRect(1, 0x1A5, 1, 1, 1, 2, 7);
|
||||
FillBgTilemapBufferRect(1, 0x1A7, 28, 1, 1, 2, 7);
|
||||
FillBgTilemapBufferRect(1, 0x1A8, 1, 3, 1, 1, 7);
|
||||
FillBgTilemapBufferRect(1, 0x1A9, 2, 3, 0x1B, 1, 7);
|
||||
FillBgTilemapBufferRect(1, 0x1AA, 28, 3, 1, 1, 7);
|
||||
FillBgTilemapBufferRect(1, 0x1A2, 1, 4, 1, 1, 7);
|
||||
FillBgTilemapBufferRect(1, 0x1A3, 2, 4, 0x1A, 1, 7);
|
||||
FillBgTilemapBufferRect(1, 0x1A4, 28, 4, 1, 1, 7);
|
||||
FillBgTilemapBufferRect(1, 0x1A5, 1, 5, 1, 0x12, 7);
|
||||
FillBgTilemapBufferRect(1, 0x1A7, 28, 5, 1, 0x12, 7);
|
||||
FillBgTilemapBufferRect(1, 0x1A8, 1, 19, 1, 1, 7);
|
||||
FillBgTilemapBufferRect(1, 0x1A9, 2, 19, 0x1A, 1, 7);
|
||||
FillBgTilemapBufferRect(1, 0x1AA, 28, 19, 1, 1, 7);
|
||||
// bg, tile, x, y, width, height, palNum
|
||||
// Draw title window frame
|
||||
FillBgTilemapBufferRect(1, TILE_TOP_CORNER_L, 1, 0, 1, 1, 7);
|
||||
FillBgTilemapBufferRect(1, TILE_TOP_EDGE, 2, 0, 27, 1, 7);
|
||||
FillBgTilemapBufferRect(1, TILE_TOP_CORNER_R, 28, 0, 1, 1, 7);
|
||||
FillBgTilemapBufferRect(1, TILE_LEFT_EDGE, 1, 1, 1, 2, 7);
|
||||
FillBgTilemapBufferRect(1, TILE_RIGHT_EDGE, 28, 1, 1, 2, 7);
|
||||
FillBgTilemapBufferRect(1, TILE_BOT_CORNER_L, 1, 3, 1, 1, 7);
|
||||
FillBgTilemapBufferRect(1, TILE_BOT_EDGE, 2, 3, 27, 1, 7);
|
||||
FillBgTilemapBufferRect(1, TILE_BOT_CORNER_R, 28, 3, 1, 1, 7);
|
||||
|
||||
// Draw options list window frame
|
||||
FillBgTilemapBufferRect(1, TILE_TOP_CORNER_L, 1, 4, 1, 1, 7);
|
||||
FillBgTilemapBufferRect(1, TILE_TOP_EDGE, 2, 4, 26, 1, 7);
|
||||
FillBgTilemapBufferRect(1, TILE_TOP_CORNER_R, 28, 4, 1, 1, 7);
|
||||
FillBgTilemapBufferRect(1, TILE_LEFT_EDGE, 1, 5, 1, 18, 7);
|
||||
FillBgTilemapBufferRect(1, TILE_RIGHT_EDGE, 28, 5, 1, 18, 7);
|
||||
FillBgTilemapBufferRect(1, TILE_BOT_CORNER_L, 1, 19, 1, 1, 7);
|
||||
FillBgTilemapBufferRect(1, TILE_BOT_EDGE, 2, 19, 26, 1, 7);
|
||||
FillBgTilemapBufferRect(1, TILE_BOT_CORNER_R, 28, 19, 1, 1, 7);
|
||||
|
||||
CopyBgTilemapBufferToVram(1);
|
||||
}
|
||||
|
||||
+30
-30
@@ -125,14 +125,14 @@ static void CreateLinkPlayerSprite(u8 linkPlayerId, u8 gameVersion);
|
||||
static void GetLinkPlayerCoords(u8 linkPlayerId, u16 *x, u16 *y);
|
||||
static u8 GetLinkPlayerFacingDirection(u8 linkPlayerId);
|
||||
static u8 GetLinkPlayerElevation(u8 linkPlayerId);
|
||||
static s32 sub_80878E4(u8 linkPlayerId);
|
||||
static s32 GetLinkPlayerObjectStepTimer(u8 linkPlayerId);
|
||||
static u8 GetLinkPlayerIdAt(s16 x, s16 y);
|
||||
static void SetPlayerFacingDirection(u8 linkPlayerId, u8 a2);
|
||||
static void ZeroObjectEvent(struct ObjectEvent *objEvent);
|
||||
static void SpawnLinkPlayerObjectEvent(u8 linkPlayerId, s16 x, s16 y, u8 a4);
|
||||
static void InitLinkPlayerObjectEventPos(struct ObjectEvent *objEvent, s16 x, s16 y);
|
||||
static void sub_80877DC(u8 linkPlayerId, u8 a2);
|
||||
static void sub_808780C(u8 linkPlayerId);
|
||||
static void SetLinkPlayerObjectRange(u8 linkPlayerId, u8 a2);
|
||||
static void DestroyLinkPlayerObject(u8 linkPlayerId);
|
||||
static u8 GetSpriteForLinkedPlayer(u8 linkPlayerId);
|
||||
static void RunTerminateLinkScript(void);
|
||||
static u32 GetLinkSendQueueLength(void);
|
||||
@@ -172,7 +172,7 @@ static u8 sPlayerTradingStates[MAX_LINK_PLAYERS];
|
||||
// adjusted key code, effectively intercepting the input before anything
|
||||
// can process it.
|
||||
static u16 (*sPlayerKeyInterceptCallback)(u32);
|
||||
static bool8 sUnknown_03000E18;
|
||||
static bool8 sReceivingFromLink;
|
||||
static u8 sRfuKeepAliveTimer;
|
||||
|
||||
// IWRAM common
|
||||
@@ -1626,7 +1626,7 @@ static void CB2_ReturnToFieldLocal(void)
|
||||
|
||||
static void CB2_ReturnToFieldLink(void)
|
||||
{
|
||||
if (!sub_8087598() && ReturnToFieldLink(&gMain.state))
|
||||
if (!Overworld_LinkRecvQueueLengthMoreThan2() && ReturnToFieldLink(&gMain.state))
|
||||
SetMainCallback2(CB2_Overworld);
|
||||
}
|
||||
|
||||
@@ -2823,18 +2823,18 @@ static void RunTerminateLinkScript(void)
|
||||
ScriptContext2_Enable();
|
||||
}
|
||||
|
||||
bool32 sub_8087598(void)
|
||||
bool32 Overworld_LinkRecvQueueLengthMoreThan2(void)
|
||||
{
|
||||
if (!IsUpdateLinkStateCBActive())
|
||||
return FALSE;
|
||||
if (GetLinkRecvQueueLength() >= 3)
|
||||
sUnknown_03000E18 = TRUE;
|
||||
sReceivingFromLink = TRUE;
|
||||
else
|
||||
sUnknown_03000E18 = FALSE;
|
||||
return sUnknown_03000E18;
|
||||
sReceivingFromLink = FALSE;
|
||||
return sReceivingFromLink;
|
||||
}
|
||||
|
||||
bool32 sub_80875C8(void)
|
||||
bool32 Overworld_RecvKeysFromLinkIsRunning(void)
|
||||
{
|
||||
u8 temp;
|
||||
|
||||
@@ -2849,8 +2849,8 @@ bool32 sub_80875C8(void)
|
||||
else if (sPlayerKeyInterceptCallback != KeyInterCB_DeferToEventScript)
|
||||
return FALSE;
|
||||
|
||||
temp = sUnknown_03000E18;
|
||||
sUnknown_03000E18 = FALSE;
|
||||
temp = sReceivingFromLink;
|
||||
sReceivingFromLink = FALSE;
|
||||
|
||||
if (temp == TRUE)
|
||||
return TRUE;
|
||||
@@ -2860,7 +2860,7 @@ bool32 sub_80875C8(void)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool32 sub_8087634(void)
|
||||
bool32 Overworld_SendKeysToLinkIsRunning(void)
|
||||
{
|
||||
if (GetLinkSendQueueLength() < 2)
|
||||
return FALSE;
|
||||
@@ -2874,7 +2874,7 @@ bool32 sub_8087634(void)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool32 sub_808766C(void)
|
||||
bool32 IsSendingKeysOverCable(void)
|
||||
{
|
||||
if (gWirelessCommType != 0)
|
||||
return FALSE;
|
||||
@@ -2923,15 +2923,15 @@ static void SpawnLinkPlayerObjectEvent(u8 linkPlayerId, s16 x, s16 y, u8 gender)
|
||||
ZeroLinkPlayerObjectEvent(linkPlayerObjEvent);
|
||||
ZeroObjectEvent(objEvent);
|
||||
|
||||
linkPlayerObjEvent->active = 1;
|
||||
linkPlayerObjEvent->active = TRUE;
|
||||
linkPlayerObjEvent->linkPlayerId = linkPlayerId;
|
||||
linkPlayerObjEvent->objEventId = objEventId;
|
||||
linkPlayerObjEvent->movementMode = MOVEMENT_MODE_FREE;
|
||||
|
||||
objEvent->active = 1;
|
||||
objEvent->active = TRUE;
|
||||
linkGender(objEvent) = gender;
|
||||
linkDirection(objEvent) = DIR_NORTH;
|
||||
objEvent->spriteId = 64;
|
||||
objEvent->spriteId = MAX_SPRITES;
|
||||
|
||||
InitLinkPlayerObjectEventPos(objEvent, x, y);
|
||||
}
|
||||
@@ -2947,7 +2947,7 @@ static void InitLinkPlayerObjectEventPos(struct ObjectEvent *objEvent, s16 x, s1
|
||||
ObjectEventUpdateZCoord(objEvent);
|
||||
}
|
||||
|
||||
static void sub_80877DC(u8 linkPlayerId, u8 dir)
|
||||
static void SetLinkPlayerObjectRange(u8 linkPlayerId, u8 dir)
|
||||
{
|
||||
if (gLinkPlayerObjectEvents[linkPlayerId].active)
|
||||
{
|
||||
@@ -2957,7 +2957,7 @@ static void sub_80877DC(u8 linkPlayerId, u8 dir)
|
||||
}
|
||||
}
|
||||
|
||||
static void sub_808780C(u8 linkPlayerId)
|
||||
static void DestroyLinkPlayerObject(u8 linkPlayerId)
|
||||
{
|
||||
struct LinkPlayerObjectEvent *linkPlayerObjEvent = &gLinkPlayerObjectEvents[linkPlayerId];
|
||||
u8 objEventId = linkPlayerObjEvent->objEventId;
|
||||
@@ -2998,7 +2998,7 @@ static u8 GetLinkPlayerElevation(u8 linkPlayerId)
|
||||
return objEvent->currentElevation;
|
||||
}
|
||||
|
||||
static s32 sub_80878E4(u8 linkPlayerId)
|
||||
static s32 GetLinkPlayerObjectStepTimer(u8 linkPlayerId)
|
||||
{
|
||||
u8 objEventId = gLinkPlayerObjectEvents[linkPlayerId].objEventId;
|
||||
struct ObjectEvent *objEvent = &gObjectEvents[objEventId];
|
||||
@@ -3048,32 +3048,32 @@ static void SetPlayerFacingDirection(u8 linkPlayerId, u8 facing)
|
||||
}
|
||||
|
||||
|
||||
static u8 MovementEventModeCB_Normal(struct LinkPlayerObjectEvent *linkPlayerObjEvent, struct ObjectEvent *objEvent, u8 a3)
|
||||
static u8 MovementEventModeCB_Normal(struct LinkPlayerObjectEvent *linkPlayerObjEvent, struct ObjectEvent *objEvent, u8 dir)
|
||||
{
|
||||
return gLinkPlayerFacingHandlers[a3](linkPlayerObjEvent, objEvent, a3);
|
||||
return gLinkPlayerFacingHandlers[dir](linkPlayerObjEvent, objEvent, dir);
|
||||
}
|
||||
|
||||
static u8 MovementEventModeCB_Ignored(struct LinkPlayerObjectEvent *linkPlayerObjEvent, struct ObjectEvent *objEvent, u8 a3)
|
||||
static u8 MovementEventModeCB_Ignored(struct LinkPlayerObjectEvent *linkPlayerObjEvent, struct ObjectEvent *objEvent, u8 dir)
|
||||
{
|
||||
return FACING_UP;
|
||||
}
|
||||
|
||||
// Duplicate Function
|
||||
static u8 MovementEventModeCB_Normal_2(struct LinkPlayerObjectEvent *linkPlayerObjEvent, struct ObjectEvent *objEvent, u8 a3)
|
||||
static u8 MovementEventModeCB_Normal_2(struct LinkPlayerObjectEvent *linkPlayerObjEvent, struct ObjectEvent *objEvent, u8 dir)
|
||||
{
|
||||
return gLinkPlayerFacingHandlers[a3](linkPlayerObjEvent, objEvent, a3);
|
||||
return gLinkPlayerFacingHandlers[dir](linkPlayerObjEvent, objEvent, dir);
|
||||
}
|
||||
|
||||
static bool8 FacingHandler_DoNothing(struct LinkPlayerObjectEvent *linkPlayerObjEvent, struct ObjectEvent *objEvent, u8 a3)
|
||||
static bool8 FacingHandler_DoNothing(struct LinkPlayerObjectEvent *linkPlayerObjEvent, struct ObjectEvent *objEvent, u8 dir)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static bool8 FacingHandler_DpadMovement(struct LinkPlayerObjectEvent *linkPlayerObjEvent, struct ObjectEvent *objEvent, u8 a3)
|
||||
static bool8 FacingHandler_DpadMovement(struct LinkPlayerObjectEvent *linkPlayerObjEvent, struct ObjectEvent *objEvent, u8 dir)
|
||||
{
|
||||
s16 x, y;
|
||||
|
||||
linkDirection(objEvent) = FlipVerticalAndClearForced(a3, linkDirection(objEvent));
|
||||
linkDirection(objEvent) = FlipVerticalAndClearForced(dir, linkDirection(objEvent));
|
||||
ObjectEventMoveDestCoords(objEvent, linkDirection(objEvent), &x, &y);
|
||||
|
||||
if (LinkPlayerDetectCollision(linkPlayerObjEvent->objEventId, linkDirection(objEvent), x, y))
|
||||
@@ -3089,9 +3089,9 @@ static bool8 FacingHandler_DpadMovement(struct LinkPlayerObjectEvent *linkPlayer
|
||||
}
|
||||
}
|
||||
|
||||
static bool8 FacingHandler_ForcedFacingChange(struct LinkPlayerObjectEvent *linkPlayerObjEvent, struct ObjectEvent *objEvent, u8 a3)
|
||||
static bool8 FacingHandler_ForcedFacingChange(struct LinkPlayerObjectEvent *linkPlayerObjEvent, struct ObjectEvent *objEvent, u8 dir)
|
||||
{
|
||||
linkDirection(objEvent) = FlipVerticalAndClearForced(a3, linkDirection(objEvent));
|
||||
linkDirection(objEvent) = FlipVerticalAndClearForced(dir, linkDirection(objEvent));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -4904,7 +4904,7 @@ void ItemUseCB_RareCandy(u8 taskId, TaskFunc task)
|
||||
else
|
||||
{
|
||||
gPartyMenuUseExitCallback = TRUE;
|
||||
PlayFanfareByFanfareNum(0);
|
||||
PlayFanfareByFanfareNum(FANFARE_LEVEL_UP);
|
||||
UpdateMonDisplayInfoAfterRareCandy(gPartyMenu.slotId, mon);
|
||||
RemoveBagItem(gSpecialVar_ItemId, 1);
|
||||
GetMonNickname(mon, gStringVar1);
|
||||
|
||||
+1
-10
@@ -3032,17 +3032,8 @@ static void SpriteCB_PokedexListMonSprite(struct Sprite *sprite)
|
||||
else
|
||||
{
|
||||
u32 var;
|
||||
|
||||
sprite->pos2.y = gSineTable[(u8)sprite->data[5]] * 76 / 256;
|
||||
// UB: possible division by zero
|
||||
#ifdef UBFIX
|
||||
if (gSineTable[sprite->data[5] + 64] != 0)
|
||||
var = 0x10000 / gSineTable[sprite->data[5] + 64];
|
||||
else
|
||||
var = 0;
|
||||
#else
|
||||
var = 0x10000 / gSineTable[sprite->data[5] + 64];
|
||||
#endif //UBFIX
|
||||
var = SAFE_DIV(0x10000, gSineTable[sprite->data[5] + 64]);
|
||||
if (var > 0xFFFF)
|
||||
var = 0xFFFF;
|
||||
SetOamMatrix(sprite->data[1] + 1, 0x100, 0, 0, var);
|
||||
|
||||
+2
-2
@@ -4649,7 +4649,7 @@ bool8 ExecuteTableBasedItemEffect(struct Pokemon *mon, u16 item, u8 partyIndex,
|
||||
{ \
|
||||
friendshipChange = itemEffect[itemEffectParam]; \
|
||||
friendship = GetMonData(mon, MON_DATA_FRIENDSHIP, NULL); \
|
||||
if (friendshipChange > 0 && holdEffect == HOLD_EFFECT_HAPPINESS_UP) \
|
||||
if (friendshipChange > 0 && holdEffect == HOLD_EFFECT_FRIENDSHIP_UP) \
|
||||
friendship += 150 * friendshipChange / 100; \
|
||||
else \
|
||||
friendship += friendshipChange; \
|
||||
@@ -5828,7 +5828,7 @@ void AdjustFriendship(struct Pokemon *mon, u8 event)
|
||||
&& (event != FRIENDSHIP_EVENT_LEAGUE_BATTLE || IS_LEAGUE_BATTLE))
|
||||
{
|
||||
s8 mod = sFriendshipEventModifiers[event][friendshipLevel];
|
||||
if (mod > 0 && holdEffect == HOLD_EFFECT_HAPPINESS_UP)
|
||||
if (mod > 0 && holdEffect == HOLD_EFFECT_FRIENDSHIP_UP)
|
||||
mod = (150 * mod) / 100;
|
||||
friendship += mod;
|
||||
if (mod > 0)
|
||||
|
||||
+14
-12
@@ -131,14 +131,16 @@ enum {
|
||||
#define TAG_MON4 3
|
||||
#define TAG_MON5 4
|
||||
|
||||
#define GFXTAG_VINE1 5
|
||||
#define GFXTAG_VINE2 6
|
||||
#define GFXTAG_VINE3 7
|
||||
#define GFXTAG_VINE4 8
|
||||
#define GFXTAG_STAR 10
|
||||
#define GFXTAG_VINE1 5
|
||||
#define GFXTAG_VINE2 6
|
||||
#define GFXTAG_VINE3 7
|
||||
#define GFXTAG_VINE4 8
|
||||
#define GFXTAG_COUNTDOWN 9
|
||||
#define GFXTAG_STAR 10
|
||||
|
||||
#define PALTAG_1 5
|
||||
#define PALTAG_2 6
|
||||
#define PALTAG_1 5
|
||||
#define PALTAG_2 6
|
||||
#define PALTAG_COUNTDOWN 7
|
||||
|
||||
#define TAG_DIGITS 800
|
||||
|
||||
@@ -2646,13 +2648,13 @@ static const struct OamData sOamData_Star =
|
||||
.affineParam = 0
|
||||
};
|
||||
|
||||
static const union AnimCmd sSpriteAnim_82FBFE0[] =
|
||||
static const union AnimCmd sAnim_Star_Still[] =
|
||||
{
|
||||
ANIMCMD_FRAME(0, 0),
|
||||
ANIMCMD_END
|
||||
};
|
||||
|
||||
static const union AnimCmd sSpriteAnim_82FBFE8[] =
|
||||
static const union AnimCmd sAnim_Star_Spinning[] =
|
||||
{
|
||||
ANIMCMD_FRAME(0, 4),
|
||||
ANIMCMD_FRAME(4, 4),
|
||||
@@ -2665,8 +2667,8 @@ static const union AnimCmd sSpriteAnim_82FBFE8[] =
|
||||
|
||||
static const union AnimCmd *const sAnims_Star[] =
|
||||
{
|
||||
sSpriteAnim_82FBFE0,
|
||||
sSpriteAnim_82FBFE8
|
||||
sAnim_Star_Still,
|
||||
sAnim_Star_Spinning
|
||||
};
|
||||
|
||||
static const struct SpriteTemplate sSpriteTemplate_Star =
|
||||
@@ -3007,7 +3009,7 @@ static void UpdateVineAnim(struct PokemonJumpGfx *jumpGfx, int vineState)
|
||||
|
||||
static void StartPokeJumpCountdown(struct PokemonJumpGfx *jumpGfx)
|
||||
{
|
||||
StartMinigameCountdown(9, 7, 120, 80, 0);
|
||||
StartMinigameCountdown(GFXTAG_COUNTDOWN, PALTAG_COUNTDOWN, 120, 80, 0);
|
||||
Gfx_ResetMonSpriteSubpriorities(jumpGfx);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -288,7 +288,7 @@ static void Task_RunLoopedTask_LinkMode(u8 taskId)
|
||||
s16 *state;
|
||||
u32 action;
|
||||
|
||||
if (sub_8087598())
|
||||
if (Overworld_LinkRecvQueueLengthMoreThan2())
|
||||
return;
|
||||
|
||||
task = (LoopedTask)GetWordTaskArg(taskId, 1);
|
||||
|
||||
@@ -84,7 +84,7 @@ EWRAM_DATA static u8 sFrontierFacility = 0;
|
||||
EWRAM_DATA static u8 sFrontierBrainSymbol = 0;
|
||||
EWRAM_DATA static MainCallback sCallback2_AfterRecordedBattle = NULL;
|
||||
EWRAM_DATA u8 gRecordedBattleMultiplayerId = 0;
|
||||
EWRAM_DATA static u8 sUnknown_0203C7B5 = 0;
|
||||
EWRAM_DATA static u8 sFrontierPassFlag = 0;
|
||||
EWRAM_DATA static u8 sBattleScene = 0;
|
||||
EWRAM_DATA static u8 sTextSpeed = 0;
|
||||
EWRAM_DATA static u32 sBattleFlags = 0;
|
||||
@@ -687,19 +687,20 @@ u8 GetActiveBattlerLinkPlayerGender(void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void sub_8185F84(void)
|
||||
void RecordedBattle_ClearFrontierPassFlag(void)
|
||||
{
|
||||
sUnknown_0203C7B5 = 0;
|
||||
sFrontierPassFlag = 0;
|
||||
}
|
||||
|
||||
void sub_8185F90(u16 arg0)
|
||||
// Set sFrontierPassFlag to received state of FLAG_SYS_FRONTIER_PASS
|
||||
void RecordedBattle_SetFrontierPassFlagFromHword(u16 arg0)
|
||||
{
|
||||
sUnknown_0203C7B5 |= (arg0 & 0x8000) >> 0xF;
|
||||
sFrontierPassFlag |= (arg0 & 0x8000) >> 15;
|
||||
}
|
||||
|
||||
u8 sub_8185FAC(void)
|
||||
u8 RecordedBattle_GetFrontierPassFlag(void)
|
||||
{
|
||||
return sUnknown_0203C7B5;
|
||||
return sFrontierPassFlag;
|
||||
}
|
||||
|
||||
u8 GetBattleSceneInRecordedBattle(void)
|
||||
|
||||
+130
-131
@@ -40,11 +40,14 @@
|
||||
#include "constants/songs.h"
|
||||
#include "constants/tv.h"
|
||||
|
||||
EWRAM_DATA struct MartInfo gMartInfo = {0};
|
||||
EWRAM_DATA struct ShopData *gShopDataPtr = NULL;
|
||||
EWRAM_DATA struct ListMenuItem *gUnknown_02039F74 = NULL;
|
||||
EWRAM_DATA u8 (*gUnknown_02039F78)[16] = {0};
|
||||
EWRAM_DATA u8 gMartPurchaseHistoryId = 0;
|
||||
#define TAG_SCROLL_ARROW 2100
|
||||
#define TAG_ITEM_ICON_BASE 2110
|
||||
|
||||
static EWRAM_DATA struct MartInfo sMartInfo = {0};
|
||||
static EWRAM_DATA struct ShopData *sShopData = NULL;
|
||||
static EWRAM_DATA struct ListMenuItem *sListMenuItems = NULL;
|
||||
static EWRAM_DATA u8 (*sItemNames)[16] = {0};
|
||||
static EWRAM_DATA u8 sPurchaseHistoryId = 0;
|
||||
EWRAM_DATA struct ItemSlot gMartPurchaseHistory[3] = {0};
|
||||
|
||||
static void Task_ShopMenu(u8 taskId);
|
||||
@@ -276,15 +279,15 @@ static u8 CreateShopMenu(u8 martType)
|
||||
int numMenuItems;
|
||||
|
||||
ScriptContext2_Enable();
|
||||
gMartInfo.martType = martType;
|
||||
sMartInfo.martType = martType;
|
||||
|
||||
if (martType == MART_TYPE_NORMAL)
|
||||
{
|
||||
struct WindowTemplate winTemplate;
|
||||
winTemplate = sShopMenuWindowTemplates[0];
|
||||
winTemplate.width = GetMaxWidthInMenuTable(sShopMenuActions_BuySellQuit, ARRAY_COUNT(sShopMenuActions_BuySellQuit));
|
||||
gMartInfo.windowId = AddWindow(&winTemplate);
|
||||
gMartInfo.menuActions = sShopMenuActions_BuySellQuit;
|
||||
sMartInfo.windowId = AddWindow(&winTemplate);
|
||||
sMartInfo.menuActions = sShopMenuActions_BuySellQuit;
|
||||
numMenuItems = ARRAY_COUNT(sShopMenuActions_BuySellQuit);
|
||||
}
|
||||
else
|
||||
@@ -292,35 +295,35 @@ static u8 CreateShopMenu(u8 martType)
|
||||
struct WindowTemplate winTemplate;
|
||||
winTemplate = sShopMenuWindowTemplates[1];
|
||||
winTemplate.width = GetMaxWidthInMenuTable(sShopMenuActions_BuyQuit, ARRAY_COUNT(sShopMenuActions_BuyQuit));
|
||||
gMartInfo.windowId = AddWindow(&winTemplate);
|
||||
gMartInfo.menuActions = sShopMenuActions_BuyQuit;
|
||||
sMartInfo.windowId = AddWindow(&winTemplate);
|
||||
sMartInfo.menuActions = sShopMenuActions_BuyQuit;
|
||||
numMenuItems = ARRAY_COUNT(sShopMenuActions_BuyQuit);
|
||||
}
|
||||
|
||||
SetStandardWindowBorderStyle(gMartInfo.windowId, 0);
|
||||
PrintMenuTable(gMartInfo.windowId, numMenuItems, gMartInfo.menuActions);
|
||||
InitMenuInUpperLeftCornerPlaySoundWhenAPressed(gMartInfo.windowId, numMenuItems, 0);
|
||||
PutWindowTilemap(gMartInfo.windowId);
|
||||
CopyWindowToVram(gMartInfo.windowId, 1);
|
||||
SetStandardWindowBorderStyle(sMartInfo.windowId, 0);
|
||||
PrintMenuTable(sMartInfo.windowId, numMenuItems, sMartInfo.menuActions);
|
||||
InitMenuInUpperLeftCornerPlaySoundWhenAPressed(sMartInfo.windowId, numMenuItems, 0);
|
||||
PutWindowTilemap(sMartInfo.windowId);
|
||||
CopyWindowToVram(sMartInfo.windowId, 1);
|
||||
|
||||
return CreateTask(Task_ShopMenu, 8);
|
||||
}
|
||||
|
||||
static void SetShopMenuCallback(void (* callback)(void))
|
||||
{
|
||||
gMartInfo.callback = callback;
|
||||
sMartInfo.callback = callback;
|
||||
}
|
||||
|
||||
static void SetShopItemsForSale(const u16 *items)
|
||||
{
|
||||
u16 i = 0;
|
||||
|
||||
gMartInfo.itemList = items;
|
||||
gMartInfo.itemCount = 0;
|
||||
sMartInfo.itemList = items;
|
||||
sMartInfo.itemCount = 0;
|
||||
|
||||
while (gMartInfo.itemList[i])
|
||||
while (sMartInfo.itemList[i])
|
||||
{
|
||||
gMartInfo.itemCount++;
|
||||
sMartInfo.itemCount++;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
@@ -337,7 +340,7 @@ static void Task_ShopMenu(u8 taskId)
|
||||
Task_HandleShopMenuQuit(taskId);
|
||||
break;
|
||||
default:
|
||||
gMartInfo.menuActions[inputCode].func.void_u8(taskId);
|
||||
sMartInfo.menuActions[inputCode].func.void_u8(taskId);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -368,14 +371,14 @@ void CB2_ExitSellMenu(void)
|
||||
|
||||
static void Task_HandleShopMenuQuit(u8 taskId)
|
||||
{
|
||||
ClearStdWindowAndFrameToTransparent(gMartInfo.windowId, 2);
|
||||
RemoveWindow(gMartInfo.windowId);
|
||||
ClearStdWindowAndFrameToTransparent(sMartInfo.windowId, 2);
|
||||
RemoveWindow(sMartInfo.windowId);
|
||||
SaveRecordedItemPurchasesForTVShow();
|
||||
ScriptContext2_Disable();
|
||||
DestroyTask(taskId);
|
||||
|
||||
if (gMartInfo.callback)
|
||||
gMartInfo.callback();
|
||||
if (sMartInfo.callback)
|
||||
sMartInfo.callback();
|
||||
}
|
||||
|
||||
static void Task_GoToBuyOrSellMenu(u8 taskId)
|
||||
@@ -398,7 +401,7 @@ static void Task_ReturnToShopMenu(u8 taskId)
|
||||
{
|
||||
if (IsWeatherNotFadingIn() == TRUE)
|
||||
{
|
||||
if (gMartInfo.martType == MART_TYPE_DECOR2)
|
||||
if (sMartInfo.martType == MART_TYPE_DECOR2)
|
||||
DisplayItemMessageOnField(taskId, gText_CanIHelpWithAnythingElse, ShowShopMenuAfterExitingBuyOrSellMenu);
|
||||
else
|
||||
DisplayItemMessageOnField(taskId, gText_AnythingElseICanHelp, ShowShopMenuAfterExitingBuyOrSellMenu);
|
||||
@@ -407,7 +410,7 @@ static void Task_ReturnToShopMenu(u8 taskId)
|
||||
|
||||
static void ShowShopMenuAfterExitingBuyOrSellMenu(u8 taskId)
|
||||
{
|
||||
CreateShopMenu(gMartInfo.martType);
|
||||
CreateShopMenu(sMartInfo.martType);
|
||||
DestroyTask(taskId);
|
||||
}
|
||||
|
||||
@@ -447,10 +450,10 @@ static void CB2_InitBuyMenu(void)
|
||||
ResetSpriteData();
|
||||
ResetTasks();
|
||||
ClearScheduledBgCopiesToVram();
|
||||
gShopDataPtr = AllocZeroed(sizeof(struct ShopData));
|
||||
gShopDataPtr->scrollIndicatorsTaskId = TASK_NONE;
|
||||
gShopDataPtr->itemSpriteIds[0] = SPRITE_NONE;
|
||||
gShopDataPtr->itemSpriteIds[1] = SPRITE_NONE;
|
||||
sShopData = AllocZeroed(sizeof(struct ShopData));
|
||||
sShopData->scrollIndicatorsTaskId = TASK_NONE;
|
||||
sShopData->itemSpriteIds[0] = SPRITE_NONE;
|
||||
sShopData->itemSpriteIds[1] = SPRITE_NONE;
|
||||
BuyMenuBuildListMenuTemplate();
|
||||
BuyMenuInitBgs();
|
||||
FillBgTilemapBufferRect_Palette0(0, 0, 0, 0, 0x20, 0x20);
|
||||
@@ -480,9 +483,9 @@ static void CB2_InitBuyMenu(void)
|
||||
|
||||
static void BuyMenuFreeMemory(void)
|
||||
{
|
||||
Free(gShopDataPtr);
|
||||
Free(gUnknown_02039F74);
|
||||
Free(gUnknown_02039F78);
|
||||
Free(sShopData);
|
||||
Free(sListMenuItems);
|
||||
Free(sItemNames);
|
||||
FreeAllWindowBuffers();
|
||||
}
|
||||
|
||||
@@ -490,29 +493,29 @@ static void BuyMenuBuildListMenuTemplate(void)
|
||||
{
|
||||
u16 i;
|
||||
|
||||
gUnknown_02039F74 = Alloc((gMartInfo.itemCount + 1) * sizeof(*gUnknown_02039F74));
|
||||
gUnknown_02039F78 = Alloc((gMartInfo.itemCount + 1) * sizeof(*gUnknown_02039F78));
|
||||
for (i = 0; i < gMartInfo.itemCount; i++)
|
||||
BuyMenuSetListEntry(&gUnknown_02039F74[i], gMartInfo.itemList[i], gUnknown_02039F78[i]);
|
||||
sListMenuItems = Alloc((sMartInfo.itemCount + 1) * sizeof(*sListMenuItems));
|
||||
sItemNames = Alloc((sMartInfo.itemCount + 1) * sizeof(*sItemNames));
|
||||
for (i = 0; i < sMartInfo.itemCount; i++)
|
||||
BuyMenuSetListEntry(&sListMenuItems[i], sMartInfo.itemList[i], sItemNames[i]);
|
||||
|
||||
StringCopy(gUnknown_02039F78[i], gText_Cancel2);
|
||||
gUnknown_02039F74[i].name = gUnknown_02039F78[i];
|
||||
gUnknown_02039F74[i].id = -2;
|
||||
StringCopy(sItemNames[i], gText_Cancel2);
|
||||
sListMenuItems[i].name = sItemNames[i];
|
||||
sListMenuItems[i].id = LIST_CANCEL;
|
||||
|
||||
gMultiuseListMenuTemplate = sShopBuyMenuListTemplate;
|
||||
gMultiuseListMenuTemplate.items = gUnknown_02039F74;
|
||||
gMultiuseListMenuTemplate.totalItems = gMartInfo.itemCount + 1;
|
||||
gMultiuseListMenuTemplate.items = sListMenuItems;
|
||||
gMultiuseListMenuTemplate.totalItems = sMartInfo.itemCount + 1;
|
||||
if (gMultiuseListMenuTemplate.totalItems > 8)
|
||||
gMultiuseListMenuTemplate.maxShowed = 8;
|
||||
else
|
||||
gMultiuseListMenuTemplate.maxShowed = gMultiuseListMenuTemplate.totalItems;
|
||||
|
||||
gShopDataPtr->itemsShowed = gMultiuseListMenuTemplate.maxShowed;
|
||||
sShopData->itemsShowed = gMultiuseListMenuTemplate.maxShowed;
|
||||
}
|
||||
|
||||
static void BuyMenuSetListEntry(struct ListMenuItem *menuItem, u16 item, u8 *name)
|
||||
{
|
||||
if (gMartInfo.martType == MART_TYPE_NORMAL)
|
||||
if (sMartInfo.martType == MART_TYPE_NORMAL)
|
||||
CopyItemName(item, name);
|
||||
else
|
||||
StringCopy(name, gDecorations[item].name);
|
||||
@@ -527,16 +530,16 @@ static void BuyMenuPrintItemDescriptionAndShowItemIcon(s32 item, bool8 onInit, s
|
||||
if (onInit != TRUE)
|
||||
PlaySE(SE_SELECT);
|
||||
|
||||
if (item != -2)
|
||||
BuyMenuAddItemIcon(item, gShopDataPtr->iconSlot);
|
||||
if (item != LIST_CANCEL)
|
||||
BuyMenuAddItemIcon(item, sShopData->iconSlot);
|
||||
else
|
||||
BuyMenuAddItemIcon(-1, gShopDataPtr->iconSlot);
|
||||
BuyMenuAddItemIcon(-1, sShopData->iconSlot);
|
||||
|
||||
BuyMenuRemoveItemIcon(item, gShopDataPtr->iconSlot ^ 1);
|
||||
gShopDataPtr->iconSlot ^= 1;
|
||||
if (item != -2)
|
||||
BuyMenuRemoveItemIcon(item, sShopData->iconSlot ^ 1);
|
||||
sShopData->iconSlot ^= 1;
|
||||
if (item != LIST_CANCEL)
|
||||
{
|
||||
if (gMartInfo.martType == MART_TYPE_NORMAL)
|
||||
if (sMartInfo.martType == MART_TYPE_NORMAL)
|
||||
description = ItemId_GetDescription(item);
|
||||
else
|
||||
description = gDecorations[item].description;
|
||||
@@ -554,9 +557,9 @@ static void BuyMenuPrintPriceInList(u8 windowId, s32 item, u8 y)
|
||||
{
|
||||
u8 x;
|
||||
|
||||
if (item != -2)
|
||||
if (item != LIST_CANCEL)
|
||||
{
|
||||
if (gMartInfo.martType == MART_TYPE_NORMAL)
|
||||
if (sMartInfo.martType == MART_TYPE_NORMAL)
|
||||
{
|
||||
ConvertIntToDecimalStringN(
|
||||
gStringVar1,
|
||||
@@ -581,26 +584,26 @@ static void BuyMenuPrintPriceInList(u8 windowId, s32 item, u8 y)
|
||||
|
||||
static void BuyMenuAddScrollIndicatorArrows(void)
|
||||
{
|
||||
if (gShopDataPtr->scrollIndicatorsTaskId == TASK_NONE && gMartInfo.itemCount + 1 > 8)
|
||||
if (sShopData->scrollIndicatorsTaskId == TASK_NONE && sMartInfo.itemCount + 1 > 8)
|
||||
{
|
||||
gShopDataPtr->scrollIndicatorsTaskId = AddScrollIndicatorArrowPairParameterized(
|
||||
sShopData->scrollIndicatorsTaskId = AddScrollIndicatorArrowPairParameterized(
|
||||
SCROLL_ARROW_UP,
|
||||
0xAC,
|
||||
0xC,
|
||||
0x94,
|
||||
gMartInfo.itemCount - 7,
|
||||
2100,
|
||||
2100,
|
||||
&gShopDataPtr->scrollOffset);
|
||||
172,
|
||||
12,
|
||||
148,
|
||||
sMartInfo.itemCount - 7,
|
||||
TAG_SCROLL_ARROW,
|
||||
TAG_SCROLL_ARROW,
|
||||
&sShopData->scrollOffset);
|
||||
}
|
||||
}
|
||||
|
||||
static void BuyMenuRemoveScrollIndicatorArrows(void)
|
||||
{
|
||||
if (gShopDataPtr->scrollIndicatorsTaskId != TASK_NONE)
|
||||
if (sShopData->scrollIndicatorsTaskId != TASK_NONE)
|
||||
{
|
||||
RemoveScrollIndicatorArrowPair(gShopDataPtr->scrollIndicatorsTaskId);
|
||||
gShopDataPtr->scrollIndicatorsTaskId = TASK_NONE;
|
||||
RemoveScrollIndicatorArrowPair(sShopData->scrollIndicatorsTaskId);
|
||||
sShopData->scrollIndicatorsTaskId = TASK_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -613,13 +616,13 @@ static void BuyMenuPrintCursor(u8 scrollIndicatorsTaskId, u8 colorSet)
|
||||
static void BuyMenuAddItemIcon(u16 item, u8 iconSlot)
|
||||
{
|
||||
u8 spriteId;
|
||||
u8 *spriteIdPtr = &gShopDataPtr->itemSpriteIds[iconSlot];
|
||||
u8 *spriteIdPtr = &sShopData->itemSpriteIds[iconSlot];
|
||||
if (*spriteIdPtr != SPRITE_NONE)
|
||||
return;
|
||||
|
||||
if (gMartInfo.martType == MART_TYPE_NORMAL || item == 0xFFFF)
|
||||
if (sMartInfo.martType == MART_TYPE_NORMAL || item == 0xFFFF)
|
||||
{
|
||||
spriteId = AddItemIconSprite(iconSlot + 2110, iconSlot + 2110, item);
|
||||
spriteId = AddItemIconSprite(iconSlot + TAG_ITEM_ICON_BASE, iconSlot + TAG_ITEM_ICON_BASE, item);
|
||||
if (spriteId != MAX_SPRITES)
|
||||
{
|
||||
*spriteIdPtr = spriteId;
|
||||
@@ -629,7 +632,7 @@ static void BuyMenuAddItemIcon(u16 item, u8 iconSlot)
|
||||
}
|
||||
else
|
||||
{
|
||||
spriteId = AddDecorationIconObject(item, 20, 84, 1, iconSlot + 2110, iconSlot + 2110);
|
||||
spriteId = AddDecorationIconObject(item, 20, 84, 1, iconSlot + TAG_ITEM_ICON_BASE, iconSlot + TAG_ITEM_ICON_BASE);
|
||||
if (spriteId != MAX_SPRITES)
|
||||
*spriteIdPtr = spriteId;
|
||||
}
|
||||
@@ -637,12 +640,12 @@ static void BuyMenuAddItemIcon(u16 item, u8 iconSlot)
|
||||
|
||||
static void BuyMenuRemoveItemIcon(u16 item, u8 iconSlot)
|
||||
{
|
||||
u8 *spriteIdPtr = &gShopDataPtr->itemSpriteIds[iconSlot];
|
||||
u8 *spriteIdPtr = &sShopData->itemSpriteIds[iconSlot];
|
||||
if (*spriteIdPtr == SPRITE_NONE)
|
||||
return;
|
||||
|
||||
FreeSpriteTilesByTag(iconSlot + 2110);
|
||||
FreeSpritePaletteByTag(iconSlot + 2110);
|
||||
FreeSpriteTilesByTag(iconSlot + TAG_ITEM_ICON_BASE);
|
||||
FreeSpritePaletteByTag(iconSlot + TAG_ITEM_ICON_BASE);
|
||||
DestroySprite(&gSprites[*spriteIdPtr]);
|
||||
*spriteIdPtr = SPRITE_NONE;
|
||||
}
|
||||
@@ -651,9 +654,9 @@ static void BuyMenuInitBgs(void)
|
||||
{
|
||||
ResetBgsAndClearDma3BusyFlags(0);
|
||||
InitBgsFromTemplates(0, sShopBuyMenuBgTemplates, ARRAY_COUNT(sShopBuyMenuBgTemplates));
|
||||
SetBgTilemapBuffer(1, gShopDataPtr->tilemapBuffers[1]);
|
||||
SetBgTilemapBuffer(2, gShopDataPtr->tilemapBuffers[3]);
|
||||
SetBgTilemapBuffer(3, gShopDataPtr->tilemapBuffers[2]);
|
||||
SetBgTilemapBuffer(1, sShopData->tilemapBuffers[1]);
|
||||
SetBgTilemapBuffer(2, sShopData->tilemapBuffers[3]);
|
||||
SetBgTilemapBuffer(3, sShopData->tilemapBuffers[2]);
|
||||
SetGpuReg(REG_OFFSET_BG0HOFS, 0);
|
||||
SetGpuReg(REG_OFFSET_BG0VOFS, 0);
|
||||
SetGpuReg(REG_OFFSET_BG1HOFS, 0);
|
||||
@@ -673,7 +676,7 @@ static void BuyMenuInitBgs(void)
|
||||
static void BuyMenuDecompressBgGraphics(void)
|
||||
{
|
||||
DecompressAndCopyTileDataToVram(1, gBuyMenuFrame_Gfx, 0x3A0, 0x3E3, 0);
|
||||
LZDecompressWram(gBuyMenuFrame_Tilemap, gShopDataPtr->tilemapBuffers[0]);
|
||||
LZDecompressWram(gBuyMenuFrame_Tilemap, sShopData->tilemapBuffers[0]);
|
||||
LoadCompressedPalette(gMenuMoneyPal, 0xC0, 0x20);
|
||||
}
|
||||
|
||||
@@ -763,16 +766,16 @@ static void BuyMenuDrawMapMetatile(s16 x, s16 y, const u16 *src, u8 metatileLaye
|
||||
switch (metatileLayerType)
|
||||
{
|
||||
case 0:
|
||||
BuyMenuDrawMapMetatileLayer(gShopDataPtr->tilemapBuffers[3], offset1, offset2, src);
|
||||
BuyMenuDrawMapMetatileLayer(gShopDataPtr->tilemapBuffers[1], offset1, offset2, src + 4);
|
||||
BuyMenuDrawMapMetatileLayer(sShopData->tilemapBuffers[3], offset1, offset2, src);
|
||||
BuyMenuDrawMapMetatileLayer(sShopData->tilemapBuffers[1], offset1, offset2, src + 4);
|
||||
break;
|
||||
case 1:
|
||||
BuyMenuDrawMapMetatileLayer(gShopDataPtr->tilemapBuffers[2], offset1, offset2, src);
|
||||
BuyMenuDrawMapMetatileLayer(gShopDataPtr->tilemapBuffers[3], offset1, offset2, src + 4);
|
||||
BuyMenuDrawMapMetatileLayer(sShopData->tilemapBuffers[2], offset1, offset2, src);
|
||||
BuyMenuDrawMapMetatileLayer(sShopData->tilemapBuffers[3], offset1, offset2, src + 4);
|
||||
break;
|
||||
case 2:
|
||||
BuyMenuDrawMapMetatileLayer(gShopDataPtr->tilemapBuffers[2], offset1, offset2, src);
|
||||
BuyMenuDrawMapMetatileLayer(gShopDataPtr->tilemapBuffers[1], offset1, offset2, src + 4);
|
||||
BuyMenuDrawMapMetatileLayer(sShopData->tilemapBuffers[2], offset1, offset2, src);
|
||||
BuyMenuDrawMapMetatileLayer(sShopData->tilemapBuffers[1], offset1, offset2, src + 4);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -796,7 +799,7 @@ static void BuyMenuCollectObjectEventData(void)
|
||||
|
||||
GetXYCoordsOneStepInFrontOfPlayer(&facingX, &facingY);
|
||||
for (y = 0; y < OBJECT_EVENTS_COUNT; y++)
|
||||
gShopDataPtr->viewportObjects[y][OBJ_EVENT_ID] = OBJECT_EVENTS_COUNT;
|
||||
sShopData->viewportObjects[y][OBJ_EVENT_ID] = OBJECT_EVENTS_COUNT;
|
||||
for (y = 0; y < 5; y++)
|
||||
{
|
||||
for (x = 0; x < 7; x++)
|
||||
@@ -805,25 +808,25 @@ static void BuyMenuCollectObjectEventData(void)
|
||||
|
||||
if (objEventId != OBJECT_EVENTS_COUNT)
|
||||
{
|
||||
gShopDataPtr->viewportObjects[r8][OBJ_EVENT_ID] = objEventId;
|
||||
gShopDataPtr->viewportObjects[r8][X_COORD] = x;
|
||||
gShopDataPtr->viewportObjects[r8][Y_COORD] = y;
|
||||
gShopDataPtr->viewportObjects[r8][LAYER_TYPE] = MapGridGetMetatileLayerTypeAt(facingX - 4 + x, facingY - 2 + y);
|
||||
sShopData->viewportObjects[r8][OBJ_EVENT_ID] = objEventId;
|
||||
sShopData->viewportObjects[r8][X_COORD] = x;
|
||||
sShopData->viewportObjects[r8][Y_COORD] = y;
|
||||
sShopData->viewportObjects[r8][LAYER_TYPE] = MapGridGetMetatileLayerTypeAt(facingX - 4 + x, facingY - 2 + y);
|
||||
|
||||
switch (gObjectEvents[objEventId].facingDirection)
|
||||
{
|
||||
case DIR_SOUTH:
|
||||
gShopDataPtr->viewportObjects[r8][ANIM_NUM] = 0;
|
||||
sShopData->viewportObjects[r8][ANIM_NUM] = 0;
|
||||
break;
|
||||
case DIR_NORTH:
|
||||
gShopDataPtr->viewportObjects[r8][ANIM_NUM] = 1;
|
||||
sShopData->viewportObjects[r8][ANIM_NUM] = 1;
|
||||
break;
|
||||
case DIR_WEST:
|
||||
gShopDataPtr->viewportObjects[r8][ANIM_NUM] = 2;
|
||||
sShopData->viewportObjects[r8][ANIM_NUM] = 2;
|
||||
break;
|
||||
case DIR_EAST:
|
||||
default:
|
||||
gShopDataPtr->viewportObjects[r8][ANIM_NUM] = 3;
|
||||
sShopData->viewportObjects[r8][ANIM_NUM] = 3;
|
||||
break;
|
||||
}
|
||||
r8++;
|
||||
@@ -840,25 +843,25 @@ static void BuyMenuDrawObjectEvents(void)
|
||||
|
||||
for (i = 0; i < OBJECT_EVENTS_COUNT; i++)
|
||||
{
|
||||
if (gShopDataPtr->viewportObjects[i][OBJ_EVENT_ID] == OBJECT_EVENTS_COUNT)
|
||||
if (sShopData->viewportObjects[i][OBJ_EVENT_ID] == OBJECT_EVENTS_COUNT)
|
||||
continue;
|
||||
|
||||
graphicsInfo = GetObjectEventGraphicsInfo(gObjectEvents[gShopDataPtr->viewportObjects[i][OBJ_EVENT_ID]].graphicsId);
|
||||
graphicsInfo = GetObjectEventGraphicsInfo(gObjectEvents[sShopData->viewportObjects[i][OBJ_EVENT_ID]].graphicsId);
|
||||
|
||||
spriteId = AddPseudoObjectEvent(
|
||||
gObjectEvents[gShopDataPtr->viewportObjects[i][OBJ_EVENT_ID]].graphicsId,
|
||||
gObjectEvents[sShopData->viewportObjects[i][OBJ_EVENT_ID]].graphicsId,
|
||||
SpriteCallbackDummy,
|
||||
(u16)gShopDataPtr->viewportObjects[i][X_COORD] * 16 + 8,
|
||||
(u16)gShopDataPtr->viewportObjects[i][Y_COORD] * 16 + 48 - graphicsInfo->height / 2,
|
||||
(u16)sShopData->viewportObjects[i][X_COORD] * 16 + 8,
|
||||
(u16)sShopData->viewportObjects[i][Y_COORD] * 16 + 48 - graphicsInfo->height / 2,
|
||||
2);
|
||||
|
||||
if (BuyMenuCheckIfObjectEventOverlapsMenuBg(gShopDataPtr->viewportObjects[i]) == TRUE)
|
||||
if (BuyMenuCheckIfObjectEventOverlapsMenuBg(sShopData->viewportObjects[i]) == TRUE)
|
||||
{
|
||||
gSprites[spriteId].subspriteTableNum = 4;
|
||||
gSprites[spriteId].subspriteMode = SUBSPRITES_ON;
|
||||
}
|
||||
|
||||
StartSpriteAnim(&gSprites[spriteId], gShopDataPtr->viewportObjects[i][ANIM_NUM]);
|
||||
StartSpriteAnim(&gSprites[spriteId], sShopData->viewportObjects[i][ANIM_NUM]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -877,8 +880,8 @@ static bool8 BuyMenuCheckIfObjectEventOverlapsMenuBg(s16 *object)
|
||||
static void BuyMenuCopyMenuBgToBg1TilemapBuffer(void)
|
||||
{
|
||||
s16 i;
|
||||
u16 *dest = gShopDataPtr->tilemapBuffers[1];
|
||||
const u16 *src = gShopDataPtr->tilemapBuffers[0];
|
||||
u16 *dest = sShopData->tilemapBuffers[1];
|
||||
const u16 *src = sShopData->tilemapBuffers[0];
|
||||
|
||||
for (i = 0; i < 1024; i++)
|
||||
{
|
||||
@@ -891,7 +894,7 @@ static void BuyMenuCopyMenuBgToBg1TilemapBuffer(void)
|
||||
|
||||
static bool8 BuyMenuCheckForOverlapWithMenuBg(int x, int y)
|
||||
{
|
||||
const u16 *metatile = gShopDataPtr->tilemapBuffers[0];
|
||||
const u16 *metatile = sShopData->tilemapBuffers[0];
|
||||
int offset1 = x * 2;
|
||||
int offset2 = y * 64;
|
||||
|
||||
@@ -913,7 +916,7 @@ static void Task_BuyMenu(u8 taskId)
|
||||
if (!gPaletteFade.active)
|
||||
{
|
||||
s32 itemId = ListMenu_ProcessInput(tListTaskId);
|
||||
ListMenuGetScrollAndRow(tListTaskId, &gShopDataPtr->scrollOffset, &gShopDataPtr->selectedRow);
|
||||
ListMenuGetScrollAndRow(tListTaskId, &sShopData->scrollOffset, &sShopData->selectedRow);
|
||||
|
||||
switch (itemId)
|
||||
{
|
||||
@@ -930,22 +933,22 @@ static void Task_BuyMenu(u8 taskId)
|
||||
BuyMenuRemoveScrollIndicatorArrows();
|
||||
BuyMenuPrintCursor(tListTaskId, 2);
|
||||
|
||||
if (gMartInfo.martType == MART_TYPE_NORMAL)
|
||||
if (sMartInfo.martType == MART_TYPE_NORMAL)
|
||||
{
|
||||
gShopDataPtr->totalCost = (ItemId_GetPrice(itemId) >> GetPriceReduction(POKENEWS_SLATEPORT));
|
||||
sShopData->totalCost = (ItemId_GetPrice(itemId) >> GetPriceReduction(POKENEWS_SLATEPORT));
|
||||
}
|
||||
else
|
||||
{
|
||||
gShopDataPtr->totalCost = gDecorations[itemId].price;
|
||||
sShopData->totalCost = gDecorations[itemId].price;
|
||||
}
|
||||
|
||||
if (!IsEnoughMoney(&gSaveBlock1Ptr->money, gShopDataPtr->totalCost))
|
||||
if (!IsEnoughMoney(&gSaveBlock1Ptr->money, sShopData->totalCost))
|
||||
{
|
||||
BuyMenuDisplayMessage(taskId, gText_YouDontHaveMoney, BuyMenuReturnToItemList);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (gMartInfo.martType == MART_TYPE_NORMAL)
|
||||
if (sMartInfo.martType == MART_TYPE_NORMAL)
|
||||
{
|
||||
CopyItemName(itemId, gStringVar1);
|
||||
if (ItemId_GetPocket(itemId) == POCKET_TM_HM)
|
||||
@@ -961,9 +964,9 @@ static void Task_BuyMenu(u8 taskId)
|
||||
else
|
||||
{
|
||||
StringCopy(gStringVar1, gDecorations[itemId].name);
|
||||
ConvertIntToDecimalStringN(gStringVar2, gShopDataPtr->totalCost, STR_CONV_MODE_LEFT_ALIGN, 6);
|
||||
ConvertIntToDecimalStringN(gStringVar2, sShopData->totalCost, STR_CONV_MODE_LEFT_ALIGN, 6);
|
||||
|
||||
if (gMartInfo.martType == MART_TYPE_DECOR)
|
||||
if (sMartInfo.martType == MART_TYPE_DECOR)
|
||||
StringExpandPlaceholders(gStringVar4, gText_Var1IsItThatllBeVar2);
|
||||
else // MART_TYPE_DECOR2
|
||||
StringExpandPlaceholders(gStringVar4, gText_YouWantedVar1ThatllBeVar2);
|
||||
@@ -992,15 +995,15 @@ static void Task_BuyHowManyDialogueInit(u8 taskId)
|
||||
BuyMenuPrintItemQuantityAndPrice(taskId);
|
||||
ScheduleBgCopyTilemapToVram(0);
|
||||
|
||||
maxQuantity = GetMoney(&gSaveBlock1Ptr->money) / gShopDataPtr->totalCost;
|
||||
maxQuantity = GetMoney(&gSaveBlock1Ptr->money) / sShopData->totalCost;
|
||||
|
||||
if (maxQuantity > MAX_BAG_ITEM_CAPACITY)
|
||||
{
|
||||
gShopDataPtr->maxQuantity = MAX_BAG_ITEM_CAPACITY;
|
||||
sShopData->maxQuantity = MAX_BAG_ITEM_CAPACITY;
|
||||
}
|
||||
else
|
||||
{
|
||||
gShopDataPtr->maxQuantity = maxQuantity;
|
||||
sShopData->maxQuantity = maxQuantity;
|
||||
}
|
||||
|
||||
gTasks[taskId].func = Task_BuyHowManyDialogueHandleInput;
|
||||
@@ -1010,9 +1013,9 @@ static void Task_BuyHowManyDialogueHandleInput(u8 taskId)
|
||||
{
|
||||
s16 *data = gTasks[taskId].data;
|
||||
|
||||
if (AdjustQuantityAccordingToDPadInput(&tItemCount, gShopDataPtr->maxQuantity) == TRUE)
|
||||
if (AdjustQuantityAccordingToDPadInput(&tItemCount, sShopData->maxQuantity) == TRUE)
|
||||
{
|
||||
gShopDataPtr->totalCost = (ItemId_GetPrice(tItemId) >> GetPriceReduction(POKENEWS_SLATEPORT)) * tItemCount;
|
||||
sShopData->totalCost = (ItemId_GetPrice(tItemId) >> GetPriceReduction(POKENEWS_SLATEPORT)) * tItemCount;
|
||||
BuyMenuPrintItemQuantityAndPrice(taskId);
|
||||
}
|
||||
else
|
||||
@@ -1027,7 +1030,7 @@ static void Task_BuyHowManyDialogueHandleInput(u8 taskId)
|
||||
PutWindowTilemap(1);
|
||||
CopyItemName(tItemId, gStringVar1);
|
||||
ConvertIntToDecimalStringN(gStringVar2, tItemCount, STR_CONV_MODE_LEFT_ALIGN, BAG_ITEM_CAPACITY_DIGITS);
|
||||
ConvertIntToDecimalStringN(gStringVar3, gShopDataPtr->totalCost, STR_CONV_MODE_LEFT_ALIGN, 6);
|
||||
ConvertIntToDecimalStringN(gStringVar3, sShopData->totalCost, STR_CONV_MODE_LEFT_ALIGN, 6);
|
||||
BuyMenuDisplayMessage(taskId, gText_Var1AndYouWantedVar2, BuyMenuConfirmPurchase);
|
||||
}
|
||||
else if (JOY_NEW(B_BUTTON))
|
||||
@@ -1053,7 +1056,7 @@ static void BuyMenuTryMakePurchase(u8 taskId)
|
||||
|
||||
PutWindowTilemap(1);
|
||||
|
||||
if (gMartInfo.martType == MART_TYPE_NORMAL)
|
||||
if (sMartInfo.martType == MART_TYPE_NORMAL)
|
||||
{
|
||||
if (AddBagItem(tItemId, tItemCount) == TRUE)
|
||||
{
|
||||
@@ -1069,7 +1072,7 @@ static void BuyMenuTryMakePurchase(u8 taskId)
|
||||
{
|
||||
if (DecorationAdd(tItemId))
|
||||
{
|
||||
if (gMartInfo.martType == MART_TYPE_DECOR)
|
||||
if (sMartInfo.martType == MART_TYPE_DECOR)
|
||||
BuyMenuDisplayMessage(taskId, gText_ThankYouIllSendItHome, BuyMenuSubtractMoney);
|
||||
else // MART_TYPE_DECOR2
|
||||
BuyMenuDisplayMessage(taskId, gText_ThanksIllSendItHome, BuyMenuSubtractMoney);
|
||||
@@ -1084,11 +1087,11 @@ static void BuyMenuTryMakePurchase(u8 taskId)
|
||||
static void BuyMenuSubtractMoney(u8 taskId)
|
||||
{
|
||||
IncrementGameStat(GAME_STAT_SHOPPED);
|
||||
RemoveMoney(&gSaveBlock1Ptr->money, gShopDataPtr->totalCost);
|
||||
RemoveMoney(&gSaveBlock1Ptr->money, sShopData->totalCost);
|
||||
PlaySE(SE_SHOP);
|
||||
PrintMoneyAmountInMoneyBox(0, GetMoney(&gSaveBlock1Ptr->money), 0);
|
||||
|
||||
if (gMartInfo.martType == MART_TYPE_NORMAL)
|
||||
if (sMartInfo.martType == MART_TYPE_NORMAL)
|
||||
{
|
||||
gTasks[taskId].func = Task_ReturnToItemListAfterItemPurchase;
|
||||
}
|
||||
@@ -1143,7 +1146,7 @@ static void BuyMenuPrintItemQuantityAndPrice(u8 taskId)
|
||||
s16 *data = gTasks[taskId].data;
|
||||
|
||||
FillWindowPixelBuffer(4, PIXEL_FILL(1));
|
||||
PrintMoneyAmount(4, 38, 1, gShopDataPtr->totalCost, TEXT_SPEED_FF);
|
||||
PrintMoneyAmount(4, 38, 1, sShopData->totalCost, TEXT_SPEED_FF);
|
||||
ConvertIntToDecimalStringN(gStringVar1, tItemCount, STR_CONV_MODE_LEADING_ZEROS, BAG_ITEM_CAPACITY_DIGITS);
|
||||
StringExpandPlaceholders(gStringVar4, gText_xVar1);
|
||||
BuyMenuPrint(4, gStringVar4, 0, 1, 0, 0);
|
||||
@@ -1169,7 +1172,7 @@ static void Task_ExitBuyMenu(u8 taskId)
|
||||
|
||||
static void ClearItemPurchases(void)
|
||||
{
|
||||
gMartPurchaseHistoryId = 0;
|
||||
sPurchaseHistoryId = 0;
|
||||
memset(gMartPurchaseHistory, 0, sizeof(gMartPurchaseHistory));
|
||||
}
|
||||
|
||||
@@ -1179,27 +1182,23 @@ static void RecordItemPurchase(u8 taskId)
|
||||
|
||||
u16 i;
|
||||
|
||||
for (i = 0; i < 3; i++)
|
||||
for (i = 0; i < ARRAY_COUNT(gMartPurchaseHistory); i++)
|
||||
{
|
||||
if (gMartPurchaseHistory[i].itemId == tItemId && gMartPurchaseHistory[i].quantity != 0)
|
||||
{
|
||||
if (gMartPurchaseHistory[i].quantity + tItemCount > 255)
|
||||
{
|
||||
gMartPurchaseHistory[i].quantity = 255;
|
||||
}
|
||||
else
|
||||
{
|
||||
gMartPurchaseHistory[i].quantity += tItemCount;
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (gMartPurchaseHistoryId < 3)
|
||||
if (sPurchaseHistoryId < ARRAY_COUNT(gMartPurchaseHistory))
|
||||
{
|
||||
gMartPurchaseHistory[gMartPurchaseHistoryId].itemId = tItemId;
|
||||
gMartPurchaseHistory[gMartPurchaseHistoryId].quantity = tItemCount;
|
||||
gMartPurchaseHistoryId++;
|
||||
gMartPurchaseHistory[sPurchaseHistoryId].itemId = tItemId;
|
||||
gMartPurchaseHistory[sPurchaseHistoryId].quantity = tItemCount;
|
||||
sPurchaseHistoryId++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+22
-19
@@ -41,24 +41,24 @@ static void Task_DuckBGMForPokemonCry(u8 taskId);
|
||||
static void RestoreBGMVolumeAfterPokemonCry(void);
|
||||
|
||||
static const struct Fanfare sFanfares[] = {
|
||||
{ MUS_LEVEL_UP, 80 },
|
||||
{ MUS_OBTAIN_ITEM, 160 },
|
||||
{ MUS_EVOLVED, 220 },
|
||||
{ MUS_OBTAIN_TMHM, 220 },
|
||||
{ MUS_HEAL, 160 },
|
||||
{ MUS_OBTAIN_BADGE, 340 },
|
||||
{ MUS_MOVE_DELETED, 180 },
|
||||
{ MUS_OBTAIN_BERRY, 120 },
|
||||
{ MUS_AWAKEN_LEGEND, 710 },
|
||||
{ MUS_SLOTS_JACKPOT, 250 },
|
||||
{ MUS_SLOTS_WIN, 150 },
|
||||
{ MUS_TOO_BAD, 160 },
|
||||
{ MUS_RG_POKE_FLUTE, 450 },
|
||||
{ MUS_RG_OBTAIN_KEY_ITEM, 170 },
|
||||
{ MUS_RG_DEX_RATING, 196 },
|
||||
{ MUS_OBTAIN_B_POINTS, 313 },
|
||||
{ MUS_OBTAIN_SYMBOL, 318 },
|
||||
{ MUS_REGISTER_MATCH_CALL, 135 },
|
||||
[FANFARE_LEVEL_UP] = { MUS_LEVEL_UP, 80 },
|
||||
[FANFARE_OBTAIN_ITEM] = { MUS_OBTAIN_ITEM, 160 },
|
||||
[FANFARE_EVOLVED] = { MUS_EVOLVED, 220 },
|
||||
[FANFARE_OBTAIN_TMHM] = { MUS_OBTAIN_TMHM, 220 },
|
||||
[FANFARE_HEAL] = { MUS_HEAL, 160 },
|
||||
[FANFARE_OBTAIN_BADGE] = { MUS_OBTAIN_BADGE, 340 },
|
||||
[FANFARE_MOVE_DELETED] = { MUS_MOVE_DELETED, 180 },
|
||||
[FANFARE_OBTAIN_BERRY] = { MUS_OBTAIN_BERRY, 120 },
|
||||
[FANFARE_AWAKEN_LEGEND] = { MUS_AWAKEN_LEGEND, 710 },
|
||||
[FANFARE_SLOTS_JACKPOT] = { MUS_SLOTS_JACKPOT, 250 },
|
||||
[FANFARE_SLOTS_WIN] = { MUS_SLOTS_WIN, 150 },
|
||||
[FANFARE_TOO_BAD] = { MUS_TOO_BAD, 160 },
|
||||
[FANFARE_RG_POKE_FLUTE] = { MUS_RG_POKE_FLUTE, 450 },
|
||||
[FANFARE_RG_OBTAIN_KEY_ITEM] = { MUS_RG_OBTAIN_KEY_ITEM, 170 },
|
||||
[FANFARE_RG_DEX_RATING] = { MUS_RG_DEX_RATING, 196 },
|
||||
[FANFARE_OBTAIN_B_POINTS] = { MUS_OBTAIN_B_POINTS, 313 },
|
||||
[FANFARE_OBTAIN_SYMBOL] = { MUS_OBTAIN_SYMBOL, 318 },
|
||||
[FANFARE_REGISTER_MATCH_CALL] = { MUS_REGISTER_MATCH_CALL, 135 },
|
||||
};
|
||||
|
||||
#define CRY_VOLUME 120 // was 125 in R/S
|
||||
@@ -212,6 +212,7 @@ bool8 WaitFanfare(bool8 stop)
|
||||
}
|
||||
}
|
||||
|
||||
// Unused
|
||||
void StopFanfareByFanfareNum(u8 fanfareNum)
|
||||
{
|
||||
m4aSongNumStop(sFanfares[fanfareNum].songNum);
|
||||
@@ -220,7 +221,7 @@ void StopFanfareByFanfareNum(u8 fanfareNum)
|
||||
void PlayFanfare(u16 songNum)
|
||||
{
|
||||
s32 i;
|
||||
for (i = 0; (u32)i < 18; i++)
|
||||
for (i = 0; (u32)i < ARRAY_COUNT(sFanfares); i++)
|
||||
{
|
||||
if (sFanfares[i].songNum == songNum)
|
||||
{
|
||||
@@ -230,6 +231,8 @@ void PlayFanfare(u16 songNum)
|
||||
}
|
||||
}
|
||||
|
||||
// songNum is not in sFanfares
|
||||
// Play first fanfare in table instead
|
||||
PlayFanfareByFanfareNum(0);
|
||||
CreateFanfareTask();
|
||||
}
|
||||
|
||||
+31
-15
@@ -170,7 +170,7 @@ static const struct MenuAction sStartMenuItems[] =
|
||||
{gText_MenuBag, {.u8_void = StartMenuBattlePyramidBagCallback}}
|
||||
};
|
||||
|
||||
static const struct BgTemplate sUnknown_085105A8[] =
|
||||
static const struct BgTemplate sBgTemplates_LinkBattleSave[] =
|
||||
{
|
||||
{
|
||||
.bg = 0,
|
||||
@@ -183,13 +183,29 @@ static const struct BgTemplate sUnknown_085105A8[] =
|
||||
}
|
||||
};
|
||||
|
||||
static const struct WindowTemplate sUnknown_085105AC[] =
|
||||
static const struct WindowTemplate sWindowTemplates_LinkBattleSave[] =
|
||||
{
|
||||
{0, 2, 0xF, 0x1A, 4, 0xF, 0x194},
|
||||
{
|
||||
.bg = 0,
|
||||
.tilemapLeft = 2,
|
||||
.tilemapTop = 15,
|
||||
.width = 26,
|
||||
.height = 4,
|
||||
.paletteNum = 15,
|
||||
.baseBlock = 0x194
|
||||
},
|
||||
DUMMY_WIN_TEMPLATE
|
||||
};
|
||||
|
||||
static const struct WindowTemplate sSaveInfoWindowTemplate = {0, 1, 1, 0xE, 0xA, 0xF, 8};
|
||||
static const struct WindowTemplate sSaveInfoWindowTemplate = {
|
||||
.bg = 0,
|
||||
.tilemapLeft = 1,
|
||||
.tilemapTop = 1,
|
||||
.width = 14,
|
||||
.height = 10,
|
||||
.paletteNum = 15,
|
||||
.baseBlock = 8
|
||||
};
|
||||
|
||||
// Local functions
|
||||
static void BuildStartMenuActions(void);
|
||||
@@ -211,13 +227,13 @@ static void CreateStartMenuTask(TaskFunc followupFunc);
|
||||
static void InitSave(void);
|
||||
static u8 RunSaveCallback(void);
|
||||
static void ShowSaveMessage(const u8 *message, u8 (*saveCallback)(void));
|
||||
static void sub_80A0014(void);
|
||||
static void HideSaveMessageWindow(void);
|
||||
static void HideSaveInfoWindow(void);
|
||||
static void SaveStartTimer(void);
|
||||
static bool8 SaveSuccesTimer(void);
|
||||
static bool8 SaveErrorTimer(void);
|
||||
static void InitBattlePyramidRetire(void);
|
||||
static void sub_80A03D8(void);
|
||||
static void VBlankCB_LinkBattleSave(void);
|
||||
static bool32 InitSaveWindowAfterLinkBattle(u8 *par1);
|
||||
static void CB2_SaveAfterLinkBattle(void);
|
||||
static void ShowSaveInfoWindow(void);
|
||||
@@ -887,7 +903,7 @@ static void SaveGameTask(u8 taskId)
|
||||
EnableBothScriptContexts();
|
||||
}
|
||||
|
||||
static void sub_80A0014(void)
|
||||
static void HideSaveMessageWindow(void)
|
||||
{
|
||||
ClearDialogWindowAndFrame(0, TRUE);
|
||||
}
|
||||
@@ -982,7 +998,7 @@ static u8 SaveConfirmInputCallback(void)
|
||||
case -1: // B Button
|
||||
case 1: // No
|
||||
HideSaveInfoWindow();
|
||||
sub_80A0014();
|
||||
HideSaveMessageWindow();
|
||||
return SAVE_CANCELED;
|
||||
}
|
||||
|
||||
@@ -1028,7 +1044,7 @@ static u8 SaveOverwriteInputCallback(void)
|
||||
case -1: // B Button
|
||||
case 1: // No
|
||||
HideSaveInfoWindow();
|
||||
sub_80A0014();
|
||||
HideSaveMessageWindow();
|
||||
return SAVE_CANCELED;
|
||||
}
|
||||
|
||||
@@ -1146,14 +1162,14 @@ static u8 BattlePyramidRetireInputCallback(void)
|
||||
return SAVE_CANCELED;
|
||||
case -1: // B Button
|
||||
case 1: // No
|
||||
sub_80A0014();
|
||||
HideSaveMessageWindow();
|
||||
return SAVE_SUCCESS;
|
||||
}
|
||||
|
||||
return SAVE_IN_PROGRESS;
|
||||
}
|
||||
|
||||
static void sub_80A03D8(void)
|
||||
static void VBlankCB_LinkBattleSave(void)
|
||||
{
|
||||
TransferPlttBuffer();
|
||||
}
|
||||
@@ -1167,7 +1183,7 @@ static bool32 InitSaveWindowAfterLinkBattle(u8 *state)
|
||||
SetVBlankCallback(NULL);
|
||||
ScanlineEffect_Stop();
|
||||
DmaClear16(3, PLTT, PLTT_SIZE);
|
||||
DmaFillLarge16(3, 0, (void *)(VRAM + 0x0), 0x18000, 0x1000);
|
||||
DmaFillLarge16(3, 0, (void *)VRAM, VRAM_SIZE, 0x1000);
|
||||
break;
|
||||
case 1:
|
||||
ResetSpriteData();
|
||||
@@ -1177,15 +1193,15 @@ static bool32 InitSaveWindowAfterLinkBattle(u8 *state)
|
||||
break;
|
||||
case 2:
|
||||
ResetBgsAndClearDma3BusyFlags(0);
|
||||
InitBgsFromTemplates(0, sUnknown_085105A8, ARRAY_COUNT(sUnknown_085105A8));
|
||||
InitWindows(sUnknown_085105AC);
|
||||
InitBgsFromTemplates(0, sBgTemplates_LinkBattleSave, ARRAY_COUNT(sBgTemplates_LinkBattleSave));
|
||||
InitWindows(sWindowTemplates_LinkBattleSave);
|
||||
LoadUserWindowBorderGfx_(0, 8, 224);
|
||||
Menu_LoadStdPalAt(240);
|
||||
break;
|
||||
case 3:
|
||||
ShowBg(0);
|
||||
BlendPalettes(-1, 16, 0);
|
||||
SetVBlankCallback(sub_80A03D8);
|
||||
SetVBlankCallback(VBlankCB_LinkBattleSave);
|
||||
EnableInterrupts(1);
|
||||
break;
|
||||
case 4:
|
||||
|
||||
+1
-1
@@ -1292,7 +1292,7 @@ const u8 gText_MatchCallMay_Intro1[] = _("My POKéMON and I help");
|
||||
const u8 gText_MatchCallMay_Intro2[] = _("my father's research.");
|
||||
const u8 gText_HatchedFromEgg[] = _("{STR_VAR_1} hatched from the EGG!");
|
||||
const u8 gText_NicknameHatchPrompt[] = _("Would you like to nickname the newly\nhatched {STR_VAR_1}?");
|
||||
ALIGNED(4) const u8 gText_ReadyToBerryCrush[] = _("Are you ready to BERRY-CRUSH?\nPlease pick a BERRY for use.\p");
|
||||
ALIGNED(4) const u8 gText_ReadyPickBerry[] = _("Are you ready to BERRY-CRUSH?\nPlease pick a BERRY for use.\p");
|
||||
ALIGNED(4) const u8 gText_WaitForAllChooseBerry[] = _("Please wait while each member\nchooses a BERRY.");
|
||||
ALIGNED(4) const u8 gText_EndedWithXUnitsPowder[] = _("{PAUSE_MUSIC}{PLAY_BGM MUS_LEVEL_UP}You ended up with {STR_VAR_1} units of\nsilky-smooth BERRY POWDER.{RESUME_MUSIC}\pYour total amount of BERRY POWDER\nis {STR_VAR_2}.\p");
|
||||
ALIGNED(4) const u8 gText_RecordingGameResults[] = _("Recording your game results in the\nsave file.\lPlease wait.");
|
||||
|
||||
+7
-10
@@ -165,9 +165,6 @@ static EWRAM_DATA struct {
|
||||
/*0xFE*/ u8 wirelessWinBottom;
|
||||
} *sTradeData = {NULL};
|
||||
|
||||
#if !defined(NONMATCHING) && MODERN
|
||||
#define static
|
||||
#endif
|
||||
static bool32 IsWirelessTrade(void);
|
||||
static void CB2_CreateTradeMenu(void);
|
||||
static void VBlankCB_TradeMenu(void);
|
||||
@@ -1163,12 +1160,12 @@ static void ReactToLinkTradeData(u8 mpId, u8 status)
|
||||
{
|
||||
switch (gBlockRecvBuffer[0][0])
|
||||
{
|
||||
case LINKCMD_CANCEL_TRADE:
|
||||
case LINKCMD_BOTH_CANCEL_TRADE:
|
||||
BeginNormalPaletteFade(PALETTES_ALL, 0, 0, 16, RGB_BLACK);
|
||||
PrintTradeMessage(TRADE_MSG_WAITING_FOR_FRIEND);
|
||||
sTradeMenuData->tradeMenuFunc = TRADEMENUFUNC_CANCEL_TRADE_1;
|
||||
break;
|
||||
case LINKCMD_0xEECC:
|
||||
case LINKCMD_PARTNER_CANCEL_TRADE:
|
||||
PrintTradeMessage(TRADE_MSG_FRIEND_WANTS_TO_TRADE);
|
||||
sTradeMenuData->tradeMenuFunc = TRADEMENUFUNC_REDRAW_MAIN_MENU;
|
||||
break;
|
||||
@@ -1183,7 +1180,7 @@ static void ReactToLinkTradeData(u8 mpId, u8 status)
|
||||
BeginNormalPaletteFade(PALETTES_ALL, 0, 0, 16, RGB_BLACK);
|
||||
sTradeMenuData->tradeMenuFunc = TRADEMENUFUNC_LINK_TRADE_WAIT_FADE;
|
||||
break;
|
||||
case LINKCMD_0xDDEE:
|
||||
case LINKCMD_PLAYER_CANCEL_TRADE:
|
||||
PrintTradeMessage(TRADE_MSG_CANCELED);
|
||||
sTradeMenuData->tradeMenuFunc = TRADEMENUFUNC_REDRAW_MAIN_MENU;
|
||||
}
|
||||
@@ -1211,7 +1208,7 @@ static void QueueLinkTradeData(void)
|
||||
&& sTradeMenuData->partnerLinkFlagChoseAction == WANTS_TO_CANCEL)
|
||||
{
|
||||
PrintTradeMessage(TRADE_MSG_CANCELED);
|
||||
sTradeMenuData->linkData[0] = LINKCMD_0xEECC;
|
||||
sTradeMenuData->linkData[0] = LINKCMD_PARTNER_CANCEL_TRADE;
|
||||
sTradeMenuData->linkData[1] = 0;
|
||||
QueueAction(QUEUE_DELAY_DATA, QUEUE_SEND_DATA);
|
||||
sTradeMenuData->playerLinkFlagStatus = sTradeMenuData->partnerLinkFlagStatus = 0;
|
||||
@@ -1222,7 +1219,7 @@ static void QueueLinkTradeData(void)
|
||||
&& sTradeMenuData->partnerLinkFlagChoseAction == WANTS_TO_TRADE)
|
||||
{
|
||||
PrintTradeMessage(TRADE_MSG_FRIEND_WANTS_TO_TRADE);
|
||||
sTradeMenuData->linkData[0] = LINKCMD_0xDDEE;
|
||||
sTradeMenuData->linkData[0] = LINKCMD_PLAYER_CANCEL_TRADE;
|
||||
sTradeMenuData->linkData[1] = 0;
|
||||
QueueAction(QUEUE_DELAY_DATA, QUEUE_SEND_DATA);
|
||||
sTradeMenuData->playerLinkFlagStatus = sTradeMenuData->partnerLinkFlagStatus = 0;
|
||||
@@ -1232,7 +1229,7 @@ static void QueueLinkTradeData(void)
|
||||
else if (sTradeMenuData->playerLinkFlagChoseAction == WANTS_TO_CANCEL
|
||||
&& sTradeMenuData->partnerLinkFlagChoseAction == WANTS_TO_CANCEL)
|
||||
{
|
||||
sTradeMenuData->linkData[0] = LINKCMD_CANCEL_TRADE;
|
||||
sTradeMenuData->linkData[0] = LINKCMD_BOTH_CANCEL_TRADE;
|
||||
sTradeMenuData->linkData[1] = 0;
|
||||
QueueAction(QUEUE_DELAY_DATA, QUEUE_SEND_DATA);
|
||||
BeginNormalPaletteFade(PALETTES_ALL, 0, 0, 16, RGB_BLACK);
|
||||
@@ -1258,7 +1255,7 @@ static void QueueLinkTradeData(void)
|
||||
|| sTradeMenuData->partnerLinkFlagStatus == CANCEL_TRADE)
|
||||
{
|
||||
PrintTradeMessage(TRADE_MSG_CANCELED);
|
||||
sTradeMenuData->linkData[0] = LINKCMD_0xDDEE;
|
||||
sTradeMenuData->linkData[0] = LINKCMD_PLAYER_CANCEL_TRADE;
|
||||
sTradeMenuData->linkData[1] = 0;
|
||||
QueueAction(QUEUE_DELAY_DATA, QUEUE_SEND_DATA);
|
||||
sTradeMenuData->playerLinkFlagStatus = 0;
|
||||
|
||||
+76
-77
@@ -80,7 +80,7 @@ struct TrainerCardData
|
||||
u8 cardTiles[0x2300];
|
||||
u16 cardTilemapBuffer[0x1000];
|
||||
u16 bgTilemapBuffer[0x1000];
|
||||
u16 var_7CA8;
|
||||
u16 cardTop;
|
||||
u8 language;
|
||||
};
|
||||
|
||||
@@ -113,7 +113,7 @@ static void SetPlayerCardData(struct TrainerCard*, u8);
|
||||
static void TrainerCard_GenerateCardForLinkPlayer(struct TrainerCard*);
|
||||
static u8 VersionToCardType(u8);
|
||||
static void SetDataFromTrainerCard(void);
|
||||
static void HandleGpuRegs(void);
|
||||
static void InitGpuRegs(void);
|
||||
static void ResetGpuRegs(void);
|
||||
static void InitBgsAndWindows(void);
|
||||
static void SetTrainerCardCb2(void);
|
||||
@@ -158,31 +158,30 @@ static bool8 Task_DrawFlippedCardSide(struct Task* task);
|
||||
static bool8 Task_SetCardFlipped(struct Task* task);
|
||||
static bool8 Task_AnimateCardFlipUp(struct Task* task);
|
||||
static bool8 Task_EndCardFlip(struct Task* task);
|
||||
static void sub_80C32EC(u16);
|
||||
static void UpdateCardFlipRegs(u16);
|
||||
static void LoadMonIconGfx(void);
|
||||
|
||||
// const rom data
|
||||
static const u32 sTrainerCardStickers_Gfx[] = INCBIN_U32("graphics/trainer_card/stickers_fr.4bpp.lz");
|
||||
static const u16 sUnused_0856F18C[] = INCBIN_U16("graphics/trainer_card/unknown_56F18C.gbapal");
|
||||
static const u16 sHoennTrainerCard1Star_Pal[] = INCBIN_U16("graphics/trainer_card/one_star.gbapal");
|
||||
static const u16 sKantoTrainerCard1Star_Pal[] = INCBIN_U16("graphics/trainer_card/one_star_fr.gbapal");
|
||||
static const u16 sHoennTrainerCard2Star_Pal[] = INCBIN_U16("graphics/trainer_card/two_stars.gbapal");
|
||||
static const u16 sKantoTrainerCard2Star_Pal[] = INCBIN_U16("graphics/trainer_card/two_stars_fr.gbapal");
|
||||
static const u16 sHoennTrainerCard3Star_Pal[] = INCBIN_U16("graphics/trainer_card/three_stars.gbapal");
|
||||
static const u16 sKantoTrainerCard3Star_Pal[] = INCBIN_U16("graphics/trainer_card/three_stars_fr.gbapal");
|
||||
static const u16 sHoennTrainerCard4Star_Pal[] = INCBIN_U16("graphics/trainer_card/four_stars.gbapal");
|
||||
static const u16 sKantoTrainerCard4Star_Pal[] = INCBIN_U16("graphics/trainer_card/four_stars_fr.gbapal");
|
||||
static const u32 sTrainerCardStickers_Gfx[] = INCBIN_U32("graphics/trainer_card/stickers_fr.4bpp.lz");
|
||||
static const u16 sUnused_Pal[] = INCBIN_U16("graphics/trainer_card/unused.gbapal");
|
||||
static const u16 sHoennTrainerCard1Star_Pal[] = INCBIN_U16("graphics/trainer_card/one_star.gbapal");
|
||||
static const u16 sKantoTrainerCard1Star_Pal[] = INCBIN_U16("graphics/trainer_card/one_star_fr.gbapal");
|
||||
static const u16 sHoennTrainerCard2Star_Pal[] = INCBIN_U16("graphics/trainer_card/two_stars.gbapal");
|
||||
static const u16 sKantoTrainerCard2Star_Pal[] = INCBIN_U16("graphics/trainer_card/two_stars_fr.gbapal");
|
||||
static const u16 sHoennTrainerCard3Star_Pal[] = INCBIN_U16("graphics/trainer_card/three_stars.gbapal");
|
||||
static const u16 sKantoTrainerCard3Star_Pal[] = INCBIN_U16("graphics/trainer_card/three_stars_fr.gbapal");
|
||||
static const u16 sHoennTrainerCard4Star_Pal[] = INCBIN_U16("graphics/trainer_card/four_stars.gbapal");
|
||||
static const u16 sKantoTrainerCard4Star_Pal[] = INCBIN_U16("graphics/trainer_card/four_stars_fr.gbapal");
|
||||
static const u16 sHoennTrainerCardFemaleBg_Pal[] = INCBIN_U16("graphics/trainer_card/female_bg.gbapal");
|
||||
static const u16 sKantoTrainerCardFemaleBg_Pal[] = INCBIN_U16("graphics/trainer_card/female_bg_fr.gbapal");
|
||||
static const u16 sHoennTrainerCardBadges_Pal[] = INCBIN_U16("graphics/trainer_card/badges.gbapal");
|
||||
static const u16 sKantoTrainerCardBadges_Pal[] = INCBIN_U16("graphics/trainer_card/badges_fr.gbapal");
|
||||
static const u16 sTrainerCardGold_Pal[] = INCBIN_U16("graphics/trainer_card/gold.gbapal");
|
||||
static const u16 sTrainerCardSticker1_Pal[] = INCBIN_U16("graphics/trainer_card/stickers_fr1.gbapal");
|
||||
static const u16 sTrainerCardSticker2_Pal[] = INCBIN_U16("graphics/trainer_card/stickers_fr2.gbapal");
|
||||
static const u16 sTrainerCardSticker3_Pal[] = INCBIN_U16("graphics/trainer_card/stickers_fr3.gbapal");
|
||||
static const u16 sTrainerCardSticker4_Pal[] = INCBIN_U16("graphics/trainer_card/stickers_fr4.gbapal");
|
||||
static const u32 sHoennTrainerCardBadges_Gfx[] = INCBIN_U32("graphics/trainer_card/badges.4bpp.lz");
|
||||
static const u32 sKantoTrainerCardBadges_Gfx[] = INCBIN_U32("graphics/trainer_card/badges_fr.4bpp.lz");
|
||||
static const u16 sHoennTrainerCardBadges_Pal[] = INCBIN_U16("graphics/trainer_card/badges.gbapal");
|
||||
static const u16 sKantoTrainerCardBadges_Pal[] = INCBIN_U16("graphics/trainer_card/badges_fr.gbapal");
|
||||
static const u16 sTrainerCardGold_Pal[] = INCBIN_U16("graphics/trainer_card/gold.gbapal");
|
||||
static const u16 sTrainerCardSticker1_Pal[] = INCBIN_U16("graphics/trainer_card/stickers_fr1.gbapal");
|
||||
static const u16 sTrainerCardSticker2_Pal[] = INCBIN_U16("graphics/trainer_card/stickers_fr2.gbapal");
|
||||
static const u16 sTrainerCardSticker3_Pal[] = INCBIN_U16("graphics/trainer_card/stickers_fr3.gbapal");
|
||||
static const u16 sTrainerCardSticker4_Pal[] = INCBIN_U16("graphics/trainer_card/stickers_fr4.gbapal");
|
||||
static const u32 sHoennTrainerCardBadges_Gfx[] = INCBIN_U32("graphics/trainer_card/badges.4bpp.lz");
|
||||
static const u32 sKantoTrainerCardBadges_Gfx[] = INCBIN_U32("graphics/trainer_card/badges_fr.4bpp.lz");
|
||||
|
||||
static const struct BgTemplate sTrainerCardBgTemplates[4] =
|
||||
{
|
||||
@@ -321,7 +320,6 @@ static bool8 (*const sTrainerCardFlipTasks[])(struct Task *) =
|
||||
Task_EndCardFlip,
|
||||
};
|
||||
|
||||
// code
|
||||
static void VblankCb_TrainerCard(void)
|
||||
{
|
||||
LoadOam();
|
||||
@@ -458,7 +456,7 @@ static void Task_TrainerCard(u8 taskId)
|
||||
}
|
||||
break;
|
||||
case STATE_WAIT_FLIP_TO_BACK:
|
||||
if (IsCardFlipTaskActive() && sub_8087598() != TRUE)
|
||||
if (IsCardFlipTaskActive() && Overworld_LinkRecvQueueLengthMoreThan2() != TRUE)
|
||||
{
|
||||
PlaySE(SE_RG_CARD_OPEN);
|
||||
sData->mainState = STATE_HANDLE_INPUT_BACK;
|
||||
@@ -515,7 +513,7 @@ static void Task_TrainerCard(u8 taskId)
|
||||
CloseTrainerCard(taskId);
|
||||
break;
|
||||
case STATE_WAIT_FLIP_TO_FRONT:
|
||||
if (IsCardFlipTaskActive() && sub_8087598() != TRUE)
|
||||
if (IsCardFlipTaskActive() && Overworld_LinkRecvQueueLengthMoreThan2() != TRUE)
|
||||
{
|
||||
sData->mainState = STATE_HANDLE_INPUT_FRONT;
|
||||
PlaySE(SE_RG_CARD_OPEN);
|
||||
@@ -620,7 +618,7 @@ static void CB2_InitTrainerCard(void)
|
||||
gMain.state++;
|
||||
break;
|
||||
case 8:
|
||||
HandleGpuRegs();
|
||||
InitGpuRegs();
|
||||
gMain.state++;
|
||||
break;
|
||||
case 9:
|
||||
@@ -841,7 +839,7 @@ static void SetDataFromTrainerCard(void)
|
||||
}
|
||||
}
|
||||
|
||||
static void HandleGpuRegs(void)
|
||||
static void InitGpuRegs(void)
|
||||
{
|
||||
SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_WIN0_ON | DISPCNT_OBJ_ON | DISPCNT_OBJ_1D_MAP);
|
||||
ShowBg(0);
|
||||
@@ -852,24 +850,23 @@ static void HandleGpuRegs(void)
|
||||
SetGpuReg(REG_OFFSET_BLDY, 0);
|
||||
SetGpuReg(REG_OFFSET_WININ, WININ_WIN0_BG_ALL | WININ_WIN0_OBJ | WININ_WIN0_CLR);
|
||||
SetGpuReg(REG_OFFSET_WINOUT, WINOUT_WIN01_BG1 | WINOUT_WIN01_BG2 | WINOUT_WIN01_BG3 | WINOUT_WIN01_OBJ);
|
||||
SetGpuReg(REG_OFFSET_WIN0V, 160);
|
||||
SetGpuReg(REG_OFFSET_WIN0H, 240);
|
||||
SetGpuReg(REG_OFFSET_WIN0V, DISPLAY_HEIGHT);
|
||||
SetGpuReg(REG_OFFSET_WIN0H, DISPLAY_WIDTH);
|
||||
if (gReceivedRemoteLinkPlayers)
|
||||
EnableInterrupts(INTR_FLAG_VBLANK | INTR_FLAG_HBLANK | INTR_FLAG_VCOUNT | INTR_FLAG_TIMER3 | INTR_FLAG_SERIAL);
|
||||
else
|
||||
EnableInterrupts(INTR_FLAG_VBLANK | INTR_FLAG_HBLANK);
|
||||
}
|
||||
|
||||
// Part of animating card flip
|
||||
static void sub_80C32EC(u16 arg0)
|
||||
static void UpdateCardFlipRegs(u16 cardTop)
|
||||
{
|
||||
s8 quotient = (arg0 + 40) / 10;
|
||||
s8 blendY = (cardTop + 40) / 10;
|
||||
|
||||
if (quotient <= 4)
|
||||
quotient = 0;
|
||||
sData->flipBlendY = quotient;
|
||||
if (blendY <= 4)
|
||||
blendY = 0;
|
||||
sData->flipBlendY = blendY;
|
||||
SetGpuReg(REG_OFFSET_BLDY, sData->flipBlendY);
|
||||
SetGpuReg(REG_OFFSET_WIN0V, (sData->var_7CA8 * 256) | (160 - sData->var_7CA8));
|
||||
SetGpuReg(REG_OFFSET_WIN0V, WIN_RANGE(sData->cardTop, DISPLAY_HEIGHT - sData->cardTop));
|
||||
}
|
||||
|
||||
static void ResetGpuRegs(void)
|
||||
@@ -1578,6 +1575,7 @@ u8 GetTrainerCardStars(u8 cardId)
|
||||
}
|
||||
|
||||
#define tFlipState data[0]
|
||||
#define tCardTop data[1]
|
||||
|
||||
static void FlipTrainerCard(void)
|
||||
{
|
||||
@@ -1608,41 +1606,43 @@ static bool8 Task_BeginCardFlip(struct Task* task)
|
||||
HideBg(3);
|
||||
ScanlineEffect_Stop();
|
||||
ScanlineEffect_Clear();
|
||||
for (i = 0; i < 160; i++)
|
||||
for (i = 0; i < DISPLAY_HEIGHT; i++)
|
||||
gScanlineEffectRegBuffers[1][i] = 0;
|
||||
task->tFlipState++;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// Note: Cannot be DISPLAY_HEIGHT / 2, or cardHeight will be 0
|
||||
#define CARD_FLIP_Y ((DISPLAY_HEIGHT / 2) - 3)
|
||||
|
||||
static bool8 Task_AnimateCardFlipDown(struct Task* task)
|
||||
{
|
||||
u32 r4, r5, r10, r7, r6, var_24, r9, var;
|
||||
u32 cardHeight, r5, r10, cardTop, r6, var_24, cardBottom, var;
|
||||
s16 i;
|
||||
|
||||
sData->allowDMACopy = FALSE;
|
||||
if (task->data[1] >= 77)
|
||||
task->data[1] = 77;
|
||||
if (task->tCardTop >= CARD_FLIP_Y)
|
||||
task->tCardTop = CARD_FLIP_Y;
|
||||
else
|
||||
task->data[1] += 7;
|
||||
task->tCardTop += 7;
|
||||
|
||||
sData->var_7CA8 = task->data[1];
|
||||
sub_80C32EC(task->data[1]);
|
||||
sData->cardTop = task->tCardTop;
|
||||
UpdateCardFlipRegs(task->tCardTop);
|
||||
|
||||
// ???
|
||||
r7 = task->data[1];
|
||||
r9 = 160 - r7;
|
||||
r4 = r9 - r7;
|
||||
r6 = -r7 << 16;
|
||||
r5 = 0xA00000 / r4;
|
||||
r5 += 0xFFFF0000;
|
||||
cardTop = task->tCardTop;
|
||||
cardBottom = DISPLAY_HEIGHT - cardTop;
|
||||
cardHeight = cardBottom - cardTop;
|
||||
r6 = -cardTop << 16;
|
||||
r5 = (DISPLAY_HEIGHT << 16) / cardHeight;
|
||||
r5 -= 1 << 16;
|
||||
var_24 = r6;
|
||||
var_24 += r5 * r4;
|
||||
r10 = r5 / r4;
|
||||
var_24 += r5 * cardHeight;
|
||||
r10 = r5 / cardHeight;
|
||||
r5 *= 2;
|
||||
|
||||
for (i = 0; i < r7; i++)
|
||||
for (i = 0; i < cardTop; i++)
|
||||
gScanlineEffectRegBuffers[0][i] = -i;
|
||||
for (; i < (s16)(r9); i++)
|
||||
for (; i < (s16)cardBottom; i++)
|
||||
{
|
||||
var = r6 >> 16;
|
||||
r6 += r5;
|
||||
@@ -1650,11 +1650,11 @@ static bool8 Task_AnimateCardFlipDown(struct Task* task)
|
||||
gScanlineEffectRegBuffers[0][i] = var;
|
||||
}
|
||||
var = var_24 >> 16;
|
||||
for (; i < 160; i++)
|
||||
for (; i < DISPLAY_HEIGHT; i++)
|
||||
gScanlineEffectRegBuffers[0][i] = var;
|
||||
|
||||
sData->allowDMACopy = TRUE;
|
||||
if (task->data[1] >= 77)
|
||||
if (task->tCardTop >= CARD_FLIP_Y)
|
||||
task->tFlipState++;
|
||||
|
||||
return FALSE;
|
||||
@@ -1663,7 +1663,7 @@ static bool8 Task_AnimateCardFlipDown(struct Task* task)
|
||||
static bool8 Task_DrawFlippedCardSide(struct Task* task)
|
||||
{
|
||||
sData->allowDMACopy = FALSE;
|
||||
if (sub_8087598() == TRUE)
|
||||
if (Overworld_LinkRecvQueueLengthMoreThan2() == TRUE)
|
||||
return FALSE;
|
||||
|
||||
do
|
||||
@@ -1736,33 +1736,32 @@ static bool8 Task_SetCardFlipped(struct Task* task)
|
||||
|
||||
static bool8 Task_AnimateCardFlipUp(struct Task* task)
|
||||
{
|
||||
u32 r4, r5, r10, r7, r6, var_24, r9, var;
|
||||
u32 cardHeight, r5, r10, cardTop, r6, var_24, cardBottom, var;
|
||||
s16 i;
|
||||
|
||||
sData->allowDMACopy = FALSE;
|
||||
if (task->data[1] <= 5)
|
||||
task->data[1] = 0;
|
||||
if (task->tCardTop <= 5)
|
||||
task->tCardTop = 0;
|
||||
else
|
||||
task->data[1] -= 5;
|
||||
task->tCardTop -= 5;
|
||||
|
||||
sData->var_7CA8 = task->data[1];
|
||||
sub_80C32EC(task->data[1]);
|
||||
sData->cardTop = task->tCardTop;
|
||||
UpdateCardFlipRegs(task->tCardTop);
|
||||
|
||||
// ???
|
||||
r7 = task->data[1];
|
||||
r9 = 160 - r7;
|
||||
r4 = r9 - r7;
|
||||
r6 = -r7 << 16;
|
||||
r5 = 0xA00000 / r4;
|
||||
r5 += 0xFFFF0000;
|
||||
cardTop = task->tCardTop;
|
||||
cardBottom = DISPLAY_HEIGHT - cardTop;
|
||||
cardHeight = cardBottom - cardTop;
|
||||
r6 = -cardTop << 16;
|
||||
r5 = (DISPLAY_HEIGHT << 16) / cardHeight;
|
||||
r5 -= 1 << 16;
|
||||
var_24 = r6;
|
||||
var_24 += r5 * r4;
|
||||
r10 = r5 / r4;
|
||||
var_24 += r5 * cardHeight;
|
||||
r10 = r5 / cardHeight;
|
||||
r5 /= 2;
|
||||
|
||||
for (i = 0; i < r7; i++)
|
||||
for (i = 0; i < cardTop; i++)
|
||||
gScanlineEffectRegBuffers[0][i] = -i;
|
||||
for (; i < (s16)(r9); i++)
|
||||
for (; i < (s16)cardBottom; i++)
|
||||
{
|
||||
var = r6 >> 16;
|
||||
r6 += r5;
|
||||
@@ -1770,11 +1769,11 @@ static bool8 Task_AnimateCardFlipUp(struct Task* task)
|
||||
gScanlineEffectRegBuffers[0][i] = var;
|
||||
}
|
||||
var = var_24 >> 16;
|
||||
for (; i < 160; i++)
|
||||
for (; i < DISPLAY_HEIGHT; i++)
|
||||
gScanlineEffectRegBuffers[0][i] = var;
|
||||
|
||||
sData->allowDMACopy = TRUE;
|
||||
if (task->data[1] <= 0)
|
||||
if (task->tCardTop <= 0)
|
||||
task->tFlipState++;
|
||||
|
||||
return FALSE;
|
||||
|
||||
+5
-5
@@ -74,7 +74,7 @@ static void GetChallengeWon(void);
|
||||
static void TrainerHillSetTag(void);
|
||||
static void SetUpDataStruct(void);
|
||||
static void FreeDataStruct(void);
|
||||
static void nullsub_2(void);
|
||||
static void TrainerHillDummy(void);
|
||||
static void SetTimerValue(u32 *dst, u32 val);
|
||||
static u32 GetTimerValue(u32 *src);
|
||||
static void SetTrainerHillMonLevel(struct Pokemon *mon, u8 level);
|
||||
@@ -358,7 +358,7 @@ static void SetUpDataStruct(void)
|
||||
sHillData = AllocZeroed(sizeof(*sHillData));
|
||||
sHillData->floorId = gMapHeader.mapLayoutId - LAYOUT_TRAINER_HILL_1F;
|
||||
CpuCopy32(sDataPerTag[gSaveBlock1Ptr->trainerHill.tag], &sHillData->tag, sizeof(sHillData->tag) + 4 * sizeof(struct TrHillFloor));
|
||||
nullsub_2();
|
||||
TrainerHillDummy();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -397,7 +397,7 @@ void CopyTrainerHillTrainerText(u8 which, u16 trainerId)
|
||||
|
||||
static void TrainerHillStartChallenge(void)
|
||||
{
|
||||
nullsub_2();
|
||||
TrainerHillDummy();
|
||||
if (!ReadTrainerHillAndValidate())
|
||||
gSaveBlock1Ptr->trainerHill.field_3D6E_0f = 1;
|
||||
else
|
||||
@@ -573,12 +573,12 @@ static void IsTrainerHillChallengeActive(void)
|
||||
gSpecialVar_Result = TRUE;
|
||||
}
|
||||
|
||||
void nullsub_129(void)
|
||||
static void TrainerHillDummy_Unused(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
static void nullsub_2(void)
|
||||
static void TrainerHillDummy(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@@ -75,9 +75,6 @@ EWRAM_DATA ALIGNED(4) u8 sTVShowState = 0;
|
||||
EWRAM_DATA u8 sTVSecretBaseSecretsRandomValues[3] = {};
|
||||
|
||||
// Static ROM declarations
|
||||
#if !defined(NONMATCHING) && MODERN
|
||||
#define static
|
||||
#endif
|
||||
void ClearPokemonNews(void);
|
||||
u8 GetTVChannelByShowType(u8 kind);
|
||||
u8 FindFirstActiveTVShowThatIsNotAMassOutbreak(void);
|
||||
|
||||
+11
-11
@@ -5,7 +5,7 @@
|
||||
#include "sound.h"
|
||||
|
||||
ALIGNED(4)
|
||||
static const u8 sUnknown_08616124[] = {1, 2, 4};
|
||||
static const u8 sScrollDistances[] = {1, 2, 4};
|
||||
static const u16 sFont6BrailleGlyphs[] = INCBIN_U16("graphics/fonts/font6.fwjpnfont");
|
||||
|
||||
static void DecompressGlyphFont6(u16);
|
||||
@@ -135,7 +135,7 @@ u16 Font6Func(struct TextPrinter *textPrinter)
|
||||
}
|
||||
DecompressGlyphFont6(char_);
|
||||
CopyGlyphToWindow(textPrinter);
|
||||
textPrinter->printerTemplate.currentX += gUnknown_03002F90.width + textPrinter->printerTemplate.letterSpacing;
|
||||
textPrinter->printerTemplate.currentX += gCurGlyph.width + textPrinter->printerTemplate.letterSpacing;
|
||||
return 0;
|
||||
case 1:
|
||||
if (TextPrinterWait(textPrinter))
|
||||
@@ -164,15 +164,15 @@ u16 Font6Func(struct TextPrinter *textPrinter)
|
||||
case 4:
|
||||
if (textPrinter->scrollDistance)
|
||||
{
|
||||
if (textPrinter->scrollDistance < sUnknown_08616124[gSaveBlock2Ptr->optionsTextSpeed])
|
||||
if (textPrinter->scrollDistance < sScrollDistances[gSaveBlock2Ptr->optionsTextSpeed])
|
||||
{
|
||||
ScrollWindow(textPrinter->printerTemplate.windowId, 0, textPrinter->scrollDistance, PIXEL_FILL(textPrinter->printerTemplate.bgColor));
|
||||
textPrinter->scrollDistance = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
ScrollWindow(textPrinter->printerTemplate.windowId, 0, sUnknown_08616124[gSaveBlock2Ptr->optionsTextSpeed], PIXEL_FILL(textPrinter->printerTemplate.bgColor));
|
||||
textPrinter->scrollDistance -= sUnknown_08616124[gSaveBlock2Ptr->optionsTextSpeed];
|
||||
ScrollWindow(textPrinter->printerTemplate.windowId, 0, sScrollDistances[gSaveBlock2Ptr->optionsTextSpeed], PIXEL_FILL(textPrinter->printerTemplate.bgColor));
|
||||
textPrinter->scrollDistance -= sScrollDistances[gSaveBlock2Ptr->optionsTextSpeed];
|
||||
}
|
||||
CopyWindowToVram(textPrinter->printerTemplate.windowId, 2);
|
||||
}
|
||||
@@ -206,12 +206,12 @@ static void DecompressGlyphFont6(u16 glyph)
|
||||
const u16 *glyphs;
|
||||
|
||||
glyphs = sFont6BrailleGlyphs + 0x100 * (glyph / 8) + 0x10 * (glyph % 8);
|
||||
DecompressGlyphTile(glyphs, (u16 *)gUnknown_03002F90.unk0);
|
||||
DecompressGlyphTile(glyphs + 0x8, (u16 *)(gUnknown_03002F90.unk20));
|
||||
DecompressGlyphTile(glyphs + 0x80, (u16 *)(gUnknown_03002F90.unk40));
|
||||
DecompressGlyphTile(glyphs + 0x88, (u16 *)(gUnknown_03002F90.unk60));
|
||||
gUnknown_03002F90.width = 0x10;
|
||||
gUnknown_03002F90.height = 0x10;
|
||||
DecompressGlyphTile(glyphs, gCurGlyph.gfxBufferTop);
|
||||
DecompressGlyphTile(glyphs + 0x8, gCurGlyph.gfxBufferTop + 8);
|
||||
DecompressGlyphTile(glyphs + 0x80, gCurGlyph.gfxBufferBottom);
|
||||
DecompressGlyphTile(glyphs + 0x88, gCurGlyph.gfxBufferBottom + 8);
|
||||
gCurGlyph.width = 0x10;
|
||||
gCurGlyph.height = 0x10;
|
||||
}
|
||||
|
||||
u32 GetGlyphWidthFont6(u16 glyphId, bool32 isJapanese)
|
||||
|
||||
Reference in New Issue
Block a user