summaryrefslogtreecommitdiffstatshomepage
path: root/src/emu/machine/k056230.c
blob: fe55c4bbeab9fdb3da164959c4163c16bf26c834 (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
/***************************************************************************

    Konami IC 056230 (LANC)

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

#include "driver.h"
#include "k056230.h"

/***************************************************************************
    TYPE DEFINITIONS
***************************************************************************/

typedef struct _k056230_state k056230_state;
struct _k056230_state
{
	UINT32  *    ram;
	int          is_thunderh;

	const device_config *cpu;
};

/*****************************************************************************
    INLINE FUNCTIONS
*****************************************************************************/

INLINE k056230_state *k056230_get_safe_token( const device_config *device )
{
	assert(device != NULL);
	assert(device->token != NULL);
	assert(device->type == K056230);

	return (k056230_state *)device->token;
}

INLINE const k056230_interface *k056230_get_interface( const device_config *device )
{
	assert(device != NULL);
	assert((device->type == K056230));
	return (const k056230_interface *) device->static_config;
}

/*****************************************************************************
    DEVICE HANDLERS
*****************************************************************************/

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

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

	return 0;
}

static TIMER_CALLBACK( network_irq_clear )
{
	k056230_state *k056230 = (k056230_state *)ptr;
	cpu_set_input_line(k056230->cpu, INPUT_LINE_IRQ2, CLEAR_LINE);
}

WRITE8_DEVICE_HANDLER( k056230_w )
{
	k056230_state *k056230 = k056230_get_safe_token(device);

	switch (offset)
	{
		case 0:		// Mode register
		{
			break;
		}
		case 1:		// Control register
		{
			if (data & 0x20)
			{
				// Thunder Hurricane breaks otherwise...
				if (!k056230->is_thunderh)
				{
					cpu_set_input_line(k056230->cpu, INPUT_LINE_IRQ2, ASSERT_LINE);
					timer_set(device->machine, ATTOTIME_IN_USEC(10), k056230, 0, network_irq_clear);
				}
			}
//          else
//              cpu_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, cpu_get_pc(space->cpu));
}

READ32_DEVICE_HANDLER( lanc_ram_r )
{
	k056230_state *k056230 = k056230_get_safe_token(device);

	//mame_printf_debug("LANC_RAM_r: %08X, %08X at %08X\n", offset, mem_mask, cpu_get_pc(space->cpu));
	return k056230->ram[offset & 0x7ff];
}

WRITE32_DEVICE_HANDLER( lanc_ram_w )
{
	k056230_state *k056230 = k056230_get_safe_token(device);

	//mame_printf_debug("LANC_RAM_w: %08X, %08X, %08X at %08X\n", data, offset, mem_mask, cpu_get_pc(space->cpu));
	COMBINE_DATA(k056230->ram + (offset & 0x7ff));
}

/*****************************************************************************
    DEVICE INTERFACE
*****************************************************************************/

static DEVICE_START( k056230 )
{
	k056230_state *k056230 = k056230_get_safe_token(device);
	const k056230_interface *intf = k056230_get_interface(device);

	k056230->cpu = devtag_get_device(device->machine, intf->cpu);
	k056230->is_thunderh = intf->is_thunderh;

	k056230->ram = auto_alloc_array(device->machine, UINT32, 0x2000);

	state_save_register_device_item_pointer(device, 0, k056230->ram, 0x2000);
}

/*-------------------------------------------------
    device definition
-------------------------------------------------*/

static const char DEVTEMPLATE_SOURCE[] = __FILE__;

#define DEVTEMPLATE_ID( p, s )	p##k056230##s
#define DEVTEMPLATE_FEATURES	      DT_HAS_START
#define DEVTEMPLATE_NAME		"Konami 056230"
#define DEVTEMPLATE_FAMILY		"Konami Network Board 056230"
#define DEVTEMPLATE_CLASS		DEVICE_CLASS_PERIPHERAL
#include "devtempl.h"