1 // FB Alpha Armed Formation driver module
2 // Based on MAME driver by Carlos A. Lozano, Phil Stroffolino, and Takahiro Nogi
3 //
4 // nb1414m4 hooked up to Kozure Ookami July 8 2015 -dink
5 // sprite colour lookup table support added July 15 2015 -dink
6 // -  July 16 2015  -
7 // text layer priorities added, fixes certain/cutscene text effects in legion & terraf
8 // fix fg layer scrolling in terraf/terrafu/terrafj
9 // fix chaotic music tempo & dac sound clarity in all games -dink
10 //
11 // - dec 27, 2016 -
12 // added Tatakae! Big Fighter / SkyRobo, biiiiiig thanks to Caps0ff.blogspot.com
13 // for dumping the impossible / badly damaged & protected i8751 protection mcu -dink
14 //
15 
16 #include "tiles_generic.h"
17 #include "m68000_intf.h"
18 #include "z80_intf.h"
19 #include "mcs51.h"
20 #include "burn_ym3812.h"
21 #include "dac.h"
22 #include "nb1414m4.h"
23 
24 static UINT8 *AllMem;
25 static UINT8 *MemEnd;
26 static UINT8 *AllRam;
27 static UINT8 *RamEnd;
28 static UINT8 *Drv68KROM;
29 static UINT8 *Drv68KRAM0;
30 static UINT8 *Drv68KRAM1;
31 static UINT8 *Drv68KRAM2;
32 static UINT8 *DrvShareRAM;
33 static UINT8 *DrvZ80ROM;
34 static UINT8 *DrvZ80RAM;
35 static UINT8 *DrvZ80ROM2;
36 static UINT8 *DrvZ80RAM2;
37 static UINT8 *DrvGfxROM0;
38 static UINT8 *DrvGfxROM1;
39 static UINT8 *DrvGfxROM2;
40 static UINT8 *DrvGfxROM3;
41 static UINT8 *DrvPalRAM;
42 static UINT8 *DrvSprRAM;
43 static UINT8 *DrvSprBuf;
44 static UINT8 *DrvBgRAM;
45 static UINT8 *DrvFgRAM;
46 static UINT8 *DrvTxRAM;
47 static UINT32 *DrvPalette;
48 
49 static UINT16*DrvSprClut;
50 static UINT16*DrvMcuCmd;
51 static UINT16*DrvScroll;
52 static UINT8 *DrvVidRegs;
53 static UINT8 *soundlatch;
54 static UINT8 *flipscreen;
55 
56 static UINT8 DrvRecalc;
57 
58 static UINT8 DrvJoy1[16];
59 static UINT8 DrvJoy2[16];
60 static UINT8 DrvDips[3];
61 static UINT16 DrvInputs[4];
62 static UINT8 DrvReset;
63 
64 static INT32 scroll_type;
65 static INT32 sprite_offy;
66 static INT32 yoffset;
67 static INT32 xoffset;
68 static INT32 irqline;
69 
70 static UINT32 fg_scrolly = 0;
71 static UINT32 fg_scrollx = 0;
72 static UINT32 waiting_msb = 0;
73 static UINT32 scroll_msb = 0;
74 
75 static INT32 usemcu = 0;
76 
77 static INT32 Terrafjb = 0;
78 static INT32 Kozuremode = 0;
79 static INT32 Skyrobo = 0;
80 static INT32 fiftysevenhertz = 0;
81 
82 static struct BurnInputInfo ArmedfInputList[] = {
83 	{"P1 Coin",		BIT_DIGITAL,	DrvJoy1 + 10,	"p1 coin"	},
84 	{"P1 Start",		BIT_DIGITAL,	DrvJoy1 + 8,	"p1 start"	},
85 	{"P1 Up",		BIT_DIGITAL,	DrvJoy1 + 0,	"p1 up"		},
86 	{"P1 Down",		BIT_DIGITAL,	DrvJoy1 + 1,	"p1 down"	},
87 	{"P1 Left",		BIT_DIGITAL,	DrvJoy1 + 2,	"p1 left"	},
88 	{"P1 Right",		BIT_DIGITAL,	DrvJoy1 + 3,	"p1 right"	},
89 	{"P1 Button 1",		BIT_DIGITAL,	DrvJoy1 + 4,	"p1 fire 1"	},
90 	{"P1 Button 2",		BIT_DIGITAL,	DrvJoy1 + 5,	"p1 fire 2"	},
91 	{"P1 Button 3",		BIT_DIGITAL,	DrvJoy1 + 6,	"p1 fire 3"	},
92 
93 	{"P2 Coin",		BIT_DIGITAL,	DrvJoy1 + 11,	"p2 coin"	},
94 	{"P2 Start",		BIT_DIGITAL,	DrvJoy1 + 9,	"p2 start"	},
95 	{"P2 Up",		BIT_DIGITAL,	DrvJoy2 + 0,	"p2 up"		},
96 	{"P2 Down",		BIT_DIGITAL,	DrvJoy2 + 1,	"p2 down"	},
97 	{"P2 Left",		BIT_DIGITAL,	DrvJoy2 + 2,	"p2 left"	},
98 	{"P2 Right",		BIT_DIGITAL,	DrvJoy2 + 3,	"p2 right"	},
99 	{"P2 Button 1",		BIT_DIGITAL,	DrvJoy2 + 4,	"p2 fire 1"	},
100 	{"P2 Button 2",		BIT_DIGITAL,	DrvJoy2 + 5,	"p2 fire 2"	},
101 	{"P2 Button 3",		BIT_DIGITAL,	DrvJoy2 + 6,	"p2 fire 3"	},
102 
103 	{"Reset",		BIT_DIGITAL,	&DrvReset,	"reset"		},
104 	{"Service",		BIT_DIGITAL,	DrvJoy2 + 8,	"service"	},
105 	{"Tilt",		BIT_DIGITAL,	DrvJoy2 + 10,	"tilt"		},
106 	{"Dip A",		BIT_DIPSWITCH,	DrvDips + 0,	"dip"		},
107 	{"Dip B",		BIT_DIPSWITCH,	DrvDips + 1,	"dip"		},
108 };
109 
110 STDINPUTINFO(Armedf)
111 
112 static struct BurnInputInfo Cclimbr2InputList[] = {
113 	{"P1 Coin",		BIT_DIGITAL,	DrvJoy1 + 10,	"p1 coin"	},
114 	{"P1 Start",		BIT_DIGITAL,	DrvJoy1 + 8,	"p1 start"	},
115 	{"P1 Up 1",		BIT_DIGITAL,	DrvJoy1 + 0,	"p1 up"		},
116 	{"P1 Down 1",		BIT_DIGITAL,	DrvJoy1 + 1,	"p1 down"	},
117 	{"P1 Left 1",		BIT_DIGITAL,	DrvJoy1 + 2,	"p1 left"	},
118 	{"P1 Right 1",		BIT_DIGITAL,	DrvJoy1 + 3,	"p1 right"	},
119 	{"P1 Up 2",		BIT_DIGITAL,	DrvJoy1 + 4,	"p3 up"		},
120 	{"P1 Down 2",		BIT_DIGITAL,	DrvJoy1 + 5,	"p3 down"	},
121 	{"P1 Left 2",		BIT_DIGITAL,	DrvJoy1 + 6,	"p3 left"	},
122 	{"P1 Right 2",		BIT_DIGITAL,	DrvJoy1 + 7,	"p3 right"	},
123 
124 	{"P2 Coin",		BIT_DIGITAL,	DrvJoy1 + 11,	"p2 coin"	},
125 	{"P2 Start",		BIT_DIGITAL,	DrvJoy1 + 9,	"p2 start"	},
126 	{"P2 Up 1",		BIT_DIGITAL,	DrvJoy2 + 0,	"p2 up"		},
127 	{"P2 Down 1",		BIT_DIGITAL,	DrvJoy2 + 1,	"p2 down"	},
128 	{"P2 Left 1",		BIT_DIGITAL,	DrvJoy2 + 2,	"p2 left"	},
129 	{"P2 Right 1",		BIT_DIGITAL,	DrvJoy2 + 3,	"p2 right"	},
130 	{"P2 Up 2",		BIT_DIGITAL,	DrvJoy2 + 4,	"p4 up"		},
131 	{"P2 Down 2",		BIT_DIGITAL,	DrvJoy2 + 5,	"p4 down"	},
132 	{"P2 Left 2",		BIT_DIGITAL,	DrvJoy2 + 6,	"p4 left"	},
133 	{"P2 Right 2",		BIT_DIGITAL,	DrvJoy2 + 7,	"p4 right"	},
134 
135 	{"Reset",		BIT_DIGITAL,	&DrvReset,	"reset"		},
136 	{"Service",		BIT_DIGITAL,	DrvJoy2 + 8,	"service"	},
137 	{"Tilt",		BIT_DIGITAL,	DrvJoy2 + 10,	"tilt"		},
138 	{"Dip A",		BIT_DIPSWITCH,	DrvDips + 0,	"dip"		},
139 	{"Dip B",		BIT_DIPSWITCH,	DrvDips + 1,	"dip"		},
140 };
141 
142 STDINPUTINFO(Cclimbr2)
143 
144 static struct BurnInputInfo BigfghtrInputList[] = {
145 	{"P1 Coin",		BIT_DIGITAL,	DrvJoy1 + 10,	"p1 coin"},
146 	{"P1 Start",		BIT_DIGITAL,	DrvJoy1 + 8,	"p1 start"},
147 	{"P1 Up",		BIT_DIGITAL,	DrvJoy1 + 0,	"p1 up"},
148 	{"P1 Down",		BIT_DIGITAL,	DrvJoy1 + 1,	"p1 down"},
149 	{"P1 Left",		BIT_DIGITAL,	DrvJoy1 + 2,	"p1 left"},
150 	{"P1 Right",		BIT_DIGITAL,	DrvJoy1 + 3,	"p1 right"},
151 	{"P1 Button 1",		BIT_DIGITAL,	DrvJoy1 + 4,	"p1 fire 1"},
152 	{"P1 Button 2",		BIT_DIGITAL,	DrvJoy1 + 5,	"p1 fire 2"},
153 	{"P1 Button 3",		BIT_DIGITAL,	DrvJoy1 + 6,	"p1 fire 3"},
154 
155 	{"P2 Coin",		BIT_DIGITAL,	DrvJoy1 + 11,	"p2 coin"},
156 	{"P2 Start",		BIT_DIGITAL,	DrvJoy1 + 9,	"p2 start"},
157 	{"P2 Up",		BIT_DIGITAL,	DrvJoy2 + 0,	"p2 up"},
158 	{"P2 Down",		BIT_DIGITAL,	DrvJoy2 + 1,	"p2 down"},
159 	{"P2 Left",		BIT_DIGITAL,	DrvJoy2 + 2,	"p2 left"},
160 	{"P2 Right",		BIT_DIGITAL,	DrvJoy2 + 3,	"p2 right"},
161 	{"P2 Button 1",		BIT_DIGITAL,	DrvJoy2 + 4,	"p2 fire 1"},
162 	{"P2 Button 2",		BIT_DIGITAL,	DrvJoy2 + 5,	"p2 fire 2"},
163 	{"P2 Button 3",		BIT_DIGITAL,	DrvJoy2 + 6,	"p2 fire 3"},
164 
165 	{"Reset",		BIT_DIGITAL,	&DrvReset,	"reset"},
166 	{"Service",		BIT_DIGITAL,	DrvJoy2 + 8,	"service"},
167 	{"Dip A",		BIT_DIPSWITCH,	DrvDips + 0,	"dip"},
168 	{"Dip B",		BIT_DIPSWITCH,	DrvDips + 1,	"dip"},
169 	{"Dip C",       BIT_DIPSWITCH,	DrvDips + 2,	"dip"},
170 };
171 
172 STDINPUTINFO(Bigfghtr)
173 
174 
175 static struct BurnDIPInfo BigfghtrDIPList[]=
176 {
177 	{0x14, 0xff, 0xff, 0xdf, NULL		},
178 	{0x15, 0xff, 0xff, 0xff, NULL		},
179 	{0x16, 0xff, 0xff, 0x02, NULL		},
180 
181 	{0   , 0xfe, 0   ,    4, "Lives"		},
182 	{0x14, 0x01, 0x03, 0x03, "3"		},
183 	{0x14, 0x01, 0x03, 0x02, "4"		},
184 	{0x14, 0x01, 0x03, 0x01, "5"		},
185 	{0x14, 0x01, 0x03, 0x00, "6"		},
186 
187 	{0   , 0xfe, 0   ,    4, "Bonus Life"		},
188 	{0x14, 0x01, 0x0c, 0x0c, "80k then every 80k"		},
189 	{0x14, 0x01, 0x0c, 0x04, "80k then every 100k"		},
190 	{0x14, 0x01, 0x0c, 0x08, "100k then every 80k"		},
191 	{0x14, 0x01, 0x0c, 0x00, "100k then every 100k"		},
192 
193 	{0   , 0xfe, 0   ,    2, "Demo Sounds"		},
194 	{0x14, 0x01, 0x10, 0x10, "On"		},
195 	{0x14, 0x01, 0x10, 0x00, "Off"		},
196 
197 	{0   , 0xfe, 0   ,    2, "Cabinet"		},
198 	{0x14, 0x01, 0x20, 0x00, "Upright"		},
199 	{0x14, 0x01, 0x20, 0x20, "Cocktail"		},
200 
201 	{0   , 0xfe, 0   ,    4, "Difficulty"		},
202 	{0x14, 0x01, 0xc0, 0xc0, "Easy"		},
203 	{0x14, 0x01, 0xc0, 0x80, "Normal"		},
204 	{0x14, 0x01, 0xc0, 0x40, "Hard"		},
205 	{0x14, 0x01, 0xc0, 0x00, "Hardest"		},
206 
207 	{0   , 0xfe, 0   ,    4, "Coin A"		},
208 	{0x15, 0x01, 0x03, 0x01, "2 Coins 1 Credits"		},
209 	{0x15, 0x01, 0x03, 0x03, "1 Coin  1 Credits"		},
210 	{0x15, 0x01, 0x03, 0x02, "1 Coin  2 Credits"		},
211 	{0x15, 0x01, 0x03, 0x00, "Free Play"		},
212 
213 	{0   , 0xfe, 0   ,    4, "Coin B"		},
214 	{0x15, 0x01, 0x0c, 0x04, "2 Coins 1 Credits"		},
215 	{0x15, 0x01, 0x0c, 0x0c, "1 Coin  1 Credits"		},
216 	{0x15, 0x01, 0x0c, 0x00, "2 Coins 3 Credits"		},
217 	{0x15, 0x01, 0x0c, 0x08, "1 Coin  2 Credits"		},
218 
219 	{0   , 0xfe, 0   ,    2, "Unknown"		},
220 	{0x15, 0x01, 0x10, 0x10, "Off"		},
221 	{0x15, 0x01, 0x10, 0x00, "On"		},
222 
223 	{0   , 0xfe, 0   ,    2, "Unknown"		},
224 	{0x15, 0x01, 0x20, 0x20, "Off"		},
225 	{0x15, 0x01, 0x20, 0x00, "On"		},
226 
227 	{0   , 0xfe, 0   ,    2, "Flip Screen"		},
228 	{0x15, 0x01, 0x40, 0x40, "Off"		},
229 	{0x15, 0x01, 0x40, 0x00, "On"		},
230 
231 	{0   , 0xfe, 0   ,    2, "Unknown"		},
232 	{0x15, 0x01, 0x80, 0x80, "Off"		},
233 	{0x15, 0x01, 0x80, 0x00, "On"		},
234 
235 	{0   , 0xfe, 0   ,    2, "Service Mode"		},
236 	{0x16, 0x01, 0x02, 0x02, "Off"		},
237 	{0x16, 0x01, 0x02, 0x00, "On"		},
238 };
239 
240 STDDIPINFO(Bigfghtr)
241 
242 static struct BurnDIPInfo ArmedfDIPList[]=
243 {
244 	{0x15, 0xff, 0xff, 0xdf, NULL					},
245 	{0x16, 0xff, 0xff, 0xcf, NULL					},
246 
247 	{0   , 0xfe, 0   ,    4, "Lives"				},
248 	{0x15, 0x01, 0x03, 0x03, "3"					},
249 	{0x15, 0x01, 0x03, 0x02, "4"					},
250 	{0x15, 0x01, 0x03, 0x01, "5"					},
251 	{0x15, 0x01, 0x03, 0x00, "6"					},
252 
253 	{0   , 0xfe, 0   ,    2, "1st Bonus Life"			},
254 	{0x15, 0x01, 0x04, 0x04, "20k"					},
255 	{0x15, 0x01, 0x04, 0x00, "40k"					},
256 
257 	{0   , 0xfe, 0   ,    2, "2nd Bonus Life"			},
258 	{0x15, 0x01, 0x08, 0x08, "60k"					},
259 	{0x15, 0x01, 0x08, 0x00, "80k"					},
260 
261 	{0   , 0xfe, 0   ,    4, "Bonus Life"				},
262 	{0x15, 0x01, 0x0c, 0x0c, "20k then every 60k"			},
263 	{0x15, 0x01, 0x0c, 0x04, "20k then every 80k"			},
264 	{0x15, 0x01, 0x0c, 0x08, "40k then every 60k"			},
265 	{0x15, 0x01, 0x0c, 0x00, "40k then every 80k"			},
266 
267 	{0   , 0xfe, 0   ,    2, "Demo Sounds"				},
268 	{0x15, 0x01, 0x10, 0x00, "Off"					},
269 	{0x15, 0x01, 0x10, 0x10, "On"					},
270 
271 	{0   , 0xfe, 0   ,    2, "Cabinet"				},
272 	{0x15, 0x01, 0x20, 0x00, "Upright"				},
273 	{0x15, 0x01, 0x20, 0x20, "Cocktail"				},
274 
275 	{0   , 0xfe, 0   ,    4, "Difficulty"				},
276 	{0x15, 0x01, 0xc0, 0xc0, "Easy"					},
277 	{0x15, 0x01, 0xc0, 0x80, "Normal"				},
278 	{0x15, 0x01, 0xc0, 0x40, "Hard"					},
279 	{0x15, 0x01, 0xc0, 0x00, "Hardest"				},
280 
281 	{0   , 0xfe, 0   ,    4, "Coin A"				},
282 	{0x16, 0x01, 0x03, 0x01, "2 Coins 1 Credits"			},
283 	{0x16, 0x01, 0x03, 0x03, "1 Coin  1 Credits"			},
284 	{0x16, 0x01, 0x03, 0x02, "1 Coin  2 Credits"			},
285 	{0x16, 0x01, 0x03, 0x00, "Free Play"				},
286 
287 	{0   , 0xfe, 0   ,    4, "Coin B"				},
288 	{0x16, 0x01, 0x0c, 0x04, "2 Coins 1 Credits"			},
289 	{0x16, 0x01, 0x0c, 0x0c, "1 Coin  1 Credits"			},
290 	{0x16, 0x01, 0x0c, 0x00, "2 Coins 3 Credits"			},
291 	{0x16, 0x01, 0x0c, 0x08, "1 Coin  2 Credits"			},
292 
293 	{0   , 0xfe, 0   ,    4, "Allow Continue"			},
294 	{0x16, 0x01, 0x30, 0x30, "No"					},
295 	{0x16, 0x01, 0x30, 0x20, "3 Times"				},
296 	{0x16, 0x01, 0x30, 0x10, "5 Times"				},
297 	{0x16, 0x01, 0x30, 0x00, "Yes"					},
298 
299 	{0   , 0xfe, 0   ,    2, "Flip Screen"				},
300 	{0x16, 0x01, 0x40, 0x40, "Off"					},
301 	{0x16, 0x01, 0x40, 0x00, "On"					},
302 };
303 
304 STDDIPINFO(Armedf)
305 
306 static struct BurnDIPInfo KozureDIPList[]=
307 {
308 	{0x15, 0xff, 0xff, 0xcf, NULL					},
309 	{0x16, 0xff, 0xff, 0xcf, NULL					},
310 
311 	{0   , 0xfe, 0   ,    4, "Lives"				},
312 	{0x15, 0x01, 0x03, 0x03, "3"					},
313 	{0x15, 0x01, 0x03, 0x02, "4"					},
314 	{0x15, 0x01, 0x03, 0x01, "5"					},
315 	{0x15, 0x01, 0x03, 0x00, "6"					},
316 
317 	{0   , 0xfe, 0   ,    2, "1st Bonus Life"			},
318 	{0x15, 0x01, 0x04, 0x04, "None"					},
319 	{0x15, 0x01, 0x04, 0x00, "50k"					},
320 
321 	{0   , 0xfe, 0   ,    2, "2nd Bonus Life"			},
322 	{0x15, 0x01, 0x08, 0x08, "60k"					},
323 	{0x15, 0x01, 0x08, 0x00, "90k"					},
324 
325 	{0   , 0xfe, 0   ,    4, "Bonus Life"				},
326 	{0x15, 0x01, 0x0c, 0x08, "50k then every 60k"			},
327 	{0x15, 0x01, 0x0c, 0x00, "50k then every 90k"			},
328 	{0x15, 0x01, 0x0c, 0x0c, "Every 60k"				},
329 	{0x15, 0x01, 0x0c, 0x04, "Every 90k"				},
330 
331 	{0   , 0xfe, 0   ,    2, "Difficulty"				},
332 	{0x15, 0x01, 0x40, 0x40, "Easy"					},
333 	{0x15, 0x01, 0x40, 0x00, "Hard"					},
334 
335 	{0   , 0xfe, 0   ,    4, "Coin A"				},
336 	{0x16, 0x01, 0x03, 0x01, "2 Coins 1 Credit"			},
337 	{0x16, 0x01, 0x03, 0x03, "1 Coin  1 Credits"			},
338 	{0x16, 0x01, 0x03, 0x02, "1 Coin  2 Credits"			},
339 	{0x16, 0x01, 0x03, 0x00, "Free Play"				},
340 
341 	{0   , 0xfe, 0   ,    4, "Coin B"				},
342 	{0x16, 0x01, 0x0c, 0x00, "3 Coins 1 Credit"			},
343 	{0x16, 0x01, 0x0c, 0x04, "2 Coins 3 Credits"			},
344 	{0x16, 0x01, 0x0c, 0x0c, "1 Coin  3 Credits"			},
345 	{0x16, 0x01, 0x0c, 0x08, "1 Coin  6 Credits"			},
346 
347 	{0   , 0xfe, 0   ,    4, "Allow Continue"			},
348 	{0x16, 0x01, 0x30, 0x30, "No"					},
349 	{0x16, 0x01, 0x30, 0x20, "3 Times"				},
350 	{0x16, 0x01, 0x30, 0x10, "5 Times"				},
351 	{0x16, 0x01, 0x30, 0x00, "Yes"					},
352 
353 	{0   , 0xfe, 0   ,    2, "Allow Continue"			},
354 	{0x16, 0x01, 0x40, 0x00, "No"					},
355 	{0x16, 0x01, 0x40, 0x40, "Yes"					},
356 };
357 
358 STDDIPINFO(Kozure)
359 
360 static struct BurnDIPInfo Cclimbr2DIPList[]=
361 {
362 	{0x17, 0xff, 0xff, 0xcf, NULL					},
363 	{0x18, 0xff, 0xff, 0xff, NULL					},
364 
365 	{0   , 0xfe, 0   ,    4, "Lives"				},
366 	{0x17, 0x01, 0x03, 0x03, "3"					},
367 	{0x17, 0x01, 0x03, 0x02, "4"					},
368 	{0x17, 0x01, 0x03, 0x01, "5"					},
369 	{0x17, 0x01, 0x03, 0x00, "6"					},
370 
371 	{0   , 0xfe, 0   ,    2, "1st Bonus Life"			},
372 	{0x17, 0x01, 0x04, 0x04, "30k"					},
373 	{0x17, 0x01, 0x04, 0x00, "60k"					},
374 
375 	{0   , 0xfe, 0   ,    2, "2nd Bonus Life"			},
376 	{0x17, 0x01, 0x08, 0x08, "70k"					},
377 	{0x17, 0x01, 0x08, 0x00, "None"					},
378 
379 	{0   , 0xfe, 0   ,    4, "Bonus Life"				},
380 	{0x17, 0x01, 0x0c, 0x0c, "30K and 100k"				},
381 	{0x17, 0x01, 0x0c, 0x08, "60k and 130k"				},
382 	{0x17, 0x01, 0x0c, 0x04, "30k only"				},
383 	{0x17, 0x01, 0x0c, 0x00, "60k only"				},
384 
385 	{0   , 0xfe, 0   ,    2, "Difficulty"				},
386 	{0x17, 0x01, 0x40, 0x40, "Easy"					},
387 	{0x17, 0x01, 0x40, 0x00, "Normal"				},
388 
389 	{0   , 0xfe, 0   ,    4, "Coin A"				},
390 	{0x18, 0x01, 0x03, 0x01, "2 Coins 1 Credits"			},
391 	{0x18, 0x01, 0x03, 0x03, "1 Coin  1 Credits"			},
392 	{0x18, 0x01, 0x03, 0x02, "1 Coin  2 Credits"			},
393 	{0x18, 0x01, 0x03, 0x00, "Free Play"				},
394 
395 	{0   , 0xfe, 0   ,    4, "Coin B"				},
396 	{0x18, 0x01, 0x0c, 0x04, "2 Coins 1 Credits"			},
397 	{0x18, 0x01, 0x0c, 0x0c, "1 Coin  1 Credits"			},
398 	{0x18, 0x01, 0x0c, 0x00, "2 Coins 3 Credits"			},
399 	{0x18, 0x01, 0x0c, 0x08, "1 Coin  2 Credits"			},
400 
401 	{0   , 0xfe, 0   ,    2, "Allow Continue"			},
402 	{0x18, 0x01, 0x10, 0x00, "No"					},
403 	{0x18, 0x01, 0x10, 0x10, "3 Times"				},
404 
405 	{0   , 0xfe, 0   ,    2, "Flip Screen"				},
406 	{0x18, 0x01, 0x20, 0x20, "Off"					},
407 	{0x18, 0x01, 0x20, 0x00, "On"					},
408 
409 	{0   , 0xfe, 0   ,    2, "Partial Invulnerability (Cheat)"	},
410 	{0x18, 0x01, 0x40, 0x40, "Off"					},
411 	{0x18, 0x01, 0x40, 0x00, "On"					},
412 };
413 
414 STDDIPINFO(Cclimbr2)
415 
416 static struct BurnDIPInfo LegionDIPList[]=
417 {
418 	{0x15, 0xff, 0xff, 0xf7, NULL					},
419 	{0x16, 0xff, 0xff, 0xff, NULL					},
420 
421 	{0   , 0xfe, 0   ,    4, "Lives"				},
422 	{0x15, 0x01, 0x03, 0x03, "3"					},
423 	{0x15, 0x01, 0x03, 0x02, "4"					},
424 	{0x15, 0x01, 0x03, 0x01, "5"					},
425 	{0x15, 0x01, 0x03, 0x00, "6"					},
426 
427 	{0   , 0xfe, 0   ,    2, "Bonus Life"				},
428 	{0x15, 0x01, 0x04, 0x04, "30k Then Every 100k"			},
429 	{0x15, 0x01, 0x04, 0x00, "50k Only"				},
430 
431 	{0   , 0xfe, 0   ,    2, "Demo Sounds"				},
432 	{0x15, 0x01, 0x08, 0x08, "Off"					},
433 	{0x15, 0x01, 0x08, 0x00, "On"					},
434 
435 	{0   , 0xfe, 0   ,    2, "Flip Screen"				},
436 	{0x15, 0x01, 0x10, 0x10, "Off"					},
437 	{0x15, 0x01, 0x10, 0x00, "On"					},
438 
439 	{0   , 0xfe, 0   ,    2, "Allow Invulnerability (Cheat)"	},
440 	{0x15, 0x01, 0x80, 0x80, "No"					},
441 	{0x15, 0x01, 0x80, 0x00, "Yes"					},
442 
443 	{0   , 0xfe, 0   ,    4, "Coin A"				},
444 	{0x16, 0x01, 0x03, 0x01, "2 Coins 1 Credits"			},
445 	{0x16, 0x01, 0x03, 0x03, "1 Coin  1 Credits"			},
446 	{0x16, 0x01, 0x03, 0x02, "1 Coin  2 Credits"			},
447 	{0x16, 0x01, 0x03, 0x00, "Free Play"				},
448 
449 	{0   , 0xfe, 0   ,    4, "Coin B"				},
450 	{0x16, 0x01, 0x0c, 0x04, "2 Coins 1 Credits"			},
451 	{0x16, 0x01, 0x0c, 0x0c, "1 Coin  1 Credits"			},
452 	{0x16, 0x01, 0x0c, 0x00, "2 Coins 3 Credits"			},
453 	{0x16, 0x01, 0x0c, 0x08, "1 Coin  2 Credits"			},
454 
455 	{0   , 0xfe, 0   ,    2, "Coin Slots"				},
456 	{0x16, 0x01, 0x10, 0x10, "Common"				},
457 	{0x16, 0x01, 0x10, 0x00, "Individual"				},
458 
459 	{0   , 0xfe, 0   ,    2, "Difficulty"				},
460 	{0x16, 0x01, 0x20, 0x20, "Easy"					},
461 	{0x16, 0x01, 0x20, 0x00, "Hard"					},
462 
463 	{0   , 0xfe, 0   ,    2, "P1 Invulnerability (Cheat)"		},
464 	{0x16, 0x01, 0x40, 0x40, "Off"					},
465 	{0x16, 0x01, 0x40, 0x00, "On"					},
466 
467 	{0   , 0xfe, 0   ,    2, "P2 Invulnerability (Cheat)"		},
468 	{0x16, 0x01, 0x80, 0x80, "Off"					},
469 	{0x16, 0x01, 0x80, 0x00, "On"					},
470 };
471 
472 STDDIPINFO(Legion)
473 
474 static struct BurnDIPInfo TerrafDIPList[]=
475 {
476 	{0x15, 0xff, 0xff, 0x0f, NULL					},
477 	{0x16, 0xff, 0xff, 0x3f, NULL					},
478 
479 	{0   , 0xfe, 0   ,    4, "Lives"				},
480 	{0x15, 0x01, 0x03, 0x03, "3"					},
481 	{0x15, 0x01, 0x03, 0x02, "4"					},
482 	{0x15, 0x01, 0x03, 0x01, "5"					},
483 	{0x15, 0x01, 0x03, 0x00, "6"					},
484 
485 	{0   , 0xfe, 0   ,    2, "1st Bonus Life"			},
486 	{0x15, 0x01, 0x04, 0x04, "20k"					},
487 	{0x15, 0x01, 0x04, 0x00, "50k"					},
488 
489 	{0   , 0xfe, 0   ,    2, "2nd Bonus Life"			},
490 	{0x15, 0x01, 0x08, 0x08, "60k"					},
491 	{0x15, 0x01, 0x08, 0x00, "90k"					},
492 
493 	{0   , 0xfe, 0   ,    4, "Bonus Life"				},
494 	{0x15, 0x01, 0x0c, 0x0c, "20k then every 60k"			},
495 	{0x15, 0x01, 0x0c, 0x04, "20k then every 90k"			},
496 	{0x15, 0x01, 0x0c, 0x08, "50k then every 60k"			},
497 	{0x15, 0x01, 0x0c, 0x00, "50k then every 90k"			},
498 
499 	{0   , 0xfe, 0   ,    2, "Demo Sounds"				},
500 	{0x15, 0x01, 0x10, 0x10, "Off"					},
501 	{0x15, 0x01, 0x10, 0x00, "On"					},
502 
503 	{0   , 0xfe, 0   ,    4, "Coin A"				},
504 	{0x16, 0x01, 0x03, 0x01, "2 Coins 1 Credits"			},
505 	{0x16, 0x01, 0x03, 0x03, "1 Coin  1 Credits"			},
506 	{0x16, 0x01, 0x03, 0x02, "1 Coin  2 Credits"			},
507 	{0x16, 0x01, 0x03, 0x00, "Free Play"				},
508 
509 	{0   , 0xfe, 0   ,    4, "Coin B"				},
510 	{0x16, 0x01, 0x0c, 0x04, "2 Coins 1 Credits"			},
511 	{0x16, 0x01, 0x0c, 0x0c, "1 Coin  1 Credits"			},
512 	{0x16, 0x01, 0x0c, 0x00, "2 Coins 3 Credits"			},
513 	{0x16, 0x01, 0x0c, 0x08, "1 Coin  2 Credits"			},
514 
515 	{0   , 0xfe, 0   ,    2, "Flip Screen"				},
516 	{0x16, 0x01, 0x20, 0x20, "Off"					},
517 	{0x16, 0x01, 0x20, 0x00, "On"					},
518 
519 	{0   , 0xfe, 0   ,    4, "Allow Continue"			},
520 	{0x16, 0x01, 0xc0, 0xc0, "No"					},
521 	{0x16, 0x01, 0xc0, 0x80, "Only 3 Times"				},
522 	{0x16, 0x01, 0xc0, 0x40, "Only 5 Times"				},
523 	{0x16, 0x01, 0xc0, 0x00, "Yes"					},
524 };
525 
STDDIPINFO(Terraf)526 STDDIPINFO(Terraf)
527 
528 static void __fastcall armedf_write_word(UINT32 address, UINT16 data)
529 {
530 	switch (address)
531 	{
532 		case 0x06d000:
533 			*DrvVidRegs = data >> 8;
534 			*flipscreen = (data >> 12) & 1;
535 		return;
536 
537 		case 0x06d002:
538 			DrvScroll[0] = data & 0x3ff;
539 		return;
540 
541 		case 0x06d004:
542 			DrvScroll[1] = data & 0x1ff;
543 		return;
544 
545 		case 0x06d006:
546 			DrvScroll[2] = data & 0x3ff;
547 		return;
548 
549 		case 0x06d008:
550 			DrvScroll[3] = data & 0x1ff;
551 		return;
552 
553 		case 0x06d00a:
554 			*soundlatch = ((data & 0x7f) << 1) | 1;
555 		return;
556 	}
557 }
558 
bigfghtr_read_word(UINT32 address)559 static UINT16 __fastcall bigfghtr_read_word(UINT32 address)
560 {
561 	switch (address)
562 	{
563 		case 0x8c000:
564 			return DrvInputs[0];
565 
566 		case 0x8c002:
567 			return (DrvInputs[1] & ~0x0200) | ((DrvDips[2] << 8) & 0x0200);
568 
569 		case 0x8c004:
570 			return DrvInputs[2];
571 
572 		case 0x8c006:
573 			return DrvInputs[3];
574 
575 		case 0x400000:
576 			mcs51_set_irq_line(MCS51_INT0_LINE, CPU_IRQSTATUS_HOLD);
577 			SekRunEnd();
578 			return 0;
579 	}
580 
581 	return 0;
582 }
583 
bigfghtr_write_word(UINT32 address,UINT16 data)584 static void __fastcall bigfghtr_write_word(UINT32 address, UINT16 data)
585 {
586 	switch (address)
587 	{
588 		case 0x08d000:
589 			*DrvVidRegs = data >> 8;
590 			*flipscreen = (data >> 12) & 1;
591 		return;
592 
593 		case 0x08d002:
594 			DrvScroll[0] = data & 0x3ff;
595 		return;
596 
597 		case 0x08d004:
598 			DrvScroll[1] = data & 0x1ff;
599 		return;
600 
601 		case 0x08d006:
602 			DrvScroll[2] = data & 0x3ff;
603 		return;
604 
605 		case 0x08d008:
606 			DrvScroll[3] = data & 0x1ff;
607 		return;
608 
609 		case 0x08d00a:
610 			*soundlatch = ((data & 0x7f) << 1) | 1;
611 		return;
612 
613 		case 0x08d00c:
614 			// NOP
615 		return;
616 
617 		case 0x08d00e:
618 			SekSetIRQLine(irqline, CPU_IRQSTATUS_NONE);
619 		return;
620 	}
621 }
622 
cclimbr2_write_byte(UINT32 address,UINT8 data)623 static void __fastcall cclimbr2_write_byte(UINT32 address, UINT8 data)
624 {
625 	switch (address)
626 	{
627 		case 0x7c006: // scroll_x
628 			DrvMcuCmd[11] = data;
629 			DrvMcuCmd[31] = 1;
630 			fg_scrolly = ((data >> 8) & 0xff) | (fg_scrolly & 0x300);
631 			waiting_msb = 1;
632 		return;
633 
634 		case 0x7c008: // scroll_y
635 			if (DrvMcuCmd[31]) {
636 				DrvMcuCmd[14] = data >> 4;
637 				DrvMcuCmd[12] = data;
638 			} else {
639 				DrvMcuCmd[13] = data;
640 			}
641 			if (waiting_msb) {
642 				scroll_msb = data >> 8;
643 				fg_scrollx = (fg_scrollx & 0xff) | (((scroll_msb >> 4) & 3) << 8);
644 				fg_scrolly = (fg_scrolly & 0xff) | (((scroll_msb >> 0) & 3) << 8);
645 			} else {
646 				fg_scrollx = ((data >> 8) & 0xff) | (fg_scrollx & 0x300);
647 			}
648 		return;
649 
650 		case 0xc0000: // msb_arm_w
651 			DrvMcuCmd[31] = 0;
652 			waiting_msb = 0;
653 		return;
654 	}
655 }
656 
cclimbr2_write_word(UINT32 address,UINT16 data)657 static void __fastcall cclimbr2_write_word(UINT32 address, UINT16 data)
658 {
659 	if (scroll_type == 6 && (address & 0xffffc0) == 0x040000) {
660 		DrvMcuCmd[(address >> 1) & 0x1f] = data;
661 		return;
662 	}
663 
664 	switch (address)
665 	{
666 		case 0x7c000:
667 			{
668 				if (nb1414_blit_data) {
669 					if(data & 0x4000 && ((*DrvVidRegs & 0x40) == 0)) { //0 -> 1 transition
670 						UINT16 *ram = (UINT16*)DrvTxRAM;
671 						nb_1414m4_exec((ram[0] << 8) | (ram[1] & 0xff),(UINT16*)DrvTxRAM,&DrvScroll[2],&DrvScroll[3]);
672 					}
673 				}
674 
675 				*DrvVidRegs = data >> 8;
676 				*flipscreen = (data >> 12) & 1;
677 		}
678 		return;
679 
680 		case 0x7c002:
681 			DrvScroll[0] = data & 0x3ff;
682 		return;
683 
684 		case 0x7c004:
685 			DrvScroll[1] = data & 0x1ff;
686 		return;
687 
688 		case 0x7c006: //scrolly_w
689 			DrvMcuCmd[11] = data;
690 			DrvMcuCmd[31] = 1;
691 			fg_scrolly = ((data >> 8) & 0xff) | (fg_scrolly & 0x300);
692 			waiting_msb = 1;
693 		return;
694 
695 		case 0x7c008: // scrollx_w
696 			if (DrvMcuCmd[31]) {
697 				DrvMcuCmd[14] = data >> 4;
698 				DrvMcuCmd[12] = data;
699 			} else {
700 				DrvMcuCmd[13] = data;
701 			}
702 			if (waiting_msb) {
703 				scroll_msb = data >> 8;
704 				fg_scrollx = (fg_scrollx & 0xff) | (((scroll_msb >> 4) & 3) << 8);
705 				fg_scrolly = (fg_scrolly & 0xff) | (((scroll_msb >> 0) & 3) << 8);
706 			} else {
707 				fg_scrollx = ((data >> 8) & 0xff) | (fg_scrollx & 0x300);
708 			}
709 		return;
710 
711 		case 0xc0000: // msb_arm_w
712 			DrvMcuCmd[31] = 0;
713 			waiting_msb = 0;
714 		return;
715 
716 		case 0x7c00a:
717 			*soundlatch = ((data & 0x7f) << 1) | 1;
718 		return;
719 
720 		case 0x7c00c:
721 			//NOP.
722 		return;
723 
724 		case 0x7c00e:
725 			SekSetIRQLine(irqline, CPU_IRQSTATUS_NONE);
726 
727 			if (scroll_type == 0 || scroll_type == 3 || scroll_type == 5) {
728 				*DrvMcuCmd = data;
729 			}
730 		return;
731 	}
732 }
733 
cclimbr2_read_word(UINT32 address)734 static UINT16 __fastcall cclimbr2_read_word(UINT32 address)
735 {
736 	switch (address)
737 	{
738 		case 0x78000:
739 			return DrvInputs[0];
740 
741 		case 0x78002:
742 			return DrvInputs[1];
743 
744 		case 0x78004:
745 			return DrvInputs[2];
746 
747 		case 0x78006:
748 			return DrvInputs[3];
749 	}
750 
751 	return 0;
752 }
753 
armedf_write_port(UINT16 port,UINT8 data)754 static void __fastcall armedf_write_port(UINT16 port, UINT8 data)
755 {
756 	switch (port & 0xff)
757 	{
758 		case 0x00:
759 			BurnYM3812Write(0, 0, data);
760 		return;
761 
762 		case 0x01:
763 			BurnYM3812Write(0, 1, data);
764 		return;
765 
766 		case 0x02:
767 			DACSignedWrite(0, data);
768 		return;
769 
770 		case 0x03:
771 			DACSignedWrite(1, data);
772 		return;
773 	}
774 }
775 
armedf_read_port(UINT16 port)776 static UINT8 __fastcall armedf_read_port(UINT16 port)
777 {
778 	switch (port & 0xff)
779 	{
780 		case 0x04:
781 			*soundlatch = 0;
782 		return 0;
783 
784 		case 0x06:
785 			return *soundlatch;
786 	}
787 
788 	return 0;
789 }
790 
terrafjbextra_write(UINT16 address,UINT8 data)791 static void __fastcall terrafjbextra_write(UINT16 address, UINT8 data)
792 {
793 	if (address >= 0x4000 && address <= 0x5fff) {
794 		DrvTxRAM[(address ^ 1) - 0x4000] = data;
795 		return;
796 	}
797 }
798 
terrafjbextra_read(UINT16 address)799 static UINT8 __fastcall terrafjbextra_read(UINT16 address)
800 {
801 	if (address >= 0x4000 && address <= 0x5fff) {
802 		return DrvTxRAM[(address ^ 1) - 0x4000];
803 	}
804 
805 	return 0;
806 }
807 
DrvSynchroniseStream(INT32 nSoundRate)808 static INT32 DrvSynchroniseStream(INT32 nSoundRate)
809 {
810 	return (INT64)ZetTotalCycles() * nSoundRate / 6000000;
811 }
812 
DrvSyncDAC()813 static INT32 DrvSyncDAC()
814 {
815 	return (INT32)(float)(nBurnSoundLen * (ZetTotalCycles() / (6000000.000 / (nBurnFPS / 100.000))));
816 }
817 
DrvDoReset()818 static INT32 DrvDoReset()
819 {
820 	DrvReset = 0;
821 
822 	memset (AllRam, 0, RamEnd - AllRam);
823 
824 	SekOpen(0);
825 	SekReset();
826 	SekClose();
827 
828 	ZetOpen(0);
829 	ZetReset();
830 	ZetClose();
831 
832 	if (usemcu) {
833 		mcs51_reset();
834 	}
835 
836 	if (Terrafjb) {
837 		ZetOpen(1);
838 		ZetReset();
839 		ZetClose();
840 	}
841 
842 	BurnYM3812Reset();
843 	DACReset();
844 
845 	fg_scrolly = 0;
846 	fg_scrollx = 0;
847 	waiting_msb = 0;
848 	scroll_msb = 0;
849 
850 	return 0;
851 }
852 
MemIndex()853 static INT32 MemIndex()
854 {
855 	UINT8 *Next; Next = AllMem;
856 
857 	Drv68KROM	= Next; Next += 0x080000;
858 	DrvZ80ROM	= Next; Next += 0x010000;
859 	DrvZ80ROM2	= Next; Next += 0x004000;
860 
861 	DrvGfxROM0	= Next; Next += 0x010000;
862 	DrvGfxROM1	= Next; Next += 0x080000;
863 	DrvGfxROM2	= Next; Next += 0x080000;
864 	DrvGfxROM3	= Next; Next += 0x080000;
865 
866 	DrvPalette	= (UINT32*)Next; Next += 0x0800 * sizeof(UINT32);
867 
868 	nb1414_blit_data   = Next; Next += 0x004000; // nb1414m4 blitter data
869 
870 	AllRam		= Next;
871 
872 	DrvSprRAM	= Next; Next += 0x001000;
873 	DrvSprClut	= (UINT16*)Next; Next += 0x002000;
874 	DrvSprBuf	= Next; Next += 0x001000;
875 	DrvBgRAM	= Next; Next += 0x001000;
876 	DrvFgRAM	= Next; Next += 0x001000;
877 	DrvTxRAM	= Next; Next += 0x004000;
878 	DrvPalRAM	= Next; Next += 0x001000;
879 	Drv68KRAM0	= Next; Next += 0x005000;
880 	Drv68KRAM1	= Next; Next += 0x001000;
881 	Drv68KRAM2	= Next; Next += 0x001000;
882 	DrvShareRAM = Next; Next += 0x004000;
883 
884 	flipscreen	= Next; Next += 0x000001;
885 	soundlatch	= Next; Next += 0x000001;
886 	DrvVidRegs	= Next; Next += 0x000001;
887 	DrvScroll	= (UINT16*)Next; Next += 0x000004 * sizeof(UINT16);
888 	DrvMcuCmd	= (UINT16*)Next; Next += 0x000020 * sizeof(UINT16);
889 
890 	DrvZ80RAM	= Next; Next += 0x004000;
891 
892 	if (Terrafjb) {
893 		DrvZ80RAM2	= Next; Next += 0x001800;
894 	}
895 
896 	RamEnd		= Next;
897 	MemEnd		= Next;
898 
899 	return 0;
900 }
901 
DrvGfxDecode()902 static INT32 DrvGfxDecode()
903 {
904 	INT32 Plane[4]   = { 0x000, 0x001, 0x002, 0x003 };
905 	INT32 XOffs0[16] = { 0x004, 0x000, 0x00c, 0x008, 0x014, 0x010, 0x01c, 0x018,
906 			   0x024, 0x020, 0x02c, 0x028, 0x034, 0x030, 0x03c, 0x038 };
907 	INT32 YOffs0[16] = { 0x000, 0x020, 0x040, 0x060, 0x080, 0x0a0, 0x0c0, 0x0e0,
908 			   0x100, 0x120, 0x140, 0x160, 0x180, 0x1a0, 0x1c0, 0x1e0 };
909 	INT32 XOffs1[16] = { 0x000004, 0x000000, 0x100004, 0x100000, 0x00000c, 0x000008, 0x10000c, 0x100008,
910 			   0x000014, 0x000010, 0x100014, 0x100010, 0x00001c, 0x000018, 0x10001c, 0x100018 };
911 	INT32 YOffs1[16] = { 0x000, 0x040, 0x080, 0x0c0, 0x100, 0x140, 0x180, 0x1c0,
912 			   0x200, 0x240, 0x280, 0x2c0, 0x300, 0x340, 0x380, 0x3c0 };
913 
914 	UINT8 *tmp = (UINT8*)BurnMalloc(0x40000);
915 	if (tmp == NULL) {
916 		return 1;
917 	}
918 
919 	memcpy (tmp, DrvGfxROM0, 0x08000);
920 
921 	GfxDecode(0x0400, 4,  8,  8, Plane, XOffs0, YOffs0, 0x100, tmp, DrvGfxROM0);
922 
923 	memcpy (tmp, DrvGfxROM1, 0x40000);
924 
925 	GfxDecode(0x0800, 4, 16, 16, Plane, XOffs0, YOffs1, 0x400, tmp, DrvGfxROM1);
926 
927 	memcpy (tmp, DrvGfxROM2, 0x20000);
928 
929 	GfxDecode(0x0400, 4, 16, 16, Plane, XOffs0, YOffs1, 0x400, tmp, DrvGfxROM2);
930 
931 	memcpy (tmp, DrvGfxROM3, 0x40000);
932 
933 	GfxDecode(0x0800, 4, 16, 16, Plane, XOffs1, YOffs0, 0x200, tmp, DrvGfxROM3);
934 
935 	BurnFree (tmp);
936 
937 	return 0;
938 }
939 
Armedf68KInit()940 static void Armedf68KInit()
941 {
942 	SekMapMemory(Drv68KROM,		0x000000, 0x05ffff, MAP_ROM);
943 	SekMapMemory(DrvSprRAM,		0x060000, 0x060fff, MAP_RAM);
944 	SekMapMemory((UINT8 *)DrvSprClut,	0x06b000, 0x06bfff, MAP_RAM);
945 	SekMapMemory(Drv68KRAM0,	0x061000, 0x065fff, MAP_RAM);
946 	SekMapMemory(DrvBgRAM,		0x066000, 0x066fff, MAP_RAM);
947 	SekMapMemory(DrvFgRAM,		0x067000, 0x067fff, MAP_RAM);
948 	SekMapMemory(DrvTxRAM,		0x068000, 0x069fff, MAP_RAM);
949 	SekMapMemory(DrvPalRAM,		0x06a000, 0x06afff, MAP_RAM);
950 	SekMapMemory(Drv68KRAM2,	0x06c000, 0x06c7ff, MAP_RAM);
951 	SekSetWriteWordHandler(0,	armedf_write_word);
952 }
953 
mcu_read_data(INT32 address)954 static UINT8 mcu_read_data(INT32 address) // skyrobo, bigfghtr
955 {
956 	if (address >= 0x0600 && address <= 0x3fff) {
957 		return DrvShareRAM[(address&0x3fff)^1];
958 	}
959 
960 	return 0;
961 }
962 
mcu_write_data(INT32 address,UINT8 data)963 static void mcu_write_data(INT32 address, UINT8 data)
964 {
965 	if (address >= 0x0600 && address <= 0x3fff) {
966 		DrvShareRAM[(address&0x3fff)^1] = data;
967 		return;
968 	}
969 }
970 
Bigfghtr68KInit()971 static void Bigfghtr68KInit()
972 {
973 	SekMapMemory(Drv68KROM,		0x000000, 0x07ffff, MAP_ROM);
974 	//SekMapMemory(DrvSprRAM,		0x080000, 0x0805ff, MAP_RAM); // copied from shareram
975 	SekMapMemory(DrvShareRAM,		0x080000, 0x083fff, MAP_RAM);
976 	DrvSprRAM = DrvShareRAM; // Sprites 0x80000 - 0x805ff, Share 0x80600 - 0x803ff
977 	SekMapMemory((UINT8 *)DrvSprClut,	0x08b000, 0x08bfff, MAP_RAM);
978 	SekMapMemory(Drv68KRAM0,	0x084000, 0x085fff, MAP_RAM);
979 	SekMapMemory(DrvBgRAM,		0x086000, 0x086fff, MAP_RAM);
980 	SekMapMemory(DrvFgRAM,		0x087000, 0x087fff, MAP_RAM);
981 	SekMapMemory(DrvTxRAM,		0x088000, 0x089fff, MAP_RAM);
982 	SekMapMemory(DrvPalRAM,		0x08a000, 0x08afff, MAP_RAM);
983 	SekSetWriteWordHandler(0,	bigfghtr_write_word);
984 	SekSetReadWordHandler(0,	bigfghtr_read_word);
985 
986 	usemcu = 1;
987 	mcs51_program_data = DrvZ80ROM2;
988 	mcs51_init ();
989 	mcs51_set_write_handler(mcu_write_data);
990 	mcs51_set_read_handler(mcu_read_data);
991 
992 }
993 
Cclimbr268KInit()994 static void Cclimbr268KInit()
995 {
996 	SekMapMemory(Drv68KROM,		0x000000, 0x05ffff, MAP_ROM);
997 	SekMapMemory(DrvSprRAM,		0x060000, 0x060fff, MAP_RAM);
998 	SekMapMemory((UINT8 *)DrvSprClut,	0x06c000, 0x06cfff, MAP_RAM);
999 	SekMapMemory(Drv68KRAM0,	0x061000, 0x063fff, MAP_RAM);
1000 	SekMapMemory(DrvPalRAM,		0x064000, 0x064fff, MAP_RAM);
1001 	SekMapMemory(DrvTxRAM,		0x068000, 0x069fff, MAP_RAM);
1002 	SekMapMemory(Drv68KRAM1,	0x06a000, 0x06a9ff, MAP_RAM);
1003 	SekMapMemory(DrvFgRAM,		0x070000, 0x070fff, MAP_RAM);
1004 	SekMapMemory(DrvBgRAM,		0x074000, 0x074fff, MAP_RAM);
1005 	SekSetWriteWordHandler(0,	cclimbr2_write_word);
1006 	SekSetWriteByteHandler(0,	cclimbr2_write_byte);
1007 	SekSetReadWordHandler(0,	cclimbr2_read_word);
1008 }
1009 
DrvInit(INT32 (* pLoadRoms)(),void (* p68KInit)(),INT32 zLen)1010 static INT32 DrvInit(INT32 (*pLoadRoms)(), void (*p68KInit)(), INT32 zLen)
1011 {
1012 	AllMem = NULL;
1013 	MemIndex();
1014 	INT32 nLen = MemEnd - (UINT8 *)0;
1015 	if ((AllMem = (UINT8 *)BurnMalloc(nLen)) == NULL) return 1;
1016 	memset(AllMem, 0, nLen);
1017 	MemIndex();
1018 
1019 	if (pLoadRoms) {
1020 		if (pLoadRoms()) return 1;
1021 	}
1022 
1023 	DrvGfxDecode();
1024 
1025 	SekInit(0, 0x68000);
1026 	SekOpen(0);
1027 
1028 	if (p68KInit)
1029 	{
1030 		p68KInit();
1031 	}
1032 
1033 	SekClose();
1034 
1035 	ZetInit(0);
1036 	ZetOpen(0);
1037 	ZetMapMemory(DrvZ80ROM, 0x0000, zLen-1, MAP_ROM);
1038 	ZetMapMemory(DrvZ80RAM, zLen+0, 0xffff, MAP_RAM);
1039 	ZetSetOutHandler(armedf_write_port);
1040 	ZetSetInHandler(armedf_read_port);
1041 	ZetClose();
1042 
1043 	if (Terrafjb) {
1044 		ZetInit(1);
1045 		ZetOpen(1);
1046 		ZetMapMemory(DrvZ80ROM2, 0x0000, 0x3fff, MAP_ROM);
1047 		ZetMapMemory(DrvZ80RAM2, 0x8000, 0x87ff, MAP_RAM);
1048 		ZetSetWriteHandler(terrafjbextra_write);
1049 		ZetSetReadHandler(terrafjbextra_read);
1050 		ZetClose();
1051 	}
1052 
1053 	BurnYM3812Init(1, 4000000, NULL, &DrvSynchroniseStream, 0);
1054 	BurnTimerAttachYM3812(&ZetConfig, 6000000);
1055 	BurnYM3812SetRoute(0, BURN_SND_YM3812_ROUTE, 0.50, BURN_SND_ROUTE_BOTH);
1056 
1057 	DACInit(0, 0, 1, DrvSyncDAC);
1058 	DACInit(1, 0, 1, DrvSyncDAC);
1059 	DACSetRoute(0, 0.40, BURN_SND_ROUTE_BOTH);
1060 	DACSetRoute(1, 0.40, BURN_SND_ROUTE_BOTH);
1061 
1062 	GenericTilesInit();
1063 
1064 	if (nScreenWidth == 320) {
1065 		xoffset = 96;
1066 		yoffset = 8;
1067 	} else {
1068 		xoffset = 112;
1069 		yoffset = 16;
1070 	}
1071 
1072 	DrvDoReset();
1073 
1074 	return 0;
1075 }
1076 
DrvExit()1077 static INT32 DrvExit()
1078 {
1079 	GenericTilesExit();
1080 
1081 	DACExit();
1082 	BurnYM3812Exit();
1083 	SekExit();
1084 	ZetExit();
1085 
1086 	if (usemcu) {
1087 		mcs51_exit();
1088 		usemcu = 0;
1089 	}
1090 
1091 	BurnFree (AllMem);
1092 
1093 	Terrafjb = 0;
1094 	Kozuremode = 0;
1095 	Skyrobo = 0;
1096 	fiftysevenhertz = 0;
1097 
1098 	BurnSetRefreshRate(60.00);
1099 
1100 	return 0;
1101 }
1102 
DrvPaletteRecalc()1103 static inline void DrvPaletteRecalc()
1104 {
1105 	UINT8 r,g,b;
1106 	UINT16 *pal = (UINT16*)DrvPalRAM;
1107 	for (INT32 i = 0; i < 0x1000 / 2; i++) {
1108 		INT32 d = pal[i];
1109 
1110 		r = (d >> 4) & 0xf0;
1111 		g = (d & 0xf0);
1112 		b = (d & 0x0f);
1113 
1114 		r |= r >> 4;
1115 		g |= g >> 4;
1116 		b |= b << 4;
1117 
1118 		DrvPalette[i] = BurnHighCol(r, g, b, 0);
1119 	}
1120 }
1121 
AssembleInputs()1122 static inline void AssembleInputs()
1123 {
1124 	DrvInputs[0] = 0xffff;
1125 	DrvInputs[1] = 0xffff;
1126 
1127 	for (INT32 i = 0; i < 16; i++) {
1128 		DrvInputs[0] ^= (DrvJoy1[i] & 1) << i;
1129 		DrvInputs[1] ^= (DrvJoy2[i] & 1) << i;
1130 	}
1131 
1132 	DrvInputs[2] = DrvDips[0] | 0xff00;
1133 	DrvInputs[3] = DrvDips[1] | 0xff00;
1134 
1135 	if (scroll_type == 1) {
1136 		UINT16 *ptr = (UINT16*)Drv68KRAM2;
1137 		ptr[0] = DrvInputs[0];
1138 		ptr[1] = DrvInputs[1];
1139 		ptr[2] = DrvInputs[2];
1140 		ptr[3] = DrvInputs[3];
1141 	}
1142 }
1143 
draw_layer(UINT8 * ram,UINT8 * gfxbase,INT32 scrollx,INT32 scrolly,INT32 coloff,INT32 code_and)1144 static void draw_layer(UINT8 *ram, UINT8 *gfxbase, INT32 scrollx, INT32 scrolly, INT32 coloff, INT32 code_and)
1145 {
1146 	UINT16 *vram = (UINT16*)ram;
1147 
1148 	for (INT32 offs = 0; offs < 64 * 32; offs++)
1149 	{
1150 		INT32 sy = (offs & 0x1f) << 4;
1151 		INT32 sx = (offs >> 5) << 4;
1152 		sy -= scrolly + yoffset;
1153 		sx -= scrollx + xoffset;
1154 		if (sy < -15) sy += 512;
1155 		if (sx < -15) sx += 1024;
1156 
1157 		if (sy >= nScreenHeight || sx >= nScreenWidth) continue;
1158 
1159 		INT32 code = vram[offs] & code_and;
1160 		INT32 color = vram[offs] >> 11;
1161 
1162 		if (*flipscreen) {
1163 			Render16x16Tile_Mask_FlipXY_Clip(pTransDraw, code, (nScreenWidth - 16) - sx, (nScreenHeight - 16) - sy, color, 4, 15, coloff, gfxbase);
1164 		} else {
1165 			Render16x16Tile_Mask_Clip(pTransDraw, code, sx, sy, color, 4, 15, coloff, gfxbase);
1166 		}
1167 	}
1168 }
1169 
draw_txt_layer(INT32 transp,INT32 priority)1170 static void draw_txt_layer(INT32 transp, INT32 priority)
1171 {
1172 	UINT16 *vram = (UINT16*)DrvTxRAM;
1173 
1174 	for (INT32 offs = 0; offs < 64 * 32; offs++)
1175 	{
1176 		INT32 ofst = 0;
1177 		INT32 ofsta = 0x400;
1178 		INT32 sx = offs & 0x3f;
1179 		INT32 sy = offs >> 6;
1180 
1181 		if (scroll_type == 1) {
1182 	 		ofst = (sx << 5) | sy;
1183 			ofsta = 0x800;
1184 		} else if (scroll_type == 3 || scroll_type == 6) { // legion, legionjb
1185 			ofst = ((sx & 0x1f) << 5) | sy | ((sx >> 5) << 11);
1186 		} else {
1187 			ofst = ((sy ^ 0x1f) << 5) | (sx & 0x1f) | ((sx >> 5) << 11);
1188 		}
1189 
1190 		sx = (sx << 3) - xoffset;
1191 		sy = (sy << 3) - yoffset;
1192 		if (scroll_type != 1) sx += 128;
1193 
1194 		if (sx >= 512) sx -= 512; // fix for left-most characters in Kozure
1195 		//sx &= 0xff; // (instead of the line above) causes breakage in Legion.
1196 
1197 		if (sx < -7 || sy < -7 || sx >= nScreenWidth || sy >= nScreenHeight) continue;
1198 
1199 		INT32 attr = vram[ofst+ofsta] & 0xff;
1200 		INT32 category = (attr & 0x8) >> 3;
1201 		INT32 code = (vram[ofst] & 0xff) | ((attr & 3) << 8);
1202 		if (scroll_type == 3 && ofst < 0x12) continue; // ignore nb1414m4 params/fix text-garbage at the bottom of legion
1203 		if (category != priority) continue;
1204 
1205 		if (transp) {
1206 			if (*flipscreen) {
1207 				Render8x8Tile_Mask_FlipXY_Clip(pTransDraw, code, (nScreenWidth - 8) - sx, (nScreenHeight - 8) - sy, attr >> 4, 4, 15, 0, DrvGfxROM0);
1208 			} else {
1209 				Render8x8Tile_Mask_Clip(pTransDraw, code, sx, sy, attr >> 4, 4, 15, 0, DrvGfxROM0);
1210 			}
1211 		} else {
1212 			if (*flipscreen) {
1213 				Render8x8Tile_FlipXY_Clip(pTransDraw, code, (nScreenWidth - 8) - sx, (nScreenHeight - 8) -sy, attr >> 4, 4, 0, DrvGfxROM0);
1214 			} else {
1215 				Render8x8Tile_Clip(pTransDraw, code, sx, sy, attr >> 4, 4, 0, DrvGfxROM0);
1216 			}
1217 		}
1218 	}
1219 }
1220 
draw_sprites(INT32 priority)1221 static void draw_sprites(INT32 priority)
1222 {
1223 	UINT16 *spr = (UINT16*)DrvSprBuf;
1224 
1225 	INT32 sprlen = 0x1000;
1226 	if (scroll_type == 0 || scroll_type == 5) sprlen = 0x400;
1227 	if (Skyrobo) sprlen = 0x600;
1228 
1229 	for (INT32 offs = 0; offs < sprlen / 2; offs+=4)
1230 	{
1231 		INT32 attr  = spr[offs + 0];
1232 		if (((attr & 0x3000) >> 12) != priority) continue;
1233 
1234 		INT32 code  = spr[offs + 1];
1235 		INT32 flipx = code & 0x2000;
1236 		INT32 flipy = code & 0x1000;
1237 		INT32 color =(spr[offs + 2] >> 8) & 0x1f;
1238 		INT32 clut  = spr[offs + 2] & 0x7f;
1239 		INT32 sx    = spr[offs + 3];
1240 		INT32 sy    = sprite_offy + 240 - (attr & 0x1ff);
1241 		code       &= 0xfff;
1242 
1243 		if (*flipscreen) {
1244 			sx = 320 - sx + 176;
1245 			sy = 240 - sy + 1;
1246 			flipx = !flipx;
1247 			flipy = !flipy;
1248 		}
1249 
1250 		sy -= yoffset;
1251 		sx -= xoffset;
1252 
1253 		if (sx < -15 || sy < -15 || sx >= nScreenWidth || sy >= nScreenHeight) continue;
1254 
1255 		// Render sprites with CLUT
1256 		if (flipy) flipy  = 0x0f;
1257 		if (flipx) flipx  = 0x0f;
1258 		UINT8 mask = 0xf;
1259 		UINT8 *src = DrvGfxROM3 + (code * 16 * 16);
1260 		UINT16 *dst;
1261 
1262 		for (INT32 y = 0; y < 16; y++, sy++) {
1263 			if (sy < 0 || sy >= nScreenHeight) continue;
1264 			dst = pTransDraw + sy * nScreenWidth;
1265 
1266 			for (INT32 x = 0; x < 16; x++, sx++) {
1267 				if (sx < 0 || sx >= nScreenWidth) continue;
1268 
1269 				//INT32 pxl = src[((y^flipy << 4) | x^flipx)]; <- neat mosaic effect, save/use for tshingen & p-47 (dink)
1270 				INT32 pxl = src[(((y^flipy) << 4) | (x^flipx))];
1271 				UINT32 nColor = (color << 4) | 0x200;
1272 				UINT32 clutpxl = (pxl & ~0xf) | ((DrvSprClut[clut*0x10+(pxl & 0xf)]) & 0xf);
1273 				if (mask == clutpxl) continue;
1274 				dst[sx] = clutpxl | nColor;
1275 			}
1276 
1277 			sx -= 16;
1278 		}
1279 	}
1280 }
1281 
DrvDraw()1282 static INT32 DrvDraw()
1283 {
1284 	if (DrvRecalc) {
1285 		DrvPaletteRecalc();
1286 	}
1287 
1288 	for (INT32 offs = 0; offs < nScreenWidth * nScreenHeight; offs++)
1289 		pTransDraw[offs] = 0x00ff;
1290 
1291 	INT32 txt_transp = 1;
1292 
1293 	if (scroll_type == 0 || scroll_type == 5) {
1294 		if ((*DrvMcuCmd & 0x000f) == 0x000f) txt_transp = 0;
1295 	}
1296 
1297 	if (scroll_type != 1) {
1298 		UINT16 *ram = (UINT16*)DrvTxRAM;
1299 		if (scroll_type == 0 || scroll_type == 6) ram = DrvMcuCmd;
1300 
1301 		DrvScroll[2] = (ram[13] & 0xff) | ((ram[14] & 3) << 8);
1302 		DrvScroll[3] = (ram[11] & 0xff) | ((ram[12] & 1) << 8);
1303 	}
1304 
1305 	if (scroll_type == 0) { // terraf
1306 		DrvScroll[2] = fg_scrollx;
1307 		DrvScroll[3] = fg_scrolly;
1308 	}
1309 
1310 	if ((*DrvMcuCmd & 0x30) == 0x30 && *DrvVidRegs & 0x01) draw_txt_layer(txt_transp, 1);
1311 	if (*DrvVidRegs & 0x08) draw_layer(DrvBgRAM, DrvGfxROM2, DrvScroll[0], DrvScroll[1], 0x600, 0x3ff);
1312 	if (*DrvVidRegs & 0x02) draw_sprites(2);
1313 	if (*DrvVidRegs & 0x04) draw_layer(DrvFgRAM, DrvGfxROM1, DrvScroll[2], DrvScroll[3], 0x400, 0x7ff);
1314 	if (*DrvVidRegs & 0x02) draw_sprites(1);
1315 	if ((*DrvMcuCmd & 0x30) == 0x00 && *DrvVidRegs & 0x01) draw_txt_layer(txt_transp, 0);
1316 	if (*DrvVidRegs & 0x02) draw_sprites(0);
1317 
1318 	BurnTransferCopy(DrvPalette);
1319 
1320 	memcpy (DrvSprBuf, DrvSprRAM, 0x1000);
1321 
1322 	return 0;
1323 }
1324 
DrvFrame()1325 static INT32 DrvFrame()
1326 {
1327 	if (DrvReset) {
1328 		DrvDoReset();
1329 	}
1330 
1331 	SekNewFrame();
1332 	ZetNewFrame();
1333 
1334 	AssembleInputs();
1335 
1336 	INT32 nSegment;
1337 	INT32 nInterleave = 262;
1338 	INT32 nTotalCycles[3] = { 8000000 / ((fiftysevenhertz) ? 57 : 60), 6000000 / ((fiftysevenhertz) ? 57 : 60), 4000000 / ((fiftysevenhertz) ? 57 : 60) };
1339 	INT32 nCyclesDone[3] = { 0, 0, 0 };
1340 
1341 	if (usemcu) nTotalCycles[2] /= 12; // i8751 internal divider (12)
1342 
1343 	SekOpen(0);
1344 	ZetOpen(0);
1345 	nb1414_frame++;
1346 
1347 	for (INT32 i = 0; i < nInterleave; i++)
1348 	{
1349 		INT32 nNext = (i + 1) * nTotalCycles[0] / nInterleave;
1350 		nSegment = nNext - nCyclesDone[0];
1351 		nCyclesDone[0] += SekRun(nSegment);
1352 
1353 		BurnTimerUpdateYM3812((i + 1) * (nTotalCycles[1] / nInterleave));
1354 
1355 		if (i & 1) ZetSetIRQLine(0, CPU_IRQSTATUS_AUTO); // 130 per frame (based on nInterleave = 262)
1356 
1357 		if (usemcu) {
1358 			mcs51Run((nTotalCycles[2] / nInterleave));
1359 		}
1360 
1361 		if (Terrafjb) {
1362 			ZetClose();
1363 			ZetOpen(1);
1364 			nNext = (i + 1) * nTotalCycles[2] / nInterleave;
1365 			nSegment = nNext - nCyclesDone[2];
1366 			nCyclesDone[2] += ZetRun(nSegment);
1367 			ZetClose();
1368 			ZetOpen(0);
1369 		}
1370 	}
1371 
1372 	BurnTimerEndFrameYM3812(nTotalCycles[1]);
1373 
1374 	SekSetIRQLine(irqline, (usemcu) ? CPU_IRQSTATUS_ACK : CPU_IRQSTATUS_AUTO);
1375 
1376 	if (pBurnSoundOut) {
1377 		BurnYM3812Update(pBurnSoundOut, nBurnSoundLen);
1378 		DACUpdate(pBurnSoundOut, nBurnSoundLen);
1379 	}
1380 
1381 	ZetClose();
1382 	SekClose();
1383 
1384 	if (pBurnDraw) {
1385 		DrvDraw();
1386 	}
1387 
1388 	return 0;
1389 }
1390 
DrvScan(INT32 nAction,INT32 * pnMin)1391 static INT32 DrvScan(INT32 nAction, INT32 *pnMin)
1392 {
1393 	struct BurnArea ba;
1394 
1395 	if (pnMin != NULL) {
1396 		*pnMin = 0x029702;
1397 	}
1398 
1399 	if (nAction & ACB_MEMORY_RAM) {
1400 		memset(&ba, 0, sizeof(ba));
1401 		ba.Data	  = AllRam;
1402 		ba.nLen	  = RamEnd-AllRam;
1403 		ba.szName = "All Ram";
1404 		BurnAcb(&ba);
1405 	}
1406 
1407 	if (nAction & ACB_DRIVER_DATA) {
1408 		SekScan(nAction);
1409 		ZetScan(nAction);
1410 		if (usemcu) {
1411 			mcs51_scan(nAction);
1412 		}
1413 
1414 		BurnYM3812Scan(nAction, pnMin);
1415 		DACScan(nAction, pnMin);
1416 
1417 		SCAN_VAR(fg_scrolly);
1418 		SCAN_VAR(fg_scrollx);
1419 		SCAN_VAR(waiting_msb);
1420 		SCAN_VAR(scroll_msb);
1421 	}
1422 
1423 	return 0;
1424 }
1425 
1426 
1427 // Armed Formation
1428 
1429 static struct BurnRomInfo armedfRomDesc[] = {
1430 	{ "06.3d",		0x10000, 0x0f9015e2, 1 | BRF_PRG | BRF_ESS }, //  0 68k Code
1431 	{ "01.3f",		0x10000, 0x816ff7c5, 1 | BRF_PRG | BRF_ESS }, //  1
1432 	{ "07.5d",		0x10000, 0x5b3144a5, 1 | BRF_PRG | BRF_ESS }, //  2
1433 	{ "02.4f",		0x10000, 0xfa10c29d, 1 | BRF_PRG | BRF_ESS }, //  3
1434 	{ "af_08.rom",	0x10000, 0xd1d43600, 1 | BRF_PRG | BRF_ESS }, //  4
1435 	{ "af_03.rom",	0x10000, 0xbbe1fe2d, 1 | BRF_PRG | BRF_ESS }, //  5
1436 
1437 	{ "af_10.rom",	0x10000, 0xc5eacb87, 2 | BRF_PRG | BRF_ESS }, //  6 Z80 code
1438 
1439 	{ "09.11c",		0x08000, 0x5c6993d5, 3 | BRF_GRA },           //  7 Characters
1440 
1441 	{ "af_04.rom",	0x10000, 0x44d3af4f, 4 | BRF_GRA },           //  8 Foreground Tiles
1442 	{ "af_05.rom",	0x10000, 0x92076cab, 4 | BRF_GRA },           //  9
1443 
1444 	{ "af_14.rom",	0x10000, 0x8c5dc5a7, 5 | BRF_GRA },           // 10 Background Tiles
1445 	{ "af_13.rom",	0x10000, 0x136a58a3, 5 | BRF_GRA },           // 11
1446 
1447 	{ "af_11.rom",	0x20000, 0xb46c473c, 6 | BRF_GRA },           // 12 Sprites
1448 	{ "af_12.rom",	0x20000, 0x23cb6bfe, 6 | BRF_GRA },           // 13
1449 };
1450 
1451 STD_ROM_PICK(armedf)
1452 STD_ROM_FN(armedf)
1453 
1454 static struct BurnRomInfo armedffRomDesc[] = {
1455 	{ "af_06.rom",	0x10000, 0xc5326603, 1 | BRF_PRG | BRF_ESS }, //  0 68k Code
1456 	{ "af_01.rom",	0x10000, 0x458e9542, 1 | BRF_PRG | BRF_ESS }, //  1
1457 	{ "af_07.rom",	0x10000, 0xcc8517f5, 1 | BRF_PRG | BRF_ESS }, //  2
1458 	{ "af_02.rom",	0x10000, 0x214ef220, 1 | BRF_PRG | BRF_ESS }, //  3
1459 	{ "af_08.rom",	0x10000, 0xd1d43600, 1 | BRF_PRG | BRF_ESS }, //  4
1460 	{ "af_03.rom",	0x10000, 0xbbe1fe2d, 1 | BRF_PRG | BRF_ESS }, //  5
1461 
1462 	{ "af_10.rom",	0x10000, 0xc5eacb87, 2 | BRF_PRG | BRF_ESS }, //  6 Z80 code
1463 
1464 	{ "af_09.rom",	0x08000, 0x7025e92d, 3 | BRF_GRA },           //  7 Characters
1465 
1466 	{ "af_04.rom",	0x10000, 0x44d3af4f, 4 | BRF_GRA },           //  8 Foreground Tiles
1467 	{ "af_05.rom",	0x10000, 0x92076cab, 4 | BRF_GRA },           //  9
1468 
1469 	{ "af_14.rom",	0x10000, 0x8c5dc5a7, 5 | BRF_GRA },           // 10 Background Tiles
1470 	{ "af_13.rom",	0x10000, 0x136a58a3, 5 | BRF_GRA },           // 11
1471 
1472 	{ "af_11.rom",	0x20000, 0xb46c473c, 6 | BRF_GRA },           // 12 Sprites
1473 	{ "af_12.rom",	0x20000, 0x23cb6bfe, 6 | BRF_GRA },           // 13
1474 };
1475 
1476 STD_ROM_PICK(armedff)
STD_ROM_FN(armedff)1477 STD_ROM_FN(armedff)
1478 
1479 static INT32 ArmedfLoadRoms()
1480 {
1481 	if (BurnLoadRom(Drv68KROM + 0x000001,	 0, 2)) return 1;
1482 	if (BurnLoadRom(Drv68KROM + 0x000000,	 1, 2)) return 1;
1483 	if (BurnLoadRom(Drv68KROM + 0x020001,	 2, 2)) return 1;
1484 	if (BurnLoadRom(Drv68KROM + 0x020000,	 3, 2)) return 1;
1485 	if (BurnLoadRom(Drv68KROM + 0x040001,	 4, 2)) return 1;
1486 	if (BurnLoadRom(Drv68KROM + 0x040000,	 5, 2)) return 1;
1487 
1488 	if (BurnLoadRom(DrvZ80ROM,		 6, 1)) return 1;
1489 
1490 	if (BurnLoadRom(DrvGfxROM0,		 7, 1)) return 1;
1491 
1492 	if (BurnLoadRom(DrvGfxROM1 + 0x000000,	 8, 1)) return 1;
1493 	if (BurnLoadRom(DrvGfxROM1 + 0x010000,	 9, 1)) return 1;
1494 
1495 	if (BurnLoadRom(DrvGfxROM2 + 0x000000,	10, 1)) return 1;
1496 	if (BurnLoadRom(DrvGfxROM2 + 0x010000,	11, 1)) return 1;
1497 
1498 	if (BurnLoadRom(DrvGfxROM3 + 0x000000,	12, 1)) return 1;
1499 	if (BurnLoadRom(DrvGfxROM3 + 0x020000,	13, 1)) return 1;
1500 
1501 	return 0;
1502 }
1503 
ArmedfInit()1504 static INT32 ArmedfInit()
1505 {
1506 	scroll_type = 1;
1507 	sprite_offy = 128;
1508 	irqline = 1;
1509 
1510 	INT32 nRet = DrvInit(ArmedfLoadRoms, Armedf68KInit, 0xf800);
1511 
1512 	if (nRet == 0) {
1513 		DACSetRoute(0, 0.40, BURN_SND_ROUTE_BOTH);
1514 		DACSetRoute(1, 0.40, BURN_SND_ROUTE_BOTH);
1515 		BurnSetRefreshRate(57.00);
1516 		fiftysevenhertz = 1;
1517 	}
1518 
1519 	return nRet;
1520 }
1521 
1522 struct BurnDriver BurnDrvArmedf = {
1523 	"armedf", NULL, NULL, NULL, "1988",
1524 	"Armed Formation\0", NULL, "Nichibutsu", "Miscellaneous",
1525 	NULL, NULL, NULL, NULL,
1526 	BDF_GAME_WORKING | BDF_ORIENTATION_VERTICAL, 2, HARDWARE_MISC_PRE90S, GBF_VERSHOOT, 0,
1527 	NULL, armedfRomInfo, armedfRomName, NULL, NULL, NULL, NULL, ArmedfInputInfo, ArmedfDIPInfo,
1528 	ArmedfInit, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalc, 0x800,
1529 	240, 320, 3, 4
1530 };
1531 
1532 struct BurnDriver BurnDrvArmedff = {
1533 	"armedff", "armedf", NULL, NULL, "1988",
1534 	"Armed Formation (Fillmore license)\0", NULL, "Nichibutsu (Fillmore license)", "Miscellaneous",
1535 	NULL, NULL, NULL, NULL,
1536 	BDF_GAME_WORKING | BDF_CLONE | BDF_ORIENTATION_VERTICAL, 2, HARDWARE_MISC_PRE90S, GBF_VERSHOOT, 0,
1537 	NULL, armedffRomInfo, armedffRomName, NULL, NULL, NULL, NULL, ArmedfInputInfo, ArmedfDIPInfo,
1538 	ArmedfInit, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalc, 0x800,
1539 	240, 320, 3, 4
1540 };
1541 
1542 // Crazy Climber 2 (Japan)
1543 
1544 static struct BurnRomInfo cclimbr2RomDesc[] = {
1545 	{ "4.bin",	0x10000, 0x7922ea14, 1 | BRF_PRG | BRF_ESS }, //  0 68k Code
1546 	{ "1.bin",	0x10000, 0x2ac7ed67, 1 | BRF_PRG | BRF_ESS }, //  1
1547 	{ "6.bin",	0x10000, 0x7905c992, 1 | BRF_PRG | BRF_ESS }, //  2
1548 	{ "5.bin",	0x10000, 0x47be6c1e, 1 | BRF_PRG | BRF_ESS }, //  3
1549 	{ "3.bin",	0x10000, 0x1fb110d6, 1 | BRF_PRG | BRF_ESS }, //  4
1550 	{ "2.bin",	0x10000, 0x0024c15b, 1 | BRF_PRG | BRF_ESS }, //  5
1551 
1552 	{ "11.bin",	0x04000, 0xfe0175be, 2 | BRF_PRG | BRF_ESS }, //  6 Z80 code
1553 	{ "12.bin",	0x08000, 0x5ddf18f2, 2 | BRF_PRG | BRF_ESS }, //  7
1554 
1555 	{ "10.bin",	0x08000, 0x7f475266, 3 | BRF_GRA },           //  8 Characters
1556 
1557 	{ "7.bin",	0x10000, 0xcbdd3906, 4 | BRF_GRA },           //  9 Foreground Tiles
1558 	{ "8.bin",	0x10000, 0xb2a613c0, 4 | BRF_GRA },           // 10
1559 
1560 	{ "17.bin",	0x10000, 0xe24bb2d7, 5 | BRF_GRA },           // 11 Background Tiles
1561 	{ "18.bin",	0x10000, 0x56834554, 5 | BRF_GRA },           // 12
1562 
1563 	{ "15.bin",	0x10000, 0x4bf838be, 6 | BRF_GRA },           // 13 Sprites
1564 	{ "16.bin",	0x10000, 0x21a265c5, 6 | BRF_GRA },           // 14
1565 	{ "13.bin",	0x10000, 0x6b6ec999, 6 | BRF_GRA },           // 15
1566 	{ "14.bin",	0x10000, 0xf426a4ad, 6 | BRF_GRA },           // 16
1567 
1568 	{ "9.bin",	0x04000, 0x740d260f, 7 | BRF_GRA | BRF_OPT }, // 17 MCU data
1569 };
1570 
1571 STD_ROM_PICK(cclimbr2)
STD_ROM_FN(cclimbr2)1572 STD_ROM_FN(cclimbr2)
1573 
1574 static INT32 Cclimbr2LoadRoms()
1575 {
1576 	if (BurnLoadRom(Drv68KROM + 0x000001,	 0, 2)) return 1;
1577 	if (BurnLoadRom(Drv68KROM + 0x000000,	 1, 2)) return 1;
1578 	if (BurnLoadRom(Drv68KROM + 0x020001,	 2, 2)) return 1;
1579 	if (BurnLoadRom(Drv68KROM + 0x020000,	 3, 2)) return 1;
1580 	if (BurnLoadRom(Drv68KROM + 0x040001,	 4, 2)) return 1;
1581 	if (BurnLoadRom(Drv68KROM + 0x040000,	 5, 2)) return 1;
1582 
1583 	if (BurnLoadRom(DrvZ80ROM + 0x000000,	 6, 1)) return 1;
1584 	if (BurnLoadRom(DrvZ80ROM + 0x004000,	 7, 1)) return 1;
1585 
1586 	if (BurnLoadRom(DrvGfxROM0,		 8, 1)) return 1;
1587 
1588 	if (BurnLoadRom(DrvGfxROM1 + 0x000000,	 9, 1)) return 1;
1589 	if (BurnLoadRom(DrvGfxROM1 + 0x010000,	10, 1)) return 1;
1590 
1591 	if (BurnLoadRom(DrvGfxROM2 + 0x000000,	11, 1)) return 1;
1592 	if (BurnLoadRom(DrvGfxROM2 + 0x010000,	12, 1)) return 1;
1593 
1594 	if (BurnLoadRom(DrvGfxROM3 + 0x000000,	13, 1)) return 1;
1595 	if (BurnLoadRom(DrvGfxROM3 + 0x010000,	14, 1)) return 1;
1596 	if (BurnLoadRom(DrvGfxROM3 + 0x020000,	15, 1)) return 1;
1597 	if (BurnLoadRom(DrvGfxROM3 + 0x030000,	16, 1)) return 1;
1598 
1599 	return 0;
1600 }
1601 
Cclimbr2Init()1602 static INT32 Cclimbr2Init()
1603 {
1604 	scroll_type = 4;
1605 	sprite_offy = 0;
1606 	irqline = 2;
1607 
1608 	return DrvInit(Cclimbr2LoadRoms, Cclimbr268KInit, 0xc000);
1609 }
1610 
1611 struct BurnDriver BurnDrvCclimbr2 = {
1612 	"cclimbr2", NULL, NULL, NULL, "1988",
1613 	"Crazy Climber 2 (Japan)\0", NULL, "Nichibutsu", "Miscellaneous",
1614 	NULL, NULL, NULL, NULL,
1615 	BDF_GAME_WORKING, 2, HARDWARE_MISC_PRE90S, GBF_PLATFORM, 0,
1616 	NULL, cclimbr2RomInfo, cclimbr2RomName, NULL, NULL, NULL, NULL, Cclimbr2InputInfo, Cclimbr2DIPInfo,
1617 	Cclimbr2Init, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalc, 0x800,
1618 	288, 224, 4, 3
1619 };
1620 
1621 
1622 // Crazy Climber 2 (Japan, Harder)
1623 
1624 static struct BurnRomInfo cclmbr2aRomDesc[] = {
1625 	{ "4a.bin",	0x10000, 0xe1d3192c, 1 | BRF_PRG | BRF_ESS }, //  0 68k Code
1626 	{ "1a.bin",	0x10000, 0x3ef84974, 1 | BRF_PRG | BRF_ESS }, //  1
1627 	{ "6.bin",	0x10000, 0x7905c992, 1 | BRF_PRG | BRF_ESS }, //  2
1628 	{ "5.bin",	0x10000, 0x47be6c1e, 1 | BRF_PRG | BRF_ESS }, //  3
1629 	{ "3.bin",	0x10000, 0x1fb110d6, 1 | BRF_PRG | BRF_ESS }, //  4
1630 	{ "2.bin",	0x10000, 0x0024c15b, 1 | BRF_PRG | BRF_ESS }, //  5
1631 
1632 	{ "11.bin",	0x04000, 0xfe0175be, 2 | BRF_PRG | BRF_ESS }, //  6 Z80 code
1633 	{ "12.bin",	0x08000, 0x5ddf18f2, 2 | BRF_PRG | BRF_ESS }, //  7
1634 
1635 	{ "10.bin",	0x08000, 0x7f475266, 3 | BRF_GRA },           //  8 Characters
1636 
1637 	{ "7.bin",	0x10000, 0xcbdd3906, 4 | BRF_GRA },           //  9 Foreground Tiles
1638 	{ "8.bin",	0x10000, 0xb2a613c0, 4 | BRF_GRA },           // 10
1639 
1640 	{ "17.bin",	0x10000, 0xe24bb2d7, 5 | BRF_GRA },           // 11 Background Tiles
1641 	{ "18.bin",	0x10000, 0x56834554, 5 | BRF_GRA },           // 12
1642 
1643 	{ "15.bin",	0x10000, 0x4bf838be, 6 | BRF_GRA },           // 13 Sprites
1644 	{ "16.bin",	0x10000, 0x21a265c5, 6 | BRF_GRA },           // 14
1645 	{ "13.bin",	0x10000, 0x6b6ec999, 6 | BRF_GRA },           // 15
1646 	{ "14.bin",	0x10000, 0xf426a4ad, 6 | BRF_GRA },           // 16
1647 
1648 	{ "9.bin",	0x04000, 0x740d260f, 7 | BRF_GRA | BRF_OPT }, // 17 MCU data
1649 };
1650 
1651 STD_ROM_PICK(cclmbr2a)
1652 STD_ROM_FN(cclmbr2a)
1653 
1654 struct BurnDriver BurnDrvCclmbr2a = {
1655 	"cclimbr2a", "cclimbr2", NULL, NULL, "1988",
1656 	"Crazy Climber 2 (Japan, Harder)\0", NULL, "Nichibutsu", "Miscellaneous",
1657 	NULL, NULL, NULL, NULL,
1658 	BDF_GAME_WORKING | BDF_CLONE, 2, HARDWARE_MISC_PRE90S, GBF_PLATFORM, 0,
1659 	NULL, cclmbr2aRomInfo, cclmbr2aRomName, NULL, NULL, NULL, NULL, Cclimbr2InputInfo, Cclimbr2DIPInfo,
1660 	Cclimbr2Init, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalc, 0x800,
1661 	288, 224, 4, 3
1662 };
1663 
1664 
1665 // Kozure Ookami (Japan)
1666 
1667 static struct BurnRomInfo kozureRomDesc[] = {
1668 	{ "kozure8.6e",		0x10000, 0x6bbfb1e6, 1 | BRF_PRG | BRF_ESS }, //  0 68k Code
1669 	{ "kozure3.6h",		0x10000, 0xf9178ec8, 1 | BRF_PRG | BRF_ESS }, //  1
1670 	{ "kozure7.5e",		0x10000, 0xa7ee09bb, 1 | BRF_PRG | BRF_ESS }, //  2
1671 	{ "kozure2.5h",		0x10000, 0x236d820f, 1 | BRF_PRG | BRF_ESS }, //  3
1672 	{ "kozure6.3e",		0x10000, 0x9120e728, 1 | BRF_PRG | BRF_ESS }, //  4
1673 	{ "kozure1.3h",		0x10000, 0x345fe7a5, 1 | BRF_PRG | BRF_ESS }, //  5
1674 
1675 	{ "kozure11.17k",	0x10000, 0xdba51e2d, 2 | BRF_PRG | BRF_ESS }, //  6 Z80 code
1676 
1677 	{ "kozure9.11e",	0x08000, 0xe041356e, 3 | BRF_GRA },           //  7 Characters
1678 
1679 	{ "kozure5.15h",	0x20000, 0x0b510258, 4 | BRF_GRA },           //  8 Foreground Tiles
1680 	{ "kozure4.14h",	0x10000, 0xfb8e13e6, 4 | BRF_GRA },           //  9
1681 
1682 	{ "kozure14.8a",	0x10000, 0x94a9c3d0, 5 | BRF_GRA },           // 10 Background Tiles
1683 
1684 	{ "kozure12.8d",	0x20000, 0x15f4021d, 6 | BRF_GRA },           // 11 Sprites
1685 	{ "kozure13.9d",	0x20000, 0xb3b6c753, 6 | BRF_GRA },           // 12
1686 
1687 	{ "kozure10.11c",	0x04000, 0xf48be21d, 7 | BRF_GRA },           // 13 MCU data
1688 
1689 	{ "n82s129an.11j",	0x00100, 0x81244757, 8 | BRF_OPT },           // 14 Proms
1690 };
1691 
1692 STD_ROM_PICK(kozure)
STD_ROM_FN(kozure)1693 STD_ROM_FN(kozure)
1694 
1695 static INT32 KozureLoadRoms()
1696 {
1697 	if (BurnLoadRom(Drv68KROM + 0x000001,	 0, 2)) return 1;
1698 	if (BurnLoadRom(Drv68KROM + 0x000000,	 1, 2)) return 1;
1699 	if (BurnLoadRom(Drv68KROM + 0x020001,	 2, 2)) return 1;
1700 	if (BurnLoadRom(Drv68KROM + 0x020000,	 3, 2)) return 1;
1701 	if (BurnLoadRom(Drv68KROM + 0x040001,	 4, 2)) return 1;
1702 	if (BurnLoadRom(Drv68KROM + 0x040000,	 5, 2)) return 1;
1703 
1704 	if (BurnLoadRom(DrvZ80ROM,		 6, 1)) return 1;
1705 
1706 	if (BurnLoadRom(DrvGfxROM0,		 7, 1)) return 1;
1707 
1708 	if (BurnLoadRom(DrvGfxROM1 + 0x000000,	 8, 1)) return 1;
1709 	if (BurnLoadRom(DrvGfxROM1 + 0x020000,	 9, 1)) return 1;
1710 
1711 	if (BurnLoadRom(DrvGfxROM2,		10, 1)) return 1;
1712 
1713 	if (BurnLoadRom(DrvGfxROM3 + 0x000000,	11, 1)) return 1;
1714 	if (BurnLoadRom(DrvGfxROM3 + 0x020000,	12, 1)) return 1;
1715 	if (BurnLoadRom(nb1414_blit_data,	13, 1)) return 1;
1716 
1717 	return 0;
1718 }
1719 
KozureInit()1720 static INT32 KozureInit()
1721 {
1722 	scroll_type = 2;
1723 	sprite_offy = 128;
1724 	irqline = 1;
1725 	Kozuremode = 1;
1726 
1727 	INT32 nRet = DrvInit(KozureLoadRoms, Cclimbr268KInit, 0xf800);
1728 
1729 	if (nRet == 0) {
1730 		*((UINT16*)(Drv68KROM + 0x1016c)) = 0x4e71; // patch "time over" bug.
1731 		*((UINT16*)(Drv68KROM + 0x04fc6)) = 0x4e71; // ROM check at POST.
1732 
1733 		DACSetRoute(0, 0.20, BURN_SND_ROUTE_BOTH);
1734 		DACSetRoute(1, 0.20, BURN_SND_ROUTE_BOTH);
1735 	}
1736 
1737 	return nRet;
1738 }
1739 
1740 struct BurnDriver BurnDrvKozure = {
1741 	"kozure", NULL, NULL, NULL, "1987",
1742 	"Kozure Ookami (Japan)\0", NULL, "Nichibutsu", "Miscellaneous",
1743 	NULL, NULL, NULL, NULL,
1744 	BDF_GAME_WORKING | BDF_ORIENTATION_FLIPPED, 2, HARDWARE_MISC_PRE90S, GBF_SCRFIGHT, 0,
1745 	NULL, kozureRomInfo, kozureRomName, NULL, NULL, NULL, NULL, ArmedfInputInfo, KozureDIPInfo,
1746 	KozureInit, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalc, 0x800,
1747 	320, 240, 4, 3
1748 };
1749 
1750 
1751 // Legion - Spinner-87 (World ver 2.03)
1752 
1753 static struct BurnRomInfo legionRomDesc[] = {
1754 	{ "lg3.bin",	0x10000, 0x777e4935, 1 | BRF_PRG | BRF_ESS }, //  0 68k Code
1755 	{ "lg1.bin",	0x10000, 0xc4aeb724, 1 | BRF_PRG | BRF_ESS }, //  1
1756 	{ "legion.1d",	0x10000, 0xc2e45e1e, 1 | BRF_PRG | BRF_ESS }, //  2
1757 	{ "legion.1b",	0x10000, 0xc306660a, 1 | BRF_PRG | BRF_ESS }, //  3
1758 
1759 	{ "legion.1h",	0x04000, 0x2ca4f7f0, 2 | BRF_PRG | BRF_ESS }, //  4 Z80 code
1760 
1761 	{ "lg8.bin",	0x08000, 0xe0596570, 3 | BRF_GRA },           //  5 Characters
1762 
1763 	{ "legion.1e",	0x10000, 0xa9d70faf, 4 | BRF_GRA },           //  6 Foreground Tiles
1764 	{ "legion.1f",	0x08000, 0xf018313b, 4 | BRF_GRA },           //  7
1765 
1766 	{ "legion.1l",	0x10000, 0x29b8adaa, 5 | BRF_GRA },           //  8 Background Tiles
1767 
1768 	{ "legion.1k",	0x10000, 0xff5a0db9, 6 | BRF_GRA },           //  9 Sprites
1769 	{ "legion.1j",	0x10000, 0xbae220c8, 6 | BRF_GRA },           // 10
1770 
1771 	{ "lg7.bin",	0x04000, 0x533e2b58, 7 | BRF_GRA },           // 11 MCU data
1772 
1773 	{ "legion.1i",	0x08000, 0x79f4a827, 2 | BRF_OPT },           // 12 Unknown
1774 };
1775 
1776 STD_ROM_PICK(legion)
STD_ROM_FN(legion)1777 STD_ROM_FN(legion)
1778 
1779 static INT32 LegionLoadRoms()
1780 {
1781 	if (BurnLoadRom(Drv68KROM + 0x000001,	 0, 2)) return 1;
1782 	if (BurnLoadRom(Drv68KROM + 0x000000,	 1, 2)) return 1;
1783 	if (BurnLoadRom(Drv68KROM + 0x020001,	 2, 2)) return 1;
1784 	if (BurnLoadRom(Drv68KROM + 0x020000,	 3, 2)) return 1;
1785 
1786 	if (BurnLoadRom(DrvZ80ROM + 0x00000,	 4, 1)) return 1;
1787 	if (BurnLoadRom(DrvZ80ROM + 0x04000,	12, 1)) return 1;
1788 
1789 	if (BurnLoadRom(DrvGfxROM0,		 		 5, 1)) return 1;
1790 
1791 	if (BurnLoadRom(DrvGfxROM1 + 0x000000,	 6, 1)) return 1;
1792 	if (BurnLoadRom(DrvGfxROM1 + 0x018000,	 7, 1)) return 1;
1793 
1794 	if (BurnLoadRom(DrvGfxROM2,		 		 8, 1)) return 1;
1795 
1796 	if (BurnLoadRom(DrvGfxROM3 + 0x000000,	 9, 1)) return 1;
1797 	if (BurnLoadRom(DrvGfxROM3 + 0x020000,	10, 1)) return 1;
1798 
1799 	return 0;
1800 }
1801 
LegionInit()1802 static INT32 LegionInit()
1803 {
1804 	scroll_type = 3;
1805 	sprite_offy = 0;
1806 	irqline = 2;
1807 
1808 	INT32 nRet = DrvInit(LegionLoadRoms, Cclimbr268KInit, 0xc000);
1809 
1810 	if (nRet == 0) { // hack
1811 		if (BurnLoadRom(nb1414_blit_data,	11, 1)) return 1;
1812 		*((UINT16*)(Drv68KROM + 0x001d6)) = 0x0001;
1813 		*((UINT16*)(Drv68KROM + 0x00488)) = 0x4e71;
1814 	}
1815 
1816 	return nRet;
1817 }
1818 
1819 struct BurnDriver BurnDrvLegion = {
1820 	"legion", NULL, NULL, NULL, "1987",
1821 	"Legion - Spinner-87 (World ver 2.03)\0", NULL, "Nichibutsu", "Miscellaneous",
1822 	NULL, NULL, NULL, NULL,
1823 	BDF_GAME_WORKING | BDF_ORIENTATION_VERTICAL, 2, HARDWARE_MISC_PRE90S, GBF_VERSHOOT, 0,
1824 	NULL, legionRomInfo, legionRomName, NULL, NULL, NULL, NULL, ArmedfInputInfo, LegionDIPInfo,
1825 	LegionInit, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalc, 0x800,
1826 	224, 288, 3, 4
1827 };
1828 
1829 
1830 // Chouji Meikyuu Legion (Japan ver 1.05)
1831 
1832 static struct BurnRomInfo legionjRomDesc[] = {
1833 	{ "legion.e5",	0x10000, 0x49e8e1b7, 1 | BRF_PRG | BRF_ESS }, //  0 68k Code1
1834 	{ "legion.e1",	0x10000, 0x977fa324, 1 | BRF_PRG | BRF_ESS }, //  1
1835 	{ "legion.1d",	0x10000, 0xc2e45e1e, 1 | BRF_PRG | BRF_ESS }, //  2
1836 	{ "legion.1b",	0x10000, 0xc306660a, 1 | BRF_PRG | BRF_ESS }, //  3
1837 
1838 	{ "legion.1h",	0x04000, 0x2ca4f7f0, 2 | BRF_PRG | BRF_ESS }, //  4 Z80 code
1839 
1840 	{ "legion.1g",	0x08000, 0xc50b0125, 3 | BRF_GRA },           //  5 Characters
1841 
1842 	{ "legion.1e",	0x10000, 0xa9d70faf, 4 | BRF_GRA },           //  6 Foreground Tiles
1843 	{ "legion.1f",	0x08000, 0xf018313b, 4 | BRF_GRA },           //  7
1844 
1845 	{ "legion.1l",	0x10000, 0x29b8adaa, 5 | BRF_GRA },           //  8 Background Tiles
1846 
1847 	{ "legion.1k",	0x10000, 0xff5a0db9, 6 | BRF_GRA },           //  9 Sprites
1848 	{ "legion.1j",	0x10000, 0xbae220c8, 6 | BRF_GRA },           // 10
1849 
1850 	{ "lg7.bin",	0x04000, 0x533e2b58, 7 | BRF_GRA },           // 11 MCU data
1851 
1852 	{ "legion.1i",	0x08000, 0x79f4a827, 2 | BRF_OPT },           // 12 Unknown
1853 };
1854 
1855 STD_ROM_PICK(legionj)
1856 STD_ROM_FN(legionj)
1857 
1858 struct BurnDriver BurnDrvLegionj = {
1859 	"legionj", "legion", NULL, NULL, "1987",
1860 	"Chouji Meikyuu Legion (Japan ver 1.05)\0", NULL, "Nichibutsu", "Miscellaneous",
1861 	NULL, NULL, NULL, NULL,
1862 	BDF_GAME_WORKING | BDF_CLONE | BDF_ORIENTATION_VERTICAL, 2, HARDWARE_MISC_PRE90S, GBF_VERSHOOT, 0,
1863 	NULL, legionjRomInfo, legionjRomName, NULL, NULL, NULL, NULL, ArmedfInputInfo, LegionDIPInfo,
1864 	LegionInit, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalc, 0x800,
1865 	224, 288, 3, 4
1866 };
1867 
1868 
1869 // Chouji Meikyuu Legion (Japan ver 1.05, bootleg)
1870 /* blitter protection removed */
1871 
1872 static struct BurnRomInfo legionjbRomDesc[] = {
1873 	{ "legion.1c",	0x10000, 0x21226660, 1 | BRF_PRG | BRF_ESS }, //  0 68k Code
1874 	{ "legion.1a",	0x10000, 0x8c0cda1d, 1 | BRF_PRG | BRF_ESS }, //  1
1875 	{ "legion.1d",	0x10000, 0xc2e45e1e, 1 | BRF_PRG | BRF_ESS }, //  2
1876 	{ "legion.1b",	0x10000, 0xc306660a, 1 | BRF_PRG | BRF_ESS }, //  3
1877 
1878 	{ "legion.1h",	0x04000, 0x2ca4f7f0, 2 | BRF_PRG | BRF_ESS }, //  4 Z80 code
1879 
1880 	{ "legion.1g",	0x08000, 0xc50b0125, 3 | BRF_GRA },           //  5 Characters
1881 
1882 	{ "legion.1e",	0x10000, 0xa9d70faf, 4 | BRF_GRA },           //  6 Foreground Tiles
1883 	{ "legion.1f",	0x08000, 0xf018313b, 4 | BRF_GRA },           //  7
1884 
1885 	{ "legion.1l",	0x10000, 0x29b8adaa, 5 | BRF_GRA },           //  8 Background Tiles
1886 
1887 	{ "legion.1k",	0x10000, 0xff5a0db9, 6 | BRF_GRA },           //  9 Sprites
1888 	{ "legion.1j",	0x10000, 0xbae220c8, 6 | BRF_GRA },           // 10
1889 
1890 	{ "legion.1i",	0x08000, 0x79f4a827, 0 | BRF_OPT },           // 11 Unknown
1891 };
1892 
1893 STD_ROM_PICK(legionjb)
STD_ROM_FN(legionjb)1894 STD_ROM_FN(legionjb)
1895 
1896 static INT32 LegionjbLoadRoms()
1897 {
1898 	if (BurnLoadRom(Drv68KROM + 0x000001,	 0, 2)) return 1;
1899 	if (BurnLoadRom(Drv68KROM + 0x000000,	 1, 2)) return 1;
1900 	if (BurnLoadRom(Drv68KROM + 0x020001,	 2, 2)) return 1;
1901 	if (BurnLoadRom(Drv68KROM + 0x020000,	 3, 2)) return 1;
1902 
1903 	if (BurnLoadRom(DrvZ80ROM + 0x00000,	 4, 1)) return 1;
1904 	if (BurnLoadRom(DrvZ80ROM + 0x04000,	11, 1)) return 1;
1905 
1906 	if (BurnLoadRom(DrvGfxROM0,		 		 5, 1)) return 1;
1907 
1908 	if (BurnLoadRom(DrvGfxROM1 + 0x000000,	 6, 1)) return 1;
1909 	if (BurnLoadRom(DrvGfxROM1 + 0x018000,	 7, 1)) return 1;
1910 
1911 	if (BurnLoadRom(DrvGfxROM2,		 		 8, 1)) return 1;
1912 
1913 	if (BurnLoadRom(DrvGfxROM3 + 0x000000,	 9, 1)) return 1;
1914 	if (BurnLoadRom(DrvGfxROM3 + 0x020000,	10, 1)) return 1;
1915 
1916 	return 0;
1917 }
1918 
LegionjbInit()1919 static INT32 LegionjbInit()
1920 {
1921 	scroll_type = 6;
1922 	sprite_offy = 0;
1923 	irqline = 2;
1924 
1925 	INT32 nRet = DrvInit(LegionjbLoadRoms, Cclimbr268KInit, 0xc000);
1926 
1927 	if (nRet == 0) { // hack
1928 		*((UINT16*)(Drv68KROM + 0x001d6)) = 0x0001;
1929 	}
1930 
1931 	return nRet;
1932 }
1933 
1934 struct BurnDriver BurnDrvLegionjb = {
1935 	"legionjb", "legion", NULL, NULL, "1987",
1936 	"Chouji Meikyuu Legion (Japan ver 1.05, bootleg)\0", NULL, "Nichibutsu", "Miscellaneous",
1937 	NULL, NULL, NULL, NULL,
1938 	BDF_GAME_WORKING | BDF_CLONE | BDF_ORIENTATION_VERTICAL, 2, HARDWARE_MISC_PRE90S, GBF_VERSHOOT, 0,
1939 	NULL, legionjbRomInfo, legionjbRomName, NULL, NULL, NULL, NULL, ArmedfInputInfo, LegionDIPInfo,
1940 	LegionjbInit, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalc, 0x800,
1941 	224, 288, 3, 4
1942 };
1943 
1944 
1945 // Terra Force
1946 
1947 static struct BurnRomInfo terrafRomDesc[] = {
1948 	{ "8.6e",		0x10000, 0xfd58fa06, 1 | BRF_PRG | BRF_ESS }, //  0 68k Code
1949 	{ "3.6h",		0x10000, 0x54823a7d, 1 | BRF_PRG | BRF_ESS }, //  1
1950 	{ "7.4e",		0x10000, 0xfde8de7e, 1 | BRF_PRG | BRF_ESS }, //  2
1951 	{ "2.4h",		0x10000, 0xdb987414, 1 | BRF_PRG | BRF_ESS }, //  3
1952 	{ "6.3e",		0x10000, 0xa5bb8c3b, 1 | BRF_PRG | BRF_ESS }, //  4
1953 	{ "1.3h",		0x10000, 0xd2de6d28, 1 | BRF_PRG | BRF_ESS }, //  5
1954 
1955 	{ "11.17k",		0x10000, 0x4407d475, 2 | BRF_PRG | BRF_ESS }, //  6 Z80 code
1956 
1957 	{ "9.11e",		0x08000, 0xbc6f7cbc, 3 | BRF_GRA },           //  7 Characters
1958 
1959 	{ "5.15h",		0x10000, 0x25d23dfd, 4 | BRF_GRA },           //  8 Foreground Tiles
1960 	{ "4.13h",		0x10000, 0xb9b0fe27, 4 | BRF_GRA },           //  9
1961 
1962 	{ "15.8a",		0x10000, 0x2144d8e0, 5 | BRF_GRA },           // 10 Background Tiles
1963 	{ "14.6a",		0x10000, 0x744f5c9e, 5 | BRF_GRA },           // 11
1964 
1965 	{ "12.7d",		0x10000, 0x2d1f2ceb, 6 | BRF_GRA },           // 12 Sprites
1966 	{ "13.9d",		0x10000, 0x1d2f92d6, 6 | BRF_GRA },           // 13
1967 
1968 	{ "10.11c",		0x04000, 0xac705812, 7 | BRF_GRA }, // 14 MCU data
1969 
1970 	{ "n82s129an.11j",	0x00100, 0x81244757, 8 | BRF_OPT },           // 15 Proms
1971 };
1972 
1973 STD_ROM_PICK(terraf)
STD_ROM_FN(terraf)1974 STD_ROM_FN(terraf)
1975 
1976 static INT32 TerrafInit()
1977 {
1978 	scroll_type = 5;
1979 	sprite_offy = 128;
1980 	irqline = 1;
1981 
1982 	INT32 nRet = DrvInit(ArmedfLoadRoms, Cclimbr268KInit, 0xf800);
1983 
1984 	if (nRet == 0) {
1985 		if (BurnLoadRom(nb1414_blit_data,	14, 1)) return 1;
1986 
1987 		DACSetRoute(0, 0.30, BURN_SND_ROUTE_BOTH);
1988 		DACSetRoute(1, 0.30, BURN_SND_ROUTE_BOTH);
1989 		BurnSetRefreshRate(57.00);
1990 		fiftysevenhertz = 1;
1991 	}
1992 
1993 	return nRet;
1994 }
1995 
1996 struct BurnDriver BurnDrvTerraf = {
1997 	"terraf", NULL, NULL, NULL, "1987",
1998 	"Terra Force\0", NULL, "Nichibutsu", "Miscellaneous",
1999 	NULL, NULL, NULL, NULL,
2000 	BDF_GAME_WORKING, 2, HARDWARE_MISC_PRE90S, GBF_HORSHOOT, 0,
2001 	NULL, terrafRomInfo, terrafRomName, NULL, NULL, NULL, NULL, ArmedfInputInfo, TerrafDIPInfo,
2002 	TerrafInit, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalc, 0x800,
2003 	320, 240, 4, 3
2004 };
2005 
2006 
2007 // Terra Force (US)
2008 
2009 static struct BurnRomInfo terrafuRomDesc[] = {
2010 	{ "tf-8.6e",	0x10000, 0xfea6dd64, 1 | BRF_PRG | BRF_ESS }, //  0 68k Code
2011 	{ "tf-3.6h",	0x10000, 0x02f9d05a, 1 | BRF_PRG | BRF_ESS }, //  1
2012 	{ "tf-7.4e",	0x10000, 0xfde8de7e, 1 | BRF_PRG | BRF_ESS }, //  2
2013 	{ "tf-2.4h",	0x10000, 0xdb987414, 1 | BRF_PRG | BRF_ESS }, //  3
2014 	{ "tf-6.3e",	0x08000, 0xb91e9ba3, 1 | BRF_PRG | BRF_ESS }, //  4
2015 	{ "tf-1.3h",	0x08000, 0xd6e22375, 1 | BRF_PRG | BRF_ESS }, //  5
2016 
2017 	{ "tf-001.17k",	0x10000, 0xeb6b4138, 2 | BRF_PRG | BRF_ESS }, //  6 Z80 code
2018 
2019 	{ "9.11e",		0x08000, 0xbc6f7cbc, 3 | BRF_GRA },           //  7 Characters
2020 
2021 	{ "5.15h",		0x10000, 0x25d23dfd, 4 | BRF_GRA },           //  8 Foreground Tiles
2022 	{ "4.13h",		0x10000, 0xb9b0fe27, 4 | BRF_GRA },           //  9
2023 
2024 	{ "15.8a",		0x10000, 0x2144d8e0, 5 | BRF_GRA },           // 10 Background Tiles
2025 	{ "14.6a",		0x10000, 0x744f5c9e, 5 | BRF_GRA },           // 11
2026 
2027 	{ "tf-003.7d",	0x10000, 0xd74085a1, 6 | BRF_GRA },           // 12 Sprites
2028 	{ "tf-002.9d",	0x10000, 0x148aa0c5, 6 | BRF_GRA },           // 13
2029 
2030 	{ "10.11c",		0x04000, 0xac705812, 7 | BRF_GRA }, // 14 MCU data
2031 
2032 	{ "n82s129an.11j",	0x00100, 0x81244757, 8 | BRF_OPT },           // 15 Proms
2033 };
2034 
2035 STD_ROM_PICK(terrafu)
STD_ROM_FN(terrafu)2036 STD_ROM_FN(terrafu)
2037 
2038 static INT32 TerrafbInit()
2039 {
2040 	scroll_type = 5;
2041 	sprite_offy = 128;
2042 	irqline = 1;
2043 
2044 	INT32 nRet = DrvInit(ArmedfLoadRoms, Cclimbr268KInit, 0xf800);
2045 
2046 	if (nRet == 0) {
2047 		DACSetRoute(0, 0.80, BURN_SND_ROUTE_BOTH);
2048 		DACSetRoute(1, 0.80, BURN_SND_ROUTE_BOTH);
2049 	}
2050 
2051 	return nRet;
2052 }
2053 
2054 struct BurnDriver BurnDrvTerrafu = {
2055 	"terrafu", "terraf", NULL, NULL, "1987",
2056 	"Terra Force (US)\0", NULL, "Nichibutsu USA", "Miscellaneous",
2057 	NULL, NULL, NULL, NULL,
2058 	BDF_GAME_WORKING | BDF_CLONE, 2, HARDWARE_MISC_PRE90S, GBF_HORSHOOT, 0,
2059 	NULL, terrafuRomInfo, terrafuRomName, NULL, NULL, NULL, NULL, ArmedfInputInfo, TerrafDIPInfo,
2060 	TerrafInit, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalc, 0x800,
2061 	320, 240, 4, 3
2062 };
2063 
2064 
2065 // Terra Force (Japan)
2066 
2067 static struct BurnRomInfo terrafjRomDesc[] = {
2068 	{ "tfj-8.bin",	0x10000, 0xb11a6fa7, 1 | BRF_PRG | BRF_ESS }, //  0 68k Code
2069 	{ "tfj-3.bin",	0x10000, 0x6c6aa7ed, 1 | BRF_PRG | BRF_ESS }, //  1
2070 	{ "tfj-7.bin",	0x10000, 0xfde8de7e, 1 | BRF_PRG | BRF_ESS }, //  2
2071 	{ "tfj-2.bin",	0x10000, 0xdb987414, 1 | BRF_PRG | BRF_ESS }, //  3
2072 	{ "tfj-6.bin",	0x10000, 0x4911dfbf, 1 | BRF_PRG | BRF_ESS }, //  4
2073 	{ "tfj-1.bin",	0x10000, 0x93063d9a, 1 | BRF_PRG | BRF_ESS }, //  5
2074 
2075 	{ "11.17k",		0x10000, 0x4407d475, 2 | BRF_PRG | BRF_ESS }, //  6 Z80 code
2076 
2077 	{ "9.11e",		0x08000, 0xbc6f7cbc, 3 | BRF_GRA },           //  7 Characters
2078 
2079 	{ "5.15h",		0x10000, 0x25d23dfd, 4 | BRF_GRA },           //  8 Foreground Tiles
2080 	{ "4.13h",		0x10000, 0xb9b0fe27, 4 | BRF_GRA },           //  9
2081 
2082 	{ "15.8a",		0x10000, 0x2144d8e0, 5 | BRF_GRA },           // 10 Background Tiles
2083 	{ "14.6a",		0x10000, 0x744f5c9e, 5 | BRF_GRA },           // 11
2084 
2085 	{ "tfj-12.7d",	0x10000, 0xd74085a1, 6 | BRF_GRA },           // 12 Sprites
2086 	{ "tfj-13.9d",	0x10000, 0x148aa0c5, 6 | BRF_GRA },           // 13
2087 
2088 	{ "10.11c",		0x04000, 0xac705812, 7 | BRF_GRA }, // 14 MCU data
2089 
2090 	{ "n82s129an.11j",	0x00100, 0x81244757, 8 | BRF_OPT },           // 15 Proms
2091 };
2092 
2093 STD_ROM_PICK(terrafj)
2094 STD_ROM_FN(terrafj)
2095 
2096 struct BurnDriver BurnDrvTerrafj = {
2097 	"terrafj", "terraf", NULL, NULL, "1987",
2098 	"Terra Force (Japan)\0", NULL, "Nichibutsu Japan", "Miscellaneous",
2099 	NULL, NULL, NULL, NULL,
2100 	BDF_GAME_WORKING | BDF_CLONE, 2, HARDWARE_MISC_PRE90S, GBF_HORSHOOT, 0,
2101 	NULL, terrafjRomInfo, terrafjRomName, NULL, NULL, NULL, NULL, ArmedfInputInfo, TerrafDIPInfo,
2102 	TerrafInit, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalc, 0x800,
2103 	320, 240, 4, 3
2104 };
2105 
2106 
2107 // Terra Force (Japan, bootleg with additional Z80)
2108 
2109 static struct BurnRomInfo terrafjbRomDesc[] = {
2110 	{ "tfj-8.bin",		0x10000, 0xb11a6fa7, 1 | BRF_PRG | BRF_ESS }, //  0 68k Code
2111 	{ "tfj-3.bin",		0x10000, 0x6c6aa7ed, 1 | BRF_PRG | BRF_ESS }, //  1
2112 	{ "tfj-7.bin",		0x10000, 0xfde8de7e, 1 | BRF_PRG | BRF_ESS }, //  2
2113 	{ "tfj-2.bin",		0x10000, 0xdb987414, 1 | BRF_PRG | BRF_ESS }, //  3
2114 	{ "tfb-6.bin",		0x08000, 0x552c3c63, 1 | BRF_PRG | BRF_ESS }, //  4
2115 	{ "tfb-1.bin",		0x08000, 0x6a0b94c7, 1 | BRF_PRG | BRF_ESS }, //  5
2116 
2117 	{ "tf-001.17k",		0x10000, 0xeb6b4138, 2 | BRF_PRG | BRF_ESS }, //  6 Z80 Code
2118 
2119 	{ "tfb-10.bin",		0x04000, 0x3f9aa367, 9 | BRF_PRG | BRF_ESS }, //  7 Z80 Code (Mcu replacement)
2120 
2121 	{ "9.11e",		0x08000, 0xbc6f7cbc, 3 | BRF_GRA },           //  8 Characters
2122 
2123 	{ "5.15h",		0x10000, 0x25d23dfd, 4 | BRF_GRA },           //  9 Foreground Tiles
2124 	{ "4.13h",		0x10000, 0xb9b0fe27, 4 | BRF_GRA },           // 10
2125 
2126 	{ "15.8a",		0x10000, 0x2144d8e0, 5 | BRF_GRA },           // 11 Background Tiles
2127 	{ "14.6a",		0x10000, 0x744f5c9e, 5 | BRF_GRA },           // 12
2128 
2129 	{ "tfj-12.7d",		0x10000, 0xd74085a1, 6 | BRF_GRA | BRF_OPT }, // 13 Sprites
2130 	{ "tfj-13.9d",		0x10000, 0x148aa0c5, 6 | BRF_GRA | BRF_OPT }, // 14
2131 
2132 	{ "n82s129an.11j",	0x00100, 0x81244757, 7 | BRF_OPT },           // 15 proms
2133 };
2134 
2135 STD_ROM_PICK(terrafjb)
STD_ROM_FN(terrafjb)2136 STD_ROM_FN(terrafjb)
2137 
2138 static INT32 TerrafjbLoadRoms()
2139 {
2140 	if (BurnLoadRom(Drv68KROM + 0x000001,	 0, 2)) return 1;
2141 	if (BurnLoadRom(Drv68KROM + 0x000000,	 1, 2)) return 1;
2142 	if (BurnLoadRom(Drv68KROM + 0x020001,	 2, 2)) return 1;
2143 	if (BurnLoadRom(Drv68KROM + 0x020000,	 3, 2)) return 1;
2144 	if (BurnLoadRom(Drv68KROM + 0x040001,	 4, 2)) return 1;
2145 	if (BurnLoadRom(Drv68KROM + 0x040000,	 5, 2)) return 1;
2146 
2147 	if (BurnLoadRom(DrvZ80ROM,		 6, 1)) return 1;
2148 
2149 	if (BurnLoadRom(DrvZ80ROM2,		 7, 1)) return 1;
2150 
2151 	if (BurnLoadRom(DrvGfxROM0,		 8, 1)) return 1;
2152 
2153 	if (BurnLoadRom(DrvGfxROM1 + 0x000000,	 9, 1)) return 1;
2154 	if (BurnLoadRom(DrvGfxROM1 + 0x010000,	10, 1)) return 1;
2155 
2156 	if (BurnLoadRom(DrvGfxROM2 + 0x000000,	11, 1)) return 1;
2157 	if (BurnLoadRom(DrvGfxROM2 + 0x010000,	12, 1)) return 1;
2158 
2159 	if (BurnLoadRom(DrvGfxROM3 + 0x000000,	13, 1)) return 1;
2160 	if (BurnLoadRom(DrvGfxROM3 + 0x020000,	14, 1)) return 1;
2161 
2162 	return 0;
2163 }
2164 
TerrafjbInit()2165 static INT32 TerrafjbInit()
2166 {
2167 	scroll_type = 5;
2168 	sprite_offy = 128;
2169 	irqline = 1;
2170 
2171 	Terrafjb = 1;
2172 
2173 	INT32 nRet = DrvInit(TerrafjbLoadRoms, Cclimbr268KInit, 0xf800);
2174 
2175 	if (nRet == 0) {
2176 		DACSetRoute(0, 0.80, BURN_SND_ROUTE_BOTH);
2177 		DACSetRoute(1, 0.80, BURN_SND_ROUTE_BOTH);
2178 	}
2179 
2180 	return nRet;
2181 }
2182 
2183 struct BurnDriver BurnDrvTerrafjb = {
2184 	"terrafjb", "terraf", NULL, NULL, "1987",
2185 	"Terra Force (Japan, bootleg with additional Z80)\0", "imperfect graphics", "bootleg", "Miscellaneous",
2186 	NULL, NULL, NULL, NULL,
2187 	BDF_GAME_WORKING | BDF_CLONE, 2, HARDWARE_MISC_PRE90S, GBF_HORSHOOT, 0,
2188 	NULL, terrafjbRomInfo, terrafjbRomName, NULL, NULL, NULL, NULL, ArmedfInputInfo, TerrafDIPInfo,
2189 	TerrafjbInit, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalc, 0x800,
2190 	320, 240, 4, 3
2191 };
2192 
2193 
2194 // Terra Force (Japan, bootleg set 2)
2195 
2196 static struct BurnRomInfo terrafbRomDesc[] = {
2197 	{ "f-14.4s",		0x10000, 0x8e5f557f, 1 | BRF_PRG | BRF_ESS }, //  0 68k Code
2198 	{ "f-11.3s",		0x10000, 0x5320162a, 1 | BRF_PRG | BRF_ESS }, //  1
2199 	{ "f-13.4p",		0x10000, 0xa86951e0, 1 | BRF_PRG | BRF_ESS }, //  2
2200 	{ "f-9.3p",			0x10000, 0x58b5f43b, 1 | BRF_PRG | BRF_ESS }, //  3
2201 	{ "f-12.4m",		0x08000, 0x4f0e1d76, 1 | BRF_PRG | BRF_ESS }, //  4
2202 	{ "f-8.3m",			0x08000, 0xd1014280, 1 | BRF_PRG | BRF_ESS }, //  5
2203 
2204 	{ "f-1.1a",			0x10000, 0xeb6b4138, 2 | BRF_PRG | BRF_ESS }, //  6 Z80 code
2205 
2206 	{ "f-11.4g",		0x08000, 0xbc6f7cbc, 3 | BRF_GRA },           //  7 Characters
2207 
2208 	{ "f-6.3c",			0x10000, 0x25d23dfd, 4 | BRF_GRA },           //  8 Foreground Tiles
2209 	{ "f-7.3e",			0x10000, 0xb9b0fe27, 4 | BRF_GRA },           //  9
2210 
2211 	{ "f-4.9k",			0x10000, 0x2144d8e0, 5 | BRF_GRA },           // 10 Background Tiles
2212 	{ "f-5.9m",			0x10000, 0x744f5c9e, 5 | BRF_GRA },           // 11
2213 
2214 	{ "f-3.6l",			0x10000, 0xd74085a1, 6 | BRF_GRA },           // 12 Sprites
2215 	{ "f-2.6j",			0x10000, 0x148aa0c5, 6 | BRF_GRA },           // 13
2216 };
2217 
2218 STD_ROM_PICK(terrafb)
2219 STD_ROM_FN(terrafb)
2220 
2221 struct BurnDriver BurnDrvTerrafb = {
2222 	"terrafb", "terraf", NULL, NULL, "1987",
2223 	"Terra Force (Japan, bootleg set 2)\0", "imperfect graphics", "bootleg", "Miscellaneous",
2224 	NULL, NULL, NULL, NULL,
2225 	BDF_GAME_WORKING | BDF_CLONE | BDF_BOOTLEG, 2, HARDWARE_MISC_PRE90S, GBF_HORSHOOT, 0,
2226 	NULL, terrafbRomInfo, terrafbRomName, NULL, NULL, NULL, NULL, ArmedfInputInfo, TerrafDIPInfo,
2227 	TerrafbInit, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalc, 0x800,
2228 	320, 240, 4, 3
2229 };
2230 
SkyroboLoadRoms()2231 static INT32 SkyroboLoadRoms()
2232 {
2233 	if (BurnLoadRom(Drv68KROM + 0x000001,	 0, 2)) return 1;
2234 	if (BurnLoadRom(Drv68KROM + 0x000000,	 1, 2)) return 1;
2235 	if (BurnLoadRom(Drv68KROM + 0x040001,	 2, 2)) return 1;
2236 	if (BurnLoadRom(Drv68KROM + 0x040000,	 3, 2)) return 1;
2237 
2238 	if (BurnLoadRom(DrvZ80ROM,		 4, 1)) return 1;
2239 
2240 	if (BurnLoadRom(DrvZ80ROM2,		 5, 1)) return 1;
2241 
2242 	if (BurnLoadRom(DrvGfxROM0,		 6, 1)) return 1;
2243 
2244 	if (BurnLoadRom(DrvGfxROM1 + 0x000000,	 7, 1)) return 1;
2245 	if (BurnLoadRom(DrvGfxROM1 + 0x020000,	 8, 1)) return 1;
2246 
2247 	if (BurnLoadRom(DrvGfxROM2 + 0x000000,	 9, 1)) return 1;
2248 	if (BurnLoadRom(DrvGfxROM2 + 0x010000,	10, 1)) return 1;
2249 
2250 	if (BurnLoadRom(DrvGfxROM3 + 0x000000,	11, 1)) return 1;
2251 	if (BurnLoadRom(DrvGfxROM3 + 0x020000,	12, 1)) return 1;
2252 
2253 	return 0;
2254 }
2255 
SkyRoboInit()2256 static INT32 SkyRoboInit()
2257 {
2258 	scroll_type = 1;
2259 	sprite_offy = 128;
2260 	irqline = 1;
2261 
2262 	Skyrobo = 1;
2263 
2264 	INT32 nRet = DrvInit(SkyroboLoadRoms, Bigfghtr68KInit, 0xf800);
2265 
2266 	if (nRet == 0) {
2267 		DACSetRoute(0, 0.80, BURN_SND_ROUTE_BOTH);
2268 		DACSetRoute(1, 0.80, BURN_SND_ROUTE_BOTH);
2269 	}
2270 
2271 	return nRet;
2272 }
2273 
2274 
2275 // Sky Robo
2276 
2277 static struct BurnRomInfo skyroboRomDesc[] = {
2278 	{ "3",		0x20000, 0x02d8ba9f, 1 | BRF_PRG | BRF_ESS }, //  0 maincpu
2279 	{ "1",		0x20000, 0xfcfd9e2e, 1 | BRF_PRG | BRF_ESS }, //  1
2280 	{ "4",		0x20000, 0x37ced4b7, 1 | BRF_PRG | BRF_ESS }, //  2
2281 	{ "2",		0x20000, 0x88d52f8e, 1 | BRF_PRG | BRF_ESS }, //  3
2282 
2283 	{ "8.17k",	0x10000, 0x0aeab61e, 2 | BRF_PRG | BRF_ESS }, //  4 audiocpu
2284 
2285 	{ "i8751.bin",	0x01000, 0x64a0d225, 3 | BRF_PRG | BRF_ESS }, //  5 mcu
2286 
2287 	{ "7",		0x08000, 0xf556ef28, 4 | BRF_GRA },           //  6 gfx1
2288 
2289 	{ "5.13f",	0x20000, 0xd440a29f, 5 | BRF_GRA },           //  7 gfx2
2290 	{ "6.15f",	0x10000, 0x27469a76, 5 | BRF_GRA },           //  8
2291 
2292 	{ "12.8a",	0x10000, 0xa5694ea9, 6 | BRF_GRA },           //  9 gfx3
2293 	{ "11.6a",	0x10000, 0x10b74e2c, 6 | BRF_GRA },           // 10
2294 
2295 	{ "9.8d",	0x20000, 0xfe67800e, 7 | BRF_GRA },           // 11 gfx4
2296 	{ "10.9d",	0x20000, 0xdcb828c4, 7 | BRF_GRA },           // 12
2297 
2298 	{ "tf.13h",	0x00100, 0x81244757, 8 | BRF_GRA },           // 13 proms
2299 };
2300 
2301 STD_ROM_PICK(skyrobo)
2302 STD_ROM_FN(skyrobo)
2303 
2304 struct BurnDriver BurnDrvSkyrobo = {
2305 	"skyrobo", NULL, NULL, NULL, "1989",
2306 	"Sky Robo\0", NULL, "Nichibutsu", "Miscellaneous",
2307 	NULL, NULL, NULL, NULL,
2308 	BDF_GAME_WORKING, 2, HARDWARE_MISC_PRE90S, GBF_HORSHOOT, 0,
2309 	NULL, skyroboRomInfo, skyroboRomName, NULL, NULL, NULL, NULL, BigfghtrInputInfo, BigfghtrDIPInfo,
2310 	SkyRoboInit, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalc, 0x800,
2311 	320, 240, 4, 3
2312 };
2313 
2314 
2315 // Tatakae! Big Fighter (Japan)
2316 
2317 static struct BurnRomInfo bigfghtrRomDesc[] = {
2318 	{ "3.ic3",	0x20000, 0xe1e1f291, 1 | BRF_PRG | BRF_ESS }, //  0 maincpu
2319 	{ "1.ic2",	0x20000, 0x1100d991, 1 | BRF_PRG | BRF_ESS }, //  1
2320 	{ "4.ic5",	0x20000, 0x2464a83b, 1 | BRF_PRG | BRF_ESS }, //  2
2321 	{ "2.ic4",	0x20000, 0xb47bbcd5, 1 | BRF_PRG | BRF_ESS }, //  3
2322 
2323 	{ "8.17k",	0x10000, 0x0aeab61e, 2 | BRF_PRG | BRF_ESS }, //  4 audiocpu
2324 
2325 	{ "i8751.bin",	0x01000, 0x64a0d225, 3 | BRF_PRG | BRF_ESS }, //  5 mcu
2326 
2327 	{ "7.11c",	0x08000, 0x1809e79f, 4 | BRF_GRA },           //  6 gfx1
2328 
2329 	{ "5.13f",	0x20000, 0xd440a29f, 5 | BRF_GRA },           //  7 gfx2
2330 	{ "6.15f",	0x10000, 0x27469a76, 5 | BRF_GRA },           //  8
2331 
2332 	{ "12.8a",	0x10000, 0xa5694ea9, 6 | BRF_GRA },           //  9 gfx3
2333 	{ "11.6a",	0x10000, 0x10b74e2c, 6 | BRF_GRA },           // 10
2334 
2335 	{ "9.8d",	0x20000, 0xfe67800e, 7 | BRF_GRA },           // 11 gfx4
2336 	{ "10.9d",	0x20000, 0xdcb828c4, 7 | BRF_GRA },           // 12
2337 
2338 	{ "tf.13h",	0x00100, 0x81244757, 8 | BRF_GRA },           // 13 proms
2339 };
2340 
2341 STD_ROM_PICK(bigfghtr)
2342 STD_ROM_FN(bigfghtr)
2343 
2344 struct BurnDriver BurnDrvBigfghtr = {
2345 	"bigfghtr", "skyrobo", NULL, NULL, "1989",
2346 	"Tatakae! Big Fighter (Japan)\0", NULL, "Nichibutsu", "Miscellaneous",
2347 	NULL, NULL, NULL, NULL,
2348 	BDF_GAME_WORKING | BDF_CLONE, 2, HARDWARE_MISC_PRE90S, GBF_HORSHOOT, 0,
2349 	NULL, bigfghtrRomInfo, bigfghtrRomName, NULL, NULL, NULL, NULL, BigfghtrInputInfo, BigfghtrDIPInfo,
2350 	SkyRoboInit, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalc, 0x800,
2351 	320, 240, 4, 3
2352 };
2353