]> git.sur5r.net Git - cc65/blob - include/cbm.h
cbm_write is not __fastcall__
[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 /* Check for errors */
42 #if !defined(__CBM__)
43 #  error This module may only be used when compiling for CBM machines!
44 #endif
45
46
47
48 /* Load the system specific files here, if needed */
49 #if defined(__C64__) && !defined(_C64_H)
50 #  include <c64.h>
51 #elif defined(__VIC20__) && !defined(_VIC20_H)
52 #  include <vic20.h>
53 #elif defined(__C128__) && !defined(_C128_H)
54 #  include <c128.h>
55 #elif defined(__PLUS4__) && !defined(_PLUS4_H)
56 #  include <plus4.h>
57 #elif defined(__CBM510__) && !defined(_CBM510_H)
58 #  include <cbm510.h>
59 #elif defined(__CBM610__) && !defined(_CBM610_H)
60 #  include <cbm610.h>
61 #elif defined(__PET__) && !defined(_PET_H)
62 #  include <pet.h>
63 #endif
64
65
66
67 /* Characters codes (CBM charset) */
68 #define CH_HLINE                 96
69 #define CH_VLINE                125
70 #define CH_ULCORNER             176
71 #define CH_URCORNER             174
72 #define CH_LLCORNER             173
73 #define CH_LRCORNER             189
74 #define CH_TTEE                 178
75 #define CH_RTEE                 179
76 #define CH_BTEE                 177
77 #define CH_LTEE                 171
78 #define CH_CROSS                123
79 #define CH_CURS_UP              145
80 #define CH_CURS_DOWN             17
81 #define CH_CURS_LEFT            157
82 #define CH_CURS_RIGHT            29
83 #define CH_PI                   126
84 #define CH_DEL                   20
85 #define CH_INS                  148
86 #define CH_ESC                   95
87
88 /* constants to use with cbm_open() for opening a file for reading or
89  * writing without the need to append ",r" or ",w" to the filename.
90  *
91  * e.g.: cbm_open(2, 8, CBM_READ, "data,s");
92  */
93 #define CBM_READ    0
94 #define CBM_WRITE   1
95
96 /* Kernel level functions */
97 void __fastcall__ cbm_k_setlfs (unsigned char LFN, unsigned char DEV,
98                                 unsigned char SA);
99 void __fastcall__ cbm_k_setnam (const char* Name);
100 unsigned int __fastcall__ cbm_k_load(unsigned char flag, unsigned addr);
101 unsigned char __fastcall__ cbm_k_save(unsigned int start, unsigned int end);
102 unsigned char __fastcall__ cbm_k_open (void);
103 void __fastcall__ cbm_k_close (unsigned char FN);
104 unsigned char __fastcall__ cbm_k_readst (void);
105 unsigned char __fastcall__ cbm_k_chkin (unsigned char FN);
106 unsigned char __fastcall__ cbm_k_ckout (unsigned char FN);
107 unsigned char __fastcall__ cbm_k_basin (void);
108 void __fastcall__ cbm_k_bsout (unsigned char C);
109 void __fastcall__ cbm_k_clrch (void);
110
111
112
113 /* BASIC-like file I/O functions
114  *
115  * All cbm_* IO functions set _oserror (see errno.h) in case of an
116  * error. For the meaning of the errorcode see the table below.
117  */
118
119
120
121 unsigned int cbm_load (const char* name, unsigned char device,
122                        const char* data);
123 /* Loads file "name" from given device to given address or to the load
124  * address of the file if "data" is the null pointer (like load"name",8,1
125  * in BASIC).
126  * Returns number of bytes that where loaded if loading was successful
127  * otherwise 0. "_oserror" contains an errorcode then (see table below).
128  */
129
130 unsigned char cbm_save (const char* name, unsigned char device,
131                        unsigned char* data, unsigned int size);
132 /* Saves "size" bytes starting at "data" to a file.
133  * Returns 0 if saving was successful, otherwise an errorcode (see table
134  * below).
135  */
136
137 unsigned char __fastcall__ cbm_open (unsigned char lfn,
138                                      unsigned char device,
139                                      unsigned char sec_addr,
140                                      const char* name);
141 /* Opens a file. Works just like the BASIC command.
142  * Returns 0 if opening was successful, otherwise an errorcode (see table
143  * below).
144  */
145
146 void __fastcall__ cbm_close (unsigned char lfn);
147 /* Closes a file */
148
149 int __fastcall__ cbm_read (unsigned char lfn, void* buffer, unsigned int size);
150 /* Reads up to "size" bytes from a file to "buffer".
151  * Returns the number of actually read bytes, 0 if there are no bytes left
152  * (EOF) or -1 in case of an error. _oserror contains an errorcode then (see
153  * table below).
154  */
155
156 int __fastcall__ cbm_write (unsigned char lfn, void* buffer, unsigned int size);
157 /* Writes up to "size" bytes from "buffer" to a file.
158  * Returns the number of actually written bytes or -1 in case of an error.
159  * _oserror contains an errorcode then (see table below).
160  */
161                  
162 /* Errorcodes of cbm_* I/O functions:
163  *
164  * errorcode    BASIC error
165  *      1   =   too many files
166  *      2   =   file open
167  *      3   =   file not open
168  *      4   =   file not found
169  *      5   =   device not present
170  *      6   =   not input file
171  *      7   =   not output file
172  *      8   =   missing filename
173  *      9   =   illegal device number
174  */
175
176
177
178 /* End of cbm.h */
179 #endif
180
181