]> git.sur5r.net Git - cc65/blobdiff - include/cbm.h
Fixed LinuxDoc Tools issues in some verbatim blocks in the Atari document.
[cc65] / include / cbm.h
index f9cf117c3ef9d20ddbc782857ad0867513979fd2..0a2d6469455d1e084d9b7992f93d74e8507f1254 100644 (file)
@@ -1,12 +1,12 @@
 /*****************************************************************************/
 /*                                                                           */
-/*                                  cbm.h                                   */
+/*                                   cbm.h                                   */
 /*                                                                           */
-/*                     CBM system-specific definitions                      */
+/*                      CBM system-specific definitions                      */
 /*                                                                           */
 /*                                                                           */
 /*                                                                           */
-/* (c) 1998-2011, Ullrich von Bassewitz                                      */
+/* (C) 1998-2015, Ullrich von Bassewitz                                      */
 /*                Roemerstrasse 52                                           */
 /*                D-70794 Filderstadt                                        */
 /* EMail:         uz@cc65.org                                                */
 
 
 /* We need NULL. */
-
-#if !defined(_STDDEF_H)
-#  include <stddef.h>
-#endif
+#include <stddef.h>
 
 /* Load the system-specific files here, if needed. */
 #if   defined(__C64__)    && !defined(_C64_H)
 #  include <pet.h>
 #endif
 
+/* Include definitions for CBM file types */
+#include <cbm_filetype.h>
+
+
+
+#define JOY_FIRE_MASK   JOY_BTN_1_MASK
+#define JOY_FIRE(v)     ((v) & JOY_FIRE_MASK)
+
 
 
 /*****************************************************************************/
 
 
 
-/* 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;  /* Defaults to current when program started */
-extern char _filetype;          /* Defaults to 'u' */
+/* The file stream implementation and the POSIX I/O functions will
+** use the following variable to determine the file type to use.
+*/
+extern char _filetype;          /* Defaults to 's' */
 
 
 
@@ -92,45 +96,29 @@ extern char _filetype;          /* Defaults to 'u' */
 
 
 
-#ifdef __CC65__
-/* ASCII-to-PetSCII character-map translations:
- * These lines convert characters that are not in CBM's character-set
- * into codes with shapes that resemble the ASCII shapes.
- */
-#pragma charmap(0x5c,0xbf)     /* '\\' */
-#pragma charmap(0x5f,0xa4)     /* '_'  thinner than built-in one */
-#pragma charmap(0x60,0xad)     /* '`'  */
-#pragma charmap(0x7b,0xb3)     /* '{'  */
-#pragma charmap(0x7c,0xdd)     /* '|'  "official" PetSCII code */
-#pragma charmap(0x7d,0xab)     /* '}'  */
-#pragma charmap(0x7e,0xb1)     /* '~'  */
-#endif
-
-
-
-#define CH_HLINE       192
-#define CH_VLINE       221
-#define CH_ULCORNER    176
-#define CH_URCORNER    174
-#define CH_LLCORNER    173
-#define CH_LRCORNER    189
-#define CH_TTEE                178
-#define CH_BTEE                177
-#define CH_LTEE                171
-#define CH_RTEE                179
-#define CH_CROSS       219
-#define CH_CURS_UP     145
-#define CH_CURS_DOWN    17
-#define CH_CURS_LEFT   157
-#define CH_CURS_RIGHT   29
-#define CH_PI          222
-#define CH_HOME                 19
-#define CH_DEL          20
-#define CH_INS         148
-#define CH_ENTER        13
-#define CH_STOP                  3
-#define CH_LIRA                 92
-#define CH_ESC          27
+#define CH_HLINE        192
+#define CH_VLINE        221
+#define CH_ULCORNER     176
+#define CH_URCORNER     174
+#define CH_LLCORNER     173
+#define CH_LRCORNER     189
+#define CH_TTEE         178
+#define CH_BTEE         177
+#define CH_LTEE         171
+#define CH_RTEE         179
+#define CH_CROSS        219
+#define CH_CURS_UP      145
+#define CH_CURS_DOWN     17
+#define CH_CURS_LEFT    157
+#define CH_CURS_RIGHT    29
+#define CH_PI           222
+#define CH_HOME          19
+#define CH_DEL           20
+#define CH_INS          148
+#define CH_ENTER         13
+#define CH_STOP           3
+#define CH_LIRA          92
+#define CH_ESC           27
 
 
 
@@ -140,19 +128,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  */
@@ -177,10 +152,20 @@ struct cbm_dirent {
 #define TV_PAL          1
 #define TV_OTHER        2
 
-unsigned char __fastcall__ get_tv (void);
+unsigned char get_tv (void);
 /* Return the video mode the machine is using. */
 
+#define KBREPEAT_CURSOR 0x00
+#define KBREPEAT_NONE   0x40
+#define KBREPEAT_ALL    0x80
 
+unsigned char __fastcall__ kbrepeat (unsigned char mode);
+/* Changes which keys have automatic repeat. */
+
+#if !defined(__CBM610__) && !defined(__PET__)
+void waitvsync (void);
+/* Wait for the start of the next frame */
+#endif
 
 /*****************************************************************************/
 /*                           CBM kernal functions                            */
@@ -189,30 +174,41 @@ unsigned char __fastcall__ get_tv (void);
 
 
 /* Constants to use with cbm_open() for openning 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, "0:data,s");
- */
-#define CBM_READ       0       /* default is ",p" */
-#define CBM_WRITE      1       /* ditto */
-#define CBM_SEQ                2       /* default is ",r" -- or ",s" when writing */
+** writing without the need to append ",r" or ",w" to the filename.
+**
+** e.g., cbm_open(2, 8, CBM_READ, "0:data,s");
+*/
+#define CBM_READ        0       /* default is ",p" */
+#define CBM_WRITE       1       /* ditto */
+#define CBM_SEQ         2       /* default is ",r" -- or ",s" when writing */
 
 /* Kernal-level functions */
-void __fastcall__ cbm_k_setlfs (unsigned char LFN, unsigned char DEV,
-                                unsigned char SA);
-void __fastcall__ cbm_k_setnam (const char* Name);
-unsigned int __fastcall__ cbm_k_load(unsigned char flag, unsigned addr);
-unsigned char __fastcall__ cbm_k_save(unsigned int start, unsigned int end);
-unsigned char cbm_k_open (void);
-void __fastcall__ cbm_k_close (unsigned char FN);
-signed char cbm_k_readst (void);
-unsigned char __fastcall__ cbm_k_chkin (unsigned char FN);
-unsigned char __fastcall__ cbm_k_ckout (unsigned char FN);
+unsigned char cbm_k_acptr (void);
 unsigned char cbm_k_basin (void);
-unsigned char cbm_k_getin (void);
 void __fastcall__ cbm_k_bsout (unsigned char C);
+unsigned char __fastcall__ cbm_k_chkin (unsigned char FN);
+void __fastcall__ cbm_k_ciout (unsigned char C);
+unsigned char __fastcall__ cbm_k_ckout (unsigned char FN);
+void cbm_k_clall (void);
+void __fastcall__ cbm_k_close (unsigned char FN);
 void cbm_k_clrch (void);
-void cbm_clall (void);
+unsigned char cbm_k_getin (void);
+unsigned cbm_k_iobase (void);
+void __fastcall__ cbm_k_listen (unsigned char dev);
+unsigned int __fastcall__ cbm_k_load(unsigned char flag, unsigned addr);
+unsigned char cbm_k_open (void);
+unsigned char cbm_k_readst (void);
+unsigned char __fastcall__ cbm_k_save(unsigned int start, unsigned int end);
+void cbm_k_scnkey (void);
+void __fastcall__ cbm_k_second (unsigned char addr);
+void __fastcall__ cbm_k_setlfs (unsigned char LFN, unsigned char DEV,
+                                unsigned char SA);
+void __fastcall__ cbm_k_setnam (const char* Name);
+void __fastcall__ cbm_k_talk (unsigned char dev);
+void __fastcall__ cbm_k_tksa (unsigned char addr);
+void cbm_k_udtim (void);
+void cbm_k_unlsn (void);
+void cbm_k_untlk (void);
 
 
 
@@ -223,78 +219,79 @@ void cbm_clall (void);
 
 
 /* The cbm_* I/O functions below set _oserror (see errno.h),
- * in case of an error.
- *
- * error-code  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 file-name
- *      9  =   illegal device-number
- *
- *     10  =   STOP-key pushed
- *     11  =   general I/O-error
- */
-
-
-
-unsigned int cbm_load (const char* name, unsigned char device, void* data);
+** in case of an error.
+**
+** error-code   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 file-name
+**       9  =   illegal device-number
+**
+**      10  =   STOP-key pushed
+**      11  =   general I/O-error
+*/
+
+
+
+unsigned int __fastcall__ 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).
- * Returns number of bytes that were loaded if loading was successful;
- * otherwise 0, "_oserror" contains an error-code, then (see table above).
- */
+** address of the file if "data" is the null pointer (like load"name",8,1
+** in BASIC).
+** Returns number of bytes that were loaded if loading was successful;
+** otherwise 0, "_oserror" contains an error-code, then (see table above).
+*/
 
 unsigned char __fastcall__ cbm_save (const char* name, unsigned char device,
                                      const void* addr, unsigned int size);
 /* Saves "size" bytes, starting at "addr", to a file.
- * Returns 0 if saving was successful, otherwise an error-code (see table
- * above).
- */
+** Returns 0 if saving was successful, otherwise an error-code (see table
+** above).
+*/
 
 unsigned char __fastcall__ cbm_open (unsigned char lfn, unsigned char device,
                                      unsigned char sec_addr, const char* name);
 /* Opens a file. Works just like the BASIC command.
- * Returns 0 if openning was successful, otherwise an error-code (see table
- * above).
- */
+** Returns 0 if openning was successful, otherwise an error-code (see table
+** above).
+*/
 
 void __fastcall__ cbm_close (unsigned char lfn);
 /* Closes a file */
 
 int __fastcall__ cbm_read (unsigned char lfn, void* buffer, unsigned int size);
 /* Reads up to "size" bytes from a file into "buffer".
- * Returns the number of actually-read bytes, 0 if there are no bytes left.
- * -1 in case of an error; then, _oserror contains an error-code (see table
- * above).  (Remember:  0 means end-of-file; -1 means error.)
- */
+** Returns the number of actually-read bytes, 0 if there are no bytes left.
+** -1 in case of an error; then, _oserror contains an error-code (see table
+** above).  (Remember:  0 means end-of-file; -1 means error.)
+*/
 
 int __fastcall__ cbm_write (unsigned char lfn, const 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 error-code, then (see above table).
- */
+** Returns the number of actually-written bytes, or -1 in case of an error;
+** _oserror contains an error-code, then (see above table).
+*/
 
-unsigned char __fastcall__ cbm_opendir (unsigned char lfn, unsigned char device);
-/* Opens directory listing.
- * Returns 0 if openning directory was successful;
- * otherwise, an error-code corresponding to cbm_open().
- */
+unsigned char cbm_opendir (unsigned char lfn, unsigned char device, ...);
+/* Opens directory listing. Returns 0 if opening directory was successful;
+** otherwise, an error-code corresponding to cbm_open(). As an optional
+** argument, the name of the directory may be passed to the function. If
+** no explicit name is specified, "$" is used.
+*/
 
 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 non-zero if reading directory failed, or no more file-names to read.
- * Returns 2 on last line.  Then, l_dirent->size = the number of "blocks free."
- */
+** Returns 0 if reading directory-line was successful.
+** Returns non-zero if reading directory failed, or no more file-names to read.
+** Returns 2 on last line.  Then, l_dirent->size = the number of "blocks free."
+*/
 
 void __fastcall__ cbm_closedir (unsigned char lfn);
 /* Closes directory by cbm_close(lfn) */