mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2024-12-25 19:24:16 +01:00
Clean up mystery gift headers
This commit is contained in:
parent
3cd27acbea
commit
d0455485c3
@ -36,17 +36,17 @@ bool32 SaveWonderNews(const struct WonderNews *news);
|
||||
bool32 SaveWonderCard(const struct WonderCard *card);
|
||||
bool32 ValidateSavedWonderNews(void);
|
||||
bool32 ValidateSavedWonderCard(void);
|
||||
bool32 IsWonderNewsSameAsSaved(const u8 *src);
|
||||
bool32 IsWonderNewsSameAsSaved(const u8 *news);
|
||||
bool32 IsSendingSavedWonderNewsAllowed(void);
|
||||
bool32 IsSendingSavedWonderCardAllowed(void);
|
||||
u16 GetWonderCardFlagID(void);
|
||||
void DisableWonderCardSending(struct WonderCard *card);
|
||||
bool32 IsSavedWonderCardGiftNotReceived(void);
|
||||
bool32 MysteryGift_TrySaveStamp(const u16 *stamp);
|
||||
void MysteryGift_LoadLinkGameData(struct MysteryGiftLinkGameData *data, bool32 a1);
|
||||
bool32 MysteryGift_ValidateLinkGameData(const struct MysteryGiftLinkGameData *data, bool32 a1);
|
||||
u32 MysteryGift_CompareCardFlags(const u16 *a0, const struct MysteryGiftLinkGameData *data, const void *unused);
|
||||
u32 MysteryGift_CheckStamps(const u16 *a0, const struct MysteryGiftLinkGameData *data, const void *unused);
|
||||
void MysteryGift_LoadLinkGameData(struct MysteryGiftLinkGameData *data, bool32 isWonderNews);
|
||||
bool32 MysteryGift_ValidateLinkGameData(const struct MysteryGiftLinkGameData *data, bool32 isWonderNews);
|
||||
u32 MysteryGift_CompareCardFlags(const u16 *flagId, const struct MysteryGiftLinkGameData *data, const void *unused);
|
||||
u32 MysteryGift_CheckStamps(const u16 *stamp, const struct MysteryGiftLinkGameData *data, const void *unused);
|
||||
bool32 MysteryGift_DoesQuestionnaireMatch(const struct MysteryGiftLinkGameData *data, const u16 *words);
|
||||
u16 MysteryGift_GetCardStatFromLinkData(const struct MysteryGiftLinkGameData *data, u32 stat);
|
||||
u16 MysteryGift_GetCardStat(u32 stat);
|
||||
|
@ -34,16 +34,16 @@ struct MysteryGiftLink
|
||||
u16 sendCounter;
|
||||
u16 sendCRC;
|
||||
u16 sendSize;
|
||||
void * recvBfr;
|
||||
const void * sendBfr;
|
||||
void * recvBuffer;
|
||||
const void * sendBuffer;
|
||||
u32 (*recvFunc)(struct MysteryGiftLink *);
|
||||
u32 (*sendFunc)(struct MysteryGiftLink *);
|
||||
};
|
||||
|
||||
void MysteryGiftLink_Init(struct MysteryGiftLink *, u32, u32);
|
||||
void MysteryGiftLink_InitSend(struct MysteryGiftLink * manager, u32 ident, const void * src, u32 size);
|
||||
bool32 MysteryGiftLink_Recv(struct MysteryGiftLink * manager);
|
||||
bool32 MysteryGiftLink_Send(struct MysteryGiftLink * manager);
|
||||
void MysteryGiftLink_InitRecv(struct MysteryGiftLink *, u32, void *);
|
||||
void MysteryGiftLink_Init(struct MysteryGiftLink * link, u32 sendPlayerId, u32 recvPlayerId);
|
||||
void MysteryGiftLink_InitSend(struct MysteryGiftLink * link, u32 ident, const void * src, u32 size);
|
||||
bool32 MysteryGiftLink_Recv(struct MysteryGiftLink * link);
|
||||
bool32 MysteryGiftLink_Send(struct MysteryGiftLink * link);
|
||||
void MysteryGiftLink_InitRecv(struct MysteryGiftLink * link, u32 ident, void * dest);
|
||||
|
||||
#endif //GUARD_MEVENT_SERVER_HELPERS_H
|
||||
|
@ -9,7 +9,7 @@ enum {
|
||||
NEWS_INPUT_NONE = 0xFF
|
||||
};
|
||||
|
||||
bool32 WonderCard_Init(struct WonderCard * card, struct WonderCardMetadata * r6);
|
||||
bool32 WonderCard_Init(struct WonderCard * card, struct WonderCardMetadata * metadata);
|
||||
bool32 WonderNews_Init(const struct WonderNews * news);
|
||||
s32 WonderCard_Enter(void);
|
||||
s32 WonderNews_Enter(void);
|
||||
|
@ -387,7 +387,7 @@ void MysteryGift_LoadLinkGameData(struct MysteryGiftLinkGameData *data, bool32 i
|
||||
data->romHeaderSoftwareVersion = RomHeaderSoftwareVersion;
|
||||
}
|
||||
|
||||
bool32 MysteryGift_ValidateLinkGameData(const struct MysteryGiftLinkGameData *data, bool32 forNews)
|
||||
bool32 MysteryGift_ValidateLinkGameData(const struct MysteryGiftLinkGameData *data, bool32 isWonderNews)
|
||||
{
|
||||
if (data->validationVar != GAME_DATA_VALID_VAR)
|
||||
return FALSE;
|
||||
@ -398,7 +398,7 @@ bool32 MysteryGift_ValidateLinkGameData(const struct MysteryGiftLinkGameData *da
|
||||
if (!(data->validationFlag2 & 1))
|
||||
return FALSE;
|
||||
|
||||
if (!forNews)
|
||||
if (!isWonderNews)
|
||||
{
|
||||
if (!(data->validationGiftType1 & GAME_DATA_VALID_GIFT_TYPE_1))
|
||||
return FALSE;
|
||||
|
@ -47,8 +47,8 @@ void MysteryGiftLink_Init(struct MysteryGiftLink * link, u32 sendPlayerId, u32 r
|
||||
link->recvCRC = 0;
|
||||
link->recvSize = 0;
|
||||
link->recvCounter = 0;
|
||||
link->sendBfr = NULL;
|
||||
link->recvBfr = NULL;
|
||||
link->sendBuffer = NULL;
|
||||
link->recvBuffer = NULL;
|
||||
link->sendFunc = MGL_Send;
|
||||
link->recvFunc = MGL_Receive;
|
||||
}
|
||||
@ -63,7 +63,7 @@ void MysteryGiftLink_InitSend(struct MysteryGiftLink * link, u32 ident, const vo
|
||||
link->sendSize = size;
|
||||
else
|
||||
link->sendSize = MG_LINK_BUFFER_SIZE;
|
||||
link->sendBfr = src;
|
||||
link->sendBuffer = src;
|
||||
}
|
||||
|
||||
void MysteryGiftLink_InitRecv(struct MysteryGiftLink * link, u32 ident, void * dest)
|
||||
@ -73,7 +73,7 @@ void MysteryGiftLink_InitRecv(struct MysteryGiftLink * link, u32 ident, void * d
|
||||
link->recvCounter = 0;
|
||||
link->recvCRC = 0;
|
||||
link->recvSize = 0;
|
||||
link->recvBfr = dest;
|
||||
link->recvBuffer = dest;
|
||||
}
|
||||
|
||||
static void MGL_ReceiveBlock(u32 playerId, void * dest, size_t size)
|
||||
@ -130,20 +130,20 @@ static bool32 MGL_Receive(struct MysteryGiftLink * link)
|
||||
size_t blocksize = link->recvCounter * 252;
|
||||
if (link->recvSize - blocksize <= 252)
|
||||
{
|
||||
MGL_ReceiveBlock(link->recvPlayerId, link->recvBfr + blocksize, link->recvSize - blocksize);
|
||||
MGL_ReceiveBlock(link->recvPlayerId, link->recvBuffer + blocksize, link->recvSize - blocksize);
|
||||
link->recvCounter++;
|
||||
link->state++;
|
||||
}
|
||||
else
|
||||
{
|
||||
MGL_ReceiveBlock(link->recvPlayerId, link->recvBfr + blocksize, 252);
|
||||
MGL_ReceiveBlock(link->recvPlayerId, link->recvBuffer + blocksize, 252);
|
||||
link->recvCounter++;
|
||||
}
|
||||
MGL_ResetReceived(link->recvPlayerId);
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
if (CalcCRC16WithTable(link->recvBfr, link->recvSize) != link->recvCRC)
|
||||
if (CalcCRC16WithTable(link->recvBuffer, link->recvSize) != link->recvCRC)
|
||||
{
|
||||
LinkRfu_FatalError();
|
||||
return FALSE;
|
||||
@ -170,7 +170,7 @@ static bool32 MGL_Send(struct MysteryGiftLink * link)
|
||||
{
|
||||
header.ident = link->sendIdent;
|
||||
header.size = link->sendSize;
|
||||
header.crc = CalcCRC16WithTable(link->sendBfr, link->sendSize);
|
||||
header.crc = CalcCRC16WithTable(link->sendBuffer, link->sendSize);
|
||||
link->sendCRC = header.crc;
|
||||
link->sendCounter = 0;
|
||||
SendBlock(0, &header, sizeof(header));
|
||||
@ -187,13 +187,13 @@ static bool32 MGL_Send(struct MysteryGiftLink * link)
|
||||
blocksize = 252 * link->sendCounter;
|
||||
if (link->sendSize - blocksize <= 252)
|
||||
{
|
||||
SendBlock(0, link->sendBfr + blocksize, link->sendSize - blocksize);
|
||||
SendBlock(0, link->sendBuffer + blocksize, link->sendSize - blocksize);
|
||||
link->sendCounter++;
|
||||
link->state++;
|
||||
}
|
||||
else
|
||||
{
|
||||
SendBlock(0, link->sendBfr + blocksize, 252);
|
||||
SendBlock(0, link->sendBuffer + blocksize, 252);
|
||||
link->sendCounter++;
|
||||
}
|
||||
}
|
||||
@ -202,7 +202,7 @@ static bool32 MGL_Send(struct MysteryGiftLink * link)
|
||||
case 2:
|
||||
if (IsLinkTaskFinished())
|
||||
{
|
||||
if (CalcCRC16WithTable(link->sendBfr, link->sendSize) != link->sendCRC)
|
||||
if (CalcCRC16WithTable(link->sendBuffer, link->sendSize) != link->sendCRC)
|
||||
LinkRfu_FatalError();
|
||||
else
|
||||
link->state++;
|
||||
|
@ -474,7 +474,7 @@ void MainCB_FreeAllBuffersAndReturnToInitTitleScreen(void)
|
||||
SetMainCallback2(CB2_InitTitleScreen);
|
||||
}
|
||||
|
||||
void PrintMysteryGiftOrEReaderTopMenu(bool8 isEReader, bool32 usePickOkCancel)
|
||||
void PrintMysteryGiftOrEReaderTopMenu(bool8 isEReader, bool32 useCancel)
|
||||
{
|
||||
const u8 * header;
|
||||
const u8 * options;
|
||||
@ -482,7 +482,7 @@ void PrintMysteryGiftOrEReaderTopMenu(bool8 isEReader, bool32 usePickOkCancel)
|
||||
if (!isEReader)
|
||||
{
|
||||
header = gText_MysteryGift;
|
||||
options = !usePickOkCancel ? gText_PickOKExit : gText_PickOKCancel;
|
||||
options = !useCancel ? gText_PickOKExit : gText_PickOKCancel;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -816,11 +816,11 @@ static bool32 ClearSavedNewsOrCard(bool32 isWonderNews)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static bool32 ExitWonderCardOrNews(bool32 isWonderNews, bool32 arg1)
|
||||
static bool32 ExitWonderCardOrNews(bool32 isWonderNews, bool32 useCancel)
|
||||
{
|
||||
if (!isWonderNews)
|
||||
{
|
||||
if (WonderCard_Exit(arg1))
|
||||
if (WonderCard_Exit(useCancel))
|
||||
{
|
||||
WonderCard_Destroy();
|
||||
return TRUE;
|
||||
@ -832,7 +832,7 @@ static bool32 ExitWonderCardOrNews(bool32 isWonderNews, bool32 arg1)
|
||||
}
|
||||
else
|
||||
{
|
||||
if (WonderNews_Exit(arg1))
|
||||
if (WonderNews_Exit(useCancel))
|
||||
{
|
||||
WonderNews_Destroy();
|
||||
return TRUE;
|
||||
@ -1486,7 +1486,7 @@ static void Task_MysteryGift(u8 taskId)
|
||||
}
|
||||
break;
|
||||
case MG_STATE_TOSS:
|
||||
if (ExitWonderCardOrNews(data->isWonderNews, 1))
|
||||
if (ExitWonderCardOrNews(data->isWonderNews, TRUE))
|
||||
{
|
||||
ClearSavedNewsOrCard(data->isWonderNews);
|
||||
data->state = MG_STATE_TOSS_SAVE;
|
||||
@ -1504,15 +1504,15 @@ static void Task_MysteryGift(u8 taskId)
|
||||
}
|
||||
break;
|
||||
case MG_STATE_GIFT_INPUT_EXIT:
|
||||
if (ExitWonderCardOrNews(data->isWonderNews, 0))
|
||||
if (ExitWonderCardOrNews(data->isWonderNews, FALSE))
|
||||
data->state = MG_STATE_TO_MAIN_MENU;
|
||||
break;
|
||||
case MG_STATE_RECEIVE:
|
||||
if (ExitWonderCardOrNews(data->isWonderNews, 1))
|
||||
if (ExitWonderCardOrNews(data->isWonderNews, TRUE))
|
||||
data->state = MG_STATE_SOURCE_PROMPT;
|
||||
break;
|
||||
case MG_STATE_SEND:
|
||||
if (ExitWonderCardOrNews(data->isWonderNews, 1))
|
||||
if (ExitWonderCardOrNews(data->isWonderNews, TRUE))
|
||||
{
|
||||
switch (data->isWonderNews)
|
||||
{
|
||||
|
@ -273,11 +273,11 @@ s32 WonderCard_Enter(void)
|
||||
sWonderCardData->enterExitState = 0;
|
||||
return 1;
|
||||
}
|
||||
++sWonderCardData->enterExitState;
|
||||
sWonderCardData->enterExitState++;
|
||||
return 0;
|
||||
}
|
||||
|
||||
s32 WonderCard_Exit(bool32 flag)
|
||||
s32 WonderCard_Exit(bool32 useCancel)
|
||||
{
|
||||
if (sWonderCardData == NULL)
|
||||
return -1;
|
||||
@ -310,7 +310,7 @@ s32 WonderCard_Exit(bool32 flag)
|
||||
FreeMonIconPalettes();
|
||||
break;
|
||||
case 5:
|
||||
PrintMysteryGiftOrEReaderTopMenu(gGiftIsFromEReader, flag);
|
||||
PrintMysteryGiftOrEReaderTopMenu(gGiftIsFromEReader, useCancel);
|
||||
CopyBgTilemapBufferToVram(0);
|
||||
BeginNormalPaletteFade(PALETTES_ALL, 0, 16, 0, RGB_BLACK);
|
||||
break;
|
||||
@ -320,7 +320,7 @@ s32 WonderCard_Exit(bool32 flag)
|
||||
sWonderCardData->enterExitState = 0;
|
||||
return 1;
|
||||
}
|
||||
++sWonderCardData->enterExitState;
|
||||
sWonderCardData->enterExitState++;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -737,11 +737,11 @@ s32 WonderNews_Enter(void)
|
||||
return 1;
|
||||
}
|
||||
|
||||
++sWonderNewsData->enterExitState;
|
||||
sWonderNewsData->enterExitState++;
|
||||
return 0;
|
||||
}
|
||||
|
||||
s32 WonderNews_Exit(bool32 flag)
|
||||
s32 WonderNews_Exit(bool32 useCancel)
|
||||
{
|
||||
if (sWonderNewsData == NULL)
|
||||
return -1;
|
||||
@ -786,7 +786,7 @@ s32 WonderNews_Exit(bool32 flag)
|
||||
}
|
||||
break;
|
||||
case 5:
|
||||
PrintMysteryGiftOrEReaderTopMenu(gGiftIsFromEReader, flag);
|
||||
PrintMysteryGiftOrEReaderTopMenu(gGiftIsFromEReader, useCancel);
|
||||
MG_DrawCheckerboardPattern(3);
|
||||
CopyBgTilemapBufferToVram(0);
|
||||
CopyBgTilemapBufferToVram(3);
|
||||
@ -798,7 +798,7 @@ s32 WonderNews_Exit(bool32 flag)
|
||||
sWonderNewsData->enterExitState = 0;
|
||||
return 1;
|
||||
}
|
||||
++sWonderNewsData->enterExitState;
|
||||
sWonderNewsData->enterExitState++;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -872,12 +872,12 @@ static void BufferNewsText(void)
|
||||
sWonderNewsData->titleText[WONDER_NEWS_TEXT_LENGTH] = EOS;
|
||||
|
||||
// Copy body text
|
||||
for (; i < WONDER_NEWS_BODY_TEXT_LINES; ++i)
|
||||
for (; i < WONDER_NEWS_BODY_TEXT_LINES; i++)
|
||||
{
|
||||
memcpy(sWonderNewsData->bodyText[i], sWonderNewsData->news.bodyText[i], WONDER_NEWS_TEXT_LENGTH);
|
||||
sWonderNewsData->bodyText[i][WONDER_NEWS_TEXT_LENGTH] = EOS;
|
||||
if (i > 7 && sWonderNewsData->bodyText[i][0] != EOS)
|
||||
++sWonderNewsData->scrollEnd;
|
||||
sWonderNewsData->scrollEnd++;
|
||||
}
|
||||
sWonderNewsData->arrowsTemplate = sNews_ArrowsTemplate;
|
||||
sWonderNewsData->arrowsTemplate.fullyDownThreshold = sWonderNewsData->scrollEnd;
|
||||
@ -899,7 +899,7 @@ static void DrawNewsWindows(void)
|
||||
AddTextPrinterParameterized3(sWonderNewsData->windowIds[NEWS_WIN_TITLE], 3, x, 6, sNews_TextColorTable[sWonderNewsData->gfx->titleTextPal], 0, sWonderNewsData->titleText);
|
||||
|
||||
// Print body text
|
||||
for (; i < WONDER_NEWS_BODY_TEXT_LINES; ++i)
|
||||
for (; i < WONDER_NEWS_BODY_TEXT_LINES; i++)
|
||||
AddTextPrinterParameterized3(sWonderNewsData->windowIds[NEWS_WIN_BODY], 3, 0,
|
||||
16 * i + 2,
|
||||
sNews_TextColorTable[sWonderNewsData->gfx->bodyTextPal],
|
||||
@ -927,9 +927,9 @@ static void UpdateNewsScroll(void)
|
||||
if (sWonderNewsData->scrollTotal > 15)
|
||||
{
|
||||
if (sWonderNewsData->scrollingDown)
|
||||
++sWonderNewsData->scrollOffset;
|
||||
sWonderNewsData->scrollOffset++;
|
||||
else
|
||||
--sWonderNewsData->scrollOffset;
|
||||
sWonderNewsData->scrollOffset--;
|
||||
sWonderNewsData->scrolling = FALSE;
|
||||
sWonderNewsData->scrollTotal = 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user