- Use ProDOS 8 unit number as parameter.

- Don't access the drive, just check its presence.

git-svn-id: svn://svn.cc65.org/cc65/trunk@4723 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
ol.sc
2010-06-16 21:19:47 +00:00
parent ab068d43e3
commit a0359724ff

View File

@@ -3,55 +3,33 @@
; ;
; dhandle_t __fastcall__ dio_open (driveid_t drive_id); ; dhandle_t __fastcall__ dio_open (driveid_t drive_id);
; ;
; drive_id = (slot * 2) + (drive - 1)
.export _dio_open .export _dio_open
.import return0 .import return0, __dos_type
.include "zeropage.inc"
.include "errno.inc" .include "errno.inc"
.include "mli.inc" .include "mli.inc"
_dio_open: _dio_open:
; Convert drive id into unit number ; Check for ProDOS 8
lsr ldx __dos_type
bcc :+ bne :+
ora #%00001000 lda #$01 ; "Bad system call number"
: asl bne oserr ; Branch always
asl
asl
asl
tay ; Save handle
; Set handle ; Walk device list
sta mliparam + MLI::ON_LINE::UNIT_NUM : ldx DEVCNT
: cmp DEVLST,x
; Alloc 16-byte buffer just below stack beq :+ ; Found drive_id in device list
lda sp dex
sec bpl :-
sbc #16 lda #$28 ; "No device connected"
sta mliparam + MLI::ON_LINE::DATA_BUFFER
lda sp+1 ; Return oserror
sbc #$00 oserr: sta __oserror
sta mliparam + MLI::ON_LINE::DATA_BUFFER+1 jmp return0
; Get device state
lda #ON_LINE_CALL
ldx #ON_LINE_COUNT
jsr callmli
bcc :+
; DIO level access doesn't necessarily need a
; ProDOS 8 disk so ignore "high level" errors
cmp #$40
bcc oserr
; Return success ; Return success
: tya ; Restore handle : ldx #$00
ldx #$00
stx __oserror stx __oserror
rts rts
; Return oserror
oserr: sta __oserror
jmp return0