Reverse engineered many of the multiplayer events

Some corrections to the way events are handled and identified.
This commit is contained in:
Phlosioneer 2019-02-10 20:42:50 -05:00
parent f2f1b1978b
commit e75f45dbcf
32 changed files with 412 additions and 350 deletions

View File

@ -6500,7 +6500,7 @@ _081D4F6C:
bne _081D4F88
movs r0, 0x49
bl PlaySE
bl sub_800A620
bl CheckShouldAdvanceLinkState
movs r0, 0
strh r0, [r5]
b _081D4FE6

View File

@ -1157,21 +1157,21 @@ EverGrandeCity_HallOfFame_EventScript_271851:: @ 8271851
setvar VAR_0x40D3, 1
return
EventScript_WhiteOut:: @ 8271857
gEventScript_WhiteOut:: @ 8271857
call EverGrandeCity_HallOfFame_EventScript_2718CC
goto EventScript_271862
goto gEventScript_ResetMrBriney
end
EventScript_271862:: @ 8271862
gEventScript_ResetMrBriney:: @ 8271862
compare VAR_0x4096, 1
goto_if_eq EverGrandeCity_HallOfFame_EventScript_271884
goto_if_eq EventScript_MoveMrBrineyToHouse
compare VAR_0x4096, 2
goto_if_eq EverGrandeCity_HallOfFame_EventScript_27189A
goto_if_eq EventScript_MoveMrBrineyToDewford
compare VAR_0x4096, 3
goto_if_eq EverGrandeCity_HallOfFame_EventScript_2718B3
goto_if_eq EventScript_MoveMrBrineyToRoute108
end
EverGrandeCity_HallOfFame_EventScript_271884:: @ 8271884
EventScript_MoveMrBrineyToHouse:: @ 8271884
setflag FLAG_HIDE_MR_BRINEY_DEWFORD_TOWN
setflag FLAG_HIDE_MR_BRINEY_BOAT_DEWFORD_TOWN
setflag FLAG_HIDE_ROUTE_108_MR_BRINEY
@ -1181,7 +1181,7 @@ EverGrandeCity_HallOfFame_EventScript_271884:: @ 8271884
clearflag FLAG_HIDE_BRINEYS_HOUSE_PEEKO
end
EverGrandeCity_HallOfFame_EventScript_27189A:: @ 827189A
EventScript_MoveMrBrineyToDewford:: @ 827189A
setflag FLAG_HIDE_ROUTE_108_MR_BRINEY
setflag FLAG_HIDE_ROUTE_109_MR_BRINEY_BOAT
setflag FLAG_HIDE_ROUTE_104_MR_BRINEY
@ -1192,7 +1192,7 @@ EverGrandeCity_HallOfFame_EventScript_27189A:: @ 827189A
clearflag FLAG_HIDE_MR_BRINEY_BOAT_DEWFORD_TOWN
end
EverGrandeCity_HallOfFame_EventScript_2718B3:: @ 82718B3
EventScript_MoveMrBrineyToRoute108:: @ 82718B3
setflag FLAG_HIDE_ROUTE_104_MR_BRINEY
setflag FLAG_HIDE_ROUTE_104_MR_BRINEY_BOAT
setflag FLAG_HIDE_BRINEYS_HOUSE_MR_BRINEY
@ -1610,7 +1610,7 @@ EventScript_271D5E:: @ 8271D5E
goto EventScript_271D89
EventScript_271D83:: @ 8271D83
special sub_80E6BE8
special EventScript_RecordMixingPlayerSpotTriggered
waitstate
lock
faceplayer

View File

@ -24,11 +24,11 @@ gUnref_82EC784:: @ 82EC784
.4byte 0x02000100
.4byte 0x08000400
gUnknown_82EC7C4:: @ 82EC7C4
.2byte 0x0100
.2byte 0x0200
.2byte 0x0400
.2byte 0x0800
gOverworldBackgroundLayerFlags:: @ 82EC7C4
.2byte 0x0100 /* BLDCNT_TGT2_BG0 */
.2byte 0x0200 /* BLDCNT_TGT2_BG1 */
.2byte 0x0400 /* BLDCNT_TGT2_BG2 */
.2byte 0x0800 /* BLDCNT_TGT2_BG3 */
gUnknown_82EC7CC:: @ 82EC7CC
.2byte 0x0001

View File

@ -52,7 +52,7 @@
"elevation": 3,
"var": "VAR_TEMP_0",
"var_value": 0,
"script": "gUnknown_08277388"
"script": "gEventScript_DoubleBattleColosseum_PlayerSpot0"
},
{
"type": "trigger",
@ -61,7 +61,7 @@
"elevation": 3,
"var": "VAR_TEMP_0",
"var_value": 0,
"script": "gUnknown_082773BE"
"script": "gEventScript_DoubleBattleColosseum_PlayerSpot2"
},
{
"type": "trigger",
@ -70,7 +70,7 @@
"elevation": 3,
"var": "VAR_TEMP_0",
"var_value": 0,
"script": "gUnknown_082773A3"
"script": "gEventScript_DoubleBattleColosseum_PlayerSpot1"
},
{
"type": "trigger",
@ -79,7 +79,7 @@
"elevation": 3,
"var": "VAR_TEMP_0",
"var_value": 0,
"script": "gUnknown_082773D9"
"script": "gEventScript_DoubleBattleColosseum_PlayerSpot3"
}
],
"bg_events": []

View File

@ -248,7 +248,7 @@ MossdeepCity_SpaceCenter_2F_EventScript_22400C:: @ 822400C
waitmovement 0
special SavePlayerParty
fadescreen 1
special sub_80F9438
special EventScript_ChooseHalfPartyForBattle
waitstate
compare VAR_RESULT, 0
goto_if_ne MossdeepCity_SpaceCenter_2F_EventScript_224032

View File

@ -66,7 +66,7 @@
"elevation": 3,
"var": "VAR_TEMP_0",
"var_value": 0,
"script": "gUnknown_0827741D"
"script": "gEventScript_RecordCenter_Spot0"
},
{
"type": "trigger",
@ -75,7 +75,7 @@
"elevation": 3,
"var": "VAR_TEMP_0",
"var_value": 0,
"script": "gUnknown_08277447"
"script": "gEventScript_RecordCenter_Spot2"
},
{
"type": "trigger",
@ -84,7 +84,7 @@
"elevation": 3,
"var": "VAR_TEMP_0",
"var_value": 0,
"script": "gUnknown_08277432"
"script": "gEventScript_RecordCenter_Spot1"
},
{
"type": "trigger",
@ -93,7 +93,7 @@
"elevation": 3,
"var": "VAR_TEMP_0",
"var_value": 0,
"script": "gUnknown_0827745C"
"script": "gEventScript_RecordCenter_Spot3"
}
],
"bg_events": []

View File

@ -52,7 +52,7 @@
"elevation": 3,
"var": "VAR_TEMP_0",
"var_value": 0,
"script": "gUnknown_08277374"
"script": "gEventScript_SingleBattleColosseum_PlayerSpot0"
},
{
"type": "trigger",
@ -61,7 +61,7 @@
"elevation": 3,
"var": "VAR_TEMP_0",
"var_value": 0,
"script": "gUnknown_0827737E"
"script": "gEventScript_SingleBattleColosseum_PlayerSpot1"
}
],
"bg_events": []

View File

@ -129,7 +129,7 @@ SootopolisCity_MysteryEventsHouse_1F_EventScript_227AE2:: @ 8227AE2
SootopolisCity_MysteryEventsHouse_1F_EventScript_227AEF:: @ 8227AEF
msgbox SootopolisCity_MysteryEventsHouse_1F_Text_227C84, MSGBOX_DEFAULT
fadescreen 1
special sub_80F9438
special EventScript_ChooseHalfPartyForBattle
waitstate
return

View File

@ -46,22 +46,24 @@
],
"coord_events": [
{
"comment": "This is trade seat #1.",
"type": "trigger",
"x": 4,
"y": 5,
"elevation": 3,
"var": "VAR_TEMP_0",
"var_value": 0,
"script": "gUnknown_082773F5"
"script": "gEventScript_TradeCenter_Chair0"
},
{
"comment": "This is trade seat #2.",
"type": "trigger",
"x": 7,
"y": 5,
"elevation": 3,
"var": "VAR_TEMP_0",
"var_value": 0,
"script": "gUnknown_082773FF"
"script": "gEventScript_TradeCenter_Chair1"
}
],
"bg_events": []

View File

@ -791,116 +791,118 @@ EventScript_CableBoxResults:: @ 8277365
releaseall
end
gUnknown_08277374:: @ 8277374
gEventScript_SingleBattleColosseum_PlayerSpot0:: @ 8277374
setvar VAR_0x8005, 0
special sub_80B3968
special EventScript_ColosseumPlayerSpotTriggered
waitstate
end
gUnknown_0827737E:: @ 827737E
gEventScript_SingleBattleColosseum_PlayerSpot1:: @ 827737E
setvar VAR_0x8005, 1
special sub_80B3968
special EventScript_ColosseumPlayerSpotTriggered
waitstate
end
gUnknown_08277388:: @ 8277388
gEventScript_DoubleBattleColosseum_PlayerSpot0:: @ 8277388
fadescreen 1
special sub_80F9438
special EventScript_ChooseHalfPartyForBattle
waitstate
compare VAR_RESULT, 0
goto_if_eq DoubleBattleColosseum_EventScript_2773F4
goto_if_eq gEventScript_DoubleBattleColosseum_CancelSpotTrigger
setvar VAR_0x8005, 0
special sub_80B3968
special EventScript_ColosseumPlayerSpotTriggered
waitstate
end
gUnknown_082773A3:: @ 82773A3
gEventScript_DoubleBattleColosseum_PlayerSpot1:: @ 82773A3
fadescreen 1
special sub_80F9438
special EventScript_ChooseHalfPartyForBattle
waitstate
compare VAR_RESULT, 0
goto_if_eq DoubleBattleColosseum_EventScript_2773F4
goto_if_eq gEventScript_DoubleBattleColosseum_CancelSpotTrigger
setvar VAR_0x8005, 1
special sub_80B3968
special EventScript_ColosseumPlayerSpotTriggered
waitstate
end
gUnknown_082773BE:: @ 82773BE
gEventScript_DoubleBattleColosseum_PlayerSpot2:: @ 82773BE
fadescreen 1
special sub_80F9438
special EventScript_ChooseHalfPartyForBattle
waitstate
compare VAR_RESULT, 0
goto_if_eq DoubleBattleColosseum_EventScript_2773F4
goto_if_eq gEventScript_DoubleBattleColosseum_CancelSpotTrigger
setvar VAR_0x8005, 2
special sub_80B3968
special EventScript_ColosseumPlayerSpotTriggered
waitstate
end
gUnknown_082773D9:: @ 82773D9
gEventScript_DoubleBattleColosseum_PlayerSpot3:: @ 82773D9
fadescreen 1
special sub_80F9438
special EventScript_ChooseHalfPartyForBattle
waitstate
compare VAR_RESULT, 0
goto_if_eq DoubleBattleColosseum_EventScript_2773F4
goto_if_eq gEventScript_DoubleBattleColosseum_CancelSpotTrigger
setvar VAR_0x8005, 3
special sub_80B3968
special EventScript_ColosseumPlayerSpotTriggered
waitstate
end
DoubleBattleColosseum_EventScript_2773F4:: @ 82773F4
gEventScript_DoubleBattleColosseum_CancelSpotTrigger:: @ 82773F4
end
gUnknown_082773F5:: @ 82773F5
gEventScript_TradeCenter_Chair0:: @ 82773F5
setvar VAR_0x8005, 0
special sub_80B3924
special EventScript_PlayerEnteredTradeSeat
waitstate
end
gUnknown_082773FF:: @ 82773FF
gEventScript_TradeCenter_Chair1:: @ 82773FF
setvar VAR_0x8005, 1
special sub_80B3924
special EventScript_PlayerEnteredTradeSeat
waitstate
end
gUnknown_08277409:: @ 8277409
/* Never used */
gEventScript_TradeCenter_Chair2:: @ 8277409
setvar VAR_0x8005, 2
special sub_80B3924
special EventScript_PlayerEnteredTradeSeat
waitstate
end
gUnknown_08277413:: @ 8277413
/* Never used */
gEventScript_TradeCenter_Chair3:: @ 8277413
setvar VAR_0x8005, 3
special sub_80B3924
special EventScript_PlayerEnteredTradeSeat
waitstate
end
gUnknown_0827741D:: @ 827741D
gEventScript_RecordCenter_Spot0:: @ 827741D
setvar VAR_0x8005, 0
special sub_80E6BE8
special EventScript_RecordMixingPlayerSpotTriggered
waitstate
compare VAR_TEMP_1, 0
goto_if_ne RecordCorner_EventScript_277471
end
gUnknown_08277432:: @ 8277432
gEventScript_RecordCenter_Spot1:: @ 8277432
setvar VAR_0x8005, 1
special sub_80E6BE8
special EventScript_RecordMixingPlayerSpotTriggered
waitstate
compare VAR_TEMP_1, 0
goto_if_ne RecordCorner_EventScript_277471
end
gUnknown_08277447:: @ 8277447
gEventScript_RecordCenter_Spot2:: @ 8277447
setvar VAR_0x8005, 2
special sub_80E6BE8
special EventScript_RecordMixingPlayerSpotTriggered
waitstate
compare VAR_TEMP_1, 0
goto_if_ne RecordCorner_EventScript_277471
end
gUnknown_0827745C:: @ 827745C
gEventScript_RecordCenter_Spot3:: @ 827745C
setvar VAR_0x8005, 3
special sub_80E6BE8
special EventScript_RecordMixingPlayerSpotTriggered
waitstate
compare VAR_TEMP_1, 0
goto_if_ne RecordCorner_EventScript_277471
@ -914,21 +916,21 @@ RecordCorner_EventScript_277471:: @ 8277471
releaseall
end
EventScript_TradeRoom_ReadTrainerCard_NoColor:: @ 827747E
gEventScript_TradeRoom_ReadTrainerCard_NoColor:: @ 827747E
msgbox Text_278452, MSGBOX_DEFAULT
fadescreen 1
special sp02A_crash_sound
waitstate
end
EventScript_TradeRoom_ReadTrainerCard_Normal:: @ 827748D
gEventScript_TradeRoom_ReadTrainerCard_Normal:: @ 827748D
msgbox Text_27847B, MSGBOX_DEFAULT
fadescreen 1
special sp02A_crash_sound
waitstate
end
EventScript_TradeRoom_TooBusyToNotice:: @ 827749C
gEventScript_TradeRoom_TooBusyToNotice:: @ 827749C
msgbox Text_27842E, MSGBOX_DEFAULT
closemessage
end
@ -968,21 +970,21 @@ RecordCorner_EventScript_2774E0:: @ 82774E0
end
gEventScript_ConfirmLeaveTradeRoom:: @ 82774EF
msgbox Text_2783A8, MSGBOX_YESNO
msgbox Text_TerminateLinkConfirmation, MSGBOX_YESNO
compare VAR_RESULT, 1
goto_if_eq gUnknown_08277509
goto_if_eq gEventScript_TerminateLink
erasebox 0, 0, 29, 19
releaseall
end
gUnknown_08277509:: @ 8277509
messageautoscroll Text_2783E9
gEventScript_TerminateLink:: @ 8277509
messageautoscroll Text_TerminateLinkPleaseWait
waitmessage
special sub_80B371C
special EventScript_ExitLinkRoom
end
EventScript_277513:: @ 8277513
special sub_80B36EC
gEventScript_DoLinkRoomExit:: @ 8277513
special EventScript_CleanupLinkRoomState
special sub_80AF9F8
waitstate
end
@ -1736,11 +1738,11 @@ OldaleTown_PokemonCenter_2F_Text_278372: @ 8278372
.string "Please confirm the number of\n"
.string "players and start again.$"
Text_2783A8: @ 82783A8
Text_TerminateLinkConfirmation: @ 82783A8
.string "The link will be terminated if you\n"
.string "leave the room. Is that okay?$"
Text_2783E9: @ 82783E9
Text_TerminateLinkPleaseWait: @ 82783E9
.string "Terminating link…\n"
.string "You will be escorted out of\l"
.string "the room. Please wait.$"

View File

@ -12,8 +12,8 @@ gSpecials:: @ 81DBA64
def_special SetCableClubWarp
def_special sub_80AF948
def_special sub_80AF9F8
def_special sub_80B36EC
def_special sub_80B371C
def_special EventScript_CleanupLinkRoomState
def_special EventScript_ExitLinkRoom
def_special sub_80E8E18
def_special sub_80E8BC8
def_special sub_80E9068
@ -35,14 +35,14 @@ gSpecials:: @ 81DBA64
def_special sub_80E91F8
def_special sub_80EA30C
def_special DoSecretBasePCTurnOffEffect
def_special sub_80E6BE8
def_special EventScript_RecordMixingPlayerSpotTriggered
def_special sub_80B2DA4
def_special sub_80B2E4C
def_special sub_80B2E74
def_special sub_80B2EA8
def_special CloseLink
def_special sub_80B3968
def_special sub_80B3924
def_special EventScript_ColosseumPlayerSpotTriggered
def_special EventScript_PlayerEnteredTradeSeat
def_special nullsub_37
def_special sub_80B3254
def_special sub_80B2FD8
@ -50,7 +50,7 @@ gSpecials:: @ 81DBA64
def_special SpawnLinkPartnerEventObject
def_special SavePlayerParty
def_special LoadPlayerParty
def_special sub_80F9438
def_special EventScript_ChooseHalfPartyForBattle
def_special sp02A_crash_sound
def_special EventObjectInteractionGetBerryTreeData
def_special EventObjectInteractionGetBerryName

View File

@ -10,6 +10,8 @@
#define FRONTIER_FACILITY_PIKE 5
#define FRONTIER_FACILITY_PYRAMID 6
#define NUM_FRONTIER_FACILITIES 7
// The multiplayer battle colosseum rooms re-use VAR_FRONTIER_FACILITY.
#define FRONTIER_FACILITY_DOUBLE_COLOSSEUM 9
#define TENT_VERDANTURF 2
#define TENT_FALLARBOR 3

View File

@ -244,7 +244,7 @@ bool8 IsLinkTaskFinished(void);
void CreateWirelessStatusIndicatorSprite(u8, u8);
void sub_800ADF8(void);
void sub_800B488(void);
void sub_800A620(void);
void CheckShouldAdvanceLinkState(void);
void sub_8011BD0(void);
u8 IsLinkMaster(void);
void sub_800AC34(void);
@ -299,8 +299,8 @@ extern struct LinkPlayer gLocalLinkPlayer;
bool32 Link_AnyPartnersPlayingRubyOrSapphire(void);
bool32 sub_800A03C(void);
void sub_8009628(u8);
u8 sub_800AA48(void);
void SetLocalLinkPlayerId(u8);
u8 GetSavedPlayerCount(void);
void sub_8009FAC(void);
bool8 sub_800A4D8(u8 a0);
u8 sub_800A9D8(void);

View File

@ -8,11 +8,22 @@
#define LINK_KEY_CODE_DPAD_LEFT 0x14
#define LINK_KEY_CODE_DPAD_RIGHT 0x15
#define LINK_KEY_CODE_UNK_2 0x16
#define LINK_KEY_CODE_UNK_3 0x17
#define LINK_KEY_CODE_EXIT_ROOM 0x17
#define LINK_KEY_CODE_START_BUTTON 0x18
#define LINK_KEY_CODE_A_BUTTON 0x19
#define LINK_KEY_CODE_UNK_4 0x1A // I'd guess this is the B button?
// These two are a hack to stop user input until link stuff can be
// resolved.
#define LINK_KEY_CODE_HANDLE_RECV_QUEUE 0x1B
#define LINK_KEY_CODE_HANDLE_SEND_QUEUE 0x1C
#define LINK_KEY_CODE_UNK_7 0x1D
#define LINK_KEY_CODE_UNK_8 0x1E
#define MOVEMENT_MODE_FREE 0
#define MOVEMENT_MODE_FROZEN 1
#define MOVEMENT_MODE_SCRIPTED 2
struct InitialPlayerAvatarState
{
u8 transitionFlags;
@ -24,7 +35,7 @@ struct LinkPlayerEventObject
u8 active;
u8 linkPlayerId;
u8 eventObjId;
u8 mode;
u8 movementMode;
};
// Exported RAM declarations
@ -120,7 +131,7 @@ void CB1_Overworld(void);
void CB2_OverworldBasic(void);
void CB2_Overworld(void);
void SetMainCallback1(void (*cb)(void));
void sub_8085E94(void *a0);
void SetUnusedCallback(void *a0);
void CB2_NewGame(void);
void CB2_WhiteOut(void);
void CB2_LoadMap(void);
@ -140,7 +151,7 @@ u32 sub_8087214(void);
bool32 sub_808727C(void);
u16 sub_8087288(void);
u16 sub_808729C(void);
u16 sub_80872B0(void);
u16 QueueExitLinkRoomKey(void);
u16 sub_80872C4(void);
bool32 sub_8087598(void);
bool32 sub_80875C8(void);

View File

@ -85,7 +85,7 @@ u8 GetItemEffectType(u16 item);
void CB2_PartyMenuFromStartMenu(void);
void sub_81B7F60(void);
void sub_81B8448(void);
void sub_81B8518(u8 unused);
void InitChooseHalfPartyForBattle(u8 unused);
void sub_81B8558(void);
void sub_81B8904(u8 initArg, MainCallback callback);
void sub_81B892C(void);

View File

@ -7,7 +7,7 @@ struct PlayerHallRecords
struct RankingHall2P twoPlayers[2];
};
void sub_80E6BE8(void);
void EventScript_RecordMixingPlayerSpotTriggered(void);
void GetPlayerHallRecords(struct PlayerHallRecords *dst);
#endif //GUARD_RECORD_MIXING_H

View File

@ -83,13 +83,11 @@ bool8 sub_8153380(void);
bool8 sub_81533AC(void);
u8 sub_81533E0(void);
u8 sub_8153408(void);
u8 sub_8153430(void);
bool8 sub_8153474(void);
u8 FullSaveGame(void); //FullSaveGame
bool8 CheckSaveFile(void); //CheckSaveFile
u8 Save_LoadGameData(u8 a1);
u16 sub_815355C(void);
u8 sub_81534D0(u8);
u8 sub_8153430(void);
bool8 sub_8153474(void);
u32 TryCopySpecialSaveSection(u8 sector, u8* dst);
u32 sub_8153634(u8 sector, u8* src);
void sub_8153688(u8 taskId);

View File

@ -767,7 +767,7 @@ static void Task_HandleSendLinkBuffersData(u8 taskId)
{
if (IsLinkMaster())
{
sub_800A620();
CheckShouldAdvanceLinkState();
gTasks[taskId].data[11]++;
}
else

View File

@ -146,8 +146,8 @@ 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 FullSaveGame(void);
extern bool8 CheckSaveFile(void);
extern void sub_80EECEC(void);
// this file's functions
@ -2600,7 +2600,7 @@ static bool8 LinkPlayAgainHandleSaving(void)
}
break;
case 2:
sub_8153430();
FullSaveGame();
sBerryBlenderData->field_1A0++;
sBerryBlenderData->framesToWait = 0;
break;
@ -2614,7 +2614,7 @@ static bool8 LinkPlayAgainHandleSaving(void)
case 4:
if (IsLinkTaskFinished())
{
if (sub_8153474())
if (CheckSaveFile())
{
sBerryBlenderData->field_1A0 = 5;
}

View File

@ -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;
}
@ -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;
}
}
@ -999,7 +999,7 @@ void sub_80B360C(void)
SetMainCallback2(sub_80A0514);
}
void sub_80B36EC(void)
void EventScript_CleanupLinkRoomState(void)
{
if (gSpecialVar_0x8004 == 1 || gSpecialVar_0x8004 == 2 || gSpecialVar_0x8004 == 5 || gSpecialVar_0x8004 == 9)
{
@ -1009,11 +1009,13 @@ void sub_80B36EC(void)
SetWarpDestinationToDynamicWarp(0x7F);
}
void sub_80B371C(void)
void EventScript_ExitLinkRoom(void)
{
sub_80872B0();
QueueExitLinkRoomKey();
}
// I can't find anything that would set data[0] to a value before this
// stask starts. Is it a bug?
static void sub_80B3728(u8 taskId)
{
struct Task* task = &gTasks[taskId];
@ -1028,7 +1030,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 +1132,8 @@ static void sub_80B3894(u8 taskId)
}
}
void sub_80B3924(void)
// Note: VAR_0x8005 is set to the ID of the trade seat.
void EventScript_PlayerEnteredTradeSeat(void)
{
if (gWirelessCommType != 0)
{
@ -1152,7 +1155,8 @@ void nullsub_37(void)
}
void sub_80B3968(void)
// Note: VAR_0x8005 is set to the ID of the player spot.
void EventScript_ColosseumPlayerSpotTriggered(void)
{
gLinkType = 0x2211;
@ -1166,6 +1170,7 @@ void sub_80B3968(void)
}
}
// This function is never called.
static void sub_80B39A4(void)
{
u8 taskId = CreateTask(sub_80B3728, 80);
@ -1265,13 +1270,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]++;
}
}

View File

@ -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)

View File

@ -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)
@ -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;
}

View File

@ -3788,10 +3788,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)

View File

@ -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);

View File

@ -66,48 +66,47 @@
#include "constants/species.h"
#include "constants/weather.h"
// These two are a hack to stop user input until link stuff can be
// resolved.
#define LINK_KEY_CODE_HANDLE_RECV_QUEUE 0x1B
#define LINK_KEY_CODE_HANDLE_SEND_QUEUE 0x1C
#define LINK_KEY_CODE_UNK_7 0x1D
#define LINK_KEY_CODE_UNK_8 0x1E
#define PLAYER_TRADING_STATE_IDLE 0x80
#define PLAYER_TRADING_STATE_BUSY 0x81
#define PLAYER_TRADING_STATE_UNK_2 0x82
#define PLAYER_TRADING_STATE_UNK_3 0x83
#define PLAYER_TRADING_STATE_EXITING_ROOM 0x83
#define EVENT_SCRIPT_NONE 0
#define EVENT_SCRIPT_ID_9 9
#define EVENT_SCRIPT_ID_10 10
#define FACING_NONE 0
#define FACING_UP 1
#define FACING_DOWN 2
#define FACING_LEFT 3
#define FACING_RIGHT 4
#define FACING_FORCED_UP 7
#define FACING_FORCED_DOWN 8
#define FACING_FORCED_LEFT 9
#define FACING_FORCED_RIGHT 10
// event scripts
extern const u8 EventScript_WhiteOut[];
extern const u8 EventScript_271862[];
extern const u8 EventScript_277513[];
extern const u8 EventScript_TradeRoom_TooBusyToNotice[];
extern const u8 EventScript_TradeRoom_ReadTrainerCard_NoColor[];
extern const u8 EventScript_TradeRoom_ReadTrainerCard_Normal[];
extern const u8 gUnknown_08277388[];
extern const u8 gUnknown_082773A3[];
extern const u8 gUnknown_082773BE[];
extern const u8 gUnknown_082773D9[];
extern const u8 gUnknown_0827741D[];
extern const u8 gUnknown_08277432[];
extern const u8 gUnknown_08277447[];
extern const u8 gUnknown_0827745C[];
extern const u8 gUnknown_08277374[];
extern const u8 gUnknown_0827737E[];
extern const u8 gUnknown_082773FF[];
extern const u8 gUnknown_082773F5[];
extern const u8 gEventScript_WhiteOut[];
extern const u8 gEventScript_ResetMrBriney[];
extern const u8 gEventScript_DoLinkRoomExit[];
extern const u8 gEventScript_TradeRoom_TooBusyToNotice[];
extern const u8 gEventScript_TradeRoom_ReadTrainerCard_NoColor[];
extern const u8 gEventScript_TradeRoom_ReadTrainerCard_Normal[];
extern const u8 gEventScript_DoubleBattleColosseum_PlayerSpot0[];
extern const u8 gEventScript_DoubleBattleColosseum_PlayerSpot1[];
extern const u8 gEventScript_DoubleBattleColosseum_PlayerSpot2[];
extern const u8 gEventScript_DoubleBattleColosseum_PlayerSpot3[];
extern const u8 gEventScript_RecordCenter_Spot0[];
extern const u8 gEventScript_RecordCenter_Spot1[];
extern const u8 gEventScript_RecordCenter_Spot2[];
extern const u8 gEventScript_RecordCenter_Spot3[];
extern const u8 gEventScript_SingleBattleColosseum_PlayerSpot0[];
extern const u8 gEventScript_SingleBattleColosseum_PlayerSpot1[];
extern const u8 gEventScript_TradeCenter_Chair1[];
extern const u8 gEventScript_TradeCenter_Chair0[];
extern const u8 gEventScript_ConfirmLeaveTradeRoom[];
extern const u8 gUnknown_08277509[];
extern const u8 gEventScript_TerminateLink[];
extern const struct MapLayout *const gMapLayouts[];
extern const struct MapHeader *const *const gMapGroups[];
extern const int gMaxFlashLevel;
extern const u16 gUnknown_82EC7C4[];
extern const u16 gOverworldBackgroundLayerFlags[];
static void Overworld_ResetStateAfterWhiteOut(void);
static void c2_80567AC(void);
@ -123,7 +122,7 @@ static bool32 map_loading_iteration_2_link(u8 *state);
static void mli4_mapscripts_and_other(void);
static void InitOverworldGraphicsRegisters(void);
static u8 GetSpriteForLinkedPlayer(u8);
static u16 sub_80871C0(u32 a1);
static u16 KeyInterCB_SendNothing(u32 a1);
static void sub_80867C8(void);
static void sub_80867D8(void);
static void sub_8086AE4(void);
@ -140,7 +139,7 @@ static void ClearAllPlayerKeys(void);
static void ResetAllTradingStates(void);
static void UpdateHeldKeyCode(u16);
static void UpdateAllLinkPlayers(u16*, s32);
static u8 npc_something3(u8 a1, u8 a2);
static u8 FlipVerticalAndClearForced(u8 a1, u8 a2);
static u8 LinkPlayerDetectCollision(u8 selfEventObjId, u8 a2, s16 x, s16 y);
static void CreateLinkPlayerSprite(u8 linkPlayerId, u8 gameVersion);
static void GetLinkPlayerCoords(u8 linkPlayerId, u16 *x, u16 *y);
@ -148,7 +147,7 @@ static u8 GetLinkPlayerFacingDirection(u8 linkPlayerId);
static u8 GetLinkPlayerElevation(u8 linkPlayerId);
static s32 sub_80878E4(u8 linkPlayerId);
static u8 GetLinkPlayerIdAt(s16 x, s16 y);
static void RunPlayerEventScript(u8 linkPlayerId, u8 a2);
static void SetPlayerFacingDirection(u8 linkPlayerId, u8 a2);
static void ZeroEventObject(struct EventObject *eventObj);
static void SpawnLinkPlayerEventObject(u8 linkPlayerId, s16 x, s16 y, u8 a4);
static void InitLinkPlayerEventObjectPos(struct EventObject *eventObj, s16 x, s16 y);
@ -159,7 +158,7 @@ static void sub_8087584(void);
static u32 GetLinkSendQueueLength(void);
static void ZeroLinkPlayerEventObject(struct LinkPlayerEventObject *linkPlayerEventObj);
static const u8 *TryInteractWithPlayer(struct TradeRoomPlayer *a1);
static u16 GetTypeForTileEventScript(const u8 *script);
static u16 GetDirectionForEventScript(const u8 *script);
static void sub_8087510(void);
static void InitLinkRoomStartMenuScript(void);
static void sub_8087530(const u8 *script);
@ -176,7 +175,7 @@ static u16 KeyInterCB_DeferToSendQueue(u32);
static void ResetPlayerHeldKeys(u16 *a1);
static u16 KeyInterCB_SelfIdle(u32 a1);
static u16 KeyInterCB_DeferToEventScript(u32 a1);
static u16 sub_8087068(u16 a1);
static u16 GetDirectionForDpadKey(u16 a1);
static void CB1_UpdateLinkState(void);
static void SetKeyInterceptCallback(u16 (*func)(u32));
static void SetFieldVBlankCallback(void);
@ -187,7 +186,7 @@ static u8 GetAdjustedInitialDirection(struct InitialPlayerAvatarState *playerStr
static u16 GetCenterScreenMetatileBehavior(void);
// IWRAM bss vars
IWRAM_DATA static void *sUnknown_03000E0C;
IWRAM_DATA static void *sUnusedCallback;
IWRAM_DATA static u8 sPlayerTradingStates[4];
// This callback is called with a player's key code. It then returns an
// adjusted key code, effectively intercepting the input before anything
@ -338,49 +337,53 @@ static const struct ScanlineEffectParams sFlashEffectParams =
0,
};
static u8 sub_80879D8(struct LinkPlayerEventObject *, struct EventObject *, u8);
static u8 sub_80879F8(struct LinkPlayerEventObject *, struct EventObject *, u8);
static u8 sub_80879FC(struct LinkPlayerEventObject *, struct EventObject *, u8);
static u8 MovementEventModeCB_Normal(struct LinkPlayerEventObject *, struct EventObject *, u8);
static u8 MovementEventModeCB_Ignored(struct LinkPlayerEventObject *, struct EventObject *, u8);
static u8 MovementEventModeCB_Normal_2(struct LinkPlayerEventObject *, struct EventObject *, u8);
static u8 (*const gLinkPlayerEventModes[])(struct LinkPlayerEventObject *, struct EventObject *, u8) =
static u8 (*const gLinkPlayerMovementModes[])(struct LinkPlayerEventObject *, struct EventObject *, u8) =
{
sub_80879D8,
sub_80879F8,
sub_80879FC,
MovementEventModeCB_Normal, // MOVEMENT_MODE_FREE
MovementEventModeCB_Ignored, // MOVEMENT_MODE_FROZEN
MovementEventModeCB_Normal_2, // MOVEMENT_MODE_SCRIPTED
};
static u8 sub_8087A1C(struct LinkPlayerEventObject *, struct EventObject *, u8);
static u8 sub_8087A20(struct LinkPlayerEventObject *, struct EventObject *, u8);
static u8 sub_8087A88(struct LinkPlayerEventObject *, struct EventObject *, u8);
static u8 FacingHandler_DoNothing(struct LinkPlayerEventObject *, struct EventObject *, u8);
static u8 FacingHandler_DpadMovement(struct LinkPlayerEventObject *, struct EventObject *, u8);
static u8 FacingHandler_ForcedFacingChange(struct LinkPlayerEventObject *, struct EventObject *, u8);
static u8 (*const gUnknown_08339DD4[])(struct LinkPlayerEventObject *, struct EventObject *, u8) =
// These handlers return TRUE if the movement was scripted and successful, and FALSE otherwise.
static bool8 (*const gLinkPlayerFacingHandlers[])(struct LinkPlayerEventObject *, struct EventObject *, u8) =
{
sub_8087A1C,
sub_8087A20,
sub_8087A20,
sub_8087A20,
sub_8087A20,
sub_8087A1C,
sub_8087A1C,
sub_8087A88,
sub_8087A88,
sub_8087A88,
sub_8087A88,
FacingHandler_DoNothing,
FacingHandler_DpadMovement,
FacingHandler_DpadMovement,
FacingHandler_DpadMovement,
FacingHandler_DpadMovement,
FacingHandler_DoNothing,
FacingHandler_DoNothing,
FacingHandler_ForcedFacingChange,
FacingHandler_ForcedFacingChange,
FacingHandler_ForcedFacingChange,
FacingHandler_ForcedFacingChange,
};
static void sub_8087AA0(struct LinkPlayerEventObject *, struct EventObject *);
static void sub_8087AA8(struct LinkPlayerEventObject *, struct EventObject *);
static void MovementStatusHandler_EnterFreeMode(struct LinkPlayerEventObject *, struct EventObject *);
static void MovementStatusHandler_TryAdvanceScript(struct LinkPlayerEventObject *, struct EventObject *);
static void (*const gUnknown_08339E00[])(struct LinkPlayerEventObject *, struct EventObject *) =
// These handlers are run after an attempted movement.
static void (*const gMovementStatusHandler[])(struct LinkPlayerEventObject *, struct EventObject *) =
{
sub_8087AA0,
sub_8087AA8,
// FALSE:
MovementStatusHandler_EnterFreeMode,
// TRUE:
MovementStatusHandler_TryAdvanceScript,
};
// code
void DoWhiteOut(void)
{
ScriptContext2_RunNewScript(EventScript_WhiteOut);
ScriptContext2_RunNewScript(gEventScript_WhiteOut);
SetMoney(&gSaveBlock1Ptr->money, GetMoney(&gSaveBlock1Ptr->money) / 2);
HealPlayerParty();
Overworld_ResetStateAfterWhiteOut();
@ -406,7 +409,7 @@ void Overworld_ResetStateAfterTeleport(void)
FlagClear(FLAG_SYS_SAFARI_MODE);
FlagClear(FLAG_SYS_USE_STRENGTH);
FlagClear(FLAG_SYS_USE_FLASH);
ScriptContext2_RunNewScript(EventScript_271862);
ScriptContext2_RunNewScript(gEventScript_ResetMrBriney);
}
void Overworld_ResetStateAfterDigEscRope(void)
@ -1495,9 +1498,10 @@ void SetMainCallback1(MainCallback cb)
gMain.callback1 = cb;
}
void sub_8085E94(void *a0)
// This function is never called.
void SetUnusedCallback(void *func)
{
sUnknown_03000E0C = a0;
sUnusedCallback = func;
}
static bool8 map_post_load_hook_exec(void)
@ -2102,7 +2106,7 @@ static void InitOverworldGraphicsRegisters(void)
SetGpuReg(REG_OFFSET_WIN0V, 0xFF);
SetGpuReg(REG_OFFSET_WIN1H, 0xFFFF);
SetGpuReg(REG_OFFSET_WIN1V, 0xFFFF);
SetGpuReg(REG_OFFSET_BLDCNT, gUnknown_82EC7C4[1] | gUnknown_82EC7C4[2] | gUnknown_82EC7C4[3]
SetGpuReg(REG_OFFSET_BLDCNT, gOverworldBackgroundLayerFlags[1] | gOverworldBackgroundLayerFlags[2] | gOverworldBackgroundLayerFlags[3]
| BLDCNT_TGT2_OBJ | BLDCNT_EFFECT_BLEND);
SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(13, 7));
InitOverworldBgs();
@ -2249,6 +2253,9 @@ static void CB1_UpdateLinkState(void)
// UpdateHeldKeyCode performs a sanity check on its input; if
// sPlayerKeyInterceptCallback echoes back the argument, which is selfId, then
// it'll use LINK_KEY_CODE_EMPTY instead.
//
// Note 2: There are some key intercept callbacks that treat the key as a player
// ID. It's so hacky.
UpdateHeldKeyCode(sPlayerKeyInterceptCallback(selfId));
ClearAllPlayerKeys();
}
@ -2311,7 +2318,7 @@ static bool32 AreAnyPlayersInState(u16 tradingState)
return FALSE;
}
static void HandleLinkPlayerKeyInput(u32 playerId, u16 key, struct TradeRoomPlayer *trainer, u16 *eventScriptType)
static void HandleLinkPlayerKeyInput(u32 playerId, u16 key, struct TradeRoomPlayer *trainer, u16 *forceFacing)
{
const u8 *script;
@ -2320,7 +2327,7 @@ static void HandleLinkPlayerKeyInput(u32 playerId, u16 key, struct TradeRoomPlay
script = TryGetTileEventScript(trainer);
if (script)
{
*eventScriptType = GetTypeForTileEventScript(script);
*forceFacing = GetDirectionForEventScript(script);
sPlayerTradingStates[playerId] = PLAYER_TRADING_STATE_BUSY;
if (trainer->isSelf)
{
@ -2329,7 +2336,7 @@ static void HandleLinkPlayerKeyInput(u32 playerId, u16 key, struct TradeRoomPlay
}
return;
}
if (AreAnyPlayersInState(PLAYER_TRADING_STATE_UNK_3) == TRUE)
if (AreAnyPlayersInState(PLAYER_TRADING_STATE_EXITING_ROOM) == TRUE)
{
sPlayerTradingStates[playerId] = PLAYER_TRADING_STATE_BUSY;
if (trainer->isSelf)
@ -2403,8 +2410,8 @@ static void HandleLinkPlayerKeyInput(u32 playerId, u16 key, struct TradeRoomPlay
switch (key)
{
case LINK_KEY_CODE_UNK_3:
sPlayerTradingStates[playerId] = PLAYER_TRADING_STATE_UNK_3;
case LINK_KEY_CODE_EXIT_ROOM:
sPlayerTradingStates[playerId] = PLAYER_TRADING_STATE_EXITING_ROOM;
break;
case LINK_KEY_CODE_UNK_2:
sPlayerTradingStates[playerId] = PLAYER_TRADING_STATE_UNK_2;
@ -2429,12 +2436,12 @@ static void UpdateAllLinkPlayers(u16 *keys, s32 selfId)
for (i = 0; i < 4; i++)
{
u8 key = keys[i];
u16 eventScriptType = EVENT_SCRIPT_NONE;
u16 setFacing = FACING_NONE;
LoadTradeRoomPlayer(i, selfId, &trainer);
HandleLinkPlayerKeyInput(i, key, &trainer, &eventScriptType);
HandleLinkPlayerKeyInput(i, key, &trainer, &setFacing);
if (sPlayerTradingStates[i] == PLAYER_TRADING_STATE_IDLE)
eventScriptType = sub_8087068(key);
RunPlayerEventScript(i, eventScriptType);
setFacing = GetDirectionForDpadKey(key);
SetPlayerFacingDirection(i, setFacing);
}
}
@ -2483,20 +2490,20 @@ static u16 KeyInterCB_ReadButtons(u32 key)
return LINK_KEY_CODE_EMPTY;
}
static u16 sub_8087068(u16 a1)
static u16 GetDirectionForDpadKey(u16 a1)
{
switch (a1)
{
case LINK_KEY_CODE_DPAD_RIGHT:
return 4;
return FACING_RIGHT;
case LINK_KEY_CODE_DPAD_LEFT:
return 3;
return FACING_LEFT;
case LINK_KEY_CODE_DPAD_UP:
return 1;
return FACING_UP;
case LINK_KEY_CODE_DPAD_DOWN:
return 2;
return FACING_DOWN;
default:
return 0;
return FACING_NONE;
}
}
@ -2577,19 +2584,19 @@ static u16 KeyInterCB_DeferToSendQueue(u32 key)
return retVal;
}
static u16 sub_8087164(u32 key)
static u16 KeyInterCB_DoNothingAndKeepAlive(u32 key)
{
CheckRfuKeepAliveTimer();
return LINK_KEY_CODE_EMPTY;
}
static u16 sub_8087170(u32 linkPlayerId)
static u16 sub_8087170(u32 keyOrPlayerId)
{
if (sPlayerTradingStates[linkPlayerId] == PLAYER_TRADING_STATE_UNK_2)
if (sPlayerTradingStates[keyOrPlayerId] == PLAYER_TRADING_STATE_UNK_2)
{
if (gMain.newKeys & B_BUTTON)
{
SetKeyInterceptCallback(sub_8087164);
SetKeyInterceptCallback(KeyInterCB_DoNothingAndKeepAlive);
return LINK_KEY_CODE_UNK_7;
}
else
@ -2610,41 +2617,45 @@ static u16 sub_80871AC(u32 a1)
return LINK_KEY_CODE_UNK_2;
}
static u16 sub_80871C0(u32 a1)
static u16 KeyInterCB_SendNothing(u32 key)
{
return LINK_KEY_CODE_EMPTY;
}
static u16 sub_80871C4(u32 a1)
static u16 KeyInterCB_WaitForPlayersToExit(u32 keyOrPlayerId)
{
if (sPlayerTradingStates[a1] != PLAYER_TRADING_STATE_UNK_3)
// 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
// CB1_UpdateLinkState.
if (sPlayerTradingStates[keyOrPlayerId] != PLAYER_TRADING_STATE_EXITING_ROOM)
CheckRfuKeepAliveTimer();
if (AreAllPlayersInState(PLAYER_TRADING_STATE_UNK_3) == TRUE)
if (AreAllPlayersInState(PLAYER_TRADING_STATE_EXITING_ROOM) == TRUE)
{
ScriptContext1_SetupScript(EventScript_277513);
SetKeyInterceptCallback(sub_80871C0);
ScriptContext1_SetupScript(gEventScript_DoLinkRoomExit);
SetKeyInterceptCallback(KeyInterCB_SendNothing);
}
return LINK_KEY_CODE_EMPTY;
}
static u16 sub_80871FC(u32 a1)
static u16 KeyInterCB_SendExitRoomKey(u32 key)
{
SetKeyInterceptCallback(sub_80871C4);
return 23;
SetKeyInterceptCallback(KeyInterCB_WaitForPlayersToExit);
return LINK_KEY_CODE_EXIT_ROOM;
}
static u16 sub_8087210(u32 a1)
// Duplicate function.
static u16 KeyInterCB_SendNothing_2(u32 key)
{
return LINK_KEY_CODE_EMPTY;
}
u32 sub_8087214(void)
{
if (AreAnyPlayersInState(PLAYER_TRADING_STATE_UNK_3) == TRUE)
if (AreAnyPlayersInState(PLAYER_TRADING_STATE_EXITING_ROOM) == TRUE)
return 2;
if (sPlayerKeyInterceptCallback == sub_8087170 && sPlayerTradingStates[gLinkSelfPlayerId] != PLAYER_TRADING_STATE_UNK_2)
return 0;
if (sPlayerKeyInterceptCallback == sub_8087164 && sPlayerTradingStates[gLinkSelfPlayerId] == PLAYER_TRADING_STATE_BUSY)
if (sPlayerKeyInterceptCallback == KeyInterCB_DoNothingAndKeepAlive && sPlayerTradingStates[gLinkSelfPlayerId] == PLAYER_TRADING_STATE_BUSY)
return 2;
if (AreAllPlayersInState(PLAYER_TRADING_STATE_UNK_2) != FALSE)
return 1;
@ -2653,7 +2664,7 @@ u32 sub_8087214(void)
bool32 sub_808727C(void)
{
return AreAnyPlayersInState(PLAYER_TRADING_STATE_UNK_3);
return AreAnyPlayersInState(PLAYER_TRADING_STATE_EXITING_ROOM);
}
u16 sub_8087288(void)
@ -2668,15 +2679,17 @@ u16 sub_808729C(void)
return 0;
}
u16 sub_80872B0(void)
// The exit room key will be sent at the next opportunity.
// The return value is meaningless.
u16 QueueExitLinkRoomKey(void)
{
SetKeyInterceptCallback(sub_80871FC);
SetKeyInterceptCallback(KeyInterCB_SendExitRoomKey);
return 0;
}
u16 sub_80872C4(void)
{
SetKeyInterceptCallback(sub_8087210);
SetKeyInterceptCallback(KeyInterCB_SendNothing_2);
return 0;
}
@ -2686,7 +2699,7 @@ static void LoadTradeRoomPlayer(s32 linkPlayerId, s32 myPlayerId, struct TradeRo
trainer->playerId = linkPlayerId;
trainer->isSelf = (linkPlayerId == myPlayerId) ? 1 : 0;
trainer->c = gLinkPlayerEventObjects[linkPlayerId].mode;
trainer->c = gLinkPlayerEventObjects[linkPlayerId].movementMode;
trainer->facing = GetLinkPlayerFacingDirection(linkPlayerId);
GetLinkPlayerCoords(linkPlayerId, &x, &y);
trainer->pos.x = x;
@ -2698,7 +2711,7 @@ static void LoadTradeRoomPlayer(s32 linkPlayerId, s32 myPlayerId, struct TradeRo
static bool32 sub_8087340(struct TradeRoomPlayer *player)
{
u8 v1 = player->c;
if (v1 == 2 || v1 == 0)
if (v1 == MOVEMENT_MODE_SCRIPTED || v1 == MOVEMENT_MODE_FREE)
return TRUE;
else
return FALSE;
@ -2708,7 +2721,7 @@ static bool32 sub_8087340(struct TradeRoomPlayer *player)
static bool32 sub_8087340_2(struct TradeRoomPlayer *player)
{
u8 v1 = player->c;
if (v1 == 2 || v1 == 0)
if (v1 == MOVEMENT_MODE_SCRIPTED || v1 == MOVEMENT_MODE_FREE)
return TRUE;
else
return FALSE;
@ -2716,14 +2729,14 @@ static bool32 sub_8087340_2(struct TradeRoomPlayer *player)
static u8 *TryGetTileEventScript(struct TradeRoomPlayer *player)
{
if (player->c != 2)
return 0;
if (player->c != MOVEMENT_MODE_SCRIPTED)
return FACING_NONE;
return GetCoordEventScriptAtMapPosition(&player->pos);
}
static bool32 PlayerIsAtSouthExit(struct TradeRoomPlayer *player)
{
if (player->c != 2 && player->c != 0)
if (player->c != MOVEMENT_MODE_SCRIPTED && player->c != MOVEMENT_MODE_FREE)
return FALSE;
else if (!MetatileBehavior_IsSouthArrowWarp(player->field_C))
return FALSE;
@ -2738,8 +2751,8 @@ static const u8 *TryInteractWithPlayer(struct TradeRoomPlayer *player)
struct MapPosition otherPlayerPos;
u8 linkPlayerId;
if (player->c && player->c != 2)
return 0;
if (player->c != MOVEMENT_MODE_FREE && player->c != MOVEMENT_MODE_SCRIPTED)
return FACING_NONE;
otherPlayerPos = player->pos;
otherPlayerPos.x += gDirectionToVectors[player->facing].x;
@ -2750,46 +2763,48 @@ static const u8 *TryInteractWithPlayer(struct TradeRoomPlayer *player)
if (linkPlayerId != 4)
{
if (!player->isSelf)
return EventScript_TradeRoom_TooBusyToNotice;
return gEventScript_TradeRoom_TooBusyToNotice;
else if (sPlayerTradingStates[linkPlayerId] != PLAYER_TRADING_STATE_IDLE)
return EventScript_TradeRoom_TooBusyToNotice;
return gEventScript_TradeRoom_TooBusyToNotice;
else if (!GetLinkTrainerCardColor(linkPlayerId))
return EventScript_TradeRoom_ReadTrainerCard_NoColor;
return gEventScript_TradeRoom_ReadTrainerCard_NoColor;
else
return EventScript_TradeRoom_ReadTrainerCard_Normal;
return gEventScript_TradeRoom_ReadTrainerCard_Normal;
}
return GetInteractedLinkPlayerScript(&otherPlayerPos, player->field_C, player->facing);
}
static u16 GetTypeForTileEventScript(const u8 *script)
// This returns which direction to force the player to look when one of
// these event scripts runs.
static u16 GetDirectionForEventScript(const u8 *script)
{
if (script == gUnknown_08277388)
return 10;
else if (script == gUnknown_082773A3)
return 9;
else if (script == gUnknown_082773BE)
return 10;
else if (script == gUnknown_082773D9)
return 9;
else if (script == gUnknown_0827741D)
return 10;
else if (script == gUnknown_08277432)
return 9;
else if (script == gUnknown_08277447)
return 10;
else if (script == gUnknown_0827745C)
return 9;
else if (script == gUnknown_08277374)
return 10;
else if (script == gUnknown_0827737E)
return 9;
else if (script == gUnknown_082773F5)
return 10;
else if (script == gUnknown_082773FF)
return 9;
if (script == gEventScript_DoubleBattleColosseum_PlayerSpot0)
return FACING_FORCED_RIGHT;
else if (script == gEventScript_DoubleBattleColosseum_PlayerSpot1)
return FACING_FORCED_LEFT;
else if (script == gEventScript_DoubleBattleColosseum_PlayerSpot2)
return FACING_FORCED_RIGHT;
else if (script == gEventScript_DoubleBattleColosseum_PlayerSpot3)
return FACING_FORCED_LEFT;
else if (script == gEventScript_RecordCenter_Spot0)
return FACING_FORCED_RIGHT;
else if (script == gEventScript_RecordCenter_Spot1)
return FACING_FORCED_LEFT;
else if (script == gEventScript_RecordCenter_Spot2)
return FACING_FORCED_RIGHT;
else if (script == gEventScript_RecordCenter_Spot3)
return FACING_FORCED_LEFT;
else if (script == gEventScript_SingleBattleColosseum_PlayerSpot0)
return FACING_FORCED_RIGHT;
else if (script == gEventScript_SingleBattleColosseum_PlayerSpot1)
return FACING_FORCED_LEFT;
else if (script == gEventScript_TradeCenter_Chair0)
return FACING_FORCED_RIGHT;
else if (script == gEventScript_TradeCenter_Chair1)
return FACING_FORCED_LEFT;
else
return 0;
return FACING_NONE;
}
static void sub_8087510(void)
@ -2827,7 +2842,7 @@ static void InitMenuBasedScript(const u8 *script)
static void sub_8087584(void)
{
ScriptContext1_SetupScript(gUnknown_08277509);
ScriptContext1_SetupScript(gEventScript_TerminateLink);
ScriptContext2_Enable();
}
@ -2927,7 +2942,7 @@ static void SpawnLinkPlayerEventObject(u8 linkPlayerId, s16 x, s16 y, u8 a4)
linkPlayerEventObj->active = 1;
linkPlayerEventObj->linkPlayerId = linkPlayerId;
linkPlayerEventObj->eventObjId = eventObjId;
linkPlayerEventObj->mode = 0;
linkPlayerEventObj->movementMode = MOVEMENT_MODE_FREE;
eventObj->active = 1;
eventObj->singleMovementActive = a4;
@ -3012,7 +3027,7 @@ static u8 GetLinkPlayerIdAt(s16 x, s16 y)
for (i = 0; i < 4; i++)
{
if (gLinkPlayerEventObjects[i].active
&& (gLinkPlayerEventObjects[i].mode == 0 || gLinkPlayerEventObjects[i].mode == 2))
&& (gLinkPlayerEventObjects[i].movementMode == 0 || gLinkPlayerEventObjects[i].movementMode == 2))
{
struct EventObject *eventObj = &gEventObjects[gLinkPlayerEventObjects[i].eventObjId];
if (eventObj->currentCoords.x == x && eventObj->currentCoords.y == y)
@ -3022,7 +3037,7 @@ static u8 GetLinkPlayerIdAt(s16 x, s16 y)
return 4;
}
static void RunPlayerEventScript(u8 linkPlayerId, u8 eventScriptType)
static void SetPlayerFacingDirection(u8 linkPlayerId, u8 facing)
{
struct LinkPlayerEventObject *linkPlayerEventObj = &gLinkPlayerEventObjects[linkPlayerId];
u8 eventObjId = linkPlayerEventObj->eventObjId;
@ -3030,94 +3045,108 @@ static void RunPlayerEventScript(u8 linkPlayerId, u8 eventScriptType)
if (linkPlayerEventObj->active)
{
if (eventScriptType > 10)
if (facing > FACING_FORCED_RIGHT)
eventObj->triggerGroundEffectsOnMove = 1;
else
gUnknown_08339E00[gLinkPlayerEventModes[linkPlayerEventObj->mode](linkPlayerEventObj, eventObj, eventScriptType)](linkPlayerEventObj, eventObj);
else {
// This is a hack to split this code onto two separate lines, without declaring a local variable.
// C++ style inline variables would be nice here.
#define TEMP gLinkPlayerMovementModes[linkPlayerEventObj->movementMode](linkPlayerEventObj, eventObj, facing)
gMovementStatusHandler[TEMP](linkPlayerEventObj, eventObj);
// Clean up the hack.
#undef TEMP
}
}
}
static u8 sub_80879D8(struct LinkPlayerEventObject *linkPlayerEventObj, struct EventObject *eventObj, u8 a3)
static u8 MovementEventModeCB_Normal(struct LinkPlayerEventObject *linkPlayerEventObj, struct EventObject *eventObj, u8 a3)
{
return gUnknown_08339DD4[a3](linkPlayerEventObj, eventObj, a3);
return gLinkPlayerFacingHandlers[a3](linkPlayerEventObj, eventObj, a3);
}
static u8 sub_80879F8(struct LinkPlayerEventObject *linkPlayerEventObj, struct EventObject *eventObj, u8 a3)
static u8 MovementEventModeCB_Ignored(struct LinkPlayerEventObject *linkPlayerEventObj, struct EventObject *eventObj, u8 a3)
{
return 1;
return FACING_UP;
}
static u8 sub_80879FC(struct LinkPlayerEventObject *linkPlayerEventObj, struct EventObject *eventObj, u8 a3)
// Duplicate Function
static u8 MovementEventModeCB_Normal_2(struct LinkPlayerEventObject *linkPlayerEventObj, struct EventObject *eventObj, u8 a3)
{
return gUnknown_08339DD4[a3](linkPlayerEventObj, eventObj, a3);
return gLinkPlayerFacingHandlers[a3](linkPlayerEventObj, eventObj, a3);
}
static u8 sub_8087A1C(struct LinkPlayerEventObject *linkPlayerEventObj, struct EventObject *eventObj, u8 a3)
static bool8 FacingHandler_DoNothing(struct LinkPlayerEventObject *linkPlayerEventObj, struct EventObject *eventObj, u8 a3)
{
return 0;
return FALSE;
}
static u8 sub_8087A20(struct LinkPlayerEventObject *linkPlayerEventObj, struct EventObject *eventObj, u8 a3)
static bool8 FacingHandler_DpadMovement(struct LinkPlayerEventObject *linkPlayerEventObj, struct EventObject *eventObj, u8 a3)
{
s16 x, y;
eventObj->range.as_byte = npc_something3(a3, eventObj->range.as_byte);
eventObj->range.as_byte = FlipVerticalAndClearForced(a3, eventObj->range.as_byte);
EventObjectMoveDestCoords(eventObj, eventObj->range.as_byte, &x, &y);
if (LinkPlayerDetectCollision(linkPlayerEventObj->eventObjId, eventObj->range.as_byte, x, y))
{
return 0;
return FALSE;
}
else
{
eventObj->directionSequenceIndex = 16;
ShiftEventObjectCoords(eventObj, x, y);
EventObjectUpdateZCoord(eventObj);
return 1;
return TRUE;
}
}
static u8 sub_8087A88(struct LinkPlayerEventObject *linkPlayerEventObj, struct EventObject *eventObj, u8 a3)
static bool8 FacingHandler_ForcedFacingChange(struct LinkPlayerEventObject *linkPlayerEventObj, struct EventObject *eventObj, u8 a3)
{
eventObj->range.as_byte = npc_something3(a3, eventObj->range.as_byte);
return 0;
eventObj->range.as_byte = FlipVerticalAndClearForced(a3, eventObj->range.as_byte);
return FALSE;
}
static void sub_8087AA0(struct LinkPlayerEventObject *linkPlayerEventObj, struct EventObject *eventObj)
// This is called every time a free movement happens. Most of the time it's a No-Op.
static void MovementStatusHandler_EnterFreeMode(struct LinkPlayerEventObject *linkPlayerEventObj, struct EventObject *eventObj)
{
linkPlayerEventObj->mode = 0;
linkPlayerEventObj->movementMode = MOVEMENT_MODE_FREE;
}
static void sub_8087AA8(struct LinkPlayerEventObject *linkPlayerEventObj, struct EventObject *eventObj)
static void MovementStatusHandler_TryAdvanceScript(struct LinkPlayerEventObject *linkPlayerEventObj, struct EventObject *eventObj)
{
eventObj->directionSequenceIndex--;
linkPlayerEventObj->mode = 1;
linkPlayerEventObj->movementMode = MOVEMENT_MODE_FROZEN;
MoveCoords(eventObj->range.as_byte, &eventObj->initialCoords.x, &eventObj->initialCoords.y);
if (!eventObj->directionSequenceIndex)
{
ShiftStillEventObjectCoords(eventObj);
linkPlayerEventObj->mode = 2;
linkPlayerEventObj->movementMode = MOVEMENT_MODE_SCRIPTED;
}
}
static u8 npc_something3(u8 a1, u8 a2)
// Flip Up/Down facing codes. If newFacing doesn't specify a direction, default
// to oldFacing. Note that this clears also the "FORCED" part of the facing code,
// even for Left/Right codes.
static u8 FlipVerticalAndClearForced(u8 newFacing, u8 oldFacing)
{
switch (a1 - 1)
switch (newFacing - 1)
{
case 0:
case 6:
return 2;
case 1:
case 7:
return 1;
case 2:
case 8:
return 3;
case 3:
case 9:
return 4;
case (FACING_UP - 1):
case (FACING_FORCED_UP - 1):
return FACING_DOWN;
case (FACING_DOWN - 1):
case (FACING_FORCED_DOWN - 1):
return FACING_UP;
case (FACING_LEFT - 1):
case (FACING_FORCED_LEFT - 1):
return FACING_LEFT;
case (FACING_RIGHT - 1):
case (FACING_FORCED_RIGHT - 1):
return FACING_RIGHT;
}
return a2;
return oldFacing;
}
static u8 LinkPlayerDetectCollision(u8 selfEventObjId, u8 a2, s16 x, s16 y)
@ -3177,7 +3206,7 @@ static void SpriteCB_LinkPlayer(struct Sprite *sprite)
SetObjectSubpriorityByZCoord(eventObj->previousElevation, sprite, 1);
sprite->oam.priority = ZCoordToPriority(eventObj->previousElevation);
if (!linkPlayerEventObj->mode)
if (!linkPlayerEventObj->movementMode != MOVEMENT_MODE_FREE)
StartSpriteAnim(sprite, GetFaceDirectionAnimNum(eventObj->range.as_byte));
else
StartSpriteAnimIfDifferent(sprite, GetMoveDirectionAnimNum(eventObj->range.as_byte));

View File

@ -6513,7 +6513,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);

View File

@ -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 EventScript_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/FireRed/LeafGreen 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

View File

@ -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();

View File

@ -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;

View File

@ -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 be
// TRUE if the party selection was successful.
void EventScript_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)

View File

@ -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;

View File

@ -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++;
}
}
@ -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++;
}
}