LinkVSync

This commit is contained in:
PikalaxALT 2017-11-14 08:44:32 -05:00
parent 6f8da5dcb6
commit 3bb450645b
7 changed files with 69 additions and 85 deletions

View File

@ -282,7 +282,7 @@ _0816CE6C:
.pool
_0816CE8C:
bl GameCubeMultiBoot_Quit
ldr r0, =sub_800BA38
ldr r0, =SerialCB
bl SetSerialCallback
_0816CE96:
movs r0, 0

View File

@ -5,80 +5,17 @@
.text
thumb_func_start sub_800B9B8
sub_800B9B8: @ 800B9B8
push {r4,lr}
ldr r3, =gLink
ldrb r4, [r3]
cmp r4, 0
beq _0800B9F4
ldrb r0, [r3, 0x1]
cmp r0, 0x2
beq _0800B9EE
cmp r0, 0x4
bne _0800BA1E
movs r0, 0xD
ldrsb r0, [r3, r0]
cmp r0, 0x8
bgt _0800B9E4
ldrb r0, [r3, 0x10]
cmp r0, 0x1
beq _0800B9EE
movs r0, 0x1
strb r0, [r3, 0x13]
b _0800BA1E
.pool
_0800B9E4:
ldrb r0, [r3, 0x13]
cmp r0, 0x1
beq _0800BA1E
movs r0, 0
strb r0, [r3, 0xD]
_0800B9EE:
bl sub_800BAC0
b _0800BA1E
_0800B9F4:
ldrb r2, [r3, 0x1]
cmp r2, 0x4
beq _0800B9FE
cmp r2, 0x2
bne _0800BA1E
_0800B9FE:
ldr r1, =gUnknown_03000D6C
ldrb r0, [r1]
adds r0, 0x1
strb r0, [r1]
lsls r0, 24
lsrs r0, 24
cmp r0, 0xA
bls _0800BA1E
cmp r2, 0x4
bne _0800BA16
movs r0, 0x2
strb r0, [r3, 0x13]
_0800BA16:
cmp r2, 0x2
bne _0800BA1E
strb r4, [r3, 0x3]
strb r4, [r3, 0xF]
_0800BA1E:
pop {r4}
pop {r0}
bx r0
.pool
thumb_func_end sub_800B9B8
thumb_func_start Timer3Intr
Timer3Intr: @ 800BA28
push {lr}
bl sub_800BD98
bl sub_800BAC0
bl StopTimer
bl StartTransfer
pop {r0}
bx r0
thumb_func_end Timer3Intr
thumb_func_start sub_800BA38
sub_800BA38: @ 800BA38
thumb_func_start SerialCB
SerialCB: @ 800BA38
push {r4,lr}
ldr r4, =gLink
ldr r0, =0x04000128
@ -121,7 +58,7 @@ _0800BA8A:
adds r0, 0x1
movs r2, 0
strb r0, [r3, 0xD]
ldr r1, =gUnknown_03000D6C
ldr r1, =sNumVBlanksWithoutSerialIntr
strb r2, [r1]
lsls r0, 24
asrs r0, 24
@ -137,10 +74,10 @@ _0800BAAA:
pop {r0}
bx r0
.pool
thumb_func_end sub_800BA38
thumb_func_end SerialCB
thumb_func_start sub_800BAC0
sub_800BAC0: @ 800BAC0
thumb_func_start StartTransfer
StartTransfer: @ 800BAC0
ldr r0, =0x04000128
ldrh r1, [r0]
movs r2, 0x80
@ -148,7 +85,7 @@ sub_800BAC0: @ 800BAC0
strh r1, [r0]
bx lr
.pool
thumb_func_end sub_800BAC0
thumb_func_end StartTransfer
thumb_func_start sub_800BAD0
sub_800BAD0: @ 800BAD0
@ -496,8 +433,8 @@ _0800BD8C:
.pool
thumb_func_end sub_800BCE4
thumb_func_start sub_800BD98
sub_800BD98: @ 800BD98
thumb_func_start StopTimer
StopTimer: @ 800BD98
push {lr}
ldr r0, =gLink
ldrb r0, [r0]
@ -516,7 +453,7 @@ _0800BDB4:
pop {r0}
bx r0
.pool
thumb_func_end sub_800BD98
thumb_func_end StopTimer
thumb_func_start sub_800BDCC
sub_800BDCC: @ 800BDCC

View File

@ -7545,13 +7545,13 @@ Rfu_IsMaster: @ 8011AB0
.pool
thumb_func_end Rfu_IsMaster
thumb_func_start LinkVSync
LinkVSync: @ 8011ABC
thumb_func_start RfuVSync
RfuVSync: @ 8011ABC
push {lr}
bl rfu_syncVBlank_
pop {r0}
bx r0
thumb_func_end LinkVSync
thumb_func_end RfuVSync
thumb_func_start sub_8011AC8
sub_8011AC8: @ 8011AC8

View File

@ -246,7 +246,6 @@ void sub_800A418(void);
void SetSuppressLinkErrorMessage(bool8 flag);
void sub_800B524(struct LinkPlayer *linkPlayer);
u8 GetSioMultiSI(void);
void sub_800B9B8(void);
extern u16 gLinkPartnersHeldKeys[6];
extern u32 gLinkDebugSeed;

View File

@ -31,5 +31,6 @@ bool32 sub_8010EC0(void);
bool32 sub_8010F1C(void);
bool32 sub_800F0B8(void);
u32 sub_80124D4(void);
void RfuVSync(void);
#endif //GUARD_LINK_RFU_H

View File

@ -60,7 +60,7 @@ IWRAM_DATA u32 sPlayerDataExchangeStatus;
IWRAM_DATA u32 gUnknown_03000D60;
IWRAM_DATA u8 sLinkTestLastBlockSendPos;
ALIGNED() IWRAM_DATA u8 sLinkTestLastBlockRecvPos[MAX_LINK_PLAYERS];
IWRAM_DATA u8 gUnknown_03000D6C;
IWRAM_DATA u8 sNumVBlanksWithoutSerialIntr;
IWRAM_DATA bool8 gUnknown_03000D6D;
IWRAM_DATA u16 sSendNonzeroCheck;
IWRAM_DATA u16 gUnknown_03000D70;
@ -159,6 +159,7 @@ static void CheckMasterOrSlave(void);
static void InitTimer(void);
static void EnqueueSendCmd(u16 *sendCmd);
static void DequeueRecvCmds(u16 (*recvCmds)[CMD_LENGTH]);
void StartTransfer(void);
// .rodata
@ -1919,7 +1920,7 @@ static void EnableSerial(void)
EnableInterrupts(INTR_FLAG_SERIAL);
REG_SIOMLT_SEND = 0;
CpuFill32(0, &gLink, sizeof(gLink));
gUnknown_03000D6C = 0;
sNumVBlanksWithoutSerialIntr = 0;
sSendNonzeroCheck = 0;
gUnknown_03000D70 = 0;
gUnknown_03000D72 = 0;
@ -2136,3 +2137,49 @@ static void DequeueRecvCmds(u16 (*recvCmds)[CMD_LENGTH])
REG_IME = gLinkSavedIme;
}
void LinkVSync(void)
{
if (gLink.isMaster)
{
switch (gLink.state)
{
case LINK_STATE_CONN_ESTABLISHED:
if (gLink.serialIntrCounter < 9)
{
if (gLink.hardwareError != TRUE)
{
gLink.lag = LAG_MASTER;
}
else
{
StartTransfer();
}
}
else if (gLink.lag != LAG_MASTER)
{
gLink.serialIntrCounter = 0;
StartTransfer();
}
break;
case LINK_STATE_HANDSHAKE:
StartTransfer();
break;
}
}
else if (gLink.state == LINK_STATE_CONN_ESTABLISHED || gLink.state == LINK_STATE_HANDSHAKE)
{
if (++ sNumVBlanksWithoutSerialIntr > 10)
{
if (gLink.state == LINK_STATE_CONN_ESTABLISHED)
{
gLink.lag = LAG_SLAVE;
}
if (gLink.state == LINK_STATE_HANDSHAKE)
{
gLink.playerCount = 0;
gLink.link_field_F = FALSE;
}
}
}
}

View File

@ -316,10 +316,10 @@ extern void ProcessDma3Requests(void);
static void VBlankIntr(void)
{
if (gWirelessCommType != FALSE)
LinkVSync();
if (gWirelessCommType != 0)
RfuVSync();
else if (gLinkVSyncDisabled == FALSE)
sub_800B9B8();
LinkVSync();
gMain.vblankCounter1++;