Skip to content

Commit

Permalink
Various Super Cassette Vision updates (#12933)
Browse files Browse the repository at this point in the history
scv.xml: Promote starspdr to partially supported.
devices/sound/upd1771.cpp: Reset m_state when resetting state in pcm_write (fixes hanging sound in some games).

bus/scv/rom;cpp: Move implementations to anonymous namespace.

bus/scv/slot.cpp: Let cartridges install themselves.

epoch/scv.cpp:
- Tweak scv_pal video timings to get closer to 50Hz refresh rate.
- Block graphic color 0 is transparent (fixes Ton Ton Ball background).
- Update comments.
  • Loading branch information
wilbertpol authored Nov 6, 2024
1 parent ae250c5 commit 1ee0573
Show file tree
Hide file tree
Showing 7 changed files with 547 additions and 823 deletions.
4 changes: 2 additions & 2 deletions hash/scv.xml
Original file line number Diff line number Diff line change
Expand Up @@ -363,11 +363,11 @@ Information found at http://www.rhod.fr/yeno_epoch.html
</part>
</software>

<software name="starspdr" supported="no">
<software name="starspdr" supported="partial">
<description>Star Speeder</description>
<year>1985</year>
<publisher>Epoch</publisher>
<notes>Game does not start.</notes>
<notes>uPD1771 adpcm playback is not supported.</notes>
<part name="cart" interface="scv_cart">
<feature name="slot" value="rom64k"/>
<dataarea name="rom" size="0x10000">
Expand Down
258 changes: 149 additions & 109 deletions src/devices/bus/scv/rom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,191 +13,231 @@
#include "rom.h"


//-------------------------------------------------
// scv_rom_device - constructor
//-------------------------------------------------
namespace {

DEFINE_DEVICE_TYPE(SCV_ROM8K, scv_rom8_device, "scv_rom8", "SCV 8K Carts")
DEFINE_DEVICE_TYPE(SCV_ROM16K, scv_rom16_device, "scv_rom16", "SCV 16K Carts")
DEFINE_DEVICE_TYPE(SCV_ROM32K, scv_rom32_device, "scv_rom32", "SCV 32K Carts")
DEFINE_DEVICE_TYPE(SCV_ROM32K_RAM8K, scv_rom32ram8_device, "scv_rom32_ram8", "SCV 32K + RAM 8K Carts")
DEFINE_DEVICE_TYPE(SCV_ROM64K, scv_rom64_device, "scv_rom64", "SCV 64K Carts")
DEFINE_DEVICE_TYPE(SCV_ROM128K, scv_rom128_device, "scv_rom128", "SCV 128K Carts")
DEFINE_DEVICE_TYPE(SCV_ROM128K_RAM4K, scv_rom128ram4_device, "scv_rom128_ram4", "SCV 128K + RAM 4K Carts")
class scv_rom8_device : public device_t,
public device_scv_cart_interface
{
public:
scv_rom8_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock)
: scv_rom8_device(mconfig, SCV_ROM8K, tag, owner, clock)
{ }

virtual void install_memory_handlers(address_space *space) override;

scv_rom8_device::scv_rom8_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock)
: device_t(mconfig, type, tag, owner, clock), device_scv_cart_interface(mconfig, *this)
{
}
protected:
scv_rom8_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, u32 clock)
: device_t(mconfig, type, tag, owner, clock), device_scv_cart_interface(mconfig, *this)
{ }

scv_rom8_device::scv_rom8_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
: scv_rom8_device(mconfig, SCV_ROM8K, tag, owner, clock)
{
}
virtual void device_start() override { }
virtual void device_reset() override { }

scv_rom16_device::scv_rom16_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
: scv_rom8_device(mconfig, SCV_ROM16K, tag, owner, clock)
{
}
static constexpr u16 CARTRIDGE_ADDRESS_END = 0xff7f;
};

scv_rom32_device::scv_rom32_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
: scv_rom8_device(mconfig, SCV_ROM32K, tag, owner, clock)
void scv_rom8_device::install_memory_handlers(address_space *space)
{
space->install_rom(0x8000, 0x9fff, cart_rom_region()->base());
space->install_rom(0xa000, 0xbfff, cart_rom_region()->base());
space->install_rom(0xc000, 0xdfff, cart_rom_region()->base());
space->install_rom(0xe000, CARTRIDGE_ADDRESS_END, cart_rom_region()->base());
}

scv_rom32ram8_device::scv_rom32ram8_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
: scv_rom8_device(mconfig, SCV_ROM32K_RAM8K, tag, owner, clock), m_ram_enabled(0)
{
}

scv_rom64_device::scv_rom64_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
: scv_rom8_device(mconfig, SCV_ROM64K, tag, owner, clock), m_bank_base(0)
{
}

scv_rom128_device::scv_rom128_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
: scv_rom8_device(mconfig, SCV_ROM128K, tag, owner, clock), m_bank_base(0)
class scv_rom16_device : public scv_rom8_device
{
}
public:
scv_rom16_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock)
: scv_rom8_device(mconfig, SCV_ROM16K, tag, owner, clock)
{ }

virtual void install_memory_handlers(address_space *space) override;
};

scv_rom128ram4_device::scv_rom128ram4_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
: scv_rom8_device(mconfig, SCV_ROM128K_RAM4K, tag, owner, clock), m_bank_base(0), m_ram_enabled(0)
void scv_rom16_device::install_memory_handlers(address_space *space)
{
space->install_rom(0x8000, 0xbfff, cart_rom_region()->base());
space->install_rom(0xc000, CARTRIDGE_ADDRESS_END, cart_rom_region()->base());
}


//-------------------------------------------------
// mapper specific start/reset
//-------------------------------------------------

void scv_rom32ram8_device::device_start()
class scv_rom32_device : public scv_rom8_device
{
save_item(NAME(m_ram_enabled));
}
public:
scv_rom32_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock)
: scv_rom8_device(mconfig, SCV_ROM32K, tag, owner, clock)
{ }

void scv_rom32ram8_device::device_reset()
virtual void install_memory_handlers(address_space *space) override;
};

void scv_rom32_device::install_memory_handlers(address_space *space)
{
m_ram_enabled = 1;
space->install_rom(0x8000, CARTRIDGE_ADDRESS_END, cart_rom_region()->base());
}


void scv_rom64_device::device_start()
{
save_item(NAME(m_bank_base));
}

void scv_rom64_device::device_reset()
class scv_rom32ram8_device : public scv_rom8_device
{
m_bank_base = 0;
}
public:
scv_rom32ram8_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock)
: scv_rom8_device(mconfig, SCV_ROM32K_RAM8K, tag, owner, clock)
, m_view(*this, "view")
{ }

virtual void install_memory_handlers(address_space *space) override;
virtual void write_bank(uint8_t data) override;

void scv_rom128_device::device_start()
{
save_item(NAME(m_bank_base));
}
protected:
virtual void device_reset() override ATTR_COLD;

void scv_rom128_device::device_reset()
private:
memory_view m_view;
};

void scv_rom32ram8_device::device_reset()
{
m_bank_base = 0;
m_view.select(1);
}


void scv_rom128ram4_device::device_start()
void scv_rom32ram8_device::install_memory_handlers(address_space *space)
{
save_item(NAME(m_bank_base));
save_item(NAME(m_ram_enabled));
space->install_rom(0x8000, CARTRIDGE_ADDRESS_END, cart_rom_region()->base());
space->install_view(0xe000, CARTRIDGE_ADDRESS_END, m_view);
m_view[0];
m_view[1].install_ram(0xe000, CARTRIDGE_ADDRESS_END, cart_ram_region()->base());
}

void scv_rom128ram4_device::device_reset()
void scv_rom32ram8_device::write_bank(uint8_t data)
{
m_bank_base = 0;
m_ram_enabled = 1;
m_view.select(BIT(data, 5));
}



/*-------------------------------------------------
mapper specific handlers
-------------------------------------------------*/

uint8_t scv_rom8_device::read_cart(offs_t offset)
class scv_rom64_device : public scv_rom8_device
{
return m_rom[offset & 0x1fff];
}
public:
scv_rom64_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock)
: scv_rom8_device(mconfig, SCV_ROM64K, tag, owner, clock)
, m_bank(*this, "bank")
{ }

virtual void install_memory_handlers(address_space *space) override;
virtual void write_bank(uint8_t data) override;

uint8_t scv_rom16_device::read_cart(offs_t offset)
{
return m_rom[offset & 0x3fff];
}
protected:
virtual void device_reset() override ATTR_COLD;

private:
memory_bank_creator m_bank;
};

uint8_t scv_rom32_device::read_cart(offs_t offset)
void scv_rom64_device::device_reset()
{
return m_rom[offset];
m_bank->set_entry(0);
}


uint8_t scv_rom32ram8_device::read_cart(offs_t offset)
void scv_rom64_device::install_memory_handlers(address_space *space)
{
if (m_ram_enabled && offset >= 0x6000)
return m_ram[offset & 0x1fff];

return m_rom[offset];
m_bank->configure_entries(0, 2, cart_rom_region()->base(), 0x8000);
space->install_read_bank(0x8000, CARTRIDGE_ADDRESS_END, m_bank);
}

void scv_rom32ram8_device::write_cart(offs_t offset, uint8_t data)
void scv_rom64_device::write_bank(uint8_t data)
{
if (m_ram_enabled && offset >= 0x6000)
m_ram[offset & 0x1fff] = data;
m_bank->set_entry(BIT(data, 5));
}

void scv_rom32ram8_device::write_bank(uint8_t data)
{
m_ram_enabled = BIT(data, 5);
}


uint8_t scv_rom64_device::read_cart(offs_t offset)
class scv_rom128_device : public scv_rom8_device
{
return m_rom[offset + (m_bank_base * 0x8000)];
}
public:
scv_rom128_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock)
: scv_rom8_device(mconfig, SCV_ROM128K, tag, owner, clock)
, m_bank(*this, "bank")
{ }

void scv_rom64_device::write_bank(uint8_t data)
virtual void install_memory_handlers(address_space *space) override;
virtual void write_bank(uint8_t data) override;

protected:
virtual void device_reset() override ATTR_COLD;

private:
memory_bank_creator m_bank;
};

void scv_rom128_device::device_reset()
{
m_bank_base = BIT(data, 5);
m_bank->set_entry(0);
}


uint8_t scv_rom128_device::read_cart(offs_t offset)
void scv_rom128_device::install_memory_handlers(address_space *space)
{
return m_rom[offset + (m_bank_base * 0x8000)];
m_bank->configure_entries(0, 4, cart_rom_region()->base(), 0x8000);
space->install_read_bank(0x8000, CARTRIDGE_ADDRESS_END, m_bank);
}

void scv_rom128_device::write_bank(uint8_t data)
{
m_bank_base = (data >> 5) & 0x03;
m_bank->set_entry((data >> 5) & 0x03);
}


uint8_t scv_rom128ram4_device::read_cart(offs_t offset)

class scv_rom128ram4_device : public scv_rom8_device
{
if (m_ram_enabled && offset >= 0x7000)
return m_ram[offset & 0xfff];
public:
scv_rom128ram4_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock)
: scv_rom8_device(mconfig, SCV_ROM128K_RAM4K, tag, owner, clock)
, m_bank(*this, "bank")
, m_view(*this, "view")
{ }

virtual void install_memory_handlers(address_space *space) override;
virtual void write_bank(uint8_t data) override;

return m_rom[offset + (m_bank_base * 0x8000)];
protected:
virtual void device_reset() override ATTR_COLD;

private:
memory_bank_creator m_bank;
memory_view m_view;
};

void scv_rom128ram4_device::device_reset()
{
m_bank->set_entry(0);
m_view.select(0);
}

void scv_rom128ram4_device::write_cart(offs_t offset, uint8_t data)
void scv_rom128ram4_device::install_memory_handlers(address_space *space)
{
if (m_ram_enabled && offset >= 0x7000)
m_ram[offset & 0xfff] = data;
m_bank->configure_entries(0, 4, cart_rom_region()->base(), 0x8000);
space->install_read_bank(0x8000, CARTRIDGE_ADDRESS_END, m_bank);
space->install_view(0xf000, CARTRIDGE_ADDRESS_END, m_view);
m_view[0];
m_view[1].install_ram(0xf000, CARTRIDGE_ADDRESS_END, cart_ram_region()->base());
}

void scv_rom128ram4_device::write_bank(uint8_t data)
{
m_bank_base = (data >> 5) & 0x03;
m_ram_enabled = BIT(data, 6);
m_bank->set_entry((data >> 5) & 0x03);
m_view.select(BIT(data, 6));
}

} // anonymous namespace

DEFINE_DEVICE_TYPE_PRIVATE(SCV_ROM8K, device_scv_cart_interface, scv_rom8_device, "scv_rom8", "SCV 8K Cartridge")
DEFINE_DEVICE_TYPE_PRIVATE(SCV_ROM16K, device_scv_cart_interface, scv_rom16_device, "scv_rom16", "SCV 16K Cartridge")
DEFINE_DEVICE_TYPE_PRIVATE(SCV_ROM32K, device_scv_cart_interface, scv_rom32_device, "scv_rom32", "SCV 32K Cartridge")
DEFINE_DEVICE_TYPE_PRIVATE(SCV_ROM32K_RAM8K, device_scv_cart_interface, scv_rom32ram8_device, "scv_rom32_ram8", "SCV 32K + RAM 8K Cartridge")
DEFINE_DEVICE_TYPE_PRIVATE(SCV_ROM64K, device_scv_cart_interface, scv_rom64_device, "scv_rom64", "SCV 64K Cartridge")
DEFINE_DEVICE_TYPE_PRIVATE(SCV_ROM128K, device_scv_cart_interface, scv_rom128_device, "scv_rom128", "SCV 128K Cartridge")
DEFINE_DEVICE_TYPE_PRIVATE(SCV_ROM128K_RAM4K, device_scv_cart_interface, scv_rom128ram4_device, "scv_rom128_ram4", "SCV 128K + RAM 4K Cartridge")
Loading

0 comments on commit 1ee0573

Please sign in to comment.