From f1d80bcabce585438a678665774662f89ee7b885 Mon Sep 17 00:00:00 2001 From: Toni Wilen Date: Wed, 10 Feb 2021 19:04:36 +0200 Subject: [PATCH] Fix CDTV and CD32 statefile restore with paused CD audio and CD32 CD audio mute. --- akiko.cpp | 24 ++++++++++++++++-------- cdtv.cpp | 6 +++++- cia.cpp | 8 ++------ 3 files changed, 23 insertions(+), 15 deletions(-) diff --git a/akiko.cpp b/akiko.cpp index a146ccff..f9f8cf37 100644 --- a/akiko.cpp +++ b/akiko.cpp @@ -1527,23 +1527,23 @@ static void akiko_thread (void *null) switch (b) { case 0x0102: // pause - sys_command_cd_pause (unitnum, 1); + sys_command_cd_pause(unitnum, 1); break; case 0x0103: // unpause - sys_command_cd_pause (unitnum, 0); + sys_command_cd_pause(unitnum, 0); break; case 0x0104: // stop cdaudiostop_do (); break; case 0x0105: // mute change - sys_command_cd_volume (unitnum, cdrom_muted ? 0 : 0x7fff, cdrom_muted ? 0 : 0x7fff); + sys_command_cd_volume(unitnum, cdrom_muted ? 0 : 0x7fff, cdrom_muted ? 0 : 0x7fff); break; case 0x0111: // instant play sys_command_cd_volume(unitnum, cdrom_muted ? 0 : 0x7fff, cdrom_muted ? 0 : 0x7fff); cdaudioplay_do(true); break; case 0x0110: // do_play! - sys_command_cd_volume (unitnum, cdrom_muted ? 0 : 0x7fff, cdrom_muted ? 0 : 0x7fff); + sys_command_cd_volume(unitnum, cdrom_muted ? 0 : 0x7fff, cdrom_muted ? 0 : 0x7fff); cdaudioplay_do(false); break; } @@ -2304,6 +2304,7 @@ void restore_akiko_final(void) if (!currprefs.cs_cd32cd) return; write_comm_pipe_u32(&requests, 0x0102, 1); // pause + write_comm_pipe_u32(&requests, 0x0105, 1); // set mute write_comm_pipe_u32(&requests, 0x0104, 1); // stop write_comm_pipe_u32(&requests, 0x0103, 1); // unpause if (cdrom_playing && isaudiotrack(last_play_pos)) { @@ -2311,7 +2312,11 @@ void restore_akiko_final(void) write_comm_pipe_u32(&requests, last_play_pos, 0); write_comm_pipe_u32(&requests, last_play_end, 0); write_comm_pipe_u32(&requests, 0, 1); - uae_sem_wait(&cda_sem); + if (!cdrom_paused) { + uae_sem_wait(&cda_sem); + } else { + write_comm_pipe_u32(&requests, 0x0102, 1); // pause + } } cd_initialized = 2; } @@ -2320,8 +2325,11 @@ void restore_akiko_final(void) void akiko_mute (int muted) { - cdrom_muted = muted; - if (unitnum >= 0) - write_comm_pipe_u32 (&requests, 0x0105, 1); + if (muted != cdrom_muted) { + cdrom_muted = muted; + if (currprefs.cs_cd32cd && unitnum >= 0) { + write_comm_pipe_u32(&requests, 0x0105, 1); + } + } } diff --git a/cdtv.cpp b/cdtv.cpp index 43541a35..07fa45cd 100644 --- a/cdtv.cpp +++ b/cdtv.cpp @@ -1941,7 +1941,11 @@ void restore_cdtv_final(void) write_comm_pipe_u32(&requests, last_play_pos, 0); write_comm_pipe_u32(&requests, last_play_end, 0); write_comm_pipe_u32(&requests, 0, 1); - uae_sem_wait(&cda_sem); + if (cd_paused) { + write_comm_pipe_u32(&requests, 0x0105, 1); // paused + } else { + uae_sem_wait(&cda_sem); + } } } diff --git a/cia.cpp b/cia.cpp index a4f5ea01..19d64180 100644 --- a/cia.cpp +++ b/cia.cpp @@ -87,7 +87,7 @@ static unsigned long ciaata_passed, ciaatb_passed, ciabta_passed, ciabtb_passed; static unsigned long ciaatod, ciabtod, ciaatol, ciabtol, ciaaalarm, ciabalarm; static int ciaatlatch, ciabtlatch; -static bool oldovl, oldcd32mute; +static bool oldovl; static bool led; static int led_old_brightness; static unsigned long led_cycles_on, led_cycles_off, led_cycle; @@ -1028,10 +1028,7 @@ static void bfe001_change(void) map_overlay(0); } } - if (currprefs.cs_cd32cd && (v & 1) != oldcd32mute) { - oldcd32mute = v & 1; - akiko_mute(oldcd32mute ? 0 : 1); - } + akiko_mute((v & 1) == 0); } static uae_u32 getciatod(uae_u32 tod) @@ -1896,7 +1893,6 @@ void CIA_reset (void) kblostsynccnt = 0; serbits = 0; - oldcd32mute = 1; resetwarning_phase = resetwarning_timer = 0; heartbeat_cnt = 0; ciab_tod_event_state = 0; -- 2.47.3