summaryrefslogtreecommitdiffstatshomepage
path: root/src/mame/video/bottom9.c
blob: 96ee5bc84a2b743e06f2f7272c9e6fc95f55a47a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#include "emu.h"
#include "video/konicdev.h"
#include "includes/bottom9.h"


/***************************************************************************

  Callbacks for the K052109

***************************************************************************/

void bottom9_tile_callback( running_machine &machine, int layer, int bank, int *code, int *color, int *flags, int *priority )
{
	bottom9_state *state = machine.driver_data<bottom9_state>();
	*code |= (*color & 0x3f) << 8;
	*color = state->m_layer_colorbase[layer] + ((*color & 0xc0) >> 6);
}


/***************************************************************************

  Callbacks for the K051960

***************************************************************************/

void bottom9_sprite_callback( running_machine &machine, int *code, int *color, int *priority, int *shadow )
{
	/* bit 4 = priority over zoom (0 = have priority) */
	/* bit 5 = priority over B (1 = have priority) */
	bottom9_state *state = machine.driver_data<bottom9_state>();
	*priority = (*color & 0x30) >> 4;
	*color = state->m_sprite_colorbase + (*color & 0x0f);
}


/***************************************************************************

  Callbacks for the K051316

***************************************************************************/

void bottom9_zoom_callback( running_machine &machine, int *code, int *color, int *flags )
{
	bottom9_state *state = machine.driver_data<bottom9_state>();
	*flags = (*color & 0x40) ? TILE_FLIPX : 0;
	*code |= ((*color & 0x03) << 8);
	*color = state->m_zoom_colorbase + ((*color & 0x3c) >> 2);
}


/***************************************************************************

    Start the video hardware emulation.

***************************************************************************/

VIDEO_START( bottom9 )
{
	bottom9_state *state = machine.driver_data<bottom9_state>();

	state->m_layer_colorbase[0] = 0;	/* not used */
	state->m_layer_colorbase[1] = 0;
	state->m_layer_colorbase[2] = 16;
	state->m_sprite_colorbase = 32;
	state->m_zoom_colorbase = 48;
}



/***************************************************************************

  Display refresh

***************************************************************************/

SCREEN_UPDATE( bottom9 )
{
	bottom9_state *state = screen->machine().driver_data<bottom9_state>();

	k052109_tilemap_update(state->m_k052109);

	/* note: FIX layer is not used */
	bitmap_fill(bitmap, cliprect, state->m_layer_colorbase[1]);
//  if (state->m_video_enable)
	{
		k051960_sprites_draw(state->m_k051960, bitmap, cliprect, 1, 1);
		k051316_zoom_draw(state->m_k051316, bitmap, cliprect, 0, 0);
		k051960_sprites_draw(state->m_k051960, bitmap, cliprect, 0, 0);
		k052109_tilemap_draw(state->m_k052109, bitmap, cliprect, 2, 0, 0);
		/* note that priority 3 is opposite to the basic layer priority! */
		/* (it IS used, but hopefully has no effect) */
		k051960_sprites_draw(state->m_k051960, bitmap, cliprect, 2, 3);
		k052109_tilemap_draw(state->m_k052109, bitmap, cliprect, 1, 0, 0);
	}
	return 0;
}