Merge branch 'master' into fix-eventobj

This commit is contained in:
GriffinR 2020-01-19 20:21:53 -05:00
commit 4c12ad00d2
30 changed files with 3398 additions and 7590 deletions

File diff suppressed because it is too large Load Diff

View File

@ -18,7 +18,7 @@ IntrSIO32: @ 82E3554
cmp r0, 0
ldmdbeq r11, {r11,sp,lr}
bxeq lr
bl sub_82E3EB0
bl Callback_Dummy_ID
ldmdb r11, {r11,sp,lr}
bx lr
_082E3590:
@ -33,7 +33,7 @@ _082E35A8:
ldmdb r11, {r11,sp,lr}
bx lr
.align 2, 0
_082E35B4: .4byte gRfuState
_082E35B4: .4byte gSTWIStatus
arm_func_end IntrSIO32
arm_func_start sio32intr_clock_master
@ -204,10 +204,10 @@ _082E3800:
beq _082E3840
ldrh r1, [r0, 0x12]
ldrb r0, [r0, 0x6]
bl sub_82E3EA8
bl Callback_Dummy_M
b _082E3840
.align 2, 0
_082E382C: .4byte gRfuState
_082E382C: .4byte gSTWIStatus
_082E3830:
add r3, r5, 0x3
strh r3, [r4]
@ -423,7 +423,7 @@ _082E3AD4:
beq _082E3C4C
mov r0, 0x1EC
add r0, r0, 0x2
bl sub_82E3EAC
bl Callback_Dummy_S
b _082E3C4C
_082E3B48:
mov r3, 0x120
@ -445,7 +445,7 @@ _082E3B48:
ldrb r0, [r0, 0x6]
mov r1, r2
orr r0, r0, r3, lsl 8
bl sub_82E3EAC
bl Callback_Dummy_S
b _082E3C4C
_082E3B9C:
mov r3, 0x208
@ -472,7 +472,7 @@ _082E3BE4:
bhi _082E3BE4
b _082E3C20
.align 2, 0
_082E3BF4: .4byte gRfuState
_082E3BF4: .4byte gSTWIStatus
_082E3BF8: .4byte 0x996601ee
_082E3BFC:
mov r2, 0xFF00
@ -532,7 +532,7 @@ _082E3CA4:
ldmdb r11, {r11,sp,lr}
bx lr
.align 2, 0
_082E3CB8: .4byte gRfuState
_082E3CB8: .4byte gSTWIStatus
arm_func_end handshake_wait
arm_func_start STWI_set_timer_in_RAM
@ -588,7 +588,7 @@ _082E3D5C:
mov r3, 0x3
b _082E3D8C
.align 2, 0
_082E3D74: .4byte gRfuState
_082E3D74: .4byte gSTWIStatus
_082E3D78:
mvn r3, 0x850
sub r3, r3, 0x2
@ -637,7 +637,7 @@ STWI_stop_timer_in_RAM: @ 82E3DCC
ldmdb r11, {r11,sp,lr}
bx lr
.align 2, 0
_082E3E18: .4byte gRfuState
_082E3E18: .4byte gSTWIStatus
arm_func_end STWI_stop_timer_in_RAM
arm_func_start STWI_init_slave
@ -677,20 +677,20 @@ STWI_init_slave: @ 82E3E1C
ldmdb r11, {r11,sp,lr}
bx lr
.align 2, 0
_082E3EA4: .4byte gRfuState
_082E3EA4: .4byte gSTWIStatus
arm_func_end STWI_init_slave
arm_func_start sub_82E3EA8
sub_82E3EA8: @ 82E3EA8
arm_func_start Callback_Dummy_M
Callback_Dummy_M: @ 82E3EA8
bx r2
arm_func_end sub_82E3EA8
arm_func_end Callback_Dummy_M
arm_func_start sub_82E3EAC
sub_82E3EAC: @ 82E3EAC
arm_func_start Callback_Dummy_S
Callback_Dummy_S: @ 82E3EAC
bx r1
arm_func_end sub_82E3EAC
arm_func_end Callback_Dummy_S
arm_func_start sub_82E3EB0
sub_82E3EB0: @ 82E3EB0
arm_func_start Callback_Dummy_ID
Callback_Dummy_ID: @ 82E3EB0
bx r0
arm_func_end sub_82E3EB0
arm_func_end Callback_Dummy_ID

View File

@ -1,6 +0,0 @@
gUnknown_03007870
gUnknown_03007880
gUnknown_03007890
gUnknown_03007894
gUnknown_03007898
gUnknown_030078A0

View File

@ -0,0 +1,5 @@
gRfuSlotStatusUNI
gRfuSlotStatusNI
gRfuLinkStatus
gRfuStatic
gRfuFixed

View File

@ -0,0 +1 @@
gRfuSIO32Id

View File

@ -1 +1 @@
gRfuState
gSTWIStatus

View File

@ -1,17 +0,0 @@
.section .rodata
gUnknown_089A3220:: @ 89A3220
.byte 2, 14, 0, 10, 9, 5, 7, 2
.byte 0, 15, 1, 3, 3, 0, 31, 0
.byte 3, 22, 18, 14, 13, 9, 11, 3
.byte 15, 15, 1, 3, 3, 0, 0x7f, 0
.asciz "RFU_V1026"
.align 2
gUnknown_089A324C:: @ 89A324C
.asciz "RFU-MBOOT"
.align 2
gUnknown_089A3258:: @ 89A3258
.asciz "NINTENDOSio32ID_030820"

View File

@ -28,7 +28,7 @@ gSpecials:: @ 81DBA64
def_special GetSecretBaseOwnerAndState
def_special InitSecretBaseDecorationSprites
def_special SetDecoration
def_special GetEventObjectLocalIdByFlag
def_special GetObjectEventLocalIdByFlag
def_special GetSecretBaseTypeInFrontOfPlayer
def_special SetSecretBaseOwnerGfxId
def_special sub_8129708

View File

@ -240,27 +240,30 @@
#define OBJ_EVENT_GFX_LINK_RS_MAY 236
#define OBJ_EVENT_GFX_LUGIA 237
#define OBJ_EVENT_GFX_HOOH 238
#define OBJ_EVENT_GFX_BARD_2 239
#define NUM_OBJ_EVENT_GFX 239
// These are dynamic object gfx ids.
// They correspond with the values of the VAR_OBJ_GFX_ID_X vars.
// More info about them in include/constants/vars.h
#define OBJ_EVENT_GFX_VAR_0 240
#define OBJ_EVENT_GFX_VAR_1 241
#define OBJ_EVENT_GFX_VAR_2 242
#define OBJ_EVENT_GFX_VAR_3 243
#define OBJ_EVENT_GFX_VAR_4 244
#define OBJ_EVENT_GFX_VAR_5 245
#define OBJ_EVENT_GFX_VAR_6 246
#define OBJ_EVENT_GFX_VAR_7 247
#define OBJ_EVENT_GFX_VAR_8 248
#define OBJ_EVENT_GFX_VAR_9 249
#define OBJ_EVENT_GFX_VAR_A 250
#define OBJ_EVENT_GFX_VAR_B 251
#define OBJ_EVENT_GFX_VAR_C 252
#define OBJ_EVENT_GFX_VAR_D 253
#define OBJ_EVENT_GFX_VAR_E 254
#define OBJ_EVENT_GFX_VAR_F 255
#define OBJ_EVENT_GFX_VARS (NUM_OBJ_EVENT_GFX + 1)
#define OBJ_EVENT_GFX_VAR_0 (OBJ_EVENT_GFX_VARS + 0x0) // 240
#define OBJ_EVENT_GFX_VAR_1 (OBJ_EVENT_GFX_VARS + 0x1)
#define OBJ_EVENT_GFX_VAR_2 (OBJ_EVENT_GFX_VARS + 0x2)
#define OBJ_EVENT_GFX_VAR_3 (OBJ_EVENT_GFX_VARS + 0x3)
#define OBJ_EVENT_GFX_VAR_4 (OBJ_EVENT_GFX_VARS + 0x4)
#define OBJ_EVENT_GFX_VAR_5 (OBJ_EVENT_GFX_VARS + 0x5)
#define OBJ_EVENT_GFX_VAR_6 (OBJ_EVENT_GFX_VARS + 0x6)
#define OBJ_EVENT_GFX_VAR_7 (OBJ_EVENT_GFX_VARS + 0x7)
#define OBJ_EVENT_GFX_VAR_8 (OBJ_EVENT_GFX_VARS + 0x8)
#define OBJ_EVENT_GFX_VAR_9 (OBJ_EVENT_GFX_VARS + 0x9)
#define OBJ_EVENT_GFX_VAR_A (OBJ_EVENT_GFX_VARS + 0xA)
#define OBJ_EVENT_GFX_VAR_B (OBJ_EVENT_GFX_VARS + 0xB)
#define OBJ_EVENT_GFX_VAR_C (OBJ_EVENT_GFX_VARS + 0xC)
#define OBJ_EVENT_GFX_VAR_D (OBJ_EVENT_GFX_VARS + 0xD)
#define OBJ_EVENT_GFX_VAR_E (OBJ_EVENT_GFX_VARS + 0xE)
#define OBJ_EVENT_GFX_VAR_F (OBJ_EVENT_GFX_VARS + 0xF) // 255
#define SHADOW_SIZE_S 0
#define SHADOW_SIZE_M 1

View File

@ -1,9 +1,6 @@
#ifndef GUARD_EVENT_OBJECT_MOVEMENT_H
#define GUARD_EVENT_OBJECT_MOVEMENT_H
#define NUM_OBJECT_GRAPHICS_INFO 239
#define SPRITE_VAR 240
enum SpinnerRunnerFollowPatterns
{
RUNFOLLOW_ANY,

View File

@ -461,7 +461,7 @@
#define REG_DMA3CNT_L (*(vu16 *)REG_ADDR_DMA3CNT_L)
#define REG_DMA3CNT_H (*(vu16 *)REG_ADDR_DMA3CNT_H)
#define REG_TMCNT(n) (*(vu16 *)(REG_ADDR_TMCNT + ((n) * 4)))
#define REG_TMCNT(n) (*(vu32 *)(REG_ADDR_TMCNT + ((n) * 4)))
#define REG_TMCNT_L(n) (*(vu16 *)(REG_ADDR_TMCNT_L + ((n) * 4)))
#define REG_TMCNT_H(n) (*(vu16 *)(REG_ADDR_TMCNT_H + ((n) * 4)))
#define REG_TM0CNT (*(vu32 *)REG_ADDR_TM0CNT)

View File

@ -45,4 +45,6 @@ void RLUnCompVram(const void *src, void *dest);
int MultiBoot(struct MultiBootParam *mp);
s32 Div(s32 num, s32 denom);
#endif // GUARD_GBA_SYSCALL_H

View File

@ -1,58 +1,280 @@
#ifndef GUARD_LIBRFU_H
#define GUARD_LIBRFU_H
#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
};
/* TODOs:
* - documentation
* - decompile librfu_intr.s once arm support is back again
(for internal structs not documented in SDK)
* - check if any field needs to be volatile
* - check if field names make sense
*/
// --------------------------------------------------------------------------
//
// Restrictions When Using RFU
//
// --------------------------------------------------------------------------
/*
The following restrictions apply when using RFU.
<Restrictions for Direct Sound>
(a) The timer for Sound DMA uses only 0
(b) The prescaler for the timer count for the Sound DMA uses 59.5 ns.
(c) The sound sampling rate is Max36.314KHz.
<Restrictions for H-DMA or DMA started with V-Blank>
These types of DMA can be operated on a maximum CPU cycle of 42 cycles.
Calculate the number of the transferable DMA count based on this 42 cycles and the access cycles of the destination and source.
For example, if both the CPU internal RAM --> VRAM have a one cycle access, then a 21 count DMA can occur.
If RFU is used outside of these restrictions, problems, such as the loss of data caused by the failure of the AGB, as a clock slave,
to notify that data has been received from the RFU, will occur.
When this problem occurs, the REQ callback will send a REQ_commandID=ID_CLOCK_SLAVE_MS_CHANGE_ERROR_BY_DMA_REQ notification.
(When using Link Manager, the LMAN call back will send a LMAN_msg=LMAN_MSG_CLOCK_SLAVE_MS_CHANGE_ERROR_BY_DMA notification.)
*/
// REQ-COMMAND (STWI) ID CODE LIST
// REQ Command ID returned by the REQ callback
#define ID_RESET_REQ 0x0010
#define ID_LINK_STATUS_REQ 0x0011
#define ID_VERSION_STATUS_REQ 0x0012 // not defined in SDK header
#define ID_SYSTEM_STATUS_REQ 0x0013
#define ID_SLOT_STATUS_REQ 0x0014 // not defined in SDK header
#define ID_CONFIG_STATUS_REQ 0x0015 // not defined in SDK header
#define ID_GAME_CONFIG_REQ 0x0016
#define ID_SYSTEM_CONFIG_REQ 0x0017
#define ID_SC_START_REQ 0x0019
#define ID_SC_POLL_REQ 0x001a
#define ID_SC_END_REQ 0x001b
#define ID_SP_START_REQ 0x001c
#define ID_SP_POLL_REQ 0x001d
#define ID_SP_END_REQ 0x001e
#define ID_CP_START_REQ 0x001f
#define ID_CP_POLL_REQ 0x0020
#define ID_CP_END_REQ 0x0021
#define ID_DATA_TX_REQ 0x0024
#define ID_DATA_TX_AND_CHANGE_REQ 0x0025
#define ID_DATA_RX_REQ 0x0026
#define ID_MS_CHANGE_REQ 0x0027 // When returned by the REQ callback, this ID indicates that execution of rfu_REQ_changeMasterSlave has finished.
// This ID is returned by both the REQ callback and the MSC callback.
// When returned by the MSC callback, this is notification that after the AGB has been made into the clock slave, the MC_Timer expired and the RFU returned the AGB to be the clock master.
#define ID_DISCONNECT_REQ 0x0030
#define ID_TEST_MODE_REQ 0x0031 // not defined in SDK header
#define ID_CPR_START_REQ 0x0032
#define ID_CPR_POLL_REQ 0x0033
#define ID_CPR_END_REQ 0x0034
#define ID_UNK35_REQ 0x0035 // not defined in SDK header
#define ID_RESUME_RETRANSMIT_AND_CHANGE_REQ 0x0037
#define ID_STOP_MODE_REQ 0x003d
#define ID_CLOCK_SLAVE_MS_CHANGE_ERROR_BY_DMA_REQ 0x00ff // When the AGB is the clock slave, the RFU generates an informational notice, and an automatically started DMA, such as HDMA, is generated at the instant the AGB is being returned as the clock master. This ID is notified by a REQ callback when the exchange of this information (REQ command) fails.
// REQ Command ID returned by the MSC callback
#define ID_DISCONNECTED_AND_CHANGE_REQ 0x0029
#define ID_DATA_READY_AND_CHANGE_REQ 0x0028
#define ID_DRAC_REQ_WITH_ACK_FLAG 0x0128
// --------------------------------------------------------------------------
//
// Data Definitions
//
// --------------------------------------------------------------------------
#define RFU_ID 0x00008001 // ID number of AGB-RFU device: ID returned by execution of rfu_REQBN_softReset_and_checkID.
#define RFU_MBOOT_DOWNLOADER_SERIAL_NO 0x0000 // The game serial number of the multi-boot downloader (programs that boot without a Game Pak)
#define RFU_API_BUFF_SIZE_RAM 0x0e8c // Necessary size for buffer specified by rfu_initializeAPI (fast communication version that operates the library SIO interrupt routines in RAM)
#define RFU_API_BUFF_SIZE_ROM 0x052c // Necessary size for buffer specified by rfu_initializeAPI (fast communication version that operates the library SIO interrupt routines in ROM)
#define RFU_CHILD_MAX 4 // Maximum number of slaves that can be connected to one parent device
#define RFU_GAME_NAME_LENGTH 13 // Possible length of game name set by rfu_REQB_configGameData
#define RFU_USER_NAME_LENGTH 8 // Possible length of user name set by rfu_REQB_configGameData
#define RFU_H_DMA_MAX_CPU_CYCLE 42 // Maximum number of CPU cycles for H-DMA or DMA that starts with V-Blank that can operate when using RFU
// Value to determine the level of the icon that displays the link strength of the wireless status (value of rfuLinkStatus->strength[0-3])
#define RFU_LINK_ICON_LEVEL4_MAX 255 // 90% -100% (If the value is betwen 229 and 255, the icon level is 4)
#define RFU_LINK_ICON_LEVEL4_MIN 229
#define RFU_LINK_ICON_LEVEL3_MAX 228 // 50% - 89% (If the value is betwen 127 and 228, the icon level is 3)
#define RFU_LINK_ICON_LEVEL3_MIN 127
#define RFU_LINK_ICON_LEVEL2_MAX 126 // 10% - 49% (If the value is betwen 25 and 126, the icon level is 2)
#define RFU_LINK_ICON_LEVEL2_MIN 25
#define RFU_LINK_ICON_LEVEL1_MAX 24 // 0% - 9% (If the value is betwen 0 and 24, the icon level is 1)
#define RFU_LINK_ICON_LEVEL1_MIN 0
// *******************************************************
// Definition Data for Arguments Used in Library Functions
// *******************************************************
// Specified by u16 mbootFlag in rfu_REQ_configGameData
#define RFU_MBOOT_FLAG 0x01 // Enabling this flag, allows connection to a multi-boot program.
// AvailSlot (number of slots available for connection) used in u16 availSlotFlag in rfu_REQ_configSystem
#define AVAIL_SLOT4 0x0000
#define AVAIL_SLOT3 0x0001
#define AVAIL_SLOT2 0x0002
#define AVAIL_SLOT1 0x0003
// u8 connTypeFlag specified by rfu_setRecvBuffer
#define TYPE_UNI 0x10 // UNI-type
#define TYPE_NI 0x20 // NI-type
// u8 connTypeFlag specified by rfu_clearSlot
#define TYPE_UNI_SEND 0x01 // UNI-type send
#define TYPE_UNI_RECV 0x02 // UNI-type receive
#define TYPE_NI_SEND 0x04 // NI-type send
#define TYPE_NI_RECV 0x08 // NI-type receive
// *******************************************************
// Definition Data Returned by Return Values for Library Functions
// *******************************************************
// The function doesn't have return value.
// Value of u8 *status for rfu_REQ_pollConnectParent (Connection Trial Status)
// #define CP_STATUS_DONE 0x00 // Connection successful
// #define CP_STATUS_IN_PROCESS 0x01 // Connecting
// #define CP_STATUS_SLOT_CLOSED 0x02 // Parent device is not in connection mode with child device
// #define CP_STATUS_DISCONNECTED 0x03 // Disconnected by parent device while connecting
// #define CP_STATUS_UNKNOWN 0xff // Cannot read status due to REQ-API execution error
// The function doesn't exist.
// Value of u8 *status argument for rfu_REQ_pollRecoveryConnect (Link Restore Status)
// #define RC_STATUS_DONE 0x00 // Connection restore successful
// #define RC_STATUS_FAILED 0x01 // Connection restore failure (meaningless to try anymore)
// #define RC_STATUS_SEARCHING_PARENT 0x02 // Searching for parent device
// #define RC_STATUS_UNKNOWN 0xff // Cannot read status due to REQ-API execution error
// Value of u8 *linkLossReason argument for rfu_REQBN_watchLink (Reason for Link Loss)
#define REASON_DISCONNECTED 0x00 // State of complete disconnection with rfuLL_disconnect and no possibility of restoring the link (can detect only child device)
#define REASON_LINK_LOSS 0x01 // State of link loss that allows for the possibility for the link to be restored
// *******************************************************
// Definition Data Returned with Return Values for Library Functions
// *******************************************************
// Value returned by rfu_getMasterSlave
#define AGB_CLK_SLAVE 0 // AGB clock slave
#define AGB_CLK_MASTER 1 // AGB clock master
// *******************************************************
// Error Code Group for Library Functions
// *******************************************************
// Error codes returned by u16 REQ_result with a REQ callback when a REQ-API function is executed
#define ERR_REQ_CMD 0x0000
#define ERR_REQ_CMD_CLOCK_DRIFT (ERR_REQ_CMD | 0x0001) // Clock drift occurs when a REQ command is sent
#define ERR_REQ_CMD_SENDING (ERR_REQ_CMD | 0x0002) // The next command cannot be issued because a REQ command is being sent
#define ERR_REQ_CMD_ACK_REJECTION (ERR_REQ_CMD | 0x0003) // The REQ command was refused when issued
#define ERR_REQ_CMD_CLOCK_SLAVE (ERR_REQ_CMD | 0x0004) // Issuing the REQ command was attempted but failed because the AGB is the clock slave
#define ERR_REQ_CMD_IME_DISABLE (ERR_REQ_CMD | 0x0006) // Issuing the REQ command was attempted but failed because the IME register is 0
#define ERR_PID_NOT_FOUND 0x0100 // The specified PID does not exist in the gRfuLinkStatus->partner[0-3].id list
// Error code returned by the return value of rfu_initializeAPI
#define ERR_RFU_API_BUFF_SIZE 0x0001
#define ERR_RFU_API_BUFF_ADR 0x0002
// Error codes returned by return values for rfu_REQBN_softReset_and_checkID
#define ERR_ID_CHECK_IME_DISABLE 0xffffffff // ID check could not be executed because REG_IME=0 when executing rfu_REQBN_softReset_and_checkID
// Error codes returned by rfu_getConnectParentStatus and rfu_CHILD_getConnectRecoveryStatus
#define ERR_REQ_CMD_ID (ERR_REQ_CMD | 0x0010) // A required REQ command was not executed within this function execution
// Error codes returned by rfu_NI_setSendData, rfu_UNI_setSendData, and rfu_NI_CHILD_setSendGameName
#define ERR_MODE 0x0300
#define ERR_MODE_NOT_PARENT (ERR_MODE | 0x0000) // not in SDK
#define ERR_MODE_NOT_CONNECTED (ERR_MODE | 0x0001) // RFU is not in connection mode (parent or child)
#define ERR_SLOT 0x0400
#define ERR_SLOT_NO (ERR_SLOT | 0x0000) // The specified slot number is not right
#define ERR_SLOT_NOT_CONNECTED (ERR_SLOT | 0x0001) // The specified slot is not connected
#define ERR_SLOT_BUSY (ERR_SLOT | 0x0002) // The specified slot is already communicating
#define ERR_SLOT_NOT_SENDING (ERR_SLOT | 0x0003) // The specified slot is not currently sending (Note: This is returned by rfu_UNI_re_setSendData)
#define ERR_SLOT_TARGET (ERR_SLOT | 0x0004) // The specified target slot is not right
#define ERR_SUBFRAME_SIZE 0x0500 // The specified subframe size is either larger than the remaining communication frame size or smaller than the link layer subframe header size
// Error code returned by rfu_clearSlot, rfu_setRecvBuffer, and rfu_changeSendTarget
#define ERR_COMM_TYPE 0x0600 // The specified communication format is not right
// Error code returned by rfu_REQ_recvData (when receiving NI-type or UNI-type data)
#define ERR_DATA_RECV 0x0700 // Error notification is issued in the following format.
// "ERR_DATA_RECV | (slot number issuing error with 0x0010<<UNI) | (slot number issuing error with 0x0001<<NI)"
// The actual error code is stored in gRfuSlotStatusNI or gRfuSlotStatusUNI[x]->recv.errorCode.
// Error code during NI-type communication (code entered into gRfuSlotStatusNI[x]->recv.errorCode)
#define ERR_RECV_BUFF_OVER (ERR_DATA_RECV | 0x0001) // The receive data size is larger than the receive buffer (Note: This error is used for both NI and UNI)
#define ERR_RECV_REPLY_SUBFRAME_SIZE (ERR_DATA_RECV | 0x0002) // All frames are already in use by other communications, and a subframe for reception response could not be secured
// Error code during UNI-type communication (code entered into gRfuSlotStatusUNI[x]->recv.errorCode)
#define ERR_RECV_DATA_OVERWRITED (ERR_DATA_RECV | 0x0008) // Received new data when gRfuSlotStatusUNI[x]->recv.newDataFlag=1
// not in SDK header
#define ERR_RECV_UNK (ERR_DATA_RECV | 0x0001 | 0x0008)
// *******************************************************
// Definition Data Used by Global Variables in the Library
// *******************************************************
// gRfuLinkStatus-------------------------------------------
// Connection status (refer to gRfuLinkStatus->parentChild)
#define MODE_NEUTRAL 0xff // Initialization
#define MODE_CHILD 0x00 // Child
#define MODE_PARENT 0x01 // Parent
// gRfuSlotStatusNI,UNI-----------------------------------
// Definition data for NI-(Numbered Information) and UNI-(Un-Numbered Information) type communication
// Definition data common to NI- and UNI-type communication
#define LLF_P_SIZE 87 // Maximum link layer communication frame size for the Parent (Maximum number of bytes per transmission)
#define LLF_C_SIZE 16 // " " for the Child
#define LLSF_P_HEADER_SIZE 3 // Header size used by one link layer subframe (NI or UNI frame) for the Parent
#define LLSF_C_HEADER_SIZE 2 // " " for the Child
// Link Layer Communication Code
#define LCOM_NULL 0x0000
#define LCOM_NI_START 0x0001
#define LCOM_NI 0x0002
#define LCOM_NI_END 0x0003
#define LCOM_UNI 0x0004
// Flag for Slot Status Data
#define SLOT_BUSY_FLAG 0x8000 // Slot in use
#define SLOT_SEND_FLAG 0x0020 // Send
#define SLOT_RECV_FLAG 0x0040 // Receive
// NI- and UNI-type shared slot stand-by data (same state as gRfuSlotStatusNI[x]->send or ->recv.state or gRfuSlotStatusUNI)
#define SLOT_STATE_READY 0x0000 // Slot initialization
// Status data for NI-type communication (gRfuSlotStatusNI[x]->send or ->recv.state)
#define SLOT_STATE_SEND_START (SLOT_BUSY_FLAG | SLOT_SEND_FLAG | LCOM_NI_START) // Start transmission
#define SLOT_STATE_SENDING (SLOT_BUSY_FLAG | SLOT_SEND_FLAG | LCOM_NI) // Transmitting
#define SLOT_STATE_SEND_LAST (SLOT_BUSY_FLAG | SLOT_SEND_FLAG | LCOM_NI_END) // Verify transmission end
#define SLOT_STATE_SEND_NULL (SLOT_BUSY_FLAG | SLOT_SEND_FLAG | LCOM_NULL) // Send NULL subframe to notify end of transmission
#define SLOT_STATE_SEND_SUCCESS ( SLOT_SEND_FLAG | 0x006) // Transmission successful
#define SLOT_STATE_SEND_FAILED ( SLOT_SEND_FLAG | 0x007) // Transmission failed
// Distinction of slot where transmission succeeded/failed compares gRfuSlotStatusNI[x]->send.bmSlot and same bmSlot_org
#define SLOT_STATE_RECV_START (SLOT_BUSY_FLAG | SLOT_RECV_FLAG | LCOM_NI_START) // Start reception
#define SLOT_STATE_RECEIVING (SLOT_BUSY_FLAG | SLOT_RECV_FLAG | LCOM_NI) // Receiving
#define SLOT_STATE_RECV_LAST (SLOT_BUSY_FLAG | SLOT_RECV_FLAG | LCOM_NI_END) // Verify reception end
#define SLOT_STATE_RECV_SUCCESS ( SLOT_RECV_FLAG | 0x006) // Reception successful
#define SLOT_STATE_RECV_FAILED ( SLOT_RECV_FLAG | 0x007) // Reception failed
#define SLOT_STATE_RECV_SUCCESS_AND_SENDSIDE_UNKNOWN (SLOT_RECV_FLAG | 0x008) // The data was received successful, but because the end of the communication was incomplete, whether the transmission side status is successful or failed is unknown
#define SLOT_STATE_RECV_IGNORE ( SLOT_RECV_FLAG | 0x009) // Ignore reception (refer to gRfuSlotStatusNI[x]->recv.errorCode for reason for ignoring)
// Status data for UNI-type communication (refer to gRfuSlotStatusUNI[x]->send.state)
#define SLOT_STATE_SEND_UNI (SLOT_BUSY_FLAG | SLOT_SEND_FLAG | LCOM_UNI) // Transmitting
// the following structs are not documented in SDK
struct RfuPacket8
{
u8 data[0x74];
@ -70,191 +292,364 @@ union RfuPacket
struct RfuPacket8 rfuPacket8;
};
struct UnkLinkRfuStruct_02022B14Substruct
struct STWIStatus
{
u16 unk_00_0:4;
u16 unk_00_4:1;
u16 unk_00_5:1;
u16 unk_00_6:1;
u16 isChampion:1;
u16 hasNationalDex:1;
u16 gameClear:1; // never read, redundant with isChampion
u16 unk_01_2:4; // always 3?
u16 unk_01_6:2;
u8 playerTrainerId[2];
};
struct __attribute__((packed, aligned(2))) UnkLinkRfuStruct_02022B14
{
struct UnkLinkRfuStruct_02022B14Substruct unk_00;
u8 unk_04[4];
u16 species:10;
u16 type:6;
u8 unk_0a_0:7;
u8 unk_0a_7:1;
u8 playerGender:1;
u8 level:7;
u8 unk_0c;
};
struct RfuStruct
{
vs32 unk_0;
u8 txParams;
u8 unk_5;
u8 activeCommand;
u8 unk_7;
u8 unk_8;
u8 unk_9;
vs32 state;
u8 reqLength;
u8 reqNext;
u8 reqActiveCommand;
u8 ackLength;
u8 ackNext;
u8 ackActiveCommand;
u8 timerSelect;
u8 unk_b;
int timerState;
s32 timerState; // this field is u32 in firered
vu8 timerActive;
u8 unk_11;
vu16 unk_12;
vu16 error;
vu8 msMode;
u8 unk_15;
u8 recoveryCount;
u8 unk_16;
u8 unk_17;
void (*callbackM)();
void (*callbackS)();
u32 callbackID;
void (*callbackS)(u16);
void (*unk_20)(void);
union RfuPacket *txPacket;
union RfuPacket *rxPacket;
vu8 unk_2c;
u8 padding[3];
};
// This struct is used as u8 array in SDK.
struct RfuIntrStruct
{
u8 rxPacketAlloc[0x74];
u8 txPacketAlloc[0x74];
u8 block1[0x960];
u8 block2[0x30];
union RfuPacket rxPacketAlloc;
union RfuPacket txPacketAlloc;
u8 block1[0x960]; // size of librfu_intr.s binary
struct STWIStatus block2;
};
struct RfuUnk1
// Data Structure for Transmitting UNI-Type Data
struct UNISend
{
u16 unk_0;
u8 unk_2;
u8 unk_3;
u8 fill_4[14];
u8 unk_12;
u32 unk_14;
u32 unk_18;
struct RfuIntrStruct unk_1c;
u16 state; // Slot communication state (SLOT_STATE_READY, SLOT_STATE_SEND_UNI)
u8 dataReadyFlag; // Flag indicating transmission data is prepared (0: data sent; 1: transmission data ready)
// Set with rfu_UNI_re_setSendData or rfu_UNI_readySendData, cleared when data is sent with rfu_REQ_sendData.
u8 bmSlot; // Expresses transmission destination slot as bits
u16 payloadSize; // Payload size of 1 transmission. "size" specified by rfu_UNI_setSendData or rfu_UNI_re_setSendData is used.
const void *src; // Beginning address of transmission data
};
struct RfuUnk2
// Data Structure for Receiving UNI Data
struct UNIRecv
{
u16 unk_0;
u16 unk_2;
u8 fill_4[0x16];
u8 unk_1a;
u8 fill_1b[0x19];
u16 unk_34;
u16 unk_36;
u8 fill_38[0x16];
u8 unk_4e;
u8 fill_4f[0x12];
u8 unk_61;
u8 fill_62[6];
void *unk_68;
void *unk_6c;
u8 unk_70[0x70];
u16 state; // Slot communication state (SLOT_STATE_READY, SLOT_STATE_RECEIVING, SLOT_STATE_RECV_IGNORE)
u16 errorCode; // Error code during reception
u16 dataSize; // Size of receive data
u8 newDataFlag; // Flag indicating whether receive data has newly arrived (0: no newly arrived data; 1: newly arrived data)
// The flag is cleared with rfu_UNI_clearRecvNewDataFlag; it is set when data is received with rfu_REQ_recvData.
u8 dataBlockFlag; // Flag for unreferenced receive data overwrite block (default is 0 Note: not used)
};
struct RfuUnk3
// Slot Status Data Structure for UNI-Type Communication
struct RfuSlotStatusUNI
{
u32 unk_0;
u32 unk_4;
u8 unk_8[0xD4];
u32 unk_dc;
struct UNISend send; // Transmission Status
struct UNIRecv recv; // Reception Status
void *recvBuffer; // Reception Buffer Address
u32 recvBufferSize; // Reception Buffer Size
};
struct RfuUnk5Sub
#define WINDOW_COUNT 4
struct NIComm
{
u16 unk_00;
u8 unk_02;
u16 unk_04;
struct UnkLinkRfuStruct_02022B14 unk_06;
u8 fill_13[1];
u8 playerName[PLAYER_NAME_LENGTH + 1];
u16 state; // Communication state of slot
u16 failCounter; // Count of failed transmissions/receptions (Count is increased when transmission/reception of data does not succeed within 1PF=16.7 ms)
const u8 *now_p[WINDOW_COUNT]; // Address of current send/receive (The data is divided into WINDOW_COUNT blocks and sent in payloadSize units.)
// remainSize is u32 in SDK. This is a hack to match ASM
s32 remainSize; // Size of remaining communication data
u16 errorCode; // Error code
u8 bmSlot; // Expresses the current communication slot in bits
// (When sending from the Master, because multiple slaves can be specified with bmSlot, communications are terminated based on the failCounter for each child device)
// Parameters used inside the Library
u8 recvAckFlag[WINDOW_COUNT];
u8 ack;
u8 phase;
u8 n[WINDOW_COUNT];
// Parameters indicating the current communication content
const void *src; // Start address transmission data (valid only for transmitting device)
u8 bmSlotOrg; // Expresses the communication source slot at the beginning of the transmission in bits (valid only for transmitting device)
u8 dataType; // Transmission/reception data type (0: User data; 1: Game identification information)
u16 payloadSize; // Payload size for one transmission
u32 dataSize; // Size of transmission/reception data
// Calculated by subtracting link layer header size from subFrameSize specified by the rfu_NI_setSendData function
};
struct RfuUnk5
struct RfuSlotStatusNI
{
u8 unk_00;
u8 unk_01;
u8 unk_02;
u8 unk_03;
u8 unk_04;
u8 unk_05;
u8 unk_06;
u8 unk_07;
u8 unk_08;
u8 filler_09[1];
u8 unk_0a[4];
u8 filler_0e[6];
struct RfuUnk5Sub unk_14[4];
struct NIComm send; // Transmission Status
struct NIComm recv; // Reception Status
void *recvBuffer; // Reception Buffer Address
u32 recvBufferSize; // Reception Buffer Size
};
extern struct RfuStruct *gRfuState;
// Game Identification Information Data Structure
struct RfuTgtData
{
u16 id; // ID of parent candidate ID of connection partner
u8 slot; // Slot number where parent candidate can enter Connection slot number
u8 mbootFlag; // Flag to indicate whether or not the parent candidate Flag to indicate whether or not the connection partner
// is multiboot program for download is multiboot program for download
u16 serialNo; // Game serial number of parent candidate Game serial number of connection partner
u8 gname[RFU_GAME_NAME_LENGTH + 2]; // Game name of parent candidate Game name of connection partner
u8 uname[RFU_USER_NAME_LENGTH + 1]; // User name for parent candidate User name for connection partner
};
extern struct RfuUnk5 *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);
struct RfuLinkStatus
{
u8 parentChild; // Connection status (0x01:MODE_PARENT 0x00:MODE_CHILD 0xff:MODE_NEUTRAL)
u8 connCount; // Number of connections
u8 connSlotFlag; // Flag to indicate in bits the connection slot (0x01<<Connection slot number)
u8 linkLossSlotFlag; // Flag to indicate in bits the slot where the link loss was generated (")
u8 sendSlotNIFlag; // Flag to indicate in bits the slot where NI-type send is occurring (")
u8 recvSlotNIFlag; // Flag to indicate in bits the slot where NI-type receive is occurring (")
u8 sendSlotUNIFlag; // Flag to indicate in bits the slot where UNI-type send is occurring (")
u8 getNameFlag; // Parent: Flag to indicate whether or not game identification information was obtained from the child connected to this slot (")
// Child: Flag to indicate whether or not game identification information was sent to the parent connected to this slot (")
u8 findParentCount; // Number of parent candidates discovered with rfu_REQ_xxxSearchParent, valid only with a child device
u8 watchInterval; // Link monitor execution interval (16.7 ms unit AGB picture frame)
u8 strength[RFU_CHILD_MAX]; // Link strength value (0x00 - 0xff; 0x00 is link loss. Updates with rfu_REQBN_watchLink)
vu8 LLFReadyFlag; // Indicates whether the link layer frame to send next has be constructed (Flag is on when calling rfu_constructLLFrame, flag is cleared when sending by rfu_REQ_sendData.)
u8 remainLLFrameSizeParent; // Remaining size of the link layer communication frame for the parent device
u8 remainLLFrameSizeChild[RFU_CHILD_MAX]; // Remaining size of the link layer communication frame for each slot for child device
struct RfuTgtData partner[RFU_CHILD_MAX]; // Parent, Child: When there is a connection, the matrix element corresponding to the number of the connected slot
// stores the game identification information for the connection partner.
// Child: Stores the game identification information for the parent candidate discovered when executing rfu_REQ_xxxxSearchParent.
struct RfuTgtData my; // The device's own game identification information (unrelated to the element slot value)
};
void STWI_init_all(struct RfuIntrStruct *interruptStruct, IntrFunc *interrupt, bool8 copyInterruptToRam);
void rfu_REQ_stopMode(void);
void rfu_waitREQComplete(void);
// the following structs are not documented in SDK
struct RfuFixed
{
void (*reqCallback)(u16, u16);
void (*fastCopyPtr)(const u8 **, u8 **, s32);
u16 fastCopyBuffer[24];
u32 fastCopyBuffer2[12];
u32 LLFBuffer[29];
struct RfuIntrStruct *STWIBuffer;
};
struct RfuStatic
{
u8 flags;
u8 NIEndRecvFlag;
u8 recvRenewalFlag;
u8 commExistFlag;
u8 recvErrorFlag;
u8 recoveryBmSlot;
u8 nowWatchInterval;
u8 nullFrameCount;
u8 emberCount;
u8 SCStartFlag;
u8 linkEmergencyFlag[4];
u8 lsFixedCount[4];
u16 cidBak[4];
u16 unk_1a;
u16 reqResult;
u16 tryPid;
u16 watchdogTimer;
u32 totalPacketSize;
};
struct RfuSIO32Id
{
u8 unk0;
u8 unk1;
u16 unk2;
u16 unk4;
u16 unk6;
u16 unk8; // unused
u16 unkA;
};
struct RfuAPIBuffer
{
struct RfuLinkStatus linkStatus;
struct RfuStatic static_;
struct RfuFixed fixed;
struct RfuSlotStatusNI NI[RFU_CHILD_MAX];
struct RfuSlotStatusUNI UNI[RFU_CHILD_MAX];
struct RfuIntrStruct intr;
};
extern struct STWIStatus *gSTWIStatus;
extern struct RfuLinkStatus *gRfuLinkStatus;
extern struct RfuStatic *gRfuStatic;
extern struct RfuFixed *gRfuFixed;
extern struct RfuSlotStatusNI *gRfuSlotStatusNI[RFU_CHILD_MAX];
extern struct RfuSlotStatusUNI *gRfuSlotStatusUNI[RFU_CHILD_MAX];
extern struct RfuSIO32Id gRfuSIO32Id;
// librfu_s32id
s32 AgbRFU_checkID(u8);
// Arguments with "bm..." specify slots of the form (0x01 << slot number) that are the object of a function operation.
// librfu_rfu
// API Initialization and Initial Settings
// API Initialization
u16 rfu_initializeAPI(struct RfuAPIBuffer *APIBuffer, u16 buffByteSize, IntrFunc *sioIntrTable_p, bool8 copyInterruptToRam);
// Set Timer Interrupt
void rfu_setTimerInterrupt(u8 timerNo, IntrFunc *timerIntrTable_p);
// Resident Function called from within a V-Blank Interrupt
u16 rfu_syncVBlank(void);
// Specify REQ Callback function
void rfu_setREQCallback(void (*callback)(u16 reqCommandId, u16 reqResult));
// REQ-API Execution Completion Wait
u16 rfu_waitREQComplete(void);
// RFU Initialization and Initial Settings
// RFU Startup and ID Check (Forced RFU reset occurs simultaneously)
u32 rfu_REQBN_softReset_and_checkID(void);
void rfu_REQ_sendData(u8);
void rfu_setMSCCallback(void (*func)(u16));
void rfu_setREQCallback(void (*func)(u16, u16));
bool8 rfu_getMasterSlave(void);
void rfu_REQBN_watchLink(u16 a0, u8 *a1, u8 *a2, u8 *a3);
bool16 rfu_syncVBlank(void);
// RFU Reset
void rfu_REQ_reset(void);
void rfu_REQ_configSystem(u16, u8, u8);
void rfu_REQ_configGameData(u8, u16, struct UnkLinkRfuStruct_02022B14 *, u8 *);
// Set RFU to Stop Mode (Power Down)
void rfu_REQ_stopMode(void);
// RFU Hardware Settings
void rfu_REQ_configSystem(u16 availSlotFlag, u8 maxMFrame, u8 mcTimer);
// Game Identification Information Configuration
void rfu_REQ_configGameData(u8 mbootFlag, u16 serialNo, const u8 *gname, const u8 *uname);
// RFU Connection Process
// Operate as parent device; search for and connect to child device
void rfu_REQ_startSearchChild(void);
void rfu_REQ_pollSearchChild(void);
void rfu_REQ_endSearchChild(void);
// Operate as child device; search for parent device
void rfu_REQ_startSearchParent(void);
void rfu_REQ_pollSearchParent(void);
void rfu_REQ_endSearchParent(void);
void rfu_REQ_startConnectParent(u16);
// Operate as child device; connect to specified parent device
void rfu_REQ_startConnectParent(u16 pid);
void rfu_REQ_pollConnectParent(void);
void rfu_REQ_endConnectParent(void);
void rfu_REQ_CHILD_startConnectRecovery(u8);
u16 rfu_getConnectParentStatus(u8 *status,u8 *connectSlotNo);
// Restore link from child device
void rfu_REQ_CHILD_startConnectRecovery(u8 bmRecoverySlot);
void rfu_REQ_CHILD_pollConnectRecovery(void);
void rfu_REQ_CHILD_endConnectRecovery(void);
u16 rfu_CHILD_getConnectRecoveryStatus(u8 *status);
// RFU Link Management
// Link Monitoring
u16 rfu_REQBN_watchLink(u16 reqCommandId, u8 *bmLinkLossSlot, u8 *linkLossReason, u8 *parentBmLinkRecoverySlot);
// Link Disconnect
void rfu_REQ_disconnect(u8 bmDisconnectSlot);
// Relation of clock between AGB and RFU
// Switch to AGB clock slave
void rfu_REQ_changeMasterSlave(void);
void rfu_REQ_RFUStatus(void);
void rfu_getRFUStatus(u8 *status);
u8 *rfu_getSTWIRecvBuffer(void);
u8 rfu_NI_CHILD_setSendGameName(u8 a0, u8 a1);
void rfu_clearSlot(u8 a0, u8 a1);
// Acquire either the master or slave clock from the current AGB-RFU
bool8 rfu_getMasterSlave(void);
// Communication Configuration
// MSC Callback Configuration
void rfu_setMSCCallback(void (*callback)(u16 reqCommandId));
// Shared by NI- and UNI-type communications
// Clear Communication Status
void rfu_clearAllSlot(void);
bool16 rfu_CHILD_getConnectRecoveryStatus(u8 *status);
bool16 rfu_getConnectParentStatus(u8 *status, u8 *a1);
bool16 rfu_UNI_PARENT_getDRAC_ACK(u8 *a0);
void rfu_REQ_disconnect(u8 who);
void rfu_changeSendTarget(u8 a0, u8 who, u8 a2);
void rfu_NI_stopReceivingData(u8 who);
u16 rfu_initializeAPI(u32 *unk0, u16 unk1, IntrFunc *interrupt, bool8 copyInterruptToRam);
void rfu_setTimerInterrupt(u8 which, IntrFunc *intr);
void rfu_setRecvBuffer(u8 a0, u8 a1, void *a2, size_t a3);
bool16 rfu_UNI_setSendData(u8 flag, void *ptr, u8 size);
void rfu_REQ_recvData(void);
void rfu_UNI_readySendData(u8 a0);
void rfu_UNI_clearRecvNewDataFlag(u8 a0);
u16 rfu_clearSlot(u8 connTypeFlag, u8 slotStatusIndex);
// Set Receive Buffer
u16 rfu_setRecvBuffer(u8 connType, u8 slotNo, void *buffer, u32 buffSize);
// Receive/Send Data
// UNI-type communication
// Set transmission data
u16 rfu_UNI_setSendData(u8 bmSendSlot, const void *src, u8 size);
// Enable transmission data
void rfu_UNI_readySendData(u8 slotStatusIndex);
// Change address or size of transmission data and enable transmission data
u16 rfu_UNI_changeAndReadySendData(u8 slotStatusIndex, const void *src, u8 size);
// Used only by parent device. At the beginning of a MSC Callback that received notification that the data transmission completed, an ACK flag is obtained.
u16 rfu_UNI_PARENT_getDRAC_ACK(u8 *ackFlag);
// Clear the flag that indicates newly arrived reception data
void rfu_UNI_clearRecvNewDataFlag(u8 slotStatusIndex);
// NI-type Communication
// Set transmission data
u16 rfu_NI_setSendData(u8 bmSendSlot, u8 subFrameSize, const void *src, u32 size);
// Used only by child device. After establishing connection at the RFU level, configure transmission of child device game identification information in order to authenticate connection
u16 rfu_NI_CHILD_setSendGameName(u8 slotNo, u8 subFrameSize);
// Stop the NI data currently being received
u16 rfu_NI_stopReceivingData(u8 slotStatusIndex);
// Shared by NI- and UNI-type communications
// Narrow transmission targets for transmission data.
u16 rfu_changeSendTarget(u8 connType, u8 slotStatusIndex, u8 bmNewTgtSlot);
// Functions for sending/receiving data to RFU
// Data transmission
void rfu_REQ_sendData(bool8 clockChangeFlag);
// Used only by parent device. Resend previous sent data (packet)
void rfu_REQ_PARENT_resumeRetransmitAndChange(void);
void rfu_NI_setSendData(u8, u8, const void *, u32);
// Read receive data
void rfu_REQ_recvData(void);
// For Multi-boot
// Inherits the information about the link established by the downloader just after the program downloaded with multiboot starts up.
u16 rfu_MBOOT_CHILD_inheritanceLinkStatus(void);
// For Debug
// Obtain address of the SWTI-layer receive buffer
struct RfuIntrStruct *rfu_getSTWIRecvBuffer(void);
// Obtain RFU state
void rfu_REQ_RFUStatus(void);
u16 rfu_getRFUStatus(u8 *rfuState);
// Using RFU, generate noise (jamming radio waves) for other RFUs
void rfu_REQ_noise(void);
// librfu_intr
void IntrSIO32(void);
// librfu_stwi
void STWI_init_all(struct RfuIntrStruct *interruptStruct, IntrFunc *interrupt, bool8 copyInterruptToRam);
void STWI_set_MS_mode(u8 mode);
void STWI_init_Callback_M(void);
void STWI_init_Callback_S(void);
void STWI_set_Callback_M(void *callbackM);
void STWI_set_Callback_S(void (*callbackS)(u16));
void STWI_init_timer(IntrFunc *interrupt, s32 timerSelect);
void AgbRFU_SoftReset(void);
void STWI_set_Callback_ID(void (*func)(void));
u16 STWI_read_status(u8 index);
u16 STWI_poll_CommandEnd(void);
void STWI_send_DataRxREQ(void);
void STWI_send_MS_ChangeREQ(void);
void STWI_send_StopModeREQ(void);
void STWI_send_SystemStatusREQ(void);
void STWI_send_GameConfigREQ(const u8 *unk1, const u8 *data);
void STWI_send_ResetREQ(void);
void STWI_send_LinkStatusREQ(void);
void STWI_send_VersionStatusREQ(void);
void STWI_send_SlotStatusREQ(void);
void STWI_send_ConfigStatusREQ(void);
void STWI_send_ResumeRetransmitAndChangeREQ(void);
void STWI_send_SystemConfigREQ(u16 unk1, u8 unk2, u8 unk3);
void STWI_send_SC_StartREQ(void);
void STWI_send_SC_PollingREQ(void);
void STWI_send_SC_EndREQ(void);
void STWI_send_SP_StartREQ(void);
void STWI_send_SP_PollingREQ(void);
void STWI_send_SP_EndREQ(void);
void STWI_send_CP_StartREQ(u16 unk1);
void STWI_send_CP_PollingREQ(void);
void STWI_send_CP_EndREQ(void);
void STWI_send_DataTxREQ(const void *in, u8 size);
void STWI_send_DataTxAndChangeREQ(const void *in, u8 size);
void STWI_send_DataReadyAndChangeREQ(u8 unk);
void STWI_send_DisconnectedAndChangeREQ(u8 unk0, u8 unk1);
void STWI_send_DisconnectREQ(u8 unk);
void STWI_send_TestModeREQ(u8 unk0, u8 unk1);
void STWI_send_CPR_StartREQ(u16 unk0, u16 unk1, u8 unk2);
void STWI_send_CPR_PollingREQ(void);
void STWI_send_CPR_EndREQ(void);
#endif // GUARD_LIBRFU_H

View File

@ -6,6 +6,33 @@
// Exported type declarations
struct UnkLinkRfuStruct_02022B14Substruct
{
u16 unk_00_0:4;
u16 unk_00_4:1;
u16 unk_00_5:1;
u16 unk_00_6:1;
u16 isChampion:1;
u16 hasNationalDex:1;
u16 gameClear:1; // never read, redundant with isChampion
u16 unk_01_2:4; // always 3?
u16 unk_01_6:2;
u8 playerTrainerId[2];
};
struct __attribute__((packed, aligned(2))) UnkLinkRfuStruct_02022B14
{
struct UnkLinkRfuStruct_02022B14Substruct unk_00;
u8 unk_04[4];
u16 species:10;
u16 type:6;
u8 unk_0a_0:7;
u8 unk_0a_7:1;
u8 playerGender:1;
u8 level:7;
u8 unk_0c;
};
struct UnkLinkRfuStruct_02022B2C
{
u8 unk_00;

View File

@ -1,7 +1,7 @@
#ifndef GUARD_UNION_ROOM_H
#define GUARD_UNION_ROOM_H
#include "librfu.h"
#include "link_rfu.h"
// Exported type declarations

View File

@ -358,7 +358,7 @@ SECTIONS {
src/librfu_intr.o(.text);
asm/librfu_intr.o(.text);
src/librfu_rfu.o(.text);
asm/librfu.o(.text);
src/librfu_sio32id.o(.text);
src/libisagbprn.o(.text);
*libagbsyscall.a:ArcTan2.o(.text);
*libagbsyscall.a:BgAffineSet.o(.text);
@ -1235,7 +1235,8 @@ SECTIONS {
src/agb_flash_mx.o(.rodata);
src/agb_flash_le.o(.rodata);
src/siirtc.o(.rodata);
data/librfu_rodata.o(.rodata);
src/librfu_rfu.o(.rodata);
src/librfu_sio32id.o(.rodata);
*libgcc.a:_divdi3.o(.rodata);
*libgcc.a:_udivdi3.o(.rodata);
*libc.a(.rodata);

View File

@ -70,7 +70,7 @@ SECTIONS {
src/librfu_intr.o(.text);
asm/librfu_intr.o(.text);
src/librfu_rfu.o(.text);
asm/librfu.o(.text);
src/librfu_sio32id.o(.text);
*libagbsyscall.a:*.o(.text*);
*libgcc.a:*.o(.text*);
*libc.a:*.o(.text*);
@ -100,7 +100,8 @@ SECTIONS {
src/agb_flash_mx.o(.rodata);
src/agb_flash_le.o(.rodata);
src/siirtc.o(.rodata);
data/librfu_rodata.o(.rodata);
src/librfu_rfu.o(.rodata);
src/librfu_sio32id.o(.rodata);
*libgcc.a:*.o(.rodata*);
*libc.a:*.o(.rodata*);
*libc.a:*.o(.data*);

View File

@ -74,7 +74,7 @@ u16 SetFlashTimerIntr(u8 timerNum, void (**intrFunc)(void))
return 1;
sTimerNum = timerNum;
sTimerReg = &REG_TMCNT(sTimerNum);
sTimerReg = &REG_TMCNT_L(sTimerNum);
*intrFunc = FlashTimerIntr;
return 0;
}

View File

@ -163,7 +163,7 @@ IntrMain: @ 8000248
IntrMain_FoundIntr:
strh r0, [r3, OFFSET_REG_IF - 0x200]
bic r2, r2, r0
ldr r0, =gRfuState
ldr r0, =gSTWIStatus
ldr r0, [r0]
ldrb r0, [r0, 0xA]
mov r1, 0x8

View File

@ -1,362 +0,0 @@
const u32 gEventObjectPic_BrendanNormal[] = INCBIN_U32("graphics/event_objects/pics/people/brendan/walking.4bpp");
const u32 gEventObjectPic_BrendanRunning[] = INCBIN_U32("graphics/event_objects/pics/people/brendan/running.4bpp");
const u16 gEventObjectPalette8[] = INCBIN_U16("graphics/event_objects/palettes/field_object_palette_08.gbapal");
const u32 gEventObjectPic_RubySapphireBrendanNormal[] = INCBIN_U32("graphics/event_objects/pics/people/ruby_sapphire_brendan/walking.4bpp");
const u32 gEventObjectPic_RubySapphireBrendanRunning[] = INCBIN_U32("graphics/event_objects/pics/people/ruby_sapphire_brendan/running.4bpp");
const u16 gEventObjectPalette33[] = INCBIN_U16("graphics/event_objects/palettes/field_object_palette_33.gbapal");
const u16 NullPalette_8499A38[16] = {};
const u16 NullPalette_8499A58[16] = {};
const u16 NullPalette_8499A78[16] = {};
const u16 NullPalette_8499A98[16] = {};
const u16 NullPalette_8499AB8[16] = {};
const u16 NullPalette_8499AD8[16] = {};
const u16 NullPalette_8499AF8[16] = {};
const u16 NullPalette_8499B18[16] = {};
const u16 NullPalette_8499B38[16] = {};
const u16 NullPalette_8499B58[16] = {};
const u16 NullPalette_8499B78[16] = {};
const u16 NullPalette_8499B98[16] = {};
const u16 NullPalette_8499BB8[16] = {};
const u16 NullPalette_8499BD8[16] = {};
const u16 NullPalette_8499BF8[16] = {};
const u16 gEventObjectPalette9[] = INCBIN_U16("graphics/event_objects/palettes/field_object_palette_09.gbapal");
const u16 gEventObjectPalette10[] = INCBIN_U16("graphics/event_objects/palettes/field_object_palette_10.gbapal");
const u32 gEventObjectPic_BrendanFieldMove[] = INCBIN_U32("graphics/event_objects/pics/people/brendan/field_move.4bpp");
const u32 gEventObjectPic_BrendanSurfing[] = INCBIN_U32("graphics/event_objects/pics/people/brendan/surfing.4bpp");
const u32 gEventObjectPic_BrendanMachBike[] = INCBIN_U32("graphics/event_objects/pics/people/brendan/mach_bike.4bpp");
const u32 gEventObjectPic_BrendanAcroBike[] = INCBIN_U32("graphics/event_objects/pics/people/brendan/acro_bike.4bpp");
const u32 gEventObjectPic_BrendanFishing[] = INCBIN_U32("graphics/event_objects/pics/people/brendan/fishing.4bpp");
const u32 gEventObjectPic_BrendanWatering[] = INCBIN_U32("graphics/event_objects/pics/people/brendan/watering.4bpp");
const u32 gEventObjectPic_BrendanDecorating[] = INCBIN_U32("graphics/event_objects/pics/people/brendan/decorating.4bpp");
const u32 gEventObjectPic_MayDecorating[] = INCBIN_U32("graphics/event_objects/pics/people/may/decorating.4bpp");
const u32 gEventObjectPic_BrendanUnderwater[] = INCBIN_U32("graphics/event_objects/pics/people/brendan/underwater.4bpp");
const u32 gEventObjectPic_MayUnderwater[] = INCBIN_U32("graphics/event_objects/pics/people/may/underwater.4bpp");
const u16 gEventObjectPalette11[] = INCBIN_U16("graphics/event_objects/palettes/field_object_palette_11.gbapal");
const u32 gEventObjectPic_MayNormal[] = INCBIN_U32("graphics/event_objects/pics/people/may/walking.4bpp");
const u32 gEventObjectPic_MayRunning[] = INCBIN_U32("graphics/event_objects/pics/people/may/running.4bpp");
const u16 gEventObjectPalette17[] = INCBIN_U16("graphics/event_objects/palettes/field_object_palette_17.gbapal");
const u16 gEventObjectPalette18[] = INCBIN_U16("graphics/event_objects/palettes/field_object_palette_18.gbapal");
const u32 gEventObjectPic_RubySapphireMayNormal[] = INCBIN_U32("graphics/event_objects/pics/people/ruby_sapphire_may/walking.4bpp");
const u32 gEventObjectPic_RubySapphireMayRunning[] = INCBIN_U32("graphics/event_objects/pics/people/ruby_sapphire_may/running.4bpp");
const u16 gEventObjectPalette34[] = INCBIN_U16("graphics/event_objects/palettes/field_object_palette_34.gbapal");
const u16 gUnusedEventObjectPalette[] = INCBIN_U16("graphics/event_objects/palettes/unused_palette.gbapal");
const u16 NullPalette_84A54F8[16] = {};
const u16 NullPalette_84A5518[16] = {};
const u16 NullPalette_84A5538[16] = {};
const u16 NullPalette_84A5558[16] = {};
const u16 NullPalette_84A5578[16] = {};
const u16 NullPalette_84A5598[16] = {};
const u16 NullPalette_84A55B8[16] = {};
const u16 NullPalette_84A55D8[16] = {};
const u16 NullPalette_84A55F8[16] = {};
const u16 NullPalette_84A5618[16] = {};
const u16 NullPalette_84A5638[16] = {};
const u16 NullPalette_84A5658[16] = {};
const u16 NullPalette_84A5678[16] = {};
const u16 NullPalette_84A5698[16] = {};
const u32 gEventObjectPic_MayMachBike[] = INCBIN_U32("graphics/event_objects/pics/people/may/mach_bike.4bpp");
const u32 gEventObjectPic_MayAcroBike[] = INCBIN_U32("graphics/event_objects/pics/people/may/acro_bike.4bpp");
const u32 gEventObjectPic_MaySurfing[] = INCBIN_U32("graphics/event_objects/pics/people/may/surfing.4bpp");
const u32 gEventObjectPic_MayFieldMove[] = INCBIN_U32("graphics/event_objects/pics/people/may/field_move.4bpp");
const u32 gEventObjectPic_MayFishing[] = INCBIN_U32("graphics/event_objects/pics/people/may/fishing.4bpp");
const u32 gEventObjectPic_MayWatering[] = INCBIN_U32("graphics/event_objects/pics/people/may/watering.4bpp");
const u16 gEventObjectPalette0[] = INCBIN_U16("graphics/event_objects/palettes/field_object_palette_00.gbapal");
const u16 gEventObjectPalette1[] = INCBIN_U16("graphics/event_objects/palettes/field_object_palette_01.gbapal");
const u16 gEventObjectPalette2[] = INCBIN_U16("graphics/event_objects/palettes/field_object_palette_02.gbapal");
const u16 gEventObjectPalette3[] = INCBIN_U16("graphics/event_objects/palettes/field_object_palette_03.gbapal");
const u16 gEventObjectPalette4[] = INCBIN_U16("graphics/event_objects/palettes/field_object_palette_04.gbapal");
const u16 gEventObjectPalette5[] = INCBIN_U16("graphics/event_objects/palettes/field_object_palette_05.gbapal");
const u16 gEventObjectPalette6[] = INCBIN_U16("graphics/event_objects/palettes/field_object_palette_06.gbapal");
const u16 gEventObjectPalette7[] = INCBIN_U16("graphics/event_objects/palettes/field_object_palette_07.gbapal");
const u32 gEventObjectPic_NinjaBoy[] = INCBIN_U32("graphics/event_objects/pics/people/ninja_boy.4bpp");
const u32 gEventObjectPic_Twin[] = INCBIN_U32("graphics/event_objects/pics/people/twin.4bpp");
const u32 gEventObjectPic_Boy1[] = INCBIN_U32("graphics/event_objects/pics/people/boy_1.4bpp");
const u32 gEventObjectPic_Girl1[] = INCBIN_U32("graphics/event_objects/pics/people/girl_1.4bpp");
const u32 gEventObjectPic_Boy2[] = INCBIN_U32("graphics/event_objects/pics/people/boy_2.4bpp");
const u32 gEventObjectPic_Girl2[] = INCBIN_U32("graphics/event_objects/pics/people/girl_2.4bpp");
const u32 gEventObjectPic_LittleBoy[] = INCBIN_U32("graphics/event_objects/pics/people/little_boy.4bpp");
const u32 gEventObjectPic_LittleGirl[] = INCBIN_U32("graphics/event_objects/pics/people/little_girl.4bpp");
const u32 gEventObjectPic_Boy3[] = INCBIN_U32("graphics/event_objects/pics/people/boy_3.4bpp");
const u32 gEventObjectPic_Girl3[] = INCBIN_U32("graphics/event_objects/pics/people/girl_3.4bpp");
const u32 gEventObjectPic_RichBoy[] = INCBIN_U32("graphics/event_objects/pics/people/rich_boy.4bpp");
const u32 gEventObjectPic_Woman1[] = INCBIN_U32("graphics/event_objects/pics/people/woman_1.4bpp");
const u32 gEventObjectPic_FatMan[] = INCBIN_U32("graphics/event_objects/pics/people/fat_man.4bpp");
const u32 gEventObjectPic_PokefanF[] = INCBIN_U32("graphics/event_objects/pics/people/pokefan_f.4bpp");
const u32 gEventObjectPic_Man1[] = INCBIN_U32("graphics/event_objects/pics/people/man_1.4bpp");
const u32 gEventObjectPic_Woman2[] = INCBIN_U32("graphics/event_objects/pics/people/woman_2.4bpp");
const u32 gEventObjectPic_ExpertM[] = INCBIN_U32("graphics/event_objects/pics/people/expert_m.4bpp");
const u32 gEventObjectPic_ExpertF[] = INCBIN_U32("graphics/event_objects/pics/people/expert_f.4bpp");
const u32 gEventObjectPic_Man2[] = INCBIN_U32("graphics/event_objects/pics/people/man_2.4bpp");
const u32 gEventObjectPic_Woman3[] = INCBIN_U32("graphics/event_objects/pics/people/woman_3.4bpp");
const u32 gEventObjectPic_PokefanM[] = INCBIN_U32("graphics/event_objects/pics/people/pokefan_m.4bpp");
const u32 gEventObjectPic_Woman4[] = INCBIN_U32("graphics/event_objects/pics/people/woman_4.4bpp");
const u32 gEventObjectPic_Cook[] = INCBIN_U32("graphics/event_objects/pics/people/cook.4bpp");
const u32 gEventObjectPic_LinkReceptionist[] = INCBIN_U32("graphics/event_objects/pics/people/link_receptionist.4bpp");
const u32 gEventObjectPic_OldMan[] = INCBIN_U32("graphics/event_objects/pics/people/old_man.4bpp");
const u32 gEventObjectPic_OldWoman[] = INCBIN_U32("graphics/event_objects/pics/people/old_woman.4bpp");
const u32 gEventObjectPic_Camper[] = INCBIN_U32("graphics/event_objects/pics/people/camper.4bpp");
const u32 gEventObjectPic_Picnicker[] = INCBIN_U32("graphics/event_objects/pics/people/picnicker.4bpp");
const u32 gEventObjectPic_Man3[] = INCBIN_U32("graphics/event_objects/pics/people/man_3.4bpp");
const u32 gEventObjectPic_Woman5[] = INCBIN_U32("graphics/event_objects/pics/people/woman_5.4bpp");
const u32 gEventObjectPic_Youngster[] = INCBIN_U32("graphics/event_objects/pics/people/youngster.4bpp");
const u32 gEventObjectPic_BugCatcher[] = INCBIN_U32("graphics/event_objects/pics/people/bug_catcher.4bpp");
const u32 gEventObjectPic_PsychicM[] = INCBIN_U32("graphics/event_objects/pics/people/psychic_m.4bpp");
const u32 gEventObjectPic_SchoolKidM[] = INCBIN_U32("graphics/event_objects/pics/people/school_kid_m.4bpp");
const u32 gEventObjectPic_Maniac[] = INCBIN_U32("graphics/event_objects/pics/people/maniac.4bpp");
const u32 gEventObjectPic_HexManiac[] = INCBIN_U32("graphics/event_objects/pics/people/hex_maniac.4bpp");
const u32 gEventObjectPic_UnusedWoman[] = INCBIN_U32("graphics/event_objects/pics/people/unused_woman.4bpp");
const u32 gEventObjectPic_SwimmerM[] = INCBIN_U32("graphics/event_objects/pics/people/swimmer_m.4bpp");
const u32 gEventObjectPic_SwimmerF[] = INCBIN_U32("graphics/event_objects/pics/people/swimmer_f.4bpp");
const u32 gEventObjectPic_BlackBelt[] = INCBIN_U32("graphics/event_objects/pics/people/black_belt.4bpp");
const u32 gEventObjectPic_Beauty[] = INCBIN_U32("graphics/event_objects/pics/people/beauty.4bpp");
const u32 gEventObjectPic_Scientist1[] = INCBIN_U32("graphics/event_objects/pics/people/scientist_1.4bpp");
const u32 gEventObjectPic_Lass[] = INCBIN_U32("graphics/event_objects/pics/people/lass.4bpp");
const u32 gEventObjectPic_Gentleman[] = INCBIN_U32("graphics/event_objects/pics/people/gentleman.4bpp");
const u32 gEventObjectPic_Sailor[] = INCBIN_U32("graphics/event_objects/pics/people/sailor.4bpp");
const u32 gEventObjectPic_Fisherman[] = INCBIN_U32("graphics/event_objects/pics/people/fisherman.4bpp");
const u32 gEventObjectPic_RunningTriathleteM[] = INCBIN_U32("graphics/event_objects/pics/people/running_triathlete_m.4bpp");
const u32 gEventObjectPic_RunningTriathleteF[] = INCBIN_U32("graphics/event_objects/pics/people/running_triathlete_f.4bpp");
const u32 gEventObjectPic_TuberF[] = INCBIN_U32("graphics/event_objects/pics/people/tuber_f.4bpp");
const u32 gEventObjectPic_TuberM[] = INCBIN_U32("graphics/event_objects/pics/people/tuber_m.4bpp");
const u32 gEventObjectPic_Hiker[] = INCBIN_U32("graphics/event_objects/pics/people/hiker.4bpp");
const u32 gEventObjectPic_CyclingTriathleteM[] = INCBIN_U32("graphics/event_objects/pics/people/cycling_triathlete_m.4bpp");
const u32 gEventObjectPic_CyclingTriathleteF[] = INCBIN_U32("graphics/event_objects/pics/people/cycling_triathlete_f.4bpp");
const u32 gEventObjectPic_Man4[] = INCBIN_U32("graphics/event_objects/pics/people/man_4.4bpp");
const u32 gEventObjectPic_Man5[] = INCBIN_U32("graphics/event_objects/pics/people/man_5.4bpp");
const u32 gEventObjectPic_Nurse[] = INCBIN_U32("graphics/event_objects/pics/people/nurse.4bpp");
const u32 gEventObjectPic_ItemBall[] = INCBIN_U32("graphics/event_objects/pics/misc/item_ball.4bpp");
const u32 gEventObjectPic_ProfBirch[] = INCBIN_U32("graphics/event_objects/pics/people/prof_birch.4bpp");
const u32 gEventObjectPic_ReporterM[] = INCBIN_U32("graphics/event_objects/pics/people/reporter_m.4bpp");
const u32 gEventObjectPic_ReporterF[] = INCBIN_U32("graphics/event_objects/pics/people/reporter_f.4bpp");
const u32 gEventObjectPic_MauvilleOldMan1[] = INCBIN_U32("graphics/event_objects/pics/people/mauville_old_man_1.4bpp");
const u32 gEventObjectPic_MauvilleOldMan2[] = INCBIN_U32("graphics/event_objects/pics/people/mauville_old_man_2.4bpp");
const u32 gEventObjectPic_MartEmployee[] = INCBIN_U32("graphics/event_objects/pics/people/mart_employee.4bpp");
const u32 gEventObjectPic_RooftopSaleWoman[] = INCBIN_U32("graphics/event_objects/pics/people/rooftop_sale_woman.4bpp");
const u32 gEventObjectPic_Teala[] = INCBIN_U32("graphics/event_objects/pics/people/teala.4bpp");
const u32 gEventObjectPic_Artist[] = INCBIN_U32("graphics/event_objects/pics/people/artist.4bpp");
const u32 gEventObjectPic_Cameraman[] = INCBIN_U32("graphics/event_objects/pics/people/cameraman.4bpp");
const u32 gEventObjectPic_Scientist2[] = INCBIN_U32("graphics/event_objects/pics/people/scientist_2.4bpp");
const u32 gEventObjectPic_DevonEmployee[] = INCBIN_U32("graphics/event_objects/pics/people/devon_employee.4bpp");
const u32 gEventObjectPic_AquaMemberM[] = INCBIN_U32("graphics/event_objects/pics/people/team_aqua/aqua_member_m.4bpp");
const u32 gEventObjectPic_AquaMemberF[] = INCBIN_U32("graphics/event_objects/pics/people/team_aqua/aqua_member_f.4bpp");
const u32 gEventObjectPic_MagmaMemberM[] = INCBIN_U32("graphics/event_objects/pics/people/team_magma/magma_member_m.4bpp");
const u32 gEventObjectPic_MagmaMemberF[] = INCBIN_U32("graphics/event_objects/pics/people/team_magma/magma_member_f.4bpp");
const u32 gEventObjectPic_Sidney[] = INCBIN_U32("graphics/event_objects/pics/people/elite_four/sidney.4bpp");
const u32 gEventObjectPic_Phoebe[] = INCBIN_U32("graphics/event_objects/pics/people/elite_four/phoebe.4bpp");
const u32 gEventObjectPic_Glacia[] = INCBIN_U32("graphics/event_objects/pics/people/elite_four/glacia.4bpp");
const u32 gEventObjectPic_Drake[] = INCBIN_U32("graphics/event_objects/pics/people/elite_four/drake.4bpp");
const u32 gEventObjectPic_Roxanne[] = INCBIN_U32("graphics/event_objects/pics/people/gym_leaders/roxanne.4bpp");
const u32 gEventObjectPic_Brawly[] = INCBIN_U32("graphics/event_objects/pics/people/gym_leaders/brawly.4bpp");
const u32 gEventObjectPic_Wattson[] = INCBIN_U32("graphics/event_objects/pics/people/gym_leaders/wattson.4bpp");
const u32 gEventObjectPic_Flannery[] = INCBIN_U32("graphics/event_objects/pics/people/gym_leaders/flannery.4bpp");
const u32 gEventObjectPic_Norman[] = INCBIN_U32("graphics/event_objects/pics/people/gym_leaders/norman.4bpp");
const u32 gEventObjectPic_Winona[] = INCBIN_U32("graphics/event_objects/pics/people/gym_leaders/winona.4bpp");
const u32 gEventObjectPic_Liza[] = INCBIN_U32("graphics/event_objects/pics/people/gym_leaders/liza.4bpp");
const u32 gEventObjectPic_Tate[] = INCBIN_U32("graphics/event_objects/pics/people/gym_leaders/tate.4bpp");
const u32 gEventObjectPic_Wallace[] = INCBIN_U32("graphics/event_objects/pics/people/wallace.4bpp");
const u32 gEventObjectPic_Steven[] = INCBIN_U32("graphics/event_objects/pics/people/steven.4bpp");
const u32 gEventObjectPic_Wally[] = INCBIN_U32("graphics/event_objects/pics/people/wally.4bpp");
const u32 gEventObjectPic_RubySapphireLittleBoy[] = INCBIN_U32("graphics/event_objects/pics/people/rs_little_boy.4bpp");
const u32 gEventObjectPic_HotSpringsOldWoman[] = INCBIN_U32("graphics/event_objects/pics/people/hot_springs_old_woman.4bpp");
const u32 gEventObjectPic_LatiasLatios[] = INCBIN_U32("graphics/event_objects/pics/pokemon/latias_latios.4bpp");
const u32 gEventObjectPic_GameboyKid[] = INCBIN_U32("graphics/event_objects/pics/people/gameboy_kid.4bpp");
const u32 gEventObjectPic_ContestJudge[] = INCBIN_U32("graphics/event_objects/pics/people/contest_judge.4bpp");
const u32 gEventObjectPic_Archie[] = INCBIN_U32("graphics/event_objects/pics/people/team_aqua/archie.4bpp");
const u32 gEventObjectPic_Maxie[] = INCBIN_U32("graphics/event_objects/pics/people/team_magma/maxie.4bpp");
const u32 gEventObjectPic_Kyogre[] = INCBIN_U32("graphics/event_objects/pics/pokemon/kyogre.4bpp");
const u32 gEventObjectPic_Groudon[] = INCBIN_U32("graphics/event_objects/pics/pokemon/groudon.4bpp");
const u32 gEventObjectPic_Regi[] = INCBIN_U32("graphics/event_objects/pics/pokemon/regi.4bpp");
const u32 gEventObjectPic_Skitty[] = INCBIN_U32("graphics/event_objects/pics/pokemon/skitty.4bpp");
const u32 gEventObjectPic_Kecleon[] = INCBIN_U32("graphics/event_objects/pics/pokemon/kecleon.4bpp");
const u32 gEventObjectPic_Rayquaza[] = INCBIN_U32("graphics/event_objects/pics/pokemon/rayquaza.4bpp");
const u32 gEventObjectPic_RayquazaStill[] = INCBIN_U32("graphics/event_objects/pics/pokemon/rayquaza_still.4bpp");
const u32 gEventObjectPic_Zigzagoon[] = INCBIN_U32("graphics/event_objects/pics/pokemon/zigzagoon.4bpp");
const u32 gEventObjectPic_Pikachu[] = INCBIN_U32("graphics/event_objects/pics/pokemon/pikachu.4bpp");
const u32 gEventObjectPic_Azumarill[] = INCBIN_U32("graphics/event_objects/pics/pokemon/azumarill.4bpp");
const u32 gEventObjectPic_Wingull[] = INCBIN_U32("graphics/event_objects/pics/pokemon/wingull.4bpp");
const u32 gEventObjectPic_TuberMSwimming[] = INCBIN_U32("graphics/event_objects/pics/people/tuber_m_swimming.4bpp");
const u32 gEventObjectPic_Azurill[] = INCBIN_U32("graphics/event_objects/pics/pokemon/azurill.4bpp");
const u32 gEventObjectPic_Mom[] = INCBIN_U32("graphics/event_objects/pics/people/mom.4bpp");
const u16 gEventObjectPalette22[] = INCBIN_U16("graphics/event_objects/palettes/field_object_palette_22.gbapal");
const u16 gEventObjectPalette23[] = INCBIN_U16("graphics/event_objects/palettes/field_object_palette_23.gbapal");
const u16 gEventObjectPalette24[] = INCBIN_U16("graphics/event_objects/palettes/field_object_palette_24.gbapal");
const u16 gEventObjectPalette25[] = INCBIN_U16("graphics/event_objects/palettes/field_object_palette_25.gbapal");
const u32 gEventObjectPic_UnusedNatuDoll[] = INCBIN_U32("graphics/event_objects/pics/dolls/unused_natu_doll.4bpp");
const u32 gEventObjectPic_UnusedMagnemiteDoll[] = INCBIN_U32("graphics/event_objects/pics/dolls/unused_magnemite_doll.4bpp");
const u32 gEventObjectPic_UnusedSquirtleDoll[] = INCBIN_U32("graphics/event_objects/pics/dolls/unused_squirtle_doll.4bpp");
const u32 gEventObjectPic_UnusedWooperDoll[] = INCBIN_U32("graphics/event_objects/pics/dolls/unused_wooper_doll.4bpp");
const u32 gEventObjectPic_UnusedPikachuDoll[] = INCBIN_U32("graphics/event_objects/pics/dolls/unused_pikachu_doll.4bpp");
const u32 gEventObjectPic_UnusedPorygon2Doll[] = INCBIN_U32("graphics/event_objects/pics/dolls/unused_porygon2_doll.4bpp");
const u32 gEventObjectPic_PichuDoll[] = INCBIN_U32("graphics/event_objects/pics/dolls/pichu_doll.4bpp");
const u32 gEventObjectPic_PikachuDoll[] = INCBIN_U32("graphics/event_objects/pics/dolls/pikachu_doll.4bpp");
const u32 gEventObjectPic_MarillDoll[] = INCBIN_U32("graphics/event_objects/pics/dolls/marill_doll.4bpp");
const u32 gEventObjectPic_TogepiDoll[] = INCBIN_U32("graphics/event_objects/pics/dolls/togepi_doll.4bpp");
const u32 gEventObjectPic_CyndaquilDoll[] = INCBIN_U32("graphics/event_objects/pics/dolls/cyndaquil_doll.4bpp");
const u32 gEventObjectPic_ChikoritaDoll[] = INCBIN_U32("graphics/event_objects/pics/dolls/chikorita_doll.4bpp");
const u32 gEventObjectPic_TotodileDoll[] = INCBIN_U32("graphics/event_objects/pics/dolls/totodile_doll.4bpp");
const u32 gEventObjectPic_JigglypuffDoll[] = INCBIN_U32("graphics/event_objects/pics/dolls/jigglypuff_doll.4bpp");
const u32 gEventObjectPic_MeowthDoll[] = INCBIN_U32("graphics/event_objects/pics/dolls/meowth_doll.4bpp");
const u32 gEventObjectPic_ClefairyDoll[] = INCBIN_U32("graphics/event_objects/pics/dolls/clefairy_doll.4bpp");
const u32 gEventObjectPic_DittoDoll[] = INCBIN_U32("graphics/event_objects/pics/dolls/ditto_doll.4bpp");
const u32 gEventObjectPic_SmoochumDoll[] = INCBIN_U32("graphics/event_objects/pics/dolls/smoochum_doll.4bpp");
const u32 gEventObjectPic_TreeckoDoll[] = INCBIN_U32("graphics/event_objects/pics/dolls/treecko_doll.4bpp");
const u32 gEventObjectPic_TorchicDoll[] = INCBIN_U32("graphics/event_objects/pics/dolls/torchic_doll.4bpp");
const u32 gEventObjectPic_MudkipDoll[] = INCBIN_U32("graphics/event_objects/pics/dolls/mudkip_doll.4bpp");
const u32 gEventObjectPic_DuskullDoll[] = INCBIN_U32("graphics/event_objects/pics/dolls/duskull_doll.4bpp");
const u32 gEventObjectPic_WynautDoll[] = INCBIN_U32("graphics/event_objects/pics/dolls/wynaut_doll.4bpp");
const u32 gEventObjectPic_BaltoyDoll[] = INCBIN_U32("graphics/event_objects/pics/dolls/baltoy_doll.4bpp");
const u32 gEventObjectPic_KecleonDoll[] = INCBIN_U32("graphics/event_objects/pics/dolls/kecleon_doll.4bpp");
const u32 gEventObjectPic_AzurillDoll[] = INCBIN_U32("graphics/event_objects/pics/dolls/azurill_doll.4bpp");
const u32 gEventObjectPic_SkittyDoll[] = INCBIN_U32("graphics/event_objects/pics/dolls/skitty_doll.4bpp");
const u32 gEventObjectPic_SwabluDoll[] = INCBIN_U32("graphics/event_objects/pics/dolls/swablu_doll.4bpp");
const u32 gEventObjectPic_GulpinDoll[] = INCBIN_U32("graphics/event_objects/pics/dolls/gulpin_doll.4bpp");
const u32 gEventObjectPic_LotadDoll[] = INCBIN_U32("graphics/event_objects/pics/dolls/lotad_doll.4bpp");
const u32 gEventObjectPic_SeedotDoll[] = INCBIN_U32("graphics/event_objects/pics/dolls/seedot_doll.4bpp");
const u32 gEventObjectPic_PikaCushion[] = INCBIN_U32("graphics/event_objects/pics/cushions/pika_cushion.4bpp");
const u32 gEventObjectPic_RoundCushion[] = INCBIN_U32("graphics/event_objects/pics/cushions/round_cushion.4bpp");
const u32 gEventObjectPic_KissCushion[] = INCBIN_U32("graphics/event_objects/pics/cushions/kiss_cushion.4bpp");
const u32 gEventObjectPic_ZigzagCushion[] = INCBIN_U32("graphics/event_objects/pics/cushions/zigzag_cushion.4bpp");
const u32 gEventObjectPic_SpinCushion[] = INCBIN_U32("graphics/event_objects/pics/cushions/spin_cushion.4bpp");
const u32 gEventObjectPic_DiamondCushion[] = INCBIN_U32("graphics/event_objects/pics/cushions/diamond_cushion.4bpp");
const u32 gEventObjectPic_BallCushion[] = INCBIN_U32("graphics/event_objects/pics/cushions/ball_cushion.4bpp");
const u32 gEventObjectPic_GrassCushion[] = INCBIN_U32("graphics/event_objects/pics/cushions/grass_cushion.4bpp");
const u32 gEventObjectPic_FireCushion[] = INCBIN_U32("graphics/event_objects/pics/cushions/fire_cushion.4bpp");
const u32 gEventObjectPic_WaterCushion[] = INCBIN_U32("graphics/event_objects/pics/cushions/water_cushion.4bpp");
const u32 gEventObjectPic_BigSnorlaxDoll[] = INCBIN_U32("graphics/event_objects/pics/dolls/big_snorlax_doll.4bpp");
const u32 gEventObjectPic_BigRhydonDoll[] = INCBIN_U32("graphics/event_objects/pics/dolls/big_rhydon_doll.4bpp");
const u32 gEventObjectPic_BigLaprasDoll[] = INCBIN_U32("graphics/event_objects/pics/dolls/big_lapras_doll.4bpp");
const u32 gEventObjectPic_BigVenusaurDoll[] = INCBIN_U32("graphics/event_objects/pics/dolls/big_venusaur_doll.4bpp");
const u32 gEventObjectPic_BigCharizardDoll[] = INCBIN_U32("graphics/event_objects/pics/dolls/big_charizard_doll.4bpp");
const u32 gEventObjectPic_BigBlastoiseDoll[] = INCBIN_U32("graphics/event_objects/pics/dolls/big_blastoise_doll.4bpp");
const u32 gEventObjectPic_BigWailmerDoll[] = INCBIN_U32("graphics/event_objects/pics/dolls/big_wailmer_doll.4bpp");
const u32 gEventObjectPic_BigRegirockDoll[] = INCBIN_U32("graphics/event_objects/pics/dolls/big_regirock_doll.4bpp");
const u32 gEventObjectPic_BigRegiceDoll[] = INCBIN_U32("graphics/event_objects/pics/dolls/big_regice_doll.4bpp");
const u32 gEventObjectPic_BigRegisteelDoll[] = INCBIN_U32("graphics/event_objects/pics/dolls/big_registeel_doll.4bpp");
const u32 gEventObjectPic_CuttableTree[] = INCBIN_U32("graphics/event_objects/pics/misc/cuttable_tree.4bpp");
const u32 gEventObjectPic_BreakableRock[] = INCBIN_U32("graphics/event_objects/pics/misc/breakable_rock.4bpp");
const u32 gEventObjectPic_PushableBoulder[] = INCBIN_U32("graphics/event_objects/pics/misc/pushable_boulder.4bpp");
const u32 gEventObjectPic_MrBrineysBoat[] = INCBIN_U32("graphics/event_objects/pics/misc/mr_brineys_boat.4bpp");
const u32 gEventObjectPic_Fossil[] = INCBIN_U32("graphics/event_objects/pics/misc/fossil.4bpp");
const u32 gEventObjectPic_SubmarineShadow[] = INCBIN_U32("graphics/event_objects/pics/misc/submarine_shadow.4bpp");
const u16 gEventObjectPalette26[] = INCBIN_U16("graphics/event_objects/palettes/field_object_palette_26.gbapal");
const u32 gEventObjectPic_Truck[] = INCBIN_U32("graphics/event_objects/pics/misc/truck.4bpp");
const u16 gEventObjectPalette14[] = INCBIN_U16("graphics/event_objects/palettes/field_object_palette_14.gbapal");
const u32 gEventObjectPic_Vigoroth[] = INCBIN_U32("graphics/event_objects/pics/pokemon/vigoroth.4bpp");
const u16 gEventObjectPalette15[] = INCBIN_U16("graphics/event_objects/palettes/field_object_palette_15.gbapal");
const u32 gEventObjectPic_BirchsBag[] = INCBIN_U32("graphics/event_objects/pics/misc/birchs_bag.4bpp");
const u32 gEventObjectPic_EnemyZigzagoon[] = INCBIN_U32("graphics/event_objects/pics/pokemon/enemy_zigzagoon.4bpp");
const u16 gEventObjectPalette16[] = INCBIN_U16("graphics/event_objects/palettes/field_object_palette_16.gbapal");
const u32 gEventObjectPic_Poochyena[] = INCBIN_U32("graphics/event_objects/pics/pokemon/poochyena.4bpp");
const u16 gEventObjectPalette27[] = INCBIN_U16("graphics/event_objects/palettes/field_object_palette_27.gbapal");
const u32 gEventObjectPic_CableCar[] = INCBIN_U32("graphics/event_objects/pics/misc/cable_car.4bpp");
const u16 gEventObjectPalette20[] = INCBIN_U16("graphics/event_objects/palettes/field_object_palette_20.gbapal");
const u32 gEventObjectPic_SSTidal[] = INCBIN_U32("graphics/event_objects/pics/misc/ss_tidal.4bpp");
const u16 gEventObjectPalette21[] = INCBIN_U16("graphics/event_objects/palettes/field_object_palette_21.gbapal");
const u32 gFieldEffectObjectPic_BerryTreeGrowthSparkle[] = INCBIN_U32("graphics/event_objects/pics/effects/berry_tree_growth_sparkle.4bpp");
const u32 gEventObjectPic_BerryTreeDirtPile[] = INCBIN_U32("graphics/event_objects/pics/berry_trees/dirt_pile.4bpp");
const u32 gEventObjectPic_BerryTreeSprout[] = INCBIN_U32("graphics/event_objects/pics/berry_trees/sprout.4bpp");
const u32 gEventObjectPic_PechaBerryTree[] = INCBIN_U32("graphics/event_objects/pics/berry_trees/pecha.4bpp");
const u32 gEventObjectPic_KelpsyBerryTree[] = INCBIN_U32("graphics/event_objects/pics/berry_trees/kelpsy.4bpp");
const u32 gEventObjectPic_WepearBerryTree[] = INCBIN_U32("graphics/event_objects/pics/berry_trees/wepear.4bpp");
const u32 gEventObjectPic_IapapaBerryTree[] = INCBIN_U32("graphics/event_objects/pics/berry_trees/iapapa.4bpp");
const u32 gEventObjectPic_CheriBerryTree[] = INCBIN_U32("graphics/event_objects/pics/berry_trees/cheri.4bpp");
const u32 gEventObjectPic_FigyBerryTree[] = INCBIN_U32("graphics/event_objects/pics/berry_trees/figy.4bpp");
const u32 gEventObjectPic_MagoBerryTree[] = INCBIN_U32("graphics/event_objects/pics/berry_trees/mago.4bpp");
const u32 gEventObjectPic_LumBerryTree[] = INCBIN_U32("graphics/event_objects/pics/berry_trees/lum.4bpp");
const u32 gEventObjectPic_RazzBerryTree[] = INCBIN_U32("graphics/event_objects/pics/berry_trees/razz.4bpp");
const u32 gEventObjectPic_GrepaBerryTree[] = INCBIN_U32("graphics/event_objects/pics/berry_trees/grepa.4bpp");
const u32 gEventObjectPic_RabutaBerryTree[] = INCBIN_U32("graphics/event_objects/pics/berry_trees/rabuta.4bpp");
const u32 gEventObjectPic_NomelBerryTree[] = INCBIN_U32("graphics/event_objects/pics/berry_trees/nomel.4bpp");
const u32 gEventObjectPic_LeppaBerryTree[] = INCBIN_U32("graphics/event_objects/pics/berry_trees/leppa.4bpp");
const u32 gEventObjectPic_LiechiBerryTree[] = INCBIN_U32("graphics/event_objects/pics/berry_trees/liechi.4bpp");
const u32 gEventObjectPic_HondewBerryTree[] = INCBIN_U32("graphics/event_objects/pics/berry_trees/hondew.4bpp");
const u32 gEventObjectPic_AguavBerryTree[] = INCBIN_U32("graphics/event_objects/pics/berry_trees/aguav.4bpp");
const u32 gEventObjectPic_WikiBerryTree[] = INCBIN_U32("graphics/event_objects/pics/berry_trees/wiki.4bpp");
const u32 gEventObjectPic_PomegBerryTree[] = INCBIN_U32("graphics/event_objects/pics/berry_trees/pomeg.4bpp");
const u32 gEventObjectPic_RawstBerryTree[] = INCBIN_U32("graphics/event_objects/pics/berry_trees/rawst.4bpp");
const u32 gEventObjectPic_SpelonBerryTree[] = INCBIN_U32("graphics/event_objects/pics/berry_trees/spelon.4bpp");
const u32 gEventObjectPic_ChestoBerryTree[] = INCBIN_U32("graphics/event_objects/pics/berry_trees/chesto.4bpp");
const u32 gEventObjectPic_OranBerryTree[] = INCBIN_U32("graphics/event_objects/pics/berry_trees/oran.4bpp");
const u32 gEventObjectPic_PersimBerryTree[] = INCBIN_U32("graphics/event_objects/pics/berry_trees/persim.4bpp");
const u32 gEventObjectPic_SitrusBerryTree[] = INCBIN_U32("graphics/event_objects/pics/berry_trees/sitrus.4bpp");
const u32 gEventObjectPic_AspearBerryTree[] = INCBIN_U32("graphics/event_objects/pics/berry_trees/aspear.4bpp");
const u32 gEventObjectPic_PamtreBerryTree[] = INCBIN_U32("graphics/event_objects/pics/berry_trees/pamtre.4bpp");
const u32 gEventObjectPic_CornnBerryTree[] = INCBIN_U32("graphics/event_objects/pics/berry_trees/cornn.4bpp");
const u32 gEventObjectPic_LansatBerryTree[] = INCBIN_U32("graphics/event_objects/pics/berry_trees/lansat.4bpp");
const u32 gEventObjectPic_DurinBerryTree[] = INCBIN_U32("graphics/event_objects/pics/berry_trees/durin.4bpp");
const u32 gEventObjectPic_TamatoBerryTree[] = INCBIN_U32("graphics/event_objects/pics/berry_trees/tamato.4bpp");
const u32 gFieldEffectObjectPic_SurfBlob[] = INCBIN_U32("graphics/event_objects/pics/effects/surf_blob.4bpp");
const u32 gEventObjectPic_QuintyPlump[] = INCBIN_U32("graphics/event_objects/pics/people/quinty_plump.4bpp");
const u16 gEventObjectPalette12[] = INCBIN_U16("graphics/event_objects/palettes/field_object_palette_12.gbapal");
const u16 gEventObjectPalette13[] = INCBIN_U16("graphics/event_objects/palettes/field_object_palette_13.gbapal");
const u32 gFieldEffectObjectPic_ShadowSmall[] = INCBIN_U32("graphics/event_objects/pics/effects/shadow_small.4bpp");
const u32 gFieldEffectObjectPic_ShadowMedium[] = INCBIN_U32("graphics/event_objects/pics/effects/shadow_medium.4bpp");
const u32 gFieldEffectObjectPic_ShadowLarge[] = INCBIN_U32("graphics/event_objects/pics/effects/shadow_large.4bpp");
const u32 gFieldEffectObjectPic_ShadowExtraLarge[] = INCBIN_U32("graphics/event_objects/pics/effects/shadow_extra_large.4bpp");
const u32 filler_8368A08[0x48] = {};
const u8 gFieldEffectPic_CutGrass[] = INCBIN_U8("graphics/event_objects/pics/effects/cut_grass.4bpp");
const u32 gFieldEffectPic_CutGrass_Copy[] = INCBIN_U32("graphics/event_objects/pics/effects/cut_grass.4bpp");
const u16 gFieldEffectObjectPalette6[] = INCBIN_U16("graphics/event_objects/palettes/field_effect_object_palette_06.gbapal");
const u32 gFieldEffectObjectPic_Ripple[] = INCBIN_U32("graphics/event_objects/pics/effects/ripple.4bpp");
const u32 gFieldEffectObjectPic_Ash[] = INCBIN_U32("graphics/event_objects/pics/effects/ash.4bpp");
const u32 gFieldEffectObjectPic_Arrow[] = INCBIN_U32("graphics/event_objects/pics/effects/arrow.4bpp");
const u16 gFieldEffectObjectPalette0[] = INCBIN_U16("graphics/event_objects/palettes/field_effect_object_palette_00.gbapal");
const u16 gFieldEffectObjectPalette1[] = INCBIN_U16("graphics/event_objects/palettes/field_effect_object_palette_01.gbapal");
const u32 gFieldEffectObjectPic_GroundImpactDust[] = INCBIN_U32("graphics/event_objects/pics/effects/ground_impact_dust.4bpp");
const u32 gFieldEffectObjectPic_BikeHopTallGrass[] = INCBIN_U32("graphics/event_objects/pics/effects/bike_hop_tall_grass.4bpp");
const u32 gUnusedGrass[] = INCBIN_U32("graphics/event_objects/pics/effects/unused_grass.4bpp");
const u32 gFieldEffectObjectPic_Unknown16[] = INCBIN_U32("graphics/event_objects/pics/effects/unknown_16.4bpp");
const u32 gFieldEffectObjectPic_Unknown17[] = INCBIN_U32("graphics/event_objects/pics/effects/unknown_17.4bpp");
const u32 gFieldEffectObjectPic_Unknown18[] = INCBIN_U32("graphics/event_objects/pics/effects/unknown_18.4bpp");
const u32 gFieldEffectObjectPic_LongGrass[] = INCBIN_U32("graphics/event_objects/pics/effects/long_grass.4bpp");
const u32 gFieldEffectObjectPic_TallGrass[] = INCBIN_U32("graphics/event_objects/pics/effects/tall_grass.4bpp");
const u32 gFieldEffectObjectPic_ShortGrass[] = INCBIN_U32("graphics/event_objects/pics/effects/short_grass.4bpp");
const u32 gFieldEffectObjectPic_SandFootprints[] = INCBIN_U32("graphics/event_objects/pics/effects/sand_footprints.4bpp");
const u32 gFieldEffectObjectPic_DeepSandFootprints[] = INCBIN_U32("graphics/event_objects/pics/effects/deep_sand_footprints.4bpp");
const u32 gFieldEffectObjectPic_BikeTireTracks[] = INCBIN_U32("graphics/event_objects/pics/effects/bike_tire_tracks.4bpp");
const u32 gFieldEffectObjectPic_Unknown19[] = INCBIN_U32("graphics/event_objects/pics/effects/unknown_19.4bpp");
const u32 gFieldEffectObjectPic_Unknown29[] = INCBIN_U32("graphics/event_objects/pics/effects/unknown_29.4bpp");
const u32 gFieldEffectObjectPic_BikeHopBigSplash[] = INCBIN_U32("graphics/event_objects/pics/effects/bike_hop_big_splash.4bpp");
const u32 gFieldEffectObjectPic_Splash[] = INCBIN_U32("graphics/event_objects/pics/effects/splash.4bpp");
const u32 gFieldEffectObjectPic_BikeHopSmallSplash[] = INCBIN_U32("graphics/event_objects/pics/effects/bike_hop_small_splash.4bpp");
const u32 gFieldEffectObjectPic_Unknown20[] = INCBIN_U32("graphics/event_objects/pics/effects/unknown_20.4bpp");
const u32 gFieldEffectObjectPic_TreeDisguise[] = INCBIN_U32("graphics/event_objects/pics/effects/tree_disguise.4bpp");
const u32 gFieldEffectObjectPic_MountainDisguise[] = INCBIN_U32("graphics/event_objects/pics/effects/mountain_disguise.4bpp");
const u32 gFieldEffectObjectPic_SandDisguisePlaceholder[] = INCBIN_U32("graphics/event_objects/pics/effects/sand_disguise_placeholder.4bpp");
const u32 gFieldEffectObjectPic_HotSpringsWater[] = INCBIN_U32("graphics/event_objects/pics/effects/hot_springs_water.4bpp");
const u16 gFieldEffectObjectPalette2[] = INCBIN_U16("graphics/event_objects/palettes/field_effect_object_palette_02.gbapal");
const u32 gFieldEffectObjectPic_JumpOutOfAsh[] = INCBIN_U32("graphics/event_objects/pics/effects/jump_out_of_ash.4bpp");
const u32 gFieldEffectObjectPic_LavaridgeGymWarp[] = INCBIN_U32("graphics/event_objects/pics/effects/lavaridge_gym_warp.4bpp");
const u32 gFieldEffectObjectPic_Bubbles[] = INCBIN_U32("graphics/event_objects/pics/effects/bubbles.4bpp");
const u32 gFieldEffectObjectPic_Unknown35[] = INCBIN_U32("graphics/event_objects/pics/effects/unknown_35.4bpp");
const u16 gFieldEffectObjectPalette3[] = INCBIN_U16("graphics/event_objects/palettes/field_effect_object_palette_03.gbapal");
const u32 gFieldEffectObjectPic_Bird[] = INCBIN_U32("graphics/event_objects/pics/effects/bird.4bpp");
const u32 gEventObjectPic_Juan[] = INCBIN_U32("graphics/event_objects/pics/people/gym_leaders/juan.4bpp");
const u32 gEventObjectPic_Scott[] = INCBIN_U32("graphics/event_objects/pics/people/scott.4bpp");
const u32 gEventObjectPic_Statue[] = INCBIN_U32("graphics/event_objects/pics/misc/statue.4bpp");
const u32 gEventObjectPic_Kirlia[] = INCBIN_U32("graphics/event_objects/pics/pokemon/kirlia.4bpp");
const u32 gEventObjectPic_Dusclops[] = INCBIN_U32("graphics/event_objects/pics/pokemon/dusclops.4bpp");
const u32 gEventObjectPic_MysteryEventDeliveryman[] = INCBIN_U32("graphics/event_objects/pics/people/mystery_event_deliveryman.4bpp");
const u32 gEventObjectPic_UnionRoomAttendant[] = INCBIN_U32("graphics/event_objects/pics/people/union_room_attendant.4bpp");
const u32 gEventObjectPic_MovingBox[] = INCBIN_U32("graphics/event_objects/pics/misc/moving_box.4bpp");
const u16 gEventObjectPalette19[] = INCBIN_U16("graphics/event_objects/palettes/field_object_palette_19.gbapal");
const u32 gEventObjectPic_Sudowoodo[] = INCBIN_U32("graphics/event_objects/pics/pokemon/sudowoodo.4bpp");
const u32 gEventObjectPic_Mew[] = INCBIN_U32("graphics/event_objects/pics/pokemon/mew.4bpp");
const u16 gEventObjectPalette28[] = INCBIN_U16("graphics/event_objects/palettes/field_object_palette_28.gbapal");
const u32 gEventObjectPic_Red[] = INCBIN_U32("graphics/event_objects/pics/people/red.4bpp");
const u32 gEventObjectPic_Leaf[] = INCBIN_U32("graphics/event_objects/pics/people/leaf.4bpp");
const u16 gEventObjectPalette30[] = INCBIN_U16("graphics/event_objects/palettes/field_object_palette_30.gbapal");
const u32 gEventObjectPic_BirthIslandStone[] = INCBIN_U32("graphics/event_objects/pics/misc/birth_island_stone.4bpp");
const u16 gEventObjectPalette29[] = INCBIN_U16("graphics/event_objects/palettes/field_object_palette_29.gbapal");
const u32 gEventObjectPic_Deoxys[] = INCBIN_U32("graphics/event_objects/pics/pokemon/deoxys.4bpp");
const u32 gEventObjectPic_Anabel[] = INCBIN_U32("graphics/event_objects/pics/people/frontier_brains/anabel.4bpp");
const u32 gEventObjectPic_Tucker[] = INCBIN_U32("graphics/event_objects/pics/people/frontier_brains/tucker.4bpp");
const u32 gEventObjectPic_Spenser[] = INCBIN_U32("graphics/event_objects/pics/people/frontier_brains/spenser.4bpp");
const u32 gEventObjectPic_Greta[] = INCBIN_U32("graphics/event_objects/pics/people/frontier_brains/greta.4bpp");
const u32 gEventObjectPic_Noland[] = INCBIN_U32("graphics/event_objects/pics/people/frontier_brains/noland.4bpp");
const u32 gEventObjectPic_Lucy[] = INCBIN_U32("graphics/event_objects/pics/people/frontier_brains/lucy.4bpp");
const u32 gEventObjectPic_Brandon[] = INCBIN_U32("graphics/event_objects/pics/people/frontier_brains/brandon.4bpp");
const u32 gEventObjectPic_Lugia[] = INCBIN_U32("graphics/event_objects/pics/pokemon/lugia.4bpp");
const u16 gEventObjectPalette32[] = INCBIN_U16("graphics/event_objects/palettes/field_object_palette_32.gbapal");
const u32 gEventObjectPic_HoOh[] = INCBIN_U32("graphics/event_objects/pics/pokemon/ho_oh.4bpp");
const u16 gEventObjectPalette31[] = INCBIN_U16("graphics/event_objects/palettes/field_object_palette_31.gbapal");

View File

@ -2155,7 +2155,7 @@ void sub_8129708(void)
}
// Unused
void GetEventObjectLocalIdByFlag(void)
void GetObjectEventLocalIdByFlag(void)
{
u8 i;

View File

@ -1861,27 +1861,29 @@ const struct ObjectEventGraphicsInfo *GetObjectEventGraphicsInfo(u8 graphicsId)
{
u8 bard;
if (graphicsId >= SPRITE_VAR)
if (graphicsId >= OBJ_EVENT_GFX_VARS)
{
graphicsId = VarGetObjectEventGraphicsId(graphicsId - SPRITE_VAR);
graphicsId = VarGetObjectEventGraphicsId(graphicsId - OBJ_EVENT_GFX_VARS);
}
if (graphicsId == OBJ_EVENT_GFX_BARD)
{
bard = GetCurrentMauvilleOldMan();
return gMauvilleOldManGraphicsInfoPointers[bard];
}
if (graphicsId >= NUM_OBJECT_GRAPHICS_INFO)
if (graphicsId >= NUM_OBJ_EVENT_GFX)
{
graphicsId = OBJ_EVENT_GFX_NINJA_BOY;
}
return gObjectEventGraphicsInfoPointers[graphicsId];
}
static void SetObjectEventDynamicGraphicsId(struct ObjectEvent *objectEvent)
{
if (objectEvent->graphicsId >= SPRITE_VAR)
if (objectEvent->graphicsId >= OBJ_EVENT_GFX_VARS)
{
objectEvent->graphicsId = VarGetObjectEventGraphicsId(objectEvent->graphicsId - SPRITE_VAR);
objectEvent->graphicsId = VarGetObjectEventGraphicsId(objectEvent->graphicsId - OBJ_EVENT_GFX_VARS);
}
}

View File

@ -1,9 +0,0 @@
#include "global.h"
#include "librfu.h"
struct RfuUnk1* gUnknown_03007870[4];
struct RfuUnk2* gUnknown_03007880[4];
struct RfuUnk5 *gUnknown_03007890;
u32 *gUnknown_03007894;
struct RfuUnk3* gUnknown_03007898;
u8 gUnknown_030078A0[12];

File diff suppressed because it is too large Load Diff

164
src/librfu_sio32id.c Normal file
View File

@ -0,0 +1,164 @@
#include "librfu.h"
static void Sio32IDIntr(void);
static void Sio32IDInit(void);
static s32 Sio32IDMain(void);
struct RfuSIO32Id gRfuSIO32Id;
static const u16 Sio32ConnectionData[] = { 0x494e, 0x544e, 0x4e45, 0x4f44 }; // NINTENDO
static const char Sio32IDLib_Var[] = "Sio32ID_030820";
s32 AgbRFU_checkID(u8 r5)
{
u16 r8;
vu16 *r4;
s32 r6;
if (REG_IME == 0)
return -1;
r8 = REG_IE;
gSTWIStatus->state = 10;
STWI_set_Callback_ID(Sio32IDIntr);
Sio32IDInit();
r4 = &REG_TMCNT_L(gSTWIStatus->timerSelect);
r5 *= 8;
while (--r5 != 0xFF)
{
r6 = Sio32IDMain();
if (r6 != 0)
break;
r4[1] = 0;
r4[0] = 0;
r4[1] = TIMER_1024CLK | TIMER_ENABLE;
while (r4[0] < 32)
;
r4[1] = 0;
r4[0] = 0;
}
REG_IME = 0;
REG_IE = r8;
REG_IME = 1;
gSTWIStatus->state = 0;
STWI_set_Callback_ID(NULL);
return r6;
}
static void Sio32IDInit(void)
{
REG_IME = 0;
REG_IE &= ~((8 << gSTWIStatus->timerSelect) | INTR_FLAG_SERIAL);
REG_IME = 1;
REG_RCNT = 0;
REG_SIOCNT = SIO_32BIT_MODE;
REG_SIOCNT |= SIO_INTR_ENABLE | SIO_ENABLE;
CpuFill32(0, &gRfuSIO32Id, sizeof(struct RfuSIO32Id));
REG_IF = INTR_FLAG_SERIAL;
}
static s32 Sio32IDMain(void)
{
u8 r12;
switch (r12 = gRfuSIO32Id.unk1)
{
case 0:
gRfuSIO32Id.unk0 = 1;
REG_SIOCNT |= SIO_38400_BPS;
REG_IME = r12;
REG_IE |= INTR_FLAG_SERIAL;
REG_IME = 1;
gRfuSIO32Id.unk1 = 1;
*(vu8 *)&REG_SIOCNT |= SIO_ENABLE;
break;
case 1:
if (gRfuSIO32Id.unkA == 0)
{
if (gRfuSIO32Id.unk0 == 1)
{
if (gRfuSIO32Id.unk2 == 0)
{
REG_IME = gRfuSIO32Id.unk2;
REG_SIOCNT |= SIO_ENABLE;
REG_IME = r12;
}
}
else if (gRfuSIO32Id.unk4 != 0x8001 && !gRfuSIO32Id.unk2)
{
REG_IME = gRfuSIO32Id.unk2;
REG_IE &= ~INTR_FLAG_SERIAL;
REG_IME = r12;
REG_SIOCNT = gRfuSIO32Id.unk2;
REG_SIOCNT = SIO_32BIT_MODE;
REG_IF = INTR_FLAG_SERIAL;
REG_SIOCNT |= SIO_INTR_ENABLE | SIO_ENABLE;
REG_IME = gRfuSIO32Id.unk2;
REG_IE |= INTR_FLAG_SERIAL;
REG_IME = r12;
}
break;
}
else
{
gRfuSIO32Id.unk1 = 2;
// fallthrough
}
default:
return gRfuSIO32Id.unkA;
}
return 0;
}
static void Sio32IDIntr(void)
{
u32 r5;
u16 r0;
#ifndef NONMATCHING
register u32 r1 asm("r1");
register u16 r0_ asm("r0");
#else
u32 r1;
u16 r0_;
#endif
r5 = REG_SIODATA32;
if (gRfuSIO32Id.unk0 != 1)
REG_SIOCNT |= SIO_ENABLE;
r1 = 16 * gRfuSIO32Id.unk0; // to handle side effect of inline asm
r1 = (r5 << r1) >> 16;
r5 = (r5 << 16 * (1 - gRfuSIO32Id.unk0)) >> 16;
if (gRfuSIO32Id.unkA == 0)
{
if (r1 == gRfuSIO32Id.unk6)
{
if (gRfuSIO32Id.unk2 > 3)
{
gRfuSIO32Id.unkA = r5;
}
else if (r1 == (u16)~gRfuSIO32Id.unk4)
{
r0_ = ~gRfuSIO32Id.unk6;
if (r5 == r0_)
++gRfuSIO32Id.unk2;
}
}
else
{
gRfuSIO32Id.unk2 = gRfuSIO32Id.unkA;
}
}
if (gRfuSIO32Id.unk2 < 4)
gRfuSIO32Id.unk4 = *(gRfuSIO32Id.unk2 + Sio32ConnectionData);
else
gRfuSIO32Id.unk4 = 0x8001;
gRfuSIO32Id.unk6 = ~r5;
REG_SIODATA32 = (gRfuSIO32Id.unk4 << 16 * (1 - gRfuSIO32Id.unk0))
+ (gRfuSIO32Id.unk6 << 16 * gRfuSIO32Id.unk0);
if (gRfuSIO32Id.unk0 == 1 && (gRfuSIO32Id.unk2 || r5 == 0x494E))
{
for (r0 = 0; r0 < 600; ++r0)
;
if (gRfuSIO32Id.unkA == 0)
REG_SIOCNT |= SIO_ENABLE;
}
}

View File

@ -1,70 +1,57 @@
#include "global.h"
#include "librfu.h"
struct RfuStruct *gRfuState;
static void STWI_intr_timer(void);
static u16 STWI_init(u8 request);
static s32 STWI_start_Command(void);
static void STWI_set_timer(u8 unk);
static void STWI_stop_timer(void);
static s32 STWI_restart_Command(void);
static s32 STWI_reset_ClockCounter(void);
extern IntrFunc IntrSIO32(void);
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);
void STWI_set_Callback_S(void * callback);
u16 STWI_init(u8 request);
int STWI_start_Command(void);
void STWI_intr_timer(void);
void STWI_set_timer(u8 unk);
int STWI_restart_Command(void);
int STWI_reset_ClockCounter(void);
struct STWIStatus *gSTWIStatus;
void STWI_init_all(struct RfuIntrStruct *interruptStruct, IntrFunc *interrupt, bool8 copyInterruptToRam)
{
// If we're copying our interrupt into RAM, DMA it to block1 and use
// block2 for our RfuStruct, otherwise block1 holds the RfuStruct.
// block2 for our STWIStatus, otherwise block1 holds the STWIStatus.
// interrupt usually is a pointer to gIntrTable[1]
if (copyInterruptToRam == TRUE)
{
*interrupt = (IntrFunc)interruptStruct->block1;
DmaCopy16(3, &IntrSIO32, interruptStruct->block1, 0x960);
gRfuState = (struct RfuStruct*)interruptStruct->block2;
DmaCopy16(3, &IntrSIO32, interruptStruct->block1, sizeof(interruptStruct->block1));
gSTWIStatus = &interruptStruct->block2;
}
else
{
*interrupt = (IntrFunc)IntrSIO32;
gRfuState = (struct RfuStruct*)interruptStruct->block1;
*interrupt = IntrSIO32;
gSTWIStatus = (struct STWIStatus *)interruptStruct->block1;
}
gRfuState->rxPacket = (union RfuPacket*)interruptStruct->rxPacketAlloc;
gRfuState->txPacket = (union RfuPacket*)interruptStruct->txPacketAlloc;
gRfuState->msMode = 1;
gRfuState->unk_0 = 0;
gRfuState->txParams = 0;
gRfuState->unk_5 = 0;
gRfuState->unk_7 = 0;
gRfuState->unk_8 = 0;
gRfuState->unk_9 = 0;
gRfuState->timerState = 0;
gRfuState->timerActive = 0;
gRfuState->unk_12 = 0;
gRfuState->unk_15 = 0;
gRfuState->unk_2c = 0;
REG_RCNT = 0x100; //TODO: mystery bit?
gSTWIStatus->rxPacket = &interruptStruct->rxPacketAlloc;
gSTWIStatus->txPacket = &interruptStruct->txPacketAlloc;
gSTWIStatus->msMode = 1;
gSTWIStatus->state = 0;
gSTWIStatus->reqLength = 0;
gSTWIStatus->reqNext = 0;
gSTWIStatus->ackLength = 0;
gSTWIStatus->ackNext = 0;
gSTWIStatus->ackActiveCommand = 0;
gSTWIStatus->timerState = 0;
gSTWIStatus->timerActive = 0;
gSTWIStatus->error = 0;
gSTWIStatus->recoveryCount = 0;
gSTWIStatus->unk_2c = 0;
REG_RCNT = 0x100; // TODO: mystery bit?
REG_SIOCNT = SIO_INTR_ENABLE | SIO_32BIT_MODE | SIO_115200_BPS;
STWI_init_Callback_M();
STWI_init_Callback_S();
IntrEnable(INTR_FLAG_SERIAL);
}
void STWI_init_timer(IntrFunc *interrupt, int timerSelect)
void STWI_init_timer(IntrFunc *interrupt, s32 timerSelect)
{
*interrupt = STWI_intr_timer;
gRfuState->timerSelect = timerSelect;
IntrEnable(INTR_FLAG_TIMER0 << gRfuState->timerSelect);
gSTWIStatus->timerSelect = timerSelect;
IntrEnable(INTR_FLAG_TIMER0 << gSTWIStatus->timerSelect);
}
void AgbRFU_SoftReset(void)
@ -74,35 +61,34 @@ void AgbRFU_SoftReset(void)
REG_RCNT = 0x8000;
REG_RCNT = 0x80A0; // all these bits are undocumented
timerL = &REG_TMCNT_L(gRfuState->timerSelect);
timerH = &REG_TMCNT_H(gRfuState->timerSelect);
timerL = &REG_TMCNT_L(gSTWIStatus->timerSelect);
timerH = &REG_TMCNT_H(gSTWIStatus->timerSelect);
*timerH = 0;
*timerL = 0;
*timerH = 0x83;
*timerH = TIMER_ENABLE | TIMER_1024CLK;
while (*timerL <= 0x11)
REG_RCNT = 0x80A2;
*timerH = 3;
REG_RCNT = 0x80A0;
REG_SIOCNT = SIO_INTR_ENABLE | SIO_32BIT_MODE | SIO_115200_BPS;
gRfuState->unk_0 = 0;
gRfuState->txParams = 0;
gRfuState->unk_5 = 0;
gRfuState->activeCommand = 0;
gRfuState->unk_7 = 0;
gRfuState->unk_8 = 0;
gRfuState->unk_9 = 0;
gRfuState->timerState = 0;
gRfuState->timerActive = 0;
gRfuState->unk_12 = 0;
gRfuState->msMode = 1;
gRfuState->unk_15 = 0;
gRfuState->unk_2c = 0;
gSTWIStatus->state = 0;
gSTWIStatus->reqLength = 0;
gSTWIStatus->reqNext = 0;
gSTWIStatus->reqActiveCommand = 0;
gSTWIStatus->ackLength = 0;
gSTWIStatus->ackNext = 0;
gSTWIStatus->ackActiveCommand = 0;
gSTWIStatus->timerState = 0;
gSTWIStatus->timerActive = 0;
gSTWIStatus->error = 0;
gSTWIStatus->msMode = 1;
gSTWIStatus->recoveryCount = 0;
gSTWIStatus->unk_2c = 0;
}
void STWI_set_MS_mode(u8 mode)
{
gRfuState->msMode = mode;
gSTWIStatus->msMode = mode;
}
u16 STWI_read_status(u8 index)
@ -110,13 +96,13 @@ u16 STWI_read_status(u8 index)
switch (index)
{
case 0:
return gRfuState->unk_12;
return gSTWIStatus->error;
case 1:
return gRfuState->msMode;
return gSTWIStatus->msMode;
case 2:
return gRfuState->unk_0;
return gSTWIStatus->state;
case 3:
return gRfuState->activeCommand;
return gSTWIStatus->reqActiveCommand;
default:
return 0xFFFF;
}
@ -124,136 +110,130 @@ u16 STWI_read_status(u8 index)
void STWI_init_Callback_M(void)
{
STWI_set_Callback_M(0);
STWI_set_Callback_M(NULL);
}
void STWI_init_Callback_S(void)
{
STWI_set_Callback_S(0);
STWI_set_Callback_S(NULL);
}
void STWI_set_Callback_M(void *callback)
// The callback can take 2 or 3 arguments.
void STWI_set_Callback_M(void *callbackM)
{
gRfuState->callbackM = callback;
gSTWIStatus->callbackM = callbackM;
}
void STWI_set_Callback_S(void *callback)
void STWI_set_Callback_S(void (*callbackS)(u16))
{
gRfuState->callbackS = callback;
gSTWIStatus->callbackS = callbackS;
}
void STWI_set_Callback_ID(u32 id)
void STWI_set_Callback_ID(void (*func)(void)) // name in SDK, but is actually setting a function pointer
{
gRfuState->callbackID = id;
gSTWIStatus->unk_20 = func;
}
u16 STWI_poll_CommandEnd(void)
{
while (gRfuState->unk_2c == TRUE)
while (gSTWIStatus->unk_2c == TRUE)
;
return gRfuState->unk_12;
return gSTWIStatus->error;
}
void STWI_send_ResetREQ(void)
{
if (!STWI_init(RFU_RESET))
if (!STWI_init(ID_RESET_REQ))
{
gRfuState->txParams = 0;
gSTWIStatus->reqLength = 0;
STWI_start_Command();
}
}
void STWI_send_LinkStatusREQ(void)
{
if (!STWI_init(RFU_LINK_STATUS))
if (!STWI_init(ID_LINK_STATUS_REQ))
{
gRfuState->txParams = 0;
gSTWIStatus->reqLength = 0;
STWI_start_Command();
}
}
void STWI_send_VersionStatusREQ(void)
{
if (!STWI_init(RFU_VERSION_STATUS))
if (!STWI_init(ID_VERSION_STATUS_REQ))
{
gRfuState->txParams = 0;
gSTWIStatus->reqLength = 0;
STWI_start_Command();
}
}
void STWI_send_SystemStatusREQ(void)
{
if (!STWI_init(RFU_SYSTEM_STATUS))
if (!STWI_init(ID_SYSTEM_STATUS_REQ))
{
gRfuState->txParams = 0;
gSTWIStatus->reqLength = 0;
STWI_start_Command();
}
}
void STWI_send_SlotStatusREQ(void)
{
if (!STWI_init(RFU_SLOT_STATUS))
if (!STWI_init(ID_SLOT_STATUS_REQ))
{
gRfuState->txParams = 0;
gSTWIStatus->reqLength = 0;
STWI_start_Command();
}
}
void STWI_send_ConfigStatusREQ(void)
{
if (!STWI_init(RFU_CONFIG_STATUS))
if (!STWI_init(ID_CONFIG_STATUS_REQ))
{
gRfuState->txParams = 0;
gSTWIStatus->reqLength = 0;
STWI_start_Command();
}
}
void STWI_send_GameConfigREQ(u8 * unk1, u8 *data)
void STWI_send_GameConfigREQ(const u8 *unk1, const u8 *data)
{
u8 *packetBytes;
int i;
s32 i;
if (!STWI_init(RFU_GAME_CONFIG))
if (!STWI_init(ID_GAME_CONFIG_REQ))
{
gRfuState->txParams = 6;
//TODO: what is unk1
packetBytes = gRfuState->txPacket->rfuPacket8.data;
gSTWIStatus->reqLength = 6;
// TODO: what is unk1
packetBytes = gSTWIStatus->txPacket->rfuPacket8.data;
packetBytes += sizeof(u32);
*(u16*)packetBytes = *(u16*)unk1;
*(u16 *)packetBytes = *(u16 *)unk1;
packetBytes += sizeof(u16);
unk1 += sizeof(u16);
for (i = 0; i < 14; i++)
for (i = 0; i < 14; ++i)
{
*packetBytes = *unk1;
packetBytes++;
unk1++;
++packetBytes;
++unk1;
}
for (i = 0; i < 8; i++)
for (i = 0; i < 8; ++i)
{
*packetBytes = *data;
packetBytes++;
data++;
++packetBytes;
++data;
}
STWI_start_Command();
}
}
void STWI_send_SystemConfigREQ(u16 unk1, u8 unk2, u8 unk3)
{
if (!STWI_init(RFU_SYSTEM_CONFIG))
if (!STWI_init(ID_SYSTEM_CONFIG_REQ))
{
u8 *packetBytes;
gRfuState->txParams = 1;
packetBytes = gRfuState->txPacket->rfuPacket8.data;
gSTWIStatus->reqLength = 1;
packetBytes = gSTWIStatus->txPacket->rfuPacket8.data;
packetBytes += sizeof(u32);
*packetBytes++ = unk3;
*packetBytes++ = unk2;
*(u16*)packetBytes = unk1;
@ -263,206 +243,196 @@ void STWI_send_SystemConfigREQ(u16 unk1, u8 unk2, u8 unk3)
void STWI_send_SC_StartREQ(void)
{
if (!STWI_init(RFU_SC_START))
if (!STWI_init(ID_SC_START_REQ))
{
gRfuState->txParams = 0;
gSTWIStatus->reqLength = 0;
STWI_start_Command();
}
}
void STWI_send_SC_PollingREQ(void)
{
if (!STWI_init(RFU_SC_POLLING))
if (!STWI_init(ID_SC_POLL_REQ))
{
gRfuState->txParams = 0;
gSTWIStatus->reqLength = 0;
STWI_start_Command();
}
}
void STWI_send_SC_EndREQ(void)
{
if (!STWI_init(RFU_SC_END))
if (!STWI_init(ID_SC_END_REQ))
{
gRfuState->txParams = 0;
gSTWIStatus->reqLength = 0;
STWI_start_Command();
}
}
void STWI_send_SP_StartREQ(void)
{
if (!STWI_init(RFU_SP_START))
if (!STWI_init(ID_SP_START_REQ))
{
gRfuState->txParams = 0;
gSTWIStatus->reqLength = 0;
STWI_start_Command();
}
}
void STWI_send_SP_PollingREQ(void)
{
if (!STWI_init(RFU_SP_POLLING))
if (!STWI_init(ID_SP_POLL_REQ))
{
gRfuState->txParams = 0;
gSTWIStatus->reqLength = 0;
STWI_start_Command();
}
}
void STWI_send_SP_EndREQ(void)
{
if (!STWI_init(RFU_SP_END))
if (!STWI_init(ID_SP_END_REQ))
{
gRfuState->txParams = 0;
gSTWIStatus->reqLength = 0;
STWI_start_Command();
}
}
void STWI_send_CP_StartREQ(u16 unk1)
{
if (!STWI_init(RFU_CP_START))
if (!STWI_init(ID_CP_START_REQ))
{
gRfuState->txParams = 1;
gRfuState->txPacket->rfuPacket32.data[0] = unk1;
gSTWIStatus->reqLength = 1;
gSTWIStatus->txPacket->rfuPacket32.data[0] = unk1;
STWI_start_Command();
}
}
void STWI_send_CP_PollingREQ(void)
{
if (!STWI_init(RFU_CP_POLLING))
if (!STWI_init(ID_CP_POLL_REQ))
{
gRfuState->txParams = 0;
gSTWIStatus->reqLength = 0;
STWI_start_Command();
}
}
void STWI_send_CP_EndREQ(void)
{
if (!STWI_init(RFU_CP_END))
if (!STWI_init(ID_CP_END_REQ))
{
gRfuState->txParams = 0;
gSTWIStatus->reqLength = 0;
STWI_start_Command();
}
}
void STWI_send_DataTxREQ(void *in, u8 size)
void STWI_send_DataTxREQ(const void *in, u8 size)
{
if (!STWI_init(RFU_DATA_TX))
if (!STWI_init(ID_DATA_TX_REQ))
{
u8 txParams = (size / sizeof(u32));
u8 reqLength = (size / sizeof(u32));
if (size & (sizeof(u32) - 1))
txParams += 1;
gRfuState->txParams = txParams;
CpuCopy32(in, gRfuState->txPacket->rfuPacket32.data, gRfuState->txParams * sizeof(u32));
reqLength += 1;
gSTWIStatus->reqLength = reqLength;
CpuCopy32(in, gSTWIStatus->txPacket->rfuPacket32.data, gSTWIStatus->reqLength * sizeof(u32));
STWI_start_Command();
}
}
void STWI_send_DataTxAndChangeREQ(void *in, u8 size)
void STWI_send_DataTxAndChangeREQ(const void *in, u8 size)
{
if (!STWI_init(RFU_DATA_TX_AND_CHANGE))
if (!STWI_init(ID_DATA_TX_AND_CHANGE_REQ))
{
u8 txParams = (size / sizeof(u32));
u8 reqLength = (size / sizeof(u32));
if (size & (sizeof(u32) - 1))
txParams += 1;
gRfuState->txParams = txParams;
CpuCopy32(in, gRfuState->txPacket->rfuPacket32.data, gRfuState->txParams * sizeof(u32));
reqLength += 1;
gSTWIStatus->reqLength = reqLength;
CpuCopy32(in, gSTWIStatus->txPacket->rfuPacket32.data, gSTWIStatus->reqLength * sizeof(u32));
STWI_start_Command();
}
}
void STWI_send_DataRxREQ(void)
{
if (!STWI_init(RFU_DATA_RX))
if (!STWI_init(ID_DATA_RX_REQ))
{
gRfuState->txParams = 0;
gSTWIStatus->reqLength = 0;
STWI_start_Command();
}
}
void STWI_send_MS_ChangeREQ(void)
{
if (!STWI_init(RFU_MS_CHANGE))
if (!STWI_init(ID_MS_CHANGE_REQ))
{
gRfuState->txParams = 0;
gSTWIStatus->reqLength = 0;
STWI_start_Command();
}
}
void STWI_send_DataReadyAndChangeREQ(u8 unk)
{
if (!STWI_init(RFU_DATA_READY_AND_CHANGE))
if (!STWI_init(ID_DATA_READY_AND_CHANGE_REQ))
{
if (!unk)
{
gRfuState->txParams = 0;
gSTWIStatus->reqLength = 0;
}
else
{
u8 *packetBytes;
gRfuState->txParams = 1;
packetBytes = gRfuState->txPacket->rfuPacket8.data;
gSTWIStatus->reqLength = 1;
packetBytes = gSTWIStatus->txPacket->rfuPacket8.data;
packetBytes += sizeof(u32);
*packetBytes++ = unk;
*packetBytes++ = 0;
*packetBytes++ = 0;
*packetBytes = 0;
}
STWI_start_Command();
}
}
void STWI_send_DisconnectedAndChangeREQ(u8 unk0, u8 unk1)
{
if (!STWI_init(RFU_DISCONNECTED_AND_CHANGE))
if (!STWI_init(ID_DISCONNECTED_AND_CHANGE_REQ))
{
u8 *packetBytes;
gRfuState->txParams = 1;
packetBytes = gRfuState->txPacket->rfuPacket8.data;
gSTWIStatus->reqLength = 1;
packetBytes = gSTWIStatus->txPacket->rfuPacket8.data;
packetBytes += sizeof(u32);
*packetBytes++ = unk0;
*packetBytes++ = unk1;
*packetBytes++ = 0;
*packetBytes = 0;
STWI_start_Command();
}
}
void STWI_send_ResumeRetransmitAndChangeREQ(void)
{
if (!STWI_init(RFU_RESUME_RETRANSMIT_AND_CHANGE))
if (!STWI_init(ID_RESUME_RETRANSMIT_AND_CHANGE_REQ))
{
gRfuState->txParams = 0;
gSTWIStatus->reqLength = 0;
STWI_start_Command();
}
}
void STWI_send_DisconnectREQ(u8 unk)
{
if (!STWI_init(RFU_DISCONNECT))
if (!STWI_init(ID_DISCONNECT_REQ))
{
gRfuState->txParams = 1;
gRfuState->txPacket->rfuPacket32.data[0] = unk;
gSTWIStatus->reqLength = 1;
gSTWIStatus->txPacket->rfuPacket32.data[0] = unk;
STWI_start_Command();
}
}
void STWI_send_TestModeREQ(u8 unk0, u8 unk1)
{
if (!STWI_init(RFU_TEST_MODE))
if (!STWI_init(ID_TEST_MODE_REQ))
{
gRfuState->txParams = 1;
gRfuState->txPacket->rfuPacket32.data[0] = unk0 | (unk1 << 8);
gSTWIStatus->reqLength = 1;
gSTWIStatus->txPacket->rfuPacket32.data[0] = unk0 | (unk1 << 8);
STWI_start_Command();
}
}
@ -472,218 +442,206 @@ void STWI_send_CPR_StartREQ(u16 unk0, u16 unk1, u8 unk2)
u32 *packetData;
u32 arg1;
if (!STWI_init(RFU_CPR_START))
if (!STWI_init(ID_CPR_START_REQ))
{
gRfuState->txParams = 2;
gSTWIStatus->reqLength = 2;
arg1 = unk1 | (unk0 << 16);
packetData = gRfuState->txPacket->rfuPacket32.data;
packetData = gSTWIStatus->txPacket->rfuPacket32.data;
packetData[0] = arg1;
packetData[1] = unk2;
STWI_start_Command();
}
}
void STWI_send_CPR_PollingREQ(void)
{
if (!STWI_init(RFU_CPR_POLLING))
if (!STWI_init(ID_CPR_POLL_REQ))
{
gRfuState->txParams = 0;
gSTWIStatus->reqLength = 0;
STWI_start_Command();
}
}
void STWI_send_CPR_EndREQ(void)
{
if (!STWI_init(RFU_CPR_END))
if (!STWI_init(ID_CPR_END_REQ))
{
gRfuState->txParams = 0;
gSTWIStatus->reqLength = 0;
STWI_start_Command();
}
}
void STWI_send_StopModeREQ(void)
{
if (!STWI_init(RFU_STOP_MODE))
if (!STWI_init(ID_STOP_MODE_REQ))
{
gRfuState->txParams = 0;
gSTWIStatus->reqLength = 0;
STWI_start_Command();
}
}
void STWI_intr_timer(void)
static void STWI_intr_timer(void)
{
switch (gRfuState->timerState)
switch (gSTWIStatus->timerState)
{
//TODO: Make an enum for these
case 2:
gRfuState->timerActive = 1;
STWI_set_timer(50);
break;
case 1:
case 4:
STWI_stop_timer();
STWI_restart_Command();
break;
case 3:
gRfuState->timerActive = 1;
STWI_stop_timer();
STWI_reset_ClockCounter();
if (gRfuState->callbackM)
gRfuState->callbackM(255, 0);
break;
// TODO: Make an enum for these
case 2:
gSTWIStatus->timerActive = 1;
STWI_set_timer(50);
break;
case 1:
case 4:
STWI_stop_timer();
STWI_restart_Command();
break;
case 3:
gSTWIStatus->timerActive = 1;
STWI_stop_timer();
STWI_reset_ClockCounter();
if (gSTWIStatus->callbackM != NULL)
gSTWIStatus->callbackM(255, 0);
break;
}
}
void STWI_set_timer(u8 unk)
static void STWI_set_timer(u8 unk)
{
vu16 *timerL;
vu16 *timerH;
timerL = &REG_TMCNT_L(gRfuState->timerSelect);
timerH = &REG_TMCNT_H(gRfuState->timerSelect);
timerL = &REG_TMCNT_L(gSTWIStatus->timerSelect);
timerH = &REG_TMCNT_H(gSTWIStatus->timerSelect);
REG_IME = 0;
switch (unk)
{
case 50:
*timerL = 0xFCCB;
gRfuState->timerState = 1;
break;
case 80:
*timerL = 0xFAE0;
gRfuState->timerState = 2;
break;
case 100:
*timerL = 0xF996;
gRfuState->timerState = 3;
break;
case 130:
*timerL = 0xF7AD;
gRfuState->timerState = 4;
break;
case 50:
*timerL = 0xFCCB;
gSTWIStatus->timerState = 1;
break;
case 80:
*timerL = 0xFAE0;
gSTWIStatus->timerState = 2;
break;
case 100:
*timerL = 0xF996;
gSTWIStatus->timerState = 3;
break;
case 130:
*timerL = 0xF7AD;
gSTWIStatus->timerState = 4;
break;
}
*timerH = TIMER_ENABLE | TIMER_INTR_ENABLE | TIMER_1024CLK;
REG_IF = INTR_FLAG_TIMER0 << gRfuState->timerSelect;
REG_IF = INTR_FLAG_TIMER0 << gSTWIStatus->timerSelect;
REG_IME = 1;
}
void STWI_stop_timer(void)
static void STWI_stop_timer(void)
{
gRfuState->timerState = 0;
REG_TMCNT_L(gRfuState->timerSelect) = 0;
REG_TMCNT_H(gRfuState->timerSelect) = 0;
gSTWIStatus->timerState = 0;
REG_TMCNT_L(gSTWIStatus->timerSelect) = 0;
REG_TMCNT_H(gSTWIStatus->timerSelect) = 0;
}
u16 STWI_init(u8 request)
static u16 STWI_init(u8 request)
{
if (!REG_IME)
{
gRfuState->unk_12 = 6;
if (gRfuState->callbackM)
gRfuState->callbackM(request, gRfuState->unk_12);
gSTWIStatus->error = ERR_REQ_CMD_IME_DISABLE;
if (gSTWIStatus->callbackM != NULL)
gSTWIStatus->callbackM(request, gSTWIStatus->error);
return TRUE;
}
else if (gRfuState->unk_2c == TRUE)
else if (gSTWIStatus->unk_2c == TRUE)
{
gRfuState->unk_12 = 2;
gRfuState->unk_2c = FALSE;
if (gRfuState->callbackM)
gRfuState->callbackM(request, gRfuState->unk_12);
gSTWIStatus->error = ERR_REQ_CMD_SENDING;
gSTWIStatus->unk_2c = FALSE;
if (gSTWIStatus->callbackM != NULL)
gSTWIStatus->callbackM(request, gSTWIStatus->error);
return TRUE;
}
else if(!gRfuState->msMode)
else if(!gSTWIStatus->msMode)
{
gRfuState->unk_12 = 4;
if (gRfuState->callbackM)
gRfuState->callbackM(request, gRfuState->unk_12, gRfuState);
gSTWIStatus->error = ERR_REQ_CMD_CLOCK_SLAVE;
if (gSTWIStatus->callbackM != NULL)
gSTWIStatus->callbackM(request, gSTWIStatus->error, gSTWIStatus);
return TRUE;
}
else
{
gRfuState->unk_2c = TRUE;
gRfuState->activeCommand = request;
gRfuState->unk_0 = 0;
gRfuState->txParams = 0;
gRfuState->unk_5 = 0;
gRfuState->unk_7 = 0;
gRfuState->unk_8 = 0;
gRfuState->unk_9 = 0;
gRfuState->timerState = 0;
gRfuState->timerActive = 0;
gRfuState->unk_12 = 0;
gRfuState->unk_15 = 0;
gSTWIStatus->unk_2c = TRUE;
gSTWIStatus->reqActiveCommand = request;
gSTWIStatus->state = 0;
gSTWIStatus->reqLength = 0;
gSTWIStatus->reqNext = 0;
gSTWIStatus->ackLength = 0;
gSTWIStatus->ackNext = 0;
gSTWIStatus->ackActiveCommand = 0;
gSTWIStatus->timerState = 0;
gSTWIStatus->timerActive = 0;
gSTWIStatus->error = 0;
gSTWIStatus->recoveryCount = 0;
REG_RCNT = 0x100;
REG_SIOCNT = SIO_INTR_ENABLE | SIO_32BIT_MODE | SIO_115200_BPS;
return FALSE;
}
}
int STWI_start_Command()
static s32 STWI_start_Command(void)
{
u16 imeTemp;
// Yes, it matters that it's casted to a u32...
*(u32*)gRfuState->txPacket->rfuPacket8.data = 0x99660000 | (gRfuState->txParams << 8) | gRfuState->activeCommand;
REG_SIODATA32 = gRfuState->txPacket->rfuPacket32.command;
gRfuState->unk_0 = 0;
gRfuState->unk_5 = 1;
// equivalent to gSTWIStatus->txPacket->rfuPacket32.command,
// but the cast here is required to avoid register issue
*(u32 *)gSTWIStatus->txPacket->rfuPacket8.data = 0x99660000 | (gSTWIStatus->reqLength << 8) | gSTWIStatus->reqActiveCommand;
REG_SIODATA32 = gSTWIStatus->txPacket->rfuPacket32.command;
gSTWIStatus->state = 0;
gSTWIStatus->reqNext = 1;
imeTemp = REG_IME;
REG_IME = 0;
REG_IE |= (INTR_FLAG_TIMER0 << gRfuState->timerSelect);
REG_IE |= (INTR_FLAG_TIMER0 << gSTWIStatus->timerSelect);
REG_IE |= INTR_FLAG_SERIAL;
REG_IME = imeTemp;
REG_SIOCNT = SIO_INTR_ENABLE | SIO_32BIT_MODE | SIO_MULTI_BUSY | SIO_115200_BPS;
return 0;
}
int STWI_restart_Command(void)
static s32 STWI_restart_Command(void)
{
if (gRfuState->unk_15 <= 1)
if (gSTWIStatus->recoveryCount <= 1)
{
gRfuState->unk_15++;
++gSTWIStatus->recoveryCount;
STWI_start_Command();
}
else
{
if (gRfuState->activeCommand == RFU_MS_CHANGE || gRfuState->activeCommand == RFU_DATA_TX_AND_CHANGE || gRfuState->activeCommand == RFU_UNK35 || gRfuState->activeCommand == RFU_RESUME_RETRANSMIT_AND_CHANGE)
if (gSTWIStatus->reqActiveCommand == ID_MS_CHANGE_REQ || gSTWIStatus->reqActiveCommand == ID_DATA_TX_AND_CHANGE_REQ || gSTWIStatus->reqActiveCommand == ID_UNK35_REQ || gSTWIStatus->reqActiveCommand == ID_RESUME_RETRANSMIT_AND_CHANGE_REQ)
{
gRfuState->unk_12 = 1;
gRfuState->unk_2c = 0;
if (gRfuState->callbackM)
gRfuState->callbackM(gRfuState->activeCommand, gRfuState->unk_12);
gSTWIStatus->error = ERR_REQ_CMD_CLOCK_DRIFT;
gSTWIStatus->unk_2c = 0;
if (gSTWIStatus->callbackM != NULL)
gSTWIStatus->callbackM(gSTWIStatus->reqActiveCommand, gSTWIStatus->error);
}
else
{
gRfuState->unk_12 = 1;
gRfuState->unk_2c = 0;
if (gRfuState->callbackM)
gRfuState->callbackM(gRfuState->activeCommand, gRfuState->unk_12);
gRfuState->unk_0 = 4; //TODO: what's 4
gSTWIStatus->error = ERR_REQ_CMD_CLOCK_DRIFT;
gSTWIStatus->unk_2c = 0;
if (gSTWIStatus->callbackM != NULL)
gSTWIStatus->callbackM(gSTWIStatus->reqActiveCommand, gSTWIStatus->error);
gSTWIStatus->state = 4; // TODO: what's 4
}
}
return 0;
}
int STWI_reset_ClockCounter(void)
static s32 STWI_reset_ClockCounter(void)
{
gRfuState->unk_0 = 5; //TODO: what is 5
gRfuState->txParams = 0;
gRfuState->unk_5 = 0;
gSTWIStatus->state = 5; // TODO: what is 5
gSTWIStatus->reqLength = 0;
gSTWIStatus->reqNext = 0;
REG_SIODATA32 = (1 << 31);
REG_SIOCNT = 0;
REG_SIOCNT = SIO_INTR_ENABLE | SIO_32BIT_MODE | SIO_115200_BPS;
REG_SIOCNT = (SIO_INTR_ENABLE | SIO_32BIT_MODE | SIO_115200_BPS) + 0x7F;
return 0;
}

View File

@ -364,7 +364,7 @@ u32 sub_800BEC0(void)
void rfu_REQ_sendData_wrapper(u8 r2)
{
u8 val;
if (!gUnknown_03007890->unk_00)
if (!gRfuLinkStatus->parentChild)
{
val = gUnknown_03004140.unk_02;
r2 = 0;
@ -515,14 +515,14 @@ u8 sub_800C12C(u16 r6, u16 r8)
sub_800D30C(0xF3, 0x01);
return 2;
}
for (i = 0; i < gUnknown_03007890->unk_08; i++)
for (i = 0; i < gRfuLinkStatus->findParentCount; i++)
{
if (gUnknown_03007890->unk_14[i].unk_00 == r6)
if (gRfuLinkStatus->partner[i].id == r6)
{
break;
}
}
if (gUnknown_03007890->unk_08 == 0 || i == gUnknown_03007890->unk_08)
if (gRfuLinkStatus->findParentCount == 0 || i == gRfuLinkStatus->findParentCount)
{
gUnknown_03004140.unk_14 = 3;
sub_800D30C(0xF3, 0x01);
@ -561,7 +561,7 @@ void sub_800C210(u8 a0)
gUnknown_03004140.unk_34[i] = 0;
}
}
i = gUnknown_03007890->unk_03 & a0;
i = gRfuLinkStatus->linkLossSlotFlag & a0;
if (i)
{
sub_800D334(i);
@ -630,8 +630,8 @@ void sub_800C27C(bool8 a0)
case 16:
gUnknown_03004140.unk_04 = gUnknown_03004140.unk_11;
gUnknown_03004140.unk_05 = gUnknown_03004140.unk_12;
sub_800D334(gUnknown_03007890->unk_03);
gUnknown_03004140.unk_14 = gUnknown_03007890->unk_03;
sub_800D334(gRfuLinkStatus->linkLossSlotFlag);
gUnknown_03004140.unk_14 = gRfuLinkStatus->linkLossSlotFlag;
sub_800D30C(0x33, 0x01);
return;
case 17:
@ -703,7 +703,7 @@ bool8 sub_800C36C(u16 a0)
}
sub_800D610();
}
if (gUnknown_03007890->unk_00 == 1)
if (gRfuLinkStatus->parentChild == 1)
{
if (sp2)
{
@ -800,7 +800,7 @@ void sub_800C54C(u32 a0)
rfu_REQ_configSystem(gUnknown_03004140.unk_3c->unk_02, gUnknown_03004140.unk_3c->unk_00, gUnknown_03004140.unk_3c->unk_01);
break;
case 4:
rfu_REQ_configGameData(gUnknown_03004140.unk_3c->unk_04, gUnknown_03004140.unk_3c->unk_06, gUnknown_03004140.unk_3c->unk_08, gUnknown_03004140.unk_3c->unk_0c);
rfu_REQ_configGameData(gUnknown_03004140.unk_3c->unk_04, gUnknown_03004140.unk_3c->unk_06, (const u8 *)gUnknown_03004140.unk_3c->unk_08, gUnknown_03004140.unk_3c->unk_0c);
break;
case 5:
rfu_REQ_startSearchChild();
@ -834,7 +834,7 @@ void sub_800C54C(u32 a0)
case 15:
break;
case 16:
rfu_REQ_CHILD_startConnectRecovery(gUnknown_03007890->unk_03);
rfu_REQ_CHILD_startConnectRecovery(gRfuLinkStatus->linkLossSlotFlag);
break;
case 17:
rfu_REQ_CHILD_pollConnectRecovery();
@ -857,7 +857,7 @@ void sub_800C54C(u32 a0)
gUnknown_03004140.unk_0e = 0;
}
} while (gUnknown_03004140.unk_04 == 18 || gUnknown_03004140.unk_04 == 19);
if (gUnknown_03007890->unk_00 != 1 || !sub_800C36C(0))
if (gRfuLinkStatus->parentChild != 1 || !sub_800C36C(0))
{
sub_800CF34();
sub_800D158();
@ -910,7 +910,7 @@ static void sub_800C744(u32 a0)
static void sub_800C7B4(u16 r8, u16 r6)
{
u8 sp0;
register u8 *stwiRecvBuffer asm("r0");
register struct RfuIntrStruct *stwiRecvBuffer asm("r0");
u8 *tmp;
u8 i;
@ -983,7 +983,7 @@ static void sub_800C7B4(u16 r8, u16 r6)
{
sub_800D30C(0x20, 0x01);
}
if (gUnknown_03004140.unk_0b && gUnknown_03004140.unk_1a != 1 && gUnknown_03007890->unk_08 == 4)
if (gUnknown_03004140.unk_0b && gUnknown_03004140.unk_1a != 1 && gRfuLinkStatus->findParentCount == 4)
{
rfu_REQ_endSearchParent();
rfu_waitREQComplete();
@ -1059,11 +1059,11 @@ static void sub_800C7B4(u16 r8, u16 r6)
case 50:
if (r6 == 0)
{
gUnknown_03004140.unk_14 = gUnknown_03007890->unk_03;
gUnknown_03004140.unk_14 = gRfuLinkStatus->linkLossSlotFlag;
gUnknown_03004140.unk_04 = gUnknown_03004140.unk_05 = 17;
for (gUnknown_03004140.unk_10 = 0; gUnknown_03004140.unk_10 < 4; gUnknown_03004140.unk_10 ++)
{
if ((gUnknown_03007890->unk_03 >> gUnknown_03004140.unk_10) & 1)
if ((gRfuLinkStatus->linkLossSlotFlag >> gUnknown_03004140.unk_10) & 1)
{
break;
}
@ -1092,7 +1092,7 @@ static void sub_800C7B4(u16 r8, u16 r6)
else
{
gUnknown_03004140.unk_04 = gUnknown_03004140.unk_05 = 0;
sub_800D334(gUnknown_03007890->unk_03);
sub_800D334(gRfuLinkStatus->linkLossSlotFlag);
gUnknown_03004140.unk_1e = 0x33;
}
gUnknown_03004140.unk_34[gUnknown_03004140.unk_10] = 0;
@ -1126,7 +1126,7 @@ static void sub_800C7B4(u16 r8, u16 r6)
{
gUnknown_03004140.unk_04 = gUnknown_03004140.unk_05 = 0;
sub_800D610();
sub_800D334(gUnknown_03007890->unk_02 | gUnknown_03007890->unk_03);
sub_800D334(gRfuLinkStatus->connSlotFlag | gRfuLinkStatus->linkLossSlotFlag);
gUnknown_03004140.unk_14 = sp0;
sub_800D30C(0x25, 0x01);
}
@ -1148,11 +1148,11 @@ static void sub_800C7B4(u16 r8, u16 r6)
rfu_REQ_RFUStatus();
rfu_waitREQComplete();
rfu_getRFUStatus(&sp0);
if (sp0 == 0 && gUnknown_03007890->unk_00 == 0)
if (sp0 == 0 && gRfuLinkStatus->parentChild == 0)
{
stwiRecvBuffer = rfu_getSTWIRecvBuffer();
stwiRecvBuffer[4] = gUnknown_03007890->unk_02;
stwiRecvBuffer[5] = 1;
stwiRecvBuffer->rxPacketAlloc.rfuPacket8.data[4] = gRfuLinkStatus->connSlotFlag;
stwiRecvBuffer->rxPacketAlloc.rfuPacket8.data[5] = 1;
sub_800C36C(0x29);
r6 = 0;
}
@ -1163,7 +1163,7 @@ static void sub_800C7B4(u16 r8, u16 r6)
if (r6 == 0)
{
stwiRecvBuffer = rfu_getSTWIRecvBuffer();
gUnknown_03004140.unk_14 = stwiRecvBuffer[8];
gUnknown_03004140.unk_14 = stwiRecvBuffer->rxPacketAlloc.rfuPacket8.data[8];
sub_800D358(gUnknown_03004140.unk_14);
if (gUnknown_03004140.unk_30)
{
@ -1191,7 +1191,7 @@ static void sub_800C7B4(u16 r8, u16 r6)
gUnknown_03004140.unk_00 &= ~gUnknown_03004140.unk_14;
if (gUnknown_03004140.unk_07)
{
if (gUnknown_03007890->unk_00 == 0xFF)
if (gRfuLinkStatus->parentChild == 0xFF)
{
if (gUnknown_03004140.unk_07 == 8)
{
@ -1206,7 +1206,7 @@ static void sub_800C7B4(u16 r8, u16 r6)
}
}
}
if (gUnknown_03007890->unk_00 == 0xFF)
if (gRfuLinkStatus->parentChild == 0xFF)
{
if (gUnknown_03004140.unk_04 == 0)
{
@ -1221,7 +1221,7 @@ static void sub_800C7B4(u16 r8, u16 r6)
break;
case 38:
sub_800D20C();
if (gUnknown_03007890->unk_00 != 0xFF)
if (gRfuLinkStatus->parentChild != 0xFF)
{
sub_800D30C(0x50, 0x00);
}
@ -1246,8 +1246,8 @@ static void sub_800C7B4(u16 r8, u16 r6)
{
if (r8 == 28 && r6 != 0 && gUnknown_03004140.unk_07 == 4)
{
gUnknown_03007890->unk_00 = 1;
gUnknown_03007890->unk_02 = 15;
gRfuLinkStatus->parentChild = 1;
gRfuLinkStatus->connSlotFlag = 15;
sub_800D334(15);
rfu_waitREQComplete();
return;
@ -1279,7 +1279,7 @@ static void sub_800CEB0(u16 r6)
r7 = gUnknown_03004140.unk_0e;
gUnknown_03004140.unk_0e = 0;
gUnknown_03004140.unk_0f = 1;
if (gUnknown_03007890->unk_00 == 0)
if (gRfuLinkStatus->parentChild == 0)
{
sub_800C36C(r6);
if (gUnknown_03004140.unk_02 != 1)
@ -1321,8 +1321,8 @@ static void sub_800CF34(void)
if (gUnknown_03004140.unk_04 == 5 || gUnknown_03004140.unk_04 == 6 || gUnknown_03004140.unk_04 == 7 || gUnknown_03004140.unk_04 == 8)
{
flags = ((gUnknown_03007890->unk_02 ^ gUnknown_03004140.unk_0c) & gUnknown_03007890->unk_02) & ~gUnknown_03007890->unk_07;
gUnknown_03004140.unk_0c = gUnknown_03007890->unk_02;
flags = ((gRfuLinkStatus->connSlotFlag ^ gUnknown_03004140.unk_0c) & gRfuLinkStatus->connSlotFlag) & ~gRfuLinkStatus->getNameFlag;
gUnknown_03004140.unk_0c = gRfuLinkStatus->connSlotFlag;
if (flags)
{
gUnknown_03004140.unk_14 = flags;
@ -1340,14 +1340,14 @@ static void sub_800CF34(void)
}
else if (gUnknown_03004140.unk_24 & r4)
{
if (gUnknown_03007880[i]->unk_34 == 0x46)
if (gRfuSlotStatusNI[i]->recv.state == 0x46)
{
if (gUnknown_03007880[i]->unk_61 == 1)
if (gRfuSlotStatusNI[i]->recv.dataType == 1)
{
r5 = 0x02;
for (ptr = gUnknown_03004140.unk_20; *ptr != 0xFFFF; ptr++)
{
if (gUnknown_03007890->unk_14[i].unk_04 == *ptr)
if (gRfuLinkStatus->partner[i].serialNo == *ptr)
{
gUnknown_03004140.unk_00 |= r4;
gUnknown_03004140.unk_01++;
@ -1386,7 +1386,7 @@ static void sub_800CF34(void)
if (gUnknown_03004140.unk_0d)
{
r5 = 0x01;
if (gUnknown_03007890->unk_06 && ((gUnknown_03004140.unk_03 & gUnknown_03004140.unk_00) != gUnknown_03004140.unk_00))
if (gRfuLinkStatus->sendSlotUNIFlag && ((gUnknown_03004140.unk_03 & gUnknown_03004140.unk_00) != gUnknown_03004140.unk_00))
{
r5 = 0x00;
}
@ -1434,7 +1434,7 @@ static void sub_800D158(void)
REG_IME = 0;
if (gUnknown_03004140.unk_04 == 15)
{
if (--gUnknown_03004140.unk_28[gUnknown_03004140.unk_10] == 0 || gUnknown_03007880[gUnknown_03004140.unk_10]->unk_0 == 0x27)
if (--gUnknown_03004140.unk_28[gUnknown_03004140.unk_10] == 0 || gRfuSlotStatusNI[gUnknown_03004140.unk_10]->send.state == 0x27)
{
sub_800D630();
gUnknown_03004140.unk_04 = 24;
@ -1453,7 +1453,7 @@ static void sub_800D158(void)
if (gUnknown_03004140.unk_02 == 0)
{
gUnknown_03004140.unk_04 = gUnknown_03004140.unk_05 = 0;
sub_800D334(gUnknown_03007890->unk_02 | gUnknown_03007890->unk_03);
sub_800D334(gRfuLinkStatus->connSlotFlag | gRfuLinkStatus->linkLossSlotFlag);
gUnknown_03004140.unk_14 = 0;
sub_800D30C(0x25, 0x01);
}
@ -1462,7 +1462,7 @@ static void sub_800D158(void)
static void sub_800D20C(void)
{
if (gUnknown_03004140.unk_04 == 15 && gUnknown_03007880[gUnknown_03004140.unk_10]->unk_0 == 0x26)
if (gUnknown_03004140.unk_04 == 15 && gRfuSlotStatusNI[gUnknown_03004140.unk_10]->send.state == 0x26)
{
gUnknown_03004140.unk_04 = gUnknown_03004140.unk_05 = 0;
rfu_clearSlot(4, gUnknown_03004140.unk_10);
@ -1490,11 +1490,11 @@ static u8 sub_800D294(void)
const u16 *ptr;
u8 flags = 0x00;
for (i = 0; i < gUnknown_03007890->unk_08; i++)
for (i = 0; i < gRfuLinkStatus->findParentCount; i++)
{
for (ptr = gUnknown_03004140.unk_20; *ptr != 0xFFFF; ptr++)
{
if (gUnknown_03007890->unk_14[i].unk_04 == *ptr)
if (gRfuLinkStatus->partner[i].serialNo == *ptr)
{
flags |= (1 << i);
}
@ -1525,34 +1525,34 @@ static void sub_800D358(u8 a0)
{
u8 i;
if (gUnknown_03007890->unk_04)
if (gRfuLinkStatus->sendSlotNIFlag)
{
for (i = 0; i < 4; i++)
{
if (gUnknown_03007880[i]->unk_0 & 0x8000 && gUnknown_03007880[i]->unk_1a & a0)
if (gRfuSlotStatusNI[i]->send.state & 0x8000 && gRfuSlotStatusNI[i]->send.bmSlot & a0)
{
rfu_changeSendTarget(0x20, i, gUnknown_03007880[i]->unk_1a & ~a0);
rfu_changeSendTarget(0x20, i, gRfuSlotStatusNI[i]->send.bmSlot & ~a0);
}
}
}
if (gUnknown_03007890->unk_05)
if (gRfuLinkStatus->recvSlotNIFlag)
{
for (i = 0; i < 4; i++)
{
if (gUnknown_03007880[i]->unk_34 & 0x8000 && gUnknown_03007880[i]->unk_4e & a0)
if (gRfuSlotStatusNI[i]->recv.state & 0x8000 && gRfuSlotStatusNI[i]->recv.bmSlot & a0)
{
rfu_NI_stopReceivingData(i);
}
}
}
if (gUnknown_03007890->unk_06)
if (gRfuLinkStatus->sendSlotUNIFlag)
{
gUnknown_03007890->unk_06 &= ~a0;
gRfuLinkStatus->sendSlotUNIFlag &= ~a0;
for (i = 0; i < 4; i++)
{
if (gUnknown_03007870[i]->unk_0 == 0x8024 && a0 & gUnknown_03007870[i]->unk_3)
if (gRfuSlotStatusUNI[i]->send.state == 0x8024 && a0 & gRfuSlotStatusUNI[i]->send.bmSlot)
{
gUnknown_03007870[i]->unk_3 &= ~a0;
gRfuSlotStatusUNI[i]->send.bmSlot &= ~a0;
}
}
}
@ -1566,32 +1566,32 @@ static void sub_800D434(void)
if (gUnknown_03004140.unk_18)
{
if (gUnknown_03007890->unk_04)
if (gRfuLinkStatus->sendSlotNIFlag)
{
for (i = 0; i < 4; i ++)
{
if (gUnknown_03007880[i]->unk_0 & 0x8000)
if (gRfuSlotStatusNI[i]->send.state & 0x8000)
{
flags = 0;
for (j = 0; j < 4; j++)
{
if ((gUnknown_03007880[i]->unk_1a >> j) & 1 && gUnknown_03007880[j]->unk_2 > gUnknown_03004140.unk_18)
if ((gRfuSlotStatusNI[i]->send.bmSlot >> j) & 1 && gRfuSlotStatusNI[j]->send.failCounter > gUnknown_03004140.unk_18)
{
flags |= (1 << j);
}
if (flags)
{
rfu_changeSendTarget(0x20, i, flags ^ gUnknown_03007880[i]->unk_1a);
rfu_changeSendTarget(0x20, i, flags ^ gRfuSlotStatusNI[i]->send.bmSlot);
}
}
}
}
}
if (gUnknown_03007890->unk_05)
if (gRfuLinkStatus->recvSlotNIFlag)
{
for (i = 0; i < 4; i++)
{
if (gUnknown_03007880[i]->unk_34 & 0x8000 && gUnknown_03007880[i]->unk_36 > gUnknown_03004140.unk_18)
if (gRfuSlotStatusNI[i]->recv.state & 0x8000 && gRfuSlotStatusNI[i]->recv.failCounter > gUnknown_03004140.unk_18)
{
rfu_NI_stopReceivingData(i);
}
@ -1628,7 +1628,7 @@ u8 sub_800D550(u8 a0, u16 a1)
u8 sub_800D594(u16 a0)
{
if (gUnknown_03007890->unk_04 | gUnknown_03007890->unk_05)
if (gRfuLinkStatus->sendSlotNIFlag | gRfuLinkStatus->recvSlotNIFlag)
{
gUnknown_03004140.unk_14 = 6;
sub_800D30C(0xf3, 0x01);
@ -2049,17 +2049,17 @@ void ASCIIToPkmnStr(u8 *q1, const u8 *q2)
u8 sub_800DD1C(u8 maxFlags)
{
u8 flagCount = 0;
u32 flags = gUnknown_03007890->unk_02;
u32 flags = gRfuLinkStatus->connSlotFlag;
u8 i;
if (gUnknown_03007890->unk_00 == 1)
if (gRfuLinkStatus->parentChild == 1)
{
for (i = 0; i < 4; flags >>= 1, i++)
{
if (flags & 1)
{
if (maxFlags == flagCount + 1)
return gUnknown_03007890->unk_0a[i];
return gRfuLinkStatus->strength[i];
flagCount++;
}
}
@ -2069,7 +2069,7 @@ u8 sub_800DD1C(u8 maxFlags)
for (i = 0; i < 4; flags >>= 1, i++)
{
if (flags & 1)
return gUnknown_03007890->unk_0a[i];
return gRfuLinkStatus->strength[i];
}
}
return 0;
@ -2081,7 +2081,7 @@ NAKED u8 sub_800DD1C(u8 maxFlags)
"\tlsls r0, 24\n"
"\tlsrs r5, r0, 24\n"
"\tmovs r6, 0\n"
"\tldr r0, =gUnknown_03007890\n"
"\tldr r0, =gRfuLinkStatus\n"
"\tldr r4, [r0]\n"
"\tldrb r2, [r4, 0x2]\n"
"\tldrb r1, [r4]\n"
@ -2177,24 +2177,24 @@ bool8 sub_800DE7C(struct UnkLinkRfuStruct_02022B14 *buff1, u8 *buff2, u8 idx)
if (gUnknown_03004140.unk_06 == 1)
{
retVal = TRUE;
if (sub_8010454(gUnknown_03007890->unk_14[idx].unk_04) && ((gUnknown_03007890->unk_07 >> idx) & 1))
if (sub_8010454(gRfuLinkStatus->partner[idx].serialNo) && ((gRfuLinkStatus->getNameFlag >> idx) & 1))
{
memcpy(buff1, &gUnknown_03007890->unk_14[idx].unk_06, 0xD);
memcpy(buff2, gUnknown_03007890->unk_14[idx].playerName, PLAYER_NAME_LENGTH + 1);
memcpy(buff1, gRfuLinkStatus->partner[idx].gname, 0xD);
memcpy(buff2, gRfuLinkStatus->partner[idx].uname, PLAYER_NAME_LENGTH + 1);
}
else
{
memset(buff1, 0, 0xD);
memset(buff2, 0, sizeof(gUnknown_03007890->unk_14[idx].playerName));
memset(buff2, 0, PLAYER_NAME_LENGTH + 1);
}
}
else
{
retVal = FALSE;
if (sub_8010454(gUnknown_03007890->unk_14[idx].unk_04))
if (sub_8010454(gRfuLinkStatus->partner[idx].serialNo))
{
memcpy(buff1, &gUnknown_03007890->unk_14[idx].unk_06, 0xD);
memcpy(buff2, gUnknown_03007890->unk_14[idx].playerName, PLAYER_NAME_LENGTH + 1);
memcpy(buff1, gRfuLinkStatus->partner[idx].gname, 0xD);
memcpy(buff2, gRfuLinkStatus->partner[idx].uname, PLAYER_NAME_LENGTH + 1);
}
else
{
@ -2208,10 +2208,10 @@ bool8 sub_800DE7C(struct UnkLinkRfuStruct_02022B14 *buff1, u8 *buff2, u8 idx)
bool8 sub_800DF34(struct UnkLinkRfuStruct_02022B14 *buff1, u8 *buff2, u8 idx)
{
bool8 retVal = FALSE;
if (gUnknown_03007890->unk_14[idx].unk_04 == 0x7F7D)
if (gRfuLinkStatus->partner[idx].serialNo == 0x7F7D)
{
memcpy(buff1, &gUnknown_03007890->unk_14[idx].unk_06, 0xD);
memcpy(buff2, gUnknown_03007890->unk_14[idx].playerName, 8);
memcpy(buff1, gRfuLinkStatus->partner[idx].gname, 0xD);
memcpy(buff2, gRfuLinkStatus->partner[idx].uname, 8);
retVal = TRUE;
}
else
@ -2237,7 +2237,7 @@ void CreateWirelessStatusIndicatorSprite(u8 x, u8 y)
x = 0xE7;
y = 0x08;
}
if (gUnknown_03007890->unk_00 == 1)
if (gRfuLinkStatus->parentChild == 1)
{
sprId = CreateSprite(&sWirelessStatusIndicatorSpriteTemplate, x, y, 0);
gSprites[sprId].data[7] = 0x1234;
@ -2278,12 +2278,12 @@ void LoadWirelessStatusIndicatorSpriteGfx(void)
u8 sub_800E124(void)
{
u8 i;
u8 flags = gUnknown_03007890->unk_02;
u8 flags = gRfuLinkStatus->connSlotFlag;
for (i = 0; i < 4; i++)
{
if (flags & 1)
{
return gUnknown_03007890->unk_0a[i];
return gRfuLinkStatus->strength[i];
}
flags >>= 1;
}
@ -2307,7 +2307,7 @@ void sub_800E174(void)
struct Sprite *sprite = &gSprites[gWirelessStatusIndicatorSpriteId];
u8 signalStrength = 255;
u8 i = 0;
if (gUnknown_03007890->unk_00 == 1)
if (gRfuLinkStatus->parentChild == 1)
{
for (i = 0; i < GetLinkPlayerCount() - 1; i++)
{
@ -2530,7 +2530,7 @@ void sub_800E6D0(void)
void sub_800E700(void)
{
if (!rfu_initializeAPI(gUnknown_03004140.unk_50, sizeof gUnknown_03004140.unk_50, gIntrTable + 1, TRUE))
if (!rfu_initializeAPI((void *)gUnknown_03004140.unk_50, sizeof gUnknown_03004140.unk_50, gIntrTable + 1, TRUE))
{
gLinkType = 0;
sub_800AAF4();
@ -2787,7 +2787,7 @@ void sub_800ED34(u16 unused)
}
rfu_REQ_recvData();
rfu_waitREQComplete();
if (gUnknown_03007870[gUnknown_03005000.unk_c3e]->unk_12)
if (gRfuSlotStatusUNI[gUnknown_03005000.unk_c3e]->recv.newDataFlag)
{
gUnknown_03005000.unk_cd0++;
sub_800D7D8(&gUnknown_03005000.unk_124, gUnknown_03005000.unk_c3f);
@ -2858,7 +2858,7 @@ bool8 sub_800EE94(void)
bool32 sub_800EEBC(void)
{
if (gUnknown_03005000.unk_04 == 7 && !sub_800C12C(gUnknown_03007890->unk_14[gUnknown_03005000.unk_c3d].unk_00, 240))
if (gUnknown_03005000.unk_04 == 7 && !sub_800C12C(gRfuLinkStatus->partner[gUnknown_03005000.unk_c3d].id, 240))
{
gUnknown_03005000.unk_04 = 9;
return TRUE;
@ -2971,7 +2971,7 @@ bool32 IsRfuRecvQueueEmpty(void)
s32 i;
s32 j;
if (gUnknown_03007890->unk_06 == 0)
if (gRfuLinkStatus->sendSlotUNIFlag == 0)
{
return FALSE;
}
@ -2999,7 +2999,7 @@ bool32 sub_800F0F8(void)
else
{
gUnknown_03005000.unk_cdb = 0;
if ((gUnknown_03005000.unk_ce2 & gUnknown_03007890->unk_02) == gUnknown_03005000.unk_ce2 && (gUnknown_03005000.unk_ce2 & gUnknown_03007890->unk_02))
if ((gUnknown_03005000.unk_ce2 & gRfuLinkStatus->connSlotFlag) == gUnknown_03005000.unk_ce2 && (gUnknown_03005000.unk_ce2 & gRfuLinkStatus->connSlotFlag))
{
if (!gUnknown_03005000.unk_cdc)
{
@ -3119,7 +3119,7 @@ bool32 sub_800F1E0(void)
gUnknown_03005000.unk_0e = 0;
}
retval = gUnknown_03005000.unk_cdc;
return gUnknown_03007890->unk_06 ? retval & 1 : FALSE;
return gRfuLinkStatus->sendSlotUNIFlag ? retval & 1 : FALSE;
}
void sub_800F498(u16 *a0, u8 *a1)
@ -3162,7 +3162,7 @@ bool32 sub_800F4F0(void)
sub_800F86C(0);
if (gUnknown_03004140.unk_02 == 0 && gUnknown_03005000.unk_ce4)
{
rfu_REQ_disconnect(gUnknown_03007890->unk_02 | gUnknown_03007890->unk_03);
rfu_REQ_disconnect(gRfuLinkStatus->connSlotFlag | gRfuLinkStatus->linkLossSlotFlag);
rfu_waitREQComplete();
switchval = sub_8011A74();
if (switchval != 1 && switchval != 6 && switchval != 9)
@ -3305,7 +3305,7 @@ static void sub_800F86C(u8 unused)
return;
// fallthrough
case 0x7700:
if (gUnknown_03007890->unk_00 == 0)
if (gRfuLinkStatus->parentChild == 0)
{
gUnknown_03005000.playerCount = gRecvCmds[i][1];
gUnknown_03005000.unk_cce = sub_800F74C((u8 *)(gRecvCmds[i] + 2));
@ -3353,7 +3353,7 @@ static void sub_800F86C(u8 unused)
{
if (gReceivedRemoteLinkPlayers != 0)
{
if (gRecvCmds[i][1] & gUnknown_03007890->unk_02)
if (gRecvCmds[i][1] & gRfuLinkStatus->connSlotFlag)
{
gReceivedRemoteLinkPlayers = 0;
sub_800D630();
@ -3611,7 +3611,7 @@ void sub_801011C(void)
void sub_8010148(void)
{
rfu_REQ_disconnect(gUnknown_03007890->unk_02 | gUnknown_03007890->unk_03);
rfu_REQ_disconnect(gRfuLinkStatus->connSlotFlag | gRfuLinkStatus->linkLossSlotFlag);
rfu_waitREQComplete();
sub_801011C();
}
@ -3631,7 +3631,7 @@ void LinkRfu_FatalError(void)
{
sub_800D630();
gUnknown_03005000.unk_ce4 = 1;
gUnknown_03005000.unk_ce3 = gUnknown_03007890->unk_02 | gUnknown_03007890->unk_03;
gUnknown_03005000.unk_ce3 = gRfuLinkStatus->connSlotFlag | gRfuLinkStatus->linkLossSlotFlag;
}
void sub_80101CC(void)
@ -3821,7 +3821,7 @@ bool8 sub_8010540(void)
{
if (gUnknown_03005000.unk_cd1[i] < 5 || gUnknown_03005000.unk_cd1[i] > 6)
{
if (gUnknown_03007880[i]->unk_34 == 0x46 || gUnknown_03007880[i]->unk_34 == 0x48)
if (gRfuSlotStatusNI[i]->recv.state == 0x46 || gRfuSlotStatusNI[i]->recv.state == 0x48)
{
if (gUnknown_03005000.unk_cd5[i] == 8)
{
@ -3833,7 +3833,7 @@ bool8 sub_8010540(void)
}
}
else if (gUnknown_03007880[gUnknown_03005000.unk_c3e]->unk_34 == 0x47)
else if (gRfuSlotStatusNI[gUnknown_03005000.unk_c3e]->recv.state == 0x47)
rfu_clearSlot(8, i);
{
@ -3898,7 +3898,7 @@ u32 sub_8010714(u16 a0, const u8 *a1)
u8 r0 = sub_8011CE4(a1, a0);
if (r0 == 0xFF)
return 2;
if (gUnknown_03007880[r0]->unk_0 == 0)
if (gRfuSlotStatusNI[r0]->send.state == 0)
return 1;
return 0;
}
@ -3910,7 +3910,7 @@ void sub_8010750(void)
sub_8010540();
for (i = 0; i < 4; i++)
{
if (gUnknown_03007880[i]->unk_0 == 0x26 || gUnknown_03007880[i]->unk_0 == 0x27)
if (gRfuSlotStatusNI[i]->send.state == 0x26 || gRfuSlotStatusNI[i]->send.state == 0x27)
{
if (gUnknown_03005000.unk_cd5[i] == 10)
gUnknown_03005000.unk_cd5[i] = 11;
@ -3924,16 +3924,16 @@ s32 sub_80107A0(void)
s32 retval = 0;
if (gUnknown_03005000.unk_c85 == 8)
{
if (gUnknown_03007880[gUnknown_03005000.unk_c3e]->unk_0 == 0x26 || gUnknown_03007880[gUnknown_03005000.unk_c3e]->unk_0 == 0x27)
if (gRfuSlotStatusNI[gUnknown_03005000.unk_c3e]->send.state == 0x26 || gRfuSlotStatusNI[gUnknown_03005000.unk_c3e]->send.state == 0x27)
rfu_clearSlot(4, gUnknown_03005000.unk_c3e);
}
if (gUnknown_03007880[gUnknown_03005000.unk_c3e]->unk_34 == 0x46 || gUnknown_03007880[gUnknown_03005000.unk_c3e]->unk_34 == 0x48)
if (gRfuSlotStatusNI[gUnknown_03005000.unk_c3e]->recv.state == 0x46 || gRfuSlotStatusNI[gUnknown_03005000.unk_c3e]->recv.state == 0x48)
{
rfu_clearSlot(8, gUnknown_03005000.unk_c3e);
sub_8011A64(gUnknown_03005000.unk_c86, 0);
retval = gUnknown_03005000.unk_c86;
}
else if (gUnknown_03007880[gUnknown_03005000.unk_c3e]->unk_34 == 0x47)
else if (gRfuSlotStatusNI[gUnknown_03005000.unk_c3e]->recv.state == 0x47)
{
rfu_clearSlot(8, gUnknown_03005000.unk_c3e);
retval = 6;
@ -4282,14 +4282,14 @@ void sub_801103C(void)
void sub_8011068(u8 a0)
{
gUnknown_02022B14.unk_0a_7 = a0;
rfu_REQ_configGameData(0, 2, &gUnknown_02022B14, gUnknown_02022B22);
rfu_REQ_configGameData(0, 2, (const u8 *)&gUnknown_02022B14, gUnknown_02022B22);
}
void sub_8011090(u8 a0, u32 a1, u32 a2)
{
if (a0)
sub_8010F84(a0, a1, a2);
rfu_REQ_configGameData(0, 2, &gUnknown_02022B14, gUnknown_02022B22);
rfu_REQ_configGameData(0, 2, (const u8 *)&gUnknown_02022B14, gUnknown_02022B22);
}
void sub_80110B8(u32 a0)
@ -4370,7 +4370,7 @@ void sub_801120C(u8 a0, u8 unused1)
{
if ((gUnknown_03004140.unk_14 >> i) & 1)
{
struct UnkLinkRfuStruct_02022B14 *structPtr = &gUnknown_03007890->unk_14[i].unk_06;
struct UnkLinkRfuStruct_02022B14 *structPtr = (void *)gRfuLinkStatus->partner[i].gname;
if (structPtr->unk_0a_0 == sub_800F7DC()->unk_0a_0)
{
gUnknown_03005000.unk_cd1[i] = 0;
@ -4528,7 +4528,7 @@ u8 sub_8011628(s32 a0)
{
if ((a0 >> i) & 1)
{
struct UnkLinkRfuStruct_02022B14 *structPtr = &gUnknown_03007890->unk_14[i].unk_06;
struct UnkLinkRfuStruct_02022B14 *structPtr = (void *)gRfuLinkStatus->partner[i].gname;
if (structPtr->unk_0a_0 == 0x45)
ret |= (1 << i);
}
@ -4629,7 +4629,7 @@ void sub_8011674(u8 a0, u8 unused1)
break;
case 0x32:
gUnknown_03005000.unk_f0 = 3;
if (gUnknown_03007890->unk_00 == 0)
if (gRfuLinkStatus->parentChild == 0)
gUnknown_03005000.unk_c3c = 1;
break;
case 0x30:
@ -4654,7 +4654,7 @@ void sub_8011674(u8 a0, u8 unused1)
sub_800C27C(0);
}
if (gUnknown_03007890->unk_00 == 0xFF && gUnknown_03004140.unk_07 == 0 && FuncIsActiveTask(sub_800EB44) == TRUE)
if (gRfuLinkStatus->parentChild == 0xFF && gUnknown_03004140.unk_07 == 0 && FuncIsActiveTask(sub_800EB44) == TRUE)
gUnknown_03005000.unk_04 = 0x11;
sub_8011A64(2, a0);
@ -4825,13 +4825,13 @@ u8 sub_8011CE4(const u8 *a0, u16 a1)
for (i = 0; i < 4; i++)
{
u16 trainerId = ReadU16(gUnknown_03007890->unk_14[i].unk_06.unk_00.playerTrainerId);
if (sub_8010454(gUnknown_03007890->unk_14[i].unk_04)
&& !StringCompare(a0, gUnknown_03007890->unk_14[i].playerName)
u16 trainerId = ReadU16(gRfuLinkStatus->partner[i].gname + 2);
if (sub_8010454(gRfuLinkStatus->partner[i].serialNo)
&& !StringCompare(a0, gRfuLinkStatus->partner[i].uname)
&& a1 == trainerId)
{
ret = i;
if (gUnknown_03007890->unk_14[i].unk_02 != 0xFF)
if (gRfuLinkStatus->partner[i].slot != 0xFF)
break;
}
}
@ -4911,7 +4911,7 @@ void sub_8011EF4(u8 taskId)
u8 id = sub_8011CE4((u8*)data, ReadU16(&data[8]));
if (id != 0xFF)
{
if (gUnknown_03007890->unk_14[id].unk_02 != 0xFF)
if (gRfuLinkStatus->partner[id].slot != 0xFF)
{
gUnknown_03005000.unk_c3d = id;
if (sub_800EEBC())
@ -5006,9 +5006,9 @@ void sub_801209C(u8 taskId)
u8 id = sub_8011CE4(gUnknown_03005000.playerName, trainerId);
if (id != 0xFF)
{
if (!sub_801200C(gTasks[taskId].data[1], &gUnknown_03007890->unk_14[id].unk_06))
if (!sub_801200C(gTasks[taskId].data[1], (void *)gRfuLinkStatus->partner[id].gname))
{
if (gUnknown_03007890->unk_14[id].unk_02 != 0xFF && !sub_800C12C(gUnknown_03007890->unk_14[id].unk_00, 0x5A))
if (gRfuLinkStatus->partner[id].slot != 0xFF && !sub_800C12C(gRfuLinkStatus->partner[id].id, 0x5A))
{
gUnknown_03005000.unk_04 = 0xA;
DestroyTask(taskId);
@ -5081,17 +5081,17 @@ void sub_801229C(void)
s32 i, j;
nullsub_13(GetBlockReceivedStatus(), 0x1C, 0x13, 2);
nullsub_13(gUnknown_03007890->unk_02, 0x14, 1, 1);
nullsub_13(gUnknown_03007890->unk_03, 0x17, 1, 1);
nullsub_13(gRfuLinkStatus->connSlotFlag, 0x14, 1, 1);
nullsub_13(gRfuLinkStatus->linkLossSlotFlag, 0x17, 1, 1);
if (gUnknown_03005000.unk_0c == 1)
{
for (i = 0; i < 4; i++)
{
if ((gUnknown_03007890->unk_07 >> i) & 1)
if ((gRfuLinkStatus->getNameFlag >> i) & 1)
{
nullsub_13(gUnknown_03007890->unk_14[i].unk_04, 1, i + 3, 4);
nullsub_5((void*) &gUnknown_03007890->unk_14[i].unk_06, 6, i + 3);
nullsub_5(gUnknown_03007890->unk_14[i].playerName, 0x16, i + 3);
nullsub_13(gRfuLinkStatus->partner[i].serialNo, 1, i + 3, 4);
nullsub_5((void*)gRfuLinkStatus->partner[i].gname, 6, i + 3);
nullsub_5(gRfuLinkStatus->partner[i].uname, 0x16, i + 3);
}
}
for (i = 0; i < 4; i++)
@ -5103,7 +5103,7 @@ void sub_801229C(void)
}
nullsub_5(gUnknown_082ED868, 1, 0xF);
}
else if (gUnknown_03007890->unk_02 != 0 && gUnknown_03007890->unk_07 != 0)
else if (gRfuLinkStatus->connSlotFlag != 0 && gRfuLinkStatus->getNameFlag != 0)
{
for (i = 0; i < 4; i++)
{
@ -5111,19 +5111,19 @@ void sub_801229C(void)
nullsub_5(gUnknown_082ED84B, 6, i + 3);
nullsub_5(gUnknown_082ED85B, 0x16, i + 3);
}
nullsub_13(gUnknown_03007890->unk_14[gUnknown_03005000.unk_c3e].unk_04, 1, 3, 4);
nullsub_5((void*) &gUnknown_03007890->unk_14[gUnknown_03005000.unk_c3e].unk_06, 6, 3);
nullsub_5(gUnknown_03007890->unk_14[gUnknown_03005000.unk_c3e].playerName, 0x16, 3);
nullsub_13(gRfuLinkStatus->partner[gUnknown_03005000.unk_c3e].serialNo, 1, 3, 4);
nullsub_5((void*)gRfuLinkStatus->partner[gUnknown_03005000.unk_c3e].gname, 6, 3);
nullsub_5(gRfuLinkStatus->partner[gUnknown_03005000.unk_c3e].uname, 0x16, 3);
}
else
{
for (i = 0; i < gUnknown_03007890->unk_08; i++)
for (i = 0; i < gRfuLinkStatus->findParentCount; i++)
{
if (gUnknown_03007890->unk_14[i].unk_02 != 0xFF)
if (gRfuLinkStatus->partner[i].slot != 0xFF)
{
nullsub_13(gUnknown_03007890->unk_14[i].unk_04, 1, i + 3, 4);
nullsub_13(gUnknown_03007890->unk_14[i].unk_00, 6, i + 3, 4);
nullsub_5(gUnknown_03007890->unk_14[i].playerName, 0x16, i + 3);
nullsub_13(gRfuLinkStatus->partner[i].serialNo, 1, i + 3, 4);
nullsub_13(gRfuLinkStatus->partner[i].id, 6, i + 3, 4);
nullsub_5(gRfuLinkStatus->partner[i].uname, 0x16, i + 3);
}
}
for (; i < 4; i++)

View File

@ -254,7 +254,7 @@ static bool32 sub_80771BC(void)
{
if (gUnknown_02022C2C == 29)
{
if (gUnknown_03007880[sub_800E87C(gUnknown_03004140.unk_00)]->unk_0 == 0)
if (gRfuSlotStatusNI[sub_800E87C(gUnknown_03004140.unk_00)]->send.state == 0)
return TRUE;
else
return FALSE;

View File

@ -4077,7 +4077,7 @@ s32 sub_8017EA0(u8 *dst, u32 gender, u16 *arg2, struct UnkStruct_URoom *arg3)
StringCopy(arg3->field_58 + 0x10, gSpeciesNames[sUnionRoomTrade.playerSpecies]);
for (i = 0; i < 4; i++)
{
if (gUnknown_03007890->unk_14[i].unk_04 == 2)
if (gRfuLinkStatus->partner[i].serialNo == 2)
{
ConvertIntToDecimalStringN(arg3->field_58 + 0x20, arg2[2], STR_CONV_MODE_LEFT_ALIGN, 3);
StringCopy(arg3->field_58 + 0x30, gSpeciesNames[arg2[1]]);

View File

@ -77,4 +77,5 @@ gReservedSpritePaletteCount:
.include "m4a.o"
.include "agb_flash.o"
.include "librfu_stwi.o"
.include "librfu.o"
.include "librfu_rfu.o"
.include "librfu_sio32id.o"