1 /*****************************************************************************/
5 /* Lynx system-specific definitions */
9 /* (C) 2003 Shawn Jefferson */
11 /* Adapted with many changes Ullrich von Bassewitz, 2004-10-09 */
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. */
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: */
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 */
32 /*****************************************************************************/
41 /* Check for errors */
42 #if !defined(__LYNX__)
43 # error This module may only be used when compiling for the Lynx game console!
48 /*****************************************************************************/
50 /*****************************************************************************/
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
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
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
98 #define JOY_BTN_A_MASK JOY_BTN_1_MASK
99 #define JOY_BTN_B_MASK JOY_BTN_2_MASK
101 #define JOY_BTN_A(v) ((v) & JOY_BTN_A_MASK)
102 #define JOY_BTN_B(v) ((v) & JOY_BTN_B_MASK)
104 /* No support for dynamically loadable drivers */
109 /*****************************************************************************/
111 /*****************************************************************************/
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[] */
122 /*****************************************************************************/
124 /*****************************************************************************/
126 void lynx_snd_init (void);
127 /* Initialize the sound driver */
129 void lynx_snd_pause (void);
132 void lynx_snd_continue (void);
133 /* Continue sound after pause */
135 void __fastcall__ lynx_snd_play (unsigned char channel, unsigned char *music);
136 /* Play tune on channel */
138 void lynx_snd_stop (void);
139 /* Stop sound on all channels */
141 void __fastcall__ lynx_snd_stop_channel (unsigned char channel);
142 /* Stop sound on all channels */
144 unsigned char lynx_snd_active(void);
145 /* Show which channels are active */
147 /*****************************************************************************/
148 /* Accessing the cart */
149 /*****************************************************************************/
153 void __fastcall__ lynx_load (int fileno);
154 /* Load a file into ram. The first entry is fileno=0. */
156 void __fastcall__ lynx_exec (int fileno);
157 /* Load a file into ram and execute it. */
161 /*****************************************************************************/
162 /* Accessing the EEPROM */
163 /*****************************************************************************/
167 unsigned __fastcall__ lynx_eeprom_read (unsigned char cell);
168 /* Read a 16 bit word from the given address */
170 unsigned __fastcall__ lynx_eeprom_write (unsigned char cell, unsigned val);
171 /* Write the word at the given address */
173 void __fastcall__ lynx_eeprom_erase (unsigned char cell);
174 /* Clear the word at the given address */
176 unsigned __fastcall__ lynx_eeread (unsigned cell);
177 /* Read a 16 bit word from the given address 93C46 93C66 or 93C86*/
179 unsigned __fastcall__ lynx_eewrite (unsigned cell, unsigned val);
180 /* Write the word at the given address 93C46 93C66 or 93C86*/
184 /*****************************************************************************/
186 /*****************************************************************************/
190 #define tgi_sprite(spr) tgi_ioctl(0, spr)
191 #define tgi_flip() tgi_ioctl(1, (void*)0)
192 #define tgi_setbgcolor(bgcol) tgi_ioctl(2, (void*)(bgcol))
193 #define tgi_setframerate(rate) tgi_ioctl(3, (void*)(rate))
194 #define tgi_busy() tgi_ioctl(4, (void*)0)
195 #define tgi_updatedisplay() tgi_ioctl(4, (void*)1)
196 #define tgi_setcollisiondetection(active) tgi_ioctl(5, (void*)(active))
198 /* Define Hardware */
200 #define MIKEY (*(struct __mikey *)0xFD00)
202 #define _MIKEY_TIMERS (*(struct _mikey_all_timers *) 0xFD00) // mikey_timers[8]
203 #define _HBL_TIMER (*(struct _mikey_timer *) 0xFD00) // timer0 (HBL)
204 #define _VBL_TIMER (*(struct _mikey_timer *) 0xFD08) // timer2 (VBL)
205 #define _UART_TIMER (*(struct _mikey_timer *) 0xFD14) // timer4 (UART)
206 #define _VIDDMA (*(unsigned int *) 0xFD92) // dispctl/viddma
209 #define SUZY (*(struct __suzy*)0xFC00)