1 #include "driver.h"
2 #include "vidhrdw/generic.h"
3 #include "vidhrdw/konamiic.h"
4 
5 static int layer_colorbase[2];
6 extern int bladestl_spritebank;
7 
PALETTE_INIT(bladestl)8 PALETTE_INIT( bladestl )
9 {
10 	int i;
11 	#define TOTAL_COLORS(gfxn) (Machine->gfx[gfxn]->total_colors * Machine->gfx[gfxn]->color_granularity)
12 	#define COLOR(gfxn,offs) (colortable[Machine->drv->gfxdecodeinfo[gfxn].color_codes_start + offs])
13 
14 	/* build the lookup table for sprites. Palette is dynamic. */
15 	for (i = 0;i < TOTAL_COLORS(1);i++)
16 		COLOR(1,i) = 0x20 + (*(color_prom++) & 0x0f);
17 }
18 
19 /***************************************************************************
20 
21   Callback for the K007342
22 
23 ***************************************************************************/
24 
tile_callback(int layer,int bank,int * code,int * color)25 static void tile_callback(int layer, int bank, int *code, int *color)
26 {
27 	*code |= ((*color & 0x0f) << 8) | ((*color & 0x40) << 6);
28 	*color = layer_colorbase[layer];
29 }
30 
31 /***************************************************************************
32 
33   Callback for the K007420
34 
35 ***************************************************************************/
36 
sprite_callback(int * code,int * color)37 static void sprite_callback(int *code,int *color)
38 {
39 	*code |= ((*color & 0xc0) << 2) + bladestl_spritebank;
40 	*code = (*code << 2) | ((*color & 0x30) >> 4);
41 	*color = 0 + (*color & 0x0f);
42 }
43 
44 
45 /***************************************************************************
46 
47 	Start the video hardware emulation.
48 
49 ***************************************************************************/
50 
VIDEO_START(bladestl)51 VIDEO_START( bladestl )
52 {
53 	layer_colorbase[0] = 0;
54 	layer_colorbase[1] = 1;
55 
56 	if (K007342_vh_start(0,tile_callback))
57 		return 1;
58 
59 	if (K007420_vh_start(1,sprite_callback))
60 		return 1;
61 
62 	return 0;
63 }
64 
65 /***************************************************************************
66 
67   Screen Refresh
68 
69 ***************************************************************************/
70 
VIDEO_UPDATE(bladestl)71 VIDEO_UPDATE( bladestl )
72 {
73 	K007342_tilemap_update();
74 
75 	K007342_tilemap_draw( bitmap, cliprect, 1, TILEMAP_IGNORE_TRANSPARENCY ,0);
76 	K007420_sprites_draw( bitmap, cliprect );
77 	K007342_tilemap_draw( bitmap, cliprect, 1, 1 | TILEMAP_IGNORE_TRANSPARENCY ,0);
78 	K007342_tilemap_draw( bitmap, cliprect, 0, 0 ,0);
79 	K007342_tilemap_draw( bitmap, cliprect, 0, 1 ,0);
80 }
81