summaryrefslogtreecommitdiffstatshomepage
path: root/src/mame/video/vs920a.cpp
blob: 23a61c540bcf23d86b0756cb5c5c4d3e645f3635 (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
// license:BSD-3-Clause
// copyright-holders:David Haywood

// currently used by gstriker.c, apparently inufuku uses the same chip

/*** VS920A (score tilemap) **********************************************/

/*

    VS920A - (Very) Simple tilemap chip
    -----------------------------------

- 1 Plane
- Tiles 8x8, 4bpp
- Map 64x64
- No scrolling or other effects (at least in gstriker)


    Videoram format:
    ----------------

pppp tttt tttt tttt

t=tile, p=palette

*/


#include "emu.h"
#include "vs920a.h"


DEFINE_DEVICE_TYPE(VS920A, vs920a_text_tilemap_device, "vs920a", "VS920A Text Tilemap")

vs920a_text_tilemap_device::vs920a_text_tilemap_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
	: device_t(mconfig, VS920A, tag, owner, clock)
	, m_tmap(nullptr)
	, m_vram()
	, m_pal_base(0)
	, m_gfx_region(0)
	, m_gfxdecode(*this, finder_base::DUMMY_TAG)
{
}


void vs920a_text_tilemap_device::device_start()
{
	if (!m_gfxdecode->started())
		throw device_missing_dependencies();

	m_vram = make_unique_clear<uint16_t[]>(0x1000/2);
	save_pointer(NAME(m_vram.get()), 0x1000/2);
	save_item(NAME(m_pal_base));


	m_tmap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(FUNC(vs920a_text_tilemap_device::get_tile_info),this),TILEMAP_SCAN_ROWS,8,8,64,32);
	m_tmap->set_transparent_pen(0);
}

void vs920a_text_tilemap_device::device_reset()
{
}


void vs920a_text_tilemap_device::set_gfx_region(int gfxregion)
{
	m_gfx_region = gfxregion;
}

void vs920a_text_tilemap_device::set_gfxdecode_tag(const char *tag)
{
	m_gfxdecode.set_tag(tag);
}



TILE_GET_INFO_MEMBER(vs920a_text_tilemap_device::get_tile_info)
{
	int data;
	int tileno, pal;

	data = m_vram[tile_index];

	tileno = data & 0xFFF;
	pal =   (data >> 12) & 0xF;

	SET_TILE_INFO_MEMBER(m_gfx_region, tileno, m_pal_base + pal, 0);
}

WRITE16_MEMBER(vs920a_text_tilemap_device::vram_w)
{
	COMBINE_DATA(&m_vram[offset]);
	m_tmap->mark_tile_dirty(offset);
}


READ16_MEMBER(vs920a_text_tilemap_device::vram_r)
{
	return m_vram[offset];
}


void vs920a_text_tilemap_device::draw(screen_device &screen, bitmap_ind16& bitmap, const rectangle &cliprect, int priority)
{
	m_tmap->draw(screen, bitmap, cliprect, 0, priority);
}