summaryrefslogtreecommitdiffstats
path: root/src/mame/video/vsystem_gga.cpp
blob: 945c813af426aa97c517e9f915e2c5bd6e2e4eca (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
// license:BSD-3-Clause
// copyright-holders:AJR
/******************************************************************************

    Video System C7-01 GGA (Graphics Gate Array?)

    Skeleton device.

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

#include "emu.h"
#include "vsystem_gga.h"


//**************************************************************************
//  VIDEO SYSTEM GGA DEVICE
//**************************************************************************

// device type definition
DEFINE_DEVICE_TYPE(VSYSTEM_GGA, vsystem_gga_device, "vsystem_gga", "Video System C7-01 GGA")

//-------------------------------------------------
//  vsystem_gga_device - constructor
//-------------------------------------------------

vsystem_gga_device::vsystem_gga_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock)
	: device_t(mconfig, VSYSTEM_GGA, tag, owner, clock),
		device_video_interface(mconfig, *this, false),
		m_write_cb(*this)
{
}

//-------------------------------------------------
//  device_start - device-specific startup
//-------------------------------------------------

void vsystem_gga_device::device_start()
{
	m_write_cb.resolve();

	m_address_latch = 0;
	for (u8 &reg : m_regs)
		reg = 0;

	save_item(NAME(m_address_latch));
	save_item(NAME(m_regs));
}

//-------------------------------------------------
//  write - register write handler
//-------------------------------------------------

void vsystem_gga_device::write(offs_t offset, u8 data)
{
	if (offset & 1)
	{
		// address write
		m_address_latch = data & 0x0f;
	}
	else
	{
		// data write
		m_regs[m_address_latch] = data;
		if (m_write_cb.isnull())
			logerror("Setting register $%02x = %02x\n", m_address_latch, data);
		else
			m_write_cb(m_address_latch, data, 0xff);
	}
}