]> git.sur5r.net Git - cc65/blob - include/cbm.h
fc55b43d14db9fccf51da7a0d4a793f1dc01a080
[cc65] / include / cbm.h
1 /*****************************************************************************/
2 /*                                                                           */
3 /*                                   cbm.h                                   */
4 /*                                                                           */
5 /*                      CBM system specific definitions                      */
6 /*                                                                           */
7 /*                                                                           */
8 /*                                                                           */
9 /* (C) 1998-2001 Ullrich von Bassewitz                                       */
10 /*               Wacholderweg 14                                             */
11 /*               D-70597 Stuttgart                                           */
12 /* EMail:        uz@musoftware.de                                            */
13 /*                                                                           */
14 /*                                                                           */
15 /* This software is provided 'as-is', without any expressed or implied       */
16 /* warranty.  In no event will the authors be held liable for any damages    */
17 /* arising from the use of this software.                                    */
18 /*                                                                           */
19 /* Permission is granted to anyone to use this software for any purpose,     */
20 /* including commercial applications, and to alter it and redistribute it    */
21 /* freely, subject to the following restrictions:                            */
22 /*                                                                           */
23 /* 1. The origin of this software must not be misrepresented; you must not   */
24 /*    claim that you wrote the original software. If you use this software   */
25 /*    in a product, an acknowledgment in the product documentation would be  */
26 /*    appreciated but is not required.                                       */
27 /* 2. Altered source versions must be plainly marked as such, and must not   */
28 /*    be misrepresented as being the original software.                      */
29 /* 3. This notice may not be removed or altered from any source              */
30 /*    distribution.                                                          */
31 /*                                                                           */
32 /*****************************************************************************/
33
34
35
36 #ifndef _CBM_H
37 #define _CBM_H
38
39
40
41 /* Load the system specific files here, if needed */
42 #if defined(__C64__) && !defined(_C64_H)
43 #  include <c64.h>
44 #elif defined(__C128__) && !defined(_C128_H)
45 #  include <c128.h>
46 #elif defined(__PLUS4__) && !defined(_PLUS4_H)
47 #  include <plus4.h>
48 #elif defined(__CBM510__) && !defined(_CBM510_H)
49 #  include <cbm510.h>
50 #elif defined(__CBM610__) && !defined(_CBM610_H)
51 #  include <cbm610.h>
52 #elif defined(__PET__) && !defined(_PET_H)
53 #  include <pet.h>
54 #endif
55
56
57
58 /* Characters codes (CBM charset) */
59 #define CH_HLINE                 96
60 #define CH_VLINE                125
61 #define CH_ULCORNER             176
62 #define CH_URCORNER             174
63 #define CH_LLCORNER             173
64 #define CH_LRCORNER             189
65 #define CH_TTEE                 178
66 #define CH_RTEE                 179
67 #define CH_BTEE                 177
68 #define CH_LTEE                 171
69 #define CH_CROSS                123
70 #define CH_CURS_UP              145
71 #define CH_CURS_DOWN             17
72 #define CH_CURS_LEFT            157
73 #define CH_CURS_RIGHT            29
74 #define CH_PI                   126
75 #define CH_DEL                   20
76 #define CH_INS                  148
77 #define CH_ESC                   95
78
79
80
81 /* Kernel level functions */
82 void __fastcall__ cbm_k_setlfs (unsigned char LFN, unsigned char DEV,
83                                 unsigned char SA);
84 void __fastcall__ cbm_k_setnam (const char* Name);
85 unsigned char __fastcall__ cbm_k_load(unsigned char flag, unsigned addr);
86 unsigned char __fastcall__ cbm_k_save(unsigned int start, unsigned int end);
87 unsigned char __fastcall__ cbm_k_open (void);
88 void __fastcall__ cbm_k_close (unsigned char FN);
89 unsigned char __fastcall__ cbm_k_readst (void);
90 unsigned char __fastcall__ cbm_k_chkin (unsigned char FN);
91 unsigned char __fastcall__ cbm_k_ckout (unsigned char FN);
92 unsigned char __fastcall__ cbm_k_basin (void);
93 void __fastcall__ cbm_k_bsout (unsigned char C);
94 void __fastcall__ cbm_k_clrch (void);
95
96
97
98 /* BASIC-like file I/O functions
99  *
100  * All cbm_* IO functions set _oserror (see errno.h) in case of an
101  * error. For the meaning of the errorcode see the table below.
102  */
103
104
105
106 unsigned char cbm_load(const char* name, unsigned char device,
107                        unsigned int addr);
108 /* Loads file "name" from given device to given address or to the load
109  * address of the file if addr is 0 (like load"name",8,1 in BASIC)
110  * Returns 0 if loading was successful otherwise an errorcode (see table
111  * below).
112  */
113
114 unsigned char cbm_save(const char* name, unsigned char device,
115                        unsigned int start, unsigned int end);
116 /* Saves a memory area from start to end-1 to a file.
117  * Returns 0 if saving was successful, otherwise an errorcode (see table
118  * below).
119  */
120
121 unsigned char cbm_open(unsigned char lfn, unsigned char device,
122                        unsigned char sec_addr, const char* name);
123 /* Opens a file. Works just like the BASIC command.
124  * Returns 0 if opening was successful, otherwise an errorcode (see table
125  * below).
126  */
127
128 void __fastcall__ cbm_close (unsigned char lfn);
129 /* Closes a file */
130
131 int cbm_read(unsigned char lfn, void* buffer, unsigned int size);
132 /* Reads up to "size" bytes from a file to "buffer".
133  * Returns the number of actually read bytes, 0 if there are no bytes left
134  * (EOF) or -1 in case of an error. _oserror contains an errorcode then (see
135  * table below).
136  */
137
138 int cbm_write(unsigned char lfn, void* buffer, unsigned int size);
139 /* Writes up to "size" bytes from "buffer" to a file.
140  * Returns the number of actually written bytes or -1 in case of an error.
141  * _oserror contains an errorcode then (see table below).
142  */
143
144 /* Errorcodes of cbm_* I/O functions:
145  *
146  * errorcode    BASIC error
147  *      1   =   too many files
148  *      2   =   file open
149  *      3   =   file not open
150  *      4   =   file not found
151  *      5   =   device not present
152  *      6   =   not input file
153  *      7   =   not output file
154  *      8   =   missing filename
155  *      9   =   illegal device number
156  */
157
158
159
160 /* End of cbm.h */
161 #endif
162
163