2002-12-06 00:32:20 +00:00
|
|
|
;
|
2000-05-28 13:40:48 +00:00
|
|
|
; common iocb setup routine for read, write
|
2002-12-06 00:32:20 +00:00
|
|
|
; expects __fastcall__ parameters (int fd, void *buf, int count)
|
2000-05-28 13:40:48 +00:00
|
|
|
;
|
2002-12-06 00:32:20 +00:00
|
|
|
.include "atari.inc"
|
|
|
|
.include "errno.inc"
|
|
|
|
.importzp tmp2,tmp3
|
|
|
|
.import incsp4,ldax0sp,ldaxysp
|
2000-05-28 13:40:48 +00:00
|
|
|
.import __errno,__oserror
|
|
|
|
.import fdtoiocb
|
2002-04-21 14:19:16 +00:00
|
|
|
|
2002-12-06 00:32:20 +00:00
|
|
|
.export __rwsetup
|
2000-05-28 13:40:48 +00:00
|
|
|
|
|
|
|
__rwsetup:
|
2002-04-21 14:19:16 +00:00
|
|
|
|
2002-12-06 00:32:20 +00:00
|
|
|
sta tmp2
|
|
|
|
stx tmp3 ; remember size
|
|
|
|
ldy #3
|
|
|
|
jsr ldaxysp ; get fd
|
2000-05-28 13:40:48 +00:00
|
|
|
jsr fdtoiocb ; convert to iocb
|
|
|
|
bmi iocberr
|
2002-12-06 00:32:20 +00:00
|
|
|
tax
|
2000-05-28 13:40:48 +00:00
|
|
|
cpx #$80 ; iocb must be 0...7
|
2002-03-24 23:44:16 +00:00
|
|
|
bcs iocberr
|
2002-12-06 00:32:20 +00:00
|
|
|
lda tmp2
|
|
|
|
sta ICBLL,x
|
|
|
|
lda tmp3 ; size hi
|
|
|
|
sta ICBLH,x
|
|
|
|
stx tmp3
|
|
|
|
jsr ldax0sp ; get buf addr
|
|
|
|
stx tmp2
|
|
|
|
ldx tmp3
|
|
|
|
sta ICBAL,x
|
|
|
|
lda tmp2
|
|
|
|
sta ICBAH,x
|
|
|
|
jsr incsp4 ; pop args
|
2002-03-24 23:44:16 +00:00
|
|
|
lda ICBLL,x
|
|
|
|
ora ICBLH,x ; return with Z if length was 0
|
2002-12-06 00:32:20 +00:00
|
|
|
rts
|
2000-05-28 13:40:48 +00:00
|
|
|
|
2002-12-06 00:32:20 +00:00
|
|
|
iocberr:jsr incsp4 ; pop args
|
2000-05-28 13:40:48 +00:00
|
|
|
ldx #$FF ; indicate error + clear ZF
|
|
|
|
rts
|
|
|
|
|
2002-04-21 14:19:16 +00:00
|
|
|
|
2000-05-28 13:40:48 +00:00
|
|
|
;
|
|
|
|
; this routine updates errno. do a JMP here right after calling
|
2002-12-06 00:32:20 +00:00
|
|
|
; CIOV. we expect status in Y.
|
2000-05-28 13:40:48 +00:00
|
|
|
;
|
2002-12-06 00:32:20 +00:00
|
|
|
.export __do_oserror,__seterrno,__inviocb
|
2000-05-28 13:40:48 +00:00
|
|
|
__do_oserror:
|
|
|
|
sty __oserror ; save os dependent error code
|
2002-04-21 14:19:16 +00:00
|
|
|
retminus:
|
2000-05-28 13:40:48 +00:00
|
|
|
lda #$FF
|
|
|
|
tax ; return -1
|
|
|
|
rts
|
|
|
|
|
|
|
|
__seterrno:
|
2002-12-06 00:32:20 +00:00
|
|
|
sta __errno
|
|
|
|
stx __errno+1
|
|
|
|
rts
|
2000-05-28 13:40:48 +00:00
|
|
|
|
|
|
|
;
|
|
|
|
; sets EINVAL error code and returns -1
|
|
|
|
;
|
|
|
|
|
|
|
|
__inviocb:
|
|
|
|
lda #<EINVAL
|
|
|
|
ldx #>EINVAL
|
|
|
|
jsr __seterrno
|
|
|
|
jmp retminus ; return -1
|