mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2024-11-16 11:37:40 +01:00
Split librfu into separate C files in its own directory, rfu_initializeAPI matching except for register differences
This commit is contained in:
parent
dd316b28e0
commit
482b42a295
108
include/librfu.h
Normal file
108
include/librfu.h
Normal file
@ -0,0 +1,108 @@
|
||||
#include "main.h"
|
||||
|
||||
enum
|
||||
{
|
||||
RFU_RESET = 0x10,
|
||||
RFU_LINK_STATUS,
|
||||
RFU_VERSION_STATUS,
|
||||
RFU_SYSTEM_STATUS,
|
||||
RFU_SLOT_STATUS,
|
||||
RFU_CONFIG_STATUS,
|
||||
RFU_GAME_CONFIG,
|
||||
RFU_SYSTEM_CONFIG,
|
||||
RFU_UNK18,
|
||||
RFU_SC_START,
|
||||
RFU_SC_POLLING,
|
||||
RFU_SC_END,
|
||||
RFU_SP_START,
|
||||
RFU_SP_POLLING,
|
||||
RFU_SP_END,
|
||||
RFU_CP_START,
|
||||
RFU_CP_POLLING,
|
||||
RFU_CP_END,
|
||||
RFU_UNK22,
|
||||
RFU_UNK23,
|
||||
RFU_DATA_TX,
|
||||
RFU_DATA_TX_AND_CHANGE,
|
||||
RFU_DATA_RX,
|
||||
RFU_MS_CHANGE,
|
||||
RFU_DATA_READY_AND_CHANGE,
|
||||
RFU_DISCONNECTED_AND_CHANGE,
|
||||
RFU_UNK2A,
|
||||
RFU_UNK2B,
|
||||
RFU_UNK2C,
|
||||
RFU_UNK2D,
|
||||
RFU_UNK2E,
|
||||
RFU_UNK2F,
|
||||
RFU_DISCONNECT,
|
||||
RFU_TEST_MODE,
|
||||
RFU_CPR_START,
|
||||
RFU_CPR_POLLING,
|
||||
RFU_CPR_END,
|
||||
RFU_UNK35,
|
||||
RFU_UNK36,
|
||||
RFU_RESUME_RETRANSMIT_AND_CHANGE,
|
||||
RFU_UNK38,
|
||||
RFU_UNK39,
|
||||
RFU_UNK3A,
|
||||
RFU_UNK3B,
|
||||
RFU_UNK3C,
|
||||
RFU_STOP_MODE, //3D
|
||||
};
|
||||
|
||||
struct RfuPacket8
|
||||
{
|
||||
u8 data[0x74];
|
||||
};
|
||||
|
||||
struct RfuPacket32
|
||||
{
|
||||
u32 command;
|
||||
u32 data[0x1C];
|
||||
};
|
||||
|
||||
union RfuPacket
|
||||
{
|
||||
struct RfuPacket32 rfuPacket32;
|
||||
struct RfuPacket8 rfuPacket8;
|
||||
};
|
||||
|
||||
struct RfuStruct
|
||||
{
|
||||
vs32 unk_0;
|
||||
u8 txParams;
|
||||
u8 unk_5;
|
||||
u8 activeCommand;
|
||||
u8 unk_7;
|
||||
u8 unk_8;
|
||||
u8 unk_9;
|
||||
u8 timerSelect;
|
||||
u8 unk_b;
|
||||
int timerState;
|
||||
vu8 timerActive;
|
||||
u8 unk_11;
|
||||
vu16 unk_12;
|
||||
vu8 msMode;
|
||||
u8 unk_15;
|
||||
u8 unk_16;
|
||||
u8 unk_17;
|
||||
void (*callbackM)();
|
||||
void (*callbackS)();
|
||||
u32 callbackID;
|
||||
union RfuPacket *txPacket;
|
||||
union RfuPacket *rxPacket;
|
||||
vu8 unk_2c;
|
||||
u8 padding[3];
|
||||
};
|
||||
|
||||
struct RfuIntrStruct
|
||||
{
|
||||
u8 rxPacketAlloc[0x74];
|
||||
u8 txPacketAlloc[0x74];
|
||||
u8 block1[0x960];
|
||||
u8 block2[0x30];
|
||||
};
|
||||
|
||||
extern struct RfuStruct *gRfuState;
|
||||
|
||||
void STWI_init_all(struct RfuIntrStruct *interruptStruct, IntrFunc *interrupt, bool8 copyInterruptToRam);
|
@ -244,8 +244,10 @@ SECTIONS {
|
||||
src/agb_flash_1m.o(.text);
|
||||
src/agb_flash_mx.o(.text);
|
||||
src/siirtc.o(.text);
|
||||
src/librfu.o(.text);
|
||||
src/librfu_stwi.o(.text);
|
||||
src/librfu_intr.o(.text);
|
||||
asm/librfu_intr.o(.text);
|
||||
src/librfu_rfu.o(.text);
|
||||
asm/librfu.o(.text);
|
||||
asm/libagbsyscall.o(.text);
|
||||
tools/agbcc/lib/libgcc.a:_call_via_rX.o(.text);
|
||||
|
4
src/librfu_intr.c
Normal file
4
src/librfu_intr.c
Normal file
@ -0,0 +1,4 @@
|
||||
#include "global.h"
|
||||
#include "main.h"
|
||||
|
||||
//TODO: decompile asm/librfu_intr.s to here
|
109
src/librfu_rfu.c
Normal file
109
src/librfu_rfu.c
Normal file
@ -0,0 +1,109 @@
|
||||
#include "global.h"
|
||||
#include "main.h"
|
||||
|
||||
#include "librfu.h"
|
||||
|
||||
struct RfuUnk1
|
||||
{
|
||||
u8 unk_0[0x14];
|
||||
u32 unk_14;
|
||||
u32 unk_18;
|
||||
struct RfuIntrStruct unk_1c;
|
||||
};
|
||||
|
||||
struct RfuUnk2
|
||||
{
|
||||
u8 unk_0[0x68];
|
||||
u32 unk_68;
|
||||
u32 unk_6c;
|
||||
u8 unk_70[0x70];
|
||||
};
|
||||
|
||||
struct RfuUnk3
|
||||
{
|
||||
u32 unk_0;
|
||||
u32 unk_4;
|
||||
u8 unk_8[0xD4];
|
||||
u32 unk_dc;
|
||||
};
|
||||
|
||||
extern u32 *gUnknown_03007890;
|
||||
extern u32 *gUnknown_03007894;
|
||||
extern struct RfuUnk3* gUnknown_03007898;
|
||||
extern struct RfuUnk2* gUnknown_03007880[4];
|
||||
extern struct RfuUnk1* gUnknown_03007870[4];
|
||||
extern void* sub_82E53F4;
|
||||
extern void rfu_STC_clearAPIVariables(void);
|
||||
|
||||
// Nonmatching, only register differences
|
||||
/*u16 rfu_initializeAPI(u32 *unk0, u16 unk1, IntrFunc *interrupt, bool8 copyInterruptToRam)
|
||||
{
|
||||
u16 i;
|
||||
u16 *v13;
|
||||
u16 *v12;
|
||||
u16 num;
|
||||
|
||||
if (((u32)unk0 & 0xF000000) == 0x2000000 && copyInterruptToRam)
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
if ((u32)unk0 & 3)
|
||||
return 2;
|
||||
|
||||
// Nintendo pls, just use a ternary for once
|
||||
if (copyInterruptToRam)
|
||||
{
|
||||
// An assert/debug print may have existed before, ie
|
||||
// printf("%s %u < %u", "somefile.c:12345", unk1, num)
|
||||
// to push this into r3?
|
||||
num = 0xe64;
|
||||
if (unk1 < num)
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (copyInterruptToRam == FALSE)
|
||||
{
|
||||
num = 0x504; // same as above, this should be r3 not r0
|
||||
if (unk1 < num)
|
||||
return 1;
|
||||
}
|
||||
gUnknown_03007890 = unk0;
|
||||
gUnknown_03007894 = unk0 + (0xB4 / sizeof(u32));
|
||||
gUnknown_03007898 = (struct RfuUnk3*)(unk0 + (0xDC / sizeof(u32)));
|
||||
gUnknown_03007880[0] = (struct RfuUnk2*)(unk0 + (0x1BC / sizeof(u32)));
|
||||
gUnknown_03007870[0] = (struct RfuUnk1*)(unk0 + (0x37C / sizeof(u32)));
|
||||
|
||||
for (i = 1; i < 4; i++, num)
|
||||
{
|
||||
gUnknown_03007880[i] = (struct RfuUnk2*)&gUnknown_03007880[i-1]->unk_70;
|
||||
gUnknown_03007870[i] = (struct RfuUnk1*)&gUnknown_03007870[i-1]->unk_1c;
|
||||
}
|
||||
|
||||
gUnknown_03007898->unk_dc = (u32)&gUnknown_03007870[3]->unk_1c;
|
||||
STWI_init_all(&gUnknown_03007870[3]->unk_1c, interrupt, copyInterruptToRam);
|
||||
rfu_STC_clearAPIVariables();
|
||||
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
gUnknown_03007880[i]->unk_68 = 0;
|
||||
gUnknown_03007880[i]->unk_6c = 0;
|
||||
gUnknown_03007870[i]->unk_14 = 0;
|
||||
gUnknown_03007870[i]->unk_18 = 0;
|
||||
}
|
||||
|
||||
// Not matching, register differences
|
||||
v12 = (u16*)((u32)&sub_82E53F4 & ~1);
|
||||
v13 = (u16*)gUnknown_03007898->unk_8;
|
||||
|
||||
for (i = 47; i != 0xFFFF; i--)
|
||||
{
|
||||
*v13 = *v12;
|
||||
++v12;
|
||||
++v13;
|
||||
}
|
||||
|
||||
gUnknown_03007898->unk_4 = (u32)(&gUnknown_03007898->unk_8[1]);
|
||||
|
||||
return 0;
|
||||
}*/
|
@ -1,111 +1,10 @@
|
||||
#include "global.h"
|
||||
#include "main.h"
|
||||
|
||||
enum
|
||||
{
|
||||
RFU_RESET = 0x10,
|
||||
RFU_LINK_STATUS,
|
||||
RFU_VERSION_STATUS,
|
||||
RFU_SYSTEM_STATUS,
|
||||
RFU_SLOT_STATUS,
|
||||
RFU_CONFIG_STATUS,
|
||||
RFU_GAME_CONFIG,
|
||||
RFU_SYSTEM_CONFIG,
|
||||
RFU_UNK18,
|
||||
RFU_SC_START,
|
||||
RFU_SC_POLLING,
|
||||
RFU_SC_END,
|
||||
RFU_SP_START,
|
||||
RFU_SP_POLLING,
|
||||
RFU_SP_END,
|
||||
RFU_CP_START,
|
||||
RFU_CP_POLLING,
|
||||
RFU_CP_END,
|
||||
RFU_UNK22,
|
||||
RFU_UNK23,
|
||||
RFU_DATA_TX,
|
||||
RFU_DATA_TX_AND_CHANGE,
|
||||
RFU_DATA_RX,
|
||||
RFU_MS_CHANGE,
|
||||
RFU_DATA_READY_AND_CHANGE,
|
||||
RFU_DISCONNECTED_AND_CHANGE,
|
||||
RFU_UNK2A,
|
||||
RFU_UNK2B,
|
||||
RFU_UNK2C,
|
||||
RFU_UNK2D,
|
||||
RFU_UNK2E,
|
||||
RFU_UNK2F,
|
||||
RFU_DISCONNECT,
|
||||
RFU_TEST_MODE,
|
||||
RFU_CPR_START,
|
||||
RFU_CPR_POLLING,
|
||||
RFU_CPR_END,
|
||||
RFU_UNK35,
|
||||
RFU_UNK36,
|
||||
RFU_RESUME_RETRANSMIT_AND_CHANGE,
|
||||
RFU_UNK38,
|
||||
RFU_UNK39,
|
||||
RFU_UNK3A,
|
||||
RFU_UNK3B,
|
||||
RFU_UNK3C,
|
||||
RFU_STOP_MODE, //3D
|
||||
};
|
||||
|
||||
struct RfuPacket8
|
||||
{
|
||||
u8 data[0x74];
|
||||
};
|
||||
|
||||
struct RfuPacket32
|
||||
{
|
||||
u32 command;
|
||||
u32 data[0x1C];
|
||||
};
|
||||
|
||||
union RfuPacket
|
||||
{
|
||||
struct RfuPacket32 rfuPacket32;
|
||||
struct RfuPacket8 rfuPacket8;
|
||||
};
|
||||
|
||||
struct RfuStruct
|
||||
{
|
||||
vs32 unk_0;
|
||||
u8 txParams;
|
||||
u8 unk_5;
|
||||
u8 activeCommand;
|
||||
u8 unk_7;
|
||||
u8 unk_8;
|
||||
u8 unk_9;
|
||||
u8 timerSelect;
|
||||
u8 unk_b;
|
||||
int timerState;
|
||||
vu8 timerActive;
|
||||
u8 unk_11;
|
||||
vu16 unk_12;
|
||||
vu8 msMode;
|
||||
u8 unk_15;
|
||||
u8 unk_16;
|
||||
u8 unk_17;
|
||||
void (*callbackM)();
|
||||
void (*callbackS)();
|
||||
u32 callbackID;
|
||||
union RfuPacket *txPacket;
|
||||
union RfuPacket *rxPacket;
|
||||
vu8 unk_2c;
|
||||
u8 padding[3];
|
||||
};
|
||||
|
||||
struct RfuIntrStruct
|
||||
{
|
||||
u8 rxPacketAlloc[0x74];
|
||||
u8 txPacketAlloc[0x74];
|
||||
u8 block1[0x960];
|
||||
u8 block2[0x30];
|
||||
};
|
||||
#include "librfu.h"
|
||||
|
||||
extern IntrFunc IntrSIO32(void);
|
||||
extern struct RfuStruct *gRfuState;
|
||||
|
||||
extern void STWI_stop_timer(void);
|
||||
|
||||
void STWI_init_Callback_M(void);
|
||||
void STWI_init_Callback_S(void);
|
||||
void STWI_set_Callback_M(void * callback);
|
||||
@ -114,7 +13,7 @@ u16 STWI_init(u8 request);
|
||||
int STWI_start_Command(void);
|
||||
void STWI_intr_timer(void);
|
||||
void STWI_set_timer(u8 unk);
|
||||
extern void STWI_stop_timer(void);
|
||||
|
||||
int STWI_restart_Command(void);
|
||||
int STWI_reset_ClockCounter(void);
|
||||
|
Loading…
Reference in New Issue
Block a user