summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/bus/electron/cart/tube.cpp
blob: e4cea6d5a491ed2d760bf0aa13cff912927809ba (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
// license:BSD-3-Clause
// copyright-holders:Nigel Barnes
/**********************************************************************

    Acorn Electron Tube Interface

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


#include "emu.h"
#include "tube.h"


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

DEFINE_DEVICE_TYPE(ELECTRON_TUBE, electron_tube_device, "electron_tube", "Acorn Electron Tube Interface")


//-------------------------------------------------
//  device_add_mconfig - add device configuration
//-------------------------------------------------

void electron_tube_device::device_add_mconfig(machine_config &config)
{
	/* tube port */
	BBC_TUBE_SLOT(config, m_tube, electron_tube_devices, nullptr);
	m_tube->irq_handler().set(DEVICE_SELF_OWNER, FUNC(electron_cartslot_device::irq_w));
}

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

//-------------------------------------------------
//  electron_tube_device - constructor
//-------------------------------------------------

electron_tube_device::electron_tube_device(const machine_config &mconfig, const char *tag, device_t *owner, const XTAL &clock)
	: device_t(mconfig, ELECTRON_TUBE, tag, owner, clock)
	, device_electron_cart_interface(mconfig, *this)
	, m_tube(*this, "tube")
{
}

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

void electron_tube_device::device_start()
{
}

//-------------------------------------------------
//  read - cartridge data read
//-------------------------------------------------

uint8_t electron_tube_device::read(offs_t offset, int infc, int infd, int romqa, int oe, int oe2)
{
	uint8_t data = 0xff;

	if (infc)
	{
		if (offset >= 0xe0 && offset < 0xf0)
		{
			data = m_tube->host_r(offset & 0x0f);
		}
	}
	else if (oe2)
	{
		data = m_rom[offset & 0x1fff];
	}

	return data;
}

//-------------------------------------------------
//  write - cartridge data write
//-------------------------------------------------

void electron_tube_device::write(offs_t offset, uint8_t data, int infc, int infd, int romqa, int oe, int oe2)
{
	if (infc)
	{
		if (offset >= 0xe0 && offset < 0xf0)
		{
			m_tube->host_w(offset & 0x0f, data);
		}
	}
}