diff --git a/src/mame/sigma/nyny.cpp b/src/mame/sigma/nyny.cpp index 3ffede741b6..13ce21abb09 100644 --- a/src/mame/sigma/nyny.cpp +++ b/src/mame/sigma/nyny.cpp @@ -111,22 +111,29 @@ public: m_pia2(*this, "pia2"), m_soundlatch(*this, "soundlatch"), m_soundlatch2(*this, "soundlatch2"), - m_soundlatch3(*this, "soundlatch3") + m_soundlatch3(*this, "soundlatch3"), + m_dac(*this, "dac") { } void nyny(machine_config &config); +protected: + virtual void machine_start() override ATTR_COLD; + virtual void machine_reset() override ATTR_COLD; + private: /* memory pointers */ required_shared_ptr_array m_videoram; required_shared_ptr_array m_colorram; /* video-related */ - bool m_flipscreen = false; - bool m_flipchars = false; - uint8_t m_star_enable = 0; - uint16_t m_star_delay_counter = 0; - uint16_t m_star_shift_reg = 0; + bool m_flipscreen = false; + bool m_flipchars = false; + bool m_dac_enable = false; + uint8_t m_dac_data = 0; + bool m_star_enable = false; + uint16_t m_star_delay_counter = 0; + uint16_t m_star_shift_reg = 0; /* devices */ required_device m_maincpu; @@ -140,6 +147,7 @@ private: required_device m_soundlatch; required_device m_soundlatch2; required_device m_soundlatch3; + required_device m_dac; void audio_1_command_w(uint8_t data); void audio_1_answer_w(uint8_t data); @@ -152,12 +160,10 @@ private: void pia_2_port_b_w(uint8_t data); void flipscreen_w(int state); void flipchars_w(int state); - void nyny_ay8910_37_port_a_w(uint8_t data); - virtual void machine_start() override ATTR_COLD; - virtual void machine_reset() override ATTR_COLD; + void ay8910_37_port_a_w(uint8_t data); + void ay8910_37_port_b_w(uint8_t data); + void update_dac(); INTERRUPT_GEN_MEMBER(update_pia_1); - void ic48_1_74123_output_changed(int state); - inline void shift_star_generator( ); MC6845_UPDATE_ROW(crtc_update_row); MC6845_END_UPDATE(crtc_end_update); @@ -167,6 +173,7 @@ private: }; + /************************************* * * Interrupt generation @@ -211,6 +218,7 @@ INTERRUPT_GEN_MEMBER(nyny_state::update_pia_1) } + /************************************* * * PIA2 @@ -229,29 +237,13 @@ void nyny_state::pia_2_port_b_w(uint8_t data) m_star_delay_counter = (m_star_delay_counter & 0x00ff) | ((data & 0x0f) << 8); /* bit 4 is star field enable */ - m_star_enable = data & 0x10; + m_star_enable = bool(data & 0x10); /* bits 5-7 go to the music board connector */ audio_2_command_w(data & 0xe0); } -/************************************* - * - * IC48 #1 - 74123 - * - * This timer is responsible for - * delaying the setting of PIA2's - * CA1 line. This delay ensures that - * CA1 is only changed in the VBLANK - * region, but not in HBLANK - * - *************************************/ - -void nyny_state::ic48_1_74123_output_changed(int state) -{ - m_pia2->ca1_w(state); -} /************************************* * @@ -259,7 +251,6 @@ void nyny_state::ic48_1_74123_output_changed(int state) * *************************************/ - void nyny_state::flipscreen_w(int state) { m_flipscreen = !state; @@ -279,9 +270,7 @@ MC6845_UPDATE_ROW( nyny_state::crtc_update_row ) for (uint8_t cx = 0; cx < x_count; cx++) { /* the memory is hooked up to the MA, RA lines this way */ - offs_t offs = ((ma << 3) & 0x3f00) | - ((ra << 5) & 0x00e0) | - ((ma << 0) & 0x001f); + offs_t offs = ((ma << 3) & 0x3f00) | ((ra << 5) & 0x00e0) | ((ma << 0) & 0x001f); if (m_flipscreen) offs ^= 0x3fff; @@ -324,12 +313,6 @@ MC6845_UPDATE_ROW( nyny_state::crtc_update_row ) } -void nyny_state::shift_star_generator( ) -{ - m_star_shift_reg = (m_star_shift_reg << 1) | (((~m_star_shift_reg >> 15) & 0x01) ^ ((m_star_shift_reg >> 2) & 0x01)); -} - - MC6845_END_UPDATE( nyny_state::crtc_end_update ) { /* draw the star field into the bitmap */ @@ -341,20 +324,20 @@ MC6845_END_UPDATE( nyny_state::crtc_end_update ) { /* check if the star status */ if (m_star_enable && (bitmap.pix(y, x) == m_palette->pen_color(0)) && - ((m_star_shift_reg & 0x80ff) == 0x00ff) && - (((y & 0x01) ^ m_flipscreen) ^ (((x & 0x08) >> 3) ^ m_flipscreen))) + ((m_star_shift_reg & 0x80ff) == 0x00ff) && + (((y & 0x01) ^ m_flipscreen) ^ (((x & 0x08) >> 3) ^ m_flipscreen))) { - uint8_t color = ((m_star_shift_reg & 0x0100) >> 8) | /* R */ - ((m_star_shift_reg & 0x0400) >> 9) | /* G */ - ((m_star_shift_reg & 0x1000) >> 10); /* B */ + uint8_t color = ((m_star_shift_reg & 0x0100) >> 8) | /* R */ + ((m_star_shift_reg & 0x0400) >> 9) | /* G */ + ((m_star_shift_reg & 0x1000) >> 10); /* B */ bitmap.pix(y, x) = m_palette->pen_color(color); } if (delay_counter == 0) - shift_star_generator(); + m_star_shift_reg = (m_star_shift_reg << 1) | (((~m_star_shift_reg >> 15) & 0x01) ^ ((m_star_shift_reg >> 2) & 0x01)); else - delay_counter = delay_counter - 1; + delay_counter--; } } } @@ -381,13 +364,31 @@ void nyny_state::audio_1_answer_w(uint8_t data) } -void nyny_state::nyny_ay8910_37_port_a_w(uint8_t data) +void nyny_state::update_dac() { - /* not sure what this does */ - - /*logerror("%s PORT A write %x at Y=%x X=%x\n", machine().describe_context(), data, m_screen->vpos(), m_screen->hpos());*/ + m_dac->write(m_dac_enable ? m_dac_data : 0x80); } + +void nyny_state::ay8910_37_port_a_w(uint8_t data) +{ + /* bit 0-2: AY1 channel A volume filter? */ + + /* bit 3: enable DAC output */ + m_dac_enable = !BIT(data, 3); + update_dac(); +} + + +void nyny_state::ay8910_37_port_b_w(uint8_t data) +{ + /* DAC data, also AY1 channel A filter? */ + m_dac_data = data; + update_dac(); +} + + + /************************************* * * Audio system - CPU 2 @@ -413,8 +414,10 @@ uint8_t nyny_state::nyny_pia_1_2_r(offs_t offset) uint8_t ret = 0; /* the address bits are directly connected to the chip selects */ - if (BIT(offset, 2)) ret = m_pia1->read(offset & 0x03); - if (BIT(offset, 3)) ret = m_pia2->read_alt(offset & 0x03); + if (BIT(offset, 2)) + ret = m_pia1->read(offset & 0x03); + if (BIT(offset, 3)) + ret = m_pia2->read_alt(offset & 0x03); return ret; } @@ -423,8 +426,10 @@ uint8_t nyny_state::nyny_pia_1_2_r(offs_t offset) void nyny_state::nyny_pia_1_2_w(offs_t offset, uint8_t data) { /* the address bits are directly connected to the chip selects */ - if (BIT(offset, 2)) m_pia1->write(offset & 0x03, data); - if (BIT(offset, 3)) m_pia2->write_alt(offset & 0x03, data); + if (BIT(offset, 2)) + m_pia1->write(offset & 0x03, data); + if (BIT(offset, 3)) + m_pia2->write_alt(offset & 0x03, data); } @@ -558,7 +563,6 @@ static INPUT_PORTS_START( nyny ) PORT_START("CROSS") /* connected to PIA1 CB1 input */ PORT_BIT( 0xff, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("PS1 (Crosshatch)") PORT_CODE(KEYCODE_F1) - INPUT_PORTS_END @@ -571,12 +575,11 @@ INPUT_PORTS_END void nyny_state::machine_start() { - m_flipscreen = false; - m_flipchars = false; - /* setup for save states */ save_item(NAME(m_flipscreen)); save_item(NAME(m_flipchars)); + save_item(NAME(m_dac_enable)); + save_item(NAME(m_dac_data)); save_item(NAME(m_star_enable)); save_item(NAME(m_star_delay_counter)); save_item(NAME(m_star_shift_reg)); @@ -584,11 +587,13 @@ void nyny_state::machine_start() void nyny_state::machine_reset() { - m_star_enable = 0; + m_star_enable = false; m_star_delay_counter = 0; m_star_shift_reg = 0; } + + /************************************* * * Machine driver @@ -625,7 +630,8 @@ void nyny_state::nyny(machine_config &config) m_mc6845->set_end_update_callback(FUNC(nyny_state::crtc_end_update)); m_mc6845->out_de_callback().set(m_ic48_1, FUNC(ttl74123_device::a_w)); - /* 74LS123 */ + /* 74LS123: This timer is responsible for delaying the setting of PIA2's CA1 line. */ + /* This delay ensures that CA1 is only changed in the VBLANK region, but not in HBLANK. */ TTL74123(config, m_ic48_1, 0); m_ic48_1->set_connection_type(TTL74123_GROUNDED); /* the hook up type */ m_ic48_1->set_resistor_value(RES_K(22)); /* resistor connected to RCext */ @@ -633,7 +639,7 @@ void nyny_state::nyny(machine_config &config) m_ic48_1->set_a_pin_value(1); /* A pin - driven by the CRTC */ m_ic48_1->set_b_pin_value(1); /* B pin - pulled high */ m_ic48_1->set_clear_pin_value(1); /* Clear pin - pulled high */ - m_ic48_1->out_cb().set(FUNC(nyny_state::ic48_1_74123_output_changed)); + m_ic48_1->out_cb().set(m_pia2, FUNC(pia6821_device::ca1_w)); PIA6821(config, m_pia1); m_pia1->readpa_handler().set_ioport("IN0"); @@ -657,8 +663,8 @@ void nyny_state::nyny(machine_config &config) GENERIC_LATCH_8(config, m_soundlatch3); ay8910_device &ay1(AY8910(config, "ay1", AUDIO_CPU_1_CLOCK)); - ay1.port_a_write_callback().set(FUNC(nyny_state::nyny_ay8910_37_port_a_w)); - ay1.port_b_write_callback().set("dac", FUNC(dac_byte_interface::data_w)); + ay1.port_a_write_callback().set(FUNC(nyny_state::ay8910_37_port_a_w)); + ay1.port_b_write_callback().set(FUNC(nyny_state::ay8910_37_port_b_w)); ay1.add_route(ALL_OUTPUTS, "speaker", 0.25); ay8910_device &ay2(AY8910(config, "ay2", AUDIO_CPU_1_CLOCK)); @@ -743,12 +749,13 @@ ROM_END } // anonymous namespace + /************************************* * * Game drivers * *************************************/ -GAME( 1980, nyny, 0, nyny, nyny, nyny_state, empty_init, ROT270, "Sigma Enterprises Inc.", "New York! New York!", MACHINE_IMPERFECT_SOUND | MACHINE_SUPPORTS_SAVE ) -GAME( 1980, nynyg, nyny, nyny, nyny, nyny_state, empty_init, ROT270, "Sigma Enterprises Inc. (Gottlieb license)", "New York! New York! (Gottlieb)", MACHINE_IMPERFECT_SOUND | MACHINE_SUPPORTS_SAVE ) -GAME( 1982, warcadia,nyny, nyny, nyny, nyny_state, empty_init, ROT270, "Sigma Enterprises Inc.", "Waga Seishun no Arcadia", MACHINE_IMPERFECT_SOUND | MACHINE_SUPPORTS_SAVE ) +GAME( 1980, nyny, 0, nyny, nyny, nyny_state, empty_init, ROT270, "Sigma Enterprises Inc.", "New York! New York!", MACHINE_IMPERFECT_SOUND | MACHINE_SUPPORTS_SAVE ) +GAME( 1980, nynyg, nyny, nyny, nyny, nyny_state, empty_init, ROT270, "Sigma Enterprises Inc. (Gottlieb license)", "New York! New York! (Gottlieb)", MACHINE_IMPERFECT_SOUND | MACHINE_SUPPORTS_SAVE ) +GAME( 1982, warcadia, nyny, nyny, nyny, nyny_state, empty_init, ROT270, "Sigma Enterprises Inc.", "Waga Seishun no Arcadia", MACHINE_IMPERFECT_SOUND | MACHINE_SUPPORTS_SAVE ) diff --git a/src/mame/sigma/r2dtank.cpp b/src/mame/sigma/r2dtank.cpp index 20422795373..a33efcf7085 100644 --- a/src/mame/sigma/r2dtank.cpp +++ b/src/mame/sigma/r2dtank.cpp @@ -1,6 +1,7 @@ // license:BSD-3-Clause // copyright-holders:David Haywood, Pierpaolo Prazzoli /******************************************************************* + R2D Tank (c) 1980 Sigma Ent. Inc. driver by: David Haywood & Pierpaolo Prazzoli @@ -81,8 +82,6 @@ public: void r2dtank(machine_config &config); - int ttl74123_output_r(); - protected: virtual void machine_start() override ATTR_COLD; @@ -100,7 +99,6 @@ private: required_device m_ay2; uint8_t m_flipscreen = 0; - uint32_t m_ttl74123_output = 0; uint8_t m_AY8910_selected = 0; uint8_t audio_command_r(); @@ -114,8 +112,6 @@ private: void flipscreen_w(int state); void pia_comp_w(offs_t offset, uint8_t data); - void ttl74123_output_changed(int state); - MC6845_UPDATE_ROW(crtc_update_row); void r2dtank_audio_map(address_map &map) ATTR_COLD; @@ -123,6 +119,7 @@ private: }; + /************************************* * * Interrupt generation @@ -132,9 +129,9 @@ private: void r2dtank_state::main_cpu_irq(int state) { int combined_state = m_pia_main->irq_a_state() | m_pia_main->irq_b_state() | - m_pia_audio->irq_a_state() | m_pia_audio->irq_b_state(); + m_pia_audio->irq_a_state() | m_pia_audio->irq_b_state(); - m_maincpu->set_input_line(M6809_IRQ_LINE, combined_state ? ASSERT_LINE : CLEAR_LINE); + m_maincpu->set_input_line(M6809_IRQ_LINE, combined_state ? ASSERT_LINE : CLEAR_LINE); } @@ -148,7 +145,6 @@ void r2dtank_state::main_cpu_irq(int state) uint8_t r2dtank_state::audio_command_r() { uint8_t ret = m_soundlatch->read(); - LOGMASKED(LOG_AUDIO_COMM, "%08X CPU#1 Audio Command Read: %x\n", m_audiocpu->pc(), ret); return ret; @@ -225,29 +221,6 @@ void r2dtank_state::AY8910_port_w(uint8_t data) } -/************************************* - * - * 74123 - * - * This timer is responsible for - * delaying the PIA1's port input. - * This delay ensures that - * CA1 is only changed in the VBLANK - * region, but not in HBLANK - * - *************************************/ - -void r2dtank_state::ttl74123_output_changed(int state) -{ - m_pia_main->ca1_w(state); - m_ttl74123_output = state; -} - - -int r2dtank_state::ttl74123_output_r() -{ - return m_ttl74123_output; -} /************************************* * @@ -259,7 +232,6 @@ void r2dtank_state::machine_start() { /* setup for save states */ save_item(NAME(m_flipscreen)); - save_item(NAME(m_ttl74123_output)); save_item(NAME(m_AY8910_selected)); } @@ -271,7 +243,6 @@ void r2dtank_state::machine_start() * *************************************/ - void r2dtank_state::flipscreen_w(int state) { m_flipscreen = !state; @@ -285,9 +256,7 @@ MC6845_UPDATE_ROW( r2dtank_state::crtc_update_row ) for (uint8_t cx = 0; cx < x_count; cx++) { /* the memory is hooked up to the MA, RA lines this way */ - offs_t offs = ((ma << 3) & 0x1f00) | - ((ra << 5) & 0x00e0) | - ((ma << 0) & 0x001f); + offs_t offs = ((ma << 3) & 0x1f00) | ((ra << 5) & 0x00e0) | ((ma << 0) & 0x001f); if (m_flipscreen) offs = offs ^ 0x1fff; @@ -365,7 +334,6 @@ void r2dtank_state::r2dtank_audio_map(address_map &map) *************************************/ static INPUT_PORTS_START( r2dtank ) - PORT_START("IN0") PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 ) PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_COIN2 ) @@ -374,7 +342,7 @@ static INPUT_PORTS_START( r2dtank ) PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_COCKTAIL PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_START1 ) PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_START2 ) - PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_CUSTOM ) PORT_READ_LINE_MEMBER(FUNC(r2dtank_state::ttl74123_output_r)) + PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_CUSTOM ) PORT_READ_LINE_DEVICE_MEMBER("74123", FUNC(ttl74123_device::q_r)) PORT_START("IN1") PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_COCKTAIL @@ -436,7 +404,6 @@ static INPUT_PORTS_START( r2dtank ) PORT_DIPNAME( 0x80, 0x00, DEF_STR( Unknown ) ) PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) PORT_DIPSETTING( 0x80, DEF_STR( On ) ) - INPUT_PORTS_END @@ -471,8 +438,8 @@ void r2dtank_state::r2dtank(machine_config &config) crtc.set_update_row_callback(FUNC(r2dtank_state::crtc_update_row)); crtc.out_de_callback().set("74123", FUNC(ttl74123_device::a_w)); - /* 74LS123 */ - + /* 74LS123: This timer is responsible for delaying the PIA1's port input. */ + /* This delay ensures that CA1 is only changed in the VBLANK region, but not in HBLANK. */ ttl74123_device &ttl74123(TTL74123(config, "74123", 0)); ttl74123.set_connection_type(TTL74123_GROUNDED); /* the hook up type */ ttl74123.set_resistor_value(RES_K(22)); /* resistor connected to RCext */ @@ -480,7 +447,7 @@ void r2dtank_state::r2dtank(machine_config &config) ttl74123.set_a_pin_value(1); /* A pin - driven by the CRTC */ ttl74123.set_b_pin_value(1); /* B pin - pulled high */ ttl74123.set_clear_pin_value(1); /* Clear pin - pulled high */ - ttl74123.out_cb().set(FUNC(r2dtank_state::ttl74123_output_changed)); + ttl74123.out_cb().set(m_pia_main, FUNC(pia6821_device::ca1_w)); PIA6821(config, m_pia_main); m_pia_main->readpa_handler().set_ioport("IN0"); @@ -534,6 +501,7 @@ ROM_END } // anonymous namespace + /************************************* * * Game driver diff --git a/src/mame/sigma/spiders.cpp b/src/mame/sigma/spiders.cpp index 24388cf4d16..065546bc512 100644 --- a/src/mame/sigma/spiders.cpp +++ b/src/mame/sigma/spiders.cpp @@ -667,4 +667,4 @@ ROM_END GAME( 1981, spiders, 0, spiders, spiders, spiders_state, empty_init, ROT270, "Sigma Enterprises Inc.", "Spiders (set 1)", MACHINE_IMPERFECT_SOUND | MACHINE_SUPPORTS_SAVE) GAME( 1981, spiders2, spiders, spiders, spiders, spiders_state, empty_init, ROT270, "Sigma Enterprises Inc.", "Spiders (set 2)", MACHINE_IMPERFECT_SOUND | MACHINE_SUPPORTS_SAVE) GAME( 1981, spiders3, spiders, spiders, spiders, spiders_state, empty_init, ROT270, "Sigma Enterprises Inc.", "Spiders (set 3)", MACHINE_IMPERFECT_SOUND | MACHINE_SUPPORTS_SAVE) -GAME( 1981, spinner, spiders, spiders, spiders, spiders_state, empty_init, ROT270, "bootleg", "Spinner", MACHINE_IMPERFECT_SOUND | MACHINE_SUPPORTS_SAVE) +GAME( 1981, spinner, spiders, spiders, spiders, spiders_state, empty_init, ROT270, "bootleg", "Spinner", MACHINE_IMPERFECT_SOUND | MACHINE_SUPPORTS_SAVE)