From 0979c261d665dad8370a315b982ddfc0eb2f8148 Mon Sep 17 00:00:00 2001 From: hap Date: Sat, 17 Jun 2023 16:59:31 +0200 Subject: [PATCH] tx1: remove unpopulated DS3, fix steering wheel mask --- src/mame/tatsumi/tx1.h | 10 +-- src/mame/tatsumi/tx1_a.cpp | 135 ++++++++++++++++++------------------- src/mame/tatsumi/tx1_a.h | 72 +++++++++----------- 3 files changed, 105 insertions(+), 112 deletions(-) diff --git a/src/mame/tatsumi/tx1.h b/src/mame/tatsumi/tx1.h index 31dcab7ee40..2e28d5579db 100644 --- a/src/mame/tatsumi/tx1.h +++ b/src/mame/tatsumi/tx1.h @@ -100,7 +100,7 @@ private: #else struct { int16_t Z; uint16_t W; } as16bit; #endif - int32_t ZW32; + int32_t ZW32 = 0; } ZW; int code = 0; @@ -208,9 +208,9 @@ private: void tx1_draw_char(uint8_t *bitmap); void tx1_draw_road_pixel(int screen, uint8_t *bmpaddr, - uint8_t apix[3], uint8_t bpix[3], uint32_t pixnuma, uint32_t pixnumb, - uint8_t stl, uint8_t sld, uint8_t selb, - uint8_t bnk, uint8_t rorev, uint8_t eb, uint8_t r, uint8_t delr); + uint8_t apix[3], uint8_t bpix[3], uint32_t pixnuma, uint32_t pixnumb, + uint8_t stl, uint8_t sld, uint8_t selb, + uint8_t bnk, uint8_t rorev, uint8_t eb, uint8_t r, uint8_t delr); void tx1_draw_road(uint8_t *bitmap); void tx1_draw_objects(uint8_t *bitmap); void tx1_update_layers(); @@ -218,7 +218,7 @@ private: void buggyboy_draw_char(uint8_t *bitmap, bool wide); void buggyboy_get_roadpix(int screen, int ls161, uint8_t rva0_6, uint8_t sld, uint32_t *_rorev, - uint8_t *rc0, uint8_t *rc1, uint8_t *rc2, uint8_t *rc3); + uint8_t *rc0, uint8_t *rc1, uint8_t *rc2, uint8_t *rc3); void buggyboy_draw_road(uint8_t *bitmap); void buggybjr_draw_road(uint8_t *bitmap); void buggyboy_draw_objs(uint8_t *bitmap, bool wide); diff --git a/src/mame/tatsumi/tx1_a.cpp b/src/mame/tatsumi/tx1_a.cpp index 9363f8d9322..036e37bad79 100644 --- a/src/mame/tatsumi/tx1_a.cpp +++ b/src/mame/tatsumi/tx1_a.cpp @@ -57,40 +57,42 @@ static const double tx1_engine_gains[16] = DEFINE_DEVICE_TYPE(TX1_SOUND, tx1_sound_device, "tx1_sound", "TX-1 Custom Sound") DEFINE_DEVICE_TYPE(TX1J_SOUND, tx1j_sound_device, "tx1j_sound", "TX-1 Custom Sound (Japan)") -tx1_sound_device::tx1_sound_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) - : tx1_sound_device(mconfig, TX1_SOUND, tag, owner, clock) +tx1_sound_device::tx1_sound_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : + tx1_sound_device(mconfig, TX1_SOUND, tag, owner, clock) { } -tx1_sound_device::tx1_sound_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock) - : device_t(mconfig, type, tag, owner, clock), - device_sound_interface(mconfig, *this), - m_audiocpu(*this, "audio_cpu"), - m_z80_ram(*this, "z80_ram"), - m_ppi(*this, "ppi8255"), - m_dsw(*this, "DSW"), - m_steering(*this, "AN_STEERING"), - m_accelerator(*this, "AN_ACCELERATOR"), - m_brake(*this, "AN_BRAKE"), - m_ppi_portd(*this, "PPI_PORTD"), - m_stream(nullptr), - m_freq_to_step(0), - m_step0(0), - m_step1(0), - m_step2(0), - m_ay_outputa(0), - m_ay_outputb(0), - m_pit0(0), - m_pit1(0), - m_pit2(0), - m_noise_lfsra(0), - m_noise_lfsrb(1), - m_noise_lfsrc(0), - m_noise_lfsrd(0), - m_noise_counter(0), - m_ym1_outputa(0), - m_ym2_outputa(0), - m_ym2_outputb(0) +tx1_sound_device::tx1_sound_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock) : + device_t(mconfig, type, tag, owner, clock), + device_sound_interface(mconfig, *this), + m_audiocpu(*this, "audio_cpu"), + m_z80_ram(*this, "z80_ram"), + m_ppi(*this, "ppi8255"), + m_dsw(*this, "DSW"), + m_steering(*this, "AN_STEERING"), + m_accelerator(*this, "AN_ACCELERATOR"), + m_brake(*this, "AN_BRAKE"), + m_stream(nullptr), + m_freq_to_step(0), + m_step0(0), + m_step1(0), + m_step2(0), + m_ay_outputa(0), + m_ay_outputb(0), + m_ppi_latch_a(0), + m_ppi_latch_b(0), + m_ts(0), + m_pit0(0), + m_pit1(0), + m_pit2(0), + m_noise_lfsra(0), + m_noise_lfsrb(1), + m_noise_lfsrc(0), + m_noise_lfsrd(0), + m_noise_counter(0), + m_ym1_outputa(0), + m_ym2_outputa(0), + m_ym2_outputb(0) { } @@ -109,7 +111,6 @@ void tx1_sound_device::device_start() static const int r1[3] = { static_cast(180e3), static_cast(390e3), static_cast(56e3) }; static const int r2[3] = { static_cast(390e3), static_cast(390e3), static_cast(180e3) }; - /* Allocate the stream */ m_stream = stream_alloc(0, 2, machine().sample_rate()); m_freq_to_step = (double)(1 << TX1_FRAC) / (double)machine().sample_rate(); @@ -119,6 +120,10 @@ void tx1_sound_device::device_start() 4, &r0[0], m_weights0, 0, 0, 3, &r1[0], m_weights1, 0, 0, 3, &r2[0], m_weights2, 0, 0); + + std::fill(std::begin(m_eng0), std::end(m_eng0), 0.0); + std::fill(std::begin(m_eng1), std::end(m_eng1), 0.0); + std::fill(std::begin(m_eng2), std::end(m_eng2), 0.0); } //------------------------------------------------- @@ -186,7 +191,7 @@ uint16_t tx1_sound_device::dipswitches_r() uint8_t buggyboy_sound_device::bb_analog_r(offs_t offset) { if (offset == 0) - return bit_reverse8(((m_accelerator->read() & 0xf) << 4) | m_steering->read()); + return bit_reverse8(((m_accelerator->read() & 0xf) << 4) | (m_steering->read() & 0xf)); else return bit_reverse8((m_brake->read() & 0xf) << 4); } @@ -194,7 +199,7 @@ uint8_t buggyboy_sound_device::bb_analog_r(offs_t offset) uint8_t buggyboyjr_sound_device::bbjr_analog_r(offs_t offset) { if (offset == 0) - return ((m_accelerator->read() & 0xf) << 4) | m_steering->read(); + return ((m_accelerator->read() & 0xf) << 4) | (m_steering->read() & 0xf); else return (m_brake->read() & 0xf) << 4; } @@ -215,7 +220,7 @@ void buggyboy_sound_device::bb_coin_cnt_w(uint8_t data) void tx1_sound_device::tx1_ppi_latch_w(uint8_t data) { m_ppi_latch_a = ((m_brake->read() & 0xf) << 4) | (m_accelerator->read() & 0xf); - m_ppi_latch_b = m_steering->read(); + m_ppi_latch_b = m_steering->read() & 0xf; } uint8_t tx1_sound_device::tx1_ppi_porta_r() @@ -225,13 +230,15 @@ uint8_t tx1_sound_device::tx1_ppi_porta_r() uint8_t tx1_sound_device::tx1_ppi_portb_r() { - return m_ppi_portd->read() | m_ppi_latch_b; + // upper nibble goes to unpopulated DS.3 + return m_ppi_latch_b & 0xf; } void tx1_sound_device::pit8253_w(offs_t offset, uint8_t data) { m_stream->update(); + // TODO: use pit8253_device if (offset < 3) { if (m_pit8253.idx[offset] == 0) @@ -476,7 +483,7 @@ INPUT_PORTS_START( tx1_inputs ) PORT_DIPSETTING( 0xe000, "No Bonus" ) PORT_START("AN_STEERING") - PORT_BIT( 0xff, 0x00, IPT_DIAL ) PORT_SENSITIVITY(20) PORT_KEYDELTA(6) + PORT_BIT( 0x0f, 0x00, IPT_DIAL ) PORT_SENSITIVITY(20) PORT_KEYDELTA(6) PORT_START("AN_ACCELERATOR") PORT_BIT( 0x1f, 0x00, IPT_PEDAL ) PORT_MINMAX(0x00,0x1f) PORT_SENSITIVITY(25) PORT_KEYDELTA(10) @@ -489,14 +496,6 @@ INPUT_PORTS_START( tx1_inputs ) PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_COIN2 ) PORT_SERVICE( 0x04, IP_ACTIVE_HIGH ) PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_BUTTON3 ) PORT_NAME("Gear Change") PORT_TOGGLE - - PORT_START("PPI_PORTD") - /* Wire jumper setting on sound PCB - actually unpopulated 4 switch DS.3 */ - PORT_DIPNAME( 0xf0, 0x80, "Sound PCB Jumper (DS.3)" ) - PORT_DIPSETTING( 0x10, "1" ) - PORT_DIPSETTING( 0x20, "2" ) - PORT_DIPSETTING( 0x40, "3" ) - PORT_DIPSETTING( 0x80, "4" ) INPUT_PORTS_END ioport_constructor tx1_sound_device::device_input_ports() const @@ -618,19 +617,19 @@ static const double bb_engine_gains[16] = DEFINE_DEVICE_TYPE(BUGGYBOY_SOUND, buggyboy_sound_device, "buggyboy_sound", "Buggy Boy Custom Sound") DEFINE_DEVICE_TYPE(BUGGYBOYJR_SOUND, buggyboyjr_sound_device, "buggyboyjr_sound", "Buggy Boy Jr. Custom Sound") -buggyboy_sound_device::buggyboy_sound_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) - : buggyboy_sound_device(mconfig, BUGGYBOY_SOUND, tag, owner, clock) +buggyboy_sound_device::buggyboy_sound_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : + buggyboy_sound_device(mconfig, BUGGYBOY_SOUND, tag, owner, clock) { } -buggyboy_sound_device::buggyboy_sound_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock) - : tx1_sound_device(mconfig, type, tag, owner, clock) - , m_ym(*this, "ym%u", 1U) +buggyboy_sound_device::buggyboy_sound_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock) : + tx1_sound_device(mconfig, type, tag, owner, clock), + m_ym(*this, "ym%u", 1U) { } -buggyboyjr_sound_device::buggyboyjr_sound_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) - : buggyboy_sound_device(mconfig, BUGGYBOYJR_SOUND, tag, owner, clock) +buggyboyjr_sound_device::buggyboyjr_sound_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : + buggyboy_sound_device(mconfig, BUGGYBOYJR_SOUND, tag, owner, clock) { } @@ -642,7 +641,6 @@ void buggyboy_sound_device::device_start() { static const int resistors[4] = { 330000, 220000, 330000, 220000 }; double aweights[4]; - int i; static const int tmp[16] = { 0x0, 0x1, 0xe, 0xf, 0x8, 0x9, 0x6, 0x7, 0xc, 0xd, 0xe, 0xf, 0x4, 0x5, 0x6, 0x7 @@ -653,7 +651,7 @@ void buggyboy_sound_device::device_start() 0, nullptr, nullptr, 0, 0, 0, nullptr, nullptr, 0, 0 ); - for (i = 0; i < 16; i++) + for (int i = 0; i < 16; i++) m_eng_voltages[i] = combine_weights(aweights, BIT(tmp[i], 0), BIT(tmp[i], 1), BIT(tmp[i], 2), BIT(tmp[i], 3)); /* Allocate the stream */ @@ -731,12 +729,6 @@ void buggyboy_sound_device::ym2_b_w(uint8_t data) m_ym2_outputb = data ^ 0xff; - if (has_coin_counters()) - { - machine().bookkeeping().coin_counter_w(0, data & 0x01); - machine().bookkeeping().coin_counter_w(1, data & 0x02); - } - /* Until we support > 2 speakers, double the gain of the front speakers @@ -756,6 +748,14 @@ void buggyboy_sound_device::ym2_b_w(uint8_t data) m_ym[1]->set_output_gain(2, gain); } +void buggyboyjr_sound_device::ym2_b_w(uint8_t data) +{ + buggyboy_sound_device::ym2_b_w(data); + + machine().bookkeeping().coin_counter_w(0, ~data & 0x01); + machine().bookkeeping().coin_counter_w(1, ~data & 0x02); +} + //------------------------------------------------- // sound_stream_update - handle a stream update @@ -789,13 +789,12 @@ void buggyboy_sound_device::sound_stream_update(sound_stream &stream, std::vecto for (int sampindex = 0; sampindex < fl.samples(); sampindex++) { - int i; s32 pit0, pit1, n1, n2; pit0 = m_eng_voltages[(m_step0 >> 24) & 0xf]; pit1 = m_eng_voltages[(m_step1 >> 24) & 0xf]; /* Calculate the tyre screech noise source */ - for (i = 0; i < BUGGYBOY_NOISE_CLOCK / machine().sample_rate(); ++i) + for (int i = 0; i < BUGGYBOY_NOISE_CLOCK / machine().sample_rate(); ++i) { /* CD4006 is a 4-4-1-4-4-1 shift register */ int p13 = BIT(m_noise_lfsra, 3); @@ -810,14 +809,14 @@ void buggyboy_sound_device::sound_stream_update(sound_stream &stream, std::vecto m_noise_lfsrd = p10 | ((m_noise_lfsrd << 1) & 0x1f); /* 4040 12-bit counter is clocked on the falling edge of Q13 */ - if ( !BIT(m_noise_lfsrc, 3) && p10 ) + if (!BIT(m_noise_lfsrc, 3) && p10) m_noise_counter = (m_noise_counter + 1) & 0x0fff; } if (n1_en) { n1 = !BIT(m_noise_counter, 7-1) * 16000; - if ( BIT(m_noise_counter, 11-1) ) n1 /=2; + if (BIT(m_noise_counter, 11-1)) n1 /=2; } else n1 = 8192; @@ -825,7 +824,7 @@ void buggyboy_sound_device::sound_stream_update(sound_stream &stream, std::vecto if (n2_en) { n2 = !BIT(m_noise_counter, 6-1) * 16000; - if ( BIT(m_noise_counter, 11-1) ) n2 /=2; + if (BIT(m_noise_counter, 11-1)) n2 /=2; } else n2 = 8192; @@ -1087,7 +1086,7 @@ void buggyboyjr_sound_device::device_add_mconfig(machine_config &config) Z80(config, m_audiocpu, BUGGYBOY_ZCLK / 2); m_audiocpu->set_addrmap(AS_PROGRAM, &buggyboyjr_sound_device::buggybjr_sound_prg); m_audiocpu->set_addrmap(AS_IO, &buggyboyjr_sound_device::buggyboy_sound_io); - m_audiocpu->set_periodic_int(DEVICE_SELF, FUNC(buggyboy_sound_device::z80_irq), attotime::from_hz(BUGGYBOY_ZCLK / 2 / 4 / 2048)); + m_audiocpu->set_periodic_int(DEVICE_SELF, FUNC(buggyboyjr_sound_device::z80_irq), attotime::from_hz(BUGGYBOY_ZCLK / 2 / 4 / 2048)); SPEAKER(config, "frontleft", -0.2, 0.0, 1.0); SPEAKER(config, "frontright", 0.2, 0.0, 1.0); @@ -1100,8 +1099,8 @@ void buggyboyjr_sound_device::device_add_mconfig(machine_config &config) m_ym[0]->add_route(ALL_OUTPUTS, "frontleft", 0.15); YM2149(config, m_ym[1], BUGGYBOY_ZCLK / 4); /* YM2149 IC24 */ - m_ym[1]->port_a_write_callback().set(FUNC(buggyboy_sound_device::ym2_a_w)); - m_ym[1]->port_b_write_callback().set(FUNC(buggyboy_sound_device::ym2_b_w)); + m_ym[1]->port_a_write_callback().set(FUNC(buggyboyjr_sound_device::ym2_a_w)); + m_ym[1]->port_b_write_callback().set(FUNC(buggyboyjr_sound_device::ym2_b_w)); m_ym[1]->add_route(ALL_OUTPUTS, "frontright", 0.15); this->add_route(0, "frontleft", 0.2); diff --git a/src/mame/tatsumi/tx1_a.h b/src/mame/tatsumi/tx1_a.h index 149ba2a8dd6..98b5ae2a7c6 100644 --- a/src/mame/tatsumi/tx1_a.h +++ b/src/mame/tatsumi/tx1_a.h @@ -32,10 +32,9 @@ public: uint8_t pit8253_r(offs_t offset); void pit8253_w(offs_t offset, uint8_t data); - INTERRUPT_GEN_MEMBER( z80_irq ); + INTERRUPT_GEN_MEMBER(z80_irq); protected: - void tx1_ppi_latch_w(uint8_t data); void tx1_coin_cnt_w(uint8_t data); uint8_t tx1_ppi_porta_r(); @@ -58,7 +57,7 @@ protected: #else struct { uint8_t MSB; uint8_t LSB; } as8bit; #endif - uint16_t val; + uint16_t val = 0; } counts[3]; int idx[3]; @@ -87,42 +86,41 @@ protected: required_ioport m_steering; required_ioport m_accelerator; required_ioport m_brake; - optional_ioport m_ppi_portd; - sound_stream *m_stream = nullptr; - uint32_t m_freq_to_step = 0; - uint32_t m_step0 = 0; - uint32_t m_step1 = 0; - uint32_t m_step2 = 0; + sound_stream *m_stream; + uint32_t m_freq_to_step; + uint32_t m_step0; + uint32_t m_step1; + uint32_t m_step2; pit8253_state m_pit8253; - uint8_t m_ay_outputa = 0; - uint8_t m_ay_outputb = 0; + uint8_t m_ay_outputa; + uint8_t m_ay_outputb; - uint8_t m_ppi_latch_a = 0; - uint8_t m_ppi_latch_b = 0; - uint32_t m_ts = 0; + uint8_t m_ppi_latch_a; + uint8_t m_ppi_latch_b; + uint32_t m_ts; - s32 m_pit0 = 0; - s32 m_pit1 = 0; - s32 m_pit2 = 0; + s32 m_pit0; + s32 m_pit1; + s32 m_pit2; - double m_weights0[4] = { 0, 0, 0, 0 }; - double m_weights1[3] = { 0, 0, 0 }; - double m_weights2[3] = { 0, 0, 0 }; - int m_eng0[4] = { 0, 0, 0, 0 }; - int m_eng1[4] = { 0, 0, 0, 0 }; - int m_eng2[4] = { 0, 0, 0, 0 }; + double m_weights0[4]; + double m_weights1[3]; + double m_weights2[3]; + int m_eng0[4]; + int m_eng1[4]; + int m_eng2[4]; - int m_noise_lfsra = 0; - int m_noise_lfsrb = 0; - int m_noise_lfsrc = 0; - int m_noise_lfsrd = 0; - int m_noise_counter = 0; - uint8_t m_ym1_outputa = 0; - uint8_t m_ym2_outputa = 0; - uint8_t m_ym2_outputb = 0; + int m_noise_lfsra; + int m_noise_lfsrb; + int m_noise_lfsrc; + int m_noise_lfsrd; + int m_noise_counter; + uint8_t m_ym1_outputa; + uint8_t m_ym2_outputa; + uint8_t m_ym2_outputb; uint16_t m_eng_voltages[16]; }; @@ -132,7 +130,6 @@ public: tx1j_sound_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); protected: - // device-level overrides virtual ioport_constructor device_input_ports() const override; }; @@ -142,9 +139,6 @@ class buggyboy_sound_device : public tx1_sound_device public: buggyboy_sound_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); - void ym2_a_w(uint8_t data); - void ym2_b_w(uint8_t data); - protected: buggyboy_sound_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock); @@ -158,12 +152,12 @@ protected: virtual void sound_stream_update(sound_stream &stream, std::vector const &inputs, std::vector &outputs) override; void ym1_a_w(uint8_t data); + void ym2_a_w(uint8_t data); + virtual void ym2_b_w(uint8_t data); uint8_t bb_analog_r(offs_t offset); void bb_coin_cnt_w(uint8_t data); - virtual bool has_coin_counters() { return false; } - void buggyboy_sound_io(address_map &map); void buggyboy_sound_prg(address_map &map); @@ -180,9 +174,9 @@ protected: virtual ioport_constructor device_input_ports() const override; virtual void device_add_mconfig(machine_config &config) override; - uint8_t bbjr_analog_r(offs_t offset); + virtual void ym2_b_w(uint8_t data) override; - virtual bool has_coin_counters() override { return true; } + uint8_t bbjr_analog_r(offs_t offset); void buggybjr_sound_prg(address_map &map); };