mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2024-12-25 11:14:15 +01:00
Port mevent2.c from pokefirered
This commit is contained in:
parent
e8edddf33c
commit
e6caf0ff10
1425
asm/mevent2.s
1425
asm/mevent2.s
File diff suppressed because it is too large
Load Diff
@ -9,7 +9,7 @@
|
||||
sub_801DB68: @ 801DB68
|
||||
push {r4,r5,lr}
|
||||
adds r4, r0, 0
|
||||
bl GetSaveBlock1Field356C
|
||||
bl sub_801B044
|
||||
adds r5, r0, 0
|
||||
movs r0, 0x3
|
||||
adds r1, r4, 0
|
||||
@ -55,7 +55,7 @@ _0801DBB8:
|
||||
thumb_func_start sub_801DBC0
|
||||
sub_801DBC0: @ 801DBC0
|
||||
push {lr}
|
||||
bl GetSaveBlock1Field356C
|
||||
bl sub_801B044
|
||||
movs r1, 0
|
||||
strb r1, [r0]
|
||||
strb r1, [r0, 0x1]
|
||||
@ -72,7 +72,7 @@ sub_801DBDC: @ 801DBDC
|
||||
ldr r0, =0x0000402e
|
||||
bl GetVarPointer
|
||||
adds r4, r0, 0
|
||||
bl GetSaveBlock1Field356C
|
||||
bl sub_801B044
|
||||
adds r2, r0, 0
|
||||
ldr r0, [r2]
|
||||
lsls r0, 24
|
||||
@ -103,7 +103,7 @@ _0801DC10:
|
||||
sub_801DC20: @ 801DC20
|
||||
push {r4-r6,lr}
|
||||
ldr r6, =gSpecialVar_Result
|
||||
bl GetSaveBlock1Field356C
|
||||
bl sub_801B044
|
||||
adds r4, r0, 0
|
||||
bl IsMysteryEventEnabled
|
||||
cmp r0, 0
|
||||
|
@ -3,12 +3,6 @@
|
||||
|
||||
.section .rodata
|
||||
|
||||
.align 2
|
||||
gUnknown_082F0DE8:: @ 82F0DE8
|
||||
.2byte 0x013a, 0x013b, 0x013c, 0x013d, 0x013e, 0x013f, 0x0140, 0x0141
|
||||
.2byte 0x0142, 0x0143, 0x0144, 0x0145, 0x0146, 0x0147, 0x0148, 0x0149
|
||||
.2byte 0x014a, 0x014b, 0x014c, 0x014d
|
||||
|
||||
.align 2
|
||||
gUnknown_082F0E10:: @ 82F0E10
|
||||
.byte 0x00, 0x02, 0x03
|
@ -336,24 +336,23 @@
|
||||
#define FLAG_RECEIVED_AURORA_TICKET 0x13A // RECEIVED Aurora Ticket in Mystery Gift
|
||||
#define FLAG_RECEIVED_MYSTIC_TICKET 0x13B // RECEIVED Mystic Ticket in Mystery Gift
|
||||
#define FLAG_RECEIVED_OLD_SEA_MAP 0x13C // RECEIVED Old Sea Map in Mystery Gift
|
||||
|
||||
#define FLAG_UNUSED_0x13D 0x13D // Unused Flag
|
||||
#define FLAG_UNUSED_0x13E 0x13E // Unused Flag
|
||||
#define FLAG_UNUSED_0x13F 0x13F // Unused Flag
|
||||
#define FLAG_UNUSED_0x140 0x140 // Unused Flag
|
||||
#define FLAG_UNUSED_0x141 0x141 // Unused Flag
|
||||
#define FLAG_UNUSED_0x142 0x142 // Unused Flag
|
||||
#define FLAG_UNUSED_0x143 0x143 // Unused Flag
|
||||
#define FLAG_UNUSED_0x144 0x144 // Unused Flag
|
||||
#define FLAG_UNUSED_0x145 0x145 // Unused Flag
|
||||
#define FLAG_UNUSED_0x146 0x146 // Unused Flag
|
||||
#define FLAG_UNUSED_0x147 0x147 // Unused Flag
|
||||
#define FLAG_UNUSED_0x148 0x148 // Unused Flag
|
||||
#define FLAG_UNUSED_0x149 0x149 // Unused Flag
|
||||
#define FLAG_UNUSED_0x14A 0x14A // Unused Flag
|
||||
#define FLAG_UNUSED_0x14B 0x14B // Unused Flag
|
||||
#define FLAG_UNUSED_0x14C 0x14C // Unused Flag
|
||||
#define FLAG_UNUSED_0x14D 0x14D // Unused Flag
|
||||
#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_MIRAGE_TOWER_VISIBLE 0x14E
|
||||
#define FLAG_CHOSE_CLAW_FOSSIL 0x14F // Player chose Claw Fossil
|
||||
|
@ -808,6 +808,76 @@ struct SaveTrainerHill
|
||||
/*0x3D6E*/ u16 tag:2; // x40, x80 = xC0
|
||||
};
|
||||
|
||||
struct MysteryEventStruct
|
||||
{
|
||||
u8 unk_0_0:2;
|
||||
u8 unk_0_2:3;
|
||||
u8 unk_0_5:3;
|
||||
u8 unk_1;
|
||||
};
|
||||
|
||||
struct MEventBuffer_3120_Sub
|
||||
{
|
||||
u16 unk_00;
|
||||
u8 unk_02;
|
||||
u8 unk_03;
|
||||
u8 unk_04[40];
|
||||
u8 unk_2C[10][40];
|
||||
};
|
||||
|
||||
struct MEventBuffer_3120
|
||||
{
|
||||
u32 crc;
|
||||
struct MEventBuffer_3120_Sub data;
|
||||
};
|
||||
|
||||
struct MEventBuffer_32E0_Sub
|
||||
{
|
||||
u16 unk_00;
|
||||
u16 unk_02;
|
||||
u32 unk_04;
|
||||
u8 unk_08_0:2;
|
||||
u8 unk_08_2:4;
|
||||
u8 unk_08_6:2;
|
||||
u8 unk_09;
|
||||
u8 unk_0A[40];
|
||||
u8 unk_32[40];
|
||||
u8 unk_5A[4][40];
|
||||
u8 unk_FA[40];
|
||||
u8 unk_122[40];
|
||||
};
|
||||
|
||||
struct MEventBuffer_32E0
|
||||
{
|
||||
u32 crc;
|
||||
struct MEventBuffer_32E0_Sub data;
|
||||
};
|
||||
|
||||
struct MEventBuffer_3430_Sub
|
||||
{
|
||||
u16 unk_00;
|
||||
u16 unk_02;
|
||||
u16 unk_04;
|
||||
u16 unk_06;
|
||||
u16 unk_08[2][7];
|
||||
};
|
||||
|
||||
struct MEventBuffer_3430
|
||||
{
|
||||
u32 crc;
|
||||
struct MEventBuffer_3430_Sub data;
|
||||
};
|
||||
|
||||
struct MEventBuffers
|
||||
{
|
||||
/*0x000 0x322C*/ struct MEventBuffer_3120 buffer_000;
|
||||
/*0x1c0 0x33EC*/ struct MEventBuffer_32E0 buffer_1c0;
|
||||
/*0x310 0x353C*/ struct MEventBuffer_3430 buffer_310;
|
||||
/*0x338 0x3564*/ u16 unk_338[4];
|
||||
/*0x340 0x356C*/ struct MysteryEventStruct unk_340;
|
||||
/*0x344 0x3570*/ u32 unk_344[2][5];
|
||||
}; // 0x36C 0x3598
|
||||
|
||||
struct SaveBlock1
|
||||
{
|
||||
/*0x00*/ struct Coords16 pos;
|
||||
@ -884,14 +954,15 @@ struct SaveBlock1
|
||||
/*0x31A8*/ u8 giftRibbons[52];
|
||||
/*0x31DC*/ struct Roamer roamer;
|
||||
/*0x31F8*/ struct EnigmaBerry enigmaBerry;
|
||||
/*0x322C*/ u8 field_322C[1260];
|
||||
/*0x322C*/ struct MEventBuffers unk_322C;
|
||||
/*0x3598*/ u8 field_3598[0x180];
|
||||
/*0x3718*/ u32 trainerHillTimes[4];
|
||||
/*0x3728*/ struct RamScript ramScript;
|
||||
/*0x3B14*/ struct RecordMixingGift recordMixingGift;
|
||||
/*0x3B24*/ u8 seen2[DEX_FLAGS_NO];
|
||||
/*0x3B58*/ LilycoveLady lilycoveLady;
|
||||
/*0x3B98*/ struct TrainerNameRecord trainerNameRecords[20];
|
||||
/*0x3C88*/ u8 filler_3C88[0xDC];
|
||||
/*0x3C88*/ u8 unk3C88[11][20];
|
||||
/*0x3D64*/ struct SaveTrainerHill trainerHill;
|
||||
/*0x3D70*/ struct WaldaPhrase waldaPhrase;
|
||||
// sizeof: 0x3D88
|
||||
|
@ -306,7 +306,7 @@ void sub_8009FAC(void);
|
||||
bool8 sub_800A4D8(u8 a0);
|
||||
u8 sub_800A9D8(void);
|
||||
u8 sub_800A0C8(s32, s32);
|
||||
u16 *GetSaveBlock1Field3564(void);
|
||||
u16 *sub_801B058(void);
|
||||
u8 sub_800A9A8(void);
|
||||
void sub_800AD10(void);
|
||||
void sub_800AB18(void);
|
||||
|
@ -42,6 +42,8 @@ struct Main
|
||||
|
||||
extern const u8 gGameVersion;
|
||||
extern const u8 gGameLanguage;
|
||||
extern const u8 RomHeaderGameCode[4];
|
||||
extern const u8 RomHeaderSoftwareVersion;
|
||||
|
||||
extern u16 gKeyRepeatStartDelay;
|
||||
extern bool8 gLinkTransferringData;
|
||||
|
36
include/mevent.h
Executable file
36
include/mevent.h
Executable file
@ -0,0 +1,36 @@
|
||||
#ifndef GUARD_MEVENT_H
|
||||
#define GUARD_MEVENT_H
|
||||
|
||||
#include <gba/gba.h>
|
||||
|
||||
struct MEvent_Str_1
|
||||
{
|
||||
u16 unk_000;
|
||||
size_t unk_004;
|
||||
const void * unk_008;
|
||||
};
|
||||
|
||||
struct MEvent_Str_2
|
||||
{
|
||||
u8 fill_00[0x40];
|
||||
};
|
||||
|
||||
struct MEventStruct_Unk1442CC
|
||||
{
|
||||
u32 unk_00;
|
||||
u16 unk_04;
|
||||
u32 unk_08;
|
||||
u16 unk_0C;
|
||||
u32 unk_10;
|
||||
u16 unk_14;
|
||||
u16 unk_16[4];
|
||||
struct MEventBuffer_3430_Sub unk_20;
|
||||
u8 unk_44;
|
||||
u8 unk_45[7];
|
||||
u8 unk_4C[4];
|
||||
u16 unk_50[6];
|
||||
u8 unk_5C[4];
|
||||
u8 unk_60;
|
||||
};
|
||||
|
||||
#endif //GUARD_MEVENT_H
|
6
include/mevent_news.h
Executable file
6
include/mevent_news.h
Executable file
@ -0,0 +1,6 @@
|
||||
#ifndef GUARD_MEVENT_NEWS_H
|
||||
#define GUARD_MEVENT_NEWS_H
|
||||
|
||||
void sub_801DBC0(void);
|
||||
|
||||
#endif //GUARD_MEVENT_NEWS_H
|
@ -56,7 +56,7 @@ SECTIONS {
|
||||
src/link_rfu.o(.text);
|
||||
src/union_room.o(.text);
|
||||
asm/union_room.o(.text);
|
||||
asm/mevent2.o(.text);
|
||||
src/mevent2.o(.text);
|
||||
asm/mevent_801BAAC.o(.text);
|
||||
asm/mevent_server.o(.text);
|
||||
asm/mevent_server_ish.o(.text);
|
||||
@ -409,7 +409,8 @@ SECTIONS {
|
||||
src/link_rfu.o(.rodata);
|
||||
src/union_room.o(.rodata);
|
||||
data/union_room.o(.rodata);
|
||||
data/mevent2.o(.rodata);
|
||||
src/mevent2.o(.rodata);
|
||||
data/mevent_801BAAC.o(.rodata);
|
||||
data/mevent_server.o(.rodata);
|
||||
data/union_room_chat.o(.rodata);
|
||||
data/berry_crush.o(.rodata);
|
||||
|
@ -1318,7 +1318,7 @@ void ShowEasyChatScreen(void)
|
||||
words = gSaveBlock2Ptr->apprentices[0].easyChatWords;
|
||||
break;
|
||||
case EASY_CHAT_TYPE_QUESTIONNAIRE:
|
||||
words = GetSaveBlock1Field3564();
|
||||
words = sub_801B058();
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
@ -5531,7 +5531,7 @@ void InitializeEasyChatWordArray(u16 *words, u16 length)
|
||||
void sub_811F8BC(void)
|
||||
{
|
||||
int i;
|
||||
u16 *words = GetSaveBlock1Field3564();
|
||||
u16 *words = sub_801B058();
|
||||
for (i = 0; i < 4; i++)
|
||||
words[i] = 0xFFFF;
|
||||
}
|
||||
|
626
src/mevent2.c
Executable file
626
src/mevent2.c
Executable file
@ -0,0 +1,626 @@
|
||||
#include "global.h"
|
||||
#include "util.h"
|
||||
#include "main.h"
|
||||
#include "event_data.h"
|
||||
#include "easy_chat.h"
|
||||
#include "script.h"
|
||||
#include "battle_tower.h"
|
||||
#include "mevent_news.h"
|
||||
#include "string_util.h"
|
||||
#include "new_game.h"
|
||||
#include "mevent.h"
|
||||
#include "constants/species.h"
|
||||
|
||||
static EWRAM_DATA bool32 gUnknown_02022C70 = FALSE;
|
||||
|
||||
void sub_801B180(void);
|
||||
void sub_801B14C(void);
|
||||
bool32 sub_801B114(const struct MEventBuffer_3120_Sub * data);
|
||||
bool32 sub_801B2CC(const struct MEventBuffer_32E0_Sub * data);
|
||||
void sub_801B330(void);
|
||||
void sub_801B368(void);
|
||||
void sub_801B9F8(void);
|
||||
void sub_801BA8C(u32 a0, u32 a1, u32 * a2, int a3);
|
||||
|
||||
void sub_801AFD8(void)
|
||||
{
|
||||
CpuFill32(0, &gSaveBlock1Ptr->unk_322C, sizeof(gSaveBlock1Ptr->unk_322C));
|
||||
sub_801B180();
|
||||
sub_811F8BC();
|
||||
}
|
||||
|
||||
struct MEventBuffer_3120_Sub * sub_801B00C(void)
|
||||
{
|
||||
return &gSaveBlock1Ptr->unk_322C.buffer_000.data;
|
||||
}
|
||||
|
||||
struct MEventBuffer_32E0_Sub * sav1_get_mevent_buffer_1(void)
|
||||
{
|
||||
return &gSaveBlock1Ptr->unk_322C.buffer_1c0.data;
|
||||
}
|
||||
|
||||
struct MEventBuffer_3430_Sub * sav1_get_mevent_buffer_2(void)
|
||||
{
|
||||
return &gSaveBlock1Ptr->unk_322C.buffer_310.data;
|
||||
}
|
||||
|
||||
struct MysteryEventStruct * sub_801B044(void)
|
||||
{
|
||||
return &gSaveBlock1Ptr->unk_322C.unk_340;
|
||||
}
|
||||
|
||||
u16 * sub_801B058(void)
|
||||
{
|
||||
return gSaveBlock1Ptr->unk_322C.unk_338;
|
||||
}
|
||||
|
||||
void sub_801B06C(void)
|
||||
{
|
||||
sub_801B14C();
|
||||
}
|
||||
|
||||
bool32 sub_801B078(const struct MEventBuffer_3120_Sub * src)
|
||||
{
|
||||
if (!sub_801B114(src))
|
||||
return FALSE;
|
||||
|
||||
sub_801B14C();
|
||||
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));
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool32 sub_801B0CC(void)
|
||||
{
|
||||
if (CalcCRC16WithTable((void *)&gSaveBlock1Ptr->unk_322C.buffer_000.data, sizeof(struct MEventBuffer_3120_Sub)) != gSaveBlock1Ptr->unk_322C.buffer_000.crc)
|
||||
return FALSE;
|
||||
if (!sub_801B114(&gSaveBlock1Ptr->unk_322C.buffer_000.data))
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool32 sub_801B114(const struct MEventBuffer_3120_Sub * data)
|
||||
{
|
||||
if (data->unk_00 == 0)
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool32 sub_801B128(void)
|
||||
{
|
||||
const struct MEventBuffer_3120_Sub * data = &gSaveBlock1Ptr->unk_322C.buffer_000.data;
|
||||
if (data->unk_02 == 0)
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void sub_801B14C(void)
|
||||
{
|
||||
CpuFill32(0, sub_801B00C(), sizeof(gSaveBlock1Ptr->unk_322C.buffer_000.data));
|
||||
gSaveBlock1Ptr->unk_322C.buffer_000.crc = 0;
|
||||
}
|
||||
|
||||
void sub_801B180(void)
|
||||
{
|
||||
CpuFill32(0, sub_801B044(), sizeof(struct MysteryEventStruct));
|
||||
sub_801DBC0();
|
||||
}
|
||||
|
||||
bool32 sub_801B1A4(const u8 * src)
|
||||
{
|
||||
const u8 * r5 = (const u8 *)&gSaveBlock1Ptr->unk_322C.buffer_000.data;
|
||||
u32 i;
|
||||
if (!sub_801B0CC())
|
||||
return FALSE;
|
||||
|
||||
for (i = 0; i < sizeof(struct MEventBuffer_3120_Sub); i++)
|
||||
{
|
||||
if (r5[i] != src[i])
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void sub_801B1E8(void)
|
||||
{
|
||||
sub_801B330();
|
||||
sub_801B368();
|
||||
sub_801B9F8();
|
||||
ClearRamScript();
|
||||
sub_809D4D8();
|
||||
sub_809D570();
|
||||
ClearEReaderTrainer(&gSaveBlock2Ptr->frontier.ereaderTrainer);
|
||||
}
|
||||
|
||||
bool32 sub_801B21C(const struct MEventBuffer_32E0_Sub * data)
|
||||
{
|
||||
struct MEventBuffer_3430_Sub * r2;
|
||||
struct MEventBuffer_32E0_Sub * r1;
|
||||
if (!sub_801B2CC(data))
|
||||
return FALSE;
|
||||
|
||||
sub_801B1E8();
|
||||
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));
|
||||
r2 = &gSaveBlock1Ptr->unk_322C.buffer_310.data;
|
||||
r1 = &gSaveBlock1Ptr->unk_322C.buffer_1c0.data;
|
||||
r2->unk_06 = r1->unk_02;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool32 sub_801B27C(void)
|
||||
{
|
||||
if (gSaveBlock1Ptr->unk_322C.buffer_1c0.crc != CalcCRC16WithTable((void *)&gSaveBlock1Ptr->unk_322C.buffer_1c0.data, sizeof(struct MEventBuffer_32E0_Sub)))
|
||||
return FALSE;
|
||||
if (!sub_801B2CC(&gSaveBlock1Ptr->unk_322C.buffer_1c0.data))
|
||||
return FALSE;
|
||||
if (!sub_80991F8())
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool32 sub_801B2CC(const struct MEventBuffer_32E0_Sub * data)
|
||||
{
|
||||
if (data->unk_00 == 0)
|
||||
return FALSE;
|
||||
if (data->unk_08_0 > 2)
|
||||
return FALSE;
|
||||
if (!(data->unk_08_6 == 0 || data->unk_08_6 == 1 || data->unk_08_6 == 2))
|
||||
return FALSE;
|
||||
if (data->unk_08_2 > 7)
|
||||
return FALSE;
|
||||
if (data->unk_09 > 7)
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool32 sub_801B308(void)
|
||||
{
|
||||
const struct MEventBuffer_32E0_Sub * data = &gSaveBlock1Ptr->unk_322C.buffer_1c0.data;
|
||||
if (data->unk_08_6 == 0)
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void sub_801B330(void)
|
||||
{
|
||||
CpuFill32(0, &gSaveBlock1Ptr->unk_322C.buffer_1c0.data, sizeof(struct MEventBuffer_32E0_Sub));
|
||||
gSaveBlock1Ptr->unk_322C.buffer_1c0.crc = 0;
|
||||
}
|
||||
|
||||
void sub_801B368(void)
|
||||
{
|
||||
CpuFill32(0, sav1_get_mevent_buffer_2(), 18 * sizeof(u16));
|
||||
gSaveBlock1Ptr->unk_322C.buffer_310.crc = 0;
|
||||
}
|
||||
|
||||
u16 sub_801B39C(void)
|
||||
{
|
||||
if (sub_801B27C())
|
||||
return gSaveBlock1Ptr->unk_322C.buffer_1c0.data.unk_00;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void sub_801B3C0(struct MEventBuffer_32E0_Sub * buffer)
|
||||
{
|
||||
if (buffer->unk_08_6 == 1)
|
||||
buffer->unk_08_6 = 0;
|
||||
}
|
||||
|
||||
bool32 sub_801B3D8(u16 a0)
|
||||
{
|
||||
if (a0 >= 1000 && a0 < 1020)
|
||||
return TRUE;
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
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,
|
||||
};
|
||||
|
||||
bool32 sub_801B3F8(void)
|
||||
{
|
||||
u16 value = sub_801B39C();
|
||||
if (!sub_801B3D8(value))
|
||||
return FALSE;
|
||||
|
||||
if (FlagGet(sMysteryGiftFlags[value - 1000]) == TRUE)
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
int sub_801B438(const struct MEventBuffer_3430_Sub * data, int size)
|
||||
{
|
||||
int r3 = 0;
|
||||
int i;
|
||||
for (i = 0; i < size; i++)
|
||||
{
|
||||
if (data->unk_08[1][i] && data->unk_08[0][i])
|
||||
r3++;
|
||||
}
|
||||
|
||||
return r3;
|
||||
}
|
||||
|
||||
bool32 sub_801B460(const struct MEventBuffer_3430_Sub * data1, const u16 * data2, int size)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < size; i++)
|
||||
{
|
||||
if (data1->unk_08[1][i] == data2[1])
|
||||
return TRUE;
|
||||
if (data1->unk_08[0][i] == data2[0])
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool32 sub_801B4A4(const u16 * data)
|
||||
{
|
||||
if (data[1] == 0)
|
||||
return FALSE;
|
||||
if (data[0] == 0)
|
||||
return FALSE;
|
||||
if (data[0] >= NUM_SPECIES)
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
int sub_801B4CC(void)
|
||||
{
|
||||
struct MEventBuffer_32E0_Sub * data;
|
||||
if (!sub_801B27C())
|
||||
return 0;
|
||||
|
||||
data = &gSaveBlock1Ptr->unk_322C.buffer_1c0.data;
|
||||
if (data->unk_08_0 != 1)
|
||||
return 0;
|
||||
|
||||
return sub_801B438(&gSaveBlock1Ptr->unk_322C.buffer_310.data, data->unk_09);
|
||||
}
|
||||
|
||||
bool32 sub_801B508(const u16 * data)
|
||||
{
|
||||
struct MEventBuffer_32E0_Sub * buffer = &gSaveBlock1Ptr->unk_322C.buffer_1c0.data;
|
||||
int size = buffer->unk_09;
|
||||
int i;
|
||||
if (!sub_801B4A4(data))
|
||||
return FALSE;
|
||||
|
||||
if (sub_801B460(&gSaveBlock1Ptr->unk_322C.buffer_310.data, 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)
|
||||
{
|
||||
gSaveBlock1Ptr->unk_322C.buffer_310.data.unk_08[1][i] = data[1];
|
||||
gSaveBlock1Ptr->unk_322C.buffer_310.data.unk_08[0][i] = data[0];
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void sub_801B580(struct MEventStruct_Unk1442CC * data, bool32 a1)
|
||||
{
|
||||
int i;
|
||||
CpuFill32(0, data, sizeof(struct MEventStruct_Unk1442CC));
|
||||
data->unk_00 = 0x101;
|
||||
data->unk_04 = 1;
|
||||
data->unk_08 = 1;
|
||||
|
||||
if (a1)
|
||||
{
|
||||
data->unk_0C = 5;
|
||||
data->unk_10 = 0x0201;
|
||||
}
|
||||
else
|
||||
{
|
||||
data->unk_0C = 4;
|
||||
data->unk_10 = 0x0200;
|
||||
}
|
||||
|
||||
if (sub_801B27C())
|
||||
{
|
||||
data->unk_14 = sav1_get_mevent_buffer_1()->unk_00;
|
||||
data->unk_20 = *sav1_get_mevent_buffer_2();
|
||||
data->unk_44 = sav1_get_mevent_buffer_1()->unk_09;
|
||||
}
|
||||
else
|
||||
{
|
||||
data->unk_14 = 0;
|
||||
}
|
||||
|
||||
for (i = 0; i < 4; i++)
|
||||
data->unk_16[i] = gSaveBlock1Ptr->unk_322C.unk_338[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];
|
||||
|
||||
memcpy(data->unk_5C, RomHeaderGameCode, 4);
|
||||
data->unk_60 = RomHeaderSoftwareVersion;
|
||||
}
|
||||
|
||||
bool32 sub_801B6A0(const struct MEventStruct_Unk1442CC * data, bool32 a1)
|
||||
{
|
||||
if (data->unk_00 != 0x101)
|
||||
return FALSE;
|
||||
|
||||
if (!(data->unk_04 & 1))
|
||||
return FALSE;
|
||||
|
||||
if (!(data->unk_08 & 1))
|
||||
return FALSE;
|
||||
|
||||
if (!a1)
|
||||
{
|
||||
if (!(data->unk_0C & 4))
|
||||
return FALSE;
|
||||
|
||||
if (!(data->unk_10 & 0x380))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
u32 sub_801B6EC(const u16 * a0, const struct MEventStruct_Unk1442CC * a1, void * unused)
|
||||
{
|
||||
if (a1->unk_14 == 0)
|
||||
return 0;
|
||||
|
||||
if (*a0 == a1->unk_14)
|
||||
return 1;
|
||||
|
||||
return 2;
|
||||
}
|
||||
|
||||
u32 sub_801B708(const u16 * a0, const struct MEventStruct_Unk1442CC * a1, void * unused)
|
||||
{
|
||||
int r4 = a1->unk_44 - sub_801B438(&a1->unk_20, a1->unk_44);
|
||||
if (r4 == 0)
|
||||
return 1;
|
||||
if (sub_801B460(&a1->unk_20, a0, a1->unk_44))
|
||||
return 3;
|
||||
if (r4 == 1)
|
||||
return 4;
|
||||
return 2;
|
||||
}
|
||||
|
||||
bool32 sub_801B748(const struct MEventStruct_Unk1442CC * a0, const u16 * a1)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
if (a0->unk_16[i] != a1[i])
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
switch (command)
|
||||
{
|
||||
case 0:
|
||||
return a0->unk_20.unk_00;
|
||||
case 1:
|
||||
return a0->unk_20.unk_02;
|
||||
case 2:
|
||||
return a0->unk_20.unk_04;
|
||||
case 3:
|
||||
return sub_801B770(a0);
|
||||
case 4:
|
||||
return a0->unk_44;
|
||||
default:
|
||||
AGB_ASSERT(0);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
void sub_801B7D8(u32 command)
|
||||
{
|
||||
struct MEventBuffer_32E0_Sub * data = &gSaveBlock1Ptr->unk_322C.buffer_1c0.data;
|
||||
if (data->unk_08_0 == 2)
|
||||
{
|
||||
u16 * dest = NULL;
|
||||
switch (command)
|
||||
{
|
||||
case 0:
|
||||
dest = &gSaveBlock1Ptr->unk_322C.buffer_310.data.unk_00;
|
||||
break;
|
||||
case 1:
|
||||
dest = &gSaveBlock1Ptr->unk_322C.buffer_310.data.unk_02;
|
||||
break;
|
||||
case 2:
|
||||
dest = &gSaveBlock1Ptr->unk_322C.buffer_310.data.unk_04;
|
||||
break;
|
||||
case 3:
|
||||
break;
|
||||
case 4:
|
||||
break;
|
||||
}
|
||||
|
||||
if (dest == NULL)
|
||||
AGB_ASSERT(0);
|
||||
else if (++(*dest) > 999)
|
||||
*dest = 999;
|
||||
}
|
||||
}
|
||||
|
||||
u16 mevent_081445C0(u32 command)
|
||||
{
|
||||
switch (command)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
struct MEventBuffer_32E0_Sub *data = &gSaveBlock1Ptr->unk_322C.buffer_1c0.data;
|
||||
if (data->unk_08_0 == 2)
|
||||
{
|
||||
struct MEventBuffer_3430_Sub * buffer = &gSaveBlock1Ptr->unk_322C.buffer_310.data;
|
||||
return buffer->unk_00;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
struct MEventBuffer_32E0_Sub *data = &gSaveBlock1Ptr->unk_322C.buffer_1c0.data;
|
||||
if (data->unk_08_0 == 2)
|
||||
{
|
||||
struct MEventBuffer_3430_Sub * buffer = &gSaveBlock1Ptr->unk_322C.buffer_310.data;
|
||||
return buffer->unk_02;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
struct MEventBuffer_32E0_Sub *data = &gSaveBlock1Ptr->unk_322C.buffer_1c0.data;
|
||||
if (data->unk_08_0 == 2)
|
||||
{
|
||||
struct MEventBuffer_3430_Sub * buffer = &gSaveBlock1Ptr->unk_322C.buffer_310.data;
|
||||
return buffer->unk_04;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 3:
|
||||
{
|
||||
struct MEventBuffer_32E0_Sub *data = &gSaveBlock1Ptr->unk_322C.buffer_1c0.data;
|
||||
if (data->unk_08_0 == 1)
|
||||
return sub_801B4CC();
|
||||
break;
|
||||
}
|
||||
case 4:
|
||||
{
|
||||
struct MEventBuffer_32E0_Sub *data = &gSaveBlock1Ptr->unk_322C.buffer_1c0.data;
|
||||
if (data->unk_08_0 == 1)
|
||||
return data->unk_09;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
AGB_ASSERT(0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void sub_801B940(void)
|
||||
{
|
||||
gUnknown_02022C70 = FALSE;
|
||||
}
|
||||
|
||||
bool32 sub_801B94C(u16 a0)
|
||||
{
|
||||
gUnknown_02022C70 = FALSE;
|
||||
if (a0 == 0)
|
||||
return FALSE;
|
||||
|
||||
if (!sub_801B27C())
|
||||
return FALSE;
|
||||
|
||||
if (gSaveBlock1Ptr->unk_322C.buffer_1c0.data.unk_00 != a0)
|
||||
return FALSE;
|
||||
|
||||
gUnknown_02022C70 = TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void sub_801B990(u32 a0, u32 a1)
|
||||
{
|
||||
if (gUnknown_02022C70)
|
||||
{
|
||||
switch (a0)
|
||||
{
|
||||
case 2:
|
||||
sub_801BA8C(2, a1, gSaveBlock1Ptr->unk_322C.unk_344[1], 5);
|
||||
break;
|
||||
case 0:
|
||||
sub_801BA8C(0, a1, gSaveBlock1Ptr->unk_322C.unk_344[0], 5);
|
||||
break;
|
||||
case 1:
|
||||
sub_801BA8C(1, a1, gSaveBlock1Ptr->unk_322C.unk_344[0], 5);
|
||||
break;
|
||||
default:
|
||||
AGB_ASSERT(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void sub_801B9F8(void)
|
||||
{
|
||||
CpuFill32(0, gSaveBlock1Ptr->unk_322C.unk_344, sizeof(gSaveBlock1Ptr->unk_322C.unk_344));
|
||||
}
|
||||
|
||||
bool32 sub_801BA24(u32 a0, u32 * a1, int size)
|
||||
{
|
||||
int i;
|
||||
int j;
|
||||
|
||||
for (i = 0; i < size; i++)
|
||||
{
|
||||
if (a1[i] == a0)
|
||||
break;
|
||||
}
|
||||
|
||||
if (i == size)
|
||||
{
|
||||
for (j = size - 1; j > 0; j--)
|
||||
a1[j] = a1[j - 1];
|
||||
|
||||
a1[0] = a0;
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (j = i; j > 0; j--)
|
||||
a1[j] = a1[j - 1];
|
||||
|
||||
a1[0] = a0;
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
void sub_801BA8C(u32 a0, u32 a1, u32 * a2, int a3)
|
||||
{
|
||||
if (sub_801BA24(a1, a2, a3))
|
||||
sub_801B7D8(a0);
|
||||
}
|
@ -46,8 +46,7 @@ gUnknown_02022C68: @ 2022C68
|
||||
gUnknown_02022C6C: @ 2022C6C
|
||||
.space 0x4
|
||||
|
||||
gUnknown_02022C70: @ 2022C70
|
||||
.space 0x4
|
||||
.include "src/mevent2.o"
|
||||
|
||||
gUnknown_02022C74: @ 2022C74
|
||||
.space 0x4
|
||||
|
Loading…
Reference in New Issue
Block a user