]> git.sur5r.net Git - cc65/blob - include/lynx.h
Merge pull request #634 from blackystardust/master
[cc65] / include / lynx.h
1 /*****************************************************************************/
2 /*                                                                           */
3 /*                                  lynx.h                                   */
4 /*                                                                           */
5 /*                     Lynx system-specific definitions                      */
6 /*                                                                           */
7 /*                                                                           */
8 /*                                                                           */
9 /* (C) 2003      Shawn Jefferson                                             */
10 /*                                                                           */
11 /* Adapted with many changes Ullrich von Bassewitz, 2004-10-09               */
12 /*                                                                           */
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 _LYNX_H
37 #define _LYNX_H
38
39
40
41 /* Check for errors */
42 #if !defined(__LYNX__)
43 #  error This module may only be used when compiling for the Lynx game console!
44 #endif
45
46
47
48 /*****************************************************************************/
49 /*                                   Data                                    */
50 /*****************************************************************************/
51
52
53
54 /* Color defines */
55 #define COLOR_BLACK             0x00
56 #define COLOR_RED               0x01
57 #define COLOR_PINK              0x02
58 #define COLOR_LIGHTGREY         0x03
59 #define COLOR_GREY              0x04
60 #define COLOR_DARKGREY          0x05
61 #define COLOR_BROWN             0x06
62 #define COLOR_PEACH             0x07
63 #define COLOR_YELLOW            0x08
64 #define COLOR_LIGHTGREEN        0x09
65 #define COLOR_GREEN             0x0A
66 #define COLOR_DARKBROWN         0x0B
67 #define COLOR_VIOLET            0x0C
68 #define COLOR_BLUE              0x0D
69 #define COLOR_LIGHTBLUE         0x0E
70 #define COLOR_WHITE             0x0F
71
72 /* TGI color defines (default palette) */
73 #define TGI_COLOR_BLACK         COLOR_BLACK
74 #define TGI_COLOR_RED           COLOR_RED
75 #define TGI_COLOR_PINK          COLOR_PINK
76 #define TGI_COLOR_LIGHTGREY     COLOR_LIGHTGREY
77 #define TGI_COLOR_GREY          COLOR_GREY
78 #define TGI_COLOR_DARKGREY      COLOR_DARKGREY
79 #define TGI_COLOR_BROWN         COLOR_BROWN
80 #define TGI_COLOR_PEACH         COLOR_PEACH
81 #define TGI_COLOR_YELLOW        COLOR_YELLOW
82 #define TGI_COLOR_LIGHTGREEN    COLOR_LIGHTGREEN
83 #define TGI_COLOR_GREEN         COLOR_GREEN
84 #define TGI_COLOR_DARKBROWN     COLOR_DARKBROWN
85 #define TGI_COLOR_VIOLET        COLOR_VIOLET
86 #define TGI_COLOR_BLUE          COLOR_BLUE
87 #define TGI_COLOR_LIGHTBLUE     COLOR_LIGHTBLUE
88 #define TGI_COLOR_WHITE         COLOR_WHITE
89
90 /* Masks for joy_read */
91 #define JOY_UP_MASK             0x80
92 #define JOY_DOWN_MASK           0x40
93 #define JOY_LEFT_MASK           0x20
94 #define JOY_RIGHT_MASK          0x10
95 #define JOY_BTN_1_MASK          0x01
96 #define JOY_BTN_2_MASK          0x02
97
98 #define JOY_BTN_A_MASK          JOY_BTN_1_MASK
99 #define JOY_BTN_B_MASK          JOY_BTN_2_MASK
100
101 #define JOY_BTN_A(v)            ((v) & JOY_BTN_A_MASK)
102 #define JOY_BTN_B(v)            ((v) & JOY_BTN_B_MASK)
103
104 /* No support for dynamically loadable drivers */
105 #define DYN_DRV 0
106
107
108
109 /*****************************************************************************/
110 /*                                 Variables                                 */
111 /*****************************************************************************/
112
113
114
115 /* The addresses of the static drivers */
116 extern void lynx_stdjoy_joy[];        /* Referred to by joy_static_stddrv[] */
117 extern void lynx_comlynx_ser[];
118 extern void lynx_160_102_16_tgi[];    /* Referred to by tgi_static_stddrv[] */
119
120
121
122 /*****************************************************************************/
123 /*                           Sound support                                   */
124 /*****************************************************************************/
125
126
127
128 void lynx_snd_init (void);
129 /* Initialize the sound driver */
130
131 void lynx_snd_pause (void);
132 /* Pause sound */
133
134 void lynx_snd_continue (void);
135 /* Continue sound after pause */
136
137 void __fastcall__ lynx_snd_play (unsigned char channel, unsigned char *music);
138 /* Play tune on channel */
139
140 void lynx_snd_stop (void);
141 /* Stop sound on all channels */
142
143 void __fastcall__ lynx_snd_stop_channel (unsigned char channel);
144 /* Stop sound on all channels */
145
146 unsigned char lynx_snd_active(void);
147 /* Show which channels are active */
148
149
150
151 /*****************************************************************************/
152 /*                           Accessing the cart                              */
153 /*****************************************************************************/
154
155
156
157 void __fastcall__ lynx_load (int fileno);
158 /* Load a file into ram. The first entry is fileno=0. */
159
160 void __fastcall__ lynx_exec (int fileno);
161 /* Load a file into ram and execute it. */
162
163
164
165 /*****************************************************************************/
166 /*                           Accessing the EEPROM                            */
167 /*****************************************************************************/
168
169
170
171 unsigned __fastcall__ lynx_eeprom_read (unsigned char cell);
172 /* Read a 16 bit word from the given address */
173
174 unsigned __fastcall__ lynx_eeprom_write (unsigned char cell, unsigned val);
175 /* Write the word at the given address */
176
177 void __fastcall__ lynx_eeprom_erase (unsigned char cell);
178 /* Clear the word at the given address */
179
180 unsigned __fastcall__ lynx_eeread (unsigned cell);
181 /* Read a 16 bit word from the given address 93C46 93C66 or 93C86*/
182
183 unsigned __fastcall__ lynx_eewrite (unsigned cell, unsigned val);
184 /* Write the word at the given address 93C46 93C66 or 93C86*/
185
186
187
188 /*****************************************************************************/
189 /*                           TGI extras                                      */
190 /*****************************************************************************/
191
192
193
194 #define tgi_sprite(spr) tgi_ioctl(0, spr)
195 #define tgi_flip() tgi_ioctl(1, (void*)0)
196 #define tgi_setbgcolor(bgcol) tgi_ioctl(2, (void*)(bgcol))
197 #define tgi_setframerate(rate) tgi_ioctl(3, (void*)(rate))
198 #define tgi_busy() tgi_ioctl(4, (void*)0)
199 #define tgi_updatedisplay() tgi_ioctl(4, (void*)1)
200 #define tgi_setcollisiondetection(active) tgi_ioctl(5, (void*)(active))
201
202 /* Define Hardware */
203 #include <_mikey.h>
204 #define MIKEY (*(struct __mikey *)0xFD00)
205
206 #define _MIKEY_TIMERS (*(struct _mikey_all_timers *) 0xFD00)  // mikey_timers[8]
207 #define _HBL_TIMER (*(struct _mikey_timer *) 0xFD00)          // timer0 (HBL)
208 #define _VBL_TIMER (*(struct _mikey_timer *) 0xFD08)          // timer2 (VBL)
209 #define _UART_TIMER (*(struct _mikey_timer *) 0xFD14)         // timer4 (UART)
210 #define _VIDDMA (*(unsigned int *) 0xFD92)                    // dispctl/viddma
211
212 #include <_suzy.h>
213 #define SUZY        (*(struct __suzy*)0xFC00)
214
215
216
217 /* End of lynx.h */
218 #endif