diff --git a/src/emu/machine/seibu_cop.c b/src/emu/machine/seibu_cop.c index 65ca18efd0d..8fb35ac71be 100644 --- a/src/emu/machine/seibu_cop.c +++ b/src/emu/machine/seibu_cop.c @@ -2,7 +2,7 @@ Seibu COP protection device - (this header needs expanding) + (this header needs expanding!) ***************************************************************************/ @@ -18,10 +18,43 @@ // device type definition const device_type SEIBU_COP = &device_creator; -#if 0 -static ADDRESS_MAP_START( seibu_cop_vram, AS_0, 16, seibu_cop_device ) + +static ADDRESS_MAP_START( seibu_cop_io, AS_0, 16, seibu_cop_device ) + AM_RANGE(0x0028, 0x0029) AM_WRITE(dma_fill_val_lo_w) + AM_RANGE(0x002a, 0x002b) AM_WRITE(dma_fill_val_hi_w) + AM_RANGE(0x005a, 0x005b) AM_WRITE(pal_brightness_val_w) + AM_RANGE(0x005c, 0x005d) AM_WRITE(pal_brightness_mode_w) + AM_RANGE(0x0074, 0x0075) AM_WRITE(dma_unk_param_w) + AM_RANGE(0x0076, 0x0077) AM_WRITE(dma_pal_fade_table_w) + AM_RANGE(0x0078, 0x0079) AM_WRITE(dma_src_w) + AM_RANGE(0x007a, 0x007b) AM_WRITE(dma_size_w) + AM_RANGE(0x007c, 0x007d) AM_WRITE(dma_dst_w) + AM_RANGE(0x007e, 0x007f) AM_WRITE(dma_trigger_w) ADDRESS_MAP_END -#endif + + +//************************************************************************** +// INLINE HELPERS +//************************************************************************** + +//------------------------------------------------- +// readbyte - read a byte at the given address +//------------------------------------------------- + +inline UINT16 seibu_cop_device::read_word(offs_t address) +{ + return space().read_word(address); +} + +//------------------------------------------------- +// writebyte - write a byte at the given address +//------------------------------------------------- + +inline void seibu_cop_device::write_word(offs_t address, UINT16 data) +{ + space().write_word(address, data); +} + //************************************************************************** // LIVE DEVICE @@ -32,7 +65,9 @@ ADDRESS_MAP_END //------------------------------------------------- seibu_cop_device::seibu_cop_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) - : device_t(mconfig, SEIBU_COP, "seibu_cop", tag, owner, clock) + : device_t(mconfig, SEIBU_COP, "seibu_cop", tag, owner, clock), + device_memory_interface(mconfig, *this), + m_space_config("io", ENDIANNESS_LITTLE, 16, 16, 0, NULL, *ADDRESS_MAP_NAME(seibu_cop_io)) { } @@ -87,65 +122,92 @@ void seibu_cop_device::device_reset() { } +//------------------------------------------------- +// memory_space_config - return a description of +// any address spaces owned by this device +//------------------------------------------------- + +const address_space_config *seibu_cop_device::memory_space_config(address_spacenum spacenum) const +{ + return (spacenum == AS_0) ? &m_space_config : NULL; +} //************************************************************************** // READ/WRITE HANDLERS //************************************************************************** +WRITE16_MEMBER(seibu_cop_device::dma_fill_val_lo_w) +{ + COMBINE_DATA(&m_dma_fill_val_lo); + m_dma_fill_val = (m_dma_fill_val_lo) | (m_dma_fill_val_hi << 16); +} + +WRITE16_MEMBER(seibu_cop_device::dma_fill_val_hi_w) +{ + COMBINE_DATA(&m_dma_fill_val_hi); + m_dma_fill_val = (m_dma_fill_val_lo) | (m_dma_fill_val_hi << 16); +} + +WRITE16_MEMBER(seibu_cop_device::pal_brightness_val_w) +{ + COMBINE_DATA(&m_pal_brightness_val); + + /* TODO: add checks for bits 15-6 */ +} + +WRITE16_MEMBER(seibu_cop_device::pal_brightness_mode_w) +{ + COMBINE_DATA(&m_pal_brightness_mode); + + /* TODO: add checks for anything that isn't 4 or 5 */ +} + +WRITE16_MEMBER(seibu_cop_device::dma_unk_param_w) +{ + /* + This sets up a DMA mode of some sort + 0x0e00: grainbow, cupsoc + 0x0a00: legionna, godzilla, denjinmk + 0x0600: heatbrl + 0x1e00: zeroteam, xsedae + raiden2 and raidendx doesn't set this up, this could indicate that this is related to the non-private buffer DMAs + (both only uses 0x14 and 0x15 as DMAs afaik) + */ + COMBINE_DATA(&m_dma_unk_param); +} + +WRITE16_MEMBER(seibu_cop_device::dma_pal_fade_table_w) +{ + COMBINE_DATA(&m_dma_pal_fade_table); +} + +WRITE16_MEMBER(seibu_cop_device::dma_src_w) +{ + COMBINE_DATA(&m_dma_src[m_dma_trigger]); +} + +WRITE16_MEMBER(seibu_cop_device::dma_size_w) +{ + COMBINE_DATA(&m_dma_size[m_dma_trigger]); +} + +WRITE16_MEMBER(seibu_cop_device::dma_dst_w) +{ + COMBINE_DATA(&m_dma_dst[m_dma_trigger]); +} + +WRITE16_MEMBER(seibu_cop_device::dma_trigger_w) +{ + COMBINE_DATA(&m_dma_exec_param); + m_dma_trigger = m_dma_exec_param & 7; +} + READ16_MEMBER( seibu_cop_device::read ) { - return 0; + return read_word(offset); } WRITE16_MEMBER( seibu_cop_device::write ) { - switch(offset) - { - case 0x028/2: - COMBINE_DATA(&m_dma_fill_val_lo); - m_dma_fill_val = (m_dma_fill_val_lo) | (m_dma_fill_val_hi << 16); - break; - - case 0x02a/2: - COMBINE_DATA(&m_dma_fill_val_hi); - m_dma_fill_val = (m_dma_fill_val_lo) | (m_dma_fill_val_hi << 16); - break; - - case (0x05a/2): COMBINE_DATA(&m_pal_brightness_val); break; - case (0x05c/2): COMBINE_DATA(&m_pal_brightness_mode); break; - - case 0x074/2: - /* - This sets up a DMA mode of some sort - 0x0e00: grainbow, cupsoc - 0x0a00: legionna, godzilla, denjinmk - 0x0600: heatbrl - 0x1e00: zeroteam, xsedae - raiden2 and raidendx doesn't set this up, this could indicate that this is related to the non-private buffer DMAs - (both only uses 0x14 and 0x15 as DMAs) - */ - COMBINE_DATA(&m_dma_unk_param); - break; - - case (0x076/2): - COMBINE_DATA(&m_cop_dma_fade_table); - break; - - case (0x078/2): /* DMA source address */ - COMBINE_DATA(&m_cop_dma_src[m_cop_dma_trigger]); - break; - - case (0x07a/2): /* DMA length */ - COMBINE_DATA(&m_cop_dma_size[m_cop_dma_trigger]); - break; - - case (0x07c/2): /* DMA destination */ - COMBINE_DATA(&m_cop_dma_dst[m_cop_dma_trigger]); - break; - - case (0x07e/2): /* DMA parameter */ - COMBINE_DATA(&m_cop_dma_exec_param); - m_cop_dma_trigger = m_cop_dma_exec_param & 7; - break; - } + write_word(offset,data); } diff --git a/src/emu/machine/seibu_cop.h b/src/emu/machine/seibu_cop.h index ad3eac18233..f4c0cb9ac8e 100644 --- a/src/emu/machine/seibu_cop.h +++ b/src/emu/machine/seibu_cop.h @@ -37,6 +37,7 @@ struct seibu_cop_interface // ======================> seibu_cop_device class seibu_cop_device : public device_t, + public device_memory_interface, public seibu_cop_interface { public: @@ -46,6 +47,16 @@ public: // I/O operations DECLARE_WRITE16_MEMBER( write ); DECLARE_READ16_MEMBER( read ); + DECLARE_WRITE16_MEMBER(dma_fill_val_lo_w); + DECLARE_WRITE16_MEMBER(dma_fill_val_hi_w); + DECLARE_WRITE16_MEMBER(pal_brightness_val_w); + DECLARE_WRITE16_MEMBER(pal_brightness_mode_w); + DECLARE_WRITE16_MEMBER(dma_unk_param_w); + DECLARE_WRITE16_MEMBER(dma_pal_fade_table_w); + DECLARE_WRITE16_MEMBER(dma_src_w); + DECLARE_WRITE16_MEMBER(dma_size_w); + DECLARE_WRITE16_MEMBER(dma_dst_w); + DECLARE_WRITE16_MEMBER(dma_trigger_w); protected: // device-level overrides @@ -53,16 +64,21 @@ protected: virtual void device_validity_check(validity_checker &valid) const; virtual void device_start(); virtual void device_reset(); + virtual const address_space_config *memory_space_config(address_spacenum spacenum = AS_0) const; private: devcb_resolved_read8 m_in_mreq_func; devcb_resolved_write8 m_out_mreq_func; + inline UINT16 read_word(offs_t address); + inline void write_word(offs_t address, UINT16 data); - UINT16 m_dma_unk_param, m_cop_dma_fade_table, m_cop_dma_src[8], m_cop_dma_dst[8], m_cop_dma_size[8], m_cop_dma_exec_param; - UINT8 m_cop_dma_trigger; + UINT16 m_dma_unk_param, m_dma_pal_fade_table, m_dma_src[8], m_dma_dst[8], m_dma_size[8], m_dma_exec_param; + UINT8 m_dma_trigger; UINT16 m_dma_fill_val_lo,m_dma_fill_val_hi; UINT32 m_dma_fill_val; - UINT8 m_pal_brightness_val, m_pal_brightness_mode; + UINT16 m_pal_brightness_val, m_pal_brightness_mode; + + const address_space_config m_space_config; };