Document remaining overworld

This commit is contained in:
GriffinR 2021-04-06 16:55:33 -04:00
parent 86a9d94ce1
commit 4a1cfbead2
10 changed files with 203 additions and 196 deletions

View File

@ -889,7 +889,7 @@ RecordCorner_EventScript_AlreadyMixed:: @ 82774E0
closemessage closemessage
end end
EventScript_ConfirmLeaveTradeRoom:: @ 82774EF EventScript_ConfirmLeaveCableClubRoom:: @ 82774EF
msgbox Text_TerminateLinkConfirmation, MSGBOX_YESNO msgbox Text_TerminateLinkConfirmation, MSGBOX_YESNO
compare VAR_RESULT, YES compare VAR_RESULT, YES
goto_if_eq EventScript_TerminateLink goto_if_eq EventScript_TerminateLink

View File

@ -2,6 +2,7 @@
#define GUARD_CABLE_CLUB_H #define GUARD_CABLE_CLUB_H
#include "task.h" #include "task.h"
#include "constants/cable_club.h"
void CreateTask_EnterCableClubSeat(TaskFunc taskFunc); void CreateTask_EnterCableClubSeat(TaskFunc taskFunc);
u8 CreateTask_ReestablishCableClubLink(void); u8 CreateTask_ReestablishCableClubLink(void);

View File

@ -28,4 +28,8 @@
#define LINKUP_FAILED_BATTLE_TOWER 11 #define LINKUP_FAILED_BATTLE_TOWER 11
#define LINKUP_FOREIGN_GAME 12 #define LINKUP_FOREIGN_GAME 12
#define CABLE_SEAT_WAITING 0
#define CABLE_SEAT_SUCCESS 1
#define CABLE_SEAT_FAILED 2
#endif //GUARD_CONSTANTS_CABLE_CLUB_H #endif //GUARD_CONSTANTS_CABLE_CLUB_H

View File

@ -607,7 +607,7 @@ extern const u8 EventScript_BattleColosseum_2P_PlayerSpot0[];
extern const u8 EventScript_BattleColosseum_2P_PlayerSpot1[]; extern const u8 EventScript_BattleColosseum_2P_PlayerSpot1[];
extern const u8 EventScript_TradeCenter_Chair1[]; extern const u8 EventScript_TradeCenter_Chair1[];
extern const u8 EventScript_TradeCenter_Chair0[]; extern const u8 EventScript_TradeCenter_Chair0[];
extern const u8 EventScript_ConfirmLeaveTradeRoom[]; extern const u8 EventScript_ConfirmLeaveCableClubRoom[];
extern const u8 EventScript_TerminateLink[]; extern const u8 EventScript_TerminateLink[];
#endif // GUARD_EVENT_SCRIPTS_H #endif // GUARD_EVENT_SCRIPTS_H

View File

@ -1055,14 +1055,4 @@ struct MapPosition
s8 height; s8 height;
}; };
struct TradeRoomPlayer
{
u8 playerId;
u8 isLocalPlayer;
u8 c;
u8 facing;
struct MapPosition pos;
u16 field_C;
};
#endif // GUARD_GLOBAL_H #endif // GUARD_GLOBAL_H

View File

@ -7,17 +7,17 @@
#define LINK_KEY_CODE_DPAD_UP 0x13 #define LINK_KEY_CODE_DPAD_UP 0x13
#define LINK_KEY_CODE_DPAD_LEFT 0x14 #define LINK_KEY_CODE_DPAD_LEFT 0x14
#define LINK_KEY_CODE_DPAD_RIGHT 0x15 #define LINK_KEY_CODE_DPAD_RIGHT 0x15
#define LINK_KEY_CODE_UNK_2 0x16 #define LINK_KEY_CODE_READY 0x16
#define LINK_KEY_CODE_EXIT_ROOM 0x17 #define LINK_KEY_CODE_EXIT_ROOM 0x17
#define LINK_KEY_CODE_START_BUTTON 0x18 #define LINK_KEY_CODE_START_BUTTON 0x18
#define LINK_KEY_CODE_A_BUTTON 0x19 #define LINK_KEY_CODE_A_BUTTON 0x19
#define LINK_KEY_CODE_UNK_4 0x1A // I'd guess this is the B button? #define LINK_KEY_CODE_IDLE 0x1A
// These two are a hack to stop user input until link stuff can be // These two are a hack to stop user input until link stuff can be
// resolved. // resolved.
#define LINK_KEY_CODE_HANDLE_RECV_QUEUE 0x1B #define LINK_KEY_CODE_HANDLE_RECV_QUEUE 0x1B
#define LINK_KEY_CODE_HANDLE_SEND_QUEUE 0x1C #define LINK_KEY_CODE_HANDLE_SEND_QUEUE 0x1C
#define LINK_KEY_CODE_UNK_7 0x1D #define LINK_KEY_CODE_EXIT_SEAT 0x1D
#define LINK_KEY_CODE_UNK_8 0x1E #define LINK_KEY_CODE_UNK_8 0x1E
#define MOVEMENT_MODE_FREE 0 #define MOVEMENT_MODE_FREE 0
@ -143,15 +143,14 @@ void CB2_ReturnToFieldFromMultiplayer(void);
void CB2_ReturnToFieldWithOpenMenu(void); void CB2_ReturnToFieldWithOpenMenu(void);
void CB2_ReturnToFieldContinueScript(void); void CB2_ReturnToFieldContinueScript(void);
void CB2_ReturnToFieldContinueScriptPlayMapMusic(void); void CB2_ReturnToFieldContinueScriptPlayMapMusic(void);
void sub_80861E8(void); void CB2_ReturnToFieldFadeFromBlack(void);
void CB2_ContinueSavedGame(void); void CB2_ContinueSavedGame(void);
void ResetAllMultiplayerState(void); void ResetAllMultiplayerState(void);
u32 sub_8087214(void); u32 GetCableClubPartnersReady(void);
bool32 sub_808727C(void); u16 SetInCableClubSeat(void);
u16 sub_8087288(void); u16 SetLinkWaitingForScript(void);
u16 sub_808729C(void);
u16 QueueExitLinkRoomKey(void); u16 QueueExitLinkRoomKey(void);
u16 sub_80872C4(void); u16 SetStartedCableClubActivity(void);
bool32 Overworld_LinkRecvQueueLengthMoreThan2(void); bool32 Overworld_LinkRecvQueueLengthMoreThan2(void);
bool32 Overworld_RecvKeysFromLinkIsRunning(void); bool32 Overworld_RecvKeysFromLinkIsRunning(void);
bool32 Overworld_SendKeysToLinkIsRunning(void); bool32 Overworld_SendKeysToLinkIsRunning(void);

View File

@ -1053,29 +1053,31 @@ static void Task_EnterCableClubSeat(u8 taskId)
case 1: case 1:
if (IsFieldMessageBoxHidden()) if (IsFieldMessageBoxHidden())
{ {
sub_8087288(); SetInCableClubSeat();
SetLocalLinkPlayerId(gSpecialVar_0x8005); SetLocalLinkPlayerId(gSpecialVar_0x8005);
task->tState = 2; task->tState = 2;
} }
break; break;
case 2: case 2:
switch (sub_8087214()) switch (GetCableClubPartnersReady())
{ {
case 0: case CABLE_SEAT_WAITING:
break; break;
case 1: case CABLE_SEAT_SUCCESS:
// Partners linked and ready, switch to relevant link function
HideFieldMessageBox(); HideFieldMessageBox();
task->tState = 0; task->tState = 0;
sub_80872C4(); SetStartedCableClubActivity();
SwitchTaskToFollowupFunc(taskId); SwitchTaskToFollowupFunc(taskId);
break; break;
case 2: case CABLE_SEAT_FAILED:
task->tState = 3; task->tState = 3;
break; break;
} }
break; break;
case 3: case 3:
sub_808729C(); // Exit, failure
SetLinkWaitingForScript();
sub_8197AE8(TRUE); sub_8197AE8(TRUE);
DestroyTask(taskId); DestroyTask(taskId);
EnableBothScriptContexts(); EnableBothScriptContexts();

View File

@ -121,7 +121,7 @@ static void Task_DiplomaFadeOut(u8 taskId)
Free(sDiplomaTilemapPtr); Free(sDiplomaTilemapPtr);
FreeAllWindowBuffers(); FreeAllWindowBuffers();
DestroyTask(taskId); DestroyTask(taskId);
SetMainCallback2(sub_80861E8); SetMainCallback2(CB2_ReturnToFieldFadeFromBlack);
} }
} }

View File

@ -68,10 +68,20 @@
#include "constants/trainer_hill.h" #include "constants/trainer_hill.h"
#include "constants/weather.h" #include "constants/weather.h"
#define PLAYER_TRADING_STATE_IDLE 0x80 struct CableClubPlayer
#define PLAYER_TRADING_STATE_BUSY 0x81 {
#define PLAYER_TRADING_STATE_UNK_2 0x82 u8 playerId;
#define PLAYER_TRADING_STATE_EXITING_ROOM 0x83 u8 isLocalPlayer;
u8 movementMode;
u8 facing;
struct MapPosition pos;
u16 metatileBehavior;
};
#define PLAYER_LINK_STATE_IDLE 0x80
#define PLAYER_LINK_STATE_BUSY 0x81
#define PLAYER_LINK_STATE_READY 0x82
#define PLAYER_LINK_STATE_EXITING_ROOM 0x83
#define FACING_NONE 0 #define FACING_NONE 0
#define FACING_UP 1 #define FACING_UP 1
@ -92,82 +102,82 @@ static void CB2_ReturnToFieldLink(void);
static void CB2_LoadMapOnReturnToFieldCableClub(void); static void CB2_LoadMapOnReturnToFieldCableClub(void);
static void CB2_LoadMap2(void); static void CB2_LoadMap2(void);
static void VBlankCB_Field(void); static void VBlankCB_Field(void);
static void SpriteCB_LinkPlayer(struct Sprite *sprite); static void SpriteCB_LinkPlayer(struct Sprite *);
static void ChooseAmbientCrySpecies(void); static void ChooseAmbientCrySpecies(void);
static void DoMapLoadLoop(u8 *state); static void DoMapLoadLoop(u8 *);
static bool32 LoadMapInStepsLocal(u8 *state, bool32); static bool32 LoadMapInStepsLocal(u8 *, bool32);
static bool32 LoadMapInStepsLink(u8 *state); static bool32 LoadMapInStepsLink(u8 *);
static bool32 ReturnToFieldLocal(u8 *state); static bool32 ReturnToFieldLocal(u8 *);
static bool32 ReturnToFieldLink(u8 *state); static bool32 ReturnToFieldLink(u8 *);
static void InitObjectEventsLink(void); static void InitObjectEventsLink(void);
static void InitObjectEventsLocal(void); static void InitObjectEventsLocal(void);
static void InitOverworldGraphicsRegisters(void); static void InitOverworldGraphicsRegisters(void);
static u8 GetSpriteForLinkedPlayer(u8); static u8 GetSpriteForLinkedPlayer(u8);
static u16 KeyInterCB_SendNothing(u32 a1); static u16 KeyInterCB_SendNothing(u32);
static void ResetMirageTowerAndSaveBlockPtrs(void); static void ResetMirageTowerAndSaveBlockPtrs(void);
static void sub_80867D8(void); static void ResetScreenForMapLoad(void);
static void OffsetCameraFocusByLinkPlayerId(void); static void OffsetCameraFocusByLinkPlayerId(void);
static void SpawnLinkPlayers(void); static void SpawnLinkPlayers(void);
static void SetCameraToTrackGuestPlayer(void); static void SetCameraToTrackGuestPlayer(void);
static void ResumeMap(bool32 arg0); static void ResumeMap(bool32);
static void SetCameraToTrackPlayer(void); static void SetCameraToTrackPlayer(void);
static void InitObjectEventsReturnToField(void); static void InitObjectEventsReturnToField(void);
static void InitViewGraphics(void); static void InitViewGraphics(void);
static void SetCameraToTrackGuestPlayer_2(void); static void SetCameraToTrackGuestPlayer_2(void);
static void CreateLinkPlayerSprites(void); static void CreateLinkPlayerSprites(void);
static void ClearAllPlayerKeys(void); static void ClearAllPlayerKeys(void);
static void ResetAllTradingStates(void); static void ResetAllPlayerLinkStates(void);
static void UpdateHeldKeyCode(u16); static void UpdateHeldKeyCode(u16);
static void UpdateAllLinkPlayers(u16*, s32); static void UpdateAllLinkPlayers(u16*, s32);
static u8 FlipVerticalAndClearForced(u8 a1, u8 a2); static u8 FlipVerticalAndClearForced(u8, u8);
static u8 LinkPlayerDetectCollision(u8 selfObjEventId, u8 a2, s16 x, s16 y); static u8 LinkPlayerDetectCollision(u8, u8, s16, s16);
static void CreateLinkPlayerSprite(u8 linkPlayerId, u8 gameVersion); static void CreateLinkPlayerSprite(u8, u8);
static void GetLinkPlayerCoords(u8 linkPlayerId, u16 *x, u16 *y); static void GetLinkPlayerCoords(u8, u16 *, u16 *);
static u8 GetLinkPlayerFacingDirection(u8 linkPlayerId); static u8 GetLinkPlayerFacingDirection(u8);
static u8 GetLinkPlayerElevation(u8 linkPlayerId); static u8 GetLinkPlayerElevation(u8);
static s32 GetLinkPlayerObjectStepTimer(u8 linkPlayerId); static s32 GetLinkPlayerObjectStepTimer(u8);
static u8 GetLinkPlayerIdAt(s16 x, s16 y); static u8 GetLinkPlayerIdAt(s16, s16);
static void SetPlayerFacingDirection(u8 linkPlayerId, u8 a2); static void SetPlayerFacingDirection(u8, u8);
static void ZeroObjectEvent(struct ObjectEvent *objEvent); static void ZeroObjectEvent(struct ObjectEvent *);
static void SpawnLinkPlayerObjectEvent(u8 linkPlayerId, s16 x, s16 y, u8 a4); static void SpawnLinkPlayerObjectEvent(u8, s16, s16, u8);
static void InitLinkPlayerObjectEventPos(struct ObjectEvent *objEvent, s16 x, s16 y); static void InitLinkPlayerObjectEventPos(struct ObjectEvent *, s16, s16);
static void SetLinkPlayerObjectRange(u8 linkPlayerId, u8 a2); static void SetLinkPlayerObjectRange(u8, u8);
static void DestroyLinkPlayerObject(u8 linkPlayerId); static void DestroyLinkPlayerObject(u8);
static u8 GetSpriteForLinkedPlayer(u8 linkPlayerId); static u8 GetSpriteForLinkedPlayer(u8);
static void RunTerminateLinkScript(void); static void RunTerminateLinkScript(void);
static u32 GetLinkSendQueueLength(void); static u32 GetLinkSendQueueLength(void);
static void ZeroLinkPlayerObjectEvent(struct LinkPlayerObjectEvent *linkPlayerObjEvent); static void ZeroLinkPlayerObjectEvent(struct LinkPlayerObjectEvent *);
static const u8 *TryInteractWithPlayer(struct TradeRoomPlayer *a1); static const u8 *TryInteractWithPlayer(struct CableClubPlayer *);
static u16 GetDirectionForEventScript(const u8 *script); static u16 GetDirectionForEventScript(const u8 *);
static void sub_8087510(void); static void InitLinkPlayerQueueScript(void);
static void InitLinkRoomStartMenuScript(void); static void InitLinkRoomStartMenuScript(void);
static void sub_8087530(const u8 *script); static void RunInteractLocalPlayerScript(const u8 *);
static void CreateConfirmLeaveTradeRoomPrompt(void); static void RunConfirmLeaveCableClubScript(void);
static void InitMenuBasedScript(const u8 *script); static void InitMenuBasedScript(const u8 *);
static void LoadTradeRoomPlayer(s32 linkPlayerId, s32 a2, struct TradeRoomPlayer *a3); static void LoadCableClubPlayer(s32, s32, struct CableClubPlayer *);
static bool32 sub_8087340(struct TradeRoomPlayer *a1); static bool32 IsCableClubPlayerUnfrozen(struct CableClubPlayer *);
static bool32 sub_8087340_2(struct TradeRoomPlayer *a1); static bool32 CanCableClubPlayerPressStart(struct CableClubPlayer *);
static u8 *TryGetTileEventScript(struct TradeRoomPlayer *a1); static u8 *TryGetTileEventScript(struct CableClubPlayer *);
static bool32 PlayerIsAtSouthExit(struct TradeRoomPlayer *a1); static bool32 PlayerIsAtSouthExit(struct CableClubPlayer *);
static const u8 *TryInteractWithPlayer(struct TradeRoomPlayer *a1); static const u8 *TryInteractWithPlayer(struct CableClubPlayer *);
static u16 KeyInterCB_DeferToRecvQueue(u32); static u16 KeyInterCB_DeferToRecvQueue(u32);
static u16 KeyInterCB_DeferToSendQueue(u32); static u16 KeyInterCB_DeferToSendQueue(u32);
static void ResetPlayerHeldKeys(u16 *a1); static void ResetPlayerHeldKeys(u16 *);
static u16 KeyInterCB_SelfIdle(u32 a1); static u16 KeyInterCB_SelfIdle(u32);
static u16 KeyInterCB_DeferToEventScript(u32 a1); static u16 KeyInterCB_DeferToEventScript(u32);
static u16 GetDirectionForDpadKey(u16 a1); static u16 GetDirectionForDpadKey(u16);
static void CB1_UpdateLinkState(void); static void CB1_UpdateLinkState(void);
static void SetKeyInterceptCallback(u16 (*func)(u32)); static void SetKeyInterceptCallback(u16 (*func)(u32));
static void SetFieldVBlankCallback(void); static void SetFieldVBlankCallback(void);
static void FieldClearVBlankHBlankCallbacks(void); static void FieldClearVBlankHBlankCallbacks(void);
static void TransitionMapMusic(void); static void TransitionMapMusic(void);
static u8 GetAdjustedInitialTransitionFlags(struct InitialPlayerAvatarState *playerStruct, u16 a2, u8 a3); static u8 GetAdjustedInitialTransitionFlags(struct InitialPlayerAvatarState *, u16, u8);
static u8 GetAdjustedInitialDirection(struct InitialPlayerAvatarState *playerStruct, u8 a2, u16 a3, u8 a4); static u8 GetAdjustedInitialDirection(struct InitialPlayerAvatarState *, u8, u16, u8);
static u16 GetCenterScreenMetatileBehavior(void); static u16 GetCenterScreenMetatileBehavior(void);
// IWRAM bss vars // IWRAM bss vars
static void *sUnusedOverworldCallback; static void *sUnusedOverworldCallback;
static u8 sPlayerTradingStates[MAX_LINK_PLAYERS]; static u8 sPlayerLinkStates[MAX_LINK_PLAYERS];
// This callback is called with a player's key code. It then returns an // This callback is called with a player's key code. It then returns an
// adjusted key code, effectively intercepting the input before anything // adjusted key code, effectively intercepting the input before anything
// can process it. // can process it.
@ -311,13 +321,13 @@ static const struct ScanlineEffectParams sFlashEffectParams =
static u8 MovementEventModeCB_Normal(struct LinkPlayerObjectEvent *, struct ObjectEvent *, u8); static u8 MovementEventModeCB_Normal(struct LinkPlayerObjectEvent *, struct ObjectEvent *, u8);
static u8 MovementEventModeCB_Ignored(struct LinkPlayerObjectEvent *, struct ObjectEvent *, u8); static u8 MovementEventModeCB_Ignored(struct LinkPlayerObjectEvent *, struct ObjectEvent *, u8);
static u8 MovementEventModeCB_Normal_2(struct LinkPlayerObjectEvent *, struct ObjectEvent *, u8); static u8 MovementEventModeCB_Scripted(struct LinkPlayerObjectEvent *, struct ObjectEvent *, u8);
static u8 (*const gLinkPlayerMovementModes[])(struct LinkPlayerObjectEvent *, struct ObjectEvent *, u8) = static u8 (*const gLinkPlayerMovementModes[])(struct LinkPlayerObjectEvent *, struct ObjectEvent *, u8) =
{ {
MovementEventModeCB_Normal, // MOVEMENT_MODE_FREE [MOVEMENT_MODE_FREE] = MovementEventModeCB_Normal,
MovementEventModeCB_Ignored, // MOVEMENT_MODE_FROZEN [MOVEMENT_MODE_FROZEN] = MovementEventModeCB_Ignored,
MovementEventModeCB_Normal_2, // MOVEMENT_MODE_SCRIPTED [MOVEMENT_MODE_SCRIPTED] = MovementEventModeCB_Scripted,
}; };
static u8 FacingHandler_DoNothing(struct LinkPlayerObjectEvent *, struct ObjectEvent *, u8); static u8 FacingHandler_DoNothing(struct LinkPlayerObjectEvent *, struct ObjectEvent *, u8);
@ -411,7 +421,7 @@ static void Overworld_ResetStateAfterWhiteOut(void)
} }
} }
static void sub_8084788(void) static void UpdateMiscOverworldStates(void)
{ {
FlagClear(FLAG_SYS_SAFARI_MODE); FlagClear(FLAG_SYS_SAFARI_MODE);
ChooseAmbientCrySpecies(); ChooseAmbientCrySpecies();
@ -1668,14 +1678,14 @@ void CB2_ReturnToFieldContinueScriptPlayMapMusic(void)
CB2_ReturnToField(); CB2_ReturnToField();
} }
void sub_80861E8(void) void CB2_ReturnToFieldFadeFromBlack(void)
{ {
FieldClearVBlankHBlankCallbacks(); FieldClearVBlankHBlankCallbacks();
gFieldCallback = FieldCB_WarpExitFadeFromBlack; gFieldCallback = FieldCB_WarpExitFadeFromBlack;
CB2_ReturnToField(); CB2_ReturnToField();
} }
static void sub_8086204(void) static void FieldCB_FadeTryShowMapPopup(void)
{ {
if (SHOW_MAP_NAME_ENABLED && SecretBaseMapPopupEnabled() == TRUE) if (SHOW_MAP_NAME_ENABLED && SecretBaseMapPopupEnabled() == TRUE)
ShowMapNamePopup(); ShowMapNamePopup();
@ -1704,7 +1714,7 @@ void CB2_ContinueSavedGame(void)
UnfreezeObjectEvents(); UnfreezeObjectEvents();
DoTimeBasedEvents(); DoTimeBasedEvents();
sub_8084788(); UpdateMiscOverworldStates();
if (gMapHeader.mapLayoutId == LAYOUT_BATTLE_FRONTIER_BATTLE_PYRAMID_FLOOR) if (gMapHeader.mapLayoutId == LAYOUT_BATTLE_FRONTIER_BATTLE_PYRAMID_FLOOR)
InitBattlePyramidMap(TRUE); InitBattlePyramidMap(TRUE);
else if (trainerHillMapId != 0) else if (trainerHillMapId != 0)
@ -1727,7 +1737,7 @@ void CB2_ContinueSavedGame(void)
else else
{ {
TryPutTodaysRivalTrainerOnAir(); TryPutTodaysRivalTrainerOnAir();
gFieldCallback = sub_8086204; gFieldCallback = FieldCB_FadeTryShowMapPopup;
SetMainCallback1(CB1_Overworld); SetMainCallback1(CB1_Overworld);
CB2_ReturnToField(); CB2_ReturnToField();
} }
@ -1796,7 +1806,7 @@ static bool32 LoadMapInStepsLink(u8 *state)
ScriptContext1_Init(); ScriptContext1_Init();
ScriptContext2_Disable(); ScriptContext2_Disable();
ResetMirageTowerAndSaveBlockPtrs(); ResetMirageTowerAndSaveBlockPtrs();
sub_80867D8(); ResetScreenForMapLoad();
(*state)++; (*state)++;
break; break;
case 1: case 1:
@ -1877,7 +1887,7 @@ static bool32 LoadMapInStepsLocal(u8 *state, bool32 a2)
break; break;
case 1: case 1:
ResetMirageTowerAndSaveBlockPtrs(); ResetMirageTowerAndSaveBlockPtrs();
sub_80867D8(); ResetScreenForMapLoad();
(*state)++; (*state)++;
break; break;
case 2: case 2:
@ -1944,7 +1954,7 @@ static bool32 ReturnToFieldLocal(u8 *state)
{ {
case 0: case 0:
ResetMirageTowerAndSaveBlockPtrs(); ResetMirageTowerAndSaveBlockPtrs();
sub_80867D8(); ResetScreenForMapLoad();
ResumeMap(FALSE); ResumeMap(FALSE);
InitObjectEventsReturnToField(); InitObjectEventsReturnToField();
SetCameraToTrackPlayer(); SetCameraToTrackPlayer();
@ -1973,7 +1983,7 @@ static bool32 ReturnToFieldLink(u8 *state)
case 0: case 0:
FieldClearVBlankHBlankCallbacks(); FieldClearVBlankHBlankCallbacks();
ResetMirageTowerAndSaveBlockPtrs(); ResetMirageTowerAndSaveBlockPtrs();
sub_80867D8(); ResetScreenForMapLoad();
(*state)++; (*state)++;
break; break;
case 1: case 1:
@ -2054,7 +2064,7 @@ static void ResetMirageTowerAndSaveBlockPtrs(void)
MoveSaveBlocks_ResetHeap(); MoveSaveBlocks_ResetHeap();
} }
static void sub_80867D8(void) static void ResetScreenForMapLoad(void)
{ {
SetGpuReg(REG_OFFSET_DISPCNT, 0); SetGpuReg(REG_OFFSET_DISPCNT, 0);
ScanlineEffect_Stop(); ScanlineEffect_Stop();
@ -2241,7 +2251,7 @@ static void CB1_UpdateLinkState(void)
void ResetAllMultiplayerState(void) void ResetAllMultiplayerState(void)
{ {
ResetAllTradingStates(); ResetAllPlayerLinkStates();
SetKeyInterceptCallback(KeyInterCB_SelfIdle); SetKeyInterceptCallback(KeyInterCB_SelfIdle);
} }
@ -2266,57 +2276,57 @@ static void CheckRfuKeepAliveTimer(void)
LinkRfu_FatalError(); LinkRfu_FatalError();
} }
static void ResetAllTradingStates(void) static void ResetAllPlayerLinkStates(void)
{ {
s32 i; s32 i;
for (i = 0; i < MAX_LINK_PLAYERS; i++) for (i = 0; i < MAX_LINK_PLAYERS; i++)
sPlayerTradingStates[i] = PLAYER_TRADING_STATE_IDLE; sPlayerLinkStates[i] = PLAYER_LINK_STATE_IDLE;
} }
// Returns true if all connected players are in tradingState. // Returns true if all connected players are in state.
static bool32 AreAllPlayersInTradingState(u16 tradingState) static bool32 AreAllPlayersInLinkState(u16 state)
{ {
s32 i; s32 i;
s32 count = gFieldLinkPlayerCount; s32 count = gFieldLinkPlayerCount;
for (i = 0; i < count; i++) for (i = 0; i < count; i++)
if (sPlayerTradingStates[i] != tradingState) if (sPlayerLinkStates[i] != state)
return FALSE; return FALSE;
return TRUE; return TRUE;
} }
static bool32 IsAnyPlayerInTradingState(u16 tradingState) static bool32 IsAnyPlayerInLinkState(u16 state)
{ {
s32 i; s32 i;
s32 count = gFieldLinkPlayerCount; s32 count = gFieldLinkPlayerCount;
for (i = 0; i < count; i++) for (i = 0; i < count; i++)
if (sPlayerTradingStates[i] == tradingState) if (sPlayerLinkStates[i] == state)
return TRUE; return TRUE;
return FALSE; return FALSE;
} }
static void HandleLinkPlayerKeyInput(u32 playerId, u16 key, struct TradeRoomPlayer *trainer, u16 *forceFacing) static void HandleLinkPlayerKeyInput(u32 playerId, u16 key, struct CableClubPlayer *trainer, u16 *forceFacing)
{ {
const u8 *script; const u8 *script;
if (sPlayerTradingStates[playerId] == PLAYER_TRADING_STATE_IDLE) if (sPlayerLinkStates[playerId] == PLAYER_LINK_STATE_IDLE)
{ {
script = TryGetTileEventScript(trainer); script = TryGetTileEventScript(trainer);
if (script) if (script)
{ {
*forceFacing = GetDirectionForEventScript(script); *forceFacing = GetDirectionForEventScript(script);
sPlayerTradingStates[playerId] = PLAYER_TRADING_STATE_BUSY; sPlayerLinkStates[playerId] = PLAYER_LINK_STATE_BUSY;
if (trainer->isLocalPlayer) if (trainer->isLocalPlayer)
{ {
SetKeyInterceptCallback(KeyInterCB_DeferToEventScript); SetKeyInterceptCallback(KeyInterCB_DeferToEventScript);
sub_8087530(script); RunInteractLocalPlayerScript(script);
} }
return; return;
} }
if (IsAnyPlayerInTradingState(PLAYER_TRADING_STATE_EXITING_ROOM) == TRUE) if (IsAnyPlayerInLinkState(PLAYER_LINK_STATE_EXITING_ROOM) == TRUE)
{ {
sPlayerTradingStates[playerId] = PLAYER_TRADING_STATE_BUSY; sPlayerLinkStates[playerId] = PLAYER_LINK_STATE_BUSY;
if (trainer->isLocalPlayer) if (trainer->isLocalPlayer)
{ {
SetKeyInterceptCallback(KeyInterCB_DeferToEventScript); SetKeyInterceptCallback(KeyInterCB_DeferToEventScript);
@ -2328,9 +2338,9 @@ static void HandleLinkPlayerKeyInput(u32 playerId, u16 key, struct TradeRoomPlay
switch (key) switch (key)
{ {
case LINK_KEY_CODE_START_BUTTON: case LINK_KEY_CODE_START_BUTTON:
if (sub_8087340_2(trainer)) if (CanCableClubPlayerPressStart(trainer))
{ {
sPlayerTradingStates[playerId] = PLAYER_TRADING_STATE_BUSY; sPlayerLinkStates[playerId] = PLAYER_LINK_STATE_BUSY;
if (trainer->isLocalPlayer) if (trainer->isLocalPlayer)
{ {
SetKeyInterceptCallback(KeyInterCB_DeferToEventScript); SetKeyInterceptCallback(KeyInterCB_DeferToEventScript);
@ -2341,11 +2351,11 @@ static void HandleLinkPlayerKeyInput(u32 playerId, u16 key, struct TradeRoomPlay
case LINK_KEY_CODE_DPAD_DOWN: case LINK_KEY_CODE_DPAD_DOWN:
if (PlayerIsAtSouthExit(trainer) == TRUE) if (PlayerIsAtSouthExit(trainer) == TRUE)
{ {
sPlayerTradingStates[playerId] = PLAYER_TRADING_STATE_BUSY; sPlayerLinkStates[playerId] = PLAYER_LINK_STATE_BUSY;
if (trainer->isLocalPlayer) if (trainer->isLocalPlayer)
{ {
SetKeyInterceptCallback(KeyInterCB_DeferToEventScript); SetKeyInterceptCallback(KeyInterCB_DeferToEventScript);
CreateConfirmLeaveTradeRoomPrompt(); RunConfirmLeaveCableClubScript();
} }
} }
break; break;
@ -2353,7 +2363,7 @@ static void HandleLinkPlayerKeyInput(u32 playerId, u16 key, struct TradeRoomPlay
script = TryInteractWithPlayer(trainer); script = TryInteractWithPlayer(trainer);
if (script) if (script)
{ {
sPlayerTradingStates[playerId] = PLAYER_TRADING_STATE_BUSY; sPlayerLinkStates[playerId] = PLAYER_LINK_STATE_BUSY;
if (trainer->isLocalPlayer) if (trainer->isLocalPlayer)
{ {
SetKeyInterceptCallback(KeyInterCB_DeferToEventScript); SetKeyInterceptCallback(KeyInterCB_DeferToEventScript);
@ -2362,24 +2372,24 @@ static void HandleLinkPlayerKeyInput(u32 playerId, u16 key, struct TradeRoomPlay
} }
break; break;
case LINK_KEY_CODE_HANDLE_RECV_QUEUE: case LINK_KEY_CODE_HANDLE_RECV_QUEUE:
if (sub_8087340(trainer)) if (IsCableClubPlayerUnfrozen(trainer))
{ {
sPlayerTradingStates[playerId] = PLAYER_TRADING_STATE_BUSY; sPlayerLinkStates[playerId] = PLAYER_LINK_STATE_BUSY;
if (trainer->isLocalPlayer) if (trainer->isLocalPlayer)
{ {
SetKeyInterceptCallback(KeyInterCB_DeferToRecvQueue); SetKeyInterceptCallback(KeyInterCB_DeferToRecvQueue);
sub_8087510(); InitLinkPlayerQueueScript();
} }
} }
break; break;
case LINK_KEY_CODE_HANDLE_SEND_QUEUE: case LINK_KEY_CODE_HANDLE_SEND_QUEUE:
if (sub_8087340(trainer)) if (IsCableClubPlayerUnfrozen(trainer))
{ {
sPlayerTradingStates[playerId] = PLAYER_TRADING_STATE_BUSY; sPlayerLinkStates[playerId] = PLAYER_LINK_STATE_BUSY;
if (trainer->isLocalPlayer) if (trainer->isLocalPlayer)
{ {
SetKeyInterceptCallback(KeyInterCB_DeferToSendQueue); SetKeyInterceptCallback(KeyInterCB_DeferToSendQueue);
sub_8087510(); InitLinkPlayerQueueScript();
} }
} }
break; break;
@ -2389,35 +2399,35 @@ static void HandleLinkPlayerKeyInput(u32 playerId, u16 key, struct TradeRoomPlay
switch (key) switch (key)
{ {
case LINK_KEY_CODE_EXIT_ROOM: case LINK_KEY_CODE_EXIT_ROOM:
sPlayerTradingStates[playerId] = PLAYER_TRADING_STATE_EXITING_ROOM; sPlayerLinkStates[playerId] = PLAYER_LINK_STATE_EXITING_ROOM;
break; break;
case LINK_KEY_CODE_UNK_2: case LINK_KEY_CODE_READY:
sPlayerTradingStates[playerId] = PLAYER_TRADING_STATE_UNK_2; sPlayerLinkStates[playerId] = PLAYER_LINK_STATE_READY;
break; break;
case LINK_KEY_CODE_UNK_4: case LINK_KEY_CODE_IDLE:
sPlayerTradingStates[playerId] = PLAYER_TRADING_STATE_IDLE; sPlayerLinkStates[playerId] = PLAYER_LINK_STATE_IDLE;
if (trainer->isLocalPlayer) if (trainer->isLocalPlayer)
SetKeyInterceptCallback(KeyInterCB_SelfIdle); SetKeyInterceptCallback(KeyInterCB_SelfIdle);
break; break;
case LINK_KEY_CODE_UNK_7: case LINK_KEY_CODE_EXIT_SEAT:
if (sPlayerTradingStates[playerId] == PLAYER_TRADING_STATE_UNK_2) if (sPlayerLinkStates[playerId] == PLAYER_LINK_STATE_READY)
sPlayerTradingStates[playerId] = PLAYER_TRADING_STATE_BUSY; sPlayerLinkStates[playerId] = PLAYER_LINK_STATE_BUSY;
break; break;
} }
} }
static void UpdateAllLinkPlayers(u16 *keys, s32 selfId) static void UpdateAllLinkPlayers(u16 *keys, s32 selfId)
{ {
struct TradeRoomPlayer trainer; struct CableClubPlayer trainer;
s32 i; s32 i;
for (i = 0; i < MAX_LINK_PLAYERS; i++) for (i = 0; i < MAX_LINK_PLAYERS; i++)
{ {
u8 key = keys[i]; u8 key = keys[i];
u16 setFacing = FACING_NONE; u16 setFacing = FACING_NONE;
LoadTradeRoomPlayer(i, selfId, &trainer); LoadCableClubPlayer(i, selfId, &trainer);
HandleLinkPlayerKeyInput(i, key, &trainer, &setFacing); HandleLinkPlayerKeyInput(i, key, &trainer, &setFacing);
if (sPlayerTradingStates[i] == PLAYER_TRADING_STATE_IDLE) if (sPlayerLinkStates[i] == PLAYER_LINK_STATE_IDLE)
setFacing = GetDirectionForDpadKey(key); setFacing = GetDirectionForDpadKey(key);
SetPlayerFacingDirection(i, setFacing); SetPlayerFacingDirection(i, setFacing);
} }
@ -2504,7 +2514,7 @@ static u16 KeyInterCB_SelfIdle(u32 key)
return LINK_KEY_CODE_HANDLE_SEND_QUEUE; return LINK_KEY_CODE_HANDLE_SEND_QUEUE;
} }
static u16 sub_80870EC(u32 key) static u16 KeyInterCB_Idle(u32 key)
{ {
CheckRfuKeepAliveTimer(); CheckRfuKeepAliveTimer();
return LINK_KEY_CODE_EMPTY; return LINK_KEY_CODE_EMPTY;
@ -2521,8 +2531,8 @@ static u16 KeyInterCB_DeferToEventScript(u32 key)
} }
else else
{ {
retVal = LINK_KEY_CODE_UNK_4; retVal = LINK_KEY_CODE_IDLE;
SetKeyInterceptCallback(sub_80870EC); SetKeyInterceptCallback(KeyInterCB_Idle);
} }
return retVal; return retVal;
} }
@ -2537,9 +2547,9 @@ static u16 KeyInterCB_DeferToRecvQueue(u32 key)
} }
else else
{ {
retVal = LINK_KEY_CODE_UNK_4; retVal = LINK_KEY_CODE_IDLE;
ScriptContext2_Disable(); ScriptContext2_Disable();
SetKeyInterceptCallback(sub_80870EC); SetKeyInterceptCallback(KeyInterCB_Idle);
} }
return retVal; return retVal;
} }
@ -2554,27 +2564,27 @@ static u16 KeyInterCB_DeferToSendQueue(u32 key)
} }
else else
{ {
retVal = LINK_KEY_CODE_UNK_4; retVal = LINK_KEY_CODE_IDLE;
ScriptContext2_Disable(); ScriptContext2_Disable();
SetKeyInterceptCallback(sub_80870EC); SetKeyInterceptCallback(KeyInterCB_Idle);
} }
return retVal; return retVal;
} }
static u16 KeyInterCB_DoNothingAndKeepAlive(u32 key) static u16 KeyInterCB_ExitingSeat(u32 key)
{ {
CheckRfuKeepAliveTimer(); CheckRfuKeepAliveTimer();
return LINK_KEY_CODE_EMPTY; return LINK_KEY_CODE_EMPTY;
} }
static u16 sub_8087170(u32 keyOrPlayerId) static u16 KeyInterCB_Ready(u32 keyOrPlayerId)
{ {
if (sPlayerTradingStates[keyOrPlayerId] == PLAYER_TRADING_STATE_UNK_2) if (sPlayerLinkStates[keyOrPlayerId] == PLAYER_LINK_STATE_READY)
{ {
if (JOY_NEW(B_BUTTON)) if (JOY_NEW(B_BUTTON))
{ {
SetKeyInterceptCallback(KeyInterCB_DoNothingAndKeepAlive); SetKeyInterceptCallback(KeyInterCB_ExitingSeat);
return LINK_KEY_CODE_UNK_7; return LINK_KEY_CODE_EXIT_SEAT;
} }
else else
{ {
@ -2588,10 +2598,10 @@ static u16 sub_8087170(u32 keyOrPlayerId)
} }
} }
static u16 sub_80871AC(u32 a1) static u16 KeyInterCB_SetReady(u32 a1)
{ {
SetKeyInterceptCallback(sub_8087170); SetKeyInterceptCallback(KeyInterCB_Ready);
return LINK_KEY_CODE_UNK_2; return LINK_KEY_CODE_READY;
} }
static u16 KeyInterCB_SendNothing(u32 key) static u16 KeyInterCB_SendNothing(u32 key)
@ -2604,9 +2614,9 @@ static u16 KeyInterCB_WaitForPlayersToExit(u32 keyOrPlayerId)
// keyOrPlayerId could be any keycode. This callback does no sanity checking // keyOrPlayerId could be any keycode. This callback does no sanity checking
// on the size of the key. It's assuming that it is being called from // on the size of the key. It's assuming that it is being called from
// CB1_UpdateLinkState. // CB1_UpdateLinkState.
if (sPlayerTradingStates[keyOrPlayerId] != PLAYER_TRADING_STATE_EXITING_ROOM) if (sPlayerLinkStates[keyOrPlayerId] != PLAYER_LINK_STATE_EXITING_ROOM)
CheckRfuKeepAliveTimer(); CheckRfuKeepAliveTimer();
if (AreAllPlayersInTradingState(PLAYER_TRADING_STATE_EXITING_ROOM) == TRUE) if (AreAllPlayersInLinkState(PLAYER_LINK_STATE_EXITING_ROOM) == TRUE)
{ {
ScriptContext1_SetupScript(EventScript_DoLinkRoomExit); ScriptContext1_SetupScript(EventScript_DoLinkRoomExit);
SetKeyInterceptCallback(KeyInterCB_SendNothing); SetKeyInterceptCallback(KeyInterCB_SendNothing);
@ -2620,37 +2630,38 @@ static u16 KeyInterCB_SendExitRoomKey(u32 key)
return LINK_KEY_CODE_EXIT_ROOM; return LINK_KEY_CODE_EXIT_ROOM;
} }
// Duplicate function. // Identical to KeyInterCB_SendNothing
static u16 KeyInterCB_SendNothing_2(u32 key) static u16 KeyInterCB_InLinkActivity(u32 key)
{ {
return LINK_KEY_CODE_EMPTY; return LINK_KEY_CODE_EMPTY;
} }
u32 sub_8087214(void) u32 GetCableClubPartnersReady(void)
{ {
if (IsAnyPlayerInTradingState(PLAYER_TRADING_STATE_EXITING_ROOM) == TRUE) if (IsAnyPlayerInLinkState(PLAYER_LINK_STATE_EXITING_ROOM) == TRUE)
return 2; return CABLE_SEAT_FAILED;
if (sPlayerKeyInterceptCallback == sub_8087170 && sPlayerTradingStates[gLocalLinkPlayerId] != PLAYER_TRADING_STATE_UNK_2) if (sPlayerKeyInterceptCallback == KeyInterCB_Ready && sPlayerLinkStates[gLocalLinkPlayerId] != PLAYER_LINK_STATE_READY)
return 0; return CABLE_SEAT_WAITING;
if (sPlayerKeyInterceptCallback == KeyInterCB_DoNothingAndKeepAlive && sPlayerTradingStates[gLocalLinkPlayerId] == PLAYER_TRADING_STATE_BUSY) if (sPlayerKeyInterceptCallback == KeyInterCB_ExitingSeat && sPlayerLinkStates[gLocalLinkPlayerId] == PLAYER_LINK_STATE_BUSY)
return 2; return CABLE_SEAT_FAILED;
if (AreAllPlayersInTradingState(PLAYER_TRADING_STATE_UNK_2) != FALSE) if (AreAllPlayersInLinkState(PLAYER_LINK_STATE_READY))
return 1; return CABLE_SEAT_SUCCESS;
return CABLE_SEAT_WAITING;
}
// Unused
static bool32 IsAnyPlayerExitingCableClub(void)
{
return IsAnyPlayerInLinkState(PLAYER_LINK_STATE_EXITING_ROOM);
}
u16 SetInCableClubSeat(void)
{
SetKeyInterceptCallback(KeyInterCB_SetReady);
return 0; return 0;
} }
bool32 sub_808727C(void) u16 SetLinkWaitingForScript(void)
{
return IsAnyPlayerInTradingState(PLAYER_TRADING_STATE_EXITING_ROOM);
}
u16 sub_8087288(void)
{
SetKeyInterceptCallback(sub_80871AC);
return 0;
}
u16 sub_808729C(void)
{ {
SetKeyInterceptCallback(KeyInterCB_DeferToEventScript); SetKeyInterceptCallback(KeyInterCB_DeferToEventScript);
return 0; return 0;
@ -2664,58 +2675,58 @@ u16 QueueExitLinkRoomKey(void)
return 0; return 0;
} }
u16 sub_80872C4(void) u16 SetStartedCableClubActivity(void)
{ {
SetKeyInterceptCallback(KeyInterCB_SendNothing_2); SetKeyInterceptCallback(KeyInterCB_InLinkActivity);
return 0; return 0;
} }
static void LoadTradeRoomPlayer(s32 linkPlayerId, s32 myPlayerId, struct TradeRoomPlayer *trainer) static void LoadCableClubPlayer(s32 linkPlayerId, s32 myPlayerId, struct CableClubPlayer *trainer)
{ {
s16 x, y; s16 x, y;
trainer->playerId = linkPlayerId; trainer->playerId = linkPlayerId;
trainer->isLocalPlayer = (linkPlayerId == myPlayerId) ? 1 : 0; trainer->isLocalPlayer = (linkPlayerId == myPlayerId) ? 1 : 0;
trainer->c = gLinkPlayerObjectEvents[linkPlayerId].movementMode; trainer->movementMode = gLinkPlayerObjectEvents[linkPlayerId].movementMode;
trainer->facing = GetLinkPlayerFacingDirection(linkPlayerId); trainer->facing = GetLinkPlayerFacingDirection(linkPlayerId);
GetLinkPlayerCoords(linkPlayerId, &x, &y); GetLinkPlayerCoords(linkPlayerId, &x, &y);
trainer->pos.x = x; trainer->pos.x = x;
trainer->pos.y = y; trainer->pos.y = y;
trainer->pos.height = GetLinkPlayerElevation(linkPlayerId); trainer->pos.height = GetLinkPlayerElevation(linkPlayerId);
trainer->field_C = MapGridGetMetatileBehaviorAt(x, y); trainer->metatileBehavior = MapGridGetMetatileBehaviorAt(x, y);
} }
static bool32 sub_8087340(struct TradeRoomPlayer *player) static bool32 IsCableClubPlayerUnfrozen(struct CableClubPlayer *player)
{ {
u8 v1 = player->c; u8 mode = player->movementMode;
if (v1 == MOVEMENT_MODE_SCRIPTED || v1 == MOVEMENT_MODE_FREE) if (mode == MOVEMENT_MODE_SCRIPTED || mode == MOVEMENT_MODE_FREE)
return TRUE; return TRUE;
else else
return FALSE; return FALSE;
} }
// Duplicate function. // Identical to IsCableClubPlayerUnfrozen
static bool32 sub_8087340_2(struct TradeRoomPlayer *player) static bool32 CanCableClubPlayerPressStart(struct CableClubPlayer *player)
{ {
u8 v1 = player->c; u8 mode = player->movementMode;
if (v1 == MOVEMENT_MODE_SCRIPTED || v1 == MOVEMENT_MODE_FREE) if (mode == MOVEMENT_MODE_SCRIPTED || mode == MOVEMENT_MODE_FREE)
return TRUE; return TRUE;
else else
return FALSE; return FALSE;
} }
static u8 *TryGetTileEventScript(struct TradeRoomPlayer *player) static u8 *TryGetTileEventScript(struct CableClubPlayer *player)
{ {
if (player->c != MOVEMENT_MODE_SCRIPTED) if (player->movementMode != MOVEMENT_MODE_SCRIPTED)
return FACING_NONE; return FACING_NONE;
return GetCoordEventScriptAtMapPosition(&player->pos); return GetCoordEventScriptAtMapPosition(&player->pos);
} }
static bool32 PlayerIsAtSouthExit(struct TradeRoomPlayer *player) static bool32 PlayerIsAtSouthExit(struct CableClubPlayer *player)
{ {
if (player->c != MOVEMENT_MODE_SCRIPTED && player->c != MOVEMENT_MODE_FREE) if (player->movementMode != MOVEMENT_MODE_SCRIPTED && player->movementMode != MOVEMENT_MODE_FREE)
return FALSE; return FALSE;
else if (!MetatileBehavior_IsSouthArrowWarp(player->field_C)) else if (!MetatileBehavior_IsSouthArrowWarp(player->metatileBehavior))
return FALSE; return FALSE;
else if (player->facing != DIR_SOUTH) else if (player->facing != DIR_SOUTH)
return FALSE; return FALSE;
@ -2723,12 +2734,12 @@ static bool32 PlayerIsAtSouthExit(struct TradeRoomPlayer *player)
return TRUE; return TRUE;
} }
static const u8 *TryInteractWithPlayer(struct TradeRoomPlayer *player) static const u8 *TryInteractWithPlayer(struct CableClubPlayer *player)
{ {
struct MapPosition otherPlayerPos; struct MapPosition otherPlayerPos;
u8 linkPlayerId; u8 linkPlayerId;
if (player->c != MOVEMENT_MODE_FREE && player->c != MOVEMENT_MODE_SCRIPTED) if (player->movementMode != MOVEMENT_MODE_FREE && player->movementMode != MOVEMENT_MODE_SCRIPTED)
return FACING_NONE; return FACING_NONE;
otherPlayerPos = player->pos; otherPlayerPos = player->pos;
@ -2741,7 +2752,7 @@ static const u8 *TryInteractWithPlayer(struct TradeRoomPlayer *player)
{ {
if (!player->isLocalPlayer) if (!player->isLocalPlayer)
return CableClub_EventScript_TooBusyToNotice; return CableClub_EventScript_TooBusyToNotice;
else if (sPlayerTradingStates[linkPlayerId] != PLAYER_TRADING_STATE_IDLE) else if (sPlayerLinkStates[linkPlayerId] != PLAYER_LINK_STATE_IDLE)
return CableClub_EventScript_TooBusyToNotice; return CableClub_EventScript_TooBusyToNotice;
else if (!GetLinkTrainerCardColor(linkPlayerId)) else if (!GetLinkTrainerCardColor(linkPlayerId))
return CableClub_EventScript_ReadTrainerCard; return CableClub_EventScript_ReadTrainerCard;
@ -2749,7 +2760,7 @@ static const u8 *TryInteractWithPlayer(struct TradeRoomPlayer *player)
return CableClub_EventScript_ReadTrainerCardColored; return CableClub_EventScript_ReadTrainerCardColored;
} }
return GetInteractedLinkPlayerScript(&otherPlayerPos, player->field_C, player->facing); return GetInteractedLinkPlayerScript(&otherPlayerPos, player->metatileBehavior, player->facing);
} }
// This returns which direction to force the player to look when one of // This returns which direction to force the player to look when one of
@ -2784,7 +2795,7 @@ static u16 GetDirectionForEventScript(const u8 *script)
return FACING_NONE; return FACING_NONE;
} }
static void sub_8087510(void) static void InitLinkPlayerQueueScript(void)
{ {
ScriptContext2_Enable(); ScriptContext2_Enable();
} }
@ -2796,17 +2807,17 @@ static void InitLinkRoomStartMenuScript(void)
ScriptContext2_Enable(); ScriptContext2_Enable();
} }
static void sub_8087530(const u8 *script) static void RunInteractLocalPlayerScript(const u8 *script)
{ {
PlaySE(SE_SELECT); PlaySE(SE_SELECT);
ScriptContext1_SetupScript(script); ScriptContext1_SetupScript(script);
ScriptContext2_Enable(); ScriptContext2_Enable();
} }
static void CreateConfirmLeaveTradeRoomPrompt(void) static void RunConfirmLeaveCableClubScript(void)
{ {
PlaySE(SE_WIN_OPEN); PlaySE(SE_WIN_OPEN);
ScriptContext1_SetupScript(EventScript_ConfirmLeaveTradeRoom); ScriptContext1_SetupScript(EventScript_ConfirmLeaveCableClubRoom);
ScriptContext2_Enable(); ScriptContext2_Enable();
} }
@ -3058,8 +3069,8 @@ static u8 MovementEventModeCB_Ignored(struct LinkPlayerObjectEvent *linkPlayerOb
return FACING_UP; return FACING_UP;
} }
// Duplicate Function // Identical to MovementEventModeCB_Normal
static u8 MovementEventModeCB_Normal_2(struct LinkPlayerObjectEvent *linkPlayerObjEvent, struct ObjectEvent *objEvent, u8 dir) static u8 MovementEventModeCB_Scripted(struct LinkPlayerObjectEvent *linkPlayerObjEvent, struct ObjectEvent *objEvent, u8 dir)
{ {
return gLinkPlayerFacingHandlers[dir](linkPlayerObjEvent, objEvent, dir); return gLinkPlayerFacingHandlers[dir](linkPlayerObjEvent, objEvent, dir);
} }

View File

@ -363,7 +363,7 @@ static void Task_RecordMixing_Main(u8 taskId)
{ {
free(sReceivedRecords); free(sReceivedRecords);
free(sSentRecord); free(sSentRecord);
sub_808729C(); SetLinkWaitingForScript();
if (gWirelessCommType != 0) if (gWirelessCommType != 0)
{ {
CreateTask(Task_ReturnToFieldRecordMixing, 10); CreateTask(Task_ReturnToFieldRecordMixing, 10);