mirror of
https://github.com/holub/mame
synced 2025-10-05 08:41:31 +03:00
csd: Update interface to better reflect real hardware, add address
deocoding PAL and verify memory map
This commit is contained in:
parent
0295ac745d
commit
fe3f74a3e9
@ -16,135 +16,20 @@
|
||||
|
||||
extern const device_type MIDWAY_CHEAP_SQUEAK_DELUXE = &device_creator<midway_cheap_squeak_deluxe_device>;
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// midway_cheap_squeak_deluxe_device - constructor
|
||||
// audio cpu map
|
||||
//-------------------------------------------------
|
||||
|
||||
midway_cheap_squeak_deluxe_device::midway_cheap_squeak_deluxe_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
|
||||
: device_t(mconfig, MIDWAY_CHEAP_SQUEAK_DELUXE, "Cheap Squeak Deluxe Sound Board", tag, owner, clock, "midcsd", __FILE__),
|
||||
device_mixer_interface(mconfig, *this),
|
||||
m_cpu(*this, "cpu"),
|
||||
m_pia(*this, "pia"),
|
||||
m_dac(*this, "dac"),
|
||||
m_status(0),
|
||||
m_dacval(0)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// read - return the status value
|
||||
//-------------------------------------------------
|
||||
|
||||
READ8_MEMBER(midway_cheap_squeak_deluxe_device::read)
|
||||
{
|
||||
return m_status;
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// write - handle an external write to the input
|
||||
// latch
|
||||
//-------------------------------------------------
|
||||
|
||||
WRITE8_MEMBER(midway_cheap_squeak_deluxe_device::write)
|
||||
{
|
||||
synchronize(0, data);
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// reset_write - write to the reset line
|
||||
//-------------------------------------------------
|
||||
|
||||
WRITE_LINE_MEMBER(midway_cheap_squeak_deluxe_device::reset_write)
|
||||
{
|
||||
m_cpu->set_input_line(INPUT_LINE_RESET, state ? ASSERT_LINE : CLEAR_LINE);
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// porta_w - PIA port A writes
|
||||
//-------------------------------------------------
|
||||
|
||||
WRITE8_MEMBER(midway_cheap_squeak_deluxe_device::porta_w)
|
||||
{
|
||||
m_dacval = (data << 2) | (m_dacval & 3);
|
||||
m_dac->write(m_dacval);
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// portb_w - PIA port B writes
|
||||
//-------------------------------------------------
|
||||
|
||||
WRITE8_MEMBER(midway_cheap_squeak_deluxe_device::portb_w)
|
||||
{
|
||||
m_dacval = (m_dacval & ~3) | (data >> 6);
|
||||
m_dac->write(m_dacval);
|
||||
|
||||
uint8_t z_mask = m_pia->port_b_z_mask();
|
||||
if (~z_mask & 0x10) m_status = (m_status & ~1) | ((data >> 4) & 1);
|
||||
if (~z_mask & 0x20) m_status = (m_status & ~2) | ((data >> 4) & 2);
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// irq_w - IRQ line state changes
|
||||
//-------------------------------------------------
|
||||
|
||||
WRITE_LINE_MEMBER(midway_cheap_squeak_deluxe_device::irq_w)
|
||||
{
|
||||
int combined_state = m_pia->irq_a_state() | m_pia->irq_b_state();
|
||||
m_cpu->set_input_line(4, combined_state ? ASSERT_LINE : CLEAR_LINE);
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// pia_r - PIA read access
|
||||
//-------------------------------------------------
|
||||
|
||||
READ16_MEMBER(midway_cheap_squeak_deluxe_device::pia_r)
|
||||
{
|
||||
// Spy Hunter accesses the MSB; Turbo Tag access via the LSB
|
||||
// My guess is that Turbo Tag works through a fluke, whereby the 68000
|
||||
// using the MOVEP instruction outputs the same value on the high and
|
||||
// low bytes.
|
||||
if (ACCESSING_BITS_8_15)
|
||||
return m_pia->read_alt(space, offset) << 8;
|
||||
else
|
||||
return m_pia->read_alt(space, offset);
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// pia_w - PIA write access
|
||||
//-------------------------------------------------
|
||||
|
||||
WRITE16_MEMBER(midway_cheap_squeak_deluxe_device::pia_w)
|
||||
{
|
||||
if (ACCESSING_BITS_8_15)
|
||||
m_pia->write_alt(space, offset, data >> 8);
|
||||
else
|
||||
m_pia->write_alt(space, offset, data);
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// audio CPU map
|
||||
//-------------------------------------------------
|
||||
|
||||
// address map determined by PAL; not verified
|
||||
// address map determined by PAL; verified
|
||||
static ADDRESS_MAP_START( csdeluxe_map, AS_PROGRAM, 16, midway_cheap_squeak_deluxe_device )
|
||||
ADDRESS_MAP_UNMAP_HIGH
|
||||
ADDRESS_MAP_GLOBAL_MASK(0x1ffff)
|
||||
AM_RANGE(0x000000, 0x007fff) AM_ROM
|
||||
AM_RANGE(0x018000, 0x018007) AM_READWRITE(pia_r, pia_w)
|
||||
AM_RANGE(0x01c000, 0x01cfff) AM_RAM
|
||||
AM_RANGE(0x00000, 0x07fff) AM_ROM
|
||||
AM_RANGE(0x18000, 0x18007) AM_MIRROR(0x3ff8) AM_DEVREADWRITE8("pia", pia6821_device, read_alt, write_alt, 0xff00) // Spy Hunter accesses the MSB
|
||||
AM_RANGE(0x18000, 0x18007) AM_MIRROR(0x3ff8) AM_DEVREADWRITE8("pia", pia6821_device, read_alt, write_alt, 0x00ff) // Turbo Tag access via the LSB
|
||||
AM_RANGE(0x1c000, 0x1cfff) AM_RAM
|
||||
ADDRESS_MAP_END
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// machine configuration
|
||||
//-------------------------------------------------
|
||||
@ -164,17 +49,39 @@ static MACHINE_CONFIG_FRAGMENT(midway_cheap_squeak_deluxe)
|
||||
MCFG_SOUND_ROUTE_EX(0, "dac", 1.0, DAC_VREF_POS_INPUT) MCFG_SOUND_ROUTE_EX(0, "dac", -1.0, DAC_VREF_NEG_INPUT)
|
||||
MACHINE_CONFIG_END
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// device_mconfig_additions - return a pointer to
|
||||
// the device's machine fragment
|
||||
//-------------------------------------------------
|
||||
|
||||
machine_config_constructor midway_cheap_squeak_deluxe_device::device_mconfig_additions() const
|
||||
{
|
||||
return MACHINE_CONFIG_NAME( midway_cheap_squeak_deluxe );
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
// rom_region - device-specific ROM region
|
||||
//-------------------------------------------------
|
||||
|
||||
ROM_START( csd )
|
||||
ROM_REGION(0x4a, "pal", 0)
|
||||
ROM_LOAD("0304-00803-0052.u15", 0x00, 0x4a, CRC(8b401aee) SHA1(360f3f59877f0bc25b4154782a2011963dd80a52)) // address decoding pal CSD002R0 (PAL14L8)
|
||||
ROM_END
|
||||
|
||||
const tiny_rom_entry *midway_cheap_squeak_deluxe_device::device_rom_region() const
|
||||
{
|
||||
return ROM_NAME( csd );
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
// midway_cheap_squeak_deluxe_device - constructor
|
||||
//-------------------------------------------------
|
||||
|
||||
midway_cheap_squeak_deluxe_device::midway_cheap_squeak_deluxe_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
|
||||
device_t(mconfig, MIDWAY_CHEAP_SQUEAK_DELUXE, "Cheap Squeak Deluxe Sound Board", tag, owner, clock, "midcsd", __FILE__),
|
||||
device_mixer_interface(mconfig, *this),
|
||||
m_cpu(*this, "cpu"),
|
||||
m_pia(*this, "pia"),
|
||||
m_dac(*this, "dac"),
|
||||
m_status(0),
|
||||
m_dacval(0)
|
||||
{
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
// device_start - device-specific startup
|
||||
@ -186,26 +93,88 @@ void midway_cheap_squeak_deluxe_device::device_start()
|
||||
save_item(NAME(m_dacval));
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// device_reset - device-specific reset
|
||||
//-------------------------------------------------
|
||||
|
||||
void midway_cheap_squeak_deluxe_device::device_reset()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// device_timer - timer callbacks
|
||||
//-------------------------------------------------
|
||||
|
||||
void midway_cheap_squeak_deluxe_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
|
||||
{
|
||||
m_pia->portb_w(param & 0x0f);
|
||||
m_pia->ca1_w(~param & 0x10);
|
||||
m_pia->ca1_w(param);
|
||||
|
||||
// oftentimes games will write one nibble at a time; the sync on this is very
|
||||
// important, so we boost the interleave briefly while this happens
|
||||
machine().scheduler().boost_interleave(attotime::zero, attotime::from_usec(100));
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
// stat_r - return the status value
|
||||
//-------------------------------------------------
|
||||
|
||||
READ8_MEMBER( midway_cheap_squeak_deluxe_device::stat_r )
|
||||
{
|
||||
return m_status;
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
// sr_w - external 4-bit write to the input latch
|
||||
//-------------------------------------------------
|
||||
|
||||
WRITE8_MEMBER( midway_cheap_squeak_deluxe_device::sr_w )
|
||||
{
|
||||
m_pia->portb_w(data & 0x0f);
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
// sirq_w - external irq write
|
||||
//-------------------------------------------------
|
||||
|
||||
WRITE_LINE_MEMBER( midway_cheap_squeak_deluxe_device::sirq_w )
|
||||
{
|
||||
synchronize(0, !state);
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
// reset_write - write to the reset line
|
||||
//-------------------------------------------------
|
||||
|
||||
WRITE_LINE_MEMBER( midway_cheap_squeak_deluxe_device::reset_w )
|
||||
{
|
||||
m_cpu->set_input_line(INPUT_LINE_RESET, state ? ASSERT_LINE : CLEAR_LINE);
|
||||
m_cpu->set_input_line(INPUT_LINE_HALT, state ? ASSERT_LINE : CLEAR_LINE);
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
// porta_w - PIA port A writes
|
||||
//-------------------------------------------------
|
||||
|
||||
WRITE8_MEMBER( midway_cheap_squeak_deluxe_device::porta_w )
|
||||
{
|
||||
m_dacval = (data << 2) | (m_dacval & 3);
|
||||
m_dac->write(m_dacval);
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
// portb_w - PIA port B writes
|
||||
//-------------------------------------------------
|
||||
|
||||
WRITE8_MEMBER( midway_cheap_squeak_deluxe_device::portb_w )
|
||||
{
|
||||
// bit 4-5, status
|
||||
uint8_t z_mask = m_pia->port_b_z_mask();
|
||||
if (~z_mask & 0x10) m_status = (m_status & ~1) | ((data >> 4) & 1);
|
||||
if (~z_mask & 0x20) m_status = (m_status & ~2) | ((data >> 4) & 2);
|
||||
|
||||
// bit 6-7, dac data
|
||||
m_dacval = (m_dacval & ~3) | (data >> 6);
|
||||
m_dac->write(m_dacval);
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
// irq_w - IRQ line state changes
|
||||
//-------------------------------------------------
|
||||
|
||||
WRITE_LINE_MEMBER( midway_cheap_squeak_deluxe_device::irq_w )
|
||||
{
|
||||
int combined_state = m_pia->irq_a_state() | m_pia->irq_b_state();
|
||||
m_cpu->set_input_line(4, combined_state ? ASSERT_LINE : CLEAR_LINE);
|
||||
}
|
||||
|
@ -23,30 +23,28 @@
|
||||
|
||||
// ======================> midway_cheap_squeak_deluxe_device
|
||||
|
||||
class midway_cheap_squeak_deluxe_device : public device_t,
|
||||
public device_mixer_interface
|
||||
class midway_cheap_squeak_deluxe_device : public device_t, public device_mixer_interface
|
||||
{
|
||||
public:
|
||||
// construction/destruction
|
||||
midway_cheap_squeak_deluxe_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
|
||||
|
||||
// read/write
|
||||
DECLARE_READ8_MEMBER(read);
|
||||
DECLARE_WRITE8_MEMBER(write);
|
||||
DECLARE_WRITE_LINE_MEMBER(reset_write);
|
||||
DECLARE_READ8_MEMBER(stat_r);
|
||||
DECLARE_WRITE8_MEMBER(sr_w);
|
||||
DECLARE_WRITE_LINE_MEMBER(sirq_w);
|
||||
DECLARE_WRITE_LINE_MEMBER(reset_w);
|
||||
|
||||
// internal communications
|
||||
DECLARE_WRITE8_MEMBER(porta_w);
|
||||
DECLARE_WRITE8_MEMBER(portb_w);
|
||||
DECLARE_WRITE_LINE_MEMBER(irq_w);
|
||||
DECLARE_READ16_MEMBER(pia_r);
|
||||
DECLARE_WRITE16_MEMBER(pia_w);
|
||||
|
||||
protected:
|
||||
// device-level overrides
|
||||
virtual machine_config_constructor device_mconfig_additions() const override;
|
||||
virtual const tiny_rom_entry *device_rom_region() const override;
|
||||
virtual void device_start() override;
|
||||
virtual void device_reset() override;
|
||||
virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override;
|
||||
|
||||
private:
|
||||
|
@ -393,7 +393,7 @@ WRITE8_MEMBER(mcr3_state::stargrds_op6_w)
|
||||
|
||||
READ8_MEMBER(mcr3_state::spyhunt_ip1_r)
|
||||
{
|
||||
return ioport("ssio:IP1")->read() | (m_cheap_squeak_deluxe->read(space, 0) << 5);
|
||||
return ioport("ssio:IP1")->read() | (m_cheap_squeak_deluxe->stat_r(space, 0) << 5);
|
||||
}
|
||||
|
||||
|
||||
@ -437,7 +437,8 @@ WRITE8_MEMBER(mcr3_state::spyhunt_op4_w)
|
||||
m_last_op4 = data;
|
||||
|
||||
/* low 5 bits go to control the Chip Squeak Deluxe */
|
||||
m_cheap_squeak_deluxe->write(space, offset, data);
|
||||
m_cheap_squeak_deluxe->sr_w(space, offset, data & 0x0f);
|
||||
m_cheap_squeak_deluxe->sirq_w(BIT(data, 4));
|
||||
}
|
||||
|
||||
|
||||
|
@ -45,8 +45,7 @@ public:
|
||||
m_videoram(*this, "videoram"),
|
||||
m_cheap_squeak_deluxe(*this, "csd"),
|
||||
m_bg_tilemap(nullptr),
|
||||
m_fg_tilemap(nullptr),
|
||||
m_sound_data(0)
|
||||
m_fg_tilemap(nullptr)
|
||||
{ }
|
||||
|
||||
DECLARE_VIDEO_START(zwackery);
|
||||
@ -64,7 +63,6 @@ public:
|
||||
DECLARE_READ8_MEMBER(pia1_porta_r);
|
||||
DECLARE_WRITE8_MEMBER(pia1_porta_w);
|
||||
DECLARE_READ8_MEMBER(pia1_portb_r);
|
||||
DECLARE_WRITE_LINE_MEMBER(pia1_ca2_w);
|
||||
DECLARE_READ8_MEMBER(pia2_porta_r);
|
||||
|
||||
DECLARE_READ8_MEMBER(ptm_r);
|
||||
@ -88,10 +86,9 @@ private:
|
||||
tilemap_t *m_fg_tilemap;
|
||||
|
||||
std::unique_ptr<uint8_t[]> m_spriteram;
|
||||
|
||||
std::unique_ptr<uint8_t[]> m_srcdata0;
|
||||
std::unique_ptr<uint8_t[]> m_srcdata2;
|
||||
|
||||
uint8_t m_sound_data;
|
||||
};
|
||||
|
||||
|
||||
@ -406,12 +403,7 @@ GFXDECODE_END
|
||||
|
||||
WRITE8_MEMBER( zwackery_state::pia1_porta_w )
|
||||
{
|
||||
m_sound_data = (data >> 4) & 0x0f;
|
||||
}
|
||||
|
||||
WRITE_LINE_MEMBER( zwackery_state::pia1_ca2_w )
|
||||
{
|
||||
m_cheap_squeak_deluxe->write(machine().dummy_space(), 0, (state << 4) | m_sound_data);
|
||||
m_cheap_squeak_deluxe->sr_w(space, 0, data >> 4);
|
||||
}
|
||||
|
||||
|
||||
@ -486,7 +478,6 @@ void zwackery_state::machine_start()
|
||||
|
||||
// register for save states
|
||||
save_pointer(NAME(m_spriteram.get()), 0x800);
|
||||
save_item(NAME(m_sound_data));
|
||||
}
|
||||
|
||||
|
||||
@ -499,6 +490,8 @@ static MACHINE_CONFIG_START( zwackery, zwackery_state )
|
||||
MCFG_CPU_ADD("maincpu", M68000, 7652400) // based on counter usage, should be XTAL_16MHz/2
|
||||
MCFG_CPU_PROGRAM_MAP(zwackery_map)
|
||||
|
||||
MCFG_QUANTUM_PERFECT_CPU("maincpu")
|
||||
|
||||
MCFG_WATCHDOG_ADD("watchdog")
|
||||
|
||||
MCFG_DEVICE_ADD("ptm", PTM6840, 7652400 / 10)
|
||||
@ -514,7 +507,7 @@ static MACHINE_CONFIG_START( zwackery, zwackery_state )
|
||||
MCFG_PIA_READPA_HANDLER(READ8(zwackery_state, pia1_porta_r))
|
||||
MCFG_PIA_WRITEPA_HANDLER(WRITE8(zwackery_state, pia1_porta_w))
|
||||
MCFG_PIA_READPB_HANDLER(READ8(zwackery_state, pia1_portb_r))
|
||||
MCFG_PIA_CA2_HANDLER(WRITELINE(zwackery_state, pia1_ca2_w))
|
||||
MCFG_PIA_CA2_HANDLER(DEVWRITELINE("csd", midway_cheap_squeak_deluxe_device, sirq_w))
|
||||
|
||||
MCFG_DEVICE_ADD("pia2", PIA6821, 0)
|
||||
MCFG_PIA_READPA_HANDLER(READ8(zwackery_state, pia2_porta_r))
|
||||
|
Loading…
Reference in New Issue
Block a user