bombjack: Soundlatch modernization (nw)

This commit is contained in:
AJR 2017-09-05 09:53:31 -04:00
parent 7b78594df3
commit 371e87b6e2
2 changed files with 29 additions and 37 deletions

View File

@ -106,23 +106,13 @@ Dip Locations and factory settings verified with manual
#include "speaker.h"
TIMER_CALLBACK_MEMBER(bombjack_state::soundlatch_callback)
READ8_MEMBER(bombjack_state::soundlatch_read_and_clear)
{
m_latch = param;
}
WRITE8_MEMBER(bombjack_state::bombjack_soundlatch_w)
{
/* make all the CPUs synchronize, and only AFTER that write the new command to the latch */
machine().scheduler().synchronize(timer_expired_delegate(FUNC(bombjack_state::soundlatch_callback),this), data);
}
READ8_MEMBER(bombjack_state::bombjack_soundlatch_r)
{
int res;
res = m_latch;
m_latch = 0;
// An extra flip-flop is used to clear the LS273 after reading it through a LS245
// (this flip-flop is then cleared in sync with the sound CPU clock)
uint8_t res = m_soundlatch->read(space, 0);
if (!machine().side_effect_disabled())
m_soundlatch->clear_w(space, 0, 0);
return res;
}
@ -155,14 +145,14 @@ static ADDRESS_MAP_START( main_map, AS_PROGRAM, 8, bombjack_state )
AM_RANGE(0xb004, 0xb004) AM_READ_PORT("DSW1")
AM_RANGE(0xb004, 0xb004) AM_WRITE(bombjack_flipscreen_w)
AM_RANGE(0xb005, 0xb005) AM_READ_PORT("DSW2")
AM_RANGE(0xb800, 0xb800) AM_WRITE(bombjack_soundlatch_w)
AM_RANGE(0xb800, 0xb800) AM_DEVWRITE("soundlatch", generic_latch_8_device, write)
AM_RANGE(0xc000, 0xdfff) AM_ROM
ADDRESS_MAP_END
static ADDRESS_MAP_START( audio_map, AS_PROGRAM, 8, bombjack_state )
AM_RANGE(0x0000, 0x1fff) AM_ROM
AM_RANGE(0x4000, 0x43ff) AM_RAM
AM_RANGE(0x6000, 0x6000) AM_READ(bombjack_soundlatch_r)
AM_RANGE(0x6000, 0x6000) AM_READ(soundlatch_read_and_clear)
ADDRESS_MAP_END
static ADDRESS_MAP_START( audio_io_map, AS_IO, 8, bombjack_state )
@ -336,14 +326,12 @@ GFXDECODE_END
void bombjack_state::machine_start()
{
save_item(NAME(m_latch));
save_item(NAME(m_background_image));
}
void bombjack_state::machine_reset()
{
m_latch = 0;
m_background_image = 0;
}
@ -366,6 +354,7 @@ static MACHINE_CONFIG_START( bombjack )
MCFG_CPU_IO_MAP(audio_io_map)
MCFG_CPU_VBLANK_INT_DRIVER("screen", bombjack_state, nmi_line_pulse)
MCFG_GENERIC_LATCH_8_ADD("soundlatch")
/* video hardware */
MCFG_SCREEN_ADD("screen", RASTER)

View File

@ -6,6 +6,8 @@
*************************************************************************/
#include "machine/gen_latch.h"
class bombjack_state : public driver_device
{
public:
@ -16,24 +18,10 @@ public:
m_spriteram(*this, "spriteram"),
m_maincpu(*this, "maincpu"),
m_gfxdecode(*this, "gfxdecode"),
m_palette(*this, "palette") { }
m_palette(*this, "palette"),
m_soundlatch(*this, "soundlatch") { }
/* memory pointers */
required_shared_ptr<uint8_t> m_videoram;
required_shared_ptr<uint8_t> m_colorram;
required_shared_ptr<uint8_t> m_spriteram;
/* video-related */
tilemap_t *m_fg_tilemap;
tilemap_t *m_bg_tilemap;
uint8_t m_background_image;
/* sound-related */
uint8_t m_latch;
uint8_t m_nmi_mask;
DECLARE_WRITE8_MEMBER(bombjack_soundlatch_w);
DECLARE_READ8_MEMBER(bombjack_soundlatch_r);
DECLARE_READ8_MEMBER(soundlatch_read_and_clear);
DECLARE_WRITE8_MEMBER(irq_mask_w);
DECLARE_WRITE8_MEMBER(bombjack_videoram_w);
DECLARE_WRITE8_MEMBER(bombjack_colorram_w);
@ -48,7 +36,22 @@ public:
INTERRUPT_GEN_MEMBER(vblank_irq);
TIMER_CALLBACK_MEMBER(soundlatch_callback);
void draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect );
private:
/* memory pointers */
required_shared_ptr<uint8_t> m_videoram;
required_shared_ptr<uint8_t> m_colorram;
required_shared_ptr<uint8_t> m_spriteram;
/* video-related */
tilemap_t *m_fg_tilemap;
tilemap_t *m_bg_tilemap;
uint8_t m_background_image;
uint8_t m_nmi_mask;
required_device<cpu_device> m_maincpu;
required_device<gfxdecode_device> m_gfxdecode;
required_device<palette_device> m_palette;
required_device<generic_latch_8_device> m_soundlatch;
};