From acbc95ebb53ded8b3aaa43258da360f0d18aee58 Mon Sep 17 00:00:00 2001 From: Angelo Salese Date: Mon, 29 Jul 2019 00:13:23 +0200 Subject: seibucop.cpp: disable sprite DMA dest increment for SD Gundam if X positions are outside expected ranges, fix sprite clipping [Angelo Salese] --- src/mame/machine/seibucop/seibucop.cpp | 8 +++++--- src/mame/machine/seibucop/seibucop.h | 1 + src/mame/machine/seibucop/seibucop_cmd.hxx | 5 ++++- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/mame/machine/seibucop/seibucop.cpp b/src/mame/machine/seibucop/seibucop.cpp index d45698b4f97..96a0b8d1120 100644 --- a/src/mame/machine/seibucop/seibucop.cpp +++ b/src/mame/machine/seibucop/seibucop.cpp @@ -1275,15 +1275,17 @@ WRITE16_MEMBER( raiden2cop_device::cop_sprite_dma_src_lo_w) m_cop_sprite_dma_src = (m_cop_sprite_dma_src&0xffff0000)|(data&0xffff); } -// guess WRITE16_MEMBER(raiden2cop_device::cop_sprite_dma_inc_w) { if (data) printf("Warning: COP RAM 0x410 used with %04x\n", data); else { - /* guess */ - cop_regs[4] += 8; + // Don't increment if the sprite DMA is out of bounds + // (A3 doesn't get updated if it happens, cfr. code at $1e56) + // TODO: hardwired for SD Gundam, must be user controllable somehow. + if (m_sprite_dma_x_clip >= -160 && m_sprite_dma_x_clip < 320) + cop_regs[4] += 8; m_cop_sprite_dma_src += 6; m_cop_sprite_dma_size--; diff --git a/src/mame/machine/seibucop/seibucop.h b/src/mame/machine/seibucop/seibucop.h index 940f6cea362..714485fe420 100644 --- a/src/mame/machine/seibucop/seibucop.h +++ b/src/mame/machine/seibucop/seibucop.h @@ -187,6 +187,7 @@ public: int m_cop_sprite_dma_abs_x,m_cop_sprite_dma_abs_y; int m_sprite_dma_rel_x, m_sprite_dma_rel_y; + int m_sprite_dma_x_clip; DECLARE_WRITE16_MEMBER(cop_sprite_dma_abs_y_w); DECLARE_WRITE16_MEMBER(cop_sprite_dma_abs_x_w); diff --git a/src/mame/machine/seibucop/seibucop_cmd.hxx b/src/mame/machine/seibucop/seibucop_cmd.hxx index da4a8521a7c..f1c96aadd1d 100644 --- a/src/mame/machine/seibucop/seibucop_cmd.hxx +++ b/src/mame/machine/seibucop/seibucop_cmd.hxx @@ -582,7 +582,10 @@ void raiden2cop_device::LEGACY_execute_c480(int offset, uint16_t data) sprite_pri |= 0x8000; m_host_space->write_word(cop_regs[4] + offs + 2, sprite_pri); } - m_host_space->write_word(cop_regs[4] + offs + 4, sprite_x); + + // save into internal clip register, cfr. increment DMA register $410 + m_sprite_dma_x_clip = sprite_x; + m_host_space->write_word(cop_regs[4] + offs + 4, m_sprite_dma_x_clip); m_host_space->write_word(cop_regs[4] + offs + 6, sprite_y); } -- cgit v1.2.3