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
|
// license:BSD-3-Clause
// copyright-holders:Enik Land
/**********************************************************************
Sega SG-1000 expansion slot emulation
**********************************************************************/
#include "emu.h"
#include "sg1000exp.h"
// slot devices
#include "sk1100.h"
#include "fm_unit.h"
//**************************************************************************
// GLOBAL VARIABLES
//**************************************************************************
DEFINE_DEVICE_TYPE(SG1000_EXPANSION_SLOT, sg1000_expansion_slot_device, "sg1000_expansion_slot", "Sega SG-1000 expansion slot")
//**************************************************************************
// CARD INTERFACE
//**************************************************************************
//-------------------------------------------------
// device_sg1000_expansion_slot_interface - constructor
//-------------------------------------------------
device_sg1000_expansion_slot_interface::device_sg1000_expansion_slot_interface(const machine_config &mconfig, device_t &device) :
device_interface(device, "sg1000exp")
{
}
//-------------------------------------------------
// ~device_sg1000_expansion_slot_interface - destructor
//-------------------------------------------------
device_sg1000_expansion_slot_interface::~device_sg1000_expansion_slot_interface()
{
}
//**************************************************************************
// LIVE DEVICE
//**************************************************************************
//-------------------------------------------------
// sg1000_expansion_slot_device - constructor
//-------------------------------------------------
sg1000_expansion_slot_device::sg1000_expansion_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, const XTAL &clock) :
device_t(mconfig, SG1000_EXPANSION_SLOT, tag, owner, clock),
device_single_card_slot_interface<device_sg1000_expansion_slot_interface>(mconfig, *this),
m_device(nullptr)
{
}
//-------------------------------------------------
// sg1000_expansion_slot_device - destructor
//-------------------------------------------------
sg1000_expansion_slot_device::~sg1000_expansion_slot_device()
{
}
//-------------------------------------------------
// device_start - device-specific startup
//-------------------------------------------------
void sg1000_expansion_slot_device::device_start()
{
m_device = get_card_device();
}
// Address offsets are masked with 0x07 because the SG-1000 expansion slot
// has only 3 address lines (A0, A1, A2).
uint8_t sg1000_expansion_slot_device::read(offs_t offset)
{
uint8_t data = 0xff;
if (m_device)
data = m_device->peripheral_r(offset & 0x07);
return data;
}
void sg1000_expansion_slot_device::write(offs_t offset, uint8_t data)
{
if (m_device)
m_device->peripheral_w(offset & 0x07, data);
}
bool sg1000_expansion_slot_device::is_readable(uint8_t offset)
{
if (m_device)
return m_device->is_readable(offset & 0x07);
return false;
}
bool sg1000_expansion_slot_device::is_writeable(uint8_t offset)
{
if (m_device)
return m_device->is_writeable(offset & 0x07);
return false;
}
//-------------------------------------------------
// SLOT_INTERFACE( sg1000_expansion_devices )
//-------------------------------------------------
void sg1000_expansion_devices(device_slot_interface &device)
{
device.option_add("sk1100", SEGA_SK1100);
device.option_add("fm", SEGA_FM_UNIT);
}
|