summaryrefslogtreecommitdiff
path: root/src/link.c
diff options
context:
space:
mode:
authorMarcus Huderle <huderlem@gmail.com>2020-01-13 20:26:20 -0600
committerMarcus Huderle <huderlem@gmail.com>2020-01-13 20:26:20 -0600
commit5a2d676e71b720e752ca8a624a5795b3b1d7eb6c (patch)
tree6ef755064008dfae8ce2942dc2762670cdabe815 /src/link.c
parent5007d279fea5326b41b877703c74fcaa56223364 (diff)
parent22931846d680de2bc585093678db3f5721aab891 (diff)
Merge remote-tracking branch 'upstream' into tustin2121-patch-5
Diffstat (limited to 'src/link.c')
-rw-r--r--src/link.c61
1 files changed, 31 insertions, 30 deletions
diff --git a/src/link.c b/src/link.c
index 9928b48da..939a4afc8 100644
--- a/src/link.c
+++ b/src/link.c
@@ -2,7 +2,7 @@
// Includes
#include "global.h"
#include "m4a.h"
-#include "alloc.h"
+#include "malloc.h"
#include "reset_save_heap.h"
#include "save.h"
#include "bg.h"
@@ -28,6 +28,7 @@
#include "link.h"
#include "link_rfu.h"
#include "constants/rgb.h"
+#include "constants/trade.h"
extern u16 gHeldKeyCodeToSend;
@@ -212,10 +213,9 @@ const struct WindowTemplate gUnknown_082ED204[] = {
{0x00, 0x00, 0x0D, 0x1E, 0x07, 0x0F, 0x016A},
DUMMY_WIN_TEMPLATE
};
-const u8 gUnknown_082ED224[] = {
- 0x00, 0x01, 0x02, 0x00,
- 0xff, 0xfe, 0xff, 0x00
-};
+
+static const u8 sTextColors[] = { TEXT_COLOR_TRANSPARENT, TEXT_COLOR_WHITE, TEXT_COLOR_DARK_GREY };
+static const u8 sUnused_082ED224[] = {0x00, 0xff, 0xfe, 0xff, 0x00};
// .text
@@ -282,7 +282,7 @@ void LinkTestScreen(void)
ResetTasks();
SetVBlankCallback(sub_80096BC);
ResetBlockSend();
- gLinkType = 0x1111;
+ gLinkType = LINKTYPE_0x1111;
OpenLink();
SeedRng(gMain.vblankCounter2);
for (i = 0; i < MAX_LINK_PLAYERS; i++)
@@ -316,10 +316,10 @@ static void InitLocalLinkPlayer(void)
gLocalLinkPlayer.language = gGameLanguage;
gLocalLinkPlayer.version = gGameVersion + 0x4000;
gLocalLinkPlayer.lp_field_2 = 0x8000;
- gLocalLinkPlayer.name[8] = IsNationalPokedexEnabled();
+ gLocalLinkPlayer.progressFlags = IsNationalPokedexEnabled();
if (FlagGet(FLAG_IS_CHAMPION))
{
- gLocalLinkPlayer.name[8] |= 0x10;
+ gLocalLinkPlayer.progressFlags |= 0x10;
}
}
@@ -452,7 +452,7 @@ static void LinkTestProcessKeyInput(void)
}
if (gMain.newKeys & R_BUTTON)
{
- TrySavingData(1);
+ TrySavingData(SAVE_LINK);
}
if (gMain.newKeys & SELECT_BUTTON)
{
@@ -597,9 +597,9 @@ static void ProcessRecvCmds(u8 unused)
*linkPlayer = block->linkPlayer;
if ((linkPlayer->version & 0xFF) == VERSION_RUBY || (linkPlayer->version & 0xFF) == VERSION_SAPPHIRE)
{
- linkPlayer->name[10] = 0;
- linkPlayer->name[9] = 0;
- linkPlayer->name[8] = 0;
+ linkPlayer->progressFlagsCopy = 0;
+ linkPlayer->neverRead = 0;
+ linkPlayer->progressFlags = 0;
}
sub_800B524(linkPlayer);
if (strcmp(block->magic1, gASCIIGameFreakInc) != 0
@@ -739,7 +739,7 @@ void ClearLinkCallback(void)
{
if (gWirelessCommType)
{
- Rfu_set_zero();
+ ClearLinkRfuCallback();
}
else
{
@@ -751,7 +751,7 @@ void ClearLinkCallback_2(void)
{
if (gWirelessCommType)
{
- Rfu_set_zero();
+ ClearLinkRfuCallback();
}
else
{
@@ -862,15 +862,15 @@ u8 GetLinkPlayerDataExchangeStatusTimed(int lower, int upper)
{
if (gLinkPlayers[0].linkType == 0x1133)
{
- switch (sub_807A728())
+ switch (GetGameProgressForLinkTrade())
{
- case 1:
- sPlayerDataExchangeStatus = EXCHANGE_STAT_4;
+ case TRADE_PLAYER_NOT_READY:
+ sPlayerDataExchangeStatus = EXCHANGE_PLAYER_NOT_READY;
break;
- case 2:
- sPlayerDataExchangeStatus = EXCHANGE_STAT_5;
+ case TRADE_PARTNER_NOT_READY:
+ sPlayerDataExchangeStatus = EXCHANGE_PARTNER_NOT_READY;
break;
- case 0:
+ case TRADE_BOTH_PLAYERS_READY:
sPlayerDataExchangeStatus = EXCHANGE_COMPLETE;
break;
}
@@ -1084,7 +1084,7 @@ bool8 IsLinkTaskFinished(void)
{
if (gWirelessCommType == TRUE)
{
- return sub_8010500();
+ return IsLinkRfuTaskFinished();
}
return gLinkCallback == NULL;
}
@@ -1349,7 +1349,7 @@ bool8 sub_800AA60(void)
{
if (gLinkPlayers[i].trainerId == gSavedLinkPlayers[i].trainerId)
{
- if (gLinkType == 0x2288)
+ if (gLinkType == LINKTYPE_BATTLE_TOWER)
{
if (gLinkType == gLinkPlayers[i].linkType)
{
@@ -1398,7 +1398,7 @@ void sub_800AB18(void)
}
}
-void sub_800AB98(void)
+void ResetLinkPlayerCount(void)
{
gSavedLinkPlayerCount = 0;
gSavedMultiplayerId = 0;
@@ -1687,8 +1687,8 @@ static void sub_800B080(void)
LoadPalette(gWirelessLinkDisplayPal, 0, 0x20);
FillWindowPixelBuffer(0, PIXEL_FILL(0));
FillWindowPixelBuffer(2, PIXEL_FILL(0));
- AddTextPrinterParameterized3(0, 3, 2, 6, gUnknown_082ED224, 0, gText_CommErrorEllipsis);
- AddTextPrinterParameterized3(2, 3, 2, 1, gUnknown_082ED224, 0, gText_MoveCloserToLinkPartner);
+ AddTextPrinterParameterized3(0, 3, 2, 6, sTextColors, 0, gText_CommErrorEllipsis);
+ AddTextPrinterParameterized3(2, 3, 2, 1, sTextColors, 0, gText_MoveCloserToLinkPartner);
PutWindowTilemap(0);
PutWindowTilemap(2);
CopyWindowToVram(0, 0);
@@ -1700,7 +1700,7 @@ static void sub_800B138(void)
LoadBgTiles(0, g2BlankTilesGfx, 0x20, 0);
FillWindowPixelBuffer(1, PIXEL_FILL(0));
FillWindowPixelBuffer(2, PIXEL_FILL(0));
- AddTextPrinterParameterized3(1, 3, 2, 0, gUnknown_082ED224, 0, gText_CommErrorCheckConnections);
+ AddTextPrinterParameterized3(1, 3, 2, 0, sTextColors, 0, gText_CommErrorCheckConnections);
PutWindowTilemap(1);
PutWindowTilemap(2);
CopyWindowToVram(1, 0);
@@ -1740,11 +1740,11 @@ static void CB2_PrintErrorMessage(void)
case 130:
if (gWirelessCommType == 2)
{
- AddTextPrinterParameterized3(0, 3, 2, 20, gUnknown_082ED224, 0, gText_ABtnTitleScreen);
+ AddTextPrinterParameterized3(0, 3, 2, 20, sTextColors, 0, gText_ABtnTitleScreen);
}
else if (gWirelessCommType == 1)
{
- AddTextPrinterParameterized3(0, 3, 2, 20, gUnknown_082ED224, 0, gText_ABtnRegistrationCounter);
+ AddTextPrinterParameterized3(0, 3, 2, 20, sTextColors, 0, gText_ABtnRegistrationCounter);
}
break;
}
@@ -1902,14 +1902,15 @@ bool32 sub_800B504(void)
return FALSE;
}
-u8 sub_800B518(void)
+// Unused
+u8 GetWirelessCommType(void)
{
return gWirelessCommType;
}
void sub_800B524(struct LinkPlayer *player)
{
- player->name[10] = player->name[8];
+ player->progressFlagsCopy = player->progressFlags;
ConvertInternationalString(player->name, player->language);
}