From 4a82eaf6c68fc6577f586d18df80785bdb42163c Mon Sep 17 00:00:00 2001 From: Thomas GUILLEMIN Date: Wed, 7 Jun 2023 17:47:25 +0200 Subject: [PATCH 1/2] Fix tape, to be error prone Fix recording, using path --- CPCCoreEmu/SoundMixer.cpp | 27 ++++++++++----------- CPCCoreEmu/Tape.cpp | 29 ++++++++++++----------- CPCCoreEmu/Tape.h | 2 +- UnitTests/CMakeLists.txt | 49 --------------------------------------- 4 files changed, 31 insertions(+), 76 deletions(-) diff --git a/CPCCoreEmu/SoundMixer.cpp b/CPCCoreEmu/SoundMixer.cpp index 786ea59..7c70ed1 100644 --- a/CPCCoreEmu/SoundMixer.cpp +++ b/CPCCoreEmu/SoundMixer.cpp @@ -492,28 +492,29 @@ bool SoundMixer::GetNewSoundFile(char * buffer, unsigned int size) #ifndef RASPPI bool name_is_ok = false; - char exe_path[MAX_PATH]; - strcpy(exe_path, ".\\REC\\"); + const fs::path exe_path = "./REC/"; + // Create record directory if necessary + if (!fs::exists(exe_path)) + { + fs::create_directories(exe_path); + } // Create new sound file unsigned int inc = 0; while (!name_is_ok && inc <= 9999) { - sprintf(buffer, "%sSND%4.4i.WAV", exe_path, inc); - const std::regex my_filter(buffer); + char sound_name[16]; + sprintf(sound_name, "SND%4.4i.WAV", inc++); - for (auto& p : fs::directory_iterator(exe_path)) + fs::path sound_file = exe_path / fs::path(sound_name); + + if ( !fs::exists(sound_file)) { - if (fs::is_regular_file(p.status())) - { - if (regex_match(p.path().filename().generic_string().c_str(), my_filter)) - { - name_is_ok = true; - break; - } - } + name_is_ok = true; + strncpy(buffer, sound_file.string().c_str(), size); } + } return name_is_ok; #else diff --git a/CPCCoreEmu/Tape.cpp b/CPCCoreEmu/Tape.cpp index e0b5593..abcf1b5 100644 --- a/CPCCoreEmu/Tape.cpp +++ b/CPCCoreEmu/Tape.cpp @@ -2870,23 +2870,26 @@ double CTape::GetSoundVolume () void CTape::SetTapePosition ( unsigned int nb_sec_from_begining) { - unsigned long long nbu_sec = 0; - unsigned int nb_sec = 0; - unsigned int i; - for (i = 0; i < nb_inversions_ && ( nb_sec < nb_sec_from_begining ); i++) + if (nb_inversions_ > 0) { - // Size of this inversion / sample rate = nb of samples - nbu_sec += tape_array_[i].length ; - while ( nbu_sec > 4000000) + unsigned long long nbu_sec = 0; + int nb_sec = 0; + unsigned int i; + for (i = 0; i < nb_inversions_ && (nb_sec < nb_sec_from_begining); i++) { - nb_sec ++; - nbu_sec -= 4000000; + // Size of this inversion / sample rate = nb of samples + nbu_sec += tape_array_[i].length; + while (nbu_sec > 4000000) + { + nb_sec++; + nbu_sec -= 4000000; + } } + tape_position_ = i; + remaining_reversal_flux_ = tape_array_[tape_position_].length - nbu_sec; + counter_sec_ = nb_sec; + counter_us_ = nbu_sec; } - tape_position_ = i; - remaining_reversal_flux_ = tape_array_[tape_position_].length - nbu_sec; - counter_sec_ = nb_sec; - counter_us_ = nbu_sec; } diff --git a/CPCCoreEmu/Tape.h b/CPCCoreEmu/Tape.h index 9e10eae..9280cea 100644 --- a/CPCCoreEmu/Tape.h +++ b/CPCCoreEmu/Tape.h @@ -64,7 +64,7 @@ class CTape : public IComponent, public IExternalSource, public ILoadingProgress { public: CTape(void); - ~CTape(void); + virtual ~CTape(void); void SetLog ( ILog* log ) {log_ = log;}; void SetNotifier ( IFdcNotify* notify_tape){tape_notifier_ = notify_tape;} diff --git a/UnitTests/CMakeLists.txt b/UnitTests/CMakeLists.txt index 6f21402..282653f 100644 --- a/UnitTests/CMakeLists.txt +++ b/UnitTests/CMakeLists.txt @@ -86,52 +86,3 @@ install ( DIRECTORY "./ROM" DESTINATION ${PROJECT_BINARY_DIR}/..) install ( DIRECTORY "./CART" DESTINATION ${PROJECT_BINARY_DIR}/..) install ( DIRECTORY "./CONF" DESTINATION ${PROJECT_BINARY_DIR}/..) install ( DIRECTORY "./res" DESTINATION ${PROJECT_BINARY_DIR}/..) - -# ini file -#install ( FILES "./TestConf.ini" CONFIGURATIONS Debug DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/Debug/ ) -#install ( FILES "./TestConf.ini" CONFIGURATIONS Release DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/Release/ ) -#install ( FILES "./TestConf.ini" CONFIGURATIONS RelWithDebInfo DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/RelWithDebInfo/ ) -# -## ROM & CONF -#install ( DIRECTORY "./ROM" CONFIGURATIONS Debug DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/Debug/ ) -#install ( DIRECTORY "./ROM" CONFIGURATIONS Release DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/Release/ ) -#install ( DIRECTORY "./ROM" CONFIGURATIONS RelWithDebInfo DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/RelWithDebInfo/ ) -# -## CARTs -#install ( DIRECTORY "./CART" CONFIGURATIONS Debug DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/Debug/) -#install ( DIRECTORY "./CART" CONFIGURATIONS Release DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/Release/) -#install ( DIRECTORY "./CART" CONFIGURATIONS RelWithDebInfo DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/RelWithDebInfo/) -# -#install ( DIRECTORY "./CONF" CONFIGURATIONS Debug DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/Debug/ ) -#install ( DIRECTORY "./CONF" CONFIGURATIONS Release DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/Release/ ) -#install ( DIRECTORY "./CONF" CONFIGURATIONS RelWithDebInfo DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/RelWithDebInfo/ ) -## Res -#install ( DIRECTORY "./res" CONFIGURATIONS Debug DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/Debug/ ) -#install ( DIRECTORY "./res" CONFIGURATIONS Release DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/Release/ ) -#install ( DIRECTORY "./res" CONFIGURATIONS RelWithDebInfo DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/RelWithDebInfo/ ) - -#zlib1.dll - - -#file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/res/After Burner" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/res" ) -#file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/res/CONF" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}" ) -#file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/res/ROM" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}" ) -#file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/res/z80" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/res" ) -#file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/res/Dsk" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/res" ) -#file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/res/Record" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/res" ) -# -#configure_file("${CMAKE_CURRENT_SOURCE_DIR}/res/DEATHSWORD128K.DSK" "${CMAKE_CURRENT_BINARY_DIR}/res/DEATHSWORD128K.DSK" COPYONLY) -#configure_file("${CMAKE_CURRENT_SOURCE_DIR}/res/Discology60PlusA1 [MAXIT][SAMdisk36B19][Original].dsk" "${CMAKE_CURRENT_BINARY_DIR}/res/Discology60PlusA1 [MAXIT][SAMdisk36B19][Original].dsk" COPYONLY) -#configure_file("${CMAKE_CURRENT_SOURCE_DIR}/res/30YMD double sides 1 and 2.hfe" "${CMAKE_CURRENT_BINARY_DIR}/res/30YMD double sides 1 and 2.hfe" COPYONLY) -#configure_file("${CMAKE_CURRENT_SOURCE_DIR}/res/1942.raw" "${CMAKE_CURRENT_BINARY_DIR}/res/1942.raw" COPYONLY) -#configure_file("${CMAKE_CURRENT_SOURCE_DIR}/res/After Burner (UK) (1988) [Activision SEGA] (Pre-release).ipf" "${CMAKE_CURRENT_BINARY_DIR}/res/After Burner (UK) (1988) [Activision SEGA] (Pre-release).ipf" COPYONLY) -#configure_file("${CMAKE_CURRENT_SOURCE_DIR}/res/The Demo [A].scp" "${CMAKE_CURRENT_BINARY_DIR}/res/The Demo [A].scp" COPYONLY) -#configure_file("${CMAKE_CURRENT_SOURCE_DIR}/res/necro.sfw" "${CMAKE_CURRENT_BINARY_DIR}/res/necro.sfw" COPYONLY) -# -#configure_file("${CMAKE_CURRENT_SOURCE_DIR}/res/Basil The Great Mouse Detective (UK) (1987) [Original] [TAPE].cdt" "${CMAKE_CURRENT_BINARY_DIR}/res/Basil The Great Mouse Detective (UK) (1987) [Original] [TAPE].cdt" COPYONLY) -#configure_file("${CMAKE_CURRENT_SOURCE_DIR}/res/Mask_1_1.csw" "${CMAKE_CURRENT_BINARY_DIR}/res/Mask_1_1.csw" COPYONLY) -#configure_file("${CMAKE_CURRENT_SOURCE_DIR}/res/Ultima Ratio (Firebird)(UK)(1987)[Original][TAPE].csw" "${CMAKE_CURRENT_BINARY_DIR}/res/Ultima Ratio (Firebird)(UK)(1987)[Original][TAPE].csw" COPYONLY) -#configure_file("${CMAKE_CURRENT_SOURCE_DIR}/res/FootBallerOfTheYear2.wav" "${CMAKE_CURRENT_BINARY_DIR}/res/FootBallerOfTheYear2.wav" COPYONLY) -#configure_file("${CMAKE_CURRENT_SOURCE_DIR}/res/K7_MICK.VOC" "${CMAKE_CURRENT_BINARY_DIR}/res/K7_MICK.VOC" COPYONLY) -# -#configure_file("${CMAKE_CURRENT_SOURCE_DIR}/res/TestConf.ini" "${CMAKE_CURRENT_BINARY_DIR}/TestConf.ini" COPYONLY) From 821ac91d46c31a34d66f917b3ce6ae190e975c6d Mon Sep 17 00:00:00 2001 From: Thomas GUILLEMIN Date: Thu, 8 Jun 2023 12:08:33 +0200 Subject: [PATCH 2/2] Fix: remove accentued characters --- CPCCoreEmu/BreakpointHandler.h | 1 - CPCCoreEmu/Machine.h | 2 +- CPCCoreEmu/Sig.h | 2 +- CPCCoreEmu/VGA.h | 2 +- 4 files changed, 3 insertions(+), 4 deletions(-) diff --git a/CPCCoreEmu/BreakpointHandler.h b/CPCCoreEmu/BreakpointHandler.h index 413a80d..bb3a9c4 100644 --- a/CPCCoreEmu/BreakpointHandler.h +++ b/CPCCoreEmu/BreakpointHandler.h @@ -27,7 +27,6 @@ class BreakpointHandler : public IBreakpoint virtual void ToggleBreakpoint ( unsigned short addr ); virtual int GetBreakpointNumber() { return breakpoint_number_; }; void AddBreakpoint(IBreakpointItem* breakpoint); - // Impl�mentation void ClearBreakpoints(); void CreateBreakpoint(int indice, std::vector param); diff --git a/CPCCoreEmu/Machine.h b/CPCCoreEmu/Machine.h index ac9a3aa..9c9dc33 100644 --- a/CPCCoreEmu/Machine.h +++ b/CPCCoreEmu/Machine.h @@ -237,7 +237,7 @@ class CPCCOREEMU_API EmulatorEngine : public ILoadingProgree void MultifaceStop (){multiface_stop_ = true;} void MultifaceToggleVisible (){multiface2_.Visible(multiface2_.IsVisible()?false:true);}; bool IsMultifaceIIVisible () { return multiface2_.IsVisible();}; - // Donn�es + // Data IPrinterPort* GetPrinter () { return motherboard_.GetPrinter();}; Memory* GetMem () { return motherboard_.GetMem();}; Asic* GetAsic() { return motherboard_.GetAsic(); } diff --git a/CPCCoreEmu/Sig.h b/CPCCoreEmu/Sig.h index 89a1742..160101e 100644 --- a/CPCCoreEmu/Sig.h +++ b/CPCCoreEmu/Sig.h @@ -70,7 +70,7 @@ class CPCCOREEMU_API CSig // Bus d'adresse Bus* address_bus_; - // Bus de donn�es + // Data bus Bus* data_bus_; // ASIC diff --git a/CPCCoreEmu/VGA.h b/CPCCoreEmu/VGA.h index 92c91ff..9016d8a 100644 --- a/CPCCoreEmu/VGA.h +++ b/CPCCoreEmu/VGA.h @@ -101,7 +101,7 @@ class CPCCOREEMU_API GateArray : public IComponent // Bus d'adresse Bus* address_bus_; - // Bus de donn�es + // Data bus Bus* data_bus_; // Signaux;