1 // FB Alpha 1943 driver module
2 // Based on MAME driver by Paul Leaman
3 
4 #include "tiles_generic.h"
5 #include "z80_intf.h"
6 #include "burn_ym2203.h"
7 #include "watchdog.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[2]        = {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 *DrvPaletteRam        = NULL;
26 static UINT8 *DrvSpriteRam         = NULL;
27 static UINT8 *DrvPromRed           = NULL;
28 static UINT8 *DrvPromGreen         = NULL;
29 static UINT8 *DrvPromBlue          = NULL;
30 static UINT8 *DrvPromCharLookup    = NULL;
31 static UINT8 *DrvPromBg2Lookup     = NULL;
32 static UINT8 *DrvPromBg2PalBank    = NULL;
33 static UINT8 *DrvPromBgLookup      = NULL;
34 static UINT8 *DrvPromBgPalBank     = NULL;
35 static UINT8 *DrvPromSpriteLookup  = NULL;
36 static UINT8 *DrvPromSpritePalBank = NULL;
37 static UINT8 *DrvBgTilemap         = NULL;
38 static UINT8 *DrvBg2Tilemap        = NULL;
39 static UINT8 *DrvChars             = NULL;
40 static UINT8 *DrvBg2Tiles          = NULL;
41 static UINT8 *DrvBgTiles           = NULL;
42 static UINT8 *DrvSprites           = NULL;
43 static UINT8 *DrvTempRom           = NULL;
44 static UINT32 *DrvPalette          = NULL;
45 
46 static UINT8 DrvRecalc;
47 
48 static UINT8 DrvSoundLatch;
49 static UINT8 DrvRomBank;
50 static UINT8 DrvBg2ScrollX[2];
51 static UINT8 DrvBgScrollX[2];
52 static UINT8 DrvBgScrollY;
53 static UINT8 DrvBg2On;
54 static UINT8 DrvBg1On;
55 static UINT8 DrvSpritesOn;
56 static UINT8 DrvCharsOn;
57 static UINT8 DrvProtValue;
58 
59 static INT32 bootleg = 0;
60 
61 static struct BurnInputInfo DrvInputList[] =
62 {
63 	{"Coin 1"            , BIT_DIGITAL  , DrvInputPort0 + 6, "p1 coin"   },
64 	{"Start 1"           , BIT_DIGITAL  , DrvInputPort0 + 0, "p1 start"  },
65 	{"Coin 2"            , BIT_DIGITAL  , DrvInputPort0 + 7, "p2 coin"   },
66 	{"Start 2"           , BIT_DIGITAL  , DrvInputPort0 + 1, "p2 start"  },
67 
68 	{"P1 Up"             , BIT_DIGITAL  , DrvInputPort1 + 3, "p1 up"     },
69 	{"P1 Down"           , BIT_DIGITAL  , DrvInputPort1 + 2, "p1 down"   },
70 	{"P1 Left"           , BIT_DIGITAL  , DrvInputPort1 + 1, "p1 left"   },
71 	{"P1 Right"          , BIT_DIGITAL  , DrvInputPort1 + 0, "p1 right"  },
72 	{"P1 Fire 1"         , BIT_DIGITAL  , DrvInputPort1 + 4, "p1 fire 1" },
73 	{"P1 Fire 2"         , BIT_DIGITAL  , DrvInputPort1 + 5, "p1 fire 2" },
74 
75 	{"P2 Up"             , BIT_DIGITAL  , DrvInputPort2 + 3, "p2 up"     },
76 	{"P2 Down"           , BIT_DIGITAL  , DrvInputPort2 + 2, "p2 down"   },
77 	{"P2 Left"           , BIT_DIGITAL  , DrvInputPort2 + 1, "p2 left"   },
78 	{"P2 Right"          , BIT_DIGITAL  , DrvInputPort2 + 0, "p2 right"  },
79 	{"Fire 1"            , BIT_DIGITAL  , DrvInputPort2 + 4, "p2 fire 1" },
80 	{"Fire 2"            , BIT_DIGITAL  , DrvInputPort2 + 5, "p2 fire 2" },
81 
82 	{"Reset"             , BIT_DIGITAL  , &DrvReset        , "reset"     },
83 	{"Dip 1"             , BIT_DIPSWITCH, DrvDip + 0       , "dip"       },
84 	{"Dip 2"             , BIT_DIPSWITCH, DrvDip + 1       , "dip"       },
85 };
86 
87 STDINPUTINFO(Drv)
88 
89 static struct BurnDIPInfo DrvDIPList[]=
90 {
91 	// Default Values
92 	{0x11, 0xff, 0xff, 0xf8, NULL                     },
93 	{0x12, 0xff, 0xff, 0xff, NULL                     },
94 
95 	// Dip 1
96 	{0   , 0xfe, 0   , 16  , "Difficulty"             },
97 	{0x11, 0x01, 0x0f, 0x0f, "1 (Easy)"               },
98 	{0x11, 0x01, 0x0f, 0x0e, "2"                      },
99 	{0x11, 0x01, 0x0f, 0x0d, "3"                      },
100 	{0x11, 0x01, 0x0f, 0x0c, "4"                      },
101 	{0x11, 0x01, 0x0f, 0x0b, "5"                      },
102 	{0x11, 0x01, 0x0f, 0x0a, "6"                      },
103 	{0x11, 0x01, 0x0f, 0x09, "7"                      },
104 	{0x11, 0x01, 0x0f, 0x08, "8 (Normal)"             },
105 	{0x11, 0x01, 0x0f, 0x07, "9"                      },
106 	{0x11, 0x01, 0x0f, 0x06, "10"                     },
107 	{0x11, 0x01, 0x0f, 0x05, "11"                     },
108 	{0x11, 0x01, 0x0f, 0x04, "12"                     },
109 	{0x11, 0x01, 0x0f, 0x03, "13"                     },
110 	{0x11, 0x01, 0x0f, 0x02, "14"                     },
111 	{0x11, 0x01, 0x0f, 0x01, "15"                     },
112 	{0x11, 0x01, 0x0f, 0x00, "16 (Difficult)"         },
113 
114 	{0   , 0xfe, 0   , 2   , "2 Player Game"          },
115 	{0x11, 0x01, 0x10, 0x00, "1 Credit / 2 Players"   },
116 	{0x11, 0x01, 0x10, 0x10, "2 Credits / 2 Players"  },
117 
118 	{0   , 0xfe, 0   , 2   , "Flip Screen"            },
119 	{0x11, 0x01, 0x20, 0x20, "Off"                    },
120 	{0x11, 0x01, 0x20, 0x00, "On"                     },
121 
122 	{0   , 0xfe, 0   , 2   , "Freeze"                 },
123 	{0x11, 0x01, 0x40, 0x40, "Off"                    },
124 	{0x11, 0x01, 0x40, 0x00, "On"                     },
125 
126 	{0   , 0xfe, 0   , 2   , "Service Mode"           },
127 	{0x11, 0x01, 0x80, 0x80, "Off"                    },
128 	{0x11, 0x01, 0x80, 0x00, "On"                     },
129 
130 	// Dip 2
131 	{0   , 0xfe, 0   , 8   , "Coin A"                 },
132 	{0x12, 0x01, 0x07, 0x00, "4 Coins 1 Play"         },
133 	{0x12, 0x01, 0x07, 0x01, "3 Coins 1 Play"         },
134 	{0x12, 0x01, 0x07, 0x02, "2 Coins 1 Play"         },
135 	{0x12, 0x01, 0x07, 0x07, "1 Coin 1 Play"          },
136 	{0x12, 0x01, 0x07, 0x06, "1 Coin 2 Plays"         },
137 	{0x12, 0x01, 0x07, 0x05, "1 Coin 3 Plays"         },
138 	{0x12, 0x01, 0x07, 0x04, "1 Coin 4 Plays"         },
139 	{0x12, 0x01, 0x07, 0x03, "1 Coin 5 Plays"         },
140 
141 	{0   , 0xfe, 0   , 8   , "Coin B"                 },
142 	{0x12, 0x01, 0x38, 0x00, "4 Coins 1 Play"         },
143 	{0x12, 0x01, 0x38, 0x08, "3 Coins 1 Play"         },
144 	{0x12, 0x01, 0x38, 0x10, "2 Coins 1 Play"         },
145 	{0x12, 0x01, 0x38, 0x38, "1 Coin 1 Play"          },
146 	{0x12, 0x01, 0x38, 0x30, "1 Coin 2 Plays"         },
147 	{0x12, 0x01, 0x38, 0x28, "1 Coin 3 Plays"         },
148 	{0x12, 0x01, 0x38, 0x20, "1 Coin 4 Plays"         },
149 	{0x12, 0x01, 0x38, 0x18, "1 Coin 5 Plays"         },
150 
151 	{0   , 0xfe, 0   , 2   , "Allow Continue"         },
152 	{0x12, 0x01, 0x40, 0x00, "No"                     },
153 	{0x12, 0x01, 0x40, 0x40, "Yes"                    },
154 
155 	{0   , 0xfe, 0   , 2   , "Demo Sounds"            },
156 	{0x12, 0x01, 0x80, 0x00, "Off"                    },
157 	{0x12, 0x01, 0x80, 0x80, "On"                     },
158 };
159 
160 STDDIPINFO(Drv)
161 
162 static struct BurnRomInfo DrvRomDesc[] = {
163 	{ "bme01.12d",     0x08000, 0x55fd447e, BRF_ESS | BRF_PRG }, //  0	Z80 #1 Program Code
164 	{ "bme02.13d",     0x10000, 0x073fc57c, BRF_ESS | BRF_PRG }, //	 1
165 	{ "bme03.14d",     0x10000, 0x835822c2, BRF_ESS | BRF_PRG }, //	 2
166 
167 	{ "bm05.4k",       0x08000, 0xee2bd2d7, BRF_ESS | BRF_PRG }, //  3	Z80 #2 Program
168 
169 	{ "bm04.5h",       0x08000, 0x46cb9d3d, BRF_GRA },	     	 //  4	Characters
170 
171 	{ "bm15.10f",      0x08000, 0x6b1a0443, BRF_GRA },	     	 //  5	BG Tiles
172 	{ "bm16.11f",      0x08000, 0x23c908c2, BRF_GRA },	     	 //  6
173 	{ "bm17.12f",      0x08000, 0x46bcdd07, BRF_GRA },	     	 //  7
174 	{ "bm18.14f",      0x08000, 0xe6ae7ba0, BRF_GRA },	     	 //  8
175 	{ "bm19.10j",      0x08000, 0x868ababc, BRF_GRA },	     	 //  9
176 	{ "bm20.11j",      0x08000, 0x0917e5d4, BRF_GRA },	     	 //  10
177 	{ "bm21.12j",      0x08000, 0x9bfb0d89, BRF_GRA },	     	 //  11
178 	{ "bm22.14j",      0x08000, 0x04f3c274, BRF_GRA },	     	 //  12
179 
180 	{ "bm24.14k",      0x08000, 0x11134036, BRF_GRA },	     	 //  13	BG2 Tiles
181 	{ "bm25.14l",      0x08000, 0x092cf9c1, BRF_GRA },	     	 //  14
182 
183 	{ "bm06.10a",      0x08000, 0x97acc8af, BRF_GRA },	     	 //  15	Sprites
184 	{ "bm07.11a",      0x08000, 0xd78f7197, BRF_GRA },	     	 //  16
185 	{ "bm08.12a",      0x08000, 0x1a626608, BRF_GRA },	     	 //  17
186 	{ "bm09.14a",      0x08000, 0x92408400, BRF_GRA },	     	 //  18
187 	{ "bm10.10c",      0x08000, 0x8438a44a, BRF_GRA },	     	 //  19
188 	{ "bm11.11c",      0x08000, 0x6c69351d, BRF_GRA },	     	 //  20
189 	{ "bm12.12c",      0x08000, 0x5e7efdb7, BRF_GRA },	     	 //  21
190 	{ "bm13.14c",      0x08000, 0x1143829a, BRF_GRA },	     	 //  22
191 
192 	{ "bm14.5f",       0x08000, 0x4d3c6401, BRF_GRA },	     	 //  23	Tilemaps
193 	{ "bm23.8k",       0x08000, 0xa52aecbd, BRF_GRA },	     	 //  24
194 
195 	{ "bm1.12a",       0x00100, 0x74421f18, BRF_GRA },	     	 //  25	PROMs
196 	{ "bm2.13a",       0x00100, 0xac27541f, BRF_GRA },	     	 //  26
197 	{ "bm3.14a",       0x00100, 0x251fb6ff, BRF_GRA },	     	 //  27
198 	{ "bm5.7f",        0x00100, 0x206713d0, BRF_GRA },	     	 //  28
199 	{ "bm10.7l",       0x00100, 0x33c2491c, BRF_GRA },	     	 //  29
200 	{ "bm9.6l",        0x00100, 0xaeea4af7, BRF_GRA },	     	 //  30
201 	{ "bm12.12m",      0x00100, 0xc18aa136, BRF_GRA },	     	 //  31
202 	{ "bm11.12l",      0x00100, 0x405aae37, BRF_GRA },	     	 //  32
203 	{ "bm8.8c",        0x00100, 0xc2010a9e, BRF_GRA },	     	 //  33
204 	{ "bm7.7c",        0x00100, 0xb56f30c3, BRF_GRA },	     	 //  34
205 	{ "bm4.12c",       0x00100, 0x91a8a2e1, BRF_GRA },	     	 //  35
206 	{ "bm6.4b",        0x00100, 0x0eaf5158, BRF_GRA },	     	 //  36
207 
208 	{ "bm.7k",         0x10000, 0x00000000, BRF_NODUMP },	     //  37	MCU
209 };
210 
211 STD_ROM_PICK(Drv)
212 STD_ROM_FN(Drv)
213 
214 static struct BurnRomInfo DrvuRomDesc[] = {
215 	{ "bmu01c.12d",    0x08000, 0xc686cc5c, BRF_ESS | BRF_PRG }, //  0	Z80 #1 Program Code
216 	{ "bmu02c.13d",    0x10000, 0xd8880a41, BRF_ESS | BRF_PRG }, //	 1
217 	{ "bmu03c.14d",    0x10000, 0x3f0ee26c, BRF_ESS | BRF_PRG }, //	 2
218 
219 	{ "bm05.4k",       0x08000, 0xee2bd2d7, BRF_ESS | BRF_PRG }, //  3	Z80 #2 Program
220 
221 	{ "bm04.5h",       0x08000, 0x46cb9d3d, BRF_GRA },	     	 //  4	Characters
222 
223 	{ "bm15.10f",      0x08000, 0x6b1a0443, BRF_GRA },	     	 //  5	BG Tiles
224 	{ "bm16.11f",      0x08000, 0x23c908c2, BRF_GRA },	     	 //  6
225 	{ "bm17.12f",      0x08000, 0x46bcdd07, BRF_GRA },	     	 //  7
226 	{ "bm18.14f",      0x08000, 0xe6ae7ba0, BRF_GRA },	     	 //  8
227 	{ "bm19.10j",      0x08000, 0x868ababc, BRF_GRA },	     	 //  9
228 	{ "bm20.11j",      0x08000, 0x0917e5d4, BRF_GRA },	     	 //  10
229 	{ "bm21.12j",      0x08000, 0x9bfb0d89, BRF_GRA },	     	 //  11
230 	{ "bm22.14j",      0x08000, 0x04f3c274, BRF_GRA },	     	 //  12
231 
232 	{ "bm24.14k",      0x08000, 0x11134036, BRF_GRA },	     	 //  13	BG2 Tiles
233 	{ "bm25.14l",      0x08000, 0x092cf9c1, BRF_GRA },	     	 //  14
234 
235 	{ "bm06.10a",      0x08000, 0x97acc8af, BRF_GRA },	     	 //  15	Sprites
236 	{ "bm07.11a",      0x08000, 0xd78f7197, BRF_GRA },	     	 //  16
237 	{ "bm08.12a",      0x08000, 0x1a626608, BRF_GRA },	     	 //  17
238 	{ "bm09.14a",      0x08000, 0x92408400, BRF_GRA },	     	 //  18
239 	{ "bm10.10c",      0x08000, 0x8438a44a, BRF_GRA },	     	 //  19
240 	{ "bm11.11c",      0x08000, 0x6c69351d, BRF_GRA },	     	 //  20
241 	{ "bm12.12c",      0x08000, 0x5e7efdb7, BRF_GRA },	     	 //  21
242 	{ "bm13.14c",      0x08000, 0x1143829a, BRF_GRA },	     	 //  22
243 
244 	{ "bm14.5f",       0x08000, 0x4d3c6401, BRF_GRA },	     	 //  23	Tilemaps
245 	{ "bm23.8k",       0x08000, 0xa52aecbd, BRF_GRA },	     	 //  24
246 
247 	{ "bm1.12a",       0x00100, 0x74421f18, BRF_GRA },	     	 //  25	PROMs
248 	{ "bm2.13a",       0x00100, 0xac27541f, BRF_GRA },	     	 //  26
249 	{ "bm3.14a",       0x00100, 0x251fb6ff, BRF_GRA },	     	 //  27
250 	{ "bm5.7f",        0x00100, 0x206713d0, BRF_GRA },	     	 //  28
251 	{ "bm10.7l",       0x00100, 0x33c2491c, BRF_GRA },	     	 //  29
252 	{ "bm9.6l",        0x00100, 0xaeea4af7, BRF_GRA },	     	 //  30
253 	{ "bm12.12m",      0x00100, 0xc18aa136, BRF_GRA },	     	 //  31
254 	{ "bm11.12l",      0x00100, 0x405aae37, BRF_GRA },	     	 //  32
255 	{ "bm8.8c",        0x00100, 0xc2010a9e, BRF_GRA },	     	 //  33
256 	{ "bm7.7c",        0x00100, 0xb56f30c3, BRF_GRA },	     	 //  34
257 	{ "bm4.12c",       0x00100, 0x91a8a2e1, BRF_GRA },	     	 //  35
258 	{ "bm6.4b",        0x00100, 0x0eaf5158, BRF_GRA },	     	 //  36
259 
260 	{ "bm.7k",         0x10000, 0x00000000, BRF_NODUMP },	     //  37	MCU
261 };
262 
263 STD_ROM_PICK(Drvu)
264 STD_ROM_FN(Drvu)
265 
266 static struct BurnRomInfo DrvuaRomDesc[] = {
267 	{ "bmu01.12d",     0x08000, 0x793cf15f, BRF_ESS | BRF_PRG }, //  0	Z80 #1 Program Code
268 	{ "bmu02.13d",     0x10000, 0x6f1353d5, BRF_ESS | BRF_PRG }, //	 1
269 	{ "bmu03.14d",     0x10000, 0x9e7c07f7, BRF_ESS | BRF_PRG }, //	 2
270 
271 	{ "bm05.4k",       0x08000, 0xee2bd2d7, BRF_ESS | BRF_PRG }, //  3	Z80 #2 Program
272 
273 	{ "bm04.5h",       0x08000, 0x46cb9d3d, BRF_GRA },	     	 //  4	Characters
274 
275 	{ "bm15.10f",      0x08000, 0x6b1a0443, BRF_GRA },	     	 //  5	BG Tiles
276 	{ "bm16.11f",      0x08000, 0x23c908c2, BRF_GRA },	     	 //  6
277 	{ "bm17.12f",      0x08000, 0x46bcdd07, BRF_GRA },	     	 //  7
278 	{ "bm18.14f",      0x08000, 0xe6ae7ba0, BRF_GRA },	     	 //  8
279 	{ "bm19.10j",      0x08000, 0x868ababc, BRF_GRA },	     	 //  9
280 	{ "bm20.11j",      0x08000, 0x0917e5d4, BRF_GRA },	     	 //  10
281 	{ "bm21.12j",      0x08000, 0x9bfb0d89, BRF_GRA },	     	 //  11
282 	{ "bm22.14j",      0x08000, 0x04f3c274, BRF_GRA },	     	 //  12
283 
284 	{ "bm24.14k",      0x08000, 0x11134036, BRF_GRA },	     	 //  13	BG2 Tiles
285 	{ "bm25.14l",      0x08000, 0x092cf9c1, BRF_GRA },	     	 //  14
286 
287 	{ "bm06.10a",      0x08000, 0x97acc8af, BRF_GRA },	     	 //  15	Sprites
288 	{ "bm07.11a",      0x08000, 0xd78f7197, BRF_GRA },	     	 //  16
289 	{ "bm08.12a",      0x08000, 0x1a626608, BRF_GRA },	     	 //  17
290 	{ "bm09.14a",      0x08000, 0x92408400, BRF_GRA },	     	 //  18
291 	{ "bm10.10c",      0x08000, 0x8438a44a, BRF_GRA },	     	 //  19
292 	{ "bm11.11c",      0x08000, 0x6c69351d, BRF_GRA },	     	 //  20
293 	{ "bm12.12c",      0x08000, 0x5e7efdb7, BRF_GRA },	     	 //  21
294 	{ "bm13.14c",      0x08000, 0x1143829a, BRF_GRA },	     	 //  22
295 
296 	{ "bm14.5f",       0x08000, 0x4d3c6401, BRF_GRA },	     	 //  23	Tilemaps
297 	{ "bm23.8k",       0x08000, 0xa52aecbd, BRF_GRA },	     	 //  24
298 
299 	{ "bm1.12a",       0x00100, 0x74421f18, BRF_GRA },	     	 //  25	PROMs
300 	{ "bm2.13a",       0x00100, 0xac27541f, BRF_GRA },	     	 //  26
301 	{ "bm3.14a",       0x00100, 0x251fb6ff, BRF_GRA },	     	 //  27
302 	{ "bm5.7f",        0x00100, 0x206713d0, BRF_GRA },	     	 //  28
303 	{ "bm10.7l",       0x00100, 0x33c2491c, BRF_GRA },	     	 //  29
304 	{ "bm9.6l",        0x00100, 0xaeea4af7, BRF_GRA },	     	 //  30
305 	{ "bm12.12m",      0x00100, 0xc18aa136, BRF_GRA },	     	 //  31
306 	{ "bm11.12l",      0x00100, 0x405aae37, BRF_GRA },	     	 //  32
307 	{ "bm8.8c",        0x00100, 0xc2010a9e, BRF_GRA },	     	 //  33
308 	{ "bm7.7c",        0x00100, 0xb56f30c3, BRF_GRA },	     	 //  34
309 	{ "bm4.12c",       0x00100, 0x91a8a2e1, BRF_GRA },	     	 //  35
310 	{ "bm6.4b",        0x00100, 0x0eaf5158, BRF_GRA },	     	 //  36
311 
312 	{ "bm.7k",         0x10000, 0x00000000, BRF_NODUMP },	     //  37	MCU
313 };
314 
315 STD_ROM_PICK(Drvua)
316 STD_ROM_FN(Drvua)
317 
318 static struct BurnRomInfo DrvjRomDesc[] = {
319 	{ "bm01b.12d",     0x08000, 0x363f9f3d, BRF_ESS | BRF_PRG }, //  0	Z80 #1 Program Code
320 	{ "bm02b.13d",     0x10000, 0x7f0d7edc, BRF_ESS | BRF_PRG }, //	 1
321 	{ "bm03b.14d",     0x10000, 0x7093da2a, BRF_ESS | BRF_PRG }, //	 2
322 
323 	{ "bm05.4k",       0x08000, 0xee2bd2d7, BRF_ESS | BRF_PRG }, //  3	Z80 #2 Program
324 
325 	{ "bm04.5h",       0x08000, 0x46cb9d3d, BRF_GRA },	     	 //  4	Characters
326 
327 	{ "bm15.10f",      0x08000, 0x6b1a0443, BRF_GRA },	     	 //  5	BG Tiles
328 	{ "bm16.11f",      0x08000, 0x23c908c2, BRF_GRA },	     	 //  6
329 	{ "bm17.12f",      0x08000, 0x46bcdd07, BRF_GRA },	     	 //  7
330 	{ "bm18.14f",      0x08000, 0xe6ae7ba0, BRF_GRA },	     	 //  8
331 	{ "bm19.10j",      0x08000, 0x868ababc, BRF_GRA },	     	 //  9
332 	{ "bm20.11j",      0x08000, 0x0917e5d4, BRF_GRA },	     	 //  10
333 	{ "bm21.12j",      0x08000, 0x9bfb0d89, BRF_GRA },	     	 //  11
334 	{ "bm22.14j",      0x08000, 0x04f3c274, BRF_GRA },	     	 //  12
335 
336 	{ "bm24.14k",      0x08000, 0x11134036, BRF_GRA },	     	 //  13	BG2 Tiles
337 	{ "bm25.14l",      0x08000, 0x092cf9c1, BRF_GRA },	     	 //  14
338 
339 	{ "bm06.10a",      0x08000, 0x97acc8af, BRF_GRA },	     	 //  15	Sprites
340 	{ "bm07.11a",      0x08000, 0xd78f7197, BRF_GRA },	     	 //  16
341 	{ "bm08.12a",      0x08000, 0x1a626608, BRF_GRA },	     	 //  17
342 	{ "bm09.14a",      0x08000, 0x92408400, BRF_GRA },	     	 //  18
343 	{ "bm10.10c",      0x08000, 0x8438a44a, BRF_GRA },	     	 //  19
344 	{ "bm11.11c",      0x08000, 0x6c69351d, BRF_GRA },	     	 //  20
345 	{ "bm12.12c",      0x08000, 0x5e7efdb7, BRF_GRA },	     	 //  21
346 	{ "bm13.14c",      0x08000, 0x1143829a, BRF_GRA },	     	 //  22
347 
348 	{ "bm14.5f",       0x08000, 0x4d3c6401, BRF_GRA },	     	 //  23	Tilemaps
349 	{ "bm23.8k",       0x08000, 0xa52aecbd, BRF_GRA },	     	 //  24
350 
351 	{ "bm1.12a",       0x00100, 0x74421f18, BRF_GRA },	     	 //  25	PROMs
352 	{ "bm2.13a",       0x00100, 0xac27541f, BRF_GRA },	     	 //  26
353 	{ "bm3.14a",       0x00100, 0x251fb6ff, BRF_GRA },	     	 //  27
354 	{ "bm5.7f",        0x00100, 0x206713d0, BRF_GRA },	     	 //  28
355 	{ "bm10.7l",       0x00100, 0x33c2491c, BRF_GRA },	     	 //  29
356 	{ "bm9.6l",        0x00100, 0xaeea4af7, BRF_GRA },	     	 //  30
357 	{ "bm12.12m",      0x00100, 0xc18aa136, BRF_GRA },	     	 //  31
358 	{ "bm11.12l",      0x00100, 0x405aae37, BRF_GRA },	     	 //  32
359 	{ "bm8.8c",        0x00100, 0xc2010a9e, BRF_GRA },	     	 //  33
360 	{ "bm7.7c",        0x00100, 0xb56f30c3, BRF_GRA },	     	 //  34
361 	{ "bm4.12c",       0x00100, 0x91a8a2e1, BRF_GRA },	     	 //  35
362 	{ "bm6.4b",        0x00100, 0x0eaf5158, BRF_GRA },	     	 //  36
363 
364 	{ "bm.7k",         0x10000, 0x00000000, BRF_NODUMP },	     //  37	MCU
365 };
366 
367 STD_ROM_PICK(Drvj)
368 STD_ROM_FN(Drvj)
369 
370 static struct BurnRomInfo DrvjaRomDesc[] = {
371 	{ "bm01.12d",      0x08000, 0x232df705, BRF_ESS | BRF_PRG }, //  0	Z80 #1 Program Code
372 	{ "bm02.13d",      0x10000, 0xaf971575, BRF_ESS | BRF_PRG }, //	 1
373 	{ "bm03.14d",      0x10000, 0x300ec713, BRF_ESS | BRF_PRG }, //	 2
374 
375 	{ "bm05.4k",       0x08000, 0xee2bd2d7, BRF_ESS | BRF_PRG }, //  3	Z80 #2 Program
376 
377 	{ "bm04.5h",       0x08000, 0x46cb9d3d, BRF_GRA },	     	 //  4	Characters
378 
379 	{ "bm15.10f",      0x08000, 0x6b1a0443, BRF_GRA },	     	 //  5	BG Tiles
380 	{ "bm16.11f",      0x08000, 0x23c908c2, BRF_GRA },	     	 //  6
381 	{ "bm17.12f",      0x08000, 0x46bcdd07, BRF_GRA },	     	 //  7
382 	{ "bm18.14f",      0x08000, 0xe6ae7ba0, BRF_GRA },	     	 //  8
383 	{ "bm19.10j",      0x08000, 0x868ababc, BRF_GRA },	     	 //  9
384 	{ "bm20.11j",      0x08000, 0x0917e5d4, BRF_GRA },	     	 //  10
385 	{ "bm21.12j",      0x08000, 0x9bfb0d89, BRF_GRA },	     	 //  11
386 	{ "bm22.14j",      0x08000, 0x04f3c274, BRF_GRA },	     	 //  12
387 
388 	{ "bm24.14k",      0x08000, 0x11134036, BRF_GRA },	     	 //  13	BG2 Tiles
389 	{ "bm25.14l",      0x08000, 0x092cf9c1, BRF_GRA },	     	 //  14
390 
391 	{ "bm06.10a",      0x08000, 0x97acc8af, BRF_GRA },	     	 //  15	Sprites
392 	{ "bm07.11a",      0x08000, 0xd78f7197, BRF_GRA },	     	 //  16
393 	{ "bm08.12a",      0x08000, 0x1a626608, BRF_GRA },	     	 //  17
394 	{ "bm09.14a",      0x08000, 0x92408400, BRF_GRA },	     	 //  18
395 	{ "bm10.10c",      0x08000, 0x8438a44a, BRF_GRA },	     	 //  19
396 	{ "bm11.11c",      0x08000, 0x6c69351d, BRF_GRA },	     	 //  20
397 	{ "bm12.12c",      0x08000, 0x5e7efdb7, BRF_GRA },	     	 //  21
398 	{ "bm13.14c",      0x08000, 0x1143829a, BRF_GRA },	     	 //  22
399 
400 	{ "bm14.5f",       0x08000, 0x4d3c6401, BRF_GRA },	     	 //  23	Tilemaps
401 	{ "bm23.8k",       0x08000, 0xa52aecbd, BRF_GRA },	     	 //  24
402 
403 	{ "bm1.12a",       0x00100, 0x74421f18, BRF_GRA },	     	 //  25	PROMs
404 	{ "bm2.13a",       0x00100, 0xac27541f, BRF_GRA },	     	 //  26
405 	{ "bm3.14a",       0x00100, 0x251fb6ff, BRF_GRA },	     	 //  27
406 	{ "bm5.7f",        0x00100, 0x206713d0, BRF_GRA },	     	 //  28
407 	{ "bm10.7l",       0x00100, 0x33c2491c, BRF_GRA },	     	 //  29
408 	{ "bm9.6l",        0x00100, 0xaeea4af7, BRF_GRA },	     	 //  30
409 	{ "bm12.12m",      0x00100, 0xc18aa136, BRF_GRA },	     	 //  31
410 	{ "bm11.12l",      0x00100, 0x405aae37, BRF_GRA },	     	 //  32
411 	{ "bm8.8c",        0x00100, 0xc2010a9e, BRF_GRA },	     	 //  33
412 	{ "bm7.7c",        0x00100, 0xb56f30c3, BRF_GRA },	     	 //  34
413 	{ "bm4.12c",       0x00100, 0x91a8a2e1, BRF_GRA },	     	 //  35
414 	{ "bm6.4b",        0x00100, 0x0eaf5158, BRF_GRA },	     	 //  36
415 
416 	{ "bm.7k",         0x10000, 0x00000000, BRF_NODUMP },	     //  37	MCU
417 };
418 
419 STD_ROM_PICK(Drvja)
420 STD_ROM_FN(Drvja)
421 
422 static struct BurnRomInfo DrvjahRomDesc[] = {
423 	{ "bm01_hack.12d", 0x08000, 0xf6935937, BRF_ESS | BRF_PRG }, //  0	Z80 #1 Program Code
424 	{ "bm02.13d",      0x10000, 0xaf971575, BRF_ESS | BRF_PRG }, //	 1
425 	{ "bm03.14d",      0x10000, 0x300ec713, BRF_ESS | BRF_PRG }, //	 2
426 
427 	{ "bm05.4k",       0x08000, 0xee2bd2d7, BRF_ESS | BRF_PRG }, //  3	Z80 #2 Program
428 
429 	{ "bm04.5h",       0x08000, 0x46cb9d3d, BRF_GRA },	     	 //  4	Characters
430 
431 	{ "bm15.10f",      0x08000, 0x6b1a0443, BRF_GRA },	     	 //  5	BG Tiles
432 	{ "bm16.11f",      0x08000, 0x23c908c2, BRF_GRA },	     	 //  6
433 	{ "bm17.12f",      0x08000, 0x46bcdd07, BRF_GRA },	     	 //  7
434 	{ "bm18.14f",      0x08000, 0xe6ae7ba0, BRF_GRA },	     	 //  8
435 	{ "bm19.10j",      0x08000, 0x868ababc, BRF_GRA },	     	 //  9
436 	{ "bm20.11j",      0x08000, 0x0917e5d4, BRF_GRA },	     	 //  10
437 	{ "bm21.12j",      0x08000, 0x9bfb0d89, BRF_GRA },	     	 //  11
438 	{ "bm22.14j",      0x08000, 0x04f3c274, BRF_GRA },	     	 //  12
439 
440 	{ "bm24.14k",      0x08000, 0x11134036, BRF_GRA },	     	 //  13	BG2 Tiles
441 	{ "bm25.14l",      0x08000, 0x092cf9c1, BRF_GRA },	     	 //  14
442 
443 	{ "bm06.10a",      0x08000, 0x97acc8af, BRF_GRA },	     	 //  15	Sprites
444 	{ "bm07.11a",      0x08000, 0xd78f7197, BRF_GRA },	     	 //  16
445 	{ "bm08.12a",      0x08000, 0x1a626608, BRF_GRA },	     	 //  17
446 	{ "bm09.14a",      0x08000, 0x92408400, BRF_GRA },	     	 //  18
447 	{ "bm10.10c",      0x08000, 0x8438a44a, BRF_GRA },	     	 //  19
448 	{ "bm11.11c",      0x08000, 0x6c69351d, BRF_GRA },	     	 //  20
449 	{ "bm12.12c",      0x08000, 0x5e7efdb7, BRF_GRA },	     	 //  21
450 	{ "bm13.14c",      0x08000, 0x1143829a, BRF_GRA },	     	 //  22
451 
452 	{ "bm14.5f",       0x08000, 0x4d3c6401, BRF_GRA },	     	 //  23	Tilemaps
453 	{ "bm23.8k",       0x08000, 0xa52aecbd, BRF_GRA },	     	 //  24
454 
455 	{ "bm1.12a",       0x00100, 0x74421f18, BRF_GRA },	     	 //  25	PROMs
456 	{ "bm2.13a",       0x00100, 0xac27541f, BRF_GRA },	     	 //  26
457 	{ "bm3.14a",       0x00100, 0x251fb6ff, BRF_GRA },	     	 //  27
458 	{ "bm5.7f",        0x00100, 0x206713d0, BRF_GRA },	     	 //  28
459 	{ "bm10.7l",       0x00100, 0x33c2491c, BRF_GRA },	     	 //  29
460 	{ "bm9.6l",        0x00100, 0xaeea4af7, BRF_GRA },	     	 //  30
461 	{ "bm12.12m",      0x00100, 0xc18aa136, BRF_GRA },	     	 //  31
462 	{ "bm11.12l",      0x00100, 0x405aae37, BRF_GRA },	     	 //  32
463 	{ "bm8.8c",        0x00100, 0xc2010a9e, BRF_GRA },	     	 //  33
464 	{ "bm7.7c",        0x00100, 0xb56f30c3, BRF_GRA },	     	 //  34
465 	{ "bm4.12c",       0x00100, 0x91a8a2e1, BRF_GRA },	     	 //  35
466 	{ "bm6.4b",        0x00100, 0x0eaf5158, BRF_GRA },	     	 //  36
467 
468 	{ "bm.7k",         0x10000, 0x00000000, BRF_NODUMP },	     //  37	MCU
469 };
470 
471 STD_ROM_PICK(Drvjah)
472 STD_ROM_FN(Drvjah)
473 
474 static struct BurnRomInfo DrvbRomDesc[] = {
475 	{ "1.12d",         0x08000, 0x9a2d70ab, BRF_ESS | BRF_PRG }, //  0	Z80 #1 Program Code
476 	{ "bm02.13d",      0x10000, 0xaf971575, BRF_ESS | BRF_PRG }, //	 1
477 	{ "bm03.14d",      0x10000, 0x300ec713, BRF_ESS | BRF_PRG }, //	 2
478 
479 	{ "bm05.4k",       0x08000, 0xee2bd2d7, BRF_ESS | BRF_PRG }, //  3	Z80 #2 Program
480 
481 	{ "4.5h",          0x08000, 0x0aba2096, BRF_GRA },	     	 //  4	Characters
482 
483 	{ "15.12f",        0x10000, 0x622b4fba, BRF_GRA },	     	 //  5	BG Tiles
484 	{ "16.14f",        0x10000, 0x25471a8d, BRF_GRA },	     	 //  6
485 	{ "17.12j",        0x10000, 0x9da79653, BRF_GRA },	     	 //  7
486 	{ "18.14j",        0x10000, 0x1f3aced8, BRF_GRA },	     	 //  8
487 
488 	{ "bm24.14k",      0x08000, 0x11134036, BRF_GRA },	     	 //  9	BG2 Tiles
489 	{ "bm25.14l",      0x08000, 0x092cf9c1, BRF_GRA },	     	 //  10
490 
491 	{ "bm06.10a",      0x08000, 0x97acc8af, BRF_GRA },	     	 //  11	Sprites
492 	{ "bm07.11a",      0x08000, 0xd78f7197, BRF_GRA },	     	 //  12
493 	{ "bm08.12a",      0x08000, 0x1a626608, BRF_GRA },	     	 //  13
494 	{ "bm09.14a",      0x08000, 0x92408400, BRF_GRA },	     	 //  14
495 	{ "bm10.10c",      0x08000, 0x8438a44a, BRF_GRA },	     	 //  15
496 	{ "bm11.11c",      0x08000, 0x6c69351d, BRF_GRA },	     	 //  16
497 	{ "bm12.12c",      0x08000, 0x5e7efdb7, BRF_GRA },	     	 //  17
498 	{ "bm13.14c",      0x08000, 0x1143829a, BRF_GRA },	     	 //  18
499 
500 	{ "bm14.5f",       0x08000, 0x4d3c6401, BRF_GRA },	     	 //  19	Tilemaps
501 	{ "bm23.8k",       0x08000, 0xa52aecbd, BRF_GRA },	     	 //  20
502 
503 	{ "bm1.12a",       0x00100, 0x74421f18, BRF_GRA },	     	 //  21	PROMs
504 	{ "bm2.13a",       0x00100, 0xac27541f, BRF_GRA },	     	 //  22
505 	{ "bm3.14a",       0x00100, 0x251fb6ff, BRF_GRA },	     	 //  23
506 	{ "bm5.7f",        0x00100, 0x206713d0, BRF_GRA },	     	 //  24
507 	{ "bm10.7l",       0x00100, 0x33c2491c, BRF_GRA },	     	 //  25
508 	{ "bm9.6l",        0x00100, 0xaeea4af7, BRF_GRA },	     	 //  26
509 	{ "bm12.12m",      0x00100, 0xc18aa136, BRF_GRA },	     	 //  27
510 	{ "bm11.12l",      0x00100, 0x405aae37, BRF_GRA },	     	 //  28
511 	{ "bm8.8c",        0x00100, 0xc2010a9e, BRF_GRA },	     	 //  29
512 	{ "bm7.7c",        0x00100, 0xb56f30c3, BRF_GRA },	     	 //  30
513 	{ "bm4.12c",       0x00100, 0x91a8a2e1, BRF_GRA },	     	 //  31
514 	{ "bm6.4b",        0x00100, 0x0eaf5158, BRF_GRA },	     	 //  32
515 };
516 
517 STD_ROM_PICK(Drvb)
518 STD_ROM_FN(Drvb)
519 
520 static struct BurnRomInfo Drvb2RomDesc[] = {
521 	{ "u28.bin",       0x08000, 0xb3b7c7cd, BRF_ESS | BRF_PRG }, //  0	Z80 #1 Program Code
522 	{ "u27.bin",       0x10000, 0xaf971575, BRF_ESS | BRF_PRG }, //	 1
523 	{ "u26.bin",       0x10000, 0x300ec713, BRF_ESS | BRF_PRG }, //	 2
524 
525 	{ "u88.bin",       0x08000, 0xee2bd2d7, BRF_ESS | BRF_PRG }, //  3	Z80 #2 Program
526 
527 	{ "u62.bin",       0x08000, 0x0aba2096, BRF_GRA },	     	 //  4	Characters
528 
529 	{ "u66.bin",       0x10000, 0x075e9a7f, BRF_GRA },	     	 //  5	BG Tiles
530 	{ "u65.bin",       0x10000, 0x05aca09a, BRF_GRA },	     	 //  6
531 	{ "u79.bin",       0x10000, 0x0f4b7e0e, BRF_GRA },	     	 //  7
532 	{ "u70.bin",       0x10000, 0x61a90c0a, BRF_GRA },	     	 //  8
533 
534 	{ "u102.bin",      0x08000, 0x11134036, BRF_GRA },	     	 //  9	BG2 Tiles
535 	{ "u116.bin",      0x08000, 0x092cf9c1, BRF_GRA },	     	 //  10
536 
537 	{ "u9.bin",        0x08000, 0x97acc8af, BRF_GRA },	     	 //  11	Sprites
538 	{ "u10.bin",       0x08000, 0xd78f7197, BRF_GRA },	     	 //  12
539 	{ "u8.bin",        0x10000, 0xed5c788a, BRF_GRA },	     	 //  13
540 	{ "u18.bin",       0x08000, 0x8438a44a, BRF_GRA },	     	 //  14
541 	{ "u19.bin",       0x08000, 0x6c69351d, BRF_GRA },	     	 //  15
542 	{ "u17.bin",       0x10000, 0x4b42445e, BRF_GRA },	     	 //  16
543 
544 	{ "u58.bin",       0x08000, 0x4d3c6401, BRF_GRA },	     	 //  17	Tilemaps
545 	{ "u96.bin",       0x08000, 0x254c881d, BRF_GRA },	     	 //  18
546 
547 	{ "bm1.12a",       0x00100, 0x74421f18, BRF_GRA },	     	 //  19	PROMs
548 	{ "bm2.13a",       0x00100, 0xac27541f, BRF_GRA },	     	 //  20
549 	{ "bm3.14a",       0x00100, 0x251fb6ff, BRF_GRA },	     	 //  21
550 	{ "bm5.7f",        0x00100, 0x206713d0, BRF_GRA },	     	 //  22
551 	{ "bm10.7l",       0x00100, 0x33c2491c, BRF_GRA },	     	 //  23
552 	{ "bm9.6l",        0x00100, 0xaeea4af7, BRF_GRA },	     	 //  24
553 	{ "bm12.12m",      0x00100, 0xc18aa136, BRF_GRA },	     	 //  25
554 	{ "bm11.12l",      0x00100, 0x405aae37, BRF_GRA },	     	 //  26
555 	{ "bm8.8c",        0x00100, 0xc2010a9e, BRF_GRA },	     	 //  27
556 	{ "bm7.7c",        0x00100, 0xb56f30c3, BRF_GRA },	     	 //  28
557 	{ "bm4.12c",       0x00100, 0x91a8a2e1, BRF_GRA },	     	 //  29
558 	{ "bm6.4b",        0x00100, 0x0eaf5158, BRF_GRA },	     	 //  30
559 };
560 
561 STD_ROM_PICK(Drvb2)
562 STD_ROM_FN(Drvb2)
563 
564 static struct BurnRomInfo DrvbjRomDesc[] = {
565 	{ "mkb03.12d",     0x08000, 0xb3b7c7cd, BRF_ESS | BRF_PRG }, //  0	Z80 #1 Program Code
566 	{ "bm02.13d",      0x10000, 0xaf971575, BRF_ESS | BRF_PRG }, //	 1
567 	{ "bm03.14d",      0x10000, 0x300ec713, BRF_ESS | BRF_PRG }, //	 2
568 
569 	{ "bm05.4k",       0x08000, 0xee2bd2d7, BRF_ESS | BRF_PRG }, //  3	Z80 #2 Program
570 
571 	{ "bm04.5h",       0x08000, 0x46cb9d3d, BRF_GRA },	     	 //  4	Characters
572 
573 	{ "mkb12.12f",     0x10000, 0x075e9a7f, BRF_GRA },	     	 //  5	BG Tiles
574 	{ "mkb11.14f",     0x10000, 0x05aca09a, BRF_GRA },	     	 //  6
575 	{ "mkb09.12j",     0x10000, 0x0f4b7e0e, BRF_GRA },	     	 //  7
576 	{ "mkb10.14j",     0x10000, 0x61a90c0a, BRF_GRA },	     	 //  8
577 
578 	{ "mkb08.14k",     0x08000, 0x798215e3, BRF_GRA },	     	 //  9	BG2 Tiles
579 	{ "bm25.14l",      0x08000, 0x092cf9c1, BRF_GRA },	     	 //  10
580 
581 	{ "bm06.10a",      0x08000, 0x97acc8af, BRF_GRA },	     	 //  11	Sprites
582 	{ "bm07.11a",      0x08000, 0xd78f7197, BRF_GRA },	     	 //  12
583 	{ "bm08.12a",      0x08000, 0x1a626608, BRF_GRA },	     	 //  13
584 	{ "bm09.14a",      0x08000, 0x92408400, BRF_GRA },	     	 //  14
585 	{ "bm10.10c",      0x08000, 0x8438a44a, BRF_GRA },	     	 //  15
586 	{ "bm11.11c",      0x08000, 0x6c69351d, BRF_GRA },	     	 //  16
587 	{ "bm12.12c",      0x08000, 0x5e7efdb7, BRF_GRA },	     	 //  17
588 	{ "bm13.14c",      0x08000, 0x1143829a, BRF_GRA },	     	 //  18
589 
590 	{ "bm14.5f",       0x08000, 0x4d3c6401, BRF_GRA },	     	 //  19	Tilemaps
591 	{ "mkb07.8k",      0x08000, 0xae1b317f, BRF_GRA },	     	 //  20
592 
593 	{ "bm1.12a",       0x00100, 0x74421f18, BRF_GRA },	     	 //  21	PROMs
594 	{ "bm2.13a",       0x00100, 0xac27541f, BRF_GRA },	     	 //  22
595 	{ "bm3.14a",       0x00100, 0x251fb6ff, BRF_GRA },	     	 //  23
596 	{ "bm5.7f",        0x00100, 0x206713d0, BRF_GRA },	     	 //  24
597 	{ "bm10.7l",       0x00100, 0x33c2491c, BRF_GRA },	     	 //  25
598 	{ "bm9.6l",        0x00100, 0xaeea4af7, BRF_GRA },	     	 //  26
599 	{ "bm12.12m",      0x00100, 0xc18aa136, BRF_GRA },	     	 //  27
600 	{ "bm11.12l",      0x00100, 0x405aae37, BRF_GRA },	     	 //  28
601 	{ "bm8.8c",        0x00100, 0xc2010a9e, BRF_GRA },	     	 //  29
602 	{ "bm7.7c",        0x00100, 0xb56f30c3, BRF_GRA },	     	 //  30
603 	{ "bm4.12c",       0x00100, 0x91a8a2e1, BRF_GRA },	     	 //  31
604 	{ "bm6.4b",        0x00100, 0x0eaf5158, BRF_GRA },	     	 //  32
605 };
606 
607 STD_ROM_PICK(Drvbj)
608 STD_ROM_FN(Drvbj)
609 
610 static struct BurnRomInfo DrvkaiRomDesc[] = {
611 	{ "bmk01.12d",     0x08000, 0x7d2211db, BRF_ESS | BRF_PRG }, //  0	Z80 #1 Program Code
612 	{ "bmk02.13d",     0x10000, 0x2ebbc8c5, BRF_ESS | BRF_PRG }, //	 1
613 	{ "bmk03.14d",     0x10000, 0x475a6ac5, BRF_ESS | BRF_PRG }, //	 2
614 
615 	{ "bmk05.4k",      0x08000, 0x25f37957, BRF_ESS | BRF_PRG }, //  3	Z80 #2 Program
616 
617 	{ "bmk04.5h",      0x08000, 0x884a8692, BRF_GRA },	     	 //  4	Characters
618 
619 	{ "bm15.10f",      0x08000, 0x6b1a0443, BRF_GRA },	     	 //  5	BG Tiles
620 	{ "bmk16.11f",     0x08000, 0x9416fe0d, BRF_GRA },	     	 //  6
621 	{ "bmk17.12f",     0x08000, 0x3d5acab9, BRF_GRA },	     	 //  7
622 	{ "bmk18.14f",     0x08000, 0x7b62da1d, BRF_GRA },	     	 //  8
623 	{ "bm19.10j",      0x08000, 0x868ababc, BRF_GRA },	     	 //  9
624 	{ "bmk20.11j",     0x08000, 0xb90364c1, BRF_GRA },	     	 //  10
625 	{ "bmk21.12j",     0x08000, 0x8c7fe74a, BRF_GRA },	     	 //  11
626 	{ "bmk22.14j",     0x08000, 0xd5ef8a0e, BRF_GRA },	     	 //  12
627 
628 	{ "bmk24.14k",     0x08000, 0xbf186ef2, BRF_GRA },	     	 //  13	BG2 Tiles
629 	{ "bmk25.14l",     0x08000, 0xa755faf1, BRF_GRA },	     	 //  14
630 
631 	{ "bmk06.10a",     0x08000, 0x5f7e38b3, BRF_GRA },	     	 //  15	Sprites
632 	{ "bmk07.11a",     0x08000, 0xff3751fd, BRF_GRA },	     	 //  16
633 	{ "bmk08.12a",     0x08000, 0x159d51bd, BRF_GRA },	     	 //  17
634 	{ "bmk09.14a",     0x08000, 0x8683e3d2, BRF_GRA },	     	 //  18
635 	{ "bmk10.10c",     0x08000, 0x1e0d9571, BRF_GRA },	     	 //  19
636 	{ "bmk11.11c",     0x08000, 0xf1fc5ee1, BRF_GRA },	     	 //  20
637 	{ "bmk12.12c",     0x08000, 0x0f50c001, BRF_GRA },	     	 //  21
638 	{ "bmk13.14c",     0x08000, 0xfd1acf8e, BRF_GRA },	     	 //  22
639 
640 	{ "bmk14.5f",      0x08000, 0xcf0f5a53, BRF_GRA },	     	 //  23	Tilemaps
641 	{ "bmk23.8k",      0x08000, 0x17f77ef9, BRF_GRA },	     	 //  24
642 
643 	{ "bmk1.12a",      0x00100, 0xe001ea33, BRF_GRA },	     	 //  25	PROMs
644 	{ "bmk2.13a",      0x00100, 0xaf34d91a, BRF_GRA },	     	 //  26
645 	{ "bmk3.14a",      0x00100, 0x43e9f6ef, BRF_GRA },	     	 //  27
646 	{ "bmk5.7f",       0x00100, 0x41878934, BRF_GRA },	     	 //  28
647 	{ "bmk10.7l",      0x00100, 0xde44b748, BRF_GRA },	     	 //  29
648 	{ "bmk9.6l",       0x00100, 0x59ea57c0, BRF_GRA },	     	 //  30
649 	{ "bmk12.12m",     0x00100, 0x8765f8b0, BRF_GRA },	     	 //  31
650 	{ "bmk11.12l",     0x00100, 0x87a8854e, BRF_GRA },	     	 //  32
651 	{ "bmk8.8c",       0x00100, 0xdad17e2d, BRF_GRA },	     	 //  33
652 	{ "bmk7.7c",       0x00100, 0x76307f8d, BRF_GRA },	     	 //  34
653 	{ "bm4.12c",       0x00100, 0x91a8a2e1, BRF_GRA },	     	 //  35
654 	{ "bm6.4b",        0x00100, 0x0eaf5158, BRF_GRA },	     	 //  36
655 
656 	{ "bm.7k",         0x10000, 0x00000000, BRF_NODUMP },	     //  37	MCU
657 };
658 
659 STD_ROM_PICK(Drvkai)
660 STD_ROM_FN(Drvkai)
661 
662 static struct BurnRomInfo DrvmiiRomDesc[] = {
663 	/* Prototype, location test or limited release? - PCB had genuine CAPCOM labels on the roms */
664 	{ "01.12d",        0x08000, 0x8ba22485, BRF_ESS | BRF_PRG }, //  0	Z80 #1 Program Code
665 	{ "02.13d",        0x10000, 0x659a5455, BRF_ESS | BRF_PRG }, //	 1
666 	{ "03.14d",        0x10000, 0x159ea771, BRF_ESS | BRF_PRG }, //	 2
667 
668 	{ "05.4k",         0x08000, 0x25f37957, BRF_ESS | BRF_PRG }, //  3	Z80 #2 Program
669 
670 	{ "04.5h",         0x08000, 0x8190e092, BRF_GRA },	     	 //  4	Characters
671 
672 	{ "bm15.10f",      0x08000, 0x6b1a0443, BRF_GRA },	     	 //  5	BG Tiles
673 	{ "bm16.11f",      0x08000, 0x23c908c2, BRF_GRA },	     	 //  6
674 	{ "17.12f",        0x08000, 0x3d5acab9, BRF_GRA },	     	 //  7
675 	{ "18.14f",        0x08000, 0x7b62da1d, BRF_GRA },	     	 //  8
676 	{ "bm19.10j",      0x08000, 0x868ababc, BRF_GRA },	     	 //  9
677 	{ "bm20.11j",      0x08000, 0x0917e5d4, BRF_GRA },	     	 //  10
678 	{ "21.12j",        0x08000, 0x8c7fe74a, BRF_GRA },	     	 //  11
679 	{ "22.14j",        0x08000, 0xd5ef8a0e, BRF_GRA },	     	 //  12
680 
681 	{ "24.14k",        0x08000, 0xa0074c68, BRF_GRA },	     	 //  13	BG2 Tiles
682 	{ "25.14l",        0x08000, 0xf979b2f2, BRF_GRA },	     	 //  14
683 
684 	{ "06.10a",        0x08000, 0xb261d5d7, BRF_GRA },	     	 //  15	Sprites
685 	{ "07.11a",        0x08000, 0x2af8a6f2, BRF_GRA },	     	 //  16
686 	{ "08.12a",        0x08000, 0x159d51bd, BRF_GRA },	     	 //  17
687 	{ "09.14a",        0x08000, 0x70d9f9a7, BRF_GRA },	     	 //  18
688 	{ "10.10c",        0x08000, 0xde539920, BRF_GRA },	     	 //  19
689 	{ "11.11c",        0x08000, 0xa6abf183, BRF_GRA },	     	 //  20
690 	{ "12.12c",        0x08000, 0x0f50c001, BRF_GRA },	     	 //  21
691 	{ "13.14c",        0x08000, 0xf065f619, BRF_GRA },	     	 //  22
692 
693 	{ "14.5f",         0x08000, 0x02a899f1, BRF_GRA },	     	 //  23	Tilemaps
694 	{ "23.8k",         0x08000, 0xb6dfdf85, BRF_GRA },	     	 //  24
695 
696 	//  PCB had standard BM0x for bproms 1 through 3, but clearly these should use the Kai BPROMs for correct colors
697     //  BPROMs 4 through 8 macth the Kai set - labels were a non descript yellow dot with prom number
698     //  BPROMs 9 through 12 are unique - labels were a non descript yellow dot with prom number
699 	{ "bmk1.12a",      0x00100, 0xe001ea33, BRF_GRA },	     	 //  25	PROMs
700 	{ "bmk2.13a",      0x00100, 0xaf34d91a, BRF_GRA },	     	 //  26
701 	{ "bmk3.14a",      0x00100, 0x43e9f6ef, BRF_GRA },	     	 //  27
702 	{ "5.7f",          0x00100, 0x41878934, BRF_GRA },	     	 //  28
703 	{ "10.7l",         0x00100, 0xdb53adf0, BRF_GRA },	     	 //  29
704 	{ "9.6l",          0x00100, 0x75d5cc90, BRF_GRA },	     	 //  30
705 	{ "12.12m",        0x00100, 0x784bdf33, BRF_GRA },	     	 //  31
706 	{ "11.12l",        0x00100, 0x6fb2e170, BRF_GRA },	     	 //  32
707 	{ "8.8c",          0x00100, 0xdad17e2d, BRF_GRA },	     	 //  33
708 	{ "7.7c",          0x00100, 0x76307f8d, BRF_GRA },	     	 //  34
709 	{ "4.12c",         0x00100, 0x91a8a2e1, BRF_GRA },	     	 //  35
710 	{ "6.4b",          0x00100, 0x0eaf5158, BRF_GRA },	     	 //  36
711 
712 	{ "bm.7k",         0x10000, 0x00000000, BRF_NODUMP },	     //  37	MCU
713 };
714 
715 STD_ROM_PICK(Drvmii)
STD_ROM_FN(Drvmii)716 STD_ROM_FN(Drvmii)
717 
718 static UINT8 Drv1943ProtRead()
719 {
720 	if (bootleg) return 0;
721 
722 	// This data comes from a table at $21a containing 64 entries, even is "case", odd is return value.
723 	switch (DrvProtValue) {
724 		case 0x24: return 0x1d;
725 		case 0x60: return 0xf7;
726 		case 0x01: return 0xac;
727 		case 0x55: return 0x50;
728 		case 0x56: return 0xe2;
729 		case 0x2a: return 0x58;
730 		case 0xa8: return 0x13;
731 		case 0x22: return 0x3e;
732 		case 0x3b: return 0x5a;
733 		case 0x1e: return 0x1b;
734 		case 0xe9: return 0x41;
735 		case 0x7d: return 0xd5;
736 		case 0x43: return 0x54;
737 		case 0x37: return 0x6f;
738 		case 0x4c: return 0x59;
739 		case 0x5f: return 0x56;
740 		case 0x3f: return 0x2f;
741 		case 0x3e: return 0x3d;
742 		case 0xfb: return 0x36;
743 		case 0x1d: return 0x3b;
744 		case 0x27: return 0xae;
745 		case 0x26: return 0x39;
746 		case 0x58: return 0x3c;
747 		case 0x32: return 0x51;
748 		case 0x1a: return 0xa8;
749 		case 0xbc: return 0x33;
750 		case 0x30: return 0x4a;
751 		case 0x64: return 0x12;
752 		case 0x11: return 0x40;
753 		case 0x33: return 0x35;
754 		case 0x09: return 0x17;
755 		case 0x25: return 0x04;
756 	}
757 
758 	return 0;
759 }
760 
Drv1943Read1(UINT16 a)761 static UINT8 __fastcall Drv1943Read1(UINT16 a)
762 {
763 	switch (a) {
764 		case 0xc000: {
765 			return DrvInput[0];
766 		}
767 
768 		case 0xc001: {
769 			return DrvInput[1];
770 		}
771 
772 		case 0xc002: {
773 			return DrvInput[2];
774 		}
775 
776 		case 0xc003: {
777 			return DrvDip[0];
778 		}
779 
780 		case 0xc004: {
781 			return DrvDip[1];
782 		}
783 
784 		case 0xc007: {
785 			return Drv1943ProtRead();
786 		}
787 
788 		default: {
789 			bprintf(PRINT_NORMAL, _T("Z80 #1 Read => %04X\n"), a);
790 		}
791 	}
792 
793 	return 0;
794 }
795 
Drv1943Write1(UINT16 a,UINT8 d)796 static void __fastcall Drv1943Write1(UINT16 a, UINT8 d)
797 {
798 	switch (a) {
799 		case 0xc800: {
800 			DrvSoundLatch = d;
801 			return;
802 		}
803 
804 		case 0xc804: {
805 			DrvRomBank = d & 0x1c;
806 
807 			ZetMapMemory(DrvZ80Rom1 + 0x10000 + (DrvRomBank * 0x1000), 0x8000, 0xbfff, MAP_ROM);
808 
809 			DrvCharsOn = d & 0x80;
810 			return;
811 		}
812 
813 		case 0xc806: {
814 			BurnWatchdogWrite();
815 			return;
816 		}
817 
818 		case 0xc807: {
819 			DrvProtValue = d;
820 			return;
821 		}
822 
823 		case 0xd800: {
824 			DrvBgScrollX[0] = d;
825 			return;
826 		}
827 
828 		case 0xd801: {
829 			DrvBgScrollX[1] = d;
830 			return;
831 		}
832 
833 		case 0xd802: {
834 			DrvBgScrollY = d;
835 			return;
836 		}
837 
838 		case 0xd803: {
839 			DrvBg2ScrollX[0] = d;
840 			return;
841 		}
842 
843 		case 0xd804: {
844 			DrvBg2ScrollX[1] = d;
845 			return;
846 		}
847 
848 		case 0xd806: {
849 			DrvBg1On = d & 0x10;
850 			DrvBg2On = d & 0x20;
851 			DrvSpritesOn = d & 0x40;
852 			return;
853 		}
854 
855 		case 0xD808:
856 		case 0xD868:
857 		case 0xD888:
858 		case 0xD8A8: {
859 			return; // NOP
860 		}
861 
862 		default: {
863 			bprintf(PRINT_NORMAL, _T("Z80 #1 Write => %04X, %02X\n"), a, d);
864 		}
865 	}
866 }
867 
Drv1943Read2(UINT16 a)868 static UINT8 __fastcall Drv1943Read2(UINT16 a)
869 {
870 	switch (a) {
871 		case 0xc800: {
872 			return DrvSoundLatch;
873 		}
874 
875 		default: {
876 			bprintf(PRINT_NORMAL, _T("Z80 #2 Read => %04X\n"), a);
877 		}
878 	}
879 
880 	return 0;
881 }
882 
Drv1943Write2(UINT16 a,UINT8 d)883 static void __fastcall Drv1943Write2(UINT16 a, UINT8 d)
884 {
885 	switch (a) {
886 		case 0xe000:
887 		case 0xe001: {
888 			BurnYM2203Write(0, a & 1, d);
889 			return;
890 		}
891 
892 		case 0xe002:
893 		case 0xe003: {
894 			BurnYM2203Write(1, a & 1, d);
895 			return;
896 		}
897 
898 		default: {
899 			bprintf(PRINT_NORMAL, _T("Z80 #2 Write => %04X, %02X\n"), a, d);
900 		}
901 	}
902 }
903 
904 static INT32 CharPlaneOffsets[2]    = { 4, 0 };
905 static INT32 CharXOffsets[8]        = { STEP4(0,1), STEP4(8,1) };
906 static INT32 CharYOffsets[8]        = { STEP8(0,16) };
907 static INT32 Bg2TilePlaneOffsets[4] = { 0x40004, 0x40000, 4, 0 };
908 static INT32 BgTilePlaneOffsets[4]  = { 0x100004, 0x100000, 4, 0 };
909 static INT32 TileXOffsets[32]       = { STEP4(0,1), STEP4(8,1), STEP4(512,1), STEP4(520,1), STEP4(1024,1), STEP4(1032,1), STEP4(1536,1), STEP4(1544,1) };
910 static INT32 TileYOffsets[32]       = { STEP32(0,16) };
911 static INT32 SpritePlaneOffsets[4]  = { 0x100004, 0x100000, 4, 0 };
912 static INT32 SpriteXOffsets[16]     = { STEP4(0,1), STEP4(8,1), STEP4(256,1), STEP4(264,1) };
913 static INT32 SpriteYOffsets[16]     = { STEP16(0,16) };
914 
tilemap_callback(bg2)915 static tilemap_callback( bg2 )
916 {
917 	INT32 Attr = DrvBg2Tilemap[offs * 2 + 1];
918 	INT32 Code = DrvBg2Tilemap[offs * 2 + 0];
919 
920 	TILE_SET_INFO(0, Code, ((Attr >> 2) & 0xf) + 0x18, TILE_FLIPYX(Attr >> 6));
921 }
922 
tilemap_callback(bg1)923 static tilemap_callback( bg1 )
924 {
925 	INT32 Attr = DrvBgTilemap[offs * 2 + 1];
926 	INT32 Code = DrvBgTilemap[offs * 2 + 0] + ((Attr & 0x01) << 8);
927 
928 	TILE_SET_INFO(1, Code, ((Attr >> 2) & 0xf) + 0x08, TILE_FLIPYX(Attr >> 6));
929 }
930 
tilemap_callback(fg)931 static tilemap_callback( fg )
932 {
933 	INT32 Attr = DrvPaletteRam[offs];
934 	INT32 Code = DrvVideoRam[offs] + ((Attr & 0xe0) << 3);
935 
936 	TILE_SET_INFO(2, Code, Attr, 0);
937 }
938 
DrvDoReset(INT32 clear_mem)939 static INT32 DrvDoReset(INT32 clear_mem)
940 {
941 	ZetOpen(0);
942 	ZetReset();
943 	ZetClose();
944 
945 	ZetOpen(1);
946 	ZetReset();
947 	BurnYM2203Reset();
948 	ZetClose();
949 
950 	BurnWatchdogReset();
951 
952 	if (clear_mem) {
953 		DrvRomBank = 0;
954 		DrvSoundLatch = 0;
955 		DrvBg2ScrollX[0] = 0;
956 		DrvBg2ScrollX[1] = 0;
957 		DrvBgScrollX[0] = 0;
958 		DrvBgScrollX[1] = 0;
959 		DrvBgScrollY = 0;
960 		DrvBg2On = 0;
961 		DrvBg1On = 0;
962 		DrvSpritesOn = 0;
963 		DrvCharsOn = 0;
964 		DrvProtValue = 0;
965 
966 		HiscoreReset();
967 	}
968 
969 	return 0;
970 }
971 
MemIndex()972 static INT32 MemIndex()
973 {
974 	UINT8 *Next; Next = Mem;
975 
976 	DrvZ80Rom1             = Next; Next += 0x30000;
977 	DrvZ80Rom2             = Next; Next += 0x08000;
978 	DrvPromRed             = Next; Next += 0x00100;
979 	DrvPromGreen           = Next; Next += 0x00100;
980 	DrvPromBlue            = Next; Next += 0x00100;
981 	DrvPromCharLookup      = Next; Next += 0x00100;
982 	DrvPromBg2Lookup       = Next; Next += 0x00100;
983 	DrvPromBg2PalBank      = Next; Next += 0x00100;
984 	DrvPromBgLookup        = Next; Next += 0x00100;
985 	DrvPromBgPalBank       = Next; Next += 0x00100;
986 	DrvPromSpriteLookup    = Next; Next += 0x00100;
987 	DrvPromSpritePalBank   = Next; Next += 0x00100;
988 	DrvBgTilemap           = Next; Next += 0x08000;
989 	DrvBg2Tilemap          = Next; Next += 0x08000;
990 
991 	RamStart               = Next;
992 
993 	DrvZ80Ram1             = Next; Next += 0x01000;
994 	DrvZ80Ram2             = Next; Next += 0x00800;
995 	DrvVideoRam            = Next; Next += 0x00400;
996 	DrvPaletteRam          = Next; Next += 0x00400;
997 	DrvSpriteRam           = Next; Next += 0x01000;
998 
999 	RamEnd                 = Next;
1000 
1001 	DrvChars               = Next; Next += 2048 * 8 * 8;
1002 	DrvBg2Tiles            = Next; Next += 128 * 32 * 32;
1003 	DrvBgTiles             = Next; Next += 512 * 32 * 32;
1004 	DrvSprites             = Next; Next += 2048 * 16 * 16;
1005 	DrvPalette             = (UINT32*)Next; Next += 0x00380 * sizeof(UINT32);
1006 
1007 	MemEnd                 = Next;
1008 
1009 	return 0;
1010 }
1011 
CommonInit(INT32 (* load)())1012 static INT32 CommonInit(INT32 (*load)())
1013 {
1014 	// Allocate and Blank all required memory
1015 	Mem = NULL;
1016 	MemIndex();
1017 	INT32 nLen = MemEnd - (UINT8 *)0;
1018 	if ((Mem = (UINT8 *)BurnMalloc(nLen)) == NULL) return 1;
1019 	memset(Mem, 0, nLen);
1020 	MemIndex();
1021 
1022 	if (load()) return 1;
1023 
1024 	// Setup the Z80 emulation
1025 	ZetInit(0);
1026 	ZetOpen(0);
1027 	ZetMapMemory(DrvZ80Rom1,		0x0000, 0x7fff, MAP_ROM);
1028 	ZetMapMemory(DrvZ80Rom1 + 0x10000,	0x8000, 0xbfff, MAP_ROM);
1029 	ZetMapMemory(DrvVideoRam,		0xd000, 0xd3ff, MAP_RAM);
1030 	ZetMapMemory(DrvPaletteRam,		0xd400, 0xd7ff, MAP_RAM);
1031 	ZetMapMemory(DrvZ80Ram1,		0xe000, 0xefff, MAP_RAM);
1032 	ZetMapMemory(DrvSpriteRam,		0xf000, 0xffff, MAP_RAM);
1033 	ZetSetReadHandler(Drv1943Read1);
1034 	ZetSetWriteHandler(Drv1943Write1);
1035 	ZetClose();
1036 
1037 	ZetInit(1);
1038 	ZetOpen(1);
1039 	ZetMapMemory(DrvZ80Rom2,		0x0000, 0x7fff, MAP_ROM);
1040 	ZetMapMemory(DrvZ80Ram2,		0xc000, 0xc7ff, MAP_RAM);
1041 	ZetSetReadHandler(Drv1943Read2);
1042 	ZetSetWriteHandler(Drv1943Write2);
1043 	ZetClose();
1044 
1045 	BurnWatchdogInit(DrvDoReset, 180);
1046 
1047 	BurnYM2203Init(2, 1500000, NULL, 0);
1048 	BurnTimerAttachZet(3000000);
1049 	BurnYM2203SetRoute(0, BURN_SND_YM2203_YM2203_ROUTE, 0.10, BURN_SND_ROUTE_BOTH);
1050 	BurnYM2203SetRoute(0, BURN_SND_YM2203_AY8910_ROUTE_1, 0.15, BURN_SND_ROUTE_BOTH);
1051 	BurnYM2203SetRoute(0, BURN_SND_YM2203_AY8910_ROUTE_2, 0.15, BURN_SND_ROUTE_BOTH);
1052 	BurnYM2203SetRoute(0, BURN_SND_YM2203_AY8910_ROUTE_3, 0.15, BURN_SND_ROUTE_BOTH);
1053 	BurnYM2203SetRoute(1, BURN_SND_YM2203_YM2203_ROUTE, 0.10, BURN_SND_ROUTE_BOTH);
1054 	BurnYM2203SetRoute(1, BURN_SND_YM2203_AY8910_ROUTE_1, 0.15, BURN_SND_ROUTE_BOTH);
1055 	BurnYM2203SetRoute(1, BURN_SND_YM2203_AY8910_ROUTE_2, 0.15, BURN_SND_ROUTE_BOTH);
1056 	BurnYM2203SetRoute(1, BURN_SND_YM2203_AY8910_ROUTE_3, 0.15, BURN_SND_ROUTE_BOTH);
1057 
1058 	GenericTilesInit();
1059 	GenericTilemapInit(0, TILEMAP_SCAN_COLS, bg2_map_callback, 32, 32, 2048,  8);
1060 	GenericTilemapInit(1, TILEMAP_SCAN_COLS, bg1_map_callback, 32, 32, 2048,  8);
1061 	GenericTilemapInit(2, TILEMAP_SCAN_ROWS, fg_map_callback,   8,  8,   32, 32);
1062 	GenericTilemapSetGfx(0, DrvBg2Tiles, 4, 32, 32, 0x20000, 0x000, 0x3f);
1063 	GenericTilemapSetGfx(1, DrvBgTiles,  4, 32, 32, 0x80000, 0x000, 0x3f);
1064 	GenericTilemapSetGfx(2, DrvChars,    2,  8,  8, 0x20000, 0x000, 0x1f);
1065 	GenericTilemapSetOffsets(TMAP_GLOBAL, 0, -16);
1066 	GenericTilemapSetTransparent(1, 0);
1067 	GenericTilemapSetTransparent(2, 0);
1068 
1069 	// Reset the driver
1070 	DrvDoReset(1);
1071 
1072 	return 0;
1073 }
1074 
DrvLoad()1075 static INT32 DrvLoad()
1076 {
1077 	INT32 nRet = 0;
1078 
1079 	DrvTempRom = (UINT8 *)BurnMalloc(0x40000);
1080 
1081 	// Load Z80 #1 Program Roms
1082 	nRet = BurnLoadRom(DrvZ80Rom1 + 0x00000, 0, 1); if (nRet != 0) return 1;
1083 	nRet = BurnLoadRom(DrvZ80Rom1 + 0x10000, 1, 1); if (nRet != 0) return 1;
1084 	nRet = BurnLoadRom(DrvZ80Rom1 + 0x20000, 2, 1); if (nRet != 0) return 1;
1085 
1086 	// Load Z80 #2 Program Roms
1087 	nRet = BurnLoadRom(DrvZ80Rom2 + 0x00000, 3, 1); if (nRet != 0) return 1;
1088 
1089 	// Load and decode the chars
1090 	nRet = BurnLoadRom(DrvTempRom, 4, 1); if (nRet != 0) return 1;
1091 	GfxDecode(2048, 2, 8, 8, CharPlaneOffsets, CharXOffsets, CharYOffsets, 0x80, DrvTempRom, DrvChars);
1092 
1093 	// Load and decode the bg2 tiles
1094 	memset(DrvTempRom, 0, 0x40000);
1095 	nRet = BurnLoadRom(DrvTempRom + 0x00000, 13, 1); if (nRet != 0) return 1;
1096 	nRet = BurnLoadRom(DrvTempRom + 0x08000, 14, 1); if (nRet != 0) return 1;
1097 	GfxDecode(128, 4, 32, 32, Bg2TilePlaneOffsets, TileXOffsets, TileYOffsets, 0x800, DrvTempRom, DrvBg2Tiles);
1098 
1099 	// Load and decode the bg tiles
1100 	memset(DrvTempRom, 0, 0x40000);
1101 	nRet = BurnLoadRom(DrvTempRom + 0x00000,  5, 1); if (nRet != 0) return 1;
1102 	nRet = BurnLoadRom(DrvTempRom + 0x08000,  6, 1); if (nRet != 0) return 1;
1103 	nRet = BurnLoadRom(DrvTempRom + 0x10000,  7, 1); if (nRet != 0) return 1;
1104 	nRet = BurnLoadRom(DrvTempRom + 0x18000,  8, 1); if (nRet != 0) return 1;
1105 	nRet = BurnLoadRom(DrvTempRom + 0x20000,  9, 1); if (nRet != 0) return 1;
1106 	nRet = BurnLoadRom(DrvTempRom + 0x28000, 10, 1); if (nRet != 0) return 1;
1107 	nRet = BurnLoadRom(DrvTempRom + 0x30000, 11, 1); if (nRet != 0) return 1;
1108 	nRet = BurnLoadRom(DrvTempRom + 0x38000, 12, 1); if (nRet != 0) return 1;
1109 	GfxDecode(512, 4, 32, 32, BgTilePlaneOffsets, TileXOffsets, TileYOffsets, 0x800, DrvTempRom, DrvBgTiles);
1110 
1111 	// Load and decode the sprites
1112 	memset(DrvTempRom, 0, 0x40000);
1113 	nRet = BurnLoadRom(DrvTempRom + 0x00000, 15, 1); if (nRet != 0) return 1;
1114 	nRet = BurnLoadRom(DrvTempRom + 0x08000, 16, 1); if (nRet != 0) return 1;
1115 	nRet = BurnLoadRom(DrvTempRom + 0x10000, 17, 1); if (nRet != 0) return 1;
1116 	nRet = BurnLoadRom(DrvTempRom + 0x18000, 18, 1); if (nRet != 0) return 1;
1117 	nRet = BurnLoadRom(DrvTempRom + 0x20000, 19, 1); if (nRet != 0) return 1;
1118 	nRet = BurnLoadRom(DrvTempRom + 0x28000, 20, 1); if (nRet != 0) return 1;
1119 	nRet = BurnLoadRom(DrvTempRom + 0x30000, 21, 1); if (nRet != 0) return 1;
1120 	nRet = BurnLoadRom(DrvTempRom + 0x38000, 22, 1); if (nRet != 0) return 1;
1121 	GfxDecode(2048, 4, 16, 16, SpritePlaneOffsets, SpriteXOffsets, SpriteYOffsets, 0x200, DrvTempRom, DrvSprites);
1122 
1123 	// Load the Tilemaps
1124 	nRet = BurnLoadRom(DrvBgTilemap,         23, 1); if (nRet != 0) return 1;
1125 	nRet = BurnLoadRom(DrvBg2Tilemap,        24, 1); if (nRet != 0) return 1;
1126 
1127 	// Load the PROMs
1128 	nRet = BurnLoadRom(DrvPromRed,           25, 1); if (nRet != 0) return 1;
1129 	nRet = BurnLoadRom(DrvPromGreen,         26, 1); if (nRet != 0) return 1;
1130 	nRet = BurnLoadRom(DrvPromBlue,          27, 1); if (nRet != 0) return 1;
1131 	nRet = BurnLoadRom(DrvPromCharLookup,    28, 1); if (nRet != 0) return 1;
1132 	nRet = BurnLoadRom(DrvPromBgLookup,      29, 1); if (nRet != 0) return 1;
1133 	nRet = BurnLoadRom(DrvPromBgPalBank,     30, 1); if (nRet != 0) return 1;
1134 	nRet = BurnLoadRom(DrvPromBg2Lookup,     31, 1); if (nRet != 0) return 1;
1135 	nRet = BurnLoadRom(DrvPromBg2PalBank,    32, 1); if (nRet != 0) return 1;
1136 	nRet = BurnLoadRom(DrvPromSpriteLookup,  33, 1); if (nRet != 0) return 1;
1137 	nRet = BurnLoadRom(DrvPromSpritePalBank, 34, 1); if (nRet != 0) return 1;
1138 
1139 	BurnFree(DrvTempRom);
1140 
1141 	return nRet;
1142 }
1143 
DrvInit()1144 static INT32 DrvInit()
1145 {
1146 	return CommonInit(DrvLoad);
1147 }
1148 
DrvbLoad()1149 static INT32 DrvbLoad()
1150 {
1151 	INT32 nRet = 0;
1152 
1153 	DrvTempRom = (UINT8 *)BurnMalloc(0x40000);
1154 
1155 	// Load Z80 #1 Program Roms
1156 	nRet = BurnLoadRom(DrvZ80Rom1 + 0x00000, 0, 1); if (nRet != 0) return 1;
1157 	nRet = BurnLoadRom(DrvZ80Rom1 + 0x10000, 1, 1); if (nRet != 0) return 1;
1158 	nRet = BurnLoadRom(DrvZ80Rom1 + 0x20000, 2, 1); if (nRet != 0) return 1;
1159 
1160 	// Load Z80 #2 Program Roms
1161 	nRet = BurnLoadRom(DrvZ80Rom2 + 0x00000, 3, 1); if (nRet != 0) return 1;
1162 
1163 	// Load and decode the chars
1164 	nRet = BurnLoadRom(DrvTempRom, 4, 1); if (nRet != 0) return 1;
1165 	GfxDecode(2048, 2, 8, 8, CharPlaneOffsets, CharXOffsets, CharYOffsets, 0x80, DrvTempRom, DrvChars);
1166 
1167 	// Load and decode the bg2 tiles
1168 	memset(DrvTempRom, 0, 0x40000);
1169 	nRet = BurnLoadRom(DrvTempRom + 0x00000,  9, 1); if (nRet != 0) return 1;
1170 	nRet = BurnLoadRom(DrvTempRom + 0x08000, 10, 1); if (nRet != 0) return 1;
1171 	GfxDecode(128, 4, 32, 32, Bg2TilePlaneOffsets, TileXOffsets, TileYOffsets, 0x800, DrvTempRom, DrvBg2Tiles);
1172 
1173 	// Load and decode the bg tiles
1174 	memset(DrvTempRom, 0, 0x40000);
1175 	nRet = BurnLoadRom(DrvTempRom + 0x00000,  5, 1); if (nRet != 0) return 1;
1176 	nRet = BurnLoadRom(DrvTempRom + 0x10000,  6, 1); if (nRet != 0) return 1;
1177 	nRet = BurnLoadRom(DrvTempRom + 0x20000,  7, 1); if (nRet != 0) return 1;
1178 	nRet = BurnLoadRom(DrvTempRom + 0x30000,  8, 1); if (nRet != 0) return 1;
1179 	GfxDecode(512, 4, 32, 32, BgTilePlaneOffsets, TileXOffsets, TileYOffsets, 0x800, DrvTempRom, DrvBgTiles);
1180 
1181 	// Load and decode the sprites
1182 	memset(DrvTempRom, 0, 0x40000);
1183 	nRet = BurnLoadRom(DrvTempRom + 0x00000, 11, 1); if (nRet != 0) return 1;
1184 	nRet = BurnLoadRom(DrvTempRom + 0x08000, 12, 1); if (nRet != 0) return 1;
1185 	nRet = BurnLoadRom(DrvTempRom + 0x10000, 13, 1); if (nRet != 0) return 1;
1186 	nRet = BurnLoadRom(DrvTempRom + 0x18000, 14, 1); if (nRet != 0) return 1;
1187 	nRet = BurnLoadRom(DrvTempRom + 0x20000, 15, 1); if (nRet != 0) return 1;
1188 	nRet = BurnLoadRom(DrvTempRom + 0x28000, 16, 1); if (nRet != 0) return 1;
1189 	nRet = BurnLoadRom(DrvTempRom + 0x30000, 17, 1); if (nRet != 0) return 1;
1190 	nRet = BurnLoadRom(DrvTempRom + 0x38000, 18, 1); if (nRet != 0) return 1;
1191 	GfxDecode(2048, 4, 16, 16, SpritePlaneOffsets, SpriteXOffsets, SpriteYOffsets, 0x200, DrvTempRom, DrvSprites);
1192 
1193 	// Load the Tilemaps
1194 	nRet = BurnLoadRom(DrvBgTilemap,         19, 1); if (nRet != 0) return 1;
1195 	nRet = BurnLoadRom(DrvBg2Tilemap,        20, 1); if (nRet != 0) return 1;
1196 
1197 	// Load the PROMs
1198 	nRet = BurnLoadRom(DrvPromRed,           21, 1); if (nRet != 0) return 1;
1199 	nRet = BurnLoadRom(DrvPromGreen,         22, 1); if (nRet != 0) return 1;
1200 	nRet = BurnLoadRom(DrvPromBlue,          23, 1); if (nRet != 0) return 1;
1201 	nRet = BurnLoadRom(DrvPromCharLookup,    24, 1); if (nRet != 0) return 1;
1202 	nRet = BurnLoadRom(DrvPromBgLookup,      25, 1); if (nRet != 0) return 1;
1203 	nRet = BurnLoadRom(DrvPromBgPalBank,     26, 1); if (nRet != 0) return 1;
1204 	nRet = BurnLoadRom(DrvPromBg2Lookup,     27, 1); if (nRet != 0) return 1;
1205 	nRet = BurnLoadRom(DrvPromBg2PalBank,    28, 1); if (nRet != 0) return 1;
1206 	nRet = BurnLoadRom(DrvPromSpriteLookup,  29, 1); if (nRet != 0) return 1;
1207 	nRet = BurnLoadRom(DrvPromSpritePalBank, 30, 1); if (nRet != 0) return 1;
1208 
1209 	BurnFree(DrvTempRom);
1210 
1211 	return nRet;
1212 }
1213 
DrvbInit()1214 static INT32 DrvbInit()
1215 {
1216 	bootleg = 1;
1217 	return CommonInit(DrvbLoad);
1218 }
1219 
DrvbjLoad()1220 static INT32 DrvbjLoad()
1221 {
1222 	INT32 nRet = 0;
1223 
1224 	DrvTempRom = (UINT8 *)BurnMalloc(0x40000);
1225 
1226 	// Load Z80 #1 Program Roms
1227 	nRet = BurnLoadRom(DrvZ80Rom1 + 0x00000, 0, 1); if (nRet != 0) return 1;
1228 	nRet = BurnLoadRom(DrvZ80Rom1 + 0x10000, 1, 1); if (nRet != 0) return 1;
1229 	nRet = BurnLoadRom(DrvZ80Rom1 + 0x20000, 2, 1); if (nRet != 0) return 1;
1230 
1231 	// Load Z80 #2 Program Roms
1232 	nRet = BurnLoadRom(DrvZ80Rom2 + 0x00000, 3, 1); if (nRet != 0) return 1;
1233 
1234 	// Load and decode the chars
1235 	nRet = BurnLoadRom(DrvTempRom, 4, 1); if (nRet != 0) return 1;
1236 	GfxDecode(2048, 2, 8, 8, CharPlaneOffsets, CharXOffsets, CharYOffsets, 0x80, DrvTempRom, DrvChars);
1237 
1238 	// Load and decode the bg2 tiles
1239 	memset(DrvTempRom, 0, 0x40000);
1240 	nRet = BurnLoadRom(DrvTempRom + 0x00000,  9, 1); if (nRet != 0) return 1;
1241 	nRet = BurnLoadRom(DrvTempRom + 0x08000, 10, 1); if (nRet != 0) return 1;
1242 	GfxDecode(128, 4, 32, 32, Bg2TilePlaneOffsets, TileXOffsets, TileYOffsets, 0x800, DrvTempRom, DrvBg2Tiles);
1243 
1244 	memset(DrvTempRom, 0, 0x40000);
1245 	UINT8 *pTemp = (UINT8*)BurnMalloc(0x40000);
1246 	nRet = BurnLoadRom(pTemp + 0x00000,  5, 1); if (nRet != 0) return 1;
1247 	nRet = BurnLoadRom(pTemp + 0x10000,  6, 1); if (nRet != 0) return 1;
1248 	nRet = BurnLoadRom(pTemp + 0x20000,  7, 1); if (nRet != 0) return 1;
1249 	nRet = BurnLoadRom(pTemp + 0x30000,  8, 1); if (nRet != 0) return 1;
1250 	memcpy(DrvTempRom + 0x00000, pTemp + 0x00000, 0x8000);
1251 	memcpy(DrvTempRom + 0x10000, pTemp + 0x08000, 0x8000);
1252 	memcpy(DrvTempRom + 0x08000, pTemp + 0x10000, 0x8000);
1253 	memcpy(DrvTempRom + 0x18000, pTemp + 0x18000, 0x8000);
1254 	memcpy(DrvTempRom + 0x20000, pTemp + 0x20000, 0x8000);
1255 	memcpy(DrvTempRom + 0x30000, pTemp + 0x28000, 0x8000);
1256 	memcpy(DrvTempRom + 0x28000, pTemp + 0x30000, 0x8000);
1257 	memcpy(DrvTempRom + 0x38000, pTemp + 0x38000, 0x8000);
1258 	BurnFree(pTemp);
1259 	GfxDecode(512, 4, 32, 32, BgTilePlaneOffsets, TileXOffsets, TileYOffsets, 0x800, DrvTempRom, DrvBgTiles);
1260 
1261 	// Load and decode the sprites
1262 	memset(DrvTempRom, 0, 0x40000);
1263 	nRet = BurnLoadRom(DrvTempRom + 0x00000, 11, 1); if (nRet != 0) return 1;
1264 	nRet = BurnLoadRom(DrvTempRom + 0x08000, 12, 1); if (nRet != 0) return 1;
1265 	nRet = BurnLoadRom(DrvTempRom + 0x10000, 13, 1); if (nRet != 0) return 1;
1266 	nRet = BurnLoadRom(DrvTempRom + 0x18000, 14, 1); if (nRet != 0) return 1;
1267 	nRet = BurnLoadRom(DrvTempRom + 0x20000, 15, 1); if (nRet != 0) return 1;
1268 	nRet = BurnLoadRom(DrvTempRom + 0x28000, 16, 1); if (nRet != 0) return 1;
1269 	nRet = BurnLoadRom(DrvTempRom + 0x30000, 17, 1); if (nRet != 0) return 1;
1270 	nRet = BurnLoadRom(DrvTempRom + 0x38000, 18, 1); if (nRet != 0) return 1;
1271 	GfxDecode(2048, 4, 16, 16, SpritePlaneOffsets, SpriteXOffsets, SpriteYOffsets, 0x200, DrvTempRom, DrvSprites);
1272 
1273 	// Load the Tilemaps
1274 	nRet = BurnLoadRom(DrvBgTilemap,         19, 1); if (nRet != 0) return 1;
1275 	nRet = BurnLoadRom(DrvTempRom,           20, 1); if (nRet != 0) return 1;
1276 	memcpy(DrvBg2Tilemap + 0x6000, DrvTempRom + 0x0000, 0x2000);
1277 	memcpy(DrvBg2Tilemap + 0x4000, DrvTempRom + 0x2000, 0x2000);
1278 	memcpy(DrvBg2Tilemap + 0x2000, DrvTempRom + 0x4000, 0x2000);
1279 	memcpy(DrvBg2Tilemap + 0x0000, DrvTempRom + 0x6000, 0x2000);
1280 
1281 	// Load the PROMs
1282 	nRet = BurnLoadRom(DrvPromRed,           21, 1); if (nRet != 0) return 1;
1283 	nRet = BurnLoadRom(DrvPromGreen,         22, 1); if (nRet != 0) return 1;
1284 	nRet = BurnLoadRom(DrvPromBlue,          23, 1); if (nRet != 0) return 1;
1285 	nRet = BurnLoadRom(DrvPromCharLookup,    24, 1); if (nRet != 0) return 1;
1286 	nRet = BurnLoadRom(DrvPromBgLookup,      25, 1); if (nRet != 0) return 1;
1287 	nRet = BurnLoadRom(DrvPromBgPalBank,     26, 1); if (nRet != 0) return 1;
1288 	nRet = BurnLoadRom(DrvPromBg2Lookup,     27, 1); if (nRet != 0) return 1;
1289 	nRet = BurnLoadRom(DrvPromBg2PalBank,    28, 1); if (nRet != 0) return 1;
1290 	nRet = BurnLoadRom(DrvPromSpriteLookup,  29, 1); if (nRet != 0) return 1;
1291 	nRet = BurnLoadRom(DrvPromSpritePalBank, 30, 1); if (nRet != 0) return 1;
1292 
1293 	BurnFree(DrvTempRom);
1294 
1295 	return nRet;
1296 }
1297 
DrvbjInit()1298 static INT32 DrvbjInit()
1299 {
1300 	bootleg = 1;
1301 
1302 	return CommonInit(DrvbjLoad);
1303 }
1304 
Drvb2Load()1305 static INT32 Drvb2Load()
1306 {
1307 	INT32 nRet = 0;
1308 
1309 	DrvTempRom = (UINT8 *)BurnMalloc(0x40000);
1310 
1311 	// Load Z80 #1 Program Roms
1312 	nRet = BurnLoadRom(DrvZ80Rom1 + 0x00000, 0, 1); if (nRet != 0) return 1;
1313 	nRet = BurnLoadRom(DrvZ80Rom1 + 0x10000, 1, 1); if (nRet != 0) return 1;
1314 	nRet = BurnLoadRom(DrvZ80Rom1 + 0x20000, 2, 1); if (nRet != 0) return 1;
1315 
1316 	// Load Z80 #2 Program Roms
1317 	nRet = BurnLoadRom(DrvZ80Rom2 + 0x00000, 3, 1); if (nRet != 0) return 1;
1318 
1319 	// Load and decode the chars
1320 	nRet = BurnLoadRom(DrvTempRom, 4, 1); if (nRet != 0) return 1;
1321 	GfxDecode(2048, 2, 8, 8, CharPlaneOffsets, CharXOffsets, CharYOffsets, 0x80, DrvTempRom, DrvChars);
1322 
1323 	// Load and decode the bg2 tiles
1324 	memset(DrvTempRom, 0, 0x40000);
1325 	nRet = BurnLoadRom(DrvTempRom + 0x00000,  9, 1); if (nRet != 0) return 1;
1326 	nRet = BurnLoadRom(DrvTempRom + 0x08000, 10, 1); if (nRet != 0) return 1;
1327 	GfxDecode(128, 4, 32, 32, Bg2TilePlaneOffsets, TileXOffsets, TileYOffsets, 0x800, DrvTempRom, DrvBg2Tiles);
1328 
1329 	memset(DrvTempRom, 0, 0x40000);
1330 	UINT8 *pTemp = (UINT8*)BurnMalloc(0x40000);
1331 	nRet = BurnLoadRom(pTemp + 0x00000,  5, 1); if (nRet != 0) return 1;
1332 	nRet = BurnLoadRom(pTemp + 0x10000,  6, 1); if (nRet != 0) return 1;
1333 	nRet = BurnLoadRom(pTemp + 0x20000,  7, 1); if (nRet != 0) return 1;
1334 	nRet = BurnLoadRom(pTemp + 0x30000,  8, 1); if (nRet != 0) return 1;
1335 	memcpy(DrvTempRom + 0x00000, pTemp + 0x00000, 0x8000);
1336 	memcpy(DrvTempRom + 0x10000, pTemp + 0x08000, 0x8000);
1337 	memcpy(DrvTempRom + 0x08000, pTemp + 0x10000, 0x8000);
1338 	memcpy(DrvTempRom + 0x18000, pTemp + 0x18000, 0x8000);
1339 	memcpy(DrvTempRom + 0x20000, pTemp + 0x20000, 0x8000);
1340 	memcpy(DrvTempRom + 0x30000, pTemp + 0x28000, 0x8000);
1341 	memcpy(DrvTempRom + 0x28000, pTemp + 0x30000, 0x8000);
1342 	memcpy(DrvTempRom + 0x38000, pTemp + 0x38000, 0x8000);
1343 	BurnFree(pTemp);
1344 	GfxDecode(512, 4, 32, 32, BgTilePlaneOffsets, TileXOffsets, TileYOffsets, 0x800, DrvTempRom, DrvBgTiles);
1345 
1346 	// Load and decode the sprites
1347 	memset(DrvTempRom, 0, 0x40000);
1348 	nRet = BurnLoadRom(DrvTempRom + 0x00000, 11, 1); if (nRet != 0) return 1;
1349 	nRet = BurnLoadRom(DrvTempRom + 0x08000, 12, 1); if (nRet != 0) return 1;
1350 	nRet = BurnLoadRom(DrvTempRom + 0x10000, 13, 1); if (nRet != 0) return 1;
1351 	nRet = BurnLoadRom(DrvTempRom + 0x20000, 14, 1); if (nRet != 0) return 1;
1352 	nRet = BurnLoadRom(DrvTempRom + 0x28000, 15, 1); if (nRet != 0) return 1;
1353 	nRet = BurnLoadRom(DrvTempRom + 0x30000, 16, 1); if (nRet != 0) return 1;
1354 	GfxDecode(2048, 4, 16, 16, SpritePlaneOffsets, SpriteXOffsets, SpriteYOffsets, 0x200, DrvTempRom, DrvSprites);
1355 
1356 	// Load the Tilemaps
1357 	nRet = BurnLoadRom(DrvBgTilemap,         17, 1); if (nRet != 0) return 1;
1358 	nRet = BurnLoadRom(DrvTempRom,           18, 1); if (nRet != 0) return 1;
1359 	memcpy(DrvBg2Tilemap + 0x6000, DrvTempRom + 0x0000, 0x2000);
1360 	memcpy(DrvBg2Tilemap + 0x4000, DrvTempRom + 0x2000, 0x2000);
1361 	memcpy(DrvBg2Tilemap + 0x2000, DrvTempRom + 0x4000, 0x2000);
1362 	memcpy(DrvBg2Tilemap + 0x0000, DrvTempRom + 0x6000, 0x2000);
1363 
1364 	// Load the PROMs
1365 	nRet = BurnLoadRom(DrvPromRed,           19, 1); if (nRet != 0) return 1;
1366 	nRet = BurnLoadRom(DrvPromGreen,         20, 1); if (nRet != 0) return 1;
1367 	nRet = BurnLoadRom(DrvPromBlue,          21, 1); if (nRet != 0) return 1;
1368 	nRet = BurnLoadRom(DrvPromCharLookup,    22, 1); if (nRet != 0) return 1;
1369 	nRet = BurnLoadRom(DrvPromBgLookup,      23, 1); if (nRet != 0) return 1;
1370 	nRet = BurnLoadRom(DrvPromBgPalBank,     24, 1); if (nRet != 0) return 1;
1371 	nRet = BurnLoadRom(DrvPromBg2Lookup,     25, 1); if (nRet != 0) return 1;
1372 	nRet = BurnLoadRom(DrvPromBg2PalBank,    26, 1); if (nRet != 0) return 1;
1373 	nRet = BurnLoadRom(DrvPromSpriteLookup,  27, 1); if (nRet != 0) return 1;
1374 	nRet = BurnLoadRom(DrvPromSpritePalBank, 28, 1); if (nRet != 0) return 1;
1375 
1376 	BurnFree(DrvTempRom);
1377 
1378 	return nRet;
1379 }
1380 
Drvb2Init()1381 static INT32 Drvb2Init()
1382 {
1383 	bootleg = 1;
1384 
1385 	return CommonInit(Drvb2Load);
1386 }
1387 
DrvExit()1388 static INT32 DrvExit()
1389 {
1390 	ZetExit();
1391 	BurnYM2203Exit();
1392 
1393 	GenericTilesExit();
1394 
1395 	DrvRomBank = 0;
1396 	DrvSoundLatch = 0;
1397 	DrvBg2ScrollX[0] = 0;
1398 	DrvBg2ScrollX[1] = 0;
1399 	DrvBgScrollX[0] = 0;
1400 	DrvBgScrollX[1] = 0;
1401 	DrvBgScrollY = 0;
1402 	DrvBg2On = 0;
1403 	DrvBg1On = 0;
1404 	DrvSpritesOn = 0;
1405 	DrvCharsOn = 0;
1406 	DrvProtValue = 0;
1407 	bootleg = 0;
1408 
1409 	BurnFree(Mem);
1410 
1411 	return 0;
1412 }
1413 
DrvCalcPalette()1414 static void DrvCalcPalette()
1415 {
1416 	INT32 i;
1417 	UINT32 Palette[256];
1418 
1419 	for (i = 0; i < 256; i++) {
1420 		INT32 bit0, bit1, bit2, bit3, r, g, b;
1421 
1422 		bit0 = (DrvPromRed[i] >> 0) & 0x01;
1423 		bit1 = (DrvPromRed[i] >> 1) & 0x01;
1424 		bit2 = (DrvPromRed[i] >> 2) & 0x01;
1425 		bit3 = (DrvPromRed[i] >> 3) & 0x01;
1426 		r = 0x0e * bit0 + 0x1f * bit1 + 0x43 * bit2 + 0x8f * bit3;
1427 
1428 		bit0 = (DrvPromGreen[i] >> 0) & 0x01;
1429 		bit1 = (DrvPromGreen[i] >> 1) & 0x01;
1430 		bit2 = (DrvPromGreen[i] >> 2) & 0x01;
1431 		bit3 = (DrvPromGreen[i] >> 3) & 0x01;
1432 		g = 0x0e * bit0 + 0x1f * bit1 + 0x43 * bit2 + 0x8f * bit3;
1433 
1434 		bit0 = (DrvPromBlue[i] >> 0) & 0x01;
1435 		bit1 = (DrvPromBlue[i] >> 1) & 0x01;
1436 		bit2 = (DrvPromBlue[i] >> 2) & 0x01;
1437 		bit3 = (DrvPromBlue[i] >> 3) & 0x01;
1438 		b = 0x0e * bit0 + 0x1f * bit1 + 0x43 * bit2 + 0x8f * bit3;
1439 
1440 		Palette[i] = BurnHighCol(r, g, b, 0);
1441 	}
1442 
1443 	for (i = 0; i < 0x80; i++) {
1444 		DrvPalette[i] = Palette[(DrvPromCharLookup[i] & 0x0f) | 0x40];
1445 	}
1446 
1447 	for (i = 0x80; i < 0x180; i++) {
1448 		DrvPalette[i] = Palette[((DrvPromBgPalBank[i - 0x80] & 0x03) << 4) | (DrvPromBgLookup[i - 0x80] & 0x0f)];
1449 	}
1450 
1451 	for (i = 0x180; i < 0x280; i++) {
1452 		DrvPalette[i] = Palette[((DrvPromBg2PalBank[i - 0x180] & 0x03) << 4) | (DrvPromBg2Lookup[i - 0x180] & 0x0f)];
1453 	}
1454 
1455 	for (i = 0x280; i < 0x380; i++) {
1456 		DrvPalette[i] = Palette[((DrvPromSpritePalBank[i - 0x280] & 0x07) << 4) | (DrvPromSpriteLookup[i - 0x280] & 0x0f) | 0x80];
1457 	}
1458 }
1459 
DrvRenderSprites(INT32 Priority)1460 static void DrvRenderSprites(INT32 Priority)
1461 {
1462 	for (INT32 Offs = 0x1000 - 32; Offs >= 0; Offs -= 32) {
1463 		INT32 Attr = DrvSpriteRam[Offs + 1];
1464 		INT32 Code = DrvSpriteRam[Offs + 0] + ((Attr & 0xe0) << 3);
1465 		INT32 Colour = Attr & 0x0f;
1466 		INT32 sx = DrvSpriteRam[Offs + 3] - ((Attr & 0x10) << 4);
1467 		INT32 sy = DrvSpriteRam[Offs + 2];
1468 
1469 		sy -= 16;
1470 
1471 		if (Priority) {
1472 			if (Colour != 0x0a && Colour != 0x0b) {
1473 				if (sx > 0 && sx < 240 && sy > 0 && sy < 208) {
1474 					Render16x16Tile_Mask(pTransDraw, Code, sx, sy, Colour + 0x28, 4, 0, 0, DrvSprites);
1475 				} else {
1476 					Render16x16Tile_Mask_Clip(pTransDraw, Code, sx, sy, Colour + 0x28, 4, 0, 0, DrvSprites);
1477 				}
1478 			}
1479 		} else {
1480 			if (Colour == 0x0a || Colour == 0x0b) {
1481 				if (sx > 0 && sx < 240 && sy > 0 && sy < 208) {
1482 					Render16x16Tile_Mask(pTransDraw, Code, sx, sy, Colour + 0x28, 4, 0, 0, DrvSprites);
1483 				} else {
1484 					Render16x16Tile_Mask_Clip(pTransDraw, Code, sx, sy, Colour + 0x28, 4, 0, 0, DrvSprites);
1485 				}
1486 			}
1487 
1488 		}
1489 	}
1490 }
1491 
DrvDraw()1492 static INT32 DrvDraw()
1493 {
1494 	if (DrvRecalc) {
1495 		DrvCalcPalette();
1496 		DrvRecalc = 0;
1497 	}
1498 
1499 	GenericTilemapSetScrollX(0, DrvBg2ScrollX[0] + (256 * DrvBg2ScrollX[1]));
1500 	GenericTilemapSetScrollX(1, DrvBgScrollX[0] + (256 * DrvBgScrollX[1]));
1501 	GenericTilemapSetScrollY(1, DrvBgScrollY);
1502 
1503 	if (DrvBg2On && nBurnLayer & 1) GenericTilemapDraw(0, pTransDraw, 0);
1504 	else BurnTransferClear();
1505 
1506 	if (DrvSpritesOn) DrvRenderSprites(0);
1507 
1508 	if (DrvBg1On && nBurnLayer & 2) GenericTilemapDraw(1, pTransDraw, 0);
1509 
1510 	if (DrvSpritesOn) DrvRenderSprites(1);
1511 
1512 	if (DrvCharsOn && nBurnLayer & 4) GenericTilemapDraw(2, pTransDraw, 0);
1513 
1514 	BurnTransferCopy(DrvPalette);
1515 
1516 	return 0;
1517 }
1518 
DrvClearOpposites(UINT8 * nJoystickInputs)1519 static inline void DrvClearOpposites(UINT8* nJoystickInputs)
1520 {
1521 	if ((*nJoystickInputs & 0x03) == 0x00) {
1522 		*nJoystickInputs |= 0x03;
1523 	}
1524 	if ((*nJoystickInputs & 0x0c) == 0x00) {
1525 		*nJoystickInputs |= 0x0c;
1526 	}
1527 }
1528 
DrvMakeInputs()1529 static inline void DrvMakeInputs()
1530 {
1531 	// Reset Inputs
1532 	DrvInput[0] = DrvInput[1] = DrvInput[2] = 0xff;
1533 
1534 	// Compile Digital Inputs
1535 	for (INT32 i = 0; i < 8; i++) {
1536 		DrvInput[0] ^= (DrvInputPort0[i] & 1) << i;
1537 		DrvInput[1] ^= (DrvInputPort1[i] & 1) << i;
1538 		DrvInput[2] ^= (DrvInputPort2[i] & 1) << i;
1539 	}
1540 
1541 	// Clear Opposites
1542 	DrvClearOpposites(&DrvInput[1]);
1543 	DrvClearOpposites(&DrvInput[2]);
1544 }
1545 
DrvFrame()1546 static INT32 DrvFrame()
1547 {
1548 	BurnWatchdogUpdate();
1549 
1550 	if (DrvReset) {
1551 		DrvDoReset(1);
1552 	}
1553 
1554 	DrvMakeInputs();
1555 
1556 	INT32 nInterleave = 256;
1557 	INT32 nCyclesTotal[2] = { 6000000 / 60, 3000000 / 60 };
1558 	INT32 nCyclesDone[2] = { 0, 0 };
1559 	INT32 nCyclesSegment;
1560 
1561 	ZetNewFrame();
1562 
1563 	for (INT32 i = 0; i < nInterleave; i++) {
1564 		INT32 nCurrentCPU, nNext;
1565 
1566 		// Run Z80 #1
1567 		nCurrentCPU = 0;
1568 		ZetOpen(nCurrentCPU);
1569 		nNext = (i + 1) * nCyclesTotal[nCurrentCPU] / nInterleave;
1570 		nCyclesSegment = nNext - nCyclesDone[nCurrentCPU];
1571 		nCyclesDone[nCurrentCPU] += ZetRun(nCyclesSegment);
1572 		if (i == 240) ZetSetIRQLine(0, CPU_IRQSTATUS_HOLD);
1573 		ZetClose();
1574 
1575 		// Run Z80 #2
1576 		nCurrentCPU = 1;
1577 		ZetOpen(nCurrentCPU);
1578 		BurnTimerUpdate((i + 1) * (nCyclesTotal[1] / nInterleave));
1579 		// execute IRQ quarterly
1580 		if (i%(nInterleave/4) == (nInterleave/4)-1) ZetSetIRQLine(0, CPU_IRQSTATUS_HOLD);
1581 		ZetClose();
1582 	}
1583 
1584 	ZetOpen(1);
1585 	BurnTimerEndFrame(nCyclesTotal[1]);
1586 	ZetClose();
1587 
1588 	// Make sure the buffer is entirely filled.
1589 	if (pBurnSoundOut) {
1590 		ZetOpen(1);
1591 		BurnYM2203Update(pBurnSoundOut, nBurnSoundLen);
1592 		ZetClose();
1593 	}
1594 
1595 	if (pBurnDraw) {
1596 		DrvDraw();
1597 	}
1598 
1599 	return 0;
1600 }
1601 
DrvScan(INT32 nAction,INT32 * pnMin)1602 static INT32 DrvScan(INT32 nAction, INT32 *pnMin)
1603 {
1604 	struct BurnArea ba;
1605 
1606 	if (pnMin != NULL) {
1607 		*pnMin = 0x029672;
1608 	}
1609 
1610 	if (nAction & ACB_MEMORY_RAM) {
1611 		memset(&ba, 0, sizeof(ba));
1612 		ba.Data	  = RamStart;
1613 		ba.nLen	  = RamEnd-RamStart;
1614 		ba.szName = "All Ram";
1615 		BurnAcb(&ba);
1616 	}
1617 
1618 	if (nAction & ACB_DRIVER_DATA) {
1619 		ZetScan(nAction);
1620 
1621 		BurnWatchdogScan(nAction);
1622 
1623 		BurnYM2203Scan(nAction, pnMin);
1624 
1625 		SCAN_VAR(DrvSoundLatch);
1626 		SCAN_VAR(DrvRomBank);
1627 		SCAN_VAR(DrvBg2ScrollX[0]);
1628 		SCAN_VAR(DrvBg2ScrollX[1]);
1629 		SCAN_VAR(DrvBgScrollX[0]);
1630 		SCAN_VAR(DrvBgScrollX[1]);
1631 		SCAN_VAR(DrvBgScrollY);
1632 		SCAN_VAR(DrvBg2On);
1633 		SCAN_VAR(DrvBg1On);
1634 		SCAN_VAR(DrvSpritesOn);
1635 		SCAN_VAR(DrvCharsOn);
1636 		SCAN_VAR(DrvProtValue);
1637 	}
1638 
1639 	if (nAction & ACB_WRITE) {
1640 		ZetOpen(0);
1641 		ZetMapMemory(DrvZ80Rom1 + 0x10000 + (DrvRomBank * 0x1000), 0x8000, 0xbfff, MAP_ROM);
1642 		ZetClose();
1643 	}
1644 
1645 	return 0;
1646 }
1647 
1648 struct BurnDriver BurnDrvNineteen43 = {
1649 	"1943", NULL, NULL, NULL, "1987",
1650 	"1943: The Battle of Midway (Euro)\0", NULL, "Capcom", "Miscellaneous",
1651 	NULL, NULL, NULL, NULL,
1652 	BDF_GAME_WORKING | BDF_ORIENTATION_VERTICAL | BDF_HISCORE_SUPPORTED, 2, HARWARE_CAPCOM_MISC, GBF_VERSHOOT, 0,
1653 	NULL, DrvRomInfo, DrvRomName, NULL, NULL, NULL, NULL, DrvInputInfo, DrvDIPInfo,
1654 	DrvInit, DrvExit, DrvFrame, DrvDraw, DrvScan,
1655 	&DrvRecalc, 0x380, 224, 256, 3, 4
1656 };
1657 
1658 struct BurnDriver BurnDrvNineteen43u = {
1659 	"1943u", "1943", NULL, NULL, "1987",
1660 	"1943: The Battle of Midway (US, Rev C)\0", NULL, "Capcom", "Miscellaneous",
1661 	NULL, NULL, NULL, NULL,
1662 	BDF_GAME_WORKING | BDF_CLONE | BDF_ORIENTATION_VERTICAL | BDF_HISCORE_SUPPORTED, 2, HARWARE_CAPCOM_MISC, GBF_VERSHOOT, 0,
1663 	NULL, DrvuRomInfo, DrvuRomName, NULL, NULL, NULL, NULL, DrvInputInfo, DrvDIPInfo,
1664 	DrvInit, DrvExit, DrvFrame, DrvDraw, DrvScan,
1665 	&DrvRecalc, 0x380, 224, 256, 3, 4
1666 };
1667 
1668 struct BurnDriver BurnDrvNineteen43ua = {
1669 	"1943ua", "1943", NULL, NULL, "1987",
1670 	"1943: The Battle of Midway (US)\0", NULL, "Capcom", "Miscellaneous",
1671 	NULL, NULL, NULL, NULL,
1672 	BDF_GAME_WORKING | BDF_CLONE | BDF_ORIENTATION_VERTICAL | BDF_HISCORE_SUPPORTED, 2, HARWARE_CAPCOM_MISC, GBF_VERSHOOT, 0,
1673 	NULL, DrvuaRomInfo, DrvuaRomName, NULL, NULL, NULL, NULL, DrvInputInfo, DrvDIPInfo,
1674 	DrvInit, DrvExit, DrvFrame, DrvDraw, DrvScan,
1675 	&DrvRecalc, 0x380, 224, 256, 3, 4
1676 };
1677 
1678 struct BurnDriver BurnDrvNineteen43j = {
1679 	"1943j", "1943", NULL, NULL, "1987",
1680 	"1943: Midway Kaisen (Japan, Rev B)\0", NULL, "Capcom", "Miscellaneous",
1681 	L"1943: \u30DF\u30C3\u30C9\u30A6\u30A7\u30A4\u6D77\u6226 (Japan, Rev B)\0", NULL, NULL, NULL,
1682 	BDF_GAME_WORKING | BDF_CLONE | BDF_ORIENTATION_VERTICAL | BDF_HISCORE_SUPPORTED, 2, HARWARE_CAPCOM_MISC, GBF_VERSHOOT, 0,
1683 	NULL, DrvjRomInfo, DrvjRomName, NULL, NULL, NULL, NULL, DrvInputInfo, DrvDIPInfo,
1684 	DrvInit, DrvExit, DrvFrame, DrvDraw, DrvScan,
1685 	&DrvRecalc, 0x380, 224, 256, 3, 4
1686 };
1687 
1688 struct BurnDriver BurnDrvNineteen43ja = {
1689 	"1943ja", "1943", NULL, NULL, "1987",
1690 	"1943: Midway Kaisen (Japan)\0", NULL, "Capcom", "Miscellaneous",
1691 	L"1943: \u30DF\u30C3\u30C9\u30A6\u30A7\u30A4\u6D77\u6226 (Japan)\0", NULL, NULL, NULL,
1692 	BDF_GAME_WORKING | BDF_CLONE | BDF_ORIENTATION_VERTICAL | BDF_HISCORE_SUPPORTED, 2, HARWARE_CAPCOM_MISC, GBF_VERSHOOT, 0,
1693 	NULL, DrvjaRomInfo, DrvjaRomName, NULL, NULL, NULL, NULL, DrvInputInfo, DrvDIPInfo,
1694 	DrvInit, DrvExit, DrvFrame, DrvDraw, DrvScan,
1695 	&DrvRecalc, 0x380, 224, 256, 3, 4
1696 };
1697 
1698 struct BurnDriver BurnDrvNineteen43jah = {
1699 	"1943jah", "1943", NULL, NULL, "1987",
1700 	"1943: Midway Kaisen (Japan, no protection hack)\0", NULL, "Capcom", "Miscellaneous",
1701 	NULL, NULL, NULL, NULL,
1702 	BDF_GAME_WORKING | BDF_CLONE | BDF_ORIENTATION_VERTICAL | BDF_HISCORE_SUPPORTED, 2, HARWARE_CAPCOM_MISC, GBF_VERSHOOT, 0,
1703 	NULL, DrvjahRomInfo, DrvjahRomName, NULL, NULL, NULL, NULL, DrvInputInfo, DrvDIPInfo,
1704 	DrvInit, DrvExit, DrvFrame, DrvDraw, DrvScan,
1705 	&DrvRecalc, 0x380, 224, 256, 3, 4
1706 };
1707 
1708 struct BurnDriver BurnDrvNineteen43b = {
1709 	"1943b", "1943", NULL, NULL, "1987",
1710 	"1943: The Battle of Midway (bootleg set 1, hack of Japan set)\0", NULL, "bootleg", "Miscellaneous",
1711 	NULL, NULL, NULL, NULL,
1712 	BDF_GAME_WORKING | BDF_CLONE | BDF_ORIENTATION_VERTICAL | BDF_BOOTLEG | BDF_HISCORE_SUPPORTED, 2, HARWARE_CAPCOM_MISC, GBF_VERSHOOT, 0,
1713 	NULL, DrvbRomInfo, DrvbRomName, NULL, NULL, NULL, NULL, DrvInputInfo, DrvDIPInfo,
1714 	DrvbInit, DrvExit, DrvFrame, DrvDraw, DrvScan,
1715 	&DrvRecalc, 0x380, 224, 256, 3, 4
1716 };
1717 
1718 struct BurnDriver BurnDrvNineteen43b2 = {
1719 	"1943b2", "1943", NULL, NULL, "1987",
1720 	"1943: The Battle of Midway (bootleg set 2, hack of Japan set)\0", NULL, "bootleg", "Miscellaneous",
1721 	NULL, NULL, NULL, NULL,
1722 	BDF_GAME_WORKING | BDF_CLONE | BDF_ORIENTATION_VERTICAL | BDF_BOOTLEG | BDF_HISCORE_SUPPORTED, 2, HARWARE_CAPCOM_MISC, GBF_VERSHOOT, 0,
1723 	NULL, Drvb2RomInfo, Drvb2RomName, NULL, NULL, NULL, NULL, DrvInputInfo, DrvDIPInfo,
1724 	Drvb2Init, DrvExit, DrvFrame, DrvDraw, DrvScan,
1725 	&DrvRecalc, 0x380, 224, 256, 3, 4
1726 };
1727 
1728 struct BurnDriver BurnDrvNineteen43bj = {
1729 	"1943bj", "1943", NULL, NULL, "1987",
1730 	"1943: Midway Kaisen (bootleg)\0", NULL, "bootleg", "Miscellaneous",
1731 	L"1943: \u30DF\u30C3\u30C9\u30A6\u30A7\u30A4\u6D77\u6226 (bootleg)\0", NULL, NULL, NULL,
1732 	BDF_GAME_WORKING | BDF_CLONE | BDF_ORIENTATION_VERTICAL | BDF_BOOTLEG | BDF_HISCORE_SUPPORTED, 2, HARWARE_CAPCOM_MISC, GBF_VERSHOOT, 0,
1733 	NULL, DrvbjRomInfo, DrvbjRomName, NULL, NULL, NULL, NULL, DrvInputInfo, DrvDIPInfo,
1734 	DrvbjInit, DrvExit, DrvFrame, DrvDraw, DrvScan,
1735 	&DrvRecalc, 0x380, 224, 256, 3, 4
1736 };
1737 
1738 struct BurnDriver BurnDrvNineteen43kai = {
1739 	"1943kai", NULL, NULL, NULL, "1987",
1740 	"1943 Kai: Midway Kaisen (Japan)\0", NULL, "Capcom", "Miscellaneous",
1741 	L"1943 \u6539: \u30DF\u30C3\u30C9\u30A6\u30A7\u30A4\u6D77\u6226 (Japan)\0", NULL, NULL, NULL,
1742 	BDF_GAME_WORKING | BDF_ORIENTATION_VERTICAL | BDF_HISCORE_SUPPORTED, 2, HARWARE_CAPCOM_MISC, GBF_VERSHOOT, 0,
1743 	NULL, DrvkaiRomInfo, DrvkaiRomName, NULL, NULL, NULL, NULL, DrvInputInfo, DrvDIPInfo,
1744 	DrvInit, DrvExit, DrvFrame, DrvDraw, DrvScan,
1745 	&DrvRecalc, 0x380, 224, 256, 3, 4
1746 };
1747 
1748 struct BurnDriver BurnDrvNineteen43mii = {
1749 	"1943mii", NULL, NULL, NULL, "1988",
1750 	"1943: The Battle of Midway Mark II (US)\0", NULL, "Capcom", "Miscellaneous",
1751 	NULL, NULL, NULL, NULL,
1752 	BDF_GAME_WORKING | BDF_ORIENTATION_VERTICAL | BDF_HISCORE_SUPPORTED, 2, HARWARE_CAPCOM_MISC, GBF_VERSHOOT, 0,
1753 	NULL, DrvmiiRomInfo, DrvmiiRomName, NULL, NULL, NULL, NULL, DrvInputInfo, DrvDIPInfo,
1754 	DrvInit, DrvExit, DrvFrame, DrvDraw, DrvScan,
1755 	&DrvRecalc, 0x380, 224, 256, 3, 4
1756 };
1757