summaryrefslogtreecommitdiffstatshomepage
path: root/src/mame/video/ultraman.c
blob: 3d2328f916352f2725b874c90c5a79e2a0ca65b3 (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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#include "emu.h"
#include "video/konicdev.h"
#include "includes/ultraman.h"

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

  Callbacks for the K051960

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

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

	*priority = (*color & 0x80) >> 7;
	*color = state->m_sprite_colorbase + ((*color & 0x7e) >> 1);
	*shadow = 0;
}


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

  Callbacks for the K051316

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

void ultraman_zoom_callback_0(running_machine &machine, int *code, int *color, int *flags )
{
	ultraman_state *state = machine.driver_data<ultraman_state>();
	*code |= ((*color & 0x07) << 8) | (state->m_bank0 << 11);
	*color = state->m_zoom_colorbase[0] + ((*color & 0xf8) >> 3);
}

void ultraman_zoom_callback_1(running_machine &machine, int *code, int *color, int *flags )
{
	ultraman_state *state = machine.driver_data<ultraman_state>();
	*code |= ((*color & 0x07) << 8) | (state->m_bank1 << 11);
	*color = state->m_zoom_colorbase[1] + ((*color & 0xf8) >> 3);
}

void ultraman_zoom_callback_2(running_machine &machine, int *code, int *color, int *flags )
{
	ultraman_state *state = machine.driver_data<ultraman_state>();
	*code |= ((*color & 0x07) << 8) | (state->m_bank2 << 11);
	*color = state->m_zoom_colorbase[2] + ((*color & 0xf8) >> 3);
}



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

    Start the video hardware emulation.

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

VIDEO_START( ultraman )
{
	ultraman_state *state = machine.driver_data<ultraman_state>();
	state->m_sprite_colorbase = 192;
	state->m_zoom_colorbase[0] = 0;
	state->m_zoom_colorbase[1] = 64;
	state->m_zoom_colorbase[2] = 128;
}



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

  Memory handlers

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

WRITE16_HANDLER( ultraman_gfxctrl_w )
{
	ultraman_state *state = space->machine().driver_data<ultraman_state>();

	if (ACCESSING_BITS_0_7)
	{
		/*  bit 0: enable wraparound for scr #1
            bit 1: msb of code for scr #1
            bit 2: enable wraparound for scr #2
            bit 3: msb of code for scr #2
            bit 4: enable wraparound for scr #3
            bit 5: msb of code for scr #3
            bit 6: coin counter 1
            bit 7: coin counter 2 */

		k051316_wraparound_enable(state->m_k051316_1, data & 0x01);

		if (state->m_bank0 != ((data & 0x02) >> 1))
		{
			state->m_bank0 = (data & 0x02) >> 1;
			tilemap_mark_all_tiles_dirty_all(space->machine());	/* should mark only zoom0 */
		}

		k051316_wraparound_enable(state->m_k051316_2, data & 0x04);

		if (state->m_bank1 != ((data & 0x08) >> 3))
		{
			state->m_bank1 = (data & 0x08) >> 3;
			tilemap_mark_all_tiles_dirty_all(space->machine());	/* should mark only zoom1 */
		}

		k051316_wraparound_enable(state->m_k051316_3, data & 0x10);

		if (state->m_bank2 != ((data & 0x20) >> 5))
		{
			state->m_bank2 = (data & 0x20) >> 5;
			tilemap_mark_all_tiles_dirty_all(space->machine());	/* should mark only zoom2 */
		}

		coin_counter_w(space->machine(), 0, data & 0x40);
		coin_counter_w(space->machine(), 1, data & 0x80);
	}
}



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

    Display Refresh

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

SCREEN_UPDATE( ultraman )
{
	ultraman_state *state = screen->machine().driver_data<ultraman_state>();

	k051316_zoom_draw(state->m_k051316_3, bitmap, cliprect, 0, 0);
	k051316_zoom_draw(state->m_k051316_2, bitmap, cliprect, 0, 0);
	k051960_sprites_draw(state->m_k051960, bitmap, cliprect, 0, 0);
	k051316_zoom_draw(state->m_k051316_1, bitmap, cliprect, 0, 0);
	k051960_sprites_draw(state->m_k051960, bitmap, cliprect, 1, 1);
	return 0;
}