1 /***************************************************************************
2
3 Cobra Command:
4 2 BAC06 background generator chips, same as Dec0.
5 1 MXC06 chip for sprites, same as Dec0.
6 256 colours, palette generated by ram.
7
8 The Real Ghostbusters:
9 1 Deco VSC30 (M60348)
10 1 Deco HMC20 (M60232)
11
12 1 playfield, same as above, with rowscroll
13 1024 colours from 2 proms.
14 Sprite hardware close to above, there are some unused (unknown) bits per sprite.
15
16 Super Real Darwin:
17 1 playfield, x-scroll only
18 Closer to earlier Darwin 4078 board than above games.
19
20 Last Mission/Shackled:
21 Has 1 Deco VSC30 (M60348) (From readme file)
22 Has 1 Deco HMC20 (M60232) (From readme file)
23
24 1 playfield
25 Sprite hardware same as Karnov.
26 (Shackled) Palettes 8-15 for tiles seem to have priority over sprites.
27
28 Gondomania:
29 Has two large square surface mount chips: [ DRL 40, 8053, 8649a ]
30 Has 1 Deco VSC30 (M60348)
31 Has 1 Deco HMC20 (M60232)
32 Priority - all tiles with *pens* 8-15 appear over sprites with palettes 8-15.
33
34 Oscar:
35 Uses MXC-06 custom chip for sprites.
36 Uses BAC-06 custom chip for background.
37 I can't find what makes the fix chars...
38 Priority - tiles with palettes 8-15 have their *pens* 8-15 appearing over
39 sprites.
40
41 ***************************************************************************/
42
43 #include "driver.h"
44 #include "vidhrdw/generic.h"
45
46 static int scroll1[4],scroll2[4];
47 static struct tilemap *dec8_pf0_tilemap,*dec8_pf1_tilemap,*dec8_fix_tilemap;
48 static int dec8_pf0_control[0x20],dec8_pf1_control[0x20];
49 static int gfx_bank,gfx_mask,game_uses_priority;
50 static unsigned char *gfx_base;
51 unsigned char *dec8_pf0_data,*dec8_pf1_data,*dec8_row;
52
53 /***************************************************************************
54
55 Convert the color PROMs into a more useable format.
56
57 Real Ghostbusters has two 1024x8 palette PROM.
58 I don't know the exact values of the resistors between the RAM and the
59 RGB output. I assumed these values (the same as Commando)
60
61 bit 7 -- 220 ohm resistor -- GREEN
62 -- 470 ohm resistor -- GREEN
63 -- 1 kohm resistor -- GREEN
64 -- 2.2kohm resistor -- GREEN
65 -- 220 ohm resistor -- RED
66 -- 470 ohm resistor -- RED
67 -- 1 kohm resistor -- RED
68 bit 0 -- 2.2kohm resistor -- RED
69
70 bit 7 -- unused
71 -- unused
72 -- unused
73 -- unused
74 -- 220 ohm resistor -- BLUE
75 -- 470 ohm resistor -- BLUE
76 -- 1 kohm resistor -- BLUE
77 bit 0 -- 2.2kohm resistor -- BLUE
78
79 ***************************************************************************/
ghostb_vh_convert_color_prom(unsigned char * palette,unsigned short * colortable,const unsigned char * color_prom)80 void ghostb_vh_convert_color_prom(unsigned char *palette, unsigned short *colortable,const unsigned char *color_prom)
81 {
82 int i;
83
84 for (i = 0;i < Machine->drv->total_colors;i++)
85 {
86 int bit0,bit1,bit2,bit3;
87
88 bit0 = (color_prom[0] >> 0) & 0x01;
89 bit1 = (color_prom[0] >> 1) & 0x01;
90 bit2 = (color_prom[0] >> 2) & 0x01;
91 bit3 = (color_prom[0] >> 3) & 0x01;
92 *(palette++) = 0x0e * bit0 + 0x1f * bit1 + 0x43 * bit2 + 0x8f * bit3;
93 bit0 = (color_prom[0] >> 4) & 0x01;
94 bit1 = (color_prom[0] >> 5) & 0x01;
95 bit2 = (color_prom[0] >> 6) & 0x01;
96 bit3 = (color_prom[0] >> 7) & 0x01;
97 *(palette++) = 0x0e * bit0 + 0x1f * bit1 + 0x43 * bit2 + 0x8f * bit3;
98 bit0 = (color_prom[Machine->drv->total_colors] >> 0) & 0x01;
99 bit1 = (color_prom[Machine->drv->total_colors] >> 1) & 0x01;
100 bit2 = (color_prom[Machine->drv->total_colors] >> 2) & 0x01;
101 bit3 = (color_prom[Machine->drv->total_colors] >> 3) & 0x01;
102 *(palette++) = 0x0e * bit0 + 0x1f * bit1 + 0x43 * bit2 + 0x8f * bit3;
103
104 color_prom++;
105 }
106 }
107
WRITE_HANDLER(dec8_bac06_0_w)108 WRITE_HANDLER( dec8_bac06_0_w )
109 {
110 dec8_pf0_control[offset]=data;
111 }
112
WRITE_HANDLER(dec8_bac06_1_w)113 WRITE_HANDLER( dec8_bac06_1_w )
114 {
115 dec8_pf1_control[offset]=data;
116 }
117
WRITE_HANDLER(dec8_pf0_data_w)118 WRITE_HANDLER( dec8_pf0_data_w )
119 {
120 dec8_pf0_data[offset]=data;
121 tilemap_mark_tile_dirty(dec8_pf0_tilemap,offset/2);
122 }
123
WRITE_HANDLER(dec8_pf1_data_w)124 WRITE_HANDLER( dec8_pf1_data_w )
125 {
126 dec8_pf1_data[offset]=data;
127 tilemap_mark_tile_dirty(dec8_pf1_tilemap,offset/2);
128 }
129
READ_HANDLER(dec8_pf0_data_r)130 READ_HANDLER( dec8_pf0_data_r )
131 {
132 return dec8_pf0_data[offset];
133 }
134
READ_HANDLER(dec8_pf1_data_r)135 READ_HANDLER( dec8_pf1_data_r )
136 {
137 return dec8_pf1_data[offset];
138 }
139
WRITE_HANDLER(dec8_videoram_w)140 WRITE_HANDLER( dec8_videoram_w )
141 {
142 videoram[offset]=data;
143 tilemap_mark_tile_dirty( dec8_fix_tilemap,offset/2 );
144 }
145
WRITE_HANDLER(srdarwin_videoram_w)146 WRITE_HANDLER( srdarwin_videoram_w )
147 {
148 videoram[offset]=data;
149 tilemap_mark_tile_dirty( dec8_fix_tilemap,offset );
150 }
151
WRITE_HANDLER(dec8_scroll1_w)152 WRITE_HANDLER( dec8_scroll1_w )
153 {
154 scroll1[offset]=data;
155 }
156
WRITE_HANDLER(dec8_scroll2_w)157 WRITE_HANDLER( dec8_scroll2_w )
158 {
159 scroll2[offset]=data;
160 }
161
WRITE_HANDLER(srdarwin_control_w)162 WRITE_HANDLER( srdarwin_control_w )
163 {
164 int bankaddress;
165 unsigned char *RAM = memory_region(REGION_CPU1);
166
167 switch (offset) {
168 case 0: /* Top 3 bits - bank switch, bottom 4 - scroll MSB */
169 bankaddress = 0x10000 + (data >> 5) * 0x4000;
170 cpu_setbank(1,&RAM[bankaddress]);
171 scroll2[0]=data&0xf;
172 return;
173
174 case 1:
175 scroll2[1]=data;
176 return;
177 }
178 }
179
WRITE_HANDLER(lastmiss_control_w)180 WRITE_HANDLER( lastmiss_control_w )
181 {
182 int bankaddress;
183 unsigned char *RAM = memory_region(REGION_CPU1);
184
185 /* Bottom 4 bits - bank switch, Bits 4 & 5 - Scroll MSBs */
186 bankaddress = 0x10000 + (data & 0x0f) * 0x4000;
187 cpu_setbank(1,&RAM[bankaddress]);
188
189 scroll2[0]=(data>>5)&1;
190 scroll2[2]=(data>>6)&1;
191
192 if (cpu_get_pc()==0xfa51) cpu_set_reset_line(1,PULSE_LINE); /* No way this can be right... */
193 if (cpu_get_pc()==0xf9d2) cpu_set_reset_line(1,PULSE_LINE); /* No way this can be right... */
194
195 //logerror("PC %06x - Write %02x to %04x\n",cpu_get_pc(),data,offset+0x1802);
196 }
197
WRITE_HANDLER(lastmiss_scrollx_w)198 WRITE_HANDLER( lastmiss_scrollx_w )
199 {
200 scroll2[1]=data;
201 }
202
WRITE_HANDLER(lastmiss_scrolly_w)203 WRITE_HANDLER( lastmiss_scrolly_w )
204 {
205 scroll2[3]=data;
206 }
207
WRITE_HANDLER(gondo_scroll_w)208 WRITE_HANDLER( gondo_scroll_w )
209 {
210 switch (offset) {
211 case 0x0:
212 scroll2[1]=data; /* X LSB */
213 break;
214 case 0x8:
215 scroll2[3]=data; /* Y LSB */
216 break;
217 case 0x10:
218 scroll2[0]=(data>>0)&1; /* Bit 0: X MSB */
219 scroll2[2]=(data>>1)&1; /* Bit 1: Y MSB */
220 /* Bit 2 is also used in Gondo & Garyoret */
221 break;
222 }
223 }
224
225 /******************************************************************************/
226
227 /* 'Karnov' sprites, used by Gondomania, Last Mission, Shackled, Ghostbusters */
draw_sprites1(struct osd_bitmap * bitmap,int priority)228 static void draw_sprites1(struct osd_bitmap *bitmap, int priority)
229 {
230 int offs,x,y,sprite,sprite2,colour,extra,fx,fy;
231
232 for (offs = 0;offs < 0x800;offs += 8)
233 {
234 y=buffered_spriteram[offs+1]+(buffered_spriteram[offs]<<8);
235 if ((y&0x8000) == 0) continue;
236
237 fx=buffered_spriteram[offs+3];
238
239 if ((fx&0x1) == 0) continue;
240
241 extra=fx&0x10;
242 fy=fx&0x2;
243 fx=fx&0x4;
244
245 x = buffered_spriteram[offs+5]+(buffered_spriteram[offs+4]<<8);
246 colour = buffered_spriteram[offs+6] >> 4;
247 if (priority==1 && (colour&8)) continue;
248 if (priority==2 && !(colour&8)) continue;
249 sprite = buffered_spriteram[offs+7]+(buffered_spriteram[offs+6]<<8);
250 sprite &= 0x0fff;
251
252 if (extra) {y=y+16;sprite&=0xffe;}
253
254 x = x & 0x01ff;
255 y = y & 0x01ff;
256 x=(x+16)%0x200;
257 y=(y+16)%0x200;
258 x=256 - x;
259 y=256 - y;
260 if (flip_screen) {
261 y=240-y;
262 x=240-x;
263 if (fx) fx=0; else fx=1;
264 if (fy) fy=0; else fy=1;
265 if (extra) y=y-16;
266 }
267
268 /* Y Flip determines order of multi-sprite */
269 if (extra && fy) {
270 sprite2=sprite;
271 sprite++;
272 }
273 else
274 sprite2=sprite+1;
275
276 drawgfx(bitmap,Machine->gfx[1],
277 sprite,
278 colour,fx,fy,x,y,
279 0,TRANSPARENCY_PEN,0);
280
281 /* 1 more sprite drawn underneath */
282 if (extra)
283 drawgfx(bitmap,Machine->gfx[1],
284 sprite2,
285 colour,fx,fy,x,y+16,
286 0,TRANSPARENCY_PEN,0);
287 }
288 }
289
290 /* 'Dec0' sprites, used by Cobra Command, Oscar */
draw_sprites2(struct osd_bitmap * bitmap,int priority)291 static void draw_sprites2(struct osd_bitmap *bitmap, int priority)
292 {
293 int offs,x,y,sprite,colour,multi,fx,fy,inc,flash,mult;
294
295 /* Sprites */
296 for (offs = 0;offs < 0x800;offs += 8)
297 {
298 y =buffered_spriteram[offs+1]+(buffered_spriteram[offs]<<8);
299 if ((y&0x8000) == 0) continue;
300 x = buffered_spriteram[offs+5]+(buffered_spriteram[offs+4]<<8);
301 colour = ((x & 0xf000) >> 12);
302 flash=x&0x800;
303 if (flash && (cpu_getcurrentframe() & 1)) continue;
304
305 if (priority==1 && (colour&4)) continue;
306 if (priority==2 && !(colour&4)) continue;
307
308 fx = y & 0x2000;
309 fy = y & 0x4000;
310 multi = (1 << ((y & 0x1800) >> 11)) - 1; /* 1x, 2x, 4x, 8x height */
311
312 /* multi = 0 1 3 7 */
313 sprite = buffered_spriteram[offs+3]+(buffered_spriteram[offs+2]<<8);
314 sprite &= 0x0fff;
315
316 x = x & 0x01ff;
317 y = y & 0x01ff;
318 if (x >= 256) x -= 512;
319 if (y >= 256) y -= 512;
320 x = 240 - x;
321 y = 240 - y;
322
323 sprite &= ~multi;
324 if (fy)
325 inc = -1;
326 else
327 {
328 sprite += multi;
329 inc = 1;
330 }
331
332 if (flip_screen) {
333 y=240-y;
334 x=240-x;
335 if (fx) fx=0; else fx=1;
336 if (fy) fy=0; else fy=1;
337 mult=16;
338 }
339 else mult=-16;
340
341 while (multi >= 0)
342 {
343 drawgfx(bitmap,Machine->gfx[1],
344 sprite - multi * inc,
345 colour,
346 fx,fy,
347 x,y + mult * multi,
348 &Machine->visible_area,TRANSPARENCY_PEN,0);
349 multi--;
350 }
351 }
352 }
353
srdarwin_drawsprites(struct osd_bitmap * bitmap,int pri)354 static void srdarwin_drawsprites(struct osd_bitmap *bitmap, int pri)
355 {
356 int offs;
357
358 /* Sprites */
359 for (offs = 0;offs < 0x200;offs += 4)
360 {
361 int multi,fx,sx,sy,sy2,code,color;
362
363 code = buffered_spriteram[offs+3] + ( ( buffered_spriteram[offs+1] & 0xe0 ) << 3 );
364 sx = (241 - buffered_spriteram[offs+2]);
365 //if (sx < -7) sx += 256;
366
367 sy = buffered_spriteram[offs];
368 color = (buffered_spriteram[offs+1] & 0x03) + ((buffered_spriteram[offs+1] & 0x08) >> 1);
369
370 if (pri==0 && color!=0) continue;
371 if (pri==1 && color==0) continue;
372
373 fx = buffered_spriteram[offs+1] & 0x04;
374 multi = buffered_spriteram[offs+1] & 0x10;
375
376 if (flip_screen) {
377 sy=240-sy;
378 sx=240-sx;
379 if (fx) fx=0; else fx=1;
380 sy2=sy-16;
381 }
382 else sy2=sy+16;
383
384 drawgfx(bitmap,Machine->gfx[1],
385 code,
386 color,
387 fx,flip_screen,
388 sx,sy,
389 &Machine->visible_area,TRANSPARENCY_PEN,0);
390 if (multi)
391 drawgfx(bitmap,Machine->gfx[1],
392 code+1,
393 color,
394 fx,flip_screen,
395 sx,sy2,
396 &Machine->visible_area,TRANSPARENCY_PEN,0);
397 }
398 }
399
400 /* Draw character tiles, each game has different colour masks */
401 /*static void draw_characters(struct osd_bitmap *bitmap, int mask, int shift)
402 {
403 int mx,my,tile,color,offs;
404
405 for (offs = 0x800 - 2;offs >= 0;offs -= 2) {
406 tile=videoram[offs+1]+((videoram[offs]&0xf)<<8);
407
408 if (!tile) continue;
409
410 color=(videoram[offs]&mask)>>shift;
411 mx = (offs/2) % 32;
412 my = (offs/2) / 32;
413
414 drawgfx(bitmap,Machine->gfx[0],
415 tile,color,0,0,8*mx,8*my,
416 &Machine->visible_area,TRANSPARENCY_PEN,0);
417 }
418 }*/
419
420 /******************************************************************************/
421
cobracom_vh_screenrefresh(struct osd_bitmap * bitmap,int full_refresh)422 void cobracom_vh_screenrefresh(struct osd_bitmap *bitmap, int full_refresh)
423 {
424 tilemap_set_scrollx( dec8_pf0_tilemap,0, (dec8_pf0_control[0x10]<<8)+dec8_pf0_control[0x11] );
425 tilemap_set_scrolly( dec8_pf0_tilemap,0, (dec8_pf0_control[0x12]<<8)+dec8_pf0_control[0x13] );
426 tilemap_set_scrollx( dec8_pf1_tilemap,0, (dec8_pf1_control[0x10]<<8)+dec8_pf1_control[0x11] );
427 tilemap_set_scrolly( dec8_pf1_tilemap,0, (dec8_pf1_control[0x12]<<8)+dec8_pf1_control[0x13] );
428 flip_screen_w(0,dec8_pf0_control[0]>>7);
429
430 gfx_mask=3;
431 gfx_bank=3;
432 gfx_base=dec8_pf0_data;
433 tilemap_update(dec8_pf0_tilemap);
434
435 gfx_bank=2;
436 gfx_base=dec8_pf1_data;
437 tilemap_update(dec8_pf1_tilemap);
438 tilemap_update(dec8_fix_tilemap);
439
440 if (palette_recalc())
441 tilemap_mark_all_pixels_dirty(ALL_TILEMAPS);
442 tilemap_render(ALL_TILEMAPS);
443
444 tilemap_draw(bitmap,dec8_pf0_tilemap,0);
445 draw_sprites2(bitmap,1);
446 tilemap_draw(bitmap,dec8_pf1_tilemap,0);
447 draw_sprites2(bitmap,2);
448 tilemap_draw(bitmap,dec8_fix_tilemap,0);
449 }
450
451 /******************************************************************************/
452
get_bac0_tile_info(int tile_index)453 static void get_bac0_tile_info( int tile_index )
454 {
455 int tile,color,offs=tile_index<<1;
456
457 tile=(gfx_base[offs]<<8) | gfx_base[offs+1];
458 color=tile >> 12;
459 if (color>7 && game_uses_priority) tile_info.priority=1; else tile_info.priority=0;
460
461 SET_TILE_INFO(gfx_bank,tile&0xfff,color&gfx_mask)
462 }
463
bac0_scan_rows(UINT32 col,UINT32 row,UINT32 num_cols,UINT32 num_rows)464 static UINT32 bac0_scan_rows(UINT32 col,UINT32 row,UINT32 num_cols,UINT32 num_rows)
465 {
466 /* logical (col,row) -> memory offset */
467 return ((col & 0x0f) + ((row & 0x0f) << 4)) + ((col & 0x10) << 5) + ((row & 0x10) << 4);
468 }
469
get_cobracom_fix_tile_info(int tile_index)470 static void get_cobracom_fix_tile_info( int tile_index )
471 {
472 int offs=tile_index<<1;
473 int tile=videoram[offs+1]+(videoram[offs]<<8);
474 int color=(tile&0xe000) >> 13;
475
476 SET_TILE_INFO(0,tile&0xfff,color)
477 }
478
cobracom_vh_start(void)479 int cobracom_vh_start(void)
480 {
481 game_uses_priority=0;
482 dec8_pf0_tilemap = tilemap_create(get_bac0_tile_info,bac0_scan_rows,0,16,16,32,32);
483 dec8_pf1_tilemap = tilemap_create(get_bac0_tile_info,bac0_scan_rows,TILEMAP_TRANSPARENT,16,16,32,32);
484 dec8_fix_tilemap = tilemap_create(get_cobracom_fix_tile_info,tilemap_scan_rows,TILEMAP_TRANSPARENT,8,8,32,32);
485
486 if (!dec8_pf0_tilemap || !dec8_pf1_tilemap || !dec8_fix_tilemap)
487 return 1;
488
489 dec8_pf1_tilemap->transparent_pen = 0;
490 dec8_fix_tilemap->transparent_pen = 0;
491
492 return 0;
493 }
494
495 /******************************************************************************/
496
ghostb_vh_screenrefresh(struct osd_bitmap * bitmap,int full_refresh)497 void ghostb_vh_screenrefresh(struct osd_bitmap *bitmap, int full_refresh)
498 {
499 if (dec8_pf0_control[0]&0x4) { /* Rowscroll */
500 int offs;
501
502 tilemap_set_scroll_rows(dec8_pf0_tilemap,512);
503 for (offs = 0;offs < 512;offs+=2)
504 tilemap_set_scrollx( dec8_pf0_tilemap,offs/2, (dec8_pf0_control[0x10]<<8)+dec8_pf0_control[0x11] + (dec8_row[offs]<<8)+dec8_row[offs+1] );
505 } else {
506 tilemap_set_scroll_rows(dec8_pf0_tilemap,1);
507 tilemap_set_scrollx( dec8_pf0_tilemap,0, (dec8_pf0_control[0x10]<<8)+dec8_pf0_control[0x11] );
508 }
509 tilemap_set_scrolly( dec8_pf0_tilemap,0, (dec8_pf0_control[0x12]<<8)+dec8_pf0_control[0x13] );
510
511 tilemap_update(ALL_TILEMAPS);
512 if (palette_recalc())
513 tilemap_mark_all_pixels_dirty(ALL_TILEMAPS);
514 tilemap_render(ALL_TILEMAPS);
515
516 tilemap_draw(bitmap,dec8_pf0_tilemap,0);
517 draw_sprites1(bitmap,0);
518 tilemap_draw(bitmap,dec8_fix_tilemap,0);
519 }
520
get_ghostb_fix_tile_info(int tile_index)521 static void get_ghostb_fix_tile_info( int tile_index )
522 {
523 int offs=tile_index<<1;
524 int tile=videoram[offs+1]+(videoram[offs]<<8);
525 int color=(tile&0xc00) >> 10;
526
527 SET_TILE_INFO(0,tile&0x3ff,color)
528 }
529
ghostb_vh_start(void)530 int ghostb_vh_start(void)
531 {
532 dec8_pf0_tilemap = tilemap_create(get_bac0_tile_info,bac0_scan_rows,0,16,16,32,32);
533 dec8_fix_tilemap = tilemap_create(get_ghostb_fix_tile_info,tilemap_scan_rows,TILEMAP_TRANSPARENT,8,8,32,32);
534 dec8_fix_tilemap->transparent_pen = 0;
535
536 if (!dec8_pf0_tilemap || !dec8_fix_tilemap)
537 return 1;
538
539 gfx_bank=2;
540 gfx_mask=0xf;
541 gfx_base=dec8_pf0_data;
542
543 return 0;
544 }
545
546 /******************************************************************************/
547
oscar_vh_screenrefresh(struct osd_bitmap * bitmap,int full_refresh)548 void oscar_vh_screenrefresh(struct osd_bitmap *bitmap, int full_refresh)
549 {
550 tilemap_set_scrollx( dec8_pf0_tilemap,0, (dec8_pf0_control[0x10]<<8)+dec8_pf0_control[0x11] );
551 tilemap_set_scrolly( dec8_pf0_tilemap,0, (dec8_pf0_control[0x12]<<8)+dec8_pf0_control[0x13] );
552 flip_screen_w(0,dec8_pf0_control[1]>>7);
553
554 tilemap_update(ALL_TILEMAPS);
555 if (palette_recalc())
556 tilemap_mark_all_pixels_dirty(ALL_TILEMAPS);
557 tilemap_render(ALL_TILEMAPS);
558
559 tilemap_draw(bitmap,dec8_pf0_tilemap,TILEMAP_BACK | 0);
560 tilemap_draw(bitmap,dec8_pf0_tilemap,TILEMAP_BACK | 1);
561 tilemap_draw(bitmap,dec8_pf0_tilemap,TILEMAP_FRONT | 0);
562 draw_sprites2(bitmap,0);
563 tilemap_draw(bitmap,dec8_pf0_tilemap,TILEMAP_FRONT | 1);
564 tilemap_draw(bitmap,dec8_fix_tilemap,0);
565 }
566
get_oscar_fix_tile_info(int tile_index)567 static void get_oscar_fix_tile_info( int tile_index )
568 {
569 int offs=tile_index<<1;
570 int tile=videoram[offs+1]+(videoram[offs]<<8);
571 int color=(tile&0xf000) >> 14;
572
573 SET_TILE_INFO(0,tile&0xfff,color)
574 }
575
oscar_vh_start(void)576 int oscar_vh_start(void)
577 {
578 dec8_pf0_tilemap = tilemap_create(get_bac0_tile_info,bac0_scan_rows,TILEMAP_SPLIT,16,16,32,32);
579 dec8_fix_tilemap = tilemap_create(get_oscar_fix_tile_info,tilemap_scan_rows,TILEMAP_TRANSPARENT,8,8,32,32);
580
581 if (!dec8_pf0_tilemap || !dec8_fix_tilemap)
582 return 1;
583
584 dec8_fix_tilemap->transparent_pen = 0;
585 dec8_pf0_tilemap->transmask[0] = 0x00ff; /* Bottom 8 pens */
586 dec8_pf0_tilemap->transmask[1] = 0xff00; /* Top 8 pens */
587 game_uses_priority=1;
588 gfx_bank=2;
589 gfx_mask=0x7;
590 gfx_base=dec8_pf0_data;
591
592 return 0;
593 }
594
595 /******************************************************************************/
596
lastmiss_vh_screenrefresh(struct osd_bitmap * bitmap,int full_refresh)597 void lastmiss_vh_screenrefresh(struct osd_bitmap *bitmap, int full_refresh)
598 {
599 tilemap_set_scrollx( dec8_pf0_tilemap,0, ((scroll2[0]<<8)+scroll2[1]) );
600 tilemap_set_scrolly( dec8_pf0_tilemap,0, ((scroll2[2]<<8)+scroll2[3]) );
601 tilemap_update(ALL_TILEMAPS);
602
603 palette_init_used_colors();
604 memset(palette_used_colors+256,PALETTE_COLOR_USED,256);
605 if (palette_recalc())
606 tilemap_mark_all_pixels_dirty(ALL_TILEMAPS);
607 tilemap_render(ALL_TILEMAPS);
608
609 tilemap_draw(bitmap,dec8_pf0_tilemap,0);
610 draw_sprites1(bitmap,0);
611 tilemap_draw(bitmap,dec8_fix_tilemap,0);
612 }
613
shackled_vh_screenrefresh(struct osd_bitmap * bitmap,int full_refresh)614 void shackled_vh_screenrefresh(struct osd_bitmap *bitmap, int full_refresh)
615 {
616 tilemap_set_scrollx( dec8_pf0_tilemap,0, ((scroll2[0]<<8)+scroll2[1]) );
617 tilemap_set_scrolly( dec8_pf0_tilemap,0, ((scroll2[2]<<8)+scroll2[3]) );
618 tilemap_update(ALL_TILEMAPS);
619
620 palette_init_used_colors();
621 memset(palette_used_colors+256,PALETTE_COLOR_USED,256);
622 if (palette_recalc())
623 tilemap_mark_all_pixels_dirty(ALL_TILEMAPS);
624 tilemap_render(ALL_TILEMAPS);
625
626 tilemap_draw(bitmap,dec8_pf0_tilemap,TILEMAP_BACK | 0);
627 tilemap_draw(bitmap,dec8_pf0_tilemap,TILEMAP_BACK | 1);
628 tilemap_draw(bitmap,dec8_pf0_tilemap,TILEMAP_FRONT | 0);
629 draw_sprites1(bitmap,0);
630 tilemap_draw(bitmap,dec8_pf0_tilemap,TILEMAP_FRONT | 1);
631 tilemap_draw(bitmap,dec8_fix_tilemap,0);
632 }
633
lastmiss_scan_rows(UINT32 col,UINT32 row,UINT32 num_cols,UINT32 num_rows)634 static UINT32 lastmiss_scan_rows(UINT32 col,UINT32 row,UINT32 num_cols,UINT32 num_rows)
635 {
636 /* logical (col,row) -> memory offset */
637 return ((col & 0x0f) + ((row & 0x0f) << 4)) + ((col & 0x10) << 4) + ((row & 0x10) << 5);
638 }
639
get_lastmiss_tile_info(int tile_index)640 static void get_lastmiss_tile_info( int tile_index )
641 {
642 int offs=tile_index*2;
643 int tile=dec8_pf0_data[offs+1]+(dec8_pf0_data[offs]<<8);
644 int color=tile >> 12;
645
646 if (color>7 && game_uses_priority) tile_info.priority=1; else tile_info.priority=0;
647
648 SET_TILE_INFO(2,tile&0xfff,color)
649 }
650
get_lastmiss_fix_tile_info(int tile_index)651 static void get_lastmiss_fix_tile_info( int tile_index )
652 {
653 int offs=tile_index<<1;
654 int tile=videoram[offs+1]+(videoram[offs]<<8);
655 int color=(tile&0xc000) >> 14;
656
657 SET_TILE_INFO(0,tile&0xfff,color)
658 }
659
lastmiss_vh_start(void)660 int lastmiss_vh_start(void)
661 {
662 dec8_pf0_tilemap = tilemap_create(get_lastmiss_tile_info,lastmiss_scan_rows,0,16,16,32,32);
663 dec8_fix_tilemap = tilemap_create(get_lastmiss_fix_tile_info,tilemap_scan_rows,TILEMAP_TRANSPARENT,8,8,32,32);
664
665 if (!dec8_pf0_tilemap || !dec8_fix_tilemap)
666 return 1;
667
668 dec8_fix_tilemap->transparent_pen = 0;
669 game_uses_priority=0;
670
671 return 0;
672 }
673
shackled_vh_start(void)674 int shackled_vh_start(void)
675 {
676 dec8_pf0_tilemap = tilemap_create(get_lastmiss_tile_info,lastmiss_scan_rows,TILEMAP_SPLIT,16,16,32,32);
677 dec8_fix_tilemap = tilemap_create(get_lastmiss_fix_tile_info,tilemap_scan_rows,TILEMAP_TRANSPARENT,8,8,32,32);
678
679 if (!dec8_pf0_tilemap || !dec8_fix_tilemap)
680 return 1;
681
682 dec8_fix_tilemap->transparent_pen = 0;
683 dec8_pf0_tilemap->transmask[0] = 0x000f; /* Bottom 12 pens */
684 dec8_pf0_tilemap->transmask[1] = 0xfff0; /* Top 4 pens */
685 game_uses_priority=1;
686
687 return 0;
688 }
689
690 /******************************************************************************/
691
srdarwin_vh_screenrefresh(struct osd_bitmap * bitmap,int full_refresh)692 void srdarwin_vh_screenrefresh(struct osd_bitmap *bitmap, int full_refresh)
693 {
694 tilemap_set_scrollx( dec8_pf0_tilemap,0, (scroll2[0]<<8)+scroll2[1] );
695 tilemap_update(ALL_TILEMAPS);
696
697 if (palette_recalc())
698 tilemap_mark_all_pixels_dirty(ALL_TILEMAPS);
699
700 tilemap_render(ALL_TILEMAPS);
701 tilemap_draw(bitmap,dec8_pf0_tilemap,TILEMAP_BACK | 1);
702 tilemap_draw(bitmap,dec8_pf0_tilemap,TILEMAP_BACK | 0);
703 tilemap_draw(bitmap,dec8_pf0_tilemap,TILEMAP_FRONT | 1);
704 srdarwin_drawsprites(bitmap,0); /* Priority may not be right on later levels */
705 tilemap_draw(bitmap,dec8_pf0_tilemap,TILEMAP_FRONT | 0);
706 srdarwin_drawsprites(bitmap,1);
707 tilemap_draw(bitmap,dec8_fix_tilemap,0);
708 }
709
get_srdarwin_fix_tile_info(int tile_index)710 static void get_srdarwin_fix_tile_info( int tile_index )
711 {
712 int tile=videoram[tile_index];
713 int color=0; /* ? */
714
715 if (color>1) tile_info.priority=1; else tile_info.priority=0;
716
717 SET_TILE_INFO(0,tile,color)
718 }
719
get_srdarwin_tile_info(int tile_index)720 static void get_srdarwin_tile_info(int tile_index)
721 {
722 int tile=dec8_pf0_data[2*tile_index+1]+(dec8_pf0_data[2*tile_index]<<8);
723 int color=tile >> 12;
724 int bank;
725
726 tile=tile&0xfff;
727 bank=(tile/0x100)+2;
728
729 SET_TILE_INFO(bank,tile,color)
730 }
731
srdarwin_vh_start(void)732 int srdarwin_vh_start(void)
733 {
734 dec8_pf0_tilemap = tilemap_create(get_srdarwin_tile_info,tilemap_scan_rows,TILEMAP_SPLIT,16,16,32,16);
735 dec8_fix_tilemap = tilemap_create(get_srdarwin_fix_tile_info,tilemap_scan_rows,TILEMAP_TRANSPARENT,8,8,32,32);
736
737 if (!dec8_pf0_tilemap || !dec8_fix_tilemap)
738 return 1;
739
740 dec8_fix_tilemap->transparent_pen = 0;
741 dec8_pf0_tilemap->transmask[0] = 0x00ff; /* Bottom 8 pens */
742 dec8_pf0_tilemap->transmask[1] = 0xff00; /* Top 8 pens */
743
744 return 0;
745 }
746
747 /******************************************************************************/
748
gondo_vh_screenrefresh(struct osd_bitmap * bitmap,int full_refresh)749 void gondo_vh_screenrefresh(struct osd_bitmap *bitmap, int full_refresh)
750 {
751 tilemap_set_scrollx( dec8_pf0_tilemap,0, ((scroll2[0]<<8)+scroll2[1]) );
752 tilemap_set_scrolly( dec8_pf0_tilemap,0, ((scroll2[2]<<8)+scroll2[3]) );
753 tilemap_update(ALL_TILEMAPS);
754
755 palette_init_used_colors();
756 memset(palette_used_colors+256,PALETTE_COLOR_USED,256);
757 if (palette_recalc())
758 tilemap_mark_all_pixels_dirty(ALL_TILEMAPS);
759 tilemap_render(ALL_TILEMAPS);
760
761 tilemap_draw(bitmap,dec8_pf0_tilemap,TILEMAP_BACK);
762 draw_sprites1(bitmap,2);
763 tilemap_draw(bitmap,dec8_pf0_tilemap,TILEMAP_FRONT);
764 draw_sprites1(bitmap,1);
765 tilemap_draw(bitmap,dec8_fix_tilemap,0);
766 }
767
garyoret_vh_screenrefresh(struct osd_bitmap * bitmap,int full_refresh)768 void garyoret_vh_screenrefresh(struct osd_bitmap *bitmap, int full_refresh)
769 {
770 tilemap_set_scrollx( dec8_pf0_tilemap,0, ((scroll2[0]<<8)+scroll2[1]) );
771 tilemap_set_scrolly( dec8_pf0_tilemap,0, ((scroll2[2]<<8)+scroll2[3]) );
772 tilemap_update(ALL_TILEMAPS);
773
774 palette_init_used_colors();
775 memset(palette_used_colors+256,PALETTE_COLOR_USED,256);
776 if (palette_recalc())
777 tilemap_mark_all_pixels_dirty(ALL_TILEMAPS);
778 tilemap_render(ALL_TILEMAPS);
779
780 tilemap_draw(bitmap,dec8_pf0_tilemap,0);
781 draw_sprites1(bitmap,0);
782 tilemap_draw(bitmap,dec8_pf0_tilemap,1);
783 tilemap_draw(bitmap,dec8_fix_tilemap,0);
784 }
785
get_gondo_fix_tile_info(int tile_index)786 static void get_gondo_fix_tile_info( int tile_index )
787 {
788 int offs=tile_index*2;
789 int tile=videoram[offs+1]+(videoram[offs]<<8);
790 int color=(tile&0x7000) >> 12;
791
792 SET_TILE_INFO(0,tile&0xfff,color)
793 }
794
get_gondo_tile_info(int tile_index)795 static void get_gondo_tile_info( int tile_index )
796 {
797 int offs=tile_index*2;
798 int tile=dec8_pf0_data[offs+1]+(dec8_pf0_data[offs]<<8);
799 int color=tile>> 12;
800
801 if (color>7 && game_uses_priority) tile_info.priority=1; else tile_info.priority=0;
802
803 SET_TILE_INFO(2,tile&0xfff,color)
804 }
805
gondo_vh_start(void)806 int gondo_vh_start(void)
807 {
808 dec8_fix_tilemap=tilemap_create(get_gondo_fix_tile_info,tilemap_scan_rows,TILEMAP_TRANSPARENT,8,8,32,32);
809 dec8_pf0_tilemap=tilemap_create(get_gondo_tile_info,tilemap_scan_rows,TILEMAP_SPLIT,16,16,32,32);
810
811 if (!dec8_fix_tilemap || !dec8_pf0_tilemap)
812 return 1;
813
814 dec8_fix_tilemap->transparent_pen = 0;
815 dec8_pf0_tilemap->transmask[0] = 0x00ff; /* Bottom 8 pens */
816 dec8_pf0_tilemap->transmask[1] = 0xff00; /* Top 8 pens */
817 game_uses_priority=0;
818
819 return 0;
820 }
821
garyoret_vh_start(void)822 int garyoret_vh_start(void)
823 {
824 dec8_fix_tilemap=tilemap_create(get_gondo_fix_tile_info,tilemap_scan_rows,TILEMAP_TRANSPARENT,8,8,32,32);
825 dec8_pf0_tilemap=tilemap_create(get_gondo_tile_info,tilemap_scan_rows,TILEMAP_SPLIT,16,16,32,32);
826
827 if (!dec8_fix_tilemap || !dec8_pf0_tilemap)
828 return 1;
829
830 dec8_fix_tilemap->transparent_pen = 0;
831 game_uses_priority=1;
832
833 return 0;
834 }
835
836 /******************************************************************************/
837