Previous 199869 Revisions Next

r32658 Saturday 11th October, 2014 at 15:49:56 UTC by Fabio Priuli
given to another couple of sound devices their own include. nw.
[src/mess]mess.mak
[src/mess/audio]dai.c dai_snd.c* dai_snd.h* special.c specimx_snd.c* specimx_snd.h*
[src/mess/drivers]special.c
[src/mess/includes]dai.h special.h

trunk/src/mess/drivers/special.c
r32657r32658
433433   MCFG_PALETTE_INIT_OWNER(special_state, specimx )
434434
435435   /* audio hardware */
436   MCFG_SOUND_ADD("custom", SPECIMX, 0)
436   MCFG_SOUND_ADD("custom", SPECIMX_SND, 0)
437437   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.00)
438438
439439   /* Devices */
trunk/src/mess/mess.mak
r32657r32658
11231123   $(MESS_DRIVERS)/cybiko.o $(MESS_MACHINE)/cybiko.o \
11241124
11251125$(MESSOBJ)/dai.a:               \
1126   $(MESS_DRIVERS)/dai.o $(MESS_AUDIO)/dai.o $(MESS_MACHINE)/dai.o $(MESS_VIDEO)/dai.o \
1126   $(MESS_DRIVERS)/dai.o $(MESS_AUDIO)/dai_snd.o $(MESS_MACHINE)/dai.o $(MESS_VIDEO)/dai.o \
11271127
11281128$(MESSOBJ)/ddr.a:               \
11291129   $(MESS_DRIVERS)/ac1.o $(MESS_MACHINE)/ac1.o $(MESS_VIDEO)/ac1.o \
r32657r32658
16281628   $(MESS_DRIVERS)/m5.o        \
16291629
16301630$(MESSOBJ)/special.a:           \
1631   $(MESS_DRIVERS)/special.o $(MESS_AUDIO)/special.o $(MESS_MACHINE)/special.o $(MESS_VIDEO)/special.o \
1631   $(MESS_DRIVERS)/special.o $(MESS_AUDIO)/specimx_snd.o $(MESS_MACHINE)/special.o $(MESS_VIDEO)/special.o \
16321632
16331633$(MESSOBJ)/sun.a:               \
16341634   $(MESS_DRIVERS)/sun1.o      \
trunk/src/mess/audio/dai.c
r32657r32658
1/***************************************************************************
2
3  audio/dai.c
4
5  Functions to emulate sound hardware of DAI Personal Computer
6
7  Krzysztof Strzecha
8
9****************************************************************************/
10
11#include "emu.h"
12#include "includes/dai.h"
13
14// device type definition
15const device_type DAI_SOUND = &device_creator<dai_sound_device>;
16
17
18//-------------------------------------------------
19//  dai_sound_device - constructor
20//-------------------------------------------------
21
22dai_sound_device::dai_sound_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
23   : device_t(mconfig, DAI_SOUND, "DAI Audio Custom", tag, owner, clock, "dai_sound", __FILE__),
24      device_sound_interface(mconfig, *this)
25{
26}
27
28//-------------------------------------------------
29//  device_start - device-specific startup
30//-------------------------------------------------
31
32void dai_sound_device::device_start()
33{
34   m_mixer_channel = machine().sound().stream_alloc(*this, 0, 2, machine().sample_rate());
35}
36
37//-------------------------------------------------
38//  device_reset - device-specific reset
39//-------------------------------------------------
40
41void dai_sound_device::device_reset()
42{
43   memset(m_dai_input, 0, sizeof(m_dai_input));
44   memset(m_osc_volume, 0, sizeof(m_osc_volume));
45   m_noise_volume = 0;
46}
47
48
49//-------------------------------------------------
50//  channels 0/1/2 volume table
51//-------------------------------------------------
52
53const UINT16 dai_sound_device::s_osc_volume_table[] = {
54                  0,  500, 1000, 1500,
55               2000, 2500, 3000, 3500,
56               4000, 4500, 5000, 5500,
57               6000, 6500, 7000, 7500
58};
59
60//-------------------------------------------------
61//  noise volume table
62//-------------------------------------------------
63
64const UINT16 dai_sound_device::s_noise_volume_table[] = {
65                  0,    0,    0,    0,
66                  0,    0,    0,    0,
67                  500, 1000, 1500, 2000,
68               2500, 3000, 3500, 4000
69};
70
71
72//-------------------------------------------------
73//  set_volume
74//-------------------------------------------------
75
76WRITE8_MEMBER(dai_sound_device::set_volume)
77{
78   m_mixer_channel->update();
79
80   switch (offset & 1)
81   {
82   case 0x00:
83      m_osc_volume[0] = data&0x0f;
84      m_osc_volume[1] = (data&0xf0)>>4;
85      break;
86
87   case 0x01:
88      m_osc_volume[2] = data&0x0f;
89      m_noise_volume = (data&0xf0)>>4;
90   }
91}
92
93//-------------------------------------------------
94//  PIT callbacks
95//-------------------------------------------------
96
97WRITE_LINE_MEMBER(dai_sound_device::set_input_ch0)
98{
99   m_mixer_channel->update();
100   m_dai_input[0] = state;
101}
102
103WRITE_LINE_MEMBER(dai_sound_device::set_input_ch1)
104{
105   m_mixer_channel->update();
106   m_dai_input[1] = state;
107}
108
109WRITE_LINE_MEMBER(dai_sound_device::set_input_ch2)
110{
111   m_mixer_channel->update();
112   m_dai_input[2] = state;
113}
114
115//-------------------------------------------------
116//  sound_stream_update - handle update requests for
117//  our sound stream
118//-------------------------------------------------
119
120void dai_sound_device::sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples)
121{
122   stream_sample_t *sample_left = outputs[0];
123   stream_sample_t *sample_right = outputs[1];
124
125   INT16 channel_0_signal = m_dai_input[0] ? s_osc_volume_table[m_osc_volume[0]] : -s_osc_volume_table[m_osc_volume[0]];
126   INT16 channel_1_signal = m_dai_input[1] ? s_osc_volume_table[m_osc_volume[1]] : -s_osc_volume_table[m_osc_volume[1]];
127   INT16 channel_2_signal = m_dai_input[2] ? s_osc_volume_table[m_osc_volume[2]] : -s_osc_volume_table[m_osc_volume[2]];
128
129   while (samples--)
130   {
131      INT16 noise = machine().rand()&0x01 ? s_noise_volume_table[m_noise_volume] : -s_noise_volume_table[m_noise_volume];
132
133      /* channel 0 + channel 1 + noise */
134      *sample_left++ = channel_0_signal + channel_1_signal + noise;
135
136      /* channel 1 + channel 2 + noise */
137      *sample_right++ = channel_1_signal + channel_2_signal + noise;
138   }
139}
trunk/src/mess/audio/special.c
r32657r32658
1/***************************************************************************
2
3  audio/special.c
4
5  Functions to emulate sound hardware of Specialist MX
6  ( based on code of DAI interface )
7
8****************************************************************************/
9
10#include "includes/special.h"
11
12
13// device type definition
14const device_type SPECIMX = &device_creator<specimx_sound_device>;
15
16
17//**************************************************************************
18//  LIVE DEVICE
19//**************************************************************************
20
21//-------------------------------------------------
22//  specimx_sound_device - constructor
23//-------------------------------------------------
24
25specimx_sound_device::specimx_sound_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
26   : device_t(mconfig, SPECIMX, "Specialist MX Audio Custom", tag, owner, clock, "specimx_sound", __FILE__),
27      device_sound_interface(mconfig, *this),
28      m_mixer_channel(NULL)
29{
30   memset(m_specimx_input, 0, sizeof(int)*3);
31}
32
33
34//-------------------------------------------------
35//  device_start - device-specific startup
36//-------------------------------------------------
37
38void specimx_sound_device::device_start()
39{
40   m_specimx_input[0] = m_specimx_input[1] = m_specimx_input[2] = 0;
41   m_mixer_channel = stream_alloc(0, 1, machine().sample_rate());
42}
43
44
45//-------------------------------------------------
46//  sound_stream_update - handle a stream update
47//-------------------------------------------------
48
49void specimx_sound_device::sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples)
50{
51   INT16 channel_0_signal;
52   INT16 channel_1_signal;
53   INT16 channel_2_signal;
54
55   stream_sample_t *sample_left = outputs[0];
56
57   channel_0_signal = m_specimx_input[0] ? 3000 : -3000;
58   channel_1_signal = m_specimx_input[1] ? 3000 : -3000;
59   channel_2_signal = m_specimx_input[2] ? 3000 : -3000;
60
61   while (samples--)
62   {
63      *sample_left = 0;
64
65      /* music channel 0 */
66      *sample_left += channel_0_signal;
67
68      /* music channel 1 */
69      *sample_left += channel_1_signal;
70
71      /* music channel 2 */
72      *sample_left += channel_2_signal;
73
74      sample_left++;
75   }
76}
77
78
79//-------------------------------------------------
80//  PIT callbacks
81//-------------------------------------------------
82
83WRITE_LINE_MEMBER(specimx_sound_device::set_input_ch0)
84{
85   m_mixer_channel->update();
86   m_specimx_input[0] = state;
87}
88
89WRITE_LINE_MEMBER(specimx_sound_device::set_input_ch1)
90{
91   m_mixer_channel->update();
92   m_specimx_input[1] = state;
93}
94
95WRITE_LINE_MEMBER(specimx_sound_device::set_input_ch2)
96{
97   m_mixer_channel->update();
98   m_specimx_input[2] = state;
99}
trunk/src/mess/audio/dai_snd.c
r0r32658
1/***************************************************************************
2
3  audio/dai_snd.c
4
5  Functions to emulate sound hardware of DAI Personal Computer
6
7  Krzysztof Strzecha
8
9****************************************************************************/
10
11#include "emu.h"
12#include "dai_snd.h"
13
14// device type definition
15const device_type DAI_SOUND = &device_creator<dai_sound_device>;
16
17
18//-------------------------------------------------
19//  dai_sound_device - constructor
20//-------------------------------------------------
21
22dai_sound_device::dai_sound_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
23   : device_t(mconfig, DAI_SOUND, "DAI Audio Custom", tag, owner, clock, "dai_sound", __FILE__),
24      device_sound_interface(mconfig, *this)
25{
26}
27
28//-------------------------------------------------
29//  device_start - device-specific startup
30//-------------------------------------------------
31
32void dai_sound_device::device_start()
33{
34   m_mixer_channel = machine().sound().stream_alloc(*this, 0, 2, machine().sample_rate());
35}
36
37//-------------------------------------------------
38//  device_reset - device-specific reset
39//-------------------------------------------------
40
41void dai_sound_device::device_reset()
42{
43   memset(m_dai_input, 0, sizeof(m_dai_input));
44   memset(m_osc_volume, 0, sizeof(m_osc_volume));
45   m_noise_volume = 0;
46}
47
48
49//-------------------------------------------------
50//  channels 0/1/2 volume table
51//-------------------------------------------------
52
53const UINT16 dai_sound_device::s_osc_volume_table[] = {
54                  0,  500, 1000, 1500,
55               2000, 2500, 3000, 3500,
56               4000, 4500, 5000, 5500,
57               6000, 6500, 7000, 7500
58};
59
60//-------------------------------------------------
61//  noise volume table
62//-------------------------------------------------
63
64const UINT16 dai_sound_device::s_noise_volume_table[] = {
65                  0,    0,    0,    0,
66                  0,    0,    0,    0,
67                  500, 1000, 1500, 2000,
68               2500, 3000, 3500, 4000
69};
70
71
72//-------------------------------------------------
73//  set_volume
74//-------------------------------------------------
75
76WRITE8_MEMBER(dai_sound_device::set_volume)
77{
78   m_mixer_channel->update();
79
80   switch (offset & 1)
81   {
82   case 0x00:
83      m_osc_volume[0] = data&0x0f;
84      m_osc_volume[1] = (data&0xf0)>>4;
85      break;
86
87   case 0x01:
88      m_osc_volume[2] = data&0x0f;
89      m_noise_volume = (data&0xf0)>>4;
90   }
91}
92
93//-------------------------------------------------
94//  PIT callbacks
95//-------------------------------------------------
96
97WRITE_LINE_MEMBER(dai_sound_device::set_input_ch0)
98{
99   m_mixer_channel->update();
100   m_dai_input[0] = state;
101}
102
103WRITE_LINE_MEMBER(dai_sound_device::set_input_ch1)
104{
105   m_mixer_channel->update();
106   m_dai_input[1] = state;
107}
108
109WRITE_LINE_MEMBER(dai_sound_device::set_input_ch2)
110{
111   m_mixer_channel->update();
112   m_dai_input[2] = state;
113}
114
115//-------------------------------------------------
116//  sound_stream_update - handle update requests for
117//  our sound stream
118//-------------------------------------------------
119
120void dai_sound_device::sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples)
121{
122   stream_sample_t *sample_left = outputs[0];
123   stream_sample_t *sample_right = outputs[1];
124
125   INT16 channel_0_signal = m_dai_input[0] ? s_osc_volume_table[m_osc_volume[0]] : -s_osc_volume_table[m_osc_volume[0]];
126   INT16 channel_1_signal = m_dai_input[1] ? s_osc_volume_table[m_osc_volume[1]] : -s_osc_volume_table[m_osc_volume[1]];
127   INT16 channel_2_signal = m_dai_input[2] ? s_osc_volume_table[m_osc_volume[2]] : -s_osc_volume_table[m_osc_volume[2]];
128
129   while (samples--)
130   {
131      INT16 noise = machine().rand()&0x01 ? s_noise_volume_table[m_noise_volume] : -s_noise_volume_table[m_noise_volume];
132
133      /* channel 0 + channel 1 + noise */
134      *sample_left++ = channel_0_signal + channel_1_signal + noise;
135
136      /* channel 1 + channel 2 + noise */
137      *sample_right++ = channel_1_signal + channel_2_signal + noise;
138   }
139}
Property changes on: trunk/src/mess/audio/dai_snd.c
Added: svn:eol-style
   + native
Added: svn:mime-type
   + text/plain
trunk/src/mess/audio/dai_snd.h
r0r32658
1/*****************************************************************************
2 *
3 * dai_snd.h
4 *
5 ****************************************************************************/
6
7#ifndef DAI_SND_H_
8#define DAI_SND_H_
9
10#include "emu.h"
11
12// ======================> dai_sound_device
13
14class dai_sound_device : public device_t,
15                     public device_sound_interface
16{
17public:
18   // construction/destruction
19   dai_sound_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
20
21   DECLARE_WRITE_LINE_MEMBER(set_input_ch0);
22   DECLARE_WRITE_LINE_MEMBER(set_input_ch1);
23   DECLARE_WRITE_LINE_MEMBER(set_input_ch2);
24   DECLARE_WRITE8_MEMBER(set_volume);
25
26protected:
27   // device-level overrides
28   virtual void device_start();
29   virtual void device_reset();
30   virtual void sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples);
31
32private:
33   sound_stream *      m_mixer_channel;
34   int                 m_dai_input[3];
35   UINT8               m_osc_volume[3];
36   UINT8               m_noise_volume;
37
38   static const UINT16 s_osc_volume_table[];
39   static const UINT16 s_noise_volume_table[];
40};
41
42extern const device_type DAI_SOUND;
43
44#endif /* DAI_H_ */
Property changes on: trunk/src/mess/audio/dai_snd.h
Added: svn:mime-type
   + text/plain
Added: svn:eol-style
   + native
trunk/src/mess/audio/specimx_snd.c
r0r32658
1/***************************************************************************
2
3  audio/special.c
4
5  Functions to emulate sound hardware of Specialist MX
6  ( based on code of DAI interface )
7
8****************************************************************************/
9
10#include "specimx_snd.h"
11
12
13// device type definition
14const device_type SPECIMX_SND = &device_creator<specimx_sound_device>;
15
16
17//**************************************************************************
18//  LIVE DEVICE
19//**************************************************************************
20
21//-------------------------------------------------
22//  specimx_sound_device - constructor
23//-------------------------------------------------
24
25specimx_sound_device::specimx_sound_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
26   : device_t(mconfig, SPECIMX_SND, "Specialist MX Audio Custom", tag, owner, clock, "specimx_sound", __FILE__),
27      device_sound_interface(mconfig, *this),
28      m_mixer_channel(NULL)
29{
30   memset(m_specimx_input, 0, sizeof(int)*3);
31}
32
33
34//-------------------------------------------------
35//  device_start - device-specific startup
36//-------------------------------------------------
37
38void specimx_sound_device::device_start()
39{
40   m_specimx_input[0] = m_specimx_input[1] = m_specimx_input[2] = 0;
41   m_mixer_channel = stream_alloc(0, 1, machine().sample_rate());
42}
43
44
45//-------------------------------------------------
46//  sound_stream_update - handle a stream update
47//-------------------------------------------------
48
49void specimx_sound_device::sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples)
50{
51   INT16 channel_0_signal;
52   INT16 channel_1_signal;
53   INT16 channel_2_signal;
54
55   stream_sample_t *sample_left = outputs[0];
56
57   channel_0_signal = m_specimx_input[0] ? 3000 : -3000;
58   channel_1_signal = m_specimx_input[1] ? 3000 : -3000;
59   channel_2_signal = m_specimx_input[2] ? 3000 : -3000;
60
61   while (samples--)
62   {
63      *sample_left = 0;
64
65      /* music channel 0 */
66      *sample_left += channel_0_signal;
67
68      /* music channel 1 */
69      *sample_left += channel_1_signal;
70
71      /* music channel 2 */
72      *sample_left += channel_2_signal;
73
74      sample_left++;
75   }
76}
77
78
79//-------------------------------------------------
80//  PIT callbacks
81//-------------------------------------------------
82
83WRITE_LINE_MEMBER(specimx_sound_device::set_input_ch0)
84{
85   m_mixer_channel->update();
86   m_specimx_input[0] = state;
87}
88
89WRITE_LINE_MEMBER(specimx_sound_device::set_input_ch1)
90{
91   m_mixer_channel->update();
92   m_specimx_input[1] = state;
93}
94
95WRITE_LINE_MEMBER(specimx_sound_device::set_input_ch2)
96{
97   m_mixer_channel->update();
98   m_specimx_input[2] = state;
99}
Property changes on: trunk/src/mess/audio/specimx_snd.c
Added: svn:mime-type
   + text/plain
Added: svn:eol-style
   + native
trunk/src/mess/audio/specimx_snd.h
r0r32658
1/*****************************************************************************
2 *
3 * specimx_snd.h
4 *
5 ****************************************************************************/
6
7#ifndef SPECIAL_SND_H_
8#define SPECIAL_SND_H_
9
10#include "emu.h"
11
12class specimx_sound_device : public device_t,
13                        public device_sound_interface
14{
15public:
16   specimx_sound_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
17   ~specimx_sound_device() { }
18
19   DECLARE_WRITE_LINE_MEMBER(set_input_ch0);
20   DECLARE_WRITE_LINE_MEMBER(set_input_ch1);
21   DECLARE_WRITE_LINE_MEMBER(set_input_ch2);
22
23protected:
24   // device-level overrides
25   virtual void device_start();
26
27   // sound stream update overrides
28   virtual void sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples);
29
30private:
31   sound_stream *m_mixer_channel;
32   int m_specimx_input[3];
33};
34
35extern const device_type SPECIMX_SND;
36
37#endif /* SPECIAL_SND_H_ */
Property changes on: trunk/src/mess/audio/specimx_snd.h
Added: svn:mime-type
   + text/plain
Added: svn:eol-style
   + native
trunk/src/mess/includes/special.h
r32657r32658
1010#include "emu.h"
1111#include "cpu/z80/z80.h"
1212#include "cpu/i8085/i8085.h"
13#include "audio/specimx_snd.h"
1314#include "sound/dac.h"
1415#include "sound/wave.h"
1516#include "machine/i8255.h"
r32657r32658
2122#include "machine/ram.h"
2223
2324
24class specimx_sound_device; // defined below
25
2625class special_state : public driver_device
2726{
2827public:
r32657r32658
154153extern const rgb_t specimx_palette[16];
155154
156155
157/*----------- defined in audio/special.c -----------*/
158
159class specimx_sound_device : public device_t,
160                        public device_sound_interface
161{
162public:
163   specimx_sound_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
164   ~specimx_sound_device() { }
165
166   DECLARE_WRITE_LINE_MEMBER(set_input_ch0);
167   DECLARE_WRITE_LINE_MEMBER(set_input_ch1);
168   DECLARE_WRITE_LINE_MEMBER(set_input_ch2);
169
170protected:
171   // device-level overrides
172   virtual void device_start();
173
174   // sound stream update overrides
175   virtual void sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples);
176
177private:
178   sound_stream *m_mixer_channel;
179   int m_specimx_input[3];
180};
181
182extern const device_type SPECIMX;
183
184156#endif /* SPECIAL_H_ */
trunk/src/mess/includes/dai.h
r32657r32658
88#define DAI_H_
99
1010#include "cpu/i8085/i8085.h"
11#include "audio/dai_snd.h"
1112#include "machine/i8255.h"
1213#include "machine/pit8253.h"
1314#include "machine/ram.h"
r32657r32658
1617#include "sound/wave.h"
1718
1819
19// ======================> dai_sound_device
20
21class dai_sound_device : public device_t,
22                     public device_sound_interface
23{
24public:
25   // construction/destruction
26   dai_sound_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
27
28   DECLARE_WRITE_LINE_MEMBER(set_input_ch0);
29   DECLARE_WRITE_LINE_MEMBER(set_input_ch1);
30   DECLARE_WRITE_LINE_MEMBER(set_input_ch2);
31   DECLARE_WRITE8_MEMBER(set_volume);
32
33protected:
34   // device-level overrides
35   virtual void device_start();
36   virtual void device_reset();
37   virtual void sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples);
38
39private:
40   sound_stream *      m_mixer_channel;
41   int                 m_dai_input[3];
42   UINT8               m_osc_volume[3];
43   UINT8               m_noise_volume;
44
45   static const UINT16 s_osc_volume_table[];
46   static const UINT16 s_noise_volume_table[];
47};
48
49
50
5120class dai_state : public driver_device
5221{
5322public:
r32657r32658
10776extern const unsigned char dai_palette[16*3];
10877
10978
110/*----------- defined in audio/dai.c -----------*/
111
112extern const device_type DAI_SOUND;
113
11479#endif /* DAI_H_ */

Previous 199869 Revisions Next


© 1997-2024 The MAME Team