1 // FB Alpha Kaneko 16-bit driver module
2 // Based on MAME driver by Luca Elia
3 
4 #include "tiles_generic.h"
5 #include "m68000_intf.h"
6 #include "z80_intf.h"
7 #include "msm6295.h"
8 #include "burn_ym2151.h"
9 #include "eeprom.h"
10 #include "bitswap.h"
11 #include "kanekotb.h"
12 #include "ay8910.h"
13 
14 /*==============================================================================================
15 Driver Variables
16 ===============================================================================================*/
17 
18 static UINT8 Kaneko16InputPort0[8] = {0, 0, 0, 0, 0, 0, 0, 0};
19 static UINT8 Kaneko16InputPort1[8] = {0, 0, 0, 0, 0, 0, 0, 0};
20 static UINT8 Kaneko16InputPort2[8] = {0, 0, 0, 0, 0, 0, 0, 0};
21 static UINT8 Kaneko16InputPort3[8] = {0, 0, 0, 0, 0, 0, 0, 0};
22 static UINT8 Kaneko16Dip[3]        = {0, 0, 0};
23 static UINT8 Kaneko16Input[4]      = {0x00, 0x00, 0x00, 0x00};
24 static UINT8 Kaneko16Reset         = 0;
25 
26 static UINT8 *Mem                  = NULL;
27 static UINT8 *MemEnd               = NULL;
28 static UINT8 *RamStart             = NULL;
29 static UINT8 *RamEnd               = NULL;
30 static UINT8 *Kaneko16Rom          = NULL;
31 static UINT8 *Kaneko16McuRom       = NULL;
32 static UINT8 *Kaneko16Z80Rom       = NULL;
33 static UINT8 *MSM6295ROMData       = NULL;
34 static UINT8 *MSM6295ROMData2      = NULL;
35 static UINT8 *Kaneko16Ram          = NULL;
36 static UINT8 *Kaneko16Z80Ram       = NULL;
37 static UINT8 *Kaneko16MCURam       = NULL;
38 static UINT8 *Kaneko16NVRam        = NULL;
39 static UINT8 *Kaneko16PaletteRam   = NULL;
40 static UINT8 *Kaneko16SpriteRam    = NULL;
41 static UINT8 *Kaneko16Video0Ram    = NULL;
42 static UINT8 *Kaneko16Video1Ram    = NULL;
43 static UINT8 *Kaneko16Video2Ram    = NULL;
44 static UINT8 *Kaneko16Video3Ram    = NULL;
45 static UINT8 *Kaneko16VScrl0Ram    = NULL;
46 static UINT8 *Kaneko16VScrl1Ram    = NULL;
47 static UINT8 *Kaneko16VScrl2Ram    = NULL;
48 static UINT8 *Kaneko16VScrl3Ram    = NULL;
49 static UINT32 *Kaneko16Palette     = NULL;
50 static UINT8 *Kaneko16Tiles        = NULL;
51 static UINT8 *Kaneko16Tiles2       = NULL;
52 static UINT8 *Kaneko16Sprites      = NULL;
53 static UINT8 *Kaneko16TempGfx      = NULL;
54 static UINT8 *Kaneko16PrioBitmap   = NULL; // Wing Force, BlaZeon, mgcrystl
55 static UINT16 *Kaneko16SpriteFbuffer = NULL; // mgcrystl sprite framebuffer/overdraw mode
56 
57 static INT32 Kaneko16Brightness;
58 static UINT32 Kaneko16SoundLatch;
59 static INT32 MSM6295Bank0;
60 static INT32 MSM6295Bank1;
61 
62 static UINT16 ToyboxMCUCom[4];
63 
64 static UINT16 Kaneko16Bg15Reg;
65 static UINT16 Kaneko16Bg15Select;
66 static UINT16 *Kaneko16Bg15Data = NULL;
67 static UINT8 Kaneko16RecalcBg15Palette;
68 
69 static UINT16 Kaneko16SpriteFlipX;
70 static UINT16 Kaneko16SpriteFlipY;
71 static INT32 Kaneko16SpriteFlipType;
72 static UINT16 Kaneko16SpriteRegs[0x20 | 0x400/2]; // mapped with SekMapMemory() which maps in blocks of 0x400
73 static UINT16 Kaneko16Layer0Regs[0x10 | 0x400/2];
74 static UINT16 Kaneko16Layer1Regs[0x10 | 0x400/2];
75 static UINT32 Kaneko16SpritesColourOffset;
76 static UINT32 Kaneko16LayersColourOffset;
77 static UINT32 Kaneko16SpritesColourMask;
78 static UINT16 Kaneko16DisplayEnable;
79 static INT32 Kaneko16TilesXOffset;
80 static INT32 Kaneko16TilesYOffset;
81 static INT32 Kaneko16SpriteXOffset;
82 
83 static UINT32 *LayerQueueXY[4];
84 static UINT32 *LayerQueueColour[4];
85 static UINT8 *LayerQueuePriority[4];
86 static INT32 LayerQueueSize[4];
87 
88 static INT32 Kaneko16NumTiles;
89 static INT32 Kaneko16NumTiles2;
90 static INT32 Kaneko16NumSprites;
91 static INT32 Kaneko16SpriteRamSize;
92 
93 // Flags
94 static INT32 Kaneko168BppSprites;
95 static INT32 Kaneko16Eeprom = 0;
96 static INT32 Kaneko16Bg15;
97 static INT32 Gtmr = 0;
98 static INT32 Bloodwar = 0;
99 static INT32 Bonkadv = 0;
100 static INT32 Mgcrystl = 0;
101 static INT32 Shogwarr = 0;
102 static INT32 Brapboys = 0;
103 
104 typedef void (*MCURun)();
105 static MCURun ToyboxMCURun;
106 
107 typedef INT32 (*ParseSprite)(INT32, struct tempsprite*);
108 static ParseSprite Kaneko16ParseSprite;
109 static INT32 Kaneko16ParseSpriteType0(INT32 i, struct tempsprite *s);
110 static INT32 Kaneko16ParseSpriteType1(INT32 i, struct tempsprite *s);
111 static INT32 Kaneko16ParseSpriteType2(INT32 i, struct tempsprite *s);
112 
113 static INT32 nCyclesDone[2], nCyclesTotal[2];
114 static INT32 nCyclesSegment;
115 static INT32 nSoundBufferPos;
116 
117 static INT32 Kaneko16Watchdog;
118 
119 static void ShogwarrConfigSoundBank(INT32 oki, INT32 nBank, INT32 nStart, INT32 nSize);
120 
121 struct tempsprite
122 {
123 	INT32 code,color;
124 	INT32 x,y;
125 	INT32 xoffs,yoffs;
126 	INT32 flipx,flipy;
127 	INT32 priority;
128 };
129 
130 static struct
131 {
132 	struct tempsprite *first_sprite;
133 }	spritelist;
134 
135 /*==============================================================================================
136 Input Definitions
137 ===============================================================================================*/
138 
139 static struct BurnInputInfo BerlwallInputList[] = {
140 	{"P1 Coin"           , BIT_DIGITAL  , Kaneko16InputPort2 + 2, "p1 coin"   },
141 	{"P1 Start"          , BIT_DIGITAL  , Kaneko16InputPort2 + 0, "p1 start"  },
142 	{"P1 Up"             , BIT_DIGITAL  , Kaneko16InputPort0 + 0, "p1 up"     },
143 	{"P1 Down"           , BIT_DIGITAL  , Kaneko16InputPort0 + 1, "p1 down"   },
144 	{"P1 Left"           , BIT_DIGITAL  , Kaneko16InputPort0 + 2, "p1 left"   },
145 	{"P1 Right"          , BIT_DIGITAL  , Kaneko16InputPort0 + 3, "p1 right"  },
146 	{"P1 Fire 1"         , BIT_DIGITAL  , Kaneko16InputPort0 + 4, "p1 fire 1" },
147 	{"P1 Fire 2"         , BIT_DIGITAL  , Kaneko16InputPort0 + 5, "p1 fire 2" },
148 	{"P1 Fire 3"         , BIT_DIGITAL  , Kaneko16InputPort0 + 6, "p1 fire 3" },
149 
150 	{"P2 Coin"           , BIT_DIGITAL  , Kaneko16InputPort2 + 3, "p2 coin"   },
151 	{"P2 Start"          , BIT_DIGITAL  , Kaneko16InputPort2 + 1, "p2 start"  },
152 	{"P2 Up"             , BIT_DIGITAL  , Kaneko16InputPort1 + 0, "p2 up"     },
153 	{"P2 Down"           , BIT_DIGITAL  , Kaneko16InputPort1 + 1, "p2 down"   },
154 	{"P2 Left"           , BIT_DIGITAL  , Kaneko16InputPort1 + 2, "p2 left"   },
155 	{"P2 Right"          , BIT_DIGITAL  , Kaneko16InputPort1 + 3, "p2 right"  },
156 	{"P2 Fire 1"         , BIT_DIGITAL  , Kaneko16InputPort1 + 4, "p2 fire 1" },
157 	{"P2 Fire 2"         , BIT_DIGITAL  , Kaneko16InputPort1 + 5, "p2 fire 2" },
158 	{"P2 Fire 3"         , BIT_DIGITAL  , Kaneko16InputPort1 + 6, "p2 fire 3" },
159 
160 	{"Reset"             , BIT_DIGITAL  , &Kaneko16Reset        , "reset"     },
161 	{"Service"           , BIT_DIGITAL  , Kaneko16InputPort2 + 6, "service"   },
162 	{"Test"              , BIT_DIGITAL  , Kaneko16InputPort2 + 4, "diag"      },
163 	{"Tilt"              , BIT_DIGITAL  , Kaneko16InputPort2 + 5, "tilt"      },
164 	{"Dip 1"             , BIT_DIPSWITCH, Kaneko16Dip + 0       , "dip"       },
165 	{"Dip 2"             , BIT_DIPSWITCH, Kaneko16Dip + 1       , "dip"       },
166 	{"Fake DIP"          , BIT_DIPSWITCH, Kaneko16Dip + 2       , "dip"       },
167 };
168 
169 STDINPUTINFO(Berlwall)
170 
171 static struct BurnInputInfo BlazeonInputList[] = {
172 	{"P1 Coin"           , BIT_DIGITAL  , Kaneko16InputPort0 + 7, "p1 coin"   },
173 	{"P1 Start"          , BIT_DIGITAL  , Kaneko16InputPort0 + 6, "p1 start"  },
174 	{"P1 Up"             , BIT_DIGITAL  , Kaneko16InputPort0 + 0, "p1 up"     },
175 	{"P1 Down"           , BIT_DIGITAL  , Kaneko16InputPort0 + 1, "p1 down"   },
176 	{"P1 Left"           , BIT_DIGITAL  , Kaneko16InputPort0 + 2, "p1 left"   },
177 	{"P1 Right"          , BIT_DIGITAL  , Kaneko16InputPort0 + 3, "p1 right"  },
178 	{"P1 Fire 1"         , BIT_DIGITAL  , Kaneko16InputPort0 + 4, "p1 fire 1" },
179 	{"P1 Fire 2"         , BIT_DIGITAL  , Kaneko16InputPort0 + 5, "p1 fire 2" },
180 
181 	{"P2 Coin"           , BIT_DIGITAL  , Kaneko16InputPort1 + 7, "p2 coin"   },
182 	{"P2 Start"          , BIT_DIGITAL  , Kaneko16InputPort1 + 6, "p2 start"  },
183 	{"P2 Up"             , BIT_DIGITAL  , Kaneko16InputPort1 + 0, "p2 up"     },
184 	{"P2 Down"           , BIT_DIGITAL  , Kaneko16InputPort1 + 1, "p2 down"   },
185 	{"P2 Left"           , BIT_DIGITAL  , Kaneko16InputPort1 + 2, "p2 left"   },
186 	{"P2 Right"          , BIT_DIGITAL  , Kaneko16InputPort1 + 3, "p2 right"  },
187 	{"P2 Fire 1"         , BIT_DIGITAL  , Kaneko16InputPort1 + 4, "p2 fire 1" },
188 	{"P2 Fire 2"         , BIT_DIGITAL  , Kaneko16InputPort1 + 5, "p2 fire 2" },
189 
190 	{"Reset"             , BIT_DIGITAL  , &Kaneko16Reset        , "reset"     },
191 	{"Service"           , BIT_DIGITAL  , Kaneko16InputPort2 + 7, "service"   },
192 	{"Test"              , BIT_DIGITAL  , Kaneko16InputPort2 + 5, "diag"      },
193 	{"Tilt"              , BIT_DIGITAL  , Kaneko16InputPort2 + 6, "tilt"      },
194 	{"Dip 1"             , BIT_DIPSWITCH, Kaneko16Dip + 0       , "dip"       },
195 	{"Dip 2"             , BIT_DIPSWITCH, Kaneko16Dip + 1       , "dip"       },
196 };
197 
198 STDINPUTINFO(Blazeon)
199 
200 static struct BurnInputInfo BloodwarInputList[] = {
201 	{"P1 Coin"           , BIT_DIGITAL  , Kaneko16InputPort2 + 2, "p1 coin"   },
202 	{"P1 Start"          , BIT_DIGITAL  , Kaneko16InputPort2 + 0, "p1 start"  },
203 	{"P1 Up"             , BIT_DIGITAL  , Kaneko16InputPort0 + 0, "p1 up"     },
204 	{"P1 Down"           , BIT_DIGITAL  , Kaneko16InputPort0 + 1, "p1 down"   },
205 	{"P1 Left"           , BIT_DIGITAL  , Kaneko16InputPort0 + 2, "p1 left"   },
206 	{"P1 Right"          , BIT_DIGITAL  , Kaneko16InputPort0 + 3, "p1 right"  },
207 	{"P1 Fire 1"         , BIT_DIGITAL  , Kaneko16InputPort0 + 4, "p1 fire 1" },
208 	{"P1 Fire 2"         , BIT_DIGITAL  , Kaneko16InputPort0 + 5, "p1 fire 2" },
209 	{"P1 Fire 3"         , BIT_DIGITAL  , Kaneko16InputPort0 + 6, "p1 fire 3" },
210 	{"P1 Fire 4"         , BIT_DIGITAL  , Kaneko16InputPort0 + 7, "p1 fire 4" },
211 
212 	{"P2 Coin"           , BIT_DIGITAL  , Kaneko16InputPort2 + 3, "p2 coin"   },
213 	{"P2 Start"          , BIT_DIGITAL  , Kaneko16InputPort2 + 1, "p2 start"  },
214 	{"P2 Up"             , BIT_DIGITAL  , Kaneko16InputPort1 + 0, "p2 up"     },
215 	{"P2 Down"           , BIT_DIGITAL  , Kaneko16InputPort1 + 1, "p2 down"   },
216 	{"P2 Left"           , BIT_DIGITAL  , Kaneko16InputPort1 + 2, "p2 left"   },
217 	{"P2 Right"          , BIT_DIGITAL  , Kaneko16InputPort1 + 3, "p2 right"  },
218 	{"P2 Fire 1"         , BIT_DIGITAL  , Kaneko16InputPort1 + 4, "p2 fire 1" },
219 	{"P2 Fire 2"         , BIT_DIGITAL  , Kaneko16InputPort1 + 5, "p2 fire 2" },
220 	{"P2 Fire 3"         , BIT_DIGITAL  , Kaneko16InputPort1 + 6, "p2 fire 3" },
221 	{"P2 Fire 4"         , BIT_DIGITAL  , Kaneko16InputPort3 + 2, "p2 fire 4" },
222 
223 	{"Reset"             , BIT_DIGITAL  , &Kaneko16Reset        , "reset"     },
224 	{"Service"           , BIT_DIGITAL  , Kaneko16InputPort2 + 6, "service"   },
225 	{"Test"              , BIT_DIGITAL  , Kaneko16InputPort2 + 4, "diag"      },
226 	{"Dip 1"             , BIT_DIPSWITCH, Kaneko16Dip + 0       , "dip"       },
227 };
228 
229 STDINPUTINFO(Bloodwar)
230 
231 static struct BurnInputInfo BonkadvInputList[] = {
232 	{"P1 Coin"           , BIT_DIGITAL  , Kaneko16InputPort2 + 2, "p1 coin"   },
233 	{"P1 Start"          , BIT_DIGITAL  , Kaneko16InputPort2 + 0, "p1 start"  },
234 	{"P1 Up"             , BIT_DIGITAL  , Kaneko16InputPort0 + 0, "p1 up"     },
235 	{"P1 Down"           , BIT_DIGITAL  , Kaneko16InputPort0 + 1, "p1 down"   },
236 	{"P1 Left"           , BIT_DIGITAL  , Kaneko16InputPort0 + 2, "p1 left"   },
237 	{"P1 Right"          , BIT_DIGITAL  , Kaneko16InputPort0 + 3, "p1 right"  },
238 	{"P1 Fire 1"         , BIT_DIGITAL  , Kaneko16InputPort0 + 4, "p1 fire 1" },
239 	{"P1 Fire 2"         , BIT_DIGITAL  , Kaneko16InputPort0 + 5, "p1 fire 2" },
240 
241 	{"P2 Coin"           , BIT_DIGITAL  , Kaneko16InputPort2 + 3, "p2 coin"   },
242 	{"P2 Start"          , BIT_DIGITAL  , Kaneko16InputPort2 + 1, "p2 start"  },
243 	{"P2 Up"             , BIT_DIGITAL  , Kaneko16InputPort1 + 0, "p2 up"     },
244 	{"P2 Down"           , BIT_DIGITAL  , Kaneko16InputPort1 + 1, "p2 down"   },
245 	{"P2 Left"           , BIT_DIGITAL  , Kaneko16InputPort1 + 2, "p2 left"   },
246 	{"P2 Right"          , BIT_DIGITAL  , Kaneko16InputPort1 + 3, "p2 right"  },
247 	{"P2 Fire 1"         , BIT_DIGITAL  , Kaneko16InputPort1 + 4, "p2 fire 1" },
248 	{"P2 Fire 2"         , BIT_DIGITAL  , Kaneko16InputPort1 + 5, "p2 fire 2" },
249 
250 	{"Reset"             , BIT_DIGITAL  , &Kaneko16Reset        , "reset"     },
251 	{"Service"           , BIT_DIGITAL  , Kaneko16InputPort2 + 6, "service"   },
252 	{"Test"              , BIT_DIGITAL  , Kaneko16InputPort2 + 4, "diag"      },
253 	{"Tilt"              , BIT_DIGITAL  , Kaneko16InputPort2 + 5, "tilt"      },
254 	{"Dip 1"             , BIT_DIPSWITCH, Kaneko16Dip + 0       , "dip"       },
255 };
256 
257 STDINPUTINFO(Bonkadv)
258 
259 static struct BurnInputInfo ExplbrkrInputList[] = {
260 	{"P1 Coin"           , BIT_DIGITAL  , Kaneko16InputPort2 + 2, "p1 coin"   },
261 	{"P1 Start"          , BIT_DIGITAL  , Kaneko16InputPort2 + 0, "p1 start"  },
262 	{"P1 Up"             , BIT_DIGITAL  , Kaneko16InputPort0 + 0, "p1 up"     },
263 	{"P1 Down"           , BIT_DIGITAL  , Kaneko16InputPort0 + 1, "p1 down"   },
264 	{"P1 Left"           , BIT_DIGITAL  , Kaneko16InputPort0 + 2, "p1 left"   },
265 	{"P1 Right"          , BIT_DIGITAL  , Kaneko16InputPort0 + 3, "p1 right"  },
266 	{"P1 Fire 1"         , BIT_DIGITAL  , Kaneko16InputPort0 + 4, "p1 fire 1" },
267 	{"P1 Fire 2"         , BIT_DIGITAL  , Kaneko16InputPort0 + 5, "p1 fire 2" },
268 
269 	{"P2 Coin"           , BIT_DIGITAL  , Kaneko16InputPort2 + 3, "p2 coin"   },
270 	{"P2 Start"          , BIT_DIGITAL  , Kaneko16InputPort2 + 1, "p2 start"  },
271 	{"P2 Up"             , BIT_DIGITAL  , Kaneko16InputPort1 + 0, "p2 up"     },
272 	{"P2 Down"           , BIT_DIGITAL  , Kaneko16InputPort1 + 1, "p2 down"   },
273 	{"P2 Left"           , BIT_DIGITAL  , Kaneko16InputPort1 + 2, "p2 left"   },
274 	{"P2 Right"          , BIT_DIGITAL  , Kaneko16InputPort1 + 3, "p2 right"  },
275 	{"P2 Fire 1"         , BIT_DIGITAL  , Kaneko16InputPort1 + 4, "p2 fire 1" },
276 	{"P2 Fire 2"         , BIT_DIGITAL  , Kaneko16InputPort1 + 5, "p2 fire 2" },
277 
278 	{"Reset"             , BIT_DIGITAL  , &Kaneko16Reset        , "reset"     },
279 	{"Service"           , BIT_DIGITAL  , Kaneko16InputPort2 + 6, "service"   },
280 	{"Dip 1"             , BIT_DIPSWITCH, Kaneko16Dip + 0       , "dip"       },
281 };
282 
283 STDINPUTINFO(Explbrkr)
284 
285 static struct BurnInputInfo GtmrInputList[] = {
286 	{"P1 Coin"           , BIT_DIGITAL  , Kaneko16InputPort2 + 2, "p1 coin"   },
287 	{"P1 Start"          , BIT_DIGITAL  , Kaneko16InputPort2 + 0, "p1 start"  },
288 	{"P1 Up"             , BIT_DIGITAL  , Kaneko16InputPort0 + 0, "p1 up"     },
289 	{"P1 Down"           , BIT_DIGITAL  , Kaneko16InputPort0 + 1, "p1 down"   },
290 	{"P1 Left"           , BIT_DIGITAL  , Kaneko16InputPort0 + 2, "p1 left"   },
291 	{"P1 Right"          , BIT_DIGITAL  , Kaneko16InputPort0 + 3, "p1 right"  },
292 	{"P1 Fire 1"         , BIT_DIGITAL  , Kaneko16InputPort0 + 4, "p1 fire 1" },
293 	{"P1 Fire 2"         , BIT_DIGITAL  , Kaneko16InputPort0 + 5, "p1 fire 2" },
294 
295 	{"P2 Coin"           , BIT_DIGITAL  , Kaneko16InputPort2 + 3, "p2 coin"   },
296 	{"P2 Start"          , BIT_DIGITAL  , Kaneko16InputPort2 + 1, "p2 start"  },
297 	{"P2 Up"             , BIT_DIGITAL  , Kaneko16InputPort1 + 0, "p2 up"     },
298 	{"P2 Down"           , BIT_DIGITAL  , Kaneko16InputPort1 + 1, "p2 down"   },
299 	{"P2 Left"           , BIT_DIGITAL  , Kaneko16InputPort1 + 2, "p2 left"   },
300 	{"P2 Right"          , BIT_DIGITAL  , Kaneko16InputPort1 + 3, "p2 right"  },
301 	{"P2 Fire 1"         , BIT_DIGITAL  , Kaneko16InputPort1 + 4, "p2 fire 1" },
302 	{"P2 Fire 2"         , BIT_DIGITAL  , Kaneko16InputPort1 + 5, "p2 fire 2" },
303 
304 	{"Reset"             , BIT_DIGITAL  , &Kaneko16Reset        , "reset"     },
305 	{"Service"           , BIT_DIGITAL  , Kaneko16InputPort2 + 6, "service"   },
306 	{"Test"              , BIT_DIGITAL  , Kaneko16InputPort2 + 4, "diag"      },
307 	{"Tilt"              , BIT_DIGITAL  , Kaneko16InputPort2 + 5, "tilt"      },
308 	{"Dip 1"             , BIT_DIPSWITCH, Kaneko16Dip + 0       , "dip"       },
309 };
310 
311 STDINPUTINFO(Gtmr)
312 
313 static struct BurnInputInfo MgcrystlInputList[] = {
314 	{"P1 Coin"           , BIT_DIGITAL  , Kaneko16InputPort2 + 2, "p1 coin"   },
315 	{"P1 Start"          , BIT_DIGITAL  , Kaneko16InputPort2 + 0, "p1 start"  },
316 	{"P1 Up"             , BIT_DIGITAL  , Kaneko16InputPort0 + 0, "p1 up"     },
317 	{"P1 Down"           , BIT_DIGITAL  , Kaneko16InputPort0 + 1, "p1 down"   },
318 	{"P1 Left"           , BIT_DIGITAL  , Kaneko16InputPort0 + 2, "p1 left"   },
319 	{"P1 Right"          , BIT_DIGITAL  , Kaneko16InputPort0 + 3, "p1 right"  },
320 	{"P1 Fire 1"         , BIT_DIGITAL  , Kaneko16InputPort0 + 4, "p1 fire 1" },
321 	{"P1 Fire 2"         , BIT_DIGITAL  , Kaneko16InputPort0 + 5, "p1 fire 2" },
322 
323 	{"P2 Coin"           , BIT_DIGITAL  , Kaneko16InputPort2 + 3, "p2 coin"   },
324 	{"P2 Start"          , BIT_DIGITAL  , Kaneko16InputPort2 + 1, "p2 start"  },
325 	{"P2 Up"             , BIT_DIGITAL  , Kaneko16InputPort1 + 0, "p2 up"     },
326 	{"P2 Down"           , BIT_DIGITAL  , Kaneko16InputPort1 + 1, "p2 down"   },
327 	{"P2 Left"           , BIT_DIGITAL  , Kaneko16InputPort1 + 2, "p2 left"   },
328 	{"P2 Right"          , BIT_DIGITAL  , Kaneko16InputPort1 + 3, "p2 right"  },
329 	{"P2 Fire 1"         , BIT_DIGITAL  , Kaneko16InputPort1 + 4, "p2 fire 1" },
330 	{"P2 Fire 2"         , BIT_DIGITAL  , Kaneko16InputPort1 + 5, "p2 fire 2" },
331 
332 	{"Reset"             , BIT_DIGITAL  , &Kaneko16Reset        , "reset"     },
333 	{"Service"           , BIT_DIGITAL  , Kaneko16InputPort2 + 6, "service"   },
334 	{"Test"              , BIT_DIGITAL  , Kaneko16InputPort2 + 4, "diag"      },
335 	{"Tilt"              , BIT_DIGITAL  , Kaneko16InputPort2 + 5, "tilt"      },
336 	{"Dip 1"             , BIT_DIPSWITCH, Kaneko16Dip + 0       , "dip"       },
337 };
338 
339 STDINPUTINFO(Mgcrystl)
340 
341 static struct BurnInputInfo ShogwarrInputList[] = {
342 	{"P1 Coin"			 , BIT_DIGITAL	, Kaneko16InputPort0 + 7, "p1 coin"   },
343 	{"P1 Start"			 , BIT_DIGITAL	, Kaneko16InputPort0 + 6, "p1 start"  },
344 	{"P1 Up"			 , BIT_DIGITAL	, Kaneko16InputPort0 + 0, "p1 up"	  },
345 	{"P1 Down"			 , BIT_DIGITAL  , Kaneko16InputPort0 + 1, "p1 down"   },
346 	{"P1 Left"			 , BIT_DIGITAL	, Kaneko16InputPort0 + 2, "p1 left"   },
347 	{"P1 Right"			 , BIT_DIGITAL	, Kaneko16InputPort0 + 3, "p1 right"  },
348 	{"P1 Button 1"		 , BIT_DIGITAL	, Kaneko16InputPort0 + 4, "p1 fire 1" },
349 	{"P1 Button 2"		 , BIT_DIGITAL	, Kaneko16InputPort0 + 5, "p1 fire 2" },
350 	{"P1 Button 3"		 , BIT_DIGITAL	, Kaneko16InputPort2 + 3, "p1 fire 3" },
351 	{"P1 Button 4"		 , BIT_DIGITAL	, Kaneko16InputPort2 + 2, "p1 fire 4" },
352 
353 	{"P2 Coin"			 , BIT_DIGITAL	, Kaneko16InputPort1 + 7, "p2 coin"	  },
354 	{"P2 Start"			 , BIT_DIGITAL	, Kaneko16InputPort1 + 6, "p2 start"  },
355 	{"P2 Up"			 , BIT_DIGITAL	, Kaneko16InputPort1 + 0, "p2 up"	  },
356 	{"P2 Down"			 , BIT_DIGITAL	, Kaneko16InputPort1 + 1, "p2 down"	  },
357 	{"P2 Left"			 , BIT_DIGITAL	, Kaneko16InputPort1 + 2, "p2 left"	  },
358 	{"P2 Right"			 , BIT_DIGITAL	, Kaneko16InputPort1 + 3, "p2 right"  },
359 	{"P2 Button 1"		 , BIT_DIGITAL	, Kaneko16InputPort1 + 4, "p2 fire 1" },
360 	{"P2 Button 2"		 , BIT_DIGITAL	, Kaneko16InputPort1 + 5, "p2 fire 2" },
361 	{"P2 Button 3"		 , BIT_DIGITAL	, Kaneko16InputPort2 + 4, "p2 fire 3" },
362 	{"P2 Button 4"		 , BIT_DIGITAL	, Kaneko16InputPort2 + 5, "p2 fire 4" },
363 
364 	{"Reset"			 , BIT_DIGITAL	, &Kaneko16Reset		, "reset"	  },
365 	{"Service"			 , BIT_DIGITAL	, Kaneko16InputPort2 + 6, "service"   },
366 	{"Dip A"			 , BIT_DIPSWITCH, Kaneko16Dip + 0		, "dip"	      },
367 };
368 
369 STDINPUTINFO(Shogwarr)
370 
371 static struct BurnInputInfo BrapboysInputList[] = {
372 	{"P1 Coin"			 , BIT_DIGITAL	, Kaneko16InputPort0 + 7, "p1 coin"   },
373 	{"P1 Start"			 , BIT_DIGITAL	, Kaneko16InputPort0 + 6, "p1 start"  },
374 	{"P1 Up"			 , BIT_DIGITAL	, Kaneko16InputPort0 + 0, "p1 up"	  },
375 	{"P1 Down"			 , BIT_DIGITAL	, Kaneko16InputPort0 + 1, "p1 down"   },
376 	{"P1 Left"			 , BIT_DIGITAL	, Kaneko16InputPort0 + 2, "p1 left"   },
377 	{"P1 Right"			 , BIT_DIGITAL	, Kaneko16InputPort0 + 3, "p1 right"  },
378 	{"P1 Button 1"		 , BIT_DIGITAL	, Kaneko16InputPort0 + 4, "p1 fire 1" },
379 	{"P1 Button 2"		 , BIT_DIGITAL	, Kaneko16InputPort0 + 5, "p1 fire 2" },
380 
381 	{"P2 Coin"			 , BIT_DIGITAL	, Kaneko16InputPort1 + 7, "p2 coin"	  },
382 	{"P2 Start"			 , BIT_DIGITAL	, Kaneko16InputPort1 + 6, "p2 start"  },
383 	{"P2 Up"			 , BIT_DIGITAL	, Kaneko16InputPort1 + 0, "p2 up"     },
384 	{"P2 Down"			 , BIT_DIGITAL	, Kaneko16InputPort1 + 1, "p2 down"	  },
385 	{"P2 Left"			 , BIT_DIGITAL	, Kaneko16InputPort1 + 2, "p2 left"	  },
386 	{"P2 Right"			 , BIT_DIGITAL	, Kaneko16InputPort1 + 3, "p2 right"  },
387 	{"P2 Button 1"		 , BIT_DIGITAL	, Kaneko16InputPort1 + 4, "p2 fire 1" },
388 	{"P2 Button 2"		 , BIT_DIGITAL	, Kaneko16InputPort1 + 5, "p2 fire 2" },
389 
390 	{"P3 Coin"			 , BIT_DIGITAL	, Kaneko16InputPort2 + 7, "p3 coin"	  },
391 	{"P3 Start"			 , BIT_DIGITAL	, Kaneko16InputPort2 + 6, "p3 start"  },
392 	{"P3 Up"			 , BIT_DIGITAL	, Kaneko16InputPort2 + 0, "p3 up"	  },
393 	{"P3 Down"			 , BIT_DIGITAL	, Kaneko16InputPort2 + 1, "p3 down"	  },
394 	{"P3 Left"			 , BIT_DIGITAL	, Kaneko16InputPort2 + 2, "p3 left"	  },
395 	{"P3 Right"			 , BIT_DIGITAL	, Kaneko16InputPort2 + 3, "p3 right"  },
396 	{"P3 Button 1"		 , BIT_DIGITAL	, Kaneko16InputPort2 + 4, "p3 fire 1" },
397 	{"P3 Button 2"		 , BIT_DIGITAL	, Kaneko16InputPort2 + 5, "p3 fire 2" },
398 
399 	{"Reset"			 , BIT_DIGITAL	, &Kaneko16Reset		, "reset"	  },
400 	{"Dip A"			 , BIT_DIPSWITCH, Kaneko16Dip + 0		, "dip"		  },
401 };
402 
STDINPUTINFO(Brapboys)403 STDINPUTINFO(Brapboys)
404 
405 inline void Kaneko16ClearOpposites(UINT8* nJoystickInputs)
406 {
407 	if ((*nJoystickInputs & 0x03) == 0x03) {
408 		*nJoystickInputs &= ~0x03;
409 	}
410 	if ((*nJoystickInputs & 0x0c) == 0x0c) {
411 		*nJoystickInputs &= ~0x0c;
412 	}
413 }
414 
Kaneko16MakeInputs()415 inline void Kaneko16MakeInputs()
416 {
417 	// Reset Inputs
418 	Kaneko16Input[0] = Kaneko16Input[1] = Kaneko16Input[2] = Kaneko16Input[3] = 0x00;
419 
420 	// Compile Digital Inputs
421 	for (INT32 i = 0; i < 8; i++) {
422 		Kaneko16Input[0] |= (Kaneko16InputPort0[i] & 1) << i;
423 		Kaneko16Input[1] |= (Kaneko16InputPort1[i] & 1) << i;
424 		Kaneko16Input[2] |= (Kaneko16InputPort2[i] & 1) << i;
425 		Kaneko16Input[3] |= (Kaneko16InputPort3[i] & 1) << i;
426 	}
427 
428 	// Clear Opposites
429 	Kaneko16ClearOpposites(&Kaneko16Input[0]);
430 	Kaneko16ClearOpposites(&Kaneko16Input[1]);
431 
432 	if (Brapboys)
433 		Kaneko16ClearOpposites(&Kaneko16Input[2]);
434 }
435 
436 /*==============================================================================================
437 Dip Switch Definitions
438 ===============================================================================================*/
439 
440 static struct BurnDIPInfo BerlwallDIPList[]=
441 {
442 	// Default Values
443 	{0x16, 0xff, 0xff, 0xff, NULL                      			  },
444 	{0x17, 0xff, 0xff, 0xff, NULL                                 },
445 
446 	// Dip 1
447 	{0   , 0xfe, 0   , 2   , "Screen Direction"                   },
448 	{0x16, 0x01, 0x01, 0x01, "Normal"                             },
449 	{0x16, 0x01, 0x01, 0x00, "Reverse"                            },
450 
451 	{0   , 0xfe, 0   , 8   , "Coin Slot A"                        },
452 	{0x16, 0x01, 0x1c, 0x1c, "1 Coin  1 Credit"                   },
453 	{0x16, 0x01, 0x1c, 0x18, "1 Coins 2 Credits"                  },
454 	{0x16, 0x01, 0x1c, 0x14, "1 Coins 3 Credits"                  },
455 	{0x16, 0x01, 0x1c, 0x10, "1 Coins 4 Credits"                  },
456 	{0x16, 0x01, 0x1c, 0x0c, "2 Coins 1 Credit"                   },
457 	{0x16, 0x01, 0x1c, 0x08, "2 Coin  3 Credits"                  },
458 	{0x16, 0x01, 0x1c, 0x04, "3 Coins 1 Credit"                   },
459 	{0x16, 0x01, 0x1c, 0x00, "4 Coins 1 Credit"                   },
460 
461 	{0   , 0xfe, 0   , 8   , "Coin Slot B"                        },
462 	{0x16, 0x01, 0xe0, 0xe0, "1 Coin  1 Credit"                   },
463 	{0x16, 0x01, 0xe0, 0xc0, "1 Coins 2 Credits"                  },
464 	{0x16, 0x01, 0xe0, 0xa0, "1 Coins 3 Credits"                  },
465 	{0x16, 0x01, 0xe0, 0x80, "1 Coins 4 Credits"                  },
466 	{0x16, 0x01, 0xe0, 0x60, "2 Coins 1 Credit"                   },
467 	{0x16, 0x01, 0xe0, 0x40, "2 Coin  3 Credits"                  },
468 	{0x16, 0x01, 0xe0, 0x20, "1 Coin  5 Credits"                  },
469 	{0x16, 0x01, 0xe0, 0x00, "1 Coin  6 Credits"                  },
470 
471 	// Dip 2
472 	{0   , 0xfe, 0   , 4   , "Game Level"                         },
473 	{0x17, 0x01, 0x03, 0x03, "Standard"                           },
474 	{0x17, 0x01, 0x03, 0x02, "Easy"                               },
475 	{0x17, 0x01, 0x03, 0x01, "Difficult"                          },
476 	{0x17, 0x01, 0x03, 0x00, "Very Difficult"                     },
477 
478 	{0   , 0xfe, 0   , 4   , "Number of Players"                  },
479 	{0x17, 0x01, 0x0c, 0x0c, "3"                                  },
480 	{0x17, 0x01, 0x0c, 0x08, "2"                                  },
481 	{0x17, 0x01, 0x0c, 0x04, "5"                                  },
482 	{0x17, 0x01, 0x0c, 0x00, "7"                                  },
483 
484 	{0   , 0xfe, 0   , 4   , "Language Type"                      },
485 	{0x17, 0x01, 0x30, 0x30, "English"                            },
486 	{0x17, 0x01, 0x30, 0x20, "Italy"                              },
487 	{0x17, 0x01, 0x30, 0x10, "Germany"                            },
488 	{0x17, 0x01, 0x30, 0x00, "Pause Mode"                         },
489 
490 	{0   , 0xfe, 0   , 2   , "Demonstration Sound"                },
491 	{0x17, 0x01, 0x40, 0x00, "Off"                                },
492 	{0x17, 0x01, 0x40, 0x40, "On"                                 },
493 
494 	{0   , 0xfe, 0   , 2   , "Testmode Switch"                    },
495 	{0x17, 0x01, 0x80, 0x80, "Normal Game"                        },
496 	{0x17, 0x01, 0x80, 0x00, "Testmode"                           },
497 
498 	{0   , 0xfe, 0   ,    2, "Disable Background Fading (HACK)"   },
499 	{0x18, 0x01, 0x01, 0x00, "Off"				      },
500 	{0x18, 0x01, 0x01, 0x01, "On"				      },
501 };
502 
503 STDDIPINFO(Berlwall)
504 
505 static struct BurnDIPInfo BerlwalltDIPList[]=
506 {
507 	// Default Values
508 	{0x16, 0xff, 0xff, 0xff, NULL                                 },
509 	{0x17, 0xff, 0xff, 0xff, NULL                                 },
510 
511 	// Dip 1
512 	{0   , 0xfe, 0   , 2   , "Screen Direction"                   },
513 	{0x16, 0x01, 0x01, 0x01, "Normal"                             },
514 	{0x16, 0x01, 0x01, 0x00, "Reverse"                            },
515 
516 	{0   , 0xfe, 0   , 8   , "Coin Slot A"                        },
517 	{0x16, 0x01, 0x1c, 0x1c, "1 Coin  1 Credit"                   },
518 	{0x16, 0x01, 0x1c, 0x18, "1 Coins 2 Credits"                  },
519 	{0x16, 0x01, 0x1c, 0x14, "1 Coins 3 Credits"                  },
520 	{0x16, 0x01, 0x1c, 0x10, "1 Coins 4 Credits"                  },
521 	{0x16, 0x01, 0x1c, 0x0c, "2 Coins 1 Credit"                   },
522 	{0x16, 0x01, 0x1c, 0x08, "2 Coin  3 Credits"                  },
523 	{0x16, 0x01, 0x1c, 0x04, "3 Coins 1 Credit"                   },
524 	{0x16, 0x01, 0x1c, 0x00, "4 Coins 1 Credit"                   },
525 
526 	{0   , 0xfe, 0   , 8   , "Coin Slot B"                        },
527 	{0x16, 0x01, 0xe0, 0xe0, "1 Coin  1 Credit"                   },
528 	{0x16, 0x01, 0xe0, 0xc0, "1 Coins 2 Credits"                  },
529 	{0x16, 0x01, 0xe0, 0xa0, "1 Coins 3 Credits"                  },
530 	{0x16, 0x01, 0xe0, 0x80, "1 Coins 4 Credits"                  },
531 	{0x16, 0x01, 0xe0, 0x60, "2 Coins 1 Credit"                   },
532 	{0x16, 0x01, 0xe0, 0x40, "2 Coin  3 Credits"                  },
533 	{0x16, 0x01, 0xe0, 0x20, "1 Coin  5 Credits"                  },
534 	{0x16, 0x01, 0xe0, 0x00, "1 Coin  6 Credits"                  },
535 
536 	// Dip 2
537 	{0   , 0xfe, 0   , 4   , "Game Level"                         },
538 	{0x17, 0x01, 0x03, 0x03, "Standard"                           },
539 	{0x17, 0x01, 0x03, 0x02, "Easy"                               },
540 	{0x17, 0x01, 0x03, 0x01, "Difficult"                          },
541 	{0x17, 0x01, 0x03, 0x00, "Very Difficult"                     },
542 
543 	{0   , 0xfe, 0   , 4   , "Number of Players"                  },
544 	{0x17, 0x01, 0x0c, 0x0c, "2"                                  },
545 	{0x17, 0x01, 0x0c, 0x08, "3"                                  },
546 	{0x17, 0x01, 0x0c, 0x04, "5"                                  },
547 	{0x17, 0x01, 0x0c, 0x00, "1"                                  },
548 
549 	{0   , 0xfe, 0   , 4   , "Language Type"                      },
550 	{0x17, 0x01, 0x30, 0x30, "English"                            },
551 	{0x17, 0x01, 0x30, 0x20, "Italy"                              },
552 	{0x17, 0x01, 0x30, 0x10, "Germany"                            },
553 	{0x17, 0x01, 0x30, 0x00, "Pause Mode"                         },
554 
555 	{0   , 0xfe, 0   , 2   , "Demonstration Sound"                },
556 	{0x17, 0x01, 0x40, 0x00, "Off"                                },
557 	{0x17, 0x01, 0x40, 0x40, "On"                                 },
558 
559 	{0   , 0xfe, 0   , 2   , "Testmode Switch"                    },
560 	{0x17, 0x01, 0x80, 0x80, "Normal Game"                        },
561 	{0x17, 0x01, 0x80, 0x00, "Testmode"                           },
562 
563 	{0   , 0xfe, 0   ,    2, "Disable Background Fading (HACK)"   },
564 	{0x18, 0x01, 0x01, 0x00, "Off"				      },
565 	{0x18, 0x01, 0x01, 0x01, "On"				      },
566 };
567 
568 STDDIPINFO(Berlwallt)
569 
570 static struct BurnDIPInfo PackbangDIPList[]=
571 {
572 	{0x16, 0xff, 0xff, 0xff, NULL								  },
573 	{0x17, 0xff, 0xff, 0xff, NULL								  },
574 	{0x18, 0xff, 0xff, 0x00, NULL								  },
575 
576 	{0   , 0xfe, 0   ,    2, "Flip Screen"						  },
577 	{0x16, 0x01, 0x01, 0x01, "Off"								  },
578 	{0x16, 0x01, 0x01, 0x00, "On"								  },
579 
580 	{0   , 0xfe, 0   ,    8, "Coin A"							  },
581 	{0x16, 0x01, 0x1c, 0x00, "4 Coins 1 Credits"				  },
582 	{0x16, 0x01, 0x1c, 0x04, "3 Coins 1 Credits"				  },
583 	{0x16, 0x01, 0x1c, 0x0c, "2 Coins 1 Credits"				  },
584 	{0x16, 0x01, 0x1c, 0x1c, "1 Coin  1 Credits"				  },
585 	{0x16, 0x01, 0x1c, 0x08, "2 Coins 3 Credits"				  },
586 	{0x16, 0x01, 0x1c, 0x18, "1 Coin  2 Credits"				  },
587 	{0x16, 0x01, 0x1c, 0x14, "1 Coin  3 Credits"				  },
588 	{0x16, 0x01, 0x1c, 0x10, "1 Coin  4 Credits"				  },
589 
590 	{0   , 0xfe, 0   ,    8, "Coin B"							  },
591 	{0x16, 0x01, 0xe0, 0x60, "2 Coins 1 Credits"				  },
592 	{0x16, 0x01, 0xe0, 0xe0, "1 Coin  1 Credits"				  },
593 	{0x16, 0x01, 0xe0, 0x40, "2 Coins 3 Credits"				  },
594 	{0x16, 0x01, 0xe0, 0xc0, "1 Coin  2 Credits"				  },
595 	{0x16, 0x01, 0xe0, 0xa0, "1 Coin  3 Credits"				  },
596 	{0x16, 0x01, 0xe0, 0x80, "1 Coin  4 Credits"				  },
597 	{0x16, 0x01, 0xe0, 0x20, "1 Coin  5 Credits"				  },
598 	{0x16, 0x01, 0xe0, 0x00, "1 Coin  6 Credits"				  },
599 
600 	{0   , 0xfe, 0   ,    4, "Difficulty"						  },
601 	{0x17, 0x01, 0x03, 0x02, "Easy"								  },
602 	{0x17, 0x01, 0x03, 0x03, "Normal"							  },
603 	{0x17, 0x01, 0x03, 0x01, "Hard"								  },
604 	{0x17, 0x01, 0x03, 0x00, "Hardest"							  },
605 
606 	{0   , 0xfe, 0   ,    2, "Timer Speed"						  },
607 	{0x17, 0x01, 0x04, 0x00, "Slow"								  },
608 	{0x17, 0x01, 0x04, 0x04, "Standard"							  },
609 
610 	{0   , 0xfe, 0   ,    4, "Language"							  },
611 	{0x17, 0x01, 0x18, 0x00, "Invalid"							  },
612 	{0x17, 0x01, 0x18, 0x08, "Korea"							  },
613 	{0x17, 0x01, 0x18, 0x10, "Japan"							  },
614 	{0x17, 0x01, 0x18, 0x18, "World"							  },
615 
616 	{0   , 0xfe, 0   ,    2, "Free Play"						  },
617 	{0x17, 0x01, 0x20, 0x20, "Off"								  },
618 	{0x17, 0x01, 0x20, 0x00, "On"								  },
619 
620 	{0   , 0xfe, 0   ,    2, "Demo Sounds"						  },
621 	{0x17, 0x01, 0x40, 0x00, "Off"								  },
622 	{0x17, 0x01, 0x40, 0x40, "On"								  },
623 
624 	{0   , 0xfe, 0   ,    2, "Service Mode"						  },
625 	{0x17, 0x01, 0x80, 0x80, "Off"								  },
626 	{0x17, 0x01, 0x80, 0x00, "On"								  },
627 
628 	{0   , 0xfe, 0   ,    2, "Disable Background Fading (HACK)"						  },
629 	{0x18, 0x01, 0x01, 0x00, "Off"								  },
630 	{0x18, 0x01, 0x01, 0x01, "On"								  },
631 };
632 
633 STDDIPINFO(Packbang)
634 
635 static struct BurnDIPInfo BlazeonDIPList[]=
636 {
637 	// Default Values
638 	{0x14, 0xff, 0xff, 0xff, NULL                                 },
639 	{0x15, 0xff, 0xff, 0xff, NULL                                 },
640 
641 	// Dip 1
642 	{0   , 0xfe, 0   , 4   , "Difficulty"                         },
643 	{0x14, 0x01, 0x03, 0x03, "Standard"                           },
644 	{0x14, 0x01, 0x03, 0x02, "Easy"                               },
645 	{0x14, 0x01, 0x03, 0x01, "Hard"                               },
646 	{0x14, 0x01, 0x03, 0x00, "Strong"                             },
647 
648 	{0   , 0xfe, 0   , 4   , "Number of Players"                  },
649 	{0x14, 0x01, 0x0c, 0x00, "2"                                  },
650 	{0x14, 0x01, 0x0c, 0x0c, "3"                                  },
651 	{0x14, 0x01, 0x0c, 0x08, "4"                                  },
652 	{0x14, 0x01, 0x0c, 0x04, "5"                                  },
653 
654 	{0   , 0xfe, 0   , 2   , "Demonstration Sound"                },
655 	{0x14, 0x01, 0x10, 0x00, "Off"                                },
656 	{0x14, 0x01, 0x10, 0x10, "On"                                 },
657 
658 	{0   , 0xfe, 0   , 2   , "Service Mode"                       },
659 	{0x14, 0x01, 0x80, 0x80, "Off"                                },
660 	{0x14, 0x01, 0x80, 0x00, "On"                                 },
661 
662 	// Dip 2
663 	{0   , 0xfe, 0   , 16   , "Coin Rate Slot A"                  },
664 	{0x15, 0x01, 0x0f, 0x00, "1 Coin 1 Play"                      },
665 	{0x15, 0x01, 0x0f, 0x01, "2 Coin 3 Play"                      },
666 	{0x15, 0x01, 0x0f, 0x02, "4 Coin 5 Play"                      },
667 	{0x15, 0x01, 0x0f, 0x03, "5 Coin 6 Play"                      },
668 	{0x15, 0x01, 0x0f, 0x04, "4 Coin 3 Play"                      },
669 	{0x15, 0x01, 0x0f, 0x05, "6 Coin 3 Play"                      },
670 	{0x15, 0x01, 0x0f, 0x06, "2 Coin 3 Play"                      },
671 	{0x15, 0x01, 0x0f, 0x07, "4 Coin 1 Play"                      },
672 	{0x15, 0x01, 0x0f, 0x08, "3 Coin 1 Play"                      },
673 	{0x15, 0x01, 0x0f, 0x09, "2 Coin 1 Play"                      },
674 	{0x15, 0x01, 0x0f, 0x0a, "1 Coin 6 Play"                      },
675 	{0x15, 0x01, 0x0f, 0x0b, "1 Coin 5 Play"                      },
676 	{0x15, 0x01, 0x0f, 0x0c, "1 Coin 4 Play"                      },
677 	{0x15, 0x01, 0x0f, 0x0d, "1 Coin 3 Play"                      },
678 	{0x15, 0x01, 0x0f, 0x0e, "1 Coin 2 Play"                      },
679 	{0x15, 0x01, 0x0f, 0x0f, "1 Coin 1 Play"                      },
680 
681 	{0   , 0xfe, 0   , 16   , "Coin Rate Slot B"                  },
682 	{0x15, 0x01, 0xf0, 0x00, "1 Coin 1 Play"                      },
683 	{0x15, 0x01, 0xf0, 0x10, "2 Coin 3 Play"                      },
684 	{0x15, 0x01, 0xf0, 0x20, "4 Coin 5 Play"                      },
685 	{0x15, 0x01, 0xf0, 0x30, "5 Coin 6 Play"                      },
686 	{0x15, 0x01, 0xf0, 0x40, "4 Coin 3 Play"                      },
687 	{0x15, 0x01, 0xf0, 0x50, "6 Coin 3 Play"                      },
688 	{0x15, 0x01, 0xf0, 0x60, "2 Coin 3 Play"                      },
689 	{0x15, 0x01, 0xf0, 0x70, "4 Coin 1 Play"                      },
690 	{0x15, 0x01, 0xf0, 0x80, "3 Coin 1 Play"                      },
691 	{0x15, 0x01, 0xf0, 0x90, "2 Coin 1 Play"                      },
692 	{0x15, 0x01, 0xf0, 0xa0, "1 Coin 6 Play"                      },
693 	{0x15, 0x01, 0xf0, 0xb0, "1 Coin 5 Play"                      },
694 	{0x15, 0x01, 0xf0, 0xc0, "1 Coin 4 Play"                      },
695 	{0x15, 0x01, 0xf0, 0xd0, "1 Coin 3 Play"                      },
696 	{0x15, 0x01, 0xf0, 0xe0, "1 Coin 2 Play"                      },
697 	{0x15, 0x01, 0xf0, 0xf0, "1 Coin 1 Play"                      },
698 };
699 
700 STDDIPINFO(Blazeon)
701 
702 static struct BurnDIPInfo BloodwarDIPList[]=
703 {
704 	// Default Values
705 	{0x17, 0xff, 0xff, 0x01, NULL                                 },
706 
707 	// Dip 1
708 	{0   , 0xfe, 0   , 2   , "Demo Sound"                         },
709 	{0x17, 0x01, 0x01, 0x00, "Off"                                },
710 	{0x17, 0x01, 0x01, 0x01, "On"                                 },
711 
712 	{0   , 0xfe, 0   , 2   , "Service Mode"                       },
713 	{0x17, 0x01, 0x02, 0x00, "Off"                                },
714 	{0x17, 0x01, 0x02, 0x02, "On"                                 },
715 
716 	{0   , 0xfe, 0   , 2   , "Screen Flip"                        },
717 	{0x17, 0x01, 0x04, 0x00, "Normal"                             },
718 	{0x17, 0x01, 0x04, 0x04, "Reverse"                            },
719 
720 	{0   , 0xfe, 0   , 8   , "Difficulty"                         },
721 	{0x17, 0x01, 0x38, 0x00, "1 Easy"                             },
722 	{0x17, 0x01, 0x38, 0x08, "2"                                  },
723 	{0x17, 0x01, 0x38, 0x10, "3"                                  },
724 	{0x17, 0x01, 0x38, 0x18, "4"                                  },
725 	{0x17, 0x01, 0x38, 0x20, "5"                                  },
726 	{0x17, 0x01, 0x38, 0x28, "6"                                  },
727 	{0x17, 0x01, 0x38, 0x30, "7"                                  },
728 	{0x17, 0x01, 0x38, 0x38, "8 Hard"                             },
729 
730 	{0   , 0xfe, 0   , 2   , "Join During Game"                   },
731 	{0x17, 0x01, 0x40, 0x40, "Impossible"                         },
732 	{0x17, 0x01, 0x40, 0x00, "Possible"                           },
733 
734 	{0   , 0xfe, 0   , 2   , "Continue Coin"                      },
735 	{0x17, 0x01, 0x80, 0x00, "Normal"                             },
736 	{0x17, 0x01, 0x80, 0x80, "Continue coin"                      },
737 };
738 
739 STDDIPINFO(Bloodwar)
740 
741 static struct BurnDIPInfo BonkadvDIPList[]=
742 {
743 	// Default Values
744 	{0x14, 0xff, 0xff, 0x10, NULL                                 },
745 
746 	// Dip 1
747 	{0   , 0xfe, 0   , 2   , "Screen Direction"                   },
748 	{0x14, 0x01, 0x01, 0x00, "Standard"                           },
749 	{0x14, 0x01, 0x01, 0x01, "Reverse"                            },
750 
751 	{0   , 0xfe, 0   , 2   , "Free Play"                          },
752 	{0x14, 0x01, 0x02, 0x00, "Off"                                },
753 	{0x14, 0x01, 0x02, 0x02, "On"                                 },
754 
755 	{0   , 0xfe, 0   , 2   , "Demo Sound"                         },
756 	{0x14, 0x01, 0x04, 0x04, "Off"                                },
757 	{0x14, 0x01, 0x04, 0x00, "On"                                 },
758 
759 	{0   , 0xfe, 0   , 2   , "Title Level Display"                },
760 	{0x14, 0x01, 0x10, 0x00, "Off"                                },
761 	{0x14, 0x01, 0x10, 0x10, "On"                                 },
762 
763 	{0   , 0xfe, 0   , 2   , "Service Mode"                       },
764 	{0x14, 0x01, 0x80, 0x00, "Off"                                },
765 	{0x14, 0x01, 0x80, 0x80, "On"                                 },
766 };
767 
768 STDDIPINFO(Bonkadv)
769 
770 static struct BurnDIPInfo ExplbrkrDIPList[]=
771 {
772 	// Default Values
773 	{0x12, 0xff, 0xff, 0xff, NULL                                 },
774 
775 	// Dip 1
776 	{0   , 0xfe, 0   , 2   , "Service Mode"                       },
777 	{0x12, 0x01, 0x02, 0x02, "Off"                                },
778 	{0x12, 0x01, 0x02, 0x00, "On"                                 },
779 };
780 
781 STDDIPINFO(Explbrkr)
782 
783 static struct BurnDIPInfo GtmrDIPList[]=
784 {
785 	// Default Values
786 	{0x14, 0xff, 0xff, 0x00, NULL                                 },
787 
788 	// Dip 1
789 	{0   , 0xfe, 0   , 2   , "Service Mode"                       },
790 	{0x14, 0x01, 0x01, 0x00, "Off"                                },
791 	{0x14, 0x01, 0x01, 0x01, "On"                                 },
792 
793 	{0   , 0xfe, 0   , 2   , "Flip Screen"                        },
794 	{0x14, 0x01, 0x02, 0x00, "Off"                                },
795 	{0x14, 0x01, 0x02, 0x02, "On"                                 },
796 
797 	{0   , 0xfe, 0   , 2   , "Cabinet"                            },
798 	{0x14, 0x01, 0x04, 0x00, "Upright"                            },
799 	{0x14, 0x01, 0x04, 0x04, "Cocktail"                           },
800 
801 	{0   , 0xfe, 0   , 4   , "Controls"                           },
802 	{0x14, 0x01, 0x18, 0x00, "1 Joystick"                         },
803 	{0x14, 0x01, 0x18, 0x10, "2 Joysticks"                        },
804 	{0x14, 0x01, 0x18, 0x08, "Wheel (360)"                        },
805 	{0x14, 0x01, 0x18, 0x18, "Wheel (270)"                        },
806 
807 	{0   , 0xfe, 0   , 2   , "Use Brake"                          },
808 	{0x14, 0x01, 0x20, 0x20, "Off"                                },
809 	{0x14, 0x01, 0x20, 0x00, "On"                                 },
810 
811 	{0   , 0xfe, 0   , 4   , "National Anthem & Flag"             },
812 	{0x14, 0x01, 0xc0, 0x00, "Use Memory"                         },
813 	{0x14, 0x01, 0xc0, 0x40, "Anthem Only"                        },
814 	{0x14, 0x01, 0xc0, 0x80, "Flag Only"                          },
815 	{0x14, 0x01, 0xc0, 0xc0, "None"                               },
816 };
817 
818 STDDIPINFO(Gtmr)
819 
820 static struct BurnDIPInfo Gtmr2DIPList[]=
821 {
822 	// Default Values
823 	{0x14, 0xff, 0xff, 0x00, NULL                                 },
824 
825 	// Dip 1
826 	{0   , 0xfe, 0   , 5   , "Communication"                      },
827 	{0x14, 0x01, 0x07, 0x00, "None"                               },
828 	{0x14, 0x01, 0x07, 0x01, "Machine 1"                          },
829 	{0x14, 0x01, 0x07, 0x02, "Machine 2"                          },
830 	{0x14, 0x01, 0x07, 0x03, "Machine 3"                          },
831 	{0x14, 0x01, 0x07, 0x04, "Machine 4"                          },
832 
833 	{0   , 0xfe, 0   , 4   , "Controls"                           },
834 	{0x14, 0x01, 0x18, 0x00, "Joystick"                           },
835 	{0x14, 0x01, 0x18, 0x10, "Wheel (360)"                        },
836 	{0x14, 0x01, 0x18, 0x08, "Wheel (270D)"                       },
837 	{0x14, 0x01, 0x18, 0x18, "Wheel (270A)"                       },
838 
839 	{0   , 0xfe, 0   , 2   , "Pedal Function"                     },
840 	{0x14, 0x01, 0x20, 0x00, "Microswitch"                        },
841 	{0x14, 0x01, 0x20, 0x20, "Potentiometer"                      },
842 
843 	{0   , 0xfe, 0   , 2   , "Flip Screen"                        },
844 	{0x14, 0x01, 0x40, 0x00, "Off"                                },
845 	{0x14, 0x01, 0x40, 0x40, "On"                                 },
846 
847 	{0   , 0xfe, 0   , 2   , "Service Mode"                       },
848 	{0x14, 0x01, 0x80, 0x00, "Off"                                },
849 	{0x14, 0x01, 0x80, 0x80, "On"                                 },
850 };
851 
852 STDDIPINFO(Gtmr2)
853 
854 static struct BurnDIPInfo MgcrystlDIPList[]=
855 {
856 	// Default Values
857 	{0x14, 0xff, 0xff, 0xff, NULL                                 },
858 
859 	// Dip 1
860 	{0   , 0xfe, 0   , 2   , "Flip Screen"                        },
861 	{0x14, 0x01, 0x01, 0x01, "Off"                                },
862 	{0x14, 0x01, 0x01, 0x00, "On"                                 },
863 
864 	{0   , 0xfe, 0   , 2   , "Service Mode"                       },
865 	{0x14, 0x01, 0x02, 0x02, "Off"                                },
866 	{0x14, 0x01, 0x02, 0x00, "On"                                 },
867 };
868 
869 STDDIPINFO(Mgcrystl)
870 
871 static struct BurnDIPInfo ShogwarrDIPList[]=
872 {
873 	{0x16, 0xff, 0xff, 0xff, NULL								  },
874 
875 	{0   , 0xfe, 0   ,    2, "Flip Screen"						  },
876 	{0x16, 0x01, 0x01, 0x01, "Off"								  },
877 	{0x16, 0x01, 0x01, 0x00, "On"								  },
878 
879 	{0   , 0xfe, 0   ,    2, "Service Mode"						  },
880 	{0x16, 0x01, 0x02, 0x02, "Off"								  },
881 	{0x16, 0x01, 0x02, 0x00, "On"								  },
882 
883 	{0   , 0xfe, 0   ,    2, "Demo Sounds"						  },
884 	{0x16, 0x01, 0x04, 0x00, "Off"								  },
885 	{0x16, 0x01, 0x04, 0x04, "On"								  },
886 
887 	{0   , 0xfe, 0   ,    8, "Difficulty"						  },
888 	{0x16, 0x01, 0x38, 0x38, "1 Easy"						      },
889 	{0x16, 0x01, 0x38, 0x30, "2"								  },
890 	{0x16, 0x01, 0x38, 0x28, "3"								  },
891 	{0x16, 0x01, 0x38, 0x20, "4 Normal"							  },
892 	{0x16, 0x01, 0x38, 0x18, "5"								  },
893 	{0x16, 0x01, 0x38, 0x10, "6"								  },
894 	{0x16, 0x01, 0x38, 0x08, "7"								  },
895 	{0x16, 0x01, 0x38, 0x00, "8 Hard"							  },
896 
897 	{0   , 0xfe, 0   ,    2, "Can Join During Game"				  },
898 	{0x16, 0x01, 0x40, 0x00, "Off"								  },
899 	{0x16, 0x01, 0x40, 0x40, "On"								  },
900 
901 	{0   , 0xfe, 0   ,    2, "Continue Coin"					  },
902 	{0x16, 0x01, 0x80, 0x80, "Off"								  },
903 	{0x16, 0x01, 0x80, 0x00, "On"								  },
904 };
905 
906 STDDIPINFO(Shogwarr)
907 
908 static struct BurnDIPInfo BrapboysDIPList[]=
909 {
910 	{0x19, 0xff, 0xff, 0xff, NULL								  },
911 
912 	{0   , 0xfe, 0   ,    2, "Flip Screen"						  },
913 	{0x19, 0x01, 0x01, 0x01, "Off"								  },
914 	{0x19, 0x01, 0x01, 0x00, "On"								  },
915 
916 	{0   , 0xfe, 0   ,    2, "Service Mode"						  },
917 	{0x19, 0x01, 0x02, 0x02, "Off"								  },
918 	{0x19, 0x01, 0x02, 0x00, "On"								  },
919 
920 	{0   , 0xfe, 0   ,    2, "Switch Test"						  },
921 	{0x19, 0x01, 0x04, 0x04, "Off"							      },
922 	{0x19, 0x01, 0x04, 0x00, "On"								  },
923 
924 	{0   , 0xfe, 0   ,    0, "Coin Slots"						  },
925 	{0x19, 0x01, 0x10, 0x10, "Separate Coins"					  },
926 	{0x19, 0x01, 0x10, 0x00, "Shared Coins"					 	  },
927 
928 	{0   , 0xfe, 0   ,    2, "Players"							  },
929 	{0x19, 0x01, 0x20, 0x20, "3"								  },
930 	{0x19, 0x01, 0x20, 0x00, "2"								  },
931 
932 	{0   , 0xfe, 0   ,    2, "Difficulty"						  },
933 	{0x19, 0x01, 0xc0, 0x80, "Easy"								  },
934 	{0x19, 0x01, 0xc0, 0xc0, "Normal"							  },
935 	{0x19, 0x01, 0xc0, 0x40, "Hard"								  },
936 	{0x19, 0x01, 0xc0, 0x00, "Very Hard"						  },
937 };
938 
939 STDDIPINFO(Brapboys)
940 
941 /*==============================================================================================
942 ROM Descriptions
943 ===============================================================================================*/
944 
945 static struct BurnRomInfo BerlwallRomDesc[] = {
946 	{ "bw100e_u23-01.u23", 	0x020000, 0x76b526ce, BRF_ESS | BRF_PRG }, //  0 68000 Program Code
947 	{ "bw101e_u39-01.u39", 	0x020000, 0x78fa7ef2, BRF_ESS | BRF_PRG }, //  1
948 
949 	{ "bw001.u84",         	0x080000, 0xbc927260, BRF_GRA },	   	   //  2 Sprites
950 	{ "bw002.u83",         	0x080000, 0x223f5465, BRF_GRA },	   	   //  3
951 #if !defined ROM_VERIFY
952 	{ "bw300.u82",         	0x020000, 0xb258737a, BRF_GRA },	   	   //  4 Masked players, Japanese text
953 #endif
954 
955 	{ "bw003.u77",         	0x080000, 0xfbb4b72d, BRF_GRA },	   	   //  5 Tiles (scrambled)
956 
957 	{ "bw004.u73",         	0x080000, 0x5300c34d, BRF_GRA },	   	   //  6 High Color Background
958 	{ "bw008.u65",         	0x080000, 0x9aaf2f2f, BRF_GRA },	       //  7 FIXED BITS (xxxxxxx0)
959 	{ "bw005.u74",         	0x080000, 0x16db6d43, BRF_GRA },	   	   //  8
960 	{ "bw009.u66",         	0x080000, 0x1151a0b0, BRF_GRA },	   	   //  9 FIXED BITS (xxxxxxx0)
961 	{ "bw006.u75",         	0x080000, 0x73a35d1f, BRF_GRA },	   	   // 10
962 	{ "bw00a.u67",         	0x080000, 0xf447dfc2, BRF_GRA },	   	   // 11 FIXED BITS (xxxxxxx0)
963 	{ "bw007.u76",         	0x080000, 0x97f85c87, BRF_GRA },	   	   // 12
964 	{ "bw00b.u68",         	0x080000, 0xb0a48225, BRF_GRA },	   	   // 13 FIXED BITS (xxxxxxx0)
965 
966 	{ "bw000.u46",         	0x040000, 0xd8fe869d, BRF_SND },		   // 14 Samples
967 
968 	{ "bw_u47.u47",        	0x000117, 0x00000000, BRF_OPT | BRF_NODUMP },
969 	{ "bw_u48.u48",        	0x000117, 0x00000000, BRF_OPT | BRF_NODUMP },
970 	{ "bw_u54.u54",        	0x000117, 0x00000000, BRF_OPT | BRF_NODUMP },
971 };
972 
973 
974 STD_ROM_PICK(Berlwall)
975 STD_ROM_FN(Berlwall)
976 
977 static struct BurnRomInfo BerlwalltRomDesc[] = {
978 	{ "bw100a.u23",        	0x020000, 0xe6bcb4eb, BRF_ESS | BRF_PRG }, //  0 68000 Program Code
979 	{ "bw101a.u39",        	0x020000, 0x38056fb2, BRF_ESS | BRF_PRG }, //  1
980 
981 	{ "bw001.u84",         	0x080000, 0xbc927260, BRF_GRA },	   	   //  2 Sprites
982 	{ "bw002.u83",         	0x080000, 0x223f5465, BRF_GRA },	   	   //  3
983 	{ "bw300.u82",         	0x020000, 0xb258737a, BRF_GRA },	   	   //  4 Masked players, Japanese text
984 
985 	{ "bw003.u77",         	0x080000, 0xfbb4b72d, BRF_GRA },	   	   //  5 Tiles (scrambled)
986 
987 	{ "bw004.u73",         	0x080000, 0x5300c34d, BRF_GRA },	   	   //  6 High Color Background
988 	{ "bw008.u65",         	0x080000, 0x9aaf2f2f, BRF_GRA },	   	   //  7 FIXED BITS (xxxxxxx0)
989 	{ "bw005.u74",         	0x080000, 0x16db6d43, BRF_GRA },	   	   //  8
990 	{ "bw009.u66",         	0x080000, 0x1151a0b0, BRF_GRA },	   	   //  9 FIXED BITS (xxxxxxx0)
991 	{ "bw006.u75",         	0x080000, 0x73a35d1f, BRF_GRA },	   	   // 10
992 	{ "bw00a.u67",         	0x080000, 0xf447dfc2, BRF_GRA },	   	   // 11 FIXED BITS (xxxxxxx0)
993 	{ "bw007.u76",         	0x080000, 0x97f85c87, BRF_GRA },	   	   // 12
994 	{ "bw00b.u68",         	0x080000, 0xb0a48225, BRF_GRA },	   	   // 13 FIXED BITS (xxxxxxx0)
995 
996 	{ "bw000.u46",         	0x040000, 0xd8fe869d, BRF_SND },		   // 14 Samples
997 
998 	{ "bw_u47.u47",        	0x000117, 0x00000000, BRF_OPT | BRF_NODUMP },
999 	{ "bw_u48.u48",        	0x000117, 0x00000000, BRF_OPT | BRF_NODUMP },
1000 	{ "bw_u54.u54",        	0x000117, 0x00000000, BRF_OPT | BRF_NODUMP },
1001 };
1002 
1003 
1004 STD_ROM_PICK(Berlwallt)
1005 STD_ROM_FN(Berlwallt)
1006 
1007 static struct BurnRomInfo BerlwallkRomDesc[] = {
1008 	{ "bw100k.u23",        	0x020000, 0x0ce1d336, BRF_ESS | BRF_PRG }, //  0 68000 Program Code
1009 	{ "bw101k.u39",        	0x020000, 0x3355be65, BRF_ESS | BRF_PRG }, //  1
1010 
1011 	{ "bw001.u84",         	0x080000, 0xbc927260, BRF_GRA },	   	   //  2 Sprites
1012 	{ "bw002.u83",         	0x080000, 0x223f5465, BRF_GRA },	   	   //  3
1013 	{ "bw300k.u82",        	0x020000, 0xb8de79d7, BRF_GRA },	   	   //  4
1014 
1015 	{ "bw003.u77",         	0x080000, 0xfbb4b72d, BRF_GRA },	   	   //  5 Tiles (scrambled)
1016 
1017 	{ "bw004.u73",         	0x080000, 0x5300c34d, BRF_GRA },	   	   //  6 High Color Background
1018 	{ "bw008.u65",         	0x080000, 0x9aaf2f2f, BRF_GRA },	   	   //  7 FIXED BITS (xxxxxxx0)
1019 	{ "bw005.u74",         	0x080000, 0x16db6d43, BRF_GRA },	   	   //  8
1020 	{ "bw009.u66",         	0x080000, 0x1151a0b0, BRF_GRA },	   	   //  9 FIXED BITS (xxxxxxx0)
1021 	{ "bw006.u75",         	0x080000, 0x73a35d1f, BRF_GRA },	   	   // 10
1022 	{ "bw00a.u67",         	0x080000, 0xf447dfc2, BRF_GRA },	   	   // 11 FIXED BITS (xxxxxxx0)
1023 	{ "bw007.u76",         	0x080000, 0x97f85c87, BRF_GRA },	   	   // 12
1024 	{ "bw00b.u68",         	0x080000, 0xb0a48225, BRF_GRA },	   	   // 13 FIXED BITS (xxxxxxx0)
1025 
1026 	{ "bw000k.u46",        	0x040000, 0x52e81a50, BRF_SND },		   // 14 Samples
1027 
1028 	{ "bw_u47.u47",        	0x000117, 0x00000000, BRF_OPT | BRF_NODUMP },
1029 	{ "bw_u48.u48",        	0x000117, 0x00000000, BRF_OPT | BRF_NODUMP },
1030 	{ "bw_u54.u54",        	0x000117, 0x00000000, BRF_OPT | BRF_NODUMP },
1031 };
1032 
1033 
1034 STD_ROM_PICK(Berlwallk)
1035 STD_ROM_FN(Berlwallk)
1036 
1037 static struct BurnRomInfo PackbangRomDesc[] = {
1038 	/* same PCB as Berlin Wall - BW-002 */
1039 	{ "bbp0x3.u23",     	0x020000, 0x105e978a, BRF_ESS | BRF_PRG }, //  0 68000 Program Code /* hand written checksum on label - 527B */
1040 	{ "bbp1x3.u39",     	0x020000, 0x465d36f5, BRF_ESS | BRF_PRG }, //  1 					/* hand written checksum on label - C5C8 */
1041 
1042    	{ "bb.u84",         		 0x080000, 0x97837aaa, BRF_GRA }, 	   //  2 Sprites
1043 	{ "pb_spr_ext_9_20_ver.u83", 0x040000, 0x666a1217, BRF_GRA },  	   //  3					/* hand written label plus checksum BA63 */
1044 
1045 	{ "bbbox1.u77",     	0x080000, 0xb2ffd081, BRF_GRA },		   //  4 Titles (scrambled) /* 1ST AND 2ND HALF IDENTICAL */
1046 
1047 	{ "bb.u73",         	0x080000, 0x896d88cb, BRF_GRA },		   //  5 High Color Background
1048 	{ "bb.u65",         	0x080000, 0xfe17c5b5, BRF_GRA }, 		   //  6 FIXED BITS (xxxxxxx0)
1049 	{ "bb.u74",         	0x080000, 0xb01e77b9, BRF_GRA },		   //  7
1050 	{ "bb.u66",         	0x080000, 0xcaec5098, BRF_GRA }, 		   //  8 FIXED BITS (xxxxxxx0)
1051 	{ "bb.u75",         	0x080000, 0x5cb4669f, BRF_GRA },		   //  9
1052 	{ "bb.u67",         	0x080000, 0xce5c9417, BRF_GRA }, 		   // 10 FIXED BITS (xxxxxxx0)
1053 
1054 	{ "bw000.u46",      	0x040000, 0xd8fe869d, BRF_SND }, 		   // 11 Samples
1055 };
1056 
1057 
1058 STD_ROM_PICK(Packbang)
1059 STD_ROM_FN(Packbang)
1060 
1061 static struct BurnRomInfo BlazeonRomDesc[] = {
1062 	{ "bz-prg1.u80",       	0x040000, 0x3d79aa70, BRF_ESS | BRF_PRG }, //  0 68000 Program Code
1063 	{ "bz-prg2.u81",       	0x040000, 0xa16d3b1e, BRF_ESS | BRF_PRG }, //  1
1064 
1065 	{ "bz_sp1.u20",        	0x100000, 0x0d5809a1, BRF_GRA },	   	   //  2 Sprites
1066 	{ "bz_sp2.u21",        	0x100000, 0x56ead2bd, BRF_GRA },	   	   //  3
1067 
1068 	{ "bz_bg.u2",          	0x100000, 0xfc67f19f, BRF_GRA },	   	   //  4 Tiles (scrambled)
1069 
1070 	{ "3.u45",             	0x020000, 0x52fe4c94, BRF_ESS | BRF_PRG }, //  5 Z80 Program Code
1071 
1072 	{ "bz_sp1.u68",        	0x100000, 0x0d5809a1, BRF_OPT },
1073 	{ "bz_sp2.u86",        	0x100000, 0x56ead2bd, BRF_OPT },
1074 };
1075 
1076 
1077 STD_ROM_PICK(Blazeon)
1078 STD_ROM_FN(Blazeon)
1079 
1080 static struct BurnRomInfo BlazeonjRomDesc[] = {
1081 	{ "bz_prg1.u80",       	0x040000, 0x8409e31d, BRF_ESS | BRF_PRG }, //  0 68000 Program Code
1082 	{ "bz_prg2.u81",       	0x040000, 0xb8a0a08b, BRF_ESS | BRF_PRG }, //  1
1083 
1084 	{ "bz_sp1.u20",        	0x100000, 0x0d5809a1, BRF_GRA },	   	   //  2 Sprites
1085 	{ "bz_sp2.u21",        	0x100000, 0x56ead2bd, BRF_GRA },	   	   //  3
1086 
1087 	{ "bz_bg.u2",          	0x100000, 0xfc67f19f, BRF_GRA },	   	   //  4 Tiles (scrambled)
1088 
1089 	{ "3.u45",             	0x020000, 0x52fe4c94, BRF_ESS | BRF_PRG }, //  5 Z80 Program Code
1090 
1091 	{ "bz_sp1.u68",        	0x100000, 0x0d5809a1, BRF_OPT },
1092 	{ "bz_sp2.u86",        	0x100000, 0x56ead2bd, BRF_OPT },
1093 };
1094 
1095 
1096 STD_ROM_PICK(Blazeonj)
1097 STD_ROM_FN(Blazeonj)
1098 
1099 static struct BurnRomInfo WingforcRomDesc[] = {
1100 	{ "e_2.24.u80",       	0x080000, 0x837e0726, BRF_ESS | BRF_PRG }, //  0 68000 Program Code
1101 	{ "o_2.24.u81",       	0x080000, 0xb6983437, BRF_ESS | BRF_PRG }, //  1
1102 
1103 	// two sprite chips, roms are doubled
1104 	{ "sp0m.u69",        	0x080000, 0x8be26a05, BRF_GRA },	   	   //  2 Sprites
1105 	{ "sp0m.u1",        	0x080000, 0x8be26a05, BRF_GRA },	   	   //  3
1106 
1107 	{ "sp1m.u1",        	0x080000, 0xad8c5b68, BRF_GRA },	   	   //  4
1108 	{ "sp1m.u69",        	0x080000, 0xad8c5b68, BRF_GRA },	   	   //  5
1109 
1110 	{ "sp2m.u20",        	0x080000, 0xb5994bda, BRF_GRA },	   	   //  6
1111 	{ "sp2m.u68",        	0x080000, 0xb5994bda, BRF_GRA },	   	   //  7
1112 
1113 	{ "sp3m.u20",        	0x080000, 0x889ddf72, BRF_GRA },	   	   //  8
1114 	{ "sp3m.u68",        	0x080000, 0x889ddf72, BRF_GRA },	   	   //  9
1115 
1116 	{ "bg0am.u2",	        0x080000, 0xf4276860, BRF_GRA },	   	   // 10 Tiles (scrambled)
1117 	{ "bg0bm.u2",	        0x080000, 0x9df92283, BRF_GRA },	   	   // 11 Tiles (scrambled)
1118 	{ "bg1am.u3",	        0x080000, 0xa44fdebb, BRF_GRA },	   	   // 12 Tiles (scrambled)
1119 	{ "bg1bm.u3",	        0x080000, 0xa9b9fc5d, BRF_GRA },	   	   // 13 Tiles (scrambled)
1120 
1121 	{ "s-drv_2.22.u45",     0x010000, 0xccdc2758, BRF_ESS | BRF_PRG }, // 14 Z80 Program Code
1122 
1123 	{ "pcm.u5",      	    0x080000, 0x233569fd, BRF_SND }, 		   // 15 Samples
1124 };
1125 
1126 
1127 STD_ROM_PICK(Wingforc)
1128 STD_ROM_FN(Wingforc)
1129 
1130 static struct BurnRomInfo BloodwarRomDesc[] = {
1131 	{ "ofp0f3.514",        	0x080000, 0x0c93da15, BRF_ESS | BRF_PRG }, //  0 68000 Program Code
1132 	{ "ofp1f3.513",        	0x080000, 0x894ecbe5, BRF_ESS | BRF_PRG }, //  1
1133 
1134 	{ "ofd0x3.124",        	0x020000, 0x399f2005, BRF_PRG | BRF_OPT }, //  2 MCU Code
1135 
1136 	{ "of-200-0201.8",     	0x200000, 0xbba63025, BRF_GRA },	   	   //  3 Sprites
1137 	{ "of-201-0202.9",     	0x200000, 0x4ffd9ddc, BRF_GRA },	   	   //  4
1138 	{ "of-202-0203.10",    	0x200000, 0xfbcc5363, BRF_GRA },	       //  5
1139 	{ "of-203-0204.11",    	0x200000, 0x8e818ce9, BRF_GRA },	       //  6
1140 	{ "of-204-0205.12",    	0x200000, 0x70c4a76b, BRF_GRA },	       //  7
1141 	{ "of-205-0206.13",    	0x200000, 0x80c667bb, BRF_GRA },	       //  8
1142 	{ "of-206-0207.14",    	0x200000, 0xc2028c97, BRF_GRA },	       //  9
1143 	{ "of-207-0208.15",    	0x200000, 0xb1f30c61, BRF_GRA },	       // 10
1144 	{ "of-208-0209.28",    	0x200000, 0xa8f29545, BRF_GRA },	       // 11
1145 	{ "of-209e-0210.16",   	0x100000, 0x93018468, BRF_GRA },	       // 12
1146 	{ "of-2090-2011.17",   	0x100000, 0x3fb226a1, BRF_GRA },	       // 13
1147 	{ "of-210e-0212.18",   	0x100000, 0x80f3fa1b, BRF_GRA },	       // 14
1148 	{ "of-2100-0213.19",   	0x100000, 0x8ca3a3d6, BRF_GRA },	       // 15
1149 	{ "of-211e-0214.20",   	0x100000, 0x8d3d96f7, BRF_GRA },	       // 16
1150 	{ "of-2110-0215.21",   	0x100000, 0x78268230, BRF_GRA },	       // 17
1151 	{ "of-212e-0216.22",   	0x100000, 0x5a013d99, BRF_GRA },	       // 18
1152 	{ "of-2120-0217.23",   	0x100000, 0x84ed25bd, BRF_GRA },	       // 19
1153 	{ "of-213e-0218.24",   	0x100000, 0x861bc5b1, BRF_GRA },	       // 20
1154 	{ "of-2130-0219.25",   	0x100000, 0xa79b8119, BRF_GRA },	       // 21
1155 	{ "of-214e-0220.26",   	0x100000, 0x43c622de, BRF_GRA },	       // 22
1156 	{ "of-2140-0221.27",   	0x100000, 0xd10bf03c, BRF_GRA },	       // 23
1157 
1158 	{ "of-300-0225.51",    	0x100000, 0xfbc3c08a, BRF_GRA },	       // 24 Tiles (scrambled)
1159 
1160 	{ "of-301-0226.55",    	0x100000, 0xfcf215de, BRF_GRA },	       // 25 Tiles (scrambled) (Layers 2 & 3)
1161 
1162 	{ "of-101-f-0223.101", 	0x100000, 0x295f3c93, BRF_SND },	       // 26 Samples, plus room for expansion
1163 
1164 	{ "of-100-0222.99",    	0x100000, 0x42b12269, BRF_SND },	       // 27 Samples
1165 };
1166 
1167 
1168 STD_ROM_PICK(Bloodwar)
1169 STD_ROM_FN(Bloodwar)
1170 
1171 static struct BurnRomInfo OedfightRomDesc[] = {
1172 	{ "ofp0j3.514",        	0x080000, 0x0c93da15, BRF_ESS | BRF_PRG }, //  0 68000 Program Code
1173 	{ "ofp1j3.513",        	0x080000, 0xcc59de49, BRF_ESS | BRF_PRG }, //  1
1174 
1175 	{ "ofd0x3.124",        	0x020000, 0x399f2005, BRF_PRG | BRF_OPT }, //  2 MCU Code
1176 
1177 	{ "of-200-0201.8",     	0x200000, 0xbba63025, BRF_GRA },	   	   //  3 Sprites
1178 	{ "of-201-0202.9",     	0x200000, 0x4ffd9ddc, BRF_GRA },	   	   //  4
1179 	{ "of-202-0203.10",    	0x200000, 0xfbcc5363, BRF_GRA },	       //  5
1180 	{ "of-203-0204.11",    	0x200000, 0x8e818ce9, BRF_GRA },	       //  6
1181 	{ "of-204-0205.12",    	0x200000, 0x70c4a76b, BRF_GRA },	       //  7
1182 	{ "of-205-0206.13",    	0x200000, 0x80c667bb, BRF_GRA },	       //  8
1183 	{ "of-206-0207.14",    	0x200000, 0xc2028c97, BRF_GRA },	       //  9
1184 	{ "of-207-0208.15",    	0x200000, 0xb1f30c61, BRF_GRA },	       // 10
1185 	{ "of-208-0209.28",    	0x200000, 0xa8f29545, BRF_GRA },	       // 11
1186 	{ "of-209e-0210.16",   	0x100000, 0x93018468, BRF_GRA },	       // 12
1187 	{ "of-2090-2011.17",   	0x100000, 0x3fb226a1, BRF_GRA },	       // 13
1188 	{ "of-210e-0212.18",   	0x100000, 0x80f3fa1b, BRF_GRA },	       // 14
1189 	{ "of-2100-0213.19",   	0x100000, 0x8ca3a3d6, BRF_GRA },	       // 15
1190 	{ "of-211e-0214.20",   	0x100000, 0x8d3d96f7, BRF_GRA },	       // 16
1191 	{ "of-2110-0215.21",   	0x100000, 0x78268230, BRF_GRA },	       // 17
1192 	{ "of-212e-0216.22",   	0x100000, 0x5a013d99, BRF_GRA },	       // 18
1193 	{ "of-2120-0217.23",   	0x100000, 0x84ed25bd, BRF_GRA },	       // 19
1194 	{ "of-213e-0218.24",   	0x100000, 0x861bc5b1, BRF_GRA },	       // 20
1195 	{ "of-2130-0219.25",   	0x100000, 0xa79b8119, BRF_GRA },	       // 21
1196 	{ "of-214e-0220.26",   	0x100000, 0x43c622de, BRF_GRA },	       // 22
1197 	{ "of-2140-0221.27",   	0x100000, 0xd10bf03c, BRF_GRA },	       // 23
1198 
1199 	{ "of-300-0225.51",    	0x100000, 0xfbc3c08a, BRF_GRA },	       // 24 Tiles (scrambled)
1200 
1201 	{ "of-301-0226.55",    	0x100000, 0xfcf215de, BRF_GRA },	       // 25 Tiles (scrambled) (Layers 2 & 3)
1202 
1203 	{ "of-101-j-0224.101", 	0x100000, 0x83a1f826, BRF_SND },	       // 26 Samples, plus room for expansion
1204 
1205 	{ "of-100-0222.99",    	0x100000, 0x42b12269, BRF_SND },	       // 27 Samples
1206 };
1207 
1208 
1209 STD_ROM_PICK(Oedfight)
1210 STD_ROM_FN(Oedfight)
1211 
1212 static struct BurnRomInfo BonkadvRomDesc[] = {
1213 	{ "prg.8",             	0x080000, 0xaf2e60f8, BRF_ESS | BRF_PRG }, //  0 68000 Program Code
1214 	{ "prg.7",             	0x080000, 0xa1cc6a78, BRF_ESS | BRF_PRG }, //  1
1215 
1216 	{ "mcu.124",           	0x020000, 0x9d4e2724, BRF_PRG | BRF_OPT }, //  2 MCU Code
1217 
1218 	{ "pc100101.37",       	0x200000, 0xc96e7c10, BRF_GRA },	       //  3 Sprites
1219 	{ "pc200102.40",       	0x100000, 0xc2b7a26a, BRF_GRA },	       //  4
1220 	{ "pc300103.38",       	0x100000, 0x51ee162c, BRF_GRA },	       //  5
1221 	{ "pc600106.42",       	0x080000, 0x25877026, BRF_GRA },	       //  6
1222 	{ "pc700107.43",       	0x080000, 0xbfe21c44, BRF_GRA },	       //  7
1223 
1224 	{ "pc400104.51",       	0x100000, 0x3b176f84, BRF_GRA },	       //  8 Tiles (scrambled)
1225 
1226 	{ "pc500105.55",       	0x100000, 0xbebb3edc, BRF_GRA },	       //  9 Tiles (scrambled) (Layers 2 & 3)
1227 
1228 	{ "pc604109.101",      	0x100000, 0x76025530, BRF_SND },		   // 10 Samples, plus room for expansion
1229 
1230 	{ "pc601106.99",       	0x100000, 0xa893651c, BRF_SND },		   // 11 Samples
1231 	{ "pc602107.100",      	0x100000, 0x0fbb23aa, BRF_SND },		   // 12
1232 	{ "pc603108.102",      	0x100000, 0x58458985, BRF_SND },		   // 13
1233 };
1234 
1235 
1236 STD_ROM_PICK(Bonkadv)
1237 STD_ROM_FN(Bonkadv)
1238 
1239 static struct BurnRomInfo ExplbrkrRomDesc[] = {
1240 	{ "ts100e.u18",        	0x040000, 0xcc84a985, BRF_ESS | BRF_PRG }, //  0 68000 Program Code
1241 	{ "ts101e.u19",        	0x040000, 0x88f4afb7, BRF_ESS | BRF_PRG }, //  1
1242 
1243 	{ "ts001e.u37",        	0x080000, 0x70b66e7e, BRF_GRA },	   	   //  2 Sprites
1244 	{ "ts000e.u38",        	0x080000, 0xa7a94143, BRF_GRA },	   	   //  3
1245 	{ "ts002e.u36",        	0x040000, 0x611271e6, BRF_GRA },	   	   //  4
1246 
1247 	{ "ts010.u4",          	0x100000, 0xdf935324, BRF_GRA },	   	   //  5 Tiles
1248 
1249 	{ "ts020.u33",         	0x100000, 0xeb58c35d, BRF_GRA },	   	   //  6 Tiles (Layers 2 & 3)
1250 
1251 	{ "ts030.u5",          	0x100000, 0x1d68e9d1, BRF_SND },		   //  7 OKI Sample ROM
1252 };
1253 
1254 
1255 STD_ROM_PICK(Explbrkr)
1256 STD_ROM_FN(Explbrkr)
1257 
1258 static struct BurnRomInfo ExplbrkrkRomDesc[] = {
1259 	{ "u18",        		0x040000, 0x08267644, BRF_ESS | BRF_PRG }, //  0 68000 Program Code
1260 	{ "u19",        		0x040000, 0xf0a243b1, BRF_ESS | BRF_PRG }, //  1
1261 
1262 	{ "ts001e.u37",        	0x080000, 0x70b66e7e, BRF_GRA },	   	   //  2 Sprites
1263 	{ "ts000e.u38",        	0x080000, 0xa7a94143, BRF_GRA },	   	   //  3
1264 	{ "ts002e.u36",        	0x040000, 0x611271e6, BRF_GRA },	   	   //  4
1265 
1266 	{ "ts010.u4",          	0x100000, 0xdf935324, BRF_GRA },	   	   //  5 Tiles
1267 
1268 	{ "ts020.u33",         	0x100000, 0xeb58c35d, BRF_GRA },	   	   //  6 Tiles (Layers 2 & 3)
1269 
1270 	{ "ts030.u5",          	0x100000, 0x1d68e9d1, BRF_SND },		   //  7 OKI Sample ROM
1271 };
1272 
1273 
1274 STD_ROM_PICK(Explbrkrk)
1275 STD_ROM_FN(Explbrkrk)
1276 
1277 static struct BurnRomInfo BakubrkrRomDesc[] = {
1278 	{ "ts100j.u18",        	0x040000, 0x8cc0a4fd, BRF_ESS | BRF_PRG }, //  0 68000 Program Code
1279 	{ "ts101j.u19",        	0x040000, 0xaea92195, BRF_ESS | BRF_PRG }, //  1
1280 
1281 	{ "ts001j.u37",        	0x080000, 0x70b66e7e, BRF_GRA },	   	   //  2 Sprites
1282 	{ "ts000j.u38",        	0x080000, 0xa7a94143, BRF_GRA },	   	   //  3
1283 	{ "ts002j.u36",        	0x040000, 0x611271e6, BRF_GRA },	   	   //  4
1284 
1285 	{ "ts010.u4",          	0x100000, 0xdf935324, BRF_GRA },	   	   //  5 Tiles
1286 
1287 	{ "ts020.u33",         	0x100000, 0xeb58c35d, BRF_GRA },	   	   //  6 Tiles (Layers 2 & 3)
1288 
1289 	{ "ts030.u5",          	0x100000, 0x1d68e9d1, BRF_SND },		   //  7 OKI Sample ROM
1290 };
1291 
1292 
1293 STD_ROM_PICK(Bakubrkr)
1294 STD_ROM_FN(Bakubrkr)
1295 
1296 static struct BurnRomInfo GtmrRomDesc[] = {
1297 	// this set shows 'PCB by Jinwei Co Ltd. ROC'
1298 	{ "u2.bin",            	0x080000, 0x031799f7, BRF_ESS | BRF_PRG }, //  0 68000 Program Code
1299 	{ "u1.bin",            	0x080000, 0x6238790a, BRF_ESS | BRF_PRG }, //  1
1300 
1301 	{ "mmd0x2.u124.bin",   	0x020000, 0x3d7cb329, BRF_PRG | BRF_OPT }, //  2 MCU Code // from gtmra
1302 
1303 	{ "mm-200-402-s0.bin", 	0x200000, 0xc0ab3efc, BRF_GRA },	   	   //  3 Sprites
1304 	{ "mm-201-403-s1.bin", 	0x200000, 0xcf6b23dc, BRF_GRA },	 	   //  4
1305 	{ "mm-202-404-s2.bin", 	0x200000, 0x8f27f5d3, BRF_GRA },	       //  5
1306 	{ "mm-203-405-s3.bin", 	0x080000, 0xe9747c8c, BRF_GRA },	       //  6
1307 	{ "mms1x2.u30.bin",    	0x020000, 0xb42b426f, BRF_GRA },	       //  7
1308 	{ "mms0x2.u29.bin",    	0x020000, 0xbd22b7d2, BRF_GRA },	       //  8
1309 
1310 	{ "mm-300-406-a0.bin", 	0x200000, 0xb15f6b7f, BRF_GRA },	       //  9 Tiles (scrambled)
1311 
1312 	{ "mm-100-401-e0.bin", 	0x100000, 0xb9cbfbee, BRF_SND },		   // 10 Samples
1313 };
1314 
1315 
1316 STD_ROM_PICK(Gtmr)
1317 STD_ROM_FN(Gtmr)
1318 
1319 static struct BurnRomInfo GtmraRomDesc[] = {
1320 	{ "mmp0x2.u514.bin",   	0x080000, 0xba4a77c8, BRF_ESS | BRF_PRG }, //  0 68000 Program Code
1321 	{ "mmp1x2.u513.bin",   	0x080000, 0xa2b9034e, BRF_ESS | BRF_PRG }, //  1
1322 
1323 	{ "mmd0x2.u124.bin",   	0x020000, 0x3d7cb329, BRF_PRG | BRF_OPT }, //  2 MCU Code
1324 
1325 	{ "mm-200-402-s0.bin", 	0x200000, 0xc0ab3efc, BRF_GRA },	   	   //  3 Sprites
1326 	{ "mm-201-403-s1.bin", 	0x200000, 0xcf6b23dc, BRF_GRA },	 	   //  4
1327 	{ "mm-202-404-s2.bin", 	0x200000, 0x8f27f5d3, BRF_GRA },	       //  5
1328 	{ "mm-203-405-s3.bin", 	0x080000, 0xe9747c8c, BRF_GRA },	       //  6
1329 	{ "mms1x2.u30.bin",    	0x020000, 0xb42b426f, BRF_GRA },	       //  7
1330 	{ "mms0x2.u29.bin",    	0x020000, 0xbd22b7d2, BRF_GRA },	       //  8
1331 
1332 	{ "mm-300-406-a0.bin", 	0x200000, 0xb15f6b7f, BRF_GRA },	       //  9 Tiles (scrambled)
1333 
1334 	{ "mm-100-401-e0.bin", 	0x100000, 0xb9cbfbee, BRF_SND },		   // 10 Samples
1335 };
1336 
1337 
1338 STD_ROM_PICK(Gtmra)
1339 STD_ROM_FN(Gtmra)
1340 
1341 static struct BurnRomInfo GtmrbRomDesc[] = {
1342 	{ "mmp0x1.u514",   		0x080000, 0x6c163f12, BRF_ESS | BRF_PRG }, //  0 68000 Program Code
1343 	{ "mmp1x1.u513",   		0x080000, 0x424dc7e1, BRF_ESS | BRF_PRG }, //  1
1344 
1345 	{ "mmd0x1.u124",   		0x020000, 0x3d7cb329, BRF_PRG | BRF_OPT }, //  2 MCU Code // == mmd0x2
1346 
1347 	{ "mm-200-402-s0.bin", 	0x200000, 0xc0ab3efc, BRF_GRA },	   	   //  3 Sprites
1348 	{ "mm-201-403-s1.bin", 	0x200000, 0xcf6b23dc, BRF_GRA },	 	   //  4
1349 	{ "mm-202-404-s2.bin", 	0x200000, 0x8f27f5d3, BRF_GRA },	       //  5
1350 	{ "mm-203-405-s3.bin", 	0x080000, 0xe9747c8c, BRF_GRA },	       //  6
1351 	{ "mms1x1.u30",    		0x020000, 0x9463825c, BRF_GRA },	       //  7
1352 	{ "mms0x1.u29",    		0x020000, 0xbd22b7d2, BRF_GRA },	       //  8 		  // == mms0x2
1353 
1354 	{ "mm-300-406-a0.bin", 	0x200000, 0xb15f6b7f, BRF_GRA },	       //  9 Tiles (scrambled)
1355 
1356 	{ "mm-100-401-e0.bin", 	0x100000, 0xb9cbfbee, BRF_SND },		   // 10 Samples
1357 };
1358 
1359 
1360 STD_ROM_PICK(Gtmrb)
1361 STD_ROM_FN(Gtmrb)
1362 
1363 static struct BurnRomInfo GtmroRomDesc[] = {
1364 	// possible prototype
1365 	{ "u514.bin",   		0x080000, 0x2e857685, BRF_ESS | BRF_PRG }, //  0 68000 Program Code
1366 	{ "u513.bin",   		0x080000, 0xd5003870, BRF_ESS | BRF_PRG }, //  1
1367 
1368 	{ "mmd0x0.u124", 	  	0x020000, 0xe1f6159e, BRF_PRG | BRF_OPT }, //  2 MCU Code
1369 
1370 	{ "mm200-e.bin", 		0x100000, 0xeb104408, BRF_GRA },	   	   //  3 Sprites
1371 	{ "mm200-o.bin", 		0x100000, 0xb6d04e7c, BRF_GRA },	 	   //  4
1372 	{ "mm201-e.bin", 		0x100000, 0xb8c64e14, BRF_GRA },	 	   //  5
1373 	{ "mm201-o.bin", 		0x100000, 0x3ecd6c0a, BRF_GRA },	 	   //  6
1374 	{ "mm202-e.bin", 		0x100000, 0xf0fd5688, BRF_GRA },	       //  7
1375 	{ "mm202-o.bin", 		0x100000, 0xe0fe1b2b, BRF_GRA },	       //  8
1376 	{ "mm203-e.bin",    	0x100000, 0xb9001f28, BRF_GRA },	       //  9
1377 	{ "mm203-o.bin",    	0x100000, 0x2ed6227d, BRF_GRA },	       // 10
1378 
1379 	{ "mm300-e.u53", 		0x100000, 0xf9ee708d, BRF_GRA },	       // 11 Tiles (scrambled)
1380 	{ "mm300-o.u54", 		0x100000, 0x76299353, BRF_GRA },	       // 12
1381 
1382 	{ "mm-100-401-e0.bin", 	0x100000, 0xb9cbfbee, BRF_SND },		   // 13 Samples
1383 };
1384 
1385 
1386 STD_ROM_PICK(Gtmro)
1387 STD_ROM_FN(Gtmro)
1388 
1389 static struct BurnRomInfo GtmreRomDesc[] = {
1390 	{ "gmmu2.bin",         	0x080000, 0x36dc4aa9, BRF_ESS | BRF_PRG }, //  0 68000 Program Code
1391 	{ "gmmu1.bin",         	0x080000, 0x8653c144, BRF_ESS | BRF_PRG }, //  1
1392 
1393 	{ "gtmrusa.u12",       	0x020000, 0x2e1a06ff, BRF_PRG | BRF_OPT }, //  2 MCU Code
1394 
1395 	{ "gmmu27.bin",        	0x200000, 0xc0ab3efc, BRF_GRA },	   	   //  3 Sprites
1396 	{ "gmmu28.bin",        	0x200000, 0xcf6b23dc, BRF_GRA },	 	   //  4
1397 	{ "gmmu29.bin",        	0x200000, 0x8f27f5d3, BRF_GRA },	       //  5
1398 	{ "gmmu30.bin",        	0x080000, 0xe9747c8c, BRF_GRA },	       //  6
1399 	{ "gmmu64.bin",        	0x100000, 0x57d77b33, BRF_GRA },	       //  7
1400 	{ "gmmu65.bin",        	0x100000, 0x05b8bdca, BRF_GRA },	       //  8
1401 
1402 	{ "gmmu52.bin",        	0x200000, 0xb15f6b7f, BRF_GRA },	       //  9 Tiles
1403 
1404 	{ "gmmu23.bin",        	0x100000, 0xb9cbfbee, BRF_SND },		   // 10 Samples, plus room for expansion
1405 
1406 	{ "gmmu24.bin",        	0x100000, 0x380cdc7c, BRF_SND },		   // 11 Samples
1407 };
1408 
1409 
1410 STD_ROM_PICK(Gtmre)
1411 STD_ROM_FN(Gtmre)
1412 
1413 static struct BurnRomInfo GtmrusaRomDesc[] = {
1414 	{ "mmp0x3.u2",          0x080000, 0x5be615c4, BRF_ESS | BRF_PRG }, //  0 68000 Program Code
1415 	{ "mmp1x3.u1",          0x080000, 0xae853e4e, BRF_ESS | BRF_PRG }, //  1
1416 
1417 	{ "mmd0x3.u12",         0x020000, 0x2e1a06ff, BRF_PRG | BRF_OPT }, //  2 MCU Code
1418 
1419 	{ "mm-200-402-s0.bin",  0x200000, 0xc0ab3efc, BRF_GRA },	       //  3 Sprites
1420 	{ "mm-201-403-s1.bin",  0x200000, 0xcf6b23dc, BRF_GRA },	       //  4
1421 	{ "mm-202-404-s2.bin",  0x200000, 0x8f27f5d3, BRF_GRA },	       //  5
1422 	{ "mm-203-405-s3.bin",  0x080000, 0xe9747c8c, BRF_GRA },	       //  6
1423 	{ "mm-204-564.bin",     0x100000, 0x57d77b33, BRF_GRA },	       //  7 HALVES IDENTICAL
1424 	{ "mm-204-406-565.bin", 0x100000, 0x05b8bdca, BRF_GRA },	       //  8 HALVES IDENTICAL
1425 
1426 	{ "mm-300-406-a0.bin",  0x200000, 0xb15f6b7f, BRF_GRA },	       //  9 Tiles (scrambled)
1427 
1428 	{ "mm-100-401-a0.bin",  0x100000, 0xb9cbfbee, BRF_SND },	       // 10 Samples, plus room for expansion
1429 
1430 	{ "mm-101-402-e24.bin", 0x100000, 0x380cdc7c, BRF_SND },	       // 11 Samples
1431 };
1432 
1433 
1434 STD_ROM_PICK(Gtmrusa)
1435 STD_ROM_FN(Gtmrusa)
1436 
1437 static struct BurnRomInfo Gtmr2RomDesc[] = {
1438 	{ "m2p0x1a.u8",        	0x080000, 0xc29039fb, BRF_ESS | BRF_PRG }, //  0 68000 Program Code
1439 	{ "m2p1x1a.u7",        	0x080000, 0x8ef392c4, BRF_ESS | BRF_PRG }, //  1
1440 
1441 	{ "m2d0x0.u31",        	0x020000, 0x2e1a06ff, BRF_PRG | BRF_OPT }, //  2 MCU Code
1442 
1443 	{ "m2-200-0.u49",      	0x400000, 0x93aafc53, BRF_GRA },		   //  3 Sprites
1444 	{ "m2-201-0.u50",      	0x200000, 0x39b60a83, BRF_GRA },	 	   //  4
1445 	{ "m2-202-0.u51",      	0x200000, 0xfd06b339, BRF_GRA },		   //  5
1446 	{ "m2s0x1a.u32",       	0x080000, 0xa485eec6, BRF_GRA },		   //  6
1447 	{ "m2s1x1a.u33",       	0x080000, 0xc5b71bb2, BRF_GRA },		   //  7
1448 
1449 	{ "m2-300-0.u89",      	0x200000, 0x4dc42fbb, BRF_GRA },		   //  8 Tiles (scrambled)
1450 	{ "m2-301-0.u90",      	0x200000, 0xf4e894f2, BRF_GRA },		   //  9
1451 	{ "m2b0x0.u93",        	0x020000, 0xe023d51b, BRF_GRA },		   // 10
1452 	{ "m2b1x0.u94",        	0x020000, 0x03c48bdb, BRF_GRA },		   // 11
1453 
1454 	{ "m2-100-0.u48",      	0x100000, 0x5250fa45, BRF_SND },		   // 12 Samples, plus room for expansion
1455 
1456 	{ "m2w1x0.u47",        	0x040000, 0x1b0513c5, BRF_SND },		   // 13 Samples
1457 };
1458 
1459 
1460 STD_ROM_PICK(Gtmr2)
1461 STD_ROM_FN(Gtmr2)
1462 
1463 static struct BurnRomInfo Gtmr2aRomDesc[] = {
1464 	{ "m2p0x1.u8",         	0x080000, 0x525f6618, BRF_ESS | BRF_PRG }, //  0 68000 Program Code
1465 	{ "m2p1x1.u7",         	0x080000, 0x914683e5, BRF_ESS | BRF_PRG }, //  1 68000 Program Code
1466 
1467 	{ "m2d0x0.u31",        	0x020000, 0x2e1a06ff, BRF_PRG | BRF_OPT }, //  2 MCU Code
1468 
1469 	{ "m2-200-0.u49",      	0x400000, 0x93aafc53, BRF_GRA },		   //  3 Sprites
1470 	{ "m2-201-0.u50",      	0x200000, 0x39b60a83, BRF_GRA },		   //  4
1471 	{ "m2-202-0.u51",      	0x200000, 0xfd06b339, BRF_GRA },		   //  5
1472 	{ "m2s0x1.u32",        	0x080000, 0x4069d6c7, BRF_GRA },		   //  6
1473 	{ "m2s1x1.u33",        	0x080000, 0xc53fe269, BRF_GRA },		   //  7
1474 
1475 	{ "m2-300-0.u89",      	0x200000, 0x4dc42fbb, BRF_GRA },		   //  8 Tiles (scrambled)
1476 	{ "m2-301-0.u90",      	0x200000, 0xf4e894f2, BRF_GRA },		   //  9
1477 	{ "m2b0x0.u93",        	0x020000, 0xe023d51b, BRF_GRA },		   // 10
1478 	{ "m2b1x0.u94",        	0x020000, 0x03c48bdb, BRF_GRA },		   // 11
1479 
1480 	{ "m2-100-0.u48",      	0x100000, 0x5250fa45, BRF_SND },		   // 12 Samples, plus room for expansion
1481 
1482 	{ "m2w1x0.u47",        	0x040000, 0x1b0513c5, BRF_SND },		   // 13 Samples
1483 };
1484 
1485 
1486 STD_ROM_PICK(Gtmr2a)
1487 STD_ROM_FN(Gtmr2a)
1488 
1489 static struct BurnRomInfo Gtmr2uRomDesc[] = {
1490 	{ "m2p0a1.u8",         	0x080000, 0x813e1d5e, BRF_ESS | BRF_PRG }, //  0 68000 Program Code
1491 	{ "m2p1a1.u7",         	0x080000, 0xbee63666, BRF_ESS | BRF_PRG }, //  1
1492 
1493 	{ "m2d0x0.u31",        	0x020000, 0x2e1a06ff, BRF_PRG | BRF_OPT }, //  2 MCU Code
1494 
1495 	{ "m2-200-0.u49",      	0x400000, 0x93aafc53, BRF_GRA },		   //  3 Sprites
1496 	{ "m2-201-0.u50",      	0x200000, 0x39b60a83, BRF_GRA },	 	   //  4
1497 	{ "m2-202-0.u51",      	0x200000, 0xfd06b339, BRF_GRA },		   //  5
1498 	{ "m2s0a1.u32",        	0x080000, 0x98977171, BRF_GRA },		   //  6
1499 	{ "m2s1a1.u33",        	0x080000, 0xc69a732e, BRF_GRA },		   //  7
1500 
1501 	{ "m2-300-0.u89",      	0x200000, 0x4dc42fbb, BRF_GRA },		   //  8 Tiles
1502 	{ "m2-301-0.u90",      	0x200000, 0xf4e894f2, BRF_GRA },		   //  9
1503 	{ "m2b0x0.u93",        	0x020000, 0xe023d51b, BRF_GRA },		   // 10
1504 	{ "m2b1x0.u94",        	0x020000, 0x03c48bdb, BRF_GRA },		   // 11
1505 
1506 	{ "m2-100-0.u48",      	0x100000, 0x5250fa45, BRF_SND },		   // 12 Samples, plus room for expansion
1507 
1508 	{ "m2w1a1.u47",        	0x080000, 0x15f25342, BRF_SND },		   // 13 Samples
1509 };
1510 
1511 
1512 STD_ROM_PICK(Gtmr2u)
1513 STD_ROM_FN(Gtmr2u)
1514 
1515 static struct BurnRomInfo MgcrystlRomDesc[] = {
1516 	{ "mc100e02.u18",      	0x020000, 0x246a1335, BRF_ESS | BRF_PRG }, //  0 68000 Program Code /* Labeled as MC100E/U18-02 */
1517 	{ "mc101e02.u19",      	0x040000, 0x708ea1dc, BRF_ESS | BRF_PRG }, //  1 					/* Labeled as MC101E/U19-02 */
1518 
1519 	{ "mc000.u38",         	0x100000, 0x28acf6f4, BRF_GRA },		   //  2 Sprites
1520 	{ "mc001.u37",         	0x080000, 0x005bc43d, BRF_GRA },		   //  3
1521 	{ "mc002e02.u36",      	0x020000, 0x27ac1056, BRF_GRA },		   //  4 					/* Labeled as MC002E/U36-02 */
1522 
1523 	{ "mc010.u04",         	0x100000, 0x85072772, BRF_GRA },		   //  5 Tiles (scrambled)
1524 
1525 	{ "mc020.u34",         	0x100000, 0x1ea92ff1, BRF_GRA },		   //  6 Tiles (scrambled) (Layers 2 & 3)
1526 
1527 	{ "mc030.u32",         	0x040000, 0xc165962e, BRF_SND },		   //  7 Samples
1528 };
1529 
1530 
1531 STD_ROM_PICK(Mgcrystl)
1532 STD_ROM_FN(Mgcrystl)
1533 
1534 static struct BurnRomInfo MgcrystloRomDesc[] = {
1535 	{ "mc100h00.u18",      	0x020000, 0xc7456ba7, BRF_ESS | BRF_PRG }, //  0 68000 Program Code /* Labeled as MC100H/U18-00 */
1536 	{ "mc101h00.u19",      	0x040000, 0xea8f9300, BRF_ESS | BRF_PRG }, //  1 					/* Labeled as MC101H/U19-00 */
1537 
1538 	{ "mc000.u38",         	0x100000, 0x28acf6f4, BRF_GRA },		   //  2 Sprites
1539 	{ "mc001.u37",         	0x080000, 0x005bc43d, BRF_GRA },		   //  3
1540 	{ "mc002h00.u36",      	0x020000, 0x22729037, BRF_GRA },		   //  4 					/* Labeled as MC002H/U36-00 */
1541 
1542 	{ "mc010.u04",         	0x100000, 0x85072772, BRF_GRA },		   //  5 Tiles (scrambled)
1543 
1544 	{ "mc020.u34",         	0x100000, 0x1ea92ff1, BRF_GRA },		   //  6 Tiles (scrambled) (Layers 2 & 3)
1545 
1546 	{ "mc030.u32",         	0x040000, 0xc165962e, BRF_SND },		   //  7 Samples
1547 };
1548 
1549 
1550 STD_ROM_PICK(Mgcrystlo)
1551 STD_ROM_FN(Mgcrystlo)
1552 
1553 static struct BurnRomInfo MgcrystljRomDesc[] = {
1554 	{ "kaneko__mc100-u18j-02.u18",		0x020000, 0xafe5882d, BRF_ESS | BRF_PRG }, //  0 68000 Program Code /* Labeled as MC100J/U18-02 */
1555 	{ "kaneko__mc101-u19j-02.u19",		0x040000, 0x60da5492, BRF_ESS | BRF_PRG }, //  1 					/* Labeled as MC101J/U19-02 */
1556 
1557 	{ "kaneko__mc-000_0001.u38",		0x100000, 0x28acf6f4, BRF_GRA },		   //  2 Sprites
1558 	{ "kaneko__mc-001_0002_r44.u37",	0x080000, 0x005bc43d, BRF_GRA },		   //  3
1559 	{ "kaneko__mc002j-u36-02.u36",		0x020000, 0x27ac1056, BRF_GRA },		   //  4 					/* Labeled as MC002J/U36-02, but same as MC002E/U36-02 */
1560 
1561 	{ "kaneko__mc-010_0003.u04",		0x100000, 0x85072772, BRF_GRA },		   //  5 Tiles (scrambled)
1562 
1563 	{ "kaneko__mc-020_0004.u34",		0x100000, 0x1ea92ff1, BRF_GRA },		   //  6 Tiles (scrambled) (Layers 2 & 3)
1564 
1565 	{ "kaneko__mc-030_0005_t99.u32",	0x040000, 0xc165962e, BRF_SND },		   //  7 Samples
1566 };
1567 
1568 
1569 STD_ROM_PICK(Mgcrystlj)
1570 STD_ROM_FN(Mgcrystlj)
1571 
1572 static struct BurnRomInfo shogwarrRomDesc[] = {
1573 	{ "fb030e.u61",			0x020000, 0x32ce7909, BRF_ESS | BRF_PRG }, //  0 68000 Program Code
1574 	{ "fb031e.u62",			0x020000, 0x228aeaf5, BRF_ESS | BRF_PRG }, //  1 68000 Program Code
1575 
1576 	{ "fb040e.u33",			0x020000, 0x299d0746, BRF_ESS | BRF_PRG }, //  2 MCU Data
1577 
1578 	{ "fb-020a.u1",			0x100000, 0x87e55c6d, BRF_GRA },	   	   //  3 Sprites
1579 	{ "fb020b.u2",			0x100000, 0x276b9d7b, BRF_GRA },	       //  4
1580 	{ "fb021a.u3",			0x100000, 0x7da15d37, BRF_GRA },	       //  5
1581 	{ "fb021b.u4",			0x100000, 0x6a512d7b, BRF_GRA },	       //  6
1582 	{ "fb-22a.u5",			0x100000, 0x9039e5d3, BRF_GRA },	       //  7
1583 	{ "fb-22b.u6",			0x100000, 0x96ac9e54, BRF_GRA },	       //  8
1584 	{ "fb023.u7",			0x100000, 0x132794bd, BRF_GRA },	       //  9
1585 
1586 	{ "fb010.u65",			0x100000, 0x296ffd92, BRF_GRA },	       // 10 Tiles (scrambled)
1587 	{ "fb011.u66",			0x080000, 0x500a0367, BRF_GRA },	       // 11
1588 
1589 	{ "fb001e.u43",			0x080000, 0xf524aaa1, BRF_SND },	       // 12 Samples
1590 	{ "fb000e.u42",			0x080000, 0x969f1465, BRF_SND },	       // 13
1591 
1592 	{ "fb-002.u45",			0x100000, 0x010acc17, BRF_SND },	       // 14 Samples
1593 	{ "fb-003.u44",			0x100000, 0x0aea4ac5, BRF_SND },	       // 15
1594 };
1595 
1596 STD_ROM_PICK(shogwarr)
1597 STD_ROM_FN(shogwarr)
1598 
1599 static struct BurnRomInfo shogwarrkRomDesc[] = {
1600 	{ "fb-030a.u61",		0x020000, 0x32ce7909, BRF_ESS | BRF_PRG }, //  0 68000 Program Code
1601 	{ "fb-031a.u62",		0x020000, 0xbbffe957, BRF_ESS | BRF_PRG }, //  1 68000 Program Code
1602 
1603 	{ "fb-040a.u33",		0x020000, 0x299d0746, BRF_ESS | BRF_PRG }, //  2 MCU Data
1604 
1605 	{ "fb-020a.u1",			0x100000, 0x87e55c6d, BRF_GRA },	   	   //  3 Sprites
1606 	{ "fb020b.u2",			0x100000, 0x276b9d7b, BRF_GRA },	       //  4
1607 	{ "fb021a.u3",			0x100000, 0x7da15d37, BRF_GRA },	       //  5
1608 	{ "fb021b.u4",			0x100000, 0x6a512d7b, BRF_GRA },	       //  6
1609 	{ "fb-22a.u5",			0x100000, 0x9039e5d3, BRF_GRA },	       //  7
1610 	{ "fb-22b.u6",			0x100000, 0x96ac9e54, BRF_GRA },	       //  8
1611 	{ "fb023.u7",			0x100000, 0x132794bd, BRF_GRA },	       //  9
1612 	{ "fb-024.u8",			0x080000, 0x4bf3282d, BRF_GRA },	       //  10
1613 
1614 	{ "fb010.u65",			0x100000, 0x296ffd92, BRF_GRA },	       // 11 Tiles (scrambled)
1615 	{ "fb011.u66",			0x080000, 0x500a0367, BRF_GRA },	       // 12
1616 
1617 	{ "fb-000.u43",			0x080000, 0xf524aaa1, BRF_SND },	       // 13 Samples
1618 	{ "fb-003.u101",		0x080000, 0x969f1465, BRF_SND },	       // 14
1619 
1620 	{ "fb-002.u45",			0x100000, 0x010acc17, BRF_SND },	       // 15 Samples
1621 	{ "fb-003.u44",			0x100000, 0x0aea4ac5, BRF_SND },	       // 16
1622 };
1623 
1624 STD_ROM_PICK(shogwarrk)
1625 STD_ROM_FN(shogwarrk)
1626 
1627 static struct BurnRomInfo shogwarruRomDesc[] = {
1628 	{ "fb030a.u61",			0x020000, 0xa04106c6, BRF_ESS | BRF_PRG }, //  0 68000 Program Code
1629 	{ "fb031a.u62",			0x020000, 0xd1def5e2, BRF_ESS | BRF_PRG }, //  1
1630 
1631 	{ "fb040a.u33",			0x020000, 0x4b62c4d9, BRF_ESS | BRF_PRG }, //  2 MCU Data
1632 
1633 	{ "fb-020a.u1",			0x100000, 0x87e55c6d, BRF_GRA },	       //  3 Sprites
1634 	{ "fb020b.u2",			0x100000, 0x276b9d7b, BRF_GRA },	       //  4
1635 	{ "fb021a.u3",			0x100000, 0x7da15d37, BRF_GRA },	       //  5
1636 	{ "fb021b.u4",			0x100000, 0x6a512d7b, BRF_GRA },	       //  6
1637 	{ "fb-22a.u5",			0x100000, 0x9039e5d3, BRF_GRA },	       //  7
1638 	{ "fb-22b.u6",			0x100000, 0x96ac9e54, BRF_GRA },	       //  8
1639 	{ "fb023.u7",			0x100000, 0x132794bd, BRF_GRA },	       //  9
1640 
1641 	{ "fb010.u65",			0x100000, 0x296ffd92, BRF_GRA },	       // 10 Tiles (scrambled)
1642 	{ "fb011.u66",			0x080000, 0x500a0367, BRF_GRA },	       // 11
1643 
1644 	{ "fb001e.u43",			0x080000, 0xf524aaa1, BRF_SND },	       // 12 Samples
1645 	{ "fb000e.u42",			0x080000, 0x969f1465, BRF_SND },	       // 13
1646 
1647 	{ "fb-002.u45",			0x100000, 0x010acc17, BRF_SND },	       // 14 Samples
1648 	{ "fb-003.u44",			0x100000, 0x0aea4ac5, BRF_SND },	       // 15
1649 };
1650 
1651 STD_ROM_PICK(shogwarru)
1652 STD_ROM_FN(shogwarru)
1653 
1654 static struct BurnRomInfo fjbusterRomDesc[] = {
1655 	// Fujiyama Buster - Japan version of Shogun Warriors
1656 	{ "fb030j.u61",			0x020000, 0x32ce7909, BRF_ESS | BRF_PRG }, //  0 68000 Program Code
1657 	{ "fb031j.u62",			0x020000, 0x000c8c08, BRF_ESS | BRF_PRG }, //  1
1658 
1659 	{ "fb040j.u33",			0x020000, 0x299d0746, BRF_ESS | BRF_PRG }, //  2 MCU Data
1660 
1661 	{ "fb-020a.u1",			0x100000, 0x87e55c6d, BRF_GRA },	       //  3 Sprites
1662 	{ "fb020b.u2",			0x100000, 0x276b9d7b, BRF_GRA },	       //  4
1663 	{ "fb021a.u3",			0x100000, 0x7da15d37, BRF_GRA },	       //  5
1664 	{ "fb021b.u4",			0x100000, 0x6a512d7b, BRF_GRA },	       //  6
1665 	{ "fb-22a.u5",			0x100000, 0x9039e5d3, BRF_GRA },	       //  7
1666 	{ "fb-22b.u6",			0x100000, 0x96ac9e54, BRF_GRA },	       //  8
1667 	{ "fb023.u7",			0x100000, 0x132794bd, BRF_GRA },	       //  9
1668 
1669 	{ "fb010.u65",			0x100000, 0x296ffd92, BRF_GRA },	       // 10 Tiles (scrambled)
1670 	{ "fb011.u66",			0x080000, 0x500a0367, BRF_GRA },	       // 11
1671 
1672 	{ "fb000j.u43",			0x080000, 0xa7522555, BRF_SND },	       // 12 Samples
1673 	{ "fb001j_u.101",		0x080000, 0x07d4e8e2, BRF_SND },	       // 13
1674 
1675 	{ "fb-002.u45",			0x100000, 0x010acc17, BRF_SND },	       // 14 Samples
1676 	{ "fb-003.u44",			0x100000, 0x0aea4ac5, BRF_SND },	       // 15
1677 };
1678 
1679 STD_ROM_PICK(fjbuster)
1680 STD_ROM_FN(fjbuster)
1681 
1682 static struct BurnRomInfo brapboysRomDesc[] = {
1683 	{ "rb-030.01.u61",		0x020000, 0xccbe9a53, BRF_ESS | BRF_PRG }, //  0 68000 Program Code
1684 	{ "rb-031.01.u62",		0x020000, 0xc72b8dda, BRF_ESS | BRF_PRG }, //  1
1685 
1686 	{ "rb-040.00.u33",		0x020000, 0x757c6e19, BRF_ESS | BRF_PRG }, //  2 MCU Data
1687 
1688 	{ "rb-020.u100",		0x100000, 0xce220d38, BRF_GRA },	       //  3 Sprites
1689 	{ "rb-021.u76",			0x100000, 0x74001407, BRF_GRA },	       //  4
1690 	{ "rb-022.u77",			0x100000, 0xcb3f42dc, BRF_GRA },	       //  5
1691 	{ "rb-023.u78",			0x100000, 0x0e6530c5, BRF_GRA },	       //  6
1692 	{ "rb-024.u79",			0x080000, 0x65fa6447, BRF_GRA },	       //  7
1693 	{ "rb-025.01.u80",		0x040000, 0x36cd6b90, BRF_GRA },	       //  8
1694 
1695 	{ "rb-010.u65",			0x100000, 0xffd73f87, BRF_GRA },	       //  9 Tiles (scrambled)
1696 	{ "rb-011.u66",			0x100000, 0xd9325f78, BRF_GRA },	       // 10
1697 	{ "rb-012.u67",			0x100000, 0xbfdbe0d1, BRF_GRA },	       // 11
1698 	{ "rb-013.u68",			0x100000, 0x28c37fe8, BRF_GRA },	       // 12
1699 
1700 	{ "rb-000.u43",			0x080000, 0x58ad1a62, BRF_SND },	       // 13 Samples
1701 	{ "rb-003.00.u101",		0x080000, 0x2cac25d7, BRF_SND },	       // 14
1702 
1703 	{ "rb-001.u44",			0x100000, 0x7cf774b3, BRF_SND },	       // 15 Samples
1704 	{ "rb-002.u45",			0x100000, 0xe4b30444, BRF_SND },	       // 16
1705 };
1706 
1707 STD_ROM_PICK(brapboys)
1708 STD_ROM_FN(brapboys)
1709 
1710 static struct BurnRomInfo brapboyspRomDesc[] = {
1711 	{ "rb-030.a0.u61",		0x020000, 0xfed2ecea, BRF_ESS | BRF_PRG }, //  0 68000 Program Code
1712 	{ "rb-031.a0.u62",		0x020000, 0xf64b9763, BRF_ESS | BRF_PRG }, //  1
1713 
1714 	{ "rb-040.a0.u33",		0x020000, 0x7b856d27, BRF_ESS | BRF_PRG }, //  2 MCU Data
1715 
1716 	{ "rb-020.u100",		0x100000, 0xce220d38, BRF_GRA },	       //  3 Sprites
1717 	{ "rb-021.u76",			0x100000, 0x74001407, BRF_GRA },	       //  4
1718 	{ "rb-022.u77",			0x100000, 0xcb3f42dc, BRF_GRA },	       //  5
1719 	{ "rb-023.u78",			0x100000, 0x0e6530c5, BRF_GRA },	       //  6
1720 	{ "rb-024.u79",			0x080000, 0x65fa6447, BRF_GRA },	       //  7
1721 	{ "rb-025.a0.u80a",		0x080000, 0xaa795ba5, BRF_GRA },	       //  8
1722 
1723 	{ "rb-010.u65",			0x100000, 0xffd73f87, BRF_GRA },	       //  9 Tiles (scrambled)
1724 	{ "rb-011.u66",			0x100000, 0xd9325f78, BRF_GRA },	       // 10
1725 	{ "rb-012.u67",			0x100000, 0xbfdbe0d1, BRF_GRA },	       // 11
1726 	{ "rb-013.u68",			0x100000, 0x28c37fe8, BRF_GRA },	       // 12
1727 
1728 	{ "rb-000.u43",			0x080000, 0x58ad1a62, BRF_SND },	       // 13 Samples
1729 	{ "rb-003.00.u101",		0x080000, 0x2cac25d7, BRF_SND },	       // 14
1730 
1731 	{ "rb-001.u44",			0x100000, 0x7cf774b3, BRF_SND },	       // 15 Samples
1732 	{ "rb-002.u45",			0x100000, 0xe4b30444, BRF_SND },	       // 16
1733 
1734 	{ "rb-026.10.u80b",		0x080000, 0xbb7604d4, BRF_GRA },	       // 17 Sprites (Extra)
1735 };
1736 
1737 STD_ROM_PICK(brapboysp)
1738 STD_ROM_FN(brapboysp)
1739 
1740 static struct BurnRomInfo brapboyspjRomDesc[] = {
1741 	{ "rb-004.u61",			0x020000, 0x5432442c, BRF_ESS | BRF_PRG }, //  0 68000 Program Code
1742 	{ "rb-005.u62",			0x020000, 0x118b3cfb, BRF_ESS | BRF_PRG }, //  1
1743 
1744 	{ "rb-006.u33",			0x020000, 0xf1d76b20, BRF_ESS | BRF_PRG }, //  2 MCU Data
1745 
1746 	{ "rb-020.u100",		0x100000, 0xce220d38, BRF_GRA },	       //  3 Sprites
1747 	{ "rb-021.u76",			0x100000, 0x74001407, BRF_GRA },	       //  4
1748 	{ "rb-022.u77",			0x100000, 0xcb3f42dc, BRF_GRA },	       //  5
1749 	{ "rb-023.u78",			0x100000, 0x0e6530c5, BRF_GRA },	       //  6
1750 	{ "rb-024.u79",			0x080000, 0x65fa6447, BRF_GRA },	       //  7
1751 	{ "rb-025.a0.u80a",		0x080000, 0xaa795ba5, BRF_GRA },	       //  8
1752 
1753 	{ "rb-010.u65",			0x100000, 0xffd73f87, BRF_GRA },	       //  9 Tiles (scrambled)
1754 	{ "rb-011.u66",			0x100000, 0xd9325f78, BRF_GRA },	       // 10
1755 	{ "rb-012.u67",			0x100000, 0xbfdbe0d1, BRF_GRA },	       // 11
1756 	{ "rb-013.u68",			0x100000, 0x28c37fe8, BRF_GRA },	       // 12
1757 
1758 	{ "rb-000.u43",			0x080000, 0x58ad1a62, BRF_SND },	       // 13 Samples
1759 	{ "rb-003.00.u101",		0x080000, 0x2cac25d7, BRF_SND },	       // 14
1760 
1761 	{ "rb-001.u44",			0x100000, 0x7cf774b3, BRF_SND },	       // 15 Samples
1762 	{ "rb-002.u45",			0x100000, 0xe4b30444, BRF_SND },	       // 16
1763 
1764 	{ "rb-026.10.u80b",		0x080000, 0xbb7604d4, BRF_GRA },	       // 17 Sprites (Extra)
1765 };
1766 
1767 STD_ROM_PICK(brapboyspj)
1768 STD_ROM_FN(brapboyspj)
1769 
1770 static struct BurnRomInfo brapboyspuRomDesc[] = {
1771 	{ "rb-030.10.u61",		0x020000, 0x527eb92a, BRF_ESS | BRF_PRG }, //  0 68000 Program Code
1772 	{ "rb-031.10.u62",		0x020000, 0xd5962bdd, BRF_ESS | BRF_PRG }, //  1
1773 
1774 	{ "rb-040.10.u33",		0x020000, 0x0c90d758, BRF_ESS | BRF_PRG }, //  2 MCU Data
1775 
1776 	{ "rb-020.u100",		0x100000, 0xce220d38, BRF_GRA },	       //  3 Sprites
1777 	{ "rb-021.u76",			0x100000, 0x74001407, BRF_GRA },	       //  4
1778 	{ "rb-022.u77",			0x100000, 0xcb3f42dc, BRF_GRA },	       //  5
1779 	{ "rb-023.u78",			0x100000, 0x0e6530c5, BRF_GRA },	       //  6
1780 	{ "rb-024.u79",			0x080000, 0x65fa6447, BRF_GRA },	       //  7
1781 	{ "rb-025.10.u80a",		0x080000, 0x140fe400, BRF_GRA },	       //  8
1782 
1783 	{ "rb-010.u65",			0x100000, 0xffd73f87, BRF_GRA },	       //  9 Tiles (scrambled)
1784 	{ "rb-011.u66",			0x100000, 0xd9325f78, BRF_GRA },	       // 10
1785 	{ "rb-012.u67",			0x100000, 0xbfdbe0d1, BRF_GRA },	       // 11
1786 	{ "rb-013.u68",			0x100000, 0x28c37fe8, BRF_GRA },	       // 12
1787 
1788 	{ "rb-000.u43",			0x080000, 0x58ad1a62, BRF_SND },	       // 13 Samples
1789 	{ "rb-003.00.u101",		0x080000, 0x2cac25d7, BRF_SND },	       // 14
1790 
1791 	{ "rb-001.u44",			0x100000, 0x7cf774b3, BRF_SND },	       // 15 Samples
1792 	{ "rb-002.u45",			0x100000, 0xe4b30444, BRF_SND },	       // 16
1793 
1794 	{ "rb-026.10.u80b",		0x080000, 0xbb7604d4, BRF_GRA },	       // 17 Sprites (Extra)
1795 };
1796 
1797 STD_ROM_PICK(brapboyspu)
STD_ROM_FN(brapboyspu)1798 STD_ROM_FN(brapboyspu)
1799 
1800 
1801 /*==============================================================================================
1802 Graphics Decoding
1803 ===============================================================================================*/
1804 
1805 static void Kaneko16DecodeBg15Bitmaps()
1806 {
1807 	INT32 sx, x, y;
1808 
1809 	for (sx = 0; sx < 32; sx++) {
1810 		for (x = 0; x < 256; x++) {
1811 			for (y = 0; y < 256; y++) {
1812 				INT32 addr = (sx * 256 * 256) + (y * 256) + x;
1813 				INT32 data = (Kaneko16TempGfx[addr * 2 + 0] * 256) + Kaneko16TempGfx[addr * 2 + 1];
1814 				INT32 r, g, b;
1815 
1816 				r = (data & 0x07c0) >> 6;
1817 				g = (data & 0xf800) >> 11;
1818 				b = (data & 0x003e) >> 1;
1819 
1820 				r ^= 0x09;
1821 
1822 				if (~g & 0x08) g ^= 0x010;
1823 				g = (g - 1) & 0x1f;
1824 
1825 				b ^= 0x03;
1826 				if (~b & 0x08) b ^= 0x10;
1827 				b = (b + 2) & 0x1f;
1828 
1829 				if ((r & 0x10) && (b & 0x10)) g = (g - 1) & 0x1f;
1830 
1831 				Kaneko16Bg15Data[addr] = 2048 + ((g << 10) | (r << 5) | b);
1832 			}
1833 		}
1834 	}
1835 }
1836 
1837 INT32 spritepriomask[4] = { 2, 3, 5, 7 }; // Default for Wingforc
1838 
Kaneko16SpritePrio(INT32 pri0,INT32 pri1,INT32 pri2,INT32 pri3)1839 static void Kaneko16SpritePrio(INT32 pri0, INT32 pri1, INT32 pri2, INT32 pri3)
1840 {
1841 	spritepriomask[0] = pri0;
1842 	spritepriomask[1] = pri1;
1843 	spritepriomask[2] = pri2;
1844 	spritepriomask[3] = pri3;
1845 }
1846 
1847 /*==============================================================================================
1848 Unscramble Tile/Sound ROM Functions
1849 ===============================================================================================*/
1850 
UnscrambleTiles(INT32 length)1851 static void UnscrambleTiles(INT32 length)
1852 {
1853 	UINT8 *RAM = Kaneko16TempGfx;
1854 	INT32 i;
1855 
1856 	if (RAM == NULL) return;
1857 
1858 	for (i = 0; i < length; i ++)
1859 	{
1860 		RAM[i] = ((RAM[i] & 0xF0)>>4) + ((RAM[i] & 0x0F)<<4);
1861 	}
1862 }
1863 
ExpandSampleBanks()1864 static void ExpandSampleBanks()
1865 {
1866 	INT32 bank;
1867 
1868 	for (bank = 15; bank > 0; bank--)
1869 	{
1870 		UINT8 *src0 = MSM6295ROMData;
1871 		UINT8 *srcn = src0 + 0x10000 * (bank < 3 ? 3 : bank);
1872 		UINT8 *dst = src0 + 0x40000 * bank;
1873 
1874 		memcpy(dst + 0x30000, srcn + 0x00000, 0x10000);
1875 		memcpy(dst + 0x00000, src0 + 0x00000, 0x30000);
1876 	}
1877 }
1878 
1879 /*==============================================================================================
1880 Allocate Memory
1881 ===============================================================================================*/
1882 
GtmrMemIndex()1883 static INT32 GtmrMemIndex()
1884 {
1885 	UINT8 *Next; Next = Mem;
1886 
1887 	Kaneko16Rom           = Next; Next += 0x100000;
1888 	MSM6295ROM            = Next; Next += 0x140000;
1889 	MSM6295ROMData        = Next; Next += 0x400000;
1890 	MSM6295ROMData2       = Next; Next += 0x300000;
1891 
1892 	RamStart = Next;
1893 
1894 	Kaneko16Ram           = Next; Next += 0x028000;
1895 	Kaneko16MCURam        = Next; Next += 0x010000;
1896 	Kaneko16NVRam         = Next; Next += 0x000100;
1897 	Kaneko16PaletteRam    = Next; Next += 0x010000;
1898 	Kaneko16SpriteRam     = Next; Next += Kaneko16SpriteRamSize;
1899 	Kaneko16Video0Ram     = Next; Next += 0x001000;
1900 	Kaneko16Video1Ram     = Next; Next += 0x001000;
1901 	Kaneko16Video2Ram     = Next; Next += 0x001000;
1902 	Kaneko16Video3Ram     = Next; Next += 0x001000;
1903 	Kaneko16VScrl0Ram     = Next; Next += 0x001000;
1904 	Kaneko16VScrl1Ram     = Next; Next += 0x001000;
1905 	Kaneko16VScrl2Ram     = Next; Next += 0x001000;
1906 	Kaneko16VScrl3Ram     = Next; Next += 0x001000;
1907 
1908 	RamEnd = Next;
1909 
1910 	Kaneko16PrioBitmap         = Next; Next += 320 * 240;
1911 
1912 	Kaneko16Sprites       = Next; Next += (Kaneko16NumSprites * 16 * 16);
1913 	Kaneko16Tiles         = Next; Next += (Kaneko16NumTiles * 16 * 16);
1914 	LayerQueueXY[0]       = (UINT32*)Next; Next += nScreenWidth * nScreenHeight * sizeof(UINT32);
1915 	LayerQueueXY[1]       = (UINT32*)Next; Next += nScreenWidth * nScreenHeight * sizeof(UINT32);
1916 	LayerQueueColour[0]   = (UINT32*)Next; Next += nScreenWidth * nScreenHeight * sizeof(UINT32);
1917 	LayerQueueColour[1]   = (UINT32*)Next; Next += nScreenWidth * nScreenHeight * sizeof(UINT32);
1918 	LayerQueuePriority[0] = Next; Next += nScreenWidth * nScreenHeight;
1919 	LayerQueuePriority[1] = Next; Next += nScreenWidth * nScreenHeight;
1920 	if (Kaneko16NumTiles2) {
1921 		Kaneko16Tiles2        = Next; Next += (Kaneko16NumTiles2 * 16 * 16);
1922 		LayerQueueXY[2]       = (UINT32*)Next; Next += nScreenWidth * nScreenHeight * sizeof(UINT32);
1923 		LayerQueueXY[3]       = (UINT32*)Next; Next += nScreenWidth * nScreenHeight * sizeof(UINT32);
1924 		LayerQueueColour[2]   = (UINT32*)Next; Next += nScreenWidth * nScreenHeight * sizeof(UINT32);
1925 		LayerQueueColour[3]   = (UINT32*)Next; Next += nScreenWidth * nScreenHeight * sizeof(UINT32);
1926 		LayerQueuePriority[2] = Next; Next += nScreenWidth * nScreenHeight;
1927 		LayerQueuePriority[3] = Next; Next += nScreenWidth * nScreenHeight;
1928 	}
1929 	Kaneko16Palette       = (UINT32*)Next; Next += 0x010000 * sizeof(UINT32);
1930 	MemEnd = Next;
1931 
1932 	return 0;
1933 }
1934 
ExplbrkrMemIndex()1935 static INT32 ExplbrkrMemIndex()
1936 {
1937 	UINT8 *Next; Next = Mem;
1938 
1939 	Kaneko16Rom           = Next; Next += 0x080000;
1940 	MSM6295ROM            = Next; Next += 0x040000;
1941 	MSM6295ROMData        = Next; Next += 0x200000;
1942 
1943 	RamStart = Next;
1944 
1945 	Kaneko16Ram           = Next; Next += 0x010000;
1946 	Kaneko16PaletteRam    = Next; Next += 0x001000;
1947 	Kaneko16SpriteRam     = Next; Next += Kaneko16SpriteRamSize;
1948 	Kaneko16Video0Ram     = Next; Next += 0x001000;
1949 	Kaneko16Video1Ram     = Next; Next += 0x001000;
1950 	Kaneko16Video2Ram     = Next; Next += 0x001000;
1951 	Kaneko16Video3Ram     = Next; Next += 0x001000;
1952 	Kaneko16VScrl0Ram     = Next; Next += 0x001000;
1953 	Kaneko16VScrl1Ram     = Next; Next += 0x001000;
1954 	Kaneko16VScrl2Ram     = Next; Next += 0x001000;
1955 	Kaneko16VScrl3Ram     = Next; Next += 0x001000;
1956 
1957 	RamEnd = Next;
1958 
1959 	Kaneko16PrioBitmap         = Next; Next += 320 * 240;
1960 	Kaneko16SpriteFbuffer      = (UINT16*)Next; Next += 320 * 240 * sizeof(UINT16); // mgcrystl
1961 
1962 	Kaneko16Sprites       = Next; Next += (Kaneko16NumSprites * 16 * 16);
1963 	Kaneko16Tiles         = Next; Next += (Kaneko16NumTiles * 16 * 16);
1964 	LayerQueueXY[0]       = (UINT32*)Next; Next += nScreenWidth * nScreenHeight * sizeof(UINT32);
1965 	LayerQueueXY[1]       = (UINT32*)Next; Next += nScreenWidth * nScreenHeight * sizeof(UINT32);
1966 	LayerQueueColour[0]   = (UINT32*)Next; Next += nScreenWidth * nScreenHeight * sizeof(UINT32);
1967 	LayerQueueColour[1]   = (UINT32*)Next; Next += nScreenWidth * nScreenHeight * sizeof(UINT32);
1968 	LayerQueuePriority[0] = Next; Next += nScreenWidth * nScreenHeight;
1969 	LayerQueuePriority[1] = Next; Next += nScreenWidth * nScreenHeight;
1970 	if (Kaneko16NumTiles2) {
1971 		Kaneko16Tiles2        = Next; Next += (Kaneko16NumTiles2 * 16 * 16);
1972 		LayerQueueXY[2]       = (UINT32*)Next; Next += nScreenWidth * nScreenHeight * sizeof(UINT32);
1973 		LayerQueueXY[3]       = (UINT32*)Next; Next += nScreenWidth * nScreenHeight * sizeof(UINT32);
1974 		LayerQueueColour[2]   = (UINT32*)Next; Next += nScreenWidth * nScreenHeight * sizeof(UINT32);
1975 		LayerQueueColour[3]   = (UINT32*)Next; Next += nScreenWidth * nScreenHeight * sizeof(UINT32);
1976 		LayerQueuePriority[2] = Next; Next += nScreenWidth * nScreenHeight;
1977 		LayerQueuePriority[3] = Next; Next += nScreenWidth * nScreenHeight;
1978 	}
1979 	if (Kaneko16Bg15) {
1980 		Kaneko16Bg15Data     = (UINT16*)Next; Next += (32 * 256 * 256) * sizeof(UINT16); // 32 bitmaps - 256 x 256
1981 		Kaneko16Palette      = (UINT32*)Next; Next += (0x001000 + 32768) * sizeof(UINT32);
1982 	} else {
1983 		Kaneko16Palette      = (UINT32*)Next; Next += 0x001000 * sizeof(UINT32);
1984 	}
1985 	MemEnd = Next;
1986 
1987 	return 0;
1988 }
1989 
BlazeonMemIndex()1990 static INT32 BlazeonMemIndex()
1991 {
1992 	UINT8 *Next; Next = Mem;
1993 
1994 	Kaneko16Rom           = Next; Next += 0x100000;
1995 	Kaneko16Z80Rom        = Next; Next += 0x020000;
1996 
1997 	MSM6295ROM            = Next; Next += 0x040000;
1998 	MSM6295ROMData        = Next; Next += 0x0c0000;
1999 	Kaneko16PrioBitmap         = Next; Next += 320 * 256;
2000 
2001 	RamStart = Next;
2002 
2003 	Kaneko16Ram           = Next; Next += 0x010000;
2004 	Kaneko16Z80Ram        = Next; Next += 0x002000;
2005 	Kaneko16PaletteRam    = Next; Next += 0x001000;
2006 	Kaneko16SpriteRam     = Next; Next += Kaneko16SpriteRamSize;
2007 	Kaneko16Video0Ram     = Next; Next += 0x001000;
2008 	Kaneko16Video1Ram     = Next; Next += 0x001000;
2009 	Kaneko16VScrl0Ram     = Next; Next += 0x001000;
2010 	Kaneko16VScrl1Ram     = Next; Next += 0x001000;
2011 
2012 	RamEnd = Next;
2013 
2014 	Kaneko16Sprites       = Next; Next += (Kaneko16NumSprites * 16 * 16);
2015 	Kaneko16Tiles         = Next; Next += (Kaneko16NumTiles * 16 * 16);
2016 	LayerQueueXY[0]       = (UINT32*)Next; Next += nScreenWidth * nScreenHeight * sizeof(UINT32);
2017 	LayerQueueXY[1]       = (UINT32*)Next; Next += nScreenWidth * nScreenHeight * sizeof(UINT32);
2018 	LayerQueueColour[0]   = (UINT32*)Next; Next += nScreenWidth * nScreenHeight * sizeof(UINT32);
2019 	LayerQueueColour[1]   = (UINT32*)Next; Next += nScreenWidth * nScreenHeight * sizeof(UINT32);
2020 	LayerQueuePriority[0] = Next; Next += nScreenWidth * nScreenHeight;
2021 	LayerQueuePriority[1] = Next; Next += nScreenWidth * nScreenHeight;
2022 	Kaneko16Palette       = (UINT32*)Next; Next += 0x001000 * sizeof(UINT32);
2023 
2024 	MemEnd = Next;
2025 
2026 	return 0;
2027 }
2028 
ShogwarrMemIndex()2029 static INT32 ShogwarrMemIndex()
2030 {
2031 	UINT8 *Next; Next = Mem;
2032 
2033 	Kaneko16Rom           = Next; Next += 0x040000;
2034 	Kaneko16McuRom	      = Next; Next += 0x020000;
2035 	MSM6295ROM            = Next; Next += 0x140000;
2036 	MSM6295ROMData        = Next; Next += 0x100000;
2037 	MSM6295ROMData2       = Next; Next += 0x200000;
2038 
2039 	Kaneko16NVRam         = Next; Next += 0x000100;
2040 
2041 	RamStart = Next;
2042 
2043 	Kaneko16Ram           = Next; Next += 0x010000;
2044 	Kaneko16MCURam        = Next; Next += 0x010000;
2045 	Kaneko16PaletteRam    = Next; Next += 0x010000;
2046 	Kaneko16SpriteRam     = Next; Next += Kaneko16SpriteRamSize;
2047 	Kaneko16Video0Ram     = Next; Next += 0x001000;
2048 	Kaneko16Video1Ram     = Next; Next += 0x001000;
2049 	Kaneko16VScrl0Ram     = Next; Next += 0x001000;
2050 	Kaneko16VScrl1Ram     = Next; Next += 0x001000;
2051 
2052 	RamEnd = Next;
2053 
2054 	Kaneko16Sprites       = Next; Next += (Kaneko16NumSprites * 16 * 16);
2055 	Kaneko16Tiles         = Next; Next += (Kaneko16NumTiles * 16 * 16);
2056 	LayerQueueXY[0]       = (UINT32*)Next; Next += nScreenWidth * nScreenHeight * sizeof(UINT32);
2057 	LayerQueueXY[1]       = (UINT32*)Next; Next += nScreenWidth * nScreenHeight * sizeof(UINT32);
2058 	LayerQueueColour[0]   = (UINT32*)Next; Next += nScreenWidth * nScreenHeight * sizeof(UINT32);
2059 	LayerQueueColour[1]   = (UINT32*)Next; Next += nScreenWidth * nScreenHeight * sizeof(UINT32);
2060 	LayerQueuePriority[0] = Next; Next += nScreenWidth * nScreenHeight;
2061 	LayerQueuePriority[1] = Next; Next += nScreenWidth * nScreenHeight;
2062 
2063 	Kaneko16Palette       = (UINT32*)Next; Next += 0x010000 * sizeof(UINT32);
2064 	MemEnd = Next;
2065 
2066 	return 0;
2067 }
2068 
2069 /*==============================================================================================
2070 Protection Calculator
2071 ===============================================================================================*/
2072 
2073 static struct {
2074 	UINT16 x1p, y1p, x1s, y1s;
2075 	UINT16 x2p, y2p, x2s, y2s;
2076 
2077 	INT16 x12, y12, x21, y21;
2078 
2079 	UINT16 mult_a, mult_b;
2080 } hit;
2081 
calc_compute_x(void)2082 static INT16 calc_compute_x(void)
2083 {
2084 	INT16 x_coll;
2085 
2086 	// X distance
2087 	if ((hit.x2p >= hit.x1p) && (hit.x2p < (hit.x1p + hit.x1s)))		// x2p inside x1
2088 		x_coll = (hit.x1s - (hit.x2p - hit.x1p));
2089 	else if ((hit.x1p >= hit.x2p) && (hit.x1p < (hit.x2p + hit.x2s)))	// x1p inside x2
2090 		x_coll = (hit.x2s - (hit.x1p - hit.x2p));
2091 	else																// normal/no overlap
2092 	 	x_coll = ((hit.x1s + hit.x2s)/2) - abs((hit.x1p + hit.x1s/2) - (hit.x2p + hit.x2s/2));
2093 
2094 	return x_coll;
2095 }
calc_compute_y(void)2096 static INT16 calc_compute_y(void)
2097 {
2098 	INT16 y_coll;
2099 
2100 	// Y distance
2101 	if ((hit.y2p >= hit.y1p) && (hit.y2p < (hit.y1p + hit.y1s)))		// y2p inside y1
2102 		y_coll = (hit.y1s - (hit.y2p - hit.y1p));
2103 	else if ((hit.y1p >= hit.y2p) && (hit.y1p < (hit.y2p + hit.y2s)))	// y1p inside y2
2104 		y_coll = (hit.y2s - (hit.y1p - hit.y2p));
2105 	else																// normal/no overlap
2106 		y_coll = ((hit.y1s + hit.y2s)/2) - abs((hit.y1p + hit.y1s/2) - (hit.y2p + hit.y2s/2));
2107 
2108 	return y_coll;
2109 }
2110 
BloodwarCalcRead(INT32 offset)2111 static UINT16 BloodwarCalcRead(INT32 offset)
2112 {
2113 	UINT16 data = 0;
2114 	INT16 x_coll, y_coll;
2115 
2116 	x_coll = calc_compute_x();
2117 	y_coll = calc_compute_y();
2118 
2119 	switch (offset)
2120 	{
2121 		case 0x00/2: // X distance
2122 			return x_coll;
2123 
2124 		case 0x02/2: // Y distance
2125 			return y_coll;
2126 
2127 		case 0x04/2: // similar to the hit detection from SuperNova, but much simpler
2128 
2129 			// 4th nibble: Y Absolute Collision -> possible values = 9,8,4,3,2
2130 			if      (hit.y1p >  hit.y2p)	data |= 0x2000;
2131 			else if (hit.y1p == hit.y2p)	data |= 0x4000;
2132 			else if (hit.y1p <  hit.y2p)	data |= 0x8000;
2133 			if (y_coll<0) data |= 0x1000;
2134 
2135 			// 3rd nibble: X Absolute Collision -> possible values = 9,8,4,3,2
2136 			if      (hit.x1p >  hit.x2p)	data |= 0x0200;
2137 			else if (hit.x1p == hit.x2p)	data |= 0x0400;
2138 			else if (hit.x1p <  hit.x2p)	data |= 0x0800;
2139 			if (x_coll<0) data |= 0x0100;
2140 
2141 			// 2nd nibble: always set to 4
2142 			data |= 0x0040;
2143 
2144 			// 1st nibble: XY Overlap Collision -> possible values = 0,2,4,f
2145 			if (x_coll>=0) data |= 0x0004;
2146 			if (y_coll>=0) data |= 0x0002;
2147 			if ((x_coll>=0)&&(y_coll>=0)) data |= 0x000F;
2148 
2149 			return data;
2150 
2151 		case 0x14/2:
2152 			return BurnRandom() & 0xffff;
2153 
2154 		case 0x20/2: return hit.x1p;
2155 		case 0x22/2: return hit.x1s;
2156 		case 0x24/2: return hit.y1p;
2157 		case 0x26/2: return hit.y1s;
2158 
2159 		case 0x2c/2: return hit.x2p;
2160 		case 0x2e/2: return hit.x2s;
2161 		case 0x30/2: return hit.y2p;
2162 		case 0x32/2: return hit.y2s;
2163 	}
2164 
2165 	return 0;
2166 }
2167 
BonkadvCalcRead(INT32 offset)2168 static UINT16 BonkadvCalcRead(INT32 offset)
2169 {
2170 	UINT16 data = 0;
2171 
2172 	switch (offset)
2173 	{
2174 		case 0x00/2: // watchdog
2175 			return 0;
2176 
2177 		case 0x02/2: // unknown (yet!), used by *MANY* games !!!
2178 			break;
2179 
2180 		case 0x04/2: // similar to the hit detection from SuperNova, but much simpler
2181 
2182 			// X Absolute Collision
2183 			if      (hit.x1p >  hit.x2p)	data |= 0x0200;
2184 			else if (hit.x1p == hit.x2p)	data |= 0x0400;
2185 			else if (hit.x1p <  hit.x2p)	data |= 0x0800;
2186 
2187 			// Y Absolute Collision
2188 			if      (hit.y1p >  hit.y2p)	data |= 0x2000;
2189 			else if (hit.y1p == hit.y2p)	data |= 0x4000;
2190 			else if (hit.y1p <  hit.y2p)	data |= 0x8000;
2191 
2192 			// XY Overlap Collision
2193 			hit.x12 = (hit.x1p) - (hit.x2p + hit.x2s);
2194 			hit.y12 = (hit.y1p) - (hit.y2p + hit.y2s);
2195 			hit.x21 = (hit.x1p + hit.x1s) - (hit.x2p);
2196 			hit.y21 = (hit.y1p + hit.y1s) - (hit.y2p);
2197 
2198 			if ((hit.x12 < 0) && (hit.y12 < 0) &&
2199 				(hit.x21 >= 0) && (hit.y21 >= 0))
2200 					data |= 0x0001;
2201 
2202 			return data;
2203 
2204 		case 0x10/2:
2205 			return (((UINT32)hit.mult_a * (UINT32)hit.mult_b) >> 16);
2206 		case 0x12/2:
2207 			return (((UINT32)hit.mult_a * (UINT32)hit.mult_b) & 0xffff);
2208 
2209 		case 0x14/2:
2210 			return BurnRandom() & 0xffff;
2211 	}
2212 
2213 	return 0;
2214 }
2215 
BloodwarCalcWrite(INT32 offset,UINT16 data)2216 static void BloodwarCalcWrite(INT32 offset, UINT16 data)
2217 {
2218 	switch (offset) {
2219 		case 0x20 >> 1: hit.x1p = data; return;
2220 		case 0x22 >> 1: hit.x1s = data; return;
2221 		case 0x24 >> 1: hit.y1p = data; return;
2222 		case 0x26 >> 1: hit.y1s = data; return;
2223 
2224 		case 0x2c >> 1: hit.x2p = data; return;
2225 		case 0x2e >> 1: hit.x2s = data; return;
2226 		case 0x30 >> 1: hit.y2p = data; return;
2227 		case 0x32 >> 1: hit.y2s = data; return;
2228 	}
2229 }
2230 
BonkadvCalcWrite(INT32 offset,UINT16 data)2231 static void BonkadvCalcWrite(INT32 offset, UINT16 data)
2232 {
2233 	switch (offset) {
2234 		case 0x00 >> 1: hit.x1p = data; return;
2235 		case 0x02 >> 1: hit.x1s = data; return;
2236 		case 0x04 >> 1: hit.y1p = data; return;
2237 		case 0x06 >> 1: hit.y1s = data; return;
2238 		case 0x08 >> 1: hit.x2p = data; return;
2239 		case 0x0a >> 1: hit.x2s = data; return;
2240 		case 0x0c >> 1: hit.y2p = data; return;
2241 		case 0x0e >> 1: hit.y2s = data; return;
2242 		case 0x10 >> 1: hit.mult_a = data; return;
2243 		case 0x12 >> 1: hit.mult_b = data; return;
2244 	}
2245 }
2246 
2247 /*==============================================================================================
2248 Protection Calculator  - Brapboys & shogwarr
2249 ===============================================================================================*/
2250 
2251 struct calc3_t
2252 {
2253 	int mcu_status;
2254 	int mcu_command_offset;
2255 	UINT16 mcu_crc;
2256 	UINT8 decryption_key_byte;
2257 	UINT8 alternateswaps;
2258 	UINT8 shift;
2259 	UINT8 subtracttype;
2260 	UINT8 mode;
2261 	UINT8 blocksize_offset;
2262 	UINT16 dataend;
2263 	UINT16 database;
2264 	int data_header[2];
2265 	UINT32 writeaddress;
2266 	UINT32 writeaddress_current;
2267 	UINT16 dsw_addr;
2268 	UINT16 eeprom_addr;
2269 	UINT16 poll_addr;
2270 	UINT16 checksumaddress;
2271 };
2272 
2273 static calc3_t m_calc3;
2274 
2275 struct calc3_hit_t
2276 {
2277 	int x1p, y1p, z1p, x1s, y1s, z1s;
2278 	int x2p, y2p, z2p, x2s, y2s, z2s;
2279 
2280 	int x1po, y1po, z1po, x1so, y1so, z1so;
2281 	int x2po, y2po, z2po, x2so, y2so, z2so;
2282 
2283 	int x12, y12, z12, x21, y21, z21;
2284 
2285 	int x_coll, y_coll, z_coll;
2286 
2287 	int x1tox2, y1toy2, z1toz2;
2288 
2289 	UINT16 mult_a, mult_b;
2290 
2291 	UINT16 flags;
2292 	UINT16 mode;
2293 };
2294 
2295 static calc3_hit_t m_hit3;
2296 
type2_calc_compute(int x1,int w1,int x2,int w2)2297 static int type2_calc_compute(int x1, int w1, int x2, int w2)
2298 {
2299 	int dist;
2300 
2301 	if(x2>=x1 && x2+w2<=(x1+w1))
2302 	{
2303 		//x2 inside x1
2304 		dist=w2;
2305 	}
2306 	else
2307 	{
2308 		if(x1>=x2 && x1+w1<=(x2+w2))
2309 		{
2310 			//x1 inside x2
2311 			dist=w1;
2312 		}
2313 		else
2314 		{
2315 			if(x2<x1)
2316 			{
2317 				//swap
2318 				int tmp=x1;
2319 				x1=x2;
2320 				x2=tmp;
2321 				tmp=w1;
2322 				w1=w2;
2323 				w2=tmp;
2324 			}
2325 			dist=x1+w1-x2;
2326 		}
2327 	}
2328 	return dist;
2329 }
2330 
2331 //calc segment coordinates
2332 
type2_calc_org(int mode,int x0,int s0,int * x1,int * s1)2333 static void type2_calc_org(int mode, int x0, int s0,  int* x1, int* s1)
2334 {
2335 	switch(mode)
2336 	{
2337 		case 0: *x1=x0; *s1=s0; break;
2338 		case 1: *x1=x0-s0/2; *s1=s0; break;
2339 		case 2: *x1=x0-s0; *s1=s0; break;
2340 		case 3: *x1=x0-s0; *s1=2*s0; break;
2341 	}
2342 	//x1 is the left most coord, s1 = width
2343 }
2344 
type2_recalc_collisions(calc3_hit_t & hit3)2345 static void type2_recalc_collisions(calc3_hit_t &hit3)
2346 {
2347 	//calculate positions and sizes
2348 
2349 	int mode=hit3.mode;
2350 
2351 	hit3.flags=0;
2352 
2353 	type2_calc_org((mode>>0)&3, hit3.x1po, hit3.x1so, &hit3.x1p, &hit3.x1s);
2354 	type2_calc_org((mode>>2)&3, hit3.y1po, hit3.y1so, &hit3.y1p, &hit3.y1s);
2355 	type2_calc_org((mode>>4)&3, hit3.z1po, hit3.z1so, &hit3.z1p, &hit3.z1s);
2356 
2357 	type2_calc_org((mode>>8)&3, hit3.x2po, hit3.x2so, &hit3.x2p, &hit3.x2s);
2358 	type2_calc_org((mode>>10)&3, hit3.y2po, hit3.y2so, &hit3.y2p, &hit3.y2s);
2359 	type2_calc_org((mode>>12)&3, hit3.z2po, hit3.z2so, &hit3.z2p, &hit3.z2s);
2360 
2361 	hit3.x1tox2=abs(hit3.x2po-hit3.x1po);
2362 	hit3.y1toy2=abs(hit3.y2po-hit3.y1po);
2363 	hit3.z1toz2=abs(hit3.z2po-hit3.z1po);
2364 
2365 	hit3.x_coll = type2_calc_compute(hit3.x1p, hit3.x1s, hit3.x2p, hit3.x2s);
2366 	hit3.y_coll = type2_calc_compute(hit3.y1p, hit3.y1s, hit3.y2p, hit3.y2s);
2367 	hit3.z_coll = type2_calc_compute(hit3.z1p, hit3.z1s, hit3.z2p, hit3.z2s);
2368 
2369 	// 4th nibble: Y Absolute Collision -> possible values = 9,8,4,3,2
2370 	if      (hit3.y1p >  hit3.y2p)  hit3.flags |= 0x2000;
2371 	else if (hit3.y1p == hit3.y2p)  hit3.flags |= 0x4000;
2372 	else if (hit3.y1p <  hit3.y2p)  hit3.flags |= 0x8000;
2373 	if (hit3.y_coll<0) hit3.flags |= 0x1000;
2374 
2375 	// 3rd nibble: X Absolute Collision -> possible values = 9,8,4,3,2
2376 	if      (hit3.x1p >  hit3.x2p)  hit3.flags |= 0x0200;
2377 	else if (hit3.x1p == hit3.x2p)  hit3.flags |= 0x0400;
2378 	else if (hit3.x1p <  hit3.x2p)  hit3.flags |= 0x0800;
2379 	if (hit3.x_coll<0) hit3.flags |= 0x0100;
2380 
2381 	// 2nd nibble: Z Absolute Collision -> possible values = 9,8,4,3,2
2382 	if      (hit3.z1p >  hit3.z2p)  hit3.flags |= 0x0020;
2383 	else if (hit3.z1p == hit3.z2p)  hit3.flags |= 0x0040;
2384 	else if (hit3.z1p <  hit3.z2p)  hit3.flags |= 0x0080;
2385 	if (hit3.z_coll<0) hit3.flags |= 0x0010;
2386 
2387 	// 1st nibble: XYZ Overlap Collision
2388 	if ((hit3.x_coll>=0)&&(hit3.y_coll>=0)&&(hit3.z_coll>=0)) hit3.flags |= 0x0008;
2389 	if ((hit3.x_coll>=0)&&(hit3.z_coll>=0)) hit3.flags |= 0x0004;
2390 	if ((hit3.y_coll>=0)&&(hit3.z_coll>=0)) hit3.flags |= 0x0002;
2391 	if ((hit3.x_coll>=0)&&(hit3.y_coll>=0)) hit3.flags |= 0x0001;
2392 }
2393 
kaneko_hit_type2_write(INT32 offset,UINT16 data)2394 static void kaneko_hit_type2_write(INT32 offset, UINT16 data)
2395 {
2396 	calc3_hit_t &hit3 = m_hit3;
2397 	int idx=offset*4;
2398 	switch (idx)
2399 	{
2400 		case 0x00:
2401 		case 0x28: hit3.x1po = data; break;
2402 		case 0x04:
2403 		case 0x2c: hit3.x1so = data; break;
2404 		case 0x08:
2405 		case 0x30: hit3.y1po = data; break;
2406 		case 0x0c:
2407 		case 0x34: hit3.y1so = data; break;
2408 		case 0x10:
2409 		case 0x58: hit3.x2po = data; break;
2410 		case 0x14:
2411 		case 0x5c: hit3.x2so = data; break;
2412 		case 0x18:
2413 		case 0x60: hit3.y2po = data; break;
2414 		case 0x1c:
2415 		case 0x64: hit3.y2so = data; break;
2416 		case 0x38:
2417 		case 0x50: hit3.z1po = data; break;
2418 		case 0x3c:
2419 		case 0x54: hit3.z1so = data; break;
2420 		case 0x20:
2421 		case 0x68: hit3.z2po = data; break;
2422 		case 0x24:
2423 		case 0x6c: hit3.z2so = data; break;
2424 		case 0x70: hit3.mode=data;break;
2425 
2426 	//	default:
2427 	//		logerror("CPU #0 PC %06x: warning - write unmapped hit address %06x [ %06x] = %06x\n",space.device().safe_pc(),offset<<1, idx, data);
2428 	}
2429 
2430 	type2_recalc_collisions(hit3);
2431 }
2432 
kaneko_hit_type2_read(INT32 offset)2433 static UINT16 kaneko_hit_type2_read(INT32 offset)
2434 {
2435 	calc3_hit_t &hit3 = m_hit3;
2436 	int idx=offset*4;
2437 
2438 //	bprintf (0, _T("HITR: %x\n"), idx);
2439 
2440 	switch (idx)
2441 	{
2442 		case 0x00: // X distance
2443 		case 0x10:
2444 			return hit3.x_coll;
2445 
2446 		case 0x04: // Y distance
2447 		case 0x14:
2448 			return hit3.y_coll;
2449 
2450 		case 0x18: // Z distance
2451 			return hit3.z_coll;
2452 
2453 		case 0x08:
2454 		case 0x1c:
2455 			return hit3.flags;
2456 
2457 		case 0x28:
2458 			return (BurnRandom() & 0xffff);
2459 
2460 		case 0x40: return hit3.x1po;
2461 		case 0x44: return hit3.x1so;
2462 		case 0x48: return hit3.y1po;
2463 		case 0x4c: return hit3.y1so;
2464 		case 0x50: return hit3.z1po;
2465 		case 0x54: return hit3.z1so;
2466 
2467 		case 0x58: return hit3.x2po;
2468 		case 0x5c: return hit3.x2so;
2469 		case 0x60: return hit3.y2po;
2470 		case 0x64: return hit3.y2so;
2471 		case 0x68: return hit3.z2po;
2472 		case 0x6c: return hit3.z2so;
2473 
2474 		case 0x80: return hit3.x1tox2;
2475 		case 0x84: return hit3.y1toy2;
2476 		case 0x88: return hit3.z1toz2;
2477 
2478 		//default:
2479 		//	logerror("CPU #0 PC %06x: warning - read unmapped calc address %06x [ %06x]\n",space.device().safe_pc(),offset<<1, idx);
2480 	}
2481 
2482 	return 0;
2483 }
2484 
shift_bits(UINT8 dat,int bits)2485 static UINT8 shift_bits(UINT8 dat, int bits)
2486 {
2487 	bits &=0x7;
2488 
2489 	if (bits==0) return BITSWAP08(dat, 7,6,5,4,3,2,1,0);
2490 	if (bits==1) return BITSWAP08(dat, 6,5,4,3,2,1,0,7);
2491 	if (bits==2) return BITSWAP08(dat, 5,4,3,2,1,0,7,6);
2492 	if (bits==3) return BITSWAP08(dat, 4,3,2,1,0,7,6,5);
2493 	if (bits==4) return BITSWAP08(dat, 3,2,1,0,7,6,5,4);
2494 	if (bits==5) return BITSWAP08(dat, 2,1,0,7,6,5,4,3);
2495 	if (bits==6) return BITSWAP08(dat, 1,0,7,6,5,4,3,2);
2496 	if (bits==7) return BITSWAP08(dat, 0,7,6,5,4,3,2,1);
2497 
2498 	return dat;
2499 }
2500 
calc3_decompress_table(int tabnum,UINT8 * dstram,int dstoffset)2501 static int calc3_decompress_table(int tabnum, UINT8* dstram, int dstoffset)
2502 {
2503 	calc3_t &calc3 = m_calc3;
2504 
2505 	UINT8* datarom = Kaneko16McuRom;
2506 
2507 	UINT8 numregions;
2508 	UINT16 length;
2509 	int local_counter=0;
2510 	int x;
2511 	int offset = 0;
2512 
2513 	numregions = datarom[offset+0];
2514 
2515 	if (tabnum > numregions)
2516 	{
2517 		return 0;
2518 	}
2519 
2520 	datarom++;
2521 
2522 	for (x=0;x<tabnum;x++)
2523 	{
2524 		UINT8 blocksize_offset = datarom[offset+0]; // location of the 'block length'
2525 		offset+= blocksize_offset+1;
2526 		length = datarom[offset+0] | (datarom[offset+1]<<8);
2527 		offset+=length+2;
2528 	}
2529 
2530 	{
2531 		UINT16 inline_table_base = 0;
2532 		UINT16 inline_table_size = 0;
2533 		calc3.database = offset;
2534 		calc3.blocksize_offset =    datarom[offset+0]; // location of the 'block length'
2535 		calc3.mode =                datarom[offset+1];
2536 		calc3.alternateswaps =             datarom[offset+2];
2537 		calc3.shift = (calc3.alternateswaps &0xf0)>>4;
2538 		calc3.subtracttype = (calc3.alternateswaps &0x03);
2539 		calc3.alternateswaps &= 0x0c;
2540 		calc3.alternateswaps >>=2;
2541 
2542 		calc3.decryption_key_byte = datarom[offset+3];
2543 
2544 		if (calc3.blocksize_offset>3)
2545 		{
2546 			inline_table_base = offset+4;
2547 			inline_table_size = calc3.blocksize_offset-3;
2548 		}
2549 
2550 		offset+= calc3.blocksize_offset+1;
2551 		length = datarom[offset+0] | (datarom[offset+1]<<8);
2552 		offset+=2;
2553 
2554 		{
2555 			int i;
2556 
2557 			if (length==0x00)
2558 			{
2559 				if (calc3.mode==0x06)
2560 				{
2561 					calc3.writeaddress_current = 0x202000;
2562 					//calc3.writeaddress_current = 0x20c000;
2563 				}
2564 				else if (calc3.mode==0x07)
2565 				{
2566 					// also calls empty table with Mode? 07
2567 					// maybe they reset to different points?
2568 				}
2569 				else if (calc3.mode==0x08 && !dstram)
2570 				{
2571 					UINT8 *eeprom = (UINT8*)Kaneko16NVRam;
2572 
2573 					for (i=0;i<0x80;i++)
2574 					{
2575 						eeprom[i^1] = SekReadByte(calc3.eeprom_addr+0x200000+i);
2576 					}
2577 				}
2578 
2579 				return 0;
2580 			}
2581 
2582 			if (inline_table_size)
2583 			{
2584 				UINT8 extra[]  = { 0x14,0xf0,0xf8,0xd2,0xbe,0xfc,0xac,0x86,0x64,0x08,0x0c,0x74,0xd6,0x6a,0x24,0x12,0x1a,0x72,0xba,0x48,0x76,0x66,0x4a,0x7c,0x5c,0x82,0x0a,0x86,0x82,0x02,0xe6 };
2585 				UINT8 extra2[] = { 0x2f,0x04,0xd1,0x69,0xad,0xeb,0x10,0x95,0xb0,0x2f,0x0a,0x83,0x7d,0x4e,0x2a,0x07,0x89,0x52,0xca,0x41,0xf1,0x4f,0xaf,0x1c,0x01,0xe9,0x89,0xd2,0xaf,0xcd };
2586 
2587 				for (i=0;i<length;i++)
2588 				{
2589 					UINT8 dat=0;
2590 
2591 					if (calc3.subtracttype==3 && calc3.alternateswaps ==0)
2592 					{
2593 						UINT8 inlinet = datarom[inline_table_base + (i%inline_table_size)];
2594 						dat = datarom[offset+i];
2595 
2596 						dat -= inlinet;
2597 
2598 						if (((i%inline_table_size)&1)==0)
2599 						{
2600 							dat -= extra[(i%inline_table_size)>>1];
2601 						}
2602 					}
2603 					else
2604 					{
2605 						if ( ((i / inline_table_size)&1)==0)
2606 						{
2607 							if (((i%inline_table_size)&1)==1)
2608 							{
2609 								UINT8 inlinet = datarom[inline_table_base + (i%inline_table_size)];
2610 								dat = datarom[offset+i];
2611 								dat -= inlinet;
2612 								dat = shift_bits(dat, calc3.shift);
2613 							}
2614 							else
2615 							{
2616 								UINT8 inlinet = datarom[inline_table_base + (i%inline_table_size)];
2617 								dat = datarom[offset+i];
2618 
2619 								if (calc3.subtracttype!=0x02)
2620 								{
2621 									dat -= inlinet;
2622 									dat -= extra[(i%inline_table_size)>>1];
2623 								}
2624 								else
2625 								{
2626 									dat += inlinet;
2627 									dat += extra[(i%inline_table_size)>>1];
2628 								}
2629 
2630 								dat = shift_bits(dat, 8-calc3.shift);
2631 							}
2632 						}
2633 						else
2634 						{
2635 							if (((i%inline_table_size)&1)==0)
2636 							{
2637 								UINT8 inlinet = datarom[inline_table_base + (i%inline_table_size)];
2638 								dat = datarom[offset+i];
2639 								dat -= inlinet;
2640 								dat = shift_bits(dat, calc3.shift);
2641 							}
2642 							else
2643 							{
2644 								dat = datarom[offset+i];
2645 
2646 								if (calc3.subtracttype!=0x02)
2647 								{
2648 									dat -= extra2[(i%inline_table_size)>>1];
2649 								}
2650 								else
2651 								{
2652 									dat += extra2[(i%inline_table_size)>>1];
2653 								}
2654 								dat = shift_bits(dat, 8-calc3.shift);
2655 							}
2656 						}
2657 					}
2658 
2659 					if(local_counter>1)
2660 					{
2661 						SekWriteByte((dstoffset+i), dat);
2662 
2663 						// debug, used to output tables at the start
2664 						if (dstram)
2665 						{
2666 							dstram[(dstoffset+i)^1] = dat;
2667 						}
2668 					}
2669 					else
2670 						calc3.data_header[local_counter]=dat;
2671 
2672 					++local_counter;
2673 				}
2674 			}
2675 			else
2676 			{
2677 				const INT16* key = calc3_keydata+(calc3.decryption_key_byte*0x40);
2678 
2679 				for (i=0;i<length;i++)
2680 				{
2681 					UINT8 dat = datarom[offset+i];
2682 					UINT8 keydat = (UINT8)key[i&0x3f];
2683 
2684 					{
2685 						if (calc3.subtracttype==0)
2686 						{
2687 							//dat = dat;
2688 						}
2689 						else if (calc3.subtracttype==1)
2690 						{
2691 							if ((i&1)==1) dat += keydat;
2692 							else dat -= keydat;
2693 						}
2694 						else if (calc3.subtracttype==2)
2695 						{
2696 							if ((i&1)==0) dat += keydat;
2697 							else dat -= keydat;
2698 						}
2699 						else if (calc3.subtracttype==3)
2700 						{
2701 							dat -= keydat;
2702 						}
2703 
2704 						if (calc3.alternateswaps == 0)
2705 						{
2706 							if ((i&1)==0) dat = shift_bits(dat, 8-calc3.shift);
2707 							else          dat = shift_bits(dat, calc3.shift);
2708 						}
2709 						else if (calc3.alternateswaps==1)
2710 						{
2711 							dat = shift_bits(dat, 8-calc3.shift);
2712 						}
2713 						else if (calc3.alternateswaps==2)
2714 						{
2715 							dat = shift_bits(dat, calc3.shift);
2716 						}
2717 						else if (calc3.alternateswaps==3)
2718 						{
2719 							// same as 0
2720 							if ((i&1)==0) dat = shift_bits(dat, 8-calc3.shift);
2721 							else          dat = shift_bits(dat, calc3.shift);
2722 						}
2723 					}
2724 
2725 					if(local_counter>1)
2726 					{
2727 						SekWriteByte((dstoffset+i), dat);
2728 
2729 						// debug, used to output tables at the start
2730 						if (dstram)
2731 						{
2732 							dstram[(dstoffset+i)^1] = dat;
2733 						}
2734 					}
2735 					else
2736 						calc3.data_header[local_counter]=dat;
2737 
2738 					++local_counter;
2739 				}
2740 			}
2741 		}
2742 
2743 		calc3.dataend = offset+length+1;
2744 	}
2745 
2746 	return length;
2747 }
2748 
shogwarr_calc3_mcu_run()2749 static void shogwarr_calc3_mcu_run()
2750 {
2751 	calc3_t &calc3 = m_calc3;
2752 	UINT16 mcu_command;
2753 	UINT16 *m_calc3_mcuram = (UINT16*)(Kaneko16MCURam);
2754 
2755 	if (calc3.mcu_status != (1|2|4|8)) return;
2756 
2757 	if (calc3.dsw_addr) SekWriteByte((calc3.dsw_addr+0x200000), (~Kaneko16Dip[0])&0xff);
2758 
2759 	mcu_command = m_calc3_mcuram[calc3.mcu_command_offset/2 + 0];
2760 
2761 	if (mcu_command == 0) return;
2762 
2763 	if (mcu_command>0)
2764 	{
2765 		if (mcu_command == 0xff)
2766 		{
2767 			// clear old command (handshake to main cpu)
2768 			m_calc3_mcuram[(calc3.mcu_command_offset>>1)+0] = 0x0000;
2769 
2770 			calc3.dsw_addr =           m_calc3_mcuram[(0>>1) + 1];
2771 			calc3.eeprom_addr =        m_calc3_mcuram[(0>>1) + 2];
2772 			calc3.mcu_command_offset = m_calc3_mcuram[(0>>1) + 3];
2773 			calc3.poll_addr =          m_calc3_mcuram[(0>>1) + 4];
2774 			calc3.checksumaddress =    m_calc3_mcuram[(0>>1) + 5];
2775 			calc3.writeaddress =      (m_calc3_mcuram[(0>>1) + 6] << 16) | (m_calc3_mcuram[(0>>1) + 7]);
2776 
2777 			// set our current write / stack pointer to the address specified
2778 			calc3.writeaddress_current = calc3.writeaddress;
2779 
2780 			m_calc3_mcuram[calc3.checksumaddress / 2] = calc3.mcu_crc;              // MCU Rom Checksum!
2781 
2782 			UINT8 *eeprom = (UINT8*)Kaneko16NVRam;
2783 
2784 			for (INT32 i=0;i<0x80;i++)
2785 			{
2786 				SekWriteByte((calc3.eeprom_addr+0x200000+i), eeprom[i^1]);
2787 			}
2788 		}
2789 		else
2790 		{
2791 			int num_transfers = mcu_command;
2792 
2793 			// clear old command (handshake to main cpu)
2794 			m_calc3_mcuram[calc3.mcu_command_offset>>1] = 0x0000;
2795 
2796 			for (INT32 i=0;i<num_transfers;i++)
2797 			{
2798 				int param1 = m_calc3_mcuram[(calc3.mcu_command_offset>>1) + 1 + (2*i)];
2799 				int param2 = m_calc3_mcuram[(calc3.mcu_command_offset>>1) + 2 + (2*i)];
2800 				UINT8  commandtabl = (param1&0xff00) >> 8;
2801 				UINT16 commandaddr =param2;
2802 				UINT8  commandunk =  (param1&0x00ff);
2803 				{
2804 					int length = calc3_decompress_table(commandtabl, 0, calc3.writeaddress_current-2);
2805 
2806 					if (length)
2807 					{
2808 						int write=commandaddr;
2809 
2810 						SekWriteByte((write+0x200000), calc3.data_header[0]);
2811 						SekWriteByte((write+0x200001), calc3.data_header[1]);
2812 
2813 						write=commandaddr+(char)commandunk;
2814 
2815 						SekWriteWord(write+0x200000, (calc3.writeaddress_current>>16)&0xffff);
2816 						SekWriteWord(write+0x200002, (calc3.writeaddress_current&0xffff));
2817 
2818 						calc3.writeaddress_current += ((length+3)&(~1));
2819 					}
2820 				}
2821 			}
2822 		}
2823 	}
2824 
2825 	if (Shogwarr == 0) { // Hack to get us past brapboys calc test
2826 		if (Kaneko16MCURam[0xE3] == 0x7F) {
2827 			Kaneko16MCURam[0xE3] |= 0x80;
2828 		}
2829 	}
2830 }
2831 
shogwarr_initial_scan_tables()2832 static void shogwarr_initial_scan_tables()
2833 {
2834 	calc3_t &calc3 = m_calc3;
2835 
2836 	UINT8* datarom = Kaneko16McuRom;
2837 
2838 	calc3.mcu_crc = 0;
2839 
2840 	for (INT32 x=0;x<0x20000;x++)
2841 	{
2842 		calc3.mcu_crc+=datarom[x];
2843 	}
2844 }
2845 
2846 /*==============================================================================================
2847 Toybox MCU
2848 ===============================================================================================*/
2849 
ToyboxMCUInit()2850 static void ToyboxMCUInit()
2851 {
2852 	memset(ToyboxMCUCom, 0, 4 * sizeof(UINT16));
2853 }
2854 
ToyboxMCUStatusRead()2855 static UINT16 ToyboxMCUStatusRead()
2856 {
2857 	return 0;
2858 }
2859 
2860 #define MCU_RESPONSE(d) memcpy(&MCURam[MCUOffset], d, sizeof(d))
2861 
BloodwarMCURun()2862 static void BloodwarMCURun()
2863 {
2864 	UINT16 *MCURam = (UINT16*)Kaneko16MCURam;
2865 	UINT16 *NVRam = (UINT16*)Kaneko16NVRam;
2866 
2867 	UINT16 MCUCommand = MCURam[0x10/2];
2868 	UINT16 MCUOffset = MCURam[0x12/2] >> 1;
2869 	UINT16 MCUData = MCURam[0x14/2];
2870 
2871 	switch (MCUCommand >> 8) {
2872 		case 0x02: {
2873 			memcpy(MCURam + MCUOffset, NVRam, 128);
2874 			return;
2875 		}
2876 
2877 		case 0x03: {
2878 			MCURam[MCUOffset + 0] = 0xff00 - (Kaneko16Dip[0] << 8);
2879 			return;
2880 		}
2881 
2882 		case 0x04: {
2883 			switch (MCUData) {
2884 				// unknown purpose data
2885 				case 0x01: MCU_RESPONSE(bloodwar_mcu_4_01); break; // Warrior 1
2886 				case 0x02: MCU_RESPONSE(bloodwar_mcu_4_02); break; // Warrior 2
2887 				case 0x03: MCU_RESPONSE(bloodwar_mcu_4_03); break; // Warrior 3
2888 				case 0x04: MCU_RESPONSE(bloodwar_mcu_4_04); break; // Warrior 4
2889 				case 0x05: MCU_RESPONSE(bloodwar_mcu_4_05); break; // Warrior 5
2890 				case 0x06: MCU_RESPONSE(bloodwar_mcu_4_06); break; // Warrior 6
2891 				case 0x07: MCU_RESPONSE(bloodwar_mcu_4_07); break; // Warrior 7
2892 				case 0x08: MCU_RESPONSE(bloodwar_mcu_4_08); break; // Warrior 8
2893 				case 0x09: MCU_RESPONSE(bloodwar_mcu_4_09); break; // Warrior 9
2894 
2895 				// palette data
2896 				case 0x0a: MCU_RESPONSE(bloodwar_mcu_4_0a); break; // Warrior 1 Player 1
2897 				case 0x0b: MCU_RESPONSE(bloodwar_mcu_4_0b); break; // Warrior 1 Player 2
2898 				case 0x0c: MCU_RESPONSE(bloodwar_mcu_4_0c); break; // Warrior 5 Player 1
2899 				case 0x0d: MCU_RESPONSE(bloodwar_mcu_4_0d); break; // Warrior 5 Player 2
2900 				case 0x0e: MCU_RESPONSE(bloodwar_mcu_4_0e); break; // Warrior 4 Player 2
2901 				case 0x0f: MCU_RESPONSE(bloodwar_mcu_4_0f); break; // Warrior 4 Player 1
2902 				case 0x10: MCU_RESPONSE(bloodwar_mcu_4_10); break; // Warrior 6 Player 1
2903 				case 0x11: MCU_RESPONSE(bloodwar_mcu_4_11); break; // Warrior 6 Player 2
2904 				case 0x12: MCU_RESPONSE(bloodwar_mcu_4_12); break; // Warrior 9 Player 1
2905 				case 0x13: MCU_RESPONSE(bloodwar_mcu_4_13); break; // Warrior 9 Player 2
2906 				case 0x14: MCU_RESPONSE(bloodwar_mcu_4_14); break; // Warrior 7 Player 1
2907 				case 0x15: MCU_RESPONSE(bloodwar_mcu_4_15); break; // Warrior 7 Player 2
2908 				case 0x16: MCU_RESPONSE(bloodwar_mcu_4_16); break; // Warrior 8 Player 1
2909 				case 0x17: MCU_RESPONSE(bloodwar_mcu_4_17); break; // Warrior 8 Player 2
2910 				case 0x18: MCU_RESPONSE(bloodwar_mcu_4_18); break; // Warrior 2 Player 2
2911 				case 0x19: MCU_RESPONSE(bloodwar_mcu_4_19); break; // Warrior 2 Player 1
2912 				case 0x1a: MCU_RESPONSE(bloodwar_mcu_4_1a); break; // Warrior 3 Player 1
2913 				case 0x1b: MCU_RESPONSE(bloodwar_mcu_4_1b); break; // Warrior 3 Player 2
2914 
2915 				// tilemap data
2916 				case 0x1c: MCU_RESPONSE(bloodwar_mcu_4_1c); break; // Warrior 8
2917 				case 0x1d: MCU_RESPONSE(bloodwar_mcu_4_1d); break; // Warrior 2
2918 				case 0x1e: MCU_RESPONSE(bloodwar_mcu_4_1e); break; // Warrior 3
2919 				case 0x1f: MCU_RESPONSE(bloodwar_mcu_4_1f); break; // Warrior 5
2920 				case 0x20: MCU_RESPONSE(bloodwar_mcu_4_20); break; // Warrior 4
2921 				case 0x21: MCU_RESPONSE(bloodwar_mcu_4_21); break; // Warrior 6
2922 				case 0x22: MCU_RESPONSE(bloodwar_mcu_4_22); break; // Warrior 1
2923 				case 0x23: MCU_RESPONSE(bloodwar_mcu_4_23); break; // Warrior 9
2924 				case 0x24: MCU_RESPONSE(bloodwar_mcu_4_24); break; // Warrior 7
2925 
2926 				// fighter data: pointers to ROM data
2927 				case 0x25: MCU_RESPONSE(bloodwar_mcu_4_25); break; // Warrior 1
2928 				case 0x26: MCU_RESPONSE(bloodwar_mcu_4_26); break; // Warrior 2
2929 				case 0x27: MCU_RESPONSE(bloodwar_mcu_4_27); break; // Warrior 3
2930 				case 0x28: MCU_RESPONSE(bloodwar_mcu_4_28); break; // Warrior 4
2931 				case 0x29: MCU_RESPONSE(bloodwar_mcu_4_29); break; // Warrior 5
2932 				case 0x2a: MCU_RESPONSE(bloodwar_mcu_4_2a); break; // Warrior 6
2933 				case 0x2b: MCU_RESPONSE(bloodwar_mcu_4_2b); break; // Warrior 7
2934 				case 0x2c: MCU_RESPONSE(bloodwar_mcu_4_2c); break; // Warrior 8
2935 				case 0x2d: MCU_RESPONSE(bloodwar_mcu_4_2d); break; // Warrior 9
2936 			}
2937 			return;
2938 		}
2939 
2940 		case 0x42: {
2941 			memcpy(NVRam, MCURam + MCUOffset, 128);
2942 			return;
2943 		}
2944 	}
2945 }
2946 
BonkadvMCURun()2947 static void BonkadvMCURun()
2948 {
2949 	UINT16 *MCURam = (UINT16*)Kaneko16MCURam;
2950 	UINT16 *NVRam = (UINT16*)Kaneko16NVRam;
2951 
2952 	UINT16 MCUCommand = MCURam[0x10/2];
2953 	UINT16 MCUOffset = MCURam[0x12/2] >> 1;
2954 	UINT16 MCUData = MCURam[0x14/2];
2955 
2956 	switch (MCUCommand >> 8) {
2957 		case 0x02: {
2958 			memcpy(MCURam + MCUOffset, NVRam, 128);
2959 			return;
2960 		}
2961 
2962 		case 0x03: {
2963 			MCURam[MCUOffset + 0] = 0xff00 - (Kaneko16Dip[0] << 8);
2964 			return;
2965 		}
2966 
2967 		case 0x04: {
2968 			switch (MCUData) {
2969 				// static, in this order, at boot/reset
2970 				case 0x34: MCU_RESPONSE(bonkadv_mcu_4_34); break;
2971 				case 0x30: MCU_RESPONSE(bonkadv_mcu_4_30); break;
2972 				case 0x31: MCU_RESPONSE(bonkadv_mcu_4_31); break;
2973 				case 0x32: MCU_RESPONSE(bonkadv_mcu_4_32); break;
2974 				case 0x33: MCU_RESPONSE(bonkadv_mcu_4_33); break;
2975 
2976 				// dynamic, per-level (29), in level order
2977 				case 0x00: MCU_RESPONSE(bonkadv_mcu_4_00); break;
2978 				case 0x02: MCU_RESPONSE(bonkadv_mcu_4_02); break;
2979 				case 0x01: MCU_RESPONSE(bonkadv_mcu_4_01); break;
2980 				case 0x05: MCU_RESPONSE(bonkadv_mcu_4_05); break;
2981 				case 0x07: MCU_RESPONSE(bonkadv_mcu_4_07); break;
2982 				case 0x06: MCU_RESPONSE(bonkadv_mcu_4_06); break;
2983 				case 0x09: MCU_RESPONSE(bonkadv_mcu_4_09); break;
2984 				case 0x0D: MCU_RESPONSE(bonkadv_mcu_4_0D); break;
2985 				case 0x03: MCU_RESPONSE(bonkadv_mcu_4_03); break;
2986 				case 0x08: MCU_RESPONSE(bonkadv_mcu_4_08); break;
2987 				case 0x04: MCU_RESPONSE(bonkadv_mcu_4_04); break;
2988 				case 0x0C: MCU_RESPONSE(bonkadv_mcu_4_0C); break;
2989 				case 0x0A: MCU_RESPONSE(bonkadv_mcu_4_0A); break;
2990 				case 0x0B: MCU_RESPONSE(bonkadv_mcu_4_0B); break;
2991 				case 0x10: MCU_RESPONSE(bonkadv_mcu_4_10); break;
2992 				case 0x0E: MCU_RESPONSE(bonkadv_mcu_4_0E); break;
2993 				case 0x13: MCU_RESPONSE(bonkadv_mcu_4_13); break;
2994 				case 0x0F: MCU_RESPONSE(bonkadv_mcu_4_0F); break;
2995 				case 0x11: MCU_RESPONSE(bonkadv_mcu_4_11); break;
2996 				case 0x14: MCU_RESPONSE(bonkadv_mcu_4_14); break;
2997 				case 0x12: MCU_RESPONSE(bonkadv_mcu_4_12); break;
2998 				case 0x17: MCU_RESPONSE(bonkadv_mcu_4_17); break;
2999 				case 0x1A: MCU_RESPONSE(bonkadv_mcu_4_1A); break;
3000 				case 0x15: MCU_RESPONSE(bonkadv_mcu_4_15); break;
3001 				case 0x18: MCU_RESPONSE(bonkadv_mcu_4_18); break;
3002 				case 0x16: MCU_RESPONSE(bonkadv_mcu_4_16); break;
3003 				case 0x19: MCU_RESPONSE(bonkadv_mcu_4_19); break;
3004 				case 0x1B: MCU_RESPONSE(bonkadv_mcu_4_1B); break;
3005 				case 0x1C: MCU_RESPONSE(bonkadv_mcu_4_1C); break;
3006 			}
3007 			return;
3008 		}
3009 
3010 		case 0x42: {
3011 			memcpy(NVRam, MCURam + MCUOffset, 128);
3012 			return;
3013 		}
3014 
3015 		case 0x43: {
3016 			// Reset defaults
3017 			memcpy(NVRam, bonkadv_mcu_43, sizeof(bonkadv_mcu_43));
3018 			return;
3019 		}
3020 	}
3021 }
3022 
3023 #undef MCU_RESPONSE
3024 
GtmrMCURun()3025 static void GtmrMCURun()
3026 {
3027 	UINT16 *MCURam = (UINT16*)Kaneko16MCURam;
3028 	UINT16 *NVRam = (UINT16*)Kaneko16NVRam;
3029 
3030 	UINT16 MCUCommand = MCURam[0x10/2];
3031 	UINT16 MCUOffset = MCURam[0x12/2] >> 1;
3032 
3033 	switch (MCUCommand >> 8) {
3034 		case 0x02: {
3035 			memcpy(MCURam + MCUOffset, NVRam, 128);
3036 			return;
3037 		}
3038 
3039 		case 0x03: {
3040 			MCURam[MCUOffset + 0] = 0xff00 - (Kaneko16Dip[0] << 8);
3041 			return;
3042 		}
3043 
3044 		case 0x04: {
3045 			/* MCU writes the string "MM0525-TOYBOX199" to shared ram */
3046 			MCURam[MCUOffset + 0] = 0x4d4d;
3047 			MCURam[MCUOffset + 1] = 0x3035;
3048 			MCURam[MCUOffset + 2] = 0x3235;
3049 			MCURam[MCUOffset + 3] = 0x2d54;
3050 			MCURam[MCUOffset + 4] = 0x4f59;
3051 			MCURam[MCUOffset + 5] = 0x424f;
3052 			MCURam[MCUOffset + 6] = 0x5831;
3053 			MCURam[MCUOffset + 7] = 0x3939;
3054 			return;
3055 		}
3056 
3057 		case 0x42: {
3058 			memcpy(NVRam, MCURam + MCUOffset, 128);
3059 			return;
3060 		}
3061 	}
3062 }
3063 
GtmrevoMCURun()3064 static void GtmrevoMCURun()
3065 {
3066 	UINT16 *MCURam = (UINT16*)Kaneko16MCURam;
3067 	UINT16 *NVRam = (UINT16*)Kaneko16NVRam;
3068 
3069 	UINT16 MCUCommand = MCURam[0x10/2];
3070 	UINT16 MCUOffset = MCURam[0x12/2] >> 1;
3071 
3072 	switch (MCUCommand >> 8) {
3073 		case 0x02: {
3074 			memcpy(MCURam + MCUOffset, NVRam, 128);
3075 			return;
3076 		}
3077 
3078 		case 0x03: {
3079 			MCURam[MCUOffset + 0] = 0xff00 - (Kaneko16Dip[0] << 8);
3080 			return;
3081 		}
3082 
3083 		case 0x04: {
3084 			/* MCU writes the string "USMM0713-TB1994 " to shared ram */
3085 			MCURam[MCUOffset + 0] = 0x5553;
3086 			MCURam[MCUOffset + 1] = 0x4d4d;
3087 			MCURam[MCUOffset + 2] = 0x3037;
3088 			MCURam[MCUOffset + 3] = 0x3133;
3089 			MCURam[MCUOffset + 4] = 0x2d54;
3090 			MCURam[MCUOffset + 5] = 0x4231;
3091 			MCURam[MCUOffset + 6] = 0x3939;
3092 			MCURam[MCUOffset + 7] = 0x3420;
3093 			return;
3094 		}
3095 
3096 		case 0x42: {
3097 			memcpy(NVRam, MCURam + MCUOffset, 128);
3098 			return;
3099 		}
3100 	}
3101 }
3102 
GtmroMCURun()3103 static void GtmroMCURun()
3104 {
3105 	UINT16 *MCURam = (UINT16*)Kaneko16MCURam;
3106 	UINT16 *NVRam = (UINT16*)Kaneko16NVRam;
3107 
3108 	UINT16 MCUCommand = MCURam[0x10/2];
3109 	UINT16 MCUOffset = MCURam[0x12/2] >> 1;
3110 
3111 	switch (MCUCommand >> 8) {
3112 		case 0x02: {
3113 			memcpy(MCURam + MCUOffset, NVRam, 128);
3114 			return;
3115 		}
3116 
3117 		case 0x03: {
3118 			MCURam[MCUOffset + 0] = 0xff00 - (Kaneko16Dip[0] << 8);
3119 			return;
3120 		}
3121 
3122 		case 0x04: {
3123 			/* MCU writes the string 'TOYBOX1994-" ?[GS]?W' to shared ram  - [GS] = ASCII Group Separator */
3124 			MCURam[MCUOffset + 0] = 0x544f;
3125 			MCURam[MCUOffset + 1] = 0x5942;
3126 			MCURam[MCUOffset + 2] = 0x4f58;
3127 			MCURam[MCUOffset + 3] = 0x3139;
3128 			MCURam[MCUOffset + 4] = 0x3934;
3129 			MCURam[MCUOffset + 5] = 0x9300;
3130 			MCURam[MCUOffset + 6] = 0xfa1d;
3131 			MCURam[MCUOffset + 7] = 0x9e57;
3132 			return;
3133 		}
3134 
3135 		case 0x42: {
3136 			memcpy(NVRam, MCURam + MCUOffset, 128);
3137 			return;
3138 		}
3139 	}
3140 }
3141 
ToyboxMCUComWrite(INT32 which,UINT16 data)3142 static void ToyboxMCUComWrite(INT32 which, UINT16 data)
3143 {
3144 	ToyboxMCUCom[which] = data;
3145 	if (ToyboxMCUCom[0] != 0xffff) return;
3146 	if (ToyboxMCUCom[1] != 0xffff) return;
3147 	if (ToyboxMCUCom[2] != 0xffff) return;
3148 	if (ToyboxMCUCom[3] != 0xffff) return;
3149 
3150 	memset(ToyboxMCUCom, 0, 4 * sizeof(UINT16));
3151 	ToyboxMCURun();
3152 }
3153 
3154 /*==============================================================================================
3155 Reset Functions
3156 ===============================================================================================*/
3157 
Kaneko16DoReset()3158 static INT32 Kaneko16DoReset()
3159 {
3160 	SekOpen(0);
3161 	SekReset();
3162 	SekClose();
3163 
3164 	Kaneko16Brightness = 0xff;
3165 
3166 	Kaneko16SpriteFlipX = 0;
3167 	Kaneko16SpriteFlipY = 0;
3168 	Kaneko16DisplayEnable = 0;
3169 	memset(Kaneko16SpriteRegs, 0, 0x20 * sizeof(UINT16));
3170 	memset(Kaneko16Layer0Regs, 0, 0x10 * sizeof(UINT16));
3171 	memset(Kaneko16Layer1Regs, 0, 0x10 * sizeof(UINT16));
3172 
3173 	return 0;
3174 }
3175 
BerlwallDoReset()3176 static INT32 BerlwallDoReset()
3177 {
3178 	INT32 nRet = Kaneko16DoReset();
3179 
3180 	for (INT32 i = 0; i < 2; i++) {
3181 		AY8910Reset(i);
3182 	}
3183 
3184 	MSM6295Reset();
3185 	MSM6295Bank0 = 0;
3186 
3187 	Kaneko16Bg15Reg = 0;
3188 	Kaneko16Bg15Select = 0;
3189 
3190 	return nRet;
3191 }
3192 
BlazeonDoReset()3193 static INT32 BlazeonDoReset()
3194 {
3195 	INT32 nRet = Kaneko16DoReset();
3196 
3197 	ZetOpen(0);
3198 	ZetReset();
3199 	ZetClose();
3200 
3201 	BurnYM2151Reset();
3202 
3203 	Kaneko16SoundLatch = 0;
3204 
3205 	return nRet;
3206 }
3207 
WingforcDoReset()3208 static INT32 WingforcDoReset()
3209 {
3210 	INT32 nRet = Kaneko16DoReset();
3211 
3212 	ZetOpen(0);
3213 	ZetReset();
3214 	ZetClose();
3215 
3216 	BurnYM2151Reset();
3217 
3218 	MSM6295Reset();
3219 	MSM6295Bank0 = 0;
3220 
3221 	Kaneko16SoundLatch = 0;
3222 
3223 	return nRet;
3224 }
3225 
ExplbrkrDoReset()3226 static INT32 ExplbrkrDoReset()
3227 {
3228 	INT32 nRet = Kaneko16DoReset();
3229 
3230 	for (INT32 i = 0; i < 2; i++) {
3231 		AY8910Reset(i);
3232 	}
3233 
3234 	if (Kaneko16Eeprom) {
3235 		EEPROMReset();
3236 	}
3237 
3238 	MSM6295Reset();
3239 	MSM6295Bank0 = 0;
3240 
3241 	return nRet;
3242 }
3243 
GtmrDoReset()3244 static INT32 GtmrDoReset()
3245 {
3246 	INT32 nRet = Kaneko16DoReset();
3247 
3248 	MSM6295Reset();
3249 	MSM6295Bank0 = 0;
3250 	MSM6295Bank1 = 0;
3251 
3252 	ToyboxMCUInit();
3253 
3254 	return nRet;
3255 }
3256 
ShogwarrDoReset()3257 static INT32 ShogwarrDoReset()
3258 {
3259 	if (Kaneko16Watchdog < 180) {
3260 		memset (RamStart, 0, RamEnd - RamStart);
3261 	}
3262 
3263 	SekOpen(0);
3264 	SekReset();
3265 	SekClose();
3266 
3267 	MSM6295Bank0 = -1;
3268 	MSM6295Bank1 = -1;
3269 	ShogwarrConfigSoundBank(0, 0, 0x30000, 0x10000);
3270 	if (Shogwarr) {
3271 		ShogwarrConfigSoundBank(1, 0, 0x00000, 0x40000);
3272 	} else {
3273 		ShogwarrConfigSoundBank(1, 0, 0x20000, 0x20000);
3274 	}
3275 
3276 	MSM6295Reset();
3277 
3278 	Kaneko16SpriteFlipX = 0;
3279 	Kaneko16SpriteFlipY = 0;
3280 	Kaneko16DisplayEnable = 0;
3281 	memset(Kaneko16SpriteRegs, 0, 0x20 * sizeof(UINT16));
3282 	memset(Kaneko16Layer0Regs, 0, 0x10 * sizeof(UINT16));
3283 	memset(Kaneko16Layer1Regs, 0, 0x10 * sizeof(UINT16));
3284 
3285 	Kaneko16Bg15Reg = 0;
3286 	Kaneko16Bg15Select = 0;
3287 
3288 	memset(&m_hit3, 0, sizeof m_hit3);
3289 	memset(&m_calc3, 0, sizeof m_calc3);
3290 
3291 	shogwarr_initial_scan_tables();
3292 
3293 	Kaneko16Watchdog = 0;
3294 
3295 	return 0;
3296 }
3297 
3298 /*==============================================================================================
3299 Memory Handlers
3300 ===============================================================================================*/
3301 
BerlwallReadByte(UINT32 a)3302 UINT8 __fastcall BerlwallReadByte(UINT32 a)
3303 {
3304 	switch (a) {
3305 		case 0x500000:
3306 		case 0x500001: {
3307 			return Kaneko16Brightness;
3308 		}
3309 
3310 		case 0x680000: {
3311 			return 0xff - Kaneko16Input[0];
3312 		}
3313 
3314 		case 0x680002: {
3315 			return 0xff - Kaneko16Input[1];
3316 		}
3317 
3318 		case 0x680004: {
3319 			return 0xff - Kaneko16Input[2];
3320 		}
3321 
3322 		case 0x800001:
3323 		case 0x80001f: {
3324 			AY8910Write(0, 0, (a - 0x800000) >> 1);
3325 			return AY8910Read(0);
3326 		}
3327 
3328 		case 0x800400:
3329 		case 0x800401: {
3330 			return MSM6295Read(0);
3331 		}
3332 
3333 //		default: {
3334 //			bprintf(PRINT_NORMAL, _T("Read byte -> %06X\n"), a);
3335 //		}
3336 	}
3337 
3338 	return 0;
3339 }
3340 
BerlwallWriteByte(UINT32 a,UINT8 d)3341 void __fastcall BerlwallWriteByte(UINT32 a, UINT8 d)
3342 {
3343 	switch (a) {
3344 		case 0x500000:
3345 		case 0x500001: {
3346 			Kaneko16RecalcBg15Palette = 1;
3347 			Kaneko16Brightness = d;
3348 		}
3349 
3350 		case 0x700000: {
3351 			// Coin lockout
3352 			return;
3353 		}
3354 
3355 		case 0x800010:
3356 		case 0x800012:
3357 		case 0x800014: {
3358 			AY8910Write(0, 0, (a - 0x800000) >> 1);
3359 			AY8910Write(0, 1, d & 0xff);
3360 			return;
3361 		}
3362 
3363 		case 0x800210:
3364 		case 0x800212:
3365 		case 0x800214: {
3366 			AY8910Write(1, 0, (a - 0x800200) >> 1);
3367 			AY8910Write(1, 1, d & 0xff);
3368 			return;
3369 		}
3370 
3371 		case 0x800400:
3372 		case 0x800401: {
3373 			MSM6295Write(0, d & 0xff);
3374 			return;
3375 		}
3376 
3377 //		default: {
3378 //			bprintf(PRINT_NORMAL, _T("Write byte -> %06X, %02X\n"), a, d);
3379 //		}
3380 	}
3381 }
3382 
BerlwallReadWord(UINT32 a)3383 UINT16 __fastcall BerlwallReadWord(UINT32 a)
3384 {
3385 	switch (a) {
3386 		case 0x500000: {
3387 			return Kaneko16Brightness;
3388 		}
3389 
3390 		case 0x780000: {
3391 			// watchdog reset
3392 			return 0;
3393 		}
3394 
3395 		case 0x80000e:
3396 		case 0x80001c:
3397 		case 0x80001e: {
3398 			AY8910Write(0, 0, (a - 0x800000) >> 1);
3399 			return AY8910Read(0);
3400 		}
3401 
3402 		case 0x80020e: {
3403 			AY8910Write(1, 0, (a - 0x800200) >> 1);
3404 			return AY8910Read(1);
3405 		}
3406 
3407 		case 0x8003fe: {
3408 			// NOP
3409 			return 0;
3410 		}
3411 
3412 		case 0x800400: {
3413 			return MSM6295Read(0);
3414 		}
3415 
3416 //		default: {
3417 //			bprintf(PRINT_NORMAL, _T("Read Word -> %06X\n"), a);
3418 //		}
3419 	}
3420 
3421 	return 0;
3422 }
3423 
BerlwallWriteWord(UINT32 a,UINT16 d)3424 void __fastcall BerlwallWriteWord(UINT32 a, UINT16 d)
3425 {
3426 	switch (a) {
3427 		case 0x480000: {
3428 			// ??
3429 			return;
3430 		}
3431 
3432 		case 0x500000: {
3433 			Kaneko16RecalcBg15Palette = 1;
3434 			Kaneko16Brightness = d & 0xff;
3435 			return;
3436 		}
3437 
3438 		case 0x580000: {
3439 			Kaneko16Bg15Select = d;
3440 			return;
3441 		}
3442 
3443 		case 0x800000:
3444 		case 0x800002:
3445 		case 0x800004:
3446 		case 0x800006:
3447 		case 0x800008:
3448 		case 0x80000a:
3449 		case 0x80000c:
3450 		case 0x80000e:
3451 		case 0x800010:
3452 		case 0x800012:
3453 		case 0x800014:
3454 		case 0x800016:
3455 		case 0x800018:
3456 		case 0x80001a: {
3457 			AY8910Write(0, 0, (a - 0x800000) >> 1);
3458 			AY8910Write(0, 1, d & 0xff);
3459 			return;
3460 		}
3461 
3462 		case 0x800200:
3463 		case 0x800202:
3464 		case 0x800204:
3465 		case 0x800206:
3466 		case 0x800208:
3467 		case 0x80020a:
3468 		case 0x80020c:
3469 		case 0x80020e:
3470 		case 0x800210:
3471 		case 0x800212:
3472 		case 0x800214:
3473 		case 0x800216:
3474 		case 0x800218:
3475 		case 0x80021a: {
3476 			AY8910Write(1, 0, (a - 0x800200) >> 1);
3477 			AY8910Write(1, 1, d & 0xff);
3478 			return;
3479 		}
3480 
3481 		case 0x8003fe: {
3482 			// NOP
3483 			return;
3484 		}
3485 
3486 		case 0x800400: {
3487 			MSM6295Write(0, d & 0xff);
3488 			return;
3489 		}
3490 
3491 //		default: {
3492 //			bprintf(PRINT_NORMAL, _T("Write word -> %06X, %04X\n"), a, d);
3493 //		}
3494 	}
3495 }
3496 
BlazeonReadByte(UINT32 a)3497 UINT8 __fastcall BlazeonReadByte(UINT32 a)
3498 {
3499 	switch (a) {
3500 		case 0xc00000: {
3501 			return 0xff - Kaneko16Input[0];
3502 		}
3503 
3504 		case 0xc00001: {
3505 			return Kaneko16Dip[0];
3506 		}
3507 
3508 		case 0xc00002: {
3509 			return 0xff - Kaneko16Input[1];
3510 		}
3511 
3512 		case 0xc00003: {
3513 			return Kaneko16Dip[1];
3514 		}
3515 
3516 		case 0xc00006: {
3517 			return 0xff - Kaneko16Input[2];
3518 		}
3519 
3520 		case 0xc00007: {
3521 			return 0xff;
3522 		}
3523 
3524 		case 0xec0000: {
3525 			// NOP
3526 			return 0;
3527 		}
3528 
3529 //		default: {
3530 //			bprintf(PRINT_NORMAL, _T("Read byte -> %06X\n"), a);
3531 //		}
3532 	}
3533 
3534 	return 0;
3535 }
3536 
BlazeonWriteByte(UINT32 a,UINT8 d)3537 void __fastcall BlazeonWriteByte(UINT32 a, UINT8 d)
3538 {
3539 	switch (a) {
3540 		case 0xd00000: {
3541 			// Coin lockout
3542 			return;
3543 		}
3544 
3545 		case 0xe00000: {
3546 			Kaneko16SoundLatch = d;
3547 			ZetOpen(0);
3548 			ZetNmi();
3549 			ZetClose();
3550 			return;
3551 		}
3552 
3553 //		default: {
3554 //			bprintf(PRINT_NORMAL, _T("Write byte -> %06X, %02X\n"), a, d);
3555 //		}
3556 	}
3557 }
3558 
BlazeonReadWord(UINT32 a)3559 UINT16 __fastcall BlazeonReadWord(UINT32 a)
3560 {
3561 	switch (a) {
3562 		case 0xc00000: {
3563 			SEK_DEF_READ_WORD(0, a);
3564 			return 0;
3565 		}
3566 
3567 		case 0xc00002: {
3568 			SEK_DEF_READ_WORD(0, a);
3569 			return 0;
3570 		}
3571 
3572 		case 0xc00004: {
3573 			return 0xffff;
3574 		}
3575 
3576 		case 0xc00006: {
3577 			SEK_DEF_READ_WORD(0, a);
3578 			return 0;
3579 		}
3580 
3581 //		default: {
3582 //			bprintf(PRINT_NORMAL, _T("Read Word -> %06X\n"), a);
3583 //		}
3584 	}
3585 
3586 	return 0;
3587 }
3588 
BlazeonWriteWord(UINT32 a,UINT16)3589 void __fastcall BlazeonWriteWord(UINT32 a, UINT16 /*d*/)
3590 {
3591 	switch (a) {
3592 		case 0xd00000: {
3593 			// Coin lockout
3594 			return;
3595 		}
3596 
3597 //		default: {
3598 //			bprintf(PRINT_NORMAL, _T("Write word -> %06X, %04X\n"), a, d);
3599 //		}
3600 	}
3601 }
3602 
ExplbrkrReadByte(UINT32 a)3603 UINT8 __fastcall ExplbrkrReadByte(UINT32 a)
3604 {
3605 	switch (a) {
3606 		case 0x400001: {
3607 			AY8910Write(0, 0, (a - 0x400000) >> 1);
3608 			return AY8910Read(0);
3609 		}
3610 
3611 		case 0x40021d: {
3612 			AY8910Write(1, 0, (a - 0x400200) >> 1);
3613 			return AY8910Read(1);
3614 		}
3615 
3616 		case 0x400401: {
3617 			return MSM6295Read(0);
3618 		}
3619 
3620 		case 0xe00000: {
3621 			return 0xff - Kaneko16Input[0];
3622 		}
3623 
3624 		case 0xe00001: {
3625 			return Kaneko16Dip[0];
3626 		}
3627 
3628 		case 0xe00002: {
3629 			return 0xff - Kaneko16Input[1];
3630 		}
3631 
3632 		case 0xe00004: {
3633 			return 0xff - Kaneko16Input[2];
3634 		}
3635 
3636 		case 0xe00006: {
3637 			return 0xff;
3638 		}
3639 
3640 //		default: {
3641 //			bprintf(PRINT_NORMAL, _T("Read byte -> %06X\n"), a);
3642 //		}
3643 	}
3644 
3645 	return 0;
3646 }
3647 
ExplbrkrWriteByte(UINT32 a,UINT8 d)3648 void __fastcall ExplbrkrWriteByte(UINT32 a, UINT8 d)
3649 {
3650 	switch (a) {
3651 		case 0x40000f:
3652 		case 0x400010:
3653 		case 0x400012:
3654 		case 0x400014: {
3655 			AY8910Write(0, 0, (a - 0x400000) >> 1);
3656 			AY8910Write(0, 1, d & 0xff);
3657 			return;
3658 		}
3659 
3660 		case 0x40020f:
3661 		case 0x400210:
3662 		case 0x400212:
3663 		case 0x400214:
3664 		case 0x40021f: {
3665 			AY8910Write(1, 0, (a - 0x400200) >> 1);
3666 			AY8910Write(1, 1, d & 0xff);
3667 			return;
3668 		}
3669 
3670 		case 0x400401: {
3671 			MSM6295Write(0, d & 0xff);
3672 			return;
3673 		}
3674 
3675 		case 0xd00000: return;
3676 
3677 		case 0xd00001: {
3678 			EEPROMWriteBit(d & 0x02);
3679 			EEPROMSetClockLine((d & 0x01) ? EEPROM_ASSERT_LINE : EEPROM_CLEAR_LINE );
3680 			return;
3681 		}
3682 
3683 //		default: {
3684 //			bprintf(PRINT_NORMAL, _T("Write byte -> %06X, %02X\n"), a, d);
3685 //		}
3686 	}
3687 }
3688 
ExplbrkrReadWord(UINT32 a)3689 UINT16 __fastcall ExplbrkrReadWord(UINT32 a)
3690 {
3691 	switch (a) {
3692 		case 0xa00000: {
3693 			// Magical crystals Watchdog reset
3694 			return 0;
3695 		}
3696 
3697 		case 0xa80000: {
3698 			// Watchdog reset
3699 			return 0;
3700 		}
3701 
3702 //		default: {
3703 //			bprintf(PRINT_NORMAL, _T("Read Word -> %06X\n"), a);
3704 //		}
3705 	}
3706 
3707 	return 0;
3708 }
3709 
ExplbrkrWriteWord(UINT32 a,UINT16 d)3710 void __fastcall ExplbrkrWriteWord(UINT32 a, UINT16 d)
3711 {
3712 	switch (a) {
3713 		case 0x400000:
3714 		case 0x400002:
3715 		case 0x400004:
3716 		case 0x400006:
3717 		case 0x400008:
3718 		case 0x40000a:
3719 		case 0x40000c:
3720 		case 0x40000e:
3721 		case 0x400010:
3722 		case 0x400012:
3723 		case 0x400014:
3724 		case 0x400016:
3725 		case 0x400018:
3726 		case 0x40001a:
3727 		case 0x40001c: {
3728 			AY8910Write(0, 0, (a - 0x400000) >> 1);
3729 			AY8910Write(0, 1, d & 0xff);
3730 			return;
3731 		}
3732 
3733 		case 0x40001e: {
3734 			if (Mgcrystl) {
3735 				AY8910Write(0, 0, (a - 0x400000) >> 1);
3736 				AY8910Write(0, 1, d & 0xff);
3737 			} else {
3738 				MSM6295Bank0 = d & 7;
3739 				memcpy(MSM6295ROM + 0x0000000, MSM6295ROMData + (0x40000 * (d & 7)), 0x40000);
3740 			}
3741 			return;
3742 		}
3743 
3744 		case 0x400200:
3745 		case 0x400202:
3746 		case 0x400204:
3747 		case 0x400206:
3748 		case 0x400208:
3749 		case 0x40020a:
3750 		case 0x40020c:
3751 		case 0x40020e:
3752 		case 0x400210:
3753 		case 0x400212:
3754 		case 0x400214:
3755 		case 0x400216:
3756 		case 0x400218:
3757 		case 0x40021a:
3758 		case 0x40021c:
3759 		case 0x40021e: {
3760 			AY8910Write(1, 0, (a - 0x400200) >> 1);
3761 			AY8910Write(1, 1, d & 0xff);
3762 			return;
3763 		}
3764 
3765 		case 0x900000: {
3766 			Kaneko16SpriteRegs[0] = d;
3767 			if (d & 0xff) {
3768 				Kaneko16SpriteFlipX = d & 2;
3769 				Kaneko16SpriteFlipY = d & 1;
3770 			}
3771 			return;
3772 		}
3773 
3774 		case 0xd00000: {
3775 			SEK_DEF_WRITE_WORD(0, a, d);
3776 			return;
3777 		}
3778 
3779 //		default: {
3780 //			bprintf(PRINT_NORMAL, _T("Write word -> %06X, %04X\n"), a, d);
3781 //		}
3782 	}
3783 }
3784 
MgcrystlReadByte(UINT32 a)3785 UINT8 __fastcall MgcrystlReadByte(UINT32 a)
3786 {
3787 	switch (a) {
3788 		case 0x400001: {
3789 			AY8910Write(0, 0, (a - 0x400000) >> 1);
3790 			return AY8910Read(0);
3791 		}
3792 
3793 		case 0x40021d: {
3794 			AY8910Write(1, 0, (a - 0x400200) >> 1);
3795 			return AY8910Read(1);
3796 		}
3797 
3798 		case 0x400401: {
3799 			return MSM6295Read(0);
3800 		}
3801 
3802 		case 0xc00000: {
3803 			return 0xff - Kaneko16Input[0];
3804 		}
3805 
3806 		case 0xc00001: {
3807 			return Kaneko16Dip[0];
3808 		}
3809 
3810 		case 0xc00002: {
3811 			return 0x3f - Kaneko16Input[1];
3812 		}
3813 
3814 		case 0xc00004: {
3815 			return 0xff - Kaneko16Input[2];
3816 		}
3817 
3818 //		default: {
3819 //			bprintf(PRINT_NORMAL, _T("Read byte -> %06X\n"), a);
3820 //		}
3821 	}
3822 
3823 	return 0;
3824 }
3825 
GtmrReadByte(UINT32 a)3826 UINT8 __fastcall GtmrReadByte(UINT32 a)
3827 {
3828 	switch (a) {
3829 		case 0x900014: {
3830 			if (Gtmr) return BurnRandom() & 0xff;
3831 			return 0;
3832 		}
3833 
3834 		case 0x900015: {
3835 			if (Bonkadv) return BonkadvCalcRead((a - 0x900000) >> 1);
3836 			return 0;
3837 		}
3838 
3839 		case 0xb00000: {
3840 			return 0xff - Kaneko16Input[0];
3841 		}
3842 
3843 		case 0xb00002: {
3844 			return 0xff - Kaneko16Input[1];
3845 		}
3846 
3847 		case 0xb00004: {
3848 			return 0xff - Kaneko16Input[2];
3849 		}
3850 
3851 		case 0xb00006: {
3852 			return 0xff - Kaneko16Input[3];
3853 		}
3854 
3855 //		default: {
3856 //			bprintf(PRINT_NORMAL, _T("Read byte -> %06X\n"), a);
3857 //		}
3858 	}
3859 
3860 	return 0;
3861 }
3862 
GtmrWriteByte(UINT32 a,UINT8 d)3863 void __fastcall GtmrWriteByte(UINT32 a, UINT8 d)
3864 {
3865 	switch (a) {
3866 		case 0x600000:
3867 		case 0x600002:
3868 		case 0x600004:
3869 		case 0x600006:
3870 		case 0x600008:
3871 		case 0x600009:
3872 		case 0x60000a:
3873 		case 0x60000b:
3874 		case 0x60000c:
3875 		case 0x60000e:
3876 		case 0x600010:
3877 		case 0x600012:
3878 		case 0x600014:
3879 		case 0x600016:
3880 		case 0x600018:
3881 		case 0x60001a:
3882 		case 0x60001c:
3883 		case 0x60001e: {
3884 			Kaneko16Layer0Regs[(a - 0x600000) >> 1] = d;
3885 			return;
3886 		}
3887 
3888 		case 0x680000:
3889 		case 0x680002:
3890 		case 0x680004:
3891 		case 0x680006:
3892 		case 0x680008:
3893 		case 0x680009:
3894 		case 0x68000a:
3895 		case 0x68000b:
3896 		case 0x68000c:
3897 		case 0x68000e:
3898 		case 0x680010:
3899 		case 0x680012:
3900 		case 0x680014:
3901 		case 0x680016:
3902 		case 0x680018:
3903 		case 0x68001a:
3904 		case 0x68001c:
3905 		case 0x68001e: {
3906 			Kaneko16Layer1Regs[(a - 0x680000) >> 1] = d;
3907 			return;
3908 		}
3909 
3910 		case 0x700000:
3911 		case 0x700002:
3912 		case 0x700004:
3913 		case 0x700006:
3914 		case 0x700008:
3915 		case 0x70000a:
3916 		case 0x70000c:
3917 		case 0x70000e:
3918 		case 0x700010:
3919 		case 0x700012:
3920 		case 0x700014:
3921 		case 0x700016:
3922 		case 0x700018:
3923 		case 0x70001a:
3924 		case 0x70001c:
3925 		case 0x70001e: {
3926 			UINT32 offset = (a - 0x700000) >> 1;
3927 			Kaneko16SpriteRegs[offset] = d;
3928 			if (offset == 0 && (d & 0xff)) {
3929 				Kaneko16SpriteFlipX = d & 2;
3930 				Kaneko16SpriteFlipY = d & 1;
3931 			}
3932 			return;
3933 		}
3934 
3935 		case 0x800001: {
3936 			MSM6295Write(0, d);
3937 			return;
3938 		}
3939 
3940 		case 0x880001: {
3941 			MSM6295Write(1, d);
3942 			return;
3943 		}
3944 
3945 		case 0xb80000: {
3946 			// Coin lockout
3947 			return;
3948 		}
3949 
3950 //		default: {
3951 //			bprintf(PRINT_NORMAL, _T("Write byte -> %06X, %02X\n"), a, d);
3952 //		}
3953 	}
3954 }
3955 
GtmrReadWord(UINT32 a)3956 UINT16 __fastcall GtmrReadWord(UINT32 a)
3957 {
3958 	switch (a) {
3959 		case 0x800000: {
3960 			return MSM6295Read(0);
3961 		}
3962 
3963 		case 0x880000: {
3964 			return MSM6295Read(1);
3965 		}
3966 
3967 		case 0x900000:
3968 		case 0x900002:
3969 		case 0x900004:
3970 		case 0x900006:
3971 		case 0x900008:
3972 		case 0x90000a:
3973 		case 0x90000c:
3974 		case 0x90000e:
3975 		case 0x900010:
3976 		case 0x900012:
3977 		case 0x900014:
3978 		case 0x900016:
3979 		case 0x900018:
3980 		case 0x90001a:
3981 		case 0x90001c:
3982 		case 0x90001e:
3983 		case 0x900020:
3984 		case 0x900022:
3985 		case 0x900024:
3986 		case 0x900026:
3987 		case 0x900028:
3988 		case 0x90002a:
3989 		case 0x90002c:
3990 		case 0x90002e:
3991 		case 0x900030:
3992 		case 0x900032:
3993 		case 0x900034:
3994 		case 0x900036:
3995 		case 0x900038: {
3996 			if (Bloodwar) return BloodwarCalcRead((a - 0x900000) >> 1);
3997 			if (Bonkadv) return BonkadvCalcRead((a - 0x900000) >> 1);
3998 			if (Gtmr) return BurnRandom() & 0xffff;
3999 			return 0;
4000 		}
4001 
4002 		case 0xa00000: {
4003 			// Watchdog read
4004 			return 0;
4005 		}
4006 
4007 		case 0xb00000: {
4008 			return 0xff00 - (Kaneko16Input[0] << 8);
4009 		}
4010 
4011 		case 0xb00002: {
4012 			return 0xff00 - (Kaneko16Input[1] << 8);
4013 		}
4014 
4015 		case 0xb00004: {
4016 			return 0xff00 - (Kaneko16Input[2] << 8);
4017 		}
4018 
4019 		case 0xb00006: {
4020 			return 0xffff;
4021 		}
4022 
4023 		case 0xd00000: {
4024 			return ToyboxMCUStatusRead();
4025 		}
4026 
4027 //		default: {
4028 //			bprintf(PRINT_NORMAL, _T("Read Word -> %06X\n"), a);
4029 //		}
4030 	}
4031 
4032 	return 0;
4033 }
4034 
GtmrWriteWord(UINT32 a,UINT16 d)4035 void __fastcall GtmrWriteWord(UINT32 a, UINT16 d)
4036 {
4037 	switch (a) {
4038 		case 0x2a0000: {
4039 			ToyboxMCUComWrite(0, d);
4040 			return;
4041 		}
4042 
4043 		case 0x2b0000: {
4044 			ToyboxMCUComWrite(1, d);
4045 			return;
4046 		}
4047 
4048 		case 0x2c0000: {
4049 			ToyboxMCUComWrite(2, d);
4050 			return;
4051 		}
4052 
4053 		case 0x2d0000: {
4054 			ToyboxMCUComWrite(3, d);
4055 			return;
4056 		}
4057 
4058 		case 0x700000: {
4059 			Kaneko16SpriteRegs[0] = d;
4060 			if (d & 0xff) {
4061 				Kaneko16SpriteFlipX = d & 2;
4062 				Kaneko16SpriteFlipY = d & 1;
4063 			}
4064 			return;
4065 		}
4066 
4067 		case 0x800000: {
4068 			MSM6295Write(0, d);
4069 			return;
4070 		}
4071 
4072 		case 0x880000: {
4073 			MSM6295Write(1, d);
4074 			return;
4075 		}
4076 
4077 		case 0x900000:
4078 		case 0x900002:
4079 		case 0x900004:
4080 		case 0x900006:
4081 		case 0x900008:
4082 		case 0x90000a:
4083 		case 0x90000c:
4084 		case 0x90000e:
4085 		case 0x900010:
4086 		case 0x900012:
4087 		case 0x900014:
4088 		case 0x900016:
4089 		case 0x900018:
4090 		case 0x90001a:
4091 		case 0x90001c:
4092 		case 0x90001e:
4093 		case 0x900020:
4094 		case 0x900022:
4095 		case 0x900024:
4096 		case 0x900026:
4097 		case 0x900028:
4098 		case 0x90002a:
4099 		case 0x90002c:
4100 		case 0x90002e:
4101 		case 0x900030:
4102 		case 0x900032:
4103 		case 0x900034:
4104 		case 0x900036:
4105 		case 0x900038: {
4106 			if (Bonkadv) BonkadvCalcWrite((a - 0x900000) >> 1, d);
4107 			if (Bloodwar) BloodwarCalcWrite((a - 0x900000) >> 1, d);
4108 			return;
4109 		}
4110 
4111 		case 0xa00000: {
4112 			// Watchdog write
4113 			return;
4114 		}
4115 
4116 		case 0xb80000: {
4117 			// Coin lockout
4118 			return;
4119 		}
4120 
4121 		case 0xc00000: {
4122 			Kaneko16DisplayEnable = d;
4123 			return;
4124 		}
4125 
4126 		case 0xe00000: {
4127 			MSM6295Bank0 = d & 0xf;
4128 			memcpy(MSM6295ROM + 0x0000000, MSM6295ROMData + (0x40000 * (d & 0x0f)),0x40000);
4129 			return;
4130 		}
4131 
4132 		case 0xe80000: {
4133 			if (Gtmr) {
4134 				MSM6295Bank1 = d & 1;
4135 				memcpy(MSM6295ROM + 0x0100000, MSM6295ROMData2 + (0x40000 * (d & 0x01)),0x40000);
4136 			} else {
4137 				MSM6295Bank1 = d;
4138 				memcpy(MSM6295ROM + 0x0100000, MSM6295ROMData2 + (0x40000 * d),0x40000);
4139 			}
4140 			return;
4141 		}
4142 
4143 //		default: {
4144 //			bprintf(PRINT_NORMAL, _T("Write word -> %06X, %04X\n"), a, d);
4145 //		}
4146 	}
4147 }
4148 
Kaneko16Z80PortRead(UINT16 a)4149 UINT8 __fastcall Kaneko16Z80PortRead(UINT16 a)
4150 {
4151 	a &= 0xff;
4152 
4153 	switch (a) {
4154 		case 0x03: {
4155 			return BurnYM2151Read();
4156 		}
4157 
4158 		case 0x06: {
4159 			return Kaneko16SoundLatch;
4160 		}
4161 
4162 		case 0x0a: {
4163 			return MSM6295Read(0);
4164 		}
4165 	}
4166 
4167 	return 0;
4168 }
4169 
Kaneko16Z80PortWrite(UINT16 a,UINT8 d)4170 void __fastcall Kaneko16Z80PortWrite(UINT16 a, UINT8 d)
4171 {
4172 	a &= 0xff;
4173 
4174 	switch (a) {
4175 		case 0x02: {
4176 			BurnYM2151SelectRegister(d);
4177 			return;
4178 		}
4179 		case 0x03: {
4180 			BurnYM2151WriteRegister(d);
4181 			return;
4182 		}
4183 		case 0x0a: {
4184 			MSM6295Write(0, d);
4185 			return;
4186 		}
4187 		case 0x0c: {
4188 			MSM6295Bank0 = d & 0x7;
4189 			memcpy(MSM6295ROM + 0x0000000, MSM6295ROMData + (0x40000 * (d & 0x07)), 0x40000);
4190 			return;
4191 		}
4192 	}
4193 }
4194 
ShogwarrConfigSoundBank(INT32 oki,INT32 nBank,INT32 nStart,INT32 nSize)4195 static void ShogwarrConfigSoundBank(INT32 oki, INT32 nBank, INT32 nStart, INT32 nSize)
4196 {
4197 	if (oki == 0 && MSM6295Bank0 == nBank) return;
4198 	if (oki == 1 && MSM6295Bank1 == nBank) return;
4199 
4200 	if (oki == 0) MSM6295Bank0 = nBank;
4201 	if (oki == 1) MSM6295Bank1 = nBank;
4202 
4203 	INT32 nBankAddress = nStart + (nSize * nBank);
4204 
4205 	UINT8 *MSMData = (oki) ? MSM6295ROMData2 : MSM6295ROMData;
4206 
4207 	memcpy (MSM6295ROM + (oki * 0x100000) + nStart, MSMData + nBankAddress, nSize);
4208 }
4209 
ShogwarrReadByte(UINT32 sekAddress)4210 static UINT8 __fastcall ShogwarrReadByte(UINT32 sekAddress)
4211 {
4212 	if ((sekAddress & 0xffff80) == 0xa00000) {
4213 		if (Shogwarr)
4214 			return BloodwarCalcRead((sekAddress - 0xa00000) >> 1) >> ((~sekAddress & 1) * 8);
4215 		else
4216 			return kaneko_hit_type2_read((sekAddress - 0xa00000) >> 1) >> ((~sekAddress & 1) * 8);
4217 	}
4218 
4219 	switch (sekAddress)
4220 	{
4221 		case 0xa80000:
4222 		case 0xa80001:
4223 			Kaneko16Watchdog = 0;
4224 			return 0;
4225 
4226 		case 0xb80000:
4227 			return 0xff - Kaneko16Input[0];
4228 
4229 		case 0xb80002:
4230 			return 0xff - Kaneko16Input[1];
4231 
4232 		case 0xb80004:
4233 			return 0xff - Kaneko16Input[2];
4234 
4235 		case 0xb80006:
4236 			return 0xff;
4237 	}
4238 
4239 	return 0;
4240 }
4241 
ShogwarrReadWord(UINT32 sekAddress)4242 static UINT16 __fastcall ShogwarrReadWord(UINT32 sekAddress)
4243 {
4244 	if ((sekAddress & 0xffff80) == 0xa00000) {
4245 		if (Shogwarr)
4246 			return BloodwarCalcRead((sekAddress - 0xa00000) >> 1);
4247 		else
4248 			return kaneko_hit_type2_read((sekAddress - 0xa00000) >> 1);
4249 	}
4250 
4251 	switch (sekAddress)
4252 	{
4253 		case 0x400000:
4254 			return MSM6295Read(0);
4255 
4256 		case 0x480000:
4257 			return MSM6295Read(1);
4258 
4259 		case 0xa80000:
4260 			Kaneko16Watchdog = 0;
4261 			return 0;
4262 
4263 		case 0xb80000:
4264 			return ((0xff - Kaneko16Input[0])<<8);
4265 
4266 		case 0xb80002:
4267 			return ((0xff - Kaneko16Input[1])<<8);
4268 
4269 		case 0xb80004:
4270 			return ((0xff - Kaneko16Input[2])<<8);
4271 
4272 		case 0xb80006:
4273 			return 0xff00;
4274 	}
4275 
4276 	return 0;
4277 }
4278 
ShogwarrWriteByte(UINT32 sekAddress,UINT8 byteValue)4279 static void __fastcall ShogwarrWriteByte(UINT32 sekAddress, UINT8 byteValue)
4280 {
4281 	if ((sekAddress & 0xffff80) == 0xa00000) {
4282 		if (Shogwarr)
4283 			BloodwarCalcWrite((sekAddress - 0xa00000) >> 1, byteValue);
4284 		else
4285 			kaneko_hit_type2_write((sekAddress - 0xa00000) >> 1, byteValue);
4286 		return;
4287 	}
4288 
4289 	switch (sekAddress)
4290 	{
4291 		case 0x400000:
4292 		case 0x400001:
4293 			MSM6295Write(0, byteValue & 0xff);
4294 		return;
4295 
4296 		case 0x480000:
4297 		case 0x480001:
4298 			MSM6295Write(1, byteValue & 0xff);
4299 		return;
4300 
4301 		case 0xa80000:
4302 		case 0xa80001:
4303 			Kaneko16Watchdog = 0;
4304 		return;
4305 
4306 		case 0xe00000:
4307 		case 0xe00001:
4308 			ShogwarrConfigSoundBank(0, (byteValue >> 4) & 0x0f, 0x30000, 0x10000);
4309 			if (Shogwarr) {
4310 				ShogwarrConfigSoundBank(1, (byteValue >> 0) & 0x0f, 0x00000, 0x40000);
4311 			} else {
4312 				ShogwarrConfigSoundBank(1, (byteValue >> 0) & 0x0f, 0x20000, 0x20000);
4313 			}
4314 		return;
4315 	}
4316 }
4317 
4318 
ShogwarrWriteWord(UINT32 sekAddress,UINT16 wordValue)4319 static void __fastcall ShogwarrWriteWord(UINT32 sekAddress, UINT16 wordValue)
4320 {
4321 	if ((sekAddress & 0xffff80) == 0xa00000) {
4322 		if (Shogwarr)
4323 			BloodwarCalcWrite((sekAddress - 0xa00000) >> 1, wordValue);
4324 		else
4325 			kaneko_hit_type2_write((sekAddress - 0xa00000) >> 1, wordValue);
4326 		return;
4327 	}
4328 
4329 	calc3_t &calc3 = m_calc3;
4330 
4331 	switch (sekAddress)
4332 	{
4333 		case 0x280000:
4334 			calc3.mcu_status |= (1 << 0);
4335 		return;
4336 
4337 		case 0x290000:
4338 			calc3.mcu_status |= (1 << 1);
4339 		return;
4340 
4341 		case 0x2b0000:
4342 			calc3.mcu_status |= (1 << 2);
4343 		return;
4344 
4345 		case 0x2d0000:
4346 			calc3.mcu_status |= (1 << 3);
4347 		return;
4348 
4349 		case 0x400000:
4350 			MSM6295Write(0, wordValue & 0xff);
4351 		return;
4352 
4353 		case 0x480000:
4354 			MSM6295Write(1, wordValue & 0xff);
4355 		return;
4356 
4357 		case 0xa80000:
4358 			Kaneko16Watchdog = 0;
4359 		return;
4360 
4361 		case 0xe00000:
4362 			ShogwarrConfigSoundBank(0, (wordValue >> 4) & 0x0f, 0x30000, 0x10000);
4363 			if (Shogwarr) {
4364 				ShogwarrConfigSoundBank(1, (wordValue >> 0) & 0x0f, 0x00000, 0x40000);
4365 			} else {
4366 				ShogwarrConfigSoundBank(1, (wordValue >> 0) & 0x0f, 0x20000, 0x20000);
4367 			}
4368 		return;
4369 	}
4370 }
4371 
4372 /*==============================================================================================
4373 Sound Chip Handlers
4374 ===============================================================================================*/
4375 
Kaneko16EepromRead(UINT32)4376 static UINT8 Kaneko16EepromRead(UINT32 /*a*/)
4377 {
4378 	return EEPROMRead() & 0x01;
4379 }
4380 
Kaneko16EepromReset(UINT32,UINT32 d)4381 static void Kaneko16EepromReset(UINT32 /*a*/, UINT32 d)
4382 {
4383 	EEPROMSetCSLine((d & 0x01) ? EEPROM_CLEAR_LINE : EEPROM_ASSERT_LINE );
4384 }
4385 
Kaneko16Dip0Read(UINT32)4386 static UINT8 Kaneko16Dip0Read(UINT32 /*a*/)
4387 {
4388 	return Kaneko16Dip[0];
4389 }
4390 
Kaneko16Dip1Read(UINT32)4391 static UINT8 Kaneko16Dip1Read(UINT32 /*a*/)
4392 {
4393 	return Kaneko16Dip[1];
4394 }
4395 
4396 /*==============================================================================================
4397 Driver Inits
4398 ===============================================================================================*/
4399 
Kaneko16VideoInit()4400 static void Kaneko16VideoInit()
4401 {
4402 	GenericTilesInit();
4403 
4404 	spritelist.first_sprite = (struct tempsprite *)BurnMalloc(0x400 * sizeof(spritelist.first_sprite[0]));
4405 
4406 	Kaneko16ParseSprite = Kaneko16ParseSpriteType0;
4407 
4408 	Kaneko16SpritesColourOffset = 0;
4409 	Kaneko16SpritesColourMask = 0x0fff;
4410 	Kaneko168BppSprites = 0;
4411 	if (Gtmr || Bloodwar || Bonkadv) {
4412 		Kaneko16SpritesColourOffset = 0x4000;
4413 		Kaneko16SpritesColourMask = 0xffff;
4414 		Kaneko168BppSprites = 1;
4415 	}
4416 	Kaneko16SpriteFlipType = 0;
4417 
4418 	Kaneko16SpriteXOffset = 0;
4419 	Kaneko16SpriteRamSize = 0x2000;
4420 
4421 	Kaneko16LayersColourOffset = 0x40 * 16;
4422 	if (Gtmr || Bloodwar || Bonkadv) Kaneko16LayersColourOffset = 0;
4423 	Kaneko16TilesXOffset = 0;
4424 	if (nScreenWidth == 256) Kaneko16TilesXOffset = 0x5b;
4425 	if (nScreenWidth == 320) Kaneko16TilesXOffset = 0x33;
4426 	Kaneko16TilesYOffset = 0;
4427 	if (nScreenHeight == 224 || nScreenHeight == 225 || nScreenHeight == 232) Kaneko16TilesYOffset = -0x08;
4428 
4429 	Kaneko16Bg15 = 0;
4430 	Kaneko16Bg15Reg = 0;
4431 	Kaneko16Bg15Select = 0;
4432 	Kaneko16RecalcBg15Palette = 0;
4433 }
4434 
GtmrMachineInit()4435 static INT32 GtmrMachineInit()
4436 {
4437 	// Setup the 68000 emulation
4438 	SekInit(0, 0x68000);
4439 	SekOpen(0);
4440 	SekMapMemory(Kaneko16Rom          , 0x000000, 0x0ffffd, MAP_ROM);
4441 	SekMapMemory(Kaneko16Ram          , 0x100000, 0x10ffff, MAP_RAM);
4442 	SekMapMemory(Kaneko16MCURam       , 0x200000, 0x20ffff, MAP_RAM);
4443 	SekMapMemory(Kaneko16PaletteRam   , 0x300000, 0x30ffff, MAP_RAM);
4444 	SekMapMemory(Kaneko16Ram + 0x10000, 0x310000, 0x327fff, MAP_RAM);
4445 	SekMapMemory(Kaneko16SpriteRam    , 0x400000, 0x401fff, MAP_RAM);
4446 	SekMapMemory(Kaneko16Video1Ram    , 0x500000, 0x500fff, MAP_RAM);
4447 	SekMapMemory(Kaneko16Video0Ram    , 0x501000, 0x501fff, MAP_RAM);
4448 	SekMapMemory(Kaneko16VScrl1Ram    , 0x502000, 0x502fff, MAP_RAM);
4449 	SekMapMemory(Kaneko16VScrl0Ram    , 0x503000, 0x503fff, MAP_RAM);
4450 	SekMapMemory(Kaneko16Video3Ram    , 0x580000, 0x580fff, MAP_RAM);
4451 	SekMapMemory(Kaneko16Video2Ram    , 0x581000, 0x581fff, MAP_RAM);
4452 	SekMapMemory(Kaneko16VScrl3Ram    , 0x582000, 0x582fff, MAP_RAM);
4453 	SekMapMemory(Kaneko16VScrl2Ram    , 0x583000, 0x583fff, MAP_RAM);
4454 	SekMapMemory((UINT8*)Kaneko16Layer0Regs    , 0x600000, 0x60001f, MAP_WRITE);
4455 	SekMapMemory((UINT8*)Kaneko16Layer1Regs    , 0x680000, 0x68001f, MAP_WRITE);
4456 	SekMapMemory((UINT8*)Kaneko16SpriteRegs + 2, 0x700002, 0x70001f, MAP_WRITE);
4457 	SekSetReadByteHandler(0, GtmrReadByte);
4458 	SekSetReadWordHandler(0, GtmrReadWord);
4459 	SekSetWriteByteHandler(0, GtmrWriteByte);
4460 	SekSetWriteWordHandler(0, GtmrWriteWord);
4461 	SekClose();
4462 
4463 	// Setup the OKIM6295 emulation
4464 	MSM6295Init(0, 1980000 / 165, 0);
4465 	MSM6295Init(1, 1980000 / 165, 0);
4466 	MSM6295SetRoute(0, 0.50, BURN_SND_ROUTE_BOTH);
4467 	MSM6295SetRoute(1, 0.50, BURN_SND_ROUTE_BOTH);
4468 
4469 	return 0;
4470 }
4471 
4472 static INT32 FourBppPlaneOffsets[4]  = { 0, 1, 2, 3 };
4473 static INT32 FourBppXOffsets[16]     = { 0, 4, 8, 12, 16, 20, 24, 28, 256, 260, 264, 268, 272, 276, 280, 284 };
4474 static INT32 FourBppYOffsets[16]     = { 0, 32, 64, 96, 128, 160, 192, 224, 512, 544, 576, 608, 640, 672, 704, 736 };
4475 static INT32 EightBppPlaneOffsets[8] = { 0, 1, 2, 3, 4, 5, 6, 7 };
4476 static INT32 EightBppXOffsets[16]    = { 0, 8, 16, 24, 32, 40, 48, 56, 512, 520, 528, 536, 544, 552, 560, 568 };
4477 static INT32 EightBppYOffsets[16]    = { 0, 64, 128, 192, 256, 320, 384, 448, 1024, 1088, 1152, 1216, 1280, 1344, 1408, 1472 };
4478 
BerlwallInit()4479 static INT32 BerlwallInit()
4480 {
4481 	INT32 nRet = 0, nLen;
4482 
4483 	Kaneko16NumSprites = 0x2400;
4484 	Kaneko16NumTiles = 0x1000;
4485 	Kaneko16NumTiles2 = 0;
4486 
4487 	Kaneko16VideoInit();
4488 	Kaneko16ParseSprite = Kaneko16ParseSpriteType2;
4489 	Kaneko16Bg15 = 1;
4490 	Kaneko16RecalcBg15Palette = 1;
4491 
4492 	// Allocate and Blank all required memory
4493 	Mem = NULL;
4494 	ExplbrkrMemIndex();
4495 	nLen = MemEnd - (UINT8 *)0;
4496 	if ((Mem = (UINT8 *)BurnMalloc(nLen)) == NULL) return 1;
4497 	memset(Mem, 0, nLen);
4498 	ExplbrkrMemIndex();
4499 
4500 	Kaneko16TempGfx = (UINT8*)BurnMalloc(0x400000);
4501 
4502 	// Load and byte-swap 68000 Program roms
4503 	nRet = BurnLoadRom(Kaneko16Rom + 0x00001, 0, 2); if (nRet != 0) return 1;
4504 	nRet = BurnLoadRom(Kaneko16Rom + 0x00000, 1, 2); if (nRet != 0) return 1;
4505 
4506 	// Load and Decode Sprite Roms
4507 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x0000000,  2, 1); if (nRet != 0) return 1;
4508 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x0080000,  3, 1); if (nRet != 0) return 1;
4509 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x0100000,  4, 1); if (nRet != 0) return 1;
4510 	GfxDecode(Kaneko16NumSprites, 4, 16, 16, FourBppPlaneOffsets, FourBppXOffsets, FourBppYOffsets, 0x400, Kaneko16TempGfx, Kaneko16Sprites);
4511 
4512 	// Load and Decode Tile Roms
4513 	memset(Kaneko16TempGfx, 0, 0x400000);
4514 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x000000, 5, 1); if (nRet != 0) return 1;
4515 	UnscrambleTiles(0x080000);
4516 	GfxDecode(Kaneko16NumTiles, 4, 16, 16, FourBppPlaneOffsets, FourBppXOffsets, FourBppYOffsets, 0x400, Kaneko16TempGfx, Kaneko16Tiles);
4517 
4518 	// Load bitmap roms
4519 	memset(Kaneko16TempGfx, 0, 0x400000);
4520 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x000000,  6, 2); if (nRet != 0) return 1;
4521 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x000001,  7, 2); if (nRet != 0) return 1;
4522 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x100000,  8, 2); if (nRet != 0) return 1;
4523 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x100001,  9, 2); if (nRet != 0) return 1;
4524 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x200000, 10, 2); if (nRet != 0) return 1;
4525 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x200001, 11, 2); if (nRet != 0) return 1;
4526 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x300000, 12, 2); if (nRet != 0) return 1;
4527 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x300001, 13, 2); if (nRet != 0) return 1;
4528 	Kaneko16DecodeBg15Bitmaps();
4529 	BurnFree(Kaneko16TempGfx);
4530 
4531 	// Load Sample Rom
4532 	nRet = BurnLoadRom(MSM6295ROM, 14, 1); if (nRet != 0) return 1;
4533 	memcpy(MSM6295ROMData, MSM6295ROM, 0x40000);
4534 
4535 	SekInit(0, 0x68000);
4536 	SekOpen(0);
4537 	SekMapMemory(Kaneko16Rom          , 0x000000, 0x03ffff, MAP_ROM);
4538 	SekMapMemory(Kaneko16Ram          , 0x200000, 0x20ffff, MAP_RAM);
4539 	SekMapMemory(Kaneko16SpriteRam    , 0x30e000, 0x30ffff, MAP_RAM);
4540 	SekMapMemory(Kaneko16PaletteRam   , 0x400000, 0x400fff, MAP_RAM);
4541 	SekMapMemory(Kaneko16Video1Ram    , 0xc00000, 0xc00fff, MAP_RAM);
4542 	SekMapMemory(Kaneko16Video0Ram    , 0xc01000, 0xc01fff, MAP_RAM);
4543 	SekMapMemory(Kaneko16VScrl1Ram    , 0xc02000, 0xc02fff, MAP_RAM);
4544 	SekMapMemory(Kaneko16VScrl0Ram    , 0xc03000, 0xc03fff, MAP_RAM);
4545 	SekMapMemory((UINT8*)Kaneko16Layer0Regs    , 0xd00000, 0xd0001f, MAP_WRITE);
4546 	SekMapMemory((UINT8*)Kaneko16SpriteRegs + 2, 0x600002, 0x60003f, MAP_WRITE);
4547 	SekSetReadByteHandler(0, BerlwallReadByte);
4548 	SekSetReadWordHandler(0, BerlwallReadWord);
4549 	SekSetWriteByteHandler(0, BerlwallWriteByte);
4550 	SekSetWriteWordHandler(0, BerlwallWriteWord);
4551 	SekClose();
4552 
4553 	AY8910Init(0, 2000000, 0);
4554 	AY8910Init(1, 2000000, 1);
4555 	AY8910SetPorts(0, &Kaneko16Dip0Read, &Kaneko16Dip1Read, NULL, NULL);
4556 	AY8910SetAllRoutes(0, 0.40, BURN_SND_ROUTE_BOTH);
4557 	AY8910SetAllRoutes(1, 0.40, BURN_SND_ROUTE_BOTH);
4558 
4559 	// Setup the OKIM6295 emulation
4560 	MSM6295Init(0, (12000000 / 6) / 132, 1);
4561 	MSM6295SetRoute(0, 0.40, BURN_SND_ROUTE_BOTH);
4562 
4563 	// Reset the driver
4564 	BerlwallDoReset();
4565 
4566 	return 0;
4567 }
4568 
PackbangInit()4569 static INT32 PackbangInit()
4570 {
4571 	INT32 nRet = 0, nLen;
4572 
4573 	Kaneko16NumSprites = 0x2400;
4574 	Kaneko16NumTiles = 0x1000;
4575 	Kaneko16NumTiles2 = 0;
4576 
4577 	Kaneko16VideoInit();
4578 	Kaneko16ParseSprite = Kaneko16ParseSpriteType2;
4579 	Kaneko16Bg15 = 1;
4580 	Kaneko16RecalcBg15Palette = 1;
4581 
4582 	// Allocate and Blank all required memory
4583 	Mem = NULL;
4584 	ExplbrkrMemIndex();
4585 	nLen = MemEnd - (UINT8 *)0;
4586 	if ((Mem = (UINT8 *)BurnMalloc(nLen)) == NULL) return 1;
4587 	memset(Mem, 0, nLen);
4588 	ExplbrkrMemIndex();
4589 
4590 	Kaneko16TempGfx = (UINT8*)BurnMalloc(0x400000);
4591 
4592 	// Load and byte-swap 68000 Program roms
4593 	nRet = BurnLoadRom(Kaneko16Rom + 0x00001, 0, 2); if (nRet != 0) return 1;
4594 	nRet = BurnLoadRom(Kaneko16Rom + 0x00000, 1, 2); if (nRet != 0) return 1;
4595 
4596 	// Load and Decode Sprite Roms
4597 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x0000000,  2, 1); if (nRet != 0) return 1;
4598 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x0080000,  3, 1); if (nRet != 0) return 1;
4599 	GfxDecode(Kaneko16NumSprites, 4, 16, 16, FourBppPlaneOffsets, FourBppXOffsets, FourBppYOffsets, 0x400, Kaneko16TempGfx, Kaneko16Sprites);
4600 
4601 	// Load and Decode Tile Roms
4602 	memset(Kaneko16TempGfx, 0, 0x400000);
4603 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x000000, 4, 1); if (nRet != 0) return 1;
4604 	UnscrambleTiles(0x080000);
4605 	GfxDecode(Kaneko16NumTiles, 4, 16, 16, FourBppPlaneOffsets, FourBppXOffsets, FourBppYOffsets, 0x400, Kaneko16TempGfx, Kaneko16Tiles);
4606 
4607 	// Load bitmap roms
4608 	memset(Kaneko16TempGfx, 0, 0x400000);
4609 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x000000,  5, 2); if (nRet != 0) return 1;
4610 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x000001,  6, 2); if (nRet != 0) return 1;
4611 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x100000,  7, 2); if (nRet != 0) return 1;
4612 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x100001,  8, 2); if (nRet != 0) return 1;
4613 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x200000,  9, 2); if (nRet != 0) return 1;
4614 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x200001, 10, 2); if (nRet != 0) return 1;
4615 	Kaneko16DecodeBg15Bitmaps();
4616 	BurnFree(Kaneko16TempGfx);
4617 
4618 	// Load Sample Rom
4619 	nRet = BurnLoadRom(MSM6295ROM, 11, 1); if (nRet != 0) return 1;
4620 	memcpy(MSM6295ROMData, MSM6295ROM, 0x40000);
4621 	MSM6295Bank0 = 0;
4622 	MSM6295Bank1 = 0;
4623 
4624 	SekInit(0, 0x68000);
4625 	SekOpen(0);
4626 	SekMapMemory(Kaneko16Rom          , 0x000000, 0x03ffff, MAP_ROM);
4627 	SekMapMemory(Kaneko16Ram          , 0x200000, 0x20ffff, MAP_RAM);
4628 	SekMapMemory(Kaneko16SpriteRam    , 0x30e000, 0x30ffff, MAP_RAM);
4629 	SekMapMemory(Kaneko16PaletteRam   , 0x400000, 0x400fff, MAP_RAM);
4630 	SekMapMemory(Kaneko16Video1Ram    , 0xc00000, 0xc00fff, MAP_RAM);
4631 	SekMapMemory(Kaneko16Video0Ram    , 0xc01000, 0xc01fff, MAP_RAM);
4632 	SekMapMemory(Kaneko16VScrl1Ram    , 0xc02000, 0xc02fff, MAP_RAM);
4633 	SekMapMemory(Kaneko16VScrl0Ram    , 0xc03000, 0xc03fff, MAP_RAM);
4634 	SekMapMemory((UINT8*)Kaneko16Layer0Regs    , 0xd00000, 0xd0001f, MAP_WRITE);
4635 	SekMapMemory((UINT8*)Kaneko16SpriteRegs + 2, 0x600002, 0x60003f, MAP_WRITE);
4636 	SekSetReadByteHandler(0, BerlwallReadByte);
4637 	SekSetReadWordHandler(0, BerlwallReadWord);
4638 	SekSetWriteByteHandler(0, BerlwallWriteByte);
4639 	SekSetWriteWordHandler(0, BerlwallWriteWord);
4640 	SekClose();
4641 
4642 	AY8910Init(0, 2000000, 0);
4643 	AY8910Init(1, 2000000, 1);
4644 	AY8910SetPorts(0, &Kaneko16Dip0Read, &Kaneko16Dip1Read, NULL, NULL);
4645 	AY8910SetAllRoutes(0, 0.40, BURN_SND_ROUTE_BOTH);
4646 	AY8910SetAllRoutes(1, 0.40, BURN_SND_ROUTE_BOTH);
4647 
4648 	// Setup the OKIM6295 emulation
4649 	MSM6295Init(0, (12000000 / 6) / 132, 1);
4650 	MSM6295SetRoute(0, 0.40, BURN_SND_ROUTE_BOTH);
4651 
4652 	// Reset the driver
4653 	BerlwallDoReset();
4654 
4655 	return 0;
4656 }
4657 
BlazeonInit()4658 static INT32 BlazeonInit()
4659 {
4660 	INT32 nRet = 0, nLen;
4661 
4662 	Kaneko16NumSprites = 0x4000;
4663 	Kaneko16NumTiles = 0x2000;
4664 	Kaneko16NumTiles2 = 0;
4665 
4666 	Kaneko16VideoInit();
4667 	Kaneko16SpriteRamSize = 0x1000;
4668 	Kaneko16SpriteXOffset = 0x10000 - 0x680;
4669 	Kaneko16SpritePrio(1, 2, 8, 8);
4670 
4671 	// Allocate and Blank all required memory
4672 	Mem = NULL;
4673 	BlazeonMemIndex();
4674 	nLen = MemEnd - (UINT8 *)0;
4675 	if ((Mem = (UINT8 *)BurnMalloc(nLen)) == NULL) return 1;
4676 	memset(Mem, 0, nLen);
4677 	BlazeonMemIndex();
4678 
4679 	Kaneko16TempGfx = (UINT8*)BurnMalloc(0x200000);
4680 
4681 	// Load and byte-swap 68000 Program roms
4682 	nRet = BurnLoadRom(Kaneko16Rom + 0x00001, 0, 2); if (nRet != 0) return 1;
4683 	nRet = BurnLoadRom(Kaneko16Rom + 0x00000, 1, 2); if (nRet != 0) return 1;
4684 
4685 	// Load and Decode Sprite Roms
4686 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x0000000,  2, 1); if (nRet != 0) return 1;
4687 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x0100000,  3, 1); if (nRet != 0) return 1;
4688 	GfxDecode(Kaneko16NumSprites, 4, 16, 16, FourBppPlaneOffsets, FourBppXOffsets, FourBppYOffsets, 0x400, Kaneko16TempGfx, Kaneko16Sprites);
4689 
4690 	// Load and Decode Tile Roms
4691 	memset(Kaneko16TempGfx, 0, 0x200000);
4692 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x000000, 4, 1); if (nRet != 0) return 1;
4693 	UnscrambleTiles(0x100000);
4694 	GfxDecode(Kaneko16NumTiles, 4, 16, 16, FourBppPlaneOffsets, FourBppXOffsets, FourBppYOffsets, 0x400, Kaneko16TempGfx, Kaneko16Tiles);
4695 
4696 	BurnFree(Kaneko16TempGfx);
4697 
4698 	// Load Z80 Rom
4699 	nRet = BurnLoadRom(Kaneko16Z80Rom, 5, 1); if (nRet != 0) return 1;
4700 
4701 	SekInit(0, 0x68000);
4702 	SekOpen(0);
4703 	SekMapMemory(Kaneko16Rom          , 0x000000, 0x07ffff, MAP_ROM);
4704 	SekMapMemory(Kaneko16Ram          , 0x300000, 0x30ffff, MAP_RAM);
4705 	SekMapMemory(Kaneko16PaletteRam   , 0x500000, 0x500fff, MAP_RAM);
4706 	SekMapMemory(Kaneko16Video1Ram    , 0x600000, 0x600fff, MAP_RAM);
4707 	SekMapMemory(Kaneko16Video0Ram    , 0x601000, 0x601fff, MAP_RAM);
4708 	SekMapMemory(Kaneko16VScrl1Ram    , 0x602000, 0x602fff, MAP_RAM);
4709 	SekMapMemory(Kaneko16VScrl0Ram    , 0x603000, 0x603fff, MAP_RAM);
4710 	SekMapMemory(Kaneko16SpriteRam    , 0x700000, 0x700fff, MAP_RAM);
4711 	SekMapMemory((UINT8*)Kaneko16Layer0Regs    , 0x800000, 0x80000f, MAP_WRITE);
4712 	SekMapMemory((UINT8*)Kaneko16SpriteRegs + 2, 0x900002, 0x90001f, MAP_WRITE);
4713 	SekSetReadByteHandler(0, BlazeonReadByte);
4714 	SekSetReadWordHandler(0, BlazeonReadWord);
4715 	SekSetWriteByteHandler(0, BlazeonWriteByte);
4716 	SekSetWriteWordHandler(0, BlazeonWriteWord);
4717 	SekClose();
4718 
4719 	// Setup the Z80 emulation
4720 	ZetInit(0);
4721 	ZetOpen(0);
4722 	ZetMapArea(0x0000, 0x7fff, 0, Kaneko16Z80Rom         );
4723 	ZetMapArea(0x0000, 0x7fff, 2, Kaneko16Z80Rom         );
4724 	ZetMapArea(0xc000, 0xdfff, 0, Kaneko16Z80Ram         );
4725 	ZetMapArea(0xc000, 0xdfff, 1, Kaneko16Z80Ram         );
4726 	ZetMapArea(0xc000, 0xdfff, 2, Kaneko16Z80Ram         );
4727 	ZetSetInHandler(Kaneko16Z80PortRead);
4728 	ZetSetOutHandler(Kaneko16Z80PortWrite);
4729 	ZetClose();
4730 
4731 	// Setup the YM2151 emulation
4732 	BurnYM2151Init(4000000);
4733 	BurnYM2151SetRoute(BURN_SND_YM2151_YM2151_ROUTE_1, 1.00, BURN_SND_ROUTE_LEFT);
4734 	BurnYM2151SetRoute(BURN_SND_YM2151_YM2151_ROUTE_2, 1.00, BURN_SND_ROUTE_RIGHT);
4735 
4736 	// Reset the driver
4737 	BlazeonDoReset();
4738 
4739 	return 0;
4740 }
4741 
WingforcInit()4742 static INT32 WingforcInit()
4743 {
4744 	INT32 nRet = 0, nLen;
4745 
4746 	Kaneko16NumSprites = 0x4000;
4747 	Kaneko16NumTiles = 0x4000;
4748 	Kaneko16NumTiles2 = 0;
4749 
4750 	Kaneko16VideoInit();
4751 	Kaneko16SpriteRamSize = 0x1000;
4752 	Kaneko16SpriteXOffset = 0x10000 - 0x680;
4753 	Kaneko16TilesYOffset = -0x09;
4754 	Kaneko16SpritePrio(2, 3, 5, 7);
4755 
4756 	// Allocate and Blank all required memory
4757 	Mem = NULL;
4758 	BlazeonMemIndex();
4759 	nLen = MemEnd - (UINT8 *)0;
4760 	if ((Mem = (UINT8 *)BurnMalloc(nLen)) == NULL) return 1;
4761 	memset(Mem, 0, nLen);
4762 	BlazeonMemIndex();
4763 
4764 	Kaneko16TempGfx = (UINT8*)BurnMalloc(0x400000);
4765 
4766 	// Load and byte-swap 68000 Program roms
4767 	nRet = BurnLoadRom(Kaneko16Rom + 0x00001, 0, 2); if (nRet != 0) return 1;
4768 	nRet = BurnLoadRom(Kaneko16Rom + 0x00000, 1, 2); if (nRet != 0) return 1;
4769 
4770 	// Load and Decode Sprite Roms
4771 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x0000000,  2, 1); if (nRet != 0) return 1;
4772 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x0000000,  3, 1); if (nRet != 0) return 1;
4773 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x0080000,  4, 1); if (nRet != 0) return 1;
4774 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x0080000,  5, 1); if (nRet != 0) return 1;
4775 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x0100000,  6, 1); if (nRet != 0) return 1;
4776 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x0100000,  7, 1); if (nRet != 0) return 1;
4777 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x0180000,  8, 1); if (nRet != 0) return 1;
4778 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x0180000,  9, 1); if (nRet != 0) return 1;
4779 	GfxDecode(Kaneko16NumSprites, 4, 16, 16, FourBppPlaneOffsets, FourBppXOffsets, FourBppYOffsets, 0x400, Kaneko16TempGfx, Kaneko16Sprites);
4780 
4781 	// Load and Decode Tile Roms
4782 	memset(Kaneko16TempGfx, 0, 0x400000);
4783 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x0000000,10, 2); if (nRet != 0) return 1;
4784 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x0000001,11, 2); if (nRet != 0) return 1;
4785 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x0100000,12, 2); if (nRet != 0) return 1;
4786 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x0100001,13, 2); if (nRet != 0) return 1;
4787 	UnscrambleTiles(0x200000);
4788 	GfxDecode(Kaneko16NumTiles, 4, 16, 16, FourBppPlaneOffsets, FourBppXOffsets, FourBppYOffsets, 0x400, Kaneko16TempGfx, Kaneko16Tiles);
4789 
4790 
4791 	// Load Z80 Rom
4792 	nRet = BurnLoadRom(Kaneko16Z80Rom, 14, 1); if (nRet != 0) return 1;
4793 
4794 	// Load & un-derange Sample Rom
4795 	memset(Kaneko16TempGfx, 0, 0x80000);
4796 	nRet = BurnLoadRom(Kaneko16TempGfx, 15, 1); if (nRet != 0) return 1;
4797 
4798 	memcpy(MSM6295ROMData + 0x00000, Kaneko16TempGfx + 0x00000, 0x20000);
4799 	memcpy(MSM6295ROMData + 0x20000, Kaneko16TempGfx + 0x20000, 0x20000);
4800 	memcpy(MSM6295ROMData + 0x40000, Kaneko16TempGfx + 0x00000, 0x20000);
4801 	memcpy(MSM6295ROMData + 0x60000, Kaneko16TempGfx + 0x40000, 0x20000);
4802 	memcpy(MSM6295ROMData + 0x80000, Kaneko16TempGfx + 0x00000, 0x20000);
4803 	memcpy(MSM6295ROMData + 0xa0000, Kaneko16TempGfx + 0x60000, 0x20000);
4804 	BurnFree(Kaneko16TempGfx);
4805 
4806 	// Setup 68k emulation
4807 	SekInit(0, 0x68000);
4808 	SekOpen(0);
4809 	SekMapMemory(Kaneko16Rom          , 0x000000, 0x0fffff, MAP_ROM);
4810 	SekMapMemory(Kaneko16Ram          , 0x300000, 0x30ffff, MAP_RAM);
4811 	SekMapMemory(Kaneko16PaletteRam   , 0x500000, 0x500fff, MAP_RAM);
4812 	SekMapMemory(Kaneko16Video1Ram    , 0x600000, 0x600fff, MAP_RAM);
4813 	SekMapMemory(Kaneko16Video0Ram    , 0x601000, 0x601fff, MAP_RAM);
4814 	SekMapMemory(Kaneko16VScrl1Ram    , 0x602000, 0x602fff, MAP_RAM);
4815 	SekMapMemory(Kaneko16VScrl0Ram    , 0x603000, 0x603fff, MAP_RAM);
4816 	SekMapMemory(Kaneko16SpriteRam    , 0x700000, 0x700fff, MAP_RAM);
4817 	SekMapMemory((UINT8*)Kaneko16Layer0Regs    , 0x800000, 0x80000f, MAP_WRITE);
4818 	SekMapMemory((UINT8*)Kaneko16SpriteRegs + 2, 0x900002, 0x90001f, MAP_WRITE);
4819 	SekSetReadByteHandler(0, BlazeonReadByte);
4820 	SekSetReadWordHandler(0, BlazeonReadWord);
4821 	SekSetWriteByteHandler(0, BlazeonWriteByte);
4822 	SekSetWriteWordHandler(0, BlazeonWriteWord);
4823 	SekClose();
4824 
4825 	// Setup the Z80 emulation
4826 	ZetInit(0);
4827 	ZetOpen(0);
4828 	ZetMapArea(0x0000, 0xbfff, 0, Kaneko16Z80Rom         );
4829 	ZetMapArea(0x0000, 0xbfff, 2, Kaneko16Z80Rom         );
4830 	ZetMapArea(0xc000, 0xdfff, 0, Kaneko16Z80Ram         );
4831 	ZetMapArea(0xc000, 0xdfff, 1, Kaneko16Z80Ram         );
4832 	ZetMapArea(0xc000, 0xdfff, 2, Kaneko16Z80Ram         );
4833 	ZetSetInHandler(Kaneko16Z80PortRead);
4834 	ZetSetOutHandler(Kaneko16Z80PortWrite);
4835 	ZetClose();
4836 
4837 //	BurnSetRefreshRate(59.1854); // hmm, this causes clicks in audio. let's just give it the cycles/per frame it wants instead. (see WingforcFrame())
4838 
4839 	// Setup the YM2151 emulation
4840 	BurnYM2151Init(4000000);
4841 	BurnYM2151SetRoute(BURN_SND_YM2151_YM2151_ROUTE_1, 0.40, BURN_SND_ROUTE_LEFT);
4842 	BurnYM2151SetRoute(BURN_SND_YM2151_YM2151_ROUTE_2, 0.40, BURN_SND_ROUTE_RIGHT);
4843 
4844 	// Setup the OKIM6295 emulation
4845 	MSM6295Init(0, (16000000 / 16) / 132, 1);
4846 	MSM6295SetRoute(0, 0.55, BURN_SND_ROUTE_BOTH);
4847 
4848 	// Reset the driver
4849 	WingforcDoReset();
4850 
4851 	return 0;
4852 }
4853 
BloodwarInit()4854 static INT32 BloodwarInit()
4855 {
4856 	INT32 nRet = 0, nLen;
4857 
4858 	Bloodwar = 1;
4859 
4860 	Kaneko16NumSprites = 0x1e000;
4861 	Kaneko16NumTiles = 0x2000;
4862 	Kaneko16NumTiles2 = 0x2000;
4863 
4864 	Kaneko16VideoInit();
4865 	Kaneko16ParseSprite = Kaneko16ParseSpriteType1;
4866 
4867 	// Allocate and Blank all required memory
4868 	Mem = NULL;
4869 	GtmrMemIndex();
4870 	nLen = MemEnd - (UINT8 *)0;
4871 	if ((Mem = (UINT8 *)BurnMalloc(nLen)) == NULL) return 1;
4872 	memset(Mem, 0, nLen);
4873 	GtmrMemIndex();
4874 
4875 	Kaneko16TempGfx = (UINT8*)BurnMalloc(0x1e00000);
4876 
4877 	// Load and byte-swap 68000 Program roms
4878 	nRet = BurnLoadRom(Kaneko16Rom + 0x00001, 0, 2); if (nRet != 0) return 1;
4879 	nRet = BurnLoadRom(Kaneko16Rom + 0x00000, 1, 2); if (nRet != 0) return 1;
4880 
4881 	// Load and Decode Sprite Roms
4882 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x0000000,  3, 1); if (nRet != 0) return 1;
4883 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x0200000,  4, 1); if (nRet != 0) return 1;
4884 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x0400000,  5, 1); if (nRet != 0) return 1;
4885 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x0600000,  6, 1); if (nRet != 0) return 1;
4886 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x0800000,  7, 1); if (nRet != 0) return 1;
4887 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x0a00000,  8, 1); if (nRet != 0) return 1;
4888 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x0c00000,  9, 1); if (nRet != 0) return 1;
4889 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x0e00000, 10, 1); if (nRet != 0) return 1;
4890 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x1000000, 11, 1); if (nRet != 0) return 1;
4891 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x1200000, 12, 2); if (nRet != 0) return 1;
4892 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x1200001, 13, 2); if (nRet != 0) return 1;
4893 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x1400000, 14, 2); if (nRet != 0) return 1;
4894 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x1400001, 15, 2); if (nRet != 0) return 1;
4895 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x1600000, 16, 2); if (nRet != 0) return 1;
4896 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x1600001, 17, 2); if (nRet != 0) return 1;
4897 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x1800000, 18, 2); if (nRet != 0) return 1;
4898 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x1800001, 19, 2); if (nRet != 0) return 1;
4899 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x1a00000, 20, 2); if (nRet != 0) return 1;
4900 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x1a00001, 21, 2); if (nRet != 0) return 1;
4901 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x1c00000, 22, 2); if (nRet != 0) return 1;
4902 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x1c00001, 23, 2); if (nRet != 0) return 1;
4903 	GfxDecode(Kaneko16NumSprites, 8, 16, 16, EightBppPlaneOffsets, EightBppXOffsets, EightBppYOffsets, 0x800, Kaneko16TempGfx, Kaneko16Sprites);
4904 
4905 	// Load and Decode Tile Roms
4906 	memset(Kaneko16TempGfx, 0, 0x1e00000);
4907 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x000000, 24, 1); if (nRet != 0) return 1;
4908 	UnscrambleTiles(0x100000);
4909 	GfxDecode(Kaneko16NumTiles, 4, 16, 16, FourBppPlaneOffsets, FourBppXOffsets, FourBppYOffsets, 0x400, Kaneko16TempGfx, Kaneko16Tiles);
4910 	memset(Kaneko16TempGfx, 0, 0x1e00000);
4911 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x000000, 25, 1); if (nRet != 0) return 1;
4912 	UnscrambleTiles(0x100000);
4913 	GfxDecode(Kaneko16NumTiles2, 4, 16, 16, FourBppPlaneOffsets, FourBppXOffsets, FourBppYOffsets, 0x400, Kaneko16TempGfx, Kaneko16Tiles2);
4914 	BurnFree(Kaneko16TempGfx);
4915 
4916 	// Load Sample Rom
4917 	nRet = BurnLoadRom(MSM6295ROMData, 26, 1); if (nRet != 0) return 1;
4918 	nRet = BurnLoadRom(MSM6295ROMData2, 27, 1); if (nRet != 0) return 1;
4919 	ExpandSampleBanks();
4920 
4921 	ToyboxMCURun = BloodwarMCURun;
4922 
4923 	nRet = GtmrMachineInit(); if (nRet != 0) return 1;
4924 
4925 	// Reset the driver
4926 	GtmrDoReset();
4927 
4928 	return 0;
4929 }
4930 
BonkadvInit()4931 static INT32 BonkadvInit()
4932 {
4933 	INT32 nRet = 0, nLen;
4934 
4935 	Bonkadv = 1;
4936 
4937 	Kaneko16NumSprites = 0x5000;
4938 	Kaneko16NumTiles = 0x4000;
4939 	Kaneko16NumTiles2 = 0x4000;
4940 
4941 	Kaneko16VideoInit();
4942 	Kaneko16ParseSprite = Kaneko16ParseSpriteType1;
4943 
4944 	// Allocate and Blank all required memory
4945 	Mem = NULL;
4946 	GtmrMemIndex();
4947 	nLen = MemEnd - (UINT8 *)0;
4948 	if ((Mem = (UINT8 *)BurnMalloc(nLen)) == NULL) return 1;
4949 	memset(Mem, 0, nLen);
4950 	GtmrMemIndex();
4951 
4952 	Kaneko16TempGfx = (UINT8*)BurnMalloc(0x500000);
4953 
4954 	// Load and byte-swap 68000 Program roms
4955 	nRet = BurnLoadRom(Kaneko16Rom + 0x00001, 0, 2); if (nRet != 0) return 1;
4956 	nRet = BurnLoadRom(Kaneko16Rom + 0x00000, 1, 2); if (nRet != 0) return 1;
4957 
4958 	// Load and Decode Sprite Roms
4959 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x0000000, 3, 1); if (nRet != 0) return 1;
4960 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x0200000, 4, 1); if (nRet != 0) return 1;
4961 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x0300000, 5, 1); if (nRet != 0) return 1;
4962 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x0400000, 6, 2); if (nRet != 0) return 1;
4963 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x0400001, 7, 2); if (nRet != 0) return 1;
4964 	GfxDecode(Kaneko16NumSprites, 8, 16, 16, EightBppPlaneOffsets, EightBppXOffsets, EightBppYOffsets, 0x800, Kaneko16TempGfx, Kaneko16Sprites);
4965 
4966 	// Load and Decode Tile Roms
4967 	memset(Kaneko16TempGfx, 0, 0x500000);
4968 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x000000, 8, 1); if (nRet != 0) return 1;
4969 	UnscrambleTiles(0x100000);
4970 	GfxDecode(Kaneko16NumTiles, 4, 16, 16, FourBppPlaneOffsets, FourBppXOffsets, FourBppYOffsets, 0x400, Kaneko16TempGfx, Kaneko16Tiles);
4971 	memset(Kaneko16TempGfx, 0, 0x500000);
4972 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x000000, 9, 1); if (nRet != 0) return 1;
4973 	UnscrambleTiles(0x100000);
4974 	GfxDecode(Kaneko16NumTiles2, 4, 16, 16, FourBppPlaneOffsets, FourBppXOffsets, FourBppYOffsets, 0x400, Kaneko16TempGfx, Kaneko16Tiles2);
4975 	BurnFree(Kaneko16TempGfx);
4976 
4977 	// Load Sample Rom
4978 	nRet = BurnLoadRom(MSM6295ROMData, 10, 1); if (nRet != 0) return 1;
4979 	nRet = BurnLoadRom(MSM6295ROMData2, 11, 1); if (nRet != 0) return 1;
4980 	nRet = BurnLoadRom(MSM6295ROMData2 + 0x100000, 12, 1); if (nRet != 0) return 1;
4981 	nRet = BurnLoadRom(MSM6295ROMData2 + 0x200000, 13, 1); if (nRet != 0) return 1;
4982 	ExpandSampleBanks();
4983 
4984 	ToyboxMCURun = BonkadvMCURun;
4985 
4986 	nRet = GtmrMachineInit(); if (nRet != 0) return 1;
4987 
4988 	// Reset the driver
4989 	GtmrDoReset();
4990 
4991 	return 0;
4992 }
4993 
ExplbrkrInit()4994 static INT32 ExplbrkrInit()
4995 {
4996 	INT32 nRet = 0, nLen;
4997 
4998 	Kaneko16NumSprites = 0x4800;
4999 	Kaneko16NumTiles = 0x2000;
5000 	Kaneko16NumTiles2 = 0x2000;
5001 
5002 	Kaneko16VideoInit();
5003 
5004 	// Allocate and Blank all required memory
5005 	Mem = NULL;
5006 	ExplbrkrMemIndex();
5007 	nLen = MemEnd - (UINT8 *)0;
5008 	if ((Mem = (UINT8 *)BurnMalloc(nLen)) == NULL) return 1;
5009 	memset(Mem, 0, nLen);
5010 	ExplbrkrMemIndex();
5011 
5012 	Kaneko16TempGfx = (UINT8*)BurnMalloc(0x240000);
5013 
5014 	// Load and byte-swap 68000 Program roms
5015 	nRet = BurnLoadRom(Kaneko16Rom + 0x00001, 0, 2); if (nRet != 0) return 1;
5016 	nRet = BurnLoadRom(Kaneko16Rom + 0x00000, 1, 2); if (nRet != 0) return 1;
5017 
5018 	// Load and Decode Sprite Roms
5019 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x0000000,  2, 1); if (nRet != 0) return 1;
5020 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x0080000,  3, 1); if (nRet != 0) return 1;
5021 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x0100000,  2, 1); if (nRet != 0) return 1;
5022 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x0180000,  3, 1); if (nRet != 0) return 1;
5023 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x0200000,  4, 1); if (nRet != 0) return 1;
5024 	GfxDecode(Kaneko16NumSprites, 4, 16, 16, FourBppPlaneOffsets, FourBppXOffsets, FourBppYOffsets, 0x400, Kaneko16TempGfx, Kaneko16Sprites);
5025 
5026 	// Load and Decode Tile Roms
5027 	memset(Kaneko16TempGfx, 0, 0x240000);
5028 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x000000, 5, 1); if (nRet != 0) return 1;
5029 	UnscrambleTiles(0x100000);
5030 	GfxDecode(Kaneko16NumTiles, 4, 16, 16, FourBppPlaneOffsets, FourBppXOffsets, FourBppYOffsets, 0x400, Kaneko16TempGfx, Kaneko16Tiles);
5031 	memset(Kaneko16TempGfx, 0, 0x240000);
5032 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x000000, 6, 1); if (nRet != 0) return 1;
5033 	UnscrambleTiles(0x100000);
5034 	GfxDecode(Kaneko16NumTiles2, 4, 16, 16, FourBppPlaneOffsets, FourBppXOffsets, FourBppYOffsets, 0x400, Kaneko16TempGfx, Kaneko16Tiles2);
5035 
5036 	// Load Sample Rom
5037 	memset(Kaneko16TempGfx, 0, 0x240000);
5038 	nRet = BurnLoadRom(Kaneko16TempGfx, 7, 1); if (nRet != 0) return 1;
5039 	memcpy(MSM6295ROMData + 0x000000, Kaneko16TempGfx + 0x000000, 0x20000);
5040 	memcpy(MSM6295ROMData + 0x020000, Kaneko16TempGfx + 0x020000, 0x20000);
5041 	memcpy(MSM6295ROMData + 0x040000, Kaneko16TempGfx + 0x000000, 0x20000);
5042 	memcpy(MSM6295ROMData + 0x060000, Kaneko16TempGfx + 0x040000, 0x20000);
5043 	memcpy(MSM6295ROMData + 0x080000, Kaneko16TempGfx + 0x000000, 0x20000);
5044 	memcpy(MSM6295ROMData + 0x0a0000, Kaneko16TempGfx + 0x060000, 0x20000);
5045 	memcpy(MSM6295ROMData + 0x0c0000, Kaneko16TempGfx + 0x000000, 0x20000);
5046 	memcpy(MSM6295ROMData + 0x0e0000, Kaneko16TempGfx + 0x080000, 0x20000);
5047 	memcpy(MSM6295ROMData + 0x100000, Kaneko16TempGfx + 0x000000, 0x20000);
5048 	memcpy(MSM6295ROMData + 0x120000, Kaneko16TempGfx + 0x0a0000, 0x20000);
5049 	memcpy(MSM6295ROMData + 0x140000, Kaneko16TempGfx + 0x000000, 0x20000);
5050 	memcpy(MSM6295ROMData + 0x160000, Kaneko16TempGfx + 0x0c0000, 0x20000);
5051 	memcpy(MSM6295ROMData + 0x180000, Kaneko16TempGfx + 0x000000, 0x20000);
5052 	memcpy(MSM6295ROMData + 0x1a0000, Kaneko16TempGfx + 0x0e0000, 0x20000);
5053 	BurnFree(Kaneko16TempGfx);
5054 
5055 	SekInit(0, 0x68000);
5056 	SekOpen(0);
5057 	SekMapMemory(Kaneko16Rom          , 0x000000, 0x07ffff, MAP_ROM);
5058 	SekMapMemory(Kaneko16Ram          , 0x100000, 0x10ffff, MAP_RAM);
5059 	SekMapMemory(Kaneko16Video1Ram    , 0x500000, 0x500fff, MAP_RAM);
5060 	SekMapMemory(Kaneko16Video0Ram    , 0x501000, 0x501fff, MAP_RAM);
5061 	SekMapMemory(Kaneko16VScrl1Ram    , 0x502000, 0x502fff, MAP_RAM);
5062 	SekMapMemory(Kaneko16VScrl0Ram    , 0x503000, 0x503fff, MAP_RAM);
5063 	SekMapMemory(Kaneko16Video3Ram    , 0x580000, 0x580fff, MAP_RAM);
5064 	SekMapMemory(Kaneko16Video2Ram    , 0x581000, 0x581fff, MAP_RAM);
5065 	SekMapMemory(Kaneko16VScrl3Ram    , 0x582000, 0x582fff, MAP_RAM);
5066 	SekMapMemory(Kaneko16VScrl2Ram    , 0x583000, 0x583fff, MAP_RAM);
5067 	SekMapMemory(Kaneko16SpriteRam    , 0x600000, 0x601fff, MAP_RAM);
5068 	SekMapMemory(Kaneko16PaletteRam   , 0x700000, 0x700fff, MAP_RAM);
5069 	SekMapMemory((UINT8*)Kaneko16Layer0Regs    , 0x800000, 0x80001f, MAP_WRITE);
5070 	SekMapMemory((UINT8*)Kaneko16SpriteRegs + 2, 0x900002, 0x90001f, MAP_WRITE);
5071 	SekMapMemory((UINT8*)Kaneko16Layer1Regs    , 0xb00000, 0xb0001f, MAP_WRITE);
5072 	SekSetReadByteHandler(0, ExplbrkrReadByte);
5073 	SekSetReadWordHandler(0, ExplbrkrReadWord);
5074 	SekSetWriteByteHandler(0, ExplbrkrWriteByte);
5075 	SekSetWriteWordHandler(0, ExplbrkrWriteWord);
5076 	SekClose();
5077 
5078 	Kaneko16Eeprom = 1;
5079 	EEPROMInit(&eeprom_interface_93C46);
5080 
5081 	AY8910Init(0, 2000000, 0);
5082 	AY8910Init(1, 2000000, 1);
5083 	AY8910SetPorts(1, &Kaneko16EepromRead, NULL, NULL, &Kaneko16EepromReset);
5084 
5085 	// Setup the OKIM6295 emulation
5086 	MSM6295Init(0, (12000000 / 6) / 132, 1);
5087 	MSM6295SetRoute(0, 1.00, BURN_SND_ROUTE_BOTH);
5088 
5089 	// Reset the driver
5090 	ExplbrkrDoReset();
5091 
5092 	return 0;
5093 }
5094 
GtmrInit()5095 static INT32 GtmrInit()
5096 {
5097 	INT32 nRet = 0, nLen;
5098 
5099 	Gtmr = 1;
5100 
5101 	Kaneko16NumSprites = 0x8400;
5102 	Kaneko16NumTiles = 0x4000;
5103 	Kaneko16NumTiles2 = 0x4000;
5104 
5105 	Kaneko16VideoInit();
5106 	Kaneko16ParseSprite = Kaneko16ParseSpriteType1;
5107 
5108 	// Allocate and Blank all required memory
5109 	Mem = NULL;
5110 	GtmrMemIndex();
5111 	nLen = MemEnd - (UINT8 *)0;
5112 	if ((Mem = (UINT8 *)BurnMalloc(nLen)) == NULL) return 1;
5113 	memset(Mem, 0, nLen);
5114 	GtmrMemIndex();
5115 
5116 	Kaneko16TempGfx = (UINT8*)BurnMalloc(0x840000);
5117 
5118 	// Load and byte-swap 68000 Program roms
5119 	nRet = BurnLoadRom(Kaneko16Rom + 0x00001, 0, 2); if (nRet != 0) return 1;
5120 	nRet = BurnLoadRom(Kaneko16Rom + 0x00000, 1, 2); if (nRet != 0) return 1;
5121 
5122 	// Load and Decode Sprite Roms
5123 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x000000, 3, 1); if (nRet != 0) return 1;
5124 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x200000, 4, 1); if (nRet != 0) return 1;
5125 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x400000, 5, 1); if (nRet != 0) return 1;
5126 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x600000, 6, 1); if (nRet != 0) return 1;
5127 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x800001, 7, 2); if (nRet != 0) return 1;
5128 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x800000, 8, 2); if (nRet != 0) return 1;
5129 	GfxDecode(Kaneko16NumSprites, 8, 16, 16, EightBppPlaneOffsets, EightBppXOffsets, EightBppYOffsets, 0x800, Kaneko16TempGfx, Kaneko16Sprites);
5130 
5131 	// Load and Decode Tile Roms
5132 	memset(Kaneko16TempGfx, 0, 0x840000);
5133 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x000000, 9, 1); if (nRet != 0) return 1;
5134 	UnscrambleTiles(0x200000);
5135 	GfxDecode(Kaneko16NumTiles, 4, 16, 16, FourBppPlaneOffsets, FourBppXOffsets, FourBppYOffsets, 0x400, Kaneko16TempGfx, Kaneko16Tiles);
5136 	BurnFree(Kaneko16TempGfx);
5137 	memcpy(Kaneko16Tiles2, Kaneko16Tiles, Kaneko16NumTiles * 16 * 16);
5138 
5139 	// Load Sample Rom
5140 	nRet = BurnLoadRom(MSM6295ROMData, 10, 1); if (nRet != 0) return 1;
5141 	ExpandSampleBanks();
5142 
5143 	ToyboxMCURun = GtmrMCURun;
5144 
5145 	nRet = GtmrMachineInit(); if (nRet != 0) return 1;
5146 
5147 	// Reset the driver
5148 	GtmrDoReset();
5149 
5150 	return 0;
5151 }
5152 
GtmroInit()5153 static INT32 GtmroInit()
5154 {
5155 	INT32 nRet = 0, nLen;
5156 
5157 	Gtmr = 1;
5158 
5159 	Kaneko16NumSprites = 0x8400;
5160 	Kaneko16NumTiles = 0x4000;
5161 	Kaneko16NumTiles2 = 0x4000;
5162 
5163 	Kaneko16VideoInit();
5164 	Kaneko16ParseSprite = Kaneko16ParseSpriteType1;
5165 
5166 	// Allocate and Blank all required memory
5167 	Mem = NULL;
5168 	GtmrMemIndex();
5169 	nLen = MemEnd - (UINT8 *)0;
5170 	if ((Mem = (UINT8 *)BurnMalloc(nLen)) == NULL) return 1;
5171 	memset(Mem, 0, nLen);
5172 	GtmrMemIndex();
5173 
5174 	Kaneko16TempGfx = (UINT8*)BurnMalloc(0x840000);
5175 
5176 	// Load and byte-swap 68000 Program roms
5177 	nRet = BurnLoadRom(Kaneko16Rom + 0x00001, 0, 2); if (nRet != 0) return 1;
5178 	nRet = BurnLoadRom(Kaneko16Rom + 0x00000, 1, 2); if (nRet != 0) return 1;
5179 
5180 	// Load and Decode Sprite Roms
5181 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x000000,  3, 2); if (nRet != 0) return 1;
5182 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x000001,  4, 2); if (nRet != 0) return 1;
5183 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x200000,  5, 2); if (nRet != 0) return 1;
5184 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x200001,  6, 2); if (nRet != 0) return 1;
5185 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x400000,  7, 2); if (nRet != 0) return 1;
5186 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x400001,  8, 2); if (nRet != 0) return 1;
5187 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x600000,  9, 2); if (nRet != 0) return 1;
5188 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x600001, 10, 2); if (nRet != 0) return 1;
5189 	GfxDecode(Kaneko16NumSprites, 8, 16, 16, EightBppPlaneOffsets, EightBppXOffsets, EightBppYOffsets, 0x800, Kaneko16TempGfx, Kaneko16Sprites);
5190 
5191 	// Load and Decode Tile Roms
5192 	memset(Kaneko16TempGfx, 0, 0x800000);
5193 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x000000, 11, 2); if (nRet != 0) return 1;
5194 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x000001, 12, 2); if (nRet != 0) return 1;
5195 	UnscrambleTiles(0x200000);
5196 	GfxDecode(Kaneko16NumTiles, 4, 16, 16, FourBppPlaneOffsets, FourBppXOffsets, FourBppYOffsets, 0x400, Kaneko16TempGfx, Kaneko16Tiles);
5197 	BurnFree(Kaneko16TempGfx);
5198 	memcpy(Kaneko16Tiles2, Kaneko16Tiles, Kaneko16NumTiles * 16 * 16);
5199 
5200 	// Load Sample Rom
5201 	nRet = BurnLoadRom(MSM6295ROMData, 13, 1); if (nRet != 0) return 1;
5202 	ExpandSampleBanks();
5203 
5204 	ToyboxMCURun = GtmroMCURun;
5205 
5206 	nRet = GtmrMachineInit(); if (nRet != 0) return 1;
5207 
5208 	// Reset the driver
5209 	GtmrDoReset();
5210 
5211 	return 0;
5212 }
5213 
GtmrevoInit()5214 static INT32 GtmrevoInit()
5215 {
5216 	INT32 nRet = 0, nLen;
5217 
5218 	Gtmr = 1;
5219 
5220 	Kaneko16NumSprites = 0x8000;
5221 	Kaneko16NumTiles = 0x4000;
5222 	Kaneko16NumTiles2 = 0x4000;
5223 
5224 	Kaneko16VideoInit();
5225 	Kaneko16ParseSprite = Kaneko16ParseSpriteType1;
5226 
5227 	// Allocate and Blank all required memory
5228 	Mem = NULL;
5229 	GtmrMemIndex();
5230 	nLen = MemEnd - (UINT8 *)0;
5231 	if ((Mem = (UINT8 *)BurnMalloc(nLen)) == NULL) return 1;
5232 	memset(Mem, 0, nLen);
5233 	GtmrMemIndex();
5234 
5235 	Kaneko16TempGfx = (UINT8*)BurnMalloc(0x800000);
5236 
5237 	// Load and byte-swap 68000 Program roms
5238 	nRet = BurnLoadRom(Kaneko16Rom + 0x00001, 0, 2); if (nRet != 0) return 1;
5239 	nRet = BurnLoadRom(Kaneko16Rom + 0x00000, 1, 2); if (nRet != 0) return 1;
5240 
5241 	// Load and Decode Sprite Roms
5242 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x600000, 7, 2); if (nRet != 0) return 1;
5243 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x600001, 8, 2); if (nRet != 0) return 1;
5244 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x000000, 3, 1); if (nRet != 0) return 1;
5245 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x200000, 4, 1); if (nRet != 0) return 1;
5246 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x400000, 5, 1); if (nRet != 0) return 1;
5247 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x600000, 6, 1); if (nRet != 0) return 1;
5248 	GfxDecode(Kaneko16NumSprites, 8, 16, 16, EightBppPlaneOffsets, EightBppXOffsets, EightBppYOffsets, 0x800, Kaneko16TempGfx, Kaneko16Sprites);
5249 
5250 	// Load and Decode Tile Roms
5251 	memset(Kaneko16TempGfx, 0, 0x800000);
5252 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x000000, 9, 1); if (nRet != 0) return 1;
5253 	UnscrambleTiles(0x200000);
5254 	GfxDecode(Kaneko16NumTiles, 4, 16, 16, FourBppPlaneOffsets, FourBppXOffsets, FourBppYOffsets, 0x400, Kaneko16TempGfx, Kaneko16Tiles);
5255 	BurnFree(Kaneko16TempGfx);
5256 	memcpy(Kaneko16Tiles2, Kaneko16Tiles, Kaneko16NumTiles * 16 * 16);
5257 
5258 	// Load Sample Rom
5259 	nRet = BurnLoadRom(MSM6295ROMData, 10, 1); if (nRet != 0) return 1;
5260 	nRet = BurnLoadRom(MSM6295ROMData2, 11, 1); if (nRet != 0) return 1;
5261 	ExpandSampleBanks();
5262 
5263 	nRet = GtmrMachineInit(); if (nRet != 0) return 1;
5264 
5265 	ToyboxMCURun = GtmrevoMCURun;
5266 
5267 	// Reset the driver
5268 	GtmrDoReset();
5269 
5270 	return 0;
5271 }
5272 
Gtmr2Init()5273 static INT32 Gtmr2Init()
5274 {
5275 	INT32 nRet = 0, nLen;
5276 
5277 	Gtmr = 1;
5278 
5279 	Kaneko16NumSprites = 0x8000;
5280 	Kaneko16NumTiles = 0x8800;
5281 	Kaneko16NumTiles2 = 0x8800;
5282 
5283 	Kaneko16VideoInit();
5284 	Kaneko16ParseSprite = Kaneko16ParseSpriteType1;
5285 
5286 	// Allocate and Blank all required memory
5287 	Mem = NULL;
5288 	GtmrMemIndex();
5289 	nLen = MemEnd - (UINT8 *)0;
5290 	if ((Mem = (UINT8 *)BurnMalloc(nLen)) == NULL) return 1;
5291 	memset(Mem, 0, nLen);
5292 	GtmrMemIndex();
5293 
5294 	Kaneko16TempGfx = (UINT8*)BurnMalloc(0x800000);
5295 
5296 	// Load and byte-swap 68000 Program roms
5297 	nRet = BurnLoadRom(Kaneko16Rom + 0x00001, 0, 2); if (nRet != 0) return 1;
5298 	nRet = BurnLoadRom(Kaneko16Rom + 0x00000, 1, 2); if (nRet != 0) return 1;
5299 
5300 	// Load and Decode Sprite Roms
5301 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x000000, 3, 1); if (nRet != 0) return 1;
5302 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x400000, 4, 1); if (nRet != 0) return 1;
5303 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x600000, 5, 1); if (nRet != 0) return 1;
5304 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x700000, 6, 2); if (nRet != 0) return 1;
5305 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x700001, 7, 2); if (nRet != 0) return 1;
5306 	GfxDecode(Kaneko16NumSprites, 8, 16, 16, EightBppPlaneOffsets, EightBppXOffsets, EightBppYOffsets, 0x800, Kaneko16TempGfx, Kaneko16Sprites);
5307 
5308 	// Load and Decode Tile Roms
5309 	memset(Kaneko16TempGfx, 0, 0x800000);
5310 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x000000,  8, 1); if (nRet != 0) return 1;
5311 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x200000,  9, 1); if (nRet != 0) return 1;
5312 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x400000, 10, 2); if (nRet != 0) return 1;
5313 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x400001, 11, 2); if (nRet != 0) return 1;
5314 	UnscrambleTiles(0x440000);
5315 	GfxDecode(Kaneko16NumTiles, 4, 16, 16, FourBppPlaneOffsets, FourBppXOffsets, FourBppYOffsets, 0x400, Kaneko16TempGfx, Kaneko16Tiles);
5316 	BurnFree(Kaneko16TempGfx);
5317 	memcpy(Kaneko16Tiles2, Kaneko16Tiles, Kaneko16NumTiles * 16 * 16);
5318 
5319 	// Load Sample Rom
5320 	nRet = BurnLoadRom(MSM6295ROMData, 12, 1); if (nRet != 0) return 1;
5321 	nRet = BurnLoadRom(MSM6295ROMData2 + 0x40000, 13, 1); if (nRet != 0) return 1;
5322 	ExpandSampleBanks();
5323 
5324 	nRet = GtmrMachineInit(); if (nRet != 0) return 1;
5325 
5326 	ToyboxMCURun = GtmrevoMCURun;
5327 
5328 	// Reset the driver
5329 	GtmrDoReset();
5330 
5331 	return 0;
5332 }
5333 
Gtmr2uInit()5334 static INT32 Gtmr2uInit()
5335 {
5336 	INT32 nRet = 0, nLen;
5337 
5338 	Gtmr = 1;
5339 
5340 	Kaneko16NumSprites = 0x8000;
5341 	Kaneko16NumTiles = 0x8800;
5342 	Kaneko16NumTiles2 = 0x8800;
5343 
5344 	Kaneko16VideoInit();
5345 	Kaneko16ParseSprite = Kaneko16ParseSpriteType1;
5346 
5347 	// Allocate and Blank all required memory
5348 	Mem = NULL;
5349 	GtmrMemIndex();
5350 	nLen = MemEnd - (UINT8 *)0;
5351 	if ((Mem = (UINT8 *)BurnMalloc(nLen)) == NULL) return 1;
5352 	memset(Mem, 0, nLen);
5353 	GtmrMemIndex();
5354 
5355 	Kaneko16TempGfx = (UINT8*)BurnMalloc(0x800000);
5356 
5357 	// Load and byte-swap 68000 Program roms
5358 	nRet = BurnLoadRom(Kaneko16Rom + 0x00001, 0, 2); if (nRet != 0) return 1;
5359 	nRet = BurnLoadRom(Kaneko16Rom + 0x00000, 1, 2); if (nRet != 0) return 1;
5360 
5361 	// Load and Decode Sprite Roms
5362 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x000000, 3, 1); if (nRet != 0) return 1;
5363 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x400000, 4, 1); if (nRet != 0) return 1;
5364 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x600000, 5, 1); if (nRet != 0) return 1;
5365 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x700000, 6, 2); if (nRet != 0) return 1;
5366 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x700001, 7, 2); if (nRet != 0) return 1;
5367 	GfxDecode(Kaneko16NumSprites, 8, 16, 16, EightBppPlaneOffsets, EightBppXOffsets, EightBppYOffsets, 0x800, Kaneko16TempGfx, Kaneko16Sprites);
5368 
5369 	// Load and Decode Tile Roms
5370 	memset(Kaneko16TempGfx, 0, 0x800000);
5371 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x000000,  8, 1); if (nRet != 0) return 1;
5372 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x200000,  9, 1); if (nRet != 0) return 1;
5373 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x400000, 10, 2); if (nRet != 0) return 1;
5374 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x400001, 11, 2); if (nRet != 0) return 1;
5375 	UnscrambleTiles(0x440000);
5376 	GfxDecode(Kaneko16NumTiles, 4, 16, 16, FourBppPlaneOffsets, FourBppXOffsets, FourBppYOffsets, 0x400, Kaneko16TempGfx, Kaneko16Tiles);
5377 	BurnFree(Kaneko16TempGfx);
5378 	memcpy(Kaneko16Tiles2, Kaneko16Tiles, Kaneko16NumTiles * 16 * 16);
5379 
5380 	// Load Sample Rom
5381 	nRet = BurnLoadRom(MSM6295ROMData, 12, 1); if (nRet != 0) return 1;
5382 	nRet = BurnLoadRom(MSM6295ROMData2, 13, 1); if (nRet != 0) return 1;
5383 	ExpandSampleBanks();
5384 
5385 	nRet = GtmrMachineInit(); if (nRet != 0) return 1;
5386 
5387 	ToyboxMCURun = GtmrevoMCURun;
5388 
5389 	// Reset the driver
5390 	GtmrDoReset();
5391 
5392 	return 0;
5393 }
5394 
MgcrystlInit()5395 static INT32 MgcrystlInit()
5396 {
5397 	INT32 nRet = 0, nLen;
5398 
5399 	Mgcrystl = 1;
5400 
5401 	Kaneko16NumSprites = 0x5000;
5402 	Kaneko16NumTiles = 0x2000;
5403 	Kaneko16NumTiles2 = 0x2000;
5404 
5405 	Kaneko16VideoInit();
5406 
5407 	Kaneko16SpritePrio(2, 3, 5, 7);
5408 
5409 	// Allocate and Blank all required memory
5410 	Mem = NULL;
5411 	ExplbrkrMemIndex();
5412 	nLen = MemEnd - (UINT8 *)0;
5413 	if ((Mem = (UINT8 *)BurnMalloc(nLen)) == NULL) return 1;
5414 	memset(Mem, 0, nLen);
5415 	ExplbrkrMemIndex();
5416 
5417 	Kaneko16TempGfx = (UINT8*)BurnMalloc(0x280000);
5418 
5419 	// Load and byte-swap 68000 Program roms
5420 	nRet = BurnLoadRom(Kaneko16Rom + 0x00001, 0, 2); if (nRet != 0) return 1;
5421 	nRet = BurnLoadRom(Kaneko16Rom + 0x00000, 1, 2); if (nRet != 0) return 1;
5422 
5423 	// Load and Decode Sprite Roms
5424 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x0000000,  2, 1); if (nRet != 0) return 1;
5425 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x0100000,  3, 1); if (nRet != 0) return 1;
5426 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x0180000,  3, 1); if (nRet != 0) return 1;
5427 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x0200000,  4, 1); if (nRet != 0) return 1;
5428 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x0220000,  4, 1); if (nRet != 0) return 1;
5429 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x0240000,  4, 1); if (nRet != 0) return 1;
5430 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x0260000,  4, 1); if (nRet != 0) return 1;
5431 	GfxDecode(Kaneko16NumSprites, 4, 16, 16, FourBppPlaneOffsets, FourBppXOffsets, FourBppYOffsets, 0x400, Kaneko16TempGfx, Kaneko16Sprites);
5432 
5433 	// Load and Decode Tile Roms
5434 	memset(Kaneko16TempGfx, 0, 0x280000);
5435 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x000000, 5, 1); if (nRet != 0) return 1;
5436 	UnscrambleTiles(0x100000);
5437 	GfxDecode(Kaneko16NumTiles, 4, 16, 16, FourBppPlaneOffsets, FourBppXOffsets, FourBppYOffsets, 0x400, Kaneko16TempGfx, Kaneko16Tiles);
5438 	memset(Kaneko16TempGfx, 0, 0x280000);
5439 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x000000, 6, 1); if (nRet != 0) return 1;
5440 	UnscrambleTiles(0x100000);
5441 	GfxDecode(Kaneko16NumTiles2, 4, 16, 16, FourBppPlaneOffsets, FourBppXOffsets, FourBppYOffsets, 0x400, Kaneko16TempGfx, Kaneko16Tiles2);
5442 	BurnFree(Kaneko16TempGfx);
5443 
5444 	// Load Sample Rom
5445 	nRet = BurnLoadRom(MSM6295ROM, 7, 1); if (nRet != 0) return 1;
5446 	memcpy(MSM6295ROMData, MSM6295ROM, 0x40000);
5447 
5448 	SekInit(0, 0x68000);
5449 	SekOpen(0);
5450 	SekMapMemory(Kaneko16Rom          , 0x000000, 0x07ffff, MAP_ROM);
5451 	SekMapMemory(Kaneko16Ram          , 0x300000, 0x30ffff, MAP_RAM);
5452 	SekMapMemory(Kaneko16PaletteRam   , 0x500000, 0x500fff, MAP_RAM);
5453 	SekMapMemory(Kaneko16Video1Ram    , 0x600000, 0x600fff, MAP_RAM);
5454 	SekMapMemory(Kaneko16Video0Ram    , 0x601000, 0x601fff, MAP_RAM);
5455 	SekMapMemory(Kaneko16VScrl1Ram    , 0x602000, 0x602fff, MAP_RAM);
5456 	SekMapMemory(Kaneko16VScrl0Ram    , 0x603000, 0x603fff, MAP_RAM);
5457 	SekMapMemory(Kaneko16Video3Ram    , 0x680000, 0x680fff, MAP_RAM);
5458 	SekMapMemory(Kaneko16Video2Ram    , 0x681000, 0x681fff, MAP_RAM);
5459 	SekMapMemory(Kaneko16VScrl3Ram    , 0x682000, 0x682fff, MAP_RAM);
5460 	SekMapMemory(Kaneko16VScrl2Ram    , 0x683000, 0x683fff, MAP_RAM);
5461 	SekMapMemory(Kaneko16SpriteRam    , 0x700000, 0x701fff, MAP_RAM);
5462 	SekMapMemory((UINT8*)Kaneko16Layer0Regs    , 0x800000, 0x80001f, MAP_WRITE);
5463 	SekMapMemory((UINT8*)Kaneko16SpriteRegs + 2, 0x900002, 0x90001f, MAP_WRITE);
5464 	SekMapMemory((UINT8*)Kaneko16Layer1Regs    , 0xb00000, 0xb0001f, MAP_WRITE);
5465 	SekSetReadByteHandler(0, MgcrystlReadByte);
5466 	SekSetReadWordHandler(0, ExplbrkrReadWord);
5467 	SekSetWriteByteHandler(0, ExplbrkrWriteByte);
5468 	SekSetWriteWordHandler(0, ExplbrkrWriteWord);
5469 	SekClose();
5470 
5471 	Kaneko16Eeprom = 1;
5472 	EEPROMInit(&eeprom_interface_93C46);
5473 
5474 	AY8910Init(0, 2000000, 0);
5475 	AY8910Init(1, 2000000, 1);
5476 	AY8910SetPorts(1, &Kaneko16EepromRead, NULL, NULL, &Kaneko16EepromReset);
5477 
5478 	// Setup the OKIM6295 emulation
5479 	MSM6295Init(0, (12000000 / 4) / 165, 1);
5480 	MSM6295SetRoute(0, 1.00, BURN_SND_ROUTE_BOTH);
5481 
5482 	// Reset the driver
5483 	ExplbrkrDoReset();
5484 
5485 	return 0;
5486 }
5487 
ShogwarrInit()5488 static INT32 ShogwarrInit()
5489 {
5490 	static const UINT16 shogwarr_default_eeprom[64] = {
5491 		0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
5492 		0x4B41, 0x4E45, 0x4B4F, 0x2F41, 0x544F, 0x5020, 0x3139, 0x3932,
5493 		0x4655, 0x4A49, 0x5941, 0x4D41, 0x2042, 0x5553, 0x5445, 0x5220,
5494 		0x2053, 0x484F, 0x4755, 0x4E20, 0x5741, 0x5252, 0x494F, 0x5253,
5495 		0x636F, 0x7079, 0x7269, 0x6768, 0x7420, 0x4B41, 0x4E45, 0x4B4F,
5496 		0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
5497 		0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xFFFF,
5498 		0x0000, 0x0000, 0x0000, 0x0000, 0x0010, 0x0000, 0x0000, 0xFFFF
5499 	};
5500 
5501 	Shogwarr = 1;
5502 
5503 	INT32 nRet = 0, nLen;
5504 
5505 	Kaneko16NumSprites = 0x10000;
5506 	Kaneko16NumTiles = 0x4000;
5507 	Kaneko16NumTiles2 = 0;
5508 
5509 	Kaneko16VideoInit();
5510 	Kaneko16SpriteXOffset = 0;
5511 	Kaneko16SpriteFlipType = 1;
5512 
5513 	// Allocate and Blank all required memory
5514 	Mem = NULL;
5515 	ShogwarrMemIndex();
5516 	nLen = MemEnd - (UINT8 *)0;
5517 	if ((Mem = (UINT8 *)BurnMalloc(nLen)) == NULL) return 1;
5518 	memset(Mem, 0, nLen);
5519 	ShogwarrMemIndex();
5520 
5521 	Kaneko16TempGfx = (UINT8*)BurnMalloc(0x800000);
5522 
5523 	// Load and byte-swap 68000 Program roms
5524 	nRet = BurnLoadRom(Kaneko16Rom + 0x00001, 0, 2); if (nRet != 0) return 1;
5525 	nRet = BurnLoadRom(Kaneko16Rom + 0x00000, 1, 2); if (nRet != 0) return 1;
5526 
5527 	nRet = BurnLoadRom(Kaneko16McuRom, 2, 1); if (nRet != 0) return 1;
5528 
5529 	// Load and Decode Sprite Roms
5530 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x0000000,  3, 1); if (nRet != 0) return 1;
5531 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x0100000,  4, 1); if (nRet != 0) return 1;
5532 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x0200000,  5, 1); if (nRet != 0) return 1;
5533 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x0300000,  6, 1); if (nRet != 0) return 1;
5534 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x0400000,  7, 1); if (nRet != 0) return 1;
5535 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x0500000,  8, 1); if (nRet != 0) return 1;
5536 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x0600000,  9, 1); if (nRet != 0) return 1;
5537 	memset (Kaneko16TempGfx + 0x0700000, 0xff, 0x100000);
5538 
5539 	GfxDecode(Kaneko16NumSprites, 4, 16, 16, FourBppPlaneOffsets, FourBppXOffsets, FourBppYOffsets, 0x400, Kaneko16TempGfx, Kaneko16Sprites);
5540 
5541 	// Load and Decode Tile Roms
5542 	memset(Kaneko16TempGfx, 0, 0x400000);
5543 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x0000000, 10, 1); if (nRet != 0) return 1;
5544 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x0100000, 11, 1); if (nRet != 0) return 1;
5545 	UnscrambleTiles(0x180000);
5546 	GfxDecode(Kaneko16NumTiles, 4, 16, 16, FourBppPlaneOffsets, FourBppXOffsets, FourBppYOffsets, 0x400, Kaneko16TempGfx, Kaneko16Tiles);
5547 
5548 	BurnFree(Kaneko16TempGfx);
5549 
5550 	nRet = BurnLoadRom(MSM6295ROMData + 0x000000, 12, 1); if (nRet != 0) return 1;
5551 	nRet = BurnLoadRom(MSM6295ROMData + 0x080000, 13, 1); if (nRet != 0) return 1;
5552 	memcpy (MSM6295ROM + 0x000000, MSM6295ROMData,  0x30000);
5553 
5554 	nRet = BurnLoadRom(MSM6295ROMData2 + 0x000000, 14, 1); if (nRet != 0) return 1;
5555 	nRet = BurnLoadRom(MSM6295ROMData2 + 0x100000, 15, 1); if (nRet != 0) return 1;
5556 
5557 	memcpy (Kaneko16NVRam, shogwarr_default_eeprom, 0x80);
5558 
5559 	SekInit(0, 0x68000);
5560 	SekOpen(0);
5561 	SekMapMemory(Kaneko16Rom          , 0x000000, 0x03ffff, MAP_ROM);
5562 	SekMapMemory(Kaneko16Ram          , 0x100000, 0x10ffff, MAP_RAM);
5563 	SekMapMemory(Kaneko16MCURam	  , 0x200000, 0x20ffff, MAP_RAM);
5564 	SekMapMemory(Kaneko16PaletteRam   , 0x380000, 0x380fff, MAP_RAM);
5565 	SekMapMemory(Kaneko16SpriteRam    , 0x580000, 0x581fff, MAP_RAM);
5566 	SekMapMemory(Kaneko16Video1Ram    , 0x600000, 0x600fff, MAP_RAM);
5567 	SekMapMemory(Kaneko16Video0Ram    , 0x601000, 0x601fff, MAP_RAM);
5568 	SekMapMemory(Kaneko16VScrl1Ram    , 0x602000, 0x602fff, MAP_RAM);
5569 	SekMapMemory(Kaneko16VScrl0Ram    , 0x603000, 0x603fff, MAP_RAM);
5570 	SekMapMemory((UINT8*)Kaneko16Layer0Regs    , 0x800000, 0x80001f, MAP_WRITE);
5571 	SekMapMemory((UINT8*)Kaneko16SpriteRegs    , 0x900000, 0x90001f, MAP_WRITE);
5572 	SekSetReadByteHandler(0, ShogwarrReadByte);
5573 	SekSetReadWordHandler(0, ShogwarrReadWord);
5574 	SekSetWriteByteHandler(0, ShogwarrWriteByte);
5575 	SekSetWriteWordHandler(0, ShogwarrWriteWord);
5576 	SekClose();
5577 
5578 	MSM6295Init(0, (16000000 / 8) / 165, 1);
5579 	MSM6295SetRoute(0, 1.00, BURN_SND_ROUTE_BOTH);
5580 
5581 	MSM6295Init(1, (16000000 / 8) / 165, 1);
5582 	MSM6295SetRoute(1, 1.00, BURN_SND_ROUTE_BOTH);
5583 
5584 	ShogwarrDoReset();
5585 
5586 	return 0;
5587 }
5588 
ShogwarrkInit()5589 static INT32 ShogwarrkInit()
5590 {
5591 	static const UINT16 shogwarr_default_eeprom[64] = {
5592 		0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
5593 		0x4B41, 0x4E45, 0x4B4F, 0x2F41, 0x544F, 0x5020, 0x3139, 0x3932,
5594 		0x4655, 0x4A49, 0x5941, 0x4D41, 0x2042, 0x5553, 0x5445, 0x5220,
5595 		0x2053, 0x484F, 0x4755, 0x4E20, 0x5741, 0x5252, 0x494F, 0x5253,
5596 		0x636F, 0x7079, 0x7269, 0x6768, 0x7420, 0x4B41, 0x4E45, 0x4B4F,
5597 		0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
5598 		0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xFFFF,
5599 		0x0000, 0x0000, 0x0000, 0x0000, 0x0010, 0x0000, 0x0000, 0xFFFF
5600 	};
5601 
5602 	Shogwarr = 1;
5603 
5604 	INT32 nRet = 0, nLen;
5605 
5606 	Kaneko16NumSprites = 0x10000;
5607 	Kaneko16NumTiles = 0x4000;
5608 	Kaneko16NumTiles2 = 0;
5609 
5610 	Kaneko16VideoInit();
5611 	Kaneko16SpriteXOffset = 0;
5612 	Kaneko16SpriteFlipType = 1;
5613 
5614 	// Allocate and Blank all required memory
5615 	Mem = NULL;
5616 	ShogwarrMemIndex();
5617 	nLen = MemEnd - (UINT8 *)0;
5618 	if ((Mem = (UINT8 *)BurnMalloc(nLen)) == NULL) return 1;
5619 	memset(Mem, 0, nLen);
5620 	ShogwarrMemIndex();
5621 
5622 	Kaneko16TempGfx = (UINT8*)BurnMalloc(0x800000);
5623 
5624 	// Load and byte-swap 68000 Program roms
5625 	nRet = BurnLoadRom(Kaneko16Rom + 0x00001, 0, 2); if (nRet != 0) return 1;
5626 	nRet = BurnLoadRom(Kaneko16Rom + 0x00000, 1, 2); if (nRet != 0) return 1;
5627 
5628 	nRet = BurnLoadRom(Kaneko16McuRom, 2, 1); if (nRet != 0) return 1;
5629 
5630 	// Load and Decode Sprite Roms
5631 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x0000000,  3, 1); if (nRet != 0) return 1;
5632 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x0100000,  4, 1); if (nRet != 0) return 1;
5633 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x0200000,  5, 1); if (nRet != 0) return 1;
5634 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x0300000,  6, 1); if (nRet != 0) return 1;
5635 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x0400000,  7, 1); if (nRet != 0) return 1;
5636 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x0500000,  8, 1); if (nRet != 0) return 1;
5637 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x0600000,  9, 1); if (nRet != 0) return 1;
5638 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x0700000, 10, 1); if (nRet != 0) return 1;
5639 	memset (Kaneko16TempGfx + 0x0780000, 0xff, 0x080000);
5640 
5641 	GfxDecode(Kaneko16NumSprites, 4, 16, 16, FourBppPlaneOffsets, FourBppXOffsets, FourBppYOffsets, 0x400, Kaneko16TempGfx, Kaneko16Sprites);
5642 
5643 	// Load and Decode Tile Roms
5644 	memset(Kaneko16TempGfx, 0, 0x400000);
5645 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x0000000, 11, 1); if (nRet != 0) return 1;
5646 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x0100000, 12, 1); if (nRet != 0) return 1;
5647 	UnscrambleTiles(0x180000);
5648 	GfxDecode(Kaneko16NumTiles, 4, 16, 16, FourBppPlaneOffsets, FourBppXOffsets, FourBppYOffsets, 0x400, Kaneko16TempGfx, Kaneko16Tiles);
5649 
5650 	BurnFree(Kaneko16TempGfx);
5651 
5652 	nRet = BurnLoadRom(MSM6295ROMData + 0x000000, 13, 1); if (nRet != 0) return 1;
5653 	nRet = BurnLoadRom(MSM6295ROMData + 0x080000, 14, 1); if (nRet != 0) return 1;
5654 	memcpy (MSM6295ROM + 0x000000, MSM6295ROMData,  0x30000);
5655 
5656 	nRet = BurnLoadRom(MSM6295ROMData2 + 0x000000, 15, 1); if (nRet != 0) return 1;
5657 	nRet = BurnLoadRom(MSM6295ROMData2 + 0x100000, 16, 1); if (nRet != 0) return 1;
5658 
5659 	memcpy (Kaneko16NVRam, shogwarr_default_eeprom, 0x80);
5660 
5661 	SekInit(0, 0x68000);
5662 	SekOpen(0);
5663 	SekMapMemory(Kaneko16Rom          , 0x000000, 0x03ffff, MAP_ROM);
5664 	SekMapMemory(Kaneko16Ram          , 0x100000, 0x10ffff, MAP_RAM);
5665 	SekMapMemory(Kaneko16MCURam	  , 0x200000, 0x20ffff, MAP_RAM);
5666 	SekMapMemory(Kaneko16PaletteRam   , 0x380000, 0x380fff, MAP_RAM);
5667 	SekMapMemory(Kaneko16SpriteRam    , 0x580000, 0x581fff, MAP_RAM);
5668 	SekMapMemory(Kaneko16Video1Ram    , 0x600000, 0x600fff, MAP_RAM);
5669 	SekMapMemory(Kaneko16Video0Ram    , 0x601000, 0x601fff, MAP_RAM);
5670 	SekMapMemory(Kaneko16VScrl1Ram    , 0x602000, 0x602fff, MAP_RAM);
5671 	SekMapMemory(Kaneko16VScrl0Ram    , 0x603000, 0x603fff, MAP_RAM);
5672 	SekMapMemory((UINT8*)Kaneko16Layer0Regs    , 0x800000, 0x80001f, MAP_WRITE);
5673 	SekMapMemory((UINT8*)Kaneko16SpriteRegs    , 0x900000, 0x90001f, MAP_WRITE);
5674 	SekSetReadByteHandler(0, ShogwarrReadByte);
5675 	SekSetReadWordHandler(0, ShogwarrReadWord);
5676 	SekSetWriteByteHandler(0, ShogwarrWriteByte);
5677 	SekSetWriteWordHandler(0, ShogwarrWriteWord);
5678 	SekClose();
5679 
5680 	MSM6295Init(0, (16000000 / 8) / 165, 1);
5681 	MSM6295SetRoute(0, 1.00, BURN_SND_ROUTE_BOTH);
5682 
5683 	MSM6295Init(1, (16000000 / 8) / 165, 1);
5684 	MSM6295SetRoute(1, 1.00, BURN_SND_ROUTE_BOTH);
5685 
5686 	ShogwarrDoReset();
5687 
5688 	return 0;
5689 }
5690 
BrapboysInit()5691 static INT32 BrapboysInit()
5692 {
5693 	static const UINT16 brapboys_default_eeprom[64] = {
5694 		0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
5695 		0x0000, 0x0005, 0x0006, 0x2030, 0x0003, 0x6818, 0x0101, 0x0101,
5696 		0x0101, 0x0001, 0x0004, 0x0008, 0x4B41, 0x4E45, 0x4B4F, 0x2020,
5697 		0x4265, 0x2052, 0x6170, 0x2042, 0x6F79, 0x7300, 0x3030, 0x302E,
5698 		0x3038, 0x10FF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,
5699 		0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,
5700 		0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,
5701 		0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x0035, 0xFFFF, 0xFFFF, 0xFFFF
5702 	};
5703 
5704 	INT32 nRet = 0, nLen;
5705 
5706 	Kaneko16NumSprites = 0x10000;
5707 	Kaneko16NumTiles = 0x8000;
5708 	Kaneko16NumTiles2 = 0;
5709 
5710 	Kaneko16VideoInit();
5711 	Kaneko16SpriteXOffset = 0;
5712 	Kaneko16SpriteFlipType = 1;
5713 
5714 	// Allocate and Blank all required memory
5715 	Mem = NULL;
5716 	ShogwarrMemIndex();
5717 	nLen = MemEnd - (UINT8 *)0;
5718 	if ((Mem = (UINT8 *)BurnMalloc(nLen)) == NULL) return 1;
5719 	memset(Mem, 0, nLen);
5720 	ShogwarrMemIndex();
5721 
5722 	Kaneko16TempGfx = (UINT8*)BurnMalloc(0x800000);
5723 
5724 	// Load and byte-swap 68000 Program roms
5725 	nRet = BurnLoadRom(Kaneko16Rom + 0x00001, 0, 2); if (nRet != 0) return 1;
5726 	nRet = BurnLoadRom(Kaneko16Rom + 0x00000, 1, 2); if (nRet != 0) return 1;
5727 
5728 	nRet = BurnLoadRom(Kaneko16McuRom, 2, 1); if (nRet != 0) return 1;
5729 
5730 	// Load and Decode Sprite Roms
5731 	memset (Kaneko16TempGfx, 0xff, 0x800000);
5732 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x0000000,  3, 1); if (nRet != 0) return 1;
5733 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x0100000,  4, 1); if (nRet != 0) return 1;
5734 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x0200000,  5, 1); if (nRet != 0) return 1;
5735 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x0300000,  6, 1); if (nRet != 0) return 1;
5736 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x0400000,  7, 1); if (nRet != 0) return 1;
5737 	memcpy (Kaneko16TempGfx + 0x0480000, Kaneko16TempGfx + 0x0400000, 0x0080000);
5738 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x0500000,  8, 1); if (nRet != 0) return 1;
5739 
5740 	BurnLoadRom(Kaneko16TempGfx + 0x580000, 17, 1); // brapboysj / brapboysu
5741 
5742 	GfxDecode(Kaneko16NumSprites, 4, 16, 16, FourBppPlaneOffsets, FourBppXOffsets, FourBppYOffsets, 0x400, Kaneko16TempGfx, Kaneko16Sprites);
5743 
5744 	// Load and Decode Tile Roms
5745 	memset(Kaneko16TempGfx, 0, 0x400000);
5746 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x0000000,  9, 1); if (nRet != 0) return 1;
5747 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x0100000, 10, 1); if (nRet != 0) return 1;
5748 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x0200000, 11, 1); if (nRet != 0) return 1;
5749 	nRet = BurnLoadRom(Kaneko16TempGfx + 0x0300000, 12, 1); if (nRet != 0) return 1;
5750 	UnscrambleTiles(0x400000);
5751 	GfxDecode(Kaneko16NumTiles, 4, 16, 16, FourBppPlaneOffsets, FourBppXOffsets, FourBppYOffsets, 0x400, Kaneko16TempGfx, Kaneko16Tiles);
5752 
5753 	BurnFree(Kaneko16TempGfx);
5754 
5755 	nRet = BurnLoadRom(MSM6295ROMData + 0x000000, 13, 1); if (nRet != 0) return 1;
5756 	nRet = BurnLoadRom(MSM6295ROMData + 0x080000, 14, 1); if (nRet != 0) return 1;
5757 	memcpy (MSM6295ROM + 0x000000, MSM6295ROMData,  0x30000);
5758 
5759 	nRet = BurnLoadRom(MSM6295ROMData2 + 0x000000, 15, 1); if (nRet != 0) return 1;
5760 	nRet = BurnLoadRom(MSM6295ROMData2 + 0x100000, 16, 1); if (nRet != 0) return 1;
5761 	memcpy (MSM6295ROM + 0x100000, MSM6295ROMData2,  0x20000);
5762 
5763 	memcpy (Kaneko16NVRam, brapboys_default_eeprom, 0x80);
5764 
5765 	SekInit(0, 0x68000);
5766 	SekOpen(0);
5767 	SekMapMemory(Kaneko16Rom          , 0x000000, 0x03ffff, MAP_ROM);
5768 	SekMapMemory(Kaneko16Ram          , 0x100000, 0x10ffff, MAP_RAM);
5769 	SekMapMemory(Kaneko16MCURam	  , 0x200000, 0x20ffff, MAP_RAM);
5770 	SekMapMemory(Kaneko16PaletteRam   , 0x380000, 0x380fff, MAP_RAM);
5771 	SekMapMemory(Kaneko16SpriteRam    , 0x580000, 0x581fff, MAP_RAM);
5772 	SekMapMemory(Kaneko16Video1Ram    , 0x600000, 0x600fff, MAP_RAM);
5773 	SekMapMemory(Kaneko16Video0Ram    , 0x601000, 0x601fff, MAP_RAM);
5774 	SekMapMemory(Kaneko16VScrl1Ram    , 0x602000, 0x602fff, MAP_RAM);
5775 	SekMapMemory(Kaneko16VScrl0Ram    , 0x603000, 0x603fff, MAP_RAM);
5776 	SekMapMemory((UINT8*)Kaneko16Layer0Regs    , 0x800000, 0x80001f, MAP_WRITE);
5777 	SekMapMemory((UINT8*)Kaneko16SpriteRegs    , 0x900000, 0x90001f, MAP_WRITE);
5778 	SekSetReadByteHandler(0, ShogwarrReadByte);
5779 	SekSetReadWordHandler(0, ShogwarrReadWord);
5780 	SekSetWriteByteHandler(0, ShogwarrWriteByte);
5781 	SekSetWriteWordHandler(0, ShogwarrWriteWord);
5782 	SekClose();
5783 
5784 	MSM6295Init(0, (16000000 / 8) / 165, 1);
5785 	MSM6295SetRoute(0, 1.00, BURN_SND_ROUTE_BOTH);
5786 
5787 	MSM6295Init(1, (16000000 / 8) / 165, 1);
5788 	MSM6295SetRoute(1, 1.00, BURN_SND_ROUTE_BOTH);
5789 
5790 	Brapboys = 1;
5791 
5792 	ShogwarrDoReset();
5793 
5794 	return 0;
5795 }
5796 
Kaneko16Exit()5797 static INT32 Kaneko16Exit()
5798 {
5799 	SekExit();
5800 	if (Kaneko16Eeprom) EEPROMExit();
5801 
5802 	GenericTilesExit();
5803 
5804 	BurnFree(Mem);
5805 	BurnFree(spritelist.first_sprite);
5806 
5807 	Kaneko16NumTiles = 0;
5808 	Kaneko16NumTiles2 = 0;
5809 	Kaneko16NumSprites = 0;
5810 	Kaneko16SpriteFlipX = 0;
5811 	Kaneko16SpriteFlipY = 0;
5812 	Kaneko16SpritesColourOffset = 0;
5813 	Kaneko16SpritesColourMask = 0;
5814 	Kaneko16LayersColourOffset = 0;
5815 	Kaneko16DisplayEnable = 0;
5816 	Kaneko168BppSprites = 0;
5817 	Kaneko16Eeprom = 0;
5818 	Kaneko16NVRam = NULL;
5819 	Kaneko16TilesXOffset = 0;
5820 	Kaneko16TilesYOffset = 0;
5821 	Kaneko16Bg15 = 0;
5822 	Kaneko16Bg15Reg = 0;
5823 	Kaneko16Bg15Select = 0;
5824 	Kaneko16RecalcBg15Palette = 0;
5825 	Kaneko16SpriteRamSize = 0;
5826 	Kaneko16SpriteXOffset = 0;
5827 	Kaneko16SoundLatch = 0;
5828 	MSM6295Bank0 = 0;
5829 	MSM6295Bank1 = 0;
5830 	memset(Kaneko16SpriteRegs, 0, 0x20 * sizeof(UINT16));
5831 	memset(Kaneko16Layer0Regs, 0, 0x10 * sizeof(UINT16));
5832 	memset(Kaneko16Layer1Regs, 0, 0x10 * sizeof(UINT16));
5833 	memset(ToyboxMCUCom, 0, 0x04 * sizeof(UINT16));
5834 
5835 	ToyboxMCURun = NULL;
5836 	Kaneko16ParseSprite = NULL;
5837 
5838 	Kaneko16PrioBitmap = NULL;
5839 	Kaneko16SpriteFbuffer = NULL;
5840 
5841 	Gtmr = 0;
5842 	Bloodwar = 0;
5843 	Bonkadv = 0;
5844 	Mgcrystl = 0;
5845 	Shogwarr = 0;
5846 	Brapboys = 0;
5847 
5848 	return 0;
5849 }
5850 
BerlwallExit()5851 static INT32 BerlwallExit()
5852 {
5853 	AY8910Exit(0);
5854 	AY8910Exit(1);
5855 	MSM6295Exit();
5856 
5857 	return Kaneko16Exit();
5858 }
5859 
BlazeonExit()5860 static INT32 BlazeonExit()
5861 {
5862 	ZetExit();
5863 	BurnYM2151Exit();
5864 
5865 	return Kaneko16Exit();
5866 }
5867 
WingforcExit()5868 static INT32 WingforcExit()
5869 {
5870 	ZetExit();
5871 	BurnYM2151Exit();
5872 	MSM6295Exit();
5873 
5874 	return Kaneko16Exit();
5875 }
5876 
GtmrMachineExit()5877 static INT32 GtmrMachineExit()
5878 {
5879 	MSM6295Exit();
5880 
5881 	return Kaneko16Exit();
5882 }
5883 
ExplbrkrExit()5884 static INT32 ExplbrkrExit()
5885 {
5886 	AY8910Exit(0);
5887 	AY8910Exit(1);
5888 	MSM6295Exit();
5889 
5890 	return Kaneko16Exit();
5891 }
5892 
5893 /*==============================================================================================
5894 Sprite Rendering
5895 ===============================================================================================*/
5896 
5897 #define USE_LATCHED_XY		1
5898 #define USE_LATCHED_CODE	2
5899 #define USE_LATCHED_COLOUR	4
5900 
Kaneko16ParseSpriteType0(INT32 i,struct tempsprite * s)5901 static INT32 Kaneko16ParseSpriteType0(INT32 i, struct tempsprite *s)
5902 {
5903 	INT32 Attr, xOffs, Offset;
5904 	UINT16 *SpriteRam = (UINT16*)Kaneko16SpriteRam;
5905 
5906 	Offset = (i * 8) >> 1;
5907 
5908 	if (Offset >= (Kaneko16SpriteRamSize >> 1)) return -1;
5909 
5910 	Attr = SpriteRam[Offset + 0];
5911 	s->code = SpriteRam[Offset + 1];
5912 	s->x = SpriteRam[Offset + 2];
5913 	s->y = SpriteRam[Offset + 3];
5914 
5915 	s->color = (Attr & 0xfc) >> 2;
5916 	s->priority = (Attr & 0x300) >> 8;
5917 	s->flipy = Attr & 0x001;
5918 	s->flipx = Attr & 0x002;
5919 
5920 	xOffs = (Attr & 0x1800) >> 11;
5921 	s->yoffs = Kaneko16SpriteRegs[0x08 + (xOffs * 2) + 1];
5922 	s->xoffs = Kaneko16SpriteRegs[0x08 + (xOffs * 2) + 0];
5923 
5924 	s->yoffs -= Kaneko16SpriteRegs[0x01];
5925 
5926 	return ((Attr & 0x2000) ? USE_LATCHED_XY : 0) | ((Attr & 0x4000) ? USE_LATCHED_COLOUR: 0) | ((Attr & 0x8000) ? USE_LATCHED_CODE : 0);
5927 }
5928 
Kaneko16ParseSpriteType1(INT32 i,struct tempsprite * s)5929 static INT32 Kaneko16ParseSpriteType1(INT32 i, struct tempsprite *s)
5930 {
5931 	INT32 Attr, xOffs, Offset;
5932 	UINT16 *SpriteRam = (UINT16*)Kaneko16SpriteRam;
5933 
5934 	Offset = (i * 8) >> 1;
5935 
5936 	if (Offset >= (Kaneko16SpriteRamSize >> 1)) return -1;
5937 
5938 	Attr = SpriteRam[Offset + 0];
5939 	s->code = SpriteRam[Offset + 1];
5940 	s->x = SpriteRam[Offset + 2];
5941 	s->y = SpriteRam[Offset + 3];
5942 
5943 	s->color = Attr & 0x3f;
5944 	s->priority = (Attr & 0xc0) >> 6;
5945 	s->flipy = Attr & 0x100;
5946 	s->flipx = Attr & 0x200;
5947 	s->code += (s->y & 1) << 16;
5948 
5949 	xOffs = (Attr & 0x1800) >> 11;
5950 	s->yoffs = Kaneko16SpriteRegs[0x08 + (xOffs * 2) + 1];
5951 	s->xoffs = Kaneko16SpriteRegs[0x08 + (xOffs * 2) + 0];
5952 
5953 	s->yoffs -= Kaneko16SpriteRegs[0x01];
5954 
5955 	return ((Attr & 0x2000) ? USE_LATCHED_XY : 0) | ((Attr & 0x4000) ? USE_LATCHED_COLOUR: 0) | ((Attr & 0x8000) ? USE_LATCHED_CODE : 0);
5956 }
5957 
Kaneko16ParseSpriteType2(INT32 i,struct tempsprite * s)5958 static INT32 Kaneko16ParseSpriteType2(INT32 i, struct tempsprite *s)
5959 {
5960 	INT32 Attr, xOffs, Offset;
5961 	UINT16 *SpriteRam = (UINT16*)Kaneko16SpriteRam;
5962 
5963 	Offset = (i * (16 >> 1)) + (8 >> 1);
5964 
5965 	if (Offset >= (Kaneko16SpriteRamSize >> 1)) return -1;
5966 
5967 	Attr = SpriteRam[Offset + 0];
5968 	s->code = SpriteRam[Offset + 1];
5969 	s->x = SpriteRam[Offset + 2];
5970 	s->y = SpriteRam[Offset + 3];
5971 
5972 	s->color = (Attr & 0xfc) >> 2;
5973 	s->priority = (Attr & 0x300) >> 8;
5974 	s->flipy = Attr & 0x001;
5975 	s->flipx = Attr & 0x002;
5976 
5977 	xOffs = (Attr & 0x1800) >> 11;
5978 	s->yoffs = Kaneko16SpriteRegs[0x08 + (xOffs * 2) + 1];
5979 	s->xoffs = Kaneko16SpriteRegs[0x08 + (xOffs * 2) + 0];
5980 
5981 	s->yoffs -= Kaneko16SpriteRegs[0x01];
5982 
5983 	return ((Attr & 0x2000) ? USE_LATCHED_XY : 0) | ((Attr & 0x4000) ? USE_LATCHED_COLOUR: 0) | ((Attr & 0x8000) ? USE_LATCHED_CODE : 0);
5984 }
5985 
Kaneko16RenderSprite(UINT32 Code,UINT32 Colour,INT32 FlipX,INT32 FlipY,INT32 sx,INT32 sy)5986 static void Kaneko16RenderSprite(UINT32 Code, UINT32 Colour, INT32 FlipX, INT32 FlipY, INT32 sx, INT32 sy)
5987 {
5988 	UINT8 *SourceBase = Kaneko16Sprites + ((Code % Kaneko16NumSprites) * 256);
5989 
5990 	INT32 SpriteScreenHeight = ((1 << 16) * 16 + 0x8000) >> 16;
5991 	INT32 SpriteScreenWidth = ((1 << 16) * 16 + 0x8000) >> 16;
5992 
5993 	if (Kaneko168BppSprites) {
5994 		Colour = 0x100 * (Colour % 0x40);
5995 	} else {
5996 		Colour = 0x10 * (Colour % 0x40);
5997 	}
5998 
5999 	if (SpriteScreenHeight && SpriteScreenWidth) {
6000 		INT32 dx = (16 << 16) / SpriteScreenWidth;
6001 		INT32 dy = (16 << 16) / SpriteScreenHeight;
6002 
6003 		INT32 ex = sx + SpriteScreenWidth;
6004 		INT32 ey = sy + SpriteScreenHeight;
6005 
6006 		INT32 xIndexBase;
6007 		INT32 yIndex;
6008 
6009 		if (FlipX) {
6010 			xIndexBase = (SpriteScreenWidth - 1) * dx;
6011 			dx = -dx;
6012 		} else {
6013 			xIndexBase = 0;
6014 		}
6015 
6016 		if (FlipY) {
6017 			yIndex = (SpriteScreenHeight - 1) * dy;
6018 			dy = -dy;
6019 		} else {
6020 			yIndex = 0;
6021 		}
6022 
6023 		if (sx < 0) {
6024 			INT32 Pixels = 0 - sx;
6025 			sx += Pixels;
6026 			xIndexBase += Pixels * dx;
6027 		}
6028 
6029 		if (sy < 0) {
6030 			INT32 Pixels = 0 - sy;
6031 			sy += Pixels;
6032 			yIndex += Pixels * dy;
6033 		}
6034 
6035 		if (ex > nScreenWidth + 1) {
6036 			INT32 Pixels = ex - nScreenWidth - 1;
6037 			ex -= Pixels;
6038 		}
6039 
6040 		if (ey > nScreenHeight + 1) {
6041 			INT32 Pixels = ey - nScreenHeight - 1;
6042 			ey -= Pixels;
6043 		}
6044 
6045 		if (ex > sx) {
6046 			INT32 y;
6047 
6048 			for (y = sy; y < ey; y++) {
6049 				UINT8 *Source = SourceBase + ((yIndex >> 16) * 16);
6050 				UINT16* pPixel = pTransDraw + (y * nScreenWidth);
6051 
6052 				if (y < 0 || y > (nScreenHeight - 1)) continue;
6053 
6054 				INT32 x, xIndex = xIndexBase;
6055 				for (x = sx; x <ex; x++) {
6056 					INT32 c = Source[xIndex >> 16];
6057 					if (c != 0) {
6058 						if (x >= 0 && x < nScreenWidth) pPixel[x] = (c | Colour | Kaneko16SpritesColourOffset) & Kaneko16SpritesColourMask;
6059 					}
6060 					xIndex += dx;
6061 				}
6062 
6063 				yIndex += dy;
6064 			}
6065 		}
6066 	}
6067 }
6068 
Kaneko16RenderSprites(INT32 PriorityDraw)6069 static void Kaneko16RenderSprites(INT32 PriorityDraw)
6070 {
6071 	struct tempsprite *s = spritelist.first_sprite;
6072 
6073 	INT32 i = 0;
6074 	INT32 x = 0;
6075 	INT32 y = 0;
6076 	INT32 Colour = 0;
6077 	INT32 Code = 0;
6078 	INT32 Priority = 0;
6079 	INT32 xOffs = 0;
6080 	INT32 yOffs = 0;
6081 	INT32 FlipX = 0;
6082 	INT32 FlipY = 0;
6083 
6084 	while (1) {
6085 		INT32 Flags;
6086 
6087 		Flags = Kaneko16ParseSprite(i, s);
6088 
6089 		if (Flags == -1) break;
6090 
6091 		if (Flags & USE_LATCHED_CODE) {
6092 			s->code = ++Code;
6093 		} else {
6094 			Code = s->code;
6095 		}
6096 
6097 		if (Flags & USE_LATCHED_COLOUR) {
6098 			s->color = Colour;
6099 			s->priority = Priority;
6100 			s->xoffs = xOffs;
6101 			s->yoffs = yOffs;
6102 			if (Kaneko16SpriteFlipType == 0) {
6103 				s->flipx = FlipX;
6104 				s->flipy = FlipY;
6105 			}
6106 		} else {
6107 			Colour = s->color;
6108 			Priority = s->priority;
6109 			xOffs = s->xoffs;
6110 			yOffs = s->yoffs;
6111 			if (Kaneko16SpriteFlipType == 0) {
6112 				FlipX = s->flipx;
6113 				FlipY = s->flipy;
6114 			}
6115 		}
6116 
6117 		if (Kaneko16SpriteFlipType == 1) {
6118 			FlipX = s->flipx;
6119 			FlipY = s->flipy;
6120 		}
6121 
6122 		if (Flags & USE_LATCHED_XY)
6123 		{
6124 			s->x += x;
6125 			s->y += y;
6126 		}
6127 
6128 		x = s->x;
6129 		y = s->y;
6130 
6131 		s->x = s->xoffs + s->x;
6132 		s->y = s->yoffs + s->y;
6133 
6134 		s->x += Kaneko16SpriteXOffset;
6135 
6136 		s->x = ((s->x & 0x7fc0) - (s->x & 0x8000)) / 0x40;
6137 		s->y = ((s->y & 0x7fc0) - (s->y & 0x8000)) / 0x40;
6138 
6139 		i++;
6140 		s++;
6141 	}
6142 
6143 	for (s = spritelist.first_sprite; s < spritelist.first_sprite + 0x400; s++) {
6144 		if (s->priority == PriorityDraw) Kaneko16RenderSprite(s->code, s->color, s->flipx, s->flipy, s->x, s->y);
6145 	}
6146 }
6147 
Kaneko16RenderSprite_PrioBuffer(UINT32 Code,UINT32 Colour,INT32 FlipX,INT32 FlipY,INT32 sx,INT32 sy,INT32 priority)6148 static void Kaneko16RenderSprite_PrioBuffer(UINT32 Code, UINT32 Colour, INT32 FlipX, INT32 FlipY, INT32 sx, INT32 sy, INT32 priority)
6149 {
6150 	UINT8 *SourceBase = Kaneko16Sprites + ((Code % Kaneko16NumSprites) * 256);
6151 
6152 	INT32 SpriteScreenHeight = ((1 << 16) * 16 + 0x8000) >> 16;
6153 	INT32 SpriteScreenWidth = ((1 << 16) * 16 + 0x8000) >> 16;
6154 
6155 	if (Kaneko168BppSprites) {
6156 		Colour = 0x100 * (Colour % 0x40);
6157 	} else {
6158 		Colour = 0x10 * (Colour % 0x40);
6159 	}
6160 
6161 	if (SpriteScreenHeight && SpriteScreenWidth) {
6162 		INT32 dx = (16 << 16) / SpriteScreenWidth;
6163 		INT32 dy = (16 << 16) / SpriteScreenHeight;
6164 
6165 		INT32 ex = sx + SpriteScreenWidth;
6166 		INT32 ey = sy + SpriteScreenHeight;
6167 
6168 		INT32 xIndexBase;
6169 		INT32 yIndex;
6170 
6171 		if (FlipX) {
6172 			xIndexBase = (SpriteScreenWidth - 1) * dx;
6173 			dx = -dx;
6174 		} else {
6175 			xIndexBase = 0;
6176 		}
6177 
6178 		if (FlipY) {
6179 			yIndex = (SpriteScreenHeight - 1) * dy;
6180 			dy = -dy;
6181 		} else {
6182 			yIndex = 0;
6183 		}
6184 
6185 		if (sx < 0) {
6186 			INT32 Pixels = 0 - sx;
6187 			sx += Pixels;
6188 			xIndexBase += Pixels * dx;
6189 		}
6190 
6191 		if (sy < 0) {
6192 			INT32 Pixels = 0 - sy;
6193 			sy += Pixels;
6194 			yIndex += Pixels * dy;
6195 		}
6196 
6197 		if (ex > nScreenWidth + 1) {
6198 			INT32 Pixels = ex - nScreenWidth - 1;
6199 			ex -= Pixels;
6200 		}
6201 
6202 		if (ey > nScreenHeight + 1) {
6203 			INT32 Pixels = ey - nScreenHeight - 1;
6204 			ey -= Pixels;
6205 		}
6206 
6207 		if (ex > sx) {
6208 			INT32 y;
6209 
6210 			for (y = sy; y < ey; y++) {
6211 				UINT8 *Source = SourceBase + ((yIndex >> 16) * 16);
6212 				UINT16* pPixel = pTransDraw + (y * nScreenWidth);
6213 
6214 				if ((~Kaneko16SpriteRegs[0] & 4) && Kaneko16SpriteFbuffer)
6215 					pPixel = Kaneko16SpriteFbuffer + (y * nScreenWidth); // mgcrystl overdraw mode
6216 
6217 				UINT8 *pri = Kaneko16PrioBitmap + (y * nScreenWidth);
6218 
6219 				if (y < 0 || y > (nScreenHeight - 1)) continue;
6220 
6221 				INT32 x, xIndex = xIndexBase;
6222 				for (x = sx; x <ex; x++) {
6223 					INT32 c = Source[xIndex >> 16];
6224 					if (c != 0) {
6225 						// If we haven't drawn a sprite here yet, do so.
6226 						if (!(pri[x] & 0x10))
6227 						{
6228 							if (pri[x] < priority) {
6229 								if (x >= 0 && x < nScreenWidth) pPixel[x] = (c | Colour | Kaneko16SpritesColourOffset) & Kaneko16SpritesColourMask;
6230 							}
6231 							// Mark that we (tried to) draw a sprite.
6232 							pri[x] |= 0x10;
6233 						}
6234 					}
6235 					xIndex += dx;
6236 				}
6237 
6238 				yIndex += dy;
6239 			}
6240 		}
6241 	}
6242 }
6243 
Kaneko16RenderSprites_PrioBuffer()6244 static void Kaneko16RenderSprites_PrioBuffer()
6245 {
6246 	struct tempsprite *s = spritelist.first_sprite;
6247 
6248 	INT32 i = 0;
6249 	INT32 x = 0;
6250 	INT32 y = 0;
6251 	INT32 Colour = 0;
6252 	INT32 Code = 0;
6253 	INT32 Priority = 0;
6254 	INT32 xOffs = 0;
6255 	INT32 yOffs = 0;
6256 	INT32 FlipX = 0;
6257 	INT32 FlipY = 0;
6258 
6259 	while (1) {
6260 		INT32 Flags;
6261 
6262 		Flags = Kaneko16ParseSprite(i, s);
6263 
6264 		if (Flags == -1) break;
6265 
6266 		if (Flags & USE_LATCHED_CODE) {
6267 			s->code = ++Code;
6268 		} else {
6269 			Code = s->code;
6270 		}
6271 
6272 		if (Flags & USE_LATCHED_COLOUR) {
6273 			s->color = Colour;
6274 			s->priority = Priority;
6275 			s->xoffs = xOffs;
6276 			s->yoffs = yOffs;
6277 			if (Kaneko16SpriteFlipType == 0) {
6278 				s->flipx = FlipX;
6279 				s->flipy = FlipY;
6280 			}
6281 		} else {
6282 			Colour = s->color;
6283 			Priority = s->priority;
6284 			xOffs = s->xoffs;
6285 			yOffs = s->yoffs;
6286 			if (Kaneko16SpriteFlipType == 0) {
6287 				FlipX = s->flipx;
6288 				FlipY = s->flipy;
6289 			}
6290 		}
6291 
6292 		if (Kaneko16SpriteFlipType == 1) {
6293 			FlipX = s->flipx;
6294 			FlipY = s->flipy;
6295 		}
6296 
6297 		if (Flags & USE_LATCHED_XY)
6298 		{
6299 			s->x += x;
6300 			s->y += y;
6301 		}
6302 
6303 		x = s->x;
6304 		y = s->y;
6305 
6306 		s->x = s->xoffs + s->x;
6307 		s->y = s->yoffs + s->y;
6308 
6309 		s->x += Kaneko16SpriteXOffset;
6310 
6311 		s->x = ((s->x & 0x7fc0) - (s->x & 0x8000)) / 0x40;
6312 		s->y = ((s->y & 0x7fc0) - (s->y & 0x8000)) / 0x40;
6313 
6314 		i++;
6315 		s++;
6316 	}
6317 
6318 	for (s--; s >= spritelist.first_sprite; s--) {
6319 		INT32 curr_pri = s->priority;
6320 
6321 		UINT32 primask = spritepriomask[curr_pri];
6322 		Kaneko16RenderSprite_PrioBuffer(s->code, s->color, s->flipx, s->flipy, s->x, s->y, primask);
6323 	}
6324 }
6325 
6326 #undef USE_LATCHED_XY
6327 #undef USE_LATCHED_CODE
6328 #undef USE_LATCHED_COLOUR
6329 
6330 /*==============================================================================================
6331 Tile Rendering
6332 ===============================================================================================*/
6333 
Kaneko16GetLayerFlipOffset(INT32 curroffs)6334 static INT32 Kaneko16GetLayerFlipOffset(INT32 curroffs)
6335 {
6336 	if (curroffs ==  0) return 15;
6337 	if (curroffs ==  1) return 14;
6338 	if (curroffs ==  2) return 13;
6339 	if (curroffs ==  3) return 12;
6340 	if (curroffs ==  4) return 11;
6341 	if (curroffs ==  5) return 10;
6342 	if (curroffs ==  6) return  9;
6343 	if (curroffs ==  7) return  8;
6344 	if (curroffs ==  8) return  7;
6345 	if (curroffs ==  9) return  6;
6346 	if (curroffs == 10) return  5;
6347 	if (curroffs == 11) return  4;
6348 	if (curroffs == 12) return  3;
6349 	if (curroffs == 13) return  2;
6350 	if (curroffs == 14) return  1;
6351 	if (curroffs == 15) return  0;
6352 
6353 	return 0;
6354 }
6355 
Kaneko16QueueTilesLayer(INT32 Layer)6356 static void Kaneko16QueueTilesLayer(INT32 Layer)
6357 {
6358 	INT32 x, y, mx, my, px, py, Code, Attr, Colour, Flip, Priority, LineScroll, TileIndex, pSrcXOffs, pSrcYOffs, xScroll, yScroll;
6359 	UINT8 pTileSrc;
6360 
6361 	LayerQueueSize[Layer] = 0;
6362 	TileIndex = 0;
6363 
6364 	UINT16 *VRAM = NULL;
6365 	UINT16 *VSCROLLRAM = NULL;
6366 	UINT16 *LAYERREGS = NULL;
6367 	UINT8 *TILEDATA = NULL;
6368 	INT32 xScrollReg = 0;
6369 	INT32 yScrollReg = 0;
6370 	INT32 xOffs = 0;
6371 	INT32 numTiles = 0;
6372 
6373 	switch (Layer) {
6374 		case 0: {
6375 			VRAM = (UINT16*)Kaneko16Video0Ram;
6376 			VSCROLLRAM = (UINT16*)Kaneko16VScrl0Ram;
6377 			LAYERREGS = Kaneko16Layer0Regs;
6378 			TILEDATA = Kaneko16Tiles;
6379 			xScrollReg = 2;
6380 			yScrollReg = 3;
6381 			xOffs = 0;
6382 			numTiles = Kaneko16NumTiles;
6383 			break;
6384 		}
6385 
6386 		case 1: {
6387 			VRAM = (UINT16*)Kaneko16Video1Ram;
6388 			VSCROLLRAM = (UINT16*)Kaneko16VScrl1Ram;
6389 			LAYERREGS = Kaneko16Layer0Regs;
6390 			TILEDATA = Kaneko16Tiles;
6391 			xScrollReg = 0;
6392 			yScrollReg = 1;
6393 			xOffs = 2;
6394 			numTiles = Kaneko16NumTiles;
6395 			break;
6396 		}
6397 
6398 		case 2: {
6399 			VRAM = (UINT16*)Kaneko16Video2Ram;
6400 			VSCROLLRAM = (UINT16*)Kaneko16VScrl2Ram;
6401 			LAYERREGS = Kaneko16Layer1Regs;
6402 			TILEDATA = Kaneko16Tiles2;
6403 			xScrollReg = 2;
6404 			yScrollReg = 3;
6405 			xOffs = 0;
6406 			numTiles = Kaneko16NumTiles2;
6407 			break;
6408 		}
6409 
6410 		case 3: {
6411 			VRAM = (UINT16*)Kaneko16Video3Ram;
6412 			VSCROLLRAM = (UINT16*)Kaneko16VScrl3Ram;
6413 			LAYERREGS = Kaneko16Layer1Regs;
6414 			TILEDATA = Kaneko16Tiles2;
6415 			xScrollReg = 0;
6416 			yScrollReg = 1;
6417 			xOffs = 2;
6418 			numTiles = Kaneko16NumTiles2;
6419 			break;
6420 		}
6421 	}
6422 
6423 	xScroll = LAYERREGS[xScrollReg];
6424 	xOffs = Kaneko16TilesXOffset + xOffs;
6425 	yScroll = ((LAYERREGS[yScrollReg] >> 6) & 0x1ff) - Kaneko16TilesYOffset;
6426 
6427 	mx = my = -1;
6428 	for (y = 0; y < 512; y++) {
6429 		if (!(y % 16)) my++;
6430 
6431 		LineScroll = VSCROLLRAM[y];
6432 		py = y - yScroll;
6433 
6434 		if (py < -30) py += 512;
6435 
6436 		for (x = 0; x < 512; x++) {
6437 			if (!(x % 16)) mx++;
6438 
6439 			if (py < 0 || py >= nScreenHeight) continue;
6440 
6441 			px = x - (((xScroll + LineScroll) >> 6) & 0x1ff) - xOffs;
6442 			if (px < -7) px += 512;
6443 
6444 			if (px < 0 || px >= nScreenWidth) continue;
6445 
6446 			TileIndex = ((my * 32) + mx) * 2;
6447 
6448 			if (numTiles & 0xfff)
6449 			{ // gtmr2
6450 				Code = VRAM[TileIndex + 1];
6451 				if (Code >= numTiles) continue;
6452 			} else {
6453 				Code = VRAM[TileIndex + 1] & (numTiles - 1);
6454 			}
6455 			Attr = VRAM[TileIndex + 0];
6456 			Priority = (Attr >> 8) & 7;
6457 			Colour = (Attr >> 2) & 0x3f;
6458 			Flip = Attr & 3;
6459 
6460 			pSrcXOffs = x % 16;
6461 			pSrcYOffs = y % 16;
6462 			if (Flip & 1) pSrcYOffs = Kaneko16GetLayerFlipOffset(pSrcYOffs);
6463 			if (Flip & 2) pSrcXOffs = Kaneko16GetLayerFlipOffset(pSrcXOffs);
6464 
6465 			pTileSrc = TILEDATA[(Code << 8) + (pSrcYOffs * 16) + pSrcXOffs];
6466 
6467 			if (pTileSrc != 0) {
6468 				LayerQueueXY[Layer][LayerQueueSize[Layer]] = (py << 9) | px;
6469 				LayerQueueColour[Layer][LayerQueueSize[Layer]] = (Colour << 4) | pTileSrc;
6470 				LayerQueuePriority[Layer][LayerQueueSize[Layer]] = Priority;
6471 				LayerQueueSize[Layer]++;
6472 			}
6473 		}
6474 		mx = -1;
6475 	}
6476 }
6477 
Kaneko16RenderLayerQueue(INT32 Layer,INT32 Priority)6478 static void Kaneko16RenderLayerQueue(INT32 Layer, INT32 Priority)
6479 {
6480 	for (INT32 i = 0; i < LayerQueueSize[Layer]; i++) {
6481 		if (LayerQueuePriority[Layer][i] == Priority) {
6482 			INT32 x = (LayerQueueXY[Layer][i] & 0x1ff);
6483 			INT32 y = (LayerQueueXY[Layer][i] >> 9);
6484 			UINT16* pPixel = pTransDraw + (y * nScreenWidth) + x;
6485 			pPixel[0] = LayerQueueColour[Layer][i] | Kaneko16LayersColourOffset;
6486 
6487 			if (Kaneko16PrioBitmap) {
6488 				UINT8 *pri = Kaneko16PrioBitmap + (y * nScreenWidth);
6489 				pri[x] = Priority;
6490 			}
6491 		}
6492 	}
6493 }
6494 
RenderTileCPMP(INT32 code,INT32 color,INT32 sx,INT32 sy,INT32 flipx,INT32 flipy,INT32 width,INT32 height,INT32 offset,INT32 priority,UINT8 * gfx)6495 static void RenderTileCPMP(INT32 code, INT32 color, INT32 sx, INT32 sy, INT32 flipx, INT32 flipy, INT32 width, INT32 height, INT32 offset, INT32 priority, UINT8 *gfx)
6496 {
6497 	UINT16 *dest = pTransDraw;
6498 
6499 	INT32 flip = 0;
6500 	if (flipy) flip |= (height - 1) * width;
6501 	if (flipx) flip |= width - 1;
6502 
6503 	gfx += code * width * height;
6504 
6505 	for (INT32 y = 0; y < height; y++, sy++) {
6506 		if (sy < 0 || sy >= nScreenHeight) continue;
6507 
6508 		for (INT32 x = 0; x < width; x++, sx++) {
6509 			if (sx < 0 || sx >= nScreenWidth) continue;
6510 
6511 			INT32 pxl = gfx[((y * width) + x) ^ flip];
6512 			if (!pxl) continue; // transparency
6513 
6514 			dest[sy * nScreenWidth + sx] = pxl | (color << 4) | offset;
6515 
6516 			if (Kaneko16PrioBitmap) {
6517 				UINT8 *pri = Kaneko16PrioBitmap + (sy * nScreenWidth);
6518 				pri[sx] = priority;
6519 			}
6520 		}
6521 		sx -= width;
6522 	}
6523 }
6524 
Kaneko16RenderTileLayer(INT32 Layer,INT32 PriorityDraw,INT32 xScroll)6525 static void Kaneko16RenderTileLayer(INT32 Layer, INT32 PriorityDraw, INT32 xScroll)
6526 {
6527 	INT32 mx, my, Code, Attr, Colour, Flip, Priority, x, y, TileIndex = 0;
6528 
6529 	UINT16 *VRAM = NULL;
6530 	UINT16 *LAYERREGS = NULL;
6531 	UINT8 *TILEDATA = NULL;
6532 	INT32 yScrollReg = 0;
6533 	INT32 xOffs = 0;
6534 	INT32 numTiles = 0;
6535 
6536 	switch (Layer) {
6537 		case 0: {
6538 			VRAM = (UINT16*)Kaneko16Video0Ram;
6539 			LAYERREGS = Kaneko16Layer0Regs;
6540 			TILEDATA = Kaneko16Tiles;
6541 			yScrollReg = 3;
6542 			xOffs = 0;
6543 			numTiles = Kaneko16NumTiles;
6544 			break;
6545 		}
6546 
6547 		case 1: {
6548 			VRAM = (UINT16*)Kaneko16Video1Ram;
6549 			LAYERREGS = Kaneko16Layer0Regs;
6550 			TILEDATA = Kaneko16Tiles;
6551 			yScrollReg = 1;
6552 			xOffs = 2;
6553 			numTiles = Kaneko16NumTiles;
6554 			break;
6555 		}
6556 
6557 		case 2: {
6558 			VRAM = (UINT16*)Kaneko16Video2Ram;
6559 			LAYERREGS = Kaneko16Layer1Regs;
6560 			TILEDATA = Kaneko16Tiles2;
6561 			yScrollReg = 3;
6562 			xOffs = 0;
6563 			numTiles = Kaneko16NumTiles2;
6564 			break;
6565 		}
6566 
6567 		case 3: {
6568 			VRAM = (UINT16*)Kaneko16Video3Ram;
6569 			LAYERREGS = Kaneko16Layer1Regs;
6570 			TILEDATA = Kaneko16Tiles2;
6571 			yScrollReg = 1;
6572 			xOffs = 2;
6573 			numTiles = Kaneko16NumTiles2;
6574 			break;
6575 		}
6576 	}
6577 
6578 	for (my = 0; my < 32; my++) {
6579 		for (mx = 0; mx < 32; mx++) {
6580 
6581 			if (numTiles & 0xfff)
6582 			{ // gtmr2
6583 				Code = VRAM[TileIndex + 1];
6584 				if (Code >= numTiles) continue;
6585 			} else {
6586 				Code = VRAM[TileIndex + 1] & (numTiles - 1);
6587 			}
6588 
6589 			Attr = VRAM[TileIndex + 0];
6590 			Colour = (Attr >> 2) & 0x3f;
6591 			Flip = Attr & 3;
6592 			Priority = (Attr >> 8) & 7;
6593 
6594 			if (Priority == PriorityDraw) {
6595 				x = 16 * mx;
6596 				y = 16 * my;
6597 
6598 				x -= (xScroll >> 6) & 0x1ff;
6599 				y -= (LAYERREGS[yScrollReg] >> 6) & 0x1ff;
6600 
6601 				if (x < -7) x += 512;
6602 				if (y < -30) y += 512;
6603 
6604 				x -= Kaneko16TilesXOffset + xOffs;
6605 				y += Kaneko16TilesYOffset;
6606 
6607 				if (Flip == 0) RenderTileCPMP(Code, Colour, x, y, 0, 0, 16, 16, Kaneko16LayersColourOffset, Priority, TILEDATA);
6608 				if (Flip == 1) RenderTileCPMP(Code, Colour, x, y, 0, 1, 16, 16, Kaneko16LayersColourOffset, Priority, TILEDATA);
6609 				if (Flip == 2) RenderTileCPMP(Code, Colour, x, y, 1, 0, 16, 16, Kaneko16LayersColourOffset, Priority, TILEDATA);
6610 				if (Flip == 3) RenderTileCPMP(Code, Colour, x, y, 1, 1, 16, 16, Kaneko16LayersColourOffset, Priority, TILEDATA);
6611 #if 0
6612 				if (x > 0 && x < (nScreenWidth - 16) && y > 0 && y < (nScreenHeight - 16)) {
6613 					if (Flip == 0) Render16x16Tile_Mask(pTransDraw, Code, x, y, Colour, 4, 0, Kaneko16LayersColourOffset, TILEDATA);
6614 					if (Flip == 1) Render16x16Tile_Mask_FlipY(pTransDraw, Code, x, y, Colour, 4, 0, Kaneko16LayersColourOffset, TILEDATA);
6615 					if (Flip == 2) Render16x16Tile_Mask_FlipX(pTransDraw, Code, x, y, Colour, 4, 0, Kaneko16LayersColourOffset, TILEDATA);
6616 					if (Flip == 3) Render16x16Tile_Mask_FlipXY(pTransDraw, Code, x, y, Colour, 4, 0, Kaneko16LayersColourOffset, TILEDATA);
6617 				} else {
6618 					if (Flip == 0) Render16x16Tile_Mask_Clip(pTransDraw, Code, x, y, Colour, 4, 0, Kaneko16LayersColourOffset, TILEDATA);
6619 					if (Flip == 1) Render16x16Tile_Mask_FlipY_Clip(pTransDraw, Code, x, y, Colour, 4, 0, Kaneko16LayersColourOffset, TILEDATA);
6620 					if (Flip == 2) Render16x16Tile_Mask_FlipX_Clip(pTransDraw, Code, x, y, Colour, 4, 0, Kaneko16LayersColourOffset, TILEDATA);
6621 					if (Flip == 3) Render16x16Tile_Mask_FlipXY_Clip(pTransDraw, Code, x, y, Colour, 4, 0, Kaneko16LayersColourOffset, TILEDATA);
6622 				}
6623 #endif
6624 			}
6625 
6626 			TileIndex += 2;
6627 		}
6628 	}
6629 }
6630 
6631 /*==============================================================================================
6632 Background Bitmap Rendering
6633 ===============================================================================================*/
6634 
Kaneko16RenderBg15Bitmap()6635 static void Kaneko16RenderBg15Bitmap()
6636 {
6637 	INT32 Select = Kaneko16Bg15Select;
6638 	INT32 Flip = Select & 0x20;
6639 	INT32 x, y;
6640 
6641 	if (Flip) Select ^= 0x1f;
6642 	Select &= 0x1f;
6643 
6644 	for (y = 0; y < nScreenHeight; y++) {
6645 		UINT16 *pPixel = pTransDraw + (y * nScreenWidth);
6646 		UINT16 *data = Kaneko16Bg15Data + (Select * 256 * 256) + ((y + 16) * 256);
6647 
6648 		for (x = 0; x < nScreenWidth; x++) {
6649 			pPixel[x] = data[x];
6650 		}
6651 	}
6652 }
6653 
6654 /*==============================================================================================
6655 Palette Handling
6656 ===============================================================================================*/
6657 
pal5bit(UINT8 bits)6658 static inline UINT8 pal5bit(UINT8 bits)
6659 {
6660 	bits &= 0x1f;
6661 	return (bits << 3) | (bits >> 2);
6662 }
6663 
CalcCol(UINT16 nColour)6664 inline static UINT32 CalcCol(UINT16 nColour)
6665 {
6666 	INT32 r, g, b;
6667 
6668 	r = pal5bit(nColour >>  5);
6669 	g = pal5bit(nColour >> 10);
6670 	b = pal5bit(nColour >>  0);
6671 
6672 	return BurnHighCol(r, g, b, 0);
6673 }
6674 
Kaneko16CalcPalette(INT32 num)6675 INT32 Kaneko16CalcPalette(INT32 num)
6676 {
6677 	INT32 i;
6678 	UINT16* ps;
6679 	UINT32* pd;
6680 
6681 	for (i = 0, ps = (UINT16*)Kaneko16PaletteRam, pd = Kaneko16Palette; i < num; i++, ps++, pd++) {
6682 		*pd = CalcCol(*ps);
6683 	}
6684 
6685 	return 0;
6686 }
6687 
6688 /*==============================================================================================
6689 Graphics Rendering
6690 ===============================================================================================*/
6691 
6692 // If the VScroll RAM is the same all the way through then just apply it as an xScroll value - much faster then doing line scroll on every line
6693 #define HANDLE_VSCROLL(_N_) \
6694 	if (Layer##_N_##Enabled) { \
6695 		INT32 vScrollFast = 1; \
6696 		UINT16 *VSCROLLRAM = (UINT16*)Kaneko16VScrl##_N_##Ram; \
6697 		INT32 LineScroll = VSCROLLRAM[0]; \
6698 		for (i = 0; i < 0x200; i++) { \
6699 			if (VSCROLLRAM[i] != LineScroll) { \
6700 				vScrollFast = 0; \
6701 				break; \
6702 			} \
6703 		} \
6704 		if (!vScrollFast) { \
6705 			vScroll##_N_##Enabled = 1; \
6706 			Kaneko16QueueTilesLayer(_N_); \
6707 		} else { \
6708 			vScroll##_N_##Enabled = 0; \
6709 			xScroll##_N_ += LineScroll; \
6710 		} \
6711 	} \
6712 \
6713 
BerlwallFrameRender()6714 static INT32 BerlwallFrameRender()
6715 {
6716 	INT32 i;
6717 	INT32 Layer0Enabled = 0;
6718 	INT32 Layer1Enabled = 0;
6719 
6720 	INT32 vScroll0Enabled = 0;
6721 	INT32 vScroll1Enabled = 0;
6722 
6723 	INT32 xScroll0 = Kaneko16Layer0Regs[2];
6724 	INT32 xScroll1 = Kaneko16Layer0Regs[0];
6725 
6726 	if (~Kaneko16Layer0Regs[4] & 0x1000) Layer0Enabled = 1;
6727 	if (~Kaneko16Layer0Regs[4] & 0x0010) Layer1Enabled = 1;
6728 
6729 	BurnTransferClear();
6730 	Kaneko16CalcPalette(0x0800);
6731 
6732 
6733 	if (Kaneko16RecalcBg15Palette) {
6734 		INT32 nBrightness = (Kaneko16Brightness * 100) / 255;
6735 
6736 		if (Kaneko16Dip[2] & 1) nBrightness = 100; // disable brightness
6737 
6738 		if (nBrightness == 0) {
6739 			for (i = 0; i < 32768; i++) {
6740 				Kaneko16Palette[i + 2048] = 0;
6741 			}
6742 		} else {
6743 		 	for (i = 0; i < 32768; i++) {
6744 				INT32 r = (pal5bit(i >> 5) * nBrightness) / 100;
6745 				INT32 g = (pal5bit(i >> 10) * nBrightness) / 100;
6746 				INT32 b = (pal5bit(i >> 0) * nBrightness) / 100;
6747 
6748 				Kaneko16Palette[i + 2048] = BurnHighCol(r, g, b, 0);
6749 			}
6750 		}
6751 
6752 		Kaneko16RecalcBg15Palette = 0;
6753 	}
6754 
6755 	if (Kaneko16Layer0Regs[4] & 0x800) {
6756 		HANDLE_VSCROLL(0)
6757 	}
6758 
6759 	if (Kaneko16Layer0Regs[4] & 0x008) {
6760 		HANDLE_VSCROLL(1)
6761 	}
6762 
6763 	Kaneko16RenderBg15Bitmap();
6764 
6765 	for (i = 0; i < 8; i++) {
6766 		if (Layer0Enabled) { if (vScroll0Enabled) { Kaneko16RenderLayerQueue(0, i); } else { Kaneko16RenderTileLayer(0, i, xScroll0); }}
6767 		if (Layer1Enabled) { if (vScroll1Enabled) { Kaneko16RenderLayerQueue(1, i); } else { Kaneko16RenderTileLayer(1, i, xScroll1); }}
6768 
6769 		if (i == 0) Kaneko16RenderSprites(0);
6770 		if (i == 1) Kaneko16RenderSprites(1);
6771 		if (i == 2) Kaneko16RenderSprites(2);
6772 		if (i == 7) Kaneko16RenderSprites(3);
6773 	}
6774 
6775 	BurnTransferCopy(Kaneko16Palette);
6776 
6777 	return 0;
6778 }
6779 
BlazeonFrameRender()6780 static INT32 BlazeonFrameRender() // and Wingforc
6781 {
6782 	INT32 i;
6783 	INT32 Layer0Enabled = 0;
6784 	INT32 Layer1Enabled = 0;
6785 
6786 	INT32 vScroll0Enabled = 0;
6787 	INT32 vScroll1Enabled = 0;
6788 
6789 	INT32 xScroll0 = Kaneko16Layer0Regs[2];
6790 	INT32 xScroll1 = Kaneko16Layer0Regs[0];
6791 
6792 	if (~Kaneko16Layer0Regs[4] & 0x1000) Layer0Enabled = 1;
6793 	if (~Kaneko16Layer0Regs[4] & 0x0010) Layer1Enabled = 1;
6794 
6795 	BurnTransferClear();
6796 	Kaneko16CalcPalette(0x0800);
6797 	memset(Kaneko16PrioBitmap, 0, 320 * 232);
6798 
6799 	if (Kaneko16Layer0Regs[4] & 0x800) {
6800 		HANDLE_VSCROLL(0)
6801 	}
6802 
6803 	if (Kaneko16Layer0Regs[4] & 0x008) {
6804 		HANDLE_VSCROLL(1)
6805 	}
6806 
6807 	for (i = 0; i < 8; i++) {
6808 		if (Layer0Enabled) { if (vScroll0Enabled) { Kaneko16RenderLayerQueue(0, i); } else { Kaneko16RenderTileLayer(0, i, xScroll0); }}
6809 		if (Layer1Enabled) { if (vScroll1Enabled) { Kaneko16RenderLayerQueue(1, i); } else { Kaneko16RenderTileLayer(1, i, xScroll1); }}
6810 	}
6811 
6812 	if (nSpriteEnable & 1) Kaneko16RenderSprites_PrioBuffer();
6813 
6814 	BurnTransferCopy(Kaneko16Palette);
6815 
6816 	return 0;
6817 }
6818 
ShogwarrFrameRender()6819 static INT32 ShogwarrFrameRender()
6820 {
6821 	INT32 i;
6822 	INT32 Layer0Enabled = 0;
6823 	INT32 Layer1Enabled = 0;
6824 
6825 	INT32 vScroll0Enabled = 0;
6826 	INT32 vScroll1Enabled = 0;
6827 
6828 	INT32 xScroll0 = Kaneko16Layer0Regs[2];
6829 	INT32 xScroll1 = Kaneko16Layer0Regs[0];
6830 
6831 	if (~Kaneko16Layer0Regs[4] & 0x1000) Layer0Enabled = 1;
6832 	if (~Kaneko16Layer0Regs[4] & 0x0010) Layer1Enabled = 1;
6833 
6834 	BurnTransferClear();
6835 	Kaneko16CalcPalette(0x0800);
6836 
6837 	if (Kaneko16Layer0Regs[4] & 0x800) {
6838 		HANDLE_VSCROLL(0)
6839 	}
6840 
6841 	if (Kaneko16Layer0Regs[4] & 0x008) {
6842 		HANDLE_VSCROLL(1)
6843 	}
6844 
6845 	for (i = 0; i < 8; i++) {
6846 		if (nBurnLayer & 1) if (Layer0Enabled) { if (vScroll0Enabled) { Kaneko16RenderLayerQueue(0, i); } else { Kaneko16RenderTileLayer(0, i, xScroll0); }}
6847 		if (nBurnLayer & 2) if (Layer1Enabled) { if (vScroll1Enabled) { Kaneko16RenderLayerQueue(1, i); } else { Kaneko16RenderTileLayer(1, i, xScroll1); }}
6848 
6849 		if (nSpriteEnable & 1) if (i == 0) Kaneko16RenderSprites(0);
6850 		if (nSpriteEnable & 2) if (i == 2) Kaneko16RenderSprites(1);
6851 		if (nSpriteEnable & 4) if (i == 4) Kaneko16RenderSprites(2);
6852 		if (nSpriteEnable & 8) if (i == 6) Kaneko16RenderSprites(3);
6853 	}
6854 
6855 	BurnTransferCopy(Kaneko16Palette);
6856 
6857 	return 0;
6858 }
6859 
BloodwarFrameRender()6860 static INT32 BloodwarFrameRender()
6861 {
6862 	INT32 i;
6863 	INT32 Layer0Enabled = 0;
6864 	INT32 Layer1Enabled = 0;
6865 	INT32 Layer2Enabled = 0;
6866 	INT32 Layer3Enabled = 0;
6867 
6868 	INT32 vScroll0Enabled = 0;
6869 	INT32 vScroll1Enabled = 0;
6870 	INT32 vScroll2Enabled = 0;
6871 	INT32 vScroll3Enabled = 0;
6872 
6873 	INT32 xScroll0 = Kaneko16Layer0Regs[2];
6874 	INT32 xScroll1 = Kaneko16Layer0Regs[0];
6875 	INT32 xScroll2 = Kaneko16Layer1Regs[2];
6876 	INT32 xScroll3 = Kaneko16Layer1Regs[0];
6877 
6878 	if (~Kaneko16Layer0Regs[4] & 0x1000) Layer0Enabled = 1;
6879 	if (~Kaneko16Layer0Regs[4] & 0x0010) Layer1Enabled = 1;
6880 	if (~Kaneko16Layer1Regs[4] & 0x1000) Layer2Enabled = 1;
6881 	if (~Kaneko16Layer1Regs[4] & 0x0010) Layer3Enabled = 1;
6882 
6883 	BurnTransferClear();
6884 	Kaneko16CalcPalette(0x10000);
6885 
6886 	if (!Kaneko16DisplayEnable) return 0;
6887 
6888 	if (Kaneko16Layer0Regs[4] & 0x800) {
6889 		HANDLE_VSCROLL(0)
6890 	}
6891 
6892 	if (Kaneko16Layer0Regs[4] & 0x008) {
6893 		HANDLE_VSCROLL(1)
6894 	}
6895 
6896 	if (Kaneko16Layer1Regs[4] & 0x800) {
6897 		HANDLE_VSCROLL(2)
6898 	}
6899 
6900 	if (Kaneko16Layer1Regs[4] & 0x008) {
6901 		HANDLE_VSCROLL(3)
6902 	}
6903 
6904 	for (i = 0; i < 8; i++) {
6905 		if (nBurnLayer & 1) if (Layer0Enabled) { if (vScroll0Enabled) { Kaneko16RenderLayerQueue(0, i); } else { Kaneko16RenderTileLayer(0, i, xScroll0); }}
6906 		if (nBurnLayer & 2) if (Layer1Enabled) { if (vScroll1Enabled) { Kaneko16RenderLayerQueue(1, i); } else { Kaneko16RenderTileLayer(1, i, xScroll1); }}
6907 		if (nBurnLayer & 4) if (Layer2Enabled) { if (vScroll2Enabled) { Kaneko16RenderLayerQueue(2, i); } else { Kaneko16RenderTileLayer(2, i, xScroll2); }}
6908 		if (nBurnLayer & 8) if (Layer3Enabled) { if (vScroll3Enabled) { Kaneko16RenderLayerQueue(3, i); } else { Kaneko16RenderTileLayer(3, i, xScroll3); }}
6909 
6910 		if (nSpriteEnable & 1) if (i == 1) Kaneko16RenderSprites(0);
6911 		if (nSpriteEnable & 2) if (i == 2) Kaneko16RenderSprites(1);
6912 		if (nSpriteEnable & 4) if (i == 4) Kaneko16RenderSprites(2);
6913 		if (nSpriteEnable & 8) if (i == 6) Kaneko16RenderSprites(3);
6914 	}
6915 
6916 	BurnTransferCopy(Kaneko16Palette);
6917 
6918 	return 0;
6919 }
6920 
ExplbrkrFrameRender()6921 static INT32 ExplbrkrFrameRender()
6922 {
6923 	INT32 i;
6924 	INT32 Layer0Enabled = 0;
6925 	INT32 Layer1Enabled = 0;
6926 	INT32 Layer2Enabled = 0;
6927 	INT32 Layer3Enabled = 0;
6928 
6929 	INT32 vScroll0Enabled = 0;
6930 	INT32 vScroll1Enabled = 0;
6931 	INT32 vScroll2Enabled = 0;
6932 	INT32 vScroll3Enabled = 0;
6933 
6934 	INT32 xScroll0 = Kaneko16Layer0Regs[2];
6935 	INT32 xScroll1 = Kaneko16Layer0Regs[0];
6936 	INT32 xScroll2 = Kaneko16Layer1Regs[2];
6937 	INT32 xScroll3 = Kaneko16Layer1Regs[0];
6938 
6939 	if (~Kaneko16Layer0Regs[4] & 0x1000) Layer0Enabled = 1;
6940 	if (~Kaneko16Layer0Regs[4] & 0x0010) Layer1Enabled = 1;
6941 	if (~Kaneko16Layer1Regs[4] & 0x1000) Layer2Enabled = 1;
6942 	if (~Kaneko16Layer1Regs[4] & 0x0010) Layer3Enabled = 1;
6943 
6944 	BurnTransferClear();
6945 	Kaneko16CalcPalette(0x1000);
6946 
6947 	if (Kaneko16Layer0Regs[4] & 0x800) {
6948 		HANDLE_VSCROLL(0)
6949 	}
6950 
6951 	if (Kaneko16Layer0Regs[4] & 0x008) {
6952 		HANDLE_VSCROLL(1)
6953 	}
6954 
6955 	if (Kaneko16Layer1Regs[4] & 0x800) {
6956 		HANDLE_VSCROLL(2)
6957 	}
6958 
6959 	if (Kaneko16Layer1Regs[4] & 0x008) {
6960 		HANDLE_VSCROLL(3)
6961 	}
6962 
6963 	for (i = 0; i < 8; i++) {
6964 		if (Layer0Enabled) { if (vScroll0Enabled) { Kaneko16RenderLayerQueue(0, i); } else { Kaneko16RenderTileLayer(0, i, xScroll0); }}
6965 		if (Layer1Enabled) { if (vScroll1Enabled) { Kaneko16RenderLayerQueue(1, i); } else { Kaneko16RenderTileLayer(1, i, xScroll1); }}
6966 		if (Layer2Enabled) { if (vScroll2Enabled) { Kaneko16RenderLayerQueue(2, i); } else { Kaneko16RenderTileLayer(2, i, xScroll2); }}
6967 		if (Layer3Enabled) { if (vScroll3Enabled) { Kaneko16RenderLayerQueue(3, i); } else { Kaneko16RenderTileLayer(3, i, xScroll3); }}
6968 	}
6969 
6970 	Kaneko16RenderSprites(0);
6971 	Kaneko16RenderSprites(1);
6972 	Kaneko16RenderSprites(2);
6973 	Kaneko16RenderSprites(3);
6974 
6975 	BurnTransferCopy(Kaneko16Palette);
6976 
6977 	return 0;
6978 }
6979 
GtmrFrameRender()6980 static INT32 GtmrFrameRender()
6981 {
6982 	INT32 i;
6983 	INT32 Layer0Enabled = 0;
6984 	INT32 Layer1Enabled = 0;
6985 	INT32 Layer2Enabled = 0;
6986 	INT32 Layer3Enabled = 0;
6987 
6988 	INT32 vScroll0Enabled = 0;
6989 	INT32 vScroll1Enabled = 0;
6990 	INT32 vScroll2Enabled = 0;
6991 	INT32 vScroll3Enabled = 0;
6992 
6993 	INT32 xScroll0 = Kaneko16Layer0Regs[2];
6994 	INT32 xScroll1 = Kaneko16Layer0Regs[0];
6995 	INT32 xScroll2 = Kaneko16Layer1Regs[2];
6996 	INT32 xScroll3 = Kaneko16Layer1Regs[0];
6997 
6998 	if (~Kaneko16Layer0Regs[4] & 0x1000) Layer0Enabled = 1;
6999 	if (~Kaneko16Layer0Regs[4] & 0x0010) Layer1Enabled = 1;
7000 	if (~Kaneko16Layer1Regs[4] & 0x1000) Layer2Enabled = 1;
7001 	if (~Kaneko16Layer1Regs[4] & 0x0010) Layer3Enabled = 1;
7002 
7003 	BurnTransferClear();
7004 	Kaneko16CalcPalette(0x10000);
7005 	memset(Kaneko16PrioBitmap, 0, 320 * 240);
7006 
7007 	if (!Kaneko16DisplayEnable) return 0;
7008 
7009 	if (Kaneko16Layer0Regs[4] & 0x800) {
7010 		HANDLE_VSCROLL(0)
7011 	}
7012 
7013 	if (Kaneko16Layer0Regs[4] & 0x008) {
7014 		HANDLE_VSCROLL(1)
7015 	}
7016 
7017 	if (Kaneko16Layer1Regs[4] & 0x800) {
7018 		HANDLE_VSCROLL(2)
7019 	}
7020 
7021 	if (Kaneko16Layer1Regs[4] & 0x008) {
7022 		HANDLE_VSCROLL(3)
7023 	}
7024 
7025 	for (i = 0; i < 8; i++) {
7026 		if (Layer0Enabled) { if (vScroll0Enabled) { Kaneko16RenderLayerQueue(0, i); } else { Kaneko16RenderTileLayer(0, i, xScroll0); }}
7027 		if (Layer1Enabled) { if (vScroll1Enabled) { Kaneko16RenderLayerQueue(1, i); } else { Kaneko16RenderTileLayer(1, i, xScroll1); }}
7028 		if (Layer2Enabled) { if (vScroll2Enabled) { Kaneko16RenderLayerQueue(2, i); } else { Kaneko16RenderTileLayer(2, i, xScroll2); }}
7029 		if (Layer3Enabled) { if (vScroll3Enabled) { Kaneko16RenderLayerQueue(3, i); } else { Kaneko16RenderTileLayer(3, i, xScroll3); }}
7030 	}
7031 
7032 	if (nSpriteEnable & 1) Kaneko16RenderSprites_PrioBuffer();
7033 
7034 	BurnTransferCopy(Kaneko16Palette);
7035 
7036 	return 0;
7037 }
7038 
MgcrystlFrameRender()7039 static INT32 MgcrystlFrameRender()
7040 {
7041 	INT32 i;
7042 	INT32 Layer0Enabled = 0;
7043 	INT32 Layer1Enabled = 0;
7044 	INT32 Layer2Enabled = 0;
7045 	INT32 Layer3Enabled = 0;
7046 
7047 	INT32 vScroll0Enabled = 0;
7048 	INT32 vScroll1Enabled = 0;
7049 	INT32 vScroll2Enabled = 0;
7050 	INT32 vScroll3Enabled = 0;
7051 
7052 	INT32 xScroll0 = Kaneko16Layer0Regs[2];
7053 	INT32 xScroll1 = Kaneko16Layer0Regs[0];
7054 	INT32 xScroll2 = Kaneko16Layer1Regs[2];
7055 	INT32 xScroll3 = Kaneko16Layer1Regs[0];
7056 
7057 	if (~Kaneko16Layer0Regs[4] & 0x1000) Layer0Enabled = 1;
7058 	if (~Kaneko16Layer0Regs[4] & 0x0010) Layer1Enabled = 1;
7059 	if (~Kaneko16Layer1Regs[4] & 0x1000) Layer2Enabled = 1;
7060 	if (~Kaneko16Layer1Regs[4] & 0x0010) Layer3Enabled = 1;
7061 
7062 	BurnTransferClear();
7063 	Kaneko16CalcPalette(0x1000);
7064 	memset(Kaneko16PrioBitmap, 0, 320 * 240);
7065 
7066 	if (Kaneko16Layer0Regs[4] & 0x800) {
7067 		HANDLE_VSCROLL(0)
7068 	}
7069 
7070 	if (Kaneko16Layer0Regs[4] & 0x008) {
7071 		HANDLE_VSCROLL(1)
7072 	}
7073 
7074 	UINT8 *tmp = Kaneko16PrioBitmap; // Don't write priority for 2nd tilemap chip (layers 2,3)
7075 	Kaneko16PrioBitmap = NULL;
7076 
7077 	if (Kaneko16Layer1Regs[4] & 0x800) {
7078 		HANDLE_VSCROLL(2)
7079 	}
7080 
7081 	if (Kaneko16Layer1Regs[4] & 0x008) {
7082 		HANDLE_VSCROLL(3)
7083 	}
7084 
7085 	Kaneko16PrioBitmap = tmp; // Restore priority map
7086 
7087 	for (i = 0; i < 8; i++) {
7088 		if (Layer0Enabled && nBurnLayer & 1) { if (vScroll0Enabled) { Kaneko16RenderLayerQueue(0, i); } else { Kaneko16RenderTileLayer(0, i, xScroll0); }}
7089 		if (Layer1Enabled && nBurnLayer & 2) { if (vScroll1Enabled) { Kaneko16RenderLayerQueue(1, i); } else { Kaneko16RenderTileLayer(1, i, xScroll1); }}
7090 
7091 		Kaneko16PrioBitmap = NULL; // Don't write priority for 2nd tilemap chip (layers 2,3)
7092 		if (Layer2Enabled && nBurnLayer & 4) { if (vScroll2Enabled) { Kaneko16RenderLayerQueue(2, i); } else { Kaneko16RenderTileLayer(2, i, xScroll2); }}
7093 		if (Layer3Enabled && nBurnLayer & 8) { if (vScroll3Enabled) { Kaneko16RenderLayerQueue(3, i); } else { Kaneko16RenderTileLayer(3, i, xScroll3); }}
7094 		Kaneko16PrioBitmap = tmp; // Restore priority map
7095 	}
7096 
7097 	if (nSpriteEnable & 1) {
7098 		if (~Kaneko16SpriteRegs[0] & 4) { // sprite framebuffer/overdraw mode
7099 			Kaneko16RenderSprites_PrioBuffer();
7100 			for (INT32 y = 0; y < nScreenHeight; y++) {
7101 				UINT16 *pPixel = (UINT16*)Kaneko16SpriteFbuffer + (y * nScreenWidth);
7102 				UINT16 *pDest = (UINT16*)pTransDraw + (y * nScreenWidth);
7103 
7104 				for (INT32 x = 0; x < nScreenWidth; x++) {
7105 					if (pPixel[x])
7106 						pDest[x] = pPixel[x];
7107 				}
7108 			}
7109 		} else {
7110 			memset(Kaneko16SpriteFbuffer, 0, 320 * 240 * sizeof(UINT16));
7111 			Kaneko16RenderSprites_PrioBuffer();
7112 		}
7113 	}
7114 
7115 	BurnTransferCopy(Kaneko16Palette);
7116 
7117 	return 0;
7118 }
7119 
7120 /*==============================================================================================
7121 Frame functions
7122 ===============================================================================================*/
7123 
ExplbrkrFrame()7124 static INT32 ExplbrkrFrame()
7125 {
7126 	INT32 nInterleave = 256;
7127 	nSoundBufferPos = 0;
7128 
7129 	if (Kaneko16Reset) ExplbrkrDoReset();
7130 
7131 	Kaneko16MakeInputs();
7132 
7133 	nCyclesTotal[0] = 12000000 / 60;
7134 	nCyclesDone[0] = 0;
7135 
7136 	for (INT32 i = 0; i < nInterleave; i++) {
7137 		INT32 nCurrentCPU, nNext;
7138 
7139 		nCurrentCPU = 0;
7140 		SekOpen(nCurrentCPU);
7141 		nNext = (i + 1) * nCyclesTotal[nCurrentCPU] / nInterleave;
7142 		nCyclesSegment = nNext - nCyclesDone[nCurrentCPU];
7143 		nCyclesDone[nCurrentCPU] += SekRun(nCyclesSegment);
7144 		if (i == 144) SekSetIRQLine(3, CPU_IRQSTATUS_AUTO);
7145 		if (i == 64) SekSetIRQLine(4, CPU_IRQSTATUS_AUTO);
7146 		if (i == 224) SekSetIRQLine(5, CPU_IRQSTATUS_AUTO);
7147 		SekClose();
7148 
7149 		// Render Sound Segment
7150 		if (pBurnSoundOut) {
7151 			INT32 nSegmentLength = nBurnSoundLen / nInterleave;
7152 			INT16* pSoundBuf = pBurnSoundOut + (nSoundBufferPos << 1);
7153 			AY8910Render(pSoundBuf, nSegmentLength);
7154 
7155 			nSoundBufferPos += nSegmentLength;
7156 		}
7157 	}
7158 
7159 	// Make sure the buffer is entirely filled.
7160 	if (pBurnSoundOut) {
7161 		INT32 nSegmentLength = nBurnSoundLen - nSoundBufferPos;
7162 		INT16* pSoundBuf = pBurnSoundOut + (nSoundBufferPos << 1);
7163 		if (nSegmentLength) {
7164 			AY8910Render(pSoundBuf, nSegmentLength);
7165 		}
7166 
7167 		MSM6295Render(pBurnSoundOut, nBurnSoundLen);
7168 	}
7169 
7170 	if (pBurnDraw) BurnDrvRedraw();
7171 
7172 	return 0;
7173 }
7174 
BlazeonFrame()7175 static INT32 BlazeonFrame()
7176 {
7177 	INT32 nInterleave = 10;
7178 	nSoundBufferPos = 0;
7179 
7180 	if (Kaneko16Reset) BlazeonDoReset();
7181 
7182 	Kaneko16MakeInputs();
7183 
7184 	nCyclesTotal[0] = 12000000 / 60;
7185 	nCyclesTotal[1] = 4000000 / 60;
7186 	nCyclesDone[0] = nCyclesDone[1] = 0;
7187 
7188 	for (INT32 i = 0; i < nInterleave; i++) {
7189 		INT32 nCurrentCPU, nNext;
7190 
7191 		nCurrentCPU = 0;
7192 		SekOpen(nCurrentCPU);
7193 		nNext = (i + 1) * nCyclesTotal[nCurrentCPU] / nInterleave;
7194 		nCyclesSegment = nNext - nCyclesDone[nCurrentCPU];
7195 		nCyclesDone[nCurrentCPU] += SekRun(nCyclesSegment);
7196 		if (i == 3) SekSetIRQLine(3, CPU_IRQSTATUS_AUTO);
7197 		if (i == 6) SekSetIRQLine(4, CPU_IRQSTATUS_AUTO);
7198 		if (i == 9) SekSetIRQLine(5, CPU_IRQSTATUS_AUTO);
7199 		SekClose();
7200 
7201 		// Run Z80
7202 		nCurrentCPU = 1;
7203 		ZetOpen(0);
7204 		nNext = (i + 1) * nCyclesTotal[nCurrentCPU] / nInterleave;
7205 		nCyclesSegment = nNext - nCyclesDone[nCurrentCPU];
7206 		nCyclesSegment = ZetRun(nCyclesSegment);
7207 		nCyclesDone[nCurrentCPU] += nCyclesSegment;
7208 		ZetClose();
7209 
7210 		// Render Sound Segment
7211 		if (pBurnSoundOut) {
7212 			INT32 nSegmentLength = nBurnSoundLen / nInterleave;
7213 			INT16* pSoundBuf = pBurnSoundOut + (nSoundBufferPos << 1);
7214 			ZetOpen(0);
7215 			BurnYM2151Render(pSoundBuf, nSegmentLength);
7216 			ZetClose();
7217 			nSoundBufferPos += nSegmentLength;
7218 		}
7219 	}
7220 
7221 	// Make sure the buffer is entirely filled.
7222 	if (pBurnSoundOut) {
7223 		INT32 nSegmentLength = nBurnSoundLen - nSoundBufferPos;
7224 		INT16* pSoundBuf = pBurnSoundOut + (nSoundBufferPos << 1);
7225 
7226 		if (nSegmentLength) {
7227 			ZetOpen(0);
7228 			BurnYM2151Render(pSoundBuf, nSegmentLength);
7229 			ZetClose();
7230 		}
7231 	}
7232 
7233 	if (pBurnDraw) BurnDrvRedraw();
7234 
7235 	return 0;
7236 }
7237 
WingforcFrame()7238 static INT32 WingforcFrame()
7239 {
7240 	INT32 nInterleave = 256;
7241 	nSoundBufferPos = 0;
7242 
7243 	if (Kaneko16Reset) WingforcDoReset();
7244 
7245 	Kaneko16MakeInputs();
7246 
7247 	nCyclesTotal[0] = ((UINT64)16000000 * (UINT64)10000) / 591854;
7248 	nCyclesTotal[1] = ((UINT64)4000000 * (UINT64)10000) / 591854;
7249 	nCyclesDone[0] = nCyclesDone[1] = 0;
7250 
7251 	for (INT32 i = 0; i < nInterleave; i++) {
7252 		INT32 nCurrentCPU, nNext;
7253 
7254 		nCurrentCPU = 0;
7255 		SekOpen(nCurrentCPU);
7256 		nNext = (i + 1) * nCyclesTotal[nCurrentCPU] / nInterleave;
7257 		nCyclesSegment = nNext - nCyclesDone[nCurrentCPU];
7258 		nCyclesDone[nCurrentCPU] += SekRun(nCyclesSegment);
7259 		if (i == 144) SekSetIRQLine(3, CPU_IRQSTATUS_AUTO);
7260 		if (i == 64) SekSetIRQLine(4, CPU_IRQSTATUS_AUTO);
7261 		if (i == 224) SekSetIRQLine(5, CPU_IRQSTATUS_AUTO);
7262 		SekClose();
7263 
7264 		// Run Z80
7265 		nCurrentCPU = 1;
7266 		ZetOpen(0);
7267 		nNext = (i + 1) * nCyclesTotal[nCurrentCPU] / nInterleave;
7268 		nCyclesSegment = nNext - nCyclesDone[nCurrentCPU];
7269 		nCyclesSegment = ZetRun(nCyclesSegment);
7270 		nCyclesDone[nCurrentCPU] += nCyclesSegment;
7271 		ZetClose();
7272 
7273 		// Render Sound Segment
7274 		if (pBurnSoundOut) {
7275 			INT32 nSegmentLength = nBurnSoundLen / nInterleave;
7276 			INT16* pSoundBuf = pBurnSoundOut + (nSoundBufferPos << 1);
7277 			ZetOpen(0);
7278 			BurnYM2151Render(pSoundBuf, nSegmentLength);
7279 			ZetClose();
7280 			nSoundBufferPos += nSegmentLength;
7281 		}
7282 	}
7283 
7284 	// Make sure the buffer is entirely filled.
7285 	if (pBurnSoundOut) {
7286 		INT32 nSegmentLength = nBurnSoundLen - nSoundBufferPos;
7287 		INT16* pSoundBuf = pBurnSoundOut + (nSoundBufferPos << 1);
7288 
7289 		if (nSegmentLength) {
7290 			ZetOpen(0);
7291 			BurnYM2151Render(pSoundBuf, nSegmentLength);
7292 			ZetClose();
7293 		}
7294 		MSM6295Render(pBurnSoundOut, nBurnSoundLen);
7295 	}
7296 
7297 	if (pBurnDraw) BurnDrvRedraw();
7298 
7299 	return 0;
7300 }
7301 
GtmrFrame()7302 static INT32 GtmrFrame()
7303 {
7304 	if (Kaneko16Reset) GtmrDoReset();
7305 
7306 	Kaneko16MakeInputs();
7307 
7308 	SekOpen(0);
7309 	SekNewFrame();
7310 
7311 	SekRun((16000000 / 60) / 4);
7312 	SekSetIRQLine(3, CPU_IRQSTATUS_AUTO);
7313 	SekRun((16000000 / 60) / 4);
7314 	SekSetIRQLine(4, CPU_IRQSTATUS_AUTO);
7315 	SekRun((16000000 / 60) / 4);
7316 	SekSetIRQLine(5, CPU_IRQSTATUS_AUTO);
7317 	SekRun((16000000 / 60) / 4);
7318 
7319 	SekClose();
7320 
7321 	if (pBurnSoundOut) {
7322 		MSM6295Render(pBurnSoundOut, nBurnSoundLen);
7323 	}
7324 
7325 	if (pBurnDraw) BurnDrvRedraw();
7326 
7327 	return 0;
7328 }
7329 
ShogwarrFrame()7330 static INT32 ShogwarrFrame()
7331 {
7332 	Kaneko16Watchdog++;
7333 	if (Kaneko16Watchdog > 180) {
7334 	//	ShogwarrDoReset();
7335 	}
7336 
7337 	if (Kaneko16Reset) ShogwarrDoReset();
7338 
7339 	Kaneko16MakeInputs();
7340 
7341 	SekOpen(0);
7342 	SekNewFrame();
7343 
7344 	INT32 nInterleave = 256;
7345 	nCyclesTotal[0] = (12000000 * 100) / 5918;
7346 	nCyclesDone[0] = 0;
7347 	INT32 nSegment = 0;
7348 
7349 	for (INT32 nScanline = 0; nScanline < nInterleave; nScanline++)
7350 	{
7351 		nSegment = (nCyclesTotal[0] - nCyclesDone[0]) / (nInterleave - nScanline);
7352 		nCyclesDone[0] += SekRun(nSegment);
7353 
7354 		if (nScanline ==  64) SekSetIRQLine(3, CPU_IRQSTATUS_AUTO);
7355 		if (nScanline == 144) SekSetIRQLine(2, CPU_IRQSTATUS_AUTO);
7356 		if (nScanline == 223-16) {
7357 			shogwarr_calc3_mcu_run();
7358 		}
7359 
7360 		if (nScanline == 224-16) { // needs -16 otherwise sprite flicker in some shogunwarriors levels.
7361 			SekSetIRQLine(4, CPU_IRQSTATUS_AUTO);
7362 		}
7363 	}
7364 
7365 	SekClose();
7366 
7367 	if (pBurnSoundOut) {
7368 		BurnSoundClear();
7369 		MSM6295Render(pBurnSoundOut, nBurnSoundLen);
7370 	}
7371 
7372 	if (pBurnDraw) BurnDrvRedraw();
7373 
7374 	return 0;
7375 }
7376 
7377 
7378 /*==============================================================================================
7379 Scan Driver
7380 ===============================================================================================*/
7381 
Kaneko16Scan(INT32 nAction,INT32 * pnMin)7382 static INT32 Kaneko16Scan(INT32 nAction, INT32 *pnMin)
7383 {
7384 	struct BurnArea ba;
7385 
7386 	if (pnMin != NULL) {
7387 		*pnMin = 0x029672;
7388 	}
7389 
7390 	if (Kaneko16Eeprom) EEPROMScan(nAction, pnMin);
7391 
7392 	if (nAction & ACB_NVRAM && Kaneko16NVRam) {
7393 		memset(&ba, 0, sizeof(ba));
7394 		ba.Data = Kaneko16NVRam;
7395 		ba.nLen = 0x100;
7396 		ba.szName = "NVRam";
7397 		BurnAcb(&ba);
7398 	}
7399 
7400 	if (nAction & ACB_MEMORY_RAM) {
7401 		memset(&ba, 0, sizeof(ba));
7402 		ba.Data	  = RamStart;
7403 		ba.nLen	  = RamEnd-RamStart;
7404 		ba.szName = "All Ram";
7405 		BurnAcb(&ba);
7406 	}
7407 
7408 	if (nAction & ACB_DRIVER_DATA) {
7409 		SekScan(nAction);
7410 
7411 		SCAN_VAR(Kaneko16SoundLatch);
7412 		SCAN_VAR(Kaneko16SpriteFlipX);
7413 		SCAN_VAR(Kaneko16SpriteFlipY);
7414 		SCAN_VAR(Kaneko16DisplayEnable);
7415 		SCAN_VAR(Kaneko16SpriteRegs);
7416 		SCAN_VAR(Kaneko16Layer0Regs);
7417 		SCAN_VAR(Kaneko16Layer1Regs);
7418 		SCAN_VAR(Kaneko16Brightness);
7419 
7420 		BurnRandomScan(nAction);
7421 
7422 		if (Kaneko16Bg15) {
7423 			SCAN_VAR(Kaneko16Bg15Reg);
7424 			SCAN_VAR(Kaneko16Bg15Select);
7425 		}
7426 	}
7427 
7428 	return 0;
7429 }
7430 
BlazeonScan(INT32 nAction,INT32 * pnMin)7431 static INT32 BlazeonScan(INT32 nAction, INT32 *pnMin)
7432 {
7433 	if (pnMin != NULL) {
7434 		*pnMin =  0x029672;
7435 	}
7436 
7437 	if (nAction & ACB_DRIVER_DATA) {
7438 		ZetScan(nAction);
7439 		BurnYM2151Scan(nAction, pnMin);
7440 	}
7441 
7442 	return Kaneko16Scan(nAction, pnMin);;
7443 }
7444 
WingforcScan(INT32 nAction,INT32 * pnMin)7445 static INT32 WingforcScan(INT32 nAction, INT32 *pnMin)
7446 {
7447 	if (pnMin != NULL) {
7448 		*pnMin =  0x029672;
7449 	}
7450 
7451 	if (nAction & ACB_DRIVER_DATA) {
7452 		ZetScan(nAction);
7453 		BurnYM2151Scan(nAction, pnMin);
7454 		MSM6295Scan(nAction, pnMin);
7455 
7456 		SCAN_VAR(MSM6295Bank0);
7457 	}
7458 
7459 	if (nAction & ACB_WRITE) {
7460 		memcpy(MSM6295ROM + 0x0000000, MSM6295ROMData  + (0x40000 * MSM6295Bank0),0x40000);
7461 	}
7462 
7463 	return Kaneko16Scan(nAction, pnMin);;
7464 }
7465 
ExplbrkrScan(INT32 nAction,INT32 * pnMin)7466 static INT32 ExplbrkrScan(INT32 nAction, INT32 *pnMin)
7467 {
7468 	if (pnMin != NULL) {
7469 		*pnMin =  0x029672;
7470 	}
7471 
7472 	if (nAction & ACB_DRIVER_DATA) {
7473 		AY8910Scan(nAction, pnMin);
7474 		MSM6295Scan(nAction, pnMin);
7475 		SCAN_VAR(MSM6295Bank0);
7476 	}
7477 
7478 	if (nAction & ACB_WRITE) {
7479 		memcpy(MSM6295ROM + 0x0000000, MSM6295ROMData  + (0x40000 * MSM6295Bank0),0x40000);
7480 	}
7481 
7482 	return Kaneko16Scan(nAction, pnMin);;
7483 }
7484 
GtmrScan(INT32 nAction,INT32 * pnMin)7485 static INT32 GtmrScan(INT32 nAction, INT32 *pnMin)
7486 {
7487 	if (pnMin != NULL) {
7488 		*pnMin =  0x029672;
7489 	}
7490 
7491 	if (nAction & ACB_DRIVER_DATA) {
7492 		MSM6295Scan(nAction, pnMin);
7493 		SCAN_VAR(ToyboxMCUCom);
7494 		SCAN_VAR(MSM6295Bank0);
7495 		SCAN_VAR(MSM6295Bank1);
7496 	}
7497 
7498 	if (nAction & ACB_WRITE) {
7499 		memcpy(MSM6295ROM + 0x0000000, MSM6295ROMData  + (0x40000 * MSM6295Bank0),0x40000);
7500 		memcpy(MSM6295ROM + 0x0100000, MSM6295ROMData2 + (0x40000 * MSM6295Bank1),0x40000);
7501 	}
7502 
7503 	return Kaneko16Scan(nAction, pnMin);;
7504 }
7505 
ShogwarrScan(INT32 nAction,INT32 * pnMin)7506 static INT32 ShogwarrScan(INT32 nAction, INT32 *pnMin)
7507 {
7508 	struct BurnArea ba;
7509 
7510 	if (pnMin != NULL) {
7511 		*pnMin =  0x029672;
7512 	}
7513 
7514 	if (nAction & ACB_DRIVER_DATA) {
7515 		memset(&ba, 0, sizeof(ba));
7516 		ba.Data	  = &m_calc3;
7517 		ba.nLen	  = sizeof (m_calc3);
7518 		ba.szName = "Calc3 Data";
7519 		BurnAcb(&ba);
7520 
7521 		memset(&ba, 0, sizeof(ba));
7522 		ba.Data	  = &m_hit3;
7523 		ba.nLen	  = sizeof (m_hit3);
7524 		ba.szName = "Hit2 Data";
7525 		BurnAcb(&ba);
7526 
7527 		MSM6295Scan(nAction, pnMin);
7528 		SCAN_VAR(MSM6295Bank0);
7529 		SCAN_VAR(MSM6295Bank1);
7530 	}
7531 
7532 	if (nAction & ACB_WRITE) {
7533 		INT32 data0 = MSM6295Bank0;
7534 		INT32 data1 = MSM6295Bank1;
7535 		MSM6295Bank0 = MSM6295Bank1 = -1;
7536 
7537 		ShogwarrConfigSoundBank(0, data0 & 0x0f, 0x30000, 0x10000);
7538 		if (Shogwarr) {
7539 			ShogwarrConfigSoundBank(1, data1 & 0x0f, 0x00000, 0x40000);
7540 		} else {
7541 			ShogwarrConfigSoundBank(1, data1 & 0x0f, 0x20000, 0x20000);
7542 		}
7543 	}
7544 
7545 	return Kaneko16Scan(nAction, pnMin);;
7546 }
7547 
7548 /*==============================================================================================
7549 Driver defs
7550 ===============================================================================================*/
7551 
7552 struct BurnDriver BurnDrvBerlwall = {
7553 	"berlwall", NULL, NULL, NULL, "1991",
7554 	"The Berlin Wall\0", NULL, "Kaneko", "Kaneko16",
7555 	NULL, NULL, NULL, NULL,
7556 	BDF_GAME_WORKING, 2, HARDWARE_KANEKO16, GBF_PLATFORM, 0,
7557 	NULL, BerlwallRomInfo, BerlwallRomName, NULL, NULL, NULL, NULL, BerlwallInputInfo, BerlwallDIPInfo,
7558 	BerlwallInit, BerlwallExit, ExplbrkrFrame, BerlwallFrameRender, ExplbrkrScan,
7559 	&Kaneko16RecalcBg15Palette, 0x9000, 256, 224, 4, 3
7560 };
7561 
7562 struct BurnDriver BurnDrvBerlwallt = {
7563 	"berlwallt", "berlwall", NULL, NULL, "1991",
7564 	"The Berlin Wall (bootleg ?)\0", NULL, "Kaneko", "Kaneko16",
7565 	NULL, NULL, NULL, NULL,
7566 	BDF_GAME_WORKING | BDF_CLONE | BDF_BOOTLEG, 2, HARDWARE_KANEKO16, GBF_PLATFORM, 0,
7567 	NULL, BerlwalltRomInfo, BerlwalltRomName, NULL, NULL, NULL, NULL, BerlwallInputInfo, BerlwalltDIPInfo,
7568 	BerlwallInit, BerlwallExit, ExplbrkrFrame, BerlwallFrameRender, ExplbrkrScan,
7569 	&Kaneko16RecalcBg15Palette, 0x9000, 256, 224, 4, 3
7570 };
7571 
7572 struct BurnDriver BurnDrvBerlwallk = {
7573 	"berlwallk", "berlwall", NULL, NULL, "1991",
7574 	"The Berlin Wall (Korea)\0", NULL, "Kaneko (Inter license)", "Kaneko16",
7575 	NULL, NULL, NULL, NULL,
7576 	BDF_GAME_WORKING | BDF_CLONE, 2, HARDWARE_KANEKO16, GBF_PLATFORM, 0,
7577 	NULL, BerlwallkRomInfo, BerlwallkRomName, NULL, NULL, NULL, NULL, BerlwallInputInfo, BerlwalltDIPInfo,
7578 	BerlwallInit, BerlwallExit, ExplbrkrFrame, BerlwallFrameRender, ExplbrkrScan,
7579 	&Kaneko16RecalcBg15Palette, 0x9000, 256, 224, 4, 3
7580 };
7581 
7582 struct BurnDriver BurnDrvPackbang = {
7583 	"packbang", NULL, NULL, NULL, "1994",
7584 	"Pack'n Bang Bang (Prototype)\0", NULL, "Kaneko", "Kaneko16",
7585 	NULL, NULL, NULL, NULL,
7586 	BDF_GAME_WORKING | BDF_ORIENTATION_VERTICAL | BDF_ORIENTATION_FLIPPED, 2, HARDWARE_KANEKO16, GBF_PUZZLE, 0,
7587 	NULL, PackbangRomInfo, PackbangRomName, NULL, NULL, NULL, NULL, BerlwallInputInfo, PackbangDIPInfo,
7588 	PackbangInit, BerlwallExit, ExplbrkrFrame, BerlwallFrameRender, ExplbrkrScan,
7589 	&Kaneko16RecalcBg15Palette, 0x9000, 225, 256, 3, 4
7590 };
7591 
7592 struct BurnDriver BurnDrvBlazeon = {
7593 	"blazeon", NULL, NULL, NULL, "1992",
7594 	"Blaze On (World)\0", NULL, "A.I (Atlus license)", "Kaneko16",
7595 	NULL, NULL, NULL, NULL,
7596 	BDF_GAME_WORKING, 2, HARDWARE_KANEKO16, GBF_HORSHOOT, 0,
7597 	NULL, BlazeonRomInfo, BlazeonRomName, NULL, NULL, NULL, NULL, BlazeonInputInfo, BlazeonDIPInfo,
7598 	BlazeonInit, BlazeonExit, BlazeonFrame, BlazeonFrameRender, BlazeonScan,
7599 	NULL, 0x1000, 320, 232, 4, 3
7600 };
7601 
7602 struct BurnDriver BurnDrvBlazeonj = {
7603 	"blazeonj", "blazeon", NULL, NULL, "1992",
7604 	"Blaze On (Japan)\0", NULL, "A.I (Atlus license)", "Kaneko16",
7605 	NULL, NULL, NULL, NULL,
7606 	BDF_GAME_WORKING | BDF_CLONE, 2, HARDWARE_KANEKO16, GBF_HORSHOOT, 0,
7607 	NULL, BlazeonjRomInfo, BlazeonjRomName, NULL, NULL, NULL, NULL, BlazeonInputInfo, BlazeonDIPInfo,
7608 	BlazeonInit, BlazeonExit, BlazeonFrame, BlazeonFrameRender, BlazeonScan,
7609 	NULL, 0x1000, 320, 232, 4, 3
7610 };
7611 
7612 struct BurnDriver BurnDrvWingforc = {
7613 	"wingforc", NULL, NULL, NULL, "1993",
7614 	"Wing Force (Japan, prototype)\0", NULL, "A.I (Atlus license)", "Kaneko16",
7615 	NULL, NULL, NULL, NULL,
7616 	BDF_GAME_WORKING | BDF_ORIENTATION_VERTICAL, 2, HARDWARE_KANEKO16, GBF_HORSHOOT, 0,
7617 	NULL, WingforcRomInfo, WingforcRomName, NULL, NULL, NULL, NULL, BlazeonInputInfo, BlazeonDIPInfo,
7618 	WingforcInit, WingforcExit, WingforcFrame, BlazeonFrameRender, WingforcScan,
7619 	NULL, 0x1000, 224, 320, 3, 4
7620 };
7621 
7622 struct BurnDriver BurnDrvBloodwar = {
7623 	"bloodwar", NULL, NULL, NULL, "1994",
7624 	"Blood Warrior\0", NULL, "Kaneko", "Kaneko16",
7625 	NULL, NULL, NULL, NULL,
7626 	BDF_GAME_WORKING, 2, HARDWARE_KANEKO16, GBF_VSFIGHT, 0,
7627 	NULL, BloodwarRomInfo, BloodwarRomName, NULL, NULL, NULL, NULL, BloodwarInputInfo, BloodwarDIPInfo,
7628 	BloodwarInit, GtmrMachineExit, GtmrFrame, BloodwarFrameRender, GtmrScan,
7629 	NULL, 0x10000, 320, 240, 4, 3
7630 };
7631 
7632 struct BurnDriver BurnDrvOedfight = {
7633 	"oedfight", "bloodwar", NULL, NULL, "1994",
7634 	"Oedo Fight (Japan Bloodshed Ver.)\0", NULL, "Kaneko", "Kaneko16",
7635 	NULL, NULL, NULL, NULL,
7636 	BDF_GAME_WORKING | BDF_CLONE, 2, HARDWARE_KANEKO16, GBF_VSFIGHT, 0,
7637 	NULL, OedfightRomInfo, OedfightRomName, NULL, NULL, NULL, NULL, BloodwarInputInfo, BloodwarDIPInfo,
7638 	BloodwarInit, GtmrMachineExit, GtmrFrame, BloodwarFrameRender, GtmrScan,
7639 	NULL, 0x10000, 320, 240, 4, 3
7640 };
7641 
7642 struct BurnDriver BurnDrvBonkadv = {
7643 	"bonkadv", NULL, NULL, NULL, "1994",
7644 	"B.C. Kid / Bonk's Adventure / Kyukyoku!! PC Genjin\0", NULL, "Kaneko", "Kaneko16",
7645 	NULL, NULL, NULL, NULL,
7646 	BDF_GAME_WORKING, 2, HARDWARE_KANEKO16, GBF_PLATFORM, 0,
7647 	NULL, BonkadvRomInfo, BonkadvRomName, NULL, NULL, NULL, NULL, BonkadvInputInfo, BonkadvDIPInfo,
7648 	BonkadvInit, GtmrMachineExit, GtmrFrame, BloodwarFrameRender, GtmrScan,
7649 	NULL, 0x10000, 320, 240, 4, 3
7650 };
7651 
7652 struct BurnDriver BurnDrvExplbrkr = {
7653 	"explbrkr", NULL, NULL, NULL, "1992",
7654 	"Explosive Breaker (World)\0", NULL, "Kaneko", "Kaneko16",
7655 	NULL, NULL, NULL, NULL,
7656 	BDF_GAME_WORKING | BDF_ORIENTATION_VERTICAL | BDF_ORIENTATION_FLIPPED, 2, HARDWARE_KANEKO16, GBF_VERSHOOT, 0,
7657 	NULL, ExplbrkrRomInfo, ExplbrkrRomName, NULL, NULL, NULL, NULL, ExplbrkrInputInfo, ExplbrkrDIPInfo,
7658 	ExplbrkrInit, ExplbrkrExit, ExplbrkrFrame, ExplbrkrFrameRender, ExplbrkrScan,
7659 	NULL, 0x1000, 224, 256, 3, 4
7660 };
7661 
7662 struct BurnDriver BurnDrvExplbrkrk = {
7663 	"explbrkrk", "explbrkr", NULL, NULL, "1992",
7664 	"Explosive Breaker (Korea)\0", NULL, "Kaneko", "Kaneko16",
7665 	NULL, NULL, NULL, NULL,
7666 	BDF_GAME_WORKING | BDF_CLONE | BDF_ORIENTATION_VERTICAL | BDF_ORIENTATION_FLIPPED, 2, HARDWARE_KANEKO16, GBF_VERSHOOT, 0,
7667 	NULL, ExplbrkrkRomInfo, ExplbrkrkRomName, NULL, NULL, NULL, NULL, ExplbrkrInputInfo, ExplbrkrDIPInfo,
7668 	ExplbrkrInit, ExplbrkrExit, ExplbrkrFrame, ExplbrkrFrameRender, ExplbrkrScan,
7669 	NULL, 0x1000, 224, 256, 3, 4
7670 };
7671 
7672 struct BurnDriver BurnDrvBakubrkr = {
7673 	"bakubrkr", "explbrkr", NULL, NULL, "1992",
7674 	"Bakuretsu Breaker (Japan)\0", NULL, "Kaneko", "Kaneko16",
7675 	NULL, NULL, NULL, NULL,
7676 	BDF_GAME_WORKING | BDF_CLONE | BDF_ORIENTATION_VERTICAL | BDF_ORIENTATION_FLIPPED, 2, HARDWARE_KANEKO16, GBF_VERSHOOT, 0,
7677 	NULL, BakubrkrRomInfo, BakubrkrRomName, NULL, NULL, NULL, NULL, ExplbrkrInputInfo, ExplbrkrDIPInfo,
7678 	ExplbrkrInit, ExplbrkrExit, ExplbrkrFrame, ExplbrkrFrameRender, ExplbrkrScan,
7679 	NULL, 0x1000, 224, 256, 3, 4
7680 };
7681 
7682 struct BurnDriver BurnDrvGtmr = {
7683 	"gtmr", NULL, NULL, NULL, "1994",
7684 	"1000 Miglia: Great 1000 Miles Rally (94/07/18)\0", NULL, "Kaneko", "Kaneko16",
7685 	NULL, NULL, NULL, NULL,
7686 	BDF_GAME_WORKING, 2, HARDWARE_KANEKO16, GBF_RACING, 0,
7687 	NULL, GtmrRomInfo, GtmrRomName, NULL, NULL, NULL, NULL, GtmrInputInfo, GtmrDIPInfo,
7688 	GtmrInit, GtmrMachineExit, GtmrFrame, GtmrFrameRender, GtmrScan,
7689 	NULL, 0x10000, 320, 240, 4, 3
7690 };
7691 
7692 struct BurnDriver BurnDrvGtmra = {
7693 	"gtmra", "gtmr", NULL, NULL, "1994",
7694 	"1000 Miglia: Great 1000 Miles Rally (94/06/13)\0", NULL, "Kaneko", "Kaneko16",
7695 	NULL, NULL, NULL, NULL,
7696 	BDF_GAME_WORKING | BDF_CLONE, 2, HARDWARE_KANEKO16, GBF_RACING, 0,
7697 	NULL, GtmraRomInfo, GtmraRomName, NULL, NULL, NULL, NULL, GtmrInputInfo, GtmrDIPInfo,
7698 	GtmrInit, GtmrMachineExit, GtmrFrame, GtmrFrameRender, GtmrScan,
7699 	NULL, 0x10000, 320, 240, 4, 3
7700 };
7701 
7702 struct BurnDriver BurnDrvGtmrb = {
7703 	"gtmrb", "gtmr", NULL, NULL, "1994",
7704 	"1000 Miglia: Great 1000 Miles Rally (94/05/26)\0", NULL, "Kaneko", "Kaneko16",
7705 	NULL, NULL, NULL, NULL,
7706 	BDF_GAME_WORKING | BDF_CLONE, 2, HARDWARE_KANEKO16, GBF_RACING, 0,
7707 	NULL, GtmrbRomInfo, GtmrbRomName, NULL, NULL, NULL, NULL, GtmrInputInfo, GtmrDIPInfo,
7708 	GtmrInit, GtmrMachineExit, GtmrFrame, GtmrFrameRender, GtmrScan,
7709 	NULL, 0x10000, 320, 240, 4, 3
7710 };
7711 
7712 struct BurnDriver BurnDrvGtmro = {
7713 	"gtmro", "gtmr", NULL, NULL, "1994",
7714 	"1000 Miglia: Great 1000 Miles Rally (94/05/10)\0", NULL, "Kaneko", "Kaneko16",
7715 	NULL, NULL, NULL, NULL,
7716 	BDF_GAME_WORKING | BDF_CLONE, 2, HARDWARE_KANEKO16, GBF_RACING, 0,
7717 	NULL, GtmroRomInfo, GtmroRomName, NULL, NULL, NULL, NULL, GtmrInputInfo, GtmrDIPInfo,
7718 	GtmroInit, GtmrMachineExit, GtmrFrame, GtmrFrameRender, GtmrScan,
7719 	NULL, 0x10000, 320, 240, 4, 3
7720 };
7721 
7722 struct BurnDriver BurnDrvGtmre = {
7723 	"gtmre", "gtmr", NULL, NULL, "1994",
7724 	"Great 1000 Miles Rally: Evolution Model!!! (94/09/06)\0", NULL, "Kaneko", "Kaneko16",
7725 	NULL, NULL, NULL, NULL,
7726 	BDF_GAME_WORKING | BDF_CLONE, 2, HARDWARE_KANEKO16, GBF_RACING, 0,
7727 	NULL, GtmreRomInfo, GtmreRomName, NULL, NULL, NULL, NULL, GtmrInputInfo, GtmrDIPInfo,
7728 	GtmrevoInit, GtmrMachineExit, GtmrFrame, GtmrFrameRender, GtmrScan,
7729 	NULL, 0x10000, 320, 240, 4, 3
7730 };
7731 
7732 struct BurnDriver BurnDrvGtmrusa = {
7733 	"gtmrusa", "gtmr", NULL, NULL, "1994",
7734 	"Great 1000 Miles Rally: U.S.A Version! (94/09/06)\0", NULL, "Kaneko", "Kaneko16",
7735 	NULL, NULL, NULL, NULL,
7736 	BDF_GAME_WORKING | BDF_CLONE, 2, HARDWARE_KANEKO16, GBF_RACING, 0,
7737 	NULL, GtmrusaRomInfo, GtmrusaRomName, NULL, NULL, NULL, NULL, GtmrInputInfo, GtmrDIPInfo,
7738 	GtmrevoInit, GtmrMachineExit, GtmrFrame, GtmrFrameRender, GtmrScan,
7739 	NULL, 0x10000, 320, 240, 4, 3
7740 };
7741 
7742 struct BurnDriver BurnDrvGtmr2 = {
7743 	"gtmr2", NULL, NULL, NULL, "1995",
7744 	"Mille Miglia 2: Great 1000 Miles Rally (95/05/24)\0", NULL, "Kaneko", "Kaneko16",
7745 	NULL, NULL, NULL, NULL,
7746 	BDF_GAME_WORKING, 2, HARDWARE_KANEKO16, GBF_RACING, 0,
7747 	NULL, Gtmr2RomInfo, Gtmr2RomName, NULL, NULL, NULL, NULL, GtmrInputInfo, Gtmr2DIPInfo,
7748 	Gtmr2Init, GtmrMachineExit, GtmrFrame, GtmrFrameRender, GtmrScan,
7749 	NULL, 0x10000, 320, 240, 4, 3
7750 };
7751 
7752 struct BurnDriver BurnDrvGtmr2a = {
7753 	"gtmr2a", "gtmr2", NULL, NULL, "1995",
7754 	"Mille Miglia 2: Great 1000 Miles Rally (95/04/04)\0", NULL, "Kaneko", "Kaneko16",
7755 	NULL, NULL, NULL, NULL,
7756 	BDF_GAME_WORKING | BDF_CLONE, 2, HARDWARE_KANEKO16, GBF_RACING, 0,
7757 	NULL, Gtmr2aRomInfo, Gtmr2aRomName, NULL, NULL, NULL, NULL, GtmrInputInfo, Gtmr2DIPInfo,
7758 	Gtmr2Init, GtmrMachineExit, GtmrFrame, GtmrFrameRender, GtmrScan,
7759 	NULL, 0x10000, 320, 240, 4, 3
7760 };
7761 
7762 struct BurnDriver BurnDrvGtmr2u = {
7763 	"gtmr2u", "gtmr2", NULL, NULL, "1995",
7764 	"Great 1000 Miles Rally 2 USA (95/05/18)\0", NULL, "Kaneko", "Kaneko16",
7765 	NULL, NULL, NULL, NULL,
7766 	BDF_GAME_WORKING | BDF_CLONE, 2, HARDWARE_KANEKO16, GBF_RACING, 0,
7767 	NULL, Gtmr2uRomInfo, Gtmr2uRomName, NULL, NULL, NULL, NULL, GtmrInputInfo, Gtmr2DIPInfo,
7768 	Gtmr2uInit, GtmrMachineExit, GtmrFrame, GtmrFrameRender, GtmrScan,
7769 	NULL, 0x10000, 320, 240, 4, 3
7770 };
7771 
7772 struct BurnDriver BurnDrvMgcrsytl = {
7773 	"mgcrystl", NULL, NULL, NULL, "1991",
7774 	"Magical Crystals (World, 92/01/10)\0", NULL, "Kaneko", "Kaneko16",
7775 	NULL, NULL, NULL, NULL,
7776 	BDF_GAME_WORKING, 2, HARDWARE_KANEKO16, GBF_RUNGUN, 0,
7777 	NULL, MgcrystlRomInfo, MgcrystlRomName, NULL, NULL, NULL, NULL, MgcrystlInputInfo, MgcrystlDIPInfo,
7778 	MgcrystlInit, ExplbrkrExit, ExplbrkrFrame, MgcrystlFrameRender, ExplbrkrScan,
7779 	NULL, 0x1000, 256, 224, 4, 3
7780 };
7781 
7782 struct BurnDriver BurnDrvMgcrsytlo = {
7783 	"mgcrystlo", "mgcrystl", NULL, NULL, "1991",
7784 	"Magical Crystals (World, 91/12/10)\0", NULL, "Kaneko", "Kaneko16",
7785 	NULL, NULL, NULL, NULL,
7786 	BDF_GAME_WORKING | BDF_CLONE, 2, HARDWARE_KANEKO16, GBF_RUNGUN, 0,
7787 	NULL, MgcrystloRomInfo, MgcrystloRomName, NULL, NULL, NULL, NULL, MgcrystlInputInfo, MgcrystlDIPInfo,
7788 	MgcrystlInit, ExplbrkrExit, ExplbrkrFrame, MgcrystlFrameRender, ExplbrkrScan,
7789 	NULL, 0x1000, 256, 224, 4, 3
7790 };
7791 
7792 struct BurnDriver BurnDrvMgcrsytlj = {
7793 	"mgcrystlj", "mgcrystl", NULL, NULL, "1991",
7794 	"Magical Crystals (Japan, 92/01/13)\0", NULL, "Kaneko (Atlus license)", "Kaneko16",
7795 	NULL, NULL, NULL, NULL,
7796 	BDF_GAME_WORKING | BDF_CLONE, 2, HARDWARE_KANEKO16, GBF_RUNGUN, 0,
7797 	NULL, MgcrystljRomInfo, MgcrystljRomName, NULL, NULL, NULL, NULL, MgcrystlInputInfo, MgcrystlDIPInfo,
7798 	MgcrystlInit, ExplbrkrExit, ExplbrkrFrame, MgcrystlFrameRender, ExplbrkrScan,
7799 	NULL, 0x1000, 256, 224, 4, 3
7800 };
7801 
7802 struct BurnDriver BurnDrvShogwarr = {
7803 	"shogwarr", NULL, NULL, NULL, "1992",
7804 	"Shogun Warriors (World)\0", NULL, "Kaneko", "Kaneko16",
7805 	NULL, NULL, NULL, NULL,
7806 	BDF_GAME_WORKING, 2, HARDWARE_KANEKO16, GBF_VSFIGHT, 0,
7807 	NULL, shogwarrRomInfo, shogwarrRomName, NULL, NULL, NULL, NULL, ShogwarrInputInfo, ShogwarrDIPInfo,
7808 	ShogwarrInit, GtmrMachineExit, ShogwarrFrame, ShogwarrFrameRender, ShogwarrScan,
7809 	NULL, 0x800, 256, 224, 4, 3
7810 };
7811 
7812 struct BurnDriver BurnDrvShogwarrk = {
7813 	"shogwarrk", "shogwarr", NULL, NULL, "1992",
7814 	"Shogun Warriors (Korea?)\0", NULL, "Kaneko", "Kaneko16",
7815 	NULL, NULL, NULL, NULL,
7816 	BDF_GAME_WORKING | BDF_CLONE, 2, HARDWARE_KANEKO16, GBF_VSFIGHT, 0,
7817 	NULL, shogwarrkRomInfo, shogwarrkRomName, NULL, NULL, NULL, NULL, ShogwarrInputInfo, ShogwarrDIPInfo,
7818 	ShogwarrkInit, GtmrMachineExit, ShogwarrFrame, ShogwarrFrameRender, ShogwarrScan,
7819 	NULL, 0x800, 256, 224, 4, 3
7820 };
7821 
7822 struct BurnDriver BurnDrvShogwarru = {
7823 	"shogwarru", "shogwarr", NULL, NULL, "1992",
7824 	"Shogun Warriors (US)\0", NULL, "Kaneko", "Kaneko16",
7825 	NULL, NULL, NULL, NULL,
7826 	BDF_GAME_WORKING | BDF_CLONE, 2, HARDWARE_KANEKO16, GBF_VSFIGHT, 0,
7827 	NULL, shogwarruRomInfo, shogwarruRomName, NULL, NULL, NULL, NULL, ShogwarrInputInfo, ShogwarrDIPInfo,
7828 	ShogwarrInit, GtmrMachineExit, ShogwarrFrame, ShogwarrFrameRender, ShogwarrScan,
7829 	NULL, 0x800, 256, 224, 4, 3
7830 };
7831 
7832 struct BurnDriver BurnDrvFjbuster = {
7833 	"fjbuster", "shogwarr", NULL, NULL, "1992",
7834 	"Fujiyama Buster (Japan)\0", NULL, "Kaneko", "Kaneko16",
7835 	NULL, NULL, NULL, NULL,
7836 	BDF_GAME_WORKING | BDF_CLONE, 2, HARDWARE_KANEKO16, GBF_VSFIGHT, 0,
7837 	NULL, fjbusterRomInfo, fjbusterRomName, NULL, NULL, NULL, NULL, ShogwarrInputInfo, ShogwarrDIPInfo,
7838 	ShogwarrInit, GtmrMachineExit, ShogwarrFrame, ShogwarrFrameRender, ShogwarrScan,
7839 	NULL, 0x800, 256, 224, 4, 3
7840 };
7841 
7842 struct BurnDriver BurnDrvBrapboys = {
7843 	"brapboys", NULL, NULL, NULL, "1992",
7844 	"B.Rap Boys (World)\0", NULL, "Kaneko", "Kaneko16",
7845 	NULL, NULL, NULL, NULL,
7846 	BDF_GAME_WORKING, 3, HARDWARE_KANEKO16, GBF_SCRFIGHT, 0,
7847 	NULL, brapboysRomInfo, brapboysRomName, NULL, NULL, NULL, NULL, BrapboysInputInfo, BrapboysDIPInfo,
7848 	BrapboysInit, GtmrMachineExit, ShogwarrFrame, ShogwarrFrameRender, ShogwarrScan,
7849 	NULL, 0x800, 256, 224, 4, 3
7850 };
7851 
7852 struct BurnDriver BurnDrvBrapboysp = {
7853 	"brapboysp", "brapboys", NULL, NULL, "1992",
7854 	"B.Rap Boys Special (World)\0", NULL, "Kaneko", "Kaneko16",
7855 	NULL, NULL, NULL, NULL,
7856 	BDF_GAME_WORKING | BDF_CLONE, 3, HARDWARE_KANEKO16, GBF_SCRFIGHT, 0,
7857 	NULL, brapboyspRomInfo, brapboyspRomName, NULL, NULL, NULL, NULL, BrapboysInputInfo, BrapboysDIPInfo,
7858 	BrapboysInit, GtmrMachineExit, ShogwarrFrame, ShogwarrFrameRender, ShogwarrScan,
7859 	NULL, 0x800, 256, 224, 4, 3
7860 };
7861 
7862 struct BurnDriver BurnDrvBrapboyspj = {
7863 	"brapboyspj", "brapboys", NULL, NULL, "1992",
7864 	"B.Rap Boys Special (Japan)\0", NULL, "Kaneko", "Kaneko16",
7865 	NULL, NULL, NULL, NULL,
7866 	BDF_GAME_WORKING | BDF_CLONE, 3, HARDWARE_KANEKO16, GBF_SCRFIGHT, 0,
7867 	NULL, brapboyspjRomInfo, brapboyspjRomName, NULL, NULL, NULL, NULL, BrapboysInputInfo, BrapboysDIPInfo,
7868 	BrapboysInit, GtmrMachineExit, ShogwarrFrame, ShogwarrFrameRender, ShogwarrScan,
7869 	NULL, 0x800, 256, 224, 4, 3
7870 };
7871 
7872 struct BurnDriver BurnDrvBrapboyspu = {
7873 	"brapboyspu", "brapboys", NULL, NULL, "1992",
7874 	"B.Rap Boys Special (US)\0", NULL, "Kaneko", "Kaneko16",
7875 	NULL, NULL, NULL, NULL,
7876 	BDF_GAME_WORKING | BDF_CLONE, 3, HARDWARE_KANEKO16, GBF_SCRFIGHT, 0,
7877 	NULL, brapboyspuRomInfo, brapboyspuRomName, NULL, NULL, NULL, NULL, BrapboysInputInfo, BrapboysDIPInfo,
7878 	BrapboysInit, GtmrMachineExit, ShogwarrFrame, ShogwarrFrameRender, ShogwarrScan,
7879 	NULL, 0x800, 256, 224, 4, 3
7880 };
7881