mame/src/mame/audio/atarijsa.h
Aaron Giles 5d93590f30 Convert Atari JSA sound boards to their own devices, and replumb
them through the Atari games that used them.
2013-07-14 22:49:13 +00:00

283 lines
9.0 KiB
C++

/***************************************************************************
audio/atarijsa.h
Functions to emulate the Atari "JSA" audio boards
****************************************************************************
Copyright Aaron Giles
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the
distribution.
* Neither the name 'MAME' nor the names of its contributors may be
used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY AARON GILES ''AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL AARON GILES BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
***************************************************************************/
#pragma once
#ifndef __ATARI_JSA__
#define __ATARI_JSA__
#include "cpu/m6502/m6502.h"
#include "sound/tms5220.h"
#include "sound/2151intf.h"
#include "sound/okim6295.h"
#include "sound/pokey.h"
#include "machine/atarigen.h"
//**************************************************************************
// GLOBAL VARIABLES
//**************************************************************************
extern const device_type ATARI_JSA_I;
extern const device_type ATARI_JSA_II;
extern const device_type ATARI_JSA_III;
extern const device_type ATARI_JSA_IIIS;
//**************************************************************************
// DEVICE CONFIGURATION MACROS
//**************************************************************************
#define MCFG_ATARI_JSA_I_ADD(_tag, _intcb) \
MCFG_DEVICE_ADD(_tag, ATARI_JSA_I, 0) \
devcb = &atari_jsa_i_device::static_set_main_int_cb(*device, DEVCB2_##_intcb);
#define MCFG_ATARI_JSA_II_ADD(_tag, _intcb) \
MCFG_DEVICE_ADD(_tag, ATARI_JSA_II, 0) \
devcb = &atari_jsa_ii_device::static_set_main_int_cb(*device, DEVCB2_##_intcb);
#define MCFG_ATARI_JSA_III_ADD(_tag, _intcb) \
MCFG_DEVICE_ADD(_tag, ATARI_JSA_III, 0) \
devcb = &atari_jsa_iii_device::static_set_main_int_cb(*device, DEVCB2_##_intcb);
#define MCFG_ATARI_JSA_IIIS_ADD(_tag, _intcb) \
MCFG_DEVICE_ADD(_tag, ATARI_JSA_IIIS, 0) \
devcb = &atari_jsa_iiis_device::static_set_main_int_cb(*device, DEVCB2_##_intcb);
#define MCFG_ATARI_JSA_TEST_PORT(_port, _bitnum) \
devcb = &atari_jsa_base_device::static_set_test_read_cb(*device, DEVCB2_IOPORT(_port)); \
MCFG_DEVCB_RSHIFT(_bitnum); \
//**************************************************************************
// TYPE DEFINITIONS
//**************************************************************************
// ======================> atari_jsa_base_device
class atari_jsa_base_device : public device_t,
public device_mixer_interface
{
protected:
// construction/destruction
atari_jsa_base_device(const machine_config &mconfig, device_type devtype, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, int channels);
public:
// static configuration
template<class _Object> static devcb2_base &static_set_test_read_cb(device_t &device, _Object object) { return downcast<atari_jsa_base_device &>(device).m_test_read_cb.set_callback(object); }
template<class _Object> static devcb2_base &static_set_main_int_cb(device_t &device, _Object object) { return downcast<atari_jsa_base_device &>(device).m_main_int_cb.set_callback(object); }
// getters
m6502_device &soundcpu() const { return *m_jsacpu; }
bool main_to_sound_ready() const { return m_soundcomm->main_to_sound_ready(); }
bool sound_to_main_ready() const { return m_soundcomm->sound_to_main_ready(); }
// main cpu accessors
DECLARE_WRITE8_MEMBER(main_command_w);
DECLARE_READ8_MEMBER(main_response_r);
DECLARE_WRITE16_MEMBER(sound_reset_w);
// read/write handlers
DECLARE_WRITE8_MEMBER( ym2151_port_w );
// I/O lines
DECLARE_WRITE_LINE_MEMBER( main_int_write_line );
protected:
// device-level overrides
virtual void device_start();
virtual void device_reset();
// internal helpers
virtual void update_all_volumes() = 0;
// devices
required_device<atari_sound_comm_device> m_soundcomm;
required_device<m6502_device> m_jsacpu;
required_device<ym2151_device> m_ym2151;
// memory banks
required_memory_bank m_cpu_bank;
// configuration state
devcb2_read_line m_test_read_cb;
devcb2_write_line m_main_int_cb;
// internal state
double m_ym2151_volume;
UINT8 m_ym2151_ct1;
UINT8 m_ym2151_ct2;
};
// ======================> atari_jsa_oki_base_device
class atari_jsa_oki_base_device : public atari_jsa_base_device
{
protected:
// derived construction/destruction
atari_jsa_oki_base_device(const machine_config &mconfig, device_type devtype, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, int channels);
public:
// read/write handlers
DECLARE_READ8_MEMBER( oki_r );
DECLARE_WRITE8_MEMBER( oki_w );
DECLARE_WRITE8_MEMBER( wrio_w );
DECLARE_WRITE8_MEMBER( mix_w );
DECLARE_WRITE8_MEMBER( overall_volume_w );
protected:
// device level overrides
virtual void device_start();
virtual void device_reset();
// internal helpers
virtual void update_all_volumes();
// devices
optional_device<okim6295_device> m_oki1;
optional_device<okim6295_device> m_oki2; // JSA IIIs only
// memory banks
optional_memory_bank m_oki1_banklo; // JSA III(s) only
optional_memory_bank m_oki1_bankhi; // JSA III(s)
optional_memory_bank m_oki2_banklo; // JSA IIIs only
optional_memory_bank m_oki2_bankhi; // JSA IIIs only
// internal state
double m_oki6295_volume;
double m_overall_volume; // JSA III(s) only
};
// ======================> atari_jsa_i_device
class atari_jsa_i_device : public atari_jsa_base_device
{
public:
// construction/destruction
atari_jsa_i_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
// read/write handlers
DECLARE_READ8_MEMBER( rdio_r );
DECLARE_WRITE8_MEMBER( wrio_w );
DECLARE_WRITE8_MEMBER( mix_w );
DECLARE_WRITE8_MEMBER( tms5220_voice );
DECLARE_READ8_MEMBER( pokey_r );
DECLARE_WRITE8_MEMBER( pokey_w );
protected:
// device level overrides
virtual machine_config_constructor device_mconfig_additions() const;
virtual ioport_constructor device_input_ports() const;
virtual void device_start();
virtual void device_reset();
// internal helpers
virtual void update_all_volumes();
// devices
optional_device<pokey_device> m_pokey;
optional_device<tms5220_device> m_tms5220;
// internal state
double m_pokey_volume;
double m_tms5220_volume;
};
// ======================> atari_jsa_ii_device
class atari_jsa_ii_device : public atari_jsa_oki_base_device
{
public:
// construction/destruction
atari_jsa_ii_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
// read/write handlers
DECLARE_READ8_MEMBER( rdio_r );
protected:
// device level overrides
virtual machine_config_constructor device_mconfig_additions() const;
virtual ioport_constructor device_input_ports() const;
};
// ======================> atari_jsa_iii_device
class atari_jsa_iii_device : public atari_jsa_oki_base_device
{
public:
// construction/destruction
atari_jsa_iii_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
protected:
// derived construction/destruction
atari_jsa_iii_device(const machine_config &mconfig, device_type devtype, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, int channels);
public:
// read/write handlers
DECLARE_READ8_MEMBER( rdio_r );
protected:
// device level overrides
virtual machine_config_constructor device_mconfig_additions() const;
virtual ioport_constructor device_input_ports() const;
};
// ======================> atari_jsa_iiis_device
class atari_jsa_iiis_device : public atari_jsa_iii_device
{
public:
// construction/destruction
atari_jsa_iiis_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
protected:
// device level overrides
virtual machine_config_constructor device_mconfig_additions() const;
};
#endif