summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/bus/vip/vp570.cpp
blob: 42ec4119c21ec7ad7d09c2179d2584f6c9f5d356 (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
// license:BSD-3-Clause
// copyright-holders:Curt Coder
/**********************************************************************

    RCA VIP Expansion Board VP-570 emulation

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

#include "vp570.h"



//**************************************************************************
//  DEVICE DEFINITIONS
//**************************************************************************

const device_type VP570 = &device_creator<vp570_device>;


//-------------------------------------------------
//  INPUT_PORTS( vp570 )
//-------------------------------------------------

static INPUT_PORTS_START( vp570 )
	PORT_START("BASE")
	PORT_DIPNAME( 0x07, 0x01, "Address Range" )
	PORT_DIPSETTING(    0x00, "0000 thru 0FFF" )
	PORT_DIPSETTING(    0x01, "1000 thru 1FFF" )
	PORT_DIPSETTING(    0x02, "2000 thru 2FFF" )
	PORT_DIPSETTING(    0x03, "3000 thru 3FFF" )
	PORT_DIPSETTING(    0x04, "4000 thru 4FFF" )
	PORT_DIPSETTING(    0x05, "5000 thru 50FFF" )
	PORT_DIPSETTING(    0x06, "6000 thru 6FFF" )
	PORT_DIPSETTING(    0x07, "7000 thru 7FFF" )

	PORT_START("SW1")
	PORT_DIPNAME( 0x01, 0x01, "Write Protect" )
	PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
	PORT_DIPSETTING(    0x00, DEF_STR( On ) )
INPUT_PORTS_END


//-------------------------------------------------
//  input_ports - device-specific input ports
//-------------------------------------------------

ioport_constructor vp570_device::device_input_ports() const
{
	return INPUT_PORTS_NAME( vp570 );
}



//**************************************************************************
//  LIVE DEVICE
//**************************************************************************

//-------------------------------------------------
//  vp570_device - constructor
//-------------------------------------------------

vp570_device::vp570_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
	device_t(mconfig, VP570, "VP570", tag, owner, clock, "vp570", __FILE__),
	device_vip_expansion_card_interface(mconfig, *this),
	m_ram(*this, "ram"),
	m_base(*this, "BASE"),
	m_sw1(*this, "SW1")
{
}


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

void vp570_device::device_start()
{
	m_ram.allocate(0x1000);
}


//-------------------------------------------------
//  vip_program_r - program read
//-------------------------------------------------

UINT8 vp570_device::vip_program_r(address_space &space, offs_t offset, int cs, int cdef, int *minh)
{
	UINT8 data = 0xff;

	offs_t base = m_base->read() << 12;

	if (offset >= base && offset < base + 0x1000)
	{
		*minh = 1;

		data = m_ram[offset & 0xfff];
	}

	return data;
}


//-------------------------------------------------
//  vip_program_w - program write
//-------------------------------------------------

void vp570_device::vip_program_w(address_space &space, offs_t offset, UINT8 data, int cdef, int *minh)
{
	offs_t base = m_base->read() << 12;

	if (offset >= base && offset < base + 0x1000)
	{
		*minh = 1;

		if (m_sw1->read())
		{
			m_ram[offset & 0xfff] = data;
		}
	}
}