]> git.sur5r.net Git - cc65/blobdiff - libsrc/atari/rs232.s
no TGI_ERR_NO_MEM or TGI_ERR_NO_IOCB anymore: replaced by TGI_ERR_NO_RES
[cc65] / libsrc / atari / rs232.s
index d312caab0c365e3447358da8ba1fd5c16f170eb1..843827fb6f54dc856df9164d84ee17d8a20e0bb8 100644 (file)
@@ -15,7 +15,7 @@
 ;
 
        .import         findfreeiocb
-       .import         __seterrno, __do_oserror, __oserror
+       .import         __do_oserror
        .import         fddecusage
        .import         fdtoiocb
        .import         __inviocb
@@ -28,7 +28,8 @@
        .export         _rs232_put, _rs232_pause, _rs232_unpause, _rs232_status
 
        .include        "atari.inc"
-       .include        "../common/errno.inc"
+       .include        "errno.inc"
+        .include        "rs232.inc"
 
        .rodata
 
@@ -59,16 +60,8 @@ rshand:      .word   $ffff
 .proc  _rs232_init
 
        jsr     findfreeiocb
-       beq     iocbok          ; we found one
-
-       lda     #<EMFILE        ; "too many open files"
-       ldx     #>EMFILE
-seterr:        jsr     __seterrno
-       lda     #$FF
-       tax
-       rts                     ; return -1
-
-iocbok:        txa
+       bne     init_err
+       txa
        tay                     ; move iocb # into Y
        lda     #3
        sta     tmp3            ; name length + 1
@@ -101,18 +94,21 @@ doopen:    tax
        sta     ICBLL,x         ; zap buf len
        sta     ICBLH,x
        jsr     CIOV
-       bmi     cioerr
+       bmi     cioerr1
 
        lda     tmp2            ; get fd
        sta     rshand
        ldx     #0
        stx     rshand+1
        txa
-       stx     __oserror
        rts
 
-cioerr:        jsr     fddecusage      ; decrement usage counter of fd as open failed
-       jmp     __do_oserror
+cioerr1:jsr    fddecusage      ; decrement usage counter of fd as open failed
+
+init_err:
+       ldx     #0
+       lda     #RS_ERR_INIT_FAILED
+       rts
 
 .endproc       ; _rs232_init
 
@@ -130,17 +126,13 @@ cioerr:   jsr     fddecusage      ; decrement usage counter of fd as open failed
 ; using 8 bit word size. So only 8 bit is currently tested.
 ;
 
-; shouldn't this come from a "rs232.inc" ??
-ErrNotInitialized      = $01
-ErrNoData              = $04
-
 .proc  _rs232_params
 
        sta     tmp2
        lda     rshand
        cmp     #$ff
        bne     work            ; work only if initialized
-       lda     #ErrNotInitialized
+       lda     #RS_ERR_NOT_INITIALIZED
        bne     done
 work:  lda     rshand
        ldx     #0
@@ -241,7 +233,7 @@ done:       rts
        ldy     rshand
        cpy     #$ff
        bne     work            ; work only if initialized
-       lda     #ErrNotInitialized
+       lda     #RS_ERR_NOT_INITIALIZED
        bne     nierr
 
 work:  sta     ptr1
@@ -267,7 +259,7 @@ go: ; check whether there is any input available
        beq     nix_da          ; no input waiting...
 
        ; input is available: get it!
-       
+
        lda     #GETCHR         ; get raw bytes
        sta     ICCOM,x         ; in command code
        lda     #0
@@ -282,11 +274,11 @@ go:       ; check whether there is any input available
        sta     (ptr1,x)        ; return received byte
        txa
        rts
-       
+
 nierr: ldx     #0
        rts
 
-nix_da:        lda     #ErrNoData
+nix_da:        lda     #RS_ERR_NO_DATA
        ldx     #0
        rts
 
@@ -307,7 +299,7 @@ nix_da:     lda     #ErrNoData
        ldy     rshand
        cpy     #$ff
        bne     work            ; work only if initialized
-       lda     #ErrNotInitialized
+       lda     #RS_ERR_NOT_INITIALIZED
        bne     nierr
 
 work:  pha