Previous 199869 Revisions Next

r17428 Thursday 23rd August, 2012 at 19:27:48 UTC by Sandro Ronco
(MESS) hr16: Added preliminary sound emulation. [Sandro Ronco]
[src/mess]mess.mak
[src/mess/audio]alesis.c*
[src/mess/drivers]alesis.c
[src/mess/includes]alesis.h*

trunk/src/mess/audio/alesis.c
r0r17428
1/***************************************************************************
2
3    Alesis HR-16 sound (DM3AG + PCM54) emulation
4
5    TODO:
6    - volume
7    - panning
8    - output 2
9    - fix 16-bit output to DAC (currently samples are only shifted by 8)
10    - remove noise during patterns recording
11
12****************************************************************************/
13
14#include "emu.h"
15#include "includes/alesis.h"
16
17#define LOG 1
18
19// device type definition
20const device_type ALESIS_DM3AG = &device_creator<alesis_dm3ag_device>;
21
22/***************************************************************************
23    IMPLEMENTATION
24***************************************************************************/
25
26static MACHINE_CONFIG_FRAGMENT( alesis_dm3ag )
27   MCFG_SPEAKER_STANDARD_STEREO("out1_left", "out1_right")
28   MCFG_SOUND_ADD("dac", DAC, 0)
29   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "out1_left",  1.0)
30   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "out1_right", 1.0)
31MACHINE_CONFIG_END
32
33//-------------------------------------------------
34//  alesis_dm3ag_device - constructor
35//-------------------------------------------------
36
37alesis_dm3ag_device::alesis_dm3ag_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
38   : device_t(mconfig, ALESIS_DM3AG, "Alesis DM3AG", tag, owner, clock),
39     m_dac(*this, "dac")
40{
41}
42
43//-------------------------------------------------
44//  device_mconfig_additions
45//-------------------------------------------------
46
47machine_config_constructor alesis_dm3ag_device::device_mconfig_additions() const
48{
49   return MACHINE_CONFIG_NAME( alesis_dm3ag );
50}
51
52//-------------------------------------------------
53//  device_start - device-specific startup
54//-------------------------------------------------
55
56void alesis_dm3ag_device::device_start()
57{
58   m_samples = (INT8*)(*region());
59   m_dac_update_timer = timer_alloc(TIMER_DAC_UPDATE);
60}
61
62//-------------------------------------------------
63//  device_reset - device-specific reset
64//-------------------------------------------------
65
66void alesis_dm3ag_device::device_reset()
67{
68   m_dac_update_timer->adjust(attotime::from_hz(48000), 0, attotime::from_hz(48000));
69
70   m_output_active = false;
71   m_count = 0;
72   m_cur_sample = 0;
73   memset(m_cmd, 0, sizeof(m_cmd));
74}
75
76//-------------------------------------------------
77//  device_timer - handler timer events
78//-------------------------------------------------
79void alesis_dm3ag_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
80{
81   if (m_output_active)
82   {
83      INT16 sample = m_samples[m_cur_sample++];
84
85      // FIXME
86      sample <<= 8;
87
88      m_dac->write_signed16(sample + 0x8000);
89
90      // every block ends with three or more -1 samples
91      if (m_cur_sample == 0xfffff || (m_samples[m_cur_sample-1] == -128 && m_samples[m_cur_sample] == -128 && m_samples[m_cur_sample+1] == -128))
92      {
93         m_output_active = false;
94         m_dac->write_signed16(0x8000);
95
96         if (LOG)   logerror("DM3AG '%s' stop: %d\n", tag(), m_cur_sample-((m_cmd[0]<<12) | (m_cmd[1]<<4) | ((m_cmd[2]>>4) & 0x0f)));
97      }
98   }
99}
100
101WRITE8_MEMBER(alesis_dm3ag_device::write)
102{
103   if (LOG)   logerror("DM3AG '%s' write: %02x\n", tag(), data);
104
105   m_cmd[m_count++] = data;
106
107   if (m_count == 5)
108   {
109      /*
110            commands are sent in block of 5 bytes (40 bits)
111
112            bit 00-19       sample position in the roms
113            bit 20-23       ???
114            bit 24-31       volume
115            bit 32-34       panning
116            bit 35          output selector: 0 = out2, 1 = out1
117            bit 36-39       ???
118        */
119
120      m_cur_sample = (m_cmd[0]<<12) | (m_cmd[1]<<4) | ((m_cmd[2]>>4) & 0x0f);
121
122      if (m_cur_sample > 0)
123      {
124         m_output_active = true;
125
126         if (LOG)
127         {
128            bool good_pos = (m_cur_sample<2 || m_samples[m_cur_sample-2] == -128);
129
130            logerror("DM3AG '%s' start: %d (%s), vol: %02x out: %d pan: %d\n", tag(), m_cur_sample, good_pos ? "ok": "no", m_cmd[3], m_cmd[4] & 0x10 ? 1 : 2, (m_cmd[4]>>5)&7);
131         }
132      }
133
134      m_count = 0;
135   }
136}
trunk/src/mess/includes/alesis.h
r0r17428
1/***************************************************************************
2
3    Alesis HR-16 and SR-16 drum machines
4
5****************************************************************************/
6
7#pragma once
8
9#ifndef _ALESIS_H_
10#define _ALESIS_H_
11
12#include "cpu/mcs51/mcs51.h"
13#include "sound/dac.h"
14#include "video/hd44780.h"
15#include "imagedev/cassette.h"
16#include "rendlay.h"
17
18#define MCFG_ALESIS_DM3AG_ADD(_tag,_clock) \
19   MCFG_DEVICE_ADD( _tag, ALESIS_DM3AG, _clock )
20
21
22// ======================> alesis_dm3ag_device
23
24class alesis_dm3ag_device :   public device_t
25{
26
27public:
28   // construction/destruction
29   alesis_dm3ag_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
30
31   // optional information overrides
32   virtual machine_config_constructor device_mconfig_additions() const;
33
34   // device interface
35   DECLARE_WRITE8_MEMBER(write);
36
37protected:
38   // device-level overrides
39   virtual void device_start();
40   virtual void device_reset();
41   virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
42
43private:
44   static const device_timer_id TIMER_DAC_UPDATE = 1;
45   required_device<dac_device> m_dac;
46
47   emu_timer *   m_dac_update_timer;
48   INT8 *      m_samples;
49   bool      m_output_active;
50   int         m_count;
51   UINT32      m_cur_sample;
52   UINT8      m_cmd[5];
53};
54
55
56// ======================> alesis_state
57
58class alesis_state : public driver_device
59{
60public:
61   alesis_state(const machine_config &mconfig, device_type type, const char *tag)
62      : driver_device(mconfig, type, tag),
63        m_cassette(*this, CASSETTE_TAG)
64      { }
65
66   optional_device<cassette_image_device> m_cassette;
67
68   virtual void palette_init();
69   virtual void machine_reset();
70
71   DECLARE_DRIVER_INIT(hr16);
72   DECLARE_WRITE8_MEMBER( led_w );
73   DECLARE_WRITE8_MEMBER( kb_matrix_w );
74   DECLARE_READ8_MEMBER( kb_r );
75   DECLARE_READ8_MEMBER( p3_r );
76   DECLARE_WRITE8_MEMBER( p3_w );
77
78private:
79   UINT8      m_kb_matrix;
80};
81
82// device type definition
83extern const device_type ALESIS_DM3AG;
84
85#endif   // _ALESIS_H_
86
trunk/src/mess/drivers/alesis.c
r17427r17428
1010****************************************************************************/
1111
1212#include "emu.h"
13#include "cpu/mcs51/mcs51.h"
14#include "imagedev/cassette.h"
15#include "video/hd44780.h"
16#include "rendlay.h"
13#include "includes/alesis.h"
1714
1815
19class alesis_state : public driver_device
20{
21public:
22   alesis_state(const machine_config &mconfig, device_type type, const char *tag)
23      : driver_device(mconfig, type, tag),
24        m_cassette(*this, CASSETTE_TAG)
25      { }
26
27   optional_device<cassette_image_device> m_cassette;
28
29   virtual void palette_init();
30   virtual void machine_reset();
31
32   DECLARE_DRIVER_INIT(hr16);
33   DECLARE_WRITE8_MEMBER( led_w );
34   DECLARE_WRITE8_MEMBER( kb_matrix_w );
35   DECLARE_READ8_MEMBER( kb_r );
36   DECLARE_READ8_MEMBER( p3_r );
37   DECLARE_WRITE8_MEMBER( p3_w );
38
39   UINT8 m_kb_matrix;
40};
41
4216WRITE8_MEMBER( alesis_state::kb_matrix_w )
4317{
4418   m_kb_matrix = data;
r17427r17428
7953
8054READ8_MEMBER( alesis_state::p3_r )
8155{
82   return (m_cassette->input() > 0.01) ? 0x00 : 0x08;
56   UINT8 data = 0xff;
57
58   data &= ~(m_cassette->input() > 0.01 ? 0x00 : 0x08);
59
60   return data;
8361}
8462
8563WRITE8_MEMBER( alesis_state::p3_w )
r17427r17428
9573static ADDRESS_MAP_START(hr16_io, AS_IO, 8, alesis_state)
9674   ADDRESS_MAP_UNMAP_HIGH
9775   AM_RANGE(0x0000, 0x0000) AM_READ(kb_r)
76   AM_RANGE(0x0002, 0x0002) AM_DEVWRITE("dm3ag", alesis_dm3ag_device, write)
77   AM_RANGE(0x0004, 0x0004) AM_WRITE(led_w)
9878   AM_RANGE(0x0006, 0x0006) AM_DEVREADWRITE("hd44780", hd44780_device, control_read, control_write)
9979   AM_RANGE(0x0007, 0x0007) AM_DEVREADWRITE("hd44780", hd44780_device, data_read, data_write)
100   AM_RANGE(0x0004, 0x0004) AM_WRITE(led_w)
10180   AM_RANGE(0x0008, 0x0008) AM_WRITE(kb_matrix_w)
81   AM_RANGE(MCS51_PORT_P1, MCS51_PORT_P1) AM_READ_PORT("SELECT")   AM_WRITENOP
82   AM_RANGE(MCS51_PORT_P2, MCS51_PORT_P2) AM_WRITENOP
10283   AM_RANGE(MCS51_PORT_P3, MCS51_PORT_P3) AM_READWRITE(p3_r, p3_w)
10384   AM_RANGE(0x8000, 0xffff) AM_RAM      /* 32Kx8 SRAM */
10485ADDRESS_MAP_END
r17427r17428
169150   PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("CLAPS")   PORT_CODE(KEYCODE_6_PAD)
170151   PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("PERC 3")   PORT_CODE(KEYCODE_7_PAD)
171152   PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("PERC 4")   PORT_CODE(KEYCODE_8_PAD)
153
154   PORT_START("SELECT")
155   PORT_BIT(0xff, 0x00, IPT_DIAL) PORT_NAME("SELECT Slider") PORT_SENSITIVITY(50) PORT_KEYDELTA(1) PORT_CODE_DEC(KEYCODE_DOWN) PORT_CODE_INC(KEYCODE_UP)
172156INPUT_PORTS_END
173157
174158
r17427r17428
223207   MCFG_CASSETTE_ADD( CASSETTE_TAG, hr16_cassette_interface )
224208
225209   MCFG_HD44780_ADD("hd44780", hr16_display)
210
211   /* sound hardware */
212   MCFG_ALESIS_DM3AG_ADD("dm3ag", XTAL_12MHz/2)
226213MACHINE_CONFIG_END
227214
228215static MACHINE_CONFIG_START( sr16, alesis_state )
r17427r17428
257244   ROM_SYSTEM_BIOS(3, "v200", "ver 2.00")
258245   ROMX_LOAD( "hr16-v2.0.bin",  0x0000, 0x8000, CRC(a3fcba12) SHA1(4c94be7e94e5a1d86443571cd4d375158a6e7b65), ROM_BIOS(4))
259246
260   ROM_REGION( 0x100000, "sounddata", ROMREGION_ERASEFF )
261   ROM_LOAD( "2-27-0003.u15", 0x00000, 0x80000, CRC(82e9b78c) SHA1(89728cb38ae172b5e347a03018617c94a087dce0))
262   ROM_LOAD( "2-27-0004.u16", 0x80000, 0x80000, CRC(8e103536) SHA1(092e1cf649fbef171cfaf91e20707d89998b7a1e))
247   ROM_REGION( 0x100000, "dm3ag", 0 )
248   ROM_LOAD( "2-27-0004.u16", 0x00000, 0x80000, CRC(8e103536) SHA1(092e1cf649fbef171cfaf91e20707d89998b7a1e))
249   ROM_LOAD( "2-27-0003.u15", 0x80000, 0x80000, CRC(82e9b78c) SHA1(89728cb38ae172b5e347a03018617c94a087dce0))
263250
264251   ROM_REGION( 0x0860, "hd44780", ROMREGION_ERASE )
265252   ROM_LOAD( "44780a00.bin",    0x0000, 0x0860,  BAD_DUMP CRC(3a89024c) SHA1(5a87b68422a916d1b37b5be1f7ad0b3fb3af5a8d))
r17427r17428
272259   ROM_SYSTEM_BIOS(0, "v200", "ver 2.00")
273260   ROMX_LOAD( "2-19-0256-v200.u11",0x0000,  0x8000, CRC(19cf0fce) SHA1(f8b3786b32d68e3627a654b8b3916befbe9bc540), ROM_BIOS(1))
274261
275   ROM_REGION( 0x100000, "sounddata", ROMREGION_ERASEFF )
276   ROM_LOAD( "2-27-0007.u15", 0x00000, 0x80000, CRC(319746db) SHA1(46b32a3ab2fbad67fb4566f607f578a2e9defd63))
277   ROM_LOAD( "2-27-0008.u16", 0x80000, 0x80000, CRC(11ca930e) SHA1(2f57fdd02f9b2146a551370a74cab1fa800145ab))
262   ROM_REGION( 0x100000, "dm3ag", 0 )
263   ROM_LOAD( "2-27-0008.u16", 0x00000, 0x80000, CRC(11ca930e) SHA1(2f57fdd02f9b2146a551370a74cab1fa800145ab))
264   ROM_LOAD( "2-27-0007.u15", 0x80000, 0x80000, CRC(319746db) SHA1(46b32a3ab2fbad67fb4566f607f578a2e9defd63))
278265
279266   ROM_REGION( 0x0860, "hd44780", ROMREGION_ERASE )
280267   ROM_LOAD( "44780a00.bin",    0x0000, 0x0860,  BAD_DUMP CRC(3a89024c) SHA1(5a87b68422a916d1b37b5be1f7ad0b3fb3af5a8d))
trunk/src/mess/mess.mak
r17427r17428
237237DRVLIBS += \
238238   $(MESSOBJ)/acorn.a \
239239   $(MESSOBJ)/act.a \
240   $(MESSOBJ)/alesis.a \
240241   $(MESSOBJ)/amiga.a \
241242   $(MESSOBJ)/amstrad.a \
242243   $(MESSOBJ)/apf.a \
r17427r17428
593594   $(MESS_DRIVERS)/victor9k.o   \
594595   $(MESS_MACHINE)/victor9kb.o   \
595596
597$(MESSOBJ)/alesis.a:         \
598   $(MESS_DRIVERS)/alesis.o   \
599   $(MESS_AUDIO)/alesis.o      \
600
596601$(MESSOBJ)/amiga.a:            \
597602   $(MESS_MACHINE)/amigacrt.o   \
598603   $(MESS_MACHINE)/amigacd.o   \
r17427r17428
19221927   $(MESS_DRIVERS)/zexall.o   \
19231928
19241929$(MESSOBJ)/skeleton.a:         \
1925   $(MESS_DRIVERS)/alesis.o   \
19261930   $(MESS_DRIVERS)/alphatro.o   \
19271931   $(MESS_DRIVERS)/amico2k.o   \
19281932   $(MESS_DRIVERS)/applix.o   \

Previous 199869 Revisions Next


© 1997-2024 The MAME Team