From ece7ef3410eb9b114cf328426c4fc16c972f71c6 Mon Sep 17 00:00:00 2001 From: GriffinR Date: Sun, 17 Oct 2021 03:00:48 -0400 Subject: Correct usage of MysteryEvent to MysteryGift --- include/constants/mevent.h | 47 ------------------ include/constants/mystery_gift.h | 47 ++++++++++++++++++ include/mevent.h | 57 ---------------------- include/mevent_client.h | 92 ----------------------------------- include/mevent_news.h | 15 ------ include/mevent_server.h | 100 --------------------------------------- include/mevent_server_helpers.h | 49 ------------------- include/mystery_event_msg.h | 22 ++++----- include/mystery_event_script.h | 4 +- include/mystery_gift.h | 63 +++++++++++++++++++----- include/mystery_gift_client.h | 92 +++++++++++++++++++++++++++++++++++ include/mystery_gift_link.h | 49 +++++++++++++++++++ include/mystery_gift_menu.h | 18 +++++++ include/mystery_gift_server.h | 100 +++++++++++++++++++++++++++++++++++++++ include/mystery_gift_view.h | 24 ++++++++++ include/wonder_news.h | 15 ++++++ include/wonder_transfer.h | 24 ---------- 17 files changed, 409 insertions(+), 409 deletions(-) delete mode 100644 include/constants/mevent.h create mode 100644 include/constants/mystery_gift.h delete mode 100755 include/mevent.h delete mode 100644 include/mevent_client.h delete mode 100755 include/mevent_news.h delete mode 100644 include/mevent_server.h delete mode 100644 include/mevent_server_helpers.h mode change 100644 => 100755 include/mystery_gift.h create mode 100644 include/mystery_gift_client.h create mode 100644 include/mystery_gift_link.h create mode 100644 include/mystery_gift_menu.h create mode 100644 include/mystery_gift_server.h create mode 100644 include/mystery_gift_view.h create mode 100755 include/wonder_news.h delete mode 100644 include/wonder_transfer.h (limited to 'include') diff --git a/include/constants/mevent.h b/include/constants/mevent.h deleted file mode 100644 index 636043fdb..000000000 --- a/include/constants/mevent.h +++ /dev/null @@ -1,47 +0,0 @@ -#ifndef GUARD_CONSTANTS_MEVENT_H -#define GUARD_CONSTANTS_MEVENT_H - -#define GET_NUM_STAMPS 0 -#define GET_MAX_STAMPS 1 -#define GET_CARD_BATTLES_WON 2 -#define GET_CARD_BATTLE_LOST 3 -#define GET_CARD_NUM_TRADES 4 - -#define CARD_STAT_BATTLES_WON 0 -#define CARD_STAT_BATTLES_LOST 1 -#define CARD_STAT_NUM_TRADES 2 -#define CARD_STAT_NUM_STAMPS 3 -#define CARD_STAT_MAX_STAMPS 4 - -// Values for the type field of Wonder Card -#define CARD_TYPE_GIFT 0 // Normal "Wonder Card" -#define CARD_TYPE_STAMP 1 // "Stamp Card" -#define CARD_TYPE_LINK_STAT 2 // Referred to as the "Battle Card", shows battle and trade stats -#define CARD_TYPE_COUNT 3 - -// Values for the sendType field of Wonder Card/News -#define SEND_TYPE_DISALLOWED 0 -#define SEND_TYPE_ALLOWED 1 -#define SEND_TYPE_ALLOWED_ALWAYS 2 - -// Return values for MysteryGift_CompareCardFlags, handled by gMysteryGiftServerScript_SendWonderCard -#define HAS_NO_CARD 0 -#define HAS_SAME_CARD 1 -#define HAS_DIFF_CARD 2 - -// The number of battles needed to be recorded on a Battle Card to win a prize -#define REQUIRED_CARD_BATTLES 3 - -// Stamps are 32 bits. The first 16 bits are the species -// and the second 16 bits are a number (presumably an ID of some kind) -#define STAMP_SPECIES 0 -#define STAMP_ID 1 - -// Number of different types/colors of Wonder Card and News backgrounds -#define NUM_WONDER_BGS 8 - -#define MAX_WONDER_CARD_STAT 999 - -#define WONDER_CARD_FLAG_OFFSET 1000 - -#endif //GUARD_MEVENT_H diff --git a/include/constants/mystery_gift.h b/include/constants/mystery_gift.h new file mode 100644 index 000000000..07690e37c --- /dev/null +++ b/include/constants/mystery_gift.h @@ -0,0 +1,47 @@ +#ifndef GUARD_CONSTANTS_MYSTERY_GIFT_H +#define GUARD_CONSTANTS_MYSTERY_GIFT_H + +#define GET_NUM_STAMPS 0 +#define GET_MAX_STAMPS 1 +#define GET_CARD_BATTLES_WON 2 +#define GET_CARD_BATTLE_LOST 3 +#define GET_CARD_NUM_TRADES 4 + +#define CARD_STAT_BATTLES_WON 0 +#define CARD_STAT_BATTLES_LOST 1 +#define CARD_STAT_NUM_TRADES 2 +#define CARD_STAT_NUM_STAMPS 3 +#define CARD_STAT_MAX_STAMPS 4 + +// Values for the type field of Wonder Card +#define CARD_TYPE_GIFT 0 // Normal "Wonder Card" +#define CARD_TYPE_STAMP 1 // "Stamp Card" +#define CARD_TYPE_LINK_STAT 2 // Referred to as the "Battle Card", shows battle and trade stats +#define CARD_TYPE_COUNT 3 + +// Values for the sendType field of Wonder Card/News +#define SEND_TYPE_DISALLOWED 0 +#define SEND_TYPE_ALLOWED 1 +#define SEND_TYPE_ALLOWED_ALWAYS 2 + +// Return values for MysteryGift_CompareCardFlags, handled by gMysteryGiftServerScript_SendWonderCard +#define HAS_NO_CARD 0 +#define HAS_SAME_CARD 1 +#define HAS_DIFF_CARD 2 + +// The number of battles needed to be recorded on a Battle Card to win a prize +#define REQUIRED_CARD_BATTLES 3 + +// Stamps are 32 bits. The first 16 bits are the species +// and the second 16 bits are a number (presumably an ID of some kind) +#define STAMP_SPECIES 0 +#define STAMP_ID 1 + +// Number of different types/colors of Wonder Card and News backgrounds +#define NUM_WONDER_BGS 8 + +#define MAX_WONDER_CARD_STAT 999 + +#define WONDER_CARD_FLAG_OFFSET 1000 + +#endif //GUARD_CONSTANTS_MYSTERY_GIFT_H diff --git a/include/mevent.h b/include/mevent.h deleted file mode 100755 index be7f5f8e6..000000000 --- a/include/mevent.h +++ /dev/null @@ -1,57 +0,0 @@ -#ifndef GUARD_MEVENT_H -#define GUARD_MEVENT_H - -#include "main.h" -#include "constants/mevent.h" - -struct MysteryGiftLinkGameData -{ - // It's possible these first 5 fields had some other meaningful purpose, - // but they are only ever set when creating this data and read to validate it. - u32 validationVar; - u16 validationFlag1; - u32 validationFlag2; - u16 validationGiftType1; - u32 validationGiftType2; - u16 flagId; - u16 questionnaireWords[NUM_QUESTIONNAIRE_WORDS]; - struct WonderCardMetadata cardMetadata; - u8 maxStamps; - u8 playerName[PLAYER_NAME_LENGTH]; - u8 playerTrainerId[TRAINER_ID_LENGTH]; - u16 easyChatProfile[EASY_CHAT_BATTLE_WORDS_COUNT]; - u8 romHeaderGameCode[GAME_CODE_LENGTH]; - u8 romHeaderSoftwareVersion; -}; - -void ClearMysteryGift(void); -struct WonderNews *GetSavedWonderNews(void); -struct WonderCard *GetSavedWonderCard(void); -struct WonderCardMetadata *GetSavedWonderCardMetadata(void); -struct WonderNewsMetadata *GetSavedWonderNewsMetadata(void); -u16 *GetQuestionnaireWordsPtr(void); -void ClearSavedWonderNewsAndRelated(void); -void ClearSavedWonderCardAndRelated(void); -bool32 SaveWonderNews(const struct WonderNews *news); -bool32 SaveWonderCard(const struct WonderCard *card); -bool32 ValidateSavedWonderNews(void); -bool32 ValidateSavedWonderCard(void); -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 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); -void MysteryGift_DisableStats(void); -bool32 MysteryGift_TryEnableStatsByFlagId(u16 flagId); -void MysteryGift_TryIncrementStat(u32 stat, u32 trainerId); - -#endif //GUARD_MEVENT_H diff --git a/include/mevent_client.h b/include/mevent_client.h deleted file mode 100644 index cc189ccc9..000000000 --- a/include/mevent_client.h +++ /dev/null @@ -1,92 +0,0 @@ -#ifndef GUARD_MEVENT_CLIENT_H -#define GUARD_MEVENT_CLIENT_H - -#include "mevent_server_helpers.h" - -// Return values for client functions called by MysteryGiftClient_Run -enum { - CLI_RET_INIT, - CLI_RET_ACTIVE, - CLI_RET_YES_NO, - CLI_RET_PRINT_MSG, - CLI_RET_ASK_TOSS, - CLI_RET_COPY_MSG, - CLI_RET_END, -}; - -// IDs for client script instructions -enum { - CLI_NONE, - CLI_RETURN, - CLI_RECV, - CLI_SEND_LOADED, - CLI_COPY_RECV, - CLI_YES_NO, - CLI_COPY_RECV_IF_N, - CLI_COPY_RECV_IF, - CLI_LOAD_GAME_DATA, - CLI_SAVE_NEWS, - CLI_SAVE_CARD, - CLI_PRINT_MSG, - CLI_COPY_MSG, - CLI_ASK_TOSS, - CLI_LOAD_TOSS_RESPONSE, - CLI_RUN_GIFT_SCRIPT, - CLI_SAVE_STAMP, - CLI_SAVE_RAM_SCRIPT, - CLI_RECV_EREADER_TRAINER, - CLI_SEND_STAT, - CLI_SEND_READY_END, - CLI_RUN_BUFFER_SCRIPT, -}; - -// IDs for client messages when ending a script. -// Given as the parameter to CLI_RETURN, and resolved to text in GetClientResultMessage -enum { - CLI_MSG_NOTHING_SENT, - CLI_MSG_RECORD_UPLOADED, - CLI_MSG_CARD_RECEIVED, - CLI_MSG_NEWS_RECEIVED, - CLI_MSG_STAMP_RECEIVED, - CLI_MSG_HAD_CARD, - CLI_MSG_HAD_STAMP, - CLI_MSG_HAD_NEWS, - CLI_MSG_NO_ROOM_STAMPS, - CLI_MSG_COMM_CANCELED, - CLI_MSG_CANT_ACCEPT, - CLI_MSG_COMM_ERROR, - CLI_MSG_TRAINER_RECEIVED, - CLI_MSG_BUFFER_SUCCESS, - CLI_MSG_BUFFER_FAILURE, -}; - -#define CLIENT_MAX_MSG_SIZE 64 - -struct MysteryGiftClientCmd -{ - u32 instr; - u32 parameter; -}; - -struct MysteryGiftClient -{ - u32 unused; - u32 param; - u32 funcId; - u32 funcState; - u32 cmdidx; - void * sendBuffer; - void * recvBuffer; - struct MysteryGiftClientCmd * script; - void * msg; - struct MysteryGiftLink link; - bool32 isWonderNews; -}; - -void MysteryGiftClient_Create(bool32 isWonderNews); -u32 MysteryGiftClient_Run(u16 * endVal); -void MysteryGiftClient_AdvanceState(void); -void * MysteryGiftClient_GetMsg(void); -void MysteryGiftClient_SetParam(u32 value); - -#endif //GUARD_MEVENT_CLIENT_H diff --git a/include/mevent_news.h b/include/mevent_news.h deleted file mode 100755 index b0a0b8f07..000000000 --- a/include/mevent_news.h +++ /dev/null @@ -1,15 +0,0 @@ -#ifndef GUARD_MEVENT_NEWS_H -#define GUARD_MEVENT_NEWS_H - -enum { - WONDER_NEWS_NONE, - WONDER_NEWS_RECV_FRIEND, - WONDER_NEWS_RECV_WIRELESS, - WONDER_NEWS_SENT, -}; - - -void InitSavedWonderNews(void); -void GenerateRandomWonderNews(u32 newsType); - -#endif //GUARD_MEVENT_NEWS_H diff --git a/include/mevent_server.h b/include/mevent_server.h deleted file mode 100644 index 98cb03f6a..000000000 --- a/include/mevent_server.h +++ /dev/null @@ -1,100 +0,0 @@ -#ifndef GUARD_MEVENT_SERVER_H -#define GUARD_MEVENT_SERVER_H - -#include "mevent_server_helpers.h" - -// Return values for Server_* functions. -// Other than SVR_RET_END, effectively useless (not checked for). -enum { - SVR_RET_INIT, - SVR_RET_ACTIVE, - SVR_RET_UNUSED, - SVR_RET_END -}; - -// IDs for server script instructions -enum { - SVR_RETURN, - SVR_SEND, - SVR_RECV, - SVR_GOTO, - SVR_GOTO_IF_EQ, - SVR_COPY_GAME_DATA, - SVR_CHECK_GAME_DATA_CARD, - SVR_CHECK_EXISTING_CARD, - SVR_READ_RESPONSE, - SVR_CHECK_EXISTING_STAMPS, - SVR_GET_CARD_STAT, - SVR_CHECK_QUESTIONNAIRE, - SVR_COMPARE, - SVR_LOAD_CARD, - SVR_LOAD_NEWS, - SVR_LOAD_RAM_SCRIPT, - SVR_LOAD_STAMP, - SVR_LOAD_UNK_2, - SVR_LOAD_CLIENT_SCRIPT, - SVR_LOAD_EREADER_TRAINER, - SVR_LOAD_MSG, - SVR_COPY_STAMP, - SVR_COPY_CARD, - SVR_COPY_NEWS, - SVR_SET_RAM_SCRIPT, - SVR_SET_CLIENT_SCRIPT, - SVR_COPY_SAVED_CARD, - SVR_COPY_SAVED_NEWS, - SVR_COPY_SAVED_RAM_SCRIPT, - SVR_LOAD_UNK_1, - SVR_CHECK_GAME_DATA_NEWS, -}; - -// IDs for server messages when ending a script. -// Given as the parameter to SVR_RETURN, and resolved to text in GetServerResultMessage -enum { - SVR_MSG_NOTHING_SENT, - SVR_MSG_RECORD_UPLOADED, - SVR_MSG_CARD_SENT, - SVR_MSG_NEWS_SENT, - SVR_MSG_STAMP_SENT, - SVR_MSG_HAS_CARD, - SVR_MSG_HAS_STAMP, - SVR_MSG_HAS_NEWS, - SVR_MSG_NO_ROOM_STAMPS, - SVR_MSG_CLIENT_CANCELED, - SVR_MSG_CANT_SEND_GIFT_1, - SVR_MSG_COMM_ERROR, - SVR_MSG_GIFT_SENT_1, - SVR_MSG_GIFT_SENT_2, - SVR_MSG_CANT_SEND_GIFT_2, -}; - -struct MysteryGiftServerCmd -{ - u32 instr; - u32 parameter; - const void * ptr; -}; - -struct MysteryGiftServer -{ - u32 unused; - u32 param; - u32 funcId; - u32 cmdidx; - const struct MysteryGiftServerCmd * script; - void * recvBuffer; - struct WonderCard * card; - struct WonderNews * news; - struct MysteryGiftLinkGameData * linkGameData; - const void * ramScript; - u32 ramScriptSize; - const void * clientScript; - u32 clientScriptSize; - u32 stamp; - struct MysteryGiftLink link; -}; - -void MysterGiftServer_CreateForCard(); -void MysterGiftServer_CreateForNews(); -u32 MysterGiftServer_Run(u16 * endVal); - -#endif //GUARD_MEVENT_SERVER_H diff --git a/include/mevent_server_helpers.h b/include/mevent_server_helpers.h deleted file mode 100644 index e8556419d..000000000 --- a/include/mevent_server_helpers.h +++ /dev/null @@ -1,49 +0,0 @@ -#ifndef GUARD_MEVENT_SERVER_HELPERS_H -#define GUARD_MEVENT_SERVER_HELPERS_H - -#define MG_LINK_BUFFER_SIZE 0x400 - -// Send/receive ids for the Client/Server to make sure -// they're sending/receiving the same thing -enum { - MG_LINKID_CLIENT_SCRIPT = 16, - MG_LINKID_GAME_DATA, - MG_LINKID_GAME_STAT, - MG_LINKID_RESPONSE, - MG_LINKID_READY_END, - MG_LINKID_DYNAMIC_MSG, - MG_LINKID_CARD, - MG_LINKID_NEWS, - MG_LINKID_STAMP, - MG_LINKID_RAM_SCRIPT, - MG_LINKID_EREADER_TRAINER, - MG_LINKID_UNK_1, - MG_LINKID_UNK_2, -}; - -struct MysteryGiftLink -{ - s32 state; - u8 sendPlayerId; - u8 recvPlayerId; - u16 recvIdent; - u16 recvCounter; - u16 recvCRC; - u16 recvSize; - u16 sendIdent; - u16 sendCounter; - u16 sendCRC; - u16 sendSize; - void * recvBuffer; - const void * sendBuffer; - u32 (*recvFunc)(struct MysteryGiftLink *); - u32 (*sendFunc)(struct MysteryGiftLink *); -}; - -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 diff --git a/include/mystery_event_msg.h b/include/mystery_event_msg.h index 465b60ccb..184496023 100644 --- a/include/mystery_event_msg.h +++ b/include/mystery_event_msg.h @@ -1,16 +1,16 @@ #ifndef GUARD_MYSTERY_EVENT_MSG_H #define GUARD_MYSTERY_EVENT_MSG_H -extern const u8 gText_MysteryGiftBerry[]; -extern const u8 gText_MysteryGiftBerryTransform[]; -extern const u8 gText_MysteryGiftBerryObtained[]; -extern const u8 gText_MysteryGiftSpecialRibbon[]; -extern const u8 gText_MysteryGiftNationalDex[]; -extern const u8 gText_MysteryGiftRareWord[]; -extern const u8 gText_MysteryGiftSentOver[]; -extern const u8 gText_MysteryGiftFullParty[]; -extern const u8 gText_MysteryGiftNewTrainer[]; -extern const u8 gText_MysteryGiftNewAdversaryInBattleTower[]; -extern const u8 gText_MysteryGiftCantBeUsed[]; +extern const u8 gText_MysteryEventBerry[]; +extern const u8 gText_MysteryEventBerryTransform[]; +extern const u8 gText_MysteryEventBerryObtained[]; +extern const u8 gText_MysteryEventSpecialRibbon[]; +extern const u8 gText_MysteryEventNationalDex[]; +extern const u8 gText_MysteryEventRareWord[]; +extern const u8 gText_MysteryEventSentOver[]; +extern const u8 gText_MysteryEventFullParty[]; +extern const u8 gText_MysteryEventNewTrainer[]; +extern const u8 gText_MysteryEventNewAdversaryInBattleTower[]; +extern const u8 gText_MysteryEventCantBeUsed[]; #endif // GUARD_MYSTERY_EVENT_MSG_H diff --git a/include/mystery_event_script.h b/include/mystery_event_script.h index 807c78b13..32b9f009f 100644 --- a/include/mystery_event_script.h +++ b/include/mystery_event_script.h @@ -1,8 +1,8 @@ #ifndef GUARD_MYSTERY_EVENT_SCRIPT_H #define GUARD_MYSTERY_EVENT_SCRIPT_H -void InitMysteryGiftScriptContext(u8 *script); -bool32 RunMysteryGiftScriptContextCommand(u32 *script); +void InitMysteryEventScriptContext(u8 *script); +bool32 RunMysteryEventScriptContextCommand(u32 *script); u32 RunMysteryEventScript(u8 *script); void SetMysteryEventScriptStatus(u32 val); u16 GetRecordMixingGift(void); diff --git a/include/mystery_gift.h b/include/mystery_gift.h old mode 100644 new mode 100755 index 73d3b93ea..3b27b3f2d --- a/include/mystery_gift.h +++ b/include/mystery_gift.h @@ -1,18 +1,57 @@ #ifndef GUARD_MYSTERY_GIFT_H #define GUARD_MYSTERY_GIFT_H -extern bool8 gGiftIsFromEReader; +#include "main.h" +#include "constants/mystery_gift.h" -u16 GetMysteryGiftBaseBlock(void); -void CB2_MysteryGiftEReader(void); -void PrintMysteryGiftOrEReaderTopMenu(bool8 isJapanese, bool32 usePickOkCancel); -void MG_DrawCheckerboardPattern(u32 bg); -void MainCB_FreeAllBuffersAndReturnToInitTitleScreen(void); -bool32 PrintMysteryGiftMenuMessage(u8 *textState, const u8 *str); -void AddTextPrinterToWindow1(const u8 *src); -void CB2_InitEReader(void); -void CB2_InitMysteryGift(void); -void MG_DrawTextBorder(u8 windowId); -s8 DoMysteryGiftYesNo(u8 *textState, u16 *windowId, bool8 yesNoBoxPlacement, const u8 *str); +struct MysteryGiftLinkGameData +{ + // It's possible these first 5 fields had some other meaningful purpose, + // but they are only ever set when creating this data and read to validate it. + u32 validationVar; + u16 validationFlag1; + u32 validationFlag2; + u16 validationGiftType1; + u32 validationGiftType2; + u16 flagId; + u16 questionnaireWords[NUM_QUESTIONNAIRE_WORDS]; + struct WonderCardMetadata cardMetadata; + u8 maxStamps; + u8 playerName[PLAYER_NAME_LENGTH]; + u8 playerTrainerId[TRAINER_ID_LENGTH]; + u16 easyChatProfile[EASY_CHAT_BATTLE_WORDS_COUNT]; + u8 romHeaderGameCode[GAME_CODE_LENGTH]; + u8 romHeaderSoftwareVersion; +}; + +void ClearMysteryGift(void); +struct WonderNews *GetSavedWonderNews(void); +struct WonderCard *GetSavedWonderCard(void); +struct WonderCardMetadata *GetSavedWonderCardMetadata(void); +struct WonderNewsMetadata *GetSavedWonderNewsMetadata(void); +u16 *GetQuestionnaireWordsPtr(void); +void ClearSavedWonderNewsAndRelated(void); +void ClearSavedWonderCardAndRelated(void); +bool32 SaveWonderNews(const struct WonderNews *news); +bool32 SaveWonderCard(const struct WonderCard *card); +bool32 ValidateSavedWonderNews(void); +bool32 ValidateSavedWonderCard(void); +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 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); +void MysteryGift_DisableStats(void); +bool32 MysteryGift_TryEnableStatsByFlagId(u16 flagId); +void MysteryGift_TryIncrementStat(u32 stat, u32 trainerId); #endif //GUARD_MYSTERY_GIFT_H diff --git a/include/mystery_gift_client.h b/include/mystery_gift_client.h new file mode 100644 index 000000000..8214d69ef --- /dev/null +++ b/include/mystery_gift_client.h @@ -0,0 +1,92 @@ +#ifndef GUARD_MYSTERY_GIFT_CLIENT_H +#define GUARD_MYSTERY_GIFT_CLIENT_H + +#include "mystery_gift_link.h" + +// Return values for client functions called by MysteryGiftClient_Run +enum { + CLI_RET_INIT, + CLI_RET_ACTIVE, + CLI_RET_YES_NO, + CLI_RET_PRINT_MSG, + CLI_RET_ASK_TOSS, + CLI_RET_COPY_MSG, + CLI_RET_END, +}; + +// IDs for client script instructions +enum { + CLI_NONE, + CLI_RETURN, + CLI_RECV, + CLI_SEND_LOADED, + CLI_COPY_RECV, + CLI_YES_NO, + CLI_COPY_RECV_IF_N, + CLI_COPY_RECV_IF, + CLI_LOAD_GAME_DATA, + CLI_SAVE_NEWS, + CLI_SAVE_CARD, + CLI_PRINT_MSG, + CLI_COPY_MSG, + CLI_ASK_TOSS, + CLI_LOAD_TOSS_RESPONSE, + CLI_RUN_MEVENT_SCRIPT, + CLI_SAVE_STAMP, + CLI_SAVE_RAM_SCRIPT, + CLI_RECV_EREADER_TRAINER, + CLI_SEND_STAT, + CLI_SEND_READY_END, + CLI_RUN_BUFFER_SCRIPT, +}; + +// IDs for client messages when ending a script. +// Given as the parameter to CLI_RETURN, and resolved to text in GetClientResultMessage +enum { + CLI_MSG_NOTHING_SENT, + CLI_MSG_RECORD_UPLOADED, + CLI_MSG_CARD_RECEIVED, + CLI_MSG_NEWS_RECEIVED, + CLI_MSG_STAMP_RECEIVED, + CLI_MSG_HAD_CARD, + CLI_MSG_HAD_STAMP, + CLI_MSG_HAD_NEWS, + CLI_MSG_NO_ROOM_STAMPS, + CLI_MSG_COMM_CANCELED, + CLI_MSG_CANT_ACCEPT, + CLI_MSG_COMM_ERROR, + CLI_MSG_TRAINER_RECEIVED, + CLI_MSG_BUFFER_SUCCESS, + CLI_MSG_BUFFER_FAILURE, +}; + +#define CLIENT_MAX_MSG_SIZE 64 + +struct MysteryGiftClientCmd +{ + u32 instr; + u32 parameter; +}; + +struct MysteryGiftClient +{ + u32 unused; + u32 param; + u32 funcId; + u32 funcState; + u32 cmdidx; + void * sendBuffer; + void * recvBuffer; + struct MysteryGiftClientCmd * script; + void * msg; + struct MysteryGiftLink link; + bool32 isWonderNews; +}; + +void MysteryGiftClient_Create(bool32 isWonderNews); +u32 MysteryGiftClient_Run(u16 * endVal); +void MysteryGiftClient_AdvanceState(void); +void * MysteryGiftClient_GetMsg(void); +void MysteryGiftClient_SetParam(u32 value); + +#endif //GUARD_MYSTERY_GIFT_CLIENT_H diff --git a/include/mystery_gift_link.h b/include/mystery_gift_link.h new file mode 100644 index 000000000..32100db5f --- /dev/null +++ b/include/mystery_gift_link.h @@ -0,0 +1,49 @@ +#ifndef GUARD_MYSTERY_GIFT_LINK_H +#define GUARD_MYSTERY_GIFT_LINK_H + +#define MG_LINK_BUFFER_SIZE 0x400 + +// Send/receive ids for the Client/Server to make sure +// they're sending/receiving the same thing +enum { + MG_LINKID_CLIENT_SCRIPT = 16, + MG_LINKID_GAME_DATA, + MG_LINKID_GAME_STAT, + MG_LINKID_RESPONSE, + MG_LINKID_READY_END, + MG_LINKID_DYNAMIC_MSG, + MG_LINKID_CARD, + MG_LINKID_NEWS, + MG_LINKID_STAMP, + MG_LINKID_RAM_SCRIPT, + MG_LINKID_EREADER_TRAINER, + MG_LINKID_UNK_1, + MG_LINKID_UNK_2, +}; + +struct MysteryGiftLink +{ + s32 state; + u8 sendPlayerId; + u8 recvPlayerId; + u16 recvIdent; + u16 recvCounter; + u16 recvCRC; + u16 recvSize; + u16 sendIdent; + u16 sendCounter; + u16 sendCRC; + u16 sendSize; + void * recvBuffer; + const void * sendBuffer; + u32 (*recvFunc)(struct MysteryGiftLink *); + u32 (*sendFunc)(struct MysteryGiftLink *); +}; + +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_MYSTERY_GIFT_LINK_H diff --git a/include/mystery_gift_menu.h b/include/mystery_gift_menu.h new file mode 100644 index 000000000..dc30d3051 --- /dev/null +++ b/include/mystery_gift_menu.h @@ -0,0 +1,18 @@ +#ifndef GUARD_MYSTERY_GIFT_MENU_H +#define GUARD_MYSTERY_GIFT_MENU_H + +extern bool8 gGiftIsFromEReader; + +u16 GetMysteryGiftBaseBlock(void); +void CB2_MysteryGiftEReader(void); +void PrintMysteryGiftOrEReaderTopMenu(bool8 isJapanese, bool32 usePickOkCancel); +void MG_DrawCheckerboardPattern(u32 bg); +void MainCB_FreeAllBuffersAndReturnToInitTitleScreen(void); +bool32 PrintMysteryGiftMenuMessage(u8 *textState, const u8 *str); +void AddTextPrinterToWindow1(const u8 *src); +void CB2_InitEReader(void); +void CB2_InitMysteryGift(void); +void MG_DrawTextBorder(u8 windowId); +s8 DoMysteryGiftYesNo(u8 *textState, u16 *windowId, bool8 yesNoBoxPlacement, const u8 *str); + +#endif //GUARD_MYSTERY_GIFT_MENU_H diff --git a/include/mystery_gift_server.h b/include/mystery_gift_server.h new file mode 100644 index 000000000..8e3842f73 --- /dev/null +++ b/include/mystery_gift_server.h @@ -0,0 +1,100 @@ +#ifndef GUARD_MYSTERY_GIFT_SERVER_H +#define GUARD_MYSTERY_GIFT_SERVER_H + +#include "mystery_gift_link.h" + +// Return values for Server_* functions. +// Other than SVR_RET_END, effectively useless (not checked for). +enum { + SVR_RET_INIT, + SVR_RET_ACTIVE, + SVR_RET_UNUSED, + SVR_RET_END +}; + +// IDs for server script instructions +enum { + SVR_RETURN, + SVR_SEND, + SVR_RECV, + SVR_GOTO, + SVR_GOTO_IF_EQ, + SVR_COPY_GAME_DATA, + SVR_CHECK_GAME_DATA_CARD, + SVR_CHECK_EXISTING_CARD, + SVR_READ_RESPONSE, + SVR_CHECK_EXISTING_STAMPS, + SVR_GET_CARD_STAT, + SVR_CHECK_QUESTIONNAIRE, + SVR_COMPARE, + SVR_LOAD_CARD, + SVR_LOAD_NEWS, + SVR_LOAD_RAM_SCRIPT, + SVR_LOAD_STAMP, + SVR_LOAD_UNK_2, + SVR_LOAD_CLIENT_SCRIPT, + SVR_LOAD_EREADER_TRAINER, + SVR_LOAD_MSG, + SVR_COPY_STAMP, + SVR_COPY_CARD, + SVR_COPY_NEWS, + SVR_SET_RAM_SCRIPT, + SVR_SET_CLIENT_SCRIPT, + SVR_COPY_SAVED_CARD, + SVR_COPY_SAVED_NEWS, + SVR_COPY_SAVED_RAM_SCRIPT, + SVR_LOAD_UNK_1, + SVR_CHECK_GAME_DATA_NEWS, +}; + +// IDs for server messages when ending a script. +// Given as the parameter to SVR_RETURN, and resolved to text in GetServerResultMessage +enum { + SVR_MSG_NOTHING_SENT, + SVR_MSG_RECORD_UPLOADED, + SVR_MSG_CARD_SENT, + SVR_MSG_NEWS_SENT, + SVR_MSG_STAMP_SENT, + SVR_MSG_HAS_CARD, + SVR_MSG_HAS_STAMP, + SVR_MSG_HAS_NEWS, + SVR_MSG_NO_ROOM_STAMPS, + SVR_MSG_CLIENT_CANCELED, + SVR_MSG_CANT_SEND_GIFT_1, + SVR_MSG_COMM_ERROR, + SVR_MSG_GIFT_SENT_1, + SVR_MSG_GIFT_SENT_2, + SVR_MSG_CANT_SEND_GIFT_2, +}; + +struct MysteryGiftServerCmd +{ + u32 instr; + u32 parameter; + const void * ptr; +}; + +struct MysteryGiftServer +{ + u32 unused; + u32 param; + u32 funcId; + u32 cmdidx; + const struct MysteryGiftServerCmd * script; + void * recvBuffer; + struct WonderCard * card; + struct WonderNews * news; + struct MysteryGiftLinkGameData * linkGameData; + const void * ramScript; + u32 ramScriptSize; + const void * clientScript; + u32 clientScriptSize; + u32 stamp; + struct MysteryGiftLink link; +}; + +void MysterGiftServer_CreateForCard(); +void MysterGiftServer_CreateForNews(); +u32 MysterGiftServer_Run(u16 * endVal); + +#endif //GUARD_MYSTERY_GIFT_SERVER_H diff --git a/include/mystery_gift_view.h b/include/mystery_gift_view.h new file mode 100644 index 000000000..038093c7a --- /dev/null +++ b/include/mystery_gift_view.h @@ -0,0 +1,24 @@ +#ifndef GUARD_MYSTERY_GIFT_VIEW_H +#define GUARD_MYSTERY_GIFT_VIEW_H + +enum { + NEWS_INPUT_A, + NEWS_INPUT_B, + NEWS_INPUT_SCROLL_UP, + NEWS_INPUT_SCROLL_DOWN, + NEWS_INPUT_NONE = 0xFF +}; + +bool32 WonderCard_Init(struct WonderCard * card, struct WonderCardMetadata * metadata); +bool32 WonderNews_Init(const struct WonderNews * news); +s32 WonderCard_Enter(void); +s32 WonderNews_Enter(void); +s32 WonderCard_Exit(bool32 flag); +s32 WonderNews_Exit(bool32 flag); +void WonderCard_Destroy(void); +void WonderNews_Destroy(void); +u32 WonderNews_GetInput(u16 input); +void WonderNews_AddScrollIndicatorArrowPair(void); +void WonderNews_RemoveScrollIndicatorArrowPair(void); + +#endif //GUARD_MYSTERY_GIFT_VIEW_H diff --git a/include/wonder_news.h b/include/wonder_news.h new file mode 100755 index 000000000..68fd59e4c --- /dev/null +++ b/include/wonder_news.h @@ -0,0 +1,15 @@ +#ifndef GUARD_WONDER_NEWS_H +#define GUARD_WONDER_NEWS_H + +enum { + WONDER_NEWS_NONE, + WONDER_NEWS_RECV_FRIEND, + WONDER_NEWS_RECV_WIRELESS, + WONDER_NEWS_SENT, +}; + + +void InitSavedWonderNews(void); +void GenerateRandomWonderNews(u32 newsType); + +#endif //GUARD_WONDER_NEWS_H diff --git a/include/wonder_transfer.h b/include/wonder_transfer.h deleted file mode 100644 index a9e80b1c7..000000000 --- a/include/wonder_transfer.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef GUARD_WONDER_TRANSFER_H -#define GUARD_WONDER_TRANSFER_H - -enum { - NEWS_INPUT_A, - NEWS_INPUT_B, - NEWS_INPUT_SCROLL_UP, - NEWS_INPUT_SCROLL_DOWN, - NEWS_INPUT_NONE = 0xFF -}; - -bool32 WonderCard_Init(struct WonderCard * card, struct WonderCardMetadata * metadata); -bool32 WonderNews_Init(const struct WonderNews * news); -s32 WonderCard_Enter(void); -s32 WonderNews_Enter(void); -s32 WonderCard_Exit(bool32 flag); -s32 WonderNews_Exit(bool32 flag); -void WonderCard_Destroy(void); -void WonderNews_Destroy(void); -u32 WonderNews_GetInput(u16 input); -void WonderNews_AddScrollIndicatorArrowPair(void); -void WonderNews_RemoveScrollIndicatorArrowPair(void); - -#endif //GUARD_WONDER_TRANSFER_H -- cgit v1.2.3