1 /*****************************************************************************/
5 /* Atari system specific definitions */
9 /* (C) 2000-2006 Mark Keates <markk@dendrite.co.uk> */
10 /* Freddy Offenga <taf_offenga@yahoo.com> */
11 /* Christian Groessler <chris@groessler.org> */
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. */
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: */
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 */
31 /*****************************************************************************/
40 /* Check for errors */
41 #if !defined(__ATARI__)
42 # error This module may only be used when compiling for the Atari!
48 #define CH_DELCHR 0xFE /* delete char under the cursor */
52 #define CH_CURS_DOWN 29
53 #define CH_CURS_LEFT 30
54 #define CH_CURS_RIGHT 31
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 */
65 /* These are defined to be Atari + NumberKey */
77 #define CH_ULCORNER 0x11
78 #define CH_URCORNER 0x05
79 #define CH_LLCORNER 0x1A
80 #define CH_LRCORNER 0x03
91 /* make GTIA color value */
92 #define _gtia_mkcolor(hue,lum) (((hue) << 4) | ((lum) << 1))
94 /* luminance values go from 0 (black) to 7 (white) */
99 #define HUE_GOLDORANGE 2
100 #define HUE_REDORANGE 3
102 #define HUE_MAGENTA 5
107 #define HUE_BLUEGREEN 10
108 #define HUE_BLUEGREEN2 11
110 #define HUE_YELLOWGREEN 13
111 #define HUE_YELLOW 14
112 #define HUE_YELLOWRED 15
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)
134 /* TGI color defines */
135 #define TGI_COLOR_BLACK COLOR_BLACK
136 #define TGI_COLOR_WHITE COLOR_WHITE
137 #define TGI_COLOR_RED COLOR_RED
138 #define TGI_COLOR_CYAN COLOR_CYAN
139 #define TGI_COLOR_VIOLET COLOR_VIOLET
140 #define TGI_COLOR_GREEN COLOR_GREEN
141 #define TGI_COLOR_BLUE COLOR_BLUE
142 #define TGI_COLOR_YELLOW COLOR_YELLOW
143 #define TGI_COLOR_ORANGE COLOR_ORANGE
144 #define TGI_COLOR_BROWN COLOR_BROWN
145 #define TGI_COLOR_LIGHTRED COLOR_LIGHTRED
146 #define TGI_COLOR_GRAY1 COLOR_GRAY1
147 #define TGI_COLOR_GRAY2 COLOR_GRAY2
148 #define TGI_COLOR_LIGHTGREEN COLOR_LIGHTGREEN
149 #define TGI_COLOR_LIGHTBLUE COLOR_LIGHTBLUE
150 #define TGI_COLOR_GRAY3 COLOR_GRAY3
152 /* Masks for joy_read */
153 #define JOY_UP_MASK 0x01
154 #define JOY_DOWN_MASK 0x02
155 #define JOY_LEFT_MASK 0x04
156 #define JOY_RIGHT_MASK 0x08
157 #define JOY_BTN_1_MASK 0x10
159 #define JOY_FIRE_MASK JOY_BTN_1_MASK
160 #define JOY_FIRE(v) ((v) & JOY_FIRE_MASK)
162 /* color register functions */
163 extern void __fastcall__ _setcolor (unsigned char color_reg, unsigned char hue, unsigned char luminace);
164 extern void __fastcall__ _setcolor_low (unsigned char color_reg, unsigned char color_value);
165 extern unsigned char __fastcall__ _getcolor (unsigned char color_reg);
167 /* other screen functions */
168 extern int __fastcall__ _graphics (unsigned char mode); /* mode value same as in BASIC */
169 extern void __fastcall__ _scroll (signed char numlines);
170 /* numlines > 0 scrolls up */
171 /* numlines < 0 scrolls down */
173 /* misc. functions */
174 extern unsigned char get_ostype(void); /* get ROM version */
175 extern unsigned char get_tv(void); /* get TV system */
176 extern void _save_vecs(void); /* save system vectors */
177 extern void _rest_vecs(void); /* restore system vectors */
178 extern char *_getdefdev(void); /* get default floppy device */
179 extern unsigned char _is_cmdline_dos(void); /* does DOS support command lines */
181 /* global variables */
182 extern unsigned char _dos_type; /* the DOS flavour */
184 extern void atr130_emd[];
185 extern void atrstd_joy[]; /* referred to by joy_static_stddrv[] */
186 extern void atrmj8_joy[];
187 extern void atrjoy_mou[];
188 extern void atrst_mou[]; /* referred to by mouse_static_stddrv[] */
189 extern void atrami_mou[];
190 extern void atrtrk_mou[];
191 extern void atrtt_mou[];
192 extern void atrrdev_ser[];
193 extern void atr3_tgi[];
194 extern void atr4_tgi[];
195 extern void atr5_tgi[];
196 extern void atr6_tgi[];
197 extern void atr7_tgi[];
198 extern void atr8_tgi[]; /* referred to by tgi_static_stddrv[] */
199 extern void atr8p2_tgi[];
200 extern void atr9_tgi[];
201 extern void atr9p2_tgi[];
202 extern void atr10_tgi[];
203 extern void atr10p2_tgi[];
204 extern void atr11_tgi[];
205 extern void atr14_tgi[];
206 extern void atr15_tgi[];
207 extern void atr15p2_tgi[];
209 extern void atrx130_emd[];
210 extern void atrxstd_joy[]; /* referred to by joy_static_stddrv[] */
211 extern void atrxmj8_joy[];
212 extern void atrxjoy_mou[];
213 extern void atrxst_mou[]; /* referred to by mouse_static_stddrv[] */
214 extern void atrxami_mou[];
215 extern void atrxtrk_mou[];
216 extern void atrxtt_mou[];
217 extern void atrxrdev_ser[];
218 extern void atrx3_tgi[];
219 extern void atrx4_tgi[];
220 extern void atrx5_tgi[];
221 extern void atrx6_tgi[];
222 extern void atrx7_tgi[];
223 extern void atrx8_tgi[]; /* referred to by tgi_static_stddrv[] */
224 extern void atrx8p2_tgi[];
225 extern void atrx9_tgi[];
226 extern void atrx9p2_tgi[];
227 extern void atrx10_tgi[];
228 extern void atrx10p2_tgi[];
229 extern void atrx11_tgi[];
230 extern void atrx14_tgi[];
231 extern void atrx15_tgi[];
232 extern void atrx15p2_tgi[];
235 /* provide old names for backwards compatibility */
236 #ifdef ATARI_COMPAT_PRE_2_11
237 #define setcolor _setcolor
238 #define setcolor_low _setcolor_low
239 #define getcolor _getcolor
240 #define graphics _graphics
241 #define scroll _scroll
242 #define save_vecs _save_vecs
243 #define rest_vecs _rest_vecs
244 #define getdefdev _getdefdev
245 #endif /* #ifdef ATARI_COMPAT_PRE_2_11 */
247 /* get_ostype return value defines (for explanation, see ostype.s) */
249 #define AT_OS_TYPE_MAIN 7
250 #define AT_OS_TYPE_MINOR (7 << 3)
251 /* AT_OS_TYPE_MAIN values */
252 #define AT_OS_UNKNOWN 0
253 #define AT_OS_400800 1
254 #define AT_OS_1200XL 2
256 /* AS_OS_TYPE_MINOR values */
257 /* for 400/800 remember this are the ROM versions */
258 /* to check whether the hw is PAL or NTSC, use get_tv() */
259 #define AT_OS_400800PAL_A 1
260 #define AT_OS_400800PAL_B 2
261 #define AT_OS_400800NTSC_A 1
262 #define AT_OS_400800NTSC_B 2
263 #define AT_OS_1200_10 1
264 #define AT_OS_1200_11 2
265 #define AT_OS_XLXE_1 1
266 #define AT_OS_XLXE_2 2
267 #define AT_OS_XLXE_3 3
268 #define AT_OS_XLXE_4 4
270 /* get_tv return values */
274 /* valid _dos_type values */
282 /* Define hardware */
284 #define GTIA_READ (*(struct __gtia_read*)0xD000)
285 #define GTIA_WRITE (*(struct __gtia_write*)0xD000)
290 #define POKEY_READ (*(struct __pokey_read*)0xD200)
291 #define POKEY_WRITE (*(struct __pokey_write*)0xD200)
294 #define PIA (*(struct __pia*)0xD300)
297 #define ANTIC (*(struct __antic*)0xD400)
299 /* device control block */
301 unsigned char device; /* device id */
302 unsigned char unit; /* unit number */
303 unsigned char command; /* command */
304 unsigned char status; /* command type / status return */
305 void *buffer; /* pointer to buffer */
306 unsigned char timeout; /* device timeout in seconds */
307 unsigned char unused;
308 unsigned int xfersize; /* # of bytes to transfer */
309 unsigned char aux1; /* 1st command auxiliary byte */
310 unsigned char aux2; /* 2nd command auxiliary byte */
312 #define DCB (*(struct __dcb *)0x300)
314 /* I/O control block */
316 unsigned char handler; /* handler index number (0xff free) */
317 unsigned char drive; /* device number (drive) */
318 unsigned char command; /* command */
319 unsigned char status; /* status of last operation */
320 void *buffer; /* pointer to buffer */
321 void *put_byte; /* pointer to device's PUT BYTE routine */
322 unsigned int buflen; /* length of buffer */
323 unsigned char aux1; /* 1st auxiliary byte */
324 unsigned char aux2; /* 2nd auxiliary byte */
325 unsigned char aux3; /* 3rd auxiliary byte */
326 unsigned char aux4; /* 4th auxiliary byte */
327 unsigned char aux5; /* 5th auxiliary byte */
328 unsigned char spare; /* spare byte */
330 #define ZIOCB (*(struct __iocb *)0x20) /* zero page IOCB */
331 #define IOCB (*(struct __iocb *)0x340) /* system IOCB buffers */
333 /* IOCB Command Codes */
334 #define IOCB_OPEN 0x03 /* open */
335 #define IOCB_GETREC 0x05 /* get record */
336 #define IOCB_GETCHR 0x07 /* get character(s) */
337 #define IOCB_PUTREC 0x09 /* put record */
338 #define IOCB_PUTCHR 0x0B /* put character(s) */
339 #define IOCB_CLOSE 0x0C /* close */
340 #define IOCB_STATIS 0x0D /* status */
341 #define IOCB_SPECIL 0x0E /* special */
342 #define IOCB_DRAWLN 0x11 /* draw line */
343 #define IOCB_FILLIN 0x12 /* draw line with right fill */
344 #define IOCB_RENAME 0x20 /* rename disk file */
345 #define IOCB_DELETE 0x21 /* delete disk file */
346 #define IOCB_LOCKFL 0x23 /* lock file (set to read-only) */
347 #define IOCB_UNLOCK 0x24 /* unlock file */
348 #define IOCB_POINT 0x25 /* point sector */
349 #define IOCB_NOTE 0x26 /* note sector */
350 #define IOCB_GETFL 0x27 /* get file length */
351 #define IOCB_CHDIR_MYDOS 0x29 /* change directory (MyDOS) */
352 #define IOCB_MKDIR 0x2A /* make directory (MyDOS/SpartaDOS) */
353 #define IOCB_RMDIR 0x2B /* remove directory (SpartaDOS) */
354 #define IOCB_CHDIR_SPDOS 0x2C /* change directory (SpartaDOS) */
355 #define IOCB_GETCWD 0x30 /* get current directory (MyDOS/SpartaDOS) */
356 #define IOCB_FORMAT 0xFE /* format */