Attempt to give meaningful names to mevent srv fields

This commit is contained in:
PikalaxALT 2018-12-01 20:27:35 -05:00
parent 8473bf1bcd
commit 2fbe528d5e
8 changed files with 352 additions and 203 deletions

View File

@ -1657,7 +1657,7 @@ _081430B8:
bl sub_81424B8
movs r0, 0x7
strb r0, [r5, 0x8]
bl sub_8144AEC
bl mevent_srv_ish_do_init
b _081435C6
.align 2, 0
_081430D0: .4byte gUnknown_3003F64
@ -1683,7 +1683,7 @@ _081430EC:
_081430F8: .4byte gUnknown_841E794
_081430FC:
adds r0, r5, 0
bl sub_8144B0C
bl mevent_srv_ish_do_exec
subs r0, 0x2
cmp r0, 0x4
bls _0814310A
@ -1712,12 +1712,12 @@ _0814312C:
b _081435C6
_0814313A:
ldr r4, [r5, 0x10]
bl sub_8144B58
bl mevent_srv_ish_get_buffer
adds r1, r0, 0
adds r0, r4, 0
movs r2, 0x40
bl memcpy
bl sub_8144B48
bl mevent_srv_ish_inc_flag
b _081435C6
_08143150:
movs r0, 0xA
@ -1740,7 +1740,7 @@ _08143170: .4byte gLinkPlayers + 8
_08143174:
adds r4, r5, 0
adds r4, 0x9
bl sub_8144B58
bl mevent_srv_ish_get_buffer
adds r3, r0, 0
adds r0, r4, 0
adds r1, r5, 0
@ -1757,7 +1757,7 @@ _08143174:
_08143198:
adds r4, r5, 0
adds r4, 0x9
bl sub_8144B58
bl mevent_srv_ish_get_buffer
adds r1, r0, 0
adds r0, r4, 0
bl mevent_0814257C
@ -1817,9 +1817,9 @@ _08143208:
_0814320C:
movs r0, 0x1
_0814320E:
bl sub_8144B64
bl mevent_srv_ish_set_param
_08143212:
bl sub_8144B48
bl mevent_srv_ish_inc_flag
movs r0, 0x7
strb r0, [r5, 0x8]
b _081435C6
@ -2199,7 +2199,7 @@ _081434D0:
bne _08143500
ldr r0, _081434FC @ =gUnknown_841EAE7
bl sub_8142504
bl sub_8144F40
bl mevent_srv_common_do_init_2
b _0814350A
.align 2, 0
_081434F0: .4byte gStringVar1
@ -2209,7 +2209,7 @@ _081434FC: .4byte gUnknown_841EAE7
_08143500:
ldr r0, _08143510 @ =gUnknown_841EB01
bl sub_8142504
bl sub_8144F1C
bl mevent_srv_common_do_init_1
_0814350A:
movs r0, 0x20
strb r0, [r5, 0x8]
@ -2218,7 +2218,7 @@ _0814350A:
_08143510: .4byte gUnknown_841EB01
_08143514:
adds r0, r5, 0
bl sub_8144F64
bl mevent_srv_init_do_exec
cmp r0, 0x3
bne _081435C6
ldrh r0, [r5]

View File

@ -3176,7 +3176,10 @@ gUnknown_8459580:: @ 8459580
.incbin "baserom.gba", 0x459580, 0x8
gUnknown_8459588:: @ 8459588
.incbin "baserom.gba", 0x459588, 0xAC
.incbin "baserom.gba", 0x459588, 0x64
gUnknown_84595EC::
.incbin "baserom.gba", 0x4595EC, 0x48
gUnknown_8459634:: @ 8459634
.incbin "baserom.gba", 0x459634, 0x8

View File

@ -1,3 +1,6 @@
.include "asm/macros.inc"
.include "constants/constants.inc"
.section .rodata
.align 2
@ -34,11 +37,5 @@ gUnknown_8468050:: @ 8468050
gUnknown_8468720:: @ 8468720
.incbin "baserom.gba", 0x468720, 0xC0
gUnknown_84687E0:: @ 84687E0
.incbin "baserom.gba", 0x4687E0, 0x38C
gUnknown_8468B6C:: @ 8468B6C
.incbin "baserom.gba", 0x468B6C, 0x60
gUnknown_8468BCC:: @ 8468BCC
.incbin "baserom.gba", 0x468BCC, 0x90
.include "data/mevent/script_ish.inc"
.include "data/mevent/script_common.inc"

View File

@ -0,0 +1,84 @@
gUnknown_8468920::
.4byte 0x12, 0x10, gUnknown_8468810
.4byte 0x01, 0x00, NULL
.4byte 0x02, 0x14, NULL
.4byte 0x00, 0x0a, NULL
.4byte 0x12, 0x10, gUnknown_8468820
.4byte 0x01, 0x00, NULL
.4byte 0x02, 0x14, NULL
.4byte 0x00, 0x0b, NULL
.4byte 0x12, 0x10, gUnknown_84688E0
.4byte 0x01, 0x00, NULL
.4byte 0x02, 0x14, NULL
.4byte 0x00, 0x09, NULL
gUnknown_84689B0::
.4byte 0x12, 0x10, gUnknown_8468898
.4byte 0x01, 0x00, NULL
.4byte 0x02, 0x14, NULL
.4byte 0x00, 0x07, NULL
gUnknown_84689E0::
.4byte 0x12, 0x28, gUnknown_8468870
.4byte 0x01, 0x00, NULL
.4byte 0x0e, 0x00, NULL
.4byte 0x01, 0x00, NULL
.4byte 0x02, 0x13, NULL
.4byte 0x08, 0x00, NULL
.4byte 0x04, 0x01, gUnknown_84689B0
.4byte 0x12, 0x10, gUnknown_84688A8
.4byte 0x01, 0x00, NULL
.4byte 0x02, 0x14, NULL
.4byte 0x00, 0x03, NULL
gUnknown_8468A64::
.4byte 0x12, 0x30, gUnknown_8468840
.4byte 0x01, 0x00, NULL
.4byte 0x0d, 0x00, NULL
.4byte 0x01, 0x00, NULL
.4byte 0x0f, 0x00, NULL
.4byte 0x01, 0x00, NULL
.4byte 0x02, 0x14, NULL
.4byte 0x00, 0x02, NULL
gUnknown_8468AC4::
.4byte 0x12, 0x28, gUnknown_84688B8
.4byte 0x01, 0x00, NULL
.4byte 0x02, 0x13, NULL
.4byte 0x08, 0x00, NULL
.4byte 0x04, 0x00, gUnknown_8468A64
.4byte 0x03, 0x00, gUnknown_84595EC
gUnknown_8468B0C::
.4byte 0x12, 0x10, gUnknown_84688F0
.4byte 0x01, 0x00, NULL
.4byte 0x02, 0x14, NULL
.4byte 0x00, 0x05, NULL
.4byte 0x12, 0x10, gUnknown_8468830
.4byte 0x01, 0x00, NULL
.4byte 0x02, 0x14, NULL
.4byte 0x00, 0x00, NULL
gUnknown_8468B6C:: @ 8468B6C
.4byte 0x1b, 0x00, NULL
.4byte 0x12, 0x20, gUnknown_84687F0
.4byte 0x01, 0x00, NULL
.4byte 0x02, 0x11, NULL
.4byte 0x05, 0x00, NULL
.4byte 0x06, 0x00, NULL
.4byte 0x04, 0x00, gUnknown_8468920
.4byte 0x03, 0x00, gUnknown_84689E0
gUnknown_8468BCC:: @ 8468BCC
.4byte 0x1a, 0x00, NULL
.4byte 0x1c, 0x00, NULL
.4byte 0x12, 0x20, gUnknown_84687F0
.4byte 0x01, 0x00, NULL
.4byte 0x02, 0x11, NULL
.4byte 0x05, 0x00, NULL
.4byte 0x06, 0x00, NULL
.4byte 0x04, 0x00, gUnknown_8468920
.4byte 0x07, 0x00, NULL
.4byte 0x04, 0x02, gUnknown_8468AC4
.4byte 0x04, 0x00, gUnknown_8468A64
.4byte 0x03, 0x00, gUnknown_8468B0C

View File

@ -0,0 +1,65 @@
gUnknown_84687E0:: @ 84687E0
.4byte 0x02, 0x10 @ RECEIVE ID(0x10)
.4byte 0x04, 0x00 @ JUMP TO RECEIVE BUFFER
gUnknown_84687F0::
.4byte 0x08, 0x00 @ SEND HEADER MAYBE
.4byte 0x03, 0x00 @ WAIT SEND
.4byte 0x02, 0x10 @ RECEIVE ID(0x10)
.4byte 0x04, 0x00 @ JUMP TO RECEIVE BUFFER
gUnknown_8468810::
.4byte 0x14, 0x00 @ SEND ALL
.4byte 0x01, 0x0a @ RETURN 0x0a
gUnknown_8468820::
.4byte 0x14, 0x00 @ SEND ALL
.4byte 0x01, 0x0b @ RETURN 0x0b
gUnknown_8468830::
.4byte 0x14, 0x00 @ SEND ALL
.4byte 0x01, 0x00 @ RETURN 0x00
gUnknown_8468840::
.4byte 0x02, 0x16 @ RECEIVE ID(0x16)
.4byte 0x0a, 0x00 @ RECEIVE_TO_SAVE_FILE
.4byte 0x02, 0x19 @ RECEIVE ID(0x19)
.4byte 0x11, 0x00 @ RECEIVE_TO_RAM_SCRIPT
.4byte 0x14, 0x00 @ SEND ALL
.4byte 0x01, 0x02 @ RETURN 0x02
gUnknown_8468870::
.4byte 0x02, 0x17 @ RECEIVE ID(0x17)
.4byte 0x09, 0x00 @ VALIDATE BUFF3120
.4byte 0x03, 0x00 @ WAIT SEND
.4byte 0x02, 0x10 @ RECEIVE ID(0x10)
.4byte 0x04, 0x00 @ JUMP TO RECEIVE BUFFER
gUnknown_8468898::
.4byte 0x14, 0x00 @ SEND ALL
.4byte 0x01, 0x07 @ RETURN 0x07
gUnknown_84688A8::
.4byte 0x14, 0x00 @ SEND ALL
.4byte 0x01, 0x03 @ RETURN 0x03
gUnknown_84688B8::
.4byte 0x0d, 0x00 @ REQUEST PARAMETER
.4byte 0x0e, 0x00 @ SEND PARAMETER
.4byte 0x03, 0x00 @ WAIT SEND
.4byte 0x02, 0x10 @ RECEIVE ID(0x10)
.4byte 0x04, 0x00 @ JUMP TO RECEIVE BUFFER
gUnknown_84688E0::
.4byte 0x14, 0x00 @ SEND ALL
.4byte 0x01, 0x09 @ RETURN 0x09
gUnknown_84688F0::
.4byte 0x14, 0x00 @ SEND ALL
.4byte 0x01, 0x05 @ RETURN 0x05
gUnknown_8468900::
.4byte 0x02, 0x15 @ RECEIVE ID(0x15)
.4byte 0x0c, 0x00 @ READ PACKET AND COMPUTE SOMETHING
.4byte 0x14, 0x00 @ SEND ALL
.4byte 0x01, 0x0d @ RETURN 0x0d

View File

@ -40,15 +40,15 @@ struct mevent_cmd_ish
struct mevent_srv_ish
{
u32 unk_00;
u32 unk_04;
u32 param;
u32 mainseqno;
u32 unk_0C;
u32 flag;
u32 cmdidx;
void * unk_14;
void * unk_18;
void * sendBuffer;
void * recvBuffer;
struct mevent_cmd_ish * cmdBuffer;
void * unk_20;
struct mevent_srv_sub unk_24;
void * buffer;
struct mevent_srv_sub manager;
};
struct mevent_cmd
@ -61,20 +61,20 @@ struct mevent_cmd
struct mevent_srv_common
{
u32 unk_00;
u32 unk_04;
u32 param;
u32 mainseqno;
u32 cmdidx;
const struct mevent_cmd * cmdBuffer;
void * unk_14;
struct MEventBuffer_32E0_Sub * unk_18;
struct MEventBuffer_3120_Sub * unk_1C;
struct MEventStruct_Unk1442CC * unk_20;
void * unk_24;
u32 unk_28;
void * unk_2C;
u32 unk_30;
void * unk_34;
struct mevent_srv_sub unk_38;
void * recvBuffer;
struct MEventBuffer_32E0_Sub * mevent_32e0;
struct MEventBuffer_3120_Sub * mevent_3120;
struct MEventStruct_Unk1442CC * mevent_unk1442cc;
void * sendBuffer1;
u32 sendBuffer1Size;
void * sendBuffer2;
u32 sendBuffer2Size;
u32 sendWord;
struct mevent_srv_sub manager;
};
u32 mevent_srv_sub_recv(struct mevent_srv_sub * svr);
@ -83,17 +83,13 @@ void mevent_srv_sub_init(struct mevent_srv_sub * svr, u32 sendPlayerNo, u32 recv
void mevent_srv_sub_init_send(struct mevent_srv_sub * svr, u32 ident, const void * src, u32 size);
void mevent_srv_sub_init_recv(struct mevent_srv_sub * svr, u32 ident, void * dest);
void sub_8144AEC(void);
u32 sub_8144B0C(u16 * a0);
void sub_8144B48(void);
void * sub_8144B58(void);
void sub_8144B64(u32 a0);
void sub_8144F1C(void);
void sub_8144F40(void);
u32 sub_8144F64(u16 * a0);
extern const u8 gUnknown_84687E0[];
extern const u8 gUnknown_8468B6C[];
extern const u8 gUnknown_8468BCC[];
void mevent_srv_ish_do_init(void);
u32 mevent_srv_ish_do_exec(u16 * a0);
void mevent_srv_ish_inc_flag(void);
void * mevent_srv_ish_get_buffer(void);
void mevent_srv_ish_set_param(u32 a0);
void mevent_srv_common_do_init_1(void);
void mevent_srv_common_do_init_2(void);
u32 mevent_srv_init_do_exec(u16 * a0);
#endif //GUARD_MEVENT_SERVER_H

View File

@ -11,84 +11,88 @@
#include "mevent.h"
#include "mevent_server.h"
EWRAM_DATA struct mevent_srv_ish * gUnknown_203F3C0 = NULL;
EWRAM_DATA struct mevent_srv_common * gUnknown_203F3C4 = NULL;
EWRAM_DATA struct mevent_srv_ish * s_mevent_srv_ish_ptr = NULL;
EWRAM_DATA struct mevent_srv_common * s_mevent_srv_common_ptr = NULL;
static void mevent_srv_ish_init(struct mevent_srv_ish *, u32, u32);
static u32 mevent_srv_ish_exec(struct mevent_srv_ish *);
static void sub_8144BC0(struct mevent_srv_ish *);
static void mevent_srv_ish_free_resources(struct mevent_srv_ish *);
static void mevent_srv_init_common(struct mevent_srv_common *, const void *, u32, u32);
static void mevent_srv_free_resources(struct mevent_srv_common *);
static u32 sub_8145600(struct mevent_srv_common *);
static u32 mevent_srv_exec_common(struct mevent_srv_common *);
void sub_8144AEC(void)
extern const u8 gUnknown_84687E0[];
extern const struct mevent_cmd gUnknown_8468B6C[];
extern const struct mevent_cmd gUnknown_8468BCC[];
void mevent_srv_ish_do_init(void)
{
gUnknown_203F3C0 = AllocZeroed(sizeof(struct mevent_srv_ish));
mevent_srv_ish_init(gUnknown_203F3C0, 1, 0);
s_mevent_srv_ish_ptr = AllocZeroed(sizeof(struct mevent_srv_ish));
mevent_srv_ish_init(s_mevent_srv_ish_ptr, 1, 0);
}
u32 sub_8144B0C(u16 * a0)
u32 mevent_srv_ish_do_exec(u16 * a0)
{
u32 result;
if (gUnknown_203F3C0 == NULL)
if (s_mevent_srv_ish_ptr == NULL)
return 6;
result = mevent_srv_ish_exec(gUnknown_203F3C0);
result = mevent_srv_ish_exec(s_mevent_srv_ish_ptr);
if (result == 6)
{
*a0 = gUnknown_203F3C0->unk_04;
sub_8144BC0(gUnknown_203F3C0);
Free(gUnknown_203F3C0);
gUnknown_203F3C0 = NULL;
*a0 = s_mevent_srv_ish_ptr->param;
mevent_srv_ish_free_resources(s_mevent_srv_ish_ptr);
Free(s_mevent_srv_ish_ptr);
s_mevent_srv_ish_ptr = NULL;
}
return result;
}
void sub_8144B48(void)
void mevent_srv_ish_inc_flag(void)
{
gUnknown_203F3C0->unk_0C++;
s_mevent_srv_ish_ptr->flag++;
}
void * sub_8144B58(void)
void * mevent_srv_ish_get_buffer(void)
{
return gUnknown_203F3C0->unk_20;
return s_mevent_srv_ish_ptr->buffer;
}
void sub_8144B64(u32 a0)
void mevent_srv_ish_set_param(u32 a0)
{
gUnknown_203F3C0->unk_04 = a0;
s_mevent_srv_ish_ptr->param = a0;
}
static void mevent_srv_ish_init(struct mevent_srv_ish * svr, u32 a1, u32 a2)
static void mevent_srv_ish_init(struct mevent_srv_ish * svr, u32 sendPlayerNo, u32 recvPlayerNo)
{
svr->unk_00 = 0;
svr->mainseqno = 0;
svr->unk_0C = 0;
svr->unk_14 = AllocZeroed(ME_SEND_BUF_SIZE);
svr->unk_18 = AllocZeroed(ME_SEND_BUF_SIZE);
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->unk_20 = AllocZeroed(0x40);
mevent_srv_sub_init(&svr->unk_24, a1, a2);
svr->buffer = AllocZeroed(0x40);
mevent_srv_sub_init(&svr->manager, sendPlayerNo, recvPlayerNo);
}
static void sub_8144BC0(struct mevent_srv_ish * svr)
static void mevent_srv_ish_free_resources(struct mevent_srv_ish * svr)
{
Free(svr->unk_14);
Free(svr->unk_18);
Free(svr->sendBuffer);
Free(svr->recvBuffer);
Free(svr->cmdBuffer);
Free(svr->unk_20);
Free(svr->buffer);
}
static void sub_8144BE4(struct mevent_srv_ish * svr)
static void mevent_srv_ish_jmp_buffer(struct mevent_srv_ish * svr)
{
memcpy(svr->cmdBuffer, svr->unk_18, ME_SEND_BUF_SIZE);
memcpy(svr->cmdBuffer, svr->recvBuffer, ME_SEND_BUF_SIZE);
svr->cmdidx = 0;
}
static void sub_8144C00(struct mevent_srv_ish * svr, u32 a1, u32 a2)
static void mevent_srv_ish_send_word(struct mevent_srv_ish * svr, u32 ident, u32 word)
{
CpuFill32(0, svr->unk_14, ME_SEND_BUF_SIZE);
*(u32 *)svr->unk_14 = a2;
mevent_srv_sub_init_send(&svr->unk_24, a1, svr->unk_14, 4);
CpuFill32(0, svr->sendBuffer, ME_SEND_BUF_SIZE);
*(u32 *)svr->sendBuffer = word;
mevent_srv_sub_init_send(&svr->manager, ident, svr->sendBuffer, sizeof(u32));
}
static u32 ish_mainseq_0(struct mevent_srv_ish * svr)
@ -97,7 +101,7 @@ static u32 ish_mainseq_0(struct mevent_srv_ish * svr)
memcpy(svr->cmdBuffer, gUnknown_84687E0, ME_SEND_BUF_SIZE);
svr->cmdidx = 0;
svr->mainseqno = 4;
svr->unk_0C = 0;
svr->flag = 0;
return 0;
}
@ -110,10 +114,10 @@ static u32 ish_mainseq_1(struct mevent_srv_ish * svr)
static u32 ish_mainseq_2(struct mevent_srv_ish * svr)
{
// do recv
if (mevent_srv_sub_recv(&svr->unk_24))
if (mevent_srv_sub_recv(&svr->manager))
{
svr->mainseqno = 4;
svr->unk_0C = 0;
svr->flag = 0;
}
return 1;
}
@ -121,10 +125,10 @@ static u32 ish_mainseq_2(struct mevent_srv_ish * svr)
static u32 ish_mainseq_3(struct mevent_srv_ish * svr)
{
// do send
if (mevent_srv_sub_send(&svr->unk_24))
if (mevent_srv_sub_send(&svr->manager))
{
svr->mainseqno = 4;
svr->unk_0C = 0;
svr->flag = 0;
}
return 1;
}
@ -139,96 +143,96 @@ static u32 ish_mainseq_4(struct mevent_srv_ish * svr)
case 0:
break;
case 1:
svr->unk_04 = cmd->parameter;
svr->param = cmd->parameter;
svr->mainseqno = 1;
svr->unk_0C = 0;
svr->flag = 0;
break;
case 2:
mevent_srv_sub_init_recv(&svr->unk_24, cmd->parameter, svr->unk_18);
mevent_srv_sub_init_recv(&svr->manager, cmd->parameter, svr->recvBuffer);
svr->mainseqno = 2;
svr->unk_0C = 0;
svr->flag = 0;
break;
case 3:
svr->mainseqno = 3;
svr->unk_0C = 0;
svr->flag = 0;
break;
case 20:
mevent_srv_sub_init_send(&svr->unk_24, 0x14, svr->unk_14, 0);
mevent_srv_sub_init_send(&svr->manager, 0x14, svr->sendBuffer, 0);
svr->mainseqno = 3;
svr->unk_0C = 0;
svr->flag = 0;
break;
case 19:
sub_8144C00(svr, 0x12, GetGameStat(cmd->parameter));
mevent_srv_ish_send_word(svr, 0x12, GetGameStat(cmd->parameter));
svr->mainseqno = 3;
svr->unk_0C = 0;
svr->flag = 0;
break;
case 6:
if (svr->unk_04 == 0)
sub_8144BE4(svr);
if (svr->param == 0)
mevent_srv_ish_jmp_buffer(svr);
break;
case 7:
if (svr->unk_04 == 1)
sub_8144BE4(svr);
if (svr->param == 1)
mevent_srv_ish_jmp_buffer(svr);
break;
case 4:
sub_8144BE4(svr);
mevent_srv_ish_jmp_buffer(svr);
break;
case 5:
memcpy(svr->unk_20, svr->unk_18, 0x40);
memcpy(svr->buffer, svr->recvBuffer, 0x40);
svr->mainseqno = 5;
svr->unk_0C = 0;
svr->flag = 0;
return 2;
case 11:
memcpy(svr->unk_20, svr->unk_18, 0x40);
memcpy(svr->buffer, svr->recvBuffer, 0x40);
svr->mainseqno = 5;
svr->unk_0C = 0;
svr->flag = 0;
return 3;
case 12:
memcpy(svr->unk_20, svr->unk_18, 0x40);
memcpy(svr->buffer, svr->recvBuffer, 0x40);
svr->mainseqno = 5;
svr->unk_0C = 0;
svr->flag = 0;
return 5;
case 13:
svr->mainseqno = 5;
svr->unk_0C = 0;
svr->flag = 0;
return 4;
case 8:
sub_81442CC(svr->unk_14);
mevent_srv_sub_init_send(&svr->unk_24, 0x11, svr->unk_14, 0x64);
sub_81442CC(svr->sendBuffer);
mevent_srv_sub_init_send(&svr->manager, 0x11, svr->sendBuffer, sizeof(struct MEventStruct_Unk1442CC));
break;
case 14:
sub_8144C00(svr, 0x13, svr->unk_04);
mevent_srv_ish_send_word(svr, 0x13, svr->param);
break;
case 10:
sub_8143F68(svr->unk_18);
sub_8143F68(svr->recvBuffer);
break;
case 9:
if (!sub_8143EF4(svr->unk_18))
if (!sub_8143EF4(svr->recvBuffer))
{
sub_8143DC8(svr->unk_18);
sub_8144C00(svr, 0x13, 0);
sub_8143DC8(svr->recvBuffer);
mevent_srv_ish_send_word(svr, 0x13, 0);
}
else
sub_8144C00(svr, 0x13, 1);
mevent_srv_ish_send_word(svr, 0x13, 1);
break;
case 15:
svr->mainseqno = 6;
svr->unk_0C = 0;
svr->flag = 0;
break;
case 16:
sub_8144254(svr->unk_18);
sub_8144254(svr->recvBuffer);
break;
case 17:
sub_8069EA4(svr->unk_18, 1000);
sub_8069EA4(svr->recvBuffer, 1000);
break;
case 18:
memcpy(gSaveBlock2Ptr->unk_4A0, svr->unk_18, 0xbc);
memcpy(gSaveBlock2Ptr->unk_4A0, svr->recvBuffer, 0xbc);
sub_80E7490();
break;
case 21:
memcpy(gDecompressionBuffer, svr->unk_18, ME_SEND_BUF_SIZE);
memcpy(gDecompressionBuffer, svr->recvBuffer, ME_SEND_BUF_SIZE);
svr->mainseqno = 7;
svr->unk_0C = 0;
svr->flag = 0;
break;
}
@ -237,11 +241,11 @@ static u32 ish_mainseq_4(struct mevent_srv_ish * svr)
static u32 ish_mainseq_5(struct mevent_srv_ish * svr)
{
// wait unk_0C
if (svr->unk_0C)
// wait flag
if (svr->flag)
{
svr->mainseqno = 4;
svr->unk_0C = 0;
svr->flag = 0;
}
return 1;
}
@ -249,17 +253,17 @@ static u32 ish_mainseq_5(struct mevent_srv_ish * svr)
static u32 ish_mainseq_6(struct mevent_srv_ish * svr)
{
// ???
switch (svr->unk_0C)
switch (svr->flag)
{
case 0:
sub_80DA89C(svr->unk_18);
++svr->unk_0C;
sub_80DA89C(svr->recvBuffer);
++svr->flag;
break;
case 1:
if (!sub_80DA8B0(&svr->unk_04))
if (!sub_80DA8B0(&svr->param))
{
svr->mainseqno = 4;
svr->unk_0C = 0;
svr->flag = 0;
}
break;
}
@ -270,10 +274,10 @@ static u32 ish_mainseq_7(struct mevent_srv_ish * svr)
{
// exec arbitrary code
u32 (*func)(u32 *, struct SaveBlock2 *, struct SaveBlock1 *) = (void *)gDecompressionBuffer;
if (func(&svr->unk_04, gSaveBlock2Ptr, gSaveBlock1Ptr) == 1)
if (func(&svr->param, gSaveBlock2Ptr, gSaveBlock1Ptr) == 1)
{
svr->mainseqno = 4;
svr->unk_0C = 0;
svr->flag = 0;
}
return 1;
}
@ -293,62 +297,62 @@ static u32 mevent_srv_ish_exec(struct mevent_srv_ish * svr)
return funcs[svr->mainseqno](svr);
}
void sub_8144F1C(void)
void mevent_srv_common_do_init_1(void)
{
gUnknown_203F3C4 = AllocZeroed(sizeof(struct mevent_srv_common));
mevent_srv_init_common(gUnknown_203F3C4, gUnknown_8468B6C, 0, 1);
s_mevent_srv_common_ptr = AllocZeroed(sizeof(struct mevent_srv_common));
mevent_srv_init_common(s_mevent_srv_common_ptr, gUnknown_8468B6C, 0, 1);
}
void sub_8144F40(void)
void mevent_srv_common_do_init_2(void)
{
gUnknown_203F3C4 = AllocZeroed(sizeof(struct mevent_srv_common));
mevent_srv_init_common(gUnknown_203F3C4, gUnknown_8468BCC, 0, 1);
s_mevent_srv_common_ptr = AllocZeroed(sizeof(struct mevent_srv_common));
mevent_srv_init_common(s_mevent_srv_common_ptr, gUnknown_8468BCC, 0, 1);
}
u32 sub_8144F64(u16 * a0)
u32 mevent_srv_init_do_exec(u16 * a0)
{
u32 result;
if (gUnknown_203F3C4 == NULL)
if (s_mevent_srv_common_ptr == NULL)
return 3;
result = sub_8145600(gUnknown_203F3C4);
result = mevent_srv_exec_common(s_mevent_srv_common_ptr);
if (result == 3)
{
*a0 = gUnknown_203F3C4->unk_04;
mevent_srv_free_resources(gUnknown_203F3C4);
Free(gUnknown_203F3C4);
gUnknown_203F3C4 = NULL;
*a0 = s_mevent_srv_common_ptr->param;
mevent_srv_free_resources(s_mevent_srv_common_ptr);
Free(s_mevent_srv_common_ptr);
s_mevent_srv_common_ptr = NULL;
}
return result;
}
static void mevent_srv_init_common(struct mevent_srv_common * svr, const void * a1, u32 a2, u32 a3)
static void mevent_srv_init_common(struct mevent_srv_common * svr, const void * cmdBuffer, u32 sendPlayerNo, u32 recvPlayerNo)
{
svr->unk_00 = 0;
svr->mainseqno = 0;
svr->unk_18 = AllocZeroed(332);
svr->unk_1C = AllocZeroed(444);
svr->unk_14 = AllocZeroed(ME_SEND_BUF_SIZE);
svr->unk_20 = AllocZeroed(100);
svr->cmdBuffer = a1;
svr->mevent_32e0 = AllocZeroed(sizeof(struct MEventBuffer_32E0_Sub));
svr->mevent_3120 = AllocZeroed(sizeof(struct MEventBuffer_3120_Sub));
svr->recvBuffer = AllocZeroed(ME_SEND_BUF_SIZE);
svr->mevent_unk1442cc = AllocZeroed(sizeof(struct MEventStruct_Unk1442CC));
svr->cmdBuffer = cmdBuffer;
svr->cmdidx = 0;
mevent_srv_sub_init(&svr->unk_38, a2, a3);
mevent_srv_sub_init(&svr->manager, sendPlayerNo, recvPlayerNo);
}
static void mevent_srv_free_resources(struct mevent_srv_common * svr)
{
Free(svr->unk_18);
Free(svr->unk_1C);
Free(svr->unk_14);
Free(svr->unk_20);
Free(svr->mevent_32e0);
Free(svr->mevent_3120);
Free(svr->recvBuffer);
Free(svr->mevent_unk1442cc);
}
static void sub_814501C(struct mevent_srv_common * svr, u32 a1, void * a2, u32 size)
static void mevent_srv_common_init_send(struct mevent_srv_common * svr, u32 ident, const void * src, u32 size)
{
AGB_ASSERT_EX(size <= ME_SEND_BUF_SIZE, "C:/WORK/POKeFRLG/src/pm_lgfr_ose/source/mevent_server.c", 257);
mevent_srv_sub_init_send(&svr->unk_38, a1, a2, size);
mevent_srv_sub_init_send(&svr->manager, ident, src, size);
}
static void * sub_814505C(void * a0, void * a1)
static void * mevent_first_if_not_null_else_second(void * a0, void * a1)
{
if (a0 != NULL)
return a0;
@ -356,7 +360,7 @@ static void * sub_814505C(void * a0, void * a1)
return a1;
}
static u32 sub_8145068(void * a0, void * a1)
static u32 mevent_compare_pointers(void * a0, void * a1)
{
if (a1 < a0)
return 0;
@ -382,7 +386,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->unk_38))
if (mevent_srv_sub_recv(&svr->manager))
svr->mainseqno = 4;
return 1;
}
@ -390,7 +394,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->unk_38))
if (mevent_srv_sub_send(&svr->manager))
svr->mainseqno = 4;
return 1;
}
@ -407,14 +411,14 @@ static u32 common_mainseq_4(struct mevent_srv_common * svr)
case 0:
AGB_ASSERT_EX(cmd->parameter == NULL, "C:/WORK/POKeFRLG/src/pm_lgfr_ose/source/mevent_server.c", 354);
svr->mainseqno = 1;
svr->unk_04 = cmd->flag;
svr->param = cmd->flag;
break;
case 1:
svr->mainseqno = 3;
break;
case 2:
AGB_ASSERT_EX(cmd->parameter == NULL, "C:/WORK/POKeFRLG/src/pm_lgfr_ose/source/mevent_server.c", 364);
mevent_srv_sub_init_recv(&svr->unk_38, cmd->flag, svr->unk_14);
mevent_srv_sub_init_recv(&svr->manager, cmd->flag, svr->recvBuffer);
svr->mainseqno = 2;
break;
case 3:
@ -425,15 +429,15 @@ static u32 common_mainseq_4(struct mevent_srv_common * svr)
case 5:
AGB_ASSERT_EX(cmd->flag == FALSE, "C:/WORK/POKeFRLG/src/pm_lgfr_ose/source/mevent_server.c", 376);
AGB_ASSERT_EX(cmd->parameter == NULL, "C:/WORK/POKeFRLG/src/pm_lgfr_ose/source/mevent_server.c", 377);
memcpy(svr->unk_20, svr->unk_14, 100);
memcpy(svr->mevent_unk1442cc, svr->recvBuffer, sizeof(struct MEventStruct_Unk1442CC));
break;
case 6:
AGB_ASSERT_EX(cmd->flag == FALSE, "C:/WORK/POKeFRLG/src/pm_lgfr_ose/source/mevent_server.c", 382);
AGB_ASSERT_EX(cmd->parameter == NULL, "C:/WORK/POKeFRLG/src/pm_lgfr_ose/source/mevent_server.c", 383);
svr->unk_04 = sub_81443D4(svr->unk_20);
svr->param = sub_81443D4(svr->mevent_unk1442cc);
break;
case 4:
if (svr->unk_04 == cmd->flag)
if (svr->param == cmd->flag)
{
svr->cmdidx = 0;
svr->cmdBuffer = cmd->parameter;
@ -441,100 +445,100 @@ static u32 common_mainseq_4(struct mevent_srv_common * svr)
break;
case 7:
AGB_ASSERT_EX(cmd->flag == FALSE, "C:/WORK/POKeFRLG/src/pm_lgfr_ose/source/mevent_server.c", 396);
ptr = sub_814505C(cmd->parameter, svr->unk_18);
svr->unk_04 = sub_8144418(ptr, svr->unk_20, ptr);
ptr = mevent_first_if_not_null_else_second(cmd->parameter, svr->mevent_32e0);
svr->param = sub_8144418(ptr, svr->mevent_unk1442cc, ptr);
break;
case 8:
AGB_ASSERT_EX(cmd->flag == FALSE, "C:/WORK/POKeFRLG/src/pm_lgfr_ose/source/mevent_server.c", 402);
AGB_ASSERT_EX(cmd->parameter == NULL, "C:/WORK/POKeFRLG/src/pm_lgfr_ose/source/mevent_server.c", 403);
svr->unk_04 = *(u32 *)svr->unk_14;
svr->param = *(u32 *)svr->recvBuffer;
break;
case 9:
AGB_ASSERT_EX(cmd->flag == FALSE, "C:/WORK/POKeFRLG/src/pm_lgfr_ose/source/mevent_server.c", 408);
ptr = sub_814505C(cmd->parameter, &svr->unk_34);
svr->unk_04 = sub_8144434(ptr, svr->unk_20, ptr);
ptr = mevent_first_if_not_null_else_second(cmd->parameter, &svr->sendWord);
svr->param = sub_8144434(ptr, svr->mevent_unk1442cc, ptr);
break;
case 10:
AGB_ASSERT_EX(cmd->parameter == NULL, "C:/WORK/POKeFRLG/src/pm_lgfr_ose/source/mevent_server.c", 415);
svr->unk_04 = sub_81444B0(svr->unk_20, cmd->flag);
svr->param = sub_81444B0(svr->mevent_unk1442cc, cmd->flag);
break;
case 11:
AGB_ASSERT_EX(cmd->flag == FALSE, "C:/WORK/POKeFRLG/src/pm_lgfr_ose/source/mevent_server.c", 420);
svr->unk_04 = sub_8144474(svr->unk_20, cmd->parameter);
svr->param = sub_8144474(svr->mevent_unk1442cc, cmd->parameter);
break;
case 12:
AGB_ASSERT_EX(cmd->flag == FALSE, "C:/WORK/POKeFRLG/src/pm_lgfr_ose/source/mevent_server.c", 426);
svr->unk_04 = sub_8145068(cmd->parameter, *(void **)svr->unk_14);
svr->param = mevent_compare_pointers(cmd->parameter, *(void **)svr->recvBuffer);
break;
case 14:
AGB_ASSERT_EX(cmd->flag == FALSE, "C:/WORK/POKeFRLG/src/pm_lgfr_ose/source/mevent_server.c", 432);
sub_814501C(svr, 0x17, sub_814505C(cmd->parameter, svr->unk_1C), 444);
mevent_srv_common_init_send(svr, 0x17, mevent_first_if_not_null_else_second(cmd->parameter, svr->mevent_3120), sizeof(struct MEventBuffer_3120_Sub));
break;
case 13:
AGB_ASSERT_EX(cmd->flag == FALSE, "C:/WORK/POKeFRLG/src/pm_lgfr_ose/source/mevent_server.c", 438);
sub_814501C(svr, 0x16, sub_814505C(cmd->parameter, svr->unk_18), 332);
mevent_srv_common_init_send(svr, 0x16, mevent_first_if_not_null_else_second(cmd->parameter, svr->mevent_32e0), sizeof(struct MEventBuffer_32E0_Sub));
break;
case 16:
AGB_ASSERT_EX(cmd->flag == FALSE, "C:/WORK/POKeFRLG/src/pm_lgfr_ose/source/mevent_server.c", 444);
sub_814501C(svr, 0x18, sub_814505C(cmd->parameter, &svr->unk_34), 4);
mevent_srv_common_init_send(svr, 0x18, mevent_first_if_not_null_else_second(cmd->parameter, &svr->sendWord), 4);
break;
case 15:
if (cmd->parameter == NULL)
sub_814501C(svr, 0x19, svr->unk_24, svr->unk_28);
mevent_srv_common_init_send(svr, 0x19, svr->sendBuffer1, svr->sendBuffer1Size);
else
sub_814501C(svr, 0x19, cmd->parameter, cmd->flag);
mevent_srv_common_init_send(svr, 0x19, cmd->parameter, cmd->flag);
break;
case 18:
if (cmd->parameter == NULL)
sub_814501C(svr, 0x10, svr->unk_2C, svr->unk_30);
mevent_srv_common_init_send(svr, 0x10, svr->sendBuffer2, svr->sendBuffer2Size);
else
sub_814501C(svr, 0x10, cmd->parameter, cmd->flag);
mevent_srv_common_init_send(svr, 0x10, cmd->parameter, cmd->flag);
break;
case 19:
AGB_ASSERT_EX(cmd->flag == FALSE, "C:/WORK/POKeFRLG/src/pm_lgfr_ose/source/mevent_server.c", 466);
sub_814501C(svr, 0x1a, cmd->parameter, 188);
mevent_srv_common_init_send(svr, 0x1a, cmd->parameter, 188);
break;
case 20:
sub_814501C(svr, 0x15, cmd->parameter, cmd->flag);
mevent_srv_common_init_send(svr, 0x15, cmd->parameter, cmd->flag);
break;
case 17:
sub_814501C(svr, 0x1c, cmd->parameter, cmd->flag);
mevent_srv_common_init_send(svr, 0x1c, cmd->parameter, cmd->flag);
break;
case 22:
AGB_ASSERT_EX(cmd->flag == FALSE, "C:/WORK/POKeFRLG/src/pm_lgfr_ose/source/mevent_server.c", 481);
memcpy(svr->unk_18, cmd->parameter, 332);
memcpy(svr->mevent_32e0, cmd->parameter, 332);
break;
case 23:
AGB_ASSERT_EX(cmd->flag == FALSE, "C:/WORK/POKeFRLG/src/pm_lgfr_ose/source/mevent_server.c", 486);
memcpy(svr->unk_1C, cmd->parameter, 444);
memcpy(svr->mevent_3120, cmd->parameter, 444);
break;
case 21:
AGB_ASSERT_EX(cmd->flag == FALSE, "C:/WORK/POKeFRLG/src/pm_lgfr_ose/source/mevent_server.c", 491);
svr->unk_34 = *(void **)cmd->parameter;
svr->sendWord = *(u32 *)cmd->parameter;
break;
case 24:
svr->unk_24 = cmd->parameter;
svr->unk_28 = cmd->flag;
svr->sendBuffer1 = cmd->parameter;
svr->sendBuffer1Size = cmd->flag;
break;
case 25:
svr->unk_2C = cmd->parameter;
svr->unk_30 = cmd->flag;
svr->sendBuffer2 = cmd->parameter;
svr->sendBuffer2Size = cmd->flag;
break;
case 26:
AGB_ASSERT_EX(cmd->flag == FALSE && cmd->parameter == NULL, "C:/WORK/POKeFRLG/src/pm_lgfr_ose/source/mevent_server.c", 506);
memcpy(svr->unk_18, sav1_get_mevent_buffer_1(), 332);
sub_814410C(svr->unk_18);
memcpy(svr->mevent_32e0, sav1_get_mevent_buffer_1(), 332);
sub_814410C(svr->mevent_32e0);
break;
case 27:
AGB_ASSERT_EX(cmd->flag == FALSE && cmd->parameter == NULL, "C:/WORK/POKeFRLG/src/pm_lgfr_ose/source/mevent_server.c", 512);
memcpy(svr->unk_1C, sub_8143D58(), 444);
memcpy(svr->mevent_3120, sub_8143D58(), 444);
break;
case 28:
AGB_ASSERT_EX(cmd->flag == FALSE && cmd->parameter == NULL, "C:/WORK/POKeFRLG/src/pm_lgfr_ose/source/mevent_server.c", 517);
svr->unk_24 = sub_8069E48();
svr->sendBuffer1 = sub_8069E48();
break;
case 29:
sub_814501C(svr, 0x1b, cmd->parameter, cmd->flag);
mevent_srv_common_init_send(svr, 0x1b, cmd->parameter, cmd->flag);
break;
}
@ -549,7 +553,7 @@ static u32 (*const func_tbl[])(struct mevent_srv_common *) = {
common_mainseq_4
};
static u32 sub_8145600(struct mevent_srv_common * svr)
static u32 mevent_srv_exec_common(struct mevent_srv_common * svr)
{
u32 response;
AGB_ASSERT_EX(svr->mainseqno < NELEMS(func_tbl), "C:/WORK/POKeFRLG/src/pm_lgfr_ose/source/mevent_server.c", 546);

View File

@ -41,10 +41,10 @@ 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 a1, const void * src, u32 size)
void mevent_srv_sub_init_send(struct mevent_srv_sub * svr, u32 ident, const void * src, u32 size)
{
svr->seqno = 0;
svr->sendIdent = a1;
svr->sendIdent = ident;
svr->sendCounter = 0;
svr->sendCRC = 0;
if (size != 0)