From e2e690612efd58619d58e7e21f4052bf4bc818fd Mon Sep 17 00:00:00 2001 From: dinkc64 <12570148+dinkc64@users.noreply.github.com> Date: Sat, 27 Feb 2016 00:39:33 +0000 Subject: [PATCH] snd/ymdeltat.c: fix for crash in gwar --- src/burn/snd/ymdeltat.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/burn/snd/ymdeltat.c b/src/burn/snd/ymdeltat.c index b3c8a0a4f..0ece10ea3 100644 --- a/src/burn/snd/ymdeltat.c +++ b/src/burn/snd/ymdeltat.c @@ -489,6 +489,22 @@ INLINE void YM_DELTAT_synthesis_from_external_memory(YM_DELTAT *DELTAT) if ( DELTAT->now_addr == (DELTAT->limit<<1) ) DELTAT->now_addr = 0; + if ( DELTAT->now_addr >= (DELTAT->memory_size<<1) ) { + /* 2-26-2016 DINK@FBAlpha: solution for crash in gwar when loading a savestate as player death sample is playing. */ + /* set EOS bit in status register */ + if(DELTAT->status_set_handler) + if(DELTAT->status_change_EOS_bit) + (DELTAT->status_set_handler)(DELTAT->status_change_which_chip, DELTAT->status_change_EOS_bit); + + /* clear PCM BUSY bit (reflected in status register) */ + DELTAT->PCM_BSY = 0; + + DELTAT->portstate = 0; + DELTAT->adpcml = 0; + DELTAT->prev_acc = 0; + return; + } + if ( DELTAT->now_addr == (DELTAT->end<<1) ) { /* 12-06-2001 JB: corrected comparison. Was > instead of == */ if( DELTAT->portstate&0x10 ){ /* repeat start */