mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2024-11-16 11:37:40 +01:00
Document mystery gift link scripts, general mystery gift
This commit is contained in:
parent
37e52c4f34
commit
c02001c46d
@ -6,7 +6,7 @@ CableClub_EventScript_HideOrShowMysteryGiftMan::
|
||||
specialvar VAR_RESULT, ShouldDistributeEonTicket
|
||||
compare VAR_RESULT, TRUE
|
||||
goto_if_eq CableClub_EventScript_ShowMysteryGiftMan
|
||||
specialvar VAR_RESULT, ValidateReceivedWonderCard
|
||||
specialvar VAR_RESULT, ValidateSavedWonderCard
|
||||
compare VAR_RESULT, FALSE
|
||||
goto_if_eq CableClub_EventScript_HideMysteryGiftMan
|
||||
goto CableClub_EventScript_ShowMysteryGiftMan
|
||||
|
@ -434,7 +434,7 @@ gSpecials::
|
||||
def_special ChooseMonForWirelessMinigame
|
||||
def_special Script_ResetUnionRoomTrade
|
||||
def_special IsBadEggInParty
|
||||
def_special ValidateReceivedWonderCard
|
||||
def_special ValidateSavedWonderCard
|
||||
def_special HasAtLeastOneBerry
|
||||
def_special IsPokemonJumpSpeciesInParty
|
||||
def_special ShowPokemonJumpRecords
|
||||
|
@ -338,23 +338,24 @@
|
||||
#define FLAG_RECEIVED_AURORA_TICKET 0x13A
|
||||
#define FLAG_RECEIVED_MYSTIC_TICKET 0x13B
|
||||
#define FLAG_RECEIVED_OLD_SEA_MAP 0x13C
|
||||
#define FLAG_UNUSED_MYSTERY_GIFT_0x13D 0x13D
|
||||
#define FLAG_UNUSED_MYSTERY_GIFT_0x13E 0x13E
|
||||
#define FLAG_UNUSED_MYSTERY_GIFT_0x13F 0x13F
|
||||
#define FLAG_UNUSED_MYSTERY_GIFT_0x140 0x140
|
||||
#define FLAG_UNUSED_MYSTERY_GIFT_0x141 0x141
|
||||
#define FLAG_UNUSED_MYSTERY_GIFT_0x142 0x142
|
||||
#define FLAG_UNUSED_MYSTERY_GIFT_0x143 0x143
|
||||
#define FLAG_UNUSED_MYSTERY_GIFT_0x144 0x144
|
||||
#define FLAG_UNUSED_MYSTERY_GIFT_0x145 0x145
|
||||
#define FLAG_UNUSED_MYSTERY_GIFT_0x146 0x146
|
||||
#define FLAG_UNUSED_MYSTERY_GIFT_0x147 0x147
|
||||
#define FLAG_UNUSED_MYSTERY_GIFT_0x148 0x148
|
||||
#define FLAG_UNUSED_MYSTERY_GIFT_0x149 0x149
|
||||
#define FLAG_UNUSED_MYSTERY_GIFT_0x14A 0x14A
|
||||
#define FLAG_UNUSED_MYSTERY_GIFT_0x14B 0x14B
|
||||
#define FLAG_UNUSED_MYSTERY_GIFT_0x14C 0x14C
|
||||
#define FLAG_UNUSED_MYSTERY_GIFT_0x14D 0x14D
|
||||
#define FLAG_MYSTERY_GIFT_UNUSED_1 0x13D // These mystery gift flags are referenced but never set
|
||||
#define FLAG_MYSTERY_GIFT_UNUSED_2 0x13E
|
||||
#define FLAG_MYSTERY_GIFT_UNUSED_3 0x13F
|
||||
#define FLAG_MYSTERY_GIFT_UNUSED_4 0x140
|
||||
#define FLAG_MYSTERY_GIFT_UNUSED_5 0x141
|
||||
#define FLAG_MYSTERY_GIFT_UNUSED_6 0x142
|
||||
#define FLAG_MYSTERY_GIFT_UNUSED_7 0x143
|
||||
#define FLAG_MYSTERY_GIFT_UNUSED_8 0x144
|
||||
#define FLAG_MYSTERY_GIFT_UNUSED_9 0x145
|
||||
#define FLAG_MYSTERY_GIFT_UNUSED_10 0x146
|
||||
#define FLAG_MYSTERY_GIFT_UNUSED_11 0x147
|
||||
#define FLAG_MYSTERY_GIFT_UNUSED_12 0x148
|
||||
#define FLAG_MYSTERY_GIFT_UNUSED_13 0x149
|
||||
#define FLAG_MYSTERY_GIFT_UNUSED_14 0x14A
|
||||
#define FLAG_MYSTERY_GIFT_UNUSED_15 0x14B
|
||||
#define FLAG_MYSTERY_GIFT_UNUSED_16 0x14C
|
||||
#define FLAG_MYSTERY_GIFT_UNUSED_17 0x14D
|
||||
#define NUM_MYSTERY_GIFT_FLAGS (1 + FLAG_MYSTERY_GIFT_UNUSED_17 - FLAG_RECEIVED_AURORA_TICKET)
|
||||
|
||||
#define FLAG_MIRAGE_TOWER_VISIBLE 0x14E
|
||||
#define FLAG_CHOSE_ROOT_FOSSIL 0x14F
|
||||
|
@ -854,15 +854,9 @@ struct MysteryEventStruct
|
||||
u8 unk_2C[10][WONDER_NEWS_TEXT_LENGTH];
|
||||
};
|
||||
|
||||
struct WonderNewsSaveStruct
|
||||
{
|
||||
u32 crc;
|
||||
struct WonderNews data;
|
||||
};
|
||||
|
||||
struct WonderCard
|
||||
{
|
||||
u16 unk_00;
|
||||
u16 flagId;
|
||||
u16 unk_02;
|
||||
u32 unk_04;
|
||||
u8 unk_08_0:2;
|
||||
@ -876,13 +870,7 @@ struct MysteryEventStruct
|
||||
u8 unk_122[WONDER_CARD_TEXT_LENGTH];
|
||||
};
|
||||
|
||||
struct WonderCardSaveStruct
|
||||
{
|
||||
u32 crc;
|
||||
struct WonderCard data;
|
||||
};
|
||||
|
||||
struct MEventBuffer_3430_Sub
|
||||
struct MEventBuffer_3430
|
||||
{
|
||||
u16 unk_00;
|
||||
u16 unk_02;
|
||||
@ -891,20 +879,17 @@ struct MysteryEventStruct
|
||||
u16 unk_08[2][7];
|
||||
};
|
||||
|
||||
struct MEventBuffer_3430
|
||||
struct MysteryGiftSave
|
||||
{
|
||||
u32 crc;
|
||||
struct MEventBuffer_3430_Sub data;
|
||||
};
|
||||
|
||||
struct MEventBuffers
|
||||
{
|
||||
/*0x000 0x322C*/ struct WonderNewsSaveStruct wonderNews;
|
||||
/*0x1c0 0x33EC*/ struct WonderCardSaveStruct wonderCard;
|
||||
/*0x310 0x353C*/ struct MEventBuffer_3430 buffer_310;
|
||||
/*0x338 0x3564*/ u16 questionnaireWords[NUM_QUESTIONNAIRE_WORDS];
|
||||
/*0x340 0x356C*/ struct MysteryEventStruct unk_340;
|
||||
/*0x344 0x3570*/ u32 unk_344[2][5];
|
||||
u32 newsCrc;
|
||||
struct WonderNews news;
|
||||
u32 cardCrc;
|
||||
struct WonderCard card;
|
||||
u32 unkCrc;
|
||||
struct MEventBuffer_3430 unk_3430;
|
||||
u16 questionnaireWords[NUM_QUESTIONNAIRE_WORDS];
|
||||
struct MysteryEventStruct unk_340;
|
||||
u32 unk_344[2][5];
|
||||
}; // 0x36C 0x3598
|
||||
|
||||
// For external event data storage. The majority of these may have never been used.
|
||||
@ -1031,7 +1016,7 @@ struct SaveBlock1
|
||||
/*0x31C7*/ struct ExternalEventFlags externalEventFlags;
|
||||
/*0x31DC*/ struct Roamer roamer;
|
||||
/*0x31F8*/ struct EnigmaBerry enigmaBerry;
|
||||
/*0x322C*/ struct MEventBuffers unk_322C;
|
||||
/*0x322C*/ struct MysteryGiftSave mysteryGift;
|
||||
/*0x3598*/ u8 field_3598[0x180];
|
||||
/*0x3718*/ u32 trainerHillTimes[4];
|
||||
/*0x3728*/ struct RamScript ramScript;
|
||||
|
@ -21,30 +21,30 @@ struct MEventStruct_Unk1442CC
|
||||
u16 unk_0C;
|
||||
u32 unk_10;
|
||||
u16 unk_14;
|
||||
u16 unk_16[NUM_QUESTIONNAIRE_WORDS];
|
||||
struct MEventBuffer_3430_Sub unk_20;
|
||||
u16 questionnaireWords[NUM_QUESTIONNAIRE_WORDS];
|
||||
struct MEventBuffer_3430 unk_20;
|
||||
u8 unk_44;
|
||||
u8 unk_45[7];
|
||||
u8 unk_4C[4];
|
||||
u16 unk_50[6];
|
||||
u8 unk_5C[4];
|
||||
u8 unk_60;
|
||||
u8 playerName[PLAYER_NAME_LENGTH];
|
||||
u8 playerTrainerId[TRAINER_ID_LENGTH];
|
||||
u16 easyChatProfile[EASY_CHAT_BATTLE_WORDS_COUNT];
|
||||
u8 romHeaderGameCode[4];
|
||||
u8 romHeaderSoftwareVersion;
|
||||
};
|
||||
|
||||
void sub_801AFD8(void);
|
||||
struct WonderNews *GetSavedWonderNews(void);
|
||||
struct WonderCard *GetSavedWonderCard(void);
|
||||
struct MEventBuffer_3430_Sub *sav1_get_mevent_buffer_2(void);
|
||||
struct MEventBuffer_3430 *sav1_get_mevent_buffer_2(void);
|
||||
struct MysteryEventStruct *sub_801B044(void);
|
||||
u16 *GetQuestionnaireWordsPtr(void);
|
||||
void DestroyWonderNews(void);
|
||||
bool32 sub_801B078(const struct WonderNews *src);
|
||||
bool32 ValidateReceivedWonderNews(void);
|
||||
void ClearSavedWonderNews(void);
|
||||
bool32 SaveWonderNews(const struct WonderNews *news);
|
||||
bool32 ValidateSavedWonderNews(void);
|
||||
bool32 WonderNews_Test_Unk_02(void);
|
||||
bool32 sub_801B1A4(const u8 *src);
|
||||
void DestroyWonderCard(void);
|
||||
bool32 sub_801B21C(const struct WonderCard *data);
|
||||
bool32 ValidateReceivedWonderCard(void);
|
||||
void ClearSavedWonderCard(void);
|
||||
bool32 SaveWonderCard(const struct WonderCard *card);
|
||||
bool32 ValidateSavedWonderCard(void);
|
||||
bool32 WonderCard_Test_Unk_08_6(void);
|
||||
u16 GetWonderCardFlagID(void);
|
||||
void WonderCard_ResetInternalReceivedFlag(struct WonderCard *buffer);
|
||||
@ -54,7 +54,7 @@ void sub_801B580(struct MEventStruct_Unk1442CC *data, bool32 a1);
|
||||
bool32 sub_801B6A0(const struct MEventStruct_Unk1442CC *data, bool32 a1);
|
||||
u32 sub_801B6EC(const u16 *a0, const struct MEventStruct_Unk1442CC *a1, const void *unused);
|
||||
u32 sub_801B708(const u16 *a0, const struct MEventStruct_Unk1442CC *a1, const void *unused);
|
||||
bool32 MEventStruct_Unk1442CC_CompareField_unk_16(const struct MEventStruct_Unk1442CC *a0, const u16 *a1);
|
||||
bool32 MysteryGift_DoesQuestionnaireMatch(const struct MEventStruct_Unk1442CC *data, const u16 *words);
|
||||
u16 MEventStruct_Unk1442CC_GetValueNFrom_unk_20(const struct MEventStruct_Unk1442CC *a0, u32 command);
|
||||
u16 mevent_081445C0(u32 command);
|
||||
void ResetReceivedWonderCardFlag(void);
|
||||
|
@ -3,31 +3,68 @@
|
||||
|
||||
#include "mevent_server_helpers.h"
|
||||
|
||||
struct mevent_client_cmd
|
||||
// Return values for client functions called by MysteryGiftClient_Run
|
||||
enum {
|
||||
CLI_RET_INIT,
|
||||
CLI_RET_1,
|
||||
CLI_RET_2,
|
||||
CLI_RET_3,
|
||||
CLI_RET_ASK_TOSS,
|
||||
CLI_RET_5,
|
||||
CLI_RET_END,
|
||||
};
|
||||
|
||||
// IDs for client script instructions
|
||||
enum {
|
||||
CLI_NONE,
|
||||
CLI_RETURN,
|
||||
CLI_RECV,
|
||||
CLI_SEND_LOADED,
|
||||
CLI_COPY_RECV,
|
||||
CLI_5,
|
||||
CLI_COPY_RECV_IF_N,
|
||||
CLI_COPY_RECV_IF,
|
||||
CLI_8,
|
||||
CLI_9,
|
||||
CLI_10,
|
||||
CLI_11,
|
||||
CLI_12,
|
||||
CLI_ASK_TOSS,
|
||||
CLI_LOAD_TOSS_RESPONSE,
|
||||
CLI_15,
|
||||
CLI_16,
|
||||
CLI_17,
|
||||
CLI_RECV_EREADER_TRAINER,
|
||||
CLI_SEND_STAT,
|
||||
CLI_20,
|
||||
CLI_21,
|
||||
};
|
||||
|
||||
struct MysteryGiftClientCmd
|
||||
{
|
||||
u32 instr;
|
||||
u32 parameter;
|
||||
};
|
||||
|
||||
struct mevent_client
|
||||
struct MysteryGiftClient
|
||||
{
|
||||
u32 unk_00;
|
||||
u32 param;
|
||||
u32 mainseqno;
|
||||
u32 flag;
|
||||
u32 funcId;
|
||||
u32 funcState;
|
||||
u32 cmdidx;
|
||||
void * sendBuffer;
|
||||
void * recvBuffer;
|
||||
struct mevent_client_cmd * cmdBuffer;
|
||||
struct MysteryGiftClientCmd * cmdBuffer;
|
||||
void * buffer;
|
||||
struct mevent_srv_sub manager;
|
||||
u32 unk_4C;
|
||||
struct MysteryGiftLink link;
|
||||
bool32 isWonderNews;
|
||||
};
|
||||
|
||||
void mevent_client_do_init(u32 arg);
|
||||
u32 mevent_client_do_exec(u16 * a0);
|
||||
void mevent_client_inc_flag(void);
|
||||
void MysteryGiftClient_Create(bool32 isWonderNews);
|
||||
u32 MysteryGiftClient_Run(u16 * param);
|
||||
void MysteryGiftClient_AdvanceState(void);
|
||||
void * mevent_client_get_buffer(void);
|
||||
void mevent_client_set_param(u32 a0);
|
||||
void MysteryGiftClient_SetParam(u32 value);
|
||||
|
||||
#endif //GUARD_MEVENT_CLIENT_H
|
||||
|
@ -26,7 +26,7 @@ struct mevent_srv_common
|
||||
const void * sendBuffer2;
|
||||
u32 sendBuffer2Size;
|
||||
u32 sendWord;
|
||||
struct mevent_srv_sub manager;
|
||||
struct MysteryGiftLink manager;
|
||||
};
|
||||
|
||||
void mevent_srv_new_wcard();
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
#define ME_SEND_BUF_SIZE 0x400
|
||||
|
||||
struct mevent_srv_sub
|
||||
struct MysteryGiftLink
|
||||
{
|
||||
s32 seqno;
|
||||
u8 sendPlayerNo;
|
||||
@ -18,8 +18,8 @@ struct mevent_srv_sub
|
||||
u16 sendSize;
|
||||
void * recvBfr;
|
||||
const void * sendBfr;
|
||||
u32 (*recvFunc)(struct mevent_srv_sub *);
|
||||
u32 (*sendFunc)(struct mevent_srv_sub *);
|
||||
u32 (*recvFunc)(struct MysteryGiftLink *);
|
||||
u32 (*sendFunc)(struct MysteryGiftLink *);
|
||||
};
|
||||
|
||||
struct send_recv_header
|
||||
@ -29,10 +29,10 @@ struct send_recv_header
|
||||
u16 size;
|
||||
};
|
||||
|
||||
void mevent_srv_sub_init(struct mevent_srv_sub *, u32, u32);
|
||||
void mevent_srv_sub_init_send(struct mevent_srv_sub * manager, u32 ident, const void * src, u32 size);
|
||||
bool32 mevent_srv_sub_recv(struct mevent_srv_sub * manager);
|
||||
bool32 mevent_srv_sub_send(struct mevent_srv_sub * manager);
|
||||
void mevent_srv_sub_init_recv(struct mevent_srv_sub *, u32, void *);
|
||||
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 *);
|
||||
|
||||
#endif //GUARD_MEVENT_SERVER_HELPERS_H
|
||||
|
@ -1,8 +1,8 @@
|
||||
#ifndef GUARD_MYSTERY_EVENT_SCRIPT_H
|
||||
#define GUARD_MYSTERY_EVENT_SCRIPT_H
|
||||
|
||||
void sub_8153870(u8 *script);
|
||||
bool32 sub_8153884(u32 *a0);
|
||||
void InitMysteryGiftScriptContext(u8 *script);
|
||||
bool32 RunMysteryGiftScriptContextCommand(u32 *script);
|
||||
u32 RunMysteryEventScript(u8 *script);
|
||||
void SetMysteryEventScriptStatus(u32 val);
|
||||
u16 GetRecordMixingGift(void);
|
||||
|
@ -9,7 +9,7 @@ enum {
|
||||
NEWS_INPUT_NONE = 0xFF
|
||||
};
|
||||
|
||||
bool32 WonderCard_Init(struct WonderCard * card, struct MEventBuffer_3430_Sub * r6);
|
||||
bool32 WonderCard_Init(struct WonderCard * card, struct MEventBuffer_3430 * r6);
|
||||
bool32 WonderNews_Init(const struct WonderNews * news);
|
||||
s32 WonderCard_Enter(void);
|
||||
s32 WonderNews_Enter(void);
|
||||
|
@ -94,7 +94,7 @@ GPIOPortReadEnable: @ 80000C8
|
||||
|
||||
.byte 0x1e, 0x1e, 0x10, 0x40
|
||||
|
||||
.4byte 0x0000322e @ offsetof(struct SaveBlock1, ? part-way into unk_322C)
|
||||
.4byte 0x0000322e @ offsetof(struct SaveBlock1, ? part-way into mysteryGift)
|
||||
.4byte 0x00000498 @ offsetof(struct SaveBlock1, pcItems)
|
||||
.4byte 0x000031a8 @ offsetof(struct SaveBlock1, giftRibbons)
|
||||
.4byte 0x000031f8 @ offsetof(struct SaveBlock1, enigmaBerry)
|
||||
|
252
src/mevent2.c
252
src/mevent2.c
@ -14,73 +14,75 @@
|
||||
static EWRAM_DATA bool32 gUnknown_02022C70 = FALSE;
|
||||
|
||||
static void sub_801B180(void);
|
||||
static void s_DestroyWonderNews(void);
|
||||
static bool32 sub_801B114(const struct WonderNews *data);
|
||||
static bool32 ValidateWonderCardData(const struct WonderCard *data);
|
||||
static void sub_801B330(void);
|
||||
static void ClearSavedWonderNewsInternal(void);
|
||||
static bool32 ValidateWonderNews(const struct WonderNews *news);
|
||||
static bool32 ValidateWonderCard(const struct WonderCard *card);
|
||||
static void InitSavedWonderCard(void);
|
||||
static void sub_801B368(void);
|
||||
static void sub_801B9F8(void);
|
||||
static void sub_801BA8C(u32 a0, u32 a1, u32 *a2, int a3);
|
||||
|
||||
#define CALC_CRC(data) CalcCRC16WithTable((void *)&(data), sizeof(data))
|
||||
|
||||
void sub_801AFD8(void)
|
||||
{
|
||||
CpuFill32(0, &gSaveBlock1Ptr->unk_322C, sizeof(gSaveBlock1Ptr->unk_322C));
|
||||
CpuFill32(0, &gSaveBlock1Ptr->mysteryGift, sizeof(gSaveBlock1Ptr->mysteryGift));
|
||||
sub_801B180();
|
||||
InitQuestionnaireWords();
|
||||
}
|
||||
|
||||
struct WonderNews *GetSavedWonderNews(void)
|
||||
{
|
||||
return &gSaveBlock1Ptr->unk_322C.wonderNews.data;
|
||||
return &gSaveBlock1Ptr->mysteryGift.news;
|
||||
}
|
||||
|
||||
struct WonderCard *GetSavedWonderCard(void)
|
||||
{
|
||||
return &gSaveBlock1Ptr->unk_322C.wonderCard.data;
|
||||
return &gSaveBlock1Ptr->mysteryGift.card;
|
||||
}
|
||||
|
||||
struct MEventBuffer_3430_Sub *sav1_get_mevent_buffer_2(void)
|
||||
struct MEventBuffer_3430 *sav1_get_mevent_buffer_2(void)
|
||||
{
|
||||
return &gSaveBlock1Ptr->unk_322C.buffer_310.data;
|
||||
return &gSaveBlock1Ptr->mysteryGift.unk_3430;
|
||||
}
|
||||
|
||||
struct MysteryEventStruct *sub_801B044(void)
|
||||
{
|
||||
return &gSaveBlock1Ptr->unk_322C.unk_340;
|
||||
return &gSaveBlock1Ptr->mysteryGift.unk_340;
|
||||
}
|
||||
|
||||
u16 *GetQuestionnaireWordsPtr(void)
|
||||
{
|
||||
return gSaveBlock1Ptr->unk_322C.questionnaireWords;
|
||||
return gSaveBlock1Ptr->mysteryGift.questionnaireWords;
|
||||
}
|
||||
|
||||
void DestroyWonderNews(void)
|
||||
void ClearSavedWonderNews(void)
|
||||
{
|
||||
s_DestroyWonderNews();
|
||||
ClearSavedWonderNewsInternal();
|
||||
}
|
||||
|
||||
bool32 sub_801B078(const struct WonderNews *src)
|
||||
bool32 SaveWonderNews(const struct WonderNews *news)
|
||||
{
|
||||
if (!sub_801B114(src))
|
||||
if (!ValidateWonderNews(news))
|
||||
return FALSE;
|
||||
|
||||
s_DestroyWonderNews();
|
||||
gSaveBlock1Ptr->unk_322C.wonderNews.data = *src;
|
||||
gSaveBlock1Ptr->unk_322C.wonderNews.crc = CalcCRC16WithTable((void *)&gSaveBlock1Ptr->unk_322C.wonderNews.data, sizeof(struct WonderNews));
|
||||
ClearSavedWonderNewsInternal();
|
||||
gSaveBlock1Ptr->mysteryGift.news = *news;
|
||||
gSaveBlock1Ptr->mysteryGift.newsCrc = CALC_CRC(gSaveBlock1Ptr->mysteryGift.news);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool32 ValidateReceivedWonderNews(void)
|
||||
bool32 ValidateSavedWonderNews(void)
|
||||
{
|
||||
if (CalcCRC16WithTable((void *)&gSaveBlock1Ptr->unk_322C.wonderNews.data, sizeof(struct WonderNews)) != gSaveBlock1Ptr->unk_322C.wonderNews.crc)
|
||||
if (CALC_CRC(gSaveBlock1Ptr->mysteryGift.news) != gSaveBlock1Ptr->mysteryGift.newsCrc)
|
||||
return FALSE;
|
||||
if (!sub_801B114(&gSaveBlock1Ptr->unk_322C.wonderNews.data))
|
||||
if (!ValidateWonderNews(&gSaveBlock1Ptr->mysteryGift.news))
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static bool32 sub_801B114(const struct WonderNews *data)
|
||||
static bool32 ValidateWonderNews(const struct WonderNews *data)
|
||||
{
|
||||
if (data->unk_00 == 0)
|
||||
return FALSE;
|
||||
@ -90,17 +92,17 @@ static bool32 sub_801B114(const struct WonderNews *data)
|
||||
|
||||
bool32 WonderNews_Test_Unk_02(void)
|
||||
{
|
||||
const struct WonderNews *data = &gSaveBlock1Ptr->unk_322C.wonderNews.data;
|
||||
const struct WonderNews *data = &gSaveBlock1Ptr->mysteryGift.news;
|
||||
if (data->unk_02 == 0)
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void s_DestroyWonderNews(void)
|
||||
static void ClearSavedWonderNewsInternal(void)
|
||||
{
|
||||
CpuFill32(0, GetSavedWonderNews(), sizeof(gSaveBlock1Ptr->unk_322C.wonderNews.data));
|
||||
gSaveBlock1Ptr->unk_322C.wonderNews.crc = 0;
|
||||
CpuFill32(0, GetSavedWonderNews(), sizeof(gSaveBlock1Ptr->mysteryGift.news));
|
||||
gSaveBlock1Ptr->mysteryGift.newsCrc = 0;
|
||||
}
|
||||
|
||||
static void sub_801B180(void)
|
||||
@ -111,9 +113,9 @@ static void sub_801B180(void)
|
||||
|
||||
bool32 sub_801B1A4(const u8 *src)
|
||||
{
|
||||
const u8 *r5 = (const u8 *)&gSaveBlock1Ptr->unk_322C.wonderNews.data;
|
||||
const u8 *r5 = (const u8 *)&gSaveBlock1Ptr->mysteryGift.news;
|
||||
u32 i;
|
||||
if (!ValidateReceivedWonderNews())
|
||||
if (!ValidateSavedWonderNews())
|
||||
return FALSE;
|
||||
|
||||
for (i = 0; i < sizeof(struct WonderNews); i++)
|
||||
@ -125,9 +127,9 @@ bool32 sub_801B1A4(const u8 *src)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void DestroyWonderCard(void)
|
||||
void ClearSavedWonderCard(void)
|
||||
{
|
||||
sub_801B330();
|
||||
InitSavedWonderCard();
|
||||
sub_801B368();
|
||||
sub_801B9F8();
|
||||
ClearRamScript();
|
||||
@ -136,27 +138,25 @@ void DestroyWonderCard(void)
|
||||
ClearEReaderTrainer(&gSaveBlock2Ptr->frontier.ereaderTrainer);
|
||||
}
|
||||
|
||||
bool32 sub_801B21C(const struct WonderCard *data)
|
||||
bool32 SaveWonderCard(const struct WonderCard *card)
|
||||
{
|
||||
struct MEventBuffer_3430_Sub *r2;
|
||||
struct WonderCard *r1;
|
||||
if (!ValidateWonderCardData(data))
|
||||
struct MEventBuffer_3430 *r2;
|
||||
if (!ValidateWonderCard(card))
|
||||
return FALSE;
|
||||
|
||||
DestroyWonderCard();
|
||||
memcpy(&gSaveBlock1Ptr->unk_322C.wonderCard.data, data, sizeof(struct WonderCard));
|
||||
gSaveBlock1Ptr->unk_322C.wonderCard.crc = CalcCRC16WithTable((void *)&gSaveBlock1Ptr->unk_322C.wonderCard.data, sizeof(struct WonderCard));
|
||||
r2 = &gSaveBlock1Ptr->unk_322C.buffer_310.data;
|
||||
r1 = &gSaveBlock1Ptr->unk_322C.wonderCard.data;
|
||||
r2->unk_06 = r1->unk_02;
|
||||
ClearSavedWonderCard();
|
||||
memcpy(&gSaveBlock1Ptr->mysteryGift.card, card, sizeof(struct WonderCard));
|
||||
gSaveBlock1Ptr->mysteryGift.cardCrc = CALC_CRC(gSaveBlock1Ptr->mysteryGift.card);
|
||||
r2 = &gSaveBlock1Ptr->mysteryGift.unk_3430;
|
||||
r2->unk_06 = (&gSaveBlock1Ptr->mysteryGift.card)->unk_02;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool32 ValidateReceivedWonderCard(void)
|
||||
bool32 ValidateSavedWonderCard(void)
|
||||
{
|
||||
if (gSaveBlock1Ptr->unk_322C.wonderCard.crc != CalcCRC16WithTable((void *)&gSaveBlock1Ptr->unk_322C.wonderCard.data, sizeof(struct WonderCard)))
|
||||
if (gSaveBlock1Ptr->mysteryGift.cardCrc != CALC_CRC(gSaveBlock1Ptr->mysteryGift.card))
|
||||
return FALSE;
|
||||
if (!ValidateWonderCardData(&gSaveBlock1Ptr->unk_322C.wonderCard.data))
|
||||
if (!ValidateWonderCard(&gSaveBlock1Ptr->mysteryGift.card))
|
||||
return FALSE;
|
||||
if (!ValidateSavedRamScript())
|
||||
return FALSE;
|
||||
@ -164,17 +164,17 @@ bool32 ValidateReceivedWonderCard(void)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static bool32 ValidateWonderCardData(const struct WonderCard *data)
|
||||
static bool32 ValidateWonderCard(const struct WonderCard *card)
|
||||
{
|
||||
if (data->unk_00 == 0)
|
||||
if (card->flagId == 0)
|
||||
return FALSE;
|
||||
if (data->unk_08_0 > 2)
|
||||
if (card->unk_08_0 > 2)
|
||||
return FALSE;
|
||||
if (!(data->unk_08_6 == 0 || data->unk_08_6 == 1 || data->unk_08_6 == 2))
|
||||
if (!(card->unk_08_6 == 0 || card->unk_08_6 == 1 || card->unk_08_6 == 2))
|
||||
return FALSE;
|
||||
if (data->bgType >= NUM_WONDER_BGS)
|
||||
if (card->bgType >= NUM_WONDER_BGS)
|
||||
return FALSE;
|
||||
if (data->unk_09 > 7)
|
||||
if (card->unk_09 > 7)
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
@ -182,29 +182,29 @@ static bool32 ValidateWonderCardData(const struct WonderCard *data)
|
||||
|
||||
bool32 WonderCard_Test_Unk_08_6(void)
|
||||
{
|
||||
const struct WonderCard *data = &gSaveBlock1Ptr->unk_322C.wonderCard.data;
|
||||
if (data->unk_08_6 == 0)
|
||||
const struct WonderCard *card = &gSaveBlock1Ptr->mysteryGift.card;
|
||||
if (card->unk_08_6 == 0)
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void sub_801B330(void)
|
||||
static void InitSavedWonderCard(void)
|
||||
{
|
||||
CpuFill32(0, &gSaveBlock1Ptr->unk_322C.wonderCard.data, sizeof(struct WonderCard));
|
||||
gSaveBlock1Ptr->unk_322C.wonderCard.crc = 0;
|
||||
CpuFill32(0, &gSaveBlock1Ptr->mysteryGift.card, sizeof(gSaveBlock1Ptr->mysteryGift.card));
|
||||
gSaveBlock1Ptr->mysteryGift.cardCrc = 0;
|
||||
}
|
||||
|
||||
static void sub_801B368(void)
|
||||
{
|
||||
CpuFill32(0, sav1_get_mevent_buffer_2(), 18 *sizeof(u16));
|
||||
gSaveBlock1Ptr->unk_322C.buffer_310.crc = 0;
|
||||
gSaveBlock1Ptr->mysteryGift.unkCrc = 0;
|
||||
}
|
||||
|
||||
u16 GetWonderCardFlagID(void)
|
||||
{
|
||||
if (ValidateReceivedWonderCard())
|
||||
return gSaveBlock1Ptr->unk_322C.wonderCard.data.unk_00;
|
||||
if (ValidateSavedWonderCard())
|
||||
return gSaveBlock1Ptr->mysteryGift.card.flagId;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -215,9 +215,9 @@ void WonderCard_ResetInternalReceivedFlag(struct WonderCard *buffer)
|
||||
buffer->unk_08_6 = 0;
|
||||
}
|
||||
|
||||
static bool32 IsWonderCardFlagIDInValidRange(u16 a0)
|
||||
static bool32 IsWonderCardFlagIDInValidRange(u16 flagId)
|
||||
{
|
||||
if (a0 >= 1000 && a0 < 1020)
|
||||
if (flagId >= 1000 && flagId < 1000 + NUM_MYSTERY_GIFT_FLAGS)
|
||||
return TRUE;
|
||||
|
||||
return FALSE;
|
||||
@ -228,23 +228,23 @@ static const u16 sMysteryGiftFlags[] =
|
||||
FLAG_RECEIVED_AURORA_TICKET,
|
||||
FLAG_RECEIVED_MYSTIC_TICKET,
|
||||
FLAG_RECEIVED_OLD_SEA_MAP,
|
||||
FLAG_UNUSED_MYSTERY_GIFT_0x13D,
|
||||
FLAG_UNUSED_MYSTERY_GIFT_0x13E,
|
||||
FLAG_UNUSED_MYSTERY_GIFT_0x13F,
|
||||
FLAG_UNUSED_MYSTERY_GIFT_0x140,
|
||||
FLAG_UNUSED_MYSTERY_GIFT_0x141,
|
||||
FLAG_UNUSED_MYSTERY_GIFT_0x142,
|
||||
FLAG_UNUSED_MYSTERY_GIFT_0x143,
|
||||
FLAG_UNUSED_MYSTERY_GIFT_0x144,
|
||||
FLAG_UNUSED_MYSTERY_GIFT_0x145,
|
||||
FLAG_UNUSED_MYSTERY_GIFT_0x146,
|
||||
FLAG_UNUSED_MYSTERY_GIFT_0x147,
|
||||
FLAG_UNUSED_MYSTERY_GIFT_0x148,
|
||||
FLAG_UNUSED_MYSTERY_GIFT_0x149,
|
||||
FLAG_UNUSED_MYSTERY_GIFT_0x14A,
|
||||
FLAG_UNUSED_MYSTERY_GIFT_0x14B,
|
||||
FLAG_UNUSED_MYSTERY_GIFT_0x14C,
|
||||
FLAG_UNUSED_MYSTERY_GIFT_0x14D,
|
||||
FLAG_MYSTERY_GIFT_UNUSED_1,
|
||||
FLAG_MYSTERY_GIFT_UNUSED_2,
|
||||
FLAG_MYSTERY_GIFT_UNUSED_3,
|
||||
FLAG_MYSTERY_GIFT_UNUSED_4,
|
||||
FLAG_MYSTERY_GIFT_UNUSED_5,
|
||||
FLAG_MYSTERY_GIFT_UNUSED_6,
|
||||
FLAG_MYSTERY_GIFT_UNUSED_7,
|
||||
FLAG_MYSTERY_GIFT_UNUSED_8,
|
||||
FLAG_MYSTERY_GIFT_UNUSED_9,
|
||||
FLAG_MYSTERY_GIFT_UNUSED_10,
|
||||
FLAG_MYSTERY_GIFT_UNUSED_11,
|
||||
FLAG_MYSTERY_GIFT_UNUSED_12,
|
||||
FLAG_MYSTERY_GIFT_UNUSED_13,
|
||||
FLAG_MYSTERY_GIFT_UNUSED_14,
|
||||
FLAG_MYSTERY_GIFT_UNUSED_15,
|
||||
FLAG_MYSTERY_GIFT_UNUSED_16,
|
||||
FLAG_MYSTERY_GIFT_UNUSED_17,
|
||||
};
|
||||
|
||||
bool32 CheckReceivedGiftFromWonderCard(void)
|
||||
@ -259,7 +259,7 @@ bool32 CheckReceivedGiftFromWonderCard(void)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static int sub_801B438(const struct MEventBuffer_3430_Sub *data, int size)
|
||||
static int sub_801B438(const struct MEventBuffer_3430 *data, int size)
|
||||
{
|
||||
int r3 = 0;
|
||||
int i;
|
||||
@ -272,7 +272,7 @@ static int sub_801B438(const struct MEventBuffer_3430_Sub *data, int size)
|
||||
return r3;
|
||||
}
|
||||
|
||||
static bool32 sub_801B460(const struct MEventBuffer_3430_Sub *data1, const u16 *data2, int size)
|
||||
static bool32 sub_801B460(const struct MEventBuffer_3430 *data1, const u16 *data2, int size)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < size; i++)
|
||||
@ -300,33 +300,33 @@ static bool32 sub_801B4A4(const u16 *data)
|
||||
static int sub_801B4CC(void)
|
||||
{
|
||||
struct WonderCard *data;
|
||||
if (!ValidateReceivedWonderCard())
|
||||
if (!ValidateSavedWonderCard())
|
||||
return 0;
|
||||
|
||||
data = &gSaveBlock1Ptr->unk_322C.wonderCard.data;
|
||||
data = &gSaveBlock1Ptr->mysteryGift.card;
|
||||
if (data->unk_08_0 != 1)
|
||||
return 0;
|
||||
|
||||
return sub_801B438(&gSaveBlock1Ptr->unk_322C.buffer_310.data, data->unk_09);
|
||||
return sub_801B438(&gSaveBlock1Ptr->mysteryGift.unk_3430, data->unk_09);
|
||||
}
|
||||
|
||||
bool32 sub_801B508(const u16 *data)
|
||||
{
|
||||
struct WonderCard *buffer = &gSaveBlock1Ptr->unk_322C.wonderCard.data;
|
||||
struct WonderCard *buffer = &gSaveBlock1Ptr->mysteryGift.card;
|
||||
int size = buffer->unk_09;
|
||||
int i;
|
||||
if (!sub_801B4A4(data))
|
||||
return FALSE;
|
||||
|
||||
if (sub_801B460(&gSaveBlock1Ptr->unk_322C.buffer_310.data, data, size))
|
||||
if (sub_801B460(&gSaveBlock1Ptr->mysteryGift.unk_3430, data, size))
|
||||
return FALSE;
|
||||
|
||||
for (i = 0; i < size; i++)
|
||||
{
|
||||
if (gSaveBlock1Ptr->unk_322C.buffer_310.data.unk_08[1][i] == 0 && gSaveBlock1Ptr->unk_322C.buffer_310.data.unk_08[0][i] == 0)
|
||||
if (gSaveBlock1Ptr->mysteryGift.unk_3430.unk_08[1][i] == 0 && gSaveBlock1Ptr->mysteryGift.unk_3430.unk_08[0][i] == 0)
|
||||
{
|
||||
gSaveBlock1Ptr->unk_322C.buffer_310.data.unk_08[1][i] = data[1];
|
||||
gSaveBlock1Ptr->unk_322C.buffer_310.data.unk_08[0][i] = data[0];
|
||||
gSaveBlock1Ptr->mysteryGift.unk_3430.unk_08[1][i] = data[1];
|
||||
gSaveBlock1Ptr->mysteryGift.unk_3430.unk_08[0][i] = data[0];
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
@ -334,7 +334,7 @@ bool32 sub_801B508(const u16 *data)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void sub_801B580(struct MEventStruct_Unk1442CC *data, bool32 a1)
|
||||
void sub_801B580(struct MEventStruct_Unk1442CC *data, bool32 isWonderNews)
|
||||
{
|
||||
int i;
|
||||
CpuFill32(0, data, sizeof(struct MEventStruct_Unk1442CC));
|
||||
@ -342,20 +342,20 @@ void sub_801B580(struct MEventStruct_Unk1442CC *data, bool32 a1)
|
||||
data->unk_04 = 1;
|
||||
data->unk_08 = 1;
|
||||
|
||||
if (a1)
|
||||
if (isWonderNews)
|
||||
{
|
||||
data->unk_0C = 5;
|
||||
data->unk_10 = 0x0201;
|
||||
}
|
||||
else
|
||||
else // Wonder Card
|
||||
{
|
||||
data->unk_0C = 4;
|
||||
data->unk_10 = 0x0200;
|
||||
}
|
||||
|
||||
if (ValidateReceivedWonderCard())
|
||||
if (ValidateSavedWonderCard())
|
||||
{
|
||||
data->unk_14 = GetSavedWonderCard()->unk_00;
|
||||
data->unk_14 = GetSavedWonderCard()->flagId;
|
||||
data->unk_20 = *sav1_get_mevent_buffer_2();
|
||||
data->unk_44 = GetSavedWonderCard()->unk_09;
|
||||
}
|
||||
@ -365,15 +365,15 @@ void sub_801B580(struct MEventStruct_Unk1442CC *data, bool32 a1)
|
||||
}
|
||||
|
||||
for (i = 0; i < NUM_QUESTIONNAIRE_WORDS; i++)
|
||||
data->unk_16[i] = gSaveBlock1Ptr->unk_322C.questionnaireWords[i];
|
||||
data->questionnaireWords[i] = gSaveBlock1Ptr->mysteryGift.questionnaireWords[i];
|
||||
|
||||
CopyTrainerId(data->unk_4C, gSaveBlock2Ptr->playerTrainerId);
|
||||
StringCopy(data->unk_45, gSaveBlock2Ptr->playerName);
|
||||
for (i = 0; i < 6; i++)
|
||||
data->unk_50[i] = gSaveBlock1Ptr->easyChatProfile[i];
|
||||
CopyTrainerId(data->playerTrainerId, gSaveBlock2Ptr->playerTrainerId);
|
||||
StringCopy(data->playerName, gSaveBlock2Ptr->playerName);
|
||||
for (i = 0; i < EASY_CHAT_BATTLE_WORDS_COUNT; i++)
|
||||
data->easyChatProfile[i] = gSaveBlock1Ptr->easyChatProfile[i];
|
||||
|
||||
memcpy(data->unk_5C, RomHeaderGameCode, 4);
|
||||
data->unk_60 = RomHeaderSoftwareVersion;
|
||||
memcpy(data->romHeaderGameCode, RomHeaderGameCode, 4);
|
||||
data->romHeaderSoftwareVersion = RomHeaderSoftwareVersion;
|
||||
}
|
||||
|
||||
bool32 sub_801B6A0(const struct MEventStruct_Unk1442CC *data, bool32 a1)
|
||||
@ -422,12 +422,12 @@ u32 sub_801B708(const u16 *a0, const struct MEventStruct_Unk1442CC *a1, const vo
|
||||
return 2;
|
||||
}
|
||||
|
||||
bool32 MEventStruct_Unk1442CC_CompareField_unk_16(const struct MEventStruct_Unk1442CC *a0, const u16 *a1)
|
||||
bool32 MysteryGift_DoesQuestionnaireMatch(const struct MEventStruct_Unk1442CC *data, const u16 *words)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < NUM_QUESTIONNAIRE_WORDS; i++)
|
||||
{
|
||||
if (a0->unk_16[i] != a1[i])
|
||||
if (data->questionnaireWords[i] != words[i])
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@ -461,20 +461,20 @@ u16 MEventStruct_Unk1442CC_GetValueNFrom_unk_20(const struct MEventStruct_Unk144
|
||||
|
||||
static void sub_801B7D8(u32 command)
|
||||
{
|
||||
struct WonderCard *data = &gSaveBlock1Ptr->unk_322C.wonderCard.data;
|
||||
struct WonderCard *data = &gSaveBlock1Ptr->mysteryGift.card;
|
||||
if (data->unk_08_0 == 2)
|
||||
{
|
||||
u16 *dest = NULL;
|
||||
switch (command)
|
||||
{
|
||||
case 0:
|
||||
dest = &gSaveBlock1Ptr->unk_322C.buffer_310.data.unk_00;
|
||||
dest = &gSaveBlock1Ptr->mysteryGift.unk_3430.unk_00;
|
||||
break;
|
||||
case 1:
|
||||
dest = &gSaveBlock1Ptr->unk_322C.buffer_310.data.unk_02;
|
||||
dest = &gSaveBlock1Ptr->mysteryGift.unk_3430.unk_02;
|
||||
break;
|
||||
case 2:
|
||||
dest = &gSaveBlock1Ptr->unk_322C.buffer_310.data.unk_04;
|
||||
dest = &gSaveBlock1Ptr->mysteryGift.unk_3430.unk_04;
|
||||
break;
|
||||
case 3:
|
||||
break;
|
||||
@ -499,46 +499,46 @@ u16 mevent_081445C0(u32 command)
|
||||
{
|
||||
case GET_CARD_BATTLES_WON_INTERNAL:
|
||||
{
|
||||
struct WonderCard *data = &gSaveBlock1Ptr->unk_322C.wonderCard.data;
|
||||
if (data->unk_08_0 == 2)
|
||||
struct WonderCard *card = &gSaveBlock1Ptr->mysteryGift.card;
|
||||
if (card->unk_08_0 == 2)
|
||||
{
|
||||
struct MEventBuffer_3430_Sub *buffer = &gSaveBlock1Ptr->unk_322C.buffer_310.data;
|
||||
struct MEventBuffer_3430 *buffer = &gSaveBlock1Ptr->mysteryGift.unk_3430;
|
||||
return buffer->unk_00;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 1: // Never occurs
|
||||
{
|
||||
struct WonderCard *data = &gSaveBlock1Ptr->unk_322C.wonderCard.data;
|
||||
if (data->unk_08_0 == 2)
|
||||
struct WonderCard *card = &gSaveBlock1Ptr->mysteryGift.card;
|
||||
if (card->unk_08_0 == 2)
|
||||
{
|
||||
struct MEventBuffer_3430_Sub *buffer = &gSaveBlock1Ptr->unk_322C.buffer_310.data;
|
||||
struct MEventBuffer_3430 *buffer = &gSaveBlock1Ptr->mysteryGift.unk_3430;
|
||||
return buffer->unk_02;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 2: // Never occurs
|
||||
{
|
||||
struct WonderCard *data = &gSaveBlock1Ptr->unk_322C.wonderCard.data;
|
||||
if (data->unk_08_0 == 2)
|
||||
struct WonderCard *card = &gSaveBlock1Ptr->mysteryGift.card;
|
||||
if (card->unk_08_0 == 2)
|
||||
{
|
||||
struct MEventBuffer_3430_Sub *buffer = &gSaveBlock1Ptr->unk_322C.buffer_310.data;
|
||||
struct MEventBuffer_3430 *buffer = &gSaveBlock1Ptr->mysteryGift.unk_3430;
|
||||
return buffer->unk_04;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case GET_NUM_STAMPS_INTERNAL:
|
||||
{
|
||||
struct WonderCard *data = &gSaveBlock1Ptr->unk_322C.wonderCard.data;
|
||||
if (data->unk_08_0 == 1)
|
||||
struct WonderCard *card = &gSaveBlock1Ptr->mysteryGift.card;
|
||||
if (card->unk_08_0 == 1)
|
||||
return sub_801B4CC();
|
||||
break;
|
||||
}
|
||||
case GET_MAX_STAMPS_INTERNAL:
|
||||
{
|
||||
struct WonderCard *data = &gSaveBlock1Ptr->unk_322C.wonderCard.data;
|
||||
if (data->unk_08_0 == 1)
|
||||
return data->unk_09;
|
||||
struct WonderCard *card = &gSaveBlock1Ptr->mysteryGift.card;
|
||||
if (card->unk_08_0 == 1)
|
||||
return card->unk_09;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -552,16 +552,16 @@ void ResetReceivedWonderCardFlag(void)
|
||||
gUnknown_02022C70 = FALSE;
|
||||
}
|
||||
|
||||
bool32 MEventHandleReceivedWonderCard(u16 a0)
|
||||
bool32 MEventHandleReceivedWonderCard(u16 flagId)
|
||||
{
|
||||
gUnknown_02022C70 = FALSE;
|
||||
if (a0 == 0)
|
||||
if (flagId == 0)
|
||||
return FALSE;
|
||||
|
||||
if (!ValidateReceivedWonderCard())
|
||||
if (!ValidateSavedWonderCard())
|
||||
return FALSE;
|
||||
|
||||
if (gSaveBlock1Ptr->unk_322C.wonderCard.data.unk_00 != a0)
|
||||
if (gSaveBlock1Ptr->mysteryGift.card.flagId != flagId)
|
||||
return FALSE;
|
||||
|
||||
gUnknown_02022C70 = TRUE;
|
||||
@ -575,13 +575,13 @@ void RecordIdOfWonderCardSenderByEventType(u32 a0, u32 a1)
|
||||
switch (a0)
|
||||
{
|
||||
case 2:
|
||||
sub_801BA8C(2, a1, gSaveBlock1Ptr->unk_322C.unk_344[1], 5);
|
||||
sub_801BA8C(2, a1, gSaveBlock1Ptr->mysteryGift.unk_344[1], 5);
|
||||
break;
|
||||
case 0:
|
||||
sub_801BA8C(0, a1, gSaveBlock1Ptr->unk_322C.unk_344[0], 5);
|
||||
sub_801BA8C(0, a1, gSaveBlock1Ptr->mysteryGift.unk_344[0], 5);
|
||||
break;
|
||||
case 1:
|
||||
sub_801BA8C(1, a1, gSaveBlock1Ptr->unk_322C.unk_344[0], 5);
|
||||
sub_801BA8C(1, a1, gSaveBlock1Ptr->mysteryGift.unk_344[0], 5);
|
||||
break;
|
||||
default:
|
||||
AGB_ASSERT(0);
|
||||
@ -591,7 +591,7 @@ void RecordIdOfWonderCardSenderByEventType(u32 a0, u32 a1)
|
||||
|
||||
static void sub_801B9F8(void)
|
||||
{
|
||||
CpuFill32(0, gSaveBlock1Ptr->unk_322C.unk_344, sizeof(gSaveBlock1Ptr->unk_322C.unk_344));
|
||||
CpuFill32(0, gSaveBlock1Ptr->mysteryGift.unk_344, sizeof(gSaveBlock1Ptr->mysteryGift.unk_344));
|
||||
}
|
||||
|
||||
static bool32 sub_801BA24(u32 a0, u32 *a1, int size)
|
||||
|
@ -8,284 +8,292 @@
|
||||
#include "mystery_event_script.h"
|
||||
#include "mevent_client.h"
|
||||
|
||||
EWRAM_DATA struct mevent_client * s_mevent_client_ptr = NULL;
|
||||
enum {
|
||||
FUNC_INIT,
|
||||
FUNC_DONE,
|
||||
FUNC_RECV,
|
||||
FUNC_SEND,
|
||||
FUNC_RUN,
|
||||
FUNC_WAIT,
|
||||
FUNC_6,
|
||||
FUNC_7,
|
||||
};
|
||||
|
||||
static void mevent_client_init(struct mevent_client *, u32, u32);
|
||||
static u32 mevent_client_exec(struct mevent_client *);
|
||||
static void mevent_client_free_resources(struct mevent_client *);
|
||||
EWRAM_DATA static struct MysteryGiftClient * sClient = NULL;
|
||||
|
||||
extern const struct mevent_client_cmd gUnknown_082F2598[];
|
||||
static void MysteryGiftClient_Init(struct MysteryGiftClient *, u32, u32);
|
||||
static u32 MysteryGiftClient_CallFunc(struct MysteryGiftClient *);
|
||||
static void MysteryGiftClient_Free(struct MysteryGiftClient *);
|
||||
|
||||
void mevent_client_do_init(u32 arg)
|
||||
extern const struct MysteryGiftClientCmd gUnknown_082F2598[];
|
||||
|
||||
void MysteryGiftClient_Create(bool32 isWonderNews)
|
||||
{
|
||||
s_mevent_client_ptr = AllocZeroed(sizeof(struct mevent_client));
|
||||
mevent_client_init(s_mevent_client_ptr, 1, 0);
|
||||
s_mevent_client_ptr->unk_4C = arg;
|
||||
sClient = AllocZeroed(sizeof(*sClient));
|
||||
MysteryGiftClient_Init(sClient, 1, 0);
|
||||
sClient->isWonderNews = isWonderNews;
|
||||
}
|
||||
|
||||
u32 mevent_client_do_exec(u16 * a0)
|
||||
u32 MysteryGiftClient_Run(u16 * endVal)
|
||||
{
|
||||
u32 result;
|
||||
if (s_mevent_client_ptr == NULL)
|
||||
return 6;
|
||||
result = mevent_client_exec(s_mevent_client_ptr);
|
||||
if (result == 6)
|
||||
if (sClient == NULL)
|
||||
return CLI_RET_END;
|
||||
result = MysteryGiftClient_CallFunc(sClient);
|
||||
if (result == CLI_RET_END)
|
||||
{
|
||||
*a0 = s_mevent_client_ptr->param;
|
||||
mevent_client_free_resources(s_mevent_client_ptr);
|
||||
Free(s_mevent_client_ptr);
|
||||
s_mevent_client_ptr = NULL;
|
||||
*endVal = sClient->param;
|
||||
MysteryGiftClient_Free(sClient);
|
||||
Free(sClient);
|
||||
sClient = NULL;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void mevent_client_inc_flag(void)
|
||||
void MysteryGiftClient_AdvanceState(void)
|
||||
{
|
||||
s_mevent_client_ptr->flag++;
|
||||
sClient->funcState++;
|
||||
}
|
||||
|
||||
void * mevent_client_get_buffer(void)
|
||||
{
|
||||
return s_mevent_client_ptr->buffer;
|
||||
return sClient->buffer;
|
||||
}
|
||||
|
||||
void mevent_client_set_param(u32 a0)
|
||||
void MysteryGiftClient_SetParam(u32 val)
|
||||
{
|
||||
s_mevent_client_ptr->param = a0;
|
||||
sClient->param = val;
|
||||
}
|
||||
|
||||
static void mevent_client_init(struct mevent_client * svr, u32 sendPlayerNo, u32 recvPlayerNo)
|
||||
static void MysteryGiftClient_Init(struct MysteryGiftClient * client, u32 sendPlayerNo, u32 recvPlayerNo)
|
||||
{
|
||||
svr->unk_00 = 0;
|
||||
svr->mainseqno = 0;
|
||||
svr->flag = 0;
|
||||
svr->sendBuffer = AllocZeroed(ME_SEND_BUF_SIZE);
|
||||
svr->recvBuffer = AllocZeroed(ME_SEND_BUF_SIZE);
|
||||
svr->cmdBuffer = AllocZeroed(ME_SEND_BUF_SIZE);
|
||||
svr->buffer = AllocZeroed(0x40);
|
||||
mevent_srv_sub_init(&svr->manager, sendPlayerNo, recvPlayerNo);
|
||||
client->unk_00 = 0;
|
||||
client->funcId = FUNC_INIT;
|
||||
client->funcState = 0;
|
||||
client->sendBuffer = AllocZeroed(ME_SEND_BUF_SIZE);
|
||||
client->recvBuffer = AllocZeroed(ME_SEND_BUF_SIZE);
|
||||
client->cmdBuffer = AllocZeroed(ME_SEND_BUF_SIZE);
|
||||
client->buffer = AllocZeroed(0x40);
|
||||
MysteryGiftLink_Init(&client->link, sendPlayerNo, recvPlayerNo);
|
||||
}
|
||||
|
||||
static void mevent_client_free_resources(struct mevent_client * svr)
|
||||
static void MysteryGiftClient_Free(struct MysteryGiftClient * client)
|
||||
{
|
||||
Free(svr->sendBuffer);
|
||||
Free(svr->recvBuffer);
|
||||
Free(svr->cmdBuffer);
|
||||
Free(svr->buffer);
|
||||
Free(client->sendBuffer);
|
||||
Free(client->recvBuffer);
|
||||
Free(client->cmdBuffer);
|
||||
Free(client->buffer);
|
||||
}
|
||||
|
||||
static void mevent_client_jmp_buffer(struct mevent_client * svr)
|
||||
static void MysteryGiftClient_CopyRecvScript(struct MysteryGiftClient * client)
|
||||
{
|
||||
memcpy(svr->cmdBuffer, svr->recvBuffer, ME_SEND_BUF_SIZE);
|
||||
svr->cmdidx = 0;
|
||||
memcpy(client->cmdBuffer, client->recvBuffer, ME_SEND_BUF_SIZE);
|
||||
client->cmdidx = 0;
|
||||
}
|
||||
|
||||
static void mevent_client_send_word(struct mevent_client * svr, u32 ident, u32 word)
|
||||
static void MysteryGiftClient_InitSend(struct MysteryGiftClient * client, u32 ident, u32 word)
|
||||
{
|
||||
CpuFill32(0, svr->sendBuffer, ME_SEND_BUF_SIZE);
|
||||
*(u32 *)svr->sendBuffer = word;
|
||||
mevent_srv_sub_init_send(&svr->manager, ident, svr->sendBuffer, sizeof(u32));
|
||||
CpuFill32(0, client->sendBuffer, ME_SEND_BUF_SIZE);
|
||||
*(u32 *)client->sendBuffer = word;
|
||||
MysteryGiftLink_InitSend(&client->link, ident, client->sendBuffer, sizeof(u32));
|
||||
}
|
||||
|
||||
static u32 mainseq_0(struct mevent_client * svr)
|
||||
static u32 Client_Init(struct MysteryGiftClient * client)
|
||||
{
|
||||
// init
|
||||
memcpy(svr->cmdBuffer, gUnknown_082F2598, ME_SEND_BUF_SIZE);
|
||||
svr->cmdidx = 0;
|
||||
svr->mainseqno = 4;
|
||||
svr->flag = 0;
|
||||
return 0;
|
||||
memcpy(client->cmdBuffer, gUnknown_082F2598, ME_SEND_BUF_SIZE);
|
||||
client->cmdidx = 0;
|
||||
client->funcId = FUNC_RUN;
|
||||
client->funcState = 0;
|
||||
return CLI_RET_INIT;
|
||||
}
|
||||
|
||||
static u32 mainseq_1(struct mevent_client * svr)
|
||||
static u32 Client_Done(struct MysteryGiftClient * client)
|
||||
{
|
||||
// done
|
||||
return 6;
|
||||
return CLI_RET_END;
|
||||
}
|
||||
|
||||
|
||||
static u32 mainseq_2(struct mevent_client * svr)
|
||||
static u32 Client_Recv(struct MysteryGiftClient * client)
|
||||
{
|
||||
// do recv
|
||||
if (mevent_srv_sub_recv(&svr->manager))
|
||||
if (MysteryGiftLink_Recv(&client->link))
|
||||
{
|
||||
svr->mainseqno = 4;
|
||||
svr->flag = 0;
|
||||
client->funcId = FUNC_RUN;
|
||||
client->funcState = 0;
|
||||
}
|
||||
return 1;
|
||||
return CLI_RET_1;
|
||||
}
|
||||
|
||||
static u32 mainseq_3(struct mevent_client * svr)
|
||||
static u32 Client_Send(struct MysteryGiftClient * client)
|
||||
{
|
||||
// do send
|
||||
if (mevent_srv_sub_send(&svr->manager))
|
||||
if (MysteryGiftLink_Send(&client->link))
|
||||
{
|
||||
svr->mainseqno = 4;
|
||||
svr->flag = 0;
|
||||
client->funcId = FUNC_RUN;
|
||||
client->funcState = 0;
|
||||
}
|
||||
return 1;
|
||||
return CLI_RET_1;
|
||||
}
|
||||
|
||||
static u32 mainseq_4(struct mevent_client * svr)
|
||||
static u32 Client_Run(struct MysteryGiftClient * client)
|
||||
{
|
||||
// process command
|
||||
struct mevent_client_cmd * cmd = &svr->cmdBuffer[svr->cmdidx];
|
||||
++svr->cmdidx;
|
||||
struct MysteryGiftClientCmd * cmd = &client->cmdBuffer[client->cmdidx];
|
||||
client->cmdidx++;
|
||||
switch (cmd->instr)
|
||||
{
|
||||
case 0:
|
||||
case CLI_NONE:
|
||||
break;
|
||||
case 1:
|
||||
svr->param = cmd->parameter;
|
||||
svr->mainseqno = 1;
|
||||
svr->flag = 0;
|
||||
case CLI_RETURN:
|
||||
client->param = cmd->parameter; // Set for endVal in MysteryGiftClient_Run
|
||||
client->funcId = FUNC_DONE;
|
||||
client->funcState = 0;
|
||||
break;
|
||||
case 2:
|
||||
mevent_srv_sub_init_recv(&svr->manager, cmd->parameter, svr->recvBuffer);
|
||||
svr->mainseqno = 2;
|
||||
svr->flag = 0;
|
||||
case CLI_RECV:
|
||||
MysteryGiftLink_InitRecv(&client->link, cmd->parameter, client->recvBuffer);
|
||||
client->funcId = FUNC_RECV;
|
||||
client->funcState = 0;
|
||||
break;
|
||||
case 3:
|
||||
svr->mainseqno = 3;
|
||||
svr->flag = 0;
|
||||
case CLI_SEND_LOADED:
|
||||
// Send without a MysteryGiftLink_InitSend
|
||||
// Sends whatever has been loaded already
|
||||
client->funcId = FUNC_SEND;
|
||||
client->funcState = 0;
|
||||
break;
|
||||
case 20:
|
||||
mevent_srv_sub_init_send(&svr->manager, 0x14, svr->sendBuffer, 0);
|
||||
svr->mainseqno = 3;
|
||||
svr->flag = 0;
|
||||
case CLI_20:
|
||||
MysteryGiftLink_InitSend(&client->link, 0x14, client->sendBuffer, 0);
|
||||
client->funcId = FUNC_SEND;
|
||||
client->funcState = 0;
|
||||
break;
|
||||
case 19:
|
||||
mevent_client_send_word(svr, 0x12, GetGameStat(cmd->parameter));
|
||||
svr->mainseqno = 3;
|
||||
svr->flag = 0;
|
||||
case CLI_SEND_STAT:
|
||||
MysteryGiftClient_InitSend(client, 0x12, GetGameStat(cmd->parameter));
|
||||
client->funcId = FUNC_SEND;
|
||||
client->funcState = 0;
|
||||
break;
|
||||
case 6:
|
||||
if (svr->param == 0)
|
||||
mevent_client_jmp_buffer(svr);
|
||||
case CLI_COPY_RECV_IF_N:
|
||||
if (client->param == FALSE)
|
||||
MysteryGiftClient_CopyRecvScript(client);
|
||||
break;
|
||||
case 7:
|
||||
if (svr->param == 1)
|
||||
mevent_client_jmp_buffer(svr);
|
||||
case CLI_COPY_RECV_IF:
|
||||
if (client->param == TRUE)
|
||||
MysteryGiftClient_CopyRecvScript(client);
|
||||
break;
|
||||
case 4:
|
||||
mevent_client_jmp_buffer(svr);
|
||||
case CLI_COPY_RECV:
|
||||
MysteryGiftClient_CopyRecvScript(client);
|
||||
break;
|
||||
case 5:
|
||||
memcpy(svr->buffer, svr->recvBuffer, 0x40);
|
||||
svr->mainseqno = 5;
|
||||
svr->flag = 0;
|
||||
return 2;
|
||||
case 11:
|
||||
memcpy(svr->buffer, svr->recvBuffer, 0x40);
|
||||
svr->mainseqno = 5;
|
||||
svr->flag = 0;
|
||||
return 3;
|
||||
case 12:
|
||||
memcpy(svr->buffer, svr->recvBuffer, 0x40);
|
||||
svr->mainseqno = 5;
|
||||
svr->flag = 0;
|
||||
return 5;
|
||||
case 13:
|
||||
svr->mainseqno = 5;
|
||||
svr->flag = 0;
|
||||
return 4;
|
||||
case 8:
|
||||
sub_801B580(svr->sendBuffer, svr->unk_4C);
|
||||
mevent_srv_sub_init_send(&svr->manager, 0x11, svr->sendBuffer, sizeof(struct MEventStruct_Unk1442CC));
|
||||
case CLI_5:
|
||||
memcpy(client->buffer, client->recvBuffer, 0x40);
|
||||
client->funcId = FUNC_WAIT;
|
||||
client->funcState = 0;
|
||||
return CLI_RET_2;
|
||||
case CLI_11:
|
||||
memcpy(client->buffer, client->recvBuffer, 0x40);
|
||||
client->funcId = FUNC_WAIT;
|
||||
client->funcState = 0;
|
||||
return CLI_RET_3;
|
||||
case CLI_12:
|
||||
memcpy(client->buffer, client->recvBuffer, 0x40);
|
||||
client->funcId = FUNC_WAIT;
|
||||
client->funcState = 0;
|
||||
return CLI_RET_5;
|
||||
case CLI_ASK_TOSS:
|
||||
client->funcId = FUNC_WAIT;
|
||||
client->funcState = 0;
|
||||
return CLI_RET_ASK_TOSS;
|
||||
case CLI_8:
|
||||
sub_801B580(client->sendBuffer, client->isWonderNews);
|
||||
MysteryGiftLink_InitSend(&client->link, 0x11, client->sendBuffer, sizeof(struct MEventStruct_Unk1442CC));
|
||||
break;
|
||||
case 14:
|
||||
mevent_client_send_word(svr, 0x13, svr->param);
|
||||
case CLI_LOAD_TOSS_RESPONSE:
|
||||
// param here is set by MG_STATE_LINK_ASK_TOSS or MG_STATE_LINK_ASK_TOSS_UNRECEIVED
|
||||
MysteryGiftClient_InitSend(client, 0x13, client->param);
|
||||
break;
|
||||
case 10:
|
||||
sub_801B21C(svr->recvBuffer);
|
||||
case CLI_10:
|
||||
SaveWonderCard(client->recvBuffer);
|
||||
break;
|
||||
case 9:
|
||||
if (!sub_801B1A4(svr->recvBuffer))
|
||||
case CLI_9:
|
||||
if (!sub_801B1A4(client->recvBuffer))
|
||||
{
|
||||
sub_801B078(svr->recvBuffer);
|
||||
mevent_client_send_word(svr, 0x13, 0);
|
||||
SaveWonderNews(client->recvBuffer);
|
||||
MysteryGiftClient_InitSend(client, 0x13, 0);
|
||||
}
|
||||
else
|
||||
mevent_client_send_word(svr, 0x13, 1);
|
||||
MysteryGiftClient_InitSend(client, 0x13, 1);
|
||||
break;
|
||||
case 15:
|
||||
svr->mainseqno = 6;
|
||||
svr->flag = 0;
|
||||
case CLI_15:
|
||||
client->funcId = FUNC_6;
|
||||
client->funcState = 0;
|
||||
break;
|
||||
case 16:
|
||||
sub_801B508(svr->recvBuffer);
|
||||
case CLI_16:
|
||||
sub_801B508(client->recvBuffer);
|
||||
break;
|
||||
case 17:
|
||||
InitRamScript_NoObjectEvent(svr->recvBuffer, 1000);
|
||||
case CLI_17:
|
||||
InitRamScript_NoObjectEvent(client->recvBuffer, 1000);
|
||||
break;
|
||||
case 18:
|
||||
memcpy(&gSaveBlock2Ptr->frontier.ereaderTrainer, svr->recvBuffer, 0xbc);
|
||||
case CLI_RECV_EREADER_TRAINER:
|
||||
memcpy(&gSaveBlock2Ptr->frontier.ereaderTrainer, client->recvBuffer, sizeof(gSaveBlock2Ptr->frontier.ereaderTrainer));
|
||||
ValidateEReaderTrainer();
|
||||
break;
|
||||
case 21:
|
||||
memcpy(gDecompressionBuffer, svr->recvBuffer, ME_SEND_BUF_SIZE);
|
||||
svr->mainseqno = 7;
|
||||
svr->flag = 0;
|
||||
case CLI_21:
|
||||
memcpy(gDecompressionBuffer, client->recvBuffer, ME_SEND_BUF_SIZE);
|
||||
client->funcId = FUNC_7;
|
||||
client->funcState = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
return 1;
|
||||
return CLI_RET_1;
|
||||
}
|
||||
|
||||
static u32 mainseq_5(struct mevent_client * svr)
|
||||
static u32 Client_Wait(struct MysteryGiftClient * client)
|
||||
{
|
||||
// wait flag
|
||||
if (svr->flag)
|
||||
if (client->funcState)
|
||||
{
|
||||
svr->mainseqno = 4;
|
||||
svr->flag = 0;
|
||||
client->funcId = FUNC_RUN;
|
||||
client->funcState = 0;
|
||||
}
|
||||
return 1;
|
||||
return CLI_RET_1;
|
||||
}
|
||||
|
||||
static u32 mainseq_6(struct mevent_client * svr)
|
||||
static u32 Client_6(struct MysteryGiftClient * client)
|
||||
{
|
||||
// ???
|
||||
switch (svr->flag)
|
||||
switch (client->funcState)
|
||||
{
|
||||
case 0:
|
||||
sub_8153870(svr->recvBuffer);
|
||||
++svr->flag;
|
||||
InitMysteryGiftScriptContext(client->recvBuffer);
|
||||
client->funcState++;
|
||||
break;
|
||||
case 1:
|
||||
if (!sub_8153884(&svr->param))
|
||||
if (!RunMysteryGiftScriptContextCommand(&client->param))
|
||||
{
|
||||
svr->mainseqno = 4;
|
||||
svr->flag = 0;
|
||||
client->funcId = FUNC_RUN;
|
||||
client->funcState = 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return 1;
|
||||
return CLI_RET_1;
|
||||
}
|
||||
|
||||
static u32 mainseq_7(struct mevent_client * svr)
|
||||
static u32 Client_7(struct MysteryGiftClient * client)
|
||||
{
|
||||
// exec arbitrary code
|
||||
u32 (*func)(u32 *, struct SaveBlock2 *, struct SaveBlock1 *) = (void *)gDecompressionBuffer;
|
||||
if (func(&svr->param, gSaveBlock2Ptr, gSaveBlock1Ptr) == 1)
|
||||
if (func(&client->param, gSaveBlock2Ptr, gSaveBlock1Ptr) == 1)
|
||||
{
|
||||
svr->mainseqno = 4;
|
||||
svr->flag = 0;
|
||||
client->funcId = FUNC_RUN;
|
||||
client->funcState = 0;
|
||||
}
|
||||
return 1;
|
||||
return CLI_RET_1;
|
||||
}
|
||||
|
||||
static u32 mevent_client_exec(struct mevent_client * svr)
|
||||
static u32 MysteryGiftClient_CallFunc(struct MysteryGiftClient * client)
|
||||
{
|
||||
u32 (*funcs[])(struct mevent_client *) = {
|
||||
mainseq_0,
|
||||
mainseq_1,
|
||||
mainseq_2,
|
||||
mainseq_3,
|
||||
mainseq_4,
|
||||
mainseq_5,
|
||||
mainseq_6,
|
||||
mainseq_7
|
||||
u32 (*funcs[])(struct MysteryGiftClient *) = {
|
||||
[FUNC_INIT] = Client_Init,
|
||||
[FUNC_DONE] = Client_Done,
|
||||
[FUNC_RECV] = Client_Recv,
|
||||
[FUNC_SEND] = Client_Send,
|
||||
[FUNC_RUN] = Client_Run,
|
||||
[FUNC_WAIT] = Client_Wait,
|
||||
[FUNC_6] = Client_6,
|
||||
[FUNC_7] = Client_7
|
||||
};
|
||||
return funcs[svr->mainseqno](svr);
|
||||
return funcs[client->funcId](client);
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ u16 sub_801DC20(void)
|
||||
struct MysteryEventStruct *r4 = sub_801B044();
|
||||
u16 r5;
|
||||
|
||||
if (!IsMysteryEventEnabled() || !ValidateReceivedWonderNews())
|
||||
if (!IsMysteryEventEnabled() || !ValidateSavedWonderNews())
|
||||
return 0;
|
||||
|
||||
r5 = sub_801DD44(r4);
|
||||
|
@ -5,187 +5,191 @@
|
||||
const u8 gText_CanceledReadingCard[] = _("Canceled reading\nthe Card.");
|
||||
|
||||
|
||||
const struct mevent_client_cmd gUnknown_082F2598[] = {
|
||||
{.instr = 2, .parameter = 16},
|
||||
{.instr = 4, .parameter = 0}
|
||||
const struct MysteryGiftClientCmd gUnknown_082F2598[] = {
|
||||
{.instr = CLI_RECV, .parameter = 16},
|
||||
{.instr = CLI_COPY_RECV}
|
||||
};
|
||||
|
||||
const struct mevent_client_cmd gUnknown_082F25A8[] = {
|
||||
{.instr = 8, .parameter = 0},
|
||||
{.instr = 3, .parameter = 0},
|
||||
{.instr = 2, .parameter = 16},
|
||||
{.instr = 4, .parameter = 0}
|
||||
const struct MysteryGiftClientCmd gUnknown_082F25A8[] = {
|
||||
{.instr = CLI_8},
|
||||
{.instr = CLI_SEND_LOADED},
|
||||
{.instr = CLI_RECV, .parameter = 16},
|
||||
{.instr = CLI_COPY_RECV}
|
||||
};
|
||||
|
||||
const struct mevent_client_cmd gUnknown_082F25C8[] = {
|
||||
{.instr = 20, .parameter = 0},
|
||||
{.instr = 1, .parameter = 10}
|
||||
const struct MysteryGiftClientCmd gUnknown_082F25C8[] = {
|
||||
{.instr = CLI_20},
|
||||
{.instr = CLI_RETURN, .parameter = 10}
|
||||
};
|
||||
|
||||
const struct mevent_client_cmd gUnknown_082F25D8[] = {
|
||||
{.instr = 20, .parameter = 0},
|
||||
{.instr = 1, .parameter = 11}
|
||||
const struct MysteryGiftClientCmd gUnknown_082F25D8[] = {
|
||||
{.instr = CLI_20},
|
||||
{.instr = CLI_RETURN, .parameter = 11}
|
||||
};
|
||||
|
||||
const struct mevent_client_cmd gUnknown_082F25E8[] = {
|
||||
{.instr = 20, .parameter = 0},
|
||||
{.instr = 1, .parameter = 0}
|
||||
const struct MysteryGiftClientCmd gUnknown_082F25E8[] = {
|
||||
{.instr = CLI_20},
|
||||
{.instr = CLI_RETURN, .parameter = 0}
|
||||
};
|
||||
|
||||
const struct mevent_client_cmd gUnknown_082F25F8[] = {
|
||||
{.instr = 2, .parameter = 22},
|
||||
{.instr = 10, .parameter = 0},
|
||||
{.instr = 2, .parameter = 25},
|
||||
{.instr = 17, .parameter = 0},
|
||||
{.instr = 20, .parameter = 0},
|
||||
{.instr = 1, .parameter = 2}
|
||||
const struct MysteryGiftClientCmd gUnknown_082F25F8[] = {
|
||||
{.instr = CLI_RECV, .parameter = 22},
|
||||
{.instr = CLI_10},
|
||||
{.instr = CLI_RECV, .parameter = 25},
|
||||
{.instr = CLI_17},
|
||||
{.instr = CLI_20},
|
||||
{.instr = CLI_RETURN, .parameter = 2}
|
||||
};
|
||||
|
||||
const struct mevent_client_cmd gUnknown_082F2628[] = {
|
||||
{.instr = 2, .parameter = 23},
|
||||
{.instr = 9, .parameter = 0},
|
||||
{.instr = 3, .parameter = 0},
|
||||
{.instr = 2, .parameter = 16},
|
||||
{.instr = 4, .parameter = 0}
|
||||
const struct MysteryGiftClientCmd gUnknown_082F2628[] = {
|
||||
{.instr = CLI_RECV, .parameter = 23},
|
||||
{.instr = CLI_9},
|
||||
{.instr = CLI_SEND_LOADED},
|
||||
{.instr = CLI_RECV, .parameter = 16},
|
||||
{.instr = CLI_COPY_RECV}
|
||||
};
|
||||
|
||||
const struct mevent_client_cmd gUnknown_082F2650[] = {
|
||||
{.instr = 20, .parameter = 0},
|
||||
{.instr = 1, .parameter = 7}
|
||||
const struct MysteryGiftClientCmd gUnknown_082F2650[] = {
|
||||
{.instr = CLI_20},
|
||||
{.instr = CLI_RETURN, .parameter = 7}
|
||||
};
|
||||
|
||||
const struct mevent_client_cmd gUnknown_082F2660[] = {
|
||||
{.instr = 20, .parameter = 0},
|
||||
{.instr = 1, .parameter = 3}
|
||||
const struct MysteryGiftClientCmd gUnknown_082F2660[] = {
|
||||
{.instr = CLI_20},
|
||||
{.instr = CLI_RETURN, .parameter = 3}
|
||||
};
|
||||
|
||||
const struct mevent_client_cmd gUnknown_082F2670[] = {
|
||||
{.instr = 13, .parameter = 0},
|
||||
{.instr = 14, .parameter = 0},
|
||||
{.instr = 3, .parameter = 0},
|
||||
{.instr = 2, .parameter = 16},
|
||||
{.instr = 4, .parameter = 0}
|
||||
const struct MysteryGiftClientCmd gUnknown_082F2670[] = {
|
||||
{.instr = CLI_ASK_TOSS},
|
||||
{.instr = CLI_LOAD_TOSS_RESPONSE},
|
||||
{.instr = CLI_SEND_LOADED},
|
||||
{.instr = CLI_RECV, .parameter = 16},
|
||||
{.instr = CLI_COPY_RECV}
|
||||
};
|
||||
|
||||
const struct mevent_client_cmd gUnknown_082F2698[] = {
|
||||
{.instr = 20, .parameter = 0},
|
||||
{.instr = 1, .parameter = 9}
|
||||
const struct MysteryGiftClientCmd gUnknown_082F2698[] = {
|
||||
{.instr = CLI_20},
|
||||
{.instr = CLI_RETURN, .parameter = 9}
|
||||
};
|
||||
|
||||
const struct mevent_client_cmd gUnknown_082F26A8[] = {
|
||||
{.instr = 20, .parameter = 0},
|
||||
{.instr = 1, .parameter = 5}
|
||||
const struct MysteryGiftClientCmd gUnknown_082F26A8[] = {
|
||||
{.instr = CLI_20},
|
||||
{.instr = CLI_RETURN, .parameter = 5}
|
||||
};
|
||||
|
||||
const struct mevent_client_cmd gUnknown_082F26B8[] = {
|
||||
{.instr = 2, .parameter = 21},
|
||||
{.instr = 12, .parameter = 0},
|
||||
{.instr = 20, .parameter = 0},
|
||||
{.instr = 1, .parameter = 14},
|
||||
{.instr = 2, .parameter = 21},
|
||||
{.instr = 12, .parameter = 0},
|
||||
{.instr = 20, .parameter = 0},
|
||||
{.instr = 1, .parameter = 13}
|
||||
const struct MysteryGiftClientCmd gUnknown_082F26B8[] = {
|
||||
{.instr = CLI_RECV, .parameter = 21},
|
||||
{.instr = CLI_12},
|
||||
{.instr = CLI_20},
|
||||
{.instr = CLI_RETURN, .parameter = 14}
|
||||
};
|
||||
|
||||
// Unused
|
||||
const struct MysteryGiftClientCmd gUnknown_082F26B8_1[] = {
|
||||
{.instr = CLI_RECV, .parameter = 21},
|
||||
{.instr = CLI_12},
|
||||
{.instr = CLI_20},
|
||||
{.instr = CLI_RETURN, .parameter = 13}
|
||||
};
|
||||
|
||||
const struct mevent_cmd gUnknown_082F26F8[] = {
|
||||
{.instr = 18, .flag = 0x10, .parameter = gUnknown_082F25C8},
|
||||
{.instr = 1, .flag = 0x00, .parameter = NULL},
|
||||
{.instr = 2, .flag = 0x14, .parameter = NULL},
|
||||
{.instr = 0, .flag = 0x0a, .parameter = NULL},
|
||||
{.instr = 18, .flag = 0x10, .parameter = gUnknown_082F25D8},
|
||||
{.instr = 1, .flag = 0x00, .parameter = NULL},
|
||||
{.instr = 2, .flag = 0x14, .parameter = NULL},
|
||||
{.instr = 0, .flag = 0x0b, .parameter = NULL},
|
||||
{.instr = 18, .flag = 0x10, .parameter = gUnknown_082F2698},
|
||||
{.instr = 1, .flag = 0x00, .parameter = NULL},
|
||||
{.instr = 2, .flag = 0x14, .parameter = NULL},
|
||||
{.instr = 0, .flag = 0x09, .parameter = NULL}
|
||||
{.instr = 18, .flag = sizeof(gUnknown_082F25C8), .parameter = gUnknown_082F25C8},
|
||||
{.instr = 1},
|
||||
{.instr = 2, .flag = 0x14},
|
||||
{.instr = 0, .flag = 0x0a},
|
||||
{.instr = 18, .flag = sizeof(gUnknown_082F25D8), .parameter = gUnknown_082F25D8},
|
||||
{.instr = 1},
|
||||
{.instr = 2, .flag = 0x14},
|
||||
{.instr = 0, .flag = 0x0b},
|
||||
{.instr = 18, .flag = sizeof(gUnknown_082F2698), .parameter = gUnknown_082F2698},
|
||||
{.instr = 1},
|
||||
{.instr = 2, .flag = 0x14},
|
||||
{.instr = 0, .flag = 0x09}
|
||||
};
|
||||
|
||||
const struct mevent_cmd gUnknown_082F2788[] = {
|
||||
{.instr = 18, .flag = 0x20, .parameter = gUnknown_082F26B8},
|
||||
{.instr = 1, .flag = 0x00, .parameter = NULL},
|
||||
{.instr = 18, .flag = sizeof(gUnknown_082F26B8), .parameter = gUnknown_082F26B8},
|
||||
{.instr = 1},
|
||||
{.instr = 20, .flag = 0x1b, .parameter = gText_CanceledReadingCard},
|
||||
{.instr = 1, .flag = 0x00, .parameter = NULL},
|
||||
{.instr = 2, .flag = 0x14, .parameter = NULL},
|
||||
{.instr = 0, .flag = 0x09, .parameter = NULL}
|
||||
{.instr = 1},
|
||||
{.instr = 2, .flag = 0x14},
|
||||
{.instr = 0, .flag = 0x09}
|
||||
};
|
||||
|
||||
const struct mevent_cmd gUnknown_082F27D0[] = {
|
||||
{.instr = 18, .flag = 0x10, .parameter = gUnknown_082F2650},
|
||||
{.instr = 1, .flag = 0x00, .parameter = NULL},
|
||||
{.instr = 2, .flag = 0x14, .parameter = NULL},
|
||||
{.instr = 0, .flag = 0x07, .parameter = NULL}
|
||||
{.instr = 18, .flag = sizeof(gUnknown_082F2650), .parameter = gUnknown_082F2650},
|
||||
{.instr = 1},
|
||||
{.instr = 2, .flag = 0x14},
|
||||
{.instr = 0, .flag = 0x07}
|
||||
};
|
||||
|
||||
const struct mevent_cmd gUnknown_082F2800[] = {
|
||||
{.instr = 18, .flag = 0x28, .parameter = gUnknown_082F2628},
|
||||
{.instr = 1, .flag = 0x00, .parameter = NULL},
|
||||
{.instr = 14, .flag = 0x00, .parameter = NULL},
|
||||
{.instr = 1, .flag = 0x00, .parameter = NULL},
|
||||
{.instr = 2, .flag = 0x13, .parameter = NULL},
|
||||
{.instr = 8, .flag = 0x00, .parameter = NULL},
|
||||
{.instr = 18, .flag = sizeof(gUnknown_082F2628), .parameter = gUnknown_082F2628},
|
||||
{.instr = 1},
|
||||
{.instr = 14},
|
||||
{.instr = 1},
|
||||
{.instr = 2, .flag = 0x13},
|
||||
{.instr = 8},
|
||||
{.instr = 4, .flag = 0x01, .parameter = gUnknown_082F27D0},
|
||||
{.instr = 18, .flag = 0x10, .parameter = gUnknown_082F2660},
|
||||
{.instr = 1, .flag = 0x00, .parameter = NULL},
|
||||
{.instr = 2, .flag = 0x14, .parameter = NULL},
|
||||
{.instr = 0, .flag = 0x03, .parameter = NULL}
|
||||
{.instr = 18, .flag = sizeof(gUnknown_082F2660), .parameter = gUnknown_082F2660},
|
||||
{.instr = 1},
|
||||
{.instr = 2, .flag = 0x14},
|
||||
{.instr = 0, .flag = 0x03}
|
||||
};
|
||||
|
||||
const struct mevent_cmd gUnknown_082F2884[] = {
|
||||
{.instr = 18, .flag = 0x30, .parameter = gUnknown_082F25F8},
|
||||
{.instr = 1, .flag = 0x00, .parameter = NULL},
|
||||
{.instr = 13, .flag = 0x00, .parameter = NULL},
|
||||
{.instr = 1, .flag = 0x00, .parameter = NULL},
|
||||
{.instr = 15, .flag = 0x00, .parameter = NULL},
|
||||
{.instr = 1, .flag = 0x00, .parameter = NULL},
|
||||
{.instr = 2, .flag = 0x14, .parameter = NULL},
|
||||
{.instr = 0, .flag = 0x02, .parameter = NULL}
|
||||
{.instr = 18, .flag = sizeof(gUnknown_082F25F8), .parameter = gUnknown_082F25F8},
|
||||
{.instr = 1},
|
||||
{.instr = 13},
|
||||
{.instr = 1},
|
||||
{.instr = 15},
|
||||
{.instr = 1},
|
||||
{.instr = 2, .flag = 0x14},
|
||||
{.instr = 0, .flag = 0x02}
|
||||
};
|
||||
|
||||
const struct mevent_cmd gUnknown_082F28E4[] = {
|
||||
{.instr = 18, .flag = 0x28, .parameter = gUnknown_082F2670},
|
||||
{.instr = 1, .flag = 0x00, .parameter = NULL},
|
||||
{.instr = 2, .flag = 0x13, .parameter = NULL},
|
||||
{.instr = 8, .flag = 0x00, .parameter = NULL},
|
||||
{.instr = 4, .flag = 0x00, .parameter = gUnknown_082F2884},
|
||||
{.instr = 3, .flag = 0x00, .parameter = gUnknown_082F2788}
|
||||
{.instr = 18, .flag = sizeof(gUnknown_082F2670), .parameter = gUnknown_082F2670},
|
||||
{.instr = 1},
|
||||
{.instr = 2, .flag = 0x13},
|
||||
{.instr = 8},
|
||||
{.instr = 4, .parameter = gUnknown_082F2884},
|
||||
{.instr = 3, .parameter = gUnknown_082F2788}
|
||||
};
|
||||
|
||||
const struct mevent_cmd gUnknown_082F292C[] = {
|
||||
{.instr = 18, .flag = 0x10, .parameter = gUnknown_082F26A8},
|
||||
{.instr = 1, .flag = 0x00, .parameter = NULL},
|
||||
{.instr = 2, .flag = 0x14, .parameter = NULL},
|
||||
{.instr = 0, .flag = 0x05, .parameter = NULL},
|
||||
{.instr = 18, .flag = 0x10, .parameter = gUnknown_082F25E8},
|
||||
{.instr = 1, .flag = 0x00, .parameter = NULL},
|
||||
{.instr = 2, .flag = 0x14, .parameter = NULL},
|
||||
{.instr = 0, .flag = 0x00, .parameter = NULL}
|
||||
{.instr = 18, .flag = sizeof(gUnknown_082F26A8), .parameter = gUnknown_082F26A8},
|
||||
{.instr = 1},
|
||||
{.instr = 2, .flag = 0x14},
|
||||
{.instr = 0, .flag = 0x05},
|
||||
{.instr = 18, .flag = sizeof(gUnknown_082F25E8), .parameter = gUnknown_082F25E8},
|
||||
{.instr = 1},
|
||||
{.instr = 2, .flag = 0x14},
|
||||
{.instr = 0}
|
||||
};
|
||||
|
||||
const struct mevent_cmd s_mevent_wonder_news[] = {
|
||||
{.instr = 27, .flag = 0x00, .parameter = NULL},
|
||||
{.instr = 18, .flag = 0x20, .parameter = gUnknown_082F25A8},
|
||||
{.instr = 1, .flag = 0x00, .parameter = NULL},
|
||||
{.instr = 2, .flag = 0x11, .parameter = NULL},
|
||||
{.instr = 5, .flag = 0x00, .parameter = NULL},
|
||||
{.instr = 30, .flag = 0x00, .parameter = NULL},
|
||||
{.instr = 4, .flag = 0x00, .parameter = gUnknown_082F26F8},
|
||||
{.instr = 3, .flag = 0x00, .parameter = gUnknown_082F2800}
|
||||
{.instr = 27},
|
||||
{.instr = 18, .flag = sizeof(gUnknown_082F25A8), .parameter = gUnknown_082F25A8},
|
||||
{.instr = 1},
|
||||
{.instr = 2, .flag = 0x11},
|
||||
{.instr = 5},
|
||||
{.instr = 30},
|
||||
{.instr = 4, .parameter = gUnknown_082F26F8},
|
||||
{.instr = 3, .parameter = gUnknown_082F2800}
|
||||
};
|
||||
|
||||
const struct mevent_cmd s_mevent_wonder_card[] = {
|
||||
{.instr = 26, .flag = 0x00, .parameter = NULL},
|
||||
{.instr = 28, .flag = 0x00, .parameter = NULL},
|
||||
{.instr = 18, .flag = 0x20, .parameter = gUnknown_082F25A8},
|
||||
{.instr = 1, .flag = 0x00, .parameter = NULL},
|
||||
{.instr = 2, .flag = 0x11, .parameter = NULL},
|
||||
{.instr = 5, .flag = 0x00, .parameter = NULL},
|
||||
{.instr = 6, .flag = 0x00, .parameter = NULL},
|
||||
{.instr = 4, .flag = 0x00, .parameter = gUnknown_082F26F8},
|
||||
{.instr = 7, .flag = 0x00, .parameter = NULL},
|
||||
{.instr = 26},
|
||||
{.instr = 28},
|
||||
{.instr = 18, .flag = sizeof(gUnknown_082F25A8), .parameter = gUnknown_082F25A8},
|
||||
{.instr = 1},
|
||||
{.instr = 2, .flag = 0x11},
|
||||
{.instr = 5},
|
||||
{.instr = 6},
|
||||
{.instr = 4, .parameter = gUnknown_082F26F8},
|
||||
{.instr = 7},
|
||||
{.instr = 4, .flag = 0x02, .parameter = gUnknown_082F28E4},
|
||||
{.instr = 4, .flag = 0x00, .parameter = gUnknown_082F2884},
|
||||
{.instr = 3, .flag = 0x00, .parameter = gUnknown_082F292C}
|
||||
{.instr = 4, .parameter = gUnknown_082F2884},
|
||||
{.instr = 3, .parameter = gUnknown_082F292C}
|
||||
};
|
||||
|
@ -52,7 +52,7 @@ static void mevent_srv_init_common(struct mevent_srv_common * svr, const void *
|
||||
svr->mevent_unk1442cc = AllocZeroed(sizeof(struct MEventStruct_Unk1442CC));
|
||||
svr->cmdBuffer = cmdBuffer;
|
||||
svr->cmdidx = 0;
|
||||
mevent_srv_sub_init(&svr->manager, sendPlayerNo, recvPlayerNo);
|
||||
MysteryGiftLink_Init(&svr->manager, sendPlayerNo, recvPlayerNo);
|
||||
}
|
||||
|
||||
static void mevent_srv_free_resources(struct mevent_srv_common * svr)
|
||||
@ -66,7 +66,7 @@ static void mevent_srv_free_resources(struct mevent_srv_common * svr)
|
||||
void mevent_srv_common_init_send(struct mevent_srv_common * svr, u32 ident, const void * src, u32 size)
|
||||
{
|
||||
AGB_ASSERT(size <= ME_SEND_BUF_SIZE);
|
||||
mevent_srv_sub_init_send(&svr->manager, ident, src, size);
|
||||
MysteryGiftLink_InitSend(&svr->manager, ident, src, size);
|
||||
}
|
||||
|
||||
static const void * mevent_first_if_not_null_else_second(const void * a0, const void * a1)
|
||||
@ -103,7 +103,7 @@ static u32 common_mainseq_1(struct mevent_srv_common * svr)
|
||||
static u32 common_mainseq_2(struct mevent_srv_common * svr)
|
||||
{
|
||||
// do recv
|
||||
if (mevent_srv_sub_recv(&svr->manager))
|
||||
if (MysteryGiftLink_Recv(&svr->manager))
|
||||
svr->mainseqno = 4;
|
||||
return 1;
|
||||
}
|
||||
@ -111,7 +111,7 @@ static u32 common_mainseq_2(struct mevent_srv_common * svr)
|
||||
static u32 common_mainseq_3(struct mevent_srv_common * svr)
|
||||
{
|
||||
// do send
|
||||
if (mevent_srv_sub_send(&svr->manager))
|
||||
if (MysteryGiftLink_Send(&svr->manager))
|
||||
svr->mainseqno = 4;
|
||||
return 1;
|
||||
}
|
||||
@ -138,7 +138,7 @@ static u32 common_mainseq_4(struct mevent_srv_common * svr)
|
||||
case 2:
|
||||
// receive
|
||||
AGB_ASSERT(cmd->parameter == NULL);
|
||||
mevent_srv_sub_init_recv(&svr->manager, cmd->flag, svr->recvBuffer);
|
||||
MysteryGiftLink_InitRecv(&svr->manager, cmd->flag, svr->recvBuffer);
|
||||
svr->mainseqno = 2;
|
||||
break;
|
||||
case 3:
|
||||
@ -196,7 +196,7 @@ static u32 common_mainseq_4(struct mevent_srv_common * svr)
|
||||
break;
|
||||
case 11:
|
||||
AGB_ASSERT(cmd->flag == FALSE);
|
||||
svr->param = MEventStruct_Unk1442CC_CompareField_unk_16(svr->mevent_unk1442cc, cmd->parameter);
|
||||
svr->param = MysteryGift_DoesQuestionnaireMatch(svr->mevent_unk1442cc, cmd->parameter);
|
||||
break;
|
||||
case 12:
|
||||
AGB_ASSERT(cmd->flag == FALSE);
|
||||
|
@ -11,20 +11,20 @@
|
||||
#include "mevent.h"
|
||||
#include "mevent_server_helpers.h"
|
||||
|
||||
static u32 mevent_receive_func(struct mevent_srv_sub *);
|
||||
static u32 mevent_send_func(struct mevent_srv_sub *);
|
||||
static u32 mevent_receive_func(struct MysteryGiftLink *);
|
||||
static u32 mevent_send_func(struct MysteryGiftLink *);
|
||||
|
||||
u32 mevent_srv_sub_recv(struct mevent_srv_sub * svr)
|
||||
u32 MysteryGiftLink_Recv(struct MysteryGiftLink * svr)
|
||||
{
|
||||
return svr->recvFunc(svr);
|
||||
}
|
||||
|
||||
u32 mevent_srv_sub_send(struct mevent_srv_sub * svr)
|
||||
u32 MysteryGiftLink_Send(struct MysteryGiftLink * svr)
|
||||
{
|
||||
return svr->sendFunc(svr);
|
||||
}
|
||||
|
||||
void mevent_srv_sub_init(struct mevent_srv_sub * svr, u32 sendPlayerNo, u32 recvPlayerNo)
|
||||
void MysteryGiftLink_Init(struct MysteryGiftLink * svr, u32 sendPlayerNo, u32 recvPlayerNo)
|
||||
{
|
||||
svr->sendPlayerNo = sendPlayerNo;
|
||||
svr->recvPlayerNo = recvPlayerNo;
|
||||
@ -41,7 +41,7 @@ void mevent_srv_sub_init(struct mevent_srv_sub * svr, u32 sendPlayerNo, u32 recv
|
||||
svr->recvFunc = mevent_receive_func;
|
||||
}
|
||||
|
||||
void mevent_srv_sub_init_send(struct mevent_srv_sub * svr, u32 ident, const void * src, u32 size)
|
||||
void MysteryGiftLink_InitSend(struct MysteryGiftLink * svr, u32 ident, const void * src, u32 size)
|
||||
{
|
||||
svr->seqno = 0;
|
||||
svr->sendIdent = ident;
|
||||
@ -54,7 +54,7 @@ void mevent_srv_sub_init_send(struct mevent_srv_sub * svr, u32 ident, const void
|
||||
svr->sendBfr = src;
|
||||
}
|
||||
|
||||
void mevent_srv_sub_init_recv(struct mevent_srv_sub * svr, u32 ident, void * dest)
|
||||
void MysteryGiftLink_InitRecv(struct MysteryGiftLink * svr, u32 ident, void * dest)
|
||||
{
|
||||
svr->seqno = 0;
|
||||
svr->recvIdent = ident;
|
||||
@ -82,7 +82,7 @@ static void mevent_reset_recv(u32 recv_idx)
|
||||
ResetBlockReceivedFlag(recv_idx);
|
||||
}
|
||||
|
||||
static bool32 mevent_receive_func(struct mevent_srv_sub * svr)
|
||||
static bool32 mevent_receive_func(struct MysteryGiftLink * svr)
|
||||
{
|
||||
struct send_recv_header header;
|
||||
|
||||
@ -148,7 +148,7 @@ static bool32 mevent_receive_func(struct mevent_srv_sub * svr)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static bool32 mevent_send_func(struct mevent_srv_sub * svr)
|
||||
static bool32 mevent_send_func(struct MysteryGiftLink * svr)
|
||||
{
|
||||
struct send_recv_header header;
|
||||
|
||||
|
@ -65,15 +65,15 @@ static bool32 RunMysteryEventScriptCommand(struct ScriptContext *ctx)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void sub_8153870(u8 *script)
|
||||
void InitMysteryGiftScriptContext(u8 *script)
|
||||
{
|
||||
InitMysteryEventScript(&sMysteryEventScriptContext, script);
|
||||
}
|
||||
|
||||
bool32 sub_8153884(u32 *a0)
|
||||
bool32 RunMysteryGiftScriptContextCommand(u32 *script)
|
||||
{
|
||||
bool32 ret = RunMysteryEventScriptCommand(&sMysteryEventScriptContext);
|
||||
*a0 = sMysteryEventScriptContext.data[2];
|
||||
*script = sMysteryEventScriptContext.data[2];
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -761,9 +761,9 @@ static s32 HandleMysteryGiftListMenu(u8 * textState, u16 * windowId, bool32 cann
|
||||
static bool32 ValidateCardOrNews(bool32 isWonderNews)
|
||||
{
|
||||
if (!isWonderNews)
|
||||
return ValidateReceivedWonderCard();
|
||||
return ValidateSavedWonderCard();
|
||||
else
|
||||
return ValidateReceivedWonderNews();
|
||||
return ValidateSavedWonderNews();
|
||||
}
|
||||
|
||||
static bool32 HandleLoadWonderCardOrNews(u8 * state, bool32 isWonderNews)
|
||||
@ -795,12 +795,12 @@ static bool32 HandleLoadWonderCardOrNews(u8 * state, bool32 isWonderNews)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static bool32 DestroyNewsOrCard(bool32 isWonderNews)
|
||||
static bool32 ClearSavedNewsOrCard(bool32 isWonderNews)
|
||||
{
|
||||
if (!isWonderNews)
|
||||
DestroyWonderCard();
|
||||
ClearSavedWonderCard();
|
||||
else
|
||||
DestroyWonderNews();
|
||||
ClearSavedWonderNews();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@ -1055,8 +1055,8 @@ enum {
|
||||
MG_STATE_COMMUNICATE,
|
||||
MG_STATE_9,
|
||||
MG_STATE_10,
|
||||
MG_STATE_11,
|
||||
MG_STATE_12,
|
||||
MG_STATE_LINK_ASK_TOSS,
|
||||
MG_STATE_LINK_ASK_TOSS_UNRECEIVED,
|
||||
MG_STATE_LINK_COMPLETE_WAIT,
|
||||
MG_STATE_LINK_COMPLETED,
|
||||
MG_STATE_LINK_RESULT_MSG,
|
||||
@ -1119,14 +1119,14 @@ static void Task_MysteryGift(u8 taskId)
|
||||
{
|
||||
case 0: // "Wonder Cards"
|
||||
data->isWonderNews = FALSE;
|
||||
if (ValidateReceivedWonderCard() == TRUE)
|
||||
if (ValidateSavedWonderCard() == TRUE)
|
||||
data->state = MG_STATE_LOAD_GIFT;
|
||||
else
|
||||
data->state = MG_STATE_DONT_HAVE_ANY;
|
||||
break;
|
||||
case 1: // "Wonder News"
|
||||
data->isWonderNews = TRUE;
|
||||
if (ValidateReceivedWonderNews() == TRUE)
|
||||
if (ValidateSavedWonderNews() == TRUE)
|
||||
data->state = MG_STATE_LOAD_GIFT;
|
||||
else
|
||||
data->state = MG_STATE_DONT_HAVE_ANY;
|
||||
@ -1220,7 +1220,7 @@ static void Task_MysteryGift(u8 taskId)
|
||||
{
|
||||
ClearScreenInBg0(TRUE);
|
||||
data->state = MG_STATE_COMMUNICATING;
|
||||
mevent_client_do_init(data->isWonderNews);
|
||||
MysteryGiftClient_Create(data->isWonderNews);
|
||||
}
|
||||
else if (gSpecialVar_Result == LINKUP_FAILED)
|
||||
{
|
||||
@ -1234,25 +1234,25 @@ static void Task_MysteryGift(u8 taskId)
|
||||
data->state = MG_STATE_COMMUNICATE;
|
||||
break;
|
||||
case MG_STATE_COMMUNICATE:
|
||||
switch (mevent_client_do_exec(&data->curPromptWindowId))
|
||||
switch (MysteryGiftClient_Run(&data->curPromptWindowId))
|
||||
{
|
||||
case 6:
|
||||
case CLI_RET_END:
|
||||
Rfu_SetCloseLinkCallback();
|
||||
data->prevPromptWindowId = data->curPromptWindowId;
|
||||
data->state = MG_STATE_LINK_COMPLETE_WAIT;
|
||||
break;
|
||||
case 5:
|
||||
case CLI_RET_5:
|
||||
memcpy(data->buffer, mevent_client_get_buffer(), 0x40);
|
||||
mevent_client_inc_flag();
|
||||
MysteryGiftClient_AdvanceState();
|
||||
break;
|
||||
case 3:
|
||||
case CLI_RET_3:
|
||||
data->state = MG_STATE_10;
|
||||
break;
|
||||
case 2:
|
||||
case CLI_RET_2:
|
||||
data->state = MG_STATE_9;
|
||||
break;
|
||||
case 4:
|
||||
data->state = MG_STATE_11;
|
||||
case CLI_RET_ASK_TOSS:
|
||||
data->state = MG_STATE_LINK_ASK_TOSS;
|
||||
StringCopy(gStringVar1, gLinkPlayers[0].name);
|
||||
break;
|
||||
}
|
||||
@ -1262,14 +1262,14 @@ static void Task_MysteryGift(u8 taskId)
|
||||
switch (input)
|
||||
{
|
||||
case 0: // Yes
|
||||
mevent_client_set_param(0);
|
||||
mevent_client_inc_flag();
|
||||
MysteryGiftClient_SetParam(0);
|
||||
MysteryGiftClient_AdvanceState();
|
||||
data->state = MG_STATE_COMMUNICATING;
|
||||
break;
|
||||
case 1: // No
|
||||
case MENU_B_PRESSED:
|
||||
mevent_client_set_param(1);
|
||||
mevent_client_inc_flag();
|
||||
MysteryGiftClient_SetParam(1);
|
||||
MysteryGiftClient_AdvanceState();
|
||||
data->state = MG_STATE_COMMUNICATING;
|
||||
break;
|
||||
}
|
||||
@ -1277,47 +1277,47 @@ static void Task_MysteryGift(u8 taskId)
|
||||
case MG_STATE_10:
|
||||
if (MG_PrintTextOnWindow1AndWaitButton(&data->textState, mevent_client_get_buffer()))
|
||||
{
|
||||
mevent_client_inc_flag();
|
||||
MysteryGiftClient_AdvanceState();
|
||||
data->state = MG_STATE_COMMUNICATING;
|
||||
}
|
||||
break;
|
||||
case MG_STATE_11:
|
||||
case MG_STATE_LINK_ASK_TOSS:
|
||||
input = DoMysteryGiftYesNo(&data->textState, &data->curPromptWindowId, FALSE, gText_ThrowAwayWonderCard);
|
||||
switch (input)
|
||||
{
|
||||
case 0: // Yes
|
||||
if (CheckReceivedGiftFromWonderCard() == TRUE)
|
||||
{
|
||||
data->state = MG_STATE_12;
|
||||
data->state = MG_STATE_LINK_ASK_TOSS_UNRECEIVED;
|
||||
}
|
||||
else
|
||||
{
|
||||
mevent_client_set_param(0);
|
||||
mevent_client_inc_flag();
|
||||
MysteryGiftClient_SetParam(0);
|
||||
MysteryGiftClient_AdvanceState();
|
||||
data->state = MG_STATE_COMMUNICATING;
|
||||
}
|
||||
break;
|
||||
case 1: // No
|
||||
case MENU_B_PRESSED:
|
||||
mevent_client_set_param(1);
|
||||
mevent_client_inc_flag();
|
||||
MysteryGiftClient_SetParam(1);
|
||||
MysteryGiftClient_AdvanceState();
|
||||
data->state = MG_STATE_COMMUNICATING;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case MG_STATE_12:
|
||||
case MG_STATE_LINK_ASK_TOSS_UNRECEIVED:
|
||||
input = DoMysteryGiftYesNo(&data->textState, &data->curPromptWindowId, FALSE, gText_HaventReceivedCardsGift);
|
||||
switch (input)
|
||||
{
|
||||
case 0: // Yes
|
||||
mevent_client_set_param(0);
|
||||
mevent_client_inc_flag();
|
||||
MysteryGiftClient_SetParam(0);
|
||||
MysteryGiftClient_AdvanceState();
|
||||
data->state = MG_STATE_COMMUNICATING;
|
||||
break;
|
||||
case 1: // No
|
||||
case MENU_B_PRESSED:
|
||||
mevent_client_set_param(1);
|
||||
mevent_client_inc_flag();
|
||||
MysteryGiftClient_SetParam(1);
|
||||
MysteryGiftClient_AdvanceState();
|
||||
data->state = MG_STATE_COMMUNICATING;
|
||||
break;
|
||||
}
|
||||
@ -1436,7 +1436,7 @@ static void Task_MysteryGift(u8 taskId)
|
||||
break;
|
||||
}
|
||||
case MG_STATE_ASK_TOSS:
|
||||
// Player is atempting to discard a Wonder Card/News
|
||||
// Player is attempting to discard a Wonder Card/News
|
||||
switch (AskDiscardGift(&data->textState, &data->curPromptWindowId, data->isWonderNews))
|
||||
{
|
||||
case 0: // Yes
|
||||
@ -1452,7 +1452,8 @@ static void Task_MysteryGift(u8 taskId)
|
||||
}
|
||||
break;
|
||||
case MG_STATE_ASK_TOSS_UNRECEIVED:
|
||||
// Player is attempting to discard a Wonder Card that they haven't received the gift for
|
||||
// Player has selected to toss a Wonder Card that they haven't received the gift for.
|
||||
// Ask for confirmation again.
|
||||
switch ((u32)DoMysteryGiftYesNo(&data->textState, &data->curPromptWindowId, TRUE, gText_HaventReceivedGiftOkayToDiscard))
|
||||
{
|
||||
case 0: // Yes
|
||||
@ -1467,7 +1468,7 @@ static void Task_MysteryGift(u8 taskId)
|
||||
case MG_STATE_TOSS:
|
||||
if (ExitWonderCardOrNews(data->isWonderNews, 1))
|
||||
{
|
||||
DestroyNewsOrCard(data->isWonderNews);
|
||||
ClearSavedNewsOrCard(data->isWonderNews);
|
||||
data->state = MG_STATE_TOSS_SAVE;
|
||||
}
|
||||
break;
|
||||
|
@ -2230,7 +2230,7 @@ bool8 ScrCmd_checkmoneventlegal(struct ScriptContext *ctx)
|
||||
}
|
||||
|
||||
// TODO: Should be renamed. Name implies general usage, but its specifically for Wonder Card
|
||||
// See GetSavedRamScriptIfValid, which is NULL if ValidateReceivedWonderCard returns FALSE
|
||||
// See GetSavedRamScriptIfValid, which is NULL if ValidateSavedWonderCard returns FALSE
|
||||
bool8 ScrCmd_gotoram(struct ScriptContext *ctx)
|
||||
{
|
||||
const u8* script = GetSavedRamScriptIfValid();
|
||||
|
@ -417,7 +417,7 @@ bool32 ValidateSavedRamScript(void)
|
||||
u8 *GetSavedRamScriptIfValid(void)
|
||||
{
|
||||
struct RamScriptData *scriptData = &gSaveBlock1Ptr->ramScript.data;
|
||||
if (!ValidateReceivedWonderCard())
|
||||
if (!ValidateSavedWonderCard())
|
||||
return NULL;
|
||||
if (scriptData->magic != RAM_SCRIPT_MAGIC)
|
||||
return NULL;
|
||||
|
@ -51,7 +51,7 @@ struct UnkStruct_203F3C8_02DC
|
||||
struct WonderCardData
|
||||
{
|
||||
/*0000*/ struct WonderCard card;
|
||||
/*014c*/ struct MEventBuffer_3430_Sub unk_014C;
|
||||
/*014c*/ struct MEventBuffer_3430 unk_014C;
|
||||
/*0170*/ const struct WonderGraphics * gfx;
|
||||
/*0174*/ u8 enterExitState;
|
||||
/*0175*/ u8 unk_0175;
|
||||
@ -176,7 +176,7 @@ static const struct WonderGraphics sCardGraphics[NUM_WONDER_BGS] = {
|
||||
{.textPal1 = 1, .textPal2 = 0, .textPal3 = 0, .textPal4 = 7, .tiles = sWonderCardBgGfx8, .map = sWonderCardBgTilemap8, .pal = sWonderCardBgPal8}
|
||||
};
|
||||
|
||||
bool32 WonderCard_Init(struct WonderCard * card, struct MEventBuffer_3430_Sub * r6)
|
||||
bool32 WonderCard_Init(struct WonderCard * card, struct MEventBuffer_3430 * r6)
|
||||
{
|
||||
if (card == NULL || r6 == NULL)
|
||||
return FALSE;
|
||||
|
Loading…
Reference in New Issue
Block a user