diff options
Diffstat (limited to 'home/serial.asm')
-rw-r--r-- | home/serial.asm | 53 |
1 files changed, 32 insertions, 21 deletions
diff --git a/home/serial.asm b/home/serial.asm index 7a515118..508148df 100644 --- a/home/serial.asm +++ b/home/serial.asm @@ -3,6 +3,9 @@ Serial:: push bc push de push hl + ld a, [wPrinterConnectionOpen] + bit 0, a + jp nz, PrinterSerial__ ld a, [hSerialConnectionStatus] inc a jr z, .connectionNotYetEstablished @@ -91,79 +94,79 @@ Serial_ExchangeByte:: ld [hSerialReceivedNewData], a ld a, [hSerialConnectionStatus] cp USING_INTERNAL_CLOCK - jr nz, .asm_21a7 + jr nz, .asm_2003 ld a, START_TRANSFER_INTERNAL_CLOCK ld [rSC], a -.asm_21a7 +.asm_2003 ld a, [hSerialReceivedNewData] and a - jr nz, .asm_21f1 + jr nz, .asm_204d ld a, [hSerialConnectionStatus] cp USING_EXTERNAL_CLOCK - jr nz, .asm_21cc + jr nz, .asm_2028 call IsUnknownCounterZero - jr z, .asm_21cc + jr z, .asm_2028 call WaitLoop_15Iterations push hl ld hl, wUnknownSerialCounter + 1 inc [hl] - jr nz, .asm_21c3 + jr nz, .asm_201f dec hl inc [hl] -.asm_21c3 +.asm_201f pop hl call IsUnknownCounterZero - jr nz, .asm_21a7 + jr nz, .asm_2003 jp SetUnknownCounterToFFFF -.asm_21cc +.asm_2028 ld a, [rIE] and (1 << SERIAL) | (1 << TIMER) | (1 << LCD_STAT) | (1 << VBLANK) cp (1 << SERIAL) - jr nz, .asm_21a7 + jr nz, .asm_2003 ld a, [wUnknownSerialCounter2] dec a ld [wUnknownSerialCounter2], a - jr nz, .asm_21a7 + jr nz, .asm_2003 ld a, [wUnknownSerialCounter2 + 1] dec a ld [wUnknownSerialCounter2 + 1], a - jr nz, .asm_21a7 + jr nz, .asm_2003 ld a, [hSerialConnectionStatus] cp USING_EXTERNAL_CLOCK - jr z, .asm_21f1 + jr z, .asm_204d ld a, 255 .waitLoop dec a jr nz, .waitLoop -.asm_21f1 +.asm_204d xor a ld [hSerialReceivedNewData], a ld a, [rIE] and (1 << SERIAL) | (1 << TIMER) | (1 << LCD_STAT) | (1 << VBLANK) sub (1 << SERIAL) - jr nz, .asm_2204 + jr nz, .asm_2060 ld [wUnknownSerialCounter2], a ld a, $50 ld [wUnknownSerialCounter2 + 1], a -.asm_2204 +.asm_2060 ld a, [hSerialReceiveData] cp SERIAL_NO_DATA_BYTE ret nz call IsUnknownCounterZero - jr z, .asm_221f + jr z, .asm_207b push hl ld hl, wUnknownSerialCounter + 1 ld a, [hl] dec a ld [hld], a inc a - jr nz, .asm_2219 + jr nz, .asm_2075 dec [hl] -.asm_2219 +.asm_2075 pop hl call IsUnknownCounterZero jr z, SetUnknownCounterToFFFF -.asm_221f +.asm_207b ld a, [rIE] and (1 << SERIAL) | (1 << TIMER) | (1 << LCD_STAT) | (1 << VBLANK) cp (1 << SERIAL) @@ -225,7 +228,7 @@ Serial_ExchangeLinkMenuSelection:: Serial_PrintWaitingTextAndSyncAndExchangeNybble:: call SaveScreenTilesToBuffer1 - callab PrintWaitingText + callab PrintWaitingText ; 1:4b89 call Serial_SyncAndExchangeNybble jp LoadScreenTilesFromBuffer1 @@ -310,3 +313,11 @@ Serial_TryEstablishingExternallyClockedConnection:: ld a, START_TRANSFER_EXTERNAL_CLOCK ld [rSC], a ret + +PrinterSerial__:: + call PrinterSerial + pop hl + pop de + pop bc + pop af + reti |