summaryrefslogtreecommitdiffstatshomepage
path: root/src/mame/video/blockhl.c
blob: b88f3c995c2b3629c66836ea177b24407fd15d11 (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
#include "emu.h"
#include "video/konicdev.h"
#include "includes/blockhl.h"


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

  Callbacks for the K052109

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

void blockhl_tile_callback( running_machine &machine, int layer, int bank, int *code, int *color, int *flags, int *priority )
{
	blockhl_state *state = machine.driver_data<blockhl_state>();
	*code |= ((*color & 0x0f) << 8);
	*color = state->m_layer_colorbase[layer] + ((*color & 0xe0) >> 5);
}

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

  Callbacks for the K051960

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

void blockhl_sprite_callback( running_machine &machine, int *code, int *color, int *priority, int *shadow )
{
	blockhl_state *state = machine.driver_data<blockhl_state>();

	if(*color & 0x10)
		*priority = 0xfe; // under K052109_tilemap[0]
	else
		*priority = 0xfc; // under K052109_tilemap[1]

	*color = state->m_sprite_colorbase + (*color & 0x0f);
}


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

    Start the video hardware emulation.

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

VIDEO_START( blockhl )
{
	blockhl_state *state = machine.driver_data<blockhl_state>();

	machine.generic.paletteram.u8 = auto_alloc_array(machine, UINT8, 0x800);

	state->m_layer_colorbase[0] = 0;
	state->m_layer_colorbase[1] = 16;
	state->m_layer_colorbase[2] = 32;
	state->m_sprite_colorbase = 48;

	state_save_register_global_pointer(machine, machine.generic.paletteram.u8, 0x800);
}

SCREEN_UPDATE( blockhl )
{
	blockhl_state *state = screen->machine().driver_data<blockhl_state>();

	bitmap_fill(screen->machine().priority_bitmap, cliprect, 0);

	k052109_tilemap_update(state->m_k052109);

	k052109_tilemap_draw(state->m_k052109, bitmap, cliprect, 2, TILEMAP_DRAW_OPAQUE, 0);	// tile 2
	k052109_tilemap_draw(state->m_k052109, bitmap, cliprect, 1, 0, 1);	// tile 1
	k052109_tilemap_draw(state->m_k052109, bitmap, cliprect, 0, 0, 2);	// tile 0

	k051960_sprites_draw(state->m_k051960, bitmap, cliprect, 0, -1);
	return 0;
}