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
|
// license:BSD-3-Clause
// copyright-holders:Enik Land
/**********************************************************************
Sega FM Sound Unit emulation
Release data from the Sega Retro project:
Year: 1987 Country/region: JP Model code: FM-70
**********************************************************************/
#include "fm_unit.h"
//**************************************************************************
// DEVICE DEFINITIONS
//**************************************************************************
const device_type SEGA_FM_UNIT = &device_creator<sega_fm_unit_device>;
static MACHINE_CONFIG_FRAGMENT( fm_config )
MCFG_SOUND_ADD("ym2413", YM2413, XTAL_10_738635MHz/3)
MCFG_SOUND_ROUTE(ALL_OUTPUTS, ":mono", 1.00)
MACHINE_CONFIG_END
machine_config_constructor sega_fm_unit_device::device_mconfig_additions() const
{
return MACHINE_CONFIG_NAME( fm_config );
}
//**************************************************************************
// LIVE DEVICE
//**************************************************************************
//-------------------------------------------------
// sega_fm_unit_device - constructor
//-------------------------------------------------
sega_fm_unit_device::sega_fm_unit_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
device_t(mconfig, SEGA_FM_UNIT, "Sega FM Sound Unit", tag, owner, clock, "sega_fm_unit", __FILE__),
device_sg1000_expansion_slot_interface(mconfig, *this),
m_ym(*this, "ym2413"),
m_audio_control(0)
{
}
//-------------------------------------------------
// device_start - device-specific startup
//-------------------------------------------------
void sega_fm_unit_device::device_start()
{
/* register for state saving */
save_item(NAME(m_audio_control));
}
//-------------------------------------------------
// peripheral_r - fm unit read
//-------------------------------------------------
READ8_MEMBER(sega_fm_unit_device::peripheral_r)
{
if (offset == 2)
{
return m_audio_control & 0x01;
}
// will not be called for other offsets.
return 0xff;
}
//-------------------------------------------------
// peripheral_w - fm unit write
//-------------------------------------------------
WRITE8_MEMBER(sega_fm_unit_device::peripheral_w)
{
switch (offset)
{
case 0: // register port
if (m_audio_control == 0x01)
{
m_ym->write(space, 0, data & 0x3f);
}
break;
case 1: // data port
if (m_audio_control == 0x01)
{
m_ym->write(space, 1, data);
}
break;
case 2: // control port
m_audio_control = data & 0x01;
break;
default:
break;
}
}
bool sega_fm_unit_device::is_readable(UINT8 offset)
{
return (offset == 2) ? true : false;
}
bool sega_fm_unit_device::is_writeable(UINT8 offset)
{
return (offset <= 2) ? true : false;
}
|