n8080.cpp: Split up state class; simplify read/write handlers (nw)

This commit is contained in:
AJR 2019-09-02 17:22:34 -04:00
parent f3ce368aaf
commit 1c202190b4
4 changed files with 338 additions and 318 deletions

View File

@ -16,7 +16,7 @@ constexpr double ATTACK_RATE = 10e-6 * 500;
constexpr double DECAY_RATE = 10e-6 * 16000; 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 dblR0 = RES_M(1.0);
double dblR1 = RES_M(1.5); 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]) if (m_mono_flop[1])
{ {
@ -68,14 +68,6 @@ void n8080_state::sheriff_update_SN76477_status()
void n8080_state::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; 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; 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; //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() 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 &= ~( m_curr_sound_pins &= ~(
(1 << 0x7) | (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 & 0x10) m_curr_sound_pins |= 1 << 0x4; /* pulse (except in Helifire) */
if (~data & 0x20) m_curr_sound_pins |= 1 << 0x1; 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(); sound_pins_changed();
m_prev_sound_pins = m_curr_sound_pins;
m_prev_snd_data = data; 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 ) 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 &= ~( m_curr_sound_pins &= ~(
(1 << 0x8) | (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 & 0x10) m_curr_sound_pins |= 1 << 0x2; /* pulse */
if (~data & 0x20) m_curr_sound_pins |= 1 << 0xc; 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(); 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 */ 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 */ 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; 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; 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; 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; 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 */ 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)); 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 & 0x40 not emulated */
/* data & 0x20 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 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; 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 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[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(n8080_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(n8080_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_snd_data));
save_item(NAME(m_prev_sound_pins)); save_item(NAME(m_prev_sound_pins));
save_item(NAME(m_curr_sound_pins)); save_item(NAME(m_curr_sound_pins));
save_item(NAME(m_n8080_hardware));
save_item(NAME(m_mono_flop)); 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[0] = 0;
m_mono_flop[1] = 0; m_mono_flop[1] = 0;
m_mono_flop[2] = 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[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(n8080_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_snd_data));
save_item(NAME(m_prev_sound_pins)); save_item(NAME(m_prev_sound_pins));
save_item(NAME(m_curr_sound_pins)); save_item(NAME(m_curr_sound_pins));
save_item(NAME(m_n8080_hardware));
save_item(NAME(m_mono_flop)); 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[0] = 0;
m_mono_flop[1] = 0; m_mono_flop[1] = 0;
m_prev_snd_data = 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_snd_data));
save_item(NAME(m_prev_sound_pins)); save_item(NAME(m_prev_sound_pins));
save_item(NAME(m_curr_sound_pins)); save_item(NAME(m_curr_sound_pins));
save_item(NAME(m_n8080_hardware)); save_item(NAME(m_dac_volume));
save_item(NAME(m_helifire_dac_volume)); save_item(NAME(m_dac_timing));
save_item(NAME(m_helifire_dac_timing)); save_item(NAME(m_dac_phase));
save_item(NAME(m_helifire_dac_phase));
} }
SOUND_RESET_MEMBER(n8080_state,helifire) void helifire_state::sound_reset()
{ {
m_n8080_hardware = 3; m_dac_volume = 1;
m_dac_timing = 0;
m_helifire_dac_volume = 1; m_dac_phase = 0;
m_helifire_dac_timing = 0;
m_helifire_dac_phase = 0;
m_prev_snd_data = 0; m_prev_snd_data = 0;
m_prev_sound_pins = 0; m_prev_sound_pins = 0;
m_curr_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(); 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 */ /* basic machine hardware */
I8035(config, m_audiocpu, 6000000); I8035(config, m_audiocpu, 6000000);
m_audiocpu->set_addrmap(AS_PROGRAM, &n8080_state::n8080_sound_cpu_map); m_audiocpu->set_addrmap(AS_PROGRAM, &spacefev_state::n8080_sound_cpu_map);
m_audiocpu->t0_in_cb().set(FUNC(n8080_state::n8080_8035_t0_r)); m_audiocpu->t0_in_cb().set(FUNC(spacefev_state::n8080_8035_t0_r));
m_audiocpu->t1_in_cb().set(FUNC(n8080_state::n8080_8035_t1_r)); m_audiocpu->t1_in_cb().set(FUNC(spacefev_state::n8080_8035_t1_r));
m_audiocpu->p1_in_cb().set(FUNC(n8080_state::n8080_8035_p1_r)); m_audiocpu->p1_in_cb().set(FUNC(spacefev_state::n8080_8035_p1_r));
m_audiocpu->p2_out_cb().set(FUNC(n8080_state::n8080_dac_w)); 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 */ /* sound hardware */
SPEAKER(config, "speaker").front_center(); 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); 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 */ /* basic machine hardware */
I8035(config, m_audiocpu, 6000000); I8035(config, m_audiocpu, 6000000);
m_audiocpu->set_addrmap(AS_PROGRAM, &n8080_state::n8080_sound_cpu_map); m_audiocpu->set_addrmap(AS_PROGRAM, &sheriff_state::n8080_sound_cpu_map);
m_audiocpu->t0_in_cb().set(FUNC(n8080_state::n8080_8035_t0_r)); m_audiocpu->t0_in_cb().set(FUNC(sheriff_state::n8080_8035_t0_r));
m_audiocpu->t1_in_cb().set(FUNC(n8080_state::n8080_8035_t1_r)); m_audiocpu->t1_in_cb().set(FUNC(sheriff_state::n8080_8035_t1_r));
m_audiocpu->p1_in_cb().set(FUNC(n8080_state::n8080_8035_p1_r)); m_audiocpu->p1_in_cb().set(FUNC(sheriff_state::n8080_8035_p1_r));
m_audiocpu->p2_out_cb().set(FUNC(n8080_state::n8080_dac_w)); m_audiocpu->p2_out_cb().set(FUNC(sheriff_state::n8080_dac_w));
/* sound hardware */ /* sound hardware */
SPEAKER(config, "speaker").front_center(); 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); 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 */ /* basic machine hardware */
I8035(config, m_audiocpu, 6000000); I8035(config, m_audiocpu, 6000000);
m_audiocpu->set_addrmap(AS_PROGRAM, &n8080_state::n8080_sound_cpu_map); m_audiocpu->set_addrmap(AS_PROGRAM, &helifire_state::n8080_sound_cpu_map);
m_audiocpu->set_addrmap(AS_IO, &n8080_state::helifire_sound_io_map); m_audiocpu->set_addrmap(AS_IO, &helifire_state::sound_io_map);
m_audiocpu->t0_in_cb().set(FUNC(n8080_state::helifire_8035_t0_r)); m_audiocpu->t0_in_cb().set(FUNC(helifire_state::helifire_8035_t0_r));
m_audiocpu->t1_in_cb().set(FUNC(n8080_state::helifire_8035_t1_r)); m_audiocpu->t1_in_cb().set(FUNC(helifire_state::helifire_8035_t1_r));
m_audiocpu->p2_in_cb().set(FUNC(n8080_state::helifire_8035_p2_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->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 */ /* sound hardware */
SPEAKER(config, "speaker").front_center(); 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)); 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_POS_INPUT);
vref.add_route(0, "helifire_dac", -1.0, DAC_VREF_NEG_INPUT); vref.add_route(0, "helifire_dac", -1.0, DAC_VREF_NEG_INPUT);

View File

@ -18,17 +18,18 @@
#define MASTER_CLOCK XTAL(20'160'000) #define MASTER_CLOCK XTAL(20'160'000)
WRITE8_MEMBER(n8080_state::n8080_shift_bits_w) void n8080_state::n8080_shift_bits_w(uint8_t data)
{ {
m_shift_bits = data & 7; m_shift_bits = data & 7;
} }
WRITE8_MEMBER(n8080_state::n8080_shift_data_w)
void n8080_state::n8080_shift_data_w(uint8_t data)
{ {
m_shift_data = (m_shift_data >> 8) | (data << 8); m_shift_data = (m_shift_data >> 8) | (data << 8);
} }
READ8_MEMBER(n8080_state::n8080_shift_r) uint8_t n8080_state::n8080_shift_r()
{ {
return m_shift_data >> (8 - m_shift_bits); return m_shift_data >> (8 - m_shift_bits);
} }
@ -41,7 +42,7 @@ void n8080_state::main_cpu_map(address_map &map)
} }
void n8080_state::helifire_main_cpu_map(address_map &map) void helifire_state::main_cpu_map(address_map &map)
{ {
map(0x0000, 0x3fff).rom(); map(0x0000, 0x3fff).rom();
map(0x4000, 0x7fff).ram().share("videoram"); map(0x4000, 0x7fff).ram().share("videoram");
@ -453,7 +454,7 @@ WRITE_LINE_MEMBER(n8080_state::n8080_inte_callback)
m_inte = state; m_inte = state;
} }
WRITE8_MEMBER(n8080_state::n8080_status_callback) void n8080_state::n8080_status_callback(uint8_t data)
{ {
if (data & i8080_cpu_device::STATUS_INTA) if (data & i8080_cpu_device::STATUS_INTA)
{ {
@ -469,138 +470,126 @@ void n8080_state::machine_start()
save_item(NAME(m_inte)); save_item(NAME(m_inte));
} }
MACHINE_RESET_MEMBER(n8080_state,n8080) void n8080_state::machine_reset()
{ {
m_shift_data = 0; m_shift_data = 0;
m_shift_bits = 0; m_shift_bits = 0;
m_inte = 0; m_inte = 0;
} }
MACHINE_RESET_MEMBER(n8080_state,spacefev) void spacefev_state::machine_reset()
{ {
MACHINE_RESET_CALL_MEMBER(n8080); n8080_state::machine_reset();
m_spacefev_red_screen = 0; m_red_screen = 0;
m_spacefev_red_cannon = 0; m_red_cannon = 0;
} }
MACHINE_RESET_MEMBER(n8080_state,sheriff) void sheriff_state::machine_reset()
{ {
MACHINE_RESET_CALL_MEMBER(n8080); n8080_state::machine_reset();
m_sheriff_color_mode = 0; m_sheriff_color_mode = 0;
m_sheriff_color_data = 0; m_sheriff_color_data = 0;
} }
MACHINE_RESET_MEMBER(n8080_state,helifire) void helifire_state::machine_reset()
{ {
MACHINE_RESET_CALL_MEMBER(n8080); n8080_state::machine_reset();
m_helifire_mv = 0; m_mv = 0;
m_helifire_sc = 0; m_sc = 0;
m_helifire_flash = 0; m_flash = 0;
} }
void n8080_state::spacefev(machine_config &config) void spacefev_state::spacefev(machine_config &config)
{ {
/* basic machine hardware */ /* basic machine hardware */
I8080(config, m_maincpu, MASTER_CLOCK / 10); I8080(config, m_maincpu, MASTER_CLOCK / 10);
m_maincpu->out_status_func().set(FUNC(n8080_state::n8080_status_callback)); m_maincpu->out_status_func().set(FUNC(spacefev_state::n8080_status_callback));
m_maincpu->out_inte_func().set(FUNC(n8080_state::n8080_inte_callback)); m_maincpu->out_inte_func().set(FUNC(spacefev_state::n8080_inte_callback));
m_maincpu->set_addrmap(AS_PROGRAM, &n8080_state::main_cpu_map); m_maincpu->set_addrmap(AS_PROGRAM, &spacefev_state::main_cpu_map);
m_maincpu->set_addrmap(AS_IO, &n8080_state::main_io_map); m_maincpu->set_addrmap(AS_IO, &spacefev_state::main_io_map);
MCFG_MACHINE_RESET_OVERRIDE(n8080_state,spacefev)
/* video hardware */ /* video hardware */
SCREEN(config, m_screen, SCREEN_TYPE_RASTER); SCREEN(config, m_screen, SCREEN_TYPE_RASTER);
m_screen->set_refresh_hz(60); m_screen->set_refresh_hz(60);
m_screen->set_size(256, 256); m_screen->set_size(256, 256);
m_screen->set_visarea(0, 255, 16, 239); m_screen->set_visarea(0, 255, 16, 239);
m_screen->set_screen_update(FUNC(n8080_state::screen_update_spacefev)); m_screen->set_screen_update(FUNC(spacefev_state::screen_update));
m_screen->set_palette(m_palette); m_screen->set_palette(m_palette);
PALETTE(config, m_palette, FUNC(n8080_state::n8080_palette), 8); PALETTE(config, m_palette, FUNC(spacefev_state::n8080_palette), 8);
MCFG_VIDEO_START_OVERRIDE(n8080_state,spacefev) TIMER(config, "rst1").configure_scanline(FUNC(spacefev_state::rst1_tick), "screen", 128, 256);
TIMER(config, "rst2").configure_scanline(FUNC(spacefev_state::rst2_tick), "screen", 240, 256);
TIMER(config, "rst1").configure_scanline(FUNC(n8080_state::rst1_tick), "screen", 128, 256);
TIMER(config, "rst2").configure_scanline(FUNC(n8080_state::rst2_tick), "screen", 240, 256);
/* sound hardware */ /* sound hardware */
spacefev_sound(config); spacefev_sound(config);
} }
void n8080_state::sheriff(machine_config &config) void sheriff_state::sheriff(machine_config &config)
{ {
/* basic machine hardware */ /* basic machine hardware */
I8080(config, m_maincpu, MASTER_CLOCK / 10); I8080(config, m_maincpu, MASTER_CLOCK / 10);
m_maincpu->out_status_func().set(FUNC(n8080_state::n8080_status_callback)); m_maincpu->out_status_func().set(FUNC(sheriff_state::n8080_status_callback));
m_maincpu->out_inte_func().set(FUNC(n8080_state::n8080_inte_callback)); m_maincpu->out_inte_func().set(FUNC(sheriff_state::n8080_inte_callback));
m_maincpu->set_addrmap(AS_PROGRAM, &n8080_state::main_cpu_map); m_maincpu->set_addrmap(AS_PROGRAM, &sheriff_state::main_cpu_map);
m_maincpu->set_addrmap(AS_IO, &n8080_state::main_io_map); m_maincpu->set_addrmap(AS_IO, &sheriff_state::main_io_map);
MCFG_MACHINE_RESET_OVERRIDE(n8080_state,sheriff)
/* video hardware */ /* video hardware */
SCREEN(config, m_screen, SCREEN_TYPE_RASTER); SCREEN(config, m_screen, SCREEN_TYPE_RASTER);
m_screen->set_refresh_hz(60); m_screen->set_refresh_hz(60);
m_screen->set_size(256, 256); m_screen->set_size(256, 256);
m_screen->set_visarea(0, 255, 16, 239); m_screen->set_visarea(0, 255, 16, 239);
m_screen->set_screen_update(FUNC(n8080_state::screen_update_sheriff)); m_screen->set_screen_update(FUNC(sheriff_state::screen_update));
m_screen->set_palette(m_palette); m_screen->set_palette(m_palette);
PALETTE(config, m_palette, FUNC(n8080_state::n8080_palette), 8); PALETTE(config, m_palette, FUNC(sheriff_state::n8080_palette), 8);
MCFG_VIDEO_START_OVERRIDE(n8080_state,sheriff) TIMER(config, "rst1").configure_scanline(FUNC(sheriff_state::rst1_tick), "screen", 128, 256);
TIMER(config, "rst2").configure_scanline(FUNC(sheriff_state::rst2_tick), "screen", 240, 256);
TIMER(config, "rst1").configure_scanline(FUNC(n8080_state::rst1_tick), "screen", 128, 256);
TIMER(config, "rst2").configure_scanline(FUNC(n8080_state::rst2_tick), "screen", 240, 256);
/* sound hardware */ /* sound hardware */
sheriff_sound(config); sheriff_sound(config);
} }
void n8080_state::westgun2(machine_config &config) void sheriff_state::westgun2(machine_config &config)
{ {
sheriff(config); sheriff(config);
/* basic machine hardware */ /* basic machine hardware */
I8080(config.replace(), m_maincpu, XTAL(19'968'000) / 10); I8080(config.replace(), m_maincpu, XTAL(19'968'000) / 10);
m_maincpu->out_status_func().set(FUNC(n8080_state::n8080_status_callback)); m_maincpu->out_status_func().set(FUNC(sheriff_state::n8080_status_callback));
m_maincpu->out_inte_func().set(FUNC(n8080_state::n8080_inte_callback)); m_maincpu->out_inte_func().set(FUNC(sheriff_state::n8080_inte_callback));
m_maincpu->set_addrmap(AS_PROGRAM, &n8080_state::main_cpu_map); m_maincpu->set_addrmap(AS_PROGRAM, &sheriff_state::main_cpu_map);
m_maincpu->set_addrmap(AS_IO, &n8080_state::main_io_map); m_maincpu->set_addrmap(AS_IO, &sheriff_state::main_io_map);
} }
void n8080_state::helifire(machine_config &config) void helifire_state::helifire(machine_config &config)
{ {
/* basic machine hardware */ /* basic machine hardware */
I8080(config, m_maincpu, MASTER_CLOCK / 10); I8080(config, m_maincpu, MASTER_CLOCK / 10);
m_maincpu->out_status_func().set(FUNC(n8080_state::n8080_status_callback)); m_maincpu->out_status_func().set(FUNC(helifire_state::n8080_status_callback));
m_maincpu->out_inte_func().set(FUNC(n8080_state::n8080_inte_callback)); m_maincpu->out_inte_func().set(FUNC(helifire_state::n8080_inte_callback));
m_maincpu->set_addrmap(AS_PROGRAM, &n8080_state::helifire_main_cpu_map); m_maincpu->set_addrmap(AS_PROGRAM, &helifire_state::main_cpu_map);
m_maincpu->set_addrmap(AS_IO, &n8080_state::main_io_map); m_maincpu->set_addrmap(AS_IO, &helifire_state::main_io_map);
MCFG_MACHINE_RESET_OVERRIDE(n8080_state,helifire)
/* video hardware */ /* video hardware */
SCREEN(config, m_screen, SCREEN_TYPE_RASTER); SCREEN(config, m_screen, SCREEN_TYPE_RASTER);
m_screen->set_refresh_hz(60); m_screen->set_refresh_hz(60);
m_screen->set_size(256, 256); m_screen->set_size(256, 256);
m_screen->set_visarea(0, 255, 16, 239); m_screen->set_visarea(0, 255, 16, 239);
m_screen->set_screen_update(FUNC(n8080_state::screen_update_helifire)); m_screen->set_screen_update(FUNC(helifire_state::screen_update));
m_screen->screen_vblank().set(FUNC(n8080_state::screen_vblank_helifire)); m_screen->screen_vblank().set(FUNC(helifire_state::screen_vblank));
m_screen->set_palette(m_palette); m_screen->set_palette(m_palette);
PALETTE(config, m_palette, FUNC(n8080_state::helifire_palette), 8 + 0x400); PALETTE(config, m_palette, FUNC(helifire_state::helifire_palette), 8 + 0x400);
MCFG_VIDEO_START_OVERRIDE(n8080_state,helifire) TIMER(config, "rst1").configure_scanline(FUNC(helifire_state::rst1_tick), "screen", 128, 256);
TIMER(config, "rst2").configure_scanline(FUNC(helifire_state::rst2_tick), "screen", 240, 256);
TIMER(config, "rst1").configure_scanline(FUNC(n8080_state::rst1_tick), "screen", 128, 256);
TIMER(config, "rst2").configure_scanline(FUNC(n8080_state::rst2_tick), "screen", 240, 256);
/* sound hardware */ /* sound hardware */
helifire_sound(config); helifire_sound(config);
@ -933,15 +922,15 @@ ROM_START( helifirea )
ROM_END ROM_END
GAME( 1979, spacefev, 0, spacefev, spacefev, n8080_state, empty_init, ROT270, "Nintendo", "Space Fever (New Ver.)", MACHINE_SUPPORTS_SAVE ) GAME( 1979, spacefev, 0, spacefev, spacefev, spacefev_state, empty_init, ROT270, "Nintendo", "Space Fever (New Ver.)", MACHINE_SUPPORTS_SAVE )
GAME( 1979, spacefevo, spacefev, spacefev, spacefev, n8080_state, empty_init, ROT270, "Nintendo", "Space Fever (Old Ver.)", MACHINE_SUPPORTS_SAVE ) GAME( 1979, spacefevo, spacefev, spacefev, spacefev, spacefev_state, empty_init, ROT270, "Nintendo", "Space Fever (Old Ver.)", MACHINE_SUPPORTS_SAVE )
GAME( 1979, spacefevo2, spacefev, spacefev, spacefev, n8080_state, empty_init, ROT270, "Nintendo", "Space Fever (Older Ver.)", MACHINE_SUPPORTS_SAVE ) GAME( 1979, spacefevo2, spacefev, spacefev, spacefev, spacefev_state, empty_init, ROT270, "Nintendo", "Space Fever (Older Ver.)", MACHINE_SUPPORTS_SAVE )
GAME( 1979, highsplt, 0, spacefev, highsplt, n8080_state, empty_init, ROT270, "Nintendo", "Space Fever High Splitter (set 1)", MACHINE_SUPPORTS_SAVE ) // known as "SF-Hisplitter" on its flyer GAME( 1979, highsplt, 0, spacefev, highsplt, spacefev_state, empty_init, ROT270, "Nintendo", "Space Fever High Splitter (set 1)", MACHINE_SUPPORTS_SAVE ) // known as "SF-Hisplitter" on its flyer
GAME( 1979, highsplta, highsplt, spacefev, highsplt, n8080_state, empty_init, ROT270, "Nintendo", "Space Fever High Splitter (set 2)", MACHINE_SUPPORTS_SAVE ) // known as "SF-Hisplitter" on its flyer GAME( 1979, highsplta, highsplt, spacefev, highsplt, spacefev_state, empty_init, ROT270, "Nintendo", "Space Fever High Splitter (set 2)", MACHINE_SUPPORTS_SAVE ) // known as "SF-Hisplitter" on its flyer
GAME( 1979, highspltb, highsplt, spacefev, highsplt, n8080_state, empty_init, ROT270, "Nintendo", "Space Fever High Splitter (alt Sound)", MACHINE_SUPPORTS_SAVE ) // known as "SF-Hisplitter" on its flyer GAME( 1979, highspltb, highsplt, spacefev, highsplt, spacefev_state, empty_init, ROT270, "Nintendo", "Space Fever High Splitter (alt Sound)", MACHINE_SUPPORTS_SAVE ) // known as "SF-Hisplitter" on its flyer
GAME( 1979, spacelnc, 0, spacefev, spacelnc, n8080_state, empty_init, ROT270, "Nintendo", "Space Launcher", MACHINE_SUPPORTS_SAVE ) GAME( 1979, spacelnc, 0, spacefev, spacelnc, spacefev_state, empty_init, ROT270, "Nintendo", "Space Launcher", MACHINE_SUPPORTS_SAVE )
GAME( 1979, sheriff, 0, sheriff, sheriff, n8080_state, empty_init, ROT270, "Nintendo", "Sheriff", MACHINE_SUPPORTS_SAVE ) GAME( 1979, sheriff, 0, sheriff, sheriff, sheriff_state, empty_init, ROT270, "Nintendo", "Sheriff", MACHINE_SUPPORTS_SAVE )
GAME( 1980, bandido, sheriff, sheriff, bandido, n8080_state, empty_init, ROT270, "Nintendo (Exidy license)", "Bandido", MACHINE_SUPPORTS_SAVE ) GAME( 1980, bandido, sheriff, sheriff, bandido, sheriff_state, empty_init, ROT270, "Nintendo (Exidy license)", "Bandido", MACHINE_SUPPORTS_SAVE )
GAME( 1980, westgun2, sheriff, westgun2, westgun2, n8080_state, empty_init, ROT270, "Nintendo (Taito Corporation license)", "Western Gun Part II", MACHINE_SUPPORTS_SAVE ) // official Taito PCBs, but title/copyright not shown GAME( 1980, westgun2, sheriff, westgun2, westgun2, sheriff_state, empty_init, ROT270, "Nintendo (Taito Corporation license)", "Western Gun Part II", MACHINE_SUPPORTS_SAVE ) // official Taito PCBs, but title/copyright not shown
GAME( 1980, helifire, 0, helifire, helifire, n8080_state, empty_init, ROT270, "Nintendo", "HeliFire (set 1)", MACHINE_IMPERFECT_SOUND | MACHINE_IMPERFECT_GRAPHICS | MACHINE_NO_COCKTAIL | MACHINE_SUPPORTS_SAVE ) GAME( 1980, helifire, 0, helifire, helifire, helifire_state, empty_init, ROT270, "Nintendo", "HeliFire (set 1)", MACHINE_IMPERFECT_SOUND | MACHINE_IMPERFECT_GRAPHICS | MACHINE_NO_COCKTAIL | MACHINE_SUPPORTS_SAVE )
GAME( 1980, helifirea, helifire, helifire, helifire, n8080_state, empty_init, ROT270, "Nintendo", "HeliFire (set 2)", MACHINE_IMPERFECT_SOUND | MACHINE_IMPERFECT_GRAPHICS | MACHINE_NO_COCKTAIL | MACHINE_SUPPORTS_SAVE ) GAME( 1980, helifirea, helifire, helifire, helifire, helifire_state, empty_init, ROT270, "Nintendo", "HeliFire (set 2)", MACHINE_IMPERFECT_SOUND | MACHINE_IMPERFECT_GRAPHICS | MACHINE_NO_COCKTAIL | MACHINE_SUPPORTS_SAVE )

View File

@ -19,49 +19,33 @@ public:
n8080_state(const machine_config &mconfig, device_type type, const char *tag) : n8080_state(const machine_config &mconfig, device_type type, const char *tag) :
driver_device(mconfig, type, tag), driver_device(mconfig, type, tag),
m_videoram(*this, "videoram"), m_videoram(*this, "videoram"),
m_colorram(*this, "colorram"),
m_maincpu(*this, "maincpu"), m_maincpu(*this, "maincpu"),
m_audiocpu(*this, "audiocpu"), m_audiocpu(*this, "audiocpu"),
m_n8080_dac(*this, "n8080_dac"), m_n8080_dac(*this, "n8080_dac"),
m_helifire_dac(*this, "helifire_dac"),
m_sn(*this, "snsnd"), m_sn(*this, "snsnd"),
m_screen(*this, "screen"), m_screen(*this, "screen"),
m_palette(*this, "palette") m_palette(*this, "palette")
{ } { }
void sheriff(machine_config &config);
void sheriff_sound(machine_config &config);
void westgun2(machine_config &config);
void helifire(machine_config &config);
void helifire_sound(machine_config &config);
void spacefev(machine_config &config);
void spacefev_sound(machine_config &config);
protected: protected:
virtual void machine_start() override; virtual void machine_start() override;
virtual void machine_reset() override;
private: virtual void sound_pins_changed();
virtual void update_SN76477_status();
virtual void delayed_sound_1(int data);
virtual void delayed_sound_2(int data);
//private:
/* memory pointers */ /* memory pointers */
required_shared_ptr<uint8_t> m_videoram; required_shared_ptr<uint8_t> m_videoram;
optional_shared_ptr<uint8_t> m_colorram; // for helifire
/* video-related */ /* video-related */
emu_timer* m_cannon_timer;
int m_spacefev_red_screen;
int m_spacefev_red_cannon;
int m_sheriff_color_mode; int m_sheriff_color_mode;
int m_sheriff_color_data; int m_sheriff_color_data;
int m_helifire_flash;
uint8_t m_helifire_LSFR[63];
unsigned m_helifire_mv;
unsigned m_helifire_sc; /* IC56 */
/* sound-related */ /* sound-related */
int m_n8080_hardware;
emu_timer* m_sound_timer[3]; emu_timer* m_sound_timer[3];
int m_helifire_dac_phase;
double m_helifire_dac_volume;
double m_helifire_dac_timing;
uint16_t m_prev_sound_pins; uint16_t m_prev_sound_pins;
uint16_t m_curr_sound_pins; uint16_t m_curr_sound_pins;
int m_mono_flop[3]; int m_mono_flop[3];
@ -76,75 +60,144 @@ private:
required_device<i8080_cpu_device> m_maincpu; required_device<i8080_cpu_device> m_maincpu;
required_device<i8035_device> m_audiocpu; required_device<i8035_device> m_audiocpu;
optional_device<dac_bit_interface> m_n8080_dac; optional_device<dac_bit_interface> m_n8080_dac;
optional_device<dac_8bit_r2r_device> m_helifire_dac;
optional_device<sn76477_device> m_sn; optional_device<sn76477_device> m_sn;
required_device<screen_device> m_screen; required_device<screen_device> m_screen;
required_device<palette_device> m_palette; required_device<palette_device> m_palette;
DECLARE_WRITE8_MEMBER(n8080_shift_bits_w); void n8080_shift_bits_w(uint8_t data);
DECLARE_WRITE8_MEMBER(n8080_shift_data_w); void n8080_shift_data_w(uint8_t data);
DECLARE_READ8_MEMBER(n8080_shift_r); uint8_t n8080_shift_r();
DECLARE_WRITE8_MEMBER(n8080_video_control_w); void n8080_video_control_w(uint8_t data);
DECLARE_WRITE8_MEMBER(n8080_sound_1_w); void n8080_sound_1_w(uint8_t data);
DECLARE_WRITE8_MEMBER(n8080_sound_2_w); void n8080_sound_2_w(uint8_t data);
DECLARE_READ8_MEMBER(n8080_8035_p1_r); uint8_t n8080_8035_p1_r();
DECLARE_READ_LINE_MEMBER(n8080_8035_t0_r); DECLARE_READ_LINE_MEMBER(n8080_8035_t0_r);
DECLARE_READ_LINE_MEMBER(n8080_8035_t1_r); DECLARE_READ_LINE_MEMBER(n8080_8035_t1_r);
DECLARE_READ_LINE_MEMBER(helifire_8035_t0_r); void n8080_dac_w(uint8_t data);
DECLARE_READ_LINE_MEMBER(helifire_8035_t1_r);
DECLARE_READ8_MEMBER(helifire_8035_external_ram_r);
DECLARE_READ8_MEMBER(helifire_8035_p2_r);
DECLARE_WRITE8_MEMBER(n8080_dac_w);
DECLARE_WRITE8_MEMBER(helifire_sound_ctrl_w);
DECLARE_WRITE_LINE_MEMBER(n8080_inte_callback); DECLARE_WRITE_LINE_MEMBER(n8080_inte_callback);
DECLARE_WRITE8_MEMBER(n8080_status_callback); void n8080_status_callback(uint8_t data);
DECLARE_MACHINE_RESET(spacefev);
DECLARE_VIDEO_START(spacefev);
void n8080_palette(palette_device &palette) const; void n8080_palette(palette_device &palette) const;
DECLARE_MACHINE_RESET(sheriff);
DECLARE_VIDEO_START(sheriff);
DECLARE_MACHINE_RESET(helifire);
DECLARE_VIDEO_START(helifire);
void helifire_palette(palette_device &palette) const;
DECLARE_SOUND_START(spacefev);
DECLARE_SOUND_RESET(spacefev);
DECLARE_SOUND_START(sheriff);
DECLARE_SOUND_RESET(sheriff);
DECLARE_SOUND_START(helifire);
DECLARE_SOUND_RESET(helifire);
DECLARE_MACHINE_START(n8080);
DECLARE_MACHINE_RESET(n8080);
uint32_t screen_update_spacefev(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
uint32_t screen_update_sheriff(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
uint32_t screen_update_helifire(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
DECLARE_WRITE_LINE_MEMBER(screen_vblank_helifire);
TIMER_CALLBACK_MEMBER(spacefev_stop_red_cannon);
TIMER_DEVICE_CALLBACK_MEMBER(rst1_tick); TIMER_DEVICE_CALLBACK_MEMBER(rst1_tick);
TIMER_DEVICE_CALLBACK_MEMBER(rst2_tick); TIMER_DEVICE_CALLBACK_MEMBER(rst2_tick);
TIMER_DEVICE_CALLBACK_MEMBER(spacefev_vco_voltage_timer);
TIMER_DEVICE_CALLBACK_MEMBER(helifire_dac_volume_timer);
void spacefev_start_red_cannon( );
void helifire_next_line( );
void spacefev_update_SN76477_status();
void sheriff_update_SN76477_status();
void update_SN76477_status();
void start_mono_flop( int n, const attotime &expire ); void start_mono_flop( int n, const attotime &expire );
void stop_mono_flop( int n ); void stop_mono_flop( int n );
TIMER_CALLBACK_MEMBER( stop_mono_flop_callback ); TIMER_CALLBACK_MEMBER( stop_mono_flop_callback );
void spacefev_sound_pins_changed();
void sheriff_sound_pins_changed();
void helifire_sound_pins_changed();
void sound_pins_changed();
void delayed_sound_1( int data );
TIMER_CALLBACK_MEMBER( delayed_sound_1_callback ); TIMER_CALLBACK_MEMBER( delayed_sound_1_callback );
void delayed_sound_2( int data );
TIMER_CALLBACK_MEMBER( delayed_sound_2_callback ); TIMER_CALLBACK_MEMBER( delayed_sound_2_callback );
void helifire_main_cpu_map(address_map &map);
void helifire_sound_io_map(address_map &map);
void main_cpu_map(address_map &map); void main_cpu_map(address_map &map);
void main_io_map(address_map &map); void main_io_map(address_map &map);
void n8080_sound_cpu_map(address_map &map); void n8080_sound_cpu_map(address_map &map);
}; };
class spacefev_state : public n8080_state
{
public:
spacefev_state(const machine_config &mconfig, device_type type, const char *tag) :
n8080_state(mconfig, type, tag)
{ }
void spacefev(machine_config &config);
protected:
virtual void machine_reset() override;
virtual void sound_start() override;
virtual void sound_reset() override;
virtual void video_start() override;
virtual void sound_pins_changed() override;
virtual void update_SN76477_status() override;
virtual void delayed_sound_1(int data) override;
virtual void delayed_sound_2(int data) override;
private:
void spacefev_sound(machine_config &config);
TIMER_DEVICE_CALLBACK_MEMBER(vco_voltage_timer);
TIMER_CALLBACK_MEMBER(stop_red_cannon);
void start_red_cannon();
uint32_t screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
emu_timer* m_cannon_timer;
int m_red_screen;
int m_red_cannon;
};
class sheriff_state : public n8080_state
{
public:
sheriff_state(const machine_config &mconfig, device_type type, const char *tag) :
n8080_state(mconfig, type, tag)
{ }
void sheriff(machine_config &config);
void westgun2(machine_config &config);
protected:
virtual void machine_reset() override;
virtual void sound_start() override;
virtual void sound_reset() override;
virtual void video_start() override;
virtual void sound_pins_changed() override;
virtual void update_SN76477_status() override;
private:
void sheriff_sound(machine_config &config);
uint32_t screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
};
class helifire_state : public n8080_state
{
public:
helifire_state(const machine_config &mconfig, device_type type, const char *tag) :
n8080_state(mconfig, type, tag),
m_dac(*this, "helifire_dac"),
m_colorram(*this, "colorram")
{ }
void helifire(machine_config &config);
protected:
virtual void machine_reset() override;
virtual void sound_start() override;
virtual void sound_reset() override;
virtual void video_start() override;
virtual void sound_pins_changed() override;
virtual void delayed_sound_2(int data) override;
private:
void helifire_sound(machine_config &config);
TIMER_DEVICE_CALLBACK_MEMBER(dac_volume_timer);
DECLARE_READ_LINE_MEMBER(helifire_8035_t0_r);
DECLARE_READ_LINE_MEMBER(helifire_8035_t1_r);
uint8_t helifire_8035_external_ram_r();
uint8_t helifire_8035_p2_r();
void sound_ctrl_w(uint8_t data);
void sound_io_map(address_map &map);
void helifire_palette(palette_device &palette) const;
void next_line();
DECLARE_WRITE_LINE_MEMBER(screen_vblank);
uint32_t screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
void main_cpu_map(address_map &map);
required_device<dac_8bit_r2r_device> m_dac;
required_shared_ptr<uint8_t> m_colorram;
int m_dac_phase;
double m_dac_volume;
double m_dac_timing;
int m_flash;
uint8_t m_LSFR[63];
unsigned m_mv;
unsigned m_sc; // IC56
};
#endif // MAME_INCLUDES_N8080_H #endif // MAME_INCLUDES_N8080_H

View File

@ -10,7 +10,7 @@
#include "includes/n8080.h" #include "includes/n8080.h"
WRITE8_MEMBER(n8080_state::n8080_video_control_w) void n8080_state::n8080_video_control_w(uint8_t data)
{ {
m_sheriff_color_mode = (data >> 3) & 3; m_sheriff_color_mode = (data >> 3) & 3;
m_sheriff_color_data = (data >> 0) & 7; m_sheriff_color_data = (data >> 0) & 7;
@ -25,7 +25,7 @@ void n8080_state::n8080_palette(palette_device &palette) const
} }
void n8080_state::helifire_palette(palette_device &palette) const void helifire_state::helifire_palette(palette_device &palette) const
{ {
n8080_palette(palette); n8080_palette(palette);
@ -42,55 +42,55 @@ void n8080_state::helifire_palette(palette_device &palette) const
} }
void n8080_state::spacefev_start_red_cannon() void spacefev_state::start_red_cannon()
{ {
m_spacefev_red_cannon = 1; m_red_cannon = 1;
m_cannon_timer->adjust(attotime::from_usec(550 * 68 * 10)); m_cannon_timer->adjust(attotime::from_usec(550 * 68 * 10));
} }
TIMER_CALLBACK_MEMBER(n8080_state::spacefev_stop_red_cannon) TIMER_CALLBACK_MEMBER(spacefev_state::stop_red_cannon)
{ {
m_spacefev_red_cannon = 0; m_red_cannon = 0;
m_cannon_timer->adjust(attotime::never); m_cannon_timer->adjust(attotime::never);
} }
void n8080_state::helifire_next_line( ) void helifire_state::next_line()
{ {
m_helifire_mv++; m_mv++;
if (m_helifire_sc % 4 == 2) if (m_sc % 4 == 2)
{ {
m_helifire_mv %= 256; m_mv %= 256;
} }
else else
{ {
if (flip_screen()) if (flip_screen())
m_helifire_mv %= 255; m_mv %= 255;
else else
m_helifire_mv %= 257; m_mv %= 257;
} }
if (m_helifire_mv == 128) if (m_mv == 128)
{ {
m_helifire_sc++; m_sc++;
} }
} }
VIDEO_START_MEMBER(n8080_state,spacefev) void spacefev_state::video_start()
{ {
m_cannon_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(n8080_state::spacefev_stop_red_cannon),this)); m_cannon_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(spacefev_state::stop_red_cannon),this));
flip_screen_set(0); flip_screen_set(0);
save_item(NAME(m_spacefev_red_screen)); save_item(NAME(m_red_screen));
save_item(NAME(m_spacefev_red_cannon)); save_item(NAME(m_red_cannon));
} }
VIDEO_START_MEMBER(n8080_state,sheriff) void sheriff_state::video_start()
{ {
flip_screen_set(0); flip_screen_set(0);
@ -99,15 +99,15 @@ VIDEO_START_MEMBER(n8080_state,sheriff)
} }
VIDEO_START_MEMBER(n8080_state,helifire) void helifire_state::video_start()
{ {
uint8_t data = 0; uint8_t data = 0;
int i; int i;
save_item(NAME(m_helifire_mv)); save_item(NAME(m_mv));
save_item(NAME(m_helifire_sc)); save_item(NAME(m_sc));
save_item(NAME(m_helifire_flash)); save_item(NAME(m_flash));
save_item(NAME(m_helifire_LSFR)); save_item(NAME(m_LSFR));
for (i = 0; i < 63; i++) for (i = 0; i < 63; i++)
{ {
@ -117,14 +117,14 @@ VIDEO_START_MEMBER(n8080_state,helifire)
data = (data << 1) | (bit & 1); data = (data << 1) | (bit & 1);
m_helifire_LSFR[i] = data; m_LSFR[i] = data;
} }
flip_screen_set(0); flip_screen_set(0);
} }
uint32_t n8080_state::screen_update_spacefev(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) uint32_t spacefev_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
{ {
uint8_t mask = flip_screen() ? 0xff : 0x00; uint8_t mask = flip_screen() ? 0xff : 0x00;
@ -144,7 +144,7 @@ uint32_t n8080_state::screen_update_spacefev(screen_device &screen, bitmap_ind16
uint8_t color = 0; uint8_t color = 0;
if (m_spacefev_red_screen) if (m_red_screen)
color = 1; color = 1;
else else
{ {
@ -152,7 +152,7 @@ uint32_t n8080_state::screen_update_spacefev(screen_device &screen, bitmap_ind16
if ((x >> 3) == 0x06) if ((x >> 3) == 0x06)
{ {
color = m_spacefev_red_cannon ? 1 : 7; color = m_red_cannon ? 1 : 7;
} }
if ((x >> 3) == 0x1b) if ((x >> 3) == 0x1b)
@ -193,7 +193,7 @@ uint32_t n8080_state::screen_update_spacefev(screen_device &screen, bitmap_ind16
} }
uint32_t n8080_state::screen_update_sheriff(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) uint32_t sheriff_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
{ {
uint8_t mask = flip_screen() ? 0xff : 0x00; uint8_t mask = flip_screen() ? 0xff : 0x00;
@ -235,15 +235,15 @@ uint32_t n8080_state::screen_update_sheriff(screen_device &screen, bitmap_ind16
} }
uint32_t n8080_state::screen_update_helifire(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) uint32_t helifire_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
{ {
int SUN_BRIGHTNESS = ioport("POT0")->read(); int SUN_BRIGHTNESS = ioport("POT0")->read();
int SEA_BRIGHTNESS = ioport("POT1")->read(); int SEA_BRIGHTNESS = ioport("POT1")->read();
static const int wave[8] = { 0, 1, 2, 2, 2, 1, 0, 0 }; static const int wave[8] = { 0, 1, 2, 2, 2, 1, 0, 0 };
unsigned saved_mv = m_helifire_mv; unsigned saved_mv = m_mv;
unsigned saved_sc = m_helifire_sc; unsigned saved_sc = m_sc;
int x; int x;
int y; int y;
@ -252,7 +252,7 @@ uint32_t n8080_state::screen_update_helifire(screen_device &screen, bitmap_ind16
{ {
uint16_t* pLine = &bitmap.pix16(y); uint16_t* pLine = &bitmap.pix16(y);
int level = 120 + wave[m_helifire_mv & 7]; int level = 120 + wave[m_mv & 7];
/* draw sky */ /* draw sky */
@ -263,28 +263,28 @@ uint32_t n8080_state::screen_update_helifire(screen_device &screen, bitmap_ind16
/* draw stars */ /* draw stars */
if (m_helifire_mv % 8 == 4) /* upper half */ if (m_mv % 8 == 4) /* upper half */
{ {
int step = (320 * (m_helifire_mv - 0)) % sizeof m_helifire_LSFR; int step = (320 * (m_mv - 0)) % sizeof m_LSFR;
int data = int data =
((m_helifire_LSFR[step] & 1) << 6) | ((m_LSFR[step] & 1) << 6) |
((m_helifire_LSFR[step] & 2) << 4) | ((m_LSFR[step] & 2) << 4) |
((m_helifire_LSFR[step] & 4) << 2) | ((m_LSFR[step] & 4) << 2) |
((m_helifire_LSFR[step] & 8) << 0); ((m_LSFR[step] & 8) << 0);
pLine[0x80 + data] |= 0x100; pLine[0x80 + data] |= 0x100;
} }
if (m_helifire_mv % 8 == 5) /* lower half */ if (m_mv % 8 == 5) /* lower half */
{ {
int step = (320 * (m_helifire_mv - 1)) % sizeof m_helifire_LSFR; int step = (320 * (m_mv - 1)) % sizeof m_LSFR;
int data = int data =
((m_helifire_LSFR[step] & 1) << 6) | ((m_LSFR[step] & 1) << 6) |
((m_helifire_LSFR[step] & 2) << 4) | ((m_LSFR[step] & 2) << 4) |
((m_helifire_LSFR[step] & 4) << 2) | ((m_LSFR[step] & 4) << 2) |
((m_helifire_LSFR[step] & 8) << 0); ((m_LSFR[step] & 8) << 0);
pLine[0x00 + data] |= 0x100; pLine[0x00 + data] |= 0x100;
} }
@ -325,21 +325,21 @@ uint32_t n8080_state::screen_update_helifire(screen_device &screen, bitmap_ind16
/* next line */ /* next line */
helifire_next_line(); next_line();
} }
m_helifire_mv = saved_mv; m_mv = saved_mv;
m_helifire_sc = saved_sc; m_sc = saved_sc;
return 0; return 0;
} }
WRITE_LINE_MEMBER(n8080_state::screen_vblank_helifire) WRITE_LINE_MEMBER(helifire_state::screen_vblank)
{ {
// falling edge // falling edge
if (!state) if (!state)
{ {
int n = (m_screen->frame_number() >> 1) % sizeof m_helifire_LSFR; int n = (m_screen->frame_number() >> 1) % sizeof m_LSFR;
int i; int i;
@ -349,9 +349,9 @@ WRITE_LINE_MEMBER(n8080_state::screen_vblank_helifire)
int G = (i & 2); int G = (i & 2);
int B = (i & 4); int B = (i & 4);
if (m_helifire_flash) if (m_flash)
{ {
if (m_helifire_LSFR[n] & 0x20) if (m_LSFR[n] & 0x20)
{ {
G |= B; G |= B;
} }
@ -370,7 +370,7 @@ WRITE_LINE_MEMBER(n8080_state::screen_vblank_helifire)
for (i = 0; i < 256; i++) for (i = 0; i < 256; i++)
{ {
helifire_next_line(); next_line();
} }
} }
} }