Rename GF Gname, Rfu, finish bulk of Union Room, more link doc
This commit is contained in:
+81
-97
@@ -15,6 +15,9 @@ enum {
|
||||
WIRELESS_STATUS_ANIM_ERROR,
|
||||
};
|
||||
|
||||
#define TAG_GFX_STATUS_INDICATOR 0xD431
|
||||
#define TAG_PAL_STATUS_INDICATOR 0xD432
|
||||
|
||||
#define UNUSED_QUEUE_NUM_SLOTS 2
|
||||
#define UNUSED_QUEUE_SLOT_LENGTH 256
|
||||
|
||||
@@ -29,7 +32,7 @@ struct RfuUnusedQueue
|
||||
|
||||
EWRAM_DATA u8 gWirelessStatusIndicatorSpriteId = 0;
|
||||
|
||||
static u8 sUnknown_03000D74;
|
||||
static u8 sSequenceArrayValOffset;
|
||||
|
||||
static const u16 sWirelessLinkIconPalette[] = INCBIN_U16("graphics/interface/wireless_link_icon.gbapal");
|
||||
static const u32 sWirelessLinkIconPic[] = INCBIN_U32("graphics/interface/wireless_link_icon.4bpp.lz");
|
||||
@@ -290,16 +293,16 @@ static const union AnimCmd *const sWirelessStatusIndicatorAnims[] = {
|
||||
};
|
||||
|
||||
static const struct CompressedSpriteSheet sWirelessStatusIndicatorSpriteSheet = {
|
||||
sWirelessLinkIconPic, 0x0380, 0xD431
|
||||
sWirelessLinkIconPic, 0x0380, TAG_GFX_STATUS_INDICATOR
|
||||
};
|
||||
|
||||
static const struct SpritePalette sWirelessStatusIndicatorSpritePalette = {
|
||||
sWirelessLinkIconPalette, 0xD432
|
||||
sWirelessLinkIconPalette, TAG_PAL_STATUS_INDICATOR
|
||||
};
|
||||
|
||||
static const struct SpriteTemplate sWirelessStatusIndicatorSpriteTemplate = {
|
||||
.tileTag = 0xD431,
|
||||
.paletteTag = 0xD432,
|
||||
.tileTag = TAG_GFX_STATUS_INDICATOR,
|
||||
.paletteTag = TAG_PAL_STATUS_INDICATOR,
|
||||
.oam = &sWirelessStatusIndicatorOamData,
|
||||
.anims = sWirelessStatusIndicatorAnims,
|
||||
.images = NULL,
|
||||
@@ -333,9 +336,7 @@ void RfuSendQueue_Reset(struct RfuSendQueue *queue)
|
||||
for (i = 0; i < SEND_QUEUE_NUM_SLOTS; i++)
|
||||
{
|
||||
for (j = 0; j < SEND_QUEUE_SLOT_LENGTH; j++)
|
||||
{
|
||||
queue->slots[i][j] = 0;
|
||||
}
|
||||
}
|
||||
queue->sendSlot = 0;
|
||||
queue->recvSlot = 0;
|
||||
@@ -351,9 +352,7 @@ static void RfuUnusedQueue_Reset(struct RfuUnusedQueue *queue)
|
||||
for (i = 0; i < UNUSED_QUEUE_NUM_SLOTS; i++)
|
||||
{
|
||||
for (j = 0; j < UNUSED_QUEUE_SLOT_LENGTH; j++)
|
||||
{
|
||||
queue->slots[i][j] = 0;
|
||||
}
|
||||
}
|
||||
queue->sendSlot = 0;
|
||||
queue->recvSlot = 0;
|
||||
@@ -555,46 +554,57 @@ static bool8 RfuUnusedQueue_Dequeue(struct RfuUnusedQueue *queue, u8 *dest)
|
||||
}
|
||||
|
||||
// Unused
|
||||
static void sub_800DBF8(u8 *q1, u8 mode)
|
||||
// Populates an array with a sequence of numbers (which numbers depends on the mode)
|
||||
// and sets the final element to the total of the other elements
|
||||
#define SEQ_ARRAY_MAX_SIZE 200
|
||||
static void PopulateArrayWithSequence(u8 *arr, u8 mode)
|
||||
{
|
||||
s32 i;
|
||||
u8 rval;
|
||||
u16 r5 = 0;
|
||||
u16 total = 0;
|
||||
switch (mode)
|
||||
{
|
||||
case 0:
|
||||
for (i = 0; i < 200; i++)
|
||||
// Populate with numbers 1-200
|
||||
// Total will be 20100
|
||||
for (i = 0; i < SEQ_ARRAY_MAX_SIZE; i++)
|
||||
{
|
||||
q1[i] = i + 1;
|
||||
r5 += i + 1;
|
||||
arr[i] = i + 1;
|
||||
total += i + 1;
|
||||
}
|
||||
*((u16 *)(q1 + i)) = r5;
|
||||
*((u16 *)(arr + i)) = total;
|
||||
break;
|
||||
case 1:
|
||||
// Populate with numbers 1-100
|
||||
// Total will be 5050
|
||||
for (i = 0; i < 100; i++)
|
||||
{
|
||||
q1[i] = i + 1;
|
||||
r5 += i + 1;
|
||||
arr[i] = i + 1;
|
||||
total += i + 1;
|
||||
}
|
||||
*((u16 *)(q1 + 200)) = r5;
|
||||
*((u16 *)(arr + SEQ_ARRAY_MAX_SIZE)) = total;
|
||||
break;
|
||||
case 2:
|
||||
for (i = 0; i < 200; i++)
|
||||
// Populate with random numbers 0-255
|
||||
// Total will be a number 0-51000
|
||||
for (i = 0; i < SEQ_ARRAY_MAX_SIZE; i++)
|
||||
{
|
||||
rval = Random();
|
||||
q1[i] = rval;
|
||||
r5 += rval;
|
||||
arr[i] = rval;
|
||||
total += rval;
|
||||
}
|
||||
*((u16 *)(q1 + i)) = r5;
|
||||
*((u16 *)(arr + i)) = total;
|
||||
break;
|
||||
case 3:
|
||||
for (i = 0; i < 200; i++)
|
||||
// Populate with numbers 1-200 + sSequenceArrayValOffset
|
||||
// Total will be a number 20100-51000
|
||||
for (i = 0; i < SEQ_ARRAY_MAX_SIZE; i++)
|
||||
{
|
||||
q1[i] = i + 1 + sUnknown_03000D74;
|
||||
r5 += (i + 1 + sUnknown_03000D74) & 0xFF;
|
||||
arr[i] = i + 1 + sSequenceArrayValOffset;
|
||||
total += (i + 1 + sSequenceArrayValOffset) & 0xFF;
|
||||
}
|
||||
*((u16 *)(q1 + i)) = r5;
|
||||
sUnknown_03000D74++;
|
||||
*((u16 *)(arr + i)) = total;
|
||||
sSequenceArrayValOffset++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -606,9 +616,7 @@ static void PkmnStrToASCII(u8 *asciiStr, const u8 *pkmnStr)
|
||||
s32 i;
|
||||
|
||||
for (i = 0; pkmnStr[i] != EOS; i++)
|
||||
{
|
||||
asciiStr[i] = sWireless_RSEtoASCIITable[pkmnStr[i]];
|
||||
}
|
||||
asciiStr[i] = 0;
|
||||
}
|
||||
|
||||
@@ -617,9 +625,7 @@ static void ASCIIToPkmnStr(u8 *pkmnStr, const u8 *asciiStr)
|
||||
s32 i;
|
||||
|
||||
for (i = 0; asciiStr[i] != 0; i++)
|
||||
{
|
||||
pkmnStr[i] = sWireless_ASCIItoRSETable[asciiStr[i]];
|
||||
}
|
||||
pkmnStr[i] = EOS;
|
||||
}
|
||||
|
||||
@@ -655,33 +661,32 @@ static u8 GetConnectedChildStrength(u8 maxFlags)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void InitHostRFUtgtGname(struct GFtgtGname *data, u8 activity, bool32 started, s32 child_sprite_genders)
|
||||
void InitHostRfuGameData(struct RfuGameData *data, u8 activity, bool32 startedActivity, s32 partnerInfo)
|
||||
{
|
||||
s32 i;
|
||||
|
||||
for (i = 0; i < 2; i++)
|
||||
{
|
||||
data->unk_00.playerTrainerId[i] = gSaveBlock2Ptr->playerTrainerId[i];
|
||||
}
|
||||
for (i = 0; i < (s32)ARRAY_COUNT(data->compatibility.playerTrainerId); i++)
|
||||
data->compatibility.playerTrainerId[i] = gSaveBlock2Ptr->playerTrainerId[i];
|
||||
|
||||
for (i = 0; i < RFU_CHILD_MAX; i++)
|
||||
{
|
||||
data->child_sprite_gender[i] = child_sprite_genders;
|
||||
child_sprite_genders >>= 8;
|
||||
data->partnerInfo[i] = partnerInfo;
|
||||
partnerInfo >>= 8; // Each element is 1 byte
|
||||
}
|
||||
data->playerGender = gSaveBlock2Ptr->playerGender;
|
||||
data->activity = activity;
|
||||
data->started = started;
|
||||
data->unk_00.language = GAME_LANGUAGE;
|
||||
data->unk_00.version = GAME_VERSION;
|
||||
data->unk_00.hasNews = FALSE;
|
||||
data->unk_00.hasCard = FALSE;
|
||||
data->unk_00.unknown = FALSE;
|
||||
data->unk_00.isChampion = FlagGet(FLAG_IS_CHAMPION);
|
||||
data->unk_00.hasNationalDex = IsNationalPokedexEnabled();
|
||||
data->unk_00.gameClear = FlagGet(FLAG_SYS_GAME_CLEAR);
|
||||
data->startedActivity = startedActivity;
|
||||
data->compatibility.language = GAME_LANGUAGE;
|
||||
data->compatibility.version = GAME_VERSION;
|
||||
data->compatibility.hasNews = FALSE;
|
||||
data->compatibility.hasCard = FALSE;
|
||||
data->compatibility.unknown = FALSE;
|
||||
data->compatibility.isChampion = FlagGet(FLAG_IS_CHAMPION);
|
||||
data->compatibility.hasNationalDex = IsNationalPokedexEnabled();
|
||||
data->compatibility.gameClear = FlagGet(FLAG_SYS_GAME_CLEAR);
|
||||
}
|
||||
|
||||
bool8 LinkRfu_GetNameIfCompatible(struct GFtgtGname *buff1, u8 *buff2, u8 idx)
|
||||
bool8 Rfu_GetCompatiblePlayerData(struct RfuGameData *gameData, u8 *username, u8 idx)
|
||||
{
|
||||
bool8 retVal;
|
||||
|
||||
@@ -690,13 +695,13 @@ bool8 LinkRfu_GetNameIfCompatible(struct GFtgtGname *buff1, u8 *buff2, u8 idx)
|
||||
retVal = TRUE;
|
||||
if (IsRfuSerialNumberValid(gRfuLinkStatus->partner[idx].serialNo) && ((gRfuLinkStatus->getNameFlag >> idx) & 1))
|
||||
{
|
||||
memcpy(buff1, gRfuLinkStatus->partner[idx].gname, RFU_GAME_NAME_LENGTH);
|
||||
memcpy(buff2, gRfuLinkStatus->partner[idx].uname, PLAYER_NAME_LENGTH + 1);
|
||||
memcpy(gameData, gRfuLinkStatus->partner[idx].gname, RFU_GAME_NAME_LENGTH);
|
||||
memcpy(username, gRfuLinkStatus->partner[idx].uname, RFU_USER_NAME_LENGTH);
|
||||
}
|
||||
else
|
||||
{
|
||||
memset(buff1, 0, RFU_GAME_NAME_LENGTH);
|
||||
memset(buff2, 0, PLAYER_NAME_LENGTH + 1);
|
||||
memset(gameData, 0, RFU_GAME_NAME_LENGTH);
|
||||
memset(username, 0, RFU_USER_NAME_LENGTH);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -704,39 +709,39 @@ bool8 LinkRfu_GetNameIfCompatible(struct GFtgtGname *buff1, u8 *buff2, u8 idx)
|
||||
retVal = FALSE;
|
||||
if (IsRfuSerialNumberValid(gRfuLinkStatus->partner[idx].serialNo))
|
||||
{
|
||||
memcpy(buff1, gRfuLinkStatus->partner[idx].gname, RFU_GAME_NAME_LENGTH);
|
||||
memcpy(buff2, gRfuLinkStatus->partner[idx].uname, PLAYER_NAME_LENGTH + 1);
|
||||
memcpy(gameData, gRfuLinkStatus->partner[idx].gname, RFU_GAME_NAME_LENGTH);
|
||||
memcpy(username, gRfuLinkStatus->partner[idx].uname, RFU_USER_NAME_LENGTH);
|
||||
}
|
||||
else
|
||||
{
|
||||
memset(buff1, 0, RFU_GAME_NAME_LENGTH);
|
||||
memset(buff2, 0, PLAYER_NAME_LENGTH + 1);
|
||||
memset(gameData, 0, RFU_GAME_NAME_LENGTH);
|
||||
memset(username, 0, RFU_USER_NAME_LENGTH);
|
||||
}
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
|
||||
bool8 LinkRfu_GetNameIfSerial7F7D(struct GFtgtGname *buff1, u8 *buff2, u8 idx)
|
||||
bool8 Rfu_GetWonderDistributorPlayerData(struct RfuGameData *gameData, u8 *username, u8 idx)
|
||||
{
|
||||
bool8 retVal = FALSE;
|
||||
if (gRfuLinkStatus->partner[idx].serialNo == RFU_SERIAL_B)
|
||||
if (gRfuLinkStatus->partner[idx].serialNo == RFU_SERIAL_WONDER_DISTRIBUTOR)
|
||||
{
|
||||
memcpy(buff1, gRfuLinkStatus->partner[idx].gname, RFU_GAME_NAME_LENGTH);
|
||||
memcpy(buff2, gRfuLinkStatus->partner[idx].uname, PLAYER_NAME_LENGTH + 1);
|
||||
memcpy(gameData, gRfuLinkStatus->partner[idx].gname, RFU_GAME_NAME_LENGTH);
|
||||
memcpy(username, gRfuLinkStatus->partner[idx].uname, RFU_USER_NAME_LENGTH);
|
||||
retVal = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
memset(buff1, 0, RFU_GAME_NAME_LENGTH);
|
||||
memset(buff2, 0, PLAYER_NAME_LENGTH + 1);
|
||||
memset(gameData, 0, RFU_GAME_NAME_LENGTH);
|
||||
memset(username, 0, RFU_USER_NAME_LENGTH);
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
|
||||
void LinkRfu3_SetGnameUnameFromStaticBuffers(struct GFtgtGname *buff1, u8 *buff2)
|
||||
void CopyHostRfuGameDataAndUsername(struct RfuGameData *gameData, u8 *username)
|
||||
{
|
||||
memcpy(buff1, &gHostRFUtgtGnameBuffer, RFU_GAME_NAME_LENGTH);
|
||||
memcpy(buff2, gHostRFUtgtUnameBuffer, PLAYER_NAME_LENGTH + 1);
|
||||
memcpy(gameData, &gHostRfuGameData, RFU_GAME_NAME_LENGTH);
|
||||
memcpy(username, gHostRfuUsername, RFU_USER_NAME_LENGTH);
|
||||
}
|
||||
|
||||
#define sNextAnimNum data[0]
|
||||
@@ -754,8 +759,8 @@ void CreateWirelessStatusIndicatorSprite(u8 x, u8 y)
|
||||
|
||||
if (x == 0 && y == 0)
|
||||
{
|
||||
x = 0xE7;
|
||||
y = 0x08;
|
||||
x = 231;
|
||||
y = 8;
|
||||
}
|
||||
if (gRfuLinkStatus->parentChild == MODE_PARENT)
|
||||
{
|
||||
@@ -788,9 +793,7 @@ void DestroyWirelessStatusIndicatorSprite(void)
|
||||
void LoadWirelessStatusIndicatorSpriteGfx(void)
|
||||
{
|
||||
if (GetSpriteTileStartByTag(sWirelessStatusIndicatorSpriteSheet.tag) == 0xFFFF)
|
||||
{
|
||||
LoadCompressedSpriteSheet(&sWirelessStatusIndicatorSpriteSheet);
|
||||
}
|
||||
LoadSpritePalette(&sWirelessStatusIndicatorSpritePalette);
|
||||
gWirelessStatusIndicatorSpriteId = SPRITE_NONE;
|
||||
}
|
||||
@@ -802,9 +805,7 @@ static u8 GetParentSignalStrength(void)
|
||||
for (i = 0; i < RFU_CHILD_MAX; i++)
|
||||
{
|
||||
if (flags & 1)
|
||||
{
|
||||
return gRfuLinkStatus->strength[i];
|
||||
}
|
||||
flags >>= 1;
|
||||
}
|
||||
return 0;
|
||||
@@ -827,40 +828,33 @@ void UpdateWirelessStatusIndicatorSprite(void)
|
||||
struct Sprite *sprite = &gSprites[gWirelessStatusIndicatorSpriteId];
|
||||
u8 signalStrength = RFU_LINK_ICON_LEVEL4_MAX;
|
||||
u8 i = 0;
|
||||
|
||||
// Get weakest signal strength
|
||||
if (gRfuLinkStatus->parentChild == MODE_PARENT)
|
||||
{
|
||||
for (i = 0; i < GetLinkPlayerCount() - 1; i++)
|
||||
{
|
||||
if (signalStrength >= GetConnectedChildStrength(i + 1))
|
||||
{
|
||||
signalStrength = GetConnectedChildStrength(i + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
signalStrength = GetParentSignalStrength();
|
||||
}
|
||||
|
||||
// Set signal strength sprite anim number
|
||||
if (IsRfuRecoveringFromLinkLoss() == TRUE)
|
||||
{
|
||||
sprite->sNextAnimNum = WIRELESS_STATUS_ANIM_ERROR;
|
||||
}
|
||||
else if (signalStrength <= RFU_LINK_ICON_LEVEL1_MAX)
|
||||
{
|
||||
sprite->sNextAnimNum = WIRELESS_STATUS_ANIM_SEARCHING;
|
||||
}
|
||||
else if (signalStrength >= RFU_LINK_ICON_LEVEL2_MIN && signalStrength <= RFU_LINK_ICON_LEVEL2_MAX)
|
||||
{
|
||||
sprite->sNextAnimNum = WIRELESS_STATUS_ANIM_1_BAR;
|
||||
}
|
||||
else if (signalStrength >= RFU_LINK_ICON_LEVEL3_MIN && signalStrength <= RFU_LINK_ICON_LEVEL3_MAX)
|
||||
{
|
||||
sprite->sNextAnimNum = WIRELESS_STATUS_ANIM_2_BARS;
|
||||
}
|
||||
else if (signalStrength >= RFU_LINK_ICON_LEVEL4_MIN)
|
||||
{
|
||||
sprite->sNextAnimNum = WIRELESS_STATUS_ANIM_3_BARS;
|
||||
}
|
||||
|
||||
if (sprite->sNextAnimNum != sprite->sSavedAnimNum)
|
||||
{
|
||||
SetWirelessStatusIndicatorAnim(sprite, sprite->sNextAnimNum);
|
||||
@@ -871,9 +865,7 @@ void UpdateWirelessStatusIndicatorSprite(void)
|
||||
sprite->sFrameIdx++;
|
||||
sprite->sFrameDelay = 0;
|
||||
if (sprite->anims[sprite->sCurrAnimNum][sprite->sFrameIdx].type == -2)
|
||||
{
|
||||
sprite->sFrameIdx = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -884,11 +876,9 @@ void UpdateWirelessStatusIndicatorSprite(void)
|
||||
gMain.oamBuffer[125].y = sprite->pos1.y + sprite->centerToCornerVecY;
|
||||
gMain.oamBuffer[125].paletteNum = sprite->oam.paletteNum;
|
||||
gMain.oamBuffer[125].tileNum = sprite->sTileStart + sprite->anims[sprite->sCurrAnimNum][sprite->sFrameIdx].frame.imageValue;
|
||||
CpuCopy16(gMain.oamBuffer + 125, (struct OamData *)OAM + 125, sizeof(struct OamData));
|
||||
CpuCopy16(&gMain.oamBuffer[125], (struct OamData *)OAM + 125, sizeof(struct OamData));
|
||||
if (RfuGetStatus() == RFU_STATUS_FATAL_ERROR)
|
||||
{
|
||||
DestroyWirelessStatusIndicatorSprite();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -926,7 +916,7 @@ void RecordMixTrainerNames(void)
|
||||
s32 i;
|
||||
s32 j;
|
||||
s32 nextSpace;
|
||||
s32 connectedTrainerRecordIndices[5];
|
||||
s32 connectedTrainerRecordIndices[MAX_RFU_PLAYERS];
|
||||
struct TrainerNameRecord *newRecords = calloc(ARRAY_COUNT(gSaveBlock1Ptr->trainerNameRecords), sizeof(struct TrainerNameRecord));
|
||||
|
||||
// Check if we already have a record saved for connected trainers.
|
||||
@@ -936,9 +926,7 @@ void RecordMixTrainerNames(void)
|
||||
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)
|
||||
{
|
||||
connectedTrainerRecordIndices[i] = j;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -952,9 +940,7 @@ void RecordMixTrainerNames(void)
|
||||
|
||||
// If we already had a record for this trainer, wipe it so that the next step doesn't duplicate it.
|
||||
if (connectedTrainerRecordIndices[i] >= 0)
|
||||
{
|
||||
memset(gSaveBlock1Ptr->trainerNameRecords[connectedTrainerRecordIndices[i]].trainerName, 0, 8);
|
||||
}
|
||||
memset(gSaveBlock1Ptr->trainerNameRecords[connectedTrainerRecordIndices[i]].trainerName, 0, PLAYER_NAME_LENGTH + 1);
|
||||
nextSpace++;
|
||||
}
|
||||
}
|
||||
@@ -967,9 +953,7 @@ void RecordMixTrainerNames(void)
|
||||
{
|
||||
CopyTrainerRecord(&newRecords[nextSpace], gSaveBlock1Ptr->trainerNameRecords[i].trainerId, gSaveBlock1Ptr->trainerNameRecords[i].trainerName);
|
||||
if (++nextSpace >= (int)ARRAY_COUNT(gSaveBlock1Ptr->trainerNameRecords))
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1001,6 +985,6 @@ void WipeTrainerNameRecords(void)
|
||||
for (i = 0; i < (int)ARRAY_COUNT(gSaveBlock1Ptr->trainerNameRecords); i++)
|
||||
{
|
||||
gSaveBlock1Ptr->trainerNameRecords[i].trainerId = 0;
|
||||
CpuFill16(0, gSaveBlock1Ptr->trainerNameRecords[i].trainerName, 8);
|
||||
CpuFill16(0, gSaveBlock1Ptr->trainerNameRecords[i].trainerName, PLAYER_NAME_LENGTH + 1);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user