summaryrefslogtreecommitdiffstatshomepage
path: root/src/emu/machine/k056230.c
blob: e37662323aa9d223cf41c01357cd3e9c99f85f7e (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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
/***************************************************************************

    Konami IC 056230 (LANC)

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

#include "emu.h"
#include "k056230.h"
#include "devhelpr.h"


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

// device type definition
const device_type K056230 = &device_creator<k056230_device>;

//-------------------------------------------------
//  k056230_device - constructor
//-------------------------------------------------

k056230_device::k056230_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
    : device_t(mconfig, K056230, "Konami 056230", tag, owner, clock)
{

}


//-------------------------------------------------
//  device_config_complete - perform any
//  operations now that the configuration is
//  complete
//-------------------------------------------------

void k056230_device::device_config_complete()
{
	// inherit a copy of the static data
	const k056230_interface *intf = reinterpret_cast<const k056230_interface *>(static_config());
	if (intf != NULL)
	{
		*static_cast<k056230_interface *>(this) = *intf;
	}

	// or initialize to defaults if none provided
	else
	{
		m_cpu_tag = NULL;
		m_is_thunderh = false;
	}
}


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

void k056230_device::device_start()
{
	if(m_cpu_tag)
	{
		m_cpu = machine().device(m_cpu_tag);
	}
	else
	{
		m_cpu = NULL;
	}

	m_ram = auto_alloc_array(machine(), UINT32, 0x2000);

	save_pointer(NAME(m_ram), 0x2000);
}


READ8_DEVICE_HANDLER_TRAMPOLINE(k056230, k056230_r)
{
	switch (offset)
	{
		case 0:		// Status register
		{
			return 0x08;
		}
	}

//  mame_printf_debug("k056230_r: %d at %08X\n", offset, space->device().safe_pc());

	return 0;
}

TIMER_CALLBACK( k056230_device::network_irq_clear_callback )
{
	reinterpret_cast<k056230_device*>(ptr)->network_irq_clear();
}

void k056230_device::network_irq_clear()
{
	if(m_cpu)
	{
		device_set_input_line(m_cpu, INPUT_LINE_IRQ2, CLEAR_LINE);
	}
}


WRITE8_DEVICE_HANDLER_TRAMPOLINE(k056230, k056230_w)
{
	switch(offset)
	{
		case 0:		// Mode register
		{
			break;
		}
		case 1:		// Control register
		{
			if(data & 0x20)
			{
				// Thunder Hurricane breaks otherwise...
				if(!m_is_thunderh)
				{
					if(m_cpu)
					{
						device_set_input_line(m_cpu, INPUT_LINE_IRQ2, ASSERT_LINE);
					}
					machine().scheduler().timer_set(attotime::from_usec(10), FUNC(network_irq_clear_callback), 0, (void*)this);
				}
			}
//          else
//              device_set_input_line(k056230->cpu, INPUT_LINE_IRQ2, CLEAR_LINE);
			break;
		}
		case 2:		// Sub ID register
		{
			break;
		}
	}
//  mame_printf_debug("k056230_w: %d, %02X at %08X\n", offset, data, space->device().safe_pc());
}

READ32_DEVICE_HANDLER_TRAMPOLINE(k056230, lanc_ram_r)
{
	//mame_printf_debug("LANC_RAM_r: %08X, %08X at %08X\n", offset, mem_mask, space->device().safe_pc());
	return m_ram[offset & 0x7ff];
}

WRITE32_DEVICE_HANDLER_TRAMPOLINE(k056230, lanc_ram_w)
{
	//mame_printf_debug("LANC_RAM_w: %08X, %08X, %08X at %08X\n", data, offset, mem_mask, space->device().safe_pc());
	COMBINE_DATA(m_ram + (offset & 0x7ff));
}