]> git.sur5r.net Git - cc65/commitdiff
Move definitions for CBM file types into its own header file, since these
authoruz <uz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Sun, 24 Jun 2012 13:52:06 +0000 (13:52 +0000)
committeruz <uz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Sun, 24 Jun 2012 13:52:06 +0000 (13:52 +0000)
definitions are needed for file type macros in dirent.h. Unify names for the
include files.

git-svn-id: svn://svn.cc65.org/cc65/trunk@5735 b7a2c559-68d2-44c3-8de9-860c34a00d81

asminc/cbm_filetype.inc [new file with mode: 0644]
asminc/cbm_ftype.inc [deleted file]
include/cbm.h
include/cbm_filetype.h [new file with mode: 0644]
libsrc/cbm/Makefile
libsrc/cbm/cbm_filetype.s [new file with mode: 0644]
libsrc/cbm/cbm_ftype.s [deleted file]

diff --git a/asminc/cbm_filetype.inc b/asminc/cbm_filetype.inc
new file mode 100644 (file)
index 0000000..c1f1afc
--- /dev/null
@@ -0,0 +1,33 @@
+;
+; Definitions for CBM file types. From cbm.h
+;
+; Ullrich von Bassewitz, 2012-06-03
+;
+
+; Define bitmapped constants for the table entries
+
+.enum
+        CBM_T_DEL               ; Deleted file
+        CBM_T_SEQ               ; Sequential file
+        CBM_T_PRG               ; Program file
+        CBM_T_USR               ; User file
+        CBM_T_REL               ; Relative file
+        CBM_T_CBM               ; 1581 sub-partition
+        CBM_T_DIR               ; IDE64 and CMD sub-directory
+        CBM_T_LNK               ; IDE64 soft-link
+        CBM_T_VRP               ; Vorpal fast-loadable format
+        CBM_T_OTHER             ; File-type not recognized
+        CBM_T_HEADER            ; Disk header / title 
+.endenum
+
+
+; The following function maps the start character for a file type to 
+; one of the file types above. Note: 'd' will always mapped to CBM_T_DEL.
+; The calling function has to look at the following character to determine
+; if the file type is actually CBM_T_DIR.
+;
+; unsigned char __fastcall__ _cbm_filetype (unsigned char c);
+
+        .global __cbm_filetype
+
+
diff --git a/asminc/cbm_ftype.inc b/asminc/cbm_ftype.inc
deleted file mode 100644 (file)
index c1f1afc..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-;
-; Definitions for CBM file types. From cbm.h
-;
-; Ullrich von Bassewitz, 2012-06-03
-;
-
-; Define bitmapped constants for the table entries
-
-.enum
-        CBM_T_DEL               ; Deleted file
-        CBM_T_SEQ               ; Sequential file
-        CBM_T_PRG               ; Program file
-        CBM_T_USR               ; User file
-        CBM_T_REL               ; Relative file
-        CBM_T_CBM               ; 1581 sub-partition
-        CBM_T_DIR               ; IDE64 and CMD sub-directory
-        CBM_T_LNK               ; IDE64 soft-link
-        CBM_T_VRP               ; Vorpal fast-loadable format
-        CBM_T_OTHER             ; File-type not recognized
-        CBM_T_HEADER            ; Disk header / title 
-.endenum
-
-
-; The following function maps the start character for a file type to 
-; one of the file types above. Note: 'd' will always mapped to CBM_T_DEL.
-; The calling function has to look at the following character to determine
-; if the file type is actually CBM_T_DIR.
-;
-; unsigned char __fastcall__ _cbm_filetype (unsigned char c);
-
-        .global __cbm_filetype
-
-
index 471349b71e7e85f4fff316980b505fbd6805b548..9ce3cbfbfce2127b5483c6a1ec9dcbfb8e86d6c7 100644 (file)
@@ -70,6 +70,9 @@
 #  include <pet.h>
 #endif
 
+/* Include definitions for CBM file types */
+#include <cbm_filetype.h>
+
 
 
 /*****************************************************************************/
@@ -124,19 +127,6 @@ extern char _filetype;          /* Defaults to 'u' */
 
 
 
-/* CBM FILE TYPES */
-#define CBM_T_DEL    0
-#define CBM_T_SEQ    1
-#define CBM_T_PRG    2
-#define CBM_T_USR    3
-#define CBM_T_REL    4
-#define CBM_T_CBM    5          /* 1581 sub-partition */
-#define CBM_T_DIR    6          /* IDE64 and CMD sub-directory */
-#define CBM_T_LNK    7          /* IDE64 soft-link */
-#define CBM_T_VRP    8          /* Vorpal fast-loadable format */
-#define CBM_T_OTHER  9          /* File-type not recognized */
-#define CBM_T_HEADER 10         /* Disk header / title */
-
 /* CBM FILE ACCESS */
 #define CBM_A_RO    1           /* Read only   */
 #define CBM_A_WO    2           /* Write only  */
@@ -149,14 +139,6 @@ struct cbm_dirent {
     unsigned char access;
 };
 
-unsigned char __fastcall__ _cbm_filetype (unsigned char c);
-/* Map the start character for a file type to one of the file types above.
- * Note: 'd' will always mapped to CBM_T_DEL. The calling function has to
- * look at the following character to determine if the file type is actually
- * CBM_T_DIR.
- * This is a function used by the implementation. There is usually no need
- * to call it from user code.
- */
 
 
 /*****************************************************************************/
diff --git a/include/cbm_filetype.h b/include/cbm_filetype.h
new file mode 100644 (file)
index 0000000..9192ee3
--- /dev/null
@@ -0,0 +1,106 @@
+/*****************************************************************************/
+/*                                                                           */
+/*                              cbm_filetype.h                               */
+/*                                                                           */
+/*                      Definitions for CBM file types                       */
+/*                                                                           */
+/*                                                                           */
+/*                                                                           */
+/* (C) 2012,      Ullrich von Bassewitz                                      */
+/*                Roemerstrasse 52                                           */
+/*                D-70794 Filderstadt                                        */
+/* EMail:         uz@cc65.org                                                */
+/*                                                                           */
+/*                                                                           */
+/* 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 _CBM_FILETYPE_H
+#define _CBM_FILETYPE_H
+
+
+
+/* Check for errors */
+#if !defined(__CBM__)
+#  error This module may be used only when compiling for CBM machines!
+#endif
+
+
+
+/*****************************************************************************/
+/*                                Definitions                                */
+/*****************************************************************************/
+
+
+
+/* CBM FILE TYPES. The definitions are used within standard headers, so we
+ * be careful with identifiers in the user name space.
+ */
+#define _CBM_T_DEL      0
+#define _CBM_T_SEQ      1
+#define _CBM_T_PRG      2
+#define _CBM_T_USR      3
+#define _CBM_T_REL      4
+#define _CBM_T_CBM      5       /* 1581 sub-partition */
+#define _CBM_T_DIR      6       /* IDE64 and CMD sub-directory */
+#define _CBM_T_LNK      7       /* IDE64 soft-link */
+#define _CBM_T_VRP      8       /* Vorpal fast-loadable format */
+#define _CBM_T_OTHER    9       /* File-type not recognized */
+#define _CBM_T_HEADER  10       /* Disk header / title */
+
+#if __CC65_STD__ == __CC65_STD_CC65__
+/* Allow for names without leading underscores */
+#define CBM_T_DEL       _CBM_T_DEL
+#define CBM_T_SEQ       _CBM_T_SEQ
+#define CBM_T_PRG       _CBM_T_PRG
+#define CBM_T_USR       _CBM_T_USR
+#define CBM_T_REL       _CBM_T_REL
+#define CBM_T_CBM       _CBM_T_CBM
+#define CBM_T_DIR       _CBM_T_DIR
+#define CBM_T_LNK       _CBM_T_LNK
+#define CBM_T_VRP       _CBM_T_VRP
+#define CBM_T_OTHER     _CBM_T_OTHER
+#define CBM_T_HEADER    _CBM_T_HEADER
+#endif
+
+
+
+/*****************************************************************************/
+/*                                   Code                                    */
+/*****************************************************************************/
+
+
+
+unsigned char __fastcall__ _cbm_filetype (unsigned char c);
+/* Map the start character for a file type to one of the file types above.
+ * Note: 'd' will always mapped to CBM_T_DEL. The calling function has to
+ * look at the following character to determine if the file type is actually
+ * CBM_T_DIR.
+ * This is a function used by the implementation. There is usually no need
+ * to call it from user code.
+ */
+
+
+
+/* End of cbm_filetype.h */
+#endif
+
+
index c91428a428ab1155f6d1d223c615481f87fa35e0..f98e5ff194cc391af5d78ce3e95187dcf35bde26 100644 (file)
@@ -57,7 +57,7 @@ S_OBJS =      c_acptr.o       \
                c_unlsn.o       \
                c_untlk.o       \
                cbm_close.o     \
-                cbm_ftype.o     \
+                cbm_filetype.o  \
                cbm_open.o      \
                cbm_read.o      \
                cbm_write.o     \
diff --git a/libsrc/cbm/cbm_filetype.s b/libsrc/cbm/cbm_filetype.s
new file mode 100644 (file)
index 0000000..3df5de3
--- /dev/null
@@ -0,0 +1,71 @@
+;
+; Determine the CBM file type. From cbm_dir.c by Josef Soucek. Moved into an
+; assembler function by Ullrich von Bassewitz 2012-06-03
+;
+; unsigned char __fastcall__ _cbm_filetype (unsigned char c);
+;
+
+        .include "cbm_filetype.inc"
+
+        .macpack generic
+
+
+; --------------------------------------------------------------------------
+; Table with types for a list of start characters
+
+.rodata
+.proc   TypeTable
+        .byte   CBM_T_CBM       ; c
+        .byte   CBM_T_DEL       ; d
+        .byte   CBM_T_OTHER     ; e
+        .byte   CBM_T_OTHER     ; f
+        .byte   CBM_T_OTHER     ; g
+        .byte   CBM_T_OTHER     ; h
+        .byte   CBM_T_OTHER     ; i
+        .byte   CBM_T_OTHER     ; j
+        .byte   CBM_T_OTHER     ; k
+        .byte   CBM_T_LNK       ; l
+        .byte   CBM_T_OTHER     ; m
+        .byte   CBM_T_OTHER     ; n
+        .byte   CBM_T_OTHER     ; o
+        .byte   CBM_T_PRG       ; p
+        .byte   CBM_T_OTHER     ; q
+        .byte   CBM_T_REL       ; r
+        .byte   CBM_T_SEQ       ; s
+        .byte   CBM_T_OTHER     ; t
+        .byte   CBM_T_USR       ; u
+        .byte   CBM_T_VRP       ; v
+.endproc
+
+
+; --------------------------------------------------------------------------
+; Mapper function
+
+.code
+.proc   __cbm_filetype
+
+        ldx     #0              ; Clear high byte
+
+; Check that the given char is in table range
+
+        sec
+        sbc     #'c'
+        bcc     L1
+        cmp     #.sizeof (TypeTable)
+        bge     L1
+
+; Ok, load the type
+
+        tay
+        lda     TypeTable,y
+        rts
+
+; Out of table range, return CBM_T_OTHER
+
+L1:     lda     #CBM_T_OTHER
+        rts
+
+.endproc
+
+
+
diff --git a/libsrc/cbm/cbm_ftype.s b/libsrc/cbm/cbm_ftype.s
deleted file mode 100644 (file)
index 862fb72..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-;
-; Determine the CBM file type. From cbm_dir.c by Josef Soucek. Moved into an
-; assembler function by Ullrich von Bassewitz 2012-06-03
-;
-; unsigned char __fastcall__ _cbm_filetype (unsigned char c);
-;
-
-        .include "cbm_ftype.inc"
-
-        .macpack generic
-
-
-; --------------------------------------------------------------------------
-; Table with types for a list of start characters
-
-.rodata
-.proc   TypeTable
-        .byte   CBM_T_CBM       ; c
-        .byte   CBM_T_DEL       ; d
-        .byte   CBM_T_OTHER     ; e
-        .byte   CBM_T_OTHER     ; f
-        .byte   CBM_T_OTHER     ; g
-        .byte   CBM_T_OTHER     ; h
-        .byte   CBM_T_OTHER     ; i
-        .byte   CBM_T_OTHER     ; j
-        .byte   CBM_T_OTHER     ; k
-        .byte   CBM_T_LNK       ; l
-        .byte   CBM_T_OTHER     ; m
-        .byte   CBM_T_OTHER     ; n
-        .byte   CBM_T_OTHER     ; o
-        .byte   CBM_T_PRG       ; p
-        .byte   CBM_T_OTHER     ; q
-        .byte   CBM_T_REL       ; r
-        .byte   CBM_T_SEQ       ; s
-        .byte   CBM_T_OTHER     ; t
-        .byte   CBM_T_USR       ; u
-        .byte   CBM_T_VRP       ; v
-.endproc
-
-
-; --------------------------------------------------------------------------
-; Mapper function
-
-.code
-.proc   __cbm_filetype
-
-        ldx     #0              ; Clear high byte
-
-; Check that the given char is in table range
-
-        sec
-        sbc     #'c'
-        bcc     L1
-        cmp     #.sizeof (TypeTable)
-        bge     L1
-
-; Ok, load the type
-
-        tay
-        lda     TypeTable,y
-        rts
-
-; Out of table range, return CBM_T_OTHER
-
-L1:     lda     #CBM_T_OTHER
-        rts
-
-.endproc
-
-
-