1 /***************************************************************************
2 
3 							-= Kaneko 16 Bit Games =-
4 
5 					driver by	Luca Elia (l.elia@tin.it)
6 
7 
8 CPU    :  68000  +  MCU [Optional]
9 
10 SOUND  :  OKI-M6295 x (1 | 2) + YM2149 x (0 | 2)
11    OR  :  Z80  +  YM2151
12 
13 OTHER  :  93C46 EEPROM [Optional]
14 
15 CUSTOM :  VU-001 046A                  (48pin PQFP)
16           VU-002 052 151021            (160pin PQFP)	<- Sprites
17           VU-003 										<- High Colour Background
18           VIEW2-CHIP 23160-509 9047EAI (144pin PQFP)	<- Tilemaps
19           MUX2-CHIP                    (64pin PQFP)
20           HELP1-CHIP
21           IU-001 9045KP002             (44pin PQFP)
22           I/O JAMMA MC-8282 047        (46pin)			<- Inputs
23 
24 
25 ---------------------------------------------------------------------------
26 Year + Game					PCB			Notes
27 ---------------------------------------------------------------------------
28 91	The Berlin Wall
29 	Magical Crystals		Z00FC-02
30 92	Bakuretsu Breaker
31 	Blaze On							2 Sprites Chips !?
32 	Sand Scorpion (by Face)				MCU protection (collision detection etc.)
33 	Shogun Warriors						MCU protection (68k code snippets, NOT WORKING)
34 	B.Rap Boys							MCU protection (not working, game can be
35                                                         run on a shoggwar board ok)
36 94	Great 1000 Miles Rally				MCU protection (EEPROM handling etc.)
37 	Bonks Adventure			Z09AF-003	MCU protection
38 95	Great 1000 Miles Rally 2			MCU protection (EEPROM handling etc.)
39 ---------------------------------------------------------------------------
40 
41 Note: gtmr manual shows "Compatible with AX Kaneko System Board"
42 
43 To Do:
44 
45 [gtmr]
46 
47 - Stage 4: The layers' scrolling is very jerky for a couple of seconds
48   in the middle of this level (probably interrupt related)
49 
50 - The layers' colours are not initialised when showing the self test
51   screen and the very first screen (with the Kaneko logo in the middle).
52   They're probably supposed to be disabled in those occasions, but the
53   relevant registers aren't changed throughout the game (?)
54 
55 [gtmr2]
56 
57 - Finish the Inputs (different wheels and pedals)
58 
59 - Find infos about the communication stuff (even if it won't be supported)
60 
61 ***************************************************************************/
62 
63 #include "driver.h"
64 #include "vidhrdw/generic.h"
65 #include "machine/eeprom.h"
66 #include "machine/random.h"
67 #include "kaneko16.h"
68 
69 /* Variables only used here: */
70 
71 static int shogwarr_mcu_status, shogwarr_mcu_command_offset;
72 static data16_t *mcu_ram, gtmr_mcu_com[4], *kaneko16_mainram;
73 
74 data16_t *kaneko16_mcu_ram;
75 
76 extern int 	kaneko16_sprite_fliptype;
77 static int calc3_mcu_status, calc3_mcu_command_offset;
78 
79 
calc3_mcu_init(void)80 void calc3_mcu_init(void)
81 {
82 	calc3_mcu_status = 0;
83 	calc3_mcu_command_offset = 0;
84 }
85 
WRITE16_HANDLER(calc3_mcu_ram_w)86 WRITE16_HANDLER( calc3_mcu_ram_w )
87 {
88 	COMBINE_DATA(&kaneko16_mcu_ram[offset]);
89 }
90 
91 #define CALC3_MCU_COM_W(_n_)				\
92 WRITE16_HANDLER( calc3_mcu_com##_n_##_w )	\
93 {											\
94 	log_cb(RETRO_LOG_DEBUG, LOGPRE "calc3w %d %04x %04x\n",_n_, data,mem_mask); \
95 	calc3_mcu_status |= (1 << _n_);			\
96 }
97 
98 CALC3_MCU_COM_W(0)
99 CALC3_MCU_COM_W(1)
100 CALC3_MCU_COM_W(2)
101 CALC3_MCU_COM_W(3)
102 
103 
104 static UINT16 calc3_mcu_crc;
105 
106 /* decryption tables */
107 
108 /* this should probably be derived from the final block at the end of the MCU rom somehow ...
109     (see 'finalblock' debug output when verbose = 1)
110    for now just putting it in a bit table, only used keys are filled in as nothing else was
111    extracted when getting the tables, unknown values are filled in as -1
112 
113    key 0 means no decryption, this could be done in logic rather than expecting the first
114    part of the table to be 0
115 */
116 
117 static const INT16 calc3_keydata[0x40*0x100] = {
118 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
119 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
120 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
121 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
122 0xce,0x55,0xa1,0x56,0x20,0xe0,0xcb,0xa9,0x5b,0x9b,0xd6,0x9b,0x5e,0x6e,0x6c,0xf6,
123 0xf8,0x16,0xb6,0x03,0x76,0xcb,0x47,0x51,0xed,0x20,0xcc,0xb3,0x4c,0x2a,0x74,0x88,
124 0x20,0xe4,0x1f,0x3f,0x25,0xd2,0x49,0x19,0x90,0xe5,0xb4,0x31,0x1e,0x9f,0xd7,0xba,
125 0xda,0x77,0x08,0x89,0xb1,0x7f,0x6b,0xd3,0xb6,0x44,0x99,0x37,0x35,0xf6,0x0f,0xff,
126   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
127   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
128   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
129   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
130   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
131   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
132   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
133   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
134 0x01,0x4a,0x9e,0xa3,0x0c,0xb4,0x74,0x2d,0x7c,0xbd,0x79,0x3a,0x62,0xe9,0x29,0x12,
135 0x01,0x50,0xc0,0x39,0x5a,0x47,0x27,0x38,0x77,0x3c,0x9e,0xa0,0x7a,0xe2,0x29,0x4d,
136 0x64,0x8e,0xbb,0xe8,0xa5,0xe1,0x23,0xaf,0x67,0xa8,0xb9,0x79,0x99,0x00,0xc8,0xf4,
137 0xbd,0xbe,0xb9,0x32,0x71,0x0e,0x03,0x64,0xbe,0x59,0xd5,0xe5,0x22,0x6d,0x80,0x7a,
138 0x5e,0xd8,0xa6,0xd7,0x00,0x94,0x23,0x66,0xaf,0xea,0xbe,0x45,0x38,0x90,0x8e,0x8d,
139 0x5b,0x14,0x2c,0xda,0x55,0x7e,0x9d,0x08,0x2d,0x31,0xfd,0x3a,0xbe,0x13,0xeb,0x21,
140 0x87,0xee,0xb7,0x7b,0x34,0x15,0x4d,0xd9,0xeb,0x4a,0xde,0xa6,0x57,0xdf,0x53,0x65,
141 0x75,0x1c,0x72,0x3a,0x20,0xe1,0xcd,0xac,0x5d,0x8c,0x6d,0xa9,0x66,0x1d,0x41,0xca,
142   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
143   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
144   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
145   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
146   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
147   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
148   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
149   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
150   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
151   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
152   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
153   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
154   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
155   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
156   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
157   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
158   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
159   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
160   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
161   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
162   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
163   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
164   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
165   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
166   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
167   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
168   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
169   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
170   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
171   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
172   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
173   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
174   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
175   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
176   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
177   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
178   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
179   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
180   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
181   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
182 0xca,0x23,0x9e,0x00,0x37,0x72,0x61,0x0d,0x71,0x99,0x02,0xb1,0x5b,0x8f,0x50,0x22,
183 0x06,0xdb,0xd6,0xd5,0x44,0x42,0xcd,0x44,0xf0,0xa2,0xc4,0xef,0xfa,0x1e,0x11,0xa1,
184 0x34,0x7b,0xf6,0xf4,0xdf,0xca,0x92,0x17,0xf3,0x48,0x8d,0xcf,0x30,0x82,0x81,0xbc,
185 0xe8,0xbd,0x29,0xde,0x89,0x94,0x4b,0x57,0xed,0xe3,0x66,0x73,0x60,0xe4,0x1b,0xe5,
186 0x75,0x98,0x5b,0x53,0x88,0x69,0x54,0x16,0x11,0x0d,0x1c,0x3b,0xae,0xad,0x1a,0xcd,
187 0xed,0x47,0x37,0x56,0xdd,0x51,0xc8,0xa3,0x52,0x9f,0x38,0xc8,0xfb,0x86,0x78,0x64,
188 0x25,0x42,0x27,0x26,0x4b,0x95,0x80,0x90,0x64,0xb1,0x07,0xfb,0xeb,0x58,0xf2,0xdc,
189 0xad,0x42,0x57,0x45,0x56,0xbf,0x19,0xaf,0xb9,0x9d,0x93,0xf6,0xe1,0x4c,0x01,0xa5,
190 0xdb,0x40,0xb2,0x74,0x40,0x97,0xee,0x0f,0x84,0xfc,0xa7,0x19,0x01,0xcb,0xe1,0x71,
191 0xc1,0x75,0xe2,0xb4,0x0d,0x26,0x19,0x03,0xb9,0xa6,0xce,0x06,0x2c,0x7d,0x8d,0x30,
192 0x31,0x5b,0x52,0x45,0x7f,0xb7,0x75,0x1a,0x09,0xb5,0x53,0x9c,0x06,0x4d,0xc0,0x14,
193 0xbf,0xaa,0x2f,0xa9,0x1a,0xd0,0x9d,0x27,0xe9,0x82,0x41,0xff,0xf2,0x63,0xf5,0x8e,
194 0xbd,0x5b,0x62,0xa2,0x20,0x3c,0xed,0x3a,0x8b,0xa6,0x64,0x8d,0x13,0x27,0x67,0x4e,
195 0x40,0xa7,0x96,0x2f,0x95,0x04,0x7f,0xa4,0xe3,0xf9,0x45,0xe9,0x4c,0x44,0x10,0x46,
196 0x19,0x08,0x38,0x91,0x3b,0x70,0x2f,0xf5,0xa2,0x95,0x31,0xf3,0x40,0xa2,0xad,0xa6,
197 0xdb,0x35,0x70,0x4b,0x96,0x09,0x97,0x00,0x3d,0xd2,0x32,0xcc,0x52,0x69,0xb7,0xe0,
198 0xdb,0x29,0x2c,0x1d,0xe8,0x99,0x12,0xd6,0xe6,0x4b,0x12,0xd6,0xa6,0x04,0x6a,0xa5,
199 0x2a,0x1c,0x15,0x07,0x35,0x28,0xbc,0xc6,0x90,0xd7,0x5e,0xb1,0x1d,0x1a,0xc1,0xe5,
200 0x9c,0x88,0x96,0x4b,0x3f,0x00,0x6f,0x62,0xef,0x90,0x60,0x3f,0x5b,0x95,0x77,0xd1,
201 0xc4,0x24,0xdc,0x6a,0x8a,0xa9,0xc6,0x7b,0x74,0xce,0x24,0x9f,0xc3,0x9f,0x06,0xdc,
202 0xf4,0xeb,0xd0,0x25,0x58,0xed,0x1d,0x23,0x54,0x2b,0x73,0x34,0x78,0x9f,0xab,0xb5,
203 0x41,0x15,0x1d,0x7c,0xac,0xd4,0x8e,0xa9,0x82,0x80,0xd9,0x9f,0x5d,0x3f,0x5f,0x4d,
204 0x7c,0x1b,0x2f,0xb2,0x4b,0xa7,0xf4,0xa0,0xaf,0xe6,0xa2,0xc0,0x15,0x68,0xde,0xd6,
205 0x38,0xb6,0x31,0x46,0xb5,0xf0,0xeb,0xd7,0x50,0xb5,0xd7,0xb8,0x03,0x43,0xa4,0xc0,
206 0xca,0xe0,0x0d,0xfa,0x2f,0x78,0xcd,0x61,0x97,0x87,0x45,0xe8,0x4a,0x39,0xe9,0xbe,
207 0x43,0xd0,0x6f,0xcf,0xbc,0x47,0xb6,0x8e,0x77,0x35,0x76,0xf2,0xcc,0xf3,0xab,0xbe,
208 0x77,0x01,0xc1,0x06,0x1e,0xa6,0x80,0xef,0xa3,0xd7,0xb5,0xb6,0x2e,0x5a,0xa4,0xf4,
209 0xf8,0x2b,0x30,0x20,0xd8,0x1f,0xc6,0x55,0x8f,0xc7,0x0d,0x55,0xd2,0x97,0x4f,0xce,
210 0x1b,0x48,0xa4,0xdd,0x2e,0x7a,0xe3,0xd1,0x6d,0x9e,0x49,0x31,0xdb,0x13,0xe6,0x00,
211 0xf1,0x8f,0xcb,0x3f,0x23,0xc1,0xf3,0xb4,0x30,0x35,0xf4,0xea,0x2c,0x77,0x65,0x79,
212 0x4e,0x7b,0x0e,0x87,0x79,0x3c,0xd1,0x8f,0x8b,0xa4,0x5a,0x61,0x68,0xac,0x87,0x6b,
213 0xc4,0xc4,0x98,0x36,0xb3,0x75,0x16,0x33,0xf2,0x45,0x84,0xb8,0xf2,0xdb,0xc7,0x46,
214 0xa8,0x63,0x55,0x0d,0x15,0x34,0x1f,0xb2,0x96,0xb0,0x3f,0x4f,0xec,0x6c,0x60,0xbb,
215 0x0b,0x91,0xf0,0x0d,0xa2,0x83,0x07,0x5b,0x6c,0xc0,0x14,0xc7,0x3b,0x0a,0x4d,0xbd,
216 0xc0,0xc8,0xd3,0x76,0x1c,0xaa,0xa8,0xc1,0x27,0x8c,0x50,0x02,0x81,0x9d,0x48,0x7b,
217 0x5c,0xc0,0x2a,0xca,0x06,0x32,0x9d,0xb3,0x38,0x6d,0xfd,0x20,0x21,0x4d,0xce,0x66,
218 0x30,0x72,0xe0,0xca,0xa4,0xe5,0x41,0x44,0xd4,0xfe,0xe6,0x82,0x3e,0x85,0x18,0x30,
219 0x50,0x17,0x9f,0x77,0xf8,0xcb,0xb0,0xc4,0xed,0x16,0x96,0xca,0xba,0xec,0x22,0xca,
220 0x8f,0x28,0xd3,0x12,0xc6,0x2e,0xc4,0xc3,0x36,0xcf,0x59,0xd8,0x3a,0x6c,0xa7,0x64,
221 0x7f,0x5f,0xa6,0x1b,0x90,0x96,0x19,0x14,0x22,0x81,0x38,0xcd,0x20,0x2f,0x22,0x70,
222 0x74,0xb4,0x04,0x55,0x9a,0xcd,0x09,0xc7,0xe5,0xc7,0xff,0x0b,0x8e,0x9c,0xce,0x9e,
223 0x81,0x5f,0x98,0xbf,0xe7,0xdb,0xaf,0x2d,0x71,0x77,0x3a,0x32,0x69,0x5d,0xa5,0xe0,
224 0x79,0xdc,0xcc,0x9b,0x38,0x0a,0xe6,0xd7,0x79,0xad,0x33,0x23,0x53,0x5c,0x64,0x67,
225 0xee,0xe1,0xcc,0x6a,0x13,0xe2,0x4a,0x97,0x71,0xc0,0xf4,0x00,0xae,0xc0,0x84,0xa3,
226 0x34,0x69,0x83,0xec,0xb8,0x2c,0x36,0x7c,0x8a,0x4b,0x4a,0x29,0x9f,0xf3,0x41,0x46,
227 0x5e,0xab,0x9b,0x24,0x2d,0xf2,0xc4,0xd8,0xb9,0x24,0xbf,0x3f,0x08,0x9e,0x96,0x40,
228 0x3f,0x22,0x7f,0x51,0x32,0x7d,0xcf,0x3d,0xb0,0x67,0x9f,0x24,0x8b,0xaa,0x3e,0xc3,
229 0x69,0x87,0x5c,0xf5,0x4d,0x55,0xf2,0x7a,0xe2,0x6b,0xf3,0xf8,0x8d,0x40,0xb4,0x3f,
230   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
231   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
232   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
233   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
234   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
235   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
236   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
237   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
238   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
239   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
240   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
241   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
242   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
243   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
244   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
245   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
246   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
247   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
248   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
249   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
250   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
251   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
252   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
253   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
254 0xfe,0xf7,0xc7,0x85,0xe4,0xd3,0x93,0xd0,0x36,0x61,0xc8,0x4d,0x0c,0x3e,0x2a,0x1c,
255 0x32,0x1a,0xbf,0x1a,0xb0,0x60,0xb5,0xa8,0x1a,0x19,0x16,0xaf,0x96,0x0d,0x2d,0xe0,
256 0xb1,0x2c,0xb6,0x41,0xe1,0x2d,0xc8,0xe5,0xd9,0x75,0x82,0xfa,0x90,0x3a,0x77,0x09,
257 0x0e,0xe8,0xda,0x7a,0xfb,0xc4,0x68,0x57,0xe8,0xcf,0x18,0x51,0x5b,0xed,0x83,0x08,
258   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
259   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
260   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
261   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
262 0x75,0x49,0x7a,0xd6,0x84,0xbd,0x70,0xbe,0x10,0x19,0x6c,0xb2,0xa9,0x5f,0x6b,0x78,
263 0x14,0x29,0x2a,0x15,0xd0,0x4a,0x10,0x93,0x69,0xb2,0xdf,0x02,0x7f,0x92,0x19,0xbd,
264 0x95,0xc1,0x32,0xee,0x99,0x5e,0x7a,0x55,0x37,0xb7,0xc8,0x45,0xdc,0x6a,0xe6,0xef,
265 0x8b,0xca,0xbe,0xe2,0x63,0x85,0x49,0xd3,0xeb,0x83,0x32,0x9a,0x23,0x11,0x4c,0x7e,
266   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
267   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
268   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
269   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
270   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
271   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
272   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
273   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
274   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
275   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
276   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
277   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
278   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
279   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
280   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
281   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
282   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
283   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
284   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
285   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
286   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
287   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
288   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
289   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
290   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
291   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
292   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
293   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
294   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
295   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
296   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
297   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
298   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
299   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
300   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
301   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
302   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
303   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
304   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
305   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
306   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
307   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
308   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
309   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
310   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
311   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
312   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
313   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
314 0x02,0xdf,0x0f,0x0e,0x98,0x3a,0xa7,0xaf,0xbd,0xb0,0xe6,0x3a,0x8d,0xeb,0xb4,0x3b,
315 0x18,0x67,0x78,0xbb,0xeb,0x1c,0x09,0x06,0x5c,0x5c,0x51,0xb1,0x98,0xfe,0xc0,0xdc,
316 0x6d,0xbc,0x77,0xb5,0xd7,0xda,0x2f,0x3d,0x4c,0x08,0xee,0x4f,0xc7,0x8a,0x68,0xde,
317 0x94,0x96,0x35,0x7e,0xe0,0xfe,0xb7,0x26,0xff,0x0e,0xc7,0x34,0x7b,0xb8,0x25,0xb1,
318 0xe0,0xee,0x9d,0xd7,0x49,0x50,0xf9,0xd0,0xa8,0x07,0xa9,0xc1,0xd8,0xf1,0x33,0x07,
319 0x63,0xfe,0x5b,0xc0,0x13,0xda,0x12,0x8e,0x3a,0xcc,0x1e,0x97,0xc1,0xdd,0x8d,0xd1,
320 0xf2,0x3e,0xda,0x7c,0x04,0xe4,0xdc,0xef,0x69,0x75,0x72,0x98,0xd9,0x67,0xee,0x3f,
321 0x1d,0x66,0x44,0x8a,0x9c,0xf7,0xf2,0xc6,0xa7,0x5c,0xae,0xe4,0x83,0xb7,0xd1,0xc2,
322   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
323   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
324   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
325   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
326 0xd0,0xa8,0x87,0xcf,0xe1,0x22,0x8d,0xe7,0xfa,0x26,0x85,0xce,0x6d,0xfa,0x2c,0x8b,
327 0xbd,0x75,0xfe,0x64,0x2b,0xab,0x25,0xa1,0x02,0xcc,0x1f,0x93,0xa2,0x4a,0x31,0xd5,
328 0x4d,0x3a,0x8e,0xd2,0xb3,0xfd,0x46,0x87,0x3f,0x1f,0xef,0x8a,0x1e,0x7f,0x15,0x4c,
329 0x13,0xb1,0x61,0x9b,0xfc,0xa0,0x8b,0x6b,0x22,0x78,0x00,0xd5,0x44,0xc3,0x52,0x60,
330   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
331   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
332   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
333   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
334 0xaf,0x2e,0xd9,0xfd,0x18,0xd1,0xb8,0xc2,0x9b,0x33,0x28,0x30,0x01,0xff,0x1c,0xf4,
335 0xc6,0xf9,0xc9,0x7c,0xa2,0x9a,0x8f,0xb9,0xd9,0xfa,0xa7,0x24,0x42,0xf3,0x8b,0xff,
336 0x18,0x84,0x29,0xdd,0x82,0x73,0xc7,0x64,0xe3,0x37,0xb3,0x52,0xe2,0x14,0xb2,0xbe,
337 0x37,0x88,0x25,0xa0,0x3b,0xe6,0xfb,0x94,0x2d,0x41,0x59,0xdb,0x44,0x8b,0x0b,0xa3,
338   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
339   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
340   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
341   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
342 0x7c,0x82,0x91,0x60,0xee,0x5d,0x7a,0x63,0x8a,0x2c,0x91,0xe7,0x94,0x02,0x02,0x42,
343 0x7d,0x8a,0xba,0x09,0x78,0xa6,0x50,0xd6,0xbe,0x55,0xb5,0x49,0xa1,0xda,0x9d,0x4d,
344 0x51,0x1b,0xab,0x9d,0x70,0x47,0x5f,0x86,0x57,0xbb,0xbf,0xee,0x24,0x27,0xc6,0x95,
345 0x8b,0xec,0x90,0x9b,0x58,0xc9,0x42,0x43,0xc6,0xb7,0xba,0xf6,0x82,0x11,0xfa,0x8b,
346 0x7d,0xf8,0x54,0xc5,0x74,0xf6,0x54,0x1d,0x40,0xe1,0x71,0xc2,0xdd,0x03,0x72,0xdf,
347 0x3b,0x77,0xa1,0x1c,0xc7,0xd6,0xb1,0x67,0xb7,0x13,0x6f,0xf4,0x18,0xa4,0x2a,0x82,
348 0x98,0xe3,0xe3,0xe1,0x12,0xb3,0x33,0xb1,0xde,0x66,0xff,0x6c,0xd5,0xde,0xdd,0xa6,
349 0x26,0xf3,0x44,0x94,0xdb,0x15,0x76,0xcc,0x28,0x33,0x2d,0x4b,0x79,0xdb,0x06,0xbc,
350 0x39,0xa2,0xb0,0xf7,0x63,0xc6,0xd4,0xc9,0xc9,0x12,0xc2,0xf3,0x26,0x02,0xe0,0x75,
351 0xe4,0x28,0xd2,0x0c,0xad,0xce,0x68,0xf9,0xb3,0xdd,0x4b,0x04,0xbe,0xfd,0x65,0xc1,
352 0xfa,0xfe,0x14,0x12,0x7d,0x77,0x0e,0xed,0x99,0xad,0x11,0x5f,0xe6,0xb6,0x52,0xd1,
353 0x0d,0xde,0xa2,0x8a,0x55,0x49,0x60,0x76,0xee,0xda,0x21,0x26,0x00,0x54,0x20,0x17,
354   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
355   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
356   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
357   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
358   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
359   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
360   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
361   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
362   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
363   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
364   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
365   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
366   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
367   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
368   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
369   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
370 0x27,0xb4,0xc1,0xba,0x5f,0xd4,0x47,0x04,0x1f,0xfe,0x42,0xa5,0xce,0xb5,0x23,0xbe,
371 0x42,0xcc,0x59,0x71,0x51,0x13,0x41,0xa4,0x18,0x35,0xcf,0x02,0x0d,0xe1,0xfb,0x43,
372 0xc5,0x28,0xed,0xae,0x84,0x27,0xe8,0xdc,0x89,0xe5,0xf6,0xbe,0x16,0x7e,0x57,0xe1,
373 0x41,0x82,0xa9,0xf1,0x7c,0x98,0xd7,0x7c,0xe5,0x67,0xc2,0xf9,0x4d,0xb6,0xb0,0x09,
374   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
375   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
376   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
377   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
378   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
379   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
380   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
381   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
382   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
383   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
384   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
385   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
386   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
387   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
388   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
389   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
390   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
391   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
392   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
393   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
394   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
395   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
396   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
397   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
398   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
399   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
400   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
401   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
402   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
403   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
404   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
405   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
406   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
407   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
408   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
409   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
410   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
411   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
412   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
413   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
414   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
415   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
416   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
417   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
418   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
419   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
420   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
421   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
422   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
423   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
424   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
425   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
426   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
427   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
428   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
429   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
430   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
431   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
432   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
433   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
434   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
435   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
436   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
437   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
438   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
439   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
440   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
441   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
442   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
443   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
444   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
445   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
446   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
447   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
448   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
449   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
450   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
451   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
452   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
453   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
454   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
455   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
456   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
457   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
458   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
459   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
460   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
461   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
462   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
463   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
464   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
465   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
466   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
467   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
468   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
469   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
470   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
471   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
472   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
473   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
474   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
475   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
476   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
477   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
478   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
479   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
480   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
481   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
482   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
483   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
484   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
485   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
486   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
487   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
488   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
489   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
490   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
491   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
492   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
493   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
494   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
495   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
496   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
497   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
498   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
499   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
500   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
501   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
502   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
503   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
504   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
505   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
506   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
507   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
508   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
509   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
510   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
511   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
512   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
513   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
514   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
515   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
516   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
517   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
518   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
519   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
520   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
521   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
522   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
523   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
524   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
525   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
526   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
527   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
528   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
529   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
530   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
531   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
532   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
533   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
534   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
535   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
536   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
537   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
538   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
539   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
540   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
541   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
542   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
543   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
544   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
545   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
546   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
547   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
548   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
549   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
550   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
551   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
552   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
553   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
554   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
555   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
556   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
557   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
558   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
559   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
560   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
561   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
562   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
563   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
564   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
565   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
566   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
567   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
568   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
569   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
570   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
571   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
572   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
573   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
574   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
575   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
576   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
577   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
578   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
579   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
580   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
581   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
582   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
583   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
584   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
585   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
586   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
587   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
588   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
589   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
590   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
591   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
592   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
593   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
594   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
595   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
596   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
597   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
598   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
599   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
600   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
601   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
602   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
603   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
604   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
605   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
606   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
607   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
608   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
609   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
610   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
611   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
612   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
613   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
614   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
615   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
616   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
617   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
618   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
619   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
620   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
621   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
622   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
623   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
624   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
625   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
626   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
627   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
628   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
629   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
630 0x33,0x8e,0x6f,0x22,0xac,0x01,0x9f,0x7a,0xc7,0xca,0x23,0xc4,0xa4,0x9c,0x07,0xf8,
631 0x98,0xc1,0x17,0x4a,0xb2,0xbc,0xcc,0xf4,0x0e,0x2e,0xf6,0x35,0xdd,0xf6,0x29,0x9a,
632 0x2f,0x9c,0xe8,0x7c,0x86,0xf0,0x93,0xca,0x1a,0xee,0x10,0x08,0xec,0xe5,0x3a,0x98,
633 0x8c,0xd8,0x0d,0x39,0xaa,0x25,0x8d,0xcd,0x5d,0x64,0x7a,0x5f,0x35,0x92,0xb5,0x64,
634   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
635   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
636   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
637   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
638   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
639   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
640   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
641   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
642   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
643   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
644   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
645   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
646   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
647   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
648   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
649   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
650   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
651   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
652   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
653   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
654   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
655   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
656   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
657   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
658   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
659   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
660   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
661   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
662   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
663   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
664   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
665   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
666 0xdd,0xa9,0x15,0x18,0x9d,0x01,0x24,0x9c,0xed,0x7a,0xeb,0x42,0x8b,0x9e,0xf3,0x72,
667 0x26,0xc9,0x45,0x18,0xea,0xd2,0x54,0x5f,0xcf,0xed,0xac,0xbc,0xa1,0xd0,0x5f,0x2f,
668 0xce,0x15,0x2a,0xc6,0xf1,0xe0,0x69,0x62,0x22,0xc1,0xc0,0xbd,0xfa,0xdc,0x85,0xac,
669 0x67,0x47,0xee,0xa2,0x35,0xb3,0xff,0x76,0x57,0x4f,0x30,0x66,0xf8,0xe9,0xe0,0x5b,
670   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
671   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
672   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
673   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
674   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
675   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
676   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
677   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
678   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
679   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
680   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
681   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
682   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
683   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
684   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
685   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
686   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
687   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
688   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
689   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
690   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
691   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
692   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
693   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
694   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
695   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
696   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
697   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
698   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
699   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
700   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
701   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
702   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
703   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
704   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
705   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
706   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
707   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
708   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
709   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
710   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
711   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
712   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
713   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
714   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
715   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
716   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
717   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
718   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
719   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
720   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
721   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
722   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
723   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
724   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
725   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
726   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
727   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
728   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
729   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
730   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
731   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
732   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
733   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
734   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
735   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
736   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
737   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
738   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
739   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
740   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
741   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
742   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
743   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
744   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
745   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
746   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
747   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
748   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
749   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
750   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
751   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
752   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
753   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
754   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
755   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
756   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
757   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
758   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
759   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
760   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
761   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
762 0x0f,0x35,0xa3,0x7c,0xf1,0x75,0xea,0x27,0x36,0x4d,0x4b,0x1a,0x3b,0x24,0xef,0x9d,
763 0x4e,0x39,0x7e,0x7b,0x3d,0x42,0x0d,0xc2,0x9f,0x53,0xc7,0xc4,0xdf,0x02,0x5d,0x61,
764 0x0c,0xc9,0x2d,0x89,0x63,0xab,0x34,0xfc,0x97,0x1b,0xb5,0x54,0xe6,0x19,0xa5,0x46,
765 0xdc,0x9e,0xdc,0x25,0xe4,0x3a,0xfc,0xa7,0x93,0xfc,0x1f,0xec,0xb3,0x92,0x43,0xbc,
766   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
767   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
768   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
769   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
770   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
771   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
772   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
773   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
774   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
775   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
776   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
777   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
778   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
779   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
780   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
781   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
782   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
783   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
784   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
785   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
786 0x5d,0xdd,0xd4,0xbe,0xc0,0xff,0xe1,0x1b,0x3a,0xd6,0x61,0xc8,0x90,0x02,0x23,0x08,
787 0xfa,0x7a,0xfa,0x1d,0xab,0x2b,0xa0,0x0b,0x24,0xe1,0x6b,0x9e,0x38,0x6b,0xb2,0xae,
788 0xdd,0xfa,0xfc,0xa2,0xb8,0xcb,0xed,0x33,0x66,0x06,0xef,0x72,0x8b,0xe5,0xa3,0x0d,
789 0x9b,0x18,0x05,0xce,0x6a,0x69,0x61,0x64,0x74,0x9c,0xf9,0x66,0xec,0x99,0x72,0x95,
790   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
791   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
792   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
793   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
794   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
795   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
796   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
797   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
798   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
799   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
800   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
801   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
802   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
803   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
804   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
805   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
806   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
807   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
808   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
809   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
810   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
811   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
812   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
813   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
814   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
815   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
816   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
817   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
818 0x2c,0xf3,0x0d,0x50,0x30,0x77,0xc2,0x25,0x91,0x83,0x5f,0xac,0xf4,0x56,0x96,0xc8,
819 0x70,0x86,0x16,0x5a,0x1b,0xa1,0x7d,0x08,0x53,0x15,0xfd,0x3c,0xcb,0x4d,0xd0,0x70,
820 0x5c,0x1d,0x5c,0xaa,0x87,0x60,0x24,0x42,0xcc,0xe0,0x75,0xeb,0xae,0x75,0xcc,0xf1,
821 0x81,0x71,0x09,0xc0,0xf8,0x3c,0x55,0xa6,0x71,0x3c,0xd2,0xda,0xfe,0xf8,0x07,0xbc,
822 0x33,0x7c,0x08,0x5e,0xb1,0xff,0x68,0x44,0x75,0xc3,0xdf,0x68,0xdf,0x3d,0xba,0x81,
823 0x84,0x76,0x06,0x85,0xb4,0xb1,0x7a,0x6d,0xc9,0x4e,0x27,0x38,0x35,0xee,0xe1,0x32,
824 0x48,0xd8,0x6b,0x76,0xc4,0x9b,0x65,0xb2,0x22,0xf5,0xf6,0x2a,0xa1,0xf4,0x37,0x00,
825 0x12,0x5b,0x65,0xb2,0x65,0x47,0xc5,0xe4,0xf2,0x13,0x55,0x60,0x87,0x78,0x37,0x5b,
826   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
827   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
828   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
829   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
830   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
831   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
832   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
833   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
834   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
835   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
836   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
837   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
838   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
839   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
840   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
841   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
842   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
843   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
844   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
845   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
846   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
847   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
848   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
849   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
850 0xeb,0xd8,0xb6,0x33,0x90,0xbf,0x13,0x7f,0xd8,0x00,0xce,0xe0,0x48,0x79,0x78,0xd7,
851 0xd7,0x62,0xa3,0xe7,0x7b,0xe8,0xc9,0x54,0x71,0x18,0xff,0x2b,0x4f,0xff,0x5e,0x82,
852 0xca,0x10,0x2c,0x01,0x47,0xc5,0xcc,0xa2,0x22,0x89,0x6b,0xb4,0xc1,0xd6,0x66,0x26,
853 0x56,0x9b,0x7c,0x02,0x77,0xe0,0xb8,0x38,0x5f,0xac,0x1b,0x9d,0x00,0x27,0x0c,0x33,
854   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
855   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
856   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
857   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
858   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
859   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
860   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
861   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
862   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
863   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
864   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
865   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
866 0x65,0x19,0xf5,0x62,0x7a,0x92,0xc5,0x4a,0x55,0xcc,0x2f,0xf8,0x6c,0x79,0x34,0x3d,
867 0xa4,0x9e,0xd3,0xec,0xe4,0x3a,0xf9,0x99,0x5a,0x28,0x2a,0xa0,0x8a,0x46,0xef,0x69,
868 0x1b,0xd7,0xfd,0xeb,0x60,0x26,0x2a,0x6f,0xa7,0x6c,0x0f,0x97,0x44,0xf4,0x7d,0x9e,
869 0x5b,0x7d,0xa0,0xe1,0x70,0xe0,0xf3,0x9f,0xb0,0xf3,0xea,0xfd,0xfc,0xac,0x58,0x4d,
870 0xb8,0x8a,0xa5,0x8f,0x58,0x30,0xb0,0x38,0xa6,0x53,0x84,0x33,0xd4,0xd7,0xbd,0x26,
871 0x45,0x35,0xb7,0xf6,0x1a,0x20,0x7b,0x8d,0x7e,0x68,0x69,0xdb,0xb1,0x1e,0xa5,0x1a,
872 0xd5,0xf9,0x42,0x57,0x7a,0xf8,0x30,0x2e,0xea,0x49,0xe5,0xd5,0x34,0x6a,0xcd,0x5b,
873 0xfa,0x8e,0x71,0x32,0xfa,0x42,0x69,0xec,0x5d,0x50,0x02,0x42,0xc2,0xe4,0xae,0x5a,
874   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
875   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
876   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
877   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
878   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
879   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
880   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
881   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
882 0x9a,0x8e,0xcf,0x66,0xe0,0xd8,0xd4,0x2a,0x0f,0x4d,0xad,0x64,0x8c,0x6d,0xcb,0x37,
883 0x2e,0x0e,0x9f,0xc4,0xca,0xff,0x85,0xf1,0x7f,0xec,0x71,0x69,0xc2,0x81,0x5c,0xe4,
884 0x28,0xd2,0x6b,0xa9,0xf6,0xfb,0xe4,0x51,0x68,0x03,0xd0,0xcd,0xc3,0x07,0x6f,0xab,
885 0x1c,0x94,0x5f,0x94,0xe6,0x54,0x8b,0x1a,0x3c,0xed,0xd4,0xb0,0xf3,0x26,0x81,0xfa,
886   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
887   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
888   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
889   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
890   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
891   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
892   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
893   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
894   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
895   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
896   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
897   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
898   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
899   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
900   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
901   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
902   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
903   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
904   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
905   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
906   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
907   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
908   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
909   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
910   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
911   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
912   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
913   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
914   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
915   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
916   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
917   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
918   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
919   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
920   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
921   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
922   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
923   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
924   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
925   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
926   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
927   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
928   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
929   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
930   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
931   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
932   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
933   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
934   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
935   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
936   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
937   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
938   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
939   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
940   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
941   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
942   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
943   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
944   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
945   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
946   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
947   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
948   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
949   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
950   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
951   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
952   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
953   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
954   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
955   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
956   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
957   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
958   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
959   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
960   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
961   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
962   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
963   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
964   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
965   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
966   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
967   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
968   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
969   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
970   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
971   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
972   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
973   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
974   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
975   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
976   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
977   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
978   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
979   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
980   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
981   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
982   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
983   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
984   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
985   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
986   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
987   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
988   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
989   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
990   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
991   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
992   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
993   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
994   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
995   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
996   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
997   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
998   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
999   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1000   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1001   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1002   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1003   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1004   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1005   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1006   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1007   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1008   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1009   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1010   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1011   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1012   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1013   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1014   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1015   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1016   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1017   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1018   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1019   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1020   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1021   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1022   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1023   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1024   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1025   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1026   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1027   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1028   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1029   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1030   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1031   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1032   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1033   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1034   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1035   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1036   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1037   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1038   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1039   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1040   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1041   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1042   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1043   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1044   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1045   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1046   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1047   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1048   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1049   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1050   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1051   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1052   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1053   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1054   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1055   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1056   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1057   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1058   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1059   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1060   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1061   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1062   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1063   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1064   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1065   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1066   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1067   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1068   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1069   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1070   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1071   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1072   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1073   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1074   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1075   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1076   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1077   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1078   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1079   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1080   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1081   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1082   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1083   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1084   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1085   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1086   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1087   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1088   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1089   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1090   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1091   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1092   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1093   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1094   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1095   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1096   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1097   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1098   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1099   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1100   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1101   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1102   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1103   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1104   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1105   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1106   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1107   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1108   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1109   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1110   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1111   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1112   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1113   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1114   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1115   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1116   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1117   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1118   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1119   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1120   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1121   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1122   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1123   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1124   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1125   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1126   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1127   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1128   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1129   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1130   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1131   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1132   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1133   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1134   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1135   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1136   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1137   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1138   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1139   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1140   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1141   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
1142  };
1143 
1144 /* global so we can use them in the filename when we save out the data (debug..)*/
1145 static UINT8 calc3_decryption_key_byte;
1146 static UINT8 calc3_alternateswaps;
1147 static UINT8 calc3_shift;
1148 static UINT8 calc3_subtracttype;
1149 static UINT8 calc3_mode;
1150 static UINT8 calc3_blocksize_offset;
1151 static UINT16 calc3_dataend;
1152 static UINT16 calc3_database;
1153 
1154 static int data_header[2];
1155 
1156 static UINT32 calc3_writeaddress;
1157 static UINT32 calc3_writeaddress_current;
1158 static UINT16 calc3_dsw_addr = 0x00;
1159 static UINT16 calc3_eeprom_addr;
1160 static UINT16 calc3_poll_addr;
1161 static UINT16 cakc3_checkumaddress;
1162 
shift_bits(UINT8 dat,int bits)1163 static UINT8 shift_bits(UINT8 dat, int bits)
1164 {
1165 	bits &=0x7;
1166 
1167 	if (bits==0) return BITSWAP8(dat, 7,6,5,4,3,2,1,0);
1168 	if (bits==1) return BITSWAP8(dat, 6,5,4,3,2,1,0,7);
1169 	if (bits==2) return BITSWAP8(dat, 5,4,3,2,1,0,7,6);
1170 	if (bits==3) return BITSWAP8(dat, 4,3,2,1,0,7,6,5);
1171 	if (bits==4) return BITSWAP8(dat, 3,2,1,0,7,6,5,4);
1172 	if (bits==5) return BITSWAP8(dat, 2,1,0,7,6,5,4,3);
1173 	if (bits==6) return BITSWAP8(dat, 1,0,7,6,5,4,3,2);
1174 	if (bits==7) return BITSWAP8(dat, 0,7,6,5,4,3,2,1);
1175 
1176 	return dat;
1177 }
1178 
1179 
calc3_decompress_table(int tabnum,UINT8 * dstram,int dstoffset)1180 static int calc3_decompress_table(int tabnum, UINT8* dstram, int dstoffset)
1181 {
1182 	UINT8* rom = memory_region(REGION_CPU2);
1183 	UINT8 numregions;
1184 	UINT16 length;
1185 	int local_counter=0;
1186 	int x;
1187 	int offset = 0;
1188 
1189 	numregions = rom[offset+0];
1190 
1191 	if (tabnum > numregions)
1192 	{
1193 		log_cb(RETRO_LOG_DEBUG, LOGPRE "CALC3 error, requested table > num tables!\n");
1194 		return 0;
1195 	}
1196 
1197 	rom++;
1198 
1199 	/* scan through the linked list to find the start of the requested table info*/
1200 	for (x=0;x<tabnum;x++)
1201 	{
1202 		UINT8 blocksize_offset = rom[offset+0]; /* location of the 'block length'*/
1203 		offset+= blocksize_offset+1;
1204 		length = rom[offset+0] | (rom[offset+1]<<8);
1205 		offset+=length+2;
1206 	}
1207 
1208 	/* we're at the start of the block, get the info about it*/
1209 	{
1210 		UINT16 inline_table_base = 0;
1211 		UINT16 inline_table_size = 0;
1212 		calc3_database = offset;
1213 		calc3_blocksize_offset =    rom[offset+0]; /* location of the 'block length'*/
1214 		calc3_mode =                rom[offset+1];
1215 		calc3_alternateswaps =             rom[offset+2];
1216 		calc3_shift = (calc3_alternateswaps &0xf0)>>4;
1217 		calc3_subtracttype = (calc3_alternateswaps &0x03);
1218 		calc3_alternateswaps &= 0x0c;
1219 		calc3_alternateswaps >>=2;
1220 
1221 		calc3_decryption_key_byte = rom[offset+3];
1222 
1223 		/* if blocksize_offset > 3, it appears to specify the encryption table as 'inline' which can be of any size (odd or even) and loops over the bytes to decrypt*/
1224 		/* the decryption key specified seems to be ignored?*/
1225 		if (calc3_blocksize_offset>3)
1226 		{
1227 			inline_table_base = offset+4;
1228 			inline_table_size = calc3_blocksize_offset-3;
1229 		}
1230 
1231 		offset+= calc3_blocksize_offset+1;
1232 		length = rom[offset+0] | (rom[offset+1]<<8);
1233 		offset+=2;
1234 
1235 		/* copy + decrypt the table to the specified memory area*/
1236 		/*if (dstram)*/
1237 		{
1238 			int i;
1239 
1240 			if (length==0x00)
1241 			{
1242 				/* shogwarr does this with 'mode' as 0x08, which probably has some special meaning*/
1243 				/*printf("CALC3: requested 0 length table!\n");*/
1244 				/* -- seems to be 'reset stack' to default for the protection table writes*/
1245 
1246 				/* except this will break shogun going into game, must be specific conditions for*/
1247 				/* this, or it can remember addresses and restore those*/
1248 
1249 				/* hack, set it to a known address instead of trying to restore to anywhere specific..*/
1250 				/* might break at some point tho, eg if it doesn't write command 06 often enough because it trys to use another one like 07...*/
1251 				/* need to understand the meaning of this (test hw?)*/
1252 
1253 				/* !dstram is used because we don't want to process these during our initial table scan, only when the game asks!*/
1254 
1255 				if (calc3_mode==0x06)
1256 				{
1257 					calc3_writeaddress_current = 0x202000; /* this is reasoanble for brapboys, not sure about shogun, needs emulating properly!*/
1258 					/*calc3_writeaddress_current = 0x20c000;*/
1259 				}
1260 				else if (calc3_mode==0x07)
1261 				{
1262 					/* also calls empty table with Mode? 07*/
1263 					/* maybe they reset to different points?*/
1264 				}
1265 				else if (calc3_mode==0x08 && !dstram)
1266 				{
1267 					/*printf("save to eeprom\n");*/
1268 
1269 					{
1270 						UINT32 length;/*, size;*/
1271 						UINT8 *dat;
1272 
1273 						dat = (UINT8 *)EEPROM_get_data_pointer(&length);
1274 
1275 						for (i=0;i<0x80;i++)
1276 						{
1277 							dat[i] = cpu_readmem24bew(calc3_eeprom_addr+0x200000+i);
1278 						}
1279 
1280 					}
1281 
1282 				}
1283 				else if (!dstram)
1284 				{
1285 					/*printf("unknown blank table command\n");*/
1286 				}
1287 
1288 				return 0;
1289 			}
1290 
1291 			if (inline_table_size)
1292 			{
1293 			/* these should be derived from the inline table somehow, probably just a +/- swap like the normal stuff.. maybe*/
1294 				UINT8 extra[]  = { 0x14,0xf0,0xf8,0xd2,0xbe,0xfc,0xac,0x86,0x64,0x08,0x0c,0x74,0xd6,0x6a,0x24,0x12,0x1a,0x72,0xba,0x48,0x76,0x66,0x4a,0x7c,0x5c,0x82,0x0a,0x86,0x82,0x02,0xe6 };
1295 				UINT8 extra2[] = { 0x2f,0x04,0xd1,0x69,0xad,0xeb,0x10,0x95,0xb0,0x2f,0x0a,0x83,0x7d,0x4e,0x2a,0x07,0x89,0x52,0xca,0x41,0xf1,0x4f,0xaf,0x1c,0x01,0xe9,0x89,0xd2,0xaf,0xcd };
1296 
1297 				for (i=0;i<length;i++)
1298 				{
1299 					UINT8 dat=0;
1300 
1301 
1302 					/* special case for Shogun Warriors table 0x40 */
1303 					if (calc3_subtracttype==3 && calc3_alternateswaps ==0)
1304 					{
1305 						UINT8 inlinet = rom[inline_table_base + (i%inline_table_size)];
1306 						dat = rom[offset+i];
1307 
1308 						dat -= inlinet;
1309 
1310 						if (((i%inline_table_size)&1)==0)
1311 						{
1312 							dat -= extra[(i%inline_table_size)>>1];
1313 						}
1314 					}
1315 					else
1316 					{
1317 						if ( ((i / inline_table_size)&1)==0)
1318 						{
1319 							if (((i%inline_table_size)&1)==1)
1320 							{
1321 								UINT8 inlinet = rom[inline_table_base + (i%inline_table_size)];
1322 								dat = rom[offset+i];
1323 								dat -= inlinet;
1324 								dat = shift_bits(dat, calc3_shift);
1325 							}
1326 							else
1327 							{
1328 
1329 								UINT8 inlinet = rom[inline_table_base + (i%inline_table_size)];
1330 								dat = rom[offset+i];
1331 
1332 								if (calc3_subtracttype!=0x02)
1333 								{
1334 									dat -= inlinet;
1335 									dat -= extra[(i%inline_table_size)>>1];
1336 								}
1337 								else
1338 								{
1339 									dat += inlinet;
1340 									dat += extra[(i%inline_table_size)>>1];
1341 								}
1342 
1343 								dat = shift_bits(dat, 8-calc3_shift);
1344 							}
1345 						}
1346 						else
1347 						{
1348 							if (((i%inline_table_size)&1)==0)
1349 							{
1350 								UINT8 inlinet = rom[inline_table_base + (i%inline_table_size)];
1351 								dat = rom[offset+i];
1352 								dat -= inlinet;
1353 								dat = shift_bits(dat, calc3_shift);
1354 							}
1355 							else
1356 							{
1357 								dat = rom[offset+i];
1358 
1359 								if (calc3_subtracttype!=0x02)
1360 								{
1361 									dat -= extra2[(i%inline_table_size)>>1];
1362 								}
1363 								else
1364 								{
1365 									dat += extra2[(i%inline_table_size)>>1];
1366 								}
1367 								dat = shift_bits(dat, 8-calc3_shift);
1368 							}
1369 						}
1370 					}
1371 
1372 					if(local_counter>1)
1373 					{
1374 						/*if (space)*/
1375 						{
1376 							cpu_writemem24bew(dstoffset+i, dat);
1377 						}
1378 
1379 						/* debug, used to output tables at the start*/
1380 						if (dstram)
1381 						{
1382 							dstram[(dstoffset+i)^1] = dat;
1383 						}
1384 					}
1385 					else
1386 						data_header[local_counter]=dat;
1387 
1388 					++local_counter;
1389 				}
1390 			}
1391 			else
1392 			{
1393 				const INT16* key = calc3_keydata+(calc3_decryption_key_byte*0x40);
1394 
1395 				if (key[0] == -1)
1396 				{
1397 				/*	fatalerror("attempting to use invalid decryption data\n");*/
1398 				}
1399 
1400 				for (i=0;i<length;i++)
1401 				{
1402 					UINT8 dat = rom[offset+i];
1403 					UINT8 keydat = (UINT8)key[i&0x3f];
1404 
1405 					{
1406 						if (calc3_subtracttype==0)
1407 						{
1408 							/*dat = dat;*/
1409 						}
1410 						else if (calc3_subtracttype==1)
1411 						{
1412 							if ((i&1)==1) dat += keydat;
1413 							else dat -= keydat;
1414 						}
1415 						else if (calc3_subtracttype==2)
1416 						{
1417 							if ((i&1)==0) dat += keydat;
1418 							else dat -= keydat;
1419 						}
1420 						else if (calc3_subtracttype==3)
1421 						{
1422 							dat -= keydat;
1423 						}
1424 
1425 						if (calc3_alternateswaps == 0)
1426 						{
1427 							if ((i&1)==0) dat = shift_bits(dat, 8-calc3_shift);
1428 							else          dat = shift_bits(dat, calc3_shift);
1429 						}
1430 						else if (calc3_alternateswaps==1)
1431 						{
1432 							dat = shift_bits(dat, 8-calc3_shift);
1433 						}
1434 						else if (calc3_alternateswaps==2)
1435 						{
1436 							dat = shift_bits(dat, calc3_shift);
1437 						}
1438 						else if (calc3_alternateswaps==3)
1439 						{
1440 							/* same as 0*/
1441 							if ((i&1)==0) dat = shift_bits(dat, 8-calc3_shift);
1442 							else          dat = shift_bits(dat, calc3_shift);
1443 						}
1444 					}
1445 
1446 					if(local_counter>1)
1447 					{
1448 						/*if (space)*/
1449 						{
1450 							cpu_writemem24bew(dstoffset+i, dat);
1451 						}
1452 
1453 						/* debug, used to output tables at the start*/
1454 						if (dstram)
1455 						{
1456 							dstram[(dstoffset+i)^1] = dat;
1457 						}
1458 					}
1459 					else
1460 						data_header[local_counter]=dat;
1461 
1462 					++local_counter;
1463 				}
1464 			}
1465 		}
1466 
1467 		calc3_dataend = offset+length+1;
1468 	}
1469 
1470 	return length;
1471 
1472 }
1473 
calc3_scantables(void)1474 void calc3_scantables(void)
1475 {
1476 	UINT8* rom = memory_region(REGION_CPU2);
1477 	UINT8 numregions;
1478 
1479 	int x;
1480 
1481 	calc3_mcu_crc = 0;
1482 	for (x=0;x<0x20000;x++)
1483 	{
1484 		calc3_mcu_crc+=rom[x];
1485 	}
1486 
1487 	numregions = rom[0];
1488 
1489 	for (x=0;x<numregions;x++)
1490 	{
1491 		UINT8* tmpdstram = (UINT8*)malloc(0x2000);
1492 		int length;
1493 		memset(tmpdstram, 0x00,0x2000);
1494 		length = calc3_decompress_table(x, tmpdstram, 0);
1495 
1496 		free(tmpdstram);
1497 	}
1498 
1499 
1500 }
1501 
calc3_mcu_run(void)1502 void calc3_mcu_run(void)
1503 {
1504 	UINT16 mcu_command;
1505 	int i;
1506 
1507 	if ( calc3_mcu_status != (1|2|4|8) )	return;
1508 
1509 	if (calc3_dsw_addr) cpu_writemem24bew(calc3_dsw_addr+0x200000, ( ~readinputport(4))&0xff); /* */ /* DSW // dsw actually updates in realtime - mcu reads+writes it every frame*/
1510 
1511 
1512 	mcu_command = kaneko16_mcu_ram[calc3_mcu_command_offset/2 + 0];
1513 
1514 	if (mcu_command == 0) return;
1515 
1516 	if (mcu_command>0)
1517 	{
1518 		/* 0xff is a special 'init' command */
1519 		if (mcu_command == 0xff)
1520 		{
1521 
1522 			/* clear old command (handshake to main cpu)*/
1523 			kaneko16_mcu_ram[(calc3_mcu_command_offset>>1)+0] = 0x0000;
1524 
1525 			calc3_dsw_addr =           kaneko16_mcu_ram[(0>>1) + 1];
1526 			calc3_eeprom_addr =        kaneko16_mcu_ram[(0>>1) + 2];
1527 			calc3_mcu_command_offset = kaneko16_mcu_ram[(0>>1) + 3];
1528 			calc3_poll_addr =          kaneko16_mcu_ram[(0>>1) + 4];
1529 			cakc3_checkumaddress =     kaneko16_mcu_ram[(0>>1) + 5];
1530 			calc3_writeaddress =      (kaneko16_mcu_ram[(0>>1) + 6] << 16) |
1531 			                          (kaneko16_mcu_ram[(0>>1) + 7]);
1532 
1533 			/* set our current write / stack pointer to the address specified*/
1534 			calc3_writeaddress_current = calc3_writeaddress;
1535 
1536 			kaneko16_mcu_ram[cakc3_checkumaddress / 2] = calc3_mcu_crc;				/* MCU Rom Checksum!*/
1537 
1538 			{
1539 				UINT32 length;/*, size;*/
1540 				UINT8 *dat;
1541 
1542 				dat = (UINT8 *)EEPROM_get_data_pointer(&length);
1543 
1544 				for (i=0;i<0x80;i++)
1545 				{
1546 					cpu_writemem24bew(calc3_eeprom_addr+0x200000+i, dat[i]);
1547 				}
1548 
1549 			}
1550 
1551 		}
1552 		/* otherwise the command number is the number of transfer operations to perform */
1553 		else
1554 		{
1555 			int num_transfers = mcu_command;
1556 			int i;
1557 
1558 			/* clear old command (handshake to main cpu)*/
1559 			kaneko16_mcu_ram[calc3_mcu_command_offset>>1] = 0x0000;;
1560 
1561 			for (i=0;i<num_transfers;i++)
1562 			{
1563 				int param1 = kaneko16_mcu_ram[(calc3_mcu_command_offset>>1) + 1 + (2*i)];
1564 				int param2 = kaneko16_mcu_ram[(calc3_mcu_command_offset>>1) + 2 + (2*i)];
1565 				UINT8  commandtabl = (param1&0xff00) >> 8;
1566 				UINT16 commandaddr =param2;/* (param1&0x00ff) | (param2&0xff00);*/
1567 				UINT8  commandunk =  (param1&0x00ff); /* brap boys sets.. seems to cause further writebasck address displacement?? (when tested on hw it looked like a simple +, but that doesn't work for brapboys...)*/
1568 				{
1569 					int length;
1570 
1571 					length = calc3_decompress_table(commandtabl, 0, calc3_writeaddress_current-2);
1572 
1573 					if (length)
1574 					{
1575 						int write=commandaddr;
1576 
1577 					    cpu_writemem24bew(write+0x200000, data_header[0]);
1578 						cpu_writemem24bew(write+0x200001, data_header[1]);
1579 						write=commandaddr+(char)commandunk;
1580 						cpu_writemem24bew_word(write+0x200000, (calc3_writeaddress_current>>16)&0xffff);
1581 						cpu_writemem24bew_word(write+0x200002, (calc3_writeaddress_current&0xffff));
1582 
1583 						calc3_writeaddress_current += ((length+3)&(~1));
1584 					}
1585 
1586 				}
1587 			}
1588 		}
1589 	}
1590 }
1591 
1592 static struct {
1593 	UINT16 x1p, y1p, x1s, y1s;
1594 	UINT16 x2p, y2p, x2s, y2s;
1595 
1596 	INT16 x12, y12, x21, y21;
1597 
1598 	UINT16 mult_a, mult_b;
1599 } hit;
1600 
READ16_HANDLER(galpanib_calc_r)1601 READ16_HANDLER(galpanib_calc_r) /* Simulation of the CALC1 MCU */
1602 {
1603 	UINT16 data = 0;
1604 
1605 	switch (offset)
1606 	{
1607 		case 0x00/2: /* watchdog*/
1608 			return watchdog_reset_r(0);
1609 
1610 		case 0x02/2: /* unknown (yet!), used by *MANY* games !!!*/
1611 			/*popmessage("unknown collision reg");*/
1612 			break;
1613 
1614 		case 0x04/2: /* similar to the hit detection from SuperNova, but much simpler*/
1615 
1616 			/* X Absolute Collision*/
1617 			if      (hit.x1p >  hit.x2p)	data |= 0x0200;
1618 			else if (hit.x1p == hit.x2p)	data |= 0x0400;
1619 			else if (hit.x1p <  hit.x2p)	data |= 0x0800;
1620 
1621 			/* Y Absolute Collision*/
1622 			if      (hit.y1p >  hit.y2p)	data |= 0x2000;
1623 			else if (hit.y1p == hit.y2p)	data |= 0x4000;
1624 			else if (hit.y1p <  hit.y2p)	data |= 0x8000;
1625 
1626 			/* XY Overlap Collision*/
1627 			hit.x12 = (hit.x1p) - (hit.x2p + hit.x2s);
1628 			hit.y12 = (hit.y1p) - (hit.y2p + hit.y2s);
1629 			hit.x21 = (hit.x1p + hit.x1s) - (hit.x2p);
1630 			hit.y21 = (hit.y1p + hit.y1s) - (hit.y2p);
1631 
1632 			if ((hit.x12 < 0) && (hit.y12 < 0) &&
1633 				(hit.x21 >= 0) && (hit.y21 >= 0))
1634 					data |= 0x0001;
1635 
1636 			return data;
1637 
1638 		case 0x10/2:
1639 			return (((UINT32)hit.mult_a * (UINT32)hit.mult_b) >> 16);
1640 		case 0x12/2:
1641 			return (((UINT32)hit.mult_a * (UINT32)hit.mult_b) & 0xffff);
1642 
1643 		case 0x14/2:
1644 			return (mame_rand() & 0xffff);
1645 
1646 		default:
1647 			break;
1648 			/*/logerror("CPU #0 PC %06x: warning - read unmapped calc address %06x\n",cpu_get_pc(space->cpu),offset<<1);*/
1649 	}
1650 
1651 	return 0;
1652 }
1653 
WRITE16_HANDLER(galpanib_calc_w)1654 WRITE16_HANDLER(galpanib_calc_w)
1655 {
1656 	switch (offset)
1657 	{
1658 		/* p is position, s is size*/
1659 		case 0x00/2: hit.x1p    = data; break;
1660 		case 0x02/2: hit.x1s    = data; break;
1661 		case 0x04/2: hit.y1p    = data; break;
1662 		case 0x06/2: hit.y1s    = data; break;
1663 		case 0x08/2: hit.x2p    = data; break;
1664 		case 0x0a/2: hit.x2s    = data; break;
1665 		case 0x0c/2: hit.y2p    = data; break;
1666 		case 0x0e/2: hit.y2s    = data; break;
1667 		case 0x10/2: hit.mult_a = data; break;
1668 		case 0x12/2: hit.mult_b = data; break;
1669 
1670 		default:
1671 			break;/*logerror("CPU #0 PC %06x: warning - write unmapped hit address %06x\n",cpu_get_pc(space->cpu),offset<<1);*/
1672 	}
1673 }
1674 
1675 
1676 static const UINT16 bonkadv_mcu_43[] = {
1677 	0x8BE0,0x8E71,0x0102,0x0102,0x0300,0x010C,0x0202,0x0202,
1678 	0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
1679 	0x0030,0x0020,0x4F6B,0x0305,0x0000,0x0000,0x0000,0x0000,
1680 	0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
1681 	0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
1682 	0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
1683 	0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
1684 	0x0000,0x0000,0x0000,0x0082,0x6F82,0x628C,0xB490,0x6CAB
1685 };
1686 
1687 /* MCU executed command: 0400 0E00 0034 - code*/
1688 /*
1689 200E00: 7071    moveq   #$71, D0
1690 200E02: 7273    moveq   #$73, D1
1691 200E04: 7475    moveq   #$75, D2
1692 200E06: 7677    moveq   #$77, D3
1693 200E08: 7879    moveq   #$79, D4
1694 200E0A: 7A7B    moveq   #$7b, D5
1695 200E0C: 7C7D    moveq   #$7d, D6
1696 200E0E: 7E7F    moveq   #$7f, D7
1697 200E10: 4E75    rts
1698 */
1699 static const UINT16 bonkadv_mcu_4_34[] = {
1700 	0x7071,0x7273,0x7475,0x7677,0x7879,0x7a7b,0x7c7d,0x7e7f,
1701 	0x4e75
1702 };
1703 /* MCU executed command: 0400 0180 0032 - 128 bytes at $200180*/
1704 static const UINT16 bonkadv_mcu_4_32[] = {
1705 	0x00cc,0xcc0c,0xc0c0,0xc080,0x0484,0xb6a6,0x0404,0x80c0,
1706 	0x80b1,0xb1a1,0xa1b2,0xa2b3,0xb3a3,0xa3b1,0xb1b1,0xb1c0,
1707 	0xc0a1,0xa1a1,0xa1b2,0xb2a2,0xa290,0x9090,0xb9b9,0xa9a9,
1708 	0xbaaa,0xbbbb,0xabab,0xb9b9,0xb9b9,0xc8c8,0xa9a9,0xa9a9,
1709 	0xbaba,0xaaaa,0x9898,0x98b9,0xb9a9,0xa9ba,0xaabb,0xbbab,
1710 	0xabb9,0xb9b9,0xb9c8,0xc8a9,0xa9a9,0xa9ba,0xbaaa,0xaa98,
1711 	0x9898,0xb1b1,0xa1a1,0xb2a2,0xb3b3,0xa3a3,0xb1b1,0xb1b1,
1712 	0xc0c0,0xa1a1,0xa1a1,0xb2b2,0xa2a2,0x9090,0x9000,0x0000
1713 };
1714 /* MCU executed command: 0400 0280 0031 - 112 bytes at $200280*/
1715 static const UINT16 bonkadv_mcu_4_31[] = {
1716 	0x1013,0x1411,0x1216,0x1519,0x1a17,0x1824,0x2322,0x211f,
1717 	0x201e,0x1d1c,0x1b27,0x2825,0x2629,0x2a2b,0x2e2f,0x2c2d,
1718 	0x3130,0x3435,0x3233,0x3f3e,0x3d3c,0x3a3b,0x3938,0x3736,
1719 	0x4243,0x4041,0x4445,0x4649,0x4a47,0x484c,0x4b4f,0x504d,
1720 	0x4e5a,0x5958,0x5755,0x5654,0x5352,0x515d,0x5e5b,0x5c5f,
1721 	0x6061,0x6465,0x6263,0x6766,0x6a6b,0x6869,0x7574,0x7372,
1722 	0x7071,0x6f6e,0x6d6c,0x7879,0x7677,0x7a7b,0x7c7d,0x7e7f
1723 };
1724 /* MCU executed command: 0400 0E50 0030 - 655 bytes at $200E50 (656 here)*/
1725 static const UINT16 bonkadv_mcu_4_30[] = {
1726 	0x8c00,0x9700,0xa000,0xa700,0xb200,0xb700,0xc000,0xcc00,
1727 	0xd600,0xdf00,0xef00,0xf500,0xfd00,0x0501,0x0b01,0x1801,
1728 	0x1e01,0x2901,0x3101,0x3701,0x4101,0x4901,0x0b01,0x5d01,
1729 	0xa700,0xb200,0x6c01,0x8101,0xb200,0x8101,0x8101,0x8101,
1730 	0x8101,0x8101,0x8101,0x8101,0x8101,0x8101,0x8101,0x8101,
1731 	0x8101,0x8101,0x8101,0x8101,0x8101,0x8101,0x8101,0x8101,
1732 	0x8101,0x8101,0x8101,0x8101,0x8101,0x8101,0x8101,0x2e02,
1733 	0x3602,0x3d02,0x4102,0x4f02,0x5502,0x5502,0x5f02,0x6402,
1734 	0x6d02,0x7302,0x7802,0x7d02,0x8302,0x8a02,0x0165,0x712b,
1735 	0x57fe,0x57a2,0xff00,0x0003,0x7c3a,0x436c,0x66ff,0x0000,
1736 	0x026c,0x6d43,0xff00,0x0000,0x74a5,0x8373,0x3599,0x9fff,
1737 
1738 	0x0000,0x074a,0xff00,0x0002,0x8788,0x3331,0x32ff,0x0000,
1739 	0x0276,0x8c71,0x2d8c,0xfe12,0x8cff,0x0000,0x0171,0x0d29,
1740 	0xfe0d,0x29ff,0x0000,0x0559,0x5a5b,0x8a8b,0xff00,0x0003,
1741 	0x0d0e,0x576a,0x641e,0xfe0d,0x0efe,0x64a3,0xff00,0x0006,
1742 	0x0262,0xff00,0x0007,0x3e3f,0x7a7b,0xff00,0x0007,0x7584,
1743 	0x4c53,0xff00,0x0001,0x6645,0xff00,0x0007,0x0d18,0x2984,
1744 	0x5384,0xfe0d,0x29ff,0x0000,0x0457,0x5cff,0x0000,0x0751,
1745 	0x5202,0x45fe,0x4575,0xff00,0x0000,0x191a,0x1b6e,0xff00,
1746 	0x0006,0x3472,0xff00,0x0000,0x6569,0x090f,0x8b23,0xff00,
1747 	0x0004,0x3b3c,0x3d79,0xff00,0x0080,0x770a,0x8176,0x2a65,
1748 	0x64fe,0x7776,0xfe2a,0x76fe,0x650a,0xff00,0x0000,0x1011,
1749 	0x1226,0x2728,0xa655,0x940f,0x68ff,0x0000,0x8045,0x6477,
1750 	0x0a81,0x762a,0x65fe,0x7776,0xfe2a,0x76fe,0x650a,0xff00,
1751 	0x0000,0x166b,0xff00,0x0007,0x1e30,0x39ff,0x0000,0x0345,
1752 	0x3a77,0x7843,0x4647,0xff00,0x0000,0x7335,0x8399,0x9fff,
1753 	0x0000,0x0237,0x38ff,0x0000,0x0044,0x303b,0xff00,0x0000,
1754 
1755 	0x7d7e,0x7fa1,0x0aff,0x0000,0x0070,0xff00,0x0000,0x3e3f,
1756 	0x7a7b,0x6180,0x89a4,0xff00,0x0006,0x86a5,0x4f42,0xff00,
1757 	0x0000,0x1011,0x1255,0x0f68,0xff00,0x0002,0x8788,0x4033,
1758 	0xff00,0x0005,0x650f,0xff00,0x0008,0x9596,0x9ba7,0xff00,
1759 	0x0000,0x4849,0x82ff,0x0000,0x022e,0x2f30,0xff00,0x0001,
1760 	0x7778,0x5826,0x2728,0xa6ff,0x0000,0x0813,0x1402,0x51ff,
1761 	0x0000,0x072e,0x5c5d,0xff00,0x0006,0x57ff,0x0000,0x0230,
1762 	0x391e,0x65fe,0x6530,0xff00,0x0000,0x4bff,0x0000,0x008e,
1763 	0x8f90,0x91ff,0x0000,0x0092,0x9d17,0xff00,0x0000,0xff00,
1764 	0x0000,0x8d9b,0xa77d,0x7e7f,0xa10a,0x9596,0xff00,0x0001,
1765 	0x1993,0xff00,0x0000,0x67ff,0x0000,0x0067,0xff00,0x0000,
1766 	0x27ff,0x0000,0x0390,0x8e23,0x978b,0xff00,0x0000,0x1d9e,
1767 	0xff00,0x0007,0x3bff,0x0000,0x001d,0xff00,0x0000,0x8e90,
1768 	0xff00,0x0005,0x2495,0x96ff,0x0000,0x009a,0xff00,0x0000
1769 };
1770 /* MCU executed command: 0400 0400 0033 - 2560 bytes at $200400*/
1771 static const UINT16 bonkadv_mcu_4_33[] = {
1772 	0x00a4,0x0001,0x00a5,0x005a,0x00a6,0x0074,0x00a7,0x009b,
1773 	0x00a8,0x00d0,0x00a9,0x00fe,0x00aa,0x015d,0x00ab,0x01b0,
1774 	0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
1775 	0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
1776 	0x0001,0x0002,0x0019,0x005b,0x0022,0x0075,0x002d,0x009c,
1777 	0x0041,0x00d1,0x004e,0x00ff,0x0060,0x015f,0x0072,0x01b1,
1778 	0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
1779 	0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
1780 	0x0002,0x0008,0x001a,0x0061,0x0023,0x007b,0x002e,0x00a2,
1781 	0x0042,0x00d7,0x004f,0x0107,0x0061,0x0165,0x0073,0x01b7,
1782 	0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
1783 	0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
1784 	0x0000,0x000a,0x0000,0x0063,0x0000,0x007d,0x0000,0x00a4,
1785 	0x0000,0x00d9,0x0000,0x0109,0x0000,0x0167,0x0000,0x01b9,
1786 	0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
1787 	0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
1788 
1789 	0x0003,0x000b,0x001b,0x0064,0x0024,0x007e,0x002f,0x00a5,
1790 	0x0043,0x00da,0x0050,0x010a,0x0062,0x0168,0x0074,0x01ba,
1791 	0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
1792 	0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
1793 	0x0000,0x000c,0x0000,0x0065,0x0000,0x007f,0x0000,0x00a6,
1794 	0x0000,0x00db,0x0000,0x010b,0x0000,0x0169,0x0000,0x01bb,
1795 	0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
1796 	0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
1797 	0x0004,0x0008,0x001c,0x0061,0x0025,0x007b,0x0030,0x00a2,
1798 	0x0044,0x00d7,0x0051,0x0107,0x0063,0x0165,0x0075,0x01b7,
1799 	0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
1800 	0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
1801 	0x0005,0x000d,0x001d,0x0066,0x0025,0x007b,0x0031,0x00a7,
1802 	0x0045,0x00dc,0x0051,0x0107,0x0063,0x0165,0x0075,0x01b7,
1803 	0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
1804 	0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
1805 
1806 	0x0000,0x0017,0x0000,0x0069,0x0000,0x0089,0x0000,0x00af,
1807 	0x0000,0x00df,0x0000,0x0115,0x0000,0x0173,0x0000,0x01c5,
1808 	0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
1809 	0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
1810 	0x0009,0x0015,0x001e,0x0067,0x0029,0x0087,0x0034,0x00ad,
1811 	0x0046,0x00dd,0x0055,0x0113,0x0067,0x0171,0x0079,0x01c3,
1812 	0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
1813 	0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
1814 	0x0006,0x000e,0x0006,0x000e,0x0026,0x0080,0x0006,0x000e,
1815 	0x0000,0x0000,0x0052,0x010c,0x0064,0x016a,0x0076,0x01bc,
1816 	0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
1817 	0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
1818 	0x0007,0x0010,0x0007,0x0010,0x0027,0x0082,0x0032,0x00a8,
1819 	0x0000,0x0000,0x0053,0x010e,0x0065,0x016c,0x0077,0x01be,
1820 	0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
1821 	0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
1822 
1823 	0x0000,0x0013,0x0000,0x0013,0x0000,0x0085,0x0000,0x00ab,
1824 	0x0000,0x0000,0x0000,0x0111,0x0000,0x016f,0x0000,0x01c1,
1825 	0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
1826 	0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
1827 	0x0008,0x0014,0x0008,0x0014,0x0028,0x0086,0x0033,0x00ac,
1828 	0x0000,0x0000,0x0054,0x0112,0x0066,0x0170,0x0078,0x01c2,
1829 	0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
1830 	0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
1831 	0x0000,0x0018,0x0000,0x006a,0x0000,0x008a,0x0000,0x00b0,
1832 	0x0000,0x00e0,0x0000,0x0116,0x0000,0x0174,0x0000,0x01c6,
1833 	0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
1834 	0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
1835 	0x0000,0x000c,0x0000,0x0065,0x0000,0x007f,0x0000,0x00a6,
1836 	0x0000,0x00db,0x0000,0x010b,0x0000,0x0169,0x0000,0x01bb,
1837 	0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
1838 	0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
1839 
1840 	0x000a,0x0019,0x001f,0x006b,0x002a,0x008b,0x0035,0x00b1,
1841 	0x0047,0x00e1,0x0056,0x0117,0x0068,0x0175,0x007a,0x01c7,
1842 	0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
1843 	0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
1844 	0x000b,0x0019,0x0020,0x006b,0x002b,0x008b,0x0036,0x00b1,
1845 	0x0048,0x00e1,0x0057,0x0117,0x0069,0x0175,0x007a,0x01c7,
1846 	0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
1847 	0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
1848 	0x0015,0x003e,0x0015,0x003e,0x0099,0x0095,0x0015,0x003e,
1849 	0x0000,0x0000,0x009e,0x013a,0x006d,0x018f,0x007e,0x01dc,
1850 	0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
1851 	0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
1852 	0x000c,0x001d,0x000c,0x001d,0x000c,0x001d,0x000c,0x001d,
1853 	0x0049,0x00e5,0x0058,0x011b,0x006a,0x0179,0x007b,0x01c9,
1854 	0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
1855 	0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
1856 
1857 	0x0000,0x001f,0x0000,0x001f,0x0000,0x001f,0x0000,0x001f,
1858 	0x0000,0x00e7,0x0000,0x011d,0x0000,0x017b,0x0000,0x01cb,
1859 	0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
1860 	0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
1861 	0x000d,0x0020,0x0021,0x006f,0x002c,0x008f,0x0037,0x00b5,
1862 	0x004a,0x00e8,0x0059,0x011e,0x006b,0x017c,0x007c,0x01cc,
1863 	0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
1864 	0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
1865 	0x0000,0x0022,0x0000,0x0071,0x0000,0x0091,0x0000,0x00b7,
1866 	0x0000,0x00ea,0x0000,0x0120,0x0000,0x017e,0x0000,0x01ce,
1867 	0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
1868 	0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
1869 	0x0014,0x003b,0x0014,0x003b,0x005d,0x0092,0x0014,0x003b,
1870 	0x0014,0x003b,0x009d,0x0137,0x00a0,0x018c,0x00a1,0x01d9,
1871 	0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
1872 	0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
1873 
1874 	0x0012,0x0036,0x0012,0x0036,0x0012,0x0036,0x0012,0x0036,
1875 	0x008a,0x00e5,0x00be,0x013c,0x006c,0x0184,0x007d,0x01d1,
1876 	0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
1877 	0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
1878 	0x0013,0x0038,0x0013,0x0038,0x0013,0x0038,0x0013,0x0038,
1879 	0x008a,0x00e5,0x00bf,0x013d,0x006c,0x0184,0x007d,0x01d1,
1880 	0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
1881 	0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
1882 	0x0038,0x00ba,0x0038,0x00ba,0x0038,0x00ba,0x0038,0x00ba,
1883 	0x0038,0x00ba,0x00a2,0x0128,0x006e,0x019c,0x007f,0x01e7,
1884 	0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
1885 	0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
1886 	0x005c,0x014d,0x005c,0x014d,0x005c,0x014d,0x005c,0x014d,
1887 	0x0000,0x0000,0x009c,0x0124,0x0071,0x01a5,0x0082,0x01f0,
1888 	0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
1889 	0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
1890 
1891 	0x005b,0x014d,0x005b,0x014d,0x005b,0x014d,0x005b,0x014d,
1892 	0x0000,0x0000,0x009b,0x0124,0x0070,0x01a1,0x0081,0x01ec,
1893 	0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
1894 	0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
1895 	0x0000,0x0044,0x0000,0x0044,0x0000,0x0044,0x0000,0x0044,
1896 	0x0000,0x00db,0x0000,0x010b,0x0000,0x0169,0x0000,0x01bb,
1897 	0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
1898 	0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
1899 	0x0018,0x0045,0x0018,0x0045,0x0018,0x0045,0x0018,0x0045,
1900 	0x0044,0x00d7,0x0051,0x0107,0x0063,0x0165,0x0075,0x01b7,
1901 	0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
1902 	0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
1903 	0x008b,0x000e,0x008b,0x000e,0x008c,0x0080,0x008b,0x000e,
1904 	0x0000,0x0000,0x008d,0x010c,0x008e,0x016a,0x008f,0x01bc,
1905 	0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
1906 	0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
1907 
1908 	0x0090,0x0010,0x0090,0x0010,0x0091,0x0082,0x0092,0x00a8,
1909 	0x0000,0x0000,0x0093,0x010e,0x0094,0x016c,0x0095,0x01be,
1910 	0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
1911 	0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
1912 	0x0096,0x003e,0x0096,0x003e,0x009a,0x0095,0x0096,0x003e,
1913 	0x0000,0x0000,0x009f,0x013a,0x0097,0x018f,0x0098,0x01dc,
1914 	0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
1915 	0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
1916 	0x0000,0x0049,0x0000,0x0069,0x0000,0x0098,0x0000,0x00af,
1917 	0x0000,0x00df,0x0000,0x0145,0x0000,0x0173,0x0000,0x01c5,
1918 	0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
1919 	0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
1920 	0x005e,0x0048,0x005f,0x0068,0x006f,0x0097,0x0080,0x00ae,
1921 	0x00ac,0x00de,0x00ad,0x0144,0x00ae,0x0172,0x00af,0x01c4,
1922 	0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
1923 	0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
1924 
1925 	0x004b,0x00ed,0x004b,0x00ed,0x004b,0x00ed,0x004b,0x00ed,
1926 	0x004b,0x00ed,0x00b0,0x012b,0x00b6,0x0186,0x00ba,0x01d3,
1927 	0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
1928 	0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
1929 	0x0087,0x00f2,0x0087,0x00f2,0x0087,0x00f2,0x0087,0x00f2,
1930 	0x0087,0x00f2,0x00b3,0x0130,0x00b8,0x018b,0x00bc,0x01d8,
1931 	0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
1932 	0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
1933 	0x00c1,0x0050,0x00c1,0x0050,0x00c1,0x0050,0x00c1,0x0050,
1934 	0x00c1,0x0050,0x00c3,0x0148,0x00c5,0x019a,0x00c7,0x01e5,
1935 	0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
1936 	0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
1937 	0x00c2,0x0050,0x00c2,0x0050,0x00c2,0x0050,0x00c2,0x0050,
1938 	0x00c2,0x0050,0x00c4,0x0148,0x00c6,0x019a,0x00c8,0x01e5,
1939 	0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
1940 	0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000
1941 };
1942 
1943 static const UINT8 toybox_mcu_decryption_table[0x100] = {
1944 0x7b,0x82,0xf0,0xbc,0x7f,0x1d,0xa2,0xc5,0x2a,0xfa,0x55,0xee,0x1a,0xd0,0x59,0x76,
1945 0x5e,0x75,0x79,0x16,0xa5,0xf6,0x84,0xed,0x0f,0x2e,0xf2,0x36,0x61,0xac,0xcd,0xab,
1946 0x01,0x3b,0x01,0x87,0x73,0xab,0xce,0x5d,0xd4,0x1d,0x68,0x2a,0x35,0xea,0x13,0x27,
1947 0x00,0xaa,0x46,0x36,0x6e,0x65,0x80,0x7e,0x19,0xe2,0x96,0xab,0xac,0xa5,0x6c,0x63,
1948 0x4a,0x6f,0x87,0xf6,0x6a,0xac,0x38,0xe2,0x1f,0x87,0xf9,0xaa,0xf5,0x41,0x60,0xa6,
1949 0x42,0xb9,0x30,0xf2,0xc3,0x1c,0x4e,0x4b,0x08,0x10,0x42,0x32,0xbf,0xb2,0xc5,0x0f,
1950 0x7a,0xab,0x97,0xf6,0xe7,0xb3,0x46,0xf8,0xec,0x2b,0x7d,0x5f,0xb1,0x10,0x03,0xe4,
1951 0x0f,0x22,0xdf,0x8d,0x10,0x66,0xa7,0x7e,0x96,0xbd,0x5a,0xaf,0xaa,0x43,0xdf,0x10,
1952 0x7c,0x04,0xe2,0x9d,0x66,0xd7,0xf0,0x02,0x58,0x8a,0x55,0x17,0x16,0xe2,0xe2,0x52,
1953 0xaf,0xd9,0xf9,0x0d,0x59,0x70,0x86,0x3c,0x05,0xd1,0x52,0xa7,0xf0,0xbf,0x17,0xd0,
1954 0x23,0x15,0xfe,0x23,0xf2,0x80,0x60,0x6f,0x95,0x89,0x67,0x65,0xc9,0x0e,0xfc,0x16,
1955 0xd6,0x8a,0x9f,0x25,0x2c,0x0f,0x2d,0xe4,0x51,0xb2,0xa8,0x18,0x3a,0x5d,0x66,0xa0,
1956 0x9f,0xb0,0x58,0xea,0x78,0x72,0x08,0x6a,0x90,0xb6,0xa4,0xf5,0x08,0x19,0x60,0x4e,
1957 0x92,0xbd,0xf1,0x05,0x67,0x4f,0x24,0x99,0x69,0x1d,0x0c,0x6d,0xe7,0x74,0x88,0x22,
1958 0x2d,0x15,0x7a,0xa2,0x37,0xa9,0xa0,0xb0,0x2c,0xfb,0x27,0xe5,0x4f,0xb6,0xcd,0x75,
1959 0xdc,0x39,0xce,0x6f,0x1f,0xfe,0xcc,0xb5,0xe6,0xda,0xd8,0xee,0x85,0xee,0x2f,0x04,
1960 };
1961 
1962 static const UINT8 toybox_mcu_decryption_table_alt[0x100] = {
1963 0x26,0x17,0xb9,0xcf,0x1a,0xf5,0x14,0x1e,0x0c,0x35,0xb3,0x66,0xa0,0x17,0xe9,0xe4,
1964 0x90,0xf6,0xd5,0x35,0xac,0x95,0x49,0x43,0x64,0x0c,0x03,0x75,0x4d,0xda,0xb6,0xdf,
1965 0x06,0xcf,0x83,0x9e,0x35,0x2c,0x71,0x2a,0xab,0xcc,0x65,0xd4,0x1f,0xb0,0x88,0x3c,
1966 0xb7,0x87,0x35,0xc0,0x41,0x65,0x9f,0xa0,0xd5,0x8c,0x3e,0x06,0x53,0xdb,0x45,0x64,
1967 0x09,0x1e,0xc5,0x8d,0x50,0x24,0xe2,0x4a,0x9b,0x99,0x77,0x25,0x43,0xa9,0x1d,0xac,
1968 0x99,0x31,0x75,0xb5,0x53,0xab,0xad,0x5a,0x42,0x14,0xa1,0x52,0xac,0xec,0x5f,0xf8,
1969 0x8c,0x78,0x05,0x47,0xea,0xb8,0xde,0x69,0x98,0x2d,0x8f,0x9d,0xfc,0x05,0xea,0xee,
1970 0x77,0xbb,0xa9,0x31,0x01,0x00,0xea,0xd8,0x9c,0x43,0xb5,0x2f,0x4e,0xb5,0x1b,0xd2,
1971 0x01,0x4b,0xc4,0xf8,0x76,0x92,0x59,0x4f,0x20,0x52,0xd9,0x7f,0xa9,0x19,0xe9,0x7c,
1972 0x8d,0x3b,0xec,0xe0,0x60,0x08,0x2e,0xbd,0x27,0x8b,0xb2,0xfc,0x29,0xd8,0x39,0x8a,
1973 0x4f,0x2f,0x6b,0x04,0x10,0xbd,0xa1,0x04,0xde,0xc0,0xd5,0x0f,0x04,0x86,0xd6,0xd8,
1974 0xfd,0xb1,0x3c,0x4c,0xd1,0xc4,0xf1,0x5b,0xf5,0x8b,0xe3,0xc4,0x89,0x3c,0x39,0x86,
1975 0xd2,0x92,0xc9,0xe5,0x2c,0x4f,0xe2,0x2f,0x2d,0xc5,0x35,0x09,0x94,0x47,0x3c,0x04,
1976 0x40,0x8b,0x57,0x08,0xf6,0x74,0xe9,0xb8,0x36,0x4d,0xc5,0x26,0x13,0x3d,0x75,0xa0,
1977 0xa8,0x29,0x09,0x8c,0x87,0xf7,0x13,0xaf,0x4c,0x38,0x0b,0x8a,0x7f,0x2c,0x62,0x27,
1978 0x47,0xaa,0xda,0x07,0x92,0x8d,0xfd,0x1f,0xee,0x48,0x1a,0x53,0x3b,0x98,0x6a,0x72,
1979 };
1980 
1981 /* I use a byteswapped MCU data rom to make the transfers to the 68k side easier*/
1982 /*  not sure if it's all 100% endian safe*/
decrypt_toybox_rom(void)1983 void decrypt_toybox_rom(void)
1984 {
1985 
1986 	UINT8 *src = (UINT8 *)memory_region(REGION_CPU2);
1987 
1988 	int i;
1989 
1990 	for (i=0;i<0x020000;i++)
1991 	{
1992 		src[i] = src[i] + toybox_mcu_decryption_table[(i^1)&0xff];
1993 	}
1994 }
1995 
decrypt_toybox_rom_alt(void)1996 void decrypt_toybox_rom_alt(void)
1997 {
1998 	UINT8 *src = (UINT8 *)memory_region(REGION_CPU2);
1999 
2000 	int i;
2001 
2002 	for (i=0;i<0x020000;i++)
2003 	{
2004 		src[i] = src[i] + toybox_mcu_decryption_table_alt[(i^1)&0xff];
2005 	}
2006 }
2007 
toxboy_handle_04_subcommand(UINT8 mcu_subcmd,UINT16 * mcu_ram)2008 void toxboy_handle_04_subcommand(UINT8 mcu_subcmd, UINT16*mcu_ram)
2009 {
2010 	UINT8 *src = (UINT8 *)memory_region(REGION_CPU2)+0x10000;
2011 	UINT8* dst = (UINT8 *)mcu_ram;
2012 
2013 	int offs = (mcu_subcmd&0x3f)*8;
2014 	int x;
2015 
2016 	/*UINT16 unused = src[offs+0] | (src[offs+1]<<8);*/
2017 	UINT16 romstart = src[offs+2] | (src[offs+3]<<8);
2018 	UINT16 romlength = src[offs+4] | (src[offs+5]<<8);
2019 	UINT16 ramdest = mcu_ram[0x0012/2];
2020 	/*UINT16 extra = src[offs+6] | (src[offs+7]<<8); */ /* BONK .. important :-(*/
2021 
2022 	/*printf("romstart %04x length %04x\n",romstart,romlength);*/
2023 
2024 	for (x=0;x<romlength;x++)
2025 	{
2026 		dst[BYTE_XOR_LE(ramdest+x)] = src[(romstart+x)];
2027 	}
2028 }
2029 
2030 
2031 void (*toybox_mcu_run)(void);
2032 
2033 static UINT16 toybox_mcu_com[4];
2034 
toybox_mcu_init(void)2035 void toybox_mcu_init(void)
2036 {
2037 	memset(toybox_mcu_com, 0, 4 * sizeof( UINT16) );
2038 }
2039 
2040 #define TOYBOX_MCU_COM_W(_n_)							\
2041 WRITE16_HANDLER( toybox_mcu_com##_n_##_w )				\
2042 {														\
2043 	COMBINE_DATA(&toybox_mcu_com[_n_]);					\
2044 	if (toybox_mcu_com[0] != 0xFFFF)	return;			\
2045 	if (toybox_mcu_com[1] != 0xFFFF)	return;			\
2046 	if (toybox_mcu_com[2] != 0xFFFF)	return;			\
2047 	if (toybox_mcu_com[3] != 0xFFFF)	return;			\
2048 														\
2049 	memset(toybox_mcu_com, 0, 4 * sizeof( UINT16 ) );	\
2050 	toybox_mcu_run();							\
2051 }
2052 
2053 TOYBOX_MCU_COM_W(0)
2054 TOYBOX_MCU_COM_W(1)
2055 TOYBOX_MCU_COM_W(2)
2056 TOYBOX_MCU_COM_W(3)
2057 
2058 /*
2059     bonkadv and bloodwar test bit 0
2060 */
READ16_HANDLER(toybox_mcu_status_r)2061 READ16_HANDLER( toybox_mcu_status_r )
2062 {
2063 	return 0; /* most games test bit 0 for failure*/
2064 }
2065 
2066 #define MCU_RESPONSE(d) memcpy(&kaneko16_mcu_ram[mcu_offset], d, sizeof(d))
2067 
bonkadv_mcu_run(void)2068 void bonkadv_mcu_run(void)
2069 {
2070 	UINT16 mcu_command	=	kaneko16_mcu_ram[0x0010/2];
2071 	UINT16 mcu_offset	=	kaneko16_mcu_ram[0x0012/2] / 2;
2072 	UINT16 mcu_data		=	kaneko16_mcu_ram[0x0014/2];
2073 
2074 	switch (mcu_command >> 8)
2075 	{
2076 		case 0x02:	/* Read from NVRAM*/
2077 		{
2078 			mame_file *f;
2079 			if ((f = mame_fopen(Machine->gamedrv->name,0,FILETYPE_NVRAM,0)) != 0)
2080 			{
2081 				mame_fread(f,&kaneko16_mcu_ram[mcu_offset], 128);
2082 				mame_fclose(f);
2083 			}
2084 		}
2085 		break;
2086 
2087 		case 0x42:	/* Write to NVRAM*/
2088 		{
2089 			mame_file *f;
2090 			if ((f = mame_fopen(Machine->gamedrv->name,0,FILETYPE_NVRAM,1)) != 0)
2091 			{
2092 				mame_fwrite(f,&kaneko16_mcu_ram[mcu_offset], 128);
2093 				mame_fclose(f);
2094 			}
2095 		}
2096 		break;
2097 
2098 		case 0x43:	/* Initialize NVRAM - MCU writes Default Data Set directly to NVRAM*/
2099 		{
2100 			mame_file *f;
2101 			if ((f = mame_fopen(Machine->gamedrv->name,0,FILETYPE_NVRAM,1)) != 0)
2102 			{
2103 				mame_fwrite(f, bonkadv_mcu_43, sizeof(bonkadv_mcu_43));
2104 				mame_fclose(f);
2105 			}
2106 		}
2107 		break;
2108 
2109 		case 0x03:	/* DSW*/
2110 		{
2111 			kaneko16_mcu_ram[mcu_offset] = readinputport(4);
2112 		}
2113 		break;
2114 
2115 		case 0x04:	/* Protection*/
2116 		{
2117 			switch(mcu_data)
2118 			{
2119 				/* static, in this order, at boot/reset - these aren't understood, different params in Mcu data rom, data can't be found*/
2120 				case 0x34: MCU_RESPONSE(bonkadv_mcu_4_34); break;
2121 				case 0x30: MCU_RESPONSE(bonkadv_mcu_4_30); break;
2122 				case 0x31: MCU_RESPONSE(bonkadv_mcu_4_31); break;
2123 				case 0x32: MCU_RESPONSE(bonkadv_mcu_4_32); break;
2124 				case 0x33: MCU_RESPONSE(bonkadv_mcu_4_33); break;
2125 
2126 				/* dynamic, per-level (29), in level order*/
2127 				default:
2128 					toxboy_handle_04_subcommand(mcu_data, kaneko16_mcu_ram);
2129 					break;
2130 
2131 			}
2132 		}
2133 		break;
2134 
2135 		default:
2136 			/*logerror("%s : MCU executed command: %04X %04X %04X (UNKNOWN COMMAND)\n", cpuexec_describe_context(machine), mcu_command, mcu_offset*2, mcu_data);*/
2137 		break;
2138 	}
2139 }
2140 
bloodwar_mcu_run(void)2141 void bloodwar_mcu_run(void)
2142 {
2143 	UINT16 mcu_command	=	kaneko16_mcu_ram[0x0010/2];
2144 	UINT16 mcu_offset	=	kaneko16_mcu_ram[0x0012/2] / 2;
2145 	UINT16 mcu_data		=	kaneko16_mcu_ram[0x0014/2];
2146 
2147 	switch (mcu_command >> 8)
2148 	{
2149 		case 0x02:	/* Read from NVRAM*/
2150 		{
2151 			mame_file *f;
2152 			if ((f = mame_fopen(Machine->gamedrv->name,0,FILETYPE_NVRAM,0)) != 0)
2153 			{
2154 				mame_fread(f,&kaneko16_mcu_ram[mcu_offset], 128);
2155 				mame_fclose(f);
2156 			}
2157 		}
2158 		break;
2159 
2160 		case 0x42:	/* Write to NVRAM*/
2161 		{
2162 			mame_file *f;
2163 			if ((f = mame_fopen(Machine->gamedrv->name,0,FILETYPE_NVRAM,1)) != 0)
2164 			{
2165 				mame_fwrite(f,&kaneko16_mcu_ram[mcu_offset], 128);
2166 				mame_fclose(f);
2167 			}
2168 		}
2169 		break;
2170 
2171 		case 0x03:	/* DSW*/
2172 		{
2173 			kaneko16_mcu_ram[mcu_offset] = readinputport(4);
2174 		}
2175 		break;
2176 
2177 		case 0x04:	/* Protection*/
2178 		{
2179 			toxboy_handle_04_subcommand(mcu_data, kaneko16_mcu_ram);
2180 
2181 		}
2182 		break;
2183 
2184 		default:
2185 		break;
2186 	}
2187 }
2188 
2189 
2190 static struct {
2191 	int x1p, y1p, z1p, x1s, y1s, z1s;
2192 	int x2p, y2p, z2p, x2s, y2s, z2s;
2193 
2194 	int x1po, y1po, z1po, x1so, y1so, z1so;
2195 	int x2po, y2po, z2po, x2so, y2so, z2so;
2196 
2197 	int x12, y12, z12, x21, y21, z21;
2198 
2199 	int x_coll, y_coll, z_coll;
2200 
2201 	int x1tox2, y1toy2, z1toz2;
2202 
2203 	UINT16 mult_a, mult_b;
2204 
2205 	UINT16 flags;
2206 	UINT16 mode;
2207 
2208 } shogwarr_hit;
2209 
2210 
2211 /*calculate simple intersection of two segments*/
2212 
shogwarr_calc_compute(int x1,int w1,int x2,int w2)2213 static int shogwarr_calc_compute(int x1, int w1, int x2, int w2)
2214 {
2215 	int dist;
2216 
2217 	if(x2>=x1 && x2+w2<=(x1+w1))
2218 	{
2219 		/*x2 inside x1*/
2220 		dist=w2;
2221 	}
2222 	else
2223 	{
2224 		if(x1>=x2 && x1+w1<=(x2+w2))
2225 		{
2226 			/*x1 inside x2*/
2227 			dist=w1;
2228 		}
2229 		else
2230 		{
2231 			if(x2<x1)
2232 			{
2233 				/*swap*/
2234 				int tmp=x1;
2235 				x1=x2;
2236 				x2=tmp;
2237 				tmp=w1;
2238 				w1=w2;
2239 				w2=tmp;
2240 			}
2241 			dist=x1+w1-x2;
2242 		}
2243 	}
2244 	return dist;
2245 }
2246 
2247 /*calc segment coordinates*/
2248 
shogwarr_calc_org(int mode,int x0,int s0,int * x1,int * s1)2249 static void shogwarr_calc_org(int mode, int x0, int s0,  int* x1, int* s1)
2250 {
2251 	switch(mode)
2252 	{
2253 		case 0: *x1=x0; *s1=s0; break;
2254 		case 1: *x1=x0-s0/2; *s1=s0; break;
2255 		case 2: *x1=x0-s0; *s1=s0; break;
2256 		case 3:	*x1=x0-s0; *s1=2*s0; break;
2257 	}
2258 	/*x1 is the left most coord, s1 = width*/
2259 }
2260 
shogwarr_recalc_collisions(void)2261 static void shogwarr_recalc_collisions(void)
2262 {
2263 	/*calculate positions and sizes*/
2264 
2265 	int mode=shogwarr_hit.mode;
2266 
2267 	shogwarr_hit.flags=0;
2268 
2269 	shogwarr_calc_org(mode&3, shogwarr_hit.x1po, shogwarr_hit.x1so, &shogwarr_hit.x1p, &shogwarr_hit.x1s);
2270 	mode>>=2;
2271 	shogwarr_calc_org(mode&3, shogwarr_hit.y1po, shogwarr_hit.y1so, &shogwarr_hit.y1p, &shogwarr_hit.y1s);
2272 	mode>>=2;
2273 	shogwarr_calc_org(mode&3, shogwarr_hit.z1po, shogwarr_hit.z1so, &shogwarr_hit.z1p, &shogwarr_hit.z1s);
2274 
2275 	mode>>=4;
2276 
2277 	shogwarr_calc_org(mode&3, shogwarr_hit.x2po, shogwarr_hit.x2so, &shogwarr_hit.x2p, &shogwarr_hit.x2s);
2278 	mode>>=2;
2279 	shogwarr_calc_org(mode&3, shogwarr_hit.y2po, shogwarr_hit.y2so, &shogwarr_hit.y2p, &shogwarr_hit.y2s);
2280 	mode>>=2;
2281 	shogwarr_calc_org(mode&3, shogwarr_hit.z2po, shogwarr_hit.z2so, &shogwarr_hit.z2p, &shogwarr_hit.z2s);
2282 
2283 
2284 	shogwarr_hit.x1tox2=abs(shogwarr_hit.x2po-shogwarr_hit.x1po);
2285 	shogwarr_hit.y1toy2=abs(shogwarr_hit.y2po-shogwarr_hit.y1po);
2286 	shogwarr_hit.z1toz2=abs(shogwarr_hit.z2po-shogwarr_hit.z1po);
2287 
2288 
2289 	shogwarr_hit.x_coll = shogwarr_calc_compute(shogwarr_hit.x1p, shogwarr_hit.x1s, shogwarr_hit.x2p, shogwarr_hit.x2s);
2290 	shogwarr_hit.y_coll = shogwarr_calc_compute(shogwarr_hit.y1p, shogwarr_hit.y1s, shogwarr_hit.y2p, shogwarr_hit.y2s);
2291 	shogwarr_hit.z_coll = shogwarr_calc_compute(shogwarr_hit.z1p, shogwarr_hit.z1s, shogwarr_hit.z2p, shogwarr_hit.z2s);
2292 
2293 
2294 	/* 4th nibble: Y Absolute Collision -> possible values = 9,8,4,3,2*/
2295 	if      (shogwarr_hit.y1p >  shogwarr_hit.y2p)	shogwarr_hit.flags |= 0x2000;
2296 	else if (shogwarr_hit.y1p == shogwarr_hit.y2p)	shogwarr_hit.flags |= 0x4000;
2297 	else if (shogwarr_hit.y1p <  shogwarr_hit.y2p)	shogwarr_hit.flags |= 0x8000;
2298 	if (shogwarr_hit.y_coll<0) shogwarr_hit.flags |= 0x1000;
2299 
2300 	/* 3rd nibble: X Absolute Collision -> possible values = 9,8,4,3,2*/
2301 	if      (shogwarr_hit.x1p >  shogwarr_hit.x2p)	shogwarr_hit.flags |= 0x0200;
2302 	else if (shogwarr_hit.x1p == shogwarr_hit.x2p)	shogwarr_hit.flags |= 0x0400;
2303 	else if (shogwarr_hit.x1p <  shogwarr_hit.x2p)	shogwarr_hit.flags |= 0x0800;
2304 	if (shogwarr_hit.x_coll<0) shogwarr_hit.flags |= 0x0100;
2305 
2306 	/* 2nd nibble: Z Absolute Collision -> possible values = 9,8,4,3,2*/
2307 	if      (shogwarr_hit.z1p >  shogwarr_hit.z2p)	shogwarr_hit.flags |= 0x0020;
2308 	else if (shogwarr_hit.z1p == shogwarr_hit.z2p)	shogwarr_hit.flags |= 0x0040;
2309 	else if (shogwarr_hit.z1p <  shogwarr_hit.z2p)	shogwarr_hit.flags |= 0x0080;
2310 	if (shogwarr_hit.z_coll<0) shogwarr_hit.flags |= 0x0010;
2311 
2312 	/* 1st nibble: XYZ Overlap Collision*/
2313 	if ((shogwarr_hit.x_coll>=0)&&(shogwarr_hit.y_coll>=0)&&(shogwarr_hit.z_coll>=0)) shogwarr_hit.flags |= 0x0008;
2314 	if ((shogwarr_hit.x_coll>=0)&&(shogwarr_hit.z_coll>=0)) shogwarr_hit.flags |= 0x0004;
2315 	if ((shogwarr_hit.y_coll>=0)&&(shogwarr_hit.z_coll>=0)) shogwarr_hit.flags |= 0x0002;
2316 	if ((shogwarr_hit.x_coll>=0)&&(shogwarr_hit.y_coll>=0)) shogwarr_hit.flags |= 0x0001;
2317 }
2318 
2319 
WRITE16_HANDLER(shogwarr_calc_w)2320 static WRITE16_HANDLER(shogwarr_calc_w)
2321 {
2322 	int idx=offset*4;
2323 	switch (idx)
2324 	{
2325 		/* p is position, s is size*/
2326 		case 0x00:
2327 		case 0x28:
2328 
2329 					shogwarr_hit.x1po = data; break;
2330 
2331 		case 0x04:
2332 		case 0x2c:
2333 					shogwarr_hit.x1so = data; break;
2334 
2335 		case 0x08:
2336 		case 0x30:
2337 					shogwarr_hit.y1po = data; break;
2338 
2339 		case 0x0c:
2340 		case 0x34:
2341 					shogwarr_hit.y1so = data; break;
2342 
2343 		case 0x10:
2344 		case 0x58:
2345 					shogwarr_hit.x2po = data; break;
2346 
2347 		case 0x14:
2348 		case 0x5c:
2349 					shogwarr_hit.x2so = data; break;
2350 
2351 		case 0x18:
2352 		case 0x60:
2353 					shogwarr_hit.y2po = data; break;
2354 
2355 		case 0x1c:
2356 		case 0x64:
2357 					shogwarr_hit.y2so = data; break;
2358 
2359 		case 0x38:
2360 		case 0x50:
2361 					shogwarr_hit.z1po = data; break;
2362 		case 0x3c:
2363 		case 0x54:
2364 					shogwarr_hit.z1so = data; break;
2365 
2366 		case 0x20:
2367 		case 0x68:
2368 					shogwarr_hit.z2po = data; break;
2369 
2370 		case 0x24:
2371 		case 0x6c:
2372 					shogwarr_hit.z2so = data; break;
2373 
2374 		case 0x70:
2375 					shogwarr_hit.mode=data;break;
2376 
2377 		default:
2378 			break;/*logerror("CPU #0 PC %06x: warning - write unmapped hit address %06x [ %06x] = %06x\n",cpu_get_pc(space->cpu),offset<<1, idx, data);*/
2379 	}
2380 
2381 	shogwarr_recalc_collisions();
2382 }
2383 
2384 
READ16_HANDLER(shogwarr_calc_r)2385 static READ16_HANDLER(shogwarr_calc_r)
2386 {
2387 
2388 	int idx=offset*4;
2389 
2390 	switch (idx)
2391 	{
2392 		case 0x00: /* X distance*/
2393 		case 0x10:
2394 			return shogwarr_hit.x_coll;
2395 
2396 		case 0x04: /* Y distance*/
2397 		case 0x14:
2398 			return shogwarr_hit.y_coll;
2399 
2400 		case 0x18: /* Z distance*/
2401 			return shogwarr_hit.z_coll;
2402 
2403 		case 0x08:
2404 		case 0x1c:
2405 
2406 			return shogwarr_hit.flags;
2407 
2408 		case 0x28:
2409 			return (mame_rand() & 0xffff);
2410 
2411 		case 0x40: return shogwarr_hit.x1po;
2412 		case 0x44: return shogwarr_hit.x1so;
2413 		case 0x48: return shogwarr_hit.y1po;
2414 		case 0x4c: return shogwarr_hit.y1so;
2415 		case 0x50: return shogwarr_hit.z1po;
2416 		case 0x54: return shogwarr_hit.z1so;
2417 
2418 		case 0x58: return shogwarr_hit.x2po;
2419 		case 0x5c: return shogwarr_hit.x2so;
2420 		case 0x60: return shogwarr_hit.y2po;
2421 		case 0x64: return shogwarr_hit.y2so;
2422 		case 0x68: return shogwarr_hit.z2po;
2423 		case 0x6c: return shogwarr_hit.z2so;
2424 
2425 		case 0x80: return shogwarr_hit.x1tox2;
2426 		case 0x84: return shogwarr_hit.y1toy2;
2427 		case 0x88: return shogwarr_hit.z1toz2;
2428 
2429 		default:
2430 			break;/*logerror("CPU #0 PC %06x: warning - read unmapped calc address %06x [ %06x]\n",cpu_get_pc(space->cpu),offset<<1, idx);*/
2431 	}
2432 
2433 	return 0;
2434 }
2435 
WRITE16_HANDLER(bloodwar_calc_w)2436 WRITE16_HANDLER(bloodwar_calc_w)
2437 {
2438 
2439 	int isbrap = ( !strcmp(Machine->gamedrv->name,"brapboysj") || !strcmp(Machine->gamedrv->name,"brapboys"));
2440 
2441 	/* our implementation is incomplete, b.rap boys requires some modifications */
2442 	if (isbrap)
2443 	{
2444 		shogwarr_calc_w(offset,data,mem_mask);
2445 		return;
2446 	}
2447 
2448 	switch (offset)
2449 	{
2450 		/* p is position, s is size*/
2451 		case 0x20/2: hit.x1p = data; break;
2452 		case 0x22/2: hit.x1s = data; break;
2453 		case 0x24/2: hit.y1p = data; break;
2454 		case 0x26/2: hit.y1s = data; break;
2455 
2456 		case 0x2c/2: hit.x2p = data; break;
2457 		case 0x2e/2: hit.x2s = data; break;
2458 		case 0x30/2: hit.y2p = data; break;
2459 		case 0x32/2: hit.y2s = data; break;
2460 
2461 		/* this register is set to zero before any computation,*/
2462 		/* but it has no effect on inputs or result registers*/
2463 		case 0x38/2: break;
2464 
2465 		default:
2466 			break;/*logerror("CPU #0 PC %06x: warning - write unmapped hit address %06x\n",cpu_get_pc(space->cpu),offset<<1);*/
2467 	}
2468 }
2469 
2470 /*
2471  collision detection: absolute "distance", negative if no overlap
2472          [one inside other] | [ normal overlap ] | [   no overlap   ]
2473   rect1   <-------------->  |  <----------->     |  <--->
2474   rect2       <----->       |     <----------->  |             <--->
2475   result      <---------->  |     <-------->     |       <---->
2476 */
2477 
calc_compute_x(void)2478 static INT16 calc_compute_x(void)
2479 {
2480 	INT16 x_coll;
2481 
2482 	/* X distance*/
2483 	if ((hit.x2p >= hit.x1p) && (hit.x2p < (hit.x1p + hit.x1s)))		/* x2p inside x1*/
2484 		x_coll = (hit.x1s - (hit.x2p - hit.x1p));
2485 	else if ((hit.x1p >= hit.x2p) && (hit.x1p < (hit.x2p + hit.x2s)))	/* x1p inside x2*/
2486 		x_coll = (hit.x2s - (hit.x1p - hit.x2p));
2487 	else																/* normal/no overlap*/
2488 	 	x_coll = ((hit.x1s + hit.x2s)/2) - abs((hit.x1p + hit.x1s/2) - (hit.x2p + hit.x2s/2));
2489 
2490 	return x_coll;
2491 }
2492 
calc_compute_y(void)2493 static INT16 calc_compute_y(void)
2494 {
2495 	INT16 y_coll;
2496 
2497 	/* Y distance*/
2498 	if ((hit.y2p >= hit.y1p) && (hit.y2p < (hit.y1p + hit.y1s)))		/* y2p inside y1*/
2499 		y_coll = (hit.y1s - (hit.y2p - hit.y1p));
2500 	else if ((hit.y1p >= hit.y2p) && (hit.y1p < (hit.y2p + hit.y2s)))	/* y1p inside y2*/
2501 		y_coll = (hit.y2s - (hit.y1p - hit.y2p));
2502 	else																/* normal/no overlap*/
2503 		y_coll = ((hit.y1s + hit.y2s)/2) - abs((hit.y1p + hit.y1s/2) - (hit.y2p + hit.y2s/2));
2504 
2505 	return y_coll;
2506 }
2507 
READ16_HANDLER(bloodwar_calc_r)2508 READ16_HANDLER(bloodwar_calc_r)
2509 {
2510 	UINT16 data = 0;
2511 	INT16 x_coll, y_coll;
2512 
2513 	/* our implementation is incomplete, b.rap boys requires some modifications */
2514 	int isbrap = ( !strcmp(Machine->gamedrv->name,"brapboysj") || !strcmp(Machine->gamedrv->name,"brapboys"));
2515 
2516 	if (isbrap)
2517 	{
2518 		return shogwarr_calc_r(offset,mem_mask);
2519 	}
2520 
2521 	x_coll = calc_compute_x();
2522 	y_coll = calc_compute_y();
2523 
2524 	switch (offset)
2525 	{
2526 		case 0x00/2: /* X distance*/
2527 			return x_coll;
2528 
2529 		case 0x02/2: /* Y distance*/
2530 			return y_coll;
2531 
2532 		case 0x04/2: /* similar to the hit detection from SuperNova, but much simpler*/
2533 
2534 			/* 4th nibble: Y Absolute Collision -> possible values = 9,8,4,3,2*/
2535 			if      (hit.y1p >  hit.y2p)	data |= 0x2000;
2536 			else if (hit.y1p == hit.y2p)	data |= 0x4000;
2537 			else if (hit.y1p <  hit.y2p)	data |= 0x8000;
2538 			if (y_coll<0) data |= 0x1000;
2539 
2540 			/* 3rd nibble: X Absolute Collision -> possible values = 9,8,4,3,2*/
2541 			if      (hit.x1p >  hit.x2p)	data |= 0x0200;
2542 			else if (hit.x1p == hit.x2p)	data |= 0x0400;
2543 			else if (hit.x1p <  hit.x2p)	data |= 0x0800;
2544 			if (x_coll<0) data |= 0x0100;
2545 
2546 			/* 2nd nibble: always set to 4*/
2547 			data |= 0x0040;
2548 
2549 			/* 1st nibble: XY Overlap Collision -> possible values = 0,2,4,f*/
2550 			if (x_coll>=0) data |= 0x0004;
2551 			if (y_coll>=0) data |= 0x0002;
2552 			if ((x_coll>=0)&&(y_coll>=0)) data |= 0x000F;
2553 
2554 			return data;
2555 
2556 		case 0x14/2:
2557 			return (mame_rand() & 0xffff);
2558 
2559 		case 0x20/2: return hit.x1p;
2560 		case 0x22/2: return hit.x1s;
2561 		case 0x24/2: return hit.y1p;
2562 		case 0x26/2: return hit.y1s;
2563 
2564 		case 0x2c/2: return hit.x2p;
2565 		case 0x2e/2: return hit.x2s;
2566 		case 0x30/2: return hit.y2p;
2567 		case 0x32/2: return hit.y2s;
2568 
2569 		default:
2570 			break; /*logerror("CPU #0 PC %06x: warning - read unmapped calc address %06x\n",cpu_get_pc(space->cpu),offset<<1);*/
2571 	}
2572 
2573 	return 0;
2574 }
2575 
2576 
2577 /***************************************************************************
2578 
2579 
2580 							Machine Initialisation
2581 
2582 
2583 ***************************************************************************/
2584 
MACHINE_INIT(kaneko16)2585 MACHINE_INIT( kaneko16 )
2586 {
2587 	kaneko16_sprite_fliptype = 0;
2588 	kaneko16_sprite_type  = 0;
2589 
2590 	kaneko16_sprite_xoffs = 0;
2591 	kaneko16_sprite_yoffs = 0;
2592 
2593 /*
2594 	Sx = Sprites with priority x, x = tiles with priority x,
2595 	Sprites - Tiles Order (bottom -> top):
2596 
2597 	0	S0	1	2	3
2598 	0	1	S1	2	3
2599 	0	1	2	S2	3
2600 	0	1	2	3	S3
2601 */
2602 
2603 	kaneko16_priority.tile[0] = 0;
2604 	kaneko16_priority.tile[1] = 1;
2605 	kaneko16_priority.tile[2] = 2;
2606 	kaneko16_priority.tile[3] = 3;
2607 
2608 	kaneko16_priority.sprite[0] = 0xfffc;	/* above tile[0],   below the others*/
2609 	kaneko16_priority.sprite[1] = 0xfff0;	/* above tile[0-1], below the others*/
2610 	kaneko16_priority.sprite[2] = 0xff00;	/* above tile[0-2], below the others*/
2611 	kaneko16_priority.sprite[3] = 0x0000;	/* above all*/
2612 }
2613 
MACHINE_INIT(berlwall)2614 static MACHINE_INIT( berlwall )
2615 {
2616 	machine_init_kaneko16();
2617 
2618 	kaneko16_sprite_type = 2;	/* like type 0, but using 16 instead of 8 bytes*/
2619 }
2620 
MACHINE_INIT(blazeon)2621 static MACHINE_INIT( blazeon )
2622 {
2623 	machine_init_kaneko16();
2624 
2625 	kaneko16_sprite_xoffs = 0x10000 - 0x680;
2626 	kaneko16_sprite_yoffs = 0x000;
2627 
2628 /*
2629 	Sx = Sprites with priority x, x = tiles with priority x,
2630 	Sprites - Tiles Order (bottom -> top):
2631 
2632 	0	S0	1	2	3
2633 	0	1	S1	2	3
2634 	0	1	2	3	S2
2635 	0	1	2	3	S3
2636 */
2637 	kaneko16_priority.sprite[0] = 0xfffc;	/* above tile[0], below the others*/
2638 	kaneko16_priority.sprite[1] = 0xfff0;	/* above tile[0-1], below the others*/
2639 	kaneko16_priority.sprite[2] = 0x0000;	/* above all*/
2640 	kaneko16_priority.sprite[3] = 0x0000;	/* ""*/
2641 }
2642 
MACHINE_INIT(bakubrkr)2643 static MACHINE_INIT( bakubrkr )
2644 {
2645 	machine_init_kaneko16();
2646 
2647 	kaneko16_priority.tile[0] = 0;
2648 	kaneko16_priority.tile[1] = 1;
2649 	kaneko16_priority.tile[2] = 2;
2650 	kaneko16_priority.tile[3] = 3;
2651 
2652 	kaneko16_priority.sprite[0] = 0x0000;	/* above all*/
2653 	kaneko16_priority.sprite[1] = 0x0000;	/* above all*/
2654 	kaneko16_priority.sprite[2] = 0x0000;	/* above all*/
2655 	kaneko16_priority.sprite[3] = 0x0000;	/* above all*/
2656 }
2657 
MACHINE_INIT(gtmr)2658 static MACHINE_INIT( gtmr )
2659 {
2660 	machine_init_kaneko16();
2661 
2662 	kaneko16_sprite_type = 1;
2663 
2664 	memset(gtmr_mcu_com, 0, 4 * sizeof( data16_t) );
2665 }
2666 
MACHINE_INIT(mgcrystl)2667 static MACHINE_INIT( mgcrystl )
2668 {
2669 	machine_init_kaneko16();
2670 /*
2671 	Sx = Sprites with priority x, x = tiles with priority x,
2672 	Sprites - Tiles Order:
2673 
2674 	S0:	below 0 2
2675 
2676 	S1:	over  2
2677 		below 0
2678 
2679 	S2:	over 0 2
2680 
2681 	S3:	over all
2682 
2683 	tiles of the 2nd VIEW2 chip always behind sprites?
2684 
2685 */
2686 	kaneko16_priority.tile[0] = 2;	/* priorty mask = 1*/
2687 	kaneko16_priority.tile[1] = 0;	/* priorty mask = 2*/
2688 	kaneko16_priority.tile[2] = 3;	/* priorty mask = 4*/
2689 	kaneko16_priority.tile[3] = 1;	/* priorty mask = 8*/
2690 
2691 	kaneko16_priority.sprite[0] = 0xfffe;	/* below all*/
2692 	kaneko16_priority.sprite[1] = 0xfffc;	/* above tile[0], below the others*/
2693 	kaneko16_priority.sprite[2] = 0x0000;	/* above all*/
2694 	kaneko16_priority.sprite[3] = 0x0000;	/* ""*/
2695 }
2696 
MACHINE_INIT(sandscrp)2697 static MACHINE_INIT( sandscrp )
2698 {
2699 	machine_init_kaneko16();
2700 
2701 	kaneko16_sprite_xoffs = 0;
2702 	kaneko16_sprite_yoffs = 0;
2703 	kaneko16_sprite_type = 3;	/* Should be using Kaneko Pandora draw*/
2704 
2705 	kaneko16_priority.sprite[0] = 0xfffc;	/* above tile[0],   below the others*/
2706 	kaneko16_priority.sprite[1] = 0xfff0;	/* above tile[0-1], below the others*/
2707 	kaneko16_priority.sprite[2] = 0xff00;	/* above tile[0-2], below the others*/
2708 	kaneko16_priority.sprite[3] = 0x0000;	/* above all*/
2709 
2710 
2711 	watchdog_reset16_r(0,0);	/* start with an armed watchdog*/
2712 }
2713 
MACHINE_INIT(shogwarr)2714 static MACHINE_INIT( shogwarr )
2715 {
2716 	machine_init_kaneko16();
2717 
2718 	kaneko16_sprite_xoffs = 0xa00;
2719 
2720 	kaneko16_sprite_yoffs = -0x40;
2721 
2722 	kaneko16_sprite_type = 0;
2723 	kaneko16_sprite_fliptype = 1;
2724 
2725 	shogwarr_mcu_status = 0;
2726 	shogwarr_mcu_command_offset = 0;
2727 
2728 	kaneko16_priority.sprite[0] = 0xfffe;	/* below all*/
2729 	kaneko16_priority.sprite[1] = 0xffc0;	/* above tile[0], below the others*/
2730 	kaneko16_priority.sprite[2] = 0x0000;	/* above all*/
2731 	kaneko16_priority.sprite[3] = 0x0000;	/* above all*/
2732 
2733 	kaneko16_priority.VIEW2_2_pri = 0;
2734 
2735 	calc3_mcu_init();
2736 	calc3_scantables();
2737 }
2738 
MACHINE_INIT(brapboys)2739 static MACHINE_INIT( brapboys )
2740 {
2741 	machine_init_kaneko16();
2742 
2743 	kaneko16_sprite_xoffs = 0xa00;
2744 
2745 	kaneko16_sprite_yoffs = -0x40;
2746 
2747 	kaneko16_sprite_type = 0;
2748 	kaneko16_sprite_fliptype = 1;
2749 
2750 	shogwarr_mcu_status = 0;
2751 	shogwarr_mcu_command_offset = 0;
2752 
2753 	kaneko16_priority.sprite[0] = 0xfffc;	/* below all*/
2754 	kaneko16_priority.sprite[1] = 0xfff0;	/* above tile[0], below the others*/
2755 	kaneko16_priority.sprite[2] = 0x0000;	/* above all*/
2756 	kaneko16_priority.sprite[3] = 0x0000;	/* above all*/
2757 
2758 	kaneko16_priority.VIEW2_2_pri = 0;
2759 
2760 	calc3_mcu_init();
2761 	calc3_scantables();
2762 }
2763 
2764 
MACHINE_INIT(bloodwar)2765 static MACHINE_INIT( bloodwar )
2766 {
2767 	machine_init_kaneko16();
2768 
2769 	kaneko16_priority.sprite[0] = 0xfffe;	/* below all*/
2770 	kaneko16_priority.sprite[1] = 0xfffe;	/* above tile[0], below the others*/
2771 	kaneko16_priority.sprite[2] = 0x0000;	/* above all*/
2772 	kaneko16_priority.sprite[3] = 0x0000;	/* above all*/
2773 
2774 	kaneko16_sprite_type = 1;
2775 
2776 	kaneko16_priority.VIEW2_2_pri = 1;
2777 
2778 	toybox_mcu_run = bloodwar_mcu_run;
2779 	toybox_mcu_init();
2780 }
2781 
MACHINE_INIT(bonkadv)2782 static MACHINE_INIT( bonkadv )
2783 {
2784 	machine_init_kaneko16();
2785 
2786 	kaneko16_priority.sprite[0] = 0xfffe;	/* below all (ever used ?)*/
2787 	kaneko16_priority.sprite[1] = 0xfffe;	/* below all (volcano lava on level 2)*/
2788 	kaneko16_priority.sprite[2] = 0x0000;	/* above all*/
2789 	kaneko16_priority.sprite[3] = 0x0000;	/* above all*/
2790 
2791 	kaneko16_sprite_type = 1;
2792 
2793 	kaneko16_priority.VIEW2_2_pri = 1;
2794 
2795 	toybox_mcu_run = bonkadv_mcu_run;
2796 	toybox_mcu_init();
2797 }
2798 
2799 /***************************************************************************
2800 
2801 
2802 							MCU Code Simulation
2803 
2804 
2805 ***************************************************************************/
2806 
2807 
2808 /***************************************************************************
2809 							Great 1000 Miles Rally
2810 ***************************************************************************/
2811 
2812 const struct GameDriver driver_gtmr;
2813 const struct GameDriver driver_gtmre;
2814 const struct GameDriver driver_gtmrusa;
2815 const struct GameDriver driver_gtmr2;
2816 
2817 /*
2818 
2819 	MCU Tasks:
2820 
2821 	- Write and ID string to shared RAM.
2822 	- Access the EEPROM
2823 	- Read the DSWs
2824 
2825 */
2826 
gtmr_mcu_run(void)2827 void gtmr_mcu_run(void)
2828 {
2829 	data16_t mcu_command	=	mcu_ram[0x0010/2];
2830 	data16_t mcu_offset		=	mcu_ram[0x0012/2] / 2;
2831 	data16_t mcu_data		=	mcu_ram[0x0014/2];
2832 
2833 	log_cb(RETRO_LOG_DEBUG, LOGPRE "CPU #0 PC %06X : MCU executed command: %04X %04X %04X\n",activecpu_get_pc(),mcu_command,mcu_offset*2,mcu_data);
2834 
2835 	switch (mcu_command >> 8)
2836 	{
2837 
2838 		case 0x02:	/* Read from NVRAM*/
2839 		{
2840 			mame_file *f;
2841 			if ((f = mame_fopen(Machine->gamedrv->name,0,FILETYPE_NVRAM,0)) != 0)
2842 			{
2843 				mame_fread(f,&mcu_ram[mcu_offset], 128);
2844 				mame_fclose(f);
2845 			}
2846 		}
2847 		break;
2848 
2849 		case 0x42:	/* Write to NVRAM*/
2850 		{
2851 			mame_file *f;
2852 			if ((f = mame_fopen(Machine->gamedrv->name,0,FILETYPE_NVRAM,1)) != 0)
2853 			{
2854 				mame_fwrite(f,&mcu_ram[mcu_offset], 128);
2855 				mame_fclose(f);
2856 			}
2857 		}
2858 		break;
2859 
2860 		case 0x03:	/* DSW*/
2861 		{
2862 			mcu_ram[mcu_offset] = readinputport(4);
2863 		}
2864 		break;
2865 
2866 		case 0x04:	/* TEST (2 versions)*/
2867 		{
2868 			if (Machine->gamedrv == &driver_gtmr)
2869 			{
2870 				/* MCU writes the string "MM0525-TOYBOX199" to shared ram */
2871 				mcu_ram[mcu_offset+0] = 0x4d4d;
2872 				mcu_ram[mcu_offset+1] = 0x3035;
2873 				mcu_ram[mcu_offset+2] = 0x3235;
2874 				mcu_ram[mcu_offset+3] = 0x2d54;
2875 				mcu_ram[mcu_offset+4] = 0x4f59;
2876 				mcu_ram[mcu_offset+5] = 0x424f;
2877 				mcu_ram[mcu_offset+6] = 0x5831;
2878 				mcu_ram[mcu_offset+7] = 0x3939;
2879 			}
2880 			else if ( (Machine->gamedrv == &driver_gtmre)  ||
2881 					  (Machine->gamedrv == &driver_gtmrusa) ||
2882 					  (Machine->gamedrv == &driver_gtmr2) )
2883 			{
2884 				/* MCU writes the string "USMM0713-TB1994 " to shared ram */
2885 				mcu_ram[mcu_offset+0] = 0x5553;
2886 				mcu_ram[mcu_offset+1] = 0x4d4d;
2887 				mcu_ram[mcu_offset+2] = 0x3037;
2888 				mcu_ram[mcu_offset+3] = 0x3133;
2889 				mcu_ram[mcu_offset+4] = 0x2d54;
2890 				mcu_ram[mcu_offset+5] = 0x4231;
2891 				mcu_ram[mcu_offset+6] = 0x3939;
2892 				mcu_ram[mcu_offset+7] = 0x3420;
2893 			}
2894 		}
2895 		break;
2896 	}
2897 
2898 }
2899 
2900 
2901 #define GTMR_MCU_COM_W(_n_) \
2902 WRITE16_HANDLER( gtmr_mcu_com##_n_##_w ) \
2903 { \
2904 	COMBINE_DATA(&gtmr_mcu_com[_n_]); \
2905 	if (gtmr_mcu_com[0] != 0xFFFF)	return; \
2906 	if (gtmr_mcu_com[1] != 0xFFFF)	return; \
2907 	if (gtmr_mcu_com[2] != 0xFFFF)	return; \
2908 	if (gtmr_mcu_com[3] != 0xFFFF)	return; \
2909 \
2910 	memset(gtmr_mcu_com, 0, 4 * sizeof( data16_t ) ); \
2911 	gtmr_mcu_run(); \
2912 }
2913 
2914 GTMR_MCU_COM_W(0)
2915 GTMR_MCU_COM_W(1)
2916 GTMR_MCU_COM_W(2)
2917 GTMR_MCU_COM_W(3)
2918 
2919 
2920 /***************************************************************************
2921 								Sand Scorpion
2922 ***************************************************************************/
2923 
2924 /*
2925 
2926 	MCU Tasks:
2927 
2928 	- Collision detection (test if 2 rectangles overlap)
2929 	- Multiply 2 words, obtaining a long word
2930 	- Return a random value?
2931 
2932 */
2933 
READ16_HANDLER(sandscrp_mcu_ram_r)2934 static READ16_HANDLER( sandscrp_mcu_ram_r )
2935 {
2936 	switch( offset )
2937 	{
2938 		case 0x04/2:	/* Bit 0: collision detection*/
2939 		{
2940 			/* First rectangle */
2941 			int x_10		=	mcu_ram[0x00/2];
2942 			int x_11		=	mcu_ram[0x02/2] + x_10;
2943 			int y_10		=	mcu_ram[0x04/2];
2944 			int y_11		=	mcu_ram[0x06/2] + y_10;
2945 
2946 			/* Second rectangle */
2947 			int x_20		=	mcu_ram[0x08/2];
2948 			int x_21		=	mcu_ram[0x0a/2] + x_20;
2949 			int y_20		=	mcu_ram[0x0c/2];
2950 			int y_21		=	mcu_ram[0x0e/2] + y_20;
2951 
2952 			/* Sign extend the words */
2953 			x_10 = (x_10 & 0x7fff) - (x_10 & 0x8000);
2954 			x_11 = (x_11 & 0x7fff) - (x_11 & 0x8000);
2955 			y_10 = (y_10 & 0x7fff) - (y_10 & 0x8000);
2956 			y_11 = (y_11 & 0x7fff) - (y_11 & 0x8000);
2957 			x_20 = (x_20 & 0x7fff) - (x_20 & 0x8000);
2958 			x_21 = (x_21 & 0x7fff) - (x_21 & 0x8000);
2959 			y_20 = (y_20 & 0x7fff) - (y_20 & 0x8000);
2960 			y_21 = (y_21 & 0x7fff) - (y_21 & 0x8000);
2961 
2962 			/* Check if they overlap */
2963 			if	(	( x_10 > x_21 ) || ( x_11 < x_20 ) ||
2964 					( y_10 > y_21 ) || ( y_11 < y_20 )	)
2965 				return 0;
2966 			else
2967 				return 1;
2968 		}
2969 		break;
2970 
2971 		case 0x10/2:	/* Multiply 2 words, obtain a long word.*/
2972 		case 0x12/2:
2973 		{
2974 			int res = mcu_ram[0x10/2] * mcu_ram[0x12/2];
2975 			if (offset == 0x10/2)	return (res >> 16) & 0xffff;
2976 			else					return (res >>  0) & 0xffff;
2977 		}
2978 		break;
2979 
2980 		case 0x14/2:	/* Random?*/
2981 			return (mame_rand() & 0xffff);
2982 	}
2983 
2984 	log_cb(RETRO_LOG_DEBUG, LOGPRE "CPU #0 PC %06X : Unknown MCU word %04X read\n",activecpu_get_pc(),offset*2);
2985 	return mcu_ram[offset];
2986 }
2987 
WRITE16_HANDLER(sandscrp_mcu_ram_w)2988 static WRITE16_HANDLER( sandscrp_mcu_ram_w )
2989 {
2990 	COMBINE_DATA(&mcu_ram[offset]);
2991 }
2992 
2993 
2994 /***************************************************************************
2995 
2996 
2997 						Misc Machine Emulation Routines
2998 
2999 
3000 ***************************************************************************/
3001 
READ16_HANDLER(kaneko16_rnd_r)3002 READ16_HANDLER( kaneko16_rnd_r )
3003 {
3004 	return mame_rand() & 0xffff;
3005 }
3006 
WRITE16_HANDLER(kaneko16_coin_lockout_w)3007 WRITE16_HANDLER( kaneko16_coin_lockout_w )
3008 {
3009 	if (ACCESSING_MSB)
3010 	{
3011 		coin_counter_w(0,   data  & 0x0100);
3012 		coin_counter_w(1,   data  & 0x0200);
3013 		coin_lockout_w(0, (~data) & 0x0400 );
3014 		coin_lockout_w(1, (~data) & 0x0800 );
3015 	}
3016 }
3017 
3018 /* Sand Scorpion */
3019 
3020 static UINT8 sprite_irq;
3021 static UINT8 unknown_irq;
3022 static UINT8 vblank_irq;
3023 
3024 
3025 /* Update the IRQ state based on all possible causes */
update_irq_state(void)3026 static void update_irq_state(void)
3027 {
3028 	if (vblank_irq || sprite_irq || unknown_irq)
3029 		cpu_set_irq_line(0, 1, ASSERT_LINE);
3030 	else
3031 		cpu_set_irq_line(0, 1, CLEAR_LINE);
3032 }
3033 
3034 
3035 /* Called once/frame to generate the VBLANK interrupt */
INTERRUPT_GEN(sandscrp_interrupt)3036 static INTERRUPT_GEN( sandscrp_interrupt )
3037 {
3038 	vblank_irq = 1;
3039 	update_irq_state();
3040 }
3041 
3042 
VIDEO_EOF(sandscrp)3043 static VIDEO_EOF( sandscrp )
3044 {
3045 	sprite_irq = 1;
3046 	update_irq_state();
3047 }
3048 
3049 /* Reads the cause of the interrupt */
READ16_HANDLER(sandscrp_irq_cause_r)3050 static READ16_HANDLER( sandscrp_irq_cause_r )
3051 {
3052 	return 	( sprite_irq  ?  0x08  : 0 ) |
3053 			( unknown_irq ?  0x10  : 0 ) |
3054 			( vblank_irq  ?  0x20  : 0 ) ;
3055 }
3056 
3057 
3058 /* Clear the cause of the interrupt */
WRITE16_HANDLER(sandscrp_irq_cause_w)3059 static WRITE16_HANDLER( sandscrp_irq_cause_w )
3060 {
3061 	if (ACCESSING_LSB)
3062 	{
3063 		kaneko16_sprite_flipx	=	data & 1;
3064 		kaneko16_sprite_flipy	=	data & 1;
3065 
3066 		if (data & 0x08)	sprite_irq  = 0;
3067 		if (data & 0x10)	unknown_irq = 0;
3068 		if (data & 0x20)	vblank_irq  = 0;
3069 	}
3070 
3071 	update_irq_state();
3072 }
3073 
3074 
3075 /***************************************************************************
3076 
3077 
3078 									Sound
3079 
3080 
3081 ***************************************************************************/
3082 
WRITE16_HANDLER(kaneko16_soundlatch_w)3083 WRITE16_HANDLER( kaneko16_soundlatch_w )
3084 {
3085 	if (ACCESSING_MSB)
3086 	{
3087 		soundlatch_w(0, (data & 0xff00) >> 8 );
3088 		cpu_set_nmi_line(1,PULSE_LINE);
3089 	}
3090 }
3091 
3092 /* Two identically mapped YM2149 chips */
3093 
READ16_HANDLER(kaneko16_YM2149_0_r)3094 READ16_HANDLER( kaneko16_YM2149_0_r )
3095 {
3096 	/* Each 2149 register is mapped to a different address */
3097 	AY8910_control_port_0_w(0,offset);
3098 	return AY8910_read_port_0_r(0);
3099 }
3100 
READ16_HANDLER(kaneko16_YM2149_1_r)3101 READ16_HANDLER( kaneko16_YM2149_1_r )
3102 {
3103 	/* Each 2149 register is mapped to a different address */
3104 	AY8910_control_port_1_w(0,offset);
3105 	return AY8910_read_port_1_r(0);
3106 }
3107 
WRITE16_HANDLER(kaneko16_YM2149_0_w)3108 WRITE16_HANDLER( kaneko16_YM2149_0_w )
3109 {
3110 	/* Each 2149 register is mapped to a different address */
3111 	AY8910_control_port_0_w(0,offset);
3112 	/* The registers are mapped to odd addresses, except one! */
3113 	if (ACCESSING_LSB)	AY8910_write_port_0_w(0, data       & 0xff);
3114 	else				AY8910_write_port_0_w(0,(data >> 8) & 0xff);
3115 }
3116 
WRITE16_HANDLER(kaneko16_YM2149_1_w)3117 WRITE16_HANDLER( kaneko16_YM2149_1_w )
3118 {
3119 	/* Each 2149 register is mapped to a different address */
3120 	AY8910_control_port_1_w(0,offset);
3121 	/* The registers are mapped to odd addresses, except one! */
3122 	if (ACCESSING_LSB)	AY8910_write_port_1_w(0, data       & 0xff);
3123 	else				AY8910_write_port_1_w(0,(data >> 8) & 0xff);
3124 }
3125 
3126 
3127 /***************************************************************************
3128 
3129 
3130 									EEPROM
3131 
3132 
3133 ***************************************************************************/
3134 
READ_HANDLER(kaneko16_eeprom_r)3135 READ_HANDLER( kaneko16_eeprom_r )
3136 {
3137 	return EEPROM_read_bit() & 1;
3138 }
3139 
WRITE_HANDLER(kaneko16_eeprom_reset_w)3140 WRITE_HANDLER( kaneko16_eeprom_reset_w )
3141 {
3142 	/* reset line asserted: reset.*/
3143 	EEPROM_set_cs_line((data & 0x01) ? CLEAR_LINE : ASSERT_LINE );
3144 }
3145 
WRITE16_HANDLER(kaneko16_eeprom_w)3146 WRITE16_HANDLER( kaneko16_eeprom_w )
3147 {
3148 	if (ACCESSING_LSB)
3149 	{
3150 		/* latch the bit*/
3151 		EEPROM_write_bit(data & 0x02);
3152 
3153 		/* reset line asserted: reset.*/
3154 /*		EEPROM_set_cs_line((data & 0x00) ? CLEAR_LINE : ASSERT_LINE );*/
3155 
3156 		/* clock line asserted: write latch or select next bit to read*/
3157 		EEPROM_set_clock_line((data & 0x01) ? ASSERT_LINE : CLEAR_LINE );
3158 	}
3159 }
3160 
3161 
3162 /***************************************************************************
3163 
3164 
3165 							Memory Maps - Main CPU
3166 
3167 
3168 ***************************************************************************/
3169 
3170 /***************************************************************************
3171 								The Berlin Wall
3172 ***************************************************************************/
3173 
MEMORY_READ16_START(berlwall_readmem)3174 static MEMORY_READ16_START( berlwall_readmem )
3175     { 0x000000, 0x03ffff, MRA16_ROM					},	/* ROM*/
3176 	{ 0x200000, 0x20ffff, MRA16_RAM					},	/* Work RAM*/
3177 	{ 0x30e000, 0x30ffff, MRA16_RAM					},	/* Sprites*/
3178 	{ 0x400000, 0x400fff, MRA16_RAM					},	/* Palette*/
3179 /*	{ 0x480000, 0x480001, MRA16_RAM					},	*/ /* ?*/
3180 	{ 0x500000, 0x500001, kaneko16_bg15_reg_r		},	/* High Color Background*/
3181 	{ 0x580000, 0x580001, kaneko16_bg15_select_r	},
3182 	{ 0x600000, 0x60003f, MRA16_RAM					},	/* Sprites Regs*/
3183 	{ 0x680000, 0x680001, input_port_0_word_r		},	/* Inputs*/
3184 	{ 0x680002, 0x680003, input_port_1_word_r		},
3185 	{ 0x680004, 0x680005, input_port_2_word_r		},
3186 /*	{ 0x680006, 0x680007, input_port_3_word_r		},*/
3187 	{ 0x780000, 0x780001, watchdog_reset16_r		},	/* Watchdog*/
3188 	{ 0x800000, 0x80001f, kaneko16_YM2149_0_r		},	/* Sound*/
3189 	{ 0x800200, 0x80021f, kaneko16_YM2149_1_r		},
3190 	{ 0x800400, 0x800401, OKIM6295_status_0_lsb_r	},
3191 	{ 0xc00000, 0xc03fff, MRA16_RAM					},	/* Layers*/
3192 	{ 0xd00000, 0xd0001f, MRA16_RAM					},	/* Layers Regs*/
3193 MEMORY_END
3194 
3195 static MEMORY_WRITE16_START( berlwall_writemem )
3196     { 0x000000, 0x03ffff, MWA16_ROM											},	/* ROM*/
3197 	{ 0x200000, 0x20ffff, MWA16_RAM											},	/* Work RAM*/
3198 	{ 0x30e000, 0x30ffff, MWA16_RAM, &spriteram16, &spriteram_size			},	/* Sprites*/
3199 	{ 0x400000, 0x400fff, paletteram16_xGGGGGRRRRRBBBBB_word_w, &paletteram16	},	/* Palette*/
3200 /*	{ 0x480000, 0x480001, MWA16_RAM											},	*/ /* ?*/
3201 	{ 0x500000, 0x500001, kaneko16_bg15_reg_w, &kaneko16_bg15_reg		},	/* High Color Background*/
3202 	{ 0x580000, 0x580001, kaneko16_bg15_select_w, &kaneko16_bg15_select	},
3203 	{ 0x600000, 0x60003f, kaneko16_sprites_regs_w, &kaneko16_sprites_regs	},	/* Sprites Regs*/
3204 	{ 0x700000, 0x700001, kaneko16_coin_lockout_w							},	/* Coin Lockout*/
3205 	{ 0x800000, 0x80001f, kaneko16_YM2149_0_w								},	/* Sound*/
3206 	{ 0x800200, 0x80021f, kaneko16_YM2149_1_w								},
3207 	{ 0x800400, 0x800401, OKIM6295_data_0_lsb_w								},
3208 	{ 0xc00000, 0xc00fff, kaneko16_vram_1_w, &kaneko16_vram_1				},	/* Layers*/
3209 	{ 0xc01000, 0xc01fff, kaneko16_vram_0_w, &kaneko16_vram_0				},	/**/
3210 	{ 0xc02000, 0xc02fff, MWA16_RAM, &kaneko16_vscroll_1,					},	/**/
3211 	{ 0xc03000, 0xc03fff, MWA16_RAM, &kaneko16_vscroll_0,					},	/**/
3212 	{ 0xd00000, 0xd0001f, kaneko16_layers_0_regs_w, &kaneko16_layers_0_regs	},	/* Layers Regs*/
3213 MEMORY_END
3214 
3215 
3216 /***************************************************************************
3217 							Bakuretsu Breaker
3218 ***************************************************************************/
3219 
3220 /* Two un-assigned OKI samples get requested during game play. Leftover bug? */
3221 /* The two YM2149 chips are only used when entering high score initials, and */
3222 /* when the game is fully completed. Overkill??? */
3223 
3224 WRITE16_HANDLER( bakubrkr_oki_bank_sw )
3225 {
3226 	if (ACCESSING_LSB) {
3227 		OKIM6295_set_bank_base(0, 0x40000 * (data & 0x7) );
3228 		log_cb(RETRO_LOG_DEBUG, LOGPRE "PC:%06X  Selecting OKI bank %02X\n",activecpu_get_pc(),data&0xff);
3229 	}
3230 }
3231 
MEMORY_READ16_START(bakubrkr_readmem)3232 static MEMORY_READ16_START( bakubrkr_readmem )
3233     { 0x000000, 0x07ffff, MRA16_ROM					},	/* ROM*/
3234 	{ 0x100000, 0x10ffff, MRA16_RAM					},	/* Work RAM*/
3235 	{ 0x400000, 0x40001f, kaneko16_YM2149_0_r		},	/* Sound*/
3236 	{ 0x400200, 0x40021f, kaneko16_YM2149_1_r		},	/**/
3237 	{ 0x400400, 0x400401, OKIM6295_status_0_lsb_r	},	/**/
3238 	{ 0x500000, 0x503fff, MRA16_RAM					},	/* Layers 1*/
3239 	{ 0x580000, 0x583fff, MRA16_RAM					},	/* Layers 0*/
3240 	{ 0x600000, 0x601fff, MRA16_RAM					},	/* Sprites*/
3241 	{ 0x700000, 0x700fff, MRA16_RAM					},	/* Palette*/
3242 	{ 0x800000, 0x80001f, MRA16_RAM					},	/* Layers 0 Regs*/
3243 	{ 0x900000, 0x90001f, MRA16_RAM					},	/* Sprites Regs*/
3244 	{ 0xa80000, 0xa80001, watchdog_reset16_r		},	/* Watchdog*/
3245 	{ 0xb00000, 0xb0001f, MRA16_RAM					},	/* Layers 1 Regs*/
3246 	{ 0xe00000, 0xe00001, input_port_0_word_r		},	/* Inputs*/
3247 	{ 0xe00002, 0xe00003, input_port_1_word_r		},
3248 	{ 0xe00004, 0xe00005, input_port_2_word_r		},
3249 	{ 0xe00006, 0xe00007, input_port_3_word_r		},
3250 MEMORY_END
3251 
3252 static MEMORY_WRITE16_START( bakubrkr_writemem )
3253     { 0x000000, 0x07ffff, MWA16_ROM											},	/* ROM*/
3254 	{ 0x100000, 0x10ffff, MWA16_RAM											},	/* Work RAM*/
3255 	{ 0x400000, 0x40001d, kaneko16_YM2149_0_w								},	/* Sound*/
3256 	{ 0x40001e, 0x40001f, bakubrkr_oki_bank_sw								},	/* OKI bank Switch*/
3257 	{ 0x400200, 0x40021f, kaneko16_YM2149_1_w								},	/**/
3258 	{ 0x400400, 0x400401, OKIM6295_data_0_lsb_w	                            },	/**/
3259 	{ 0x500000, 0x500fff, kaneko16_vram_1_w, &kaneko16_vram_1				},	/* Layers 0*/
3260 	{ 0x501000, 0x501fff, kaneko16_vram_0_w, &kaneko16_vram_0				},	/**/
3261 	{ 0x502000, 0x502fff, MWA16_RAM, &kaneko16_vscroll_1,					},	/**/
3262 	{ 0x503000, 0x503fff, MWA16_RAM, &kaneko16_vscroll_0,					},	/**/
3263 	{ 0x580000, 0x580fff, kaneko16_vram_3_w, &kaneko16_vram_3				},	/* Layers 1*/
3264 	{ 0x581000, 0x581fff, kaneko16_vram_2_w, &kaneko16_vram_2				},	/**/
3265 	{ 0x582000, 0x582fff, MWA16_RAM, &kaneko16_vscroll_3,					},	/**/
3266 	{ 0x583000, 0x583fff, MWA16_RAM, &kaneko16_vscroll_2,					},	/**/
3267 	{ 0x600000, 0x601fff, MWA16_RAM, &spriteram16, &spriteram_size			},	/* Sprites*/
3268 	{ 0x700000, 0x700fff, paletteram16_xGGGGGRRRRRBBBBB_word_w, &paletteram16	},	/* Palette*/
3269 	{ 0x900000, 0x90001f, kaneko16_sprites_regs_w, &kaneko16_sprites_regs	},	/* Sprites Regs*/
3270 	{ 0x800000, 0x80001f, kaneko16_layers_0_regs_w, &kaneko16_layers_0_regs	},	/* Layers 1 Regs*/
3271 	{ 0xb00000, 0xb0001f, kaneko16_layers_1_regs_w, &kaneko16_layers_1_regs	},	/* Layers 0 Regs*/
3272 	{ 0xd00000, 0xd00001, kaneko16_eeprom_w									},	/* EEPROM*/
3273 MEMORY_END
3274 
3275 /***************************************************************************
3276 									Blaze On
3277 ***************************************************************************/
3278 
3279 static MEMORY_READ16_START( blazeon_readmem )
3280     { 0x000000, 0x07ffff, MRA16_ROM				},	/* ROM*/
3281 	{ 0x300000, 0x30ffff, MRA16_RAM				},	/* Work RAM*/
3282 	{ 0x500000, 0x500fff, MRA16_RAM				},	/* Palette*/
3283 	{ 0x600000, 0x603fff, MRA16_RAM				},	/* Layers 0*/
3284 	{ 0x700000, 0x700fff, MRA16_RAM				},	/* Sprites*/
3285 /**/{ 0x800000, 0x80001f, MRA16_RAM				},	/* Layers 0 Regs*/
3286 /**/{ 0x900000, 0x90001f, MRA16_RAM				},	/* Sprites Regs #1*/
3287 /**/{ 0x980000, 0x98001f, MRA16_RAM				},	/* Sprites Regs #2*/
3288 	{ 0xc00000, 0xc00001, input_port_0_word_r	},	/* Inputs*/
3289 	{ 0xc00002, 0xc00003, input_port_1_word_r	},
3290 	{ 0xc00004, 0xc00005, input_port_2_word_r	},
3291 	{ 0xc00006, 0xc00007, input_port_3_word_r	},
3292 	{ 0xe00000, 0xe00001, MRA16_NOP				},	/* IRQ Ack ?*/
3293 	{ 0xe40000, 0xe40001, MRA16_NOP				},	/* IRQ Ack ?*/
3294 /*	{ 0xe80000, 0xe80001, MRA16_NOP				},	*/ /* IRQ Ack ?*/
3295 	{ 0xec0000, 0xec0001, MRA16_NOP				},	/* Lev 4 IRQ Ack ?*/
3296 MEMORY_END
3297 
3298 static MEMORY_WRITE16_START( blazeon_writemem )
3299     { 0x000000, 0x07ffff, MWA16_ROM		},	/* ROM*/
3300 	{ 0x300000, 0x30ffff, MWA16_RAM     },	/* Work RAM*/
3301 	{ 0x500000, 0x500fff, paletteram16_xGGGGGRRRRRBBBBB_word_w, &paletteram16	},	/* Palette*/
3302 	{ 0x600000, 0x600fff, kaneko16_vram_1_w, &kaneko16_vram_1				},	/* Layers 0*/
3303 	{ 0x601000, 0x601fff, kaneko16_vram_0_w, &kaneko16_vram_0				},	/**/
3304 	{ 0x602000, 0x602fff, MWA16_RAM, &kaneko16_vscroll_1,					},	/**/
3305 	{ 0x603000, 0x603fff, MWA16_RAM, &kaneko16_vscroll_0,					},	/**/
3306 	{ 0x700000, 0x700fff, MWA16_RAM, &spriteram16, &spriteram_size			},	/* Sprites*/
3307 	{ 0x800000, 0x80001f, kaneko16_layers_0_regs_w, &kaneko16_layers_0_regs	},	/* Layers 1 Regs*/
3308 	{ 0x900000, 0x90001f, kaneko16_sprites_regs_w, &kaneko16_sprites_regs	},	/* Sprites Regs #1*/
3309 	{ 0x980000, 0x98001f, MWA16_RAM											},	/* Sprites Regs #2*/
3310 	{ 0xd00000, 0xd00001, kaneko16_coin_lockout_w							},	/* Coin Lockout*/
3311 	{ 0xe00000, 0xe00001, kaneko16_soundlatch_w								},
3312 MEMORY_END
3313 
3314 /***************************************************************************
3315 									Wing Force
3316 ***************************************************************************/
3317 
3318 static MEMORY_READ16_START( wingforc_readmem )
3319     { 0x000000, 0x0fffff, MRA16_ROM				},	/* ROM*/
3320 	{ 0x300000, 0x30ffff, MRA16_RAM				},	/* Work RAM*/
3321 	{ 0x500000, 0x500fff, MRA16_RAM				},	/* Palette*/
3322 	{ 0x600000, 0x603fff, MRA16_RAM				},	/* Layers 0*/
3323 	{ 0x700000, 0x700fff, MRA16_RAM				},	/* Sprites*/
3324 /**/{ 0x800000, 0x80001f, MRA16_RAM				},	/* Layers 0 Regs*/
3325 /**/{ 0x900000, 0x90001f, MRA16_RAM				},	/* Sprites Regs #1*/
3326 /**/{ 0x980000, 0x98001f, MRA16_RAM				},	/* Sprites Regs #2*/
3327 	{ 0xc00000, 0xc00001, input_port_0_word_r	},	/* Inputs*/
3328 	{ 0xc00002, 0xc00003, input_port_1_word_r	},
3329 	{ 0xc00004, 0xc00005, input_port_2_word_r	},
3330 	{ 0xc00006, 0xc00007, input_port_3_word_r	},
3331 	{ 0xe00000, 0xe00001, MRA16_NOP				},	/* IRQ Ack ?*/
3332 	{ 0xe40000, 0xe40001, MRA16_NOP				},	/* IRQ Ack ?*/
3333 /*	{ 0xe80000, 0xe80001, MRA16_NOP				},	*/ /* IRQ Ack ?*/
3334 	{ 0xec0000, 0xec0001, MRA16_NOP				},	/* Lev 4 IRQ Ack ?*/
3335 MEMORY_END
3336 
3337 static MEMORY_WRITE16_START( wingforc_writemem )
3338     { 0x000000, 0x0fffff, MWA16_ROM					 },	/* ROM*/
3339 	{ 0x300000, 0x30ffff, MWA16_RAM					 },	/* Work RAM*/
3340 	{ 0x500000, 0x500fff, paletteram16_xGGGGGRRRRRBBBBB_word_w, &paletteram16	},	/* Palette*/
3341 	{ 0x600000, 0x600fff, kaneko16_vram_1_w, &kaneko16_vram_1				},	/* Layers 0*/
3342 	{ 0x601000, 0x601fff, kaneko16_vram_0_w, &kaneko16_vram_0				},	/**/
3343 	{ 0x602000, 0x602fff, MWA16_RAM, &kaneko16_vscroll_1,					},	/**/
3344 	{ 0x603000, 0x603fff, MWA16_RAM, &kaneko16_vscroll_0,					},	/**/
3345 	{ 0x700000, 0x700fff, MWA16_RAM, &spriteram16, &spriteram_size			},	/* Sprites*/
3346 	{ 0x800000, 0x80001f, kaneko16_layers_0_regs_w, &kaneko16_layers_0_regs	},	/* Layers 1 Regs*/
3347 	{ 0x900000, 0x90001f, kaneko16_sprites_regs_w, &kaneko16_sprites_regs	},	/* Sprites Regs #1*/
3348 	{ 0x980000, 0x98001f, MWA16_RAM											},	/* Sprites Regs #2*/
3349 	{ 0xd00000, 0xd00001, kaneko16_coin_lockout_w							},	/* Coin Lockout*/
3350 	{ 0xe00000, 0xe00001, kaneko16_soundlatch_w								},
3351 MEMORY_END
3352 
3353 
3354 /***************************************************************************
3355 							Great 1000 Miles Rally
3356 ***************************************************************************/
3357 
3358 
3359 READ16_HANDLER( gtmr_wheel_r )
3360 {
3361 	if ( (readinputport(4) & 0x1800) == 0x10)	/* DSW setting*/
3362 		return	readinputport(5)<<8;			/* 360РWheel*/
3363 	else
3364 		return	readinputport(5);				/* 270РWheel*/
3365 }
3366 
3367 static int bank0;
WRITE16_HANDLER(gtmr_oki_0_bank_w)3368 WRITE16_HANDLER( gtmr_oki_0_bank_w )
3369 {
3370 	if (ACCESSING_LSB)
3371 	{
3372 		OKIM6295_set_bank_base(0, 0x10000 * (data & 0xF) );
3373 		bank0 = (data & 0xF);
3374 /*		log_cb(RETRO_LOG_DEBUG, LOGPRE "CPU #0 PC %06X : OKI0 bank %08X\n",activecpu_get_pc(),data);*/
3375 	}
3376 }
3377 
WRITE16_HANDLER(gtmr_oki_1_bank_w)3378 WRITE16_HANDLER( gtmr_oki_1_bank_w )
3379 {
3380 	if (ACCESSING_LSB)
3381 	{
3382 		OKIM6295_set_bank_base(1, 0x40000 * (data & 0x1) );
3383 /*		log_cb(RETRO_LOG_DEBUG, LOGPRE "CPU #0 PC %06X : OKI1 bank %08X\n",activecpu_get_pc(),data);*/
3384 	}
3385 }
3386 
3387 /*
3388 	If you look at the samples ROM for the OKI chip #0, you'll see
3389 	it's divided into 16 chunks, each chunk starting with the header
3390 	holding the samples	addresses. But, except for chunk 0, the first
3391 	$100 bytes ($20 samples) of each chunk are empty, and despite that,
3392 	samples in the range $0-1f are played. So, whenever a samples in
3393 	this range is requested, we use the address and sample from chunk 0,
3394 	otherwise we use those from the selected bank. By using this scheme
3395 	the sound improves, but I wouldn't bet it's correct..
3396 */
3397 
WRITE16_HANDLER(gtmr_oki_0_data_w)3398 WRITE16_HANDLER( gtmr_oki_0_data_w )
3399 {
3400 	static int pend = 0;
3401 
3402 	if (ACCESSING_LSB)
3403 	{
3404 
3405 		if (pend)	pend = 0;
3406 		else
3407 		{
3408 			if (data & 0x80)
3409 			{
3410 				int samp = data &0x7f;
3411 
3412 				pend = 1;
3413 				if (samp < 0x20)
3414 				{
3415 					OKIM6295_set_bank_base(0, 0);
3416 /*					log_cb(RETRO_LOG_DEBUG, LOGPRE "Setting OKI0 bank to zero\n");*/
3417 				}
3418 				else
3419 					OKIM6295_set_bank_base(0, 0x10000 * bank0 );
3420 			}
3421 		}
3422 
3423 		OKIM6295_data_0_w(0,data);
3424 /*		log_cb(RETRO_LOG_DEBUG, LOGPRE "CPU #0 PC %06X : OKI0 <- %08X\n",activecpu_get_pc(),data);*/
3425 
3426 	}
3427 
3428 }
3429 
WRITE16_HANDLER(gtmr_oki_1_data_w)3430 WRITE16_HANDLER( gtmr_oki_1_data_w )
3431 {
3432 	if (ACCESSING_LSB)
3433 	{
3434 		OKIM6295_data_1_w(0,data);
3435 /*		log_cb(RETRO_LOG_DEBUG, LOGPRE "CPU #0 PC %06X : OKI1 <- %08X\n",activecpu_get_pc(),data);*/
3436 	}
3437 }
3438 
3439 
MEMORY_READ16_START(gtmr_readmem)3440 static MEMORY_READ16_START( gtmr_readmem )
3441     { 0x000000, 0x0ffffd, MRA16_ROM					},	/* ROM*/
3442 	{ 0x0ffffe, 0x0fffff, gtmr_wheel_r				},	/* Wheel Value*/
3443 	{ 0x100000, 0x10ffff, MRA16_RAM					},	/* Work RAM*/
3444 	{ 0x200000, 0x20ffff, MRA16_RAM					},	/* Shared With MCU*/
3445 	{ 0x300000, 0x30ffff, MRA16_RAM					},	/* Palette*/
3446 	{ 0x310000, 0x327fff, MRA16_RAM					},	/**/
3447 	{ 0x400000, 0x401fff, MRA16_RAM					},	/* Sprites*/
3448 	{ 0x500000, 0x503fff, MRA16_RAM					},	/* Layers 0*/
3449 	{ 0x580000, 0x583fff, MRA16_RAM					},	/* Layers 1*/
3450 	{ 0x600000, 0x60000f, MRA16_RAM					},	/* Layers 0 Regs*/
3451 	{ 0x680000, 0x68000f, MRA16_RAM					},	/* Layers 1 Regs*/
3452 	{ 0x700000, 0x70001f, kaneko16_sprites_regs_r	},	/* Sprites Regs*/
3453 	{ 0x800000, 0x800001, OKIM6295_status_0_lsb_r	},	/* Samples*/
3454 	{ 0x880000, 0x880001, OKIM6295_status_1_lsb_r	},
3455 	{ 0x900014, 0x900015, kaneko16_rnd_r			},	/* Random Number ?*/
3456 	{ 0xa00000, 0xa00001, watchdog_reset16_r		},	/* Watchdog*/
3457 	{ 0xb00000, 0xb00001, input_port_0_word_r		},	/* Inputs*/
3458 	{ 0xb00002, 0xb00003, input_port_1_word_r		},
3459 	{ 0xb00004, 0xb00005, input_port_2_word_r		},
3460 	{ 0xb00006, 0xb00007, input_port_3_word_r		},
3461 	{ 0xd00000, 0xd00001, MRA16_NOP					},	/* ? (bit 0)*/
3462 MEMORY_END
3463 
3464 static MEMORY_WRITE16_START( gtmr_writemem )
3465     { 0x000000, 0x0fffff, MWA16_ROM					},	/* ROM*/
3466 	{ 0x100000, 0x10ffff, MWA16_RAM					},	/* Work RAM*/
3467 	{ 0x200000, 0x20ffff, MWA16_RAM, &mcu_ram		},	/* Shared With MCU*/
3468 	{ 0x2a0000, 0x2a0001, gtmr_mcu_com0_w			},	/* To MCU ?*/
3469 	{ 0x2b0000, 0x2b0001, gtmr_mcu_com1_w			},
3470 	{ 0x2c0000, 0x2c0001, gtmr_mcu_com2_w			},
3471 	{ 0x2d0000, 0x2d0001, gtmr_mcu_com3_w			},
3472 	{ 0x300000, 0x30ffff, paletteram16_xGGGGGRRRRRBBBBB_word_w, &paletteram16	},	/* Palette*/
3473 	{ 0x310000, 0x327fff, MWA16_RAM												},	/**/
3474 	{ 0x400000, 0x401fff, MWA16_RAM, &spriteram16, &spriteram_size			},	/* Sprites*/
3475 	{ 0x500000, 0x500fff, kaneko16_vram_1_w, &kaneko16_vram_1				},	/* Layers 0*/
3476 	{ 0x501000, 0x501fff, kaneko16_vram_0_w, &kaneko16_vram_0				},	/**/
3477 	{ 0x502000, 0x502fff, MWA16_RAM, &kaneko16_vscroll_1,					},	/**/
3478 	{ 0x503000, 0x503fff, MWA16_RAM, &kaneko16_vscroll_0,					},	/**/
3479 	{ 0x580000, 0x580fff, kaneko16_vram_3_w, &kaneko16_vram_3				},	/* Layers 1*/
3480 	{ 0x581000, 0x581fff, kaneko16_vram_2_w, &kaneko16_vram_2				},	/**/
3481 	{ 0x582000, 0x582fff, MWA16_RAM, &kaneko16_vscroll_3,					},	/**/
3482 	{ 0x583000, 0x583fff, MWA16_RAM, &kaneko16_vscroll_2,					},	/**/
3483 	{ 0x600000, 0x60000f, kaneko16_layers_0_regs_w, &kaneko16_layers_0_regs	},	/* Layers 0 Regs*/
3484 	{ 0x680000, 0x68000f, kaneko16_layers_1_regs_w, &kaneko16_layers_1_regs	},	/* Layers 1 Regs*/
3485 	{ 0x700000, 0x70001f, kaneko16_sprites_regs_w, &kaneko16_sprites_regs	},	/* Sprites Regs*/
3486 	{ 0x800000, 0x800001, gtmr_oki_0_data_w			},	/* Samples*/
3487 	{ 0x880000, 0x880001, gtmr_oki_1_data_w			},
3488 	{ 0xa00000, 0xa00001, watchdog_reset16_w		},	/* Watchdog*/
3489 	{ 0xb80000, 0xb80001, kaneko16_coin_lockout_w	},	/* Coin Lockout*/
3490 /*	{ 0xc00000, 0xc00001, MWA16_NOP					},	*/ /* ?*/
3491 	{ 0xe00000, 0xe00001, gtmr_oki_0_bank_w			},	/* Samples Bankswitching*/
3492 	{ 0xe80000, 0xe80001, gtmr_oki_1_bank_w			},
3493 MEMORY_END
3494 
3495 
3496 /***************************************************************************
3497 							Great 1000 Miles Rally 2
3498 ***************************************************************************/
3499 
3500 
3501 READ16_HANDLER( gtmr2_wheel_r )
3502 {
3503 	switch (readinputport(4) & 0x1800)
3504 	{
3505 		case 0x0000:	/* 270РA. Wheel*/
3506 			return	(readinputport(5));
3507 			break;
3508 		case 0x1000:	/* 270РD. Wheel*/
3509 			return	(readinputport(6) << 8);
3510 			break;
3511 		case 0x0800:	/* 360РWheel*/
3512 			return	(readinputport(7) << 8);
3513 			break;
3514 		default:
3515 			log_cb(RETRO_LOG_DEBUG, LOGPRE "gtmr2_wheel_r : read at %06x with joystick\n", activecpu_get_pc());
3516 			return	(~0);
3517 			break;
3518 	}
3519 }
3520 
READ16_HANDLER(gtmr2_IN1_r)3521 READ16_HANDLER( gtmr2_IN1_r )
3522 {
3523 	return	(readinputport(1) & (readinputport(8) | ~0x7100));
3524 }
3525 
MEMORY_READ16_START(gtmr2_readmem)3526 static MEMORY_READ16_START( gtmr2_readmem )
3527     { 0x000000, 0x0ffffd, MRA16_ROM					},	/* ROM*/
3528 	{ 0x0ffffe, 0x0fffff, gtmr2_wheel_r				},	/* Wheel Value*/
3529 	{ 0x100000, 0x10ffff, MRA16_RAM					},	/* Work RAM*/
3530 	{ 0x200000, 0x20ffff, MRA16_RAM					},	/* Shared With MCU*/
3531 	{ 0x300000, 0x30ffff, MRA16_RAM					},	/* Palette*/
3532 	{ 0x310000, 0x327fff, MRA16_RAM					},	/**/
3533 	{ 0x400000, 0x401fff, MRA16_RAM					},	/* Sprites*/
3534 	{ 0x500000, 0x503fff, MRA16_RAM					},	/* Layers 0*/
3535 	{ 0x580000, 0x583fff, MRA16_RAM					},	/* Layers 1*/
3536 	{ 0x600000, 0x60000f, MRA16_RAM					},	/* Layers 0 Regs*/
3537 	{ 0x680000, 0x68000f, MRA16_RAM					},	/* Layers 1 Regs*/
3538 	{ 0x700000, 0x70001f, kaneko16_sprites_regs_r	},	/* Sprites Regs*/
3539 	{ 0x800000, 0x800001, OKIM6295_status_0_lsb_r	},	/* Samples*/
3540 	{ 0x880000, 0x880001, OKIM6295_status_1_lsb_r	},
3541 	{ 0x900014, 0x900015, kaneko16_rnd_r			},	/* Random Number ?*/
3542 	{ 0xa00000, 0xa00001, watchdog_reset16_r		},	/* Watchdog*/
3543 	{ 0xb00000, 0xb00001, input_port_0_word_r		},	/* Inputs*/
3544 /*	{ 0xb00002, 0xb00003, input_port_1_word_r		},*/
3545 	{ 0xb00002, 0xb00003, gtmr2_IN1_r		},
3546 	{ 0xb00004, 0xb00005, input_port_2_word_r		},
3547 	{ 0xb00006, 0xb00007, input_port_3_word_r		},
3548 	{ 0xd00000, 0xd00001, MRA16_NOP					},	/* ? (bit 0)*/
3549 MEMORY_END
3550 
3551 /***************************************************************************
3552 								Magical Crystal
3553 ***************************************************************************/
3554 
3555 static MEMORY_READ16_START( mgcrystl_readmem )
3556     { 0x000000, 0x07ffff, MRA16_ROM					},	/* ROM*/
3557 	{ 0x300000, 0x30ffff, MRA16_RAM					},	/* Work RAM*/
3558 	{ 0x400000, 0x40001f, kaneko16_YM2149_0_r		},	/* Sound*/
3559 	{ 0x400200, 0x40021f, kaneko16_YM2149_1_r		},
3560 	{ 0x400400, 0x400401, OKIM6295_status_0_lsb_r	},
3561 	{ 0x500000, 0x500fff, MRA16_RAM					},	/* Palette*/
3562 	{ 0x600000, 0x603fff, MRA16_RAM					},	/* Layers 0*/
3563 	{ 0x680000, 0x683fff, MRA16_RAM					},	/* Layers 1*/
3564 	{ 0x700000, 0x701fff, MRA16_RAM					},	/* Sprites*/
3565 	{ 0x800000, 0x80000f, MRA16_RAM					},	/* Layers 0 Regs*/
3566 	{ 0x900000, 0x90001f, MRA16_RAM					},	/* Sprites Regs*/
3567 	{ 0xb00000, 0xb0000f, MRA16_RAM					},	/* Layers 1 Regs*/
3568 	{ 0xa00000, 0xa00001, watchdog_reset16_r		},	/* Watchdog*/
3569 	{ 0xc00000, 0xc00001, input_port_0_word_r		},	/* Inputs*/
3570 	{ 0xc00002, 0xc00003, input_port_1_word_r		},	/**/
3571 	{ 0xc00004, 0xc00005, input_port_2_word_r		},	/**/
3572 MEMORY_END
3573 
3574 static MEMORY_WRITE16_START( mgcrystl_writemem )
3575     { 0x000000, 0x07ffff, MWA16_ROM						},	/* ROM*/
3576 	{ 0x300000, 0x30ffff, MWA16_RAM						},	/* Work RAM*/
3577 	{ 0x400000, 0x40001f, kaneko16_YM2149_0_w			},	/* Sound*/
3578 	{ 0x400200, 0x40021f, kaneko16_YM2149_1_w			},
3579 	{ 0x400400, 0x400401, OKIM6295_data_0_lsb_w			},
3580 	{ 0x500000, 0x500fff, paletteram16_xGGGGGRRRRRBBBBB_word_w, &paletteram16	},	/* Palette*/
3581 	{ 0x600000, 0x600fff, kaneko16_vram_1_w, &kaneko16_vram_1				},	/* Layers 0*/
3582 	{ 0x601000, 0x601fff, kaneko16_vram_0_w, &kaneko16_vram_0				},	/**/
3583 	{ 0x602000, 0x602fff, MWA16_RAM, &kaneko16_vscroll_1,					},	/**/
3584 	{ 0x603000, 0x603fff, MWA16_RAM, &kaneko16_vscroll_0,					},	/**/
3585 	{ 0x680000, 0x680fff, kaneko16_vram_3_w, &kaneko16_vram_3				},	/* Layers 1*/
3586 	{ 0x681000, 0x681fff, kaneko16_vram_2_w, &kaneko16_vram_2				},	/**/
3587 	{ 0x682000, 0x682fff, MWA16_RAM, &kaneko16_vscroll_3,					},	/**/
3588 	{ 0x683000, 0x683fff, MWA16_RAM, &kaneko16_vscroll_2,					},	/**/
3589 	{ 0x700000, 0x701fff, MWA16_RAM, &spriteram16, &spriteram_size			},	/* Sprites*/
3590 	{ 0x800000, 0x80001f, kaneko16_layers_0_regs_w, &kaneko16_layers_0_regs	},	/* Layers 0 Regs*/
3591 	{ 0x900000, 0x90001f, kaneko16_sprites_regs_w, &kaneko16_sprites_regs	},	/* Sprites Regs*/
3592 	{ 0xb00000, 0xb0001f, kaneko16_layers_1_regs_w, &kaneko16_layers_1_regs	},	/* Layers 1 Regs*/
3593 	{ 0xd00000, 0xd00001, kaneko16_eeprom_w									},	/* EEPROM*/
3594 MEMORY_END
3595 
3596 
3597 /***************************************************************************
3598 								Sand Scorpion
3599 ***************************************************************************/
3600 
3601 WRITE16_HANDLER( sandscrp_coin_counter_w )
3602 {
3603 	if (ACCESSING_LSB)
3604 	{
3605 		coin_counter_w(0,   data  & 0x0001);
3606 		coin_counter_w(1,   data  & 0x0002);
3607 	}
3608 }
3609 
3610 static data8_t latch1_full;
3611 static data8_t latch2_full;
3612 
READ16_HANDLER(sandscrp_latchstatus_word_r)3613 static READ16_HANDLER( sandscrp_latchstatus_word_r )
3614 {
3615 	return	(latch1_full ? 0x80 : 0) |
3616 			(latch2_full ? 0x40 : 0) ;
3617 }
3618 
WRITE16_HANDLER(sandscrp_latchstatus_word_w)3619 static WRITE16_HANDLER( sandscrp_latchstatus_word_w )
3620 {
3621 	if (ACCESSING_LSB)
3622 	{
3623 		latch1_full = data & 0x80;
3624 		latch2_full = data & 0x40;
3625 	}
3626 }
3627 
READ16_HANDLER(sandscrp_soundlatch_word_r)3628 static READ16_HANDLER( sandscrp_soundlatch_word_r )
3629 {
3630 	latch2_full = 0;
3631 	return soundlatch2_r(0);
3632 }
3633 
WRITE16_HANDLER(sandscrp_soundlatch_word_w)3634 static WRITE16_HANDLER( sandscrp_soundlatch_word_w )
3635 {
3636 	if (ACCESSING_LSB)
3637 	{
3638 		latch1_full = 1;
3639 		soundlatch_w(0, data & 0xff);
3640 		cpu_set_nmi_line(1,PULSE_LINE);
3641 		cpu_spinuntil_time(TIME_IN_USEC(400));	/* Allow the other cpu to reply*/
3642 	}
3643 }
3644 
MEMORY_READ16_START(sandscrp_readmem)3645 static MEMORY_READ16_START( sandscrp_readmem )
3646     { 0x000000, 0x07ffff, MRA16_ROM						},	/* ROM*/
3647 	{ 0x700000, 0x70ffff, MRA16_RAM						},	/* RAM*/
3648 	{ 0x200000, 0x20001f, sandscrp_mcu_ram_r			},	/* Protection*/
3649 	{ 0x300000, 0x30000f, MRA16_RAM						},	/* Scroll*/
3650 	{ 0x400000, 0x401fff, MRA16_RAM						},	/* Layers*/
3651 	{ 0x402000, 0x403fff, MRA16_RAM						},	/**/
3652 	{ 0x500000, 0x501fff, MRA16_RAM						},	/* Sprites*/
3653 	{ 0x600000, 0x600fff, MRA16_RAM						},	/* Palette*/
3654 	{ 0xb00000, 0xb00001, input_port_0_word_r			},	/* Inputs*/
3655 	{ 0xb00002, 0xb00003, input_port_1_word_r			},	/**/
3656 	{ 0xb00004, 0xb00005, input_port_2_word_r			},	/**/
3657 	{ 0xb00006, 0xb00007, input_port_3_word_r			},	/**/
3658 	{ 0xec0000, 0xec0001, watchdog_reset16_r			},	/**/
3659 	{ 0x800000, 0x800001, sandscrp_irq_cause_r			},	/* IRQ Cause*/
3660 	{ 0xe00000, 0xe00001, sandscrp_soundlatch_word_r	},	/* From Sound CPU*/
3661 	{ 0xe40000, 0xe40001, sandscrp_latchstatus_word_r	},	/**/
3662 MEMORY_END
3663 
3664 
3665 static MEMORY_WRITE16_START( sandscrp_writemem )
3666     { 0x000000, 0x07ffff, MWA16_ROM				                },	/* ROM*/
3667 	{ 0x200000, 0x20001f, sandscrp_mcu_ram_w, &mcu_ram			},	/* Protection*/
3668 	{ 0x700000, 0x70ffff, MWA16_RAM								},	/* RAM*/
3669 	{ 0x300000, 0x30000f, kaneko16_layers_0_regs_w, &kaneko16_layers_0_regs	},	/* Layers 0 Regs*/
3670 	{ 0x100000, 0x100001, sandscrp_irq_cause_w					},	/* IRQ Ack*/
3671 	{ 0x400000, 0x400fff, kaneko16_vram_1_w, &kaneko16_vram_1	},	/* Layers 0*/
3672 	{ 0x401000, 0x401fff, kaneko16_vram_0_w, &kaneko16_vram_0	},	/**/
3673 	{ 0x402000, 0x402fff, MWA16_RAM, &kaneko16_vscroll_1,		},	/**/
3674 	{ 0x403000, 0x403fff, MWA16_RAM, &kaneko16_vscroll_0		},	/**/
3675 	{ 0x500000, 0x501fff, MWA16_RAM, &spriteram16, &spriteram_size	},	/* Sprites*/
3676 	{ 0x600000, 0x600fff, paletteram16_xGGGGGRRRRRBBBBB_word_w, &paletteram16	},	/* Palette*/
3677 	{ 0xa00000, 0xa00001, sandscrp_coin_counter_w				},	/* Coin Counters (Lockout unused)*/
3678 	{ 0xe00000, 0xe00001, sandscrp_soundlatch_word_w			},	/* To Sound CPU*/
3679 	{ 0xe40000, 0xe40001, sandscrp_latchstatus_word_w			},	/**/
3680 MEMORY_END
3681 
3682 
3683 /***************************************************************************
3684 								Shogun Warriors
3685 ***************************************************************************/
3686 
3687 /* Untested */
3688 WRITE16_HANDLER( shogwarr_oki_bank_w )
3689 {
3690 	if (ACCESSING_LSB)
3691 	{
3692 		OKIM6295_set_bank_base(1, 0x40000 * ((data >> 0) & 0xf) );
3693 		OKIM6295_set_bank_base(0, 0x40000 * ((data >> 4) & 0xf) );
3694 	}
3695 }
3696 
3697 
MEMORY_READ16_START(shogwarr_readmem)3698 static MEMORY_READ16_START( shogwarr_readmem )
3699         { 0x000000, 0x03ffff, MRA16_ROM	 }, /* ROM*/
3700 	{ 0x100000, 0x10ffff, MRA16_RAM	 },	/* Work RAM*/
3701 	{ 0x200000, 0x20ffff, MRA16_RAM  }, /* Shared With MCU*/
3702 	{ 0x380000, 0x380fff, MRA16_RAM  },	/* Palette*/
3703 	{ 0x400000, 0x400001, OKIM6295_status_0_lsb_r }, /* Sound*/
3704 	{ 0x480000, 0x480001, OKIM6295_status_1_lsb_r },
3705 	{ 0x580000, 0x581fff, MRA16_RAM },	/* Sprites*/
3706 	{ 0x600000, 0x603fff, MRA16_RAM },	/* Layers 0*/
3707 	{ 0x800000, 0x80000f, MRA16_RAM },	/* Layers 0 Regs*/
3708 	{ 0x900000, 0x90001f, MRA16_RAM },	/* Sprites Regs*/
3709 	{ 0xa00000, 0xa0007f, bloodwar_calc_r },
3710 	{ 0xa80000, 0xa80001, watchdog_reset16_r },	/* Watchdog*/
3711 	{ 0xb80000, 0xb80001, input_port_0_word_r },	/* Inputs*/
3712 	{ 0xb80002, 0xb80003, input_port_1_word_r },
3713 	{ 0xb80004, 0xb80005, input_port_2_word_r },
3714 	{ 0xb80006, 0xb80007, input_port_3_word_r },
3715 	{ 0xd00000, 0xd00001, MRA16_NOP			  },	/* ? (bit 0)*/
3716 MEMORY_END
3717 
3718 static MEMORY_WRITE16_START( shogwarr_writemem )
3719         { 0x000000, 0x03ffff, MWA16_ROM	            },              /* ROM*/
3720 	{ 0x100000, 0x10ffff, MWA16_RAM, &kaneko16_mainram       },	/* Work RAM*/
3721 	{ 0x200000, 0x20ffff, calc3_mcu_ram_w, &kaneko16_mcu_ram },	/* Shared With MCU*/
3722 	{ 0x280000, 0x280001, calc3_mcu_com0_w      },
3723 	{ 0x290000, 0x290001, calc3_mcu_com1_w      },
3724 	{ 0x2b0000, 0x2b0001, calc3_mcu_com2_w      },
3725 	/*{ 0x2c0000, 0x2c0001, calc3_run }, */ /* guess, might be irqack*/
3726 	{ 0x2d0000, 0x2d0001, calc3_mcu_com3_w      },
3727 	{ 0x380000, 0x380fff, paletteram16_xGGGGGRRRRRBBBBB_word_w, &paletteram16 },  /* Palette*/
3728 	{ 0x400000, 0x400001, OKIM6295_data_0_lsb_w },                                /* Sound*/
3729 	{ 0x480000, 0x480001, OKIM6295_data_1_lsb_w },
3730 	{ 0x580000, 0x581fff, MWA16_RAM, &spriteram16, &spriteram_size  },			  /* Sprites*/
3731 	{ 0x600000, 0x600fff, kaneko16_vram_1_w, &kaneko16_vram_1 },	              /* Layers 0*/
3732 	{ 0x601000, 0x601fff, kaneko16_vram_0_w, &kaneko16_vram_0 },
3733 	{ 0x602000, 0x602fff, MWA16_RAM, &kaneko16_vscroll_1, },
3734 	{ 0x603000, 0x603fff, MWA16_RAM, &kaneko16_vscroll_0, },
3735 	{ 0x800000, 0x80000f, kaneko16_layers_0_regs_w, &kaneko16_layers_0_regs },	  /* Layers 0 Regs*/
3736 	{ 0x900000, 0x90001f, kaneko16_sprites_regs_w, &kaneko16_sprites_regs },	  /* Sprites Regs*/
3737 	{ 0xa00000, 0xa0007f, bloodwar_calc_w       },
3738 	{ 0xa80000, 0xa80001, watchdog_reset16_w    },	                              /* Watchdog*/
3739 	{ 0xd00000, 0xd00001, MWA16_NOP			    },				                  /* ? (bit 0)*/
3740 	{ 0xe00000, 0xe00001, shogwarr_oki_bank_w   },                                /* Samples Bankswitching*/
3741 MEMORY_END
3742 
3743 
3744 static WRITE16_HANDLER( bonkadv_oki_0_bank_w )
3745 {
3746 	if (ACCESSING_LSB)
3747 	{
3748 		OKIM6295_set_bank_base(0, 0x40000 * (data & 0xF));
3749 	}
3750 }
3751 
WRITE16_HANDLER(bonkadv_oki_1_bank_w)3752 static WRITE16_HANDLER( bonkadv_oki_1_bank_w )
3753 {
3754 	if (ACCESSING_LSB)
3755 	{
3756 		OKIM6295_set_bank_base(1, 0x40000 * data );
3757 	}
3758 }
3759 
WRITE16_HANDLER(bloodwar_coin_lockout_w)3760 static WRITE16_HANDLER( bloodwar_coin_lockout_w )
3761 {
3762 	if (ACCESSING_MSB)
3763 	{
3764 		coin_counter_w(0, data & 0x0100);
3765 
3766 		coin_lockout_w(0, data & 0x8000 );
3767 		coin_lockout_w(1, data & 0x8000 );
3768 	}
3769 }
3770 
3771 
MEMORY_READ16_START(bonkadv_readmem)3772 static MEMORY_READ16_START( bonkadv_readmem )
3773     { 0x000000, 0x0fffff, MRA16_ROM	       },		/* ROM*/
3774 	{ 0x100000, 0x10ffff, MRA16_RAM		   },       /* Work RAM*/
3775 	{ 0x200000, 0x20ffff, MRA16_RAM        },    	/* Shared With MCU*/
3776 	{ 0x300000, 0x30ffff, MRA16_RAM        },   	/* Palette*/
3777 	{ 0x400000, 0x401fff, MRA16_RAM		   },	    /* Sprites*/
3778 	{ 0x500000, 0x500fff, MRA16_RAM        },    	/* Layers 0*/
3779 	{ 0x501000, 0x501fff, MRA16_RAM        },    	/**/
3780 	{ 0x502000, 0x502fff, MRA16_RAM		   },		/**/
3781 	{ 0x503000, 0x503fff, MRA16_RAM		   },		/**/
3782 	{ 0x580000, 0x580fff, MRA16_RAM        },	    /* Layers 1*/
3783 	{ 0x581000, 0x581fff, MRA16_RAM        },   	/**/
3784 	{ 0x582000, 0x582fff, MRA16_RAM		   },		/**/
3785 	{ 0x583000, 0x583fff, MRA16_RAM		   },		/**/
3786 	{ 0x600000, 0x60001f, MRA16_RAM        },	    /* Layers 0 Regs*/
3787 	{ 0x680000, 0x68001f, MRA16_RAM        },	    /* Layers 1 Regs*/
3788 	{ 0x700000, 0x70001f, MRA16_RAM        },	    /* Sprites Regs*/
3789 	{ 0x800000, 0x800001, OKIM6295_status_0_lsb_r  },   /* Sound*/
3790 	{ 0x880000, 0x880001, OKIM6295_status_1_lsb_r  },   /**/
3791 	{ 0x900000, 0x900015, galpanib_calc_r          },   /* Protection*/
3792 	{ 0xa00000, 0xa00001, watchdog_reset16_r       },	/* Watchdog*/
3793 	{ 0xb00000, 0xb00001, input_port_0_word_r	   },	/* Inputs*/
3794     { 0xb00002, 0xb00003, input_port_1_word_r	   },   /**/
3795 	{ 0xb00004, 0xb00005, input_port_2_word_r	   },   /**/
3796 	{ 0xb00006, 0xb00007, input_port_3_word_r	   },   /**/
3797 	{ 0xd00000, 0xd00001, toybox_mcu_status_r      },
3798 MEMORY_END
3799 
3800 static MEMORY_WRITE16_START( bonkadv_writemem )
3801     { 0x000000, 0x0fffff, MWA16_ROM	        },		 /* ROM*/
3802 	{ 0x100000, 0x10ffff, MWA16_RAM		    },       /* Work RAM*/
3803 	{ 0x200000, 0x20ffff, MWA16_RAM, &kaneko16_mcu_ram },	/* Shared With MCU*/
3804 	{ 0x2a0000, 0x2a0001, toybox_mcu_com0_w },	     /* To MCU ?*/
3805 	{ 0x2b0000, 0x2b0001, toybox_mcu_com1_w },       /**/
3806 	{ 0x2c0000, 0x2c0001, toybox_mcu_com2_w },       /**/
3807 	{ 0x2d0000, 0x2d0001, toybox_mcu_com3_w },       /**/
3808 	{ 0x300000, 0x30ffff, paletteram16_xGGGGGRRRRRBBBBB_word_w, &paletteram16 },	/* Palette*/
3809 	{ 0x400000, 0x401fff, MWA16_RAM, &spriteram16, &spriteram_size },				/* Sprites*/
3810 	{ 0x500000, 0x500fff, kaneko16_vram_1_w, &kaneko16_vram_1 },	/* Layers 0*/
3811 	{ 0x501000, 0x501fff, kaneko16_vram_0_w, &kaneko16_vram_0 },	/**/
3812 	{ 0x502000, 0x502fff, MWA16_RAM, &kaneko16_vscroll_1, },									/**/
3813 	{ 0x503000, 0x503fff, MWA16_RAM, &kaneko16_vscroll_0, },								/**/
3814 	{ 0x580000, 0x580fff, kaneko16_vram_3_w, &kaneko16_vram_3 },/* Layers 1*/
3815 	{ 0x581000, 0x581fff, kaneko16_vram_2_w, &kaneko16_vram_2 },	/**/
3816 	{ 0x582000, 0x582fff, MWA16_RAM, &kaneko16_vscroll_3, },								/**/
3817 	{ 0x583000, 0x583fff, MWA16_RAM, &kaneko16_vscroll_2, },								/**/
3818 	{ 0x600000, 0x60001f, kaneko16_layers_0_regs_w, &kaneko16_layers_0_regs },	/* Layers 0 Regs*/
3819 	{ 0x680000, 0x68001f, kaneko16_layers_1_regs_w, &kaneko16_layers_1_regs },	/* Layers 1 Regs*/
3820 	{ 0x700000, 0x70001f, kaneko16_sprites_regs_w, &kaneko16_sprites_regs },	/* Sprites Regs*/
3821 	{ 0x800000, 0x800001, OKIM6295_data_0_lsb_w }, /* Sound*/
3822 	{ 0x880000, 0x880001, OKIM6295_data_1_lsb_w },
3823 	{ 0x900000, 0x900015, galpanib_calc_w }, /* Protection*/
3824 	{ 0xa00000, 0xa00001, watchdog_reset16_w }, /* Watchdog*/
3825 	{ 0xb80000, 0xb80001, bloodwar_coin_lockout_w }, /* Coin Lockout*/
3826 /*	{ 0xc00000, 0xc00001, kaneko16_display_enable }, */ /* iq_132*/
3827 	{ 0xe00000, 0xe00001, bonkadv_oki_0_bank_w },  /* Sound*/
3828 	{ 0xe80000, 0xe80001, bonkadv_oki_1_bank_w },  /**/
3829 MEMORY_END
3830 
3831 /***************************************************************************
3832 								Blood Warrior
3833 ***************************************************************************/
3834 
3835 static WRITE16_HANDLER( bloodwar_oki_0_bank_w )
3836 {
3837 	if (ACCESSING_LSB)
3838 	{
3839 		OKIM6295_set_bank_base(0, 0x40000 * (data & 0x3) );
3840 /*		log_cb(RETRO_LOG_DEBUG, LOGPRE "CPU #0 PC %06X : OKI0  bank %08X\n",activecpu_get_pc(),data);*/
3841 	}
3842 }
3843 
WRITE16_HANDLER(bloodwar_oki_1_bank_w)3844 static WRITE16_HANDLER( bloodwar_oki_1_bank_w )
3845 {
3846 	if (ACCESSING_LSB)
3847 	{
3848 		OKIM6295_set_bank_base(1, 0x40000 * (data & 0x3) );
3849 /*		log_cb(RETRO_LOG_DEBUG, LOGPRE "CPU #0 PC %06X : OKI1  bank %08X\n",activecpu_get_pc(),data);*/
3850 	}
3851 }
3852 
3853 
MEMORY_READ16_START(bloodwar_readmem)3854 static MEMORY_READ16_START( bloodwar_readmem )
3855     { 0x000000, 0x0fffff, MRA16_ROM       },		 /* ROM*/
3856 	{ 0x100000, 0x10ffff, MRA16_RAM       },		 /* Work RAM*/
3857 	{ 0x200000, 0x20ffff, MRA16_RAM       },	     /* Shared With MCU*/
3858 	{ 0x300000, 0x30ffff, MRA16_RAM       },	     /* Palette*/
3859 	{ 0x400000, 0x401fff, MRA16_RAM		  },	     /* Sprites*/
3860 	{ 0x500000, 0x500fff, MRA16_RAM       },	     /* Layers 0*/
3861 	{ 0x501000, 0x501fff, MRA16_RAM       },	     /**/
3862 	{ 0x502000, 0x502fff, MRA16_RAM		  },		 /**/
3863 	{ 0x503000, 0x503fff, MRA16_RAM		  },		 /**/
3864 	{ 0x580000, 0x580fff, MRA16_RAM       },	     /* Layers 1*/
3865 	{ 0x581000, 0x581fff, MRA16_RAM       },	     /**/
3866 	{ 0x582000, 0x582fff, MRA16_RAM		  },		 /**/
3867 	{ 0x583000, 0x583fff, MRA16_RAM		  },		 /**/
3868 	{ 0x600000, 0x60001f, MRA16_RAM       },	     /* Layers 0 Regs*/
3869 	{ 0x680000, 0x68001f, MRA16_RAM       },	     /* Layers 1 Regs*/
3870 	{ 0x700000, 0x70001f, MRA16_RAM       },	     /* Sprites Regs*/
3871 	{ 0x800000, 0x800001, OKIM6295_status_0_lsb_r }, /* Sound*/
3872 	{ 0x880000, 0x880001, OKIM6295_status_1_lsb_r }, /**/
3873 	{ 0x900000, 0x900039, bloodwar_calc_r         }, /* Protection*/
3874 	{ 0xa00000, 0xa00001, watchdog_reset16_r      }, /* Watchdog*/
3875 	{ 0xb00000, 0xb00001, input_port_0_word_r	  }, /* Inputs*/
3876 	{ 0xb00002, 0xb00003, input_port_1_word_r	  },
3877 	{ 0xb00004, 0xb00005, input_port_2_word_r	  },
3878 	{ 0xb00006, 0xb00007, input_port_3_word_r	  },
3879 	{ 0xd00000, 0xd00001, toybox_mcu_status_r     },
3880 MEMORY_END
3881 
3882 static MEMORY_WRITE16_START( bloodwar_writemem )
3883     { 0x000000, 0x0fffff, MWA16_ROM		     },  /* ROM*/
3884 	{ 0x100000, 0x10ffff, MWA16_RAM		     },  /* Work RAM*/
3885 	{ 0x200000, 0x20ffff, MWA16_RAM, &kaneko16_mcu_ram },	/* Shared With MCU*/
3886 	{ 0x2a0000, 0x2a0001, toybox_mcu_com0_w },	/* To MCU ?*/
3887 	{ 0x2b0000, 0x2b0001, toybox_mcu_com1_w },
3888 	{ 0x2c0000, 0x2c0001, toybox_mcu_com2_w },
3889 	{ 0x2d0000, 0x2d0001, toybox_mcu_com3_w },
3890 	{ 0x300000, 0x30ffff, paletteram16_xGGGGGRRRRRBBBBB_word_w, &paletteram16 },	/* Palette*/
3891 	{ 0x400000, 0x401fff, MWA16_RAM, &spriteram16, &spriteram_size },				/* Sprites*/
3892 	{ 0x500000, 0x500fff, kaneko16_vram_1_w, &kaneko16_vram_1 },	/* Layers 0*/
3893 	{ 0x501000, 0x501fff, kaneko16_vram_0_w, &kaneko16_vram_0 },    /**/
3894 	{ 0x502000, 0x502fff, MWA16_RAM, &kaneko16_vscroll_1, },			/**/
3895 	{ 0x503000, 0x503fff, MWA16_RAM, &kaneko16_vscroll_0, },			/**/
3896 	{ 0x580000, 0x580fff, kaneko16_vram_3_w, &kaneko16_vram_3 },    /* Layers 1*/
3897 	{ 0x581000, 0x581fff, kaneko16_vram_2_w, &kaneko16_vram_2 },	/**/
3898 	{ 0x582000, 0x582fff, MWA16_RAM, &kaneko16_vscroll_3, },			/**/
3899 	{ 0x583000, 0x583fff, MWA16_RAM, &kaneko16_vscroll_2, },			/**/
3900 	{ 0x600000, 0x60001f, kaneko16_layers_0_regs_w, &kaneko16_layers_0_regs },	/* Layers 0 Regs*/
3901 	{ 0x680000, 0x68001f, kaneko16_layers_1_regs_w, &kaneko16_layers_1_regs },	/* Layers 1 Regs*/
3902 	{ 0x700000, 0x70001f, kaneko16_sprites_regs_w, &kaneko16_sprites_regs   },	/* Sprites Regs*/
3903 	{ 0x800000, 0x800001, OKIM6295_data_0_lsb_w   }, /* Sound*/
3904 	{ 0x880000, 0x880001, OKIM6295_data_1_lsb_w   }, /**/
3905 	{ 0x900000, 0x900039, bloodwar_calc_w         }, /* Protection*/
3906 	{ 0xa00000, 0xa00001, watchdog_reset16_w      }, /* Watchdog*/
3907 	{ 0xb80000, 0xb80001, bloodwar_coin_lockout_w }, /* Coin Lockout*/
3908 /*	{ 0xc00000, 0xc00001, kaneko16_display_enable }, */ /* iq_132*/
3909 	{ 0xe00000, 0xe00001, bloodwar_oki_0_bank_w   },
3910 	{ 0xe80000, 0xe80001, bloodwar_oki_1_bank_w   },
3911 MEMORY_END
3912 
3913 /***************************************************************************
3914 
3915 
3916 							Memory Maps - Sound CPU
3917 
3918 
3919 ***************************************************************************/
3920 
3921 /***************************************************************************
3922 									Blaze On
3923 ***************************************************************************/
3924 
3925 #if 0
3926 static WRITE_HANDLER( blazeon_bankswitch_w )
3927 {
3928 	unsigned char *RAM = memory_region(REGION_CPU1);
3929 	int bank = data & 7;
3930 	cpu_setbank(15, &RAM[bank * 0x10000 + 0x1000]);
3931 }
3932 #endif
3933 
3934 
3935 static MEMORY_READ_START( blazeon_sound_readmem )
3936 	{ 0x0000, 0x7fff, MRA_ROM					},	/* ROM*/
3937 	{ 0xc000, 0xdfff, MRA_RAM					},	/* RAM*/
3938 MEMORY_END
3939 
3940 static MEMORY_WRITE_START( blazeon_sound_writemem )
3941 	{ 0x0000, 0x7fff, MWA_ROM					},	/* ROM*/
3942 	{ 0xc000, 0xdfff, MWA_RAM					},	/* RAM*/
3943 MEMORY_END
3944 
3945 static PORT_READ_START( blazeon_sound_readport )
3946 	{ 0x03, 0x03, YM2151_status_port_0_r	},
3947 	{ 0x06, 0x06, soundlatch_r				},
3948 PORT_END
3949 
3950 static PORT_WRITE_START( blazeon_sound_writeport )
3951 	{ 0x02, 0x02, YM2151_register_port_0_w	},
3952 	{ 0x03, 0x03, YM2151_data_port_0_w		},
3953 PORT_END
3954 
3955 /***************************************************************************
3956                                 Wing Force
3957 +***************************************************************************/
3958 
3959 WRITE_HANDLER(wingforc_oki_bank_w)
3960 {
3961 	if (data <= 2)
3962 		OKIM6295_set_bank_base(0, 0x40000 * data );
3963 	else
3964 		log_cb(RETRO_LOG_DEBUG, LOGPRE "%s: unknown OKI bank %02X\n", activecpu_get_pc(),data);
3965 }
3966 
MEMORY_READ_START(wingforc_sound_readmem)3967 static MEMORY_READ_START( wingforc_sound_readmem )
3968     { 0x0000, 0xbfff, MRA_ROM		},	/* ROM*/
3969 	{ 0xc000, 0xdfff, MRA_RAM		},	/* RAM*/
3970 MEMORY_END
3971 
3972 static MEMORY_WRITE_START( wingforc_sound_writemem )
3973     { 0x0000, 0xbfff, MWA_ROM		},	/* ROM*/
3974 	{ 0xc000, 0xdfff, MWA_RAM		},	/* RAM*/
3975 MEMORY_END
3976 
3977 static PORT_READ_START( wingforc_sound_readport )
3978     { 0x03, 0x03, YM2151_status_port_0_r	},
3979 	{ 0x0a, 0x0a, OKIM6295_status_0_r       },
3980 	{ 0x06, 0x06, soundlatch_r				},
3981 PORT_END
3982 
3983 static PORT_WRITE_START( wingforc_sound_writeport )
3984     { 0x02, 0x02, YM2151_register_port_0_w	},
3985 	{ 0x03, 0x03, YM2151_data_port_0_w		},
3986 	{ 0x0a, 0x0a, OKIM6295_data_0_w			},
3987 	{ 0x0c, 0x0c, wingforc_oki_bank_w       },
3988 PORT_END
3989 
3990 
3991 /***************************************************************************
3992 								Sand Scorpion
3993 ***************************************************************************/
3994 
3995 WRITE_HANDLER( sandscrp_bankswitch_w )
3996 {
3997 	unsigned char *RAM = memory_region(REGION_CPU1);
3998 	int bank = data & 0x07;
3999 
4000 	if ( bank != data )	log_cb(RETRO_LOG_DEBUG, LOGPRE "CPU #1 - PC %04X: Bank %02X\n",activecpu_get_pc(),data);
4001 
4002 	if (bank < 3)	RAM = &RAM[0x4000 * bank];
4003 	else			RAM = &RAM[0x4000 * (bank-3) + 0x10000];
4004 
4005 	cpu_setbank(1, RAM);
4006 }
4007 
READ_HANDLER(sandscrp_latchstatus_r)4008 static READ_HANDLER( sandscrp_latchstatus_r )
4009 {
4010 	return	(latch2_full ? 0x80 : 0) |	/* swapped!?*/
4011 			(latch1_full ? 0x40 : 0) ;
4012 }
4013 
READ_HANDLER(sandscrp_soundlatch_r)4014 static READ_HANDLER( sandscrp_soundlatch_r )
4015 {
4016 	latch1_full = 0;
4017 	return soundlatch_r(0);
4018 }
4019 
WRITE_HANDLER(sandscrp_soundlatch_w)4020 static WRITE_HANDLER( sandscrp_soundlatch_w )
4021 {
4022 	latch2_full = 1;
4023 	soundlatch2_w(0,data);
4024 }
4025 
MEMORY_READ_START(sandscrp_sound_readmem)4026 static MEMORY_READ_START( sandscrp_sound_readmem )
4027 	{ 0x0000, 0x7fff, MRA_ROM					},	/* ROM*/
4028 	{ 0x8000, 0xbfff, MRA_BANK1					},	/* Banked ROM*/
4029 	{ 0xc000, 0xdfff, MRA_RAM					},	/* RAM*/
4030 MEMORY_END
4031 
4032 static MEMORY_WRITE_START( sandscrp_sound_writemem )
4033 	{ 0x0000, 0x7fff, MWA_ROM					},	/* ROM*/
4034 	{ 0x8000, 0xbfff, MWA_ROM					},	/* Banked ROM*/
4035 	{ 0xc000, 0xdfff, MWA_RAM					},	/* RAM*/
4036 MEMORY_END
4037 
4038 static PORT_READ_START( sandscrp_sound_readport )
4039 	{ 0x02, 0x02, YM2203_status_port_0_r		},	/* YM2203*/
4040 	{ 0x03, 0x03, YM2203_read_port_0_r			},	/* PORTA/B read*/
4041 	{ 0x07, 0x07, sandscrp_soundlatch_r			},	/**/
4042 	{ 0x08, 0x08, sandscrp_latchstatus_r		},	/**/
4043 PORT_END
4044 
4045 static PORT_WRITE_START( sandscrp_sound_writeport )
4046 	{ 0x00, 0x00, sandscrp_bankswitch_w		},	/* ROM Bank*/
4047 	{ 0x02, 0x02, YM2203_control_port_0_w	},	/* YM2203*/
4048 	{ 0x03, 0x03, YM2203_write_port_0_w		},	/**/
4049 	{ 0x04, 0x04, OKIM6295_data_0_w			},	/* OKIM6295*/
4050 	{ 0x06, 0x06, sandscrp_soundlatch_w		},	/**/
4051 PORT_END
4052 
4053 
4054 /***************************************************************************
4055 
4056 
4057 								Input Ports
4058 
4059 
4060 ***************************************************************************/
4061 
4062 /***************************************************************************
4063 							Bakuretsu Breaker
4064 ***************************************************************************/
4065 
4066 INPUT_PORTS_START( bakubrkr )
4067 	PORT_START	/* IN0 - Player 1 + DSW - e00000.w*/
4068 	PORT_DIPNAME( 0x0001, 0x0001, DEF_STR( Flip_Screen ) )
4069 	PORT_DIPSETTING(      0x0001, DEF_STR( Off ) )
4070 	PORT_DIPSETTING(      0x0000, DEF_STR( On )  )
4071 	PORT_SERVICE( 0x0002, IP_ACTIVE_LOW )
4072 	PORT_DIPNAME( 0x0004, 0x0004, "Unknown 1-2" )
4073 	PORT_DIPSETTING(      0x0004, DEF_STR( Off ) )
4074 	PORT_DIPSETTING(      0x0000, DEF_STR( On )  )
4075 	PORT_DIPNAME( 0x0008, 0x0008, "Unknown 1-3" )
4076 	PORT_DIPSETTING(      0x0008, DEF_STR( Off ) )
4077 	PORT_DIPSETTING(      0x0000, DEF_STR( On )  )
4078 	PORT_DIPNAME( 0x0010, 0x0010, "Unknown 1-4" )
4079 	PORT_DIPSETTING(      0x0010, DEF_STR( Off ) )
4080 	PORT_DIPSETTING(      0x0000, DEF_STR( On )  )
4081 	PORT_DIPNAME( 0x0020, 0x0020, "Unknown 1-5" )
4082 	PORT_DIPSETTING(      0x0020, DEF_STR( Off ) )
4083 	PORT_DIPSETTING(      0x0000, DEF_STR( On )  )
4084 	PORT_DIPNAME( 0x0040, 0x0040, "Unknown 1-6" )
4085 	PORT_DIPSETTING(      0x0040, DEF_STR( Off ) )
4086 	PORT_DIPSETTING(      0x0000, DEF_STR( On )  )
4087 	PORT_DIPNAME( 0x0080, 0x0080, "Unknown 1-7" )
4088 	PORT_DIPSETTING(      0x0080, DEF_STR( Off ) )
4089 	PORT_DIPSETTING(      0x0000, DEF_STR( On )  )
4090 
4091 	PORT_BIT(  0x0100, IP_ACTIVE_LOW, IPT_JOYSTICK_UP    | IPF_8WAY | IPF_PLAYER1 )
4092 	PORT_BIT(  0x0200, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN  | IPF_8WAY | IPF_PLAYER1 )
4093 	PORT_BIT(  0x0400, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT  | IPF_8WAY | IPF_PLAYER1 )
4094 	PORT_BIT(  0x0800, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_8WAY | IPF_PLAYER1 )
4095 	PORT_BIT(  0x1000, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER1 )
4096 	PORT_BIT(  0x2000, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_PLAYER1 )
4097 	PORT_BIT(  0x4000, IP_ACTIVE_LOW, IPT_UNKNOWN )
4098 	PORT_BIT(  0x8000, IP_ACTIVE_LOW, IPT_UNKNOWN )
4099 
4100 	PORT_START	/* IN1 - Player 2 - e00002.b*/
4101 	PORT_BIT(  0x0100, IP_ACTIVE_LOW, IPT_JOYSTICK_UP    | IPF_8WAY | IPF_PLAYER2 )
4102 	PORT_BIT(  0x0200, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN  | IPF_8WAY | IPF_PLAYER2 )
4103 	PORT_BIT(  0x0400, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT  | IPF_8WAY | IPF_PLAYER2 )
4104 	PORT_BIT(  0x0800, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_8WAY | IPF_PLAYER2 )
4105 	PORT_BIT(  0x1000, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER2 )
4106 	PORT_BIT(  0x2000, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_PLAYER2 )
4107 	PORT_BIT(  0x4000, IP_ACTIVE_LOW, IPT_UNKNOWN )
4108 	PORT_BIT(  0x8000, IP_ACTIVE_LOW, IPT_UNKNOWN )
4109 
4110 	PORT_START	/* IN2 - Coins - e00004.b*/
4111 	PORT_BIT(  0x0100, IP_ACTIVE_LOW, IPT_START1	)
4112 	PORT_BIT(  0x0200, IP_ACTIVE_LOW, IPT_START2	)
4113 	PORT_BIT_IMPULSE( 0x0400, IP_ACTIVE_LOW, IPT_COIN1, 2 )
4114 	PORT_BIT_IMPULSE( 0x0800, IP_ACTIVE_LOW, IPT_COIN2, 2 )
4115 	PORT_BITX( 0x1000, IP_ACTIVE_LOW, IPT_SERVICE, DEF_STR( Service_Mode ), KEYCODE_F2, IP_JOY_NONE )
4116 	PORT_BIT(  0x2000, IP_ACTIVE_LOW, IPT_TILT		)	/* pause*/
4117 	PORT_BIT(  0x4000, IP_ACTIVE_LOW, IPT_SERVICE1	)
4118 	PORT_BIT(  0x8000, IP_ACTIVE_LOW, IPT_UNKNOWN	)
4119 
4120 	PORT_START	/* IN3 - Seems unused ! - e00006.b*/
4121 	PORT_BIT(  0x0100, IP_ACTIVE_LOW, IPT_UNKNOWN )
4122 	PORT_BIT(  0x0200, IP_ACTIVE_LOW, IPT_UNKNOWN )
4123 	PORT_BIT(  0x0400, IP_ACTIVE_LOW, IPT_UNKNOWN )
4124 	PORT_BIT(  0x0800, IP_ACTIVE_LOW, IPT_UNKNOWN )
4125 	PORT_BIT(  0x1000, IP_ACTIVE_LOW, IPT_UNKNOWN )
4126 	PORT_BIT(  0x2000, IP_ACTIVE_LOW, IPT_UNKNOWN )
4127 	PORT_BIT(  0x4000, IP_ACTIVE_LOW, IPT_UNKNOWN )
4128 	PORT_BIT(  0x8000, IP_ACTIVE_LOW, IPT_UNKNOWN )
4129 INPUT_PORTS_END
4130 
4131 
4132 /***************************************************************************
4133 							The Berlin Wall (set 1)
4134 ***************************************************************************/
4135 
4136 INPUT_PORTS_START( berlwall )
4137 	PORT_START	/* IN0 - Player 1 - 680000.w*/
4138 	PORT_BIT(  0x0100, IP_ACTIVE_LOW, IPT_JOYSTICK_UP    | IPF_8WAY | IPF_PLAYER1 )
4139 	PORT_BIT(  0x0200, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN  | IPF_8WAY | IPF_PLAYER1 )
4140 	PORT_BIT(  0x0400, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT  | IPF_8WAY | IPF_PLAYER1 )
4141 	PORT_BIT(  0x0800, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_8WAY | IPF_PLAYER1 )
4142 	PORT_BIT(  0x1000, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER1 )
4143 	PORT_BIT(  0x2000, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_PLAYER1 )
4144 	PORT_BIT(  0x4000, IP_ACTIVE_LOW, IPT_BUTTON3 | IPF_PLAYER1 )
4145 	PORT_BIT(  0x8000, IP_ACTIVE_LOW, IPT_UNKNOWN )
4146 
4147 	PORT_START	/* IN1 - Player 2 - 680002.w*/
4148 	PORT_BIT(  0x0100, IP_ACTIVE_LOW, IPT_JOYSTICK_UP    | IPF_8WAY | IPF_PLAYER2 )
4149 	PORT_BIT(  0x0200, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN  | IPF_8WAY | IPF_PLAYER2 )
4150 	PORT_BIT(  0x0400, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT  | IPF_8WAY | IPF_PLAYER2 )
4151 	PORT_BIT(  0x0800, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_8WAY | IPF_PLAYER2 )
4152 	PORT_BIT(  0x1000, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER2 )
4153 	PORT_BIT(  0x2000, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_PLAYER2 )
4154 	PORT_BIT(  0x4000, IP_ACTIVE_LOW, IPT_BUTTON3 | IPF_PLAYER2 )
4155 	PORT_BIT(  0x8000, IP_ACTIVE_LOW, IPT_UNKNOWN )
4156 
4157 	PORT_START	/* IN2 - Coins - 680004.w*/
4158 	PORT_BIT(  0x0100, IP_ACTIVE_LOW, IPT_START1	)
4159 	PORT_BIT(  0x0200, IP_ACTIVE_LOW, IPT_START2	)
4160 	PORT_BIT_IMPULSE( 0x0400, IP_ACTIVE_LOW, IPT_COIN1, 2 )
4161 	PORT_BIT_IMPULSE( 0x0800, IP_ACTIVE_LOW, IPT_COIN2, 2 )
4162 	PORT_BITX( 0x1000, IP_ACTIVE_LOW, IPT_SERVICE, DEF_STR( Service_Mode ), KEYCODE_F2, IP_JOY_NONE )
4163 	PORT_BIT(  0x2000, IP_ACTIVE_LOW, IPT_TILT		)
4164 	PORT_BIT(  0x4000, IP_ACTIVE_LOW, IPT_SERVICE1	)
4165 	PORT_BIT(  0x8000, IP_ACTIVE_LOW, IPT_UNKNOWN	)
4166 
4167 	PORT_START	/* IN3 - ? - 680006.w*/
4168 	PORT_BIT(  0x0100, IP_ACTIVE_LOW, IPT_UNKNOWN )
4169 	PORT_BIT(  0x0200, IP_ACTIVE_LOW, IPT_UNKNOWN )
4170 	PORT_BIT(  0x0400, IP_ACTIVE_LOW, IPT_UNKNOWN )
4171 	PORT_BIT(  0x0800, IP_ACTIVE_LOW, IPT_UNKNOWN )
4172 	PORT_BIT(  0x1000, IP_ACTIVE_LOW, IPT_UNKNOWN )
4173 	PORT_BIT(  0x2000, IP_ACTIVE_LOW, IPT_UNKNOWN )
4174 	PORT_BIT(  0x4000, IP_ACTIVE_LOW, IPT_UNKNOWN )
4175 	PORT_BIT(  0x8000, IP_ACTIVE_LOW, IPT_UNKNOWN )
4176 
4177 	PORT_START	/* IN4 - DSW 1 - $200018.b <- ! $80001d.b*/
4178 	PORT_DIPNAME( 0x01, 0x01, DEF_STR( Flip_Screen ) )
4179 	PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
4180 	PORT_DIPSETTING(    0x00, DEF_STR( On ) )
4181 	PORT_DIPNAME( 0x02, 0x02, "Reserved" )
4182 	PORT_DIPSETTING(    0x02, DEF_STR( Off ) )
4183 	PORT_DIPSETTING(    0x00, DEF_STR( On ) )
4184 	PORT_DIPNAME( 0x1c, 0x1c, DEF_STR( Coin_A ) )
4185 	PORT_DIPSETTING(    0x00, DEF_STR( 4C_1C ) )
4186 	PORT_DIPSETTING(    0x04, DEF_STR( 3C_1C ) )
4187 	PORT_DIPSETTING(    0x0c, DEF_STR( 2C_1C ) )
4188 	PORT_DIPSETTING(    0x1c, DEF_STR( 1C_1C ) )
4189 	PORT_DIPSETTING(    0x08, DEF_STR( 2C_3C ) )
4190 	PORT_DIPSETTING(    0x18, DEF_STR( 1C_2C ) )
4191 	PORT_DIPSETTING(    0x14, DEF_STR( 1C_3C ) )
4192 	PORT_DIPSETTING(    0x10, DEF_STR( 1C_4C ) )
4193 	PORT_DIPNAME( 0xe0, 0xe0, DEF_STR( Coin_B ) )
4194 	PORT_DIPSETTING(    0x60, DEF_STR( 2C_1C ) )
4195 	PORT_DIPSETTING(    0xe0, DEF_STR( 1C_1C ) )
4196 	PORT_DIPSETTING(    0x40, DEF_STR( 2C_3C ) )
4197 	PORT_DIPSETTING(    0xc0, DEF_STR( 1C_2C ) )
4198 	PORT_DIPSETTING(    0xa0, DEF_STR( 1C_3C ) )
4199 	PORT_DIPSETTING(    0x80, DEF_STR( 1C_4C ) )
4200 	PORT_DIPSETTING(    0x20, DEF_STR( 1C_5C ) )
4201 	PORT_DIPSETTING(    0x00, DEF_STR( 1C_6C ) )
4202 
4203 	PORT_START	/* IN5 - DSW 2 - $200019.b <- $80001f.b*/
4204 	PORT_DIPNAME( 0x03, 0x03, DEF_STR( Difficulty ) )
4205 	PORT_DIPSETTING(    0x02, "Easy"    )
4206 	PORT_DIPSETTING(    0x03, "Normal"  )
4207 	PORT_DIPSETTING(    0x01, "Hard"    )
4208 	PORT_DIPSETTING(    0x00, "Hardest" )
4209 	PORT_DIPNAME( 0x0c, 0x0c, DEF_STR( Lives ) )	/* 1p lives at 202982.b*/
4210 	PORT_DIPSETTING(    0x00, "1" )
4211 	PORT_DIPSETTING(    0x0c, "2" )
4212 	PORT_DIPSETTING(    0x08, "3" )
4213 	PORT_DIPSETTING(    0x04, "5" )
4214 	PORT_DIPNAME( 0x30, 0x30, "Country"   )
4215 	PORT_DIPSETTING(    0x30, "England" )
4216 	PORT_DIPSETTING(    0x20, "Italy"   )
4217 	PORT_DIPSETTING(    0x10, "Germany" )
4218 	PORT_DIPSETTING(    0x00, "Freeze Screen" )
4219 	PORT_DIPNAME( 0x40, 0x40, DEF_STR( Demo_Sounds ) )
4220 	PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
4221 	PORT_DIPSETTING(    0x40, DEF_STR( On ) )
4222 	PORT_SERVICE( 0x80, IP_ACTIVE_LOW )
4223 INPUT_PORTS_END
4224 
4225 
4226 /***************************************************************************
4227 							The Berlin Wall (set 2)
4228 ***************************************************************************/
4229 
4230 /*	Same as berlwall, but for a different lives setting*/
4231 
4232 INPUT_PORTS_START( berlwalt )
4233 	PORT_START	/* IN0 - Player 1 - 680000.w*/
4234 	PORT_BIT(  0x0100, IP_ACTIVE_LOW, IPT_JOYSTICK_UP    | IPF_8WAY | IPF_PLAYER1 )
4235 	PORT_BIT(  0x0200, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN  | IPF_8WAY | IPF_PLAYER1 )
4236 	PORT_BIT(  0x0400, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT  | IPF_8WAY | IPF_PLAYER1 )
4237 	PORT_BIT(  0x0800, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_8WAY | IPF_PLAYER1 )
4238 	PORT_BIT(  0x1000, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER1 )
4239 	PORT_BIT(  0x2000, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_PLAYER1 )
4240 	PORT_BIT(  0x4000, IP_ACTIVE_LOW, IPT_BUTTON3 | IPF_PLAYER1 )
4241 	PORT_BIT(  0x8000, IP_ACTIVE_LOW, IPT_UNKNOWN )
4242 
4243 	PORT_START	/* IN1 - Player 2 - 680002.w*/
4244 	PORT_BIT(  0x0100, IP_ACTIVE_LOW, IPT_JOYSTICK_UP    | IPF_8WAY | IPF_PLAYER2 )
4245 	PORT_BIT(  0x0200, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN  | IPF_8WAY | IPF_PLAYER2 )
4246 	PORT_BIT(  0x0400, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT  | IPF_8WAY | IPF_PLAYER2 )
4247 	PORT_BIT(  0x0800, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_8WAY | IPF_PLAYER2 )
4248 	PORT_BIT(  0x1000, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER2 )
4249 	PORT_BIT(  0x2000, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_PLAYER2 )
4250 	PORT_BIT(  0x4000, IP_ACTIVE_LOW, IPT_BUTTON3 | IPF_PLAYER2 )
4251 	PORT_BIT(  0x8000, IP_ACTIVE_LOW, IPT_UNKNOWN )
4252 
4253 	PORT_START	/* IN2 - Coins - 680004.w*/
4254 	PORT_BIT(  0x0100, IP_ACTIVE_LOW, IPT_START1	)
4255 	PORT_BIT(  0x0200, IP_ACTIVE_LOW, IPT_START2	)
4256 	PORT_BIT_IMPULSE( 0x0400, IP_ACTIVE_LOW, IPT_COIN1, 2 )
4257 	PORT_BIT_IMPULSE( 0x0800, IP_ACTIVE_LOW, IPT_COIN2, 2 )
4258 	PORT_BITX( 0x1000, IP_ACTIVE_LOW, IPT_SERVICE, DEF_STR( Service_Mode ), KEYCODE_F2, IP_JOY_NONE )
4259 	PORT_BIT(  0x2000, IP_ACTIVE_LOW, IPT_TILT		)
4260 	PORT_BIT(  0x4000, IP_ACTIVE_LOW, IPT_SERVICE1	)
4261 	PORT_BIT(  0x8000, IP_ACTIVE_LOW, IPT_UNKNOWN	)
4262 
4263 	PORT_START	/* IN3 - ? - 680006.w*/
4264 	PORT_BIT(  0x0100, IP_ACTIVE_LOW, IPT_UNKNOWN )
4265 	PORT_BIT(  0x0200, IP_ACTIVE_LOW, IPT_UNKNOWN )
4266 	PORT_BIT(  0x0400, IP_ACTIVE_LOW, IPT_UNKNOWN )
4267 	PORT_BIT(  0x0800, IP_ACTIVE_LOW, IPT_UNKNOWN )
4268 	PORT_BIT(  0x1000, IP_ACTIVE_LOW, IPT_UNKNOWN )
4269 	PORT_BIT(  0x2000, IP_ACTIVE_LOW, IPT_UNKNOWN )
4270 	PORT_BIT(  0x4000, IP_ACTIVE_LOW, IPT_UNKNOWN )
4271 	PORT_BIT(  0x8000, IP_ACTIVE_LOW, IPT_UNKNOWN )
4272 
4273 	PORT_START	/* IN4 - DSW 1 - $80001d.b*/
4274 	PORT_DIPNAME( 0x01, 0x01, DEF_STR( Flip_Screen ) )
4275 	PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
4276 	PORT_DIPSETTING(    0x00, DEF_STR( On ) )
4277 	PORT_DIPNAME( 0x02, 0x02, "Reserved" )
4278 	PORT_DIPSETTING(    0x02, DEF_STR( Off ) )
4279 	PORT_DIPSETTING(    0x00, DEF_STR( On ) )
4280 	PORT_DIPNAME( 0x1c, 0x1c, DEF_STR( Coin_A ) )
4281 	PORT_DIPSETTING(    0x00, DEF_STR( 4C_1C ) )
4282 	PORT_DIPSETTING(    0x04, DEF_STR( 3C_1C ) )
4283 	PORT_DIPSETTING(    0x0c, DEF_STR( 2C_1C ) )
4284 	PORT_DIPSETTING(    0x1c, DEF_STR( 1C_1C ) )
4285 	PORT_DIPSETTING(    0x08, DEF_STR( 2C_3C ) )
4286 	PORT_DIPSETTING(    0x18, DEF_STR( 1C_2C ) )
4287 	PORT_DIPSETTING(    0x14, DEF_STR( 1C_3C ) )
4288 	PORT_DIPSETTING(    0x10, DEF_STR( 1C_4C ) )
4289 	PORT_DIPNAME( 0xe0, 0xe0, DEF_STR( Coin_B ) )
4290 	PORT_DIPSETTING(    0x60, DEF_STR( 2C_1C ) )
4291 	PORT_DIPSETTING(    0xe0, DEF_STR( 1C_1C ) )
4292 	PORT_DIPSETTING(    0x40, DEF_STR( 2C_3C ) )
4293 	PORT_DIPSETTING(    0xc0, DEF_STR( 1C_2C ) )
4294 	PORT_DIPSETTING(    0xa0, DEF_STR( 1C_3C ) )
4295 	PORT_DIPSETTING(    0x80, DEF_STR( 1C_4C ) )
4296 	PORT_DIPSETTING(    0x20, DEF_STR( 1C_5C ) )
4297 	PORT_DIPSETTING(    0x00, DEF_STR( 1C_6C ) )
4298 
4299 	PORT_START	/* IN5 - DSW 2 - $80001f.b*/
4300 	PORT_DIPNAME( 0x03, 0x03, DEF_STR( Difficulty ) )
4301 	PORT_DIPSETTING(    0x02, "Easy"    )
4302 	PORT_DIPSETTING(    0x03, "Normal"  )
4303 	PORT_DIPSETTING(    0x01, "Hard"    )
4304 	PORT_DIPSETTING(    0x00, "Hardest" )
4305 	PORT_DIPNAME( 0x0c, 0x0c, DEF_STR( Lives ) )
4306 	PORT_DIPSETTING(    0x00, "7" )
4307 	PORT_DIPSETTING(    0x04, "5" )
4308 	PORT_DIPSETTING(    0x0c, "3" )
4309 	PORT_DIPSETTING(    0x08, "2" )
4310 	PORT_DIPNAME( 0x30, 0x30, "Country"   )
4311 	PORT_DIPSETTING(    0x30, "England" )
4312 	PORT_DIPSETTING(    0x20, "Italy"   )
4313 	PORT_DIPSETTING(    0x10, "Germany" )
4314 	PORT_DIPSETTING(    0x00, "Freeze Screen" )
4315 	PORT_DIPNAME( 0x40, 0x40, DEF_STR( Demo_Sounds ) )
4316 	PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
4317 	PORT_DIPSETTING(    0x40, DEF_STR( On ) )
4318 	PORT_SERVICE( 0x80, IP_ACTIVE_LOW )
4319 INPUT_PORTS_END
4320 
4321 
4322 /***************************************************************************
4323                                Pack'n Bang Bang
4324 ***************************************************************************/
4325 
4326 INPUT_PORTS_START( packbang )
4327 	PORT_START        /* 680000.w */
4328 	PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_JOYSTICK_UP | IPF_8WAY | IPF_PLAYER1 )
4329 	PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | IPF_8WAY | IPF_PLAYER1 )
4330 	PORT_BIT( 0x0400, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_8WAY | IPF_PLAYER1 )
4331 	PORT_BIT( 0x0800, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_8WAY | IPF_PLAYER1 )
4332 	PORT_BIT( 0x1000, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER1 )
4333 	PORT_BIT( 0x2000, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_PLAYER1 )
4334 	PORT_BIT( 0x4000, IP_ACTIVE_LOW, IPT_BUTTON3 | IPF_PLAYER1 )
4335 	PORT_BIT( 0x8000, IP_ACTIVE_LOW, IPT_UNKNOWN )
4336 
4337 	PORT_START        /* 680002.w */
4338 	PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_JOYSTICK_UP | IPF_8WAY | IPF_PLAYER2 )
4339 	PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | IPF_8WAY | IPF_PLAYER2 )
4340 	PORT_BIT( 0x0400, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_8WAY | IPF_PLAYER2 )
4341 	PORT_BIT( 0x0800, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_8WAY | IPF_PLAYER2 )
4342 	PORT_BIT( 0x1000, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER2 )
4343 	PORT_BIT( 0x2000, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_PLAYER2 )
4344 	PORT_BIT( 0x4000, IP_ACTIVE_LOW, IPT_BUTTON3 | IPF_PLAYER2 )
4345 	PORT_BIT( 0x8000, IP_ACTIVE_LOW, IPT_UNKNOWN )
4346 
4347 	PORT_START   /* 680000.w */
4348 	PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_START1 )
4349 	PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_START2 )
4350 	PORT_BIT_IMPULSE( 0x0400, IP_ACTIVE_LOW, IPT_COIN1, 2 )
4351 	PORT_BIT_IMPULSE( 0x0800, IP_ACTIVE_LOW, IPT_COIN2, 2 )
4352 	PORT_BITX( 0x1000, IP_ACTIVE_LOW, IPT_SERVICE, DEF_STR( Service_Mode ), KEYCODE_F2, IP_JOY_NONE )
4353 	PORT_BIT( 0x2000, IP_ACTIVE_LOW, IPT_TILT )
4354 	PORT_BIT( 0x4000, IP_ACTIVE_LOW, IPT_SERVICE1 )
4355 	PORT_BIT( 0x8000, IP_ACTIVE_LOW, IPT_UNKNOWN )
4356 
4357 	PORT_START       /* ? - 680006.w */
4358 	PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_UNKNOWN )
4359 	PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_UNKNOWN )
4360 	PORT_BIT( 0x0400, IP_ACTIVE_LOW, IPT_UNKNOWN )
4361 	PORT_BIT( 0x0800, IP_ACTIVE_LOW, IPT_UNKNOWN )
4362 	PORT_BIT( 0x1000, IP_ACTIVE_LOW, IPT_UNKNOWN )
4363 	PORT_BIT( 0x2000, IP_ACTIVE_LOW, IPT_UNKNOWN )
4364 	PORT_BIT( 0x4000, IP_ACTIVE_LOW, IPT_UNKNOWN )
4365 	PORT_BIT( 0x8000, IP_ACTIVE_LOW, IPT_UNKNOWN )
4366 
4367 	PORT_START
4368 	PORT_DIPNAME( 0x01, 0x01, DEF_STR( Flip_Screen ) )
4369 	PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
4370 	PORT_DIPSETTING(    0x00, DEF_STR( On ) )
4371 	PORT_DIPNAME( 0x02, 0x02, "Unused" ) /* Listed as "Unused" */
4372 	PORT_DIPNAME( 0x1c, 0x1c, DEF_STR( Coin_A ) )
4373 	PORT_DIPSETTING(    0x00, DEF_STR( 4C_1C ) )
4374 	PORT_DIPSETTING(    0x04, DEF_STR( 3C_1C ) )
4375 	PORT_DIPSETTING(    0x0c, DEF_STR( 2C_1C ) )
4376 	PORT_DIPSETTING(    0x1c, DEF_STR( 1C_1C ) )
4377 	PORT_DIPSETTING(    0x08, DEF_STR( 2C_3C ) )
4378 	PORT_DIPSETTING(    0x18, DEF_STR( 1C_2C ) )
4379 	PORT_DIPSETTING(    0x14, DEF_STR( 1C_3C ) )
4380 	PORT_DIPSETTING(    0x10, DEF_STR( 1C_4C ) )
4381 	PORT_DIPNAME( 0xe0, 0xe0, DEF_STR( Coin_B ) )
4382 	PORT_DIPSETTING(    0x60, DEF_STR( 2C_1C ) )
4383 	PORT_DIPSETTING(    0xe0, DEF_STR( 1C_1C ) )
4384 	PORT_DIPSETTING(    0x40, DEF_STR( 2C_3C ) )
4385 	PORT_DIPSETTING(    0xc0, DEF_STR( 1C_2C ) )
4386 	PORT_DIPSETTING(    0xa0, DEF_STR( 1C_3C ) )
4387 	PORT_DIPSETTING(    0x80, DEF_STR( 1C_4C ) )
4388 	PORT_DIPSETTING(    0x20, DEF_STR( 1C_5C ) )
4389 	PORT_DIPSETTING(    0x00, DEF_STR( 1C_6C ) )
4390 
4391 	PORT_START
4392 	PORT_DIPNAME( 0x03, 0x03, DEF_STR( Difficulty ) )
4393 	PORT_DIPSETTING(    0x02, "Easy" )
4394 	PORT_DIPSETTING(    0x03, "Normal" )
4395 	PORT_DIPSETTING(    0x01, "Hard" )
4396 	PORT_DIPSETTING(    0x00, "Hardest" )
4397 	PORT_DIPNAME(       0x04, 0x04, "Timer Speed" )
4398 	PORT_DIPSETTING(    0x00, "Slow" )
4399 	PORT_DIPSETTING(    0x04, "Standard" )
4400 	PORT_DIPNAME(       0x18, 0x18, "Language" )
4401 	PORT_DIPSETTING(    0x00, "Invalid" ) /* Japanese text, Korean Kaneko logo 'Unusued' according to test mode*/
4402 	PORT_DIPSETTING(    0x08, "Korea" )
4403 	PORT_DIPSETTING(    0x10, "Japan" )
4404 	PORT_DIPSETTING(    0x18, "World" )
4405 	PORT_DIPNAME( 0x20, 0x20, DEF_STR( Free_Play ) )
4406 	PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
4407 	PORT_DIPSETTING(    0x00, DEF_STR( On ) )
4408 	PORT_DIPNAME( 0x40, 0x40, DEF_STR( Demo_Sounds ) )
4409 	PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
4410 	PORT_DIPSETTING(    0x40, DEF_STR( On ) )
4411 	PORT_SERVICE( 0x80, IP_ACTIVE_LOW )
4412 INPUT_PORTS_END
4413 
4414 /***************************************************************************
4415 									Blaze On
4416 ***************************************************************************/
4417 
4418 INPUT_PORTS_START( blazeon )
4419 	PORT_START	/* IN0 - Player 1 + DSW - c00000.w*/
4420 	PORT_DIPNAME( 0x0003, 0x0003, DEF_STR( Difficulty ) )
4421 	PORT_DIPSETTING(      0x0002, "Easy"    )
4422 	PORT_DIPSETTING(      0x0003, "Normal"  )
4423 	PORT_DIPSETTING(      0x0001, "Hard"    )
4424 	PORT_DIPSETTING(      0x0000, "Hardest" )
4425 	PORT_DIPNAME( 0x000c, 0x000c, DEF_STR( Lives ) )
4426 	PORT_DIPSETTING(      0x0000, "2" )
4427 	PORT_DIPSETTING(      0x000c, "3" )
4428 	PORT_DIPSETTING(      0x0008, "4" )
4429 	PORT_DIPSETTING(      0x0004, "5" )
4430 	PORT_DIPNAME( 0x0010, 0x0010, DEF_STR( Demo_Sounds ) )
4431 	PORT_DIPSETTING(      0x0000, DEF_STR( Off ) )
4432 	PORT_DIPSETTING(      0x0010, DEF_STR( On ) )
4433 	PORT_DIPNAME( 0x0020, 0x0020, "Unknown 1-5" )
4434 	PORT_DIPSETTING(      0x0020, DEF_STR( Off ) )
4435 	PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
4436 	PORT_DIPNAME( 0x0040, 0x0040, "Unknown 1-6" )
4437 	PORT_DIPSETTING(      0x0040, DEF_STR( Off ) )
4438 	PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
4439 	PORT_SERVICE( 0x0080, IP_ACTIVE_LOW )
4440 
4441 	PORT_BIT(  0x0100, IP_ACTIVE_LOW, IPT_JOYSTICK_UP    | IPF_PLAYER1 )
4442 	PORT_BIT(  0x0200, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN  | IPF_PLAYER1 )
4443 	PORT_BIT(  0x0400, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT  | IPF_PLAYER1 )
4444 	PORT_BIT(  0x0800, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_PLAYER1 )
4445 	PORT_BIT(  0x1000, IP_ACTIVE_LOW, IPT_BUTTON1        | IPF_PLAYER1 )
4446 	PORT_BIT(  0x2000, IP_ACTIVE_LOW, IPT_BUTTON2        | IPF_PLAYER1 )
4447 	PORT_BIT(  0x4000, IP_ACTIVE_LOW, IPT_START1                       )
4448 	PORT_BIT_IMPULSE( 0x8000, IP_ACTIVE_LOW, IPT_COIN1, 2 )
4449 
4450 	PORT_START	/* IN1 - Player 2 - c00002.w*/
4451 	PORT_DIPNAME( 0x000f, 0x000f, DEF_STR( Coin_A ) )
4452 	PORT_DIPSETTING(      0x0007, DEF_STR( 4C_1C ) )
4453 	PORT_DIPSETTING(      0x0008, DEF_STR( 3C_1C ) )
4454 	PORT_DIPSETTING(      0x0005, "6 Coins/3 Credits" )
4455 	PORT_DIPSETTING(      0x0009, DEF_STR( 2C_1C ) )
4456 	PORT_DIPSETTING(      0x0004, DEF_STR( 4C_3C ) )
4457 	PORT_DIPSETTING(      0x000f, DEF_STR( 1C_1C ) )
4458 /*	PORT_DIPSETTING(      0x0000, DEF_STR( 1C_1C ) )*/
4459 	PORT_DIPSETTING(      0x0003, "5 Coins/6 Credits" )
4460 	PORT_DIPSETTING(      0x0002, DEF_STR( 4C_5C ) )
4461 	PORT_DIPSETTING(      0x0006, DEF_STR( 2C_3C ) )
4462 /*	PORT_DIPSETTING(      0x0001, DEF_STR( 2C_3C ) )*/
4463 	PORT_DIPSETTING(      0x000e, DEF_STR( 1C_2C ) )
4464 	PORT_DIPSETTING(      0x000d, DEF_STR( 1C_3C ) )
4465 	PORT_DIPSETTING(      0x000c, DEF_STR( 1C_4C ) )
4466 	PORT_DIPSETTING(      0x000b, DEF_STR( 1C_5C ) )
4467 	PORT_DIPSETTING(      0x000a, DEF_STR( 1C_6C ) )
4468 
4469 	PORT_DIPNAME( 0x00f0, 0x00f0, DEF_STR( Coin_B ) )
4470 	PORT_DIPSETTING(      0x0070, DEF_STR( 4C_1C ) )
4471 	PORT_DIPSETTING(      0x0080, DEF_STR( 3C_1C ) )
4472 	PORT_DIPSETTING(      0x0050, "6 Coins/3 Credits" )
4473 	PORT_DIPSETTING(      0x0090, DEF_STR( 2C_1C ) )
4474 	PORT_DIPSETTING(      0x0040, DEF_STR( 4C_3C ) )
4475 	PORT_DIPSETTING(      0x00f0, DEF_STR( 1C_1C ) )
4476 /*	PORT_DIPSETTING(      0x0000, DEF_STR( 1C_1C ) )*/
4477 	PORT_DIPSETTING(      0x0030, "5 Coins/6 Credits" )
4478 	PORT_DIPSETTING(      0x0020, DEF_STR( 4C_5C ) )
4479 	PORT_DIPSETTING(      0x0060, DEF_STR( 2C_3C ) )
4480 /*	PORT_DIPSETTING(      0x0010, DEF_STR( 2C_3C ) )*/
4481 	PORT_DIPSETTING(      0x00e0, DEF_STR( 1C_2C ) )
4482 	PORT_DIPSETTING(      0x00d0, DEF_STR( 1C_3C ) )
4483 	PORT_DIPSETTING(      0x00c0, DEF_STR( 1C_4C ) )
4484 	PORT_DIPSETTING(      0x00b0, DEF_STR( 1C_5C ) )
4485 	PORT_DIPSETTING(      0x00a0, DEF_STR( 1C_6C ) )
4486 
4487 	PORT_BIT(  0x0100, IP_ACTIVE_LOW, IPT_JOYSTICK_UP    | IPF_PLAYER2 )
4488 	PORT_BIT(  0x0200, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN  | IPF_PLAYER2 )
4489 	PORT_BIT(  0x0400, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT  | IPF_PLAYER2 )
4490 	PORT_BIT(  0x0800, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_PLAYER2 )
4491 	PORT_BIT(  0x1000, IP_ACTIVE_LOW, IPT_BUTTON1        | IPF_PLAYER2 )
4492 	PORT_BIT(  0x2000, IP_ACTIVE_LOW, IPT_BUTTON2        | IPF_PLAYER2 )
4493 	PORT_BIT(  0x4000, IP_ACTIVE_LOW, IPT_START2                       )
4494 	PORT_BIT_IMPULSE( 0x8000, IP_ACTIVE_LOW, IPT_COIN2, 2 )
4495 
4496 	PORT_START	/* IN2 - ? - c00004.w*/
4497 	PORT_BIT(  0xffff, IP_ACTIVE_LOW, IPT_UNKNOWN )	/* unused?*/
4498 
4499 	PORT_START	/* IN3 - Other Buttons - c00006.w*/
4500 	PORT_BIT(  0x0100, IP_ACTIVE_LOW, IPT_UNKNOWN )
4501 	PORT_BIT(  0x0200, IP_ACTIVE_LOW, IPT_UNKNOWN )
4502 	PORT_BIT(  0x0400, IP_ACTIVE_LOW, IPT_UNKNOWN )
4503 	PORT_BIT(  0x0800, IP_ACTIVE_LOW, IPT_UNKNOWN )
4504 	PORT_BIT(  0x1000, IP_ACTIVE_LOW, IPT_UNKNOWN )
4505 	PORT_BITX( 0x2000, IP_ACTIVE_LOW, IPT_SERVICE, DEF_STR( Service_Mode ), KEYCODE_F2, IP_JOY_NONE )
4506 	PORT_BIT(  0x4000, IP_ACTIVE_LOW, IPT_TILT  )
4507 	PORT_BIT(  0x8000, IP_ACTIVE_LOW, IPT_SERVICE1 )
4508 INPUT_PORTS_END
4509 
4510 /***************************************************************************
4511 								Blood Warrior
4512 ***************************************************************************/
4513 
4514 INPUT_PORTS_START( bloodwar )
4515 	PORT_START	/* IN0 - Player 2 - b00000.w*/
4516 	PORT_BIT(  0x0100, IP_ACTIVE_LOW, IPT_JOYSTICK_UP		|	IPF_PLAYER1 )
4517 	PORT_BIT(  0x0200, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN		|	IPF_PLAYER1 )
4518 	PORT_BIT(  0x0400, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT		|	IPF_PLAYER1 )
4519 	PORT_BIT(  0x0800, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT	|	IPF_PLAYER1 )
4520 	PORT_BIT(  0x1000, IP_ACTIVE_LOW, IPT_BUTTON1			|	IPF_PLAYER1 )
4521 	PORT_BIT(  0x2000, IP_ACTIVE_LOW, IPT_BUTTON2			|	IPF_PLAYER1 )
4522 	PORT_BIT(  0x4000, IP_ACTIVE_LOW, IPT_BUTTON3			|	IPF_PLAYER1 )
4523 	PORT_BIT(  0x8000, IP_ACTIVE_LOW, IPT_BUTTON4			|	IPF_PLAYER1 )
4524 
4525 	PORT_START	/* IN1 - Player 2 - b00002.w*/
4526 	PORT_BIT(  0x0100, IP_ACTIVE_LOW, IPT_JOYSTICK_UP		|	IPF_PLAYER2 )
4527 	PORT_BIT(  0x0200, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN		|	IPF_PLAYER2 )
4528 	PORT_BIT(  0x0400, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT		|	IPF_PLAYER2 )
4529 	PORT_BIT(  0x0800, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT	|	IPF_PLAYER2 )
4530 	PORT_BIT(  0x1000, IP_ACTIVE_LOW, IPT_BUTTON1			|	IPF_PLAYER2 )
4531 	PORT_BIT(  0x2000, IP_ACTIVE_LOW, IPT_BUTTON2			|	IPF_PLAYER2 )
4532 	PORT_BIT(  0x4000, IP_ACTIVE_LOW, IPT_BUTTON3			|	IPF_PLAYER2 )
4533 	PORT_BIT(  0x8000, IP_ACTIVE_LOW, IPT_BUTTON4			|	IPF_PLAYER2 )
4534 
4535 	PORT_START	/* IN2 - Coins - b00004.w*/
4536 	PORT_BIT(  0x0100, IP_ACTIVE_LOW, IPT_START1	)
4537 	PORT_BIT(  0x0200, IP_ACTIVE_LOW, IPT_START2	)
4538 	PORT_BIT_IMPULSE( 0x0400, IP_ACTIVE_LOW, IPT_COIN1, 2 )
4539 	PORT_BIT_IMPULSE( 0x0800, IP_ACTIVE_LOW, IPT_COIN2, 2 )
4540 	PORT_BITX( 0x1000, IP_ACTIVE_LOW, IPT_SERVICE, DEF_STR( Service_Mode ), KEYCODE_F2, IP_JOY_NONE )
4541 	PORT_BIT(  0x2000, IP_ACTIVE_LOW, IPT_TILT		)
4542 	PORT_BIT(  0x4000, IP_ACTIVE_LOW, IPT_SERVICE1	)
4543 	PORT_BIT(  0x8000, IP_ACTIVE_LOW, IPT_SERVICE2	)	/* tested*/
4544 
4545 	PORT_START	/* IN3 - ? - b00006.w*/
4546 	PORT_BIT(  0x0100, IP_ACTIVE_LOW, IPT_UNKNOWN )	/* tested*/
4547 	PORT_BIT(  0x0200, IP_ACTIVE_LOW, IPT_UNKNOWN )
4548 	PORT_BIT(  0x0400, IP_ACTIVE_LOW, IPT_UNKNOWN )	/* tested*/
4549 	PORT_BIT(  0x0800, IP_ACTIVE_LOW, IPT_UNKNOWN )
4550 	PORT_BIT(  0x1000, IP_ACTIVE_LOW, IPT_UNKNOWN )
4551 	PORT_BIT(  0x2000, IP_ACTIVE_LOW, IPT_UNKNOWN )
4552 	PORT_BIT(  0x4000, IP_ACTIVE_LOW, IPT_UNKNOWN )
4553 	PORT_BIT(  0x8000, IP_ACTIVE_LOW, IPT_UNKNOWN )
4554 
4555 	PORT_START	/* IN4 - DSW from the MCU - $10497e.b <- $208000.b*/
4556 	PORT_DIPNAME( 0x0100, 0x0000, DEF_STR( Demo_Sounds ) )
4557 	PORT_DIPSETTING(      0x0100, DEF_STR( Off ) )
4558 	PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
4559 	PORT_SERVICE( 0x0200, IP_ACTIVE_LOW )
4560 	PORT_DIPNAME( 0x0400, 0x0400, DEF_STR( Flip_Screen ) )
4561 	PORT_DIPSETTING(      0x0400, DEF_STR( Off ) )
4562 	PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
4563 	PORT_DIPNAME( 0x3800, 0x3800, DEF_STR( Difficulty ) )
4564 	PORT_DIPSETTING(      0x3800, "1 Easy" )
4565 	PORT_DIPSETTING(      0x3000, "2" )
4566 	PORT_DIPSETTING(      0x2800, "3" )
4567 	PORT_DIPSETTING(      0x2000, "4" )
4568 	PORT_DIPSETTING(      0x1800, "5" )
4569 	PORT_DIPSETTING(      0x1000, "6" )
4570 	PORT_DIPSETTING(      0x0800, "7" )
4571 	PORT_DIPSETTING(      0x0000, "8 Hard" )
4572 	PORT_DIPNAME( 0x4000, 0x4000, "Join During Game" )
4573 	PORT_DIPSETTING(      0x0000, DEF_STR( Off ) )
4574 	PORT_DIPSETTING(      0x4000, DEF_STR( On ) )
4575 	PORT_DIPNAME( 0x8000, 0x8000, "Allow Continue" )
4576 	PORT_DIPSETTING(      0x8000, DEF_STR( Off ) )
4577 	PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
4578 INPUT_PORTS_END
4579 
4580 /***************************************************************************
4581 							Great 1000 Miles Rally
4582 ***************************************************************************/
4583 
4584 INPUT_PORTS_START( gtmr )
4585 	PORT_START	/* IN0 - Player 1 - b00000.w*/
4586 	PORT_BIT(  0x0100, IP_ACTIVE_LOW, IPT_JOYSTICK_UP    | IPF_8WAY | IPF_PLAYER1 )
4587 	PORT_BIT(  0x0200, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN  | IPF_8WAY | IPF_PLAYER1 )
4588 	PORT_BIT(  0x0400, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT  | IPF_8WAY | IPF_PLAYER1 )
4589 	PORT_BIT(  0x0800, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_8WAY | IPF_PLAYER1 )
4590 	PORT_BIT(  0x1000, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_PLAYER1 ) /* swapped for consistency:*/
4591 	PORT_BIT(  0x2000, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER1 ) /* button1 is usually accel.*/
4592 	PORT_BIT(  0x4000, IP_ACTIVE_LOW, IPT_UNKNOWN )
4593 	PORT_BIT(  0x8000, IP_ACTIVE_LOW, IPT_UNKNOWN )
4594 
4595 	PORT_START	/* IN1 - Player 2 - b00002.w*/
4596 	PORT_BIT(  0x0100, IP_ACTIVE_LOW, IPT_JOYSTICK_UP    | IPF_8WAY | IPF_PLAYER2 )
4597 	PORT_BIT(  0x0200, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN  | IPF_8WAY | IPF_PLAYER2 )
4598 	PORT_BIT(  0x0400, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT  | IPF_8WAY | IPF_PLAYER2 )
4599 	PORT_BIT(  0x0800, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_8WAY | IPF_PLAYER2 )
4600 	PORT_BIT(  0x1000, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_PLAYER2 ) /* swapped for consistency:*/
4601 	PORT_BIT(  0x2000, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER2 ) /* button1 is usually accel.*/
4602 	PORT_BIT(  0x4000, IP_ACTIVE_LOW, IPT_UNKNOWN )
4603 	PORT_BIT(  0x8000, IP_ACTIVE_LOW, IPT_UNKNOWN )
4604 
4605 	PORT_START	/* IN2 - Coins - b00004.w*/
4606 	PORT_BIT(  0x0100, IP_ACTIVE_LOW, IPT_START1	)
4607 	PORT_BIT(  0x0200, IP_ACTIVE_LOW, IPT_START2	)
4608 	PORT_BIT_IMPULSE( 0x0400, IP_ACTIVE_LOW, IPT_COIN1, 2 )
4609 	PORT_BIT_IMPULSE( 0x0800, IP_ACTIVE_LOW, IPT_COIN2, 2 )
4610 	PORT_BITX( 0x1000, IP_ACTIVE_LOW, IPT_SERVICE, DEF_STR( Service_Mode ), KEYCODE_F2, IP_JOY_NONE )
4611 	PORT_BIT(  0x2000, IP_ACTIVE_LOW, IPT_TILT		)
4612 	PORT_BIT(  0x4000, IP_ACTIVE_LOW, IPT_SERVICE1	)
4613 	PORT_BIT(  0x8000, IP_ACTIVE_LOW, IPT_UNKNOWN	)
4614 
4615 	PORT_START	/* IN3 - Seems unused ! - b00006.w*/
4616 	PORT_BIT(  0x0100, IP_ACTIVE_LOW, IPT_UNKNOWN )
4617 	PORT_BIT(  0x0200, IP_ACTIVE_LOW, IPT_UNKNOWN )
4618 	PORT_BIT(  0x0400, IP_ACTIVE_LOW, IPT_UNKNOWN )
4619 	PORT_BIT(  0x0800, IP_ACTIVE_LOW, IPT_UNKNOWN )
4620 	PORT_BIT(  0x1000, IP_ACTIVE_LOW, IPT_UNKNOWN )
4621 	PORT_BIT(  0x2000, IP_ACTIVE_LOW, IPT_UNKNOWN )
4622 	PORT_BIT(  0x4000, IP_ACTIVE_LOW, IPT_UNKNOWN )
4623 	PORT_BIT(  0x8000, IP_ACTIVE_LOW, IPT_UNKNOWN )
4624 
4625 	PORT_START	/* IN4 - DSW from the MCU - 101265.b <- 206000.b*/
4626 	PORT_SERVICE( 0x0100, IP_ACTIVE_LOW )
4627 	PORT_DIPNAME( 0x0200, 0x0200, DEF_STR( Flip_Screen ) )
4628 	PORT_DIPSETTING(      0x0200, DEF_STR( Off ) )
4629 	PORT_DIPSETTING(      0x0000, DEF_STR( On )  )
4630 	PORT_DIPNAME( 0x0400, 0x0400, DEF_STR( Cabinet )  )
4631 	PORT_DIPSETTING(      0x0400, DEF_STR( Upright )  )
4632 	PORT_DIPSETTING(      0x0000, DEF_STR( Cocktail ) )
4633 	PORT_DIPNAME( 0x1800, 0x1800, "Controls"    )
4634 	PORT_DIPSETTING(      0x1800, "1 Joystick"  )
4635 	PORT_DIPSETTING(      0x0800, "2 Joysticks" )
4636 	PORT_DIPSETTING(      0x1000, "Wheel (360)" )
4637 	PORT_DIPSETTING(      0x0000, "Wheel (270)" )
4638 	PORT_DIPNAME( 0x2000, 0x2000, "Use Brake"    )
4639 	PORT_DIPSETTING(      0x0000, DEF_STR( Off ) )
4640 	PORT_DIPSETTING(      0x2000, DEF_STR( On )  )
4641 	PORT_DIPNAME( 0xc000, 0xc000, "National Anthem & Flag" )
4642 	PORT_DIPSETTING(      0xc000, "Use Memory"  )
4643 	PORT_DIPSETTING(      0x8000, "Anthem Only" )
4644 	PORT_DIPSETTING(      0x4000, "Flag Only"   )
4645 	PORT_DIPSETTING(      0x0000, "None"        )
4646 
4647 	PORT_START	/* IN5 - Wheel - 100015.b <- ffffe.b*/
4648 	PORT_ANALOG ( 0x00ff, 0x0080, IPT_AD_STICK_X | IPF_CENTER, 30, 1, 0x00, 0xff )
4649 INPUT_PORTS_END
4650 
4651 
4652 /***************************************************************************
4653 							Great 1000 Miles Rally 2
4654 ***************************************************************************/
4655 
4656 INPUT_PORTS_START( gtmr2 )
4657 	PORT_START	/* IN0 - Player 1 - 100004.w <- b00000.w (cpl)*/
4658 	PORT_BIT(  0x0100, IP_ACTIVE_LOW, IPT_JOYSTICK_UP    | IPF_8WAY | IPF_PLAYER1 )
4659 	PORT_BIT(  0x0200, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN  | IPF_8WAY | IPF_PLAYER1 )
4660 	PORT_BIT(  0x0400, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT  | IPF_8WAY | IPF_PLAYER1 )
4661 	PORT_BIT(  0x0800, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_8WAY | IPF_PLAYER1 )
4662 	PORT_BIT(  0x1000, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_PLAYER1 ) /* swapped for consistency:*/
4663 	PORT_BIT(  0x2000, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER1 ) /* button1 is usually accel.*/
4664 	PORT_BIT(  0x4000, IP_ACTIVE_LOW, IPT_UNKNOWN )
4665 	PORT_BIT(  0x8000, IP_ACTIVE_LOW, IPT_UNKNOWN )
4666 
4667 	PORT_START	/* IN1 - Player 2 - 10000c.w <- b00002.w (cpl) - for "test mode" only*/
4668 	PORT_BIT(  0x0100, IP_ACTIVE_LOW, IPT_JOYSTICK_UP    | IPF_8WAY | IPF_PLAYER2 )
4669 	PORT_BIT(  0x0200, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN  | IPF_8WAY | IPF_PLAYER2 )
4670 	PORT_BIT(  0x0400, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT  | IPF_8WAY | IPF_PLAYER2 )
4671 	PORT_BIT(  0x0800, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_8WAY | IPF_PLAYER2 )
4672 	PORT_BIT(  0x1000, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_PLAYER2 ) /* swapped for consistency:*/
4673 	PORT_BIT(  0x2000, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER2 ) /* button1 is usually accel.*/
4674 	PORT_BIT(  0x4000, IP_ACTIVE_LOW, IPT_UNKNOWN )
4675 	PORT_BIT(  0x8000, IP_ACTIVE_LOW, IPT_UNKNOWN )
4676 
4677 	PORT_START	/* IN2 - Coins - 100014.w <- b00004.w (cpl)*/
4678 	PORT_BIT(  0x0100, IP_ACTIVE_LOW, IPT_START1	)
4679 	PORT_BIT(  0x0200, IP_ACTIVE_LOW, IPT_START2	)	/* only in "test mode"*/
4680 	PORT_BIT_IMPULSE( 0x0400, IP_ACTIVE_LOW, IPT_COIN1, 2 )
4681 	PORT_BIT_IMPULSE( 0x0800, IP_ACTIVE_LOW, IPT_COIN2, 2 )
4682 	PORT_BITX( 0x1000, IP_ACTIVE_LOW, IPT_SERVICE, DEF_STR( Service_Mode ), KEYCODE_F2, IP_JOY_NONE )
4683 	PORT_BIT(  0x2000, IP_ACTIVE_LOW, IPT_TILT	)
4684 	PORT_BIT(  0x4000, IP_ACTIVE_LOW, IPT_SERVICE1	)
4685 	PORT_BIT(  0x8000, IP_ACTIVE_LOW, IPT_UNKNOWN	)
4686 
4687 	PORT_START	/* IN3 - 100017.w <- b00006.w*/
4688 	PORT_BIT(  0x0100, IP_ACTIVE_LOW, IPT_UNKNOWN )
4689 	PORT_BIT(  0x0200, IP_ACTIVE_LOW, IPT_UNKNOWN )
4690 	PORT_BIT(  0x0400, IP_ACTIVE_LOW, IPT_UNKNOWN )
4691 	PORT_BIT(  0x0800, IP_ACTIVE_LOW, IPT_UNKNOWN )
4692 	PORT_BIT(  0x1000, IP_ACTIVE_LOW, IPT_UNKNOWN )
4693 	PORT_BIT(  0x2000, IP_ACTIVE_LOW, IPT_UNKNOWN )
4694 	PORT_BITX( 0x4000, IP_ACTIVE_LOW, IPT_BUTTON3, "IN 3-6", IP_KEY_DEFAULT, IP_JOY_NONE )	/* Code at 0x002236 - Centers 270D wheel ?*/
4695 	PORT_BIT(  0x8000, IP_ACTIVE_LOW, IPT_UNKNOWN )
4696 
4697 	PORT_START	/* IN4 - DSW from the MCU - 1016f7.b <- 206000.b*/
4698 	PORT_DIPNAME( 0x0700, 0x0700, "Communication" )
4699 	PORT_DIPSETTING(      0x0700, "None" )
4700 	PORT_DIPSETTING(      0x0600, "Machine 1" )
4701 	PORT_DIPSETTING(      0x0500, "Machine 2" )
4702 	PORT_DIPSETTING(      0x0400, "Machine 3" )
4703 	PORT_DIPSETTING(      0x0300, "Machine 4" )
4704 	/* 0x0000 to 0x0200 : "Machine 4"
4705 	PORT_DIPSETTING(      0x0200, "Machine 4 (0x0200)" )
4706 	PORT_DIPSETTING(      0x0100, "Machine 4 (0x0100)" )
4707 	PORT_DIPSETTING(      0x0000, "Machine 4 (0x0000)" )
4708 	*/
4709 	PORT_DIPNAME( 0x1800, 0x1800, "Controls" )
4710 	PORT_DIPSETTING(      0x1800, "Joystick" )
4711 	PORT_DIPSETTING(      0x0800, "Wheel (360)" )			/* Not working correctly in race*/
4712 	PORT_DIPSETTING(      0x1000, "Wheel (270D)" )			/* Not working correctly !*/
4713 	PORT_DIPSETTING(      0x0000, "Wheel (270A)" )			/* Not working correctly in race*/
4714 	PORT_DIPNAME( 0x2000, 0x2000, "Pedal Function" )
4715 	PORT_DIPSETTING(      0x2000, "Microswitch" )
4716 /*	PORT_DIPSETTING(      0x0000, "Potentiometer" )			*/ /* Not implemented yet*/
4717 	PORT_DIPNAME( 0x4000, 0x4000, DEF_STR( Flip_Screen ) )
4718 	PORT_DIPSETTING(      0x4000, DEF_STR( Off ) )
4719 	PORT_DIPSETTING(      0x0000, DEF_STR( On )  )
4720 	PORT_SERVICE( 0x8000, IP_ACTIVE_LOW )
4721 
4722 	PORT_START	/* IN5 - Wheel (270A) - 100019.b <- fffff.b*/
4723 	PORT_ANALOG ( 0x00ff, 0x0080, IPT_AD_STICK_X | IPF_CENTER, 30, 1, 0x00, 0xff )
4724 
4725 	PORT_START	/* IN6 - Wheel (270D) - 100019.b <- ffffe.b*/
4726 	PORT_ANALOG ( 0x00ff, 0x0080, IPT_AD_STICK_X, 30, 1, 0x00, 0xff )
4727 
4728 	PORT_START	/* IN7 - Wheel (360) - 100019.b <- ffffe.b*/
4729 	PORT_ANALOGX( 0x00ff, 0x0080, IPT_DIAL, 30, 1, 0, 0, KEYCODE_LEFT, KEYCODE_RIGHT, IP_JOY_NONE, IP_JOY_NONE )
4730 
4731 	PORT_START	/* Fake IN1 - To be pressed during boot sequence - Code at 0x000c9e*/
4732 	PORT_BITX( 0x0100, IP_ACTIVE_LOW, IPT_BUTTON5, "IN 1-0", KEYCODE_H, IP_JOY_NONE )	/* "sound test"*/
4733 	PORT_BIT(  0x2000, IP_ACTIVE_LOW, IPT_UNKNOWN )
4734 	PORT_BIT(  0x4000, IP_ACTIVE_LOW, IPT_UNKNOWN )
4735 	PORT_BIT(  0x8000, IP_ACTIVE_LOW, IPT_UNKNOWN )
4736 	PORT_BITX( 0x1000, IP_ACTIVE_LOW, IPT_BUTTON6, "IN 1-4", KEYCODE_J, IP_JOY_NONE )	/* "view tiles"*/
4737 	PORT_BITX( 0x2000, IP_ACTIVE_LOW, IPT_BUTTON7, "IN 1-5", KEYCODE_K, IP_JOY_NONE )	/* "view memory"*/
4738 	PORT_BITX( 0x4000, IP_ACTIVE_LOW, IPT_BUTTON8, "IN 1-6", KEYCODE_L, IP_JOY_NONE )	/* "view sprites ?"*/
4739 	PORT_BIT(  0x8000, IP_ACTIVE_LOW, IPT_UNKNOWN )
4740 INPUT_PORTS_END
4741 
4742 
4743 /***************************************************************************
4744 								Magical Crystal
4745 ***************************************************************************/
4746 
4747 INPUT_PORTS_START( mgcrystl )
4748 	PORT_START	/* IN0 - Player 1 + DSW - c00000.w*/
4749 	PORT_DIPNAME( 0x0001, 0x0001, DEF_STR( Flip_Screen ) )
4750 	PORT_DIPSETTING(      0x0001, DEF_STR( Off ) )
4751 	PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
4752 	PORT_SERVICE( 0x0002, IP_ACTIVE_LOW )
4753 	PORT_DIPNAME( 0x0004, 0x0004, DEF_STR( Unknown ) )
4754 	PORT_DIPSETTING(      0x0004, DEF_STR( Off ) )
4755 	PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
4756 	PORT_DIPNAME( 0x0008, 0x0008, DEF_STR( Unknown ) )
4757 	PORT_DIPSETTING(      0x0008, DEF_STR( Off ) )
4758 	PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
4759 	PORT_DIPNAME( 0x0010, 0x0010, DEF_STR( Unknown ) )
4760 	PORT_DIPSETTING(      0x0010, DEF_STR( Off ) )
4761 	PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
4762 	PORT_DIPNAME( 0x0020, 0x0020, DEF_STR( Unknown ) )
4763 	PORT_DIPSETTING(      0x0020, DEF_STR( Off ) )
4764 	PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
4765 	PORT_DIPNAME( 0x0040, 0x0040, DEF_STR( Unknown ) )	/* TESTED!*/
4766 	PORT_DIPSETTING(      0x0040, DEF_STR( Off ) )
4767 	PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
4768 	PORT_DIPNAME( 0x0080, 0x0080, DEF_STR( Unknown ) )
4769 	PORT_DIPSETTING(      0x0080, DEF_STR( Off ) )
4770 	PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
4771 
4772 	PORT_BIT(  0x0100, IP_ACTIVE_LOW, IPT_JOYSTICK_UP    | IPF_PLAYER1 )
4773 	PORT_BIT(  0x0200, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN  | IPF_PLAYER1 )
4774 	PORT_BIT(  0x0400, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT  | IPF_PLAYER1 )
4775 	PORT_BIT(  0x0800, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_PLAYER1 )
4776 	PORT_BIT(  0x1000, IP_ACTIVE_LOW, IPT_BUTTON1        | IPF_PLAYER1 )
4777 	PORT_BIT(  0x2000, IP_ACTIVE_LOW, IPT_BUTTON2        | IPF_PLAYER1 )
4778 	PORT_BIT(  0x4000, IP_ACTIVE_LOW, IPT_UNKNOWN )
4779 	PORT_BIT(  0x8000, IP_ACTIVE_LOW, IPT_UNKNOWN )
4780 
4781 	PORT_START	/* IN1 - Player 2 - c00002.b*/
4782 	PORT_DIPNAME( 0x0001, 0x0001, DEF_STR( Unknown ) )
4783 	PORT_DIPSETTING(      0x0001, DEF_STR( Off ) )
4784 	PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
4785 	PORT_DIPNAME( 0x0002, 0x0002, DEF_STR( Unknown ) )
4786 	PORT_DIPSETTING(      0x0002, DEF_STR( Off ) )
4787 	PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
4788 	PORT_DIPNAME( 0x0004, 0x0004, DEF_STR( Unknown ) )
4789 	PORT_DIPSETTING(      0x0004, DEF_STR( Off ) )
4790 	PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
4791 	PORT_DIPNAME( 0x0008, 0x0008, DEF_STR( Unknown ) )
4792 	PORT_DIPSETTING(      0x0008, DEF_STR( Off ) )
4793 	PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
4794 	PORT_DIPNAME( 0x0010, 0x0010, DEF_STR( Unknown ) )
4795 	PORT_DIPSETTING(      0x0010, DEF_STR( Off ) )
4796 	PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
4797 	PORT_DIPNAME( 0x0020, 0x0020, DEF_STR( Unknown ) )
4798 	PORT_DIPSETTING(      0x0020, DEF_STR( Off ) )
4799 	PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
4800 	PORT_DIPNAME( 0x0040, 0x0040, DEF_STR( Unknown ) )
4801 	PORT_DIPSETTING(      0x0040, DEF_STR( Off ) )
4802 	PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
4803 	PORT_DIPNAME( 0x0080, 0x0080, DEF_STR( Unknown ) )
4804 	PORT_DIPSETTING(      0x0080, DEF_STR( Off ) )
4805 	PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
4806 
4807 	PORT_BIT(  0x0100, IP_ACTIVE_LOW, IPT_JOYSTICK_UP    | IPF_PLAYER2 )
4808 	PORT_BIT(  0x0200, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN  | IPF_PLAYER2 )
4809 	PORT_BIT(  0x0400, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT  | IPF_PLAYER2 )
4810 	PORT_BIT(  0x0800, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_PLAYER2 )
4811 	PORT_BIT(  0x1000, IP_ACTIVE_LOW, IPT_BUTTON1        | IPF_PLAYER2 )
4812 	PORT_BIT(  0x2000, IP_ACTIVE_LOW, IPT_BUTTON2        | IPF_PLAYER2 )
4813 	PORT_BIT(  0x4000, IP_ACTIVE_LOW, IPT_UNKNOWN )
4814 	PORT_BIT(  0x8000, IP_ACTIVE_LOW, IPT_UNKNOWN )
4815 
4816 	PORT_START	/* IN2 - Other Buttons - c00004.b*/
4817 	PORT_BIT ( 0x00ff, IP_ACTIVE_LOW, IPT_UNKNOWN  )
4818 	PORT_BIT ( 0x0100, IP_ACTIVE_LOW, IPT_START1   )
4819 	PORT_BIT ( 0x0200, IP_ACTIVE_LOW, IPT_START2   )
4820 	PORT_BIT_IMPULSE( 0x0400, IP_ACTIVE_LOW, IPT_COIN1, 2 )
4821 	PORT_BIT_IMPULSE( 0x0800, IP_ACTIVE_LOW, IPT_COIN2, 2 )
4822 	PORT_BITX( 0x1000, IP_ACTIVE_LOW, IPT_SERVICE, DEF_STR( Service_Mode ), KEYCODE_F2, IP_JOY_NONE )
4823 	PORT_BIT ( 0x2000, IP_ACTIVE_LOW, IPT_TILT     )
4824 	PORT_BIT ( 0x4000, IP_ACTIVE_LOW, IPT_SERVICE1 )
4825 	PORT_BIT ( 0x8000, IP_ACTIVE_LOW, IPT_UNKNOWN  )
4826 INPUT_PORTS_END
4827 
4828 
4829 /***************************************************************************
4830 								Sand Scorpion
4831 ***************************************************************************/
4832 
4833 INPUT_PORTS_START( sandscrp )
4834 	PORT_START	/* IN0 - $b00000.w*/
4835 	PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_JOYSTICK_UP    | IPF_PLAYER1 )
4836 	PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN	| IPF_PLAYER1 )
4837 	PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT  | IPF_PLAYER1 )
4838 	PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_PLAYER1 )
4839 	PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_BUTTON1        | IPF_PLAYER1 )
4840 	PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_BUTTON2        | IPF_PLAYER1 )
4841 	PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_UNKNOWN )
4842 	PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_UNKNOWN )
4843 
4844 	PORT_BIT( 0xff00, IP_ACTIVE_LOW, IPT_UNKNOWN )
4845 
4846 	PORT_START	/* IN1 - $b00002.w*/
4847 	PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_JOYSTICK_UP    | IPF_PLAYER2 )
4848 	PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN	| IPF_PLAYER2 )
4849 	PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT  | IPF_PLAYER2 )
4850 	PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_PLAYER2 )
4851 	PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_BUTTON1        | IPF_PLAYER2 )
4852 	PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_BUTTON2        | IPF_PLAYER2 )
4853 	PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_UNKNOWN )
4854 	PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_UNKNOWN )
4855 
4856 	PORT_BIT( 0xff00, IP_ACTIVE_LOW, IPT_UNKNOWN )
4857 
4858 	PORT_START	/* IN2 - $b00004.w*/
4859 	PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_START1   )
4860 	PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_START2   )
4861 	PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_COIN1    )
4862 	PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_COIN2    )
4863 	PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_TILT     )
4864 	PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_UNKNOWN  )
4865 	PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_SERVICE1 )
4866 	PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_UNKNOWN  )
4867 
4868 	PORT_BIT( 0xff00, IP_ACTIVE_LOW, IPT_UNKNOWN )
4869 
4870 	PORT_START	/* IN3 - $b00006.w*/
4871 	PORT_BIT( 0xffff, IP_ACTIVE_LOW, IPT_UNKNOWN )
4872 
4873 	PORT_START	/* IN4 - DSW 1 read by the Z80 through the sound chip*/
4874 	PORT_DIPNAME( 0x03, 0x03, DEF_STR( Lives ) )
4875 	PORT_DIPSETTING(    0x02, "1" )
4876 	PORT_DIPSETTING(    0x01, "2" )
4877 	PORT_DIPSETTING(    0x03, "3" )
4878 	PORT_DIPSETTING(    0x00, "5" )
4879 	PORT_DIPNAME( 0x0c, 0x0c, "Bombs" )
4880 	PORT_DIPSETTING(    0x08, "1" )
4881 	PORT_DIPSETTING(    0x04, "2" )
4882 	PORT_DIPSETTING(    0x0c, "3" )
4883 	PORT_DIPSETTING(    0x00, "5" )
4884 	PORT_DIPNAME( 0x30, 0x30, DEF_STR( Difficulty ) )
4885 	PORT_DIPSETTING(    0x30, "Easy"    )
4886 	PORT_DIPSETTING(    0x20, "Normal"  )
4887 	PORT_DIPSETTING(    0x10, "Hard"    )
4888 	PORT_DIPSETTING(    0x00, "Hardest" )
4889 	PORT_DIPNAME( 0xc0, 0xc0, DEF_STR( Bonus_Life ) )
4890 	PORT_DIPSETTING(    0x80, "100K, 300K" )
4891 	PORT_DIPSETTING(    0xc0, "200K, 500K" )
4892 	PORT_DIPSETTING(    0x40, "500K, 1000K" )
4893 	PORT_DIPSETTING(    0x00, "1000K, 3000K" )
4894 
4895 	PORT_START	/* IN5 - DSW 2 read by the Z80 through the sound chip*/
4896 	PORT_DIPNAME( 0x0f, 0x0f, DEF_STR( Coinage ) )
4897 	PORT_DIPSETTING(    0x0a, DEF_STR( 6C_1C ) )
4898 	PORT_DIPSETTING(    0x0b, DEF_STR( 5C_1C ) )
4899 	PORT_DIPSETTING(    0x0c, DEF_STR( 4C_1C ) )
4900 	PORT_DIPSETTING(    0x0d, DEF_STR( 3C_1C ) )
4901 	PORT_DIPSETTING(    0x01, DEF_STR( 8C_3C ) )
4902 	PORT_DIPSETTING(    0x0e, DEF_STR( 2C_1C ) )
4903 	PORT_DIPSETTING(    0x02, DEF_STR( 5C_3C ) )
4904 	PORT_DIPSETTING(    0x03, DEF_STR( 3C_2C ) )
4905 	PORT_DIPSETTING(    0x0f, DEF_STR( 1C_1C ) )
4906 	PORT_DIPSETTING(    0x04, DEF_STR( 2C_3C ) )
4907 	PORT_DIPSETTING(    0x09, DEF_STR( 1C_2C ) )
4908 	PORT_DIPSETTING(    0x08, DEF_STR( 1C_3C ) )
4909 	PORT_DIPSETTING(    0x07, DEF_STR( 1C_4C ) )
4910 	PORT_DIPSETTING(    0x06, DEF_STR( 1C_5C ) )
4911 	PORT_DIPSETTING(    0x05, DEF_STR( 1C_6C ) )
4912 	PORT_DIPSETTING(    0x00, DEF_STR( Free_Play ) )
4913 	PORT_DIPNAME( 0x10, 0x10, DEF_STR( Flip_Screen ) )
4914 	PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
4915 	PORT_DIPSETTING(    0x00, DEF_STR( On ) )
4916 	PORT_DIPNAME( 0x20, 0x20, "Allow Continue" )
4917 	PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
4918 	PORT_DIPSETTING(    0x20, DEF_STR( On ) )
4919 	PORT_DIPNAME( 0x40, 0x40, DEF_STR( Demo_Sounds ) )
4920 	PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
4921 	PORT_DIPSETTING(    0x40, DEF_STR( On ) )
4922 	PORT_SERVICE( 0x80, IP_ACTIVE_LOW )
4923 INPUT_PORTS_END
4924 
4925 
4926 /***************************************************************************
4927 								Shogun Warriors
4928 ***************************************************************************/
4929 
4930 INPUT_PORTS_START( shogwarr )
4931 	PORT_START	/* IN0 - - b80000.w*/
4932 	PORT_BIT(  0x0100, IP_ACTIVE_LOW, IPT_JOYSTICK_UP    | IPF_8WAY | IPF_PLAYER1 )
4933 	PORT_BIT(  0x0200, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN  | IPF_8WAY | IPF_PLAYER1 )
4934 	PORT_BIT(  0x0400, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT  | IPF_8WAY | IPF_PLAYER1 )
4935 	PORT_BIT(  0x0800, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_8WAY | IPF_PLAYER1 )
4936 	PORT_BIT(  0x1000, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER1 )
4937 	PORT_BIT(  0x2000, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_PLAYER1 )
4938 	PORT_BIT(  0x4000, IP_ACTIVE_LOW, IPT_START1 )
4939 	PORT_BIT(  0x8000, IP_ACTIVE_LOW, IPT_COIN1 )
4940 
4941 	PORT_START	/* IN1 - - b80002.w*/
4942 	PORT_BIT(  0x0100, IP_ACTIVE_LOW, IPT_JOYSTICK_UP    | IPF_8WAY | IPF_PLAYER2 )
4943 	PORT_BIT(  0x0200, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN  | IPF_8WAY | IPF_PLAYER2 )
4944 	PORT_BIT(  0x0400, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT  | IPF_8WAY | IPF_PLAYER2 )
4945 	PORT_BIT(  0x0800, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_8WAY | IPF_PLAYER2 )
4946 	PORT_BIT(  0x1000, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER2 )
4947 	PORT_BIT(  0x2000, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_PLAYER2 )
4948 	PORT_BIT( 0x4000, IP_ACTIVE_LOW, IPT_START2 )
4949 	PORT_BIT( 0x8000, IP_ACTIVE_LOW, IPT_COIN2 )
4950 
4951 	PORT_START	/* IN2 - Coins - b80004.w*/
4952 	PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_START1	)
4953 	PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_START2	)
4954 	PORT_BIT( 0x0400, IP_ACTIVE_LOW, IPT_BUTTON4 | IPF_PLAYER1 )
4955 	PORT_BIT( 0x0800, IP_ACTIVE_LOW, IPT_BUTTON3 | IPF_PLAYER1 )
4956 	PORT_BIT( 0x1000, IP_ACTIVE_LOW, IPT_BUTTON3 | IPF_PLAYER2 )
4957 	PORT_BIT( 0x2000, IP_ACTIVE_LOW, IPT_BUTTON4 | IPF_PLAYER2 )
4958 	PORT_BIT( 0x4000, IP_ACTIVE_LOW, IPT_SERVICE1	)
4959 	PORT_BIT( 0x8000, IP_ACTIVE_LOW, IPT_UNKNOWN	)
4960 
4961 	PORT_START	/* IN3 - ? - b80006.w*/
4962 	PORT_BIT(  0x0100, IP_ACTIVE_LOW, IPT_UNKNOWN )
4963 	PORT_BIT(  0x0200, IP_ACTIVE_LOW, IPT_UNKNOWN )
4964 	PORT_BIT(  0x0400, IP_ACTIVE_LOW, IPT_UNKNOWN )
4965 	PORT_BIT(  0x0800, IP_ACTIVE_LOW, IPT_UNKNOWN )
4966 	PORT_BIT(  0x1000, IP_ACTIVE_LOW, IPT_UNKNOWN )
4967 	PORT_BIT(  0x2000, IP_ACTIVE_LOW, IPT_UNKNOWN )
4968 	PORT_BIT(  0x4000, IP_ACTIVE_LOW, IPT_UNKNOWN )
4969 	PORT_BIT(  0x8000, IP_ACTIVE_LOW, IPT_UNKNOWN )
4970 
4971 	PORT_START	/* IN4 - DSW from the MCU - 102e15.b <- 200059.b*/
4972 	PORT_DIPNAME( 0x01, 0x01, DEF_STR( Flip_Screen ) )
4973 	PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
4974 	PORT_DIPSETTING(    0x00, DEF_STR( On ) )
4975 	PORT_SERVICE(0x02, IP_ACTIVE_LOW )
4976 	PORT_DIPNAME( 0x04, 0x04, DEF_STR( Demo_Sounds ) )
4977 	PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
4978 	PORT_DIPSETTING(    0x04, DEF_STR( On ) )
4979 	PORT_DIPNAME( 0x38, 0x38, DEF_STR( Difficulty ) )
4980 	PORT_DIPSETTING(    0x38, "1 Easy" )
4981 	PORT_DIPSETTING(    0x30, "2" )
4982 	PORT_DIPSETTING(    0x28, "3" )
4983 	PORT_DIPSETTING(    0x20, "4 Normal" )
4984 	PORT_DIPSETTING(    0x18, "5" )
4985 	PORT_DIPSETTING(    0x10, "6" )
4986 	PORT_DIPSETTING(    0x08, "7" )
4987 	PORT_DIPSETTING(    0x00, "8 Hard" )
4988 	PORT_DIPNAME( 0x40, 0x40, "Can Join During Game" )
4989 	PORT_DIPSETTING(    0x00, DEF_STR( Off ) )	/*  2 credits       winner vs computer*/
4990 	PORT_DIPSETTING(    0x40, DEF_STR( On ) )	/*  1 credit        game over*/
4991 	PORT_DIPNAME( 0x80, 0x80, "Continue Coin" )
4992 	PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
4993 	PORT_DIPSETTING(    0x00, DEF_STR( On ) )
4994 INPUT_PORTS_END
4995 
4996 /***************************************************************************
4997 								Bonk
4998 ***************************************************************************/
4999 
5000 INPUT_PORTS_START( bonkadv )
5001 	PORT_START 	/* b0000.w */
5002 	PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_JOYSTICK_UP | IPF_PLAYER1 )
5003 	PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | IPF_PLAYER1 )
5004 	PORT_BIT( 0x0400, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_PLAYER1 )
5005 	PORT_BIT( 0x0800, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_PLAYER1 )
5006 	PORT_BIT( 0x1000, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER1 )
5007 	PORT_BIT( 0x2000, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_PLAYER1 )
5008 	PORT_BIT( 0x4000, IP_ACTIVE_LOW, IPT_BUTTON3 | IPF_PLAYER1 )
5009 	PORT_BIT( 0x8000, IP_ACTIVE_LOW, IPT_BUTTON4 | IPF_PLAYER1 )
5010 
5011 	PORT_START 	/* b0002.w */
5012 	PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_JOYSTICK_UP | IPF_PLAYER2 )
5013 	PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | IPF_PLAYER2 )
5014 	PORT_BIT( 0x0400, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_PLAYER2 )
5015 	PORT_BIT( 0x0800, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_PLAYER2 )
5016 	PORT_BIT( 0x1000, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER2 )
5017 	PORT_BIT( 0x2000, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_PLAYER2 )
5018 	PORT_BIT( 0x4000, IP_ACTIVE_LOW, IPT_BUTTON3 | IPF_PLAYER2 )
5019 	PORT_BIT( 0x8000, IP_ACTIVE_LOW, IPT_BUTTON4 | IPF_PLAYER2 )
5020 
5021 	PORT_START  /* b0004.w */
5022 	PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_START1	)
5023 	PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_START2	)
5024 	PORT_BIT( 0x0400, IP_ACTIVE_LOW, IPT_COIN1 ) /*PORT_IMPULSE(2)*/
5025 	PORT_BIT( 0x0800, IP_ACTIVE_LOW, IPT_COIN2 ) /*PORT_IMPULSE(2)*/
5026 	PORT_SERVICE_NO_TOGGLE( 0x1000, IP_ACTIVE_LOW )
5027 	PORT_BIT( 0x2000, IP_ACTIVE_LOW, IPT_TILT )
5028 	PORT_BIT( 0x4000, IP_ACTIVE_LOW, IPT_SERVICE1 )
5029 	PORT_BIT( 0x8000, IP_ACTIVE_LOW, IPT_SERVICE2 )
5030 
5031 	PORT_START 		/* ? - b0006.w */
5032 	PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_UNKNOWN )
5033 	PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_UNKNOWN )
5034 	PORT_BIT( 0x0400, IP_ACTIVE_LOW, IPT_UNKNOWN )
5035 	PORT_BIT( 0x0800, IP_ACTIVE_LOW, IPT_UNKNOWN )
5036 	PORT_BIT( 0x1000, IP_ACTIVE_LOW, IPT_UNKNOWN ) /* tested*/
5037 	PORT_BIT( 0x2000, IP_ACTIVE_LOW, IPT_UNKNOWN ) /* tested*/
5038 	PORT_BIT( 0x4000, IP_ACTIVE_LOW, IPT_UNKNOWN )
5039 	PORT_BIT( 0x8000, IP_ACTIVE_LOW, IPT_UNKNOWN )
5040 
5041 	PORT_START  	/* from the MCU - $10019e.b <- $200200.b */
5042 	PORT_DIPNAME( 0x0100, 0x0100, DEF_STR( Flip_Screen ) )
5043 	PORT_DIPSETTING(      0x0100, DEF_STR( Off ) )
5044 	PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
5045 	PORT_DIPNAME( 0x0200, 0x0200, DEF_STR( Free_Play ) )
5046 	PORT_DIPSETTING(      0x0200, DEF_STR( Off ) )
5047 	PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
5048 	PORT_DIPNAME( 0x0400, 0x0400, DEF_STR( Demo_Sounds ) )
5049 	PORT_DIPSETTING(      0x0000, DEF_STR( Off ) )
5050 	PORT_DIPSETTING(      0x0400, DEF_STR( On ) )
5051 	PORT_DIPNAME( 0x0800, 0x0800, "Ticket dispenser" ) /* "Reserved" for Japan/Europe */
5052 	PORT_DIPSETTING(      0x0800, DEF_STR( Off ) )
5053 	PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
5054 	PORT_DIPNAME( 0x1000, 0x0000, "Title Level Display" )
5055 	PORT_DIPSETTING(      0x1000, DEF_STR( Off ) )
5056 	PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
5057 	PORT_DIPNAME( 0x2000, 0x2000, "Reserved" )
5058 	PORT_DIPSETTING(      0x2000, DEF_STR( Off ) )
5059 	PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
5060 	PORT_DIPNAME( 0x4000, 0x4000, "Reserved" )
5061 	PORT_DIPSETTING(      0x4000, DEF_STR( Off ) )
5062 	PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
5063 	PORT_SERVICE( 0x8000, IP_ACTIVE_LOW )
5064 INPUT_PORTS_END
5065 
5066 INPUT_PORTS_START( brapboys )
5067 	PORT_START		/* b80000.w */
5068 	PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_JOYSTICK_UP | IPF_8WAY | IPF_PLAYER1 )
5069 	PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | IPF_8WAY | IPF_PLAYER1 )
5070 	PORT_BIT( 0x0400, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_8WAY | IPF_PLAYER1 )
5071 	PORT_BIT( 0x0800, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_8WAY | IPF_PLAYER1 )
5072 	PORT_BIT( 0x1000, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER1 )
5073 	PORT_BIT( 0x2000, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_PLAYER1 )
5074 	PORT_BIT( 0x4000, IP_ACTIVE_LOW, IPT_START1 )
5075 	PORT_BIT( 0x8000, IP_ACTIVE_LOW, IPT_COIN1 )
5076 
5077 	PORT_START		/* b80002.w */
5078 	PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_JOYSTICK_UP | IPF_8WAY | IPF_PLAYER2 )
5079 	PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | IPF_8WAY | IPF_PLAYER2 )
5080 	PORT_BIT( 0x0400, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_8WAY | IPF_PLAYER2 )
5081 	PORT_BIT( 0x0800, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_8WAY | IPF_PLAYER2 )
5082 	PORT_BIT( 0x1000, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER2 )
5083 	PORT_BIT( 0x2000, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_PLAYER2 )
5084 	PORT_BIT( 0x4000, IP_ACTIVE_LOW, IPT_START2 )
5085 	PORT_BIT( 0x8000, IP_ACTIVE_LOW, IPT_COIN2 )
5086 
5087 	PORT_START	/* b80004.w */
5088 	PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_JOYSTICK_UP | IPF_8WAY | IPF_PLAYER3 )
5089 	PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | IPF_8WAY | IPF_PLAYER3 )
5090 	PORT_BIT( 0x0400, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_8WAY | IPF_PLAYER3 )
5091 	PORT_BIT( 0x0800, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_8WAY | IPF_PLAYER3 )
5092 	PORT_BIT( 0x1000, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER3 )
5093 	PORT_BIT( 0x2000, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_PLAYER3 )
5094 	PORT_BIT( 0x4000, IP_ACTIVE_LOW, IPT_START3 )
5095 	PORT_BIT( 0x8000, IP_ACTIVE_LOW, IPT_COIN3 )
5096 
5097 	PORT_START		/* ? - b80006.w */
5098 	PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_UNKNOWN )
5099 	PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_UNKNOWN )
5100 	PORT_BIT( 0x0400, IP_ACTIVE_LOW, IPT_UNKNOWN )
5101 	PORT_BIT( 0x0800, IP_ACTIVE_LOW, IPT_UNKNOWN )
5102 	PORT_BIT( 0x1000, IP_ACTIVE_LOW, IPT_UNKNOWN )
5103 	PORT_BIT( 0x2000, IP_ACTIVE_LOW, IPT_UNKNOWN )
5104 	PORT_BIT( 0x4000, IP_ACTIVE_LOW, IPT_UNKNOWN )
5105 	PORT_BIT( 0x8000, IP_ACTIVE_LOW, IPT_UNKNOWN )
5106 
5107 	PORT_START
5108 	PORT_DIPNAME( 0x01, 0x01, DEF_STR( Flip_Screen ) )
5109 	PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
5110 	PORT_DIPSETTING(    0x00, DEF_STR( On ) )
5111 	PORT_SERVICE(0x02, IP_ACTIVE_LOW )
5112 	PORT_DIPNAME( 0x04, 0x04, "Switch Test" )
5113 	PORT_DIPSETTING(    0x04, DEF_STR( Off ) )
5114 	PORT_DIPSETTING(    0x00, DEF_STR( On ) )
5115 	PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN )
5116 	PORT_DIPNAME( 0x10, 0x10, "Coin Slots" )
5117 	PORT_DIPSETTING(    0x10, "Separate Coins" )
5118 	PORT_DIPSETTING(    0x00, "Shared Coins" )
5119 	PORT_DIPNAME( 0x20, 0x20, "Players" )
5120 	PORT_DIPSETTING(    0x20, "3" )
5121 	PORT_DIPSETTING(    0x00, "2" )
5122 	PORT_DIPNAME( 0xc0, 0xc0, DEF_STR( Difficulty ) )
5123 	PORT_DIPSETTING(    0x80, "Easy" )
5124 	PORT_DIPSETTING(    0xc0, "Normal" )
5125 	PORT_DIPSETTING(    0x40, "Hard" )
5126 	PORT_DIPSETTING(    0x00, "Very Hard" )
5127 INPUT_PORTS_END
5128 
5129  /***************************************************************************
5130                                 Wing Force
5131 ***************************************************************************/
5132 
5133 INPUT_PORTS_START( wingforc )
5134 	PORT_START       /* c00000.w */
5135 	PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_UNKNOWN )
5136 	PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_UNKNOWN )
5137 	PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_UNKNOWN )
5138 	PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_UNKNOWN )
5139 	PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_UNKNOWN )
5140 	PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_UNKNOWN )
5141 	PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_UNKNOWN )
5142 	PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_UNKNOWN )
5143 
5144 	PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_JOYSTICK_UP | IPF_PLAYER1 )
5145 	PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | IPF_PLAYER1 )
5146 	PORT_BIT( 0x0400, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_PLAYER1 )
5147 	PORT_BIT( 0x0800, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_PLAYER1 )
5148 	PORT_BIT( 0x1000, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER1 )
5149 	PORT_BIT( 0x2000, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_PLAYER1 )
5150 	PORT_BIT( 0x4000, IP_ACTIVE_LOW, IPT_START1 )
5151 	PORT_BIT_IMPULSE( 0x8000, IP_ACTIVE_LOW, IPT_COIN1, 2 )
5152 
5153 	PORT_START       /* c00002.w */
5154 	PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_UNKNOWN )
5155 	PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_UNKNOWN )
5156 	PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_UNKNOWN )
5157 	PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_UNKNOWN )
5158 	PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_UNKNOWN )
5159 	PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_UNKNOWN )
5160 	PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_UNKNOWN )
5161 	PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_UNKNOWN )
5162 
5163 	PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_JOYSTICK_UP | IPF_PLAYER2 )
5164 	PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | IPF_PLAYER2 )
5165 	PORT_BIT( 0x0400, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_PLAYER2 )
5166 	PORT_BIT( 0x0800, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_PLAYER2 )
5167 	PORT_BIT( 0x1000, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER2 )
5168 	PORT_BIT( 0x2000, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_PLAYER2 )
5169 	PORT_BIT( 0x4000, IP_ACTIVE_LOW, IPT_START2 )
5170 	PORT_BIT_IMPULSE( 0x8000, IP_ACTIVE_LOW, IPT_COIN2, 2 )
5171 
5172 	PORT_START          /* ? - c00004.w */
5173 	PORT_BIT( 0xffff, IP_ACTIVE_LOW, IPT_UNKNOWN )  /* unused?*/
5174 
5175 	PORT_START        /* c00006.w */
5176 	PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_UNKNOWN )
5177 	PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_UNKNOWN )
5178 	PORT_BIT( 0x0400, IP_ACTIVE_LOW, IPT_UNKNOWN )
5179 	PORT_BIT( 0x0800, IP_ACTIVE_LOW, IPT_UNKNOWN )
5180 	PORT_BIT( 0x1000, IP_ACTIVE_LOW, IPT_UNKNOWN )
5181 	PORT_SERVICE_NO_TOGGLE( 0x2000, IP_ACTIVE_LOW )		/* unused*/
5182 	PORT_BIT( 0x4000, IP_ACTIVE_LOW, IPT_TILT )			/* unused*/
5183 	PORT_BIT( 0x8000, IP_ACTIVE_LOW, IPT_SERVICE1 )
5184 INPUT_PORTS_END
5185 
5186 
5187 
5188 /***************************************************************************
5189 
5190 
5191 								Graphics Layouts
5192 
5193 
5194 ***************************************************************************/
5195 
5196 
5197 /*
5198 	16x16x4 made of 4 8x8x4 blocks arrenged like:		 	01
5199  	(nibbles are swapped for tiles, not for sprites)		23
5200 */
5201 static struct GfxLayout layout_16x16x4 =
5202 {
5203 	16,16,
5204 	RGN_FRAC(1,1),
5205 	4,
5206 	{ STEP4(0,1) },
5207 	{ STEP8(8*8*4*0,4),   STEP8(8*8*4*1,4)   },
5208 	{ STEP8(8*8*4*0,8*4), STEP8(8*8*4*2,8*4) },
5209 	16*16*4
5210 };
5211 
5212 /*
5213 	16x16x8 made of 4 8x8x8 blocks arrenged like:	01
5214 													23
5215 */
5216 static struct GfxLayout layout_16x16x8 =
5217 {
5218 	16,16,
5219 	RGN_FRAC(1,1),
5220 	8,
5221 	{ STEP8(0,1) },
5222 	{ STEP8(0,8),   STEP8(8*8*8*1,8)   },
5223 	{ STEP8(0,8*8), STEP8(8*8*8*2,8*8) },
5224 	16*16*8
5225 };
5226 
5227 static struct GfxDecodeInfo kaneko16_gfx_1x4bit_1x4bit[] =
5228 {
5229 	{ REGION_GFX1, 0, &layout_16x16x4, 0,			0x40 }, /* [0] Sprites*/
5230 	{ REGION_GFX2, 0, &layout_16x16x4, 0x40 * 16,	0x40 }, /* [1] Layers*/
5231 	{ -1 }
5232 };
5233 
5234 static struct GfxDecodeInfo kaneko16_gfx_1x4bit_2x4bit[] =
5235 {
5236 	{ REGION_GFX1, 0, &layout_16x16x4, 0,			0x40 }, /* [0] Sprites*/
5237 	{ REGION_GFX2, 0, &layout_16x16x4, 0x40 * 16,	0x40 }, /* [1] Layers*/
5238 	{ REGION_GFX3, 0, &layout_16x16x4, 0x40 * 16,	0x40 }, /* [2] Layers*/
5239 	{ -1 }
5240 };
5241 
5242 static struct GfxDecodeInfo kaneko16_gfx_1x8bit_2x4bit[] =
5243 {
5244 	{ REGION_GFX1, 0, &layout_16x16x8,	0x40 * 256,	0x40 }, /* [0] Sprites*/
5245 	{ REGION_GFX2, 0, &layout_16x16x4,	0,			0x40 }, /* [1] Layers*/
5246 	{ REGION_GFX3, 0, &layout_16x16x4,	0,			0x40 }, /* [2] Layers*/
5247 	{ -1 }
5248 };
5249 
5250 /* 16x16x4 tiles (made of four 8x8 tiles) */
5251 static struct GfxLayout layout_16x16x4_2 =
5252 {
5253 	16,16,
5254 	RGN_FRAC(1,1),
5255 	4,
5256 	{ STEP4(0,1) },
5257 	{ STEP4(8*8*4*0 + 3*4, -4), STEP4(8*8*4*0 + 7*4, -4),
5258 	  STEP4(8*8*4*1 + 3*4, -4), STEP4(8*8*4*1 + 7*4, -4) },
5259 	{ STEP8(8*8*4*0, 8*4),     STEP8(8*8*4*2, 8*4) },
5260 	16*16*4
5261 };
5262 
5263 static struct GfxDecodeInfo sandscrp_gfxdecodeinfo[] =
5264 {
5265 	{ REGION_GFX1, 0, &layout_16x16x4,   0x000, 0x10 }, /* [0] Sprites*/
5266 	{ REGION_GFX2, 0, &layout_16x16x4_2, 0x400, 0x40 }, /* [1] Layers*/
5267 	{ -1 }
5268 };
5269 
5270 
5271 /***************************************************************************
5272 
5273 
5274 								Machine Drivers
5275 
5276 
5277 ***************************************************************************/
5278 
5279 #define KANEKO16_INTERRUPTS_NUM	3
INTERRUPT_GEN(kaneko16_interrupt)5280 INTERRUPT_GEN( kaneko16_interrupt )
5281 {
5282 	switch ( cpu_getiloops() )
5283 	{
5284 		case 2:  cpu_set_irq_line(0, 3, HOLD_LINE);	break;
5285 		case 1:  cpu_set_irq_line(0, 4, HOLD_LINE); break;
5286 		case 0:  cpu_set_irq_line(0, 5, HOLD_LINE); break;
5287 	}
5288 }
5289 
5290 static struct OKIM6295interface okim6295_intf_12kHz =
5291 {
5292 	1,
5293 	{ 12000000/6/165 }, /* 2MHz -> 6295 (mode A) */
5294 	{ REGION_SOUND1 },
5295 	{ 100 }
5296 };
5297 
5298 static struct OKIM6295interface okim6295_intf_15kHz =
5299 {
5300 	1,
5301 	{ 12000000/6/132 }, /* 2MHz -> 6295 (mode B) */
5302 	{ REGION_SOUND1 },
5303 	{ 50 }
5304 };
5305 
5306 static struct OKIM6295interface okim6295_intf_18kHz =
5307 {
5308 	1,
5309 	{ 12000000/4/165 }, /* 3MHz -> 6295 (mode A) */
5310 	{ REGION_SOUND1 },
5311 	{ 100 }
5312 };
5313 
5314 static struct OKIM6295interface okim6295_intf_2x12kHz =
5315 {
5316 	2,
5317 	{ 12000, 12000 },
5318 	{ REGION_SOUND1, REGION_SOUND2 },
5319 	{ 100, 100 }
5320 };
5321 
5322 static struct AY8910interface ay8910_intf_2x1MHz_DSW =
5323 {
5324 	2,
5325 	1000000,	/* ? */
5326 	{ MIXER(100,MIXER_PAN_LEFT), MIXER(100,MIXER_PAN_RIGHT) },
5327 	{ input_port_4_r, 0 },	/* input A: DSW 1 */
5328 	{ input_port_5_r, 0 },	/* input B: DSW 2 */
5329 	{ 0, 0 },
5330 	{ 0, 0 }
5331 };
5332 
5333 static struct AY8910interface ay8910_intf_2x2MHz_EEPROM =
5334 {
5335 	2,
5336 	2000000,	/* ? */
5337 	{ MIXER(100,MIXER_PAN_LEFT), MIXER(100,MIXER_PAN_RIGHT) },
5338 	{ 0, kaneko16_eeprom_r },		/* inputs  A:  0,EEPROM bit read */
5339 	{ 0, 0 },						/* inputs  B */
5340 	{ 0, 0 },						/* outputs A */
5341 	{ 0, kaneko16_eeprom_reset_w }	/* outputs B:  0,EEPROM reset */
5342 };
5343 
5344 static struct YM2151interface ym2151_intf_blazeon =
5345 {
5346 	1,
5347 	4000000,			/* ? */
5348 	{ YM3012_VOL(100,MIXER_PAN_LEFT,100,MIXER_PAN_RIGHT) },
5349 	{ 0 },				/* irq handler */
5350 	{ 0 }				/* port_write */
5351 };
5352 
5353 
5354 static struct YM2151interface ym2151_intf_wingforc =
5355 {
5356 	1,
5357 	4000000,			/* ? */
5358 	{ YM3012_VOL(40,MIXER_PAN_LEFT,40,MIXER_PAN_RIGHT) },
5359 	{ 0 },				/* irq handler */
5360 	{ 0 }				/* port_write */
5361 };
5362 
5363 
5364 static struct OKIM6295interface okim6295_intf_wingforc =
5365 {
5366 	1,
5367 	{ 16000000/16/132},
5368 	{ REGION_SOUND1 },
5369 	{ 100 }
5370 };
5371 /***************************************************************************
5372 								The Berlin Wall
5373 ***************************************************************************/
5374 
5375 /*
5376 	Berlwall interrupts:
5377 
5378 	1-3]	e8c:
5379 	4]		e54:
5380 	5]		de4:
5381 	6-7]	rte
5382 */
5383 
5384 static MACHINE_DRIVER_START( berlwall )
5385 
5386 	/* basic machine hardware */
5387 	MDRV_CPU_ADD(M68000, 12000000)	/* MC68000P12 */
MDRV_CPU_MEMORY(berlwall_readmem,berlwall_writemem)5388 	MDRV_CPU_MEMORY(berlwall_readmem,berlwall_writemem)
5389 	MDRV_CPU_VBLANK_INT(kaneko16_interrupt,KANEKO16_INTERRUPTS_NUM)
5390 
5391 	MDRV_FRAMES_PER_SECOND(60)
5392 	MDRV_VBLANK_DURATION(DEFAULT_REAL_60HZ_VBLANK_DURATION)
5393 
5394 	MDRV_MACHINE_INIT(berlwall)
5395 
5396 	/* video hardware */
5397 	MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER | VIDEO_UPDATE_AFTER_VBLANK)	/* mangled sprites otherwise*/
5398 	MDRV_SCREEN_SIZE(256, 256)
5399 	MDRV_VISIBLE_AREA(0, 256-1, 16, 240-1)
5400 	MDRV_GFXDECODE(kaneko16_gfx_1x4bit_1x4bit)
5401 	MDRV_PALETTE_LENGTH(2048 + 32768)	/* 32768 static colors for the bg */
5402 
5403 	MDRV_PALETTE_INIT(berlwall)
5404 	MDRV_VIDEO_START(berlwall)
5405 	MDRV_VIDEO_UPDATE(kaneko16)
5406 
5407 	/* sound hardware */
5408 	MDRV_SOUND_ATTRIBUTES(SOUND_SUPPORTS_STEREO)
5409 	MDRV_SOUND_ADD(AY8910, ay8910_intf_2x1MHz_DSW)
5410 	MDRV_SOUND_ADD(OKIM6295, okim6295_intf_12kHz)
5411 MACHINE_DRIVER_END
5412 
5413 
5414 /***************************************************************************
5415 							Bakuretsu Breaker
5416 ***************************************************************************/
5417 
5418 static MACHINE_DRIVER_START( bakubrkr )
5419 
5420 	/* basic machine hardware */
5421 	MDRV_CPU_ADD(M68000, 12000000)	/* TMP68HC000-12 */
5422 	MDRV_CPU_MEMORY(bakubrkr_readmem,bakubrkr_writemem)
5423 	MDRV_CPU_VBLANK_INT(kaneko16_interrupt,KANEKO16_INTERRUPTS_NUM)
5424 
5425 	MDRV_FRAMES_PER_SECOND(59)
5426 	MDRV_VBLANK_DURATION(DEFAULT_REAL_60HZ_VBLANK_DURATION)
5427 
5428 	MDRV_MACHINE_INIT(bakubrkr)
5429 	MDRV_NVRAM_HANDLER(93C46)
5430 
5431 	/* video hardware */
5432 	MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER | VIDEO_UPDATE_AFTER_VBLANK)	/* mangled sprites otherwise*/
5433 	MDRV_SCREEN_SIZE(256, 256)
5434 	MDRV_VISIBLE_AREA(0, 256-1, 16, 240-1)
5435 	MDRV_GFXDECODE(kaneko16_gfx_1x4bit_2x4bit)
5436 
5437 	MDRV_PALETTE_LENGTH(2048)
5438 
5439 	MDRV_VIDEO_START(kaneko16_2xVIEW2)
5440 	MDRV_VIDEO_UPDATE(kaneko16)
5441 
5442 	/* sound hardware */
5443 	MDRV_SOUND_ADD(AY8910, ay8910_intf_2x2MHz_EEPROM)
5444 	MDRV_SOUND_ADD(OKIM6295, okim6295_intf_15kHz)
5445 MACHINE_DRIVER_END
5446 
5447 
5448 /***************************************************************************
5449 									Blaze On
5450 ***************************************************************************/
5451 
5452 /*
5453 	Blaze On:
5454 		1]		busy loop
5455 		2]		does nothing
5456 		3]		rte
5457 		4]		drives the game
5458 		5]		== 2
5459 		6-7]	busy loop
5460 */
5461 
5462 static MACHINE_DRIVER_START( blazeon )
5463 
5464 	/* basic machine hardware */
5465 	MDRV_CPU_ADD(M68000,12000000)	/* TMP68HC000-12 */
5466 	MDRV_CPU_MEMORY(blazeon_readmem,blazeon_writemem)
5467 	MDRV_CPU_VBLANK_INT(kaneko16_interrupt,KANEKO16_INTERRUPTS_NUM)
5468 
5469 	MDRV_CPU_ADD(Z80,4000000)	/* D780C-2 */
5470 	MDRV_CPU_MEMORY(blazeon_sound_readmem,blazeon_sound_writemem)
5471 	MDRV_CPU_PORTS(blazeon_sound_readport,blazeon_sound_writeport)
5472 
5473 	MDRV_FRAMES_PER_SECOND(60)
5474 	MDRV_VBLANK_DURATION(DEFAULT_REAL_60HZ_VBLANK_DURATION)
5475 
5476 	MDRV_MACHINE_INIT(blazeon)
5477 
5478 	/* video hardware */
5479 	MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER | VIDEO_UPDATE_AFTER_VBLANK)
5480 	MDRV_SCREEN_SIZE(320, 240)
5481 	MDRV_VISIBLE_AREA(0, 320-1, 0, 240-1 -8)
5482 	MDRV_GFXDECODE(kaneko16_gfx_1x4bit_1x4bit)
5483 	MDRV_PALETTE_LENGTH(2048)
5484 
5485 	MDRV_VIDEO_START(wingforce_1xVIEW2)
5486 	MDRV_VIDEO_UPDATE(kaneko16)
5487 
5488 	/* sound hardware */
5489 	MDRV_SOUND_ATTRIBUTES(SOUND_SUPPORTS_STEREO)
5490 	MDRV_SOUND_ADD(YM2151, ym2151_intf_blazeon)
5491 MACHINE_DRIVER_END
5492 
5493 
5494 static MACHINE_DRIVER_START( wingforc )
5495 
5496 	/* basic machine hardware */
5497 	MDRV_CPU_ADD(M68000,16000000)	/* TMP68HC000-16 */
5498 	MDRV_CPU_MEMORY(wingforc_readmem,wingforc_writemem)
5499 	MDRV_CPU_VBLANK_INT(kaneko16_interrupt,KANEKO16_INTERRUPTS_NUM)
5500 
5501 	MDRV_CPU_ADD(Z80,4000000)	/* D780C-2 */
5502 	MDRV_CPU_MEMORY(wingforc_sound_readmem,wingforc_sound_writemem)
5503 	MDRV_CPU_PORTS(wingforc_sound_readport,wingforc_sound_writeport)
5504 
5505 	MDRV_FRAMES_PER_SECOND(59.1854)
5506 	MDRV_VBLANK_DURATION(DEFAULT_REAL_60HZ_VBLANK_DURATION)
5507 
5508 	MDRV_MACHINE_INIT(blazeon)
5509 
5510 	/* video hardware */
5511 	MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER | VIDEO_UPDATE_AFTER_VBLANK)
5512 	MDRV_SCREEN_SIZE(320, 240)
5513 	MDRV_VISIBLE_AREA(0, 320-1, 0, 240-1 -16)
5514 	MDRV_GFXDECODE(kaneko16_gfx_1x4bit_1x4bit)
5515 	MDRV_PALETTE_LENGTH(2048)
5516 
5517 	MDRV_VIDEO_START(wingforce_1xVIEW2)
5518 	MDRV_VIDEO_UPDATE(kaneko16)
5519 
5520 	/* sound hardware */
5521 	MDRV_SOUND_ATTRIBUTES(SOUND_SUPPORTS_STEREO)
5522 	MDRV_SOUND_ADD(YM2151, ym2151_intf_wingforc)
5523 	MDRV_SOUND_ADD(OKIM6295, okim6295_intf_wingforc)
5524 MACHINE_DRIVER_END
5525 
5526 
5527 
5528 /***************************************************************************
5529 							Great 1000 Miles Rally
5530 ***************************************************************************/
5531 
5532 /*
5533 	gtmr interrupts:
5534 
5535 	3] 476:			time, input ports, scroll registers
5536 	4] 466->258e:	set sprite ram
5537 	5] 438:			set sprite colors
5538 
5539 	VIDEO_UPDATE_AFTER_VBLANK fixes the mangled/wrong colored sprites
5540 */
5541 
5542 static MACHINE_DRIVER_START( gtmr )
5543 
5544 	/* basic machine hardware */
5545 	MDRV_CPU_ADD_TAG("gtmr", M68000, 16000000)	/* ? Most likely a 68000-HC16 */
5546 	MDRV_CPU_MEMORY(gtmr_readmem,gtmr_writemem)
5547 	MDRV_CPU_VBLANK_INT(kaneko16_interrupt,KANEKO16_INTERRUPTS_NUM)
5548 
5549 	MDRV_FRAMES_PER_SECOND(60)
5550 	MDRV_VBLANK_DURATION(DEFAULT_REAL_60HZ_VBLANK_DURATION)
5551 
5552 	MDRV_MACHINE_INIT(gtmr)
5553 
5554 	/* video hardware */
5555 	MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER | VIDEO_UPDATE_AFTER_VBLANK)
5556 	MDRV_SCREEN_SIZE(320, 240)
5557 	MDRV_VISIBLE_AREA(0, 320-1, 0, 240-1)
5558 	MDRV_GFXDECODE(kaneko16_gfx_1x8bit_2x4bit)
5559 	MDRV_PALETTE_LENGTH(32768)
5560 
5561 	MDRV_VIDEO_START(kaneko16_2xVIEW2)
5562 	MDRV_VIDEO_UPDATE(kaneko16)
5563 
5564 	/* sound hardware */
5565 	MDRV_SOUND_ADD(OKIM6295, okim6295_intf_2x12kHz)
5566 MACHINE_DRIVER_END
5567 
5568 /***************************************************************************
5569 							Great 1000 Miles Rally 2
5570 ***************************************************************************/
5571 
5572 static MACHINE_DRIVER_START( gtmr2 )
5573 
5574 	/* basic machine hardware */
5575 	MDRV_IMPORT_FROM(gtmr)
5576 	MDRV_CPU_MODIFY("gtmr")
5577 	MDRV_CPU_MEMORY(gtmr2_readmem,gtmr_writemem)
5578 MACHINE_DRIVER_END
5579 
5580 /***************************************************************************
5581 								Magical Crystal
5582 ***************************************************************************/
5583 
5584 static MACHINE_DRIVER_START( mgcrystl )
5585 
5586 	/* basic machine hardware */
5587 	MDRV_CPU_ADD(M68000, 12000000)
5588 	MDRV_CPU_MEMORY(mgcrystl_readmem,mgcrystl_writemem)
5589 	MDRV_CPU_VBLANK_INT(kaneko16_interrupt,KANEKO16_INTERRUPTS_NUM)
5590 
5591 	MDRV_FRAMES_PER_SECOND(60)
5592 	MDRV_VBLANK_DURATION(DEFAULT_REAL_60HZ_VBLANK_DURATION)
5593 
5594 	MDRV_MACHINE_INIT(mgcrystl)
5595 	MDRV_NVRAM_HANDLER(93C46)
5596 
5597 	/* video hardware */
5598 	MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER | VIDEO_UPDATE_AFTER_VBLANK)
5599 	MDRV_SCREEN_SIZE(256, 256)
5600 	MDRV_VISIBLE_AREA(0, 256-1, 0+16, 256-16-1)
5601 	MDRV_GFXDECODE(kaneko16_gfx_1x4bit_2x4bit)
5602 	MDRV_PALETTE_LENGTH(2048)
5603 
5604 	MDRV_VIDEO_START(kaneko16_2xVIEW2)
5605 	MDRV_VIDEO_UPDATE(kaneko16)
5606 
5607 	/* sound hardware */
5608 	MDRV_SOUND_ADD(AY8910, ay8910_intf_2x2MHz_EEPROM)
5609 	MDRV_SOUND_ADD(OKIM6295, okim6295_intf_18kHz)
5610 MACHINE_DRIVER_END
5611 
5612 
5613 /***************************************************************************
5614 								Sand Scorpion
5615 ***************************************************************************/
5616 
5617 /* YM3014B + YM2203C */
5618 
5619 static void irq_handler(int irq)
5620 {
5621 	cpu_set_irq_line(1,0,irq ? ASSERT_LINE : CLEAR_LINE);
5622 }
5623 
5624 static struct YM2203interface ym2203_intf_sandscrp =
5625 {
5626 	1,
5627 	4000000,	/* ? */
5628 	{ YM2203_VOL(80,80) },
5629 	{ input_port_4_r },	/* Port A Read - DSW 1 */
5630 	{ input_port_5_r },	/* Port B Read - DSW 2 */
5631 	{ 0 },	/* Port A Write */
5632 	{ 0 },	/* Port B Write */
5633 	{ irq_handler },	/* IRQ handler */
5634 };
5635 
5636 
5637 static MACHINE_DRIVER_START( sandscrp )
5638 
5639 	/* basic machine hardware */
5640 	MDRV_CPU_ADD(M68000,12000000)	/* TMP68HC000N-12 */
MDRV_CPU_MEMORY(sandscrp_readmem,sandscrp_writemem)5641 	MDRV_CPU_MEMORY(sandscrp_readmem,sandscrp_writemem)
5642 	MDRV_CPU_VBLANK_INT(sandscrp_interrupt,1)
5643 
5644 	MDRV_CPU_ADD(Z80,4000000)	/* Z8400AB1, Reads the DSWs: it can't be disabled */
5645 	MDRV_CPU_MEMORY(sandscrp_sound_readmem,sandscrp_sound_writemem)
5646 	MDRV_CPU_PORTS(sandscrp_sound_readport,sandscrp_sound_writeport)
5647 
5648 	MDRV_FRAMES_PER_SECOND(60)
5649 	MDRV_VBLANK_DURATION(DEFAULT_REAL_60HZ_VBLANK_DURATION)	/* eof callback*/
5650 
5651 	MDRV_MACHINE_INIT(sandscrp)
5652 
5653 	/* video hardware */
5654 	MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER)
5655 	MDRV_SCREEN_SIZE(256, 256)
5656 	MDRV_VISIBLE_AREA(0, 256-1, 0+16, 256-16-1)
5657 	MDRV_GFXDECODE(sandscrp_gfxdecodeinfo)
5658 	MDRV_PALETTE_LENGTH(2048)
5659 
5660 	MDRV_VIDEO_START(sandscrp_1xVIEW2)
5661 	MDRV_VIDEO_EOF(sandscrp)
5662 	MDRV_VIDEO_UPDATE(kaneko16)
5663 
5664 	/* sound hardware */
5665 	MDRV_SOUND_ATTRIBUTES(SOUND_SUPPORTS_STEREO)
5666 	MDRV_SOUND_ADD(OKIM6295, okim6295_intf_15kHz)
5667 	MDRV_SOUND_ADD(YM2203, ym2203_intf_sandscrp)
5668 MACHINE_DRIVER_END
5669 
5670 
5671 /***************************************************************************
5672 								Shogun Warriors
5673 ***************************************************************************/
5674 
5675 /*
5676 	shogwarr interrupts:
5677 
5678 	2] 100:	rte
5679 	3] 102:
5680 	4] 136:
5681 		movem.l D0-D7/A0-A6, -(A7)
5682 		movea.l $207808.l, A0	; from mcu?
5683 		jmp     ($4,A0)
5684 
5685 	other: busy loop
5686 */
5687 #define SHOGWARR_INTERRUPTS_NUM	3
5688 INTERRUPT_GEN( shogwarr_interrupt )
5689 {
5690 	switch ( cpu_getiloops() )
5691 	{
5692 		case 2:  cpu_set_irq_line(0, 2, HOLD_LINE); break;
5693 		case 1:  cpu_set_irq_line(0, 3, HOLD_LINE); break;
5694 		case 0:  cpu_set_irq_line(0, 4, HOLD_LINE); calc3_mcu_run();break;
5695 	}
5696 }
5697 
5698 /* the above eeprom looks corrupt, some of the text is wrong, the game never writes this text tho.. maybe it should be as below*/
5699 /* leaving both here incase they relate to which tables get 'locked out' by the MCU somehow*/
5700 static data8_t shogwarr_default_eeprom[128] = {
5701 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
5702 	0x4B, 0x41, 0x4E, 0x45, 0x4B, 0x4F, 0x2F, 0x41, 0x54, 0x4F, 0x50, 0x20, 0x31, 0x39, 0x39, 0x32,
5703 	0x46, 0x55, 0x4A, 0x49, 0x59, 0x41, 0x4D, 0x41, 0x20, 0x42, 0x55, 0x53, 0x54, 0x45, 0x52, 0x20,
5704 	0x20, 0x53, 0x48, 0x4F, 0x47, 0x55, 0x4E, 0x20, 0x57, 0x41, 0x52, 0x52, 0x49, 0x4F, 0x52, 0x53,
5705 	0x63, 0x6F, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68, 0x74, 0x20, 0x4B, 0x41, 0x4E, 0x45, 0x4B, 0x4F,
5706 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
5707 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF,
5708 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF
5709 };
5710 
5711 static data8_t brapboys_default_eeprom[128] = {
5712 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
5713 	0x00, 0x00, 0x00, 0x05, 0x00, 0x06, 0x20, 0x30, 0x00, 0x03, 0x68, 0x18, 0x01, 0x01, 0x01, 0x01,
5714 	0x01, 0x01, 0x00, 0x01, 0x00, 0x04, 0x00, 0x08, 0x4B, 0x41, 0x4E, 0x45, 0x4B, 0x4F, 0x20, 0x20,
5715 	0x42, 0x65, 0x20, 0x52, 0x61, 0x70, 0x20, 0x42, 0x6F, 0x79, 0x73, 0x00, 0x30, 0x30, 0x30, 0x2E,
5716 	0x30, 0x38, 0x10, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
5717 	0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
5718 	0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
5719 	0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x35, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF
5720 };
5721 
NVRAM_HANDLER(shogwarr)5722 static NVRAM_HANDLER( shogwarr )
5723 {
5724 	int isbrap = ( !strcmp(Machine->gamedrv->name,"brapboysj") || !strcmp(Machine->gamedrv->name,"brapboys"));
5725 
5726 	if (read_or_write)
5727 		EEPROM_save(file);
5728 	else
5729 	{
5730 		EEPROM_init(&eeprom_interface_93C46);
5731 
5732 		if (file) EEPROM_load(file);
5733 		else
5734 		{
5735 			if (isbrap)
5736 				EEPROM_set_data(brapboys_default_eeprom,128);
5737 			else
5738 				EEPROM_set_data(shogwarr_default_eeprom,128);
5739 		}
5740 	}
5741 }
5742 
5743 
5744 static MACHINE_DRIVER_START( shogwarr )
5745 
5746 	/* basic machine hardware */
5747 	MDRV_CPU_ADD(M68000, 12000000)
MDRV_CPU_MEMORY(shogwarr_readmem,shogwarr_writemem)5748 	MDRV_CPU_MEMORY(shogwarr_readmem,shogwarr_writemem)
5749 	MDRV_CPU_VBLANK_INT(shogwarr_interrupt,SHOGWARR_INTERRUPTS_NUM)
5750 
5751 	MDRV_FRAMES_PER_SECOND(59.1854)
5752 	MDRV_VBLANK_DURATION(TIME_IN_USEC(0))
5753 
5754 	MDRV_MACHINE_INIT(shogwarr)
5755 	MDRV_NVRAM_HANDLER(shogwarr)
5756 
5757 	/* video hardware */
5758 	MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER)
5759 	MDRV_SCREEN_SIZE(320, 240)
5760 	MDRV_VISIBLE_AREA(40, 296-1, 16, 240-1)
5761 
5762 	MDRV_GFXDECODE(kaneko16_gfx_1x4bit_1x4bit)
5763 	MDRV_PALETTE_LENGTH(2048)
5764 
5765 	MDRV_VIDEO_START(kaneko16_1xVIEW2)
5766 	MDRV_VIDEO_UPDATE(kaneko16)
5767 
5768 	/* sound hardware */
5769 	MDRV_SOUND_ADD(OKIM6295, okim6295_intf_2x12kHz)
5770 MACHINE_DRIVER_END
5771 
5772 
5773 static MACHINE_DRIVER_START( brapboys )
5774 
5775 	/* basic machine hardware */
5776 	MDRV_CPU_ADD(M68000, 12000000)
5777 	MDRV_CPU_MEMORY(shogwarr_readmem,shogwarr_writemem)
5778 	MDRV_CPU_VBLANK_INT(shogwarr_interrupt,SHOGWARR_INTERRUPTS_NUM)
5779 
5780 	MDRV_FRAMES_PER_SECOND(59.1854)
5781 	MDRV_VBLANK_DURATION(TIME_IN_USEC(0))
5782 
5783 	MDRV_MACHINE_INIT(brapboys)
5784 	MDRV_NVRAM_HANDLER(shogwarr)
5785 
5786 	/* video hardware */
5787 	MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER)
5788 	MDRV_SCREEN_SIZE(320, 240)
5789 	MDRV_VISIBLE_AREA(40, 296-1, 16, 240-1)
5790 
5791 	MDRV_GFXDECODE(kaneko16_gfx_1x4bit_1x4bit)
5792 	MDRV_PALETTE_LENGTH(2048)
5793 
5794 	MDRV_VIDEO_START(kaneko16_1xVIEW2)
5795 	MDRV_VIDEO_UPDATE(kaneko16)
5796 
5797 	/* sound hardware */
5798 	MDRV_SOUND_ADD(OKIM6295, okim6295_intf_2x12kHz)
5799 MACHINE_DRIVER_END
5800 
5801 /***************************************************************************
5802 							Bonks Adventure
5803 ***************************************************************************/
5804 
5805 
5806 static MACHINE_DRIVER_START( bonkadv )
5807 
5808 	/* basic machine hardware */
5809 	MDRV_IMPORT_FROM(gtmr)
5810 	MDRV_CPU_MODIFY("gtmr")
5811 	MDRV_CPU_MEMORY(bonkadv_readmem,bonkadv_writemem)
5812 	MDRV_CPU_VBLANK_INT(kaneko16_interrupt,KANEKO16_INTERRUPTS_NUM + 1 )
5813 
5814 	MDRV_MACHINE_INIT( bonkadv )
5815 MACHINE_DRIVER_END
5816 
5817 
5818 static MACHINE_DRIVER_START( bloodwar )
5819 
5820 	/* basic machine hardware */
5821 	MDRV_IMPORT_FROM(gtmr)
5822 	MDRV_CPU_MODIFY("gtmr")
5823 	MDRV_CPU_MEMORY(bloodwar_readmem,bloodwar_writemem)
5824 
5825 	MDRV_MACHINE_INIT( bloodwar )
5826 
5827 MACHINE_DRIVER_END
5828 
5829 
5830 /***************************************************************************
5831 
5832 
5833 								ROMs Loading
5834 
5835 
5836 ***************************************************************************/
5837 
5838 
5839 
5840 /***************************************************************************
5841 
5842 								Bakuretsu Breaker
5843 
5844 	USES TOSHIBA 68000 CPU W/TWO YM2149 & OKI M6295 FOR SOUND
5845 
5846 	LOCATION    TYPE
5847 	------------------
5848 	U38         27C040
5849 	U37         "
5850 	U36         27C020
5851 	U19         "
5852 	U18         "
5853 
5854 Bakuretsu Breaker
5855 Kaneko, 1992
5856 
5857 PCB Layout
5858 ----------
5859 
5860 ZOOFC-02
5861 |------------------------------------------|
5862 | PAL    TS020.U33                PAL      |
5863 | 6264                            6264     |
5864 | 6264    VIEW2-CHIP              6264     |
5865 | 4464 4464           VIEW2-CHIP  TS010.U4 |
5866 | 4464 4464                                |
5867 | 4464 4464                       699206P  |
5868 |                         5116    (QFP44)  |
5869 |                                          |
5870 |         TS002J.U36 MUX2-CHIP    699205P  |
5871 |VU-002   TS001J.U37      5116    (QFP44) J|
5872 |(QFP160) TS000J.U38                      A|
5873 |                   62256 TS100J.U18      M|
5874 |        6116 6116  62256 TS101J.U19      M|
5875 |        PAL                     PAL      A|
5876 |16MHz   PAL  PAL  TMP68HC000N-12          |
5877 |12MHz        PAL                IU-001    |
5878 |   VU-001                      (QFP44)    |
5879 |   (QFP48)  YM2149      PAL               |
5880 |93C46       YM2149  TS030.U5  M6295       |
5881 |    DSW1(4)                               |
5882 |------------------------------------------|
5883 
5884 Notes:
5885        68000 clock: 12.000MHz
5886       YM2149 clock: 2.000MHz
5887        M6295 clock: 2.000MHz, sample rate = clock /132
5888              VSync: 59Hz
5889              HSync: 15.68kHz
5890 
5891 
5892 ***************************************************************************/
5893 
5894 ROM_START( bakubrkr )
5895  	ROM_REGION( 0x080000, REGION_CPU1, 0 )			/* 68000 Code */
5896 	ROM_LOAD16_BYTE( "ts100j.u18", 0x000000, 0x040000, CRC(8cc0a4fd) SHA1(e7e18b5ea236522a79ba9db8f573ac8f7ade504b) )
5897 	ROM_LOAD16_BYTE( "ts101j.u19", 0x000001, 0x040000, CRC(aea92195) SHA1(e89f964e7e936fd7774f21956eb4ff5c9104837b) )
5898 
5899 	ROM_REGION( 0x240000, REGION_GFX1, ROMREGION_DISPOSE )	/* Sprites */
5900 	ROM_LOAD( "ts001j.u37",  0x000000, 0x080000, CRC(70b66e7e) SHA1(307ba27b623f67ee4b4023179870c270bac8ea22) )
5901 	ROM_RELOAD(       0x100000, 0x080000             )
5902 	ROM_LOAD( "ts000j.u38",  0x080000, 0x080000, CRC(a7a94143) SHA1(d811a7597402c161850ddf98cdb00661ea506c7d) )
5903 	ROM_RELOAD(       0x180000, 0x080000             )
5904 	ROM_LOAD( "ts002j.u36",  0x200000, 0x040000, CRC(611271e6) SHA1(811c21822b074fbb4bb809fed29d48bbd51d57a0) )
5905 
5906 	ROM_REGION( 0x100000, REGION_GFX2, ROMREGION_DISPOSE )	/* Tiles */
5907 	ROM_LOAD( "ts010.u4",  0x000000, 0x100000, CRC(df935324) SHA1(73b7aff8800a4e88a47ad426190b73dabdfbf142) )
5908 
5909 	ROM_REGION( 0x100000, REGION_GFX3, ROMREGION_DISPOSE )	/* Tiles */
5910 	ROM_LOAD( "ts020.u33",  0x000000, 0x100000, CRC(eb58c35d) SHA1(762c5219de6f729a0fc1df90fce09cdf711c2a1e) )
5911 
5912 	ROM_REGION( 0x100000, REGION_USER1, ROMREGION_DISPOSE )	/* OKI Sample ROM */
5913 	ROM_LOAD( "ts030.u5",    0x000000, 0x100000, CRC(1d68e9d1) SHA1(aaa64a8e8d7cd7f91d2be346fafb9d1f29b40eda) )
5914 
5915 	/* $00000-$20000 stays the same in all sound banks, */
5916 	/* the second half of the bank is what gets switched */
5917 	ROM_REGION( 0x200000, REGION_SOUND1, 0 )	/* Samples */
5918 	ROM_COPY( REGION_USER1, 0x000000, 0x000000, 0x020000)
5919 	ROM_COPY( REGION_USER1, 0x020000, 0x020000, 0x020000)
5920 	ROM_COPY( REGION_USER1, 0x000000, 0x040000, 0x020000)
5921 	ROM_COPY( REGION_USER1, 0x040000, 0x060000, 0x020000)
5922 	ROM_COPY( REGION_USER1, 0x000000, 0x080000, 0x020000)
5923 	ROM_COPY( REGION_USER1, 0x060000, 0x0a0000, 0x020000)
5924 	ROM_COPY( REGION_USER1, 0x000000, 0x0c0000, 0x020000)
5925 	ROM_COPY( REGION_USER1, 0x080000, 0x0e0000, 0x020000)
5926 	ROM_COPY( REGION_USER1, 0x000000, 0x100000, 0x020000)
5927 	ROM_COPY( REGION_USER1, 0x0a0000, 0x120000, 0x020000)
5928 	ROM_COPY( REGION_USER1, 0x000000, 0x140000, 0x020000)
5929 	ROM_COPY( REGION_USER1, 0x0c0000, 0x160000, 0x020000)
5930 	ROM_COPY( REGION_USER1, 0x000000, 0x180000, 0x020000)
5931 	ROM_COPY( REGION_USER1, 0x0e0000, 0x1a0000, 0x020000)
5932 	ROM_FILL(                         0x1c0000, 0x020000, 0x00 )
5933 	ROM_FILL(                         0x1e0000, 0x020000, 0x00 )
5934 ROM_END
5935 
5936 
5937 /***************************************************************************
5938 
5939 								The Berlin Wall
5940 
5941 The Berlin Wall, Kaneko 1991, BW-002
5942 
5943 ----
5944 
5945 BW-004 BW-008                    VU-003
5946 BW-005 BW-009                    VU-003
5947 BW-006 BW-00A                    VU-003
5948 BW-007 BW-00B                          6116-90
5949                                        6116-90
5950 BW-003                           52256  52256
5951                                  BW101A BW100A
5952 5864
5953 5864                   MUX2      68000
5954             VIEW2
5955 BW300
5956 BW-002
5957 BW-001                      42101
5958                             42101
5959 41464 41464      VU-002
5960 41464 41464                      YM2149  IU-004
5961 41464 41464                      YM2149
5962                            SWB             BW-000  6295
5963                            SWA
5964 
5965 
5966 PALs : BW-U47, BW-U48 (backgrounds encryption)
5967 
5968 ***************************************************************************/
5969 
5970 ROM_START( berlwall )
5971  	ROM_REGION( 0x040000, REGION_CPU1, 0 )			/* 68000 Code */
5972 	ROM_LOAD16_BYTE( "bw100a", 0x000000, 0x020000, CRC(e6bcb4eb) SHA1(220b8fddc79230b4f6a8cf33e1035355c485e8d1) )
5973 	ROM_LOAD16_BYTE( "bw101a", 0x000001, 0x020000, CRC(38056fb2) SHA1(48338b9a5ebea872286541a3c45016673c4af76b) )
5974 
5975 	ROM_REGION( 0x120000, REGION_GFX1, ROMREGION_DISPOSE )	/* Sprites */
5976 	ROM_LOAD( "bw001",  0x000000, 0x080000, CRC(bc927260) SHA1(44273a8b6a041504d54da4a7897adf23e3e9db10) )
5977 	ROM_LOAD( "bw002",  0x080000, 0x080000, CRC(223f5465) SHA1(6ed077514ab4370a215a4a60c3aecc8b72ed1c97) )
5978 	ROM_LOAD( "bw300",  0x100000, 0x020000, CRC(b258737a) SHA1(b5c8fe44a8dcfc19bccba896bdb73030c5843544) )
5979 
5980 	ROM_REGION( 0x080000, REGION_GFX2, ROMREGION_DISPOSE )	/* Tiles (Scrambled) */
5981 	ROM_LOAD( "bw003",  0x000000, 0x080000, CRC(fbb4b72d) SHA1(07a0590f18b3bba1843ef6a89a5c214e8e605cc3) )
5982 
5983 	ROM_REGION( 0x400000, REGION_GFX3, ROMREGION_DISPOSE )	/* High Color Background */
5984 	ROM_LOAD16_BYTE( "bw004",  0x000000, 0x080000, CRC(5300c34d) SHA1(ccb12ea05f89ef68bcfe003faced2ffea24c4bf0) )
5985 	ROM_LOAD16_BYTE( "bw008",  0x000001, 0x080000, CRC(9aaf2f2f) SHA1(1352856159e19f07e8e30f9c44b21347103ce024) ) /* FIXED BITS (xxxxxxx0)*/
5986 	ROM_LOAD16_BYTE( "bw005",  0x100000, 0x080000, CRC(16db6d43) SHA1(0158d0278d085487400ad4384b8cc9618503319e) )
5987 	ROM_LOAD16_BYTE( "bw009",  0x100001, 0x080000, CRC(1151a0b0) SHA1(584a0da7eb7f06450f95e76faa20d19f053cb74c) ) /* FIXED BITS (xxxxxxx0)*/
5988 	ROM_LOAD16_BYTE( "bw006",  0x200000, 0x080000, CRC(73a35d1f) SHA1(af919cf858c5923aea45e0d8d91493e6284cb99e) )
5989 	ROM_LOAD16_BYTE( "bw00a",  0x200001, 0x080000, CRC(f447dfc2) SHA1(1254eafea92e8e416deedf21cb01990ffc4f896c) ) /* FIXED BITS (xxxxxxx0)*/
5990 	ROM_LOAD16_BYTE( "bw007",  0x300000, 0x080000, CRC(97f85c87) SHA1(865e076e098c49c96639f62be793f2de24b4926b) )
5991 	ROM_LOAD16_BYTE( "bw00b",  0x300001, 0x080000, CRC(b0a48225) SHA1(de256bb6e2a824114274bff0c6c1234934c31c49) ) /* FIXED BITS (xxxxxxx0)*/
5992 
5993 	ROM_REGION( 0x040000, REGION_SOUND1, 0 )	/* Samples */
5994 	ROM_LOAD( "bw000",  0x000000, 0x040000, CRC(d8fe869d) SHA1(75e9044c4164ca6db9519fcff8eca6c8a2d8d5d1) )
5995 ROM_END
5996 
5997 ROM_START( berlwalt )
5998  	ROM_REGION( 0x040000, REGION_CPU1, 0 )			/* 68000 Code */
5999 	ROM_LOAD16_BYTE( "u23_01.bin", 0x000000, 0x020000, CRC(76b526ce) SHA1(95ba7cccbe88fd695c28b6a7c25a1afd130c1aa6) )
6000 	ROM_LOAD16_BYTE( "u39_01.bin", 0x000001, 0x020000, CRC(78fa7ef2) SHA1(8392de6e307dcd2bf5bcbeb37d578d33246acfcf) )
6001 
6002 	ROM_REGION( 0x120000, REGION_GFX1, ROMREGION_DISPOSE )	/* Sprites */
6003 	ROM_LOAD( "bw001",  0x000000, 0x080000, CRC(bc927260) SHA1(44273a8b6a041504d54da4a7897adf23e3e9db10) )
6004 	ROM_LOAD( "bw002",  0x080000, 0x080000, CRC(223f5465) SHA1(6ed077514ab4370a215a4a60c3aecc8b72ed1c97) )
6005 	ROM_LOAD( "bw300",  0x100000, 0x020000, CRC(b258737a) SHA1(b5c8fe44a8dcfc19bccba896bdb73030c5843544) )
6006 
6007 	ROM_REGION( 0x080000, REGION_GFX2, ROMREGION_DISPOSE )	/* Tiles (Scrambled) */
6008 	ROM_LOAD( "bw003",  0x000000, 0x080000, CRC(fbb4b72d) SHA1(07a0590f18b3bba1843ef6a89a5c214e8e605cc3) )
6009 
6010 	ROM_REGION( 0x400000, REGION_GFX3, ROMREGION_DISPOSE )	/* High Color Background */
6011 	ROM_LOAD16_BYTE( "bw004",  0x000000, 0x080000, CRC(5300c34d) SHA1(ccb12ea05f89ef68bcfe003faced2ffea24c4bf0) )
6012 	ROM_LOAD16_BYTE( "bw008",  0x000001, 0x080000, CRC(9aaf2f2f) SHA1(1352856159e19f07e8e30f9c44b21347103ce024) ) /* FIXED BITS (xxxxxxx0)*/
6013 	ROM_LOAD16_BYTE( "bw005",  0x100000, 0x080000, CRC(16db6d43) SHA1(0158d0278d085487400ad4384b8cc9618503319e) )
6014 	ROM_LOAD16_BYTE( "bw009",  0x100001, 0x080000, CRC(1151a0b0) SHA1(584a0da7eb7f06450f95e76faa20d19f053cb74c) ) /* FIXED BITS (xxxxxxx0)*/
6015 	ROM_LOAD16_BYTE( "bw006",  0x200000, 0x080000, CRC(73a35d1f) SHA1(af919cf858c5923aea45e0d8d91493e6284cb99e) )
6016 	ROM_LOAD16_BYTE( "bw00a",  0x200001, 0x080000, CRC(f447dfc2) SHA1(1254eafea92e8e416deedf21cb01990ffc4f896c) ) /* FIXED BITS (xxxxxxx0)*/
6017 	ROM_LOAD16_BYTE( "bw007",  0x300000, 0x080000, CRC(97f85c87) SHA1(865e076e098c49c96639f62be793f2de24b4926b) )
6018 	ROM_LOAD16_BYTE( "bw00b",  0x300001, 0x080000, CRC(b0a48225) SHA1(de256bb6e2a824114274bff0c6c1234934c31c49) ) /* FIXED BITS (xxxxxxx0)*/
6019 
6020 	ROM_REGION( 0x040000, REGION_SOUND1, 0 )	/* Samples */
6021 	ROM_LOAD( "bw000",  0x000000, 0x040000, CRC(d8fe869d) SHA1(75e9044c4164ca6db9519fcff8eca6c8a2d8d5d1) )
6022 ROM_END
6023 
6024 
6025 
6026 /***************************************************************************
6027 
6028 							Blaze On (Japan version)
6029 
6030 CPU:          TMP68HC000-12/D780C-2(Z80)
6031 SOUND:        YM2151
6032 OSC:          13.3330/16.000MHz
6033 CUSTOM:       KANEKO VU-002 x2
6034               KANEKO 23160-509 VIEW2-CHIP
6035               KANEKO MUX2-CHIP
6036               KANEKO HELP1-CHIP
6037 
6038 ---------------------------------------------------
6039  filemanes          devices       kind
6040 ---------------------------------------------------
6041  BZ_PRG1.U80        27C020        68000 main prg.
6042  BZ_PRG2.U81        27C020        68000 main prg.
6043  3.U45              27C010        Z80 sound prg.
6044  BZ_BG.U2           57C8200       BG CHR
6045  BZ_SP1.U20         27C8001       OBJ
6046  BZ_SP2.U21         27C8001       OBJ
6047  BZ_SP1.U68 ( == BZ_SP1.U20)
6048  BZ_SP2.U86 ( == BZ_SP2.U21)
6049 
6050 ***************************************************************************/
6051 
6052 ROM_START( blazeon )
6053  	ROM_REGION( 0x080000, REGION_CPU1, 0 )			/* 68000 Code */
6054 	ROM_LOAD16_BYTE( "bz_prg1.u80", 0x000000, 0x040000, CRC(8409e31d) SHA1(a9dfc299f4b457df190314401aef309adfaf9bae) )
6055 	ROM_LOAD16_BYTE( "bz_prg2.u81", 0x000001, 0x040000, CRC(b8a0a08b) SHA1(5f275b98d3e49a834850b45179d26e8c2f9fd604) )
6056 
6057  	ROM_REGION( 0x020000, REGION_CPU2, 0 )			/* Z80 Code */
6058 	ROM_LOAD( "3.u45", 0x000000, 0x020000, CRC(52fe4c94) SHA1(896230e4627503292575bbd84edc3cf9cb18b27e) )	/* 1xxxxxxxxxxxxxxxx = 0xFF*/
6059 
6060 	ROM_REGION( 0x200000, REGION_GFX1, ROMREGION_DISPOSE )	/* Sprites */
6061 	ROM_LOAD( "bz_sp1.u20", 0x000000, 0x100000, CRC(0d5809a1) SHA1(e72669f95b050d1967d10a865bab8f3634c9daad) )
6062 	ROM_LOAD( "bz_sp2.u21", 0x100000, 0x100000, CRC(56ead2bd) SHA1(463723f3c533603ce3a95310e9ce12b4e582b52d) )
6063 
6064 	ROM_REGION( 0x100000, REGION_GFX2, ROMREGION_DISPOSE )	/* Tiles (Scrambled) */
6065 	ROM_LOAD( "bz_bg.u2", 0x000000, 0x100000, CRC(fc67f19f) SHA1(f5d9e037a736b0932efbfb48587de08bec93df5d) )
6066 ROM_END
6067 
6068 /***************************************************************************
6069 
6070 								Blood Warrior
6071 
6072 Kaneko 1994
6073 
6074 TOP BOARD
6075 
6076 CPU - Toshiba TMP68HC000N - 16
6077 SOUND - OKI M6295  x2
6078 QUARTZ OSCILLATORS AT 27.0000MHz, 16.0000MHz, 20.0000MHz and 33.3330MHz
6079 RAM - LC3664 x6, 424260 x2, LH52B256D x6, D42101C x2
6080 
6081 
6082 PCU11.u11 - 18CV8PC    \
6083 PCU15.u15 - 18CV8PC     | NEAR OKI
6084 Z091P016.u16 - 18CV8PC /
6085 Z091P013.u13 - 18CV8PC \
6086 PCU17.u17 - 18CV8PC     |
6087 PCU14.u14 - 18CV8PC     | NEAR 68000
6088 PCU94.u94 - 18CV8PC     |
6089 PCU92.u92 - 18CV8PC     |
6090 Z092P093.u93 - 18CV8PC /
6091 ALL ABOVE NOT DUMPED
6092 
6093 Custom Chips
6094 
6095 231609-509 View2-Chip x2
6096 KC-002 L0002 023 9321EK702
6097 9343T - 44 pin PQFP (NEAR JAMMMA CONNECTOR)
6098 
6099 BOTTOM BOARD
6100 
6101 TBS0P01 452 9339PK001 - MCU
6102 
6103 ofs1g006.u6 - GAL16V8B
6104 ofs1g007.u7 - GAL16V8B
6105 ofs1p059.u59 - 18CV8PC
6106 ofs1p511.u511 - 18CV8PC
6107 ALL ABOVE NOT DUMPED
6108 
6109 ROMS
6110 
6111 9346.u126 - 93C46
6112 ofdox3.U124 - 27C010
6113 ofp1f3.U513 - 27C4000
6114 ofpof3.U514 - 27C4000
6115 of101f0223.U101 - 27C800
6116 of20902011.u17 - 27C040
6117 of210000213.u19 - 27C040
6118 of2110215.u21 - 27C040
6119 of21200217.u23 - 27C040
6120 of21300219.u25 - 27C040
6121 of21400221.u27 - 27C040
6122 of1000222.u99 - 27C800
6123 of0010226.u55 - 27C800
6124 of3000225.u51 - 27C800
6125 of2080209.u28 - 27V160
6126 of2060207.u14 - 27V160
6127 of2070208.u15 - 27V160
6128 of2050206.u13 - 27V160
6129 of2040205.u12 - 27V160
6130 of2030204.u11 - 27V160
6131 of2020203.u10 - 27V160
6132 of2010202.u9 - 27V160
6133 of2000201.u8 - 27V160
6134 of209e0210.u16 - 27C040
6135 of210e0212.u18 - 27C040
6136 of211e0214.u20 - 27C040
6137 of212e0216.u22 - 27C040
6138 of213e0218.u24 - 27C040
6139 of214e0220.u26 - 27C040
6140 
6141 ***************************************************************************/
6142 
6143 ROM_START( bloodwar )
6144  	ROM_REGION( 0x100000, REGION_CPU1, 0 )			/* 68000 Code */
6145 	ROM_LOAD16_BYTE( "pof3.514", 0x000000, 0x080000, CRC(0c93da15) SHA1(65b6b1b4acfc32c551ae4fbe6a13f7f2b8554dbf) )
6146 	ROM_LOAD16_BYTE( "p1f3.513", 0x000001, 0x080000, CRC(894ecbe5) SHA1(bf403d19e6315266114ac742a08cac903e7b54b5) )
6147 
6148  	ROM_REGION( 0x020000, REGION_CPU2, 0 )			/* MCU Code */
6149 	ROM_LOAD16_WORD_SWAP( "dox3.124",  0x000000, 0x020000, CRC(399f2005) SHA1(ff0370724770c35963953fd9596d9f808ba87d8f) )
6150 
6151 	ROM_REGION( 0x1e00000, REGION_GFX1, 0 )	/* Sprites */
6152 	ROM_LOAD       ( "2000201.8",   0x0000000, 0x200000, CRC(bba63025) SHA1(daec5285469ee953f6f838fe3cb3903524e9ac39) )
6153 	ROM_LOAD       ( "2010202.9",   0x0200000, 0x200000, CRC(4ffd9ddc) SHA1(62bc8c0ed2efab407fc2956c514c3e732bcc47ee) )
6154 	ROM_LOAD       ( "2020203.10",  0x0400000, 0x200000, CRC(fbcc5363) SHA1(9eff48c29d5c887d39e4db442c6ee51ec879521e) )
6155 	ROM_LOAD       ( "2030204.11",  0x0600000, 0x200000, CRC(8e818ce9) SHA1(bc37d35247edfc563400cd67459d455b1fea6eab) )
6156 	ROM_LOAD       ( "2040205.12",  0x0800000, 0x200000, CRC(70c4a76b) SHA1(01b17bda156f2e6f480bdc976927c8bba47c1186) )
6157 	ROM_LOAD       ( "2050206.13",  0x0a00000, 0x200000, CRC(80c667bb) SHA1(7edf33c713c8448ff73fa84b9f7684dd4d46eed1) )
6158 	ROM_LOAD       ( "2060207.14",  0x0c00000, 0x200000, CRC(c2028c97) SHA1(ac3b73ff34f84015432ceb22cf9c57ab0ff07a70) )
6159 	ROM_LOAD       ( "2070208.15",  0x0e00000, 0x200000, CRC(b1f30c61) SHA1(2ae010c10b7a2ae09df904f7ea81425e80389622) )
6160 	ROM_LOAD       ( "2080209.28",  0x1000000, 0x200000, CRC(a8f29545) SHA1(5d018147aa71207f679909343104deaa0f08fd9d) )
6161 	ROM_LOAD16_BYTE( "209e0210.16", 0x1200000, 0x100000, CRC(93018468) SHA1(d156f408a78fbd736048ce33e44c0b1e10403b0e) )
6162 	ROM_LOAD16_BYTE( "20902011.17", 0x1200001, 0x100000, CRC(3fb226a1) SHA1(efba54f82fb9914559faad5fba92aa108ec039d5) )
6163 	ROM_LOAD16_BYTE( "210e0212.18", 0x1400000, 0x100000, CRC(80f3fa1b) SHA1(ca0e84cb47228ef5ac3b94238a33c3ebc3c2f528) )
6164 	ROM_LOAD16_BYTE( "21000213.19", 0x1400001, 0x100000, CRC(8ca3a3d6) SHA1(b6f3876f987ce6828bfa26ca492ff6ca2d282d80) )
6165 	ROM_LOAD16_BYTE( "211e0214.20", 0x1600000, 0x100000, CRC(8d3d96f7) SHA1(0a7c459f02938f86d53979498647c73837eb9e51) )
6166 	ROM_LOAD16_BYTE( "21100215.21", 0x1600001, 0x100000, CRC(78268230) SHA1(63fbf88551f6fde833222ae6a4382891e1bf5b39) )
6167 	ROM_LOAD16_BYTE( "212e0216.22", 0x1800000, 0x100000, CRC(5a013d99) SHA1(c4af944c8f0b33a93b4bb083e32e2901c5607a39) )
6168 	ROM_LOAD16_BYTE( "21200217.23", 0x1800001, 0x100000, CRC(84ed25bd) SHA1(ddff811d326586eb7353230e74db37867af075eb) )
6169 	ROM_LOAD16_BYTE( "213e0218.24", 0x1a00000, 0x100000, CRC(861bc5b1) SHA1(a85936781a56b5406bee2e4f36fadcb5b9f43b05) )
6170 	ROM_LOAD16_BYTE( "21300219.25", 0x1a00001, 0x100000, CRC(a79b8119) SHA1(62e3fb28fd3a538a8191a51242dbed7e88c62a54) )
6171 	ROM_LOAD16_BYTE( "214e0220.26", 0x1c00000, 0x100000, CRC(43c622de) SHA1(73efe57233f056127e2d34590c624f39d1c0ab79) )
6172 	ROM_LOAD16_BYTE( "21400221.27", 0x1c00001, 0x100000, CRC(d10bf03c) SHA1(a81d6b7df7382fc8d50614c1332611e0c202b805) )
6173 
6174 	ROM_REGION( 0x100000, REGION_GFX2, 0 )	/* Tiles (scrambled) */
6175 	ROM_LOAD( "3000225.51", 0x000000, 0x100000, CRC(fbc3c08a) SHA1(0ba52b381e7a10fb1513244b394438b440950af3) )
6176 
6177 	ROM_REGION( 0x100000, REGION_GFX3, 0 )	/* Tiles (scrambled) */
6178 	ROM_LOAD( "3010226.55", 0x000000, 0x100000, CRC(fcf215de) SHA1(83015f10e62b917efd6e3edfbd45fb8f9b35db2b) )
6179 
6180 	ROM_REGION( 0x400000, REGION_SOUND1, 0 )	/* Samples, plus room for expansion */
6181 	ROM_LOAD( "101f0223.101", 0x000000, 0x100000, CRC(295f3c93) SHA1(558698f1d04b23dd2a73e2eae5ecce598defb228) )
6182 
6183 	ROM_REGION( 0x100000, REGION_SOUND2, 0 )	/* Samples */
6184 	ROM_LOAD( "1000222.99",   0x000000, 0x100000, CRC(42b12269) SHA1(f9d9c42057e176710f09e8db0bfcbf603c15ca11) )
6185 ROM_END
6186 
6187 
6188 /***************************************************************************
6189 
6190 							Great 1000 Miles Rally
6191 
6192 GMMU2+1	512K * 2	68k
6193 GMMU23	1M		OKI6295: 00000-2ffff + chunks of 0x10000 with headers
6194 GMMU24	1M		OKI6295: chunks of 0x40000 with headers - FIRST AND SECOND HALF IDENTICAL
6195 
6196 GMMU27	2M		sprites
6197 GMMU28	2M		sprites
6198 GMMU29	2M		sprites
6199 GMMU30	512k	sprites
6200 
6201 GMMU64	1M		sprites - FIRST AND SECOND HALF IDENTICAL
6202 GMMU65	1M		sprites - FIRST AND SECOND HALF IDENTICAL
6203 
6204 GMMU52	2M		tiles
6205 
6206 
6207 ---------------------------------------------------------------------------
6208 								Game code
6209 ---------------------------------------------------------------------------
6210 
6211 100000.b	<- (!b00000.b) & 7f	[1p]
6212     01.b	previous value of the above
6213     02.b	bits gone high
6214 
6215 100008.b	<- (!b00002.b) & 7f	[2p]
6216 
6217 100010.b	<- !b00004.b [coins]
6218     11.b	previous value of the above
6219     12.b	bits gone high
6220 
6221 100013.b	<- b00006.b	(both never accessed again?)
6222 
6223 100015.b	<- wheel value
6224 
6225 600000.w	<- 100a20.w + 100a30.w		600002.w	<- 100a22.w + 100a32.w
6226 600004.w	<- 100a24.w + 100a34.w		600006.w	<- 100a26.w + 100a36.w
6227 
6228 680000.w	<- 100a28.w + 100a38.w		680002.w	<- 100a2a.w + 100a3a.w
6229 680004.w	<- 100a2c.w + 100a3c.w		680006.w	<- 100a2e.w + 100a3e.w
6230 
6231 101265.b	<- DSW (from 206000)
6232 101266		<- Settings from NVRAM (0x80 bytes from 208000)
6233 
6234 1034f8.b	credits
6235 103502.b	coins x ..
6236 103503.b	.. credits
6237 
6238 1035ec.l	*** Time (BCD: seconds * 10000) ***
6239 103e64.w	*** Speed << 4 ***
6240 
6241 10421a.b	bank for the oki mapped at 800000
6242 104216.b	last value of the above
6243 
6244 10421c.b	bank for the oki mapped at 880000
6245 104218.b	last value of the above
6246 
6247 ROUTINES:
6248 
6249 dd6	print string: a2->scr ; a1->string ; d1.l = xpos.w<<6|ypos.w<<6
6250 
6251 Trap #2 = 43a0 ; d0.w = routine index ; (where not specified: 43c0):
6252 1:  43C4	2:  43F8	3:  448E	4:  44EE
6253 5:  44D2	6:  4508	7:  453A	10: 0AF6
6254 18: 4580	19: 4604
6255 20> 2128	writes 700000-70001f
6256 21: 21F6
6257 24> 2346	clears 400000-401407 (641*8 = $281*8)
6258 30> 282A	writes 600008/9/b/e-f, 680008/9/b/e-f
6259 31: 295A
6260 32> 2B36	100a30-f <- 100a10-f
6261 34> 2B4C	clears 500000-503fff, 580000-583fff
6262 35> 2B9E	d1.w = selects between:	500000;501000;580000;581000.
6263 			Fill 0x1000 bytes from there with d2.l
6264 
6265 70: 2BCE>	11d8a
6266 71: 2BD6
6267 74: 2BDE	90: 3D44
6268 91> 3D4C	wait for bit 0 of d00000 to be 0
6269 92> 3D5C	200010.w<-D1	200012.w<-D2	200014.w<-D3
6270 f1: 10F6
6271 
6272 ***************************************************************************/
6273 
6274 /*	This version displays:
6275 
6276 	tb05mm-eu "1000 miglia"
6277 	master up= 94/07/18 15:12:35			*/
6278 
6279 ROM_START( gtmr )
6280  	ROM_REGION( 0x100000, REGION_CPU1, 0 )			/* 68000 Code */
6281 	ROM_LOAD16_BYTE( "u2.bin", 0x000000, 0x080000, CRC(031799f7) SHA1(a59a9635002d139247828e3b74f6cf2fbdd5e569) )
6282 	ROM_LOAD16_BYTE( "u1.bin", 0x000001, 0x080000, CRC(6238790a) SHA1(a137fd581138804534f3193068f117611a982004) )
6283 
6284  	ROM_REGION( 0x020000, REGION_CPU2, 0 )			/* MCU Code */
6285 	ROM_LOAD( "mmd0x2.u124.bin",  0x000000, 0x020000, CRC(3d7cb329) SHA1(053106acde642a414fde0b01105fe6762b6a10f6) ) /* from gtmra*/
6286 
6287 	ROM_REGION( 0x840000, REGION_GFX1, ROMREGION_DISPOSE )	/* Sprites */
6288 	ROM_LOAD( "mm-200-402-s0.bin",  0x000000, 0x200000, CRC(c0ab3efc) SHA1(e6cd15480977b036234d91e6f3a6e21b7f0a3c3e) )
6289 	ROM_LOAD( "mm-201-403-s1.bin",  0x200000, 0x200000, CRC(cf6b23dc) SHA1(ccfd0b17507e091e55c169361cd6a6b19641b717) )
6290 	ROM_LOAD( "mm-202-404-s2.bin",  0x400000, 0x200000, CRC(8f27f5d3) SHA1(219a86446ce2556682009d8aff837480f040a01e) )
6291 	ROM_LOAD( "mm-203-405-s3.bin",  0x600000, 0x080000, CRC(e9747c8c) SHA1(2507102ec34755c6f110eadb3444e6d3a3474051) )
6292   	ROM_LOAD16_BYTE( "mms1x2.u30.bin",  0x800001, 0x020000, CRC(b42b426f) SHA1(6aee5759b5f0786c5ee074d9df3d2716919ea621) )
6293   	ROM_LOAD16_BYTE( "mms0x2.u29.bin",  0x800000, 0x020000, CRC(bd22b7d2) SHA1(ef82d00d72439590c71aed33ecfabc6ee71a6ff9) )
6294 
6295 	ROM_REGION( 0x200000, REGION_GFX2, ROMREGION_DISPOSE )	/* Tiles (scrambled) */
6296 	ROM_LOAD( "mm-300-406-a0.bin",  0x000000, 0x200000, CRC(b15f6b7f) SHA1(5e84919d788add53fc87f4d85f437df413b1dbc5) )
6297 
6298 	ROM_REGION( 0x200000, REGION_GFX3, ROMREGION_DISPOSE )	/* Tiles (scrambled) */
6299 	ROM_COPY(REGION_GFX2,0,0,0x200000) /* it isn't on the board twice.*/
6300 
6301 	ROM_REGION( 0x400000, REGION_SOUND1, 0 )	/* Samples, plus room for expansion */
6302 	ROM_LOAD( "mm-100-401-e0.bin",  0x000000, 0x100000, CRC(b9cbfbee) SHA1(051d48a68477ef9c29bd5cc0bb7955d513a0ab94) )	/* 16 x $10000*/
6303 
6304 	ROM_REGION( 0x100000, REGION_SOUND2, 0 )	/* Samples */
6305 	/* Not present on this board */
6306 ROM_END
6307 
6308 /*	This version displays:
6309 
6310 	tb05mm-eu "1000 miglia"
6311 	master up= 94/09/06 14:49:19			*/
6312 
6313 ROM_START( gtmre )
6314  	ROM_REGION( 0x100000, REGION_CPU1, 0 )			/* 68000 Code */
6315 	ROM_LOAD16_BYTE( "gmmu2.bin", 0x000000, 0x080000, CRC(36dc4aa9) SHA1(0aea4dc169d7aad2ea957a1de698d1fa12c71556) )
6316 	ROM_LOAD16_BYTE( "gmmu1.bin", 0x000001, 0x080000, CRC(8653c144) SHA1(a253a01327a9443337a55a13c063ea5096444c4c) )
6317 
6318  	ROM_REGION( 0x020000, REGION_CPU2, 0 )			/* MCU Code */
6319 	ROM_LOAD( "mcu_code.u12",  0x000000, 0x020000, NO_DUMP )
6320 
6321 	ROM_REGION( 0x800000, REGION_GFX1, ROMREGION_DISPOSE )	/* Sprites */
6322 	/* fill the 0x700000-7fffff range first, with the second of the identical halves */
6323 	ROM_LOAD16_BYTE( "gmmu64.bin",  0x600000, 0x100000, CRC(57d77b33) SHA1(f7ae28ae889be4442b7b236705943eaad1f0c84e) )	/* HALVES IDENTICAL*/
6324 	ROM_LOAD16_BYTE( "gmmu65.bin",  0x600001, 0x100000, CRC(05b8bdca) SHA1(44471d66787d5b48ae8b13676f42f27af44e5c6a) )	/* HALVES IDENTICAL*/
6325 	ROM_LOAD( "gmmu27.bin",  0x000000, 0x200000, CRC(c0ab3efc) SHA1(e6cd15480977b036234d91e6f3a6e21b7f0a3c3e) )
6326 	ROM_LOAD( "gmmu28.bin",  0x200000, 0x200000, CRC(cf6b23dc) SHA1(ccfd0b17507e091e55c169361cd6a6b19641b717) )
6327 	ROM_LOAD( "gmmu29.bin",  0x400000, 0x200000, CRC(8f27f5d3) SHA1(219a86446ce2556682009d8aff837480f040a01e) )
6328 	ROM_LOAD( "gmmu30.bin",  0x600000, 0x080000, CRC(e9747c8c) SHA1(2507102ec34755c6f110eadb3444e6d3a3474051) )
6329 	/* codes 6800-6fff are explicitly skipped */
6330 
6331 	ROM_REGION( 0x200000, REGION_GFX2, ROMREGION_DISPOSE )	/* Tiles (scrambled) */
6332 	ROM_LOAD( "gmmu52.bin",  0x000000, 0x200000, CRC(b15f6b7f) SHA1(5e84919d788add53fc87f4d85f437df413b1dbc5) )
6333 
6334 	ROM_REGION( 0x200000, REGION_GFX3, ROMREGION_DISPOSE )	/* Tiles (scrambled) */
6335 	ROM_LOAD( "gmmu52.bin",  0x000000, 0x200000, CRC(b15f6b7f) SHA1(5e84919d788add53fc87f4d85f437df413b1dbc5) )
6336 
6337 	ROM_REGION( 0x100000, REGION_SOUND1, 0 )	/* Samples */
6338 	ROM_LOAD( "gmmu23.bin",  0x000000, 0x100000, CRC(b9cbfbee) SHA1(051d48a68477ef9c29bd5cc0bb7955d513a0ab94) )	/* 16 x $10000*/
6339 
6340 	ROM_REGION( 0x100000, REGION_SOUND2, 0 )	/* Samples */
6341 	ROM_LOAD( "gmmu24.bin",  0x000000, 0x100000, CRC(380cdc7c) SHA1(ba7f51201b0f2bf15e66557e45bb2af5cf797779) )	/*  2 x $40000 - HALVES IDENTICAL*/
6342 ROM_END
6343 
6344 
6345 /*	This version displays:
6346 
6347 	tb05mm-eu "1000 miglia"
6348 	master up= 94/09/06 20:30:39			*/
6349 
6350 ROM_START( gtmrusa )
6351  	ROM_REGION( 0x100000, REGION_CPU1, 0 )			/* 68000 Code */
6352 	ROM_LOAD16_BYTE( "gtmrusa.u2", 0x000000, 0x080000, CRC(5be615c4) SHA1(c14d11a5bf6e025a65b932039165302ff407c4e1) )
6353 	ROM_LOAD16_BYTE( "gtmrusa.u1", 0x000001, 0x080000, CRC(ae853e4e) SHA1(31eaa73b0c5ddab1292f521ceec43b202653efe9) )
6354 
6355  	ROM_REGION( 0x020000, REGION_CPU2, 0 )			/* MCU Code? */
6356 	ROM_LOAD( "gtmrusa.u12",  0x000000, 0x020000, CRC(2e1a06ff) SHA1(475a7555653eefac84307492a385895b839cab0d) )
6357 
6358 	ROM_REGION( 0x800000, REGION_GFX1, ROMREGION_DISPOSE )	/* Sprites */
6359 	/* fill the 0x700000-7fffff range first, with the second of the identical halves */
6360 	ROM_LOAD16_BYTE( "gmmu64.bin",  0x600000, 0x100000, CRC(57d77b33) SHA1(f7ae28ae889be4442b7b236705943eaad1f0c84e) )	/* HALVES IDENTICAL*/
6361 	ROM_LOAD16_BYTE( "gmmu65.bin",  0x600001, 0x100000, CRC(05b8bdca) SHA1(44471d66787d5b48ae8b13676f42f27af44e5c6a) )	/* HALVES IDENTICAL*/
6362 	ROM_LOAD( "gmmu27.bin",  0x000000, 0x200000, CRC(c0ab3efc) SHA1(e6cd15480977b036234d91e6f3a6e21b7f0a3c3e) )
6363 	ROM_LOAD( "gmmu28.bin",  0x200000, 0x200000, CRC(cf6b23dc) SHA1(ccfd0b17507e091e55c169361cd6a6b19641b717) )
6364 	ROM_LOAD( "gmmu29.bin",  0x400000, 0x200000, CRC(8f27f5d3) SHA1(219a86446ce2556682009d8aff837480f040a01e) )
6365 	ROM_LOAD( "gmmu30.bin",  0x600000, 0x080000, CRC(e9747c8c) SHA1(2507102ec34755c6f110eadb3444e6d3a3474051) )
6366 	/* codes 6800-6fff are explicitly skipped */
6367 
6368 	ROM_REGION( 0x200000, REGION_GFX2, ROMREGION_DISPOSE )	/* Tiles (scrambled) */
6369 	ROM_LOAD( "gmmu52.bin",  0x000000, 0x200000, CRC(b15f6b7f) SHA1(5e84919d788add53fc87f4d85f437df413b1dbc5) )
6370 
6371 	ROM_REGION( 0x200000, REGION_GFX3, ROMREGION_DISPOSE )	/* Tiles (scrambled) */
6372 	ROM_LOAD( "gmmu52.bin",  0x000000, 0x200000, CRC(b15f6b7f) SHA1(5e84919d788add53fc87f4d85f437df413b1dbc5) )
6373 
6374 	ROM_REGION( 0x100000, REGION_SOUND1, 0 )	/* Samples */
6375 	ROM_LOAD( "gmmu23.bin",  0x000000, 0x100000, CRC(b9cbfbee) SHA1(051d48a68477ef9c29bd5cc0bb7955d513a0ab94) )	/* 16 x $10000*/
6376 
6377 	ROM_REGION( 0x100000, REGION_SOUND2, 0 )	/* Samples */
6378 	ROM_LOAD( "gmmu24.bin",  0x000000, 0x100000, CRC(380cdc7c) SHA1(ba7f51201b0f2bf15e66557e45bb2af5cf797779) )	/*  2 x $40000 - HALVES IDENTICAL*/
6379 ROM_END
6380 
6381 
6382 /***************************************************************************
6383 
6384 						Great 1000 Miles Rally 2
6385 
6386 Bootup displays "TB06MM2EX 1000 Miglia 2"
6387                 "Master Up 95-04-04 19:39:01"
6388 
6389 Top board
6390 ---------
6391 PCB ID : M201F00138  KANEKO AX-SYSTEM BOARD
6392 CPU    : TMP68HC000N-16 (68000)
6393 SOUND  : Oki M6295 (x2)
6394 OSC    : 27.000MHz, 16.000MHz, 20.000MHz, 33.3330MHz
6395 RAM    : LC3664 (28 pin SOIC, x4)
6396          UT6264 (28 pin SOIC, x2)
6397          LH628256 (28 pin DIP, x6)
6398          D42101 (24 pin DIP, x2)
6399          424260 (40 pin SOIC, x2)
6400 PALs   : AXOP048, AXOP049, AXOP050 (GAL16V8, near M6295's)
6401          AXOP021 \
6402          AXOP022  |
6403          AXOP062  |
6404          AXOP063  |  (18CV8     )
6405          AXOP064  |  (near 68000)
6406          AXOP070  |
6407          AXOP071  |
6408          AXOP089 /
6409 
6410 OTHER  : Custom chips
6411                       Kaneko Japan 9448 TA (44 pin PQFP, near JAMMA connector)
6412                       Kaneko VIEW2-CHIP (x2, 144 pin PQFP)
6413                       Kaneko KC002 L0002 023 9339EK706 (208 pin PQFP)
6414 
6415 ROMs   : None
6416 
6417 
6418 Bottom board
6419 ------------
6420 PCB ID : AX09S00138  KANEKO AX-SYSTEM BOARD ROM-08
6421 DIP    : 8 position (x1)
6422 RAM    : 6116 (x4)
6423 PALs   : COMUX4, COMUX4 (GAL16V8, near U21)
6424          MMs4P067 (18CV8, near U47)
6425          MMs6G095 (GAL16V8, near U94)
6426          MMs4G084 (GAL16V8, near U50)
6427          COMUX2, COMUX3 (GAL16V8, near U33)
6428          COMUX1, MMS4P004 (18CV8, near U33)
6429 
6430 OTHER  : 93C46 EEPROM
6431          KANEKO TBSOP02 454 9451MK002 (74 pin PQFP, Custom MCU?)
6432 
6433 ROMs   :  (filename is ROM Label, extension is PCB 'u' location)
6434 
6435 ***************************************************************************/
6436 
6437 ROM_START( gtmr2 )
6438  	ROM_REGION( 0x100000, REGION_CPU1, 0 )			/* 68000 Code */
6439 	ROM_LOAD16_BYTE( "m2p0x1.u8",  0x000000, 0x080000, CRC(525f6618) SHA1(da8008cc7768b4e8c0091aa3ea21752d0ca33691) )
6440 	ROM_LOAD16_BYTE( "m2p1x1.u7",  0x000001, 0x080000, CRC(914683e5) SHA1(dbb2140f7de86073647abc6e73ba739ea201dd30) )
6441 
6442  	ROM_REGION( 0x020000, REGION_CPU2, 0 )			/* MCU Code? */
6443 	ROM_LOAD( "m2d0x0.u31",        0x000000, 0x020000, CRC(2e1a06ff) SHA1(475a7555653eefac84307492a385895b839cab0d) )
6444 
6445 	ROM_REGION( 0x800000, REGION_GFX1, 0 )	/* Sprites */
6446 	ROM_LOAD( "m2-200-0.u49",      0x000000, 0x400000, CRC(93aafc53) SHA1(1d28b6e3bd61ce9c938fc5303aeabcdefa549852) )
6447 	ROM_LOAD( "m2-201-0.u50",      0x400000, 0x200000, CRC(39b60a83) SHA1(aa7b37c7c92bbcf685f4fec84cc6d8a77d26433c) )
6448 	ROM_LOAD( "m2-202-0.u51",      0x600000, 0x200000, CRC(fd06b339) SHA1(5de0af7d23147f6eb403700eabd66794198f3641) )
6449 	ROM_LOAD16_BYTE( "m2s0x1.u32", 0x700000, 0x080000, CRC(4069d6c7) SHA1(2ed1cbb7ebde8347e0359cd56ee3a0d4d42d551f) )
6450 	ROM_LOAD16_BYTE( "m2s1x1.u33", 0x700001, 0x080000, CRC(c53fe269) SHA1(e6c485bbaea4b67f074b89e047f686f107805713) )
6451 
6452 	ROM_REGION( 0x440000, REGION_GFX2, 0 )	/* Tiles (scrambled) */
6453 	ROM_LOAD( "m2-300-0.u89",      0x000000, 0x200000, CRC(4dc42fbb) SHA1(f14c287bc60f561eb9a57db4e3390aae9a81c392) )
6454 	ROM_LOAD( "m2-301-0.u90",      0x200000, 0x200000, CRC(f4e894f2) SHA1(1f983a1d93845fe298afba60d4dacdd1a10cab7f) )
6455 	ROM_LOAD16_BYTE( "m2b0x0.u93", 0x400000, 0x020000, CRC(e023d51b) SHA1(3c9f591f3ca2ee8e1100b83ae8eb593e11e6eac7) )
6456 	ROM_LOAD16_BYTE( "m2b1x0.u94", 0x400001, 0x020000, CRC(03c48bdb) SHA1(f5ba45d026530d46f760cf06d02a1ffcca89aa3c) )
6457 
6458 	ROM_REGION( 0x440000, REGION_GFX3, 0 )	/* Tiles (scrambled) */
6459 	ROM_COPY(REGION_GFX2,0,0,0x440000) /* it isn't on the board twice.*/
6460 
6461 	ROM_REGION( 0x400000, REGION_SOUND1, 0 )	/* Samples, plus room for expansion */
6462 	ROM_LOAD( "m2-100-0.u48",      0x000000, 0x100000, CRC(5250fa45) SHA1(b1ad4660906997faea0aa89866de01a0e9f2b61d) )
6463 
6464 	ROM_REGION( 0x080000, REGION_SOUND2, 0 )	/* Samples */
6465 	ROM_LOAD( "m2w1x0.u47",        0x040000, 0x040000, CRC(1b0513c5) SHA1(8c9ddef19297e1b39d900297005203b7ff28667e) )
6466 ROM_END
6467 
6468 
6469 /***************************************************************************
6470 
6471 								Magical Crystals
6472 
6473 (c)1991 Kaneko/Atlus
6474 Z00FC-02
6475 
6476 CPU  : TMP68HC000N-12
6477 Sound: YM2149Fx2 M6295
6478 OSC  : 16.0000MHz(X1) 12.0000MHz(X2)
6479 
6480 ROMs:
6481 mc100j.u18 - Main programs
6482 mc101j.u19 /
6483 
6484 mc000.u38  - Graphics (32pin mask)
6485 mc001.u37  | (32pin mask)
6486 mc002j.u36 / (27c010)
6487 
6488 mc010.u04 - Graphics (42pin mask)
6489 
6490 mc020.u33 - Graphics (42pin mask)
6491 
6492 mc030.u32 - Samples (32pin mask)
6493 
6494 PALs (18CV8PC):
6495 u08, u20, u41, u42, u50, u51, u54
6496 
6497 Custom chips:
6498 KANEKO VU-001 046A (u53, 48pin PQFP)
6499 KANEKO VU-002 052 151021 (u60, 160pin PQFP)
6500 KANEKO 23160-509 9047EAI VIEW2-CHIP (u24 & u34, 144pin PQFP)
6501 KANEKO MUX2-CHIP (u28, 64pin PQFP)
6502 KANEKO IU-001 9045KP002 (u22, 44pin PQFP)
6503 KANEKO I/O JAMMA MC-8282 047 (u5, 46pin)
6504 699206p (u09, 44pin PQFP)
6505 699205p (u10, 44pin PQFP)
6506 
6507 Other:
6508 93C46 EEPROM
6509 
6510 DIP settings:
6511 1: Flip screen
6512 2: Test mode
6513 3: Unused
6514 4: Unused
6515 
6516 ***************************************************************************/
6517 
6518 ROM_START( mgcrystl )
6519  	ROM_REGION( 0x040000*2, REGION_CPU1, ROMREGION_ERASE )			/* 68000 Code */
6520 	ROM_LOAD16_BYTE( "magcrstl.u18", 0x000000, 0x020000, CRC(c7456ba7) SHA1(96c25c3432069373fa86d7af3e093e02e39aea34) )
6521 	ROM_LOAD16_BYTE( "magcrstl.u19", 0x000001, 0x040000, CRC(ea8f9300) SHA1(0cd0d448805aa45986b63befca00b08fe066dbb2) ) /*!!*/
6522 
6523 	ROM_REGION( 0x280000, REGION_GFX1, ROMREGION_DISPOSE )	/* Sprites */
6524 	ROM_LOAD( "mc000.u38",    0x000000, 0x100000, CRC(28acf6f4) SHA1(6647ad90ea580b65ed28772f9d65352b06833d0c) )
6525 	ROM_LOAD( "mc001.u37",    0x100000, 0x080000, CRC(005bc43d) SHA1(6f6cd99e8e60562fa86581008455a6d9d646fa95) )
6526 	ROM_RELOAD(               0x180000, 0x080000             )
6527 	ROM_LOAD( "magcrstl.u36", 0x200000, 0x020000, CRC(22729037) SHA1(de4e1bdab57aa617411b6327f3db4856970e8953) )
6528 	ROM_RELOAD(               0x220000, 0x020000             )
6529 	ROM_RELOAD(               0x240000, 0x020000             )
6530 	ROM_RELOAD(               0x260000, 0x020000             )
6531 
6532 	ROM_REGION( 0x100000, REGION_GFX2, ROMREGION_DISPOSE )	/* Tiles (Scrambled) */
6533 	ROM_LOAD( "mc010.u04",  0x000000, 0x100000, CRC(85072772) SHA1(25e903cc2c893d61db791d1fe60a1205a4395667) )
6534 
6535 	ROM_REGION( 0x100000, REGION_GFX3, ROMREGION_DISPOSE )	/* Tiles (Scrambled) */
6536 	ROM_LOAD( "mc020.u34",  0x000000, 0x100000, CRC(1ea92ff1) SHA1(66ec53e664b2a5a751a280a538aaeceafc187ceb) )
6537 
6538 	ROM_REGION( 0x040000, REGION_SOUND1, 0 )	/* Samples */
6539 	ROM_LOAD( "mc030.u32",  0x000000, 0x040000, CRC(c165962e) SHA1(f7e130db387ae9dcb7223f7ad6e51270d3033bc9) )
6540 ROM_END
6541 
6542 ROM_START( mgcrystj )
6543  	ROM_REGION( 0x040000*2, REGION_CPU1, ROMREGION_ERASE )			/* 68000 Code */
6544 	ROM_LOAD16_BYTE( "mc100j.u18", 0x000000, 0x020000, CRC(afe5882d) SHA1(176e6e12e3df63c08d7aff781f5e5a9bd83ec293) )
6545 	ROM_LOAD16_BYTE( "mc101j.u19", 0x000001, 0x040000, CRC(60da5492) SHA1(82b90a617d355825624ce9fb30bddf4714bd0d18) )	/*!!*/
6546 
6547 	ROM_REGION( 0x280000, REGION_GFX1, ROMREGION_DISPOSE )	/* Sprites */
6548 	ROM_LOAD( "mc000.u38",  0x000000, 0x100000, CRC(28acf6f4) SHA1(6647ad90ea580b65ed28772f9d65352b06833d0c) )
6549 	ROM_LOAD( "mc001.u37",  0x100000, 0x080000, CRC(005bc43d) SHA1(6f6cd99e8e60562fa86581008455a6d9d646fa95) )
6550 	ROM_RELOAD(             0x180000, 0x080000             )
6551 	ROM_LOAD( "mc002j.u36", 0x200000, 0x020000, CRC(27ac1056) SHA1(34b07c1a0d403ca45c9849d3d8d311012f787df6) )
6552 	ROM_RELOAD(             0x220000, 0x020000             )
6553 	ROM_RELOAD(             0x240000, 0x020000             )
6554 	ROM_RELOAD(             0x260000, 0x020000             )
6555 
6556 	ROM_REGION( 0x100000, REGION_GFX2, ROMREGION_DISPOSE )	/* Tiles (Scrambled) */
6557 	ROM_LOAD( "mc010.u04",  0x000000, 0x100000, CRC(85072772) SHA1(25e903cc2c893d61db791d1fe60a1205a4395667) )
6558 
6559 	ROM_REGION( 0x100000, REGION_GFX3, ROMREGION_DISPOSE )	/* Tiles (Scrambled) */
6560 	ROM_LOAD( "mc020.u34",  0x000000, 0x100000, CRC(1ea92ff1) SHA1(66ec53e664b2a5a751a280a538aaeceafc187ceb) )
6561 
6562 	ROM_REGION( 0x040000, REGION_SOUND1, 0 )	/* Samples */
6563 	ROM_LOAD( "mc030.u32",  0x000000, 0x040000, CRC(c165962e) SHA1(f7e130db387ae9dcb7223f7ad6e51270d3033bc9) )
6564 ROM_END
6565 
6566 
6567 /***************************************************************************
6568 
6569 								Sand Scorpion
6570 
6571 (C) FACE
6572 68HC000N-12
6573 Z8400AB1
6574 OKI6295, YM2203C
6575 OSC:  16.000mhz,   12.000mhz
6576 
6577 SANDSC03.BIN     27C040
6578 SANDSC04.BIN     27C040
6579 SANDSC05.BIN     27C040
6580 SANDSC06.BIN     27C040
6581 SANDSC07.BIN     27C2001
6582 SANDSC08.BIN     27C1001
6583 SANDSC11.BIN     27C2001
6584 SANDSC12.BIN     27C2001
6585 
6586 ***************************************************************************/
6587 
6588 ROM_START( sandscrp )
6589 	ROM_REGION( 0x080000, REGION_CPU1, 0 )		/* 68000 Code */
6590 	ROM_LOAD16_BYTE( "sandsc11.bin", 0x000000, 0x040000, CRC(9b24ab40) SHA1(3187422dbe8b15d8053be4cb20e56d3e6afbd5f2) )
6591 	ROM_LOAD16_BYTE( "sandsc12.bin", 0x000001, 0x040000, CRC(ad12caee) SHA1(83267445b89c3cf4dc317106aa68763d2f29eff7) )
6592 
6593 	ROM_REGION( 0x24000, REGION_CPU2, 0 )		/* Z80 Code */
6594 	ROM_LOAD( "sandsc08.bin", 0x00000, 0x0c000, CRC(6f3e9db1) SHA1(06a04fa17f44319986913bff70433510c89e38f1) )
6595 	ROM_CONTINUE(             0x10000, 0x14000             )
6596 
6597 	ROM_REGION( 0x100000, REGION_GFX1, ROMREGION_DISPOSE )	/* Sprites */
6598 	ROM_LOAD( "sandsc05.bin", 0x000000, 0x080000, CRC(9bb675f6) SHA1(c3f6768cfd99a0e19ca2224fff9aa4e27ec0da24) )
6599 	ROM_LOAD( "sandsc06.bin", 0x080000, 0x080000, CRC(7df2f219) SHA1(e2a59e201bfededa92d6c86f8dc1b212527ef66f) )
6600 
6601 	ROM_REGION( 0x100000, REGION_GFX2, ROMREGION_DISPOSE )	/* Layers */
6602 	ROM_LOAD16_BYTE( "sandsc04.bin", 0x000000, 0x080000, CRC(b9222ff2) SHA1(a445da3f7f5dea5ff64bb0b048f624f947875a39) )
6603 	ROM_LOAD16_BYTE( "sandsc03.bin", 0x000001, 0x080000, CRC(adf20fa0) SHA1(67a7a2be774c86916cbb97e4c9b16c2e48125780) )
6604 
6605 	ROM_REGION( 0x040000, REGION_SOUND1, 0 )	/* Samples */
6606 	ROM_LOAD( "sandsc07.bin", 0x000000, 0x040000, CRC(9870ab12) SHA1(5ea3412cbc57bfaa32a1e2552b2eb46f4ceb5fa8) )
6607 ROM_END
6608 
6609 
6610 /***************************************************************************
6611 
6612 								Shogun Warriors
6613 
6614 Shogun Warriors, Kaneko 1992
6615 
6616    fb010.u65           fb040.u33
6617    fb011.u66
6618    rb012.u67
6619    rb013.u68
6620 
6621                          fb001.u43
6622      68000-12            fb000.u42  m6295
6623     51257     fb030.u61  fb002.u44  m6295
6624     51257     fb031.u62  fb003.u45
6625 
6626 
6627                 fb021a.u3
6628                 fb021b.u4
6629                 fb022a.u5
6630    fb023.u7     fb022b.u6
6631    fb020a.u1    fb020b.u2
6632 
6633 
6634 
6635 ---------------------------------------------------------------------------
6636 								Game code
6637 ---------------------------------------------------------------------------
6638 
6639 102e04-7	<- !b80004-7
6640 102e18.w	-> $800000
6641 102e1c.w	-> $800002 , $800006
6642 102e1a.w	-> $800004
6643 102e20.w	-> $800008
6644 
6645 ROUTINES:
6646 
6647 6622	print ($600000)
6648 
6649 ***************************************************************************/
6650 
6651 ROM_START( shogwarr )
6652  	ROM_REGION( 0x040000, REGION_CPU1, 0 )			/* 68000 Code */
6653 	ROM_LOAD16_BYTE( "fb030a.u61", 0x000000, 0x020000, CRC(a04106c6) SHA1(95ab084f2e709be7cec2964cb09bcf5a8d3aacdf) )
6654 	ROM_LOAD16_BYTE( "fb031a.u62", 0x000001, 0x020000, CRC(d1def5e2) SHA1(f442de4433547e52b483549aca5786e4597a7122) )
6655 
6656  	ROM_REGION( 0x020000, REGION_CPU2, 0 )			/* MCU Code */
6657 	ROM_LOAD( "fb040a.u33",  0x000000, 0x020000, CRC(4b62c4d9) SHA1(35c943dde70438a411714070e42a84366db5ef83) )
6658 
6659 	ROM_REGION( 0x1000000, REGION_GFX1, ROMREGION_ERASEFF )	/* Sprites */
6660 	ROM_LOAD( "fb-020a.u1", 0x000000, 0x100000, CRC(87e55c6d) SHA1(87886c045d7c30b8dee3c8fb0bf8f2cdbc5fd7fb) )
6661 	ROM_LOAD( "fb020b.u2",  0x100000, 0x100000, CRC(276b9d7b) SHA1(7a154f65b4737f2b6ac8effa3352711079f571dc) )
6662 	ROM_LOAD( "fb021a.u3",  0x200000, 0x100000, CRC(7da15d37) SHA1(345cf2242e8210a697294a45197f2b3b974de885) )
6663 	ROM_LOAD( "fb021b.u4",  0x300000, 0x100000, CRC(6a512d7b) SHA1(7fc3002d23262a9a590a283ea9e111e38d889ef2) )
6664 	ROM_LOAD( "fb-22a.u5",  0x400000, 0x100000, CRC(9039e5d3) SHA1(222452cd7947f7c99c68e495835cca62e0449b5c) )
6665 	ROM_LOAD( "fb-22b.u6",  0x500000, 0x100000, CRC(96ac9e54) SHA1(2b066375963dc57fe2ce89d65f6c0a9d183a838d) )
6666 	ROM_LOAD( "fb023.u7",   0x600000, 0x100000, CRC(132794bd) SHA1(bcc73c3183c59a4b66f79d04774773b8a9239501) )
6667 
6668 	ROM_REGION( 0x400000, REGION_GFX2, 0 )	/* Tiles (scrambled) */
6669 	ROM_LOAD( "fb010.u65",  0x000000, 0x100000, CRC(296ffd92) SHA1(183a28e4594c428deb4726ed22d5166592b94b60) )	/* 42 pin mask rom*/
6670 	ROM_LOAD( "fb011.u66",  0x100000, 0x080000, CRC(500a0367) SHA1(6dc5190f81b21f59ee56a3b2332c8d86d6599782) )	/* 40 pin mask rom (verified correct)*/
6671 
6672 	ROM_REGION( 0x300000, REGION_USER1, 0 ) /*samples*/
6673 	ROM_LOAD( "fb001e.u43",  0x000000, 0x080000, CRC(f524aaa1) SHA1(006a886f9df2e57c51b61c6cea70a6574fc20304) )
6674 	ROM_LOAD( "fb000e.u42",  0x080000, 0x080000, CRC(969f1465) SHA1(4f56d1ad341b08f4db41b7ab2498740612ff7c3d) )
6675 
6676 	/* Sound data is copied here during driver init */
6677 	ROM_REGION( 0x400000*16, REGION_SOUND1, 0 )
6678 	ROM_FILL(                0x00000, 0x400000*16, 0x00 )
6679 
6680 	ROM_REGION( 0x200000, REGION_SOUND2, 0 )
6681 	ROM_LOAD( "fb-002.u45",   0x000000, 0x100000, CRC(010acc17) SHA1(2dc0897c7778eacf6bce12ff0adbadb307ea6c17) )
6682 	ROM_LOAD( "fb-003.u44",   0x100000, 0x100000, CRC(0aea4ac5) SHA1(8f3b30e505b0ba51c140a0a2c071680d4fa05db9) )
6683 ROM_END
6684 
6685 /***************************************************************************
6686 
6687 								Fujiyama Buster
6688 
6689 Japan (c) 1992 Kaneko
6690 This is the Japanese version of Shogun Warriors
6691 
6692 Main PCB No: ZO1DK-002 (Same as B.Rap Boys)
6693  ROM PCB No: ZO5DP
6694         CPU: TMP68HC000N-12 (Toshiba)
6695         SND: OKI M6295 x 2
6696         OSC: 16.000MHz, 12.000MHz
6697         DIP: 1 x 8 POSITION
6698 
6699 OTHER:
6700 93C46 (8 Pin DIP, EEPROM, Linked to FB-040.U33 & CALC3 Chip)
6701 KANEKO JAPAN 9152EV 175101 (160 Pin PQFP)
6702 KANEKO VIEW2-CHIP (144 Pin PQFP)
6703 KANEKO MUX2-CHIP (64 Pin PQFP)
6704 KANEKO CALC3 508 (74 Pin PQFP, MCU, Linked to FB-040.U33)
6705 KANEKO JAPAN 9203 T (44 PIN PQFP)
6706 
6707 Differences from Shogun Warriors:
6708 
6709 File Name    CRC32       Labelled As   ROM Type
6710 ===============================================
6711 fb030j.u61   0x32ce7909  FB030J/U61-00   27C010 | 68000 CPU Code
6712 fb031j.u62   0x000c8c08  FB031J/U62-00   27C010 /
6713 
6714 fb040j.u33   0x299d0746  FB040J/U33-00   27C010 - MCU Code? 68000 Code snipets??
6715 
6716 fb000j.u43   0xa7522555  FB000J/U43-00   27C040 | Japanese Sound Samples
6717 fb001j_u.101 0x07d4e8e2  FB001J/U101-0   27C040 /
6718 
6719 NOTE: U67 & U68 are empty on this Original board.
6720 
6721 ***************************************************************************/
6722 
6723 ROM_START( fjbuster )	/* Fujiyama Buster - Japan version of Shogun Warriors*/
6724  	ROM_REGION( 0x040000, REGION_CPU1, 0 )			/* 68000 Code */
6725 	ROM_LOAD16_BYTE( "fb030j.u61", 0x000000, 0x020000, CRC(32ce7909) SHA1(02d87342706ac9547eb611bd542f8498ba41e34a) )
6726 	ROM_LOAD16_BYTE( "fb031j.u62", 0x000001, 0x020000, CRC(000c8c08) SHA1(439daac1541c34557b5a4308ed69dfebb93abe13) )
6727 
6728  	ROM_REGION( 0x020000, REGION_CPU2, 0 )			/* MCU Code */
6729 	ROM_LOAD( "fb040j.u33",  0x000000, 0x020000, CRC(299d0746) SHA1(67fe3a47ab01fa02ce2bb5836c2041986c19d875) )
6730 
6731 	ROM_REGION( 0x1000000, REGION_GFX1, ROMREGION_ERASEFF )	/* Sprites */
6732 	ROM_LOAD( "fb-020a.u1", 0x000000, 0x100000, CRC(87e55c6d) SHA1(87886c045d7c30b8dee3c8fb0bf8f2cdbc5fd7fb) )
6733 	ROM_LOAD( "fb020b.u2",  0x100000, 0x100000, CRC(276b9d7b) SHA1(7a154f65b4737f2b6ac8effa3352711079f571dc) )
6734 	ROM_LOAD( "fb021a.u3",  0x200000, 0x100000, CRC(7da15d37) SHA1(345cf2242e8210a697294a45197f2b3b974de885) )
6735 	ROM_LOAD( "fb021b.u4",  0x300000, 0x100000, CRC(6a512d7b) SHA1(7fc3002d23262a9a590a283ea9e111e38d889ef2) )
6736 	ROM_LOAD( "fb-22a.u5",  0x400000, 0x100000, CRC(9039e5d3) SHA1(222452cd7947f7c99c68e495835cca62e0449b5c) )
6737 	ROM_LOAD( "fb-22b.u6",  0x500000, 0x100000, CRC(96ac9e54) SHA1(2b066375963dc57fe2ce89d65f6c0a9d183a838d) )
6738 	ROM_LOAD( "fb023.u7",   0x600000, 0x100000, CRC(132794bd) SHA1(bcc73c3183c59a4b66f79d04774773b8a9239501) )
6739 
6740 	ROM_REGION( 0x400000, REGION_GFX2, 0 )	/* Tiles (scrambled) */
6741 	ROM_LOAD( "fb010.u65",  0x000000, 0x100000, CRC(296ffd92) SHA1(183a28e4594c428deb4726ed22d5166592b94b60) )	/* 42 pin mask rom*/
6742 	ROM_LOAD( "fb011.u66",  0x100000, 0x080000, CRC(500a0367) SHA1(6dc5190f81b21f59ee56a3b2332c8d86d6599782) )	/* 40 pin mask rom (verified correct)*/
6743 
6744 
6745 	ROM_REGION( 0x300000, REGION_USER1, 0 )
6746 	ROM_LOAD( "fb000j.u43",    0x000000, 0x080000, CRC(a7522555) SHA1(ea88d90dda20bc309f98a1924c41551e7708e6af) )
6747 	ROM_LOAD( "fb001j_u.101",  0x080000, 0x080000, CRC(07d4e8e2) SHA1(0de911f452ddeb54b0b435b9c1cf5d5881175d44) )
6748 
6749 	/* Sound data is copied here during driver init */
6750 	ROM_REGION( 0x400000*16, REGION_SOUND1, 0 )
6751 	ROM_FILL(                0x00000, 0x400000*16, 0x00 )
6752 
6753 	ROM_REGION( 0x200000, REGION_SOUND2, 0 )
6754 	ROM_LOAD( "fb-002.u45",   0x000000, 0x100000, CRC(010acc17) SHA1(2dc0897c7778eacf6bce12ff0adbadb307ea6c17) )
6755 	ROM_LOAD( "fb-003.u44",   0x100000, 0x100000, CRC(0aea4ac5) SHA1(8f3b30e505b0ba51c140a0a2c071680d4fa05db9) )
6756 ROM_END
6757 
6758 /***************************************************************************
6759 
6760 								B.Rap Boys
6761 
6762 B.Rap Boys
6763 Kaneko, 1992
6764 
6765 Game is a beat-em up, where a bunch of rapping boys (The B.Rap Boys) beats
6766 up anyone and anything that gets in their way, smashing shop windows
6767 and other property with their fists, chairs, wooden bats and whatever else
6768 they can lay their hands on!
6769 
6770 
6771 Main PCB No: ZO1DK-002
6772 ROM PCB No:  ZO1DK-EXROM
6773 CPU: TMP68HC000N-12
6774 SND: OKI M6295 x 2
6775 OSC: 16.000MHz, 12.000MHz
6776 DIP: 1 x 8 POSITION
6777 SW1 - PCB location for 2 position DIP but location is unpopulated.
6778 SW2:
6779 
6780 					1	2	3	4	5	6	7	8
6781 SCREEN FLIP		NORMAL		OFF
6782 			FLIP		ON
6783 MODE			NORMAL			OFF
6784 			TEST			ON
6785 SWITCH TEST [1]		NO				OFF
6786 			YES				ON
6787 POSITION #4		NOT USED				OFF
6788 COIN TYPE	 	LOCAL COIN					OFF
6789 			COMMON COIN					ON
6790 GAME TYPE		3 PLAYERS	 					OFF
6791 			2 PLAYERS						ON
6792 DIFFICULTY [2]		EASY								ON	OFF
6793 			NORMAL								OFF	OFF
6794 			HARD								OFF	ON
6795 			VERY HARD							ON	ON
6796 
6797 [1] This additional test becomes available in test mode when this DIP is ON.
6798 [2] Additional settings available in test mode via another on-screen menu.
6799 Some text is written in Japanese. See scan in archive for details.
6800 
6801 Control is via 8 Way Joystick and 2 buttons
6802 
6803 There are two extra pin connectors near the JAMMA connector.
6804 Pinouts are....
6805 
6806 (A)
6807 10 3P START SW
6808  9 3P COIN SW
6809  8 3P BUTTON 2
6810  7 3P BUTTON 1
6811  6 3P UP
6812  5 3P DOWN
6813  4 3P LEFT
6814  3 3P RIGHT
6815  2 GND
6816  1 GND
6817 
6818 (B)
6819 6 COIN COUNTER 3
6820 5 COIN LOCKOUT 3
6821 4 TOTAL COIN COUNTER
6822 3 NC
6823 2 NC
6824 1 NC
6825 
6826 RAM:
6827 M5M4464 x 6, M51257AL x 2, KM6264BLS x 2, D42101C x 2, LH5116D x 2, CAT71C256 x 2
6828 
6829 OTHER:
6830 93C46 (8 PIN DIP, EEPROM, LINKED TO RB-006.U33)
6831 KANEKO JAPAN 9152EV 175101 (160 PIN PQFP)
6832 KANEKO VIEW2-CHIP (144 PIN PQFP)
6833 KANEKO MUX2-CHIP (64 PIN PQFP)
6834 KANEKO CALC3 508 (74 PIN PQFP, MCU, LINKED TO RB-006.U33)
6835 KANEKO JAPAN 9204 T (44 PIN PQFP)
6836 PALs (x 11, read protected, not dumped)
6837 
6838 ROMs:
6839 RB-004.U61	27C010	  \     Main program
6840 RB-005.U62	27C010    /
6841 
6842 RB-000.U43	2M mask	  \
6843 RB-001.U44	4M mask	   |    Located near main program and OKI M6295 chips
6844 RB-002.U45	4M mask	   |    Possibly sound related / OKI Samples etc..
6845 RB-003.101	4M mask	  /
6846 
6847 RB-006.U33	27C010	  	MCU program? (Linked to CALC3 508)
6848 
6849 RB-010.U65	8M mask   \
6850 RB-011.U66	8M mask	   |    GFX
6851 RB-012.U67	8M mask    |
6852 RB-013.U68	8M mask   /
6853 
6854 RB-021.U76	4M mask   \
6855 RB-022.U77	4M mask    |
6856 RB-023.U78	4M mask	   |	GFX (located under a plug-in ROM PCB)
6857 RB-024.U79	4M mask   /
6858 
6859 RB-020.U2	4M mask   \
6860 RB-025.U4	27C040	   |	GFX (located on a plug-in ROM PCB)
6861 RB-026.U5	27C040    /
6862 
6863 
6864 -----
6865 
6866 Game can be ROM Swapped onto a Shogun Warriors board and works
6867 
6868 ***************************************************************************/
6869 
6870 ROM_START( brapboys ) /* Single PCB, fully populated, no rom sub board */
6871  	ROM_REGION( 0x040000, REGION_CPU1, 0 )			/* 68000 Code */
6872 	ROM_LOAD16_BYTE( "rb-030.u61", 0x000000, 0x020000, CRC(ccbe9a53) SHA1(b96baf0ecbf6550bfaf8e512d9275c53a3928bee) )
6873 	ROM_LOAD16_BYTE( "rb-031.u62", 0x000001, 0x020000, CRC(c72b8dda) SHA1(450e1fb8acb140fa0ab23630daad82924f7ce72b) )
6874 
6875  	ROM_REGION( 0x020000, REGION_CPU2, 0 )			/* MCU Code */
6876 	ROM_LOAD( "rb-040.u33",  0x000000, 0x020000, CRC(757c6e19) SHA1(0f1c37b1b1eb6b230c593e4648c4302f413a61f5) )
6877 
6878 	ROM_REGION( 0x600000, REGION_GFX1, ROMREGION_ERASEFF )	/* Sprites */
6879 	ROM_LOAD( "rb-020.c2",  0x000000, 0x100000, CRC(ce220d38) SHA1(b88d7c89a3e1a826bf19a1fa692ec77c944596d9) )
6880 	ROM_LOAD( "rb-021.u76", 0x100000, 0x100000, CRC(74001407) SHA1(90002056ceb4e0401246950b8c3f996af0a2463c) )
6881 	ROM_LOAD( "rb-022.u77", 0x200000, 0x100000, CRC(cb3f42dc) SHA1(5415f15621924dd263b8fe7daaf3dc25d470b814) )
6882 	ROM_LOAD( "rb-023.u78", 0x300000, 0x100000, CRC(0e6530c5) SHA1(72bff46f0672927e540f4f3546ae533dd0a231e0) )
6883 	ROM_LOAD( "rb-024.u79", 0x400000, 0x080000, CRC(65fa6447) SHA1(551e540d7bf412753b4a7098e25e6f9d8774bcf4) ) /* correct, both halves identical when dumped as larger*/
6884 	ROM_LOAD( "rb-025.u80", 0x500000, 0x040000, CRC(36cd6b90) SHA1(45c50f2652726ded67c9c24185a71a6367e09270) ) /* eprom, contains title logo for this version*/
6885 
6886 	ROM_REGION( 0x400000, REGION_GFX2, 0 )	/* Tiles (scrambled) */
6887 	ROM_LOAD( "rb-010.u65",  0x000000, 0x100000, CRC(ffd73f87) SHA1(1a661f71976be61c22d9b962850e738ba17f1d45) )
6888 	ROM_LOAD( "rb-011.u66",  0x100000, 0x100000, CRC(d9325f78) SHA1(346832608664aa8f3ac9260a549903386b4125a8) )
6889 	ROM_LOAD( "rb-012.u67",  0x200000, 0x100000, CRC(bfdbe0d1) SHA1(3abc5398ee8ee1871b4d081f9b748539d69bcdba) )
6890 	ROM_LOAD( "rb-013.u68",  0x300000, 0x100000, CRC(28c37fe8) SHA1(e10dd1a810983077328b44e6e33ce2e899c506d2) )
6891 
6892 	ROM_REGION( 0x300000, REGION_USER1, 0 ) /* samples */
6893 	/* OKI 1 */
6894 	ROM_LOAD( "rb-000.u43",  0x000000, 0x080000, CRC(58ad1a62) SHA1(1d2643b5f6eac22682972a88d284e00de3e3b223) )
6895 	ROM_LOAD( "rb-003.101",  0x080000, 0x080000, CRC(2cac25d7) SHA1(0412c317bf650a93051b9304d23035efde0c026a) )
6896 
6897 	/* OKI 2 */
6898 	ROM_LOAD( "rb-001.u44",  0x100000, 0x100000, CRC(7cf774b3) SHA1(3fb0a5096ce9480f97e311439042eb8cbc26efb4) )
6899 	ROM_LOAD( "rb-002.u45",  0x200000, 0x100000, CRC(e4b30444) SHA1(be6756dce3721226e0b7f5d4d168008c31aeea8e) )
6900 
6901 	/* Sound data is copied here during driver init */
6902 	ROM_REGION( 0x40000*16, REGION_SOUND1, 0 )
6903 	ROM_FILL(                0x00000, 0x40000*16, 0x00 )
6904 
6905 	ROM_REGION( 0x40000*16, REGION_SOUND2, 0 )
6906 	ROM_FILL(                0x00000, 0x40000*16, 0x00 )
6907 ROM_END
6908 
6909 ROM_START( brapboysj ) /* The Japanese version has an extra rom??? and used a rom sub board */
6910  	ROM_REGION( 0x040000, REGION_CPU1, 0 )			/* 68000 Code */
6911 	ROM_LOAD16_BYTE( "rb-004.u61", 0x000000, 0x020000, CRC(5432442c) SHA1(f0f7328ece96ef25e6d4fd1958d734f64a9ef371) )
6912 	ROM_LOAD16_BYTE( "rb-005.u62", 0x000001, 0x020000, CRC(118b3cfb) SHA1(1690ecf5c629879bd97131ff77029e152919e45d) )
6913 
6914  	ROM_REGION( 0x020000, REGION_CPU2, 0 )			/* MCU Code */
6915 	ROM_LOAD( "rb-006.u33",  0x000000, 0x020000, CRC(f1d76b20) SHA1(c571b5f28e529589ee2d7697ef5d4b60ccb66e7a) )
6916 
6917 	ROM_REGION( 0x600000, REGION_GFX1, ROMREGION_ERASEFF )	/* Sprites */
6918 	/* prety sure all these are at least half size */
6919 	ROM_LOAD( "rb-020.c2",  0x000000, 0x100000, CRC(ce220d38) SHA1(b88d7c89a3e1a826bf19a1fa692ec77c944596d9) )
6920 	ROM_LOAD( "rb-021.u76", 0x100000, 0x100000, CRC(74001407) SHA1(90002056ceb4e0401246950b8c3f996af0a2463c) )
6921 	ROM_LOAD( "rb-022.u77", 0x200000, 0x100000, CRC(cb3f42dc) SHA1(5415f15621924dd263b8fe7daaf3dc25d470b814) )
6922 	ROM_LOAD( "rb-023.u78", 0x300000, 0x100000, CRC(0e6530c5) SHA1(72bff46f0672927e540f4f3546ae533dd0a231e0) )
6923 	ROM_LOAD( "rb-024.u79", 0x400000, 0x080000, CRC(65fa6447) SHA1(551e540d7bf412753b4a7098e25e6f9d8774bcf4) ) /* correct, both halves identical when dumped as larger*/
6924 	ROM_LOAD( "rb-025.u4",  0x500000, 0x080000, CRC(aa795ba5) SHA1(c5256dcceded2e76f548b60c18e51d0dd0209d81) ) /* eprom, special title screen*/
6925 	ROM_LOAD( "rb-026.u5",  0x580000, 0x080000, CRC(bb7604d4) SHA1(57d51ce4ea2000f9a50bae326cfcb66ec494249f) ) /* eprom, logs that bounce past*/
6926 
6927 	ROM_REGION( 0x400000, REGION_GFX2, 0 )	/* Tiles (scrambled) */
6928 	ROM_LOAD( "rb-010.u65",  0x000000, 0x100000, CRC(ffd73f87) SHA1(1a661f71976be61c22d9b962850e738ba17f1d45) )
6929 	ROM_LOAD( "rb-011.u66",  0x100000, 0x100000, CRC(d9325f78) SHA1(346832608664aa8f3ac9260a549903386b4125a8) )
6930 	ROM_LOAD( "rb-012.u67",  0x200000, 0x100000, CRC(bfdbe0d1) SHA1(3abc5398ee8ee1871b4d081f9b748539d69bcdba) )
6931 	ROM_LOAD( "rb-013.u68",  0x300000, 0x100000, CRC(28c37fe8) SHA1(e10dd1a810983077328b44e6e33ce2e899c506d2) )
6932 
6933 	ROM_REGION( 0x300000, REGION_USER1, 0 )
6934 	/* OKI 1 */
6935 	ROM_LOAD( "rb-000.u43",  0x000000, 0x080000, CRC(58ad1a62) SHA1(1d2643b5f6eac22682972a88d284e00de3e3b223) )
6936 	ROM_LOAD( "rb-003.101",  0x080000, 0x080000, CRC(2cac25d7) SHA1(0412c317bf650a93051b9304d23035efde0c026a) )
6937 
6938 	/* OKI 2 */
6939 	ROM_LOAD( "rb-001.u44",  0x100000, 0x100000, CRC(7cf774b3) SHA1(3fb0a5096ce9480f97e311439042eb8cbc26efb4) )
6940 	ROM_LOAD( "rb-002.u45",  0x200000, 0x100000, CRC(e4b30444) SHA1(be6756dce3721226e0b7f5d4d168008c31aeea8e) )
6941 
6942 	/* Sound data is copied here during driver init */
6943 	ROM_REGION( 0x40000*16, REGION_SOUND1, 0 )
6944 	ROM_FILL(                0x00000, 0x40000*16, 0x00 )
6945 
6946 	ROM_REGION( 0x40000*16, REGION_SOUND2, 0 )
6947 	ROM_FILL(                0x00000, 0x40000*16, 0x00 )
6948 ROM_END
6949 
6950 
6951 
6952 /**********************************************************************
6953 
6954 							Bonks Adventure
6955 
6956 Bonks Adventure
6957 Kaneko, 1994
6958 
6959 PCB Layout
6960 ----------
6961 
6962 Z09AF-003
6963 |--------------------------------------------------------|
6964 | LA4460  PC604109.101     PAL   3664 3664  PC500105.55  |
6965 |  M6295   PC603108.102    PAL                           |
6966 |  M6295   PC602107.100  PAL      VIEW2-CHIP             |
6967 |          PC601106.99   PAL                             |
6968 |                                           PC400104.51  |
6969 |                                 3664  3664             |
6970 |              62256                                     |
6971 |J  KANEKO     62256              VIEW2-CHIP             |
6972 |A  JAPAN                                                |
6973 |M  9203T                                     424260     |
6974 |M                                                       |
6975 |A   62256    62256   6116                               |
6976 |    PRG.7    PRG.8   6116      KANEKO    424260         |
6977 |                    3364       KC-002    PAL            |
6978 | 62256    68000     3364                                |
6979 | 62256                                                  |
6980 |          PAL      PAL  20MHz                           |
6981 |          PAL      PAL  16MHz   PC600106.42             |
6982 |                   PAL          PC700107.43             |
6983 |        MCU.124                 PC200102.40             |
6984 | DSW(8) KANEKO  93C46           PC100101.37 PC300103.38 |
6985 |        TBSOP01 27MHz 33.3333MHz                        |
6986 |--------------------------------------------------------|
6987 
6988 Notes:
6989       68000 clock: 16.000MHz
6990       M6295 clock: 2.000MHz, Sample Rate: /165 (both)
6991       VSync: 60Hz
6992       HSync: 15.625kHz
6993 
6994       PC100-PC500: 16M MASK
6995       PC601-PC604: 8M MASK
6996       PC600-PC700: 27C4001
6997             PRG's: 27C4001
6998             MCU  : 27C010
6999 
7000 **********************************************************************/
7001 
7002 ROM_START( bonkadv )
7003 	ROM_REGION( 0x100000, REGION_CPU1, 0 )			/* 68000 Code */
7004 	ROM_LOAD16_BYTE( "prg.8",                0x000000, 0x080000, CRC(af2e60f8) SHA1(406f79e155d1244b84f8c89c25b37188e1b4f4a6) )
7005 	ROM_LOAD16_BYTE( "prg.7",                0x000001, 0x080000, CRC(a1cc6a78) SHA1(a9cea21a6a0dfd3b0952664681c057190aa27f8c) )
7006 
7007 	ROM_REGION( 0x020000, REGION_CPU2, 0 )			/* MCU Code */
7008 	ROM_LOAD16_WORD_SWAP( "mcu.124",	 0x000000, 0x020000, CRC(9d4e2724) SHA1(9dd43703265e39f876877020a0ac3875de6faa8d) )
7009 
7010 	ROM_REGION( 0x500000, REGION_GFX1, ROMREGION_DISPOSE )	/* Sprites */
7011 	ROM_LOAD( "pc100101.37",		 0x000000, 0x200000, CRC(c96e7c10) SHA1(607cc7745abc3ff820047e8a00060ece61646623) )
7012 	ROM_LOAD( "pc200102.40",		 0x200000, 0x100000, CRC(c2b7a26a) SHA1(1c8783442e0ccf30c5640866c5493f1dc1dd48f8) )
7013 	ROM_LOAD( "pc300103.38",		 0x300000, 0x100000, CRC(51ee162c) SHA1(b33afc7d1e9f55f191e08472e8c51ca931b0389d) )
7014 	ROM_LOAD16_BYTE( "pc600106.42",          0x400000, 0x080000, CRC(25877026) SHA1(96814d97e9f9284f98c35edfe5e76677ac50dd97) )
7015 	ROM_LOAD16_BYTE( "pc700107.43",          0x400001, 0x080000, CRC(bfe21c44) SHA1(9900a6fe4182b720a90d64d368bd0fd08bf936a8) )
7016 
7017 	ROM_REGION( 0x200000, REGION_GFX2, ROMREGION_DISPOSE )	/* Tiles (scrambled) */
7018 	ROM_LOAD( "pc400104.51",		 0x000000, 0x100000, CRC(3b176f84) SHA1(0ad6fd5f03d275165490881173bafcb0a94762eb) )
7019 
7020 	ROM_REGION( 0x200000, REGION_GFX3, ROMREGION_DISPOSE )	/* Tiles (scrambled) */
7021 	ROM_LOAD( "pc500105.55",		 0x000000, 0x100000, CRC(bebb3edc) SHA1(e0fed4307316deaeb811ec29f5022adeaf577a95) )
7022 
7023 	ROM_REGION( 0x400000, REGION_SOUND1, 0 )	/* Samples, plus room for expansion */
7024 	ROM_LOAD( "pc604109.101",		 0x000000, 0x100000, CRC(76025530) SHA1(e0c8192d783057798eea084aa3e87938f6e01cb7) )
7025 
7026 	ROM_REGION( 0x300000, REGION_SOUND2, 0 )	/* Samples */
7027 	ROM_LOAD( "pc601106.99",		 0x000000, 0x100000, CRC(a893651c) SHA1(d221ce89f19a76be497724f6c16fab82c8a52661) )
7028 	ROM_LOAD( "pc602107.100",		 0x100000, 0x100000, CRC(0fbb23aa) SHA1(69b620375c65246317d7105fbc414f3c36e02b2c) )
7029 	ROM_LOAD( "pc603108.102",		 0x200000, 0x100000, CRC(58458985) SHA1(9a846d604ba901eb2a59d2b6cd9c42e3b43adb6a) )
7030 
7031 	ROM_REGION16_BE( 0x0080, REGION_USER1, 0 )			/* EEPROM */
7032 ROM_END
7033 
7034 ROM_START( wingforc )
7035 	ROM_REGION( 0x100000, REGION_CPU1, 0 )            /* 68000 Code */
7036 	ROM_LOAD16_BYTE( "e_2.24.u80", 0x000000, 0x80000, CRC(837e0726) SHA1(349013edc5ccdfd05ae022563e6a831ce98e4a1a) )
7037 	ROM_LOAD16_BYTE( "o_2.24.u81", 0x000001, 0x80000, CRC(b6983437) SHA1(0a124e64ad37f9381f8a10a7b462a29563c2ccd9) )
7038 
7039 	ROM_REGION( 0x10000, REGION_CPU2, 0 )           /* Z80 Code */
7040 	ROM_LOAD( "s-drv_2.22.u45", 0x00000, 0x10000, CRC(ccdc2758) SHA1(5c0448a70306bd7574f35056ad45ffcbd4a866a8) )
7041 
7042 	ROM_REGION( 0x200000, REGION_GFX1, ROMREGION_DISPOSE )   /* Sprites */
7043 	/* two sprite chips, roms are doubled*/
7044 	ROM_LOAD( "sp0m.u69", 0x000000, 0x80000, CRC(8be26a05) SHA1(5b54cd74235c0e32a234ddbe9cf26817700451f1) )
7045 	ROM_LOAD( "sp0m.u1",  0x000000, 0x80000, CRC(8be26a05) SHA1(5b54cd74235c0e32a234ddbe9cf26817700451f1) )
7046 
7047 	ROM_LOAD( "sp1m.u1",  0x080000, 0x80000, CRC(ad8c5b68) SHA1(438b58df301a06266284aad63e19d607d7e9f726) )
7048 	ROM_LOAD( "sp1m.u69", 0x080000, 0x80000, CRC(ad8c5b68) SHA1(438b58df301a06266284aad63e19d607d7e9f726) )
7049 
7050 	ROM_LOAD( "sp2m.u20", 0x100000, 0x80000, CRC(b5994bda) SHA1(66bd9664e31ac0c831a1c538d895386cabb03ac8) )
7051 	ROM_LOAD( "sp2m.u68", 0x100000, 0x80000, CRC(b5994bda) SHA1(66bd9664e31ac0c831a1c538d895386cabb03ac8) )
7052 
7053 	ROM_LOAD( "sp3m.u20", 0x180000, 0x80000, CRC(889ddf72) SHA1(1eaeb4580133d38185ff52fbdc445744c207a202) )
7054 	ROM_LOAD( "sp3m.u68", 0x180000, 0x80000, CRC(889ddf72) SHA1(1eaeb4580133d38185ff52fbdc445744c207a202) )
7055 
7056 	ROM_REGION( 0x200000, REGION_GFX2, ROMREGION_DISPOSE )  /* Tiles (Scrambled) */
7057 	ROM_LOAD16_BYTE( "bg0am.u2", 0x000000, 0x80000, CRC(f4276860) SHA1(8c0848d43ec07f88734993a996a62919979c75ea) )
7058 	ROM_LOAD16_BYTE( "bg0bm.u2", 0x000001, 0x80000, CRC(9df92283) SHA1(53bcac1d63b7bb84b664507906ee768a83be28c9) )
7059 	ROM_LOAD16_BYTE( "bg1am.u3", 0x100000, 0x80000, CRC(a44fdebb) SHA1(676ade63d22818c7a7adf39d42aad41fa93319d2) )
7060 	ROM_LOAD16_BYTE( "bg1bm.u3", 0x100001, 0x80000, CRC(a9b9fc5d) SHA1(33db691007a8cf25aea6b87a0f009c50df2676f2) )
7061 
7062 	ROM_REGION( 0x80000, REGION_USER1, ROMREGION_DISPOSE ) /* OKI Sample ROM */
7063 	ROM_LOAD( "pcm.u5", 0x00000, 0x80000, CRC(233569fd) SHA1(eb835008bcb961528c0ef4ca72e44ee08c517b81) )
7064 
7065 	/* $00000-$20000 stays the same in all sound banks, */
7066 	/* the second half of the bank is what gets switched */
7067 	ROM_REGION( 0x100000, REGION_SOUND1, 0 )    /* Samples */
7068 	ROM_COPY( REGION_USER1, 0x000000, 0x000000, 0x020000)
7069 	ROM_COPY( REGION_USER1, 0x020000, 0x020000, 0x020000)
7070 	ROM_COPY( REGION_USER1, 0x000000, 0x040000, 0x020000)
7071 	ROM_COPY( REGION_USER1, 0x040000, 0x060000, 0x020000)
7072 	ROM_COPY( REGION_USER1, 0x000000, 0x080000, 0x020000)
7073 	ROM_COPY( REGION_USER1, 0x060000, 0x0a0000, 0x020000)
7074 	ROM_COPY( REGION_USER1, 0x000000, 0x0c0000, 0x020000)
7075 	ROM_COPY( REGION_USER1, 0x000000, 0x0e0000, 0x020000)
7076 ROM_END
7077 
7078 ROM_START( packbang )
7079 	ROM_REGION( 0x040000, REGION_CPU1, 0 )            /* 68000 Code */
7080 	ROM_LOAD16_BYTE( "bbp0x3.u23", 0x000000, 0x020000, CRC(105e978a) SHA1(d2aa72a25b70726ebe4b16bfe16da149bb37cd85) ) /* hand written checksum on label - 527B */
7081 	ROM_LOAD16_BYTE( "bbp1x3.u39", 0x000001, 0x020000, CRC(465d36f5) SHA1(d3bc9e5d444e086652d2bc562d9adfb8a1fd0d2d) ) /* hand written checksum on label - C5C8 */
7082 
7083 	ROM_REGION( 0x120000, REGION_GFX1, ROMREGION_DISPOSE )  /* Sprites */
7084 	ROM_LOAD( "bb.u84",  0x000000, 0x080000, CRC(97837aaa) SHA1(303780621afea01f9e4d1386229c7421307562ec) )
7085 	ROM_LOAD( "pb_spr_ext_9_20_ver.u83", 0x080000, 0x040000, CRC(666a1217) SHA1(0d7b08d63b229d70b7e9e77a36516a695533c4cb) ) /* hand written label plus checksum BA63 */
7086 
7087 	ROM_REGION( 0x080000, REGION_GFX2, ROMREGION_DISPOSE )   /* Tiles (Scrambled) */
7088 	ROM_LOAD( "bbbox1.u77",  0x000000, 0x080000, CRC(b2ffd081) SHA1(e4b8b60ed0c5f2e0709477cc840864e1c0a351ea) ) /* 1ST AND 2ND HALF IDENTICAL*/
7089 
7090 	ROM_REGION( 0x400000, REGION_GFX3, ROMREGION_DISPOSE )   /* High Color Background */
7091 	ROM_LOAD16_BYTE( "bb.u73",  0x000000, 0x080000, CRC(896d88cb) SHA1(7546e64149d8d8e3425d9112a7a63b2d2e59b8bb) )
7092 	ROM_LOAD16_BYTE( "bb.u65",  0x000001, 0x080000, CRC(fe17c5b5) SHA1(daea65bd87d2137526250d521f36f122f733fd9d) ) /* FIXED BITS (xxxxxxx0)*/
7093 	ROM_LOAD16_BYTE( "bb.u74",  0x100000, 0x080000, CRC(b01e77b9) SHA1(73f3adaf6468f4e9c54bff63268af1765cfc5f67) )
7094 	ROM_LOAD16_BYTE( "bb.u66",  0x100001, 0x080000, CRC(caec5098) SHA1(9966cd643abe498f84a9e01bc32003f4654584de) ) /* FIXED BITS (xxxxxxx0)*/
7095 	ROM_LOAD16_BYTE( "bb.u75",  0x200000, 0x080000, CRC(5cb4669f) SHA1(ab061f5b34435dca46f710ea8118c919a3a9f87c) )
7096 	ROM_LOAD16_BYTE( "bb.u67",  0x200001, 0x080000, CRC(ce5c9417) SHA1(30aca496d1f4218b44a32b3630e58889f0c54564) ) /* FIXED BITS (xxxxxxx0)*/
7097 
7098 	ROM_REGION( 0x040000, REGION_SOUND1, 0 )    /* Samples */
7099 	ROM_LOAD( "bw000.u46",  0x000000, 0x040000, CRC(d8fe869d) SHA1(75e9044c4164ca6db9519fcff8eca6c8a2d8d5d1) )
7100 ROM_END
7101 
7102 
7103 static void kaneko16_expand_sample_banks(int region)
7104 {
7105 	/* The sample data for the first OKI has an address translator/
7106        banking register in it that munges the addresses as follows:
7107 
7108          Offsets 00000-2FFFF always come from ROM 00000-2FFFF
7109          Offsets 30000-3FFFF come from ROM (10000*bank) + 00000-0FFFF
7110 
7111        Because we can't do this dynamically, we pre-generate all 16
7112        possible combinations of these and swap between them.
7113     */
7114 	int bank;
7115 	UINT8 *src0;
7116 
7117 /*	if (memory_region_length(region) < 0x40000 * 16)*/
7118 /*		fatalerror("gtmr SOUND1 region too small");*/
7119 
7120 	/* bank 0 maps to itself, so we just leave it alone */
7121 	src0 = memory_region(region);
7122 	for (bank = 15; bank > 0; bank--)
7123 	{
7124 		UINT8 *srcn = src0 + 0x10000 * (bank < 3 ? 3 : bank);
7125 		UINT8 *dst = src0 + 0x40000 * bank;
7126 
7127 		memcpy(dst + 0x30000, srcn + 0x00000, 0x10000);
7128 		memcpy(dst + 0x00000, src0 + 0x00000, 0x30000);
7129 	}
7130 }
7131 
7132 
7133 /*
7134  Sprites and tiles are stored in the ROMs using the same layout. But tiles
7135  have the even and odd pixels swapped. So we use this function to untangle
7136  them and have one single gfxlayout for both tiles and sprites.
7137 */
7138 
kaneko16_unscramble_tiles(int region)7139 static void kaneko16_unscramble_tiles(int region)
7140 {
7141 	UINT8 *RAM	=	memory_region(region);
7142 	int size	=	memory_region_length(region);
7143 	int i;
7144 
7145 	if (RAM == NULL)	return;
7146 
7147 	for (i = 0; i < size; i ++)
7148 	{
7149 		RAM[i] = ((RAM[i] & 0xF0)>>4) + ((RAM[i] & 0x0F)<<4);
7150 	}
7151 }
7152 
DRIVER_INIT(kaneko16)7153 DRIVER_INIT( kaneko16 )
7154 {
7155 	kaneko16_unscramble_tiles(REGION_GFX2);
7156 	kaneko16_unscramble_tiles(REGION_GFX3);
7157 }
7158 
DRIVER_INIT(berlwall)7159 DRIVER_INIT( berlwall )
7160 {
7161 	kaneko16_unscramble_tiles(REGION_GFX2);
7162 }
7163 
7164 
DRIVER_INIT(bloodwar)7165 static DRIVER_INIT( bloodwar )
7166 {
7167 	kaneko16_unscramble_tiles(REGION_GFX2);
7168 	kaneko16_unscramble_tiles(REGION_GFX3);
7169 	kaneko16_expand_sample_banks(REGION_SOUND1);
7170 	decrypt_toybox_rom();
7171 }
7172 
7173 
7174 
expand_shogwarr_samples(void)7175 static void expand_shogwarr_samples(void)
7176 {
7177 	/*
7178         Expand the OKI sample data
7179 
7180         OKI 1:
7181         Address space 0x00000-0x2ffff is fixed
7182         Address space 0x30000-0x3ffff is banked (13 banks)
7183     */
7184 
7185 	int bank;
7186 	UINT8 *src = memory_region(REGION_USER1);
7187 	UINT8 *dst1 = memory_region(REGION_SOUND1);
7188 
7189 	/* OKI 1 */
7190 	for (bank = 0; bank < 13; ++bank)
7191 	{
7192 		UINT8 *dst;
7193 		UINT8 *srcn;
7194 
7195 		dst = dst1 + 0x40000 * bank;
7196 		srcn = src + 0x30000 + (0x10000 * bank);
7197 		memcpy(dst, src, 0x30000);
7198 		memcpy(dst + 0x30000, srcn, 0x10000);
7199 	}
7200 }
7201 
calc3_init(void)7202 static void calc3_init(void)
7203 {
7204 	/*calc3_scantables();*/
7205 
7206 	kaneko16_unscramble_tiles(REGION_GFX2);
7207 	kaneko16_unscramble_tiles(REGION_GFX3);
7208 	expand_shogwarr_samples();
7209     /*  MCU is a 78K series III type CPU*/
7210 }
7211 
expand_brapboys_music(void)7212 static void expand_brapboys_music(void)
7213 {
7214 	/*
7215         Expand the OKI sample data
7216 
7217         OKI 2:
7218         Address space 0x00000-0x1ffff is fixed
7219         Address space 0x20000-0x3ffff is banked (15 banks)
7220     */
7221 
7222 	int bank;
7223 	UINT8 *src = memory_region(REGION_USER1);
7224 	UINT8 *dst2 = memory_region(REGION_SOUND2);
7225 
7226 	/* OKI 2 */
7227 	for (bank = 0; bank < 15; ++bank)
7228 	{
7229 		UINT8 *dst;
7230 		UINT8 *srcn;
7231 		dst = dst2 + 0x40000 * bank;
7232 		srcn = src + 0x120000 + (0x20000 * bank);
7233 		memcpy(dst, src + 0x100000, 0x20000);
7234 		memcpy(dst + 0x20000, srcn, 0x20000);
7235 	}
7236 }
7237 
7238 
DRIVER_INIT(brapboys)7239 static DRIVER_INIT( brapboys )
7240 {
7241 	/* sample banking is different on brap boys for the music, why? GALs / PALs ?*/
7242 	expand_brapboys_music();
7243 	calc3_init();
7244 }
7245 
DRIVER_INIT(shogwarr)7246 static DRIVER_INIT( shogwarr )
7247 {
7248 	calc3_init();
7249 }
7250 
7251 
7252 
7253 /***************************************************************************
7254 
7255 
7256 								Game drivers
7257 
7258 
7259 ***************************************************************************/
7260 
7261 
7262 GAME( 1991, berlwall, 0,        berlwall, berlwall, berlwall,   ROT0,  "Kaneko", "The Berlin Wall (set 1)" )
7263 GAME( 1991, berlwalt, berlwall, berlwall, berlwalt, berlwall,   ROT0,  "Kaneko", "The Berlin Wall (set 2)" )
7264 GAME( 1991, mgcrystl, 0,        mgcrystl, mgcrystl, kaneko16,   ROT0,  "Kaneko", "Magical Crystals (World)" )
7265 GAME( 1991, mgcrystj, mgcrystl, mgcrystl, mgcrystl, kaneko16,   ROT0,  "Kaneko", "Magical Crystals (Japan)" )
7266 GAME( 1992, blazeon,  0,        blazeon,  blazeon,  kaneko16,   ROT0,  "Atlus",  "Blaze On (Japan)" )
7267 GAMEX(1992, sandscrp, 0,        sandscrp, sandscrp, 0,          ROT90, "Face",   "Sand Scorpion",  GAME_IMPERFECT_SOUND )
7268 GAME( 1994, gtmr,     0,        gtmr,     gtmr,     kaneko16,   ROT0,  "Kaneko", "Great 1000 Miles Rally" )
7269 GAME( 1994, gtmre,    gtmr,     gtmr,     gtmr,     kaneko16,   ROT0,  "Kaneko", "Great 1000 Miles Rally (Evolution Model)" )
7270 GAME( 1994, gtmrusa,  gtmr,     gtmr,     gtmr,     kaneko16,   ROT0,  "Kaneko", "Great 1000 Miles Rally (USA)" )
7271 GAME( 1995, gtmr2,    0,        gtmr2,    gtmr2,    kaneko16,   ROT0,  "Kaneko", "Mille Miglia 2 - Great 1000 Miles Rally" )
7272 
7273 /* New-working games */
7274 
7275 GAMEX(1992, bakubrkr, 0,        bakubrkr, bakubrkr, kaneko16,   ROT90, "Kaneko", "Bakuretsu Breaker", GAME_IMPERFECT_GRAPHICS )
7276 GAMEX(1992, shogwarr, 0,        shogwarr, shogwarr, shogwarr,   ROT0,  "Kaneko", "Shogun Warriors", GAME_IMPERFECT_GRAPHICS )
7277 GAMEX(1992, fjbuster, shogwarr, shogwarr, shogwarr, shogwarr,   ROT0,  "Kaneko", "Fujiyama Buster (Japan)", GAME_IMPERFECT_GRAPHICS )
7278 GAMEX(1992, brapboys, 0,        brapboys, brapboys, brapboys,   ROT0,  "Kaneko", "B.Rap Boys (World)", GAME_IMPERFECT_GRAPHICS )
7279 GAMEX(1992, brapboysj,brapboys, brapboys, brapboys, brapboys,   ROT0,  "Kaneko", "B.Rap Boys Special (Japan)", GAME_IMPERFECT_GRAPHICS )
7280 GAMEX(1994, bloodwar, 0,        bloodwar, bloodwar, bloodwar,   ROT0,  "Kaneko", "Blood Warrior", GAME_IMPERFECT_GRAPHICS )
7281 GAMEX(1994, bonkadv,  0,        bonkadv , bonkadv,  bloodwar,   ROT0,  "Kaneko", "Bonk's Adventure", GAME_IMPERFECT_GRAPHICS )
7282 GAMEX(1994, packbang, 0,        berlwall, packbang, berlwall,   ROT90, "Kaneko", "Pack'n Bang Bang (prototype)", GAME_IMPERFECT_GRAPHICS ) /* priorities between stages?*/
7283 GAME( 1993, wingforc, 0,        wingforc, wingforc, kaneko16,   ROT270,"Atlus",  "Wing Force (Japan, prototype)" )
7284