Correct usage of MysteryEvent to MysteryGift

This commit is contained in:
GriffinR
2021-10-17 03:00:48 -04:00
parent d0455485c3
commit ece7ef3410
48 changed files with 2492 additions and 2492 deletions

View File

@@ -1,5 +1,5 @@
#ifndef GUARD_CONSTANTS_MEVENT_H
#define GUARD_CONSTANTS_MEVENT_H
#ifndef GUARD_CONSTANTS_MYSTERY_GIFT_H
#define GUARD_CONSTANTS_MYSTERY_GIFT_H
#define GET_NUM_STAMPS 0
#define GET_MAX_STAMPS 1
@@ -44,4 +44,4 @@
#define WONDER_CARD_FLAG_OFFSET 1000
#endif //GUARD_MEVENT_H
#endif //GUARD_CONSTANTS_MYSTERY_GIFT_H

View File

@@ -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

View File

@@ -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

View File

@@ -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);

63
include/mystery_gift.h Normal file → Executable file
View File

@@ -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

View File

@@ -1,7 +1,7 @@
#ifndef GUARD_MEVENT_CLIENT_H
#define GUARD_MEVENT_CLIENT_H
#ifndef GUARD_MYSTERY_GIFT_CLIENT_H
#define GUARD_MYSTERY_GIFT_CLIENT_H
#include "mevent_server_helpers.h"
#include "mystery_gift_link.h"
// Return values for client functions called by MysteryGiftClient_Run
enum {
@@ -31,7 +31,7 @@ enum {
CLI_COPY_MSG,
CLI_ASK_TOSS,
CLI_LOAD_TOSS_RESPONSE,
CLI_RUN_GIFT_SCRIPT,
CLI_RUN_MEVENT_SCRIPT,
CLI_SAVE_STAMP,
CLI_SAVE_RAM_SCRIPT,
CLI_RECV_EREADER_TRAINER,
@@ -89,4 +89,4 @@ void MysteryGiftClient_AdvanceState(void);
void * MysteryGiftClient_GetMsg(void);
void MysteryGiftClient_SetParam(u32 value);
#endif //GUARD_MEVENT_CLIENT_H
#endif //GUARD_MYSTERY_GIFT_CLIENT_H

View File

@@ -1,5 +1,5 @@
#ifndef GUARD_MEVENT_SERVER_HELPERS_H
#define GUARD_MEVENT_SERVER_HELPERS_H
#ifndef GUARD_MYSTERY_GIFT_LINK_H
#define GUARD_MYSTERY_GIFT_LINK_H
#define MG_LINK_BUFFER_SIZE 0x400
@@ -46,4 +46,4 @@ 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
#endif //GUARD_MYSTERY_GIFT_LINK_H

View File

@@ -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

View File

@@ -1,7 +1,7 @@
#ifndef GUARD_MEVENT_SERVER_H
#define GUARD_MEVENT_SERVER_H
#ifndef GUARD_MYSTERY_GIFT_SERVER_H
#define GUARD_MYSTERY_GIFT_SERVER_H
#include "mevent_server_helpers.h"
#include "mystery_gift_link.h"
// Return values for Server_* functions.
// Other than SVR_RET_END, effectively useless (not checked for).
@@ -97,4 +97,4 @@ void MysterGiftServer_CreateForCard();
void MysterGiftServer_CreateForNews();
u32 MysterGiftServer_Run(u16 * endVal);
#endif //GUARD_MEVENT_SERVER_H
#endif //GUARD_MYSTERY_GIFT_SERVER_H

View File

@@ -1,5 +1,5 @@
#ifndef GUARD_WONDER_TRANSFER_H
#define GUARD_WONDER_TRANSFER_H
#ifndef GUARD_MYSTERY_GIFT_VIEW_H
#define GUARD_MYSTERY_GIFT_VIEW_H
enum {
NEWS_INPUT_A,
@@ -21,4 +21,4 @@ u32 WonderNews_GetInput(u16 input);
void WonderNews_AddScrollIndicatorArrowPair(void);
void WonderNews_RemoveScrollIndicatorArrowPair(void);
#endif //GUARD_WONDER_TRANSFER_H
#endif //GUARD_MYSTERY_GIFT_VIEW_H

View File

@@ -1,5 +1,5 @@
#ifndef GUARD_MEVENT_NEWS_H
#define GUARD_MEVENT_NEWS_H
#ifndef GUARD_WONDER_NEWS_H
#define GUARD_WONDER_NEWS_H
enum {
WONDER_NEWS_NONE,
@@ -12,4 +12,4 @@ enum {
void InitSavedWonderNews(void);
void GenerateRandomWonderNews(u32 newsType);
#endif //GUARD_MEVENT_NEWS_H
#endif //GUARD_WONDER_NEWS_H