summaryrefslogtreecommitdiffstatshomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/devices/cpu/alto2/a2ether.cpp2
-rw-r--r--src/devices/cpu/alto2/a2ether.h78
-rw-r--r--src/mame/interton/vc4000.h67
-rw-r--r--src/mame/interton/vc4000_v.cpp59
-rw-r--r--src/mame/shared/exidysound.cpp301
-rw-r--r--src/mame/shared/exidysound.h31
6 files changed, 230 insertions, 308 deletions
diff --git a/src/devices/cpu/alto2/a2ether.cpp b/src/devices/cpu/alto2/a2ether.cpp
index 87ee4268370..4bdd9b649a5 100644
--- a/src/devices/cpu/alto2/a2ether.cpp
+++ b/src/devices/cpu/alto2/a2ether.cpp
@@ -1307,7 +1307,7 @@ void alto2_cpu_device::update_tclk(int tclk)
void alto2_cpu_device::init_ether(int task)
{
// intialize all ethernet variables
- memset(&m_eth, 0, sizeof(m_eth));
+ m_eth = decltype(m_eth)();
save_item(NAME(m_eth.fifo));
save_item(NAME(m_eth.fifo_rd));
save_item(NAME(m_eth.fifo_wr));
diff --git a/src/devices/cpu/alto2/a2ether.h b/src/devices/cpu/alto2/a2ether.h
index 7d0ab567215..7ec4320c226 100644
--- a/src/devices/cpu/alto2/a2ether.h
+++ b/src/devices/cpu/alto2/a2ether.h
@@ -48,45 +48,45 @@ enum {
};
struct {
- uint32_t serin; //!< serial input shift registers 74164 #37 and #33
- uint16_t fifo[ALTO2_ETHER_FIFO_SIZE]; //!< FIFO buffer
- uint16_t fifo_rd; //!< FIFO input pointer
- uint16_t fifo_wr; //!< FIFO output pointer
- uint16_t status; //!< status word
- uint16_t rx_crc; //!< receiver CRC
- uint16_t tx_crc; //!< transmitter CRC
- uint32_t rx_count; //!< received words count
- uint32_t tx_count; //!< transmitted words count
- std::unique_ptr<uint16_t[]> rx_packet; //!< buffer to collect received words
- std::unique_ptr<uint16_t[]> tx_packet; //!< buffer to collect transmitted words
- emu_timer* rx_timer; //!< receiver timer
- emu_timer* tx_timer; //!< transmitter timer
- jkff_t ff_10a; //!< JK flip-flop 10a IBUSY (Sheet 13)
- jkff_t ff_10b; //!< JK flip-flop 10b OBUSY (Sheet 13)
- jkff_t ff_21a; //!< JK flip-flop 21a OUTON (Sheet 19)
- jkff_t ff_21b; //!< JK flip-flop 21b COLL (Sheet 19)
- jkff_t ff_31a; //!< JK flip-flop 31a OUTGONE (Sheet 19)
- jkff_t ff_31b; //!< JK flip-flop 31b OEOT (Sheet 19)
- jkff_t ff_35a; //!< JK flip-flop 35a OCMD (Sheet 7)
- jkff_t ff_35b; //!< JK flip-flop 35b ICMD (Sheet 7)
- jkff_t ff_47a; //!< JK flip-flop 47a ISR14 (Sheet 15)
- jkff_t ff_47b; //!< JK flip-flop 47b ISR15 (Sheet 15)
- jkff_t ff_51a; //!< JK flip-flop 51a EWFCT latch (Sheet 19)
- jkff_t ff_51b; //!< JK flip-flop 51b OCDW (Sheet 19)
- jkff_t ff_52b; //!< JK flip-flop 52b OSLOAD (Sheet 17)
- jkff_t ff_61a; //!< JK flip-flop 61a CRCGO (Sheet 21)
- jkff_t ff_61b; //!< JK flip-flop 61b OUTRGO (Sheet 21)
- jkff_t ff_62a; //!< JK flip-flop 62a OUTON (Sheet 21)
- jkff_t ff_62b; //!< JK flip-flop 62b OUTGO (Sheet 21)
- jkff_t ff_65a; //!< JK flip-flop 65a IDL (Sheet 10)
- jkff_t ff_65b; //!< JK flip-flop 65b IO (Sheet 10)
- jkff_t ff_69a; //!< JK flip-flop 69a IT (Sheet 14)
- jkff_t ff_69b; //!< JK flip-flop 69b INON (Sheet 14)
- jkff_t ff_70a; //!< JK flip-flop 70a IMID (Sheet 14)
- jkff_t ff_70b; //!< JK flip-flop 70b ILOC (Sheet 14)
- jkff_t ff_77a; //!< JK flip-flop 77a WR (Sheet 10)
- jkff_t ff_77b; //!< JK flip-flop 77b WLF (Sheet 10)
- int breath_of_life; //!< if non-zero, interval in seconds at which to broadcast the breath-of-life
+ uint32_t serin = 0; //!< serial input shift registers 74164 #37 and #33
+ uint16_t fifo[ALTO2_ETHER_FIFO_SIZE] = { }; //!< FIFO buffer
+ uint16_t fifo_rd = 0; //!< FIFO input pointer
+ uint16_t fifo_wr = 0; //!< FIFO output pointer
+ uint16_t status = 0; //!< status word
+ uint16_t rx_crc = 0; //!< receiver CRC
+ uint16_t tx_crc = 0; //!< transmitter CRC
+ uint32_t rx_count = 0; //!< received words count
+ uint32_t tx_count = 0; //!< transmitted words count
+ std::unique_ptr<uint16_t []> rx_packet; //!< buffer to collect received words
+ std::unique_ptr<uint16_t []> tx_packet; //!< buffer to collect transmitted words
+ emu_timer *rx_timer = nullptr; //!< receiver timer
+ emu_timer *tx_timer = nullptr; //!< transmitter timer
+ jkff_t ff_10a = JKFF_0; //!< JK flip-flop 10a IBUSY (Sheet 13)
+ jkff_t ff_10b = JKFF_0; //!< JK flip-flop 10b OBUSY (Sheet 13)
+ jkff_t ff_21a = JKFF_0; //!< JK flip-flop 21a OUTON (Sheet 19)
+ jkff_t ff_21b = JKFF_0; //!< JK flip-flop 21b COLL (Sheet 19)
+ jkff_t ff_31a = JKFF_0; //!< JK flip-flop 31a OUTGONE (Sheet 19)
+ jkff_t ff_31b = JKFF_0; //!< JK flip-flop 31b OEOT (Sheet 19)
+ jkff_t ff_35a = JKFF_0; //!< JK flip-flop 35a OCMD (Sheet 7)
+ jkff_t ff_35b = JKFF_0; //!< JK flip-flop 35b ICMD (Sheet 7)
+ jkff_t ff_47a = JKFF_0; //!< JK flip-flop 47a ISR14 (Sheet 15)
+ jkff_t ff_47b = JKFF_0; //!< JK flip-flop 47b ISR15 (Sheet 15)
+ jkff_t ff_51a = JKFF_0; //!< JK flip-flop 51a EWFCT latch (Sheet 19)
+ jkff_t ff_51b = JKFF_0; //!< JK flip-flop 51b OCDW (Sheet 19)
+ jkff_t ff_52b = JKFF_0; //!< JK flip-flop 52b OSLOAD (Sheet 17)
+ jkff_t ff_61a = JKFF_0; //!< JK flip-flop 61a CRCGO (Sheet 21)
+ jkff_t ff_61b = JKFF_0; //!< JK flip-flop 61b OUTRGO (Sheet 21)
+ jkff_t ff_62a = JKFF_0; //!< JK flip-flop 62a OUTON (Sheet 21)
+ jkff_t ff_62b = JKFF_0; //!< JK flip-flop 62b OUTGO (Sheet 21)
+ jkff_t ff_65a = JKFF_0; //!< JK flip-flop 65a IDL (Sheet 10)
+ jkff_t ff_65b = JKFF_0; //!< JK flip-flop 65b IO (Sheet 10)
+ jkff_t ff_69a = JKFF_0; //!< JK flip-flop 69a IT (Sheet 14)
+ jkff_t ff_69b = JKFF_0; //!< JK flip-flop 69b INON (Sheet 14)
+ jkff_t ff_70a = JKFF_0; //!< JK flip-flop 70a IMID (Sheet 14)
+ jkff_t ff_70b = JKFF_0; //!< JK flip-flop 70b ILOC (Sheet 14)
+ jkff_t ff_77a = JKFF_0; //!< JK flip-flop 77a WR (Sheet 10)
+ jkff_t ff_77b = JKFF_0; //!< JK flip-flop 77b WLF (Sheet 10)
+ int breath_of_life = 0; //!< if non-zero, interval in seconds at which to broadcast the breath-of-life
} m_eth;
TIMER_CALLBACK_MEMBER( rx_breath_of_life ); //!< HACK: pull the next word from the breath-of-life in the fifo
diff --git a/src/mame/interton/vc4000.h b/src/mame/interton/vc4000.h
index 2f7059bad87..5c83e81c29c 100644
--- a/src/mame/interton/vc4000.h
+++ b/src/mame/interton/vc4000.h
@@ -22,6 +22,10 @@
#include "emupal.h"
#include "screen.h"
+#include <algorithm>
+#include <cassert>
+
+
// define this to use digital inputs instead of the slow
// autocentering analog mame joys
#define ANALOG_HACK
@@ -55,13 +59,17 @@ public:
#endif
{ }
- void cx3000tc(machine_config &config);
- void mpu1000(machine_config &config);
- void vc4000(machine_config &config);
- void database(machine_config &config);
- void h21(machine_config &config);
- void rwtrntcs(machine_config &config);
- void elektor(machine_config &config);
+ void cx3000tc(machine_config &config) ATTR_COLD;
+ void mpu1000(machine_config &config) ATTR_COLD;
+ void vc4000(machine_config &config) ATTR_COLD;
+ void database(machine_config &config) ATTR_COLD;
+ void h21(machine_config &config) ATTR_COLD;
+ void rwtrntcs(machine_config &config) ATTR_COLD;
+ void elektor(machine_config &config) ATTR_COLD;
+
+protected:
+ virtual void machine_start() override ATTR_COLD;
+ virtual void video_start() override ATTR_COLD;
private:
struct SPRITE_HELPER
@@ -90,7 +98,7 @@ private:
uint8_t background_collision = 0;
union
{
- uint8_t data[0x100]{};
+ uint8_t data[0x100];
struct
{
SPRITE_HELPER sprites[3];
@@ -111,6 +119,12 @@ private:
uint8_t sprite_collision;
} d;
} reg;
+
+ vc4000_video_t()
+ {
+ static_assert(sizeof(reg.d) == 204, "video registers not packed correctly");
+ std::fill(std::begin(reg.data), std::end(reg.data), 0);
+ }
};
void vc4000_sound_ctl(offs_t offset, uint8_t data);
@@ -120,19 +134,8 @@ private:
int vc4000_vsync_r();
uint8_t elektor_cass_r();
void elektor_cass_w(uint8_t data);
- vc4000_video_t m_video;
- uint8_t m_sprite_collision[0x20]{};
- uint8_t m_background_collision[0x20]{};
- uint8_t m_joy1_x = 0;
- uint8_t m_joy1_y = 0;
- uint8_t m_joy2_x = 0;
- uint8_t m_joy2_y = 0;
- uint8_t m_objects[512]{};
- uint8_t m_irq_pause = 0;
- std::unique_ptr<bitmap_ind16> m_bitmap;
- virtual void machine_start() override ATTR_COLD;
- virtual void video_start() override ATTR_COLD;
- void vc4000_palette(palette_device &palette) const;
+
+ void vc4000_palette(palette_device &palette) const ATTR_COLD;
uint32_t screen_update_vc4000(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
INTERRUPT_GEN_MEMBER(vc4000_video_line);
DECLARE_QUICKLOAD_LOAD_MEMBER(quickload_cb);
@@ -140,6 +143,12 @@ private:
void elektor_mem(address_map &map) ATTR_COLD;
void vc4000_mem(address_map &map) ATTR_COLD;
+ inline uint8_t vc4000_joystick_return_to_centre(uint8_t joy);
+ void vc4000_draw_digit(bitmap_ind16 &bitmap, int x, int y, int d, int line);
+ inline void vc4000_collision_plot(uint8_t *collision, uint8_t data, uint8_t color, int scale);
+ void vc4000_sprite_update(bitmap_ind16 &bitmap, uint8_t *collision, SPRITE *This);
+ inline void vc4000_draw_grid(uint8_t *collision);
+
required_device<s2650_device> m_maincpu;
required_device<screen_device> m_screen;
optional_device<cassette_image_device> m_cassette;
@@ -161,11 +170,17 @@ private:
required_ioport m_joys;
required_ioport m_config;
#endif
- inline uint8_t vc4000_joystick_return_to_centre(uint8_t joy);
- void vc4000_draw_digit(bitmap_ind16 &bitmap, int x, int y, int d, int line);
- inline void vc4000_collision_plot(uint8_t *collision, uint8_t data, uint8_t color, int scale);
- void vc4000_sprite_update(bitmap_ind16 &bitmap, uint8_t *collision, SPRITE *This);
- inline void vc4000_draw_grid(uint8_t *collision);
+
+ bitmap_ind16 m_bitmap;
+ vc4000_video_t m_video;
+ uint8_t m_sprite_collision[0x20]{};
+ uint8_t m_background_collision[0x20]{};
+ uint8_t m_joy1_x = 0;
+ uint8_t m_joy1_y = 0;
+ uint8_t m_joy2_x = 0;
+ uint8_t m_joy2_y = 0;
+ uint8_t m_objects[512]{};
+ uint8_t m_irq_pause = 0;
};
#endif // MAME_INTERTON_VC4000_H
diff --git a/src/mame/interton/vc4000_v.cpp b/src/mame/interton/vc4000_v.cpp
index 288acb6b0e9..5f3dfb85a5d 100644
--- a/src/mame/interton/vc4000_v.cpp
+++ b/src/mame/interton/vc4000_v.cpp
@@ -27,22 +27,21 @@
void vc4000_state::video_start()
{
- int i;
-
- for (i=0;i<0x20; i++)
+ for (int i = 0; i < std::size(m_sprite_collision); i++)
{
- m_sprite_collision[i]=0;
- if ((i&3)==3) m_sprite_collision[i]|=0x20;
- if ((i&5)==5) m_sprite_collision[i]|=0x10;
- if ((i&9)==9) m_sprite_collision[i]|=8;
- if ((i&6)==6) m_sprite_collision[i]|=4;
- if ((i&0xa)==0xa) m_sprite_collision[i]|=2;
- if ((i&0xc)==0xc) m_sprite_collision[i]|=1;
- m_background_collision[i]=0;
- if ((i&0x11)==0x11) m_background_collision[i]|=0x80;
- if ((i&0x12)==0x12) m_background_collision[i]|=0x40;
- if ((i&0x14)==0x14) m_background_collision[i]|=0x20;
- if ((i&0x18)==0x18) m_background_collision[i]|=0x10;
+ m_sprite_collision[i] = 0;
+ if ((i & 0x3) == 0x3) m_sprite_collision[i] |= 0x20;
+ if ((i & 0x5) == 0x5) m_sprite_collision[i] |= 0x10;
+ if ((i & 0x9) == 0x9) m_sprite_collision[i] |= 0x08;
+ if ((i & 0x6) == 0x6) m_sprite_collision[i] |= 0x04;
+ if ((i & 0xa) == 0xa) m_sprite_collision[i] |= 0x02;
+ if ((i & 0xc) == 0xc) m_sprite_collision[i] |= 0x01;
+
+ m_background_collision[i] = 0;
+ if ((i & 0x11) == 0x11) m_background_collision[i] |= 0x80;
+ if ((i & 0x12) == 0x12) m_background_collision[i] |= 0x40;
+ if ((i & 0x14) == 0x14) m_background_collision[i] |= 0x20;
+ if ((i & 0x18) == 0x18) m_background_collision[i] |= 0x10;
}
m_joy1_x = STICKCENTRE;
@@ -50,8 +49,8 @@ void vc4000_state::video_start()
m_joy2_x = STICKCENTRE;
m_joy2_y = STICKCENTRE;
- memset(&m_video, 0, sizeof(m_video));
- for (i=0; i<3; i++)
+ m_video = vc4000_video_t();
+ for (int i = 0; i < std::size(m_video.reg.d.sprites); i++)
{
m_video.sprites[i].data = &m_video.reg.d.sprites[i];
m_video.sprites[i].mask = 1 << i;
@@ -59,7 +58,7 @@ void vc4000_state::video_start()
m_video.sprites[3].data = &m_video.reg.d.sprite4;
m_video.sprites[3].mask = 1 << 3;
- m_bitmap = std::make_unique<bitmap_ind16>(m_screen->width(), m_screen->height());
+ m_bitmap.allocate(m_screen->width(), m_screen->height());
}
inline uint8_t vc4000_state::vc4000_joystick_return_to_centre(uint8_t joy)
@@ -523,7 +522,7 @@ inline void vc4000_state::vc4000_draw_grid(uint8_t *collision)
if (m_video.line>=height) return;
- m_bitmap->plot_box(0, m_video.line, width, 1, (m_video.reg.d.background)&7);
+ m_bitmap.plot_box(0, m_video.line, width, 1, (m_video.reg.d.background)&7);
if (line<0 || line>=200) return;
if (~m_video.reg.d.background & 8) return;
@@ -564,7 +563,7 @@ inline void vc4000_state::vc4000_draw_grid(uint8_t *collision)
{
int l;
for (l=0; l<w; l++) collision[x+l]|=0x10;
- m_bitmap->plot_box(x, m_video.line, w, 1, (m_video.reg.d.background>>4)&7);
+ m_bitmap.plot_box(x, m_video.line, w, 1, (m_video.reg.d.background>>4)&7);
}
if (j==7) m=0x100;
}
@@ -602,10 +601,10 @@ INTERRUPT_GEN_MEMBER(vc4000_state::vc4000_video_line)
for (int i=visarea.min_x; i<visarea.max_x; i++) m_objects[i]=8;
/* calculate object colours and OR overlapping object colours */
- vc4000_sprite_update(*m_bitmap, collision, &m_video.sprites[0]);
- vc4000_sprite_update(*m_bitmap, collision, &m_video.sprites[1]);
- vc4000_sprite_update(*m_bitmap, collision, &m_video.sprites[2]);
- vc4000_sprite_update(*m_bitmap, collision, &m_video.sprites[3]);
+ vc4000_sprite_update(m_bitmap, collision, &m_video.sprites[0]);
+ vc4000_sprite_update(m_bitmap, collision, &m_video.sprites[1]);
+ vc4000_sprite_update(m_bitmap, collision, &m_video.sprites[2]);
+ vc4000_sprite_update(m_bitmap, collision, &m_video.sprites[3]);
for (int i=visarea.min_x; i<visarea.max_x; i++)
{
@@ -613,7 +612,7 @@ INTERRUPT_GEN_MEMBER(vc4000_state::vc4000_video_line)
m_video.background_collision|=m_background_collision[collision[i]];
/* display final object colours */
if (m_objects[i] < 8)
- m_bitmap->pix(m_video.line, i) = m_objects[i];
+ m_bitmap.pix(m_video.line, i) = m_objects[i];
}
int y = m_video.reg.d.score_control&1?200:20;
@@ -621,11 +620,11 @@ INTERRUPT_GEN_MEMBER(vc4000_state::vc4000_video_line)
if ((m_video.line>=y)&&(m_video.line<y+20))
{
int x = 60;
- vc4000_draw_digit(*m_bitmap, x, y, m_video.reg.d.bcd[0]>>4, m_video.line-y);
- vc4000_draw_digit(*m_bitmap, x+16, y, m_video.reg.d.bcd[0]&0xf, m_video.line-y);
+ vc4000_draw_digit(m_bitmap, x, y, m_video.reg.d.bcd[0]>>4, m_video.line-y);
+ vc4000_draw_digit(m_bitmap, x+16, y, m_video.reg.d.bcd[0]&0xf, m_video.line-y);
if (m_video.reg.d.score_control&2) x -= 16;
- vc4000_draw_digit(*m_bitmap, x+48, y, m_video.reg.d.bcd[1]>>4, m_video.line-y);
- vc4000_draw_digit(*m_bitmap, x+64, y, m_video.reg.d.bcd[1]&0xf, m_video.line-y);
+ vc4000_draw_digit(m_bitmap, x+48, y, m_video.reg.d.bcd[1]>>4, m_video.line-y);
+ vc4000_draw_digit(m_bitmap, x+64, y, m_video.reg.d.bcd[1]&0xf, m_video.line-y);
}
}
if (m_video.line==VC4000_END_LINE) m_video.reg.d.sprite_collision |=0x40;
@@ -643,6 +642,6 @@ INTERRUPT_GEN_MEMBER(vc4000_state::vc4000_video_line)
uint32_t vc4000_state::screen_update_vc4000(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
{
- copybitmap(bitmap, *m_bitmap, 0, 0, 0, 0, cliprect);
+ copybitmap(bitmap, m_bitmap, 0, 0, 0, 0, cliprect);
return 0;
}
diff --git a/src/mame/shared/exidysound.cpp b/src/mame/shared/exidysound.cpp
index 4bfea5e6463..311fa60dea4 100644
--- a/src/mame/shared/exidysound.cpp
+++ b/src/mame/shared/exidysound.cpp
@@ -5,17 +5,17 @@
Exidy 6502 hardware
TODO:
- - use ptm6840_device and pit8253_device
+ - use ptm6840_device
*************************************************************************/
#include "emu.h"
#include "exidysound.h"
+#include "cpu/m6502/m6502.h"
#include "cpu/z80/z80.h"
#include "machine/input_merger.h"
#include "machine/rescap.h"
-#include "cpu/m6502/m6502.h"
#include "speaker.h"
@@ -138,53 +138,10 @@ inline int exidy_sound_device::sh6840_update_noise(int clocks)
/*************************************
*
- * 6840 state saving
- *
- *************************************/
-
-void exidy_sound_device::sh6840_register_state_globals()
-{
- save_item(STRUCT_MEMBER(m_sh6840_timer, cr));
- save_item(STRUCT_MEMBER(m_sh6840_timer, state));
- save_item(STRUCT_MEMBER(m_sh6840_timer, leftovers));
- save_item(STRUCT_MEMBER(m_sh6840_timer, timer));
- save_item(STRUCT_MEMBER(m_sh6840_timer, clocks));
- save_item(NAME(m_sh6840_timer[0].counter.w));
- save_item(NAME(m_sh6840_timer[1].counter.w));
- save_item(NAME(m_sh6840_timer[2].counter.w));
-
- save_item(NAME(m_sh6840_volume));
- save_item(NAME(m_sh6840_MSB_latch));
- save_item(NAME(m_sh6840_LSB_latch));
- save_item(NAME(m_sh6840_LFSR_oldxor));
- save_item(NAME(m_sh6840_LFSR_0));
- save_item(NAME(m_sh6840_LFSR_1));
- save_item(NAME(m_sh6840_LFSR_2));
- save_item(NAME(m_sh6840_LFSR_3));
- save_item(NAME(m_sh6840_clock_count));
- save_item(NAME(m_sfxctrl));
-}
-
-
-
-/*************************************
- *
* Audio startup routines
*
*************************************/
-void exidy_sound_device::common_sh_start()
-{
- int sample_rate = SH8253_CLOCK.value();
-
- m_sh6840_clocks_per_sample = (int)(SH6840_CLOCK.dvalue() / (double)sample_rate * (double)(1 << 24));
-
- // allocate the stream
- m_stream = stream_alloc(0, 1, sample_rate);
-
- sh6840_register_state_globals();
-}
-
DEFINE_DEVICE_TYPE(EXIDY, exidy_sound_device, "exidy_sfx", "Exidy SFX")
exidy_sound_device::exidy_sound_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
@@ -196,7 +153,6 @@ exidy_sound_device::exidy_sound_device(const machine_config &mconfig, device_typ
: 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)
@@ -210,21 +166,77 @@ exidy_sound_device::exidy_sound_device(const machine_config &mconfig, device_typ
{
}
+exidy_sound_device::~exidy_sound_device()
+{
+}
+
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_pia(*this, "pia")
+ , m_pit(*this, "pit")
{
}
+void exidy_sh8253_sound_device::device_add_mconfig(machine_config &config)
+{
+ exidy_sound_device::device_add_mconfig(config);
+
+ MOS6532(config, m_riot, SH6532_CLOCK);
+ m_riot->irq_wr_callback().set("audioirq", FUNC(input_merger_device::in_w<0>));
+
+ PIA6821(config, m_pia);
+ m_pia->irqa_handler().set("audioirq", FUNC(input_merger_device::in_w<1>));
+
+ PIT8253(config, m_pit, SH6532_CLOCK);
+ m_pit->set_clk<0>(SH8253_CLOCK);
+ m_pit->set_clk<1>(SH8253_CLOCK);
+ m_pit->set_clk<2>(SH8253_CLOCK);
+ m_pit->out_handler<0>().set(FUNC(exidy_sh8253_sound_device::pit_out<0>));
+ m_pit->out_handler<1>().set(FUNC(exidy_sh8253_sound_device::pit_out<1>));
+ m_pit->out_handler<2>().set(FUNC(exidy_sh8253_sound_device::pit_out<2>));
+
+ INPUT_MERGER_ANY_HIGH(config, "audioirq").output_handler().set_inputline("audiocpu", m6502_device::IRQ_LINE); // open collector
+
+ SPEAKER(config, "mono").front_center();
+
+ this->add_route(ALL_OUTPUTS, "mono", 0.50);
+}
+
+
//-------------------------------------------------
// device_start - device-specific startup
//-------------------------------------------------
void exidy_sound_device::device_start()
{
- common_sh_start();
+ int sample_rate = SH8253_CLOCK.value();
+
+ m_sh6840_clocks_per_sample = int(SH6840_CLOCK.dvalue() / double(sample_rate) * double(1 << 24));
+
+ // allocate the stream
+ m_stream = stream_alloc(0, 1, sample_rate);
+
+ save_item(STRUCT_MEMBER(m_sh6840_timer, cr));
+ save_item(STRUCT_MEMBER(m_sh6840_timer, state));
+ save_item(STRUCT_MEMBER(m_sh6840_timer, leftovers));
+ save_item(STRUCT_MEMBER(m_sh6840_timer, timer));
+ save_item(STRUCT_MEMBER(m_sh6840_timer, clocks));
+ save_item(NAME(m_sh6840_timer[0].counter.w));
+ save_item(NAME(m_sh6840_timer[1].counter.w));
+ save_item(NAME(m_sh6840_timer[2].counter.w));
+
+ save_item(NAME(m_sh6840_volume));
+ save_item(NAME(m_sh6840_MSB_latch));
+ save_item(NAME(m_sh6840_LSB_latch));
+ save_item(NAME(m_sh6840_LFSR_oldxor));
+ save_item(NAME(m_sh6840_LFSR_0));
+ save_item(NAME(m_sh6840_LFSR_1));
+ save_item(NAME(m_sh6840_LFSR_2));
+ save_item(NAME(m_sh6840_LFSR_3));
+ save_item(NAME(m_sh6840_clock_count));
+ save_item(NAME(m_sfxctrl));
}
@@ -234,7 +246,30 @@ void exidy_sound_device::device_start()
void exidy_sound_device::device_reset()
{
- common_sh_reset();
+ // 6840
+ for (auto &channel : m_sh6840_timer)
+ {
+ channel.cr = 0;
+ channel.state = 0;
+ channel.leftovers = 0;
+ channel.timer = 0;
+ channel.clocks = 0;
+ channel.counter.w = 0;
+ }
+ m_sh6840_MSB_latch = 0;
+ m_sh6840_LSB_latch = 0;
+ m_sh6840_volume[0] = 0;
+ m_sh6840_volume[1] = 0;
+ m_sh6840_volume[2] = 0;
+ m_sh6840_clock_count = 0;
+ m_sfxctrl = 0;
+
+ // LFSR
+ 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;
}
@@ -317,36 +352,13 @@ void exidy_sound_device::sound_stream_update(sound_stream &stream, std::vector<r
s32 exidy_sh8253_sound_device::generate_music_sample()
{
- sh8253_timer_channel *c;
s32 sample = 0;
-
- // music channel 0
- c = &m_sh8253_timer[0];
- if (c->enable)
- {
- c->fraction += c->step;
- if (c->fraction & 0x0800000)
- sample += BASE_VOLUME;
- }
-
- // music channel 1
- c = &m_sh8253_timer[1];
- if (c->enable)
- {
- c->fraction += c->step;
- if (c->fraction & 0x0800000)
- sample += BASE_VOLUME;
- }
-
- // music channel 2
- c = &m_sh8253_timer[2];
- if (c->enable)
- {
- c->fraction += c->step;
- if (c->fraction & 0x0800000)
- sample += BASE_VOLUME;
- }
-
+ if (BIT(m_pit_out, 0))
+ sample += BASE_VOLUME;
+ if (BIT(m_pit_out, 1))
+ sample += BASE_VOLUME;
+ if (BIT(m_pit_out, 2))
+ sample += BASE_VOLUME;
return sample;
}
@@ -354,88 +366,24 @@ s32 exidy_sh8253_sound_device::generate_music_sample()
/*************************************
*
- * Audio reset routines
- *
- *************************************/
-
-void exidy_sound_device::common_sh_reset()
-{
- // 6840
- memset(m_sh6840_timer, 0, sizeof(m_sh6840_timer));
- m_sh6840_MSB_latch = 0;
- m_sh6840_LSB_latch = 0;
- m_sh6840_volume[0] = 0;
- m_sh6840_volume[1] = 0;
- m_sh6840_volume[2] = 0;
- m_sh6840_clock_count = 0;
- m_sfxctrl = 0;
-
- // LFSR
- 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;
-}
-
-
-
-/*************************************
- *
- * 8253 state saving
- *
- *************************************/
-
-void exidy_sh8253_sound_device::sh8253_register_state_globals()
-{
- save_item(STRUCT_MEMBER(m_sh8253_timer, clstate));
- save_item(STRUCT_MEMBER(m_sh8253_timer, enable));
- save_item(STRUCT_MEMBER(m_sh8253_timer, count));
- save_item(STRUCT_MEMBER(m_sh8253_timer, step));
- save_item(STRUCT_MEMBER(m_sh8253_timer, fraction));
-}
-
-
-
-/*************************************
- *
* 8253 timer handlers
*
*************************************/
void exidy_sh8253_sound_device::sh8253_w(offs_t offset, uint8_t data)
{
- int chan;
-
m_stream->update();
+ m_pit->write(offset, data);
+}
- switch (offset)
- {
- case 0:
- case 1:
- case 2:
- chan = offset;
- if (!m_sh8253_timer[chan].clstate)
- {
- m_sh8253_timer[chan].clstate = 1;
- m_sh8253_timer[chan].count = (m_sh8253_timer[chan].count & 0xff00) | (data & 0x00ff);
- }
- else
- {
- m_sh8253_timer[chan].clstate = 0;
- m_sh8253_timer[chan].count = (m_sh8253_timer[chan].count & 0x00ff) | ((data << 8) & 0xff00);
- if (m_sh8253_timer[chan].count)
- m_sh8253_timer[chan].step = m_freq_to_step * SH8253_CLOCK.dvalue() / m_sh8253_timer[chan].count;
- else
- m_sh8253_timer[chan].step = 0;
- }
- break;
-
- case 3:
- chan = (data & 0xc0) >> 6;
- m_sh8253_timer[chan].enable = ((data & 0x0e) != 0);
- break;
- }
+template <unsigned N>
+void exidy_sh8253_sound_device::pit_out(int state)
+{
+ m_stream->update();
+ if (state)
+ m_pit_out |= u8(1) << N;
+ else
+ m_pit_out &= ~(u8(1) << N);
}
@@ -586,24 +534,15 @@ venture_sound_device::venture_sound_device(const machine_config &mconfig, device
void exidy_sh8253_sound_device::device_start()
{
- common_sh_start();
-
- // 8253
- m_freq_to_step = (1 << 24) / SH8253_CLOCK;
- sh8253_register_state_globals();
-}
+ exidy_sound_device::device_start();
+ save_item(NAME(m_pit_out));
-//-------------------------------------------------
-// device_reset - device-specific reset
-//-------------------------------------------------
+ m_pit_out = 0;
-void exidy_sh8253_sound_device::device_reset()
-{
- common_sh_reset();
-
- // 8253
- memset(m_sh8253_timer, 0, sizeof(m_sh8253_timer));
+ m_pit->write_gate0(1);
+ m_pit->write_gate1(1);
+ m_pit->write_gate2(1);
}
@@ -641,24 +580,15 @@ void venture_sound_device::venture_audio_map(address_map &map)
void venture_sound_device::device_add_mconfig(machine_config &config)
{
+ exidy_sh8253_sound_device::device_add_mconfig(config);
+
m6502_device &audiocpu(M6502(config, "audiocpu", 3.579545_MHz_XTAL / 4));
audiocpu.set_addrmap(AS_PROGRAM, &venture_sound_device::venture_audio_map);
- MOS6532(config, m_riot, SH6532_CLOCK);
- m_riot->irq_wr_callback().set("audioirq", FUNC(input_merger_device::in_w<0>));
-
- PIA6821(config, m_pia);
m_pia->writepa_handler().set(FUNC(venture_sound_device::pia_pa_w));
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->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
-
- SPEAKER(config, "mono").front_center();
-
- this->add_route(ALL_OUTPUTS, "mono", 0.50);
}
@@ -690,11 +620,7 @@ mtrap_sound_device::mtrap_sound_device(const machine_config &mconfig, const char
void mtrap_sound_device::device_start()
{
- common_sh_start();
-
- // 8253
- m_freq_to_step = (1 << 24) / SH8253_CLOCK;
- sh8253_register_state_globals();
+ venture_sound_device::device_start();
save_item(NAME(m_cvsd_data));
save_item(NAME(m_cvsd_clk));
@@ -934,27 +860,20 @@ void victory_sound_device::victory_audio_map(address_map &map)
void victory_sound_device::device_add_mconfig(machine_config &config)
{
+ exidy_sh8253_sound_device::device_add_mconfig(config);
+
m6502_device &audiocpu(M6502(config, "audiocpu", 3.579545_MHz_XTAL / 4));
audiocpu.set_addrmap(AS_PROGRAM, &victory_sound_device::victory_audio_map);
- MOS6532(config, m_riot, SH6532_CLOCK);
m_riot->pa_wr_callback().set(m_tms, FUNC(tms5220_device::data_w));
m_riot->pa_rd_callback().set(m_tms, FUNC(tms5220_device::status_r));
m_riot->pb_wr_callback<0>().set(m_tms, FUNC(tms5220_device::rsq_w));
m_riot->pb_wr_callback<1>().set(m_tms, FUNC(tms5220_device::wsq_w));
m_riot->pb_rd_callback<2>().set(m_tms, FUNC(tms5220_device::readyq_r));
m_riot->pb_rd_callback<3>().set(m_tms, FUNC(tms5220_device::intq_r));
- m_riot->irq_wr_callback().set("audioirq", FUNC(input_merger_device::in_w<0>));
- PIA6821(config, m_pia);
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->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
-
- SPEAKER(config, "mono").front_center();
- this->add_route(ALL_OUTPUTS, "mono", 1.0);
TMS5220(config, m_tms, 640000).add_route(ALL_OUTPUTS, "mono", 1.0);
}
diff --git a/src/mame/shared/exidysound.h b/src/mame/shared/exidysound.h
index e7c74b0b7df..28fbcafadfd 100644
--- a/src/mame/shared/exidysound.h
+++ b/src/mame/shared/exidysound.h
@@ -7,6 +7,7 @@
#include "machine/6821pia.h"
#include "machine/mos6530.h"
+#include "machine/pit8253.h"
#include "machine/timer.h"
#include "sound/flt_biquad.h"
#include "sound/hc55516.h"
@@ -36,7 +37,7 @@ class exidy_sound_device : public device_t, public device_sound_interface
public:
exidy_sound_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
- ~exidy_sound_device() {}
+ ~exidy_sound_device();
uint8_t sh6840_r(offs_t offset);
void sh6840_w(offs_t offset, uint8_t data);
@@ -49,11 +50,6 @@ protected:
virtual void device_start() override ATTR_COLD;
virtual void device_reset() override ATTR_COLD;
- void common_sh_start();
- void common_sh_reset();
-
- void sh6840_register_state_globals();
-
// sound stream update overrides
virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override;
virtual s32 generate_music_sample() { return 0; }
@@ -62,7 +58,6 @@ protected:
// sound streaming variables
sound_stream *m_stream;
- double m_freq_to_step;
private:
// internal state
@@ -80,7 +75,7 @@ private:
uint8_t m_sfxctrl;
- inline int sh6840_update_noise(int clocks);
+ int sh6840_update_noise(int clocks);
};
DECLARE_DEVICE_TYPE(EXIDY, exidy_sound_device)
@@ -88,31 +83,25 @@ DECLARE_DEVICE_TYPE(EXIDY, exidy_sound_device)
class exidy_sh8253_sound_device : public exidy_sound_device
{
- struct sh8253_timer_channel
- {
- uint8_t clstate = 0;
- uint8_t enable = 0;
- uint16_t count = 0;
- uint32_t step = 0;
- uint32_t fraction = 0;
- };
-
protected:
exidy_sh8253_sound_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock);
// device_t implementation
+ virtual void device_add_mconfig(machine_config &config) override ATTR_COLD;
virtual void device_start() override ATTR_COLD;
- virtual void device_reset() override ATTR_COLD;
virtual s32 generate_music_sample() override;
void sh8253_w(offs_t offset, uint8_t data);
- void sh8253_register_state_globals();
-
- sh8253_timer_channel m_sh8253_timer[3];
required_device<mos6532_device> m_riot;
required_device<pia6821_device> m_pia;
+ required_device<pit8253_device> m_pit;
+
+private:
+ template <unsigned N> void pit_out(int state);
+
+ u8 m_pit_out;
};