diff options
Diffstat (limited to 'home/serial.asm')
-rw-r--r-- | home/serial.asm | 50 |
1 files changed, 24 insertions, 26 deletions
diff --git a/home/serial.asm b/home/serial.asm index 0fb1750b..78814317 100644 --- a/home/serial.asm +++ b/home/serial.asm @@ -10,7 +10,7 @@ Serial:: bit 0, a jr nz, .printer - ldh a, [hLinkPlayerNumber] + ldh a, [hSerialConnectionStatus] inc a ; is it equal to CONNECTION_NOT_ESTABLISHED? jr z, .establish_connection @@ -20,7 +20,7 @@ Serial:: ldh a, [hSerialSend] ldh [rSB], a - ldh a, [hLinkPlayerNumber] + ldh a, [hSerialConnectionStatus] cp USING_INTERNAL_CLOCK jr z, .player2 @@ -43,7 +43,7 @@ Serial:: .player1 ldh [hSerialReceive], a - ldh [hLinkPlayerNumber], a + ldh [hSerialConnectionStatus], a cp USING_INTERNAL_CLOCK jr z, ._player2 @@ -57,7 +57,6 @@ Serial:: bit 7, a jr nz, .wait_bit_7 - ; Cycle the serial controller ld a, (0 << rSC_ON) | (0 << rSC_CLOCK) ldh [rSC], a ld a, (1 << rSC_ON) | (0 << rSC_CLOCK) @@ -70,7 +69,7 @@ Serial:: .player2 ld a, TRUE - ldh [hFFCC], a + ldh [hSerialReceivedNewData], a ld a, SERIAL_NO_DATA_BYTE ldh [hSerialSend], a @@ -82,8 +81,8 @@ Serial:: reti Serial_ExchangeBytes:: - ld a, 1 - ldh [hFFCE], a + ld a, $1 + ldh [hSerialIgnoringInitialData], a .loop ld a, [hl] ldh [hSerialSend], a @@ -95,7 +94,7 @@ Serial_ExchangeBytes:: .wait dec a jr nz, .wait - ldh a, [hFFCE] + ldh a, [hSerialIgnoringInitialData] and a ld a, b pop bc @@ -104,7 +103,7 @@ Serial_ExchangeBytes:: cp SERIAL_PREAMBLE_BYTE jr nz, .loop xor a - ldh [hFFCE], a + ldh [hSerialIgnoringInitialData], a jr .loop .load @@ -119,22 +118,21 @@ Serial_ExchangeBytes:: Serial_ExchangeByte:: .loop xor a - ldh [hFFCC], a - ldh a, [hLinkPlayerNumber] - cp 2 + ldh [hSerialReceivedNewData], a + ldh a, [hSerialConnectionStatus] + cp USING_INTERNAL_CLOCK jr nz, .not_player_2 ld a, (0 << rSC_ON) | (1 << rSC_CLOCK) ldh [rSC], a ld a, (1 << rSC_ON) | (1 << rSC_CLOCK) ldh [rSC], a - .not_player_2 .loop2 - ldh a, [hFFCC] + ldh a, [hSerialReceivedNewData] and a jr nz, .reset_ffcc - ldh a, [hLinkPlayerNumber] - cp 1 + ldh a, [hSerialConnectionStatus] + cp USING_EXTERNAL_CLOCK jr nz, .not_player_1_or_wLinkTimeoutFrames_zero call CheckwLinkTimeoutFramesNonzero jr z, .not_player_1_or_wLinkTimeoutFrames_zero @@ -165,10 +163,10 @@ Serial_ExchangeByte:: dec a ld [wce5d + 1], a jr nz, .loop2 - ldh a, [hLinkPlayerNumber] - cp 1 + ldh a, [hSerialConnectionStatus] + cp USING_EXTERNAL_CLOCK jr z, .reset_ffcc - + ld a, 255 .delay_255_cycles dec a @@ -176,7 +174,7 @@ Serial_ExchangeByte:: .reset_ffcc xor a - ldh [hFFCC], a + ldh [hSerialReceivedNewData], a ldh a, [rIE] and (1 << SERIAL) | (1 << TIMER) | (1 << LCD_STAT) | (1 << VBLANK) sub 1 << SERIAL @@ -246,7 +244,7 @@ Serial_ExchangeLinkMenuSelection:: ld de, wOtherPlayerLinkMode ld c, 2 ld a, TRUE - ldh [hFFCE], a + ldh [hSerialIgnoringInitialData], a .asm_7f8 call DelayFrame ld a, [hl] @@ -254,10 +252,10 @@ Serial_ExchangeLinkMenuSelection:: call Serial_ExchangeByte ld b, a inc hl - ldh a, [hFFCE] + ldh a, [hSerialIgnoringInitialData] and a - ld a, 0 - ldh [hFFCE], a + ld a, FALSE + ldh [hSerialIgnoringInitialData], a jr nz, .asm_7f8 ld a, b ld [de], a @@ -343,7 +341,7 @@ LinkTransfer:: ld a, [wPlayerLinkAction] add b ldh [hSerialSend], a - ldh a, [hLinkPlayerNumber] + ldh a, [hSerialConnectionStatus] cp USING_INTERNAL_CLOCK jr nz, .player_1 ld a, (0 << rSC_ON) | (1 << rSC_CLOCK) @@ -373,7 +371,7 @@ LinkDataReceived:: ; Let the other system know that the data has been received. xor a ldh [hSerialSend], a - ldh a, [hLinkPlayerNumber] + ldh a, [hSerialConnectionStatus] cp USING_INTERNAL_CLOCK ret nz ld a, (0 << rSC_ON) | (1 << rSC_CLOCK) |