2017-11-11 06:39:02 +01:00
|
|
|
|
|
|
|
// Includes
|
|
|
|
#include "global.h"
|
2017-11-17 05:37:09 +01:00
|
|
|
#include "link.h"
|
2017-11-18 21:15:54 +01:00
|
|
|
#include "librfu.h"
|
2017-11-17 05:37:09 +01:00
|
|
|
#include "link_rfu.h"
|
2017-11-11 06:39:02 +01:00
|
|
|
|
|
|
|
// Static type declarations
|
|
|
|
|
2017-11-17 05:37:09 +01:00
|
|
|
struct UnkRfuStruct_1 gUnknown_03004140;
|
|
|
|
|
2017-11-11 06:39:02 +01:00
|
|
|
// Static RAM declarations
|
2017-11-18 21:15:54 +01:00
|
|
|
IWRAM_DATA u8 gUnknown_03000D74;
|
|
|
|
ALIGNED(4) IWRAM_DATA u8 gUnknown_03000D78[8];
|
2017-11-11 06:39:02 +01:00
|
|
|
IWRAM_DATA u8 gUnknown_03000D80[16];
|
|
|
|
IWRAM_DATA u16 gUnknown_03000D90[8];
|
|
|
|
|
|
|
|
// Static ROM declarations
|
|
|
|
|
2017-11-18 21:15:54 +01:00
|
|
|
void sub_800C000(void);
|
|
|
|
void sub_800CEB0(u16 unk0);
|
|
|
|
void sub_800C7B4(u16 unk0, u16 unk1);
|
|
|
|
void sub_800D30C(u8 a0, u8 a1);
|
|
|
|
void sub_800D610(void);
|
|
|
|
|
2017-11-11 06:39:02 +01:00
|
|
|
// .rodata
|
|
|
|
|
|
|
|
// .text
|
2017-11-18 21:15:54 +01:00
|
|
|
|
|
|
|
u32 sub_800BEC0(void)
|
|
|
|
{
|
|
|
|
u32 r4;
|
|
|
|
|
|
|
|
r4 = rfu_REQBN_softReset_and_checkID();
|
|
|
|
if (r4 == 0x8001)
|
|
|
|
{
|
|
|
|
gUnknown_03004140.unk_08 = 1;
|
|
|
|
}
|
|
|
|
if (gUnknown_03004140.unk_04 != 0x17 && gUnknown_03004140.unk_04 != 0x01)
|
|
|
|
{
|
|
|
|
gUnknown_03004140.unk_05 = 0;
|
|
|
|
gUnknown_03004140.unk_04 = 0;
|
|
|
|
}
|
|
|
|
gUnknown_03004140.unk_07 = 0;
|
|
|
|
gUnknown_03004140.unk_0d = 0;
|
|
|
|
gUnknown_03004140.unk_01 = 0;
|
|
|
|
gUnknown_03004140.unk_00 = 0;
|
|
|
|
gUnknown_03004140.unk_06 = -1;
|
|
|
|
sub_800D610();
|
|
|
|
return r4;
|
|
|
|
}
|
|
|
|
|
|
|
|
void rfu_REQ_sendData_wrapper(u8 r2)
|
|
|
|
{
|
|
|
|
u8 val;
|
|
|
|
if (!gUnknown_03007890->unk_00)
|
|
|
|
{
|
|
|
|
val = gUnknown_03004140.unk_02;
|
|
|
|
r2 = 0;
|
|
|
|
if (val == 1)
|
|
|
|
{
|
|
|
|
r2 = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gUnknown_03004140.unk_03 = 0;
|
|
|
|
}
|
|
|
|
rfu_REQ_sendData(r2);
|
|
|
|
}
|
|
|
|
|
|
|
|
int sub_800BF4C(void (*func1)(u8), void (*func2)(void))
|
|
|
|
{
|
|
|
|
if (func1 == NULL)
|
|
|
|
{
|
|
|
|
return 4;
|
|
|
|
}
|
|
|
|
CpuFill16(0, &gUnknown_03004140, sizeof(gUnknown_03004140));
|
|
|
|
gUnknown_03004140.unk_06 = -1;
|
|
|
|
gUnknown_03004140.unk_40 = func1;
|
|
|
|
gUnknown_03004140.unk_44 = func2;
|
|
|
|
rfu_setMSCCallback(sub_800CEB0);
|
|
|
|
rfu_setREQCallback(sub_800C7B4);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void sub_800BFA0(void)
|
|
|
|
{
|
|
|
|
CpuFill16(0, &gUnknown_03004140, sizeof(gUnknown_03004140) - 2 * sizeof(void *));
|
|
|
|
gUnknown_03004140.unk_06 = -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
void sub_800BFCC(struct UnkLinkRfuStruct_02022B2C *unk0)
|
|
|
|
{
|
|
|
|
sub_800C000();
|
|
|
|
gUnknown_03004140.unk_04 = 1;
|
|
|
|
gUnknown_03004140.unk_05 = 2;
|
|
|
|
gUnknown_03004140.unk_3c = unk0;
|
|
|
|
gUnknown_03004140.unk_09 = unk0->unk_11;
|
|
|
|
gUnknown_03004140.unk_32 = unk0->unk_12;
|
|
|
|
gUnknown_03004140.unk_18 = unk0->unk_14;
|
|
|
|
if (unk0->unk_10)
|
|
|
|
{
|
|
|
|
gUnknown_03004140.unk_0b = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void sub_800C000(void)
|
|
|
|
{
|
|
|
|
u8 i;
|
|
|
|
|
|
|
|
gUnknown_03004140.unk_05 = 0;
|
|
|
|
gUnknown_03004140.unk_04 = 0;
|
|
|
|
gUnknown_03004140.unk_06 = -1;
|
|
|
|
gUnknown_03004140.unk_07 = 0;
|
|
|
|
gUnknown_03004140.unk_10 = 0;
|
|
|
|
gUnknown_03004140.unk_0c = 0;
|
|
|
|
gUnknown_03004140.unk_24 = 0;
|
|
|
|
gUnknown_03004140.unk_30 = 0;
|
|
|
|
for (i = 0; i < 4; i++)
|
|
|
|
{
|
|
|
|
gUnknown_03004140.unk_28[i] = 0;
|
|
|
|
gUnknown_03004140.unk_34[i] = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void sub_800C048(void)
|
|
|
|
{
|
|
|
|
gUnknown_03004140.unk_04 = 0x15;
|
|
|
|
}
|
|
|
|
|
|
|
|
u8 sub_800C054(u8 r5, u16 r7, u16 r8, u16 *r6)
|
|
|
|
{
|
|
|
|
u8 i;
|
|
|
|
u16 *buffer;
|
|
|
|
|
|
|
|
if (gUnknown_03004140.unk_04 != 0 && (gUnknown_03004140.unk_04 != 0x08 || r5 != 1))
|
|
|
|
{
|
|
|
|
gUnknown_03004140.unk_14 = 1;
|
|
|
|
sub_800D30C(0xf3, 0x01);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
if (!rfu_getMasterSlave())
|
|
|
|
{
|
|
|
|
gUnknown_03004140.unk_14 = 2;
|
|
|
|
sub_800D30C(0xf3, 0x01);
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
for (i = 0, buffer = r6; i < 16; i++)
|
|
|
|
{
|
|
|
|
if (*buffer++ == 0xFFFF)
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (i == 16)
|
|
|
|
{
|
|
|
|
gUnknown_03004140.unk_14 = 4;
|
|
|
|
sub_800D30C(0xf3, 0x01);
|
|
|
|
return 4;
|
|
|
|
}
|
|
|
|
if (r5 > 1)
|
|
|
|
{
|
|
|
|
gUnknown_03004140.unk_07 = 1;
|
|
|
|
r5 = 1;
|
|
|
|
r7 = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gUnknown_03004140.unk_07 = 0;
|
|
|
|
}
|
|
|
|
if (r5 != 0)
|
|
|
|
{
|
|
|
|
gUnknown_03004140.unk_04 = 5;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gUnknown_03004140.unk_04 = 9;
|
|
|
|
if (gUnknown_03004140.unk_0b)
|
|
|
|
{
|
|
|
|
gUnknown_03004140.unk_0b = 2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
gUnknown_03004140.unk_06 = r5;
|
|
|
|
gUnknown_03004140.unk_1a = r7;
|
|
|
|
gUnknown_03004140.unk_26 = r8;
|
|
|
|
gUnknown_03004140.unk_20 = r6;
|
|
|
|
return 0;
|
|
|
|
}
|