blob: 049e12cb9ed3167013e44be99f862aa618f892b5 (
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
|
/***************************************************************************
Midway 8080-based black and white hardware
****************************************************************************/
#include "emu.h"
#include "machine/mb14241.h"
typedef struct _mb14241_state mb14241_state;
struct _mb14241_state
{
UINT16 shift_data; /* 15 bits only */
UINT8 shift_count; /* 3 bits */
};
/*****************************************************************************
INLINE FUNCTIONS
*****************************************************************************/
INLINE mb14241_state *get_safe_token( device_t *device )
{
assert(device != NULL);
assert(device->type() == MB14241);
return (mb14241_state *)downcast<mb14241_device *>(device)->token();
}
/*****************************************************************************
IMPLEMENTATION
*****************************************************************************/
WRITE8_DEVICE_HANDLER( mb14241_shift_count_w )
{
mb14241_state *mb14241 = get_safe_token(device);
mb14241->shift_count = ~data & 0x07;
}
WRITE8_DEVICE_HANDLER( mb14241_shift_data_w )
{
mb14241_state *mb14241 = get_safe_token(device);
mb14241->shift_data = (mb14241->shift_data >> 8) | ((UINT16)data << 7);
}
READ8_DEVICE_HANDLER( mb14241_shift_result_r )
{
mb14241_state *mb14241 = get_safe_token(device);
return mb14241->shift_data >> mb14241->shift_count;
}
/*****************************************************************************
DEVICE INTERFACE
*****************************************************************************/
static DEVICE_START( mb14241 )
{
mb14241_state *mb14241 = get_safe_token(device);
device->save_item(NAME(mb14241->shift_data));
device->save_item(NAME(mb14241->shift_count));
}
static DEVICE_RESET( mb14241 )
{
mb14241_state *mb14241 = get_safe_token(device);
mb14241->shift_data = 0;
mb14241->shift_count = 0;
}
DEVICE_GET_INFO(mb14241)
{
switch (state)
{
case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(mb14241_state); break;
case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(mb14241); break;
case DEVINFO_FCT_RESET: info->reset = DEVICE_RESET_NAME(mb14241); break;
case DEVINFO_STR_NAME: strcpy(info->s, "MB14241"); break;
}
}
const device_type MB14241 = &device_creator<mb14241_device>;
mb14241_device::mb14241_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
: device_t(mconfig, MB14241, "MB14241", tag, owner, clock)
{
m_token = global_alloc_array_clear(UINT8, sizeof(mb14241_state));
}
//-------------------------------------------------
// device_config_complete - perform any
// operations now that the configuration is
// complete
//-------------------------------------------------
void mb14241_device::device_config_complete()
{
}
//-------------------------------------------------
// device_start - device-specific startup
//-------------------------------------------------
void mb14241_device::device_start()
{
DEVICE_START_NAME( mb14241 )(this);
}
//-------------------------------------------------
// device_reset - device-specific reset
//-------------------------------------------------
void mb14241_device::device_reset()
{
DEVICE_RESET_NAME( mb14241 )(this);
}
|