1 /* Data East Backfire!
2
3 Backfire!
4
5 inputs are incomplete (p2 side.., alt control modes etc.)
6
7 there may still be some problems with the 156 co-processor, but it seems to be mostly correct
8
9 set 2 defaults to wheel controls, so until they're mapped you must change back to joystick in test mode
10
11 */
12
13 #define DE156CPU ARM
14 extern void deco156_decrypt(void);
15
16 #include "driver.h"
17 #include "decocrpt.h"
18 #include "deco32.h"
19 #include "machine/eeprom.h"
20 #include "vidhrdw/generic.h"
21 #include "cpu/arm/arm.h"
22 #include "machine/random.h"
23 #include "deco16ic.h"
24 #include "state.h"
25
26 #include "mame2003.h"
27 #include "bootstrap.h"
28 #include "inptport.h"
29
30 UINT32 *backfire_spriteram32_1;
31 UINT32 *backfire_spriteram32_2;
32 UINT32 *backfire_mainram;
33 struct mame_bitmap * backfire_left;
34 struct mame_bitmap * backfire_right;
35
36 /*UINT32 *backfire_180010, *backfire_188010;*/
37 UINT32 *backfire_left_priority, *backfire_right_priority;
38
39 extern int deco16_pf1_colour_bank,deco16_pf2_colour_bank,deco16_pf3_colour_bank,deco16_pf4_colour_bank;
40
41 /* I'm using the functions in deco16ic.c ... same chips, why duplicate code? */
42
backfire_bank_callback(int bank)43 static int backfire_bank_callback(int bank)
44 {
45 /* log_cb(RETRO_LOG_DEBUG, LOGPRE "bank callback %04x\n",bank); */ /* bit 1 gets set too?*/
46
47 bank = bank >> 4;
48
49 bank = (bank & 1) | ( (bank & 4) >> 1 ) | ((bank & 2) << 1);
50
51 return bank * 0x1000;
52 }
53
54
55
VIDEO_START(backfire)56 VIDEO_START(backfire)
57 {
58 /* allocate the ram as 16-bit (we do it here because the CPU is 32-bit) */
59 deco16_pf1_data = auto_malloc(0x2000);
60 deco16_pf2_data = auto_malloc(0x2000);
61 deco16_pf3_data = auto_malloc(0x2000);
62 deco16_pf4_data = auto_malloc(0x2000);
63 deco16_pf1_rowscroll = auto_malloc(0x0800);
64 deco16_pf2_rowscroll = auto_malloc(0x0800);
65 deco16_pf3_rowscroll = auto_malloc(0x0800);
66 deco16_pf4_rowscroll = auto_malloc(0x0800);
67 deco16_pf12_control = auto_malloc(0x10);
68 deco16_pf34_control = auto_malloc(0x10);
69
70 /* and register the allocated ram so that save states still work */
71 state_save_register_UINT16 ("BFVIDEO", 0, "Playfield 1 Data", deco16_pf1_data, 0x2000/2);
72 state_save_register_UINT16 ("BFVIDEO", 0, "Playfield 2 Data", deco16_pf2_data, 0x2000/2);
73 state_save_register_UINT16 ("BFVIDEO", 0, "Playfield 3 Data", deco16_pf3_data, 0x2000/2);
74 state_save_register_UINT16 ("BFVIDEO", 0, "Playfield 4 Data", deco16_pf4_data, 0x2000/2);
75 state_save_register_UINT16 ("BFVIDEO", 0, "Playfield 1 Rowscroll", deco16_pf1_rowscroll, 0x800/2);
76 state_save_register_UINT16 ("BFVIDEO", 0, "Playfield 2 Rowscroll", deco16_pf2_rowscroll, 0x800/2);
77 state_save_register_UINT16 ("BFVIDEO", 0, "Playfield 3 Rowscroll", deco16_pf3_rowscroll, 0x800/2);
78 state_save_register_UINT16 ("BFVIDEO", 0, "Playfield 4 Rowscroll", deco16_pf4_rowscroll, 0x800/2);
79 state_save_register_UINT16 ("BFVIDEO", 0, "Playfield 1+2 Control Registers", deco16_pf12_control, 0x10/2);
80 state_save_register_UINT16 ("BFVIDEO", 0, "Playfield 3+4 Control Registers", deco16_pf34_control, 0x10/2);
81
82 if (deco16_2_video_init(0))
83 return 1;
84
85 deco16_pf1_colour_bank = 0x00;
86 deco16_pf2_colour_bank = 0x40;
87 deco16_pf3_colour_bank = 0x10;
88 deco16_pf4_colour_bank = 0x50;
89
90 deco16_set_tilemap_bank_callback(0, backfire_bank_callback);
91 deco16_set_tilemap_bank_callback(1, backfire_bank_callback);
92 deco16_set_tilemap_bank_callback(2, backfire_bank_callback);
93 deco16_set_tilemap_bank_callback(3, backfire_bank_callback);
94
95 backfire_left = auto_bitmap_alloc_depth(80*8, 32*8, 16);
96 backfire_right = auto_bitmap_alloc_depth(80*8, 32*8, 16);
97
98 return 0;
99 }
100
backfire_drawsprites(struct mame_bitmap * bitmap,const struct rectangle * cliprect,UINT32 * backfire_spriteram32,int region)101 static void backfire_drawsprites(struct mame_bitmap *bitmap,const struct rectangle *cliprect, UINT32 *backfire_spriteram32, int region)
102 {
103 int offs;
104
105 flip_screen = 1;
106
107 for (offs = (0x1400/4)-4;offs >= 0;offs -= 4) /* 0x1400 for charlien*/
108 {
109 int x,y,sprite,colour,multi,fx,fy,inc,flash,mult, pri;
110
111 sprite = backfire_spriteram32[offs+1]&0xffff;
112
113 y = backfire_spriteram32[offs]&0xffff;
114 flash=y&0x1000;
115 if (flash && (cpu_getcurrentframe() & 1)) continue;
116
117 x = backfire_spriteram32[offs+2]&0xffff;
118 colour = (x >>9) & 0x1f;
119
120 pri = (x&0xc000); /* 2 bits or 1?*/
121
122 switch (pri&0xc000) {
123 case 0x0000: pri=0; break; /* numbers, people, cars when in the air, status display..*/
124 case 0x4000: pri=0xf0;break; /* cars most of the time*/
125 case 0x8000: pri=0; break; /* car wheels during jump?*/
126 case 0xc000: pri=0xf0;break; /* car wheels in race? */
127 }
128
129 /* pri 0 = ontop of everything*/ /**/
130
131 /* pri = 0;*/
132
133 fx = y & 0x2000;
134 fy = y & 0x4000;
135 multi = (1 << ((y & 0x0600) >> 9)) - 1; /* 1x, 2x, 4x, 8x height */
136
137 x = x & 0x01ff;
138 y = y & 0x01ff;
139 if (x >= 320) x -= 512;
140 if (y >= 256) y -= 512;
141 y = 240 - y;
142 x = 304 - x;
143
144 if (x>320) continue;
145
146 sprite &= ~multi;
147 if (fy)
148 inc = -1;
149 else
150 {
151 sprite += multi;
152 inc = 1;
153 }
154
155 if (flip_screen)
156 {
157 y=240-y;
158 x=304-x;
159 if (fx) fx=0; else fx=1;
160 if (fy) fy=0; else fy=1;
161 mult=16;
162 }
163 else mult=-16;
164
165 while (multi >= 0)
166 {
167 pdrawgfx(bitmap,Machine->gfx[region],
168 sprite - multi * inc,
169 colour,
170 fx,fy,
171 x,y + mult * multi,
172 cliprect,TRANSPARENCY_PEN,0,pri);
173
174 multi--;
175 }
176 }
177 }
178
179
180
VIDEO_UPDATE(backfire)181 VIDEO_UPDATE(backfire)
182 {
183 /* screen 1 uses pf1 as the forground and pf3 as the background */
184 /* screen 2 uses pf2 as the foreground and pf4 as the background */
185 int x,y;
186
187 deco16_pf12_update(deco16_pf1_rowscroll,deco16_pf2_rowscroll);
188 deco16_pf34_update(deco16_pf3_rowscroll,deco16_pf4_rowscroll);
189
190 fillbitmap(priority_bitmap,0,NULL);
191 fillbitmap(backfire_left,Machine->pens[0x100],cliprect);
192
193 if (backfire_left_priority[0] == 0)
194 {
195 deco16_tilemap_3_draw(backfire_left,cliprect,0,1);
196 deco16_tilemap_1_draw(backfire_left,cliprect,0,2);
197 backfire_drawsprites(backfire_left,cliprect,backfire_spriteram32_1,3);
198 }
199 else if (backfire_left_priority[0] == 2)
200 {
201 deco16_tilemap_1_draw(backfire_left,cliprect,0,2);
202 deco16_tilemap_3_draw(backfire_left,cliprect,0,4);
203 backfire_drawsprites(backfire_left,cliprect,backfire_spriteram32_1,3);
204 }
205 else
206 {
207 usrintf_showmessage( "unknown left priority %08x", backfire_left_priority[0] );
208 }
209
210 fillbitmap(priority_bitmap,0,NULL);
211 fillbitmap(backfire_right,Machine->pens[0x500],cliprect);
212
213 if (backfire_right_priority[0] == 0)
214 {
215 deco16_tilemap_4_draw(backfire_right,cliprect,0,1);
216 deco16_tilemap_2_draw(backfire_right,cliprect,0,2);
217 backfire_drawsprites(backfire_right,cliprect,backfire_spriteram32_2,4);
218 }
219 else if (backfire_right_priority[0] == 2)
220 {
221 deco16_tilemap_2_draw(backfire_right,cliprect,0,2);
222 deco16_tilemap_4_draw(backfire_right,cliprect,0,4);
223 backfire_drawsprites(backfire_right,cliprect,backfire_spriteram32_2,4);
224 }
225 else
226 {
227 usrintf_showmessage( "unknown right priority %08x", backfire_right_priority[0] );
228 }
229
230 /* copy the screens to the final display bitmap */
231 for(y=0;y<32*8;y++)
232 {
233 UINT16* line_dest = (UINT16 *)(bitmap->line[y]);
234 UINT16* line_src = (UINT16 *)(backfire_left->line[y]);
235 UINT16* line_src2 = (UINT16 *)(backfire_right->line[y]);
236 /* left screen */
237 for (x=0*8;x<40*8;x++)
238 {
239 line_dest[x] = line_src[x];
240 }
241 /* right screen */
242 for (x=0*8;x<40*8;x++)
243 {
244 line_dest[x+40*8] = line_src2[x];
245 }
246 }
247
248 }
249
250
READ32_HANDLER(backfire_eeprom_r)251 static READ32_HANDLER(backfire_eeprom_r)
252 {
253 /* some kind of screen indicator? checked by backfira set before it will boot */
254 int backfire_screen = mame_rand()&1;
255 return ((EEPROM_read_bit()<<24) | readinputport(0)
256 | ((readinputport(2) & ~0x40) <<16)
257 | ((readinputport(3) & 0x40) <<16)) ^ (backfire_screen << 26) ;
258 }
259
READ32_HANDLER(backfire_control2_r)260 static READ32_HANDLER(backfire_control2_r)
261 {
262 /* log_cb(RETRO_LOG_DEBUG, LOGPRE "%08x:Read eprom %08x (%08x)\n",activecpu_get_pc(),offset<<1,mem_mask);*/
263 return (EEPROM_read_bit()<<24) | readinputport(1) | (readinputport(1)<<16);
264 }
265
266 #ifdef UNUSED_FUNCTION
READ32_HANDLER(backfire_control3_r)267 static READ32_HANDLER(backfire_control3_r)
268 {
269 /* log_cb(RETRO_LOG_DEBUG, LOGPRE "%08x:Read eprom %08x (%08x)\n",activecpu_get_pc(),offset<<1,mem_mask);*/
270 return (EEPROM_read_bit()<<24) | readinputport(2) | (readinputport(2)<<16);
271 }
272 #endif
273
274
WRITE32_HANDLER(backfire_eeprom_w)275 static WRITE32_HANDLER(backfire_eeprom_w)
276 {
277 log_cb(RETRO_LOG_DEBUG, LOGPRE "%08x:write eprom %08x (%08x) %08x\n",activecpu_get_pc(),offset<<1,mem_mask,data);
278 if (ACCESSING_LSB32) {
279 EEPROM_set_clock_line((data & 0x2) ? ASSERT_LINE : CLEAR_LINE);
280 EEPROM_write_bit(data & 0x1);
281 EEPROM_set_cs_line((data & 0x4) ? CLEAR_LINE : ASSERT_LINE);
282 }
283 }
284
285
WRITE32_HANDLER(backfire_nonbuffered_palette_w)286 static WRITE32_HANDLER(backfire_nonbuffered_palette_w)
287 {
288 int r,g,b;
289
290 COMBINE_DATA(&paletteram32[offset]);
291
292 b = (paletteram32[offset] >>10) & 0x1f;
293 g = (paletteram32[offset] >> 5) & 0x1f;
294 r = (paletteram32[offset] >> 0) & 0x1f;
295
296 palette_set_color(offset,r<<3,g<<3,b<<3);
297 }
298
299
READ32_HANDLER(deco156_snd_r)300 static READ32_HANDLER( deco156_snd_r )
301 {
302 return YMZ280B_status_0_r(0);
303 }
304
WRITE32_HANDLER(deco156_snd_w)305 static WRITE32_HANDLER( deco156_snd_w )
306 {
307 if (offset)
308 YMZ280B_data_0_w(0, data);
309 else
310 YMZ280B_register_0_w(0, data);
311 }
312
313 /* map 32-bit writes to 16-bit */
314
READ32_HANDLER(backfire_pf1_rowscroll_r)315 READ32_HANDLER( backfire_pf1_rowscroll_r ) { return deco16_pf1_rowscroll[offset]^0xffff0000; }
READ32_HANDLER(backfire_pf2_rowscroll_r)316 READ32_HANDLER( backfire_pf2_rowscroll_r ) { return deco16_pf2_rowscroll[offset]^0xffff0000; }
READ32_HANDLER(backfire_pf3_rowscroll_r)317 READ32_HANDLER( backfire_pf3_rowscroll_r ) { return deco16_pf3_rowscroll[offset]^0xffff0000; }
READ32_HANDLER(backfire_pf4_rowscroll_r)318 READ32_HANDLER( backfire_pf4_rowscroll_r ) { return deco16_pf4_rowscroll[offset]^0xffff0000; }
WRITE32_HANDLER(backfire_pf1_rowscroll_w)319 WRITE32_HANDLER( backfire_pf1_rowscroll_w ) { data &=0x0000ffff; mem_mask &=0x0000ffff; COMBINE_DATA(&deco16_pf1_rowscroll[offset]); }
WRITE32_HANDLER(backfire_pf2_rowscroll_w)320 WRITE32_HANDLER( backfire_pf2_rowscroll_w ) { data &=0x0000ffff; mem_mask &=0x0000ffff; COMBINE_DATA(&deco16_pf2_rowscroll[offset]); }
WRITE32_HANDLER(backfire_pf3_rowscroll_w)321 WRITE32_HANDLER( backfire_pf3_rowscroll_w ) { data &=0x0000ffff; mem_mask &=0x0000ffff; COMBINE_DATA(&deco16_pf3_rowscroll[offset]); }
WRITE32_HANDLER(backfire_pf4_rowscroll_w)322 WRITE32_HANDLER( backfire_pf4_rowscroll_w ) { data &=0x0000ffff; mem_mask &=0x0000ffff; COMBINE_DATA(&deco16_pf4_rowscroll[offset]); }
READ32_HANDLER(backfire_pf12_control_r)323 READ32_HANDLER ( backfire_pf12_control_r ) { return deco16_pf12_control[offset]^0xffff0000; }
READ32_HANDLER(backfire_pf34_control_r)324 READ32_HANDLER ( backfire_pf34_control_r ) { return deco16_pf34_control[offset]^0xffff0000; }
WRITE32_HANDLER(backfire_pf12_control_w)325 WRITE32_HANDLER( backfire_pf12_control_w ) { data &=0x0000ffff; mem_mask &=0x0000ffff; COMBINE_DATA(&deco16_pf12_control[offset]); }
WRITE32_HANDLER(backfire_pf34_control_w)326 WRITE32_HANDLER( backfire_pf34_control_w ) { data &=0x0000ffff; mem_mask &=0x0000ffff; COMBINE_DATA(&deco16_pf34_control[offset]); }
READ32_HANDLER(backfire_pf1_data_r)327 READ32_HANDLER( backfire_pf1_data_r ) { return deco16_pf1_data[offset]^0xffff0000; }
READ32_HANDLER(backfire_pf2_data_r)328 READ32_HANDLER( backfire_pf2_data_r ) { return deco16_pf2_data[offset]^0xffff0000; }
READ32_HANDLER(backfire_pf3_data_r)329 READ32_HANDLER( backfire_pf3_data_r ) { return deco16_pf3_data[offset]^0xffff0000; }
READ32_HANDLER(backfire_pf4_data_r)330 READ32_HANDLER( backfire_pf4_data_r ) { return deco16_pf4_data[offset]^0xffff0000; }
WRITE32_HANDLER(backfire_pf1_data_w)331 WRITE32_HANDLER( backfire_pf1_data_w ) { data &=0x0000ffff; mem_mask &=0x0000ffff; deco16_pf1_data_w(offset,data,mem_mask); }
WRITE32_HANDLER(backfire_pf2_data_w)332 WRITE32_HANDLER( backfire_pf2_data_w ) { data &=0x0000ffff; mem_mask &=0x0000ffff; deco16_pf2_data_w(offset,data,mem_mask); }
WRITE32_HANDLER(backfire_pf3_data_w)333 WRITE32_HANDLER( backfire_pf3_data_w ) { data &=0x0000ffff; mem_mask &=0x0000ffff; deco16_pf3_data_w(offset,data,mem_mask); }
WRITE32_HANDLER(backfire_pf4_data_w)334 WRITE32_HANDLER( backfire_pf4_data_w ) { data &=0x0000ffff; mem_mask &=0x0000ffff; deco16_pf4_data_w(offset,data,mem_mask); }
335
336 #ifdef UNUSED_FUNCTION
READ32_HANDLER(backfire_unknown_wheel_r)337 READ32_HANDLER( backfire_unknown_wheel_r )
338 {
339 return readinputport(4); /* maybe incorrect but no matter Backfire! only uses the joystick in this driver*/
340 }
341
READ32_HANDLER(backfire_wheel1_r)342 READ32_HANDLER( backfire_wheel1_r )
343 {
344 return mame_rand();
345 }
346
READ32_HANDLER(backfire_wheel2_r)347 READ32_HANDLER( backfire_wheel2_r )
348 {
349 return mame_rand();
350 }
351 #endif
352
353
MEMORY_READ32_START(backfire_readmem)354 static MEMORY_READ32_START( backfire_readmem )
355 { 0x000000, 0x0fffff, MRA32_ROM },
356 { 0x100000, 0x10001f, backfire_pf12_control_r },
357 { 0x110000, 0x111fff, backfire_pf1_data_r },
358 { 0x114000, 0x115fff, backfire_pf2_data_r },
359 { 0x120000, 0x120fff, backfire_pf1_rowscroll_r },
360 { 0x124000, 0x124fff, backfire_pf2_rowscroll_r },
361 { 0x130000, 0x13001f, backfire_pf34_control_r },
362 { 0x140000, 0x141fff, backfire_pf3_data_r },
363 { 0x144000, 0x145fff, backfire_pf4_data_r },
364 { 0x150000, 0x150fff, backfire_pf3_rowscroll_r },
365 { 0x154000, 0x154fff, backfire_pf4_rowscroll_r },
366 { 0x170000, 0x177fff, MRA32_RAM },/* main ram*/
367 { 0x184000, 0x185fff, MRA32_RAM },
368 { 0x18c000, 0x18dfff, MRA32_RAM },
369 { 0x190000, 0x190003, backfire_eeprom_r },
370 { 0x194000, 0x194003, backfire_control2_r },
371 { 0x1a8000, 0x1a8003, MRA32_RAM },
372 { 0x1ac000, 0x1ac003, MRA32_RAM },
373 { 0x1c0000, 0x1c0007, deco156_snd_r },
374 MEMORY_END
375
376 static MEMORY_WRITE32_START( backfire_writemem )
377 { 0x000000, 0x0fffff, MWA32_ROM },
378 { 0x100000, 0x10001f, backfire_pf12_control_w },
379 { 0x110000, 0x111fff, backfire_pf1_data_w },
380 { 0x114000, 0x115fff, backfire_pf2_data_w },
381 { 0x120000, 0x120fff, backfire_pf1_rowscroll_w },
382 { 0x124000, 0x124fff, backfire_pf2_rowscroll_w },
383 { 0x130000, 0x13001f, backfire_pf34_control_w },
384 { 0x140000, 0x141fff, backfire_pf3_data_w },
385 { 0x144000, 0x145fff, backfire_pf4_data_w },
386 { 0x150000, 0x150fff, backfire_pf3_rowscroll_w },
387 { 0x154000, 0x154fff, backfire_pf4_rowscroll_w },
388 { 0x160000, 0x161fff, backfire_nonbuffered_palette_w, &paletteram32 },
389 { 0x170000, 0x177fff, MWA32_RAM, &backfire_mainram },/* main ram*/
390 { 0x184000, 0x185fff, MWA32_RAM, &backfire_spriteram32_1 },
391 { 0x18c000, 0x18dfff, MWA32_RAM, &backfire_spriteram32_2 },
392 { 0x1a4000, 0x1a4003, backfire_eeprom_w },
393 { 0x1a8000, 0x1a8003, MWA32_RAM, &backfire_left_priority },
394 { 0x1ac000, 0x1ac003, MWA32_RAM, &backfire_right_priority },
395 { 0x1c0000, 0x1c0007, deco156_snd_w },
396 MEMORY_END
397
398
399 INPUT_PORTS_START( backfire )
400 PORT_START
401 PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_JOYSTICK_UP | IPF_8WAY | IPF_PLAYER1 )
402 PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | IPF_8WAY | IPF_PLAYER1 )
403 PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_8WAY | IPF_PLAYER1 )
404 PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_8WAY | IPF_PLAYER1 )
405 PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER1 )
406 PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_PLAYER1 )
407 PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_BUTTON3 | IPF_PLAYER1 )
408 PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_START1 )
409
410 PORT_START
411 PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP | IPF_8WAY | IPF_PLAYER2 )
412 PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | IPF_8WAY | IPF_PLAYER2 )
413 PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_8WAY | IPF_PLAYER2 )
414 PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_8WAY | IPF_PLAYER2 )
415 PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER2 )
416 PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_PLAYER2 )
417 PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON3 | IPF_PLAYER2 )
418 PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_START2 )
419
420 PORT_START
421 PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_COIN1 )
422 PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_COIN2 )
423 PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_SERVICE1 )
424 PORT_SERVICE_NO_TOGGLE( 0x0008, IP_ACTIVE_LOW )
425 PORT_BIT( 0x0010, IP_ACTIVE_HIGH, IPT_VBLANK )
426 PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_UNUSED ) /* 'soundmask' */
427 PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_UNUSED )
428 PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_UNUSED )
429 PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_BUTTON4 | IPF_PLAYER1 )
430 PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_BUTTON5 | IPF_PLAYER1 )
431 PORT_BIT( 0x0400, IP_ACTIVE_LOW, IPT_BUTTON6 | IPF_PLAYER1 )
432 PORT_BIT( 0x0800, IP_ACTIVE_LOW, IPT_UNUSED )
433 PORT_BIT( 0x1000, IP_ACTIVE_LOW, IPT_BUTTON4 | IPF_PLAYER2 )
434 PORT_BIT( 0x2000, IP_ACTIVE_LOW, IPT_BUTTON5 | IPF_PLAYER2 )
435 PORT_BIT( 0x4000, IP_ACTIVE_LOW, IPT_BUTTON6 | IPF_PLAYER2 )
436 PORT_BIT( 0x8000, IP_ACTIVE_LOW, IPT_UNUSED )
437
438 PORT_START
439 PORT_BIT( 0x003f, IP_ACTIVE_LOW, IPT_UNUSED ) /* all other bits like low IN2 */
440 PORT_BIT( 0x0040, IP_ACTIVE_HIGH, IPT_VBLANK )
441 PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_UNUSED )
442
443 PORT_START
444 PORT_ANALOG ( 0x00ff, 0x0080, IPT_PADDLE, 30, 10, 0x00, 0xff)/* not used*/
445
446 PORT_START
447 PORT_ANALOG ( 0x00ff, 0x0080, IPT_PADDLE, 30, 10, 0x00, 0xff)/* not used*/
448
449 PORT_START
450 /* ?? */
451 INPUT_PORTS_END
452
453
454 static struct GfxLayout charlayout =
455 {
456 8,8,
457 RGN_FRAC(1,2),
458 4,
459 { RGN_FRAC(1,2)+8, RGN_FRAC(1,2), 8, 0 },
460 { 0, 1, 2, 3, 4, 5, 6, 7 },
461 { 0*16, 1*16, 2*16, 3*16, 4*16, 5*16, 6*16, 7*16 },
462 16*8 /* every char takes 8 consecutive bytes */
463 };
464
465 static struct GfxLayout spritelayout =
466 {
467 16,16,
468 RGN_FRAC(1,1),
469 4,
470 { 16, 0, 24, 8 },
471 { 64*8+0, 64*8+1, 64*8+2, 64*8+3, 64*8+4, 64*8+5, 64*8+6, 64*8+7,
472 0, 1, 2, 3, 4, 5, 6, 7 },
473 { 0*32, 1*32, 2*32, 3*32, 4*32, 5*32, 6*32, 7*32,
474 8*32, 9*32, 10*32, 11*32, 12*32, 13*32, 14*32, 15*32 },
475 128*8
476 };
477
478 static struct GfxLayout tilelayout =
479 {
480 16,16,
481 RGN_FRAC(1,2),
482 4,
483 { RGN_FRAC(1,2)+8, RGN_FRAC(1,2), 8, 0 },
484 { 32*8+0, 32*8+1, 32*8+2, 32*8+3, 32*8+4, 32*8+5, 32*8+6, 32*8+7,
485 0, 1, 2, 3, 4, 5, 6, 7 },
486 { 0*16, 1*16, 2*16, 3*16, 4*16, 5*16, 6*16, 7*16,
487 8*16, 9*16, 10*16, 11*16, 12*16, 13*16, 14*16, 15*16 },
488 64*8
489 };
490
491
492 static struct GfxDecodeInfo gfxdecodeinfo_backfire[] =
493 {
494 { REGION_GFX1, 0, &charlayout, 0, 128 }, /* Characters 8x8 */
495 { REGION_GFX1, 0, &tilelayout, 0, 128 }, /* Tiles 16x16 */
496 { REGION_GFX2, 0, &tilelayout, 0, 128 }, /* Tiles 16x16 */
497 { REGION_GFX3, 0, &spritelayout, 0x200, 32 }, /* Sprites 16x16 (screen 1) */
498 { REGION_GFX4, 0, &spritelayout, 0x600, 32 }, /* Sprites 16x16 (screen 2) */
499 { -1 } /* end of array */
500 };
501
502
sound_irq_gen(int state)503 static void sound_irq_gen(int state)
504 {
505 log_cb(RETRO_LOG_DEBUG, LOGPRE "sound irq\n");
506 }
507
508
509 static struct YMZ280Binterface ymz280b_intf =
510 {
511 1,
512 { 28000000 / 2 }, /* Confirmed on real board */
513 { REGION_SOUND1 },
514 { YM3012_VOL(100,MIXER_PAN_LEFT,100,MIXER_PAN_RIGHT) },
515 { sound_irq_gen }
516 };
517
518
INTERRUPT_GEN(deco32_vbl_interrupt)519 static INTERRUPT_GEN( deco32_vbl_interrupt )
520 {
521 cpu_set_irq_line(0, ARM_IRQ_LINE, HOLD_LINE);
522 }
523
524
525
526 static MACHINE_DRIVER_START( backfire )
527
528 /* basic machine hardware */
529 MDRV_CPU_ADD(ARM, 28000000/4) /* Unconfirmed */
MDRV_CPU_MEMORY(backfire_readmem,backfire_writemem)530 MDRV_CPU_MEMORY(backfire_readmem,backfire_writemem)
531 MDRV_CPU_VBLANK_INT(deco32_vbl_interrupt,1)
532
533 MDRV_FRAMES_PER_SECOND(58)
534 MDRV_VBLANK_DURATION(529)
535 MDRV_NVRAM_HANDLER(93C46)
536
537 /* video hardware */
538 MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER | VIDEO_NEEDS_6BITS_PER_GUN )
539 MDRV_SCREEN_SIZE(80*8, 32*8)
540 MDRV_VISIBLE_AREA(0*8, 40*8-1, 1*8, 31*8-1) /*tweaked for single screen only display */
541 MDRV_GFXDECODE(gfxdecodeinfo_backfire)
542 MDRV_PALETTE_LENGTH(2048)
543 MDRV_ASPECT_RATIO(4,3) /*tweaked for single screen only display */
544
545 MDRV_VIDEO_START(backfire)
546 MDRV_VIDEO_UPDATE(backfire)
547
548 /* sound hardware */
549 MDRV_SOUND_ATTRIBUTES(SOUND_SUPPORTS_STEREO)
550 MDRV_SOUND_ADD(YMZ280B, ymz280b_intf)
551 MACHINE_DRIVER_END
552
553
554 /*
555
556 Backfire!
557 Data East, 1995
558
559 This game is similar to World Rally, Blomby Car, Drift Out'94 etc
560
561
562 PCB Layout
563 ----------
564
565
566 DE-0432-2
567 ---------------------------------------------------------------------
568 | MBZ-06.19L 28.000MHz MBZ-04.19A * |
569 | 52 |
570 | 153 MBZ-03.18A + |
571 | MBZ-05.17L |
572 | |
573 --| LC7881 YMZ280B-F 153 52 MBZ-04.16A * |
574 | |
575 --| MBZ-03.15A + |
576 | CY7C185 (x2) |
577 |J 141 |
578 | MBZ-02.12A |
579 |A |
580 | MBZ-01.10A |
581 |M 223 |
582 | MBZ-00.9A |
583 |M 93C45.8M CY7C185 (x2) 141 |
584 | |
585 |A |
586 | |
587 --| |
588 | |
589 --| TSW1 |
590 | CY7C185 (x4) |
591 | 156 |
592 | ADC0808 RA01-0.3J |
593 | RA00-0.2J |
594 |CONN2 CONN1 D4701 |
595 | |
596 ---------------------------------------------------------------------
597
598
599 Notes:
600 CONN1 & CONN2: For connection of potentiometer or opto steering wheel.
601 Joystick (via JAMMA) can also be used for controls.
602 TSW1: Push Button TEST switch to access options menu (coins/lives etc).
603 * : These ROMs have identical contents AND identical halves.
604 + : These ROMs have identical contents AND identical halves.
605
606 */
607
608 ROM_START( backfire )
609 ROM_REGION( 0x100000, REGION_CPU1, 0 ) /* DE156 code (encrypted) */
610 ROM_LOAD32_WORD( "ra00-0.2j", 0x000002, 0x080000, CRC(790da069) SHA1(84fd90fb1833b97459cb337fdb92f7b6e93b5936) )
611 ROM_LOAD32_WORD( "ra01-0.3j", 0x000000, 0x080000, CRC(447cb57b) SHA1(1d503b9cf1cadd3fdd7c9d6d59d4c40a59fa25ab))
612
613 ROM_REGION( 0x400000, REGION_GFX1, ROMREGION_DISPOSE ) /* Tiles 1 */
614 ROM_LOAD( "mbz-00.9a", 0x000000, 0x080000, CRC(1098d504) SHA1(1fecd26b92faffce0b59a8a9646bfd457c17c87c) )
615 ROM_CONTINUE( 0x200000, 0x080000)
616 ROM_CONTINUE( 0x100000, 0x080000)
617 ROM_CONTINUE( 0x300000, 0x080000)
618 ROM_LOAD( "mbz-01.10a", 0x080000, 0x080000, CRC(19b81e5c) SHA1(4c8204a6a4ad30b23fbfdd79c6e39581e23de6ae) )
619 ROM_CONTINUE( 0x280000, 0x080000)
620 ROM_CONTINUE( 0x180000, 0x080000)
621 ROM_CONTINUE( 0x380000, 0x080000)
622
623 ROM_REGION( 0x100000, REGION_GFX2, ROMREGION_DISPOSE ) /* Tiles 2 */
624 ROM_LOAD( "mbz-02.12a", 0x000000, 0x100000, CRC(2bd2b0a1) SHA1(8fcb37728f3248ad55e48f2d398b014b36c9ec05) )
625
626 ROM_REGION( 0x400000, REGION_GFX3, ROMREGION_DISPOSE ) /* Sprites 1 */
627 ROM_LOAD16_BYTE( "mbz-03.15a", 0x000001, 0x200000, CRC(2e818569) SHA1(457c1cad25d9b21459262be8b5788969f566a996) )
628 ROM_LOAD16_BYTE( "mbz-04.16a", 0x000000, 0x200000, CRC(67bdafb1) SHA1(9729c18f3153e4bba703a6f46ad0b886c52d84e2) )
629
630 ROM_REGION( 0x400000, REGION_GFX4, ROMREGION_DISPOSE ) /* Sprites 2 */
631 ROM_LOAD16_BYTE( "mbz-03.18a", 0x000001, 0x200000, CRC(2e818569) SHA1(457c1cad25d9b21459262be8b5788969f566a996) )
632 ROM_LOAD16_BYTE( "mbz-04.19a", 0x000000, 0x200000, CRC(67bdafb1) SHA1(9729c18f3153e4bba703a6f46ad0b886c52d84e2) )
633
634 ROM_REGION( 0x400000, REGION_SOUND1, ROMREGION_ERASEFF ) /* samples */
635 ROM_LOAD( "mbz-05.17l", 0x000000, 0x200000, CRC(947c1da6) SHA1(ac36006e04dc5e3990f76539763cc76facd08376) )
636 ROM_LOAD( "mbz-06.19l", 0x200000, 0x080000, CRC(4a38c635) SHA1(7f0fb6a7a4aa6774c04fa38e53ceff8744fe1e9f) )
637 ROM_END
638
639
640 static void descramble_sound( void )
641 {
642 UINT8 *rom = memory_region(REGION_SOUND1);
643 int length = 0x200000; /* only the first rom is swapped on backfire!*/
644 UINT8 *buf1 = malloc(length);
645 UINT32 x;
646
647 for (x=0;x<length;x++)
648 {
649 UINT32 addr;
650
651 addr = BITSWAP24 (x,23,22,21,0, 20,
652 19,18,17,16,
653 15,14,13,12,
654 11,10,9, 8,
655 7, 6, 5, 4,
656 3, 2, 1 );
657
658 buf1[addr] = rom[x];
659 }
660
661 memcpy(rom,buf1,length);
662
663 free (buf1);
664 }
665
READ32_HANDLER(backfire_speedup_r)666 static READ32_HANDLER( backfire_speedup_r )
667 {
668 /* log_cb(RETRO_LOG_DEBUG, LOGPRE "%08x\n",activecpu_get_pc());*/
669
670 if (activecpu_get_pc()==0xce44) cpu_spinuntil_time(TIME_IN_USEC(400)); /* backfire*/
671 if (activecpu_get_pc()==0xcee4) cpu_spinuntil_time(TIME_IN_USEC(400)); /* backfira*/
672
673 return backfire_mainram[0x18/4];
674 }
675
676
DRIVER_INIT(backfire)677 static DRIVER_INIT( backfire )
678 {
679 deco56_decrypt(REGION_GFX1); /* 141 */
680 deco56_decrypt(REGION_GFX2); /* 141 */
681 deco156_decrypt();
682 cpunum_set_clockscale(0, 4.0f); /* core timings aren't accurate */
683 descramble_sound();
684 install_mem_read32_handler(0, 0x0170018, 0x017001b, backfire_speedup_r );
685 }
686
687 GAME( 1995, backfire, 0, backfire, backfire, backfire, ROT0, "Data East Corporation", "Backfire!" )
688