Document cable_club.c

This commit is contained in:
GriffinR 2020-06-03 18:00:53 -04:00
parent 9190af73b7
commit 3f97763181
32 changed files with 591 additions and 535 deletions

View File

@ -786,19 +786,19 @@ BattleFrontier_BattleTowerLobby_EventScript_TryCableLink:: @ 823F2C5
setvar VAR_0x8005, 0
special TryBattleLinkup
waitstate
compare VAR_RESULT, 1
compare VAR_RESULT, LINKUP_SUCCESS
goto_if_eq BattleFrontier_BattleTowerLobby_EventScript_CableLinkSuccessful
compare VAR_RESULT, 2
compare VAR_RESULT, LINKUP_SOMEONE_NOT_READY
goto_if_eq CableClub_EventScript_AbortLinkSomeoneNotReady
compare VAR_RESULT, 3
compare VAR_RESULT, LINKUP_DIFF_SELECTIONS
goto_if_eq BattleFrontier_BattleTowerLobby_EventScript_AbortLinkDifferentSelections
compare VAR_RESULT, 4
compare VAR_RESULT, LINKUP_WRONG_NUM_PLAYERS
goto_if_eq BattleFrontier_BattleTowerLobby_EventScript_AbortLinkIncorrectNumberOfPlayers
compare VAR_RESULT, 5
compare VAR_RESULT, LINKUP_FAILED
goto_if_eq BattleFrontier_BattleTowerLobby_EventScript_CancelChallenge
compare VAR_RESULT, 6
compare VAR_RESULT, LINKUP_CONNECTION_ERROR
goto_if_eq CableClub_EventScript_AbortLinkConnectionError
compare VAR_RESULT, 11
compare VAR_RESULT, LINKUP_FAILED_BATTLE_TOWER
goto_if_eq BattleFrontier_BattleTowerLobby_EventScript_AbortLink
end
@ -853,7 +853,7 @@ BattleFrontier_BattleTowerLobby_EventScript_CableLinkSuccessful:: @ 823F3AF
message BattleFrontier_BattleTowerLobby_Text_SaveGameBeforeShowingIn
waitmessage
tower_save CHALLENGE_STATUS_SAVING
special sub_80A08CC
special SaveForBattleTowerLink
waitstate
playse SE_SAVE
waitse
@ -914,7 +914,7 @@ BattleFrontier_BattleTowerLobby_EventScript_WirelessLinkSuccessful:: @ 823F496
message BattleFrontier_BattleTowerLobby_Text_SaveGameBeforeShowingIn
waitmessage
tower_save CHALLENGE_STATUS_SAVING
special sub_80A08CC
special SaveForBattleTowerLink
waitstate
playse SE_SAVE
waitse

View File

@ -767,15 +767,15 @@ LilycoveCity_ContestLobby_EventScript_TrySetUpLinkContest:: @ 821AA15
call_if_eq LilycoveCity_ContestLobby_EventScript_TryLinkGMode
compare VAR_TEMP_C, 2
goto_if_ge LilycoveCity_ContestLobby_EventScript_CancelLinkContest
compare VAR_RESULT, 4
compare VAR_RESULT, LINKUP_WRONG_NUM_PLAYERS
goto_if_eq LilycoveCity_ContestLobby_EventScript_CancelLinkDifferentChoices
compare VAR_RESULT, 3
compare VAR_RESULT, LINKUP_DIFF_SELECTIONS
goto_if_eq LilycoveCity_ContestLobby_EventScript_CancelLinkDifferentChoices
compare VAR_RESULT, 5
compare VAR_RESULT, LINKUP_FAILED
goto_if_eq LilycoveCity_ContestLobby_EventScript_CancelLinkContest
compare VAR_RESULT, 6
compare VAR_RESULT, LINKUP_CONNECTION_ERROR
goto_if_eq LilycoveCity_ContestLobby_EventScript_CancelLinkError
compare VAR_RESULT, 10
compare VAR_RESULT, LINKUP_FAILED_CONTEST_GMODE
goto_if_eq LilycoveCity_ContestLobby_EventScript_CancelLinkModeDifference
message3 LilycoveCity_ContestLobby_Text_Transmitting
contestlinktransfer

View File

@ -600,15 +600,15 @@ BerryBlender_EventScript_TryDoLinkBlender: @ 82940BB
waitmessage
special TryBerryBlenderLinkup
waitstate
compare VAR_RESULT, 1
compare VAR_RESULT, LINKUP_SUCCESS
goto_if_eq BerryBlender_EventScript_SpawnLinkPartners
compare VAR_RESULT, 2
compare VAR_RESULT, LINKUP_SOMEONE_NOT_READY
goto_if_eq BerryBlender_EventScript_CloseLinkNotReady
compare VAR_RESULT, 3
compare VAR_RESULT, LINKUP_DIFF_SELECTIONS
goto_if_eq BerryBlender_EventScript_CloseLinkDifferentSelections
compare VAR_RESULT, 5
compare VAR_RESULT, LINKUP_FAILED
goto_if_eq BerryBlender_EventScript_CloseLink
compare VAR_RESULT, 6
compare VAR_RESULT, LINKUP_CONNECTION_ERROR
goto_if_eq BerryBlender_EventScript_LinkError
end

View File

@ -452,21 +452,21 @@ CableClub_EventScript_TradeCenter:: @ 82770B2
waitmessage
special TryTradeLinkup
waitstate
compare VAR_RESULT, 1
compare VAR_RESULT, LINKUP_SUCCESS
goto_if_eq CableClub_EventScript_EnterTradeCenter
compare VAR_RESULT, 2
compare VAR_RESULT, LINKUP_SOMEONE_NOT_READY
goto_if_eq CableClub_EventScript_AbortLinkSomeoneNotReady
compare VAR_RESULT, 3
compare VAR_RESULT, LINKUP_DIFF_SELECTIONS
goto_if_eq CableClub_EventScript_AbortLinkDifferentSelections
compare VAR_RESULT, 4
compare VAR_RESULT, LINKUP_WRONG_NUM_PLAYERS
goto_if_eq CableClub_EventScript_AbortLinkIncorrectNumberOfParticipants
compare VAR_RESULT, 5
compare VAR_RESULT, LINKUP_FAILED
goto_if_eq CableClub_EventScript_AbortLink
compare VAR_RESULT, 6
compare VAR_RESULT, LINKUP_CONNECTION_ERROR
goto_if_eq CableClub_EventScript_AbortLinkConnectionError
compare VAR_RESULT, 7
compare VAR_RESULT, LINKUP_PLAYER_NOT_READY
goto_if_eq CableClub_EventScript_AbortLinkPlayerNotReady
compare VAR_RESULT, 9
compare VAR_RESULT, LINKUP_PARTNER_NOT_READY
goto_if_eq CableClub_EventScript_AbortLinkOtherTrainerNotReady
end
@ -527,21 +527,21 @@ CableClub_EventScript_RecordCorner:: @ 82771DB
waitmessage
special TryRecordMixLinkup
waitstate
special sub_80B2EA8
special ValidateMixingGameLanguage
waitstate
compare VAR_RESULT, 12
compare VAR_RESULT, LINKUP_FOREIGN_GAME
goto_if_eq CableClub_EventScript_AbortLinkForeignGame
compare VAR_RESULT, 1
compare VAR_RESULT, LINKUP_SUCCESS
goto_if_eq CableClub_EventScript_EnterRecordCorner
compare VAR_RESULT, 2
compare VAR_RESULT, LINKUP_SOMEONE_NOT_READY
goto_if_eq CableClub_EventScript_AbortLinkSomeoneNotReady
compare VAR_RESULT, 3
compare VAR_RESULT, LINKUP_DIFF_SELECTIONS
goto_if_eq CableClub_EventScript_AbortLinkDifferentSelections
compare VAR_RESULT, 4
compare VAR_RESULT, LINKUP_WRONG_NUM_PLAYERS
goto_if_eq CableClub_EventScript_AbortLinkIncorrectNumberOfParticipants
compare VAR_RESULT, 5
compare VAR_RESULT, LINKUP_FAILED
goto_if_eq CableClub_EventScript_AbortLink
compare VAR_RESULT, 6
compare VAR_RESULT, LINKUP_CONNECTION_ERROR
goto_if_eq CableClub_EventScript_AbortLinkConnectionError
end

View File

@ -39,7 +39,7 @@ gSpecials:: @ 81DBA64
def_special TryBattleLinkup
def_special TryTradeLinkup
def_special TryRecordMixLinkup
def_special sub_80B2EA8
def_special ValidateMixingGameLanguage
def_special CloseLink
def_special ColosseumPlayerSpotTriggered
def_special PlayerEnteredTradeSeat
@ -502,7 +502,7 @@ gSpecials:: @ 81DBA64
def_special CreateAbnormalWeatherEvent
def_special GetAbnormalWeatherMapNameAndType
def_special GetMartEmployeeObjectEventId
def_special sub_80A08CC
def_special SaveForBattleTowerLink
def_special Unused_SetWeatherSunny
def_special SetUnlockedPokedexFlags
def_special IsTrainerRegistered

View File

@ -9,12 +9,12 @@
// Exported ROM declarations
void sub_80B37D4(TaskFunc taskFunc);
u8 sub_80B3050(void);
void CreateTask_EnterCableClubSeat(TaskFunc taskFunc);
u8 CreateTask_ReestablishCableClubLink(void);
void CB2_ReturnFromCableClubBattle(void);
bool32 sub_80B2AF4(u16 *arg0, u16 *arg1);
bool32 AreBattleTowerLinkSpeciesSame(u16 *speciesList1, u16 *speciesList2);
void sub_80B3AF8(u8 taskId);
void task00_08081A90(u8 taskId);
void Task_WaitForLinkPlayerConnection(u8 taskId);
bool32 GetLinkTrainerCardColor(u8 linkPlayerIndex);
#endif //GUARD_CABLE_CLUB_H

View File

@ -12,4 +12,22 @@
#define USING_MINIGAME 8
#define USING_BATTLE_TOWER 9
#define LINKUP_ONGOING 0
#define LINKUP_SUCCESS 1
#define LINKUP_SOMEONE_NOT_READY 2
#define LINKUP_DIFF_SELECTIONS 3
#define LINKUP_WRONG_NUM_PLAYERS 4
#define LINKUP_FAILED 5
#define LINKUP_CONNECTION_ERROR 6
#define LINKUP_PLAYER_NOT_READY 7
#define LINKUP_UNK8 8
#define LINKUP_PARTNER_NOT_READY 9
#define LINKUP_FAILED_CONTEST_GMODE 10
#define LINKUP_FAILED_BATTLE_TOWER 11
#define LINKUP_FOREIGN_GAME 12
#define LINK_BATTLE_TOWER_SAME_MON 1
#define LINK_BATTLE_TOWER_SAME_MONS 2
#define LINK_BATTLE_TOWER_DIFF_MODE 3
#endif //GUARD_CONSTANTS_CABLE_CLUB_H

View File

@ -16,7 +16,7 @@ bool8 ShowFieldAutoScrollMessage(const u8 *message);
void HideFieldMessageBox(void);
bool8 IsFieldMessageBoxHidden(void);
u8 GetFieldMessageBoxMode(void);
void sub_8098374(void);
void StopFieldMessage(void);
void InitFieldMessageBox(void);
#endif // GUARD_FIELD_MESSAGE_BOX_H

View File

@ -73,10 +73,10 @@
#define LINKCMD_CANCEL_TRADE 0xEEBB
#define LINKCMD_0xEECC 0xEECC
#define LINKTYPE_0x1111 0x1111 // trade
#define LINKTYPE_0x1122 0x1122 // trade
#define LINKTYPE_0x1133 0x1133 // trade
#define LINKTYPE_0x1144 0x1144 // trade
#define LINKTYPE_TRADE 0x1111
#define LINKTYPE_TRADE_CONNECTING 0x1122
#define LINKTYPE_TRADE_SETUP 0x1133
#define LINKTYPE_TRADE_DISCONNECTED 0x1144
#define LINKTYPE_BATTLE 0x2211
#define LINKTYPE_0x2222 0x2222 // unused battle?
#define LINKTYPE_SINGLE_BATTLE 0x2233
@ -85,13 +85,13 @@
#define LINKTYPE_BATTLE_TOWER_50 0x2266
#define LINKTYPE_BATTLE_TOWER_OPEN 0x2277
#define LINKTYPE_BATTLE_TOWER 0x2288
#define LINKTYPE_0x3311 0x3311
#define LINKTYPE_0x3322 0x3322
#define LINKTYPE_RECORD_MIX_BEFORE 0x3311
#define LINKTYPE_RECORD_MIX_AFTER 0x3322
#define LINKTYPE_BERRY_BLENDER_SETUP 0x4411
#define LINKTYPE_BERRY_BLENDER 0x4422
#define LINKTYPE_0x5501 0x5501 // mystery event
#define LINKTYPE_MYSTERY_EVENT 0x5501
#define LINKTYPE_0x5502 0x5502 // unused?
#define LINKTYPE_0x5503 0x5503 // eReader
#define LINKTYPE_EREADER 0x5503
#define LINKTYPE_CONTEST_GMODE 0x6601
#define LINKTYPE_CONTEST_EMODE 0x6602
@ -126,10 +126,10 @@ enum
EXCHANGE_NOT_STARTED,
EXCHANGE_COMPLETE,
EXCHANGE_TIMED_OUT,
EXCHANGE_IN_PROGRESS,
EXCHANGE_DIFF_SELECTIONS,
EXCHANGE_PLAYER_NOT_READY,
EXCHANGE_PARTNER_NOT_READY,
EXCHANGE_STAT_6,
EXCHANGE_WRONG_NUM_PLAYERS,
EXCHANGE_STAT_7
};

View File

@ -1,6 +1,6 @@
#ifndef GUARD_MEVENT2_H
#define GUARD_MEVENT2_H
void sub_801B990(u32, u32);
void RecordIdOfWonderCardSenderByEventType(u32, u32);
#endif //GUARD_MEVENT2_H

View File

@ -102,7 +102,7 @@ u8 Save_LoadGameData(u8 saveType);
u16 sub_815355C(void);
u32 TryReadSpecialSaveSection(u8 sector, u8* dst);
u32 TryWriteSpecialSaveSection(u8 sector, u8* src);
void sub_8153688(u8 taskId);
void Task_LinkSave(u8 taskId);
// save_failed_screen.c
void DoSaveFailedScreen(u8 saveType);

View File

@ -8,8 +8,8 @@ void Task_ShowStartMenu(u8 taskId);
void ShowStartMenu(void);
void ShowBattlePyramidStartMenu(void);
void SaveGame(void);
void sub_80A0514(void);
void sub_80A08CC(void);
void CB2_SetUpSaveAfterLinkBattle(void);
void SaveForBattleTowerLink(void);
void HideStartMenu(void);
void AppendToList(u8* list, u8* pos, u8 newEntry);

View File

@ -962,7 +962,7 @@ extern const u8 gText_TwoDashes[];
extern const u8 *const gReturnToXStringsTable2[];
extern const u8 gText_XPLink[];
extern const u8 gText_NumPlayerLink[];
extern const u8 gText_ConfirmLinkWhenPlayersReady[];
extern const u8 gText_ConfirmStartLinkWithXPlayers[];
extern const u8 gText_AwaitingLinkup[];

View File

@ -161,7 +161,7 @@ extern u8 gUnionRoomRequestedMonType;
// Exported ROM declarations
u8 CreateTask_ReturnFromLinkTrade(void);
u8 CreateTask_CreateTradeMenu(void);
void nullsub_89(u8 taskId);
void var_800D_set_xB(void);
void MEvent_CreateTask_CardOrNewsWithFriend(u32 arg0);

View File

@ -36,7 +36,7 @@ void HandleLinkBattleSetup(void)
SetWirelessCommType1();
if (!gReceivedRemoteLinkPlayers)
OpenLink();
CreateTask(task00_08081A90, 0);
CreateTask(Task_WaitForLinkPlayerConnection, 0);
CreateTasksForSendRecvLinkBuffers();
}
}

View File

@ -3013,10 +3013,10 @@ static u32 sub_8024134(struct BerryCrushGame *r5, u8 *r4)
DrawDialogueFrame(0, 0);
AddTextPrinterParameterized2(0, 1, gText_SavingDontTurnOffPower, 0, 0, 2, 1, 3);
CopyWindowToVram(0, 3);
CreateTask(sub_8153688, 0);
CreateTask(Task_LinkSave, 0);
break;
case 3:
if (FuncIsActiveTask(sub_8153688))
if (FuncIsActiveTask(Task_LinkSave))
return 0;
break;
case 4:

File diff suppressed because it is too large Load Diff

View File

@ -4483,12 +4483,12 @@ static void sub_802A380(void)
case 2:
if (!IsDma3ManagerBusyWithBgCopy())
{
CreateTask(sub_8153688, 0);
CreateTask(Task_LinkSave, 0);
gUnknown_02022CF8->state++;
}
break;
case 3:
if (!FuncIsActiveTask(sub_8153688))
if (!FuncIsActiveTask(Task_LinkSave))
gUnknown_02022CF8->state++;
break;
default:

View File

@ -85,10 +85,10 @@ static u8 sub_81D4DE8(struct Unk03006370 *arg0)
return var0;
}
static void sub_81D4E30(void)
static void OpenEReaderLink(void)
{
memset(gDecompressionBuffer, 0, 0x2000);
gLinkType = LINKTYPE_0x5503;
gLinkType = LINKTYPE_EREADER;
OpenLink();
SetSuppressLinkErrorMessage(TRUE);
}
@ -255,7 +255,7 @@ static void sub_81D5084(u8 taskId)
data->unk8 = 1;
break;
case 1:
sub_81D4E30();
OpenEReaderLink();
sub_81D505C(&data->unk0);
data->unk8 = 2;
break;
@ -285,7 +285,7 @@ static void sub_81D5084(u8 taskId)
case 5:
if (sub_81D5064(&data->unk0, 90))
{
sub_81D4E30();
OpenEReaderLink();
data->unk8 = 6;
}
else if (gMain.newKeys & B_BUTTON)
@ -319,7 +319,7 @@ static void sub_81D5084(u8 taskId)
else if (sub_81D5064(&data->unk0, 10))
{
CloseLink();
sub_81D4E30();
OpenEReaderLink();
sub_81D505C(&data->unk0);
}
break;
@ -360,7 +360,7 @@ static void sub_81D5084(u8 taskId)
data->unk8 = 12;
break;
case 12:
sub_81D4E30();
OpenEReaderLink();
AddTextPrinterToWindow1(gJPText_AllowEReaderToLoadCard);
data->unk8 = 13;
break;

View File

@ -148,7 +148,7 @@ void sub_8098358(void)
sFieldMessageBoxMode = 0;
}
void sub_8098374(void)
void StopFieldMessage(void)
{
task_del_textbox();
sFieldMessageBoxMode = 0;

View File

@ -162,7 +162,7 @@ static void Task_ReturnToFieldCableLink(u8 taskId)
switch (task->data[0])
{
case 0:
task->data[1] = sub_80B3050();
task->data[1] = CreateTask_ReestablishCableClubLink();
task->data[0]++;
break;
case 1:

View File

@ -282,7 +282,7 @@ void LinkTestScreen(void)
ResetTasks();
SetVBlankCallback(sub_80096BC);
ResetBlockSend();
gLinkType = LINKTYPE_0x1111;
gLinkType = LINKTYPE_TRADE;
OpenLink();
SeedRng(gMain.vblankCounter2);
for (i = 0; i < MAX_LINK_PLAYERS; i++)
@ -826,23 +826,23 @@ void OpenLinkTimed(void)
OpenLink();
}
u8 GetLinkPlayerDataExchangeStatusTimed(int lower, int upper)
u8 GetLinkPlayerDataExchangeStatusTimed(int minPlayers, int maxPlayers)
{
int i;
int count;
u32 index;
u8 cmpVal;
u8 numPlayers;
u32 linkType1;
u32 linkType2;
count = 0;
if (gReceivedRemoteLinkPlayers == TRUE)
{
cmpVal = GetLinkPlayerCount_2();
if (lower > cmpVal || cmpVal > upper)
numPlayers = GetLinkPlayerCount_2();
if (minPlayers > numPlayers || numPlayers > maxPlayers)
{
sPlayerDataExchangeStatus = EXCHANGE_STAT_6;
return 6;
sPlayerDataExchangeStatus = EXCHANGE_WRONG_NUM_PLAYERS;
return sPlayerDataExchangeStatus;
}
else
{
@ -860,19 +860,19 @@ u8 GetLinkPlayerDataExchangeStatusTimed(int lower, int upper)
}
if (count == GetLinkPlayerCount())
{
if (gLinkPlayers[0].linkType == 0x1133)
if (gLinkPlayers[0].linkType == LINKTYPE_TRADE_SETUP)
{
switch (GetGameProgressForLinkTrade())
{
case TRADE_PLAYER_NOT_READY:
sPlayerDataExchangeStatus = EXCHANGE_PLAYER_NOT_READY;
break;
case TRADE_PARTNER_NOT_READY:
sPlayerDataExchangeStatus = EXCHANGE_PARTNER_NOT_READY;
break;
case TRADE_BOTH_PLAYERS_READY:
sPlayerDataExchangeStatus = EXCHANGE_COMPLETE;
break;
case TRADE_PLAYER_NOT_READY:
sPlayerDataExchangeStatus = EXCHANGE_PLAYER_NOT_READY;
break;
case TRADE_PARTNER_NOT_READY:
sPlayerDataExchangeStatus = EXCHANGE_PARTNER_NOT_READY;
break;
case TRADE_BOTH_PLAYERS_READY:
sPlayerDataExchangeStatus = EXCHANGE_COMPLETE;
break;
}
}
else
@ -882,11 +882,14 @@ u8 GetLinkPlayerDataExchangeStatusTimed(int lower, int upper)
}
else
{
sPlayerDataExchangeStatus = EXCHANGE_IN_PROGRESS;
sPlayerDataExchangeStatus = EXCHANGE_DIFF_SELECTIONS;
linkType1 = gLinkPlayers[GetMultiplayerId()].linkType;
linkType2 = gLinkPlayers[GetMultiplayerId() ^ 1].linkType;
if ((linkType1 == 0x2266 && linkType2 == 0x2277) || (linkType1 == 0x2277 && linkType2 == 0x2266))
if ((linkType1 == LINKTYPE_BATTLE_TOWER_50 && linkType2 == LINKTYPE_BATTLE_TOWER_OPEN)
|| (linkType1 == LINKTYPE_BATTLE_TOWER_OPEN && linkType2 == LINKTYPE_BATTLE_TOWER_50))
{
// 3 below indicates partner made different level mode selection
// See BattleFrontier_BattleTowerLobby_EventScript_AbortLinkDifferentSelections
gSpecialVar_0x8005 = 3;
}
}
@ -921,7 +924,7 @@ bool8 IsLinkPlayerDataExchangeComplete(void)
else
{
retval = FALSE;
sPlayerDataExchangeStatus = EXCHANGE_IN_PROGRESS;
sPlayerDataExchangeStatus = EXCHANGE_DIFF_SELECTIONS;
}
return retval;
}

View File

@ -2408,7 +2408,7 @@ void sub_8011AFC(void)
SetVBlankCallback(sub_8011AE8);
if (IsWirelessAdapterConnected())
{
gLinkType = LINKTYPE_0x1111;
gLinkType = LINKTYPE_TRADE;
SetWirelessCommType1();
OpenLink();
SeedRng(gMain.vblankCounter2);

View File

@ -569,7 +569,7 @@ bool32 MEventHandleReceivedWonderCard(u16 a0)
return TRUE;
}
void sub_801B990(u32 a0, u32 a1)
void RecordIdOfWonderCardSenderByEventType(u32 a0, u32 a1)
{
if (gUnknown_02022C70)
{

View File

@ -152,7 +152,7 @@ static void CB2_MysteryEventMenu(void)
if (!IsTextPrinterActive(0))
{
gMain.state++;
gLinkType = LINKTYPE_0x5501;
gLinkType = LINKTYPE_MYSTERY_EVENT;
OpenLink();
}
break;
@ -206,7 +206,7 @@ static void CB2_MysteryEventMenu(void)
{
if (gReceivedRemoteLinkPlayers != 0)
{
if (GetLinkPlayerDataExchangeStatusTimed(2, 2) == 3)
if (GetLinkPlayerDataExchangeStatusTimed(2, 2) == EXCHANGE_DIFF_SELECTIONS)
{
sub_800AC34();
GetEventLoadMessage(gStringVar4, 1);

View File

@ -1148,12 +1148,12 @@ static bool32 sub_802B720(void)
case 2:
if (sub_802C70C())
{
CreateTask(sub_8153688, 6);
CreateTask(Task_LinkSave, 6);
gUnknown_02022CFC->unk8++;
}
break;
case 3:
if (!FuncIsActiveTask(sub_8153688))
if (!FuncIsActiveTask(Task_LinkSave))
{
sub_802DA14();
gUnknown_02022CFC->unk8++;

View File

@ -169,10 +169,9 @@ static const u8 gUnknown_0858CFBE[3][4] =
#define BUFFER_CHUNK_SIZE 200
// Note: VAR_0x8005 contains the spotId.
void RecordMixingPlayerSpotTriggered(void)
{
sub_80B37D4(Task_RecordMixing_Main);
CreateTask_EnterCableClubSeat(Task_RecordMixing_Main);
}
// these variables were const in R/S, but had to become changeable because of saveblocks changing RAM position
@ -351,7 +350,7 @@ static void Task_RecordMixing_Main(u8 taskId)
{
tState = 4;
if (gWirelessCommType == 0)
data[10] = sub_80B3050();
data[10] = CreateTask_ReestablishCableClubLink();
PrintTextOnRecordMixing(gText_RecordMixingComplete);
data[8] = 0;
@ -987,12 +986,12 @@ static void Task_DoRecordMixing(u8 taskId)
case 6:
if (!sub_801048C(FALSE))
{
CreateTask(sub_8153688, 5);
CreateTask(Task_LinkSave, 5);
task->data[0] ++;
}
break;
case 7: // wait for sub_8153688 to finish.
if (!FuncIsActiveTask(sub_8153688))
case 7: // wait for Task_LinkSave to finish.
if (!FuncIsActiveTask(Task_LinkSave))
{
if (gWirelessCommType)
{

View File

@ -897,74 +897,78 @@ u32 TryWriteSpecialSaveSection(u8 sector, u8* src)
return SAVE_STATUS_OK;
}
void sub_8153688(u8 taskId)
{
s16* taskData = gTasks[taskId].data;
#define tState data[0]
#define tTimer data[1]
#define tPartialSave data[2]
switch (taskData[0])
void Task_LinkSave(u8 taskId)
{
s16* data = gTasks[taskId].data;
switch (tState)
{
case 0:
gSoftResetDisabled = TRUE;
taskData[0] = 1;
tState = 1;
break;
case 1:
sub_800ADF8();
taskData[0] = 2;
tState = 2;
break;
case 2:
if (IsLinkTaskFinished())
{
if (taskData[2] == 0)
if (!tPartialSave)
save_serialize_map();
taskData[0] = 3;
tState = 3;
}
break;
case 3:
if (taskData[2] == 0)
if (!tPartialSave)
SetContinueGameWarpStatusToDynamicWarp();
sub_8153380();
taskData[0] = 4;
tState = 4;
break;
case 4:
if (++taskData[1] == 5)
if (++tTimer == 5)
{
taskData[1] = 0;
taskData[0] = 5;
tTimer = 0;
tState = 5;
}
break;
case 5:
if (sub_81533AC())
taskData[0] = 6;
tState = 6;
else
taskData[0] = 4;
tState = 4;
break;
case 6:
sub_81533E0();
taskData[0] = 7;
tState = 7;
break;
case 7:
if (taskData[2] == 0)
if (!tPartialSave)
ClearContinueGameWarpStatus2();
sub_800ADF8();
taskData[0] = 8;
tState = 8;
break;
case 8:
if (IsLinkTaskFinished())
{
sub_8153408();
taskData[0] = 9;
tState = 9;
}
break;
case 9:
sub_800ADF8();
taskData[0] = 10;
tState = 10;
break;
case 10:
if (IsLinkTaskFinished())
taskData[0]++;
tState++;
break;
case 11:
if (++taskData[1] > 5)
if (++tTimer > 5)
{
gSoftResetDisabled = FALSE;
DestroyTask(taskId);
@ -972,3 +976,7 @@ void sub_8153688(u8 taskId)
break;
}
}
#undef tState
#undef tTimer
#undef tPartialSave

View File

@ -133,8 +133,8 @@ static u8 BattlePyramidRetireInputCallback(void);
// Task callbacks
static void StartMenuTask(u8 taskId);
static void SaveGameTask(u8 taskId);
static void sub_80A0550(u8 taskId);
static void sub_80A08A4(u8 taskId);
static void Task_SaveAfterLinkBattle(u8 taskId);
static void Task_WaitForBattleTowerLinkSave(u8 taskId);
static bool8 FieldCB_ReturnToFieldStartMenu(void);
static const struct WindowTemplate sSafariBallsWindowTemplate = {0, 1, 1, 9, 4, 0xF, 8};
@ -219,8 +219,8 @@ static bool8 SaveSuccesTimer(void);
static bool8 SaveErrorTimer(void);
static void InitBattlePyramidRetire(void);
static void sub_80A03D8(void);
static bool32 sub_80A03E4(u8 *par1);
static void sub_80A0540(void);
static bool32 InitSaveWindowAfterLinkBattle(u8 *par1);
static void CB2_SaveAfterLinkBattle(void);
static void ShowSaveInfoWindow(void);
static void RemoveSaveInfoWindow(void);
static void HideStartMenuWindow(void);
@ -1159,9 +1159,9 @@ static void sub_80A03D8(void)
TransferPlttBuffer();
}
static bool32 sub_80A03E4(u8 *par1)
static bool32 InitSaveWindowAfterLinkBattle(u8 *state)
{
switch (*par1)
switch (*state)
{
case 0:
SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_MODE_0);
@ -1193,43 +1193,43 @@ static bool32 sub_80A03E4(u8 *par1)
return TRUE;
}
(*par1)++;
(*state)++;
return FALSE;
}
void sub_80A0514(void)
void CB2_SetUpSaveAfterLinkBattle(void)
{
if (sub_80A03E4(&gMain.state))
if (InitSaveWindowAfterLinkBattle(&gMain.state))
{
CreateTask(sub_80A0550, 0x50);
SetMainCallback2(sub_80A0540);
CreateTask(Task_SaveAfterLinkBattle, 0x50);
SetMainCallback2(CB2_SaveAfterLinkBattle);
}
}
static void sub_80A0540(void)
static void CB2_SaveAfterLinkBattle(void)
{
RunTasks();
UpdatePaletteFade();
}
static void sub_80A0550(u8 taskId)
static void Task_SaveAfterLinkBattle(u8 taskId)
{
s16 *step = gTasks[taskId].data;
s16 *state = gTasks[taskId].data;
if (!gPaletteFade.active)
{
switch (*step)
switch (*state)
{
case 0:
FillWindowPixelBuffer(0, PIXEL_FILL(1));
AddTextPrinterParameterized2(0,
1,
gText_SavingDontTurnOffPower,
255,
TEXT_SPEED_FF,
NULL,
2,
1,
3);
TEXT_COLOR_DARK_GREY,
TEXT_COLOR_WHITE,
TEXT_COLOR_LIGHT_GREY);
DrawTextBorderOuter(0, 8, 14);
PutWindowTilemap(0);
CopyWindowToVram(0, 3);
@ -1239,35 +1239,35 @@ static void sub_80A0550(u8 taskId)
{
if (sub_800A07C())
{
*step = 1;
*state = 1;
}
else
{
*step = 5;
*state = 5;
}
}
else
{
gSoftResetDisabled = 1;
*step = 1;
*state = 1;
}
break;
case 1:
SetContinueGameWarpStatusToDynamicWarp();
FullSaveGame();
*step = 2;
*state = 2;
break;
case 2:
if (CheckSaveFile())
{
ClearContinueGameWarpStatus2();
*step = 3;
*state = 3;
gSoftResetDisabled = 0;
}
break;
case 3:
BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK);
*step = 4;
*state = 4;
break;
case 4:
FreeAllWindowBuffers();
@ -1275,13 +1275,13 @@ static void sub_80A0550(u8 taskId)
DestroyTask(taskId);
break;
case 5:
CreateTask(sub_8153688, 0x5);
*step = 6;
CreateTask(Task_LinkSave, 5);
*state = 6;
break;
case 6:
if (!FuncIsActiveTask(sub_8153688))
if (!FuncIsActiveTask(Task_LinkSave))
{
*step = 3;
*state = 3;
}
break;
}
@ -1357,22 +1357,26 @@ static void RemoveSaveInfoWindow(void)
RemoveWindow(sSaveInfoWindowId);
}
static void sub_80A08A4(u8 taskId)
static void Task_WaitForBattleTowerLinkSave(u8 taskId)
{
if (!FuncIsActiveTask(sub_8153688))
if (!FuncIsActiveTask(Task_LinkSave))
{
DestroyTask(taskId);
EnableBothScriptContexts();
}
}
void sub_80A08CC(void)
#define tPartialSave data[2]
void SaveForBattleTowerLink(void)
{
u8 taskId = CreateTask(sub_8153688, 0x5);
gTasks[taskId].data[2] = 1;
gTasks[CreateTask(sub_80A08A4, 0x6)].data[1] = taskId;
u8 taskId = CreateTask(Task_LinkSave, 5);
gTasks[taskId].tPartialSave = TRUE;
gTasks[CreateTask(Task_WaitForBattleTowerLinkSave, 6)].data[1] = taskId;
}
#undef tPartialSave
static void HideStartMenuWindow(void)
{
ClearStdWindowAndFrame(GetStartMenuWindowId(), TRUE);

View File

@ -1492,7 +1492,7 @@ const u8 gText_FrameTypeNumber[] = _("{COLOR GREEN}{SHADOW LIGHT_GREEN}");
const u8 gText_ButtonTypeNormal[] = _("{COLOR GREEN}{SHADOW LIGHT_GREEN}NORMAL");
const u8 gText_ButtonTypeLR[] = _("{COLOR GREEN}{SHADOW LIGHT_GREEN}LR");
const u8 gText_ButtonTypeLEqualsA[] = _("{COLOR GREEN}{SHADOW LIGHT_GREEN}L=A");
const u8 gText_XPLink[] = _("{STR_VAR_1}P LINK");
const u8 gText_NumPlayerLink[] = _("{STR_VAR_1}P LINK");
const u8 gText_BronzeCard[] = _("BRONZE");
const u8 gText_CopperCard[] = _("COPPER");
const u8 gText_SilverCard[] = _("SILVER");

View File

@ -389,7 +389,7 @@ static void CB2_CreateTradeMenu(void)
if (!gReceivedRemoteLinkPlayers)
{
gLinkType = LINKTYPE_0x1122;
gLinkType = LINKTYPE_TRADE_CONNECTING;
sTradeMenuData->timer = 0;
if (gWirelessCommType)
@ -402,7 +402,7 @@ static void CB2_CreateTradeMenu(void)
{
OpenLink();
gMain.state++;
CreateTask(task00_08081A90, 1);
CreateTask(Task_WaitForLinkPlayerConnection, 1);
}
}
else
@ -2750,7 +2750,7 @@ void CB2_LinkTrade(void)
case 0:
if (!gReceivedRemoteLinkPlayers)
{
gLinkType = LINKTYPE_0x1144;
gLinkType = LINKTYPE_TRADE_DISCONNECTED;
CloseLink();
}
sTradeData = AllocZeroed(sizeof(*sTradeData));
@ -4597,7 +4597,7 @@ static void CB2_SaveAndEndTrade(void)
IncrementGameStat(GAME_STAT_POKEMON_TRADES);
if (gWirelessCommType)
{
sub_801B990(2, gLinkPlayers[GetMultiplayerId() ^ 1].trainerId);
RecordIdOfWonderCardSenderByEventType(2, gLinkPlayers[GetMultiplayerId() ^ 1].trainerId);
}
SetContinueGameWarpStatusToDynamicWarp();
sub_8153380();

View File

@ -1298,15 +1298,15 @@ static u8 GetNewLeaderCandidate(void)
return ret;
}
static void Task_ReturnFromLinkTrade(u8 taskId)
static void Task_CreateTradeMenu(u8 taskId)
{
CB2_StartCreateTradeMenu();
DestroyTask(taskId);
}
u8 CreateTask_ReturnFromLinkTrade(void)
u8 CreateTask_CreateTradeMenu(void)
{
u8 taskId = CreateTask(Task_ReturnFromLinkTrade, 0);
u8 taskId = CreateTask(Task_CreateTradeMenu, 0);
return taskId;
}
@ -1589,7 +1589,7 @@ static void Task_RunScriptAndFadeToActivity(u8 taskId)
switch (data[0])
{
case 0:
gSpecialVar_Result = 1;
gSpecialVar_Result = LINKUP_SUCCESS;
switch (gPlayerCurrActivity)
{
case ACTIVITY_BATTLE_TOWER:
@ -1655,9 +1655,9 @@ static void Task_RunScriptAndFadeToActivity(u8 taskId)
if (GetBlockReceivedStatus() == 3)
{
ResetBlockReceivedFlags();
if (sub_80B2AF4(gBlockRecvBuffer[0], gBlockRecvBuffer[1]))
if (AreBattleTowerLinkSpeciesSame(gBlockRecvBuffer[0], gBlockRecvBuffer[1]))
{
gSpecialVar_Result = 11;
gSpecialVar_Result = LINKUP_FAILED_BATTLE_TOWER;
data[0] = 7;
}
else