]> git.sur5r.net Git - cc65/blobdiff - libsrc/apple2/dioopen.s
Added library reference ser_libref to SER interface.
[cc65] / libsrc / apple2 / dioopen.s
index b6946c385bd366eacd1b73193c78213e137a09ed..62b2f06a38de7b958628b1a7ce6fd13f950eeb29 100644 (file)
@@ -1,35 +1,38 @@
 ;
 ; Oliver Schmidt, 24.03.2005
 ;
-; dhandle_t __fastcall__ dio_open (driveid_t drive_id);
+; dhandle_t __fastcall__ dio_open (unsigned char device);
 ;
 
-        .export        _dio_open
-        .import        return0, __dos_type
+        .export         _dio_open
+        .import         return0, __dos_type, isdevice
 
-        .include       "errno.inc"
-        .include       "mli.inc"
+        .include        "errno.inc"
+        .include        "mli.inc"
 
 _dio_open:
         ; Check for ProDOS 8
-        ldx    __dos_type
-        bne    :+
-        lda    #$01            ; "Bad system call number"
-        bne    oserr           ; Branch always
+        ldx     __dos_type
+        bne     :+
+        lda     #$01            ; "Bad system call number"
+        bne     oserr           ; Branch always
+
+        ; Check for valid device
+:       tax
+        jsr     isdevice
+        beq     :+
+        lda     #$28            ; "No device connected"
 
-        ; Walk device list
-:       ldx    DEVCNT
-:       cmp    DEVLST,x
-        beq    :+              ; Found drive_id in device list
-        dex
-        bpl    :-
-        lda    #$28            ; "No device detected/connected"
-        
         ; Return oserror
-oserr:  sta    __oserror
-        jmp    return0
+oserr:  sta     __oserror
+        jmp     return0
 
         ; Return success
-:       ldx    #$00
-        stx    __oserror
+:       txa
+        asl
+        asl
+        asl
+        asl
+        ldx     #$00
+        stx     __oserror
         rts