summaryrefslogtreecommitdiffstatshomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/emu/bus/msx_cart/cartridge.c2
-rw-r--r--src/emu/bus/msx_cart/moonsound.c123
-rw-r--r--src/emu/bus/msx_cart/moonsound.h38
3 files changed, 163 insertions, 0 deletions
diff --git a/src/emu/bus/msx_cart/cartridge.c b/src/emu/bus/msx_cart/cartridge.c
index c8dfb3da9b8..9415ab2f3c0 100644
--- a/src/emu/bus/msx_cart/cartridge.c
+++ b/src/emu/bus/msx_cart/cartridge.c
@@ -16,6 +16,7 @@
#include "konami.h"
#include "korean.h"
#include "majutsushi.h"
+#include "moonsound.h"
#include "msx_audio.h"
#include "msxdos2.h"
#include "nomapper.h"
@@ -61,6 +62,7 @@ SLOT_INTERFACE_START(msx_cart)
SLOT_INTERFACE_INTERNAL("disk_fsfd1a", MSX_CART_FSFD1A)
SLOT_INTERFACE_INTERNAL("disk_fscf351", MSX_CART_FSCF351)
SLOT_INTERFACE("bm_012", MSX_CART_BM_012)
+ SLOT_INTERFACE("moonsound", MSX_CART_MOONSOUND)
SLOT_INTERFACE_END
diff --git a/src/emu/bus/msx_cart/moonsound.c b/src/emu/bus/msx_cart/moonsound.c
new file mode 100644
index 00000000000..93bbe1a8e0d
--- /dev/null
+++ b/src/emu/bus/msx_cart/moonsound.c
@@ -0,0 +1,123 @@
+// license:BSD-3-Clause
+// copyright-holders:Wilbert Pol
+/**********************************************************************************
+
+TODO:
+- Properly hook up correct SRAM sizes for different moonsound compatible
+ cartridges. (Original moonsound has 128KB SRAM)
+- Fix FM support (ymf262 support needs to be added to ymf278b).
+
+**********************************************************************************/
+
+#include "emu.h"
+#include "moonsound.h"
+
+
+#define VERBOSE 0
+#define LOG(x) do { if (VERBOSE) logerror x; } while (0)
+
+
+const device_type MSX_CART_MOONSOUND = &device_creator<msx_cart_moonsound>;
+
+
+msx_cart_moonsound::msx_cart_moonsound(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
+ : device_t(mconfig, MSX_CART_MOONSOUND, "MSX Cartridge - MOONSOUND", tag, owner, clock, "msx_cart_moonsound", __FILE__)
+ , msx_cart_interface(mconfig, *this)
+ , m_ymf278b(*this, "ymf278b")
+{
+}
+
+
+static ADDRESS_MAP_START( ymf278b_map, AS_0, 8, msx_cart_moonsound )
+ AM_RANGE(0x000000, 0x1fffff) AM_ROM
+ AM_RANGE(0x200000, 0x3fffff) AM_RAM // 2MB sram for testing
+ADDRESS_MAP_END
+
+
+static MACHINE_CONFIG_FRAGMENT( moonsound )
+ // This is actually incorrect. The sound output is passed back into the MSX machine where it is mixed internally and output through the system 'speaker'.
+ MCFG_SPEAKER_STANDARD_MONO("mono")
+ MCFG_SOUND_ADD("ymf278b", YMF278B, YMF278B_STD_CLOCK)
+ MCFG_DEVICE_ADDRESS_MAP(AS_0, ymf278b_map)
+ MCFG_YMF278B_IRQ_HANDLER(WRITELINE(msx_cart_moonsound,irq_w))
+ MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.40)
+MACHINE_CONFIG_END
+
+
+machine_config_constructor msx_cart_moonsound::device_mconfig_additions() const
+{
+ return MACHINE_CONFIG_NAME( moonsound );
+}
+
+
+ROM_START( msx_cart_moonsound )
+ ROM_REGION(0x400000, "ymf278b", 0)
+ ROM_LOAD("yrw801.rom", 0x0, 0x200000, CRC(2a9d8d43) SHA1(32760893ce06dbe3930627755ba065cc3d8ec6ca))
+ROM_END
+
+
+const rom_entry *msx_cart_moonsound::device_rom_region() const
+{
+ return ROM_NAME( msx_cart_moonsound );
+}
+
+
+void msx_cart_moonsound::device_start()
+{
+ m_out_irq_cb.resolve_safe();
+
+ // Install IO read/write handlers
+ address_space &space = machine().device<cpu_device>("maincpu")->space(AS_IO);
+ space.install_readwrite_handler(0x7e, 0x7f, read8_delegate(FUNC(msx_cart_moonsound::read_ymf278b_pcm), this), write8_delegate(FUNC(msx_cart_moonsound::write_ymf278b_pcm), this));
+ space.install_readwrite_handler(0xc4, 0xc7, read8_delegate(FUNC(msx_cart_moonsound::read_ymf278b_fm), this), write8_delegate(FUNC(msx_cart_moonsound::write_ymf278b_fm), this));
+ space.install_read_handler(0xc0, 0xc0, read8_delegate(FUNC(msx_cart_moonsound::read_c0), this));
+}
+
+
+void msx_cart_moonsound::device_reset()
+{
+}
+
+
+WRITE_LINE_MEMBER(msx_cart_moonsound::irq_w)
+{
+ LOG(("moonsound: irq state %d\n", state));
+ m_out_irq_cb(state);
+}
+
+
+WRITE8_MEMBER(msx_cart_moonsound::write_ymf278b_fm)
+{
+ LOG(("moonsound: write 0x%02x, data 0x%02x\n", 0xc4 + offset, data));
+ m_ymf278b->write(space, offset, data);
+}
+
+
+READ8_MEMBER(msx_cart_moonsound::read_ymf278b_fm)
+{
+ LOG(("moonsound: read 0x%02x\n", 0xc4 + offset));
+ return m_ymf278b->read(space, offset);
+}
+
+
+WRITE8_MEMBER(msx_cart_moonsound::write_ymf278b_pcm)
+{
+ LOG(("moonsound: write 0x%02x, data 0x%02x\n", 0x7e + offset, data));
+ m_ymf278b->write(space, 4 + offset, data);
+}
+
+
+READ8_MEMBER(msx_cart_moonsound::read_ymf278b_pcm)
+{
+ LOG(("moonsound: read 0x%02x\n", 0x7e + offset));
+ return m_ymf278b->read(space, 4 + offset);
+}
+
+
+// For detecting presence of moonsound cartridge
+READ8_MEMBER(msx_cart_moonsound::read_c0)
+{
+ LOG(("moonsound: read 0xc0\n"));
+ return 0x00;
+}
+
diff --git a/src/emu/bus/msx_cart/moonsound.h b/src/emu/bus/msx_cart/moonsound.h
new file mode 100644
index 00000000000..930fedb363c
--- /dev/null
+++ b/src/emu/bus/msx_cart/moonsound.h
@@ -0,0 +1,38 @@
+// license:BSD-3-Clause
+// copyright-holders:Wilbert Pol
+#ifndef __MSX_CART_MOONSOUND_H
+#define __MSX_CART_MOONSOUND_H
+
+#include "bus/msx_cart/cartridge.h"
+#include "sound/ymf278b.h"
+
+
+extern const device_type MSX_CART_MOONSOUND;
+
+
+class msx_cart_moonsound : public device_t
+ , public msx_cart_interface
+{
+public:
+ msx_cart_moonsound(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
+
+ // device-level overrides
+ virtual void device_start();
+ virtual void device_reset();
+ virtual machine_config_constructor device_mconfig_additions() const;
+ virtual const rom_entry *device_rom_region() const;
+
+ DECLARE_WRITE8_MEMBER(write_ymf278b_fm);
+ DECLARE_READ8_MEMBER(read_ymf278b_fm);
+ DECLARE_WRITE8_MEMBER(write_ymf278b_pcm);
+ DECLARE_READ8_MEMBER(read_ymf278b_pcm);
+ DECLARE_READ8_MEMBER(read_c0);
+ DECLARE_WRITE_LINE_MEMBER(irq_w);
+
+private:
+ required_device<ymf278b_device> m_ymf278b;
+
+};
+
+
+#endif