From 24169507bd15c5d710c287afbe090a272799dbdb Mon Sep 17 00:00:00 2001 From: elasota Date: Sun, 9 May 2021 23:45:27 -0400 Subject: [PATCH] Add beep sound to platforms with no beep --- Aerofoil/GpSystemServices_Win32.cpp | 5 +++-- Aerofoil/GpSystemServices_Win32.h | 2 +- .../app/jni/main/GpSystemServices_Android.cpp | 8 +++++++- .../app/jni/main/GpSystemServices_Android.h | 3 ++- AerofoilWeb/GpSystemServices_Web.cpp | 8 +++++++- AerofoilWeb/GpSystemServices_Web.h | 3 ++- AerofoilX/GpSystemServices_X.cpp | 8 +++++++- AerofoilX/GpSystemServices_X.h | 3 ++- ApplicationResourcePatches/DITL/2005.json | 12 ++++++++++-- ApplicationResourcePatches/SND/1063.wav | Bin 0 -> 13568 bytes ApplicationResourcePatches/manifest.json | 3 ++- CMakeLists.txt | 1 - GpApp/About.cpp | 2 +- GpApp/GliderDefines.h | 4 +++- GpApp/Sound.cpp | 14 ++++++++++++-- GpCommon/IGpSystemServices.h | 2 +- PortabilityLayer/DialogManager.cpp | 5 +++-- PortabilityLayer/FileBrowserUI.cpp | 7 ++++--- PortabilityLayer/PLApplication.cpp | 11 ++++++++++- PortabilityLayer/PLApplication.h | 6 +++++- PortabilityLayer/PLSound.cpp | 3 +++ 21 files changed, 85 insertions(+), 25 deletions(-) create mode 100644 ApplicationResourcePatches/SND/1063.wav diff --git a/Aerofoil/GpSystemServices_Win32.cpp b/Aerofoil/GpSystemServices_Win32.cpp index 7c56fa0..88d8e29 100644 --- a/Aerofoil/GpSystemServices_Win32.cpp +++ b/Aerofoil/GpSystemServices_Win32.cpp @@ -232,9 +232,10 @@ uint64_t GpSystemServices_Win32::GetFreeMemoryCosmetic() const return memStatus.ullAvailPhys; } -void GpSystemServices_Win32::Beep() const +bool GpSystemServices_Win32::Beep() const { MessageBeep(MB_OK); + return true; } bool GpSystemServices_Win32::IsTouchscreen() const @@ -264,7 +265,7 @@ bool GpSystemServices_Win32::IsFullscreenOnStartup() const bool GpSystemServices_Win32::HasNativeFileManager() const { - return false; + return true; } unsigned int GpSystemServices_Win32::GetCPUCount() const diff --git a/Aerofoil/GpSystemServices_Win32.h b/Aerofoil/GpSystemServices_Win32.h index 8830ed2..cb0f274 100644 --- a/Aerofoil/GpSystemServices_Win32.h +++ b/Aerofoil/GpSystemServices_Win32.h @@ -28,7 +28,7 @@ public: void *CreateThread(ThreadFunc_t threadFunc, void *context) override; IGpThreadEvent *CreateThreadEvent(bool autoReset, bool startSignaled) override; uint64_t GetFreeMemoryCosmetic() const override; - void Beep() const override; + bool Beep() const override; bool IsTouchscreen() const override; bool IsUsingMouseAsTouch() const override; bool IsTextInputObstructive() const override; diff --git a/AerofoilAndroid/app/jni/main/GpSystemServices_Android.cpp b/AerofoilAndroid/app/jni/main/GpSystemServices_Android.cpp index 1cefa7e..468abba 100644 --- a/AerofoilAndroid/app/jni/main/GpSystemServices_Android.cpp +++ b/AerofoilAndroid/app/jni/main/GpSystemServices_Android.cpp @@ -55,8 +55,9 @@ void *GpSystemServices_Android::CreateThread(ThreadFunc_t threadFunc, void *cont return thread; } -void GpSystemServices_Android::Beep() const +bool GpSystemServices_Android::Beep() const { + return false; } bool GpSystemServices_Android::IsTouchscreen() const @@ -84,6 +85,11 @@ bool GpSystemServices_Android::IsFullscreenOnStartup() const return true; } +bool GpSystemServices_Android::HasNativeFileManager() const +{ + return false; +} + unsigned int GpSystemServices_Android::GetCPUCount() const { return SDL_GetCPUCount(); diff --git a/AerofoilAndroid/app/jni/main/GpSystemServices_Android.h b/AerofoilAndroid/app/jni/main/GpSystemServices_Android.h index 81c9985..881cbbf 100644 --- a/AerofoilAndroid/app/jni/main/GpSystemServices_Android.h +++ b/AerofoilAndroid/app/jni/main/GpSystemServices_Android.h @@ -9,12 +9,13 @@ public: GpSystemServices_Android(); void *CreateThread(ThreadFunc_t threadFunc, void *context) override; - void Beep() const override; + bool Beep() const override; bool IsTouchscreen() const override; bool IsUsingMouseAsTouch() const override; bool IsTextInputObstructive() const override; bool IsFullscreenPreferred() const override; bool IsFullscreenOnStartup() const override; + bool HasNativeFileManager() const override; unsigned int GetCPUCount() const override; void SetTextInputEnabled(bool isEnabled) override; bool IsTextInputEnabled() const override; diff --git a/AerofoilWeb/GpSystemServices_Web.cpp b/AerofoilWeb/GpSystemServices_Web.cpp index 25f3147..545fe63 100644 --- a/AerofoilWeb/GpSystemServices_Web.cpp +++ b/AerofoilWeb/GpSystemServices_Web.cpp @@ -136,8 +136,9 @@ void *GpSystemServices_Web::CreateThread(ThreadFunc_t threadFunc, void *context) return nullptr; } -void GpSystemServices_Web::Beep() const +bool GpSystemServices_Web::Beep() const { + return false; } bool GpSystemServices_Web::IsTouchscreen() const @@ -165,6 +166,11 @@ bool GpSystemServices_Web::IsFullscreenOnStartup() const return false; } +bool GpSystemServices_Web::HasNativeFileManager() const +{ + return false; +} + unsigned int GpSystemServices_Web::GetCPUCount() const { return SDL_GetCPUCount(); diff --git a/AerofoilWeb/GpSystemServices_Web.h b/AerofoilWeb/GpSystemServices_Web.h index ebc7e5d..4aafd63 100644 --- a/AerofoilWeb/GpSystemServices_Web.h +++ b/AerofoilWeb/GpSystemServices_Web.h @@ -12,12 +12,13 @@ public: ~GpSystemServices_Web(); void *CreateThread(ThreadFunc_t threadFunc, void *context) override; - void Beep() const override; + bool Beep() const override; bool IsTouchscreen() const override; bool IsUsingMouseAsTouch() const override; bool IsTextInputObstructive() const override; bool IsFullscreenPreferred() const override; bool IsFullscreenOnStartup() const override; + bool HasNativeFileManager() const override; unsigned int GetCPUCount() const override; void SetTextInputEnabled(bool isEnabled) override; bool IsTextInputEnabled() const override; diff --git a/AerofoilX/GpSystemServices_X.cpp b/AerofoilX/GpSystemServices_X.cpp index ed1401a..80f5247 100644 --- a/AerofoilX/GpSystemServices_X.cpp +++ b/AerofoilX/GpSystemServices_X.cpp @@ -64,8 +64,9 @@ void *GpSystemServices_X::CreateThread(ThreadFunc_t threadFunc, void *context) return thread; } -void GpSystemServices_X::Beep() const +bool GpSystemServices_X::Beep() const { + return false; } bool GpSystemServices_X::IsTouchscreen() const @@ -93,6 +94,11 @@ bool GpSystemServices_X::IsFullscreenOnStartup() const return false; } +bool GpSystemServices_X::HasNativeFileManager() const +{ + return true; +} + unsigned int GpSystemServices_X::GetCPUCount() const { return SDL_GetCPUCount(); diff --git a/AerofoilX/GpSystemServices_X.h b/AerofoilX/GpSystemServices_X.h index f9e9998..704eeab 100644 --- a/AerofoilX/GpSystemServices_X.h +++ b/AerofoilX/GpSystemServices_X.h @@ -12,12 +12,13 @@ public: ~GpSystemServices_X(); void *CreateThread(ThreadFunc_t threadFunc, void *context) override; - void Beep() const override; + bool Beep() const override; bool IsTouchscreen() const override; bool IsUsingMouseAsTouch() const override; bool IsTextInputObstructive() const override; bool IsFullscreenPreferred() const override; bool IsFullscreenOnStartup() const override; + bool HasNativeFileManager() const override; unsigned int GetCPUCount() const override; void SetTextInputEnabled(bool isEnabled) override; bool IsTextInputEnabled() const override; diff --git a/ApplicationResourcePatches/DITL/2005.json b/ApplicationResourcePatches/DITL/2005.json index 381f6df..351b1d4 100644 --- a/ApplicationResourcePatches/DITL/2005.json +++ b/ApplicationResourcePatches/DITL/2005.json @@ -4,7 +4,7 @@ { "name" : "Okay", "itemType" : "Button", - "pos" : [ 438, 292 ], + "pos" : [ 438, 316 ], "size" : [ 58, 20 ], "id" : 1, "enabled" : true @@ -12,7 +12,7 @@ { "name" : "Export Source Code to ZIP Archive...", "itemType" : "Button", - "pos" : [ 205, 292 ], + "pos" : [ 205, 316 ], "size" : [ 226, 20 ], "id" : 1, "enabled" : false @@ -176,6 +176,14 @@ "size" : [ 66, 20 ], "id" : 1, "enabled" : true + }, + { + "name" : "Ping sound original: Darrelle Jed Montojo (\"LittleRainySeasons\")", + "itemType" : "Label", + "pos" : [ 16, 277 ], + "size" : [ 406, 20 ], + "id" : 1, + "enabled" : true } ] } \ No newline at end of file diff --git a/ApplicationResourcePatches/SND/1063.wav b/ApplicationResourcePatches/SND/1063.wav new file mode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ny+KhZN+1aB5QP$>_!)3S6l~xquyHj7fh80Sk6J`6R6s5yT&Mi7Mq^2| zpm4+RKuH}Tij)#ffC>ndr(pu$`U<%k?GmaU7=1U4DX|?5U)K`bk)xb)djv|d5%dd% ztol8MDjiy$^1djVnP~Pnn%-hH% zYJrJ_Vo;barS%pl~}L{>@U1;J96@(OwVi2NQV| zXt^HBkH$hR$WhSpG{$OZwW8q3g&$scM!^xQ8`x1o!3NItHc`SSN;cN( zJ4&L!M^zRDit7nnp9Fs-greS#g@xjEDd8glftysLxE?Lk-bi1Mg3rEQpyNglz*|z1 z4F*T?!a<;RynzZ>i0ydety7J5lvpSPlkEjuMK25?`^H*UyurqsYyVxPgxOon`@0&r zMK0k6wb=OIJywhK|9`jeUlWbr)8Fko|9|0bwfGRe^S@~C$U(j%Chz>&y=BK1zgsP| zT2R+>kS*Fzb5o7^zzE$N2LT}H`HLTG6*ue4ui7w3fn|3Pz!y4Sd; zO$@m}g<(`{1CGU z{ZOLI%?*qFhD260EKg>#6k z@Fv8l#}eKfQ%YN<12nGVg?y*cEMyc=nSP^Nk^sjLh0s23XoAgEU8#BH>Q%iPN0Ez( Px-$9g*MxR_m1+Ag&{kVv literal 0 HcmV?d00001 diff --git a/ApplicationResourcePatches/manifest.json b/ApplicationResourcePatches/manifest.json index b05a6ab..2f74d3f 100644 --- a/ApplicationResourcePatches/manifest.json +++ b/ApplicationResourcePatches/manifest.json @@ -39,7 +39,8 @@ "LICS/1004.txt" : "ApplicationResourcePatches/LICS/1004.txt", "LICS/1005.txt" : "ApplicationResourcePatches/LICS/1005.txt", "LICS/1006.txt" : "ApplicationResourcePatches/LICS/1006.txt", - "STR$23/1006.txt" : "ApplicationResourcePatches/STR/1006.txt" + "STR$23/1006.txt" : "ApplicationResourcePatches/STR/1006.txt", + "snd$20/1063.wav" : "ApplicationResourcePatches/SND/1063.wav" }, "delete" : [ diff --git a/CMakeLists.txt b/CMakeLists.txt index a3480d5..093e836 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -56,7 +56,6 @@ add_library(PortabilityLayer STATIC PortabilityLayer/MemoryManager.cpp PortabilityLayer/MemReaderStream.cpp PortabilityLayer/MenuManager.cpp - PortabilityLayer/MMBlock.cpp PortabilityLayer/MMHandleBlock.cpp PortabilityLayer/PLApplication.cpp PortabilityLayer/PLButtonWidget.cpp diff --git a/GpApp/About.cpp b/GpApp/About.cpp index 42e8194..336b9b5 100644 --- a/GpApp/About.cpp +++ b/GpApp/About.cpp @@ -249,7 +249,7 @@ void DoAboutOpenSource(void) static const int kAboutOpenSourceDialogTemplateID = 2005; - const Rect windowRect = Rect::Create(0, 0, 324, 512); + const Rect windowRect = Rect::Create(0, 0, 348, 512); PortabilityLayer::WindowDef wdef = PortabilityLayer::WindowDef::Create(windowRect, PortabilityLayer::WindowStyleFlags::kAlert, true, 0, 0, PSTR("")); diff --git a/GpApp/GliderDefines.h b/GpApp/GliderDefines.h index 55944ff..7b9db0d 100644 --- a/GpApp/GliderDefines.h +++ b/GpApp/GliderDefines.h @@ -115,7 +115,8 @@ #define kTransInSound 60 // ее ее #define kBonusSound 61 // еееееее #define kHissSound 62 // -#define kTriggerSound 63 +#define kPingSound 63 // +#define kTriggerSound 64 // This must be the last one #define kHitWallPriority 100 // ееееее #define kScoreTikPriority 101 // ее @@ -177,6 +178,7 @@ #define kFollowPriority 904 #define kTransInPriority 905 #define kTransOutPriority 906 +#define kPingPriority 907 #define kTriggerPriority 999 #define kArrowCursor 0 diff --git a/GpApp/Sound.cpp b/GpApp/Sound.cpp index 5ac7e74..5a56b4e 100644 --- a/GpApp/Sound.cpp +++ b/GpApp/Sound.cpp @@ -23,7 +23,7 @@ #define kBaseBufferSoundID 1000 -#define kMaxSounds 64 +#define kMaxSounds 65 void CallBack0 (PortabilityLayer::AudioChannel *); @@ -38,7 +38,7 @@ IGpAudioBuffer *ParseAndConvertSound(const THandle &handle); PortabilityLayer::AudioChannel *channel0, *channel1, *channel2; IGpAudioBuffer *theSoundData[kMaxSounds]; short numSoundsLoaded; -Boolean soundLoaded[kMaxSounds], dontLoadSounds; +Boolean dontLoadSounds; Boolean channelOpen, isSoundOn, failedSound; //============================================================== Functions @@ -341,6 +341,14 @@ void CloseSoundChannels (void) channelOpen = false; } +//-------------------------------------------------------------- PingBeep + +void PingBeep (int duration) +{ + PlayPrioritySound(kPingSound, kPingPriority); +} + + //-------------------------------------------------------------- InitSound void InitSound (void) @@ -376,6 +384,8 @@ void InitSound (void) failedSound = true; } } + + SetBeepFunction (PingBeep); } //-------------------------------------------------------------- KillSound diff --git a/GpCommon/IGpSystemServices.h b/GpCommon/IGpSystemServices.h index e774e8d..76f64ac 100644 --- a/GpCommon/IGpSystemServices.h +++ b/GpCommon/IGpSystemServices.h @@ -26,7 +26,7 @@ public: virtual void *CreateThread(ThreadFunc_t threadFunc, void *context) = 0; virtual IGpThreadEvent *CreateThreadEvent(bool autoReset, bool startSignaled) = 0; virtual uint64_t GetFreeMemoryCosmetic() const = 0; // Returns free memory in bytes, does not have to be accurate - virtual void Beep() const = 0; + virtual bool Beep() const = 0; virtual bool IsTouchscreen() const = 0; virtual bool IsUsingMouseAsTouch() const = 0; virtual bool IsFullscreenPreferred() const = 0; diff --git a/PortabilityLayer/DialogManager.cpp b/PortabilityLayer/DialogManager.cpp index 18f0803..ad70cf2 100644 --- a/PortabilityLayer/DialogManager.cpp +++ b/PortabilityLayer/DialogManager.cpp @@ -13,6 +13,7 @@ #include "WindowDef.h" #include "WindowManager.h" +#include "PLApplication.h" #include "PLArrayView.h" #include "PLBigEndian.h" #include "PLButtonWidget.h" @@ -471,7 +472,7 @@ namespace PortabilityLayer Rect2i windowFullRect = WindowManager::GetInstance()->GetWindowFullRect(window); if (!windowFullRect.Contains(Vec2i(mouseEvent.m_x, mouseEvent.m_y))) { - PLDrivers::GetSystemServices()->Beep(); + SysBeep(1); continue; } } @@ -834,7 +835,7 @@ namespace PortabilityLayer // If sound index is 0, play no sound if (soundIndexes[0] != 0) - PLDrivers::GetSystemServices()->Beep(); + SysBeep(1); const Rect dialogRect = alertResData.m_rect.ToRect(); diff --git a/PortabilityLayer/FileBrowserUI.cpp b/PortabilityLayer/FileBrowserUI.cpp index d6cddea..e2a0004 100644 --- a/PortabilityLayer/FileBrowserUI.cpp +++ b/PortabilityLayer/FileBrowserUI.cpp @@ -21,6 +21,7 @@ #include "WindowDef.h" #include "MacRomanConversion.h" +#include "PLApplication.h" #include "PLArrayView.h" #include "PLControlDefinitions.h" #include "PLCore.h" @@ -756,7 +757,7 @@ namespace PortabilityLayer PLPasStr nameStr = editBox->GetString(); if (nameStr.Length() == 0 || !fs->ValidateFilePath(nameStr.Chars(), nameStr.Length())) { - PLDrivers::GetSystemServices()->Beep(); + SysBeep(1); FileBrowserUIImpl::PopUpAlert(Rect::Create(0, 0, 135, 327), kFileBrowserUIBadNameDialogTemplateID, nullptr); hit = -1; } @@ -772,7 +773,7 @@ namespace PortabilityLayer { DialogTextSubstitutions substitutions(nameStr); - PLDrivers::GetSystemServices()->Beep(); + SysBeep(1); int16_t subHit = FileBrowserUIImpl::PopUpAlert(Rect::Create(0, 0, 135, 327), kFileBrowserUIOverwriteDialogTemplateID, &substitutions); if (subHit == kOverwriteNoButton) @@ -783,7 +784,7 @@ namespace PortabilityLayer if ((mode == Mode_Open && hit == kOpenDeleteButton) || (mode == Mode_SaveWithDelete && hit == kSaveDeleteButton)) { - PLDrivers::GetSystemServices()->Beep(); + SysBeep(1); int16_t subHit = FileBrowserUIImpl::PopUpAlert(Rect::Create(0, 0, 135, 327), kFileBrowserUIDeleteDialogTemplateID, &substitutions); if (subHit == kOverwriteYesButton) diff --git a/PortabilityLayer/PLApplication.cpp b/PortabilityLayer/PLApplication.cpp index e743618..b82216e 100644 --- a/PortabilityLayer/PLApplication.cpp +++ b/PortabilityLayer/PLApplication.cpp @@ -18,9 +18,18 @@ namespace PortabilityLayer memcpy(dest + 1, src, sz); } } + + static BeepFunction_t gs_beepFunction = nullptr; } void SysBeep(int duration) { - PLDrivers::GetSystemServices()->Beep(); + if (!PLDrivers::GetSystemServices()->Beep()) + if (PortabilityLayer::gs_beepFunction != nullptr) + PortabilityLayer::gs_beepFunction(duration); +} + +void SetBeepFunction(BeepFunction_t beepFunction) +{ + PortabilityLayer::gs_beepFunction = beepFunction; } diff --git a/PortabilityLayer/PLApplication.h b/PortabilityLayer/PLApplication.h index 8f6e3bf..6e1351c 100644 --- a/PortabilityLayer/PLApplication.h +++ b/PortabilityLayer/PLApplication.h @@ -23,7 +23,11 @@ void PasStringCopy(const unsigned char *src, unsigned char *dest); template void PasStringCopy(const PortabilityLayer::PascalStrLiteral &src, unsigned char *dest); -void SysBeep(int duration); +void SysBeep(int duration); + +typedef void (*BeepFunction_t)(int duration); +void SetBeepFunction(BeepFunction_t beepFunction); + /////////////////////////////////////////////////////////////////////////////// #include "PascalStrLiteral.h" diff --git a/PortabilityLayer/PLSound.cpp b/PortabilityLayer/PLSound.cpp index 9b9b0fa..809f02f 100644 --- a/PortabilityLayer/PLSound.cpp +++ b/PortabilityLayer/PLSound.cpp @@ -180,6 +180,9 @@ namespace PortabilityLayer bool AudioChannelImpl::AddBuffer(IGpAudioBuffer *buffer, bool blocking) { + if (!buffer) + return false; + buffer->AddRef(); AudioCommand cmd;