1 // license:BSD-3-Clause
2 // copyright-holders:Nicola Salmoria
3 
4 #include "emu.h"
5 #include "includes/bottom9.h"
6 #include "screen.h"
7 
8 
9 /***************************************************************************
10 
11   Callbacks for the K052109
12 
13 ***************************************************************************/
14 
15 static const int layer_colorbase[] = { 0 / 16, 0 / 16, 256 / 16 };
16 
K052109_CB_MEMBER(bottom9_state::tile_callback)17 K052109_CB_MEMBER(bottom9_state::tile_callback)
18 {
19 	*code |= (*color & 0x3f) << 8;
20 	*color = layer_colorbase[layer] + ((*color & 0xc0) >> 6);
21 }
22 
23 
24 /***************************************************************************
25 
26   Callbacks for the K051960
27 
28 ***************************************************************************/
29 
K051960_CB_MEMBER(bottom9_state::sprite_callback)30 K051960_CB_MEMBER(bottom9_state::sprite_callback)
31 {
32 	enum { sprite_colorbase = 512 / 16 };
33 
34 	/* bit 4 = priority over zoom (0 = have priority) */
35 	/* bit 5 = priority over B (1 = have priority) */
36 	*priority = 0;
37 	if ( *color & 0x10) *priority |= GFX_PMASK_1;
38 	if (~*color & 0x20) *priority |= GFX_PMASK_2;
39 
40 	*color = sprite_colorbase + (*color & 0x0f);
41 }
42 
43 
44 /***************************************************************************
45 
46   Callbacks for the K051316
47 
48 ***************************************************************************/
49 
K051316_CB_MEMBER(bottom9_state::zoom_callback)50 K051316_CB_MEMBER(bottom9_state::zoom_callback)
51 {
52 	enum { zoom_colorbase = 768 / 16 };
53 
54 	*flags = (*color & 0x40) ? TILE_FLIPX : 0;
55 	*code |= ((*color & 0x03) << 8);
56 	*color = zoom_colorbase + ((*color & 0x3c) >> 2);
57 }
58 
59 
60 /***************************************************************************
61 
62   Display refresh
63 
64 ***************************************************************************/
65 
screen_update_bottom9(screen_device & screen,bitmap_ind16 & bitmap,const rectangle & cliprect)66 uint32_t bottom9_state::screen_update_bottom9(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
67 {
68 	m_k052109->tilemap_update();
69 
70 	/* note: FIX layer is not used */
71 	bitmap.fill(layer_colorbase[1], cliprect);
72 	screen.priority().fill(0, cliprect);
73 
74 //  if (m_video_enable)
75 	{
76 		m_k051316->zoom_draw(screen, bitmap, cliprect, 0, 1);
77 		m_k052109->tilemap_draw(screen, bitmap, cliprect, 2, 0, 2);
78 		m_k051960->k051960_sprites_draw(bitmap, cliprect, screen.priority(), -1, -1);
79 		m_k052109->tilemap_draw(screen, bitmap, cliprect, 1, 0, 0);
80 	}
81 	return 0;
82 }
83