X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=libsrc%2Fplus4%2Fplus4-stdser.s;h=30569a31fdfc9a4b786c9bf8d103249573c28fca;hb=351e0828c6c26965cd18ea934cc4232d7c193413;hp=a5aace9f4aa1b57d5eebda572429cc779c05b1ea;hpb=ad6a85b2550a7ebf6021350e845c600b00fb47cd;p=cc65 diff --git a/libsrc/plus4/plus4-stdser.s b/libsrc/plus4/plus4-stdser.s index a5aace9f4..30569a31f 100644 --- a/libsrc/plus4/plus4-stdser.s +++ b/libsrc/plus4/plus4-stdser.s @@ -133,10 +133,16 @@ ParityTable: ; ; UNINSTALL routine. Is called before the driver is removed from memory. ; Must return an SER_ERR_xx code in a/x. - +; +; and: +; +; CLOSE: Close the port, disable interrupts and flush the buffer. Called +; without parameters. Must return an error code in a/x. +; INSTALL: UNINSTALL: +CLOSE: ; Deactivate DTR and disable 6551 interrupts @@ -164,7 +170,15 @@ OPEN: ; Initialize buffers - jsr InitBuffers + ldx #0 + stx Stopped + stx RecvHead + stx RecvTail + stx SendHead + stx SendTail + dex ; X = 255 + stx RecvFreeCnt + stx SendFreeCnt ; Set the value for the control register, which contains stop bits, word ; length and the baud rate. @@ -223,28 +237,6 @@ InvBaud: ldx #>SER_ERR_BAUD_UNAVAIL rts -;---------------------------------------------------------------------------- -; CLOSE: Close the port, disable interrupts and flush the buffer. Called -; without parameters. Must return an error code in a/x. -; - -CLOSE: - -; Stop interrupts, drop DTR - - lda #%00001010 - sta ACIA_CMD - -; Initalize buffers. - - jsr InitBuffers - -; Return OK - - lda #SER_ERR_INV_IOCTL -; rts ; Run into IRQ instead + rts ; Run into IRQ instead ;---------------------------------------------------------------------------- ; IRQ: Called from the builtin runtime IRQ handler as a subroutine. All -; registers are already save, no parameters are passed and no return code -; is expected. +; registers are already save, no parameters are passed, but the carry flag +; is clear on entry. The routine must return with carry set if the interrupt +; was handled, otherwise with carry clear. ; IRQ: lda ACIA_STATUS ; Check ACIA status for receive interrupt and #$08 - beq @L9 ; Jump if no ACIA interrupt + beq @L9 ; Jump if no ACIA interrupt (carry still clear) lda ACIA_DATA ; Get byte from ACIA ldx RecvFreeCnt ; Check if we have free space left beq @L1 ; Jump if no space in receive buffer @@ -362,14 +355,15 @@ IRQ: lda ACIA_STATUS ; Check ACIA status for receive interrupt dec RecvFreeCnt ; Decrement free space counter cpx #33 ; Check for buffer space low bcc @L1 ; Assert flow control if buffer space low -@L9: rts + rts ; Return with carry set (interrupt handled) ; Assert flow control if buffer space too low @L1: lda RtsOff sta ACIA_CMD sta Stopped - rts + sec ; Interrupt handled +@L9: rts ;---------------------------------------------------------------------------- ; Try to send a byte. Internal routine. A = TryHard @@ -407,18 +401,3 @@ IRQ: lda ACIA_STATUS ; Check ACIA status for receive interrupt .endproc -;---------------------------------------------------------------------------- -; Initialize buffers - -InitBuffers: - ldx #0 - stx Stopped - stx RecvHead - stx RecvTail - stx SendHead - stx SendTail - dex ; X = 255 - stx RecvFreeCnt - stx SendFreeCnt - rts -