Skip to content

Commit

Permalink
Define SERIAL_LINK_BYTE_TIMEOUT
Browse files Browse the repository at this point in the history
  • Loading branch information
Rangi42 committed Oct 29, 2020
1 parent a51b1a2 commit 7883e8f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
3 changes: 3 additions & 0 deletions constants/serial_constants.asm
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 3 additions & 2 deletions engine/link/link.asm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions home/serial.asm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 7883e8f

Please sign in to comment.