msx.c: Start hooking up moonsound; not fully working yet (nw)

This commit is contained in:
Wilbert Pol 2015-07-19 14:36:12 +02:00
parent 16d785db9c
commit 69f5f49c52
5 changed files with 166 additions and 1 deletions

View File

@ -890,6 +890,8 @@ if (BUSES["MSX_SLOT"]~=null) then
MAME_DIR .. "src/emu/bus/msx_cart/korean.h",
MAME_DIR .. "src/emu/bus/msx_cart/majutsushi.c",
MAME_DIR .. "src/emu/bus/msx_cart/majutsushi.h",
MAME_DIR .. "src/emu/bus/msx_cart/moonsound.h",
MAME_DIR .. "src/emu/bus/msx_cart/moonsound.c",
MAME_DIR .. "src/emu/bus/msx_cart/msx_audio.c",
MAME_DIR .. "src/emu/bus/msx_cart/msx_audio.h",
MAME_DIR .. "src/emu/bus/msx_cart/msx_audio_kb.c",

View File

@ -156,7 +156,7 @@ SOUNDS["YM3526"] = true
SOUNDS["Y8950"] = true
SOUNDS["YMF262"] = true
--SOUNDS["YMF271"] = true
--SOUNDS["YMF278B"] = true
SOUNDS["YMF278B"] = true
--SOUNDS["YMZ280B"] = true
SOUNDS["SN76477"] = true
SOUNDS["SN76496"] = true

View File

@ -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

View File

@ -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;
}

View File

@ -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