SNES cartridge/clock refinements (nw)

- Eliminate MCFG macros
- Use callback for cartridge IRQ
- Clock cartridge slot and PPU at MCLK
- Derive SuperFX clock from configured MCLK
This commit is contained in:
AJR 2018-12-09 10:58:05 -05:00
parent d9130865c6
commit 62af3e0b1c
10 changed files with 100 additions and 46 deletions

View File

@ -244,17 +244,20 @@ static void bsx_cart(device_slot_interface &device)
// device_add_mconfig - add device configuration
//-------------------------------------------------
MACHINE_CONFIG_START(sns_rom_bsx_device::device_add_mconfig)
MCFG_SNS_BSX_CARTRIDGE_ADD("bs_slot", bsx_cart, nullptr)
MACHINE_CONFIG_END
void sns_rom_bsx_device::device_add_mconfig(machine_config &config)
{
SNS_BSX_CART_SLOT(config, m_slot, bsx_cart, nullptr);
}
MACHINE_CONFIG_START(sns_rom_bsxlo_device::device_add_mconfig)
MCFG_SNS_BSX_CARTRIDGE_ADD("bs_slot", bsx_cart, nullptr)
MACHINE_CONFIG_END
void sns_rom_bsxlo_device::device_add_mconfig(machine_config &config)
{
SNS_BSX_CART_SLOT(config, m_slot, bsx_cart, nullptr);
}
MACHINE_CONFIG_START(sns_rom_bsxhi_device::device_add_mconfig)
MCFG_SNS_BSX_CARTRIDGE_ADD("bs_slot", bsx_cart, nullptr)
MACHINE_CONFIG_END
void sns_rom_bsxhi_device::device_add_mconfig(machine_config &config)
{
SNS_BSX_CART_SLOT(config, m_slot, bsx_cart, nullptr);
}
/*-------------------------------------------------

View File

@ -170,11 +170,11 @@ void sns_sa1_device::recalc_irqs()
{
if (m_scpu_flags & m_scpu_sie & (SCPU_IRQ_SA1|SCPU_IRQ_CHARCONV))
{
machine().device("maincpu")->execute().set_input_line(G65816_LINE_IRQ, ASSERT_LINE);
write_irq(ASSERT_LINE);
}
else
{
machine().device("maincpu")->execute().set_input_line(G65816_LINE_IRQ, CLEAR_LINE);
write_irq(CLEAR_LINE);
}
if (m_sa1_flags & m_sa1_sie & (SA1_IRQ_SCPU|SA1_IRQ_TIMER|SA1_IRQ_DMA))

View File

@ -9,7 +9,6 @@
#include "emu.h"
#include "sfx.h"
#include "cpu/g65816/g65816.h"
//-------------------------------------------------
// sns_rom_superfx_device - constructor
@ -82,13 +81,13 @@ void sns_rom_superfx_device::sfx_map(address_map &map)
WRITE_LINE_MEMBER(sns_rom_superfx_device::snes_extern_irq_w)
{
machine().device("maincpu")->execute().set_input_line(G65816_LINE_IRQ, state);
write_irq(state);
}
void sns_rom_superfx_device::device_add_mconfig(machine_config &config)
{
SUPERFX(config, m_superfx, 21480000); /* 21.48MHz */
SUPERFX(config, m_superfx, DERIVED_CLOCK(1, 1)); /* 21.48MHz */
m_superfx->set_addrmap(AS_PROGRAM, &sns_rom_superfx_device::sfx_map);
m_superfx->irq().set(FUNC(sns_rom_superfx_device::snes_extern_irq_w)); /* IRQ line from cart */
}

View File

@ -71,7 +71,8 @@ DEFINE_DEVICE_TYPE(SNS_BSX_CART_SLOT, sns_bsx_cart_slot_device, "sns_bsx_c
device_sns_cart_interface::device_sns_cart_interface(const machine_config &mconfig, device_t &device) :
device_slot_card_interface(mconfig, device),
m_rom(nullptr),
m_rom_size(0)
m_rom_size(0),
m_slot(nullptr)
{
}
@ -165,6 +166,17 @@ void device_sns_cart_interface::rom_map_setup(uint32_t size)
// }
}
//-------------------------------------------------
// write_irq - set the cart IRQ output
//-------------------------------------------------
WRITE_LINE_MEMBER(device_sns_cart_interface::write_irq)
{
if (m_slot != nullptr)
m_slot->write_irq(state);
}
//**************************************************************************
// LIVE DEVICE
//**************************************************************************
@ -178,7 +190,8 @@ base_sns_cart_slot_device::base_sns_cart_slot_device(const machine_config &mconf
device_slot_interface(mconfig, *this),
m_addon(ADDON_NONE),
m_type(SNES_MODE20),
m_cart(nullptr)
m_cart(nullptr),
m_irq_callback(*this)
{
}
@ -212,6 +225,9 @@ base_sns_cart_slot_device::~base_sns_cart_slot_device()
void base_sns_cart_slot_device::device_start()
{
m_cart = dynamic_cast<device_sns_cart_interface *>(get_card_device());
m_cart->m_slot = this;
m_irq_callback.resolve_safe();
}

View File

@ -98,10 +98,14 @@ enum
ADDON_Z80GB
};
class base_sns_cart_slot_device;
// ======================> device_sns_cart_interface
class device_sns_cart_interface : public device_slot_card_interface
{
friend class base_sns_cart_slot_device;
public:
// construction/destruction
virtual ~device_sns_cart_interface();
@ -137,6 +141,8 @@ public:
protected:
device_sns_cart_interface(const machine_config &mconfig, device_t &device);
DECLARE_WRITE_LINE_MEMBER(write_irq);
// internal state
uint8_t *m_rom;
uint32_t m_rom_size;
@ -145,6 +151,8 @@ protected:
std::vector<uint8_t> m_rtc_ram; // temp pointer to save RTC ram to nvram (will disappear when RTCs become devices)
uint8_t rom_bank_map[256]; // 32K chunks of rom
base_sns_cart_slot_device *m_slot;
};
@ -158,6 +166,9 @@ public:
// construction/destruction
virtual ~base_sns_cart_slot_device();
// configuration
auto irq_callback() { return m_irq_callback.bind(); }
// device-level overrides
virtual void device_start() override;
@ -187,14 +198,16 @@ public:
virtual std::string get_default_card_software(get_default_card_software_hook &hook) const override;
// reading and writing
virtual DECLARE_READ8_MEMBER(read_l);
virtual DECLARE_READ8_MEMBER(read_h);
virtual DECLARE_READ8_MEMBER(read_ram);
virtual DECLARE_WRITE8_MEMBER(write_l);
virtual DECLARE_WRITE8_MEMBER(write_h);
virtual DECLARE_WRITE8_MEMBER(write_ram);
virtual DECLARE_READ8_MEMBER(chip_read);
virtual DECLARE_WRITE8_MEMBER(chip_write);
DECLARE_READ8_MEMBER(read_l);
DECLARE_READ8_MEMBER(read_h);
DECLARE_READ8_MEMBER(read_ram);
DECLARE_WRITE8_MEMBER(write_l);
DECLARE_WRITE8_MEMBER(write_h);
DECLARE_WRITE8_MEMBER(write_ram);
DECLARE_READ8_MEMBER(chip_read);
DECLARE_WRITE8_MEMBER(chip_write);
DECLARE_WRITE_LINE_MEMBER(write_irq) { m_irq_callback(state); }
// in order to support legacy dumps + add-on CPU dump appended at the end of the file, we
// check if the required data is present and update bank map accordingly
@ -214,6 +227,9 @@ public:
protected:
base_sns_cart_slot_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock);
private:
devcb_write_line m_irq_callback;
};
// ======================> sns_cart_slot_device
@ -222,6 +238,15 @@ class sns_cart_slot_device : public base_sns_cart_slot_device
{
public:
// construction/destruction
template <typename T>
sns_cart_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock, T &&opts, const char *dflt)
: sns_cart_slot_device(mconfig, tag, owner, clock)
{
option_reset();
opts(*this);
set_default_option(dflt);
set_fixed(false);
}
sns_cart_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
virtual const char *image_interface() const override { return "snes_cart"; }
virtual const char *file_extensions() const override { return "sfc"; }
@ -233,6 +258,15 @@ class sns_sufami_cart_slot_device : public base_sns_cart_slot_device
{
public:
// construction/destruction
template <typename T>
sns_sufami_cart_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, T &&opts, const char *dflt)
: sns_sufami_cart_slot_device(mconfig, tag, owner, 0)
{
option_reset();
opts(*this);
set_default_option(dflt);
set_fixed(false);
}
sns_sufami_cart_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
virtual const char *image_interface() const override { return "st_cart"; }
virtual const char *file_extensions() const override { return "st"; }
@ -245,6 +279,15 @@ class sns_bsx_cart_slot_device : public base_sns_cart_slot_device
{
public:
// construction/destruction
template <typename T>
sns_bsx_cart_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, T &&opts, const char *dflt)
: sns_bsx_cart_slot_device(mconfig, tag, owner, 0)
{
option_reset();
opts(*this);
set_default_option(dflt);
set_fixed(false);
}
sns_bsx_cart_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
virtual const char *image_interface() const override { return "bspack"; }
virtual const char *file_extensions() const override { return "bs"; }
@ -265,17 +308,4 @@ DECLARE_DEVICE_TYPE(SNS_BSX_CART_SLOT, sns_bsx_cart_slot_device)
#define SNSSLOT_ROM_REGION_TAG ":cart:rom"
#define MCFG_SNS_CARTRIDGE_ADD(_tag,_slot_intf,_def_slot) \
MCFG_DEVICE_ADD(_tag, SNS_CART_SLOT, 0) \
MCFG_DEVICE_SLOT_INTERFACE(_slot_intf, _def_slot, false)
#define MCFG_SNS_SUFAMI_CARTRIDGE_ADD(_tag,_slot_intf,_def_slot) \
MCFG_DEVICE_ADD(_tag, SNS_SUFAMI_CART_SLOT, 0) \
MCFG_DEVICE_SLOT_INTERFACE(_slot_intf, _def_slot, false)
#define MCFG_SNS_BSX_CARTRIDGE_ADD(_tag,_slot_intf,_def_slot) \
MCFG_DEVICE_ADD(_tag, SNS_BSX_CART_SLOT, 0) \
MCFG_DEVICE_SLOT_INTERFACE(_slot_intf, _def_slot, false)
#endif // MAME_BUS_SNES_SNES_SLOT_H

View File

@ -56,10 +56,11 @@ static void sufamiturbo_cart(device_slot_interface &device)
// device_add_mconfig - add device configuration
//-------------------------------------------------
MACHINE_CONFIG_START(sns_rom_sufami_device::device_add_mconfig)
MCFG_SNS_SUFAMI_CARTRIDGE_ADD("st_slot1", sufamiturbo_cart, nullptr)
MCFG_SNS_SUFAMI_CARTRIDGE_ADD("st_slot2", sufamiturbo_cart, nullptr)
MACHINE_CONFIG_END
void sns_rom_sufami_device::device_add_mconfig(machine_config &config)
{
SNS_SUFAMI_CART_SLOT(config, m_slot1, sufamiturbo_cart, nullptr);
SNS_SUFAMI_CART_SLOT(config, m_slot2, sufamiturbo_cart, nullptr);
}
/*-------------------------------------------------
mapper specific handlers

View File

@ -871,7 +871,7 @@ MACHINE_CONFIG_START(nss_state::nss)
MCFG_SCREEN_UPDATE_DRIVER( snes_state, screen_update )
MCFG_SCREEN_VBLANK_CALLBACK(WRITELINE(*this, nss_state, nss_vblank_irq))
SNES_PPU(config, m_ppu, 0);
SNES_PPU(config, m_ppu, MCLK_NTSC);
m_ppu->open_bus_callback().set([this] { return snes_open_bus_r(); }); // lambda because overloaded function name
m_ppu->set_screen("screen");

View File

@ -492,7 +492,7 @@ MACHINE_CONFIG_START(sfcbox_state::sfcbox)
MCFG_SCREEN_RAW_PARAMS(DOTCLK_NTSC, SNES_HTOTAL, 0, SNES_SCR_WIDTH, SNES_VTOTAL_NTSC, 0, SNES_SCR_HEIGHT_NTSC)
MCFG_SCREEN_UPDATE_DRIVER( snes_state, screen_update )
SNES_PPU(config, m_ppu, 0);
SNES_PPU(config, m_ppu, MCLK_NTSC);
m_ppu->open_bus_callback().set([this] { return snes_open_bus_r(); }); // lambda because overloaded function name
m_ppu->set_screen("screen");

View File

@ -1352,7 +1352,7 @@ MACHINE_CONFIG_START(snes_console_state::snes)
MCFG_SCREEN_RAW_PARAMS(DOTCLK_NTSC * 2, SNES_HTOTAL * 2, 0, SNES_SCR_WIDTH * 2, SNES_VTOTAL_NTSC, 0, SNES_SCR_HEIGHT_NTSC)
MCFG_SCREEN_UPDATE_DRIVER( snes_state, screen_update )
SNES_PPU(config, m_ppu, 0);
SNES_PPU(config, m_ppu, MCLK_NTSC);
m_ppu->open_bus_callback().set([this] { return snes_open_bus_r(); }); // lambda because overloaded function name
m_ppu->set_screen("screen");
@ -1369,7 +1369,9 @@ MACHINE_CONFIG_START(snes_console_state::snes)
MCFG_SOUND_ROUTE(0, "lspeaker", 1.00)
MCFG_SOUND_ROUTE(1, "rspeaker", 1.00)
MCFG_SNS_CARTRIDGE_ADD("snsslot", snes_cart, nullptr)
SNS_CART_SLOT(config, m_cartslot, MCLK_NTSC, snes_cart, nullptr);
m_cartslot->irq_callback().set_inputline(m_maincpu, G65816_LINE_IRQ);
MCFG_SOFTWARE_LIST_ADD("cart_list","snes")
MCFG_SOFTWARE_LIST_ADD("bsx_list","snes_bspack")
MCFG_SOFTWARE_LIST_ADD("st_list","snes_strom")
@ -1382,6 +1384,9 @@ MACHINE_CONFIG_START(snes_console_state::snespal)
MCFG_SCREEN_MODIFY("screen")
MCFG_SCREEN_RAW_PARAMS(DOTCLK_PAL, SNES_HTOTAL, 0, SNES_SCR_WIDTH, SNES_VTOTAL_PAL, 0, SNES_SCR_HEIGHT_PAL)
m_ppu->set_clock(MCLK_PAL);
m_cartslot->set_clock(MCLK_PAL);
MACHINE_CONFIG_END

View File

@ -719,7 +719,7 @@ MACHINE_CONFIG_START(snesb_state::kinstb)
MCFG_SCREEN_RAW_PARAMS(DOTCLK_NTSC, SNES_HTOTAL, 0, SNES_SCR_WIDTH, SNES_VTOTAL_NTSC, 0, SNES_SCR_HEIGHT_NTSC)
MCFG_SCREEN_UPDATE_DRIVER( snes_state, screen_update )
SNES_PPU(config, m_ppu, 0);
SNES_PPU(config, m_ppu, MCLK_NTSC);
m_ppu->open_bus_callback().set([this] { return snes_open_bus_r(); }); // lambda because overloaded function name
m_ppu->set_screen("screen");