Sync link_rfu_3
This commit is contained in:
|
Before Width: | Height: | Size: 308 B After Width: | Height: | Size: 308 B |
+11
-22
@@ -29,8 +29,6 @@
|
|||||||
#define RECV_QUEUE_NUM_SLOTS 20
|
#define RECV_QUEUE_NUM_SLOTS 20
|
||||||
#define SEND_QUEUE_NUM_SLOTS 40
|
#define SEND_QUEUE_NUM_SLOTS 40
|
||||||
#define BACKUP_QUEUE_NUM_SLOTS 2
|
#define BACKUP_QUEUE_NUM_SLOTS 2
|
||||||
#define UNUSED_QUEUE_NUM_SLOTS 2
|
|
||||||
#define UNUSED_QUEUE_SLOT_LENGTH 256
|
|
||||||
|
|
||||||
#define RFU_PACKET_SIZE 6
|
#define RFU_PACKET_SIZE 6
|
||||||
|
|
||||||
@@ -141,8 +139,8 @@ struct RfuBlockSend
|
|||||||
struct RfuRecvQueue
|
struct RfuRecvQueue
|
||||||
{
|
{
|
||||||
/* 0x000 */ u8 slots[RECV_QUEUE_NUM_SLOTS][COMM_SLOT_LENGTH * MAX_RFU_PLAYERS];
|
/* 0x000 */ u8 slots[RECV_QUEUE_NUM_SLOTS][COMM_SLOT_LENGTH * MAX_RFU_PLAYERS];
|
||||||
/* 0x578 */ vu8 recv_slot;
|
/* 0x578 */ vu8 recvSlot;
|
||||||
/* 0x579 */ vu8 send_slot;
|
/* 0x579 */ vu8 sendSlot;
|
||||||
/* 0x57a */ vu8 count;
|
/* 0x57a */ vu8 count;
|
||||||
/* 0x57b */ vu8 full;
|
/* 0x57b */ vu8 full;
|
||||||
};
|
};
|
||||||
@@ -150,8 +148,8 @@ struct RfuRecvQueue
|
|||||||
struct RfuSendQueue
|
struct RfuSendQueue
|
||||||
{
|
{
|
||||||
/* 0x000 */ u8 slots[SEND_QUEUE_NUM_SLOTS][COMM_SLOT_LENGTH];
|
/* 0x000 */ u8 slots[SEND_QUEUE_NUM_SLOTS][COMM_SLOT_LENGTH];
|
||||||
/* 0x230 */ vu8 recv_slot;
|
/* 0x230 */ vu8 recvSlot;
|
||||||
/* 0x231 */ vu8 send_slot;
|
/* 0x231 */ vu8 sendSlot;
|
||||||
/* 0x232 */ vu8 count;
|
/* 0x232 */ vu8 count;
|
||||||
/* 0x233 */ vu8 full;
|
/* 0x233 */ vu8 full;
|
||||||
};
|
};
|
||||||
@@ -159,20 +157,11 @@ struct RfuSendQueue
|
|||||||
struct RfuBackupQueue
|
struct RfuBackupQueue
|
||||||
{
|
{
|
||||||
/* 0x00 */ u8 slots[BACKUP_QUEUE_NUM_SLOTS][COMM_SLOT_LENGTH];
|
/* 0x00 */ u8 slots[BACKUP_QUEUE_NUM_SLOTS][COMM_SLOT_LENGTH];
|
||||||
/* 0x1c */ vu8 recv_slot;
|
/* 0x1c */ vu8 recvSlot;
|
||||||
/* 0x1d */ vu8 send_slot;
|
/* 0x1d */ vu8 sendSlot;
|
||||||
/* 0x1e */ vu8 count;
|
/* 0x1e */ vu8 count;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct RfuUnusedQueue
|
|
||||||
{
|
|
||||||
/* 0x000 */ u8 slots[UNUSED_QUEUE_NUM_SLOTS][UNUSED_QUEUE_SLOT_LENGTH];
|
|
||||||
/* 0x200 */ vu8 recv_slot;
|
|
||||||
/* 0x201 */ vu8 send_slot;
|
|
||||||
/* 0x202 */ vu8 count;
|
|
||||||
/* 0x203 */ vu8 full;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct RfuManager
|
struct RfuManager
|
||||||
{
|
{
|
||||||
/* 0x000 */ void (*callback)(void);
|
/* 0x000 */ void (*callback)(void);
|
||||||
@@ -296,7 +285,7 @@ bool8 RfuBackupQueue_Dequeue(struct RfuBackupQueue *queue, u8 *dest);
|
|||||||
void RfuBackupQueue_Enqueue(struct RfuBackupQueue *queue, const u8 *dest);
|
void RfuBackupQueue_Enqueue(struct RfuBackupQueue *queue, const u8 *dest);
|
||||||
bool8 RfuRecvQueue_Dequeue(struct RfuRecvQueue * queue, u8 *dest);
|
bool8 RfuRecvQueue_Dequeue(struct RfuRecvQueue * queue, u8 *dest);
|
||||||
void RfuSendQueue_Enqueue(struct RfuSendQueue * queue, u8 *src);
|
void RfuSendQueue_Enqueue(struct RfuSendQueue * queue, u8 *src);
|
||||||
void InitHostRFUtgtGname(struct RfuGameData *data, u8 activity, bool32 started, s32 partnerInfo);
|
void InitHostRfuGameData(struct RfuGameData *data, u8 activity, bool32 started, s32 partnerInfo);
|
||||||
void UpdateGameData_GroupLockedIn(bool8 started);
|
void UpdateGameData_GroupLockedIn(bool8 started);
|
||||||
bool32 IsRfuSerialNumberValid(u32 serialNo);
|
bool32 IsRfuSerialNumberValid(u32 serialNo);
|
||||||
bool8 IsRfuRecoveringFromLinkLoss(void);
|
bool8 IsRfuRecoveringFromLinkLoss(void);
|
||||||
@@ -311,12 +300,12 @@ u32 WaitSendRfuStatusToPartner(u16 trainerId, const u8 *name);
|
|||||||
void SetHostRfuGameData(u8 activity, u32 partnerInfo, bool32 startedActivity);
|
void SetHostRfuGameData(u8 activity, u32 partnerInfo, bool32 startedActivity);
|
||||||
void InitializeRfuLinkManager_LinkLeader(u32 availSlots);
|
void InitializeRfuLinkManager_LinkLeader(u32 availSlots);
|
||||||
void RequestDisconnectSlotByTrainerNameAndId(const u8 *trainerName, u16 trainerId);
|
void RequestDisconnectSlotByTrainerNameAndId(const u8 *trainerName, u16 trainerId);
|
||||||
void LinkRfu3_SetGnameUnameFromStaticBuffers(struct RfuGameData *gname, u8 *uname);
|
void CopyHostRfuGameDataAndUsername(struct RfuGameData *gameData, u8 *username);
|
||||||
void InitializeRfuLinkManager_JoinGroup(void);
|
void InitializeRfuLinkManager_JoinGroup(void);
|
||||||
void SendLeaveGroupNotice(void);
|
void SendLeaveGroupNotice(void);
|
||||||
void CreateTask_RfuReconnectWithParent(const u8 *src, u16 trainerId);
|
void CreateTask_RfuReconnectWithParent(const u8 *src, u16 trainerId);
|
||||||
void UpdateGameData_SetActivity(u8 activity, u32 partnerInfo, u32 startedActivity);
|
void UpdateGameData_SetActivity(u8 activity, u32 partnerInfo, u32 startedActivity);
|
||||||
void RecordMixTrainerNames(void);
|
void SaveLinkTrainerNames(void);
|
||||||
void LinkRfu_CreateConnectionAsParent();
|
void LinkRfu_CreateConnectionAsParent();
|
||||||
void LinkRfu_StopManagerBeforeEnteringChat();
|
void LinkRfu_StopManagerBeforeEnteringChat();
|
||||||
void SetHostRfuWonderFlags(bool32 hasNews, bool32 hasCard);
|
void SetHostRfuWonderFlags(bool32 hasNews, bool32 hasCard);
|
||||||
@@ -328,8 +317,8 @@ void InitializeRfuLinkManager_EnterUnionRoom(void);
|
|||||||
void Rfu_DisconnectPlayerById(u32 playerIdx);
|
void Rfu_DisconnectPlayerById(u32 playerIdx);
|
||||||
void TryConnectToUnionRoomParent(const u8 *name, struct RfuGameData *parent, u8 activity);
|
void TryConnectToUnionRoomParent(const u8 *name, struct RfuGameData *parent, u8 activity);
|
||||||
bool32 PlayerHasMetTrainerBefore(u16 id, u8 *name);
|
bool32 PlayerHasMetTrainerBefore(u16 id, u8 *name);
|
||||||
bool8 LinkRfu_GetNameIfCompatible(struct RfuGameData *gname, u8 *uname, u8 idx);
|
bool8 Rfu_GetCompatiblePlayerData(struct RfuGameData *gameData, u8 *username, u8 idx);
|
||||||
bool8 LinkRfu_GetNameIfSerial7F7D(struct RfuGameData *gname, u8 *uname, u8 idx);
|
bool8 Rfu_GetWonderDistributorPlayerData(struct RfuGameData *gameData, u8 *username, u8 idx);
|
||||||
bool32 Rfu_IsPlayerExchangeActive(void);
|
bool32 Rfu_IsPlayerExchangeActive(void);
|
||||||
void Rfu_StopPartnerSearch(void);
|
void Rfu_StopPartnerSearch(void);
|
||||||
void RfuSetNormalDisconnectMode(void);
|
void RfuSetNormalDisconnectMode(void);
|
||||||
|
|||||||
+2
-2
@@ -2057,12 +2057,12 @@ static void SetHostRfuUsername(void)
|
|||||||
void ResetHostRfuGameData(void)
|
void ResetHostRfuGameData(void)
|
||||||
{
|
{
|
||||||
memset(&gHostRfuGameData, 0, RFU_GAME_NAME_LENGTH);
|
memset(&gHostRfuGameData, 0, RFU_GAME_NAME_LENGTH);
|
||||||
InitHostRFUtgtGname(&gHostRfuGameData, ACTIVITY_NONE, FALSE, 0);
|
InitHostRfuGameData(&gHostRfuGameData, ACTIVITY_NONE, FALSE, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetHostRfuGameData(u8 activity, u32 partnerInfo, u32 startedActivity)
|
void SetHostRfuGameData(u8 activity, u32 partnerInfo, u32 startedActivity)
|
||||||
{
|
{
|
||||||
InitHostRFUtgtGname(&gHostRfuGameData, activity, startedActivity, partnerInfo);
|
InitHostRfuGameData(&gHostRfuGameData, activity, startedActivity, partnerInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetHostRfuWonderFlags(bool32 hasNews, bool32 hasCard)
|
void SetHostRfuWonderFlags(bool32 hasNews, bool32 hasCard)
|
||||||
|
|||||||
+136
-163
@@ -6,12 +6,35 @@
|
|||||||
#include "link_rfu.h"
|
#include "link_rfu.h"
|
||||||
#include "random.h"
|
#include "random.h"
|
||||||
|
|
||||||
static EWRAM_DATA u8 gWirelessStatusIndicatorSpriteId = 0;
|
enum {
|
||||||
|
WIRELESS_STATUS_ANIM_3_BARS,
|
||||||
|
WIRELESS_STATUS_ANIM_2_BARS,
|
||||||
|
WIRELESS_STATUS_ANIM_1_BAR,
|
||||||
|
WIRELESS_STATUS_ANIM_SEARCHING,
|
||||||
|
WIRELESS_STATUS_ANIM_ERROR,
|
||||||
|
};
|
||||||
|
|
||||||
static const u16 gWirelessLinkIconPalette[] = INCBIN_U16("graphics/interface/wireless_link_icon.gbapal");
|
#define TAG_GFX_STATUS_INDICATOR 0xD431
|
||||||
|
#define TAG_PAL_STATUS_INDICATOR 0xD432
|
||||||
|
|
||||||
static const u32 gWirelessLinkIconPic[] = INCBIN_U32("graphics/interface/wireless_link_icon.4bpp.lz");
|
#define UNUSED_QUEUE_NUM_SLOTS 2
|
||||||
|
#define UNUSED_QUEUE_SLOT_LENGTH 256
|
||||||
|
|
||||||
|
struct RfuUnusedQueue
|
||||||
|
{
|
||||||
|
u8 slots[UNUSED_QUEUE_NUM_SLOTS][UNUSED_QUEUE_SLOT_LENGTH];
|
||||||
|
vu8 recvSlot;
|
||||||
|
vu8 sendSlot;
|
||||||
|
vu8 count;
|
||||||
|
vu8 full;
|
||||||
|
};
|
||||||
|
|
||||||
|
static EWRAM_DATA u8 sWirelessStatusIndicatorSpriteId = 0;
|
||||||
|
|
||||||
|
static const u16 sWirelessLinkIconPalette[] = INCBIN_U16("graphics/link/wireless_icon.gbapal");
|
||||||
|
static const u32 sWirelessLinkIconPic[] = INCBIN_U32("graphics/link/wireless_icon.4bpp.lz");
|
||||||
|
|
||||||
|
// Most of the below two tables won't make sense with ASCII encoding.
|
||||||
static const u8 sWireless_ASCIItoRSETable[] = {
|
static const u8 sWireless_ASCIItoRSETable[] = {
|
||||||
EOS,
|
EOS,
|
||||||
0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0x37,
|
0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0x37,
|
||||||
@@ -222,8 +245,7 @@ static const struct OamData sWirelessStatusIndicatorOamData =
|
|||||||
.paletteNum = 0,
|
.paletteNum = 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
static const union AnimCmd sWirelessStatusIndicatorAnim0[] = {
|
static const union AnimCmd sWirelessStatusIndicator_3Bars[] = {
|
||||||
// 3 bars
|
|
||||||
ANIMCMD_FRAME( 4, 5),
|
ANIMCMD_FRAME( 4, 5),
|
||||||
ANIMCMD_FRAME( 8, 5),
|
ANIMCMD_FRAME( 8, 5),
|
||||||
ANIMCMD_FRAME(12, 5),
|
ANIMCMD_FRAME(12, 5),
|
||||||
@@ -233,8 +255,7 @@ static const union AnimCmd sWirelessStatusIndicatorAnim0[] = {
|
|||||||
ANIMCMD_JUMP(0)
|
ANIMCMD_JUMP(0)
|
||||||
};
|
};
|
||||||
|
|
||||||
static const union AnimCmd sWirelessStatusIndicatorAnim1[] = {
|
static const union AnimCmd sWirelessStatusIndicator_2Bars[] = {
|
||||||
// 2 bars
|
|
||||||
ANIMCMD_FRAME( 4, 5),
|
ANIMCMD_FRAME( 4, 5),
|
||||||
ANIMCMD_FRAME( 8, 5),
|
ANIMCMD_FRAME( 8, 5),
|
||||||
ANIMCMD_FRAME(12, 10),
|
ANIMCMD_FRAME(12, 10),
|
||||||
@@ -242,46 +263,43 @@ static const union AnimCmd sWirelessStatusIndicatorAnim1[] = {
|
|||||||
ANIMCMD_JUMP(0)
|
ANIMCMD_JUMP(0)
|
||||||
};
|
};
|
||||||
|
|
||||||
static const union AnimCmd sWirelessStatusIndicatorAnim2[] = {
|
static const union AnimCmd sWirelessStatusIndicator_1Bar[] = {
|
||||||
// 1 bar
|
|
||||||
ANIMCMD_FRAME(4, 5),
|
ANIMCMD_FRAME(4, 5),
|
||||||
ANIMCMD_FRAME(8, 5),
|
ANIMCMD_FRAME(8, 5),
|
||||||
ANIMCMD_JUMP(0)
|
ANIMCMD_JUMP(0)
|
||||||
};
|
};
|
||||||
|
|
||||||
static const union AnimCmd sWirelessStatusIndicatorAnim3[] = {
|
static const union AnimCmd sWirelessStatusIndicator_Searching[] = {
|
||||||
// searching
|
|
||||||
ANIMCMD_FRAME( 4, 10),
|
ANIMCMD_FRAME( 4, 10),
|
||||||
ANIMCMD_FRAME(20, 10),
|
ANIMCMD_FRAME(20, 10),
|
||||||
ANIMCMD_JUMP(0)
|
ANIMCMD_JUMP(0)
|
||||||
};
|
};
|
||||||
|
|
||||||
static const union AnimCmd sWirelessStatusIndicatorAnim4[] = {
|
static const union AnimCmd sWirelessStatusIndicator_Error[] = {
|
||||||
// error
|
|
||||||
ANIMCMD_FRAME(24, 10),
|
ANIMCMD_FRAME(24, 10),
|
||||||
ANIMCMD_FRAME( 4, 10),
|
ANIMCMD_FRAME( 4, 10),
|
||||||
ANIMCMD_JUMP(0)
|
ANIMCMD_JUMP(0)
|
||||||
};
|
};
|
||||||
|
|
||||||
static const union AnimCmd *const sWirelessStatusIndicatorAnims[] = {
|
static const union AnimCmd *const sWirelessStatusIndicatorAnims[] = {
|
||||||
sWirelessStatusIndicatorAnim0,
|
[WIRELESS_STATUS_ANIM_3_BARS] = sWirelessStatusIndicator_3Bars,
|
||||||
sWirelessStatusIndicatorAnim1,
|
[WIRELESS_STATUS_ANIM_2_BARS] = sWirelessStatusIndicator_2Bars,
|
||||||
sWirelessStatusIndicatorAnim2,
|
[WIRELESS_STATUS_ANIM_1_BAR] = sWirelessStatusIndicator_1Bar,
|
||||||
sWirelessStatusIndicatorAnim3,
|
[WIRELESS_STATUS_ANIM_SEARCHING] = sWirelessStatusIndicator_Searching,
|
||||||
sWirelessStatusIndicatorAnim4
|
[WIRELESS_STATUS_ANIM_ERROR] = sWirelessStatusIndicator_Error
|
||||||
};
|
};
|
||||||
|
|
||||||
static const struct CompressedSpriteSheet sWirelessStatusIndicatorSpriteSheet = {
|
static const struct CompressedSpriteSheet sWirelessStatusIndicatorSpriteSheet = {
|
||||||
gWirelessLinkIconPic, 0x0380, 0xD431
|
sWirelessLinkIconPic, 0x0380, TAG_GFX_STATUS_INDICATOR
|
||||||
};
|
};
|
||||||
|
|
||||||
static const struct SpritePalette sWirelessStatusIndicatorSpritePalette = {
|
static const struct SpritePalette sWirelessStatusIndicatorSpritePalette = {
|
||||||
gWirelessLinkIconPalette, 0xD432
|
sWirelessLinkIconPalette, TAG_PAL_STATUS_INDICATOR
|
||||||
};
|
};
|
||||||
|
|
||||||
static const struct SpriteTemplate sWirelessStatusIndicatorSpriteTemplate = {
|
static const struct SpriteTemplate sWirelessStatusIndicatorSpriteTemplate = {
|
||||||
.tileTag = 0xD431,
|
.tileTag = TAG_GFX_STATUS_INDICATOR,
|
||||||
.paletteTag = 0xD432,
|
.paletteTag = TAG_PAL_STATUS_INDICATOR,
|
||||||
.oam = &sWirelessStatusIndicatorOamData,
|
.oam = &sWirelessStatusIndicatorOamData,
|
||||||
.anims = sWirelessStatusIndicatorAnims,
|
.anims = sWirelessStatusIndicatorAnims,
|
||||||
.images = NULL,
|
.images = NULL,
|
||||||
@@ -301,8 +319,8 @@ void RfuRecvQueue_Reset(struct RfuRecvQueue *queue)
|
|||||||
for (j = 0; j < COMM_SLOT_LENGTH * MAX_RFU_PLAYERS; j++)
|
for (j = 0; j < COMM_SLOT_LENGTH * MAX_RFU_PLAYERS; j++)
|
||||||
queue->slots[i][j] = 0;
|
queue->slots[i][j] = 0;
|
||||||
}
|
}
|
||||||
queue->send_slot = 0;
|
queue->sendSlot = 0;
|
||||||
queue->recv_slot = 0;
|
queue->recvSlot = 0;
|
||||||
queue->count = 0;
|
queue->count = 0;
|
||||||
queue->full = FALSE;
|
queue->full = FALSE;
|
||||||
}
|
}
|
||||||
@@ -317,8 +335,8 @@ void RfuSendQueue_Reset(struct RfuSendQueue *queue)
|
|||||||
for (j = 0; j < COMM_SLOT_LENGTH; j++)
|
for (j = 0; j < COMM_SLOT_LENGTH; j++)
|
||||||
queue->slots[i][j] = 0;
|
queue->slots[i][j] = 0;
|
||||||
}
|
}
|
||||||
queue->send_slot = 0;
|
queue->sendSlot = 0;
|
||||||
queue->recv_slot = 0;
|
queue->recvSlot = 0;
|
||||||
queue->count = 0;
|
queue->count = 0;
|
||||||
queue->full = FALSE;
|
queue->full = FALSE;
|
||||||
}
|
}
|
||||||
@@ -331,12 +349,10 @@ static void RfuUnusedQueue_Reset(struct RfuUnusedQueue *queue)
|
|||||||
for (i = 0; i < UNUSED_QUEUE_NUM_SLOTS; i++)
|
for (i = 0; i < UNUSED_QUEUE_NUM_SLOTS; i++)
|
||||||
{
|
{
|
||||||
for (j = 0; j < UNUSED_QUEUE_SLOT_LENGTH; j++)
|
for (j = 0; j < UNUSED_QUEUE_SLOT_LENGTH; j++)
|
||||||
{
|
|
||||||
queue->slots[i][j] = 0;
|
queue->slots[i][j] = 0;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
queue->send_slot = 0;
|
queue->sendSlot = 0;
|
||||||
queue->recv_slot = 0;
|
queue->recvSlot = 0;
|
||||||
queue->count = 0;
|
queue->count = 0;
|
||||||
queue->full = FALSE;
|
queue->full = FALSE;
|
||||||
}
|
}
|
||||||
@@ -360,9 +376,9 @@ void RfuRecvQueue_Enqueue(struct RfuRecvQueue *queue, u8 *src)
|
|||||||
if (count != MAX_RFU_PLAYERS)
|
if (count != MAX_RFU_PLAYERS)
|
||||||
{
|
{
|
||||||
for (i = 0; i < COMM_SLOT_LENGTH * MAX_RFU_PLAYERS; i++)
|
for (i = 0; i < COMM_SLOT_LENGTH * MAX_RFU_PLAYERS; i++)
|
||||||
queue->slots[queue->recv_slot][i] = src[i];
|
queue->slots[queue->recvSlot][i] = src[i];
|
||||||
queue->recv_slot++;
|
queue->recvSlot++;
|
||||||
queue->recv_slot %= RECV_QUEUE_NUM_SLOTS;
|
queue->recvSlot %= RECV_QUEUE_NUM_SLOTS;
|
||||||
queue->count++;
|
queue->count++;
|
||||||
for (i = 0; i < COMM_SLOT_LENGTH * MAX_RFU_PLAYERS; i++)
|
for (i = 0; i < COMM_SLOT_LENGTH * MAX_RFU_PLAYERS; i++)
|
||||||
src[i] = 0;
|
src[i] = 0;
|
||||||
@@ -392,9 +408,9 @@ void RfuSendQueue_Enqueue(struct RfuSendQueue *queue, u8 *src)
|
|||||||
if (i != COMM_SLOT_LENGTH)
|
if (i != COMM_SLOT_LENGTH)
|
||||||
{
|
{
|
||||||
for (i = 0; i < COMM_SLOT_LENGTH; i++)
|
for (i = 0; i < COMM_SLOT_LENGTH; i++)
|
||||||
queue->slots[queue->recv_slot][i] = src[i];
|
queue->slots[queue->recvSlot][i] = src[i];
|
||||||
queue->recv_slot++;
|
queue->recvSlot++;
|
||||||
queue->recv_slot %= SEND_QUEUE_NUM_SLOTS;
|
queue->recvSlot %= SEND_QUEUE_NUM_SLOTS;
|
||||||
queue->count++;
|
queue->count++;
|
||||||
for (i = 0; i < COMM_SLOT_LENGTH; i++)
|
for (i = 0; i < COMM_SLOT_LENGTH; i++)
|
||||||
src[i] = 0;
|
src[i] = 0;
|
||||||
@@ -414,7 +430,7 @@ bool8 RfuRecvQueue_Dequeue(struct RfuRecvQueue *queue, u8 *dest)
|
|||||||
|
|
||||||
imeBak = REG_IME;
|
imeBak = REG_IME;
|
||||||
REG_IME = 0;
|
REG_IME = 0;
|
||||||
if (queue->recv_slot == queue->send_slot || queue->full)
|
if (queue->recvSlot == queue->sendSlot || queue->full)
|
||||||
{
|
{
|
||||||
for (i = 0; i < COMM_SLOT_LENGTH * MAX_RFU_PLAYERS; i++)
|
for (i = 0; i < COMM_SLOT_LENGTH * MAX_RFU_PLAYERS; i++)
|
||||||
dest[i] = 0;
|
dest[i] = 0;
|
||||||
@@ -422,9 +438,9 @@ bool8 RfuRecvQueue_Dequeue(struct RfuRecvQueue *queue, u8 *dest)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
for (i = 0; i < COMM_SLOT_LENGTH * MAX_RFU_PLAYERS; i++)
|
for (i = 0; i < COMM_SLOT_LENGTH * MAX_RFU_PLAYERS; i++)
|
||||||
dest[i] = queue->slots[queue->send_slot][i];
|
dest[i] = queue->slots[queue->sendSlot][i];
|
||||||
queue->send_slot++;
|
queue->sendSlot++;
|
||||||
queue->send_slot %= RECV_QUEUE_NUM_SLOTS;
|
queue->sendSlot %= RECV_QUEUE_NUM_SLOTS;
|
||||||
queue->count--;
|
queue->count--;
|
||||||
REG_IME = imeBak;
|
REG_IME = imeBak;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@@ -435,14 +451,14 @@ bool8 RfuSendQueue_Dequeue(struct RfuSendQueue *queue, u8 *dest)
|
|||||||
s32 i;
|
s32 i;
|
||||||
u16 imeBak;
|
u16 imeBak;
|
||||||
|
|
||||||
if (queue->recv_slot == queue->send_slot || queue->full)
|
if (queue->recvSlot == queue->sendSlot || queue->full)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
imeBak = REG_IME;
|
imeBak = REG_IME;
|
||||||
REG_IME = 0;
|
REG_IME = 0;
|
||||||
for (i = 0; i < COMM_SLOT_LENGTH; i++)
|
for (i = 0; i < COMM_SLOT_LENGTH; i++)
|
||||||
dest[i] = queue->slots[queue->send_slot][i];
|
dest[i] = queue->slots[queue->sendSlot][i];
|
||||||
queue->send_slot++;
|
queue->sendSlot++;
|
||||||
queue->send_slot %= SEND_QUEUE_NUM_SLOTS;
|
queue->sendSlot %= SEND_QUEUE_NUM_SLOTS;
|
||||||
queue->count--;
|
queue->count--;
|
||||||
REG_IME = imeBak;
|
REG_IME = imeBak;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@@ -459,17 +475,13 @@ void RfuBackupQueue_Enqueue(struct RfuBackupQueue *queue, const u8 *dest)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (i = 0; i < COMM_SLOT_LENGTH; i++)
|
for (i = 0; i < COMM_SLOT_LENGTH; i++)
|
||||||
queue->slots[queue->recv_slot][i] = dest[i];
|
queue->slots[queue->recvSlot][i] = dest[i];
|
||||||
queue->recv_slot++;
|
queue->recvSlot++;
|
||||||
queue->recv_slot %= BACKUP_QUEUE_NUM_SLOTS;
|
queue->recvSlot %= BACKUP_QUEUE_NUM_SLOTS;
|
||||||
if (queue->count < BACKUP_QUEUE_NUM_SLOTS)
|
if (queue->count < BACKUP_QUEUE_NUM_SLOTS)
|
||||||
{
|
|
||||||
queue->count++;
|
queue->count++;
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
queue->sendSlot = queue->recvSlot;
|
||||||
queue->send_slot = queue->recv_slot;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -478,16 +490,15 @@ bool8 RfuBackupQueue_Dequeue(struct RfuBackupQueue *queue, u8 *dest)
|
|||||||
s32 i;
|
s32 i;
|
||||||
|
|
||||||
if (queue->count == 0)
|
if (queue->count == 0)
|
||||||
{
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
|
||||||
if (dest != NULL)
|
if (dest != NULL)
|
||||||
{
|
{
|
||||||
for (i = 0; i < COMM_SLOT_LENGTH; i++)
|
for (i = 0; i < COMM_SLOT_LENGTH; i++)
|
||||||
dest[i] = queue->slots[queue->send_slot][i];
|
dest[i] = queue->slots[queue->sendSlot][i];
|
||||||
}
|
}
|
||||||
queue->send_slot++;
|
queue->sendSlot++;
|
||||||
queue->send_slot %= BACKUP_QUEUE_NUM_SLOTS;
|
queue->sendSlot %= BACKUP_QUEUE_NUM_SLOTS;
|
||||||
queue->count--;
|
queue->count--;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
@@ -499,11 +510,9 @@ static void RfuUnusedQueue_Dequeue(struct RfuUnusedQueue *queue, u8 *dest)
|
|||||||
if (queue->count < UNUSED_QUEUE_NUM_SLOTS)
|
if (queue->count < UNUSED_QUEUE_NUM_SLOTS)
|
||||||
{
|
{
|
||||||
for (i = 0; i < UNUSED_QUEUE_SLOT_LENGTH; i++)
|
for (i = 0; i < UNUSED_QUEUE_SLOT_LENGTH; i++)
|
||||||
{
|
queue->slots[queue->recvSlot][i] = dest[i];
|
||||||
queue->slots[queue->recv_slot][i] = dest[i];
|
queue->recvSlot++;
|
||||||
}
|
queue->recvSlot %= UNUSED_QUEUE_NUM_SLOTS;
|
||||||
queue->recv_slot++;
|
|
||||||
queue->recv_slot %= UNUSED_QUEUE_NUM_SLOTS;
|
|
||||||
queue->count++;
|
queue->count++;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -516,16 +525,14 @@ static bool8 RfuUnusedQueue_Enqueue(struct RfuUnusedQueue *queue, u8 *dest)
|
|||||||
{
|
{
|
||||||
s32 i;
|
s32 i;
|
||||||
|
|
||||||
if (queue->recv_slot == queue->send_slot || queue->full)
|
if (queue->recvSlot == queue->sendSlot || queue->full)
|
||||||
{
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
|
||||||
for (i = 0; i < UNUSED_QUEUE_SLOT_LENGTH; i++)
|
for (i = 0; i < UNUSED_QUEUE_SLOT_LENGTH; i++)
|
||||||
{
|
dest[i] = queue->slots[queue->sendSlot][i];
|
||||||
dest[i] = queue->slots[queue->send_slot][i];
|
|
||||||
}
|
queue->sendSlot++;
|
||||||
queue->send_slot++;
|
queue->sendSlot %= UNUSED_QUEUE_NUM_SLOTS;
|
||||||
queue->send_slot %= UNUSED_QUEUE_NUM_SLOTS;
|
|
||||||
queue->count--;
|
queue->count--;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
@@ -593,9 +600,7 @@ static void PkmnStrToASCII(u8 *dest, const u8 *src)
|
|||||||
s32 i;
|
s32 i;
|
||||||
|
|
||||||
for (i = 0; src[i] != EOS; i++)
|
for (i = 0; src[i] != EOS; i++)
|
||||||
{
|
|
||||||
dest[i] = sWireless_RSEtoASCIITable[src[i]];
|
dest[i] = sWireless_RSEtoASCIITable[src[i]];
|
||||||
}
|
|
||||||
dest[i] = 0;
|
dest[i] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -604,9 +609,7 @@ static void ASCIIToPkmnStr(u8 *dest, const u8 *src)
|
|||||||
s32 i;
|
s32 i;
|
||||||
|
|
||||||
for (i = 0; src[i] != 0; i++)
|
for (i = 0; src[i] != 0; i++)
|
||||||
{
|
|
||||||
dest[i] = sWireless_ASCIItoRSETable[src[i]];
|
dest[i] = sWireless_ASCIItoRSETable[src[i]];
|
||||||
}
|
|
||||||
dest[i] = EOS;
|
dest[i] = EOS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -644,18 +647,17 @@ static u8 GetConnectedChildStrength(u8 maxFlags)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void InitHostRFUtgtGname(struct RfuGameData *data, u8 activity, bool32 startedActivity, s32 partnerInfo)
|
void InitHostRfuGameData(struct RfuGameData *data, u8 activity, bool32 startedActivity, s32 partnerInfo)
|
||||||
{
|
{
|
||||||
s32 i;
|
s32 i;
|
||||||
|
|
||||||
for (i = 0; i < 2; i++)
|
for (i = 0; i < (s32)ARRAY_COUNT(data->compatibility.playerTrainerId); i++)
|
||||||
{
|
|
||||||
data->compatibility.playerTrainerId[i] = gSaveBlock2Ptr->playerTrainerId[i];
|
data->compatibility.playerTrainerId[i] = gSaveBlock2Ptr->playerTrainerId[i];
|
||||||
}
|
|
||||||
for (i = 0; i < RFU_CHILD_MAX; i++)
|
for (i = 0; i < RFU_CHILD_MAX; i++)
|
||||||
{
|
{
|
||||||
data->partnerInfo[i] = partnerInfo;
|
data->partnerInfo[i] = partnerInfo;
|
||||||
partnerInfo >>= 8;
|
partnerInfo >>= 8; // Each element is 1 byte
|
||||||
}
|
}
|
||||||
data->playerGender = gSaveBlock2Ptr->playerGender;
|
data->playerGender = gSaveBlock2Ptr->playerGender;
|
||||||
data->activity = activity;
|
data->activity = activity;
|
||||||
@@ -671,13 +673,13 @@ void InitHostRFUtgtGname(struct RfuGameData *data, u8 activity, bool32 startedAc
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* ==========================================================
|
* ================================================================
|
||||||
* Returns 1 if parent, 0 if child or neutral.
|
* Returns 1 if parent, 0 if child or neutral.
|
||||||
* If partner serial number is valid, copies gname and uname.
|
* If partner serial number is valid, copies gameData and username.
|
||||||
* Otherwise, blanks these.
|
* Otherwise, blanks these.
|
||||||
* ==========================================================
|
* ================================================================
|
||||||
*/
|
*/
|
||||||
bool8 LinkRfu_GetNameIfCompatible(struct RfuGameData *gname, u8 *uname, u8 idx)
|
bool8 Rfu_GetCompatiblePlayerData(struct RfuGameData *gameData, u8 *username, u8 idx)
|
||||||
{
|
{
|
||||||
bool8 retVal;
|
bool8 retVal;
|
||||||
|
|
||||||
@@ -686,13 +688,13 @@ bool8 LinkRfu_GetNameIfCompatible(struct RfuGameData *gname, u8 *uname, u8 idx)
|
|||||||
retVal = TRUE;
|
retVal = TRUE;
|
||||||
if (IsRfuSerialNumberValid(gRfuLinkStatus->partner[idx].serialNo) && ((gRfuLinkStatus->getNameFlag >> idx) & 1))
|
if (IsRfuSerialNumberValid(gRfuLinkStatus->partner[idx].serialNo) && ((gRfuLinkStatus->getNameFlag >> idx) & 1))
|
||||||
{
|
{
|
||||||
memcpy(gname, &gRfuLinkStatus->partner[idx].gname, RFU_GAME_NAME_LENGTH);
|
memcpy(gameData, gRfuLinkStatus->partner[idx].gname, RFU_GAME_NAME_LENGTH);
|
||||||
memcpy(uname, gRfuLinkStatus->partner[idx].uname, RFU_USER_NAME_LENGTH);
|
memcpy(username, gRfuLinkStatus->partner[idx].uname, RFU_USER_NAME_LENGTH);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
memset(gname, 0, RFU_GAME_NAME_LENGTH);
|
memset(gameData, 0, RFU_GAME_NAME_LENGTH);
|
||||||
memset(uname, 0, RFU_USER_NAME_LENGTH);
|
memset(username, 0, RFU_USER_NAME_LENGTH);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -700,45 +702,39 @@ bool8 LinkRfu_GetNameIfCompatible(struct RfuGameData *gname, u8 *uname, u8 idx)
|
|||||||
retVal = FALSE;
|
retVal = FALSE;
|
||||||
if (IsRfuSerialNumberValid(gRfuLinkStatus->partner[idx].serialNo))
|
if (IsRfuSerialNumberValid(gRfuLinkStatus->partner[idx].serialNo))
|
||||||
{
|
{
|
||||||
memcpy(gname, &gRfuLinkStatus->partner[idx].gname, RFU_GAME_NAME_LENGTH);
|
memcpy(gameData, gRfuLinkStatus->partner[idx].gname, RFU_GAME_NAME_LENGTH);
|
||||||
memcpy(uname, gRfuLinkStatus->partner[idx].uname, RFU_USER_NAME_LENGTH);
|
memcpy(username, gRfuLinkStatus->partner[idx].uname, RFU_USER_NAME_LENGTH);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
memset(gname, 0, RFU_GAME_NAME_LENGTH);
|
memset(gameData, 0, RFU_GAME_NAME_LENGTH);
|
||||||
memset(uname, 0, RFU_USER_NAME_LENGTH);
|
memset(username, 0, RFU_USER_NAME_LENGTH);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
bool8 Rfu_GetWonderDistributorPlayerData(struct RfuGameData *gameData, u8 *username, u8 idx)
|
||||||
* ==========================================================
|
|
||||||
* Specific check for serial number 0x7F7D,
|
|
||||||
* which comes from ???
|
|
||||||
* ==========================================================
|
|
||||||
*/
|
|
||||||
bool8 LinkRfu_GetNameIfSerial7F7D(struct RfuGameData *gname, u8 *uname, u8 idx)
|
|
||||||
{
|
{
|
||||||
bool8 retVal = FALSE;
|
bool8 retVal = FALSE;
|
||||||
if (gRfuLinkStatus->partner[idx].serialNo == RFU_SERIAL_WONDER_DISTRIBUTOR)
|
if (gRfuLinkStatus->partner[idx].serialNo == RFU_SERIAL_WONDER_DISTRIBUTOR)
|
||||||
{
|
{
|
||||||
memcpy(gname, gRfuLinkStatus->partner[idx].gname, RFU_GAME_NAME_LENGTH);
|
memcpy(gameData, gRfuLinkStatus->partner[idx].gname, RFU_GAME_NAME_LENGTH);
|
||||||
memcpy(uname, gRfuLinkStatus->partner[idx].uname, RFU_USER_NAME_LENGTH);
|
memcpy(username, gRfuLinkStatus->partner[idx].uname, RFU_USER_NAME_LENGTH);
|
||||||
retVal = TRUE;
|
retVal = TRUE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
memset(gname, 0, RFU_GAME_NAME_LENGTH);
|
memset(gameData, 0, RFU_GAME_NAME_LENGTH);
|
||||||
memset(uname, 0, RFU_USER_NAME_LENGTH);
|
memset(username, 0, RFU_USER_NAME_LENGTH);
|
||||||
}
|
}
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LinkRfu3_SetGnameUnameFromStaticBuffers(struct RfuGameData *gname, u8 *uname)
|
void CopyHostRfuGameDataAndUsername(struct RfuGameData *gameData, u8 *username)
|
||||||
{
|
{
|
||||||
memcpy(gname, &gHostRfuGameData, RFU_GAME_NAME_LENGTH);
|
memcpy(gameData, &gHostRfuGameData, RFU_GAME_NAME_LENGTH);
|
||||||
memcpy(uname, gHostRfuUsername, RFU_USER_NAME_LENGTH);
|
memcpy(username, gHostRfuUsername, RFU_USER_NAME_LENGTH);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define sNextAnimNum data[0]
|
#define sNextAnimNum data[0]
|
||||||
@@ -765,23 +761,23 @@ void CreateWirelessStatusIndicatorSprite(u8 x, u8 y)
|
|||||||
gSprites[sprId].sValidator = STATUS_INDICATOR_ACTIVE;
|
gSprites[sprId].sValidator = STATUS_INDICATOR_ACTIVE;
|
||||||
gSprites[sprId].sTileStart = GetSpriteTileStartByTag(sWirelessStatusIndicatorSpriteSheet.tag);
|
gSprites[sprId].sTileStart = GetSpriteTileStartByTag(sWirelessStatusIndicatorSpriteSheet.tag);
|
||||||
gSprites[sprId].invisible = TRUE;
|
gSprites[sprId].invisible = TRUE;
|
||||||
gWirelessStatusIndicatorSpriteId = sprId;
|
sWirelessStatusIndicatorSpriteId = sprId;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
gWirelessStatusIndicatorSpriteId = CreateSprite(&sWirelessStatusIndicatorSpriteTemplate, x, y, 0);
|
sWirelessStatusIndicatorSpriteId = CreateSprite(&sWirelessStatusIndicatorSpriteTemplate, x, y, 0);
|
||||||
gSprites[gWirelessStatusIndicatorSpriteId].sValidator = STATUS_INDICATOR_ACTIVE;
|
gSprites[sWirelessStatusIndicatorSpriteId].sValidator = STATUS_INDICATOR_ACTIVE;
|
||||||
gSprites[gWirelessStatusIndicatorSpriteId].sTileStart = GetSpriteTileStartByTag(sWirelessStatusIndicatorSpriteSheet.tag);
|
gSprites[sWirelessStatusIndicatorSpriteId].sTileStart = GetSpriteTileStartByTag(sWirelessStatusIndicatorSpriteSheet.tag);
|
||||||
gSprites[gWirelessStatusIndicatorSpriteId].invisible = TRUE;
|
gSprites[sWirelessStatusIndicatorSpriteId].invisible = TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DestroyWirelessStatusIndicatorSprite(void)
|
void DestroyWirelessStatusIndicatorSprite(void)
|
||||||
{
|
{
|
||||||
if (gSprites[gWirelessStatusIndicatorSpriteId].sValidator == STATUS_INDICATOR_ACTIVE)
|
if (gSprites[sWirelessStatusIndicatorSpriteId].sValidator == STATUS_INDICATOR_ACTIVE)
|
||||||
{
|
{
|
||||||
gSprites[gWirelessStatusIndicatorSpriteId].sValidator = 0;
|
gSprites[sWirelessStatusIndicatorSpriteId].sValidator = 0;
|
||||||
DestroySprite(&gSprites[gWirelessStatusIndicatorSpriteId]);
|
DestroySprite(&gSprites[sWirelessStatusIndicatorSpriteId]);
|
||||||
gMain.oamBuffer[125] = gDummyOamData;
|
gMain.oamBuffer[125] = gDummyOamData;
|
||||||
CpuCopy16(&gDummyOamData, (struct OamData *)OAM + 125, sizeof(struct OamData));
|
CpuCopy16(&gDummyOamData, (struct OamData *)OAM + 125, sizeof(struct OamData));
|
||||||
}
|
}
|
||||||
@@ -790,11 +786,9 @@ void DestroyWirelessStatusIndicatorSprite(void)
|
|||||||
void LoadWirelessStatusIndicatorSpriteGfx(void)
|
void LoadWirelessStatusIndicatorSpriteGfx(void)
|
||||||
{
|
{
|
||||||
if (GetSpriteTileStartByTag(sWirelessStatusIndicatorSpriteSheet.tag) == 0xFFFF)
|
if (GetSpriteTileStartByTag(sWirelessStatusIndicatorSpriteSheet.tag) == 0xFFFF)
|
||||||
{
|
|
||||||
LoadCompressedSpriteSheet(&sWirelessStatusIndicatorSpriteSheet);
|
LoadCompressedSpriteSheet(&sWirelessStatusIndicatorSpriteSheet);
|
||||||
}
|
|
||||||
LoadSpritePalette(&sWirelessStatusIndicatorSpritePalette);
|
LoadSpritePalette(&sWirelessStatusIndicatorSpritePalette);
|
||||||
gWirelessStatusIndicatorSpriteId = 0xFF;
|
sWirelessStatusIndicatorSpriteId = SPRITE_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static u8 GetParentSignalStrength(void)
|
static u8 GetParentSignalStrength(void)
|
||||||
@@ -804,19 +798,17 @@ static u8 GetParentSignalStrength(void)
|
|||||||
for (i = 0; i < RFU_CHILD_MAX; i++)
|
for (i = 0; i < RFU_CHILD_MAX; i++)
|
||||||
{
|
{
|
||||||
if (flags & 1)
|
if (flags & 1)
|
||||||
{
|
|
||||||
return gRfuLinkStatus->strength[i];
|
return gRfuLinkStatus->strength[i];
|
||||||
}
|
|
||||||
flags >>= 1;
|
flags >>= 1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SetAndRestartWirelessStatusIndicatorAnim(struct Sprite *sprite, s32 signalStrengthAnimNum)
|
static void SetAndRestartWirelessStatusIndicatorAnim(struct Sprite *sprite, s32 animNum)
|
||||||
{
|
{
|
||||||
if (sprite->sCurrAnimNum != signalStrengthAnimNum)
|
if (sprite->sCurrAnimNum != animNum)
|
||||||
{
|
{
|
||||||
sprite->sCurrAnimNum = signalStrengthAnimNum;
|
sprite->sCurrAnimNum = animNum;
|
||||||
sprite->sFrameDelay = 0;
|
sprite->sFrameDelay = 0;
|
||||||
sprite->sFrameIdx = 0;
|
sprite->sFrameIdx = 0;
|
||||||
}
|
}
|
||||||
@@ -824,45 +816,38 @@ static void SetAndRestartWirelessStatusIndicatorAnim(struct Sprite *sprite, s32
|
|||||||
|
|
||||||
void UpdateWirelessStatusIndicatorSprite(void)
|
void UpdateWirelessStatusIndicatorSprite(void)
|
||||||
{
|
{
|
||||||
if (gWirelessStatusIndicatorSpriteId != 0xFF && gSprites[gWirelessStatusIndicatorSpriteId].sValidator == STATUS_INDICATOR_ACTIVE)
|
if (sWirelessStatusIndicatorSpriteId != SPRITE_NONE && gSprites[sWirelessStatusIndicatorSpriteId].sValidator == STATUS_INDICATOR_ACTIVE)
|
||||||
{
|
{
|
||||||
struct Sprite *sprite = &gSprites[gWirelessStatusIndicatorSpriteId];
|
struct Sprite *sprite = &gSprites[sWirelessStatusIndicatorSpriteId];
|
||||||
u8 signalStrength = RFU_LINK_ICON_LEVEL4_MAX;
|
u8 signalStrength = RFU_LINK_ICON_LEVEL4_MAX;
|
||||||
u8 i = 0;
|
u8 i = 0;
|
||||||
|
|
||||||
|
// Get weakest signal strength
|
||||||
if (gRfuLinkStatus->parentChild == MODE_PARENT)
|
if (gRfuLinkStatus->parentChild == MODE_PARENT)
|
||||||
{
|
{
|
||||||
for (i = 0; i < GetLinkPlayerCount() - 1; i++)
|
for (i = 0; i < GetLinkPlayerCount() - 1; i++)
|
||||||
{
|
{
|
||||||
if (signalStrength >= GetConnectedChildStrength(i + 1))
|
if (signalStrength >= GetConnectedChildStrength(i + 1))
|
||||||
{
|
|
||||||
signalStrength = GetConnectedChildStrength(i + 1);
|
signalStrength = GetConnectedChildStrength(i + 1);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
signalStrength = GetParentSignalStrength();
|
signalStrength = GetParentSignalStrength();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set signal strength sprite anim number
|
||||||
if (IsRfuRecoveringFromLinkLoss() == TRUE)
|
if (IsRfuRecoveringFromLinkLoss() == TRUE)
|
||||||
{
|
sprite->sNextAnimNum = WIRELESS_STATUS_ANIM_ERROR;
|
||||||
sprite->sNextAnimNum = 4;
|
|
||||||
}
|
|
||||||
else if (signalStrength <= RFU_LINK_ICON_LEVEL1_MAX)
|
else if (signalStrength <= RFU_LINK_ICON_LEVEL1_MAX)
|
||||||
{
|
sprite->sNextAnimNum = WIRELESS_STATUS_ANIM_SEARCHING;
|
||||||
sprite->sNextAnimNum = 3;
|
|
||||||
}
|
|
||||||
else if (signalStrength >= RFU_LINK_ICON_LEVEL2_MIN && signalStrength <= RFU_LINK_ICON_LEVEL2_MAX)
|
else if (signalStrength >= RFU_LINK_ICON_LEVEL2_MIN && signalStrength <= RFU_LINK_ICON_LEVEL2_MAX)
|
||||||
{
|
sprite->sNextAnimNum = WIRELESS_STATUS_ANIM_1_BAR;
|
||||||
sprite->sNextAnimNum = 2;
|
|
||||||
}
|
|
||||||
else if (signalStrength >= RFU_LINK_ICON_LEVEL3_MIN && signalStrength <= RFU_LINK_ICON_LEVEL3_MAX)
|
else if (signalStrength >= RFU_LINK_ICON_LEVEL3_MIN && signalStrength <= RFU_LINK_ICON_LEVEL3_MAX)
|
||||||
{
|
sprite->sNextAnimNum = WIRELESS_STATUS_ANIM_2_BARS;
|
||||||
sprite->sNextAnimNum = 1;
|
|
||||||
}
|
|
||||||
else if (signalStrength >= RFU_LINK_ICON_LEVEL4_MIN)
|
else if (signalStrength >= RFU_LINK_ICON_LEVEL4_MIN)
|
||||||
{
|
sprite->sNextAnimNum = WIRELESS_STATUS_ANIM_3_BARS;
|
||||||
sprite->sNextAnimNum = 0;
|
|
||||||
}
|
|
||||||
if (sprite->sNextAnimNum != sprite->sSavedAnimNum)
|
if (sprite->sNextAnimNum != sprite->sSavedAnimNum)
|
||||||
{
|
{
|
||||||
SetAndRestartWirelessStatusIndicatorAnim(sprite, sprite->sNextAnimNum);
|
SetAndRestartWirelessStatusIndicatorAnim(sprite, sprite->sNextAnimNum);
|
||||||
@@ -873,9 +858,7 @@ void UpdateWirelessStatusIndicatorSprite(void)
|
|||||||
sprite->sFrameIdx++;
|
sprite->sFrameIdx++;
|
||||||
sprite->sFrameDelay = 0;
|
sprite->sFrameDelay = 0;
|
||||||
if (sprite->anims[sprite->sCurrAnimNum][sprite->sFrameIdx].type == -2) // ANIMCMD_JUMP
|
if (sprite->anims[sprite->sCurrAnimNum][sprite->sFrameIdx].type == -2) // ANIMCMD_JUMP
|
||||||
{
|
|
||||||
sprite->sFrameIdx = 0;
|
sprite->sFrameIdx = 0;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -906,7 +889,7 @@ static void CopyTrainerRecord(struct TrainerNameRecord *dest, u32 trainerId, con
|
|||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
dest->trainerId = trainerId;
|
dest->trainerId = trainerId;
|
||||||
for (i = 0; i < 7; i++)
|
for (i = 0; i < PLAYER_NAME_LENGTH; i++)
|
||||||
{
|
{
|
||||||
if (name[i] == EOS)
|
if (name[i] == EOS)
|
||||||
break;
|
break;
|
||||||
@@ -920,9 +903,7 @@ static void ZeroName(u8 *name)
|
|||||||
s32 i;
|
s32 i;
|
||||||
|
|
||||||
for (i = 0; i < PLAYER_NAME_LENGTH + 1; i++)
|
for (i = 0; i < PLAYER_NAME_LENGTH + 1; i++)
|
||||||
{
|
|
||||||
*name++ = 0;
|
*name++ = 0;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool32 NameIsEmpty(const u8 *name)
|
static bool32 NameIsEmpty(const u8 *name)
|
||||||
@@ -932,15 +913,13 @@ static bool32 NameIsEmpty(const u8 *name)
|
|||||||
for (i = 0; i < PLAYER_NAME_LENGTH + 1; i++)
|
for (i = 0; i < PLAYER_NAME_LENGTH + 1; i++)
|
||||||
{
|
{
|
||||||
if (*name++ != 0)
|
if (*name++ != 0)
|
||||||
{
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save the currently connected players into the trainer records, shifting all previous records down.
|
// Save the currently connected players into the trainer records, shifting all previous records down.
|
||||||
void RecordMixTrainerNames(void)
|
void SaveLinkTrainerNames(void)
|
||||||
{
|
{
|
||||||
if (gWirelessCommType != 0)
|
if (gWirelessCommType != 0)
|
||||||
{
|
{
|
||||||
@@ -948,13 +927,13 @@ void RecordMixTrainerNames(void)
|
|||||||
s32 j;
|
s32 j;
|
||||||
s32 nextSpace;
|
s32 nextSpace;
|
||||||
s32 connectedTrainerRecordIndices[5];
|
s32 connectedTrainerRecordIndices[5];
|
||||||
struct TrainerNameRecord *newRecords = AllocZeroed(20 * sizeof(struct TrainerNameRecord));
|
struct TrainerNameRecord *newRecords = AllocZeroed(sizeof(gSaveBlock1Ptr->trainerNameRecords));
|
||||||
|
|
||||||
// Check if we already have a record saved for connected trainers.
|
// Check if we already have a record saved for connected trainers.
|
||||||
for (i = 0; i < GetLinkPlayerCount(); i++)
|
for (i = 0; i < GetLinkPlayerCount(); i++)
|
||||||
{
|
{
|
||||||
connectedTrainerRecordIndices[i] = -1;
|
connectedTrainerRecordIndices[i] = -1;
|
||||||
for (j = 0; j < 20; j++)
|
for (j = 0; j < (int)ARRAY_COUNT(gSaveBlock1Ptr->trainerNameRecords); j++)
|
||||||
{
|
{
|
||||||
if ((u16)gLinkPlayers[i].trainerId == gSaveBlock1Ptr->trainerNameRecords[j].trainerId && StringCompare(gLinkPlayers[i].name, gSaveBlock1Ptr->trainerNameRecords[j].trainerName) == 0)
|
if ((u16)gLinkPlayers[i].trainerId == gSaveBlock1Ptr->trainerNameRecords[j].trainerId && StringCompare(gLinkPlayers[i].name, gSaveBlock1Ptr->trainerNameRecords[j].trainerName) == 0)
|
||||||
{
|
{
|
||||||
@@ -973,29 +952,25 @@ void RecordMixTrainerNames(void)
|
|||||||
|
|
||||||
// If we already had a record for this trainer, wipe it so that the next step doesn't duplicate it.
|
// If we already had a record for this trainer, wipe it so that the next step doesn't duplicate it.
|
||||||
if (connectedTrainerRecordIndices[i] >= 0)
|
if (connectedTrainerRecordIndices[i] >= 0)
|
||||||
{
|
|
||||||
ZeroName(gSaveBlock1Ptr->trainerNameRecords[connectedTrainerRecordIndices[i]].trainerName);
|
ZeroName(gSaveBlock1Ptr->trainerNameRecords[connectedTrainerRecordIndices[i]].trainerName);
|
||||||
}
|
|
||||||
nextSpace++;
|
nextSpace++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Copy all non-empty records to the new list, in the order they appear on the old list. If the list is full,
|
// Copy all non-empty records to the new list, in the order they appear on the old list. If the list is full,
|
||||||
// the last (oldest) records will be dropped.
|
// the last (oldest) records will be dropped.
|
||||||
for (i = 0; i < 20; i++)
|
for (i = 0; i < (int)ARRAY_COUNT(gSaveBlock1Ptr->trainerNameRecords); i++)
|
||||||
{
|
{
|
||||||
if (!NameIsEmpty(gSaveBlock1Ptr->trainerNameRecords[i].trainerName))
|
if (!NameIsEmpty(gSaveBlock1Ptr->trainerNameRecords[i].trainerName))
|
||||||
{
|
{
|
||||||
CopyTrainerRecord(&newRecords[nextSpace], gSaveBlock1Ptr->trainerNameRecords[i].trainerId, gSaveBlock1Ptr->trainerNameRecords[i].trainerName);
|
CopyTrainerRecord(&newRecords[nextSpace], gSaveBlock1Ptr->trainerNameRecords[i].trainerId, gSaveBlock1Ptr->trainerNameRecords[i].trainerName);
|
||||||
if (++nextSpace >= 20)
|
if (++nextSpace >= (int)ARRAY_COUNT(gSaveBlock1Ptr->trainerNameRecords))
|
||||||
{
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Finalize the new list, and clean up.
|
// Finalize the new list, and clean up.
|
||||||
memcpy(gSaveBlock1Ptr->trainerNameRecords, newRecords, 20 * sizeof(struct TrainerNameRecord));
|
memcpy(gSaveBlock1Ptr->trainerNameRecords, newRecords, sizeof(gSaveBlock1Ptr->trainerNameRecords));
|
||||||
Free(newRecords);
|
Free(newRecords);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1004,16 +979,14 @@ bool32 PlayerHasMetTrainerBefore(u16 id, u8 *name)
|
|||||||
{
|
{
|
||||||
s32 i;
|
s32 i;
|
||||||
|
|
||||||
for (i = 0; i < 20; i++)
|
for (i = 0; i < (int)ARRAY_COUNT(gSaveBlock1Ptr->trainerNameRecords); i++)
|
||||||
{
|
{
|
||||||
if (StringCompareN(gSaveBlock1Ptr->trainerNameRecords[i].trainerName, name, 7) == 0 && gSaveBlock1Ptr->trainerNameRecords[i].trainerId == id)
|
if (StringCompareN(gSaveBlock1Ptr->trainerNameRecords[i].trainerName, name, PLAYER_NAME_LENGTH) == 0
|
||||||
{
|
&& gSaveBlock1Ptr->trainerNameRecords[i].trainerId == id)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
|
||||||
if (NameIsEmpty(gSaveBlock1Ptr->trainerNameRecords[i].trainerName))
|
if (NameIsEmpty(gSaveBlock1Ptr->trainerNameRecords[i].trainerName))
|
||||||
{
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-6
@@ -756,7 +756,7 @@ static void Task_TryBecomeLinkLeader(u8 taskId)
|
|||||||
data->field_8 = AllocZeroed(UROOM_MAX_PARTY_SIZE * sizeof(struct UnkStruct_x20));
|
data->field_8 = AllocZeroed(UROOM_MAX_PARTY_SIZE * sizeof(struct UnkStruct_x20));
|
||||||
BlankUnkStruct_x1CArray(data->field_4->arr, 4);
|
BlankUnkStruct_x1CArray(data->field_4->arr, 4);
|
||||||
BlankUnkStruct_x20Array(data->field_0->arr, UROOM_MAX_PARTY_SIZE);
|
BlankUnkStruct_x20Array(data->field_0->arr, UROOM_MAX_PARTY_SIZE);
|
||||||
LinkRfu3_SetGnameUnameFromStaticBuffers(&data->field_0->arr[0].gname_uname.gname, data->field_0->arr[0].gname_uname.uname);
|
CopyHostRfuGameDataAndUsername(&data->field_0->arr[0].gname_uname.gname, data->field_0->arr[0].gname_uname.uname);
|
||||||
data->field_0->arr[0].field_18 = 0;
|
data->field_0->arr[0].field_18 = 0;
|
||||||
data->field_0->arr[0].groupScheduledAnim = UNION_ROOM_SPAWN_IN;
|
data->field_0->arr[0].groupScheduledAnim = UNION_ROOM_SPAWN_IN;
|
||||||
data->field_0->arr[0].field_1A_1 = 0;
|
data->field_0->arr[0].field_1A_1 = 0;
|
||||||
@@ -1919,7 +1919,7 @@ static void Task_StartActivity(u8 taskId)
|
|||||||
case ACTIVITY_BPICK:
|
case ACTIVITY_BPICK:
|
||||||
case ACTIVITY_SPINTRADE:
|
case ACTIVITY_SPINTRADE:
|
||||||
case ACTIVITY_ITEMTRADE:
|
case ACTIVITY_ITEMTRADE:
|
||||||
RecordMixTrainerNames();
|
SaveLinkTrainerNames();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2089,7 +2089,7 @@ static void Task_MEvent_Leader(u8 taskId)
|
|||||||
data->field_8 = AllocZeroed(UROOM_MAX_PARTY_SIZE * sizeof(struct UnkStruct_x20));
|
data->field_8 = AllocZeroed(UROOM_MAX_PARTY_SIZE * sizeof(struct UnkStruct_x20));
|
||||||
BlankUnkStruct_x1CArray(data->field_4->arr, 4);
|
BlankUnkStruct_x1CArray(data->field_4->arr, 4);
|
||||||
BlankUnkStruct_x20Array(data->field_0->arr, UROOM_MAX_PARTY_SIZE);
|
BlankUnkStruct_x20Array(data->field_0->arr, UROOM_MAX_PARTY_SIZE);
|
||||||
LinkRfu3_SetGnameUnameFromStaticBuffers(&data->field_0->arr[0].gname_uname.gname, data->field_0->arr[0].gname_uname.uname);
|
CopyHostRfuGameDataAndUsername(&data->field_0->arr[0].gname_uname.gname, data->field_0->arr[0].gname_uname.uname);
|
||||||
data->field_0->arr[0].field_18 = 0;
|
data->field_0->arr[0].field_18 = 0;
|
||||||
data->field_0->arr[0].groupScheduledAnim = UNION_ROOM_SPAWN_IN;
|
data->field_0->arr[0].groupScheduledAnim = UNION_ROOM_SPAWN_IN;
|
||||||
data->field_0->arr[0].field_1A_1 = FALSE;
|
data->field_0->arr[0].field_1A_1 = FALSE;
|
||||||
@@ -3654,7 +3654,7 @@ static void Task_SearchForChildOrParent(u8 taskId)
|
|||||||
|
|
||||||
for (i = 0; i < RFU_CHILD_MAX; i++)
|
for (i = 0; i < RFU_CHILD_MAX; i++)
|
||||||
{
|
{
|
||||||
parent_child = LinkRfu_GetNameIfCompatible(&gname_uname.gname, gname_uname.uname, i);
|
parent_child = Rfu_GetCompatiblePlayerData(&gname_uname.gname, gname_uname.uname, i);
|
||||||
if (!IsPartnerActivityAcceptable(gname_uname.gname.activity, gTasks[taskId].data[4]))
|
if (!IsPartnerActivityAcceptable(gname_uname.gname.activity, gTasks[taskId].data[4]))
|
||||||
{
|
{
|
||||||
gname_uname = sUnionGnameUnamePair_Dummy;
|
gname_uname = sUnionGnameUnamePair_Dummy;
|
||||||
@@ -3700,7 +3700,7 @@ static void Task_ListenForPartnersWithCompatibleSerialNos(u8 taskId)
|
|||||||
|
|
||||||
for (i = 0; i < RFU_CHILD_MAX; i++)
|
for (i = 0; i < RFU_CHILD_MAX; i++)
|
||||||
{
|
{
|
||||||
LinkRfu_GetNameIfCompatible(&ptr[0]->arr[i].gname_uname.gname, ptr[0]->arr[i].gname_uname.uname, i);
|
Rfu_GetCompatiblePlayerData(&ptr[0]->arr[i].gname_uname.gname, ptr[0]->arr[i].gname_uname.uname, i);
|
||||||
if (!IsPartnerActivityAcceptable(ptr[0]->arr[i].gname_uname.gname.activity, gTasks[taskId].data[2]))
|
if (!IsPartnerActivityAcceptable(ptr[0]->arr[i].gname_uname.gname.activity, gTasks[taskId].data[2]))
|
||||||
{
|
{
|
||||||
ptr[0]->arr[i].gname_uname = sUnionGnameUnamePair_Dummy;
|
ptr[0]->arr[i].gname_uname = sUnionGnameUnamePair_Dummy;
|
||||||
@@ -3753,7 +3753,7 @@ static void Task_ListenForPartnersWithSerial7F7D(u8 taskId)
|
|||||||
|
|
||||||
for (i = 0; i < RFU_CHILD_MAX; i++)
|
for (i = 0; i < RFU_CHILD_MAX; i++)
|
||||||
{
|
{
|
||||||
if (LinkRfu_GetNameIfSerial7F7D(&ptr[0]->arr[i].gname_uname.gname, ptr[0]->arr[i].gname_uname.uname, i))
|
if (Rfu_GetWonderDistributorPlayerData(&ptr[0]->arr[i].gname_uname.gname, ptr[0]->arr[i].gname_uname.uname, i))
|
||||||
{
|
{
|
||||||
GetGnameWonderFlagByLinkGroup(&ptr[0]->arr[i].gname_uname.gname, gTasks[taskId].data[2]);
|
GetGnameWonderFlagByLinkGroup(&ptr[0]->arr[i].gname_uname.gname, gTasks[taskId].data[2]);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user