1 // FB Alpha Mitchell driver module
2 // Based on MAME driver by Nicola Salmoria
3 
4 #include "tiles_generic.h"
5 #include "z80_intf.h"
6 #include "eeprom.h"
7 #include "burn_ym2413.h"
8 #include "msm6295.h"
9 
10 static UINT8 DrvInputPort0[8]  = {0, 0, 0, 0, 0, 0, 0, 0};
11 static UINT8 DrvInputPort1[8]  = {0, 0, 0, 0, 0, 0, 0, 0};
12 static UINT8 DrvInputPort2[8]  = {0, 0, 0, 0, 0, 0, 0, 0};
13 static UINT8 DrvInputPort3[8]  = {0, 0, 0, 0, 0, 0, 0, 0};
14 static UINT8 DrvInputPort4[8]  = {0, 0, 0, 0, 0, 0, 0, 0};
15 static UINT8 DrvInputPort5[8]  = {0, 0, 0, 0, 0, 0, 0, 0};
16 static UINT8 DrvInputPort6[8]  = {0, 0, 0, 0, 0, 0, 0, 0};
17 static UINT8 DrvInputPort7[8]  = {0, 0, 0, 0, 0, 0, 0, 0};
18 static UINT8 DrvInputPort8[8]  = {0, 0, 0, 0, 0, 0, 0, 0};
19 static UINT8 DrvInputPort9[8]  = {0, 0, 0, 0, 0, 0, 0, 0};
20 static UINT8 DrvInputPort10[8] = {0, 0, 0, 0, 0, 0, 0, 0};
21 static UINT8 DrvInputPort11[8] = {0, 0, 0, 0, 0, 0, 0, 0};
22 static UINT8 DrvInput[12]      = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
23 static UINT8 DrvDip[2]         = {0, 0};
24 static UINT8 DrvReset          = 0;
25 static INT16 DrvDial1          = 0;
26 static INT16 DrvDial2          = 0;
27 
28 static UINT8 *Mem                 = NULL;
29 static UINT8 *MemEnd              = NULL;
30 static UINT8 *RamStart            = NULL;
31 static UINT8 *RamEnd              = NULL;
32 static UINT8 *DrvZ80Rom           = NULL;
33 static UINT8 *DrvZ80Code          = NULL;
34 static UINT8 *DrvZ80Rom2          = NULL;
35 static UINT8 *DrvSoundRom         = NULL;
36 static UINT8 *DrvZ80Ram           = NULL;
37 static UINT8 *DrvZ80Ram2          = NULL;
38 static UINT8 *DrvPaletteRam       = NULL;
39 static UINT8 *DrvAttrRam          = NULL;
40 static UINT8 *DrvVideoRam         = NULL;
41 static UINT8 *DrvSpriteRam        = NULL;
42 static UINT8 *DrvChars            = NULL;
43 static UINT8 *DrvSprites          = NULL;
44 static UINT8 *DrvTempRom          = NULL;
45 static UINT32 *DrvPalette          = NULL;
46 static INT32 nCyclesDone[2], nCyclesTotal[2];
47 static INT32 nCyclesSegment;
48 
49 static UINT8 DrvRomBank;
50 static UINT8 DrvPaletteRamBank;
51 static UINT8 DrvOkiBank;
52 static UINT8 DrvFlipScreen;
53 static UINT8 DrvVideoBank;
54 static UINT8 DrvInput5Toggle;
55 static UINT8 DrvPort5Kludge;
56 static INT32 DrvTileMask;
57 static UINT8 DrvHasEEPROM;
58 static INT32 DrvNumColours;
59 static INT32 DrvNVRamSize;
60 static INT32 DrvNVRamAddress;
61 static UINT8 DrvDialSelected;
62 static INT32 DrvDial[2];
63 static UINT8 DrvSoundLatch;
64 
65 static UINT8 DrvInputType;
66 static INT32 DrvMahjongKeyMatrix;
67 
68 #define DRV_INPUT_TYPE_MAHJONG		1
69 #define DRV_INPUT_TYPE_BLOCK		2
70 
71 static struct BurnInputInfo MgakuenInputList[] =
72 {
73 	{"Coin 1"            , BIT_DIGITAL  , DrvInputPort0  + 7, "p1 coin"   },
74 	{"Start 1"           , BIT_DIGITAL  , DrvInputPort1  + 2, "p1 start"  },
75 	{"Start 2"           , BIT_DIGITAL  , DrvInputPort7  + 2, "p2 start"  },
76 
77 	{"P1 A"              , BIT_DIGITAL  , DrvInputPort1  + 7, "mah a"     },
78 	{"P1 B"              , BIT_DIGITAL  , DrvInputPort2  + 7, "mah b"     },
79 	{"P1 C"              , BIT_DIGITAL  , DrvInputPort4  + 7, "mah c"     },
80 	{"P1 D"              , BIT_DIGITAL  , DrvInputPort5  + 7, "mah d"     },
81 	{"P1 E"              , BIT_DIGITAL  , DrvInputPort1  + 6, "mah e"     },
82 	{"P1 F"              , BIT_DIGITAL  , DrvInputPort2  + 6, "mah f"     },
83 	{"P1 G"              , BIT_DIGITAL  , DrvInputPort4  + 6, "mah g"     },
84 	{"P1 H"              , BIT_DIGITAL  , DrvInputPort5  + 6, "mah h"     },
85 	{"P1 I"              , BIT_DIGITAL  , DrvInputPort1  + 5, "mah i"     },
86 	{"P1 J"              , BIT_DIGITAL  , DrvInputPort2  + 5, "mah j"     },
87 	{"P1 K"              , BIT_DIGITAL  , DrvInputPort4  + 5, "mah k"     },
88 	{"P1 L"              , BIT_DIGITAL  , DrvInputPort5  + 5, "mah l"     },
89 	{"P1 M"              , BIT_DIGITAL  , DrvInputPort1  + 4, "mah m"     },
90 	{"P1 N"              , BIT_DIGITAL  , DrvInputPort2  + 4, "mah n"     },
91 	{"P1 Pon"            , BIT_DIGITAL  , DrvInputPort5  + 4, "mah pon"   },
92 	{"P1 Chi"            , BIT_DIGITAL  , DrvInputPort4  + 4, "mah chi"   },
93 	{"P1 Kan"            , BIT_DIGITAL  , DrvInputPort1  + 3, "mah kan"   },
94 	{"P1 Ron"            , BIT_DIGITAL  , DrvInputPort4  + 3, "mah ron"   },
95 	{"P1 Reach"          , BIT_DIGITAL  , DrvInputPort2  + 3, "mah reach" },
96 	{"P1 Flip Flop"      , BIT_DIGITAL  , DrvInputPort6  + 4, "mah ff"    },
97 
98 	{"P2 A"              , BIT_DIGITAL  , DrvInputPort7  + 7, "mah a"     },
99 	{"P2 B"              , BIT_DIGITAL  , DrvInputPort8  + 7, "mah b"     },
100 	{"P2 C"              , BIT_DIGITAL  , DrvInputPort9  + 7, "mah c"     },
101 	{"P2 D"              , BIT_DIGITAL  , DrvInputPort10 + 7, "mah d"     },
102 	{"P2 E"              , BIT_DIGITAL  , DrvInputPort7  + 6, "mah e"     },
103 	{"P2 F"              , BIT_DIGITAL  , DrvInputPort8  + 6, "mah f"     },
104 	{"P2 G"              , BIT_DIGITAL  , DrvInputPort9  + 6, "mah g"     },
105 	{"P2 H"              , BIT_DIGITAL  , DrvInputPort10 + 6, "mah h"     },
106 	{"P2 I"              , BIT_DIGITAL  , DrvInputPort7  + 5, "mah i"     },
107 	{"P2 J"              , BIT_DIGITAL  , DrvInputPort8  + 5, "mah j"     },
108 	{"P2 K"              , BIT_DIGITAL  , DrvInputPort9  + 5, "mah k"     },
109 	{"P2 L"              , BIT_DIGITAL  , DrvInputPort10 + 5, "mah l"     },
110 	{"P2 M"              , BIT_DIGITAL  , DrvInputPort7  + 4, "mah m"     },
111 	{"P2 N"              , BIT_DIGITAL  , DrvInputPort2  + 4, "mah n"     },
112 	{"P2 Pon"            , BIT_DIGITAL  , DrvInputPort10 + 4, "mah pon"   },
113 	{"P2 Chi"            , BIT_DIGITAL  , DrvInputPort9  + 4, "mah chi"   },
114 	{"P2 Kan"            , BIT_DIGITAL  , DrvInputPort7  + 3, "mah kan"   },
115 	{"P2 Ron"            , BIT_DIGITAL  , DrvInputPort9  + 3, "mah ron"   },
116 	{"P2 Reach"          , BIT_DIGITAL  , DrvInputPort8  + 3, "mah reach" },
117 	{"P2 Flip Flop"      , BIT_DIGITAL  , DrvInputPort11 + 4, "mah ff"    },
118 
119 	{"Reset"             , BIT_DIGITAL  , &DrvReset         , "reset"     },
120 	{"Dip 1"             , BIT_DIPSWITCH, DrvDip + 0        , "dip"       },
121 	{"Dip 2"             , BIT_DIPSWITCH, DrvDip + 1        , "dip"       },
122 };
123 
124 STDINPUTINFO(Mgakuen)
125 
126 static struct BurnInputInfo MarukinInputList[] =
127 {
128 	{"Coin 1"            , BIT_DIGITAL  , DrvInputPort0  + 7, "p1 coin"   },
129 	{"Start 1"           , BIT_DIGITAL  , DrvInputPort1  + 2, "p1 start"  },
130 	{"Start 2"           , BIT_DIGITAL  , DrvInputPort7  + 2, "p2 start"  },
131 
132 	{"P1 A"              , BIT_DIGITAL  , DrvInputPort1  + 7, "mah a"     },
133 	{"P1 B"              , BIT_DIGITAL  , DrvInputPort2  + 7, "mah b"     },
134 	{"P1 C"              , BIT_DIGITAL  , DrvInputPort4  + 7, "mah c"     },
135 	{"P1 D"              , BIT_DIGITAL  , DrvInputPort5  + 7, "mah d"     },
136 	{"P1 E"              , BIT_DIGITAL  , DrvInputPort1  + 6, "mah e"     },
137 	{"P1 F"              , BIT_DIGITAL  , DrvInputPort2  + 6, "mah f"     },
138 	{"P1 G"              , BIT_DIGITAL  , DrvInputPort4  + 6, "mah g"     },
139 	{"P1 H"              , BIT_DIGITAL  , DrvInputPort5  + 6, "mah h"     },
140 	{"P1 I"              , BIT_DIGITAL  , DrvInputPort1  + 5, "mah i"     },
141 	{"P1 J"              , BIT_DIGITAL  , DrvInputPort2  + 5, "mah j"     },
142 	{"P1 K"              , BIT_DIGITAL  , DrvInputPort4  + 5, "mah k"     },
143 	{"P1 L"              , BIT_DIGITAL  , DrvInputPort5  + 5, "mah l"     },
144 	{"P1 M"              , BIT_DIGITAL  , DrvInputPort1  + 4, "mah m"     },
145 	{"P1 N"              , BIT_DIGITAL  , DrvInputPort2  + 4, "mah n"     },
146 	{"P1 Pon"            , BIT_DIGITAL  , DrvInputPort5  + 4, "mah pon"   },
147 	{"P1 Chi"            , BIT_DIGITAL  , DrvInputPort4  + 4, "mah chi"   },
148 	{"P1 Kan"            , BIT_DIGITAL  , DrvInputPort1  + 3, "mah kan"   },
149 	{"P1 Ron"            , BIT_DIGITAL  , DrvInputPort4  + 3, "mah ron"   },
150 	{"P1 Reach"          , BIT_DIGITAL  , DrvInputPort2  + 3, "mah reach" },
151 	{"P1 Flip Flop"      , BIT_DIGITAL  , DrvInputPort6  + 4, "mah ff"    },
152 
153 	{"P2 A"              , BIT_DIGITAL  , DrvInputPort7  + 7, "mah a"     },
154 	{"P2 B"              , BIT_DIGITAL  , DrvInputPort8  + 7, "mah b"     },
155 	{"P2 C"              , BIT_DIGITAL  , DrvInputPort9  + 7, "mah c"     },
156 	{"P2 D"              , BIT_DIGITAL  , DrvInputPort10 + 7, "mah d"     },
157 	{"P2 E"              , BIT_DIGITAL  , DrvInputPort7  + 6, "mah e"     },
158 	{"P2 F"              , BIT_DIGITAL  , DrvInputPort8  + 6, "mah f"     },
159 	{"P2 G"              , BIT_DIGITAL  , DrvInputPort9  + 6, "mah g"     },
160 	{"P2 H"              , BIT_DIGITAL  , DrvInputPort10 + 6, "mah h"     },
161 	{"P2 I"              , BIT_DIGITAL  , DrvInputPort7  + 5, "mah i"     },
162 	{"P2 J"              , BIT_DIGITAL  , DrvInputPort8  + 5, "mah j"     },
163 	{"P2 K"              , BIT_DIGITAL  , DrvInputPort9  + 5, "mah k"     },
164 	{"P2 L"              , BIT_DIGITAL  , DrvInputPort10 + 5, "mah l"     },
165 	{"P2 M"              , BIT_DIGITAL  , DrvInputPort7  + 4, "mah m"     },
166 	{"P2 N"              , BIT_DIGITAL  , DrvInputPort2  + 4, "mah n"     },
167 	{"P2 Pon"            , BIT_DIGITAL  , DrvInputPort10 + 4, "mah pon"   },
168 	{"P2 Chi"            , BIT_DIGITAL  , DrvInputPort9  + 4, "mah chi"   },
169 	{"P2 Kan"            , BIT_DIGITAL  , DrvInputPort7  + 3, "mah kan"   },
170 	{"P2 Ron"            , BIT_DIGITAL  , DrvInputPort9  + 3, "mah ron"   },
171 	{"P2 Reach"          , BIT_DIGITAL  , DrvInputPort8  + 3, "mah reach" },
172 	{"P2 Flip Flop"      , BIT_DIGITAL  , DrvInputPort11 + 4, "mah ff"    },
173 
174 	{"Reset"             , BIT_DIGITAL  , &DrvReset         , "reset"     },
175 	{"Diagnostics"       , BIT_DIGITAL  , DrvInputPort3  + 1, "diag"      },
176 };
177 
178 STDINPUTINFO(Marukin)
179 
180 static struct BurnInputInfo PkladiesInputList[] =
181 {
182 	{"Coin 1"            , BIT_DIGITAL  , DrvInputPort0  + 7, "p1 coin"   },
183 	{"Start 1"           , BIT_DIGITAL  , DrvInputPort1  + 2, "p1 start"  },
184 	{"Start 2"           , BIT_DIGITAL  , DrvInputPort7  + 2, "p2 start"  },
185 
186 	{"P1 A"              , BIT_DIGITAL  , DrvInputPort1  + 7, "mah a"     },
187 	{"P1 B"              , BIT_DIGITAL  , DrvInputPort2  + 7, "mah b"     },
188 	{"P1 C"              , BIT_DIGITAL  , DrvInputPort4  + 7, "mah c"     },
189 	{"P1 D"              , BIT_DIGITAL  , DrvInputPort5  + 7, "mah d"     },
190 	{"P1 E"              , BIT_DIGITAL  , DrvInputPort1  + 6, "mah e"     },
191 	{"P1 Deal"           , BIT_DIGITAL  , DrvInputPort1  + 5, "p1 fire 1" },
192 	{"P1 Cancel"         , BIT_DIGITAL  , DrvInputPort2  + 5, "p1 fire 2" },
193 	{"P1 Flip"           , BIT_DIGITAL  , DrvInputPort4  + 5, "p1 fire 3" },
194 
195 	{"P2 A"              , BIT_DIGITAL  , DrvInputPort7  + 7, "mah a"     },
196 	{"P2 B"              , BIT_DIGITAL  , DrvInputPort8  + 7, "mah b"     },
197 	{"P2 C"              , BIT_DIGITAL  , DrvInputPort9  + 7, "mah c"     },
198 	{"P2 D"              , BIT_DIGITAL  , DrvInputPort10 + 7, "mah d"     },
199 	{"P2 E"              , BIT_DIGITAL  , DrvInputPort7  + 6, "mah e"     },
200 	{"P2 Deal"           , BIT_DIGITAL  , DrvInputPort7  + 5, "p2 fire 1" },
201 	{"P2 Cancel"         , BIT_DIGITAL  , DrvInputPort8  + 5, "p2 fire 2" },
202 	{"P2 Flip"           , BIT_DIGITAL  , DrvInputPort9  + 5, "p2 fire 3" },
203 
204 	{"Reset"             , BIT_DIGITAL  , &DrvReset         , "reset"     },
205 	{"Service"           , BIT_DIGITAL  , DrvInputPort0  + 0, "service"   },
206 	{"Diagnostics"       , BIT_DIGITAL  , DrvInputPort3  + 1, "diag"      },
207 };
208 
209 STDINPUTINFO(Pkladies)
210 
211 static struct BurnInputInfo PangInputList[] =
212 {
213 	{"Coin 1"            , BIT_DIGITAL  , DrvInputPort0  + 7, "p1 coin"   },
214 	{"Start 1"           , BIT_DIGITAL  , DrvInputPort0  + 3, "p1 start"  },
215 	{"Start 2"           , BIT_DIGITAL  , DrvInputPort0  + 1, "p2 start"  },
216 
217 	{"P1 Up"             , BIT_DIGITAL  , DrvInputPort1  + 7, "p1 up"     },
218 	{"P1 Down"           , BIT_DIGITAL  , DrvInputPort1  + 6, "p1 down"   },
219 	{"P1 Left"           , BIT_DIGITAL  , DrvInputPort1  + 5, "p1 left"   },
220 	{"P1 Right"          , BIT_DIGITAL  , DrvInputPort1  + 4, "p1 right"  },
221 	{"P1 Fire 1"         , BIT_DIGITAL  , DrvInputPort1  + 3, "p1 fire 1" },
222 	{"P1 Fire 2"         , BIT_DIGITAL  , DrvInputPort1  + 2, "p1 fire 2" },
223 
224 	{"P2 Up"             , BIT_DIGITAL  , DrvInputPort2  + 7, "p2 up"     },
225 	{"P2 Down"           , BIT_DIGITAL  , DrvInputPort2  + 6, "p2 down"   },
226 	{"P2 Left"           , BIT_DIGITAL  , DrvInputPort2  + 5, "p2 left"   },
227 	{"P2 Right"          , BIT_DIGITAL  , DrvInputPort2  + 4, "p2 right"  },
228 	{"P2 Fire 1"         , BIT_DIGITAL  , DrvInputPort2  + 3, "p2 fire 1" },
229 	{"P2 Fire 2"         , BIT_DIGITAL  , DrvInputPort2  + 2, "p2 fire 2" },
230 
231 	{"Reset"             , BIT_DIGITAL  , &DrvReset         , "reset"     },
232 	{"Service"           , BIT_DIGITAL  , DrvInputPort0  + 6, "service"   },
233 	{"Diagnostics"       , BIT_DIGITAL  , DrvInputPort3  + 1, "diag"      },
234 };
235 
236 STDINPUTINFO(Pang)
237 
238 static struct BurnInputInfo Qtono1InputList[] =
239 {
240 	{"Coin 1"            , BIT_DIGITAL  , DrvInputPort0  + 7, "p1 coin"   },
241 	{"Start 1"           , BIT_DIGITAL  , DrvInputPort1  + 2, "p1 start"  },
242 	{"Start 2"           , BIT_DIGITAL  , DrvInputPort2  + 2, "p2 start"  },
243 
244 	{"P1 Fire 1"         , BIT_DIGITAL  , DrvInputPort1  + 7, "p1 fire 1" },
245 	{"P1 Fire 2"         , BIT_DIGITAL  , DrvInputPort1  + 6, "p1 fire 2" },
246 	{"P1 Fire 3"         , BIT_DIGITAL  , DrvInputPort1  + 5, "p1 fire 3" },
247 	{"P1 Fire 4"         , BIT_DIGITAL  , DrvInputPort1  + 4, "p1 fire 4" },
248 
249 	{"P2 Fire 1"         , BIT_DIGITAL  , DrvInputPort2  + 7, "p2 fire 1" },
250 	{"P2 Fire 2"         , BIT_DIGITAL  , DrvInputPort2  + 6, "p2 fire 2" },
251 	{"P2 Fire 3"         , BIT_DIGITAL  , DrvInputPort2  + 5, "p2 fire 3" },
252 	{"P2 Fire 4"         , BIT_DIGITAL  , DrvInputPort2  + 4, "p2 fire 4" },
253 
254 	{"Reset"             , BIT_DIGITAL  , &DrvReset         , "reset"     },
255 	{"Service"           , BIT_DIGITAL  , DrvInputPort0  + 6, "service"   },
256 	{"Diagnostics"       , BIT_DIGITAL  , DrvInputPort3  + 1, "diag"      },
257 };
258 
259 STDINPUTINFO(Qtono1)
260 
261 static struct BurnInputInfo MstworldInputList[] =
262 {
263 	{"Coin 1"            , BIT_DIGITAL  , DrvInputPort0  + 7, "p1 coin"   },
264 	{"Start 1"           , BIT_DIGITAL  , DrvInputPort0  + 3, "p1 start"  },
265 	{"Coin 2"            , BIT_DIGITAL  , DrvInputPort0  + 5, "p2 coin"   },
266 	{"Start 2"           , BIT_DIGITAL  , DrvInputPort0  + 1, "p2 start"  },
267 
268 	{"P1 Up"             , BIT_DIGITAL  , DrvInputPort1  + 7, "p1 up"     },
269 	{"P1 Down"           , BIT_DIGITAL  , DrvInputPort1  + 6, "p1 down"   },
270 	{"P1 Left"           , BIT_DIGITAL  , DrvInputPort1  + 5, "p1 left"   },
271 	{"P1 Right"          , BIT_DIGITAL  , DrvInputPort1  + 4, "p1 right"  },
272 	{"P1 Fire 1"         , BIT_DIGITAL  , DrvInputPort1  + 3, "p1 fire 1" },
273 	{"P1 Fire 2"         , BIT_DIGITAL  , DrvInputPort1  + 2, "p1 fire 2" },
274 	{"P1 Fire 3"         , BIT_DIGITAL  , DrvInputPort1  + 1, "p1 fire 3" },
275 
276 	{"P2 Up"             , BIT_DIGITAL  , DrvInputPort2  + 7, "p2 up"     },
277 	{"P2 Down"           , BIT_DIGITAL  , DrvInputPort2  + 6, "p2 down"   },
278 	{"P2 Left"           , BIT_DIGITAL  , DrvInputPort2  + 5, "p2 left"   },
279 	{"P2 Right"          , BIT_DIGITAL  , DrvInputPort2  + 4, "p2 right"  },
280 	{"P2 Fire 1"         , BIT_DIGITAL  , DrvInputPort2  + 3, "p2 fire 1" },
281 	{"P2 Fire 2"         , BIT_DIGITAL  , DrvInputPort2  + 2, "p2 fire 2" },
282 	{"P2 Fire 3"         , BIT_DIGITAL  , DrvInputPort2  + 1, "p2 fire 3" },
283 
284 	{"Reset"             , BIT_DIGITAL  , &DrvReset         , "reset"     },
285 	{"Service"           , BIT_DIGITAL  , DrvInputPort0  + 6, "service"   },
286 	{"Diagnostics"       , BIT_DIGITAL  , DrvInputPort3  + 1, "diag"      },
287 	{"Dip 1"             , BIT_DIPSWITCH, DrvDip + 0        , "dip"       },
288 };
289 
290 STDINPUTINFO(Mstworld)
291 
292 static struct BurnInputInfo BlockInputList[] =
293 {
294 	{"Coin 1"            , BIT_DIGITAL  , DrvInputPort0  + 7, "p1 coin"   },
295 	{"Start 1"           , BIT_DIGITAL  , DrvInputPort0  + 3, "p1 start"  },
296 	{"Start 2"           , BIT_DIGITAL  , DrvInputPort0  + 1, "p2 start"  },
297 
298 	{"P1 Left"           , BIT_DIGITAL  , DrvInputPort11 + 0, "p1 left"   },
299 	{"P1 Right"          , BIT_DIGITAL  , DrvInputPort11 + 1, "p1 right"  },
300 	{"P1 Fire 1"         , BIT_DIGITAL  , DrvInputPort1  + 7, "p1 fire 1" },
301 
302 	{"P2 Left"           , BIT_DIGITAL  , DrvInputPort11 + 2, "p2 left"   },
303 	{"P2 Right"          , BIT_DIGITAL  , DrvInputPort11 + 3, "p2 right"  },
304 	{"P2 Fire 1"         , BIT_DIGITAL  , DrvInputPort2  + 7, "p2 fire 1" },
305 
306 	{"Reset"             , BIT_DIGITAL  , &DrvReset         , "reset"     },
307 	{"Service"           , BIT_DIGITAL  , DrvInputPort0  + 6, "service"   },
308 	{"Diagnostics"       , BIT_DIGITAL  , DrvInputPort3  + 1, "diag"      },
309 };
310 
311 STDINPUTINFO(Block)
312 
313 static struct BurnInputInfo BlockjoyInputList[] =
314 {
315 	{"Coin 1"            , BIT_DIGITAL  , DrvInputPort0  + 7, "p1 coin"   },
316 	{"Start 1"           , BIT_DIGITAL  , DrvInputPort0  + 3, "p1 start"  },
317 	{"Start 2"           , BIT_DIGITAL  , DrvInputPort0  + 1, "p2 start"  },
318 
319 	{"P1 Left"           , BIT_DIGITAL  , DrvInputPort1  + 5, "p1 left"   },
320 	{"P1 Right"          , BIT_DIGITAL  , DrvInputPort1  + 4, "p1 right"  },
321 	{"P1 Fire 1"         , BIT_DIGITAL  , DrvInputPort1  + 7, "p1 fire 1" },
322 
323 	{"P2 Left"           , BIT_DIGITAL  , DrvInputPort2  + 5, "p2 left"   },
324 	{"P2 Right"          , BIT_DIGITAL  , DrvInputPort2  + 4, "p2 right"  },
325 	{"P2 Fire 1"         , BIT_DIGITAL  , DrvInputPort2  + 7, "p2 fire 1" },
326 
327 	{"Reset"             , BIT_DIGITAL  , &DrvReset         , "reset"     },
328 	{"Service"           , BIT_DIGITAL  , DrvInputPort0  + 6, "service"   },
329 	{"Diagnostics"       , BIT_DIGITAL  , DrvInputPort3  + 1, "diag"      },
330 };
331 
STDINPUTINFO(Blockjoy)332 STDINPUTINFO(Blockjoy)
333 
334 static inline void DrvClearOpposites(UINT8* nJoystickInputs)
335 {
336 	if ((*nJoystickInputs & 0x30) == 0x30) {
337 		*nJoystickInputs &= ~0x30;
338 	}
339 	if ((*nJoystickInputs & 0xc0) == 0xc0) {
340 		*nJoystickInputs &= ~0xc0;
341 	}
342 }
343 
DrvMakeInputs()344 static inline void DrvMakeInputs()
345 {
346 	for (INT32 i = 0; i < 12; i++) DrvInput[i] = 0x00;
347 
348 	for (INT32 i = 0; i < 8; i++) {
349 		DrvInput[ 0] |= (DrvInputPort0[ i] & 1) << i;
350 		DrvInput[ 1] |= (DrvInputPort1[ i] & 1) << i;
351 		DrvInput[ 2] |= (DrvInputPort2[ i] & 1) << i;
352 		DrvInput[ 3] |= (DrvInputPort3[ i] & 1) << i;
353 		DrvInput[ 4] |= (DrvInputPort4[ i] & 1) << i;
354 		DrvInput[ 5] |= (DrvInputPort5[ i] & 1) << i;
355 		DrvInput[ 6] |= (DrvInputPort6[ i] & 1) << i;
356 		DrvInput[ 7] |= (DrvInputPort7[ i] & 1) << i;
357 		DrvInput[ 8] |= (DrvInputPort8[ i] & 1) << i;
358 		DrvInput[ 9] |= (DrvInputPort9[ i] & 1) << i;
359 		DrvInput[10] |= (DrvInputPort10[i] & 1) << i;
360 		DrvInput[11] |= (DrvInputPort11[i] & 1) << i;
361 	}
362 
363 	if (DrvInputType == DRV_INPUT_TYPE_BLOCK) {
364 		if (DrvInputPort11[0]) DrvDial1 -= 0x04;
365 		if (DrvInputPort11[1]) DrvDial1 += 0x04;
366 		if (DrvDial1 >= 0x100) DrvDial1 = 0;
367 		if (DrvDial1 < 0) DrvDial1 = 0xfc;
368 
369 		if (DrvInputPort11[2]) DrvDial2 -= 0x04;
370 		if (DrvInputPort11[3]) DrvDial2 += 0x04;
371 		if (DrvDial2 >= 0x100) DrvDial2 = 0;
372 		if (DrvDial2 < 0) DrvDial2 = 0xfc;
373 	} else {
374 		if (DrvInputType != DRV_INPUT_TYPE_MAHJONG) {
375 			DrvClearOpposites(&DrvInput[1]);
376 			DrvClearOpposites(&DrvInput[2]);
377 		}
378 	}
379 }
380 
381 static struct BurnDIPInfo MgakuenDIPList[]=
382 {
383 	// Default Values
384 	{0x2c, 0xff, 0xff, 0xef, NULL                     },
385 	{0x2d, 0xff, 0xff, 0x8f, NULL                     },
386 
387 	// Dip 1
388 	{0   , 0xfe, 0   , 8   , "Coin A"                 },
389 	{0x2c, 0x01, 0x07, 0x00, "4 Coins 1 Play"         },
390 	{0x2c, 0x01, 0x07, 0x01, "3 Coins 1 Play"         },
391 	{0x2c, 0x01, 0x07, 0x02, "2 Coins 1 Play"         },
392 	{0x2c, 0x01, 0x07, 0x07, "1 Coin  1 Play"         },
393 	{0x2c, 0x01, 0x07, 0x06, "1 Coin  2 Plays"        },
394 	{0x2c, 0x01, 0x07, 0x05, "1 Coin  3 Plays"        },
395 	{0x2c, 0x01, 0x07, 0x04, "1 Coin  4 Plays"        },
396 	{0x2c, 0x01, 0x07, 0x03, "1 Coin  6 Plays"        },
397 
398 	{0   , 0xfe, 0   , 2   , "Rules"                  },
399 	{0x2c, 0x01, 0x08, 0x08, "Kantou"                 },
400 	{0x2c, 0x01, 0x08, 0x00, "Kansai"                 },
401 
402 	{0   , 0xfe, 0   , 2   , "Harness Type"           },
403 	{0x2c, 0x01, 0x10, 0x10, "Generic"                },
404 	{0x2c, 0x01, 0x10, 0x00, "Royal Mahjong"          },
405 
406 	{0   , 0xfe, 0   , 2   , "Flip Screen"            },
407 	{0x2c, 0x01, 0x20, 0x20, "Off"                    },
408 	{0x2c, 0x01, 0x20, 0x00, "On"                     },
409 
410 	{0   , 0xfe, 0   , 2   , "Freeze"                 },
411 	{0x2c, 0x01, 0x40, 0x40, "Off"                    },
412 	{0x2c, 0x01, 0x40, 0x00, "On"                     },
413 
414 	{0   , 0xfe, 0   , 2   , "Service Mode"           },
415 	{0x2c, 0x01, 0x80, 0x80, "Off"                    },
416 	{0x2c, 0x01, 0x80, 0x00, "On"                     },
417 
418 	// Dip 2
419 	{0   , 0xfe, 0   , 4   , "Player 1 Skill"         },
420 	{0x2d, 0x01, 0x03, 0x03, "Weak"                   },
421 	{0x2d, 0x01, 0x03, 0x02, "Normal"                 },
422 	{0x2d, 0x01, 0x03, 0x01, "Strong"                 },
423 	{0x2d, 0x01, 0x03, 0x00, "Very Strong"            },
424 
425 	{0   , 0xfe, 0   , 4   , "Player 2 Skill"         },
426 	{0x2d, 0x01, 0x0c, 0x0c, "Weak"                   },
427 	{0x2d, 0x01, 0x0c, 0x08, "Normal"                 },
428 	{0x2d, 0x01, 0x0c, 0x04, "Strong"                 },
429 	{0x2d, 0x01, 0x0c, 0x00, "Very Strong"            },
430 
431 	{0   , 0xfe, 0   , 2   , "Music"                  },
432 	{0x2d, 0x01, 0x10, 0x10, "Off"                    },
433 	{0x2d, 0x01, 0x10, 0x00, "On"                     },
434 
435 	{0   , 0xfe, 0   , 2   , "Demo Sounds"            },
436 	{0x2d, 0x01, 0x20, 0x20, "Off"                    },
437 	{0x2d, 0x01, 0x20, 0x00, "On"                     },
438 
439 	{0   , 0xfe, 0   , 2   , "Help Mode"              },
440 	{0x2d, 0x01, 0x40, 0x40, "Off"                    },
441 	{0x2d, 0x01, 0x40, 0x00, "On"                     },
442 };
443 
444 STDDIPINFO(Mgakuen)
445 
446 static struct BurnDIPInfo MstworldDIPList[]=
447 {
448 	// Default Values
449 	{0x15, 0xff, 0xff, 0xb0, NULL                     },
450 
451 	// Dip 1
452 	{0   , 0xfe, 0   , 8   , "Coinage"                },
453 	{0x15, 0x01, 0x07, 0x03, "A 1C/4P B 1C/4P"        },
454 	{0x15, 0x01, 0x07, 0x02, "A 1C/3P B 1C/3P"        },
455 	{0x15, 0x01, 0x07, 0x01, "A 1C/2P B 1C/2P"        },
456 	{0x15, 0x01, 0x07, 0x00, "A 1C/1P B 1C/4P"        },
457 	{0x15, 0x01, 0x07, 0x04, "A 2C/1P B 1C/2P"        },
458 	{0x15, 0x01, 0x07, 0x05, "A 2C/1P B 1C/3P"        },
459 	{0x15, 0x01, 0x07, 0x06, "A 3C/1P B 1C/2P"        },
460 	{0x15, 0x01, 0x07, 0x07, "A 4C/1P B 1C/1P"        },
461 
462 	{0   , 0xfe, 0   , 4   , "Lives"                  },
463 	{0x15, 0x01, 0x18, 0x00, "1"                      },
464 	{0x15, 0x01, 0x18, 0x08, "2"                      },
465 	{0x15, 0x01, 0x18, 0x10, "3"                      },
466 	{0x15, 0x01, 0x18, 0x18, "4"                      },
467 
468 	{0   , 0xfe, 0   , 4   , "Difficulty"             },
469 	{0x15, 0x01, 0x60, 0x00, "Easy"                   },
470 	{0x15, 0x01, 0x60, 0x20, "Normal"                 },
471 	{0x15, 0x01, 0x60, 0x40, "Hard"                   },
472 	{0x15, 0x01, 0x60, 0x60, "Hardest"                },
473 
474 	{0   , 0xfe, 0   , 2   , "Demo Sounds"            },
475 	{0x15, 0x01, 0x80, 0x00, "Off"                    },
476 	{0x15, 0x01, 0x80, 0x80, "On"                     },
477 };
478 
479 STDDIPINFO(Mstworld)
480 
481 static struct BurnRomInfo MgakuenRomDesc[] = {
482 	{ "mg-1.1j",       0x08000, 0xbf02ea6b, BRF_ESS | BRF_PRG }, //  0	Z80 #1 Program Code
483 	{ "mg-2.1l",       0x20000, 0x64141b0c, BRF_ESS | BRF_PRG }, //	 1
484 
485 	{ "mg-1.13h",      0x80000, 0xfd6a0805, BRF_GRA },	     //  2	Characters
486 	{ "mg-2.14h",      0x80000, 0xe26e871e, BRF_GRA },	     //  3
487 	{ "mg-3.16h",      0x80000, 0xdd781d9a, BRF_GRA },	     //  4
488 	{ "mg-4.17h",      0x80000, 0x97afcc79, BRF_GRA },	     //  5
489 
490 	{ "mg-6.4l",       0x20000, 0x34594e62, BRF_GRA },	     //  6	Sprites
491 	{ "mg-7.6l",       0x20000, 0xf304c806, BRF_GRA },	     //  7
492 
493 	{ "mg-5.1c",       0x80000, 0x170332f1, BRF_SND },	     //  8	Samples
494 };
495 
496 STD_ROM_PICK(Mgakuen)
497 STD_ROM_FN(Mgakuen)
498 
499 static struct BurnRomInfo SeventoitsuRomDesc[] = {
500 	{ "mc01.1j",       0x08000, 0x0bebe45f, BRF_ESS | BRF_PRG }, //  0	Z80 #1 Program Code
501 	{ "mc02.1l",       0x20000, 0x375378b0, BRF_ESS | BRF_PRG }, //	 1
502 
503 	{ "mg-1.13h",      0x80000, 0xfd6a0805, BRF_GRA },	     //  2	Characters
504 	{ "mg-2.14h",      0x80000, 0xe26e871e, BRF_GRA },	     //  3
505 	{ "mg-3.16h",      0x80000, 0xdd781d9a, BRF_GRA },	     //  4
506 	{ "mg-4.17h",      0x80000, 0x97afcc79, BRF_GRA },	     //  5
507 
508 	{ "mc06.4l",       0x20000, 0x0ef83926, BRF_GRA },	     //  6	Sprites
509 	{ "mc07.6l",       0x20000, 0x59f9ffb1, BRF_GRA },	     //  7
510 
511 	{ "mg-5.1c",       0x80000, 0x170332f1, BRF_SND },	     //  8	Samples
512 };
513 
514 STD_ROM_PICK(Seventoitsu)
515 STD_ROM_FN(Seventoitsu)
516 
517 static struct BurnRomInfo Mgakuen2RomDesc[] = {
518 	{ "mg2-xf.1j",     0x08000, 0xc8165d2d, BRF_ESS | BRF_PRG }, //  0	Z80 #1 Program Code
519 	{ "mg2-y.1l",      0x20000, 0x75bbcc14, BRF_ESS | BRF_PRG }, //	 1
520 	{ "mg2-z.3l",      0x20000, 0xbfdba961, BRF_ESS | BRF_PRG }, //	 2
521 
522 	{ "mg2-a.13h",     0x80000, 0x31a0c55e, BRF_GRA },	     //  3	Characters
523 	{ "mg2-b.14h",     0x80000, 0xc18488fa, BRF_GRA },	     //  4
524 	{ "mg2-c.16h",     0x80000, 0x9425b364, BRF_GRA },	     //  5
525 	{ "mg2-d.17h",     0x80000, 0x6cc9eeba, BRF_GRA },	     //  6
526 
527 	{ "mg2-f.4l",      0x20000, 0x3172c9fe, BRF_GRA },	     //  7	Sprites
528 	{ "mg2-g.6l",      0x20000, 0x19b8b61c, BRF_GRA },	     //  8
529 
530 	{ "mg2-e.1c",      0x80000, 0x70fd0809, BRF_SND },	     //  9	Samples
531 };
532 
533 STD_ROM_PICK(Mgakuen2)
534 STD_ROM_FN(Mgakuen2)
535 
536 static struct BurnRomInfo PkladiesRomDesc[] = {
537 	{ "pko-prg1.14f",  0x08000, 0x86585a94, BRF_ESS | BRF_PRG }, //  0	Z80 #1 Program Code
538 	{ "pko-prg2.15f",  0x10000, 0x86cbe82d, BRF_ESS | BRF_PRG }, //	 1
539 
540 	{ "pko-001.8h",    0x80000, 0x1ead5d9b, BRF_GRA },	     //  2	Characters
541 	{ "pko-003.8j",    0x80000, 0x339ab4e6, BRF_GRA },	     //  3
542 	{ "pko-002.9h",    0x80000, 0x1cf02586, BRF_GRA },	     //  4
543 	{ "pko-004.9j",    0x80000, 0x09ccb442, BRF_GRA },	     //  5
544 
545 	{ "pko-chr1.2j",   0x20000, 0x31ce33cd, BRF_GRA },	     //  6	Sprites
546 	{ "pko-chr2.3j",   0x20000, 0xad7e055f, BRF_GRA },	     //  7
547 
548 	{ "pko-voi1.2d",   0x20000, 0x07e0f531, BRF_SND },	     //  8	Samples
549 	{ "pko-voi2.3d",   0x20000, 0x18398bf6, BRF_SND },	     //  9
550 };
551 
552 STD_ROM_PICK(Pkladies)
553 STD_ROM_FN(Pkladies)
554 
555 static struct BurnRomInfo PkladieslRomDesc[] = {
556 	{ "pk05.14f",      0x08000, 0xea1740a6, BRF_ESS | BRF_PRG }, //  0	Z80 #1 Program Code
557 	{ "pk06.15f",      0x20000, 0x3078ff5e, BRF_ESS | BRF_PRG }, //	 1
558 
559 	{ "pko-001.8h",    0x80000, 0x1ead5d9b, BRF_GRA },	     //  2	Characters
560 	{ "pko-003.8j",    0x80000, 0x339ab4e6, BRF_GRA },	     //  3
561 	{ "pko-002.9h",    0x80000, 0x1cf02586, BRF_GRA },	     //  4
562 	{ "pko-004.9j",    0x80000, 0x09ccb442, BRF_GRA },	     //  5
563 
564 	{ "pko-chr1.2j",   0x20000, 0x31ce33cd, BRF_GRA },	     //  6	Sprites
565 	{ "pko-chr2.3j",   0x20000, 0xad7e055f, BRF_GRA },	     //  7
566 
567 	{ "pko-voi1.2d",   0x20000, 0x07e0f531, BRF_SND },	     //  8	Samples
568 	{ "pko-voi2.3d",   0x20000, 0x18398bf6, BRF_SND },	     //  9
569 };
570 
571 STD_ROM_PICK(Pkladiesl)
572 STD_ROM_FN(Pkladiesl)
573 
574 static struct BurnRomInfo PkladieslaRomDesc[] = {
575 	{ "pk05.14f",        0x08000, 0xfa18e16a, BRF_ESS | BRF_PRG }, //  0	Z80 #1 Program Code
576 	{ "pk06.15f",        0x10000, 0xa2fb7646, BRF_ESS | BRF_PRG }, //	 1
577 
578 	{ "pk0-001-t18.8h",    0x80000, 0x1ead5d9b, BRF_GRA },	     //  2	Characters
579 	{ "pk0-003-t20.8j",    0x80000, 0x339ab4e6, BRF_GRA },	     //  3
580 	{ "pk0-002-t19.9h",    0x80000, 0x1cf02586, BRF_GRA },	     //  4
581 	{ "pk0-004-t21.9j",    0x80000, 0x09ccb442, BRF_GRA },	     //  5
582 
583 	{ "pk16.2j",   0x20000, 0x31ce33cd, BRF_GRA },	     //  6	Sprites
584 	{ "pk17.3j",   0x20000, 0xad7e055f, BRF_GRA },	     //  7
585 
586 	{ "pk01.2d",   0x20000, 0x07e0f531, BRF_SND },	     //  8	Samples
587 	{ "pk02.3d",   0x20000, 0x18398bf6, BRF_SND },	     //  9
588 
589 	{ "93c46.14a", 0x00080, 0x6856c4aa, BRF_OPT },
590 	{ "epl16p8bp.pl-c4.5j", 0x00117, 0x6cae00f7, BRF_OPT },
591 	{ "pal16l8cn.poker.10g", 0x00117, 0x8e592f22, BRF_OPT },
592 };
593 
594 STD_ROM_PICK(Pkladiesla)
595 STD_ROM_FN(Pkladiesla)
596 
597 static struct BurnRomInfo DokabenRomDesc[] = {
598 	{ "db_06.11h",     0x08000, 0x413e0886, BRF_ESS | BRF_PRG }, //  0	Z80 #1 Program Code
599 	{ "db_07.13h",     0x20000, 0x8bdcf49e, BRF_ESS | BRF_PRG }, //	 1
600 	{ "db_08.14h",     0x20000, 0x1643bdd9, BRF_ESS | BRF_PRG }, //	 2
601 
602 	{ "db_02.1e",      0x20000, 0x9aa8470c, BRF_GRA },	     //  3	Characters
603 	{ "db_03.2e",      0x20000, 0x3324e43d, BRF_GRA },	     //  4
604 	{ "db_04.1g",      0x20000, 0xc0c5b6c2, BRF_GRA },	     //  5
605 	{ "db_05.2g",      0x20000, 0xd2ab25f2, BRF_GRA },	     //  6
606 
607 	{ "db_10.2k",      0x20000, 0x9e70f7ae, BRF_GRA },	     //  7	Sprites
608 	{ "db_09.1k",      0x20000, 0x2d9263f7, BRF_GRA },	     //  8
609 
610 	{ "db_01.1d",      0x20000, 0x62fa6b81, BRF_SND },	     //  9	Samples
611 };
612 
613 STD_ROM_PICK(Dokaben)
614 STD_ROM_FN(Dokaben)
615 
616 static struct BurnRomInfo Dokaben2RomDesc[] = {
617 	{ "d2_06.11h",     0x08000, 0x9adcc38c, BRF_ESS | BRF_PRG }, //  0	Z80 #1 Program Code
618 	{ "d2_07.13h",     0x20000, 0x43076e32, BRF_ESS | BRF_PRG }, //	 1
619 	{ "d2_08.14h",     0x20000, 0xcb9deb7a, BRF_ESS | BRF_PRG }, //	 2
620 
621 	{ "d2_02.1e",      0x20000, 0x5dd7b941, BRF_GRA },	     //  3	Characters
622 	{ "d2_03.2e",      0x20000, 0xb615e696, BRF_GRA },	     //  4
623 	{ "d2_04.1g",      0x20000, 0x56b35605, BRF_GRA },	     //  5
624 	{ "d2_05.2g",      0x20000, 0xce98ff74, BRF_GRA },	     //  6
625 
626 	{ "d2_10.2k",      0x20000, 0x9b9bfb5f, BRF_GRA },	     //  7	Sprites
627 	{ "d2_09.1k",      0x20000, 0x84de2e1d, BRF_GRA },	     //  8
628 
629 	{ "db_01.1d",      0x20000, 0x62fa6b81, BRF_SND },	     //  9	Samples
630 };
631 
632 STD_ROM_PICK(Dokaben2)
633 STD_ROM_FN(Dokaben2)
634 
635 static struct BurnRomInfo PangRomDesc[] = {
636 	{ "pwe_06.11h",    0x08000, 0x68be52cd, BRF_ESS | BRF_PRG }, //  0	Z80 #1 Program Code
637 	{ "pwe_07.13h",    0x20000, 0x4a2e70f6, BRF_ESS | BRF_PRG }, //	 1
638 
639 	{ "pwe_02.1e",     0x20000, 0x3a5883f5, BRF_GRA },	     //  2	Characters
640 	{ "pw_03.2e",      0x20000, 0x79a8ed08, BRF_GRA },	     //  3
641 	{ "pwe_04.1g",     0x20000, 0x166a16ae, BRF_GRA },	     //  4
642 	{ "pw_05.2g",      0x20000, 0x2fb3db6c, BRF_GRA },	     //  5
643 
644 	{ "pw_10.2k",      0x20000, 0xfdba4f6e, BRF_GRA },	     //  6	Sprites
645 	{ "pw_9.1k",       0x20000, 0x39f47a63, BRF_GRA },	     //  7
646 
647 	{ "pw_01.1d",       0x20000, 0xc52e5b8e, BRF_SND },	     //  8	Samples
648 };
649 
650 STD_ROM_PICK(Pang)
651 STD_ROM_FN(Pang)
652 
653 static struct BurnRomInfo BbrosRomDesc[] = {
654 	{ "pwu_06.11h",    0x08000, 0xa3041ca4, BRF_ESS | BRF_PRG }, //  0	Z80 #1 Program Code
655 	{ "pwu_07.13h",    0x20000, 0x09231c68, BRF_ESS | BRF_PRG }, //	 1
656 
657 	{ "pwu_02.1e",     0x20000, 0x62f29992, BRF_GRA },	     //  2	Characters
658 	{ "pw_03.2e",      0x20000, 0x79a8ed08, BRF_GRA },	     //  3
659 	{ "pwu_04.1g",     0x20000, 0xf705aa89, BRF_GRA },	     //  4
660 	{ "pw_05.2g",      0x20000, 0x2fb3db6c, BRF_GRA },	     //  5
661 
662 	{ "pw_10.2k",      0x20000, 0xfdba4f6e, BRF_GRA },	     //  6	Sprites
663 	{ "pw_9.1k",       0x20000, 0x39f47a63, BRF_GRA },	     //  7
664 
665 	{ "pw_01.1d",      0x20000, 0xc52e5b8e, BRF_SND },	     //  8	Samples
666 };
667 
668 STD_ROM_PICK(Bbros)
669 STD_ROM_FN(Bbros)
670 
671 static struct BurnRomInfo PompingwRomDesc[] = {
672 	{ "pwj_06.11h",    0x08000, 0x4a0a6426, BRF_ESS | BRF_PRG }, //  0	Z80 #1 Program Code
673 	{ "pwj_07.13h",    0x20000, 0xa9402420, BRF_ESS | BRF_PRG }, //	 1
674 
675 	{ "pw_02.1e",      0x20000, 0x4b5992e4, BRF_GRA },	     //  2	Characters
676 	{ "pw_03.2e",      0x20000, 0x79a8ed08, BRF_GRA },	     //  3
677 	{ "pwj_04.1g",     0x20000, 0x01e49081, BRF_GRA },	     //  4
678 	{ "pw_05.2g",      0x20000, 0x2fb3db6c, BRF_GRA },	     //  5
679 
680 	{ "pw_10.2k",      0x20000, 0xfdba4f6e, BRF_GRA },	     //  6	Sprites
681 	{ "pw_9.1k",       0x20000, 0x39f47a63, BRF_GRA },	     //  7
682 
683 	{ "pw_01.1d",       0x20000, 0xc52e5b8e, BRF_SND },	     //  8	Samples
684 };
685 
686 STD_ROM_PICK(Pompingw)
687 STD_ROM_FN(Pompingw)
688 
689 static struct BurnRomInfo PangbRomDesc[] = {
690 	{ "pang_04.bin",   0x10000, 0xf68f88a5, BRF_ESS | BRF_PRG }, //  0	Z80 #1 Program Code
691 	{ "pang_02.bin",   0x20000, 0x3f15bb61, BRF_ESS | BRF_PRG }, //	 1
692 	{ "pang_03.bin",   0x20000, 0x0c8477ae, BRF_ESS | BRF_PRG }, //	 2
693 
694 	{ "pang_9.bin",    0x20000, 0x3a5883f5, BRF_GRA },	     //  3	Characters
695 	{ "bb3.bin",       0x20000, 0x79a8ed08, BRF_GRA },	     //  4
696 	{ "bb11.bin",      0x20000, 0x166a16ae, BRF_GRA },	     //  5
697 	{ "bb5.bin",       0x20000, 0x2fb3db6c, BRF_GRA },	     //  6
698 
699 	{ "bb10.bin",      0x20000, 0xfdba4f6e, BRF_GRA },	     //  7	Sprites
700 	{ "bb9.bin",       0x20000, 0x39f47a63, BRF_GRA },	     //  8
701 
702 	{ "bb1.bin",       0x20000, 0xc52e5b8e, BRF_SND },	     //  9	Samples
703 };
704 
705 STD_ROM_PICK(Pangb)
706 STD_ROM_FN(Pangb)
707 
708 static struct BurnRomInfo PangboldRomDesc[] = {
709 	{ "4.6l",          0x10000, 0xf68f88a5, BRF_ESS | BRF_PRG }, //  0	Z80 #1 Program Code
710 	{ "2.3l",          0x20000, 0x3f15bb61, BRF_ESS | BRF_PRG }, //	 1
711 	{ "3.5l",          0x20000, 0xce6375e4, BRF_ESS | BRF_PRG }, //	 2
712 
713 	{ "9.10o",         0x20000, 0x3a5883f5, BRF_GRA },	     //  3	Characters
714 	{ "10.14o",        0x20000, 0x79a8ed08, BRF_GRA },	     //  4
715 	{ "11.17j",        0x20000, 0x166a16ae, BRF_GRA },	     //  5
716 	{ "12.20j",        0x20000, 0x2fb3db6c, BRF_GRA },	     //  6
717 
718 	{ "8.7o",          0x10000, 0xf3188aa1, BRF_GRA },	     //  7	Sprites
719 	{ "7.5o",          0x10000, 0x011da14b, BRF_GRA },	     //  8
720 	{ "6.3o",          0x10000, 0x0e25e797, BRF_GRA },	     //  9
721 	{ "5.1o",          0x10000, 0x6daa4e27, BRF_GRA },	     //  10
722 
723 	{ "1.1a",          0x10000, 0xb6463907, BRF_SND },	     //  11	Samples
724 };
725 
726 STD_ROM_PICK(Pangbold)
727 STD_ROM_FN(Pangbold)
728 
729 static struct BurnRomInfo Pangbold2RomDesc[] = {
730 	// f205v id 1294
731 	{ "4.bin",         0x10000, 0x4ef5908b, BRF_ESS | BRF_PRG }, //  0	Z80 #1 Program Code
732 	{ "2.l3",          0x20000, 0x3f15bb61, BRF_ESS | BRF_PRG }, //	 1
733 	{ "3.bin",         0x20000, 0x19c4c0fb, BRF_ESS | BRF_PRG }, //	 2
734 
735 	{ "9.o10",         0x20000, 0x3a5883f5, BRF_GRA },	     //  3	Characters
736 	{ "10.o13",        0x20000, 0x79a8ed08, BRF_GRA },	     //  4
737 	{ "11.j17",        0x20000, 0x166a16ae, BRF_GRA },	     //  5
738 	{ "12.j20",        0x20000, 0x2fb3db6c, BRF_GRA },	     //  6
739 
740 	{ "8.o7",          0x10000, 0xf3188aa1, BRF_GRA },	     //  7	Sprites
741 	{ "7.o5",          0x10000, 0x011da14b, BRF_GRA },	     //  8
742 	{ "6.o3",          0x10000, 0x0e25e797, BRF_GRA },	     //  9
743 	{ "5.o2",          0x10000, 0x6daa4e27, BRF_GRA },	     //  10
744 
745 	{ "1.bin",         0x10000, 0xd7ecf849, BRF_SND },	     //  11	Samples
746 };
747 
748 STD_ROM_PICK(Pangbold2)
749 STD_ROM_FN(Pangbold2)
750 
751 static struct BurnRomInfo Pangbold3RomDesc[] = {
752 	{ "4.l6",          0x10000, 0xf5e6e2fa, BRF_ESS | BRF_PRG }, //  0	Z80 #1 Program Code
753 	{ "2.l3",          0x20000, 0x3f15bb61, BRF_ESS | BRF_PRG }, //	 1
754 	{ "3.l5",          0x20000, 0xce6375e4, BRF_ESS | BRF_PRG }, //	 2
755 
756 	{ "9.o10",         0x20000, 0x3a5883f5, BRF_GRA },	     //  3	Characters
757 	{ "10.o13",        0x20000, 0x79a8ed08, BRF_GRA },	     //  4
758 	{ "11.j17",        0x20000, 0x166a16ae, BRF_GRA },	     //  5
759 	{ "12.j20",        0x20000, 0x2fb3db6c, BRF_GRA },	     //  6
760 
761 	{ "8.o7",          0x10000, 0xf3188aa1, BRF_GRA },	     //  7	Sprites
762 	{ "7.o5",          0x10000, 0x011da14b, BRF_GRA },	     //  8
763 	{ "6.o3",          0x10000, 0x0e25e797, BRF_GRA },	     //  9
764 	{ "5.o2",          0x10000, 0x6daa4e27, BRF_GRA },	     //  10
765 
766 	{ "1.a1",          0x10000, 0xb6463907, BRF_SND },	     //  11	Samples
767 };
768 
769 STD_ROM_PICK(Pangbold3)
770 STD_ROM_FN(Pangbold3)
771 
772 static struct BurnRomInfo Pangb2RomDesc[] = {
773 	{ "27c512.11h",    0x10000, 0x369a453e, BRF_ESS | BRF_PRG }, //  0	Z80 #1 Program Code
774 	{ "27c020.13h",    0x40000, 0x5e7f24b1, BRF_ESS | BRF_PRG }, //	 1
775 
776 	{ "pang_9.bin",    0x20000, 0x3a5883f5, BRF_GRA },	     //  2	Characters
777 	{ "bb3.bin",       0x20000, 0x79a8ed08, BRF_GRA },	     //  3
778 	{ "bb11.bin",      0x20000, 0x166a16ae, BRF_GRA },	     //  4
779 	{ "bb5.bin",       0x20000, 0x2fb3db6c, BRF_GRA },	     //  5
780 
781 	{ "bb10.bin",      0x20000, 0xfdba4f6e, BRF_GRA },	     //  6	Sprites
782 	{ "bb9.bin",       0x20000, 0x39f47a63, BRF_GRA },	     //  7
783 
784 	{ "bb1.bin",       0x20000, 0xc52e5b8e, BRF_SND },	     //  8	Samples
785 };
786 
787 STD_ROM_PICK(Pangb2)
788 STD_ROM_FN(Pangb2)
789 
790 static struct BurnRomInfo CworldRomDesc[] = {
791 	{ "cw05.bin",      0x08000, 0xd3c1723d, BRF_ESS | BRF_PRG }, //  0	Z80 #1 Program Code
792 	{ "cw06.bin",      0x20000, 0xd71ed4a3, BRF_ESS | BRF_PRG }, //	 1
793 	{ "cw07.bin",      0x20000, 0xd419ce08, BRF_ESS | BRF_PRG }, //	 2
794 
795 	{ "cw08.bin",      0x20000, 0x6c80da3c, BRF_GRA },	     //  3	Characters
796 	{ "cw09.bin",      0x20000, 0x7607da71, BRF_GRA },	     //  4
797 	{ "cw10.bin",      0x20000, 0x6f0e639f, BRF_GRA },	     //  5
798 	{ "cw11.bin",      0x20000, 0x130bd7c0, BRF_GRA },	     //  6
799 	{ "cw18.bin",      0x20000, 0xbe6ee0c9, BRF_GRA },	     //  7
800 	{ "cw19.bin",      0x20000, 0x51fc5532, BRF_GRA },	     //  8
801 	{ "cw20.bin",      0x20000, 0x58381d58, BRF_GRA },	     //  9
802 	{ "cw21.bin",      0x20000, 0x910cc753, BRF_GRA },	     //  10
803 
804 	{ "cw16.bin",      0x20000, 0xf90217d1, BRF_GRA },	     //  11	Sprites
805 	{ "cw17.bin",      0x20000, 0xc953c702, BRF_GRA },	     //  12
806 
807 	{ "cw01.bin",      0x20000, 0xf4368f5b, BRF_SND },	     //  13	Samples
808 };
809 
810 STD_ROM_PICK(Cworld)
811 STD_ROM_FN(Cworld)
812 
813 static struct BurnRomInfo HatenaRomDesc[] = {
814 	{ "q2-05.rom",     0x08000, 0x66c9e1da, BRF_ESS | BRF_PRG }, //  0	Z80 #1 Program Code
815 	{ "q2-06.rom",     0x20000, 0x5fc39916, BRF_ESS | BRF_PRG }, //	 1
816 	{ "q2-07.rom",     0x20000, 0xec6d5e5e, BRF_ESS | BRF_PRG }, //	 2
817 
818 	{ "q2-08.rom",     0x20000, 0x6c80da3c, BRF_GRA },	     //  3	Characters
819 	{ "q2-09.rom",     0x20000, 0xabe3e15c, BRF_GRA },	     //  4
820 	{ "q2-10.rom",     0x20000, 0x6963450d, BRF_GRA },	     //  5
821 	{ "q2-11.rom",     0x20000, 0x1e319fa2, BRF_GRA },	     //  6
822 	{ "q2-18.rom",     0x20000, 0xbe6ee0c9, BRF_GRA },	     //  7
823 	{ "q2-19.rom",     0x20000, 0x70300445, BRF_GRA },	     //  8
824 	{ "q2-20.rom",     0x20000, 0x21a6ff42, BRF_GRA },	     //  9
825 	{ "q2-21.rom",     0x20000, 0x076280c9, BRF_GRA },	     //  10
826 
827 	{ "q2-16.rom",     0x20000, 0xec19b2f0, BRF_GRA },	     //  11	Sprites
828 	{ "q2-17.rom",     0x20000, 0xecd69d92, BRF_GRA },	     //  12
829 
830 	{ "q2-01.rom",     0x20000, 0x149e7a89, BRF_SND },	     //  13	Samples
831 };
832 
833 STD_ROM_PICK(Hatena)
834 STD_ROM_FN(Hatena)
835 
836 static struct BurnRomInfo SpangRomDesc[] = {
837 	{ "spe_06.11h",    0x08000, 0x1af106fb, BRF_ESS | BRF_PRG }, //  0	Z80 #1 Program Code
838 	{ "spe_07.13h",    0x20000, 0x208b5f54, BRF_ESS | BRF_PRG }, //	 1
839 	{ "spe_08.14h",    0x20000, 0x2bc03ade, BRF_ESS | BRF_PRG }, //	 2
840 
841 	{ "spe_02.1e",     0x20000, 0x63c9dfd2, BRF_GRA },	     //  3	Characters
842 	{ "spj_03.3e",     0x20000, 0x3ae28bc1, BRF_GRA },	     //  4
843 	{ "spe_04.1g",     0x20000, 0x9d7b225b, BRF_GRA },	     //  5
844 	{ "spj_05.2g",     0x20000, 0x4a060884, BRF_GRA },	     //  6
845 
846 	{ "spj_10.2k",     0x20000, 0xeedd0ade, BRF_GRA },	     //  7	Sprites
847 	{ "spj_09.1k",     0x20000, 0x04b41b75, BRF_GRA },	     //  8
848 
849 	{ "spe_01.1d",     0x20000, 0x2d19c133, BRF_SND },	     //  9	Samples
850 
851 	{ "eeprom-spang.bin", 0x80, 0xdeae1291, BRF_PRG },
852 };
853 
854 STD_ROM_PICK(Spang)
855 STD_ROM_FN(Spang)
856 
857 static struct BurnRomInfo SpangjRomDesc[] = {
858 	{ "spj_06.11h",    0x08000, 0x1a548b0b, BRF_ESS | BRF_PRG }, //  0	Z80 #1 Program Code
859 	{ "spj_07.13h",    0x20000, 0x14c2b765, BRF_ESS | BRF_PRG }, //	 1
860 	{ "spj_08.14h",    0x20000, 0x4be4e5b7, BRF_ESS | BRF_PRG }, //	 2
861 
862 	{ "spj_02.1e",     0x20000, 0x419f69d7, BRF_GRA },	     //  3	Characters
863 	{ "spj_03.3e",     0x20000, 0x3ae28bc1, BRF_GRA },	     //  4
864 	{ "spj_04.1g",     0x20000, 0x6870506f, BRF_GRA },	     //  5
865 	{ "spj_05.2g",     0x20000, 0x4a060884, BRF_GRA },	     //  6
866 
867 	{ "spj_10.2k",     0x20000, 0xeedd0ade, BRF_GRA },	     //  7	Sprites
868 	{ "spj_09.1k",     0x20000, 0x04b41b75, BRF_GRA },	     //  8
869 
870 	{ "spj_01.1d",     0x20000, 0xb96ea126, BRF_SND },	     //  9	Samples
871 
872 	{ "eeprom-spangj.bin",0x80, 0x237c00eb, BRF_PRG },
873 };
874 
875 STD_ROM_PICK(Spangj)
876 STD_ROM_FN(Spangj)
877 
878 static struct BurnRomInfo SbbrosRomDesc[] = {
879 	{ "spu_06.11h",    0x08000, 0x292eee6a, BRF_ESS | BRF_PRG }, //  0	Z80 #1 Program Code
880 	{ "spu_07.13h",    0x20000, 0xf46b698d, BRF_ESS | BRF_PRG }, //	 1
881 	{ "spu_08.14h",    0x20000, 0xa75e7fbe, BRF_ESS | BRF_PRG }, //	 2
882 
883 	{ "spu_02.1e",     0x20000, 0x0c22ffc6, BRF_GRA },	     //  3	Characters
884 	{ "spj_03.3e",     0x20000, 0x3ae28bc1, BRF_GRA },	     //  4
885 	{ "spu_04.1g",     0x20000, 0xbb3dee5b, BRF_GRA },	     //  5
886 	{ "spj_05.2g",     0x20000, 0x4a060884, BRF_GRA },	     //  6
887 
888 	{ "spu_10.2k",     0x20000, 0xd6675d8f, BRF_GRA },	     //  7	Sprites
889 	{ "spu_09.1k",     0x20000, 0x8f678bc8, BRF_GRA },	     //  8
890 
891 	{ "spj_01.1d",     0x20000, 0xb96ea126, BRF_SND },	     //  9	Samples
892 
893 	{ "eeprom-sbbros.bin",0x80, 0xed69d3cd, BRF_PRG },
894 };
895 
896 STD_ROM_PICK(Sbbros)
897 STD_ROM_FN(Sbbros)
898 
899 static struct BurnRomInfo MstworldRomDesc[] = {
900 	{ "mw-1.rom",      0x80000, 0xc4e51fb4, BRF_ESS | BRF_PRG }, //  0	Z80 #1 Program Code
901 
902 	{ "mw-2.rom",      0x08000, 0x12c4fea9, BRF_ESS | BRF_PRG }, //  1	Z80 #2 Program Code
903 
904 	{ "mw-4.rom",      0x20000, 0x28a3af15, BRF_GRA },	     //  2	Characters
905 	{ "mw-5.rom",      0x20000, 0xffdf7e9f, BRF_GRA },	     //  3
906 	{ "mw-6.rom",      0x20000, 0x1ed773a3, BRF_GRA },	     //  4
907 	{ "mw-7.rom",      0x20000, 0x8eb7525c, BRF_GRA },	     //  5
908 
909 	{ "mw-8.rom",      0x20000, 0xb9b92a3c, BRF_GRA },	     //  6	Sprites
910 	{ "mw-9.rom",      0x20000, 0x75fc3375, BRF_GRA },	     //  7
911 
912 	{ "mw-3.rom",      0x80000, 0x110c6a68, BRF_SND },	     //  8	Samples
913 };
914 
915 STD_ROM_PICK(Mstworld)
916 STD_ROM_FN(Mstworld)
917 
918 static struct BurnRomInfo MarukinRomDesc[] = {
919 	{ "mg3-01.9d",     0x08000, 0x04357973, BRF_ESS | BRF_PRG }, //  0	Z80 #1 Program Code
920 	{ "mg3-02.10d",    0x20000, 0x50d08da0, BRF_ESS | BRF_PRG }, //	 1
921 
922 	{ "mg3-a.3k",      0x80000, 0x420f1de7, BRF_GRA },	     //  2	Characters
923 	{ "mg3-b.4k",      0x80000, 0xd8de13fa, BRF_GRA },	     //  3
924 	{ "mg3-c.6k",      0x80000, 0xfbeb66e8, BRF_GRA },	     //  4
925 	{ "mg3-d.7k",      0x80000, 0x8f6bd831, BRF_GRA },	     //  5
926 
927 	{ "mg3-05.2g",     0x20000, 0x7a738d2d, BRF_GRA },	     //  6	Sprites
928 	{ "mg3-04.1g",     0x20000, 0x56f30515, BRF_GRA },	     //  7
929 
930 	{ "mg3-e.1d",      0x80000, 0x106c2fa9, BRF_SND },	     //  8	Samples
931 };
932 
933 STD_ROM_PICK(Marukin)
934 STD_ROM_FN(Marukin)
935 
936 static struct BurnRomInfo Qtono1RomDesc[] = {
937 	{ "q3-05.rom",     0x08000, 0x1dd0a344, BRF_ESS | BRF_PRG }, //  0	Z80 #1 Program Code
938 	{ "q3-06.rom",     0x20000, 0xbd6a2110, BRF_ESS | BRF_PRG }, //	 1
939 	{ "q3-07.rom",     0x20000, 0x61e53c4f, BRF_ESS | BRF_PRG }, //	 2
940 
941 	{ "q3-08.rom",     0x20000, 0x1533b978, BRF_GRA },	     //  3	Characters
942 	{ "q3-09.rom",     0x20000, 0xa32db2f2, BRF_GRA },	     //  4
943 	{ "q3-10.rom",     0x20000, 0xed681aa8, BRF_GRA },	     //  5
944 	{ "q3-11.rom",     0x20000, 0x38b2fd10, BRF_GRA },	     //  6
945 	{ "q3-18.rom",     0x20000, 0x9e4292ac, BRF_GRA },	     //  7
946 	{ "q3-19.rom",     0x20000, 0xb7f6d40f, BRF_GRA },	     //  8
947 	{ "q3-20.rom",     0x20000, 0x6cd7f38d, BRF_GRA },	     //  9
948 	{ "q3-21.rom",     0x20000, 0xb4aa6b4b, BRF_GRA },	     //  10
949 
950 	{ "q3-16.rom",     0x20000, 0x863d6836, BRF_GRA },	     //  11	Sprites
951 	{ "q3-17.rom",     0x20000, 0x459bf59c, BRF_GRA },	     //  12
952 
953 	{ "q3-01.rom",     0x20000, 0x6c1be591, BRF_SND },	     //  13	Samples
954 };
955 
956 STD_ROM_PICK(Qtono1)
957 STD_ROM_FN(Qtono1)
958 
959 static struct BurnRomInfo QsangokuRomDesc[] = {
960 	{ "q4-05c.rom",    0x08000, 0xe1d010b4, BRF_ESS | BRF_PRG }, //  0	Z80 #1 Program Code
961 	{ "q4-06.rom",     0x20000, 0xa0301849, BRF_ESS | BRF_PRG }, //	 1
962 	{ "q4-07.rom",     0x20000, 0x2941ef5b, BRF_ESS | BRF_PRG }, //	 2
963 
964 	{ "q4-08.rom",     0x20000, 0xdc84c6cb, BRF_GRA },	     //  3	Characters
965 	{ "q4-09.rom",     0x20000, 0xcbb6234c, BRF_GRA },	     //  4
966 	{ "q4-10.rom",     0x20000, 0xc20a27a8, BRF_GRA },	     //  5
967 	{ "q4-11.rom",     0x20000, 0x4ff66aed, BRF_GRA },	     //  6
968 	{ "q4-18.rom",     0x20000, 0xca3acea5, BRF_GRA },	     //  7
969 	{ "q4-19.rom",     0x20000, 0x1fd92b7d, BRF_GRA },	     //  8
970 	{ "q4-20.rom",     0x20000, 0xb02dc6a1, BRF_GRA },	     //  9
971 	{ "q4-21.rom",     0x20000, 0x432b1dc1, BRF_GRA },	     //  10
972 
973 	{ "q4-16.rom",     0x20000, 0x77342320, BRF_GRA },	     //  11	Sprites
974 	{ "q4-17.rom",     0x20000, 0x1275c436, BRF_GRA },	     //  12
975 
976 	{ "q4-01.rom",     0x20000, 0x5d0d07d8, BRF_SND },	     //  13	Samples
977 };
978 
979 STD_ROM_PICK(Qsangoku)
980 STD_ROM_FN(Qsangoku)
981 
982 static struct BurnRomInfo BlockRomDesc[] = {
983 	{ "ble_05b.14f",   0x08000, 0xfcdb7885, BRF_ESS | BRF_PRG }, //  0	Z80 #1 Program Code
984 	{ "ble_06b.15f",   0x20000, 0xe114ebde, BRF_ESS | BRF_PRG }, //	 1
985 	{ "ble_07b.16f",   0x20000, 0x61bef077, BRF_ESS | BRF_PRG }, //	 2
986 
987 	{ "bl_08.8h",      0x20000, 0xaa0f4ff1, BRF_GRA },	     //  3	Characters
988 	{ "bl_09.9h",      0x20000, 0x6fa8c186, BRF_GRA },	     //  4
989 	{ "bl_18.8j",      0x20000, 0xc0acafaf, BRF_GRA },	     //  5
990 	{ "bl_19.9j",      0x20000, 0x1ae942f5, BRF_GRA },	     //  6
991 
992 	{ "bl_16.2j",      0x20000, 0xfadcaff7, BRF_GRA },	     //  7	Sprites
993 	{ "bl_17.3j",      0x20000, 0x5f8cab42, BRF_GRA },	     //  8
994 
995 	{ "bl_01.2d",      0x20000, 0xc2ec2abb, BRF_SND },	     //  9	Samples
996 };
997 
998 STD_ROM_PICK(Block)
999 STD_ROM_FN(Block)
1000 
1001 static struct BurnRomInfo Blockr1RomDesc[] = {
1002 	{ "ble_05a.14f",   0x08000, 0xfa2a4536, BRF_ESS | BRF_PRG }, //  0	Z80 #1 Program Code
1003 	{ "ble_06a.15f",   0x20000, 0xe114ebde, BRF_ESS | BRF_PRG }, //	 1
1004 	{ "ble_07.16f",    0x20000, 0x1d114f13, BRF_ESS | BRF_PRG }, //	 2
1005 
1006 	{ "bl_08.8h",      0x20000, 0xaa0f4ff1, BRF_GRA },	     //  3	Characters
1007 	{ "bl_09.9h",      0x20000, 0x6fa8c186, BRF_GRA },	     //  4
1008 	{ "bl_18.8j",      0x20000, 0xc0acafaf, BRF_GRA },	     //  5
1009 	{ "bl_19.9j",      0x20000, 0x1ae942f5, BRF_GRA },	     //  6
1010 
1011 	{ "bl_16.2j",      0x20000, 0xfadcaff7, BRF_GRA },	     //  7	Sprites
1012 	{ "bl_17.3j",      0x20000, 0x5f8cab42, BRF_GRA },	     //  8
1013 
1014 	{ "bl_01.2d",      0x20000, 0xc2ec2abb, BRF_SND },	     //  9	Samples
1015 };
1016 
1017 STD_ROM_PICK(Blockr1)
1018 STD_ROM_FN(Blockr1)
1019 
1020 static struct BurnRomInfo Blockr2RomDesc[] = {
1021 	{ "ble_05.14f",    0x08000, 0xc12e7f4c, BRF_ESS | BRF_PRG }, //  0	Z80 #1 Program Code
1022 	{ "ble_06.15f",    0x20000, 0xcdb13d55, BRF_ESS | BRF_PRG }, //	 1
1023 	{ "ble_07.16f",    0x20000, 0x1d114f13, BRF_ESS | BRF_PRG }, //	 2
1024 
1025 	{ "bl_08.8h",      0x20000, 0xaa0f4ff1, BRF_GRA },	     //  3	Characters
1026 	{ "bl_09.9h",      0x20000, 0x6fa8c186, BRF_GRA },	     //  4
1027 	{ "bl_18.8j",      0x20000, 0xc0acafaf, BRF_GRA },	     //  5
1028 	{ "bl_19.9j",      0x20000, 0x1ae942f5, BRF_GRA },	     //  6
1029 
1030 	{ "bl_16.2j",      0x20000, 0xfadcaff7, BRF_GRA },	     //  7	Sprites
1031 	{ "bl_17.3j",      0x20000, 0x5f8cab42, BRF_GRA },	     //  8
1032 
1033 	{ "bl_01.2d",      0x20000, 0xc2ec2abb, BRF_SND },	     //  9	Samples
1034 };
1035 
1036 STD_ROM_PICK(Blockr2)
1037 STD_ROM_FN(Blockr2)
1038 
1039 static struct BurnRomInfo BlockjRomDesc[] = {
1040 	{ "blj_05.14f",    0x08000, 0x3b55969a, BRF_ESS | BRF_PRG }, //  0	Z80 #1 Program Code
1041 	{ "ble_06.15f",    0x20000, 0xcdb13d55, BRF_ESS | BRF_PRG }, //	 1
1042 	{ "blj_07.16f",    0x20000, 0x1723883c, BRF_ESS | BRF_PRG }, //	 2
1043 
1044 	{ "bl_08.8h",      0x20000, 0xaa0f4ff1, BRF_GRA },	     //  3	Characters
1045 	{ "bl_09.9h",      0x20000, 0x6fa8c186, BRF_GRA },	     //  4
1046 	{ "bl_18.8j",      0x20000, 0xc0acafaf, BRF_GRA },	     //  5
1047 	{ "bl_19.9j",      0x20000, 0x1ae942f5, BRF_GRA },	     //  6
1048 
1049 	{ "bl_16.2j",      0x20000, 0xfadcaff7, BRF_GRA },	     //  7	Sprites
1050 	{ "bl_17.3j",      0x20000, 0x5f8cab42, BRF_GRA },	     //  8
1051 
1052 	{ "bl_01.2d",      0x20000, 0xc2ec2abb, BRF_SND },	     //  9	Samples
1053 };
1054 
1055 STD_ROM_PICK(Blockj)
1056 STD_ROM_FN(Blockj)
1057 
1058 static struct BurnRomInfo BlockblRomDesc[] = {
1059 	{ "m7.l6",         0x10000, 0x3b576fd9, BRF_ESS | BRF_PRG }, //  0	Z80 #1 Program Code
1060 	{ "m5.l3",         0x40000, 0x7c988bb7, BRF_ESS | BRF_PRG }, //	 1
1061 	{ "m6.l5",         0x20000, 0x5768d8eb, BRF_ESS | BRF_PRG }, //	 2
1062 
1063 	{ "m12.o10",       0x20000, 0x963154d9, BRF_GRA },	     //  3	Characters
1064 	{ "m13.o14",       0x20000, 0x069480bb, BRF_GRA },	     //  4
1065 	{ "m4.j17",        0x20000, 0x9e3b6f4f, BRF_GRA },	     //  5
1066 	{ "m3.j20",        0x20000, 0x629d58fe, BRF_GRA },	     //  6
1067 
1068 	{ "m11.o7",        0x10000, 0x255180a5, BRF_GRA },	     //  7	Sprites
1069 	{ "m10.o5",        0x10000, 0x3201c088, BRF_GRA },	     //  8
1070 	{ "m9.o3",         0x10000, 0x29357fe4, BRF_GRA },	     //  9
1071 	{ "m8.o2",         0x10000, 0xabd665d1, BRF_GRA },	     //  10
1072 
1073 	{ "bl_01.rom",     0x20000, 0xc2ec2abb, BRF_SND },	     //  11	Samples
1074 };
1075 
1076 STD_ROM_PICK(Blockbl)
1077 STD_ROM_FN(Blockbl)
1078 
1079 static const eeprom_interface MitchellEEPROMIntf =
1080 {
1081 	6,
1082 	16,
1083 	"0110",
1084 	"0101",
1085 	"0111",
1086 	0,
1087 	0,
1088 	0,
1089 	0
1090 };
1091 
MgakuenMemIndex()1092 static INT32 MgakuenMemIndex()
1093 {
1094 	UINT8 *Next; Next = Mem;
1095 
1096 	DrvZ80Rom              = Next; Next += 0x50000;
1097 	DrvSoundRom            = Next; Next += 0x80000;
1098 
1099 	RamStart               = Next;
1100 
1101 	DrvZ80Ram              = Next; Next += 0x01000;
1102 	DrvPaletteRam          = Next; Next += 0x00800;
1103 	DrvAttrRam             = Next; Next += 0x00800;
1104 	DrvVideoRam            = Next; Next += 0x01000;
1105 	DrvSpriteRam           = Next; Next += 0x01000;
1106 
1107 	RamEnd                 = Next;
1108 
1109 	DrvChars               = Next; Next += 0x10000 * 8 * 8;
1110 	DrvSprites             = Next; Next += 0x00800 * 16 * 16;
1111 	DrvPalette             = (UINT32*)Next; Next += 0x00400 * sizeof(UINT32);
1112 
1113 	MemEnd                 = Next;
1114 
1115 	return 0;
1116 }
1117 
PangMemIndex()1118 static INT32 PangMemIndex()
1119 {
1120 	UINT8 *Next; Next = Mem;
1121 
1122 	DrvZ80Rom              = Next; Next += 0x50000;
1123 	DrvZ80Code             = Next; Next += 0x50000;
1124 	DrvSoundRom            = Next; Next += 0x20000;
1125 
1126 	RamStart               = Next;
1127 
1128 	DrvZ80Ram              = Next; Next += 0x02000;
1129 	DrvPaletteRam          = Next; Next += 0x01000;
1130 	DrvAttrRam             = Next; Next += 0x00800;
1131 	DrvVideoRam            = Next; Next += 0x01000;
1132 	DrvSpriteRam           = Next; Next += 0x01000;
1133 
1134 	RamEnd                 = Next;
1135 
1136 	DrvChars               = Next; Next += 0x8000 * 8 * 8;
1137 	DrvSprites             = Next; Next += 0x0800 * 16 * 16;
1138 	DrvPalette             = (UINT32*)Next; Next += 0x00800 * sizeof(UINT32);
1139 
1140 	MemEnd                 = Next;
1141 
1142 	return 0;
1143 }
1144 
MahjongMemIndex()1145 static INT32 MahjongMemIndex()
1146 {
1147 	UINT8 *Next; Next = Mem;
1148 
1149 	DrvZ80Rom              = Next; Next += 0x50000;
1150 	DrvZ80Code             = Next; Next += 0x50000;
1151 	DrvSoundRom            = Next; Next += 0x80000;
1152 
1153 	RamStart               = Next;
1154 
1155 	DrvZ80Ram              = Next; Next += 0x02000;
1156 	DrvPaletteRam          = Next; Next += 0x01000;
1157 	DrvAttrRam             = Next; Next += 0x00800;
1158 	DrvVideoRam            = Next; Next += 0x01000;
1159 	DrvSpriteRam           = Next; Next += 0x01000;
1160 
1161 	RamEnd                 = Next;
1162 
1163 	DrvChars               = Next; Next += 0x10000 * 8 * 8;
1164 	DrvSprites             = Next; Next += 0x00800 * 16 * 16;
1165 	DrvPalette             = (UINT32*)Next; Next += 0x00800 * sizeof(UINT32);
1166 
1167 	MemEnd                 = Next;
1168 
1169 	return 0;
1170 }
1171 
MstworldMemIndex()1172 static INT32 MstworldMemIndex()
1173 {
1174 	UINT8 *Next; Next = Mem;
1175 
1176 	DrvZ80Rom              = Next; Next += 0x50000;
1177 	DrvZ80Code             = Next; Next += 0x50000;
1178 	DrvZ80Rom2             = Next; Next += 0x08000;
1179 	DrvSoundRom            = Next; Next += 0x100000;
1180 
1181 	RamStart               = Next;
1182 
1183 	DrvZ80Ram              = Next; Next += 0x02000;
1184 	DrvZ80Ram2             = Next; Next += 0x00800;
1185 	DrvPaletteRam          = Next; Next += 0x01000;
1186 	DrvAttrRam             = Next; Next += 0x00800;
1187 	DrvVideoRam            = Next; Next += 0x01000;
1188 	DrvSpriteRam           = Next; Next += 0x01000;
1189 
1190 	RamEnd                 = Next;
1191 
1192 	DrvChars               = Next; Next += 0x4000 * 8 * 8;
1193 	DrvSprites             = Next; Next += 0x0800 * 16 * 16;
1194 	DrvPalette             = (UINT32*)Next; Next += 0x00800 * sizeof(UINT32);
1195 
1196 	MemEnd                 = Next;
1197 
1198 	return 0;
1199 }
1200 
oki_bankswitch(INT32 bank)1201 static void oki_bankswitch(INT32 bank)
1202 {
1203 	DrvOkiBank = bank;
1204 
1205 	MSM6295SetBank(0, DrvSoundRom + (DrvOkiBank * 0x40000), 0x00000, 0x3ffff);
1206 }
1207 
DrvDoReset()1208 static INT32 DrvDoReset()
1209 {
1210 	ZetOpen(0);
1211 	DrvRomBank = 0;
1212 	ZetMapArea(0x8000, 0xbfff, 0, DrvZ80Rom + 0x10000 + (DrvRomBank * 0x4000));
1213 	if (DrvHasEEPROM) {
1214 		ZetMapArea(0x8000, 0xbfff, 2, DrvZ80Code + 0x10000 + (DrvRomBank * 0x4000), DrvZ80Rom + 0x10000 + (DrvRomBank * 0x4000));
1215 	} else {
1216 		ZetMapArea(0x8000, 0xbfff, 2, DrvZ80Rom + 0x10000 + (DrvRomBank * 0x4000));
1217 	}
1218 	ZetReset();
1219 	ZetClose();
1220 
1221 	BurnYM2413Reset();
1222 	MSM6295Reset(0);
1223 	oki_bankswitch(0);
1224 
1225 	if (DrvHasEEPROM) EEPROMReset();
1226 
1227 	DrvPaletteRamBank = 0;
1228 	DrvVideoBank = 0;
1229 	DrvDialSelected = 0;
1230 
1231 	HiscoreReset();
1232 
1233 	return 0;
1234 }
1235 
MstworldDoReset()1236 static INT32 MstworldDoReset()
1237 {
1238 	ZetOpen(0);
1239 	DrvRomBank = 0;
1240 	ZetMapArea(0x8000, 0xbfff, 0, DrvZ80Rom + 0x10000 + (DrvRomBank * 0x4000));
1241 	ZetMapArea(0x8000, 0xbfff, 2, DrvZ80Code + 0x10000 + (DrvRomBank * 0x4000), DrvZ80Rom + 0x10000 + (DrvRomBank * 0x4000));
1242 	ZetReset();
1243 	ZetClose();
1244 
1245 	ZetOpen(1);
1246 	ZetReset();
1247 	ZetClose();
1248 
1249 	MSM6295Reset(0);
1250 
1251 	DrvPaletteRamBank = 0;
1252 	DrvVideoBank = 0;
1253 	DrvSoundLatch = 0;
1254 
1255 	HiscoreReset();
1256 
1257 	return 0;
1258 }
1259 
BlockDialRead(INT32 Offset)1260 static UINT8 BlockDialRead(INT32 Offset)
1261 {
1262 	static INT32 Dir[2];
1263 
1264 	if (DrvDialSelected) {
1265 		INT32 Delta;
1266 
1267 		Delta = ((Offset ? DrvDial2 : DrvDial1) - DrvDial[Offset]) & 0xff;
1268 		if (Delta & 0x80) {
1269 			Delta = (-Delta) & 0xff;
1270 			if (Dir[Offset]) {
1271 				Dir[Offset] = 0;
1272 				Delta = 0;
1273 			}
1274 		} else {
1275 			if (Delta > 0) {
1276 				if (Dir[Offset] == 0) {
1277 					Dir[Offset] = 1;
1278 					Delta = 0;
1279 				}
1280 			}
1281 		}
1282 
1283 		if (Delta > 0x3f) Delta = 0x3f;
1284 
1285 		return Delta << 2;
1286 	} else {
1287 		INT32 Res = (0xff - DrvInput[Offset + 1]) & 0xf7;
1288 		if (Dir[Offset]) Res |= 0x08;
1289 
1290 		return Res;
1291 	}
1292 }
1293 
MitchellZ80Read(UINT16 a)1294 static UINT8 __fastcall MitchellZ80Read(UINT16 a)
1295 {
1296 	if (a >= 0xc000 && a <= 0xc7ff) {
1297 		return DrvPaletteRam[(a - 0xc000) + (DrvPaletteRamBank ? 0x800 : 0x000)];
1298 	}
1299 
1300 	if (a >= 0xd000 && a <= 0xdfff) {
1301 		INT32 Offset = a - 0xd000;
1302 		if (DrvVideoBank) {
1303 			return DrvSpriteRam[Offset];
1304 		} else {
1305 			return DrvVideoRam[Offset];
1306 		}
1307 	}
1308 
1309 	switch (a) {
1310 		default: {
1311 			bprintf(PRINT_NORMAL, _T("Z80 #1 Read => %04X\n"), a);
1312 		}
1313 	}
1314 
1315 	return 0;
1316 }
1317 
MitchellZ80Write(UINT16 a,UINT8 d)1318 static void __fastcall MitchellZ80Write(UINT16 a, UINT8 d)
1319 {
1320 	if (a >= 0xc000 && a <= 0xc7ff) {
1321 		DrvPaletteRam[(a - 0xc000) + (DrvPaletteRamBank ? 0x800 : 0x000)] = d;
1322 		return;
1323 	}
1324 
1325 	if (a >= 0xd000 && a <= 0xdfff) {
1326 		INT32 Offset = a - 0xd000;
1327 		if (DrvVideoBank) {
1328 			DrvSpriteRam[Offset] = d;
1329 		} else {
1330 			DrvVideoRam[Offset] = d;
1331 		}
1332 		return;
1333 	}
1334 
1335 	switch (a) {
1336 		default: {
1337 			bprintf(PRINT_NORMAL, _T("Z80 #1 Write => %04X, %02X\n"), a, d);
1338 		}
1339 	}
1340 }
1341 
MitchellZ80PortRead(UINT16 a)1342 static UINT8 __fastcall MitchellZ80PortRead(UINT16 a)
1343 {
1344 	a &= 0xff;
1345 
1346 	switch (a) {
1347 		case 0x00: {
1348 			return 0xff - DrvInput[0];
1349 		}
1350 
1351 		case 0x01: {
1352 			switch (DrvInputType) {
1353 				case DRV_INPUT_TYPE_MAHJONG: {
1354 					if (DrvMahjongKeyMatrix & (0x80 >> 0)) return 0xff - DrvInput[1];
1355 					if (DrvMahjongKeyMatrix & (0x80 >> 1)) return 0xff - DrvInput[2];
1356 					if (DrvMahjongKeyMatrix & (0x80 >> 2)) return 0xff - DrvInput[4];
1357 					if (DrvMahjongKeyMatrix & (0x80 >> 3)) return 0xff - DrvInput[5];
1358 					if (DrvMahjongKeyMatrix & (0x80 >> 4)) return 0xff - DrvInput[6];
1359 				}
1360 
1361 				case DRV_INPUT_TYPE_BLOCK: {
1362 					return BlockDialRead(0);
1363 				}
1364 			}
1365 
1366 			return 0xff - DrvInput[1];
1367 		}
1368 
1369 		case 0x02: {
1370 			switch (DrvInputType) {
1371 				case DRV_INPUT_TYPE_MAHJONG: {
1372 					if (DrvMahjongKeyMatrix & (0x80 >> 0)) return 0xff - DrvInput[7];
1373 					if (DrvMahjongKeyMatrix & (0x80 >> 1)) return 0xff - DrvInput[8];
1374 					if (DrvMahjongKeyMatrix & (0x80 >> 2)) return 0xff - DrvInput[9];
1375 					if (DrvMahjongKeyMatrix & (0x80 >> 3)) return 0xff - DrvInput[10];
1376 					if (DrvMahjongKeyMatrix & (0x80 >> 4)) return 0xff - DrvInput[11];
1377 				}
1378 
1379 				case DRV_INPUT_TYPE_BLOCK: {
1380 					return BlockDialRead(1);
1381 				}
1382 			}
1383 
1384 			return 0xff - DrvInput[2];
1385 		}
1386 
1387 		case 0x03: {
1388 			return DrvDip[0];
1389 		}
1390 
1391 		case 0x04: {
1392 			return DrvDip[1];
1393 		}
1394 
1395 		case 0x05: {
1396 			INT32 Bit = DrvHasEEPROM ? (EEPROMRead() & 0x01) << 7 : 0x80;
1397 			Bit |= 0x01;
1398 			Bit |= 0x08;
1399 			if (DrvInput5Toggle) {
1400 				//Bit |= 0x01;
1401 			} else {
1402 				Bit ^= 0x08;
1403 				Bit ^= 0x01;
1404 			}
1405 
1406 			if (DrvPort5Kludge) Bit ^= 0x08;
1407 
1408 			return ((0xff - DrvInput[3]) & 0x76) | Bit;
1409 		}
1410 
1411 		default: {
1412 			bprintf(PRINT_NORMAL, _T("Z80 #1 Port Read => %02X\n"), a);
1413 		}
1414 	}
1415 
1416 	return 0xff;
1417 }
1418 
MitchellZ80PortWrite(UINT16 a,UINT8 d)1419 static void __fastcall MitchellZ80PortWrite(UINT16 a, UINT8 d)
1420 {
1421 	a &= 0xff;
1422 
1423 	switch (a) {
1424 		case 0x00: {
1425 			DrvFlipScreen = d & 0x04;
1426 			if (DrvOkiBank != (d & 0x10)>>4) {
1427 				DrvOkiBank = (d & 0x10)>>4;
1428 
1429 				oki_bankswitch(DrvOkiBank);
1430 			}
1431 			DrvPaletteRamBank = d & 0x20;
1432 			return;
1433 		}
1434 
1435 		case 0x01: {
1436 			switch (DrvInputType) {
1437 				case DRV_INPUT_TYPE_MAHJONG: {
1438 					DrvMahjongKeyMatrix = d;
1439 					return;
1440 				}
1441 
1442 				case DRV_INPUT_TYPE_BLOCK: {
1443 					if (d == 0x08) {
1444 						DrvDial[0] = DrvDial1;
1445 						DrvDial[1] = DrvDial2;
1446 					} else {
1447 						if (d == 0x80) {
1448 							DrvDialSelected = 0;
1449 						} else {
1450 							DrvDialSelected = 1;
1451 						}
1452 					}
1453 					return;
1454 				}
1455 			}
1456 
1457 			return;
1458 		}
1459 
1460 		case 0x02: {
1461 			DrvRomBank = d & 0x0f;
1462 			ZetMapArea(0x8000, 0xbfff, 0, DrvZ80Rom + 0x10000 + (DrvRomBank * 0x4000));
1463 			if (DrvHasEEPROM) {
1464 				ZetMapArea(0x8000, 0xbfff, 2, DrvZ80Code + 0x10000 + (DrvRomBank * 0x4000), DrvZ80Rom + 0x10000 + (DrvRomBank * 0x4000));
1465 			} else {
1466 				ZetMapArea(0x8000, 0xbfff, 2, DrvZ80Rom + 0x10000 + (DrvRomBank * 0x4000));
1467 			}
1468 			return;
1469 		}
1470 
1471 		case 0x03: {
1472 			BurnYM2413Write(1, d);
1473 			return;
1474 		}
1475 
1476 		case 0x04: {
1477 			BurnYM2413Write(0, d);
1478 			return;
1479 		}
1480 
1481 		case 0x05: {
1482 			MSM6295Write(0, d);
1483 			return;
1484 		}
1485 
1486 		case 0x06:{
1487 			// nop
1488 			return;
1489 		}
1490 
1491 		case 0x07: {
1492 			DrvVideoBank = d;
1493 			return;
1494 		}
1495 
1496 		case 0x08 :{
1497 			if (DrvHasEEPROM) EEPROMSetCSLine(d ? 0 : 1);
1498 			return;
1499 		}
1500 
1501 		case 0x10 :{
1502 			if (DrvHasEEPROM) EEPROMSetClockLine(d ? 0 : 1);
1503 			return;
1504 		}
1505 
1506 		case 0x18 :{
1507 			if (DrvHasEEPROM) EEPROMWriteBit(d);
1508 			return;
1509 		}
1510 
1511 		default: {
1512 			//bprintf(PRINT_NORMAL, _T("Z80 #1 Port Write => %02X, %02X\n"), a, d);
1513 		}
1514 	}
1515 }
1516 
MstworldZ80PortRead(UINT16 a)1517 static UINT8 __fastcall MstworldZ80PortRead(UINT16 a)
1518 {
1519 	a &= 0xff;
1520 
1521 	switch (a) {
1522 		case 0x00: {
1523 			return 0xff - DrvInput[0];
1524 		}
1525 
1526 		case 0x01: {
1527 			return 0xfe - DrvInput[1];
1528 		}
1529 
1530 		case 0x02: {
1531 			return 0xfe - DrvInput[2];
1532 		}
1533 
1534 		case 0x03: {
1535 			return DrvDip[0];
1536 		}
1537 
1538 		case 0x05: {
1539 			return 0xff - DrvInput[3];
1540 		}
1541 
1542 		case 0x06: {
1543 			return 0xff;
1544 		}
1545 
1546 		default: {
1547 			bprintf(PRINT_NORMAL, _T("Z80 #1 Port Read => %02X\n"), a);
1548 		}
1549 	}
1550 
1551 	return 0xff;
1552 }
1553 
MstworldZ80PortWrite(UINT16 a,UINT8 d)1554 static void __fastcall MstworldZ80PortWrite(UINT16 a, UINT8 d)
1555 {
1556 	a &= 0xff;
1557 
1558 	switch (a) {
1559 		case 0x00: {
1560 			DrvFlipScreen = d & 0x04;
1561 			DrvPaletteRamBank = d & 0x20;
1562 			return;
1563 		}
1564 
1565 		case 0x02: {
1566 			DrvRomBank = d & 0x0f;
1567 			ZetMapArea(0x8000, 0xbfff, 0, DrvZ80Rom + 0x10000 + (DrvRomBank * 0x4000));
1568 			ZetMapArea(0x8000, 0xbfff, 2, DrvZ80Code + 0x10000 + (DrvRomBank * 0x4000), DrvZ80Rom + 0x10000 + (DrvRomBank * 0x4000));
1569 			return;
1570 		}
1571 
1572 		case 0x03: {
1573 			DrvSoundLatch = d;
1574 			ZetSetIRQLine(1, 0, CPU_IRQSTATUS_ACK);
1575 		}
1576 
1577 		case 0x06: {
1578 			// nop
1579 			return;
1580 		}
1581 
1582 		case 0x07: {
1583 			DrvVideoBank = d & 0x01;
1584 			return;
1585 		}
1586 
1587 		case 0x08:
1588 		case 0x10:
1589 		case 0x18:
1590 		case 0x27: {
1591 			// ???
1592 			return;
1593 		}
1594 
1595 		default: { // block block seems to write to random ports quite often
1596 			//bprintf(PRINT_NORMAL, _T("Z80 #1 Port Write => %02X, %02X\n"), a, d);
1597 		}
1598 	}
1599 }
1600 
MstworldSoundZ80Read(UINT16 a)1601 static UINT8 __fastcall MstworldSoundZ80Read(UINT16 a)
1602 {
1603 	switch (a) {
1604 		case 0x9800: {
1605 			return MSM6295Read(0);
1606 		}
1607 
1608 		case 0xa000: {
1609 			ZetSetIRQLine(0, CPU_IRQSTATUS_NONE);
1610 			return DrvSoundLatch;
1611 		}
1612 
1613 		default: {
1614 			bprintf(PRINT_NORMAL, _T("Z80 #2 Read => %04X\n"), a);
1615 		}
1616 	}
1617 
1618 	return 0;
1619 }
1620 
MstworldSoundZ80Write(UINT16 a,UINT8 d)1621 static void __fastcall MstworldSoundZ80Write(UINT16 a, UINT8 d)
1622 {
1623 	switch (a) {
1624 		case 0x9000: {
1625 			DrvOkiBank = d & 0x03;
1626 
1627 			oki_bankswitch(DrvOkiBank);
1628 			return;
1629 		}
1630 
1631 		case 0x9800: {
1632 			MSM6295Write(0, d);
1633 			return;
1634 		}
1635 
1636 		default: {
1637 			bprintf(PRINT_NORMAL, _T("Z80 #2 Write => %04X, %02X\n"), a, d);
1638 		}
1639 	}
1640 }
1641 
1642 // Kabuki - we use the module from the CPS-1 Q-Sound games
1643 extern void kabuki_decode(UINT8 *src, UINT8 *dest_op, UINT8 *dest_data, INT32 base_addr, INT32 length, INT32 swap_key1, INT32 swap_key2, INT32 addr_key, INT32 xor_key);
1644 
mitchell_decode(INT32 swap_key1,INT32 swap_key2,INT32 addr_key,INT32 xor_key)1645 static void mitchell_decode(INT32 swap_key1, INT32 swap_key2, INT32 addr_key, INT32 xor_key)
1646 {
1647 	UINT8 *rom = DrvZ80Rom;
1648 	UINT8 *decrypt = DrvZ80Code;
1649 	INT32 numbanks = (0x50000 - 0x10000) / 0x4000;
1650 	INT32 i;
1651 
1652 	kabuki_decode(rom, decrypt, rom, 0x0000, 0x8000, swap_key1, swap_key2, addr_key, xor_key);
1653 
1654 	rom += 0x10000;
1655 	decrypt += 0x10000;
1656 	for (i = 0; i < numbanks; i++)
1657 		kabuki_decode(rom + i * 0x4000,decrypt + i * 0x4000, rom + i * 0x4000, 0x8000, 0x4000, swap_key1, swap_key2, addr_key, xor_key);
1658 }
1659 
mgakuen2_decode()1660 static void mgakuen2_decode() { mitchell_decode(0x76543210, 0x01234567, 0xaa55, 0xa5); }
pang_decode()1661 static void pang_decode()     { mitchell_decode(0x01234567, 0x76543210, 0x6548, 0x24); }
cworld_decode()1662 static void cworld_decode()   { mitchell_decode(0x04152637, 0x40516273, 0x5751, 0x43); }
hatena_decode()1663 static void hatena_decode()   { mitchell_decode(0x45670123, 0x45670123, 0x5751, 0x43); }
spang_decode()1664 static void spang_decode()    { mitchell_decode(0x45670123, 0x45670123, 0x5852, 0x43); }
spangj_decode()1665 static void spangj_decode()   { mitchell_decode(0x45123670, 0x67012345, 0x55aa, 0x5a); }
sbbros_decode()1666 static void sbbros_decode()   { mitchell_decode(0x45670123, 0x45670123, 0x2130, 0x12); }
marukin_decode()1667 static void marukin_decode()  { mitchell_decode(0x54321076, 0x54321076, 0x4854, 0x4f); }
qtono1_decode()1668 static void qtono1_decode()   { mitchell_decode(0x12345670, 0x12345670, 0x1111, 0x11); }
qsangoku_decode()1669 static void qsangoku_decode() { mitchell_decode(0x23456701, 0x23456701, 0x1828, 0x18); }
block_decode()1670 static void block_decode()    { mitchell_decode(0x02461357, 0x64207531, 0x0002, 0x01); }
1671 
1672 static INT32 CharPlaneOffsets[4]           = { 0x400004, 0x400000, 4, 0 };
1673 static INT32 CharXOffsets[8]               = { 0, 1, 2, 3, 8, 9, 10, 11 };
1674 static INT32 CharYOffsets[8]               = { 0, 16, 32, 48, 64, 80, 96, 112 };
1675 static INT32 MahjongCharPlaneOffsets[4]    = { 12, 8, 4, 0 };
1676 static INT32 MahjongCharXOffsets[8]        = { 0, 1, 2, 3, 16, 17, 18, 19 };
1677 static INT32 MahjongCharYOffsets[8]        = { 0, 32, 64, 96, 128, 160, 192, 224 };
1678 static INT32 SpritePlaneOffsets[4]         = { 0x100004, 0x100000, 4, 0 };
1679 static INT32 SpriteXOffsets[16]            = { 0, 1, 2, 3, 8, 9, 10, 11, 256, 257, 258, 259, 264, 265, 266, 267 };
1680 static INT32 SpriteYOffsets[16]            = { 0, 16, 32, 48, 64, 80, 96, 112, 128, 144, 160, 176, 192, 208, 224, 240 };
1681 static INT32 MstworldCharPlaneOffsets[4]   = { 0x200000, 0x300000, 0, 0x100000 };
1682 static INT32 MstworldCharXOffsets[8]       = { 7, 6, 5, 4, 3, 2, 1, 0 };
1683 static INT32 MstworldCharYOffsets[8]       = { 0, 8, 16, 24, 32, 40, 48, 56 };
1684 static INT32 MstworldSpritePlaneOffsets[4] = { 4, 0, 0x100004, 0x100000 };
1685 static INT32 MstworldSpriteXOffsets[16]    = { 0, 1, 2, 3, 8, 9, 10, 11, 256, 257, 258, 259, 264, 265, 266, 267 };
1686 static INT32 MstworldSpriteYOffsets[16]    = { 0, 16, 32, 48, 64, 80, 96, 112, 128, 144, 160, 176, 192, 208, 224, 240 };
1687 
MitchellMachineInit()1688 static void MitchellMachineInit()
1689 {
1690 	ZetInit(0);
1691 	ZetOpen(0);
1692 	ZetSetReadHandler(MitchellZ80Read);
1693 	ZetSetWriteHandler(MitchellZ80Write);
1694 	ZetSetInHandler(MitchellZ80PortRead);
1695 	ZetSetOutHandler(MitchellZ80PortWrite);
1696 	ZetMapArea(0x0000, 0x7fff, 0, DrvZ80Rom  + 0x00000                     );
1697 	ZetMapArea(0x0000, 0x7fff, 2, DrvZ80Code + 0x00000, DrvZ80Rom + 0x00000);
1698 	ZetMapArea(0x8000, 0xbfff, 0, DrvZ80Rom  + 0x10000                     );
1699 	ZetMapArea(0x8000, 0xbfff, 2, DrvZ80Code + 0x10000, DrvZ80Rom + 0x10000);
1700 	ZetMapArea(0xc800, 0xcfff, 0, DrvAttrRam                               );
1701 	ZetMapArea(0xc800, 0xcfff, 1, DrvAttrRam                               );
1702 	ZetMapArea(0xc800, 0xcfff, 2, DrvAttrRam                               );
1703 	ZetMapArea(0xe000, 0xffff, 0, DrvZ80Ram                                );
1704 	ZetMapArea(0xe000, 0xffff, 1, DrvZ80Ram                                );
1705 	ZetMapArea(0xe000, 0xffff, 2, DrvZ80Ram                                );
1706 	ZetClose();
1707 
1708 	BurnYM2413Init(4000000);
1709 	BurnYM2413SetAllRoutes(1.00, BURN_SND_ROUTE_BOTH);
1710 	MSM6295Init(0, 1000000 / 132, 1);
1711 	MSM6295SetRoute(0, 0.30, BURN_SND_ROUTE_BOTH);
1712 
1713 	EEPROMInit(&MitchellEEPROMIntf);
1714 	DrvHasEEPROM = 1;
1715 
1716 	GenericTilesInit();
1717 
1718 	DrvTileMask = 0x7fff;
1719 	DrvNumColours = 0x800;
1720 	DrvInput5Toggle = 0;
1721 }
1722 
MahjongMachineInit()1723 static void MahjongMachineInit()
1724 {
1725 	ZetInit(0);
1726 	ZetOpen(0);
1727 	ZetSetReadHandler(MitchellZ80Read);
1728 	ZetSetWriteHandler(MitchellZ80Write);
1729 	ZetSetInHandler(MitchellZ80PortRead);
1730 	ZetSetOutHandler(MitchellZ80PortWrite);
1731 	ZetMapArea(0x0000, 0x7fff, 0, DrvZ80Rom  + 0x00000                     );
1732 	ZetMapArea(0x0000, 0x7fff, 2, DrvZ80Code + 0x00000, DrvZ80Rom + 0x00000);
1733 	ZetMapArea(0x8000, 0xbfff, 0, DrvZ80Rom  + 0x10000                     );
1734 	ZetMapArea(0x8000, 0xbfff, 2, DrvZ80Code + 0x10000, DrvZ80Rom + 0x10000);
1735 	ZetMapArea(0xc800, 0xcfff, 0, DrvAttrRam                               );
1736 	ZetMapArea(0xc800, 0xcfff, 1, DrvAttrRam                               );
1737 	ZetMapArea(0xc800, 0xcfff, 2, DrvAttrRam                               );
1738 	ZetMapArea(0xe000, 0xffff, 0, DrvZ80Ram                                );
1739 	ZetMapArea(0xe000, 0xffff, 1, DrvZ80Ram                                );
1740 	ZetMapArea(0xe000, 0xffff, 2, DrvZ80Ram                                );
1741 	ZetClose();
1742 
1743 	BurnYM2413Init(4000000);
1744 	BurnYM2413SetAllRoutes(1.00, BURN_SND_ROUTE_BOTH);
1745 	MSM6295Init(0, 990000 / 132, 1);
1746 	MSM6295SetRoute(0, 0.30, BURN_SND_ROUTE_BOTH);
1747 
1748 	EEPROMInit(&MitchellEEPROMIntf);
1749 	DrvHasEEPROM = 1;
1750 
1751 	GenericTilesInit();
1752 
1753 	DrvTileMask = 0xffff;
1754 	DrvNumColours = 0x800;
1755 }
1756 
MgakuenInit()1757 static INT32 MgakuenInit()
1758 {
1759 	INT32 nRet = 0, nLen;
1760 
1761 	Mem = NULL;
1762 	MgakuenMemIndex();
1763 	nLen = MemEnd - (UINT8 *)0;
1764 	if ((Mem = (UINT8 *)BurnMalloc(nLen)) == NULL) return 1;
1765 	memset(Mem, 0, nLen);
1766 	MgakuenMemIndex();
1767 
1768 	DrvTempRom = (UINT8 *)BurnMalloc(0x200000);
1769 
1770 	nRet = BurnLoadRom(DrvZ80Rom  + 0x000000,  0, 1); if (nRet != 0) return 1;
1771 	nRet = BurnLoadRom(DrvZ80Rom  + 0x010000,  1, 1); if (nRet != 0) return 1;
1772 
1773 	memset(DrvTempRom, 0xff, 0x200000);
1774 	nRet = BurnLoadRom(DrvTempRom + 0x000000,  2, 1); if (nRet != 0) return 1;
1775 	nRet = BurnLoadRom(DrvTempRom + 0x080000,  3, 1); if (nRet != 0) return 1;
1776 	nRet = BurnLoadRom(DrvTempRom + 0x100000,  4, 1); if (nRet != 0) return 1;
1777 	nRet = BurnLoadRom(DrvTempRom + 0x180000,  5, 1); if (nRet != 0) return 1;
1778 	GfxDecode(0x10000, 4, 8, 8, MahjongCharPlaneOffsets, MahjongCharXOffsets, MahjongCharYOffsets, 0x100, DrvTempRom, DrvChars);
1779 
1780 	memset(DrvTempRom, 0xff, 0x200000);
1781 	nRet = BurnLoadRom(DrvTempRom + 0x000000,  6, 1); if (nRet != 0) return 1;
1782 	nRet = BurnLoadRom(DrvTempRom + 0x020000,  7, 1); if (nRet != 0) return 1;
1783 	GfxDecode(0x00800, 4, 16, 16, SpritePlaneOffsets, SpriteXOffsets, SpriteYOffsets, 0x200, DrvTempRom, DrvSprites);
1784 
1785 	BurnFree(DrvTempRom);
1786 
1787 	nRet = BurnLoadRom(DrvSoundRom + 0x000000, 8, 1); if (nRet != 0) return 1;
1788 
1789 	ZetInit(0);
1790 	ZetOpen(0);
1791 	ZetSetInHandler(MitchellZ80PortRead);
1792 	ZetSetOutHandler(MitchellZ80PortWrite);
1793 	ZetMapArea(0x0000, 0x7fff, 0, DrvZ80Rom + 0x00000);
1794 	ZetMapArea(0x0000, 0x7fff, 2, DrvZ80Rom + 0x00000);
1795 	ZetMapArea(0x8000, 0xbfff, 0, DrvZ80Rom + 0x10000);
1796 	ZetMapArea(0x8000, 0xbfff, 2, DrvZ80Rom + 0x10000);
1797 	ZetMapArea(0xc000, 0xc7ff, 0, DrvPaletteRam      );
1798 	ZetMapArea(0xc000, 0xc7ff, 1, DrvPaletteRam      );
1799 	ZetMapArea(0xc000, 0xc7ff, 2, DrvPaletteRam      );
1800 	ZetMapArea(0xc800, 0xcfff, 0, DrvAttrRam         );
1801 	ZetMapArea(0xc800, 0xcfff, 1, DrvAttrRam         );
1802 	ZetMapArea(0xc800, 0xcfff, 2, DrvAttrRam         );
1803 	ZetMapArea(0xd000, 0xdfff, 0, DrvVideoRam        );
1804 	ZetMapArea(0xd000, 0xdfff, 1, DrvVideoRam        );
1805 	ZetMapArea(0xd000, 0xdfff, 2, DrvVideoRam        );
1806 	ZetMapArea(0xe000, 0xefff, 0, DrvZ80Ram          );
1807 	ZetMapArea(0xe000, 0xefff, 1, DrvZ80Ram          );
1808 	ZetMapArea(0xe000, 0xefff, 2, DrvZ80Ram          );
1809 	ZetMapArea(0xf000, 0xffff, 0, DrvSpriteRam       );
1810 	ZetMapArea(0xf000, 0xffff, 1, DrvSpriteRam       );
1811 	ZetMapArea(0xf000, 0xffff, 2, DrvSpriteRam       );
1812 	ZetClose();
1813 
1814 	BurnYM2413Init(4000000);
1815 	BurnYM2413SetAllRoutes(1.00, BURN_SND_ROUTE_BOTH);
1816 	MSM6295Init(0, 990000 / 132, 1);
1817 	MSM6295SetRoute(0, 0.50, BURN_SND_ROUTE_BOTH);
1818 
1819 	GenericTilesInit();
1820 
1821 	DrvTileMask = 0xffff;
1822 	DrvNumColours = 0x400;
1823 	DrvHasEEPROM = 0;
1824 	DrvPort5Kludge = 1;
1825 
1826 	DrvInputType = DRV_INPUT_TYPE_MAHJONG;
1827 
1828 	DrvDoReset();
1829 
1830 	return 0;
1831 }
1832 
Mgakuen2Init()1833 static INT32 Mgakuen2Init()
1834 {
1835 	INT32 nRet = 0, nLen;
1836 
1837 	Mem = NULL;
1838 	MahjongMemIndex();
1839 	nLen = MemEnd - (UINT8 *)0;
1840 	if ((Mem = (UINT8 *)BurnMalloc(nLen)) == NULL) return 1;
1841 	memset(Mem, 0, nLen);
1842 	MahjongMemIndex();
1843 
1844 	DrvTempRom = (UINT8 *)BurnMalloc(0x200000);
1845 
1846 	nRet = BurnLoadRom(DrvZ80Rom  + 0x000000,  0, 1); if (nRet != 0) return 1;
1847 	nRet = BurnLoadRom(DrvZ80Rom  + 0x010000,  1, 1); if (nRet != 0) return 1;
1848 	nRet = BurnLoadRom(DrvZ80Rom  + 0x030000,  2, 1); if (nRet != 0) return 1;
1849 
1850 	memset(DrvTempRom, 0xff, 0x200000);
1851 	nRet = BurnLoadRom(DrvTempRom + 0x000000,  3, 1); if (nRet != 0) return 1;
1852 	nRet = BurnLoadRom(DrvTempRom + 0x080000,  4, 1); if (nRet != 0) return 1;
1853 	nRet = BurnLoadRom(DrvTempRom + 0x100000,  5, 1); if (nRet != 0) return 1;
1854 	nRet = BurnLoadRom(DrvTempRom + 0x180000,  6, 1); if (nRet != 0) return 1;
1855 	GfxDecode(0x10000, 4, 8, 8, MahjongCharPlaneOffsets, MahjongCharXOffsets, MahjongCharYOffsets, 0x100, DrvTempRom, DrvChars);
1856 
1857 	memset(DrvTempRom, 0xff, 0x200000);
1858 	nRet = BurnLoadRom(DrvTempRom + 0x000000,  7, 1); if (nRet != 0) return 1;
1859 	nRet = BurnLoadRom(DrvTempRom + 0x020000,  8, 1); if (nRet != 0) return 1;
1860 	GfxDecode(0x00800, 4, 16, 16, SpritePlaneOffsets, SpriteXOffsets, SpriteYOffsets, 0x200, DrvTempRom, DrvSprites);
1861 
1862 	BurnFree(DrvTempRom);
1863 
1864 	nRet = BurnLoadRom(DrvSoundRom + 0x000000, 9, 1); if (nRet != 0) return 1;
1865 
1866 	mgakuen2_decode();
1867 
1868 	MahjongMachineInit();
1869 
1870 	DrvInputType = DRV_INPUT_TYPE_MAHJONG;
1871 
1872 	DrvPort5Kludge = 1;
1873 
1874 	DrvDoReset();
1875 
1876 	return 0;
1877 }
1878 
PkladiesInit()1879 static INT32 PkladiesInit()
1880 {
1881 	INT32 nRet = 0, nLen;
1882 
1883 	Mem = NULL;
1884 	MahjongMemIndex();
1885 	nLen = MemEnd - (UINT8 *)0;
1886 	if ((Mem = (UINT8 *)BurnMalloc(nLen)) == NULL) return 1;
1887 	memset(Mem, 0, nLen);
1888 	MahjongMemIndex();
1889 
1890 	DrvTempRom = (UINT8 *)BurnMalloc(0x200000);
1891 
1892 	nRet = BurnLoadRom(DrvZ80Rom  + 0x000000,  0, 1); if (nRet != 0) return 1;
1893 	nRet = BurnLoadRom(DrvZ80Rom  + 0x010000,  1, 1); if (nRet != 0) return 1;
1894 
1895 	memset(DrvTempRom, 0xff, 0x200000);
1896 	nRet = BurnLoadRom(DrvTempRom + 0x000000,  2, 2); if (nRet != 0) return 1;
1897 	nRet = BurnLoadRom(DrvTempRom + 0x000001,  3, 2); if (nRet != 0) return 1;
1898 	nRet = BurnLoadRom(DrvTempRom + 0x100000,  4, 2); if (nRet != 0) return 1;
1899 	nRet = BurnLoadRom(DrvTempRom + 0x100001,  5, 2); if (nRet != 0) return 1;
1900 	GfxDecode(0x10000, 4, 8, 8, MahjongCharPlaneOffsets, MahjongCharXOffsets, MahjongCharYOffsets, 0x100, DrvTempRom, DrvChars);
1901 
1902 	memset(DrvTempRom, 0xff, 0x200000);
1903 	nRet = BurnLoadRom(DrvTempRom + 0x000000,  6, 1); if (nRet != 0) return 1;
1904 	nRet = BurnLoadRom(DrvTempRom + 0x020000,  7, 1); if (nRet != 0) return 1;
1905 	GfxDecode(0x00800, 4, 16, 16, SpritePlaneOffsets, SpriteXOffsets, SpriteYOffsets, 0x200, DrvTempRom, DrvSprites);
1906 
1907 	BurnFree(DrvTempRom);
1908 
1909 	nRet = BurnLoadRom(DrvSoundRom + 0x000000, 8, 1); if (nRet != 0) return 1;
1910 	nRet = BurnLoadRom(DrvSoundRom + 0x020000, 9, 1); if (nRet != 0) return 1;
1911 
1912 	mgakuen2_decode();
1913 
1914 	MahjongMachineInit();
1915 
1916 	DrvInputType = DRV_INPUT_TYPE_MAHJONG;
1917 
1918 	DrvDoReset();
1919 
1920 	return 0;
1921 }
1922 
DokabenInit()1923 static INT32 DokabenInit()
1924 {
1925 	INT32 nRet = 0, nLen;
1926 
1927 	Mem = NULL;
1928 	PangMemIndex();
1929 	nLen = MemEnd - (UINT8 *)0;
1930 	if ((Mem = (UINT8 *)BurnMalloc(nLen)) == NULL) return 1;
1931 	memset(Mem, 0, nLen);
1932 	PangMemIndex();
1933 
1934 	DrvTempRom = (UINT8 *)BurnMalloc(0x100000);
1935 
1936 	nRet = BurnLoadRom(DrvZ80Rom  + 0x00000,  0, 1); if (nRet != 0) return 1;
1937 	nRet = BurnLoadRom(DrvZ80Rom  + 0x10000,  1, 1); if (nRet != 0) return 1;
1938 	nRet = BurnLoadRom(DrvZ80Rom  + 0x30000,  2, 1); if (nRet != 0) return 1;
1939 
1940 	memset(DrvTempRom, 0xff, 0x100000);
1941 	nRet = BurnLoadRom(DrvTempRom + 0x00000,  3, 1); if (nRet != 0) return 1;
1942 	nRet = BurnLoadRom(DrvTempRom + 0x20000,  4, 1); if (nRet != 0) return 1;
1943 	nRet = BurnLoadRom(DrvTempRom + 0x80000,  5, 1); if (nRet != 0) return 1;
1944 	nRet = BurnLoadRom(DrvTempRom + 0xa0000,  6, 1); if (nRet != 0) return 1;
1945 	GfxDecode(0x8000, 4, 8, 8, CharPlaneOffsets, CharXOffsets, CharYOffsets, 0x80, DrvTempRom, DrvChars);
1946 
1947 	memset(DrvTempRom, 0xff, 0x100000);
1948 	nRet = BurnLoadRom(DrvTempRom + 0x00000,  7, 1); if (nRet != 0) return 1;
1949 	nRet = BurnLoadRom(DrvTempRom + 0x20000,  8, 1); if (nRet != 0) return 1;
1950 	GfxDecode(0x0800, 4, 16, 16, SpritePlaneOffsets, SpriteXOffsets, SpriteYOffsets, 0x200, DrvTempRom, DrvSprites);
1951 
1952 	BurnFree(DrvTempRom);
1953 
1954 	nRet = BurnLoadRom(DrvSoundRom + 0x00000,  9, 1); if (nRet != 0) return 1;
1955 
1956 	mgakuen2_decode();
1957 
1958 	MitchellMachineInit();
1959 
1960 	DrvDoReset();
1961 
1962 	return 0;
1963 }
1964 
PangInit()1965 static INT32 PangInit()
1966 {
1967 	INT32 nRet = 0, nLen;
1968 	BurnSetRefreshRate(57);
1969 	Mem = NULL;
1970 	PangMemIndex();
1971 	nLen = MemEnd - (UINT8 *)0;
1972 	if ((Mem = (UINT8 *)BurnMalloc(nLen)) == NULL) return 1;
1973 	memset(Mem, 0, nLen);
1974 	PangMemIndex();
1975 
1976 	DrvTempRom = (UINT8 *)BurnMalloc(0x100000);
1977 
1978 	nRet = BurnLoadRom(DrvZ80Rom  + 0x00000,  0, 1); if (nRet != 0) return 1;
1979 	nRet = BurnLoadRom(DrvZ80Rom  + 0x10000,  1, 1); if (nRet != 0) return 1;
1980 
1981 	memset(DrvTempRom, 0xff, 0x100000);
1982 	nRet = BurnLoadRom(DrvTempRom + 0x00000,  2, 1); if (nRet != 0) return 1;
1983 	nRet = BurnLoadRom(DrvTempRom + 0x20000,  3, 1); if (nRet != 0) return 1;
1984 	nRet = BurnLoadRom(DrvTempRom + 0x80000,  4, 1); if (nRet != 0) return 1;
1985 	nRet = BurnLoadRom(DrvTempRom + 0xa0000,  5, 1); if (nRet != 0) return 1;
1986 	GfxDecode(0x8000, 4, 8, 8, CharPlaneOffsets, CharXOffsets, CharYOffsets, 0x80, DrvTempRom, DrvChars);
1987 
1988 	memset(DrvTempRom, 0xff, 0x100000);
1989 	nRet = BurnLoadRom(DrvTempRom + 0x00000,  6, 1); if (nRet != 0) return 1;
1990 	nRet = BurnLoadRom(DrvTempRom + 0x20000,  7, 1); if (nRet != 0) return 1;
1991 	GfxDecode(0x0800, 4, 16, 16, SpritePlaneOffsets, SpriteXOffsets, SpriteYOffsets, 0x200, DrvTempRom, DrvSprites);
1992 
1993 	BurnFree(DrvTempRom);
1994 
1995 	nRet = BurnLoadRom(DrvSoundRom + 0x00000,  8, 1); if (nRet != 0) return 1;
1996 
1997 	pang_decode();
1998 
1999 	MitchellMachineInit();
2000 
2001 	DrvDoReset();
2002 
2003 	return 0;
2004 }
2005 
PangbInit()2006 static INT32 PangbInit()
2007 {
2008 	INT32 nRet = 0, nLen;
2009 
2010 	Mem = NULL;
2011 	PangMemIndex();
2012 	nLen = MemEnd - (UINT8 *)0;
2013 	if ((Mem = (UINT8 *)BurnMalloc(nLen)) == NULL) return 1;
2014 	memset(Mem, 0, nLen);
2015 	PangMemIndex();
2016 
2017 	DrvTempRom = (UINT8 *)BurnMalloc(0x100000);
2018 
2019 	nRet = BurnLoadRom(DrvZ80Code + 0x00000,  0, 1); if (nRet != 0) return 1;
2020 	nRet = BurnLoadRom(DrvZ80Code + 0x10000,  1, 1); if (nRet != 0) return 1;
2021 	nRet = BurnLoadRom(DrvZ80Rom  + 0x10000,  2, 1); if (nRet != 0) return 1;
2022 	memcpy(DrvZ80Rom + 0x0000, DrvZ80Code + 0x8000, 0x8000);
2023 	memset(DrvZ80Code + 0x8000, 0, 0x8000);
2024 
2025 	memset(DrvTempRom, 0xff, 0x100000);
2026 	nRet = BurnLoadRom(DrvTempRom + 0x00000,  3, 1); if (nRet != 0) return 1;
2027 	nRet = BurnLoadRom(DrvTempRom + 0x20000,  4, 1); if (nRet != 0) return 1;
2028 	nRet = BurnLoadRom(DrvTempRom + 0x80000,  5, 1); if (nRet != 0) return 1;
2029 	nRet = BurnLoadRom(DrvTempRom + 0xa0000,  6, 1); if (nRet != 0) return 1;
2030 	GfxDecode(0x8000, 4, 8, 8, CharPlaneOffsets, CharXOffsets, CharYOffsets, 0x80, DrvTempRom, DrvChars);
2031 
2032 	memset(DrvTempRom, 0xff, 0x100000);
2033 	nRet = BurnLoadRom(DrvTempRom + 0x00000,  7, 1); if (nRet != 0) return 1;
2034 	nRet = BurnLoadRom(DrvTempRom + 0x20000,  8, 1); if (nRet != 0) return 1;
2035 	GfxDecode(0x0800, 4, 16, 16, SpritePlaneOffsets, SpriteXOffsets, SpriteYOffsets, 0x200, DrvTempRom, DrvSprites);
2036 
2037 	BurnFree(DrvTempRom);
2038 
2039 	nRet = BurnLoadRom(DrvSoundRom + 0x00000,  9, 1); if (nRet != 0) return 1;
2040 
2041 	MitchellMachineInit();
2042 
2043 	DrvDoReset();
2044 
2045 	return 0;
2046 }
2047 
PangboldInit()2048 static INT32 PangboldInit()
2049 {
2050 	INT32 nRet = 0, nLen;
2051 
2052 	Mem = NULL;
2053 	PangMemIndex();
2054 	nLen = MemEnd - (UINT8 *)0;
2055 	if ((Mem = (UINT8 *)BurnMalloc(nLen)) == NULL) return 1;
2056 	memset(Mem, 0, nLen);
2057 	PangMemIndex();
2058 
2059 	DrvTempRom = (UINT8 *)BurnMalloc(0x100000);
2060 
2061 	nRet = BurnLoadRom(DrvZ80Code + 0x00000,  0, 1); if (nRet != 0) return 1;
2062 	nRet = BurnLoadRom(DrvZ80Code + 0x10000,  1, 1); if (nRet != 0) return 1;
2063 	nRet = BurnLoadRom(DrvZ80Rom  + 0x10000,  2, 1); if (nRet != 0) return 1;
2064 	memcpy(DrvZ80Rom + 0x0000, DrvZ80Code + 0x8000, 0x8000);
2065 	memset(DrvZ80Code + 0x8000, 0, 0x8000);
2066 
2067 	memset(DrvTempRom, 0xff, 0x100000);
2068 	nRet = BurnLoadRom(DrvTempRom + 0x00000,  3, 1); if (nRet != 0) return 1;
2069 	nRet = BurnLoadRom(DrvTempRom + 0x20000,  4, 1); if (nRet != 0) return 1;
2070 	nRet = BurnLoadRom(DrvTempRom + 0x80000,  5, 1); if (nRet != 0) return 1;
2071 	nRet = BurnLoadRom(DrvTempRom + 0xa0000,  6, 1); if (nRet != 0) return 1;
2072 	GfxDecode(0x8000, 4, 8, 8, CharPlaneOffsets, CharXOffsets, CharYOffsets, 0x80, DrvTempRom, DrvChars);
2073 
2074 	memset(DrvTempRom, 0xff, 0x100000);
2075 	nRet = BurnLoadRom(DrvTempRom + 0x00000,  7, 1); if (nRet != 0) return 1;
2076 	nRet = BurnLoadRom(DrvTempRom + 0x10000,  8, 1); if (nRet != 0) return 1;
2077 	nRet = BurnLoadRom(DrvTempRom + 0x20000,  9, 1); if (nRet != 0) return 1;
2078 	nRet = BurnLoadRom(DrvTempRom + 0x30000, 10, 1); if (nRet != 0) return 1;
2079 	GfxDecode(0x0800, 4, 16, 16, SpritePlaneOffsets, SpriteXOffsets, SpriteYOffsets, 0x200, DrvTempRom, DrvSprites);
2080 
2081 	BurnFree(DrvTempRom);
2082 
2083 	nRet = BurnLoadRom(DrvSoundRom + 0x00000, 11, 1); if (nRet != 0) return 1;
2084 
2085 	MitchellMachineInit();
2086 
2087 	DrvDoReset();
2088 
2089 	return 0;
2090 }
2091 
Pangb2Init()2092 static INT32 Pangb2Init()
2093 {
2094 	INT32 nRet = 0, nLen;
2095 
2096 	Mem = NULL;
2097 	PangMemIndex();
2098 	nLen = MemEnd - (UINT8 *)0;
2099 	if ((Mem = (UINT8 *)BurnMalloc(nLen)) == NULL) return 1;
2100 	memset(Mem, 0, nLen);
2101 	PangMemIndex();
2102 
2103 	DrvTempRom = (UINT8 *)BurnMalloc(0x100000);
2104 
2105 	nRet = BurnLoadRom(DrvZ80Code + 0x00000,  0, 1); if (nRet != 0) return 1;
2106 	nRet = BurnLoadRom(DrvZ80Code + 0x10000,  1, 1); if (nRet != 0) return 1;
2107 	memcpy(DrvZ80Rom + 0x00000, DrvZ80Code + 0x08000, 0x08000);
2108 	memcpy(DrvZ80Rom + 0x10000, DrvZ80Code + 0x30000, 0x20000);
2109 	memset(DrvZ80Code + 0x8000, 0, 0x8000);
2110 
2111 	memset(DrvTempRom, 0xff, 0x100000);
2112 	nRet = BurnLoadRom(DrvTempRom + 0x00000,  2, 1); if (nRet != 0) return 1;
2113 	nRet = BurnLoadRom(DrvTempRom + 0x20000,  3, 1); if (nRet != 0) return 1;
2114 	nRet = BurnLoadRom(DrvTempRom + 0x80000,  4, 1); if (nRet != 0) return 1;
2115 	nRet = BurnLoadRom(DrvTempRom + 0xa0000,  5, 1); if (nRet != 0) return 1;
2116 	GfxDecode(0x8000, 4, 8, 8, CharPlaneOffsets, CharXOffsets, CharYOffsets, 0x80, DrvTempRom, DrvChars);
2117 
2118 	memset(DrvTempRom, 0xff, 0x100000);
2119 	nRet = BurnLoadRom(DrvTempRom + 0x00000,  6, 1); if (nRet != 0) return 1;
2120 	nRet = BurnLoadRom(DrvTempRom + 0x20000,  7, 1); if (nRet != 0) return 1;
2121 	GfxDecode(0x0800, 4, 16, 16, SpritePlaneOffsets, SpriteXOffsets, SpriteYOffsets, 0x200, DrvTempRom, DrvSprites);
2122 
2123 	BurnFree(DrvTempRom);
2124 
2125 	nRet = BurnLoadRom(DrvSoundRom + 0x00000,  8, 1); if (nRet != 0) return 1;
2126 
2127 	MitchellMachineInit();
2128 
2129 	DrvDoReset();
2130 
2131 	return 0;
2132 }
2133 
CworldInit()2134 static INT32 CworldInit()
2135 {
2136 	INT32 nRet = 0, nLen;
2137 
2138 	Mem = NULL;
2139 	PangMemIndex();
2140 	nLen = MemEnd - (UINT8 *)0;
2141 	if ((Mem = (UINT8 *)BurnMalloc(nLen)) == NULL) return 1;
2142 	memset(Mem, 0, nLen);
2143 	PangMemIndex();
2144 
2145 	DrvTempRom = (UINT8 *)BurnMalloc(0x100000);
2146 
2147 	nRet = BurnLoadRom(DrvZ80Rom  + 0x00000,  0, 1); if (nRet != 0) return 1;
2148 	nRet = BurnLoadRom(DrvZ80Rom  + 0x10000,  1, 1); if (nRet != 0) return 1;
2149 	nRet = BurnLoadRom(DrvZ80Rom  + 0x30000,  2, 1); if (nRet != 0) return 1;
2150 
2151 	memset(DrvTempRom, 0xff, 0x100000);
2152 	nRet = BurnLoadRom(DrvTempRom + 0x00000,  3, 1); if (nRet != 0) return 1;
2153 	nRet = BurnLoadRom(DrvTempRom + 0x20000,  4, 1); if (nRet != 0) return 1;
2154 	nRet = BurnLoadRom(DrvTempRom + 0x40000,  5, 1); if (nRet != 0) return 1;
2155 	nRet = BurnLoadRom(DrvTempRom + 0x60000,  6, 1); if (nRet != 0) return 1;
2156 	nRet = BurnLoadRom(DrvTempRom + 0x80000,  7, 1); if (nRet != 0) return 1;
2157 	nRet = BurnLoadRom(DrvTempRom + 0xa0000,  8, 1); if (nRet != 0) return 1;
2158 	nRet = BurnLoadRom(DrvTempRom + 0xc0000,  9, 1); if (nRet != 0) return 1;
2159 	nRet = BurnLoadRom(DrvTempRom + 0xe0000, 10, 1); if (nRet != 0) return 1;
2160 	GfxDecode(0x8000, 4, 8, 8, CharPlaneOffsets, CharXOffsets, CharYOffsets, 0x80, DrvTempRom, DrvChars);
2161 
2162 	memset(DrvTempRom, 0xff, 0x100000);
2163 	nRet = BurnLoadRom(DrvTempRom + 0x00000, 11, 1); if (nRet != 0) return 1;
2164 	nRet = BurnLoadRom(DrvTempRom + 0x20000, 12, 1); if (nRet != 0) return 1;
2165 	GfxDecode(0x0800, 4, 16, 16, SpritePlaneOffsets, SpriteXOffsets, SpriteYOffsets, 0x200, DrvTempRom, DrvSprites);
2166 
2167 	BurnFree(DrvTempRom);
2168 
2169 	nRet = BurnLoadRom(DrvSoundRom + 0x00000, 13, 1); if (nRet != 0) return 1;
2170 
2171 	cworld_decode();
2172 
2173 	MitchellMachineInit();
2174 
2175 	DrvDoReset();
2176 
2177 	return 0;
2178 }
2179 
HatenaInit()2180 static INT32 HatenaInit()
2181 {
2182 	INT32 nRet = 0, nLen;
2183 
2184 	Mem = NULL;
2185 	PangMemIndex();
2186 	nLen = MemEnd - (UINT8 *)0;
2187 	if ((Mem = (UINT8 *)BurnMalloc(nLen)) == NULL) return 1;
2188 	memset(Mem, 0, nLen);
2189 	PangMemIndex();
2190 
2191 	DrvTempRom = (UINT8 *)BurnMalloc(0x100000);
2192 
2193 	nRet = BurnLoadRom(DrvZ80Rom  + 0x00000,  0, 1); if (nRet != 0) return 1;
2194 	nRet = BurnLoadRom(DrvZ80Rom  + 0x10000,  1, 1); if (nRet != 0) return 1;
2195 	nRet = BurnLoadRom(DrvZ80Rom  + 0x30000,  2, 1); if (nRet != 0) return 1;
2196 
2197 	memset(DrvTempRom, 0xff, 0x100000);
2198 	nRet = BurnLoadRom(DrvTempRom + 0x00000,  3, 1); if (nRet != 0) return 1;
2199 	nRet = BurnLoadRom(DrvTempRom + 0x20000,  4, 1); if (nRet != 0) return 1;
2200 	nRet = BurnLoadRom(DrvTempRom + 0x40000,  5, 1); if (nRet != 0) return 1;
2201 	nRet = BurnLoadRom(DrvTempRom + 0x60000,  6, 1); if (nRet != 0) return 1;
2202 	nRet = BurnLoadRom(DrvTempRom + 0x80000,  7, 1); if (nRet != 0) return 1;
2203 	nRet = BurnLoadRom(DrvTempRom + 0xa0000,  8, 1); if (nRet != 0) return 1;
2204 	nRet = BurnLoadRom(DrvTempRom + 0xc0000,  9, 1); if (nRet != 0) return 1;
2205 	nRet = BurnLoadRom(DrvTempRom + 0xe0000, 10, 1); if (nRet != 0) return 1;
2206 	GfxDecode(0x8000, 4, 8, 8, CharPlaneOffsets, CharXOffsets, CharYOffsets, 0x80, DrvTempRom, DrvChars);
2207 
2208 	memset(DrvTempRom, 0xff, 0x100000);
2209 	nRet = BurnLoadRom(DrvTempRom + 0x00000, 11, 1); if (nRet != 0) return 1;
2210 	nRet = BurnLoadRom(DrvTempRom + 0x20000, 12, 1); if (nRet != 0) return 1;
2211 	GfxDecode(0x0800, 4, 16, 16, SpritePlaneOffsets, SpriteXOffsets, SpriteYOffsets, 0x200, DrvTempRom, DrvSprites);
2212 
2213 	BurnFree(DrvTempRom);
2214 
2215 	nRet = BurnLoadRom(DrvSoundRom + 0x00000, 13, 1); if (nRet != 0) return 1;
2216 
2217 	hatena_decode();
2218 
2219 	MitchellMachineInit();
2220 
2221 	DrvDoReset();
2222 
2223 	return 0;
2224 }
2225 
SpangInit()2226 static INT32 SpangInit()
2227 {
2228 	INT32 nRet = 0, nLen;
2229 
2230 	Mem = NULL;
2231 	PangMemIndex();
2232 	nLen = MemEnd - (UINT8 *)0;
2233 	if ((Mem = (UINT8 *)BurnMalloc(nLen)) == NULL) return 1;
2234 	memset(Mem, 0, nLen);
2235 	PangMemIndex();
2236 
2237 	DrvTempRom = (UINT8 *)BurnMalloc(0x100000);
2238 
2239 	nRet = BurnLoadRom(DrvZ80Rom  + 0x00000,  0, 1); if (nRet != 0) return 1;
2240 	nRet = BurnLoadRom(DrvZ80Rom  + 0x10000,  1, 1); if (nRet != 0) return 1;
2241 	nRet = BurnLoadRom(DrvZ80Rom  + 0x30000,  2, 1); if (nRet != 0) return 1;
2242 
2243 	memset(DrvTempRom, 0xff, 0x100000);
2244 	nRet = BurnLoadRom(DrvTempRom + 0x00000,  3, 1); if (nRet != 0) return 1;
2245 	nRet = BurnLoadRom(DrvTempRom + 0x20000,  4, 1); if (nRet != 0) return 1;
2246 	nRet = BurnLoadRom(DrvTempRom + 0x80000,  5, 1); if (nRet != 0) return 1;
2247 	nRet = BurnLoadRom(DrvTempRom + 0xa0000,  6, 1); if (nRet != 0) return 1;
2248 	GfxDecode(0x8000, 4, 8, 8, CharPlaneOffsets, CharXOffsets, CharYOffsets, 0x80, DrvTempRom, DrvChars);
2249 
2250 	memset(DrvTempRom, 0xff, 0x100000);
2251 	nRet = BurnLoadRom(DrvTempRom + 0x00000,  7, 1); if (nRet != 0) return 1;
2252 	nRet = BurnLoadRom(DrvTempRom + 0x20000,  8, 1); if (nRet != 0) return 1;
2253 	GfxDecode(0x0800, 4, 16, 16, SpritePlaneOffsets, SpriteXOffsets, SpriteYOffsets, 0x200, DrvTempRom, DrvSprites);
2254 
2255 	nRet = BurnLoadRom(DrvSoundRom + 0x00000,  9, 1); if (nRet != 0) return 1;
2256 
2257 	nRet = BurnLoadRom(DrvTempRom + 0x00000, 10, 1); if (nRet != 0) return 1;
2258 
2259 	spang_decode();
2260 
2261 	MitchellMachineInit();
2262 
2263 	if (!EEPROMAvailable()) EEPROMFill(DrvTempRom, 0, 128);
2264 
2265 	BurnFree(DrvTempRom);
2266 
2267 	DrvNVRamSize = 0x0080;
2268 	DrvNVRamAddress = 0x0000;
2269 
2270 	DrvDoReset();
2271 
2272 	return 0;
2273 }
2274 
SpangjInit()2275 static INT32 SpangjInit()
2276 {
2277 	INT32 nRet = 0, nLen;
2278 
2279 	Mem = NULL;
2280 	PangMemIndex();
2281 	nLen = MemEnd - (UINT8 *)0;
2282 	if ((Mem = (UINT8 *)BurnMalloc(nLen)) == NULL) return 1;
2283 	memset(Mem, 0, nLen);
2284 	PangMemIndex();
2285 
2286 	DrvTempRom = (UINT8 *)BurnMalloc(0x100000);
2287 
2288 	nRet = BurnLoadRom(DrvZ80Rom  + 0x00000,  0, 1); if (nRet != 0) return 1;
2289 	nRet = BurnLoadRom(DrvZ80Rom  + 0x10000,  1, 1); if (nRet != 0) return 1;
2290 	nRet = BurnLoadRom(DrvZ80Rom  + 0x30000,  2, 1); if (nRet != 0) return 1;
2291 
2292 	memset(DrvTempRom, 0xff, 0x100000);
2293 	nRet = BurnLoadRom(DrvTempRom + 0x00000,  3, 1); if (nRet != 0) return 1;
2294 	nRet = BurnLoadRom(DrvTempRom + 0x20000,  4, 1); if (nRet != 0) return 1;
2295 	nRet = BurnLoadRom(DrvTempRom + 0x80000,  5, 1); if (nRet != 0) return 1;
2296 	nRet = BurnLoadRom(DrvTempRom + 0xa0000,  6, 1); if (nRet != 0) return 1;
2297 	GfxDecode(0x8000, 4, 8, 8, CharPlaneOffsets, CharXOffsets, CharYOffsets, 0x80, DrvTempRom, DrvChars);
2298 
2299 	memset(DrvTempRom, 0xff, 0x100000);
2300 	nRet = BurnLoadRom(DrvTempRom + 0x00000,  7, 1); if (nRet != 0) return 1;
2301 	nRet = BurnLoadRom(DrvTempRom + 0x20000,  8, 1); if (nRet != 0) return 1;
2302 	GfxDecode(0x0800, 4, 16, 16, SpritePlaneOffsets, SpriteXOffsets, SpriteYOffsets, 0x200, DrvTempRom, DrvSprites);
2303 
2304 	nRet = BurnLoadRom(DrvSoundRom + 0x00000,  9, 1); if (nRet != 0) return 1;
2305 
2306 	nRet = BurnLoadRom(DrvTempRom + 0x00000, 10, 1); if (nRet != 0) return 1;
2307 
2308 	spangj_decode();
2309 
2310 	MitchellMachineInit();
2311 
2312 	if (!EEPROMAvailable()) EEPROMFill(DrvTempRom, 0, 128);
2313 
2314 	BurnFree(DrvTempRom);
2315 
2316 	DrvNVRamSize = 0x0080;
2317 	DrvNVRamAddress = 0x0000;
2318 
2319 	DrvDoReset();
2320 
2321 	return 0;
2322 }
2323 
SbbrosInit()2324 static INT32 SbbrosInit()
2325 {
2326 	INT32 nRet = 0, nLen;
2327 
2328 	Mem = NULL;
2329 	PangMemIndex();
2330 	nLen = MemEnd - (UINT8 *)0;
2331 	if ((Mem = (UINT8 *)BurnMalloc(nLen)) == NULL) return 1;
2332 	memset(Mem, 0, nLen);
2333 	PangMemIndex();
2334 
2335 	DrvTempRom = (UINT8 *)BurnMalloc(0x100000);
2336 
2337 	nRet = BurnLoadRom(DrvZ80Rom  + 0x00000,  0, 1); if (nRet != 0) return 1;
2338 	nRet = BurnLoadRom(DrvZ80Rom  + 0x10000,  1, 1); if (nRet != 0) return 1;
2339 	nRet = BurnLoadRom(DrvZ80Rom  + 0x30000,  2, 1); if (nRet != 0) return 1;
2340 
2341 	memset(DrvTempRom, 0xff, 0x100000);
2342 	nRet = BurnLoadRom(DrvTempRom + 0x00000,  3, 1); if (nRet != 0) return 1;
2343 	nRet = BurnLoadRom(DrvTempRom + 0x20000,  4, 1); if (nRet != 0) return 1;
2344 	nRet = BurnLoadRom(DrvTempRom + 0x80000,  5, 1); if (nRet != 0) return 1;
2345 	nRet = BurnLoadRom(DrvTempRom + 0xa0000,  6, 1); if (nRet != 0) return 1;
2346 	GfxDecode(0x8000, 4, 8, 8, CharPlaneOffsets, CharXOffsets, CharYOffsets, 0x80, DrvTempRom, DrvChars);
2347 
2348 	memset(DrvTempRom, 0xff, 0x100000);
2349 	nRet = BurnLoadRom(DrvTempRom + 0x00000,  7, 1); if (nRet != 0) return 1;
2350 	nRet = BurnLoadRom(DrvTempRom + 0x20000,  8, 1); if (nRet != 0) return 1;
2351 	GfxDecode(0x0800, 4, 16, 16, SpritePlaneOffsets, SpriteXOffsets, SpriteYOffsets, 0x200, DrvTempRom, DrvSprites);
2352 
2353 	nRet = BurnLoadRom(DrvSoundRom + 0x00000,  9, 1); if (nRet != 0) return 1;
2354 
2355 	nRet = BurnLoadRom(DrvTempRom + 0x00000, 10, 1); if (nRet != 0) return 1;
2356 
2357 	sbbros_decode();
2358 
2359 	MitchellMachineInit();
2360 
2361 	if (!EEPROMAvailable()) EEPROMFill(DrvTempRom, 0, 128);
2362 
2363 	BurnFree(DrvTempRom);
2364 
2365 	DrvNVRamSize = 0x0080;
2366 	DrvNVRamAddress = 0x0000;
2367 
2368 	DrvDoReset();
2369 
2370 	return 0;
2371 }
2372 
MstworldInit()2373 static INT32 MstworldInit()
2374 {
2375 	INT32 nRet = 0, nLen;
2376 
2377 	Mem = NULL;
2378 	MstworldMemIndex();
2379 	nLen = MemEnd - (UINT8 *)0;
2380 	if ((Mem = (UINT8 *)BurnMalloc(nLen)) == NULL) return 1;
2381 	memset(Mem, 0, nLen);
2382 	MstworldMemIndex();
2383 
2384 	DrvTempRom = (UINT8 *)BurnMalloc(0x80000);
2385 
2386 	nRet = BurnLoadRom(DrvZ80Rom  + 0x00000,  0, 1); if (nRet != 0) return 1;
2387 
2388 	nRet = BurnLoadRom(DrvZ80Rom2 + 0x00000,  1, 1); if (nRet != 0) return 1;
2389 
2390 	memset(DrvTempRom, 0x00, 0x80000);
2391 	nRet = BurnLoadRom(DrvTempRom + 0x00000,  2, 1); if (nRet != 0) return 1;
2392 	nRet = BurnLoadRom(DrvTempRom + 0x20000,  3, 1); if (nRet != 0) return 1;
2393 	nRet = BurnLoadRom(DrvTempRom + 0x40000,  4, 1); if (nRet != 0) return 1;
2394 	nRet = BurnLoadRom(DrvTempRom + 0x60000,  5, 1); if (nRet != 0) return 1;
2395 	for (INT32 i = 0; i < 0x80000; i++) DrvTempRom[i] ^= 0xff;
2396 	GfxDecode(0x4000, 4, 8, 8, MstworldCharPlaneOffsets, MstworldCharXOffsets, MstworldCharYOffsets, 0x40, DrvTempRom, DrvChars);
2397 
2398 	memset(DrvTempRom, 0x00, 0x80000);
2399 	nRet = BurnLoadRom(DrvTempRom + 0x00000,  6, 1); if (nRet != 0) return 1;
2400 	nRet = BurnLoadRom(DrvTempRom + 0x20000,  7, 1); if (nRet != 0) return 1;
2401 	for (INT32 i = 0; i < 0x40000; i++) DrvTempRom[i] ^= 0xff;
2402 	GfxDecode(0x0800, 4, 16, 16, MstworldSpritePlaneOffsets, MstworldSpriteXOffsets, MstworldSpriteYOffsets, 0x200, DrvTempRom, DrvSprites);
2403 
2404 	nRet = BurnLoadRom(DrvTempRom + 0x00000,  8, 1); if (nRet != 0) return 1;
2405 	memcpy(DrvSoundRom + 0x000000, DrvTempRom + 0x000000, 0x20000);
2406 	memcpy(DrvSoundRom + 0x020000, DrvTempRom + 0x000000, 0x20000);
2407 	memcpy(DrvSoundRom + 0x040000, DrvTempRom + 0x000000, 0x20000);
2408 	memcpy(DrvSoundRom + 0x060000, DrvTempRom + 0x020000, 0x20000);
2409 	memcpy(DrvSoundRom + 0x080000, DrvTempRom + 0x000000, 0x20000);
2410 	memcpy(DrvSoundRom + 0x0a0000, DrvTempRom + 0x040000, 0x20000);
2411 	memcpy(DrvSoundRom + 0x0c0000, DrvTempRom + 0x000000, 0x20000);
2412 	memcpy(DrvSoundRom + 0x0e0000, DrvTempRom + 0x060000, 0x20000);
2413 
2414 	static const INT32 tablebank[] = {
2415 		0,  0,
2416 		1,  1,
2417 		-1, -1,
2418 		-1, -1,
2419 		10,  4,
2420 		5, 13,
2421 		7, 17,
2422 		21,  2,
2423 		18,  9,
2424 		15,  3,
2425 		6, 11,
2426 		19,  8,
2427 		-1, -1,
2428 		-1, -1,
2429 		-1, -1,
2430 		-1, -1,
2431 		20, 20,
2432 		14, 14,
2433 		16, 16,
2434 		12, 12,
2435 	};
2436 
2437 	memcpy(DrvTempRom, DrvZ80Rom, 0x80000);
2438 	for (INT32 x = 0; x < 40; x += 2) {
2439 		if (tablebank[x] != -1) {
2440 			memcpy(&DrvZ80Rom[(x / 2) * 0x4000], &DrvTempRom[tablebank[x] * 0x4000], 0x4000);
2441 			memcpy(&DrvZ80Code[(x / 2) * 0x4000], &DrvTempRom[tablebank[x + 1] * 0x4000], 0x4000);
2442 		}
2443 	}
2444 
2445 	BurnFree(DrvTempRom);
2446 
2447 	ZetInit(0);
2448 	ZetOpen(0);
2449 	ZetSetReadHandler(MitchellZ80Read);
2450 	ZetSetWriteHandler(MitchellZ80Write);
2451 	ZetSetInHandler(MstworldZ80PortRead);
2452 	ZetSetOutHandler(MstworldZ80PortWrite);
2453 	ZetMapArea(0x0000, 0x7fff, 0, DrvZ80Rom  + 0x00000                     );
2454 	ZetMapArea(0x0000, 0x7fff, 2, DrvZ80Code + 0x00000, DrvZ80Rom + 0x00000);
2455 	ZetMapArea(0x8000, 0xbfff, 0, DrvZ80Rom  + 0x10000                     );
2456 	ZetMapArea(0x8000, 0xbfff, 2, DrvZ80Code + 0x10000, DrvZ80Rom + 0x10000);
2457 	ZetMapArea(0xc800, 0xcfff, 0, DrvAttrRam                               );
2458 	ZetMapArea(0xc800, 0xcfff, 1, DrvAttrRam                               );
2459 	ZetMapArea(0xc800, 0xcfff, 2, DrvAttrRam                               );
2460 	ZetMapArea(0xe000, 0xffff, 0, DrvZ80Ram                                );
2461 	ZetMapArea(0xe000, 0xffff, 1, DrvZ80Ram                                );
2462 	ZetMapArea(0xe000, 0xffff, 2, DrvZ80Ram                                );
2463 	ZetClose();
2464 
2465 	ZetInit(1);
2466 	ZetOpen(1);
2467 	ZetSetReadHandler(MstworldSoundZ80Read);
2468 	ZetSetWriteHandler(MstworldSoundZ80Write);
2469 	ZetMapArea(0x0000, 0x7fff, 0, DrvZ80Rom2);
2470 	ZetMapArea(0x0000, 0x7fff, 2, DrvZ80Rom2);
2471 	ZetMapArea(0x8000, 0x87ff, 0, DrvZ80Ram2);
2472 	ZetMapArea(0x8000, 0x87ff, 1, DrvZ80Ram2);
2473 	ZetMapArea(0x8000, 0x87ff, 2, DrvZ80Ram2);
2474 	ZetClose();
2475 
2476 	MSM6295Init(0, 990000 / 132, 0);
2477 	MSM6295SetRoute(0, 0.50, BURN_SND_ROUTE_BOTH);
2478 
2479 	DrvHasEEPROM = 0;
2480 
2481 	GenericTilesInit();
2482 
2483 	DrvTileMask = 0x3fff;
2484 	DrvNumColours = 0x800;
2485 
2486 	MstworldDoReset();
2487 
2488 	return 0;
2489 }
2490 
MarukinInit()2491 static INT32 MarukinInit()
2492 {
2493 	INT32 nRet = 0, nLen;
2494 
2495 	Mem = NULL;
2496 	MahjongMemIndex();
2497 	nLen = MemEnd - (UINT8 *)0;
2498 	if ((Mem = (UINT8 *)BurnMalloc(nLen)) == NULL) return 1;
2499 	memset(Mem, 0, nLen);
2500 	MahjongMemIndex();
2501 
2502 	DrvTempRom = (UINT8 *)BurnMalloc(0x200000);
2503 
2504 	nRet = BurnLoadRom(DrvZ80Rom  + 0x000000,  0, 1); if (nRet != 0) return 1;
2505 	nRet = BurnLoadRom(DrvZ80Rom  + 0x010000,  1, 1); if (nRet != 0) return 1;
2506 
2507 	memset(DrvTempRom, 0xff, 0x200000);
2508 	nRet = BurnLoadRom(DrvTempRom + 0x000000,  2, 1); if (nRet != 0) return 1;
2509 	nRet = BurnLoadRom(DrvTempRom + 0x080000,  3, 1); if (nRet != 0) return 1;
2510 	nRet = BurnLoadRom(DrvTempRom + 0x100000,  4, 1); if (nRet != 0) return 1;
2511 	nRet = BurnLoadRom(DrvTempRom + 0x180000,  5, 1); if (nRet != 0) return 1;
2512 	GfxDecode(0x10000, 4, 8, 8, MahjongCharPlaneOffsets, MahjongCharXOffsets, MahjongCharYOffsets, 0x100, DrvTempRom, DrvChars);
2513 
2514 	memset(DrvTempRom, 0xff, 0x200000);
2515 	nRet = BurnLoadRom(DrvTempRom + 0x000000,  6, 1); if (nRet != 0) return 1;
2516 	nRet = BurnLoadRom(DrvTempRom + 0x020000,  7, 1); if (nRet != 0) return 1;
2517 	GfxDecode(0x00800, 4, 16, 16, SpritePlaneOffsets, SpriteXOffsets, SpriteYOffsets, 0x200, DrvTempRom, DrvSprites);
2518 
2519 	BurnFree(DrvTempRom);
2520 
2521 	nRet = BurnLoadRom(DrvSoundRom + 0x000000,  8, 1); if (nRet != 0) return 1;
2522 
2523 	marukin_decode();
2524 
2525 	MahjongMachineInit();
2526 
2527 	DrvInputType = DRV_INPUT_TYPE_MAHJONG;
2528 
2529 	DrvDoReset();
2530 
2531 	return 0;
2532 }
2533 
Qtono1Init()2534 static INT32 Qtono1Init()
2535 {
2536 	INT32 nRet = 0, nLen;
2537 
2538 	Mem = NULL;
2539 	PangMemIndex();
2540 	nLen = MemEnd - (UINT8 *)0;
2541 	if ((Mem = (UINT8 *)BurnMalloc(nLen)) == NULL) return 1;
2542 	memset(Mem, 0, nLen);
2543 	PangMemIndex();
2544 
2545 	DrvTempRom = (UINT8 *)BurnMalloc(0x100000);
2546 
2547 	nRet = BurnLoadRom(DrvZ80Rom  + 0x00000,  0, 1); if (nRet != 0) return 1;
2548 	nRet = BurnLoadRom(DrvZ80Rom  + 0x10000,  1, 1); if (nRet != 0) return 1;
2549 	nRet = BurnLoadRom(DrvZ80Rom  + 0x30000,  2, 1); if (nRet != 0) return 1;
2550 
2551 	memset(DrvTempRom, 0xff, 0x100000);
2552 	nRet = BurnLoadRom(DrvTempRom + 0x00000,  3, 1); if (nRet != 0) return 1;
2553 	nRet = BurnLoadRom(DrvTempRom + 0x20000,  4, 1); if (nRet != 0) return 1;
2554 	nRet = BurnLoadRom(DrvTempRom + 0x40000,  5, 1); if (nRet != 0) return 1;
2555 	nRet = BurnLoadRom(DrvTempRom + 0x60000,  6, 1); if (nRet != 0) return 1;
2556 	nRet = BurnLoadRom(DrvTempRom + 0x80000,  7, 1); if (nRet != 0) return 1;
2557 	nRet = BurnLoadRom(DrvTempRom + 0xa0000,  8, 1); if (nRet != 0) return 1;
2558 	nRet = BurnLoadRom(DrvTempRom + 0xc0000,  9, 1); if (nRet != 0) return 1;
2559 	nRet = BurnLoadRom(DrvTempRom + 0xe0000, 10, 1); if (nRet != 0) return 1;
2560 	GfxDecode(0x8000, 4, 8, 8, CharPlaneOffsets, CharXOffsets, CharYOffsets, 0x80, DrvTempRom, DrvChars);
2561 
2562 	memset(DrvTempRom, 0xff, 0x100000);
2563 	nRet = BurnLoadRom(DrvTempRom + 0x00000, 11, 1); if (nRet != 0) return 1;
2564 	nRet = BurnLoadRom(DrvTempRom + 0x20000, 12, 1); if (nRet != 0) return 1;
2565 	GfxDecode(0x0800, 4, 16, 16, SpritePlaneOffsets, SpriteXOffsets, SpriteYOffsets, 0x200, DrvTempRom, DrvSprites);
2566 
2567 	BurnFree(DrvTempRom);
2568 
2569 	nRet = BurnLoadRom(DrvSoundRom + 0x00000, 13, 1); if (nRet != 0) return 1;
2570 
2571 	qtono1_decode();
2572 
2573 	MitchellMachineInit();
2574 
2575 	if (!EEPROMAvailable()) {
2576 		// the game doesn't work properly until p2 start is pressed ?
2577 		// setting the default eeprom get around this issue
2578 		const UINT8 qtono1_default_eeprom[32]=
2579 		{
2580 			0x50,0x41,0x53,0x53,0x00,0x00,0x02,0x00,0x1f,0x0d,0xff,0x00,0x00,0x00,0x00,0x00,
2581 			0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
2582 		};
2583 		EEPROMFill(qtono1_default_eeprom, 0, 32);
2584 	}
2585 
2586 	DrvDoReset();
2587 
2588 	return 0;
2589 }
2590 
QsangokuInit()2591 static INT32 QsangokuInit()
2592 {
2593 	INT32 nRet = 0, nLen;
2594 
2595 	Mem = NULL;
2596 	PangMemIndex();
2597 	nLen = MemEnd - (UINT8 *)0;
2598 	if ((Mem = (UINT8 *)BurnMalloc(nLen)) == NULL) return 1;
2599 	memset(Mem, 0, nLen);
2600 	PangMemIndex();
2601 
2602 	DrvTempRom = (UINT8 *)BurnMalloc(0x100000);
2603 
2604 	nRet = BurnLoadRom(DrvZ80Rom  + 0x00000,  0, 1); if (nRet != 0) return 1;
2605 	nRet = BurnLoadRom(DrvZ80Rom  + 0x10000,  1, 1); if (nRet != 0) return 1;
2606 	nRet = BurnLoadRom(DrvZ80Rom  + 0x30000,  2, 1); if (nRet != 0) return 1;
2607 
2608 	memset(DrvTempRom, 0xff, 0x100000);
2609 	nRet = BurnLoadRom(DrvTempRom + 0x00000,  3, 1); if (nRet != 0) return 1;
2610 	nRet = BurnLoadRom(DrvTempRom + 0x20000,  4, 1); if (nRet != 0) return 1;
2611 	nRet = BurnLoadRom(DrvTempRom + 0x40000,  5, 1); if (nRet != 0) return 1;
2612 	nRet = BurnLoadRom(DrvTempRom + 0x60000,  6, 1); if (nRet != 0) return 1;
2613 	nRet = BurnLoadRom(DrvTempRom + 0x80000,  7, 1); if (nRet != 0) return 1;
2614 	nRet = BurnLoadRom(DrvTempRom + 0xa0000,  8, 1); if (nRet != 0) return 1;
2615 	nRet = BurnLoadRom(DrvTempRom + 0xc0000,  9, 1); if (nRet != 0) return 1;
2616 	nRet = BurnLoadRom(DrvTempRom + 0xe0000, 10, 1); if (nRet != 0) return 1;
2617 	GfxDecode(0x8000, 4, 8, 8, CharPlaneOffsets, CharXOffsets, CharYOffsets, 0x80, DrvTempRom, DrvChars);
2618 
2619 	memset(DrvTempRom, 0xff, 0x100000);
2620 	nRet = BurnLoadRom(DrvTempRom + 0x00000, 11, 1); if (nRet != 0) return 1;
2621 	nRet = BurnLoadRom(DrvTempRom + 0x20000, 12, 1); if (nRet != 0) return 1;
2622 	GfxDecode(0x0800, 4, 16, 16, SpritePlaneOffsets, SpriteXOffsets, SpriteYOffsets, 0x200, DrvTempRom, DrvSprites);
2623 
2624 	BurnFree(DrvTempRom);
2625 
2626 	nRet = BurnLoadRom(DrvSoundRom + 0x00000, 13, 1); if (nRet != 0) return 1;
2627 
2628 	qsangoku_decode();
2629 
2630 	MitchellMachineInit();
2631 
2632 	DrvDoReset();
2633 
2634 	return 0;
2635 }
2636 
BlockInit()2637 static INT32 BlockInit()
2638 {
2639 	INT32 nRet = 0, nLen;
2640 
2641 	Mem = NULL;
2642 	PangMemIndex();
2643 	nLen = MemEnd - (UINT8 *)0;
2644 	if ((Mem = (UINT8 *)BurnMalloc(nLen)) == NULL) return 1;
2645 	memset(Mem, 0, nLen);
2646 	PangMemIndex();
2647 
2648 	DrvTempRom = (UINT8 *)BurnMalloc(0x100000);
2649 
2650 	nRet = BurnLoadRom(DrvZ80Rom  + 0x00000,  0, 1); if (nRet != 0) return 1;
2651 	nRet = BurnLoadRom(DrvZ80Rom  + 0x10000,  1, 1); if (nRet != 0) return 1;
2652 	nRet = BurnLoadRom(DrvZ80Rom  + 0x30000,  2, 1); if (nRet != 0) return 1;
2653 
2654 	memset(DrvTempRom, 0xff, 0x100000);
2655 	nRet = BurnLoadRom(DrvTempRom + 0x00000,  3, 1); if (nRet != 0) return 1;
2656 	nRet = BurnLoadRom(DrvTempRom + 0x20000,  4, 1); if (nRet != 0) return 1;
2657 	nRet = BurnLoadRom(DrvTempRom + 0x80000,  5, 1); if (nRet != 0) return 1;
2658 	nRet = BurnLoadRom(DrvTempRom + 0xa0000,  6, 1); if (nRet != 0) return 1;
2659 	GfxDecode(0x8000, 4, 8, 8, CharPlaneOffsets, CharXOffsets, CharYOffsets, 0x80, DrvTempRom, DrvChars);
2660 
2661 	memset(DrvTempRom, 0xff, 0x100000);
2662 	nRet = BurnLoadRom(DrvTempRom + 0x00000,  7, 1); if (nRet != 0) return 1;
2663 	nRet = BurnLoadRom(DrvTempRom + 0x20000,  8, 1); if (nRet != 0) return 1;
2664 	GfxDecode(0x0800, 4, 16, 16, SpritePlaneOffsets, SpriteXOffsets, SpriteYOffsets, 0x200, DrvTempRom, DrvSprites);
2665 
2666 	BurnFree(DrvTempRom);
2667 
2668 	nRet = BurnLoadRom(DrvSoundRom + 0x00000,  9, 1); if (nRet != 0) return 1;
2669 
2670 	block_decode();
2671 
2672 	MitchellMachineInit();
2673 
2674 	DrvInputType = DRV_INPUT_TYPE_BLOCK;
2675 
2676 	DrvNVRamSize = 0x0080;
2677 	DrvNVRamAddress = 0x1f80;
2678 
2679 	DrvDoReset();
2680 
2681 	return 0;
2682 }
2683 
BlockjoyInit()2684 static INT32 BlockjoyInit()
2685 {
2686 	INT32 nRet = 0, nLen;
2687 
2688 	Mem = NULL;
2689 	PangMemIndex();
2690 	nLen = MemEnd - (UINT8 *)0;
2691 	if ((Mem = (UINT8 *)BurnMalloc(nLen)) == NULL) return 1;
2692 	memset(Mem, 0, nLen);
2693 	PangMemIndex();
2694 
2695 	DrvTempRom = (UINT8 *)BurnMalloc(0x100000);
2696 
2697 	nRet = BurnLoadRom(DrvZ80Rom  + 0x00000,  0, 1); if (nRet != 0) return 1;
2698 	nRet = BurnLoadRom(DrvZ80Rom  + 0x10000,  1, 1); if (nRet != 0) return 1;
2699 	nRet = BurnLoadRom(DrvZ80Rom  + 0x30000,  2, 1); if (nRet != 0) return 1;
2700 
2701 	memset(DrvTempRom, 0xff, 0x100000);
2702 	nRet = BurnLoadRom(DrvTempRom + 0x00000,  3, 1); if (nRet != 0) return 1;
2703 	nRet = BurnLoadRom(DrvTempRom + 0x20000,  4, 1); if (nRet != 0) return 1;
2704 	nRet = BurnLoadRom(DrvTempRom + 0x80000,  5, 1); if (nRet != 0) return 1;
2705 	nRet = BurnLoadRom(DrvTempRom + 0xa0000,  6, 1); if (nRet != 0) return 1;
2706 	GfxDecode(0x8000, 4, 8, 8, CharPlaneOffsets, CharXOffsets, CharYOffsets, 0x80, DrvTempRom, DrvChars);
2707 
2708 	memset(DrvTempRom, 0xff, 0x100000);
2709 	nRet = BurnLoadRom(DrvTempRom + 0x00000,  7, 1); if (nRet != 0) return 1;
2710 	nRet = BurnLoadRom(DrvTempRom + 0x20000,  8, 1); if (nRet != 0) return 1;
2711 	GfxDecode(0x0800, 4, 16, 16, SpritePlaneOffsets, SpriteXOffsets, SpriteYOffsets, 0x200, DrvTempRom, DrvSprites);
2712 
2713 	BurnFree(DrvTempRom);
2714 
2715 	nRet = BurnLoadRom(DrvSoundRom + 0x00000, 9, 1); if (nRet != 0) return 1;
2716 
2717 	block_decode();
2718 
2719 	MitchellMachineInit();
2720 
2721 	DrvDoReset();
2722 
2723 	return 0;
2724 }
2725 
BlockblInit()2726 static INT32 BlockblInit()
2727 {
2728 	INT32 nRet = 0, nLen;
2729 
2730 	Mem = NULL;
2731 	PangMemIndex();
2732 	nLen = MemEnd - (UINT8 *)0;
2733 	if ((Mem = (UINT8 *)BurnMalloc(nLen)) == NULL) return 1;
2734 	memset(Mem, 0, nLen);
2735 	PangMemIndex();
2736 
2737 	DrvTempRom = (UINT8 *)BurnMalloc(0x100000);
2738 
2739 	nRet = BurnLoadRom(DrvZ80Code + 0x00000,  0, 1); if (nRet != 0) return 1;
2740 	nRet = BurnLoadRom(DrvZ80Code + 0x10000,  1, 1); if (nRet != 0) return 1;
2741 	nRet = BurnLoadRom(DrvZ80Rom  + 0x30000,  2, 1); if (nRet != 0) return 1;
2742 	memcpy(DrvZ80Rom + 0x00000, DrvZ80Code + 0x08000, 0x08000);
2743 	memset(DrvZ80Code + 0x08000, 0, 0x08000);
2744 	memcpy(DrvZ80Rom + 0x10000, DrvZ80Code + 0x30000, 0x20000);
2745 	memset(DrvZ80Code + 0x30000, 0, 0x20000);
2746 
2747 	memset(DrvTempRom, 0xff, 0x100000);
2748 	nRet = BurnLoadRom(DrvTempRom + 0x00000,  3, 1); if (nRet != 0) return 1;
2749 	nRet = BurnLoadRom(DrvTempRom + 0x20000,  4, 1); if (nRet != 0) return 1;
2750 	nRet = BurnLoadRom(DrvTempRom + 0x80000,  5, 1); if (nRet != 0) return 1;
2751 	nRet = BurnLoadRom(DrvTempRom + 0xa0000,  6, 1); if (nRet != 0) return 1;
2752 	GfxDecode(0x8000, 4, 8, 8, CharPlaneOffsets, CharXOffsets, CharYOffsets, 0x80, DrvTempRom, DrvChars);
2753 
2754 	memset(DrvTempRom, 0xff, 0x100000);
2755 	nRet = BurnLoadRom(DrvTempRom + 0x00000,  7, 1); if (nRet != 0) return 1;
2756 	nRet = BurnLoadRom(DrvTempRom + 0x10000,  8, 1); if (nRet != 0) return 1;
2757 	nRet = BurnLoadRom(DrvTempRom + 0x20000,  9, 1); if (nRet != 0) return 1;
2758 	nRet = BurnLoadRom(DrvTempRom + 0x30000, 10, 1); if (nRet != 0) return 1;
2759 	GfxDecode(0x0800, 4, 16, 16, SpritePlaneOffsets, SpriteXOffsets, SpriteYOffsets, 0x200, DrvTempRom, DrvSprites);
2760 
2761 	BurnFree(DrvTempRom);
2762 
2763 	nRet = BurnLoadRom(DrvSoundRom + 0x00000, 11, 1); if (nRet != 0) return 1;
2764 
2765 	MitchellMachineInit();
2766 
2767 	DrvInputType = DRV_INPUT_TYPE_BLOCK;
2768 
2769 	DrvNVRamSize = 0x0080;
2770 	DrvNVRamAddress = 0x1f80;
2771 
2772 	DrvDoReset();
2773 
2774 	return 0;
2775 }
2776 
CommonExit()2777 static INT32 CommonExit()
2778 {
2779 	ZetExit();
2780 
2781 	MSM6295Exit(0);
2782 	if (DrvHasEEPROM) EEPROMExit();
2783 
2784 	GenericTilesExit();
2785 
2786 	BurnFree(Mem);
2787 
2788 	DrvRomBank = 0;
2789 	DrvPaletteRamBank = 0;
2790 	DrvOkiBank = 0;
2791 	DrvFlipScreen = 0;
2792 	DrvVideoBank = 0;
2793 	DrvInputType = 0;
2794 	DrvMahjongKeyMatrix = 0;
2795 	DrvTileMask = 0;
2796 	DrvInput5Toggle = 0;
2797 	DrvPort5Kludge = 0;
2798 	DrvHasEEPROM = 0;
2799 	DrvNumColours = 0;
2800 	DrvNVRamSize = 0;
2801 	DrvNVRamAddress = 0;
2802 	DrvDialSelected = 0;
2803 	DrvSoundLatch = 0;
2804 
2805 	return 0;
2806 }
2807 
DrvExit()2808 static INT32 DrvExit()
2809 {
2810 	BurnYM2413Exit();
2811 
2812 	return CommonExit();
2813 }
2814 
pal4bit(UINT8 bits)2815 static inline UINT8 pal4bit(UINT8 bits)
2816 {
2817 	bits &= 0x0f;
2818 	return (bits << 4) | bits;
2819 }
2820 
CalcCol(UINT16 nColour)2821 inline static UINT32 CalcCol(UINT16 nColour)
2822 {
2823 	INT32 r, g, b;
2824 
2825 	r = pal4bit(nColour >> 8);
2826 	g = pal4bit(nColour >> 4);
2827 	b = pal4bit(nColour >> 0);
2828 
2829 	return BurnHighCol(r, g, b, 0);
2830 }
2831 
DrvCalcPalette()2832 static void DrvCalcPalette()
2833 {
2834 	for (INT32 i = 0; i < DrvNumColours * 2; i += 2) {
2835 		INT32 Val = DrvPaletteRam[i & ~1] + (DrvPaletteRam[i | 1] << 8);
2836 
2837 		DrvPalette[i >> 1] = CalcCol(Val);
2838 	}
2839 }
2840 
DrvRenderBgLayer()2841 static void DrvRenderBgLayer()
2842 {
2843 	INT32 mx, my, Code, Attr, Colour, x, y, TileIndex = 0, xFlip;
2844 
2845 	for (my = 0; my < 32; my++) {
2846 		for (mx = 0; mx < 64; mx++) {
2847 			Attr = DrvAttrRam[TileIndex];
2848 			Code = DrvVideoRam[(2 * TileIndex) + 0] + (DrvVideoRam[(2 * TileIndex) + 1] << 8);
2849 			Colour = Attr & (DrvNumColours == 0x800 ? 0x7f : 0x3f);
2850 			xFlip = (Attr & 0x80);
2851 
2852 			x = 8 * mx;
2853 			y = 8 * my;
2854 
2855 			if (DrvFlipScreen) {
2856 				x = 504 - x;
2857 				y = 248 - y;
2858 				xFlip = !xFlip;
2859 			}
2860 
2861 			x -= 64;
2862 			y -= 8;
2863 
2864 			Code &= DrvTileMask;
2865 
2866 			if (DrvFlipScreen) {
2867 				if (x > 8 && x < (nScreenWidth - 8) && y > 8 && y < (nScreenHeight - 8)) {
2868 					if (xFlip) {
2869 						Render8x8Tile_Mask_FlipXY(pTransDraw, Code, x, y, Colour, 4, 15, 0, DrvChars);
2870 					} else {
2871 						Render8x8Tile_Mask_FlipY(pTransDraw, Code, x, y, Colour, 4, 15, 0, DrvChars);
2872 					}
2873 				} else {
2874 					if (xFlip) {
2875 						Render8x8Tile_Mask_FlipXY_Clip(pTransDraw, Code, x, y, Colour, 4, 15, 0, DrvChars);
2876 					} else {
2877 						Render8x8Tile_Mask_FlipY_Clip(pTransDraw, Code, x, y, Colour, 4, 15, 0, DrvChars);
2878 					}
2879 				}
2880 			} else {
2881 				if (x > 8 && x < (nScreenWidth - 8) && y > 8 && y < (nScreenHeight - 8)) {
2882 					if (xFlip) {
2883 						Render8x8Tile_Mask_FlipX(pTransDraw, Code, x, y, Colour, 4, 15, 0, DrvChars);
2884 					} else {
2885 						Render8x8Tile_Mask(pTransDraw, Code, x, y, Colour, 4, 15, 0, DrvChars);
2886 					}
2887 				} else {
2888 					if (xFlip) {
2889 						Render8x8Tile_Mask_FlipX_Clip(pTransDraw, Code, x, y, Colour, 4, 15, 0, DrvChars);
2890 					} else {
2891 						Render8x8Tile_Mask_Clip(pTransDraw, Code, x, y, Colour, 4, 15, 0, DrvChars);
2892 					}
2893 				}
2894 			}
2895 
2896 			TileIndex++;
2897 		}
2898 	}
2899 }
2900 
DrvRenderSpriteLayer()2901 static void DrvRenderSpriteLayer()
2902 {
2903 	INT32 sx, sy;
2904 
2905 	for (INT32 Offset = 0x1000 - 0x40; Offset >= 0; Offset -= 0x20) {
2906 		INT32 Code = DrvSpriteRam[Offset + 0];
2907 		INT32 Attr = DrvSpriteRam[Offset + 1];
2908 		INT32 Colour = Attr & 0x0f;
2909 		sx = DrvSpriteRam[Offset + 3] + ((Attr & 0x10) << 4);
2910 		sy = ((DrvSpriteRam[Offset + 2] + 8) & 0xff) - 8;
2911 		Code += (Attr & 0xe0) << 3;
2912 
2913 		if (DrvFlipScreen) {
2914 			sx = 496 - sx;
2915 			sy = 240 - sy;
2916 		}
2917 
2918 		sx -= 64;
2919 		sy -= 8;
2920 
2921 		if (DrvFlipScreen) {
2922 			if (sx > 16 && sx < (nScreenWidth - 16) && sy > 16 && sy < (nScreenHeight - 16)) {
2923 				Render16x16Tile_Mask_FlipXY(pTransDraw, Code, sx, sy, Colour, 4, 15, 0, DrvSprites);
2924 			} else {
2925 				Render16x16Tile_Mask_FlipXY_Clip(pTransDraw, Code, sx, sy, Colour, 4, 15, 0, DrvSprites);
2926 			}
2927 		} else {
2928 			if (sx > 16 && sx < (nScreenWidth - 16) && sy > 16 && sy < (nScreenHeight - 16)) {
2929 				Render16x16Tile_Mask(pTransDraw, Code, sx, sy, Colour, 4, 15, 0, DrvSprites);
2930 			} else {
2931 				Render16x16Tile_Mask_Clip(pTransDraw, Code, sx, sy, Colour, 4, 15, 0, DrvSprites);
2932 			}
2933 		}
2934 	}
2935 }
2936 
DrvDraw()2937 static INT32 DrvDraw()
2938 {
2939 	BurnTransferClear();
2940 	DrvCalcPalette();
2941 	DrvRenderBgLayer();
2942 	DrvRenderSpriteLayer();
2943 	BurnTransferCopy(DrvPalette);
2944 
2945 	return 0;
2946 }
2947 
DrvFrame()2948 static INT32 DrvFrame()
2949 {
2950 	INT32 nInterleave = 256;
2951 	INT32 nSoundBufferPos = 0;
2952 
2953 	if (DrvReset) DrvDoReset();
2954 
2955 	DrvMakeInputs();
2956 
2957 	nCyclesTotal[0] = 8000000 / 57;
2958 	nCyclesDone[0] = 0;
2959 
2960 	//DrvInput5Toggle = 0;
2961 
2962 	ZetNewFrame();
2963 
2964 	for (INT32 i = 0; i < nInterleave; i++) {
2965 		INT32 nCurrentCPU;
2966 
2967 		// Run Z80 #1
2968 		nCurrentCPU = 0;
2969 		ZetOpen(nCurrentCPU);
2970 		nCyclesSegment = nCyclesTotal[nCurrentCPU] / nInterleave;
2971 		nCyclesDone[nCurrentCPU] += ZetRun(nCyclesSegment);
2972 		if (i == 0 || i == 240) {
2973 			ZetSetIRQLine(0, CPU_IRQSTATUS_HOLD);
2974 			DrvInput5Toggle = (i == 240);
2975 		}
2976 		ZetClose();
2977 
2978 		if (pBurnSoundOut) {
2979 			INT32 nSegmentLength = nBurnSoundLen / nInterleave;
2980 			INT16* pSoundBuf = pBurnSoundOut + (nSoundBufferPos << 1);
2981 			BurnYM2413Render(pSoundBuf, nSegmentLength);
2982 			MSM6295Render(0, pSoundBuf, nSegmentLength);
2983 			nSoundBufferPos += nSegmentLength;
2984 		}
2985 	}
2986 
2987 	if (pBurnSoundOut) {
2988 		INT32 nSegmentLength = nBurnSoundLen - nSoundBufferPos;
2989 		INT16* pSoundBuf = pBurnSoundOut + (nSoundBufferPos << 1);
2990 
2991 		if (nSegmentLength) {
2992 			BurnYM2413Render(pSoundBuf, nSegmentLength);
2993 			MSM6295Render(0, pSoundBuf, nSegmentLength);
2994 		}
2995 	}
2996 
2997 	if (pBurnDraw) DrvDraw();
2998 
2999 	return 0;
3000 }
3001 
MstworldFrame()3002 static INT32 MstworldFrame()
3003 {
3004 	INT32 nInterleave = 10;
3005 	INT32 nSoundBufferPos = 0;
3006 
3007 	if (DrvReset) MstworldDoReset();
3008 
3009 	DrvMakeInputs();
3010 
3011 	nCyclesTotal[0] = 24000000 / 60;
3012 	nCyclesTotal[1] = 6000000 / 60;
3013 	nCyclesDone[0] = nCyclesDone[1] = 0;
3014 
3015 	ZetNewFrame();
3016 
3017 	for (INT32 i = 0; i < nInterleave; i++) {
3018 		INT32 nCurrentCPU, nNext;
3019 
3020 		nCurrentCPU = 0;
3021 		ZetOpen(nCurrentCPU);
3022 		nNext = (i + 1) * nCyclesTotal[nCurrentCPU] / nInterleave;
3023 		nCyclesSegment = nNext - nCyclesDone[nCurrentCPU];
3024 		nCyclesDone[nCurrentCPU] += ZetRun(nCyclesSegment);
3025 		if (i == 9) {
3026 			ZetSetIRQLine(0, CPU_IRQSTATUS_HOLD);
3027 		}
3028 		ZetClose();
3029 
3030 		nCurrentCPU = 1;
3031 		ZetOpen(nCurrentCPU);
3032 		nNext = (i + 1) * nCyclesTotal[nCurrentCPU] / nInterleave;
3033 		nCyclesSegment = nNext - nCyclesDone[nCurrentCPU];
3034 		nCyclesDone[nCurrentCPU] += ZetRun(nCyclesSegment);
3035 		ZetClose();
3036 
3037 		if (pBurnSoundOut) {
3038 			INT32 nSegmentLength = nBurnSoundLen / nInterleave;
3039 			INT16* pSoundBuf = pBurnSoundOut + (nSoundBufferPos << 1);
3040 			MSM6295Render(0, pSoundBuf, nSegmentLength);
3041 			nSoundBufferPos += nSegmentLength;
3042 		}
3043 	}
3044 
3045 	if (pBurnSoundOut) {
3046 		INT32 nSegmentLength = nBurnSoundLen - nSoundBufferPos;
3047 		INT16* pSoundBuf = pBurnSoundOut + (nSoundBufferPos << 1);
3048 
3049 		if (nSegmentLength) {
3050 			MSM6295Render(0, pSoundBuf, nSegmentLength);
3051 		}
3052 	}
3053 
3054 	if (pBurnDraw) DrvDraw();
3055 
3056 	return 0;
3057 }
3058 
DrvScan(INT32 nAction,INT32 * pnMin)3059 static INT32 DrvScan(INT32 nAction, INT32 *pnMin)
3060 {
3061 	struct BurnArea ba;
3062 
3063 	if (pnMin != NULL) {			// Return minimum compatible version
3064 		*pnMin = 0x029707;
3065 	}
3066 
3067 	if (nAction & ACB_MEMORY_RAM) {
3068 		memset(&ba, 0, sizeof(ba));
3069 		ba.Data	  = RamStart;
3070 		ba.nLen	  = RamEnd-RamStart;
3071 		ba.szName = "All Ram";
3072 		BurnAcb(&ba);
3073 	}
3074 
3075 	if (nAction & ACB_NVRAM && DrvNVRamSize) {
3076 		memset(&ba, 0, sizeof(ba));
3077 		ba.Data = DrvZ80Ram + DrvNVRamAddress;
3078 		ba.nLen = DrvNVRamSize;
3079 		ba.szName = "NVRam";
3080 		BurnAcb(&ba);
3081 	}
3082 
3083 	if (nAction & ACB_DRIVER_DATA) {
3084 		ZetScan(nAction);
3085 		BurnYM2413Scan(nAction, pnMin);
3086 		MSM6295Scan(nAction, pnMin);
3087 
3088 		if (DrvHasEEPROM) EEPROMScan(nAction, pnMin);
3089 
3090 		SCAN_VAR(nCyclesDone[0]);
3091 		SCAN_VAR(nCyclesDone[1]);
3092 		SCAN_VAR(DrvRomBank);
3093 		SCAN_VAR(DrvPaletteRamBank);
3094 		SCAN_VAR(DrvOkiBank);
3095 		SCAN_VAR(DrvFlipScreen);
3096 		SCAN_VAR(DrvVideoBank);
3097 		SCAN_VAR(DrvInput5Toggle);
3098 		SCAN_VAR(DrvDialSelected);
3099 		SCAN_VAR(DrvDial[0]);
3100 		SCAN_VAR(DrvDial[1]);
3101 		SCAN_VAR(DrvDial1);
3102 		SCAN_VAR(DrvDial2);
3103 		SCAN_VAR(DrvMahjongKeyMatrix);
3104 	}
3105 
3106 	if (nAction & ACB_WRITE) {
3107 		ZetOpen(0);
3108 		ZetMapArea(0x8000, 0xbfff, 0, DrvZ80Rom + 0x10000 + (DrvRomBank * 0x4000));
3109 		if (DrvHasEEPROM) {
3110 			ZetMapArea(0x8000, 0xbfff, 2, DrvZ80Code + 0x10000 + (DrvRomBank * 0x4000), DrvZ80Rom + 0x10000 + (DrvRomBank * 0x4000));
3111 		} else {
3112 			ZetMapArea(0x8000, 0xbfff, 2, DrvZ80Rom + 0x10000 + (DrvRomBank * 0x4000));
3113 		}
3114 		ZetClose();
3115 
3116 		oki_bankswitch(DrvOkiBank);
3117 	}
3118 
3119 	return 0;
3120 }
3121 
MstworldScan(INT32 nAction,INT32 * pnMin)3122 static INT32 MstworldScan(INT32 nAction, INT32 *pnMin)
3123 {
3124 	struct BurnArea ba;
3125 
3126 	if (pnMin != NULL) {			// Return minimum compatible version
3127 		*pnMin = 0x029707;
3128 	}
3129 
3130 	if (nAction & ACB_MEMORY_RAM) {
3131 		memset(&ba, 0, sizeof(ba));
3132 		ba.Data	  = RamStart;
3133 		ba.nLen	  = RamEnd-RamStart;
3134 		ba.szName = "All Ram";
3135 		BurnAcb(&ba);
3136 	}
3137 
3138 	if (nAction & ACB_DRIVER_DATA) {
3139 		ZetScan(nAction);
3140 		MSM6295Scan(nAction, pnMin);
3141 
3142 		SCAN_VAR(nCyclesDone[0]);
3143 		SCAN_VAR(nCyclesDone[1]);
3144 		SCAN_VAR(DrvRomBank);
3145 		SCAN_VAR(DrvPaletteRamBank);
3146 		SCAN_VAR(DrvOkiBank);
3147 		SCAN_VAR(DrvFlipScreen);
3148 		SCAN_VAR(DrvVideoBank);
3149 		SCAN_VAR(DrvSoundLatch);
3150 	}
3151 
3152 	if (nAction & ACB_WRITE) {
3153 		ZetOpen(0);
3154 		ZetMapArea(0x8000, 0xbfff, 0, DrvZ80Rom + 0x10000 + (DrvRomBank * 0x4000));
3155 		ZetMapArea(0x8000, 0xbfff, 2, DrvZ80Code + 0x10000 + (DrvRomBank * 0x4000), DrvZ80Rom + 0x10000 + (DrvRomBank * 0x4000));
3156 		ZetClose();
3157 
3158 		oki_bankswitch(DrvOkiBank);
3159 	}
3160 
3161 	return 0;
3162 }
3163 
3164 struct BurnDriver BurnDrvMgakuen = {
3165 	"mgakuen", NULL, NULL, NULL, "1988",
3166 	"Mahjong Gakuen\0", NULL, "Yuga", "Miscellaneous",
3167 	NULL, NULL, NULL, NULL,
3168 	BDF_GAME_WORKING | BDF_HISCORE_SUPPORTED, 2, HARDWARE_MISC_PRE90S, GBF_MAHJONG, 0,
3169 	NULL, MgakuenRomInfo, MgakuenRomName, NULL, NULL, NULL, NULL, MgakuenInputInfo, MgakuenDIPInfo,
3170 	MgakuenInit, DrvExit, DrvFrame, DrvDraw, DrvScan,
3171 	NULL, 0x400, 384, 240, 4, 3
3172 };
3173 
3174 struct BurnDriver BurnDrvSeventoitsu = {
3175 	"7toitsu", "mgakuen", NULL, NULL, "1988",
3176 	"Chi-Toitsu\0", NULL, "Yuga", "Miscellaneous",
3177 	NULL, NULL, NULL, NULL,
3178 	BDF_GAME_WORKING | BDF_CLONE | BDF_HISCORE_SUPPORTED, 2, HARDWARE_MISC_PRE90S, GBF_MAHJONG, 0,
3179 	NULL, SeventoitsuRomInfo, SeventoitsuRomName, NULL, NULL, NULL, NULL, MgakuenInputInfo, MgakuenDIPInfo,
3180 	MgakuenInit, DrvExit, DrvFrame, DrvDraw, DrvScan,
3181 	NULL, 0x400, 384, 240, 4, 3
3182 };
3183 
3184 struct BurnDriver BurnDrvMgakuen2 = {
3185 	"mgakuen2", NULL, NULL, NULL, "1989",
3186 	"Mahjong Gakuen 2 Gakuen-chou no Fukushuu\0", NULL, "Face", "Miscellaneous",
3187 	NULL, NULL, NULL, NULL,
3188 	BDF_GAME_WORKING | BDF_HISCORE_SUPPORTED, 2, HARDWARE_MISC_PRE90S, GBF_MAHJONG, 0,
3189 	NULL, Mgakuen2RomInfo, Mgakuen2RomName, NULL, NULL, NULL, NULL, MarukinInputInfo, NULL,
3190 	Mgakuen2Init, DrvExit, DrvFrame, DrvDraw, DrvScan,
3191 	NULL, 0x800, 384, 240, 4, 3
3192 };
3193 
3194 struct BurnDriver BurnDrvPkladies = {
3195 	"pkladies", NULL, NULL, NULL, "1989",
3196 	"Poker Ladies\0", NULL, "Mitchell", "Miscellaneous",
3197 	NULL, NULL, NULL, NULL,
3198 	BDF_GAME_WORKING | BDF_HISCORE_SUPPORTED, 2, HARDWARE_MISC_PRE90S, GBF_MAHJONG, 0,
3199 	NULL, PkladiesRomInfo, PkladiesRomName, NULL, NULL, NULL, NULL, PkladiesInputInfo, NULL,
3200 	PkladiesInit, DrvExit, DrvFrame, DrvDraw, DrvScan,
3201 	NULL, 0x800, 384, 240, 4, 3
3202 };
3203 
3204 struct BurnDriver BurnDrvPkladiesl = {
3205 	"pkladiesl", "pkladies", NULL, NULL, "1989",
3206 	"Poker Ladies (Leprechaun ver. 510)\0", NULL, "Leprechaun", "Miscellaneous",
3207 	NULL, NULL, NULL, NULL,
3208 	BDF_GAME_WORKING | BDF_CLONE | BDF_HISCORE_SUPPORTED, 2, HARDWARE_MISC_PRE90S, GBF_MAHJONG, 0,
3209 	NULL, PkladieslRomInfo, PkladieslRomName, NULL, NULL, NULL, NULL, PkladiesInputInfo, NULL,
3210 	PkladiesInit, DrvExit, DrvFrame, DrvDraw, DrvScan,
3211 	NULL, 0x800, 384, 240, 4, 3
3212 };
3213 
3214 struct BurnDriver BurnDrvPkladiesla = {
3215 	"pkladiesla", "pkladies", NULL, NULL, "1989",
3216 	"Poker Ladies (Leprechaun ver. 401)\0", NULL, "Leprechaun", "Miscellaneous",
3217 	NULL, NULL, NULL, NULL,
3218 	BDF_GAME_WORKING | BDF_CLONE | BDF_HISCORE_SUPPORTED, 2, HARDWARE_MISC_PRE90S, GBF_MAHJONG, 0,
3219 	NULL, PkladieslaRomInfo, PkladieslaRomName, NULL, NULL, NULL, NULL, PkladiesInputInfo, NULL,
3220 	PkladiesInit, DrvExit, DrvFrame, DrvDraw, DrvScan,
3221 	NULL, 0x800, 384, 240, 4, 3
3222 };
3223 
3224 struct BurnDriver BurnDrvDokaben2 = {
3225 	"dokaben2", NULL, NULL, NULL, "1989",
3226 	"Dokaben 2 (Japan)\0", NULL, "Capcom", "Miscellaneous",
3227 	NULL, NULL, NULL, NULL,
3228 	BDF_GAME_WORKING | BDF_HISCORE_SUPPORTED, 2, HARDWARE_MISC_PRE90S, GBF_SPORTSMISC, 0,
3229 	NULL, Dokaben2RomInfo, Dokaben2RomName, NULL, NULL, NULL, NULL, PangInputInfo, NULL,
3230 	DokabenInit, DrvExit, DrvFrame, DrvDraw, DrvScan,
3231 	NULL, 0x800, 384, 240, 4, 3
3232 };
3233 
3234 struct BurnDriver BurnDrvDokaben = {
3235 	"dokaben", NULL, NULL, NULL, "1989",
3236 	"Dokaben (Japan)\0", NULL, "Capcom", "Miscellaneous",
3237 	NULL, NULL, NULL, NULL,
3238 	BDF_GAME_WORKING | BDF_HISCORE_SUPPORTED, 2, HARDWARE_MISC_PRE90S, GBF_SPORTSMISC, 0,
3239 	NULL, DokabenRomInfo, DokabenRomName, NULL, NULL, NULL, NULL, PangInputInfo, NULL,
3240 	DokabenInit, DrvExit, DrvFrame, DrvDraw, DrvScan,
3241 	NULL, 0x800, 384, 240, 4, 3
3242 };
3243 
3244 struct BurnDriver BurnDrvPang = {
3245 	"pang", NULL, NULL, NULL, "1989",
3246 	"Pang (World)\0", NULL, "Mitchell", "Miscellaneous",
3247 	NULL, NULL, NULL, NULL,
3248 	BDF_GAME_WORKING | BDF_HISCORE_SUPPORTED, 2, HARDWARE_MISC_PRE90S, GBF_PUZZLE, 0,
3249 	NULL, PangRomInfo, PangRomName, NULL, NULL, NULL, NULL, PangInputInfo, NULL,
3250 	PangInit, DrvExit, DrvFrame, DrvDraw, DrvScan,
3251 	NULL, 0x800, 384, 240, 4, 3
3252 };
3253 
3254 struct BurnDriver BurnDrvBbros = {
3255 	"bbros", "pang", NULL, NULL, "1989",
3256 	"Buster Bros. (USA)\0", NULL, "Mitchell (Capcom license)", "Miscellaneous",
3257 	NULL, NULL, NULL, NULL,
3258 	BDF_GAME_WORKING | BDF_CLONE | BDF_HISCORE_SUPPORTED, 2, HARDWARE_MISC_PRE90S, GBF_PUZZLE, 0,
3259 	NULL, BbrosRomInfo, BbrosRomName, NULL, NULL, NULL, NULL, PangInputInfo, NULL,
3260 	PangInit, DrvExit, DrvFrame, DrvDraw, DrvScan,
3261 	NULL, 0x800, 384, 240, 4, 3
3262 };
3263 
3264 struct BurnDriver BurnDrvPompingw = {
3265 	"pompingw", "pang", NULL, NULL, "1989",
3266 	"Pomping World (Japan)\0", NULL, "Mitchell", "Miscellaneous",
3267 	NULL, NULL, NULL, NULL,
3268 	BDF_GAME_WORKING | BDF_CLONE | BDF_HISCORE_SUPPORTED, 2, HARDWARE_MISC_PRE90S, GBF_PUZZLE, 0,
3269 	NULL, PompingwRomInfo, PompingwRomName, NULL, NULL, NULL, NULL, PangInputInfo, NULL,
3270 	PangInit, DrvExit, DrvFrame, DrvDraw, DrvScan,
3271 	NULL, 0x800, 384, 240, 4, 3
3272 };
3273 
3274 struct BurnDriver BurnDrvPangb = {
3275 	"pangb", "pang", NULL, NULL, "1989",
3276 	"Pang (bootleg, set 1)\0", NULL, "bootleg", "Miscellaneous",
3277 	NULL, NULL, NULL, NULL,
3278 	BDF_GAME_WORKING | BDF_CLONE | BDF_BOOTLEG | BDF_HISCORE_SUPPORTED, 2, HARDWARE_MISC_PRE90S, GBF_PUZZLE, 0,
3279 	NULL, PangbRomInfo, PangbRomName, NULL, NULL, NULL, NULL, PangInputInfo, NULL,
3280 	PangbInit, DrvExit, DrvFrame, DrvDraw, DrvScan,
3281 	NULL, 0x800, 384, 240, 4, 3
3282 };
3283 
3284 struct BurnDriver BurnDrvPangbold = {
3285 	"pangbold", "pang", NULL, NULL, "1989",
3286 	"Pang (bootleg, set 2)\0", NULL, "bootleg", "Miscellaneous",
3287 	NULL, NULL, NULL, NULL,
3288 	BDF_GAME_WORKING | BDF_CLONE | BDF_BOOTLEG | BDF_HISCORE_SUPPORTED, 2, HARDWARE_MISC_PRE90S, GBF_PUZZLE, 0,
3289 	NULL, PangboldRomInfo, PangboldRomName, NULL, NULL, NULL, NULL, PangInputInfo, NULL,
3290 	PangboldInit, DrvExit, DrvFrame, DrvDraw, DrvScan,
3291 	NULL, 0x800, 384, 240, 4, 3
3292 };
3293 
3294 struct BurnDriver BurnDrvPangbold2 = {
3295 	"pangbold2", "pang", NULL, NULL, "1990",
3296 	"Pang (bootleg, set 5)\0", NULL, "bootleg", "Miscellaneous",
3297 	NULL, NULL, NULL, NULL,
3298 	BDF_GAME_WORKING | BDF_CLONE | BDF_BOOTLEG | BDF_HISCORE_SUPPORTED, 2, HARDWARE_MISC_PRE90S, GBF_PUZZLE, 0,
3299 	NULL, Pangbold2RomInfo, Pangbold2RomName, NULL, NULL, NULL, NULL, PangInputInfo, NULL,
3300 	PangboldInit, DrvExit, DrvFrame, DrvDraw, DrvScan,
3301 	NULL, 0x800, 384, 240, 4, 3
3302 };
3303 
3304 struct BurnDriver BurnDrvPangbold3 = {
3305 	"pangbold3", "pang", NULL, NULL, "1989",
3306 	"Pang (bootleg, set 6)\0", NULL, "bootleg", "Miscellaneous",
3307 	NULL, NULL, NULL, NULL,
3308 	BDF_GAME_WORKING | BDF_CLONE | BDF_BOOTLEG | BDF_HISCORE_SUPPORTED, 2, HARDWARE_MISC_PRE90S, GBF_PUZZLE, 0,
3309 	NULL, Pangbold3RomInfo, Pangbold3RomName, NULL, NULL, NULL, NULL, PangInputInfo, NULL,
3310 	PangboldInit, DrvExit, DrvFrame, DrvDraw, DrvScan,
3311 	NULL, 0x800, 384, 240, 4, 3
3312 };
3313 
3314 struct BurnDriver BurnDrvPangb2 = {
3315 	"pangb2", "pang", NULL, NULL, "1989",
3316 	"Pang (bootleg, set 4)\0", NULL, "bootleg", "Miscellaneous",
3317 	NULL, NULL, NULL, NULL,
3318 	BDF_GAME_WORKING | BDF_CLONE | BDF_BOOTLEG | BDF_HISCORE_SUPPORTED, 2, HARDWARE_MISC_PRE90S, GBF_PUZZLE, 0,
3319 	NULL, Pangb2RomInfo, Pangb2RomName, NULL, NULL, NULL, NULL, PangInputInfo, NULL,
3320 	Pangb2Init, DrvExit, DrvFrame, DrvDraw, DrvScan,
3321 	NULL, 0x800, 384, 240, 4, 3
3322 };
3323 
3324 struct BurnDriver BurnDrvCworld = {
3325 	"cworld", NULL, NULL, NULL, "1990",
3326 	"Capcom World (Japan)\0", NULL, "Capcom", "Miscellaneous",
3327 	NULL, NULL, NULL, NULL,
3328 	BDF_GAME_WORKING | BDF_HISCORE_SUPPORTED, 2, HARDWARE_MISC_POST90S, GBF_QUIZ, 0,
3329 	NULL, CworldRomInfo, CworldRomName, NULL, NULL, NULL, NULL, Qtono1InputInfo, NULL,
3330 	CworldInit, DrvExit, DrvFrame, DrvDraw, DrvScan,
3331 	NULL, 0x800, 384, 240, 4, 3
3332 };
3333 
3334 struct BurnDriver BurnDrvHatena = {
3335 	"hatena", NULL, NULL, NULL, "1990",
3336 	"Adventure Quiz 2 - Hatena? no Daibouken (Japan 900228)\0", NULL, "Capcom", "Miscellaneous",
3337 	NULL, NULL, NULL, NULL,
3338 	BDF_GAME_WORKING | BDF_HISCORE_SUPPORTED, 2, HARDWARE_MISC_POST90S, GBF_QUIZ, 0,
3339 	NULL, HatenaRomInfo, HatenaRomName, NULL, NULL, NULL, NULL, Qtono1InputInfo, NULL,
3340 	HatenaInit, DrvExit, DrvFrame, DrvDraw, DrvScan,
3341 	NULL, 0x800, 384, 240, 4, 3
3342 };
3343 
3344 struct BurnDriver BurnDrvSpang = {
3345 	"spang", NULL, NULL, NULL, "1990",
3346 	"Super Pang (World 900914)\0", NULL, "Mitchell", "Miscellaneous",
3347 	NULL, NULL, NULL, NULL,
3348 	BDF_GAME_WORKING | BDF_HISCORE_SUPPORTED, 2, HARDWARE_MISC_POST90S, GBF_PUZZLE, 0,
3349 	NULL, SpangRomInfo, SpangRomName, NULL, NULL, NULL, NULL, PangInputInfo, NULL,
3350 	SpangInit, DrvExit, DrvFrame, DrvDraw, DrvScan,
3351 	NULL, 0x800, 384, 240, 4, 3
3352 };
3353 
3354 struct BurnDriver BurnDrvSpangj = {
3355 	"spangj", "spang", NULL, NULL, "1990",
3356 	"Super Pang (Japan 901023)\0", NULL, "Mitchell", "Miscellaneous",
3357 	NULL, NULL, NULL, NULL,
3358 	BDF_GAME_WORKING | BDF_CLONE | BDF_HISCORE_SUPPORTED, 2, HARDWARE_MISC_POST90S, GBF_PUZZLE, 0,
3359 	NULL, SpangjRomInfo, SpangjRomName, NULL, NULL, NULL, NULL, PangInputInfo, NULL,
3360 	SpangjInit, DrvExit, DrvFrame, DrvDraw, DrvScan,
3361 	NULL, 0x800, 384, 240, 4, 3
3362 };
3363 
3364 struct BurnDriver BurnDrvSbbros = {
3365 	"sbbros", "spang", NULL, NULL, "1990",
3366 	"Super Buster Bros. (USA 901001)\0", NULL, "Mitchell (Capcom license)", "Miscellaneous",
3367 	NULL, NULL, NULL, NULL,
3368 	BDF_GAME_WORKING | BDF_CLONE | BDF_HISCORE_SUPPORTED, 2, HARDWARE_MISC_POST90S, GBF_PUZZLE, 0,
3369 	NULL, SbbrosRomInfo, SbbrosRomName, NULL, NULL, NULL, NULL, PangInputInfo, NULL,
3370 	SbbrosInit, DrvExit, DrvFrame, DrvDraw, DrvScan,
3371 	NULL, 0x800, 384, 240, 4, 3
3372 };
3373 
3374 struct BurnDriver BurnDrvMstworld = {
3375 	"mstworld", NULL, NULL, NULL, "1994",
3376 	"Monsters World (bootleg of Super Pang)\0", NULL, "bootleg (TCH)", "Miscellaneous",
3377 	NULL, NULL, NULL, NULL,
3378 	BDF_GAME_WORKING | BDF_HISCORE_SUPPORTED, 2, HARDWARE_MISC_POST90S, GBF_PUZZLE, 0,
3379 	NULL, MstworldRomInfo, MstworldRomName, NULL, NULL, NULL, NULL, MstworldInputInfo, MstworldDIPInfo,
3380 	MstworldInit, CommonExit, MstworldFrame, DrvDraw, MstworldScan,
3381 	NULL, 0x800, 384, 240, 4, 3
3382 };
3383 
3384 struct BurnDriver BurnDrvMarukin = {
3385 	"marukin", NULL, NULL, NULL, "1990",
3386 	"Super Marukin-Ban (Japan 901017)\0", NULL, "Yuga", "Miscellaneous",
3387 	NULL, NULL, NULL, NULL,
3388 	BDF_GAME_WORKING | BDF_HISCORE_SUPPORTED, 2, HARDWARE_MISC_POST90S, GBF_MAHJONG, 0,
3389 	NULL, MarukinRomInfo, MarukinRomName, NULL, NULL, NULL, NULL, MarukinInputInfo, NULL,
3390 	MarukinInit, DrvExit, DrvFrame, DrvDraw, DrvScan,
3391 	NULL, 0x800, 384, 240, 4, 3
3392 };
3393 
3394 struct BurnDriver BurnDrvQtono1 = {
3395 	"qtono1", NULL, NULL, NULL, "1991",
3396 	"Quiz Tonosama no Yabou (Japan)\0", NULL, "Capcom", "Miscellaneous",
3397 	NULL, NULL, NULL, NULL,
3398 	BDF_GAME_WORKING | BDF_HISCORE_SUPPORTED, 2, HARDWARE_MISC_POST90S, GBF_QUIZ, 0,
3399 	NULL, Qtono1RomInfo, Qtono1RomName, NULL, NULL, NULL, NULL, Qtono1InputInfo, NULL,
3400 	Qtono1Init, DrvExit, DrvFrame, DrvDraw, DrvScan,
3401 	NULL, 0x800, 384, 240, 4, 3
3402 };
3403 
3404 struct BurnDriver BurnDrvQsangoku = {
3405 	"qsangoku", NULL, NULL, NULL, "1991",
3406 	"Quiz Sangokushi (Japan)\0", NULL, "Capcom", "Miscellaneous",
3407 	NULL, NULL, NULL, NULL,
3408 	BDF_GAME_WORKING | BDF_HISCORE_SUPPORTED, 2, HARDWARE_MISC_POST90S, GBF_QUIZ, 0,
3409 	NULL, QsangokuRomInfo, QsangokuRomName, NULL, NULL, NULL, NULL, Qtono1InputInfo, NULL,
3410 	QsangokuInit, DrvExit, DrvFrame, DrvDraw, DrvScan,
3411 	NULL, 0x800, 384, 240, 4, 3
3412 };
3413 
3414 struct BurnDriver BurnDrvBlock = {
3415 	"block", NULL, NULL, NULL, "1991",
3416 	"Block Block (World 911219 Joystick)\0", NULL, "Capcom", "Miscellaneous",
3417 	NULL, NULL, NULL, NULL,
3418 	BDF_GAME_WORKING | BDF_ORIENTATION_VERTICAL | BDF_HISCORE_SUPPORTED, 2, HARDWARE_MISC_POST90S, GBF_BREAKOUT, 0,
3419 	NULL, BlockRomInfo, BlockRomName, NULL, NULL, NULL, NULL, BlockjoyInputInfo, NULL,
3420 	BlockjoyInit, DrvExit, DrvFrame, DrvDraw, DrvScan,
3421 	NULL, 0x800, 240, 384, 3, 4
3422 };
3423 
3424 struct BurnDriver BurnDrvBlockr1 = {
3425 	"blockr1", "block", NULL, NULL, "1991",
3426 	"Block Block (World 911106 Joystick)\0", NULL, "Capcom", "Miscellaneous",
3427 	NULL, NULL, NULL, NULL,
3428 	BDF_GAME_WORKING | BDF_ORIENTATION_VERTICAL | BDF_CLONE | BDF_HISCORE_SUPPORTED, 2, HARDWARE_MISC_POST90S, GBF_BREAKOUT, 0,
3429 	NULL, Blockr1RomInfo, Blockr1RomName, NULL, NULL, NULL, NULL, BlockjoyInputInfo, NULL,
3430 	BlockjoyInit, DrvExit, DrvFrame, DrvDraw, DrvScan,
3431 	NULL, 0x800, 240, 384, 3, 4
3432 };
3433 
3434 struct BurnDriver BurnDrvBlockr2 = {
3435 	"blockr2", "block", NULL, NULL, "1991",
3436 	"Block Block (World 910910)\0", NULL, "Capcom", "Miscellaneous",
3437 	NULL, NULL, NULL, NULL,
3438 	BDF_GAME_WORKING | BDF_ORIENTATION_VERTICAL | BDF_CLONE | BDF_HISCORE_SUPPORTED, 2, HARDWARE_MISC_POST90S, GBF_BREAKOUT, 0,
3439 	NULL, Blockr2RomInfo, Blockr2RomName, NULL, NULL, NULL, NULL, BlockInputInfo, NULL,
3440 	BlockInit, DrvExit, DrvFrame, DrvDraw, DrvScan,
3441 	NULL, 0x800, 240, 384, 3, 4
3442 };
3443 
3444 struct BurnDriver BurnDrvBlockj = {
3445 	"blockj", "block", NULL, NULL, "1991",
3446 	"Block Block (Japan 910910)\0", NULL, "Capcom", "Miscellaneous",
3447 	NULL, NULL, NULL, NULL,
3448 	BDF_GAME_WORKING | BDF_ORIENTATION_VERTICAL | BDF_CLONE | BDF_HISCORE_SUPPORTED, 2, HARDWARE_MISC_POST90S, GBF_BREAKOUT, 0,
3449 	NULL, BlockjRomInfo, BlockjRomName, NULL, NULL, NULL, NULL, BlockInputInfo, NULL,
3450 	BlockInit, DrvExit, DrvFrame, DrvDraw, DrvScan,
3451 	NULL, 0x800, 240, 384, 3, 4
3452 };
3453 
3454 struct BurnDriver BurnDrvBlockbl = {
3455 	"blockbl", "block", NULL, NULL, "1991",
3456 	"Block Block (bootleg)\0", NULL, "bootleg", "Miscellaneous",
3457 	NULL, NULL, NULL, NULL,
3458 	BDF_GAME_WORKING | BDF_ORIENTATION_VERTICAL | BDF_CLONE | BDF_BOOTLEG | BDF_HISCORE_SUPPORTED, 2, HARDWARE_MISC_POST90S, GBF_BREAKOUT, 0,
3459 	NULL, BlockblRomInfo, BlockblRomName, NULL, NULL, NULL, NULL, BlockInputInfo, NULL,
3460 	BlockblInit, DrvExit, DrvFrame, DrvDraw, DrvScan,
3461 	NULL, 0x800, 240, 384, 3, 4
3462 };
3463