]> git.sur5r.net Git - cc65/commitdiff
Introduced mass-storage device enumaration - with implementation for C64 and C128.
authorol.sc <ol.sc@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Sun, 9 Sep 2012 12:14:45 +0000 (12:14 +0000)
committerol.sc <ol.sc@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Sun, 9 Sep 2012 12:14:45 +0000 (12:14 +0000)
git-svn-id: svn://svn.cc65.org/cc65/trunk@5820 b7a2c559-68d2-44c3-8de9-860c34a00d81

include/device.h [new file with mode: 0644]
libsrc/c128/Makefile
libsrc/c128/getdevice.s [new file with mode: 0644]
libsrc/c64/Makefile
libsrc/c64/getdevice.s [new file with mode: 0644]

diff --git a/include/device.h b/include/device.h
new file mode 100644 (file)
index 0000000..37323e6
--- /dev/null
@@ -0,0 +1,61 @@
+/*****************************************************************************/
+/*                                                                           */
+/*                                 device.h                                  */
+/*                                                                           */
+/*                              Device handling                              */
+/*                                                                           */
+/*                                                                           */
+/*                                                                           */
+/* (C) 2012  Oliver Schmidt, <ol.sc@web.de>                                  */
+/*                                                                           */
+/*                                                                           */
+/* This software is provided 'as-is', without any expressed or implied       */
+/* warranty.  In no event will the authors be held liable for any damages    */
+/* arising from the use of this software.                                    */
+/*                                                                           */
+/* Permission is granted to anyone to use this software for any purpose,     */
+/* including commercial applications, and to alter it and redistribute it    */
+/* freely, subject to the following restrictions:                            */
+/*                                                                           */
+/* 1. The origin of this software must not be misrepresented; you must not   */
+/*    claim that you wrote the original software. If you use this software   */
+/*    in a product, an acknowledgment in the product documentation would be  */
+/*    appreciated but is not required.                                       */
+/* 2. Altered source versions must be plainly marked as such, and must not   */
+/*    be misrepresented as being the original software.                      */
+/* 3. This notice may not be removed or altered from any source              */
+/*    distribution.                                                          */
+/*                                                                           */
+/*****************************************************************************/
+
+
+
+#ifndef _DEVICE_H
+#define _DEVICE_H
+
+
+
+/*****************************************************************************/
+/*                                  Data                                    */
+/*****************************************************************************/
+
+
+
+#define INVALID_DEVICE  255
+
+
+
+/*****************************************************************************/
+/*                                  Code                                    */
+/*****************************************************************************/
+
+
+
+unsigned char getfirstdevice (void);
+
+unsigned char __fastcall__ getnextdevice (unsigned char device);
+
+
+
+/* End of device.h */
+#endif
index f462ddf9905e95f87b5816c86f9814fd205d2551..a6dc0f2b1532bdeb54b7b7242879089361fdde7e 100644 (file)
@@ -56,6 +56,7 @@ OBJS =        _scrsize.o              \
                devnum.o                \
        fast.o                  \
         get_tv.o               \
+        getdevice.o            \
        joy_stddrv.o            \
        kbhit.o                 \
         kernal.o               \
diff --git a/libsrc/c128/getdevice.s b/libsrc/c128/getdevice.s
new file mode 100644 (file)
index 0000000..9ec2abe
--- /dev/null
@@ -0,0 +1,67 @@
+;
+; Oliver Schmidt, 2012-09-04
+;
+; unsigned char getfirstdevice (void);
+; unsigned char __fastcall__ getnextdevice (unsigned char device);
+;
+
+        .export         _getfirstdevice
+        .export         _getnextdevice
+
+        .import         isdisk
+        .import         opencmdchannel
+        .import         closecmdchannel
+        .importzp       tmp2
+
+        .include        "c128.inc"
+
+;------------------------------------------------------------------------------
+; _getfirstdevice
+
+_getfirstdevice:
+        lda     #$FF
+        ; Fall through
+
+;------------------------------------------------------------------------------
+; _getnextdevice
+
+_getnextdevice:
+        tax
+next:  inx
+        cpx     #$FF
+        beq     done
+
+; [open|close]cmdchannel already call isdisk internally but they
+; interpret a non-disk as a no-op while we need to interpret it
+; as an error here
+
+        jsr     isdisk
+        bcs     next
+
+; [open|close]cmdchannel don't call into the Kernal at all if they
+; only [in|de]crement the reference count of the shared cmdchannel
+; so we need to explicitly initialize ST here
+
+        lda     #$00
+        sta     ST
+
+        stx     tmp2
+        jsr     opencmdchannel
+        ldx     tmp2
+        jsr     closecmdchannel
+        ldx     tmp2
+
+; As we had to reference ST above anyway we can as well do so
+; here too (instead of calling READST)
+
+        lda     ST
+
+; Either the Kernal calls above were successfull or there was
+; already a cmdchannel to the device open - which is a pretty
+; good indication of its existence ;-)
+
+        bmi     next
+
+done:   txa
+        ldx     #$00
+        rts
index 4fb2af9166ba8177d39a4b64581a98d71153efdc..2c952b7c0a5e986998ed5247d7b7ce8bf06f31a4 100644 (file)
@@ -55,6 +55,7 @@ OBJS =        _scrsize.o              \
                devnum.o                \
         get_ostype.o            \
         get_tv.o                \
+        getdevice.o             \
        joy_stddrv.o            \
                kbhit.o                 \
         kernal.o                \
diff --git a/libsrc/c64/getdevice.s b/libsrc/c64/getdevice.s
new file mode 100644 (file)
index 0000000..90bf6ba
--- /dev/null
@@ -0,0 +1,67 @@
+;
+; Oliver Schmidt, 2012-09-04
+;
+; unsigned char getfirstdevice (void);
+; unsigned char __fastcall__ getnextdevice (unsigned char device);
+;
+
+        .export         _getfirstdevice
+        .export         _getnextdevice
+
+        .import         isdisk
+        .import         opencmdchannel
+        .import         closecmdchannel
+        .importzp       tmp2
+
+        .include        "c64.inc"
+
+;------------------------------------------------------------------------------
+; _getfirstdevice
+
+_getfirstdevice:
+        lda     #$FF
+        ; Fall through
+
+;------------------------------------------------------------------------------
+; _getnextdevice
+
+_getnextdevice:
+        tax
+next:  inx
+        cpx     #$FF
+        beq     done
+
+; [open|close]cmdchannel already call isdisk internally but they
+; interpret a non-disk as a no-op while we need to interpret it
+; as an error here
+
+        jsr     isdisk
+        bcs     next
+
+; [open|close]cmdchannel don't call into the Kernal at all if they
+; only [in|de]crement the reference count of the shared cmdchannel
+; so we need to explicitly initialize ST here
+
+        lda     #$00
+        sta     ST
+
+        stx     tmp2
+        jsr     opencmdchannel
+        ldx     tmp2
+        jsr     closecmdchannel
+        ldx     tmp2
+
+; As we had to reference ST above anyway we can as well do so
+; here too (instead of calling READST)
+
+        lda     ST
+
+; Either the Kernal calls above were successfull or there was
+; already a cmdchannel to the device open - which is a pretty
+; good indication of its existence ;-)
+
+        bmi     next
+
+done:   txa
+        ldx     #$00
+        rts