]> git.sur5r.net Git - cc65/commitdiff
I wasn't aware that the unit numbers in the ProDOS device list contain device type...
authorol.sc <ol.sc@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Mon, 15 Oct 2012 21:59:51 +0000 (21:59 +0000)
committerol.sc <ol.sc@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Mon, 15 Oct 2012 21:59:51 +0000 (21:59 +0000)
git-svn-id: svn://svn.cc65.org/cc65/trunk@5852 b7a2c559-68d2-44c3-8de9-860c34a00d81

doc/apple2.sgml
doc/apple2enh.sgml
libsrc/apple2/Makefile
libsrc/apple2/devicedir.s
libsrc/apple2/dioopen.s
libsrc/apple2/getdevice.s
libsrc/apple2/isdevice.s [new file with mode: 0644]
libsrc/apple2enh/Makefile

index 28f550b0ef3200c3a5fb195a6ee067561a32e4d9..02c8450a2cf0ab3b0b472844dc91d896754c6143 100644 (file)
@@ -494,10 +494,10 @@ url="ca65.html" name="assembler manual">.
   to the formula
 
   <tscreen>
-    device = slot * 0x10 + (drive - 1) * 0x80
+    device = slot + (drive - 1) * 8
   </tscreen>
 
-  so that for example slot 6 drive 2 is mapped to <tt/device/ 0xE0.
+  so that for example slot 6 drive 2 is mapped to <tt/device/ 14.
 
   <tag/Sector count/
   The function <htmlurl url="dio-3.html" name="dio_query_sectcount()"> returns
index 1567f4c0b5d332007f3d4ec68606aa19c8e04697..f3ae6e4e15bb9df41da4be9327b6f9bca6403b1d 100644 (file)
@@ -500,10 +500,10 @@ url="ca65.html" name="assembler manual">.
   to the formula
 
   <tscreen>
-    device = slot * 0x10 + (drive - 1) * 0x80
+    device = slot + (drive - 1) * 8
   </tscreen>
 
-  so that for example slot 6 drive 2 is mapped to <tt/device/ 0xE0.
+  so that for example slot 6 drive 2 is mapped to <tt/device/ 14.
 
   <tag/Sector count/
   The function <htmlurl url="dio-3.html" name="dio_query_sectcount()"> returns
index 3896f290365840e4ee0beeac21b597d56ad0a75e..ad4573ac3133ee9ba7d4823466221b629e119270 100644 (file)
@@ -19,7 +19,7 @@ CFLAGS        = -Osir -g -T -t $(SYS) --forget-inc-paths -I . -I ../../include
 #--------------------------------------------------------------------------
 # Rules
 
-%.o:           %.c
+%.o:   %.c
        @$(CC) $(CFLAGS) $<
        @$(AS) -o $@ $(AFLAGS) $(*).s
 
@@ -50,19 +50,19 @@ C_OBJS=     closedir.o      \
        rewinddir.o
 
 S_OBJS=        _scrsize.o      \
-       break.o         \
-       cclear.o        \
-       cgetc.o         \
-       chline.o        \
+       break.o         \
+       cclear.o        \
+       cgetc.o         \
+       chline.o        \
        close.o         \
-       clrscr.o        \
-       color.o         \
-        cout.o          \
-       cputc.o         \
-       crt0.o          \
-       ctype.o         \
-       cvline.o        \
-       devicedir.o     \
+       clrscr.o        \
+       color.o         \
+       cout.o          \
+       cputc.o         \
+       crt0.o          \
+       ctype.o         \
+       cvline.o        \
+       devicedir.o     \
        dioclose.o      \
        diocommon.o     \
        dioopen.o       \
@@ -75,41 +75,42 @@ S_OBJS=     _scrsize.o      \
        exehdr.o        \
        filedes.o       \
        filename.o      \
-        get_ostype.o    \
+       get_ostype.o    \
        getdevice.o     \
        gotoxy.o        \
        gotoy.o         \
-        home.o          \
+       home.o          \
        initcwd.o       \
-       iobuf.o         \
-        joy_stddrv.o    \
-       kbhit.o         \
-        mainargs.o      \
+       iobuf.o         \
+       isdevice.o      \
+       joy_stddrv.o    \
+       kbhit.o         \
+       mainargs.o      \
        mcbdefault.o    \
        mli.o           \
-        mouse_stddrv.o  \
+       mouse_stddrv.o  \
        open.o          \
-        oserrlist.o     \
+       oserrlist.o     \
        oserror.o       \
-        randomize.o     \
-        rdkey.o         \
-       read.o          \
-       reboot.o        \
-       revers.o        \
+       randomize.o     \
+       rdkey.o         \
+       read.o          \
+       reboot.o        \
+       revers.o        \
        rwcommon.o      \
        syschdir.o      \
        sysmkdir.o      \
        sysremove.o     \
        sysrename.o     \
        sysrmdir.o      \
-        systime.o       \
-        sysuname.o      \
-        tgi_colors.o    \
-        tgi_stddrv.o    \
-        toascii.o       \
-        vtabz.o         \
-       wherex.o        \
-               wherey.o        \
+       systime.o       \
+       sysuname.o      \
+       tgi_colors.o    \
+       tgi_stddrv.o    \
+       toascii.o       \
+       vtabz.o         \
+       wherex.o        \
+       wherey.o        \
        write.o
 
 S_EXTRA_OBJS=          \
@@ -141,5 +142,5 @@ all:        $(C_OBJS) $(S_OBJS) $(S_EXTRA_OBJS) $(EMDS) $(JOYS) $(MOUS) $(SERS) $(TGIS
 clean:
        @$(RM) $(C_OBJS:.o=.s) $(C_OBJS) $(S_OBJS) $(S_EXTRA_OBJS) $(EMDS:.emd=.o) $(JOYS:.joy=.o) $(MOUS:.mou=.o) $(SERS:.ser=.o) $(TGIS:.tgi=.o)
 
-zap:           clean
+zap:   clean
        @$(RM) $(EMDS) $(JOYS) $(MOUS) $(SERS) $(TGIS)
index 3572eeeeb499642c666b851c1dfcfa871d7669d9..b2a6382f8076eac8e9e2602a9ff26d4360ffe9af 100644 (file)
@@ -27,13 +27,13 @@ _getdevicedir:
 
         ; Set device
         jsr    popa
+        asl
+        asl
+        asl
+        asl
         sta    mliparam + MLI::ON_LINE::UNIT_NUM
 
         ; Check for valid slot
-        tax
-        and    #$0F
-        bne    erange
-        txa
         and    #$70
         beq    erange
 
index 8d51530fa74d91e5df2dc73beac1683d014ac11a..4c07f0eb2e32254b46d8c6c0f24a90623338716f 100644 (file)
@@ -5,7 +5,7 @@
 ;
 
         .export        _dio_open
-        .import        return0, __dos_type
+        .import        return0, __dos_type, isdevice
 
         .include       "errno.inc"
         .include       "mli.inc"
@@ -17,19 +17,22 @@ _dio_open:
         lda    #$01            ; "Bad system call number"
         bne    oserr           ; Branch always
 
-        ; Walk device list
-:       ldx    DEVCNT
-:       cmp    DEVLST,x
-        beq    :+              ; Found drive_id in device list
-        dex
-        bpl    :-
+        ; Check for valid device
+:       tax
+        jsr    isdevice
+        beq    :+
         lda    #$28            ; "No device connected"
-        
+
         ; Return oserror
 oserr:  sta    __oserror
         jmp    return0
 
         ; Return success
-:       ldx    #$00
+:       txa
+        asl
+        asl
+        asl
+        asl
+        ldx    #$00
         stx    __oserror
         rts
index d07420902172701bc34a916bfe34f857c82b2bb2..ef35edea77273f2baeb786583a6cdec787044c23 100644 (file)
@@ -7,42 +7,28 @@
 
         .export         _getfirstdevice
         .export         _getnextdevice
-
-        .import         __dos_type
+        .import         __dos_type, isdevice
 
         .include        "zeropage.inc"
-        .include        "mli.inc"
 
 _getfirstdevice:
         lda     #$FF
         ; Fall through
 
 _getnextdevice:
-next:   tax
-        inx
-        txa
-        cmp     #$FF
+        tax
+next:   inx
+        cpx     #$FF
         beq     done
 
         ; Check for ProDOS 8
-        ldx     __dos_type
+        lda     __dos_type
         beq     next
 
-        ; Up to 14 units may be active
-        ldx     #<DEVLST
-        ldy     #>DEVLST
-        stx     ptr1
-        sty     ptr1+1
-
-        ; Number of on-line devices (minus 1)
-        ldy     DEVCNT
-
-        ; Does the list contain the device?
-:       cmp     (ptr1),y
-        beq     done
-        dey
-        bpl     :-
-        bmi     next            ; Branch always
+        ; Check for valid device
+        jsr     isdevice
+        bne     next
 
-done:   ldx     #$00
+done:   txa
+        ldx     #$00
         rts
diff --git a/libsrc/apple2/isdevice.s b/libsrc/apple2/isdevice.s
new file mode 100644 (file)
index 0000000..fad1688
--- /dev/null
@@ -0,0 +1,22 @@
+;
+; Oliver Schmidt, 2012-10-15
+;
+
+        .export         isdevice
+
+        .include        "zeropage.inc"
+        .include        "mli.inc"
+
+isdevice:
+        ldy     DEVCNT
+:       lda     DEVLST,y
+        lsr
+        lsr
+        lsr
+        lsr
+        sta     tmp1
+        cpx     tmp1
+        beq     :+
+        dey
+        bpl     :-
+:       rts
index 44165604be944e71df2a12df73cc2c754fbb0fd2..0c564d465a210ce65de21883433cb39cc175d272 100644 (file)
@@ -19,7 +19,7 @@ CFLAGS        = -Osir -g -T -t $(SYS) --forget-inc-paths -I ../apple2 -I ../../include
 #--------------------------------------------------------------------------
 # Rules
 
-%.o:           ../apple2/%.c
+%.o:   ../apple2/%.c
        @$(CC) -o $(notdir $(*).s) $(CFLAGS) $<
        @$(AS) -o $@ $(AFLAGS) $(*).s
 
@@ -53,19 +53,19 @@ C_OBJS=     closedir.o      \
        rewinddir.o
 
 S_OBJS=        _scrsize.o      \
-       break.o         \
-       cclear.o        \
-       cgetc.o         \
-       chline.o        \
+       break.o         \
+       cclear.o        \
+       cgetc.o         \
+       chline.o        \
        close.o         \
-       clrscr.o        \
-       color.o         \
-        cout.o          \
-       cputc.o         \
-       crt0.o          \
-       ctype.o         \
-       cvline.o        \
-       devicedir.o     \
+       clrscr.o        \
+       color.o         \
+       cout.o          \
+       cputc.o         \
+       crt0.o          \
+       ctype.o         \
+       cvline.o        \
+       devicedir.o     \
        dioclose.o      \
        diocommon.o     \
        dioopen.o       \
@@ -78,43 +78,44 @@ S_OBJS=     _scrsize.o      \
        exehdr.o        \
        filedes.o       \
        filename.o      \
-        get_ostype.o    \
+       get_ostype.o    \
        getdevice.o     \
        gotoxy.o        \
        gotoy.o         \
-        home.o          \
+       home.o          \
        initcwd.o       \
-       iobuf.o         \
-        joy_stddrv.o    \
-       kbhit.o         \
-        mainargs.o      \
+       iobuf.o         \
+       isdevice.o      \
+       joy_stddrv.o    \
+       kbhit.o         \
+       mainargs.o      \
        mcbdefault.o    \
        mli.o           \
-        mouse_stddrv.o  \
+       mouse_stddrv.o  \
        open.o          \
-        oserrlist.o     \
+       oserrlist.o     \
        oserror.o       \
-        randomize.o     \
-        rdkey.o         \
-       read.o          \
-       reboot.o        \
-       revers.o        \
+       randomize.o     \
+       rdkey.o         \
+       read.o          \
+       reboot.o        \
+       revers.o        \
        rwcommon.o      \
        syschdir.o      \
        sysmkdir.o      \
        sysremove.o     \
        sysrename.o     \
        sysrmdir.o      \
-        systime.o       \
-        sysuname.o      \
+       systime.o       \
+       sysuname.o      \
        textframe.o     \
-        tgi_colors.o    \
-        tgi_stddrv.o    \
-        toascii.o       \
-        videomode.o     \
-        vtabz.o         \
-       wherex.o        \
-               wherey.o        \
+       tgi_colors.o    \
+       tgi_stddrv.o    \
+       toascii.o       \
+       videomode.o     \
+       vtabz.o         \
+       wherex.o        \
+       wherey.o        \
        write.o
 
 S_EXTRA_OBJS=          \
@@ -146,5 +147,5 @@ all:        $(C_OBJS) $(S_OBJS) $(S_EXTRA_OBJS) $(EMDS) $(JOYS) $(MOUS) $(SERS) $(TGIS
 clean:
        @$(RM) $(C_OBJS:.o=.s) $(C_OBJS) $(S_OBJS) $(S_EXTRA_OBJS) $(EMDS:.emd=.o) $(JOYS:.joy=.o) $(MOUS:.mou=.o) $(SERS:.ser=.o) $(TGIS:.tgi=.o)
 
-zap:           clean
+zap:   clean
        @$(RM) $(EMDS) $(JOYS) $(MOUS) $(SERS) $(TGIS)