diff options
| -rw-r--r-- | src/mame/drivers/spyhuntertec.cpp | 57 |
1 files changed, 31 insertions, 26 deletions
diff --git a/src/mame/drivers/spyhuntertec.cpp b/src/mame/drivers/spyhuntertec.cpp index 67347354ea3..c41dde50fac 100644 --- a/src/mame/drivers/spyhuntertec.cpp +++ b/src/mame/drivers/spyhuntertec.cpp @@ -31,7 +31,9 @@ class spyhuntertec_state : public driver_device public: spyhuntertec_state(const machine_config &mconfig, device_type type, const char *tag) : driver_device(mconfig, type, tag), + m_maincpu(*this, "maincpu"), m_audiocpu(*this, "audiocpu"), + m_analog_timer(*this, "analog_timer"), m_videoram(*this, "videoram"), m_spriteram(*this, "spriteram"), m_spriteram2(*this, "spriteram2"), @@ -43,12 +45,17 @@ public: { } + required_device<cpu_device> m_maincpu; required_device<cpu_device> m_audiocpu; + required_device<timer_device> m_analog_timer; required_shared_ptr<UINT8> m_videoram; required_shared_ptr<UINT8> m_spriteram; required_shared_ptr<UINT8> m_spriteram2; required_shared_ptr<UINT8> m_paletteram; required_shared_ptr<UINT8> m_spyhunt_alpharam; + required_device<palette_device> m_palette; + required_device<gfxdecode_device> m_gfxdecode; + required_device<screen_device> m_screen; virtual void machine_start() override; virtual void machine_reset() override; @@ -57,9 +64,6 @@ public: UINT32 screen_update_spyhuntertec(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); - required_device<palette_device> m_palette; - required_device<gfxdecode_device> m_gfxdecode; - required_device<screen_device> m_screen; UINT8 m_spyhunt_sprite_color_mask; INT16 m_spyhunt_scroll_offset; @@ -98,9 +102,12 @@ public: TILE_GET_INFO_MEMBER(spyhunt_get_alpha_tile_info); void mcr3_update_sprites(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int color_mask, int code_xor, int dx, int dy, int interlaced); + TIMER_DEVICE_CALLBACK_MEMBER(analog_shift_callback); + void reset_analog_timer(); int m_analog_read_ready; - int m_analog_latched_value; + UINT8 m_analog_latched_value; + UINT8 m_analog_select; int m_analog_read_count; }; @@ -115,7 +122,17 @@ READ8_MEMBER(spyhuntertec_state::ay1_porta_r) return 0; } +void spyhuntertec_state::reset_analog_timer() +{ + // 555 timer? complete guess + m_analog_timer->adjust(attotime::from_nsec(7600)); +} +TIMER_DEVICE_CALLBACK_MEMBER(spyhuntertec_state::analog_shift_callback) +{ + m_analog_read_count++; + reset_analog_timer(); +} WRITE8_MEMBER(spyhuntertec_state::ay2_porta_w) { @@ -124,25 +141,17 @@ WRITE8_MEMBER(spyhuntertec_state::ay2_porta_w) // or 81 / 01 // depending on which sound command was used // assuming input select - - if (data == 0x80) + + // d7 falling edge + if (~data & m_analog_select & 0x80) { m_analog_read_ready = 1; m_analog_read_count = 0; - m_analog_latched_value = ioport("PEDAL")->read(); + reset_analog_timer(); + m_analog_latched_value = ioport((data & 1) ? "PADDLE" : "PEDAL")->read(); } - else if (data == 0x81) - { - m_analog_read_ready = 1; - m_analog_read_count = 0; - m_analog_latched_value = ioport("PADDLE")->read(); - - } - - - - + m_analog_select = data; } READ8_MEMBER(spyhuntertec_state::ay2_porta_r) @@ -410,6 +419,7 @@ READ8_MEMBER(spyhuntertec_state::spyhuntertec_in2_r) */ +// printf("%04x spyhuntertec_in2_r\n", space.device().safe_pc()); UINT8 ret = ioport("IN2")->read()&~0x40; @@ -421,18 +431,12 @@ READ8_MEMBER(spyhuntertec_state::spyhuntertec_in2_r) m_analog_read_count = 0; m_analog_read_ready = 0; } - else - { - // ret |= 0x40; - m_analog_read_count++; - } } else { ret |= 0x40; } -// printf("%04x spyhuntertec_in2_r\n", space.device().safe_pc()); return ret; } @@ -617,7 +621,7 @@ static INPUT_PORTS_START( spyhuntertec ) PORT_START("PEDAL") PORT_BIT( 0xff, 0x02, IPT_PEDAL ) PORT_MINMAX(0x02,0xff) PORT_SENSITIVITY(100) PORT_KEYDELTA(10) PORT_REVERSE PORT_START("PADDLE") - PORT_BIT( 0xff, 0x02, IPT_PADDLE ) PORT_MINMAX(0x02,0xff) PORT_SENSITIVITY(40) PORT_KEYDELTA(10) PORT_REVERSE + PORT_BIT( 0x7f, 0x40, IPT_PADDLE ) PORT_MINMAX(0x30,0x50) PORT_SENSITIVITY(40) PORT_KEYDELTA(3) PORT_REVERSE INPUT_PORTS_END @@ -700,7 +704,8 @@ static MACHINE_CONFIG_START( spyhuntertec, spyhuntertec_state ) MCFG_CPU_ADD("maincpu", Z80, MASTER_CLOCK/4) MCFG_CPU_PROGRAM_MAP(spyhuntertec_map) MCFG_CPU_IO_MAP(spyhuntertec_portmap) - MCFG_CPU_VBLANK_INT_DRIVER("screen", spyhuntertec_state, irq0_line_hold) + MCFG_CPU_VBLANK_INT_DRIVER("screen", spyhuntertec_state, irq0_line_hold) + MCFG_TIMER_DRIVER_ADD("analog_timer", spyhuntertec_state, analog_shift_callback) /* video hardware */ MCFG_SCREEN_ADD("screen", RASTER) |
