]> git.sur5r.net Git - cc65/blobdiff - libsrc/cbm610/cbm610-stdser.s
no TGI_ERR_NO_MEM or TGI_ERR_NO_IOCB anymore: replaced by TGI_ERR_NO_RES
[cc65] / libsrc / cbm610 / cbm610-stdser.s
index 74fd480c84b0a420031d16760b0435585121878e..563083267f79abfaa74c75f10a066b6b2dd7bf98 100644 (file)
@@ -125,10 +125,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
 
@@ -156,7 +162,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.
@@ -216,28 +230,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
-        jsr     write_cmd
-
-; Initalize buffers.
-
-        jsr     InitBuffers
-
-; Return OK
-
-        lda     #<SER_ERR_OK
-        tax                             ; A is zero
-               rts
-
 ;----------------------------------------------------------------------------
 ; GET: Will fetch a character from the receive buffer and store it into the
 ; variable pointer to by ptr1. If no data is available, SER_ERR_NO_DATA is
@@ -344,8 +336,9 @@ IOCTL:  lda     #<SER_ERR_INV_IOCTL     ; We don't support ioclts for now
 
 ;----------------------------------------------------------------------------
 ; 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     #$0F
@@ -353,16 +346,16 @@ IRQ:    lda     #$0F
         ldy     #ACIA::STATUS
         lda     (acia),y        ; Check ACIA status for receive interrupt
        and     #$08
-               beq     @L10            ; Jump if no ACIA interrupt
+               beq     @L9             ; Jump if no ACIA interrupt (carry still clear)
         ldy     #ACIA::DATA
         lda            (acia),y        ; Get byte from ACIA
-       ldx     RecvFreeCnt     ; Check if we have free space left
+       ldx     RecvFreeCnt     ; Check if we have free space left
                beq     @L1             ; Jump if no space in receive buffer
-       ldy     RecvTail        ; Load buffer pointer
-       sta     RecvBuf,y       ; Store received byte in buffer
-       inc     RecvTail        ; Increment buffer pointer
-       dec     RecvFreeCnt     ; Decrement free space counter
-       cpx     #33             ; Check for buffer space low
+       ldy     RecvTail        ; Load buffer pointer
+       sta     RecvBuf,y       ; Store received byte in buffer
+       inc     RecvTail        ; Increment buffer pointer
+       dec     RecvFreeCnt     ; Decrement free space counter
+       cpx     #33             ; Check for buffer space low
                bcs     @L9             ; Assert flow control if buffer space low
 
 ; Assert flow control if buffer space too low
@@ -370,7 +363,7 @@ IRQ:    lda     #$0F
 @L1:   lda     RtsOff
         ldy     #ACIA::CMD
         sta     (acia),y
-       sta     Stopped
+       sta     Stopped
         sec                     ; Interrupt handled
 
 ; Done, switch back to the execution segment
@@ -379,13 +372,6 @@ IRQ:    lda     #$0F
         sta     IndReg
         rts
 
-; No ACIA interrupt
-
-@L10:   clc                     ; Interrupt not handled
-        lda     ExecReg
-        sta     IndReg
-        rts
-
 ;----------------------------------------------------------------------------
 ; Try to send a byte. Internal routine. A = TryHard
 
@@ -431,21 +417,6 @@ IRQ:    lda     #$0F
 .endproc
 
 
-;----------------------------------------------------------------------------
-; Initialize buffers
-
-InitBuffers:
-        ldx    #0
-        stx     Stopped
-               stx     RecvHead
-       stx     RecvTail
-       stx     SendHead
-       stx     SendTail
-        dex                             ; X = 255
-               stx     RecvFreeCnt
-       stx     SendFreeCnt
-        rts
-
 ;----------------------------------------------------------------------------
 ; Write to the ACIA changing the indirect segment. Offset is in Y, value in A.