(MESS) hr16: Added preliminary sound emulation. [Sandro Ronco]

This commit is contained in:
Sandro Ronco 2012-08-23 19:27:48 +00:00
parent 8555376f43
commit 4d79ea8ba6
5 changed files with 251 additions and 36 deletions

2
.gitattributes vendored
View File

@ -5426,6 +5426,7 @@ src/mame/video/zaccaria.c svneol=native#text/plain
src/mame/video/zaxxon.c svneol=native#text/plain
src/mame/video/zerozone.c svneol=native#text/plain
src/mame/video/zodiack.c svneol=native#text/plain
src/mess/audio/alesis.c svneol=native#text/plain
src/mess/audio/arcadia.c svneol=native#text/plain
src/mess/audio/arcadia.h svneol=native#text/plain
src/mess/audio/channelf.c svneol=native#text/plain
@ -5996,6 +5997,7 @@ src/mess/includes/adam.h svneol=native#text/plain
src/mess/includes/advision.h svneol=native#text/plain
src/mess/includes/aim65.h svneol=native#text/plain
src/mess/includes/aim65_40.h svneol=native#text/plain
src/mess/includes/alesis.h svneol=native#text/plain
src/mess/includes/amstr_pc.h svneol=native#text/plain
src/mess/includes/amstrad.h svneol=native#text/plain
src/mess/includes/apollo.h svneol=native#text/plain

136
src/mess/audio/alesis.c Normal file
View File

@ -0,0 +1,136 @@
/***************************************************************************
Alesis HR-16 sound (DM3AG + PCM54) emulation
TODO:
- volume
- panning
- output 2
- fix 16-bit output to DAC (currently samples are only shifted by 8)
- remove noise during patterns recording
****************************************************************************/
#include "emu.h"
#include "includes/alesis.h"
#define LOG 1
// device type definition
const device_type ALESIS_DM3AG = &device_creator<alesis_dm3ag_device>;
/***************************************************************************
IMPLEMENTATION
***************************************************************************/
static MACHINE_CONFIG_FRAGMENT( alesis_dm3ag )
MCFG_SPEAKER_STANDARD_STEREO("out1_left", "out1_right")
MCFG_SOUND_ADD("dac", DAC, 0)
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "out1_left", 1.0)
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "out1_right", 1.0)
MACHINE_CONFIG_END
//-------------------------------------------------
// alesis_dm3ag_device - constructor
//-------------------------------------------------
alesis_dm3ag_device::alesis_dm3ag_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
: device_t(mconfig, ALESIS_DM3AG, "Alesis DM3AG", tag, owner, clock),
m_dac(*this, "dac")
{
}
//-------------------------------------------------
// device_mconfig_additions
//-------------------------------------------------
machine_config_constructor alesis_dm3ag_device::device_mconfig_additions() const
{
return MACHINE_CONFIG_NAME( alesis_dm3ag );
}
//-------------------------------------------------
// device_start - device-specific startup
//-------------------------------------------------
void alesis_dm3ag_device::device_start()
{
m_samples = (INT8*)(*region());
m_dac_update_timer = timer_alloc(TIMER_DAC_UPDATE);
}
//-------------------------------------------------
// device_reset - device-specific reset
//-------------------------------------------------
void alesis_dm3ag_device::device_reset()
{
m_dac_update_timer->adjust(attotime::from_hz(48000), 0, attotime::from_hz(48000));
m_output_active = false;
m_count = 0;
m_cur_sample = 0;
memset(m_cmd, 0, sizeof(m_cmd));
}
//-------------------------------------------------
// device_timer - handler timer events
//-------------------------------------------------
void alesis_dm3ag_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
{
if (m_output_active)
{
INT16 sample = m_samples[m_cur_sample++];
// FIXME
sample <<= 8;
m_dac->write_signed16(sample + 0x8000);
// every block ends with three or more -1 samples
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))
{
m_output_active = false;
m_dac->write_signed16(0x8000);
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)));
}
}
}
WRITE8_MEMBER(alesis_dm3ag_device::write)
{
if (LOG) logerror("DM3AG '%s' write: %02x\n", tag(), data);
m_cmd[m_count++] = data;
if (m_count == 5)
{
/*
commands are sent in block of 5 bytes (40 bits)
bit 00-19 sample position in the roms
bit 20-23 ???
bit 24-31 volume
bit 32-34 panning
bit 35 output selector: 0 = out2, 1 = out1
bit 36-39 ???
*/
m_cur_sample = (m_cmd[0]<<12) | (m_cmd[1]<<4) | ((m_cmd[2]>>4) & 0x0f);
if (m_cur_sample > 0)
{
m_output_active = true;
if (LOG)
{
bool good_pos = (m_cur_sample<2 || m_samples[m_cur_sample-2] == -128);
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);
}
}
m_count = 0;
}
}

View File

@ -10,35 +10,9 @@
****************************************************************************/
#include "emu.h"
#include "cpu/mcs51/mcs51.h"
#include "imagedev/cassette.h"
#include "video/hd44780.h"
#include "rendlay.h"
#include "includes/alesis.h"
class alesis_state : public driver_device
{
public:
alesis_state(const machine_config &mconfig, device_type type, const char *tag)
: driver_device(mconfig, type, tag),
m_cassette(*this, CASSETTE_TAG)
{ }
optional_device<cassette_image_device> m_cassette;
virtual void palette_init();
virtual void machine_reset();
DECLARE_DRIVER_INIT(hr16);
DECLARE_WRITE8_MEMBER( led_w );
DECLARE_WRITE8_MEMBER( kb_matrix_w );
DECLARE_READ8_MEMBER( kb_r );
DECLARE_READ8_MEMBER( p3_r );
DECLARE_WRITE8_MEMBER( p3_w );
UINT8 m_kb_matrix;
};
WRITE8_MEMBER( alesis_state::kb_matrix_w )
{
m_kb_matrix = data;
@ -79,7 +53,11 @@ WRITE8_MEMBER( alesis_state::led_w )
READ8_MEMBER( alesis_state::p3_r )
{
return (m_cassette->input() > 0.01) ? 0x00 : 0x08;
UINT8 data = 0xff;
data &= ~(m_cassette->input() > 0.01 ? 0x00 : 0x08);
return data;
}
WRITE8_MEMBER( alesis_state::p3_w )
@ -95,10 +73,13 @@ ADDRESS_MAP_END
static ADDRESS_MAP_START(hr16_io, AS_IO, 8, alesis_state)
ADDRESS_MAP_UNMAP_HIGH
AM_RANGE(0x0000, 0x0000) AM_READ(kb_r)
AM_RANGE(0x0002, 0x0002) AM_DEVWRITE("dm3ag", alesis_dm3ag_device, write)
AM_RANGE(0x0004, 0x0004) AM_WRITE(led_w)
AM_RANGE(0x0006, 0x0006) AM_DEVREADWRITE("hd44780", hd44780_device, control_read, control_write)
AM_RANGE(0x0007, 0x0007) AM_DEVREADWRITE("hd44780", hd44780_device, data_read, data_write)
AM_RANGE(0x0004, 0x0004) AM_WRITE(led_w)
AM_RANGE(0x0008, 0x0008) AM_WRITE(kb_matrix_w)
AM_RANGE(MCS51_PORT_P1, MCS51_PORT_P1) AM_READ_PORT("SELECT") AM_WRITENOP
AM_RANGE(MCS51_PORT_P2, MCS51_PORT_P2) AM_WRITENOP
AM_RANGE(MCS51_PORT_P3, MCS51_PORT_P3) AM_READWRITE(p3_r, p3_w)
AM_RANGE(0x8000, 0xffff) AM_RAM /* 32Kx8 SRAM */
ADDRESS_MAP_END
@ -169,6 +150,9 @@ static INPUT_PORTS_START( alesis )
PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("CLAPS") PORT_CODE(KEYCODE_6_PAD)
PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("PERC 3") PORT_CODE(KEYCODE_7_PAD)
PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("PERC 4") PORT_CODE(KEYCODE_8_PAD)
PORT_START("SELECT")
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)
INPUT_PORTS_END
@ -223,6 +207,9 @@ static MACHINE_CONFIG_START( hr16, alesis_state )
MCFG_CASSETTE_ADD( CASSETTE_TAG, hr16_cassette_interface )
MCFG_HD44780_ADD("hd44780", hr16_display)
/* sound hardware */
MCFG_ALESIS_DM3AG_ADD("dm3ag", XTAL_12MHz/2)
MACHINE_CONFIG_END
static MACHINE_CONFIG_START( sr16, alesis_state )
@ -257,9 +244,9 @@ ROM_START( hr16 )
ROM_SYSTEM_BIOS(3, "v200", "ver 2.00")
ROMX_LOAD( "hr16-v2.0.bin", 0x0000, 0x8000, CRC(a3fcba12) SHA1(4c94be7e94e5a1d86443571cd4d375158a6e7b65), ROM_BIOS(4))
ROM_REGION( 0x100000, "sounddata", ROMREGION_ERASEFF )
ROM_LOAD( "2-27-0003.u15", 0x00000, 0x80000, CRC(82e9b78c) SHA1(89728cb38ae172b5e347a03018617c94a087dce0))
ROM_LOAD( "2-27-0004.u16", 0x80000, 0x80000, CRC(8e103536) SHA1(092e1cf649fbef171cfaf91e20707d89998b7a1e))
ROM_REGION( 0x100000, "dm3ag", 0 )
ROM_LOAD( "2-27-0004.u16", 0x00000, 0x80000, CRC(8e103536) SHA1(092e1cf649fbef171cfaf91e20707d89998b7a1e))
ROM_LOAD( "2-27-0003.u15", 0x80000, 0x80000, CRC(82e9b78c) SHA1(89728cb38ae172b5e347a03018617c94a087dce0))
ROM_REGION( 0x0860, "hd44780", ROMREGION_ERASE )
ROM_LOAD( "44780a00.bin", 0x0000, 0x0860, BAD_DUMP CRC(3a89024c) SHA1(5a87b68422a916d1b37b5be1f7ad0b3fb3af5a8d))
@ -272,9 +259,9 @@ ROM_START( hr16b )
ROM_SYSTEM_BIOS(0, "v200", "ver 2.00")
ROMX_LOAD( "2-19-0256-v200.u11",0x0000, 0x8000, CRC(19cf0fce) SHA1(f8b3786b32d68e3627a654b8b3916befbe9bc540), ROM_BIOS(1))
ROM_REGION( 0x100000, "sounddata", ROMREGION_ERASEFF )
ROM_LOAD( "2-27-0007.u15", 0x00000, 0x80000, CRC(319746db) SHA1(46b32a3ab2fbad67fb4566f607f578a2e9defd63))
ROM_LOAD( "2-27-0008.u16", 0x80000, 0x80000, CRC(11ca930e) SHA1(2f57fdd02f9b2146a551370a74cab1fa800145ab))
ROM_REGION( 0x100000, "dm3ag", 0 )
ROM_LOAD( "2-27-0008.u16", 0x00000, 0x80000, CRC(11ca930e) SHA1(2f57fdd02f9b2146a551370a74cab1fa800145ab))
ROM_LOAD( "2-27-0007.u15", 0x80000, 0x80000, CRC(319746db) SHA1(46b32a3ab2fbad67fb4566f607f578a2e9defd63))
ROM_REGION( 0x0860, "hd44780", ROMREGION_ERASE )
ROM_LOAD( "44780a00.bin", 0x0000, 0x0860, BAD_DUMP CRC(3a89024c) SHA1(5a87b68422a916d1b37b5be1f7ad0b3fb3af5a8d))

View File

@ -0,0 +1,86 @@
/***************************************************************************
Alesis HR-16 and SR-16 drum machines
****************************************************************************/
#pragma once
#ifndef _ALESIS_H_
#define _ALESIS_H_
#include "cpu/mcs51/mcs51.h"
#include "sound/dac.h"
#include "video/hd44780.h"
#include "imagedev/cassette.h"
#include "rendlay.h"
#define MCFG_ALESIS_DM3AG_ADD(_tag,_clock) \
MCFG_DEVICE_ADD( _tag, ALESIS_DM3AG, _clock )
// ======================> alesis_dm3ag_device
class alesis_dm3ag_device : public device_t
{
public:
// construction/destruction
alesis_dm3ag_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
// optional information overrides
virtual machine_config_constructor device_mconfig_additions() const;
// device interface
DECLARE_WRITE8_MEMBER(write);
protected:
// device-level overrides
virtual void device_start();
virtual void device_reset();
virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
private:
static const device_timer_id TIMER_DAC_UPDATE = 1;
required_device<dac_device> m_dac;
emu_timer * m_dac_update_timer;
INT8 * m_samples;
bool m_output_active;
int m_count;
UINT32 m_cur_sample;
UINT8 m_cmd[5];
};
// ======================> alesis_state
class alesis_state : public driver_device
{
public:
alesis_state(const machine_config &mconfig, device_type type, const char *tag)
: driver_device(mconfig, type, tag),
m_cassette(*this, CASSETTE_TAG)
{ }
optional_device<cassette_image_device> m_cassette;
virtual void palette_init();
virtual void machine_reset();
DECLARE_DRIVER_INIT(hr16);
DECLARE_WRITE8_MEMBER( led_w );
DECLARE_WRITE8_MEMBER( kb_matrix_w );
DECLARE_READ8_MEMBER( kb_r );
DECLARE_READ8_MEMBER( p3_r );
DECLARE_WRITE8_MEMBER( p3_w );
private:
UINT8 m_kb_matrix;
};
// device type definition
extern const device_type ALESIS_DM3AG;
#endif // _ALESIS_H_

View File

@ -237,6 +237,7 @@ SOUNDS += AWACS
DRVLIBS += \
$(MESSOBJ)/acorn.a \
$(MESSOBJ)/act.a \
$(MESSOBJ)/alesis.a \
$(MESSOBJ)/amiga.a \
$(MESSOBJ)/amstrad.a \
$(MESSOBJ)/apf.a \
@ -593,6 +594,10 @@ $(MESSOBJ)/act.a: \
$(MESS_DRIVERS)/victor9k.o \
$(MESS_MACHINE)/victor9kb.o \
$(MESSOBJ)/alesis.a: \
$(MESS_DRIVERS)/alesis.o \
$(MESS_AUDIO)/alesis.o \
$(MESSOBJ)/amiga.a: \
$(MESS_MACHINE)/amigacrt.o \
$(MESS_MACHINE)/amigacd.o \
@ -1922,7 +1927,6 @@ $(MESSOBJ)/test.a: \
$(MESS_DRIVERS)/zexall.o \
$(MESSOBJ)/skeleton.a: \
$(MESS_DRIVERS)/alesis.o \
$(MESS_DRIVERS)/alphatro.o \
$(MESS_DRIVERS)/amico2k.o \
$(MESS_DRIVERS)/applix.o \