summaryrefslogtreecommitdiffstats
path: root/src/mame/video/route16.cpp
blob: 97b71c584cd22443c840aceef9220c1df05e0f48 (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
136
137
138
139
140
141
142
143
144
145
146
147
148
// license:BSD-3-Clause
// copyright-holders:Zsolt Vasvari
/***************************************************************************

  route16.cpp

  Functions to emulate the video hardware of the machine.

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

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

void route16_state::video_start()
{
	save_item(NAME(m_flipscreen));
	save_item(NAME(m_palette_1));
	save_item(NAME(m_palette_2));
}

/*************************************
 *
 *  Memory handlers
 *
 *************************************/

void route16_state::out0_w(uint8_t data)
{
	m_palette_1 = data & 0x1f;

	machine().bookkeeping().coin_counter_w(0, (data >> 5) & 0x01);
}


void route16_state::out1_w(uint8_t data)
{
	m_palette_2 = data & 0x1f;

	m_flipscreen = (data >> 5) & 0x01;
}



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

/*
 *  Game observation shows that Route 16 can blank each
 *  bitmap by setting bit 1 of the palette register.
 *  Since the schematics are missing the relevant pages, I
 *  cannot confirm how this works, but I am 99% sure the bit 1
 *  would be connected to A7 of the color PROM.  Since the
 *  color PROMs contain 0 in the upper half, this would produce
 *  a black output.
 */

uint32_t route16_state::screen_update_route16(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect)
{
	uint8_t *color_prom1 = &memregion("proms")->base()[0x000];
	uint8_t *color_prom2 = &memregion("proms")->base()[0x100];

	for (offs_t offs = 0; offs < m_videoram1.bytes(); offs++)
	{
		uint8_t y = offs >> 6;
		uint8_t x = offs << 2;

		uint8_t data1 = m_videoram1[offs];
		uint8_t data2 = m_videoram2[offs];

		for (int i = 0; i < 4; i++)
		{
			uint8_t color1 = color_prom1[((m_palette_1 << 6) & 0x80) |
										(m_palette_1 << 2) |
										((data1 >> 3) & 0x02) |
										((data1 >> 0) & 0x01)];

			/* bit 7 of the 2nd color is the OR of the 1st color bits 0 and 1 - this is a guess */
			uint8_t color2 = color_prom2[((m_palette_2 << 6) & 0x80) | (((color1 << 6) & 0x80) | ((color1 << 7) & 0x80)) |
										(m_palette_2 << 2) |
										((data2 >> 3) & 0x02) |
										((data2 >> 0) & 0x01)];

			/* the final color is the OR of the two colors (verified) */
			uint8_t final_color = (color1 | color2) & 0x07;

			if (m_flipscreen)
				bitmap.pix(255 - y, 255 - x) = m_palette->pen_color(final_color);
			else
				bitmap.pix(y, x) = m_palette->pen_color(final_color);

			x++;
			data1 >>= 1;
			data2 >>= 1;
		}
	}

	return 0;
}


/*
 *  The Stratovox video connections have been verified from the schematics
 */

uint32_t route16_state::screen_update_jongpute(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect)
{
	uint8_t *color_prom1 = &memregion("proms")->base()[0x000];
	uint8_t *color_prom2 = &memregion("proms")->base()[0x100];

	for (offs_t offs = 0; offs < m_videoram1.bytes(); offs++)
	{
		uint8_t y = offs >> 6;
		uint8_t x = offs << 2;

		uint8_t data1 = m_videoram1[offs];
		uint8_t data2 = m_videoram2[offs];

		for (int i = 0; i < 4; i++)
		{
			uint8_t color1 = color_prom1[(m_palette_1 << 2) |
										((data1 >> 3) & 0x02) |
										((data1 >> 0) & 0x01)];

			/* bit 7 of the 2nd color is the OR of the 1st color bits 0 and 1 (verified) */
			uint8_t color2 = color_prom2[(((data1 << 3) & 0x80) | ((data1 << 7) & 0x80)) |
										(m_palette_2 << 2) |
										((data2 >> 3) & 0x02) |
										((data2 >> 0) & 0x01)];

			/* the final color is the OR of the two colors */
			uint8_t final_color = (color1 | color2) & 0x07;

			if (m_flipscreen)
				bitmap.pix(255 - y, 255 - x) = m_palette->pen_color(final_color);
			else
				bitmap.pix(y, x) = m_palette->pen_color(final_color);

			x++;
			data1 >>= 1;
			data2 >>= 1;
		}
	}

	return 0;
}