1 // license:BSD-3-Clause
2 // copyright-holders:R. Belmont
3 /***************************************************************************
4 
5  Bishi Bashi Champ Mini Game Senshuken
6  (c) 1996 Konami
7 
8  Video hardware emulation.
9 
10 ***************************************************************************/
11 
12 #include "emu.h"
13 #include "includes/bishi.h"
14 
15 
K056832_CB_MEMBER(bishi_state::tile_callback)16 K056832_CB_MEMBER(bishi_state::tile_callback)
17 {
18 //  *code -= '0';
19 //  *color = m_layer_colorbase[layer] | (*color>>2 & 0x0f);
20 //  K055555GX_decode_vmixcolor(layer, color);
21 //  if (*color) osd_printf_debug("plane %x col %x [55 %x %x]\n", layer, *color, layer_colorbase[layer], K055555_get_palette_index(layer));
22 
23 	*color = m_layer_colorbase[layer] + ((*color & 0xf0));
24 }
25 
video_start()26 void bishi_state::video_start()
27 {
28 	assert(m_screen->format() == BITMAP_FORMAT_RGB32);
29 
30 	m_k056832->set_layer_association(0);
31 
32 	m_k056832->set_layer_offs(0, -2, 0);
33 	m_k056832->set_layer_offs(1,  2, 0);
34 	m_k056832->set_layer_offs(2,  4, 0);
35 	m_k056832->set_layer_offs(3,  6, 0);
36 
37 	// the 55555 is set to "0x10, 0x11, 0x12, 0x13", but these values are almost correct...
38 	m_layer_colorbase[0] = 0x00;
39 	m_layer_colorbase[1] = 0x40;    // this one is wrong
40 	m_layer_colorbase[2] = 0x80;
41 	m_layer_colorbase[3] = 0xc0;
42 }
43 
screen_update_bishi(screen_device & screen,bitmap_rgb32 & bitmap,const rectangle & cliprect)44 uint32_t bishi_state::screen_update_bishi(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect)
45 {
46 	int layers[4], layerpri[4], i;/*, old;*/
47 /*  int bg_colorbase, new_colorbase, plane, dirty; */
48 	static const int pris[4] = { K55_PRIINP_0, K55_PRIINP_3, K55_PRIINP_6, K55_PRIINP_7 };
49 	static const int enables[4] = { K55_INP_VRAM_A, K55_INP_VRAM_B, K55_INP_VRAM_C, K55_INP_VRAM_D };
50 
51 	m_k054338->update_all_shadows(0, *m_palette);
52 	m_k054338->fill_solid_bg(bitmap, cliprect);
53 
54 	for (i = 0; i < 4; i++)
55 	{
56 		layers[i] = i;
57 		layerpri[i] = m_k055555->K055555_read_register(pris[i]);
58 	}
59 
60 	konami_sortlayers4(layers, layerpri);
61 
62 	screen.priority().fill(0, cliprect);
63 
64 	for (i = 0; i < 4; i++)
65 	{
66 		if (m_k055555->K055555_read_register(K55_INPUT_ENABLES) & enables[layers[i]])
67 		{
68 			m_k056832->tilemap_draw(screen, bitmap, cliprect, layers[i], 0, 1 << i);
69 		}
70 	}
71 	return 0;
72 }
73