summaryrefslogtreecommitdiffstatshomepage
path: root/src/mame/video/crgolf.cpp
blob: a12e514fc68d0628d073661c5167bbd228ce419a (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
// license:BSD-3-Clause
// copyright-holders:Aaron Giles
/***************************************************************************

    Kitco Crowns Golf hardware

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

#include "emu.h"
#include "includes/crgolf.h"


#define NUM_PENS        (0x20)
#define VIDEORAM_SIZE   (0x2000 * 3)





/*************************************
 *
 *  Video startup
 *
 *************************************/

void crgolf_state::crgolf_palette(palette_device &palette) const
{
	uint8_t const *const prom = memregion("proms")->base();

	for (offs_t offs = 0; offs < NUM_PENS; offs++)
	{
		int bit0, bit1, bit2;

		uint8_t const data = prom[offs];

		// red component
		bit0 = BIT(data, 0);
		bit1 = BIT(data, 1);
		bit2 = BIT(data, 2);
		int const r = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;

		// green component
		bit0 = BIT(data, 3);
		bit1 = BIT(data, 4);
		bit2 = BIT(data, 5);
		int const g = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;

		// blue component
		bit0 = BIT(data, 6);
		bit1 = BIT(data, 7);
		int const b = 0x4f * bit0 + 0xa8 * bit1;

		m_palette->set_pen_color(offs, r, g, b);
	}
}

void crgolf_state::mastrglf_palette(palette_device &palette) const
{
}

/*************************************
 *
 *  Video update
 *
 *************************************/

uint32_t crgolf_state::screen_update_crgolf(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
{
	int flip = m_screen_flip;

	offs_t offs;

	/* for each byte in the video RAM */
	for (offs = 0; offs < VIDEORAM_SIZE / 3; offs++)
	{
		int i;

		uint8_t y = (offs & 0x1fe0) >> 5;
		uint8_t x = (offs & 0x001f) << 3;

		uint8_t data_a0 = m_videoram_a[0x2000 | offs];
		uint8_t data_a1 = m_videoram_a[0x0000 | offs];
		uint8_t data_a2 = m_videoram_a[0x4000 | offs];
		uint8_t data_b0 = m_videoram_b[0x2000 | offs];
		uint8_t data_b1 = m_videoram_b[0x0000 | offs];
		uint8_t data_b2 = m_videoram_b[0x4000 | offs];

		if (flip)
		{
			y = ~y;
			x = ~x;
		}

		/* for each pixel in the byte */
		for (i = 0; i < 8; i++)
		{
			offs_t color;
			uint8_t data_b = 0;
			uint8_t data_a = 0;

			if (!m_screena_enable)
				data_a = ((data_a0 & 0x80) >> 7) | ((data_a1 & 0x80) >> 6) | ((data_a2 & 0x80) >> 5);

			if (!m_screenb_enable)
				data_b = ((data_b0 & 0x80) >> 7) | ((data_b1 & 0x80) >> 6) | ((data_b2 & 0x80) >> 5);

			/* screen A has priority over B */
			if (data_a)
				color = data_a;
			else
				color = data_b | 0x08;

			/* add HI bit if enabled */
			if (m_color_select)
				color = color | 0x10;

			bitmap.pix16(y, x) = color;

			/* next pixel */
			data_a0 = data_a0 << 1;
			data_a1 = data_a1 << 1;
			data_a2 = data_a2 << 1;
			data_b0 = data_b0 << 1;
			data_b1 = data_b1 << 1;
			data_b2 = data_b2 << 1;

			if (flip)
				x = x - 1;
			else
				x = x + 1;
		}
	}

	return 0;
}