Merge pull request #551 from Phlosioneer/multiplayer-stuff
Document overworld.c and link stuff in general
This commit is contained in:
@@ -767,7 +767,7 @@ static void Task_HandleSendLinkBuffersData(u8 taskId)
|
||||
{
|
||||
if (IsLinkMaster())
|
||||
{
|
||||
sub_800A620();
|
||||
CheckShouldAdvanceLinkState();
|
||||
gTasks[taskId].data[11]++;
|
||||
}
|
||||
else
|
||||
|
||||
@@ -34,6 +34,8 @@
|
||||
#include "battle_records.h"
|
||||
#include "graphics.h"
|
||||
#include "new_game.h"
|
||||
#include "save.h"
|
||||
#include "link.h"
|
||||
|
||||
#define BLENDER_SCORE_BEST 0
|
||||
#define BLENDER_SCORE_GOOD 1
|
||||
@@ -140,15 +142,8 @@ extern const u8 gText_Space[];
|
||||
extern const u8 gText_BlenderMaxSpeedRecord[];
|
||||
extern const u8 gText_234Players[];
|
||||
|
||||
extern void sub_800A418(void);
|
||||
extern u8 sub_800A9D8(void);
|
||||
extern void sub_81AABF0(void (*callback)(void));
|
||||
extern void sub_800B4C0(void);
|
||||
extern void ClearLinkCallback(void);
|
||||
extern void sub_8009F8C(void);
|
||||
extern void sub_8153430(void);
|
||||
extern bool8 sub_8153474(void);
|
||||
extern void sub_80EECEC(void);
|
||||
|
||||
// this file's functions
|
||||
static void BerryBlender_SetBackgroundsPos(void);
|
||||
@@ -2600,7 +2595,7 @@ static bool8 LinkPlayAgainHandleSaving(void)
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
sub_8153430();
|
||||
FullSaveGame();
|
||||
sBerryBlenderData->field_1A0++;
|
||||
sBerryBlenderData->framesToWait = 0;
|
||||
break;
|
||||
@@ -2614,7 +2609,7 @@ static bool8 LinkPlayAgainHandleSaving(void)
|
||||
case 4:
|
||||
if (IsLinkTaskFinished())
|
||||
{
|
||||
if (sub_8153474())
|
||||
if (CheckSaveFile())
|
||||
{
|
||||
sBerryBlenderData->field_1A0 = 5;
|
||||
}
|
||||
|
||||
@@ -282,7 +282,7 @@ static void sub_80B2804(u8 taskId)
|
||||
|
||||
if (GetFieldMessageBoxMode() == FIELD_MESSAGE_BOX_HIDDEN)
|
||||
{
|
||||
if (sub_800AA48() != GetLinkPlayerCount_2())
|
||||
if (GetSavedPlayerCount() != GetLinkPlayerCount_2())
|
||||
{
|
||||
ShowFieldAutoScrollMessage(gText_ConfirmLinkWhenPlayersReady);
|
||||
gTasks[taskId].func = sub_80B270C;
|
||||
@@ -295,7 +295,7 @@ static void sub_80B2804(u8 taskId)
|
||||
else if (gMain.heldKeys & A_BUTTON)
|
||||
{
|
||||
PlaySE(SE_SELECT);
|
||||
sub_800A620();
|
||||
CheckShouldAdvanceLinkState();
|
||||
gTasks[taskId].func = sub_80B28A8;
|
||||
}
|
||||
}
|
||||
@@ -310,7 +310,7 @@ static void sub_80B28A8(u8 taskId)
|
||||
|| sub_80B2D6C(taskId) == TRUE)
|
||||
return;
|
||||
|
||||
if (GetLinkPlayerCount_2() != sub_800AA48())
|
||||
if (GetLinkPlayerCount_2() != GetSavedPlayerCount())
|
||||
{
|
||||
gTasks[taskId].func = sub_80B2D2C;
|
||||
}
|
||||
@@ -352,7 +352,7 @@ static void sub_80B2918(u8 taskId)
|
||||
else
|
||||
{
|
||||
gFieldLinkPlayerCount = GetLinkPlayerCount_2();
|
||||
gUnknown_03005DB4 = GetMultiplayerId();
|
||||
gLocalLinkPlayerId = GetMultiplayerId();
|
||||
sub_800AA04(gFieldLinkPlayerCount);
|
||||
card = (struct TrainerCard *)gBlockSendBuffer;
|
||||
TrainerCard_GenerateCardForPlayer(card);
|
||||
@@ -399,7 +399,7 @@ static void sub_80B2A08(u8 taskId)
|
||||
else
|
||||
{
|
||||
gFieldLinkPlayerCount = GetLinkPlayerCount_2();
|
||||
gUnknown_03005DB4 = GetMultiplayerId();
|
||||
gLocalLinkPlayerId = GetMultiplayerId();
|
||||
sub_800AA04(gFieldLinkPlayerCount);
|
||||
card = (struct TrainerCard *)gBlockSendBuffer;
|
||||
TrainerCard_GenerateCardForPlayer(card);
|
||||
@@ -764,9 +764,9 @@ static void sub_80B3194(u8 taskId)
|
||||
|
||||
static void sub_80B31E8(u8 taskId)
|
||||
{
|
||||
if (sub_800AA48() == GetLinkPlayerCount_2())
|
||||
if (GetSavedPlayerCount() == GetLinkPlayerCount_2())
|
||||
{
|
||||
sub_800A620();
|
||||
CheckShouldAdvanceLinkState();
|
||||
gTasks[taskId].func = sub_80B3220;
|
||||
}
|
||||
}
|
||||
@@ -972,7 +972,7 @@ void sub_80B360C(void)
|
||||
|
||||
if (gSpecialVar_0x8004 == 1 || gSpecialVar_0x8004 == 2)
|
||||
{
|
||||
UpdatePlayerLinkBattleRecords(gUnknown_03005DB4 ^ 1);
|
||||
UpdatePlayerLinkBattleRecords(gLocalLinkPlayerId ^ 1);
|
||||
if (gWirelessCommType)
|
||||
{
|
||||
switch (gBattleOutcome)
|
||||
@@ -993,13 +993,13 @@ void sub_80B360C(void)
|
||||
}
|
||||
else
|
||||
{
|
||||
gMain.savedCallback = c2_8056854;
|
||||
gMain.savedCallback = CB2_ReturnToFieldFromMultiplayer;
|
||||
}
|
||||
|
||||
SetMainCallback2(sub_80A0514);
|
||||
}
|
||||
|
||||
void sub_80B36EC(void)
|
||||
void CleanupLinkRoomState(void)
|
||||
{
|
||||
if (gSpecialVar_0x8004 == 1 || gSpecialVar_0x8004 == 2 || gSpecialVar_0x8004 == 5 || gSpecialVar_0x8004 == 9)
|
||||
{
|
||||
@@ -1009,9 +1009,9 @@ void sub_80B36EC(void)
|
||||
SetWarpDestinationToDynamicWarp(0x7F);
|
||||
}
|
||||
|
||||
void sub_80B371C(void)
|
||||
void ExitLinkRoom(void)
|
||||
{
|
||||
sub_80872B0();
|
||||
QueueExitLinkRoomKey();
|
||||
}
|
||||
|
||||
static void sub_80B3728(u8 taskId)
|
||||
@@ -1028,7 +1028,7 @@ static void sub_80B3728(u8 taskId)
|
||||
if (IsFieldMessageBoxHidden())
|
||||
{
|
||||
sub_8087288();
|
||||
sub_8009628(gSpecialVar_0x8005);
|
||||
SetLocalLinkPlayerId(gSpecialVar_0x8005);
|
||||
task->data[0] = 2;
|
||||
}
|
||||
break;
|
||||
@@ -1130,7 +1130,8 @@ static void sub_80B3894(u8 taskId)
|
||||
}
|
||||
}
|
||||
|
||||
void sub_80B3924(void)
|
||||
// Note: VAR_0x8005 is set to the ID of the trade seat.
|
||||
void PlayerEnteredTradeSeat(void)
|
||||
{
|
||||
if (gWirelessCommType != 0)
|
||||
{
|
||||
@@ -1152,7 +1153,8 @@ void nullsub_37(void)
|
||||
|
||||
}
|
||||
|
||||
void sub_80B3968(void)
|
||||
// Note: VAR_0x8005 is set to the ID of the player spot.
|
||||
void ColosseumPlayerSpotTriggered(void)
|
||||
{
|
||||
gLinkType = 0x2211;
|
||||
|
||||
@@ -1166,6 +1168,7 @@ void sub_80B3968(void)
|
||||
}
|
||||
}
|
||||
|
||||
// This function is never called.
|
||||
static void sub_80B39A4(void)
|
||||
{
|
||||
u8 taskId = CreateTask(sub_80B3728, 80);
|
||||
@@ -1177,14 +1180,16 @@ void sp02A_crash_sound(void)
|
||||
ShowTrainerCardInLink(gSpecialVar_0x8006, CB2_ReturnToFieldContinueScriptPlayMapMusic);
|
||||
}
|
||||
|
||||
bool32 sub_80B39D4(u8 linkPlayerIndex)
|
||||
// Returns FALSE if the player has no stars. Returns TRUE otherwise, and puts the name of the
|
||||
// color into gStringVar2.
|
||||
bool32 GetLinkTrainerCardColor(u8 linkPlayerIndex)
|
||||
{
|
||||
u32 trainerCardColorIndex;
|
||||
|
||||
gSpecialVar_0x8006 = linkPlayerIndex;
|
||||
StringCopy(gStringVar1, gLinkPlayers[linkPlayerIndex].name);
|
||||
|
||||
trainerCardColorIndex = sub_80C4904(linkPlayerIndex);
|
||||
trainerCardColorIndex = GetTrainerCardStars(linkPlayerIndex);
|
||||
if (trainerCardColorIndex == 0)
|
||||
return FALSE;
|
||||
|
||||
@@ -1263,13 +1268,13 @@ void sub_80B3AF8(u8 taskId)
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
if (GetLinkPlayerCount_2() >= sub_800AA48())
|
||||
if (GetLinkPlayerCount_2() >= GetSavedPlayerCount())
|
||||
{
|
||||
if (IsLinkMaster())
|
||||
{
|
||||
if (++data[1] > 30)
|
||||
{
|
||||
sub_800A620();
|
||||
CheckShouldAdvanceLinkState();
|
||||
data[0]++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1114,7 +1114,7 @@ static void sub_811A2A4(u8 taskId, TaskFunc taskFunc)
|
||||
|
||||
static void sub_811A2C0(u8 taskId)
|
||||
{
|
||||
if (!is_c1_link_related_active())
|
||||
if (!IsUpdateLinkStateCBActive())
|
||||
{
|
||||
while (sub_811A428(taskId));
|
||||
}
|
||||
|
||||
@@ -255,7 +255,7 @@ void sub_80AF2B4(u8 taskId)
|
||||
break;
|
||||
case 2:
|
||||
sub_8009F18();
|
||||
sub_8086C2C();
|
||||
ResetAllMultiplayerState();
|
||||
ScriptContext2_Disable();
|
||||
DestroyTask(taskId);
|
||||
break;
|
||||
@@ -621,7 +621,7 @@ void sub_80AF948(void)
|
||||
CreateTask(sub_80AF8E0, 10);
|
||||
}
|
||||
|
||||
static void sub_80AF96C(u8 taskId)
|
||||
static void Task_ReturnToWorldFromLinkRoom(u8 taskId)
|
||||
{
|
||||
s16 *data = gTasks[taskId].data;
|
||||
|
||||
@@ -654,7 +654,7 @@ static void sub_80AF96C(u8 taskId)
|
||||
|
||||
void sub_80AF9F8(void)
|
||||
{
|
||||
CreateTask(sub_80AF96C, 10);
|
||||
CreateTask(Task_ReturnToWorldFromLinkRoom, 10);
|
||||
}
|
||||
|
||||
static void sub_80AFA0C(u8 taskId)
|
||||
|
||||
28
src/link.c
28
src/link.c
@@ -28,7 +28,7 @@
|
||||
#include "link.h"
|
||||
#include "link_rfu.h"
|
||||
|
||||
extern u16 gUnknown_03005DA8;
|
||||
extern u16 gHeldKeyCodeToSend;
|
||||
|
||||
// Static type declarations
|
||||
|
||||
@@ -302,9 +302,9 @@ void LinkTestScreen(void)
|
||||
SetMainCallback2(CB2_LinkTest);
|
||||
}
|
||||
|
||||
void sub_8009628(u8 a0)
|
||||
void SetLocalLinkPlayerId(u8 playerId)
|
||||
{
|
||||
gLocalLinkPlayer.id = a0;
|
||||
gLocalLinkPlayer.id = playerId;
|
||||
}
|
||||
|
||||
static void InitLocalLinkPlayer(void)
|
||||
@@ -695,12 +695,12 @@ static void BuildSendCmd(u16 command)
|
||||
gSendCmd[0] = LINKCMD_0x5566;
|
||||
break;
|
||||
case LINKCMD_SEND_HELD_KEYS_2:
|
||||
if (gUnknown_03005DA8 == 0 || gLinkTransferringData)
|
||||
if (gHeldKeyCodeToSend == 0 || gLinkTransferringData)
|
||||
{
|
||||
break;
|
||||
}
|
||||
gSendCmd[0] = LINKCMD_SEND_HELD_KEYS_2;
|
||||
gSendCmd[1] = gUnknown_03005DA8;
|
||||
gSendCmd[1] = gHeldKeyCodeToSend;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -714,11 +714,11 @@ void sub_8009F18(void)
|
||||
gLinkCallback = sub_8009F70;
|
||||
}
|
||||
|
||||
bool32 sub_8009F3C(void)
|
||||
bool32 IsSendingKeysToLink(void)
|
||||
{
|
||||
if (gWirelessCommType)
|
||||
{
|
||||
return sub_800F7E4();
|
||||
return IsSendingKeysToRfu();
|
||||
}
|
||||
if (gLinkCallback == sub_8009F70)
|
||||
{
|
||||
@@ -1142,7 +1142,7 @@ void ResetBlockReceivedFlag(u8 who)
|
||||
}
|
||||
}
|
||||
|
||||
void sub_800A620(void)
|
||||
void CheckShouldAdvanceLinkState(void)
|
||||
{
|
||||
if ((gLinkStatus & LINK_STAT_MASTER) && EXTRACT_PLAYER_COUNT(gLinkStatus) > 1)
|
||||
{
|
||||
@@ -1327,7 +1327,9 @@ void sub_800AA04(u8 a0)
|
||||
}
|
||||
}
|
||||
|
||||
u8 sub_800AA48(void)
|
||||
// The number of players when trading began. This is frequently compared against the
|
||||
// current number of connected players to check if anyone dropped out.
|
||||
u8 GetSavedPlayerCount(void)
|
||||
{
|
||||
return gSavedLinkPlayerCount;
|
||||
}
|
||||
@@ -1849,7 +1851,7 @@ bool8 HandleLinkConnection(void)
|
||||
r5 = sub_8010F1C();
|
||||
if (sub_808766C() == TRUE)
|
||||
{
|
||||
if (r4 == TRUE || sub_800F0B8() || r5)
|
||||
if (r4 == TRUE || IsRfuRecvQueueEmpty() || r5)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
@@ -1882,18 +1884,18 @@ void sub_800B4C0(void)
|
||||
}
|
||||
}
|
||||
|
||||
u32 sub_800B4DC(void)
|
||||
u32 GetLinkRecvQueueLength(void)
|
||||
{
|
||||
if (gWirelessCommType != 0)
|
||||
{
|
||||
return sub_80124D4();
|
||||
return GetRfuRecvQueueLength();
|
||||
}
|
||||
return gLink.recvQueue.count;
|
||||
}
|
||||
|
||||
bool8 sub_800B504(void)
|
||||
{
|
||||
if (sub_800B4DC() > 2)
|
||||
if (GetLinkRecvQueueLength() > 2)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
#include "constants/species.h"
|
||||
#include "save.h"
|
||||
|
||||
extern u16 gUnknown_03005DA8;
|
||||
extern u16 gHeldKeyCodeToSend;
|
||||
extern void nullsub_89(u8 taskId);
|
||||
|
||||
struct UnkRfuStruct_1 gUnknown_03004140;
|
||||
@@ -2991,7 +2991,7 @@ static void sub_800F048(void)
|
||||
}
|
||||
}
|
||||
|
||||
bool32 sub_800F0B8(void)
|
||||
bool32 IsRfuRecvQueueEmpty(void)
|
||||
{
|
||||
s32 i;
|
||||
s32 j;
|
||||
@@ -3212,7 +3212,7 @@ bool32 sub_800F4F0(void)
|
||||
for (i = 0; i < CMD_LENGTH - 1; i++)
|
||||
gSendCmd[i] = 0;
|
||||
}
|
||||
return sub_800F0B8();
|
||||
return IsRfuRecvQueueEmpty();
|
||||
}
|
||||
|
||||
void sub_800F638(u8 unused, u32 flags)
|
||||
@@ -3272,10 +3272,12 @@ u8 sub_800F74C(const u8 *a0)
|
||||
|
||||
void rfu_func_080F97B8(void)
|
||||
{
|
||||
if (gReceivedRemoteLinkPlayers && gUnknown_03005DA8 && gLinkTransferringData != 1)
|
||||
if (gReceivedRemoteLinkPlayers
|
||||
&& gHeldKeyCodeToSend != LINK_KEY_CODE_NULL
|
||||
&& gLinkTransferringData != TRUE)
|
||||
{
|
||||
gUnknown_03000D78[0]++;
|
||||
gUnknown_03005DA8 |= (gUnknown_03000D78[0] << 8);
|
||||
gHeldKeyCodeToSend |= (gUnknown_03000D78[0] << 8);
|
||||
sub_800FD14(0xbe00);
|
||||
}
|
||||
}
|
||||
@@ -3285,7 +3287,7 @@ struct UnkLinkRfuStruct_02022B14 *sub_800F7DC(void)
|
||||
return &gUnknown_02022B14;
|
||||
}
|
||||
|
||||
bool32 sub_800F7E4(void)
|
||||
bool32 IsSendingKeysToRfu(void)
|
||||
{
|
||||
return gUnknown_03005000.unk_00 == rfu_func_080F97B8;
|
||||
}
|
||||
@@ -3509,7 +3511,7 @@ void sub_800FD14(u16 command)
|
||||
gSendCmd[1 + i] = gUnknown_03005000.unk_f2[i];
|
||||
break;
|
||||
case 0xbe00:
|
||||
gSendCmd[1] = gUnknown_03005DA8;
|
||||
gSendCmd[1] = gHeldKeyCodeToSend;
|
||||
break;
|
||||
case 0xee00:
|
||||
break;
|
||||
@@ -3799,10 +3801,10 @@ bool32 sub_8010454(u32 a0)
|
||||
|
||||
u8 sub_801048C(bool32 a0)
|
||||
{
|
||||
if (a0 == 0)
|
||||
if (a0 == FALSE)
|
||||
return sub_800D550(0, 0);
|
||||
sub_800D550(1, 0x258);
|
||||
return FALSE;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void sub_80104B0(void)
|
||||
@@ -5163,7 +5165,7 @@ u32 sub_80124C0(void)
|
||||
return gUnknown_03005000.unk_9e8.unk_232;
|
||||
}
|
||||
|
||||
u32 sub_80124D4(void)
|
||||
u32 GetRfuRecvQueueLength(void)
|
||||
{
|
||||
return gUnknown_03005000.unk_124.unk_8c2;
|
||||
}
|
||||
|
||||
@@ -293,7 +293,7 @@ bool8 sub_8122148(u16 itemId)
|
||||
|
||||
bool8 itemid_80BF6D8_mail_related(u16 itemId)
|
||||
{
|
||||
if (is_c1_link_related_active() != TRUE && InUnionRoom() != TRUE)
|
||||
if (IsUpdateLinkStateCBActive() != TRUE && InUnionRoom() != TRUE)
|
||||
return TRUE;
|
||||
else if (ItemIsMail(itemId) != TRUE)
|
||||
return TRUE;
|
||||
@@ -303,7 +303,7 @@ bool8 itemid_80BF6D8_mail_related(u16 itemId)
|
||||
|
||||
bool8 sub_81221AC(void)
|
||||
{
|
||||
if (is_c1_link_related_active() == TRUE || gReceivedRemoteLinkPlayers == 1)
|
||||
if (IsUpdateLinkStateCBActive() == TRUE || gReceivedRemoteLinkPlayers == 1)
|
||||
return TRUE;
|
||||
else
|
||||
return FALSE;
|
||||
|
||||
@@ -179,7 +179,7 @@ static void CB2_MysteryEventMenu(void)
|
||||
if (gMain.newKeys & A_BUTTON)
|
||||
{
|
||||
PlaySE(SE_SELECT);
|
||||
sub_800A620();
|
||||
CheckShouldAdvanceLinkState();
|
||||
SetWindowBorderStyle(1, 1, 1, 0xD);
|
||||
PrintMysteryMenuText(1, gText_LoadingEvent, 1, 2, 0);
|
||||
PutWindowTilemap(1);
|
||||
|
||||
931
src/overworld.c
931
src/overworld.c
File diff suppressed because it is too large
Load Diff
@@ -6522,7 +6522,7 @@ static void sub_81B8474(u8 taskId)
|
||||
gTasks[taskId].func = sub_81B8104;
|
||||
}
|
||||
|
||||
void sub_81B8518(u8 unused)
|
||||
void InitChooseHalfPartyForBattle(u8 unused)
|
||||
{
|
||||
sub_81B8558();
|
||||
InitPartyMenu(4, 0, 0, 0, 0, sub_81B1370, gMain.savedCallback);
|
||||
|
||||
@@ -388,7 +388,7 @@ u32 sub_81C7078(u32 (*func)(s32), u32 priority)
|
||||
{
|
||||
u16 taskId;
|
||||
|
||||
if (!is_c1_link_related_active())
|
||||
if (!IsUpdateLinkStateCBActive())
|
||||
taskId = CreateTask(sub_81C7170, priority);
|
||||
else
|
||||
taskId = CreateTask(sub_81C71E4, priority);
|
||||
|
||||
@@ -106,7 +106,7 @@ static EWRAM_DATA union PlayerRecords *sSentRecord = NULL;
|
||||
// Static ROM declarations
|
||||
|
||||
static void Task_RecordMixing_Main(u8 taskId);
|
||||
static void sub_80E7324(u8 taskId);
|
||||
static void Task_MixingRecordsRecv(u8 taskId);
|
||||
static void Task_SendPacket(u8 taskId);
|
||||
static void Task_CopyReceiveBuffer(u8 taskId);
|
||||
static void Task_SendPacket_SwitchToReceive(u8 taskId);
|
||||
@@ -120,7 +120,7 @@ static void ReceiveLilycoveLadyData(LilycoveLady *, size_t, u8);
|
||||
static void sub_80E7B2C(const u8 *);
|
||||
static void ReceiveDaycareMailData(struct RecordMixingDayCareMail *, size_t, u8, TVShow *);
|
||||
static void ReceiveGiftItem(u16 *item, u8 which);
|
||||
static void sub_80E7FF8(u8 taskId);
|
||||
static void Task_DoRecordMixing(u8 taskId);
|
||||
static void sub_80E8110(struct Apprentice *arg0, struct Apprentice *arg1);
|
||||
static void ReceiveApprenticeData(struct Apprentice *arg0, size_t arg1, u32 arg2);
|
||||
static void ReceiveRankingHallRecords(struct PlayerHallRecords *hallRecords, size_t arg1, u32 arg2);
|
||||
@@ -170,7 +170,8 @@ static const u8 gUnknown_0858CFBE[3][4] =
|
||||
|
||||
#define BUFFER_CHUNK_SIZE 200
|
||||
|
||||
void sub_80E6BE8(void)
|
||||
// Note: VAR_0x8005 contains the spotId.
|
||||
void RecordMixingPlayerSpotTriggered(void)
|
||||
{
|
||||
sub_80B37D4(Task_RecordMixing_Main);
|
||||
}
|
||||
@@ -313,6 +314,7 @@ static void Task_RecordMixing_SoundEffect(u8 taskId)
|
||||
#define tState data[0]
|
||||
#define tSndEffTaskId data[15]
|
||||
|
||||
// Note: Currently, special var 8005 contains the player's spot id.
|
||||
static void Task_RecordMixing_Main(u8 taskId)
|
||||
{
|
||||
s16 *data = gTasks[taskId].data;
|
||||
@@ -322,16 +324,16 @@ static void Task_RecordMixing_Main(u8 taskId)
|
||||
case 0: // init
|
||||
sSentRecord = malloc(sizeof(union PlayerRecords));
|
||||
sReceivedRecords = malloc(sizeof(union PlayerRecords) * 4);
|
||||
sub_8009628(gSpecialVar_0x8005);
|
||||
SetLocalLinkPlayerId(gSpecialVar_0x8005);
|
||||
VarSet(VAR_TEMP_0, 1);
|
||||
gUnknown_03001130 = FALSE;
|
||||
PrepareExchangePacket();
|
||||
CreateRecordMixingSprite();
|
||||
tState = 1;
|
||||
data[10] = CreateTask(sub_80E7324, 80);
|
||||
data[10] = CreateTask(Task_MixingRecordsRecv, 80);
|
||||
tSndEffTaskId = CreateTask(Task_RecordMixing_SoundEffect, 81);
|
||||
break;
|
||||
case 1: // wait for sub_80E7324
|
||||
case 1: // wait for Task_MixingRecordsRecv
|
||||
if (!gTasks[data[10]].isActive)
|
||||
{
|
||||
tState = 2;
|
||||
@@ -341,11 +343,11 @@ static void Task_RecordMixing_Main(u8 taskId)
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
data[10] = CreateTask(sub_80E7FF8, 10);
|
||||
data[10] = CreateTask(Task_DoRecordMixing, 10);
|
||||
tState = 3;
|
||||
PlaySE(SE_W226);
|
||||
break;
|
||||
case 3: // wait for sub_80E7FF8
|
||||
case 3: // wait for Task_DoRecordMixing
|
||||
if (!gTasks[data[10]].isActive)
|
||||
{
|
||||
tState = 4;
|
||||
@@ -381,7 +383,7 @@ static void Task_RecordMixing_Main(u8 taskId)
|
||||
#undef tState
|
||||
#undef tSndEffTaskId
|
||||
|
||||
static void sub_80E7324(u8 taskId)
|
||||
static void Task_MixingRecordsRecv(u8 taskId)
|
||||
{
|
||||
struct Task *task = &gTasks[taskId];
|
||||
|
||||
@@ -405,7 +407,7 @@ static void sub_80E7324(u8 taskId)
|
||||
u8 players = GetLinkPlayerCount_2();
|
||||
if (IsLinkMaster() == TRUE)
|
||||
{
|
||||
if (players == sub_800AA48())
|
||||
if (players == GetSavedPlayerCount())
|
||||
{
|
||||
PlaySE(SE_PIN);
|
||||
task->data[0] = 201;
|
||||
@@ -420,14 +422,15 @@ static void sub_80E7324(u8 taskId)
|
||||
}
|
||||
break;
|
||||
case 201:
|
||||
if (sub_800AA48() == GetLinkPlayerCount_2() && ++task->data[12] > (GetLinkPlayerCount_2() * 30))
|
||||
// We're the link master. Delay for 30 frames per connected player.
|
||||
if (GetSavedPlayerCount() == GetLinkPlayerCount_2() && ++task->data[12] > (GetLinkPlayerCount_2() * 30))
|
||||
{
|
||||
sub_800A620();
|
||||
CheckShouldAdvanceLinkState();
|
||||
task->data[0] = 1;
|
||||
}
|
||||
break;
|
||||
case 301:
|
||||
if (sub_800AA48() == GetLinkPlayerCount_2())
|
||||
if (GetSavedPlayerCount() == GetLinkPlayerCount_2())
|
||||
task->data[0] = 1;
|
||||
break;
|
||||
case 400: // wait 20 frames
|
||||
@@ -470,6 +473,7 @@ static void sub_80E7324(u8 taskId)
|
||||
StorePtrInTaskData(sReceivedRecords, (u16 *)&gTasks[subTaskId].data[5]);
|
||||
sRecordStructSize = sizeof(struct PlayerRecordsEmerald);
|
||||
}
|
||||
// Note: This task is destroyed by Task_CopyReceiveBuffer when it's done.
|
||||
}
|
||||
break;
|
||||
case 5: // wait 60 frames
|
||||
@@ -938,7 +942,7 @@ static void ReceiveGiftItem(u16 *item, u8 which)
|
||||
}
|
||||
}
|
||||
|
||||
static void sub_80E7FF8(u8 taskId)
|
||||
static void Task_DoRecordMixing(u8 taskId)
|
||||
{
|
||||
struct Task *task = &gTasks[taskId];
|
||||
|
||||
@@ -953,20 +957,22 @@ static void sub_80E7FF8(u8 taskId)
|
||||
else
|
||||
task->data[0] = 6;
|
||||
break;
|
||||
|
||||
// Mixing Ruby/Sapphire records.
|
||||
case 2:
|
||||
SetContinueGameWarpStatusToDynamicWarp();
|
||||
sub_8153430();
|
||||
FullSaveGame();
|
||||
task->data[0] ++;
|
||||
break;
|
||||
case 3:
|
||||
if (sub_8153474())
|
||||
if (CheckSaveFile())
|
||||
{
|
||||
ClearContinueGameWarpStatus2();
|
||||
task->data[0] = 4;
|
||||
task->data[1] = 0;
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
case 4: // Wait 10 frames
|
||||
if (++task->data[1] > 10)
|
||||
{
|
||||
sub_800AC34();
|
||||
@@ -974,22 +980,24 @@ static void sub_80E7FF8(u8 taskId)
|
||||
}
|
||||
break;
|
||||
case 5:
|
||||
if (gReceivedRemoteLinkPlayers == 0)
|
||||
if (gReceivedRemoteLinkPlayers == FALSE)
|
||||
DestroyTask(taskId);
|
||||
break;
|
||||
|
||||
// Mixing Emerald records.
|
||||
case 6:
|
||||
if (!sub_801048C(0))
|
||||
if (!sub_801048C(FALSE))
|
||||
{
|
||||
CreateTask(sub_8153688, 5);
|
||||
task->data[0] ++;
|
||||
}
|
||||
break;
|
||||
case 7:
|
||||
case 7: // wait for sub_8153688 to finish.
|
||||
if (!FuncIsActiveTask(sub_8153688))
|
||||
{
|
||||
if (gWirelessCommType)
|
||||
{
|
||||
sub_801048C(1);
|
||||
sub_801048C(TRUE);
|
||||
task->data[0] = 8;
|
||||
}
|
||||
else
|
||||
|
||||
@@ -188,7 +188,7 @@ extern u8 gUnknown_02022C3E;
|
||||
extern u16 gUnknown_02022C3C;
|
||||
extern u8 gUnknown_02022C20[];
|
||||
extern u8 gFieldLinkPlayerCount;
|
||||
extern u8 gUnknown_03005DB4;
|
||||
extern u8 gLocalLinkPlayerId;
|
||||
|
||||
// IWRAM vars
|
||||
IWRAM_DATA struct UnkStruct_Leader *gUnknown_03000DA0;
|
||||
@@ -1641,7 +1641,7 @@ void sub_8014304(s8 mapGroup, s8 mapNum, s32 x, s32 y, u16 arg4)
|
||||
gSpecialVar_0x8004 = arg4;
|
||||
VarSet(VAR_CABLE_CLUB_STATE, arg4);
|
||||
gFieldLinkPlayerCount = GetLinkPlayerCount();
|
||||
gUnknown_03005DB4 = GetMultiplayerId();
|
||||
gLocalLinkPlayerId = GetMultiplayerId();
|
||||
SetCableClubWarp();
|
||||
SetWarpDestination(mapGroup, mapNum, -1, x, y);
|
||||
WarpIntoMap();
|
||||
@@ -1697,7 +1697,7 @@ void sub_801440C(u8 taskId)
|
||||
case 81:
|
||||
CleanupOverworldWindowsAndTilemaps();
|
||||
gMain.savedCallback = sub_801AC54;
|
||||
sub_81B8518(3);
|
||||
InitChooseHalfPartyForBattle(3);
|
||||
break;
|
||||
case 1:
|
||||
CleanupOverworldWindowsAndTilemaps();
|
||||
|
||||
@@ -768,7 +768,7 @@ u8 sub_8153408(void) // trade.s save
|
||||
return 0;
|
||||
}
|
||||
|
||||
u8 sub_8153430(void)
|
||||
u8 FullSaveGame(void)
|
||||
{
|
||||
if (gFlashMemoryPresent != TRUE)
|
||||
return 1;
|
||||
@@ -780,7 +780,7 @@ u8 sub_8153430(void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool8 sub_8153474(void)
|
||||
bool8 CheckSaveFile(void)
|
||||
{
|
||||
u8 retVal = FALSE;
|
||||
u16 val = ++gUnknown_03006208;
|
||||
|
||||
@@ -1203,7 +1203,7 @@ bool8 ScrCmd_turnvobject(struct ScriptContext *ctx)
|
||||
|
||||
bool8 ScrCmd_lockall(struct ScriptContext *ctx)
|
||||
{
|
||||
if (is_c1_link_related_active())
|
||||
if (IsUpdateLinkStateCBActive())
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
@@ -1217,7 +1217,7 @@ bool8 ScrCmd_lockall(struct ScriptContext *ctx)
|
||||
|
||||
bool8 ScrCmd_lock(struct ScriptContext *ctx)
|
||||
{
|
||||
if (is_c1_link_related_active())
|
||||
if (IsUpdateLinkStateCBActive())
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
@@ -2182,7 +2182,7 @@ bool8 ScrCmd_cmdD8(struct ScriptContext *ctx)
|
||||
|
||||
bool8 ScrCmd_cmdD9(struct ScriptContext *ctx)
|
||||
{
|
||||
if (is_c1_link_related_active())
|
||||
if (IsUpdateLinkStateCBActive())
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include "constants/items.h"
|
||||
#include "constants/species.h"
|
||||
#include "constants/vars.h"
|
||||
#include "constants/battle_frontier.h"
|
||||
|
||||
extern const u16 gEventObjectPalette8[];
|
||||
extern const u16 gEventObjectPalette17[];
|
||||
@@ -40,7 +41,7 @@ static const u8 gUnknown_0858D8EC[] = { 3, 4, 5, 14 };
|
||||
|
||||
static void sub_80F8EE8(u8 taskId);
|
||||
static void sub_80F9088(u8 taskId);
|
||||
static void sub_80F9460(void);
|
||||
static void CB2_ReturnFromChooseHalfParty(void);
|
||||
static void sub_80F94B8(void);
|
||||
|
||||
void SetContestTrainerGfxIds(void)
|
||||
@@ -640,22 +641,24 @@ void ScriptSetMonMoveSlot(u8 monIndex, u16 move, u8 slot)
|
||||
SetMonMoveSlot(&gPlayerParty[monIndex], move, slot);
|
||||
}
|
||||
|
||||
void sub_80F9438(void)
|
||||
// Note: When control returns to the event script, gSpecialVar_Result will be
|
||||
// TRUE if the party selection was successful.
|
||||
void ChooseHalfPartyForBattle(void)
|
||||
{
|
||||
gMain.savedCallback = sub_80F9460;
|
||||
VarSet(VAR_FRONTIER_FACILITY, 9); // this isn't a valid frontier facility id (??)
|
||||
sub_81B8518(0);
|
||||
gMain.savedCallback = CB2_ReturnFromChooseHalfParty;
|
||||
VarSet(VAR_FRONTIER_FACILITY, FRONTIER_FACILITY_DOUBLE_COLOSSEUM);
|
||||
InitChooseHalfPartyForBattle(0);
|
||||
}
|
||||
|
||||
static void sub_80F9460(void)
|
||||
static void CB2_ReturnFromChooseHalfParty(void)
|
||||
{
|
||||
switch (gSelectedOrderFromParty[0])
|
||||
{
|
||||
case 0:
|
||||
gSpecialVar_Result = 0;
|
||||
gSpecialVar_Result = FALSE;
|
||||
break;
|
||||
default:
|
||||
gSpecialVar_Result = 1;
|
||||
gSpecialVar_Result = TRUE;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -665,7 +668,7 @@ static void sub_80F9460(void)
|
||||
void sub_80F9490(void)
|
||||
{
|
||||
gMain.savedCallback = sub_80F94B8;
|
||||
sub_81B8518(gSpecialVar_0x8004 + 1);
|
||||
InitChooseHalfPartyForBattle(gSpecialVar_0x8004 + 1);
|
||||
}
|
||||
|
||||
static void sub_80F94B8(void)
|
||||
|
||||
@@ -84,7 +84,7 @@ EWRAM_DATA static bool8 sSavingComplete = FALSE;
|
||||
EWRAM_DATA static u8 sSaveInfoWindowId = 0;
|
||||
|
||||
// Extern variables.
|
||||
extern u8 gUnknown_03005DB4;
|
||||
extern u8 gLocalLinkPlayerId;
|
||||
|
||||
// Extern functions in not decompiled files.
|
||||
extern void sub_80AF688(void);
|
||||
@@ -244,7 +244,7 @@ static void BuildStartMenuActions(void)
|
||||
{
|
||||
sNumStartMenuActions = 0;
|
||||
|
||||
if (is_c1_link_related_active() == TRUE)
|
||||
if (IsUpdateLinkStateCBActive() == TRUE)
|
||||
{
|
||||
BuildLinkModeStartMenu();
|
||||
}
|
||||
@@ -547,7 +547,7 @@ void sub_809FA34(u8 taskId) // Referenced in field_screen.s and rom_8011DC0.s
|
||||
|
||||
void ShowStartMenu(void) // Called from overworld.c and field_control_avatar.s
|
||||
{
|
||||
if (!is_c1_link_related_active())
|
||||
if (!IsUpdateLinkStateCBActive())
|
||||
{
|
||||
FreezeEventObjects();
|
||||
sub_808B864();
|
||||
@@ -672,7 +672,7 @@ static bool8 StartMenuPlayerNameCallback(void)
|
||||
RemoveExtraStartMenuWindows();
|
||||
CleanupOverworldWindowsAndTilemaps();
|
||||
|
||||
if (is_c1_link_related_active() || InUnionRoom())
|
||||
if (IsUpdateLinkStateCBActive() || InUnionRoom())
|
||||
ShowPlayerTrainerCard(CB2_ReturnToFieldWithOpenMenu); // Display trainer card
|
||||
else if (FlagGet(FLAG_SYS_FRONTIER_PASS))
|
||||
ShowFrontierPass(CB2_ReturnToFieldWithOpenMenu); // Display frontier pass
|
||||
@@ -734,7 +734,7 @@ static bool8 StartMenuLinkModePlayerNameCallback(void)
|
||||
{
|
||||
PlayRainStoppingSoundEffect();
|
||||
CleanupOverworldWindowsAndTilemaps();
|
||||
ShowTrainerCardInLink(gUnknown_03005DB4, CB2_ReturnToFieldWithOpenMenu);
|
||||
ShowTrainerCardInLink(gLocalLinkPlayerId, CB2_ReturnToFieldWithOpenMenu);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@@ -1265,11 +1265,11 @@ static void sub_80A0550(u8 taskId)
|
||||
break;
|
||||
case 1:
|
||||
SetContinueGameWarpStatusToDynamicWarp();
|
||||
sub_8153430();
|
||||
FullSaveGame();
|
||||
*step = 2;
|
||||
break;
|
||||
case 2:
|
||||
if (sub_8153474())
|
||||
if (CheckSaveFile())
|
||||
{
|
||||
ClearContinueGameWarpStatus2();
|
||||
*step = 3;
|
||||
|
||||
12
src/trade.c
12
src/trade.c
@@ -1507,13 +1507,13 @@ static void sub_80773D0(void)
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
if (GetLinkPlayerCount_2() >= sub_800AA48())
|
||||
if (GetLinkPlayerCount_2() >= GetSavedPlayerCount())
|
||||
{
|
||||
if (IsLinkMaster())
|
||||
{
|
||||
if (++gUnknown_0203229C->unk_A8 > 30)
|
||||
{
|
||||
sub_800A620();
|
||||
CheckShouldAdvanceLinkState();
|
||||
gMain.state++;
|
||||
}
|
||||
}
|
||||
@@ -2762,7 +2762,7 @@ static void sub_80794CC(void)
|
||||
Free(gUnknown_0203229C);
|
||||
FreeAllWindowBuffers();
|
||||
sub_800E084();
|
||||
SetMainCallback2(c2_8056854);
|
||||
SetMainCallback2(CB2_ReturnToFieldFromMultiplayer);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -2772,7 +2772,7 @@ static void sub_80794CC(void)
|
||||
Free(gUnknown_02032184);
|
||||
Free(gUnknown_0203229C);
|
||||
FreeAllWindowBuffers();
|
||||
SetMainCallback2(c2_8056854);
|
||||
SetMainCallback2(CB2_ReturnToFieldFromMultiplayer);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4099,11 +4099,11 @@ void sub_807AE50(void)
|
||||
case 3:
|
||||
if (IsLinkMaster())
|
||||
{
|
||||
if (GetLinkPlayerCount_2() >= sub_800AA48())
|
||||
if (GetLinkPlayerCount_2() >= GetSavedPlayerCount())
|
||||
{
|
||||
if (++gUnknown_020322A0->timer > 30)
|
||||
{
|
||||
sub_800A620();
|
||||
CheckShouldAdvanceLinkState();
|
||||
gMain.state++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1536,7 +1536,7 @@ static void sub_80C48C8(void)
|
||||
}
|
||||
}
|
||||
|
||||
u8 sub_80C4904(u8 cardId)
|
||||
u8 GetTrainerCardStars(u8 cardId)
|
||||
{
|
||||
struct TrainerCard* trainerCards = gTrainerCards;
|
||||
return trainerCards[cardId].stars;
|
||||
|
||||
Reference in New Issue
Block a user