1 // license:BSD-3-Clause
2 // copyright-holders:David Haywood, Nicola Salmoria
3 #include "emu.h"
4 #include "includes/usgames.h"
5 
6 
usgames_palette(palette_device & palette) const7 void usgames_state::usgames_palette(palette_device &palette) const
8 {
9 	for (int j = 0; j < 16; j++)
10 	{
11 		int r = BIT(j, 0);
12 		int g = BIT(j, 1);
13 		int b = BIT(j, 2);
14 		int const i = BIT(j, 3);
15 
16 		r = 0xff * r;
17 		g = 0x7f * g * (i + 1);
18 		b = 0x7f * b * (i + 1);
19 
20 		palette.set_pen_color(j, rgb_t(r, g, b));
21 	}
22 }
23 
video_start()24 void usgames_state::video_start()
25 {
26 	m_gfxdecode->gfx(0)->set_source(m_charram);
27 }
28 
charram_w(offs_t offset,uint8_t data)29 void usgames_state::charram_w(offs_t offset, uint8_t data)
30 {
31 	m_charram[offset] = data;
32 	m_gfxdecode->gfx(0)->mark_dirty(offset/8);
33 }
34 
MC6845_UPDATE_ROW(usgames_state::update_row)35 MC6845_UPDATE_ROW(usgames_state::update_row)
36 {
37 	uint32_t *pix = &bitmap.pix(y);
38 	ra &= 0x07;
39 
40 	for (int x = 0; x < x_count; x++)
41 	{
42 		int tile_index = (x + ma) & (m_videoram.mask()/2);
43 		int tile = m_videoram[tile_index*2];
44 		int attr = m_videoram[tile_index*2+1];
45 		uint8_t bg_color = attr & 0xf;
46 		uint8_t fg_color = (attr & 0xf0) >> 4;
47 
48 		const uint8_t plane = m_charram[(tile << 3) | ra];
49 		for (int n = 7; n >= 0; n--)
50 			*pix++ = m_palette->pen(BIT(plane, n) ? fg_color : bg_color);
51 	}
52 }
53 
54