diff --git a/.gitattributes b/.gitattributes index 93c2dbb300a..13e041aaa9e 100644 --- a/.gitattributes +++ b/.gitattributes @@ -2306,7 +2306,6 @@ src/mame/includes/1942.h svneol=native#text/plain src/mame/includes/1943.h svneol=native#text/plain src/mame/includes/20pacgal.h svneol=native#text/plain src/mame/includes/4enraya.h svneol=native#text/plain -src/mame/includes/8080bw.h svneol=native#text/plain src/mame/includes/actfancr.h svneol=native#text/plain src/mame/includes/aeroboto.h svneol=native#text/plain src/mame/includes/aerofgt.h svneol=native#text/plain diff --git a/src/mame/audio/8080bw.c b/src/mame/audio/8080bw.c index 227d5df0a43..910cffa61ae 100644 --- a/src/mame/audio/8080bw.c +++ b/src/mame/audio/8080bw.c @@ -1,23 +1,13 @@ -/* 8080bw.c ********************************* - */ +/* 8080bw.c *******************************************/ + #include "driver.h" -#include "8080bw.h" -#include "mw8080bw.h" #include "sound/samples.h" #include "sound/sn76477.h" #include "sound/discrete.h" #include "sound/speaker.h" +#include "includes/mw8080bw.h" -static emu_timer *schaser_effect_555_timer; -static attotime schaser_effect_555_time_remain; -static INT32 schaser_effect_555_time_remain_savable; -static int schaser_effect_555_is_low; -static int schaser_explosion; -static UINT8 port_1_last_extra = 0; -static UINT8 port_2_last_extra = 0; -static UINT8 port_3_last_extra = 0; - /*******************************************************/ /* */ /* Global state registration */ @@ -26,9 +16,11 @@ static UINT8 port_3_last_extra = 0; MACHINE_START( extra_8080bw_sh ) { - state_save_register_global(machine, port_1_last_extra); - state_save_register_global(machine, port_2_last_extra); - state_save_register_global(machine, port_3_last_extra); + mw8080bw_state *state = (mw8080bw_state *)machine->driver_data; + + state_save_register_global(machine, state->port_1_last_extra); + state_save_register_global(machine, state->port_2_last_extra); + state_save_register_global(machine, state->port_3_last_extra); } /*******************************************************/ @@ -39,22 +31,21 @@ MACHINE_START( extra_8080bw_sh ) WRITE8_HANDLER( invadpt2_sh_port_1_w ) { - const device_config *samples = devtag_get_device(space->machine, "samples"); - const device_config *sn = devtag_get_device(space->machine, "snsnd"); - UINT8 rising_bits = data & ~port_1_last_extra; + mw8080bw_state *state = (mw8080bw_state *)space->machine->driver_data; + UINT8 rising_bits = data & ~state->port_1_last_extra; - sn76477_enable_w(sn, !(data & 0x01)); /* SAUCER SOUND */ + sn76477_enable_w(state->sn, !(data & 0x01)); /* SAUCER SOUND */ - if (rising_bits & 0x02) sample_start(samples, 0, 0, 0); /* MISSLE SOUND */ - if (rising_bits & 0x04) sample_start(samples, 1, 1, 0); /* EXPLOSION */ - if (rising_bits & 0x08) sample_start(samples, 2, 2, 0); /* INVADER HIT */ - if (rising_bits & 0x10) sample_start(samples, 5, 8, 0); /* BONUS MISSILE BASE */ + if (rising_bits & 0x02) sample_start(state->samples, 0, 0, 0); /* MISSLE SOUND */ + if (rising_bits & 0x04) sample_start(state->samples, 1, 1, 0); /* EXPLOSION */ + if (rising_bits & 0x08) sample_start(state->samples, 2, 2, 0); /* INVADER HIT */ + if (rising_bits & 0x10) sample_start(state->samples, 5, 8, 0); /* BONUS MISSILE BASE */ - c8080bw_screen_red_w(data & 0x04); + state->screen_red = data & 0x04; sound_global_enable(space->machine, data & 0x20); - port_1_last_extra = data; + state->port_1_last_extra = data; } @@ -67,18 +58,18 @@ WRITE8_HANDLER( invadpt2_sh_port_2_w ) D2 = 82K D3 = 100K */ - const device_config *samples = devtag_get_device(space->machine, "samples"); - UINT8 rising_bits = data & ~port_2_last_extra; + mw8080bw_state *state = (mw8080bw_state *)space->machine->driver_data; + UINT8 rising_bits = data & ~state->port_2_last_extra; - if (rising_bits & 0x01) sample_start(samples, 4, 3, 0); /* FLEET */ - if (rising_bits & 0x02) sample_start(samples, 4, 4, 0); /* FLEET */ - if (rising_bits & 0x04) sample_start(samples, 4, 5, 0); /* FLEET */ - if (rising_bits & 0x08) sample_start(samples, 4, 6, 0); /* FLEET */ - if (rising_bits & 0x10) sample_start(samples, 3, 7, 0); /* SAUCER HIT */ + if (rising_bits & 0x01) sample_start(state->samples, 4, 3, 0); /* FLEET */ + if (rising_bits & 0x02) sample_start(state->samples, 4, 4, 0); /* FLEET */ + if (rising_bits & 0x04) sample_start(state->samples, 4, 5, 0); /* FLEET */ + if (rising_bits & 0x08) sample_start(state->samples, 4, 6, 0); /* FLEET */ + if (rising_bits & 0x10) sample_start(state->samples, 3, 7, 0); /* SAUCER HIT */ - c8080bw_flip_screen_w(space, data & 0x20); + state->c8080bw_flip_screen = data & 0x20; - port_2_last_extra = data; + state->port_2_last_extra = data; } @@ -90,20 +81,18 @@ WRITE8_HANDLER( invadpt2_sh_port_2_w ) WRITE8_HANDLER( spcewars_sh_port_w ) { - const device_config *samples = devtag_get_device(space->machine, "samples"); - const device_config *speaker = devtag_get_device(space->machine, "speaker"); - const device_config *sn = devtag_get_device(space->machine, "snsnd"); - UINT8 rising_bits = data & ~port_1_last_extra; + mw8080bw_state *state = (mw8080bw_state *)space->machine->driver_data; + UINT8 rising_bits = data & ~state->port_1_last_extra; - sn76477_enable_w(sn, !(data & 0x01)); /* Saucer Sound */ + sn76477_enable_w(state->sn, !(data & 0x01)); /* Saucer Sound */ - if (rising_bits & 0x02) sample_start(samples, 0, 0, 0); /* Shot Sound */ - if (rising_bits & 0x04) sample_start(samples, 1, 1, 0); /* Base Hit */ - if (rising_bits & 0x08) sample_start(samples, 2, 2, 0); /* Invader Hit */ + if (rising_bits & 0x02) sample_start(state->samples, 0, 0, 0); /* Shot Sound */ + if (rising_bits & 0x04) sample_start(state->samples, 1, 1, 0); /* Base Hit */ + if (rising_bits & 0x08) sample_start(state->samples, 2, 2, 0); /* Invader Hit */ - speaker_level_w(speaker, (data & 0x10) ? 1 : 0); /* Various bitstream tunes */ + speaker_level_w(state->speaker, (data & 0x10) ? 1 : 0); /* Various bitstream tunes */ - port_1_last_extra = data; + state->port_1_last_extra = data; } @@ -136,40 +125,39 @@ const samples_interface lrescue_samples_interface = WRITE8_HANDLER( lrescue_sh_port_1_w ) { - const device_config *samples = devtag_get_device(space->machine, "samples"); - UINT8 rising_bits = data & ~port_1_last_extra; + mw8080bw_state *state = (mw8080bw_state *)space->machine->driver_data; + UINT8 rising_bits = data & ~state->port_1_last_extra; - if (rising_bits & 0x01) sample_start(samples, 0, 3, 0); /* Thrust */ - if (rising_bits & 0x02) sample_start(samples, 1, 2, 0); /* Shot Sound */ - if (rising_bits & 0x04) sample_start(samples, 0, 1, 0); /* Death */ - if (rising_bits & 0x08) sample_start(samples, 1, 0, 0); /* Alien Hit */ - if (rising_bits & 0x10) sample_start(samples, 2, 5, 0); /* Bonus Ship (not confirmed) */ + if (rising_bits & 0x01) sample_start(state->samples, 0, 3, 0); /* Thrust */ + if (rising_bits & 0x02) sample_start(state->samples, 1, 2, 0); /* Shot Sound */ + if (rising_bits & 0x04) sample_start(state->samples, 0, 1, 0); /* Death */ + if (rising_bits & 0x08) sample_start(state->samples, 1, 0, 0); /* Alien Hit */ + if (rising_bits & 0x10) sample_start(state->samples, 2, 5, 0); /* Bonus Ship (not confirmed) */ sound_global_enable(space->machine, data & 0x20); - c8080bw_screen_red_w(data & 0x04); + state->screen_red = data & 0x04; - port_1_last_extra = data; + state->port_1_last_extra = data; } WRITE8_HANDLER( lrescue_sh_port_2_w ) { - const device_config *samples = devtag_get_device(space->machine, "samples"); - const device_config *speaker = devtag_get_device(space->machine, "speaker"); - UINT8 rising_bits = data & ~port_2_last_extra; + mw8080bw_state *state = (mw8080bw_state *)space->machine->driver_data; + UINT8 rising_bits = data & ~state->port_2_last_extra; - if (rising_bits & 0x01) sample_start(samples, 1, 8, 0); /* Footstep high tone */ - if (rising_bits & 0x02) sample_start(samples, 1, 7, 0); /* Footstep low tone */ - if (rising_bits & 0x04) sample_start(samples, 1, 4, 0); /* Bonus when counting men saved */ + if (rising_bits & 0x01) sample_start(state->samples, 1, 8, 0); /* Footstep high tone */ + if (rising_bits & 0x02) sample_start(state->samples, 1, 7, 0); /* Footstep low tone */ + if (rising_bits & 0x04) sample_start(state->samples, 1, 4, 0); /* Bonus when counting men saved */ - speaker_level_w(speaker, (data & 0x08) ? 1 : 0); /* Bitstream tunes - endlevel and bonus1 */ + speaker_level_w(state->speaker, (data & 0x08) ? 1 : 0); /* Bitstream tunes - endlevel and bonus1 */ - if (rising_bits & 0x10) sample_start(samples, 3, 6, 0); /* Shooting Star and Rescue Ship sounds */ - if (~data & 0x10 && port_2_last_extra & 0x10) sample_stop (samples, 3); /* This makes the rescue ship sound beep on and off */ + if (rising_bits & 0x10) sample_start(state->samples, 3, 6, 0); /* Shooting Star and Rescue Ship sounds */ + if (~data & 0x10 && state->port_2_last_extra & 0x10) sample_stop (state->samples, 3); /* This makes the rescue ship sound beep on and off */ - c8080bw_flip_screen_w(space, data & 0x20); + state->c8080bw_flip_screen = data & 0x20; - port_2_last_extra = data; + state->port_2_last_extra = data; } @@ -195,34 +183,34 @@ WRITE8_HANDLER( cosmo_sh_port_2_w ) WRITE8_HANDLER( ballbomb_sh_port_1_w ) { - const device_config *samples = devtag_get_device(space->machine, "samples"); - UINT8 rising_bits = data & ~port_1_last_extra; + mw8080bw_state *state = (mw8080bw_state *)space->machine->driver_data; + UINT8 rising_bits = data & ~state->port_1_last_extra; - if (rising_bits & 0x01) sample_start(samples, 1, 2, 0); /* Hit a balloon */ - if (rising_bits & 0x02) sample_start(samples, 2, 0, 0); /* Shot Sound */ - if (rising_bits & 0x04) sample_start(samples, 2, 1, 0); /* Base Hit */ - if (rising_bits & 0x08) sample_start(samples, 1, 7, 0); /* Hit a Bomb */ - if (rising_bits & 0x10) sample_start(samples, 3, 8, 0); /* Bonus Base at 1500 points */ + if (rising_bits & 0x01) sample_start(state->samples, 1, 2, 0); /* Hit a balloon */ + if (rising_bits & 0x02) sample_start(state->samples, 2, 0, 0); /* Shot Sound */ + if (rising_bits & 0x04) sample_start(state->samples, 2, 1, 0); /* Base Hit */ + if (rising_bits & 0x08) sample_start(state->samples, 1, 7, 0); /* Hit a Bomb */ + if (rising_bits & 0x10) sample_start(state->samples, 3, 8, 0); /* Bonus Base at 1500 points */ sound_global_enable(space->machine, data & 0x20); - c8080bw_screen_red_w(data & 0x04); + state->screen_red = data & 0x04; - port_1_last_extra = data; + state->port_1_last_extra = data; } WRITE8_HANDLER( ballbomb_sh_port_2_w ) { - const device_config *samples = devtag_get_device(space->machine, "samples"); - UINT8 rising_bits = data & ~port_2_last_extra; + mw8080bw_state *state = (mw8080bw_state *)space->machine->driver_data; + UINT8 rising_bits = data & ~state->port_2_last_extra; - if (data & 0x01) sample_start(samples, 0, 7, 0); /* Indicates plane will drop bombs */ - if (data & 0x04) sample_start(samples, 0, 4, 0); /* Plane is dropping new balloons at start of level */ - if (rising_bits & 0x10) sample_start(samples, 2, 2, 0); /* Balloon hit and bomb drops */ + if (data & 0x01) sample_start(state->samples, 0, 7, 0); /* Indicates plane will drop bombs */ + if (data & 0x04) sample_start(state->samples, 0, 4, 0); /* Plane is dropping new balloons at start of level */ + if (rising_bits & 0x10) sample_start(state->samples, 2, 2, 0); /* Balloon hit and bomb drops */ - c8080bw_flip_screen_w(space, data & 0x20); + state->c8080bw_flip_screen = data & 0x20; - port_2_last_extra = data; + state->port_2_last_extra = data; } @@ -272,33 +260,32 @@ DISCRETE_SOUND_END WRITE8_HANDLER( indianbt_sh_port_1_w ) { /* bit 4 occurs every 5.25 seconds during gameplay */ + mw8080bw_state *state = (mw8080bw_state *)space->machine->driver_data; + UINT8 rising_bits = data & ~state->port_1_last_extra; - const device_config *samples = devtag_get_device(space->machine, "samples"); - UINT8 rising_bits = data & ~port_1_last_extra; - - if (rising_bits & 0x01) sample_start(samples, 1, 7, 0); /* Death */ - if (rising_bits & 0x02) sample_start(samples, 0, 1, 0); /* Shot Sound */ - if (rising_bits & 0x04) sample_start(samples, 2, 3, 0); /* Move */ - if (rising_bits & 0x08) sample_start(samples, 3, 2, 0); /* Hit */ + if (rising_bits & 0x01) sample_start(state->samples, 1, 7, 0); /* Death */ + if (rising_bits & 0x02) sample_start(state->samples, 0, 1, 0); /* Shot Sound */ + if (rising_bits & 0x04) sample_start(state->samples, 2, 3, 0); /* Move */ + if (rising_bits & 0x08) sample_start(state->samples, 3, 2, 0); /* Hit */ sound_global_enable(space->machine, data & 0x20); - c8080bw_screen_red_w(data & 0x01); + state->screen_red = data & 0x01; - port_1_last_extra = data; + state->port_1_last_extra = data; } WRITE8_HANDLER( indianbt_sh_port_2_w ) { - const device_config *samples = devtag_get_device(space->machine, "samples"); - UINT8 rising_bits = data & ~port_2_last_extra; + mw8080bw_state *state = (mw8080bw_state *)space->machine->driver_data; + UINT8 rising_bits = data & ~state->port_2_last_extra; - if (rising_bits & 0x01) sample_start(samples, 4, 0, 0); /* Bird dropped an egg, Lasso used */ - if (rising_bits & 0x02) sample_start(samples, 4, 2, 0); /* Egg hatches, egg shot */ - if (rising_bits & 0x08) sample_start(samples, 5, 0, 0); /* Grabber, Lasso caught something */ - if (rising_bits & 0x10) sample_start(samples, 3, 7, 0); /* Lasso sound */ + if (rising_bits & 0x01) sample_start(state->samples, 4, 0, 0); /* Bird dropped an egg, Lasso used */ + if (rising_bits & 0x02) sample_start(state->samples, 4, 2, 0); /* Egg hatches, egg shot */ + if (rising_bits & 0x08) sample_start(state->samples, 5, 0, 0); /* Grabber, Lasso caught something */ + if (rising_bits & 0x10) sample_start(state->samples, 3, 7, 0); /* Lasso sound */ - port_2_last_extra = data; + state->port_2_last_extra = data; } WRITE8_DEVICE_HANDLER( indianbt_sh_port_3_w ) @@ -646,10 +633,11 @@ WRITE8_DEVICE_HANDLER( polaris_sh_port_2_w ) WRITE8_DEVICE_HANDLER( polaris_sh_port_3_w ) { + mw8080bw_state *state = (mw8080bw_state *)device->machine->driver_data; coin_lockout_global_w(device->machine, data & 0x04); /* SX8 */ - c8080bw_flip_screen_w(cputag_get_address_space(device->machine, "maincpu", ADDRESS_SPACE_PROGRAM), data & 0x20); /* SX11 */ + state->c8080bw_flip_screen = data & 0x20; /* SX11 */ /* 0x01 - SX6 - Plane Down */ discrete_sound_w(device, POLARIS_SX6_EN, data & 0x01); @@ -799,9 +787,7 @@ static const double schaser_effect_rc[8] = WRITE8_HANDLER( schaser_sh_port_1_w ) { - const device_config *discrete = devtag_get_device(space->machine, "discrete"); - const device_config *sn = devtag_get_device(space->machine, "snsnd"); - static int last_effect = 0; + mw8080bw_state *state = (mw8080bw_state *)space->machine->driver_data; int effect; /* bit 0 - Dot Sound Enable (SX0) @@ -812,8 +798,8 @@ WRITE8_HANDLER( schaser_sh_port_1_w ) bit 5 - Explosion (SX5) */ //printf( "schaser_sh_port_1_w: %02x\n", data ); - discrete_sound_w(discrete, SCHASER_DOT_EN, data & 0x01); - discrete_sound_w(discrete, SCHASER_DOT_SEL, data & 0x02); + discrete_sound_w(state->discrete, SCHASER_DOT_EN, data & 0x01); + discrete_sound_w(state->discrete, SCHASER_DOT_SEL, data & 0x02); /* The effect is a variable rate 555 timer. A diode/resistor array is used to * select the frequency. Because of the diode voltage drop, we can not use the @@ -822,47 +808,47 @@ WRITE8_HANDLER( schaser_sh_port_1_w ) * but the bleed time is so long, that we can just cheat and put the time on hold * when effect = 0. */ effect = (data >> 2) & 0x07; - if (last_effect != effect) + if (state->schaser_last_effect != effect) { if (effect) { - if (attotime_compare(schaser_effect_555_time_remain, attotime_zero) != 0) + if (attotime_compare(state->schaser_effect_555_time_remain, attotime_zero) != 0) { /* timer re-enabled, use up remaining 555 high time */ - timer_adjust_oneshot(schaser_effect_555_timer, schaser_effect_555_time_remain, effect); + timer_adjust_oneshot(state->schaser_effect_555_timer, state->schaser_effect_555_time_remain, effect); } - else if (!schaser_effect_555_is_low) + else if (!state->schaser_effect_555_is_low) { /* set 555 high time */ attotime new_time = attotime_make(0, ATTOSECONDS_PER_SECOND * .8873 * schaser_effect_rc[effect]); - timer_adjust_oneshot(schaser_effect_555_timer, new_time, effect); + timer_adjust_oneshot(state->schaser_effect_555_timer, new_time, effect); } } else { /* disable effect - stops at end of low cycle */ - if (!schaser_effect_555_is_low) + if (!state->schaser_effect_555_is_low) { - schaser_effect_555_time_remain = timer_timeleft(schaser_effect_555_timer); - schaser_effect_555_time_remain_savable = attotime_to_double(schaser_effect_555_time_remain); - timer_adjust_oneshot(schaser_effect_555_timer, attotime_never, 0); + state->schaser_effect_555_time_remain = timer_timeleft(state->schaser_effect_555_timer); + state->schaser_effect_555_time_remain_savable = attotime_to_double(state->schaser_effect_555_time_remain); + timer_adjust_oneshot(state->schaser_effect_555_timer, attotime_never, 0); } } - last_effect = effect; + state->schaser_last_effect = effect; } - schaser_explosion = (data >> 5) & 0x01; - if (schaser_explosion) + state->schaser_explosion = (data >> 5) & 0x01; + if (state->schaser_explosion) { - sn76477_amplitude_res_w(sn, 1.0 / (1.0/RES_K(200) + 1.0/RES_K(68))); + sn76477_amplitude_res_w(state->sn, 1.0 / (1.0/RES_K(200) + 1.0/RES_K(68))); } else { - sn76477_amplitude_res_w(sn, RES_K(200)); + sn76477_amplitude_res_w(state->sn, RES_K(200)); } - sn76477_enable_w(sn, !(schaser_effect_555_is_low || schaser_explosion)); - sn76477_one_shot_cap_voltage_w(sn, !(schaser_effect_555_is_low || schaser_explosion) ? 0 : SN76477_EXTERNAL_VOLTAGE_DISCONNECT); - sn76477_mixer_b_w(sn, schaser_explosion); + sn76477_enable_w(state->sn, !(state->schaser_effect_555_is_low || state->schaser_explosion)); + sn76477_one_shot_cap_voltage_w(state->sn, !(state->schaser_effect_555_is_low || state->schaser_explosion) ? 0 : SN76477_EXTERNAL_VOLTAGE_DISCONNECT); + sn76477_mixer_b_w(state->sn, state->schaser_explosion); } WRITE8_HANDLER( schaser_sh_port_2_w ) @@ -874,36 +860,37 @@ WRITE8_HANDLER( schaser_sh_port_2_w ) bit 4 - Field Control B (SX10) bit 5 - Flip Screen */ - const device_config *discrete = devtag_get_device(space->machine, "discrete"); + mw8080bw_state *state = (mw8080bw_state *)space->machine->driver_data; - //printf( "schaser_sh_port_2_w: %02x\n", data ); + //printf( "schaser_sh_port_2_w: %02x\n", data ); - discrete_sound_w(discrete, SCHASER_MUSIC_BIT, data & 0x01); + discrete_sound_w(state->discrete, SCHASER_MUSIC_BIT, data & 0x01); - discrete_sound_w(discrete, SCHASER_SND_EN, data & 0x02); + discrete_sound_w(state->discrete, SCHASER_SND_EN, data & 0x02); sound_global_enable(space->machine, data & 0x02); coin_lockout_global_w(space->machine, data & 0x04); - schaser_background_control_w(data & 0x18); + state->schaser_background_disable = (data >> 3) & 0x01; + state->schaser_background_select = (data >> 4) & 0x01; - c8080bw_flip_screen_w(space, data & 0x20); + state->c8080bw_flip_screen = data & 0x20; - port_2_last_extra = data; + state->port_2_last_extra = data; } static TIMER_CALLBACK( schaser_effect_555_cb ) { - const device_config *sn = devtag_get_device(machine, "snsnd"); + mw8080bw_state *state = (mw8080bw_state *)machine->driver_data; int effect = param; attotime new_time; /* Toggle 555 output */ - schaser_effect_555_is_low = !schaser_effect_555_is_low; - schaser_effect_555_time_remain = attotime_zero; - schaser_effect_555_time_remain_savable = attotime_to_double(schaser_effect_555_time_remain); + state->schaser_effect_555_is_low = !state->schaser_effect_555_is_low; + state->schaser_effect_555_time_remain = attotime_zero; + state->schaser_effect_555_time_remain_savable = attotime_to_double(state->schaser_effect_555_time_remain); - if (schaser_effect_555_is_low) + if (state->schaser_effect_555_is_low) new_time = attotime_div(PERIOD_OF_555_ASTABLE(0, RES_K(20), CAP_U(1)), 2); else { @@ -912,46 +899,46 @@ static TIMER_CALLBACK( schaser_effect_555_cb ) else new_time = attotime_never; } - timer_adjust_oneshot(schaser_effect_555_timer, new_time, effect); - sn76477_enable_w(sn, !(schaser_effect_555_is_low || schaser_explosion)); - sn76477_one_shot_cap_voltage_w(sn, !(schaser_effect_555_is_low || schaser_explosion) ? 0 : SN76477_EXTERNAL_VOLTAGE_DISCONNECT); + timer_adjust_oneshot(state->schaser_effect_555_timer, new_time, effect); + sn76477_enable_w(state->sn, !(state->schaser_effect_555_is_low || state->schaser_explosion)); + sn76477_one_shot_cap_voltage_w(state->sn, !(state->schaser_effect_555_is_low || state->schaser_explosion) ? 0 : SN76477_EXTERNAL_VOLTAGE_DISCONNECT); } static STATE_POSTLOAD( schaser_reinit_555_time_remain ) { - const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM); - schaser_effect_555_time_remain = double_to_attotime(schaser_effect_555_time_remain_savable); - schaser_sh_port_2_w(space, 0, port_2_last_extra); + mw8080bw_state *state = (mw8080bw_state *)machine->driver_data; + const address_space *space = cpu_get_address_space(state->maincpu, ADDRESS_SPACE_PROGRAM); + state->schaser_effect_555_time_remain = double_to_attotime(state->schaser_effect_555_time_remain_savable); + schaser_sh_port_2_w(space, 0, state->port_2_last_extra); } -MACHINE_START( schaser ) +MACHINE_START( schaser_sh ) { - schaser_effect_555_timer = timer_alloc(machine, schaser_effect_555_cb, NULL); + mw8080bw_state *state = (mw8080bw_state *)machine->driver_data; - state_save_register_global(machine, schaser_explosion); - state_save_register_global(machine, schaser_effect_555_is_low); - state_save_register_global(machine, schaser_effect_555_time_remain_savable); - state_save_register_global(machine, port_2_last_extra); - state_save_register_postload(machine, schaser_reinit_555_time_remain, NULL); + state->schaser_effect_555_timer = timer_alloc(machine, schaser_effect_555_cb, NULL); - MACHINE_START_CALL(extra_8080bw_vh); - MACHINE_START_CALL(mw8080bw); + state_save_register_global(machine, state->schaser_explosion); + state_save_register_global(machine, state->schaser_effect_555_is_low); + state_save_register_global(machine, state->schaser_effect_555_time_remain_savable); + state_save_register_global(machine, state->port_2_last_extra); + state_save_register_postload(machine, schaser_reinit_555_time_remain, NULL); } -MACHINE_RESET( schaser ) +MACHINE_RESET( schaser_sh ) { + mw8080bw_state *state = (mw8080bw_state *)machine->driver_data; const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM); - schaser_effect_555_is_low = 0; - timer_adjust_oneshot(schaser_effect_555_timer, attotime_never, 0); + + state->schaser_effect_555_is_low = 0; + timer_adjust_oneshot(state->schaser_effect_555_timer, attotime_never, 0); schaser_sh_port_1_w(space, 0, 0); schaser_sh_port_2_w(space, 0, 0); - schaser_effect_555_time_remain = attotime_zero; - schaser_effect_555_time_remain_savable = attotime_to_double(schaser_effect_555_time_remain); - - MACHINE_RESET_CALL(mw8080bw); + state->schaser_effect_555_time_remain = attotime_zero; + state->schaser_effect_555_time_remain_savable = attotime_to_double(state->schaser_effect_555_time_remain); } @@ -963,14 +950,14 @@ MACHINE_RESET( schaser ) WRITE8_HANDLER( rollingc_sh_port_w ) { - const device_config *samples = devtag_get_device(space->machine, "samples"); - UINT8 rising_bits = data & ~port_3_last_extra; + mw8080bw_state *state = (mw8080bw_state *)space->machine->driver_data; + UINT8 rising_bits = data & ~state->port_3_last_extra; - if (rising_bits & 0x02) sample_start(samples, 4, 0, 0); /* Steering */ - if (rising_bits & 0x04) sample_start(samples, 0, 1, 0); /* Collision */ - if (rising_bits & 0x10) sample_start(samples, 1, 8, 0); /* Computer car is starting to move */ + if (rising_bits & 0x02) sample_start(state->samples, 4, 0, 0); /* Steering */ + if (rising_bits & 0x04) sample_start(state->samples, 0, 1, 0); /* Collision */ + if (rising_bits & 0x10) sample_start(state->samples, 1, 8, 0); /* Computer car is starting to move */ - port_3_last_extra = data; + state->port_3_last_extra = data; } @@ -987,28 +974,29 @@ WRITE8_HANDLER( rollingc_sh_port_w ) WRITE8_HANDLER( invrvnge_sh_port_w ) { - const device_config *samples = devtag_get_device(space->machine, "samples"); + mw8080bw_state *state = (mw8080bw_state *)space->machine->driver_data; + switch (data) { case 0x06: - sample_start(samples, 1, 0, 0); /* Shoot */ + sample_start(state->samples, 1, 0, 0); /* Shoot */ break; case 0x14: - sample_start(samples, 2, 2, 0); /* Hit Alien */ + sample_start(state->samples, 2, 2, 0); /* Hit Alien */ break; case 0x16: - sample_start(samples, 2, 5, 0); /* Hit Asteroid */ + sample_start(state->samples, 2, 5, 0); /* Hit Asteroid */ break; case 0x1e: - sample_start(samples, 3, 1, 0); /* Death (followed by 0x0a byte), also bit 4 of port 5 */ + sample_start(state->samples, 3, 1, 0); /* Death (followed by 0x0a byte), also bit 4 of port 5 */ break; case 0x18: /* Fuel Low */ case 0x30: /* Fuel bar filling up */ - sample_start(samples, 4, 7, 0); + sample_start(state->samples, 4, 7, 0); break; case 0x02: /* Coin */ @@ -1018,7 +1006,7 @@ WRITE8_HANDLER( invrvnge_sh_port_w ) break; case 0x3a: /* Thrust, Docking, extra ship? */ - sample_start(samples, 0, 8, 0); + sample_start(state->samples, 0, 8, 0); break; } } @@ -1031,35 +1019,36 @@ WRITE8_HANDLER( invrvnge_sh_port_w ) WRITE8_HANDLER( lupin3_sh_port_1_w ) { - const device_config *samples = devtag_get_device(space->machine, "samples"); - const device_config *sn = devtag_get_device(space->machine, "snsnd"); - UINT8 rising_bits = data & ~port_1_last_extra; + mw8080bw_state *state = (mw8080bw_state *)space->machine->driver_data; + UINT8 rising_bits = data & ~state->port_1_last_extra; - if (rising_bits & 0x01) sample_start(samples, 0, 6, 0); /* Walking, get money */ + if (rising_bits & 0x01) sample_start(state->samples, 0, 6, 0); /* Walking, get money */ - sn76477_enable_w(sn, data & 0x02 ? 0:1); /* Helicopter */ + sn76477_enable_w(state->sn, data & 0x02 ? 0:1); /* Helicopter */ - if (rising_bits & 0x04) sample_start(samples, 0, 7, 0); /* Translocate */ - if (rising_bits & 0x08) sample_start(samples, 0, 1, 0); /* Jail */ - if (rising_bits & 0x10) sample_start(samples, 3, 8, 0); /* Bonus Man */ + if (rising_bits & 0x04) sample_start(state->samples, 0, 7, 0); /* Translocate */ + if (rising_bits & 0x08) sample_start(state->samples, 0, 1, 0); /* Jail */ + if (rising_bits & 0x10) sample_start(state->samples, 3, 8, 0); /* Bonus Man */ - port_1_last_extra = data; + state->port_1_last_extra = data; } WRITE8_HANDLER( lupin3_sh_port_2_w ) { - const device_config *samples = devtag_get_device(space->machine, "samples"); - UINT8 rising_bits = data & ~port_2_last_extra; + mw8080bw_state *state = (mw8080bw_state *)space->machine->driver_data; + UINT8 rising_bits = data & ~state->port_2_last_extra; - if (rising_bits & 0x01) sample_start(samples, 0, 3, 0); /* Lands on top of building, wife kicks man */ - if (rising_bits & 0x02) sample_start(samples, 1, 2, 0); /* deposit money, start intermission, end game */ - if (rising_bits & 0x04) sample_start(samples, 2, 5, 0); /* deposit money, start intermission, Slides down rope */ - if (rising_bits & 0x08) sample_start(samples, 3, 0, 0); /* start intermission, end game */ - //if (rising_bits & 0x10) sample_start(samples, 3, 9, 0); /* Dog barking */ + if (rising_bits & 0x01) sample_start(state->samples, 0, 3, 0); /* Lands on top of building, wife kicks man */ + if (rising_bits & 0x02) sample_start(state->samples, 1, 2, 0); /* deposit money, start intermission, end game */ + if (rising_bits & 0x04) sample_start(state->samples, 2, 5, 0); /* deposit money, start intermission, Slides down rope */ + if (rising_bits & 0x08) sample_start(state->samples, 3, 0, 0); /* start intermission, end game */ + //if (rising_bits & 0x10) sample_start(state->samples, 3, 9, 0); /* Dog barking */ - lupin3_flip_screen_w(space, data & 0x60); + state->color_map = data & 0x40; - port_2_last_extra = data; + state->c8080bw_flip_screen = (data & 0x20) && (input_port_read(space->machine, "IN2") & 0x04); + + state->port_2_last_extra = data; } @@ -1075,24 +1064,24 @@ WRITE8_HANDLER( schasrcv_sh_port_1_w ) bit 3 = 1st speedup Death is a stream of ff's with some fe's thrown in */ - const device_config *samples = devtag_get_device(space->machine, "samples"); - UINT8 rising_bits = data & ~port_1_last_extra; + mw8080bw_state *state = (mw8080bw_state *)space->machine->driver_data; + UINT8 rising_bits = data & ~state->port_1_last_extra; - if (rising_bits & 0x02) sample_start(samples, 1, 6, 0); /* Ran over a dot */ - if (rising_bits & 0x10) sample_start(samples, 0, 1, 0); /* Death */ + if (rising_bits & 0x02) sample_start(state->samples, 1, 6, 0); /* Ran over a dot */ + if (rising_bits & 0x10) sample_start(state->samples, 0, 1, 0); /* Death */ - port_1_last_extra = data; + state->port_1_last_extra = data; } WRITE8_HANDLER( schasrcv_sh_port_2_w ) { - const device_config *speaker = devtag_get_device(space->machine, "speaker"); + mw8080bw_state *state = (mw8080bw_state *)space->machine->driver_data; - speaker_level_w(speaker, (data & 0x01) ? 1 : 0); /* End-of-Level */ + speaker_level_w(state->speaker, (data & 0x01) ? 1 : 0); /* End-of-Level */ sound_global_enable(space->machine, data & 0x10); - c8080bw_flip_screen_w(space, data & 0x20); + state->c8080bw_flip_screen = data & 0x20; } @@ -1103,36 +1092,35 @@ WRITE8_HANDLER( schasrcv_sh_port_2_w ) WRITE8_HANDLER( yosakdon_sh_port_1_w ) { - const device_config *samples = devtag_get_device(space->machine, "samples"); - UINT8 rising_bits = data & ~port_1_last_extra; + mw8080bw_state *state = (mw8080bw_state *)space->machine->driver_data; + UINT8 rising_bits = data & ~state->port_1_last_extra; - if (rising_bits & 0x01) sample_start(samples, 0, 3, 0); /* Game Over */ - if (rising_bits & 0x02) sample_start(samples, 2, 0, 0); /* Bird dead */ - if (rising_bits & 0x04) sample_start(samples, 0, 1, 0); /* Rifle being fired */ - if (rising_bits & 0x08) sample_start(samples, 1, 2, 0); /* Man dead */ - if (rising_bits & 0x10) sample_start(samples, 5, 8, 0); /* Bonus Man? */ + if (rising_bits & 0x01) sample_start(state->samples, 0, 3, 0); /* Game Over */ + if (rising_bits & 0x02) sample_start(state->samples, 2, 0, 0); /* Bird dead */ + if (rising_bits & 0x04) sample_start(state->samples, 0, 1, 0); /* Rifle being fired */ + if (rising_bits & 0x08) sample_start(state->samples, 1, 2, 0); /* Man dead */ + if (rising_bits & 0x10) sample_start(state->samples, 5, 8, 0); /* Bonus Man? */ sound_global_enable(space->machine, data & 0x20); - port_1_last_extra = data; + state->port_1_last_extra = data; } WRITE8_HANDLER( yosakdon_sh_port_2_w ) { - const device_config *samples = devtag_get_device(space->machine, "samples"); - const device_config *sn = devtag_get_device(space->machine, "snsnd"); - UINT8 rising_bits = data & ~port_2_last_extra; + mw8080bw_state *state = (mw8080bw_state *)space->machine->driver_data; + UINT8 rising_bits = data & ~state->port_2_last_extra; - if (rising_bits & 0x01) sample_start(samples, 1, 6, 0); /* Ready? , Game Over */ - if (rising_bits & 0x04) sample_start(samples, 3, 7, 0); /* Big bird dead */ + if (rising_bits & 0x01) sample_start(state->samples, 1, 6, 0); /* Ready? , Game Over */ + if (rising_bits & 0x04) sample_start(state->samples, 3, 7, 0); /* Big bird dead */ - sn76477_enable_w(sn, data & 0x08 ? 0:1); /* Big bird */ + sn76477_enable_w(state->sn, data & 0x08 ? 0:1); /* Big bird */ - if (rising_bits & 0x10) sample_start(samples, 2, 7, 0); /* Game Over */ + if (rising_bits & 0x10) sample_start(state->samples, 2, 7, 0); /* Game Over */ - c8080bw_flip_screen_w(space, data & 0x20); + state->c8080bw_flip_screen = data & 0x20; - port_2_last_extra = data; + state->port_2_last_extra = data; } @@ -1144,38 +1132,37 @@ WRITE8_HANDLER( yosakdon_sh_port_2_w ) WRITE8_HANDLER( shuttlei_sh_port_1_w ) { /* bit 3 is high while you are alive and playing */ + mw8080bw_state *state = (mw8080bw_state *)space->machine->driver_data; + UINT8 rising_bits = data & ~state->port_1_last_extra; - const device_config *samples = devtag_get_device(space->machine, "samples"); - const device_config *sn = devtag_get_device(space->machine, "snsnd"); - UINT8 rising_bits = data & ~port_1_last_extra; + if (rising_bits & 0x01) sample_start(state->samples, 4, 4, 0); /* Fleet move */ + if (rising_bits & 0x02) sample_start(state->samples, 5, 8, 0); /* Extra Tank */ - if (rising_bits & 0x01) sample_start(samples, 4, 4, 0); /* Fleet move */ - if (rising_bits & 0x02) sample_start(samples, 5, 8, 0); /* Extra Tank */ + sn76477_enable_w(state->sn, data & 0x04 ? 0:1); /* UFO */ - sn76477_enable_w(sn, data & 0x04 ? 0:1); /* UFO */ - - port_1_last_extra = data; + state->port_1_last_extra = data; } WRITE8_HANDLER( shuttlei_sh_port_2_w ) { - const device_config *samples = devtag_get_device(space->machine, "samples"); + mw8080bw_state *state = (mw8080bw_state *)space->machine->driver_data; + switch (data) { case 0x23: - sample_start(samples, 2, 2, 0); /* Hit */ + sample_start(state->samples, 2, 2, 0); /* Hit */ break; case 0x2b: - sample_start(samples, 0, 0, 0); /* Shoot */ + sample_start(state->samples, 0, 0, 0); /* Shoot */ break; case 0xa3: - sample_start(samples, 3, 7, 0); /* Hit UFO */ + sample_start(state->samples, 3, 7, 0); /* Hit UFO */ break; case 0xab: - sample_start(samples, 1, 1, 0); /* Death */ + sample_start(state->samples, 1, 1, 0); /* Death */ break; } } diff --git a/src/mame/audio/mw8080bw.c b/src/mame/audio/mw8080bw.c index bd15bd2d9e5..410307d0640 100644 --- a/src/mame/audio/mw8080bw.c +++ b/src/mame/audio/mw8080bw.c @@ -5,22 +5,10 @@ ****************************************************************************/ #include "driver.h" -#include "mw8080bw.h" #include "sound/samples.h" #include "sound/sn76477.h" #include "sound/discrete.h" - - - -/************************************* - * - * Globals - * - *************************************/ - -static UINT8 port_1_last; -static UINT8 port_2_last; - +#include "includes/mw8080bw.h" /************************************* @@ -31,11 +19,12 @@ static UINT8 port_2_last; static SOUND_START( samples ) { - /* setup for save states */ - state_save_register_global(machine, port_1_last); - state_save_register_global(machine, port_2_last); -} + mw8080bw_state *state = (mw8080bw_state *)machine->driver_data; + /* setup for save states */ + state_save_register_global(machine, state->port_1_last); + state_save_register_global(machine, state->port_2_last); +} /************************************* @@ -45,12 +34,12 @@ static SOUND_START( samples ) * *************************************/ -#define MIDWAY_TONE_EN NODE_100 -#define MIDWAY_TONE_DATA_L NODE_101 -#define MIDWAY_TONE_DATA_H NODE_102 -#define MIDWAY_TONE_SND NODE_103 -#define MIDWAY_TONE_TRASFORM_OUT NODE_104 -#define MIDWAY_TONE_BEFORE_AMP_SND NODE_105 +#define MIDWAY_TONE_EN NODE_100 +#define MIDWAY_TONE_DATA_L NODE_101 +#define MIDWAY_TONE_DATA_H NODE_102 +#define MIDWAY_TONE_SND NODE_103 +#define MIDWAY_TONE_TRASFORM_OUT NODE_104 +#define MIDWAY_TONE_BEFORE_AMP_SND NODE_105 #define MIDWAY_TONE_GENERATOR(discrete_op_amp_tvca_info) \ @@ -176,29 +165,29 @@ MACHINE_DRIVER_END WRITE8_HANDLER( seawolf_audio_w ) { - const device_config *samples = devtag_get_device(space->machine, "samples"); - UINT8 rising_bits = data & ~port_1_last; + mw8080bw_state *state = (mw8080bw_state *)space->machine->driver_data; + UINT8 rising_bits = data & ~state->port_1_last; /* if (data & 0x01) enable SHIP HIT sound */ - if (rising_bits & 0x01) sample_start(samples, 0, 0, 0); + if (rising_bits & 0x01) sample_start(state->samples, 0, 0, 0); /* if (data & 0x02) enable TORPEDO sound */ - if (rising_bits & 0x02) sample_start(samples, 1, 1, 0); + if (rising_bits & 0x02) sample_start(state->samples, 1, 1, 0); /* if (data & 0x04) enable DIVE sound */ - if (rising_bits & 0x04) sample_start(samples, 2, 2, 0); + if (rising_bits & 0x04) sample_start(state->samples, 2, 2, 0); /* if (data & 0x08) enable SONAR sound */ - if (rising_bits & 0x08) sample_start(samples, 3, 3, 0); + if (rising_bits & 0x08) sample_start(state->samples, 3, 3, 0); /* if (data & 0x10) enable MINE HIT sound */ - if (rising_bits & 0x10) sample_start(samples, 4, 4, 0); + if (rising_bits & 0x10) sample_start(state->samples, 4, 4, 0); coin_counter_w(space->machine, 0, (data >> 5) & 0x01); /* D6 and D7 are not connected */ - port_1_last = data; + state->port_1_last = data; } @@ -242,8 +231,7 @@ MACHINE_DRIVER_END WRITE8_HANDLER( gunfight_audio_w ) { - const device_config *samples0 = devtag_get_device(space->machine, "samples1"); - const device_config *samples1 = devtag_get_device(space->machine, "samples2"); + mw8080bw_state *state = (mw8080bw_state *)space->machine->driver_data; /* D0 and D1 are just tied to 1k resistors */ @@ -257,26 +245,26 @@ WRITE8_HANDLER( gunfight_audio_w ) case 0x01: /* enable LEFT SHOOT sound (left speaker) */ - sample_start(samples0, 0, 0, 0); + sample_start(state->samples1, 0, 0, 0); break; case 0x02: /* enable RIGHT SHOOT sound (right speaker) */ - sample_start(samples1, 0, 0, 0); + sample_start(state->samples2, 0, 0, 0); break; case 0x03: /* enable LEFT HIT sound (left speaker) */ - sample_start(samples0, 0, 1, 0); + sample_start(state->samples1, 0, 1, 0); break; case 0x04: /* enable RIGHT HIT sound (right speaker) */ - sample_start(samples1, 0, 1, 0); + sample_start(state->samples2, 0, 1, 0); break; default: - logerror("%04x: Unknown sh port write %02x\n",cpu_get_pc(space->cpu),data); + logerror("%04x: Unknown sh port write %02x\n", cpu_get_pc(space->cpu), data); break; } } @@ -289,19 +277,19 @@ WRITE8_HANDLER( gunfight_audio_w ) * *************************************/ -#define TORNBASE_SQUAREW_240 NODE_01 -#define TORNBASE_SQUAREW_960 NODE_02 -#define TORNBASE_SQUAREW_120 NODE_03 +#define TORNBASE_SQUAREW_240 NODE_01 +#define TORNBASE_SQUAREW_960 NODE_02 +#define TORNBASE_SQUAREW_120 NODE_03 -#define TORNBASE_TONE_240_EN NODE_04 -#define TORNBASE_TONE_960_EN NODE_05 -#define TORNBASE_TONE_120_EN NODE_06 +#define TORNBASE_TONE_240_EN NODE_04 +#define TORNBASE_TONE_960_EN NODE_05 +#define TORNBASE_TONE_120_EN NODE_06 -#define TORNBASE_TONE_240_SND NODE_07 -#define TORNBASE_TONE_960_SND NODE_08 -#define TORNBASE_TONE_120_SND NODE_09 -#define TORNBASE_TONE_SND NODE_10 -#define TORNBASE_TONE_SND_FILT NODE_11 +#define TORNBASE_TONE_240_SND NODE_07 +#define TORNBASE_TONE_960_SND NODE_08 +#define TORNBASE_TONE_120_SND NODE_09 +#define TORNBASE_TONE_SND NODE_10 +#define TORNBASE_TONE_SND_FILT NODE_11 static DISCRETE_SOUND_START(tornbase) @@ -425,22 +413,22 @@ WRITE8_HANDLER( zzzap_audio_2_w ) *************************************/ /* nodes - inputs */ -#define MAZE_P1_DATA NODE_01 -#define MAZE_P2_DATA NODE_02 -#define MAZE_TONE_TIMING NODE_03 -#define MAZE_COIN NODE_04 +#define MAZE_P1_DATA NODE_01 +#define MAZE_P2_DATA NODE_02 +#define MAZE_TONE_TIMING NODE_03 +#define MAZE_COIN NODE_04 /* nodes - other */ -#define MAZE_JOYSTICK_IN_USE NODE_11 -#define MAZE_AUDIO_ENABLE NODE_12 -#define MAZE_TONE_ENABLE NODE_13 -#define MAZE_GAME_OVER NODE_14 -#define MAZE_R305_306_308 NODE_15 -#define MAZE_R303_309 NODE_16 -#define MAZE_PLAYER_SEL NODE_17 +#define MAZE_JOYSTICK_IN_USE NODE_11 +#define MAZE_AUDIO_ENABLE NODE_12 +#define MAZE_TONE_ENABLE NODE_13 +#define MAZE_GAME_OVER NODE_14 +#define MAZE_R305_306_308 NODE_15 +#define MAZE_R303_309 NODE_16 +#define MAZE_PLAYER_SEL NODE_17 /* nodes - sounds */ -#define MAZE_SND NODE_18 +#define MAZE_SND NODE_18 static const discrete_555_desc maze_555_F2 = @@ -618,21 +606,21 @@ void maze_write_discrete(const device_config *device, UINT8 maze_tone_timing_sta *************************************/ /* nodes - inputs */ -#define BOOTHILL_GAME_ON_EN NODE_01 -#define BOOTHILL_LEFT_SHOT_EN NODE_02 -#define BOOTHILL_RIGHT_SHOT_EN NODE_03 -#define BOOTHILL_LEFT_HIT_EN NODE_04 -#define BOOTHILL_RIGHT_HIT_EN NODE_05 +#define BOOTHILL_GAME_ON_EN NODE_01 +#define BOOTHILL_LEFT_SHOT_EN NODE_02 +#define BOOTHILL_RIGHT_SHOT_EN NODE_03 +#define BOOTHILL_LEFT_HIT_EN NODE_04 +#define BOOTHILL_RIGHT_HIT_EN NODE_05 /* nodes - sounds */ -#define BOOTHILL_NOISE NODE_06 -#define BOOTHILL_L_SHOT_SND NODE_07 -#define BOOTHILL_R_SHOT_SND NODE_08 -#define BOOTHILL_L_HIT_SND NODE_09 -#define BOOTHILL_R_HIT_SND NODE_10 +#define BOOTHILL_NOISE NODE_06 +#define BOOTHILL_L_SHOT_SND NODE_07 +#define BOOTHILL_R_SHOT_SND NODE_08 +#define BOOTHILL_L_HIT_SND NODE_09 +#define BOOTHILL_R_HIT_SND NODE_10 /* nodes - adjusters */ -#define BOOTHILL_MUSIC_ADJ NODE_11 +#define BOOTHILL_MUSIC_ADJ NODE_11 static const discrete_op_amp_tvca_info boothill_tone_tvca_info = @@ -862,23 +850,23 @@ WRITE8_DEVICE_HANDLER( boothill_audio_w ) *************************************/ /* nodes - inputs */ -#define CHECKMAT_BOOM_EN NODE_01 -#define CHECKMAT_TONE_EN NODE_02 -#define CHECKMAT_TONE_DATA_45 NODE_03 -#define CHECKMAT_TONE_DATA_67 NODE_04 +#define CHECKMAT_BOOM_EN NODE_01 +#define CHECKMAT_TONE_EN NODE_02 +#define CHECKMAT_TONE_DATA_45 NODE_03 +#define CHECKMAT_TONE_DATA_67 NODE_04 /* nodes - other */ -#define CHECKMAT_R401_402_400 NODE_06 -#define CHECKMAT_R407_406_410 NODE_07 +#define CHECKMAT_R401_402_400 NODE_06 +#define CHECKMAT_R407_406_410 NODE_07 /* nodes - sounds */ -#define CHECKMAT_BOOM_SND NODE_10 -#define CHECKMAT_TONE_SND NODE_11 -#define CHECKMAT_FINAL_SND NODE_12 +#define CHECKMAT_BOOM_SND NODE_10 +#define CHECKMAT_TONE_SND NODE_11 +#define CHECKMAT_FINAL_SND NODE_12 /* nodes - adjusters */ -#define CHECKMAT_R309 NODE_15 -#define CHECKMAT_R411 NODE_16 +#define CHECKMAT_R309 NODE_15 +#define CHECKMAT_R411 NODE_16 static const discrete_comp_adder_table checkmat_r401_402_400 = @@ -1090,25 +1078,25 @@ WRITE8_DEVICE_HANDLER( checkmat_audio_w ) *************************************/ /* nodes - inputs */ -#define DESERTGU_GAME_ON_EN NODE_01 -#define DESERTGU_RIFLE_SHOT_EN NODE_02 -#define DESERTGU_BOTTLE_HIT_EN NODE_03 -#define DESERTGU_ROAD_RUNNER_HIT_EN NODE_04 -#define DESERTGU_CREATURE_HIT_EN NODE_05 -#define DESERTGU_ROADRUNNER_BEEP_BEEP_EN NODE_06 -#define DESERTGU_TRIGGER_CLICK_EN NODE_07 +#define DESERTGU_GAME_ON_EN NODE_01 +#define DESERTGU_RIFLE_SHOT_EN NODE_02 +#define DESERTGU_BOTTLE_HIT_EN NODE_03 +#define DESERTGU_ROAD_RUNNER_HIT_EN NODE_04 +#define DESERTGU_CREATURE_HIT_EN NODE_05 +#define DESERTGU_ROADRUNNER_BEEP_BEEP_EN NODE_06 +#define DESERTGU_TRIGGER_CLICK_EN NODE_07 /* nodes - sounds */ -#define DESERTGU_NOISE NODE_08 -#define DESERTGU_RIFLE_SHOT_SND NODE_09 -#define DESERTGU_BOTTLE_HIT_SND NODE_10 -#define DESERTGU_ROAD_RUNNER_HIT_SND NODE_11 -#define DESERTGU_CREATURE_HIT_SND NODE_12 -#define DESERTGU_ROADRUNNER_BEEP_BEEP_SND NODE_13 -#define DESERTGU_TRIGGER_CLICK_SND DESERTGU_TRIGGER_CLICK_EN +#define DESERTGU_NOISE NODE_08 +#define DESERTGU_RIFLE_SHOT_SND NODE_09 +#define DESERTGU_BOTTLE_HIT_SND NODE_10 +#define DESERTGU_ROAD_RUNNER_HIT_SND NODE_11 +#define DESERTGU_CREATURE_HIT_SND NODE_12 +#define DESERTGU_ROADRUNNER_BEEP_BEEP_SND NODE_13 +#define DESERTGU_TRIGGER_CLICK_SND DESERTGU_TRIGGER_CLICK_EN /* nodes - adjusters */ -#define DESERTGU_MUSIC_ADJ NODE_15 +#define DESERTGU_MUSIC_ADJ NODE_15 static const discrete_op_amp_tvca_info desertgu_rifle_shot_tvca_info = @@ -1296,13 +1284,15 @@ WRITE8_DEVICE_HANDLER( desertgu_audio_1_w ) WRITE8_DEVICE_HANDLER( desertgu_audio_2_w ) { + mw8080bw_state *state = (mw8080bw_state *)device->machine->driver_data; + discrete_sound_w(device, DESERTGU_ROADRUNNER_BEEP_BEEP_EN, (data >> 0) & 0x01); discrete_sound_w(device, DESERTGU_TRIGGER_CLICK_EN, (data >> 1) & 0x01); output_set_value("KICKER", (data >> 2) & 0x01); - desertgun_set_controller_select((data >> 3) & 0x01); + state->desertgun_controller_select = (data >> 3) & 0x01; /* D4-D7 are not connected */ } @@ -1318,21 +1308,21 @@ WRITE8_DEVICE_HANDLER( desertgu_audio_2_w ) *************************************/ /* nodes - inputs */ -#define DPLAY_GAME_ON_EN NODE_01 -#define DPLAY_TONE_ON_EN NODE_02 -#define DPLAY_SIREN_EN NODE_03 -#define DPLAY_WHISTLE_EN NODE_04 -#define DPLAY_CHEER_EN NODE_05 +#define DPLAY_GAME_ON_EN NODE_01 +#define DPLAY_TONE_ON_EN NODE_02 +#define DPLAY_SIREN_EN NODE_03 +#define DPLAY_WHISTLE_EN NODE_04 +#define DPLAY_CHEER_EN NODE_05 /* nodes - sounds */ -#define DPLAY_NOISE NODE_06 -#define DPLAY_TONE_SND NODE_07 -#define DPLAY_SIREN_SND NODE_08 -#define DPLAY_WHISTLE_SND NODE_09 -#define DPLAY_CHEER_SND NODE_10 +#define DPLAY_NOISE NODE_06 +#define DPLAY_TONE_SND NODE_07 +#define DPLAY_SIREN_SND NODE_08 +#define DPLAY_WHISTLE_SND NODE_09 +#define DPLAY_CHEER_SND NODE_10 /* nodes - adjusters */ -#define DPLAY_MUSIC_ADJ NODE_11 +#define DPLAY_MUSIC_ADJ NODE_11 static const discrete_lfsr_desc dplay_lfsr = @@ -1603,9 +1593,8 @@ WRITE8_HANDLER( gmissile_audio_1_w ) reversed (D5=R, D7=L), but the software confirms that ours is right */ - const device_config *samples0 = devtag_get_device(space->machine, "samples1"); - const device_config *samples1 = devtag_get_device(space->machine, "samples2"); - UINT8 rising_bits = data & ~port_1_last; + mw8080bw_state *state = (mw8080bw_state *)space->machine->driver_data; + UINT8 rising_bits = data & ~state->port_1_last; /* D0 and D1 are not connected */ @@ -1614,20 +1603,20 @@ WRITE8_HANDLER( gmissile_audio_1_w ) sound_global_enable(space->machine, (data >> 3) & 0x01); /* if (data & 0x10) enable RIGHT MISSILE sound (goes to right speaker) */ - if (rising_bits & 0x10) sample_start(samples1, 0, 0, 0); + if (rising_bits & 0x10) sample_start(state->samples2, 0, 0, 0); /* if (data & 0x20) enable LEFT EXPLOSION sound (goes to left speaker) */ output_set_value("L_EXP_LIGHT", (data >> 5) & 0x01); - if (rising_bits & 0x20) sample_start(samples0, 0, 1, 0); + if (rising_bits & 0x20) sample_start(state->samples1, 0, 1, 0); /* if (data & 0x40) enable LEFT MISSILE sound (goes to left speaker) */ - if (rising_bits & 0x40) sample_start(samples0, 0, 0, 0); + if (rising_bits & 0x40) sample_start(state->samples1, 0, 0, 0); /* if (data & 0x80) enable RIGHT EXPLOSION sound (goes to right speaker) */ output_set_value("R_EXP_LIGHT", (data >> 7) & 0x01); - if (rising_bits & 0x80) sample_start(samples1, 0, 1, 0); + if (rising_bits & 0x80) sample_start(state->samples2, 0, 1, 0); - port_1_last = data; + state->port_1_last = data; } @@ -1699,9 +1688,8 @@ MACHINE_DRIVER_END WRITE8_HANDLER( m4_audio_1_w ) { - const device_config *samples0 = devtag_get_device(space->machine, "samples1"); - const device_config *samples1 = devtag_get_device(space->machine, "samples2"); - UINT8 rising_bits = data & ~port_1_last; + mw8080bw_state *state = (mw8080bw_state *)space->machine->driver_data; + UINT8 rising_bits = data & ~state->port_1_last; /* D0 and D1 are not connected */ @@ -1710,32 +1698,31 @@ WRITE8_HANDLER( m4_audio_1_w ) sound_global_enable(space->machine, (data >> 3) & 0x01); /* if (data & 0x10) enable LEFT PLAYER SHOT sound (goes to left speaker) */ - if (rising_bits & 0x10) sample_start(samples0, 0, 0, 0); + if (rising_bits & 0x10) sample_start(state->samples1, 0, 0, 0); /* if (data & 0x20) enable RIGHT PLAYER SHOT sound (goes to right speaker) */ - if (rising_bits & 0x20) sample_start(samples1, 0, 0, 0); + if (rising_bits & 0x20) sample_start(state->samples2, 0, 0, 0); /* if (data & 0x40) enable LEFT PLAYER EXPLOSION sound via 300K res (goes to left speaker) */ - if (rising_bits & 0x40) sample_start(samples0, 1, 1, 0); + if (rising_bits & 0x40) sample_start(state->samples1, 1, 1, 0); /* if (data & 0x80) enable RIGHT PLAYER EXPLOSION sound via 300K res (goes to right speaker) */ - if (rising_bits & 0x80) sample_start(samples1, 1, 1, 0); + if (rising_bits & 0x80) sample_start(state->samples2, 1, 1, 0); - port_1_last = data; + state->port_1_last = data; } WRITE8_HANDLER( m4_audio_2_w ) { - const device_config *samples0 = devtag_get_device(space->machine, "samples1"); - const device_config *samples1 = devtag_get_device(space->machine, "samples2"); - UINT8 rising_bits = data & ~port_2_last; + mw8080bw_state *state = (mw8080bw_state *)space->machine->driver_data; + UINT8 rising_bits = data & ~state->port_2_last; /* if (data & 0x01) enable LEFT PLAYER EXPLOSION sound via 510K res (goes to left speaker) */ - if (rising_bits & 0x01) sample_start(samples0, 1, 1, 0); + if (rising_bits & 0x01) sample_start(state->samples1, 1, 1, 0); /* if (data & 0x02) enable RIGHT PLAYER EXPLOSION sound via 510K res (goes to right speaker) */ - if (rising_bits & 0x02) sample_start(samples1, 1, 1, 0); + if (rising_bits & 0x02) sample_start(state->samples2, 1, 1, 0); /* if (data & 0x04) enable LEFT TANK MOTOR sound (goes to left speaker) */ @@ -1749,7 +1736,7 @@ WRITE8_HANDLER( m4_audio_2_w ) /* D6 and D7 are not connected */ - port_2_last = data; + state->port_2_last = data; } @@ -1763,20 +1750,20 @@ WRITE8_HANDLER( m4_audio_2_w ) *************************************/ /* nodes - inputs */ -#define CLOWNS_POP_BOTTOM_EN NODE_01 -#define CLOWNS_POP_MIDDLE_EN NODE_02 -#define CLOWNS_POP_TOP_EN NODE_03 -#define CLOWNS_SPRINGBOARD_HIT_EN NODE_04 -#define CLOWNS_SPRINGBOARD_MISS_EN NODE_05 +#define CLOWNS_POP_BOTTOM_EN NODE_01 +#define CLOWNS_POP_MIDDLE_EN NODE_02 +#define CLOWNS_POP_TOP_EN NODE_03 +#define CLOWNS_SPRINGBOARD_HIT_EN NODE_04 +#define CLOWNS_SPRINGBOARD_MISS_EN NODE_05 /* nodes - sounds */ -#define CLOWNS_NOISE NODE_06 -#define CLOWNS_POP_SND NODE_07 -#define CLOWNS_SB_HIT_SND NODE_08 -#define CLOWNS_SB_MISS_SND NODE_09 +#define CLOWNS_NOISE NODE_06 +#define CLOWNS_POP_SND NODE_07 +#define CLOWNS_SB_HIT_SND NODE_08 +#define CLOWNS_SB_MISS_SND NODE_09 /* nodes - adjusters */ -#define CLOWNS_R507_POT NODE_11 +#define CLOWNS_R507_POT NODE_11 static const discrete_op_amp_tvca_info clowns_pop_tvca_info = @@ -1963,9 +1950,10 @@ MACHINE_DRIVER_END WRITE8_HANDLER( clowns_audio_1_w ) { + mw8080bw_state *state = (mw8080bw_state *)space->machine->driver_data; coin_counter_w(space->machine, 0, (data >> 0) & 0x01); - clowns_set_controller_select((data >> 1) & 0x01); + state->clowns_controller_select = (data >> 1) & 0x01; /* D2-D7 are not connected */ } @@ -1973,8 +1961,8 @@ WRITE8_HANDLER( clowns_audio_1_w ) WRITE8_DEVICE_HANDLER( clowns_audio_2_w ) { - const device_config *samples = devtag_get_device(device->machine, "samples"); - UINT8 rising_bits = data & ~port_2_last; + mw8080bw_state *state = (mw8080bw_state *)device->machine->driver_data; + UINT8 rising_bits = data & ~state->port_2_last; discrete_sound_w(device, CLOWNS_POP_BOTTOM_EN, (data >> 0) & 0x01); @@ -1986,11 +1974,11 @@ WRITE8_DEVICE_HANDLER( clowns_audio_2_w ) discrete_sound_w(device, CLOWNS_SPRINGBOARD_HIT_EN, (data >> 4) & 0x01); - if (rising_bits & 0x20) sample_start(samples, 0, 0, 0); /* springboard miss */ + if (rising_bits & 0x20) sample_start(state->samples, 0, 0, 0); /* springboard miss */ /* D6 and D7 are not connected */ - port_2_last = data; + state->port_2_last = data; } @@ -2004,24 +1992,24 @@ WRITE8_DEVICE_HANDLER( clowns_audio_2_w ) *************************************/ /* Discrete Sound Input Nodes */ -#define SPACWALK_TARGET_HIT_BOTTOM_EN NODE_01 -#define SPACWALK_TARGET_HIT_MIDDLE_EN NODE_02 -#define SPACWALK_TARGET_HIT_TOP_EN NODE_03 -#define SPACWALK_SPRINGBOARD_HIT1_EN NODE_04 -#define SPACWALK_SPRINGBOARD_HIT2_EN NODE_05 -#define SPACWALK_SPRINGBOARD_MISS_EN NODE_06 -#define SPACWALK_SPACE_SHIP_EN NODE_07 +#define SPACWALK_TARGET_HIT_BOTTOM_EN NODE_01 +#define SPACWALK_TARGET_HIT_MIDDLE_EN NODE_02 +#define SPACWALK_TARGET_HIT_TOP_EN NODE_03 +#define SPACWALK_SPRINGBOARD_HIT1_EN NODE_04 +#define SPACWALK_SPRINGBOARD_HIT2_EN NODE_05 +#define SPACWALK_SPRINGBOARD_MISS_EN NODE_06 +#define SPACWALK_SPACE_SHIP_EN NODE_07 /* Discrete Sound Output Nodes */ -#define SPACWALK_NOISE NODE_10 -#define SPACWALK_TARGET_HIT_SND NODE_11 -#define SPACWALK_SPRINGBOARD_HIT1_SND NODE_12 -#define SPACWALK_SPRINGBOARD_HIT2_SND NODE_13 -#define SPACWALK_SPRINGBOARD_MISS_SND NODE_14 -#define SPACWALK_SPACE_SHIP_SND NODE_15 +#define SPACWALK_NOISE NODE_10 +#define SPACWALK_TARGET_HIT_SND NODE_11 +#define SPACWALK_SPRINGBOARD_HIT1_SND NODE_12 +#define SPACWALK_SPRINGBOARD_HIT2_SND NODE_13 +#define SPACWALK_SPRINGBOARD_MISS_SND NODE_14 +#define SPACWALK_SPACE_SHIP_SND NODE_15 /* Adjusters */ -#define SPACWALK_R507_POT NODE_19 +#define SPACWALK_R507_POT NODE_19 /* Parts List - Resistors */ #define SPACWALK_R200 RES_K(820) @@ -2329,9 +2317,11 @@ MACHINE_DRIVER_END WRITE8_DEVICE_HANDLER( spacwalk_audio_1_w ) { + mw8080bw_state *state = (mw8080bw_state *)device->machine->driver_data; + coin_counter_w(device->machine, 0, (data >> 0) & 0x01); - clowns_set_controller_select((data >> 1) & 0x01); + state->clowns_controller_select = (data >> 1) & 0x01; sound_global_enable(device->machine, (data >> 2) & 0x01); @@ -2364,19 +2354,19 @@ WRITE8_DEVICE_HANDLER( spacwalk_audio_2_w ) *************************************/ /* Discrete Sound Input Nodes */ -#define SHUFFLE_ROLLING_1_EN NODE_01 -#define SHUFFLE_ROLLING_2_EN NODE_02 -#define SHUFFLE_ROLLING_3_EN NODE_03 -#define SHUFFLE_FOUL_EN NODE_04 -#define SHUFFLE_ROLLOVER_EN NODE_05 -#define SHUFFLE_CLICK_EN NODE_06 +#define SHUFFLE_ROLLING_1_EN NODE_01 +#define SHUFFLE_ROLLING_2_EN NODE_02 +#define SHUFFLE_ROLLING_3_EN NODE_03 +#define SHUFFLE_FOUL_EN NODE_04 +#define SHUFFLE_ROLLOVER_EN NODE_05 +#define SHUFFLE_CLICK_EN NODE_06 /* Discrete Sound Output Nodes */ -#define SHUFFLE_NOISE NODE_10 -#define SHUFFLE_ROLLING_SND NODE_11 -#define SHUFFLE_FOUL_SND NODE_12 -#define SHUFFLE_ROLLOVER_SND NODE_13 -#define SHUFFLE_CLICK_SND NODE_14 +#define SHUFFLE_NOISE NODE_10 +#define SHUFFLE_ROLLING_SND NODE_11 +#define SHUFFLE_FOUL_SND NODE_12 +#define SHUFFLE_ROLLOVER_SND NODE_13 +#define SHUFFLE_CLICK_SND NODE_14 /* Parts List - Resistors */ #define SHUFFLE_R300 RES_K(33) @@ -2677,23 +2667,23 @@ static const sn76477_interface spcenctr_sn76477_interface = /* nodes - inputs */ -#define SPCENCTR_ENEMY_SHIP_SHOT_EN NODE_01 -#define SPCENCTR_PLAYER_SHOT_EN NODE_02 -#define SPCENCTR_SCREECH_EN NODE_03 -#define SPCENCTR_CRASH_EN NODE_04 -#define SPCENCTR_EXPLOSION_EN NODE_05 -#define SPCENCTR_BONUS_EN NODE_06 -#define SPCENCTR_WIND_DATA NODE_07 +#define SPCENCTR_ENEMY_SHIP_SHOT_EN NODE_01 +#define SPCENCTR_PLAYER_SHOT_EN NODE_02 +#define SPCENCTR_SCREECH_EN NODE_03 +#define SPCENCTR_CRASH_EN NODE_04 +#define SPCENCTR_EXPLOSION_EN NODE_05 +#define SPCENCTR_BONUS_EN NODE_06 +#define SPCENCTR_WIND_DATA NODE_07 /* nodes - sounds */ -#define SPCENCTR_NOISE NODE_10 -#define SPCENCTR_ENEMY_SHIP_SHOT_SND NODE_11 -#define SPCENCTR_PLAYER_SHOT_SND NODE_12 -#define SPCENCTR_SCREECH_SND NODE_13 -#define SPCENCTR_CRASH_SND NODE_14 -#define SPCENCTR_EXPLOSION_SND NODE_15 -#define SPCENCTR_BONUS_SND NODE_16 -#define SPCENCTR_WIND_SND NODE_17 +#define SPCENCTR_NOISE NODE_10 +#define SPCENCTR_ENEMY_SHIP_SHOT_SND NODE_11 +#define SPCENCTR_PLAYER_SHOT_SND NODE_12 +#define SPCENCTR_SCREECH_SND NODE_13 +#define SPCENCTR_CRASH_SND NODE_14 +#define SPCENCTR_EXPLOSION_SND NODE_15 +#define SPCENCTR_BONUS_SND NODE_16 +#define SPCENCTR_WIND_SND NODE_17 static const discrete_op_amp_info spcenctr_enemy_ship_shot_op_amp_E1 = @@ -3175,6 +3165,8 @@ WRITE8_DEVICE_HANDLER( spcenctr_audio_1_w ) WRITE8_DEVICE_HANDLER( spcenctr_audio_2_w ) { + mw8080bw_state *state = (mw8080bw_state *)device->machine->driver_data; + /* set WIND SOUND FREQ(data & 0x0f) 0, if no wind */ discrete_sound_w(device, SPCENCTR_EXPLOSION_EN, (data >> 4) & 0x01); @@ -3183,25 +3175,25 @@ WRITE8_DEVICE_HANDLER( spcenctr_audio_2_w ) /* D6 and D7 are not connected */ - port_2_last = data; + state->port_2_last = data; } WRITE8_DEVICE_HANDLER( spcenctr_audio_3_w ) { - const device_config *sn = devtag_get_device(device->machine, "snsnd"); + mw8080bw_state *state = (mw8080bw_state *)device->machine->driver_data; /* if (data & 0x01) enable SCREECH (hit the sides) sound */ discrete_sound_w(device, SPCENCTR_ENEMY_SHIP_SHOT_EN, (data >> 1) & 0x01); - spcenctr_set_strobe_state((data >> 2) & 0x01); + state->spcenctr_strobe_state = (data >> 2) & 0x01; output_set_value("LAMP", (data >> 3) & 0x01); discrete_sound_w(device, SPCENCTR_BONUS_EN, (data >> 4) & 0x01); - sn76477_enable_w(sn, (data >> 5) & 0x01); /* saucer sound */ + sn76477_enable_w(state->sn, (data >> 5) & 0x01); /* saucer sound */ /* D6 and D7 are not connected */ } @@ -3242,11 +3234,11 @@ MACHINE_DRIVER_END WRITE8_HANDLER( phantom2_audio_1_w ) { - const device_config *samples = devtag_get_device(space->machine, "samples"); - UINT8 rising_bits = data & ~port_1_last; + mw8080bw_state *state = (mw8080bw_state *)space->machine->driver_data; + UINT8 rising_bits = data & ~state->port_1_last; /* if (data & 0x01) enable PLAYER SHOT sound */ - if (rising_bits & 0x01) sample_start(samples, 0, 0, 0); + if (rising_bits & 0x01) sample_start(state->samples, 0, 0, 0); /* if (data & 0x02) enable ENEMY SHOT sound */ @@ -3258,25 +3250,25 @@ WRITE8_HANDLER( phantom2_audio_1_w ) /* D5-D7 are not connected */ - port_1_last = data; + state->port_1_last = data; } WRITE8_HANDLER( phantom2_audio_2_w ) { - const device_config *samples = devtag_get_device(space->machine, "samples"); - UINT8 rising_bits = data & ~port_2_last; + mw8080bw_state *state = (mw8080bw_state *)space->machine->driver_data; + UINT8 rising_bits = data & ~state->port_2_last; /* D0-D2 are not connected */ /* if (data & 0x08) enable EXPLOSION sound */ - if (rising_bits & 0x08) sample_start(samples, 1, 1, 0); + if (rising_bits & 0x08) sample_start(state->samples, 1, 1, 0); output_set_value("EXPLAMP", (data >> 4) & 0x01); /* set JET SOUND FREQ((data >> 5) & 0x07) 0, if no jet sound */ - port_2_last = data; + state->port_2_last = data; } @@ -3291,10 +3283,10 @@ WRITE8_HANDLER( phantom2_audio_2_w ) *************************************/ /* nodes - inputs */ -#define BOWLER_FOWL_EN NODE_01 +#define BOWLER_FOWL_EN NODE_01 /* nodes - sounds */ -#define BOWLER_FOWL_SND NODE_10 +#define BOWLER_FOWL_SND NODE_10 static const discrete_op_amp_tvca_info bowler_fowl_tvca = @@ -3527,21 +3519,21 @@ MACHINE_DRIVER_END /* nodes - inputs */ -#define INVADERS_SAUCER_HIT_EN 01 -#define INVADERS_FLEET_DATA 02 -#define INVADERS_BONUS_MISSLE_BASE_EN 03 -#define INVADERS_INVADER_HIT_EN 04 -#define INVADERS_EXPLOSION_EN 05 -#define INVADERS_MISSILE_EN 06 +#define INVADERS_SAUCER_HIT_EN 01 +#define INVADERS_FLEET_DATA 02 +#define INVADERS_BONUS_MISSLE_BASE_EN 03 +#define INVADERS_INVADER_HIT_EN 04 +#define INVADERS_EXPLOSION_EN 05 +#define INVADERS_MISSILE_EN 06 /* nodes - sounds */ -#define INVADERS_NOISE NODE_10 -#define INVADERS_SAUCER_HIT_SND 11 -#define INVADERS_FLEET_SND 12 -#define INVADERS_BONUS_MISSLE_BASE_SND 13 -#define INVADERS_INVADER_HIT_SND 14 -#define INVADERS_EXPLOSION_SND 15 -#define INVADERS_MISSILE_SND 16 +#define INVADERS_NOISE NODE_10 +#define INVADERS_SAUCER_HIT_SND 11 +#define INVADERS_FLEET_SND 12 +#define INVADERS_BONUS_MISSLE_BASE_SND 13 +#define INVADERS_INVADER_HIT_SND 14 +#define INVADERS_EXPLOSION_SND 15 +#define INVADERS_MISSILE_SND 16 static const discrete_op_amp_info invaders_saucer_hit_op_amp_B3_9 = @@ -4095,9 +4087,9 @@ MACHINE_DRIVER_END WRITE8_DEVICE_HANDLER( invaders_audio_1_w ) { - const device_config *sn = devtag_get_device(device->machine, "snsnd"); + mw8080bw_state *state = (mw8080bw_state *)device->machine->driver_data; - sn76477_enable_w(sn, (~data >> 0) & 0x01); /* saucer sound */ + sn76477_enable_w(state->sn, (~data >> 0) & 0x01); /* saucer sound */ discrete_sound_w(device, INVADERS_NODE(INVADERS_MISSILE_EN, 1), data & 0x02); discrete_sound_w(device, INVADERS_NODE(INVADERS_EXPLOSION_EN, 1), data & 0x04); @@ -4112,13 +4104,15 @@ WRITE8_DEVICE_HANDLER( invaders_audio_1_w ) WRITE8_DEVICE_HANDLER( invaders_audio_2_w ) { + mw8080bw_state *state = (mw8080bw_state *)device->machine->driver_data; + discrete_sound_w(device, INVADERS_NODE(INVADERS_FLEET_DATA, 1), data & 0x0f); discrete_sound_w(device, INVADERS_NODE(INVADERS_SAUCER_HIT_EN, 1), data & 0x10); /* the flip screen line is only connected on the cocktail PCB */ if (invaders_is_cabinet_cocktail(device->machine)) { - invaders_set_flip_screen((data >> 5) & 0x01); + state->invaders_flip_screen = (data >> 5) & 0x01; } /* D6 and D7 are not connected */ @@ -4137,19 +4131,19 @@ WRITE8_DEVICE_HANDLER( invaders_audio_2_w ) *************************************/ /* nodes - inputs */ -#define BLUESHRK_OCTOPUS_EN NODE_01 -#define BLUESHRK_HIT_EN NODE_02 -#define BLUESHRK_SHARK_EN NODE_03 -#define BLUESHRK_SHOT_EN NODE_04 -#define BLUESHRK_GAME_ON_EN NODE_05 +#define BLUESHRK_OCTOPUS_EN NODE_01 +#define BLUESHRK_HIT_EN NODE_02 +#define BLUESHRK_SHARK_EN NODE_03 +#define BLUESHRK_SHOT_EN NODE_04 +#define BLUESHRK_GAME_ON_EN NODE_05 /* nodes - sounds */ -#define BLUESHRK_NOISE_1 NODE_11 -#define BLUESHRK_NOISE_2 NODE_12 -#define BLUESHRK_OCTOPUS_SND NODE_13 -#define BLUESHRK_HIT_SND NODE_14 -#define BLUESHRK_SHARK_SND NODE_15 -#define BLUESHRK_SHOT_SND NODE_16 +#define BLUESHRK_NOISE_1 NODE_11 +#define BLUESHRK_NOISE_2 NODE_12 +#define BLUESHRK_OCTOPUS_SND NODE_13 +#define BLUESHRK_HIT_SND NODE_14 +#define BLUESHRK_SHARK_SND NODE_15 +#define BLUESHRK_SHOT_SND NODE_16 /* Parts List - Resistors */ #define BLUESHRK_R300 RES_M(1) @@ -4726,9 +4720,9 @@ MACHINE_DRIVER_END WRITE8_DEVICE_HANDLER( invad2ct_audio_1_w ) { - const device_config *sn = devtag_get_device(device->machine, "sn1"); + mw8080bw_state *state = (mw8080bw_state *)device->machine->driver_data; - sn76477_enable_w(sn, (~data >> 0) & 0x01); /* saucer sound */ + sn76477_enable_w(state->sn1, (~data >> 0) & 0x01); /* saucer sound */ discrete_sound_w(device, INVADERS_NODE(INVADERS_MISSILE_EN, 1), data & 0x02); discrete_sound_w(device, INVADERS_NODE(INVADERS_EXPLOSION_EN, 1), data & 0x04); @@ -4752,9 +4746,9 @@ WRITE8_DEVICE_HANDLER( invad2ct_audio_2_w ) WRITE8_DEVICE_HANDLER( invad2ct_audio_3_w ) { - const device_config *sn = devtag_get_device(device->machine, "sn2"); + mw8080bw_state *state = (mw8080bw_state *)device->machine->driver_data; - sn76477_enable_w(sn, (~data >> 0) & 0x01); /* saucer sound */ + sn76477_enable_w(state->sn2, (~data >> 0) & 0x01); /* saucer sound */ discrete_sound_w(device, INVADERS_NODE(INVADERS_MISSILE_EN, 2), data & 0x02); discrete_sound_w(device, INVADERS_NODE(INVADERS_EXPLOSION_EN, 2), data & 0x04); diff --git a/src/mame/drivers/8080bw.c b/src/mame/drivers/8080bw.c index 81382b6e82a..ab827621969 100644 --- a/src/mame/drivers/8080bw.c +++ b/src/mame/drivers/8080bw.c @@ -89,11 +89,10 @@ #include "driver.h" #include "cpu/m6800/m6800.h" #include "cpu/i8085/i8085.h" +#include "machine/mb14241.h" #include "sound/speaker.h" #include "deprecat.h" -#include "8080bw.h" -#include "mw8080bw.h" -#include "machine/mb14241.h" +#include "includes/mw8080bw.h" #include "invrvnge.lh" #include "shuttlei.lh" @@ -106,9 +105,9 @@ static MACHINE_START( extra_8080bw ) { - MACHINE_START_CALL(extra_8080bw_sh); - MACHINE_START_CALL(extra_8080bw_vh); - MACHINE_START_CALL(mw8080bw); + MACHINE_START_CALL(extra_8080bw_sh); + MACHINE_START_CALL(extra_8080bw_vh); + MACHINE_START_CALL(mw8080bw); } /*******************************************************/ @@ -203,13 +202,13 @@ INPUT_PORTS_END /*******************************************************/ static ADDRESS_MAP_START( invadpt2_io_map, ADDRESS_SPACE_IO, 8 ) - AM_RANGE(0x00, 0x00) AM_READ_PORT("IN0") - AM_RANGE(0x01, 0x01) AM_READ_PORT("IN1") - AM_RANGE(0x02, 0x02) AM_READ_PORT("IN2") AM_DEVWRITE("mb14241", mb14241_shift_count_w) - AM_RANGE(0x03, 0x03) AM_DEVREAD("mb14241", mb14241_shift_result_r) AM_WRITE(invadpt2_sh_port_1_w) - AM_RANGE(0x04, 0x04) AM_DEVWRITE("mb14241", mb14241_shift_data_w) - AM_RANGE(0x05, 0x05) AM_WRITE(invadpt2_sh_port_2_w) - AM_RANGE(0x06, 0x06) AM_WRITE(watchdog_reset_w) + AM_RANGE(0x00, 0x00) AM_READ_PORT("IN0") + AM_RANGE(0x01, 0x01) AM_READ_PORT("IN1") + AM_RANGE(0x02, 0x02) AM_READ_PORT("IN2") AM_DEVWRITE("mb14241", mb14241_shift_count_w) + AM_RANGE(0x03, 0x03) AM_DEVREAD("mb14241", mb14241_shift_result_r) AM_WRITE(invadpt2_sh_port_1_w) + AM_RANGE(0x04, 0x04) AM_DEVWRITE("mb14241", mb14241_shift_data_w) + AM_RANGE(0x05, 0x05) AM_WRITE(invadpt2_sh_port_2_w) + AM_RANGE(0x06, 0x06) AM_WRITE(watchdog_reset_w) ADDRESS_MAP_END static INPUT_PORTS_START( invadpt2 ) @@ -240,14 +239,14 @@ INPUT_PORTS_END static MACHINE_DRIVER_START( invadpt2 ) - /* basic machine hardware */ + /* basic machine hardware */ MDRV_IMPORT_FROM(mw8080bw_root) MDRV_CPU_MODIFY("maincpu") MDRV_CPU_IO_MAP(invadpt2_io_map) MDRV_MACHINE_START(extra_8080bw) - /* 60 Hz signal clocks two LS161. Ripple carry will */ - /* reset circuit, if LS161 not cleared before. */ + /* 60 Hz signal clocks two LS161. Ripple carry will */ + /* reset circuit, if LS161 not cleared before. */ MDRV_WATCHDOG_VBLANK_INIT(255) /* add shifter */ @@ -256,7 +255,7 @@ static MACHINE_DRIVER_START( invadpt2 ) /* video hardware */ MDRV_VIDEO_UPDATE(invadpt2) - /* sound hardware */ + /* sound hardware */ MDRV_IMPORT_FROM(invaders_samples_audio) MACHINE_DRIVER_END @@ -374,7 +373,7 @@ INPUT_PORTS_END static MACHINE_DRIVER_START( astropal ) - /* basic machine hardware */ + /* basic machine hardware */ MDRV_IMPORT_FROM(invaders) MDRV_CPU_MODIFY("maincpu") MDRV_CPU_IO_MAP(astropal_io_map) @@ -389,9 +388,9 @@ MACHINE_DRIVER_END static ADDRESS_MAP_START( cosmo_map, ADDRESS_SPACE_PROGRAM, 8 ) AM_RANGE(0x0000, 0x1fff) AM_ROM - AM_RANGE(0x2000, 0x3fff) AM_RAM AM_BASE(&mw8080bw_ram) AM_SIZE(&mw8080bw_ram_size) + AM_RANGE(0x2000, 0x3fff) AM_RAM AM_BASE_SIZE_MEMBER(mw8080bw_state, main_ram, main_ram_size) AM_RANGE(0x4000, 0x57ff) AM_ROM - AM_RANGE(0x5c00, 0x5fff) AM_RAM AM_BASE(&c8080bw_colorram) + AM_RANGE(0x5c00, 0x5fff) AM_RAM AM_BASE_MEMBER(mw8080bw_state, colorram) ADDRESS_MAP_END /* at least one of these MWA8_NOPs must be sound related */ @@ -399,8 +398,8 @@ static ADDRESS_MAP_START( cosmo_io_map, ADDRESS_SPACE_IO, 8 ) AM_RANGE(0x00, 0x00) AM_READ_PORT("IN0") AM_WRITENOP AM_RANGE(0x01, 0x01) AM_READ_PORT("IN1") AM_WRITENOP AM_RANGE(0x02, 0x02) AM_READ_PORT("IN2") AM_WRITENOP - AM_RANGE(0x03, 0x03) AM_WRITE(invadpt2_sh_port_1_w) - AM_RANGE(0x05, 0x05) AM_WRITE(cosmo_sh_port_2_w) + AM_RANGE(0x03, 0x03) AM_WRITE(invadpt2_sh_port_1_w) + AM_RANGE(0x05, 0x05) AM_WRITE(cosmo_sh_port_2_w) AM_RANGE(0x06, 0x06) AM_WRITE(watchdog_reset_w) AM_RANGE(0x07, 0x07) AM_WRITENOP ADDRESS_MAP_END @@ -424,17 +423,17 @@ INPUT_PORTS_END static MACHINE_DRIVER_START( cosmo ) - /* basic machine hardware */ + /* basic machine hardware */ MDRV_IMPORT_FROM(mw8080bw_root) MDRV_CPU_MODIFY("maincpu") MDRV_CPU_PROGRAM_MAP(cosmo_map) MDRV_CPU_IO_MAP(cosmo_io_map) MDRV_MACHINE_START(extra_8080bw) - /* video hardware */ + /* video hardware */ MDRV_VIDEO_UPDATE(cosmo) - /* sound hardware */ + /* sound hardware */ MDRV_IMPORT_FROM(invaders_samples_audio) MACHINE_DRIVER_END @@ -765,9 +764,9 @@ INPUT_PORTS_END static ADDRESS_MAP_START( rollingc_map, ADDRESS_SPACE_PROGRAM, 8 ) AM_RANGE(0x0000, 0x1fff) AM_ROM - AM_RANGE(0x2000, 0x3fff) AM_RAM AM_BASE(&mw8080bw_ram) AM_SIZE(&mw8080bw_ram_size) + AM_RANGE(0x2000, 0x3fff) AM_RAM AM_BASE_SIZE_MEMBER(mw8080bw_state, main_ram, main_ram_size) AM_RANGE(0x4000, 0x5fff) AM_ROM - AM_RANGE(0xa000, 0xbfff) AM_MIRROR(0x00e0) AM_RAM AM_BASE(&c8080bw_colorram) + AM_RANGE(0xa000, 0xbfff) AM_MIRROR(0x00e0) AM_RAM AM_BASE_MEMBER(mw8080bw_state, colorram) AM_RANGE(0xe400, 0xffff) AM_RAM ADDRESS_MAP_END @@ -828,9 +827,9 @@ MACHINE_DRIVER_END static ADDRESS_MAP_START( schaser_map, ADDRESS_SPACE_PROGRAM, 8 ) AM_RANGE(0x0000, 0x1fff) AM_ROM - AM_RANGE(0x2000, 0x3fff) AM_RAM AM_BASE(&mw8080bw_ram) AM_SIZE(&mw8080bw_ram_size) + AM_RANGE(0x2000, 0x3fff) AM_RAM AM_BASE_SIZE_MEMBER(mw8080bw_state, main_ram, main_ram_size) AM_RANGE(0x4000, 0x5fff) AM_ROM - AM_RANGE(0xc000, 0xdfff) AM_MIRROR(0x0060) AM_RAM AM_BASE(&c8080bw_colorram) + AM_RANGE(0xc000, 0xdfff) AM_MIRROR(0x0060) AM_RAM AM_BASE_MEMBER(mw8080bw_state, colorram) ADDRESS_MAP_END @@ -901,11 +900,24 @@ static INPUT_PORTS_START( schaser ) PORT_ADJUSTER( 70, "VR3 - Dot Volume" ) INPUT_PORTS_END +MACHINE_START( schaser ) +{ + MACHINE_START_CALL(schaser_sh); + MACHINE_START_CALL(extra_8080bw_vh); + MACHINE_START_CALL(mw8080bw); +} + +MACHINE_RESET( schaser ) +{ + MACHINE_RESET_CALL(schaser_sh); + MACHINE_RESET_CALL(mw8080bw); +} + static MACHINE_DRIVER_START( schaser ) /* basic machine hardware */ MDRV_IMPORT_FROM(mw8080bw_root) - MDRV_CPU_REPLACE("maincpu",8080,1996800) /* 19.968MHz / 10 */ + MDRV_CPU_REPLACE("maincpu",8080,1996800) /* 19.968MHz / 10 */ MDRV_CPU_PROGRAM_MAP(schaser_map) MDRV_CPU_IO_MAP(schaser_io_map) MDRV_WATCHDOG_VBLANK_INIT(255) @@ -1002,25 +1014,25 @@ MACHINE_DRIVER_END /* */ /*******************************************************/ -static UINT8 sfl_int = 0; - static CUSTOM_INPUT( sflush_80_r ) { - sfl_int ^= 1; /* vblank flag ? */ + mw8080bw_state *state = (mw8080bw_state *)field->port->machine->driver_data; + state->sfl_int ^= 1; /* vblank flag ? */ - return sfl_int; + return state->sfl_int; } static MACHINE_START( sflush ) { - state_save_register_global(machine, sfl_int); + mw8080bw_state *state = (mw8080bw_state *)machine->driver_data; + state_save_register_global(machine, state->sfl_int); - MACHINE_START_CALL(mw8080bw); + MACHINE_START_CALL(mw8080bw); } static ADDRESS_MAP_START( sflush_map, ADDRESS_SPACE_PROGRAM, 8 ) AM_RANGE(0x0000, 0x1fff) AM_RAM - AM_RANGE(0x4000, 0x5fff) AM_RAM AM_BASE(&mw8080bw_ram) AM_SIZE(&mw8080bw_ram_size) + AM_RANGE(0x4000, 0x5fff) AM_RAM AM_BASE_SIZE_MEMBER(mw8080bw_state, main_ram, main_ram_size) AM_RANGE(0x8008, 0x8008) AM_READ_PORT("PADDLE") AM_RANGE(0x8009, 0x8009) AM_DEVREAD("mb14241", mb14241_shift_result_r) AM_RANGE(0x800a, 0x800a) AM_READ_PORT("IN2") @@ -1030,7 +1042,7 @@ static ADDRESS_MAP_START( sflush_map, ADDRESS_SPACE_PROGRAM, 8 ) AM_RANGE(0x801a, 0x801a) AM_WRITENOP AM_RANGE(0x801c, 0x801c) AM_WRITENOP AM_RANGE(0x801d, 0x801d) AM_WRITENOP - AM_RANGE(0xa000, 0xbfff) AM_MIRROR(0x0060) AM_RAM AM_BASE(&c8080bw_colorram) + AM_RANGE(0xa000, 0xbfff) AM_MIRROR(0x0060) AM_RAM AM_BASE_MEMBER(mw8080bw_state, colorram) AM_RANGE(0xd800, 0xffff) AM_ROM ADDRESS_MAP_END @@ -1068,7 +1080,7 @@ static MACHINE_DRIVER_START( sflush ) /* basic machine hardware */ MDRV_IMPORT_FROM(mw8080bw_root) - MDRV_CPU_REPLACE("maincpu",M6800,2000000) /* ?? */ + MDRV_CPU_REPLACE("maincpu",M6800,2000000) /* ?? */ MDRV_CPU_PROGRAM_MAP(sflush_map) MDRV_CPU_VBLANK_INT_HACK(irq0_line_pulse,2) MDRV_MACHINE_START(sflush) @@ -1218,34 +1230,25 @@ MACHINE_DRIVER_END /* */ /*******************************************************/ -static UINT8 polaris_cloud_speed; -static UINT8 polaris_cloud_pos; - - static INTERRUPT_GEN( polaris_interrupt ) { - polaris_cloud_speed++; + mw8080bw_state *state = (mw8080bw_state *)device->machine->driver_data; + state->polaris_cloud_speed++; - if (polaris_cloud_speed >= 4) /* every 4 frames - this was verified against real machine */ + if (state->polaris_cloud_speed >= 4) /* every 4 frames - this was verified against real machine */ { - polaris_cloud_speed = 0; - - polaris_cloud_pos++; + state->polaris_cloud_speed = 0; + state->polaris_cloud_pos++; } } - -UINT8 polaris_get_cloud_pos(void) -{ - return polaris_cloud_pos; -} - static MACHINE_START( polaris ) { - state_save_register_global(machine, polaris_cloud_speed); - state_save_register_global(machine, polaris_cloud_pos); + mw8080bw_state *state = (mw8080bw_state *)machine->driver_data; + state_save_register_global(machine, state->polaris_cloud_speed); + state_save_register_global(machine, state->polaris_cloud_pos); - MACHINE_START_CALL(mw8080bw); + MACHINE_START_CALL(mw8080bw); } // Port 5 is used to reset the watchdog timer. @@ -1323,7 +1326,7 @@ static MACHINE_DRIVER_START( polaris ) /* basic machine hardware */ MDRV_IMPORT_FROM(mw8080bw_root) - MDRV_CPU_REPLACE("maincpu",8080,1996800) /* 19.968MHz / 10 */ + MDRV_CPU_REPLACE("maincpu",8080,1996800) /* 19.968MHz / 10 */ MDRV_CPU_PROGRAM_MAP(schaser_map) MDRV_CPU_IO_MAP(polaris_io_map) MDRV_WATCHDOG_VBLANK_INIT(255) @@ -1476,7 +1479,7 @@ MACHINE_DRIVER_END static ADDRESS_MAP_START( yosakdon_map, ADDRESS_SPACE_PROGRAM, 8 ) AM_RANGE(0x0000, 0x1fff) AM_ROM - AM_RANGE(0x2000, 0x3fff) AM_RAM AM_BASE(&mw8080bw_ram) AM_SIZE(&mw8080bw_ram_size) + AM_RANGE(0x2000, 0x3fff) AM_RAM AM_BASE_SIZE_MEMBER(mw8080bw_state, main_ram, main_ram_size) AM_RANGE(0x4000, 0x43ff) AM_WRITEONLY /* what's this? */ ADDRESS_MAP_END @@ -1819,7 +1822,7 @@ INPUT_PORTS_END static ADDRESS_MAP_START( shuttlei_map, ADDRESS_SPACE_PROGRAM, 8 ) AM_RANGE(0x0000, 0x1fff) AM_ROM - AM_RANGE(0x2000, 0x3fff) AM_RAM AM_BASE(&mw8080bw_ram) AM_SIZE(&mw8080bw_ram_size) + AM_RANGE(0x2000, 0x3fff) AM_RAM AM_BASE_SIZE_MEMBER(mw8080bw_state, main_ram, main_ram_size) AM_RANGE(0x4000, 0x43ff) AM_RAM AM_SHARE("share1") // shuttlei AM_RANGE(0x6000, 0x63ff) AM_RAM AM_SHARE("share1") // skylove (is it mirrored, or different PCB hookup?) ADDRESS_MAP_END @@ -1894,7 +1897,7 @@ static MACHINE_RESET( darthvdr ) static ADDRESS_MAP_START( darthvdr_map, ADDRESS_SPACE_PROGRAM, 8 ) AM_RANGE(0x0000, 0x17ff) AM_ROM AM_RANGE(0x1800, 0x1fff) AM_RAM - AM_RANGE(0x4000, 0x5fff) AM_RAM AM_BASE(&mw8080bw_ram) AM_SIZE(&mw8080bw_ram_size) + AM_RANGE(0x4000, 0x5fff) AM_RAM AM_BASE_SIZE_MEMBER(mw8080bw_state, main_ram, main_ram_size) ADDRESS_MAP_END static ADDRESS_MAP_START( darthvdr_io_map, ADDRESS_SPACE_IO, 8 ) @@ -1945,7 +1948,7 @@ INPUT_PORTS_END static MACHINE_DRIVER_START( darthvdr ) - /* basic machine hardware */ + /* basic machine hardware */ MDRV_IMPORT_FROM(mw8080bw_root) MDRV_CPU_MODIFY("maincpu") MDRV_CPU_PROGRAM_MAP(darthvdr_map) @@ -2852,7 +2855,7 @@ GAME( 1980, lupin3, 0, lupin3, lupin3, 0, ROT270, "Taito", "Lupin I GAME( 1980, lupin3a, lupin3, lupin3a, lupin3a, 0, ROT270, "Taito", "Lupin III (set 2)", GAME_SUPPORTS_SAVE | GAME_IMPERFECT_SOUND ) GAME( 1980, polaris, 0, polaris, polaris, 0, ROT270, "Taito", "Polaris (set 1)", GAME_SUPPORTS_SAVE ) GAME( 1980, polarisa, polaris, polaris, polaris, 0, ROT270, "Taito", "Polaris (set 2)", GAME_SUPPORTS_SAVE ) -GAME( 1980, ballbomb, 0, ballbomb, ballbomb, 0, ROT270, "Taito", "Balloon Bomber", GAME_SUPPORTS_SAVE | GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS ) /* missing clouds */ +GAME( 1980, ballbomb, 0, ballbomb, ballbomb, 0, ROT270, "Taito", "Balloon Bomber", GAME_SUPPORTS_SAVE | GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS ) /* missing clouds */ GAME( 1980, indianbt, 0, indianbt, indianbt, 0, ROT270, "Taito", "Indian Battle", GAME_SUPPORTS_SAVE | GAME_IMPERFECT_SOUND ) GAME( 1980, steelwkr, 0, steelwkr, steelwkr, 0, ROT0 , "Taito", "Steel Worker", GAME_SUPPORTS_SAVE | GAME_IMPERFECT_SOUND ) diff --git a/src/mame/drivers/mw8080bw.c b/src/mame/drivers/mw8080bw.c index 5f177352817..8a513580e08 100644 --- a/src/mame/drivers/mw8080bw.c +++ b/src/mame/drivers/mw8080bw.c @@ -147,8 +147,8 @@ #include "cpu/i8085/i8085.h" #include "rendlay.h" #include "machine/rescap.h" -#include "mw8080bw.h" #include "machine/mb14241.h" +#include "includes/mw8080bw.h" #include "280zzzap.lh" #include "clowns.lh" @@ -165,13 +165,10 @@ * *************************************/ -static UINT8 rev_shift_res; - - static READ8_HANDLER( mw8080bw_shift_result_rev_r ) { - const device_config *mb14241 = devtag_get_device(space->machine, "mb14241"); - UINT8 ret = mb14241_shift_result_r(mb14241, 0); + mw8080bw_state *state = (mw8080bw_state *)space->machine->driver_data; + UINT8 ret = mb14241_shift_result_r(state->mb14241, 0); return BITSWAP8(ret,0,1,2,3,4,5,6,7); } @@ -179,16 +176,16 @@ static READ8_HANDLER( mw8080bw_shift_result_rev_r ) static READ8_HANDLER( mw8080bw_reversable_shift_result_r ) { - const device_config *mb14241 = devtag_get_device(space->machine, "mb14241"); + mw8080bw_state *state = (mw8080bw_state *)space->machine->driver_data; UINT8 ret; - if (rev_shift_res) + if (state->rev_shift_res) { ret = mw8080bw_shift_result_rev_r(space, 0); } else { - ret = mb14241_shift_result_r(mb14241, 0); + ret = mb14241_shift_result_r(state->mb14241, 0); } return ret; @@ -196,10 +193,10 @@ static READ8_HANDLER( mw8080bw_reversable_shift_result_r ) static WRITE8_HANDLER( mw8080bw_reversable_shift_count_w) { - const device_config *mb14241 = devtag_get_device(space->machine, "mb14241"); - mb14241_shift_count_w(mb14241, offset, data); + mw8080bw_state *state = (mw8080bw_state *)space->machine->driver_data; + mb14241_shift_count_w(state->mb14241, offset, data); - rev_shift_res = data & 0x08; + state->rev_shift_res = data & 0x08; } @@ -210,14 +207,10 @@ static WRITE8_HANDLER( mw8080bw_reversable_shift_count_w) * *************************************/ -UINT8 *mw8080bw_ram; -size_t mw8080bw_ram_size; - - static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 8 ) ADDRESS_MAP_GLOBAL_MASK(0x7fff) AM_RANGE(0x0000, 0x1fff) AM_ROM AM_WRITENOP - AM_RANGE(0x2000, 0x3fff) AM_MIRROR(0x4000) AM_RAM AM_BASE(&mw8080bw_ram) AM_SIZE(&mw8080bw_ram_size) + AM_RANGE(0x2000, 0x3fff) AM_MIRROR(0x4000) AM_RAM AM_BASE_SIZE_MEMBER(mw8080bw_state, main_ram, main_ram_size) AM_RANGE(0x4000, 0x5fff) AM_ROM AM_WRITENOP ADDRESS_MAP_END @@ -231,6 +224,9 @@ ADDRESS_MAP_END MACHINE_DRIVER_START( mw8080bw_root ) + /* driver data */ + MDRV_DRIVER_DATA(mw8080bw_state) + /* basic machine hardware */ MDRV_CPU_ADD("maincpu",8080,MW8080BW_CPU_CLOCK) MDRV_CPU_PROGRAM_MAP(main_map) @@ -434,16 +430,16 @@ MACHINE_DRIVER_END static WRITE8_HANDLER( gunfight_io_w ) { - const device_config *mb14241 = devtag_get_device(space->machine, "mb14241"); + mw8080bw_state *state = (mw8080bw_state *)space->machine->driver_data; if (offset & 0x01) gunfight_audio_w(space, 0, data); if (offset & 0x02) - mb14241_shift_count_w(mb14241, 0, data); + mb14241_shift_count_w(state->mb14241, 0, data); if (offset & 0x04) - mb14241_shift_data_w(mb14241, 0, data); + mb14241_shift_data_w(state->mb14241, 0, data); } @@ -631,16 +627,16 @@ static CUSTOM_INPUT( tornbase_score_input_r ) static WRITE8_HANDLER( tornbase_io_w ) { - const device_config *mb14241 = devtag_get_device(space->machine, "mb14241"); + mw8080bw_state *state = (mw8080bw_state *)space->machine->driver_data; if (offset & 0x01) tornbase_audio_w(devtag_get_device(space->machine, "discrete"), 0, data); if (offset & 0x02) - mb14241_shift_count_w(mb14241, 0, data); + mb14241_shift_count_w(state->mb14241, 0, data); if (offset & 0x04) - mb14241_shift_data_w(mb14241, 0, data); + mb14241_shift_data_w(state->mb14241, 0, data); } @@ -884,33 +880,33 @@ MACHINE_DRIVER_END /* schematic says 12.5 Hz, but R/C values shown give 8.5Hz */ #define MAZE_555_B1_PERIOD PERIOD_OF_555_ASTABLE(RES_K(33) /* R200 */, RES_K(68) /* R201 */, CAP_U(1) /* C201 */) -/* output of IC C1, pin 5 */ -static UINT8 maze_tone_timing_state; - - static STATE_POSTLOAD( maze_update_discrete ) { - maze_write_discrete(devtag_get_device(machine, "discrete"), maze_tone_timing_state); + mw8080bw_state *state = (mw8080bw_state *)machine->driver_data; + maze_write_discrete(devtag_get_device(machine, "discrete"), state->maze_tone_timing_state); } static TIMER_CALLBACK( maze_tone_timing_timer_callback ) { - maze_tone_timing_state = !maze_tone_timing_state; - maze_write_discrete(devtag_get_device(machine, "discrete"), maze_tone_timing_state); + mw8080bw_state *state = (mw8080bw_state *)machine->driver_data; + state->maze_tone_timing_state = !state->maze_tone_timing_state; + maze_write_discrete(state->discrete, state->maze_tone_timing_state); } static MACHINE_START( maze ) { + mw8080bw_state *state = (mw8080bw_state *)machine->driver_data; + /* create astable timer for IC B1 */ timer_pulse(machine, MAZE_555_B1_PERIOD, NULL, 0, maze_tone_timing_timer_callback); /* initialize state of Tone Timing FF, IC C1 */ - maze_tone_timing_state = 0; + state->maze_tone_timing_state = 0; /* setup for save states */ - state_save_register_global(machine, maze_tone_timing_state); + state_save_register_global(machine, state->maze_tone_timing_state); state_save_register_postload(machine, maze_update_discrete, NULL); MACHINE_START_CALL(mw8080bw); @@ -995,8 +991,10 @@ MACHINE_DRIVER_END static MACHINE_START( boothill ) { + mw8080bw_state *state = (mw8080bw_state *)machine->driver_data; + /* setup for save states */ - state_save_register_global(machine, rev_shift_res); + state_save_register_global(machine, state->rev_shift_res); MACHINE_START_CALL(mw8080bw); } @@ -1057,7 +1055,7 @@ static INPUT_PORTS_START( boothill ) PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_COIN1 ) PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_START2 ) - PORT_START("MUSIC_ADJ") /* 3 */ + PORT_START("MUSIC_ADJ") PORT_ADJUSTER( 35, "Music Volume" ) INPUT_PORTS_END @@ -1089,7 +1087,9 @@ MACHINE_DRIVER_END static WRITE8_HANDLER( checkmat_io_w ) { - if (offset & 0x01) checkmat_audio_w(devtag_get_device(space->machine, "discrete"), 0, data); + mw8080bw_state *state = (mw8080bw_state *)space->machine->driver_data; + + if (offset & 0x01) checkmat_audio_w(state->discrete, 0, data); if (offset & 0x02) watchdog_reset_w(space, 0, data); } @@ -1160,10 +1160,10 @@ static INPUT_PORTS_START( checkmat ) PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_UNUSED ) PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_COIN1 ) - PORT_START("R309") /* 4 */ + PORT_START("R309") PORT_ADJUSTER( 50, "Boom Volume" ) - PORT_START("R411") /* 5 */ + PORT_START("R411") PORT_ADJUSTER( 50, "Tone Volume" ) INPUT_PORTS_END @@ -1193,29 +1193,23 @@ MACHINE_DRIVER_END #define DESERTGU_DIP_SW_0_1_SET_2_TAG ("DIPSW01SET2") -static UINT8 desertgu_controller_select; - - static MACHINE_START( desertgu ) { + mw8080bw_state *state = (mw8080bw_state *)machine->driver_data; + /* setup for save states */ - state_save_register_global(machine, desertgu_controller_select); + state_save_register_global(machine, state->desertgu_controller_select); MACHINE_START_CALL(mw8080bw); } -void desertgun_set_controller_select(UINT8 data) -{ - desertgu_controller_select = data; -} - - static CUSTOM_INPUT( desertgu_gun_input_r ) { + mw8080bw_state *state = (mw8080bw_state *)field->port->machine->driver_data; UINT32 ret; - if (desertgu_controller_select) + if (state->desertgu_controller_select) ret = input_port_read(field->port->machine, DESERTGU_GUN_X_PORT_TAG); else ret = input_port_read(field->port->machine, DESERTGU_GUN_Y_PORT_TAG); @@ -1226,9 +1220,10 @@ static CUSTOM_INPUT( desertgu_gun_input_r ) static CUSTOM_INPUT( desertgu_dip_sw_0_1_r ) { + mw8080bw_state *state = (mw8080bw_state *)field->port->machine->driver_data; UINT32 ret; - if (desertgu_controller_select) + if (state->desertgu_controller_select) ret = input_port_read(field->port->machine, DESERTGU_DIP_SW_0_1_SET_2_TAG); else ret = input_port_read(field->port->machine, DESERTGU_DIP_SW_0_1_SET_1_TAG); @@ -1530,8 +1525,10 @@ MACHINE_DRIVER_END static MACHINE_START( gmissile ) { + mw8080bw_state *state = (mw8080bw_state *)machine->driver_data; + /* setup for save states */ - state_save_register_global(machine, rev_shift_res); + state_save_register_global(machine, state->rev_shift_res); MACHINE_START_CALL(mw8080bw); } @@ -1625,8 +1622,10 @@ MACHINE_DRIVER_END static MACHINE_START( m4 ) { + mw8080bw_state *state = (mw8080bw_state *)machine->driver_data; + /* setup for save states */ - state_save_register_global(machine, rev_shift_res); + state_save_register_global(machine, state->rev_shift_res); MACHINE_START_CALL(mw8080bw); } @@ -1720,29 +1719,23 @@ MACHINE_DRIVER_END #define CLOWNS_CONTROLLER_P2_TAG ("CONTP2") -static UINT8 clowns_controller_select; - - static MACHINE_START( clowns ) { + mw8080bw_state *state = (mw8080bw_state *)machine->driver_data; + /* setup for save states */ - state_save_register_global(machine, clowns_controller_select); + state_save_register_global(machine, state->clowns_controller_select); MACHINE_START_CALL(mw8080bw); } -void clowns_set_controller_select(UINT8 data) -{ - clowns_controller_select = data; -} - - static CUSTOM_INPUT( clowns_controller_r ) { + mw8080bw_state *state = (mw8080bw_state *)field->port->machine->driver_data; UINT32 ret; - if (clowns_controller_select) + if (state->clowns_controller_select) { ret = input_port_read(field->port->machine, CLOWNS_CONTROLLER_P2_TAG); } @@ -2161,78 +2154,74 @@ MACHINE_DRIVER_END #define SPCENCTR_STROBE_DUTY_CYCLE (95) /* % */ -static UINT8 spcenctr_strobe_state; -static UINT8 spcenctr_trench_width; -static UINT8 spcenctr_trench_center; -static UINT8 spcenctr_trench_slope[16]; /* 16x4 bit RAM */ - - static TIMER_DEVICE_CALLBACK( spcenctr_strobe_timer_callback ) { - output_set_value("STROBE", param && spcenctr_strobe_state); + mw8080bw_state *state = (mw8080bw_state *)timer->machine->driver_data; + output_set_value("STROBE", param && state->spcenctr_strobe_state); } static MACHINE_START( spcenctr ) { + mw8080bw_state *state = (mw8080bw_state *)machine->driver_data; + /* setup for save states */ - state_save_register_global(machine, spcenctr_strobe_state); - state_save_register_global(machine, spcenctr_trench_width); - state_save_register_global(machine, spcenctr_trench_center); - state_save_register_global_array(machine, spcenctr_trench_slope); + state_save_register_global(machine, state->spcenctr_strobe_state); + state_save_register_global(machine, state->spcenctr_trench_width); + state_save_register_global(machine, state->spcenctr_trench_center); + state_save_register_global_array(machine, state->spcenctr_trench_slope); MACHINE_START_CALL(mw8080bw); } - -void spcenctr_set_strobe_state(UINT8 data) +#if 0 +UINT8 spcenctr_get_trench_width( *running_machine *machine ) { - spcenctr_strobe_state = data; + mw8080bw_state *state = (mw8080bw_state *)machine->driver_data; + return state->spcenctr_trench_width; } -UINT8 spcenctr_get_trench_width(void) +UINT8 spcenctr_get_trench_center( *running_machine *machine ) { - return spcenctr_trench_width; + mw8080bw_state *state = (mw8080bw_state *)machine->driver_data; + return state->spcenctr_trench_center; } -UINT8 spcenctr_get_trench_center(void) +UINT8 spcenctr_get_trench_slope( *running_machine *machine , UINT8 addr ) { - return spcenctr_trench_center; + mw8080bw_state *state = (mw8080bw_state *)machine->driver_data; + return state->spcenctr_trench_slope[addr & 0x0f]; } - - -UINT8 spcenctr_get_trench_slope(UINT8 addr) -{ - return spcenctr_trench_slope[addr & 0x0f]; -} - +#endif static WRITE8_HANDLER( spcenctr_io_w ) { /* A7 A6 A5 A4 A3 A2 A1 A0 */ + mw8080bw_state *state = (mw8080bw_state *)space->machine->driver_data; + if ((offset & 0x07) == 0x02) watchdog_reset_w(space, 0, data); /* - - - - - 0 1 0 */ else if ((offset & 0x5f) == 0x01) - spcenctr_audio_1_w(devtag_get_device(space->machine, "discrete"), 0, data); /* - 0 - 0 0 0 0 1 */ + spcenctr_audio_1_w(state->discrete, 0, data); /* - 0 - 0 0 0 0 1 */ else if ((offset & 0x5f) == 0x09) - spcenctr_audio_2_w(devtag_get_device(space->machine, "discrete"), 0, data); /* - 0 - 0 1 0 0 1 */ + spcenctr_audio_2_w(state->discrete, 0, data); /* - 0 - 0 1 0 0 1 */ else if ((offset & 0x5f) == 0x11) - spcenctr_audio_3_w(devtag_get_device(space->machine, "discrete"), 0, data); /* - 0 - 1 0 0 0 1 */ + spcenctr_audio_3_w(state->discrete, 0, data); /* - 0 - 1 0 0 0 1 */ else if ((offset & 0x07) == 0x03) { /* - - - - - 0 1 1 */ UINT8 addr = ((offset & 0xc0) >> 4) | ((offset & 0x18) >> 3); - spcenctr_trench_slope[addr] = data; + state->spcenctr_trench_slope[addr] = data; } else if ((offset & 0x07) == 0x04) - spcenctr_trench_center = data; /* - - - - - 1 0 0 */ + state->spcenctr_trench_center = data; /* - - - - - 1 0 0 */ else if ((offset & 0x07) == 0x07) - spcenctr_trench_width = data; /* - - - - - 1 1 1 */ + state->spcenctr_trench_width = data; /* - - - - - 1 1 1 */ else logerror("%04x: Unmapped I/O port write to %02x = %02x\n", cpu_get_pc(space->cpu), offset, data); @@ -2334,30 +2323,18 @@ MACHINE_DRIVER_END * *************************************/ -static UINT16 phantom2_cloud_counter = 0; - static MACHINE_START( phantom2 ) { + mw8080bw_state *state = (mw8080bw_state *)machine->driver_data; + /* setup for save states */ - state_save_register_global(machine, phantom2_cloud_counter); + state_save_register_global(machine, state->phantom2_cloud_counter); MACHINE_START_CALL(mw8080bw); } -UINT16 phantom2_get_cloud_counter(void) -{ - return phantom2_cloud_counter; -} - - -void phantom2_set_cloud_counter(UINT16 data) -{ - phantom2_cloud_counter = data; -} - - static ADDRESS_MAP_START( phantom2_io_map, ADDRESS_SPACE_IO, 8 ) ADDRESS_MAP_GLOBAL_MASK(0x7) AM_RANGE(0x00, 0x00) AM_MIRROR(0x04) AM_READ(mw8080bw_shift_result_rev_r) @@ -2443,9 +2420,9 @@ static READ8_HANDLER( bowler_shift_result_r ) /* ZV - not too sure why this is needed, I don't see anything unusual on the schematics that would cause the bits to flip */ - const device_config *mb14241 = devtag_get_device(space->machine, "mb14241"); + mw8080bw_state *state = (mw8080bw_state *)space->machine->driver_data; - return ~mb14241_shift_result_r(mb14241, 0); + return ~mb14241_shift_result_r(state->mb14241, 0); } static WRITE8_HANDLER( bowler_lights_1_w ) @@ -2577,29 +2554,18 @@ MACHINE_DRIVER_END #define INVADERS_SW6_SW7_PORT_TAG ("SW6SW7") #define INVADERS_SW5_PORT_TAG ("SW5") -static UINT8 invaders_flip_screen = 0; - static MACHINE_START( invaders ) { + mw8080bw_state *state = (mw8080bw_state *)machine->driver_data; + /* setup for save states */ - state_save_register_global(machine, invaders_flip_screen); + state_save_register_global(machine, state->invaders_flip_screen); MACHINE_START_CALL(mw8080bw); } -UINT8 invaders_is_flip_screen(void) -{ - return invaders_flip_screen; -} - - -void invaders_set_flip_screen(UINT8 data) -{ - invaders_flip_screen = data; -} - static CUSTOM_INPUT( invaders_coin_input_r ) { diff --git a/src/mame/includes/8080bw.h b/src/mame/includes/8080bw.h deleted file mode 100644 index d8b2f36f244..00000000000 --- a/src/mame/includes/8080bw.h +++ /dev/null @@ -1,93 +0,0 @@ -/************************************************************************* - - 8080bw.h - -*************************************************************************/ - -#include "sound/discrete.h" -#include "sound/sn76477.h" -#include "sound/samples.h" - - - -#define CABINET_PORT_TAG "CAB" - - -/*----------- defined in drivers/8080bw.c -----------*/ - -UINT8 polaris_get_cloud_pos(void); - - -/*----------- defined in audio/8080bw.c -----------*/ - -MACHINE_START( extra_8080bw_sh ); - -WRITE8_HANDLER( invadpt2_sh_port_1_w ); -WRITE8_HANDLER( invadpt2_sh_port_2_w ); - -WRITE8_HANDLER( spcewars_sh_port_w ); - -WRITE8_HANDLER( lrescue_sh_port_1_w ); -WRITE8_HANDLER( lrescue_sh_port_2_w ); -extern const samples_interface lrescue_samples_interface; - -WRITE8_HANDLER( cosmo_sh_port_2_w ); - -WRITE8_HANDLER( ballbomb_sh_port_1_w ); -WRITE8_HANDLER( ballbomb_sh_port_2_w ); - -WRITE8_HANDLER( indianbt_sh_port_1_w ); -WRITE8_HANDLER( indianbt_sh_port_2_w ); -WRITE8_DEVICE_HANDLER( indianbt_sh_port_3_w ); -DISCRETE_SOUND_EXTERN( indianbt ); - -WRITE8_DEVICE_HANDLER( polaris_sh_port_1_w ); -WRITE8_DEVICE_HANDLER( polaris_sh_port_2_w ); -WRITE8_DEVICE_HANDLER( polaris_sh_port_3_w ); -DISCRETE_SOUND_EXTERN( polaris ); - -MACHINE_RESET( schaser ); -MACHINE_START( schaser ); -WRITE8_HANDLER( schaser_sh_port_1_w ); -WRITE8_HANDLER( schaser_sh_port_2_w ); -extern const sn76477_interface schaser_sn76477_interface; -DISCRETE_SOUND_EXTERN( schaser ); - -WRITE8_HANDLER( rollingc_sh_port_w ); - -WRITE8_HANDLER( invrvnge_sh_port_w ); - -WRITE8_HANDLER( lupin3_sh_port_1_w ); -WRITE8_HANDLER( lupin3_sh_port_2_w ); - -WRITE8_HANDLER( schasrcv_sh_port_1_w ); -WRITE8_HANDLER( schasrcv_sh_port_2_w ); - -WRITE8_HANDLER( yosakdon_sh_port_1_w ); -WRITE8_HANDLER( yosakdon_sh_port_2_w ); - -WRITE8_HANDLER( shuttlei_sh_port_1_w ); -WRITE8_HANDLER( shuttlei_sh_port_2_w ); - -/*----------- defined in video/8080bw.c -----------*/ - -extern UINT8 *c8080bw_colorram; - -MACHINE_START( extra_8080bw_vh ); - -void c8080bw_flip_screen_w(const address_space *space, int data); -void lupin3_flip_screen_w(const address_space *space, int data); -void c8080bw_screen_red_w(int data); -void schaser_background_control_w(int data); - -VIDEO_UPDATE( invadpt2 ); -VIDEO_UPDATE( ballbomb ); -VIDEO_UPDATE( schaser ); -VIDEO_UPDATE( schasrcv ); -VIDEO_UPDATE( rollingc ); -VIDEO_UPDATE( polaris ); -VIDEO_UPDATE( lupin3 ); -VIDEO_UPDATE( cosmo ); -VIDEO_UPDATE( indianbt ); -VIDEO_UPDATE( shuttlei ); -VIDEO_UPDATE( sflush ); diff --git a/src/mame/includes/mw8080bw.h b/src/mame/includes/mw8080bw.h index 6035a3f8d98..cbd01e051b3 100644 --- a/src/mame/includes/mw8080bw.h +++ b/src/mame/includes/mw8080bw.h @@ -4,33 +4,95 @@ ****************************************************************************/ +#include "sound/discrete.h" +#include "sound/sn76477.h" +#include "sound/samples.h" -#define MW8080BW_MASTER_CLOCK (19968000) -#define MW8080BW_CPU_CLOCK (MW8080BW_MASTER_CLOCK / 10) -#define MW8080BW_PIXEL_CLOCK (MW8080BW_MASTER_CLOCK / 4) -#define MW8080BW_HTOTAL (0x140) -#define MW8080BW_HBEND (0x000) -#define MW8080BW_HBSTART (0x100) -#define MW8080BW_VTOTAL (0x106) -#define MW8080BW_VBEND (0x000) -#define MW8080BW_VBSTART (0x0e0) -#define MW8080BW_VCOUNTER_START_NO_VBLANK (0x020) -#define MW8080BW_VCOUNTER_START_VBLANK (0x0da) -#define MW8080BW_INT_TRIGGER_COUNT_1 (0x080) -#define MW8080BW_INT_TRIGGER_VBLANK_1 (0) -#define MW8080BW_INT_TRIGGER_COUNT_2 MW8080BW_VCOUNTER_START_VBLANK -#define MW8080BW_INT_TRIGGER_VBLANK_2 (1) + +#define MW8080BW_MASTER_CLOCK (19968000) +#define MW8080BW_CPU_CLOCK (MW8080BW_MASTER_CLOCK / 10) +#define MW8080BW_PIXEL_CLOCK (MW8080BW_MASTER_CLOCK / 4) +#define MW8080BW_HTOTAL (0x140) +#define MW8080BW_HBEND (0x000) +#define MW8080BW_HBSTART (0x100) +#define MW8080BW_VTOTAL (0x106) +#define MW8080BW_VBEND (0x000) +#define MW8080BW_VBSTART (0x0e0) +#define MW8080BW_VCOUNTER_START_NO_VBLANK (0x020) +#define MW8080BW_VCOUNTER_START_VBLANK (0x0da) +#define MW8080BW_INT_TRIGGER_COUNT_1 (0x080) +#define MW8080BW_INT_TRIGGER_VBLANK_1 (0) +#define MW8080BW_INT_TRIGGER_COUNT_2 MW8080BW_VCOUNTER_START_VBLANK +#define MW8080BW_INT_TRIGGER_VBLANK_2 (1) /* +4 is added to HBSTART because the hardware displays that many pixels after setting HBLANK */ -#define MW8080BW_HPIXCOUNT (MW8080BW_HBSTART + 4) +#define MW8080BW_HPIXCOUNT (MW8080BW_HBSTART + 4) + + +typedef struct _mw8080bw_state mw8080bw_state; +struct _mw8080bw_state +{ + /* memory pointers */ + UINT8 * main_ram; + UINT8 * colorram; + size_t main_ram_size; + + /* sound-related */ + UINT8 port_1_last; + UINT8 port_2_last; + UINT8 port_1_last_extra; + UINT8 port_2_last_extra; + UINT8 port_3_last_extra; + + /* misc game specific */ + emu_timer *schaser_effect_555_timer; + attotime schaser_effect_555_time_remain; + INT32 schaser_effect_555_time_remain_savable; + int schaser_effect_555_is_low; + int schaser_explosion; + int schaser_last_effect; + UINT8 sfl_int; + UINT8 polaris_cloud_speed; + UINT8 polaris_cloud_pos; + UINT8 schaser_background_disable; + UINT8 schaser_background_select; + UINT8 c8080bw_flip_screen; + UINT8 color_map; + UINT8 screen_red; + + + UINT16 phantom2_cloud_counter; + UINT8 invaders_flip_screen; + UINT8 rev_shift_res; + UINT8 maze_tone_timing_state; /* output of IC C1, pin 5 */ + UINT8 desertgun_controller_select; + UINT8 clowns_controller_select; + + UINT8 spcenctr_strobe_state; + UINT8 spcenctr_trench_width; + UINT8 spcenctr_trench_center; + UINT8 spcenctr_trench_slope[16]; /* 16x4 bit RAM */ + + /* timer */ + emu_timer *interrupt_timer; + + /* devices */ + const device_config *maincpu; + const device_config *mb14241; + const device_config *samples; + const device_config *samples1; + const device_config *samples2; + const device_config *speaker; + const device_config *sn1; + const device_config *sn2; + const device_config *sn; + const device_config *discrete; +}; /*----------- defined in drivers/mw8080bw.c -----------*/ -extern UINT8 *mw8080bw_ram; -extern size_t mw8080bw_ram_size; - MACHINE_DRIVER_EXTERN( mw8080bw_root ); MACHINE_DRIVER_EXTERN( invaders ); extern const char layout_invaders[]; @@ -44,26 +106,18 @@ UINT8 tornbase_get_cabinet_type(running_machine *machine); #define DESERTGU_GUN_X_PORT_TAG ("GUNX") #define DESERTGU_GUN_Y_PORT_TAG ("GUNY") -void desertgun_set_controller_select(UINT8 data); - -void clowns_set_controller_select(UINT8 data); - -void spcenctr_set_strobe_state(UINT8 data); -UINT8 spcenctr_get_trench_width(void); -UINT8 spcenctr_get_trench_center(void); -UINT8 spcenctr_get_trench_slope(UINT8 addr); - -UINT16 phantom2_get_cloud_counter(void); -void phantom2_set_cloud_counter(UINT16 data); #define INVADERS_CAB_TYPE_PORT_TAG ("CAB") #define INVADERS_P1_CONTROL_PORT_TAG ("CONTP1") #define INVADERS_P2_CONTROL_PORT_TAG ("CONTP2") +/* for games in 8080bw.c */ +#define CABINET_PORT_TAG "CAB" + + CUSTOM_INPUT( invaders_in1_control_r ); CUSTOM_INPUT( invaders_in2_control_r ); -UINT8 invaders_is_flip_screen(void); -void invaders_set_flip_screen(UINT8 data); + int invaders_is_cabinet_cocktail(running_machine *machine); #define BLUESHRK_SPEAR_PORT_TAG ("IN0") @@ -184,6 +238,56 @@ WRITE8_DEVICE_HANDLER( invad2ct_audio_2_w ); WRITE8_DEVICE_HANDLER( invad2ct_audio_3_w ); WRITE8_DEVICE_HANDLER( invad2ct_audio_4_w ); +/*----------- defined in audio/8080bw.c -----------*/ + +MACHINE_START( extra_8080bw_sh ); + +WRITE8_HANDLER( invadpt2_sh_port_1_w ); +WRITE8_HANDLER( invadpt2_sh_port_2_w ); + +WRITE8_HANDLER( spcewars_sh_port_w ); + +WRITE8_HANDLER( lrescue_sh_port_1_w ); +WRITE8_HANDLER( lrescue_sh_port_2_w ); +extern const samples_interface lrescue_samples_interface; + +WRITE8_HANDLER( cosmo_sh_port_2_w ); + +WRITE8_HANDLER( ballbomb_sh_port_1_w ); +WRITE8_HANDLER( ballbomb_sh_port_2_w ); + +WRITE8_HANDLER( indianbt_sh_port_1_w ); +WRITE8_HANDLER( indianbt_sh_port_2_w ); +WRITE8_DEVICE_HANDLER( indianbt_sh_port_3_w ); +DISCRETE_SOUND_EXTERN( indianbt ); + +WRITE8_DEVICE_HANDLER( polaris_sh_port_1_w ); +WRITE8_DEVICE_HANDLER( polaris_sh_port_2_w ); +WRITE8_DEVICE_HANDLER( polaris_sh_port_3_w ); +DISCRETE_SOUND_EXTERN( polaris ); + +MACHINE_RESET( schaser_sh ); +MACHINE_START( schaser_sh ); +WRITE8_HANDLER( schaser_sh_port_1_w ); +WRITE8_HANDLER( schaser_sh_port_2_w ); +extern const sn76477_interface schaser_sn76477_interface; +DISCRETE_SOUND_EXTERN( schaser ); + +WRITE8_HANDLER( rollingc_sh_port_w ); + +WRITE8_HANDLER( invrvnge_sh_port_w ); + +WRITE8_HANDLER( lupin3_sh_port_1_w ); +WRITE8_HANDLER( lupin3_sh_port_2_w ); + +WRITE8_HANDLER( schasrcv_sh_port_1_w ); +WRITE8_HANDLER( schasrcv_sh_port_2_w ); + +WRITE8_HANDLER( yosakdon_sh_port_1_w ); +WRITE8_HANDLER( yosakdon_sh_port_2_w ); + +WRITE8_HANDLER( shuttlei_sh_port_1_w ); +WRITE8_HANDLER( shuttlei_sh_port_2_w ); /*----------- defined in video/mw8080bw.c -----------*/ @@ -196,3 +300,21 @@ VIDEO_UPDATE( phantom2 ); VIDEO_EOF( phantom2 ); VIDEO_UPDATE( invaders ); + + +/*----------- defined in video/8080bw.c -----------*/ + +MACHINE_START( extra_8080bw_vh ); + +VIDEO_UPDATE( invadpt2 ); +VIDEO_UPDATE( ballbomb ); +VIDEO_UPDATE( schaser ); +VIDEO_UPDATE( schasrcv ); +VIDEO_UPDATE( rollingc ); +VIDEO_UPDATE( polaris ); +VIDEO_UPDATE( lupin3 ); +VIDEO_UPDATE( cosmo ); +VIDEO_UPDATE( indianbt ); +VIDEO_UPDATE( shuttlei ); +VIDEO_UPDATE( sflush ); + diff --git a/src/mame/machine/mw8080bw.c b/src/mame/machine/mw8080bw.c index e0199ea88af..eaa08000ae6 100644 --- a/src/mame/machine/mw8080bw.c +++ b/src/mame/machine/mw8080bw.c @@ -5,7 +5,7 @@ ****************************************************************************/ #include "driver.h" -#include "mw8080bw.h" +#include "includes/mw8080bw.h" /************************************* * @@ -13,42 +13,30 @@ * *************************************/ -static emu_timer *interrupt_timer; - - -static UINT8 vpos_to_vysnc_chain_counter(int vpos) +static UINT8 vpos_to_vysnc_chain_counter( int vpos ) { /* convert from a vertical position to the actual values on the vertical sync counters */ UINT8 counter; int vblank = (vpos >= MW8080BW_VBSTART); if (vblank) - { counter = vpos - MW8080BW_VBSTART + MW8080BW_VCOUNTER_START_VBLANK; - } else - { counter = vpos + MW8080BW_VCOUNTER_START_NO_VBLANK; - } - return counter; } -static int vysnc_chain_counter_to_vpos(UINT8 counter, int vblank) +static int vysnc_chain_counter_to_vpos( UINT8 counter, int vblank ) { /* convert from the vertical sync counters to an actual vertical position */ int vpos; if (vblank) - { vpos = counter - MW8080BW_VCOUNTER_START_VBLANK + MW8080BW_VBSTART; - } else - { vpos = counter - MW8080BW_VCOUNTER_START_NO_VBLANK; - } return vpos; } @@ -56,6 +44,7 @@ static int vysnc_chain_counter_to_vpos(UINT8 counter, int vblank) static TIMER_CALLBACK( mw8080bw_interrupt_callback ) { + mw8080bw_state *state = (mw8080bw_state *)machine->driver_data; UINT8 next_counter; int next_vpos; int next_vblank; @@ -64,7 +53,7 @@ static TIMER_CALLBACK( mw8080bw_interrupt_callback ) int vpos = video_screen_get_vpos(machine->primary_screen); UINT8 counter = vpos_to_vysnc_chain_counter(vpos); UINT8 vector = 0xc7 | ((counter & 0x40) >> 2) | ((~counter & 0x40) >> 3); - cputag_set_input_line_and_vector(machine, "maincpu", 0, HOLD_LINE, vector); + cpu_set_input_line_and_vector(state->maincpu, 0, HOLD_LINE, vector); /* set up for next interrupt */ if (counter == MW8080BW_INT_TRIGGER_COUNT_1) @@ -79,20 +68,22 @@ static TIMER_CALLBACK( mw8080bw_interrupt_callback ) } next_vpos = vysnc_chain_counter_to_vpos(next_counter, next_vblank); - timer_adjust_oneshot(interrupt_timer, video_screen_get_time_until_pos(machine->primary_screen, next_vpos, 0), 0); + timer_adjust_oneshot(state->interrupt_timer, video_screen_get_time_until_pos(machine->primary_screen, next_vpos, 0), 0); } -static void mw8080bw_create_interrupt_timer(running_machine *machine) +static void mw8080bw_create_interrupt_timer( running_machine *machine ) { - interrupt_timer = timer_alloc(machine, mw8080bw_interrupt_callback, NULL); + mw8080bw_state *state = (mw8080bw_state *)machine->driver_data; + state->interrupt_timer = timer_alloc(machine, mw8080bw_interrupt_callback, NULL); } -static void mw8080bw_start_interrupt_timer(running_machine *machine) +static void mw8080bw_start_interrupt_timer( running_machine *machine ) { + mw8080bw_state *state = (mw8080bw_state *)machine->driver_data; int vpos = vysnc_chain_counter_to_vpos(MW8080BW_INT_TRIGGER_COUNT_1, MW8080BW_INT_TRIGGER_VBLANK_1); - timer_adjust_oneshot(interrupt_timer, video_screen_get_time_until_pos(machine->primary_screen, vpos, 0), 0); + timer_adjust_oneshot(state->interrupt_timer, video_screen_get_time_until_pos(machine->primary_screen, vpos, 0), 0); } @@ -105,9 +96,21 @@ static void mw8080bw_start_interrupt_timer(running_machine *machine) MACHINE_START( mw8080bw ) { - mw8080bw_create_interrupt_timer(machine); -} + mw8080bw_state *state = (mw8080bw_state *)machine->driver_data; + mw8080bw_create_interrupt_timer(machine); + + state->maincpu = devtag_get_device(machine, "maincpu"); + state->samples = devtag_get_device(machine, "samples"); + state->samples1 = devtag_get_device(machine, "samples1"); + state->samples2 = devtag_get_device(machine, "samples2"); + state->sn = devtag_get_device(machine, "snsnd"); + state->sn1 = devtag_get_device(machine, "sn1"); + state->sn2 = devtag_get_device(machine, "sn2"); + state->discrete = devtag_get_device(machine, "discrete"); + state->speaker = devtag_get_device(machine, "speaker"); + state->mb14241 = devtag_get_device(machine, "mb14241"); +} /************************************* diff --git a/src/mame/video/8080bw.c b/src/mame/video/8080bw.c index 18204fdb708..1b7baca758d 100644 --- a/src/mame/video/8080bw.c +++ b/src/mame/video/8080bw.c @@ -7,61 +7,28 @@ ***************************************************************************/ #include "driver.h" -#include "8080bw.h" -#include "mw8080bw.h" +#include "includes/mw8080bw.h" #define NUM_PENS (8) -UINT8 *c8080bw_colorram; - -static UINT8 c8080bw_flip_screen; -static UINT8 color_map; -static UINT8 screen_red; -static UINT8 schaser_background_disable; -static UINT8 schaser_background_select; - MACHINE_START( extra_8080bw_vh ) { - state_save_register_global(machine, c8080bw_flip_screen); - state_save_register_global(machine, color_map); - state_save_register_global(machine, screen_red); + mw8080bw_state *state = (mw8080bw_state *)machine->driver_data; - // These two only belong to schaser, but for simplicity's sake let's waste - // two bytes in other drivers' .sta files. - state_save_register_global(machine, schaser_background_disable); - state_save_register_global(machine, schaser_background_select); -} + state_save_register_global(machine, state->c8080bw_flip_screen); + state_save_register_global(machine, state->color_map); + state_save_register_global(machine, state->screen_red); -void c8080bw_flip_screen_w(const address_space *space, int data) -{ - color_map = data; - c8080bw_flip_screen = data && (input_port_read(space->machine, CABINET_PORT_TAG) & 0x01); + // These two only belong to schaser, but for simplicity's sake let's waste + // two bytes in other drivers' .sta files. + state_save_register_global(machine, state->schaser_background_disable); + state_save_register_global(machine, state->schaser_background_select); } -void lupin3_flip_screen_w(const address_space *space, int data) -{ - color_map = data & 0x40; - c8080bw_flip_screen = (data & 0x20) && (input_port_read(space->machine, "IN2") & 0x04); -} - - -void c8080bw_screen_red_w(int data) -{ - screen_red = data; -} - - -void schaser_background_control_w(int data) -{ - schaser_background_disable = (data >> 3) & 0x01; - schaser_background_select = (data >> 4) & 0x01; -} - - -static void invadpt2_get_pens(pen_t *pens) +static void invadpt2_get_pens( pen_t *pens ) { offs_t i; @@ -72,7 +39,7 @@ static void invadpt2_get_pens(pen_t *pens) } -static void sflush_get_pens(pen_t *pens) +static void sflush_get_pens( pen_t *pens ) { offs_t i; @@ -85,7 +52,7 @@ static void sflush_get_pens(pen_t *pens) } -static void cosmo_get_pens(pen_t *pens) +static void cosmo_get_pens( pen_t *pens ) { offs_t i; @@ -96,11 +63,13 @@ static void cosmo_get_pens(pen_t *pens) } -INLINE void set_pixel(bitmap_t *bitmap, UINT8 y, UINT8 x, pen_t *pens, UINT8 color) +INLINE void set_pixel( running_machine *machine, bitmap_t *bitmap, UINT8 y, UINT8 x, pen_t *pens, UINT8 color ) { + mw8080bw_state *state = (mw8080bw_state *)machine->driver_data; + if (y >= MW8080BW_VCOUNTER_START_NO_VBLANK) { - if (c8080bw_flip_screen) + if (state->c8080bw_flip_screen) *BITMAP_ADDR32(bitmap, MW8080BW_VBSTART - 1 - (y - MW8080BW_VCOUNTER_START_NO_VBLANK), MW8080BW_HPIXCOUNT - 1 - x) = pens[color]; else *BITMAP_ADDR32(bitmap, y - MW8080BW_VCOUNTER_START_NO_VBLANK, x) = pens[color]; @@ -108,14 +77,13 @@ INLINE void set_pixel(bitmap_t *bitmap, UINT8 y, UINT8 x, pen_t *pens, UINT8 col } -INLINE void set_8_pixels(bitmap_t *bitmap, UINT8 y, UINT8 x, UINT8 data, - pen_t *pens, UINT8 fore_color, UINT8 back_color) +INLINE void set_8_pixels( running_machine *machine, bitmap_t *bitmap, UINT8 y, UINT8 x, UINT8 data, pen_t *pens, UINT8 fore_color, UINT8 back_color ) { int i; for (i = 0; i < 8; i++) { - set_pixel(bitmap, y, x, pens, (data & 0x01) ? fore_color : back_color); + set_pixel(machine, bitmap, y, x, pens, (data & 0x01) ? fore_color : back_color); x = x + 1; data = data >> 1; @@ -124,8 +92,9 @@ INLINE void set_8_pixels(bitmap_t *bitmap, UINT8 y, UINT8 x, UINT8 data, /* this is needed as this driver doesn't emulate the shift register like mw8080bw does */ -static void clear_extra_columns(bitmap_t *bitmap, pen_t *pens, UINT8 color) +static void clear_extra_columns( running_machine *machine, bitmap_t *bitmap, pen_t *pens, UINT8 color ) { + mw8080bw_state *state = (mw8080bw_state *)machine->driver_data; UINT8 x; for (x = 0; x < 4; x++) @@ -134,7 +103,7 @@ static void clear_extra_columns(bitmap_t *bitmap, pen_t *pens, UINT8 color) for (y = MW8080BW_VCOUNTER_START_NO_VBLANK; y != 0; y++) { - if (c8080bw_flip_screen) + if (state->c8080bw_flip_screen) *BITMAP_ADDR32(bitmap, MW8080BW_VBSTART - 1 - (y - MW8080BW_VCOUNTER_START_NO_VBLANK), MW8080BW_HPIXCOUNT - 1 - (256 + x)) = pens[color]; else *BITMAP_ADDR32(bitmap, y - MW8080BW_VCOUNTER_START_NO_VBLANK, 256 + x) = pens[color]; @@ -145,6 +114,7 @@ static void clear_extra_columns(bitmap_t *bitmap, pen_t *pens, UINT8 color) VIDEO_UPDATE( invadpt2 ) { + mw8080bw_state *state = (mw8080bw_state *)screen->machine->driver_data; pen_t pens[NUM_PENS]; offs_t offs; UINT8 *prom; @@ -153,22 +123,22 @@ VIDEO_UPDATE( invadpt2 ) invadpt2_get_pens(pens); prom = memory_region(screen->machine, "proms"); - color_map_base = color_map ? &prom[0x0400] : &prom[0x0000]; + color_map_base = state->color_map ? &prom[0x0400] : &prom[0x0000]; - for (offs = 0; offs < mw8080bw_ram_size; offs++) + for (offs = 0; offs < state->main_ram_size; offs++) { UINT8 y = offs >> 5; UINT8 x = offs << 3; offs_t color_address = (offs >> 8 << 5) | (offs & 0x1f); - UINT8 data = mw8080bw_ram[offs]; - UINT8 fore_color = screen_red ? 1 : color_map_base[color_address] & 0x07; + UINT8 data = state->main_ram[offs]; + UINT8 fore_color = state->screen_red ? 1 : color_map_base[color_address] & 0x07; - set_8_pixels(bitmap, y, x, data, pens, fore_color, 0); + set_8_pixels(screen->machine, bitmap, y, x, data, pens, fore_color, 0); } - clear_extra_columns(bitmap, pens, 0); + clear_extra_columns(screen->machine, bitmap, pens, 0); return 0; } @@ -176,6 +146,7 @@ VIDEO_UPDATE( invadpt2 ) VIDEO_UPDATE( ballbomb ) { + mw8080bw_state *state = (mw8080bw_state *)screen->machine->driver_data; pen_t pens[NUM_PENS]; offs_t offs; UINT8 *color_map_base; @@ -184,23 +155,23 @@ VIDEO_UPDATE( ballbomb ) invadpt2_get_pens(pens); prom = memory_region(screen->machine, "proms"); - color_map_base = color_map ? &prom[0x0400] : &prom[0x0000]; + color_map_base = state->color_map ? &prom[0x0400] : &prom[0x0000]; - for (offs = 0; offs < mw8080bw_ram_size; offs++) + for (offs = 0; offs < state->main_ram_size; offs++) { UINT8 y = offs >> 5; UINT8 x = offs << 3; offs_t color_address = (offs >> 8 << 5) | (offs & 0x1f); - UINT8 data = mw8080bw_ram[offs]; - UINT8 fore_color = screen_red ? 1 : color_map_base[color_address] & 0x07; + UINT8 data = state->main_ram[offs]; + UINT8 fore_color = state->screen_red ? 1 : color_map_base[color_address] & 0x07; /* blue background */ - set_8_pixels(bitmap, y, x, data, pens, fore_color, 2); + set_8_pixels(screen->machine, bitmap, y, x, data, pens, fore_color, 2); } - clear_extra_columns(bitmap, pens, 2); + clear_extra_columns(screen->machine, bitmap, pens, 2); return 0; } @@ -208,6 +179,7 @@ VIDEO_UPDATE( ballbomb ) VIDEO_UPDATE( schaser ) { + mw8080bw_state *state = (mw8080bw_state *)screen->machine->driver_data; pen_t pens[NUM_PENS]; offs_t offs; UINT8 *background_map_base; @@ -216,17 +188,17 @@ VIDEO_UPDATE( schaser ) background_map_base = memory_region(screen->machine, "proms"); - for (offs = 0; offs < mw8080bw_ram_size; offs++) + for (offs = 0; offs < state->main_ram_size; offs++) { UINT8 back_color = 0; UINT8 y = offs >> 5; UINT8 x = offs << 3; - UINT8 data = mw8080bw_ram[offs]; - UINT8 fore_color = c8080bw_colorram[offs & 0x1f9f] & 0x07; + UINT8 data = state->main_ram[offs]; + UINT8 fore_color = state->colorram[offs & 0x1f9f] & 0x07; - if (!schaser_background_disable) + if (!state->schaser_background_disable) { offs_t back_address = (offs >> 8 << 5) | (offs & 0x1f); @@ -234,13 +206,13 @@ VIDEO_UPDATE( schaser ) /* the equations derived from the schematics don't appear to produce the right colors, but this one does, at least for this PROM */ - back_color = (((back_data & 0x0c) == 0x0c) && schaser_background_select) ? 4 : 2; + back_color = (((back_data & 0x0c) == 0x0c) && state->schaser_background_select) ? 4 : 2; } - set_8_pixels(bitmap, y, x, data, pens, fore_color, back_color); + set_8_pixels(screen->machine, bitmap, y, x, data, pens, fore_color, back_color); } - clear_extra_columns(bitmap, pens, schaser_background_disable ? 0 : 2); + clear_extra_columns(screen->machine, bitmap, pens, state->schaser_background_disable ? 0 : 2); return 0; } @@ -248,24 +220,25 @@ VIDEO_UPDATE( schaser ) VIDEO_UPDATE( schasrcv ) { + mw8080bw_state *state = (mw8080bw_state *)screen->machine->driver_data; pen_t pens[NUM_PENS]; offs_t offs; invadpt2_get_pens(pens); - for (offs = 0; offs < mw8080bw_ram_size; offs++) + for (offs = 0; offs < state->main_ram_size; offs++) { UINT8 y = offs >> 5; UINT8 x = offs << 3; - UINT8 data = mw8080bw_ram[offs]; - UINT8 fore_color = c8080bw_colorram[offs & 0x1f9f] & 0x07; + UINT8 data = state->main_ram[offs]; + UINT8 fore_color = state->colorram[offs & 0x1f9f] & 0x07; /* blue background */ - set_8_pixels(bitmap, y, x, data, pens, fore_color, 2); + set_8_pixels(screen->machine, bitmap, y, x, data, pens, fore_color, 2); } - clear_extra_columns(bitmap, pens, 2); + clear_extra_columns(screen->machine, bitmap, pens, 2); return 0; } @@ -273,23 +246,24 @@ VIDEO_UPDATE( schasrcv ) VIDEO_UPDATE( rollingc ) { + mw8080bw_state *state = (mw8080bw_state *)screen->machine->driver_data; pen_t pens[NUM_PENS]; offs_t offs; invadpt2_get_pens(pens); - for (offs = 0; offs < mw8080bw_ram_size; offs++) + for (offs = 0; offs < state->main_ram_size; offs++) { UINT8 y = offs >> 5; UINT8 x = offs << 3; - UINT8 data = mw8080bw_ram[offs]; - UINT8 fore_color = c8080bw_colorram[offs & 0x1f1f] & 0x07; + UINT8 data = state->main_ram[offs]; + UINT8 fore_color = state->colorram[offs & 0x1f1f] & 0x07; - set_8_pixels(bitmap, y, x, data, pens, fore_color, 0); + set_8_pixels(screen->machine, bitmap, y, x, data, pens, fore_color, 0); } - clear_extra_columns(bitmap, pens, 0); + clear_extra_columns(screen->machine, bitmap, pens, 0); return 0; } @@ -297,6 +271,7 @@ VIDEO_UPDATE( rollingc ) VIDEO_UPDATE( polaris ) { + mw8080bw_state *state = (mw8080bw_state *)screen->machine->driver_data; pen_t pens[NUM_PENS]; offs_t offs; UINT8 *color_map_base; @@ -307,12 +282,12 @@ VIDEO_UPDATE( polaris ) color_map_base = memory_region(screen->machine, "proms"); cloud_gfx = memory_region(screen->machine, "user1"); - for (offs = 0; offs < mw8080bw_ram_size; offs++) + for (offs = 0; offs < state->main_ram_size; offs++) { UINT8 y = offs >> 5; UINT8 x = offs << 3; - UINT8 data = mw8080bw_ram[offs]; + UINT8 data = state->main_ram[offs]; offs_t color_address = (offs >> 8 << 5) | (offs & 0x1f); @@ -323,13 +298,13 @@ VIDEO_UPDATE( polaris ) bits 1 and 2 are marked 'not use' (sic) */ UINT8 back_color = (color_map_base[color_address] & 0x01) ? 6 : 2; - UINT8 fore_color = ~c8080bw_colorram[offs & 0x1f9f] & 0x07; + UINT8 fore_color = ~state->colorram[offs & 0x1f9f] & 0x07; - UINT8 cloud_y = y - polaris_get_cloud_pos(); + UINT8 cloud_y = y - state->polaris_cloud_pos; if ((color_map_base[color_address] & 0x08) || (cloud_y >= 64)) { - set_8_pixels(bitmap, y, x, data, pens, fore_color, back_color); + set_8_pixels(screen->machine, bitmap, y, x, data, pens, fore_color, back_color); } else { @@ -352,7 +327,7 @@ VIDEO_UPDATE( polaris ) color = (cloud_gfx[cloud_gfx_offs] & bit) ? 7 : back_color; } - set_pixel(bitmap, y, x, pens, color); + set_pixel(screen->machine, bitmap, y, x, pens, color); x = x + 1; data = data >> 1; @@ -360,7 +335,7 @@ VIDEO_UPDATE( polaris ) } } - clear_extra_columns(bitmap, pens, 6); + clear_extra_columns(screen->machine, bitmap, pens, 6); return 0; } @@ -368,23 +343,24 @@ VIDEO_UPDATE( polaris ) VIDEO_UPDATE( lupin3 ) { + mw8080bw_state *state = (mw8080bw_state *)screen->machine->driver_data; pen_t pens[NUM_PENS]; offs_t offs; invadpt2_get_pens(pens); - for (offs = 0; offs < mw8080bw_ram_size; offs++) + for (offs = 0; offs < state->main_ram_size; offs++) { UINT8 y = offs >> 5; UINT8 x = offs << 3; - UINT8 data = mw8080bw_ram[offs]; - UINT8 fore_color = ~c8080bw_colorram[offs & 0x1f9f] & 0x07; + UINT8 data = state->main_ram[offs]; + UINT8 fore_color = ~state->colorram[offs & 0x1f9f] & 0x07; - set_8_pixels(bitmap, y, x, data, pens, fore_color, 0); + set_8_pixels(screen->machine, bitmap, y, x, data, pens, fore_color, 0); } - clear_extra_columns(bitmap, pens, 0); + clear_extra_columns(screen->machine, bitmap, pens, 0); return 0; } @@ -392,25 +368,26 @@ VIDEO_UPDATE( lupin3 ) VIDEO_UPDATE( cosmo ) { + mw8080bw_state *state = (mw8080bw_state *)screen->machine->driver_data; pen_t pens[NUM_PENS]; offs_t offs; cosmo_get_pens(pens); - for (offs = 0; offs < mw8080bw_ram_size; offs++) + for (offs = 0; offs < state->main_ram_size; offs++) { UINT8 y = offs >> 5; UINT8 x = offs << 3; offs_t color_address = (offs >> 8 << 5) | (offs & 0x1f); - UINT8 data = mw8080bw_ram[offs]; - UINT8 fore_color = c8080bw_colorram[color_address] & 0x07; + UINT8 data = state->main_ram[offs]; + UINT8 fore_color = state->colorram[color_address] & 0x07; - set_8_pixels(bitmap, y, x, data, pens, fore_color, 0); + set_8_pixels(screen->machine, bitmap, y, x, data, pens, fore_color, 0); } - clear_extra_columns(bitmap, pens, 0); + clear_extra_columns(screen->machine, bitmap, pens, 0); return 0; } @@ -418,6 +395,7 @@ VIDEO_UPDATE( cosmo ) VIDEO_UPDATE( indianbt ) { + mw8080bw_state *state = (mw8080bw_state *)screen->machine->driver_data; pen_t pens[NUM_PENS]; offs_t offs; UINT8 *color_map_base; @@ -426,22 +404,22 @@ VIDEO_UPDATE( indianbt ) cosmo_get_pens(pens); prom = memory_region(screen->machine, "proms"); - color_map_base = color_map ? &prom[0x0400] : &prom[0x0000]; + color_map_base = state->color_map ? &prom[0x0400] : &prom[0x0000]; - for (offs = 0; offs < mw8080bw_ram_size; offs++) + for (offs = 0; offs < state->main_ram_size; offs++) { UINT8 y = offs >> 5; UINT8 x = offs << 3; offs_t color_address = (offs >> 8 << 5) | (offs & 0x1f); - UINT8 data = mw8080bw_ram[offs]; + UINT8 data = state->main_ram[offs]; UINT8 fore_color = color_map_base[color_address] & 0x07; - set_8_pixels(bitmap, y, x, data, pens, fore_color, 0); + set_8_pixels(screen->machine, bitmap, y, x, data, pens, fore_color, 0); } - clear_extra_columns(bitmap, pens, 0); + clear_extra_columns(screen->machine, bitmap, pens, 0); return 0; } @@ -449,17 +427,18 @@ VIDEO_UPDATE( indianbt ) VIDEO_UPDATE( shuttlei ) { + mw8080bw_state *state = (mw8080bw_state *)screen->machine->driver_data; pen_t pens[2] = { RGB_BLACK, RGB_WHITE }; offs_t offs; - for (offs = 0; offs < mw8080bw_ram_size; offs++) + for (offs = 0; offs < state->main_ram_size; offs++) { int i; UINT8 y = offs >> 5; UINT8 x = offs << 3; - UINT8 data = mw8080bw_ram[offs]; + UINT8 data = state->main_ram[offs]; for (i = 0; i < 8; i++) { @@ -471,7 +450,7 @@ VIDEO_UPDATE( shuttlei ) } } - clear_extra_columns(bitmap, pens, 0); + clear_extra_columns(screen->machine, bitmap, pens, 0); return 0; } @@ -479,23 +458,24 @@ VIDEO_UPDATE( shuttlei ) VIDEO_UPDATE( sflush ) { + mw8080bw_state *state = (mw8080bw_state *)screen->machine->driver_data; pen_t pens[NUM_PENS]; offs_t offs; sflush_get_pens(pens); - for (offs = 0; offs < mw8080bw_ram_size; offs++) + for (offs = 0; offs < state->main_ram_size; offs++) { UINT8 y = offs >> 5; UINT8 x = offs << 3; - UINT8 data = mw8080bw_ram[offs]; - UINT8 fore_color = c8080bw_colorram[offs & 0x1f9f] & 0x07; + UINT8 data = state->main_ram[offs]; + UINT8 fore_color = state->colorram[offs & 0x1f9f] & 0x07; - set_8_pixels(bitmap, y, x, data, pens, fore_color, 0); + set_8_pixels(screen->machine, bitmap, y, x, data, pens, fore_color, 0); } - clear_extra_columns(bitmap, pens, 0); + clear_extra_columns(screen->machine, bitmap, pens, 0); return 0; } diff --git a/src/mame/video/mw8080bw.c b/src/mame/video/mw8080bw.c index 700ceb10a3a..71d6e3d07d7 100644 --- a/src/mame/video/mw8080bw.c +++ b/src/mame/video/mw8080bw.c @@ -5,12 +5,12 @@ ****************************************************************************/ #include "driver.h" -#include "mw8080bw.h" - +#include "includes/mw8080bw.h" VIDEO_UPDATE( mw8080bw ) { + mw8080bw_state *state = (mw8080bw_state *)screen->machine->driver_data; UINT8 x = 0; UINT8 y = MW8080BW_VCOUNTER_START_NO_VBLANK; UINT8 video_data = 0; @@ -51,7 +51,7 @@ VIDEO_UPDATE( mw8080bw ) else if ((x & 0x07) == 0x04) { offs_t offs = ((offs_t)y << 5) | (x >> 3); - video_data = mw8080bw_ram[offs]; + video_data = state->main_ram[offs]; } } @@ -67,16 +67,17 @@ VIDEO_UPDATE( mw8080bw ) *************************************/ -#define PHANTOM2_BOTTOM_TRENCH_DARK_RGB32_PEN RGB_BLACK -#define PHANTOM2_BOTTOM_TRENCH_LIGHT_RGB32_PEN MAKE_RGB(0x5a, 0x5a, 0x5a) -#define PHANTOM2_TOP_TRENCH_DARK_RGB32_PEN RGB_BLACK -#define PHANTOM2_TOP_TRENCH_LIGHT_RGB32_PEN RGB_WHITE -#define PHANTOM2_SIDE_TRENCH_DARK_RGB32_PEN RGB_BLACK -#define PHANTOM2_SIDE_TRENCH_LIGHT_RGB32_PEN MAKE_RGB(0x72, 0x72, 0x72) +#define PHANTOM2_BOTTOM_TRENCH_DARK_RGB32_PEN RGB_BLACK +#define PHANTOM2_BOTTOM_TRENCH_LIGHT_RGB32_PEN MAKE_RGB(0x5a, 0x5a, 0x5a) +#define PHANTOM2_TOP_TRENCH_DARK_RGB32_PEN RGB_BLACK +#define PHANTOM2_TOP_TRENCH_LIGHT_RGB32_PEN RGB_WHITE +#define PHANTOM2_SIDE_TRENCH_DARK_RGB32_PEN RGB_BLACK +#define PHANTOM2_SIDE_TRENCH_LIGHT_RGB32_PEN MAKE_RGB(0x72, 0x72, 0x72) VIDEO_UPDATE( spcenctr ) { + mw8080bw_state *state = (mw8080bw_state *)screen->machine->driver_data; UINT8 line_buf[256]; /* 256x1 bit RAM */ UINT8 x = 0; @@ -85,9 +86,9 @@ VIDEO_UPDATE( spcenctr ) UINT8 draw_line = 0; UINT8 draw_trench = 0; UINT8 draw_floor = 0; - UINT8 width = spcenctr_get_trench_width(); + UINT8 width = state->spcenctr_trench_width; UINT8 floor_width = width; - UINT8 center = spcenctr_get_trench_center(); + UINT8 center = state->spcenctr_trench_center; memset(line_buf, 0, 256); @@ -149,7 +150,7 @@ VIDEO_UPDATE( spcenctr ) /* update the trench control for the next line */ offs = ((offs_t)y << 5) | 0x1f; - trench_control = mw8080bw_ram[offs]; + trench_control = state->main_ram[offs]; if (trench_control & 0x40) draw_trench = 1; @@ -167,11 +168,11 @@ VIDEO_UPDATE( spcenctr ) /* add the lower 2 bits stored in the slope array to width */ if (draw_trench) - width = width + (spcenctr_get_trench_slope(y) & 0x03); + width = width + (state->spcenctr_trench_slope[y & 0x0f] & 0x03); /* add the higher 2 bits stored in the slope array to floor width */ if (draw_floor) - floor_width = floor_width + ((spcenctr_get_trench_slope(y) & 0x0c) >> 2); + floor_width = floor_width + ((state->spcenctr_trench_slope[y & 0x0f] & 0x0c) >> 2); /* next row, video_data is now 0, so the next line will start with 4 blank pixels */ @@ -185,7 +186,7 @@ VIDEO_UPDATE( spcenctr ) else if ((x & 0x07) == 0x04) { offs_t offs = ((offs_t)y << 5) | (x >> 3); - video_data = mw8080bw_ram[offs]; + video_data = state->main_ram[offs]; } } @@ -211,21 +212,22 @@ VIDEO_UPDATE( spcenctr ) Bits 1-7 go to address line A4-A10 of the cloud gfx prom. */ -#define PHANTOM2_CLOUD_COUNTER_START (0x0e0b) -#define PHANTOM2_CLOUD_COUNTER_END (0x1000) -#define PHANTOM2_CLOUD_COUNTER_PERIOD (PHANTOM2_CLOUD_COUNTER_END - PHANTOM2_CLOUD_COUNTER_START) +#define PHANTOM2_CLOUD_COUNTER_START (0x0e0b) +#define PHANTOM2_CLOUD_COUNTER_END (0x1000) +#define PHANTOM2_CLOUD_COUNTER_PERIOD (PHANTOM2_CLOUD_COUNTER_END - PHANTOM2_CLOUD_COUNTER_START) -#define PHANTOM2_RGB32_CLOUD_PEN MAKE_RGB(0xc0, 0xc0, 0xc0) +#define PHANTOM2_RGB32_CLOUD_PEN MAKE_RGB(0xc0, 0xc0, 0xc0) VIDEO_UPDATE( phantom2 ) { + mw8080bw_state *state = (mw8080bw_state *)screen->machine->driver_data; UINT8 x = 0; UINT8 y = MW8080BW_VCOUNTER_START_NO_VBLANK; UINT8 video_data = 0; UINT8 cloud_data = 0; - UINT16 cloud_counter = phantom2_get_cloud_counter(); + UINT16 cloud_counter = state->phantom2_cloud_counter; UINT8 *cloud_region = memory_region(screen->machine, "proms"); @@ -301,7 +303,7 @@ VIDEO_UPDATE( phantom2 ) else if ((x & 0x07) == 0x04) { offs_t offs = ((offs_t)y << 5) | (x >> 3); - video_data = mw8080bw_ram[offs]; + video_data = state->main_ram[offs]; } } @@ -311,18 +313,15 @@ VIDEO_UPDATE( phantom2 ) VIDEO_EOF( phantom2 ) { - UINT16 cloud_counter = phantom2_get_cloud_counter(); + mw8080bw_state *state = (mw8080bw_state *)machine->driver_data; - cloud_counter = cloud_counter + MW8080BW_VTOTAL; + state->phantom2_cloud_counter += MW8080BW_VTOTAL; - if (cloud_counter >= PHANTOM2_CLOUD_COUNTER_END) - cloud_counter = PHANTOM2_CLOUD_COUNTER_START + (cloud_counter - PHANTOM2_CLOUD_COUNTER_END); - - phantom2_set_cloud_counter(cloud_counter); + if (state->phantom2_cloud_counter >= PHANTOM2_CLOUD_COUNTER_END) + state->phantom2_cloud_counter = PHANTOM2_CLOUD_COUNTER_START + (state->phantom2_cloud_counter - PHANTOM2_CLOUD_COUNTER_END); } - /************************************* * * Space Invaders @@ -334,10 +333,11 @@ VIDEO_EOF( phantom2 ) VIDEO_UPDATE( invaders ) { + mw8080bw_state *state = (mw8080bw_state *)screen->machine->driver_data; UINT8 x = 0; UINT8 y = MW8080BW_VCOUNTER_START_NO_VBLANK; UINT8 video_data = 0; - UINT8 flip = invaders_is_flip_screen(); + UINT8 flip = state->invaders_flip_screen; while (1) { @@ -383,7 +383,7 @@ VIDEO_UPDATE( invaders ) else if ((x & 0x07) == 0x04) { offs_t offs = ((offs_t)y << 5) | (x >> 3); - video_data = mw8080bw_ram[offs]; + video_data = state->main_ram[offs]; } }