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
|
// license: GPL-2.0+
// copyright-holders: Dirk Best
/***************************************************************************
Blue Alpha Sound Sampler for SAM Coupe
***************************************************************************/
#include "emu.h"
#include "machine/rescap.h"
#include "blue_sampler.h"
#include "speaker.h"
//**************************************************************************
// DEVICE DEFINITIONS
//**************************************************************************
DEFINE_DEVICE_TYPE(SAM_BLUE_SOUND_SAMPLER, sam_blue_sound_sampler_device, "blue_sampler", "Blue Alpha Sound Sampler")
//-------------------------------------------------
// device_add_mconfig - add device configuration
//-------------------------------------------------
void sam_blue_sound_sampler_device::device_add_mconfig(machine_config &config)
{
SPEAKER(config, "mono").front_center();
I8255A(config, m_ppi);
m_ppi->out_pa_callback().set("dac", FUNC(dac_byte_interface::data_w));
m_ppi->out_pb_callback().set(FUNC(sam_blue_sound_sampler_device::ppi_portb_w));
m_ppi->in_pc_callback().set(FUNC(sam_blue_sound_sampler_device::ppi_portc_r));
ZN426E(config, m_dac).add_route(ALL_OUTPUTS, "mono", 0.5);
// TODO: ZN449E ADC
// 555 with variable resistor ~19.342hz
TIMER(config, "timer").configure_periodic(FUNC(sam_blue_sound_sampler_device::clock_callback), PERIOD_OF_555_MONOSTABLE(RES_K(1), CAP_N(47)));
}
//**************************************************************************
// LIVE DEVICE
//**************************************************************************
//-------------------------------------------------
// sam_blue_sound_sampler_device - constructor
//-------------------------------------------------
sam_blue_sound_sampler_device::sam_blue_sound_sampler_device(const machine_config &mconfig, const char *tag, device_t *owner, const XTAL &clock) :
device_t(mconfig, SAM_BLUE_SOUND_SAMPLER, tag, owner, clock),
device_samcoupe_expansion_interface(mconfig, *this),
m_ppi(*this, "ppi"),
m_dac(*this, "dac"),
m_portc(0)
{
}
//-------------------------------------------------
// device_start - device-specific startup
//-------------------------------------------------
void sam_blue_sound_sampler_device::device_start()
{
// register for savestates
save_item(NAME(m_portc));
}
//**************************************************************************
// IMPLEMENTATION
//**************************************************************************
TIMER_DEVICE_CALLBACK_MEMBER( sam_blue_sound_sampler_device::clock_callback )
{
m_portc ^= 1;
}
void sam_blue_sound_sampler_device::ppi_portb_w(uint8_t data)
{
// 765432-- not used
// ------1- enable for adc
// -------0 enable for dac and ppi pc6
m_ppi->pc6_w(BIT(data, 0));
}
uint8_t sam_blue_sound_sampler_device::ppi_portc_r()
{
// 7------- not used
// -6------ from ppi pb0
// --5----- not used
// ---4---- busy output from zn449e adc
// ----321- not used
// -------- clock input from 555
return m_portc;
}
uint8_t sam_blue_sound_sampler_device::iorq_r(offs_t offset)
{
uint8_t data = 0xff;
if ((offset & 0xff) == 0x7f)
return m_ppi->read(offset >> 8);
return data;
}
void sam_blue_sound_sampler_device::iorq_w(offs_t offset, uint8_t data)
{
if ((offset & 0xff) == 0x7f)
m_ppi->write(offset >> 8, data);
}
|