]> git.sur5r.net Git - cc65/blobdiff - include/atari.h
Adds test code for the Atari (xex) linker file format.
[cc65] / include / atari.h
index 0ca2dc577799d7785ff4ddad3b82f5059e48b310..e06967ff97edff06b090e0962c987137d2727812 100644 (file)
@@ -6,9 +6,10 @@
 /*                                                                           */
 /*                                                                           */
 /*                                                                           */
-/* (C) 2000-2018 Mark Keates <markk@dendrite.co.uk>                          */
+/* (C) 2000-2019 Mark Keates <markk@dendrite.co.uk>                          */
 /*               Freddy Offenga <taf_offenga@yahoo.com>                      */
 /*               Christian Groessler <chris@groessler.org>                   */
+/*               Bill Kendrick <nbs@sonic.net>                               */
 /*                                                                           */
 /*                                                                           */
 /* This software is provided 'as-is', without any expressed or implied       */
 
 
 
-/* Character codes */
+/*****************************************************************************/
+/* Character codes                                                           */
+/*****************************************************************************/
+
 #define CH_DELCHR       0xFE   /* delete char under the cursor */
 #define CH_ENTER        0x9B
 #define CH_ESC          0x1B
 #define CH_HLINE        0x12
 #define CH_VLINE        0x7C
 
-/* color defines */
-
-/* make GTIA color value */
-#define _gtia_mkcolor(hue,lum) (((hue) << 4) | ((lum) << 1))
-
-/* luminance values go from 0 (black) to 7 (white) */
-
-/* hue values */
-#define HUE_GREY        0
-#define HUE_GOLD        1
-#define HUE_GOLDORANGE  2
-#define HUE_REDORANGE   3
-#define HUE_ORANGE      4
-#define HUE_MAGENTA     5
-#define HUE_PURPLE      6
-#define HUE_BLUE        7
-#define HUE_BLUE2       8
-#define HUE_CYAN        9
-#define HUE_BLUEGREEN   10
-#define HUE_BLUEGREEN2  11
-#define HUE_GREEN       12
-#define HUE_YELLOWGREEN 13
-#define HUE_YELLOW      14
-#define HUE_YELLOWRED   15
-
-/* Color defines, similar to c64 colors (untested) */
-/* Note that the conio color implementation is monochrome (bgcolor and textcolor are only placeholders) */
-/* Use the defines with the setcolor() or _atari_xxxcolor() functions */
-#define COLOR_BLACK             _gtia_mkcolor(HUE_GREY,0)
-#define COLOR_WHITE             _gtia_mkcolor(HUE_GREY,7)
-#define COLOR_RED               _gtia_mkcolor(HUE_REDORANGE,1)
-#define COLOR_CYAN              _gtia_mkcolor(HUE_CYAN,3)
-#define COLOR_VIOLET            _gtia_mkcolor(HUE_PURPLE,4)
-#define COLOR_GREEN             _gtia_mkcolor(HUE_GREEN,2)
-#define COLOR_BLUE              _gtia_mkcolor(HUE_BLUE,2)
-#define COLOR_YELLOW            _gtia_mkcolor(HUE_YELLOW,7)
-#define COLOR_ORANGE            _gtia_mkcolor(HUE_ORANGE,5)
-#define COLOR_BROWN             _gtia_mkcolor(HUE_YELLOW,2)
-#define COLOR_LIGHTRED          _gtia_mkcolor(HUE_REDORANGE,6)
-#define COLOR_GRAY1             _gtia_mkcolor(HUE_GREY,2)
-#define COLOR_GRAY2             _gtia_mkcolor(HUE_GREY,3)
-#define COLOR_LIGHTGREEN        _gtia_mkcolor(HUE_GREEN,6)
-#define COLOR_LIGHTBLUE         _gtia_mkcolor(HUE_BLUE,6)
-#define COLOR_GRAY3             _gtia_mkcolor(HUE_GREY,5)
-
-/* TGI color defines */
-#define TGI_COLOR_BLACK         COLOR_BLACK
-#define TGI_COLOR_WHITE         COLOR_WHITE
-#define TGI_COLOR_RED           COLOR_RED
-#define TGI_COLOR_CYAN          COLOR_CYAN
-#define TGI_COLOR_VIOLET        COLOR_VIOLET
-#define TGI_COLOR_GREEN         COLOR_GREEN
-#define TGI_COLOR_BLUE          COLOR_BLUE
-#define TGI_COLOR_YELLOW        COLOR_YELLOW
-#define TGI_COLOR_ORANGE        COLOR_ORANGE
-#define TGI_COLOR_BROWN         COLOR_BROWN
-#define TGI_COLOR_LIGHTRED      COLOR_LIGHTRED
-#define TGI_COLOR_GRAY1         COLOR_GRAY1
-#define TGI_COLOR_GRAY2         COLOR_GRAY2
-#define TGI_COLOR_LIGHTGREEN    COLOR_LIGHTGREEN
-#define TGI_COLOR_LIGHTBLUE     COLOR_LIGHTBLUE
-#define TGI_COLOR_GRAY3         COLOR_GRAY3
-
-/* Masks for joy_read */
+
+/*****************************************************************************/
+/* Masks for joy_read                                                        */
+/*****************************************************************************/
+
 #define JOY_UP_MASK     0x01
 #define JOY_DOWN_MASK   0x02
 #define JOY_LEFT_MASK   0x04
 #define JOY_FIRE_MASK   JOY_BTN_1_MASK
 #define JOY_FIRE(v)     ((v) & JOY_FIRE_MASK)
 
-/* Keyboard values returned by kbcode / CH */
+
+/*****************************************************************************/
+/* Keyboard values returned by kbcode / CH                                   */
+/*****************************************************************************/
+
 #define KEY_NONE        ((unsigned char) 0xFF)
 
 #define KEY_0           ((unsigned char) 0x32)
 #define KEY_INVERSE     ((unsigned char) 0x27)
 #define KEY_HELP        ((unsigned char) 0x11)
 
+/* Function keys only exist on the 1200XL model. */
 #define KEY_F1          ((unsigned char) 0x03)
 #define KEY_F2          ((unsigned char) 0x04)
 #define KEY_F3          ((unsigned char) 0x13)
 #define KEY_F4          ((unsigned char) 0x14)
 
+/* N.B. Cannot read Ctrl key alone */
 #define KEY_CTRL        ((unsigned char) 0x80)
+
+/* N.B. Cannot read Shift key alone via KBCODE;
+** instead, check "Shfit key press" bit of SKSTAT register.
+** Also, no way to tell left Shift from right Shift.
+*/
 #define KEY_SHIFT       ((unsigned char) 0x40)
 
-/* Composed keys */
+
+/* Composed keys
+** (Other combinations are possible, including Shift+Ctrl+key,
+** though not all such combinations are available.)
+*/
 
 #define KEY_EXCLAMATIONMARK     (KEY_1 | KEY_SHIFT)
 #define KEY_QUOTE               (KEY_2 | KEY_SHIFT)
 #define KEY_LEFT    (KEY_PLUS | KEY_CTRL)
 #define KEY_RIGHT   (KEY_ASTERISK | KEY_CTRL)
 
-/* color register functions */
+
+/*****************************************************************************/
+/* Color register functions                                                  */
+/*****************************************************************************/
+
 extern void __fastcall__ _setcolor     (unsigned char color_reg, unsigned char hue, unsigned char luminace);
 extern void __fastcall__ _setcolor_low (unsigned char color_reg, unsigned char color_value);
 extern unsigned char __fastcall__ _getcolor (unsigned char color_reg);
 
-/* other screen functions */
+/*****************************************************************************/
+/* Other screen functions                                                    */
+/*****************************************************************************/
+
 extern int  __fastcall__ _graphics (unsigned char mode); /* mode value same as in BASIC */
 extern void __fastcall__ _scroll (signed char numlines);
                                           /* numlines > 0  scrolls up */
                                           /* numlines < 0  scrolls down */
 
-/* misc. functions */
+
+/*****************************************************************************/
+/* Misc. functions                                                           */
+/*****************************************************************************/
+
 extern unsigned char get_ostype(void);       /* get ROM version */
 extern unsigned char get_tv(void);           /* get TV system */
 extern void _save_vecs(void);                /* save system vectors */
@@ -275,7 +246,11 @@ extern void _rest_vecs(void);                /* restore system vectors */
 extern char *_getdefdev(void);               /* get default floppy device */
 extern unsigned char _is_cmdline_dos(void);  /* does DOS support command lines */
 
-/* global variables */
+
+/*****************************************************************************/
+/* Global variables                                                          */
+/*****************************************************************************/
+
 extern unsigned char _dos_type;         /* the DOS flavour */
 #ifndef __ATARIXL__
 extern void atr130_emd[];
@@ -329,7 +304,11 @@ extern void atrx15_tgi[];
 extern void atrx15p2_tgi[];
 #endif
 
-/* get_ostype return value defines (for explanation, see ostype.s) */
+
+/*****************************************************************************/
+/* get_ostype return value defines (for explanation, see ostype.s)           */
+/*****************************************************************************/
+
 /* masks */
 #define AT_OS_TYPE_MAIN  7
 #define AT_OS_TYPE_MINOR (7 << 3)
@@ -352,11 +331,19 @@ extern void atrx15p2_tgi[];
 #define AT_OS_XLXE_3   3
 #define AT_OS_XLXE_4   4
 
-/* get_tv return values */
+
+/*****************************************************************************/
+/* get_tv return values                                                      */
+/*****************************************************************************/
+
 #define AT_NTSC     0
 #define AT_PAL      1
 
-/* valid _dos_type values */
+
+/*****************************************************************************/
+/* valid _dos_type values                                                    */
+/*****************************************************************************/
+
 #define SPARTADOS   0
 #define REALDOS     1
 #define BWDOS       2
@@ -366,7 +353,11 @@ extern void atrx15p2_tgi[];
 #define MYDOS       6
 #define NODOS       255
 
-/* Define hardware */
+
+/*****************************************************************************/
+/* Define hardware and where they're mapped in memory                        */
+/*****************************************************************************/
+
 #include <_gtia.h>
 #define GTIA_READ  (*(struct __gtia_read*)0xD000)
 #define GTIA_WRITE (*(struct __gtia_write*)0xD000)
@@ -383,7 +374,68 @@ extern void atrx15p2_tgi[];
 #include <_antic.h>
 #define ANTIC (*(struct __antic*)0xD400)
 
-/* device control block */
+
+/*****************************************************************************/
+/* Shadow registers for hardware registers                                   */
+/*****************************************************************************/
+
+/* GTIA */
+#define STRIG0 (*(unsigned char*)0x284) /* TRIG0 */
+#define STRIG1 (*(unsigned char*)0x285) /* TRIG1 */
+#define STRIG2 (*(unsigned char*)0x286) /* TRIG2 */
+#define STRIG3 (*(unsigned char*)0x287) /* TRIG3 */
+#define PCOLR0 (*(unsigned char*)0x2C0) /* COLPM0 */
+#define PCOLR1 (*(unsigned char*)0x2C1) /* COLPM1 */
+#define PCOLR2 (*(unsigned char*)0x2C2) /* COLPM2 */
+#define PCOLR3 (*(unsigned char*)0x2C3) /* COLPM3 */
+#define COLOR0 (*(unsigned char*)0x2C4) /* COLPF0 */
+#define COLOR1 (*(unsigned char*)0x2C5) /* COLPF1 */
+#define COLOR2 (*(unsigned char*)0x2C6) /* COLPF2 */
+#define COLOR3 (*(unsigned char*)0x2C7) /* COLPF3 */
+#define COLOR4 (*(unsigned char*)0x2C8) /* COLPBK */
+#define GPRIOR (*(unsigned char*)0x264) /* PRIOR */
+
+/* ANTIC */
+#define SDMCTL (*(unsigned char*)0x22F) /* DMACTL */
+#define CHACT  (*(unsigned char*)0x2F3) /* CHACTL */
+#define SDLSTL (*(unsigned char*)0x230) /* DLISTL */
+#define SDLSTH (*(unsigned char*)0x231) /* DLISTH */
+#define SDLST  (*(unsigned int*)0x230)  /* DLISTL/H together */
+#define CHBAS  (*(unsigned char*)0x2F4) /* CHBASE */
+#define LPENH  (*(unsigned char*)0x233) /* PENH */
+#define LPENV  (*(unsigned char*)0x234) /* PENV */
+
+/* POKEY */
+#define PADDL0 (*(unsigned char*)0x270) /* POT0 */
+#define PADDL1 (*(unsigned char*)0x271) /* POT1 */
+#define PADDL2 (*(unsigned char*)0x272) /* POT2 */
+#define PADDL3 (*(unsigned char*)0x273) /* POT3 */
+#define PADDL4 (*(unsigned char*)0x274) /* POT4 */
+#define PADDL5 (*(unsigned char*)0x275) /* POT5 */
+#define PADDL6 (*(unsigned char*)0x276) /* POT6 */
+#define PADDL7 (*(unsigned char*)0x277) /* POT7 */
+#define CH     (*(unsigned char*)0x2FC) /* KBCODE */
+#define POKMSK (*(unsigned char*)0x10)  /* IRQEN */
+
+/* PIA */
+#define STICK0 (*(unsigned char*)0x278) /* PORTA for controller port 1 */
+#define STICK1 (*(unsigned char*)0x279) /* PORTA for controller port 2 */
+#define STICK2 (*(unsigned char*)0x27A) /* PORTB for controller port 3 */
+#define STICK3 (*(unsigned char*)0x27B) /* PORTB for controller port 4 */
+#define PTRIG0 (*(unsigned char*)0x27C) /* PORTA for controller port 1, paddle 1 */
+#define PTRIG1 (*(unsigned char*)0x27D) /* PORTA for controller port 1, paddle 2 */
+#define PTRIG2 (*(unsigned char*)0x27E) /* PORTA for controller port 1, paddle 3 */
+#define PTRIG3 (*(unsigned char*)0x27F) /* PORTA for controller port 1, paddle 4 */
+#define PTRIG4 (*(unsigned char*)0x280) /* PORTA for controller port 2, paddle 5 */
+#define PTRIG5 (*(unsigned char*)0x281) /* PORTA for controller port 2, paddle 6 */
+#define PTRIG6 (*(unsigned char*)0x282) /* PORTA for controller port 2, paddle 7 */
+#define PTRIG7 (*(unsigned char*)0x283) /* PORTA for controller port 2, paddle 8 */
+
+
+/*****************************************************************************/
+/* Device control block                                                      */
+/*****************************************************************************/
+
 struct __dcb {
     unsigned char device;     /* device id */
     unsigned char unit;       /* unit number */
@@ -398,7 +450,11 @@ struct __dcb {
 };
 #define DCB (*(struct __dcb *)0x300)
 
-/* I/O control block */
+
+/*****************************************************************************/
+/* I/O control block                                                         */
+/*****************************************************************************/
+
 struct __iocb {
     unsigned char handler;    /* handler index number (0xff free) */
     unsigned char drive;      /* device number (drive) */
@@ -443,6 +499,5 @@ struct __iocb {
 #define IOCB_FORMAT      0xFE  /* format */
 
 
-
 /* End of atari.h */
 #endif