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
|
#include "emu.h"
#include "music.h"
const device_type MSX_SLOT_MUSIC = &device_creator<msx_slot_music_device>;
msx_slot_music_device::msx_slot_music_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
: msx_slot_rom_device(mconfig, MSX_SLOT_MUSIC, "MSX Internal MSX-MUSIC", tag, owner, clock, "msx_slot_music", __FILE__)
, m_ym2413(NULL)
, m_ym2413_tag(NULL)
, m_opll_active(false)
, m_unlock(0)
{
}
void msx_slot_music_device::device_start()
{
msx_slot_rom_device::device_start();
if (m_ym2413_tag == NULL)
{
fatalerror("msx_slot_music_device: no YM2413 tag specified\n");
}
m_ym2413 = owner()->subdevice<ym2413_device>(m_ym2413_tag);
if (m_ym2413 == NULL)
{
fatalerror("msx_slot_ym2413_device: Unable to find YM2413 with tag '%s'\n", m_ym2413_tag);
}
// Install IO read/write handlers
address_space &space = machine().device<cpu_device>("maincpu")->space(AS_IO);
space.install_write_handler(0x7c, 0x7d, write8_delegate(FUNC(msx_slot_music_device::write_ym2413), this));
}
void msx_slot_music_device::device_reset()
{
m_opll_active = false;
}
READ8_MEMBER(msx_slot_music_device::read)
{
return msx_slot_rom_device::read(space, offset);
}
WRITE8_MEMBER(msx_slot_music_device::write)
{
if (m_unlock == 0xbe && data == 0x41)
{
m_opll_active = true;
}
m_unlock = data;
}
WRITE8_MEMBER(msx_slot_music_device::write_ym2413)
{
if (m_opll_active)
{
m_ym2413->write(space, offset & 1, data);
}
}
|