]> git.sur5r.net Git - cc65/blob - include/atari.h
Adjusted C declarations to the changed static driver names.
[cc65] / include / atari.h
1 /*****************************************************************************/
2 /*                                                                           */
3 /*                                 atari.h                                   */
4 /*                                                                           */
5 /*                      Atari system specific definitions                    */
6 /*                                                                           */
7 /*                                                                           */
8 /*                                                                           */
9 /* (C) 2000-2006 Mark Keates <markk@dendrite.co.uk>                          */
10 /*               Freddy Offenga <taf_offenga@yahoo.com>                      */
11 /*               Christian Groessler <chris@groessler.org>                   */
12 /*                                                                           */
13 /*                                                                           */
14 /* This software is provided 'as-is', without any expressed or implied       */
15 /* warranty.  In no event will the authors be held liable for any damages    */
16 /* arising from the use of this software.                                    */
17 /*                                                                           */
18 /* Permission is granted to anyone to use this software for any purpose,     */
19 /* including commercial applications, and to alter it and redistribute it    */
20 /* freely, subject to the following restrictions:                            */
21 /*                                                                           */
22 /* 1. The origin of this software must not be misrepresented; you must not   */
23 /*    claim that you wrote the original software. If you use this software   */
24 /*    in a product, an acknowledgment in the product documentation would be  */
25 /*    appreciated but is not required.                                       */
26 /* 2. Altered source versions must be plainly marked as such, and must not   */
27 /*    be misrepresented as being the original software.                      */
28 /* 3. This notice may not be removed or altered from any source              */
29 /*    distribution.                                                          */
30 /*                                                                           */
31 /*****************************************************************************/
32
33
34
35 #ifndef _ATARI_H
36 #define _ATARI_H
37
38
39
40 /* Check for errors */
41 #if !defined(__ATARI__)
42 #  error This module may only be used when compiling for the Atari!
43 #endif
44
45
46
47 /* Character codes */
48 #define CH_DELCHR       0xFE   /* delete char under the cursor */
49 #define CH_ENTER        0x9B
50 #define CH_ESC          0x1B
51 #define CH_CURS_UP      28
52 #define CH_CURS_DOWN    29
53 #define CH_CURS_LEFT    30
54 #define CH_CURS_RIGHT   31
55
56 #define CH_TAB          0x7F   /* tabulator */
57 #define CH_EOL          0x9B   /* end-of-line marker */
58 #define CH_CLR          0x7D   /* clear screen */
59 #define CH_BEL          0xFD   /* bell */
60 #define CH_DEL          0x7E   /* back space (delete char to the left) */
61 #define CH_RUBOUT       0x7E   /* back space (old, deprecated) */
62 #define CH_DELLINE      0x9C   /* delete line */
63 #define CH_INSLINE      0x9D   /* insert line */
64
65 /* These are defined to be Atari + NumberKey */
66 #define CH_F1           177
67 #define CH_F2           178
68 #define CH_F3           179
69 #define CH_F4           180
70 #define CH_F5           181
71 #define CH_F6           182
72 #define CH_F7           183
73 #define CH_F8           184
74 #define CH_F9           185
75 #define CH_F10          176
76
77 #define CH_ULCORNER     0x11
78 #define CH_URCORNER     0x05
79 #define CH_LLCORNER     0x1A
80 #define CH_LRCORNER     0x03
81 #define CH_TTEE         0x17
82 #define CH_BTEE         0x18
83 #define CH_LTEE         0x01
84 #define CH_RTEE         0x04
85 #define CH_CROSS        0x13
86 #define CH_HLINE        0x12
87 #define CH_VLINE        0x7C
88
89 /* color defines */
90
91 /* make GTIA color value */
92 #define _gtia_mkcolor(hue,lum) (((hue) << 4) | ((lum) << 1))
93
94 /* luminance values go from 0 (black) to 7 (white) */
95
96 /* hue values */
97 #define HUE_GREY        0
98 #define HUE_GOLD        1
99 #define HUE_GOLDORANGE  2
100 #define HUE_REDORANGE   3
101 #define HUE_ORANGE      4
102 #define HUE_MAGENTA     5
103 #define HUE_PURPLE      6
104 #define HUE_BLUE        7
105 #define HUE_BLUE2       8
106 #define HUE_CYAN        9
107 #define HUE_BLUEGREEN   10
108 #define HUE_BLUEGREEN2  11
109 #define HUE_GREEN       12
110 #define HUE_YELLOWGREEN 13
111 #define HUE_YELLOW      14
112 #define HUE_YELLOWRED   15
113
114 /* Color defines, similar to c64 colors (untested) */
115 /* Note that the conio color implementation is monochrome (bgcolor and textcolor are only placeholders) */
116 /* Use the defines with the setcolor() or _atari_xxxcolor() functions */
117 #define COLOR_BLACK             _gtia_mkcolor(HUE_GREY,0)
118 #define COLOR_WHITE             _gtia_mkcolor(HUE_GREY,7)
119 #define COLOR_RED               _gtia_mkcolor(HUE_REDORANGE,1)
120 #define COLOR_CYAN              _gtia_mkcolor(HUE_CYAN,3)
121 #define COLOR_VIOLET            _gtia_mkcolor(HUE_PURPLE,4)
122 #define COLOR_GREEN             _gtia_mkcolor(HUE_GREEN,2)
123 #define COLOR_BLUE              _gtia_mkcolor(HUE_BLUE,2)
124 #define COLOR_YELLOW            _gtia_mkcolor(HUE_YELLOW,7)
125 #define COLOR_ORANGE            _gtia_mkcolor(HUE_ORANGE,5)
126 #define COLOR_BROWN             _gtia_mkcolor(HUE_YELLOW,2)
127 #define COLOR_LIGHTRED          _gtia_mkcolor(HUE_REDORANGE,6)
128 #define COLOR_GRAY1             _gtia_mkcolor(HUE_GREY,2)
129 #define COLOR_GRAY2             _gtia_mkcolor(HUE_GREY,3)
130 #define COLOR_LIGHTGREEN        _gtia_mkcolor(HUE_GREEN,6)
131 #define COLOR_LIGHTBLUE         _gtia_mkcolor(HUE_BLUE,6)
132 #define COLOR_GRAY3             _gtia_mkcolor(HUE_GREY,5)
133
134 /* color register functions */
135 extern void __fastcall__ _setcolor     (unsigned char color_reg, unsigned char hue, unsigned char luminace);
136 extern void __fastcall__ _setcolor_low (unsigned char color_reg, unsigned char color_value);
137 extern unsigned char __fastcall__ _getcolor (unsigned char color_reg);
138
139 /* other screen functions */
140 extern int  __fastcall__ _graphics (unsigned char mode); /* mode value same as in BASIC */
141 extern void __fastcall__ _scroll (signed char numlines);
142                                           /* numlines > 0  scrolls up */
143                                           /* numlines < 0  scrolls down */
144
145 /* misc. functions */
146 extern unsigned char get_ostype(void);  /* get ROM version */
147 extern unsigned char get_tv(void);      /* get TV system */
148 extern void _save_vecs(void);           /* save system vectors */
149 extern void _rest_vecs(void);           /* restore system vectors */
150 extern char *_getdefdev(void);          /* get default floppy device */
151
152 /* global variables */
153 extern unsigned char _dos_type;        /* the DOS flavour */
154 extern void atr130xe_emd[];
155 extern void ataristd_joy[];            /* referred to by joy_static_stddrv[] */
156 extern void atarim8_joy[];
157 extern void atari10_tgi[];
158 extern void atr10p2_tgi[];
159 extern void atari11_tgi[];
160 extern void atari14_tgi[];
161 extern void atari15_tgi[];
162 extern void atr15p2_tgi[];
163 extern void atari3_tgi[];
164 extern void atari4_tgi[];
165 extern void atari5_tgi[];
166 extern void atari6_tgi[];
167 extern void atari7_tgi[];
168 extern void atari8_tgi[];              /* referred to by tgi_static_stddrv[] */
169 extern void atr8p2_tgi[];
170 extern void atari9_tgi[];
171 extern void atr9p2_tgi[];
172
173 /* provide old names for backwards compatibility */
174 #ifdef ATARI_COMPAT_PRE_2_11
175 #define setcolor     _setcolor
176 #define setcolor_low _setcolor_low
177 #define getcolor     _getcolor
178 #define graphics     _graphics
179 #define scroll       _scroll
180 #define save_vecs    _save_vecs
181 #define rest_vecs    _rest_vecs
182 #define getdefdev    _getdefdev
183 #endif  /* #ifdef ATARI_COMPAT_PRE_2_11 */
184
185 /* get_ostype return value defines (for explanation, see ostype.s) */
186 /* masks */
187 #define AT_OS_TYPE_MAIN  7
188 #define AT_OS_TYPE_MINOR (7 << 3)
189 /* AT_OS_TYPE_MAIN values */
190 #define AT_OS_UNKNOWN  0
191 #define AT_OS_400800   1
192 #define AT_OS_1200XL   2
193 #define AT_OS_XLXE     3
194 /* AS_OS_TYPE_MINOR values */
195 /* for 400/800 remember this are the ROM versions */
196 /* to check whether the hw is PAL or NTSC, use get_tv() */
197 #define AT_OS_400800PAL_A  1
198 #define AT_OS_400800PAL_B  2
199 #define AT_OS_400800NTSC_A 1
200 #define AT_OS_400800NTSC_B 2
201 #define AT_OS_1200_10  1
202 #define AT_OS_1200_11  2
203 #define AT_OS_XLXE_1   1
204 #define AT_OS_XLXE_2   2
205 #define AT_OS_XLXE_3   3
206 #define AT_OS_XLXE_4   4
207
208 /* get_tv return values */
209 #define AT_NTSC     0
210 #define AT_PAL      1
211
212 /* valid _dos_type values */
213 #define ATARIDOS    0
214 #define SPARTADOS   1
215 #define OSADOS      2
216 #define MYDOS       3
217 #define XDOS        4
218 #define NODOS       255
219
220 /* Define hardware */
221 #include <_gtia.h>
222 #define GTIA_READ  (*(struct __gtia_read*)0xD000)
223 #define GTIA_WRITE (*(struct __gtia_write*)0xD000)
224
225 #include <_pbi.h>
226
227 #include <_pokey.h>
228 #define POKEY_READ  (*(struct __pokey_read*)0xD200)
229 #define POKEY_WRITE (*(struct __pokey_write*)0xD200)
230
231 #include <_pia.h>
232 #define PIA (*(struct __pia*)0xD300)
233
234 #include <_antic.h>
235 #define ANTIC (*(struct __antic*)0xD400)
236
237 /* device control block */
238 struct __dcb {
239     unsigned char device;     /* device id */
240     unsigned char unit;       /* unit number */
241     unsigned char command;    /* command */
242     unsigned char status;     /* command type / status return */
243     void          *buffer;    /* pointer to buffer */
244     unsigned char timeout;    /* device timeout in seconds */
245     unsigned char unused;
246     unsigned int  xfersize;   /* # of bytes to transfer */
247     unsigned char aux1;       /* 1st command auxiliary byte */
248     unsigned char aux2;       /* 2nd command auxiliary byte */
249 };
250 #define DCB (*(struct __dcb *)0x300)
251
252 /* I/O control block */
253 struct __iocb {
254     unsigned char handler;    /* handler index number (0xff free) */
255     unsigned char drive;      /* device number (drive) */
256     unsigned char command;    /* command */
257     unsigned char status;     /* status of last operation */
258     void          *buffer;    /* pointer to buffer */
259     void          *put_byte;  /* pointer to device's PUT BYTE routine */
260     unsigned int  buflen;     /* length of buffer */
261     unsigned char aux1;       /* 1st auxiliary byte */
262     unsigned char aux2;       /* 2nd auxiliary byte */
263     unsigned char aux3;       /* 3rd auxiliary byte */
264     unsigned char aux4;       /* 4th auxiliary byte */
265     unsigned char aux5;       /* 5th auxiliary byte */
266     unsigned char spare;      /* spare byte */
267 };
268 #define ZIOCB (*(struct __iocb *)0x20)  /* zero page IOCB */
269 #define IOCB (*(struct __iocb *)0x340)  /* system IOCB buffers */
270
271 /* End of atari.h */
272 #endif /* #ifndef _ATARI_H */