From 98e9a4b28d3d13aa31a0134168f8e925f7c04582 Mon Sep 17 00:00:00 2001 From: tildearrow Date: Sun, 22 May 2022 17:49:41 -0500 Subject: [PATCH] MSM6258 emulator de-MAMEfication --- CMakeLists.txt | 2 + src/engine/platform/sound/oki/okim6258.cpp | 59 +++++----------------- src/engine/platform/sound/oki/okim6258.h | 27 ++++------ 3 files changed, 24 insertions(+), 64 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 094e9ce00..5b71d8f70 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -323,6 +323,8 @@ src/engine/platform/sound/ymz280b.cpp src/engine/platform/sound/rf5c68.cpp +src/engine/platform/sound/oki/okim6258.cpp + src/engine/platform/oplAInterface.cpp src/engine/platform/ym2608Interface.cpp src/engine/platform/ym2610Interface.cpp diff --git a/src/engine/platform/sound/oki/okim6258.cpp b/src/engine/platform/sound/oki/okim6258.cpp index 349fe9ca1..5ccfcb3f3 100644 --- a/src/engine/platform/sound/oki/okim6258.cpp +++ b/src/engine/platform/sound/oki/okim6258.cpp @@ -11,8 +11,9 @@ **********************************************************************************************/ -#include "emu.h" #include "okim6258.h" +#include +#include #define COMMAND_STOP (1 << 0) #define COMMAND_PLAY (1 << 1) @@ -34,9 +35,6 @@ static int tables_computed = 0; -// device type definition -DEFINE_DEVICE_TYPE(OKIM6258, okim6258_device, "okim6258", "OKI MSM6258 ADPCM") - //************************************************************************** // LIVE DEVICE @@ -46,19 +44,18 @@ DEFINE_DEVICE_TYPE(OKIM6258, okim6258_device, "okim6258", "OKI MSM6258 ADPCM") // okim6258_device - constructor //------------------------------------------------- -okim6258_device::okim6258_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) - : device_t(mconfig, OKIM6258, tag, owner, clock), - device_sound_interface(mconfig, *this), +okim6258_device::okim6258_device(uint32_t clock) + : m_status(0), m_start_divider(0), m_divider(512), m_adpcm_type(0), m_data_in(0), m_nibble_shift(0), - m_stream(nullptr), m_output_bits(0), m_signal(0), - m_step(0) + m_step(0), + m_clock(clock) { } @@ -114,12 +111,8 @@ void okim6258_device::device_start() m_divider = dividers[m_start_divider]; - m_stream = stream_alloc(0, 1, clock()/m_divider); - m_signal = -2; m_step = 0; - - state_save_register(); } @@ -129,8 +122,6 @@ void okim6258_device::device_start() void okim6258_device::device_reset() { - m_stream->update(); - m_signal = -2; m_step = 0; m_status = 0; @@ -141,7 +132,7 @@ void okim6258_device::device_reset() // sound_stream_update - handle a stream update //------------------------------------------------- -void okim6258_device::sound_stream_update(sound_stream &stream, std::vector const &inputs, std::vector &outputs) +void okim6258_device::sound_stream_update(short** outputs, int len) { auto &buffer = outputs[0]; @@ -149,7 +140,7 @@ void okim6258_device::sound_stream_update(sound_stream &stream, std::vector> nibble_shift) & 0xf; @@ -159,7 +150,7 @@ void okim6258_device::sound_stream_update(sound_stream &stream, std::vectorset_sample_rate(clock() / m_divider); } @@ -248,7 +220,7 @@ void okim6258_device::device_clock_changed() int okim6258_device::get_vclk() { - return (clock() / m_divider); + return (m_clock / m_divider); } @@ -260,8 +232,6 @@ int okim6258_device::get_vclk() uint8_t okim6258_device::status_r() { - m_stream->update(); - return (m_status & STATUS_PLAYING) ? 0x00 : 0x80; } @@ -273,9 +243,6 @@ uint8_t okim6258_device::status_r() ***********************************************************************************************/ void okim6258_device::data_w(uint8_t data) { - /* update the stream */ - m_stream->update(); - m_data_in = data; m_nibble_shift = 0; } @@ -289,8 +256,6 @@ void okim6258_device::data_w(uint8_t data) void okim6258_device::ctrl_w(uint8_t data) { - m_stream->update(); - if (data & COMMAND_STOP) { m_status &= ~(STATUS_PLAYING | STATUS_RECORDING); @@ -316,7 +281,7 @@ void okim6258_device::ctrl_w(uint8_t data) if (data & COMMAND_RECORD) { - logerror("M6258: Record enabled\n"); + //logerror("M6258: Record enabled\n"); m_status |= STATUS_RECORDING; } else diff --git a/src/engine/platform/sound/oki/okim6258.h b/src/engine/platform/sound/oki/okim6258.h index 95189f0ef..689bac5a0 100644 --- a/src/engine/platform/sound/oki/okim6258.h +++ b/src/engine/platform/sound/oki/okim6258.h @@ -3,8 +3,7 @@ #ifndef MAME_SOUND_OKIM6258_H #define MAME_SOUND_OKIM6258_H -#pragma once - +#include //************************************************************************** // TYPE DEFINITIONS @@ -12,9 +11,7 @@ // ======================> okim6258_device -class okim6258_device : public device_t, - public device_sound_interface -{ +class okim6258_device { public: static constexpr int FOSC_DIV_BY_1024 = 0; static constexpr int FOSC_DIV_BY_768 = 1; @@ -26,7 +23,7 @@ public: static constexpr int OUTPUT_10BITS = 10; static constexpr int OUTPUT_12BITS = 12; - okim6258_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); + okim6258_device(uint32_t clock); // configuration void set_start_div(int div) { m_start_divider = div; } @@ -40,17 +37,15 @@ public: void set_divider(int val); int get_vclk(); -protected: - // device-level overrides - virtual void device_start() override; - virtual void device_reset() override; - virtual void device_clock_changed() override; + // device-levels + virtual void device_start(); + virtual void device_reset(); + virtual void device_clock_changed(); - // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector const &inputs, std::vector &outputs) override; + // sound stream updates + virtual void sound_stream_update(short** outputs, int len); private: - void state_save_register(); int16_t clock_adpcm(uint8_t nibble); uint8_t m_status; @@ -60,15 +55,13 @@ private: uint8_t m_adpcm_type; /* 3/4 bit ADPCM select */ uint8_t m_data_in; /* ADPCM data-in register */ uint8_t m_nibble_shift; /* nibble select */ - sound_stream *m_stream; /* which stream are we playing on? */ uint8_t m_output_bits; /* D/A precision is 10-bits but 12-bit data can be output serially to an external DAC */ int32_t m_signal; int32_t m_step; + unsigned int m_clock; }; -DECLARE_DEVICE_TYPE(OKIM6258, okim6258_device) - #endif // MAME_SOUND_OKIM6258_H