summaryrefslogtreecommitdiffstatshomepage
path: root/src/emu/machine/rf5c296.c
blob: 3b530a97669863187eec236f96cb47dbea735c4e (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
#include "rf5c296.h"

// rf5c296 is very inaccurate at that point, it hardcodes the gnet config

const device_type RF5C296 = &device_creator<rf5c296_device>;

rf5c296_device::rf5c296_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
	device_t(mconfig, PCCARD_SLOT, "PCCARD SLOT", tag, owner, clock, "pccard", __FILE__)
{
}

void rf5c296_device::device_start()
{
	m_pccard = machine().device<pccard_slot_device>(m_pccard_name);
}

void rf5c296_device::reg_w(ATTR_UNUSED UINT8 reg, UINT8 data)
{
	//  fprintf(stderr, "rf5c296_reg_w %02x, %02x (%s)\n", reg, data, machine().describe_context());
	switch (reg)
	{
		// Interrupt and General Control Register
		case 0x03:
			// Check for card reset
			if (!(data & 0x40))
			{
				m_pccard->reset();
			}
			break;

		default:
			break;
	}
}

UINT8 rf5c296_device::reg_r(ATTR_UNUSED UINT8 reg)
{
	//  fprintf(stderr, "rf5c296_reg_r %02x (%s)\n", reg, machine().describe_context());
	return 0x00;
}

WRITE16_MEMBER(rf5c296_device::io_w)
{
	/// TODO: find out if this should be done here.
	offset *= 2;
	if (mem_mask == 0xff00)
	{
		mem_mask >>= 8;
		data >>= 8;
		offset++;
	}

	switch(offset)
	{
	case 0x3e0:
		m_rf5c296_reg = data;
		break;

	case 0x3e1:
		reg_w(m_rf5c296_reg, data);
		break;

	default:
		m_pccard->write_memory(space, offset, data, mem_mask);
		break;
	}
}

READ16_MEMBER(rf5c296_device::io_r)
{
	/// TODO: find out if this should be done here.
	offset *= 2;
	int shift = 0;
	if (mem_mask == 0xff00)
	{
		shift = 8;
		mem_mask >>= 8;
		offset++;
	}

	UINT16 data;

	switch( offset )
	{
	case 0x3e0:
		data = m_rf5c296_reg;
		break;

	case 0x3e1:
		data = reg_r(m_rf5c296_reg);
		break;

	default:
		data = m_pccard->read_memory(space, offset, mem_mask);
		break;
	}

	return data << shift;
}

// Hardcoded to reach the pcmcia CIS

READ16_MEMBER(rf5c296_device::mem_r)
{
	return m_pccard->read_reg(space, offset, mem_mask);
}

WRITE16_MEMBER(rf5c296_device::mem_w)
{
	m_pccard->write_reg(space, offset, data, mem_mask);
}