trocana: Add preliminary MSM6650 device and some test inputs

okim6376: Use device_rom_interface; convert logging calls to logmacro.h (nw)
This commit is contained in:
AJR 2019-08-06 17:00:59 -04:00
parent c750b8efd5
commit e7e165b44a
4 changed files with 187 additions and 29 deletions

View File

@ -19,8 +19,8 @@
#define MAX_SAMPLE_CHUNK 10000
//#define MAX_WORDS 111
#define OKIVERBOSE 0
#define MSM6376LOG(...) do { if (OKIVERBOSE) logerror(__VA_ARGS__); } while (0)
//#define VERBOSE 1
#include "logmacro.h"
/* step size index shift table */
static const int index_shift[8] = { -1, -1, -1, -1, 2, 4, 6, 8 };
@ -111,11 +111,12 @@ void okim6376_device::ADPCMVoice::reset()
DEFINE_DEVICE_TYPE(OKIM6376, okim6376_device, "okim6376", "OKI MSM6376 ADPCM")
DEFINE_DEVICE_TYPE(OKIM6650, okim6650_device, "okim6650", "OKI MSM6650 ADPCM")
okim6376_device::okim6376_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
: device_t(mconfig, OKIM6376, tag, owner, clock),
okim6376_device::okim6376_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock, int addrbits)
: device_t(mconfig, type, tag, owner, clock),
device_sound_interface(mconfig, *this),
m_region_base(*this, DEVICE_SELF),
device_rom_interface(mconfig, *this, addrbits, ENDIANNESS_BIG, 8),
//m_command[OKIM6376_VOICES],
m_latch(0),
//m_stage[OKIM6376_VOICES],
@ -133,6 +134,16 @@ okim6376_device::okim6376_device(const machine_config &mconfig, const char *tag,
{
}
okim6376_device::okim6376_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
: okim6376_device(mconfig, OKIM6376, tag, owner, clock, 21)
{
}
okim6650_device::okim6650_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
: okim6376_device(mconfig, OKIM6650, tag, owner, clock, 23)
{
}
//-------------------------------------------------
// device_start - device-specific startup
//-------------------------------------------------
@ -184,6 +195,11 @@ void okim6376_device::device_reset()
}
void okim6376_device::rom_bank_updated()
{
}
/**********************************************************************************************
clock_adpcm -- clock the next ADPCM byte
@ -212,13 +228,34 @@ int16_t okim6376_device::ADPCMVoice::clock(uint8_t nibble)
}
offs_t okim6376_device::get_start_position(int channel)
{
offs_t base = m_command[channel] * 4;
// max address space is 16Mbit
return (read_byte(base+0) << 16 | read_byte(base+1) << 8 | read_byte(base+2)) & 0x1fffff;
}
offs_t okim6650_device::get_start_position(int channel)
{
offs_t base = 0x000800 + m_command[channel] * 4;
// determine sampling frequency for phrase
uint8_t data = read_byte(base);
m_divisor = ((data & 3) == 2 ? 5 : 8 - (data & 3) * 2) * (BIT(data, 2) ? 2 : 1);
notify_clock_changed();
// max address space is 64Mbit
return (read_byte(base+1) << 16 | read_byte(base+2) << 8 | read_byte(base+3)) & 0x7fffff;
}
void okim6376_device::oki_process(int channel, int command)
{
/* if a command is pending, process the second half */
if ((command != -1) && (command != 0)) //process silence separately
{
int start;
unsigned char *base/*, *base_end*/;
/* update the stream */
m_stream->update();
@ -226,10 +263,8 @@ void okim6376_device::oki_process(int channel, int command)
{
struct ADPCMVoice *voice = &m_voice[channel];
/* determine the start position, max address space is 16Mbit */
base = &m_region_base[m_command[channel] * 4];
//base_end = &m_region_base[(MAX_WORDS+1) * 4];
start = ((base[0] << 16) + (base[1] << 8) + base[2]) & 0x1fffff;
// determine the start position
offs_t start = get_start_position(channel);
if (start == 0)
{
@ -293,7 +328,7 @@ void okim6376_device::generate_adpcm(struct ADPCMVoice *voice, int16_t *buffer,
/* if this voice is active */
if (voice->playing)
{
uint8_t *base = m_region_base + voice->base_offset;
offs_t base = voice->base_offset;
int sample = voice->sample;
int count = voice->count;
@ -305,7 +340,7 @@ void okim6376_device::generate_adpcm(struct ADPCMVoice *voice, int16_t *buffer,
if (count == 0)
{
/* get the number of samples to play */
count = (base[sample / 2] & 0x7f) << 1;
count = (read_byte(base + sample / 2) & 0x7f) << 1;
/* end of voice marker */
if (count == 0)
@ -321,7 +356,7 @@ void okim6376_device::generate_adpcm(struct ADPCMVoice *voice, int16_t *buffer,
}
/* compute the new amplitude and update the current step */
nibble = base[sample / 2] >> (((sample & 1) << 2) ^ 4);
nibble = read_byte(base + sample / 2) >> (((sample & 1) << 2) ^ 4);
/* output to the buffer, scaling by the volume */
/* signal in range -4096..4095, volume in range 2..16 => signal * volume / 2 in range -32768..32767 */
@ -400,6 +435,11 @@ void okim6376_device::device_clock_changed()
m_stream->set_sample_rate(clock() / m_divisor);
}
void okim6650_device::device_clock_changed()
{
m_stream->set_sample_rate(clock() / 64 / m_divisor);
}
/**********************************************************************************************
@ -425,14 +465,14 @@ READ_LINE_MEMBER( okim6376_device::busy_r )
READ_LINE_MEMBER( okim6376_device::nar_r )
{
MSM6376LOG("OKIM6376: NAR %x\n",m_nar);
LOG("OKIM6376: NAR %x\n",m_nar);
return m_nar;
}
WRITE_LINE_MEMBER( okim6376_device::ch2_w )
{
m_ch2_update = 0;//Clear flag
MSM6376LOG("OKIM6376: CH2 %x\n",state);
LOG("OKIM6376: CH2 %x\n",state);
if (m_ch2 != state)
{
@ -445,7 +485,7 @@ WRITE_LINE_MEMBER( okim6376_device::ch2_w )
struct ADPCMVoice *voice0 = &m_voice[0];
struct ADPCMVoice *voice1 = &m_voice[1];
// We set to channel 2
MSM6376LOG("OKIM6376: Channel 1\n");
LOG("OKIM6376: Channel 1\n");
m_channel = 1;
if ((voice0->playing)&&(m_st))
@ -460,7 +500,7 @@ WRITE_LINE_MEMBER( okim6376_device::ch2_w )
{
m_stage[1]=0;
oki_process(1, m_command[1]);
MSM6376LOG("OKIM6376: Channel 0\n");
LOG("OKIM6376: Channel 0\n");
m_channel = 0;
}
}
@ -471,7 +511,7 @@ WRITE_LINE_MEMBER( okim6376_device::st_w )
//As in STart, presumably, this triggers everything
m_st_update = 0;//Clear flag
MSM6376LOG("OKIM6376: ST %x\n",state);
LOG("OKIM6376: ST %x\n",state);
if (m_st != state)
{
@ -483,7 +523,7 @@ WRITE_LINE_MEMBER( okim6376_device::st_w )
struct ADPCMVoice *voice = &m_voice[m_channel];
{
m_st_pulses ++;
MSM6376LOG("OKIM6376: ST pulses %x\n",m_st_pulses);
LOG("OKIM6376: ST pulses %x\n",m_st_pulses);
if (m_st_pulses > 3)
{
m_st_pulses = 3; //undocumented behaviour beyond 3 pulses
@ -507,6 +547,12 @@ WRITE_LINE_MEMBER( okim6376_device::st_w )
}
}
WRITE_LINE_MEMBER( okim6650_device::cmd_w )
{
// TODO
}
/**********************************************************************************************
okim6376_data_w -- write to the data port of an OKIM6376-compatible chip

View File

@ -7,8 +7,7 @@
/* an interface for the OKIM6376 and similar chips (CPU interface only) */
class okim6376_device : public device_t,
public device_sound_interface
class okim6376_device : public device_t, public device_sound_interface, public device_rom_interface
{
public:
okim6376_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
@ -22,6 +21,8 @@ public:
DECLARE_READ_LINE_MEMBER( nar_r );
protected:
okim6376_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock, int addrbits);
// device-level overrides
virtual void device_start() override;
virtual void device_reset() override;
@ -31,7 +32,11 @@ protected:
// sound stream update overrides
virtual void sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples) override;
private:
// device_rom_interface overrides
virtual void rom_bank_updated() override;
virtual offs_t get_start_position(int channel);
/* struct describing a single playing ADPCM voice */
struct ADPCMVoice
{
@ -50,8 +55,6 @@ private:
};
// internal state
required_region_ptr<uint8_t> m_region_base; /* pointer to the base of the region */
static constexpr unsigned OKIM6376_VOICES = 2;
struct ADPCMVoice m_voice[OKIM6376_VOICES];
int32_t m_command[OKIM6376_VOICES];
@ -75,6 +78,21 @@ private:
void adpcm_state_save_register(struct ADPCMVoice *voice, int index);
};
class okim6650_device : public okim6376_device
{
public:
okim6650_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
DECLARE_WRITE_LINE_MEMBER( cmd_w );
protected:
// device-level overrides
virtual void device_clock_changed() override;
virtual offs_t get_start_position(int channel) override;
};
DECLARE_DEVICE_TYPE(OKIM6376, okim6376_device)
DECLARE_DEVICE_TYPE(OKIM6650, okim6650_device)
#endif // MAME_SOUND_OKIM6376_H

View File

@ -101,6 +101,8 @@
#include "emu.h"
#include "cpu/m68000/m68000.h"
#include "sound/okim6376.h"
#include "speaker.h"
class maygayew_state : public driver_device
{
@ -136,6 +138,9 @@ void maygayew_state::maygayew(machine_config &config)
/* basic machine hardware */
M68000(config, m_maincpu, 8000000); // MC68306FC16 - standard 68000 core + peripherals
m_maincpu->set_addrmap(AS_PROGRAM, &maygayew_state::maygayew_map);
SPEAKER(config, "mono").front_center();
OKIM6650(config, "snd", 4_MHz_XTAL).add_route(ALL_OUTPUTS, "mono", 1.0);
}
ROM_START( mg_gbr )
@ -383,6 +388,9 @@ ROM_START( mg_ewg )
ROM_LOAD16_BYTE( "sa6-283.u2", 0x00000, 0x020000, CRC(49b59728) SHA1(b9728e63a5453b66469af2457e258761dbc21927) )
ROM_LOAD16_BYTE( "sa6-284.u1", 0x00001, 0x020000, CRC(bd16cd1e) SHA1(fcb9314f83d60d84ed4ff17d2c02c29f20e15fdf) )
ROM_LOAD16_BYTE( "sa6-284.u2", 0x00000, 0x020000, CRC(fc40c076) SHA1(825fec1f768fd2442a5de89d627609f3b133dc5b) )
ROM_REGION( 0x100000, "snd", 0 )
ROM_LOAD( "snd.u3", 0x000000, 0x080000, NO_DUMP )
ROM_END
ROM_START( mg_jv )
@ -397,6 +405,9 @@ ROM_START( mg_jv )
ROM_LOAD16_BYTE( "sa6-610.u2", 0x0000, 0x020000, CRC(bb3cbd6f) SHA1(1642712bc3afbf9675639280667d27a74833863d) )
ROM_LOAD16_BYTE( "sa6-611.u1", 0x0000, 0x020000, CRC(c65af93d) SHA1(bd4a83d3405be39fb61d8d5b59e19c40b81a841f) )
ROM_LOAD16_BYTE( "sa6-611.u2", 0x0000, 0x020000, CRC(c75a0135) SHA1(bb4aba84894d95458720f26703622622efbffb7d) )
ROM_REGION( 0x100000, "snd", 0 )
ROM_LOAD( "snd.u3", 0x000000, 0x080000, NO_DUMP )
ROM_END
ROM_START( mg_kf )
@ -407,6 +418,9 @@ ROM_START( mg_kf )
ROM_REGION( 0x1000000, "altrevs", 0 )
ROM_LOAD16_BYTE( "sw6-100.u27", 0x0000, 0x020000, CRC(ea5b6583) SHA1(70f1fd73d6e422cf0e9d39c8fcd9650085801953) )
ROM_LOAD16_BYTE( "sw6-100.u28", 0x0000, 0x020000, CRC(a90f949b) SHA1(4d8d92e78da69628b12e418e61a073f17d97ed8a) )
ROM_REGION( 0x100000, "snd", 0 )
ROM_LOAD( "snd.u3", 0x000000, 0x080000, NO_DUMP )
ROM_END
@ -420,6 +434,9 @@ ROM_START( mg_pbw )
ROM_LOAD16_BYTE( "sw8-149.u28", 0x00001, 0x020000, CRC(0a9f0fd6) SHA1(7841cbb4997e0f244164072790b8936d49910879) )
ROM_LOAD16_BYTE( "pwizu27", 0x00000, 0x080000, CRC(84af9df8) SHA1(f31fd5721cac97f17476fb71bb0071ad6c44091b) )
ROM_LOAD16_BYTE( "pwizu28", 0x00001, 0x080000, CRC(ba00fecd) SHA1(9e78626b2f611ecd3b62fa5035041b231d53c26f) )
ROM_REGION( 0x100000, "snd", 0 )
ROM_LOAD( "snd.u3", 0x000000, 0x080000, NO_DUMP )
ROM_END
@ -433,6 +450,9 @@ ROM_START( mg_scl )
ROM_LOAD16_BYTE( "sw8-153.u28", 0x00001, 0x020000, CRC(8afd96f1) SHA1(db3b4ef58c293cddddefeed9e3ba8b936d682dc4) )
ROM_LOAD16_BYTE( "sclue.u27", 0x00000, 0x080000, CRC(1296124a) SHA1(502de898fee639fa7917a607ce451bc3a3374c5b) )
ROM_LOAD16_BYTE( "sclue.u28", 0x00001, 0x080000, CRC(1330b949) SHA1(11736865f7524a1de7da235d85c4aafd7199ed62) )
ROM_REGION( 0x100000, "snd", 0 )
ROM_LOAD( "snd.u3", 0x000000, 0x080000, NO_DUMP )
ROM_END
// complete(?) dump

View File

@ -36,23 +36,97 @@ class nmkmedal_state : public driver_device
{
public:
nmkmedal_state(const machine_config &mconfig, device_type type, const char *tag)
: driver_device(mconfig, type, tag),
m_maincpu(*this, "maincpu")
: driver_device(mconfig, type, tag)
, m_maincpu(*this, "maincpu")
, m_oki(*this, "oki")
{ }
void trocana(machine_config &config);
void mem_map(address_map &map);
private:
void adpcm_control_w(u8 data);
void mem_map(address_map &map);
required_device<cpu_device> m_maincpu;
required_device<okim6650_device> m_oki;
};
void nmkmedal_state::adpcm_control_w(u8 data)
{
m_oki->ch2_w(BIT(data, 0));
m_oki->cmd_w(BIT(data, 1));
m_oki->st_w(BIT(data, 2) || !BIT(data, 1));
}
void nmkmedal_state::mem_map(address_map &map)
{
map(0x0000, 0x7fff).rom().region("maincpu", 0);
map(0x8000, 0x8000).portr("IN0");
map(0x8001, 0x8001).portr("IN1");
map(0x8002, 0x8002).portr("IN2");
map(0x8003, 0x8003).portr("IN3");
map(0x8004, 0x8004).portr("IN4");
map(0x8005, 0x8005).portr("IN5");
map(0xa003, 0xa003).w(m_oki, FUNC(okim6376_device::write));
map(0xa004, 0xa004).w(FUNC(nmkmedal_state::adpcm_control_w));
map(0xc000, 0xc7ff).ram();
}
static INPUT_PORTS_START( trocana )
PORT_START("IN0")
PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_OTHER) PORT_NAME("0.0") PORT_CODE(KEYCODE_1)
PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_OTHER) PORT_NAME("0.1") PORT_CODE(KEYCODE_2)
PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_OTHER) PORT_NAME("0.2") PORT_CODE(KEYCODE_3)
PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_OTHER) PORT_NAME("0.3") PORT_CODE(KEYCODE_4)
PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_OTHER) PORT_NAME("0.4") PORT_CODE(KEYCODE_5)
PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_OTHER) PORT_NAME("0.5") PORT_CODE(KEYCODE_6)
PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_OTHER) PORT_NAME("0.6") PORT_CODE(KEYCODE_7)
PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_OTHER) PORT_NAME("0.7") PORT_CODE(KEYCODE_8)
PORT_START("IN1")
PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_OTHER) PORT_NAME("1.0") PORT_CODE(KEYCODE_Q)
PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_OTHER) PORT_NAME("1.1") PORT_CODE(KEYCODE_W)
PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_OTHER) PORT_NAME("1.2") PORT_CODE(KEYCODE_E)
PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_OTHER) PORT_NAME("1.3") PORT_CODE(KEYCODE_R)
PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_OTHER) PORT_NAME("1.4") PORT_CODE(KEYCODE_T)
PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_OTHER) PORT_NAME("1.5") PORT_CODE(KEYCODE_Y)
PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_OTHER) PORT_NAME("1.6") PORT_CODE(KEYCODE_U)
PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_OTHER) PORT_NAME("1.7") PORT_CODE(KEYCODE_I)
PORT_START("IN2")
PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_OTHER) PORT_NAME("2.0") PORT_CODE(KEYCODE_A)
PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_OTHER) PORT_NAME("2.1") PORT_CODE(KEYCODE_S)
PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_OTHER) PORT_NAME("2.2") PORT_CODE(KEYCODE_D)
PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_OTHER) PORT_NAME("2.3") PORT_CODE(KEYCODE_F)
PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_OTHER) PORT_NAME("2.4") PORT_CODE(KEYCODE_G)
PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_OTHER) PORT_NAME("2.5") PORT_CODE(KEYCODE_H)
PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_OTHER) PORT_NAME("2.6") PORT_CODE(KEYCODE_J)
PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_OTHER) PORT_NAME("2.7") PORT_CODE(KEYCODE_K)
PORT_START("IN3")
PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_OTHER) PORT_NAME("3.0") PORT_CODE(KEYCODE_LSHIFT)
PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_OTHER) PORT_NAME("3.1") PORT_CODE(KEYCODE_Z)
PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_OTHER) PORT_NAME("3.2") PORT_CODE(KEYCODE_X)
PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_OTHER) PORT_NAME("3.3") PORT_CODE(KEYCODE_C)
PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_OTHER) PORT_NAME("3.4") PORT_CODE(KEYCODE_V)
PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_OTHER) PORT_NAME("3.5") PORT_CODE(KEYCODE_B)
PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_OTHER) PORT_NAME("3.6") PORT_CODE(KEYCODE_N)
PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_OTHER) PORT_NAME("3.7") PORT_CODE(KEYCODE_M)
PORT_START("IN4")
PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_OTHER) PORT_NAME("4.0") PORT_CODE(KEYCODE_9)
PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_OTHER) PORT_NAME("4.1") PORT_CODE(KEYCODE_0)
PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_OTHER) PORT_NAME("4.2") PORT_CODE(KEYCODE_MINUS)
PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_OTHER) PORT_NAME("4.3") PORT_CODE(KEYCODE_EQUALS)
PORT_BIT(0xf0, IP_ACTIVE_LOW, IPT_UNUSED)
PORT_START("IN5")
PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_OTHER) PORT_NAME("5.0") PORT_CODE(KEYCODE_COMMA)
PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_OTHER) PORT_NAME("5.1") PORT_CODE(KEYCODE_STOP)
PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_OTHER) PORT_NAME("5.2") PORT_CODE(KEYCODE_SLASH)
PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_OTHER) PORT_NAME("5.3") PORT_CODE(KEYCODE_RSHIFT)
PORT_BIT(0xf0, IP_ACTIVE_LOW, IPT_UNUSED)
INPUT_PORTS_END
void nmkmedal_state::trocana(machine_config &config)
@ -61,7 +135,7 @@ void nmkmedal_state::trocana(machine_config &config)
m_maincpu->set_addrmap(AS_PROGRAM, &nmkmedal_state::mem_map);
SPEAKER(config, "mono").front_center();
OKIM6376(config, "oki", 16500000 / 16).add_route(ALL_OUTPUTS, "mono", 1.0); // actually MSM6650
OKIM6650(config, m_oki, 16500000 / 4).add_route(ALL_OUTPUTS, "mono", 1.0);
}
ROM_START( trocana)