.export _lseek
.import incsp6,__oserror
.import __inviocb,ldax0sp,ldaxysp,fdtoiocb
- .import __seterrno
+ .import __dos_type
.import fd_table
.importzp sreg,ptr1,ptr2,ptr3,ptr4
.importzp tmp1,tmp2,tmp3
; seeking not supported, return -1 and ENOSYS errno value
no_supp:jsr incsp6
lda #<ENOSYS
- ldx #>ENOSYS
- jsr __seterrno
- ldx #0
- stx __oserror
- dex
- txa
+ jsr __directerrno ; returns with $FFFF in AX
sta sreg
sta sreg+1
rts
bpl l01
; error returned from CIO
-xxerr: sty __oserror
- bmi iocberr
+xxerr: tya
+ pha
+ jsr incsp6
+ pla
+ jsr __mappederrno ; returns with $FFFF in AX
+ sta sreg
+ sta sreg+1
+ rts
; check for offset 0, SEEK_CUR (get current position)
cont: ldy #3
; tmp3: iocb
; X: index into fd_table
;
+; On non-SpartaDOS, seeking is not supported.
; We check, whether CIO function 39 (get file size) returns OK.
-; If yes, NOTE and POINT work with real file offset. @@@ check out more DOS versions @@@
+; If yes, NOTE and POINT work with real file offset.
; If not, NOTE and POINT work with the standard ScNum/Offset values.
; We remember a successful check in fd_table.ft_flag, bit 3.
bne supp
; do the test
-unkn: txa
+ lda __dos_type
+ cmp #SPARTADOS
+ bne ns1
+ txa
pha
+ lda DOS+1 ; get SpartaDOS version
+ cmp #$40
+ bcs supp1 ; SD-X (ver 4.xx) supports seeking on all disks
ldx tmp3 ; iocb to use
lda #39 ; get file size
sta ICCOM,x
; seeking is supported on this DOS/Disk combination
- pla
+supp1: pla
tax
lda #8
ora fd_table+ft_flag,x
rts
notsupp:pla
- clc
+ns1: clc
rts