diff --git a/asm/code_08030C94.s b/asm/code_08030C94.s index 5100006..9c78073 100644 --- a/asm/code_08030C94.s +++ b/asm/code_08030C94.s @@ -997,7 +997,7 @@ _080314C4: ldr r0, [r4, #0xc] cmp r0, #0 bne _080315AE - ldr r1, _080314EC @ =gUnk_03002554 + ldr r1, _080314EC @ =gMultiSioStatusFlags ldr r2, [r1] movs r0, #0x80 lsls r0, r0, #5 @@ -1012,7 +1012,7 @@ _080314C4: b _08031524 .align 2, 0 _080314E8: .4byte gUnk_020382A0 -_080314EC: .4byte gUnk_03002554 +_080314EC: .4byte gMultiSioStatusFlags _080314F0: .4byte 0x0000FFFE _080314F4: movs r1, #0x80 @@ -1161,7 +1161,7 @@ _08031600: movs r1, #0x80 lsls r1, r1, #1 lsls r1, r3 - ldr r0, _08031638 @ =gUnk_03002554 + ldr r0, _08031638 @ =gMultiSioStatusFlags ldr r2, [r0] ands r1, r2 cmp r1, #0 @@ -1186,7 +1186,7 @@ _08031600: mov sb, r0 b _0803167C .align 2, 0 -_08031638: .4byte gUnk_03002554 +_08031638: .4byte gMultiSioStatusFlags _0803163C: .4byte gMultiSioRecv _08031640: .4byte 0x0000FFFB _08031644: @@ -1267,7 +1267,7 @@ sub_0803169C: @ 0x0803169C ands r0, r1 cmp r0, #0 bne _0803171C - ldr r0, _08031714 @ =gUnk_03002554 + ldr r0, _08031714 @ =gMultiSioStatusFlags ldr r2, [r0] movs r0, #0x80 ands r0, r2 @@ -1293,7 +1293,7 @@ _08031704: .4byte gMultiSioSend _08031708: .4byte 0x00000123 _0803170C: .4byte 0x0000FFFC _08031710: .4byte 0x04000128 -_08031714: .4byte gUnk_03002554 +_08031714: .4byte gMultiSioStatusFlags _08031718: .4byte sub_08031764 _0803171C: ldr r3, _08031758 @ =0x04000128 @@ -1302,7 +1302,7 @@ _0803171C: ands r0, r1 cmp r0, #0 beq _08031750 - ldr r0, _0803175C @ =gUnk_03002554 + ldr r0, _0803175C @ =gMultiSioStatusFlags ldr r2, [r0] movs r0, #0x80 ands r0, r2 @@ -1330,7 +1330,7 @@ _08031750: bx r1 .align 2, 0 _08031758: .4byte 0x04000128 -_0803175C: .4byte gUnk_03002554 +_0803175C: .4byte gMultiSioStatusFlags _08031760: .4byte sub_080319F0 thumb_func_start sub_08031764 @@ -1355,7 +1355,7 @@ sub_08031764: @ 0x08031764 ands r0, r1 cmp r0, #0 bne _080317A8 - ldr r0, _080317CC @ =gUnk_03002554 + ldr r0, _080317CC @ =gMultiSioStatusFlags ldr r2, [r0] movs r0, #0x80 ands r0, r2 @@ -1384,7 +1384,7 @@ _080317BC: .4byte gUnk_020382A0 _080317C0: .4byte gMultiSioSend _080317C4: .4byte 0x00000123 _080317C8: .4byte 0x04000128 -_080317CC: .4byte gUnk_03002554 +_080317CC: .4byte gMultiSioStatusFlags _080317D0: .4byte 0x0000FFFC _080317D4: .4byte sub_0803169C _080317D8: @@ -1489,7 +1489,7 @@ sub_08031860: @ 0x08031860 ands r0, r1 cmp r0, #0 bne _080318B8 - ldr r1, _080318DC @ =gUnk_03002554 + ldr r1, _080318DC @ =gMultiSioStatusFlags ldr r2, [r1] movs r0, #0x80 ands r0, r2 @@ -1519,7 +1519,7 @@ _080318CC: .4byte gUnk_020382A0 _080318D0: .4byte gMultiSioSend _080318D4: .4byte 0x00000123 _080318D8: .4byte 0x04000128 -_080318DC: .4byte gUnk_03002554 +_080318DC: .4byte gMultiSioStatusFlags _080318E0: .4byte 0x0000FFFC _080318E4: .4byte sub_0803169C _080318E8: @@ -1687,7 +1687,7 @@ sub_080319F0: @ 0x080319F0 ands r0, r1 cmp r0, #0 beq _08031A38 - ldr r0, _08031A60 @ =gUnk_03002554 + ldr r0, _08031A60 @ =gMultiSioStatusFlags ldr r2, [r0] movs r0, #0x80 ands r0, r2 @@ -1718,7 +1718,7 @@ _08031A50: .4byte gMultiSioSend _08031A54: .4byte gMultiSioRecv _08031A58: .4byte 0x00000123 _08031A5C: .4byte 0x04000128 -_08031A60: .4byte gUnk_03002554 +_08031A60: .4byte gMultiSioStatusFlags _08031A64: .4byte 0x0000FFFC _08031A68: .4byte sub_0803169C _08031A6C: @@ -1779,7 +1779,7 @@ sub_08031AA8: @ 0x08031AA8 ands r0, r1 cmp r0, #0 beq _08031AF4 - ldr r0, _08031B1C @ =gUnk_03002554 + ldr r0, _08031B1C @ =gMultiSioStatusFlags ldr r2, [r0] movs r0, #0x80 ands r0, r2 @@ -1810,7 +1810,7 @@ _08031B0C: .4byte gMultiSioSend _08031B10: .4byte gMultiSioRecv _08031B14: .4byte 0x00000123 _08031B18: .4byte 0x04000128 -_08031B1C: .4byte gUnk_03002554 +_08031B1C: .4byte gMultiSioStatusFlags _08031B20: .4byte 0x0000FFFC _08031B24: .4byte sub_0803169C _08031B28: @@ -4466,7 +4466,7 @@ _08032F6E: ldr r0, [r1, #8] movs r2, #0x80 lsls r2, r2, #0x18 - ldr r3, _08032FF4 @ =gUnk_03002554 + ldr r3, _08032FF4 @ =gMultiSioStatusFlags ldr r5, _08032FF8 @ =gUnk_03002558 cmp r0, #0 bge _08032F98 @@ -4514,7 +4514,7 @@ _08032FE4: .4byte gMultiSioSend _08032FE8: .4byte 0x85000005 _08032FEC: .4byte gMultiSioRecv _08032FF0: .4byte 0x85000014 -_08032FF4: .4byte gUnk_03002554 +_08032FF4: .4byte gMultiSioStatusFlags _08032FF8: .4byte gUnk_03002558 _08032FFC: .4byte 0x04000208 _08033000: .4byte gIntrTable diff --git a/asm/code_0815819C.s b/asm/code_0815819C.s index eae7c23..a04ac16 100644 --- a/asm/code_0815819C.s +++ b/asm/code_0815819C.s @@ -1027,7 +1027,7 @@ sub_08158934: @ 0x08158934 ldr r1, _08158980 @ =0x85000014 str r1, [r0, #8] ldr r0, [r0, #8] - ldr r0, _08158984 @ =gUnk_03002554 + ldr r0, _08158984 @ =gMultiSioStatusFlags str r2, [r0] ldr r0, _08158988 @ =gUnk_03002558 strb r2, [r0] @@ -1042,7 +1042,7 @@ _08158974: .4byte gMultiSioSend _08158978: .4byte 0x85000005 _0815897C: .4byte gMultiSioRecv _08158980: .4byte 0x85000014 -_08158984: .4byte gUnk_03002554 +_08158984: .4byte gMultiSioStatusFlags _08158988: .4byte gUnk_03002558 thumb_func_start sub_0815898C diff --git a/include/main.h b/include/main.h index 5a5ceec..053b0cf 100644 --- a/include/main.h +++ b/include/main.h @@ -81,7 +81,7 @@ extern u16 gUnk_03002544; extern u8 gUnk_03002548; extern u16 gUnk_0300254C; extern u8 gUnk_03002550; -extern u32 gUnk_03002554; +extern u32 gMultiSioStatusFlags; extern u8 gUnk_03002558; extern u8 gUnk_03002760[2][0x280]; extern u16 gObjPalette[0x100]; diff --git a/include/multi_08019F28.h b/include/multi_08019F28.h index 73bcfcf..3b77c78 100644 --- a/include/multi_08019F28.h +++ b/include/multi_08019F28.h @@ -28,7 +28,7 @@ struct Multi_08019F28 u16 unk9E; u8 fillerA0[4]; s32 unkA4; - u8 unkA8; + u8 loadRequest; u8 unkA9; u16 unkAA; u16 unkAC; diff --git a/include/multi_sio.h b/include/multi_sio.h index 21bf896..3dab688 100644 --- a/include/multi_sio.h +++ b/include/multi_sio.h @@ -180,38 +180,44 @@ extern u32 MultiSioMain(void *sendp, void *recvp, u32 loadRequest); //* Return Value: -#define MULTI_SIO_RECV_ID_MASK 0x000f // Receive Success Flag -#define MULTI_SIO_CONNECTED_ID_MASK 0x0f00 // Connection History Flag +#define MULTI_SIO_RECV_ID_MASK 0x000f // Receive success flag +#define MULTI_SIO_CONNECTED_ID_MASK 0x0f00 // Connection history flag -#define MULTI_SIO_RECV_ID0 0x0001 // Receive Success Flag Master -#define MULTI_SIO_RECV_ID1 0x0002 // Slave 1 -#define MULTI_SIO_RECV_ID2 0x0004 // Slave 2 -#define MULTI_SIO_RECV_ID3 0x0008 // Slave 3 -#define MULTI_SIO_LD_ENABLE 0x0010 // Enable Load -#define MULTI_SIO_LD_REQUEST 0x0020 // Load Request -#define MULTI_SIO_LD_SUCCESS 0x0040 // Load Success -#define MULTI_SIO_TYPE 0x0080 // Connection (Master/Slave) -#define MULTI_SIO_PARENT 0x0080 // Master Connection -#define MULTI_SIO_CHILD 0x0000 // Slave Connection -#define MULTI_SIO_CONNECTED_ID0 0x0100 // Connection History Flag Master -#define MULTI_SIO_CONNECTED_ID1 0x0200 // Slave 1 -#define MULTI_SIO_CONNECTED_ID2 0x0400 // Slave 2 -#define MULTI_SIO_CONNECTED_ID3 0x0800 // Slave 3 -#define MULTI_SIO_UNK_x1000 0x1000 -#define MULTI_SIO_UNK_x2000 0x2000 +#define MULTI_SIO_RECV_ID_SHIFT 0 +#define MULTI_SIO_CONNECTED_ID_SHIFT 8 + +#define MULTI_SIO_RECV_ID0 0x0001 // Receive success flag Master +#define MULTI_SIO_RECV_ID1 0x0002 // Slave 1 +#define MULTI_SIO_RECV_ID2 0x0004 // Slave 2 +#define MULTI_SIO_RECV_ID3 0x0008 // Slave 3 +#define MULTI_SIO_LD_ENABLE 0x0010 // Enable load +#define MULTI_SIO_LD_REQUEST 0x0020 // Load request +#define MULTI_SIO_LD_SUCCESS 0x0040 // Load success +#define MULTI_SIO_TYPE 0x0080 // Connection (Master/Slave) +#define MULTI_SIO_PARENT 0x0080 // Connect Master +#define MULTI_SIO_CHILD 0x0000 // Connect Slave +#define MULTI_SIO_CONNECTED_ID0 0x0100 // Connection history flag Master +#define MULTI_SIO_CONNECTED_ID1 0x0200 // Slave 1 +#define MULTI_SIO_CONNECTED_ID2 0x0400 // Slave 2 +#define MULTI_SIO_CONNECTED_ID3 0x0800 // Slave 3 +#define MULTI_SIO_HARD_ERROR 0x1000 // Hard error +#define MULTI_SIO_ID_OVER_ERROR 0x2000 // ID over error +#define MULTI_SIO_RECV_FLAGS_AVAILABLE 0x8000 // Validate receive success flag // Return Value Structure struct MultiSioReturn { - u32 recvSuccessFlags:4; // Receive Success Flag - u32 loadEnable:1; // Enable Load - u32 loadRequest:1; // Load Request - u32 loadSuccessFlag:1; // Load Success - u32 type:1; // Connection (Master/Slave) - u32 connectedFlags:4; // Connection History Flag - u32 multisioreturn_unk00_0c:1; - u32 multisioreturn_unk00_0d:1; + u32 recvSuccessFlags:4; // Receive success flag + u32 loadEnable:1; // Enable load + u32 loadRequest:1; // Load request + u32 loadSuccessFlag:1; // Load success + u32 type:1; // Connection (master/slave) + u32 connectedFlags:4; // Connection history flag + u32 hardError:1; // Hard error + u32 idOverError:1; // ID over error + u32 reserved:1; // Reservation + u32 recvFlagsAvailable:1; // Validate receive success flag }; diff --git a/linker.ld b/linker.ld index 1320f9b..33c0cee 100644 --- a/linker.ld +++ b/linker.ld @@ -183,7 +183,7 @@ SECTIONS { . = 0x00002548; gUnk_03002548 = .; . = 0x0000254C; gUnk_0300254C = .; . = 0x00002550; gUnk_03002550 = .; - . = 0x00002554; gUnk_03002554 = .; + . = 0x00002554; gMultiSioStatusFlags = .; . = 0x00002558; gUnk_03002558 = .; . = 0x00002560; gTaskList = .; . = 0x00002760; gUnk_03002760 = .; diff --git a/src/main.c b/src/main.c index ddd1608..15009f9 100644 --- a/src/main.c +++ b/src/main.c @@ -196,7 +196,7 @@ void GameInit(void) { DmaWait(3); DmaFill32(3, 0, gMultiSioRecv, sizeof(gMultiSioRecv)); DmaWait(3); - gUnk_03002554 = 0; + gMultiSioStatusFlags = 0; gUnk_03002558 = 0; MultiSioInit(0); gUnk_0300607C = 0; @@ -205,7 +205,6 @@ void GameInit(void) { } void GameLoop(void) { - u32 ret; while (1) { gUnk_030068D4 = 0; gUnk_03002440 &= ~0x01000000; @@ -219,8 +218,7 @@ void GameLoop(void) { GetInput(); if (gUnk_03002558 != 0) { sub_08030E44(); - ret = MultiSioMain(&gMultiSioSend, gMultiSioRecv, 0); - gUnk_03002554 = ret; + gMultiSioStatusFlags = MultiSioMain(&gMultiSioSend, gMultiSioRecv, 0); if (sub_08030FE0() == 0) { sub_08032E98(); } diff --git a/src/multi_08019F28.c b/src/multi_08019F28.c index 78ca4eb..b27e971 100644 --- a/src/multi_08019F28.c +++ b/src/multi_08019F28.c @@ -629,7 +629,7 @@ static void sub_0801A618(struct Multi_08019F28 *r5) { u32 r3; - if (gUnk_03002554 & 0x20) + if (gMultiSioStatusFlags & MULTI_SIO_LD_REQUEST) { switch (r5->unk80) { @@ -648,10 +648,10 @@ static void sub_0801A618(struct Multi_08019F28 *r5) else r5->callback = sub_0801A8E8; } - if (gUnk_03002554 & 0x10) - r5->unkA8 = 1; + if (gMultiSioStatusFlags & MULTI_SIO_LD_ENABLE) + r5->loadRequest = 1; gMultiSioSend.unk0 = gUnk_08D60A80; - gUnk_03002554 = MultiSioMain(&gMultiSioSend, gMultiSioRecv, r5->unkA8); + gMultiSioStatusFlags = MultiSioMain(&gMultiSioSend, gMultiSioRecv, r5->loadRequest); if (r5->unkA4 == 0) { MultiSioStart(); @@ -684,7 +684,7 @@ static void sub_0801A6BC(struct Multi_08019F28 *r5) REG_IME = 0; gIntrTable[0] = Sio32MultiLoadIntr; REG_IME = 1; - Sio32MultiLoadInit(gUnk_03002554 & 0x80, datap); + Sio32MultiLoadInit(gMultiSioStatusFlags & MULTI_SIO_TYPE, datap); r5->callback = sub_0801A8C4; } @@ -792,10 +792,10 @@ static void sub_0801A908(struct Multi_08019F28 *r4) REG_IME = 0; gIntrTable[0] = (void *)gMultiSioIntrFuncBuf; REG_IME = 1; - MultiSioInit((gUnk_03002554 & 0xF00) >> 8); - r4->unkA8 = 0; + MultiSioInit((gMultiSioStatusFlags & MULTI_SIO_CONNECTED_ID_MASK) >> 8); + r4->loadRequest = 0; r4->unkA4 = 0; - gUnk_03002554 = 0; + gMultiSioStatusFlags = 0; } static void sub_0801A950(struct Multi_08019F28 *r4) @@ -861,9 +861,9 @@ static void sub_0801AA40(struct Multi_08019F28 *r4) static void sub_0801AA58(struct Multi_08019F28 *r2) { - if (gUnk_03002554 & 0x10) + if (gMultiSioStatusFlags & MULTI_SIO_LD_ENABLE) { - if (gUnk_03002554 & 0x40) + if (gMultiSioStatusFlags & MULTI_SIO_LD_SUCCESS) ++gMultiSioSend.unk2; r2->callback = sub_0801A618; }