diff --git a/src/mame/audio/atarijsa.c b/src/mame/audio/atarijsa.c index 34aa8fc0438..5e32327ac0a 100644 --- a/src/mame/audio/atarijsa.c +++ b/src/mame/audio/atarijsa.c @@ -46,9 +46,6 @@ Static Program ROM (48K bytes) 4000-FFFF R D0-D7 static UINT8 *bank_base; static UINT8 *bank_source_data; -static UINT8 speech_data; -static UINT8 last_ctl; - static running_device *jsacpu; static const char *test_port; static UINT16 test_mask; @@ -101,9 +98,6 @@ ADDRESS_MAP_END static void init_save_state(running_machine *machine) { - state_save_register_global(machine, speech_data); - state_save_register_global(machine, last_ctl); - state_save_register_global(machine, overall_volume); state_save_register_global(machine, pokey_volume); state_save_register_global(machine, ym2151_volume); @@ -178,8 +172,6 @@ void atarijsa_reset(void) atarigen_sound_io_reset(jsacpu); /* reset the static states */ - speech_data = 0; - last_ctl = 0; overall_volume = 100; pokey_volume = 100; ym2151_volume = 100; @@ -228,7 +220,10 @@ static READ8_HANDLER( jsa1_io_r ) if (!(input_port_read(space->machine, test_port) & test_mask)) result ^= 0x80; if (atarigen->cpu_to_sound_ready) result ^= 0x40; if (atarigen->sound_to_cpu_ready) result ^= 0x20; - if (tms5220 == NULL || !tms5220_readyq_r(tms5220)) result ^= 0x10; + if ((tms5220 != NULL) && (tms5220_readyq_r(tms5220) == 0)) + result |= 0x10; + else + result &= ~0x10; break; case 0x006: /* /IRQACK */ @@ -262,7 +257,7 @@ static WRITE8_HANDLER( jsa1_io_w ) break; case 0x200: /* /VOICE */ - speech_data = data; + tms5220_data_w(tms5220, 0, data); break; case 0x202: /* /WRP */ @@ -284,14 +279,14 @@ static WRITE8_HANDLER( jsa1_io_w ) if (tms5220 != NULL) { int count; - - tms5220_wsq_w(tms5220, (data&0x02)?1:0); - tms5220_rsq_w(tms5220, (data&0x04)?1:0); - if (((data ^ last_ctl) & 0x02) && (data & 0x02)) - tms5220_data_w(tms5220, 0, speech_data); + tms5220_wsq_w(tms5220, (data&0x02)>>1); + tms5220_rsq_w(tms5220, (data&0x04)>>2); count = 5 | ((data >> 2) & 2); tms5220_set_frequency(tms5220, JSA_MASTER_CLOCK*2 / (16 - count)); } + + /* reset the YM2151 if needed */ + if ((data&1) == 0) devtag_reset(space->machine, "ymsnd"); /* coin counters */ coin_counter_w(space->machine, 1, (data >> 5) & 1); @@ -299,7 +294,6 @@ static WRITE8_HANDLER( jsa1_io_w ) /* update the bank */ memcpy(bank_base, &bank_source_data[0x1000 * ((data >> 6) & 3)], 0x1000); - last_ctl = data; break; case 0x206: /* MIX */ @@ -411,10 +405,12 @@ static WRITE8_HANDLER( jsa2_io_w ) 0x02 = n/c 0x01 = YM2151 reset (active low) */ + + /* reset the YM2151 if needed */ + if ((data&1) == 0) devtag_reset(space->machine, "ymsnd"); /* update the bank */ memcpy(bank_base, &bank_source_data[0x1000 * ((data >> 6) & 3)], 0x1000); - last_ctl = data; /* coin counters */ coin_counter_w(space->machine, 1, (data >> 5) & 1); @@ -534,6 +530,9 @@ static WRITE8_HANDLER( jsa3_io_w ) 0x02 = OKI6295 bank bit 0 0x01 = YM2151 reset (active low) */ + + /* reset the YM2151 if needed */ + if ((data&1) == 0) devtag_reset(space->machine, "ymsnd"); /* update the OKI bank */ if (oki6295 != NULL) @@ -541,7 +540,6 @@ static WRITE8_HANDLER( jsa3_io_w ) /* update the bank */ memcpy(bank_base, &bank_source_data[0x1000 * ((data >> 6) & 3)], 0x1000); - last_ctl = data; /* coin counters */ coin_counter_w(space->machine, 1, (data >> 5) & 1); @@ -666,13 +664,15 @@ static WRITE8_HANDLER( jsa3s_io_w ) 0x02 = left OKI6295 bank bit 0 0x01 = YM2151 reset (active low) */ + + /* reset the YM2151 if needed */ + if ((data&1) == 0) devtag_reset(space->machine, "ymsnd"); /* update the OKI bank */ memory_set_bank(space->machine, "bank12", (memory_get_bank(space->machine, "bank12") & 2) | ((data >> 1) & 1)); /* update the bank */ memcpy(bank_base, &bank_source_data[0x1000 * ((data >> 6) & 3)], 0x1000); - last_ctl = data; /* coin counters */ coin_counter_w(space->machine, 1, (data >> 5) & 1);