summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRangi <remy.oukaour+rangi42@gmail.com>2021-02-22 12:39:49 -0500
committerRangi <remy.oukaour+rangi42@gmail.com>2021-02-22 12:39:49 -0500
commitbb88e045d10b704bfb6e86f142975016b3329eed (patch)
tree34bb66d1274f7a609566dd8e4c1d0b97aae2f45d
parent95100227ec03465c090e8f21bac3ec5839f8a21d (diff)
Identify link sync buffers, separate from link action bytes
-rw-r--r--engine/link/link.asm10
-rw-r--r--home/serial.asm9
-rw-r--r--wram.asm6
3 files changed, 15 insertions, 10 deletions
diff --git a/engine/link/link.asm b/engine/link/link.asm
index 3dc46e50..c28330f4 100644
--- a/engine/link/link.asm
+++ b/engine/link/link.asm
@@ -2379,20 +2379,20 @@ Link_ResetSerialRegistersAfterLinkClosure:
Link_EnsureSync:
add $d0
- ld [wPlayerLinkAction], a
- ld [wUnusedLinkAction], a
+ ld [wLinkPlayerSyncBuffer], a
+ ld [wLinkPlayerSyncBuffer + 1], a
ld a, $2
ldh [hVBlank], a
call DelayFrame
call DelayFrame
.receive_loop
- call Serial_ExchangeLinkMenuSelection
- ld a, [wOtherPlayerLinkMode]
+ call Serial_ExchangeSyncBytes
+ ld a, [wLinkReceivedSyncBuffer]
ld b, a
and $f0
cp $d0
jr z, .done
- ld a, [wOtherPlayerLinkAction]
+ ld a, [wLinkReceivedSyncBuffer + 1]
ld b, a
and $f0
cp $d0
diff --git a/home/serial.asm b/home/serial.asm
index 808111d5..47494a85 100644
--- a/home/serial.asm
+++ b/home/serial.asm
@@ -244,11 +244,10 @@ SerialDisconnected::
ld [wLinkTimeoutFrames + 1], a
ret
-; This is used to exchange the button press and selected menu item on the link menu.
-; The data is sent thrice and read twice to increase reliability.
-Serial_ExchangeLinkMenuSelection::
- ld hl, wPlayerLinkAction
- ld de, wOtherPlayerLinkMode
+; This is used to check that both players entered the same Cable Club room.
+Serial_ExchangeSyncBytes::
+ ld hl, wLinkPlayerSyncBuffer
+ ld de, wLinkReceivedSyncBuffer
ld c, 2
ld a, TRUE
ldh [hSerialIgnoringInitialData], a
diff --git a/wram.asm b/wram.asm
index 521e393f..1b382d39 100644
--- a/wram.asm
+++ b/wram.asm
@@ -1102,6 +1102,8 @@ wAttrmapEnd::
wTileAnimBuffer:: ds 1 tiles
+; link data
+UNION
wOtherPlayerLinkMode:: db
wOtherPlayerLinkAction::
wBattleAction:: db
@@ -1109,6 +1111,10 @@ wBattleAction:: db
wPlayerLinkAction:: db
wUnusedLinkAction:: db
ds 3
+NEXTU
+wLinkReceivedSyncBuffer:: ds 5
+wLinkPlayerSyncBuffer:: ds 5
+ENDU
wLinkTimeoutFrames:: dw
wLinkByteTimeout:: dw