1 // Based on MAME driver by Mike Balfour
2 
3 #include "tiles_generic.h"
4 #include "z80_intf.h"
5 #include "burn_ym2151.h"
6 #include "burn_ym2203.h"
7 #include "dac.h"
8 
9 static UINT8 DrvInputPort0[8] = {0, 0, 0, 0, 0, 0, 0, 0};
10 static UINT8 DrvInputPort1[8] = {0, 0, 0, 0, 0, 0, 0, 0};
11 static UINT8 DrvInputPort2[8] = {0, 0, 0, 0, 0, 0, 0, 0};
12 static UINT8 DrvDip[3]        = {0, 0, 0};
13 static UINT8 DrvInput[3]      = {0x00, 0x00, 0x00};
14 static UINT8 DrvReset         = 0;
15 
16 static UINT8 *Mem                 = NULL;
17 static UINT8 *MemEnd              = NULL;
18 static UINT8 *RamStart            = NULL;
19 static UINT8 *RamEnd              = NULL;
20 static UINT8 *DrvZ80Rom1          = NULL;
21 static UINT8 *DrvZ80Rom2          = NULL;
22 static UINT8 *DrvZ80Ram1          = NULL;
23 static UINT8 *DrvZ80Ram2          = NULL;
24 static UINT8 *DrvVideoRam         = NULL;
25 static UINT8 *DrvSpriteRam        = NULL;
26 static UINT8 *DrvPaletteRam       = NULL;
27 static UINT8 *DrvChars            = NULL;
28 static UINT8 *DrvBackTiles        = NULL;
29 static UINT8 *DrvSprites          = NULL;
30 static UINT8 *DrvSamples          = NULL;
31 static UINT8 *DrvTempRom          = NULL;
32 static UINT32 *DrvPalette         = NULL;
33 
34 static UINT8 DrvRomBank;
35 static UINT8 DrvSoundLatch;
36 static UINT8 DrvIrqVector;
37 
38 static INT32 DrvRearColour;
39 static INT32 DrvRearDisable;
40 static INT32 DrvHorizScrollLo;
41 static INT32 DrvHorizScrollHi;
42 static INT32 DrvRearHorizScrollLo;
43 static INT32 DrvRearHorizScrollHi;
44 static INT32 DrvSampleAddress;
45 
46 static INT32 nCyclesDone[2], nCyclesTotal[2];
47 
48 static UINT8 DrvHasYM2203 = 0;
49 static UINT8 DrvKikcubicDraw = 0;
50 
51 #define VECTOR_INIT		0
52 #define YM2151_ASSERT	1
53 #define YM2151_CLEAR	2
54 #define Z80_ASSERT		3
55 #define Z80_CLEAR		4
56 
57 static struct BurnInputInfo DrvInputList[] =
58 {
59 	{"Coin 1"            , BIT_DIGITAL  , DrvInputPort0 + 3, "p1 coin"   },
60 	{"Start 1"           , BIT_DIGITAL  , DrvInputPort0 + 0, "p1 start"  },
61 	{"Coin 2"            , BIT_DIGITAL  , DrvInputPort2 + 4, "p2 coin"   },
62 	{"Start 2"           , BIT_DIGITAL  , DrvInputPort0 + 1, "p2 start"  },
63 
64 	{"Up"                , BIT_DIGITAL  , DrvInputPort1 + 3, "p1 up"     },
65 	{"Down"              , BIT_DIGITAL  , DrvInputPort1 + 2, "p1 down"   },
66 	{"Left"              , BIT_DIGITAL  , DrvInputPort1 + 1, "p1 left"   },
67 	{"Right"             , BIT_DIGITAL  , DrvInputPort1 + 0, "p1 right"  },
68 	{"Fire 1"            , BIT_DIGITAL  , DrvInputPort1 + 5, "p1 fire 1" },
69 	{"Fire 2"            , BIT_DIGITAL  , DrvInputPort1 + 7, "p1 fire 2" },
70 
71 	{"Up (Cocktail)"     , BIT_DIGITAL  , DrvInputPort2 + 3, "p2 up"     },
72 	{"Down (Cocktail)"   , BIT_DIGITAL  , DrvInputPort2 + 2, "p2 down"   },
73 	{"Left (Cocktail)"   , BIT_DIGITAL  , DrvInputPort2 + 1, "p2 left"   },
74 	{"Right (Cocktail)"  , BIT_DIGITAL  , DrvInputPort2 + 0, "p2 right"  },
75 	{"Fire 1 (Cocktail)" , BIT_DIGITAL  , DrvInputPort2 + 5, "p2 fire 1" },
76 	{"Fire 2 (Cocktail)" , BIT_DIGITAL  , DrvInputPort2 + 7, "p2 fire 2" },
77 
78 	{"Reset"             , BIT_DIGITAL  , &DrvReset        , "reset"     },
79 	{"Service"           , BIT_DIGITAL  , DrvInputPort0 + 2, "service"   },
80 	{"Dip 1"             , BIT_DIPSWITCH, DrvDip + 0       , "dip"       },
81 	{"Dip 2"             , BIT_DIPSWITCH, DrvDip + 1       , "dip"       },
82 };
83 
84 STDINPUTINFO(Drv)
85 
86 static struct BurnInputInfo BuccanrsInputList[] =
87 {
88 	{"Coin 1"            , BIT_DIGITAL  , DrvInputPort0 + 4, "p1 coin"   },
89 	{"Start 1"           , BIT_DIGITAL  , DrvInputPort0 + 7, "p1 start"  },
90 	{"Coin 2"            , BIT_DIGITAL  , DrvInputPort2 + 4, "p2 coin"   },
91 	{"Start 2"           , BIT_DIGITAL  , DrvInputPort0 + 6, "p2 start"  },
92 
93 	{"Up"                , BIT_DIGITAL  , DrvInputPort1 + 3, "p1 up"     },
94 	{"Down"              , BIT_DIGITAL  , DrvInputPort1 + 2, "p1 down"   },
95 	{"Left"              , BIT_DIGITAL  , DrvInputPort1 + 1, "p1 left"   },
96 	{"Right"             , BIT_DIGITAL  , DrvInputPort1 + 0, "p1 right"  },
97 	{"Fire 1"            , BIT_DIGITAL  , DrvInputPort1 + 7, "p1 fire 1" },
98 	{"Fire 2"            , BIT_DIGITAL  , DrvInputPort1 + 5, "p1 fire 2" },
99 
100 	{"Up (Cocktail)"     , BIT_DIGITAL  , DrvInputPort2 + 3, "p2 up"     },
101 	{"Down (Cocktail)"   , BIT_DIGITAL  , DrvInputPort2 + 2, "p2 down"   },
102 	{"Left (Cocktail)"   , BIT_DIGITAL  , DrvInputPort2 + 1, "p2 left"   },
103 	{"Right (Cocktail)"  , BIT_DIGITAL  , DrvInputPort2 + 0, "p2 right"  },
104 	{"Fire 1 (Cocktail)" , BIT_DIGITAL  , DrvInputPort2 + 7, "p2 fire 1" },
105 	{"Fire 2 (Cocktail)" , BIT_DIGITAL  , DrvInputPort2 + 5, "p2 fire 2" },
106 
107 	{"Reset"             , BIT_DIGITAL  , &DrvReset        , "reset"     },
108 	{"Dip 1"             , BIT_DIPSWITCH, DrvDip + 0       , "dip"       },
109 	{"Dip 2"             , BIT_DIPSWITCH, DrvDip + 1       , "dip"       },
110 	{"Dip 3"             , BIT_DIPSWITCH, DrvDip + 2       , "dip"       },
111 };
112 
113 STDINPUTINFO(Buccanrs)
114 
115 static struct BurnInputInfo BuccanrsaInputList[] =
116 {
117 	{"Coin 1"            , BIT_DIGITAL  , DrvInputPort0 + 3, "p1 coin"   },
118 	{"Start 1"           , BIT_DIGITAL  , DrvInputPort0 + 0, "p1 start"  },
119 	{"Coin 2"            , BIT_DIGITAL  , DrvInputPort2 + 4, "p2 coin"   },
120 	{"Start 2"           , BIT_DIGITAL  , DrvInputPort0 + 1, "p2 start"  },
121 
122 	{"Up"                , BIT_DIGITAL  , DrvInputPort1 + 3, "p1 up"     },
123 	{"Down"              , BIT_DIGITAL  , DrvInputPort1 + 2, "p1 down"   },
124 	{"Left"              , BIT_DIGITAL  , DrvInputPort1 + 1, "p1 left"   },
125 	{"Right"             , BIT_DIGITAL  , DrvInputPort1 + 0, "p1 right"  },
126 	{"Fire 1"            , BIT_DIGITAL  , DrvInputPort1 + 7, "p1 fire 1" },
127 	{"Fire 2"            , BIT_DIGITAL  , DrvInputPort1 + 5, "p1 fire 2" },
128 
129 	{"Up (Cocktail)"     , BIT_DIGITAL  , DrvInputPort2 + 3, "p2 up"     },
130 	{"Down (Cocktail)"   , BIT_DIGITAL  , DrvInputPort2 + 2, "p2 down"   },
131 	{"Left (Cocktail)"   , BIT_DIGITAL  , DrvInputPort2 + 1, "p2 left"   },
132 	{"Right (Cocktail)"  , BIT_DIGITAL  , DrvInputPort2 + 0, "p2 right"  },
133 	{"Fire 1 (Cocktail)" , BIT_DIGITAL  , DrvInputPort2 + 7, "p2 fire 1" },
134 	{"Fire 2 (Cocktail)" , BIT_DIGITAL  , DrvInputPort2 + 5, "p2 fire 2" },
135 
136 	{"Reset"             , BIT_DIGITAL  , &DrvReset        , "reset"     },
137 	{"Dip 1"             , BIT_DIPSWITCH, DrvDip + 0       , "dip"       },
138 	{"Dip 2"             , BIT_DIPSWITCH, DrvDip + 1       , "dip"       },
139 	{"Dip 3"             , BIT_DIPSWITCH, DrvDip + 2       , "dip"       },
140 };
141 
142 STDINPUTINFO(Buccanrsa)
143 
144 static struct BurnInputInfo KikcubicInputList[] =
145 {
146 	{"Coin 1"            , BIT_DIGITAL  , DrvInputPort0 + 4, "p1 coin"   },
147 	{"Start 1"           , BIT_DIGITAL  , DrvInputPort0 + 0, "p1 start"  },
148 	{"Coin 2"            , BIT_DIGITAL  , DrvInputPort0 + 5, "p2 coin"   },
149 	{"Start 2"           , BIT_DIGITAL  , DrvInputPort0 + 1, "p2 start"  },
150 
151 	{"Up"                , BIT_DIGITAL  , DrvInputPort1 + 3, "p1 up"     },
152 	{"Down"              , BIT_DIGITAL  , DrvInputPort1 + 2, "p1 down"   },
153 	{"Left"              , BIT_DIGITAL  , DrvInputPort1 + 1, "p1 left"   },
154 	{"Right"             , BIT_DIGITAL  , DrvInputPort1 + 0, "p1 right"  },
155 	{"Fire 1"            , BIT_DIGITAL  , DrvInputPort1 + 7, "p1 fire 1" },
156 	{"Fire 2"            , BIT_DIGITAL  , DrvInputPort1 + 5, "p1 fire 2" },
157 
158 	{"Up (Cocktail)"     , BIT_DIGITAL  , DrvInputPort2 + 3, "p2 up"     },
159 	{"Down (Cocktail)"   , BIT_DIGITAL  , DrvInputPort2 + 2, "p2 down"   },
160 	{"Left (Cocktail)"   , BIT_DIGITAL  , DrvInputPort2 + 1, "p2 left"   },
161 	{"Right (Cocktail)"  , BIT_DIGITAL  , DrvInputPort2 + 0, "p2 right"  },
162 	{"Fire 1 (Cocktail)" , BIT_DIGITAL  , DrvInputPort2 + 7, "p2 fire 1" },
163 	{"Fire 2 (Cocktail)" , BIT_DIGITAL  , DrvInputPort2 + 5, "p2 fire 2" },
164 
165 	{"Reset"             , BIT_DIGITAL  , &DrvReset        , "reset"     },
166 	{"Dip 1"             , BIT_DIPSWITCH, DrvDip + 0       , "dip"       },
167 	{"Dip 2"             , BIT_DIPSWITCH, DrvDip + 1       , "dip"       },
168 };
169 
STDINPUTINFO(Kikcubic)170 STDINPUTINFO(Kikcubic)
171 
172 static inline void DrvClearOpposites(UINT8* nJoystickInputs)
173 {
174 	if ((*nJoystickInputs & 0x03) == 0x03) {
175 		*nJoystickInputs &= ~0x03;
176 	}
177 	if ((*nJoystickInputs & 0x0c) == 0x0c) {
178 		*nJoystickInputs &= ~0x0c;
179 	}
180 }
181 
DrvMakeInputs()182 static inline void DrvMakeInputs()
183 {
184 	// Reset Inputs
185 	DrvInput[0] = DrvInput[1] = DrvInput[2] = 0x00;
186 
187 	// Compile Digital Inputs
188 	for (INT32 i = 0; i < 8; i++) {
189 		DrvInput[0] |= (DrvInputPort0[i] & 1) << i;
190 		DrvInput[1] |= (DrvInputPort1[i] & 1) << i;
191 		DrvInput[2] |= (DrvInputPort2[i] & 1) << i;
192 	}
193 
194 	// Clear Opposites
195 	DrvClearOpposites(&DrvInput[1]);
196 	DrvClearOpposites(&DrvInput[2]);
197 }
198 
199 static struct BurnDIPInfo DrvDIPList[]=
200 {
201 	// Default Values
202 	{0x12, 0xff, 0xff, 0xff, NULL                     },
203 	{0x13, 0xff, 0xff, 0xfd, NULL                     },
204 
205 	// Dip 1
206 	{0   , 0xfe, 0   , 4   , "Lives"                  },
207 	{0x12, 0x01, 0x03, 0x02, "2"                      },
208 	{0x12, 0x01, 0x03, 0x03, "3"                      },
209 	{0x12, 0x01, 0x03, 0x01, "4"                      },
210 	{0x12, 0x01, 0x03, 0x00, "5"                      },
211 
212 	{0   , 0xfe, 0   , 2   , "Difficulty"             },
213 	{0x12, 0x01, 0x04, 0x04, "Normal"                 },
214 	{0x12, 0x01, 0x04, 0x00, "Hard"                   },
215 
216 	{0   , 0xfe, 0   , 2   , "Energy Decrease Rate"   },
217 	{0x12, 0x01, 0x08, 0x08, "Slow"                   },
218 	{0x12, 0x01, 0x08, 0x00, "Fast"                   },
219 
220 	{0   , 0xfe, 0   , 16  , "Coinage"                },
221 	{0x12, 0x01, 0xf0, 0xa0, "6 Coins 1 Play"         },
222 	{0x12, 0x01, 0xf0, 0xb0, "5 Coins 1 Play"         },
223 	{0x12, 0x01, 0xf0, 0xc0, "4 Coins 1 Play"         },
224 	{0x12, 0x01, 0xf0, 0xd0, "3 Coins 1 Play"         },
225 	{0x12, 0x01, 0xf0, 0x10, "8 Coins 3 Plays"        },
226 	{0x12, 0x01, 0xf0, 0xe0, "2 Coins 1 Play"         },
227 	{0x12, 0x01, 0xf0, 0x20, "5 Coins 3 Plays"        },
228 	{0x12, 0x01, 0xf0, 0x30, "3 Coins 2 Plays"        },
229 	{0x12, 0x01, 0xf0, 0xf0, "1 Coin  1 Play"         },
230 	{0x12, 0x01, 0xf0, 0x40, "2 Coins 3 Plays"        },
231 	{0x12, 0x01, 0xf0, 0x90, "1 Coin  2 Plays"        },
232 	{0x12, 0x01, 0xf0, 0x80, "1 Coin  3 Plays"        },
233 	{0x12, 0x01, 0xf0, 0x70, "1 Coin  4 Plays"        },
234 	{0x12, 0x01, 0xf0, 0x60, "1 Coin  5 Plays"        },
235 	{0x12, 0x01, 0xf0, 0x50, "1 Coin  6 Plays"        },
236 	{0x12, 0x01, 0xf0, 0x00, "Freeplay"               },
237 
238 	// Dip 2
239 	{0   , 0xfe, 0   , 2   , "Flip Screen"            },
240 	{0x13, 0x01, 0x01, 0x01, "Off"                    },
241 	{0x13, 0x01, 0x01, 0x00, "On"                     },
242 
243 	{0   , 0xfe, 0   , 2   , "Cabinet"                },
244 	{0x13, 0x01, 0x02, 0x00, "Upright"                },
245 	{0x13, 0x01, 0x02, 0x02, "Cocktail"               },
246 
247 	{0   , 0xfe, 0   , 2   , "Coin Mode"              },
248 	{0x13, 0x01, 0x04, 0x04, "Mode 1"                 },
249 	{0x13, 0x01, 0x04, 0x00, "Mode 2"                 },
250 
251 	{0   , 0xfe, 0   , 2   , "Demo Sounds"            },
252 	{0x13, 0x01, 0x08, 0x00, "Off"                    },
253 	{0x13, 0x01, 0x08, 0x08, "On"                     },
254 
255 	{0   , 0xfe, 0   , 2   , "Allow Continue"         },
256 	{0x13, 0x01, 0x10, 0x00, "Off"                    },
257 	{0x13, 0x01, 0x10, 0x10, "On"                     },
258 
259 	{0   , 0xfe, 0   , 2   , "Stop Mode"              },
260 	{0x13, 0x01, 0x20, 0x20, "Off"                    },
261 	{0x13, 0x01, 0x20, 0x00, "On"                     },
262 
263 	{0   , 0xfe, 0   , 2   , "Invulnerability"        },
264 	{0x13, 0x01, 0x40, 0x40, "Off"                    },
265 	{0x13, 0x01, 0x40, 0x00, "On"                     },
266 };
267 
268 STDDIPINFO(Drv)
269 
270 static struct BurnDIPInfo BuccanrsDIPList[]=
271 {
272 	// Default Values
273 	{0x11, 0xff, 0xff, 0x2f, NULL                     },
274 	{0x12, 0xff, 0xff, 0xff, NULL                     },
275 	{0x13, 0xff, 0xff, 0x7f, NULL                     },
276 
277 	// Dip 1
278 	{0   , 0xfe, 0   , 2   , "Service Mode"           },
279 	{0x11, 0x01, 0x01, 0x01, "Off"                    },
280 	{0x11, 0x01, 0x01, 0x00, "On"                     },
281 
282 	// Dip 2
283 	{0   , 0xfe, 0   , 12  , "Coin A"                 },
284 	{0x12, 0x01, 0x0f, 0x04, "4 Coins 1 Play"         },
285 	{0x12, 0x01, 0x0f, 0x07, "3 Coins 1 Play"         },
286 	{0x12, 0x01, 0x0f, 0x00, "5 Coins 2 Plays"        },
287 	{0x12, 0x01, 0x0f, 0x0a, "2 Coins 1 Play"         },
288 	{0x12, 0x01, 0x0f, 0x06, "3 Coins 2 Plays"        },
289 	{0x12, 0x01, 0x0f, 0x03, "4 Coins 3 Plays"        },
290 	{0x12, 0x01, 0x0f, 0x0f, "1 Coin  1 Play"         },
291 	{0x12, 0x01, 0x0f, 0x05, "3 Coins 5 Plays"        },
292 	{0x12, 0x01, 0x0f, 0x0e, "1 Coin  2 Plays"        },
293 	{0x12, 0x01, 0x0f, 0x0d, "1 Coin  3 Plays"        },
294 	{0x12, 0x01, 0x0f, 0x0c, "1 Coin  4 Plays"        },
295 	{0x12, 0x01, 0x0f, 0x0b, "1 Coin  5 Plays"        },
296 
297 	{0   , 0xfe, 0   , 12  , "Coin B"                 },
298 	{0x12, 0x01, 0xf0, 0x40, "4 Coins 1 Play"         },
299 	{0x12, 0x01, 0xf0, 0x70, "3 Coins 1 Play"         },
300 	{0x12, 0x01, 0xf0, 0x00, "5 Coins 2 Plays"        },
301 	{0x12, 0x01, 0xf0, 0xa0, "2 Coins 1 Play"         },
302 	{0x12, 0x01, 0xf0, 0x60, "3 Coins 2 Plays"        },
303 	{0x12, 0x01, 0xf0, 0x30, "4 Coins 3 Plays"        },
304 	{0x12, 0x01, 0xf0, 0xf0, "1 Coin  1 Play"         },
305 	{0x12, 0x01, 0xf0, 0x50, "3 Coins 5 Plays"        },
306 	{0x12, 0x01, 0xf0, 0xe0, "1 Coin  2 Plays"        },
307 	{0x12, 0x01, 0xf0, 0xd0, "1 Coin  3 Plays"        },
308 	{0x12, 0x01, 0xf0, 0xc0, "1 Coin  4 Plays"        },
309 	{0x12, 0x01, 0xf0, 0xb0, "1 Coin  5 Plays"        },
310 
311 	// Dip 3
312 	{0   , 0xfe, 0   , 2   , "Flip Screen"            },
313 	{0x13, 0x01, 0x01, 0x01, "Off"                    },
314 	{0x13, 0x01, 0x01, 0x00, "On"                     },
315 
316 	{0   , 0xfe, 0   , 4   , "Lives"                  },
317 	{0x13, 0x01, 0x06, 0x06, "2"                      },
318 	{0x13, 0x01, 0x06, 0x04, "3"                      },
319 	{0x13, 0x01, 0x06, 0x02, "4"                      },
320 	{0x13, 0x01, 0x06, 0x00, "5"                      },
321 
322 	{0   , 0xfe, 0   , 4   , "Difficulty"             },
323 	{0x13, 0x01, 0x18, 0x18, "Normal"                 },
324 	{0x13, 0x01, 0x18, 0x08, "Medium"                 },
325 	{0x13, 0x01, 0x18, 0x10, "Hard"                   },
326 	{0x13, 0x01, 0x18, 0x00, "Invincibilty"           },
327 
328 	{0   , 0xfe, 0   , 2   , "Cabinet"                },
329 	{0x13, 0x01, 0x20, 0x20, "Upright"                },
330 	{0x13, 0x01, 0x20, 0x00, "Cocktail"               },
331 
332 	{0   , 0xfe, 0   , 2   , "Demo Sounds"            },
333 	{0x13, 0x01, 0x40, 0x00, "Off"                    },
334 	{0x13, 0x01, 0x40, 0x40, "On"                     },
335 
336 	{0   , 0xfe, 0   , 2   , "Allow Continue"         },
337 	{0x13, 0x01, 0x80, 0x80, "Off"                    },
338 	{0x13, 0x01, 0x80, 0x00, "On"                     },
339 };
340 
341 STDDIPINFO(Buccanrs)
342 
343 static struct BurnDIPInfo BuccanrsaDIPList[]=
344 {
345 	// Default Values
346 	{0x11, 0xff, 0xff, 0xf4, NULL                     },
347 	{0x12, 0xff, 0xff, 0xff, NULL                     },
348 	{0x13, 0xff, 0xff, 0x7f, NULL                     },
349 
350 	// Dip 1
351 	{0   , 0xfe, 0   , 2   , "Service Mode"           },
352 	{0x11, 0x01, 0xf4, 0xf4, "Off"                    },
353 	{0x11, 0x01, 0xf4, 0x00, "On"                     },
354 
355 	// Dip 2
356 	{0   , 0xfe, 0   , 12  , "Coin A"                 },
357 	{0x12, 0x01, 0x0f, 0x04, "4 Coins 1 Play"         },
358 	{0x12, 0x01, 0x0f, 0x07, "3 Coins 1 Play"         },
359 	{0x12, 0x01, 0x0f, 0x00, "5 Coins 2 Plays"        },
360 	{0x12, 0x01, 0x0f, 0x0a, "2 Coins 1 Play"         },
361 	{0x12, 0x01, 0x0f, 0x06, "3 Coins 2 Plays"        },
362 	{0x12, 0x01, 0x0f, 0x03, "4 Coins 3 Plays"        },
363 	{0x12, 0x01, 0x0f, 0x0f, "1 Coin  1 Play"         },
364 	{0x12, 0x01, 0x0f, 0x05, "3 Coins 5 Plays"        },
365 	{0x12, 0x01, 0x0f, 0x0e, "1 Coin  2 Plays"        },
366 	{0x12, 0x01, 0x0f, 0x0d, "1 Coin  3 Plays"        },
367 	{0x12, 0x01, 0x0f, 0x0c, "1 Coin  4 Plays"        },
368 	{0x12, 0x01, 0x0f, 0x0b, "1 Coin  5 Plays"        },
369 
370 	{0   , 0xfe, 0   , 12  , "Coin B"                 },
371 	{0x12, 0x01, 0xf0, 0x40, "4 Coins 1 Play"         },
372 	{0x12, 0x01, 0xf0, 0x70, "3 Coins 1 Play"         },
373 	{0x12, 0x01, 0xf0, 0x00, "5 Coins 2 Plays"        },
374 	{0x12, 0x01, 0xf0, 0xa0, "2 Coins 1 Play"         },
375 	{0x12, 0x01, 0xf0, 0x60, "3 Coins 2 Plays"        },
376 	{0x12, 0x01, 0xf0, 0x30, "4 Coins 3 Plays"        },
377 	{0x12, 0x01, 0xf0, 0xf0, "1 Coin  1 Play"         },
378 	{0x12, 0x01, 0xf0, 0x50, "3 Coins 5 Plays"        },
379 	{0x12, 0x01, 0xf0, 0xe0, "1 Coin  2 Plays"        },
380 	{0x12, 0x01, 0xf0, 0xd0, "1 Coin  3 Plays"        },
381 	{0x12, 0x01, 0xf0, 0xc0, "1 Coin  4 Plays"        },
382 	{0x12, 0x01, 0xf0, 0xb0, "1 Coin  5 Plays"        },
383 
384 	// Dip 3
385 	{0   , 0xfe, 0   , 2   , "Flip Screen"            },
386 	{0x13, 0x01, 0x01, 0x01, "Off"                    },
387 	{0x13, 0x01, 0x01, 0x00, "On"                     },
388 
389 	{0   , 0xfe, 0   , 4   , "Lives"                  },
390 	{0x13, 0x01, 0x06, 0x06, "2"                      },
391 	{0x13, 0x01, 0x06, 0x04, "3"                      },
392 	{0x13, 0x01, 0x06, 0x02, "4"                      },
393 	{0x13, 0x01, 0x06, 0x00, "5"                      },
394 
395 	{0   , 0xfe, 0   , 4   , "Difficulty"             },
396 	{0x13, 0x01, 0x18, 0x18, "Normal"                 },
397 	{0x13, 0x01, 0x18, 0x08, "Medium"                 },
398 	{0x13, 0x01, 0x18, 0x10, "Hard"                   },
399 	{0x13, 0x01, 0x18, 0x00, "Invincibilty"           },
400 
401 	{0   , 0xfe, 0   , 2   , "Cabinet"                },
402 	{0x13, 0x01, 0x20, 0x20, "Upright"                },
403 	{0x13, 0x01, 0x20, 0x00, "Cocktail"               },
404 
405 	{0   , 0xfe, 0   , 2   , "Demo Sounds"            },
406 	{0x13, 0x01, 0x40, 0x00, "Off"                    },
407 	{0x13, 0x01, 0x40, 0x40, "On"                     },
408 
409 	{0   , 0xfe, 0   , 2   , "Allow Continue"         },
410 	{0x13, 0x01, 0x80, 0x80, "Off"                    },
411 	{0x13, 0x01, 0x80, 0x00, "On"                     },
412 };
413 
414 STDDIPINFO(Buccanrsa)
415 
416 static struct BurnDIPInfo KikcubicDIPList[]=
417 {
418 	// Default Values
419 	{0x11, 0xff, 0xff, 0xff, NULL                     },
420 	{0x12, 0xff, 0xff, 0xd5, NULL                     },
421 
422 	// Dip 1
423 	{0   , 0xfe, 0   , 4   , "Difficulty"             },
424 	{0x11, 0x01, 0x03, 0x02, "Easy"                   },
425 	{0x11, 0x01, 0x03, 0x03, "Medium"                 },
426 	{0x11, 0x01, 0x03, 0x01, "Hard"                   },
427 	{0x11, 0x01, 0x03, 0x00, "Hardest"                },
428 
429 	{0   , 0xfe, 0   , 4   , "Lives"                  },
430 	{0x11, 0x01, 0x0c, 0x08, "1"                      },
431 	{0x11, 0x01, 0x0c, 0x04, "2"                      },
432 	{0x11, 0x01, 0x0c, 0x0c, "3"                      },
433 	{0x11, 0x01, 0x0c, 0x00, "4"                      },
434 
435 	{0   , 0xfe, 0   , 12  , "Coinage"                },
436 	{0x11, 0x01, 0xf0, 0xa0, "6 Coins 1 Play"         },
437 	{0x11, 0x01, 0xf0, 0xb0, "5 Coins 1 Play"         },
438 	{0x11, 0x01, 0xf0, 0xc0, "4 Coins 1 Play"         },
439 	{0x11, 0x01, 0xf0, 0xd0, "3 Coins 1 Play"         },
440 	{0x11, 0x01, 0xf0, 0xe0, "2 Coins 1 Play"         },
441 	{0x11, 0x01, 0xf0, 0xf0, "1 Coin  1 Play"         },
442 	{0x11, 0x01, 0xf0, 0x70, "1 Coin  2 Plays"        },
443 	{0x11, 0x01, 0xf0, 0x60, "1 Coin  3 Plays"        },
444 	{0x11, 0x01, 0xf0, 0x50, "1 Coin  4 Plays"        },
445 	{0x11, 0x01, 0xf0, 0x40, "1 Coin  5 Plays"        },
446 	{0x11, 0x01, 0xf0, 0x30, "1 Coin  6 Plays"        },
447 	{0x11, 0x01, 0xf0, 0x00, "Freeplay"               },
448 
449 	// Dip 2
450 	{0   , 0xfe, 0   , 2   , "Flip Screen"            },
451 	{0x12, 0x01, 0x01, 0x01, "Off"                    },
452 	{0x12, 0x01, 0x01, 0x00, "On"                     },
453 
454 	{0   , 0xfe, 0   , 2   , "Cabinet"                },
455 	{0x12, 0x01, 0x02, 0x00, "Upright"                },
456 	{0x12, 0x01, 0x02, 0x02, "Cocktail"               },
457 
458 	{0   , 0xfe, 0   , 2   , "Coin Mode"              },
459 	{0x12, 0x01, 0x04, 0x04, "Mode 1"                 },
460 	{0x12, 0x01, 0x04, 0x00, "Mode 2"                 },
461 
462 	{0   , 0xfe, 0   , 2   , "Demo Sounds"            },
463 	{0x12, 0x01, 0x08, 0x08, "Off"                    },
464 	{0x12, 0x01, 0x08, 0x00, "On"                     },
465 
466 	{0   , 0xfe, 0   , 2   , "Invulnerability"        },
467 	{0x12, 0x01, 0x10, 0x10, "Off"                    },
468 	{0x12, 0x01, 0x10, 0x00, "On"                     },
469 
470 	{0   , 0xfe, 0   , 2   , "Level Select"           },
471 	{0x12, 0x01, 0x20, 0x20, "Off"                    },
472 	{0x12, 0x01, 0x20, 0x00, "On"                     },
473 
474 	{0   , 0xfe, 0   , 2   , "Player Adding"          },
475 	{0x12, 0x01, 0x40, 0x40, "Off"                    },
476 	{0x12, 0x01, 0x40, 0x00, "On"                     },
477 
478 	{0   , 0xfe, 0   , 2   , "Service Mode"           },
479 	{0x12, 0x01, 0x80, 0x80, "Off"                    },
480 	{0x12, 0x01, 0x80, 0x00, "On"                     },
481 };
482 
483 STDDIPINFO(Kikcubic)
484 
485 static struct BurnRomInfo DrvRomDesc[] = {
486 	{ "vg_a-8h-e.ic55",   0x08000, 0x0d4e6866, BRF_ESS | BRF_PRG },	//  0	Z80 #1 Program Code
487 	{ "vg_a-8l-a.ic57",   0x10000, 0x690d812f, BRF_ESS | BRF_PRG },	//  1
488 
489 	{ "vg_a-5j-.ic37",    0x10000, 0x10582b2d, BRF_ESS | BRF_PRG },	//  2	Z80 #2 Program
490 
491 	{ "vg_b-4f-.ic34",    0x10000, 0x01579d20, BRF_GRA },			//  3	Characters
492 	{ "vg_b-4j-.ic35",    0x10000, 0x4f5872f0, BRF_GRA },			//  4
493 
494 	{ "vg_b-6l-.ic62",    0x20000, 0xfbe9552d, BRF_GRA },			//  5   Sprites
495 	{ "vg_b-6k-.ic61",    0x20000, 0xae09d5c0, BRF_GRA },			//  6
496 	{ "vg_b-6p-.ic64",    0x20000, 0xafb77461, BRF_GRA },			//  7
497 	{ "vg_b-6n-.ic63",    0x20000, 0x5065cd35, BRF_GRA },			//  8
498 
499 	{ "vg_b-1d-.ic2",     0x10000, 0x81b1ee5c, BRF_GRA },			//  9	Background
500 	{ "vg_b-1f-.ic3",     0x10000, 0xd0d33673, BRF_GRA },			// 10
501 	{ "vg_b-1h-.ic4",     0x10000, 0xaae81695, BRF_GRA },			// 11
502 
503 	{ "vg_a-4d-.ic26",    0x10000, 0x9b85101d, BRF_SND },			// 12	Samples
504 
505 	{ "vg_b-8r.ic90",  	  0x00117, 0xdf368a7a, BRF_GRA },			// 13	PALs
506 	{ "vg_b-4m.ic38",     0x00117, 0xdbca4204, BRF_GRA },			// 14
507 	{ "vg_b-1b.ic1",      0x00117, 0x922e5167, BRF_GRA },			// 15
508 
509 	{ "tbp24s10_7a.ic52", 0x00100, 0xc324835e, BRF_OPT },			// 16	Video Timing PROM
510 };
511 
512 STD_ROM_PICK(Drv)
513 STD_ROM_FN(Drv)
514 
515 static struct BurnRomInfo Drv1RomDesc[] = {
516 	{ "vg_a-8h-c.ic55",   0x08000, 0xd72682e8, BRF_ESS | BRF_PRG },	//  0	Z80 #1 Program Code
517 	{ "vg_a-8l-a.ic57",   0x10000, 0x690d812f, BRF_ESS | BRF_PRG },	//  1
518 
519 	{ "vg_a-5j-.ic37",    0x10000, 0x10582b2d, BRF_ESS | BRF_PRG },	//  2	Z80 #2 Program
520 
521 	{ "613.ic34",         0x20000, 0xee7a6c2f, BRF_GRA },			//  3	Characters
522 	{ "614.ic35",         0x20000, 0x6422e8ba, BRF_GRA },			//  4
523 
524 	{ "616.ic62",         0x20000, 0xfbe9552d, BRF_GRA },			//  5   Sprites
525 	{ "615.ic61",         0x20000, 0xae09d5c0, BRF_GRA },			//  6
526 	{ "618.ic64",         0x20000, 0xafb77461, BRF_GRA },			//  7
527 	{ "617.ic63",         0x20000, 0x5065cd35, BRF_GRA },			//  8
528 
529 	{ "619.ic2",          0x20000, 0x9e2f8759, BRF_GRA },			//  9	Background
530 	{ "612.ic4",          0x20000, 0x85057c81, BRF_GRA },			// 10
531 
532 	{ "vg_a-4d-.ic26",    0x10000, 0x9b85101d, BRF_SND },			// 11	Samples
533 
534 	{ "vg_b-8r.ic90",  	  0x00117, 0xdf368a7a, BRF_GRA },			// 12	PALs
535 	{ "vg_b-4m.ic38",     0x00117, 0xdbca4204, BRF_GRA },			// 13
536 	{ "vg_b-1b.ic1",      0x00117, 0x922e5167, BRF_GRA },			// 14
537 
538 	{ "tbp24s10_7a.ic52", 0x00100, 0xc324835e, BRF_OPT },			// 15	Video Timing PROM
539 };
540 
541 STD_ROM_PICK(Drv1)
542 STD_ROM_FN(Drv1)
543 
544 static struct BurnRomInfo DrvuRomDesc[] = {
545 	{ "vg_a-8h-.ic55",    0x08000, 0x8d15109e, BRF_ESS | BRF_PRG },	//  0	Z80 #1 Program Code
546 	{ "vg_a-8l-.ic57",    0x10000, 0x7f95799b, BRF_ESS | BRF_PRG },	//  1
547 
548 	{ "vg_a-5j-.ic37",    0x10000, 0x10582b2d, BRF_ESS | BRF_PRG },	//  2	Z80 #2 Program
549 
550 	{ "613.ic34",         0x20000, 0xee7a6c2f, BRF_GRA },			//  3	Characters
551 	{ "614.ic35",         0x20000, 0x6422e8ba, BRF_GRA },			//  4
552 
553 	{ "616.ic62",         0x20000, 0xfbe9552d, BRF_GRA },			//  5   Sprites
554 	{ "615.ic61",         0x20000, 0xae09d5c0, BRF_GRA },			//  6
555 	{ "618.ic64",         0x20000, 0xafb77461, BRF_GRA },			//  7
556 	{ "617.ic63",         0x20000, 0x5065cd35, BRF_GRA },			//  8
557 
558 	{ "619.ic2",          0x20000, 0x9e2f8759, BRF_GRA },			//  9	Background
559 	{ "612.ic4",          0x20000, 0x85057c81, BRF_GRA },			// 10
560 
561 	{ "vg_a-4d-.ic26",    0x10000, 0x9b85101d, BRF_SND },			// 11	Samples
562 
563 	{ "vg_b-8r.ic90",  	  0x00117, 0xdf368a7a, BRF_GRA },			// 12	PALs
564 	{ "vg_b-4m.ic38",     0x00117, 0xdbca4204, BRF_GRA },			// 13
565 	{ "vg_b-1b.ic1",      0x00117, 0x922e5167, BRF_GRA },			// 14
566 
567 	{ "tbp24s10_7a.ic52", 0x00100, 0xc324835e, BRF_OPT },			// 15	Video Timing PROM
568 };
569 
570 STD_ROM_PICK(Drvu)
571 STD_ROM_FN(Drvu)
572 
573 static struct BurnRomInfo Drvu2RomDesc[] = {
574 	{ "vg_a-8h-g.ic55",   0x08000, 0x9444c04e, BRF_ESS | BRF_PRG },	//  0	Z80 #1 Program Code
575 	{ "vg_a-8l-.ic57",    0x10000, 0x7f95799b, BRF_ESS | BRF_PRG },	//  1
576 
577 	{ "vg_a-5j-.ic37",    0x10000, 0x10582b2d, BRF_ESS | BRF_PRG },	//  2	Z80 #2 Program
578 
579 	{ "vg_b-4f-.ic34",    0x10000, 0x01579d20, BRF_GRA },			//  3	Characters
580 	{ "vg_b-4j-.ic35",    0x10000, 0x4f5872f0, BRF_GRA },			//  4
581 
582 	{ "vg_b-6l-.ic62",    0x20000, 0xfbe9552d, BRF_GRA },			//  5   Sprites
583 	{ "vg_b-6k-.ic61",    0x20000, 0xae09d5c0, BRF_GRA },			//  6
584 	{ "vg_b-6p-.ic64",    0x20000, 0xafb77461, BRF_GRA },			//  7
585 	{ "vg_b-6n-.ic63",    0x20000, 0x5065cd35, BRF_GRA },			//  8
586 
587 	{ "vg_b-1d-.ic2",     0x10000, 0x81b1ee5c, BRF_GRA },			//  9	Background
588 	{ "vg_b-1f-.ic3",     0x10000, 0xd0d33673, BRF_GRA },			// 10
589 	{ "vg_b-1h-.ic4",     0x10000, 0xaae81695, BRF_GRA },			// 11
590 
591 	{ "vg_a-4d-.ic26",    0x10000, 0x9b85101d, BRF_SND },			// 12	Samples
592 
593 	{ "vg_b-8r.ic90",  	  0x00117, 0xdf368a7a, BRF_GRA },			// 13	PALs
594 	{ "vg_b-4m.ic38",     0x00117, 0xdbca4204, BRF_GRA },			// 14
595 	{ "vg_b-1b.ic1",      0x00117, 0x922e5167, BRF_GRA },			// 15
596 
597 	{ "tbp24s10_7a.ic52", 0x00100, 0xc324835e, BRF_OPT },			// 16	Video Timing PROM
598 };
599 
600 STD_ROM_PICK(Drvu2)
601 STD_ROM_FN(Drvu2)
602 
603 static struct BurnRomInfo DrvjRomDesc[] = {
604 	{ "vg_a-8h-d.ic55",   0x08000, 0xba848713, BRF_ESS | BRF_PRG },	//  0	Z80 #1 Program Code
605 	{ "vg_a-8l-d.ic57",   0x10000, 0x3b12b1d8, BRF_ESS | BRF_PRG },	//  1
606 
607 	{ "vg_a-5j-d.ic37",   0x10000, 0x10582b2d, BRF_ESS | BRF_PRG },	//  2	Z80 #2 Program
608 
609 	{ "613.ic34",         0x20000, 0xee7a6c2f, BRF_GRA },			//  3	Characters
610 	{ "614.ic35",         0x20000, 0x6422e8ba, BRF_GRA },			//  4
611 
612 	{ "616.ic62",         0x20000, 0xfbe9552d, BRF_GRA },			//  5   Sprites
613 	{ "615.ic61",         0x20000, 0xae09d5c0, BRF_GRA },			//  6
614 	{ "618.ic64",         0x20000, 0xafb77461, BRF_GRA },			//  7
615 	{ "617.ic63",         0x20000, 0x5065cd35, BRF_GRA },			//  8
616 
617 	{ "619.ic2",          0x20000, 0x9e2f8759, BRF_GRA },			//  9	Background
618 	{ "612.ic4",          0x20000, 0x85057c81, BRF_GRA },			// 10
619 
620 	{ "vg_a-4d-d.ic26",    0x10000, 0x9b85101d, BRF_SND },			// 11	Samples
621 
622 	{ "vg_b-8r.ic90",  	  0x00117, 0xdf368a7a, BRF_GRA },			// 12	PALs
623 	{ "vg_b-4m.ic38",     0x00117, 0xdbca4204, BRF_GRA },			// 13
624 	{ "vg_b-1b.ic1",      0x00117, 0x922e5167, BRF_GRA },			// 14
625 
626 	{ "tbp24s10_7a.ic52", 0x00100, 0xc324835e, BRF_OPT },			// 15	Video Timing PROM
627 };
628 
629 STD_ROM_PICK(Drvj)
630 STD_ROM_FN(Drvj)
631 
632 static struct BurnRomInfo DrvbRomDesc[] = {
633 	{ "g07_c03.bin",   0x08000, 0x9dcca081, BRF_ESS | BRF_PRG },	//  0	Z80 #1 Program Code
634 	{ "j07_c04.bin",   0x10000, 0xe0159105, BRF_ESS | BRF_PRG },	//  1
635 
636 	{ "g05_c02.bin",   0x10000, 0x10582b2d, BRF_ESS | BRF_PRG },	//  2	Z80 #2 Program
637 
638 	{ "f05_c08.bin",   0x10000, 0x01579d20, BRF_GRA },				//  3	Characters
639 	{ "h05_c09.bin",   0x10000, 0x4f5872f0, BRF_GRA },				//  4
640 
641 	{ "n07_c12.bin",   0x10000, 0x10af8eb2, BRF_GRA },				//  5	Sprites
642 	{ "k07_c10.bin",   0x10000, 0x9576f304, BRF_GRA },				//  6
643 	{ "o07_c13.bin",   0x10000, 0xb1d9d4dc, BRF_GRA },				//  7
644 	{ "l07_c11.bin",   0x10000, 0x4598be4a, BRF_GRA },				//  8
645 	{ "t07_c16.bin",   0x10000, 0xf5425e42, BRF_GRA },				//  9
646 	{ "p07_c14.bin",   0x10000, 0xcb50a17c, BRF_GRA },				// 10
647 	{ "v07_c17.bin",   0x10000, 0x959ba3c7, BRF_GRA },				// 11
648 	{ "s07_c15.bin",   0x10000, 0x7f2e91c5, BRF_GRA },				// 12
649 
650 	{ "d01_c05.bin",   0x10000, 0x81b1ee5c, BRF_GRA },				// 13	Background
651 	{ "e01_c06.bin",   0x10000, 0xd0d33673, BRF_GRA },				// 14
652 	{ "f01_c07.bin",   0x10000, 0xaae81695, BRF_GRA },				// 15
653 
654 	{ "d04_c01.bin",   0x10000, 0x9b85101d, BRF_SND },				// 16	Samples
655 
656 	{ "p09_16l8.bin",  0x00117, 0xdf368a7a, BRF_GRA },				// 17	PALs
657 	{ "m05_16l8.bin",  0x00117, 0xdbca4204, BRF_GRA },				// 18
658 	{ "b01_16l8.bin",  0x00104, 0x1beae498, BRF_GRA },				// 19
659 
660 	{ "a07_129.bin",   0x00100, 0xc324835e, BRF_OPT },				// 20	Video Timing PROM
661 	{ "t10_129a.bin",  0x00100, 0x1513df33, BRF_OPT },				// 21
662 	{ "u10_129b.bin",  0x00100, 0x06661d00, BRF_OPT },				// 22
663 	{ "v10_129c.bin",  0x00100, 0x3f186bc8, BRF_OPT },				// 23
664 };
665 
666 STD_ROM_PICK(Drvb)
667 STD_ROM_FN(Drvb)
668 
669 static struct BurnRomInfo VigilantaRomDesc[] = {
670 	{ "vg_a-8h-a.ic55",   0x08000, 0x97df1454, BRF_ESS | BRF_PRG },	//  0	Z80 #1 Program Code
671 	{ "vg_a-8l-a.ic57",   0x10000, 0x690d812f, BRF_ESS | BRF_PRG },	//  1
672 
673 	{ "vg_a-5j-a.ic37",   0x10000, 0x10582b2d, BRF_ESS | BRF_PRG },	//  2	Z80 #2 Program
674 
675 	{ "613.ic34",         0x20000, 0xee7a6c2f, BRF_GRA },			//  3	Characters
676 	{ "614.ic35",         0x20000, 0x6422e8ba, BRF_GRA },			//  4
677 
678 	{ "616.ic62",         0x20000, 0xfbe9552d, BRF_GRA },			//  5   Sprites
679 	{ "615.ic61",         0x20000, 0xae09d5c0, BRF_GRA },			//  6
680 	{ "618.ic64",         0x20000, 0xafb77461, BRF_GRA },			//  7
681 	{ "617.ic63",         0x20000, 0x5065cd35, BRF_GRA },			//  8
682 
683 	{ "619.ic2",          0x20000, 0x9e2f8759, BRF_GRA },			//  9	Background
684 	{ "612.ic4",          0x20000, 0x85057c81, BRF_GRA },			// 10
685 
686 	{ "vg_a-4d-a.ic26",   0x10000, 0x9b85101d, BRF_SND },			// 11	Samples
687 
688 	{ "vg_b-8r.ic90",  	  0x00117, 0xdf368a7a, BRF_GRA },			// 12	PALs
689 	{ "vg_b-4m.ic38",     0x00117, 0xdbca4204, BRF_GRA },			// 13
690 	{ "vg_b-1b.ic1",      0x00117, 0x922e5167, BRF_GRA },			// 14
691 
692 	{ "tbp24s10_7a.ic52", 0x00100, 0xc324835e, BRF_OPT },			// 15	Video Timing PROM
693 };
694 
695 STD_ROM_PICK(Vigilanta)
696 STD_ROM_FN(Vigilanta)
697 
698 static struct BurnRomInfo VigilantbRomDesc[] = {
699 	{ "vg_a-8h-b.ic55",   0x08000, 0x05350c2a, BRF_ESS | BRF_PRG },	//  0	Z80 #1 Program Code
700 	{ "vg_a-8l-.ic57",    0x10000, 0x7f95799b, BRF_ESS | BRF_PRG },	//  1
701 
702 	{ "vg_a-5j-.ic37",    0x10000, 0x10582b2d, BRF_ESS | BRF_PRG },	//  2	Z80 #2 Program
703 
704 	{ "613.ic34",         0x20000, 0xee7a6c2f, BRF_GRA },			//  3	Characters
705 	{ "614.ic35",         0x20000, 0x6422e8ba, BRF_GRA },			//  4
706 
707 	{ "616.ic62",         0x20000, 0xfbe9552d, BRF_GRA },			//  5   Sprites
708 	{ "615.ic61",         0x20000, 0xae09d5c0, BRF_GRA },			//  6
709 	{ "618.ic64",         0x20000, 0xafb77461, BRF_GRA },			//  7
710 	{ "617.ic63",         0x20000, 0x5065cd35, BRF_GRA },			//  8
711 
712 	{ "619.ic2",          0x20000, 0x9e2f8759, BRF_GRA },			//  9	Background
713 	{ "612.ic4",          0x20000, 0x85057c81, BRF_GRA },			// 10
714 
715 	{ "vg_a-4d-.ic26",    0x10000, 0x9b85101d, BRF_SND },			// 11	Samples
716 
717 	{ "vg_b-8r.ic90",  	  0x00117, 0xdf368a7a, BRF_GRA },			// 12	PALs
718 	{ "vg_b-4m.ic38",     0x00117, 0xdbca4204, BRF_GRA },			// 13
719 	{ "vg_b-1b.ic1",      0x00117, 0x922e5167, BRF_GRA },			// 14
720 
721 	{ "tbp24s10_7a.ic52", 0x00100, 0xc324835e, BRF_OPT },			// 15	Video Timing PROM
722 };
723 
724 STD_ROM_PICK(Vigilantb)
725 STD_ROM_FN(Vigilantb)
726 
727 static struct BurnRomInfo BuccanrsRomDesc[] = {
728 	{ "bc-011_k-163.u58",       0x10000, 0xbf1d7e6f, BRF_ESS | BRF_PRG },	//  0	Z80 #1 Program Code
729 	{ "bc-012_k-163.u25",       0x10000, 0x87303ba8, BRF_ESS | BRF_PRG },	//  1
730 
731 	{ "bc-001_k-0161.u128",    	0x10000, 0xeb65f8c3, BRF_ESS | BRF_PRG },	//  2	Z80 #2 Program
732 
733 	{ "bc-003_k-0161.u212",    	0x10000, 0x95e3c517, BRF_GRA },				//  3	Characters
734 	{ "bc-004_k-0161.u189",     0x10000, 0xfe2377ab, BRF_GRA },				//  4
735 
736 	{ "bc-005_k-0161.u113",     0x20000, 0x16dc435f, BRF_GRA },				//  5	Sprites
737 	{ "bc-006_k-161.u80",       0x10000, 0x4fe3bf97, BRF_GRA },				//  6
738 	{ "bc-008_k-161.u52",       0x20000, 0x078aef7f, BRF_GRA },				//  7
739 	{ "bc-007_k-161.u70",       0x10000, 0xf650fa90, BRF_GRA },				//  8
740 
741 	{ "bc-009_k-163.u49",       0x20000, 0x0c6188fb, BRF_GRA },				//  9	Background
742 	{ "bc-010_k-163.u27",       0x20000, 0x2d383ff8, BRF_GRA },				// 10
743 
744 	{ "bc-002_k-0161.u74",      0x10000, 0x36ee1dac, BRF_SND },				// 11	Samples
745 
746 	{ "prom1.u54",     			0x00100, 0xc324835e, BRF_GRA },				// 12	PROMs
747 	{ "prom4.u79",     			0x00100, 0xe6506ef4, BRF_GRA },				// 13
748 	{ "prom3.u88",     			0x00100, 0xb43d094f, BRF_GRA },				// 14
749 	{ "prom2.u99",     			0x00100, 0xe0aa8869, BRF_GRA },				// 15
750 
751 	{ "pal16l8.u103",  			0x00104, 0x00000000, BRF_GRA | BRF_NODUMP },	// 16	PALs
752 	{ "pal16l8.u156",  			0x00104, 0x00000000, BRF_GRA | BRF_NODUMP },	// 17
753 	{ "pal16l8.u42",   			0x00104, 0x00000000, BRF_GRA | BRF_NODUMP },	// 18
754 };
755 
756 STD_ROM_PICK(Buccanrs)
757 STD_ROM_FN(Buccanrs)
758 
759 static struct BurnRomInfo BuccanrsaRomDesc[] = {
760 	{ "bc-011",        			0x08000, 0x6b657ef1, BRF_ESS | BRF_PRG },	//  0	Z80 #1 Program Code
761 	{ "bc-012_k-163.u25",       0x10000, 0x87303ba8, BRF_ESS | BRF_PRG },	//  1
762 
763 	{ "bc-001_k-0161.u128",    	0x10000, 0xeb65f8c3, BRF_ESS | BRF_PRG },	//  2	Z80 #2 Program
764 
765 	{ "bc-003_k-0161.u212",    	0x10000, 0x95e3c517, BRF_GRA },				//  3	Characters
766 	{ "bc-004_k-0161.u189",     0x10000, 0xfe2377ab, BRF_GRA },				//  4
767 
768 	{ "bc-005_k-0161.u113",     0x20000, 0x16dc435f, BRF_GRA },				//  5	Sprites
769 	{ "bc-006_k-161.u80",       0x10000, 0x4fe3bf97, BRF_GRA },				//  6
770 	{ "bc-008_k-161.u52",       0x20000, 0x078aef7f, BRF_GRA },				//  7
771 	{ "bc-007_k-161.u70",       0x10000, 0xf650fa90, BRF_GRA },				//  8
772 
773 	{ "bc-009_k-163.u49",       0x20000, 0x0c6188fb, BRF_GRA },				//  9	Background
774 	{ "bc-010_k-163.u27",       0x20000, 0x2d383ff8, BRF_GRA },				// 10
775 
776 	{ "bc-002_k-0161.u74",      0x10000, 0x36ee1dac, BRF_SND },				// 11	Samples
777 
778 	{ "prom1.u54",     			0x00100, 0xc324835e, BRF_GRA },				// 12	PROMs
779 	{ "prom4.u79",     			0x00100, 0xe6506ef4, BRF_GRA },				// 13
780 	{ "prom3.u88",     			0x00100, 0xb43d094f, BRF_GRA },				// 14
781 	{ "prom2.u99",     			0x00100, 0xe0aa8869, BRF_GRA },				// 15
782 };
783 
784 STD_ROM_PICK(Buccanrsa)
785 STD_ROM_FN(Buccanrsa)
786 
787 static struct BurnRomInfo BuccanrsbRomDesc[] = {
788 	{ "rr_du.u58",       		0x08000, 0xdcad3a8b, BRF_ESS | BRF_PRG },	//  0	Z80 #1 Program Code
789 	{ "bc-012_k-163.u25",       0x10000, 0x87303ba8, BRF_ESS | BRF_PRG },	//  1
790 
791 	{ "bc-001_k-0161.u128",    	0x10000, 0xeb65f8c3, BRF_ESS | BRF_PRG },	//  2	Z80 #2 Program
792 
793 	{ "bc-003_k-0161.u212",    	0x10000, 0x95e3c517, BRF_GRA },				//  3	Characters
794 	{ "bc-004_k-0161.u189",     0x10000, 0xfe2377ab, BRF_GRA },				//  4
795 
796 	{ "bc-005_k-0161.u113",     0x20000, 0x16dc435f, BRF_GRA },				//  5	Sprites
797 	{ "bc-006_k-161.u80",       0x10000, 0x4fe3bf97, BRF_GRA },				//  6
798 	{ "bc-008_k-161.u52",       0x20000, 0x078aef7f, BRF_GRA },				//  7
799 	{ "bc-007_k-161.u70",       0x10000, 0xf650fa90, BRF_GRA },				//  8
800 
801 	{ "bc-009_k-163.u49",       0x20000, 0x0c6188fb, BRF_GRA },				//  9	Background
802 	{ "bc-010_k-163.u27",       0x20000, 0x2d383ff8, BRF_GRA },				// 10
803 
804 	{ "bc-002_k-0161.u74",      0x10000, 0x36ee1dac, BRF_SND },				// 11	Samples
805 
806 	{ "prom1.u54",     			0x00100, 0xc324835e, BRF_GRA },				// 12	PROMs
807 	{ "prom4.u79",     			0x00100, 0xe6506ef4, BRF_GRA },				// 13
808 	{ "prom3.u88",     			0x00100, 0xb43d094f, BRF_GRA },				// 14
809 	{ "prom2.u99",     			0x00100, 0xe0aa8869, BRF_GRA },				// 15
810 };
811 
812 STD_ROM_PICK(Buccanrsb)
813 STD_ROM_FN(Buccanrsb)
814 
815 static struct BurnRomInfo KikcubicRomDesc[] = {
816 	{ "mqj-p0",        0x08000, 0x9cef394a, BRF_ESS | BRF_PRG },	//  0	Z80 #1 Program Code
817 	{ "mqj-b0",        0x10000, 0xd9bcf4cd, BRF_ESS | BRF_PRG },	//  1
818 	{ "mqj-b1",        0x10000, 0x54a0abe1, BRF_ESS | BRF_PRG },	//  2
819 
820 	{ "mqj-sp",        0x10000, 0xbbcf3582, BRF_ESS | BRF_PRG },	//  3	Z80 #2 Program
821 
822 	{ "mqj-c0",        0x10000, 0x975585c5, BRF_GRA },				//  4	Characters
823 	{ "mqj-c1",        0x10000, 0x49d9936d, BRF_GRA },				//  5
824 
825 	{ "mqj-00",        0x40000, 0x7fb0c58f, BRF_GRA },				//  6	Sprites
826 	{ "mqj-10",        0x40000, 0x3a189205, BRF_GRA },				//  7
827 
828 	{ "mqj-v0",        0x10000, 0x54762956, BRF_SND },				//  8	Samples
829 
830 	{ "8d",            0x00100, 0x7379bb12, BRF_GRA },				//  9	PROMs
831 	{ "6h",            0x00020, 0xface0cbb, BRF_GRA },				// 10
832 	{ "7s",            0x00020, 0xface0cbb, BRF_GRA },				// 11
833 };
834 
835 STD_ROM_PICK(Kikcubic)
836 STD_ROM_FN(Kikcubic)
837 
838 static struct BurnRomInfo KikcubicbRomDesc[] = {
839 	{ "1.bin",         0x08000, 0xd3a589ba, BRF_ESS | BRF_PRG },	//  0	Z80 #1 Program Code
840 	{ "4.bin",         0x10000, 0x9ae1e1a6, BRF_ESS | BRF_PRG },	//  1
841 	{ "5.bin",         0x08000, 0xa5a6bffd, BRF_ESS | BRF_PRG },	//  2
842 
843 	{ "mqj-sp",        0x10000, 0xbbcf3582, BRF_ESS | BRF_PRG },	//  3	Z80 #2 Program
844 
845 	{ "7.bin",         0x10000, 0x1788d51a, BRF_GRA },				//  4	Characters
846 	{ "mqj-c1",        0x10000, 0x49d9936d, BRF_GRA },				//  5
847 
848 	{ "11.bin",        0x10000, 0x0f0cac92, BRF_GRA },				//  6	Sprites
849 	{ "10.bin",        0x10000, 0x7d3822a8, BRF_GRA },				//  7
850 	{ "9.bin",         0x10000, 0x56fb4fa3, BRF_GRA },				//  8
851 	{ "8.bin",         0x10000, 0x947dbd4e, BRF_GRA },				//  9
852 
853 	{ "mqj-v0",        0x10000, 0x54762956, BRF_SND },				// 10	Samples
854 
855 	{ "8d",            0x00100, 0x7379bb12, BRF_GRA },				// 11	PROMs
856 	{ "6h",            0x00020, 0xface0cbb, BRF_GRA },				// 12
857 	{ "7s",            0x00020, 0xface0cbb, BRF_GRA },				// 13
858 };
859 
860 STD_ROM_PICK(Kikcubicb)
STD_ROM_FN(Kikcubicb)861 STD_ROM_FN(Kikcubicb)
862 
863 static INT32 MemIndex()
864 {
865 	UINT8 *Next; Next = Mem;
866 
867 	DrvZ80Rom1             = Next; Next += 0x28000;
868 	DrvZ80Rom2             = Next; Next += 0x10000;
869 	DrvSamples             = Next; Next += 0x10000;
870 
871 	RamStart               = Next;
872 
873 	DrvZ80Ram1             = Next; Next += 0x02000;
874 	DrvZ80Ram2             = Next; Next += 0x01000;
875 	DrvSpriteRam           = Next; Next += 0x00100;
876 	DrvPaletteRam          = Next; Next += 0x00800;
877 	DrvVideoRam            = Next; Next += 0x01000;
878 	DrvPalette             = (UINT32*)Next; Next += (512 + 32) * sizeof(UINT32);
879 
880 	RamEnd                 = Next;
881 
882 	DrvChars               = Next; Next += 0x1000 * 8 * 8;
883 	DrvSprites             = Next; Next += 0x1000 * 16 * 16;
884 	DrvBackTiles           = Next; Next += 0x4000 * 32;
885 
886 	MemEnd                 = Next;
887 
888 	return 0;
889 }
890 
DrvSetVector(INT32 Status)891 static void DrvSetVector(INT32 Status)
892 {
893 	switch (Status) {
894 		case VECTOR_INIT: {
895 			DrvIrqVector = 0xff;
896 			break;
897 		}
898 
899 		case YM2151_ASSERT: {
900 			DrvIrqVector &= 0xef;
901 			break;
902 		}
903 
904 		case YM2151_CLEAR: {
905 			DrvIrqVector |= 0x10;
906 			break;
907 		}
908 
909 		case Z80_ASSERT: {
910 			DrvIrqVector &= 0xdf;
911 			break;
912 		}
913 
914 		case Z80_CLEAR: {
915 			DrvIrqVector |= 0x20;
916 			break;
917 		}
918 	}
919 
920 	if (DrvIrqVector == 0xff) {
921 		ZetSetVector(DrvIrqVector);
922 		ZetSetIRQLine(0, CPU_IRQSTATUS_NONE);
923 	} else {
924 		ZetSetVector(DrvIrqVector);
925 		ZetSetIRQLine(0, CPU_IRQSTATUS_ACK);
926 	}
927 }
928 
bank_switch(INT32 data)929 static void bank_switch(INT32 data)
930 {
931 	DrvRomBank = data & 0x07;
932 	ZetMapMemory(DrvZ80Rom1 + 0x10000 + (DrvRomBank * 0x4000), 0x8000, 0xbfff, MAP_ROM);
933 }
934 
DrvDoReset()935 static INT32 DrvDoReset()
936 {
937 	for (INT32 i = 0; i < 2; i++) {
938 		ZetOpen(i);
939 		ZetReset();
940 		if (i == 1) DrvSetVector(VECTOR_INIT);
941 		ZetClose();
942 	}
943 
944 	if (DrvHasYM2203) {
945 		BurnYM2203Reset();
946 	} else {
947 		BurnYM2151Reset();
948 	}
949 
950 	DACReset();
951 
952 	DrvRomBank = 0;
953 	DrvSoundLatch = 0;
954 	DrvRearColour = 0;
955 	DrvRearDisable = 0;
956 	DrvHorizScrollLo = 0;
957 	DrvHorizScrollHi = 0;
958 	DrvRearHorizScrollLo = 0;
959 	DrvRearHorizScrollHi = 0;
960 	DrvSampleAddress = 0;
961 
962 	return 0;
963 }
964 
VigilanteZ80Read1(UINT16 a)965 static UINT8 __fastcall VigilanteZ80Read1(UINT16 a)
966 {
967 	switch (a) {
968 		default: {
969 //			bprintf(PRINT_NORMAL, _T("Z80 #1 Read => %04X\n"), a);
970 		}
971 	}
972 
973 	return 0;
974 }
975 
VigilanteZ80Write1(UINT16 a,UINT8 d)976 static void __fastcall VigilanteZ80Write1(UINT16 a, UINT8 d)
977 {
978 	if (a >= 0xc020 && a <= 0xc0df) {
979 		DrvSpriteRam[a - 0xc020] = d;
980 		return;
981 	}
982 
983 	if (a >= 0xc800 && a <= 0xcfff) {
984 		INT32 Offset = a & 0x7ff;
985 		INT32 Bank = Offset & 0x400;
986 		INT32 r, g, b;
987 
988 		DrvPaletteRam[Offset] = d;
989 
990 		Offset &= 0xff;
991 		r = (DrvPaletteRam[Bank + Offset + 0x000] << 3) & 0xff;
992 		g = (DrvPaletteRam[Bank + Offset + 0x100] << 3) & 0xff;
993 		b = (DrvPaletteRam[Bank + Offset + 0x200] << 3) & 0xff;
994 
995 		DrvPalette[(Bank >> 2) + Offset] = BurnHighCol(r, g, b, 0);
996 		return;
997 	}
998 
999 	switch (a) {
1000 		default: {
1001 //			bprintf(PRINT_NORMAL, _T("Z80 #1 Write => %04X, %02X\n"), a, d);
1002 		}
1003 	}
1004 }
1005 
VigilanteZ80PortRead1(UINT16 a)1006 static UINT8 __fastcall VigilanteZ80PortRead1(UINT16 a)
1007 {
1008 	a &= 0xff;
1009 
1010 	switch (a) {
1011 		case 0x00: {
1012 			return 0xff - DrvInput[0];
1013 		}
1014 
1015 		case 0x01: {
1016 			return 0xff - DrvInput[1];
1017 		}
1018 
1019 		case 0x02: {
1020 			return 0xff - DrvInput[2];
1021 		}
1022 
1023 		case 0x03: {
1024 			return DrvDip[0];
1025 		}
1026 
1027 		case 0x04: {
1028 			return DrvDip[1];
1029 		}
1030 
1031 		default: {
1032 //			bprintf(PRINT_NORMAL, _T("Z80 #1 Port Read => %02X\n"), a);
1033 		}
1034 	}
1035 
1036 	return 0;
1037 }
1038 
BuccanrsZ80PortRead1(UINT16 a)1039 static UINT8 __fastcall BuccanrsZ80PortRead1(UINT16 a)
1040 {
1041 	a &= 0xff;
1042 
1043 	switch (a) {
1044 		case 0x00: {
1045 			return (0xd0 - DrvInput[0]) | DrvDip[0];
1046 		}
1047 
1048 		case 0x01: {
1049 			return 0xff - DrvInput[1];
1050 		}
1051 
1052 		case 0x02: {
1053 			return 0xff - DrvInput[2];
1054 		}
1055 
1056 		case 0x03: {
1057 			return DrvDip[1];
1058 		}
1059 
1060 		case 0x04: {
1061 			return DrvDip[2];
1062 		}
1063 
1064 		default: {
1065 //			bprintf(PRINT_NORMAL, _T("Z80 #1 Port Read => %02X\n"), a);
1066 		}
1067 	}
1068 
1069 	return 0;
1070 }
1071 
BuccanrsaZ80PortRead1(UINT16 a)1072 static UINT8 __fastcall BuccanrsaZ80PortRead1(UINT16 a)
1073 {
1074 	a &= 0xff;
1075 
1076 	switch (a) {
1077 		case 0x00: {
1078 			return (0x0b - DrvInput[0]) | DrvDip[0];
1079 		}
1080 
1081 		case 0x01: {
1082 			return 0xff - DrvInput[1];
1083 		}
1084 
1085 		case 0x02: {
1086 			return 0xff - DrvInput[2];
1087 		}
1088 
1089 		case 0x03: {
1090 			return DrvDip[1];
1091 		}
1092 
1093 		case 0x04: {
1094 			return DrvDip[2];
1095 		}
1096 
1097 		default: {
1098 //			bprintf(PRINT_NORMAL, _T("Z80 #1 Port Read => %02X\n"), a);
1099 		}
1100 	}
1101 
1102 	return 0;
1103 }
1104 
VigilanteZ80PortWrite1(UINT16 a,UINT8 d)1105 static void __fastcall VigilanteZ80PortWrite1(UINT16 a, UINT8 d)
1106 {
1107 	a &= 0xff;
1108 
1109 	switch (a) {
1110 		case 0x00: {
1111 			DrvSoundLatch = d;
1112 			ZetCPUPush(1);
1113 			DrvSetVector(Z80_ASSERT);
1114 			ZetCPUPop();
1115 			return;
1116 		}
1117 
1118 		case 0x01: {
1119 			// output port?
1120 			return;
1121 		}
1122 
1123 		case 0x04: {
1124 			bank_switch(d);
1125 			return;
1126 		}
1127 
1128 		case 0x80: {
1129 			DrvHorizScrollLo = d;
1130 			return;
1131 		}
1132 
1133 		case 0x81: {
1134 			DrvHorizScrollHi = (d & 0x01) << 8;
1135 			return;
1136 		}
1137 
1138 		case 0x82: {
1139 			DrvRearHorizScrollLo = d;
1140 			return;
1141 		}
1142 
1143 		case 0x83: {
1144 			DrvRearHorizScrollHi = (d & 0x07) << 8;
1145 			return;
1146 		}
1147 
1148 		case 0x84: {
1149 			DrvRearColour = d & 0x0d;
1150 			DrvRearDisable = d & 0x40;
1151 			return;
1152 		}
1153 
1154 		default: {
1155 //			bprintf(PRINT_NORMAL, _T("Z80 #1 Port Write => %02X, %02X\n"), a, d);
1156 		}
1157 	}
1158 }
1159 
KikcubicZ80Read1(UINT16 a)1160 static UINT8 __fastcall KikcubicZ80Read1(UINT16 a)
1161 {
1162 	switch (a) {
1163 		default: {
1164 //			bprintf(PRINT_NORMAL, _T("Z80 #1 Read => %04X\n"), a);
1165 		}
1166 	}
1167 
1168 	return 0;
1169 }
1170 
KikcubicZ80Write1(UINT16 a,UINT8 d)1171 static void __fastcall KikcubicZ80Write1(UINT16 a, UINT8 d)
1172 {
1173 	if (a >= 0xc800 && a <= 0xcaff) {
1174 		INT32 Offset = a & 0x3ff;
1175 		INT32 Bank = 0; /*Offset & 0x400;*/ // always bank 0 due to shortened palette ram in kikcubic
1176 		INT32 r, g, b;
1177 
1178 		DrvPaletteRam[Offset] = d;
1179 
1180 		Offset &= 0xff;
1181 		r = (DrvPaletteRam[Bank + Offset + 0x000] << 3) & 0xff;
1182 		g = (DrvPaletteRam[Bank + Offset + 0x100] << 3) & 0xff;
1183 		b = (DrvPaletteRam[Bank + Offset + 0x200] << 3) & 0xff;
1184 
1185 		DrvPalette[(Bank >> 2) + Offset] = BurnHighCol(r, g, b, 0);
1186 		return;
1187 	}
1188 
1189 	switch (a) {
1190 		default: {
1191 //			bprintf(PRINT_NORMAL, _T("Z80 #1 Write => %04X, %02X\n"), a, d);
1192 		}
1193 	}
1194 }
1195 
KikcubicZ80PortRead1(UINT16 a)1196 static UINT8 __fastcall KikcubicZ80PortRead1(UINT16 a)
1197 {
1198 	a &= 0xff;
1199 
1200 	switch (a) {
1201 		case 0x00: {
1202 			return DrvDip[0];
1203 		}
1204 
1205 		case 0x01: {
1206 			return DrvDip[1];
1207 		}
1208 
1209 		case 0x02: {
1210 			return 0xff - DrvInput[1];
1211 		}
1212 
1213 		case 0x03: {
1214 			return 0xff - DrvInput[0];
1215 		}
1216 
1217 		case 0x04: {
1218 			return 0xff - DrvInput[2];
1219 		}
1220 
1221 		default: {
1222 //			bprintf(PRINT_NORMAL, _T("Z80 #1 Port Read => %02X\n"), a);
1223 		}
1224 	}
1225 
1226 	return 0;
1227 }
1228 
KikcubicZ80PortWrite1(UINT16 a,UINT8 d)1229 static void __fastcall KikcubicZ80PortWrite1(UINT16 a, UINT8 d)
1230 {
1231 	a &= 0xff;
1232 
1233 	switch (a) {
1234 		case 0x00: {
1235 			// coin write
1236 			return;
1237 		}
1238 
1239 		case 0x04: {
1240 			bank_switch(d);
1241 			return;
1242 		}
1243 
1244 		case 0x06: {
1245 			if (d == 0x20) return; // ???
1246 			DrvSoundLatch = d;
1247 			ZetCPUPush(1);
1248 			DrvSetVector(Z80_ASSERT);
1249 			ZetCPUPop();
1250 			return;
1251 		}
1252 
1253 		case 0x07: {
1254 			// nop???
1255 			return;
1256 		}
1257 
1258 		default: {
1259 //			bprintf(PRINT_NORMAL, _T("Z80 #1 Port Write => %02X, %02X\n"), a, d);
1260 		}
1261 	}
1262 }
1263 
VigilanteZ80Read2(UINT16 a)1264 static UINT8 __fastcall VigilanteZ80Read2(UINT16 a)
1265 {
1266 	switch (a) {
1267 		default: {
1268 //			bprintf(PRINT_NORMAL, _T("Z80 #2 Read => %04X\n"), a);
1269 		}
1270 	}
1271 
1272 	return 0;
1273 }
1274 
VigilanteZ80Write2(UINT16 a,UINT8)1275 static void __fastcall VigilanteZ80Write2(UINT16 a, UINT8 /*d*/)
1276 {
1277 	switch (a) {
1278 		default: {
1279 //			bprintf(PRINT_NORMAL, _T("Z80 #2 Write => %04X, %02X\n"), a, d);
1280 		}
1281 	}
1282 }
1283 
VigilanteZ80PortRead2(UINT16 a)1284 static UINT8 __fastcall VigilanteZ80PortRead2(UINT16 a)
1285 {
1286 	a &= 0xff;
1287 
1288 	switch (a) {
1289 		case 0x01: {
1290 			return BurnYM2151Read();
1291 		}
1292 
1293 		case 0x80: {
1294 			return DrvSoundLatch;
1295 		}
1296 
1297 		case 0x84: {
1298 			return DrvSamples[DrvSampleAddress];
1299 		}
1300 
1301 		default: {
1302 //			bprintf(PRINT_NORMAL, _T("Z80 #2 Port Read => %02X\n"), a);
1303 		}
1304 	}
1305 
1306 	return 0;
1307 }
1308 
VigilanteZ80PortWrite2(UINT16 a,UINT8 d)1309 static void __fastcall VigilanteZ80PortWrite2(UINT16 a, UINT8 d)
1310 {
1311 	a &= 0xff;
1312 
1313 	switch (a) {
1314 		case 0x00: {
1315 			BurnYM2151SelectRegister(d);
1316 			return;
1317 		}
1318 
1319 		case 0x01: {
1320 			BurnYM2151WriteRegister(d);
1321 			return;
1322 		}
1323 
1324 		case 0x80: {
1325 			DrvSampleAddress = (DrvSampleAddress & 0xff00) | ((d << 0) & 0x00ff);
1326 			return;
1327 		}
1328 
1329 		case 0x81: {
1330 			DrvSampleAddress = (DrvSampleAddress & 0x00ff) | ((d << 8) & 0xff00);
1331 			return;
1332 		}
1333 
1334 		case 0x82: {
1335 			DACSignedWrite(0, d);
1336 			DrvSampleAddress = (DrvSampleAddress + 1) & 0xffff;
1337 			return;
1338 		}
1339 
1340 		case 0x83: {
1341 			DrvSetVector(Z80_CLEAR);
1342 			return;
1343 		}
1344 
1345 		default: {
1346 //			bprintf(PRINT_NORMAL, _T("Z80 #2 Port Write => %02X, %02X\n"), a, d);
1347 		}
1348 	}
1349 }
1350 
BuccanrsZ80PortRead2(UINT16 a)1351 static UINT8 __fastcall BuccanrsZ80PortRead2(UINT16 a)
1352 {
1353 	a &= 0xff;
1354 
1355 	switch (a) {
1356 		case 0x00: {
1357 			return YM2203Read(0, 0);
1358 		}
1359 
1360 		case 0x02: {
1361 			return YM2203Read(1, 0);
1362 		}
1363 
1364 		case 0x80: {
1365 			return DrvSoundLatch;
1366 		}
1367 
1368 		case 0x84: {
1369 			return DrvSamples[DrvSampleAddress];
1370 		}
1371 
1372 		default: {
1373 //			bprintf(PRINT_NORMAL, _T("Z80 #2 Port Read => %02X\n"), a);
1374 		}
1375 	}
1376 
1377 	return 0;
1378 }
1379 
BuccanrsZ80PortWrite2(UINT16 a,UINT8 d)1380 static void __fastcall BuccanrsZ80PortWrite2(UINT16 a, UINT8 d)
1381 {
1382 	a &= 0xff;
1383 
1384 	switch (a) {
1385 		case 0x00: {
1386 			BurnYM2203Write(0, 0, d);
1387 			return;
1388 		}
1389 
1390 		case 0x01: {
1391 			BurnYM2203Write(0, 1, d);
1392 			return;
1393 		}
1394 
1395 		case 0x02: {
1396 			BurnYM2203Write(1, 0, d);
1397 			return;
1398 		}
1399 
1400 		case 0x03: {
1401 			BurnYM2203Write(1, 1, d);
1402 			return;
1403 		}
1404 
1405 		case 0x80: {
1406 			DrvSampleAddress = (DrvSampleAddress & 0xff00) | ((d << 0) & 0x00ff);
1407 			return;
1408 		}
1409 
1410 		case 0x81: {
1411 			DrvSampleAddress = (DrvSampleAddress & 0x00ff) | ((d << 8) & 0xff00);
1412 			return;
1413 		}
1414 
1415 		case 0x82: {
1416 			DACSignedWrite(0, d);
1417 			DrvSampleAddress = (DrvSampleAddress + 1) & 0xffff;
1418 			return;
1419 		}
1420 
1421 		case 0x83: {
1422 			DrvSetVector(Z80_CLEAR);
1423 			return;
1424 		}
1425 
1426 		default: {
1427 //			bprintf(PRINT_NORMAL, _T("Z80 #2 Port Write => %02X, %02X\n"), a, d);
1428 		}
1429 	}
1430 }
1431 
VigilantYM2151IrqHandler(INT32 Irq)1432 static void VigilantYM2151IrqHandler(INT32 Irq)
1433 {
1434 	if (Irq) {
1435 		DrvSetVector(YM2151_ASSERT);
1436 	} else {
1437 		DrvSetVector(YM2151_CLEAR);
1438 	}
1439 }
1440 
BuccanrsYM2203IRQHandler(INT32,INT32 nStatus)1441 inline static void BuccanrsYM2203IRQHandler(INT32, INT32 nStatus)
1442 {
1443 	if (nStatus & 1) {
1444 		DrvSetVector(YM2151_ASSERT);
1445 	} else {
1446 		DrvSetVector(YM2151_CLEAR);
1447 	}
1448 }
1449 
VigilantSyncDAC()1450 static INT32 VigilantSyncDAC()
1451 {
1452 	return (INT32)(float)(nBurnSoundLen * (ZetTotalCycles() / ((nCyclesTotal[1] * 55.0000) / (nBurnFPS / 100.0000))));
1453 }
1454 
1455 static INT32 CharPlaneOffsets[4]         = { 0x80000, 0x80004, 0, 4 };
1456 static INT32 CharXOffsets[8]             = { 0, 1, 2, 3, 64, 65, 66, 67 };
1457 static INT32 CharYOffsets[8]             = { 0, 8, 16, 24, 32, 40, 48, 56 };
1458 static INT32 SpritePlaneOffsets[4]       = { 0x200000, 0x200004, 0, 4 };
1459 static INT32 SpriteXOffsets[16]          = { 0, 1, 2, 3, 128, 129, 130, 131, 256, 257, 258, 259, 384, 385, 386, 387 };
1460 static INT32 SpriteYOffsets[16]          = { 0, 8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104, 112, 120 };
1461 static INT32 BackTilePlaneOffsets[4]     = { 0, 2, 4, 6 };
1462 static INT32 BackTileXOffsets[32]        = { 1, 0, 9, 8, 17, 16, 25, 24, 33, 32, 41, 40, 49, 48, 57, 56, 65, 64, 73, 72, 81, 80, 89, 88, 97, 96, 105, 104, 113, 112, 121, 120 };
1463 static INT32 BackTileYOffsets[1]         = { 0 };
1464 static INT32 BuccSpriteXOffsets[16]      = { 3, 2, 1, 0, 131, 130, 129, 128, 259, 258, 257, 256, 387, 386, 385, 384 };
1465 static INT32 BuccBackTilePlaneOffsets[4] = { 6, 4, 2, 0 };
1466 
DrvInit()1467 static INT32 DrvInit()
1468 {
1469 	INT32 nRet = 0, nLen;
1470 
1471 	BurnSetRefreshRate(55.0);
1472 
1473 	// Allocate and Blank all required memory
1474 	Mem = NULL;
1475 	MemIndex();
1476 	nLen = MemEnd - (UINT8 *)0;
1477 	if ((Mem = (UINT8 *)BurnMalloc(nLen)) == NULL) return 1;
1478 	memset(Mem, 0, nLen);
1479 	MemIndex();
1480 
1481 	DrvTempRom = (UINT8 *)BurnMalloc(0x80000);
1482 
1483 	// Load Z80 #1 Program Roms
1484 	nRet = BurnLoadRom(DrvZ80Rom1 + 0x00000,  0, 1); if (nRet != 0) return 1;
1485 	nRet = BurnLoadRom(DrvZ80Rom1 + 0x10000,  1, 1); if (nRet != 0) return 1;
1486 
1487 	// Load Z80 #2 Program Roms
1488 	nRet = BurnLoadRom(DrvZ80Rom2 + 0x00000,  2, 1); if (nRet != 0) return 1;
1489 
1490 	// Load and decode the chars
1491 	nRet = BurnLoadRom(DrvTempRom + 0x00000,  3, 1); if (nRet != 0) return 1;
1492 	nRet = BurnLoadRom(DrvTempRom + 0x10000,  4, 1); if (nRet != 0) return 1;
1493 	GfxDecode(0x1000, 4, 8, 8, CharPlaneOffsets, CharXOffsets, CharYOffsets, 0x80, DrvTempRom, DrvChars);
1494 
1495 	// Load and decode the sprites
1496 	UINT8 *tmp2 = (UINT8*)BurnMalloc(0x20000);
1497 	memset(DrvTempRom, 0, 0x80000);
1498 	nRet = BurnLoadRom(tmp2 + 0x00000,  5, 1); if (nRet != 0) return 1;
1499 	memcpy(DrvTempRom + 0x00000, tmp2 + 0x00000, 0x10000);
1500 	memcpy(DrvTempRom + 0x20000, tmp2 + 0x10000, 0x10000);
1501 	nRet = BurnLoadRom(tmp2 + 0x00000,  6, 1); if (nRet != 0) return 1;
1502 	memcpy(DrvTempRom + 0x10000, tmp2 + 0x00000, 0x10000);
1503 	memcpy(DrvTempRom + 0x30000, tmp2 + 0x10000, 0x10000);
1504 	nRet = BurnLoadRom(tmp2 + 0x00000,  7, 1); if (nRet != 0) return 1;
1505 	memcpy(DrvTempRom + 0x40000, tmp2 + 0x00000, 0x10000);
1506 	memcpy(DrvTempRom + 0x60000, tmp2 + 0x10000, 0x10000);
1507 	nRet = BurnLoadRom(tmp2 + 0x00000,  8, 1); if (nRet != 0) return 1;
1508 	memcpy(DrvTempRom + 0x50000, tmp2 + 0x00000, 0x10000);
1509 	memcpy(DrvTempRom + 0x70000, tmp2 + 0x10000, 0x10000);
1510 	GfxDecode(0x1000, 4, 16, 16, SpritePlaneOffsets, SpriteXOffsets, SpriteYOffsets, 0x200, DrvTempRom, DrvSprites);
1511 	BurnFree(tmp2);
1512 
1513 	// Load and decode the bg tiles
1514 	memset(DrvTempRom, 0, 0x80000);
1515 	nRet = BurnLoadRom(DrvTempRom + 0x00000,  9, 1); if (nRet != 0) return 1;
1516 	nRet = BurnLoadRom(DrvTempRom + 0x10000, 10, 1); if (nRet != 0) return 1;
1517 	nRet = BurnLoadRom(DrvTempRom + 0x20000, 11, 1); if (nRet != 0) return 1;
1518 	GfxDecode(0x4000, 4, 32, 1, BackTilePlaneOffsets, BackTileXOffsets, BackTileYOffsets, 0x80, DrvTempRom, DrvBackTiles);
1519 
1520 	BurnFree(DrvTempRom);
1521 
1522 	// Load sample Roms
1523 	nRet = BurnLoadRom(DrvSamples + 0x00000, 12, 1); if (nRet != 0) return 1;
1524 
1525 	// Setup the Z80 emulation
1526 	ZetInit(0);
1527 	ZetOpen(0);
1528 	ZetSetReadHandler(VigilanteZ80Read1);
1529 	ZetSetWriteHandler(VigilanteZ80Write1);
1530 	ZetSetInHandler(VigilanteZ80PortRead1);
1531 	ZetSetOutHandler(VigilanteZ80PortWrite1);
1532 	ZetMapArea(0x0000, 0x7fff, 0, DrvZ80Rom1             );
1533 	ZetMapArea(0x0000, 0x7fff, 2, DrvZ80Rom1             );
1534 	ZetMapArea(0x8000, 0xbfff, 0, DrvZ80Rom1 + 0x10000   );
1535 	ZetMapArea(0x8000, 0xbfff, 2, DrvZ80Rom1 + 0x10000   );
1536 	ZetMapArea(0xc800, 0xcfff, 0, DrvPaletteRam          );
1537 	ZetMapArea(0xc800, 0xcfff, 2, DrvPaletteRam          );
1538 	ZetMapArea(0xd000, 0xdfff, 0, DrvVideoRam            );
1539 	ZetMapArea(0xd000, 0xdfff, 1, DrvVideoRam            );
1540 	ZetMapArea(0xd000, 0xdfff, 2, DrvVideoRam            );
1541 	ZetMapArea(0xe000, 0xefff, 0, DrvZ80Ram1             );
1542 	ZetMapArea(0xe000, 0xefff, 1, DrvZ80Ram1             );
1543 	ZetMapArea(0xe000, 0xefff, 2, DrvZ80Ram1             );
1544 	ZetClose();
1545 
1546 	ZetInit(1);
1547 	ZetOpen(1);
1548 	ZetSetReadHandler(VigilanteZ80Read2);
1549 	ZetSetWriteHandler(VigilanteZ80Write2);
1550 	ZetSetInHandler(VigilanteZ80PortRead2);
1551 	ZetSetOutHandler(VigilanteZ80PortWrite2);
1552 	ZetMapArea(0x0000, 0xbfff, 0, DrvZ80Rom2             );
1553 	ZetMapArea(0x0000, 0xbfff, 2, DrvZ80Rom2             );
1554 	ZetMapArea(0xf000, 0xffff, 0, DrvZ80Ram2             );
1555 	ZetMapArea(0xf000, 0xffff, 1, DrvZ80Ram2             );
1556 	ZetMapArea(0xf000, 0xffff, 2, DrvZ80Ram2             );
1557 	ZetClose();
1558 
1559 	nCyclesTotal[0] = 3579645 / 55;   // 3579_6_45??? -dink
1560 	nCyclesTotal[1] = 3579645 / 55;
1561 
1562 	GenericTilesInit();
1563 	BurnYM2151InitBuffered(3579645, 1, NULL, 0);
1564 	BurnTimerAttachZet(3579645);
1565 	BurnYM2151SetIrqHandler(&VigilantYM2151IrqHandler);
1566 	BurnYM2151SetRoute(BURN_SND_YM2151_YM2151_ROUTE_1, 0.55, BURN_SND_ROUTE_LEFT);
1567 	BurnYM2151SetRoute(BURN_SND_YM2151_YM2151_ROUTE_2, 0.55, BURN_SND_ROUTE_RIGHT);
1568 	DACInit(0, 0, 1, VigilantSyncDAC);
1569 	DACSetRoute(0, 0.45, BURN_SND_ROUTE_BOTH);
1570 
1571 	DrvDoReset();
1572 
1573 	return 0;
1574 }
1575 
DrvcInit()1576 static INT32 DrvcInit()
1577 {
1578 	INT32 nRet = 0, nLen;
1579 
1580 	BurnSetRefreshRate(55.0);
1581 
1582 	// Allocate and Blank all required memory
1583 	Mem = NULL;
1584 	MemIndex();
1585 	nLen = MemEnd - (UINT8 *)0;
1586 	if ((Mem = (UINT8 *)BurnMalloc(nLen)) == NULL) return 1;
1587 	memset(Mem, 0, nLen);
1588 	MemIndex();
1589 
1590 	DrvTempRom = (UINT8 *)BurnMalloc(0x80000);
1591 
1592 	// Load Z80 #1 Program Roms
1593 	nRet = BurnLoadRom(DrvZ80Rom1 + 0x00000,  0, 1); if (nRet != 0) return 1;
1594 	nRet = BurnLoadRom(DrvZ80Rom1 + 0x10000,  1, 1); if (nRet != 0) return 1;
1595 
1596 	// Load Z80 #2 Program Roms
1597 	nRet = BurnLoadRom(DrvZ80Rom2 + 0x00000,  2, 1); if (nRet != 0) return 1;
1598 
1599 	// Load and decode the chars
1600 	nRet = BurnLoadRom(DrvTempRom + 0x00000,  3, 1); if (nRet != 0) return 1;
1601 	nRet = BurnLoadRom(DrvTempRom + 0x10000,  4, 1); if (nRet != 0) return 1;
1602 	GfxDecode(0x1000, 4, 8, 8, CharPlaneOffsets, CharXOffsets, CharYOffsets, 0x80, DrvTempRom, DrvChars);
1603 
1604 	// Load and decode the sprites
1605 	UINT8 *tmp2 = (UINT8*)BurnMalloc(0x20000);
1606 	memset(DrvTempRom, 0, 0x80000);
1607 	nRet = BurnLoadRom(tmp2 + 0x00000,  5, 1); if (nRet != 0) return 1;
1608 	memcpy(DrvTempRom + 0x00000, tmp2 + 0x00000, 0x10000);
1609 	memcpy(DrvTempRom + 0x20000, tmp2 + 0x10000, 0x10000);
1610 	nRet = BurnLoadRom(tmp2 + 0x00000,  6, 1); if (nRet != 0) return 1;
1611 	memcpy(DrvTempRom + 0x10000, tmp2 + 0x00000, 0x10000);
1612 	memcpy(DrvTempRom + 0x30000, tmp2 + 0x10000, 0x10000);
1613 	nRet = BurnLoadRom(tmp2 + 0x00000,  7, 1); if (nRet != 0) return 1;
1614 	memcpy(DrvTempRom + 0x40000, tmp2 + 0x00000, 0x10000);
1615 	memcpy(DrvTempRom + 0x60000, tmp2 + 0x10000, 0x10000);
1616 	nRet = BurnLoadRom(tmp2 + 0x00000,  8, 1); if (nRet != 0) return 1;
1617 	memcpy(DrvTempRom + 0x50000, tmp2 + 0x00000, 0x10000);
1618 	memcpy(DrvTempRom + 0x70000, tmp2 + 0x10000, 0x10000);
1619 	GfxDecode(0x1000, 4, 16, 16, SpritePlaneOffsets, SpriteXOffsets, SpriteYOffsets, 0x200, DrvTempRom, DrvSprites);
1620 	BurnFree(tmp2);
1621 
1622 	// Load and decode the bg tiles
1623 	memset(DrvTempRom, 0, 0x80000);
1624 	nRet = BurnLoadRom(DrvTempRom + 0x00000,  9, 1); if (nRet != 0) return 1;
1625 	nRet = BurnLoadRom(DrvTempRom + 0x20000, 10, 1); if (nRet != 0) return 1;
1626 	GfxDecode(0x4000, 4, 32, 1, BackTilePlaneOffsets, BackTileXOffsets, BackTileYOffsets, 0x80, DrvTempRom, DrvBackTiles);
1627 
1628 	BurnFree(DrvTempRom);
1629 
1630 	// Load sample Roms
1631 	nRet = BurnLoadRom(DrvSamples + 0x00000, 11, 1); if (nRet != 0) return 1;
1632 
1633 	// Setup the Z80 emulation
1634 	ZetInit(0);
1635 	ZetOpen(0);
1636 	ZetSetReadHandler(VigilanteZ80Read1);
1637 	ZetSetWriteHandler(VigilanteZ80Write1);
1638 	ZetSetInHandler(VigilanteZ80PortRead1);
1639 	ZetSetOutHandler(VigilanteZ80PortWrite1);
1640 	ZetMapArea(0x0000, 0x7fff, 0, DrvZ80Rom1             );
1641 	ZetMapArea(0x0000, 0x7fff, 2, DrvZ80Rom1             );
1642 	ZetMapArea(0x8000, 0xbfff, 0, DrvZ80Rom1 + 0x10000   );
1643 	ZetMapArea(0x8000, 0xbfff, 2, DrvZ80Rom1 + 0x10000   );
1644 	ZetMapArea(0xc800, 0xcfff, 0, DrvPaletteRam          );
1645 	ZetMapArea(0xc800, 0xcfff, 2, DrvPaletteRam          );
1646 	ZetMapArea(0xd000, 0xdfff, 0, DrvVideoRam            );
1647 	ZetMapArea(0xd000, 0xdfff, 1, DrvVideoRam            );
1648 	ZetMapArea(0xd000, 0xdfff, 2, DrvVideoRam            );
1649 	ZetMapArea(0xe000, 0xefff, 0, DrvZ80Ram1             );
1650 	ZetMapArea(0xe000, 0xefff, 1, DrvZ80Ram1             );
1651 	ZetMapArea(0xe000, 0xefff, 2, DrvZ80Ram1             );
1652 	ZetClose();
1653 
1654 	ZetInit(1);
1655 	ZetOpen(1);
1656 	ZetSetReadHandler(VigilanteZ80Read2);
1657 	ZetSetWriteHandler(VigilanteZ80Write2);
1658 	ZetSetInHandler(VigilanteZ80PortRead2);
1659 	ZetSetOutHandler(VigilanteZ80PortWrite2);
1660 	ZetMapArea(0x0000, 0xbfff, 0, DrvZ80Rom2             );
1661 	ZetMapArea(0x0000, 0xbfff, 2, DrvZ80Rom2             );
1662 	ZetMapArea(0xf000, 0xffff, 0, DrvZ80Ram2             );
1663 	ZetMapArea(0xf000, 0xffff, 1, DrvZ80Ram2             );
1664 	ZetMapArea(0xf000, 0xffff, 2, DrvZ80Ram2             );
1665 	ZetClose();
1666 
1667 	nCyclesTotal[0] = 3579645 / 55;
1668 	nCyclesTotal[1] = 3579645 / 55;
1669 
1670 	GenericTilesInit();
1671 	BurnYM2151InitBuffered(3579645, 1, NULL, 0);
1672 	BurnTimerAttachZet(3579645);
1673 	BurnYM2151SetIrqHandler(&VigilantYM2151IrqHandler);
1674 	BurnYM2151SetRoute(BURN_SND_YM2151_YM2151_ROUTE_1, 0.55, BURN_SND_ROUTE_LEFT);
1675 	BurnYM2151SetRoute(BURN_SND_YM2151_YM2151_ROUTE_2, 0.55, BURN_SND_ROUTE_RIGHT);
1676 	DACInit(0, 0, 1, VigilantSyncDAC);
1677 	DACSetRoute(0, 0.45, BURN_SND_ROUTE_BOTH);
1678 
1679 	DrvDoReset();
1680 
1681 	return 0;
1682 }
1683 
DrvbInit()1684 static INT32 DrvbInit()
1685 {
1686 	INT32 nRet = 0, nLen;
1687 
1688 	BurnSetRefreshRate(55.0);
1689 
1690 	// Allocate and Blank all required memory
1691 	Mem = NULL;
1692 	MemIndex();
1693 	nLen = MemEnd - (UINT8 *)0;
1694 	if ((Mem = (UINT8 *)BurnMalloc(nLen)) == NULL) return 1;
1695 	memset(Mem, 0, nLen);
1696 	MemIndex();
1697 
1698 	DrvTempRom = (UINT8 *)BurnMalloc(0x80000);
1699 
1700 	// Load Z80 #1 Program Roms
1701 	nRet = BurnLoadRom(DrvZ80Rom1 + 0x00000,  0, 1); if (nRet != 0) return 1;
1702 	nRet = BurnLoadRom(DrvZ80Rom1 + 0x10000,  1, 1); if (nRet != 0) return 1;
1703 
1704 	// Load Z80 #2 Program Roms
1705 	nRet = BurnLoadRom(DrvZ80Rom2 + 0x00000,  2, 1); if (nRet != 0) return 1;
1706 
1707 	// Load and decode the chars
1708 	nRet = BurnLoadRom(DrvTempRom + 0x00000,  3, 1); if (nRet != 0) return 1;
1709 	nRet = BurnLoadRom(DrvTempRom + 0x10000,  4, 1); if (nRet != 0) return 1;
1710 	GfxDecode(0x1000, 4, 8, 8, CharPlaneOffsets, CharXOffsets, CharYOffsets, 0x80, DrvTempRom, DrvChars);
1711 
1712 	// Load and decode the sprites
1713 	memset(DrvTempRom, 0, 0x80000);
1714 	nRet = BurnLoadRom(DrvTempRom + 0x00000,  5, 1); if (nRet != 0) return 1;
1715 	nRet = BurnLoadRom(DrvTempRom + 0x10000,  6, 1); if (nRet != 0) return 1;
1716 	nRet = BurnLoadRom(DrvTempRom + 0x20000,  7, 1); if (nRet != 0) return 1;
1717 	nRet = BurnLoadRom(DrvTempRom + 0x30000,  8, 1); if (nRet != 0) return 1;
1718 	nRet = BurnLoadRom(DrvTempRom + 0x40000,  9, 1); if (nRet != 0) return 1;
1719 	nRet = BurnLoadRom(DrvTempRom + 0x50000, 10, 1); if (nRet != 0) return 1;
1720 	nRet = BurnLoadRom(DrvTempRom + 0x60000, 11, 1); if (nRet != 0) return 1;
1721 	nRet = BurnLoadRom(DrvTempRom + 0x70000, 12, 1); if (nRet != 0) return 1;
1722 	GfxDecode(0x1000, 4, 16, 16, SpritePlaneOffsets, SpriteXOffsets, SpriteYOffsets, 0x200, DrvTempRom, DrvSprites);
1723 
1724 	// Load and decode the bg tiles
1725 	memset(DrvTempRom, 0, 0x80000);
1726 	nRet = BurnLoadRom(DrvTempRom + 0x00000, 13, 1); if (nRet != 0) return 1;
1727 	nRet = BurnLoadRom(DrvTempRom + 0x10000, 14, 1); if (nRet != 0) return 1;
1728 	nRet = BurnLoadRom(DrvTempRom + 0x20000, 15, 1); if (nRet != 0) return 1;
1729 	GfxDecode(0x4000, 4, 32, 1, BackTilePlaneOffsets, BackTileXOffsets, BackTileYOffsets, 0x80, DrvTempRom, DrvBackTiles);
1730 
1731 	BurnFree(DrvTempRom);
1732 
1733 	// Load sample Roms
1734 	nRet = BurnLoadRom(DrvSamples + 0x00000, 16, 1); if (nRet != 0) return 1;
1735 
1736 	// Setup the Z80 emulation
1737 	ZetInit(0);
1738 	ZetOpen(0);
1739 	ZetSetReadHandler(VigilanteZ80Read1);
1740 	ZetSetWriteHandler(VigilanteZ80Write1);
1741 	ZetSetInHandler(VigilanteZ80PortRead1);
1742 	ZetSetOutHandler(VigilanteZ80PortWrite1);
1743 	ZetMapArea(0x0000, 0x7fff, 0, DrvZ80Rom1             );
1744 	ZetMapArea(0x0000, 0x7fff, 2, DrvZ80Rom1             );
1745 	ZetMapArea(0x8000, 0xbfff, 0, DrvZ80Rom1 + 0x10000   );
1746 	ZetMapArea(0x8000, 0xbfff, 2, DrvZ80Rom1 + 0x10000   );
1747 	ZetMapArea(0xc800, 0xcfff, 0, DrvPaletteRam          );
1748 	ZetMapArea(0xc800, 0xcfff, 2, DrvPaletteRam          );
1749 	ZetMapArea(0xd000, 0xdfff, 0, DrvVideoRam            );
1750 	ZetMapArea(0xd000, 0xdfff, 1, DrvVideoRam            );
1751 	ZetMapArea(0xd000, 0xdfff, 2, DrvVideoRam            );
1752 	ZetMapArea(0xe000, 0xefff, 0, DrvZ80Ram1             );
1753 	ZetMapArea(0xe000, 0xefff, 1, DrvZ80Ram1             );
1754 	ZetMapArea(0xe000, 0xefff, 2, DrvZ80Ram1             );
1755 	ZetClose();
1756 
1757 	ZetInit(1);
1758 	ZetOpen(1);
1759 	ZetSetReadHandler(VigilanteZ80Read2);
1760 	ZetSetWriteHandler(VigilanteZ80Write2);
1761 	ZetSetInHandler(VigilanteZ80PortRead2);
1762 	ZetSetOutHandler(VigilanteZ80PortWrite2);
1763 	ZetMapArea(0x0000, 0xbfff, 0, DrvZ80Rom2             );
1764 	ZetMapArea(0x0000, 0xbfff, 2, DrvZ80Rom2             );
1765 	ZetMapArea(0xf000, 0xffff, 0, DrvZ80Ram2             );
1766 	ZetMapArea(0xf000, 0xffff, 1, DrvZ80Ram2             );
1767 	ZetMapArea(0xf000, 0xffff, 2, DrvZ80Ram2             );
1768 	ZetClose();
1769 
1770 	nCyclesTotal[0] = 3579645 / 55;
1771 	nCyclesTotal[1] = 3579645 / 55;
1772 
1773 	GenericTilesInit();
1774 	BurnYM2151InitBuffered(3579645, 1, NULL, 0);
1775 	BurnTimerAttachZet(3579645);
1776 	BurnYM2151SetIrqHandler(&VigilantYM2151IrqHandler);
1777 	BurnYM2151SetRoute(BURN_SND_YM2151_YM2151_ROUTE_1, 0.55, BURN_SND_ROUTE_LEFT);
1778 	BurnYM2151SetRoute(BURN_SND_YM2151_YM2151_ROUTE_2, 0.55, BURN_SND_ROUTE_RIGHT);
1779 	DACInit(0, 0, 1, VigilantSyncDAC);
1780 	DACSetRoute(0, 0.45, BURN_SND_ROUTE_BOTH);
1781 
1782 	DrvDoReset();
1783 
1784 	return 0;
1785 }
1786 
BuccanrsInit()1787 static INT32 BuccanrsInit()
1788 {
1789 	INT32 nRet = 0, nLen;
1790 
1791 	BurnSetRefreshRate(55.0);
1792 
1793 	// Allocate and Blank all required memory
1794 	Mem = NULL;
1795 	MemIndex();
1796 	nLen = MemEnd - (UINT8 *)0;
1797 	if ((Mem = (UINT8 *)BurnMalloc(nLen)) == NULL) return 1;
1798 	memset(Mem, 0, nLen);
1799 	MemIndex();
1800 
1801 	DrvTempRom = (UINT8 *)BurnMalloc(0x80000);
1802 
1803 	// Load Z80 #1 Program Roms
1804 	nRet = BurnLoadRom(DrvZ80Rom1 + 0x00000,  0, 1); if (nRet != 0) return 1;
1805 	nRet = BurnLoadRom(DrvZ80Rom1 + 0x10000,  1, 1); if (nRet != 0) return 1;
1806 
1807 	// Load Z80 #2 Program Roms
1808 	nRet = BurnLoadRom(DrvZ80Rom2 + 0x00000,  2, 1); if (nRet != 0) return 1;
1809 
1810 	// Load and decode the chars
1811 	nRet = BurnLoadRom(DrvTempRom + 0x00000,  3, 1); if (nRet != 0) return 1;
1812 	nRet = BurnLoadRom(DrvTempRom + 0x10000,  4, 1); if (nRet != 0) return 1;
1813 	GfxDecode(0x1000, 4, 8, 8, CharPlaneOffsets, CharXOffsets, CharYOffsets, 0x80, DrvTempRom, DrvChars);
1814 
1815 	// Load and decode the sprites
1816 	memset(DrvTempRom, 0, 0x80000);
1817 	nRet = BurnLoadRom(DrvTempRom + 0x00000,  5, 1); if (nRet != 0) return 1;
1818 	memcpy(DrvTempRom + 0x20000, DrvTempRom + 0x10000, 0x10000);
1819 	nRet = BurnLoadRom(DrvTempRom + 0x10000,  6, 1); if (nRet != 0) return 1;
1820 	nRet = BurnLoadRom(DrvTempRom + 0x40000,  7, 1); if (nRet != 0) return 1;
1821 	memcpy(DrvTempRom + 0x60000, DrvTempRom + 0x50000, 0x10000);
1822 	nRet = BurnLoadRom(DrvTempRom + 0x50000,  8, 1); if (nRet != 0) return 1;
1823 	GfxDecode(0x1000, 4, 16, 16, SpritePlaneOffsets, BuccSpriteXOffsets, SpriteYOffsets, 0x200, DrvTempRom, DrvSprites);
1824 
1825 	// Load and decode the bg tiles
1826 	memset(DrvTempRom, 0, 0x80000);
1827 	nRet = BurnLoadRom(DrvTempRom + 0x20000,  9, 1); if (nRet != 0) return 1;
1828 	nRet = BurnLoadRom(DrvTempRom + 0x00000, 10, 1); if (nRet != 0) return 1;
1829 	GfxDecode(0x4000, 4, 32, 1, BuccBackTilePlaneOffsets, BackTileXOffsets, BackTileYOffsets, 0x80, DrvTempRom, DrvBackTiles);
1830 
1831 	BurnFree(DrvTempRom);
1832 
1833 	// Load sample Roms
1834 	nRet = BurnLoadRom(DrvSamples + 0x00000, 11, 1); if (nRet != 0) return 1;
1835 
1836 	// Setup the Z80 emulation
1837 	ZetInit(0);
1838 	ZetOpen(0);
1839 	ZetSetReadHandler(VigilanteZ80Read1);
1840 	ZetSetWriteHandler(VigilanteZ80Write1);
1841 	ZetSetInHandler(BuccanrsZ80PortRead1);
1842 	ZetSetOutHandler(VigilanteZ80PortWrite1);
1843 	if (!strcmp(BurnDrvGetTextA(DRV_NAME), "buccanrsa")) ZetSetInHandler(BuccanrsaZ80PortRead1);
1844 	ZetMapArea(0x0000, 0x7fff, 0, DrvZ80Rom1             );
1845 	ZetMapArea(0x0000, 0x7fff, 2, DrvZ80Rom1             );
1846 	ZetMapArea(0x8000, 0xbfff, 0, DrvZ80Rom1 + 0x10000   );
1847 	ZetMapArea(0x8000, 0xbfff, 2, DrvZ80Rom1 + 0x10000   );
1848 	ZetMapArea(0xc800, 0xcfff, 0, DrvPaletteRam          );
1849 	ZetMapArea(0xc800, 0xcfff, 2, DrvPaletteRam          );
1850 	ZetMapArea(0xd000, 0xdfff, 0, DrvVideoRam            );
1851 	ZetMapArea(0xd000, 0xdfff, 1, DrvVideoRam            );
1852 	ZetMapArea(0xd000, 0xdfff, 2, DrvVideoRam            );
1853 	ZetMapArea(0xe000, 0xefff, 0, DrvZ80Ram1             );
1854 	ZetMapArea(0xe000, 0xefff, 1, DrvZ80Ram1             );
1855 	ZetMapArea(0xe000, 0xefff, 2, DrvZ80Ram1             );
1856 	ZetClose();
1857 
1858 	ZetInit(1);
1859 	ZetOpen(1);
1860 	ZetSetReadHandler(VigilanteZ80Read2);
1861 	ZetSetWriteHandler(VigilanteZ80Write2);
1862 	ZetSetInHandler(BuccanrsZ80PortRead2);
1863 	ZetSetOutHandler(BuccanrsZ80PortWrite2);
1864 	ZetMapArea(0x0000, 0xbfff, 0, DrvZ80Rom2             );
1865 	ZetMapArea(0x0000, 0xbfff, 2, DrvZ80Rom2             );
1866 	ZetMapArea(0xf000, 0xffff, 0, DrvZ80Ram2             );
1867 	ZetMapArea(0xf000, 0xffff, 1, DrvZ80Ram2             );
1868 	ZetMapArea(0xf000, 0xffff, 2, DrvZ80Ram2             );
1869 	ZetClose();
1870 
1871 	nCyclesTotal[0] = 5688800 / 55;
1872 	nCyclesTotal[1] = (18432000 / 6) / 55;
1873 
1874 	GenericTilesInit();
1875 
1876 	DrvHasYM2203 = 1;
1877 	BurnYM2203Init(2, 18432000 / 6, &BuccanrsYM2203IRQHandler, 0);
1878 	BurnTimerAttachZet(18432000 / 6);
1879 	BurnYM2203SetRoute(0, BURN_SND_YM2203_YM2203_ROUTE, 0.50, BURN_SND_ROUTE_BOTH);
1880 	BurnYM2203SetRoute(0, BURN_SND_YM2203_AY8910_ROUTE_1, 0.35, BURN_SND_ROUTE_BOTH);
1881 	BurnYM2203SetRoute(0, BURN_SND_YM2203_AY8910_ROUTE_2, 0.35, BURN_SND_ROUTE_BOTH);
1882 	BurnYM2203SetRoute(0, BURN_SND_YM2203_AY8910_ROUTE_3, 0.35, BURN_SND_ROUTE_BOTH);
1883 	BurnYM2203SetRoute(1, BURN_SND_YM2203_YM2203_ROUTE, 0.50, BURN_SND_ROUTE_BOTH);
1884 	BurnYM2203SetRoute(1, BURN_SND_YM2203_AY8910_ROUTE_1, 0.35, BURN_SND_ROUTE_BOTH);
1885 	BurnYM2203SetRoute(1, BURN_SND_YM2203_AY8910_ROUTE_2, 0.35, BURN_SND_ROUTE_BOTH);
1886 	BurnYM2203SetRoute(1, BURN_SND_YM2203_AY8910_ROUTE_3, 0.35, BURN_SND_ROUTE_BOTH);
1887 
1888 	DACInit(0, 0, 1, VigilantSyncDAC);
1889 	DACSetRoute(0, 0.35, BURN_SND_ROUTE_BOTH);
1890 
1891 	DrvDoReset();
1892 
1893 	return 0;
1894 }
1895 
KikcubicInit()1896 static INT32 KikcubicInit()
1897 {
1898 	INT32 nRet = 0, nLen;
1899 	BurnSetRefreshRate(55.0);
1900 
1901 	// Allocate and Blank all required memory
1902 	Mem = NULL;
1903 	MemIndex();
1904 	nLen = MemEnd - (UINT8 *)0;
1905 	if ((Mem = (UINT8 *)BurnMalloc(nLen)) == NULL) return 1;
1906 	memset(Mem, 0, nLen);
1907 	MemIndex();
1908 
1909 	DrvTempRom = (UINT8 *)BurnMalloc(0x80000);
1910 
1911 	if (!strcmp(BurnDrvGetTextA(DRV_NAME), "kikcubicb")) {
1912 		// Load Z80 #1 Program Roms
1913 		nRet = BurnLoadRom(DrvZ80Rom1 + 0x00000,  0, 1); if (nRet != 0) return 1;
1914 		nRet = BurnLoadRom(DrvZ80Rom1 + 0x10000,  1, 1); if (nRet != 0) return 1;
1915 		nRet = BurnLoadRom(DrvZ80Rom1 + 0x20000,  2, 1); if (nRet != 0) return 1;
1916 		nRet = BurnLoadRom(DrvZ80Rom1 + 0x28000,  2, 1); if (nRet != 0) return 1;
1917 
1918 		// Load Z80 #2 Program Roms
1919 		nRet = BurnLoadRom(DrvZ80Rom2 + 0x00000,  3, 1); if (nRet != 0) return 1;
1920 
1921 		// Load and decode the chars
1922 		nRet = BurnLoadRom(DrvTempRom + 0x00000,  4, 1); if (nRet != 0) return 1;
1923 		nRet = BurnLoadRom(DrvTempRom + 0x10000,  5, 1); if (nRet != 0) return 1;
1924 		GfxDecode(0x1000, 4, 8, 8, CharPlaneOffsets, CharXOffsets, CharYOffsets, 0x80, DrvTempRom, DrvChars);
1925 
1926 		// Load and decode the sprites
1927 		memset(DrvTempRom, 0, 0x80000);
1928 		nRet = BurnLoadRom(DrvTempRom + 0x00000,  6, 1); if (nRet != 0) return 1;
1929 		nRet = BurnLoadRom(DrvTempRom + 0x20000,  6, 1); if (nRet != 0) return 1;
1930 		nRet = BurnLoadRom(DrvTempRom + 0x10000,  7, 1); if (nRet != 0) return 1;
1931 		nRet = BurnLoadRom(DrvTempRom + 0x30000,  7, 1); if (nRet != 0) return 1;
1932 		nRet = BurnLoadRom(DrvTempRom + 0x40000,  8, 1); if (nRet != 0) return 1;
1933 		nRet = BurnLoadRom(DrvTempRom + 0x60000,  8, 1); if (nRet != 0) return 1;
1934 		nRet = BurnLoadRom(DrvTempRom + 0x50000,  9, 1); if (nRet != 0) return 1;
1935 		nRet = BurnLoadRom(DrvTempRom + 0x70000,  9, 1); if (nRet != 0) return 1;
1936 		GfxDecode(0x1000, 4, 16, 16, SpritePlaneOffsets, SpriteXOffsets, SpriteYOffsets, 0x200, DrvTempRom, DrvSprites);
1937 
1938 		// Load sample Roms
1939 		nRet = BurnLoadRom(DrvSamples + 0x00000, 10, 1); if (nRet != 0) return 1;
1940 	} else {
1941 		// Load Z80 #1 Program Roms
1942 		nRet = BurnLoadRom(DrvZ80Rom1 + 0x00000,  0, 1); if (nRet != 0) return 1;
1943 		nRet = BurnLoadRom(DrvZ80Rom1 + 0x10000,  1, 1); if (nRet != 0) return 1;
1944 		nRet = BurnLoadRom(DrvZ80Rom1 + 0x20000,  2, 1); if (nRet != 0) return 1;
1945 
1946 		// Load Z80 #2 Program Roms
1947 		nRet = BurnLoadRom(DrvZ80Rom2 + 0x00000,  3, 1); if (nRet != 0) return 1;
1948 
1949 		// Load and decode the chars
1950 		nRet = BurnLoadRom(DrvTempRom + 0x00000,  4, 1); if (nRet != 0) return 1;
1951 		nRet = BurnLoadRom(DrvTempRom + 0x10000,  5, 1); if (nRet != 0) return 1;
1952 		GfxDecode(0x1000, 4, 8, 8, CharPlaneOffsets, CharXOffsets, CharYOffsets, 0x80, DrvTempRom, DrvChars);
1953 
1954 		// Load and decode the sprites
1955 		memset(DrvTempRom, 0, 0x80000);
1956 		nRet = BurnLoadRom(DrvTempRom + 0x00000,  6, 1); if (nRet != 0) return 1;
1957 		nRet = BurnLoadRom(DrvTempRom + 0x40000,  7, 1); if (nRet != 0) return 1;
1958 		GfxDecode(0x1000, 4, 16, 16, SpritePlaneOffsets, SpriteXOffsets, SpriteYOffsets, 0x200, DrvTempRom, DrvSprites);
1959 
1960 		// Load sample Roms
1961 		nRet = BurnLoadRom(DrvSamples + 0x00000, 8, 1); if (nRet != 0) return 1;
1962 	}
1963 
1964 	BurnFree(DrvTempRom);
1965 
1966 	// Setup the Z80 emulation
1967 	ZetInit(0);
1968 	ZetOpen(0);
1969 	ZetSetReadHandler(KikcubicZ80Read1);
1970 	ZetSetWriteHandler(KikcubicZ80Write1);
1971 	ZetSetInHandler(KikcubicZ80PortRead1);
1972 	ZetSetOutHandler(KikcubicZ80PortWrite1);
1973 	ZetMapArea(0x0000, 0x7fff, 0, DrvZ80Rom1             );
1974 	ZetMapArea(0x0000, 0x7fff, 2, DrvZ80Rom1             );
1975 	ZetMapArea(0x8000, 0xbfff, 0, DrvZ80Rom1 + 0x10000   );
1976 	ZetMapArea(0x8000, 0xbfff, 2, DrvZ80Rom1 + 0x10000   );
1977 	ZetMapArea(0xc000, 0xc0ff, 0, DrvSpriteRam           );
1978 	ZetMapArea(0xc000, 0xc0ff, 1, DrvSpriteRam           );
1979 	ZetMapArea(0xc000, 0xc0ff, 2, DrvSpriteRam           );
1980 	ZetMapArea(0xc800, 0xcaff, 0, DrvPaletteRam          );
1981 	ZetMapArea(0xc800, 0xcaff, 2, DrvPaletteRam          );
1982 	ZetMapArea(0xd000, 0xdfff, 0, DrvVideoRam            );
1983 	ZetMapArea(0xd000, 0xdfff, 1, DrvVideoRam            );
1984 	ZetMapArea(0xd000, 0xdfff, 2, DrvVideoRam            );
1985 	ZetMapArea(0xe000, 0xffff, 0, DrvZ80Ram1             );
1986 	ZetMapArea(0xe000, 0xffff, 1, DrvZ80Ram1             );
1987 	ZetMapArea(0xe000, 0xffff, 2, DrvZ80Ram1             );
1988 	ZetClose();
1989 
1990 	ZetInit(1);
1991 	ZetOpen(1);
1992 	ZetSetReadHandler(VigilanteZ80Read2);
1993 	ZetSetWriteHandler(VigilanteZ80Write2);
1994 	ZetSetInHandler(VigilanteZ80PortRead2);
1995 	ZetSetOutHandler(VigilanteZ80PortWrite2);
1996 	ZetMapArea(0x0000, 0xbfff, 0, DrvZ80Rom2             );
1997 	ZetMapArea(0x0000, 0xbfff, 2, DrvZ80Rom2             );
1998 	ZetMapArea(0xf000, 0xffff, 0, DrvZ80Ram2             );
1999 	ZetMapArea(0xf000, 0xffff, 1, DrvZ80Ram2             );
2000 	ZetMapArea(0xf000, 0xffff, 2, DrvZ80Ram2             );
2001 	ZetClose();
2002 
2003 	nCyclesTotal[0] = 3579645 / 55;
2004 	nCyclesTotal[1] = 3579645 / 55;
2005 
2006 	GenericTilesInit();
2007 	BurnYM2151InitBuffered(3579645, 1, NULL, 0);
2008 	BurnTimerAttachZet(3579645);
2009 	BurnYM2151SetIrqHandler(&VigilantYM2151IrqHandler);
2010 	BurnYM2151SetRoute(BURN_SND_YM2151_YM2151_ROUTE_1, 0.55, BURN_SND_ROUTE_LEFT);
2011 	BurnYM2151SetRoute(BURN_SND_YM2151_YM2151_ROUTE_2, 0.55, BURN_SND_ROUTE_RIGHT);
2012 	DACInit(0, 0, 1, VigilantSyncDAC);
2013 	DACSetRoute(0, 1.00, BURN_SND_ROUTE_BOTH);
2014 
2015 	DrvKikcubicDraw = 1;
2016 
2017 	DrvDoReset();
2018 
2019 	return 0;
2020 }
2021 
DrvExit()2022 static INT32 DrvExit()
2023 {
2024 	ZetExit();
2025 	if (DrvHasYM2203) {
2026 		BurnYM2203Exit();
2027 	} else {
2028 		BurnYM2151Exit();
2029 	}
2030 	DACExit();
2031 
2032 	GenericTilesExit();
2033 
2034 	BurnFree(Mem);
2035 
2036 	DrvRomBank = 0;
2037 	DrvSoundLatch = 0;
2038 	DrvIrqVector = 0;
2039 	DrvRearColour = 0;
2040 	DrvRearDisable = 0;
2041 	DrvHorizScrollLo = 0;
2042 	DrvHorizScrollHi = 0;
2043 	DrvRearHorizScrollLo = 0;
2044 	DrvRearHorizScrollHi = 0;
2045 	DrvSampleAddress = 0;
2046 
2047 	DrvHasYM2203 = 0;
2048 	DrvKikcubicDraw = 0;
2049 
2050 	return 0;
2051 }
2052 
DrvRenderBackground()2053 static void DrvRenderBackground()
2054 {
2055 	INT32 CharCode = 0;
2056 	INT32 Scroll = 0x17a - (DrvRearHorizScrollLo + DrvRearHorizScrollHi);
2057 	if (Scroll > 0) Scroll -= 2048;
2058 
2059 	for (INT32 i = 0; i < 16; i++) {
2060 		INT32 r, g, b;
2061 
2062 		r = (DrvPaletteRam[0x400 + 16 * DrvRearColour + i] << 3) & 0xff;
2063 		g = (DrvPaletteRam[0x500 + 16 * DrvRearColour + i] << 3) & 0xff;
2064 		b = (DrvPaletteRam[0x600 + 16 * DrvRearColour + i] << 3) & 0xff;
2065 
2066 		DrvPalette[512 + i] = BurnHighCol(r, g, b, 0);
2067 
2068 		r = (DrvPaletteRam[0x400 + 16 * DrvRearColour + 32 + i] << 3) & 0xff;
2069 		g = (DrvPaletteRam[0x500 + 16 * DrvRearColour + 32 + i] << 3) & 0xff;
2070 		b = (DrvPaletteRam[0x600 + 16 * DrvRearColour + 32 + i] << 3) & 0xff;
2071 
2072 		DrvPalette[512 + 16 + i] = BurnHighCol(r, g, b, 0);
2073 	}
2074 
2075 	for (INT32 Page = 0; Page < 4; Page++) {
2076 		for (INT32 Row = 0; Row < 256; Row++) {
2077 			for (INT32 Col = 0; Col < 512; Col += 32) {
2078 				INT32 Colour = (Row < 128) ? 0 : 1;
2079 				UINT32 nPalette = 512 | (Colour << 4);
2080 
2081 				for (INT32 px = 0; px < 32; px++) {
2082 					UINT8 c = DrvBackTiles[(CharCode * 32) + px];
2083 					INT32 xPos = (512 * Page) + Col + px + Scroll;
2084 
2085 					if (Row >= 0 && Row < nScreenHeight) {
2086 						UINT16* pPixel = pTransDraw + (Row * nScreenWidth);
2087 
2088 						if (xPos >= 0 && xPos < nScreenWidth) {
2089 							pPixel[xPos] = c | nPalette;
2090 						}
2091 					}
2092 				}
2093 
2094 				CharCode++;
2095 			}
2096 		}
2097 	}
2098 }
2099 
DrvDrawForeground(INT32 Priority,INT32 Opaque)2100 static void DrvDrawForeground(INT32 Priority, INT32 Opaque)
2101 {
2102 	INT32 Scroll = -(DrvHorizScrollLo + DrvHorizScrollHi);
2103 
2104 	for (INT32 Offset = 0; Offset < 0x1000; Offset += 2) {
2105 		INT32 sy = 8 * ((Offset / 2) / 64);
2106 		INT32 sx = 8 * ((Offset / 2) % 64);
2107 		INT32 Attr = DrvVideoRam[Offset + 1];
2108 		INT32 Colour = Attr & 0x0f;
2109 		INT32 Tile = DrvVideoRam[Offset + 0] | ((Attr & 0xf0) << 4);
2110 
2111 		if (Priority) {
2112 			// Sprite masking
2113 			if ((Colour & 0x0c) == 0x0c) {
2114 				if (sy >= 48) {
2115 					sx = (sx + Scroll) & 0x1ff;
2116 
2117 					sx -= 128;
2118 
2119 					INT32 px, py;
2120 					UINT32 nPalette = 256 | (Colour << 4);
2121 
2122 					for (py = 0; py < 8; py++) {
2123 						for (px = 0; px < 8; px++) {
2124 							UINT8 c = DrvChars[(Tile * 64) + (py * 8) + px];
2125 
2126 							if (((0xff >> c) & 0x01) == 0) {
2127 								INT32 xPos = sx + px;
2128 								INT32 yPos = sy + py;
2129 
2130 								if (yPos >= 0 && yPos < nScreenHeight) {
2131 									UINT16* pPixel = pTransDraw + (yPos * nScreenWidth);
2132 
2133 									if (xPos >= 0 && xPos < nScreenWidth) {
2134 										pPixel[xPos] = c | nPalette;
2135 									}
2136 								}
2137 							}
2138 						}
2139 					}
2140 				}
2141 			}
2142 		} else {
2143 			if (sy >= 48) sx = (sx + Scroll) & 0x1ff;
2144 
2145 			sx -= 128;
2146 
2147 			if (sx >= 0 && sx < (nScreenWidth - 8) && sy >= 0 && sy < (nScreenHeight - 8)) {
2148 				if (Opaque || Colour >= 4) {
2149 					Render8x8Tile(pTransDraw, Tile, sx, sy, Colour, 4, 256, DrvChars);
2150 				} else {
2151 					Render8x8Tile_Mask(pTransDraw, Tile, sx, sy, Colour, 4, 0, 256, DrvChars);
2152 				}
2153 			} else {
2154 				if (Opaque || Colour >= 4) {
2155 					Render8x8Tile_Clip(pTransDraw, Tile, sx, sy, Colour, 4, 256, DrvChars);
2156 				} else {
2157 					Render8x8Tile_Mask_Clip(pTransDraw, Tile, sx, sy, Colour, 4, 0, 256, DrvChars);
2158 				}
2159 			}
2160 		}
2161 	}
2162 }
2163 
DrvDrawSprites()2164 static void DrvDrawSprites()
2165 {
2166 	INT32 DrvSpriteRamSize = 0xc0;
2167 	if (DrvKikcubicDraw) DrvSpriteRamSize = 0x100;
2168 
2169 	for (INT32 Offset = 0; Offset < DrvSpriteRamSize; Offset += 8) {
2170 		INT32 Code, Colour, sx, sy, xFlip, yFlip, h;
2171 
2172 		Code = DrvSpriteRam[Offset + 4] | ((DrvSpriteRam[Offset + 5] & 0x0f) << 8);
2173 		Colour = DrvSpriteRam[Offset + 0] & 0x0f;
2174 		sx = (DrvSpriteRam[Offset + 6] | ((DrvSpriteRam[Offset + 7] & 0x01) << 8));
2175 		sy = 256 + 128 - (DrvSpriteRam[Offset + 2] | ((DrvSpriteRam[Offset + 3] & 0x01) << 8));
2176 		xFlip = DrvSpriteRam[Offset + 5] & 0x40;
2177 		yFlip = DrvSpriteRam[Offset + 5] & 0x80;
2178 		h = 1 << ((DrvSpriteRam[Offset + 5] & 0x30) >> 4);
2179 		sy -= 16 * h;
2180 
2181 		Code &= ~(h - 1);
2182 
2183 		if (DrvKikcubicDraw) {
2184 			sx -= 64;
2185 		} else {
2186 			sx -= 128;
2187 		}
2188 
2189 		for (INT32 y = 0; y < h; y++) {
2190 			INT32 c = Code;
2191 
2192 			if (yFlip) {
2193 				c += h - 1 - y;
2194 			} else {
2195 				c += y;
2196 			}
2197 
2198 			if (sx > 16 && sx < (nScreenWidth - 16) && (sy + (16 * y)) > 16 && (sy + (16 * y)) < (nScreenHeight - 16)) {
2199 				if (xFlip) {
2200 					if (yFlip) {
2201 						Render16x16Tile_Mask_FlipXY(pTransDraw, c, sx, sy + (16 * y), Colour, 4, 0, 0, DrvSprites);
2202 					} else {
2203 						Render16x16Tile_Mask_FlipX(pTransDraw, c, sx, sy + (16 * y), Colour, 4, 0, 0, DrvSprites);
2204 					}
2205 				} else {
2206 					if (yFlip) {
2207 						Render16x16Tile_Mask_FlipY(pTransDraw, c, sx, sy + (16 * y), Colour, 4, 0, 0, DrvSprites);
2208 					} else {
2209 						Render16x16Tile_Mask(pTransDraw, c, sx, sy + (16 * y), Colour, 4, 0, 0, DrvSprites);
2210 					}
2211 				}
2212 			} else {
2213 				if (xFlip) {
2214 					if (yFlip) {
2215 						Render16x16Tile_Mask_FlipXY_Clip(pTransDraw, c, sx, sy + (16 * y), Colour, 4, 0, 0, DrvSprites);
2216 					} else {
2217 						Render16x16Tile_Mask_FlipX_Clip(pTransDraw, c, sx, sy + (16 * y), Colour, 4, 0, 0, DrvSprites);
2218 					}
2219 				} else {
2220 					if (yFlip) {
2221 						Render16x16Tile_Mask_FlipY_Clip(pTransDraw, c, sx, sy + (16 * y), Colour, 4, 0, 0, DrvSprites);
2222 					} else {
2223 						Render16x16Tile_Mask_Clip(pTransDraw, c, sx, sy + (16 * y), Colour, 4, 0, 0, DrvSprites);
2224 					}
2225 				}
2226 			}
2227 		}
2228 	}
2229 }
2230 
DrvDraw()2231 static INT32 DrvDraw()
2232 {
2233 	BurnTransferClear();
2234 
2235 	if (DrvRearDisable) {
2236 		DrvDrawForeground(0, 1);
2237 		DrvDrawSprites();
2238 		DrvDrawForeground(1, 0);
2239 	} else {
2240 		DrvRenderBackground();
2241 		DrvDrawForeground(0, 0);
2242 		DrvDrawSprites();
2243 		DrvDrawForeground(1, 0);
2244 	}
2245 
2246 	BurnTransferCopy(DrvPalette);
2247 
2248 	return 0;
2249 }
2250 
KikcubicDraw()2251 static INT32 KikcubicDraw()
2252 {
2253 	BurnTransferClear();
2254 
2255 	for (INT32 Offset = 0; Offset < 0x1000; Offset += 2) {
2256 		INT32 sy = 8 * ((Offset / 2) / 64);
2257 		INT32 sx = 8 * ((Offset / 2) % 64);
2258 		INT32 Attr = DrvVideoRam[Offset + 1];
2259 		INT32 Colour = (Attr & 0xf0) >> 4;
2260 		INT32 Code = DrvVideoRam[Offset] | ((Attr & 0x0f) << 8);
2261 
2262 		sx -= 64;
2263 		if (sx >= 0 && sx < (nScreenWidth - 8) && sy >= 0 && sy < (nScreenHeight - 8)) {
2264 			Render8x8Tile(pTransDraw, Code, sx, sy, Colour, 4, 0, DrvChars);
2265 		} else {
2266 			Render8x8Tile_Clip(pTransDraw, Code, sx, sy, Colour, 4, 0, DrvChars);
2267 		}
2268 	}
2269 
2270 	DrvDrawSprites();
2271 	BurnTransferCopy(DrvPalette);
2272 
2273 	return 0;
2274 }
2275 
DrvFrame()2276 static INT32 DrvFrame()
2277 {
2278 	INT32 nInterleave = 256; // dac needs 128 NMIs
2279 
2280 	if (DrvReset) DrvDoReset();
2281 
2282 	DrvMakeInputs();
2283 
2284 	nCyclesDone[0] = nCyclesDone[1] = 0;
2285 
2286 	ZetNewFrame();
2287 
2288 	for (INT32 i = 0; i < nInterleave; i++) {
2289 		ZetOpen(0);
2290 		CPU_RUN(0, Zet);
2291 		if (i == (nInterleave - 1)) ZetSetIRQLine(0, CPU_IRQSTATUS_AUTO);
2292 		ZetClose();
2293 
2294 		ZetOpen(1);
2295 		CPU_RUN_TIMER(1);
2296 		if (i & 1) ZetNmi();
2297 		ZetClose();
2298 	}
2299 
2300 	ZetOpen(1);
2301 	if (pBurnSoundOut && !DrvHasYM2203) {
2302 		BurnYM2151Render(pBurnSoundOut, nBurnSoundLen);
2303 		DACUpdate(pBurnSoundOut, nBurnSoundLen);
2304 	}
2305 
2306 	if (DrvHasYM2203 && pBurnSoundOut) {
2307 		BurnYM2203Update(pBurnSoundOut, nBurnSoundLen);
2308 		DACUpdate(pBurnSoundOut, nBurnSoundLen);
2309 	}
2310 	ZetClose();
2311 
2312 	if (pBurnDraw) {
2313 		if (DrvKikcubicDraw) {
2314 			KikcubicDraw();
2315 		} else {
2316 			DrvDraw();
2317 		}
2318 	}
2319 
2320 	return 0;
2321 }
2322 
DrvScan(INT32 nAction,INT32 * pnMin)2323 static INT32 DrvScan(INT32 nAction, INT32 *pnMin)
2324 {
2325 	struct BurnArea ba;
2326 
2327 	if (pnMin != NULL) {			// Return minimum compatible version
2328 		*pnMin = 0x029705;
2329 	}
2330 
2331 	if (nAction & ACB_MEMORY_RAM) {
2332 		memset(&ba, 0, sizeof(ba));
2333 		ba.Data	  = RamStart;
2334 		ba.nLen	  = RamEnd-RamStart;
2335 		ba.szName = "All Ram";
2336 		BurnAcb(&ba);
2337 	}
2338 
2339 	if (nAction & ACB_DRIVER_DATA) {
2340 		ZetScan(nAction);
2341 		if (DrvHasYM2203) {
2342 			BurnYM2203Scan(nAction, pnMin);
2343 		} else {
2344 			BurnYM2151Scan(nAction, pnMin);
2345 		}
2346 		DACScan(nAction, pnMin);
2347 
2348 		SCAN_VAR(DrvRomBank);
2349 		SCAN_VAR(DrvSoundLatch);
2350 		SCAN_VAR(DrvIrqVector);
2351 
2352 		SCAN_VAR(DrvRearColour);
2353 		SCAN_VAR(DrvRearDisable);
2354 		SCAN_VAR(DrvHorizScrollLo);
2355 		SCAN_VAR(DrvHorizScrollHi);
2356 		SCAN_VAR(DrvRearHorizScrollLo);
2357 		SCAN_VAR(DrvRearHorizScrollHi);
2358 		SCAN_VAR(DrvSampleAddress);
2359 	}
2360 
2361 	if (nAction & ACB_WRITE) {
2362 		ZetOpen(0);
2363 		bank_switch(DrvRomBank);
2364 		ZetClose();
2365 	}
2366 
2367 	return 0;
2368 }
2369 
2370 #undef VECTOR_INIT
2371 #undef YM2151_ASSERT
2372 #undef YM2151_CLEAR
2373 #undef Z80_ASSERT
2374 #undef Z80_CLEAR
2375 
2376 struct BurnDriver BurnDrvVigilant = {
2377 	"vigilant", NULL, NULL, NULL, "1988",
2378 	"Vigilante (World, Rev E)\0", NULL, "Irem", "Miscellaneous",
2379 	NULL, NULL, NULL, NULL,
2380 	BDF_GAME_WORKING, 2, HARDWARE_IREM_MISC, GBF_SCRFIGHT, 0,
2381 	NULL, DrvRomInfo, DrvRomName, NULL, NULL, NULL, NULL, DrvInputInfo, DrvDIPInfo,
2382 	DrvInit, DrvExit, DrvFrame, DrvDraw, DrvScan,
2383 	NULL, 544, 256, 256, 4, 3
2384 };
2385 
2386 struct BurnDriver BurnDrvVigilanta = {
2387 	"vigilanta", "vigilant", NULL, NULL, "1988",
2388 	"Vigilante (World, Rev A)\0", NULL, "Irem", "Miscellaneous",
2389 	NULL, NULL, NULL, NULL,
2390 	BDF_GAME_WORKING | BDF_CLONE, 2, HARDWARE_IREM_MISC, GBF_SCRFIGHT, 0,
2391 	NULL, VigilantaRomInfo, VigilantaRomName, NULL, NULL, NULL, NULL, DrvInputInfo, DrvDIPInfo,
2392 	DrvcInit, DrvExit, DrvFrame, DrvDraw, DrvScan,
2393 	NULL, 544, 256, 256, 4, 3
2394 };
2395 
2396 struct BurnDriver BurnDrvVigilantb = {
2397 	"vigilantb", "vigilant", NULL, NULL, "1988",
2398 	"Vigilante (US, Rev B)\0", NULL, "Irem (Data East License)", "Miscellaneous",
2399 	NULL, NULL, NULL, NULL,
2400 	BDF_GAME_WORKING | BDF_CLONE, 2, HARDWARE_IREM_MISC, GBF_SCRFIGHT, 0,
2401 	NULL, VigilantbRomInfo, VigilantbRomName, NULL, NULL, NULL, NULL, DrvInputInfo, DrvDIPInfo,
2402 	DrvcInit, DrvExit, DrvFrame, DrvDraw, DrvScan,
2403 	NULL, 544, 256, 256, 4, 3
2404 };
2405 
2406 struct BurnDriver BurnDrvVigilantc = {
2407 	"vigilantc", "vigilant", NULL, NULL, "1988",
2408 	"Vigilante (World, Rev C)\0", NULL, "Irem", "Miscellaneous",
2409 	NULL, NULL, NULL, NULL,
2410 	BDF_GAME_WORKING | BDF_CLONE, 2, HARDWARE_IREM_MISC, GBF_SCRFIGHT, 0,
2411 	NULL, Drv1RomInfo, Drv1RomName, NULL, NULL, NULL, NULL, DrvInputInfo, DrvDIPInfo,
2412 	DrvcInit, DrvExit, DrvFrame, DrvDraw, DrvScan,
2413 	NULL, 544, 256, 256, 4, 3
2414 };
2415 
2416 struct BurnDriver BurnDrvVigilanto = {
2417 	"vigilanto", "vigilant", NULL, NULL, "1988",
2418 	"Vigilante (US)\0", NULL, "Irem (Data East USA License)", "Miscellaneous",
2419 	NULL, NULL, NULL, NULL,
2420 	BDF_GAME_WORKING | BDF_CLONE, 2, HARDWARE_IREM_MISC, GBF_SCRFIGHT, 0,
2421 	NULL, DrvuRomInfo, DrvuRomName, NULL, NULL, NULL, NULL, DrvInputInfo, DrvDIPInfo,
2422 	DrvcInit, DrvExit, DrvFrame, DrvDraw, DrvScan,
2423 	NULL, 544, 256, 256, 4, 3
2424 };
2425 
2426 struct BurnDriver BurnDrvVigilantg = {
2427 	"vigilantg", "vigilant", NULL, NULL, "1988",
2428 	"Vigilante (US, Rev G)\0", NULL, "Irem (Data East USA License)", "Miscellaneous",
2429 	NULL, NULL, NULL, NULL,
2430 	BDF_GAME_WORKING | BDF_CLONE, 2, HARDWARE_IREM_MISC, GBF_SCRFIGHT, 0,
2431 	NULL, Drvu2RomInfo, Drvu2RomName, NULL, NULL, NULL, NULL, DrvInputInfo, DrvDIPInfo,
2432 	DrvInit, DrvExit, DrvFrame, DrvDraw, DrvScan,
2433 	NULL, 544, 256, 256, 4, 3
2434 };
2435 
2436 struct BurnDriver BurnDrvVigilantd = {
2437 	"vigilantd", "vigilant", NULL, NULL, "1988",
2438 	"Vigilante (Japan, Rev D)\0", NULL, "Irem", "Miscellaneous",
2439 	NULL, NULL, NULL, NULL,
2440 	BDF_GAME_WORKING | BDF_CLONE, 2, HARDWARE_IREM_MISC, GBF_SCRFIGHT, 0,
2441 	NULL, DrvjRomInfo, DrvjRomName, NULL, NULL, NULL, NULL, DrvInputInfo, DrvDIPInfo,
2442 	DrvcInit, DrvExit, DrvFrame, DrvDraw, DrvScan,
2443 	NULL, 544, 256, 256, 4, 3
2444 };
2445 
2446 struct BurnDriver BurnDrvVigilantbl = {
2447 	"vigilantbl", "vigilant", NULL, NULL, "1988",
2448 	"Vigilante (bootleg)\0", NULL, "bootleg", "Miscellaneous",
2449 	NULL, NULL, NULL, NULL,
2450 	BDF_GAME_WORKING | BDF_CLONE, 2, HARDWARE_IREM_MISC, GBF_SCRFIGHT, 0,
2451 	NULL, DrvbRomInfo, DrvbRomName, NULL, NULL, NULL, NULL, DrvInputInfo, DrvDIPInfo,
2452 	DrvbInit, DrvExit, DrvFrame, DrvDraw, DrvScan,
2453 	NULL, 544, 256, 256, 4, 3
2454 };
2455 
2456 struct BurnDriver BurnDrvKikcubic = {
2457 	"kikcubic", NULL, NULL, NULL, "1988",
2458 	"Meikyu Jima (Japan)\0", NULL, "Irem", "Miscellaneous",
2459 	NULL, NULL, NULL, NULL,
2460 	BDF_GAME_WORKING, 2, HARDWARE_IREM_MISC, GBF_MAZE, 0,
2461 	NULL, KikcubicRomInfo, KikcubicRomName, NULL, NULL, NULL, NULL, KikcubicInputInfo, KikcubicDIPInfo,
2462 	KikcubicInit, DrvExit, DrvFrame, KikcubicDraw, DrvScan,
2463 	NULL, 544, 384, 256, 4, 3
2464 };
2465 
2466 struct BurnDriver BurnDrvKikcubicb = {
2467 	"kikcubicb", "kikcubic", NULL, NULL, "1988",
2468 	"Kickle Cubele\0", NULL, "bootleg", "Miscellaneous",
2469 	NULL, NULL, NULL, NULL,
2470 	BDF_GAME_WORKING | BDF_CLONE | BDF_BOOTLEG, 2, HARDWARE_IREM_MISC, GBF_MAZE, 0,
2471 	NULL, KikcubicbRomInfo, KikcubicbRomName, NULL, NULL, NULL, NULL, KikcubicInputInfo, KikcubicDIPInfo,
2472 	KikcubicInit, DrvExit, DrvFrame, KikcubicDraw, DrvScan,
2473 	NULL, 544, 384, 256, 4, 3
2474 };
2475 
2476 struct BurnDriver BurnDrvBuccanrs = {
2477 	"buccanrs", NULL, NULL, NULL, "1989",
2478 	"Buccaneers (set 1)\0", NULL, "Duintronic", "Miscellaneous",
2479 	NULL, NULL, NULL, NULL,
2480 	BDF_GAME_WORKING, 2, HARDWARE_IREM_MISC, GBF_SCRFIGHT, 0,
2481 	NULL, BuccanrsRomInfo, BuccanrsRomName, NULL, NULL, NULL, NULL, BuccanrsInputInfo, BuccanrsDIPInfo,
2482 	BuccanrsInit, DrvExit, DrvFrame, DrvDraw, DrvScan,
2483 	NULL, 544, 256, 256, 4, 3
2484 };
2485 
2486 struct BurnDriver BurnDrvBuccanrsa = {
2487 	"buccanrsa", "buccanrs", NULL, NULL, "1989",
2488 	"Buccaneers (set 2)\0", NULL, "Duintronic", "Miscellaneous",
2489 	NULL, NULL, NULL, NULL,
2490 	BDF_GAME_WORKING | BDF_CLONE, 2, HARDWARE_IREM_MISC, GBF_SCRFIGHT, 0,
2491 	NULL, BuccanrsaRomInfo, BuccanrsaRomName, NULL, NULL, NULL, NULL, BuccanrsaInputInfo, BuccanrsaDIPInfo,
2492 	BuccanrsInit, DrvExit, DrvFrame, DrvDraw, DrvScan,
2493 	NULL, 544, 256, 256, 4, 3
2494 };
2495 
2496 struct BurnDriver BurnDrvBuccanrsb = {
2497 	"buccanrsb", "buccanrs", NULL, NULL, "1989",
2498 	"Buccaneers (set 3, harder)\0", NULL, "Duintronic", "Miscellaneous",
2499 	NULL, NULL, NULL, NULL,
2500 	BDF_GAME_WORKING | BDF_CLONE, 2, HARDWARE_IREM_MISC, GBF_SCRFIGHT, 0,
2501 	NULL, BuccanrsbRomInfo, BuccanrsbRomName, NULL, NULL, NULL, NULL, BuccanrsInputInfo, BuccanrsDIPInfo,
2502 	BuccanrsInit, DrvExit, DrvFrame, DrvDraw, DrvScan,
2503 	NULL, 544, 256, 256, 4, 3
2504 };
2505