summaryrefslogtreecommitdiffstatshomepage
path: root/src/mame/video/osi.cpp
blob: e19fa3c354715cea4beab852b5a2c9bf7d82a84e (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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
// license:BSD-3-Clause
// copyright-holders:Curt Coder, Robbbert, Wilbert Pol
#include "includes/osi.h"

/* Palette Initialization */

PALETTE_INIT_MEMBER(sb2m600_state, osi630)
{
	/* black and white */
	palette.set_pen_color(0, 0x00, 0x00, 0x00); // black
	palette.set_pen_color(1, 0xff, 0xff, 0xff); // white

	/* color enabled */
	palette.set_pen_color(2, 0xff, 0xff, 0x00); // yellow
	palette.set_pen_color(3, 0xff, 0x00, 0x00); // red
	palette.set_pen_color(4, 0x00, 0xff, 0x00); // green
	palette.set_pen_color(5, 0x00, 0x80, 0x00); // olive green
	palette.set_pen_color(6, 0x00, 0x00, 0xff); // blue
	palette.set_pen_color(7, 0xff, 0x00, 0xff); // purple
	palette.set_pen_color(8, 0x00, 0x00, 0x80); // sky blue
	palette.set_pen_color(9, 0x00, 0x00, 0x00); // black
}

/* Video Start */

void sb2m600_state::video_start()
{
	m_p_chargen = memregion("chargen")->base();
	uint16_t addr;

	/* randomize video memory contents */
	for (addr = 0; addr < OSI600_VIDEORAM_SIZE; addr++)
		m_video_ram[addr] = machine().rand() & 0xff;

	/* randomize color memory contents */
	if (m_color_ram)
		for (addr = 0; addr < OSI630_COLORRAM_SIZE; addr++)
			m_color_ram[addr] = machine().rand() & 0x0f;
}

/* Video Update */

uint32_t sb2m600_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
{
	int y, bit, sx;

	if (m_32)
	{
		for (y = 0; y < 256; y++)
		{
			uint16_t videoram_addr = (y >> 4) * 64;
			int line = (y >> 1) & 0x07;
			int x = 0;

			for (sx = 0; sx < 64; sx++)
			{
				uint8_t videoram_data = m_video_ram[videoram_addr];
				uint16_t charrom_addr = ((videoram_data << 3) | line) & 0x7ff;
				uint8_t charrom_data = m_p_chargen[charrom_addr];

				for (bit = 0; bit < 8; bit++)
				{
					bool color = BIT(charrom_data, 7);

					if (m_coloren)
					{
						uint8_t colorram_data = m_color_ram[videoram_addr];
						color = (color ^ BIT(colorram_data, 0)) ? (((colorram_data >> 1) & 0x07) + 2) : 0;
					}

					bitmap.pix16(y, x++) = color;

					charrom_data <<= 1;
				}

				videoram_addr++;
			}
		}
	}
	else
	{
		for (y = 0; y < 256; y++)
		{
			uint16_t videoram_addr = (y >> 3) * 32;
			int line = y & 0x07;
			int x = 0;

			for (sx = 0; sx < 32; sx++)
			{
				uint8_t videoram_data = m_video_ram[videoram_addr];
				uint16_t charrom_addr = ((videoram_data << 3) | line) & 0x7ff;
				uint8_t charrom_data = m_p_chargen[charrom_addr];

				for (bit = 0; bit < 8; bit++)
				{
					bool color = BIT(charrom_data, 7);

					if (m_coloren)
					{
						uint8_t colorram_data = m_color_ram[videoram_addr];
						color = (color ^ BIT(colorram_data, 0)) ? (((colorram_data >> 1) & 0x07) + 2) : 0;
					}

					bitmap.pix16(y, x++) = color;
					bitmap.pix16(y, x++) = color;

					charrom_data <<= 1;
				}

				videoram_addr++;
			}
		}
	}

	return 0;
}

uint32_t uk101_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
{
	int y, bit, sx;

	for (y = 0; y < 256; y++)
	{
		uint16_t videoram_addr = (y >> 4) * 64;
		int line = (y >> 1) & 0x07;
		int x = 0;

		for (sx = 0; sx < 64; sx++)
		{
			uint8_t videoram_data = m_video_ram[videoram_addr++];
			uint16_t charrom_addr = ((videoram_data << 3) | line) & 0x7ff;
			uint8_t charrom_data = m_p_chargen[charrom_addr];

			for (bit = 0; bit < 8; bit++)
			{
				bitmap.pix16(y, x) = BIT(charrom_data, 7);
				x++;
				charrom_data <<= 1;
			}
		}
	}

	return 0;
}

/* Machine Drivers */

MACHINE_CONFIG_FRAGMENT( osi600_video )
	MCFG_SCREEN_ADD(SCREEN_TAG, RASTER)
	MCFG_SCREEN_REFRESH_RATE(X1/256/256) // 60 Hz
	MCFG_SCREEN_UPDATE_DRIVER(sb2m600_state, screen_update)
	MCFG_SCREEN_SIZE(64*8, 32*8)
	MCFG_SCREEN_VISIBLE_AREA(0*8, 64*8-1, 0, 32*8-1)
	MCFG_SCREEN_PALETTE("palette")

	MCFG_PALETTE_ADD_MONOCHROME("palette")
MACHINE_CONFIG_END

MACHINE_CONFIG_FRAGMENT( uk101_video )
	MCFG_SCREEN_ADD(SCREEN_TAG, RASTER)
	MCFG_SCREEN_REFRESH_RATE(50)
	MCFG_SCREEN_UPDATE_DRIVER(uk101_state, screen_update)
	MCFG_SCREEN_SIZE(64*8, 16*16)
	MCFG_SCREEN_VISIBLE_AREA(0, 64*8-1, 0, 16*16-1)
	MCFG_SCREEN_PALETTE("palette")

	MCFG_PALETTE_ADD_MONOCHROME("palette")
MACHINE_CONFIG_END

MACHINE_CONFIG_FRAGMENT( osi630_video )
	MCFG_SCREEN_ADD(SCREEN_TAG, RASTER)
	MCFG_SCREEN_REFRESH_RATE(X1/256/256) // 60 Hz
	MCFG_SCREEN_UPDATE_DRIVER(sb2m600_state, screen_update)
	MCFG_SCREEN_SIZE(64*8, 16*16)
	MCFG_SCREEN_VISIBLE_AREA(0, 64*8-1, 0, 16*16-1)
	MCFG_SCREEN_PALETTE("palette")

	MCFG_PALETTE_ADD("palette", 8+2)
	MCFG_PALETTE_INIT_OWNER(sb2m600_state, osi630)
MACHINE_CONFIG_END