Merge pull request #216 from PikalaxALT/link_rfu

Port link_rfu from Emerald
This commit is contained in:
PikalaxALT
2020-01-15 11:07:17 -05:00
committed by GitHub
32 changed files with 7589 additions and 15847 deletions
+6 -6
View File
@@ -78,7 +78,7 @@ sub_814B754: @ 814B754
_0814B772:
adds r0, r4, 0
bl SetMainCallback2
ldr r0, _0814B78C @ =gUnknown_3005450
ldr r0, _0814B78C @ =Rfu
mov r1, r8
strh r1, [r0, 0x10]
strh r1, [r0, 0x12]
@@ -86,7 +86,7 @@ _0814B772:
.align 2, 0
_0814B784: .4byte gReceivedRemoteLinkPlayers
_0814B788: .4byte gWirelessCommType
_0814B78C: .4byte gUnknown_3005450
_0814B78C: .4byte Rfu
_0814B790:
bl GetLinkPlayerCount
lsls r0, 24
@@ -103,13 +103,13 @@ _0814B790:
_0814B7AC:
adds r0, r4, 0
bl SetMainCallback2
ldr r0, _0814B7BC @ =gUnknown_3005450
ldr r0, _0814B7BC @ =Rfu
movs r1, 0
strh r1, [r0, 0x10]
strh r1, [r0, 0x12]
b _0814B7DC
.align 2, 0
_0814B7BC: .4byte gUnknown_3005450
_0814B7BC: .4byte Rfu
_0814B7C0:
ldr r6, _0814B7E8 @ =gUnknown_203F3DC
ldr r0, _0814B7EC @ =0x000041c0
@@ -120,7 +120,7 @@ _0814B7C0:
bne _0814B7F4
adds r0, r4, 0
bl SetMainCallback2
ldr r0, _0814B7F0 @ =gUnknown_3005450
ldr r0, _0814B7F0 @ =Rfu
strh r5, [r0, 0x10]
strh r5, [r0, 0x12]
_0814B7DC:
@@ -132,7 +132,7 @@ _0814B7DC:
.align 2, 0
_0814B7E8: .4byte gUnknown_203F3DC
_0814B7EC: .4byte 0x000041c0
_0814B7F0: .4byte gUnknown_3005450
_0814B7F0: .4byte Rfu
_0814B7F4:
str r4, [r5]
movs r4, 0
-3175
View File
File diff suppressed because it is too large Load Diff
-10188
View File
File diff suppressed because it is too large Load Diff
+3 -3
View File
@@ -5722,7 +5722,7 @@ sub_8057910: @ 8057910
lsrs r0, 24
cmp r0, 0x3C
bls _0805792E
bl sub_80FA190
bl LinkRfu_FatalError
_0805792E:
pop {r0}
bx r0
@@ -7124,7 +7124,7 @@ _08058350: .4byte gWirelessCommType
_08058354: .4byte gLink
_08058358: .4byte 0x00000339
_0805835C:
ldr r0, _08058368 @ =gUnknown_3005450
ldr r0, _08058368 @ =Rfu
ldr r1, _0805836C @ =0x000008d2
adds r0, r1
ldrb r0, [r0]
@@ -7132,7 +7132,7 @@ _08058364:
pop {r1}
bx r1
.align 2, 0
_08058368: .4byte gUnknown_3005450
_08058368: .4byte Rfu
_0805836C: .4byte 0x000008d2
thumb_func_end sub_805833C
+2 -2
View File
@@ -3930,7 +3930,7 @@ _081497FA:
sub_8149804: @ 8149804
push {lr}
movs r2, 0
ldr r1, _08149828 @ =gUnknown_3005450
ldr r1, _08149828 @ =Rfu
ldr r3, _0814982C @ =0x0000069e
adds r0, r1, r3
ldrb r0, [r0]
@@ -3947,7 +3947,7 @@ _08149820:
pop {r1}
bx r1
.align 2, 0
_08149828: .4byte gUnknown_3005450
_08149828: .4byte Rfu
_0814982C: .4byte 0x0000069e
_08149830: .4byte 0x000008d2
thumb_func_end sub_8149804
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+1
View File
@@ -0,0 +1 @@
gUnknown_3005E10
+3
View File
@@ -0,0 +1,3 @@
gUnknown_3005440
Rfu
gUnknown_3005E00
-277
View File
@@ -1,277 +0,0 @@
#include "constants/region_map.h"
#include "constants/flags.h"
#include "constants/moves.h"
.include "asm/macros.inc"
.include "constants/constants.inc"
.section .rodata
.align 2
gUnknown_843EBB4:: @ 843EBB4
.byte 0x04, 0x20
.2byte 0x0000
.byte 0x00
.align 1
.2byte 0x0002
.4byte gUnknown_3005440
.4byte gUnknown_3005E00
.byte 0x01, 0x00
.2byte 0x0258, 0x012c
.align 2
gUnknown_843EBCC:: @ 843EBCC
.byte 0x00, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00
gUnknown_843EBD4:: @ 843EBD4
.4byte 0x00000000, 0x00000001, 0x00000003, 0x00000007, 0x0000000f, 0x0000001f, 0x0000003f, 0x0000007f
.4byte 0x000000ff, 0x000001ff, 0x000003ff, 0x000007ff, 0x00000fff, 0x00001fff, 0x00003fff, 0x00007fff
.4byte 0x0000ffff, 0x0001ffff, 0x0003ffff, 0x0007ffff, 0x000fffff, 0x001fffff, 0x003fffff, 0x007fffff
.4byte 0x00ffffff
gUnknown_843EC38:: @ 843EC38
.byte 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02
.byte 0x03
gUnknown_843EC41:: @ 843EC41
.byte 0x00, 0x01, 0x01, 0x02, 0x01, 0x02, 0x02, 0x03
.byte 0x01, 0x02, 0x02, 0x03, 0x02, 0x03, 0x03, 0x04
gUnknown_843EC51:: @ 843EC51
.byte 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00
.byte 0x03, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00
.byte 0x00, 0x00, 0x00
gUnknown_843EC64:: @ 843EC64
.4byte gBlockSendBuffer
.2byte 0xc8
.align 2
.4byte gBlockSendBuffer
.2byte 0xc8
.align 2
.4byte gBlockSendBuffer
.2byte 0x64
.align 2
.4byte gBlockSendBuffer
.2byte 0xdc
.align 2
.4byte gBlockSendBuffer
.2byte 0x28
.align 2
gUnknown_843EC8C:: @ 843EC8C
.2byte 0x0002, 0x7f7d, 0xffff
.macro ascipad str, len
1:
.ascii "\str"
2:
.space \len - (2b - 1b)
.endm
sUnref_843EC92::
ascipad "RFU WAIT", 15
ascipad "RFU BOOT", 15
ascipad "RFU ERROR", 15
ascipad "RFU RESET", 15
ascipad "RFU CONFIG", 15
ascipad "RFU START", 15
ascipad "RFU SC POLL", 15
ascipad "RFU SP POLL", 15
ascipad "RFU START", 15
ascipad "RFU SEND ERR", 15
ascipad "RFU CP POLL", 15
sUnref_843ED38::
ascipad " ", 16
ascipad "RECOVER START ", 16
ascipad "DISSCONECT ", 16
ascipad "RECOVER SUUSES", 16
ascipad "RECOVER FAILED", 16
.align 2
gUnknown_843ED88:: @ 843ED88
.4byte sub_80FA834
.4byte sub_80FAA94
.4byte sub_80FACF0
.align 2
gUnknown_843ED94:: @ 843ED94
abspath "rfu.c"
.align 2
gUnknown_843EDC4:: @ 843EDC4
.asciz "Rfu.RfuFunc == NULL"
.align 2
gUnknown_843EDD8:: @ 843EDD8
.asciz "size<=252"
.align 2
gUnknown_843EDE4:: @ 843EDE4
.asciz "PokemonSioInfo"
.byte 0, 1, 7, 0x14, 0xFF
.align 2
gUnknown_843EDF8:: @ 843EDF8
.asciz "LINK LOSS DISCONNECT!"
.align 2
gUnknown_843EE10:: @ 843EE10
.asciz "LINK LOSS RECOVERY NOW"
.align 2
gUnknown_843EE28:: @ 843EE28
.asciz " "
gUnknown_843EE47:: @ 843EE47
.asciz " "
gUnknown_843EE57:: @ 843EE57
.asciz " "
.asciz " "
.asciz "*"
.align 2
gUnknown_843EE64:: @ 843EE64
.asciz "NOWSLOT"
.align 2
.asciz " "
.align 2
.asciz "CLOCK DRIFT"
.align 2
.asciz "BUSY SEND "
.align 2
.asciz "CMD REJECT "
.align 2
.asciz "CLOCK SLAVE"
.align 2
.asciz "CHILD "
.align 2
.asciz "PARENT"
.align 2
.asciz "SEARCH"
.align 2
gUnknown_843EEC0::
.incbin "graphics/interface/wireless_link_icon.gbapal"
gUnknown_843EEE0::
.incbin "graphics/interface/wireless_link_icon.4bpp.lz"
gUnknown_843F004:: @ 843F004
.byte 0xff, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0x37
.byte 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f
.byte 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47
.byte 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f
.byte 0x00, 0xab, 0xb5, 0xb6, 0xb1, 0x00, 0x00, 0x00
.byte 0x00, 0x00, 0xb2, 0xf1, 0x00, 0xae, 0xad, 0xba
.byte 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8
.byte 0xa9, 0xaa, 0x00, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f
.byte 0x00, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, 0xc0, 0xc1
.byte 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9
.byte 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, 0xd0, 0xd1
.byte 0xd2, 0xd3, 0xd4, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6
.byte 0x00, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xdb
.byte 0xdc, 0xdd, 0xde, 0xdf, 0xe0, 0xe1, 0xe2, 0xe3
.byte 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, 0xeb
.byte 0xec, 0xed, 0xee, 0x2d, 0x2f, 0x30, 0x31, 0x32
.byte 0x33, 0x34, 0x35, 0x36, 0x50, 0x00, 0x01, 0x02
.byte 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a
.byte 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12
.byte 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a
.byte 0x1b, 0xad, 0xb3, 0xb4, 0x00, 0xaf, 0x7d, 0x7f
.byte 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0xa0
.byte 0xae, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57
.byte 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f
.byte 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67
.byte 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f
.byte 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77
.byte 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7e, 0xb0, 0xac
.byte 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23
.byte 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b
.byte 0x2c, 0x2e, 0x87, 0x88, 0x89, 0x8a, 0x8b, 0x8c
.byte 0x8d, 0x8e, 0x8f, 0x90, 0x91, 0x92, 0x93, 0x94
gUnknown_843F104:: @ 843F104
.byte 0x20, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x8b, 0x8c
.byte 0x8d, 0x8e, 0x8f, 0x90, 0x91, 0x92, 0x93, 0x94
.byte 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0x9b, 0x9c
.byte 0x9d, 0x9e, 0x9f, 0xa0, 0xe0, 0xe1, 0xe2, 0xe3
.byte 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, 0xeb
.byte 0xec, 0xed, 0xee, 0xef, 0xf0, 0x7b, 0xf1, 0x7c
.byte 0x7d, 0x7e, 0x7f, 0x80, 0x81, 0x82, 0x83, 0x07
.byte 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f
.byte 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17
.byte 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f
.byte 0x84, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7
.byte 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf
.byte 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7
.byte 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf
.byte 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7
.byte 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xa6, 0xdd, 0xa7
.byte 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xf2
.byte 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa
.byte 0xfb, 0xfc, 0xfd, 0xfe, 0xff, 0x01, 0x02, 0x03
.byte 0x04, 0x05, 0x06, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f
.byte 0xaf, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36
.byte 0x37, 0x38, 0x39, 0x21, 0xdf, 0xa1, 0xb0, 0xa5
.byte 0xde, 0x24, 0x2a, 0xa2, 0xa3, 0x22, 0x23, 0x20
.byte 0xa4, 0x20, 0x2f, 0x41, 0x42, 0x43, 0x44, 0x45
.byte 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d
.byte 0x4e, 0x4f, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55
.byte 0x56, 0x57, 0x58, 0x59, 0x5a, 0x61, 0x62, 0x63
.byte 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b
.byte 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73
.byte 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x20
.byte 0x20, 0x2b, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, 0x20
.byte 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x00
gUnknown_843F204:: @ 843F204
.4byte 0x40000000, 0x00000000
gAnimCmd_843F20C::
obj_image_anim_frame 0x0004, 5
obj_image_anim_frame 0x0008, 5
obj_image_anim_frame 0x000c, 5
obj_image_anim_frame 0x0010, 10
obj_image_anim_frame 0x000c, 5
obj_image_anim_frame 0x0008, 5
obj_image_anim_jump 0
gAnimCmd_843F228::
obj_image_anim_frame 0x0004, 5
obj_image_anim_frame 0x0008, 5
obj_image_anim_frame 0x000c, 10
obj_image_anim_frame 0x0008, 5
obj_image_anim_jump 0
gAnimCmd_843F23C::
obj_image_anim_frame 0x0004, 5
obj_image_anim_frame 0x0008, 5
obj_image_anim_jump 0
gAnimCmd_843F248::
obj_image_anim_frame 0x0004, 10
obj_image_anim_frame 0x0014, 10
obj_image_anim_jump 0
gAnimCmd_843F254::
obj_image_anim_frame 0x0018, 10
obj_image_anim_frame 0x0004, 10
obj_image_anim_jump 0
gSpriteAnimTable_843F260::
.4byte gAnimCmd_843F20C
.4byte gAnimCmd_843F228
.4byte gAnimCmd_843F23C
.4byte gAnimCmd_843F248
.4byte gAnimCmd_843F254
gUnknown_843F274:: @ 843F274
obj_tiles gUnknown_843EEE0, 0x0380, 54321
gUnknown_843F27C:: @ 843F27C
obj_pal gUnknown_843EEC0, 54322
gUnknown_843F284:: @ 843F284
spr_template 54321, 54322, gUnknown_843F204, gSpriteAnimTable_843F260, NULL, gDummySpriteAffineAnimTable, SpriteCallbackDummy
+2
View File
@@ -1549,6 +1549,8 @@ gUnknown_8459580:: @ 8459580
gUnknown_8459588:: @ 8459588
.string "Finished checking {SPECIAL_F7 0x01}'s\nTRAINER CARD.{PAUSE 60}$"
@ why is this data here of all places?
.align 2
gUnknown_84595B0::
.string "Canceled reading the Card.$"
+8 -1
View File
@@ -712,6 +712,12 @@ struct TrainerRematchState
u8 rematches[100];
};
struct TrainerNameRecord
{
u32 trainerId;
u8 trainerName[PLAYER_NAME_LENGTH];
};
struct SaveBlock1
{
/*0x0000*/ struct Coords16 pos;
@@ -766,7 +772,8 @@ struct SaveBlock1
/*0x3A18*/ u8 seen2[DEX_FLAGS_NO];
/*0x3A4C*/ u8 rivalName[PLAYER_NAME_LENGTH];
/*0x3A54*/ struct FameCheckerSaveData fameChecker[NUM_FAMECHECKER_PERSONS];
/*0x3A94*/ u8 filler3A94[0x204];
/*0x3A94*/ u8 filler3A94[0x114];
/*0x3BA8*/ struct TrainerNameRecord trainerNameRecords[20];
/*0x3C98*/ struct DaycareMon route5DayCareMon;
/*0x3D24*/ u8 filler3D24[0x10];
/*0x3D34*/ u32 unkArrayIdx;
+1 -29
View File
@@ -275,34 +275,6 @@
// 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
// TODO: move the 2 structs to some other header as they're declared by GF
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;
u16 unk_01_2:4;
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;
};
// the following structs are not documented in SDK
struct RfuPacket8
{
@@ -616,7 +588,7 @@ u16 rfu_changeSendTarget(u8 connType, u8 slotStatusIndex, u8 bmNewTgtSlot);
// Functions for sending/receiving data to RFU
// Data transmission
void rfu_REQ_sendData(u8 clockChangeFlag);
void rfu_REQ_sendData(bool8 clockChangeFlag);
// Used only by parent device. Resend previous sent data (packet)
void rfu_REQ_PARENT_resumeRetransmitAndChange(void);
// Read receive data
+17
View File
@@ -65,6 +65,19 @@
#define LINKCMD_SEND_HELD_KEYS_2 0xCAFE
#define LINKCMD_0xCCCC 0xCCCC
#define LINKTYPE_0x1111 0x1111 // trade
#define LINKTYPE_0x1122 0x1122 // trade
#define LINKTYPE_0x1133 0x1133 // trade
#define LINKTYPE_0x1144 0x1144 // trade
#define LINKTYPE_BATTLE 0x2211
#define LINKTYPE_0x2222 0x2222 // unused battle?
#define LINKTYPE_SINGLE_BATTLE 0x2233
#define LINKTYPE_DOUBLE_BATTLE 0x2244
#define LINKTYPE_MULTI_BATTLE 0x2255
#define LINKTYPE_BATTLE_TOWER_50 0x2266
#define LINKTYPE_BATTLE_TOWER_OPEN 0x2277
#define LINKTYPE_BATTLE_TOWER 0x2288
#define MASTER_HANDSHAKE 0x8FFF
#define SLAVE_HANDSHAKE 0xB9A0
@@ -188,6 +201,7 @@ extern bool8 gLinkVSyncDisabled;
extern u8 gWirelessCommType;
extern u8 gShouldAdvanceLinkState;
extern u16 gLinkPartnersHeldKeys[6];
void Task_DestroySelf(u8);
void OpenLink(void);
@@ -261,5 +275,8 @@ bool8 IsWirelessAdapterConnected(void);
bool8 sub_800A474(u8 a0);
void LinkVSync(void);
bool8 HandleLinkConnection(void);
void sub_800B0B4(void);
void sub_800B110(u32 who);
void sub_800ACBC(u32 status, u8 lastSendQueueCount, u8 lastRecvQueueCount, u8 unk_06);
#endif // GUARD_LINK_H
+251 -4
View File
@@ -4,14 +4,231 @@
#include "global.h"
#include "librfu.h"
// RfuTgtData.gname is read as these structs.
struct GFtgtGnameSub
{
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;
u16 unk_01_2:4;
u16 unk_01_6:2;
u8 playerTrainerId[2];
};
struct __attribute__((packed, aligned(2))) GFtgtGname
{
struct GFtgtGnameSub 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 Padded_U8
{
u8 value;
};
struct UnkLinkRfuStruct_02022B2C
{
u8 unk_00;
u8 unk_01;
u16 unk_02;
u8 unk_04;
u16 unk_06;
struct GFtgtGname *unk_08;
u8 *unk_0c;
u8 unk_10;
u8 unk_11;
u16 unk_12;
u16 unk_14;
};
struct UnkLinkRfuStruct_02022B44
{
u8 fill_00[6];
u16 unk_06;
u8 fill_08[6];
vu8 unk_0e;
u8 unk_0f;
u8 fill_10[0x54];
u16 unk_64;
u8 fill_66[0x1d];
u8 unk_83;
u8 fill_84[0x58];
};
struct UnkRfuStruct_1
{
/* 0x000 */ u8 unk_00;
/* 0x001 */ u8 unk_01;
/* 0x002 */ vu8 unk_02;
/* 0x003 */ vu8 unk_03;
/* 0x004 */ u8 unk_04;
/* 0x005 */ u8 unk_05;
/* 0x006 */ u8 unk_06;
/* 0x007 */ u8 unk_07;
/* 0x008 */ u8 unk_08;
/* 0x009 */ u8 unk_09;
/* 0x00a */ u8 unk_0a;
/* 0x00b */ u8 unk_0b;
/* 0x00c */ u8 unk_0c;
/* 0x00d */ u8 unk_0d;
/* 0x00e */ u8 unk_0e;
/* 0x00f */ u8 unk_0f;
/* 0x010 */ u8 unk_10;
/* 0x011 */ u8 unk_11;
/* 0x012 */ u8 unk_12;
// aligned
/* 0x014 */ u16 unk_14;
/* 0x016 */ u16 unk_16;
/* 0x018 */ u16 unk_18;
/* 0x01a */ u16 unk_1a;
/* 0x01c */ u16 unk_1c;
/* 0x01e */ u16 unk_1e;
/* 0x020 */ const u16 *unk_20;
/* 0x024 */ u8 unk_24;
/* 0x026 */ u16 unk_26;
/* 0x028 */ u16 unk_28[RFU_CHILD_MAX];
/* 0x030 */ u8 unk_30;
// aligned
/* 0x032 */ u16 unk_32;
/* 0x034 */ u16 unk_34[RFU_CHILD_MAX];
/* 0x03c */ const struct UnkLinkRfuStruct_02022B2C *unk_3c;
/* 0x040 */ void (*unk_40)(u8, u8);
/* 0x044 */ void (*unk_44)(u16);
};
struct UnkRfuStruct_2_Sub_6c
{
/* 0x00 */ u16 unk_00;
/* 0x02 */ u16 unk_02;
/* 0x04 */ const u8 *unk_04;
/* 0x08 */ u32 unk_08;
/* 0x0c */ u32 unk_0c;
/* 0x10 */ u8 unk_10;
/* 0x11 */ u8 unk_11;
/* 0x12 */ u8 unk_12;
};
struct UnkRfuStruct_2_Sub_124
{
/* 0x000 */ u8 unk_00[20][70];
/* 0x578 */ vu8 unk_8c0;
/* 0x579 */ vu8 unk_8c1;
/* 0x57a */ vu8 unk_8c2;
/* 0x57b */ vu8 unk_8c3;
};
struct UnkRfuStruct_2_Sub_9e8
{
/* 0x000 */ u8 unk_00[40][14];
/* 0x230 */ vu8 unk_230;
/* 0x231 */ vu8 unk_231;
/* 0x232 */ vu8 unk_232;
/* 0x233 */ vu8 unk_233;
};
struct UnkRfuStruct_2_Sub_c1c
{
/* 0x00 */ u8 unk_00[2][14];
/* 0x1c */ vu8 unk_1c;
/* 0x1d */ vu8 unk_1d;
/* 0x1e */ vu8 unk_1e;
};
struct UnkRfuStruct_Sub_Unused
{
/* 0x000 */ u8 unk_00[2][256];
/* 0x200 */ vu8 unk_200;
/* 0x201 */ vu8 unk_201;
/* 0x202 */ vu8 unk_202;
/* 0x203 */ vu8 unk_203;
};
struct UnkRfuStruct_2
{
/* 0x000 */ void (*RfuFunc)(void);
/* 0x004 */ u16 unk_04;
/* 0x006 */ u8 filler_06[4];
/* 0x00a */ u16 unk_0a;
/* 0x00c */ u8 unk_0c; // parentChildMode?
/* 0x00d */ u8 playerCount;
/* 0x00e */ u8 unk_0e;
/* 0x00f */ u8 unk_0f;
/* 0x010 */ u16 unk_10;
/* 0x012 */ u16 unk_12;
/* 0x014 */ u8 unk_14[RFU_CHILD_MAX][14];
/* 0x04c */ u8 unk_4c[14];
/* 0x05a */ u8 unk_5a;
/* 0x05b */ u8 unk_5b;
/* 0x05c */ u8 unk_5c[5];
/* 0x061 */ u8 unk_61[5];
/* 0x066 */ u8 unk_66;
/* 0x067 */ u8 unk_67;
/* 0x068 */ u8 filler_68[4];
/* 0x06c */ struct UnkRfuStruct_2_Sub_6c unk_6c;
/* 0x080 */ struct UnkRfuStruct_2_Sub_6c unk_80[5];
/* 0x0e4 */ u8 unk_e4[5];
/* 0x0e9 */ u8 unk_e9[5];
/* 0x0ee */ vu8 unk_ee;
/* 0x0ef */ u8 unk_ef;
/* 0x0f0 */ u8 unk_f0;
/* 0x0f1 */ u8 unk_f1;
/* 0x0f2 */ u16 unk_f2[6];
/* 0x0fe */ u16 unk_fe;
/* 0x100 */ u16 unk_100;
/* 0x102 */ u8 unk_102;
/* 0x104 */ struct RfuTgtData unk_104;
/* 0x124 */ struct UnkRfuStruct_2_Sub_124 unk_124;
/* 0x6a0 */ struct UnkRfuStruct_2_Sub_9e8 unk_9e8;
/* 0x8d4 */ struct UnkRfuStruct_2_Sub_c1c unk_c1c;
/* 0x8f4 */ vu8 unk_c3c;
/* 0x8f5 */ u8 unk_c3d;
/* 0x8f6 */ vu8 unk_c3e;
/* 0x8f7 */ u8 unk_c3f[70];
/* 0x93d */ u8 unk_c85;
/* 0x93e */ u8 unk_c86;
/* 0x93f */ u8 unk_c87[5][7][2];
/* 0x985 */ u8 unk_ccd;
/* 0x986 */ u8 unk_cce; // childId
/* 0x987 */ u8 unk_ccf;
/* 0x988 */ vu8 unk_cd0;
/* 0x989 */ u8 unk_cd1[RFU_CHILD_MAX];
/* 0x98d */ u8 unk_cd5[RFU_CHILD_MAX];
/* 0x991 */ u8 unk_cd9;
/* 0x992 */ u8 unk_cda;
/* 0x993 */ vu8 unk_cdb;
/* 0x994 */ vu8 unk_cdc;
/* 0x995 */ u8 unk_cdd;
/* 0x996 */ u8 unk_cde[RFU_CHILD_MAX];
/* 0x99a */ u8 unk_ce2;
/* 0x99b */ u8 unk_ce3;
/* 0x99c */ u8 unk_ce4;
/* 0x99d */ u8 unk_ce5;
/* 0x99e */ u8 unk_ce6;
/* 0x99f */ u8 unk_ce7;
/* 0x9a0 */ u8 unk_ce8;
/* 0x9a1 */ u8 unk_ce9;
/* 0x9a2 */ u8 unk_cea[RFU_CHILD_MAX];
/* 0x9a6 */ u8 unk_cee[RFU_CHILD_MAX];
}; // size: 0x9AC
extern struct UnkRfuStruct_1 gUnknown_3005E10;
extern struct GFtgtGname gUnknown_3005440;
extern u8 gUnknown_3005E00[];
void AddTextPrinterToWindow1(const u8 *str);
bool32 MG_PrintTextOnWindow1AndWaitButton(u8 * cmdPtr, const u8 * src);
void sub_80FA190(void);
void LinkRfu_FatalError(void);
void MG_DrawCheckerboardPattern(void);
void task_add_05_task_del_08FA224_when_no_RfuFunc(void);
bool8 IsLinkRfuTaskFinished(void);
@@ -29,8 +246,8 @@ bool32 IsSendingKeysToRfu(void);
void Rfu_set_zero(void);
u8 GetRfuPlayerCount(void);
void sub_80F9828(void);
u8 rfu_get_multiplayer_id(void);
bool8 Rfu_InitBlockSend(const void * src, u16 size);
u8 LinkRfu_GetMultiplayerId(void);
bool32 Rfu_InitBlockSend(const u8 * src, size_t size);
bool8 sub_80FA0F8(u8 a0);
u8 Rfu_GetBlockReceivedStatus(void);
void Rfu_SetBlockReceivedFlag(u8 who);
@@ -45,9 +262,39 @@ void sub_80F8DC0(void);
void sub_80FBB20(void);
bool8 sub_80FA484(bool32 a0);
void var_800D_set_xB(void);
struct UnkLinkRfuStruct_02022B14 *sub_80F9800(void);
struct GFtgtGname *sub_80F9800(void);
void sub_80FCF34(void);
void InitRFU(void);
void sub_80FEB14(void);
bool32 sub_80FBA00(void);
void sub_80FC478(struct UnkRfuStruct_2_Sub_124 *ptr);
void sub_80FC4D4(struct UnkRfuStruct_2_Sub_9e8 *ptr);
void sub_80FD4B0(const struct UnkLinkRfuStruct_02022B2C *unk0);
u8 sub_80FD538(u8 r5, u16 r7, u16 r8, const u16 *r6);
void sub_80FD760(bool8 a0);
void sub_80FEA10(void (*func)(u16));
void sub_80FB9E4(u8 a0, u16 a1);
u8 sub_80FB9F4(void);
void LinkRfu_REQ_SendData_HandleParentRelationship(bool8 clockChangeFlag);
void sub_80FC588(struct UnkRfuStruct_2_Sub_124 *q1, u8 *q2);
void sub_80FD52C(void);
u8 sub_80FD610(u16 parentId, u16 unk_1a);
bool8 sub_80FC79C(struct UnkRfuStruct_2_Sub_9e8 *q1, u8 *q2);
bool8 sub_80FC888(struct UnkRfuStruct_2_Sub_c1c *q1, u8 *q2);
void sub_80FC828(struct UnkRfuStruct_2_Sub_c1c *q1, const u8 *q2);
bool8 sub_80FC6E8(struct UnkRfuStruct_2_Sub_124 * a0, u8 *a1);
void sub_80FC63C(struct UnkRfuStruct_2_Sub_9e8 * a0, u8 *a1);
u8 sub_80FEA34(u8 a0, u16 a1);
void sub_80FDA30(u32 a0);
void sub_80FCB54(struct GFtgtGname *data, u8 r9, bool32 r2, s32 r3);
void LinkRfu_syncVBlank_(void);
s32 sub_80FD430(void (*func1)(u8, u8), void (*func2)(u16));
void sub_80FEB3C(void);
void sub_80FAFE0(u8 a0);
bool32 sub_80FA44C(u32 a0);
bool8 sub_80FC1B0(void);
#include "mevent_server.h"
extern const struct mevent_server_cmd gMEventSrvScript_OtherTrainerCanceled[];
+1
View File
@@ -6,5 +6,6 @@ extern bool8 gGiftIsFromEReader;
void MainCB_FreeAllBuffersAndReturnToInitTitleScreen(void);
void PrintMysteryGiftOrEReaderTopMenu(bool8, bool32);
void c2_mystery_gift(void);
void c2_mystery_gift_e_reader_run(void);
#endif //GUARD_MYSTERY_GIFT_MENU_H
+25
View File
@@ -4,6 +4,29 @@
#include "global.h"
#include "main.h"
#define LINK_KEY_CODE_NULL 0x00
#define LINK_KEY_CODE_EMPTY 0x11
#define LINK_KEY_CODE_DPAD_DOWN 0x12
#define LINK_KEY_CODE_DPAD_UP 0x13
#define LINK_KEY_CODE_DPAD_LEFT 0x14
#define LINK_KEY_CODE_DPAD_RIGHT 0x15
#define LINK_KEY_CODE_UNK_2 0x16
#define LINK_KEY_CODE_EXIT_ROOM 0x17
#define LINK_KEY_CODE_START_BUTTON 0x18
#define LINK_KEY_CODE_A_BUTTON 0x19
#define LINK_KEY_CODE_UNK_4 0x1A // I'd guess this is the B button?
// These two are a hack to stop user input until link stuff can be
// resolved.
#define LINK_KEY_CODE_HANDLE_RECV_QUEUE 0x1B
#define LINK_KEY_CODE_HANDLE_SEND_QUEUE 0x1C
#define LINK_KEY_CODE_UNK_7 0x1D
#define LINK_KEY_CODE_UNK_8 0x1E
#define MOVEMENT_MODE_FREE 0
#define MOVEMENT_MODE_FROZEN 1
#define MOVEMENT_MODE_SCRIPTED 2
struct UnkPlayerStruct
{
u8 player_field_0;
@@ -153,4 +176,6 @@ void sub_805546C(u8 a0);
bool32 sub_80582E0(void);
bool32 sub_8058274(void);
extern u16 gHeldKeyCodeToSend;
#endif //GUARD_OVERWORLD_H
+3 -3
View File
@@ -2,7 +2,7 @@
#define GUARD_TRADE_H
#include "global.h"
#include "librfu.h"
#include "link_rfu.h"
#include "constants/trade.h"
extern struct MailStruct gLinkPartnerMail[6];
@@ -11,7 +11,7 @@ extern u8 gSelectedTradeMonPositions[2];
extern const u16 gUnknown_826601C[];
void CB2_ReturnFromLinkTrade(void);
s32 sub_804FB34(void);
s32 CanRegisterMonForTradingBoard(struct UnkLinkRfuStruct_02022B14Substruct rfuPlayer, u16 species2, u16 species, u8 isObedientBitSet);
s32 GetUnionRoomTradeMessageId(struct UnkLinkRfuStruct_02022B14Substruct rfuPlayer, struct UnkLinkRfuStruct_02022B14Substruct rfuPartner, u16 playerSpecies2, u16 partnerSpecies, u8 requestedType, u16 playerSpecies, u8 isObedientBitSet);
s32 CanRegisterMonForTradingBoard(struct GFtgtGnameSub rfuPlayer, u16 species2, u16 species, u8 isObedientBitSet);
s32 GetUnionRoomTradeMessageId(struct GFtgtGnameSub rfuPlayer, struct GFtgtGnameSub rfuPartner, u16 playerSpecies2, u16 partnerSpecies, u8 requestedType, u16 playerSpecies, u8 isObedientBitSet);
#endif //GUARD_TRADE_H
+2 -2
View File
@@ -6,7 +6,7 @@
struct UnkStruct_Shared
{
struct UnkLinkRfuStruct_02022B14 field_0;
struct GFtgtGname field_0;
u8 ALIGNED(4) playerName[PLAYER_NAME_LENGTH];
};
@@ -149,7 +149,7 @@ struct TradeUnkStruct
u32 personality;
};
extern struct UnkLinkRfuStruct_02022B14Substruct gUnknown_203B064;
extern struct GFtgtGnameSub gUnknown_203B064;
extern u16 gUnionRoomOfferedSpecies;
extern u8 gUnionRoomRequestedMonType;
+9 -6
View File
@@ -225,8 +225,9 @@ SECTIONS {
asm/box_party_pokemon_dropdown.o(.text);
src/save_menu_util.o(.text);
src/map_preview_screen.o(.text);
asm/link_rfu_2.o(.text);
asm/link_rfu.o(.text);
src/link_rfu_2.o(.text);
src/link_rfu_3.o(.text);
src/link_rfu.o(.text);
asm/easy_chat_2.o(.text);
src/pokedex_screen.o(.text);
asm/pokedex_screen.o(.text);
@@ -240,7 +241,8 @@ SECTIONS {
src/mailbox_pc.o(.text);
src/menu.o(.text);
src/quest_log.o(.text);
asm/link_rfu_3.o(.text);
asm/union_room.o(.text);
asm/union_room_player_avatar.o(.text);
asm/pokemon_special_anim.o(.text);
src/party_menu.o(.text);
asm/union_room_chat.o(.text);
@@ -509,8 +511,9 @@ SECTIONS {
src/new_menu_helpers.o(.rodata);
data/box_party_pokemon_dropdown.o(.rodata);
src/map_preview_screen.o(.rodata);
data/link_rfu_2.o(.rodata);
data/link_rfu.o(.rodata);
src/link_rfu_2.o(.rodata);
src/link_rfu_3.o(.rodata);
data/easy_chat_2.o(.rodata);
src/pokedex_screen.o(.rodata);
data/pokedex_screen.o(.rodata);
src/list_menu.o(.rodata);
@@ -524,7 +527,7 @@ SECTIONS {
data/decorations.o(.rodata);
src/menu.o(.rodata);
src/quest_log.o(.rodata);
data/link_rfu_3.o(.rodata);
data/union_room.o(.rodata);
data/pokemon_special_anim.o(.rodata);
src/party_menu.o(.rodata);
data/union_room_chat.o(.rodata);
+5 -5
View File
@@ -1533,11 +1533,11 @@ void rfu_UNI_clearRecvNewDataFlag(u8 slotStatusIndex)
gRfuSlotStatusUNI[slotStatusIndex]->recv.newDataFlag = 0;
}
void rfu_REQ_sendData(u8 clockChangeFlag)
void rfu_REQ_sendData(bool8 clockChangeFlag)
{
if (gRfuLinkStatus->parentChild != MODE_NEUTRAL)
{
if (gRfuLinkStatus->parentChild == 1
if (gRfuLinkStatus->parentChild == MODE_PARENT
&& !(gRfuLinkStatus->sendSlotNIFlag | gRfuLinkStatus->recvSlotNIFlag | gRfuLinkStatus->sendSlotUNIFlag))
{
if (gRfuStatic->commExistFlag)
@@ -1555,7 +1555,7 @@ void rfu_REQ_sendData(u8 clockChangeFlag)
gRfuFixed->LLFBuffer[0] = 1;
gRfuFixed->LLFBuffer[4] = 0xFF;
STWI_set_Callback_M(rfu_CB_sendData3);
if (clockChangeFlag == 0)
if (!clockChangeFlag)
STWI_send_DataTxREQ(gRfuFixed->LLFBuffer, 1);
else
STWI_send_DataTxAndChangeREQ(gRfuFixed->LLFBuffer, 1);
@@ -1569,7 +1569,7 @@ void rfu_REQ_sendData(u8 clockChangeFlag)
if (gRfuLinkStatus->LLFReadyFlag)
{
STWI_set_Callback_M(rfu_CB_sendData);
if (clockChangeFlag != 0)
if (clockChangeFlag)
{
STWI_send_DataTxAndChangeREQ(gRfuFixed->LLFBuffer, gRfuStatic->totalPacketSize + 4);
return;
@@ -1577,7 +1577,7 @@ void rfu_REQ_sendData(u8 clockChangeFlag)
STWI_send_DataTxREQ(gRfuFixed->LLFBuffer, gRfuStatic->totalPacketSize + 4);
}
}
if (clockChangeFlag != 0)
if (clockChangeFlag)
{
if (gRfuLinkStatus->parentChild == MODE_PARENT)
{
+1 -1
View File
@@ -984,7 +984,7 @@ u8 GetMultiplayerId(void)
{
if (gWirelessCommType == 1)
{
return rfu_get_multiplayer_id();
return LinkRfu_GetMultiplayerId();
}
return SIO_MULTI_CNT->id;
}
+1381
View File
File diff suppressed because it is too large Load Diff
+2834
View File
File diff suppressed because it is too large Load Diff
+948
View File
@@ -0,0 +1,948 @@
#include "global.h"
#include "decompress.h"
#include "event_data.h"
#include "link.h"
#include "link_rfu.h"
#include "malloc.h"
#include "random.h"
#include "string_util.h"
#include "text.h"
#include "constants/flags.h"
static EWRAM_DATA u8 gWirelessStatusIndicatorSpriteId = 0;
static const u16 gWirelessLinkIconPalette[] = INCBIN_U16("graphics/interface/wireless_link_icon.gbapal");
static const u32 gWirelessLinkIconPic[] = INCBIN_U32("graphics/interface/wireless_link_icon.4bpp.lz");
static const u8 sWireless_ASCIItoRSETable[] = {
0xff, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0x37,
0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f,
0x00, 0xab, 0xb5, 0xb6, 0xb1, 0x00, 0x00, 0x00,
0x00, 0x00, 0xb2, 0xf1, 0x00, 0xae, 0xad, 0xba,
0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8,
0xa9, 0xaa, 0x00, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f,
0x00, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, 0xc0, 0xc1,
0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9,
0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, 0xd0, 0xd1,
0xd2, 0xd3, 0xd4, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6,
0x00, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xdb,
0xdc, 0xdd, 0xde, 0xdf, 0xe0, 0xe1, 0xe2, 0xe3,
0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, 0xeb,
0xec, 0xed, 0xee, 0x2d, 0x2f, 0x30, 0x31, 0x32,
0x33, 0x34, 0x35, 0x36, 0x50, 0x00, 0x01, 0x02,
0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a,
0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12,
0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a,
0x1b, 0xad, 0xb3, 0xb4, 0x00, 0xaf, 0x7d, 0x7f,
0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0xa0,
0xae, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57,
0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f,
0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f,
0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77,
0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7e, 0xb0, 0xac,
0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23,
0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b,
0x2c, 0x2e, 0x87, 0x88, 0x89, 0x8a, 0x8b, 0x8c,
0x8d, 0x8e, 0x8f, 0x90, 0x91, 0x92, 0x93, 0x94
};
static const u8 sWireless_RSEtoASCIITable[] = {
0x20, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x8b, 0x8c,
0x8d, 0x8e, 0x8f, 0x90, 0x91, 0x92, 0x93, 0x94,
0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0x9b, 0x9c,
0x9d, 0x9e, 0x9f, 0xa0, 0xe0, 0xe1, 0xe2, 0xe3,
0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, 0xeb,
0xec, 0xed, 0xee, 0xef, 0xf0, 0x7b, 0xf1, 0x7c,
0x7d, 0x7e, 0x7f, 0x80, 0x81, 0x82, 0x83, 0x07,
0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
0x84, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7,
0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf,
0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7,
0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf,
0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7,
0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xa6, 0xdd, 0xa7,
0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xf2,
0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa,
0xfb, 0xfc, 0xfd, 0xfe, 0xff, 0x01, 0x02, 0x03,
0x04, 0x05, 0x06, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
0xaf, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36,
0x37, 0x38, 0x39, 0x21, 0xdf, 0xa1, 0xb0, 0xa5,
0xde, 0x24, 0x2a, 0xa2, 0xa3, 0x22, 0x23, 0x20,
0xa4, 0x20, 0x2f, 0x41, 0x42, 0x43, 0x44, 0x45,
0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d,
0x4e, 0x4f, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55,
0x56, 0x57, 0x58, 0x59, 0x5a, 0x61, 0x62, 0x63,
0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b,
0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73,
0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x20,
0x20, 0x2b, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x00
};
static const struct OamData sWirelessStatusIndicatorOamData =
{
.y = 0,
.affineMode = ST_OAM_AFFINE_OFF,
.objMode = ST_OAM_OBJ_NORMAL,
.bpp = ST_OAM_4BPP,
.shape = SPRITE_SHAPE(16x16),
.x = 0,
.size = SPRITE_SIZE(16x16),
.tileNum = 0,
.priority = 0,
.paletteNum = 0,
};
static const union AnimCmd sWirelessStatusIndicatorAnim0[] = {
// 3 bars
ANIMCMD_FRAME( 4, 5),
ANIMCMD_FRAME( 8, 5),
ANIMCMD_FRAME(12, 5),
ANIMCMD_FRAME(16, 10),
ANIMCMD_FRAME(12, 5),
ANIMCMD_FRAME( 8, 5),
ANIMCMD_JUMP(0)
};
static const union AnimCmd sWirelessStatusIndicatorAnim1[] = {
// 2 bars
ANIMCMD_FRAME( 4, 5),
ANIMCMD_FRAME( 8, 5),
ANIMCMD_FRAME(12, 10),
ANIMCMD_FRAME( 8, 5),
ANIMCMD_JUMP(0)
};
static const union AnimCmd sWirelessStatusIndicatorAnim2[] = {
// 1 bar
ANIMCMD_FRAME(4, 5),
ANIMCMD_FRAME(8, 5),
ANIMCMD_JUMP(0)
};
static const union AnimCmd sWirelessStatusIndicatorAnim3[] = {
// searching
ANIMCMD_FRAME( 4, 10),
ANIMCMD_FRAME(20, 10),
ANIMCMD_JUMP(0)
};
static const union AnimCmd sWirelessStatusIndicatorAnim4[] = {
// error
ANIMCMD_FRAME(24, 10),
ANIMCMD_FRAME( 4, 10),
ANIMCMD_JUMP(0)
};
static const union AnimCmd *const sWirelessStatusIndicatorAnims[] = {
sWirelessStatusIndicatorAnim0,
sWirelessStatusIndicatorAnim1,
sWirelessStatusIndicatorAnim2,
sWirelessStatusIndicatorAnim3,
sWirelessStatusIndicatorAnim4
};
static const struct CompressedSpriteSheet sWirelessStatusIndicatorSpriteSheet = {
gWirelessLinkIconPic, 0x0380, 0xD431
};
static const struct SpritePalette sWirelessStatusIndicatorSpritePalette = {
gWirelessLinkIconPalette, 0xD432
};
static const struct SpriteTemplate sWirelessStatusIndicatorSpriteTemplate = {
0xD431,
0xD432,
&sWirelessStatusIndicatorOamData,
sWirelessStatusIndicatorAnims,
NULL,
gDummySpriteAffineAnimTable,
SpriteCallbackDummy
};
void sub_80FC478(struct UnkRfuStruct_2_Sub_124 *ptr)
{
s32 i;
s32 j;
for (i = 0; i < 20; i++)
{
for (j = 0; j < 70; j++)
{
ptr->unk_00[i][j] = 0;
}
}
ptr->unk_8c1 = 0;
ptr->unk_8c0 = 0;
ptr->unk_8c2 = 0;
ptr->unk_8c3 = 0;
}
void sub_80FC4D4(struct UnkRfuStruct_2_Sub_9e8 *ptr)
{
s32 i;
s32 j;
for (i = 0; i < 40; i++)
{
for (j = 0; j < 14; j++)
{
ptr->unk_00[i][j] = 0;
}
}
ptr->unk_231 = 0;
ptr->unk_230 = 0;
ptr->unk_232 = 0;
ptr->unk_233 = 0;
}
static void sub_80FC530(struct UnkRfuStruct_Sub_Unused *ptr)
{
s32 i;
s32 j;
for (i = 0; i < 2; i++)
{
for (j = 0; j < 256; j++)
{
ptr->unk_00[i][j] = 0;
}
}
ptr->unk_201 = 0;
ptr->unk_200 = 0;
ptr->unk_202 = 0;
ptr->unk_203 = 0;
}
void sub_80FC588(struct UnkRfuStruct_2_Sub_124 *q1, u8 *q2)
{
s32 i;
u16 imeBak;
u8 count;
if (q1->unk_8c2 < 20)
{
imeBak = REG_IME;
REG_IME = 0;
count = 0;
for (i = 0; i < 70; i += 14)
{
if (q2[i] == 0 && q2[i + 1] == 0)
{
count++;
}
}
if (count != 5)
{
for (i = 0; i < 70; i++)
{
q1->unk_00[q1->unk_8c0][i] = q2[i];
}
q1->unk_8c0++;
q1->unk_8c0 %= 20;
q1->unk_8c2++;
for (i = 0; i < 70; i++)
{
q2[i] = 0;
}
}
REG_IME = imeBak;
}
else
{
q1->unk_8c3 = 1;
}
}
void sub_80FC63C(struct UnkRfuStruct_2_Sub_9e8 *q1, u8 *q2)
{
s32 i;
u16 imeBak;
if (q1->unk_232 < 40)
{
imeBak = REG_IME;
REG_IME = 0;
for (i = 0; i < 14; i++)
{
if (q2[i] != 0)
{
break;
}
}
if (i != 14)
{
for (i = 0; i < 14; i++)
{
q1->unk_00[q1->unk_230][i] = q2[i];
}
q1->unk_230++;
q1->unk_230 %= 40;
q1->unk_232++;
for (i = 0; i < 14; i++)
{
q2[i] = 0;
}
}
REG_IME = imeBak;
}
else
{
q1->unk_233 = 1;
}
}
bool8 sub_80FC6E8(struct UnkRfuStruct_2_Sub_124 *q1, u8 *q2)
{
u16 imeBak;
s32 i;
imeBak = REG_IME;
REG_IME = 0;
if (q1->unk_8c0 == q1->unk_8c1 || q1->unk_8c3 != 0)
{
for (i = 0; i < 70; i++)
{
q2[i] = 0;
}
REG_IME = imeBak;
return FALSE;
}
for (i = 0; i < 70; i++)
{
q2[i] = q1->unk_00[q1->unk_8c1][i];
}
q1->unk_8c1++;
q1->unk_8c1 %= 20;
q1->unk_8c2--;
REG_IME = imeBak;
return TRUE;
}
bool8 sub_80FC79C(struct UnkRfuStruct_2_Sub_9e8 *q1, u8 *q2)
{
s32 i;
u16 imeBak;
if (q1->unk_230 == q1->unk_231 || q1->unk_233 != 0)
{
return FALSE;
}
imeBak = REG_IME;
REG_IME = 0;
for (i = 0; i < 14; i++)
{
q2[i] = q1->unk_00[q1->unk_231][i];
}
q1->unk_231++;
q1->unk_231 %= 40;
q1->unk_232--;
REG_IME = imeBak;
return TRUE;
}
void sub_80FC828(struct UnkRfuStruct_2_Sub_c1c *q1, const u8 *q2)
{
s32 i;
if (q2[1] == 0)
{
sub_80FC888(q1, NULL);
}
else
{
for (i = 0; i < 14; i++)
{
q1->unk_00[q1->unk_1c][i] = q2[i];
}
q1->unk_1c++;
q1->unk_1c %= 2;
if (q1->unk_1e < 2)
{
q1->unk_1e++;
}
else
{
q1->unk_1d = q1->unk_1c;
}
}
}
bool8 sub_80FC888(struct UnkRfuStruct_2_Sub_c1c *q1, u8 *q2)
{
s32 i;
if (q1->unk_1e == 0)
{
return FALSE;
}
if (q2 != NULL)
{
for (i = 0; i < 14; i++)
{
q2[i] = q1->unk_00[q1->unk_1d][i];
}
}
q1->unk_1d++;
q1->unk_1d %= 2;
q1->unk_1e--;
return TRUE;
}
static void sub_80FC8D8(struct UnkRfuStruct_Sub_Unused *q1, u8 *q2)
{
s32 i;
if (q1->unk_202 < 2)
{
for (i = 0; i < 256; i++)
{
q1->unk_00[q1->unk_200][i] = q2[i];
}
q1->unk_200++;
q1->unk_200 %= 2;
q1->unk_202++;
}
else
{
q1->unk_203 = 1;
}
}
static bool8 sub_80FC944(struct UnkRfuStruct_Sub_Unused *q1, u8 *q2)
{
s32 i;
if (q1->unk_200 == q1->unk_201 || q1->unk_203)
{
return FALSE;
}
for (i = 0; i < 256; i++)
{
q2[i] = q1->unk_00[q1->unk_201][i];
}
q1->unk_201++;
q1->unk_201 %= 2;
q1->unk_202--;
return TRUE;
}
static void sub_80FC9B8(u8 *q1, u8 mode)
{
s32 i;
u8 rval;
u16 r5 = 0;
static u8 _3002018;
switch (mode)
{
case 0:
for (i = 0; i < 200; i++)
{
q1[i] = i + 1;
r5 += i + 1;
}
*((u16 *)(q1 + i)) = r5;
break;
case 1:
for (i = 0; i < 100; i++)
{
q1[i] = i + 1;
r5 += i + 1;
}
*((u16 *)(q1 + 200)) = r5;
break;
case 2:
for (i = 0; i < 200; i++)
{
rval = Random();
q1[i] = rval;
r5 += rval;
}
*((u16 *)(q1 + i)) = r5;
break;
case 3:
for (i = 0; i < 200; i++)
{
q1[i] = i + 1 + _3002018;
r5 += (i + 1 + _3002018) & 0xFF;
}
*((u16 *)(q1 + i)) = r5;
_3002018++;
break;
}
}
static void PkmnStrToASCII(u8 *q1, const u8 *q2)
{
s32 i;
for (i = 0; q2[i] != EOS; i++)
{
q1[i] = sWireless_RSEtoASCIITable[q2[i]];
}
q1[i] = 0;
}
static void ASCIIToPkmnStr(u8 *q1, const u8 *q2)
{
s32 i;
for (i = 0; q2[i] != 0; i++)
{
q1[i] = sWireless_ASCIItoRSETable[q2[i]];
}
q1[i] = EOS;
}
#ifdef NONMATCHING
static u8 sub_80FCADC(u8 maxFlags)
{
u8 flagCount = 0;
u8 flags = gRfuLinkStatus->connSlotFlag;
u8 i;
if (gRfuLinkStatus->parentChild == MODE_PARENT)
{
for (i = 0; i < 4; flags >>= 1, i++)
{
if (flags & 1)
{
if (maxFlags == flagCount + 1)
return gRfuLinkStatus->strength[i];
flagCount++;
}
}
return 0;
}
else
{
for (i = 0; i < 4; flags >>= 1, i++)
{
if (flags & 1)
return gRfuLinkStatus->strength[i];
}
return 0;
}
}
#else
NAKED
static u8 sub_80FCADC(u8 maxFlags)
{
asm_unified("\tpush {r4-r7,lr}\n"
"\tlsls r0, 24\n"
"\tlsrs r5, r0, 24\n"
"\tmovs r6, 0\n"
"\tldr r0, _080FCB04 @ =gRfuLinkStatus\n"
"\tldr r4, [r0]\n"
"\tldrb r2, [r4, 0x2]\n"
"\tldrb r1, [r4]\n"
"\tadds r7, r0, 0\n"
"\tcmp r1, 0x1\n"
"\tbne _080FCB32\n"
"\tmovs r3, 0\n"
"\tands r1, r2\n"
"\tcmp r1, 0\n"
"\tbeq _080FCB0E\n"
"\tcmp r5, 0x1\n"
"\tbne _080FCB08\n"
"\tldrb r0, [r4, 0xA]\n"
"\tb _080FCB4C\n"
"\t.align 2, 0\n"
"_080FCB04: .4byte gRfuLinkStatus\n"
"_080FCB08:\n"
"\tadds r0, r6, 0x1\n"
"\tlsls r0, 24\n"
"\tlsrs r6, r0, 24\n"
"_080FCB0E:\n"
"\tlsrs r2, 1\n"
"\tadds r0, r3, 0x1\n"
"\tlsls r0, 24\n"
"\tlsrs r3, r0, 24\n"
"\tcmp r3, 0x3\n"
"\tbhi _080FCB4A\n"
"\tmovs r0, 0x1\n"
"\tands r0, r2\n"
"\tcmp r0, 0\n"
"\tbeq _080FCB0E\n"
"\tadds r0, r6, 0x1\n"
"\tcmp r5, r0\n"
"\tbne _080FCB08\n"
"_080FCB28:\n"
"\tldr r0, [r7]\n"
"\tadds r0, 0xA\n"
"\tadds r0, r3\n"
"\tldrb r0, [r0]\n"
"\tb _080FCB4C\n"
"_080FCB32:\n"
"\tmovs r3, 0\n"
"\tmovs r1, 0x1\n"
"_080FCB36:\n"
"\tadds r0, r2, 0\n"
"\tands r0, r1\n"
"\tcmp r0, 0\n"
"\tbne _080FCB28\n"
"\tlsrs r2, 1\n"
"\tadds r0, r3, 0x1\n"
"\tlsls r0, 24\n"
"\tlsrs r3, r0, 24\n"
"\tcmp r3, 0x3\n"
"\tbls _080FCB36\n"
"_080FCB4A:\n"
"\tmovs r0, 0\n"
"_080FCB4C:\n"
"\tpop {r4-r7}\n"
"\tpop {r1}\n"
"\tbx r1");
}
#endif
void sub_80FCB54(struct GFtgtGname *data, u8 r9, bool32 r2, s32 r3)
{
s32 i;
for (i = 0; i < 2; i++)
{
data->unk_00.playerTrainerId[i] = gSaveBlock2Ptr->playerTrainerId[i];
}
for (i = 0; i < RFU_CHILD_MAX; i++)
{
data->unk_04[i] = r3;
r3 >>= 8;
}
data->playerGender = gSaveBlock2Ptr->playerGender;
data->unk_0a_0 = r9;
data->unk_0a_7 = r2;
data->unk_00.unk_00_0 = GAME_LANGUAGE;
data->unk_00.unk_01_2 = GAME_VERSION;
data->unk_00.unk_00_4 = 0;
data->unk_00.unk_00_5 = 0;
data->unk_00.unk_00_6 = 0;
data->unk_00.isChampion = FlagGet(FLAG_SYS_CAN_LINK_WITH_RS);
data->unk_00.hasNationalDex = IsNationalPokedexEnabled();
data->unk_00.gameClear = FlagGet(FLAG_SYS_GAME_CLEAR);
}
bool8 sub_80FCC3C(struct GFtgtGname *buff1, u8 *buff2, u8 idx)
{
bool8 retVal;
if (gUnknown_3005E10.unk_06 == 1)
{
retVal = TRUE;
if (sub_80FA44C(gRfuLinkStatus->partner[idx].serialNo) && ((gRfuLinkStatus->getNameFlag >> idx) & 1))
{
memcpy(buff1, &gRfuLinkStatus->partner[idx].gname, RFU_GAME_NAME_LENGTH);
memcpy(buff2, gRfuLinkStatus->partner[idx].uname, RFU_USER_NAME_LENGTH);
}
else
{
memset(buff1, 0, RFU_GAME_NAME_LENGTH);
memset(buff2, 0, RFU_USER_NAME_LENGTH);
}
}
else
{
retVal = FALSE;
if (sub_80FA44C(gRfuLinkStatus->partner[idx].serialNo))
{
memcpy(buff1, &gRfuLinkStatus->partner[idx].gname, RFU_GAME_NAME_LENGTH);
memcpy(buff2, gRfuLinkStatus->partner[idx].uname, RFU_USER_NAME_LENGTH);
}
else
{
memset(buff1, 0, RFU_GAME_NAME_LENGTH);
memset(buff2, 0, RFU_USER_NAME_LENGTH);
}
}
return retVal;
}
bool8 sub_80FCCF4(struct GFtgtGname *buff1, u8 *buff2, u8 idx)
{
bool8 retVal = FALSE;
if (gRfuLinkStatus->partner[idx].serialNo == 0x7F7D)
{
memcpy(buff1, gRfuLinkStatus->partner[idx].gname, RFU_GAME_NAME_LENGTH);
memcpy(buff2, gRfuLinkStatus->partner[idx].uname, RFU_USER_NAME_LENGTH);
retVal = TRUE;
}
else
{
memset(buff1, 0, RFU_GAME_NAME_LENGTH);
memset(buff2, 0, RFU_USER_NAME_LENGTH);
}
return retVal;
}
void sub_80FCD50(struct GFtgtGname *buff1, u8 *buff2)
{
memcpy(buff1, &gUnknown_3005440, RFU_GAME_NAME_LENGTH);
memcpy(buff2, gUnknown_3005E00, RFU_USER_NAME_LENGTH);
}
void CreateWirelessStatusIndicatorSprite(u8 x, u8 y)
{
u8 sprId;
if (x == 0 && y == 0)
{
x = 0xE7;
y = 0x08;
}
if (gRfuLinkStatus->parentChild == MODE_PARENT)
{
sprId = CreateSprite(&sWirelessStatusIndicatorSpriteTemplate, x, y, 0);
gSprites[sprId].data[7] = 0x1234;
gSprites[sprId].data[6] = GetSpriteTileStartByTag(sWirelessStatusIndicatorSpriteSheet.tag);
gSprites[sprId].invisible = TRUE;
gWirelessStatusIndicatorSpriteId = sprId;
}
else
{
gWirelessStatusIndicatorSpriteId = CreateSprite(&sWirelessStatusIndicatorSpriteTemplate, x, y, 0);
gSprites[gWirelessStatusIndicatorSpriteId].data[7] = 0x1234;
gSprites[gWirelessStatusIndicatorSpriteId].data[6] = GetSpriteTileStartByTag(sWirelessStatusIndicatorSpriteSheet.tag);
gSprites[gWirelessStatusIndicatorSpriteId].invisible = TRUE;
}
}
void DestroyWirelessStatusIndicatorSprite(void)
{
if (gSprites[gWirelessStatusIndicatorSpriteId].data[7] == 0x1234)
{
gSprites[gWirelessStatusIndicatorSpriteId].data[7] = 0;
DestroySprite(&gSprites[gWirelessStatusIndicatorSpriteId]);
gMain.oamBuffer[125] = gDummyOamData;
CpuCopy16(&gDummyOamData, (struct OamData *)OAM + 125, sizeof(struct OamData));
}
}
void LoadWirelessStatusIndicatorSpriteGfx(void)
{
if (GetSpriteTileStartByTag(sWirelessStatusIndicatorSpriteSheet.tag) == 0xFFFF)
{
LoadCompressedSpriteSheet(&sWirelessStatusIndicatorSpriteSheet);
}
LoadSpritePalette(&sWirelessStatusIndicatorSpritePalette);
gWirelessStatusIndicatorSpriteId = 0xFF;
}
static u8 sub_80FCEE4(void)
{
u8 i;
u8 flags = gRfuLinkStatus->connSlotFlag;
for (i = 0; i < RFU_CHILD_MAX; i++)
{
if (flags & 1)
{
return gRfuLinkStatus->strength[i];
}
flags >>= 1;
}
return 0;
}
static void sub_80FCF1C(struct Sprite *sprite, s32 signalStrengthAnimNum)
{
if (sprite->data[2] != signalStrengthAnimNum)
{
sprite->data[2] = signalStrengthAnimNum;
sprite->data[3] = 0;
sprite->data[4] = 0;
}
}
void sub_80FCF34(void)
{
if (gWirelessStatusIndicatorSpriteId != 0xFF && gSprites[gWirelessStatusIndicatorSpriteId].data[7] == 0x1234)
{
struct Sprite *sprite = &gSprites[gWirelessStatusIndicatorSpriteId];
u8 signalStrength = 255;
u8 i = 0;
if (gRfuLinkStatus->parentChild == MODE_PARENT)
{
for (i = 0; i < GetLinkPlayerCount() - 1; i++)
{
if (signalStrength >= sub_80FCADC(i + 1))
{
signalStrength = sub_80FCADC(i + 1);
}
}
}
else
{
signalStrength = sub_80FCEE4();
}
if (sub_80FC1B0() == TRUE)
{
sprite->data[0] = 4;
}
else if (signalStrength < 25)
{
sprite->data[0] = 3;
}
else if (signalStrength >= 25 && signalStrength < 127)
{
sprite->data[0] = 2;
}
else if (signalStrength >= 127 && signalStrength < 229)
{
sprite->data[0] = 1;
}
else if (signalStrength >= 229)
{
sprite->data[0] = 0;
}
if (sprite->data[0] != sprite->data[1])
{
sub_80FCF1C(sprite, sprite->data[0]);
sprite->data[1] = sprite->data[0];
}
if (sprite->anims[sprite->data[2]][sprite->data[4]].frame.duration < sprite->data[3])
{
sprite->data[4]++;
sprite->data[3] = 0;
if (sprite->anims[sprite->data[2]][sprite->data[4]].type == -2)
{
sprite->data[4] = 0;
}
}
else
{
sprite->data[3]++;
}
gMain.oamBuffer[125] = sWirelessStatusIndicatorOamData;
gMain.oamBuffer[125].x = sprite->pos1.x + sprite->centerToCornerVecX;
gMain.oamBuffer[125].y = sprite->pos1.y + sprite->centerToCornerVecY;
gMain.oamBuffer[125].paletteNum = sprite->oam.paletteNum;
gMain.oamBuffer[125].tileNum = sprite->data[6] + sprite->anims[sprite->data[2]][sprite->data[4]].frame.imageValue;
CpuCopy16(gMain.oamBuffer + 125, (struct OamData *)OAM + 125, sizeof(struct OamData));
if (sub_80FB9F4() == 1)
{
DestroyWirelessStatusIndicatorSprite();
}
}
}
static void CopyTrainerRecord(struct TrainerNameRecord *dest, u32 trainerId, const u8 *name)
{
int i;
dest->trainerId = trainerId;
for (i = 0; i < 7; i++)
{
if (name[i] == EOS)
break;
dest->trainerName[i] = name[i];
}
dest->trainerName[i] = EOS;
}
static void ZeroName(u8 *name)
{
s32 i;
for (i = 0; i < PLAYER_NAME_LENGTH; i++)
{
*name++ = 0;
}
}
static bool32 NameIsEmpty(const u8 *name)
{
s32 i;
for (i = 0; i < PLAYER_NAME_LENGTH; i++)
{
if (*name++ != 0)
{
return FALSE;
}
}
return TRUE;
}
// Save the currently connected players into the trainer records, shifting all previous records down.
void RecordMixTrainerNames(void)
{
if (gWirelessCommType != 0)
{
s32 i;
s32 j;
s32 nextSpace;
s32 connectedTrainerRecordIndices[5];
struct TrainerNameRecord *newRecords = AllocZeroed(20 * sizeof(struct TrainerNameRecord));
// Check if we already have a record saved for connected trainers.
for (i = 0; i < GetLinkPlayerCount(); i++)
{
connectedTrainerRecordIndices[i] = -1;
for (j = 0; j < 20; j++)
{
if ((u16)gLinkPlayers[i].trainerId == gSaveBlock1Ptr->trainerNameRecords[j].trainerId && StringCompare(gLinkPlayers[i].name, gSaveBlock1Ptr->trainerNameRecords[j].trainerName) == 0)
{
connectedTrainerRecordIndices[i] = j;
}
}
}
// Save the connected trainers first, at the top of the list.
nextSpace = 0;
for (i = 0; i < GetLinkPlayerCount(); i++)
{
if (i != GetMultiplayerId() && gLinkPlayers[i].language != LANGUAGE_JAPANESE)
{
CopyTrainerRecord(&newRecords[nextSpace], (u16)gLinkPlayers[i].trainerId, gLinkPlayers[i].name);
// If we already had a record for this trainer, wipe it so that the next step doesn't duplicate it.
if (connectedTrainerRecordIndices[i] >= 0)
{
ZeroName(gSaveBlock1Ptr->trainerNameRecords[connectedTrainerRecordIndices[i]].trainerName);
}
nextSpace++;
}
}
// Copy all non-empty records to the new list, in the order they appear on the old list. If the list is full,
// the last (oldest) records will be dropped.
for (i = 0; i < 20; i++)
{
if (!NameIsEmpty(gSaveBlock1Ptr->trainerNameRecords[i].trainerName))
{
CopyTrainerRecord(&newRecords[nextSpace], gSaveBlock1Ptr->trainerNameRecords[i].trainerId, gSaveBlock1Ptr->trainerNameRecords[i].trainerName);
if (++nextSpace >= 20)
{
break;
}
}
}
// Finalize the new list, and clean up.
memcpy(gSaveBlock1Ptr->trainerNameRecords, newRecords, 20 * sizeof(struct TrainerNameRecord));
Free(newRecords);
}
}
bool32 sub_80FD338(u16 id, u8 *name)
{
s32 i;
for (i = 0; i < 20; i++)
{
if (StringCompareN(gSaveBlock1Ptr->trainerNameRecords[i].trainerName, name, 7) == 0 && gSaveBlock1Ptr->trainerNameRecords[i].trainerId == id)
{
return TRUE;
}
if (NameIsEmpty(gSaveBlock1Ptr->trainerNameRecords[i].trainerName))
{
return FALSE;
}
}
return FALSE;
}
+4 -4
View File
@@ -96,12 +96,12 @@ static bool32 mevent_receive_func(struct mevent_srv_sub * svr)
svr->recvCRC = header.crc;
if (svr->recvSize > ME_SEND_BUF_SIZE)
{
sub_80FA190();
LinkRfu_FatalError();
return FALSE;
}
else if (svr->recvIdent != header.ident)
{
sub_80FA190();
LinkRfu_FatalError();
return FALSE;
}
else
@@ -133,7 +133,7 @@ static bool32 mevent_receive_func(struct mevent_srv_sub * svr)
case 2:
if (CalcCRC16WithTable(svr->recvBfr, svr->recvSize) != svr->recvCRC)
{
sub_80FA190();
LinkRfu_FatalError();
return FALSE;
}
else
@@ -192,7 +192,7 @@ static bool32 mevent_send_func(struct mevent_srv_sub * svr)
if (IsLinkTaskFinished())
{
if (CalcCRC16WithTable(svr->sendBfr, svr->sendSize) != svr->sendCRC)
sub_80FA190();
LinkRfu_FatalError();
else
++svr->seqno;
}
+2 -2
View File
@@ -3881,7 +3881,7 @@ static void CursorCB_Register(u8 taskId)
u16 species = GetMonData(&gPlayerParty[gPartyMenu.slotId], MON_DATA_SPECIES);
u8 obedience = GetMonData(&gPlayerParty[gPartyMenu.slotId], MON_DATA_OBEDIENCE);
switch (CanRegisterMonForTradingBoard(*(struct UnkLinkRfuStruct_02022B14Substruct *)sub_80F9800(), species2, species, obedience))
switch (CanRegisterMonForTradingBoard(*(struct GFtgtGnameSub *)sub_80F9800(), species2, species, obedience))
{
case CANT_REGISTER_MON:
StringExpandPlaceholders(gStringVar4, gText_PkmnCantBeTradedNow);
@@ -3907,7 +3907,7 @@ static void CursorCB_Trade1(u8 taskId)
u16 species2 = GetMonData(&gPlayerParty[gPartyMenu.slotId], MON_DATA_SPECIES2);
u16 species = GetMonData(&gPlayerParty[gPartyMenu.slotId], MON_DATA_SPECIES);
u8 obedience = GetMonData(&gPlayerParty[gPartyMenu.slotId], MON_DATA_OBEDIENCE);
u32 stringId = GetUnionRoomTradeMessageId(*(struct UnkLinkRfuStruct_02022B14Substruct *)sub_80F9800(), gUnknown_203B064, species2, gUnionRoomOfferedSpecies, gUnionRoomRequestedMonType, species, obedience);
u32 stringId = GetUnionRoomTradeMessageId(*(struct GFtgtGnameSub *)sub_80F9800(), gUnknown_203B064, species2, gUnionRoomOfferedSpecies, gUnionRoomRequestedMonType, species, obedience);
if (stringId != UR_TRADE_MSG_NONE)
{
+2 -2
View File
@@ -2763,7 +2763,7 @@ static bool32 IsDeoxysOrMewUntradable(u16 species, bool8 isObedientBitSet)
return FALSE;
}
int GetUnionRoomTradeMessageId(struct UnkLinkRfuStruct_02022B14Substruct a0, struct UnkLinkRfuStruct_02022B14Substruct a1, u16 species1, u16 species2, u8 type, u16 species3, u8 isObedientBitSet)
int GetUnionRoomTradeMessageId(struct GFtgtGnameSub a0, struct GFtgtGnameSub a1, u16 species1, u16 species2, u8 type, u16 species3, u8 isObedientBitSet)
{
u8 r9 = a0.hasNationalDex;
u8 r4 = a0.isChampion;
@@ -2843,7 +2843,7 @@ int GetUnionRoomTradeMessageId(struct UnkLinkRfuStruct_02022B14Substruct a0, str
return 0;
}
int CanRegisterMonForTradingBoard(struct UnkLinkRfuStruct_02022B14Substruct a0, u16 species, u16 a2, u8 a3)
int CanRegisterMonForTradingBoard(struct GFtgtGnameSub a0, u16 species, u16 a2, u8 a3)
{
u8 canTradeEggAndNational = a0.hasNationalDex;
+5 -16
View File
@@ -70,22 +70,11 @@ gUnknown_3000FE8: @ 3000FE8
.align 2
.include "src/easy_chat.o"
gUnknown_3001188: @ 3001188
.space 0x8
gRfuAPIBuffer: @ 3001190
.space 0xE68
gUnknown_3001FF8: @ 3001FF8
.space 0x10
gUnknown_3002008: @ 3002008
.space 0x10
gUnknown_3002018: @ 3002018
.space 0x4
.align 2
.include "src/link_rfu_2.o"
.align 2
.include "src/link_rfu_3.o"
.align 2
.include "src/quest_log.o"
.align 2
+4 -54
View File
@@ -75,60 +75,10 @@ gUnknown_3005078: @ 3005078
gUnknown_3005430: @ 3005430
.space 0x10
gUnknown_3005440: @ 3005440
.space 0x10
gUnknown_3005450: @ 3005450
.space 0x14
gUnknown_3005464: @ 3005464
.space 0x58
gUnknown_30054BC: @ 30054BC
.space 0x2
gUnknown_30054BE: @ 30054BE
.space 0x76
gUnknown_3005534: @ 3005534
.space 0xE
gUnknown_3005542: @ 3005542
.space 0x18
gUnknown_300555A: @ 300555A
.space 0x1A
gUnknown_3005574: @ 3005574
.space 0x57C
gUnknown_3005AF0: @ 3005AF0
.space 0x29F
gUnknown_3005D8F: @ 3005D8F
.space 0x47
gUnknown_3005DD6: @ 3005DD6
.space 0x3
gUnknown_3005DD9: @ 3005DD9
.space 0x4
gUnknown_3005DDD: @ 3005DDD
.space 0x9
gUnknown_3005DE6: @ 3005DE6
.space 0x1A
gUnknown_3005E00: @ 3005E00
.space 0x10
gUnknown_3005E10: @ 3005E10
.space 0x10
gUnknown_3005E20: @ 3005E20
.space 0x40
.align 4
.include "link_rfu_2.o"
.align 4
.include "link_rfu.o"
.align 4
.include "list_menu.o"
.align 2
+4 -10
View File
@@ -17,7 +17,6 @@
.include "src/link.o"
.space 8
@ .include "src/link_rfu.o"
.align 2
.include "src/battle_controllers.o"
.align 2
@@ -330,16 +329,11 @@ gUnknown_203ABE8: @ 203ABE8
.align 2
.include "src/map_preview_screen.o"
.align 2
gUnknown_203ABF0: @ 203ABF0
.space 0x18
gUnknown_203AC08: @ 203AC08
.space 0xDC
gUnknown_203ACE4: @ 203ACE4
.space 0x4
.include "src/link_rfu_2.o"
.align 2
.include "src/link_rfu_3.o"
.align 2
gUnknown_203ACE8: @ 203ACE8
.space 0x4