]> git.sur5r.net Git - cc65/blobdiff - include/cbm.h
New EMD driver for the ISEPIC cartridge written and contributed by
[cc65] / include / cbm.h
index 1e68776c629fb0657a330d672ff449c86a078ff6..6ba1ef47e12a02fa8708efb3a217d9fada5a2ce1 100644 (file)
@@ -6,10 +6,10 @@
 /*                                                                           */
 /*                                                                           */
 /*                                                                           */
-/* (C) 1998-2001 Ullrich von Bassewitz                                       */
-/*               Wacholderweg 14                                             */
-/*               D-70597 Stuttgart                                           */
-/* EMail:        uz@musoftware.de                                            */
+/* (C) 1998-2004 Ullrich von Bassewitz                                       */
+/*               Römerstrasse 52                                             */
+/*               D-70794 Filderstadt                                         */
+/* EMail:        uz@cc65.org                                                 */
 /*                                                                           */
 /*                                                                           */
 /* This software is provided 'as-is', without any expressed or implied       */
@@ -54,6 +54,8 @@
 #  include <c128.h>
 #elif defined(__PLUS4__) && !defined(_PLUS4_H)
 #  include <plus4.h>
+#elif defined(__C16__) && !defined(_C16_H)
+#  include <c16.h>
 #elif defined(__CBM510__) && !defined(_CBM510_H)
 #  include <cbm510.h>
 #elif defined(__CBM610__) && !defined(_CBM610_H)
 
 
 
-/* Characters codes (CBM charset) */
+/*****************************************************************************/
+/*                                 Variables                                 */
+/*****************************************************************************/
+
+
+
+/* The file stream implementation and the POSIX I/O functions will use the
+ * following variables to determine the file type and the disk unit to use.
+ */
+extern unsigned char _curunit;          /* Default 8 */
+extern unsigned char _filetype;         /* Default 'u' */
+
+
+
+/*****************************************************************************/
+/*                      Characters codes (CBM charset)                       */
+/*****************************************************************************/
+
+
+
 #define CH_HLINE                96
 #define CH_VLINE               125
 #define        CH_ULCORNER             176
 #define CH_PI                  126
 #define CH_DEL                  20
 #define CH_INS                 148
-#define CH_ESC                  95
+#define CH_ENTER                '\n'
+#define CH_STOP                   3
+#define CH_ESC                   27
+
+
+
+/*****************************************************************************/
+/*                Definitions for directory reading functions                */
+/*****************************************************************************/
+
+
+
+/* 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_RESERVED  7       /* Not used, but kept free for compatibility */
+#define CBM_T_VRP       8       /* Vorpal fast-loadable format */
+#define CBM_T_OTHER     9       /* Other file-types not yet defined */
+#define CBM_T_HEADER   10       /* Disk header / title */
+
+/* CBM FILE ACCESS */
+#define CBM_A_RO    1           /* Read only   */
+#define CBM_A_RW    3           /* Read, Write */
+
+struct cbm_dirent {
+    char          name[17];     /* File name in PETSCII, limited to 16 chars */
+    unsigned int  size;         /* Size in 256B blocks */
+    unsigned char type;
+    unsigned char access;
+};
+
+
+
+/*****************************************************************************/
+/*                               Machine info                                */
+/*****************************************************************************/
+
+
+
+#define TV_NTSC         0
+#define TV_PAL          1
+#define TV_OTHER        2
+
+unsigned char __fastcall__ get_tv (void);
+/* Return the video mode the machine is using. */
+
+
 
-/* constants to use with cbm_open() for opening a file for reading or
+/*****************************************************************************/
+/*                           CBM kernal functions                            */
+/*****************************************************************************/
+
+
+
+/* Constants to use with cbm_open() for opening a file for reading or
  * writing without the need to append ",r" or ",w" to the filename.
  *
  * e.g.: cbm_open(2, 8, CBM_READ, "data,s");
@@ -110,16 +188,30 @@ void __fastcall__ cbm_k_clrch (void);
 
 
 
-/* BASIC-like file I/O functions
+/*****************************************************************************/
+/*                       BASIC-like file I/O functions                       */
+/*****************************************************************************/
+
+
+
+/* All cbm_* IO functions set _oserror (see errno.h) in case of an
+ * error.
  *
- * All cbm_* IO functions set _oserror (see errno.h) in case of an
- * error. For the meaning of the errorcode see the table below.
+ * errorcode   BASIC error
+ *     1   =   too many files
+ *     2   =   file open
+ *     3   =   file not open
+ *     4   =   file not found
+ *     5   =   device not present
+ *     6   =   not input file
+ *     7   =   not output file
+ *     8   =   missing filename
+ *     9   =   illegal device number
  */
 
 
 
-unsigned int cbm_load(const char* name, unsigned char device,
-                      const char* data);
+unsigned int cbm_load (const char* name, unsigned char device, void* data);
 /* Loads file "name" from given device to given address or to the load
  * address of the file if "data" is the null pointer (like load"name",8,1
  * in BASIC).
@@ -127,8 +219,8 @@ unsigned int cbm_load(const char* name, unsigned char device,
  * otherwise 0. "_oserror" contains an errorcode then (see table below).
  */
 
-unsigned char cbm_save(const char* name, unsigned char device,
-                       unsigned char* data, unsigned int size);
+unsigned char cbm_save (const char* name, unsigned char device,
+                        const void* data, unsigned int size);
 /* Saves "size" bytes starting at "data" to a file.
  * Returns 0 if saving was successful, otherwise an errorcode (see table
  * below).
@@ -153,26 +245,27 @@ int __fastcall__ cbm_read (unsigned char lfn, void* buffer, unsigned int size);
  * table below).
  */
 
-int cbm_write(unsigned char lfn, void* buffer, unsigned int size);
+int __fastcall__ cbm_write (unsigned char lfn, void* buffer, unsigned int size);
 /* Writes up to "size" bytes from "buffer" to a file.
  * Returns the number of actually written bytes or -1 in case of an error.
- * _oserror contains an errorcode then (see table below).
+ * _oserror contains an errorcode then (see above table).
  */
 
-/* Errorcodes of cbm_* I/O functions:
- *
- * errorcode   BASIC error
- *     1   =   too many files
- *     2   =   file open
- *     3   =   file not open
- *     4   =   file not found
- *     5   =   device not present
- *     6   =   not input file
- *     7   =   not output file
- *     8   =   missing filename
- *     9   =   illegal device number
+unsigned char __fastcall__ cbm_opendir (unsigned char lfn, unsigned char device);
+/* Opens directory listing.
+ * Returns 0 if opening directory was successful,
+ * othervise errorcode corresponding to cbm_open()
+ */
+
+unsigned char __fastcall__ cbm_readdir (unsigned char lfn, struct cbm_dirent* l_dirent);
+/* Reads one directory line into cbm_dirent structure.
+ * Returns 0 if reading directory line was successful.
+ * Returns 'true' if reading directory failed or no more files to read.
  */
 
+void __fastcall__ cbm_closedir (unsigned char lfn);
+/* Closes directory by cbm_close (unsigned char lfn) */
+
 
 
 /* End of cbm.h */