From df8aade7a2abf27025ff9b8fdb426cea97876b2b Mon Sep 17 00:00:00 2001 From: hap Date: Thu, 29 Jun 2023 14:48:20 +0200 Subject: [PATCH] victory,exidy440: similar collision timer fix as exidy.cpp, exidysound: add todo note, PIA irq is from pin 38, not pin 37 --- src/mame/exidy/exidy440.h | 4 +- src/mame/exidy/exidy440_v.cpp | 18 ++++++--- src/mame/exidy/victory.h | 16 ++++---- src/mame/exidy/victory_v.cpp | 24 +++++++----- src/mame/shared/exidysound.cpp | 68 ++++++++++++++++++---------------- src/mame/shared/exidysound.h | 4 +- 6 files changed, 75 insertions(+), 59 deletions(-) diff --git a/src/mame/exidy/exidy440.h b/src/mame/exidy/exidy440.h index 2ba19536247..a2539969b5f 100644 --- a/src/mame/exidy/exidy440.h +++ b/src/mame/exidy/exidy440.h @@ -98,8 +98,8 @@ private: uint8_t m_firq_select = 0U; uint8_t m_palettebank_io = 0U; uint8_t m_palettebank_vis = 0U; - emu_timer *m_beam_firq_timer = nullptr; - emu_timer *m_collide_firq_timer = nullptr; + emu_timer *m_beam_firq_timer; + emu_timer *m_collide_firq_timer[128]; uint8_t m_beam_firq_count = 0U; }; diff --git a/src/mame/exidy/exidy440_v.cpp b/src/mame/exidy/exidy440_v.cpp index 7f3eb5519aa..34e429c10cc 100644 --- a/src/mame/exidy/exidy440_v.cpp +++ b/src/mame/exidy/exidy440_v.cpp @@ -53,7 +53,9 @@ void exidy440_state::video_start() memset(m_local_paletteram.get(), 0, 512 * 2); m_beam_firq_timer = timer_alloc(FUNC(exidy440_state::beam_firq_callback), this); - m_collide_firq_timer = timer_alloc(FUNC(exidy440_state::collide_firq_callback), this); + + for (int i = 0; i < 128; i++) + m_collide_firq_timer[i] = timer_alloc(FUNC(exidy440_state::collide_firq_callback), this); } @@ -355,8 +357,11 @@ void exidy440_state::draw_sprites(screen_device &screen, bitmap_ind16 &bitmap, c bitmap.pix(yoffs, currx) = pen; /* check the collisions bit */ - if (check_collision && (palette[2 * pen] & 0x80) && (count++ < 128)) - m_collide_firq_timer->adjust(screen.time_until_pos(yoffs, currx), currx); + if (check_collision && (palette[2 * pen] & 0x80) && count < 128) + { + m_collide_firq_timer[count]->adjust(screen.time_until_pos(yoffs, currx), currx); + count++; + } } currx++; @@ -368,8 +373,11 @@ void exidy440_state::draw_sprites(screen_device &screen, bitmap_ind16 &bitmap, c bitmap.pix(yoffs, currx) = pen; /* check the collisions bit */ - if (check_collision && (palette[2 * pen] & 0x80) && (count++ < 128)) - m_collide_firq_timer->adjust(screen.time_until_pos(yoffs, currx), currx); + if (check_collision && (palette[2 * pen] & 0x80) && count < 128) + { + m_collide_firq_timer[count]->adjust(screen.time_until_pos(yoffs, currx), currx); + count++; + } } currx++; } diff --git a/src/mame/exidy/victory.h b/src/mame/exidy/victory.h index 80af00c77e1..84e2a189abe 100644 --- a/src/mame/exidy/victory.h +++ b/src/mame/exidy/victory.h @@ -16,13 +16,13 @@ #define VICTORY_MAIN_CPU_CLOCK (XTAL(8'000'000) / 2) -#define VICTORY_PIXEL_CLOCK (XTAL(11'289'000) / 2) -#define VICTORY_HTOTAL (0x150) -#define VICTORY_HBEND (0x000) -#define VICTORY_HBSTART (0x100) -#define VICTORY_VTOTAL (0x118) -#define VICTORY_VBEND (0x000) -#define VICTORY_VBSTART (0x100) +#define VICTORY_PIXEL_CLOCK (XTAL(11'289'000) / 2) +#define VICTORY_HTOTAL (0x150) +#define VICTORY_HBEND (0x000) +#define VICTORY_HBSTART (0x100) +#define VICTORY_VTOTAL (0x118) +#define VICTORY_VBEND (0x000) +#define VICTORY_VBSTART (0x100) class victory_state : public driver_device @@ -107,7 +107,7 @@ private: uint8_t m_scrolly = 0; uint8_t m_video_control = 0; micro_t m_micro; - emu_timer *m_bgcoll_irq_timer = nullptr; + emu_timer *m_bgcoll_irq_timer[128]; }; #endif // MAME_EXIDY_VICTORY_H diff --git a/src/mame/exidy/victory_v.cpp b/src/mame/exidy/victory_v.cpp index 468a3a945fc..87c0fb3c33a 100644 --- a/src/mame/exidy/victory_v.cpp +++ b/src/mame/exidy/victory_v.cpp @@ -48,9 +48,12 @@ void victory_state::video_start() m_bgcoll = m_bgcollx = m_bgcolly = 0; m_scrollx = m_scrolly = 0; m_video_control = 0; + memset(&m_micro, 0, sizeof(m_micro)); m_micro.timer = machine().scheduler().timer_alloc(timer_expired_delegate()); - m_bgcoll_irq_timer = timer_alloc(FUNC(victory_state::bgcoll_irq_callback), this); + + for (int i = 0; i < 128; i++) + m_bgcoll_irq_timer[i] = timer_alloc(FUNC(victory_state::bgcoll_irq_callback), this); /* register for state saving */ save_item(NAME(m_paletteram)); @@ -603,13 +606,12 @@ int victory_state::command3() int xcount = 8 - (micro.r >> 5); int shift = micro.xp & 7; int nshift = 8 - shift; - int x, y, sy; - for (x = 0; x < xcount; x++, micro.xp += 8) + for (int x = 0; x < xcount; x++, micro.xp += 8) { - sy = micro.yp; + uint8_t sy = micro.yp; - for (y = 0; y < ycount; y++) + for (int y = 0; y < ycount; y++) { int srcoffs = micro.i++ & 0x3fff; int dstoffs = (sy++ & 0xff) * 32 + micro.xp / 8; @@ -800,12 +802,11 @@ int victory_state::command5() uint8_t y = micro.yp; int acc = 0x80; int i = micro.i >> 8; - int c; /* non-collision-detect case */ if (!(micro.cmd & 0x08) || m_fgcoll) { - for (c = micro.i & 0xff; c < 0x100; c++) + for (int c = micro.i & 0xff; c < 0x100; c++) { int addr = y * 32 + x / 8; int shift = x & 7; @@ -836,7 +837,7 @@ int victory_state::command5() /* collision-detect case */ else { - for (c = micro.i & 0xff; c < 0x100; c++) + for (int c = micro.i & 0xff; c < 0x100; c++) { int addr = y * 32 + x / 8; int shift = x & 7; @@ -1119,8 +1120,11 @@ uint32_t victory_state::screen_update(screen_device &screen, bitmap_ind16 &bitma int fpix = *fg++; int bpix = bg[(x + m_scrollx) & 255]; scanline[x] = bpix | (fpix << 3); - if (fpix && (bpix & bgcollmask) && count++ < 128) - m_bgcoll_irq_timer->adjust(screen.time_until_pos(y, x), x | (y << 8)); + if (fpix && (bpix & bgcollmask) && count < 128) + { + m_bgcoll_irq_timer[count]->adjust(screen.time_until_pos(y, x), x | (y << 8)); + count++; + } } } diff --git a/src/mame/shared/exidysound.cpp b/src/mame/shared/exidysound.cpp index 2ec5011c301..1155214871d 100644 --- a/src/mame/shared/exidysound.cpp +++ b/src/mame/shared/exidysound.cpp @@ -4,6 +4,9 @@ Exidy 6502 hardware + TODO: + - use ptm6840_device and pit8253_device + *************************************************************************/ #include "emu.h" @@ -24,7 +27,7 @@ * *************************************/ -#define CRYSTAL_OSC (XTAL(3'579'545)) +#define CRYSTAL_OSC (3.579545_MHz_XTAL) #define SH8253_CLOCK (CRYSTAL_OSC / 2) #define SH6840_CLOCK (CRYSTAL_OSC / 4) #define SH6532_CLOCK (CRYSTAL_OSC / 4) @@ -168,6 +171,7 @@ void exidy_sound_device::sh6840_register_state_globals() save_item(NAME(m_sh6840_timer[2].counter.w)); } + /************************************* * * Audio startup routines @@ -194,32 +198,32 @@ exidy_sound_device::exidy_sound_device(const machine_config &mconfig, const char } exidy_sh8253_sound_device::exidy_sh8253_sound_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock) - : exidy_sound_device(mconfig, type, tag, owner, clock), - m_riot(*this, "riot"), - m_cvsd(*this, "cvsd"), - m_cvsd_filter(*this, "cvsd_filter"), - m_cvsd_filter2(*this, "cvsd_filter2"), - m_cvsdcpu(*this, "cvsdcpu"), - m_tms(*this, "tms"), - m_pia(*this, "pia") + : exidy_sound_device(mconfig, type, tag, owner, clock) + , m_riot(*this, "riot") + , m_cvsd(*this, "cvsd") + , m_cvsd_filter(*this, "cvsd_filter") + , m_cvsd_filter2(*this, "cvsd_filter2") + , m_cvsdcpu(*this, "cvsdcpu") + , m_tms(*this, "tms") + , m_pia(*this, "pia") { } exidy_sound_device::exidy_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_stream(nullptr), - m_freq_to_step(0), - m_sh6840_MSB_latch(0), - m_sh6840_LSB_latch(0), - m_sh6840_LFSR_oldxor(0), - m_sh6840_LFSR_0(0xffffffff), - m_sh6840_LFSR_1(0xffffffff), - m_sh6840_LFSR_2(0xffffffff), - m_sh6840_LFSR_3(0xffffffff), - m_sh6840_clocks_per_sample(0), - m_sh6840_clock_count(0), - m_sfxctrl(0) + : device_t(mconfig, type, tag, owner, clock) + , device_sound_interface(mconfig, *this) + , m_stream(nullptr) + , m_freq_to_step(0) + , m_sh6840_MSB_latch(0) + , m_sh6840_LSB_latch(0) + , m_sh6840_LFSR_oldxor(0) + , m_sh6840_LFSR_0(0xffffffff) + , m_sh6840_LFSR_1(0xffffffff) + , m_sh6840_LFSR_2(0xffffffff) + , m_sh6840_LFSR_3(0xffffffff) + , m_sh6840_clocks_per_sample(0) + , m_sh6840_clock_count(0) + , m_sfxctrl(0) { } @@ -444,7 +448,6 @@ uint8_t exidy_sh8253_sound_device::r6532_portb_r() * *************************************/ - void exidy_sh8253_sound_device::sh8253_register_state_globals() { save_item(NAME(m_sh8253_timer[0].clstate)); @@ -464,6 +467,7 @@ void exidy_sh8253_sound_device::sh8253_register_state_globals() save_item(NAME(m_sh8253_timer[2].fraction)); } + /************************************* * * 8253 timer handlers @@ -639,7 +643,6 @@ void venture_sound_device::filter_w(uint8_t data) * *************************************/ - DEFINE_DEVICE_TYPE(EXIDY_VENTURE, venture_sound_device, "venture_sound", "Exidy SFX+PSG") venture_sound_device::venture_sound_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) @@ -737,7 +740,7 @@ void venture_sound_device::venture_audio_map(address_map &map) map(0x0000, 0x007f).mirror(0x0780).ram(); map(0x0800, 0x087f).mirror(0x0780).rw("riot", FUNC(riot6532_device::read), FUNC(riot6532_device::write)); map(0x1000, 0x1003).mirror(0x07fc).rw("pia", FUNC(pia6821_device::read), FUNC(pia6821_device::write)); - map(0x1800, 0x1803).mirror(0x07fc).w(FUNC(venture_sound_device::sh8253_w)); + map(0x1800, 0x1803).mirror(0x07fc).w(FUNC(venture_sound_device::sh8253_w)).nopr(); // no /RD map(0x2000, 0x27ff).w(FUNC(venture_sound_device::filter_w)); map(0x2800, 0x2807).mirror(0x07f8).rw(FUNC(venture_sound_device::sh6840_r), FUNC(venture_sound_device::sh6840_w)); map(0x3000, 0x3003).mirror(0x07fc).w(FUNC(venture_sound_device::sfxctrl_w)); @@ -747,7 +750,7 @@ void venture_sound_device::venture_audio_map(address_map &map) void venture_sound_device::device_add_mconfig(machine_config &config) { - m6502_device &audiocpu(M6502(config, "audiocpu", 3579545/4)); + m6502_device &audiocpu(M6502(config, "audiocpu", 3.579545_MHz_XTAL / 4)); audiocpu.set_addrmap(AS_PROGRAM, &venture_sound_device::venture_audio_map); RIOT6532(config, m_riot, SH6532_CLOCK); @@ -762,7 +765,7 @@ void venture_sound_device::device_add_mconfig(machine_config &config) m_pia->writepb_handler().set(FUNC(venture_sound_device::pia_pb_w)); m_pia->ca2_handler().set(FUNC(venture_sound_device::pia_ca2_w)); m_pia->cb2_handler().set(FUNC(venture_sound_device::pia_cb2_w)); - m_pia->irqb_handler().set("audioirq", FUNC(input_merger_device::in_w<1>)); + m_pia->irqa_handler().set("audioirq", FUNC(input_merger_device::in_w<1>)); INPUT_MERGER_ANY_HIGH(config, "audioirq").output_handler().set_inputline("audiocpu", m6502_device::IRQ_LINE); // open collector @@ -883,11 +886,10 @@ void mtrap_sound_device::device_add_mconfig(machine_config &config) * *************************************/ -#define VICTORY_AUDIO_CPU_CLOCK (XTAL(3'579'545) / 4) +#define VICTORY_AUDIO_CPU_CLOCK (3.579545_MHz_XTAL / 4) #define VICTORY_LOG_SOUND 0 - uint8_t victory_sound_device::response_r() { uint8_t ret = m_pia->b_output(); @@ -960,6 +962,8 @@ DEFINE_DEVICE_TYPE(EXIDY_VICTORY, victory_sound_device, "victory_sound", "Exidy victory_sound_device::victory_sound_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : exidy_sh8253_sound_device(mconfig, EXIDY_VICTORY, tag, owner, clock) , m_victory_sound_response_ack_clk(0) + , m_pia_ca1(0) + , m_pia_cb1(0) { } @@ -1002,7 +1006,7 @@ void victory_sound_device::victory_audio_map(address_map &map) map(0x0000, 0x00ff).mirror(0x0f00).ram(); map(0x1000, 0x107f).mirror(0x0f80).rw("riot", FUNC(riot6532_device::read), FUNC(riot6532_device::write)); map(0x2000, 0x2003).mirror(0x0ffc).rw("pia", FUNC(pia6821_device::read), FUNC(pia6821_device::write)); - map(0x3000, 0x3003).mirror(0x0ffc).w(FUNC(victory_sound_device::sh8253_w)); + map(0x3000, 0x3003).mirror(0x0ffc).w(FUNC(victory_sound_device::sh8253_w)).nopr(); // no /RD map(0x4000, 0x4fff).noprw(); map(0x5000, 0x5007).mirror(0x0ff8).rw(FUNC(victory_sound_device::sh6840_r), FUNC(victory_sound_device::sh6840_w)); map(0x6000, 0x6003).mirror(0x0ffc).w(FUNC(victory_sound_device::sfxctrl_w)); @@ -1026,7 +1030,7 @@ void victory_sound_device::device_add_mconfig(machine_config &config) PIA6821(config, m_pia, 0); m_pia->ca2_handler().set(FUNC(victory_sound_device::irq_clear_w)); m_pia->cb2_handler().set(FUNC(victory_sound_device::main_ack_w)); - m_pia->irqb_handler().set("audioirq", FUNC(input_merger_device::in_w<1>)); + m_pia->irqa_handler().set("audioirq", FUNC(input_merger_device::in_w<1>)); INPUT_MERGER_ANY_HIGH(config, "audioirq").output_handler().set_inputline("audiocpu", m6502_device::IRQ_LINE); // open collector diff --git a/src/mame/shared/exidysound.h b/src/mame/shared/exidysound.h index cf41f2799a9..a346d4c1b86 100644 --- a/src/mame/shared/exidysound.h +++ b/src/mame/shared/exidysound.h @@ -223,8 +223,8 @@ private: TIMER_CALLBACK_MEMBER( delayed_command_w ); - int m_pia_ca1 = 0; - int m_pia_cb1 = 0; + int m_pia_ca1; + int m_pia_cb1; }; DECLARE_DEVICE_TYPE(EXIDY_VICTORY, victory_sound_device)