Document remaining functions in cable_club

This commit is contained in:
GriffinR 2021-08-15 16:11:30 -04:00
parent e01ae55c13
commit dfdcfc1568
14 changed files with 77 additions and 97 deletions

View File

@ -43,7 +43,7 @@ gSpecials:: @ 81DBA64
def_special CloseLink def_special CloseLink
def_special ColosseumPlayerSpotTriggered def_special ColosseumPlayerSpotTriggered
def_special PlayerEnteredTradeSeat def_special PlayerEnteredTradeSeat
def_special nullsub_37 def_special Script_StartWiredTrade
def_special CableClubSaveGame def_special CableClubSaveGame
def_special TryBerryBlenderLinkup def_special TryBerryBlenderLinkup
def_special GetLinkPartnerNames def_special GetLinkPartnerNames

View File

@ -104,6 +104,14 @@
#define LINKTYPE_CONTEST_GMODE 0x6601 #define LINKTYPE_CONTEST_GMODE 0x6601
#define LINKTYPE_CONTEST_EMODE 0x6602 #define LINKTYPE_CONTEST_EMODE 0x6602
enum {
BLOCK_REQ_SIZE_NONE, // Identical to 200
BLOCK_REQ_SIZE_200,
BLOCK_REQ_SIZE_100,
BLOCK_REQ_SIZE_220,
BLOCK_REQ_SIZE_40,
};
struct LinkStatus struct LinkStatus
{ {
u32 localId:2; u32 localId:2;
@ -227,8 +235,6 @@ struct BlockRequest
u32 size; u32 size;
}; };
extern const struct BlockRequest sBlockRequestLookupTable[5];
extern struct Link gLink; extern struct Link gLink;
extern u16 gRecvCmds[MAX_RFU_PLAYERS][CMD_LENGTH]; extern u16 gRecvCmds[MAX_RFU_PLAYERS][CMD_LENGTH];
extern u8 gBlockSendBuffer[BLOCK_BUFFER_SIZE]; extern u8 gBlockSendBuffer[BLOCK_BUFFER_SIZE];
@ -236,8 +242,7 @@ extern u16 gLinkType;
extern u32 gLinkStatus; extern u32 gLinkStatus;
extern u16 gBlockRecvBuffer[MAX_RFU_PLAYERS][BLOCK_BUFFER_SIZE / 2]; extern u16 gBlockRecvBuffer[MAX_RFU_PLAYERS][BLOCK_BUFFER_SIZE / 2];
extern u16 gSendCmd[CMD_LENGTH]; extern u16 gSendCmd[CMD_LENGTH];
extern struct LinkPlayer gLinkPlayers[5]; extern struct LinkPlayer gLinkPlayers[MAX_RFU_PLAYERS];
extern u16 word_3002910[];
extern bool8 gReceivedRemoteLinkPlayers; extern bool8 gReceivedRemoteLinkPlayers;
extern u32 gBerryBlenderKeySendAttempts; extern u32 gBerryBlenderKeySendAttempts;
extern bool8 gLinkVSyncDisabled; extern bool8 gLinkVSyncDisabled;
@ -249,8 +254,6 @@ void Task_DestroySelf(u8 taskId);
void OpenLink(void); void OpenLink(void);
void CloseLink(void); void CloseLink(void);
u16 LinkMain2(const u16 *); u16 LinkMain2(const u16 *);
void sub_8007B14(void);
bool32 sub_8007B24(void);
void ClearLinkCallback(void); void ClearLinkCallback(void);
void ClearLinkCallback_2(void); void ClearLinkCallback_2(void);
u8 GetLinkPlayerCount(void); u8 GetLinkPlayerCount(void);
@ -259,10 +262,8 @@ u8 GetLinkPlayerDataExchangeStatusTimed(int lower, int upper);
bool8 IsLinkPlayerDataExchangeComplete(void); bool8 IsLinkPlayerDataExchangeComplete(void);
u32 GetLinkPlayerTrainerId(u8); u32 GetLinkPlayerTrainerId(u8);
void ResetLinkPlayers(void); void ResetLinkPlayers(void);
void sub_8007E24(void);
void sub_8007E4C(void);
u8 GetMultiplayerId(void); u8 GetMultiplayerId(void);
u8 bitmask_all_link_players_but_self(void); u8 BitmaskAllOtherLinkPlayers(void);
bool8 SendBlock(u8, const void *, u16); bool8 SendBlock(u8, const void *, u16);
u8 GetBlockReceivedStatus(void); u8 GetBlockReceivedStatus(void);
void ResetBlockReceivedFlags(void); void ResetBlockReceivedFlags(void);
@ -270,7 +271,7 @@ void ResetBlockReceivedFlag(u8);
u8 GetLinkPlayerCount_2(void); u8 GetLinkPlayerCount_2(void);
bool8 IsLinkMaster(void); bool8 IsLinkMaster(void);
void CB2_LinkError(void); void CB2_LinkError(void);
u8 GetSioMultiSI(void); bool8 GetSioMultiSI(void);
bool8 IsLinkConnectionEstablished(void); bool8 IsLinkConnectionEstablished(void);
bool8 HasLinkErrorOccurred(void); bool8 HasLinkErrorOccurred(void);
void ResetSerial(void); void ResetSerial(void);
@ -285,14 +286,12 @@ void CreateWirelessStatusIndicatorSprite(u8, u8);
void SetLinkStandbyCallback(void); void SetLinkStandbyCallback(void);
void SetWirelessCommType1(void); void SetWirelessCommType1(void);
void CheckShouldAdvanceLinkState(void); void CheckShouldAdvanceLinkState(void);
u8 IsLinkMaster(void);
void SetCloseLinkCallback(void); void SetCloseLinkCallback(void);
bool8 HandleLinkConnection(void); bool8 HandleLinkConnection(void);
void SetLinkDebugValues(u32 seed, u32 flags); void SetLinkDebugValues(u32 seed, u32 flags);
void SetBerryBlenderLinkCallback(void); void SetBerryBlenderLinkCallback(void);
void SetSuppressLinkErrorMessage(bool8 flag); void SetSuppressLinkErrorMessage(bool8 flag);
void ConvertLinkPlayerName(struct LinkPlayer *linkPlayer); void ConvertLinkPlayerName(struct LinkPlayer *linkPlayer);
u8 GetSioMultiSI(void);
void ClearSavedLinkPlayers(void); void ClearSavedLinkPlayers(void);
void BufferLinkErrorInfo(u32 status, u8 lastSendQueueCount, u8 lastRecvQueueCount, bool8 disconnected); void BufferLinkErrorInfo(u32 status, u8 lastSendQueueCount, u8 lastRecvQueueCount, bool8 disconnected);
void LocalLinkPlayerToBlock(void); void LocalLinkPlayerToBlock(void);
@ -312,8 +311,6 @@ extern bool8 gRemoteLinkPlayersNotReceived[MAX_LINK_PLAYERS];
extern u8 gBlockReceivedStatus[MAX_LINK_PLAYERS]; extern u8 gBlockReceivedStatus[MAX_LINK_PLAYERS];
extern u16 gLinkHeldKeys; extern u16 gLinkHeldKeys;
extern u32 gLinkStatus; extern u32 gLinkStatus;
extern u8 gUnknown_030030E4;
extern u8 gUnknown_030030E8;
extern bool8 gReadyToExitStandby[MAX_LINK_PLAYERS]; extern bool8 gReadyToExitStandby[MAX_LINK_PLAYERS];
extern bool8 gReadyToCloseLink[MAX_LINK_PLAYERS]; extern bool8 gReadyToCloseLink[MAX_LINK_PLAYERS];
extern u16 gReadyCloseLinkType; extern u16 gReadyCloseLinkType;
@ -329,23 +326,14 @@ extern u8 gBlockRequestType;
extern u8 gLastSendQueueCount; extern u8 gLastSendQueueCount;
extern u8 gLastRecvQueueCount; extern u8 gLastRecvQueueCount;
extern u16 gLinkSavedIme; extern u16 gLinkSavedIme;
extern u32 gFiller_03003074;
extern u32 gFiller_03003154;
extern u32 gFiller_03003158;
extern u32 gFiller_0300315c;
extern u32 gFiller_03004138;
extern u32 gFiller_0300413C;
extern u32 gFiller_03003080;
extern struct LinkPlayer gLocalLinkPlayer; extern struct LinkPlayer gLocalLinkPlayer;
bool32 Link_AnyPartnersPlayingRubyOrSapphire(void); bool32 Link_AnyPartnersPlayingRubyOrSapphire(void);
bool32 LinkDummy_Return2(void); bool32 LinkDummy_Return2(void);
void SetLocalLinkPlayerId(u8); void SetLocalLinkPlayerId(u8);
u8 GetSavedPlayerCount(void); u8 GetSavedPlayerCount(void);
void sub_8009FAC(void);
bool8 SendBlockRequest(u8 type); bool8 SendBlockRequest(u8 type);
u8 GetLinkPlayerCountAsBitFlags(void); u8 GetLinkPlayerCountAsBitFlags(void);
u8 sub_800A0C8(s32, s32);
u8 GetSavedLinkPlayerCountAsBitFlags(void); u8 GetSavedLinkPlayerCountAsBitFlags(void);
void SetCloseLinkCallbackHandleJP(void); void SetCloseLinkCallbackHandleJP(void);
void CheckLinkPlayersMatchSaved(void); void CheckLinkPlayersMatchSaved(void);

View File

@ -789,7 +789,7 @@ static void Task_HandleSendLinkBuffersData(u8 taskId)
gTasks[taskId].data[15] = 0; gTasks[taskId].data[15] = 0;
} }
blockSize = (gLinkBattleSendBuffer[gTasks[taskId].data[15] + LINK_BUFF_SIZE_LO] | (gLinkBattleSendBuffer[gTasks[taskId].data[15] + LINK_BUFF_SIZE_HI] << 8)) + LINK_BUFF_DATA; blockSize = (gLinkBattleSendBuffer[gTasks[taskId].data[15] + LINK_BUFF_SIZE_LO] | (gLinkBattleSendBuffer[gTasks[taskId].data[15] + LINK_BUFF_SIZE_HI] << 8)) + LINK_BUFF_DATA;
SendBlock(bitmask_all_link_players_but_self(), &gLinkBattleSendBuffer[gTasks[taskId].data[15]], blockSize); SendBlock(BitmaskAllOtherLinkPlayers(), &gLinkBattleSendBuffer[gTasks[taskId].data[15]], blockSize);
gTasks[taskId].data[11]++; gTasks[taskId].data[11]++;
} }
else else

View File

@ -986,7 +986,7 @@ static void CB2_HandleStartBattle(void)
gLinkPlayers[1].id = 1; gLinkPlayers[1].id = 1;
} }
SendBlock(bitmask_all_link_players_but_self(), &gBattleStruct->multiBuffer.linkBattlerHeader, sizeof(gBattleStruct->multiBuffer.linkBattlerHeader)); SendBlock(BitmaskAllOtherLinkPlayers(), &gBattleStruct->multiBuffer.linkBattlerHeader, sizeof(gBattleStruct->multiBuffer.linkBattlerHeader));
gBattleCommunication[MULTIUSE_STATE] = 2; gBattleCommunication[MULTIUSE_STATE] = 2;
} }
if (gWirelessCommType) if (gWirelessCommType)
@ -1024,7 +1024,7 @@ static void CB2_HandleStartBattle(void)
case 3: case 3:
if (IsLinkTaskFinished()) if (IsLinkTaskFinished())
{ {
SendBlock(bitmask_all_link_players_but_self(), gPlayerParty, sizeof(struct Pokemon) * 2); SendBlock(BitmaskAllOtherLinkPlayers(), gPlayerParty, sizeof(struct Pokemon) * 2);
gBattleCommunication[MULTIUSE_STATE]++; gBattleCommunication[MULTIUSE_STATE]++;
} }
break; break;
@ -1039,7 +1039,7 @@ static void CB2_HandleStartBattle(void)
case 7: case 7:
if (IsLinkTaskFinished()) if (IsLinkTaskFinished())
{ {
SendBlock(bitmask_all_link_players_but_self(), gPlayerParty + 2, sizeof(struct Pokemon) * 2); SendBlock(BitmaskAllOtherLinkPlayers(), gPlayerParty + 2, sizeof(struct Pokemon) * 2);
gBattleCommunication[MULTIUSE_STATE]++; gBattleCommunication[MULTIUSE_STATE]++;
} }
break; break;
@ -1054,7 +1054,7 @@ static void CB2_HandleStartBattle(void)
case 11: case 11:
if (IsLinkTaskFinished()) if (IsLinkTaskFinished())
{ {
SendBlock(bitmask_all_link_players_but_self(), gPlayerParty + 4, sizeof(struct Pokemon) * 2); SendBlock(BitmaskAllOtherLinkPlayers(), gPlayerParty + 4, sizeof(struct Pokemon) * 2);
gBattleCommunication[MULTIUSE_STATE]++; gBattleCommunication[MULTIUSE_STATE]++;
} }
break; break;
@ -1096,7 +1096,7 @@ static void CB2_HandleStartBattle(void)
case 16: case 16:
if (IsLinkTaskFinished()) if (IsLinkTaskFinished())
{ {
SendBlock(bitmask_all_link_players_but_self(), &gRecordedBattleRngSeed, sizeof(gRecordedBattleRngSeed)); SendBlock(BitmaskAllOtherLinkPlayers(), &gRecordedBattleRngSeed, sizeof(gRecordedBattleRngSeed));
gBattleCommunication[MULTIUSE_STATE]++; gBattleCommunication[MULTIUSE_STATE]++;
} }
break; break;
@ -1188,7 +1188,7 @@ static void CB2_HandleStartMultiPartnerBattle(void)
*(&gBattleStruct->multiBuffer.linkBattlerHeader.versionSignatureHi) = 3; *(&gBattleStruct->multiBuffer.linkBattlerHeader.versionSignatureHi) = 3;
BufferPartyVsScreenHealth_AtStart(); BufferPartyVsScreenHealth_AtStart();
SetPlayerBerryDataInBattleStruct(); SetPlayerBerryDataInBattleStruct();
SendBlock(bitmask_all_link_players_but_self(), &gBattleStruct->multiBuffer.linkBattlerHeader, sizeof(gBattleStruct->multiBuffer.linkBattlerHeader)); SendBlock(BitmaskAllOtherLinkPlayers(), &gBattleStruct->multiBuffer.linkBattlerHeader, sizeof(gBattleStruct->multiBuffer.linkBattlerHeader));
gBattleCommunication[MULTIUSE_STATE] = 2; gBattleCommunication[MULTIUSE_STATE] = 2;
} }
@ -1224,7 +1224,7 @@ static void CB2_HandleStartMultiPartnerBattle(void)
case 3: case 3:
if (IsLinkTaskFinished()) if (IsLinkTaskFinished())
{ {
SendBlock(bitmask_all_link_players_but_self(), gPlayerParty, sizeof(struct Pokemon) * 2); SendBlock(BitmaskAllOtherLinkPlayers(), gPlayerParty, sizeof(struct Pokemon) * 2);
gBattleCommunication[MULTIUSE_STATE]++; gBattleCommunication[MULTIUSE_STATE]++;
} }
break; break;
@ -1248,7 +1248,7 @@ static void CB2_HandleStartMultiPartnerBattle(void)
case 5: case 5:
if (IsLinkTaskFinished()) if (IsLinkTaskFinished())
{ {
SendBlock(bitmask_all_link_players_but_self(), gPlayerParty + 2, sizeof(struct Pokemon)); SendBlock(BitmaskAllOtherLinkPlayers(), gPlayerParty + 2, sizeof(struct Pokemon));
gBattleCommunication[MULTIUSE_STATE]++; gBattleCommunication[MULTIUSE_STATE]++;
} }
break; break;
@ -1272,7 +1272,7 @@ static void CB2_HandleStartMultiPartnerBattle(void)
case 7: case 7:
if (IsLinkTaskFinished()) if (IsLinkTaskFinished())
{ {
SendBlock(bitmask_all_link_players_but_self(), gEnemyParty, sizeof(struct Pokemon) * 2); SendBlock(BitmaskAllOtherLinkPlayers(), gEnemyParty, sizeof(struct Pokemon) * 2);
gBattleCommunication[MULTIUSE_STATE]++; gBattleCommunication[MULTIUSE_STATE]++;
} }
break; break;
@ -1290,7 +1290,7 @@ static void CB2_HandleStartMultiPartnerBattle(void)
case 9: case 9:
if (IsLinkTaskFinished()) if (IsLinkTaskFinished())
{ {
SendBlock(bitmask_all_link_players_but_self(), gEnemyParty + 2, sizeof(struct Pokemon) * 2); SendBlock(BitmaskAllOtherLinkPlayers(), gEnemyParty + 2, sizeof(struct Pokemon) * 2);
gBattleCommunication[MULTIUSE_STATE]++; gBattleCommunication[MULTIUSE_STATE]++;
} }
break; break;
@ -1308,7 +1308,7 @@ static void CB2_HandleStartMultiPartnerBattle(void)
case 11: case 11:
if (IsLinkTaskFinished()) if (IsLinkTaskFinished())
{ {
SendBlock(bitmask_all_link_players_but_self(), gEnemyParty + 4, sizeof(struct Pokemon) * 2); SendBlock(BitmaskAllOtherLinkPlayers(), gEnemyParty + 4, sizeof(struct Pokemon) * 2);
gBattleCommunication[MULTIUSE_STATE]++; gBattleCommunication[MULTIUSE_STATE]++;
} }
break; break;
@ -1350,7 +1350,7 @@ static void CB2_HandleStartMultiPartnerBattle(void)
case 14: case 14:
if (IsLinkTaskFinished()) if (IsLinkTaskFinished())
{ {
SendBlock(bitmask_all_link_players_but_self(), &gRecordedBattleRngSeed, sizeof(gRecordedBattleRngSeed)); SendBlock(BitmaskAllOtherLinkPlayers(), &gRecordedBattleRngSeed, sizeof(gRecordedBattleRngSeed));
gBattleCommunication[MULTIUSE_STATE]++; gBattleCommunication[MULTIUSE_STATE]++;
} }
break; break;
@ -1432,7 +1432,7 @@ static void CB2_PreInitMultiBattle(void)
{ {
sMultiPartnerPartyBuffer = Alloc(sizeof(struct UnknownPokemonStruct4) * ARRAY_COUNT(gMultiPartnerParty)); sMultiPartnerPartyBuffer = Alloc(sizeof(struct UnknownPokemonStruct4) * ARRAY_COUNT(gMultiPartnerParty));
sub_80379F8(0); sub_80379F8(0);
SendBlock(bitmask_all_link_players_but_self(), sMultiPartnerPartyBuffer, sizeof(struct UnknownPokemonStruct4) * ARRAY_COUNT(gMultiPartnerParty)); SendBlock(BitmaskAllOtherLinkPlayers(), sMultiPartnerPartyBuffer, sizeof(struct UnknownPokemonStruct4) * ARRAY_COUNT(gMultiPartnerParty));
gBattleCommunication[MULTIUSE_STATE]++; gBattleCommunication[MULTIUSE_STATE]++;
} }
break; break;
@ -1577,7 +1577,7 @@ static void CB2_HandleStartMultiBattle(void)
BufferPartyVsScreenHealth_AtStart(); BufferPartyVsScreenHealth_AtStart();
SetPlayerBerryDataInBattleStruct(); SetPlayerBerryDataInBattleStruct();
SendBlock(bitmask_all_link_players_but_self(), &gBattleStruct->multiBuffer.linkBattlerHeader, sizeof(gBattleStruct->multiBuffer.linkBattlerHeader)); SendBlock(BitmaskAllOtherLinkPlayers(), &gBattleStruct->multiBuffer.linkBattlerHeader, sizeof(gBattleStruct->multiBuffer.linkBattlerHeader));
gBattleCommunication[MULTIUSE_STATE]++; gBattleCommunication[MULTIUSE_STATE]++;
} }
if (gWirelessCommType) if (gWirelessCommType)
@ -1634,7 +1634,7 @@ static void CB2_HandleStartMultiBattle(void)
case 3: case 3:
if (IsLinkTaskFinished()) if (IsLinkTaskFinished())
{ {
SendBlock(bitmask_all_link_players_but_self(), gPlayerParty, sizeof(struct Pokemon) * 2); SendBlock(BitmaskAllOtherLinkPlayers(), gPlayerParty, sizeof(struct Pokemon) * 2);
gBattleCommunication[MULTIUSE_STATE]++; gBattleCommunication[MULTIUSE_STATE]++;
} }
break; break;
@ -1697,7 +1697,7 @@ static void CB2_HandleStartMultiBattle(void)
case 5: case 5:
if (IsLinkTaskFinished()) if (IsLinkTaskFinished())
{ {
SendBlock(bitmask_all_link_players_but_self(), gPlayerParty + 2, sizeof(struct Pokemon)); SendBlock(BitmaskAllOtherLinkPlayers(), gPlayerParty + 2, sizeof(struct Pokemon));
gBattleCommunication[MULTIUSE_STATE]++; gBattleCommunication[MULTIUSE_STATE]++;
} }
break; break;
@ -1796,7 +1796,7 @@ static void CB2_HandleStartMultiBattle(void)
u32* ptr = gBattleStruct->multiBuffer.battleVideo; u32* ptr = gBattleStruct->multiBuffer.battleVideo;
ptr[0] = gBattleTypeFlags; ptr[0] = gBattleTypeFlags;
ptr[1] = gRecordedBattleRngSeed; // UB: overwrites berry data ptr[1] = gRecordedBattleRngSeed; // UB: overwrites berry data
SendBlock(bitmask_all_link_players_but_self(), ptr, sizeof(gBattleStruct->multiBuffer.battleVideo)); SendBlock(BitmaskAllOtherLinkPlayers(), ptr, sizeof(gBattleStruct->multiBuffer.battleVideo));
gBattleCommunication[MULTIUSE_STATE]++; gBattleCommunication[MULTIUSE_STATE]++;
} }
break; break;

View File

@ -2575,7 +2575,7 @@ static void LoadLinkMultiOpponentsData(void)
challengeNum = gSaveBlock2Ptr->frontier.towerWinStreaks[battleMode][lvlMode] / 7; challengeNum = gSaveBlock2Ptr->frontier.towerWinStreaks[battleMode][lvlMode] / 7;
if (IsLinkTaskFinished()) if (IsLinkTaskFinished())
{ {
SendBlock(bitmask_all_link_players_but_self(), &challengeNum, sizeof(challengeNum)); SendBlock(BitmaskAllOtherLinkPlayers(), &challengeNum, sizeof(challengeNum));
gSpecialVar_Result = 1; gSpecialVar_Result = 1;
} }
} }
@ -2612,7 +2612,7 @@ static void LoadLinkMultiOpponentsData(void)
case 2: case 2:
if (IsLinkTaskFinished()) if (IsLinkTaskFinished())
{ {
SendBlock(bitmask_all_link_players_but_self(), &gSaveBlock2Ptr->frontier.trainerIds, sizeof(gSaveBlock2Ptr->frontier.trainerIds)); SendBlock(BitmaskAllOtherLinkPlayers(), &gSaveBlock2Ptr->frontier.trainerIds, sizeof(gSaveBlock2Ptr->frontier.trainerIds));
gSpecialVar_Result = 3; gSpecialVar_Result = 3;
} }
break; break;

View File

@ -1355,7 +1355,7 @@ static void CB2_StartBlenderLink(void)
{ {
ResetBlockReceivedFlags(); ResetBlockReceivedFlags();
if (GetMultiplayerId() == 0) if (GetMultiplayerId() == 0)
SendBlockRequest(4); SendBlockRequest(BLOCK_REQ_SIZE_40);
sBerryBlender->mainState++; sBerryBlender->mainState++;
} }
break; break;

View File

@ -185,9 +185,9 @@ static bool32 CheckLinkCanceled(u8 taskId)
return FALSE; return FALSE;
} }
static bool32 sub_80B25CC(u8 taskId) static bool32 CheckSioErrored(u8 taskId)
{ {
if (GetSioMultiSI() == 1) if (GetSioMultiSI() == TRUE)
{ {
gTasks[taskId].func = Task_LinkupConnectionError; gTasks[taskId].func = Task_LinkupConnectionError;
return TRUE; return TRUE;
@ -196,12 +196,12 @@ static bool32 sub_80B25CC(u8 taskId)
} }
// Unused // Unused
static void sub_80B2600(u8 taskId) static void Task_DelayedBlockRequest(u8 taskId)
{ {
gTasks[taskId].data[0]++; gTasks[taskId].data[0]++;
if (gTasks[taskId].data[0] == 10) if (gTasks[taskId].data[0] == 10)
{ {
SendBlockRequest(2); SendBlockRequest(BLOCK_REQ_SIZE_100);
DestroyTask(taskId); DestroyTask(taskId);
} }
} }
@ -252,7 +252,7 @@ static void Task_LinkupAwaitConnection(u8 taskId)
static void Task_LinkupConfirmWhenReady(u8 taskId) static void Task_LinkupConfirmWhenReady(u8 taskId)
{ {
if (CheckLinkCanceledBeforeConnection(taskId) == TRUE if (CheckLinkCanceledBeforeConnection(taskId) == TRUE
|| sub_80B25CC(taskId) == TRUE || CheckSioErrored(taskId) == TRUE
|| CheckLinkErrored(taskId) == TRUE) || CheckLinkErrored(taskId) == TRUE)
return; return;
@ -269,7 +269,7 @@ static void Task_LinkupAwaitConfirmation(u8 taskId)
s32 linkPlayerCount = GetLinkPlayerCount_2(); s32 linkPlayerCount = GetLinkPlayerCount_2();
if (CheckLinkCanceledBeforeConnection(taskId) == TRUE if (CheckLinkCanceledBeforeConnection(taskId) == TRUE
|| sub_80B25CC(taskId) == TRUE || CheckSioErrored(taskId) == TRUE
|| CheckLinkErrored(taskId) == TRUE) || CheckLinkErrored(taskId) == TRUE)
return; return;
@ -291,7 +291,7 @@ static void Task_LinkupAwaitConfirmation(u8 taskId)
static void Task_LinkupTryConfirmation(u8 taskId) static void Task_LinkupTryConfirmation(u8 taskId)
{ {
if (CheckLinkCanceledBeforeConnection(taskId) == TRUE if (CheckLinkCanceledBeforeConnection(taskId) == TRUE
|| sub_80B25CC(taskId) == TRUE || CheckSioErrored(taskId) == TRUE
|| CheckLinkErrored(taskId) == TRUE) || CheckLinkErrored(taskId) == TRUE)
return; return;
@ -424,7 +424,7 @@ static void Task_LinkupCheckStatusAfterConfirm(u8 taskId)
card->monSpecies[0] = GetMonData(&gPlayerParty[gSelectedOrderFromParty[0] - 1], MON_DATA_SPECIES, NULL); card->monSpecies[0] = GetMonData(&gPlayerParty[gSelectedOrderFromParty[0] - 1], MON_DATA_SPECIES, NULL);
card->monSpecies[1] = GetMonData(&gPlayerParty[gSelectedOrderFromParty[1] - 1], MON_DATA_SPECIES, NULL); card->monSpecies[1] = GetMonData(&gPlayerParty[gSelectedOrderFromParty[1] - 1], MON_DATA_SPECIES, NULL);
gTasks[taskId].func = Task_LinkupAwaitTrainerCardData; gTasks[taskId].func = Task_LinkupAwaitTrainerCardData;
SendBlockRequest(2); SendBlockRequest(BLOCK_REQ_SIZE_100);
} }
} }
@ -1172,9 +1172,11 @@ static void CreateTask_StartWiredTrade(void)
CreateTask(Task_StartWiredTrade, 80); CreateTask(Task_StartWiredTrade, 80);
} }
void nullsub_37(void) // Unused, implemented in Ruby/Sapphire
void Script_StartWiredTrade(void)
{ {
// CreateTask_StartWiredTrade();
// ScriptContext1_Stop();
} }
void ColosseumPlayerSpotTriggered(void) void ColosseumPlayerSpotTriggered(void)
@ -1251,7 +1253,7 @@ void Task_WaitForLinkPlayerConnection(u8 taskId)
#undef tTimer #undef tTimer
static void sub_80B3AAC(u8 taskId) static void Task_WaitExitToScript(u8 taskId)
{ {
if (!gReceivedRemoteLinkPlayers) if (!gReceivedRemoteLinkPlayers)
{ {
@ -1261,10 +1263,10 @@ static void sub_80B3AAC(u8 taskId)
} }
// Unused // Unused
static void sub_80B3AD0(u8 taskId) static void ExitLinkToScript(u8 taskId)
{ {
SetCloseLinkCallback(); SetCloseLinkCallback();
gTasks[taskId].func = sub_80B3AAC; gTasks[taskId].func = Task_WaitExitToScript;
} }
#define tTimer data[1] #define tTimer data[1]

View File

@ -22,7 +22,7 @@ static void Task_LinkContest_InitFlags(u8);
bool32 LinkContest_SendBlock(void *src, u16 size) bool32 LinkContest_SendBlock(void *src, u16 size)
{ {
memcpy(gDecompressionBuffer, src, size); memcpy(gDecompressionBuffer, src, size);
if (SendBlock(bitmask_all_link_players_but_self(), gDecompressionBuffer, size)) if (SendBlock(BitmaskAllOtherLinkPlayers(), gDecompressionBuffer, size))
return TRUE; return TRUE;
else else
return FALSE; return FALSE;
@ -162,7 +162,7 @@ void Task_LinkContest_CommunicateMonsRS(u8 taskId)
// Only if leader. Request other players data // Only if leader. Request other players data
if (++gTasks[taskId].tTimer > 300) if (++gTasks[taskId].tTimer > 300)
{ {
SendBlockRequest(2); SendBlockRequest(BLOCK_REQ_SIZE_100);
gTasks[taskId].tState = 1; gTasks[taskId].tState = 1;
} }
break; break;
@ -238,7 +238,7 @@ void Task_LinkContest_CommunicateCategoryRS(u8 taskId)
case 10: case 10:
if (++gTasks[taskId].tTimer > 10) if (++gTasks[taskId].tTimer > 10)
{ {
SendBlockRequest(2); SendBlockRequest(BLOCK_REQ_SIZE_100);
gTasks[taskId].tState = 1; gTasks[taskId].tState = 1;
} }
break; break;
@ -491,7 +491,7 @@ void Task_LinkContest_CommunicateLeaderIdsRS(u8 taskId)
case 10: case 10:
if (++gTasks[taskId].tTimer > 10) if (++gTasks[taskId].tTimer > 10)
{ {
SendBlockRequest(2); SendBlockRequest(BLOCK_REQ_SIZE_100);
gTasks[taskId].tState = 1; gTasks[taskId].tState = 1;
} }
break; break;

View File

@ -3779,7 +3779,7 @@ static void Task_LinkRetireStatusWithBattleTowerPartner(u8 taskId)
{ {
// Send value of gSpecialVar_0x8004 to leader // Send value of gSpecialVar_0x8004 to leader
// Will either be BATTLE_TOWER_LINK_CONTINUE or BATTLE_TOWER_LINK_RETIRE // Will either be BATTLE_TOWER_LINK_CONTINUE or BATTLE_TOWER_LINK_RETIRE
SendBlock(bitmask_all_link_players_but_self(), &gSpecialVar_0x8004, sizeof(gSpecialVar_0x8004)); SendBlock(BitmaskAllOtherLinkPlayers(), &gSpecialVar_0x8004, sizeof(gSpecialVar_0x8004));
gTasks[taskId].tState++; gTasks[taskId].tState++;
} }
} }
@ -3828,7 +3828,7 @@ static void Task_LinkRetireStatusWithBattleTowerPartner(u8 taskId)
else else
{ {
// Send whether or not play should continue // Send whether or not play should continue
SendBlock(bitmask_all_link_players_but_self(), &gSpecialVar_Result, sizeof(gSpecialVar_Result)); SendBlock(BitmaskAllOtherLinkPlayers(), &gSpecialVar_Result, sizeof(gSpecialVar_Result));
gTasks[taskId].tState++; gTasks[taskId].tState++;
} }
} }

View File

@ -166,11 +166,11 @@ static const u16 sLinkTestDigitsGfx[] = INCBIN_U16("graphics/interface/link_test
static const u8 sUnusedTransparentWhite[] = _("{HIGHLIGHT TRANSPARENT}{COLOR WHITE}"); static const u8 sUnusedTransparentWhite[] = _("{HIGHLIGHT TRANSPARENT}{COLOR WHITE}");
static const u16 sCommErrorBg_Gfx[] = INCBIN_U16("graphics/interface/comm_error_bg.4bpp"); static const u16 sCommErrorBg_Gfx[] = INCBIN_U16("graphics/interface/comm_error_bg.4bpp");
static const struct BlockRequest sBlockRequests[] = { static const struct BlockRequest sBlockRequests[] = {
{gBlockSendBuffer, 200}, [BLOCK_REQ_SIZE_NONE] = {gBlockSendBuffer, 200},
{gBlockSendBuffer, 200}, [BLOCK_REQ_SIZE_200] = {gBlockSendBuffer, 200},
{gBlockSendBuffer, 100}, [BLOCK_REQ_SIZE_100] = {gBlockSendBuffer, 100},
{gBlockSendBuffer, 220}, [BLOCK_REQ_SIZE_220] = {gBlockSendBuffer, 220},
{gBlockSendBuffer, 40} [BLOCK_REQ_SIZE_40] = {gBlockSendBuffer, 40}
}; };
static const u8 sBGControlRegs[] = { static const u8 sBGControlRegs[] = {
REG_OFFSET_BG0CNT, REG_OFFSET_BG0CNT,
@ -1025,7 +1025,7 @@ u8 GetMultiplayerId(void)
return SIO_MULTI_CNT->id; return SIO_MULTI_CNT->id;
} }
u8 bitmask_all_link_players_but_self(void) u8 BitmaskAllOtherLinkPlayers(void)
{ {
u8 mpId; u8 mpId;
@ -1727,12 +1727,12 @@ static void CB2_PrintErrorMessage(void)
bool8 GetSioMultiSI(void) bool8 GetSioMultiSI(void)
{ {
return (REG_SIOCNT & 0x04) != 0; return (REG_SIOCNT & SIO_MULTI_SI) != 0;
} }
static bool8 IsSioMultiMaster(void) static bool8 IsSioMultiMaster(void)
{ {
return (REG_SIOCNT & 0x8) && !(REG_SIOCNT & 0x04); return (REG_SIOCNT & SIO_MULTI_SD) && (REG_SIOCNT & SIO_MULTI_SI) == 0;
} }
bool8 IsLinkConnectionEstablished(void) bool8 IsLinkConnectionEstablished(void)

View File

@ -177,11 +177,11 @@ static const u8 sUnknown_082ED6A5[] = {
}; };
static const struct BlockRequest sBlockRequests[] = { static const struct BlockRequest sBlockRequests[] = {
{ gBlockSendBuffer, 200 }, [BLOCK_REQ_SIZE_NONE] = { gBlockSendBuffer, 200 },
{ gBlockSendBuffer, 200 }, [BLOCK_REQ_SIZE_200] = { gBlockSendBuffer, 200 },
{ gBlockSendBuffer, 100 }, [BLOCK_REQ_SIZE_100] = { gBlockSendBuffer, 100 },
{ gBlockSendBuffer, 220 }, [BLOCK_REQ_SIZE_220] = { gBlockSendBuffer, 220 },
{ gBlockSendBuffer, 40 } [BLOCK_REQ_SIZE_40] = { gBlockSendBuffer, 40 }
}; };
static const u16 sAcceptedSerialNos[] = { static const u16 sAcceptedSerialNos[] = {
@ -1753,7 +1753,7 @@ static void sub_801084C(u8 taskId)
{ {
if (AreNoPlayersReceiving()) if (AreNoPlayersReceiving())
{ {
Rfu.blockRequestType = 0; Rfu.blockRequestType = BLOCK_REQ_SIZE_NONE;
RfuPrepareSendBuffer(RFUCMD_SEND_BLOCK_REQ); RfuPrepareSendBuffer(RFUCMD_SEND_BLOCK_REQ);
gTasks[taskId].data[0]++; gTasks[taskId].data[0]++;
} }

View File

@ -499,7 +499,7 @@ static void Task_SendPacket(u8 taskId)
break; break;
case 1: case 1:
if (GetMultiplayerId() == 0) if (GetMultiplayerId() == 0)
SendBlockRequest(1); SendBlockRequest(BLOCK_REQ_SIZE_200);
task->data[0]++; task->data[0]++;
break; break;
case 2: case 2:

View File

@ -1008,9 +1008,7 @@ static bool8 BufferTradeParties(void)
break; break;
case 3: case 3:
if (id == 0) if (id == 0)
{ RequestLinkData(BLOCK_REQ_SIZE_200);
RequestLinkData(1);
}
sTradeMenuData->bufferPartyState++; sTradeMenuData->bufferPartyState++;
break; break;
case 4: case 4:
@ -1027,9 +1025,7 @@ static bool8 BufferTradeParties(void)
break; break;
case 7: case 7:
if (id == 0) if (id == 0)
{ RequestLinkData(BLOCK_REQ_SIZE_200);
RequestLinkData(1);
}
sTradeMenuData->bufferPartyState++; sTradeMenuData->bufferPartyState++;
break; break;
case 8: case 8:
@ -1046,9 +1042,7 @@ static bool8 BufferTradeParties(void)
break; break;
case 11: case 11:
if (id == 0) if (id == 0)
{ RequestLinkData(BLOCK_REQ_SIZE_200);
RequestLinkData(1);
}
sTradeMenuData->bufferPartyState++; sTradeMenuData->bufferPartyState++;
break; break;
case 12: case 12:
@ -1065,9 +1059,7 @@ static bool8 BufferTradeParties(void)
break; break;
case 15: case 15:
if (id == 0) if (id == 0)
{ RequestLinkData(BLOCK_REQ_SIZE_220);
RequestLinkData(3);
}
sTradeMenuData->bufferPartyState++; sTradeMenuData->bufferPartyState++;
break; break;
case 16: case 16:
@ -1084,9 +1076,7 @@ static bool8 BufferTradeParties(void)
break; break;
case 19: case 19:
if (id == 0) if (id == 0)
{ RequestLinkData(BLOCK_REQ_SIZE_40);
RequestLinkData(4);
}
sTradeMenuData->bufferPartyState++; sTradeMenuData->bufferPartyState++;
break; break;
case 20: case 20:
@ -3096,7 +3086,7 @@ static void TrySendTradeFinishData(void)
case 1: case 1:
if (IsLinkTaskFinished()) if (IsLinkTaskFinished())
{ {
SendBlock(bitmask_all_link_players_but_self(), sTradeData->linkData, sizeof(sTradeData->linkData)); SendBlock(BitmaskAllOtherLinkPlayers(), sTradeData->linkData, sizeof(sTradeData->linkData));
sTradeData->sendTradeFinishState++; sTradeData->sendTradeFinishState++;
} }
// fallthrough // fallthrough
@ -4632,7 +4622,7 @@ static void CB2_TryFinishTrade(void)
&& sTradeData->partnerLinkFlagFinishTrade == READY_FINISH_TRADE) && sTradeData->partnerLinkFlagFinishTrade == READY_FINISH_TRADE)
{ {
sTradeData->linkData[0] = LINKCMD_CONFIRM_FINISH_TRADE; sTradeData->linkData[0] = LINKCMD_CONFIRM_FINISH_TRADE;
SendBlock(bitmask_all_link_players_but_self(), sTradeData->linkData, sizeof(sTradeData->linkData)); SendBlock(BitmaskAllOtherLinkPlayers(), sTradeData->linkData, sizeof(sTradeData->linkData));
sTradeData->playerLinkFlagFinishTrade = FINISH_TRADE; sTradeData->playerLinkFlagFinishTrade = FINISH_TRADE;
sTradeData->partnerLinkFlagFinishTrade = FINISH_TRADE; sTradeData->partnerLinkFlagFinishTrade = FINISH_TRADE;
} }

View File

@ -1494,7 +1494,7 @@ static void Task_ExchangeCards(u8 taskId)
{ {
case 0: case 0:
if (GetMultiplayerId() == 0) if (GetMultiplayerId() == 0)
SendBlockRequest(2); SendBlockRequest(BLOCK_REQ_SIZE_100);
gTasks[taskId].data[0]++; gTasks[taskId].data[0]++;
break; break;
case 1: case 1: