summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRangi <remy.oukaour+rangi42@gmail.com>2020-10-29 16:43:28 -0400
committerRangi <remy.oukaour+rangi42@gmail.com>2020-10-29 16:43:28 -0400
commit7883e8f431a0b8f995c8f581af248b53896e5aa5 (patch)
tree75eac0ae6bb0e55b77b985de9e9877ed62f208c7
parenta51b1a2f1399798193e3d788d9f3fb8bb9f3ac5c (diff)
Define SERIAL_LINK_BYTE_TIMEOUT
-rw-r--r--constants/serial_constants.asm3
-rw-r--r--engine/link/link.asm5
-rw-r--r--home/serial.asm5
3 files changed, 9 insertions, 4 deletions
diff --git a/constants/serial_constants.asm b/constants/serial_constants.asm
index 7113eb690..715534372 100644
--- a/constants/serial_constants.asm
+++ b/constants/serial_constants.asm
@@ -31,4 +31,7 @@ SERIAL_PATCH_LIST_PART_TERMINATOR EQU $ff
SERIAL_PREAMBLE_LENGTH EQU 6
+; timeout duration after exchanging a byte
+SERIAL_LINK_BYTE_TIMEOUT EQU $5000
+
MAX_MYSTERY_GIFT_PARTNERS EQU 5
diff --git a/engine/link/link.asm b/engine/link/link.asm
index 7c8edddd2..3fa34df03 100644
--- a/engine/link/link.asm
+++ b/engine/link/link.asm
@@ -28,9 +28,10 @@ LinkCommunications:
call SetTradeRoomBGPals
call WaitBGMap2
ld hl, wLinkByteTimeout
- xor a ; LOW($5000)
+ assert LOW(SERIAL_LINK_BYTE_TIMEOUT) == 0
+ xor a ; LOW(SERIAL_LINK_BYTE_TIMEOUT)
ld [hli], a
- ld [hl], HIGH($5000)
+ ld [hl], HIGH(SERIAL_LINK_BYTE_TIMEOUT)
ld a, [wLinkMode]
cp LINK_TIMECAPSULE
jp nz, Gen2ToGen2LinkComms
diff --git a/home/serial.asm b/home/serial.asm
index 40cdc8c33..f6e9e7db7 100644
--- a/home/serial.asm
+++ b/home/serial.asm
@@ -191,9 +191,10 @@ Serial_ExchangeByte::
sub 1 << SERIAL
jr nz, .non_serial_interrupts_enabled
- ; a == LOW($5000)
+ ; a == 0
+ assert LOW(SERIAL_LINK_BYTE_TIMEOUT) == 0
ld [wLinkByteTimeout], a
- ld a, HIGH($5000)
+ ld a, HIGH(SERIAL_LINK_BYTE_TIMEOUT)
ld [wLinkByteTimeout + 1], a
.non_serial_interrupts_enabled