diff --git a/include/global.h b/include/global.h index 0506c036e..7b570d72e 100644 --- a/include/global.h +++ b/include/global.h @@ -816,7 +816,7 @@ struct MysteryEventStruct u8 unk_1; }; - struct MEventBuffer_3120_Sub + struct WonderNews { u16 unk_00; u8 unk_02; @@ -825,13 +825,13 @@ struct MysteryEventStruct u8 unk_2C[10][40]; }; - struct MEventBuffer_3120 + struct WonderNewsSaveStruct { u32 crc; - struct MEventBuffer_3120_Sub data; + struct WonderNews data; }; - struct MEventBuffer_32E0_Sub + struct WonderCard { u16 unk_00; u16 unk_02; @@ -847,10 +847,10 @@ struct MysteryEventStruct u8 unk_122[40]; }; - struct MEventBuffer_32E0 + struct WonderCardSaveStruct { u32 crc; - struct MEventBuffer_32E0_Sub data; + struct WonderCard data; }; struct MEventBuffer_3430_Sub @@ -870,8 +870,8 @@ struct MysteryEventStruct struct MEventBuffers { - /*0x000 0x322C*/ struct MEventBuffer_3120 buffer_000; - /*0x1c0 0x33EC*/ struct MEventBuffer_32E0 buffer_1c0; + /*0x000 0x322C*/ struct WonderNewsSaveStruct wonderNews; + /*0x1c0 0x33EC*/ struct WonderCardSaveStruct wonderCard; /*0x310 0x353C*/ struct MEventBuffer_3430 buffer_310; /*0x338 0x3564*/ u16 unk_338[4]; /*0x340 0x356C*/ struct MysteryEventStruct unk_340; diff --git a/include/mevent.h b/include/mevent.h index 68c19abfc..a34ca355c 100755 --- a/include/mevent.h +++ b/include/mevent.h @@ -32,30 +32,30 @@ struct MEventStruct_Unk1442CC }; void sub_801AFD8(void); -struct MEventBuffer_3120_Sub *sav1_get_mevent_buffer_0(void); -struct MEventBuffer_32E0_Sub *sav1_get_mevent_buffer_1(void); +struct WonderNews *GetSavedWonderNews(void); +struct WonderCard *GetSavedWonderCard(void); struct MEventBuffer_3430_Sub *sav1_get_mevent_buffer_2(void); struct MysteryEventStruct *sub_801B044(void); u16 *sub_801B058(void); void DestroyWonderNews(void); -bool32 sub_801B078(const struct MEventBuffer_3120_Sub *src); +bool32 sub_801B078(const struct WonderNews *src); bool32 ValidateReceivedWonderNews(void); bool32 WonderNews_Test_Unk_02(void); bool32 sub_801B1A4(const u8 *src); void DestroyWonderCard(void); -bool32 sub_801B21C(const struct MEventBuffer_32E0_Sub *data); +bool32 sub_801B21C(const struct WonderCard *data); bool32 ValidateReceivedWonderCard(void); bool32 WonderCard_Test_Unk_08_6(void); u16 GetWonderCardFlagID(void); -void sub_801B3C0(struct MEventBuffer_32E0_Sub *buffer); +void WonderCard_ResetInternalReceivedFlag(struct WonderCard *buffer); bool32 CheckReceivedGiftFromWonderCard(void); bool32 sub_801B508(const u16 *data); 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 sub_801B748(const struct MEventStruct_Unk1442CC *a0, const u16 *a1); -u16 sub_801B784(const struct MEventStruct_Unk1442CC *a0, u32 command); +bool32 MEventStruct_Unk1442CC_CompareField_unk_16(const struct MEventStruct_Unk1442CC *a0, const u16 *a1); +u16 MEventStruct_Unk1442CC_GetValueNFrom_unk_20(const struct MEventStruct_Unk1442CC *a0, u32 command); u16 mevent_081445C0(u32 command); void sub_801B940(void); bool32 sub_801B94C(u16 a0); diff --git a/include/mevent_801BAAC.h b/include/mevent_801BAAC.h index 547d5237b..d76bc92c2 100644 --- a/include/mevent_801BAAC.h +++ b/include/mevent_801BAAC.h @@ -1,8 +1,8 @@ #ifndef GUARD_MEVENT_801BAAC_H #define GUARD_MEVENT_801BAAC_H -bool32 InitWonderCardResources(struct MEventBuffer_32E0_Sub * r5, struct MEventBuffer_3430_Sub * r6); -bool32 InitWonderNewsResources(const struct MEventBuffer_3120_Sub * a0); +bool32 InitWonderCardResources(struct WonderCard * r5, struct MEventBuffer_3430_Sub * r6); +bool32 InitWonderNewsResources(const struct WonderNews * a0); s32 FadeToWonderCardMenu(void); s32 FadeToWonderNewsMenu(void); s32 FadeOutFromWonderCard(bool32 flag); diff --git a/include/mevent_server.h b/include/mevent_server.h index 019f3c685..e74337cf6 100644 --- a/include/mevent_server.h +++ b/include/mevent_server.h @@ -18,8 +18,8 @@ struct mevent_srv_common u32 cmdidx; const struct mevent_cmd * cmdBuffer; void * recvBuffer; - struct MEventBuffer_32E0_Sub * mevent_32e0; - struct MEventBuffer_3120_Sub * mevent_3120; + struct WonderCard * wonder_card; + struct WonderNews * wonder_news; struct MEventStruct_Unk1442CC * mevent_unk1442cc; const void * sendBuffer1; u32 sendBuffer1Size; diff --git a/include/script.h b/include/script.h index 34f4635bb..cfe493479 100644 --- a/include/script.h +++ b/include/script.h @@ -57,9 +57,9 @@ u32 CalculateRamScriptChecksum(void); void ClearRamScript(void); bool8 InitRamScript(const u8 *script, u16 scriptSize, u8 mapGroup, u8 mapNum, u8 objectId); const u8 *GetRamScript(u8 objectId, const u8 *script); -bool32 sub_80991F8(void); -u8 *sub_8099244(void); -void sub_80992A0(u8 *script, u16 scriptSize); +bool32 ValidateSavedRamScript(void); +u8 *GetSavedRamScriptIfValid(void); +void InitRamScript_NoEventObject(u8 *script, u16 scriptSize); // srccmd.h void sub_809BE48(u16 npcId); diff --git a/src/mevent2.c b/src/mevent2.c index 8585224ef..f36e5d06b 100755 --- a/src/mevent2.c +++ b/src/mevent2.c @@ -15,8 +15,8 @@ static EWRAM_DATA bool32 gUnknown_02022C70 = FALSE; static void sub_801B180(void); static void s_DestroyWonderNews(void); -static bool32 sub_801B114(const struct MEventBuffer_3120_Sub *data); -static bool32 sub_801B2CC(const struct MEventBuffer_32E0_Sub *data); +static bool32 sub_801B114(const struct WonderNews *data); +static bool32 sub_801B2CC(const struct WonderCard *data); static void sub_801B330(void); static void sub_801B368(void); static void sub_801B9F8(void); @@ -29,14 +29,14 @@ void sub_801AFD8(void) sub_811F8BC(); } -struct MEventBuffer_3120_Sub *sav1_get_mevent_buffer_0(void) +struct WonderNews *GetSavedWonderNews(void) { - return &gSaveBlock1Ptr->unk_322C.buffer_000.data; + return &gSaveBlock1Ptr->unk_322C.wonderNews.data; } -struct MEventBuffer_32E0_Sub *sav1_get_mevent_buffer_1(void) +struct WonderCard *GetSavedWonderCard(void) { - return &gSaveBlock1Ptr->unk_322C.buffer_1c0.data; + return &gSaveBlock1Ptr->unk_322C.wonderCard.data; } struct MEventBuffer_3430_Sub *sav1_get_mevent_buffer_2(void) @@ -59,28 +59,28 @@ void DestroyWonderNews(void) s_DestroyWonderNews(); } -bool32 sub_801B078(const struct MEventBuffer_3120_Sub *src) +bool32 sub_801B078(const struct WonderNews *src) { if (!sub_801B114(src)) return FALSE; s_DestroyWonderNews(); - gSaveBlock1Ptr->unk_322C.buffer_000.data = *src; - gSaveBlock1Ptr->unk_322C.buffer_000.crc = CalcCRC16WithTable((void *)&gSaveBlock1Ptr->unk_322C.buffer_000.data, sizeof(struct MEventBuffer_3120_Sub)); + gSaveBlock1Ptr->unk_322C.wonderNews.data = *src; + gSaveBlock1Ptr->unk_322C.wonderNews.crc = CalcCRC16WithTable((void *)&gSaveBlock1Ptr->unk_322C.wonderNews.data, sizeof(struct WonderNews)); return TRUE; } bool32 ValidateReceivedWonderNews(void) { - if (CalcCRC16WithTable((void *)&gSaveBlock1Ptr->unk_322C.buffer_000.data, sizeof(struct MEventBuffer_3120_Sub)) != gSaveBlock1Ptr->unk_322C.buffer_000.crc) + if (CalcCRC16WithTable((void *)&gSaveBlock1Ptr->unk_322C.wonderNews.data, sizeof(struct WonderNews)) != gSaveBlock1Ptr->unk_322C.wonderNews.crc) return FALSE; - if (!sub_801B114(&gSaveBlock1Ptr->unk_322C.buffer_000.data)) + if (!sub_801B114(&gSaveBlock1Ptr->unk_322C.wonderNews.data)) return FALSE; return TRUE; } -static bool32 sub_801B114(const struct MEventBuffer_3120_Sub *data) +static bool32 sub_801B114(const struct WonderNews *data) { if (data->unk_00 == 0) return FALSE; @@ -90,7 +90,7 @@ static bool32 sub_801B114(const struct MEventBuffer_3120_Sub *data) bool32 WonderNews_Test_Unk_02(void) { - const struct MEventBuffer_3120_Sub *data = &gSaveBlock1Ptr->unk_322C.buffer_000.data; + const struct WonderNews *data = &gSaveBlock1Ptr->unk_322C.wonderNews.data; if (data->unk_02 == 0) return FALSE; @@ -99,8 +99,8 @@ bool32 WonderNews_Test_Unk_02(void) static void s_DestroyWonderNews(void) { - CpuFill32(0, sav1_get_mevent_buffer_0(), sizeof(gSaveBlock1Ptr->unk_322C.buffer_000.data)); - gSaveBlock1Ptr->unk_322C.buffer_000.crc = 0; + CpuFill32(0, GetSavedWonderNews(), sizeof(gSaveBlock1Ptr->unk_322C.wonderNews.data)); + gSaveBlock1Ptr->unk_322C.wonderNews.crc = 0; } static void sub_801B180(void) @@ -111,12 +111,12 @@ static void sub_801B180(void) bool32 sub_801B1A4(const u8 *src) { - const u8 *r5 = (const u8 *)&gSaveBlock1Ptr->unk_322C.buffer_000.data; + const u8 *r5 = (const u8 *)&gSaveBlock1Ptr->unk_322C.wonderNews.data; u32 i; if (!ValidateReceivedWonderNews()) return FALSE; - for (i = 0; i < sizeof(struct MEventBuffer_3120_Sub); i++) + for (i = 0; i < sizeof(struct WonderNews); i++) { if (r5[i] != src[i]) return FALSE; @@ -136,35 +136,35 @@ void DestroyWonderCard(void) ClearEReaderTrainer(&gSaveBlock2Ptr->frontier.ereaderTrainer); } -bool32 sub_801B21C(const struct MEventBuffer_32E0_Sub *data) +bool32 sub_801B21C(const struct WonderCard *data) { struct MEventBuffer_3430_Sub *r2; - struct MEventBuffer_32E0_Sub *r1; + struct WonderCard *r1; if (!sub_801B2CC(data)) return FALSE; DestroyWonderCard(); - memcpy(&gSaveBlock1Ptr->unk_322C.buffer_1c0.data, data, sizeof(struct MEventBuffer_32E0_Sub)); - gSaveBlock1Ptr->unk_322C.buffer_1c0.crc = CalcCRC16WithTable((void *)&gSaveBlock1Ptr->unk_322C.buffer_1c0.data, sizeof(struct MEventBuffer_32E0_Sub)); + 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.buffer_1c0.data; + r1 = &gSaveBlock1Ptr->unk_322C.wonderCard.data; r2->unk_06 = r1->unk_02; return TRUE; } bool32 ValidateReceivedWonderCard(void) { - if (gSaveBlock1Ptr->unk_322C.buffer_1c0.crc != CalcCRC16WithTable((void *)&gSaveBlock1Ptr->unk_322C.buffer_1c0.data, sizeof(struct MEventBuffer_32E0_Sub))) + if (gSaveBlock1Ptr->unk_322C.wonderCard.crc != CalcCRC16WithTable((void *)&gSaveBlock1Ptr->unk_322C.wonderCard.data, sizeof(struct WonderCard))) return FALSE; - if (!sub_801B2CC(&gSaveBlock1Ptr->unk_322C.buffer_1c0.data)) + if (!sub_801B2CC(&gSaveBlock1Ptr->unk_322C.wonderCard.data)) return FALSE; - if (!sub_80991F8()) + if (!ValidateSavedRamScript()) return FALSE; return TRUE; } -static bool32 sub_801B2CC(const struct MEventBuffer_32E0_Sub *data) +static bool32 sub_801B2CC(const struct WonderCard *data) { if (data->unk_00 == 0) return FALSE; @@ -182,7 +182,7 @@ static bool32 sub_801B2CC(const struct MEventBuffer_32E0_Sub *data) bool32 WonderCard_Test_Unk_08_6(void) { - const struct MEventBuffer_32E0_Sub *data = &gSaveBlock1Ptr->unk_322C.buffer_1c0.data; + const struct WonderCard *data = &gSaveBlock1Ptr->unk_322C.wonderCard.data; if (data->unk_08_6 == 0) return FALSE; @@ -191,8 +191,8 @@ bool32 WonderCard_Test_Unk_08_6(void) static void sub_801B330(void) { - CpuFill32(0, &gSaveBlock1Ptr->unk_322C.buffer_1c0.data, sizeof(struct MEventBuffer_32E0_Sub)); - gSaveBlock1Ptr->unk_322C.buffer_1c0.crc = 0; + CpuFill32(0, &gSaveBlock1Ptr->unk_322C.wonderCard.data, sizeof(struct WonderCard)); + gSaveBlock1Ptr->unk_322C.wonderCard.crc = 0; } static void sub_801B368(void) @@ -204,12 +204,12 @@ static void sub_801B368(void) u16 GetWonderCardFlagID(void) { if (ValidateReceivedWonderCard()) - return gSaveBlock1Ptr->unk_322C.buffer_1c0.data.unk_00; + return gSaveBlock1Ptr->unk_322C.wonderCard.data.unk_00; return 0; } -void sub_801B3C0(struct MEventBuffer_32E0_Sub *buffer) +void WonderCard_ResetInternalReceivedFlag(struct WonderCard *buffer) { if (buffer->unk_08_6 == 1) buffer->unk_08_6 = 0; @@ -299,11 +299,11 @@ static bool32 sub_801B4A4(const u16 *data) static int sub_801B4CC(void) { - struct MEventBuffer_32E0_Sub *data; + struct WonderCard *data; if (!ValidateReceivedWonderCard()) return 0; - data = &gSaveBlock1Ptr->unk_322C.buffer_1c0.data; + data = &gSaveBlock1Ptr->unk_322C.wonderCard.data; if (data->unk_08_0 != 1) return 0; @@ -312,7 +312,7 @@ static int sub_801B4CC(void) bool32 sub_801B508(const u16 *data) { - struct MEventBuffer_32E0_Sub *buffer = &gSaveBlock1Ptr->unk_322C.buffer_1c0.data; + struct WonderCard *buffer = &gSaveBlock1Ptr->unk_322C.wonderCard.data; int size = buffer->unk_09; int i; if (!sub_801B4A4(data)) @@ -355,9 +355,9 @@ void sub_801B580(struct MEventStruct_Unk1442CC *data, bool32 a1) if (ValidateReceivedWonderCard()) { - data->unk_14 = sav1_get_mevent_buffer_1()->unk_00; + data->unk_14 = GetSavedWonderCard()->unk_00; data->unk_20 = *sav1_get_mevent_buffer_2(); - data->unk_44 = sav1_get_mevent_buffer_1()->unk_09; + data->unk_44 = GetSavedWonderCard()->unk_09; } else { @@ -422,7 +422,7 @@ u32 sub_801B708(const u16 *a0, const struct MEventStruct_Unk1442CC *a1, const vo return 2; } -bool32 sub_801B748(const struct MEventStruct_Unk1442CC *a0, const u16 *a1) +bool32 MEventStruct_Unk1442CC_CompareField_unk_16(const struct MEventStruct_Unk1442CC *a0, const u16 *a1) { int i; for (i = 0; i < 4; i++) @@ -439,7 +439,7 @@ static int sub_801B770(const struct MEventStruct_Unk1442CC *a0) return sub_801B438(&a0->unk_20, a0->unk_44); } -u16 sub_801B784(const struct MEventStruct_Unk1442CC *a0, u32 command) +u16 MEventStruct_Unk1442CC_GetValueNFrom_unk_20(const struct MEventStruct_Unk1442CC *a0, u32 command) { switch (command) { @@ -461,7 +461,7 @@ u16 sub_801B784(const struct MEventStruct_Unk1442CC *a0, u32 command) static void sub_801B7D8(u32 command) { - struct MEventBuffer_32E0_Sub *data = &gSaveBlock1Ptr->unk_322C.buffer_1c0.data; + struct WonderCard *data = &gSaveBlock1Ptr->unk_322C.wonderCard.data; if (data->unk_08_0 == 2) { u16 *dest = NULL; @@ -495,7 +495,7 @@ u16 mevent_081445C0(u32 command) { case 0: { - struct MEventBuffer_32E0_Sub *data = &gSaveBlock1Ptr->unk_322C.buffer_1c0.data; + struct WonderCard *data = &gSaveBlock1Ptr->unk_322C.wonderCard.data; if (data->unk_08_0 == 2) { struct MEventBuffer_3430_Sub *buffer = &gSaveBlock1Ptr->unk_322C.buffer_310.data; @@ -505,7 +505,7 @@ u16 mevent_081445C0(u32 command) } case 1: { - struct MEventBuffer_32E0_Sub *data = &gSaveBlock1Ptr->unk_322C.buffer_1c0.data; + struct WonderCard *data = &gSaveBlock1Ptr->unk_322C.wonderCard.data; if (data->unk_08_0 == 2) { struct MEventBuffer_3430_Sub *buffer = &gSaveBlock1Ptr->unk_322C.buffer_310.data; @@ -515,7 +515,7 @@ u16 mevent_081445C0(u32 command) } case 2: { - struct MEventBuffer_32E0_Sub *data = &gSaveBlock1Ptr->unk_322C.buffer_1c0.data; + struct WonderCard *data = &gSaveBlock1Ptr->unk_322C.wonderCard.data; if (data->unk_08_0 == 2) { struct MEventBuffer_3430_Sub *buffer = &gSaveBlock1Ptr->unk_322C.buffer_310.data; @@ -525,14 +525,14 @@ u16 mevent_081445C0(u32 command) } case 3: { - struct MEventBuffer_32E0_Sub *data = &gSaveBlock1Ptr->unk_322C.buffer_1c0.data; + struct WonderCard *data = &gSaveBlock1Ptr->unk_322C.wonderCard.data; if (data->unk_08_0 == 1) return sub_801B4CC(); break; } case 4: { - struct MEventBuffer_32E0_Sub *data = &gSaveBlock1Ptr->unk_322C.buffer_1c0.data; + struct WonderCard *data = &gSaveBlock1Ptr->unk_322C.wonderCard.data; if (data->unk_08_0 == 1) return data->unk_09; break; @@ -557,7 +557,7 @@ bool32 sub_801B94C(u16 a0) if (!ValidateReceivedWonderCard()) return FALSE; - if (gSaveBlock1Ptr->unk_322C.buffer_1c0.data.unk_00 != a0) + if (gSaveBlock1Ptr->unk_322C.wonderCard.data.unk_00 != a0) return FALSE; gUnknown_02022C70 = TRUE; diff --git a/src/mevent_801BAAC.c b/src/mevent_801BAAC.c index 24a999f69..62240af98 100644 --- a/src/mevent_801BAAC.c +++ b/src/mevent_801BAAC.c @@ -35,7 +35,7 @@ struct UnkStruct_203F3C8_02DC struct UnkStruct_203F3C8 { - /*0000*/ struct MEventBuffer_32E0_Sub unk_0000; + /*0000*/ struct WonderCard unk_0000; /*014c*/ struct MEventBuffer_3430_Sub unk_014C; /*0170*/ const struct UnkStruct_8467FB8 * unk_0170; /*0174*/ u8 unk_0174; @@ -150,7 +150,7 @@ const struct UnkStruct_8467FB8 gUnknown_082F1D60[8] = { {1, 0, 0, 7, gWonderCardBgGfx8, gWonderCardBgTilemap8, gWonderCardBgPal8} }; -bool32 InitWonderCardResources(struct MEventBuffer_32E0_Sub * r5, struct MEventBuffer_3430_Sub * r6) +bool32 InitWonderCardResources(struct WonderCard * r5, struct MEventBuffer_3430_Sub * r6) { if (r5 == NULL || r6 == NULL) return FALSE; @@ -465,7 +465,7 @@ void sub_801C61C(void) struct UnkStruct_203F3CC { - /*0000*/ struct MEventBuffer_3120_Sub unk_0000; + /*0000*/ struct WonderNews unk_0000; /*01bc*/ const struct UnkStruct_8467FB8 * unk_01BC; /*01c0*/ u8 unk_01C0_0:1; u8 unk_01C0_1:7; @@ -542,7 +542,7 @@ const struct UnkStruct_8467FB8 gUnknown_082F24C8[] = { {1, 0, 0, 0, gWonderNewsGfx8, gWonderNewsTilemap8, gWonderNewsPal8} }; -bool32 InitWonderNewsResources(const struct MEventBuffer_3120_Sub * a0) +bool32 InitWonderNewsResources(const struct WonderNews * a0) { if (a0 == NULL) return FALSE; diff --git a/src/mevent_server.c b/src/mevent_server.c index fe13943ff..06b10dd95 100644 --- a/src/mevent_server.c +++ b/src/mevent_server.c @@ -46,8 +46,8 @@ static void mevent_srv_init_common(struct mevent_srv_common * svr, const void * { svr->unk_00 = 0; svr->mainseqno = 0; - svr->mevent_32e0 = AllocZeroed(sizeof(struct MEventBuffer_32E0_Sub)); - svr->mevent_3120 = AllocZeroed(sizeof(struct MEventBuffer_3120_Sub)); + svr->wonder_card = AllocZeroed(sizeof(struct WonderCard)); + svr->wonder_news = AllocZeroed(sizeof(struct WonderNews)); svr->recvBuffer = AllocZeroed(ME_SEND_BUF_SIZE); svr->mevent_unk1442cc = AllocZeroed(sizeof(struct MEventStruct_Unk1442CC)); svr->cmdBuffer = cmdBuffer; @@ -57,8 +57,8 @@ static void mevent_srv_init_common(struct mevent_srv_common * svr, const void * static void mevent_srv_free_resources(struct mevent_srv_common * svr) { - Free(svr->mevent_32e0); - Free(svr->mevent_3120); + Free(svr->wonder_card); + Free(svr->wonder_news); Free(svr->recvBuffer); Free(svr->mevent_unk1442cc); } @@ -176,7 +176,7 @@ static u32 common_mainseq_4(struct mevent_srv_common * svr) case 7: // check_crc AGB_ASSERT(cmd->flag == FALSE); - ptr = mevent_first_if_not_null_else_second(cmd->parameter, svr->mevent_32e0); + ptr = mevent_first_if_not_null_else_second(cmd->parameter, svr->wonder_card); svr->param = sub_801B6EC(ptr, svr->mevent_unk1442cc, ptr); break; case 8: @@ -192,11 +192,11 @@ static u32 common_mainseq_4(struct mevent_srv_common * svr) break; case 10: AGB_ASSERT(cmd->parameter == NULL); - svr->param = sub_801B784(svr->mevent_unk1442cc, cmd->flag); + svr->param = MEventStruct_Unk1442CC_GetValueNFrom_unk_20(svr->mevent_unk1442cc, cmd->flag); break; case 11: AGB_ASSERT(cmd->flag == FALSE); - svr->param = sub_801B748(svr->mevent_unk1442cc, cmd->parameter); + svr->param = MEventStruct_Unk1442CC_CompareField_unk_16(svr->mevent_unk1442cc, cmd->parameter); break; case 12: AGB_ASSERT(cmd->flag == FALSE); @@ -204,11 +204,11 @@ static u32 common_mainseq_4(struct mevent_srv_common * svr) break; case 14: AGB_ASSERT(cmd->flag == FALSE); - mevent_srv_common_init_send(svr, 0x17, mevent_first_if_not_null_else_second(cmd->parameter, svr->mevent_3120), sizeof(struct MEventBuffer_3120_Sub)); + mevent_srv_common_init_send(svr, 0x17, mevent_first_if_not_null_else_second(cmd->parameter, svr->wonder_news), sizeof(struct WonderNews)); break; case 13: AGB_ASSERT(cmd->flag == FALSE); - mevent_srv_common_init_send(svr, 0x16, mevent_first_if_not_null_else_second(cmd->parameter, svr->mevent_32e0), sizeof(struct MEventBuffer_32E0_Sub)); + mevent_srv_common_init_send(svr, 0x16, mevent_first_if_not_null_else_second(cmd->parameter, svr->wonder_card), sizeof(struct WonderCard)); break; case 16: AGB_ASSERT(cmd->flag == FALSE); @@ -238,11 +238,11 @@ static u32 common_mainseq_4(struct mevent_srv_common * svr) break; case 22: AGB_ASSERT(cmd->flag == FALSE); - memcpy(svr->mevent_32e0, cmd->parameter, 332); + memcpy(svr->wonder_card, cmd->parameter, 332); break; case 23: AGB_ASSERT(cmd->flag == FALSE); - memcpy(svr->mevent_3120, cmd->parameter, 444); + memcpy(svr->wonder_news, cmd->parameter, 444); break; case 21: AGB_ASSERT(cmd->flag == FALSE); @@ -258,16 +258,16 @@ static u32 common_mainseq_4(struct mevent_srv_common * svr) break; case 26: AGB_ASSERT(cmd->flag == FALSE && cmd->parameter == NULL); - memcpy(svr->mevent_32e0, sav1_get_mevent_buffer_1(), 332); - sub_801B3C0(svr->mevent_32e0); + memcpy(svr->wonder_card, GetSavedWonderCard(), 332); + WonderCard_ResetInternalReceivedFlag(svr->wonder_card); break; case 27: AGB_ASSERT(cmd->flag == FALSE && cmd->parameter == NULL); - memcpy(svr->mevent_3120, sav1_get_mevent_buffer_0(), 444); + memcpy(svr->wonder_news, GetSavedWonderNews(), 444); break; case 28: AGB_ASSERT(cmd->flag == FALSE && cmd->parameter == NULL); - svr->sendBuffer1 = sub_8099244(); + svr->sendBuffer1 = GetSavedRamScriptIfValid(); break; case 29: mevent_srv_common_init_send(svr, 0x1b, cmd->parameter, cmd->flag); diff --git a/src/mevent_server_ish.c b/src/mevent_server_ish.c index 0303bfd9b..48f72eaad 100644 --- a/src/mevent_server_ish.c +++ b/src/mevent_server_ish.c @@ -216,7 +216,7 @@ static u32 ish_mainseq_4(struct mevent_srv_ish * svr) sub_801B508(svr->recvBuffer); break; case 17: - sub_80992A0(svr->recvBuffer, 1000); + InitRamScript_NoEventObject(svr->recvBuffer, 1000); break; case 18: memcpy(&gSaveBlock2Ptr->frontier.ereaderTrainer, svr->recvBuffer, 0xbc); diff --git a/src/mystery_gift.c b/src/mystery_gift.c index c8b3a9060..c935e9b25 100644 --- a/src/mystery_gift.c +++ b/src/mystery_gift.c @@ -815,11 +815,11 @@ static bool32 HandleLoadWonderCardOrNews(u8 * state, bool32 cardOrNews) case 0: if (cardOrNews == 0) { - InitWonderCardResources(sav1_get_mevent_buffer_1(), sav1_get_mevent_buffer_2()); + InitWonderCardResources(GetSavedWonderCard(), sav1_get_mevent_buffer_2()); } else { - InitWonderNewsResources(sav1_get_mevent_buffer_0()); + InitWonderNewsResources(GetSavedWonderNews()); } (*state)++; break; diff --git a/src/scrcmd.c b/src/scrcmd.c index 314504600..0b1006cef 100644 --- a/src/scrcmd.c +++ b/src/scrcmd.c @@ -2217,7 +2217,7 @@ bool8 ScrCmd_checkmonobedience(struct ScriptContext *ctx) bool8 ScrCmd_cmdCF(struct ScriptContext *ctx) { - const u8* v1 = sub_8099244(); + const u8* v1 = GetSavedRamScriptIfValid(); if (v1) { diff --git a/src/script.c b/src/script.c index cb06300bf..27476dba3 100644 --- a/src/script.c +++ b/src/script.c @@ -386,7 +386,7 @@ const u8 *GetRamScript(u8 objectId, const u8 *script) } } -bool32 sub_80991F8(void) +bool32 ValidateSavedRamScript(void) { struct RamScriptData *scriptData = &gSaveBlock1Ptr->ramScript.data; if (scriptData->magic != RAM_SCRIPT_MAGIC) @@ -402,7 +402,7 @@ bool32 sub_80991F8(void) return TRUE; } -u8 *sub_8099244(void) +u8 *GetSavedRamScriptIfValid(void) { struct RamScriptData *scriptData = &gSaveBlock1Ptr->ramScript.data; if (!ValidateReceivedWonderCard()) @@ -426,7 +426,7 @@ u8 *sub_8099244(void) } } -void sub_80992A0(u8 *script, u16 scriptSize) +void InitRamScript_NoEventObject(u8 *script, u16 scriptSize) { if (scriptSize > sizeof(gSaveBlock1Ptr->ramScript.data.script)) scriptSize = sizeof(gSaveBlock1Ptr->ramScript.data.script);