mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2024-12-25 11:14:15 +01:00
Done documenting link code in overworld.c
This commit is contained in:
parent
3fd878483f
commit
f2f1b1978b
@ -12,7 +12,7 @@ sub_81C7078: @ 81C7078
|
||||
push {r4,r5,lr}
|
||||
adds r5, r0, 0
|
||||
adds r4, r1, 0
|
||||
bl is_c1_link_related_active
|
||||
bl IsUpdateLinkStateCBActive
|
||||
cmp r0, 0
|
||||
bne _081C7090
|
||||
ldr r0, =sub_81C7170
|
||||
|
@ -1,8 +1,8 @@
|
||||
gBGTilemapBuffers1
|
||||
gBGTilemapBuffers2
|
||||
gBGTilemapBuffers3
|
||||
gUnknown_03005DA8
|
||||
gHeldKeyCodeToSend
|
||||
gFieldCallback
|
||||
gFieldCallback2
|
||||
gLinkGuestPlayerId
|
||||
gLinkSelfPlayerId
|
||||
gFieldLinkPlayerCount
|
||||
|
@ -967,7 +967,7 @@ RecordCorner_EventScript_2774E0:: @ 82774E0
|
||||
closemessage
|
||||
end
|
||||
|
||||
gUnknown_082774EF:: @ 82774EF
|
||||
gEventScript_ConfirmLeaveTradeRoom:: @ 82774EF
|
||||
msgbox Text_2783A8, MSGBOX_YESNO
|
||||
compare VAR_RESULT, 1
|
||||
goto_if_eq gUnknown_08277509
|
||||
|
@ -907,13 +907,13 @@ struct MapPosition
|
||||
s8 height;
|
||||
};
|
||||
|
||||
struct TradeRoomTrainer
|
||||
struct TradeRoomPlayer
|
||||
{
|
||||
u8 a;
|
||||
u8 b;
|
||||
u8 playerId;
|
||||
u8 isSelf;
|
||||
u8 c;
|
||||
u8 facing;
|
||||
struct MapPosition sub;
|
||||
struct MapPosition pos;
|
||||
u16 field_C;
|
||||
};
|
||||
|
||||
|
@ -312,7 +312,7 @@ void sub_800AB18(void);
|
||||
void sub_8009F18(void);
|
||||
bool8 sub_800AA60(void);
|
||||
void sub_800ABF4(u16 a0);
|
||||
bool32 sub_8009F3C(void);
|
||||
u32 sub_800B4DC(void);
|
||||
bool32 IsSendingKeysToLink(void);
|
||||
u32 GetLinkRecvQueueLength(void);
|
||||
|
||||
#endif // GUARD_LINK_H
|
||||
|
@ -218,7 +218,7 @@ void sub_800E700(void);
|
||||
void sub_800EDD4(void);
|
||||
void sub_800F6FC(u8 who);
|
||||
void sub_800F728(u8 who);
|
||||
bool32 sub_800F7E4(void);
|
||||
bool32 IsSendingKeysToRfu(void);
|
||||
void sub_800F804(void);
|
||||
void sub_800F850(void);
|
||||
u8 sub_800FCD8(void);
|
||||
@ -237,8 +237,8 @@ void sub_800E6D0(void);
|
||||
bool32 sub_8010EC0(void);
|
||||
bool32 sub_8010F1C(void);
|
||||
bool32 sub_8011A80(void);
|
||||
bool32 sub_800F0B8(void);
|
||||
u32 sub_80124D4(void);
|
||||
bool32 IsRfuRecvQueueEmpty(void);
|
||||
u32 GetRfuRecvQueueLength(void);
|
||||
void RfuVSync(void);
|
||||
void sub_80111B0(bool32 a0);
|
||||
u8 sub_8011A74(void);
|
||||
|
@ -1,6 +1,18 @@
|
||||
#ifndef GUARD_OVERWORLD_H
|
||||
#define GUARD_OVERWORLD_H
|
||||
|
||||
#define LINK_KEY_CODE_NULL 0x00
|
||||
#define LINK_KEY_CODE_EMPTY 0x11
|
||||
#define LINK_KEY_CODE_DPAD_DOWN 0x12
|
||||
#define LINK_KEY_CODE_DPAD_UP 0x13
|
||||
#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_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?
|
||||
|
||||
struct InitialPlayerAvatarState
|
||||
{
|
||||
u8 transitionFlags;
|
||||
@ -22,10 +34,10 @@ extern struct LinkPlayerEventObject gLinkPlayerEventObjects[4];
|
||||
extern u16 *gBGTilemapBuffers1;
|
||||
extern u16 *gBGTilemapBuffers2;
|
||||
extern u16 *gBGTilemapBuffers3;
|
||||
extern u16 gUnknown_03005DA8;
|
||||
extern u16 gHeldKeyCodeToSend;
|
||||
extern void (*gFieldCallback)(void);
|
||||
extern bool8 (*gFieldCallback2)(void);
|
||||
extern u8 gLinkGuestPlayerId;
|
||||
extern u8 gLinkSelfPlayerId;
|
||||
extern u8 gFieldLinkPlayerCount;
|
||||
|
||||
// Exported ROM declarations
|
||||
@ -103,7 +115,7 @@ u8 GetSavedWarpRegionMapSectionId(void);
|
||||
u8 GetCurrentRegionMapSectionId(void);
|
||||
u8 GetCurrentMapBattleScene(void);
|
||||
void CleanupOverworldWindowsAndTilemaps(void);
|
||||
bool32 is_c1_link_related_active(void);
|
||||
bool32 IsUpdateLinkStateCBActive(void);
|
||||
void CB1_Overworld(void);
|
||||
void CB2_OverworldBasic(void);
|
||||
void CB2_Overworld(void);
|
||||
@ -117,13 +129,13 @@ void sub_8086074(void);
|
||||
void CB2_ReturnToField(void);
|
||||
void CB2_ReturnToFieldLocal(void);
|
||||
void CB2_ReturnToFieldLink(void);
|
||||
void c2_8056854(void);
|
||||
void CB2_ReturnToFieldFromMultiplayer(void);
|
||||
void CB2_ReturnToFieldWithOpenMenu(void);
|
||||
void CB2_ReturnToFieldContinueScript(void);
|
||||
void CB2_ReturnToFieldContinueScriptPlayMapMusic(void);
|
||||
void sub_80861E8(void);
|
||||
void CB2_ContinueSavedGame(void);
|
||||
void sub_8086C2C(void);
|
||||
void ResetAllMultiplayerState(void);
|
||||
u32 sub_8087214(void);
|
||||
bool32 sub_808727C(void);
|
||||
u16 sub_8087288(void);
|
||||
|
@ -352,7 +352,7 @@ static void sub_80B2918(u8 taskId)
|
||||
else
|
||||
{
|
||||
gFieldLinkPlayerCount = GetLinkPlayerCount_2();
|
||||
gLinkGuestPlayerId = GetMultiplayerId();
|
||||
gLinkSelfPlayerId = GetMultiplayerId();
|
||||
sub_800AA04(gFieldLinkPlayerCount);
|
||||
card = (struct TrainerCard *)gBlockSendBuffer;
|
||||
TrainerCard_GenerateCardForPlayer(card);
|
||||
@ -399,7 +399,7 @@ static void sub_80B2A08(u8 taskId)
|
||||
else
|
||||
{
|
||||
gFieldLinkPlayerCount = GetLinkPlayerCount_2();
|
||||
gLinkGuestPlayerId = GetMultiplayerId();
|
||||
gLinkSelfPlayerId = GetMultiplayerId();
|
||||
sub_800AA04(gFieldLinkPlayerCount);
|
||||
card = (struct TrainerCard *)gBlockSendBuffer;
|
||||
TrainerCard_GenerateCardForPlayer(card);
|
||||
@ -972,7 +972,7 @@ void sub_80B360C(void)
|
||||
|
||||
if (gSpecialVar_0x8004 == 1 || gSpecialVar_0x8004 == 2)
|
||||
{
|
||||
UpdatePlayerLinkBattleRecords(gLinkGuestPlayerId ^ 1);
|
||||
UpdatePlayerLinkBattleRecords(gLinkSelfPlayerId ^ 1);
|
||||
if (gWirelessCommType)
|
||||
{
|
||||
switch (gBattleOutcome)
|
||||
@ -993,7 +993,7 @@ void sub_80B360C(void)
|
||||
}
|
||||
else
|
||||
{
|
||||
gMain.savedCallback = c2_8056854;
|
||||
gMain.savedCallback = CB2_ReturnToFieldFromMultiplayer;
|
||||
}
|
||||
|
||||
SetMainCallback2(sub_80A0514);
|
||||
|
@ -146,7 +146,7 @@ static void sub_811A2A4(u8 taskId, TaskFunc taskFunc)
|
||||
|
||||
static void sub_811A2C0(u8 taskId)
|
||||
{
|
||||
if (!is_c1_link_related_active())
|
||||
if (!IsUpdateLinkStateCBActive())
|
||||
{
|
||||
while (sub_811A428(taskId));
|
||||
}
|
||||
|
@ -255,7 +255,7 @@ void sub_80AF2B4(u8 taskId)
|
||||
break;
|
||||
case 2:
|
||||
sub_8009F18();
|
||||
sub_8086C2C();
|
||||
ResetAllMultiplayerState();
|
||||
ScriptContext2_Disable();
|
||||
DestroyTask(taskId);
|
||||
break;
|
||||
|
18
src/link.c
18
src/link.c
@ -28,7 +28,7 @@
|
||||
#include "link.h"
|
||||
#include "link_rfu.h"
|
||||
|
||||
extern u16 gUnknown_03005DA8;
|
||||
extern u16 gHeldKeyCodeToSend;
|
||||
|
||||
// Static type declarations
|
||||
|
||||
@ -695,12 +695,12 @@ static void BuildSendCmd(u16 command)
|
||||
gSendCmd[0] = LINKCMD_0x5566;
|
||||
break;
|
||||
case LINKCMD_SEND_HELD_KEYS_2:
|
||||
if (gUnknown_03005DA8 == 0 || gLinkTransferringData)
|
||||
if (gHeldKeyCodeToSend == 0 || gLinkTransferringData)
|
||||
{
|
||||
break;
|
||||
}
|
||||
gSendCmd[0] = LINKCMD_SEND_HELD_KEYS_2;
|
||||
gSendCmd[1] = gUnknown_03005DA8;
|
||||
gSendCmd[1] = gHeldKeyCodeToSend;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -714,11 +714,11 @@ void sub_8009F18(void)
|
||||
gLinkCallback = sub_8009F70;
|
||||
}
|
||||
|
||||
bool32 sub_8009F3C(void)
|
||||
bool32 IsSendingKeysToLink(void)
|
||||
{
|
||||
if (gWirelessCommType)
|
||||
{
|
||||
return sub_800F7E4();
|
||||
return IsSendingKeysToRfu();
|
||||
}
|
||||
if (gLinkCallback == sub_8009F70)
|
||||
{
|
||||
@ -1849,7 +1849,7 @@ bool8 HandleLinkConnection(void)
|
||||
r5 = sub_8010F1C();
|
||||
if (sub_808766C() == TRUE)
|
||||
{
|
||||
if (r4 == TRUE || sub_800F0B8() || r5)
|
||||
if (r4 == TRUE || IsRfuRecvQueueEmpty() || r5)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
@ -1882,18 +1882,18 @@ void sub_800B4C0(void)
|
||||
}
|
||||
}
|
||||
|
||||
u32 sub_800B4DC(void)
|
||||
u32 GetLinkRecvQueueLength(void)
|
||||
{
|
||||
if (gWirelessCommType != 0)
|
||||
{
|
||||
return sub_80124D4();
|
||||
return GetRfuRecvQueueLength();
|
||||
}
|
||||
return gLink.recvQueue.count;
|
||||
}
|
||||
|
||||
bool8 sub_800B504(void)
|
||||
{
|
||||
if (sub_800B4DC() > 2)
|
||||
if (GetLinkRecvQueueLength() > 2)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -17,7 +17,7 @@
|
||||
#include "text.h"
|
||||
#include "constants/species.h"
|
||||
|
||||
extern u16 gUnknown_03005DA8;
|
||||
extern u16 gHeldKeyCodeToSend;
|
||||
extern void nullsub_89(u8 taskId);
|
||||
|
||||
struct UnkRfuStruct_1 gUnknown_03004140;
|
||||
@ -2978,7 +2978,7 @@ static void sub_800F048(void)
|
||||
}
|
||||
}
|
||||
|
||||
bool32 sub_800F0B8(void)
|
||||
bool32 IsRfuRecvQueueEmpty(void)
|
||||
{
|
||||
s32 i;
|
||||
s32 j;
|
||||
@ -3199,7 +3199,7 @@ bool32 sub_800F4F0(void)
|
||||
for (i = 0; i < CMD_LENGTH - 1; i++)
|
||||
gSendCmd[i] = 0;
|
||||
}
|
||||
return sub_800F0B8();
|
||||
return IsRfuRecvQueueEmpty();
|
||||
}
|
||||
|
||||
void sub_800F638(u8 unused, u32 flags)
|
||||
@ -3259,10 +3259,12 @@ u8 sub_800F74C(const u8 *a0)
|
||||
|
||||
void rfu_func_080F97B8(void)
|
||||
{
|
||||
if (gReceivedRemoteLinkPlayers && gUnknown_03005DA8 && gLinkTransferringData != 1)
|
||||
if (gReceivedRemoteLinkPlayers
|
||||
&& gHeldKeyCodeToSend != LINK_KEY_CODE_NULL
|
||||
&& gLinkTransferringData != TRUE)
|
||||
{
|
||||
gUnknown_03000D78[0]++;
|
||||
gUnknown_03005DA8 |= (gUnknown_03000D78[0] << 8);
|
||||
gHeldKeyCodeToSend |= (gUnknown_03000D78[0] << 8);
|
||||
sub_800FD14(0xbe00);
|
||||
}
|
||||
}
|
||||
@ -3272,7 +3274,7 @@ struct UnkLinkRfuStruct_02022B14 *sub_800F7DC(void)
|
||||
return &gUnknown_02022B14;
|
||||
}
|
||||
|
||||
bool32 sub_800F7E4(void)
|
||||
bool32 IsSendingKeysToRfu(void)
|
||||
{
|
||||
return gUnknown_03005000.unk_00 == rfu_func_080F97B8;
|
||||
}
|
||||
@ -3496,7 +3498,7 @@ void sub_800FD14(u16 command)
|
||||
gSendCmd[1 + i] = gUnknown_03005000.unk_f2[i];
|
||||
break;
|
||||
case 0xbe00:
|
||||
gSendCmd[1] = gUnknown_03005DA8;
|
||||
gSendCmd[1] = gHeldKeyCodeToSend;
|
||||
break;
|
||||
case 0xee00:
|
||||
break;
|
||||
@ -5150,7 +5152,7 @@ u32 sub_80124C0(void)
|
||||
return gUnknown_03005000.unk_9e8.unk_232;
|
||||
}
|
||||
|
||||
u32 sub_80124D4(void)
|
||||
u32 GetRfuRecvQueueLength(void)
|
||||
{
|
||||
return gUnknown_03005000.unk_124.unk_8c2;
|
||||
}
|
||||
|
@ -293,7 +293,7 @@ bool8 sub_8122148(u16 itemId)
|
||||
|
||||
bool8 itemid_80BF6D8_mail_related(u16 itemId)
|
||||
{
|
||||
if (is_c1_link_related_active() != TRUE && InUnionRoom() != TRUE)
|
||||
if (IsUpdateLinkStateCBActive() != TRUE && InUnionRoom() != TRUE)
|
||||
return TRUE;
|
||||
else if (ItemIsMail(itemId) != TRUE)
|
||||
return TRUE;
|
||||
@ -303,7 +303,7 @@ bool8 itemid_80BF6D8_mail_related(u16 itemId)
|
||||
|
||||
bool8 sub_81221AC(void)
|
||||
{
|
||||
if (is_c1_link_related_active() == TRUE || gReceivedRemoteLinkPlayers == 1)
|
||||
if (IsUpdateLinkStateCBActive() == TRUE || gReceivedRemoteLinkPlayers == 1)
|
||||
return TRUE;
|
||||
else
|
||||
return FALSE;
|
||||
|
602
src/overworld.c
602
src/overworld.c
File diff suppressed because it is too large
Load Diff
@ -188,7 +188,7 @@ extern u8 gUnknown_02022C3E;
|
||||
extern u16 gUnknown_02022C3C;
|
||||
extern u8 gUnknown_02022C20[];
|
||||
extern u8 gFieldLinkPlayerCount;
|
||||
extern u8 gLinkGuestPlayerId;
|
||||
extern u8 gLinkSelfPlayerId;
|
||||
|
||||
// IWRAM vars
|
||||
IWRAM_DATA struct UnkStruct_Leader *gUnknown_03000DA0;
|
||||
@ -1641,7 +1641,7 @@ void sub_8014304(s8 mapGroup, s8 mapNum, s32 x, s32 y, u16 arg4)
|
||||
gSpecialVar_0x8004 = arg4;
|
||||
VarSet(VAR_0x4087, arg4);
|
||||
gFieldLinkPlayerCount = GetLinkPlayerCount();
|
||||
gLinkGuestPlayerId = GetMultiplayerId();
|
||||
gLinkSelfPlayerId = GetMultiplayerId();
|
||||
SetCableClubWarp();
|
||||
SetWarpDestination(mapGroup, mapNum, -1, x, y);
|
||||
WarpIntoMap();
|
||||
|
@ -1203,7 +1203,7 @@ bool8 ScrCmd_turnvobject(struct ScriptContext *ctx)
|
||||
|
||||
bool8 ScrCmd_lockall(struct ScriptContext *ctx)
|
||||
{
|
||||
if (is_c1_link_related_active())
|
||||
if (IsUpdateLinkStateCBActive())
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
@ -1217,7 +1217,7 @@ bool8 ScrCmd_lockall(struct ScriptContext *ctx)
|
||||
|
||||
bool8 ScrCmd_lock(struct ScriptContext *ctx)
|
||||
{
|
||||
if (is_c1_link_related_active())
|
||||
if (IsUpdateLinkStateCBActive())
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
@ -2182,7 +2182,7 @@ bool8 ScrCmd_cmdD8(struct ScriptContext *ctx)
|
||||
|
||||
bool8 ScrCmd_cmdD9(struct ScriptContext *ctx)
|
||||
{
|
||||
if (is_c1_link_related_active())
|
||||
if (IsUpdateLinkStateCBActive())
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -84,7 +84,7 @@ EWRAM_DATA static bool8 sSavingComplete = FALSE;
|
||||
EWRAM_DATA static u8 sSaveInfoWindowId = 0;
|
||||
|
||||
// Extern variables.
|
||||
extern u8 gLinkGuestPlayerId;
|
||||
extern u8 gLinkSelfPlayerId;
|
||||
|
||||
// Extern functions in not decompiled files.
|
||||
extern void sub_80AF688(void);
|
||||
@ -244,7 +244,7 @@ static void BuildStartMenuActions(void)
|
||||
{
|
||||
sNumStartMenuActions = 0;
|
||||
|
||||
if (is_c1_link_related_active() == TRUE)
|
||||
if (IsUpdateLinkStateCBActive() == TRUE)
|
||||
{
|
||||
BuildLinkModeStartMenu();
|
||||
}
|
||||
@ -547,7 +547,7 @@ void sub_809FA34(u8 taskId) // Referenced in field_screen.s and rom_8011DC0.s
|
||||
|
||||
void ShowStartMenu(void) // Called from overworld.c and field_control_avatar.s
|
||||
{
|
||||
if (!is_c1_link_related_active())
|
||||
if (!IsUpdateLinkStateCBActive())
|
||||
{
|
||||
FreezeEventObjects();
|
||||
sub_808B864();
|
||||
@ -672,7 +672,7 @@ static bool8 StartMenuPlayerNameCallback(void)
|
||||
RemoveExtraStartMenuWindows();
|
||||
CleanupOverworldWindowsAndTilemaps();
|
||||
|
||||
if (is_c1_link_related_active() || InUnionRoom())
|
||||
if (IsUpdateLinkStateCBActive() || InUnionRoom())
|
||||
ShowPlayerTrainerCard(CB2_ReturnToFieldWithOpenMenu); // Display trainer card
|
||||
else if (FlagGet(FLAG_SYS_FRONTIER_PASS))
|
||||
ShowFrontierPass(CB2_ReturnToFieldWithOpenMenu); // Display frontier pass
|
||||
@ -734,7 +734,7 @@ static bool8 StartMenuLinkModePlayerNameCallback(void)
|
||||
{
|
||||
PlayRainSoundEffect();
|
||||
CleanupOverworldWindowsAndTilemaps();
|
||||
ShowTrainerCardInLink(gLinkGuestPlayerId, CB2_ReturnToFieldWithOpenMenu);
|
||||
ShowTrainerCardInLink(gLinkSelfPlayerId, CB2_ReturnToFieldWithOpenMenu);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -2762,7 +2762,7 @@ static void sub_80794CC(void)
|
||||
Free(gUnknown_0203229C);
|
||||
FreeAllWindowBuffers();
|
||||
sub_800E084();
|
||||
SetMainCallback2(c2_8056854);
|
||||
SetMainCallback2(CB2_ReturnToFieldFromMultiplayer);
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -2772,7 +2772,7 @@ static void sub_80794CC(void)
|
||||
Free(gUnknown_02032184);
|
||||
Free(gUnknown_0203229C);
|
||||
FreeAllWindowBuffers();
|
||||
SetMainCallback2(c2_8056854);
|
||||
SetMainCallback2(CB2_ReturnToFieldFromMultiplayer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user