summaryrefslogtreecommitdiffstatshomepage
path: root/src/mame/audio
diff options
context:
space:
mode:
author AJR <ajrhacker@users.noreply.github.com>2019-09-02 17:22:34 -0400
committer AJR <ajrhacker@users.noreply.github.com>2019-09-02 17:22:34 -0400
commit1c202190b48a57a3596b6832dd7030a5e02b55f3 (patch)
tree6a85e1d577c0ff745dc5b43623f4020113a99d34 /src/mame/audio
parentf3ce368aafe6be885f5d35e267c235791c1e4dff (diff)
n8080.cpp: Split up state class; simplify read/write handlers (nw)
Diffstat (limited to 'src/mame/audio')
-rw-r--r--src/mame/audio/n8080.cpp214
1 files changed, 96 insertions, 118 deletions
diff --git a/src/mame/audio/n8080.cpp b/src/mame/audio/n8080.cpp
index 9d135e89433..4d86d867692 100644
--- a/src/mame/audio/n8080.cpp
+++ b/src/mame/audio/n8080.cpp
@@ -16,7 +16,7 @@ constexpr double ATTACK_RATE = 10e-6 * 500;
constexpr double DECAY_RATE = 10e-6 * 16000;
-void n8080_state::spacefev_update_SN76477_status()
+void spacefev_state::update_SN76477_status()
{
double dblR0 = RES_M(1.0);
double dblR1 = RES_M(1.5);
@@ -45,7 +45,7 @@ void n8080_state::spacefev_update_SN76477_status()
}
-void n8080_state::sheriff_update_SN76477_status()
+void sheriff_state::update_SN76477_status()
{
if (m_mono_flop[1])
{
@@ -68,14 +68,6 @@ void n8080_state::sheriff_update_SN76477_status()
void n8080_state::update_SN76477_status()
{
- if (m_n8080_hardware == 1)
- {
- spacefev_update_SN76477_status();
- }
- if (m_n8080_hardware == 2)
- {
- sheriff_update_SN76477_status();
- }
}
@@ -105,7 +97,7 @@ TIMER_CALLBACK_MEMBER( n8080_state::stop_mono_flop_callback )
}
-void n8080_state::spacefev_sound_pins_changed()
+void spacefev_state::sound_pins_changed()
{
uint16_t changes = ~m_curr_sound_pins & m_prev_sound_pins;
@@ -135,7 +127,7 @@ void n8080_state::spacefev_sound_pins_changed()
}
-void n8080_state::sheriff_sound_pins_changed()
+void sheriff_state::sound_pins_changed()
{
uint16_t changes = ~m_curr_sound_pins & m_prev_sound_pins;
@@ -157,7 +149,7 @@ void n8080_state::sheriff_sound_pins_changed()
}
-void n8080_state::helifire_sound_pins_changed()
+void helifire_state::sound_pins_changed()
{
//uint16_t changes = ~m_curr_sound_pins & m_prev_sound_pins;
@@ -172,18 +164,10 @@ void n8080_state::helifire_sound_pins_changed()
void n8080_state::sound_pins_changed()
{
- if (m_n8080_hardware == 1)
- spacefev_sound_pins_changed();
- if (m_n8080_hardware == 2)
- sheriff_sound_pins_changed();
- if (m_n8080_hardware == 3)
- helifire_sound_pins_changed();
-
- m_prev_sound_pins = m_curr_sound_pins;
}
-void n8080_state::delayed_sound_1( int data )
+void n8080_state::delayed_sound_1(int data)
{
m_curr_sound_pins &= ~(
(1 << 0x7) |
@@ -200,21 +184,22 @@ void n8080_state::delayed_sound_1( int data )
if (~data & 0x10) m_curr_sound_pins |= 1 << 0x4; /* pulse (except in Helifire) */
if (~data & 0x20) m_curr_sound_pins |= 1 << 0x1;
- if (m_n8080_hardware == 1)
- {
- if (data & ~m_prev_snd_data & 0x10)
- {
- spacefev_start_red_cannon();
- }
-
- m_spacefev_red_screen = data & 0x08;
- }
-
sound_pins_changed();
+ m_prev_sound_pins = m_curr_sound_pins;
m_prev_snd_data = data;
}
+void spacefev_state::delayed_sound_1(int data)
+{
+ if (data & ~m_prev_snd_data & 0x10)
+ start_red_cannon();
+
+ m_red_screen = data & 0x08;
+
+ n8080_state::delayed_sound_1(data);
+}
+
TIMER_CALLBACK_MEMBER( n8080_state::delayed_sound_1_callback )
{
@@ -222,7 +207,7 @@ TIMER_CALLBACK_MEMBER( n8080_state::delayed_sound_1_callback )
}
-void n8080_state::delayed_sound_2( int data )
+void n8080_state::delayed_sound_2(int data)
{
m_curr_sound_pins &= ~(
(1 << 0x8) |
@@ -239,12 +224,23 @@ void n8080_state::delayed_sound_2( int data )
if (~data & 0x10) m_curr_sound_pins |= 1 << 0x2; /* pulse */
if (~data & 0x20) m_curr_sound_pins |= 1 << 0xc;
- if (m_n8080_hardware == 1)
- flip_screen_set(data & 0x20);
- if (m_n8080_hardware == 3)
- m_helifire_flash = data & 0x20;
-
sound_pins_changed();
+
+ m_prev_sound_pins = m_curr_sound_pins;
+}
+
+void spacefev_state::delayed_sound_2(int data)
+{
+ flip_screen_set(data & 0x20);
+
+ n8080_state::delayed_sound_2(data);
+}
+
+void helifire_state::delayed_sound_2(int data)
+{
+ m_flash = data & 0x20;
+
+ n8080_state::delayed_sound_2(data);
}
@@ -254,18 +250,18 @@ TIMER_CALLBACK_MEMBER( n8080_state::delayed_sound_2_callback )
}
-WRITE8_MEMBER(n8080_state::n8080_sound_1_w)
+void n8080_state::n8080_sound_1_w(uint8_t data)
{
machine().scheduler().synchronize(timer_expired_delegate(FUNC(n8080_state::delayed_sound_1_callback), this), data); /* force CPUs to sync */
}
-WRITE8_MEMBER(n8080_state::n8080_sound_2_w)
+void n8080_state::n8080_sound_2_w(uint8_t data)
{
machine().scheduler().synchronize(timer_expired_delegate(FUNC(n8080_state::delayed_sound_2_callback), this), data); /* force CPUs to sync */
}
-READ8_MEMBER(n8080_state::n8080_8035_p1_r)
+uint8_t n8080_state::n8080_8035_p1_r()
{
uint8_t val = 0;
@@ -292,17 +288,17 @@ READ_LINE_MEMBER(n8080_state::n8080_8035_t1_r)
}
-READ_LINE_MEMBER(n8080_state::helifire_8035_t0_r)
+READ_LINE_MEMBER(helifire_state::helifire_8035_t0_r)
{
return (m_curr_sound_pins >> 0x3) & 1;
}
-READ_LINE_MEMBER(n8080_state::helifire_8035_t1_r)
+READ_LINE_MEMBER(helifire_state::helifire_8035_t1_r)
{
return (m_curr_sound_pins >> 0x4) & 1;
}
-READ8_MEMBER(n8080_state::helifire_8035_external_ram_r)
+uint8_t helifire_state::helifire_8035_external_ram_r()
{
uint8_t val = 0;
@@ -315,39 +311,39 @@ READ8_MEMBER(n8080_state::helifire_8035_external_ram_r)
}
-READ8_MEMBER(n8080_state::helifire_8035_p2_r)
+uint8_t helifire_state::helifire_8035_p2_r()
{
return ((m_curr_sound_pins >> 0xc) & 1) ? 0x10 : 0x00; /* not used */
}
-WRITE8_MEMBER(n8080_state::n8080_dac_w)
+void n8080_state::n8080_dac_w(uint8_t data)
{
m_n8080_dac->write(BIT(data, 7));
}
-WRITE8_MEMBER(n8080_state::helifire_sound_ctrl_w)
+void helifire_state::sound_ctrl_w(uint8_t data)
{
- m_helifire_dac_phase = data & 0x80;
+ m_dac_phase = data & 0x80;
/* data & 0x40 not emulated */
/* data & 0x20 not emulated */
- if (m_helifire_dac_phase)
+ if (m_dac_phase)
{
- m_helifire_dac_timing = ATTACK_RATE * log(1 - m_helifire_dac_volume);
+ m_dac_timing = ATTACK_RATE * log(1 - m_dac_volume);
}
else
{
- m_helifire_dac_timing = DECAY_RATE * log(m_helifire_dac_volume);
+ m_dac_timing = DECAY_RATE * log(m_dac_volume);
}
- m_helifire_dac_timing += machine().time().as_double();
+ m_dac_timing += machine().time().as_double();
}
-TIMER_DEVICE_CALLBACK_MEMBER(n8080_state::spacefev_vco_voltage_timer)
+TIMER_DEVICE_CALLBACK_MEMBER(spacefev_state::vco_voltage_timer)
{
double voltage = 0;
@@ -360,40 +356,37 @@ TIMER_DEVICE_CALLBACK_MEMBER(n8080_state::spacefev_vco_voltage_timer)
}
-TIMER_DEVICE_CALLBACK_MEMBER(n8080_state::helifire_dac_volume_timer)
+TIMER_DEVICE_CALLBACK_MEMBER(helifire_state::dac_volume_timer)
{
- double t = m_helifire_dac_timing - machine().time().as_double();
+ double t = m_dac_timing - machine().time().as_double();
- if (m_helifire_dac_phase)
+ if (m_dac_phase)
{
- m_helifire_dac_volume = 1 - exp(t / ATTACK_RATE);
+ m_dac_volume = 1 - exp(t / ATTACK_RATE);
}
else
{
- m_helifire_dac_volume = exp(t / DECAY_RATE);
+ m_dac_volume = exp(t / DECAY_RATE);
}
- m_helifire_dac->set_output_gain(ALL_OUTPUTS, m_helifire_dac_volume);
+ m_dac->set_output_gain(ALL_OUTPUTS, m_dac_volume);
}
-SOUND_START_MEMBER(n8080_state,spacefev)
+void spacefev_state::sound_start()
{
- m_sound_timer[0] = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(n8080_state::stop_mono_flop_callback), this));
- m_sound_timer[1] = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(n8080_state::stop_mono_flop_callback), this));
- m_sound_timer[2] = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(n8080_state::stop_mono_flop_callback), this));
+ m_sound_timer[0] = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(spacefev_state::stop_mono_flop_callback), this));
+ m_sound_timer[1] = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(spacefev_state::stop_mono_flop_callback), this));
+ m_sound_timer[2] = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(spacefev_state::stop_mono_flop_callback), this));
save_item(NAME(m_prev_snd_data));
save_item(NAME(m_prev_sound_pins));
save_item(NAME(m_curr_sound_pins));
- save_item(NAME(m_n8080_hardware));
save_item(NAME(m_mono_flop));
}
-SOUND_RESET_MEMBER(n8080_state,spacefev)
+void spacefev_state::sound_reset()
{
- m_n8080_hardware = 1;
-
m_mono_flop[0] = 0;
m_mono_flop[1] = 0;
m_mono_flop[2] = 0;
@@ -406,22 +399,19 @@ SOUND_RESET_MEMBER(n8080_state,spacefev)
}
-SOUND_START_MEMBER(n8080_state,sheriff)
+void sheriff_state::sound_start()
{
- m_sound_timer[0] = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(n8080_state::stop_mono_flop_callback), this));
- m_sound_timer[1] = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(n8080_state::stop_mono_flop_callback), this));
+ m_sound_timer[0] = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(sheriff_state::stop_mono_flop_callback), this));
+ m_sound_timer[1] = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(sheriff_state::stop_mono_flop_callback), this));
save_item(NAME(m_prev_snd_data));
save_item(NAME(m_prev_sound_pins));
save_item(NAME(m_curr_sound_pins));
- save_item(NAME(m_n8080_hardware));
save_item(NAME(m_mono_flop));
}
-SOUND_RESET_MEMBER(n8080_state,sheriff)
+void sheriff_state::sound_reset()
{
- m_n8080_hardware = 2;
-
m_mono_flop[0] = 0;
m_mono_flop[1] = 0;
m_prev_snd_data = 0;
@@ -433,24 +423,21 @@ SOUND_RESET_MEMBER(n8080_state,sheriff)
}
-SOUND_START_MEMBER(n8080_state,helifire)
+void helifire_state::sound_start()
{
save_item(NAME(m_prev_snd_data));
save_item(NAME(m_prev_sound_pins));
save_item(NAME(m_curr_sound_pins));
- save_item(NAME(m_n8080_hardware));
- save_item(NAME(m_helifire_dac_volume));
- save_item(NAME(m_helifire_dac_timing));
- save_item(NAME(m_helifire_dac_phase));
+ save_item(NAME(m_dac_volume));
+ save_item(NAME(m_dac_timing));
+ save_item(NAME(m_dac_phase));
}
-SOUND_RESET_MEMBER(n8080_state,helifire)
+void helifire_state::sound_reset()
{
- m_n8080_hardware = 3;
-
- m_helifire_dac_volume = 1;
- m_helifire_dac_timing = 0;
- m_helifire_dac_phase = 0;
+ m_dac_volume = 1;
+ m_dac_timing = 0;
+ m_dac_phase = 0;
m_prev_snd_data = 0;
m_prev_sound_pins = 0;
m_curr_sound_pins = 0;
@@ -466,25 +453,22 @@ void n8080_state::n8080_sound_cpu_map(address_map &map)
map(0x0000, 0x03ff).rom();
}
-void n8080_state::helifire_sound_io_map(address_map &map)
+void helifire_state::sound_io_map(address_map &map)
{
- map(0x00, 0x7f).r(FUNC(n8080_state::helifire_8035_external_ram_r));
+ map(0x00, 0x00).mirror(0x7f).r(FUNC(helifire_state::helifire_8035_external_ram_r));
}
-void n8080_state::spacefev_sound(machine_config &config)
+void spacefev_state::spacefev_sound(machine_config &config)
{
- MCFG_SOUND_START_OVERRIDE(n8080_state,spacefev)
- MCFG_SOUND_RESET_OVERRIDE(n8080_state,spacefev)
-
/* basic machine hardware */
I8035(config, m_audiocpu, 6000000);
- m_audiocpu->set_addrmap(AS_PROGRAM, &n8080_state::n8080_sound_cpu_map);
- m_audiocpu->t0_in_cb().set(FUNC(n8080_state::n8080_8035_t0_r));
- m_audiocpu->t1_in_cb().set(FUNC(n8080_state::n8080_8035_t1_r));
- m_audiocpu->p1_in_cb().set(FUNC(n8080_state::n8080_8035_p1_r));
- m_audiocpu->p2_out_cb().set(FUNC(n8080_state::n8080_dac_w));
+ m_audiocpu->set_addrmap(AS_PROGRAM, &spacefev_state::n8080_sound_cpu_map);
+ m_audiocpu->t0_in_cb().set(FUNC(spacefev_state::n8080_8035_t0_r));
+ m_audiocpu->t1_in_cb().set(FUNC(spacefev_state::n8080_8035_t1_r));
+ m_audiocpu->p1_in_cb().set(FUNC(spacefev_state::n8080_8035_p1_r));
+ m_audiocpu->p2_out_cb().set(FUNC(spacefev_state::n8080_dac_w));
- TIMER(config, "vco_timer").configure_periodic(FUNC(n8080_state::spacefev_vco_voltage_timer), attotime::from_hz(1000));
+ TIMER(config, "vco_timer").configure_periodic(FUNC(spacefev_state::vco_voltage_timer), attotime::from_hz(1000));
/* sound hardware */
SPEAKER(config, "speaker").front_center();
@@ -510,18 +494,15 @@ void n8080_state::spacefev_sound(machine_config &config)
m_sn->add_route(ALL_OUTPUTS, "speaker", 0.35);
}
-void n8080_state::sheriff_sound(machine_config &config)
+void sheriff_state::sheriff_sound(machine_config &config)
{
- MCFG_SOUND_START_OVERRIDE(n8080_state,sheriff)
- MCFG_SOUND_RESET_OVERRIDE(n8080_state,sheriff)
-
/* basic machine hardware */
I8035(config, m_audiocpu, 6000000);
- m_audiocpu->set_addrmap(AS_PROGRAM, &n8080_state::n8080_sound_cpu_map);
- m_audiocpu->t0_in_cb().set(FUNC(n8080_state::n8080_8035_t0_r));
- m_audiocpu->t1_in_cb().set(FUNC(n8080_state::n8080_8035_t1_r));
- m_audiocpu->p1_in_cb().set(FUNC(n8080_state::n8080_8035_p1_r));
- m_audiocpu->p2_out_cb().set(FUNC(n8080_state::n8080_dac_w));
+ m_audiocpu->set_addrmap(AS_PROGRAM, &sheriff_state::n8080_sound_cpu_map);
+ m_audiocpu->t0_in_cb().set(FUNC(sheriff_state::n8080_8035_t0_r));
+ m_audiocpu->t1_in_cb().set(FUNC(sheriff_state::n8080_8035_t1_r));
+ m_audiocpu->p1_in_cb().set(FUNC(sheriff_state::n8080_8035_p1_r));
+ m_audiocpu->p2_out_cb().set(FUNC(sheriff_state::n8080_dac_w));
/* sound hardware */
SPEAKER(config, "speaker").front_center();
@@ -547,26 +528,23 @@ void n8080_state::sheriff_sound(machine_config &config)
m_sn->add_route(ALL_OUTPUTS, "speaker", 0.35);
}
-void n8080_state::helifire_sound(machine_config &config)
+void helifire_state::helifire_sound(machine_config &config)
{
- MCFG_SOUND_START_OVERRIDE(n8080_state,helifire)
- MCFG_SOUND_RESET_OVERRIDE(n8080_state,helifire)
-
/* basic machine hardware */
I8035(config, m_audiocpu, 6000000);
- m_audiocpu->set_addrmap(AS_PROGRAM, &n8080_state::n8080_sound_cpu_map);
- m_audiocpu->set_addrmap(AS_IO, &n8080_state::helifire_sound_io_map);
- m_audiocpu->t0_in_cb().set(FUNC(n8080_state::helifire_8035_t0_r));
- m_audiocpu->t1_in_cb().set(FUNC(n8080_state::helifire_8035_t1_r));
- m_audiocpu->p2_in_cb().set(FUNC(n8080_state::helifire_8035_p2_r));
+ m_audiocpu->set_addrmap(AS_PROGRAM, &helifire_state::n8080_sound_cpu_map);
+ m_audiocpu->set_addrmap(AS_IO, &helifire_state::sound_io_map);
+ m_audiocpu->t0_in_cb().set(FUNC(helifire_state::helifire_8035_t0_r));
+ m_audiocpu->t1_in_cb().set(FUNC(helifire_state::helifire_8035_t1_r));
+ m_audiocpu->p2_in_cb().set(FUNC(helifire_state::helifire_8035_p2_r));
m_audiocpu->p1_out_cb().set("helifire_dac", FUNC(dac_byte_interface::data_w));
- m_audiocpu->p2_out_cb().set(FUNC(n8080_state::helifire_sound_ctrl_w));
+ m_audiocpu->p2_out_cb().set(FUNC(helifire_state::sound_ctrl_w));
- TIMER(config, "helifire_dac_volume_timer").configure_periodic(FUNC(n8080_state::helifire_dac_volume_timer), attotime::from_hz(1000));
+ TIMER(config, "helifire_dac_volume_timer").configure_periodic(FUNC(helifire_state::dac_volume_timer), attotime::from_hz(1000));
/* sound hardware */
SPEAKER(config, "speaker").front_center();
- DAC_8BIT_R2R(config, m_helifire_dac, 0).add_route(ALL_OUTPUTS, "speaker", 0.15); // unknown DAC
+ DAC_8BIT_R2R(config, m_dac, 0).add_route(ALL_OUTPUTS, "speaker", 0.15); // unknown DAC
voltage_regulator_device &vref(VOLTAGE_REGULATOR(config, "vref", 0));
vref.add_route(0, "helifire_dac", 1.0, DAC_VREF_POS_INPUT);
vref.add_route(0, "helifire_dac", -1.0, DAC_VREF_NEG_INPUT);